From 598db5816664472e1649ef94b0ba4c5cc1b9f3b4 Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Thu, 13 Mar 2014 16:46:00 +0000 Subject: iio: force snprintf for PAGE_SIZE bufs This is a tiny preventative measure to make sure we can't write beyond PAGE_SIZE on the buffers being used in sysfs for iio. There is currently no way for this to happen, but the change makes this code more robust for the future. Signed-off-by: Kees Cook Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index ede16aec20fb..1375921d8261 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -340,7 +340,7 @@ ssize_t iio_enum_read(struct iio_dev *indio_dev, else if (i >= e->num_items) return -EINVAL; - return sprintf(buf, "%s\n", e->items[i]); + return snprintf(buf, PAGE_SIZE, "%s\n", e->items[i]); } EXPORT_SYMBOL_GPL(iio_enum_read); @@ -820,7 +820,7 @@ static ssize_t iio_show_dev_name(struct device *dev, char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); - return sprintf(buf, "%s\n", indio_dev->name); + return snprintf(buf, PAGE_SIZE, "%s\n", indio_dev->name); } static DEVICE_ATTR(name, S_IRUGO, iio_show_dev_name, NULL); -- cgit v1.2.3 From 43c7ecb1fa6b45633747773f055b8deb1c3e52be Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Wed, 3 Dec 2014 12:53:00 +0000 Subject: iio:as3935: Add DT binding docs for AS3935 driver Document compatible string, required and optional DT properties for AS3935 chipset driver. Signed-off-by: Matt Ranostay Acked-by: Rob Herring Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/proximity/as3935.txt | 28 ++++++++++++++++++++++ .../devicetree/bindings/vendor-prefixes.txt | 1 + 2 files changed, 29 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/proximity/as3935.txt diff --git a/Documentation/devicetree/bindings/iio/proximity/as3935.txt b/Documentation/devicetree/bindings/iio/proximity/as3935.txt new file mode 100644 index 000000000000..ae23dd8da736 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/proximity/as3935.txt @@ -0,0 +1,28 @@ +Austrian Microsystems AS3935 Franklin lightning sensor device driver + +Required properties: + - compatible: must be "ams,as3935" + - reg: SPI chip select number for the device + - spi-cpha: SPI Mode 1. Refer to spi/spi-bus.txt for generic SPI + slave node bindings. + - interrupt-parent : should be the phandle for the interrupt controller + - interrupts : the sole interrupt generated by the device + + Refer to interrupt-controller/interrupts.txt for generic + interrupt client node bindings. + +Optional properties: + - ams,tuning-capacitor-pf: Calibration tuning capacitor stepping + value 0 - 120pF. This will require using the calibration data from + the manufacturer. + +Example: + +as3935@0 { + compatible = "ams,as3935"; + reg = <0>; + spi-cpha; + interrupt-parent = <&gpio1>; + interrupts = <16 1>; + ams,tuning-capacitor-pf = <80>; +}; diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt index 40ce2df0e0e9..2025cee4b6b2 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.txt +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt @@ -11,6 +11,7 @@ ak Asahi Kasei Corp. allwinner Allwinner Technology Co., Ltd. altr Altera Corp. amcc Applied Micro Circuits Corporation (APM, formally AMCC) +ams AMS AG amstaos AMS-Taos Inc. apm Applied Micro Circuits Corporation (APM) arm ARM Ltd. -- cgit v1.2.3 From 24ddb0e4bba4e98d3f3a783846789520e796b164 Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Wed, 3 Dec 2014 12:53:00 +0000 Subject: iio: Add AS3935 lightning sensor support AS3935 chipset can detect lightning strikes and reports those back as events and the estimated distance to the storm. Signed-off-by: Matt Ranostay Reviewed-by: Marek Vasut Signed-off-by: Jonathan Cameron --- .../ABI/testing/sysfs-bus-iio-proximity-as3935 | 16 + drivers/iio/Kconfig | 1 + drivers/iio/Makefile | 1 + drivers/iio/proximity/Kconfig | 19 + drivers/iio/proximity/Makefile | 6 + drivers/iio/proximity/as3935.c | 456 +++++++++++++++++++++ 6 files changed, 499 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935 create mode 100644 drivers/iio/proximity/Kconfig create mode 100644 drivers/iio/proximity/Makefile create mode 100644 drivers/iio/proximity/as3935.c diff --git a/Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935 b/Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935 new file mode 100644 index 000000000000..6708c5e264aa --- /dev/null +++ b/Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935 @@ -0,0 +1,16 @@ +What /sys/bus/iio/devices/iio:deviceX/in_proximity_raw +Date: March 2014 +KernelVersion: 3.15 +Contact: Matt Ranostay +Description: + Get the current distance in meters of storm (1km steps) + 1000-40000 = distance in meters + +What /sys/bus/iio/devices/iio:deviceX/sensor_sensitivity +Date: March 2014 +KernelVersion: 3.15 +Contact: Matt Ranostay +Description: + Show or set the gain boost of the amp, from 0-31 range. + 18 = indoors (default) + 14 = outdoors diff --git a/drivers/iio/Kconfig b/drivers/iio/Kconfig index 5dd0e120a504..743485e4d6f8 100644 --- a/drivers/iio/Kconfig +++ b/drivers/iio/Kconfig @@ -74,6 +74,7 @@ if IIO_TRIGGER source "drivers/iio/trigger/Kconfig" endif #IIO_TRIGGER source "drivers/iio/pressure/Kconfig" +source "drivers/iio/proximity/Kconfig" source "drivers/iio/temperature/Kconfig" endif # IIO diff --git a/drivers/iio/Makefile b/drivers/iio/Makefile index 887d39090d75..698afc2d17ce 100644 --- a/drivers/iio/Makefile +++ b/drivers/iio/Makefile @@ -24,5 +24,6 @@ obj-y += light/ obj-y += magnetometer/ obj-y += orientation/ obj-y += pressure/ +obj-y += proximity/ obj-y += temperature/ obj-y += trigger/ diff --git a/drivers/iio/proximity/Kconfig b/drivers/iio/proximity/Kconfig new file mode 100644 index 000000000000..0c8cdf58f6a1 --- /dev/null +++ b/drivers/iio/proximity/Kconfig @@ -0,0 +1,19 @@ +# +# Proximity sensors +# + +menu "Lightning sensors" + +config AS3935 + tristate "AS3935 Franklin lightning sensor" + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER + depends on SPI + help + Say Y here to build SPI interface support for the Austrian + Microsystems AS3935 lightning detection sensor. + + To compile this driver as a module, choose M here: the + module will be called as3935 + +endmenu diff --git a/drivers/iio/proximity/Makefile b/drivers/iio/proximity/Makefile new file mode 100644 index 000000000000..743adee1c8bf --- /dev/null +++ b/drivers/iio/proximity/Makefile @@ -0,0 +1,6 @@ +# +# Makefile for IIO proximity sensors +# + +# When adding new entries keep the list in alphabetical order +obj-$(CONFIG_AS3935) += as3935.o diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c new file mode 100644 index 000000000000..bf677bfe8eb2 --- /dev/null +++ b/drivers/iio/proximity/as3935.c @@ -0,0 +1,456 @@ +/* + * as3935.c - Support for AS3935 Franklin lightning sensor + * + * Copyright (C) 2014 Matt Ranostay + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#define AS3935_AFE_GAIN 0x00 +#define AS3935_AFE_MASK 0x3F +#define AS3935_AFE_GAIN_MAX 0x1F +#define AS3935_AFE_PWR_BIT BIT(0) + +#define AS3935_INT 0x03 +#define AS3935_INT_MASK 0x07 +#define AS3935_EVENT_INT BIT(3) +#define AS3935_NOISE_INT BIT(1) + +#define AS3935_DATA 0x07 +#define AS3935_DATA_MASK 0x3F + +#define AS3935_TUNE_CAP 0x08 +#define AS3935_CALIBRATE 0x3D + +#define AS3935_WRITE_DATA BIT(15) +#define AS3935_READ_DATA BIT(14) +#define AS3935_ADDRESS(x) ((x) << 8) + +#define MAX_PF_CAP 120 +#define TUNE_CAP_DIV 8 + +struct as3935_state { + struct spi_device *spi; + struct iio_trigger *trig; + struct mutex lock; + struct delayed_work work; + + u32 tune_cap; + u8 buf[2] ____cacheline_aligned; +}; + +static const struct iio_chan_spec as3935_channels[] = { + { + .type = IIO_PROXIMITY, + .info_mask_separate = + BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_PROCESSED), + .scan_index = 0, + .scan_type = { + .sign = 'u', + .realbits = 6, + .storagebits = 8, + }, + }, + IIO_CHAN_SOFT_TIMESTAMP(1), +}; + +static int as3935_read(struct as3935_state *st, unsigned int reg, int *val) +{ + u8 cmd; + int ret; + + cmd = (AS3935_READ_DATA | AS3935_ADDRESS(reg)) >> 8; + ret = spi_w8r8(st->spi, cmd); + if (ret < 0) + return ret; + *val = ret; + + return 0; +}; + +static int as3935_write(struct as3935_state *st, + unsigned int reg, + unsigned int val) +{ + u8 *buf = st->buf; + + buf[0] = (AS3935_WRITE_DATA | AS3935_ADDRESS(reg)) >> 8; + buf[1] = val; + + return spi_write(st->spi, buf, 2); +}; + +static ssize_t as3935_sensor_sensitivity_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct as3935_state *st = iio_priv(dev_to_iio_dev(dev)); + int val, ret; + + ret = as3935_read(st, AS3935_AFE_GAIN, &val); + if (ret) + return ret; + val = (val & AS3935_AFE_MASK) >> 1; + + return sprintf(buf, "%d\n", val); +}; + +static ssize_t as3935_sensor_sensitivity_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t len) +{ + struct as3935_state *st = iio_priv(dev_to_iio_dev(dev)); + unsigned long val; + int ret; + + ret = kstrtoul((const char *) buf, 10, &val); + if (ret) + return -EINVAL; + + if (val > AS3935_AFE_GAIN_MAX) + return -EINVAL; + + as3935_write(st, AS3935_AFE_GAIN, val << 1); + + return len; +}; + +static IIO_DEVICE_ATTR(sensor_sensitivity, S_IRUGO | S_IWUSR, + as3935_sensor_sensitivity_show, as3935_sensor_sensitivity_store, 0); + + +static struct attribute *as3935_attributes[] = { + &iio_dev_attr_sensor_sensitivity.dev_attr.attr, + NULL, +}; + +static struct attribute_group as3935_attribute_group = { + .attrs = as3935_attributes, +}; + +static int as3935_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, + int *val2, + long m) +{ + struct as3935_state *st = iio_priv(indio_dev); + int ret; + + + switch (m) { + case IIO_CHAN_INFO_PROCESSED: + case IIO_CHAN_INFO_RAW: + *val2 = 0; + ret = as3935_read(st, AS3935_DATA, val); + if (ret) + return ret; + + if (m == IIO_CHAN_INFO_RAW) + return IIO_VAL_INT; + + /* storm out of range */ + if (*val == AS3935_DATA_MASK) + return -EINVAL; + *val *= 1000; + break; + default: + return -EINVAL; + } + + return IIO_VAL_INT; +} + +static const struct iio_info as3935_info = { + .driver_module = THIS_MODULE, + .attrs = &as3935_attribute_group, + .read_raw = &as3935_read_raw, +}; + +static irqreturn_t as3935_trigger_handler(int irq, void *private) +{ + struct iio_poll_func *pf = private; + struct iio_dev *indio_dev = pf->indio_dev; + struct as3935_state *st = iio_priv(indio_dev); + int val, ret; + + ret = as3935_read(st, AS3935_DATA, &val); + if (ret) + goto err_read; + val &= AS3935_DATA_MASK; + val *= 1000; + + iio_push_to_buffers_with_timestamp(indio_dev, &val, pf->timestamp); +err_read: + iio_trigger_notify_done(indio_dev->trig); + + return IRQ_HANDLED; +}; + +static const struct iio_trigger_ops iio_interrupt_trigger_ops = { + .owner = THIS_MODULE, +}; + +static void as3935_event_work(struct work_struct *work) +{ + struct as3935_state *st; + int val; + + st = container_of(work, struct as3935_state, work.work); + + as3935_read(st, AS3935_INT, &val); + val &= AS3935_INT_MASK; + + switch (val) { + case AS3935_EVENT_INT: + iio_trigger_poll(st->trig, iio_get_time_ns()); + break; + case AS3935_NOISE_INT: + dev_warn(&st->spi->dev, "noise level is too high"); + break; + } +}; + +static irqreturn_t as3935_interrupt_handler(int irq, void *private) +{ + struct iio_dev *indio_dev = private; + struct as3935_state *st = iio_priv(indio_dev); + + /* + * Delay work for >2 milliseconds after an interrupt to allow + * estimated distance to recalculated. + */ + + schedule_delayed_work(&st->work, msecs_to_jiffies(3)); + + return IRQ_HANDLED; +} + +static void calibrate_as3935(struct as3935_state *st) +{ + mutex_lock(&st->lock); + + /* mask disturber interrupt bit */ + as3935_write(st, AS3935_INT, BIT(5)); + + as3935_write(st, AS3935_CALIBRATE, 0x96); + as3935_write(st, AS3935_TUNE_CAP, + BIT(5) | (st->tune_cap / TUNE_CAP_DIV)); + + mdelay(2); + as3935_write(st, AS3935_TUNE_CAP, (st->tune_cap / TUNE_CAP_DIV)); + + mutex_unlock(&st->lock); +} + +#ifdef CONFIG_PM_SLEEP +static int as3935_suspend(struct spi_device *spi, pm_message_t msg) +{ + struct iio_dev *indio_dev = spi_get_drvdata(spi); + struct as3935_state *st = iio_priv(indio_dev); + int val, ret; + + mutex_lock(&st->lock); + ret = as3935_read(st, AS3935_AFE_GAIN, &val); + if (ret) + goto err_suspend; + val |= AS3935_AFE_PWR_BIT; + + ret = as3935_write(st, AS3935_AFE_GAIN, val); + +err_suspend: + mutex_unlock(&st->lock); + + return ret; +} + +static int as3935_resume(struct spi_device *spi) +{ + struct iio_dev *indio_dev = spi_get_drvdata(spi); + struct as3935_state *st = iio_priv(indio_dev); + int val, ret; + + mutex_lock(&st->lock); + ret = as3935_read(st, AS3935_AFE_GAIN, &val); + if (ret) + goto err_resume; + val &= ~AS3935_AFE_PWR_BIT; + ret = as3935_write(st, AS3935_AFE_GAIN, val); + +err_resume: + mutex_unlock(&st->lock); + + return ret; +} +#else +#define as3935_suspend NULL +#define as3935_resume NULL +#endif + +static int as3935_probe(struct spi_device *spi) +{ + struct iio_dev *indio_dev; + struct iio_trigger *trig; + struct as3935_state *st; + struct device_node *np = spi->dev.of_node; + int ret; + + /* Be sure lightning event interrupt is specified */ + if (!spi->irq) { + dev_err(&spi->dev, "unable to get event interrupt\n"); + return -EINVAL; + } + + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(st)); + if (!indio_dev) + return -ENOMEM; + + st = iio_priv(indio_dev); + st->spi = spi; + st->tune_cap = 0; + + spi_set_drvdata(spi, indio_dev); + mutex_init(&st->lock); + INIT_DELAYED_WORK(&st->work, as3935_event_work); + + ret = of_property_read_u32(np, + "ams,tuning-capacitor-pf", &st->tune_cap); + if (ret) { + st->tune_cap = 0; + dev_warn(&spi->dev, + "no tuning-capacitor-pf set, defaulting to %d", + st->tune_cap); + } + + if (st->tune_cap > MAX_PF_CAP) { + dev_err(&spi->dev, + "wrong tuning-capacitor-pf setting of %d\n", + st->tune_cap); + return -EINVAL; + } + + indio_dev->dev.parent = &spi->dev; + indio_dev->name = spi_get_device_id(spi)->name; + indio_dev->channels = as3935_channels; + indio_dev->num_channels = ARRAY_SIZE(as3935_channels); + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->info = &as3935_info; + + trig = devm_iio_trigger_alloc(&spi->dev, "%s-dev%d", + indio_dev->name, indio_dev->id); + + if (!trig) + return -ENOMEM; + + st->trig = trig; + trig->dev.parent = indio_dev->dev.parent; + iio_trigger_set_drvdata(trig, indio_dev); + trig->ops = &iio_interrupt_trigger_ops; + + ret = iio_trigger_register(trig); + if (ret) { + dev_err(&spi->dev, "failed to register trigger\n"); + return ret; + } + + ret = iio_triggered_buffer_setup(indio_dev, NULL, + &as3935_trigger_handler, NULL); + + if (ret) { + dev_err(&spi->dev, "cannot setup iio trigger\n"); + goto unregister_trigger; + } + + calibrate_as3935(st); + + ret = devm_request_irq(&spi->dev, spi->irq, + &as3935_interrupt_handler, + IRQF_TRIGGER_RISING, + dev_name(&spi->dev), + indio_dev); + + if (ret) { + dev_err(&spi->dev, "unable to request irq\n"); + goto unregister_buffer; + } + + ret = iio_device_register(indio_dev); + if (ret < 0) { + dev_err(&spi->dev, "unable to register device\n"); + goto unregister_buffer; + } + return 0; + +unregister_buffer: + iio_triggered_buffer_cleanup(indio_dev); + +unregister_trigger: + iio_trigger_unregister(st->trig); + + return ret; +}; + +static int as3935_remove(struct spi_device *spi) +{ + struct iio_dev *indio_dev = spi_get_drvdata(spi); + struct as3935_state *st = iio_priv(indio_dev); + + iio_device_unregister(indio_dev); + iio_triggered_buffer_cleanup(indio_dev); + iio_trigger_unregister(st->trig); + + return 0; +}; + +static const struct spi_device_id as3935_id[] = { + {"as3935", 0}, + {}, +}; +MODULE_DEVICE_TABLE(spi, as3935_id); + +static struct spi_driver as3935_driver = { + .driver = { + .name = "as3935", + .owner = THIS_MODULE, + }, + .probe = as3935_probe, + .remove = as3935_remove, + .id_table = as3935_id, + .suspend = as3935_suspend, + .resume = as3935_resume, +}; +module_spi_driver(as3935_driver); + +MODULE_AUTHOR("Matt Ranostay "); +MODULE_DESCRIPTION("AS3935 lightning sensor"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("spi:as3935"); -- cgit v1.2.3 From c0a6b7ee9498269e4bf9a7e6676f2f45edca2f1a Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Fri, 3 Oct 2014 17:25:00 +0100 Subject: iio: documentation: Add ABI documentation for *_mean_raw Add ABI documentation for in_*_mean_raw files, which are already supported and used in the kernel for some time. Signed-off-by: Sebastian Reichel Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index 6e02c5029152..58ba33300305 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -210,6 +210,14 @@ Contact: linux-iio@vger.kernel.org Description: Scaled humidity measurement in milli percent. +What: /sys/bus/iio/devices/iio:deviceX/in_X_mean_raw +KernelVersion: 3.5 +Contact: linux-iio@vger.kernel.org +Description: + Averaged raw measurement from channel X. The number of values + used for averaging is device specific. The converting rules for + normal raw values also applies to the averaged raw values. + What: /sys/bus/iio/devices/iio:deviceX/in_accel_offset What: /sys/bus/iio/devices/iio:deviceX/in_accel_x_offset What: /sys/bus/iio/devices/iio:deviceX/in_accel_y_offset -- cgit v1.2.3 From 476d4af22cec8a9ebc90137712e5ab7070b7379d Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Fri, 3 Oct 2014 17:25:00 +0100 Subject: iio: inkern: add iio_read_channel_average_raw Add iio_read_channel_average_raw to support reading averaged raw values in consumer drivers. Signed-off-by: Sebastian Reichel Signed-off-by: Jonathan Cameron --- drivers/iio/inkern.c | 18 ++++++++++++++++++ include/linux/iio/consumer.h | 13 +++++++++++++ 2 files changed, 31 insertions(+) diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index 0cf5f8e06cfc..adeba5a0ecf7 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -443,6 +443,24 @@ err_unlock: } EXPORT_SYMBOL_GPL(iio_read_channel_raw); +int iio_read_channel_average_raw(struct iio_channel *chan, int *val) +{ + int ret; + + mutex_lock(&chan->indio_dev->info_exist_lock); + if (chan->indio_dev->info == NULL) { + ret = -ENODEV; + goto err_unlock; + } + + ret = iio_channel_read(chan, val, NULL, IIO_CHAN_INFO_AVERAGE_RAW); +err_unlock: + mutex_unlock(&chan->indio_dev->info_exist_lock); + + return ret; +} +EXPORT_SYMBOL_GPL(iio_read_channel_average_raw); + static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan, int raw, int *processed, unsigned int scale) { diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h index 2752b1fd12be..651f9a0e2765 100644 --- a/include/linux/iio/consumer.h +++ b/include/linux/iio/consumer.h @@ -122,6 +122,19 @@ struct iio_channel int iio_read_channel_raw(struct iio_channel *chan, int *val); +/** + * iio_read_channel_average_raw() - read from a given channel + * @chan: The channel being queried. + * @val: Value read back. + * + * Note raw reads from iio channels are in adc counts and hence + * scale will need to be applied if standard units required. + * + * In opposit to the normal iio_read_channel_raw this function + * returns the average of multiple reads. + */ +int iio_read_channel_average_raw(struct iio_channel *chan, int *val); + /** * iio_read_channel_processed() - read processed value from a given channel * @chan: The channel being queried. -- cgit v1.2.3 From 396590b3bc919800d40464559f2a9c16938a193f Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 3 Oct 2014 10:31:00 +0100 Subject: staging:iio:ad799x: Move ring functions to the main file The ad799x_ring.c file is pretty much only one function these days. No need to keep it in a separate file. Since there is then only one user of the header left also move everything from the header to the main file. Signed-off-by: Lars-Peter Clausen Acked-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/Kconfig | 13 +-- drivers/staging/iio/adc/Makefile | 1 - drivers/staging/iio/adc/ad799x.h | 121 ---------------------------- drivers/staging/iio/adc/ad799x_core.c | 145 +++++++++++++++++++++++++++++++++- drivers/staging/iio/adc/ad799x_ring.c | 84 -------------------- 5 files changed, 143 insertions(+), 221 deletions(-) delete mode 100644 drivers/staging/iio/adc/ad799x.h delete mode 100644 drivers/staging/iio/adc/ad799x_ring.c diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig index 363329808a4f..ed23cceba17d 100644 --- a/drivers/staging/iio/adc/Kconfig +++ b/drivers/staging/iio/adc/Kconfig @@ -40,23 +40,14 @@ config AD7606_IFACE_SPI config AD799X tristate "Analog Devices AD799x ADC driver" depends on I2C - select IIO_TRIGGER if IIO_BUFFER - select AD799X_RING_BUFFER + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER help Say yes here to build support for Analog Devices: ad7991, ad7995, ad7999, ad7992, ad7993, ad7994, ad7997, ad7998 i2c analog to digital converters (ADC). Provides direct access via sysfs. -config AD799X_RING_BUFFER - bool "Analog Devices AD799x: use ring buffer" - depends on AD799X - select IIO_BUFFER - select IIO_TRIGGERED_BUFFER - help - Say yes here to include ring buffer support in the AD799X - ADC driver. - config AD7780 tristate "Analog Devices AD7780 and similar ADCs driver" depends on SPI diff --git a/drivers/staging/iio/adc/Makefile b/drivers/staging/iio/adc/Makefile index 3e9fb143d25b..b2d35f813292 100644 --- a/drivers/staging/iio/adc/Makefile +++ b/drivers/staging/iio/adc/Makefile @@ -9,7 +9,6 @@ ad7606-$(CONFIG_AD7606_IFACE_SPI) += ad7606_spi.o obj-$(CONFIG_AD7606) += ad7606.o ad799x-y := ad799x_core.o -ad799x-$(CONFIG_AD799X_RING_BUFFER) += ad799x_ring.o obj-$(CONFIG_AD799X) += ad799x.o obj-$(CONFIG_AD7291) += ad7291.o diff --git a/drivers/staging/iio/adc/ad799x.h b/drivers/staging/iio/adc/ad799x.h deleted file mode 100644 index fc8c85298feb..000000000000 --- a/drivers/staging/iio/adc/ad799x.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) 2010-2011 Michael Hennerich, Analog Devices Inc. - * Copyright (C) 2008-2010 Jonathan Cameron - * - * 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. - * - * ad799x.h - */ - -#ifndef _AD799X_H_ -#define _AD799X_H_ - -#define AD799X_CHANNEL_SHIFT 4 -#define AD799X_STORAGEBITS 16 -/* - * AD7991, AD7995 and AD7999 defines - */ - -#define AD7991_REF_SEL 0x08 -#define AD7991_FLTR 0x04 -#define AD7991_BIT_TRIAL_DELAY 0x02 -#define AD7991_SAMPLE_DELAY 0x01 - -/* - * AD7992, AD7993, AD7994, AD7997 and AD7998 defines - */ - -#define AD7998_FLTR 0x08 -#define AD7998_ALERT_EN 0x04 -#define AD7998_BUSY_ALERT 0x02 -#define AD7998_BUSY_ALERT_POL 0x01 - -#define AD7998_CONV_RES_REG 0x0 -#define AD7998_ALERT_STAT_REG 0x1 -#define AD7998_CONF_REG 0x2 -#define AD7998_CYCLE_TMR_REG 0x3 - -#define AD7998_DATALOW_REG(x) ((x) * 3 + 0x4) -#define AD7998_DATAHIGH_REG(x) ((x) * 3 + 0x5) -#define AD7998_HYST_REG(x) ((x) * 3 + 0x6) - -#define AD7998_CYC_MASK 0x7 -#define AD7998_CYC_DIS 0x0 -#define AD7998_CYC_TCONF_32 0x1 -#define AD7998_CYC_TCONF_64 0x2 -#define AD7998_CYC_TCONF_128 0x3 -#define AD7998_CYC_TCONF_256 0x4 -#define AD7998_CYC_TCONF_512 0x5 -#define AD7998_CYC_TCONF_1024 0x6 -#define AD7998_CYC_TCONF_2048 0x7 - -#define AD7998_ALERT_STAT_CLEAR 0xFF - -/* - * AD7997 and AD7997 defines - */ - -#define AD7997_8_READ_SINGLE 0x80 -#define AD7997_8_READ_SEQUENCE 0x70 -/* TODO: move this into a common header */ -#define RES_MASK(bits) ((1 << (bits)) - 1) - -enum { - ad7991, - ad7995, - ad7999, - ad7992, - ad7993, - ad7994, - ad7997, - ad7998 -}; - -struct ad799x_state; - -/** - * struct ad799x_chip_info - chip specifc information - * @channel: channel specification - * @num_channels: number of channels - * @monitor_mode: whether the chip supports monitor interrupts - * @default_config: device default configuration - * @event_attrs: pointer to the monitor event attribute group - */ - -struct ad799x_chip_info { - struct iio_chan_spec channel[9]; - int num_channels; - u16 default_config; - const struct iio_info *info; -}; - -struct ad799x_state { - struct i2c_client *client; - const struct ad799x_chip_info *chip_info; - struct regulator *reg; - struct regulator *vref; - unsigned id; - u16 config; - - u8 *rx_buf; - unsigned int transfer_size; -}; - -#ifdef CONFIG_AD799X_RING_BUFFER -int ad799x_register_ring_funcs_and_init(struct iio_dev *indio_dev); -void ad799x_ring_cleanup(struct iio_dev *indio_dev); -#else /* CONFIG_AD799X_RING_BUFFER */ - -static inline int -ad799x_register_ring_funcs_and_init(struct iio_dev *indio_dev) -{ - return 0; -} - -static inline void ad799x_ring_cleanup(struct iio_dev *indio_dev) -{ -} -#endif /* CONFIG_AD799X_RING_BUFFER */ -#endif /* _AD799X_H_ */ diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index 979ec77d6c2d..bcbf6102efed 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -37,8 +37,144 @@ #include #include #include +#include +#include -#include "ad799x.h" +#define AD799X_CHANNEL_SHIFT 4 +#define AD799X_STORAGEBITS 16 +/* + * AD7991, AD7995 and AD7999 defines + */ + +#define AD7991_REF_SEL 0x08 +#define AD7991_FLTR 0x04 +#define AD7991_BIT_TRIAL_DELAY 0x02 +#define AD7991_SAMPLE_DELAY 0x01 + +/* + * AD7992, AD7993, AD7994, AD7997 and AD7998 defines + */ + +#define AD7998_FLTR 0x08 +#define AD7998_ALERT_EN 0x04 +#define AD7998_BUSY_ALERT 0x02 +#define AD7998_BUSY_ALERT_POL 0x01 + +#define AD7998_CONV_RES_REG 0x0 +#define AD7998_ALERT_STAT_REG 0x1 +#define AD7998_CONF_REG 0x2 +#define AD7998_CYCLE_TMR_REG 0x3 + +#define AD7998_DATALOW_REG(x) ((x) * 3 + 0x4) +#define AD7998_DATAHIGH_REG(x) ((x) * 3 + 0x5) +#define AD7998_HYST_REG(x) ((x) * 3 + 0x6) + +#define AD7998_CYC_MASK 0x7 +#define AD7998_CYC_DIS 0x0 +#define AD7998_CYC_TCONF_32 0x1 +#define AD7998_CYC_TCONF_64 0x2 +#define AD7998_CYC_TCONF_128 0x3 +#define AD7998_CYC_TCONF_256 0x4 +#define AD7998_CYC_TCONF_512 0x5 +#define AD7998_CYC_TCONF_1024 0x6 +#define AD7998_CYC_TCONF_2048 0x7 + +#define AD7998_ALERT_STAT_CLEAR 0xFF + +/* + * AD7997 and AD7997 defines + */ + +#define AD7997_8_READ_SINGLE 0x80 +#define AD7997_8_READ_SEQUENCE 0x70 +/* TODO: move this into a common header */ +#define RES_MASK(bits) ((1 << (bits)) - 1) + +enum { + ad7991, + ad7995, + ad7999, + ad7992, + ad7993, + ad7994, + ad7997, + ad7998 +}; + +/** + * struct ad799x_chip_info - chip specifc information + * @channel: channel specification + * @num_channels: number of channels + * @monitor_mode: whether the chip supports monitor interrupts + * @default_config: device default configuration + * @event_attrs: pointer to the monitor event attribute group + */ +struct ad799x_chip_info { + struct iio_chan_spec channel[9]; + int num_channels; + u16 default_config; + const struct iio_info *info; +}; + +struct ad799x_state { + struct i2c_client *client; + const struct ad799x_chip_info *chip_info; + struct regulator *reg; + struct regulator *vref; + unsigned id; + u16 config; + + u8 *rx_buf; + unsigned int transfer_size; +}; + +/** + * ad799x_trigger_handler() bh of trigger launched polling to ring buffer + * + * Currently there is no option in this driver to disable the saving of + * timestamps within the ring. + **/ +static irqreturn_t ad799x_trigger_handler(int irq, void *p) +{ + struct iio_poll_func *pf = p; + struct iio_dev *indio_dev = pf->indio_dev; + struct ad799x_state *st = iio_priv(indio_dev); + int b_sent; + u8 cmd; + + switch (st->id) { + case ad7991: + case ad7995: + case ad7999: + cmd = st->config | + (*indio_dev->active_scan_mask << AD799X_CHANNEL_SHIFT); + break; + case ad7992: + case ad7993: + case ad7994: + cmd = (*indio_dev->active_scan_mask << AD799X_CHANNEL_SHIFT) | + AD7998_CONV_RES_REG; + break; + case ad7997: + case ad7998: + cmd = AD7997_8_READ_SEQUENCE | AD7998_CONV_RES_REG; + break; + default: + cmd = 0; + } + + b_sent = i2c_smbus_read_i2c_block_data(st->client, + cmd, st->transfer_size, st->rx_buf); + if (b_sent < 0) + goto out; + + iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf, + iio_get_time_ns()); +out: + iio_trigger_notify_done(indio_dev->trig); + + return IRQ_HANDLED; +} /* * ad799x register access by I2C @@ -578,7 +714,8 @@ static int ad799x_probe(struct i2c_client *client, indio_dev->channels = st->chip_info->channel; indio_dev->num_channels = st->chip_info->num_channels; - ret = ad799x_register_ring_funcs_and_init(indio_dev); + ret = iio_triggered_buffer_setup(indio_dev, NULL, + &ad799x_trigger_handler, NULL); if (ret) goto error_disable_reg; @@ -601,7 +738,7 @@ static int ad799x_probe(struct i2c_client *client, return 0; error_cleanup_ring: - ad799x_ring_cleanup(indio_dev); + iio_triggered_buffer_cleanup(indio_dev); error_disable_reg: if (!IS_ERR(st->vref)) regulator_disable(st->vref); @@ -618,7 +755,7 @@ static int ad799x_remove(struct i2c_client *client) iio_device_unregister(indio_dev); - ad799x_ring_cleanup(indio_dev); + iio_triggered_buffer_cleanup(indio_dev); if (!IS_ERR(st->vref)) regulator_disable(st->vref); if (!IS_ERR(st->reg)) diff --git a/drivers/staging/iio/adc/ad799x_ring.c b/drivers/staging/iio/adc/ad799x_ring.c deleted file mode 100644 index 0ff6c03a483e..000000000000 --- a/drivers/staging/iio/adc/ad799x_ring.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2010-2012 Michael Hennerich, Analog Devices Inc. - * Copyright (C) 2008-2010 Jonathan Cameron - * - * 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. - * - * ad799x_ring.c - */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "ad799x.h" - -/** - * ad799x_trigger_handler() bh of trigger launched polling to ring buffer - * - * Currently there is no option in this driver to disable the saving of - * timestamps within the ring. - **/ - -static irqreturn_t ad799x_trigger_handler(int irq, void *p) -{ - struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->indio_dev; - struct ad799x_state *st = iio_priv(indio_dev); - int b_sent; - u8 cmd; - - switch (st->id) { - case ad7991: - case ad7995: - case ad7999: - cmd = st->config | - (*indio_dev->active_scan_mask << AD799X_CHANNEL_SHIFT); - break; - case ad7992: - case ad7993: - case ad7994: - cmd = (*indio_dev->active_scan_mask << AD799X_CHANNEL_SHIFT) | - AD7998_CONV_RES_REG; - break; - case ad7997: - case ad7998: - cmd = AD7997_8_READ_SEQUENCE | AD7998_CONV_RES_REG; - break; - default: - cmd = 0; - } - - b_sent = i2c_smbus_read_i2c_block_data(st->client, - cmd, st->transfer_size, st->rx_buf); - if (b_sent < 0) - goto out; - - iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf, - iio_get_time_ns()); -out: - iio_trigger_notify_done(indio_dev->trig); - - return IRQ_HANDLED; -} - -int ad799x_register_ring_funcs_and_init(struct iio_dev *indio_dev) -{ - return iio_triggered_buffer_setup(indio_dev, NULL, - &ad799x_trigger_handler, NULL); -} - -void ad799x_ring_cleanup(struct iio_dev *indio_dev) -{ - iio_triggered_buffer_cleanup(indio_dev); -} -- cgit v1.2.3 From bd75afaa314b2743c5379df3ccc84fab03126b71 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 3 Oct 2014 10:31:00 +0100 Subject: staging:iio: Move ad799x driver out of staging The driver is now at a reasonable quality level. Move it out of staging. Signed-off-by: Lars-Peter Clausen Acked-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- drivers/iio/adc/Kconfig | 11 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/ad799x.c | 794 ++++++++++++++++++++++++++++++++++ drivers/staging/iio/adc/Kconfig | 11 - drivers/staging/iio/adc/Makefile | 3 - drivers/staging/iio/adc/ad799x_core.c | 794 ---------------------------------- 6 files changed, 806 insertions(+), 808 deletions(-) create mode 100644 drivers/iio/adc/ad799x.c delete mode 100644 drivers/staging/iio/adc/ad799x_core.c diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 555320659c99..a0368119c275 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -96,6 +96,17 @@ config AD7923 To compile this driver as a module, choose M here: the module will be called ad7923. +config AD799X + tristate "Analog Devices AD799x ADC driver" + depends on I2C + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER + help + Say yes here to build support for Analog Devices: + ad7991, ad7995, ad7999, ad7992, ad7993, ad7994, ad7997, ad7998 + i2c analog to digital converters (ADC). Provides direct access + via sysfs. + config AT91_ADC tristate "Atmel AT91 ADC" depends on ARCH_AT91 diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index 89f1216e636a..1e2fc8912825 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -11,6 +11,7 @@ obj-$(CONFIG_AD7476) += ad7476.o obj-$(CONFIG_AD7791) += ad7791.o obj-$(CONFIG_AD7793) += ad7793.o obj-$(CONFIG_AD7887) += ad7887.o +obj-$(CONFIG_AD799X) += ad799x.o obj-$(CONFIG_AT91_ADC) += at91_adc.o obj-$(CONFIG_EXYNOS_ADC) += exynos_adc.o obj-$(CONFIG_LP8788_ADC) += lp8788_adc.o diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c new file mode 100644 index 000000000000..bcbf6102efed --- /dev/null +++ b/drivers/iio/adc/ad799x.c @@ -0,0 +1,794 @@ +/* + * iio/adc/ad799x.c + * Copyright (C) 2010-2011 Michael Hennerich, Analog Devices Inc. + * + * based on iio/adc/max1363 + * Copyright (C) 2008-2010 Jonathan Cameron + * + * based on linux/drivers/i2c/chips/max123x + * Copyright (C) 2002-2004 Stefan Eletzhofer + * + * based on linux/drivers/acron/char/pcf8583.c + * Copyright (C) 2000 Russell King + * + * 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. + * + * ad799x.c + * + * Support for ad7991, ad7995, ad7999, ad7992, ad7993, ad7994, ad7997, + * ad7998 and similar chips. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#define AD799X_CHANNEL_SHIFT 4 +#define AD799X_STORAGEBITS 16 +/* + * AD7991, AD7995 and AD7999 defines + */ + +#define AD7991_REF_SEL 0x08 +#define AD7991_FLTR 0x04 +#define AD7991_BIT_TRIAL_DELAY 0x02 +#define AD7991_SAMPLE_DELAY 0x01 + +/* + * AD7992, AD7993, AD7994, AD7997 and AD7998 defines + */ + +#define AD7998_FLTR 0x08 +#define AD7998_ALERT_EN 0x04 +#define AD7998_BUSY_ALERT 0x02 +#define AD7998_BUSY_ALERT_POL 0x01 + +#define AD7998_CONV_RES_REG 0x0 +#define AD7998_ALERT_STAT_REG 0x1 +#define AD7998_CONF_REG 0x2 +#define AD7998_CYCLE_TMR_REG 0x3 + +#define AD7998_DATALOW_REG(x) ((x) * 3 + 0x4) +#define AD7998_DATAHIGH_REG(x) ((x) * 3 + 0x5) +#define AD7998_HYST_REG(x) ((x) * 3 + 0x6) + +#define AD7998_CYC_MASK 0x7 +#define AD7998_CYC_DIS 0x0 +#define AD7998_CYC_TCONF_32 0x1 +#define AD7998_CYC_TCONF_64 0x2 +#define AD7998_CYC_TCONF_128 0x3 +#define AD7998_CYC_TCONF_256 0x4 +#define AD7998_CYC_TCONF_512 0x5 +#define AD7998_CYC_TCONF_1024 0x6 +#define AD7998_CYC_TCONF_2048 0x7 + +#define AD7998_ALERT_STAT_CLEAR 0xFF + +/* + * AD7997 and AD7997 defines + */ + +#define AD7997_8_READ_SINGLE 0x80 +#define AD7997_8_READ_SEQUENCE 0x70 +/* TODO: move this into a common header */ +#define RES_MASK(bits) ((1 << (bits)) - 1) + +enum { + ad7991, + ad7995, + ad7999, + ad7992, + ad7993, + ad7994, + ad7997, + ad7998 +}; + +/** + * struct ad799x_chip_info - chip specifc information + * @channel: channel specification + * @num_channels: number of channels + * @monitor_mode: whether the chip supports monitor interrupts + * @default_config: device default configuration + * @event_attrs: pointer to the monitor event attribute group + */ +struct ad799x_chip_info { + struct iio_chan_spec channel[9]; + int num_channels; + u16 default_config; + const struct iio_info *info; +}; + +struct ad799x_state { + struct i2c_client *client; + const struct ad799x_chip_info *chip_info; + struct regulator *reg; + struct regulator *vref; + unsigned id; + u16 config; + + u8 *rx_buf; + unsigned int transfer_size; +}; + +/** + * ad799x_trigger_handler() bh of trigger launched polling to ring buffer + * + * Currently there is no option in this driver to disable the saving of + * timestamps within the ring. + **/ +static irqreturn_t ad799x_trigger_handler(int irq, void *p) +{ + struct iio_poll_func *pf = p; + struct iio_dev *indio_dev = pf->indio_dev; + struct ad799x_state *st = iio_priv(indio_dev); + int b_sent; + u8 cmd; + + switch (st->id) { + case ad7991: + case ad7995: + case ad7999: + cmd = st->config | + (*indio_dev->active_scan_mask << AD799X_CHANNEL_SHIFT); + break; + case ad7992: + case ad7993: + case ad7994: + cmd = (*indio_dev->active_scan_mask << AD799X_CHANNEL_SHIFT) | + AD7998_CONV_RES_REG; + break; + case ad7997: + case ad7998: + cmd = AD7997_8_READ_SEQUENCE | AD7998_CONV_RES_REG; + break; + default: + cmd = 0; + } + + b_sent = i2c_smbus_read_i2c_block_data(st->client, + cmd, st->transfer_size, st->rx_buf); + if (b_sent < 0) + goto out; + + iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf, + iio_get_time_ns()); +out: + iio_trigger_notify_done(indio_dev->trig); + + return IRQ_HANDLED; +} + +/* + * ad799x register access by I2C + */ +static int ad799x_i2c_read16(struct ad799x_state *st, u8 reg, u16 *data) +{ + struct i2c_client *client = st->client; + int ret = 0; + + ret = i2c_smbus_read_word_swapped(client, reg); + if (ret < 0) { + dev_err(&client->dev, "I2C read error\n"); + return ret; + } + + *data = (u16)ret; + + return 0; +} + +static int ad799x_i2c_read8(struct ad799x_state *st, u8 reg, u8 *data) +{ + struct i2c_client *client = st->client; + int ret = 0; + + ret = i2c_smbus_read_byte_data(client, reg); + if (ret < 0) { + dev_err(&client->dev, "I2C read error\n"); + return ret; + } + + *data = (u8)ret; + + return 0; +} + +static int ad799x_i2c_write16(struct ad799x_state *st, u8 reg, u16 data) +{ + struct i2c_client *client = st->client; + int ret = 0; + + ret = i2c_smbus_write_word_swapped(client, reg, data); + if (ret < 0) + dev_err(&client->dev, "I2C write error\n"); + + return ret; +} + +static int ad799x_i2c_write8(struct ad799x_state *st, u8 reg, u8 data) +{ + struct i2c_client *client = st->client; + int ret = 0; + + ret = i2c_smbus_write_byte_data(client, reg, data); + if (ret < 0) + dev_err(&client->dev, "I2C write error\n"); + + return ret; +} + +static int ad7997_8_update_scan_mode(struct iio_dev *indio_dev, + const unsigned long *scan_mask) +{ + struct ad799x_state *st = iio_priv(indio_dev); + + kfree(st->rx_buf); + st->rx_buf = kmalloc(indio_dev->scan_bytes, GFP_KERNEL); + if (!st->rx_buf) + return -ENOMEM; + + st->transfer_size = bitmap_weight(scan_mask, indio_dev->masklength) * 2; + + switch (st->id) { + case ad7997: + case ad7998: + return ad799x_i2c_write16(st, AD7998_CONF_REG, + st->config | (*scan_mask << AD799X_CHANNEL_SHIFT)); + default: + break; + } + + return 0; +} + +static int ad799x_scan_direct(struct ad799x_state *st, unsigned ch) +{ + u16 rxbuf; + u8 cmd; + int ret; + + switch (st->id) { + case ad7991: + case ad7995: + case ad7999: + cmd = st->config | ((1 << ch) << AD799X_CHANNEL_SHIFT); + break; + case ad7992: + case ad7993: + case ad7994: + cmd = (1 << ch) << AD799X_CHANNEL_SHIFT; + break; + case ad7997: + case ad7998: + cmd = (ch << AD799X_CHANNEL_SHIFT) | AD7997_8_READ_SINGLE; + break; + default: + return -EINVAL; + } + + ret = ad799x_i2c_read16(st, cmd, &rxbuf); + if (ret < 0) + return ret; + + return rxbuf; +} + +static int ad799x_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, + int *val2, + long m) +{ + int ret; + struct ad799x_state *st = iio_priv(indio_dev); + + switch (m) { + case IIO_CHAN_INFO_RAW: + mutex_lock(&indio_dev->mlock); + if (iio_buffer_enabled(indio_dev)) + ret = -EBUSY; + else + ret = ad799x_scan_direct(st, chan->scan_index); + mutex_unlock(&indio_dev->mlock); + + if (ret < 0) + return ret; + *val = (ret >> chan->scan_type.shift) & + RES_MASK(chan->scan_type.realbits); + return IIO_VAL_INT; + case IIO_CHAN_INFO_SCALE: + ret = regulator_get_voltage(st->vref); + if (ret < 0) + return ret; + *val = ret / 1000; + *val2 = chan->scan_type.realbits; + return IIO_VAL_FRACTIONAL_LOG2; + } + return -EINVAL; +} +static const unsigned int ad7998_frequencies[] = { + [AD7998_CYC_DIS] = 0, + [AD7998_CYC_TCONF_32] = 15625, + [AD7998_CYC_TCONF_64] = 7812, + [AD7998_CYC_TCONF_128] = 3906, + [AD7998_CYC_TCONF_512] = 976, + [AD7998_CYC_TCONF_1024] = 488, + [AD7998_CYC_TCONF_2048] = 244, +}; +static ssize_t ad799x_read_frequency(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct ad799x_state *st = iio_priv(indio_dev); + + int ret; + u8 val; + ret = ad799x_i2c_read8(st, AD7998_CYCLE_TMR_REG, &val); + if (ret) + return ret; + + val &= AD7998_CYC_MASK; + + return sprintf(buf, "%u\n", ad7998_frequencies[val]); +} + +static ssize_t ad799x_write_frequency(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t len) +{ + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct ad799x_state *st = iio_priv(indio_dev); + + long val; + int ret, i; + u8 t; + + ret = kstrtol(buf, 10, &val); + if (ret) + return ret; + + mutex_lock(&indio_dev->mlock); + ret = ad799x_i2c_read8(st, AD7998_CYCLE_TMR_REG, &t); + if (ret) + goto error_ret_mutex; + /* Wipe the bits clean */ + t &= ~AD7998_CYC_MASK; + + for (i = 0; i < ARRAY_SIZE(ad7998_frequencies); i++) + if (val == ad7998_frequencies[i]) + break; + if (i == ARRAY_SIZE(ad7998_frequencies)) { + ret = -EINVAL; + goto error_ret_mutex; + } + t |= i; + ret = ad799x_i2c_write8(st, AD7998_CYCLE_TMR_REG, t); + +error_ret_mutex: + mutex_unlock(&indio_dev->mlock); + + return ret ? ret : len; +} + +static int ad799x_read_event_config(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, + enum iio_event_type type, + enum iio_event_direction dir) +{ + return 1; +} + +static unsigned int ad799x_threshold_reg(const struct iio_chan_spec *chan, + enum iio_event_direction dir, + enum iio_event_info info) +{ + switch (info) { + case IIO_EV_INFO_VALUE: + if (dir == IIO_EV_DIR_FALLING) + return AD7998_DATALOW_REG(chan->channel); + else + return AD7998_DATAHIGH_REG(chan->channel); + case IIO_EV_INFO_HYSTERESIS: + return AD7998_HYST_REG(chan->channel); + default: + return -EINVAL; + } + + return 0; +} + +static int ad799x_write_event_value(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, + enum iio_event_type type, + enum iio_event_direction dir, + enum iio_event_info info, + int val, int val2) +{ + int ret; + struct ad799x_state *st = iio_priv(indio_dev); + + mutex_lock(&indio_dev->mlock); + ret = ad799x_i2c_write16(st, ad799x_threshold_reg(chan, dir, info), + val); + mutex_unlock(&indio_dev->mlock); + + return ret; +} + +static int ad799x_read_event_value(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, + enum iio_event_type type, + enum iio_event_direction dir, + enum iio_event_info info, + int *val, int *val2) +{ + int ret; + struct ad799x_state *st = iio_priv(indio_dev); + u16 valin; + + mutex_lock(&indio_dev->mlock); + ret = ad799x_i2c_read16(st, ad799x_threshold_reg(chan, dir, info), + &valin); + mutex_unlock(&indio_dev->mlock); + if (ret < 0) + return ret; + *val = valin; + + return IIO_VAL_INT; +} + +static irqreturn_t ad799x_event_handler(int irq, void *private) +{ + struct iio_dev *indio_dev = private; + struct ad799x_state *st = iio_priv(private); + u8 status; + int i, ret; + + ret = ad799x_i2c_read8(st, AD7998_ALERT_STAT_REG, &status); + if (ret) + goto done; + + if (!status) + goto done; + + ad799x_i2c_write8(st, AD7998_ALERT_STAT_REG, AD7998_ALERT_STAT_CLEAR); + + for (i = 0; i < 8; i++) { + if (status & (1 << i)) + iio_push_event(indio_dev, + i & 0x1 ? + IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, + (i >> 1), + IIO_EV_TYPE_THRESH, + IIO_EV_DIR_RISING) : + IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, + (i >> 1), + IIO_EV_TYPE_THRESH, + IIO_EV_DIR_FALLING), + iio_get_time_ns()); + } + +done: + return IRQ_HANDLED; +} + +static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, + ad799x_read_frequency, + ad799x_write_frequency); +static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("15625 7812 3906 1953 976 488 244 0"); + +static struct attribute *ad799x_event_attributes[] = { + &iio_dev_attr_sampling_frequency.dev_attr.attr, + &iio_const_attr_sampling_frequency_available.dev_attr.attr, + NULL, +}; + +static struct attribute_group ad799x_event_attrs_group = { + .attrs = ad799x_event_attributes, + .name = "events", +}; + +static const struct iio_info ad7991_info = { + .read_raw = &ad799x_read_raw, + .driver_module = THIS_MODULE, +}; + +static const struct iio_info ad7993_4_7_8_info = { + .read_raw = &ad799x_read_raw, + .event_attrs = &ad799x_event_attrs_group, + .read_event_config = &ad799x_read_event_config, + .read_event_value = &ad799x_read_event_value, + .write_event_value = &ad799x_write_event_value, + .driver_module = THIS_MODULE, + .update_scan_mode = ad7997_8_update_scan_mode, +}; + +static const struct iio_event_spec ad799x_events[] = { + { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_RISING, + .mask_separate = BIT(IIO_EV_INFO_VALUE) | + BIT(IIO_EV_INFO_ENABLE), + }, { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_FALLING, + .mask_separate = BIT(IIO_EV_INFO_VALUE) | + BIT(IIO_EV_INFO_ENABLE), + }, { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_EITHER, + .mask_separate = BIT(IIO_EV_INFO_HYSTERESIS), + }, +}; + +#define _AD799X_CHANNEL(_index, _realbits, _ev_spec, _num_ev_spec) { \ + .type = IIO_VOLTAGE, \ + .indexed = 1, \ + .channel = (_index), \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ + .scan_index = (_index), \ + .scan_type = { \ + .sign = 'u', \ + .realbits = (_realbits), \ + .storagebits = 16, \ + .shift = 12 - (_realbits), \ + .endianness = IIO_BE, \ + }, \ + .event_spec = _ev_spec, \ + .num_event_specs = _num_ev_spec, \ +} + +#define AD799X_CHANNEL(_index, _realbits) \ + _AD799X_CHANNEL(_index, _realbits, NULL, 0) + +#define AD799X_CHANNEL_WITH_EVENTS(_index, _realbits) \ + _AD799X_CHANNEL(_index, _realbits, ad799x_events, \ + ARRAY_SIZE(ad799x_events)) + +static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { + [ad7991] = { + .channel = { + AD799X_CHANNEL(0, 12), + AD799X_CHANNEL(1, 12), + AD799X_CHANNEL(2, 12), + AD799X_CHANNEL(3, 12), + IIO_CHAN_SOFT_TIMESTAMP(4), + }, + .num_channels = 5, + .info = &ad7991_info, + }, + [ad7995] = { + .channel = { + AD799X_CHANNEL(0, 10), + AD799X_CHANNEL(1, 10), + AD799X_CHANNEL(2, 10), + AD799X_CHANNEL(3, 10), + IIO_CHAN_SOFT_TIMESTAMP(4), + }, + .num_channels = 5, + .info = &ad7991_info, + }, + [ad7999] = { + .channel = { + AD799X_CHANNEL(0, 8), + AD799X_CHANNEL(1, 8), + AD799X_CHANNEL(2, 8), + AD799X_CHANNEL(3, 8), + IIO_CHAN_SOFT_TIMESTAMP(4), + }, + .num_channels = 5, + .info = &ad7991_info, + }, + [ad7992] = { + .channel = { + AD799X_CHANNEL_WITH_EVENTS(0, 12), + AD799X_CHANNEL_WITH_EVENTS(1, 12), + IIO_CHAN_SOFT_TIMESTAMP(3), + }, + .num_channels = 3, + .default_config = AD7998_ALERT_EN, + .info = &ad7993_4_7_8_info, + }, + [ad7993] = { + .channel = { + AD799X_CHANNEL_WITH_EVENTS(0, 10), + AD799X_CHANNEL_WITH_EVENTS(1, 10), + AD799X_CHANNEL_WITH_EVENTS(2, 10), + AD799X_CHANNEL_WITH_EVENTS(3, 10), + IIO_CHAN_SOFT_TIMESTAMP(4), + }, + .num_channels = 5, + .default_config = AD7998_ALERT_EN, + .info = &ad7993_4_7_8_info, + }, + [ad7994] = { + .channel = { + AD799X_CHANNEL_WITH_EVENTS(0, 12), + AD799X_CHANNEL_WITH_EVENTS(1, 12), + AD799X_CHANNEL_WITH_EVENTS(2, 12), + AD799X_CHANNEL_WITH_EVENTS(3, 12), + IIO_CHAN_SOFT_TIMESTAMP(4), + }, + .num_channels = 5, + .default_config = AD7998_ALERT_EN, + .info = &ad7993_4_7_8_info, + }, + [ad7997] = { + .channel = { + AD799X_CHANNEL_WITH_EVENTS(0, 10), + AD799X_CHANNEL_WITH_EVENTS(1, 10), + AD799X_CHANNEL_WITH_EVENTS(2, 10), + AD799X_CHANNEL_WITH_EVENTS(3, 10), + AD799X_CHANNEL(4, 10), + AD799X_CHANNEL(5, 10), + AD799X_CHANNEL(6, 10), + AD799X_CHANNEL(7, 10), + IIO_CHAN_SOFT_TIMESTAMP(8), + }, + .num_channels = 9, + .default_config = AD7998_ALERT_EN, + .info = &ad7993_4_7_8_info, + }, + [ad7998] = { + .channel = { + AD799X_CHANNEL_WITH_EVENTS(0, 12), + AD799X_CHANNEL_WITH_EVENTS(1, 12), + AD799X_CHANNEL_WITH_EVENTS(2, 12), + AD799X_CHANNEL_WITH_EVENTS(3, 12), + AD799X_CHANNEL(4, 12), + AD799X_CHANNEL(5, 12), + AD799X_CHANNEL(6, 12), + AD799X_CHANNEL(7, 12), + IIO_CHAN_SOFT_TIMESTAMP(8), + }, + .num_channels = 9, + .default_config = AD7998_ALERT_EN, + .info = &ad7993_4_7_8_info, + }, +}; + +static int ad799x_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + int ret; + struct ad799x_state *st; + struct iio_dev *indio_dev; + + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st)); + if (indio_dev == NULL) + return -ENOMEM; + + st = iio_priv(indio_dev); + /* this is only used for device removal purposes */ + i2c_set_clientdata(client, indio_dev); + + st->id = id->driver_data; + st->chip_info = &ad799x_chip_info_tbl[st->id]; + st->config = st->chip_info->default_config; + + /* TODO: Add pdata options for filtering and bit delay */ + + st->reg = devm_regulator_get(&client->dev, "vcc"); + if (IS_ERR(st->reg)) + return PTR_ERR(st->reg); + ret = regulator_enable(st->reg); + if (ret) + return ret; + st->vref = devm_regulator_get(&client->dev, "vref"); + if (IS_ERR(st->vref)) { + ret = PTR_ERR(st->vref); + goto error_disable_reg; + } + ret = regulator_enable(st->vref); + if (ret) + goto error_disable_reg; + + st->client = client; + + indio_dev->dev.parent = &client->dev; + indio_dev->name = id->name; + indio_dev->info = st->chip_info->info; + + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = st->chip_info->channel; + indio_dev->num_channels = st->chip_info->num_channels; + + ret = iio_triggered_buffer_setup(indio_dev, NULL, + &ad799x_trigger_handler, NULL); + if (ret) + goto error_disable_reg; + + if (client->irq > 0) { + ret = devm_request_threaded_irq(&client->dev, + client->irq, + NULL, + ad799x_event_handler, + IRQF_TRIGGER_FALLING | + IRQF_ONESHOT, + client->name, + indio_dev); + if (ret) + goto error_cleanup_ring; + } + ret = iio_device_register(indio_dev); + if (ret) + goto error_cleanup_ring; + + return 0; + +error_cleanup_ring: + iio_triggered_buffer_cleanup(indio_dev); +error_disable_reg: + if (!IS_ERR(st->vref)) + regulator_disable(st->vref); + if (!IS_ERR(st->reg)) + regulator_disable(st->reg); + + return ret; +} + +static int ad799x_remove(struct i2c_client *client) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(client); + struct ad799x_state *st = iio_priv(indio_dev); + + iio_device_unregister(indio_dev); + + iio_triggered_buffer_cleanup(indio_dev); + if (!IS_ERR(st->vref)) + regulator_disable(st->vref); + if (!IS_ERR(st->reg)) + regulator_disable(st->reg); + kfree(st->rx_buf); + + return 0; +} + +static const struct i2c_device_id ad799x_id[] = { + { "ad7991", ad7991 }, + { "ad7995", ad7995 }, + { "ad7999", ad7999 }, + { "ad7992", ad7992 }, + { "ad7993", ad7993 }, + { "ad7994", ad7994 }, + { "ad7997", ad7997 }, + { "ad7998", ad7998 }, + {} +}; + +MODULE_DEVICE_TABLE(i2c, ad799x_id); + +static struct i2c_driver ad799x_driver = { + .driver = { + .name = "ad799x", + }, + .probe = ad799x_probe, + .remove = ad799x_remove, + .id_table = ad799x_id, +}; +module_i2c_driver(ad799x_driver); + +MODULE_AUTHOR("Michael Hennerich "); +MODULE_DESCRIPTION("Analog Devices AD799x ADC"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig index ed23cceba17d..b87e382ad768 100644 --- a/drivers/staging/iio/adc/Kconfig +++ b/drivers/staging/iio/adc/Kconfig @@ -37,17 +37,6 @@ config AD7606_IFACE_SPI Say yes here to include parallel interface support on the AD7606 ADC driver. -config AD799X - tristate "Analog Devices AD799x ADC driver" - depends on I2C - select IIO_BUFFER - select IIO_TRIGGERED_BUFFER - help - Say yes here to build support for Analog Devices: - ad7991, ad7995, ad7999, ad7992, ad7993, ad7994, ad7997, ad7998 - i2c analog to digital converters (ADC). Provides direct access - via sysfs. - config AD7780 tristate "Analog Devices AD7780 and similar ADCs driver" depends on SPI diff --git a/drivers/staging/iio/adc/Makefile b/drivers/staging/iio/adc/Makefile index b2d35f813292..afdcd1ff08ff 100644 --- a/drivers/staging/iio/adc/Makefile +++ b/drivers/staging/iio/adc/Makefile @@ -8,9 +8,6 @@ ad7606-$(CONFIG_AD7606_IFACE_PARALLEL) += ad7606_par.o ad7606-$(CONFIG_AD7606_IFACE_SPI) += ad7606_spi.o obj-$(CONFIG_AD7606) += ad7606.o -ad799x-y := ad799x_core.o -obj-$(CONFIG_AD799X) += ad799x.o - obj-$(CONFIG_AD7291) += ad7291.o obj-$(CONFIG_AD7780) += ad7780.o obj-$(CONFIG_AD7816) += ad7816.o diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c deleted file mode 100644 index bcbf6102efed..000000000000 --- a/drivers/staging/iio/adc/ad799x_core.c +++ /dev/null @@ -1,794 +0,0 @@ -/* - * iio/adc/ad799x.c - * Copyright (C) 2010-2011 Michael Hennerich, Analog Devices Inc. - * - * based on iio/adc/max1363 - * Copyright (C) 2008-2010 Jonathan Cameron - * - * based on linux/drivers/i2c/chips/max123x - * Copyright (C) 2002-2004 Stefan Eletzhofer - * - * based on linux/drivers/acron/char/pcf8583.c - * Copyright (C) 2000 Russell King - * - * 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. - * - * ad799x.c - * - * Support for ad7991, ad7995, ad7999, ad7992, ad7993, ad7994, ad7997, - * ad7998 and similar chips. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#define AD799X_CHANNEL_SHIFT 4 -#define AD799X_STORAGEBITS 16 -/* - * AD7991, AD7995 and AD7999 defines - */ - -#define AD7991_REF_SEL 0x08 -#define AD7991_FLTR 0x04 -#define AD7991_BIT_TRIAL_DELAY 0x02 -#define AD7991_SAMPLE_DELAY 0x01 - -/* - * AD7992, AD7993, AD7994, AD7997 and AD7998 defines - */ - -#define AD7998_FLTR 0x08 -#define AD7998_ALERT_EN 0x04 -#define AD7998_BUSY_ALERT 0x02 -#define AD7998_BUSY_ALERT_POL 0x01 - -#define AD7998_CONV_RES_REG 0x0 -#define AD7998_ALERT_STAT_REG 0x1 -#define AD7998_CONF_REG 0x2 -#define AD7998_CYCLE_TMR_REG 0x3 - -#define AD7998_DATALOW_REG(x) ((x) * 3 + 0x4) -#define AD7998_DATAHIGH_REG(x) ((x) * 3 + 0x5) -#define AD7998_HYST_REG(x) ((x) * 3 + 0x6) - -#define AD7998_CYC_MASK 0x7 -#define AD7998_CYC_DIS 0x0 -#define AD7998_CYC_TCONF_32 0x1 -#define AD7998_CYC_TCONF_64 0x2 -#define AD7998_CYC_TCONF_128 0x3 -#define AD7998_CYC_TCONF_256 0x4 -#define AD7998_CYC_TCONF_512 0x5 -#define AD7998_CYC_TCONF_1024 0x6 -#define AD7998_CYC_TCONF_2048 0x7 - -#define AD7998_ALERT_STAT_CLEAR 0xFF - -/* - * AD7997 and AD7997 defines - */ - -#define AD7997_8_READ_SINGLE 0x80 -#define AD7997_8_READ_SEQUENCE 0x70 -/* TODO: move this into a common header */ -#define RES_MASK(bits) ((1 << (bits)) - 1) - -enum { - ad7991, - ad7995, - ad7999, - ad7992, - ad7993, - ad7994, - ad7997, - ad7998 -}; - -/** - * struct ad799x_chip_info - chip specifc information - * @channel: channel specification - * @num_channels: number of channels - * @monitor_mode: whether the chip supports monitor interrupts - * @default_config: device default configuration - * @event_attrs: pointer to the monitor event attribute group - */ -struct ad799x_chip_info { - struct iio_chan_spec channel[9]; - int num_channels; - u16 default_config; - const struct iio_info *info; -}; - -struct ad799x_state { - struct i2c_client *client; - const struct ad799x_chip_info *chip_info; - struct regulator *reg; - struct regulator *vref; - unsigned id; - u16 config; - - u8 *rx_buf; - unsigned int transfer_size; -}; - -/** - * ad799x_trigger_handler() bh of trigger launched polling to ring buffer - * - * Currently there is no option in this driver to disable the saving of - * timestamps within the ring. - **/ -static irqreturn_t ad799x_trigger_handler(int irq, void *p) -{ - struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->indio_dev; - struct ad799x_state *st = iio_priv(indio_dev); - int b_sent; - u8 cmd; - - switch (st->id) { - case ad7991: - case ad7995: - case ad7999: - cmd = st->config | - (*indio_dev->active_scan_mask << AD799X_CHANNEL_SHIFT); - break; - case ad7992: - case ad7993: - case ad7994: - cmd = (*indio_dev->active_scan_mask << AD799X_CHANNEL_SHIFT) | - AD7998_CONV_RES_REG; - break; - case ad7997: - case ad7998: - cmd = AD7997_8_READ_SEQUENCE | AD7998_CONV_RES_REG; - break; - default: - cmd = 0; - } - - b_sent = i2c_smbus_read_i2c_block_data(st->client, - cmd, st->transfer_size, st->rx_buf); - if (b_sent < 0) - goto out; - - iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf, - iio_get_time_ns()); -out: - iio_trigger_notify_done(indio_dev->trig); - - return IRQ_HANDLED; -} - -/* - * ad799x register access by I2C - */ -static int ad799x_i2c_read16(struct ad799x_state *st, u8 reg, u16 *data) -{ - struct i2c_client *client = st->client; - int ret = 0; - - ret = i2c_smbus_read_word_swapped(client, reg); - if (ret < 0) { - dev_err(&client->dev, "I2C read error\n"); - return ret; - } - - *data = (u16)ret; - - return 0; -} - -static int ad799x_i2c_read8(struct ad799x_state *st, u8 reg, u8 *data) -{ - struct i2c_client *client = st->client; - int ret = 0; - - ret = i2c_smbus_read_byte_data(client, reg); - if (ret < 0) { - dev_err(&client->dev, "I2C read error\n"); - return ret; - } - - *data = (u8)ret; - - return 0; -} - -static int ad799x_i2c_write16(struct ad799x_state *st, u8 reg, u16 data) -{ - struct i2c_client *client = st->client; - int ret = 0; - - ret = i2c_smbus_write_word_swapped(client, reg, data); - if (ret < 0) - dev_err(&client->dev, "I2C write error\n"); - - return ret; -} - -static int ad799x_i2c_write8(struct ad799x_state *st, u8 reg, u8 data) -{ - struct i2c_client *client = st->client; - int ret = 0; - - ret = i2c_smbus_write_byte_data(client, reg, data); - if (ret < 0) - dev_err(&client->dev, "I2C write error\n"); - - return ret; -} - -static int ad7997_8_update_scan_mode(struct iio_dev *indio_dev, - const unsigned long *scan_mask) -{ - struct ad799x_state *st = iio_priv(indio_dev); - - kfree(st->rx_buf); - st->rx_buf = kmalloc(indio_dev->scan_bytes, GFP_KERNEL); - if (!st->rx_buf) - return -ENOMEM; - - st->transfer_size = bitmap_weight(scan_mask, indio_dev->masklength) * 2; - - switch (st->id) { - case ad7997: - case ad7998: - return ad799x_i2c_write16(st, AD7998_CONF_REG, - st->config | (*scan_mask << AD799X_CHANNEL_SHIFT)); - default: - break; - } - - return 0; -} - -static int ad799x_scan_direct(struct ad799x_state *st, unsigned ch) -{ - u16 rxbuf; - u8 cmd; - int ret; - - switch (st->id) { - case ad7991: - case ad7995: - case ad7999: - cmd = st->config | ((1 << ch) << AD799X_CHANNEL_SHIFT); - break; - case ad7992: - case ad7993: - case ad7994: - cmd = (1 << ch) << AD799X_CHANNEL_SHIFT; - break; - case ad7997: - case ad7998: - cmd = (ch << AD799X_CHANNEL_SHIFT) | AD7997_8_READ_SINGLE; - break; - default: - return -EINVAL; - } - - ret = ad799x_i2c_read16(st, cmd, &rxbuf); - if (ret < 0) - return ret; - - return rxbuf; -} - -static int ad799x_read_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int *val, - int *val2, - long m) -{ - int ret; - struct ad799x_state *st = iio_priv(indio_dev); - - switch (m) { - case IIO_CHAN_INFO_RAW: - mutex_lock(&indio_dev->mlock); - if (iio_buffer_enabled(indio_dev)) - ret = -EBUSY; - else - ret = ad799x_scan_direct(st, chan->scan_index); - mutex_unlock(&indio_dev->mlock); - - if (ret < 0) - return ret; - *val = (ret >> chan->scan_type.shift) & - RES_MASK(chan->scan_type.realbits); - return IIO_VAL_INT; - case IIO_CHAN_INFO_SCALE: - ret = regulator_get_voltage(st->vref); - if (ret < 0) - return ret; - *val = ret / 1000; - *val2 = chan->scan_type.realbits; - return IIO_VAL_FRACTIONAL_LOG2; - } - return -EINVAL; -} -static const unsigned int ad7998_frequencies[] = { - [AD7998_CYC_DIS] = 0, - [AD7998_CYC_TCONF_32] = 15625, - [AD7998_CYC_TCONF_64] = 7812, - [AD7998_CYC_TCONF_128] = 3906, - [AD7998_CYC_TCONF_512] = 976, - [AD7998_CYC_TCONF_1024] = 488, - [AD7998_CYC_TCONF_2048] = 244, -}; -static ssize_t ad799x_read_frequency(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *indio_dev = dev_to_iio_dev(dev); - struct ad799x_state *st = iio_priv(indio_dev); - - int ret; - u8 val; - ret = ad799x_i2c_read8(st, AD7998_CYCLE_TMR_REG, &val); - if (ret) - return ret; - - val &= AD7998_CYC_MASK; - - return sprintf(buf, "%u\n", ad7998_frequencies[val]); -} - -static ssize_t ad799x_write_frequency(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *indio_dev = dev_to_iio_dev(dev); - struct ad799x_state *st = iio_priv(indio_dev); - - long val; - int ret, i; - u8 t; - - ret = kstrtol(buf, 10, &val); - if (ret) - return ret; - - mutex_lock(&indio_dev->mlock); - ret = ad799x_i2c_read8(st, AD7998_CYCLE_TMR_REG, &t); - if (ret) - goto error_ret_mutex; - /* Wipe the bits clean */ - t &= ~AD7998_CYC_MASK; - - for (i = 0; i < ARRAY_SIZE(ad7998_frequencies); i++) - if (val == ad7998_frequencies[i]) - break; - if (i == ARRAY_SIZE(ad7998_frequencies)) { - ret = -EINVAL; - goto error_ret_mutex; - } - t |= i; - ret = ad799x_i2c_write8(st, AD7998_CYCLE_TMR_REG, t); - -error_ret_mutex: - mutex_unlock(&indio_dev->mlock); - - return ret ? ret : len; -} - -static int ad799x_read_event_config(struct iio_dev *indio_dev, - const struct iio_chan_spec *chan, - enum iio_event_type type, - enum iio_event_direction dir) -{ - return 1; -} - -static unsigned int ad799x_threshold_reg(const struct iio_chan_spec *chan, - enum iio_event_direction dir, - enum iio_event_info info) -{ - switch (info) { - case IIO_EV_INFO_VALUE: - if (dir == IIO_EV_DIR_FALLING) - return AD7998_DATALOW_REG(chan->channel); - else - return AD7998_DATAHIGH_REG(chan->channel); - case IIO_EV_INFO_HYSTERESIS: - return AD7998_HYST_REG(chan->channel); - default: - return -EINVAL; - } - - return 0; -} - -static int ad799x_write_event_value(struct iio_dev *indio_dev, - const struct iio_chan_spec *chan, - enum iio_event_type type, - enum iio_event_direction dir, - enum iio_event_info info, - int val, int val2) -{ - int ret; - struct ad799x_state *st = iio_priv(indio_dev); - - mutex_lock(&indio_dev->mlock); - ret = ad799x_i2c_write16(st, ad799x_threshold_reg(chan, dir, info), - val); - mutex_unlock(&indio_dev->mlock); - - return ret; -} - -static int ad799x_read_event_value(struct iio_dev *indio_dev, - const struct iio_chan_spec *chan, - enum iio_event_type type, - enum iio_event_direction dir, - enum iio_event_info info, - int *val, int *val2) -{ - int ret; - struct ad799x_state *st = iio_priv(indio_dev); - u16 valin; - - mutex_lock(&indio_dev->mlock); - ret = ad799x_i2c_read16(st, ad799x_threshold_reg(chan, dir, info), - &valin); - mutex_unlock(&indio_dev->mlock); - if (ret < 0) - return ret; - *val = valin; - - return IIO_VAL_INT; -} - -static irqreturn_t ad799x_event_handler(int irq, void *private) -{ - struct iio_dev *indio_dev = private; - struct ad799x_state *st = iio_priv(private); - u8 status; - int i, ret; - - ret = ad799x_i2c_read8(st, AD7998_ALERT_STAT_REG, &status); - if (ret) - goto done; - - if (!status) - goto done; - - ad799x_i2c_write8(st, AD7998_ALERT_STAT_REG, AD7998_ALERT_STAT_CLEAR); - - for (i = 0; i < 8; i++) { - if (status & (1 << i)) - iio_push_event(indio_dev, - i & 0x1 ? - IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, - (i >> 1), - IIO_EV_TYPE_THRESH, - IIO_EV_DIR_RISING) : - IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, - (i >> 1), - IIO_EV_TYPE_THRESH, - IIO_EV_DIR_FALLING), - iio_get_time_ns()); - } - -done: - return IRQ_HANDLED; -} - -static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, - ad799x_read_frequency, - ad799x_write_frequency); -static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("15625 7812 3906 1953 976 488 244 0"); - -static struct attribute *ad799x_event_attributes[] = { - &iio_dev_attr_sampling_frequency.dev_attr.attr, - &iio_const_attr_sampling_frequency_available.dev_attr.attr, - NULL, -}; - -static struct attribute_group ad799x_event_attrs_group = { - .attrs = ad799x_event_attributes, - .name = "events", -}; - -static const struct iio_info ad7991_info = { - .read_raw = &ad799x_read_raw, - .driver_module = THIS_MODULE, -}; - -static const struct iio_info ad7993_4_7_8_info = { - .read_raw = &ad799x_read_raw, - .event_attrs = &ad799x_event_attrs_group, - .read_event_config = &ad799x_read_event_config, - .read_event_value = &ad799x_read_event_value, - .write_event_value = &ad799x_write_event_value, - .driver_module = THIS_MODULE, - .update_scan_mode = ad7997_8_update_scan_mode, -}; - -static const struct iio_event_spec ad799x_events[] = { - { - .type = IIO_EV_TYPE_THRESH, - .dir = IIO_EV_DIR_RISING, - .mask_separate = BIT(IIO_EV_INFO_VALUE) | - BIT(IIO_EV_INFO_ENABLE), - }, { - .type = IIO_EV_TYPE_THRESH, - .dir = IIO_EV_DIR_FALLING, - .mask_separate = BIT(IIO_EV_INFO_VALUE) | - BIT(IIO_EV_INFO_ENABLE), - }, { - .type = IIO_EV_TYPE_THRESH, - .dir = IIO_EV_DIR_EITHER, - .mask_separate = BIT(IIO_EV_INFO_HYSTERESIS), - }, -}; - -#define _AD799X_CHANNEL(_index, _realbits, _ev_spec, _num_ev_spec) { \ - .type = IIO_VOLTAGE, \ - .indexed = 1, \ - .channel = (_index), \ - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ - .scan_index = (_index), \ - .scan_type = { \ - .sign = 'u', \ - .realbits = (_realbits), \ - .storagebits = 16, \ - .shift = 12 - (_realbits), \ - .endianness = IIO_BE, \ - }, \ - .event_spec = _ev_spec, \ - .num_event_specs = _num_ev_spec, \ -} - -#define AD799X_CHANNEL(_index, _realbits) \ - _AD799X_CHANNEL(_index, _realbits, NULL, 0) - -#define AD799X_CHANNEL_WITH_EVENTS(_index, _realbits) \ - _AD799X_CHANNEL(_index, _realbits, ad799x_events, \ - ARRAY_SIZE(ad799x_events)) - -static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { - [ad7991] = { - .channel = { - AD799X_CHANNEL(0, 12), - AD799X_CHANNEL(1, 12), - AD799X_CHANNEL(2, 12), - AD799X_CHANNEL(3, 12), - IIO_CHAN_SOFT_TIMESTAMP(4), - }, - .num_channels = 5, - .info = &ad7991_info, - }, - [ad7995] = { - .channel = { - AD799X_CHANNEL(0, 10), - AD799X_CHANNEL(1, 10), - AD799X_CHANNEL(2, 10), - AD799X_CHANNEL(3, 10), - IIO_CHAN_SOFT_TIMESTAMP(4), - }, - .num_channels = 5, - .info = &ad7991_info, - }, - [ad7999] = { - .channel = { - AD799X_CHANNEL(0, 8), - AD799X_CHANNEL(1, 8), - AD799X_CHANNEL(2, 8), - AD799X_CHANNEL(3, 8), - IIO_CHAN_SOFT_TIMESTAMP(4), - }, - .num_channels = 5, - .info = &ad7991_info, - }, - [ad7992] = { - .channel = { - AD799X_CHANNEL_WITH_EVENTS(0, 12), - AD799X_CHANNEL_WITH_EVENTS(1, 12), - IIO_CHAN_SOFT_TIMESTAMP(3), - }, - .num_channels = 3, - .default_config = AD7998_ALERT_EN, - .info = &ad7993_4_7_8_info, - }, - [ad7993] = { - .channel = { - AD799X_CHANNEL_WITH_EVENTS(0, 10), - AD799X_CHANNEL_WITH_EVENTS(1, 10), - AD799X_CHANNEL_WITH_EVENTS(2, 10), - AD799X_CHANNEL_WITH_EVENTS(3, 10), - IIO_CHAN_SOFT_TIMESTAMP(4), - }, - .num_channels = 5, - .default_config = AD7998_ALERT_EN, - .info = &ad7993_4_7_8_info, - }, - [ad7994] = { - .channel = { - AD799X_CHANNEL_WITH_EVENTS(0, 12), - AD799X_CHANNEL_WITH_EVENTS(1, 12), - AD799X_CHANNEL_WITH_EVENTS(2, 12), - AD799X_CHANNEL_WITH_EVENTS(3, 12), - IIO_CHAN_SOFT_TIMESTAMP(4), - }, - .num_channels = 5, - .default_config = AD7998_ALERT_EN, - .info = &ad7993_4_7_8_info, - }, - [ad7997] = { - .channel = { - AD799X_CHANNEL_WITH_EVENTS(0, 10), - AD799X_CHANNEL_WITH_EVENTS(1, 10), - AD799X_CHANNEL_WITH_EVENTS(2, 10), - AD799X_CHANNEL_WITH_EVENTS(3, 10), - AD799X_CHANNEL(4, 10), - AD799X_CHANNEL(5, 10), - AD799X_CHANNEL(6, 10), - AD799X_CHANNEL(7, 10), - IIO_CHAN_SOFT_TIMESTAMP(8), - }, - .num_channels = 9, - .default_config = AD7998_ALERT_EN, - .info = &ad7993_4_7_8_info, - }, - [ad7998] = { - .channel = { - AD799X_CHANNEL_WITH_EVENTS(0, 12), - AD799X_CHANNEL_WITH_EVENTS(1, 12), - AD799X_CHANNEL_WITH_EVENTS(2, 12), - AD799X_CHANNEL_WITH_EVENTS(3, 12), - AD799X_CHANNEL(4, 12), - AD799X_CHANNEL(5, 12), - AD799X_CHANNEL(6, 12), - AD799X_CHANNEL(7, 12), - IIO_CHAN_SOFT_TIMESTAMP(8), - }, - .num_channels = 9, - .default_config = AD7998_ALERT_EN, - .info = &ad7993_4_7_8_info, - }, -}; - -static int ad799x_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - int ret; - struct ad799x_state *st; - struct iio_dev *indio_dev; - - indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st)); - if (indio_dev == NULL) - return -ENOMEM; - - st = iio_priv(indio_dev); - /* this is only used for device removal purposes */ - i2c_set_clientdata(client, indio_dev); - - st->id = id->driver_data; - st->chip_info = &ad799x_chip_info_tbl[st->id]; - st->config = st->chip_info->default_config; - - /* TODO: Add pdata options for filtering and bit delay */ - - st->reg = devm_regulator_get(&client->dev, "vcc"); - if (IS_ERR(st->reg)) - return PTR_ERR(st->reg); - ret = regulator_enable(st->reg); - if (ret) - return ret; - st->vref = devm_regulator_get(&client->dev, "vref"); - if (IS_ERR(st->vref)) { - ret = PTR_ERR(st->vref); - goto error_disable_reg; - } - ret = regulator_enable(st->vref); - if (ret) - goto error_disable_reg; - - st->client = client; - - indio_dev->dev.parent = &client->dev; - indio_dev->name = id->name; - indio_dev->info = st->chip_info->info; - - indio_dev->modes = INDIO_DIRECT_MODE; - indio_dev->channels = st->chip_info->channel; - indio_dev->num_channels = st->chip_info->num_channels; - - ret = iio_triggered_buffer_setup(indio_dev, NULL, - &ad799x_trigger_handler, NULL); - if (ret) - goto error_disable_reg; - - if (client->irq > 0) { - ret = devm_request_threaded_irq(&client->dev, - client->irq, - NULL, - ad799x_event_handler, - IRQF_TRIGGER_FALLING | - IRQF_ONESHOT, - client->name, - indio_dev); - if (ret) - goto error_cleanup_ring; - } - ret = iio_device_register(indio_dev); - if (ret) - goto error_cleanup_ring; - - return 0; - -error_cleanup_ring: - iio_triggered_buffer_cleanup(indio_dev); -error_disable_reg: - if (!IS_ERR(st->vref)) - regulator_disable(st->vref); - if (!IS_ERR(st->reg)) - regulator_disable(st->reg); - - return ret; -} - -static int ad799x_remove(struct i2c_client *client) -{ - struct iio_dev *indio_dev = i2c_get_clientdata(client); - struct ad799x_state *st = iio_priv(indio_dev); - - iio_device_unregister(indio_dev); - - iio_triggered_buffer_cleanup(indio_dev); - if (!IS_ERR(st->vref)) - regulator_disable(st->vref); - if (!IS_ERR(st->reg)) - regulator_disable(st->reg); - kfree(st->rx_buf); - - return 0; -} - -static const struct i2c_device_id ad799x_id[] = { - { "ad7991", ad7991 }, - { "ad7995", ad7995 }, - { "ad7999", ad7999 }, - { "ad7992", ad7992 }, - { "ad7993", ad7993 }, - { "ad7994", ad7994 }, - { "ad7997", ad7997 }, - { "ad7998", ad7998 }, - {} -}; - -MODULE_DEVICE_TABLE(i2c, ad799x_id); - -static struct i2c_driver ad799x_driver = { - .driver = { - .name = "ad799x", - }, - .probe = ad799x_probe, - .remove = ad799x_remove, - .id_table = ad799x_id, -}; -module_i2c_driver(ad799x_driver); - -MODULE_AUTHOR("Michael Hennerich "); -MODULE_DESCRIPTION("Analog Devices AD799x ADC"); -MODULE_LICENSE("GPL v2"); -- cgit v1.2.3 From 2816ac64ac46c4017355a49331250e5c016dc2c0 Mon Sep 17 00:00:00 2001 From: Angelo Compagnucci Date: Sun, 3 Aug 2014 23:22:00 +0100 Subject: Add support for Microchip Technology's MCP3426/7/8 ADC This patch extends previous mcp3422 driver to support missing members of the family, mcp3426/7/8. Signed-off-by: Angelo Compagnucci Signed-off-by: Jonathan Cameron --- drivers/iio/adc/Kconfig | 7 ++++--- drivers/iio/adc/mcp3422.c | 33 ++++++++++++++++++++++++++++----- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index a0368119c275..1dffa2d56262 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -157,11 +157,12 @@ config MCP320X called mcp320x. config MCP3422 - tristate "Microchip Technology MCP3422/3/4 driver" + tristate "Microchip Technology MCP3422/3/4/6/7/8 driver" depends on I2C help - Say yes here to build support for Microchip Technology's MCP3422, - MCP3423 or MCP3424 analog to digital converters. + Say yes here to build support for Microchip Technology's + MCP3422, MCP3423, MCP3424, MCP3426, MCP3427 or MCP3428 + analog to digital converters. This driver can also be built as a module. If so, the module will be called mcp3422. diff --git a/drivers/iio/adc/mcp3422.c b/drivers/iio/adc/mcp3422.c index 47dcb34ff44c..51672256072b 100644 --- a/drivers/iio/adc/mcp3422.c +++ b/drivers/iio/adc/mcp3422.c @@ -1,10 +1,11 @@ /* - * mcp3422.c - driver for the Microchip mcp3422/3/4 chip family + * mcp3422.c - driver for the Microchip mcp3422/3/4/6/7/8 chip family * * Copyright (C) 2013, Angelo Compagnucci * Author: Angelo Compagnucci * * Datasheet: http://ww1.microchip.com/downloads/en/devicedoc/22088b.pdf + * http://ww1.microchip.com/downloads/en/DeviceDoc/22226a.pdf * * This driver exports the value of analog input voltage to sysfs, the * voltage unit is nV. @@ -96,6 +97,7 @@ static const int mcp3422_sign_extend[4] = { /* Client data (each client gets its own) */ struct mcp3422 { struct i2c_client *i2c; + u8 id; u8 config; u8 pga[4]; struct mutex lock; @@ -238,6 +240,8 @@ static int mcp3422_write_raw(struct iio_dev *iio, temp = MCP3422_SRATE_15; break; case 3: + if (adc->id > 4) + return -EINVAL; temp = MCP3422_SRATE_3; break; default: @@ -271,6 +275,17 @@ static int mcp3422_write_raw_get_fmt(struct iio_dev *indio_dev, } } +static ssize_t mcp3422_show_samp_freqs(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct mcp3422 *adc = iio_priv(dev_to_iio_dev(dev)); + + if (adc->id > 4) + return sprintf(buf, "240 60 15\n"); + + return sprintf(buf, "240 60 15 3\n"); +} + static ssize_t mcp3422_show_scales(struct device *dev, struct device_attribute *attr, char *buf) { @@ -284,12 +299,13 @@ static ssize_t mcp3422_show_scales(struct device *dev, mcp3422_scales[sample_rate][3]); } -static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("240 60 15 3"); +static IIO_DEVICE_ATTR(sampling_frequency_available, S_IRUGO, + mcp3422_show_samp_freqs, NULL, 0); static IIO_DEVICE_ATTR(in_voltage_scale_available, S_IRUGO, mcp3422_show_scales, NULL, 0); static struct attribute *mcp3422_attributes[] = { - &iio_const_attr_sampling_frequency_available.dev_attr.attr, + &iio_dev_attr_sampling_frequency_available.dev_attr.attr, &iio_dev_attr_in_voltage_scale_available.dev_attr.attr, NULL, }; @@ -335,6 +351,7 @@ static int mcp3422_probe(struct i2c_client *client, adc = iio_priv(indio_dev); adc->i2c = client; + adc->id = (u8)(id->driver_data); mutex_init(&adc->lock); @@ -343,13 +360,16 @@ static int mcp3422_probe(struct i2c_client *client, indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &mcp3422_info; - switch ((unsigned int)(id->driver_data)) { + switch (adc->id) { case 2: case 3: + case 6: + case 7: indio_dev->channels = mcp3422_channels; indio_dev->num_channels = ARRAY_SIZE(mcp3422_channels); break; case 4: + case 8: indio_dev->channels = mcp3424_channels; indio_dev->num_channels = ARRAY_SIZE(mcp3424_channels); break; @@ -375,6 +395,9 @@ static const struct i2c_device_id mcp3422_id[] = { { "mcp3422", 2 }, { "mcp3423", 3 }, { "mcp3424", 4 }, + { "mcp3426", 6 }, + { "mcp3427", 7 }, + { "mcp3428", 8 }, { } }; MODULE_DEVICE_TABLE(i2c, mcp3422_id); @@ -399,5 +422,5 @@ static struct i2c_driver mcp3422_driver = { module_i2c_driver(mcp3422_driver); MODULE_AUTHOR("Angelo Compagnucci "); -MODULE_DESCRIPTION("Microchip mcp3422/3/4 driver"); +MODULE_DESCRIPTION("Microchip mcp3422/3/4/6/7/8 driver"); MODULE_LICENSE("GPL v2"); -- cgit v1.2.3 From ef4b4856593fc3d9d169bededdaf7acf62f83a52 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 3 Jan 2014 22:24:00 +0000 Subject: iio:core: Fix bug in length of event info_mask and catch unhandled bits set in masks. The unhandled bits case was highlighted by smatch: CHECK drivers/iio/industrialio-core.c drivers/iio/industrialio-core.c:719 iio_device_add_info_mask_type() error: buffer overflow 'iio_chan_info_postfix' 17 <= 31 CC [M] drivers/iio/industrialio-core.o CHECK drivers/iio/industrialio-event.c drivers/iio/industrialio-event.c:327 iio_device_add_event() error: buffer overflow 'iio_ev_info_text' 3 <= 3 The incorrect limit for the for_each_set_bit loop was noticed whilst fixing this other case. Note that as we only have 3 possible entries a the moment and the value was set to 4, the bug would not have any effect currently. It will bite fairly soon though, so best fix it now. Signed-off-by: Jonathan Cameron Cc: Lars-Peter Clausen Cc: Dan Carpenter --- drivers/iio/industrialio-core.c | 2 ++ drivers/iio/industrialio-event.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 1375921d8261..184444db62ac 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -716,6 +716,8 @@ static int iio_device_add_info_mask_type(struct iio_dev *indio_dev, int i, ret, attrcount = 0; for_each_set_bit(i, infomask, sizeof(infomask)*8) { + if (i >= ARRAY_SIZE(iio_chan_info_postfix)) + return -EINVAL; ret = __iio_add_chan_devattr(iio_chan_info_postfix[i], chan, &iio_read_channel_info, diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c index ea6e06b9c7d4..dddfb0f90d34 100644 --- a/drivers/iio/industrialio-event.c +++ b/drivers/iio/industrialio-event.c @@ -321,7 +321,9 @@ static int iio_device_add_event(struct iio_dev *indio_dev, char *postfix; int ret; - for_each_set_bit(i, mask, sizeof(*mask)) { + for_each_set_bit(i, mask, sizeof(*mask)*8) { + if (i >= ARRAY_SIZE(iio_ev_info_text)) + return -EINVAL; postfix = kasprintf(GFP_KERNEL, "%s_%s_%s", iio_ev_type_text[type], iio_ev_dir_text[dir], iio_ev_info_text[i]); -- cgit v1.2.3 From 239670ef48dfff9cf07675acdb3bb7deee4853e1 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 3 Jan 2014 22:08:00 +0000 Subject: iio:gyro:itg3200 - drop unreachable return ret. Highlighted by smatch CHECK drivers/iio/gyro/itg3200_core.c drivers/iio/gyro/itg3200_core.c:114 itg3200_read_raw() info: ignoring unreachable code. Signed-off-by: Jonathan Cameron Cc: Neil Brown Cc: Dan Carpenter --- drivers/iio/gyro/itg3200_core.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/iio/gyro/itg3200_core.c b/drivers/iio/gyro/itg3200_core.c index 4d3f3b92b361..8295e318399f 100644 --- a/drivers/iio/gyro/itg3200_core.c +++ b/drivers/iio/gyro/itg3200_core.c @@ -110,8 +110,6 @@ static int itg3200_read_raw(struct iio_dev *indio_dev, default: return -EINVAL; } - - return ret; } static ssize_t itg3200_read_frequency(struct device *dev, -- cgit v1.2.3 From 6027c077f62f11818a7645151119f8718862d764 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Wed, 19 Mar 2014 16:56:00 +0000 Subject: iio: ak8975 : Add AK8963 compatibility mode support AK8963 and AK8975 use same register definitions, except the range of X,Y,Z values. Added support of 8963 based on i2c_device_id. Unfortunately there is no way to detect the type via registers, both device registers return 0x48 as id of chipset. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/Kconfig | 3 ++- drivers/iio/magnetometer/ak8975.c | 34 +++++++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/drivers/iio/magnetometer/Kconfig b/drivers/iio/magnetometer/Kconfig index d86d226dcd67..05a364c543f8 100644 --- a/drivers/iio/magnetometer/Kconfig +++ b/drivers/iio/magnetometer/Kconfig @@ -11,7 +11,8 @@ config AK8975 depends on GPIOLIB help Say yes here to build support for Asahi Kasei AK8975 3-Axis - Magnetometer. + Magnetometer. This driver can also support AK8963, if i2c + device name is identified as ak8963. To compile this driver as a module, choose M here: the module will be called ak8975. diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c index 74866d1efd1b..0f1ca5303139 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -85,7 +85,14 @@ #define AK8975_MAX_CONVERSION_TIMEOUT 500 #define AK8975_CONVERSION_DONE_POLL_TIME 10 #define AK8975_DATA_READY_TIMEOUT ((100*HZ)/1000) -#define RAW_TO_GAUSS(asa) ((((asa) + 128) * 3000) / 256) +#define RAW_TO_GAUSS_8975(asa) ((((asa) + 128) * 3000) / 256) +#define RAW_TO_GAUSS_8963(asa) ((((asa) + 128) * 6000) / 256) + +/* Compatible Asahi Kasei Compass parts */ +enum asahi_compass_chipset { + AK8975, + AK8963, +}; /* * Per-instance context data for the device. @@ -101,6 +108,7 @@ struct ak8975_data { int eoc_irq; wait_queue_head_t data_ready_queue; unsigned long flags; + enum asahi_compass_chipset chipset; }; static const int ak8975_index_to_reg[] = { @@ -272,9 +280,21 @@ static int ak8975_setup(struct i2c_client *client) * Since ASA doesn't change, we cache the resultant scale factor into the * device context in ak8975_setup(). */ - data->raw_to_gauss[0] = RAW_TO_GAUSS(data->asa[0]); - data->raw_to_gauss[1] = RAW_TO_GAUSS(data->asa[1]); - data->raw_to_gauss[2] = RAW_TO_GAUSS(data->asa[2]); + if (data->chipset == AK8963) { + /* + * H range is +-8190 and magnetometer range is +-4912. + * So HuT using the above explanation for 8975, + * 4912/8190 = ~ 6/10. + * So the Hadj should use 6/10 instead of 3/10. + */ + data->raw_to_gauss[0] = RAW_TO_GAUSS_8963(data->asa[0]); + data->raw_to_gauss[1] = RAW_TO_GAUSS_8963(data->asa[1]); + data->raw_to_gauss[2] = RAW_TO_GAUSS_8963(data->asa[2]); + } else { + data->raw_to_gauss[0] = RAW_TO_GAUSS_8975(data->asa[0]); + data->raw_to_gauss[1] = RAW_TO_GAUSS_8975(data->asa[1]); + data->raw_to_gauss[2] = RAW_TO_GAUSS_8975(data->asa[2]); + } return 0; } @@ -499,6 +519,9 @@ static int ak8975_probe(struct i2c_client *client, data->eoc_gpio = eoc_gpio; data->eoc_irq = 0; + data->chipset = (enum asahi_compass_chipset)(id->driver_data); + dev_dbg(&client->dev, "Asahi compass chip %s\n", id->name); + /* Perform some basic start-of-day setup of the device. */ err = ak8975_setup(client); if (err < 0) { @@ -552,7 +575,8 @@ static int ak8975_remove(struct i2c_client *client) } static const struct i2c_device_id ak8975_id[] = { - {"ak8975", 0}, + {"ak8975", AK8975}, + {"ak8963", AK8963}, {} }; -- cgit v1.2.3 From d913971ecaf31d7d5a6836224b669e1972469445 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Wed, 19 Mar 2014 16:56:00 +0000 Subject: iio: ak8975: Added ACPI enumeration Added capability so that this device can be enumerated via ACPI. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/ak8975.c | 40 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c index 0f1ca5303139..f5c1d41bf39f 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -475,6 +476,27 @@ static const struct iio_info ak8975_info = { .driver_module = THIS_MODULE, }; +static const struct acpi_device_id ak_acpi_match[] = { + {"AK8975", AK8975}, + {"AK8963", AK8963}, + {"INVN6500", AK8963}, + { }, +}; +MODULE_DEVICE_TABLE(acpi, ak_acpi_match); + +static char *ak8975_match_acpi_device(struct device *dev, + enum asahi_compass_chipset *chipset) +{ + const struct acpi_device_id *id; + + id = acpi_match_device(dev->driver->acpi_match_table, dev); + if (!id) + return NULL; + *chipset = (int)id->driver_data; + + return (char *)dev_name(dev); +} + static int ak8975_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -482,6 +504,7 @@ static int ak8975_probe(struct i2c_client *client, struct iio_dev *indio_dev; int eoc_gpio; int err; + char *name = NULL; /* Grab and set up the supplied GPIO. */ if (client->dev.platform_data) @@ -519,8 +542,18 @@ static int ak8975_probe(struct i2c_client *client, data->eoc_gpio = eoc_gpio; data->eoc_irq = 0; - data->chipset = (enum asahi_compass_chipset)(id->driver_data); - dev_dbg(&client->dev, "Asahi compass chip %s\n", id->name); + /* id will be NULL when enumerated via ACPI */ + if (id) { + data->chipset = + (enum asahi_compass_chipset)(id->driver_data); + name = (char *) id->name; + } else if (ACPI_HANDLE(&client->dev)) + name = ak8975_match_acpi_device(&client->dev, &data->chipset); + else { + err = -ENOSYS; + goto exit_free_iio; + } + dev_dbg(&client->dev, "Asahi compass chip %s\n", name); /* Perform some basic start-of-day setup of the device. */ err = ak8975_setup(client); @@ -538,7 +571,7 @@ static int ak8975_probe(struct i2c_client *client, indio_dev->info = &ak8975_info; indio_dev->name = id->name; indio_dev->modes = INDIO_DIRECT_MODE; - + indio_dev->name = name; err = iio_device_register(indio_dev); if (err < 0) goto exit_free_iio; @@ -593,6 +626,7 @@ static struct i2c_driver ak8975_driver = { .driver = { .name = "ak8975", .of_match_table = ak8975_of_match, + .acpi_match_table = ACPI_PTR(ak_acpi_match), }, .probe = ak8975_probe, .remove = ak8975_remove, -- cgit v1.2.3 From 6f174fd312d50abf3e98c0c5f7adf0cf434ae705 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Wed, 19 Mar 2014 16:56:00 +0000 Subject: iio: imu: inv_mpu6050: Add compatibity with MPU6500 Adding MPU6500 in target list for this driver. Description: Source Document: MPU-6500 Register Map and Descriptions Revision 2.1 Section 3: Register Map This section describes difference in terms device programmability between MPU6050 and MPU6500. These are different registers, which differs between MPU6050 and MPU6500. Addr Name --------------------- 1E LP_ACCEL_ODR 6C PWR_MGMT_2 77 XA_OFFSET_H 78 XA_OFFSET_L 7A YA_OFFSET_H 7B YA_OFFSET_L 7D ZA_OFFSET_H 7E ZA_OFFSET_L But the current MPU6050 driver doesn't use registers which are different except PWR_MGMT_2. The difference is support of "LP_WAKE_CTRL" at bit6-7 in MPU6050 mode. In MPU6500 they are not defined. In current mpu6050 driver, only values used for this register are for standby mode for gyro and accelerometer. In both case frequency of wakeups is set to default and not using bit 6-7. So this driver van as well support MPU6500. In addition MPU6500 can run MPU6050 mode by changing device trim settings. So changing config comments to allow MPU6500 to use this driver. When the driver is enhanced to support more functions, i2c driver data INV_MPU6500 or "WHO_AM_I" register can be used to add additional functionality. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/imu/inv_mpu6050/Kconfig | 2 ++ drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 1 + drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 1 + 3 files changed, 4 insertions(+) diff --git a/drivers/iio/imu/inv_mpu6050/Kconfig b/drivers/iio/imu/inv_mpu6050/Kconfig index 361b2328453d..2d0608ba88d7 100644 --- a/drivers/iio/imu/inv_mpu6050/Kconfig +++ b/drivers/iio/imu/inv_mpu6050/Kconfig @@ -9,6 +9,8 @@ config INV_MPU6050_IIO select IIO_TRIGGERED_BUFFER help This driver supports the Invensense MPU6050 devices. + This driver can also support MPU6500 in MPU6050 compatibility mode + and also in MPU6500 mode with some limitations. It is a gyroscope/accelerometer combo device. This driver can be built as a module. The module will be called inv-mpu6050. diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c index cb9f96b446a5..af287bf71915 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -764,6 +764,7 @@ static SIMPLE_DEV_PM_OPS(inv_mpu_pmops, inv_mpu_suspend, inv_mpu_resume); */ static const struct i2c_device_id inv_mpu_id[] = { {"mpu6050", INV_MPU6050}, + {"mpu6500", INV_MPU6500}, {} }; diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h index 0ab382be1e64..e7799315d4dc 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h @@ -59,6 +59,7 @@ struct inv_mpu6050_reg_map { /*device enum */ enum inv_devices { INV_MPU6050, + INV_MPU6500, INV_NUM_PARTS }; -- cgit v1.2.3 From b64aef7034572b1f669bf295b88332ea0b149050 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 4 May 2014 17:45:00 +0100 Subject: staging:iio:adc:spear adc - prefix defines to avoid namespace clashes. Signed-off-by: Jonathan Cameron Acked-by: Stefan Roese Acked-by: Hartmut Knaack --- drivers/staging/iio/adc/spear_adc.c | 73 ++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/drivers/staging/iio/adc/spear_adc.c b/drivers/staging/iio/adc/spear_adc.c index 970d9edc73b6..49293f9e609f 100644 --- a/drivers/staging/iio/adc/spear_adc.c +++ b/drivers/staging/iio/adc/spear_adc.c @@ -22,39 +22,36 @@ #include #include -/* - * SPEAR registers definitions - */ - -#define SCAN_RATE_LO(x) ((x) & 0xFFFF) -#define SCAN_RATE_HI(x) (((x) >> 0x10) & 0xFFFF) -#define CLK_LOW(x) (((x) & 0xf) << 0) -#define CLK_HIGH(x) (((x) & 0xf) << 4) +/* SPEAR registers definitions */ +#define SPEAR600_ADC_SCAN_RATE_LO(x) ((x) & 0xFFFF) +#define SPEAR600_ADC_SCAN_RATE_HI(x) (((x) >> 0x10) & 0xFFFF) +#define SPEAR_ADC_CLK_LOW(x) (((x) & 0xf) << 0) +#define SPEAR_ADC_CLK_HIGH(x) (((x) & 0xf) << 4) /* Bit definitions for SPEAR_ADC_STATUS */ -#define START_CONVERSION (1 << 0) -#define CHANNEL_NUM(x) ((x) << 1) -#define ADC_ENABLE (1 << 4) -#define AVG_SAMPLE(x) ((x) << 5) -#define VREF_INTERNAL (1 << 9) +#define SPEAR_ADC_STATUS_START_CONVERSION (1 << 0) +#define SPEAR_ADC_STATUS_CHANNEL_NUM(x) ((x) << 1) +#define SPEAR_ADC_STATUS_ADC_ENABLE (1 << 4) +#define SPEAR_ADC_STATUS_AVG_SAMPLE(x) ((x) << 5) +#define SPEAR_ADC_STATUS_VREF_INTERNAL (1 << 9) -#define DATA_MASK 0x03ff -#define DATA_BITS 10 +#define SPEAR_ADC_DATA_MASK 0x03ff +#define SPEAR_ADC_DATA_BITS 10 -#define MOD_NAME "spear-adc" +#define SPEAR_ADC_MOD_NAME "spear-adc" -#define ADC_CHANNEL_NUM 8 +#define SPEAR_ADC_CHANNEL_NUM 8 -#define CLK_MIN 2500000 -#define CLK_MAX 20000000 +#define SPEAR_ADC_CLK_MIN 2500000 +#define SPEAR_ADC_CLK_MAX 20000000 struct adc_regs_spear3xx { u32 status; u32 average; u32 scan_rate; u32 clk; /* Not avail for 1340 & 1310 */ - u32 ch_ctrl[ADC_CHANNEL_NUM]; - u32 ch_data[ADC_CHANNEL_NUM]; + u32 ch_ctrl[SPEAR_ADC_CHANNEL_NUM]; + u32 ch_data[SPEAR_ADC_CHANNEL_NUM]; }; struct chan_data { @@ -66,8 +63,8 @@ struct adc_regs_spear6xx { u32 status; u32 pad[2]; u32 clk; - u32 ch_ctrl[ADC_CHANNEL_NUM]; - struct chan_data ch_data[ADC_CHANNEL_NUM]; + u32 ch_ctrl[SPEAR_ADC_CHANNEL_NUM]; + struct chan_data ch_data[SPEAR_ADC_CHANNEL_NUM]; u32 scan_rate_lo; u32 scan_rate_hi; struct chan_data average; @@ -106,7 +103,7 @@ static void spear_adc_set_clk(struct spear_adc_info *info, u32 val) clk_high = count - clk_low; info->current_clk = apb_clk / count; - __raw_writel(CLK_LOW(clk_low) | CLK_HIGH(clk_high), + __raw_writel(SPEAR_ADC_CLK_LOW(clk_low) | SPEAR_ADC_CLK_HIGH(clk_high), &info->adc_base_spear6xx->clk); } @@ -120,19 +117,19 @@ static u32 spear_adc_get_average(struct spear_adc_info *info) { if (of_device_is_compatible(info->np, "st,spear600-adc")) { return __raw_readl(&info->adc_base_spear6xx->average.msb) & - DATA_MASK; + SPEAR_ADC_DATA_MASK; } else { return __raw_readl(&info->adc_base_spear3xx->average) & - DATA_MASK; + SPEAR_ADC_DATA_MASK; } } static void spear_adc_set_scanrate(struct spear_adc_info *info, u32 rate) { if (of_device_is_compatible(info->np, "st,spear600-adc")) { - __raw_writel(SCAN_RATE_LO(rate), + __raw_writel(SPEAR600_ADC_SCAN_RATE_LO(rate), &info->adc_base_spear6xx->scan_rate_lo); - __raw_writel(SCAN_RATE_HI(rate), + __raw_writel(SPEAR600_ADC_SCAN_RATE_HI(rate), &info->adc_base_spear6xx->scan_rate_hi); } else { __raw_writel(rate, &info->adc_base_spear3xx->scan_rate); @@ -152,11 +149,12 @@ static int spear_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_RAW: mutex_lock(&indio_dev->mlock); - status = CHANNEL_NUM(chan->channel) | - AVG_SAMPLE(info->avg_samples) | - START_CONVERSION | ADC_ENABLE; + status = SPEAR_ADC_STATUS_CHANNEL_NUM(chan->channel) | + SPEAR_ADC_STATUS_AVG_SAMPLE(info->avg_samples) | + SPEAR_ADC_STATUS_START_CONVERSION | + SPEAR_ADC_STATUS_ADC_ENABLE; if (info->vref_external == 0) - status |= VREF_INTERNAL; + status |= SPEAR_ADC_STATUS_VREF_INTERNAL; spear_adc_set_status(info, status); wait_for_completion(&info->completion); /* set by ISR */ @@ -168,7 +166,7 @@ static int spear_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_SCALE: *val = info->vref_external; - *val2 = DATA_BITS; + *val2 = SPEAR_ADC_DATA_BITS; return IIO_VAL_FRACTIONAL_LOG2; } @@ -253,7 +251,7 @@ static ssize_t spear_adc_write_frequency(struct device *dev, mutex_lock(&indio_dev->mlock); - if ((lval < CLK_MIN) || (lval > CLK_MAX)) { + if ((lval < SPEAR_ADC_CLK_MIN) || (lval > SPEAR_ADC_CLK_MAX)) { ret = -EINVAL; goto out; } @@ -339,7 +337,8 @@ static int spear_adc_probe(struct platform_device *pdev) goto errout3; } - ret = devm_request_irq(dev, irq, spear_adc_isr, 0, MOD_NAME, info); + ret = devm_request_irq(dev, irq, spear_adc_isr, 0, SPEAR_ADC_MOD_NAME, + info); if (ret < 0) { dev_err(dev, "failed requesting interrupt\n"); goto errout3; @@ -370,7 +369,7 @@ static int spear_adc_probe(struct platform_device *pdev) init_completion(&info->completion); - iodev->name = MOD_NAME; + iodev->name = SPEAR_ADC_MOD_NAME; iodev->dev.parent = dev; iodev->info = &spear_adc_iio_info; iodev->modes = INDIO_DIRECT_MODE; @@ -419,7 +418,7 @@ static struct platform_driver spear_adc_driver = { .probe = spear_adc_probe, .remove = spear_adc_remove, .driver = { - .name = MOD_NAME, + .name = SPEAR_ADC_MOD_NAME, .owner = THIS_MODULE, .of_match_table = of_match_ptr(spear_adc_dt_ids), }, -- cgit v1.2.3 From a8375a9952c1864bea1047a8087a81747b09f3ae Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 4 May 2014 17:45:00 +0100 Subject: staging:iio:adc:spear_adc drop initialization of unused scan_type As the driver does not support the buffered interfaces of IIO this is not used. Signed-off-by: Jonathan Cameron Acked-by: Stefan Roese --- drivers/staging/iio/adc/spear_adc.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/iio/adc/spear_adc.c b/drivers/staging/iio/adc/spear_adc.c index 49293f9e609f..c4e928b283f8 100644 --- a/drivers/staging/iio/adc/spear_adc.c +++ b/drivers/staging/iio/adc/spear_adc.c @@ -179,10 +179,6 @@ static int spear_read_raw(struct iio_dev *indio_dev, .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ .channel = idx, \ - .scan_type = { \ - .sign = 'u', \ - .storagebits = 16, \ - }, \ } static const struct iio_chan_spec spear_adc_iio_channels[] = { -- cgit v1.2.3 From 932de74ba335358e2521f951c59bbda2746c5aef Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 4 May 2014 17:45:00 +0100 Subject: staging:iio:adc:spear_adc use info_mask_shared_by_all for samp freq Using the core support makes this element available to in kernel users as well as to userspace under exactly the same interface as before. The intent is to move all sampling frequency control to this approach throughout IIO. Drop unused clk_high and clk_low whilst we are at it. Signed-off-by: Jonathan Cameron Acked-by: Stefan Roese Acked-by: Hartmut Knaack --- drivers/staging/iio/adc/spear_adc.c | 92 +++++++++++++------------------------ 1 file changed, 33 insertions(+), 59 deletions(-) diff --git a/drivers/staging/iio/adc/spear_adc.c b/drivers/staging/iio/adc/spear_adc.c index c4e928b283f8..44a129f37d9c 100644 --- a/drivers/staging/iio/adc/spear_adc.c +++ b/drivers/staging/iio/adc/spear_adc.c @@ -168,16 +168,48 @@ static int spear_read_raw(struct iio_dev *indio_dev, *val = info->vref_external; *val2 = SPEAR_ADC_DATA_BITS; return IIO_VAL_FRACTIONAL_LOG2; + case IIO_CHAN_INFO_SAMP_FREQ: + *val = info->current_clk; + return IIO_VAL_INT; } return -EINVAL; } +static int spear_adc_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, + int val2, + long mask) +{ + struct spear_adc_info *info = iio_priv(indio_dev); + int ret = 0; + + if (mask != IIO_CHAN_INFO_SAMP_FREQ) + return -EINVAL; + + mutex_lock(&indio_dev->mlock); + + if ((val < SPEAR_ADC_CLK_MIN) || + (val > SPEAR_ADC_CLK_MAX) || + (val2 != 0)) { + ret = -EINVAL; + goto out; + } + + spear_adc_set_clk(info, val); + +out: + mutex_unlock(&indio_dev->mlock); + return ret; +} + #define SPEAR_ADC_CHAN(idx) { \ .type = IIO_VOLTAGE, \ .indexed = 1, \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),\ .channel = idx, \ } @@ -219,67 +251,9 @@ static int spear_adc_configure(struct spear_adc_info *info) return 0; } -static ssize_t spear_adc_read_frequency(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *indio_dev = dev_to_iio_dev(dev); - struct spear_adc_info *info = iio_priv(indio_dev); - - return sprintf(buf, "%d\n", info->current_clk); -} - -static ssize_t spear_adc_write_frequency(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *indio_dev = dev_to_iio_dev(dev); - struct spear_adc_info *info = iio_priv(indio_dev); - u32 clk_high, clk_low, count; - u32 apb_clk = clk_get_rate(info->clk); - unsigned long lval; - int ret; - - ret = kstrtoul(buf, 10, &lval); - if (ret) - return ret; - - mutex_lock(&indio_dev->mlock); - - if ((lval < SPEAR_ADC_CLK_MIN) || (lval > SPEAR_ADC_CLK_MAX)) { - ret = -EINVAL; - goto out; - } - - count = (apb_clk + lval - 1) / lval; - clk_low = count / 2; - clk_high = count - clk_low; - info->current_clk = apb_clk / count; - spear_adc_set_clk(info, lval); - -out: - mutex_unlock(&indio_dev->mlock); - - return ret ? ret : len; -} - -static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, - spear_adc_read_frequency, - spear_adc_write_frequency); - -static struct attribute *spear_attributes[] = { - &iio_dev_attr_sampling_frequency.dev_attr.attr, - NULL -}; - -static const struct attribute_group spear_attribute_group = { - .attrs = spear_attributes, -}; - static const struct iio_info spear_adc_iio_info = { .read_raw = &spear_read_raw, - .attrs = &spear_attribute_group, + .write_raw = &spear_adc_write_raw, .driver_module = THIS_MODULE, }; -- cgit v1.2.3 From b586e5d9eee038b8ee6f846cdb6cf2fcbcb2f4ed Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 4 May 2014 17:45:00 +0100 Subject: staging:iio:adc:spear rename device specific state structure to _state Also rename instances of it to st. This brings the driver inline with the conventions of IIO and avoids some naming confusion with some IIO structures which also use the _info postfix. Signed-off-by: Jonathan Cameron Acked-by: Hartmut Knaack --- drivers/staging/iio/adc/spear_adc.c | 126 ++++++++++++++++++------------------ 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/drivers/staging/iio/adc/spear_adc.c b/drivers/staging/iio/adc/spear_adc.c index 44a129f37d9c..3003e89b5779 100644 --- a/drivers/staging/iio/adc/spear_adc.c +++ b/drivers/staging/iio/adc/spear_adc.c @@ -70,7 +70,7 @@ struct adc_regs_spear6xx { struct chan_data average; }; -struct spear_adc_info { +struct spear_adc_state { struct device_node *np; struct adc_regs_spear3xx __iomem *adc_base_spear3xx; struct adc_regs_spear6xx __iomem *adc_base_spear6xx; @@ -88,51 +88,51 @@ struct spear_adc_info { * static inline functions, because of different register offsets * on different SoC variants (SPEAr300 vs SPEAr600 etc). */ -static void spear_adc_set_status(struct spear_adc_info *info, u32 val) +static void spear_adc_set_status(struct spear_adc_state *st, u32 val) { - __raw_writel(val, &info->adc_base_spear6xx->status); + __raw_writel(val, &st->adc_base_spear6xx->status); } -static void spear_adc_set_clk(struct spear_adc_info *info, u32 val) +static void spear_adc_set_clk(struct spear_adc_state *st, u32 val) { u32 clk_high, clk_low, count; - u32 apb_clk = clk_get_rate(info->clk); + u32 apb_clk = clk_get_rate(st->clk); count = (apb_clk + val - 1) / val; clk_low = count / 2; clk_high = count - clk_low; - info->current_clk = apb_clk / count; + st->current_clk = apb_clk / count; __raw_writel(SPEAR_ADC_CLK_LOW(clk_low) | SPEAR_ADC_CLK_HIGH(clk_high), - &info->adc_base_spear6xx->clk); + &st->adc_base_spear6xx->clk); } -static void spear_adc_set_ctrl(struct spear_adc_info *info, int n, +static void spear_adc_set_ctrl(struct spear_adc_state *st, int n, u32 val) { - __raw_writel(val, &info->adc_base_spear6xx->ch_ctrl[n]); + __raw_writel(val, &st->adc_base_spear6xx->ch_ctrl[n]); } -static u32 spear_adc_get_average(struct spear_adc_info *info) +static u32 spear_adc_get_average(struct spear_adc_state *st) { - if (of_device_is_compatible(info->np, "st,spear600-adc")) { - return __raw_readl(&info->adc_base_spear6xx->average.msb) & + if (of_device_is_compatible(st->np, "st,spear600-adc")) { + return __raw_readl(&st->adc_base_spear6xx->average.msb) & SPEAR_ADC_DATA_MASK; } else { - return __raw_readl(&info->adc_base_spear3xx->average) & + return __raw_readl(&st->adc_base_spear3xx->average) & SPEAR_ADC_DATA_MASK; } } -static void spear_adc_set_scanrate(struct spear_adc_info *info, u32 rate) +static void spear_adc_set_scanrate(struct spear_adc_state *st, u32 rate) { - if (of_device_is_compatible(info->np, "st,spear600-adc")) { + if (of_device_is_compatible(st->np, "st,spear600-adc")) { __raw_writel(SPEAR600_ADC_SCAN_RATE_LO(rate), - &info->adc_base_spear6xx->scan_rate_lo); + &st->adc_base_spear6xx->scan_rate_lo); __raw_writel(SPEAR600_ADC_SCAN_RATE_HI(rate), - &info->adc_base_spear6xx->scan_rate_hi); + &st->adc_base_spear6xx->scan_rate_hi); } else { - __raw_writel(rate, &info->adc_base_spear3xx->scan_rate); + __raw_writel(rate, &st->adc_base_spear3xx->scan_rate); } } @@ -142,7 +142,7 @@ static int spear_read_raw(struct iio_dev *indio_dev, int *val2, long mask) { - struct spear_adc_info *info = iio_priv(indio_dev); + struct spear_adc_state *st = iio_priv(indio_dev); u32 status; switch (mask) { @@ -150,26 +150,26 @@ static int spear_read_raw(struct iio_dev *indio_dev, mutex_lock(&indio_dev->mlock); status = SPEAR_ADC_STATUS_CHANNEL_NUM(chan->channel) | - SPEAR_ADC_STATUS_AVG_SAMPLE(info->avg_samples) | + SPEAR_ADC_STATUS_AVG_SAMPLE(st->avg_samples) | SPEAR_ADC_STATUS_START_CONVERSION | SPEAR_ADC_STATUS_ADC_ENABLE; - if (info->vref_external == 0) + if (st->vref_external == 0) status |= SPEAR_ADC_STATUS_VREF_INTERNAL; - spear_adc_set_status(info, status); - wait_for_completion(&info->completion); /* set by ISR */ - *val = info->value; + spear_adc_set_status(st, status); + wait_for_completion(&st->completion); /* set by ISR */ + *val = st->value; mutex_unlock(&indio_dev->mlock); return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: - *val = info->vref_external; + *val = st->vref_external; *val2 = SPEAR_ADC_DATA_BITS; return IIO_VAL_FRACTIONAL_LOG2; case IIO_CHAN_INFO_SAMP_FREQ: - *val = info->current_clk; + *val = st->current_clk; return IIO_VAL_INT; } @@ -182,7 +182,7 @@ static int spear_adc_write_raw(struct iio_dev *indio_dev, int val2, long mask) { - struct spear_adc_info *info = iio_priv(indio_dev); + struct spear_adc_state *st = iio_priv(indio_dev); int ret = 0; if (mask != IIO_CHAN_INFO_SAMP_FREQ) @@ -197,7 +197,7 @@ static int spear_adc_write_raw(struct iio_dev *indio_dev, goto out; } - spear_adc_set_clk(info, val); + spear_adc_set_clk(st, val); out: mutex_unlock(&indio_dev->mlock); @@ -226,32 +226,32 @@ static const struct iio_chan_spec spear_adc_iio_channels[] = { static irqreturn_t spear_adc_isr(int irq, void *dev_id) { - struct spear_adc_info *info = (struct spear_adc_info *)dev_id; + struct spear_adc_state *st = (struct spear_adc_state *)dev_id; /* Read value to clear IRQ */ - info->value = spear_adc_get_average(info); - complete(&info->completion); + st->value = spear_adc_get_average(st); + complete(&st->completion); return IRQ_HANDLED; } -static int spear_adc_configure(struct spear_adc_info *info) +static int spear_adc_configure(struct spear_adc_state *st) { int i; /* Reset ADC core */ - spear_adc_set_status(info, 0); - __raw_writel(0, &info->adc_base_spear6xx->clk); + spear_adc_set_status(st, 0); + __raw_writel(0, &st->adc_base_spear6xx->clk); for (i = 0; i < 8; i++) - spear_adc_set_ctrl(info, i, 0); - spear_adc_set_scanrate(info, 0); + spear_adc_set_ctrl(st, i, 0); + spear_adc_set_scanrate(st, 0); - spear_adc_set_clk(info, info->sampling_freq); + spear_adc_set_clk(st, st->sampling_freq); return 0; } -static const struct iio_info spear_adc_iio_info = { +static const struct iio_info spear_adc_info = { .read_raw = &spear_read_raw, .write_raw = &spear_adc_write_raw, .driver_module = THIS_MODULE, @@ -261,40 +261,40 @@ static int spear_adc_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; struct device *dev = &pdev->dev; - struct spear_adc_info *info; + struct spear_adc_state *st; struct iio_dev *iodev = NULL; int ret = -ENODEV; int irq; - iodev = devm_iio_device_alloc(dev, sizeof(struct spear_adc_info)); + iodev = devm_iio_device_alloc(dev, sizeof(struct spear_adc_state)); if (!iodev) { dev_err(dev, "failed allocating iio device\n"); return -ENOMEM; } - info = iio_priv(iodev); - info->np = np; + st = iio_priv(iodev); + st->np = np; /* * SPEAr600 has a different register layout than other SPEAr SoC's * (e.g. SPEAr3xx). Let's provide two register base addresses * to support multi-arch kernels. */ - info->adc_base_spear6xx = of_iomap(np, 0); - if (!info->adc_base_spear6xx) { + st->adc_base_spear6xx = of_iomap(np, 0); + if (!st->adc_base_spear6xx) { dev_err(dev, "failed mapping memory\n"); return -ENOMEM; } - info->adc_base_spear3xx = - (struct adc_regs_spear3xx __iomem *)info->adc_base_spear6xx; + st->adc_base_spear3xx = + (struct adc_regs_spear3xx __iomem *)st->adc_base_spear6xx; - info->clk = clk_get(dev, NULL); - if (IS_ERR(info->clk)) { + st->clk = clk_get(dev, NULL); + if (IS_ERR(st->clk)) { dev_err(dev, "failed getting clock\n"); goto errout1; } - ret = clk_prepare_enable(info->clk); + ret = clk_prepare_enable(st->clk); if (ret) { dev_err(dev, "failed enabling clock\n"); goto errout2; @@ -308,14 +308,14 @@ static int spear_adc_probe(struct platform_device *pdev) } ret = devm_request_irq(dev, irq, spear_adc_isr, 0, SPEAR_ADC_MOD_NAME, - info); + st); if (ret < 0) { dev_err(dev, "failed requesting interrupt\n"); goto errout3; } if (of_property_read_u32(np, "sampling-frequency", - &info->sampling_freq)) { + &st->sampling_freq)) { dev_err(dev, "sampling-frequency missing in DT\n"); ret = -EINVAL; goto errout3; @@ -325,23 +325,23 @@ static int spear_adc_probe(struct platform_device *pdev) * Optional avg_samples defaults to 0, resulting in single data * conversion */ - of_property_read_u32(np, "average-samples", &info->avg_samples); + of_property_read_u32(np, "average-samples", &st->avg_samples); /* * Optional vref_external defaults to 0, resulting in internal vref * selection */ - of_property_read_u32(np, "vref-external", &info->vref_external); + of_property_read_u32(np, "vref-external", &st->vref_external); - spear_adc_configure(info); + spear_adc_configure(st); platform_set_drvdata(pdev, iodev); - init_completion(&info->completion); + init_completion(&st->completion); iodev->name = SPEAR_ADC_MOD_NAME; iodev->dev.parent = dev; - iodev->info = &spear_adc_iio_info; + iodev->info = &spear_adc_info; iodev->modes = INDIO_DIRECT_MODE; iodev->channels = spear_adc_iio_channels; iodev->num_channels = ARRAY_SIZE(spear_adc_iio_channels); @@ -355,23 +355,23 @@ static int spear_adc_probe(struct platform_device *pdev) return 0; errout3: - clk_disable_unprepare(info->clk); + clk_disable_unprepare(st->clk); errout2: - clk_put(info->clk); + clk_put(st->clk); errout1: - iounmap(info->adc_base_spear6xx); + iounmap(st->adc_base_spear6xx); return ret; } static int spear_adc_remove(struct platform_device *pdev) { struct iio_dev *iodev = platform_get_drvdata(pdev); - struct spear_adc_info *info = iio_priv(iodev); + struct spear_adc_state *st = iio_priv(iodev); iio_device_unregister(iodev); - clk_disable_unprepare(info->clk); - clk_put(info->clk); - iounmap(info->adc_base_spear6xx); + clk_disable_unprepare(st->clk); + clk_put(st->clk); + iounmap(st->adc_base_spear6xx); return 0; } -- cgit v1.2.3 From e90ba52f4dee0e8e96910efe96358b1f9ed0f9d2 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 4 May 2014 17:45:00 +0100 Subject: staging:iio:adc:spear rename iodev -> indio_dev to fit with current convention How we ended up with indio_dev is a mystery, but we have so in the interests of consistency, move this driver over to that convention. Signed-off-by: Jonathan Cameron Acked-by: Hartmut Knaack --- drivers/staging/iio/adc/spear_adc.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/staging/iio/adc/spear_adc.c b/drivers/staging/iio/adc/spear_adc.c index 3003e89b5779..52c26a6b7c1f 100644 --- a/drivers/staging/iio/adc/spear_adc.c +++ b/drivers/staging/iio/adc/spear_adc.c @@ -262,17 +262,17 @@ static int spear_adc_probe(struct platform_device *pdev) struct device_node *np = pdev->dev.of_node; struct device *dev = &pdev->dev; struct spear_adc_state *st; - struct iio_dev *iodev = NULL; + struct iio_dev *indio_dev = NULL; int ret = -ENODEV; int irq; - iodev = devm_iio_device_alloc(dev, sizeof(struct spear_adc_state)); - if (!iodev) { + indio_dev = devm_iio_device_alloc(dev, sizeof(struct spear_adc_state)); + if (!indio_dev) { dev_err(dev, "failed allocating iio device\n"); return -ENOMEM; } - st = iio_priv(iodev); + st = iio_priv(indio_dev); st->np = np; /* @@ -335,18 +335,18 @@ static int spear_adc_probe(struct platform_device *pdev) spear_adc_configure(st); - platform_set_drvdata(pdev, iodev); + platform_set_drvdata(pdev, indio_dev); init_completion(&st->completion); - iodev->name = SPEAR_ADC_MOD_NAME; - iodev->dev.parent = dev; - iodev->info = &spear_adc_info; - iodev->modes = INDIO_DIRECT_MODE; - iodev->channels = spear_adc_iio_channels; - iodev->num_channels = ARRAY_SIZE(spear_adc_iio_channels); + indio_dev->name = SPEAR_ADC_MOD_NAME; + indio_dev->dev.parent = dev; + indio_dev->info = &spear_adc_info; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = spear_adc_iio_channels; + indio_dev->num_channels = ARRAY_SIZE(spear_adc_iio_channels); - ret = iio_device_register(iodev); + ret = iio_device_register(indio_dev); if (ret) goto errout3; @@ -365,10 +365,10 @@ errout1: static int spear_adc_remove(struct platform_device *pdev) { - struct iio_dev *iodev = platform_get_drvdata(pdev); - struct spear_adc_state *st = iio_priv(iodev); + struct iio_dev *indio_dev = platform_get_drvdata(pdev); + struct spear_adc_state *st = iio_priv(indio_dev); - iio_device_unregister(iodev); + iio_device_unregister(indio_dev); clk_disable_unprepare(st->clk); clk_put(st->clk); iounmap(st->adc_base_spear6xx); -- cgit v1.2.3 From e20d6090e314fa52f25e4a257de3672aa474122c Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 4 May 2014 17:45:00 +0100 Subject: staging:iio:adc:spear rename spear_read_raw to spear_adc_read_raw This brings it inline with all the other prefix usage in the driver. Signed-off-by: Jonathan Cameron Acked-by: Hartmut Knaack --- drivers/staging/iio/adc/spear_adc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/iio/adc/spear_adc.c b/drivers/staging/iio/adc/spear_adc.c index 52c26a6b7c1f..c5492ba50751 100644 --- a/drivers/staging/iio/adc/spear_adc.c +++ b/drivers/staging/iio/adc/spear_adc.c @@ -136,11 +136,11 @@ static void spear_adc_set_scanrate(struct spear_adc_state *st, u32 rate) } } -static int spear_read_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int *val, - int *val2, - long mask) +static int spear_adc_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, + int *val2, + long mask) { struct spear_adc_state *st = iio_priv(indio_dev); u32 status; @@ -252,7 +252,7 @@ static int spear_adc_configure(struct spear_adc_state *st) } static const struct iio_info spear_adc_info = { - .read_raw = &spear_read_raw, + .read_raw = &spear_adc_read_raw, .write_raw = &spear_adc_write_raw, .driver_module = THIS_MODULE, }; -- cgit v1.2.3 From 9ef080ec0c5e9cddf68e73a70438a2a7916b595a Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Mon, 4 Aug 2014 14:24:00 +0100 Subject: iio: adc: Fix exynos_adc dependencies EXYNOS_ADC shouldn't only depend on OF. It is useless on architectures other than Exynos so it should depend on ARCH_EXYNOS (which implies OF.) Signed-off-by: Jean Delvare Cc: Jonathan Cameron Cc: Kukjin Kim Signed-off-by: Jonathan Cameron --- drivers/iio/adc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 1dffa2d56262..5572c5067c3c 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -118,7 +118,7 @@ config AT91_ADC config EXYNOS_ADC bool "Exynos ADC driver support" - depends on OF + depends on ARCH_EXYNOS || (OF && COMPILE_TEST) help Core support for the ADC block found in the Samsung EXYNOS series of SoCs for drivers such as the touchscreen and hwmon to use to share -- cgit v1.2.3 From 913423409df02fe6706ee81d9ac5c31f166c3d6c Mon Sep 17 00:00:00 2001 From: Michael Welling Date: Sat, 4 Oct 2014 03:26:00 +0100 Subject: Staging:iio:tsl2583 Removes unwanted space before semicolon Signed-off-by: Michael Welling Signed-off-by: Jonathan Cameron --- drivers/staging/iio/light/tsl2583.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index f8c659568c38..9d39387b47b9 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -211,7 +211,7 @@ static int taos_get_lux(struct iio_dev *indio_dev) if (chip->taos_chip_status != TSL258X_CHIP_WORKING) { /* device is not enabled */ dev_err(&chip->client->dev, "taos_get_lux device is not enabled\n"); - ret = -EBUSY ; + ret = -EBUSY; goto out_unlock; } -- cgit v1.2.3 From cf0d0739c0d1f1ae6178c187db6550b96dfa2019 Mon Sep 17 00:00:00 2001 From: Michael Welling Date: Sat, 4 Oct 2014 03:26:00 +0100 Subject: Staging:iio:tsl2583 Remove quoted string split across lines warnings Signed-off-by: Michael Welling Signed-off-by: Jonathan Cameron --- drivers/staging/iio/light/tsl2583.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index 9d39387b47b9..8d46c92f6f64 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -165,8 +165,9 @@ taos_i2c_read(struct i2c_client *client, u8 reg, u8 *val, unsigned int len) /* select register to write */ ret = i2c_smbus_write_byte(client, (TSL258X_CMD_REG | reg)); if (ret < 0) { - dev_err(&client->dev, "taos_i2c_read failed to write" - " register %x\n", reg); + dev_err(&client->dev, + "taos_i2c_read failed to write register %x\n", + reg); return ret; } /* read the data */ @@ -231,8 +232,9 @@ static int taos_get_lux(struct iio_dev *indio_dev) int reg = TSL258X_CMD_REG | (TSL258X_ALS_CHAN0LO + i); ret = taos_i2c_read(chip->client, reg, &buf[i], 1); if (ret < 0) { - dev_err(&chip->client->dev, "taos_get_lux failed to read" - " register %x\n", reg); + dev_err(&chip->client->dev, + "taos_get_lux failed to read register %x\n", + reg); goto out_unlock; } } @@ -809,9 +811,7 @@ static int taos_probe(struct i2c_client *clientp, if (!i2c_check_functionality(clientp->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { - dev_err(&clientp->dev, - "taos_probe() - i2c smbus byte data " - "functions unsupported\n"); + dev_err(&clientp->dev, "taos_probe() - i2c smbus byte data func unsupported\n"); return -EOPNOTSUPP; } @@ -830,30 +830,32 @@ static int taos_probe(struct i2c_client *clientp, ret = i2c_smbus_write_byte(clientp, (TSL258X_CMD_REG | (TSL258X_CNTRL + i))); if (ret < 0) { - dev_err(&clientp->dev, "i2c_smbus_write_bytes() to cmd " - "reg failed in taos_probe(), err = %d\n", ret); + dev_err(&clientp->dev, + "i2c_smbus_write_byte to cmd reg failed in taos_probe(), err = %d\n", + ret); return ret; } ret = i2c_smbus_read_byte(clientp); if (ret < 0) { - dev_err(&clientp->dev, "i2c_smbus_read_byte from " - "reg failed in taos_probe(), err = %d\n", ret); - + dev_err(&clientp->dev, + "i2c_smbus_read_byte from reg failed in taos_probe(), err = %d\n", + ret); return ret; } buf[i] = ret; } if (!taos_tsl258x_device(buf)) { - dev_info(&clientp->dev, "i2c device found but does not match " - "expected id in taos_probe()\n"); + dev_info(&clientp->dev, + "i2c device found but does not match expected id in taos_probe()\n"); return -EINVAL; } ret = i2c_smbus_write_byte(clientp, (TSL258X_CMD_REG | TSL258X_CNTRL)); if (ret < 0) { - dev_err(&clientp->dev, "i2c_smbus_write_byte() to cmd reg " - "failed in taos_probe(), err = %d\n", ret); + dev_err(&clientp->dev, + "i2c_smbus_write_byte() to cmd reg failed in taos_probe(), err = %d\n", + ret); return ret; } -- cgit v1.2.3 From e193385bf4fa1bdbafcc12eaea4f0e718aeae858 Mon Sep 17 00:00:00 2001 From: Michael Welling Date: Sat, 4 Oct 2014 03:26:00 +0100 Subject: Staging:iio:tsl2583 Switch from msleep to usleep range per timers-howto.txt Signed-off-by: Michael Welling Signed-off-by: Jonathan Cameron --- drivers/staging/iio/light/tsl2583.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index 8d46c92f6f64..de3c9d8e7722 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -451,7 +451,7 @@ static int taos_chip_on(struct iio_dev *indio_dev) } } - msleep(3); + usleep_range(3000, 3500); /* NOW enable the ADC * initialize the desired mode of operation */ utmp = TSL258X_CNTL_PWR_ON | TSL258X_CNTL_ADC_ENBL; -- cgit v1.2.3 From 763b4247cafdb978630d4da7ff48c8113c7d961e Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:14 +0200 Subject: staging: rtl8723au: Remove a bunch of calls via indirect HAL interface and call functions directly The 'HW' variable interface is confusing and simply obfuscates the code, so this is the first patch in a series to remove it and make direct calls to the functions in place. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 10 ++++---- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 9 ++++--- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 30 ++--------------------- drivers/staging/rtl8723au/include/hal_intf.h | 8 ++---- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 3 +-- drivers/staging/rtl8723au/os_dep/os_intfs.c | 2 +- 6 files changed, 16 insertions(+), 46 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 4c753639ea5a..7be834f996ab 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -7561,7 +7561,7 @@ unsigned int send_beacon23a(struct rtw_adapter *padapter) unsigned long start = jiffies; unsigned int passing_time; - rtw_hal_set_hwreg23a(padapter, HW_VAR_BCN_VALID, NULL); + rtl8723a_bcn_valid(padapter); do { issue_beacon23a(padapter, 100); issue++; @@ -8832,7 +8832,7 @@ void mlmeext_sta_del_event_callback23a(struct rtw_adapter *padapter) { /* set_opmode_cmd(padapter, infra_client_with_mlme); */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_DISCONNECT, NULL); + hw_var_set_mlme_disconnect(padapter); rtw_hal_set_hwreg23a(padapter, HW_VAR_BSSID, null_addr); /* restore to initial setting. */ @@ -9305,7 +9305,7 @@ u8 join_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) /* Set_MSR23a(padapter, _HW_STATE_NOLINK_); */ Set_MSR23a(padapter, _HW_STATE_STATION_); - rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_DISCONNECT, NULL); + hw_var_set_mlme_disconnect(padapter); } rtw_joinbss_reset23a(padapter); @@ -9424,7 +9424,7 @@ u8 disconnect_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf) /* pmlmeinfo->state = WIFI_FW_NULL_STATE; */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_DISCONNECT, NULL); + hw_var_set_mlme_disconnect(padapter); rtw_hal_set_hwreg23a(padapter, HW_VAR_BSSID, null_addr); /* restore to initial setting. */ @@ -9644,7 +9644,7 @@ u8 setkey_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) write_cam23a(padapter, pparm->keyid, ctrl, null_sta, pparm->key); /* allow multicast packets to driver */ - padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_ON_RCR_AM, null_addr); + rtl8723a_on_rcr_am(padapter); return H2C_SUCCESS; } diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 0dfcfbce3b52..3ed3beb2e6d3 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -490,7 +490,7 @@ void CAM_empty_entry23a(struct rtw_adapter *Adapter, u8 ucIndex) void invalidate_cam_all23a(struct rtw_adapter *padapter) { - rtw_hal_set_hwreg23a(padapter, HW_VAR_CAM_INVALID_ALL, NULL); + rtl8723a_cam_invalid_all(padapter); } void write_cam23a(struct rtw_adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key) @@ -561,7 +561,7 @@ void flush_all_cam_entry23a(struct rtw_adapter *padapter) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - rtw_hal_set_hwreg23a(padapter, HW_VAR_CAM_INVALID_ALL, NULL); + rtl8723a_cam_invalid_all(padapter); memset((u8 *)(pmlmeinfo->FW_sta_info), 0, sizeof(pmlmeinfo->FW_sta_info)); } @@ -1726,9 +1726,10 @@ void update_TSF23a(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len) pmlmeext->TSFValue |= le32_to_cpu(*pbuf); } -void correct_TSF23a(struct rtw_adapter *padapter, struct mlme_ext_priv *pmlmeext) +void correct_TSF23a(struct rtw_adapter *padapter, + struct mlme_ext_priv *pmlmeext) { - rtw_hal_set_hwreg23a(padapter, HW_VAR_CORRECT_TSF, NULL); + hw_var_set_correct_tsf(padapter); } void beacon_timing_control23a(struct rtw_adapter *padapter) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 0982b0a4ab9b..a09716907569 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3018,7 +3018,7 @@ static void hw_var_set_bssid(struct rtw_adapter *padapter, u8 *val) rtw_write8(padapter, (reg_bssid + idx), val[idx]); } -static void hw_var_set_correct_tsf(struct rtw_adapter *padapter) +void hw_var_set_correct_tsf(struct rtw_adapter *padapter) { u64 tsf; u32 reg_tsftr; @@ -3055,7 +3055,7 @@ static void hw_var_set_correct_tsf(struct rtw_adapter *padapter) ResumeTxBeacon(padapter); } -static void hw_var_set_mlme_disconnect(struct rtw_adapter *padapter) +void hw_var_set_mlme_disconnect(struct rtw_adapter *padapter) { /* reject all data frames */ rtw_write16(padapter, REG_RXFLTMAP2, 0); @@ -3167,18 +3167,10 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_set_bcn_func(padapter, *val); break; - case HW_VAR_CORRECT_TSF: - hw_var_set_correct_tsf(padapter); - break; - case HW_VAR_CHECK_BSSID: rtl8723a_check_bssid(padapter, *val); break; - case HW_VAR_MLME_DISCONNECT: - hw_var_set_mlme_disconnect(padapter); - break; - case HW_VAR_MLME_SITESURVEY: rtl8723a_mlme_sitesurvey(padapter, *val); break; @@ -3187,14 +3179,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) hw_var_set_mlme_join(padapter, *val); break; - case HW_VAR_ON_RCR_AM: - rtl8723a_on_rcr_am(padapter); - break; - - case HW_VAR_OFF_RCR_AM: - rtl8723a_off_rcr_am(padapter); - break; - case HW_VAR_BEACON_INTERVAL: rtl8723a_set_beacon_interval(padapter, *((u16 *) val)); break; @@ -3234,10 +3218,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_cam_empty_entry(padapter, *val); break; - case HW_VAR_CAM_INVALID_ALL: - rtl8723a_cam_invalid_all(padapter); - break; - case HW_VAR_CAM_WRITE: rtl8723a_cam_write(padapter, val32[0], val32[1]); break; @@ -3297,9 +3277,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) case HW_VAR_EFUSE_BT_BYTES: pHalData->BTEfuseUsedBytes = *((u16 *) val); break; - case HW_VAR_FIFO_CLEARN_UP: - rtl8723a_fifo_cleanup(padapter); - break; case HW_VAR_CHECK_TXBUF: break; case HW_VAR_APFM_ON_MAC: @@ -3309,9 +3286,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) case HW_VAR_NAV_UPPER: rtl8723a_set_nav_upper(padapter, *val32); break; - case HW_VAR_BCN_VALID: - rtl8723a_bcn_valid(padapter); - break; default: break; } diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index d183f4ba1ecb..5bd47136def7 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -45,13 +45,9 @@ enum HW_VARIABLES { HW_VAR_BASIC_RATE, HW_VAR_TXPAUSE, HW_VAR_BCN_FUNC, - HW_VAR_CORRECT_TSF, HW_VAR_CHECK_BSSID, - HW_VAR_MLME_DISCONNECT, HW_VAR_MLME_SITESURVEY, HW_VAR_MLME_JOIN, - HW_VAR_ON_RCR_AM, - HW_VAR_OFF_RCR_AM, HW_VAR_BEACON_INTERVAL, HW_VAR_SLOT_TIME, HW_VAR_RESP_SIFS, @@ -64,7 +60,6 @@ enum HW_VARIABLES { HW_VAR_DM_FUNC_SET, HW_VAR_DM_FUNC_CLR, HW_VAR_CAM_EMPTY_ENTRY, - HW_VAR_CAM_INVALID_ALL, HW_VAR_CAM_WRITE, HW_VAR_CAM_READ, HW_VAR_AC_PARAM_VO, @@ -94,7 +89,6 @@ enum HW_VARIABLES { HW_VAR_SWITCH_EPHY_WoWLAN, HW_VAR_EFUSE_BYTES, HW_VAR_EFUSE_BT_BYTES, - HW_VAR_FIFO_CLEARN_UP, HW_VAR_CHECK_TXBUF, HW_VAR_APFM_ON_MAC, /* Auto FSM to Turn On, include clock, isolation, power control for MAC only */ /* The valid upper nav range for the HW updating, if the true value is larger than the upper range, the HW won't update it. */ @@ -388,5 +382,7 @@ void rtw_hal_reset_security_engine23a(struct rtw_adapter *adapter); s32 rtw_hal_c2h_handler23a(struct rtw_adapter *adapter, struct c2h_evt_hdr *c2h_evt); c2h_id_filter rtw_hal_c2h_id_filter_ccx23a(struct rtw_adapter *adapter); +void hw_var_set_correct_tsf(struct rtw_adapter *padapter); +void hw_var_set_mlme_disconnect(struct rtw_adapter *padapter); #endif /* __HAL_INTF_H__ */ diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 50840b9a11fa..58366236777f 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -1883,7 +1883,6 @@ static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie, int wpa_ielen = 0; int wpa2_ielen = 0; u8 *pwpa, *pwpa2; - u8 null_addr[] = { 0, 0, 0, 0, 0, 0 }; int i; if (!pie || !ielen) { @@ -2097,7 +2096,7 @@ static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie, padapter->securitypriv.dot11PrivacyAlgrthm == _AES_) /* WPS open need to enable multicast */ /* check_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS) == true)*/ - rtw_hal_set_hwreg23a(padapter, HW_VAR_OFF_RCR_AM, null_addr); + rtl8723a_off_rcr_am(padapter); RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("rtw_set_wpa_ie: pairwise_cipher = 0x%08x padapter->" diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index 57eca7a45672..eab40d21fb3d 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -887,7 +887,7 @@ void rtw_ips_pwr_down23a(struct rtw_adapter *padapter) void rtw_ips_dev_unload23a(struct rtw_adapter *padapter) { - rtw_hal_set_hwreg23a(padapter, HW_VAR_FIFO_CLEARN_UP, NULL); + rtl8723a_fifo_cleanup(padapter); if (padapter->intf_stop) padapter->intf_stop(padapter); -- cgit v1.2.3 From ff5d82e45740bbaa47e15147f705dae42ab9524d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:15 +0200 Subject: staging: rtl8723au: This gets rid of the last HW_VAR_BCN_VALID usage Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 6 +++--- drivers/staging/rtl8723au/hal/hal_com.c | 9 +++++++++ drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 6 ------ drivers/staging/rtl8723au/include/hal_com.h | 1 + drivers/staging/rtl8723au/include/hal_intf.h | 1 - 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 7be834f996ab..28750eb4169e 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -7555,7 +7555,7 @@ unsigned int send_delba23a(struct rtw_adapter *padapter, u8 initiator, u8 *addr) unsigned int send_beacon23a(struct rtw_adapter *padapter) { - u8 bxmitok = false; + bool bxmitok; int issue = 0; int poll = 0; unsigned long start = jiffies; @@ -7567,9 +7567,9 @@ unsigned int send_beacon23a(struct rtw_adapter *padapter) issue++; do { yield(); - rtw23a_hal_get_hwreg(padapter, HW_VAR_BCN_VALID, (u8 *)(&bxmitok)); + bxmitok = rtl8723a_get_bcn_valid(padapter); poll++; - } while ((poll%10)!= 0 && false == bxmitok && + } while ((poll % 10) != 0 && bxmitok == false && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index 0640f3522136..5f20117e4e4f 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -752,6 +752,15 @@ void rtl8723a_bcn_valid(struct rtw_adapter *padapter) rtw_read8(padapter, REG_TDECTRL + 2) | BIT0); } +bool rtl8723a_get_bcn_valid(struct rtw_adapter *padapter) +{ + bool retval; + + retval = (rtw_read8(padapter, REG_TDECTRL + 2) & BIT0) ? true : false; + + return retval; +} + void rtl8723a_set_tx_pause(struct rtw_adapter *padapter, u8 pause) { rtw_write8(padapter, REG_TXPAUSE, pause); diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index a09716907569..26efc7069977 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3305,12 +3305,6 @@ void GetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) *val = rtw_read8(padapter, REG_TXPAUSE); break; - case HW_VAR_BCN_VALID: - /* BCN_VALID, BIT16 of REG_TDECTRL = BIT0 of REG_TDECTRL+2 */ - val[0] = (BIT0 & rtw_read8(padapter, REG_TDECTRL + 2)) ? true : - false; - break; - case HW_VAR_RF_TYPE: *val = pHalData->rf_type; break; diff --git a/drivers/staging/rtl8723au/include/hal_com.h b/drivers/staging/rtl8723au/include/hal_com.h index 20f983cfc2b7..8e94d2e3ecef 100644 --- a/drivers/staging/rtl8723au/include/hal_com.h +++ b/drivers/staging/rtl8723au/include/hal_com.h @@ -189,6 +189,7 @@ void rtl8723a_cam_write(struct rtw_adapter *padapter, u32 val1, u32 val2); void rtl8723a_fifo_cleanup(struct rtw_adapter *padapter); void rtl8723a_set_apfm_on_mac(struct rtw_adapter *padapter, u8 val); void rtl8723a_bcn_valid(struct rtw_adapter *padapter); +bool rtl8723a_get_bcn_valid(struct rtw_adapter *padapter); void rtl8723a_set_tx_pause(struct rtw_adapter *padapter, u8 pause); void rtl8723a_set_beacon_interval(struct rtw_adapter *padapter, u16 interval); void rtl8723a_set_resp_sifs(struct rtw_adapter *padapter, diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 5bd47136def7..a5306e618f9a 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -53,7 +53,6 @@ enum HW_VARIABLES { HW_VAR_RESP_SIFS, HW_VAR_ACK_PREAMBLE, HW_VAR_SEC_CFG, - HW_VAR_BCN_VALID, HW_VAR_RF_TYPE, HW_VAR_DM_FLAG, HW_VAR_DM_FUNC_OP, -- cgit v1.2.3 From 03aa3ec054e9b2354a587cf3652c4e4ffd67c5b8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:16 +0200 Subject: staging: rtl8723au: Remove HW_VAR_MEDIA_STATUS* usage Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 7 +------ drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 8 -------- drivers/staging/rtl8723au/include/hal_intf.h | 2 -- 3 files changed, 1 insertion(+), 16 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 3ed3beb2e6d3..0114c46c36a1 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -304,14 +304,9 @@ void Switch_DM_Func23a(struct rtw_adapter *padapter, unsigned long mode, u8 enab rtw_hal_set_hwreg23a(padapter, HW_VAR_DM_FUNC_CLR, (u8 *)(&mode)); } -static void Set_NETYPE0_MSR(struct rtw_adapter *padapter, u8 type) -{ - rtw_hal_set_hwreg23a(padapter, HW_VAR_MEDIA_STATUS, (u8 *)(&type)); -} - void Set_MSR23a(struct rtw_adapter *padapter, u8 type) { - Set_NETYPE0_MSR(padapter, type); + rtl8723a_set_media_status(padapter, type); } inline u8 rtw_get_oper_ch23a(struct rtw_adapter *adapter) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 26efc7069977..d6afc049548f 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3135,14 +3135,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) u32 *val32 = (u32 *)val; switch (variable) { - case HW_VAR_MEDIA_STATUS: - rtl8723a_set_media_status(padapter, *val); - break; - - case HW_VAR_MEDIA_STATUS1: - rtl8723a_set_media_status1(padapter, *val); - break; - case HW_VAR_SET_OPMODE: hw_var_set_opmode(padapter, *val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index a5306e618f9a..c4a1869527e7 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -36,8 +36,6 @@ enum _CHIP_TYPE { }; enum HW_VARIABLES { - HW_VAR_MEDIA_STATUS, - HW_VAR_MEDIA_STATUS1, HW_VAR_SET_OPMODE, HW_VAR_MAC_ADDR, HW_VAR_BSSID, -- cgit v1.2.3 From dbdcd36b2e8c23d4abb871993754878086cec920 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:17 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_SET_OPMODE usage Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 16 ++++------------ drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 6 +----- drivers/staging/rtl8723au/include/hal_intf.h | 2 +- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 28750eb4169e..d91e88e0f955 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -9189,27 +9189,19 @@ u8 setopmode_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct setopmode_parm *psetop = (struct setopmode_parm *)pbuf; - if (psetop->mode == Ndis802_11APMode) - { + if (psetop->mode == Ndis802_11APMode) { pmlmeinfo->state = WIFI_FW_AP_STATE; type = _HW_STATE_AP_; - } - else if (psetop->mode == Ndis802_11Infrastructure) - { + } else if (psetop->mode == Ndis802_11Infrastructure) { pmlmeinfo->state &= ~(BIT(0)|BIT(1));/* clear state */ pmlmeinfo->state |= WIFI_FW_STATION_STATE;/* set to STATION_STATE */ type = _HW_STATE_STATION_; - } - else if (psetop->mode == Ndis802_11IBSS) - { + } else if (psetop->mode == Ndis802_11IBSS) type = _HW_STATE_ADHOC_; - } else - { type = _HW_STATE_NOLINK_; - } - rtw_hal_set_hwreg23a(padapter, HW_VAR_SET_OPMODE, (u8 *)(&type)); + hw_var_set_opmode(padapter, type); /* Set_NETYPE0_MSR(padapter, type); */ return H2C_SUCCESS; diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index d6afc049548f..eebd01cea138 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -2935,7 +2935,7 @@ void rtl8723a_fill_fake_txdesc(struct rtw_adapter *padapter, u8 *pDesc, rtl8723a_cal_txdesc_chksum(ptxdesc); } -static void hw_var_set_opmode(struct rtw_adapter *padapter, u8 mode) +void hw_var_set_opmode(struct rtw_adapter *padapter, u8 mode) { u8 val8; @@ -3135,10 +3135,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) u32 *val32 = (u32 *)val; switch (variable) { - case HW_VAR_SET_OPMODE: - hw_var_set_opmode(padapter, *val); - break; - case HW_VAR_MAC_ADDR: hw_var_set_macaddr(padapter, val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index c4a1869527e7..ee3315ec7d77 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -36,7 +36,6 @@ enum _CHIP_TYPE { }; enum HW_VARIABLES { - HW_VAR_SET_OPMODE, HW_VAR_MAC_ADDR, HW_VAR_BSSID, HW_VAR_INIT_RTS_RATE, @@ -381,5 +380,6 @@ s32 rtw_hal_c2h_handler23a(struct rtw_adapter *adapter, struct c2h_evt_hdr *c2h_ c2h_id_filter rtw_hal_c2h_id_filter_ccx23a(struct rtw_adapter *adapter); void hw_var_set_correct_tsf(struct rtw_adapter *padapter); void hw_var_set_mlme_disconnect(struct rtw_adapter *padapter); +void hw_var_set_opmode(struct rtw_adapter *padapter, u8 mode); #endif /* __HAL_INTF_H__ */ -- cgit v1.2.3 From fa2e52092ad5a6877dbf3819006c3e2c655f7aa4 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:18 +0200 Subject: staging: rtl8723au: Eliminate usage of HW_VAR_BASIC_RATE Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 2 +- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 2 +- drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 2 +- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 8 -------- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 6 files changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index a357e98cb83e..95311bd8fe76 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -715,7 +715,7 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) rtw_hal_set_hwreg23a(padapter, HW_VAR_BEACON_INTERVAL, (u8 *)(&bcn_interval)); UpdateBrateTbl23a(padapter, pnetwork->SupportedRates); - rtw_hal_set_hwreg23a(padapter, HW_VAR_BASIC_RATE, pnetwork->SupportedRates); + HalSetBrateCfg23a(padapter, pnetwork->SupportedRates); if (!pmlmepriv->cur_network.join_res) { /* setting only at first time */ diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index d91e88e0f955..36b8a732824a 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -8724,7 +8724,7 @@ void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, int join_re /* update IOT-releated issue */ update_IOT_info23a(padapter); - rtw_hal_set_hwreg23a(padapter, HW_VAR_BASIC_RATE, cur_network->SupportedRates); + HalSetBrateCfg23a(padapter, cur_network->SupportedRates); /* BCN interval */ rtw_hal_set_hwreg23a(padapter, HW_VAR_BEACON_INTERVAL, (u8 *)(&pmlmeinfo->bcn_interval)); diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 0114c46c36a1..8f1bd0708a13 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -1452,7 +1452,7 @@ void update_tx_basic_rate23a(struct rtw_adapter *padapter, u8 wirelessmode) else update_mgnt_tx_rate23a(padapter, IEEE80211_OFDM_RATE_6MB); - rtw_hal_set_hwreg23a(padapter, HW_VAR_BASIC_RATE, supported_rates); + HalSetBrateCfg23a(padapter, supported_rates); } unsigned char check_assoc_AP23a(u8 *pframe, uint len) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index 9d738d79de4b..e4496c840b4d 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -4677,7 +4677,7 @@ bthci_StateConnected(struct rtw_adapter *padapter, if (padapter->HalFunc.UpdateRAMaskHandler) padapter->HalFunc.UpdateRAMaskHandler(padapter, MAX_FW_SUPPORT_MACID_NUM-1-EntryNum, 0); - rtw_hal_set_hwreg23a(padapter, HW_VAR_BASIC_RATE, padapter->mlmepriv.cur_network.network.SupportedRates); + HalSetBrateCfg23a(padapter, padapter->mlmepriv.cur_network.network.SupportedRates); BTDM_SetFwChnlInfo(padapter, RT_MEDIA_CONNECT); break; default: diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index eebd01cea138..b66ab21d0073 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3143,10 +3143,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) hw_var_set_bssid(padapter, val); break; - case HW_VAR_BASIC_RATE: - HalSetBrateCfg23a(padapter, val); - break; - case HW_VAR_TXPAUSE: rtl8723a_set_tx_pause(padapter, *val); break; @@ -3285,10 +3281,6 @@ void GetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); switch (variable) { - case HW_VAR_BASIC_RATE: - *((u16 *) val) = pHalData->BasicRateSet; - break; - case HW_VAR_TXPAUSE: *val = rtw_read8(padapter, REG_TXPAUSE); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index ee3315ec7d77..7e6cb41a8355 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -39,7 +39,6 @@ enum HW_VARIABLES { HW_VAR_MAC_ADDR, HW_VAR_BSSID, HW_VAR_INIT_RTS_RATE, - HW_VAR_BASIC_RATE, HW_VAR_TXPAUSE, HW_VAR_BCN_FUNC, HW_VAR_CHECK_BSSID, -- cgit v1.2.3 From 3c5660e7573eecc6423322a27e851185a4f8e58c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:19 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_MAC_ADDR usage .... and rip out a couple of unnecessary layers of function calls Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_com.c | 6 ------ drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 6 +----- drivers/staging/rtl8723au/hal/usb_halinit.c | 2 +- drivers/staging/rtl8723au/include/hal_com.h | 2 -- drivers/staging/rtl8723au/include/hal_intf.h | 2 +- 5 files changed, 3 insertions(+), 15 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index 5f20117e4e4f..29f42068d3b9 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -344,12 +344,6 @@ bool Hal_MappingOutPipe23a(struct rtw_adapter *pAdapter, u8 NumOutPipe) return result; } -void hal_init_macaddr23a(struct rtw_adapter *adapter) -{ - rtw_hal_set_hwreg23a(adapter, HW_VAR_MAC_ADDR, - adapter->eeprompriv.mac_addr); -} - /* * C2H event format: * Field TRIGGER CONTENT CMD_SEQ CMD_LEN CMD_ID diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index b66ab21d0073..0eccf5304c67 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -2996,7 +2996,7 @@ void hw_var_set_opmode(struct rtw_adapter *padapter, u8 mode) rtw_write8(padapter, MSR, val8); } -static void hw_var_set_macaddr(struct rtw_adapter *padapter, u8 *val) +void hw_var_set_macaddr(struct rtw_adapter *padapter, u8 *val) { u8 idx = 0; u32 reg_macid; @@ -3135,10 +3135,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) u32 *val32 = (u32 *)val; switch (variable) { - case HW_VAR_MAC_ADDR: - hw_var_set_macaddr(padapter, val); - break; - case HW_VAR_BSSID: hw_var_set_bssid(padapter, val); break; diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index e206829d50fa..eae95ec38516 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -779,7 +779,7 @@ static u32 rtl8723au_hal_init(struct rtw_adapter *Adapter) _InitDriverInfoSize(Adapter, DRVINFO_SZ); _InitInterrupt(Adapter); - hal_init_macaddr23a(Adapter);/* set mac_address */ + hw_var_set_macaddr(Adapter, Adapter->eeprompriv.mac_addr); _InitNetworkType(Adapter);/* set msr */ _InitWMACSetting(Adapter); _InitAdaptiveCtrl(Adapter); diff --git a/drivers/staging/rtl8723au/include/hal_com.h b/drivers/staging/rtl8723au/include/hal_com.h index 8e94d2e3ecef..b62ca2d4b5b4 100644 --- a/drivers/staging/rtl8723au/include/hal_com.h +++ b/drivers/staging/rtl8723au/include/hal_com.h @@ -165,8 +165,6 @@ void HalSetBrateCfg23a(struct rtw_adapter *padapter, u8 *mBratesOS); bool Hal_MappingOutPipe23a(struct rtw_adapter *pAdapter, u8 NumOutPipe); -void hal_init_macaddr23a(struct rtw_adapter *adapter); - void c2h_evt_clear23a(struct rtw_adapter *adapter); s32 c2h_evt_read23a(struct rtw_adapter *adapter, u8 *buf); diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 7e6cb41a8355..8334ab084047 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -36,7 +36,6 @@ enum _CHIP_TYPE { }; enum HW_VARIABLES { - HW_VAR_MAC_ADDR, HW_VAR_BSSID, HW_VAR_INIT_RTS_RATE, HW_VAR_TXPAUSE, @@ -380,5 +379,6 @@ c2h_id_filter rtw_hal_c2h_id_filter_ccx23a(struct rtw_adapter *adapter); void hw_var_set_correct_tsf(struct rtw_adapter *padapter); void hw_var_set_mlme_disconnect(struct rtw_adapter *padapter); void hw_var_set_opmode(struct rtw_adapter *padapter, u8 mode); +void hw_var_set_macaddr(struct rtw_adapter *padapter, u8 *val); #endif /* __HAL_INTF_H__ */ -- cgit v1.2.3 From 38dd10b59b726e05cce1abc797cd7f2ead1bc681 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:20 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_BSSID usage Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 2 +- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 11 +++++------ drivers/staging/rtl8723au/core/rtw_sreset.c | 2 +- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 6 +----- drivers/staging/rtl8723au/include/hal_intf.h | 2 +- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 95311bd8fe76..5b89c206928e 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -695,7 +695,7 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) Set_MSR23a(padapter, _HW_STATE_AP_); /* Set BSSID REG */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_BSSID, pnetwork->MacAddress); + hw_var_set_bssid(padapter, pnetwork->MacAddress); /* Set EDCA param reg */ acparm = 0x002F3217; /* VO */ diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 36b8a732824a..87e4df63b283 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -8008,7 +8008,7 @@ void start_create_ibss23a(struct rtw_adapter* padapter) } else { - rtw_hal_set_hwreg23a(padapter, HW_VAR_BSSID, padapter->registrypriv.dev_network.MacAddress); + hw_var_set_bssid(padapter, padapter->registrypriv.dev_network.MacAddress); join_type = 0; rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); @@ -8698,7 +8698,7 @@ void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, int join_re { join_type = 1; rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); - rtw_hal_set_hwreg23a(padapter, HW_VAR_BSSID, null_addr); + hw_var_set_bssid(padapter, null_addr); /* restore to initial setting. */ update_tx_basic_rate23a(padapter, padapter->registrypriv.wireless_mode); @@ -8833,7 +8833,7 @@ void mlmeext_sta_del_event_callback23a(struct rtw_adapter *padapter) /* set_opmode_cmd(padapter, infra_client_with_mlme); */ hw_var_set_mlme_disconnect(padapter); - rtw_hal_set_hwreg23a(padapter, HW_VAR_BSSID, null_addr); + hw_var_set_bssid(padapter, null_addr); /* restore to initial setting. */ update_tx_basic_rate23a(padapter, padapter->registrypriv.wireless_mode); @@ -9386,8 +9386,7 @@ u8 join_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) /* rtw_hal_set_hwreg23a(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_BSSID, - pmlmeinfo->network.MacAddress); + hw_var_set_bssid(padapter, pmlmeinfo->network.MacAddress); join_type = 0; rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); @@ -9417,7 +9416,7 @@ u8 disconnect_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf) /* pmlmeinfo->state = WIFI_FW_NULL_STATE; */ hw_var_set_mlme_disconnect(padapter); - rtw_hal_set_hwreg23a(padapter, HW_VAR_BSSID, null_addr); + hw_var_set_bssid(padapter, null_addr); /* restore to initial setting. */ update_tx_basic_rate23a(padapter, padapter->registrypriv.wireless_mode); diff --git a/drivers/staging/rtl8723au/core/rtw_sreset.c b/drivers/staging/rtl8723au/core/rtw_sreset.c index 4f7459203390..625760d2a67b 100644 --- a/drivers/staging/rtl8723au/core/rtw_sreset.c +++ b/drivers/staging/rtl8723au/core/rtw_sreset.c @@ -142,7 +142,7 @@ static void sreset_restore_network_station(struct rtw_adapter *padapter) /* disable dynamic functions, such as high power, DIG */ /* Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DISABLE, false); */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_BSSID, pmlmeinfo->network.MacAddress); + hw_var_set_bssid(padapter, pmlmeinfo->network.MacAddress); { u8 join_type = 0; diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 0eccf5304c67..0c1eaed9d44a 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3007,7 +3007,7 @@ void hw_var_set_macaddr(struct rtw_adapter *padapter, u8 *val) rtw_write8(padapter, (reg_macid + idx), val[idx]); } -static void hw_var_set_bssid(struct rtw_adapter *padapter, u8 *val) +void hw_var_set_bssid(struct rtw_adapter *padapter, u8 *val) { u8 idx = 0; u32 reg_bssid; @@ -3135,10 +3135,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) u32 *val32 = (u32 *)val; switch (variable) { - case HW_VAR_BSSID: - hw_var_set_bssid(padapter, val); - break; - case HW_VAR_TXPAUSE: rtl8723a_set_tx_pause(padapter, *val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 8334ab084047..eb011360cc0e 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -36,7 +36,6 @@ enum _CHIP_TYPE { }; enum HW_VARIABLES { - HW_VAR_BSSID, HW_VAR_INIT_RTS_RATE, HW_VAR_TXPAUSE, HW_VAR_BCN_FUNC, @@ -380,5 +379,6 @@ void hw_var_set_correct_tsf(struct rtw_adapter *padapter); void hw_var_set_mlme_disconnect(struct rtw_adapter *padapter); void hw_var_set_opmode(struct rtw_adapter *padapter, u8 mode); void hw_var_set_macaddr(struct rtw_adapter *padapter, u8 *val); +void hw_var_set_bssid(struct rtw_adapter *padapter, u8 *val); #endif /* __HAL_INTF_H__ */ -- cgit v1.2.3 From a086023ac5bbc14019c2c17e07b98e2e6ee95208 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:21 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_MLME_SITESURVEY usage Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 10 +++------ drivers/staging/rtl8723au/core/rtw_p2p.c | 27 +++++++++-------------- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 4 ---- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 4 files changed, 14 insertions(+), 28 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 87e4df63b283..ef0a829e365a 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -7615,7 +7615,7 @@ bool IsLegal5GChannel(struct rtw_adapter *Adapter, u8 channel) void site_survey23a(struct rtw_adapter *padapter) { - unsigned char survey_channel = 0, val8; + unsigned char survey_channel = 0; enum rt_scan_type ScanType = SCAN_PASSIVE; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -7761,8 +7761,7 @@ void site_survey23a(struct rtw_adapter *padapter) } - val8 = 0; /* survey done */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); + rtl8723a_mlme_sitesurvey(padapter, 0); report_surveydone_event23a(padapter); @@ -9518,7 +9517,6 @@ u8 sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct sitesurvey_parm *pparm = (struct sitesurvey_parm *)pbuf; u8 bdelayscan = false; - u8 val8; u32 initialgain; u32 i; @@ -9589,9 +9587,7 @@ u8 sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) /* set MSR to no link state */ Set_MSR23a(padapter, _HW_STATE_NOLINK_); - val8 = 1; /* under site survey */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_SITESURVEY, - (u8 *)(&val8)); + rtl8723a_mlme_sitesurvey(padapter, 1); pmlmeext->sitesurvey_res.state = SCAN_PROCESS; } diff --git a/drivers/staging/rtl8723au/core/rtw_p2p.c b/drivers/staging/rtl8723au/core/rtw_p2p.c index 27a6cc76973d..67d17a17a6b1 100644 --- a/drivers/staging/rtl8723au/core/rtw_p2p.c +++ b/drivers/staging/rtl8723au/core/rtw_p2p.c @@ -3120,45 +3120,40 @@ static void restore_p2p_state_handler(struct rtw_adapter *padapter) static void pre_tx_invitereq_handler(struct rtw_adapter *padapter) { struct wifidirect_info *pwdinfo = &padapter->wdinfo; - u8 val8 = 1; set_channel_bwmode23a(padapter, pwdinfo->invitereq_info.peer_ch, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); - padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); + rtl8723a_mlme_sitesurvey(padapter, 1); issue23a_probereq_p2p(padapter, NULL); mod_timer(&pwdinfo->pre_tx_scan_timer, jiffies + msecs_to_jiffies(P2P_TX_PRESCAN_TIMEOUT)); - - } static void pre_tx_provdisc_handler(struct rtw_adapter *padapter) { struct wifidirect_info *pwdinfo = &padapter->wdinfo; - u8 val8 = 1; - - set_channel_bwmode23a(padapter, pwdinfo->tx_prov_disc_info.peer_channel_num[0], HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); - rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); + set_channel_bwmode23a(padapter, + pwdinfo->tx_prov_disc_info.peer_channel_num[0], + HAL_PRIME_CHNL_OFFSET_DONT_CARE, + HT_CHANNEL_WIDTH_20); + rtl8723a_mlme_sitesurvey(padapter, 1); issue23a_probereq_p2p(padapter, NULL); mod_timer(&pwdinfo->pre_tx_scan_timer, jiffies + msecs_to_jiffies(P2P_TX_PRESCAN_TIMEOUT)); - - } static void pre_tx_negoreq_handler(struct rtw_adapter *padapter) { struct wifidirect_info *pwdinfo = &padapter->wdinfo; - u8 val8 = 1; - - set_channel_bwmode23a(padapter, pwdinfo->nego_req_info.peer_channel_num[0], HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); - rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); + set_channel_bwmode23a(padapter, + pwdinfo->nego_req_info.peer_channel_num[0], + HAL_PRIME_CHNL_OFFSET_DONT_CARE, + HT_CHANNEL_WIDTH_20); + rtl8723a_mlme_sitesurvey(padapter, 1); issue23a_probereq_p2p(padapter, NULL); mod_timer(&pwdinfo->pre_tx_scan_timer, jiffies + msecs_to_jiffies(P2P_TX_PRESCAN_TIMEOUT)); - - } static void ro_ch_handler(struct rtw_adapter *padapter) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 0c1eaed9d44a..bcf400dcb823 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3147,10 +3147,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_check_bssid(padapter, *val); break; - case HW_VAR_MLME_SITESURVEY: - rtl8723a_mlme_sitesurvey(padapter, *val); - break; - case HW_VAR_MLME_JOIN: hw_var_set_mlme_join(padapter, *val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index eb011360cc0e..163743190625 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -40,7 +40,6 @@ enum HW_VARIABLES { HW_VAR_TXPAUSE, HW_VAR_BCN_FUNC, HW_VAR_CHECK_BSSID, - HW_VAR_MLME_SITESURVEY, HW_VAR_MLME_JOIN, HW_VAR_BEACON_INTERVAL, HW_VAR_SLOT_TIME, -- cgit v1.2.3 From ea0cd73023ec317ea92ea69e0193746f44c236d4 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:22 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_CHECK_BSSID and HW_VAR_MLME_JOIN Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 28 +++++++--------------- drivers/staging/rtl8723au/core/rtw_sreset.c | 6 +---- .../staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 6 ++--- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 10 +------- drivers/staging/rtl8723au/include/hal_intf.h | 3 +-- 5 files changed, 14 insertions(+), 39 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index ef0a829e365a..bed8829b00bd 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -7969,7 +7969,6 @@ void start_create_ibss23a(struct rtw_adapter* padapter) { unsigned short caps; u8 val8; - u8 join_type; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; @@ -8008,8 +8007,7 @@ void start_create_ibss23a(struct rtw_adapter* padapter) else { hw_var_set_bssid(padapter, padapter->registrypriv.dev_network.MacAddress); - join_type = 0; - rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); + hw_var_set_mlme_join(padapter, 0); report_join_res23a(padapter, 1); pmlmeinfo->state |= WIFI_FW_ASSOC_SUCCESS; @@ -8690,17 +8688,15 @@ void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, int join_re struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; struct sta_priv *pstapriv = &padapter->stapriv; - u8 join_type; u16 media_status; - if (join_res < 0) - { - join_type = 1; - rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); + if (join_res < 0) { + hw_var_set_mlme_join(padapter, 1); hw_var_set_bssid(padapter, null_addr); /* restore to initial setting. */ - update_tx_basic_rate23a(padapter, padapter->registrypriv.wireless_mode); + update_tx_basic_rate23a(padapter, + padapter->registrypriv.wireless_mode); goto exit_mlmeext_joinbss_event_callback23a; } @@ -8756,11 +8752,9 @@ void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, int join_re rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status); } - join_type = 2; - rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); + hw_var_set_mlme_join(padapter, 2); - if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) - { + if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) { /* correcting TSF */ correct_TSF23a(padapter, pmlmeext); @@ -8777,7 +8771,6 @@ void mlmeext_sta_add_event_callback23a(struct rtw_adapter *padapter, struct sta_ { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - u8 join_type; DBG_8723A("%s\n", __func__); @@ -8809,8 +8802,7 @@ void mlmeext_sta_add_event_callback23a(struct rtw_adapter *padapter, struct sta_ } - join_type = 2; - rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); + hw_var_set_mlme_join(padapter, 2); } pmlmeinfo->FW_sta_info[psta->mac_id].psta = psta; @@ -9266,7 +9258,6 @@ u8 createbss_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) u8 join_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) { - u8 join_type; struct ndis_802_11_var_ies * pIE; struct registry_priv *pregpriv = &padapter->registrypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -9386,8 +9377,7 @@ u8 join_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) (u8 *)(&initialgain)); */ hw_var_set_bssid(padapter, pmlmeinfo->network.MacAddress); - join_type = 0; - rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); + hw_var_set_mlme_join(padapter, 0); /* cancel link timer */ del_timer_sync(&pmlmeext->link_timer); diff --git a/drivers/staging/rtl8723au/core/rtw_sreset.c b/drivers/staging/rtl8723au/core/rtw_sreset.c index 625760d2a67b..e3c189556794 100644 --- a/drivers/staging/rtl8723au/core/rtw_sreset.c +++ b/drivers/staging/rtl8723au/core/rtw_sreset.c @@ -143,11 +143,7 @@ static void sreset_restore_network_station(struct rtw_adapter *padapter) /* Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DISABLE, false); */ hw_var_set_bssid(padapter, pmlmeinfo->network.MacAddress); - - { - u8 join_type = 0; - rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); - } + hw_var_set_mlme_join(padapter, 0); Set_MSR23a(padapter, (pmlmeinfo->state & 0x3)); diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index e4496c840b4d..5ff540e8241c 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -3944,7 +3944,6 @@ bthci_CmdAMPTestEnd(struct rtw_adapter *padapter, enum hci_status status = HCI_STATUS_SUCCESS; struct bt_30info *pBTInfo = GET_BT_INFO(padapter); struct bt_hci_info *pBtHciInfo = &pBTInfo->BtHciInfo; - u8 bFilterOutNonAssociatedBSSID = true; if (!pBtHciInfo->bInTestMode) { RTPRINT(FIOCTL, (IOCTL_BT_EVENT|IOCTL_BT_LOGO), ("Not in Test mode, return status = HCI_STATUS_CMD_DISALLOW\n")); @@ -3956,7 +3955,7 @@ bthci_CmdAMPTestEnd(struct rtw_adapter *padapter, del_timer_sync(&pBTInfo->BTTestSendPacketTimer); - rtw_hal_set_hwreg23a(padapter, HW_VAR_CHECK_BSSID, (u8 *)(&bFilterOutNonAssociatedBSSID)); + rtl8723a_check_bssid(padapter, true); /* send command complete event here when all data are received. */ { @@ -4057,8 +4056,7 @@ bthci_CmdAMPTestCommand(struct rtw_adapter *padapter, jiffies + msecs_to_jiffies(50)); RTPRINT(FIOCTL, (IOCTL_BT_EVENT|IOCTL_BT_LOGO), ("TX Single Test \n")); } else if (pBtHciInfo->TestScenario == 0x02) { - u8 bFilterOutNonAssociatedBSSID = false; - rtw_hal_set_hwreg23a(padapter, HW_VAR_CHECK_BSSID, (u8 *)(&bFilterOutNonAssociatedBSSID)); + rtl8723a_check_bssid(padapter, false); RTPRINT(FIOCTL, (IOCTL_BT_EVENT|IOCTL_BT_LOGO), ("Receive Frame Test \n")); } diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index bcf400dcb823..ac64815861aa 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3067,7 +3067,7 @@ void hw_var_set_mlme_disconnect(struct rtw_adapter *padapter) SetBcnCtrlReg23a(padapter, DIS_TSF_UDT, 0); } -static void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type) +void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type) { u8 RetryLimit = 0x30; @@ -3143,14 +3143,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_set_bcn_func(padapter, *val); break; - case HW_VAR_CHECK_BSSID: - rtl8723a_check_bssid(padapter, *val); - break; - - case HW_VAR_MLME_JOIN: - hw_var_set_mlme_join(padapter, *val); - break; - case HW_VAR_BEACON_INTERVAL: rtl8723a_set_beacon_interval(padapter, *((u16 *) val)); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 163743190625..2ca5713b0232 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -39,8 +39,6 @@ enum HW_VARIABLES { HW_VAR_INIT_RTS_RATE, HW_VAR_TXPAUSE, HW_VAR_BCN_FUNC, - HW_VAR_CHECK_BSSID, - HW_VAR_MLME_JOIN, HW_VAR_BEACON_INTERVAL, HW_VAR_SLOT_TIME, HW_VAR_RESP_SIFS, @@ -379,5 +377,6 @@ void hw_var_set_mlme_disconnect(struct rtw_adapter *padapter); void hw_var_set_opmode(struct rtw_adapter *padapter, u8 mode); void hw_var_set_macaddr(struct rtw_adapter *padapter, u8 *val); void hw_var_set_bssid(struct rtw_adapter *padapter, u8 *val); +void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type); #endif /* __HAL_INTF_H__ */ -- cgit v1.2.3 From 477f008d55654bc30ef8adca4286925c2da969e1 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:23 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_BEACON_INTERVAL Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 2 +- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 4 ---- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 4 files changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 5b89c206928e..888901aa9b13 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -712,7 +712,7 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) rtw_hal_set_hwreg23a(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); /* Beacon Control related register */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_BEACON_INTERVAL, (u8 *)(&bcn_interval)); + rtl8723a_set_beacon_interval(padapter, bcn_interval); UpdateBrateTbl23a(padapter, pnetwork->SupportedRates); HalSetBrateCfg23a(padapter, pnetwork->SupportedRates); diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index bed8829b00bd..90efa4738d96 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -8722,7 +8722,7 @@ void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, int join_re HalSetBrateCfg23a(padapter, cur_network->SupportedRates); /* BCN interval */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_BEACON_INTERVAL, (u8 *)(&pmlmeinfo->bcn_interval)); + rtl8723a_set_beacon_interval(padapter, pmlmeinfo->bcn_interval); /* udpate capability */ update_capinfo23a(padapter, pmlmeinfo->capability); diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index ac64815861aa..8931626a6946 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3143,10 +3143,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_set_bcn_func(padapter, *val); break; - case HW_VAR_BEACON_INTERVAL: - rtl8723a_set_beacon_interval(padapter, *((u16 *) val)); - break; - case HW_VAR_SLOT_TIME: rtl8723a_set_slot_time(padapter, *val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 2ca5713b0232..395660193c81 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -39,7 +39,6 @@ enum HW_VARIABLES { HW_VAR_INIT_RTS_RATE, HW_VAR_TXPAUSE, HW_VAR_BCN_FUNC, - HW_VAR_BEACON_INTERVAL, HW_VAR_SLOT_TIME, HW_VAR_RESP_SIFS, HW_VAR_ACK_PREAMBLE, -- cgit v1.2.3 From 04c3842773aff89c3c0bce54d982c07513b4a24d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:24 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_SLOT_TIME Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 2 +- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 4 ---- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 8f1bd0708a13..183b2665abdd 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -1600,7 +1600,7 @@ void update_capinfo23a(struct rtw_adapter *Adapter, u16 updateCap) pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME; } } - rtw_hal_set_hwreg23a(Adapter, HW_VAR_SLOT_TIME, &pmlmeinfo->slotTime); + rtl8723a_set_slot_time(Adapter, pmlmeinfo->slotTime); } void update_wireless_mode23a(struct rtw_adapter *padapter) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 8931626a6946..9c5d8310376d 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3143,10 +3143,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_set_bcn_func(padapter, *val); break; - case HW_VAR_SLOT_TIME: - rtl8723a_set_slot_time(padapter, *val); - break; - case HW_VAR_RESP_SIFS: rtl8723a_set_resp_sifs(padapter, val[0], val[1], val[2], val[3]); diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 395660193c81..edf54b77172d 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -39,7 +39,6 @@ enum HW_VARIABLES { HW_VAR_INIT_RTS_RATE, HW_VAR_TXPAUSE, HW_VAR_BCN_FUNC, - HW_VAR_SLOT_TIME, HW_VAR_RESP_SIFS, HW_VAR_ACK_PREAMBLE, HW_VAR_SEC_CFG, -- cgit v1.2.3 From 7b7aefaab13773c3f54ddc492df04872f8d60d36 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:25 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_RESP_SIFS Yet another case of an endian bug from treating a 32 bit integer as an array of 8 bit numbers... Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 8 +++----- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 5 ----- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 183b2665abdd..ab9d98d5fc7e 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -1606,7 +1606,6 @@ void update_capinfo23a(struct rtw_adapter *Adapter, u16 updateCap) void update_wireless_mode23a(struct rtw_adapter *padapter) { int ratelen, network_type = 0; - u32 SIFS_Timer; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; @@ -1635,10 +1634,9 @@ void update_wireless_mode23a(struct rtw_adapter *padapter) pmlmeext->cur_wireless_mode = network_type & padapter->registrypriv.wireless_mode; - SIFS_Timer = 0x0a0a0808; /* 0x0808 -> for CCK, 0x0a0a -> for OFDM */ - /* change this value if having IOT issues. */ - - padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_RESP_SIFS, (u8 *)&SIFS_Timer); + /* 0x0808 -> for CCK, 0x0a0a -> for OFDM */ + /* change this value if having IOT issues. */ + rtl8723a_set_resp_sifs(padapter, 0x08, 0x08, 0x0a, 0x0a); if (pmlmeext->cur_wireless_mode & WIRELESS_11B) update_mgnt_tx_rate23a(padapter, IEEE80211_CCK_RATE_1MB); diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 9c5d8310376d..27752fd30c7e 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3143,11 +3143,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_set_bcn_func(padapter, *val); break; - case HW_VAR_RESP_SIFS: - rtl8723a_set_resp_sifs(padapter, val[0], val[1], - val[2], val[3]); - break; - case HW_VAR_ACK_PREAMBLE: rtl8723a_ack_preamble(padapter, *val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index edf54b77172d..81ebefea0157 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -39,7 +39,6 @@ enum HW_VARIABLES { HW_VAR_INIT_RTS_RATE, HW_VAR_TXPAUSE, HW_VAR_BCN_FUNC, - HW_VAR_RESP_SIFS, HW_VAR_ACK_PREAMBLE, HW_VAR_SEC_CFG, HW_VAR_RF_TYPE, -- cgit v1.2.3 From 093dd41e03d89e13e56a821feda3eefbc1ecbf5a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:26 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_ACK_PREAMBLE Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 7 ++----- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 4 ---- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index ab9d98d5fc7e..d675891ad23e 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -1562,22 +1562,19 @@ void update_capinfo23a(struct rtw_adapter *Adapter, u16 updateCap) { struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - bool ShortPreamble; if (updateCap & cShortPreamble) { /* Short Preamble */ if (pmlmeinfo->preamble_mode != PREAMBLE_SHORT) { /* PREAMBLE_LONG or PREAMBLE_AUTO */ - ShortPreamble = true; pmlmeinfo->preamble_mode = PREAMBLE_SHORT; - rtw_hal_set_hwreg23a(Adapter, HW_VAR_ACK_PREAMBLE, (u8 *)&ShortPreamble); + rtl8723a_ack_preamble(Adapter, true); } } else { /* Long Preamble */ if (pmlmeinfo->preamble_mode != PREAMBLE_LONG) { /* PREAMBLE_SHORT or PREAMBLE_AUTO */ - ShortPreamble = false; pmlmeinfo->preamble_mode = PREAMBLE_LONG; - rtw_hal_set_hwreg23a(Adapter, HW_VAR_ACK_PREAMBLE, (u8 *)&ShortPreamble); + rtl8723a_ack_preamble(Adapter, false); } } if (updateCap & cIBSS) { diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 27752fd30c7e..fba69da87dd4 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3143,10 +3143,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_set_bcn_func(padapter, *val); break; - case HW_VAR_ACK_PREAMBLE: - rtl8723a_ack_preamble(padapter, *val); - break; - case HW_VAR_SEC_CFG: rtl8723a_set_sec_cfg(padapter, *val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 81ebefea0157..b63643641e62 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -39,7 +39,6 @@ enum HW_VARIABLES { HW_VAR_INIT_RTS_RATE, HW_VAR_TXPAUSE, HW_VAR_BCN_FUNC, - HW_VAR_ACK_PREAMBLE, HW_VAR_SEC_CFG, HW_VAR_RF_TYPE, HW_VAR_DM_FLAG, -- cgit v1.2.3 From b8e99163b3181142bb781c3113facb194eae8e49 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:27 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_SEC_CFG usage Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 5 +++-- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 18 +++++++----------- drivers/staging/rtl8723au/core/rtw_sreset.c | 3 ++- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 4 ---- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 5 files changed, 12 insertions(+), 19 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 888901aa9b13..18ade6036b23 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -708,8 +708,9 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) rtw_hal_set_hwreg23a(padapter, HW_VAR_AC_PARAM_BK, (u8 *)(&acparm)); /* Set Security */ - val8 = (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X)? 0xcc: 0xcf; - rtw_hal_set_hwreg23a(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); + val8 = (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) ? + 0xcc: 0xcf; + rtl8723a_set_sec_cfg(padapter, val8); /* Beacon Control related register */ rtl8723a_set_beacon_interval(padapter, bcn_interval); diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 90efa4738d96..068203e62688 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -7968,7 +7968,6 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, struct recv_frame *precv_fr void start_create_ibss23a(struct rtw_adapter* padapter) { unsigned short caps; - u8 val8; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; @@ -7981,10 +7980,8 @@ void start_create_ibss23a(struct rtw_adapter* padapter) /* udpate capability */ caps = rtw_get_capability23a(pnetwork); update_capinfo23a(padapter, caps); - if (caps&cap_IBSS)/* adhoc master */ - { - val8 = 0xcf; - rtw_hal_set_hwreg23a(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); + if (caps&cap_IBSS) { /* adhoc master */ + rtl8723a_set_sec_cfg(padapter, 0xcf); /* switch channel */ /* SelectChannel23a(padapter, pmlmeext->cur_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE); */ @@ -8044,9 +8041,10 @@ void start_clnt_join23a(struct rtw_adapter* padapter) Set_MSR23a(padapter, WIFI_FW_STATION_STATE); - val8 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_8021X)? 0xcc: 0xcf; + val8 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_8021X) ? + 0xcc: 0xcf; - rtw_hal_set_hwreg23a(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); + rtl8723a_set_sec_cfg(padapter, val8); /* switch channel */ /* set_channel_bwmode23a(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); */ @@ -8059,12 +8057,10 @@ void start_clnt_join23a(struct rtw_adapter* padapter) msecs_to_jiffies((REAUTH_TO * REAUTH_LIMIT) + (REASSOC_TO*REASSOC_LIMIT) + beacon_timeout)); pmlmeinfo->state = WIFI_FW_AUTH_NULL | WIFI_FW_STATION_STATE; } - else if (caps&cap_IBSS) /* adhoc client */ - { + else if (caps&cap_IBSS) { /* adhoc client */ Set_MSR23a(padapter, WIFI_FW_ADHOC_STATE); - val8 = 0xcf; - rtw_hal_set_hwreg23a(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); + rtl8723a_set_sec_cfg(padapter, 0xcf); /* switch channel */ set_channel_bwmode23a(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); diff --git a/drivers/staging/rtl8723au/core/rtw_sreset.c b/drivers/staging/rtl8723au/core/rtw_sreset.c index e3c189556794..e243a3afcdcd 100644 --- a/drivers/staging/rtl8723au/core/rtw_sreset.c +++ b/drivers/staging/rtl8723au/core/rtw_sreset.c @@ -99,7 +99,8 @@ static void sreset_restore_security_station(struct rtw_adapter *padapter) val8 = 0xcc; else val8 = 0xcf; - rtw_hal_set_hwreg23a(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); + + rtl8723a_set_sec_cfg(padapter, val8); if ((padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_) || (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_)) { diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index fba69da87dd4..6d574cd96129 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3143,10 +3143,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_set_bcn_func(padapter, *val); break; - case HW_VAR_SEC_CFG: - rtl8723a_set_sec_cfg(padapter, *val); - break; - case HW_VAR_DM_FLAG: rtl8723a_odm_support_ability_write(padapter, *val32); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index b63643641e62..8e3dd1264380 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -39,7 +39,6 @@ enum HW_VARIABLES { HW_VAR_INIT_RTS_RATE, HW_VAR_TXPAUSE, HW_VAR_BCN_FUNC, - HW_VAR_SEC_CFG, HW_VAR_RF_TYPE, HW_VAR_DM_FLAG, HW_VAR_DM_FUNC_OP, -- cgit v1.2.3 From a15a46a7b96f7a5bd780ba6689cb4d23322473b3 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:28 +0200 Subject: staging: rtl8723au: Kill off HW_VAR_CAM_EMPTY_ENTRY and some function layers wrapping it Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 5 ----- drivers/staging/rtl8723au/hal/hal_com.c | 6 ++++-- drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 6 ++++-- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 4 ---- drivers/staging/rtl8723au/include/hal_intf.h | 1 - drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 1 - 6 files changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index d675891ad23e..1e538854dbb4 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -478,11 +478,6 @@ unsigned int decide_wait_for_beacon_timeout23a(unsigned int bcn_interval) return bcn_interval << 2; } -void CAM_empty_entry23a(struct rtw_adapter *Adapter, u8 ucIndex) -{ - rtw_hal_set_hwreg23a(Adapter, HW_VAR_CAM_EMPTY_ENTRY, (u8 *)(&ucIndex)); -} - void invalidate_cam_all23a(struct rtw_adapter *padapter) { rtl8723a_cam_invalid_all(padapter); diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index 29f42068d3b9..06ea165ceddd 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -670,11 +670,13 @@ void rtl8723a_cam_empty_entry(struct rtw_adapter *padapter, u8 ucIndex) /* delay_ms(40); */ rtw_write32(padapter, WCAMI, ulContent); /* RT_TRACE(COMP_SEC, DBG_LOUD, - ("CAM_empty_entry23a(): WRITE A4: %lx \n", ulContent));*/ + ("rtl8723a_cam_empty_entry(): WRITE A4: %lx \n", + ulContent));*/ /* delay_ms(40); */ rtw_write32(padapter, RWCAM, ulCommand); /* RT_TRACE(COMP_SEC, DBG_LOUD, - ("CAM_empty_entry23a(): WRITE A0: %lx \n", ulCommand));*/ + ("rtl8723a_cam_empty_entry(): WRITE A0: %lx \n", + ulCommand));*/ } } diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index 5ff540e8241c..3de077b3ed5b 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -11232,8 +11232,10 @@ void HALBT_RemoveKey(struct rtw_adapter *padapter, u8 EntryNum) if (pBTinfo->BtAsocEntry[EntryNum].HwCAMIndex != 0) { /* ToDo : add New HALBT_RemoveKey function !! */ - if (pBtAssocEntry->HwCAMIndex >= BT_HWCAM_STAR && pBtAssocEntry->HwCAMIndex < HALF_CAM_ENTRY) - CAM_empty_entry23a(padapter, pBtAssocEntry->HwCAMIndex); + if (pBtAssocEntry->HwCAMIndex >= BT_HWCAM_STAR && + pBtAssocEntry->HwCAMIndex < HALF_CAM_ENTRY) + rtl8723a_cam_empty_entry(padapter, + pBtAssocEntry->HwCAMIndex); pBTinfo->BtAsocEntry[EntryNum].HwCAMIndex = 0; } } diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 6d574cd96129..cfc9eb1276ea 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3157,10 +3157,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_odm_support_ability_clr(padapter, *val32); break; - case HW_VAR_CAM_EMPTY_ENTRY: - rtl8723a_cam_empty_entry(padapter, *val); - break; - case HW_VAR_CAM_WRITE: rtl8723a_cam_write(padapter, val32[0], val32[1]); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 8e3dd1264380..72da07444212 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -44,7 +44,6 @@ enum HW_VARIABLES { HW_VAR_DM_FUNC_OP, HW_VAR_DM_FUNC_SET, HW_VAR_DM_FUNC_CLR, - HW_VAR_CAM_EMPTY_ENTRY, HW_VAR_CAM_WRITE, HW_VAR_CAM_READ, HW_VAR_AC_PARAM_VO, diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 0aaf0d5d8aea..060de9f3de83 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -500,7 +500,6 @@ void write_cam23a(struct rtw_adapter *padapter, u8 entry, u16 ctrl, void clear_cam_entry23a(struct rtw_adapter *padapter, u8 entry); void invalidate_cam_all23a(struct rtw_adapter *padapter); -void CAM_empty_entry23a(struct rtw_adapter *Adapter, u8 ucIndex); int allocate_fw_sta_entry23a(struct rtw_adapter *padapter); void flush_all_cam_entry23a(struct rtw_adapter *padapter); -- cgit v1.2.3 From dc0d16a1079320282c272de69c14e08802b46ea8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:29 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_CAM_WRITE and clean up all the wrapping around it Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 7 ++-- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 39 +--------------------- drivers/staging/rtl8723au/hal/hal_com.c | 31 ++++++++++++++--- .../staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 4 ++- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 4 --- drivers/staging/rtl8723au/include/hal_com.h | 3 +- drivers/staging/rtl8723au/include/hal_intf.h | 1 - drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 2 -- 8 files changed, 37 insertions(+), 54 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 068203e62688..a40bb035187f 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -9614,7 +9614,7 @@ u8 setkey_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) DBG_8723A_LEVEL(_drv_always_, "set group key to hw: alg:%d(WEP40-1 WEP104-5 TKIP-2 AES-4) " "keyid:%d\n", pparm->algorithm, pparm->keyid); - write_cam23a(padapter, pparm->keyid, ctrl, null_sta, pparm->key); + rtl8723a_cam_write(padapter, pparm->keyid, ctrl, null_sta, pparm->key); /* allow multicast packets to driver */ rtl8723a_on_rcr_am(padapter); @@ -9678,7 +9678,8 @@ u8 set_stakey_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) pparm->addr[1], pparm->addr[2], pparm->addr[3], pparm->addr[4], pparm->addr[5], cam_id); - write_cam23a(padapter, cam_id, ctrl, pparm->addr, pparm->key); + rtl8723a_cam_write(padapter, cam_id, ctrl, + pparm->addr, pparm->key); return H2C_SUCCESS_RSP; @@ -9701,7 +9702,7 @@ u8 set_stakey_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) ctrl = BIT(15) | ((pparm->algorithm) << 2); - write_cam23a(padapter, cam_id, ctrl, pparm->addr, pparm->key); + rtl8723a_cam_write(padapter, cam_id, ctrl, pparm->addr, pparm->key); pmlmeinfo->enc_algo = pparm->algorithm; diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 1e538854dbb4..221184457b71 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -483,50 +483,13 @@ void invalidate_cam_all23a(struct rtw_adapter *padapter) rtl8723a_cam_invalid_all(padapter); } -void write_cam23a(struct rtw_adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key) -{ - unsigned int i, val, addr; - int j; - u32 cam_val[2]; - - addr = entry << 3; - - for (j = 5; j >= 0; j--) { - switch (j) { - case 0: - val = (ctrl | (mac[0] << 16) | (mac[1] << 24)); - break; - case 1: - val = (mac[2] | (mac[3] << 8) | (mac[4] << 16) | (mac[5] << 24)); - break; - default: - i = (j - 2) << 2; - val = (key[i] | (key[i+1] << 8) | (key[i+2] << 16) | (key[i+3] << 24)); - break; - } - - cam_val[0] = val; - cam_val[1] = addr + (unsigned int)j; - - rtw_hal_set_hwreg23a(padapter, HW_VAR_CAM_WRITE, (u8 *)cam_val); - - /* rtw_write32(padapter, WCAMI, val); */ - - /* cmd = CAM_POLLINIG | CAM_WRITE | (addr + j); */ - /* rtw_write32(padapter, RWCAM, cmd); */ - - /* DBG_8723A("%s => cam write: %x, %x\n", __func__, cmd, val); */ - - } -} - void clear_cam_entry23a(struct rtw_adapter *padapter, u8 entry) { unsigned char null_sta[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; unsigned char null_key[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - write_cam23a(padapter, entry, 0, null_sta, null_key); + rtl8723a_cam_write(padapter, entry, 0, null_sta, null_key); } int allocate_fw_sta_entry23a(struct rtw_adapter *padapter) diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index 06ea165ceddd..5d4e51c493e6 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -685,14 +685,37 @@ void rtl8723a_cam_invalid_all(struct rtw_adapter *padapter) rtw_write32(padapter, RWCAM, BIT(31) | BIT(30)); } -void rtl8723a_cam_write(struct rtw_adapter *padapter, u32 val1, u32 val2) +void rtl8723a_cam_write(struct rtw_adapter *padapter, + u8 entry, u16 ctrl, u8 *mac, u8 *key) { u32 cmd; + unsigned int i, val, addr; + int j; - rtw_write32(padapter, WCAMI, val1); + addr = entry << 3; - cmd = CAM_POLLINIG | CAM_WRITE | val2; - rtw_write32(padapter, RWCAM, cmd); + for (j = 5; j >= 0; j--) { + switch (j) { + case 0: + val = ctrl | (mac[0] << 16) | (mac[1] << 24); + break; + case 1: + val = mac[2] | (mac[3] << 8) | + (mac[4] << 16) | (mac[5] << 24); + break; + default: + i = (j - 2) << 2; + val = key[i] | (key[i+1] << 8) | + (key[i+2] << 16) | (key[i+3] << 24); + break; + } + + rtw_write32(padapter, WCAMI, val); + cmd = CAM_POLLINIG | CAM_WRITE | (addr + j); + rtw_write32(padapter, RWCAM, cmd); + + /* DBG_8723A("%s => cam write: %x, %x\n", __func__, cmd, val);*/ + } } void rtl8723a_fifo_cleanup(struct rtw_adapter *padapter) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index 3de077b3ed5b..69041efe5c36 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -11219,7 +11219,9 @@ void HALBT_SetKey(struct rtw_adapter *padapter, u8 EntryNum) pBtAssocEntry->HwCAMIndex = BT_HWCAM_STAR + EntryNum; usConfig = CAM_VALID | (CAM_AES << 2); - write_cam23a(padapter, pBtAssocEntry->HwCAMIndex, usConfig, pBtAssocEntry->BTRemoteMACAddr, pBtAssocEntry->PTK + TKIP_ENC_KEY_POS); + rtl8723a_cam_write(padapter, pBtAssocEntry->HwCAMIndex, usConfig, + pBtAssocEntry->BTRemoteMACAddr, + pBtAssocEntry->PTK + TKIP_ENC_KEY_POS); } void HALBT_RemoveKey(struct rtw_adapter *padapter, u8 EntryNum) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index cfc9eb1276ea..ba58bab2a3f6 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3157,10 +3157,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_odm_support_ability_clr(padapter, *val32); break; - case HW_VAR_CAM_WRITE: - rtl8723a_cam_write(padapter, val32[0], val32[1]); - break; - case HW_VAR_AC_PARAM_VO: rtl8723a_set_ac_param_vo(padapter, *val32); break; diff --git a/drivers/staging/rtl8723au/include/hal_com.h b/drivers/staging/rtl8723au/include/hal_com.h index b62ca2d4b5b4..9d036132ac4f 100644 --- a/drivers/staging/rtl8723au/include/hal_com.h +++ b/drivers/staging/rtl8723au/include/hal_com.h @@ -183,7 +183,8 @@ void rtl8723a_ack_preamble(struct rtw_adapter *padapter, u8 bShortPreamble); void rtl8723a_set_sec_cfg(struct rtw_adapter *padapter, u8 sec); void rtl8723a_cam_empty_entry(struct rtw_adapter *padapter, u8 ucIndex); void rtl8723a_cam_invalid_all(struct rtw_adapter *padapter); -void rtl8723a_cam_write(struct rtw_adapter *padapter, u32 val1, u32 val2); +void rtl8723a_cam_write(struct rtw_adapter *padapter, + u8 entry, u16 ctrl, u8 *mac, u8 *key); void rtl8723a_fifo_cleanup(struct rtw_adapter *padapter); void rtl8723a_set_apfm_on_mac(struct rtw_adapter *padapter, u8 val); void rtl8723a_bcn_valid(struct rtw_adapter *padapter); diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 72da07444212..64fed853c2fa 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -44,7 +44,6 @@ enum HW_VARIABLES { HW_VAR_DM_FUNC_OP, HW_VAR_DM_FUNC_SET, HW_VAR_DM_FUNC_CLR, - HW_VAR_CAM_WRITE, HW_VAR_CAM_READ, HW_VAR_AC_PARAM_VO, HW_VAR_AC_PARAM_VI, diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 060de9f3de83..b61fc95b1037 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -495,8 +495,6 @@ void SetBWMode23a(struct rtw_adapter *padapter, unsigned short bwmode, unsigned int decide_wait_for_beacon_timeout23a(unsigned int bcn_interval); -void write_cam23a(struct rtw_adapter *padapter, u8 entry, u16 ctrl, - u8 *mac, u8 *key); void clear_cam_entry23a(struct rtw_adapter *padapter, u8 entry); void invalidate_cam_all23a(struct rtw_adapter *padapter); -- cgit v1.2.3 From 2487205e0e7fbe997981b78f758b46cd86e320ef Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:30 +0200 Subject: staging: rtl8723au: Eiminate the use of HW_VAR_AC_PARAM_{VO,VI,BE,BK} Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 8 ++++---- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 8 ++++---- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 16 ---------------- drivers/staging/rtl8723au/include/hal_intf.h | 4 ---- 4 files changed, 8 insertions(+), 28 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 18ade6036b23..59e161c16678 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -699,13 +699,13 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) /* Set EDCA param reg */ acparm = 0x002F3217; /* VO */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_AC_PARAM_VO, (u8 *)(&acparm)); + rtl8723a_set_ac_param_vo(padapter, acparm); acparm = 0x005E4317; /* VI */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_AC_PARAM_VI, (u8 *)(&acparm)); + rtl8723a_set_ac_param_vi(padapter, acparm); acparm = 0x005ea42b; - rtw_hal_set_hwreg23a(padapter, HW_VAR_AC_PARAM_BE, (u8 *)(&acparm)); + rtl8723a_set_ac_param_be(padapter, acparm); acparm = 0x0000A444; /* BK */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_AC_PARAM_BK, (u8 *)(&acparm)); + rtl8723a_set_ac_param_bk(padapter, acparm); /* Set Security */ val8 = (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) ? diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 221184457b71..8ede5d08f289 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -602,22 +602,22 @@ void WMMOnAssocRsp23a(struct rtw_adapter *padapter) switch (ACI) { case 0x0: - rtw_hal_set_hwreg23a(padapter, HW_VAR_AC_PARAM_BE, (u8 *)(&acParm)); + rtl8723a_set_ac_param_be(padapter, acParm); acm_mask |= (ACM? BIT(1):0); edca[XMIT_BE_QUEUE] = acParm; break; case 0x1: - rtw_hal_set_hwreg23a(padapter, HW_VAR_AC_PARAM_BK, (u8 *)(&acParm)); + rtl8723a_set_ac_param_bk(padapter, acParm); /* acm_mask |= (ACM? BIT(0):0); */ edca[XMIT_BK_QUEUE] = acParm; break; case 0x2: - rtw_hal_set_hwreg23a(padapter, HW_VAR_AC_PARAM_VI, (u8 *)(&acParm)); + rtl8723a_set_ac_param_vi(padapter, acParm); acm_mask |= (ACM? BIT(2):0); edca[XMIT_VI_QUEUE] = acParm; break; case 0x3: - rtw_hal_set_hwreg23a(padapter, HW_VAR_AC_PARAM_VO, (u8 *)(&acParm)); + rtl8723a_set_ac_param_vo(padapter, acParm); acm_mask |= (ACM? BIT(3):0); edca[XMIT_VO_QUEUE] = acParm; break; diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index ba58bab2a3f6..0e2c4031c14d 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3157,22 +3157,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_odm_support_ability_clr(padapter, *val32); break; - case HW_VAR_AC_PARAM_VO: - rtl8723a_set_ac_param_vo(padapter, *val32); - break; - - case HW_VAR_AC_PARAM_VI: - rtl8723a_set_ac_param_vi(padapter, *val32); - break; - - case HW_VAR_AC_PARAM_BE: - rtl8723a_set_ac_param_be(padapter, *val32); - break; - - case HW_VAR_AC_PARAM_BK: - rtl8723a_set_ac_param_bk(padapter, *val32); - break; - case HW_VAR_ACM_CTRL: rtl8723a_set_acm_ctrl(padapter, *val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 64fed853c2fa..a768957b8f8b 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -45,10 +45,6 @@ enum HW_VARIABLES { HW_VAR_DM_FUNC_SET, HW_VAR_DM_FUNC_CLR, HW_VAR_CAM_READ, - HW_VAR_AC_PARAM_VO, - HW_VAR_AC_PARAM_VI, - HW_VAR_AC_PARAM_BE, - HW_VAR_AC_PARAM_BK, HW_VAR_ACM_CTRL, HW_VAR_AMPDU_MIN_SPACE, HW_VAR_AMPDU_FACTOR, -- cgit v1.2.3 From d5cdb9e1daecdc72a9b2f5facee3d6481fe61673 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:31 +0200 Subject: staging: rtl8723au: Kill off HW_VAR_ACM_CTRL Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 2 +- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 4 ---- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 8ede5d08f289..2d0cc6b3c52d 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -627,7 +627,7 @@ void WMMOnAssocRsp23a(struct rtw_adapter *padapter) } if (padapter->registrypriv.acm_method == 1) - rtw_hal_set_hwreg23a(padapter, HW_VAR_ACM_CTRL, (u8 *)(&acm_mask)); + rtl8723a_set_acm_ctrl(padapter, acm_mask); else padapter->mlmepriv.acm_mask = acm_mask; diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 0e2c4031c14d..8c8e98b55255 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3157,10 +3157,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_odm_support_ability_clr(padapter, *val32); break; - case HW_VAR_ACM_CTRL: - rtl8723a_set_acm_ctrl(padapter, *val); - break; - case HW_VAR_AMPDU_MIN_SPACE: rtl8723a_set_ampdu_min_space(padapter, *val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index a768957b8f8b..30398d3028d2 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -45,7 +45,6 @@ enum HW_VARIABLES { HW_VAR_DM_FUNC_SET, HW_VAR_DM_FUNC_CLR, HW_VAR_CAM_READ, - HW_VAR_ACM_CTRL, HW_VAR_AMPDU_MIN_SPACE, HW_VAR_AMPDU_FACTOR, HW_VAR_RXDMA_AGG_PG_TH, -- cgit v1.2.3 From dce610a77fdb33ccb13d93dd54342e2fab9310e6 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:32 +0200 Subject: staging: rtl8723au: Make direct calls for HW_VAR_AMPDU_{MIN_SPACE,FACTOR} Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 5 ++--- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 5 ++--- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 8 -------- drivers/staging/rtl8723au/include/hal_intf.h | 2 -- 4 files changed, 4 insertions(+), 16 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 59e161c16678..f55e86d8be65 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -632,9 +632,8 @@ static void update_hw_ht_param(struct rtw_adapter *padapter) min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) >> 2; - rtw_hal_set_hwreg23a(padapter, HW_VAR_AMPDU_MIN_SPACE, (u8 *)(&min_MPDU_spacing)); - - rtw_hal_set_hwreg23a(padapter, HW_VAR_AMPDU_FACTOR, (u8 *)(&max_AMPDU_len)); + rtl8723a_set_ampdu_min_space(padapter, min_MPDU_spacing); + rtl8723a_set_ampdu_factor(padapter, max_AMPDU_len); /* Config SM Power Save setting */ pmlmeinfo->SM_PS = (pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info & 0x0C) >> 2; diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 2d0cc6b3c52d..91bb7a451fba 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -849,9 +849,8 @@ void HTOnAssocRsp23a(struct rtw_adapter *padapter) min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) >> 2; - rtw_hal_set_hwreg23a(padapter, HW_VAR_AMPDU_MIN_SPACE, (u8 *)(&min_MPDU_spacing)); - - rtw_hal_set_hwreg23a(padapter, HW_VAR_AMPDU_FACTOR, (u8 *)(&max_AMPDU_len)); + rtl8723a_set_ampdu_min_space(padapter, min_MPDU_spacing); + rtl8723a_set_ampdu_factor(padapter, max_AMPDU_len); } void ERP_IE_handler23a(struct rtw_adapter *padapter, struct ndis_802_11_var_ies * pIE) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 8c8e98b55255..56c6654d61e0 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3157,14 +3157,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_odm_support_ability_clr(padapter, *val32); break; - case HW_VAR_AMPDU_MIN_SPACE: - rtl8723a_set_ampdu_min_space(padapter, *val); - break; - - case HW_VAR_AMPDU_FACTOR: - rtl8723a_set_ampdu_factor(padapter, *val); - break; - case HW_VAR_RXDMA_AGG_PG_TH: rtl8723a_set_rxdma_agg_pg_th(padapter, *val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 30398d3028d2..01aec72ab77c 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -45,8 +45,6 @@ enum HW_VARIABLES { HW_VAR_DM_FUNC_SET, HW_VAR_DM_FUNC_CLR, HW_VAR_CAM_READ, - HW_VAR_AMPDU_MIN_SPACE, - HW_VAR_AMPDU_FACTOR, HW_VAR_RXDMA_AGG_PG_TH, HW_VAR_SET_RPWM, HW_VAR_H2C_FW_PWRMODE, -- cgit v1.2.3 From 7c82a2b91d8c57d78ae2059664fd23ad3b542e97 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:33 +0200 Subject: staging: rtl8723au: Kill off HW_VAR_INITIAL_GAIN Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 26 ++++++----------------- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 3 --- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index a40bb035187f..8757a13086ce 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -7619,7 +7619,6 @@ void site_survey23a(struct rtw_adapter *padapter) enum rt_scan_type ScanType = SCAN_PASSIVE; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - u32 initialgain = 0; #ifdef CONFIG_8723AU_P2P struct wifidirect_info *pwdinfo = &padapter->wdinfo; @@ -7719,8 +7718,8 @@ void site_survey23a(struct rtw_adapter *padapter) rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_LISTEN); pmlmeext->sitesurvey_res.state = SCAN_DISABLE; - initialgain = 0xff; /* restore RX GAIN */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); + /* restore RX GAIN */ + rtl8723a_set_initial_gain(padapter, 0xff); /* turn on dynamic functions */ Restore_DM_Func_Flag23a(padapter); /* Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DIG|DYNAMIC_FUNC_HP|DYNAMIC_FUNC_SS, true); */ @@ -7749,8 +7748,8 @@ void site_survey23a(struct rtw_adapter *padapter) /* config MSR */ Set_MSR23a(padapter, (pmlmeinfo->state & 0x3)); - initialgain = 0xff; /* restore RX GAIN */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); + /* restore RX GAIN */ + rtl8723a_set_initial_gain(padapter, 0xff); /* turn on dynamic functions */ Restore_DM_Func_Flag23a(padapter); /* Switch_DM_Func23a(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); */ @@ -9231,10 +9230,6 @@ u8 createbss_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) Save_DM_Func_Flag23a(padapter); Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DISABLE, false); - /* config the initial gain under linking, need to write the BB registers */ - /* initialgain = 0x1E; */ - /* rtw_hal_set_hwreg23a(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); */ - /* cancel link timer */ del_timer_sync(&pmlmeext->link_timer); @@ -9366,12 +9361,6 @@ u8 join_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) /* disable dynamic functions, such as high power, DIG */ /* Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DISABLE, false); */ - /* config the initial gain under linking, need to write the BB - registers */ - /* initialgain = 0x1E; */ - /* rtw_hal_set_hwreg23a(padapter, HW_VAR_INITIAL_GAIN, - (u8 *)(&initialgain)); */ - hw_var_set_bssid(padapter, pmlmeinfo->network.MacAddress); hw_var_set_mlme_join(padapter, 0); @@ -9562,13 +9551,12 @@ u8 sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) /* config the initial gain under scaning, need to write the BB registers */ - if ((wdev_to_priv(padapter->rtw_wdev))->p2p_enabled == true) { + if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled == true) initialgain = 0x30; - } else + else initialgain = 0x1E; - rtw_hal_set_hwreg23a(padapter, HW_VAR_INITIAL_GAIN, - (u8 *)(&initialgain)); + rtl8723a_set_initial_gain(padapter, initialgain); /* set MSR to no link state */ Set_MSR23a(padapter, _HW_STATE_NOLINK_); diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 56c6654d61e0..330289b88895 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3175,9 +3175,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) break; #endif /* CONFIG_8723AU_P2P */ - case HW_VAR_INITIAL_GAIN: - rtl8723a_set_initial_gain(padapter, *val32); - break; case HW_VAR_EFUSE_BYTES: pHalData->EfuseUsedBytes = *((u16 *) val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 01aec72ab77c..45d6cfbe8797 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -55,7 +55,6 @@ enum HW_VARIABLES { HW_VAR_TDLS_INIT_CH_SEN, HW_VAR_TDLS_RS_RCR, HW_VAR_TDLS_DONE_CH_SEN, - HW_VAR_INITIAL_GAIN, HW_VAR_TRIGGER_GPIO_0, HW_VAR_BT_SET_COEXIST, HW_VAR_BT_ISSUE_DELBA, -- cgit v1.2.3 From dc451608f3456f94b55d73cf513b32984b3d73c5 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:34 +0200 Subject: staging: rtl8723au: Nuke HW_VAR_BCN_FUNC Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 10 +++------- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 4 ---- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 8757a13086ce..96d744152903 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -9378,7 +9378,6 @@ u8 disconnect_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; - u8 val8; if (is_client_associated_to_ap23a(padapter)) { @@ -9395,12 +9394,9 @@ u8 disconnect_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf) /* restore to initial setting. */ update_tx_basic_rate23a(padapter, padapter->registrypriv.wireless_mode); - if (((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) - { - /* Stop BCN */ - val8 = 0; - rtw_hal_set_hwreg23a(padapter, HW_VAR_BCN_FUNC, (u8 *)(&val8)); - } + if (((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) || + ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)) + rtl8723a_set_bcn_func(padapter, 0); /* Stop BCN */ /* set MSR to no link state -> infra. mode */ Set_MSR23a(padapter, _HW_STATE_STATION_); diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 330289b88895..d496330a23c6 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3139,10 +3139,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_set_tx_pause(padapter, *val); break; - case HW_VAR_BCN_FUNC: - rtl8723a_set_bcn_func(padapter, *val); - break; - case HW_VAR_DM_FLAG: rtl8723a_odm_support_ability_write(padapter, *val32); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 45d6cfbe8797..75e751cedcd7 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -38,7 +38,6 @@ enum _CHIP_TYPE { enum HW_VARIABLES { HW_VAR_INIT_RTS_RATE, HW_VAR_TXPAUSE, - HW_VAR_BCN_FUNC, HW_VAR_RF_TYPE, HW_VAR_DM_FLAG, HW_VAR_DM_FUNC_OP, -- cgit v1.2.3 From 6952905d216474fb494995e41a61f9ebdcfa8090 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:35 +0200 Subject: staging: rtl8723au: Nuke HW_VAR_CHECK_TXBUF, which was also a no-op Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 3 --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 2 -- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 3 files changed, 6 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 96d744152903..ab42739366ea 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -9492,9 +9492,6 @@ u8 sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) u32 i; if (pmlmeext->sitesurvey_res.state == SCAN_DISABLE) { - /* for first time sitesurvey_cmd */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_CHECK_TXBUF, NULL); - pmlmeext->sitesurvey_res.state = SCAN_START; pmlmeext->sitesurvey_res.bss_cnt = 0; pmlmeext->sitesurvey_res.channel_idx = 0; diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index d496330a23c6..e6e501217e6d 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3177,8 +3177,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) case HW_VAR_EFUSE_BT_BYTES: pHalData->BTEfuseUsedBytes = *((u16 *) val); break; - case HW_VAR_CHECK_TXBUF: - break; case HW_VAR_APFM_ON_MAC: rtl8723a_set_apfm_on_mac(padapter, *val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 75e751cedcd7..fcb441154b31 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -63,7 +63,6 @@ enum HW_VARIABLES { HW_VAR_SWITCH_EPHY_WoWLAN, HW_VAR_EFUSE_BYTES, HW_VAR_EFUSE_BT_BYTES, - HW_VAR_CHECK_TXBUF, HW_VAR_APFM_ON_MAC, /* Auto FSM to Turn On, include clock, isolation, power control for MAC only */ /* The valid upper nav range for the HW updating, if the true value is larger than the upper range, the HW won't update it. */ /* Unit in microsecond. 0 means disable this function. */ -- cgit v1.2.3 From 1e7b6ebe193a23faf3f559c9611dc1b5ca87c287 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:36 +0200 Subject: staging: rtl8723au: Make direct calls for HW_VAR_TXDMA_AGG_PG_TH This was in fact turned into a no-op for the RTL8723AU, but it looks like a bug, so this reenables it. Keep an eye out for side-effects here and revert this, if it causes issues. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 9 +++------ drivers/staging/rtl8723au/core/rtw_sreset.c | 10 +++++----- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 4 ---- drivers/staging/rtl8723au/hal/usb_halinit.c | 2 -- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 5 files changed, 8 insertions(+), 18 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 6cee78785bdc..9cf26ea0088b 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -2193,13 +2193,10 @@ void rtw_joinbss_reset23a(struct rtw_adapter *padapter) threshold = 1; else threshold = 0; - rtw_hal_set_hwreg23a(padapter, HW_VAR_RXDMA_AGG_PG_TH, - (u8 *)(&threshold)); - } else { + } else threshold = 1; - rtw_hal_set_hwreg23a(padapter, HW_VAR_RXDMA_AGG_PG_TH, - (u8 *)(&threshold)); - } + + rtl8723a_set_rxdma_agg_pg_th(padapter, threshold); } /* the fucntion is >= passive_level */ diff --git a/drivers/staging/rtl8723au/core/rtw_sreset.c b/drivers/staging/rtl8723au/core/rtw_sreset.c index e243a3afcdcd..dd2a6f18f7d7 100644 --- a/drivers/staging/rtl8723au/core/rtw_sreset.c +++ b/drivers/staging/rtl8723au/core/rtw_sreset.c @@ -132,13 +132,13 @@ static void sreset_restore_network_station(struct rtw_adapter *padapter) threshold = 1; else threshold = 0; - rtw_hal_set_hwreg23a(padapter, HW_VAR_RXDMA_AGG_PG_TH, (u8 *)(&threshold)); - } else { + } else threshold = 1; - rtw_hal_set_hwreg23a(padapter, HW_VAR_RXDMA_AGG_PG_TH, (u8 *)(&threshold)); - } - set_channel_bwmode23a(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); + rtl8723a_set_rxdma_agg_pg_th(padapter, threshold); + + set_channel_bwmode23a(padapter, pmlmeext->cur_channel, + pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); /* disable dynamic functions, such as high power, DIG */ /* Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DISABLE, false); */ diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index e6e501217e6d..fee79d1a190a 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3153,10 +3153,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_odm_support_ability_clr(padapter, *val32); break; - case HW_VAR_RXDMA_AGG_PG_TH: - rtl8723a_set_rxdma_agg_pg_th(padapter, *val); - break; - case HW_VAR_H2C_FW_PWRMODE: rtl8723a_set_FwPwrMode_cmd(padapter, *val); break; diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index eae95ec38516..2b44b17acc70 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1519,8 +1519,6 @@ static void rtl8723au_trigger_gpio_0(struct rtw_adapter *padapter) static void SetHwReg8723AU(struct rtw_adapter *Adapter, u8 variable, u8 *val) { switch (variable) { - case HW_VAR_RXDMA_AGG_PG_TH: - break; case HW_VAR_SET_RPWM: rtl8723a_set_rpwm(Adapter, *val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index fcb441154b31..e2b9fdcb2192 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -44,7 +44,6 @@ enum HW_VARIABLES { HW_VAR_DM_FUNC_SET, HW_VAR_DM_FUNC_CLR, HW_VAR_CAM_READ, - HW_VAR_RXDMA_AGG_PG_TH, HW_VAR_SET_RPWM, HW_VAR_H2C_FW_PWRMODE, HW_VAR_H2C_FW_JOINBSSRPT, -- cgit v1.2.3 From 327c70c04b2d045b9eea15d1ac30e4254ac4f687 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:37 +0200 Subject: staging: rtl8723au: Make direct calls for HW_VAR_H2C_FW_{PWRMODE,JOINBSSRPT} Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 6 ++---- drivers/staging/rtl8723au/core/rtw_p2p.c | 17 +++++++---------- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 13 ++++--------- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 8 -------- drivers/staging/rtl8723au/include/hal_intf.h | 2 -- 5 files changed, 13 insertions(+), 33 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 5e3088a01800..0b25cd2f6584 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -1269,8 +1269,7 @@ void lps_ctrl_wk_hdl(struct rtw_adapter *padapter, u8 lps_ctrl_type) mstatus = 1;/* connect */ /* Reset LPS Setting */ padapter->pwrctrlpriv.LpsIdleCount = 0; - rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_JOINBSSRPT, - (u8 *)&mstatus); + rtl8723a_set_FwJoinBssReport_cmd(padapter, 1); #ifdef CONFIG_8723AU_BT_COEXIST BT_WifiMediaStatusNotify(padapter, mstatus); #endif @@ -1284,8 +1283,7 @@ void lps_ctrl_wk_hdl(struct rtw_adapter *padapter, u8 lps_ctrl_type) { LPS_Leave23a(padapter); } - rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_JOINBSSRPT, - (u8 *)&mstatus); + rtl8723a_set_FwJoinBssReport_cmd(padapter, 0); break; case LPS_CTRL_SPECIAL_PACKET: pwrpriv->DelayLPSLastTimeStamp = jiffies; diff --git a/drivers/staging/rtl8723au/core/rtw_p2p.c b/drivers/staging/rtl8723au/core/rtw_p2p.c index 67d17a17a6b1..81eebe5b74d9 100644 --- a/drivers/staging/rtl8723au/core/rtw_p2p.c +++ b/drivers/staging/rtl8723au/core/rtw_p2p.c @@ -16,6 +16,7 @@ #include #include +#include #include #ifdef CONFIG_8723AU_P2P @@ -3573,12 +3574,10 @@ void p2p_ps_wk_hdl23a(struct rtw_adapter *padapter, u8 p2p_ps_state) pwdinfo->opp_ps = 0; pwdinfo->noa_num = 0; pwdinfo->p2p_ps_mode = P2P_PS_NONE; - if (padapter->pwrctrlpriv.bFwCurrentInPSMode == true) - { - if (pwrpriv->smart_ps == 0) - { + if (padapter->pwrctrlpriv.bFwCurrentInPSMode == true) { + if (pwrpriv->smart_ps == 0) { pwrpriv->smart_ps = 2; - rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)&padapter->pwrctrlpriv.pwr_mode); + rtl8723a_set_FwPwrMode_cmd(padapter, padapter->pwrctrlpriv.pwr_mode); } } break; @@ -3586,13 +3585,11 @@ void p2p_ps_wk_hdl23a(struct rtw_adapter *padapter, u8 p2p_ps_state) if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) { pwdinfo->p2p_ps_state = p2p_ps_state; - if (pwdinfo->ctwindow > 0) - { - if (pwrpriv->smart_ps != 0) - { + if (pwdinfo->ctwindow > 0) { + if (pwrpriv->smart_ps != 0) { pwrpriv->smart_ps = 0; DBG_8723A("%s(): Enter CTW, change SmartPS\n", __func__); - rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)&padapter->pwrctrlpriv.pwr_mode); + rtl8723a_set_FwPwrMode_cmd(padapter, padapter->pwrctrlpriv.pwr_mode); } } rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_P2P_PS_OFFLOAD, (u8 *)(&p2p_ps_state)); diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index 8ddd67f194ba..c2e86529047b 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -341,25 +341,22 @@ void rtw_set_ps_mode23a(struct rtw_adapter *padapter, u8 ps_mode, u8 smart_ps, u pwrpriv->pwr_mode = ps_mode; rtw_set_rpwm23a(padapter, PS_STATE_S4); - rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&ps_mode)); + rtl8723a_set_FwPwrMode_cmd(padapter, ps_mode); pwrpriv->bFwCurrentInPSMode = false; } - } - else - { + } else { if (PS_RDY_CHECK(padapter) #ifdef CONFIG_8723AU_BT_COEXIST || (BT_1Ant(padapter) == true) #endif - ) - { + ) { DBG_8723A("%s: Enter 802.11 power save\n", __func__); pwrpriv->bFwCurrentInPSMode = true; pwrpriv->pwr_mode = ps_mode; pwrpriv->smart_ps = smart_ps; pwrpriv->bcn_ant_mode = bcn_ant_mode; - rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&ps_mode)); + rtl8723a_set_FwPwrMode_cmd(padapter, ps_mode); #ifdef CONFIG_8723AU_P2P /* Set CTWindow after LPS */ @@ -370,8 +367,6 @@ void rtw_set_ps_mode23a(struct rtw_adapter *padapter, u8 ps_mode, u8 smart_ps, u rtw_set_rpwm23a(padapter, PS_STATE_S2); } } - - } /* diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index fee79d1a190a..2e0350952d0a 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3153,14 +3153,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_odm_support_ability_clr(padapter, *val32); break; - case HW_VAR_H2C_FW_PWRMODE: - rtl8723a_set_FwPwrMode_cmd(padapter, *val); - break; - - case HW_VAR_H2C_FW_JOINBSSRPT: - rtl8723a_set_FwJoinBssReport_cmd(padapter, *val); - break; - #ifdef CONFIG_8723AU_P2P case HW_VAR_H2C_FW_P2P_PS_OFFLOAD: rtl8723a_set_p2p_ps_offload_cmd(padapter, *val); diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index e2b9fdcb2192..27b0eb8bb866 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -45,8 +45,6 @@ enum HW_VARIABLES { HW_VAR_DM_FUNC_CLR, HW_VAR_CAM_READ, HW_VAR_SET_RPWM, - HW_VAR_H2C_FW_PWRMODE, - HW_VAR_H2C_FW_JOINBSSRPT, HW_VAR_FWLPS_RF_ON, HW_VAR_H2C_FW_P2P_PS_OFFLOAD, HW_VAR_TDLS_WRCR, -- cgit v1.2.3 From c6d921c5808c78a3b89a4dfdba2c8c979fec5581 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:38 +0200 Subject: staging: rtl8723au: Make direct calls for HW_VAR_H2C_P2P_PS_OFFLOAD Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_p2p.c | 8 +++++--- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 6 ------ drivers/staging/rtl8723au/include/hal_intf.h | 1 - 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_p2p.c b/drivers/staging/rtl8723au/core/rtw_p2p.c index 81eebe5b74d9..e5d9991040bb 100644 --- a/drivers/staging/rtl8723au/core/rtw_p2p.c +++ b/drivers/staging/rtl8723au/core/rtw_p2p.c @@ -3567,7 +3567,7 @@ void p2p_ps_wk_hdl23a(struct rtw_adapter *padapter, u8 p2p_ps_state) case P2P_PS_DISABLE: pwdinfo->p2p_ps_state = p2p_ps_state; - rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_P2P_PS_OFFLOAD, (u8 *)(&p2p_ps_state)); + rtl8723a_set_p2p_ps_offload_cmd(padapter, p2p_ps_state); pwdinfo->noa_index = 0; pwdinfo->ctwindow = 0; @@ -3592,7 +3592,8 @@ void p2p_ps_wk_hdl23a(struct rtw_adapter *padapter, u8 p2p_ps_state) rtl8723a_set_FwPwrMode_cmd(padapter, padapter->pwrctrlpriv.pwr_mode); } } - rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_P2P_PS_OFFLOAD, (u8 *)(&p2p_ps_state)); + rtl8723a_set_p2p_ps_offload_cmd(padapter, + p2p_ps_state); } break; case P2P_PS_SCAN: @@ -3600,7 +3601,8 @@ void p2p_ps_wk_hdl23a(struct rtw_adapter *padapter, u8 p2p_ps_state) case P2P_PS_ALLSTASLEEP: if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) { pwdinfo->p2p_ps_state = p2p_ps_state; - rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_P2P_PS_OFFLOAD, (u8 *)(&p2p_ps_state)); + rtl8723a_set_p2p_ps_offload_cmd(padapter, + p2p_ps_state); } break; default: diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 2e0350952d0a..f8d4ef3e7b0b 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3153,12 +3153,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_odm_support_ability_clr(padapter, *val32); break; -#ifdef CONFIG_8723AU_P2P - case HW_VAR_H2C_FW_P2P_PS_OFFLOAD: - rtl8723a_set_p2p_ps_offload_cmd(padapter, *val); - break; -#endif /* CONFIG_8723AU_P2P */ - case HW_VAR_EFUSE_BYTES: pHalData->EfuseUsedBytes = *((u16 *) val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 27b0eb8bb866..f1cab544a44c 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -46,7 +46,6 @@ enum HW_VARIABLES { HW_VAR_CAM_READ, HW_VAR_SET_RPWM, HW_VAR_FWLPS_RF_ON, - HW_VAR_H2C_FW_P2P_PS_OFFLOAD, HW_VAR_TDLS_WRCR, HW_VAR_TDLS_INIT_CH_SEN, HW_VAR_TDLS_RS_RCR, -- cgit v1.2.3 From 9ff3513cb4d77d468ca0d0b5fd05d8a268d13cc9 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:39 +0200 Subject: staging: rtl8723au: Make direct calls for HW_VAR_SET_RPWM Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 2 +- drivers/staging/rtl8723au/hal/usb_halinit.c | 3 --- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index c2e86529047b..da6645e9b9fc 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -263,7 +263,7 @@ void rtw_set_rpwm23a(struct rtw_adapter *padapter, u8 pslv) pwrpriv->rpwm = pslv; - rtw_hal_set_hwreg23a(padapter, HW_VAR_SET_RPWM, (u8 *)(&rpwm)); + rtl8723a_set_rpwm(padapter, rpwm); pwrpriv->tog += 0x80; pwrpriv->cpwm = pslv; diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 2b44b17acc70..0bbc56a95481 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1519,9 +1519,6 @@ static void rtl8723au_trigger_gpio_0(struct rtw_adapter *padapter) static void SetHwReg8723AU(struct rtw_adapter *Adapter, u8 variable, u8 *val) { switch (variable) { - case HW_VAR_SET_RPWM: - rtl8723a_set_rpwm(Adapter, *val); - break; case HW_VAR_TRIGGER_GPIO_0: rtl8723au_trigger_gpio_0(Adapter); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index f1cab544a44c..2d5ace57d834 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -44,7 +44,6 @@ enum HW_VARIABLES { HW_VAR_DM_FUNC_SET, HW_VAR_DM_FUNC_CLR, HW_VAR_CAM_READ, - HW_VAR_SET_RPWM, HW_VAR_FWLPS_RF_ON, HW_VAR_TDLS_WRCR, HW_VAR_TDLS_INIT_CH_SEN, -- cgit v1.2.3 From a3252966e137fc047175cdb9f17c532972ce37c9 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:40 +0200 Subject: staging: rtl8723au: Remove commented out set_hwreg calls Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index ab42739366ea..b0c082039c1f 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -7651,9 +7651,6 @@ void site_survey23a(struct rtw_adapter *padapter) if (survey_channel != 0) { /* PAUSE 4-AC Queue when site_survey23a */ - /* rtw23a_hal_get_hwreg(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ - /* val8 |= 0x0f; */ - /* rtw_hal_set_hwreg23a(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ if (pmlmeext->sitesurvey_res.channel_idx == 0) set_channel_bwmode23a(padapter, survey_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, @@ -7743,7 +7740,6 @@ void site_survey23a(struct rtw_adapter *padapter) /* flush 4-AC Queue after site_survey23a */ /* val8 = 0; */ - /* rtw_hal_set_hwreg23a(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ /* config MSR */ Set_MSR23a(padapter, (pmlmeinfo->state & 0x3)); -- cgit v1.2.3 From 6883e7c720e90de5b0af6f0ea293a8eb090ca263 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:41 +0200 Subject: staging: rtl8723au: Make direct calls for HW_VAR_NAV_UPPER Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 3 --- drivers/staging/rtl8723au/hal/usb_halinit.c | 3 +-- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index f8d4ef3e7b0b..8d7f124df497 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3163,9 +3163,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_set_apfm_on_mac(padapter, *val); break; - case HW_VAR_NAV_UPPER: - rtl8723a_set_nav_upper(padapter, *val32); - break; default: break; } diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 0bbc56a95481..aaa81f87cc6e 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -621,7 +621,6 @@ static u32 rtl8723au_hal_init(struct rtw_adapter *Adapter) struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); struct pwrctrl_priv *pwrctrlpriv = &Adapter->pwrctrlpriv; struct registry_priv *pregistrypriv = &Adapter->registrypriv; - u32 NavUpper = WiFiNavUpperUs; unsigned long init_start_time = jiffies; @@ -888,7 +887,7 @@ static u32 rtl8723au_hal_init(struct rtw_adapter *Adapter) rtl8723a_InitHalDm(Adapter); HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MISC31); - rtw_hal_set_hwreg23a(Adapter, HW_VAR_NAV_UPPER, (u8 *)&NavUpper); + rtl8723a_set_nav_upper(Adapter, WiFiNavUpperUs); /* 2011/03/09 MH debug only, UMC-B cut pass 2500 S5 test, but we need to fin root cause. */ if (((rtw_read32(Adapter, rFPGA0_RFMOD) & 0xFF000000) != 0x83000000)) { diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 2d5ace57d834..9c94b13b3329 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -61,7 +61,6 @@ enum HW_VARIABLES { HW_VAR_APFM_ON_MAC, /* Auto FSM to Turn On, include clock, isolation, power control for MAC only */ /* The valid upper nav range for the HW updating, if the true value is larger than the upper range, the HW won't update it. */ /* Unit in microsecond. 0 means disable this function. */ - HW_VAR_NAV_UPPER, HW_VAR_RPT_TIMER_SETTING, HW_VAR_TX_RPT_MAX_MACID, HW_VAR_H2C_MEDIA_STATUS_RPT, -- cgit v1.2.3 From a945bf30129d60659d4f983db93d7b7dc08c8571 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:42 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_DM_FUNC_OP calls Demux the code and remove multiple call layers Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 9 +++++---- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 13 ------------- drivers/staging/rtl8723au/hal/hal_com.c | 16 +++++++++------- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 3 --- drivers/staging/rtl8723au/include/hal_com.h | 3 ++- drivers/staging/rtl8723au/include/hal_intf.h | 1 - drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 2 -- 7 files changed, 16 insertions(+), 31 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index b0c082039c1f..316200ea0c50 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -7718,7 +7718,7 @@ void site_survey23a(struct rtw_adapter *padapter) /* restore RX GAIN */ rtl8723a_set_initial_gain(padapter, 0xff); /* turn on dynamic functions */ - Restore_DM_Func_Flag23a(padapter); + rtl8723a_odm_support_ability_restore(padapter); /* Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DIG|DYNAMIC_FUNC_HP|DYNAMIC_FUNC_SS, true); */ mod_timer(&pwdinfo->find_phase_timer, jiffies + @@ -7747,7 +7747,7 @@ void site_survey23a(struct rtw_adapter *padapter) /* restore RX GAIN */ rtl8723a_set_initial_gain(padapter, 0xff); /* turn on dynamic functions */ - Restore_DM_Func_Flag23a(padapter); + rtl8723a_odm_support_ability_restore(padapter); /* Switch_DM_Func23a(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); */ if (is_client_associated_to_ap23a(padapter) == true) @@ -9223,7 +9223,8 @@ u8 createbss_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) pmlmeinfo->candidate_tid_bitmap = 0; /* disable dynamic functions, such as high power, DIG */ - Save_DM_Func_Flag23a(padapter); + rtl8723a_odm_support_ability_backup(padapter); + Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DISABLE, false); /* cancel link timer */ @@ -9535,7 +9536,7 @@ u8 sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) if ((pmlmeext->sitesurvey_res.state == SCAN_START) || (pmlmeext->sitesurvey_res.state == SCAN_TXNULL)) { /* disable dynamic functions, such as high power, DIG */ - Save_DM_Func_Flag23a(padapter); + rtl8723a_odm_support_ability_backup(padapter); Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DISABLE, false); /* config the initial gain under scaning, need to diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 91bb7a451fba..809d4167731f 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -283,19 +283,6 @@ void Update23aTblForSoftAP(u8 *bssrateset, u32 bssratelen) } } -void Save_DM_Func_Flag23a(struct rtw_adapter *padapter) -{ - u8 bSaveFlag = true; - - rtw_hal_set_hwreg23a(padapter, HW_VAR_DM_FUNC_OP, (u8 *)(&bSaveFlag)); -} - -void Restore_DM_Func_Flag23a(struct rtw_adapter *padapter) -{ - u8 bSaveFlag = false; - rtw_hal_set_hwreg23a(padapter, HW_VAR_DM_FUNC_OP, (u8 *)(&bSaveFlag)); -} - void Switch_DM_Func23a(struct rtw_adapter *padapter, unsigned long mode, u8 enable) { if (enable == true) diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index 5d4e51c493e6..66adec743a85 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -872,16 +872,18 @@ void rtl8723a_odm_support_ability_write(struct rtw_adapter *padapter, u32 val) pHalData->odmpriv.SupportAbility = val; } -void rtl8723a_odm_support_ability_backup(struct rtw_adapter *padapter, u8 val) +void rtl8723a_odm_support_ability_restore(struct rtw_adapter *padapter) { struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - if (val) /* save dm flag */ - pHalData->odmpriv.BK_SupportAbility = - pHalData->odmpriv.SupportAbility; - else /* restore dm flag */ - pHalData->odmpriv.SupportAbility = - pHalData->odmpriv.BK_SupportAbility; + pHalData->odmpriv.SupportAbility = pHalData->odmpriv.BK_SupportAbility; +} + +void rtl8723a_odm_support_ability_backup(struct rtw_adapter *padapter) +{ + struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); + + pHalData->odmpriv.BK_SupportAbility = pHalData->odmpriv.SupportAbility; } void rtl8723a_odm_support_ability_set(struct rtw_adapter *padapter, u32 val) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 8d7f124df497..79e63bfb0b2e 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3142,9 +3142,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) case HW_VAR_DM_FLAG: rtl8723a_odm_support_ability_write(padapter, *val32); break; - case HW_VAR_DM_FUNC_OP: - rtl8723a_odm_support_ability_backup(padapter, *val); - break; case HW_VAR_DM_FUNC_SET: rtl8723a_odm_support_ability_set(padapter, *val32); break; diff --git a/drivers/staging/rtl8723au/include/hal_com.h b/drivers/staging/rtl8723au/include/hal_com.h index 9d036132ac4f..e8774fc602c0 100644 --- a/drivers/staging/rtl8723au/include/hal_com.h +++ b/drivers/staging/rtl8723au/include/hal_com.h @@ -202,7 +202,8 @@ void rtl8723a_set_nav_upper(struct rtw_adapter *padapter, u32 usNavUpper); void rtl8723a_set_initial_gain(struct rtw_adapter *padapter, u32 rx_gain); void rtl8723a_odm_support_ability_write(struct rtw_adapter *padapter, u32 val); -void rtl8723a_odm_support_ability_backup(struct rtw_adapter *padapter, u8 val); +void rtl8723a_odm_support_ability_backup(struct rtw_adapter *padapter); +void rtl8723a_odm_support_ability_restore(struct rtw_adapter *padapter); void rtl8723a_odm_support_ability_set(struct rtw_adapter *padapter, u32 val); void rtl8723a_odm_support_ability_clr(struct rtw_adapter *padapter, u32 val); diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 9c94b13b3329..2218032ef617 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -40,7 +40,6 @@ enum HW_VARIABLES { HW_VAR_TXPAUSE, HW_VAR_RF_TYPE, HW_VAR_DM_FLAG, - HW_VAR_DM_FUNC_OP, HW_VAR_DM_FUNC_SET, HW_VAR_DM_FUNC_CLR, HW_VAR_CAM_READ, diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index b61fc95b1037..53b2d0a34734 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -474,8 +474,6 @@ void get_rate_set23a(struct rtw_adapter *padapter, unsigned char *pbssrate, void UpdateBrateTbl23a(struct rtw_adapter *padapter,u8 *mBratesOS); void Update23aTblForSoftAP(u8 *bssrateset, u32 bssratelen); -void Save_DM_Func_Flag23a(struct rtw_adapter *padapter); -void Restore_DM_Func_Flag23a(struct rtw_adapter *padapter); void Switch_DM_Func23a(struct rtw_adapter *padapter, unsigned long mode, u8 enable); void Set_MSR23a(struct rtw_adapter *padapter, u8 type); -- cgit v1.2.3 From 585eefb45398abdc9d330785e2ef7e084655f1ff Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:43 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_DM_FUNC_{SET,CLR} Unroll two layers of mux/demux in the call chain for each. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 3 ++- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 12 +++++------- drivers/staging/rtl8723au/core/rtw_sreset.c | 3 --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 16 ++++------------ drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 7 ------- drivers/staging/rtl8723au/include/hal_intf.h | 2 -- drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 2 -- 7 files changed, 11 insertions(+), 34 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index f55e86d8be65..c18eee9222ce 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -723,7 +723,8 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) /* disable dynamic functions, such as high power, DIG */ /* turn on all dynamic functions */ - Switch_DM_Func23a(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); + rtl8723a_odm_support_ability_set(padapter, + DYNAMIC_ALL_FUNC_ENABLE); } /* set channel, bwmode */ p = rtw_get_ie23a((pnetwork->IEs + sizeof(struct ndis_802_11_fixed_ies)), diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 316200ea0c50..94ba6ef8f24b 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -7719,7 +7719,6 @@ void site_survey23a(struct rtw_adapter *padapter) rtl8723a_set_initial_gain(padapter, 0xff); /* turn on dynamic functions */ rtl8723a_odm_support_ability_restore(padapter); - /* Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DIG|DYNAMIC_FUNC_HP|DYNAMIC_FUNC_SS, true); */ mod_timer(&pwdinfo->find_phase_timer, jiffies + msecs_to_jiffies(pwdinfo->listen_dwell * 100)); @@ -7748,7 +7747,6 @@ void site_survey23a(struct rtw_adapter *padapter) rtl8723a_set_initial_gain(padapter, 0xff); /* turn on dynamic functions */ rtl8723a_odm_support_ability_restore(padapter); - /* Switch_DM_Func23a(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); */ if (is_client_associated_to_ap23a(padapter) == true) { @@ -8705,7 +8703,7 @@ void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, int join_re } /* turn on dynamic functions */ - Switch_DM_Func23a(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); + rtl8723a_odm_support_ability_set(padapter, DYNAMIC_ALL_FUNC_ENABLE); /* update IOT-releated issue */ update_IOT_info23a(padapter); @@ -9225,7 +9223,8 @@ u8 createbss_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) /* disable dynamic functions, such as high power, DIG */ rtl8723a_odm_support_ability_backup(padapter); - Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DISABLE, false); + rtl8723a_odm_support_ability_clr(padapter, + DYNAMIC_FUNC_DISABLE); /* cancel link timer */ del_timer_sync(&pmlmeext->link_timer); @@ -9355,8 +9354,6 @@ u8 join_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) i += (pIE->Length + 2); } - /* disable dynamic functions, such as high power, DIG */ - /* Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DISABLE, false); */ hw_var_set_bssid(padapter, pmlmeinfo->network.MacAddress); hw_var_set_mlme_join(padapter, 0); @@ -9537,7 +9534,8 @@ u8 sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) (pmlmeext->sitesurvey_res.state == SCAN_TXNULL)) { /* disable dynamic functions, such as high power, DIG */ rtl8723a_odm_support_ability_backup(padapter); - Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DISABLE, false); + rtl8723a_odm_support_ability_clr(padapter, + DYNAMIC_FUNC_DISABLE); /* config the initial gain under scaning, need to write the BB registers */ diff --git a/drivers/staging/rtl8723au/core/rtw_sreset.c b/drivers/staging/rtl8723au/core/rtw_sreset.c index dd2a6f18f7d7..5bf7beb6d19c 100644 --- a/drivers/staging/rtl8723au/core/rtw_sreset.c +++ b/drivers/staging/rtl8723au/core/rtw_sreset.c @@ -140,9 +140,6 @@ static void sreset_restore_network_station(struct rtw_adapter *padapter) set_channel_bwmode23a(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); - /* disable dynamic functions, such as high power, DIG */ - /* Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DISABLE, false); */ - hw_var_set_bssid(padapter, pmlmeinfo->network.MacAddress); hw_var_set_mlme_join(padapter, 0); diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 809d4167731f..227280230dee 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -283,14 +283,6 @@ void Update23aTblForSoftAP(u8 *bssrateset, u32 bssratelen) } } -void Switch_DM_Func23a(struct rtw_adapter *padapter, unsigned long mode, u8 enable) -{ - if (enable == true) - rtw_hal_set_hwreg23a(padapter, HW_VAR_DM_FUNC_SET, (u8 *)(&mode)); - else - rtw_hal_set_hwreg23a(padapter, HW_VAR_DM_FUNC_CLR, (u8 *)(&mode)); -} - void Set_MSR23a(struct rtw_adapter *padapter, u8 type) { rtl8723a_set_media_status(padapter, type); @@ -1485,15 +1477,15 @@ void update_IOT_info23a(struct rtw_adapter *padapter) pmlmeinfo->turboMode_cts2self = 0; pmlmeinfo->turboMode_rtsen = 1; /* disable high power */ - Switch_DM_Func23a(padapter, ~DYNAMIC_BB_DYNAMIC_TXPWR, - false); + rtl8723a_odm_support_ability_clr(padapter, (u32) + ~DYNAMIC_BB_DYNAMIC_TXPWR); break; case HT_IOT_PEER_REALTEK: /* rtw_write16(padapter, 0x4cc, 0xffff); */ /* rtw_write16(padapter, 0x546, 0x01c0); */ /* disable high power */ - Switch_DM_Func23a(padapter, ~DYNAMIC_BB_DYNAMIC_TXPWR, - false); + rtl8723a_odm_support_ability_clr(padapter, (u32) + ~DYNAMIC_BB_DYNAMIC_TXPWR); break; default: pmlmeinfo->turboMode_cts2self = 0; diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 79e63bfb0b2e..62089f846838 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3142,13 +3142,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) case HW_VAR_DM_FLAG: rtl8723a_odm_support_ability_write(padapter, *val32); break; - case HW_VAR_DM_FUNC_SET: - rtl8723a_odm_support_ability_set(padapter, *val32); - break; - - case HW_VAR_DM_FUNC_CLR: - rtl8723a_odm_support_ability_clr(padapter, *val32); - break; case HW_VAR_EFUSE_BYTES: pHalData->EfuseUsedBytes = *((u16 *) val); diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 2218032ef617..2675fc09fecf 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -40,8 +40,6 @@ enum HW_VARIABLES { HW_VAR_TXPAUSE, HW_VAR_RF_TYPE, HW_VAR_DM_FLAG, - HW_VAR_DM_FUNC_SET, - HW_VAR_DM_FUNC_CLR, HW_VAR_CAM_READ, HW_VAR_FWLPS_RF_ON, HW_VAR_TDLS_WRCR, diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 53b2d0a34734..7729b2be25ae 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -474,8 +474,6 @@ void get_rate_set23a(struct rtw_adapter *padapter, unsigned char *pbssrate, void UpdateBrateTbl23a(struct rtw_adapter *padapter,u8 *mBratesOS); void Update23aTblForSoftAP(u8 *bssrateset, u32 bssratelen); -void Switch_DM_Func23a(struct rtw_adapter *padapter, unsigned long mode, u8 enable); - void Set_MSR23a(struct rtw_adapter *padapter, u8 type); u8 rtw_get_oper_ch23a(struct rtw_adapter *adapter); -- cgit v1.2.3 From df09df24d0d682c926eee174dc1f1692b03f577a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:44 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_DM_FLAG Both the read and write calls were never used Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_com.c | 7 ------- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 12 ------------ drivers/staging/rtl8723au/include/hal_intf.h | 1 - 3 files changed, 20 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index 66adec743a85..62281287456f 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -865,13 +865,6 @@ void rtl8723a_set_initial_gain(struct rtw_adapter *padapter, u32 rx_gain) } } -void rtl8723a_odm_support_ability_write(struct rtw_adapter *padapter, u32 val) -{ - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - - pHalData->odmpriv.SupportAbility = val; -} - void rtl8723a_odm_support_ability_restore(struct rtw_adapter *padapter) { struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 62089f846838..2c5334512129 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3132,17 +3132,12 @@ void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type) void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) { struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - u32 *val32 = (u32 *)val; switch (variable) { case HW_VAR_TXPAUSE: rtl8723a_set_tx_pause(padapter, *val); break; - case HW_VAR_DM_FLAG: - rtl8723a_odm_support_ability_write(padapter, *val32); - break; - case HW_VAR_EFUSE_BYTES: pHalData->EfuseUsedBytes = *((u16 *) val); break; @@ -3172,13 +3167,6 @@ void GetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) *val = pHalData->rf_type; break; - case HW_VAR_DM_FLAG: - { - struct dm_odm_t *podmpriv = &pHalData->odmpriv; - *((u32 *) val) = podmpriv->SupportAbility; - } - break; - case HW_VAR_FWLPS_RF_ON: { /* When we halt NIC, we should check if FW LPS is leave. */ diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 2675fc09fecf..1fd253733277 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -39,7 +39,6 @@ enum HW_VARIABLES { HW_VAR_INIT_RTS_RATE, HW_VAR_TXPAUSE, HW_VAR_RF_TYPE, - HW_VAR_DM_FLAG, HW_VAR_CAM_READ, HW_VAR_FWLPS_RF_ON, HW_VAR_TDLS_WRCR, -- cgit v1.2.3 From 441ffea706564f710af1d532ff708ef0b0e24911 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:45 +0200 Subject: staging: rtl8723au: Remove HW_VAR_APFM_ON_MAC None of this was ever used, so pull it out together with related variables Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_com.c | 8 -------- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 6 ------ drivers/staging/rtl8723au/include/hal_intf.h | 1 - drivers/staging/rtl8723au/include/rtl8723a_hal.h | 8 -------- 4 files changed, 23 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index 62281287456f..7e657af460b1 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -755,14 +755,6 @@ void rtl8723a_fifo_cleanup(struct rtw_adapter *padapter) } } -void rtl8723a_set_apfm_on_mac(struct rtw_adapter *padapter, u8 val) -{ - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - - pHalData->bMacPwrCtrlOn = val; - DBG_8723A("%s: bMacPwrCtrlOn =%d\n", __func__, pHalData->bMacPwrCtrlOn); -} - void rtl8723a_bcn_valid(struct rtw_adapter *padapter) { /* BCN_VALID, BIT16 of REG_TDECTRL = BIT0 of REG_TDECTRL+2, diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 2c5334512129..d5ab4d787861 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3144,9 +3144,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) case HW_VAR_EFUSE_BT_BYTES: pHalData->BTEfuseUsedBytes = *((u16 *) val); break; - case HW_VAR_APFM_ON_MAC: - rtl8723a_set_apfm_on_mac(padapter, *val); - break; default: break; @@ -3195,9 +3192,6 @@ void GetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) *((u16 *) val) = pHalData->BTEfuseUsedBytes; break; - case HW_VAR_APFM_ON_MAC: - *val = pHalData->bMacPwrCtrlOn; - break; case HW_VAR_CHK_HI_QUEUE_EMPTY: *val = ((rtw_read32(padapter, REG_HGQ_INFORMATION) & 0x0000ff00) == diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 1fd253733277..39ddbcb3d717 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -54,7 +54,6 @@ enum HW_VARIABLES { HW_VAR_SWITCH_EPHY_WoWLAN, HW_VAR_EFUSE_BYTES, HW_VAR_EFUSE_BT_BYTES, - HW_VAR_APFM_ON_MAC, /* Auto FSM to Turn On, include clock, isolation, power control for MAC only */ /* The valid upper nav range for the HW updating, if the true value is larger than the upper range, the HW won't update it. */ /* Unit in microsecond. 0 means disable this function. */ HW_VAR_RPT_TIMER_SETTING, diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index c20248bab717..5fce43cd55a4 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -437,14 +437,6 @@ struct hal_data_8723a { /* Interrupt related register information. */ u32 IntArray[2]; u32 IntrMask[2]; - - /* */ - /* For SDIO Interface HAL related */ - /* */ - - /* Auto FSM to Turn On, include clock, isolation, power control for MAC only */ - u8 bMacPwrCtrlOn; - }; #define GET_HAL_DATA(__pAdapter) ((struct hal_data_8723a *)((__pAdapter)->HalData)) -- cgit v1.2.3 From a2342292e59a42d357ad98cc516438d476855a0b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:46 +0200 Subject: staging: rtl8723au: Remove HW_VAR_EFUSE_{BT_,}BYTES Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 45 ++++++++--------------- drivers/staging/rtl8723au/include/hal_intf.h | 2 - 2 files changed, 16 insertions(+), 31 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index d5ab4d787861..6c1af4919214 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -619,6 +619,7 @@ hal_ReadEFuse_WiFi(struct rtw_adapter *padapter, u8 offset, wden; u8 efuseHeader, efuseExtHdr, efuseData; u16 i, total, used; + struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); /* Do NOT excess total size of EFuse table. Added by Roger, 2008.11.10. */ @@ -696,7 +697,7 @@ hal_ReadEFuse_WiFi(struct rtw_adapter *padapter, EFUSE_GetEfuseDefinition23a(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, &total); used = eFuse_Addr - 1; - rtw_hal_set_hwreg23a(padapter, HW_VAR_EFUSE_BYTES, (u8 *)&used); + pHalData->EfuseUsedBytes = used; kfree(efuseTbl); } @@ -711,6 +712,7 @@ hal_ReadEFuse_BT(struct rtw_adapter *padapter, u8 efuseHeader, efuseExtHdr, efuseData; u8 offset, wden; u16 i, total, used; + struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); /* Do NOT excess total size of EFuse table. Added by Roger, 2008.11.10. */ @@ -812,7 +814,7 @@ hal_ReadEFuse_BT(struct rtw_adapter *padapter, EFUSE_GetEfuseDefinition23a(padapter, EFUSE_BT, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, &total); used = (EFUSE_BT_REAL_BANK_CONTENT_LEN * (bank - 1)) + eFuse_Addr - 1; - rtw_hal_set_hwreg23a(padapter, HW_VAR_EFUSE_BT_BYTES, (u8 *) &used); + pHalData->BTEfuseUsedBytes = used; exit: kfree(efuseTbl); @@ -834,8 +836,9 @@ hal_EfuseGetCurrentSize_WiFi(struct rtw_adapter *padapter) u16 efuse_addr = 0; u8 hoffset = 0, hworden = 0; u8 efuse_data, word_cnts = 0; + struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - rtw23a_hal_get_hwreg(padapter, HW_VAR_EFUSE_BYTES, (u8 *) &efuse_addr); + efuse_addr = pHalData->EfuseUsedBytes; DBG_8723A("%s: start_efuse_addr = 0x%X\n", __func__, efuse_addr); @@ -872,7 +875,7 @@ hal_EfuseGetCurrentSize_WiFi(struct rtw_adapter *padapter) efuse_addr += (word_cnts * 2) + 1; } - rtw_hal_set_hwreg23a(padapter, HW_VAR_EFUSE_BYTES, (u8 *) &efuse_addr); + pHalData->EfuseUsedBytes = efuse_addr; DBG_8723A("%s: CurrentSize =%d\n", __func__, efuse_addr); @@ -888,8 +891,9 @@ hal_EfuseGetCurrentSize_BT(struct rtw_adapter *padapter) u8 hoffset = 0, hworden = 0; u8 efuse_data, word_cnts = 0; u16 retU2 = 0; + struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - rtw23a_hal_get_hwreg(padapter, HW_VAR_EFUSE_BT_BYTES, (u8 *) &btusedbytes); + btusedbytes = pHalData->BTEfuseUsedBytes; efuse_addr = (u16) ((btusedbytes % EFUSE_BT_REAL_BANK_CONTENT_LEN)); startBank = (u8) (1 + (btusedbytes / EFUSE_BT_REAL_BANK_CONTENT_LEN)); @@ -954,7 +958,7 @@ hal_EfuseGetCurrentSize_BT(struct rtw_adapter *padapter) } retU2 = ((bank - 1) * EFUSE_BT_REAL_BANK_CONTENT_LEN) + efuse_addr; - rtw_hal_set_hwreg23a(padapter, HW_VAR_EFUSE_BT_BYTES, (u8 *)&retU2); + pHalData->BTEfuseUsedBytes = retU2; DBG_8723A("%s: CurrentSize =%d\n", __func__, retU2); return retU2; @@ -1144,6 +1148,7 @@ static u8 hal_EfusePartialWriteCheck(struct rtw_adapter *padapter, u8 efuseType, u16 *pAddr, struct pg_pkt_struct *pTargetPkt) { + struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); u8 bRet = false; u16 startAddr = 0, efuse_max_available_len = 0, efuse_max = 0; u8 efuse_data = 0; @@ -1154,13 +1159,11 @@ hal_EfusePartialWriteCheck(struct rtw_adapter *padapter, u8 efuseType, EFUSE_GetEfuseDefinition23a(padapter, efuseType, TYPE_EFUSE_CONTENT_LEN_BANK, &efuse_max); - if (efuseType == EFUSE_WIFI) { - rtw23a_hal_get_hwreg(padapter, HW_VAR_EFUSE_BYTES, - (u8 *) &startAddr); - } else { - rtw23a_hal_get_hwreg(padapter, HW_VAR_EFUSE_BT_BYTES, - (u8 *) &startAddr); - } + if (efuseType == EFUSE_WIFI) + startAddr = pHalData->EfuseUsedBytes; + else + startAddr = pHalData->BTEfuseUsedBytes; + startAddr %= efuse_max; while (1) { @@ -3131,20 +3134,11 @@ void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type) void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) { - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - switch (variable) { case HW_VAR_TXPAUSE: rtl8723a_set_tx_pause(padapter, *val); break; - case HW_VAR_EFUSE_BYTES: - pHalData->EfuseUsedBytes = *((u16 *) val); - break; - case HW_VAR_EFUSE_BT_BYTES: - pHalData->BTEfuseUsedBytes = *((u16 *) val); - break; - default: break; } @@ -3184,13 +3178,6 @@ void GetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) } } break; - case HW_VAR_EFUSE_BYTES: - *((u16 *) val) = pHalData->EfuseUsedBytes; - break; - - case HW_VAR_EFUSE_BT_BYTES: - *((u16 *) val) = pHalData->BTEfuseUsedBytes; - break; case HW_VAR_CHK_HI_QUEUE_EMPTY: *val = diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 39ddbcb3d717..b6362deff01a 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -52,8 +52,6 @@ enum HW_VARIABLES { HW_VAR_ANTENNA_DIVERSITY_LINK, HW_VAR_ANTENNA_DIVERSITY_SELECT, HW_VAR_SWITCH_EPHY_WoWLAN, - HW_VAR_EFUSE_BYTES, - HW_VAR_EFUSE_BT_BYTES, /* The valid upper nav range for the HW updating, if the true value is larger than the upper range, the HW won't update it. */ /* Unit in microsecond. 0 means disable this function. */ HW_VAR_RPT_TIMER_SETTING, -- cgit v1.2.3 From aafb8684a8540a9266d0953b815ea55fb4f6c50a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:47 +0200 Subject: staging: rtl8723au: Remove HW_VAR_TXPAUSE This wasn't used at all Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_com.c | 5 ----- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 8 -------- drivers/staging/rtl8723au/include/hal_com.h | 1 - drivers/staging/rtl8723au/include/hal_intf.h | 1 - 4 files changed, 15 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index 7e657af460b1..38fef52c6020 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -772,11 +772,6 @@ bool rtl8723a_get_bcn_valid(struct rtw_adapter *padapter) return retval; } -void rtl8723a_set_tx_pause(struct rtw_adapter *padapter, u8 pause) -{ - rtw_write8(padapter, REG_TXPAUSE, pause); -} - void rtl8723a_set_beacon_interval(struct rtw_adapter *padapter, u16 interval) { rtw_write16(padapter, REG_BCN_INTERVAL, interval); diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 6c1af4919214..29ec6ab61c7c 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3135,10 +3135,6 @@ void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type) void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) { switch (variable) { - case HW_VAR_TXPAUSE: - rtl8723a_set_tx_pause(padapter, *val); - break; - default: break; } @@ -3150,10 +3146,6 @@ void GetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); switch (variable) { - case HW_VAR_TXPAUSE: - *val = rtw_read8(padapter, REG_TXPAUSE); - break; - case HW_VAR_RF_TYPE: *val = pHalData->rf_type; break; diff --git a/drivers/staging/rtl8723au/include/hal_com.h b/drivers/staging/rtl8723au/include/hal_com.h index e8774fc602c0..832cbac4ac9e 100644 --- a/drivers/staging/rtl8723au/include/hal_com.h +++ b/drivers/staging/rtl8723au/include/hal_com.h @@ -189,7 +189,6 @@ void rtl8723a_fifo_cleanup(struct rtw_adapter *padapter); void rtl8723a_set_apfm_on_mac(struct rtw_adapter *padapter, u8 val); void rtl8723a_bcn_valid(struct rtw_adapter *padapter); bool rtl8723a_get_bcn_valid(struct rtw_adapter *padapter); -void rtl8723a_set_tx_pause(struct rtw_adapter *padapter, u8 pause); void rtl8723a_set_beacon_interval(struct rtw_adapter *padapter, u16 interval); void rtl8723a_set_resp_sifs(struct rtw_adapter *padapter, u8 r2t1, u8 r2t2, u8 t2t1, u8 t2t2); diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index b6362deff01a..d86a8f12b822 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -37,7 +37,6 @@ enum _CHIP_TYPE { enum HW_VARIABLES { HW_VAR_INIT_RTS_RATE, - HW_VAR_TXPAUSE, HW_VAR_RF_TYPE, HW_VAR_CAM_READ, HW_VAR_FWLPS_RF_ON, -- cgit v1.2.3 From 4b03eb73ca441ea9756e304c9115a8009eb33b04 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:48 +0200 Subject: staging: rtl8723au: Eliminate unused HW_VAR_TRIGGER_GPIO_0 ... and related functions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_halinit.c | 18 ------------------ drivers/staging/rtl8723au/include/hal_intf.h | 1 - 2 files changed, 19 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index aaa81f87cc6e..382bca56825a 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1496,21 +1496,6 @@ static void ReadAdapterInfo8723AU(struct rtw_adapter *Adapter) _ReadAdapterInfo8723AU(Adapter); } -#define GPIO_DEBUG_PORT_NUM 0 -static void rtl8723au_trigger_gpio_0(struct rtw_adapter *padapter) -{ - u32 gpioctrl; - DBG_8723A("==> trigger_gpio_0...\n"); - rtw_write16_async(padapter, REG_GPIO_PIN_CTRL, 0); - rtw_write8_async(padapter, REG_GPIO_PIN_CTRL+2, 0xFF); - gpioctrl = (BIT(GPIO_DEBUG_PORT_NUM) << 24)| - (BIT(GPIO_DEBUG_PORT_NUM) << 16); - rtw_write32_async(padapter, REG_GPIO_PIN_CTRL, gpioctrl); - gpioctrl |= (BIT(GPIO_DEBUG_PORT_NUM)<<8); - rtw_write32_async(padapter, REG_GPIO_PIN_CTRL, gpioctrl); - DBG_8723A("<=== trigger_gpio_0...\n"); -} - /* * If variable not handled here, * some variables will be processed in SetHwReg8723A() @@ -1518,9 +1503,6 @@ static void rtl8723au_trigger_gpio_0(struct rtw_adapter *padapter) static void SetHwReg8723AU(struct rtw_adapter *Adapter, u8 variable, u8 *val) { switch (variable) { - case HW_VAR_TRIGGER_GPIO_0: - rtl8723au_trigger_gpio_0(Adapter); - break; default: SetHwReg8723A(Adapter, variable, val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index d86a8f12b822..a4b48772fd88 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -44,7 +44,6 @@ enum HW_VARIABLES { HW_VAR_TDLS_INIT_CH_SEN, HW_VAR_TDLS_RS_RCR, HW_VAR_TDLS_DONE_CH_SEN, - HW_VAR_TRIGGER_GPIO_0, HW_VAR_BT_SET_COEXIST, HW_VAR_BT_ISSUE_DELBA, HW_VAR_CURRENT_ANTENNA, -- cgit v1.2.3 From 3d577f60da985a2d0ed8935b517a3d84a98023dd Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:49 +0200 Subject: staging: rtl8723au: Remove calls to HW_VAR_H2C_MEDIA_STATUS This call was unhandled, so these calls were effectively a no-op Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 15 ++------------- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 4 ---- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 9cf26ea0088b..e6969362261d 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -1299,12 +1299,8 @@ void rtw23a_joinbss_event_cb(struct rtw_adapter *adapter, u8 *pbuf) /* FOR AP , AD-HOC mode */ void rtw_stassoc_hw_rpt23a(struct rtw_adapter *adapter, struct sta_info *psta) { - u16 media_status; - - if (psta == NULL) return; - - media_status = (psta->mac_id<<8)|1; /* MACID|OPMODE:1 connect */ - rtw_hal_set_hwreg23a(adapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status); + if (psta == NULL) + return; } void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) @@ -1402,13 +1398,6 @@ void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) DBG_8723A("%s(mac_id=%d)=" MAC_FMT "\n", __func__, mac_id, MAC_ARG(pstadel->macaddr)); - if(mac_id>=0) { - u16 media_status; - media_status = (mac_id<<8)|0; /* MACID|OPMODE:0 means disconnect */ - /* for STA,AP,ADHOC mode, report disconnect stauts to FW */ - rtw_hal_set_hwreg23a(adapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status); - } - if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { return; diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 94ba6ef8f24b..ff7ff9eb2403 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -8677,7 +8677,6 @@ void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, int join_re struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; struct sta_priv *pstapriv = &padapter->stapriv; - u16 media_status; if (join_res < 0) { hw_var_set_mlme_join(padapter, 1); @@ -8736,9 +8735,6 @@ void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, int join_re /* set per sta rate after updating HT cap. */ set_sta_rate23a(padapter, psta); - - media_status = (psta->mac_id<<8)|1; /* MACID|OPMODE: 1 means connect */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status); } hw_var_set_mlme_join(padapter, 2); diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index a4b48772fd88..bb27488e12eb 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -54,7 +54,6 @@ enum HW_VARIABLES { /* Unit in microsecond. 0 means disable this function. */ HW_VAR_RPT_TIMER_SETTING, HW_VAR_TX_RPT_MAX_MACID, - HW_VAR_H2C_MEDIA_STATUS_RPT, HW_VAR_CHK_HI_QUEUE_EMPTY, HW_VAR_READ_LLT_TAB, }; -- cgit v1.2.3 From 891d3decbb7ea6999a87dbca3774be4580586af0 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:50 +0200 Subject: staging: rtl8723au: Remove SetHwReg*() related code Remove all references to this odd mux/demux pseudo hw register handling code. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_intf.c | 6 ------ drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 9 --------- drivers/staging/rtl8723au/hal/usb_halinit.c | 15 --------------- drivers/staging/rtl8723au/include/hal_intf.h | 3 --- drivers/staging/rtl8723au/include/rtl8723a_hal.h | 1 - 5 files changed, 34 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index de3608b4010a..cafe347de63b 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -117,12 +117,6 @@ uint rtw_hal_deinit23a(struct rtw_adapter *padapter) return status; } -void rtw_hal_set_hwreg23a(struct rtw_adapter *padapter, u8 variable, u8 *val) -{ - if (padapter->HalFunc.SetHwRegHandler) - padapter->HalFunc.SetHwRegHandler(padapter, variable, val); -} - void rtw23a_hal_get_hwreg(struct rtw_adapter *padapter, u8 variable, u8 *val) { if (padapter->HalFunc.GetHwRegHandler) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 29ec6ab61c7c..f8ceeb27fb76 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3132,15 +3132,6 @@ void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type) #endif } -void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) -{ - switch (variable) { - default: - break; - } - -} - void GetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) { struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 382bca56825a..53ef7c39eae5 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1496,20 +1496,6 @@ static void ReadAdapterInfo8723AU(struct rtw_adapter *Adapter) _ReadAdapterInfo8723AU(Adapter); } -/* - * If variable not handled here, - * some variables will be processed in SetHwReg8723A() - */ -static void SetHwReg8723AU(struct rtw_adapter *Adapter, u8 variable, u8 *val) -{ - switch (variable) { - default: - SetHwReg8723A(Adapter, variable, val); - break; - } - -} - /* * If variable not handled here, * some variables will be processed in GetHwReg8723A() @@ -1796,7 +1782,6 @@ int rtl8723au_set_hal_ops(struct rtw_adapter *padapter) pHalFunc->init_default_value = &rtl8723au_init_default_value; pHalFunc->intf_chip_configure = &rtl8723au_interface_configure; pHalFunc->read_adapter_info = &ReadAdapterInfo8723AU; - pHalFunc->SetHwRegHandler = &SetHwReg8723AU; pHalFunc->GetHwRegHandler = &GetHwReg8723AU; pHalFunc->GetHalDefVarHandler = &GetHalDefVar8192CUsb; pHalFunc->SetHalDefVarHandler = &SetHalDefVar8192CUsb; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index bb27488e12eb..d38a670ca431 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -126,8 +126,6 @@ struct hal_ops { void (*hal_dm_watchdog)(struct rtw_adapter *padapter); - void (*SetHwRegHandler)(struct rtw_adapter *padapter, - u8 variable, u8 *val); void (*GetHwRegHandler)(struct rtw_adapter *padapter, u8 variable, u8 *val); @@ -263,7 +261,6 @@ u32 rtw_hal_power_on23a(struct rtw_adapter *padapter); uint rtw_hal_init23a(struct rtw_adapter *padapter); uint rtw_hal_deinit23a(struct rtw_adapter *padapter); void rtw_hal_stop(struct rtw_adapter *padapter); -void rtw_hal_set_hwreg23a(struct rtw_adapter *padapter, u8 variable, u8 *val); void rtw23a_hal_get_hwreg(struct rtw_adapter *padapter, u8 variable, u8 *val); void rtw_hal_chip_configure23a(struct rtw_adapter *padapter); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index 5fce43cd55a4..49d743dc68de 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -548,7 +548,6 @@ void Hal_EfuseParseThermalMeter_8723A(struct rtw_adapter *padapter, u8 *hwinfo, void Hal_InitChannelPlan23a(struct rtw_adapter *padapter); void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc); -void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val); void GetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val); #ifdef CONFIG_8723AU_BT_COEXIST void rtl8723a_SingleDualAntennaDetection(struct rtw_adapter *padapter); -- cgit v1.2.3 From f075870605b496794041430519f43fd37024ae07 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:51 +0200 Subject: staging: rtl8723au: Remove empty function rtw_stassoc_hw_rpt23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 2 -- drivers/staging/rtl8723au/core/rtw_mlme.c | 11 ----------- drivers/staging/rtl8723au/include/rtw_mlme.h | 1 - 3 files changed, 14 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index c18eee9222ce..75b52bf5dccf 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -523,8 +523,6 @@ static void update_bmc_sta(struct rtw_adapter *padapter) psta->raid = raid; psta->init_rate = init_rate; - rtw_stassoc_hw_rpt23a(padapter, psta); - spin_lock_bh(&psta->lock); psta->state = _FW_LINKED; spin_unlock_bh(&psta->lock); diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index e6969362261d..22e71702a84a 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -1296,13 +1296,6 @@ void rtw23a_joinbss_event_cb(struct rtw_adapter *adapter, u8 *pbuf) } -/* FOR AP , AD-HOC mode */ -void rtw_stassoc_hw_rpt23a(struct rtw_adapter *adapter, struct sta_info *psta) -{ - if (psta == NULL) - return; -} - void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) { struct sta_info *psta; @@ -1322,8 +1315,6 @@ void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) /* bss_cap_update_on_sta_join23a(adapter, psta); */ /* sta_info_update23a(adapter, psta); */ ap_sta_info_defer_update23a(adapter, psta); - - rtw_stassoc_hw_rpt23a(adapter,psta); } return; } @@ -1350,8 +1341,6 @@ void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) /* for ad-hoc mode */ rtw_hal_set_odm_var23a(adapter,HAL_ODM_STA_INFO,psta,true); - rtw_stassoc_hw_rpt23a(adapter,psta); - if(adapter->securitypriv.dot11AuthAlgrthm==dot11AuthAlgrthm_8021X) psta->dot118021XPrivacy = adapter->securitypriv.dot11PrivacyAlgrthm; diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index 31f96f39b498..dac930c77c01 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -619,6 +619,5 @@ void rtw23a_roaming(struct rtw_adapter *adapter, struct wlan_network *tgt_network); void rtw_set_roaming(struct rtw_adapter *adapter, u8 to_roaming); u8 rtw_to_roaming(struct rtw_adapter *adapter); -void rtw_stassoc_hw_rpt23a(struct rtw_adapter *adapter, struct sta_info *psta); #endif /* __RTL871X_MLME_H_ */ -- cgit v1.2.3 From b54e8804400773680a08ec73c127515c527440a8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:52 +0200 Subject: staging: rtl8723au: Improve some bad switch() formatting Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 61 ++++++++++-------------- drivers/staging/rtl8723au/core/rtw_mlme.c | 19 ++++---- drivers/staging/rtl8723au/core/rtw_p2p.c | 78 +++++++++++++++---------------- 3 files changed, 72 insertions(+), 86 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 75b52bf5dccf..e68d13aa5db5 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -1349,50 +1349,37 @@ void update_beacon23a(struct rtw_adapter *padapter, u8 ie_id, u8 *oui, u8 tx) switch (ie_id) { - case 0xFF: - - update_bcn_fixed_ie(padapter);/* 8: TimeStamp, 2: Beacon Interval 2:Capability */ - - break; - - case _TIM_IE_: - - update_BCNTIM(padapter); - - break; - - case _ERPINFO_IE_: - - update_bcn_erpinfo_ie(padapter); - - break; - - case _HT_CAPABILITY_IE_: - - update_bcn_htcap_ie(padapter); - - break; - - case _RSN_IE_2_: - - update_bcn_rsn_ie(padapter); - - break; + case 0xFF: + /* 8: TimeStamp, 2: Beacon Interval 2:Capability */ + update_bcn_fixed_ie(padapter); + break; - case _HT_ADD_INFO_IE_: + case _TIM_IE_: + update_BCNTIM(padapter); + break; - update_bcn_htinfo_ie(padapter); + case _ERPINFO_IE_: + update_bcn_erpinfo_ie(padapter); + break; - break; + case _HT_CAPABILITY_IE_: + update_bcn_htcap_ie(padapter); + break; - case _VENDOR_SPECIFIC_IE_: + case _RSN_IE_2_: + update_bcn_rsn_ie(padapter); + break; - update_bcn_vendor_spec_ie(padapter, oui); + case _HT_ADD_INFO_IE_: + update_bcn_htinfo_ie(padapter); + break; - break; + case _VENDOR_SPECIFIC_IE_: + update_bcn_vendor_spec_ie(padapter, oui); + break; - default: - break; + default: + break; } pmlmepriv->update_bcn = true; diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 22e71702a84a..717ba10c66a5 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -2324,17 +2324,18 @@ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len) pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_40; switch ((pmlmeinfo->HT_info.infos[0] & 0x3)) { - case HT_EXTCHNL_OFFSET_UPPER: - pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; - break; + case HT_EXTCHNL_OFFSET_UPPER: + pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; + break; - case HT_EXTCHNL_OFFSET_LOWER: - pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; - break; + case HT_EXTCHNL_OFFSET_LOWER: + pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; + break; - default: - pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - break; + default: + pmlmeext->cur_ch_offset = + HAL_PRIME_CHNL_OFFSET_DONT_CARE; + break; } } diff --git a/drivers/staging/rtl8723au/core/rtw_p2p.c b/drivers/staging/rtl8723au/core/rtw_p2p.c index e5d9991040bb..ba851cf4f992 100644 --- a/drivers/staging/rtl8723au/core/rtw_p2p.c +++ b/drivers/staging/rtl8723au/core/rtw_p2p.c @@ -3564,52 +3564,50 @@ void p2p_ps_wk_hdl23a(struct rtw_adapter *padapter, u8 p2p_ps_state) /* Pre action for p2p state */ switch (p2p_ps_state) { - case P2P_PS_DISABLE: + case P2P_PS_DISABLE: + pwdinfo->p2p_ps_state = p2p_ps_state; + + rtl8723a_set_p2p_ps_offload_cmd(padapter, p2p_ps_state); + + pwdinfo->noa_index = 0; + pwdinfo->ctwindow = 0; + pwdinfo->opp_ps = 0; + pwdinfo->noa_num = 0; + pwdinfo->p2p_ps_mode = P2P_PS_NONE; + if (padapter->pwrctrlpriv.bFwCurrentInPSMode == true) { + if (pwrpriv->smart_ps == 0) { + pwrpriv->smart_ps = 2; + rtl8723a_set_FwPwrMode_cmd(padapter, padapter->pwrctrlpriv.pwr_mode); + } + } + break; + case P2P_PS_ENABLE: + if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) { pwdinfo->p2p_ps_state = p2p_ps_state; - rtl8723a_set_p2p_ps_offload_cmd(padapter, p2p_ps_state); - - pwdinfo->noa_index = 0; - pwdinfo->ctwindow = 0; - pwdinfo->opp_ps = 0; - pwdinfo->noa_num = 0; - pwdinfo->p2p_ps_mode = P2P_PS_NONE; - if (padapter->pwrctrlpriv.bFwCurrentInPSMode == true) { - if (pwrpriv->smart_ps == 0) { - pwrpriv->smart_ps = 2; + if (pwdinfo->ctwindow > 0) { + if (pwrpriv->smart_ps != 0) { + pwrpriv->smart_ps = 0; + DBG_8723A("%s(): Enter CTW, change " + "SmartPS\n", __func__); rtl8723a_set_FwPwrMode_cmd(padapter, padapter->pwrctrlpriv.pwr_mode); } } - break; - case P2P_PS_ENABLE: - if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) { - pwdinfo->p2p_ps_state = p2p_ps_state; - - if (pwdinfo->ctwindow > 0) { - if (pwrpriv->smart_ps != 0) { - pwrpriv->smart_ps = 0; - DBG_8723A("%s(): Enter CTW, change SmartPS\n", __func__); - rtl8723a_set_FwPwrMode_cmd(padapter, padapter->pwrctrlpriv.pwr_mode); - } - } - rtl8723a_set_p2p_ps_offload_cmd(padapter, - p2p_ps_state); - } - break; - case P2P_PS_SCAN: - case P2P_PS_SCAN_DONE: - case P2P_PS_ALLSTASLEEP: - if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) { - pwdinfo->p2p_ps_state = p2p_ps_state; - rtl8723a_set_p2p_ps_offload_cmd(padapter, - p2p_ps_state); - } - break; - default: - break; + rtl8723a_set_p2p_ps_offload_cmd(padapter, + p2p_ps_state); + } + break; + case P2P_PS_SCAN: + case P2P_PS_SCAN_DONE: + case P2P_PS_ALLSTASLEEP: + if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) { + pwdinfo->p2p_ps_state = p2p_ps_state; + rtl8723a_set_p2p_ps_offload_cmd(padapter, p2p_ps_state); + } + break; + default: + break; } - - } u8 p2p_ps_wk_cmd23a(struct rtw_adapter*padapter, u8 p2p_ps_state, u8 enqueue) -- cgit v1.2.3 From c2370e83ab5432e2d32e9c097930c69366d27b4c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:53 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_RF_TYPE usage Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 8 ++++---- drivers/staging/rtl8723au/core/rtw_ioctl_set.c | 3 +-- drivers/staging/rtl8723au/core/rtw_mlme.c | 10 ++++------ drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 3 +-- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 2 +- drivers/staging/rtl8723au/hal/hal_com.c | 7 +++++++ drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 6 ------ drivers/staging/rtl8723au/include/hal_com.h | 1 + drivers/staging/rtl8723au/include/hal_intf.h | 1 - drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 2 +- 10 files changed, 20 insertions(+), 23 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index e68d13aa5db5..131d787dac78 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -374,9 +374,9 @@ void add_RATid23a(struct rtw_adapter *padapter, struct sta_info *psta, u8 rssi_l tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value23a(psta->bssrateset[i]&0x7f); } /* n mode ra_bitmap */ - if (psta_ht->ht_option) - { - rtw23a_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + if (psta_ht->ht_option) { + rf_type = rtl8723a_get_rf_type(padapter); + if (rf_type == RF_2T2R) limit = 16;/* 2R */ else @@ -989,7 +989,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, int len) ht_cap = true; network_type |= WIRELESS_11_24N; - rtw23a_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + rf_type = rtl8723a_get_rf_type(padapter); if ((psecuritypriv->wpa_pairwise_cipher & WPA_CIPHER_CCMP) || (psecuritypriv->wpa2_pairwise_cipher & WPA_CIPHER_CCMP)) diff --git a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c index 30d7185e5637..1f9d3a3d4920 100644 --- a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c @@ -577,8 +577,7 @@ u16 rtw_get_cur_max_rate23a(struct rtw_adapter *adapter) short_GI_20 = (pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info&IEEE80211_HT_CAP_SGI_20) ? 1:0; short_GI_40 = (pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info&IEEE80211_HT_CAP_SGI_40) ? 1:0; - rtw23a_hal_get_hwreg(adapter, HW_VAR_RF_TYPE, - (u8 *)(&rf_type)); + rf_type = rtl8723a_get_rf_type(adapter); max_rate = rtw_mcs_rate23a(rf_type, bw_40MHz & pregistrypriv->cbw40_enable, short_GI_20, short_GI_40, diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 717ba10c66a5..f72bae42dcb0 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -2305,16 +2305,14 @@ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len) /* update cur_bwmode & cur_ch_offset */ if ((pregistrypriv->cbw40_enable) && (pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info & BIT(1)) && - (pmlmeinfo->HT_info.infos[0] & BIT(2))) - { + (pmlmeinfo->HT_info.infos[0] & BIT(2))) { int i; - u8 rf_type; + u8 rf_type; - padapter->HalFunc.GetHwRegHandler(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + rf_type = rtl8723a_get_rf_type(padapter); /* update the MCS rates */ - for (i = 0; i < 16; i++) - { + for (i = 0; i < 16; i++) { if ((rf_type == RF_1T1R) || (rf_type == RF_1T2R)) pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= MCS_rate_1R23A[i]; else diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index ff7ff9eb2403..ae6ef6532af0 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -6454,8 +6454,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info |= 0x000c; - rtw23a_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, - (u8 *)(&rf_type)); + rf_type = rtl8723a_get_rf_type(padapter); /* switch (pregpriv->rf_config) */ switch (rf_type) { diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 227280230dee..e364d7afc08d 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -770,7 +770,7 @@ void HT_caps_handler23a(struct rtw_adapter *padapter, struct ndis_802_11_var_ies pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info = le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info); pmlmeinfo->HT_caps.u.HT_cap_element.HT_ext_caps = le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_ext_caps); - rtw23a_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + rf_type = rtl8723a_get_rf_type(padapter); /* update the MCS rates */ for (i = 0; i < 16; i++) { diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index 38fef52c6020..c41781e6a5e5 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -889,3 +889,10 @@ void rtl8723a_set_rpwm(struct rtw_adapter *padapter, u8 val) { rtw_write8(padapter, REG_USB_HRPWM, val); } + +u8 rtl8723a_get_rf_type(struct rtw_adapter *padapter) +{ + struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); + + return pHalData->rf_type; +} diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index f8ceeb27fb76..b3d398a75512 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3134,13 +3134,7 @@ void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type) void GetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) { - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - switch (variable) { - case HW_VAR_RF_TYPE: - *val = pHalData->rf_type; - break; - case HW_VAR_FWLPS_RF_ON: { /* When we halt NIC, we should check if FW LPS is leave. */ diff --git a/drivers/staging/rtl8723au/include/hal_com.h b/drivers/staging/rtl8723au/include/hal_com.h index 832cbac4ac9e..d2e372c302f7 100644 --- a/drivers/staging/rtl8723au/include/hal_com.h +++ b/drivers/staging/rtl8723au/include/hal_com.h @@ -207,5 +207,6 @@ void rtl8723a_odm_support_ability_set(struct rtw_adapter *padapter, u32 val); void rtl8723a_odm_support_ability_clr(struct rtw_adapter *padapter, u32 val); void rtl8723a_set_rpwm(struct rtw_adapter *padapter, u8 val); +u8 rtl8723a_get_rf_type(struct rtw_adapter *padapter); #endif /* __HAL_COMMON_H__ */ diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index d38a670ca431..5bdf34b0e3d6 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -37,7 +37,6 @@ enum _CHIP_TYPE { enum HW_VARIABLES { HW_VAR_INIT_RTS_RATE, - HW_VAR_RF_TYPE, HW_VAR_CAM_READ, HW_VAR_FWLPS_RF_ON, HW_VAR_TDLS_WRCR, diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 58366236777f..fadc53cf6266 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -4347,7 +4347,7 @@ void rtw_cfg80211_init_wiphy(struct rtw_adapter *padapter) struct wireless_dev *pwdev = padapter->rtw_wdev; struct wiphy *wiphy = pwdev->wiphy; - rtw23a_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + rf_type = rtl8723a_get_rf_type(padapter); DBG_8723A("%s:rf_type =%d\n", __func__, rf_type); -- cgit v1.2.3 From 0cee8101d83bbc5cc3d8e44ab601e2fdb15cf887 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:54 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_FWLPS_RF_ON usage Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 7 +++---- drivers/staging/rtl8723au/hal/hal_com.c | 23 +++++++++++++++++++++++ drivers/staging/rtl8723au/hal/rtl8723a_dm.c | 2 +- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 21 --------------------- drivers/staging/rtl8723au/include/hal_com.h | 1 + drivers/staging/rtl8723au/include/hal_intf.h | 1 - 6 files changed, 28 insertions(+), 27 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index da6645e9b9fc..07c63246ca31 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -386,12 +386,11 @@ s32 LPS_RF_ON_check23a(struct rtw_adapter *padapter, u32 delay_ms) while (1) { - rtw23a_hal_get_hwreg(padapter, HW_VAR_FWLPS_RF_ON, &bAwake); - if (true == bAwake) + bAwake = rtl8723a_get_fwlps_rf_on(padapter); + if (bAwake == true) break; - if (true == padapter->bSurpriseRemoved) - { + if (padapter->bSurpriseRemoved == true) { err = -2; DBG_8723A("%s: device surprise removed!!\n", __func__); break; diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index c41781e6a5e5..7b00dbadf105 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -896,3 +896,26 @@ u8 rtl8723a_get_rf_type(struct rtw_adapter *padapter) return pHalData->rf_type; } + +bool rtl8723a_get_fwlps_rf_on(struct rtw_adapter *padapter) +{ + bool retval; + u32 valRCR; + + /* When we halt NIC, we should check if FW LPS is leave. */ + + if ((padapter->bSurpriseRemoved == true) || + (padapter->pwrctrlpriv.rf_pwrstate == rf_off)) { + /* If it is in HW/SW Radio OFF or IPS state, we do + not check Fw LPS Leave, because Fw is unload. */ + retval = true; + } else { + valRCR = rtw_read32(padapter, REG_RCR); + if (valRCR & 0x00070000) + retval = false; + else + retval = true; + } + + return retval; +} diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_dm.c b/drivers/staging/rtl8723au/hal/rtl8723a_dm.c index f204ab1714e7..b3907ca2e96b 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_dm.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_dm.c @@ -217,7 +217,7 @@ rtl8723a_HalDmWatchDog( goto skip_dm; bFwCurrentInPSMode = Adapter->pwrctrlpriv.bFwCurrentInPSMode; - rtw23a_hal_get_hwreg(Adapter, HW_VAR_FWLPS_RF_ON, (u8 *)(&bFwPSAwake)); + bFwPSAwake = rtl8723a_get_fwlps_rf_on(Adapter); #ifdef CONFIG_8723AU_P2P /* Fw is under p2p powersaving mode, driver should stop dynamic mechanism. */ diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index b3d398a75512..f9cf4c88f7ff 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3135,27 +3135,6 @@ void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type) void GetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) { switch (variable) { - case HW_VAR_FWLPS_RF_ON: - { - /* When we halt NIC, we should check if FW LPS is leave. */ - u32 valRCR; - - if ((padapter->bSurpriseRemoved == true) || - (padapter->pwrctrlpriv.rf_pwrstate == rf_off)) { - /* If it is in HW/SW Radio OFF or IPS state, we do - not check Fw LPS Leave, because Fw is unload. */ - *val = true; - } else { - valRCR = rtw_read32(padapter, REG_RCR); - valRCR &= 0x00070000; - if (valRCR) - *val = false; - else - *val = true; - } - } - break; - case HW_VAR_CHK_HI_QUEUE_EMPTY: *val = ((rtw_read32(padapter, REG_HGQ_INFORMATION) & 0x0000ff00) == diff --git a/drivers/staging/rtl8723au/include/hal_com.h b/drivers/staging/rtl8723au/include/hal_com.h index d2e372c302f7..84e472e671d1 100644 --- a/drivers/staging/rtl8723au/include/hal_com.h +++ b/drivers/staging/rtl8723au/include/hal_com.h @@ -208,5 +208,6 @@ void rtl8723a_odm_support_ability_clr(struct rtw_adapter *padapter, u32 val); void rtl8723a_set_rpwm(struct rtw_adapter *padapter, u8 val); u8 rtl8723a_get_rf_type(struct rtw_adapter *padapter); +bool rtl8723a_get_fwlps_rf_on(struct rtw_adapter *padapter); #endif /* __HAL_COMMON_H__ */ diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 5bdf34b0e3d6..35bedf984ba9 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -38,7 +38,6 @@ enum _CHIP_TYPE { enum HW_VARIABLES { HW_VAR_INIT_RTS_RATE, HW_VAR_CAM_READ, - HW_VAR_FWLPS_RF_ON, HW_VAR_TDLS_WRCR, HW_VAR_TDLS_INIT_CH_SEN, HW_VAR_TDLS_RS_RCR, -- cgit v1.2.3 From 8d3fd6145b963c5d156e442677193c3fa10df708 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:55 +0200 Subject: staging: rtl8723au: Eliminate HW_WAR_CHK_HI_QUEUE_EMPTY usage Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 9 ++++----- drivers/staging/rtl8723au/hal/hal_com.c | 9 +++++++++ drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 5 ----- drivers/staging/rtl8723au/include/hal_com.h | 1 + drivers/staging/rtl8723au/include/hal_intf.h | 1 - 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 0b25cd2f6584..2c558e0dd12b 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -1441,11 +1441,11 @@ static void rtw_chk_hi_queue_hdl(struct rtw_adapter *padapter) return; if (psta_bmc->sleepq_len == 0) { - u8 val = 0; + bool val; - rtw23a_hal_get_hwreg(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &val); + val = rtl8723a_chk_hi_queue_empty(padapter); - while(val == false) { + while (val == false) { msleep(100); cnt++; @@ -1453,8 +1453,7 @@ static void rtw_chk_hi_queue_hdl(struct rtw_adapter *padapter) if (cnt>10) break; - rtw23a_hal_get_hwreg(padapter, - HW_VAR_CHK_HI_QUEUE_EMPTY, &val); + val = rtl8723a_chk_hi_queue_empty(padapter); } if (cnt <= 10) { diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index 7b00dbadf105..d1701a35bc90 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -919,3 +919,12 @@ bool rtl8723a_get_fwlps_rf_on(struct rtw_adapter *padapter) return retval; } + +bool rtl8723a_chk_hi_queue_empty(struct rtw_adapter *padapter) +{ + u32 hgq; + + hgq = rtw_read32(padapter, REG_HGQ_INFORMATION); + + return ((hgq & 0x0000ff00) == 0) ? true : false; +} diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index f9cf4c88f7ff..9967c075a702 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3135,11 +3135,6 @@ void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type) void GetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) { switch (variable) { - case HW_VAR_CHK_HI_QUEUE_EMPTY: - *val = - ((rtw_read32(padapter, REG_HGQ_INFORMATION) & 0x0000ff00) == - 0) ? true : false; - break; } } diff --git a/drivers/staging/rtl8723au/include/hal_com.h b/drivers/staging/rtl8723au/include/hal_com.h index 84e472e671d1..5f050a346a8a 100644 --- a/drivers/staging/rtl8723au/include/hal_com.h +++ b/drivers/staging/rtl8723au/include/hal_com.h @@ -209,5 +209,6 @@ void rtl8723a_odm_support_ability_clr(struct rtw_adapter *padapter, u32 val); void rtl8723a_set_rpwm(struct rtw_adapter *padapter, u8 val); u8 rtl8723a_get_rf_type(struct rtw_adapter *padapter); bool rtl8723a_get_fwlps_rf_on(struct rtw_adapter *padapter); +bool rtl8723a_chk_hi_queue_empty(struct rtw_adapter *padapter); #endif /* __HAL_COMMON_H__ */ diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 35bedf984ba9..e5b71ca639dc 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -52,7 +52,6 @@ enum HW_VARIABLES { /* Unit in microsecond. 0 means disable this function. */ HW_VAR_RPT_TIMER_SETTING, HW_VAR_TX_RPT_MAX_MACID, - HW_VAR_CHK_HI_QUEUE_EMPTY, HW_VAR_READ_LLT_TAB, }; -- cgit v1.2.3 From 0a44991073d38604fe7d422d39b7de7896b9e844 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:56 +0200 Subject: staging: rtl8723au: Kill off ugly GetHwReg*() interface Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_intf.c | 6 ------ drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 6 ------ drivers/staging/rtl8723au/hal/usb_halinit.c | 10 ---------- drivers/staging/rtl8723au/include/hal_intf.h | 4 ---- drivers/staging/rtl8723au/include/rtl8723a_hal.h | 1 - 5 files changed, 27 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index cafe347de63b..04cc53424b51 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -117,12 +117,6 @@ uint rtw_hal_deinit23a(struct rtw_adapter *padapter) return status; } -void rtw23a_hal_get_hwreg(struct rtw_adapter *padapter, u8 variable, u8 *val) -{ - if (padapter->HalFunc.GetHwRegHandler) - padapter->HalFunc.GetHwRegHandler(padapter, variable, val); -} - u8 rtw_hal_set_def_var23a(struct rtw_adapter *padapter, enum hal_def_variable eVariable, void *pValue) { if (padapter->HalFunc.SetHalDefVarHandler) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 9967c075a702..8ea00ba851a2 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3132,12 +3132,6 @@ void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type) #endif } -void GetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) -{ - switch (variable) { - } -} - #ifdef CONFIG_8723AU_BT_COEXIST void rtl8723a_SingleDualAntennaDetection(struct rtw_adapter *padapter) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 53ef7c39eae5..0a6e343373ff 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1496,15 +1496,6 @@ static void ReadAdapterInfo8723AU(struct rtw_adapter *Adapter) _ReadAdapterInfo8723AU(Adapter); } -/* - * If variable not handled here, - * some variables will be processed in GetHwReg8723A() - */ -static void GetHwReg8723AU(struct rtw_adapter *Adapter, u8 variable, u8 *val) -{ - GetHwReg8723A(Adapter, variable, val); -} - /* */ /* Description: */ /* Query setting of specified variable. */ @@ -1782,7 +1773,6 @@ int rtl8723au_set_hal_ops(struct rtw_adapter *padapter) pHalFunc->init_default_value = &rtl8723au_init_default_value; pHalFunc->intf_chip_configure = &rtl8723au_interface_configure; pHalFunc->read_adapter_info = &ReadAdapterInfo8723AU; - pHalFunc->GetHwRegHandler = &GetHwReg8723AU; pHalFunc->GetHalDefVarHandler = &GetHalDefVar8192CUsb; pHalFunc->SetHalDefVarHandler = &SetHalDefVar8192CUsb; pHalFunc->UpdateRAMaskHandler = &UpdateHalRAMask8192CUsb; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index e5b71ca639dc..0284ec054d0d 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -123,9 +123,6 @@ struct hal_ops { void (*hal_dm_watchdog)(struct rtw_adapter *padapter); - void (*GetHwRegHandler)(struct rtw_adapter *padapter, - u8 variable, u8 *val); - u8 (*GetHalDefVarHandler)(struct rtw_adapter *padapter, enum hal_def_variable eVariable, void *pValue); @@ -258,7 +255,6 @@ u32 rtw_hal_power_on23a(struct rtw_adapter *padapter); uint rtw_hal_init23a(struct rtw_adapter *padapter); uint rtw_hal_deinit23a(struct rtw_adapter *padapter); void rtw_hal_stop(struct rtw_adapter *padapter); -void rtw23a_hal_get_hwreg(struct rtw_adapter *padapter, u8 variable, u8 *val); void rtw_hal_chip_configure23a(struct rtw_adapter *padapter); void rtw_hal_read_chip_info23a(struct rtw_adapter *padapter); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index 49d743dc68de..ce11245fefd7 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -548,7 +548,6 @@ void Hal_EfuseParseThermalMeter_8723A(struct rtw_adapter *padapter, u8 *hwinfo, void Hal_InitChannelPlan23a(struct rtw_adapter *padapter); void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc); -void GetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val); #ifdef CONFIG_8723AU_BT_COEXIST void rtl8723a_SingleDualAntennaDetection(struct rtw_adapter *padapter); #endif -- cgit v1.2.3 From ec21da4696ea7a94ca44b9a221daa49d172b565f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:57 +0200 Subject: staging: rtl8723au: Remove obsolete HW_VARIABLES enum Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/hal_intf.h | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 0284ec054d0d..946bce045d5f 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -35,26 +35,6 @@ enum _CHIP_TYPE { MAX_CHIP_TYPE }; -enum HW_VARIABLES { - HW_VAR_INIT_RTS_RATE, - HW_VAR_CAM_READ, - HW_VAR_TDLS_WRCR, - HW_VAR_TDLS_INIT_CH_SEN, - HW_VAR_TDLS_RS_RCR, - HW_VAR_TDLS_DONE_CH_SEN, - HW_VAR_BT_SET_COEXIST, - HW_VAR_BT_ISSUE_DELBA, - HW_VAR_CURRENT_ANTENNA, - HW_VAR_ANTENNA_DIVERSITY_LINK, - HW_VAR_ANTENNA_DIVERSITY_SELECT, - HW_VAR_SWITCH_EPHY_WoWLAN, - /* The valid upper nav range for the HW updating, if the true value is larger than the upper range, the HW won't update it. */ - /* Unit in microsecond. 0 means disable this function. */ - HW_VAR_RPT_TIMER_SETTING, - HW_VAR_TX_RPT_MAX_MACID, - HW_VAR_READ_LLT_TAB, -}; - enum hal_def_variable { HAL_DEF_UNDERCORATEDSMOOTHEDPWDB, HAL_DEF_IS_SUPPORT_ANT_DIV, -- cgit v1.2.3 From 3f58bf2ec0682bb00cdefd5bc7f3e91bcc2e30fa Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:58 +0200 Subject: staging: rtl8723au: Remove unused is_boot_from_eeprom() macro Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 946bce045d5f..0b07e8b1f068 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -214,7 +214,6 @@ enum hardware_type { }; #define GET_EEPROM_EFUSE_PRIV(adapter) (&adapter->eeprompriv) -#define is_boot_from_eeprom(adapter) (adapter->eeprompriv.EepromOrEfuse) extern int rtw_ht_enable23A; extern int rtw_cbw40_enable23A; -- cgit v1.2.3 From 141bd353c5a9ba987dbe7b28ffdd034bb3ed55ba Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:59 +0200 Subject: staging: rtl8723au: Remove #ifdef CONFIG_DEBUG_CFG80211 Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 65 +---------------------- 1 file changed, 2 insertions(+), 63 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index fadc53cf6266..86721dc7c1b9 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -1298,10 +1298,8 @@ static int cfg80211_rtw_get_station(struct wiphy *wiphy, ret = -ENOENT; goto exit; } -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A(FUNC_NDEV_FMT " mac =" MAC_FMT "\n", FUNC_NDEV_ARG(ndev), MAC_ARG(mac)); -#endif /* for infra./P2PClient mode */ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && @@ -1438,9 +1436,8 @@ void rtw_cfg80211_indicate_scan_done(struct rtw_wdev_priv *pwdev_priv, { spin_lock_bh(&pwdev_priv->scan_req_lock); if (pwdev_priv->scan_request != NULL) { -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("%s with scan req\n", __func__); -#endif + if (pwdev_priv->scan_request->wiphy != pwdev_priv->rtw_wdev->wiphy) DBG_8723A("error wiphy compare\n"); @@ -1449,9 +1446,7 @@ void rtw_cfg80211_indicate_scan_done(struct rtw_wdev_priv *pwdev_priv, pwdev_priv->scan_request = NULL; } else { -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("%s without scan req\n", __func__); -#endif } spin_unlock_bh(&pwdev_priv->scan_req_lock); } @@ -1463,10 +1458,6 @@ void rtw_cfg80211_surveydone_event_callback(struct rtw_adapter *padapter) struct rtw_queue *queue = &pmlmepriv->scanned_queue; struct wlan_network *pnetwork; -#ifdef CONFIG_DEBUG_CFG80211 - DBG_8723A("%s\n", __func__); -#endif - spin_lock_bh(&pmlmepriv->scanned_queue.lock); phead = get_list_head(queue); @@ -1502,16 +1493,13 @@ static int rtw_cfg80211_set_probe_req_wpsp2pie(struct rtw_adapter *padapter, #endif struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("%s, ielen =%d\n", __func__, len); -#endif if (len > 0) { wps_ie = rtw_get_wps_ie23a(buf, len, NULL, &wps_ielen); if (wps_ie) { -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("probe_req_wps_ielen =%d\n", wps_ielen); -#endif + if (pmlmepriv->wps_probe_req_ie) { pmlmepriv->wps_probe_req_ie_len = 0; kfree(pmlmepriv->wps_probe_req_ie); @@ -1531,9 +1519,7 @@ static int rtw_cfg80211_set_probe_req_wpsp2pie(struct rtw_adapter *padapter, #ifdef CONFIG_8723AU_P2P p2p_ie = rtw_get_p2p_ie23a(buf, len, NULL, &p2p_ielen); if (p2p_ie) { -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("probe_req_p2p_ielen =%d\n", p2p_ielen); -#endif if (pmlmepriv->p2p_probe_req_ie) { pmlmepriv->p2p_probe_req_ie_len = 0; @@ -1559,9 +1545,7 @@ static int rtw_cfg80211_set_probe_req_wpsp2pie(struct rtw_adapter *padapter, #ifdef CONFIG_8723AU_P2P if (rtw_get_wfd_ie(buf, len, NULL, &wfd_ielen)) { -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("probe_req_wfd_ielen =%d\n", wfd_ielen); -#endif if (pmlmepriv->wfd_probe_req_ie) { pmlmepriv->wfd_probe_req_ie_len = 0; @@ -1605,19 +1589,14 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy, #endif /* CONFIG_8723AU_P2P */ bool need_indicate_scan_done = false; -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A(FUNC_ADPT_FMT "\n", FUNC_ADPT_ARG(padapter)); -#endif spin_lock_bh(&pwdev_priv->scan_req_lock); pwdev_priv->scan_request = request; spin_unlock_bh(&pwdev_priv->scan_req_lock); if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { - -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("%s under WIFI_AP_STATE\n", __func__); -#endif /* need_indicate_scan_done = true; */ /* goto check_need_indicate_scan_done; */ } @@ -1634,11 +1613,9 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy, wdev_to_priv(padapter->rtw_wdev)->p2p_enabled = true; } else { rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("%s, role =%d, p2p_state =%d\n", __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo)); -#endif } rtw_p2p_set_state(pwdinfo, P2P_STATE_LISTEN); @@ -1692,10 +1669,8 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy, memset(ssid, 0, sizeof(struct cfg80211_ssid) * RTW_SSID_SCAN_AMOUNT); /* parsing request ssids, n_ssids */ for (i = 0; i < request->n_ssids && i < RTW_SSID_SCAN_AMOUNT; i++) { -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("ssid =%s, len =%d\n", ssids[i].ssid, ssids[i].ssid_len); -#endif memcpy(ssid[i].ssid, ssids[i].ssid, ssids[i].ssid_len); ssid[i].ssid_len = ssids[i].ssid_len; } @@ -1707,11 +1682,9 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy, if (request->n_channels == 1) { for (i = 0; i < request->n_channels && i < RTW_CHANNEL_SCAN_AMOUNT; i++) { -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A(FUNC_ADPT_FMT CHAN_FMT "\n", FUNC_ADPT_ARG(padapter), CHAN_ARG(request->channels[i])); -#endif ch[i].hw_value = request->channels[i]->hw_value; ch[i].flags = request->channels[i]->flags; } @@ -2036,10 +2009,8 @@ static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie, p2p_ie = rtw_get_p2p_ie23a(buf, ielen, NULL, &p2p_ielen); if (p2p_ie) { -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("%s p2p_assoc_req_ielen =%d\n", __func__, p2p_ielen); -#endif if (pmlmepriv->p2p_assoc_req_ie) { pmlmepriv->p2p_assoc_req_ie_len = 0; @@ -2066,10 +2037,8 @@ static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie, struct mlme_priv *pmlmepriv = &padapter->mlmepriv; if (rtw_get_wfd_ie(buf, ielen, NULL, &wfd_ielen)) { -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("%s wfd_assoc_req_ielen =%d\n", __func__, wfd_ielen); -#endif if (pmlmepriv->wfd_assoc_req_ie) { pmlmepriv->wfd_assoc_req_ie_len = 0; @@ -3616,10 +3585,8 @@ static s32 cfg80211_rtw_remain_on_channel(struct wiphy *wiphy, wdev_to_priv(padapter->rtw_wdev)->p2p_enabled = true; } else { rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("%s, role =%d, p2p_state =%d\n", __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo)); -#endif } rtw_p2p_set_state(pwdinfo, P2P_STATE_LISTEN); @@ -3685,10 +3652,8 @@ static s32 cfg80211_rtw_cancel_remain_on_channel(struct wiphy *wiphy, } rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("%s, role =%d, p2p_state =%d\n", __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo)); -#endif pcfg80211_wdinfo->is_ro_ch = false; return err; @@ -3770,21 +3735,15 @@ static int _cfg80211_rtw_mgmt_tx(struct rtw_adapter *padapter, u8 tx_ch, ack = false; ret = _FAIL; -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("%s, ack == _FAIL\n", __func__); -#endif } else { -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("%s, ack =%d, ok!\n", __func__, ack); -#endif ret = _SUCCESS; } exit: -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("%s, ret =%d\n", __func__, ret); -#endif return ret; } @@ -3823,10 +3782,8 @@ static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, /* cookie generation */ *cookie = (unsigned long)buf; -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A(FUNC_ADPT_FMT " len =%zu, ch =%d" "\n", FUNC_ADPT_ARG(padapter), len, tx_ch); -#endif /* CONFIG_DEBUG_CFG80211 */ /* indicate ack before issue frame to avoid racing with rsp frame */ rtw_cfg80211_mgmt_tx_status(padapter, *cookie, buf, len, ack, @@ -3892,12 +3849,6 @@ static void cfg80211_rtw_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev, u16 frame_type, bool reg) { - -#ifdef CONFIG_DEBUG_CFG80211 - DBG_8723A(FUNC_ADPT_FMT " frame_type:%x, reg:%d\n", - FUNC_ADPT_ARG(adapter), frame_type, reg); -#endif - if (frame_type != (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ)) return; @@ -3927,9 +3878,7 @@ static int rtw_cfg80211_set_beacon_wpsp2pie(struct net_device *ndev, char *buf, if (len > 0) { wps_ie = rtw_get_wps_ie23a(buf, len, NULL, &wps_ielen); if (wps_ie) { -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("bcn_wps_ielen =%d\n", wps_ielen); -#endif if (pmlmepriv->wps_beacon_ie) { pmlmepriv->wps_beacon_ie_len = 0; @@ -3955,9 +3904,7 @@ static int rtw_cfg80211_set_beacon_wpsp2pie(struct net_device *ndev, char *buf, #ifdef CONFIG_8723AU_P2P p2p_ie = rtw_get_p2p_ie23a(buf, len, NULL, &p2p_ielen); if (p2p_ie) { -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("bcn_p2p_ielen =%d\n", p2p_ielen); -#endif if (pmlmepriv->p2p_beacon_ie) { pmlmepriv->p2p_beacon_ie_len = 0; @@ -3983,9 +3930,7 @@ static int rtw_cfg80211_set_beacon_wpsp2pie(struct net_device *ndev, char *buf, #ifdef CONFIG_8723AU_P2P if (rtw_get_wfd_ie(buf, len, NULL, &wfd_ielen)) { -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("bcn_wfd_ielen =%d\n", wfd_ielen); -#endif if (pmlmepriv->wfd_beacon_ie) { pmlmepriv->wfd_beacon_ie_len = 0; @@ -4076,9 +4021,7 @@ static int rtw_cfg80211_set_probe_resp_wpsp2pie(struct net_device *net, u32 attr_contentlen = 0; u16 cap_attr = 0; -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("probe_resp_p2p_ielen =%d\n", p2p_ielen); -#endif /* Check P2P Capability ATTR */ if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, @@ -4142,9 +4085,7 @@ static int rtw_cfg80211_set_probe_resp_wpsp2pie(struct net_device *net, #ifdef CONFIG_8723AU_P2P if (rtw_get_wfd_ie(buf, len, NULL, &wfd_ielen)) { -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("probe_resp_wfd_ielen =%d\n", wfd_ielen); -#endif if (pmlmepriv->wfd_probe_resp_ie) { pmlmepriv->wfd_probe_resp_ie_len = 0; @@ -4208,9 +4149,7 @@ int rtw_cfg80211_set_mgnt_wpsp2pie(struct net_device *net, char *buf, int len, u32 p2p_ielen = 0; #endif -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("%s, ielen =%d\n", __func__, len); -#endif if ((rtw_get_wps_ie23a(buf, len, NULL, &wps_ielen) && (wps_ielen > 0)) #ifdef CONFIG_8723AU_P2P -- cgit v1.2.3 From 810c832f5d9b99cec69b3dcb763c8c35215abf94 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:00 +0200 Subject: staging: rtl8723au: Remove two layers of wrappers around rtw_cfg80211_indicate_scan_done() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 10 +++------- drivers/staging/rtl8723au/include/mlme_osdep.h | 1 - drivers/staging/rtl8723au/include/rtw_mlme.h | 1 - drivers/staging/rtl8723au/os_dep/mlme_linux.c | 6 ------ drivers/staging/rtl8723au/os_dep/usb_intf.c | 3 ++- 5 files changed, 5 insertions(+), 16 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index f72bae42dcb0..8d45c1c841ef 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -959,11 +959,6 @@ void rtw_indicate_disconnect23a(struct rtw_adapter *padapter) } -inline void rtw_indicate_scan_done23a(struct rtw_adapter *padapter, bool aborted) -{ - rtw_os_indicate_scan_done23a(padapter, aborted); -} - void rtw_scan_abort23a(struct rtw_adapter *adapter) { unsigned long start; @@ -985,7 +980,8 @@ void rtw_scan_abort23a(struct rtw_adapter *adapter) if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { if (!adapter->bDriverStopped && !adapter->bSurpriseRemoved) DBG_8723A(FUNC_NDEV_FMT"waiting for scan_abort time out!\n", FUNC_NDEV_ARG(adapter->pnetdev)); - rtw_indicate_scan_done23a(adapter, true); + rtw_cfg80211_indicate_scan_done(wdev_to_priv(adapter->rtw_wdev), + true); } pmlmeext->scan_abort = false; } @@ -1546,7 +1542,7 @@ void rtw_scan_timeout_handler23a(unsigned long data) spin_unlock_bh(&pmlmepriv->lock); - rtw_indicate_scan_done23a(adapter, true); + rtw_cfg80211_indicate_scan_done(wdev_to_priv(adapter->rtw_wdev), true); } static void rtw_auto_scan_handler(struct rtw_adapter *padapter) diff --git a/drivers/staging/rtl8723au/include/mlme_osdep.h b/drivers/staging/rtl8723au/include/mlme_osdep.h index b7132a9a1378..82584dad1864 100644 --- a/drivers/staging/rtl8723au/include/mlme_osdep.h +++ b/drivers/staging/rtl8723au/include/mlme_osdep.h @@ -20,7 +20,6 @@ void rtw_os_indicate_disconnect23a(struct rtw_adapter *adapter); void rtw_os_indicate_connect23a(struct rtw_adapter *adapter); -void rtw_os_indicate_scan_done23a(struct rtw_adapter *padapter, bool aborted); void rtw_report_sec_ie23a(struct rtw_adapter *adapter, u8 authmode, u8 *sec_ie); void rtw_reset_securitypriv23a(struct rtw_adapter *adapter); diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index dac930c77c01..2d4f61b91943 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -553,7 +553,6 @@ void rtw_free_assoc_resources23a(struct rtw_adapter *adapter, int lock_scanned_queue); void rtw_indicate_disconnect23a(struct rtw_adapter *adapter); void rtw_indicate_connect23a(struct rtw_adapter *adapter); -void rtw_indicate_scan_done23a(struct rtw_adapter *padapter, bool aborted); void rtw_scan_abort23a(struct rtw_adapter *adapter); int rtw_restruct_sec_ie23a(struct rtw_adapter *adapter, u8 *in_ie, u8 *out_ie, diff --git a/drivers/staging/rtl8723au/os_dep/mlme_linux.c b/drivers/staging/rtl8723au/os_dep/mlme_linux.c index b30d4d37556a..37ecdb4eba2d 100644 --- a/drivers/staging/rtl8723au/os_dep/mlme_linux.c +++ b/drivers/staging/rtl8723au/os_dep/mlme_linux.c @@ -30,12 +30,6 @@ void rtw_os_indicate_connect23a(struct rtw_adapter *adapter) rtw_signal_process(adapter->pid[2], SIGALRM); } -void rtw_os_indicate_scan_done23a(struct rtw_adapter *padapter, bool aborted) -{ - rtw_cfg80211_indicate_scan_done(wdev_to_priv(padapter->rtw_wdev), - aborted); -} - static struct rt_pmkid_list backupPMKIDList[NUM_PMKID_CACHE]; void rtw_reset_securitypriv23a(struct rtw_adapter *adapter) diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index 612806e0de2e..778508d3a047 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -509,7 +509,8 @@ static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message) up(&pwrpriv->lock); if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) - rtw_indicate_scan_done23a(padapter, 1); + rtw_cfg80211_indicate_scan_done( + wdev_to_priv(padapter->rtw_wdev), true); if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) rtw_indicate_disconnect23a(padapter); -- cgit v1.2.3 From ce16d2f18944f9ba6cafbc73be20803d848adf78 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:01 +0200 Subject: staging: rtl8723au: Don't wrap kill_pid() in an unnecessary macro Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_dm.c | 2 +- drivers/staging/rtl8723au/include/osdep_service.h | 2 -- drivers/staging/rtl8723au/os_dep/mlme_linux.c | 2 +- drivers/staging/rtl8723au/os_dep/usb_intf.c | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_dm.c b/drivers/staging/rtl8723au/hal/rtl8723a_dm.c index b3907ca2e96b..71ee47abcace 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_dm.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_dm.c @@ -76,7 +76,7 @@ static void dm_CheckPbcGPIO(struct rtw_adapter *padapter) return; } - rtw_signal_process(padapter->pid[0], SIGUSR1); + kill_pid(find_vpid(padapter->pid[0]), SIGUSR1, 1); } } diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index 039bc7285ed0..e03d19b84bcb 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -174,8 +174,6 @@ void rtw_unlock_suspend(void); #define FUNC_ADPT_FMT "%s(%s)" #define FUNC_ADPT_ARG(adapter) __func__, adapter->pnetdev->name -#define rtw_signal_process(pid, sig) kill_pid(find_vpid((pid)),(sig), 1) - u64 rtw_modular6423a(u64 x, u64 y); u64 rtw_division6423a(u64 x, u64 y); diff --git a/drivers/staging/rtl8723au/os_dep/mlme_linux.c b/drivers/staging/rtl8723au/os_dep/mlme_linux.c index 37ecdb4eba2d..d07e2203950c 100644 --- a/drivers/staging/rtl8723au/os_dep/mlme_linux.c +++ b/drivers/staging/rtl8723au/os_dep/mlme_linux.c @@ -27,7 +27,7 @@ void rtw_os_indicate_connect23a(struct rtw_adapter *adapter) netif_carrier_on(adapter->pnetdev); if (adapter->pid[2] != 0) - rtw_signal_process(adapter->pid[2], SIGALRM); + kill_pid(find_vpid(adapter->pid[2]), SIGALRM, 1); } static struct rt_pmkid_list backupPMKIDList[NUM_PMKID_CACHE]; diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index 778508d3a047..e6fbe6a62a6b 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -566,7 +566,7 @@ int rtw_resume_process23a(struct rtw_adapter *padapter) if (padapter->pid[1] != 0) { DBG_8723A("pid[1]:%d\n", padapter->pid[1]); - rtw_signal_process(padapter->pid[1], SIGUSR2); + kill_pid(find_vpid(padapter->pid[1]), SIGUSR2, 1); } rtw23a_roaming(padapter, NULL); -- cgit v1.2.3 From 483557be8e63221dfb6d4193085415ba742c47f8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:02 +0200 Subject: staging: rtl8723au: rtw_os_indicate_connect23a() is only called from one place - fold it in Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 7 ++++++- drivers/staging/rtl8723au/include/mlme_osdep.h | 1 - drivers/staging/rtl8723au/os_dep/mlme_linux.c | 10 ---------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 8d45c1c841ef..4846768809c1 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -908,7 +908,12 @@ void rtw_indicate_connect23a(struct rtw_adapter *padapter) rtw_led_control(padapter, LED_CTL_LINK); - rtw_os_indicate_connect23a(padapter); + rtw_cfg80211_indicate_connect(padapter); + + netif_carrier_on(padapter->pnetdev); + + if (padapter->pid[2] != 0) + kill_pid(find_vpid(padapter->pid[2]), SIGALRM, 1); } rtw_set_roaming(padapter, 0); diff --git a/drivers/staging/rtl8723au/include/mlme_osdep.h b/drivers/staging/rtl8723au/include/mlme_osdep.h index 82584dad1864..e2cae3d63527 100644 --- a/drivers/staging/rtl8723au/include/mlme_osdep.h +++ b/drivers/staging/rtl8723au/include/mlme_osdep.h @@ -19,7 +19,6 @@ #include void rtw_os_indicate_disconnect23a(struct rtw_adapter *adapter); -void rtw_os_indicate_connect23a(struct rtw_adapter *adapter); void rtw_report_sec_ie23a(struct rtw_adapter *adapter, u8 authmode, u8 *sec_ie); void rtw_reset_securitypriv23a(struct rtw_adapter *adapter); diff --git a/drivers/staging/rtl8723au/os_dep/mlme_linux.c b/drivers/staging/rtl8723au/os_dep/mlme_linux.c index d07e2203950c..73a54a4ae792 100644 --- a/drivers/staging/rtl8723au/os_dep/mlme_linux.c +++ b/drivers/staging/rtl8723au/os_dep/mlme_linux.c @@ -20,16 +20,6 @@ #include #include -void rtw_os_indicate_connect23a(struct rtw_adapter *adapter) -{ - rtw_cfg80211_indicate_connect(adapter); - - netif_carrier_on(adapter->pnetdev); - - if (adapter->pid[2] != 0) - kill_pid(find_vpid(adapter->pid[2]), SIGALRM, 1); -} - static struct rt_pmkid_list backupPMKIDList[NUM_PMKID_CACHE]; void rtw_reset_securitypriv23a(struct rtw_adapter *adapter) -- cgit v1.2.3 From b319c6a35d0cc9a860946bebe1bd667ebc8aafb2 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:03 +0200 Subject: staging: rtl8723au: Remove unnecessary memset() followed by a memcpy() into the same space Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/mlme_linux.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/mlme_linux.c b/drivers/staging/rtl8723au/os_dep/mlme_linux.c index 73a54a4ae792..ab5550650e21 100644 --- a/drivers/staging/rtl8723au/os_dep/mlme_linux.c +++ b/drivers/staging/rtl8723au/os_dep/mlme_linux.c @@ -36,9 +36,6 @@ void rtw_reset_securitypriv23a(struct rtw_adapter *adapter) * When the countermeasure is trigger, the driver have to * disconnect with AP for 60 seconds. */ - memset(&backupPMKIDList[0], 0x00, sizeof(struct rt_pmkid_list) * - NUM_PMKID_CACHE); - memcpy(&backupPMKIDList[0], &adapter->securitypriv.PMKIDList[0], sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE); backupPMKIDIndex = adapter->securitypriv.PMKIDIndex; -- cgit v1.2.3 From 90102edc28162210694b68a422192017e80fcbfd Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:04 +0200 Subject: staging: rtl8723au: Fix hopeless brackets for declaring a variable mid-function Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/usb_intf.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index e6fbe6a62a6b..dd5899f21388 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -353,6 +353,7 @@ int rtw_hw_suspend23a(struct rtw_adapter *padapter) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; struct net_device *pnetdev = padapter->pnetdev; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; if ((!padapter->bup) || (padapter->bDriverStopped) || (padapter->bSurpriseRemoved)) { @@ -380,20 +381,16 @@ int rtw_hw_suspend23a(struct rtw_adapter *padapter) /* s2-2. indicate disconnect to os */ /* rtw_indicate_disconnect23a(padapter); */ - { - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - if (check_fwstate(pmlmepriv, _FW_LINKED)) { - _clr_fwstate_(pmlmepriv, _FW_LINKED); + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + _clr_fwstate_(pmlmepriv, _FW_LINKED); - rtw_led_control(padapter, LED_CTL_NO_LINK); + rtw_led_control(padapter, LED_CTL_NO_LINK); - rtw_os_indicate_disconnect23a(padapter); + rtw_os_indicate_disconnect23a(padapter); - /* donnot enqueue cmd */ - rtw_lps_ctrl_wk_cmd23a(padapter, - LPS_CTRL_DISCONNECT, 0); - } + /* donnot enqueue cmd */ + rtw_lps_ctrl_wk_cmd23a(padapter, + LPS_CTRL_DISCONNECT, 0); } /* s2-3. */ rtw_free_assoc_resources23a(padapter, 1); -- cgit v1.2.3 From 1eb663227f9aaf886ac0d7db7623462705ad3c69 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:05 +0200 Subject: staging: rtl8723au: Remove unused functions rtw_indicate_sta_{dis,}assoc_event23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtw_ap.h | 2 -- drivers/staging/rtl8723au/os_dep/mlme_linux.c | 46 --------------------------- 2 files changed, 48 deletions(-) diff --git a/drivers/staging/rtl8723au/include/rtw_ap.h b/drivers/staging/rtl8723au/include/rtw_ap.h index 76f82d68f633..7bcadff02ef9 100644 --- a/drivers/staging/rtl8723au/include/rtw_ap.h +++ b/drivers/staging/rtl8723au/include/rtw_ap.h @@ -22,8 +22,6 @@ #ifdef CONFIG_8723AU_AP_MODE /* external function */ -void rtw_indicate_sta_assoc_event23a(struct rtw_adapter *padapter, struct sta_info *psta); -void rtw_indicate_sta_disassoc_event23a(struct rtw_adapter *padapter, struct sta_info *psta); void init_mlme_ap_info23a(struct rtw_adapter *padapter); void free_mlme_ap_info23a(struct rtw_adapter *padapter); diff --git a/drivers/staging/rtl8723au/os_dep/mlme_linux.c b/drivers/staging/rtl8723au/os_dep/mlme_linux.c index ab5550650e21..959c1d1d838a 100644 --- a/drivers/staging/rtl8723au/os_dep/mlme_linux.c +++ b/drivers/staging/rtl8723au/os_dep/mlme_linux.c @@ -120,49 +120,3 @@ void rtw_report_sec_ie23a(struct rtw_adapter *adapter, u8 authmode, u8 *sec_ie) kfree(buff); } } - -#ifdef CONFIG_8723AU_AP_MODE -void rtw_indicate_sta_assoc_event23a(struct rtw_adapter *padapter, - struct sta_info *psta) -{ - struct sta_priv *pstapriv = &padapter->stapriv; - union iwreq_data wrqu; - - if (psta == NULL) - return; - - if (psta->aid > NUM_STA) - return; - - if (pstapriv->sta_aid[psta->aid - 1] != psta) - return; - - wrqu.addr.sa_family = ARPHRD_ETHER; - - memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN); - - DBG_8723A("+rtw_indicate_sta_assoc_event23a\n"); -} - -void rtw_indicate_sta_disassoc_event23a(struct rtw_adapter *padapter, - struct sta_info *psta) -{ - struct sta_priv *pstapriv = &padapter->stapriv; - union iwreq_data wrqu; - - if (psta == NULL) - return; - - if (psta->aid > NUM_STA) - return; - - if (pstapriv->sta_aid[psta->aid - 1] != psta) - return; - - wrqu.addr.sa_family = ARPHRD_ETHER; - - memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN); - - DBG_8723A("+rtw_indicate_sta_disassoc_event23a\n"); -} -#endif -- cgit v1.2.3 From 814a1d900e4a31f0205bbba0d8a6c0fedac70aae Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:06 +0200 Subject: staging: rtl8723au: rtw_report_sec_ie23a() is only called from rtw_mlme.c Move it there and declare it static Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 46 ++++++++++++++++++++++++-- drivers/staging/rtl8723au/include/mlme_osdep.h | 2 -- drivers/staging/rtl8723au/os_dep/mlme_linux.c | 40 ---------------------- 3 files changed, 44 insertions(+), 44 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 4846768809c1..1060a9fab64f 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -2002,6 +2002,48 @@ static int rtw_append_pmkid(struct rtw_adapter *Adapter, int iEntry, } return ie_len; } + +static void +_rtw_report_sec_ie(struct rtw_adapter *adapter, u8 authmode, u8 *sec_ie) +{ + uint len; + u8 *buff, *p, i; + union iwreq_data wrqu; + + RT_TRACE(_module_mlme_osdep_c_, _drv_info_, + ("+_rtw_report_sec_ie, authmode =%d\n", authmode)); + + buff = NULL; + if (authmode == _WPA_IE_ID_) { + RT_TRACE(_module_mlme_osdep_c_, _drv_info_, + ("_rtw_report_sec_ie, authmode =%d\n", authmode)); + + buff = kzalloc(IW_CUSTOM_MAX, GFP_KERNEL); + if (!buff) + return; + p = buff; + + p += sprintf(p, "ASSOCINFO(ReqIEs ="); + + len = sec_ie[1]+2; + len = (len < IW_CUSTOM_MAX) ? len : IW_CUSTOM_MAX; + + for (i = 0; i < len; i++) + p += sprintf(p, "%02x", sec_ie[i]); + + p += sprintf(p, ")"); + + memset(&wrqu, 0, sizeof(wrqu)); + + wrqu.data.length = p-buff; + + wrqu.data.length = (wrqu.data.length < IW_CUSTOM_MAX) ? + wrqu.data.length : IW_CUSTOM_MAX; + + kfree(buff); + } +} + int rtw_restruct_sec_ie23a(struct rtw_adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len) { @@ -2037,8 +2079,8 @@ int rtw_restruct_sec_ie23a(struct rtw_adapter *adapter, u8 *in_ie, u8 *out_ie, memcpy(&out_ie[ielength], &psecuritypriv->supplicant_ie[0], psecuritypriv->supplicant_ie[1] + 2); ielength += psecuritypriv->supplicant_ie[1] + 2; - rtw_report_sec_ie23a(adapter, authmode, - psecuritypriv->supplicant_ie); + _rtw_report_sec_ie(adapter, authmode, + psecuritypriv->supplicant_ie); } iEntry = SecIsInPMKIDList(adapter, pmlmepriv->assoc_bssid); diff --git a/drivers/staging/rtl8723au/include/mlme_osdep.h b/drivers/staging/rtl8723au/include/mlme_osdep.h index e2cae3d63527..4bb5525b7a68 100644 --- a/drivers/staging/rtl8723au/include/mlme_osdep.h +++ b/drivers/staging/rtl8723au/include/mlme_osdep.h @@ -19,8 +19,6 @@ #include void rtw_os_indicate_disconnect23a(struct rtw_adapter *adapter); -void rtw_report_sec_ie23a(struct rtw_adapter *adapter, u8 authmode, u8 *sec_ie); - void rtw_reset_securitypriv23a(struct rtw_adapter *adapter); #endif /* _MLME_OSDEP_H_ */ diff --git a/drivers/staging/rtl8723au/os_dep/mlme_linux.c b/drivers/staging/rtl8723au/os_dep/mlme_linux.c index 959c1d1d838a..c0e79f56d2eb 100644 --- a/drivers/staging/rtl8723au/os_dep/mlme_linux.c +++ b/drivers/staging/rtl8723au/os_dep/mlme_linux.c @@ -80,43 +80,3 @@ void rtw_os_indicate_disconnect23a(struct rtw_adapter *adapter) rtw_reset_securitypriv23a(adapter); } - -void rtw_report_sec_ie23a(struct rtw_adapter *adapter, u8 authmode, u8 *sec_ie) -{ - uint len; - u8 *buff, *p, i; - union iwreq_data wrqu; - - RT_TRACE(_module_mlme_osdep_c_, _drv_info_, - ("+rtw_report_sec_ie23a, authmode =%d\n", authmode)); - - buff = NULL; - if (authmode == _WPA_IE_ID_) { - RT_TRACE(_module_mlme_osdep_c_, _drv_info_, - ("rtw_report_sec_ie23a, authmode =%d\n", authmode)); - - buff = kzalloc(IW_CUSTOM_MAX, GFP_KERNEL); - if (!buff) - return; - p = buff; - - p += sprintf(p, "ASSOCINFO(ReqIEs ="); - - len = sec_ie[1]+2; - len = (len < IW_CUSTOM_MAX) ? len : IW_CUSTOM_MAX; - - for (i = 0; i < len; i++) - p += sprintf(p, "%02x", sec_ie[i]); - - p += sprintf(p, ")"); - - memset(&wrqu, 0, sizeof(wrqu)); - - wrqu.data.length = p-buff; - - wrqu.data.length = (wrqu.data.length < IW_CUSTOM_MAX) ? - wrqu.data.length : IW_CUSTOM_MAX; - - kfree(buff); - } -} -- cgit v1.2.3 From 41ed2cb92e3a9b4591f5ca76bd28fe0d0f3d4cc7 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:07 +0200 Subject: staging: rtl8723au: Remove last remnants of CONFIG_BR_EXT Reported-by: Paul Bolle Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/drv_types.h | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/staging/rtl8723au/include/drv_types.h b/drivers/staging/rtl8723au/include/drv_types.h index 53eecea48cec..14c7f2e915e0 100644 --- a/drivers/staging/rtl8723au/include/drv_types.h +++ b/drivers/staging/rtl8723au/include/drv_types.h @@ -327,21 +327,6 @@ struct rtw_adapter { /* IFACE_ID1 is equals to SECONDARY_ADAPTER */ u8 iface_id; -#ifdef CONFIG_BR_EXT - _lock br_ext_lock; - /* unsigned int macclone_completed; */ - struct nat25_network_db_entry *nethash[NAT25_HASH_SIZE]; - int pppoe_connection_in_progress; - unsigned char pppoe_addr[MACADDRLEN]; - unsigned char scdb_mac[MACADDRLEN]; - unsigned char scdb_ip[4]; - struct nat25_network_db_entry *scdb_entry; - unsigned char br_mac[MACADDRLEN]; - unsigned char br_ip[4]; - - struct br_ext_info ethBrExtInfo; -#endif /* CONFIG_BR_EXT */ - u8 fix_rate; unsigned char in_cta_test; -- cgit v1.2.3 From f4f1cb92ae7966a6c65237beabb541af655ff9d9 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:08 +0200 Subject: staging: rtl8723au: Fold rtw_remainder_len23a() into _rtw_open_pktfile23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/xmit_osdep.h | 1 - drivers/staging/rtl8723au/os_dep/xmit_linux.c | 9 ++------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723au/include/xmit_osdep.h b/drivers/staging/rtl8723au/include/xmit_osdep.h index 0eca53ece75d..b94e5467c408 100644 --- a/drivers/staging/rtl8723au/include/xmit_osdep.h +++ b/drivers/staging/rtl8723au/include/xmit_osdep.h @@ -44,7 +44,6 @@ int rtw_os_xmit_resource_alloc23a(struct rtw_adapter *padapter, struct xmit_buf *pxmitbuf, u32 alloc_sz); void rtw_os_xmit_resource_free23a(struct rtw_adapter *padapter, struct xmit_buf *pxmitbuf); -uint rtw_remainder_len23a(struct pkt_file *pfile); void _rtw_open_pktfile23a(struct sk_buff *pkt, struct pkt_file *pfile); uint _rtw_pktfile_read23a(struct pkt_file *pfile, u8 *rmem, uint rlen); int rtw_endofpktfile23a(struct pkt_file *pfile); diff --git a/drivers/staging/rtl8723au/os_dep/xmit_linux.c b/drivers/staging/rtl8723au/os_dep/xmit_linux.c index e1c6fc746233..3cf539a2dd0f 100644 --- a/drivers/staging/rtl8723au/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8723au/os_dep/xmit_linux.c @@ -24,12 +24,6 @@ #include #include -uint rtw_remainder_len23a(struct pkt_file *pfile) -{ - return pfile->buf_len - ((unsigned long)(pfile->cur_addr) - - (unsigned long)(pfile->buf_start)); -} - void _rtw_open_pktfile23a(struct sk_buff *pktptr, struct pkt_file *pfile) { pfile->pkt = pktptr; @@ -45,7 +39,8 @@ uint _rtw_pktfile_read23a(struct pkt_file *pfile, u8 *rmem, uint rlen) { uint len = 0; - len = rtw_remainder_len23a(pfile); + len = pfile->buf_len - ((unsigned long)(pfile->cur_addr) - + (unsigned long)(pfile->buf_start)); len = (rlen > len) ? len : rlen; if (rmem) -- cgit v1.2.3 From 3483b8ae77ce81130dd379417131f8687e4a24d9 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:09 +0200 Subject: staging: rtl8723au: Use proper ETH_P_* types instead of hard coded constants in rtw_xmit.c Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 0f10cfa10d39..6fcf4e29cb3c 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -453,11 +453,11 @@ static void set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib) _rtw_pktfile_read23a(ppktfile, (unsigned char*)ðerhdr, ETH_HLEN); /* get UserPriority from IP hdr */ - if (pattrib->ether_type == 0x0800) { + if (pattrib->ether_type == ETH_P_IP) { _rtw_pktfile_read23a(ppktfile, (u8*)&ip_hdr, sizeof(ip_hdr)); /* UserPriority = (ntohs(ip_hdr.tos) >> 5) & 0x3; */ UserPriority = ip_hdr.tos >> 5; - } else if (pattrib->ether_type == 0x888e) { + } else if (pattrib->ether_type == ETH_P_PAE) { /* "When priority processing of data frames is supported, */ /* a STA's SME should send EAPOL-Key frames at the highest priority." */ @@ -518,7 +518,7 @@ static s32 update_attrib(struct rtw_adapter *padapter, _rtw_pktfile_read23a(&pktfile, &tmp[0], 24); pattrib->dhcp_pkt = 0; if (pktfile.pkt_len > 282) {/* MINIMUM_DHCP_PACKET_SIZE) { */ - if (ETH_P_IP == pattrib->ether_type) {/* IP header */ + if (pattrib->ether_type == ETH_P_IP) {/* IP header */ if (((tmp[21] == 68) && (tmp[23] == 67)) || ((tmp[21] == 67) && (tmp[23] == 68))) { /* 68 : UDP BOOTP client */ @@ -532,17 +532,17 @@ static s32 update_attrib(struct rtw_adapter *padapter, } } } - } else if (0x888e == pattrib->ether_type) { + } else if (pattrib->ether_type == ETH_P_PAE) { DBG_8723A_LEVEL(_drv_always_, "send eapol packet\n"); } - if ((pattrib->ether_type == 0x888e) || (pattrib->dhcp_pkt == 1)) { + if ((pattrib->ether_type == ETH_P_PAE) || (pattrib->dhcp_pkt == 1)) { rtw_set_scan_deny(padapter, 3000); } /* If EAPOL , ARP , OR DHCP packet, driver must be in active mode. */ - if ((pattrib->ether_type == 0x0806) || - (pattrib->ether_type == 0x888e) || (pattrib->dhcp_pkt == 1)) { + if ((pattrib->ether_type == ETH_P_ARP) || + (pattrib->ether_type == ETH_P_PAE) || (pattrib->dhcp_pkt == 1)) { rtw_lps_ctrl_wk_cmd23a(padapter, LPS_CTRL_SPECIAL_PACKET, 1); } @@ -610,7 +610,7 @@ static s32 update_attrib(struct rtw_adapter *padapter, pattrib->encrypt = 0; - if ((pattrib->ether_type != 0x888e) && + if ((pattrib->ether_type != ETH_P_PAE) && (check_fwstate(pmlmepriv, WIFI_MP_STATE) == false)) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("\npsta->ieee8021x_blocked == true, " -- cgit v1.2.3 From e59cb424d76440275f3667a3a173b9e6e81bb363 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:10 +0200 Subject: staging: rtl8723au: Fix update_attrib() and set_qos() to not use pktfile nonsense Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 60 ++++++++++++++----------------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 6fcf4e29cb3c..2fba6815455f 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -443,20 +443,16 @@ u8 qos_acm23a(u8 acm_mask, u8 priority) return change_priority; } -static void set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib) +static void set_qos(struct sk_buff *skb, struct pkt_attrib *pattrib) { - struct ethhdr etherhdr; - struct iphdr ip_hdr; + u8 *pframe = skb->data; + struct iphdr *ip_hdr; s32 UserPriority = 0; - _rtw_open_pktfile23a(ppktfile->pkt, ppktfile); - _rtw_pktfile_read23a(ppktfile, (unsigned char*)ðerhdr, ETH_HLEN); - /* get UserPriority from IP hdr */ if (pattrib->ether_type == ETH_P_IP) { - _rtw_pktfile_read23a(ppktfile, (u8*)&ip_hdr, sizeof(ip_hdr)); -/* UserPriority = (ntohs(ip_hdr.tos) >> 5) & 0x3; */ - UserPriority = ip_hdr.tos >> 5; + ip_hdr = (struct iphdr *)(pframe + ETH_HLEN); + UserPriority = ip_hdr->tos >> 5; } else if (pattrib->ether_type == ETH_P_PAE) { /* "When priority processing of data frames is supported, */ /* a STA's SME should send EAPOL-Key frames at the highest @@ -470,57 +466,53 @@ static void set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib) } static s32 update_attrib(struct rtw_adapter *padapter, - struct sk_buff *pkt, struct pkt_attrib *pattrib) + struct sk_buff *skb, struct pkt_attrib *pattrib) { - uint i; - struct pkt_file pktfile; struct sta_info *psta = NULL; - struct ethhdr etherhdr; - int bmcast; struct sta_priv *pstapriv = &padapter->stapriv; struct security_priv *psecuritypriv = &padapter->securitypriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct qos_priv *pqospriv = &pmlmepriv->qospriv; int res = _SUCCESS; + struct ethhdr *ehdr = (struct ethhdr *) skb->data; - _rtw_open_pktfile23a(pkt, &pktfile); - i = _rtw_pktfile_read23a(&pktfile, (u8*)ðerhdr, ETH_HLEN); - - pattrib->ether_type = ntohs(etherhdr.h_proto); + pattrib->ether_type = ntohs(ehdr->h_proto); - memcpy(pattrib->dst, ðerhdr.h_dest, ETH_ALEN); - memcpy(pattrib->src, ðerhdr.h_source, ETH_ALEN); + ether_addr_copy(pattrib->dst, ehdr->h_dest); + ether_addr_copy(pattrib->src, ehdr->h_source); pattrib->pctrl = 0; if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) || (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) { - memcpy(pattrib->ra, pattrib->dst, ETH_ALEN); - memcpy(pattrib->ta, pattrib->src, ETH_ALEN); + ether_addr_copy(pattrib->ra, pattrib->dst); + ether_addr_copy(pattrib->ta, pattrib->src); } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { - memcpy(pattrib->ra, get_bssid(pmlmepriv), ETH_ALEN); - memcpy(pattrib->ta, pattrib->src, ETH_ALEN); + ether_addr_copy(pattrib->ra, get_bssid(pmlmepriv)); + ether_addr_copy(pattrib->ta, pattrib->src); } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { - memcpy(pattrib->ra, pattrib->dst, ETH_ALEN); - memcpy(pattrib->ta, get_bssid(pmlmepriv), ETH_ALEN); + ether_addr_copy(pattrib->ra, pattrib->dst); + ether_addr_copy(pattrib->ta, get_bssid(pmlmepriv)); } - pattrib->pktlen = pktfile.pkt_len; + pattrib->pktlen = skb->len - ETH_HLEN; if (pattrib->ether_type == ETH_P_IP) { /* The following is for DHCP and ARP packet, we use cck1M to tx these packets and let LPS awake some time */ /* to prevent DHCP protocol fail */ - u8 tmp[24]; - _rtw_pktfile_read23a(&pktfile, &tmp[0], 24); pattrib->dhcp_pkt = 0; - if (pktfile.pkt_len > 282) {/* MINIMUM_DHCP_PACKET_SIZE) { */ + /* MINIMUM_DHCP_PACKET_SIZE) { */ + if (pattrib->pktlen > 282 + 24) { if (pattrib->ether_type == ETH_P_IP) {/* IP header */ - if (((tmp[21] == 68) && (tmp[23] == 67)) || - ((tmp[21] == 67) && (tmp[23] == 68))) { + u8 *pframe = skb->data; + pframe += ETH_HLEN; + + if ((pframe[21] == 68 && pframe[23] == 67) || + (pframe[21] == 67 && pframe[23] == 68)) { /* 68 : UDP BOOTP client */ /* 67 : UDP BOOTP server */ RT_TRACE(_module_rtl871x_xmit_c_, @@ -592,10 +584,10 @@ static s32 update_attrib(struct rtw_adapter *padapter, if (check_fwstate(pmlmepriv, WIFI_AP_STATE | WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE)) { if (psta->qos_option) - set_qos(&pktfile, pattrib); + set_qos(skb, pattrib); } else { if (pqospriv->qos_option) { - set_qos(&pktfile, pattrib); + set_qos(skb, pattrib); if (pmlmepriv->acm_mask != 0) { pattrib->priority = qos_acm23a(pmlmepriv->acm_mask, -- cgit v1.2.3 From 69a0f9745c963de5ea1e42cdb8370913248c4872 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:11 +0200 Subject: staging: rtl8723au: Make rtw_xmitframe_coalesce23a() more readable Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 56 +++++++++++++++++++------------ 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 2fba6815455f..7ab436b0c88d 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -1112,9 +1112,9 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt, struct xmit_frame *pxmitframe) { struct pkt_file pktfile; - struct sta_info *psta; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct pkt_attrib *pattrib = &pxmitframe->attrib; + struct sta_info *psta; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct pkt_attrib *pattrib = &pxmitframe->attrib; s32 frg_inx, frg_len, mpdu_len, llc_sz, mem_sz; u8 *pframe, *mem_start; u8 hw_hdr_offset; @@ -1123,24 +1123,25 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt, s32 bmcst = is_multicast_ether_addr(pattrib->ra); s32 res = _SUCCESS; - if (pattrib->psta) { + if (pattrib->psta) psta = pattrib->psta; - } else { + else { DBG_8723A("%s, call rtw_get_stainfo23a()\n", __func__); psta = rtw_get_stainfo23a(&padapter->stapriv, pattrib->ra); } - if (psta == NULL) { + if (!psta) { DBG_8723A("%s, psta == NUL\n", __func__); return _FAIL; } if (!(psta->state &_FW_LINKED)) { - DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, psta->state); + DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n", + __func__, psta->state); return _FAIL; } - if (pxmitframe->buf_addr == NULL) { + if (!pxmitframe->buf_addr) { DBG_8723A("==> %s buf_addr == NULL\n", __func__); return _FAIL; } @@ -1149,7 +1150,7 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt, hw_hdr_offset = TXDESC_OFFSET; - mem_start = pbuf_start + hw_hdr_offset; + mem_start = pbuf_start + hw_hdr_offset; if (rtw_make_wlanhdr23a(padapter, mem_start, pattrib) == _FAIL) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, @@ -1179,23 +1180,30 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt, /* adding icv, if necessary... */ if (pattrib->iv_len) { - if (psta != NULL) { + if (psta) { switch (pattrib->encrypt) { case _WEP40_: case _WEP104_: - WEP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); + WEP_IV(pattrib->iv, psta->dot11txpn, + pattrib->key_idx); break; case _TKIP_: if (bmcst) - TKIP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); + TKIP_IV(pattrib->iv, + psta->dot11txpn, + pattrib->key_idx); else - TKIP_IV(pattrib->iv, psta->dot11txpn, 0); + TKIP_IV(pattrib->iv, + psta->dot11txpn, 0); break; case _AES_: if (bmcst) - AES_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); + AES_IV(pattrib->iv, + psta->dot11txpn, + pattrib->key_idx); else - AES_IV(pattrib->iv, psta->dot11txpn, 0); + AES_IV(pattrib->iv, + psta->dot11txpn, 0); break; } } @@ -1217,14 +1225,16 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt, mpdu_len -= llc_sz; } - if ((pattrib->icv_len >0) && (pattrib->bswenc)) + if (pattrib->icv_len > 0 && pattrib->bswenc) mpdu_len -= pattrib->icv_len; if (bmcst) { /* don't do fragment to broadcat/multicast packets */ - mem_sz = _rtw_pktfile_read23a(&pktfile, pframe, pattrib->pktlen); + mem_sz = _rtw_pktfile_read23a(&pktfile, pframe, + pattrib->pktlen); } else { - mem_sz = _rtw_pktfile_read23a(&pktfile, pframe, mpdu_len); + mem_sz = _rtw_pktfile_read23a(&pktfile, pframe, + mpdu_len); } pframe += mem_sz; @@ -1235,7 +1245,7 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt, frg_inx++; - if (bmcst || (rtw_endofpktfile23a(&pktfile))) { + if (bmcst || rtw_endofpktfile23a(&pktfile)) { pattrib->nr_frags = frg_inx; pattrib->last_txcmdsz = pattrib->hdrlen + @@ -1249,16 +1259,18 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt, break; } else { - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("%s: There're still something in packet!\n", __func__)); + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, + ("%s: There're still something in packet!\n", + __func__)); } mem_start = PTR_ALIGN(pframe, 4) + hw_hdr_offset; memcpy(mem_start, pbuf_start + hw_hdr_offset, pattrib->hdrlen); - } if (xmitframe_addmic(padapter, pxmitframe) == _FAIL) { - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic(padapter, pxmitframe) == _FAIL\n")); + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, + ("xmitframe_addmic(padapter, pxmitframe) == _FAIL\n")); DBG_8723A("xmitframe_addmic(padapter, pxmitframe) == _FAIL\n"); res = _FAIL; goto exit; -- cgit v1.2.3 From 3e689a9ff53952aad8aca5bd7d01c09268e8deea Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:12 +0200 Subject: staging: rtl8723au: Don't use pktfile interface in rtw_xmitframe_coalesce23a() The pktfil interface is horrible, no idea where it came from, but not using it is a win. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 7ab436b0c88d..c0e2d7607b72 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -1108,10 +1108,9 @@ This sub-routine will perform all the following: 6. apply sw-encrypt, if necessary. */ -s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt, +s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *skb, struct xmit_frame *pxmitframe) { - struct pkt_file pktfile; struct sta_info *psta; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct pkt_attrib *pattrib = &pxmitframe->attrib; @@ -1119,7 +1118,8 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt, u8 *pframe, *mem_start; u8 hw_hdr_offset; u8 *pbuf_start; - + u8 *pdata = skb->data; + int data_len = skb->len; s32 bmcst = is_multicast_ether_addr(pattrib->ra); s32 res = _SUCCESS; @@ -1160,8 +1160,8 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt, goto exit; } - _rtw_open_pktfile23a(pkt, &pktfile); - _rtw_pktfile_read23a(&pktfile, NULL, pattrib->pkt_hdrlen); + pdata += pattrib->pkt_hdrlen; + data_len -= pattrib->pkt_hdrlen; frg_inx = 0; frg_len = pxmitpriv->frag_len - 4;/* 2346-4 = 2342 */ @@ -1228,15 +1228,17 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt, if (pattrib->icv_len > 0 && pattrib->bswenc) mpdu_len -= pattrib->icv_len; - if (bmcst) { + if (bmcst) /* don't do fragment to broadcat/multicast packets */ - mem_sz = _rtw_pktfile_read23a(&pktfile, pframe, - pattrib->pktlen); - } else { - mem_sz = _rtw_pktfile_read23a(&pktfile, pframe, - mpdu_len); - } + mem_sz = min_t(s32, data_len, pattrib->pktlen); + else + mem_sz = min_t(s32, data_len, mpdu_len); + + memcpy(pframe, pdata, mem_sz); + pframe += mem_sz; + pdata += mem_sz; + data_len -= mem_sz; if ((pattrib->icv_len >0) && (pattrib->bswenc)) { memcpy(pframe, pattrib->icv, pattrib->icv_len); @@ -1245,7 +1247,7 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt, frg_inx++; - if (bmcst || rtw_endofpktfile23a(&pktfile)) { + if (bmcst || data_len <= 0) { pattrib->nr_frags = frg_inx; pattrib->last_txcmdsz = pattrib->hdrlen + -- cgit v1.2.3 From 4c9c5700d6719f2e7b45e1c71fdfbc88b5ce44d5 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:13 +0200 Subject: staging: rtl8723au: Remove ugly pktfile interface Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/xmit_osdep.h | 12 --------- drivers/staging/rtl8723au/os_dep/xmit_linux.c | 36 -------------------------- 2 files changed, 48 deletions(-) diff --git a/drivers/staging/rtl8723au/include/xmit_osdep.h b/drivers/staging/rtl8723au/include/xmit_osdep.h index b94e5467c408..9740ef6d96f9 100644 --- a/drivers/staging/rtl8723au/include/xmit_osdep.h +++ b/drivers/staging/rtl8723au/include/xmit_osdep.h @@ -18,15 +18,6 @@ #include #include -struct pkt_file { - struct sk_buff *pkt; - __kernel_size_t pkt_len; /* the remainder length of the open_file */ - unsigned char *cur_buffer; - u8 *buf_start; - u8 *cur_addr; - __kernel_size_t buf_len; -}; - #define NR_XMITFRAME 256 @@ -44,9 +35,6 @@ int rtw_os_xmit_resource_alloc23a(struct rtw_adapter *padapter, struct xmit_buf *pxmitbuf, u32 alloc_sz); void rtw_os_xmit_resource_free23a(struct rtw_adapter *padapter, struct xmit_buf *pxmitbuf); -void _rtw_open_pktfile23a(struct sk_buff *pkt, struct pkt_file *pfile); -uint _rtw_pktfile_read23a(struct pkt_file *pfile, u8 *rmem, uint rlen); -int rtw_endofpktfile23a(struct pkt_file *pfile); void rtw_os_pkt_complete23a(struct rtw_adapter *padapter, struct sk_buff *pkt); void rtw_os_xmit_complete23a(struct rtw_adapter *padapter, diff --git a/drivers/staging/rtl8723au/os_dep/xmit_linux.c b/drivers/staging/rtl8723au/os_dep/xmit_linux.c index 3cf539a2dd0f..69f88848715a 100644 --- a/drivers/staging/rtl8723au/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8723au/os_dep/xmit_linux.c @@ -24,42 +24,6 @@ #include #include -void _rtw_open_pktfile23a(struct sk_buff *pktptr, struct pkt_file *pfile) -{ - pfile->pkt = pktptr; - pfile->buf_start = pktptr->data; - pfile->cur_addr = pktptr->data; - pfile->buf_len = pktptr->len; - pfile->pkt_len = pktptr->len; - - pfile->cur_buffer = pfile->buf_start; -} - -uint _rtw_pktfile_read23a(struct pkt_file *pfile, u8 *rmem, uint rlen) -{ - uint len = 0; - - len = pfile->buf_len - ((unsigned long)(pfile->cur_addr) - - (unsigned long)(pfile->buf_start)); - len = (rlen > len) ? len : rlen; - - if (rmem) - skb_copy_bits(pfile->pkt, pfile->buf_len-pfile->pkt_len, - rmem, len); - - pfile->cur_addr += len; - pfile->pkt_len -= len; - - return len; -} - -int rtw_endofpktfile23a(struct pkt_file *pfile) -{ - if (pfile->pkt_len == 0) - return true; - return false; -} - int rtw_os_xmit_resource_alloc23a(struct rtw_adapter *padapter, struct xmit_buf *pxmitbuf, u32 alloc_sz) { -- cgit v1.2.3 From 458dc03913b77501f069b268198d0751b8837e46 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:14 +0200 Subject: staging: rtl8723au: Remove unnecessary forward struct declarations from xmit_osdep.h Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/xmit_osdep.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8723au/include/xmit_osdep.h b/drivers/staging/rtl8723au/include/xmit_osdep.h index 9740ef6d96f9..2be04c48656c 100644 --- a/drivers/staging/rtl8723au/include/xmit_osdep.h +++ b/drivers/staging/rtl8723au/include/xmit_osdep.h @@ -21,12 +21,6 @@ #define NR_XMITFRAME 256 -struct xmit_priv; -struct pkt_attrib; -struct sta_xmit_priv; -struct xmit_frame; -struct xmit_buf; - int rtw_xmit23a_entry23a(struct sk_buff *pkt, struct net_device *pnetdev); void rtw_os_xmit_schedule23a(struct rtw_adapter *padapter); -- cgit v1.2.3 From 8000d1c413059c7d6b84bc57610353b2b546d74d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:15 +0200 Subject: staging: rtl8723au: No need to include header files for unused circ_buf and old iwpriv bits Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/osdep_service.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index e03d19b84bcb..a2cc21cd318b 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -40,7 +39,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3 From 9cd81fa609eaa23c95817f2afeb516c24a9c3001 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:16 +0200 Subject: staging: rtl8723au: Remove a couple of unused prototypes Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/osdep_service.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index a2cc21cd318b..c5fb356d6be2 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -195,9 +195,7 @@ bool rtw_cbuf_push23a(struct rtw_cbuf *cbuf, void *buf); void *rtw_cbuf_pop23a(struct rtw_cbuf *cbuf); struct rtw_cbuf *rtw_cbuf_alloc23a(u32 size); void rtw_cbuf_free(struct rtw_cbuf *cbuf); -int rtw_change_ifname(struct rtw_adapter *padapter, const char *ifname); s32 c2h_evt_hdl(struct rtw_adapter *adapter, struct c2h_evt_hdr *c2h_evt, c2h_id_filter filter); -void indicate_wx_scan_complete_event(struct rtw_adapter *padapter); u8 rtw_do_join23a(struct rtw_adapter *padapter); #endif -- cgit v1.2.3 From 6484767b93e3cb81b0e70dc3c877f5d721e89c27 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:17 +0200 Subject: staging: rtl8723au: Remove unused bitshift() function Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/osdep_service.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index c5fb356d6be2..6b7d7aa464fd 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -147,16 +147,6 @@ extern unsigned char MCS_rate_1R23A[16]; void _rtw_init_queue23a(struct rtw_queue *pqueue); u32 _rtw_queue_empty23a(struct rtw_queue *pqueue); -static inline u32 bitshift(u32 bitmask) -{ - u32 i; - - for (i = 0; i <= 31; i++) - if (((bitmask>>i) & 0x1) == 1) break; - - return i; -} - void rtw_suspend_lock_init(void); void rtw_suspend_lock_uninit(void); void rtw_lock_suspend(void); -- cgit v1.2.3 From 88cdc943c5d8fc5e5920c20a275ec1759fd8e6fd Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 9 Apr 2014 23:21:18 +0200 Subject: staging: rtl8723au: Fix build error due to bad commit 6c89f82 Two routines are missing includes of a necessary header. Signed-off-by: Larry Finger Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 1 + drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 2c558e0dd12b..592f0ee274e4 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -19,6 +19,7 @@ #include #include #include +#include #ifdef CONFIG_8723AU_BT_COEXIST #include diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index 07c63246ca31..c14b8193ce02 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -17,6 +17,7 @@ #include #include #include +#include #ifdef CONFIG_8723AU_BT_COEXIST #include -- cgit v1.2.3 From f4337aa31d67202f8d9db84ec43f2270b8878cd5 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:19 +0200 Subject: staging: rtl8723au: Call do_div() directly and get rid of unnecessary wrapper functions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 4 ++-- drivers/staging/rtl8723au/include/osdep_service.h | 4 ---- drivers/staging/rtl8723au/os_dep/osdep_service.c | 11 ----------- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 8ea00ba851a2..0a86923e7def 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3031,8 +3031,8 @@ void hw_var_set_correct_tsf(struct rtw_adapter *padapter) /* tsf = pmlmeext->TSFValue - ((u32)pmlmeext->TSFValue % (pmlmeinfo->bcn_interval*1024)) - 1024; us */ tsf = pmlmeext->TSFValue - - rtw_modular6423a(pmlmeext->TSFValue, - (pmlmeinfo->bcn_interval * 1024)) - 1024; /* us */ + do_div(pmlmeext->TSFValue, + (pmlmeinfo->bcn_interval * 1024)) - 1024; /* us */ if (((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)) { diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index 6b7d7aa464fd..92c954eb2179 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -162,10 +162,6 @@ void rtw_unlock_suspend(void); #define FUNC_ADPT_FMT "%s(%s)" #define FUNC_ADPT_ARG(adapter) __func__, adapter->pnetdev->name -u64 rtw_modular6423a(u64 x, u64 y); -u64 rtw_division6423a(u64 x, u64 y); - - /* Macros for handling unaligned memory accesses */ #define RTW_GET_BE24(a) ((((u32) (a)[0]) << 16) | (((u32) (a)[1]) << 8) | \ diff --git a/drivers/staging/rtl8723au/os_dep/osdep_service.c b/drivers/staging/rtl8723au/os_dep/osdep_service.c index 97fc27dce19c..b89e779fa045 100644 --- a/drivers/staging/rtl8723au/os_dep/osdep_service.c +++ b/drivers/staging/rtl8723au/os_dep/osdep_service.c @@ -71,17 +71,6 @@ u32 _rtw_queue_empty23a(struct rtw_queue *pqueue) return false; } -u64 rtw_modular6423a(u64 x, u64 y) -{ - return do_div(x, y); -} - -u64 rtw_division6423a(u64 x, u64 y) -{ - do_div(x, y); - return x; -} - /* rtw_cbuf_full23a - test if cbuf is full * @cbuf: pointer of struct rtw_cbuf * -- cgit v1.2.3 From 7dd1e720256ebd5628fb9e9193d95eacaeb42b27 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:20 +0200 Subject: staging: rtl8723au: Use proper ETH_P_* types in rtw_recv.c Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_recv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 0b2455e4f5b6..8ae191654a42 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -576,7 +576,7 @@ static struct recv_frame *portctrl(struct rtw_adapter *adapter, struct sta_priv *pstapriv ; struct recv_frame *prtnframe; u16 ether_type = 0; - u16 eapol_type = 0x888e;/* for Funia BD's WPA issue */ + u16 eapol_type = ETH_P_PAE;/* for Funia BD's WPA issue */ struct rx_pkt_attrib *pattrib; pstapriv = &adapter->stapriv; @@ -2102,7 +2102,7 @@ int recv_indicatepkt_reorder(struct rtw_adapter *padapter, /* s1. */ wlanhdr_to_ethhdr(prframe); - if ((pattrib->qos!= 1) || (pattrib->eth_type == 0x0806) || + if ((pattrib->qos!= 1) || (pattrib->eth_type == ETH_P_ARP) || (pattrib->ack_policy != 0)) { if ((padapter->bDriverStopped == false) && (padapter->bSurpriseRemoved == false)) { -- cgit v1.2.3 From 514c485c01676927feb77c2a3e350bb3985fa11e Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:21 +0200 Subject: staging: rtl8723au: Fix case where ethtype was never obtained and always be checked against 0 Zero-initializing ether_type masked that the ether type would never be obtained for 8021x packets and the comparition against eapol_type would always fail. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_recv.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 8ae191654a42..e448511d2f45 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -575,7 +575,7 @@ static struct recv_frame *portctrl(struct rtw_adapter *adapter, struct sta_info *psta; struct sta_priv *pstapriv ; struct recv_frame *prtnframe; - u16 ether_type = 0; + u16 ether_type; u16 eapol_type = ETH_P_PAE;/* for Funia BD's WPA issue */ struct rx_pkt_attrib *pattrib; @@ -593,7 +593,12 @@ static struct recv_frame *portctrl(struct rtw_adapter *adapter, ("########portctrl:adapter->securitypriv.dot11AuthAlgrthm =" "%d\n", adapter->securitypriv.dot11AuthAlgrthm)); - if (auth_alg == 2) { + if (auth_alg == dot11AuthAlgrthm_8021X) { + /* get ether_type */ + ptr = ptr + pfhdr->attrib.hdrlen + LLC_HEADER_SIZE; + memcpy(ðer_type, ptr, 2); + ether_type = ntohs((unsigned short)ether_type); + if ((psta != NULL) && (psta->ieee8021x_blocked)) { /* blocked */ /* only accept EAPOL frame */ @@ -601,13 +606,6 @@ static struct recv_frame *portctrl(struct rtw_adapter *adapter, ("########portctrl:psta->ieee8021x_blocked ==" "1\n")); - prtnframe = precv_frame; - - /* get ether_type */ - ptr = ptr + pfhdr->attrib.hdrlen + LLC_HEADER_SIZE; - memcpy(ðer_type, ptr, 2); - ether_type = ntohs((unsigned short)ether_type); - if (ether_type == eapol_type) { prtnframe = precv_frame; } else { @@ -651,9 +649,7 @@ static struct recv_frame *portctrl(struct rtw_adapter *adapter, prtnframe = precv_frame; } - - - return prtnframe; + return prtnframe; } int recv_decache(struct recv_frame *precv_frame, u8 bretry, -- cgit v1.2.3 From 7d0d2b15a0e06ce18c5fd69c4c9692f5670aa9d4 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:22 +0200 Subject: staging: rtl8723au: Calling rtw_get_stainfo() with a NULL sta_addr will return NULL This makes the follow-on check for psta != NULL pointless and makes the whole exercise rather pointless. This is another case of why blindly zero-initializing variables when they are declared is bad. This bug seems to be present in multiple drivers provided by Realtek. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_recv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index e448511d2f45..5292bc2fd29a 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -569,7 +569,7 @@ struct recv_frame *decryptor(struct rtw_adapter *padapter, static struct recv_frame *portctrl(struct rtw_adapter *adapter, struct recv_frame *precv_frame) { - u8 *psta_addr = NULL, *ptr; + u8 *psta_addr, *ptr; uint auth_alg; struct recv_frame *pfhdr; struct sta_info *psta; @@ -580,7 +580,6 @@ static struct recv_frame *portctrl(struct rtw_adapter *adapter, struct rx_pkt_attrib *pattrib; pstapriv = &adapter->stapriv; - psta = rtw_get_stainfo23a(pstapriv, psta_addr); auth_alg = adapter->securitypriv.dot11AuthAlgrthm; @@ -588,6 +587,7 @@ static struct recv_frame *portctrl(struct rtw_adapter *adapter, pfhdr = precv_frame; pattrib = &pfhdr->attrib; psta_addr = pattrib->ta; + psta = rtw_get_stainfo23a(pstapriv, psta_addr); RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:adapter->securitypriv.dot11AuthAlgrthm =" -- cgit v1.2.3 From 94b080bc7005ad7be2519040410fdfef7345eb9d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:23 +0200 Subject: staging: rtl8723au: Simplify retrieving the ether_type in portctrl() This renders the last element in include/ethernet.h unnecessary, so remove it as well. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 1 - drivers/staging/rtl8723au/core/rtw_recv.c | 8 +++----- drivers/staging/rtl8723au/hal/rtl8723au_recv.c | 1 - drivers/staging/rtl8723au/include/ethernet.h | 22 ---------------------- drivers/staging/rtl8723au/os_dep/os_intfs.c | 1 - drivers/staging/rtl8723au/os_dep/recv_linux.c | 1 - 6 files changed, 3 insertions(+), 31 deletions(-) delete mode 100644 drivers/staging/rtl8723au/include/ethernet.h diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index ae6ef6532af0..be593989aec7 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #ifdef CONFIG_8723AU_BT_COEXIST diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 5292bc2fd29a..713a377ce28f 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -583,7 +582,6 @@ static struct recv_frame *portctrl(struct rtw_adapter *adapter, auth_alg = adapter->securitypriv.dot11AuthAlgrthm; - ptr = precv_frame->pkt->data; pfhdr = precv_frame; pattrib = &pfhdr->attrib; psta_addr = pattrib->ta; @@ -595,9 +593,9 @@ static struct recv_frame *portctrl(struct rtw_adapter *adapter, if (auth_alg == dot11AuthAlgrthm_8021X) { /* get ether_type */ - ptr = ptr + pfhdr->attrib.hdrlen + LLC_HEADER_SIZE; - memcpy(ðer_type, ptr, 2); - ether_type = ntohs((unsigned short)ether_type); + ptr = pfhdr->pkt->data + pfhdr->attrib.hdrlen; + + ether_type = (ptr[6] << 8) | ptr[7]; if ((psta != NULL) && (psta->ieee8021x_blocked)) { /* blocked */ diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_recv.c b/drivers/staging/rtl8723au/hal/rtl8723au_recv.c index 213d1936109d..a7568bb65e2a 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723au_recv.c +++ b/drivers/staging/rtl8723au/hal/rtl8723au_recv.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/staging/rtl8723au/include/ethernet.h b/drivers/staging/rtl8723au/include/ethernet.h deleted file mode 100644 index 39fc6df88188..000000000000 --- a/drivers/staging/rtl8723au/include/ethernet.h +++ /dev/null @@ -1,22 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek 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. - * - * - ******************************************************************************/ -/*! \file */ -#ifndef __INC_ETHERNET_H -#define __INC_ETHERNET_H - -#define LLC_HEADER_SIZE 6 /* LLC Header Length */ - -#endif /* #ifndef __INC_ETHERNET_H */ diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index eab40d21fb3d..7c7c2c93e413 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include diff --git a/drivers/staging/rtl8723au/os_dep/recv_linux.c b/drivers/staging/rtl8723au/os_dep/recv_linux.c index 84402a589f25..18572090ac48 100644 --- a/drivers/staging/rtl8723au/os_dep/recv_linux.c +++ b/drivers/staging/rtl8723au/os_dep/recv_linux.c @@ -21,7 +21,6 @@ #include #include -#include #include -- cgit v1.2.3 From f619621f409a9e8d5c56b2089d359fe3b5b8ad57 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 31 Mar 2014 10:50:36 +0300 Subject: staging: comedi: remove an unneeded variable "chanlist" was left over, we don't need it any more. Signed-off-by: Dan Carpenter Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index ea6dc36d753b..1e91161fb38f 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -1597,7 +1597,6 @@ static int do_cmdtest_ioctl(struct comedi_device *dev, { struct comedi_cmd cmd; struct comedi_subdevice *s; - unsigned int *chanlist = NULL; unsigned int __user *user_chanlist; int ret; @@ -1626,8 +1625,6 @@ static int do_cmdtest_ioctl(struct comedi_device *dev, ret = -EFAULT; } - kfree(chanlist); - return ret; } -- cgit v1.2.3 From b2f4874174b17db72d4a67aec2dac56304ceb8ba Mon Sep 17 00:00:00 2001 From: Yves Deweerdt Date: Mon, 31 Mar 2014 22:55:39 +0200 Subject: staging: comedi: comedy_fops.c: fix line over 80, characters warnings Signed-off-by: Yves Deweerdt Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 1e91161fb38f..e283e6c7b52b 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -1435,13 +1435,15 @@ static int __comedi_get_user_cmd(struct comedi_device *dev, s = &dev->subdevices[cmd->subdev]; if (s->type == COMEDI_SUBD_UNUSED) { - dev_dbg(dev->class_dev, "%d not valid subdevice\n", cmd->subdev); + dev_dbg(dev->class_dev, "%d not valid subdevice\n", + cmd->subdev); return -EIO; } if (!s->do_cmd || !s->do_cmdtest || !s->async) { dev_dbg(dev->class_dev, - "subdevice %d does not support commands\n", cmd->subdev); + "subdevice %d does not support commands\n", + cmd->subdev); return -EIO; } -- cgit v1.2.3 From 1e4742df19bee14669e72ee3da670c3b6b33cd5e Mon Sep 17 00:00:00 2001 From: Yves Deweerdt Date: Mon, 31 Mar 2014 22:55:44 +0200 Subject: staging: comedi: drivers.c: Fix missing a blank line, after declarations warning Signed-off-by: Yves Deweerdt Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index ab0e8ed47291..cb5d21411a0c 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -258,6 +258,7 @@ static int insn_rw_emulate_bits(struct comedi_device *dev, const unsigned base_bitfield_channel = (chan < channels_per_bitfield) ? 0 : chan; unsigned int new_data[2]; + memset(new_data, 0, sizeof(new_data)); memset(&new_insn, 0, sizeof(new_insn)); new_insn.insn = INSN_BITS; -- cgit v1.2.3 From 571845c6f47de51a41ab7964a144b22d297d06ce Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Thu, 3 Apr 2014 18:43:27 -0500 Subject: staging: comedi: s626: use comedi_timeout() on remaining loops There were just a handful of more while loops in this file that needed timeouts, and this patch takes care of them. One new callback is introduced, and all of the proper comedi_timeout() calls are then used. The return type of s626_i2c_handshake() has been changed from uint32_t to int so that a negative error code from comedi_timeout() can be propagated if necessary. Signed-off-by: Chase Southwood Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/s626.c | 36 ++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index 95fadf343f27..6da43de51eb3 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c @@ -295,10 +295,24 @@ static void s626_debi_replace(struct comedi_device *dev, unsigned int addr, /* ************** EEPROM ACCESS FUNCTIONS ************** */ -static uint32_t s626_i2c_handshake(struct comedi_device *dev, uint32_t val) +static int s626_i2c_handshake_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + bool status; + + status = s626_mc_test(dev, S626_MC2_UPLD_IIC, S626_P_MC2); + if (status) + return 0; + return -EBUSY; +} + +static int s626_i2c_handshake(struct comedi_device *dev, uint32_t val) { struct s626_private *devpriv = dev->private; unsigned int ctrl; + int ret; /* Write I2C command to I2C Transfer Control shadow register */ writel(val, devpriv->mmio + S626_P_I2CCTRL); @@ -308,8 +322,9 @@ static uint32_t s626_i2c_handshake(struct comedi_device *dev, uint32_t val) * wait for upload confirmation. */ s626_mc_enable(dev, S626_MC2_UPLD_IIC, S626_P_MC2); - while (!s626_mc_test(dev, S626_MC2_UPLD_IIC, S626_P_MC2)) - ; + ret = comedi_timeout(dev, NULL, NULL, s626_i2c_handshake_eoc, 0); + if (ret) + return ret; /* Wait until I2C bus transfer is finished or an error occurs */ do { @@ -2029,8 +2044,9 @@ static int s626_ai_insn_read(struct comedi_device *dev, /* Wait for the data to arrive in FB BUFFER 1 register. */ /* Wait for ADC done */ - while (!(readl(devpriv->mmio + S626_P_PSR) & S626_PSR_GPIO2)) - ; + ret = comedi_timeout(dev, s, insn, s626_ai_eoc, 0); + if (ret) + return ret; /* Fetch ADC data from audio interface's input shift register. */ @@ -2681,8 +2697,9 @@ static int s626_initialize(struct comedi_device *dev) writel(S626_I2C_CLKSEL | S626_I2C_ABORT, devpriv->mmio + S626_P_I2CSTAT); s626_mc_enable(dev, S626_MC2_UPLD_IIC, S626_P_MC2); - while (!(readl(devpriv->mmio + S626_P_MC2) & S626_MC2_UPLD_IIC)) - ; + ret = comedi_timeout(dev, NULL, NULL, s626_i2c_handshake_eoc, 0); + if (ret) + return ret; /* * Per SAA7146 data sheet, write to STATUS @@ -2691,8 +2708,9 @@ static int s626_initialize(struct comedi_device *dev) for (i = 0; i < 2; i++) { writel(S626_I2C_CLKSEL, devpriv->mmio + S626_P_I2CSTAT); s626_mc_enable(dev, S626_MC2_UPLD_IIC, S626_P_MC2); - while (!s626_mc_test(dev, S626_MC2_UPLD_IIC, S626_P_MC2)) - ; + ret = comedi_timeout(dev, NULL, NULL, s626_i2c_handshake_eoc, 0); + if (ret) + return ret; } /* -- cgit v1.2.3 From 6425b1c2d25d9cdcaa23c266a5845e8cd2e4f2d6 Mon Sep 17 00:00:00 2001 From: Kumar Amit Mehta Date: Fri, 4 Apr 2014 18:44:44 +0300 Subject: staging: comedi: drivers: pcl812.c: add curly braces for checkpatch Kernel style is that if one side of the if else statement gets has curly braces then both side should have them. Signed-off-by: Kumar Amit Mehta Acked-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 160eac8083db..5cc01fe45cf2 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -811,8 +811,9 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_dma = 0; break; } - } else + } else { devpriv->ai_dma = 0; + } devpriv->ai_act_scan = 0; devpriv->ai_poll_ptr = 0; -- cgit v1.2.3 From b5ebcaa8d3405e14ca431257fd6c6cdc30df13c5 Mon Sep 17 00:00:00 2001 From: Georg Gast Date: Tue, 8 Apr 2014 18:52:58 +0200 Subject: staging: comedi: more descriptive names for addi-data drivers - more descriptive module description for following boards: ADDI-DATA APCI 1032/1500/1564/2032/3120 Signed-off-by: Georg Gast Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1032.c | 2 +- drivers/staging/comedi/drivers/addi_apci_1500.c | 2 +- drivers/staging/comedi/drivers/addi_apci_1564.c | 2 +- drivers/staging/comedi/drivers/addi_apci_2032.c | 2 +- drivers/staging/comedi/drivers/addi_apci_3120.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1032.c b/drivers/staging/comedi/drivers/addi_apci_1032.c index 0daa0ea63b5e..d6a5424654fc 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1032.c +++ b/drivers/staging/comedi/drivers/addi_apci_1032.c @@ -379,5 +379,5 @@ static struct pci_driver apci1032_pci_driver = { module_comedi_pci_driver(apci1032_driver, apci1032_pci_driver); MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_DESCRIPTION("ADDI-DATA APCI-1032, 32 channel DI boards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c index bd8e08ca14c0..eab75eb26478 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1500.c +++ b/drivers/staging/comedi/drivers/addi_apci_1500.c @@ -72,5 +72,5 @@ static struct pci_driver apci1500_pci_driver = { module_comedi_pci_driver(apci1500_driver, apci1500_pci_driver); MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_DESCRIPTION("ADDI-DATA APCI-1500, 16 channel DI / 16 channel DO boards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 27aa9ae1bdd9..11aa0bd5d7b1 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -70,5 +70,5 @@ static struct pci_driver apci1564_pci_driver = { module_comedi_pci_driver(apci1564_driver, apci1564_pci_driver); MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_DESCRIPTION("ADDI-DATA APCI-1564, 32 channel DI / 32 channel DO boards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_2032.c b/drivers/staging/comedi/drivers/addi_apci_2032.c index c9b933cb5987..feefc7a5ca9a 100644 --- a/drivers/staging/comedi/drivers/addi_apci_2032.c +++ b/drivers/staging/comedi/drivers/addi_apci_2032.c @@ -374,5 +374,5 @@ static struct pci_driver apci2032_pci_driver = { module_comedi_pci_driver(apci2032_driver, apci2032_pci_driver); MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_DESCRIPTION("ADDI-DATA APCI-2032, 32 channel DO boards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 57ee6e5c7635..0cfb12fa1cbc 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -246,5 +246,5 @@ static struct pci_driver apci3120_pci_driver = { module_comedi_pci_driver(apci3120_driver, apci3120_pci_driver); MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_DESCRIPTION("ADDI-DATA APCI-3120, Analog input board"); MODULE_LICENSE("GPL"); -- cgit v1.2.3 From 110775bd5dbc811ab4d55f7498a57ef96994dbde Mon Sep 17 00:00:00 2001 From: Richard Leitner Date: Wed, 9 Apr 2014 18:27:13 +0200 Subject: staging: comedi: adl_pci9118: fix whitespace issues Removed not needed spaces and fixed too long lines Signed-off-by: Richard Leitner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 3cfa1756fa6a..b6abef6ceab7 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -96,7 +96,7 @@ Configuration options: * correct channel number on every 12 bit sample */ -#define IORANGE_9118 64 /* I hope */ +#define IORANGE_9118 64 /* I hope */ #define PCI9118_CHANLEN 255 /* * len of chanlist, some source say 256, * but reality looks like 255 :-( @@ -383,7 +383,7 @@ struct pci9118_private { * 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 *, + void (*int_ai_func)(struct comedi_device *, struct comedi_subdevice *, unsigned short, unsigned int, unsigned short); /* @@ -1045,7 +1045,7 @@ static void interrupt_pci9118_ai_dma(struct comedi_device *dev, move_block_from_dma(dev, s, devpriv->dmabuf_virt[devpriv->dma_actbuf], samplesinbuf); - m = m - sampls; /* m= how many samples was transferred */ + m = m - sampls; /* m=how many samples was transferred */ } if (!devpriv->ai_neverending) { -- cgit v1.2.3 From bee2d6a82cc31ebcc44a0ec9484ec1670c07ca6a Mon Sep 17 00:00:00 2001 From: Michele Curti Date: Thu, 10 Apr 2014 16:38:00 +0200 Subject: staging: comedi: declare das6402_boards as static das6402_boards array is used in das6402.c only, so declare it as static. Signed-off-by: Michele Curti Reviewed-by: Ian Abbott Acked-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das6402.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/das6402.c b/drivers/staging/comedi/drivers/das6402.c index e0cfb6cb547b..d18eea6c01aa 100644 --- a/drivers/staging/comedi/drivers/das6402.c +++ b/drivers/staging/comedi/drivers/das6402.c @@ -125,7 +125,7 @@ struct das6402_boardinfo { unsigned int maxdata; }; -struct das6402_boardinfo das6402_boards[] = { +static struct das6402_boardinfo das6402_boards[] = { { .name = "das6402-12", .maxdata = 0x0fff, -- cgit v1.2.3 From a47a0f506414022075c750e680ef84ce97dc2fb2 Mon Sep 17 00:00:00 2001 From: Gary Rookard Date: Thu, 20 Mar 2014 23:28:43 -0400 Subject: Staging: bcm: CmHost: remove temp bracing from switch/cases. Remove the temp bracing afixed to case labels. Properly indent switch/case breaks. Signed-off-by: Gary Alan Rookard Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 50 +++++++------------------------------------- 1 file changed, 7 insertions(+), 43 deletions(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index 632f81a7c63f..4564c63f908c 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -460,42 +460,30 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* u8CSSpecification); switch (psfLocalSet->u8CSSpecification) { case eCSPacketIPV4: - { Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV4_CS; break; - } case eCSPacketIPV6: - { Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV6_CS; break; - } case eCS802_3PacketEthernet: case eCS802_1QPacketVLAN: - { Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = ETH_CS_802_3; break; - } case eCSPacketIPV4Over802_1QVLAN: case eCSPacketIPV4Over802_3Ethernet: - { Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV4_CS; Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = ETH_CS_802_3; break; - } case eCSPacketIPV6Over802_1QVLAN: case eCSPacketIPV6Over802_3Ethernet: - { Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV6_CS; Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = ETH_CS_802_3; break; - } default: - { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Error in value of CS Classification.. setting default to IP CS\n"); Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV4_CS; break; } - } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "CopyToAdapter : Queue No : %X ETH CS Support : %X , IP CS Support : %X\n", uiSearchRuleIndex, @@ -542,32 +530,23 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* u8ClassfierDSCAction) { case 0: /* DSC Add Classifier */ - { eClassifierAction = eAddClassifier; - } - break; + break; case 1: /* DSC Replace Classifier */ - { eClassifierAction = eReplaceClassifier; - } - break; + break; case 2: /* DSC Delete Classifier */ - { eClassifierAction = eDeleteClassifier; - } - break; + break; default: - { eClassifierAction = eInvalidClassifierAction; } - } } u16PacketClassificationRuleIndex = ntohs(psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex); switch (eClassifierAction) { case eAddClassifier: - { /* Get a Free Classifier Index From Classifier table for this SF to add the Classifier */ /* Contained in this message */ nClassifierIndex = SearchClsid(Adapter, ulSFID, u16PacketClassificationRuleIndex); @@ -587,10 +566,8 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* u8PhsDSCAction) { case eDeleteAllPHSRules: - { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Deleting All PHS Rules For VCID: 0x%X\n", uVCID); /* Delete All the PHS rules for this Service flow */ PhsDeleteSFRules(&Adapter->stBCMPhsContext, uVCID); break; - } case eDeletePHSRule: - { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "PHS DSC Action = Delete PHS Rule\n"); if (psfCSType->cPhsRule.u8PHSI) PhsDeletePHSRule(&Adapter->stBCMPhsContext, uVCID, psfCSType->cCPacketClassificationRule.u8AssociatedPHSI); break; - } default: - { if (ucDsxType == DSC_ACK) { /* BCM_DEBUG_PRINT(CONN_MSG,("Invalid PHS DSC Action For DSC\n",psfCSType->cPhsRule.u8PHSI)); */ break; /* FOr DSC ACK Case PHS DSC Action must be in valid set */ } - } /* Proceed To Add PHS rule for DSA_ACK case even if PHS DSC action is unspecified */ /* No Break Here . Intentionally! */ case eAddPHSRule: case eSetPHSRule: - { if (psfCSType->cPhsRule.u8PHSI) { /* Apply This PHS Rule to all classifiers whose Associated PHSI Match */ unsigned int uiClassifierIndex = 0; @@ -738,8 +703,7 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* Date: Fri, 4 Apr 2014 12:25:55 -0600 Subject: staging/bcm fix hostmibs.c checkpatch problems Fix 4 checkpatch errors, many warnings in bcm/hostmibs.c Signed-off-by: Jake Edge Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/hostmibs.c | 51 +++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/drivers/staging/bcm/hostmibs.c b/drivers/staging/bcm/hostmibs.c index 39ace5510c43..42d9004e357d 100644 --- a/drivers/staging/bcm/hostmibs.c +++ b/drivers/staging/bcm/hostmibs.c @@ -9,37 +9,40 @@ #include "headers.h" -INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, struct bcm_host_stats_mibs *pstHostMibs) +INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, + struct bcm_host_stats_mibs *pstHostMibs) { struct bcm_phs_entry *pstServiceFlowEntry = NULL; struct bcm_phs_rule *pstPhsRule = NULL; struct bcm_phs_classifier_table *pstClassifierTable = NULL; struct bcm_phs_classifier_entry *pstClassifierRule = NULL; - struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *) &Adapter->stBCMPhsContext; - - UINT nClassifierIndex = 0, nPhsTableIndex = 0, nSfIndex = 0, uiIndex = 0; + struct bcm_phs_extension *pDeviceExtension = &Adapter->stBCMPhsContext; + UINT nClassifierIndex = 0; + UINT nPhsTableIndex = 0; + UINT nSfIndex = 0; + UINT uiIndex = 0; if (pDeviceExtension == NULL) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, HOST_MIBS, DBG_LVL_ALL, "Invalid Device Extension\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, HOST_MIBS, + DBG_LVL_ALL, "Invalid Device Extension\n"); return STATUS_FAILURE; } /* Copy the classifier Table */ - for (nClassifierIndex = 0; nClassifierIndex < MAX_CLASSIFIERS; nClassifierIndex++) { + for (nClassifierIndex = 0; nClassifierIndex < MAX_CLASSIFIERS; + nClassifierIndex++) { if (Adapter->astClassifierTable[nClassifierIndex].bUsed == TRUE) - memcpy((PVOID) &pstHostMibs-> - astClassifierTable[nClassifierIndex], - (PVOID) &Adapter-> - astClassifierTable[nClassifierIndex], + memcpy(&pstHostMibs->astClassifierTable[nClassifierIndex], + &Adapter->astClassifierTable[nClassifierIndex], sizeof(struct bcm_mibs_classifier_rule)); } /* Copy the SF Table */ for (nSfIndex = 0; nSfIndex < NO_OF_QUEUES; nSfIndex++) { if (Adapter->PackInfo[nSfIndex].bValid) { - memcpy((PVOID) &pstHostMibs->astSFtable[nSfIndex], - (PVOID) &Adapter->PackInfo[nSfIndex], - sizeof(struct bcm_mibs_table)); + memcpy(&pstHostMibs->astSFtable[nSfIndex], + &Adapter->PackInfo[nSfIndex], + sizeof(struct bcm_mibs_table)); } else { /* If index in not valid, * don't process this for the PHS table. @@ -68,9 +71,9 @@ INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, struct bcm_host_stats_m pstHostMibs->astPhsRulesTable[nPhsTableIndex]. ulSFID = Adapter->PackInfo[nSfIndex].ulSFID; - memcpy(&pstHostMibs-> - astPhsRulesTable[nPhsTableIndex].u8PHSI, - &pstPhsRule->u8PHSI, sizeof(struct bcm_phs_rule)); + memcpy(&pstHostMibs->astPhsRulesTable[nPhsTableIndex].u8PHSI, + &pstPhsRule->u8PHSI, + sizeof(struct bcm_phs_rule)); nPhsTableIndex++; } @@ -82,26 +85,32 @@ INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, struct bcm_host_stats_m /* Copy other Host Statistics parameters */ pstHostMibs->stHostInfo.GoodTransmits = Adapter->dev->stats.tx_packets; pstHostMibs->stHostInfo.GoodReceives = Adapter->dev->stats.rx_packets; - pstHostMibs->stHostInfo.CurrNumFreeDesc = atomic_read(&Adapter->CurrNumFreeTxDesc); + pstHostMibs->stHostInfo.CurrNumFreeDesc = + atomic_read(&Adapter->CurrNumFreeTxDesc); pstHostMibs->stHostInfo.BEBucketSize = Adapter->BEBucketSize; pstHostMibs->stHostInfo.rtPSBucketSize = Adapter->rtPSBucketSize; pstHostMibs->stHostInfo.TimerActive = Adapter->TimerActive; pstHostMibs->stHostInfo.u32TotalDSD = Adapter->u32TotalDSD; - memcpy(pstHostMibs->stHostInfo.aTxPktSizeHist, Adapter->aTxPktSizeHist, sizeof(UINT32) * MIBS_MAX_HIST_ENTRIES); - memcpy(pstHostMibs->stHostInfo.aRxPktSizeHist, Adapter->aRxPktSizeHist, sizeof(UINT32) * MIBS_MAX_HIST_ENTRIES); + memcpy(pstHostMibs->stHostInfo.aTxPktSizeHist, Adapter->aTxPktSizeHist, + sizeof(UINT32) * MIBS_MAX_HIST_ENTRIES); + memcpy(pstHostMibs->stHostInfo.aRxPktSizeHist, Adapter->aRxPktSizeHist, + sizeof(UINT32) * MIBS_MAX_HIST_ENTRIES); return STATUS_SUCCESS; } -VOID GetDroppedAppCntrlPktMibs(struct bcm_host_stats_mibs *pstHostMibs, struct bcm_tarang_data *pTarang) +VOID GetDroppedAppCntrlPktMibs(struct bcm_host_stats_mibs *pstHostMibs, + struct bcm_tarang_data *pTarang) { memcpy(&(pstHostMibs->stDroppedAppCntrlMsgs), &(pTarang->stDroppedAppCntrlMsgs), sizeof(struct bcm_mibs_dropped_cntrl_msg)); } -VOID CopyMIBSExtendedSFParameters(struct bcm_mini_adapter *Adapter, struct bcm_connect_mgr_params *psfLocalSet, UINT uiSearchRuleIndex) +VOID CopyMIBSExtendedSFParameters(struct bcm_mini_adapter *Adapter, + struct bcm_connect_mgr_params *psfLocalSet, + UINT uiSearchRuleIndex) { struct bcm_mibs_parameters *t = &Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable; -- cgit v1.2.3 From 2315e49e788be1eef57c45d230303cc929c976c8 Mon Sep 17 00:00:00 2001 From: Luis Ortega Date: Wed, 9 Apr 2014 13:56:09 +0200 Subject: Staging: bcm: Qos: fixed braces' coding style Fixed badly placed and unnecessary braces. PS: Performed as task 10 of the Eudyptula Challenge. Signed-off-by: Luis Ortega Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Qos.c | 174 +++++++++++++--------------------------------- 1 file changed, 48 insertions(+), 126 deletions(-) diff --git a/drivers/staging/bcm/Qos.c b/drivers/staging/bcm/Qos.c index 4f315835ddfc..09e548aef812 100644 --- a/drivers/staging/bcm/Qos.c +++ b/drivers/staging/bcm/Qos.c @@ -33,14 +33,11 @@ static bool MatchSrcIpAddress(struct bcm_classifier_rule *pstClassifierRule, ULO ulSrcIP = ntohl(ulSrcIP); if (0 == pstClassifierRule->ucIPSourceAddressLength) return TRUE; - for (ucLoopIndex = 0; ucLoopIndex < (pstClassifierRule->ucIPSourceAddressLength); ucLoopIndex++) - { + for (ucLoopIndex = 0; ucLoopIndex < (pstClassifierRule->ucIPSourceAddressLength); ucLoopIndex++) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Ip Address Mask:0x%x PacketIp:0x%x and Classification:0x%x", (UINT)pstClassifierRule->stSrcIpAddress.ulIpv4Mask[ucLoopIndex], (UINT)ulSrcIP, (UINT)pstClassifierRule->stSrcIpAddress.ulIpv6Addr[ucLoopIndex]); if ((pstClassifierRule->stSrcIpAddress.ulIpv4Mask[ucLoopIndex] & ulSrcIP) == (pstClassifierRule->stSrcIpAddress.ulIpv4Addr[ucLoopIndex] & pstClassifierRule->stSrcIpAddress.ulIpv4Mask[ucLoopIndex])) - { return TRUE; - } } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Ip Address Not Matched"); return false; @@ -68,13 +65,10 @@ static bool MatchDestIpAddress(struct bcm_classifier_rule *pstClassifierRule, UL return TRUE; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Destination Ip Address 0x%x 0x%x 0x%x ", (UINT)ulDestIP, (UINT)pstClassifierRule->stDestIpAddress.ulIpv4Mask[ucLoopIndex], (UINT)pstClassifierRule->stDestIpAddress.ulIpv4Addr[ucLoopIndex]); - for (ucLoopIndex = 0; ucLoopIndex < (pstClassifierRule->ucIPDestinationAddressLength); ucLoopIndex++) - { + for (ucLoopIndex = 0; ucLoopIndex < (pstClassifierRule->ucIPDestinationAddressLength); ucLoopIndex++) { if ((pstClassifierRule->stDestIpAddress.ulIpv4Mask[ucLoopIndex] & ulDestIP) == (pstClassifierRule->stDestIpAddress.ulIpv4Addr[ucLoopIndex] & pstClassifierRule->stDestIpAddress.ulIpv4Mask[ucLoopIndex])) - { return TRUE; - } } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Destination Ip Address Not Matched"); return false; @@ -99,9 +93,8 @@ static bool MatchTos(struct bcm_classifier_rule *pstClassifierRule, UCHAR ucType return TRUE; if (((pstClassifierRule->ucTosMask & ucTypeOfService) <= pstClassifierRule->ucTosHigh) && ((pstClassifierRule->ucTosMask & ucTypeOfService) >= pstClassifierRule->ucTosLow)) - { return TRUE; - } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Type Of Service Not Matched"); return false; } @@ -123,13 +116,10 @@ bool MatchProtocol(struct bcm_classifier_rule *pstClassifierRule, UCHAR ucProtoc struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); if (0 == pstClassifierRule->ucProtocolLength) return TRUE; - for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucProtocolLength; ucLoopIndex++) - { + for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucProtocolLength; ucLoopIndex++) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Protocol:0x%X Classification Protocol:0x%X", ucProtocol, pstClassifierRule->ucProtocol[ucLoopIndex]); if (pstClassifierRule->ucProtocol[ucLoopIndex] == ucProtocol) - { return TRUE; - } } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Protocol Not Matched"); return false; @@ -155,13 +145,10 @@ bool MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule, USHORT ushSrcPo if (0 == pstClassifierRule->ucSrcPortRangeLength) return TRUE; - for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucSrcPortRangeLength; ucLoopIndex++) - { + for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucSrcPortRangeLength; ucLoopIndex++) { if (ushSrcPort <= pstClassifierRule->usSrcPortRangeHi[ucLoopIndex] && ushSrcPort >= pstClassifierRule->usSrcPortRangeLo[ucLoopIndex]) - { return TRUE; - } } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Port: %x Not Matched ", ushSrcPort); return false; @@ -186,15 +173,12 @@ bool MatchDestPort(struct bcm_classifier_rule *pstClassifierRule, USHORT ushDest if (0 == pstClassifierRule->ucDestPortRangeLength) return TRUE; - for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucDestPortRangeLength; ucLoopIndex++) - { + for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucDestPortRangeLength; ucLoopIndex++) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Matching Port:0x%X 0x%X 0x%X", ushDestPort, pstClassifierRule->usDestPortRangeLo[ucLoopIndex], pstClassifierRule->usDestPortRangeHi[ucLoopIndex]); if (ushDestPort <= pstClassifierRule->usDestPortRangeHi[ucLoopIndex] && ushDestPort >= pstClassifierRule->usDestPortRangeLo[ucLoopIndex]) - { return TRUE; - } } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Dest Port: %x Not Matched", ushDestPort); return false; @@ -273,21 +257,13 @@ static USHORT IpVersion4(struct bcm_mini_adapter *Adapter, bClassificationSucceed = TRUE; } while (0); - if (TRUE == bClassificationSucceed) - { + if (TRUE == bClassificationSucceed) { INT iMatchedSFQueueIndex = 0; iMatchedSFQueueIndex = SearchSfid(Adapter, pstClassifierRule->ulSFID); if (iMatchedSFQueueIndex >= NO_OF_QUEUES) - { bClassificationSucceed = false; - } - else - { - if (false == Adapter->PackInfo[iMatchedSFQueueIndex].bActive) - { - bClassificationSucceed = false; - } - } + else if (false == Adapter->PackInfo[iMatchedSFQueueIndex].bActive) + bClassificationSucceed = false; } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "IpVersion4 <=========="); @@ -299,8 +275,7 @@ VOID PruneQueueAllSF(struct bcm_mini_adapter *Adapter) { UINT iIndex = 0; - for (iIndex = 0; iIndex < HiPriority; iIndex++) - { + for (iIndex = 0; iIndex < HiPriority; iIndex++) { if (!Adapter->PackInfo[iIndex].bValid) continue; @@ -334,10 +309,10 @@ static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex) spin_lock_bh(&Adapter->PackInfo[iIndex].SFQueueLock); - while (1) + while (1) { // while((UINT)Adapter->PackInfo[iIndex].uiCurrentPacketsOnHost > -// SF_MAX_ALLOWED_PACKETS_TO_BACKUP) - { +// SF_MAX_ALLOWED_PACKETS_TO_BACKUP) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "uiCurrentBytesOnHost:%x uiMaxBucketSize :%x", Adapter->PackInfo[iIndex].uiCurrentBytesOnHost, Adapter->PackInfo[iIndex].uiMaxBucketSize); @@ -350,8 +325,7 @@ static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex) ((1000*(jiffies - *((B_UINT32 *)(PacketToDrop->cb)+SKB_CB_LATENCY_OFFSET))/HZ) <= Adapter->PackInfo[iIndex].uiMaxLatency)) break; - if (PacketToDrop) - { + if (PacketToDrop) { if (netif_msg_tx_err(Adapter)) pr_info(PFX "%s: tx queue %d overlimit\n", Adapter->dev->name, iIndex); @@ -394,20 +368,16 @@ VOID flush_all_queues(struct bcm_mini_adapter *Adapter) BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "=====>"); // down(&Adapter->data_packet_queue_lock); - for (iQIndex = LowPriority; iQIndex < HiPriority; iQIndex++) - { + for (iQIndex = LowPriority; iQIndex < HiPriority; iQIndex++) { struct net_device_stats *netstats = &Adapter->dev->stats; spin_lock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock); - while (Adapter->PackInfo[iQIndex].FirstTxQueue) - { + while (Adapter->PackInfo[iQIndex].FirstTxQueue) { PacketToDrop = Adapter->PackInfo[iQIndex].FirstTxQueue; - if (PacketToDrop) - { + if (PacketToDrop) { uiTotalPacketLength = PacketToDrop->len; netstats->tx_dropped++; - } - else + } else uiTotalPacketLength = 0; DEQUEUEPACKET(Adapter->PackInfo[iQIndex].FirstTxQueue, @@ -455,58 +425,42 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb) *((UINT32*) (skb->cb) +SKB_CB_TCPACK_OFFSET) = 0; EThCSGetPktInfo(Adapter, pvEThPayload, &stEthCsPktInfo); - switch (stEthCsPktInfo.eNwpktEthFrameType) - { + switch (stEthCsPktInfo.eNwpktEthFrameType) { case eEth802LLCFrame: - { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : 802LLCFrame\n"); pIpHeader = pvEThPayload + sizeof(struct bcm_eth_llc_frame); break; - } - case eEth802LLCSNAPFrame: - { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : 802LLC SNAP Frame\n"); pIpHeader = pvEThPayload + sizeof(struct bcm_eth_llc_snap_frame); break; - } case eEth802QVLANFrame: - { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : 802.1Q VLANFrame\n"); pIpHeader = pvEThPayload + sizeof(struct bcm_eth_q_frame); break; - } case eEthOtherFrame: - { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : ETH Other Frame\n"); pIpHeader = pvEThPayload + sizeof(struct bcm_ethernet2_frame); break; - } default: - { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : Unrecognized ETH Frame\n"); pIpHeader = pvEThPayload + sizeof(struct bcm_ethernet2_frame); break; - } } - if (stEthCsPktInfo.eNwpktIPFrameType == eIPv4Packet) - { + if (stEthCsPktInfo.eNwpktIPFrameType == eIPv4Packet) { usCurrFragment = (ntohs(pIpHeader->frag_off) & IP_OFFSET); if ((ntohs(pIpHeader->frag_off) & IP_MF) || usCurrFragment) bFragmentedPkt = TRUE; - if (bFragmentedPkt) - { + if (bFragmentedPkt) { //Fragmented Packet. Get Frag Classifier Entry. pstClassifierRule = GetFragIPClsEntry(Adapter, pIpHeader->id, pIpHeader->saddr); - if (pstClassifierRule) - { + if (pstClassifierRule) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "It is next Fragmented pkt"); bClassificationSucceed = TRUE; } - if (!(ntohs(pIpHeader->frag_off) & IP_MF)) - { + if (!(ntohs(pIpHeader->frag_off) & IP_MF)) { //Fragmented Last packet . Remove Frag Classifier Entry BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "This is the last fragmented Pkt"); DelFragIPClsEntry(Adapter, pIpHeader->id, pIpHeader->saddr); @@ -514,23 +468,19 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb) } } - for (uiLoopIndex = MAX_CLASSIFIERS - 1; uiLoopIndex >= 0; uiLoopIndex--) - { + for (uiLoopIndex = MAX_CLASSIFIERS - 1; uiLoopIndex >= 0; uiLoopIndex--) { if (bClassificationSucceed) break; //Iterate through all classifiers which are already in order of priority //to classify the packet until match found - do - { - if (false == Adapter->astClassifierTable[uiLoopIndex].bUsed) - { + do { + if (false == Adapter->astClassifierTable[uiLoopIndex].bUsed) { bClassificationSucceed = false; break; } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Adapter->PackInfo[%d].bvalid=True\n", uiLoopIndex); - if (0 == Adapter->astClassifierTable[uiLoopIndex].ucDirection) - { + if (0 == Adapter->astClassifierTable[uiLoopIndex].ucDirection) { bClassificationSucceed = false;//cannot be processed for classification. break; // it is a down link connection } @@ -543,11 +493,9 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb) break; } - if (Adapter->PackInfo[uiSfIndex].bEthCSSupport) - { + if (Adapter->PackInfo[uiSfIndex].bEthCSSupport) { - if (eEthUnsupportedFrame == stEthCsPktInfo.eNwpktEthFrameType) - { + if (eEthUnsupportedFrame == stEthCsPktInfo.eNwpktEthFrameType) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, " ClassifyPacket : Packet Not a Valid Supported Ethernet Frame\n"); bClassificationSucceed = false; break; @@ -558,17 +506,12 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb) BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Performing ETH CS Classification on Classifier Rule ID : %x Service Flow ID : %lx\n", pstClassifierRule->uiClassifierRuleIndex, Adapter->PackInfo[uiSfIndex].ulSFID); bClassificationSucceed = EThCSClassifyPkt(Adapter, skb, &stEthCsPktInfo, pstClassifierRule, Adapter->PackInfo[uiSfIndex].bEthCSSupport); - if (!bClassificationSucceed) - { + if (!bClassificationSucceed) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : Ethernet CS Classification Failed\n"); break; } - } - - else // No ETH Supported on this SF - { - if (eEthOtherFrame != stEthCsPktInfo.eNwpktEthFrameType) - { + } else { // No ETH Supported on this SF + if (eEthOtherFrame != stEthCsPktInfo.eNwpktEthFrameType) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, " ClassifyPacket : Packet Not a 802.3 Ethernet Frame... hence not allowed over non-ETH CS SF\n"); bClassificationSucceed = false; break; @@ -577,11 +520,9 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb) BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Proceeding to IP CS Clasification"); - if (Adapter->PackInfo[uiSfIndex].bIPCSSupport) - { + if (Adapter->PackInfo[uiSfIndex].bIPCSSupport) { - if (stEthCsPktInfo.eNwpktIPFrameType == eNonIPPacket) - { + if (stEthCsPktInfo.eNwpktIPFrameType == eNonIPPacket) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, " ClassifyPacket : Packet is Not an IP Packet\n"); bClassificationSucceed = false; break; @@ -598,31 +539,26 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb) } while (0); } - if (bClassificationSucceed == TRUE) - { + if (bClassificationSucceed == TRUE) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "CF id : %d, SF ID is =%lu", pstClassifierRule->uiClassifierRuleIndex, pstClassifierRule->ulSFID); //Store The matched Classifier in SKB *((UINT32*)(skb->cb)+SKB_CB_CLASSIFICATION_OFFSET) = pstClassifierRule->uiClassifierRuleIndex; - if ((TCP == pIpHeader->protocol) && !bFragmentedPkt && (ETH_AND_IP_HEADER_LEN + TCP_HEADER_LEN <= skb->len)) - { + if ((TCP == pIpHeader->protocol) && !bFragmentedPkt && (ETH_AND_IP_HEADER_LEN + TCP_HEADER_LEN <= skb->len)) { IpHeaderLength = pIpHeader->ihl; pTcpHeader = (struct bcm_tcp_header *)(((PUCHAR)pIpHeader)+(IpHeaderLength*4)); TcpHeaderLength = GET_TCP_HEADER_LEN(pTcpHeader->HeaderLength); if ((pTcpHeader->ucFlags & TCP_ACK) && (ntohs(pIpHeader->tot_len) == (IpHeaderLength*4)+(TcpHeaderLength*4))) - { *((UINT32*) (skb->cb) + SKB_CB_TCPACK_OFFSET) = TCP_ACK; - } } usIndex = SearchSfid(Adapter, pstClassifierRule->ulSFID); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "index is =%d", usIndex); //If this is the first fragment of a Fragmented pkt, add this CF. Only This CF should be used for all other fragment of this Pkt. - if (bFragmentedPkt && (usCurrFragment == 0)) - { + if (bFragmentedPkt && (usCurrFragment == 0)) { //First Fragment of Fragmented Packet. Create Frag CLS Entry struct bcm_fragmented_packet_info stFragPktInfo; stFragPktInfo.bUsed = TRUE; @@ -649,8 +585,7 @@ static bool EthCSMatchSrcMACAddress(struct bcm_classifier_rule *pstClassifierRul if (pstClassifierRule->ucEthCSSrcMACLen == 0) return TRUE; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s\n", __FUNCTION__); - for (i = 0; i < MAC_ADDRESS_SIZE; i++) - { + for (i = 0; i < MAC_ADDRESS_SIZE; i++) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "SRC MAC[%x] = %x ClassifierRuleSrcMAC = %x Mask : %x\n", i, Mac[i], pstClassifierRule->au8EThCSSrcMAC[i], pstClassifierRule->au8EThCSSrcMACMask[i]); if ((pstClassifierRule->au8EThCSSrcMAC[i] & pstClassifierRule->au8EThCSSrcMACMask[i]) != (Mac[i] & pstClassifierRule->au8EThCSSrcMACMask[i])) @@ -666,8 +601,7 @@ static bool EthCSMatchDestMACAddress(struct bcm_classifier_rule *pstClassifierRu if (pstClassifierRule->ucEthCSDestMACLen == 0) return TRUE; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s\n", __FUNCTION__); - for (i = 0; i < MAC_ADDRESS_SIZE; i++) - { + for (i = 0; i < MAC_ADDRESS_SIZE; i++) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "SRC MAC[%x] = %x ClassifierRuleSrcMAC = %x Mask : %x\n", i, Mac[i], pstClassifierRule->au8EThCSDestMAC[i], pstClassifierRule->au8EThCSDestMACMask[i]); if ((pstClassifierRule->au8EThCSDestMAC[i] & pstClassifierRule->au8EThCSDestMACMask[i]) != (Mac[i] & pstClassifierRule->au8EThCSDestMACMask[i])) @@ -684,8 +618,7 @@ static bool EthCSMatchEThTypeSAP(struct bcm_classifier_rule *pstClassifierRule, return TRUE; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s SrcEtherType:%x CLS EtherType[0]:%x\n", __FUNCTION__, pstEthCsPktInfo->usEtherType, pstClassifierRule->au8EthCSEtherType[0]); - if (pstClassifierRule->au8EthCSEtherType[0] == 1) - { + if (pstClassifierRule->au8EthCSEtherType[0] == 1) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s CLS EtherType[1]:%x EtherType[2]:%x\n", __FUNCTION__, pstClassifierRule->au8EthCSEtherType[1], pstClassifierRule->au8EthCSEtherType[2]); if (memcmp(&pstEthCsPktInfo->usEtherType, &pstClassifierRule->au8EthCSEtherType[1], 2) == 0) @@ -694,8 +627,7 @@ static bool EthCSMatchEThTypeSAP(struct bcm_classifier_rule *pstClassifierRule, return false; } - if (pstClassifierRule->au8EthCSEtherType[0] == 2) - { + if (pstClassifierRule->au8EthCSEtherType[0] == 2) { if (eEth802LLCFrame != pstEthCsPktInfo->eNwpktEthFrameType) return false; @@ -721,8 +653,7 @@ static bool EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule, s BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s CLS UserPrio:%x CLS VLANID:%x\n", __FUNCTION__, ntohs(*((USHORT *)pstClassifierRule->usUserPriority)), pstClassifierRule->usVLANID); /* In case FW didn't receive the TLV, the priority field should be ignored */ - if (pstClassifierRule->usValidityBitMap & (1<usValidityBitMap & (1<eNwpktEthFrameType != eEth802QVLANFrame) return false; @@ -739,8 +670,7 @@ static bool EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule, s bClassificationSucceed = false; - if (pstClassifierRule->usValidityBitMap & (1<usValidityBitMap & (1<eNwpktEthFrameType != eEth802QVLANFrame) return false; @@ -800,32 +730,24 @@ static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter, PVOID pvEthPayload USHORT u16Etype = ntohs(((struct bcm_eth_header *)pvEthPayload)->u16Etype); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCSGetPktInfo : Eth Hdr Type : %X\n", u16Etype); - if (u16Etype > 0x5dc) - { + if (u16Etype > 0x5dc) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCSGetPktInfo : ETH2 Frame\n"); //ETH2 Frame - if (u16Etype == ETHERNET_FRAMETYPE_802QVLAN) - { + if (u16Etype == ETHERNET_FRAMETYPE_802QVLAN) { //802.1Q VLAN Header pstEthCsPktInfo->eNwpktEthFrameType = eEth802QVLANFrame; u16Etype = ((struct bcm_eth_q_frame *)pvEthPayload)->EthType; //((ETH_CS_802_Q_FRAME*)pvEthPayload)->UserPriority - } - else - { + } else { pstEthCsPktInfo->eNwpktEthFrameType = eEthOtherFrame; u16Etype = ntohs(u16Etype); } - - } - else - { + } else { //802.2 LLC BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "802.2 LLC Frame\n"); pstEthCsPktInfo->eNwpktEthFrameType = eEth802LLCFrame; pstEthCsPktInfo->ucDSAP = ((struct bcm_eth_llc_frame *)pvEthPayload)->DSAP; - if (pstEthCsPktInfo->ucDSAP == 0xAA && ((struct bcm_eth_llc_frame *)pvEthPayload)->SSAP == 0xAA) - { + if (pstEthCsPktInfo->ucDSAP == 0xAA && ((struct bcm_eth_llc_frame *)pvEthPayload)->SSAP == 0xAA) { //SNAP Frame pstEthCsPktInfo->eNwpktEthFrameType = eEth802LLCSNAPFrame; u16Etype = ((struct bcm_eth_llc_snap_frame *)pvEthPayload)->usEtherType; -- cgit v1.2.3 From 9f9e1e0ff3980b73da94b1b3b12779581a2ae580 Mon Sep 17 00:00:00 2001 From: Joel Porquet Date: Wed, 9 Apr 2014 20:09:45 +0200 Subject: staging: iio: fix coding style As suggested by checkpatch.pl, use dev_info() instead of printk(KERN_INFO ...) to print message. Signed-off-by: Joel Porquet Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/trigger/iio-trig-periodic-rtc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c index 48a6afa84088..38ecb4bb6e4c 100644 --- a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c +++ b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c @@ -33,7 +33,8 @@ static int iio_trig_periodic_rtc_set_state(struct iio_trigger *trig, bool state) struct iio_prtc_trigger_info *trig_info = iio_trigger_get_drvdata(trig); if (trig_info->frequency == 0) return -EINVAL; - printk(KERN_INFO "trigger frequency is %d\n", trig_info->frequency); + dev_info(&trig_info->rtc->dev, "trigger frequency is %d\n", + trig_info->frequency); return rtc_irq_set_state(trig_info->rtc, &trig_info->task, state); } -- cgit v1.2.3 From 8f2150dd8e6f0eb39b739e64949e98a72755599b Mon Sep 17 00:00:00 2001 From: Michael Welling Date: Wed, 9 Apr 2014 21:26:43 -0500 Subject: Staging: iio: Removes unwanted space before semicolon Signed-off-by: Michael Welling Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/light/tsl2583.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index 0a60def92735..77c7f65c3762 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -211,7 +211,7 @@ static int taos_get_lux(struct iio_dev *indio_dev) if (chip->taos_chip_status != TSL258X_CHIP_WORKING) { /* device is not enabled */ dev_err(&chip->client->dev, "taos_get_lux device is not enabled\n"); - ret = -EBUSY ; + ret = -EBUSY; goto out_unlock; } -- cgit v1.2.3 From b47b894c6002d36ac93e4cc82139c7e7157a0f19 Mon Sep 17 00:00:00 2001 From: Michael Welling Date: Wed, 9 Apr 2014 21:26:44 -0500 Subject: Staging: iio: Remove quoted string split across lines warnings Signed-off-by: Michael Welling Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/light/tsl2583.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index 77c7f65c3762..f015fb4c09a8 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -165,8 +165,9 @@ taos_i2c_read(struct i2c_client *client, u8 reg, u8 *val, unsigned int len) /* select register to write */ ret = i2c_smbus_write_byte(client, (TSL258X_CMD_REG | reg)); if (ret < 0) { - dev_err(&client->dev, "taos_i2c_read failed to write" - " register %x\n", reg); + dev_err(&client->dev, + "taos_i2c_read failed to write register %x\n", + reg); return ret; } /* read the data */ @@ -231,8 +232,9 @@ static int taos_get_lux(struct iio_dev *indio_dev) int reg = TSL258X_CMD_REG | (TSL258X_ALS_CHAN0LO + i); ret = taos_i2c_read(chip->client, reg, &buf[i], 1); if (ret < 0) { - dev_err(&chip->client->dev, "taos_get_lux failed to read" - " register %x\n", reg); + dev_err(&chip->client->dev, + "taos_get_lux failed to read register %x\n", + reg); goto out_unlock; } } @@ -809,9 +811,7 @@ static int taos_probe(struct i2c_client *clientp, if (!i2c_check_functionality(clientp->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { - dev_err(&clientp->dev, - "taos_probe() - i2c smbus byte data " - "functions unsupported\n"); + dev_err(&clientp->dev, "taos_probe() - i2c smbus byte data func unsupported\n"); return -EOPNOTSUPP; } @@ -830,30 +830,32 @@ static int taos_probe(struct i2c_client *clientp, ret = i2c_smbus_write_byte(clientp, (TSL258X_CMD_REG | (TSL258X_CNTRL + i))); if (ret < 0) { - dev_err(&clientp->dev, "i2c_smbus_write_bytes() to cmd " - "reg failed in taos_probe(), err = %d\n", ret); + dev_err(&clientp->dev, + "i2c_smbus_write_byte to cmd reg failed in taos_probe(), err = %d\n", + ret); return ret; } ret = i2c_smbus_read_byte(clientp); if (ret < 0) { - dev_err(&clientp->dev, "i2c_smbus_read_byte from " - "reg failed in taos_probe(), err = %d\n", ret); - + dev_err(&clientp->dev, + "i2c_smbus_read_byte from reg failed in taos_probe(), err = %d\n", + ret); return ret; } buf[i] = ret; } if (!taos_tsl258x_device(buf)) { - dev_info(&clientp->dev, "i2c device found but does not match " - "expected id in taos_probe()\n"); + dev_info(&clientp->dev, + "i2c device found but does not match expected id in taos_probe()\n"); return -EINVAL; } ret = i2c_smbus_write_byte(clientp, (TSL258X_CMD_REG | TSL258X_CNTRL)); if (ret < 0) { - dev_err(&clientp->dev, "i2c_smbus_write_byte() to cmd reg " - "failed in taos_probe(), err = %d\n", ret); + dev_err(&clientp->dev, + "i2c_smbus_write_byte() to cmd reg failed in taos_probe(), err = %d\n", + ret); return ret; } -- cgit v1.2.3 From 7fe704ce6af8f5996ebde436afdb9fa2599a7384 Mon Sep 17 00:00:00 2001 From: Michael Welling Date: Wed, 9 Apr 2014 21:26:45 -0500 Subject: Staging: iio: Switch from msleep to usleep range per timers-howto.txt Signed-off-by: Michael Welling Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/light/tsl2583.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index f015fb4c09a8..fa9649879662 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -451,7 +451,7 @@ static int taos_chip_on(struct iio_dev *indio_dev) } } - msleep(3); + usleep_range(3000, 3500); /* NOW enable the ADC * initialize the desired mode of operation */ utmp = TSL258X_CNTL_PWR_ON | TSL258X_CNTL_ADC_ENBL; -- cgit v1.2.3 From dab3775c6cf8cb47d8cb7af273c375e0ebde523f Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Thu, 10 Apr 2014 13:34:58 +0100 Subject: staging: rtl8821ae: Fix whitespace in rtl8821ae/hw.h Fix checkpatch warnings, lines over 80 chars using tabs where possible. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/rtl8821ae/hw.h | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8821ae/rtl8821ae/hw.h b/drivers/staging/rtl8821ae/rtl8821ae/hw.h index 4fb6bf0d1da2..3f2068175345 100644 --- a/drivers/staging/rtl8821ae/rtl8821ae/hw.h +++ b/drivers/staging/rtl8821ae/rtl8821ae/hw.h @@ -34,42 +34,43 @@ void rtl8821ae_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val); void rtl8821ae_read_eeprom_info(struct ieee80211_hw *hw); void rtl8821ae_interrupt_recognized(struct ieee80211_hw *hw, - u32 *p_inta, u32 *p_intb); + u32 *p_inta, u32 *p_intb); int rtl8821ae_hw_init(struct ieee80211_hw *hw); void rtl8821ae_card_disable(struct ieee80211_hw *hw); void rtl8821ae_enable_interrupt(struct ieee80211_hw *hw); void rtl8821ae_disable_interrupt(struct ieee80211_hw *hw); -int rtl8821ae_set_network_type(struct ieee80211_hw *hw, enum nl80211_iftype type); +int rtl8821ae_set_network_type(struct ieee80211_hw *hw, + enum nl80211_iftype type); void rtl8821ae_set_check_bssid(struct ieee80211_hw *hw, bool check_bssid); void rtl8821ae_set_qos(struct ieee80211_hw *hw, int aci); void rtl8821ae_set_beacon_related_registers(struct ieee80211_hw *hw); void rtl8821ae_set_beacon_interval(struct ieee80211_hw *hw); void rtl8821ae_update_interrupt_mask(struct ieee80211_hw *hw, - u32 add_msr, u32 rm_msr); + u32 add_msr, u32 rm_msr); void rtl8821ae_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val); void rtl8821ae_update_hal_rate_tbl(struct ieee80211_hw *hw, - struct ieee80211_sta *sta, - u8 rssi_level); + struct ieee80211_sta *sta, + u8 rssi_level); void rtl8821ae_update_channel_access_setting(struct ieee80211_hw *hw); bool rtl8821ae_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid); void rtl8821ae_enable_hw_security_config(struct ieee80211_hw *hw); void rtl8821ae_set_key(struct ieee80211_hw *hw, u32 key_index, - u8 *p_macaddr, bool is_group, u8 enc_algo, - bool is_wepkey, bool clear_all); + u8 *p_macaddr, bool is_group, u8 enc_algo, + bool is_wepkey, bool clear_all); void rtl8821ae_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw, - bool autoload_fail, - u8* hwinfo); + bool autoload_fail, + u8* hwinfo); void rtl8812ae_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw, - bool autoload_fail, - u8* hwinfo); + bool autoload_fail, + u8* hwinfo); void rtl8821ae_bt_reg_init(struct ieee80211_hw* hw); void rtl8821ae_bt_hw_init(struct ieee80211_hw* hw); void rtl8821ae_suspend(struct ieee80211_hw *hw); void rtl8821ae_resume(struct ieee80211_hw *hw); void rtl8821ae_allow_all_destaddr(struct ieee80211_hw *hw, - bool allow_all_da, - bool write_into_reg); + bool allow_all_da, + bool write_into_reg); void _rtl8821ae_stop_tx_beacon(struct ieee80211_hw *hw); void _rtl8821ae_resume_tx_beacon(struct ieee80211_hw *hw); #endif -- cgit v1.2.3 From f6d49cb0ffd57fa8068e1f5607cf9d2dcd8118d0 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Thu, 10 Apr 2014 13:34:59 +0100 Subject: staging: rtl8821ae: Remove FSF mailing address from rtl8821ae/hw.h header Fix checkpatch check: CHECK: Do not include the paragraph about writing to the Free Software Foundation's mailing address from the sample GPL notice. The FSF has changed addresses in the past, and may do so again. Linux already includes a copy of the GPL. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/rtl8821ae/hw.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/rtl8821ae/rtl8821ae/hw.h b/drivers/staging/rtl8821ae/rtl8821ae/hw.h index 3f2068175345..335d4ab5e39f 100644 --- a/drivers/staging/rtl8821ae/rtl8821ae/hw.h +++ b/drivers/staging/rtl8821ae/rtl8821ae/hw.h @@ -11,10 +11,6 @@ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * * The full GNU General Public License is included in this distribution in the * file called LICENSE. * -- cgit v1.2.3 From bd2715f6e7023aa9ba9779e92e1baf2a48292383 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Thu, 10 Apr 2014 13:35:00 +0100 Subject: staging: rtl8821ae: Fix rtl8821ae/hw.h pointer declaration style Fix all occurences of the checkpatch error: ERROR: "foo* bar" should be "foo *bar" Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/rtl8821ae/hw.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8821ae/rtl8821ae/hw.h b/drivers/staging/rtl8821ae/rtl8821ae/hw.h index 335d4ab5e39f..256e514f424a 100644 --- a/drivers/staging/rtl8821ae/rtl8821ae/hw.h +++ b/drivers/staging/rtl8821ae/rtl8821ae/hw.h @@ -56,12 +56,12 @@ void rtl8821ae_set_key(struct ieee80211_hw *hw, u32 key_index, void rtl8821ae_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw, bool autoload_fail, - u8* hwinfo); + u8 *hwinfo); void rtl8812ae_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw, bool autoload_fail, - u8* hwinfo); -void rtl8821ae_bt_reg_init(struct ieee80211_hw* hw); -void rtl8821ae_bt_hw_init(struct ieee80211_hw* hw); + u8 *hwinfo); +void rtl8821ae_bt_reg_init(struct ieee80211_hw *hw); +void rtl8821ae_bt_hw_init(struct ieee80211_hw *hw); void rtl8821ae_suspend(struct ieee80211_hw *hw); void rtl8821ae_resume(struct ieee80211_hw *hw); void rtl8821ae_allow_all_destaddr(struct ieee80211_hw *hw, -- cgit v1.2.3 From 2c44ef7526b8f0fe16e461065539076c538d36ac Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Fri, 21 Mar 2014 10:41:10 -0400 Subject: staging: dgap: Remove some unused code in dgap.c This patch removes some unused code in dgap.c. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index a5fc3c75ed4e..ea66c9f8db5d 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -78,10 +78,6 @@ #include "dgap.h" -#define init_MUTEX(sem) sema_init(sem, 1) -#define DECLARE_MUTEX(name) \ - struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) - MODULE_LICENSE("GPL"); MODULE_AUTHOR("Digi International, http://www.digi.com"); MODULE_DESCRIPTION("Driver for the Digi International EPCA PCI based product line"); @@ -245,9 +241,7 @@ static struct board_t *dgap_Board[MAXBOARDS]; static ulong dgap_poll_counter; static char *dgap_config_buf; static int dgap_driver_state = DRIVER_INITIALIZED; -DEFINE_SPINLOCK(dgap_dl_lock); static wait_queue_head_t dgap_dl_wait; -static int dgap_dl_action; static int dgap_poll_tick = 20; /* Poll interval - 20 ms */ /* @@ -1197,7 +1191,6 @@ static void dgap_init_globals(void) init_timer(&dgap_poll_timer); init_waitqueue_head(&dgap_dl_wait); - dgap_dl_action = 0; } /************************************************************************ -- cgit v1.2.3 From 35ed972362fba5253846d5353c31670b428c3fc7 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Fri, 21 Mar 2014 10:41:11 -0400 Subject: staging: dgap: Remove some unneeded comments This patch removes some unneeded comments from dgap.c Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index ea66c9f8db5d..ea920e41dc0a 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -12,21 +12,6 @@ * 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. - * - * - * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! - * - * This is shared code between Digi's CVS archive and the - * Linux Kernel sources. - * Changing the source just for reformatting needlessly breaks - * our CVS diff history. - * - * Send any bug fixes/changes to: Eng.Linux at digi dot com. - * Thank you. - * */ /* @@ -83,12 +68,6 @@ MODULE_AUTHOR("Digi International, http://www.digi.com"); MODULE_DESCRIPTION("Driver for the Digi International EPCA PCI based product line"); MODULE_SUPPORTED_DEVICE("dgap"); -/************************************************************************** - * - * protos for this file - * - */ - static int dgap_start(void); static void dgap_init_globals(void); static int dgap_found_board(struct pci_dev *pdev, int id); @@ -101,7 +80,6 @@ static int dgap_probe1(struct pci_dev *pdev, int card_type); static int dgap_do_remap(struct board_t *brd); static irqreturn_t dgap_intr(int irq, void *voidbrd); -/* Our function prototypes */ static int dgap_tty_open(struct tty_struct *tty, struct file *file); static void dgap_tty_close(struct tty_struct *tty, struct file *file); static int dgap_block_til_ready(struct tty_struct *tty, struct file *file, @@ -221,7 +199,6 @@ static int dgap_do_wait_for_fep(struct board_t *brd); static int dgap_tty_register_ports(struct board_t *brd); static int dgap_firmware_load(struct pci_dev *pdev, int card_type); -/* Driver unload function */ static void dgap_cleanup_module(void); module_exit(dgap_cleanup_module); @@ -233,9 +210,6 @@ static const struct file_operations DgapBoardFops = { .owner = THIS_MODULE, }; -/* - * Globals - */ static uint dgap_NumBoards; static struct board_t *dgap_Board[MAXBOARDS]; static ulong dgap_poll_counter; @@ -244,9 +218,6 @@ static int dgap_driver_state = DRIVER_INITIALIZED; static wait_queue_head_t dgap_dl_wait; static int dgap_poll_tick = 20; /* Poll interval - 20 ms */ -/* - * Static vars. - */ static struct class *dgap_class; static struct board_t *dgap_BoardsByMajor[256]; -- cgit v1.2.3 From 084eb9d75b9f3bc0f8c8eb0c4010fbfb6f7b89c6 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Fri, 21 Mar 2014 10:41:12 -0400 Subject: staging: dgap: fix some whitespace warnings in dgap.h This patch fixes some whitespace warnings as reported by checkpatch in dgap.h. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.h | 47 +++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h index 6b8f5f858327..1466901ca02f 100644 --- a/drivers/staging/dgap/dgap.h +++ b/drivers/staging/dgap/dgap.h @@ -61,7 +61,7 @@ typedef unsigned char uchar; /* * defines from dgap_pci.h - */ + */ #define PCIMAX 32 /* maximum number of PCI boards */ #define DIGI_VID 0x114F @@ -209,7 +209,8 @@ typedef unsigned char uchar; #define FEP5_PLUS 0x0E40 /* ASCII '5' and ASCII 'A' is here */ #define ECS_SEG 0x0E44 /* Segment of the extended channel structure */ #define LINE_SPEED 0x10 /* Offset into ECS_SEG for line speed */ - /* if the fep has extended capabilities */ + /* if the fep has extended */ + /* capabilities */ /* BIOS MAGIC SPOTS */ #define ERROR 0x0C14L /* BIOS error code */ @@ -362,13 +363,13 @@ typedef unsigned char uchar; #define MC8E8K 36 #define AVANFS 42 /* start of Avanstar family definitions */ -#define A8P 42 +#define A8P 42 #define A16P 43 #define AVANFE 43 /* end of Avanstar family definitions */ #define DA2000FS 44 /* start of AccelePort 2000 family definitions */ -#define DA22 44 /* AccelePort 2002 */ -#define DA24 45 /* AccelePort 2004 */ +#define DA22 44 /* AccelePort 2002 */ +#define DA24 45 /* AccelePort 2004 */ #define DA28 46 /* AccelePort 2008 */ #define DA216 47 /* AccelePort 2016 */ #define DAR4 48 /* AccelePort RAS 4 port */ @@ -578,7 +579,7 @@ struct board_t { ulong membase; /* Start of base memory of the card */ ulong membase_end; /* End of base memory of the card */ - uchar *re_map_port; /* Remapped io port of the card */ + uchar *re_map_port; /* Remapped io port of the card */ uchar *re_map_membase;/* Remapped memory of the card */ uchar runwait; /* # Processes waiting for FEP */ @@ -737,26 +738,26 @@ struct un_t { /* Adapter Memory */ #define DIGI_GETFLOW (('e'<<8) | 99) /* Get startc/stopc flow */ - /* control characters */ -#define DIGI_SETFLOW (('e'<<8) | 100) /* Set startc/stopc flow */ + /* control characters */ +#define DIGI_SETFLOW (('e'<<8) | 100) /* Set startc/stopc flow */ /* control characters */ -#define DIGI_GETAFLOW (('e'<<8) | 101) /* Get Aux. startc/stopc */ - /* flow control chars */ -#define DIGI_SETAFLOW (('e'<<8) | 102) /* Set Aux. startc/stopc */ +#define DIGI_GETAFLOW (('e'<<8) | 101) /* Get Aux. startc/stopc */ + /* flow control chars */ +#define DIGI_SETAFLOW (('e'<<8) | 102) /* Set Aux. startc/stopc */ /* flow control chars */ -#define DIGI_GEDELAY (('d'<<8) | 246) /* Get edelay */ -#define DIGI_SEDELAY (('d'<<8) | 247) /* Set edelay */ +#define DIGI_GEDELAY (('d'<<8) | 246) /* Get edelay */ +#define DIGI_SEDELAY (('d'<<8) | 247) /* Set edelay */ struct digiflow_t { - unsigned char startc; /* flow cntl start char */ - unsigned char stopc; /* flow cntl stop char */ + unsigned char startc; /* flow cntl start char */ + unsigned char stopc; /* flow cntl stop char */ }; #ifdef FLOW_2200 -#define F2200_GETA (('e'<<8) | 104) /* Get 2x36 flow cntl flags */ -#define F2200_SETAW (('e'<<8) | 105) /* Set 2x36 flow cntl flags */ +#define F2200_GETA (('e'<<8) | 104) /* Get 2x36 flow cntl flags */ +#define F2200_SETAW (('e'<<8) | 105) /* Set 2x36 flow cntl flags */ #define F2200_MASK 0x03 /* 2200 flow cntl bit mask */ #define FCNTL_2200 0x01 /* 2x36 terminal flow cntl */ #define PCNTL_2200 0x02 /* 2x36 printer flow cntl */ @@ -873,7 +874,7 @@ struct shrink_buf_struct { xxinit call. */ unsigned char shrink_buf_anports; /* Number of async ports */ - unsigned char shrink_buf_snports; /* Number of sync ports */ + unsigned char shrink_buf_snports; /* Number of sync ports */ unsigned char shrink_buf_type; /* Board type 1 = PC/Xi, 2 = PC/Xm, 3 = PC/Xe @@ -936,9 +937,9 @@ struct digi_stat { struct digi_ch { unsigned long info_bdnum; /* Board number (0 based) */ unsigned long info_channel; /* Channel index number */ - unsigned long info_ch_cflag; /* Channel cflag */ - unsigned long info_ch_iflag; /* Channel iflag */ - unsigned long info_ch_oflag; /* Channel oflag */ + unsigned long info_ch_cflag; /* Channel cflag */ + unsigned long info_ch_iflag; /* Channel iflag */ + unsigned long info_ch_oflag; /* Channel oflag */ unsigned long info_chsize; /* Channel structure size */ unsigned long info_sleep_stat; /* sleep status */ dev_t info_dev; /* device number */ @@ -1208,7 +1209,7 @@ struct bs_t { volatile unsigned char stopc; /* W Xoff character */ volatile unsigned char vnextc; /* W Vnext character */ volatile unsigned char hflow; /* C Software flow control */ - + volatile unsigned char fillc; /* U Delay Fill character */ volatile unsigned char ochar; /* U Saved output character */ volatile unsigned char omask; /* U Output character mask */ @@ -1225,7 +1226,7 @@ struct cnode { union { struct { - char type; /* Board Type */ + char type; /* Board Type */ long port; /* I/O Address */ char *portstr; /* I/O Address in string */ long addr; /* Memory Address */ -- cgit v1.2.3 From d68dcfc18034c8ff8a8a8e054e776211a7dafdb2 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Fri, 21 Mar 2014 10:41:13 -0400 Subject: staging: dgap: Fix several 80+ line warnings in dgap.h This patch fixes several 80+ char line warnings as reported by checkpatch in dgap.h Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.h | 244 +++++++++++++++++++++++--------------------- 1 file changed, 129 insertions(+), 115 deletions(-) diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h index 1466901ca02f..2913f6e3def5 100644 --- a/drivers/staging/dgap/dgap.h +++ b/drivers/staging/dgap/dgap.h @@ -207,9 +207,10 @@ typedef unsigned char uchar; #define EVSTART 0x0800L /* Start of event buffer */ #define EVMAX 0x0c00L /* End of event buffer */ #define FEP5_PLUS 0x0E40 /* ASCII '5' and ASCII 'A' is here */ -#define ECS_SEG 0x0E44 /* Segment of the extended channel structure */ -#define LINE_SPEED 0x10 /* Offset into ECS_SEG for line speed */ - /* if the fep has extended */ +#define ECS_SEG 0x0E44 /* Segment of the extended */ + /* channel structure */ +#define LINE_SPEED 0x10 /* Offset into ECS_SEG for line */ + /* speed if the fep has extended */ /* capabilities */ /* BIOS MAGIC SPOTS */ @@ -248,12 +249,12 @@ typedef unsigned char uchar; #define FEPTIMEOUT 200000 -#define ENABLE_INTR 0x0e04 /* Enable interrupts flag */ -#define FEPPOLL_MIN 1 /* minimum of 1 millisecond */ -#define FEPPOLL_MAX 20 /* maximum of 20 milliseconds */ -#define FEPPOLL 0x0c26 /* Fep event poll interval */ +#define ENABLE_INTR 0x0e04 /* Enable interrupts flag */ +#define FEPPOLL_MIN 1 /* minimum of 1 millisecond */ +#define FEPPOLL_MAX 20 /* maximum of 20 milliseconds */ +#define FEPPOLL 0x0c26 /* Fep event poll interval */ -#define IALTPIN 0x0080 /* Input flag to swap DSR <-> DCD */ +#define IALTPIN 0x0080 /* Input flag to swap DSR <-> DCD */ /************************************************************************ * FEP supported functions @@ -367,7 +368,7 @@ typedef unsigned char uchar; #define A16P 43 #define AVANFE 43 /* end of Avanstar family definitions */ -#define DA2000FS 44 /* start of AccelePort 2000 family definitions */ +#define DA2000FS 44 /* start of AccelePort 2000 family definitions */ #define DA22 44 /* AccelePort 2002 */ #define DA24 45 /* AccelePort 2004 */ #define DA28 46 /* AccelePort 2008 */ @@ -572,7 +573,8 @@ struct board_t { ulong irq; /* Interrupt request number */ ulong intr_count; /* Count of interrupts */ u32 intr_used; /* Non-zero if using interrupts */ - u32 intr_running; /* Non-zero if FEP knows its doing interrupts */ + u32 intr_running; /* Non-zero if FEP knows its doing */ + /* interrupts */ ulong port; /* Start of base io port of the card */ ulong port_end; /* End of base io port of the card */ @@ -583,9 +585,10 @@ struct board_t { uchar *re_map_membase;/* Remapped memory of the card */ uchar runwait; /* # Processes waiting for FEP */ - uchar inhibit_poller; /* Tells the poller to leave us alone */ + uchar inhibit_poller; /* Tells the poller to leave us alone */ - struct channel_t *channels[MAXPORTS]; /* array of pointers to our channels. */ + struct channel_t *channels[MAXPORTS]; /* array of pointers to our */ + /* channels. */ struct tty_driver *SerialDriver; struct tty_port *SerialPorts; @@ -600,16 +603,21 @@ struct board_t { u32 dgap_Serial_Major; u32 dgap_TransparentPrint_Major; - struct bs_t *bd_bs; /* Base structure pointer */ + struct bs_t *bd_bs; /* Base structure pointer */ - char *flipbuf; /* Our flip buffer, alloced if board is found */ - char *flipflagbuf; /* Our flip flag buffer, alloced if board is found */ + char *flipbuf; /* Our flip buffer, alloced if */ + /* board is found */ + char *flipflagbuf; /* Our flip flag buffer, alloced */ + /* if board is found */ - u16 dpatype; /* The board "type", as defined by DPA */ - u16 dpastatus; /* The board "status", as defined by DPA */ - wait_queue_head_t kme_wait; /* Needed for DPA support */ + u16 dpatype; /* The board "type", as defined */ + /* by DPA */ + u16 dpastatus; /* The board "status", as defined */ + /* by DPA */ + wait_queue_head_t kme_wait; /* Needed for DPA support */ - u32 conc_dl_status; /* Status of any pending conc download */ + u32 conc_dl_status; /* Status of any pending conc */ + /* download */ }; @@ -690,8 +698,8 @@ struct un_t { #if !defined(TIOCMODG) -#define TIOCMODG (('d'<<8) | 250) /* get modem ctrl state */ -#define TIOCMODS (('d'<<8) | 251) /* set modem ctrl state */ +#define TIOCMODG (('d'<<8) | 250) /* get modem ctrl state */ +#define TIOCMODS (('d'<<8) | 251) /* set modem ctrl state */ #ifndef TIOCM_LE #define TIOCM_LE 0x01 /* line enable */ @@ -710,13 +718,13 @@ struct un_t { #endif #if !defined(TIOCMSET) -#define TIOCMSET (('d'<<8) | 252) /* set modem ctrl state */ -#define TIOCMGET (('d'<<8) | 253) /* set modem ctrl state */ +#define TIOCMSET (('d'<<8) | 252) /* set modem ctrl state */ +#define TIOCMGET (('d'<<8) | 253) /* set modem ctrl state */ #endif #if !defined(TIOCMBIC) -#define TIOCMBIC (('d'<<8) | 254) /* set modem ctrl state */ -#define TIOCMBIS (('d'<<8) | 255) /* set modem ctrl state */ +#define TIOCMBIC (('d'<<8) | 254) /* set modem ctrl state */ +#define TIOCMBIS (('d'<<8) | 255) /* set modem ctrl state */ #endif @@ -853,9 +861,9 @@ struct shrink_buf_struct { unsigned long shrink_buf_vaddr; /* Virtual address of board */ unsigned long shrink_buf_phys; /* Physical address of board */ unsigned long shrink_buf_bseg; /* Amount of board memory */ - unsigned long shrink_buf_hseg; /* '186 Beginning of Dual-Port */ + unsigned long shrink_buf_hseg; /* 186 Beginning of Dual-Port */ - unsigned long shrink_buf_lseg; /* '186 Beginning of freed memory */ + unsigned long shrink_buf_lseg; /* 186 Beginning of freed mem */ unsigned long shrink_buf_mseg; /* Linear address from start of dual-port were freed memory begins, host viewpoint. */ @@ -893,7 +901,7 @@ struct digi_dinfo { char dinfo_version[16]; /* driver version */ }; -#define DIGI_GETDD (('d'<<8) | 248) /* get driver info */ +#define DIGI_GETDD (('d'<<8) | 248) /* get driver info */ /************************************************************************ * Structure used with ioctl commands for per-board information @@ -913,7 +921,7 @@ struct digi_info { char info_reserved[7]; /* for future expansion */ }; -#define DIGI_GETBD (('d'<<8) | 249) /* get board info */ +#define DIGI_GETBD (('d'<<8) | 249) /* get board info */ struct digi_stat { unsigned int info_chan; /* Channel number (0 based) */ @@ -928,7 +936,7 @@ struct digi_stat { unsigned long info_reserved[8]; /* for future expansion */ }; -#define DIGI_GETSTAT (('d'<<8) | 244) /* get board info */ +#define DIGI_GETSTAT (('d'<<8) | 244) /* get board info */ /************************************************************************ * * Structure used with ioctl commands for per-channel information @@ -971,7 +979,7 @@ struct digi_cmd { #define INFO_CH_WLOW 0x0020 #define INFO_XXBUF_BUSY 0x0040 -#define DIGI_GETCH (('d'<<8) | 245) /* get board info */ +#define DIGI_GETCH (('d'<<8) | 245) /* get board info */ /* Board type definitions */ @@ -1016,12 +1024,13 @@ struct digi_cmd { #define BD_TRIBOOT 0x8 #define BD_BADKME 0x80 -#define DIGI_LOOPBACK (('d'<<8) | 252) /* Enable/disable UART internal loopback */ -#define DIGI_SPOLL (('d'<<8) | 254) /* change poller rate */ +#define DIGI_LOOPBACK (('d'<<8) | 252) /* Enable/disable UART */ + /* internal loopback */ +#define DIGI_SPOLL (('d'<<8) | 254) /* change poller rate */ -#define DIGI_SETCUSTOMBAUD _IOW('e', 106, int) /* Set integer baud rate */ -#define DIGI_GETCUSTOMBAUD _IOR('e', 107, int) /* Get integer baud rate */ -#define DIGI_RESET_PORT (('e'<<8) | 93) /* Reset port */ +#define DIGI_SETCUSTOMBAUD _IOW('e', 106, int) /* Set integer baud rate */ +#define DIGI_GETCUSTOMBAUD _IOR('e', 107, int) /* Get integer baud rate */ +#define DIGI_RESET_PORT (('e'<<8) | 93) /* Reset port */ /************************************************************************ * Channel information structure. @@ -1049,7 +1058,8 @@ struct channel_t { u32 ch_flags; /* Channel flags */ - u32 ch_close_delay; /* How long we should drop RTS/DTR for */ + u32 ch_close_delay; /* How long we should drop */ + /* RTS/DTR for */ u32 ch_cpstime; /* Time for CPS calculations */ @@ -1058,7 +1068,7 @@ struct channel_t { tcflag_t ch_c_oflag; /* channel oflags */ tcflag_t ch_c_lflag; /* channel lflags */ - u16 ch_fepiflag; /* FEP tty iflags */ + u16 ch_fepiflag; /* FEP tty iflags */ u16 ch_fepcflag; /* FEP tty cflags */ u16 ch_fepoflag; /* FEP tty oflags */ u16 ch_wopen; /* Waiting for open process cnt */ @@ -1094,11 +1104,11 @@ struct channel_t { uchar ch_tx_win; /* channel tx buffer window */ uchar ch_rx_win; /* channel rx buffer window */ uint ch_custom_speed; /* Custom baud, if set */ - uint ch_baud_info; /* Current baud info for /proc output */ - ulong ch_rxcount; /* total of data received so far */ - ulong ch_txcount; /* total of data transmitted so far */ - ulong ch_err_parity; /* Count of parity errors on channel */ - ulong ch_err_frame; /* Count of framing errors on channel */ + uint ch_baud_info; /* Current baud info for /proc output */ + ulong ch_rxcount; /* total of data received so far */ + ulong ch_txcount; /* total of data transmitted so far */ + ulong ch_err_parity; /* Count of parity errors on channel */ + ulong ch_err_frame; /* Count of framing errors on channel */ ulong ch_err_break; /* Count of breaks on channel */ ulong ch_err_overrun; /* Count of overruns on channel */ @@ -1113,20 +1123,20 @@ struct channel_t { * Command structure definition. ************************************************************************/ struct cm_t { - volatile unsigned short cm_head; /* Command buffer head offset */ - volatile unsigned short cm_tail; /* Command buffer tail offset */ - volatile unsigned short cm_start; /* start offset of buffer */ - volatile unsigned short cm_max; /* last offset of buffer */ + volatile unsigned short cm_head; /* Command buffer head offset */ + volatile unsigned short cm_tail; /* Command buffer tail offset */ + volatile unsigned short cm_start; /* start offset of buffer */ + volatile unsigned short cm_max; /* last offset of buffer */ }; /************************************************************************ * Event structure definition. ************************************************************************/ struct ev_t { - volatile unsigned short ev_head; /* Command buffer head offset */ - volatile unsigned short ev_tail; /* Command buffer tail offset */ - volatile unsigned short ev_start; /* start offset of buffer */ - volatile unsigned short ev_max; /* last offset of buffer */ + volatile unsigned short ev_head; /* Command buffer head offset */ + volatile unsigned short ev_tail; /* Command buffer tail offset */ + volatile unsigned short ev_start; /* start offset of buffer */ + volatile unsigned short ev_max; /* last offset of buffer */ }; /************************************************************************ @@ -1153,70 +1163,74 @@ struct downld_t { * U = unknown (may be changed w/o notice) * ************************************************************************/ struct bs_t { - volatile unsigned short tp_jmp; /* Transmit poll jump */ - volatile unsigned short tc_jmp; /* Cooked procedure jump */ - volatile unsigned short ri_jmp; /* Not currently used */ - volatile unsigned short rp_jmp; /* Receive poll jump */ - - volatile unsigned short tx_seg; /* W Tx segment */ - volatile unsigned short tx_head; /* W Tx buffer head offset */ - volatile unsigned short tx_tail; /* R Tx buffer tail offset */ - volatile unsigned short tx_max; /* W Tx buffer size - 1 */ - - volatile unsigned short rx_seg; /* W Rx segment */ - volatile unsigned short rx_head; /* W Rx buffer head offset */ - volatile unsigned short rx_tail; /* R Rx buffer tail offset */ - volatile unsigned short rx_max; /* W Rx buffer size - 1 */ - - volatile unsigned short tx_lw; /* W Tx buffer low water mark */ - volatile unsigned short rx_lw; /* W Rx buffer low water mark */ - volatile unsigned short rx_hw; /* W Rx buffer high water mark */ - volatile unsigned short incr; /* W Increment to next channel */ - - volatile unsigned short fepdev; /* U SCC device base address */ - volatile unsigned short edelay; /* W Exception delay */ - volatile unsigned short blen; /* W Break length */ - volatile unsigned short btime; /* U Break complete time */ - - volatile unsigned short iflag; /* C UNIX input flags */ - volatile unsigned short oflag; /* C UNIX output flags */ - volatile unsigned short cflag; /* C UNIX control flags */ - volatile unsigned short wfill[13]; /* U Reserved for expansion */ - - volatile unsigned char num; /* U Channel number */ - volatile unsigned char ract; /* U Receiver active counter */ - volatile unsigned char bstat; /* U Break status bits */ - volatile unsigned char tbusy; /* W Transmit busy */ - volatile unsigned char iempty; /* W Transmit empty event enable */ - volatile unsigned char ilow; /* W Transmit low-water event enable */ - volatile unsigned char idata; /* W Receive data interrupt enable */ - volatile unsigned char eflag; /* U Host event flags */ - - volatile unsigned char tflag; /* U Transmit flags */ - volatile unsigned char rflag; /* U Receive flags */ - volatile unsigned char xmask; /* U Transmit ready flags */ - volatile unsigned char xval; /* U Transmit ready value */ - volatile unsigned char m_stat; /* RC Modem status bits */ - volatile unsigned char m_change; /* U Modem bits which changed */ - volatile unsigned char m_int; /* W Modem interrupt enable bits */ - volatile unsigned char m_last; /* U Last modem status */ - - volatile unsigned char mtran; /* C Unreported modem trans */ - volatile unsigned char orun; /* C Buffer overrun occurred */ - volatile unsigned char astartc; /* W Auxiliary Xon char */ - volatile unsigned char astopc; /* W Auxiliary Xoff char */ - volatile unsigned char startc; /* W Xon character */ - volatile unsigned char stopc; /* W Xoff character */ - volatile unsigned char vnextc; /* W Vnext character */ - volatile unsigned char hflow; /* C Software flow control */ - - volatile unsigned char fillc; /* U Delay Fill character */ - volatile unsigned char ochar; /* U Saved output character */ - volatile unsigned char omask; /* U Output character mask */ - - volatile unsigned char bfill[13]; /* U Reserved for expansion */ - - volatile unsigned char scc[16]; /* U SCC registers */ + volatile unsigned short tp_jmp; /* Transmit poll jump */ + volatile unsigned short tc_jmp; /* Cooked procedure jump */ + volatile unsigned short ri_jmp; /* Not currently used */ + volatile unsigned short rp_jmp; /* Receive poll jump */ + + volatile unsigned short tx_seg; /* W Tx segment */ + volatile unsigned short tx_head; /* W Tx buffer head offset */ + volatile unsigned short tx_tail; /* R Tx buffer tail offset */ + volatile unsigned short tx_max; /* W Tx buffer size - 1 */ + + volatile unsigned short rx_seg; /* W Rx segment */ + volatile unsigned short rx_head; /* W Rx buffer head offset */ + volatile unsigned short rx_tail; /* R Rx buffer tail offset */ + volatile unsigned short rx_max; /* W Rx buffer size - 1 */ + + volatile unsigned short tx_lw; /* W Tx buffer low water mark */ + volatile unsigned short rx_lw; /* W Rx buffer low water mark */ + volatile unsigned short rx_hw; /* W Rx buffer high water mark*/ + volatile unsigned short incr; /* W Increment to next channel*/ + + volatile unsigned short fepdev; /* U SCC device base address */ + volatile unsigned short edelay; /* W Exception delay */ + volatile unsigned short blen; /* W Break length */ + volatile unsigned short btime; /* U Break complete time */ + + volatile unsigned short iflag; /* C UNIX input flags */ + volatile unsigned short oflag; /* C UNIX output flags */ + volatile unsigned short cflag; /* C UNIX control flags */ + volatile unsigned short wfill[13]; /* U Reserved for expansion */ + + volatile unsigned char num; /* U Channel number */ + volatile unsigned char ract; /* U Receiver active counter */ + volatile unsigned char bstat; /* U Break status bits */ + volatile unsigned char tbusy; /* W Transmit busy */ + volatile unsigned char iempty; /* W Transmit empty event */ + /* enable */ + volatile unsigned char ilow; /* W Transmit low-water event */ + /* enable */ + volatile unsigned char idata; /* W Receive data interrupt */ + /* enable */ + volatile unsigned char eflag; /* U Host event flags */ + + volatile unsigned char tflag; /* U Transmit flags */ + volatile unsigned char rflag; /* U Receive flags */ + volatile unsigned char xmask; /* U Transmit ready flags */ + volatile unsigned char xval; /* U Transmit ready value */ + volatile unsigned char m_stat; /* RC Modem status bits */ + volatile unsigned char m_change; /* U Modem bits which changed */ + volatile unsigned char m_int; /* W Modem interrupt enable */ + /* bits */ + volatile unsigned char m_last; /* U Last modem status */ + + volatile unsigned char mtran; /* C Unreported modem trans */ + volatile unsigned char orun; /* C Buffer overrun occurred */ + volatile unsigned char astartc; /* W Auxiliary Xon char */ + volatile unsigned char astopc; /* W Auxiliary Xoff char */ + volatile unsigned char startc; /* W Xon character */ + volatile unsigned char stopc; /* W Xoff character */ + volatile unsigned char vnextc; /* W Vnext character */ + volatile unsigned char hflow; /* C Software flow control */ + + volatile unsigned char fillc; /* U Delay Fill character */ + volatile unsigned char ochar; /* U Saved output character */ + volatile unsigned char omask; /* U Output character mask */ + + volatile unsigned char bfill[13]; /* U Reserved for expansion */ + + volatile unsigned char scc[16]; /* U SCC registers */ }; struct cnode { -- cgit v1.2.3 From cb873994a723a6026c72e5f21fef46268bf70fba Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Fri, 21 Mar 2014 10:41:14 -0400 Subject: staging: dgap: remove some unused code in dgap.h This patch removes some unused code in dgap.h Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.h | 53 --------------------------------------------- 1 file changed, 53 deletions(-) diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h index 2913f6e3def5..979ad404e2f7 100644 --- a/drivers/staging/dgap/dgap.h +++ b/drivers/staging/dgap/dgap.h @@ -839,59 +839,6 @@ struct rw_t { unsigned char rw_data[128]; /* Data to read/write */ }; -/*********************************************************************** - * Shrink Buffer and Board Information definitions and structures. - - ************************************************************************/ - /* Board type return codes */ -#define PCXI_TYPE 1 /* Board type at the designated port is a PC/Xi */ -#define PCXM_TYPE 2 /* Board type at the designated port is a PC/Xm */ -#define PCXE_TYPE 3 /* Board type at the designated port is a PC/Xe */ -#define MCXI_TYPE 4 /* Board type at the designated port is a MC/Xi */ -#define COMXI_TYPE 5 /* Board type at the designated port is a COM/Xi */ - - /* Non-Zero Result codes. */ -#define RESULT_NOBDFND 1 /* A Digi product at that port is not config installed */ -#define RESULT_NODESCT 2 /* A memory descriptor was not obtainable */ -#define RESULT_NOOSSIG 3 /* FEP/OS signature was not detected on the board */ -#define RESULT_TOOSML 4 /* Too small an area to shrink. */ -#define RESULT_NOCHAN 5 /* Channel structure for the board was not found */ - -struct shrink_buf_struct { - unsigned long shrink_buf_vaddr; /* Virtual address of board */ - unsigned long shrink_buf_phys; /* Physical address of board */ - unsigned long shrink_buf_bseg; /* Amount of board memory */ - unsigned long shrink_buf_hseg; /* 186 Beginning of Dual-Port */ - - unsigned long shrink_buf_lseg; /* 186 Beginning of freed mem */ - unsigned long shrink_buf_mseg; /* Linear address from start of - dual-port were freed memory - begins, host viewpoint. */ - - unsigned long shrink_buf_bdparam; /* Parameter for xxmemon and - xxmemoff */ - - unsigned long shrink_buf_reserva; /* Reserved */ - unsigned long shrink_buf_reservb; /* Reserved */ - unsigned long shrink_buf_reservc; /* Reserved */ - unsigned long shrink_buf_reservd; /* Reserved */ - - unsigned char shrink_buf_result; /* Reason for call failing - Zero is Good return */ - unsigned char shrink_buf_init; /* Non-Zero if it caused an - xxinit call. */ - - unsigned char shrink_buf_anports; /* Number of async ports */ - unsigned char shrink_buf_snports; /* Number of sync ports */ - unsigned char shrink_buf_type; /* Board type 1 = PC/Xi, - 2 = PC/Xm, - 3 = PC/Xe - 4 = MC/Xi - 5 = COMX/i */ - unsigned char shrink_buf_card; /* Card number */ - -}; - /************************************************************************ * Structure to get driver status information ************************************************************************/ -- cgit v1.2.3 From 559edcb73a13af63066aee0e9a322383fef7cae2 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Tue, 25 Mar 2014 16:38:13 -0400 Subject: staging: dgap: Removes excessive empty lines from dgap.h This patch removes excessive empty lines from dgap.h not previously caught. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.h | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h index 979ad404e2f7..64156807a333 100644 --- a/drivers/staging/dgap/dgap.h +++ b/drivers/staging/dgap/dgap.h @@ -282,14 +282,12 @@ typedef unsigned char uchar; #define SPINTFC 0xfc /* Reserved */ #define SCOMMODE 0xfd /* Set RS232/422 mode */ - /************************************************************************ * Modes for SCOMMODE ************************************************************************/ #define MODE_232 0x00 #define MODE_422 0x01 - /************************************************************************ * Event flags. ************************************************************************/ @@ -494,8 +492,6 @@ enum { REQUESTED_CONCENTRATOR }; - - /* * Modem line constants are defined as macros because DSR and * DCD are swapable using the ditty altpin option. @@ -507,14 +503,12 @@ enum { #define D_RI(ch) DM_RI /* Ring indicator */ #define D_DTR(ch) DM_DTR /* Data terminal ready */ - /************************************************************************* * * Structures and closely related defines. * *************************************************************************/ - /* * A structure to hold a statistics counter. We also * compute moving averages for this counter. @@ -526,7 +520,6 @@ struct macounter { ulong ema; /* Exponential moving average */ }; - /************************************************************************ * Device flag definitions for bd_flags. ************************************************************************/ @@ -620,8 +613,6 @@ struct board_t { /* download */ }; - - /************************************************************************ * Unit flag definitions for un_flags. ************************************************************************/ @@ -659,7 +650,6 @@ struct un_t { struct device *un_sysfs; }; - /************************************************************************ * Device flag definitions for ch_flags. ************************************************************************/ @@ -686,7 +676,6 @@ struct un_t { #define SNIFF_WAIT_DATA 0x2 #define SNIFF_WAIT_SPACE 0x4 - /************************************************************************ *** Definitions for Digi ditty(1) command. ************************************************************************/ @@ -727,7 +716,6 @@ struct un_t { #define TIOCMBIS (('d'<<8) | 255) /* set modem ctrl state */ #endif - #if !defined(TIOCSDTR) #define TIOCSDTR (('e'<<8) | 0) /* set DTR */ #define TIOCCDTR (('e'<<8) | 1) /* clear DTR */ @@ -762,7 +750,6 @@ struct digiflow_t { unsigned char stopc; /* flow cntl stop char */ }; - #ifdef FLOW_2200 #define F2200_GETA (('e'<<8) | 104) /* Get 2x36 flow cntl flags */ #define F2200_SETAW (('e'<<8) | 105) /* Set 2x36 flow cntl flags */ @@ -1004,7 +991,6 @@ struct channel_t { u32 ch_open_count; /* open count */ u32 ch_flags; /* Channel flags */ - u32 ch_close_delay; /* How long we should drop */ /* RTS/DTR for */ @@ -1256,29 +1242,17 @@ struct cnode { } module; char *ttyname; - char *cuname; - char *printname; - long majornumber; - long altpin; - long ttysize; - long chsize; - long bssize; - long unsize; - long f2size; - long vpixsize; - long useintr; } u; }; - #endif -- cgit v1.2.3 From 9e84401638143184cb16a2d5c5326476c13467e8 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Tue, 25 Mar 2014 16:38:14 -0400 Subject: staging: dgap: Only read config file dgap.conf once The config file is currently read for each board found. It only needs to be read one time. The buffer it is read into can now be freed immediately after it is parsed instead of at driver unload time. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index ea920e41dc0a..07fcb8df6a60 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -620,8 +620,6 @@ static void dgap_cleanup_module(void) class_destroy(dgap_class); unregister_chrdev(DIGI_DGAP_MAJOR, "dgap"); - kfree(dgap_config_buf); - for (i = 0; i < dgap_NumBoards; ++i) { dgap_remove_ports_sysfiles(dgap_Board[i]); dgap_tty_uninit(dgap_Board[i]); @@ -828,7 +826,7 @@ static int dgap_firmware_load(struct pci_dev *pdev, int card_type) dgap_get_vpd(brd); dgap_do_reset_board(brd); - if (fw_info[card_type].conf_name) { + if ((fw_info[card_type].conf_name) && !dgap_config_buf) { ret = request_firmware(&fw, fw_info[card_type].conf_name, &pdev->dev); if (ret) { @@ -836,20 +834,22 @@ static int dgap_firmware_load(struct pci_dev *pdev, int card_type) fw_info[card_type].conf_name); return ret; } + + dgap_config_buf = kmalloc(fw->size + 1, GFP_KERNEL); if (!dgap_config_buf) { - dgap_config_buf = kmalloc(fw->size + 1, GFP_ATOMIC); - if (!dgap_config_buf) { - release_firmware(fw); - return -ENOMEM; - } + release_firmware(fw); + return -ENOMEM; } memcpy(dgap_config_buf, fw->data, fw->size); release_firmware(fw); dgap_config_buf[fw->size + 1] = '\0'; - if (dgap_parsefile(&dgap_config_buf, TRUE) != 0) + if (dgap_parsefile(&dgap_config_buf, TRUE) != 0) { + kfree(dgap_config_buf); return -EINVAL; + } + kfree(dgap_config_buf); } ret = dgap_after_config_loaded(brd->boardnum); -- cgit v1.2.3 From 77c9976fa6a70cf62c8d5eb606d5353b8713ce1e Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Tue, 25 Mar 2014 16:38:15 -0400 Subject: staging: dgap: Macros with complex values should be enclosed in parenthesis This patch fixes a checkpatch warning "Macros with complex values should be enclosed in parenthesis" Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h index 64156807a333..01eb56fd9ada 100644 --- a/drivers/staging/dgap/dgap.h +++ b/drivers/staging/dgap/dgap.h @@ -186,7 +186,7 @@ typedef unsigned char uchar; ECHOCTL | ECHOKE | IEXTEN) #ifndef _POSIX_VDISABLE -#define _POSIX_VDISABLE '\0' +#define _POSIX_VDISABLE ('\0') #endif #define SNIFF_MAX 65536 /* Sniff buffer size (2^n) */ -- cgit v1.2.3 From 70dc23361daca50801e8e2e08d2a7681d886e390 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Tue, 25 Mar 2014 16:38:16 -0400 Subject: staging: dgap: remove volatiles from dgap.h This patch fixes checkpatch warnings about using volatiles in dgap.h Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.h | 152 ++++++++++++++++++++++---------------------- 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h index 01eb56fd9ada..2fce41c31cf7 100644 --- a/drivers/staging/dgap/dgap.h +++ b/drivers/staging/dgap/dgap.h @@ -1056,20 +1056,20 @@ struct channel_t { * Command structure definition. ************************************************************************/ struct cm_t { - volatile unsigned short cm_head; /* Command buffer head offset */ - volatile unsigned short cm_tail; /* Command buffer tail offset */ - volatile unsigned short cm_start; /* start offset of buffer */ - volatile unsigned short cm_max; /* last offset of buffer */ + unsigned short cm_head; /* Command buffer head offset */ + unsigned short cm_tail; /* Command buffer tail offset */ + unsigned short cm_start; /* start offset of buffer */ + unsigned short cm_max; /* last offset of buffer */ }; /************************************************************************ * Event structure definition. ************************************************************************/ struct ev_t { - volatile unsigned short ev_head; /* Command buffer head offset */ - volatile unsigned short ev_tail; /* Command buffer tail offset */ - volatile unsigned short ev_start; /* start offset of buffer */ - volatile unsigned short ev_max; /* last offset of buffer */ + unsigned short ev_head; /* Command buffer head offset */ + unsigned short ev_tail; /* Command buffer tail offset */ + unsigned short ev_start; /* start offset of buffer */ + unsigned short ev_max; /* last offset of buffer */ }; /************************************************************************ @@ -1096,74 +1096,74 @@ struct downld_t { * U = unknown (may be changed w/o notice) * ************************************************************************/ struct bs_t { - volatile unsigned short tp_jmp; /* Transmit poll jump */ - volatile unsigned short tc_jmp; /* Cooked procedure jump */ - volatile unsigned short ri_jmp; /* Not currently used */ - volatile unsigned short rp_jmp; /* Receive poll jump */ - - volatile unsigned short tx_seg; /* W Tx segment */ - volatile unsigned short tx_head; /* W Tx buffer head offset */ - volatile unsigned short tx_tail; /* R Tx buffer tail offset */ - volatile unsigned short tx_max; /* W Tx buffer size - 1 */ - - volatile unsigned short rx_seg; /* W Rx segment */ - volatile unsigned short rx_head; /* W Rx buffer head offset */ - volatile unsigned short rx_tail; /* R Rx buffer tail offset */ - volatile unsigned short rx_max; /* W Rx buffer size - 1 */ - - volatile unsigned short tx_lw; /* W Tx buffer low water mark */ - volatile unsigned short rx_lw; /* W Rx buffer low water mark */ - volatile unsigned short rx_hw; /* W Rx buffer high water mark*/ - volatile unsigned short incr; /* W Increment to next channel*/ - - volatile unsigned short fepdev; /* U SCC device base address */ - volatile unsigned short edelay; /* W Exception delay */ - volatile unsigned short blen; /* W Break length */ - volatile unsigned short btime; /* U Break complete time */ - - volatile unsigned short iflag; /* C UNIX input flags */ - volatile unsigned short oflag; /* C UNIX output flags */ - volatile unsigned short cflag; /* C UNIX control flags */ - volatile unsigned short wfill[13]; /* U Reserved for expansion */ - - volatile unsigned char num; /* U Channel number */ - volatile unsigned char ract; /* U Receiver active counter */ - volatile unsigned char bstat; /* U Break status bits */ - volatile unsigned char tbusy; /* W Transmit busy */ - volatile unsigned char iempty; /* W Transmit empty event */ - /* enable */ - volatile unsigned char ilow; /* W Transmit low-water event */ - /* enable */ - volatile unsigned char idata; /* W Receive data interrupt */ - /* enable */ - volatile unsigned char eflag; /* U Host event flags */ - - volatile unsigned char tflag; /* U Transmit flags */ - volatile unsigned char rflag; /* U Receive flags */ - volatile unsigned char xmask; /* U Transmit ready flags */ - volatile unsigned char xval; /* U Transmit ready value */ - volatile unsigned char m_stat; /* RC Modem status bits */ - volatile unsigned char m_change; /* U Modem bits which changed */ - volatile unsigned char m_int; /* W Modem interrupt enable */ - /* bits */ - volatile unsigned char m_last; /* U Last modem status */ - - volatile unsigned char mtran; /* C Unreported modem trans */ - volatile unsigned char orun; /* C Buffer overrun occurred */ - volatile unsigned char astartc; /* W Auxiliary Xon char */ - volatile unsigned char astopc; /* W Auxiliary Xoff char */ - volatile unsigned char startc; /* W Xon character */ - volatile unsigned char stopc; /* W Xoff character */ - volatile unsigned char vnextc; /* W Vnext character */ - volatile unsigned char hflow; /* C Software flow control */ - - volatile unsigned char fillc; /* U Delay Fill character */ - volatile unsigned char ochar; /* U Saved output character */ - volatile unsigned char omask; /* U Output character mask */ - - volatile unsigned char bfill[13]; /* U Reserved for expansion */ - - volatile unsigned char scc[16]; /* U SCC registers */ + unsigned short tp_jmp; /* Transmit poll jump */ + unsigned short tc_jmp; /* Cooked procedure jump */ + unsigned short ri_jmp; /* Not currently used */ + unsigned short rp_jmp; /* Receive poll jump */ + + unsigned short tx_seg; /* W Tx segment */ + unsigned short tx_head; /* W Tx buffer head offset */ + unsigned short tx_tail; /* R Tx buffer tail offset */ + unsigned short tx_max; /* W Tx buffer size - 1 */ + + unsigned short rx_seg; /* W Rx segment */ + unsigned short rx_head; /* W Rx buffer head offset */ + unsigned short rx_tail; /* R Rx buffer tail offset */ + unsigned short rx_max; /* W Rx buffer size - 1 */ + + unsigned short tx_lw; /* W Tx buffer low water mark */ + unsigned short rx_lw; /* W Rx buffer low water mark */ + unsigned short rx_hw; /* W Rx buffer high water mark*/ + unsigned short incr; /* W Increment to next channel*/ + + unsigned short fepdev; /* U SCC device base address */ + unsigned short edelay; /* W Exception delay */ + unsigned short blen; /* W Break length */ + unsigned short btime; /* U Break complete time */ + + unsigned short iflag; /* C UNIX input flags */ + unsigned short oflag; /* C UNIX output flags */ + unsigned short cflag; /* C UNIX control flags */ + unsigned short wfill[13]; /* U Reserved for expansion */ + + unsigned char num; /* U Channel number */ + unsigned char ract; /* U Receiver active counter */ + unsigned char bstat; /* U Break status bits */ + unsigned char tbusy; /* W Transmit busy */ + unsigned char iempty; /* W Transmit empty event */ + /* enable */ + unsigned char ilow; /* W Transmit low-water event */ + /* enable */ + unsigned char idata; /* W Receive data interrupt */ + /* enable */ + unsigned char eflag; /* U Host event flags */ + + unsigned char tflag; /* U Transmit flags */ + unsigned char rflag; /* U Receive flags */ + unsigned char xmask; /* U Transmit ready flags */ + unsigned char xval; /* U Transmit ready value */ + unsigned char m_stat; /* RC Modem status bits */ + unsigned char m_change; /* U Modem bits which changed */ + unsigned char m_int; /* W Modem interrupt enable */ + /* bits */ + unsigned char m_last; /* U Last modem status */ + + unsigned char mtran; /* C Unreported modem trans */ + unsigned char orun; /* C Buffer overrun occurred */ + unsigned char astartc; /* W Auxiliary Xon char */ + unsigned char astopc; /* W Auxiliary Xoff char */ + unsigned char startc; /* W Xon character */ + unsigned char stopc; /* W Xoff character */ + unsigned char vnextc; /* W Vnext character */ + unsigned char hflow; /* C Software flow control */ + + unsigned char fillc; /* U Delay Fill character */ + unsigned char ochar; /* U Saved output character */ + unsigned char omask; /* U Output character mask */ + + unsigned char bfill[13]; /* U Reserved for expansion */ + + unsigned char scc[16]; /* U SCC registers */ }; struct cnode { -- cgit v1.2.3 From 20fe4ae19d58766a87af6f74a97027a2eb0c85c3 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Tue, 25 Mar 2014 16:38:17 -0400 Subject: staging: dgap: fix/change a pr_info This patch just fixes a pr_info. brd->state is not proper at this point in time. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 07fcb8df6a60..4bbedae22d49 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -782,9 +782,8 @@ static int dgap_found_board(struct pci_dev *pdev, int id) if (i) brd->state = BOARD_FAILED; - pr_info("dgap: board %d: %s (rev %d), irq %ld, %s\n", - dgap_NumBoards, brd->name, brd->rev, brd->irq, - brd->state ? "NOT READY\0" : "READY\0"); + pr_info("dgap: board %d: %s (rev %d), irq %ld\n", + dgap_NumBoards, brd->name, brd->rev, brd->irq); return 0; } -- cgit v1.2.3 From c9a129966227b39ec5f03abd4e24c8c08ee010ac Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Fri, 28 Mar 2014 09:30:15 -0400 Subject: staging: dgap: rename and fixup dgap_wait_for_xxx functions This patch renames and changes the dgap_wait_for_bios and dgap_wait_for_fep functions from boolean functions to return zero on success and a negative error code on error. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 4bbedae22d49..34693dc5d8c4 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -194,8 +194,8 @@ static int dgap_finalize_board_init(struct board_t *brd); static void dgap_get_vpd(struct board_t *brd); static void dgap_do_reset_board(struct board_t *brd); -static int dgap_do_wait_for_bios(struct board_t *brd); -static int dgap_do_wait_for_fep(struct board_t *brd); +static int dgap_test_bios(struct board_t *brd); +static int dgap_test_fep(struct board_t *brd); static int dgap_tty_register_ports(struct board_t *brd); static int dgap_firmware_load(struct pci_dev *pdev, int card_type); @@ -890,8 +890,9 @@ static int dgap_firmware_load(struct pci_dev *pdev, int card_type) release_firmware(fw); /* Wait for BIOS to test board... */ - if (!dgap_do_wait_for_bios(brd)) - return -ENXIO; + ret = dgap_test_bios(brd); + if (ret) + return ret; } if (fw_info[card_type].fep_name) { @@ -906,8 +907,9 @@ static int dgap_firmware_load(struct pci_dev *pdev, int card_type) release_firmware(fw); /* Wait for FEP to load on board... */ - if (!dgap_do_wait_for_fep(brd)) - return -ENXIO; + ret = dgap_test_fep(brd); + if (ret) + return ret; } #ifdef DIGI_CONCENTRATORS_SUPPORTED @@ -4332,16 +4334,15 @@ static void dgap_do_bios_load(struct board_t *brd, const uchar *ubios, int len) /* * Checks to see if the BIOS completed running on the card. */ -static int dgap_do_wait_for_bios(struct board_t *brd) +static int dgap_test_bios(struct board_t *brd) { uchar *addr; u16 word; u16 err1; u16 err2; - int ret = 0; if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) - return ret; + return -EINVAL; addr = brd->re_map_membase; word = readw(addr + POSTAREA); @@ -4355,7 +4356,7 @@ static int dgap_do_wait_for_bios(struct board_t *brd) while (brd->wait_for_bios < 1000) { /* Check to see if BIOS thinks board is good. (GD). */ if (word == *(u16 *) "GD") - return 1; + return 0; msleep_interruptible(10); brd->wait_for_bios++; word = readw(addr + POSTAREA); @@ -4369,7 +4370,7 @@ static int dgap_do_wait_for_bios(struct board_t *brd) brd->state = BOARD_FAILED; brd->dpastatus = BD_NOBIOS; - return ret; + return -EIO; } /* @@ -4420,16 +4421,15 @@ static void dgap_do_fep_load(struct board_t *brd, const uchar *ufep, int len) /* * Waits for the FEP to report thats its ready for us to use. */ -static int dgap_do_wait_for_fep(struct board_t *brd) +static int dgap_test_fep(struct board_t *brd) { uchar *addr; u16 word; u16 err1; u16 err2; - int ret = 0; if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) - return ret; + return -EINVAL; addr = brd->re_map_membase; word = readw(addr + FEPSTAT); @@ -4449,7 +4449,7 @@ static int dgap_do_wait_for_fep(struct board_t *brd) if (word == *(u16 *) "5A") brd->bd_flags |= BD_FEP5PLUS; - return 1; + return 0; } msleep_interruptible(10); brd->wait_for_fep++; @@ -4464,7 +4464,7 @@ static int dgap_do_wait_for_fep(struct board_t *brd) brd->state = BOARD_FAILED; brd->dpastatus = BD_NOFEP; - return ret; + return -EIO; } /* -- cgit v1.2.3 From 2023d18e6b38c5490df0cd6f17a8e0f2ec6dae0f Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Mon, 14 Apr 2014 16:42:43 -0400 Subject: staging: dgap: remove uchar typedef and replace use with u8 This patch removes the uchar typedef in dgap.h and changes all uses of it to u8. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 100 ++++++++++++++++++++++---------------------- drivers/staging/dgap/dgap.h | 65 ++++++++++++++-------------- 2 files changed, 81 insertions(+), 84 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 34693dc5d8c4..3c9278a224e2 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -135,9 +135,9 @@ static void dgap_cmdw_ext(struct channel_t *ch, u16 cmd, u16 word, uint ncmds); static int dgap_event(struct board_t *bd); static void dgap_poll_tasklet(unsigned long data); -static void dgap_cmdb(struct channel_t *ch, uchar cmd, uchar byte1, - uchar byte2, uint ncmds); -static void dgap_cmdw(struct channel_t *ch, uchar cmd, u16 word, uint ncmds); +static void dgap_cmdb(struct channel_t *ch, u8 cmd, u8 byte1, + u8 byte2, uint ncmds); +static void dgap_cmdw(struct channel_t *ch, u8 cmd, u16 word, uint ncmds); static void dgap_wmove(struct channel_t *ch, char *buf, uint cnt); static int dgap_param(struct tty_struct *tty); static void dgap_parity_scan(struct channel_t *ch, unsigned char *cbuf, @@ -184,10 +184,10 @@ static uint dgap_config_get_useintr(struct board_t *bd); static uint dgap_config_get_altpin(struct board_t *bd); static int dgap_ms_sleep(ulong ms); -static void dgap_do_bios_load(struct board_t *brd, const uchar *ubios, int len); -static void dgap_do_fep_load(struct board_t *brd, const uchar *ufep, int len); +static void dgap_do_bios_load(struct board_t *brd, const u8 *ubios, int len); +static void dgap_do_fep_load(struct board_t *brd, const u8 *ufep, int len); #ifdef DIGI_CONCENTRATORS_SUPPORTED -static void dgap_do_conc_load(struct board_t *brd, uchar *uaddr, int len); +static void dgap_do_conc_load(struct board_t *brd, u8 *uaddr, int len); #endif static int dgap_after_config_loaded(int board); static int dgap_finalize_board_init(struct board_t *brd); @@ -275,7 +275,7 @@ MODULE_DEVICE_TABLE(pci, dgap_pci_tbl); */ struct board_id { uint config_type; - uchar *name; + u8 *name; uint maxports; uint dpatype; }; @@ -307,10 +307,10 @@ static struct pci_driver dgap_driver = { }; struct firmware_info { - uchar *conf_name; /* dgap.conf */ - uchar *bios_name; /* BIOS filename */ - uchar *fep_name; /* FEP filename */ - uchar *con_name; /* Concentrator filename FIXME*/ + u8 *conf_name; /* dgap.conf */ + u8 *bios_name; /* BIOS filename */ + u8 *fep_name; /* FEP filename */ + u8 *con_name; /* Concentrator filename FIXME*/ int num; /* sequence number */ }; @@ -1293,8 +1293,8 @@ static int dgap_tty_init(struct board_t *brd) int i; int tlw; uint true_count = 0; - uchar *vaddr; - uchar modem = 0; + u8 *vaddr; + u8 modem = 0; struct channel_t *ch; struct bs_t *bs; struct cm_t *cm; @@ -1505,8 +1505,8 @@ static void dgap_tty_uninit(struct board_t *brd) * dgap_sniff - Dump data out to the "sniff" buffer if the * proc sniff file is opened... */ -static void dgap_sniff_nowait_nolock(struct channel_t *ch, uchar *text, - uchar *buf, int len) +static void dgap_sniff_nowait_nolock(struct channel_t *ch, u8 *text, + u8 *buf, int len) { struct timeval tv; int n; @@ -1640,8 +1640,8 @@ static void dgap_input(struct channel_t *ch) int flip_len; int len = 0; int n = 0; - uchar *buf; - uchar tmpchar; + u8 *buf; + u8 tmpchar; int s = 0; if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) @@ -2410,7 +2410,7 @@ static int dgap_tty_chars_in_buffer(struct tty_struct *tty) struct channel_t *ch = NULL; struct un_t *un = NULL; struct bs_t *bs = NULL; - uchar tbusy; + u8 tbusy; uint chars = 0; u16 thead, ttail, tmask, chead, ctail; ulong lock_flags = 0; @@ -2843,8 +2843,8 @@ static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, n -= remain; vaddr = ch->ch_taddr + head; - memcpy_toio(vaddr, (uchar *) buf, remain); - dgap_sniff_nowait_nolock(ch, "USER WRITE", (uchar *) buf, + memcpy_toio(vaddr, (u8 *) buf, remain); + dgap_sniff_nowait_nolock(ch, "USER WRITE", (u8 *) buf, remain); head = ch->ch_tstart; @@ -2859,8 +2859,8 @@ static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, vaddr = ch->ch_taddr + head; remain = n; - memcpy_toio(vaddr, (uchar *) buf, remain); - dgap_sniff_nowait_nolock(ch, "USER WRITE", (uchar *)buf, + memcpy_toio(vaddr, (u8 *) buf, remain); + dgap_sniff_nowait_nolock(ch, "USER WRITE", (u8 *)buf, remain); head += remain; @@ -2915,7 +2915,7 @@ static int dgap_tty_tiocmget(struct tty_struct *tty) struct channel_t *ch; struct un_t *un; int result = -EIO; - uchar mstat = 0; + u8 mstat = 0; ulong lock_flags; if (!tty || tty->magic != TTY_MAGIC) @@ -3141,7 +3141,7 @@ static void dgap_tty_send_xchar(struct tty_struct *tty, char c) static int dgap_get_modem_info(struct channel_t *ch, unsigned int __user *value) { int result = 0; - uchar mstat = 0; + u8 mstat = 0; ulong lock_flags; int rc = 0; @@ -4301,9 +4301,9 @@ static int dgap_tty_register_ports(struct board_t *brd) * Copies the BIOS code from the user to the board, * and starts the BIOS running. */ -static void dgap_do_bios_load(struct board_t *brd, const uchar *ubios, int len) +static void dgap_do_bios_load(struct board_t *brd, const u8 *ubios, int len) { - uchar *addr; + u8 *addr; uint offset; int i; @@ -4336,7 +4336,7 @@ static void dgap_do_bios_load(struct board_t *brd, const uchar *ubios, int len) */ static int dgap_test_bios(struct board_t *brd) { - uchar *addr; + u8 *addr; u16 word; u16 err1; u16 err2; @@ -4377,9 +4377,9 @@ static int dgap_test_bios(struct board_t *brd) * Copies the FEP code from the user to the board, * and starts the FEP running. */ -static void dgap_do_fep_load(struct board_t *brd, const uchar *ufep, int len) +static void dgap_do_fep_load(struct board_t *brd, const u8 *ufep, int len) { - uchar *addr; + u8 *addr; uint offset; if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) @@ -4398,8 +4398,8 @@ static void dgap_do_fep_load(struct board_t *brd, const uchar *ufep, int len) * it its config string describing how the concentrators look. */ if ((brd->type == PCX) || (brd->type == PEPC)) { - uchar string[100]; - uchar *config, *xconfig; + u8 string[100]; + u8 *config, *xconfig; int i = 0; xconfig = dgap_create_config_string(brd, string); @@ -4423,7 +4423,7 @@ static void dgap_do_fep_load(struct board_t *brd, const uchar *ufep, int len) */ static int dgap_test_fep(struct board_t *brd) { - uchar *addr; + u8 *addr; u16 word; u16 err1; u16 err2; @@ -4472,7 +4472,7 @@ static int dgap_test_fep(struct board_t *brd) */ static void dgap_do_reset_board(struct board_t *brd) { - uchar check; + u8 check; u32 check1; u32 check2; int i = 0; @@ -4520,7 +4520,7 @@ static void dgap_do_reset_board(struct board_t *brd) /* * Sends a concentrator image into the FEP5 board. */ -static void dgap_do_conc_load(struct board_t *brd, uchar *uaddr, int len) +static void dgap_do_conc_load(struct board_t *brd, u8 *uaddr, int len) { char *vaddr; u16 offset = 0; @@ -4553,8 +4553,8 @@ static void dgap_get_vpd(struct board_t *brd) u16 vpd_offset; u16 image_length; u16 i; - uchar byte1; - uchar byte2; + u8 byte1; + u8 byte2; /* * Poke the magic number at the PCI Rom Address location. @@ -4733,8 +4733,8 @@ out: * in the cmd buffer before returning. * *=======================================================================*/ -static void dgap_cmdb(struct channel_t *ch, uchar cmd, uchar byte1, - uchar byte2, uint ncmds) +static void dgap_cmdb(struct channel_t *ch, u8 cmd, u8 byte1, + u8 byte2, uint ncmds) { char *vaddr = NULL; struct cm_t *cm_addr = NULL; @@ -4776,7 +4776,7 @@ static void dgap_cmdb(struct channel_t *ch, uchar cmd, uchar byte1, * Put the data in the circular command buffer. */ writeb(cmd, (char *) (vaddr + head + CMDSTART + 0)); - writeb((uchar) ch->ch_portnum, (char *) (vaddr + head + CMDSTART + 1)); + writeb((u8) ch->ch_portnum, (char *) (vaddr + head + CMDSTART + 1)); writeb(byte1, (char *) (vaddr + head + CMDSTART + 2)); writeb(byte2, (char *) (vaddr + head + CMDSTART + 3)); @@ -4819,7 +4819,7 @@ static void dgap_cmdb(struct channel_t *ch, uchar cmd, uchar byte1, * in the cmd buffer before returning. * *=======================================================================*/ -static void dgap_cmdw(struct channel_t *ch, uchar cmd, u16 word, uint ncmds) +static void dgap_cmdw(struct channel_t *ch, u8 cmd, u16 word, uint ncmds) { char *vaddr = NULL; struct cm_t *cm_addr = NULL; @@ -4860,7 +4860,7 @@ static void dgap_cmdw(struct channel_t *ch, uchar cmd, u16 word, uint ncmds) * Put the data in the circular command buffer. */ writeb(cmd, (char *) (vaddr + head + CMDSTART + 0)); - writeb((uchar) ch->ch_portnum, (char *) (vaddr + head + CMDSTART + 1)); + writeb((u8) ch->ch_portnum, (char *) (vaddr + head + CMDSTART + 1)); writew((u16) word, (char *) (vaddr + head + CMDSTART + 2)); head = (head + 4) & (CMDMAX - CMDSTART - 4); @@ -4944,9 +4944,9 @@ static void dgap_cmdw_ext(struct channel_t *ch, u16 cmd, u16 word, uint ncmds) */ /* Write an FF to tell the FEP that we want an extended command */ - writeb((uchar) 0xff, (char *) (vaddr + head + CMDSTART + 0)); + writeb((u8) 0xff, (char *) (vaddr + head + CMDSTART + 0)); - writeb((uchar) ch->ch_portnum, (uchar *) (vaddr + head + CMDSTART + 1)); + writeb((u8) ch->ch_portnum, (u8 *) (vaddr + head + CMDSTART + 1)); writew((u16) cmd, (char *) (vaddr + head + CMDSTART + 2)); /* @@ -5051,7 +5051,7 @@ static void dgap_wmove(struct channel_t *ch, char *buf, uint cnt) */ static uint dgap_get_custom_baud(struct channel_t *ch) { - uchar *vaddr; + u8 *vaddr; ulong offset = 0; uint value = 0; @@ -5123,8 +5123,8 @@ static int dgap_param(struct tty_struct *tty) u16 head; u16 cflag; u16 iflag; - uchar mval; - uchar hflow; + u8 mval; + u8 hflow; if (!tty || tty->magic != TTY_MAGIC) return -ENXIO; @@ -5390,7 +5390,7 @@ static int dgap_param(struct tty_struct *tty) ch->ch_hflow = hflow; /* Okay to have channel and board locks held calling this */ - dgap_cmdb(ch, SHFLOW, (uchar) hflow, 0xff, 0); + dgap_cmdb(ch, SHFLOW, (u8) hflow, 0xff, 0); } @@ -5418,7 +5418,7 @@ static int dgap_param(struct tty_struct *tty) ch->ch_mostat = mval; /* Okay to have channel and board locks held calling this */ - dgap_cmdb(ch, SMODEM, (uchar) mval, D_RTS(ch)|D_DTR(ch), 0); + dgap_cmdb(ch, SMODEM, (u8) mval, D_RTS(ch)|D_DTR(ch), 0); } /* @@ -5572,8 +5572,8 @@ static int dgap_event(struct board_t *bd) ulong lock_flags; ulong lock_flags2; struct bs_t *bs; - uchar *event; - uchar *vaddr = NULL; + u8 *event; + u8 *vaddr = NULL; struct ev_t *eaddr = NULL; uint head; uint tail; diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h index 2fce41c31cf7..b23570bd183d 100644 --- a/drivers/staging/dgap/dgap.h +++ b/drivers/staging/dgap/dgap.h @@ -39,9 +39,6 @@ # define FALSE 0 #endif -/* Required for our shared headers! */ -typedef unsigned char uchar; - #if !defined(TTY_FLIPBUF_SIZE) # define TTY_FLIPBUF_SIZE 512 #endif @@ -541,11 +538,11 @@ struct board_t { u16 device; /* PCI device ID */ u16 subvendor; /* PCI subsystem vendor ID */ u16 subdevice; /* PCI subsystem device ID */ - uchar rev; /* PCI revision ID */ + u8 rev; /* PCI revision ID */ uint pci_bus; /* PCI bus value */ uint pci_slot; /* PCI slot value */ u16 maxports; /* MAX ports this board can handle */ - uchar vpd[VPDSIZE]; /* VPD of board, if found */ + u8 vpd[VPDSIZE]; /* VPD of board, if found */ u32 bd_flags; /* Board flags */ spinlock_t bd_lock; /* Used to protect board */ @@ -574,11 +571,11 @@ struct board_t { ulong membase; /* Start of base memory of the card */ ulong membase_end; /* End of base memory of the card */ - uchar *re_map_port; /* Remapped io port of the card */ - uchar *re_map_membase;/* Remapped memory of the card */ + u8 *re_map_port; /* Remapped io port of the card */ + u8 *re_map_membase;/* Remapped memory of the card */ - uchar runwait; /* # Processes waiting for FEP */ - uchar inhibit_poller; /* Tells the poller to leave us alone */ + u8 runwait; /* # Processes waiting for FEP */ + u8 inhibit_poller; /* Tells the poller to leave us alone */ struct channel_t *channels[MAXPORTS]; /* array of pointers to our */ /* channels. */ @@ -985,7 +982,7 @@ struct channel_t { wait_queue_head_t ch_flags_wait; u32 pscan_state; - uchar pscan_savechar; + u8 pscan_savechar; u32 ch_portnum; /* Port number, 0 offset. */ u32 ch_open_count; /* open count */ @@ -1015,27 +1012,27 @@ struct channel_t { u16 ch_cook; /* Output character mask */ - uchar ch_card; /* Card channel is on */ - uchar ch_stopc; /* Stop character */ - uchar ch_startc; /* Start character */ - - uchar ch_mostat; /* FEP output modem status */ - uchar ch_mistat; /* FEP input modem status */ - uchar ch_mforce; /* Modem values to be forced */ - uchar ch_mval; /* Force values */ - uchar ch_fepstopc; /* FEP stop character */ - uchar ch_fepstartc; /* FEP start character */ - - uchar ch_astopc; /* Auxiliary Stop character */ - uchar ch_astartc; /* Auxiliary Start character */ - uchar ch_fepastopc; /* Auxiliary FEP stop char */ - uchar ch_fepastartc; /* Auxiliary FEP start char */ - - uchar ch_hflow; /* FEP hardware handshake */ - uchar ch_dsr; /* stores real dsr value */ - uchar ch_cd; /* stores real cd value */ - uchar ch_tx_win; /* channel tx buffer window */ - uchar ch_rx_win; /* channel rx buffer window */ + u8 ch_card; /* Card channel is on */ + u8 ch_stopc; /* Stop character */ + u8 ch_startc; /* Start character */ + + u8 ch_mostat; /* FEP output modem status */ + u8 ch_mistat; /* FEP input modem status */ + u8 ch_mforce; /* Modem values to be forced */ + u8 ch_mval; /* Force values */ + u8 ch_fepstopc; /* FEP stop character */ + u8 ch_fepstartc; /* FEP start character */ + + u8 ch_astopc; /* Auxiliary Stop character */ + u8 ch_astartc; /* Auxiliary Start character */ + u8 ch_fepastopc; /* Auxiliary FEP stop char */ + u8 ch_fepastartc; /* Auxiliary FEP start char */ + + u8 ch_hflow; /* FEP hardware handshake */ + u8 ch_dsr; /* stores real dsr value */ + u8 ch_cd; /* stores real cd value */ + u8 ch_tx_win; /* channel tx buffer window */ + u8 ch_rx_win; /* channel rx buffer window */ uint ch_custom_speed; /* Custom baud, if set */ uint ch_baud_info; /* Current baud info for /proc output */ ulong ch_rxcount; /* total of data received so far */ @@ -1076,14 +1073,14 @@ struct ev_t { * Download buffer structure. ************************************************************************/ struct downld_t { - uchar dl_type; /* Header */ - uchar dl_seq; /* Download sequence */ + u8 dl_type; /* Header */ + u8 dl_seq; /* Download sequence */ ushort dl_srev; /* Software revision number */ ushort dl_lrev; /* Low revision number */ ushort dl_hrev; /* High revision number */ ushort dl_seg; /* Start segment address */ ushort dl_size; /* Number of bytes to download */ - uchar dl_data[1024]; /* Download data */ + u8 dl_data[1024]; /* Download data */ }; /************************************************************************ -- cgit v1.2.3 From 597baaff65b68d58ee035d556ddd6e2387c63c6d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:20 +0200 Subject: staging: rtl8723au: Fix buffer overflow in rtw_get_wfd_ie() Add bounds checking to not allow WFD Information Elements larger than 128, and make sure we use the correct buffer size MAX_WFD_IE_LEN instea of hardcoding the size. This also simplifies rtw_get_wfd_ie() by using the cfg80211 infrastructure. Reported-by: Dan Carpenter Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 46 +++++++------------------- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8723au/core/rtw_p2p.c | 4 +-- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 2 +- 4 files changed, 16 insertions(+), 38 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index 780631fd3b6d..a48ab25a7d8a 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -1496,45 +1496,23 @@ void rtw_wlan_bssid_ex_remove_p2p_attr23a(struct wlan_bssid_ex *bss_ex, u8 attr_ int rtw_get_wfd_ie(u8 *in_ie, int in_len, u8 *wfd_ie, uint *wfd_ielen) { int match; - uint cnt = 0; - u8 eid, wfd_oui[4] = {0x50, 0x6F, 0x9A, 0x0A}; + const u8 *ie; - match = false; + match = 0; - if (in_len < 0) { + if (in_len < 0) return match; - } - - while (cnt < in_len) - { - eid = in_ie[cnt]; - if ((eid == _VENDOR_SPECIFIC_IE_) && - !memcmp(&in_ie[cnt+2], wfd_oui, 4)) { - if (wfd_ie != NULL) { - memcpy(wfd_ie, &in_ie[cnt], in_ie[cnt + 1] + 2); - - } else { - if (wfd_ielen != NULL) { - *wfd_ielen = 0; - } - } - - if (wfd_ielen != NULL) { - *wfd_ielen = in_ie[cnt + 1] + 2; - } - - cnt += in_ie[cnt + 1] + 2; - - match = true; - break; - } else { - cnt += in_ie[cnt + 1] +2; /* goto next */ - } - } + ie = cfg80211_find_vendor_ie(0x506F9A, 0x0A, in_ie, in_len); + if (ie && (ie[1] <= (MAX_WFD_IE_LEN - 2))) { + if (wfd_ie) { + *wfd_ielen = ie[1] + 2; + memcpy(wfd_ie, ie, ie[1] + 2); + } else + if (wfd_ielen) + *wfd_ielen = 0; - if (match == true) { - match = cnt; + match = 1; } return match; diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index be593989aec7..07493bc70539 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1280,7 +1280,7 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec u8 p2p_status_code = P2P_STATUS_SUCCESS; u8 *p2pie; u32 p2pielen = 0; - u8 wfd_ie[ 128 ] = { 0x00 }; + u8 wfd_ie[MAX_WFD_IE_LEN] = { 0x00 }; u32 wfd_ielen = 0; #endif /* CONFIG_8723AU_P2P */ diff --git a/drivers/staging/rtl8723au/core/rtw_p2p.c b/drivers/staging/rtl8723au/core/rtw_p2p.c index ba851cf4f992..a3bf031ee738 100644 --- a/drivers/staging/rtl8723au/core/rtw_p2p.c +++ b/drivers/staging/rtl8723au/core/rtw_p2p.c @@ -2536,7 +2536,7 @@ u8 process_p2p_group_negotation_req23a(struct wifidirect_info *pwdinfo, u8 *pfra u16 wps_devicepassword_id = 0x0000; uint wps_devicepassword_id_len = 0; #ifdef CONFIG_8723AU_P2P - u8 wfd_ie[ 128 ] = { 0x00 }; + u8 wfd_ie[MAX_WFD_IE_LEN] = { 0x00 }; u32 wfd_ielen = 0; #endif /* CONFIG_8723AU_P2P */ @@ -2742,7 +2742,7 @@ u8 process_p2p_group_negotation_resp23a(struct wifidirect_info *pwdinfo, u8 *pfr u32 ies_len; u8 * p2p_ie; #ifdef CONFIG_8723AU_P2P - u8 wfd_ie[ 128 ] = { 0x00 }; + u8 wfd_ie[MAX_WFD_IE_LEN] = { 0x00 }; u32 wfd_ielen = 0; #endif /* CONFIG_8723AU_P2P */ diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index e364d7afc08d..f54021ceba5c 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -502,7 +502,7 @@ void flush_all_cam_entry23a(struct rtw_adapter *padapter) int WFD_info_handler(struct rtw_adapter *padapter, struct ndis_802_11_var_ies * pIE) { struct wifidirect_info *pwdinfo; - u8 wfd_ie[128] = {0x00}; + u8 wfd_ie[MAX_WFD_IE_LEN] = {0x00}; u32 wfd_ielen = 0; pwdinfo = &padapter->wdinfo; -- cgit v1.2.3 From 9300c94b8a817f3b96cf00d2bdeed6751c2744d8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:21 +0200 Subject: staging: rtl8723au: Remove duplicate #defines for WLAN_EID_VENDOR_SPECIFIC Lets not keep one local copy ... no lets keep two ... no lets keep three! Rip them all out and use the kernel provided one. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 6 +-- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 22 +++++---- drivers/staging/rtl8723au/core/rtw_mlme.c | 9 ++-- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 51 +++++++++++--------- drivers/staging/rtl8723au/core/rtw_p2p.c | 58 +++++++++++++++-------- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 8 ++-- drivers/staging/rtl8723au/include/rtw_security.h | 1 - drivers/staging/rtl8723au/include/wifi.h | 2 - drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 16 +++---- 9 files changed, 99 insertions(+), 74 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 131d787dac78..fc8b7b2c4443 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -927,7 +927,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, int len) psecuritypriv->wpa_group_cipher = _NO_PRIVACY_; psecuritypriv->wpa_pairwise_cipher = _NO_PRIVACY_; for (p = ie + _BEACON_IE_OFFSET_; ;p += (ie_len + 2)) { - p = rtw_get_ie23a(p, _SSN_IE_1_, &ie_len, + p = rtw_get_ie23a(p, WLAN_EID_VENDOR_SPECIFIC, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); if ((p) && (!memcmp(p+2, OUI1, 4))) { @@ -955,7 +955,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, int len) pmlmepriv->qospriv.qos_option = 0; if (pregistrypriv->wmm_enable) { for (p = ie + _BEACON_IE_OFFSET_; ;p += (ie_len + 2)) { - p = rtw_get_ie23a(p, _VENDOR_SPECIFIC_IE_, &ie_len, + p = rtw_get_ie23a(p, WLAN_EID_VENDOR_SPECIFIC, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); if ((p) && !memcmp(p+2, WMM_PARA_IE, 6)) { @@ -1374,7 +1374,7 @@ void update_beacon23a(struct rtw_adapter *padapter, u8 ie_id, u8 *oui, u8 tx) update_bcn_htinfo_ie(padapter); break; - case _VENDOR_SPECIFIC_IE_: + case WLAN_EID_VENDOR_SPECIFIC: update_bcn_vendor_spec_ie(padapter, oui); break; diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index a48ab25a7d8a..b01dd008e913 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -469,7 +469,8 @@ unsigned char *rtw_get_wpa_ie23a(unsigned char *pie, int *wpa_ie_len, int limit) int limit_new = limit; while(1) { - pbuf = rtw_get_ie23a(pbuf, _WPA_IE_ID_, &len, limit_new); + pbuf = rtw_get_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, + &len, limit_new); if (pbuf) { /* check if oui matches... */ @@ -557,7 +558,8 @@ int rtw_parse_wpa_ie23a(u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pair return _FAIL; } - if ((*wpa_ie != _WPA_IE_ID_) || (*(wpa_ie+1) != (u8)(wpa_ie_len - 2)) || + if ((*wpa_ie != WLAN_EID_VENDOR_SPECIFIC) || + (*(wpa_ie+1) != (u8)(wpa_ie_len - 2)) || memcmp(wpa_ie + 2, RTW_WPA_OUI23A_TYPE, WPA_SELECTOR_LEN)) { return _FAIL; } @@ -719,7 +721,7 @@ int rtw_get_sec_ie23a(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, while(cnt < in_len) { authmode = in_ie[cnt]; - if ((authmode == _WPA_IE_ID_) && + if ((authmode == WLAN_EID_VENDOR_SPECIFIC) && !memcmp(&in_ie[cnt+2], &wpa_oui[0], 4)) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\n rtw_get_wpa_ie23a: sec_idx =%d " @@ -788,7 +790,8 @@ u8 rtw_is_wps_ie23a(u8 *ie_ptr, uint *wps_ielen) eid = ie_ptr[0]; - if ((eid == _WPA_IE_ID_) && !memcmp(&ie_ptr[2], wps_oui, 4)) { + if ((eid == WLAN_EID_VENDOR_SPECIFIC) && + !memcmp(&ie_ptr[2], wps_oui, 4)) { /* DBG_8723A("==> found WPS_IE.....\n"); */ *wps_ielen = ie_ptr[1] + 2; match = true; @@ -824,7 +827,8 @@ u8 *rtw_get_wps_ie23a(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen) while (cnt < in_len) { eid = in_ie[cnt]; - if ((eid == _WPA_IE_ID_) && !memcmp(&in_ie[cnt+2], wps_oui, 4)) { + if ((eid == WLAN_EID_VENDOR_SPECIFIC) && + !memcmp(&in_ie[cnt+2], wps_oui, 4)) { wpsie_ptr = &in_ie[cnt]; if (wps_ie) @@ -866,7 +870,7 @@ u8 *rtw_get_wps_attr23a(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, if (len_attr) *len_attr = 0; - if ((wps_ie[0] != _VENDOR_SPECIFIC_IE_) || + if ((wps_ie[0] != WLAN_EID_VENDOR_SPECIFIC) || memcmp(wps_ie + 2, wps_oui, 4)) { return attr_ptr; } @@ -1305,7 +1309,7 @@ u8 *rtw_get_p2p_ie23a(u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen) dump_stack(); return NULL; } - if ((eid == _VENDOR_SPECIFIC_IE_) && + if ((eid == WLAN_EID_VENDOR_SPECIFIC) && !memcmp(&in_ie[cnt + 2], p2p_oui, 4)) { p2p_ie_ptr = in_ie + cnt; @@ -1351,7 +1355,7 @@ u8 *rtw_get_p2p_attr23a(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id, if (len_attr) *len_attr = 0; - if (!p2p_ie || (p2p_ie[0] != _VENDOR_SPECIFIC_IE_) || + if (!p2p_ie || (p2p_ie[0] != WLAN_EID_VENDOR_SPECIFIC) || memcmp(p2p_ie + 2, p2p_oui, 4)) { return attr_ptr; } @@ -1531,7 +1535,7 @@ int rtw_get_wfd_attr_content(u8 *wfd_ie, uint wfd_ielen, u8 target_attr_id, match = false; - if ((wfd_ie[0] != _VENDOR_SPECIFIC_IE_) || + if ((wfd_ie[0] != WLAN_EID_VENDOR_SPECIFIC) || memcmp(wfd_ie + 2, wfd_oui, 4)) { return match; } diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 1060a9fab64f..d94cff681ad4 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -2014,7 +2014,7 @@ _rtw_report_sec_ie(struct rtw_adapter *adapter, u8 authmode, u8 *sec_ie) ("+_rtw_report_sec_ie, authmode =%d\n", authmode)); buff = NULL; - if (authmode == _WPA_IE_ID_) { + if (authmode == WLAN_EID_VENDOR_SPECIFIC) { RT_TRACE(_module_mlme_osdep_c_, _drv_info_, ("_rtw_report_sec_ie, authmode =%d\n", authmode)); @@ -2064,7 +2064,7 @@ int rtw_restruct_sec_ie23a(struct rtw_adapter *adapter, u8 *in_ie, u8 *out_ie, ielength = 12; if ((ndisauthmode==Ndis802_11AuthModeWPA) || (ndisauthmode==Ndis802_11AuthModeWPAPSK)) - authmode=_WPA_IE_ID_; + authmode = WLAN_EID_VENDOR_SPECIFIC; if ((ndisauthmode==Ndis802_11AuthModeWPA2) || (ndisauthmode==Ndis802_11AuthModeWPA2PSK)) authmode=_WPA2_IE_ID_; @@ -2074,7 +2074,8 @@ int rtw_restruct_sec_ie23a(struct rtw_adapter *adapter, u8 *in_ie, u8 *out_ie, psecuritypriv->wps_ie_len); ielength += psecuritypriv->wps_ie_len; - } else if ((authmode==_WPA_IE_ID_) || (authmode==_WPA2_IE_ID_)) { + } else if ((authmode == WLAN_EID_VENDOR_SPECIFIC) || + (authmode==_WPA2_IE_ID_)) { /* copy RSN or SSN */ memcpy(&out_ie[ielength], &psecuritypriv->supplicant_ie[0], psecuritypriv->supplicant_ie[1] + 2); @@ -2242,7 +2243,7 @@ unsigned int rtw_restructure_ht_ie23a(struct rtw_adapter *padapter, u8 *in_ie, if (pqospriv->qos_option == 0) { out_len = *pout_len; pframe = rtw_set_ie23a(out_ie + out_len, - _VENDOR_SPECIFIC_IE_, + WLAN_EID_VENDOR_SPECIFIC, _WMM_IE_Length_, WMM_IE, pout_len); pqospriv->qos_option = 1; diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 07493bc70539..423f3956d063 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1543,7 +1543,10 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec p = pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset; ie_len = 0; for (;;) { - p = rtw_get_ie23a(p, _VENDOR_SPECIFIC_IE_, &ie_len, pkt_len - sizeof(struct ieee80211_hdr_3addr) - ie_offset); + p = rtw_get_ie23a(p, WLAN_EID_VENDOR_SPECIFIC, &ie_len, + pkt_len - + sizeof(struct ieee80211_hdr_3addr) - + ie_offset); if (p != NULL) { if (!memcmp(p+2, WMM_IE, 6)) { @@ -1826,7 +1829,7 @@ unsigned int OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *prec switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_: + case WLAN_EID_VENDOR_SPECIFIC: if (!memcmp(pIE->data, WMM_PARA_OUI23A, 6))/* WMM */ WMM_param_handler23a(padapter, pIE); #if defined(CONFIG_8723AU_P2P) @@ -2245,7 +2248,8 @@ void issue_p2p_GO_request23a(struct rtw_adapter *padapter, u8* raddr) wpsielen += 2; - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *) wpsie, &pattrib->pktlen); + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, wpsielen, + (unsigned char *) wpsie, &pattrib->pktlen); /* P2P IE Section. */ @@ -2497,7 +2501,8 @@ void issue_p2p_GO_request23a(struct rtw_adapter *padapter, u8* raddr) /* Channel Number */ p2pie[p2pielen++] = pwdinfo->operating_channel; /* operating channel number */ - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *) p2pie, &pattrib->pktlen); + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, + (unsigned char *) p2pie, &pattrib->pktlen); #ifdef CONFIG_8723AU_P2P wfdielen = build_nego_req_wfd_ie(pwdinfo, pframe); @@ -2641,7 +2646,7 @@ static void issue_p2p_GO_response(struct rtw_adapter *padapter, u8* raddr, u8* f } } - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, wpsielen, (unsigned char *) wpsie, &pattrib->pktlen); /* P2P IE Section. */ @@ -2910,7 +2915,7 @@ static void issue_p2p_GO_response(struct rtw_adapter *padapter, u8* raddr, u8* f } - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, (unsigned char *) p2pie, &pattrib->pktlen); #ifdef CONFIG_8723AU_P2P @@ -3115,7 +3120,7 @@ static void issue_p2p_GO_confirm(struct rtw_adapter *padapter, u8* raddr, p2pielen += pwdinfo->nego_ssidlen; } - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); #ifdef CONFIG_8723AU_P2P @@ -3393,7 +3398,7 @@ void issue_p2p_invitation_request23a(struct rtw_adapter *padapter, u8* raddr) pwdinfo->device_name_len); p2pielen += pwdinfo->device_name_len; - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, (unsigned char *) p2pie, &pattrib->pktlen); #ifdef CONFIG_8723AU_P2P @@ -3612,7 +3617,7 @@ void issue_p2p_invitation_response23a(struct rtw_adapter *padapter, u8 *raddr, } } - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); #ifdef CONFIG_8723AU_P2P @@ -3721,7 +3726,7 @@ void issue_p2p_provision_request23a(struct rtw_adapter *padapter, u8 *pssid, *(u16*) (wpsie + wpsielen) = cpu_to_be16(pwdinfo->tx_prov_disc_info.wps_config_method_request); wpsielen += 2; - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, wpsielen, (unsigned char *) wpsie, &pattrib->pktlen); #ifdef CONFIG_8723AU_P2P @@ -4047,8 +4052,8 @@ void issue_probersp23a_p2p23a(struct rtw_adapter *padapter, unsigned char *da) cpu_to_be16(pwdinfo->supported_wps_cm); wpsielen += 2; - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, - (unsigned char *)wpsie, + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, + wpsielen, (unsigned char *)wpsie, &pattrib->pktlen); p2pielen = build_probe_resp_p2p_ie23a(pwdinfo, pframe); @@ -4283,8 +4288,8 @@ static int _issue23a_probereq_p2p(struct rtw_adapter *padapter, u8 *da, cpu_to_be16(WPS_DPID_REGISTRAR_SPEC); wpsielen += 2; - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, - (unsigned char *)wpsie, + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, + wpsielen, (unsigned char *)wpsie, &pattrib->pktlen); /* P2P OUI */ @@ -4393,8 +4398,8 @@ static int _issue23a_probereq_p2p(struct rtw_adapter *padapter, u8 *da, p2pie[p2pielen++] = pwdinfo->operating_channel; } - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, - (unsigned char *)p2pie, + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, + p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); if (pmlmepriv->wps_probe_req_ie) { @@ -6239,7 +6244,7 @@ void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status, 0x01, 0x01}; for (pbuf = ie + _BEACON_IE_OFFSET_; ; pbuf += (ie_len + 2)) { - pbuf = rtw_get_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, + pbuf = rtw_get_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, &ie_len, (pnetwork->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); @@ -6257,7 +6262,7 @@ void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status, } if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) { - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, 6, + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, 6, REALTEK_96B_IE23A, &pattrib->pktlen); } @@ -6513,7 +6518,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_: + case WLAN_EID_VENDOR_SPECIFIC: if (!memcmp(pIE->data, RTW_WPA_OUI23A, 4) || !memcmp(pIE->data, WMM_OUI23A, 4) || !memcmp(pIE->data, WPS_OUI23A, 4)) { @@ -6526,7 +6531,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) pIE->Length = 14; } pframe = rtw_set_ie23a(pframe, - _VENDOR_SPECIFIC_IE_, + WLAN_EID_VENDOR_SPECIFIC, pIE->Length, pIE->data, &pattrib->pktlen); } @@ -6540,7 +6545,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) } if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, 6, + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, 6, REALTEK_96B_IE23A, &pattrib->pktlen); #ifdef CONFIG_8723AU_P2P @@ -6704,7 +6709,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) ETH_ALEN); /* P2P Interface Address List */ p2pielen += ETH_ALEN; - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); @@ -9300,7 +9305,7 @@ u8 join_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_:/* Get WMM IE. */ + case WLAN_EID_VENDOR_SPECIFIC:/* Get WMM IE. */ if (!memcmp(pIE->data, WMM_OUI23A, 4)) pmlmeinfo->WMM_enable = 1; break; diff --git a/drivers/staging/rtl8723au/core/rtw_p2p.c b/drivers/staging/rtl8723au/core/rtw_p2p.c index a3bf031ee738..22753e34848e 100644 --- a/drivers/staging/rtl8723au/core/rtw_p2p.c +++ b/drivers/staging/rtl8723au/core/rtw_p2p.c @@ -256,7 +256,8 @@ static void issue_p2p_devdisc_resp(struct wifidirect_info *pwdinfo, u8 *da, u8 s /* P2P_ATTR_STATUS */ p2pielen += rtw_set_p2p_attr_content23a(&p2pie[p2pielen], P2P_ATTR_STATUS, 1, &status); - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, p2pie, &pattrib->pktlen); + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, + p2pie, &pattrib->pktlen); pattrib->last_txcmdsz = pattrib->pktlen; @@ -340,7 +341,8 @@ static void issue_p2p_provision_resp(struct wifidirect_info *pwdinfo, u8* raddr, put_unaligned_be16(config_method, wpsie + wpsielen); wpsielen += 2; - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *) wpsie, &pattrib->pktlen); + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, wpsielen, + (unsigned char *) wpsie, &pattrib->pktlen); #ifdef CONFIG_8723AU_P2P wfdielen = build_provdisc_resp_wfd_ie(pwdinfo, pframe); @@ -428,8 +430,8 @@ static void issue_p2p_presence_resp(struct wifidirect_info *pwdinfo, u8 *da, u8 p2pielen += rtw_set_p2p_attr_content23a(&p2pie[p2pielen], P2P_ATTR_NOA, 2, noa_attr_content); - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, p2pie, - &pattrib->pktlen); + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, + p2pie, &pattrib->pktlen); pattrib->last_txcmdsz = pattrib->pktlen; @@ -481,7 +483,8 @@ u32 build_beacon_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf) /* go_add_noa_attr(pwdinfo); */ - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *) p2pie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, p2pielen, + (unsigned char *) p2pie, &len); return len; } @@ -602,7 +605,8 @@ u32 build_beacon_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) wfdie[ wfdielen++ ] = 0; wfdie[ wfdielen++ ] = 0; - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, + (unsigned char *) wfdie, &len); return len; } @@ -713,7 +717,8 @@ u32 build_probe_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) wfdie[ wfdielen++ ] = 0; wfdie[ wfdielen++ ] = 0; - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, + (unsigned char *) wfdie, &len); return len; } @@ -900,7 +905,8 @@ u32 build_probe_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 tunnel } - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, + (unsigned char *) wfdie, &len); return len; } @@ -1007,7 +1013,8 @@ u32 build_assoc_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) wfdie[ wfdielen++ ] = 0; wfdie[ wfdielen++ ] = 0; - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, + (unsigned char *) wfdie, &len); return len; } @@ -1105,7 +1112,8 @@ u32 build_assoc_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) wfdie[ wfdielen++ ] = 0; wfdie[ wfdielen++ ] = 0; - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, + (unsigned char *) wfdie, &len); return len; } @@ -1203,7 +1211,8 @@ u32 build_nego_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) wfdie[ wfdielen++ ] = 0; wfdie[ wfdielen++ ] = 0; - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, + (unsigned char *) wfdie, &len); return len; } @@ -1301,7 +1310,8 @@ u32 build_nego_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) wfdie[ wfdielen++ ] = 0; wfdie[ wfdielen++ ] = 0; - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, + (unsigned char *) wfdie, &len); return len; } @@ -1398,7 +1408,8 @@ u32 build_nego_confirm_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) wfdie[ wfdielen++ ] = 0; wfdie[ wfdielen++ ] = 0; - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, + (unsigned char *) wfdie, &len); return len; } @@ -1511,7 +1522,8 @@ u32 build_invitation_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) } - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, + (unsigned char *) wfdie, &len); return len; } @@ -1624,7 +1636,8 @@ u32 build_invitation_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) } - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, + (unsigned char *) wfdie, &len); return len; } @@ -1722,7 +1735,8 @@ u32 build_provdisc_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) wfdie[ wfdielen++ ] = 0; wfdie[ wfdielen++ ] = 0; - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, + (unsigned char *) wfdie, &len); return len; } @@ -1820,7 +1834,8 @@ u32 build_provdisc_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) wfdie[ wfdielen++ ] = 0; wfdie[ wfdielen++ ] = 0; - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, + (unsigned char *) wfdie, &len); return len; } @@ -1973,7 +1988,8 @@ u32 build_probe_resp_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf) p2pielen += go_add_group_info_attr(pwdinfo, p2pie + p2pielen); } - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *) p2pie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, p2pielen, + (unsigned char *) p2pie, &len); return len; } @@ -2103,7 +2119,8 @@ u32 build_prov_disc_request_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf, } - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *) p2pie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, p2pielen, + (unsigned char *) p2pie, &len); return len; } @@ -2132,7 +2149,8 @@ u32 build_assoc_resp_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 sta /* Length: */ /* Value: */ - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *) p2pie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, p2pielen, + (unsigned char *) p2pie, &len); return len; } diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index f54021ceba5c..8f0e79e9664f 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -1130,7 +1130,7 @@ unsigned int is_ap_in_tkip23a(struct rtw_adapter *padapter) pIE = (struct ndis_802_11_var_ies *)(pmlmeinfo->network.IEs + i); switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_: + case WLAN_EID_VENDOR_SPECIFIC: if ((!memcmp(pIE->data, RTW_WPA_OUI23A, 4)) && (!memcmp((pIE->data + 12), WPA_TKIP_CIPHER23A, 4))) return true; break; @@ -1161,7 +1161,7 @@ unsigned int should_forbid_n_rate23a(struct rtw_adapter * padapter) pIE = (struct ndis_802_11_var_ies *)(cur_network->IEs + i); switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_: + case WLAN_EID_VENDOR_SPECIFIC: if (!memcmp(pIE->data, RTW_WPA_OUI23A, 4) && ((!memcmp((pIE->data + 12), WPA_CIPHER_SUITE_CCMP23A, 4)) || (!memcmp((pIE->data + 16), WPA_CIPHER_SUITE_CCMP23A, 4)))) @@ -1196,7 +1196,7 @@ unsigned int is_ap_in_wep23a(struct rtw_adapter *padapter) pIE = (struct ndis_802_11_var_ies *)(pmlmeinfo->network.IEs + i); switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_: + case WLAN_EID_VENDOR_SPECIFIC: if (!memcmp(pIE->data, RTW_WPA_OUI23A, 4)) return false; break; @@ -1404,7 +1404,7 @@ unsigned char check_assoc_AP23a(u8 *pframe, uint len) pIE = (struct ndis_802_11_var_ies *)(pframe + i); switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_: + case WLAN_EID_VENDOR_SPECIFIC: if ((!memcmp(pIE->data, ARTHEROS_OUI1, 3)) || (!memcmp(pIE->data, ARTHEROS_OUI2, 3))) { DBG_8723A("link to Artheros AP\n"); diff --git a/drivers/staging/rtl8723au/include/rtw_security.h b/drivers/staging/rtl8723au/include/rtw_security.h index 75bbb934a53c..fcb43bd15b89 100644 --- a/drivers/staging/rtl8723au/include/rtw_security.h +++ b/drivers/staging/rtl8723au/include/rtw_security.h @@ -30,7 +30,6 @@ #define is_wep_enc(alg) (((alg) == _WEP40_) || ((alg) == _WEP104_)) -#define _WPA_IE_ID_ 0xdd #define _WPA2_IE_ID_ 0x30 #define SHA256_MAC_LEN 32 diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index b5034c6ef1dc..a8695f435968 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -229,7 +229,6 @@ static inline unsigned char *get_hdr_bssid(unsigned char *pframe) #define _SUPPORTED_CH_IE_ 36 #define _CH_SWTICH_ANNOUNCE_ 37 /* Secondary Channel Offset */ #define _RSN_IE_2_ 48 -#define _SSN_IE_1_ 221 #define _ERPINFO_IE_ 42 #define _EXT_SUPPORTEDRATES_IE_ 50 @@ -249,7 +248,6 @@ static inline unsigned char *get_hdr_bssid(unsigned char *pframe) #define _CH_SWITCH_TIMING_ 104 #define _PTI_BUFFER_STATUS_ 106 #define _EXT_CAP_IE_ 127 -#define _VENDOR_SPECIFIC_IE_ 221 #define _RESERVED47_ 47 diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 86721dc7c1b9..a0d59c7963d1 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -2986,10 +2986,10 @@ static int rtw_add_beacon(struct rtw_adapter *adapter, const u8 *head, #endif /* pbss_network->IEs will not include p2p_ie, wfd ie */ - rtw_ies_remove_ie23a(pbuf, &len, _BEACON_IE_OFFSET_, _VENDOR_SPECIFIC_IE_, - P2P_OUI23A, 4); - rtw_ies_remove_ie23a(pbuf, &len, _BEACON_IE_OFFSET_, _VENDOR_SPECIFIC_IE_, - WFD_OUI23A, 4); + rtw_ies_remove_ie23a(pbuf, &len, _BEACON_IE_OFFSET_, + WLAN_EID_VENDOR_SPECIFIC, P2P_OUI23A, 4); + rtw_ies_remove_ie23a(pbuf, &len, _BEACON_IE_OFFSET_, + WLAN_EID_VENDOR_SPECIFIC, WFD_OUI23A, 4); if (rtw_check_beacon_data23a(adapter, pbuf, len) == _SUCCESS) { #ifdef CONFIG_8723AU_P2P @@ -3489,7 +3489,7 @@ void rtw_cfg80211_issue_p2p_provision_request23a(struct rtw_adapter *padapter, memcpy(p2p_ie + p2pielen, devinfo_content, devinfo_contentlen); p2pielen += devinfo_contentlen; - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, (unsigned char *)p2p_ie, &p2p_ielen); pattrib->pktlen += p2p_ielen; @@ -3524,7 +3524,7 @@ void rtw_cfg80211_issue_p2p_provision_request23a(struct rtw_adapter *padapter, cpu_to_be16(pwdinfo->tx_prov_disc_info.wps_config_method_request); wpsielen += 2; - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, wpsielen, (unsigned char *)wpsie, &pattrib->pktlen); #ifdef CONFIG_8723AU_P2P @@ -3897,8 +3897,8 @@ static int rtw_cfg80211_set_beacon_wpsp2pie(struct net_device *ndev, char *buf, pmlmepriv->wps_beacon_ie_len = wps_ielen; #ifdef CONFIG_8723AU_AP_MODE - update_beacon23a(padapter, _VENDOR_SPECIFIC_IE_, wps_oui, - true); + update_beacon23a(padapter, WLAN_EID_VENDOR_SPECIFIC, + wps_oui, true); #endif } #ifdef CONFIG_8723AU_P2P -- cgit v1.2.3 From 1a2818fb28813eacde2cc6454dc628e0622c5874 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:22 +0200 Subject: staging: rtl8723au: rtw_security.h - remove some unused macros Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtw_security.h | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/drivers/staging/rtl8723au/include/rtw_security.h b/drivers/staging/rtl8723au/include/rtw_security.h index fcb43bd15b89..702dd845a3ff 100644 --- a/drivers/staging/rtl8723au/include/rtw_security.h +++ b/drivers/staging/rtl8723au/include/rtw_security.h @@ -315,22 +315,6 @@ static const unsigned long K[64] = { 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL }; -/* Various logical functions */ -#define RORc(x, y) \ -(((((unsigned long)(x) & 0xFFFFFFFFUL) >> (unsigned long) ((y) & 31)) | \ -((unsigned long)(x) << (unsigned long) (32 - ((y) & 31)))) & 0xFFFFFFFFUL) -#define Ch(x, y, z) (z ^ (x & (y ^ z))) -#define Maj(x, y, z) (((x | y) & z) | (x & y)) -#define S(x, n) RORc((x), (n)) -#define R(x, n) (((x)&0xFFFFFFFFUL)>>(n)) -#define Sigma0(x) (S(x, 2) ^ S(x, 13) ^ S(x, 22)) -#define Sigma1(x) (S(x, 6) ^ S(x, 11) ^ S(x, 25)) -#define Gamma0(x) (S(x, 7) ^ S(x, 18) ^ R(x, 3)) -#define Gamma1(x) (S(x, 17) ^ S(x, 19) ^ R(x, 10)) -#ifndef MIN -#define MIN(x, y) (((x) < (y)) ? (x) : (y)) -#endif - void rtw_secmicsetkey23a(struct mic_data *pmicdata, u8 *key); void rtw_secmicappend23abyte23a(struct mic_data *pmicdata, u8 b); void rtw_secmicappend23a(struct mic_data *pmicdata, u8 *src, u32 nbBytes); -- cgit v1.2.3 From 7a65382f49f139f26425803d492538340897f982 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:23 +0200 Subject: staging: rtl8723au: make source * argument const Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 2 +- drivers/staging/rtl8723au/include/ieee80211.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index b01dd008e913..626a9df2645d 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -131,7 +131,7 @@ u8 *rtw_set_fixed_ie23a(unsigned char *pbuf, unsigned int len, } /* rtw_set_ie23a will update frame length */ -u8 *rtw_set_ie23a(u8 *pbuf, int index, uint len, u8 *source, uint *frlen) +u8 *rtw_set_ie23a(u8 *pbuf, int index, uint len, const u8 *source, uint *frlen) { *pbuf = (u8)index; diff --git a/drivers/staging/rtl8723au/include/ieee80211.h b/drivers/staging/rtl8723au/include/ieee80211.h index 28e4ab239fb9..61326e5e089c 100644 --- a/drivers/staging/rtl8723au/include/ieee80211.h +++ b/drivers/staging/rtl8723au/include/ieee80211.h @@ -518,7 +518,7 @@ enum parse_res rtw_ieee802_11_parse_elems23a(u8 *start, uint len, int show_errors); u8 *rtw_set_fixed_ie23a(unsigned char *pbuf, unsigned int len, unsigned char *source, unsigned int *frlen); -u8 *rtw_set_ie23a(u8 *pbuf, int index, uint len, u8 *source, uint *frlen); +u8 *rtw_set_ie23a(u8 *pbuf, int index, uint len, const u8 *source, uint *frlen); enum secondary_ch_offset { SCN = 0, /* no secondary channel */ -- cgit v1.2.3 From 5afd391a572b48b559a91b97cf0645580cf46da2 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:24 +0200 Subject: staging: rtl8723au: rtw_mlme_ext.c: Use the kernel's WLAN_EID_* definitions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 149 ++++++++++++++------------ 1 file changed, 83 insertions(+), 66 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 423f3956d063..9b9124c531ec 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -727,7 +727,7 @@ _continue: } p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + - _PROBEREQ_IE_OFFSET_, _SSID_IE_, (int *)&ielen, + _PROBEREQ_IE_OFFSET_, WLAN_EID_SSID, (int *)&ielen, len - sizeof(struct ieee80211_hdr_3addr) - _PROBEREQ_IE_OFFSET_); @@ -839,7 +839,7 @@ unsigned int OnBeacon23a(struct rtw_adapter *padapter, u32 ielen = 0; p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + - _BEACON_IE_OFFSET_, _EXT_SUPPORTEDRATES_IE_, &ielen, + _BEACON_IE_OFFSET_, WLAN_EID_EXT_SUPP_RATES, &ielen, len - sizeof(struct ieee80211_hdr_3addr) - _BEACON_IE_OFFSET_); if ((p != NULL) && (ielen > 0)) { @@ -1089,7 +1089,8 @@ unsigned int OnAuth23a(struct rtw_adapter *padapter, p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + - 4 + _AUTH_IE_OFFSET_, _CHLGETXT_IE_, + 4 + _AUTH_IE_OFFSET_, + WLAN_EID_CHALLENGE, (int *)&ie_len, len - sizeof(struct ieee80211_hdr_3addr) - _AUTH_IE_OFFSET_ - 4); @@ -1197,7 +1198,7 @@ unsigned int OnAuth23aClient23a(struct rtw_adapter *padapter, if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) { /* legendary shared system */ - p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + _AUTH_IE_OFFSET_, _CHLGETXT_IE_, (int *)&len, + p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + _AUTH_IE_OFFSET_, WLAN_EID_CHALLENGE, (int *)&len, pkt_len - sizeof(struct ieee80211_hdr_3addr) - _AUTH_IE_OFFSET_); if (p == NULL) @@ -1351,8 +1352,9 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec /* now we should check all the fields... */ /* checking SSID */ - p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset, _SSID_IE_, &ie_len, - pkt_len - sizeof(struct ieee80211_hdr_3addr) - ie_offset); + p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + + ie_offset, WLAN_EID_SSID, &ie_len, pkt_len - + sizeof(struct ieee80211_hdr_3addr) - ie_offset); if (p == NULL) { status = WLAN_STATUS_UNSPECIFIED_FAILURE; @@ -1373,7 +1375,7 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec goto OnAssocReq23aFail; /* check if the supported rate is ok */ - p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset, _SUPPORTEDRATES_IE_, &ie_len, pkt_len - sizeof(struct ieee80211_hdr_3addr) - ie_offset); + p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset, WLAN_EID_SUPP_RATES, &ie_len, pkt_len - sizeof(struct ieee80211_hdr_3addr) - ie_offset); if (p == NULL) { DBG_8723A("Rx a sta assoc-req which supported rate is empty!\n"); /* use our own rate set as statoin used */ @@ -1386,7 +1388,7 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec memcpy(supportRate, p+2, ie_len); supportRateNum = ie_len; - p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset, _EXT_SUPPORTEDRATES_IE_, &ie_len, + p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset, WLAN_EID_EXT_SUPP_RATES, &ie_len, pkt_len - sizeof(struct ieee80211_hdr_3addr) - ie_offset); if (p != NULL) { @@ -1840,15 +1842,15 @@ unsigned int OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *prec #endif break; - case _HT_CAPABILITY_IE_: /* HT caps */ + case WLAN_EID_HT_CAPABILITY: /* HT caps */ HT_caps_handler23a(padapter, pIE); break; - case _HT_EXTRA_INFO_IE_: /* HT info */ + case WLAN_EID_HT_OPERATION: /* HT info */ HT_info_handler23a(padapter, pIE); break; - case _ERPINFO_IE_: + case WLAN_EID_ERP_INFO: ERP_IE_handler23a(padapter, pIE); default: @@ -3847,22 +3849,24 @@ void issue_probersp23a_p2p23a(struct rtw_adapter *padapter, unsigned char *da) pattrib->pktlen += 2; /* SSID */ - pframe = rtw_set_ie23a(pframe, _SSID_IE_, 7, pwdinfo->p2p_wildcard_ssid, - &pattrib->pktlen); + pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID, 7, + pwdinfo->p2p_wildcard_ssid, &pattrib->pktlen); /* supported rates... */ /* Use the OFDM rate in the P2P probe response frame. (6(B), 9(B), 12, 18, 24, 36, 48, 54) */ - pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_, 8, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, 8, pwdinfo->support_rate, &pattrib->pktlen); /* DS parameter set */ if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled && listen_channel != 0) { - pframe = rtw_set_ie23a(pframe, _DSSET_IE_, 1, (unsigned char *) - &listen_channel, &pattrib->pktlen); + pframe = rtw_set_ie23a(pframe, WLAN_EID_DS_PARAMS, 1, + (unsigned char *) &listen_channel, + &pattrib->pktlen); } else { - pframe = rtw_set_ie23a(pframe, _DSSET_IE_, 1, (unsigned char *) + pframe = rtw_set_ie23a(pframe, WLAN_EID_DS_PARAMS, 1, + (unsigned char *) &pwdinfo->listen_channel, &pattrib->pktlen); } @@ -4149,19 +4153,19 @@ static int _issue23a_probereq_p2p(struct rtw_adapter *padapter, u8 *da, pattrib->pktlen = sizeof (struct ieee80211_hdr_3addr); if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ)) { - pframe = rtw_set_ie23a(pframe, _SSID_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID, pwdinfo->tx_prov_disc_info.ssid.ssid_len, pwdinfo->tx_prov_disc_info.ssid.ssid, &pattrib->pktlen); } else { - pframe = rtw_set_ie23a(pframe, _SSID_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID, P2P_WILDCARD_SSID_LEN, pwdinfo->p2p_wildcard_ssid, &pattrib->pktlen); } /* Use the OFDM rate in the P2P probe request frame. (6(B), 9(B), 12(B), 24(B), 36, 48, 54) */ - pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_, 8, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, 8, pwdinfo->support_rate, &pattrib->pktlen); if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled) { @@ -5507,17 +5511,18 @@ void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms) pattrib->pktlen += 2; /* SSID */ - pframe = rtw_set_ie23a(pframe, _SSID_IE_, cur_network->Ssid.ssid_len, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID, + cur_network->Ssid.ssid_len, cur_network->Ssid.ssid, &pattrib->pktlen); /* supported rates... */ rate_len = rtw_get_rateset_len23a(cur_network->SupportedRates); - pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, ((rate_len > 8)? 8: rate_len), cur_network->SupportedRates, &pattrib->pktlen); /* DS parameter set */ - pframe = rtw_set_ie23a(pframe, _DSSET_IE_, 1, (unsigned char *) + pframe = rtw_set_ie23a(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *) &cur_network->Configuration.DSConfig, &pattrib->pktlen); @@ -5528,18 +5533,18 @@ void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms) /* IBSS Parameter Set... */ /* ATIMWindow = cur->Configuration.ATIMWindow; */ ATIMWindow = 0; - pframe = rtw_set_ie23a(pframe, _IBSS_PARA_IE_, 2, + pframe = rtw_set_ie23a(pframe, WLAN_EID_IBSS_PARAMS, 2, (unsigned char *)&ATIMWindow, &pattrib->pktlen); /* ERP IE */ - pframe = rtw_set_ie23a(pframe, _ERPINFO_IE_, 1, + pframe = rtw_set_ie23a(pframe, WLAN_EID_ERP_INFO, 1, &erpinfo, &pattrib->pktlen); } /* EXTERNDED SUPPORTED RATE */ if (rate_len > 8) - pframe = rtw_set_ie23a(pframe, _EXT_SUPPORTEDRATES_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_EXT_SUPP_RATES, rate_len - 8, cur_network->SupportedRates + 8, &pattrib->pktlen); @@ -5685,7 +5690,7 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, ies = pmgntframe->buf_addr + TXDESC_OFFSET + sizeof(struct ieee80211_hdr_3addr); - ssid_ie = rtw_get_ie23a(ies+_FIXED_IE_LENGTH_, _SSID_IE_, + ssid_ie = rtw_get_ie23a(ies+_FIXED_IE_LENGTH_, WLAN_EID_SSID, &ssid_ielen, (pframe-ies)-_FIXED_IE_LENGTH_); @@ -5741,19 +5746,20 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, /* below for ad-hoc mode */ /* SSID */ - pframe = rtw_set_ie23a(pframe, _SSID_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID, cur_network->Ssid.ssid_len, cur_network->Ssid.ssid, &pattrib->pktlen); /* supported rates... */ rate_len = rtw_get_rateset_len23a(cur_network->SupportedRates); - pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, ((rate_len > 8)? 8: rate_len), cur_network->SupportedRates, &pattrib->pktlen); /* DS parameter set */ - pframe = rtw_set_ie23a(pframe, _DSSET_IE_, 1, (unsigned char *) + pframe = rtw_set_ie23a(pframe, WLAN_EID_DS_PARAMS, 1, + (unsigned char *) &cur_network->Configuration.DSConfig, &pattrib->pktlen); @@ -5763,18 +5769,18 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, /* IBSS Parameter Set... */ /* ATIMWindow = cur->Configuration.ATIMWindow; */ ATIMWindow = 0; - pframe = rtw_set_ie23a(pframe, _IBSS_PARA_IE_, 2, + pframe = rtw_set_ie23a(pframe, WLAN_EID_IBSS_PARAMS, 2, (unsigned char *)&ATIMWindow, &pattrib->pktlen); /* ERP IE */ - pframe = rtw_set_ie23a(pframe, _ERPINFO_IE_, 1, + pframe = rtw_set_ie23a(pframe, WLAN_EID_ERP_INFO, 1, &erpinfo, &pattrib->pktlen); } /* EXTERNDED SUPPORTED RATE */ if (rate_len > 8) - pframe = rtw_set_ie23a(pframe, _EXT_SUPPORTEDRATES_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_EXT_SUPP_RATES, rate_len - 8, cur_network->SupportedRates + 8, &pattrib->pktlen); @@ -5878,22 +5884,22 @@ static int _issue_probereq23a(struct rtw_adapter *padapter, pattrib->pktlen = sizeof (struct ieee80211_hdr_3addr); if (pssid) - pframe = rtw_set_ie23a(pframe, _SSID_IE_, pssid->ssid_len, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID, pssid->ssid_len, pssid->ssid, &pattrib->pktlen); else - pframe = rtw_set_ie23a(pframe, _SSID_IE_, 0, NULL, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID, 0, NULL, &pattrib->pktlen); get_rate_set23a(padapter, bssrate, &bssrate_len); if (bssrate_len > 8) { - pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_, 8, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, 8, bssrate, &pattrib->pktlen); - pframe = rtw_set_ie23a(pframe, _EXT_SUPPORTEDRATES_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_EXT_SUPP_RATES, (bssrate_len - 8), (bssrate + 8), &pattrib->pktlen); } else { - pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, bssrate_len, bssrate, &pattrib->pktlen); } @@ -6049,7 +6055,7 @@ void issue_auth23a(struct rtw_adapter *padapter, struct sta_info *psta, /* added challenging text... */ if ((psta->auth_seq == 2) && (psta->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) - pframe = rtw_set_ie23a(pframe, _CHLGETXT_IE_, 128, + pframe = rtw_set_ie23a(pframe, WLAN_EID_CHALLENGE, 128, psta->chg_txt, &pattrib->pktlen); #endif } else { @@ -6108,7 +6114,7 @@ void issue_auth23a(struct rtw_adapter *padapter, struct sta_info *psta, if ((pmlmeinfo->auth_seq == 3) && (pmlmeinfo->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) { - pframe = rtw_set_ie23a(pframe, _CHLGETXT_IE_, 128, + pframe = rtw_set_ie23a(pframe, WLAN_EID_CHALLENGE, 128, pmlmeinfo->chg_txt, &pattrib->pktlen); @@ -6200,13 +6206,13 @@ void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status, &pattrib->pktlen); if (pstat->bssratelen <= 8) { - pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, pstat->bssratelen, pstat->bssrateset, &pattrib->pktlen); } else { - pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_, 8, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, 8, pstat->bssrateset, &pattrib->pktlen); - pframe = rtw_set_ie23a(pframe, _EXT_SUPPORTEDRATES_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_EXT_SUPP_RATES, pstat->bssratelen - 8, pstat->bssrateset + 8, &pattrib->pktlen); } @@ -6217,7 +6223,7 @@ void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status, /* FILL HT CAP INFO IE */ /* p = hostapd_eid_ht_capabilities_info(hapd, p); */ pbuf = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, - _HT_CAPABILITY_IE_, &ie_len, + WLAN_EID_HT_CAPABILITY, &ie_len, pnetwork->IELength - _BEACON_IE_OFFSET_); if (pbuf && ie_len>0) { memcpy(pframe, pbuf, ie_len + 2); @@ -6227,8 +6233,8 @@ void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status, /* FILL HT ADD INFO IE */ /* p = hostapd_eid_ht_operation(hapd, p); */ - pbuf = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _HT_ADD_INFO_IE_, - &ie_len, + pbuf = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, + WLAN_EID_HT_OPERATION, &ie_len, pnetwork->IELength - _BEACON_IE_OFFSET_); if (pbuf && ie_len > 0) { memcpy(pframe, pbuf, ie_len + 2); @@ -6356,7 +6362,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) pattrib->pktlen += 2; /* SSID */ - pframe = rtw_set_ie23a(pframe, _SSID_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID, pmlmeinfo->network.Ssid.ssid_len, pmlmeinfo->network.Ssid.ssid, &pattrib->pktlen); @@ -6418,29 +6424,29 @@ void issue_assocreq23a(struct rtw_adapter *padapter) } if (bssrate_len > 8) { - pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_, 8, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, 8, bssrate, &pattrib->pktlen); - pframe = rtw_set_ie23a(pframe, _EXT_SUPPORTEDRATES_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_EXT_SUPP_RATES, (bssrate_len - 8), (bssrate + 8), &pattrib->pktlen); } else - pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, bssrate_len, bssrate, &pattrib->pktlen); /* RSN */ p = rtw_get_ie23a((pmlmeinfo->network.IEs + - sizeof(struct ndis_802_11_fixed_ies)), _RSN_IE_2_, + sizeof(struct ndis_802_11_fixed_ies)), WLAN_EID_RSN, &ie_len, (pmlmeinfo->network.IELength - sizeof(struct ndis_802_11_fixed_ies))); if (p) - pframe = rtw_set_ie23a(pframe, _RSN_IE_2_, ie_len, (p + 2), + pframe = rtw_set_ie23a(pframe, WLAN_EID_RSN, ie_len, (p + 2), &pattrib->pktlen); /* HT caps */ if (padapter->mlmepriv.htpriv.ht_option == true) { p = rtw_get_ie23a((pmlmeinfo->network.IEs + sizeof(struct ndis_802_11_fixed_ies)), - _HT_CAPABILITY_IE_, &ie_len, + WLAN_EID_HT_CAPABILITY, &ie_len, (pmlmeinfo->network.IELength - sizeof(struct ndis_802_11_fixed_ies))); if ((p != NULL) && (!(is_ap_in_tkip23a(padapter)))) { @@ -6503,7 +6509,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) } #endif - pframe = rtw_set_ie23a(pframe, _HT_CAPABILITY_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_HT_CAPABILITY, ie_len, (u8 *)&pmlmeinfo->HT_caps, &pattrib->pktlen); @@ -7439,8 +7445,8 @@ static void issue_action_BSSCoexistPacket(struct rtw_adapter *padapter) iedata |= BIT(2);/* 20 MHz BSS Width Request */ - pframe = rtw_set_ie23a(pframe, EID_BSSCoexistence, 1, &iedata, &pattrib->pktlen); - + pframe = rtw_set_ie23a(pframe, WLAN_EID_BSS_COEX_2040, 1, + &iedata, &pattrib->pktlen); } /* */ @@ -7464,7 +7470,10 @@ static void issue_action_BSSCoexistPacket(struct rtw_adapter *padapter) pbss_network = &pnetwork->network; - p = rtw_get_ie23a(pbss_network->IEs + _FIXED_IE_LENGTH_, _HT_CAPABILITY_IE_, &len, pbss_network->IELength - _FIXED_IE_LENGTH_); + p = rtw_get_ie23a(pbss_network->IEs + _FIXED_IE_LENGTH_, + WLAN_EID_HT_CAPABILITY, &len, + pbss_network->IELength - + _FIXED_IE_LENGTH_); if ((p == NULL) || (len == 0))/* non-HT */ { if ((pbss_network->Configuration.DSConfig<= 0) || (pbss_network->Configuration.DSConfig>14)) @@ -7829,7 +7838,8 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, struct recv_frame *precv_fr bssid->PhyInfo.SignalStrength = precv_frame->attrib.phy_info.SignalStrength;/* in percentage */ /* checking SSID */ - if ((p = rtw_get_ie23a(bssid->IEs + ie_offset, _SSID_IE_, &len, bssid->IELength - ie_offset)) == NULL) + if ((p = rtw_get_ie23a(bssid->IEs + ie_offset, WLAN_EID_SSID, &len, + bssid->IELength - ie_offset)) == NULL) { DBG_8723A("marc: cannot find SSID for survey event\n"); return _FAIL; @@ -7851,7 +7861,8 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, struct recv_frame *precv_fr /* checking rate info... */ i = 0; - p = rtw_get_ie23a(bssid->IEs + ie_offset, _SUPPORTEDRATES_IE_, &len, bssid->IELength - ie_offset); + p = rtw_get_ie23a(bssid->IEs + ie_offset, WLAN_EID_SUPP_RATES, &len, + bssid->IELength - ie_offset); if (p != NULL) { if (len > NDIS_802_11_LENGTH_RATES_EX) @@ -7863,7 +7874,8 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, struct recv_frame *precv_fr i = len; } - p = rtw_get_ie23a(bssid->IEs + ie_offset, _EXT_SUPPORTEDRATES_IE_, &len, bssid->IELength - ie_offset); + p = rtw_get_ie23a(bssid->IEs + ie_offset, WLAN_EID_EXT_SUPP_RATES, + &len, bssid->IELength - ie_offset); if (p != NULL) { if (len > (NDIS_802_11_LENGTH_RATES_EX-i)) @@ -7883,7 +7895,8 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, struct recv_frame *precv_fr return _FAIL; /* Checking for DSConfig */ - p = rtw_get_ie23a(bssid->IEs + ie_offset, _DSSET_IE_, &len, bssid->IELength - ie_offset); + p = rtw_get_ie23a(bssid->IEs + ie_offset, WLAN_EID_DS_PARAMS, &len, + bssid->IELength - ie_offset); bssid->Configuration.DSConfig = 0; bssid->Configuration.Length = 0; @@ -7895,7 +7908,9 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, struct recv_frame *precv_fr else {/* In 5G, some ap do not have DSSET IE */ /* checking HT info for channel */ - p = rtw_get_ie23a(bssid->IEs + ie_offset, _HT_ADD_INFO_IE_, &len, bssid->IELength - ie_offset); + p = rtw_get_ie23a(bssid->IEs + ie_offset, + WLAN_EID_HT_OPERATION, &len, + bssid->IELength - ie_offset); if (p) { struct HT_info_element *HT_info = (struct HT_info_element *)(p + 2); @@ -7940,7 +7955,7 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, struct recv_frame *precv_fr { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - p = rtw_get_ie23a(bssid->IEs + ie_offset, _HT_CAPABILITY_IE_, &len, bssid->IELength - ie_offset); + p = rtw_get_ie23a(bssid->IEs + ie_offset, WLAN_EID_HT_CAPABILITY, &len, bssid->IELength - ie_offset); if (p && len > 0) { struct HT_caps_element *pHT_caps; pHT_caps = (struct HT_caps_element *)(p + 2); @@ -8171,7 +8186,9 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b u8 noc; /* number of channel */ u8 j, k; - ie = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, _COUNTRY_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); + ie = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, + WLAN_EID_COUNTRY, &len, + bssid->IELength - _FIXED_IE_LENGTH_); if (!ie) return; if (len < 6) return; @@ -9310,11 +9327,11 @@ u8 join_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) pmlmeinfo->WMM_enable = 1; break; - case _HT_CAPABILITY_IE_: /* Get HT Cap IE. */ + case WLAN_EID_HT_CAPABILITY: /* Get HT Cap IE. */ pmlmeinfo->HT_caps_enable = 1; break; - case _HT_EXTRA_INFO_IE_: /* Get HT Info IE. */ + case WLAN_EID_HT_OPERATION: /* Get HT Info IE. */ pmlmeinfo->HT_info_enable = 1; /* spec case only for cisco's ap because cisco's ap -- cgit v1.2.3 From a7eab38fe7d114597ebe6d6f6d5830804d9614f0 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:25 +0200 Subject: staging: rtl8723au: rtw_mlme.c: Use the kernel's WLAN_EID_* definitions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index d94cff681ad4..59b2c6cedcf7 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -2236,7 +2236,8 @@ unsigned int rtw_restructure_ht_ie23a(struct rtw_adapter *padapter, u8 *in_ie, phtpriv->ht_option = false; - p = rtw_get_ie23a(in_ie + 12, _HT_CAPABILITY_IE_, &ielen, in_len - 12); + p = rtw_get_ie23a(in_ie + 12, WLAN_EID_HT_CAPABILITY, &ielen, + in_len - 12); if (p && ielen > 0) { u32 rx_packet_offset, max_recvbuf_sz; @@ -2273,17 +2274,19 @@ unsigned int rtw_restructure_ht_ie23a(struct rtw_adapter *padapter, u8 *in_ie, ht_capie.ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_DENSITY & 0x00); - pframe = rtw_set_ie23a(out_ie + out_len, _HT_CAPABILITY_IE_, + pframe = rtw_set_ie23a(out_ie + out_len, WLAN_EID_HT_CAPABILITY, sizeof(struct ieee80211_ht_cap), (unsigned char*)&ht_capie, pout_len); phtpriv->ht_option = true; - p = rtw_get_ie23a(in_ie + 12, _HT_ADD_INFO_IE_, &ielen, in_len-12); + p = rtw_get_ie23a(in_ie + 12, WLAN_EID_HT_OPERATION, &ielen, + in_len-12); if (p && (ielen == sizeof(struct ieee80211_ht_addt_info))) { out_len = *pout_len; - pframe = rtw_set_ie23a(out_ie + out_len, _HT_ADD_INFO_IE_, - ielen, p + 2 , pout_len); + pframe = rtw_set_ie23a(out_ie + out_len, + WLAN_EID_HT_OPERATION, + ielen, p + 2 , pout_len); } } @@ -2327,7 +2330,9 @@ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len) /* check Max Rx A-MPDU Size */ len = 0; - p = rtw_get_ie23a(pie+sizeof (struct ndis_802_11_fixed_ies), _HT_CAPABILITY_IE_, &len, ie_len-sizeof (struct ndis_802_11_fixed_ies)); + p = rtw_get_ie23a(pie+sizeof (struct ndis_802_11_fixed_ies), + WLAN_EID_HT_CAPABILITY, &len, + ie_len-sizeof (struct ndis_802_11_fixed_ies)); if (p && len > 0) { pht_capie = (struct ieee80211_ht_cap *)(p+2); max_ampdu_sz = (pht_capie->ampdu_params_info & IEEE80211_HT_AMPDU_PARM_FACTOR); @@ -2339,7 +2344,9 @@ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len) } len = 0; - p = rtw_get_ie23a(pie+sizeof (struct ndis_802_11_fixed_ies), _HT_ADD_INFO_IE_, &len, ie_len-sizeof (struct ndis_802_11_fixed_ies)); + p = rtw_get_ie23a(pie+sizeof (struct ndis_802_11_fixed_ies), + WLAN_EID_HT_OPERATION, &len, + ie_len-sizeof (struct ndis_802_11_fixed_ies)); if (p && len>0) { pht_addtinfo = (struct ieee80211_ht_addt_info *)(p+2); -- cgit v1.2.3 From af2cb2c2772293e94d30e13c9914dbeb6477a9d6 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:26 +0200 Subject: staging: rtl8723au: rtw_ap.c: Use the kernel's WLAN_EID_* definitions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 62 ++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index fc8b7b2c4443..b9bf353e6b4e 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -79,7 +79,8 @@ static void update_BCNTIM(struct rtw_adapter *padapter) tim_bitmap_le = cpu_to_le16(pstapriv->tim_bitmap); - p = rtw_get_ie23a(pie + _FIXED_IE_LENGTH_, _TIM_IE_, &tim_ielen, pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_); + p = rtw_get_ie23a(pie + _FIXED_IE_LENGTH_, WLAN_EID_TIM, &tim_ielen, + pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_); if (p != NULL && tim_ielen>0) { tim_ielen += 2; @@ -98,12 +99,16 @@ static void update_BCNTIM(struct rtw_adapter *padapter) offset = _FIXED_IE_LENGTH_; /* get ssid_ie len */ - p = rtw_get_ie23a(pie + _BEACON_IE_OFFSET_, _SSID_IE_, &tmp_len, (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_)); + p = rtw_get_ie23a(pie + _BEACON_IE_OFFSET_, WLAN_EID_SSID, + &tmp_len, (pnetwork_mlmeext->IELength - + _BEACON_IE_OFFSET_)); if (p != NULL) offset += tmp_len+2; /* get supported rates len */ - p = rtw_get_ie23a(pie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &tmp_len, (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_)); + p = rtw_get_ie23a(pie + _BEACON_IE_OFFSET_, WLAN_EID_SUPP_RATES, + &tmp_len, (pnetwork_mlmeext->IELength - + _BEACON_IE_OFFSET_)); if (p != NULL) offset += tmp_len+2; @@ -124,7 +129,7 @@ static void update_BCNTIM(struct rtw_adapter *padapter) memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); } - *dst_ie++= _TIM_IE_; + *dst_ie++= WLAN_EID_TIM; if ((pstapriv->tim_bitmap&0xff00) && (pstapriv->tim_bitmap&0x00fc)) tim_ielen = 5; @@ -248,7 +253,7 @@ void expire_timeout_chk23a(struct rtw_adapter *padapter) /* to update bcn with tim_bitmap for this station */ pstapriv->tim_bitmap |= CHKBIT(psta->aid); - update_beacon23a(padapter, _TIM_IE_, NULL, false); + update_beacon23a(padapter, WLAN_EID_TIM, NULL, false); if (!pmlmeext->active_keep_alive_check) continue; @@ -726,7 +731,7 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) } /* set channel, bwmode */ p = rtw_get_ie23a((pnetwork->IEs + sizeof(struct ndis_802_11_fixed_ies)), - _HT_ADD_INFO_IE_, &ie_len, (pnetwork->IELength - + WLAN_EID_HT_OPERATION, &ie_len, (pnetwork->IELength - sizeof(struct ndis_802_11_fixed_ies))); if (p && ie_len) { pht_info = (struct HT_info_element *)(p+2); @@ -775,7 +780,7 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) #endif /* CONFIG_8723AU_P2P */ if (pmlmeext->bstart_bss) { - update_beacon23a(padapter, _TIM_IE_, NULL, false); + update_beacon23a(padapter, WLAN_EID_TIM, NULL, false); /* issue beacon frame */ if (send_beacon23a(padapter) == _FAIL) @@ -847,7 +852,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, int len) cap = get_unaligned_le16(ie); /* SSID */ - p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _SSID_IE_, &ie_len, + p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_SSID, &ie_len, (pbss_network->IELength -_BEACON_IE_OFFSET_)); if (p && ie_len > 0) { memset(&pbss_network->Ssid, 0, sizeof(struct cfg80211_ssid)); @@ -858,7 +863,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, int len) /* chnnel */ channel = 0; pbss_network->Configuration.Length = 0; - p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _DSSET_IE_, &ie_len, + p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_DS_PARAMS, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); if (p && ie_len > 0) channel = *(p + 2); @@ -867,7 +872,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, int len) memset(supportRate, 0, NDIS_802_11_LENGTH_RATES_EX); /* get supported rates */ - p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &ie_len, + p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_SUPP_RATES, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); if (p) { memcpy(supportRate, p+2, ie_len); @@ -875,7 +880,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, int len) } /* get ext_supported rates */ - p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _EXT_SUPPORTEDRATES_IE_, + p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_EXT_SUPP_RATES, &ie_len, pbss_network->IELength - _BEACON_IE_OFFSET_); if (p) { memcpy(supportRate+supportRateNum, p+2, ie_len); @@ -888,7 +893,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, int len) rtw_set_supported_rate23a(pbss_network->SupportedRates, network_type); /* parsing ERP_IE */ - p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _ERPINFO_IE_, &ie_len, + p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_ERP_INFO, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); if (p && ie_len > 0) ERP_IE_handler23a(padapter, (struct ndis_802_11_var_ies *)p); @@ -905,7 +910,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, int len) group_cipher = 0; pairwise_cipher = 0; psecuritypriv->wpa2_group_cipher = _NO_PRIVACY_; psecuritypriv->wpa2_pairwise_cipher = _NO_PRIVACY_; - p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _RSN_IE_2_, &ie_len, + p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_RSN, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); if (p && ie_len > 0) { if (rtw_parse_wpa2_ie23a(p, ie_len+2, &group_cipher, @@ -977,7 +982,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, int len) } } /* parsing HT_CAP_IE */ - p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _HT_CAPABILITY_IE_, &ie_len, + p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_HT_CAPABILITY, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); if (p && ie_len > 0) { u8 rf_type; @@ -1009,7 +1014,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, int len) } /* parsing HT_INFO_IE */ - p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _HT_ADD_INFO_IE_, &ie_len, + p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_HT_OPERATION, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); if (p && ie_len > 0) pHT_info_ie = p; @@ -1199,7 +1204,7 @@ static void update_bcn_erpinfo_ie(struct rtw_adapter *padapter) return; /* parsing ERP_IE */ - p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _ERPINFO_IE_, &len, (pnetwork->IELength - _BEACON_IE_OFFSET_)); + p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_ERP_INFO, &len, (pnetwork->IELength - _BEACON_IE_OFFSET_)); if (p && len>0) { struct ndis_802_11_var_ies * pIE = (struct ndis_802_11_var_ies *)p; @@ -1354,23 +1359,23 @@ void update_beacon23a(struct rtw_adapter *padapter, u8 ie_id, u8 *oui, u8 tx) update_bcn_fixed_ie(padapter); break; - case _TIM_IE_: + case WLAN_EID_TIM: update_BCNTIM(padapter); break; - case _ERPINFO_IE_: + case WLAN_EID_ERP_INFO: update_bcn_erpinfo_ie(padapter); break; - case _HT_CAPABILITY_IE_: + case WLAN_EID_HT_CAPABILITY: update_bcn_htcap_ie(padapter); break; - case _RSN_IE_2_: + case WLAN_EID_RSN: update_bcn_rsn_ie(padapter); break; - case _HT_ADD_INFO_IE_: + case WLAN_EID_HT_OPERATION: update_bcn_htinfo_ie(padapter); break; @@ -1548,7 +1553,7 @@ void bss_cap_update_on_sta_join23a(struct rtw_adapter *padapter, struct sta_info if (pmlmepriv->num_sta_non_erp == 1) { beacon_updated = true; - update_beacon23a(padapter, _ERPINFO_IE_, NULL, true); + update_beacon23a(padapter, WLAN_EID_ERP_INFO, NULL, true); } } @@ -1564,7 +1569,7 @@ void bss_cap_update_on_sta_join23a(struct rtw_adapter *padapter, struct sta_info if (pmlmepriv->num_sta_non_erp == 0) { beacon_updated = true; - update_beacon23a(padapter, _ERPINFO_IE_, NULL, true); + update_beacon23a(padapter, WLAN_EID_ERP_INFO, NULL, true); } } @@ -1655,8 +1660,8 @@ void bss_cap_update_on_sta_join23a(struct rtw_adapter *padapter, struct sta_info if (rtw_ht_operation_update(padapter) > 0) { - update_beacon23a(padapter, _HT_CAPABILITY_IE_, NULL, false); - update_beacon23a(padapter, _HT_ADD_INFO_IE_, NULL, true); + update_beacon23a(padapter, WLAN_EID_HT_CAPABILITY, NULL, false); + update_beacon23a(padapter, WLAN_EID_HT_OPERATION, NULL, true); } /* update associcated stations cap. */ @@ -1691,7 +1696,8 @@ u8 bss_cap_update_on_sta_leave23a(struct rtw_adapter *padapter, struct sta_info if (pmlmepriv->num_sta_non_erp == 0) { beacon_updated = true; - update_beacon23a(padapter, _ERPINFO_IE_, NULL, true); + update_beacon23a(padapter, WLAN_EID_ERP_INFO, + NULL, true); } } @@ -1723,8 +1729,8 @@ u8 bss_cap_update_on_sta_leave23a(struct rtw_adapter *padapter, struct sta_info if (rtw_ht_operation_update(padapter) > 0) { - update_beacon23a(padapter, _HT_CAPABILITY_IE_, NULL, false); - update_beacon23a(padapter, _HT_ADD_INFO_IE_, NULL, true); + update_beacon23a(padapter, WLAN_EID_HT_CAPABILITY, NULL, false); + update_beacon23a(padapter, WLAN_EID_HT_OPERATION, NULL, true); } /* update associcated stations cap. */ -- cgit v1.2.3 From 9676c3b9f5076c0572d4b6a6969a6319978e5118 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:27 +0200 Subject: staging: rtl8723au: rtw_p2p.c: Use the kernel's WLAN_EID_* definitions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_p2p.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_p2p.c b/drivers/staging/rtl8723au/core/rtw_p2p.c index 22753e34848e..49c09089fd24 100644 --- a/drivers/staging/rtl8723au/core/rtw_p2p.c +++ b/drivers/staging/rtl8723au/core/rtw_p2p.c @@ -2170,8 +2170,11 @@ u32 process_probe_req_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pframe, uin u32 p2pielen = 0; int ssid_len = 0, rate_cnt = 0; - p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + _PROBEREQ_IE_OFFSET_, _SUPPORTEDRATES_IE_, (int *)&rate_cnt, - len - sizeof(struct ieee80211_hdr_3addr) - _PROBEREQ_IE_OFFSET_); + p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + + _PROBEREQ_IE_OFFSET_, WLAN_EID_SUPP_RATES, + (int *)&rate_cnt, + len - sizeof(struct ieee80211_hdr_3addr) - + _PROBEREQ_IE_OFFSET_); if (rate_cnt <= 4) { @@ -2210,8 +2213,10 @@ u32 process_probe_req_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pframe, uin /* 5. Requested Device Type in WSC IE. (Todo) */ /* 6. Device ID attribute in P2P IE. (Todo) */ - p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + _PROBEREQ_IE_OFFSET_, _SSID_IE_, (int *)&ssid_len, - len - sizeof(struct ieee80211_hdr_3addr) - _PROBEREQ_IE_OFFSET_); + p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + + _PROBEREQ_IE_OFFSET_, WLAN_EID_SSID, (int *)&ssid_len, + len - sizeof(struct ieee80211_hdr_3addr) - + _PROBEREQ_IE_OFFSET_); ssid_len &= 0xff; /* Just last 1 byte is valid for ssid len of the probe request */ if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE) || rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) -- cgit v1.2.3 From 4323b043e41db47187888ac6b8da0a5ff1483afc Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:28 +0200 Subject: staging: rtl8723au: rtw_ieee80211.c: Use the kernel's WLAN_EID_* definitions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index 626a9df2645d..966b7be80923 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -413,7 +413,7 @@ int rtw_generate_ie23a(struct registry_priv *pregistrypriv) ie += 2; /* SSID */ - ie = rtw_set_ie23a(ie, _SSID_IE_, pdev_network->Ssid.ssid_len, + ie = rtw_set_ie23a(ie, WLAN_EID_SSID, pdev_network->Ssid.ssid_len, pdev_network->Ssid.ssid, &sz); /* supported rates */ @@ -431,25 +431,25 @@ int rtw_generate_ie23a(struct registry_priv *pregistrypriv) rateLen = rtw_get_rateset_len23a(pdev_network->SupportedRates); if (rateLen > 8) { - ie = rtw_set_ie23a(ie, _SUPPORTEDRATES_IE_, 8, + ie = rtw_set_ie23a(ie, WLAN_EID_SUPP_RATES, 8, pdev_network->SupportedRates, &sz); /* ie = rtw_set_ie23a(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); */ } else { - ie = rtw_set_ie23a(ie, _SUPPORTEDRATES_IE_, rateLen, + ie = rtw_set_ie23a(ie, WLAN_EID_SUPP_RATES, rateLen, pdev_network->SupportedRates, &sz); } /* DS parameter set */ - ie = rtw_set_ie23a(ie, _DSSET_IE_, 1, + ie = rtw_set_ie23a(ie, WLAN_EID_DS_PARAMS, 1, (u8 *)&pdev_network->Configuration.DSConfig, &sz); /* IBSS Parameter Set */ - ie = rtw_set_ie23a(ie, _IBSS_PARA_IE_, 2, + ie = rtw_set_ie23a(ie, WLAN_EID_IBSS_PARAMS, 2, (u8 *)&pdev_network->Configuration.ATIMWindow, &sz); if (rateLen > 8) { - ie = rtw_set_ie23a(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), + ie = rtw_set_ie23a(ie, WLAN_EID_EXT_SUPP_RATES, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); } @@ -1694,8 +1694,8 @@ void rtw_get_bcn_info23a(struct wlan_network *pnetwork) /* get bwmode and ch_offset */ /* parsing HT_CAP_IE */ p = rtw_get_ie23a(pnetwork->network.IEs + _FIXED_IE_LENGTH_, - _HT_CAPABILITY_IE_, &len, - pnetwork->network.IELength - _FIXED_IE_LENGTH_); + WLAN_EID_HT_CAPABILITY, &len, + pnetwork->network.IELength - _FIXED_IE_LENGTH_); if (p && len > 0) { pht_cap = (struct ieee80211_ht_cap *)(p + 2); pnetwork->BcnInfo.ht_cap_info = pht_cap->cap_info; @@ -1704,7 +1704,7 @@ void rtw_get_bcn_info23a(struct wlan_network *pnetwork) } /* parsing HT_INFO_IE */ p = rtw_get_ie23a(pnetwork->network.IEs + _FIXED_IE_LENGTH_, - _HT_ADD_INFO_IE_, &len, + WLAN_EID_HT_OPERATION, &len, pnetwork->network.IELength - _FIXED_IE_LENGTH_); if (p && len > 0) { pht_info = (struct HT_info_element *)(p + 2); -- cgit v1.2.3 From 25c934fa38326d51286b90f08fe03e3870bcb77d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:29 +0200 Subject: staging: rtl8723au: rtw_wlan_util.c: Use the kernel's WLAN_EID_* definitions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 34 +++++++++++++++++--------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 8f0e79e9664f..f774b03f23d9 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -933,7 +933,9 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u8 *pframe, u32 packet_le /* check bw and channel offset */ /* parsing HT_CAP_IE */ - p = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, _HT_CAPABILITY_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); + p = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, + WLAN_EID_HT_CAPABILITY, + &len, bssid->IELength - _FIXED_IE_LENGTH_); if (p && len>0) { pht_cap = (struct ieee80211_ht_cap *)(p + 2); ht_cap_info = pht_cap->cap_info; @@ -941,7 +943,8 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u8 *pframe, u32 packet_le ht_cap_info = 0; } /* parsing HT_INFO_IE */ - p = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, _HT_ADD_INFO_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); + p = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, WLAN_EID_HT_OPERATION, + &len, bssid->IELength - _FIXED_IE_LENGTH_); if (p && len>0) { pht_info = (struct HT_info_element *)(p + 2); ht_info_infos_0 = pht_info->infos[0]; @@ -962,11 +965,14 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u8 *pframe, u32 packet_le } /* Checking for channel */ - p = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, _DSSET_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); + p = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, WLAN_EID_DS_PARAMS, + &len, bssid->IELength - _FIXED_IE_LENGTH_); if (p) { bcn_channel = *(p + 2); } else {/* In 5G, some ap do not have DSSET IE checking HT info for channel */ - p = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, _HT_ADD_INFO_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); + p = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, + WLAN_EID_HT_OPERATION, &len, + bssid->IELength - _FIXED_IE_LENGTH_); if (pht_info) { bcn_channel = pht_info->primary_channel; } else { /* we don't find channel IE, so don't check it */ @@ -981,7 +987,9 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u8 *pframe, u32 packet_le } /* checking SSID */ - if ((p = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, _SSID_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_)) == NULL) { + if ((p = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, WLAN_EID_SSID, + &len, bssid->IELength - _FIXED_IE_LENGTH_)) == + NULL) { DBG_8723A("%s marc: cannot find SSID for survey event\n", __func__); hidden_ssid = true; } else { @@ -1102,11 +1110,11 @@ void update_beacon23a_info(struct rtw_adapter *padapter, u8 *pframe, uint pkt_le pIE = (struct ndis_802_11_var_ies *)(pframe + (_BEACON_IE_OFFSET_ + sizeof(struct ieee80211_hdr_3addr)) + i); switch (pIE->ElementID) { - case _HT_EXTRA_INFO_IE_: /* HT info */ + case WLAN_EID_HT_OPERATION: /* HT info */ /* HT_info_handler23a(padapter, pIE); */ bwmode_update_check(padapter, pIE); break; - case _ERPINFO_IE_: + case WLAN_EID_ERP_INFO: ERP_IE_handler23a(padapter, pIE); VCS_update23a(padapter, psta); break; @@ -1134,7 +1142,7 @@ unsigned int is_ap_in_tkip23a(struct rtw_adapter *padapter) if ((!memcmp(pIE->data, RTW_WPA_OUI23A, 4)) && (!memcmp((pIE->data + 12), WPA_TKIP_CIPHER23A, 4))) return true; break; - case _RSN_IE_2_: + case WLAN_EID_RSN: if (!memcmp((pIE->data + 8), RSN_TKIP_CIPHER23A, 4)) return true; break; @@ -1167,7 +1175,7 @@ unsigned int should_forbid_n_rate23a(struct rtw_adapter * padapter) (!memcmp((pIE->data + 16), WPA_CIPHER_SUITE_CCMP23A, 4)))) return false; break; - case _RSN_IE_2_: + case WLAN_EID_RSN: if ((!memcmp((pIE->data + 8), RSN_CIPHER_SUITE_CCMP23A, 4)) || (!memcmp((pIE->data + 12), RSN_CIPHER_SUITE_CCMP23A, 4))) return false; @@ -1200,7 +1208,7 @@ unsigned int is_ap_in_wep23a(struct rtw_adapter *padapter) if (!memcmp(pIE->data, RTW_WPA_OUI23A, 4)) return false; break; - case _RSN_IE_2_: + case WLAN_EID_RSN: return false; default: @@ -1598,14 +1606,16 @@ int update_sta_support_rate23a(struct rtw_adapter *padapter, u8 *pvar_ie, uint v struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - pIE = (struct ndis_802_11_var_ies *)rtw_get_ie23a(pvar_ie, _SUPPORTEDRATES_IE_, &ie_len, var_ie_len); + pIE = (struct ndis_802_11_var_ies *)rtw_get_ie23a(pvar_ie, + WLAN_EID_SUPP_RATES, + &ie_len, var_ie_len); if (pIE == NULL) return _FAIL; memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates, pIE->data, ie_len); supportRateNum = ie_len; - pIE = (struct ndis_802_11_var_ies *)rtw_get_ie23a(pvar_ie, _EXT_SUPPORTEDRATES_IE_, &ie_len, var_ie_len); + pIE = (struct ndis_802_11_var_ies *)rtw_get_ie23a(pvar_ie, WLAN_EID_EXT_SUPP_RATES, &ie_len, var_ie_len); if (pIE) memcpy((pmlmeinfo->FW_sta_info[cam_idx].SupportedRates + supportRateNum), pIE->data, ie_len); return _SUCCESS; -- cgit v1.2.3 From 4288e5fd1bd5f7880447a426dbb5fd3405a8d422 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:30 +0200 Subject: staging: rtl8723au: rtl8723a_cmd.c: Use the kernel's WLAN_EID_* definitions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c index 0b205e1204fc..7a2284d96f4a 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c @@ -255,30 +255,36 @@ static void ConstructBeacon(struct rtw_adapter *padapter, u8 *pframe, u32 *pLeng /* below for ad-hoc mode */ /* SSID */ - pframe = rtw_set_ie23a(pframe, _SSID_IE_, cur_network->Ssid.ssid_len, - cur_network->Ssid.ssid, &pktlen); + pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID, + cur_network->Ssid.ssid_len, + cur_network->Ssid.ssid, &pktlen); /* supported rates... */ rate_len = rtw_get_rateset_len23a(cur_network->SupportedRates); - pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8) ? + pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pktlen); /* DS parameter set */ - pframe = rtw_set_ie23a(pframe, _DSSET_IE_, 1, (unsigned char *)&cur_network->Configuration.DSConfig, &pktlen); + pframe = rtw_set_ie23a(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *) + &cur_network->Configuration.DSConfig, &pktlen); if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { u32 ATIMWindow; /* IBSS Parameter Set... */ /* ATIMWindow = cur->Configuration.ATIMWindow; */ ATIMWindow = 0; - pframe = rtw_set_ie23a(pframe, _IBSS_PARA_IE_, 2, (unsigned char *)(&ATIMWindow), &pktlen); + pframe = rtw_set_ie23a(pframe, WLAN_EID_IBSS_PARAMS, 2, + (unsigned char *)(&ATIMWindow), &pktlen); } /* todo: ERP IE */ /* EXTERNDED SUPPORTED RATE */ if (rate_len > 8) - pframe = rtw_set_ie23a(pframe, _EXT_SUPPORTEDRATES_IE_, (rate_len - 8), (cur_network->SupportedRates + 8), &pktlen); + pframe = rtw_set_ie23a(pframe, WLAN_EID_EXT_SUPP_RATES, + (rate_len - 8), + (cur_network->SupportedRates + 8), + &pktlen); /* todo:HT for adhoc */ -- cgit v1.2.3 From 3455f1f062641c13858c77c5a2c07c9a45a1a820 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:31 +0200 Subject: staging: rtl8723au: rtw_xmit.c: Use the kernel's WLAN_EID_* definitions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index c0e2d7607b72..c0eaf5e21057 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -1333,7 +1333,7 @@ void rtw_update_protection23a(struct rtw_adapter *padapter, u8 *ie, uint ie_len) break; case AUTO_VCS: default: - perp = rtw_get_ie23a(ie, _ERPINFO_IE_, &erp_len, ie_len); + perp = rtw_get_ie23a(ie, WLAN_EID_ERP_INFO, &erp_len, ie_len); if (perp == NULL) { pxmitpriv->vcs = NONE_VCS; } else { @@ -2042,7 +2042,8 @@ int xmitframe_enqueue_for_sleeping_sta23a(struct rtw_adapter *padapter, struct x /* DBG_8723A("enqueue, sq_len =%d, tim =%x\n", psta->sleepq_len, pstapriv->tim_bitmap); */ - update_beacon23a(padapter, _TIM_IE_, NULL, false);/* tx bc/mc packets after upate bcn */ + /* tx bc/mc packets after upate bcn */ + update_beacon23a(padapter, WLAN_EID_TIM, NULL, false); /* spin_unlock_bh(&psta->sleep_q.lock); */ @@ -2099,7 +2100,8 @@ int xmitframe_enqueue_for_sleeping_sta23a(struct rtw_adapter *padapter, struct x if (psta->sleepq_len == 1) { /* upate BCN for TIM IE */ - update_beacon23a(padapter, _TIM_IE_, NULL, false); + update_beacon23a(padapter, WLAN_EID_TIM, + NULL, false); } } @@ -2313,7 +2315,7 @@ void wakeup_sta_to_xmit23a(struct rtw_adapter *padapter, struct sta_info *psta) } if (update_mask) - update_beacon23a(padapter, _TIM_IE_, NULL, false); + update_beacon23a(padapter, WLAN_EID_TIM, NULL, false); } void xmit_delivery_enabled_frames23a(struct rtw_adapter *padapter, @@ -2378,7 +2380,7 @@ void xmit_delivery_enabled_frames23a(struct rtw_adapter *padapter, pstapriv->tim_bitmap &= ~CHKBIT(psta->aid); /* upate BCN for TIM IE */ - update_beacon23a(padapter, _TIM_IE_, NULL, false); + update_beacon23a(padapter, WLAN_EID_TIM, NULL, false); } } spin_unlock_bh(&pxmitpriv->lock); -- cgit v1.2.3 From df220942dfc5e64b0f84b4f381b9a08eb1bdd16b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:32 +0200 Subject: staging: rtl8723au: rtw_recv.c: Use the kernel's WLAN_EID_* definitions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_recv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 713a377ce28f..5d81a8c18218 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -1216,8 +1216,8 @@ int validate_recv_ctrl_frame(struct rtw_adapter *padapter, /* upate BCN for TIM IE */ /* update_BCNTIM(padapter); */ - update_beacon23a(padapter, _TIM_IE_, - NULL, false); + update_beacon23a(padapter, WLAN_EID_TIM, + NULL, false); } /* spin_unlock_bh(&psta->sleep_q.lock); */ @@ -1248,8 +1248,8 @@ int validate_recv_ctrl_frame(struct rtw_adapter *padapter, /* upate BCN for TIM IE */ /* update_BCNTIM(padapter); */ - update_beacon23a(padapter, _TIM_IE_, - NULL, false); + update_beacon23a(padapter, WLAN_EID_TIM, + NULL, false); } } } -- cgit v1.2.3 From 3021bc42072ba073536a82458192bc98c8e0698e Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:33 +0200 Subject: staging: rtl8723au: Fixup last users to use the kernel's WLAN_EID_* definitions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 2 +- drivers/staging/rtl8723au/core/rtw_ioctl_set.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 592f0ee274e4..f8306efa979d 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -1461,7 +1461,7 @@ static void rtw_chk_hi_queue_hdl(struct rtw_adapter *padapter) pstapriv->tim_bitmap &= ~BIT(0); pstapriv->sta_dz_bitmap &= ~BIT(0); - update_beacon23a(padapter, _TIM_IE_, NULL, false); + update_beacon23a(padapter, WLAN_EID_TIM, NULL, false); } else /* re check again */ rtw_chk_hi_queue_cmd23a(padapter); } diff --git a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c index 1f9d3a3d4920..6468c1ca2528 100644 --- a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c @@ -557,7 +557,7 @@ u16 rtw_get_cur_max_rate23a(struct rtw_adapter *adapter) return 0; if (pmlmeext->cur_wireless_mode & (WIRELESS_11_24N|WIRELESS_11_5N)) { - p = rtw_get_ie23a(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_, + p = rtw_get_ie23a(&pcur_bss->IEs[12], WLAN_EID_HT_CAPABILITY, &ht_ielen, pcur_bss->IELength - 12); if (p && ht_ielen > 0) { pht_capie = (struct ieee80211_ht_cap *)(p + 2); -- cgit v1.2.3 From 91624933fd2868693c4f55ba503e9d1b6932de7b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:34 +0200 Subject: staging: rtl8723au: Remove obsolete local defines matching WLAN_EID_* Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/wifi.h | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index a8695f435968..57e394543ec1 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -219,37 +219,8 @@ static inline unsigned char *get_hdr_bssid(unsigned char *pframe) #define _FIXED_IE_LENGTH_ _BEACON_IE_OFFSET_ -#define _SSID_IE_ 0 -#define _SUPPORTEDRATES_IE_ 1 -#define _DSSET_IE_ 3 -#define _TIM_IE_ 5 -#define _IBSS_PARA_IE_ 6 -#define _COUNTRY_IE_ 7 -#define _CHLGETXT_IE_ 16 -#define _SUPPORTED_CH_IE_ 36 -#define _CH_SWTICH_ANNOUNCE_ 37 /* Secondary Channel Offset */ -#define _RSN_IE_2_ 48 -#define _ERPINFO_IE_ 42 -#define _EXT_SUPPORTEDRATES_IE_ 50 - -#define _HT_CAPABILITY_IE_ 45 -#define _FTIE_ 55 -#define _TIMEOUT_ITVL_IE_ 56 -#define _SRC_IE_ 59 -#define _HT_EXTRA_INFO_IE_ 61 -#define _HT_ADD_INFO_IE_ 61 /* _HT_EXTRA_INFO_IE_ */ - - -#define EID_BSSCoexistence 72 /* 20/40 BSS Coexistence */ -#define EID_BSSIntolerantChlReport 73 -#define _RIC_Descriptor_IE_ 75 - -#define _LINK_ID_IE_ 101 -#define _CH_SWITCH_TIMING_ 104 -#define _PTI_BUFFER_STATUS_ 106 -#define _EXT_CAP_IE_ 127 -#define _RESERVED47_ 47 +#define EID_BSSIntolerantChlReport 73 /* --------------------------------------------------------------------------- Below is the fixed elements... -- cgit v1.2.3 From 98fb81291d30f83838379bf1522fead6673b5fdf Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:35 +0200 Subject: staging: rtl8723au: Remove P2P/WiFiDirect/WiFiDisplay code Discussing with Johannes Berg and Larry Finger, we have concluded that this code really should be handled through wpa_supplicant, and not in the kernel. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/Kconfig | 8 - drivers/staging/rtl8723au/Makefile | 1 - drivers/staging/rtl8723au/core/rtw_ap.c | 9 - drivers/staging/rtl8723au/core/rtw_cmd.c | 58 - drivers/staging/rtl8723au/core/rtw_ieee80211.c | 311 -- drivers/staging/rtl8723au/core/rtw_mlme.c | 22 +- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 3564 +----------------- drivers/staging/rtl8723au/core/rtw_p2p.c | 4016 --------------------- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 57 +- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 35 - drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 73 - drivers/staging/rtl8723au/hal/rtl8723a_dm.c | 7 - drivers/staging/rtl8723au/include/drv_types.h | 11 - drivers/staging/rtl8723au/include/ieee80211.h | 14 - drivers/staging/rtl8723au/include/rtl8723a_cmd.h | 4 - drivers/staging/rtl8723au/include/rtl8723a_hal.h | 5 - drivers/staging/rtl8723au/include/rtw_cmd.h | 3 - drivers/staging/rtl8723au/include/rtw_mlme.h | 123 - drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 16 - drivers/staging/rtl8723au/include/rtw_p2p.h | 158 - drivers/staging/rtl8723au/include/wifi.h | 17 - drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 851 +---- drivers/staging/rtl8723au/os_dep/os_intfs.c | 42 - drivers/staging/rtl8723au/os_dep/usb_intf.c | 4 - 24 files changed, 85 insertions(+), 9324 deletions(-) delete mode 100644 drivers/staging/rtl8723au/core/rtw_p2p.c delete mode 100644 drivers/staging/rtl8723au/include/rtw_p2p.h diff --git a/drivers/staging/rtl8723au/Kconfig b/drivers/staging/rtl8723au/Kconfig index 07fb5e4e50fa..435f3594dabe 100644 --- a/drivers/staging/rtl8723au/Kconfig +++ b/drivers/staging/rtl8723au/Kconfig @@ -19,14 +19,6 @@ config 8723AU_AP_MODE will never be used as an AP, or the target system has limited memory, "Y" should be selected. -config 8723AU_P2P - bool "Realtek RTL8723AU Peer-to-peer mode" - default y - ---help--- - This option enables peer-to-peer mode for the r8723au driver. Unless you - know that peer-to-peer (P2P) mode will never be used, or the target system has - limited memory, "Y" should be selected. - config 8723AU_BT_COEXIST bool "Realtek RTL8723AU BlueTooth Coexistence" default y diff --git a/drivers/staging/rtl8723au/Makefile b/drivers/staging/rtl8723au/Makefile index 11c6dd486462..bbf503dd437a 100644 --- a/drivers/staging/rtl8723au/Makefile +++ b/drivers/staging/rtl8723au/Makefile @@ -8,7 +8,6 @@ r8723au-y := \ core/rtw_led.o \ core/rtw_mlme.o \ core/rtw_mlme_ext.o \ - core/rtw_p2p.o \ core/rtw_pwrctrl.o \ core/rtw_recv.o \ core/rtw_security.o \ diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index b9bf353e6b4e..f04d9dfb4446 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -659,9 +659,6 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *pnetwork_mlmeext = &pmlmeinfo->network; struct HT_info_element *pht_info = NULL; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* CONFIG_8723AU_P2P */ bcn_interval = (u16)pnetwork->Configuration.BeaconPeriod; cur_channel = pnetwork->Configuration.DSConfig; @@ -773,12 +770,6 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) /* let pnetwork_mlmeext == pnetwork_mlme. */ memcpy(pnetwork_mlmeext, pnetwork, pnetwork->Length); -#ifdef CONFIG_8723AU_P2P - memcpy(pwdinfo->p2p_group_ssid, pnetwork->Ssid.ssid, - pnetwork->Ssid.ssid_len); - pwdinfo->p2p_group_ssid_len = pnetwork->Ssid.ssid_len; -#endif /* CONFIG_8723AU_P2P */ - if (pmlmeext->bstart_bss) { update_beacon23a(padapter, WLAN_EID_TIM, NULL, false); diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index f8306efa979d..cb15ddaae12e 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -527,12 +527,6 @@ u8 rtw_sitesurvey_cmd23a(struct rtw_adapter *padapter, if (check_fwstate(pmlmepriv, _FW_LINKED) == true) rtw_lps_ctrl_wk_cmd23a(padapter, LPS_CTRL_SCAN, 1); -#ifdef CONFIG_8723AU_P2P - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { - p2p_ps_wk_cmd23a(padapter, P2P_PS_SCAN, 1); - } -#endif /* CONFIG_8723AU_P2P */ - ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (!ph2c) return _FAIL; @@ -1354,48 +1348,6 @@ static void power_saving_wk_hdl(struct rtw_adapter *padapter, u8 *pbuf, int sz) rtw_ps_processor23a(padapter); } -#ifdef CONFIG_8723AU_P2P -u8 p2p_protocol_wk_cmd23a(struct rtw_adapter*padapter, int intCmdType) -{ - struct cmd_obj *ph2c; - struct drvextra_cmd_parm *pdrvextra_cmd_parm; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - { - return res; - } - - ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (!ph2c) { - res = _FAIL; - goto exit; - } - - pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), - GFP_ATOMIC); - if (!pdrvextra_cmd_parm) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - - pdrvextra_cmd_parm->ec_id = P2P_PROTO_WK_CID; - pdrvextra_cmd_parm->type_size = intCmdType; /* As the command tppe. */ - pdrvextra_cmd_parm->pbuf = NULL; /* Must be NULL here */ - - init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, - GEN_CMD_CODE(_Set_Drv_Extra)); - - res = rtw_enqueue_cmd23a(pcmdpriv, ph2c); -exit: - - return res; -} -#endif /* CONFIG_8723AU_P2P */ - u8 rtw_ps_cmd23a(struct rtw_adapter*padapter) { struct cmd_obj *ppscmd; @@ -1634,16 +1586,6 @@ u8 rtw_drvextra_cmd_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf) case LPS_CTRL_WK_CID: lps_ctrl_wk_hdl(padapter, (u8)pdrvextra_cmd->type_size); break; -#ifdef CONFIG_8723AU_P2P - case P2P_PS_WK_CID: - p2p_ps_wk_hdl23a(padapter, pdrvextra_cmd->type_size); - break; - case P2P_PROTO_WK_CID: - /* Commented by Albert 2011/07/01 */ - /* I used the type_size as the type command */ - p2p_protocol_wk_hdl23a(padapter, pdrvextra_cmd->type_size); - break; -#endif /* CONFIG_8723AU_P2P */ #ifdef CONFIG_8723AU_AP_MODE case CHECK_HIQ_WK_CID: rtw_chk_hi_queue_hdl(padapter); diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index 966b7be80923..d7a6b47b49b3 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -1227,9 +1227,6 @@ void dump_ies23a(u8 *buf, u32 buf_len) { len = *(pos + 1); DBG_8723A("%s ID:%u, LEN:%u\n", __func__, id, len); -#ifdef CONFIG_8723AU_P2P - dump_p2p_ie23a(pos, len); -#endif dump_wps_ie23a(pos, len); pos += (2 + len); @@ -1259,314 +1256,6 @@ void dump_wps_ie23a(u8 *ie, u32 ie_len) { } } -#ifdef CONFIG_8723AU_P2P -void dump_p2p_ie23a(u8 *ie, u32 ie_len) { - u8* pos = (u8*)ie; - u8 id; - u16 len; - - u8 *p2p_ie; - uint p2p_ielen; - - p2p_ie = rtw_get_p2p_ie23a(ie, ie_len, NULL, &p2p_ielen); - if (p2p_ie != ie || p2p_ielen == 0) - return; - - pos += 6; - while (pos-ie < ie_len) { - id = *pos; - len = get_unaligned_le16(pos+1); - - DBG_8723A("%s ID:%u, LEN:%u\n", __func__, id, len); - - pos+= (3+len); - } -} - -/** - * rtw_get_p2p_ie23a - Search P2P IE from a series of IEs - * @in_ie: Address of IEs to search - * @in_len: Length limit from in_ie - * @p2p_ie: If not NULL and P2P IE is found, P2P IE will be copied to the - * buf starting from p2p_ie - * @p2p_ielen: If not NULL and P2P IE is found, will set to the length of - * the entire P2P IE - * - * Returns: The address of the P2P IE found, or NULL - */ -u8 *rtw_get_p2p_ie23a(u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen) -{ - uint cnt = 0; - u8 *p2p_ie_ptr; - u8 eid, p2p_oui[4]={0x50, 0x6F, 0x9A, 0x09}; - - if (p2p_ielen) - *p2p_ielen = 0; - - while (cnt MAX_IE_SZ)) { - dump_stack(); - return NULL; - } - if ((eid == WLAN_EID_VENDOR_SPECIFIC) && - !memcmp(&in_ie[cnt + 2], p2p_oui, 4)) { - p2p_ie_ptr = in_ie + cnt; - - if (p2p_ie != NULL) { - memcpy(p2p_ie, &in_ie[cnt], - in_ie[cnt + 1] + 2); - } - - if (p2p_ielen != NULL) { - *p2p_ielen = in_ie[cnt + 1] + 2; - } - - return p2p_ie_ptr; - - break; - } else { - cnt += in_ie[cnt + 1] + 2; /* goto next */ - } - } - - return NULL; -} - -/** - * rtw_get_p2p_attr23a - Search a specific P2P attribute from a given P2P IE - * @p2p_ie: Address of P2P IE to search - * @p2p_ielen: Length limit from p2p_ie - * @target_attr_id: The attribute ID of P2P attribute to search - * @buf_attr: If not NULL and the P2P attribute is found, P2P attribute will - * be copied to the buf starting from buf_attr - * @len_attr: If not NULL and the P2P attribute is found, will set to the - * length of the entire P2P attribute - * - * Returns: the address of the specific WPS attribute found, or NULL - */ -u8 *rtw_get_p2p_attr23a(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id, - u8 *buf_attr, u32 *len_attr) -{ - u8 *attr_ptr = NULL; - u8 *target_attr_ptr = NULL; - u8 p2p_oui[4]={0x50, 0x6F, 0x9A, 0x09}; - - if (len_attr) - *len_attr = 0; - - if (!p2p_ie || (p2p_ie[0] != WLAN_EID_VENDOR_SPECIFIC) || - memcmp(p2p_ie + 2, p2p_oui, 4)) { - return attr_ptr; - } - - /* 6 = 1(Element ID) + 1(Length) + 3 (OUI) + 1(OUI Type) */ - attr_ptr = p2p_ie + 6; /* goto first attr */ - - while (attr_ptr - p2p_ie < p2p_ielen) { - /* 3 = 1(Attribute ID) + 2(Length) */ - u8 attr_id = *attr_ptr; - u16 attr_data_len = get_unaligned_le16(attr_ptr + 1); - u16 attr_len = attr_data_len + 3; - - /* DBG_8723A("%s attr_ptr:%p, id:%u, length:%u\n", __func__, attr_ptr, attr_id, attr_data_len); */ - if (attr_id == target_attr_id) { - target_attr_ptr = attr_ptr; - - if (buf_attr) - memcpy(buf_attr, attr_ptr, attr_len); - - if (len_attr) - *len_attr = attr_len; - - break; - } else { - attr_ptr += attr_len; /* goto next */ - } - } - - return target_attr_ptr; -} - -/** - * rtw_get_p2p_attr23a_content - Search a specific P2P attribute content from - * a given P2P IE - * @p2p_ie: Address of P2P IE to search - * @p2p_ielen: Length limit from p2p_ie - * @target_attr_id: The attribute ID of P2P attribute to search - * @buf_content: If not NULL and the P2P attribute is found, P2P attribute - * content will be copied to the buf starting from buf_content - * @len_content: If not NULL and the P2P attribute is found, will set to the - * length of the P2P attribute content - * - * Returns: the address of the specific P2P attribute content found, or NULL - */ -u8 *rtw_get_p2p_attr23a_content(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id, - u8 *buf_content, uint *len_content) -{ - u8 *attr_ptr; - u32 attr_len; - - if (len_content) - *len_content = 0; - - attr_ptr = rtw_get_p2p_attr23a(p2p_ie, p2p_ielen, target_attr_id, - NULL, &attr_len); - - if (attr_ptr && attr_len) { - if (buf_content) - memcpy(buf_content, attr_ptr + 3, attr_len - 3); - - if (len_content) - *len_content = attr_len - 3; - - return attr_ptr+3; - } - - return NULL; -} - -u32 rtw_set_p2p_attr_content23a(u8 *pbuf, u8 attr_id, u16 attr_len, u8 *pdata_attr) -{ - u32 a_len; - - *pbuf = attr_id; - - /* u16*)(pbuf + 1) = cpu_to_le16(attr_len); */ - put_unaligned_le16(attr_len, pbuf + 1); - - if (pdata_attr) - memcpy(pbuf + 3, pdata_attr, attr_len); - - a_len = attr_len + 3; - - return a_len; -} - -static uint rtw_p2p_attr_remove(u8 *ie, uint ielen_ori, u8 attr_id) -{ - u8 *target_attr; - u32 target_attr_len; - uint ielen = ielen_ori; - - while(1) { - target_attr = rtw_get_p2p_attr23a(ie, ielen, attr_id, NULL, - &target_attr_len); - if (target_attr && target_attr_len) { - u8 *next_attr = target_attr+target_attr_len; - uint remain_len = ielen-(next_attr-ie); - /* dump_ies23a(ie, ielen); */ - - memset(target_attr, 0, target_attr_len); - memcpy(target_attr, next_attr, remain_len); - memset(target_attr+remain_len, 0, target_attr_len); - *(ie + 1) -= target_attr_len; - ielen -= target_attr_len; - } else { - /* if (index>0) */ - /* dump_ies23a(ie, ielen); */ - break; - } - } - - return ielen; -} - -void rtw_wlan_bssid_ex_remove_p2p_attr23a(struct wlan_bssid_ex *bss_ex, u8 attr_id) -{ - u8 *p2p_ie; - uint p2p_ielen, p2p_ielen_ori; - - if ((p2p_ie = rtw_get_p2p_ie23a(bss_ex->IEs + _FIXED_IE_LENGTH_, - bss_ex->IELength - _FIXED_IE_LENGTH_, - NULL, &p2p_ielen_ori))) { - p2p_ielen = rtw_p2p_attr_remove(p2p_ie, p2p_ielen_ori, attr_id); - if (p2p_ielen != p2p_ielen_ori) { - u8 *next_ie_ori = p2p_ie+p2p_ielen_ori; - u8 *next_ie = p2p_ie+p2p_ielen; - uint remain_len; - remain_len = bss_ex->IELength-(next_ie_ori-bss_ex->IEs); - - memcpy(next_ie, next_ie_ori, remain_len); - memset(next_ie+remain_len, 0, p2p_ielen_ori-p2p_ielen); - bss_ex->IELength -= p2p_ielen_ori-p2p_ielen; - } - } -} - -#endif /* CONFIG_8723AU_P2P */ - -#ifdef CONFIG_8723AU_P2P -int rtw_get_wfd_ie(u8 *in_ie, int in_len, u8 *wfd_ie, uint *wfd_ielen) -{ - int match; - const u8 *ie; - - match = 0; - - if (in_len < 0) - return match; - - ie = cfg80211_find_vendor_ie(0x506F9A, 0x0A, in_ie, in_len); - if (ie && (ie[1] <= (MAX_WFD_IE_LEN - 2))) { - if (wfd_ie) { - *wfd_ielen = ie[1] + 2; - memcpy(wfd_ie, ie, ie[1] + 2); - } else - if (wfd_ielen) - *wfd_ielen = 0; - - match = 1; - } - - return match; -} - -/* attr_content: The output buffer, contains the "body field" of - WFD attribute. */ -/* attr_contentlen: The data length of the "body field" of WFD - attribute. */ -int rtw_get_wfd_attr_content(u8 *wfd_ie, uint wfd_ielen, u8 target_attr_id, - u8 *attr_content, uint *attr_contentlen) -{ - int match; - uint cnt = 0; - u8 attr_id, wfd_oui[4] = {0x50, 0x6F, 0x9A, 0x0A}; - - match = false; - - if ((wfd_ie[0] != WLAN_EID_VENDOR_SPECIFIC) || - memcmp(wfd_ie + 2, wfd_oui, 4)) { - return match; - } - - /* 1 (WFD IE) + 1 (Length) + 3 (OUI) + 1 (OUI Type) */ - cnt = 6; - while (cnt < wfd_ielen) { - u16 attrlen = get_unaligned_be16(wfd_ie + cnt + 1); - - attr_id = wfd_ie[cnt]; - if (attr_id == target_attr_id) { - /* 3 -> 1 byte for attribute ID field, 2 - bytes for length field */ - if (attr_content) - memcpy(attr_content, &wfd_ie[cnt + 3], attrlen); - - if (attr_contentlen) - *attr_contentlen = attrlen; - - cnt += attrlen + 3; - - match = true; - break; - } else { - cnt += attrlen + 3; /* goto next */ - } - } - - return match; -} -#endif /* CONFIG_8723AU_P2P */ /* Baron adds to avoid FreeBSD warning */ int ieee80211_is_empty_essid23a(const char *essid, int essid_len) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 59b2c6cedcf7..67df0d7bd116 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -787,11 +787,6 @@ void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) spin_unlock_bh(&pmlmepriv->lock); -#ifdef CONFIG_8723AU_P2P - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - p2p_ps_wk_cmd23a(adapter, P2P_PS_SCAN_DONE, 0); -#endif /* CONFIG_8723AU_P2P */ - rtw_os_xmit_schedule23a(adapter); if(pmlmeext->sitesurvey_res.bss_cnt == 0) @@ -956,10 +951,6 @@ void rtw_indicate_disconnect23a(struct rtw_adapter *padapter) } -#ifdef CONFIG_8723AU_P2P - p2p_ps_wk_cmd23a(padapter, P2P_PS_DISABLE, 1); -#endif /* CONFIG_8723AU_P2P */ - rtw_lps_ctrl_wk_cmd23a(padapter, LPS_CTRL_DISCONNECT, 1); } @@ -1581,16 +1572,9 @@ void rtw_dynamic_check_timer_handler(unsigned long data) rtw_dynamic_chk_wk_cmd23a(adapter); - if (pregistrypriv->wifi_spec == 1) - { -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &adapter->wdinfo; - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) -#endif - { - /* auto site survey */ - rtw_auto_scan_handler(adapter); - } + if (pregistrypriv->wifi_spec == 1) { + /* auto site survey */ + rtw_auto_scan_handler(adapter); } out: mod_timer(&adapter->mlmepriv.dynamic_chk_timer, diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 9b9124c531ec..084003943396 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -631,30 +631,6 @@ void mgt_dispatcher23a(struct rtw_adapter *padapter, #endif } -#ifdef CONFIG_8723AU_P2P -static u32 p2p_listen_state_process(struct rtw_adapter *padapter, - unsigned char *da) -{ - bool response = true; - - if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled == false || - padapter->mlmepriv.wps_probe_resp_ie == NULL || - padapter->mlmepriv.p2p_probe_resp_ie == NULL) { - DBG_8723A("DON'T issue_probersp23a_p2p23a: p2p_enabled:%d, " - "wps_probe_resp_ie:%p, p2p_probe_resp_ie:%p\n", - wdev_to_priv(padapter->rtw_wdev)->p2p_enabled, - padapter->mlmepriv.wps_probe_resp_ie, - padapter->mlmepriv.p2p_probe_resp_ie); - response = false; - } - - if (response == true) - issue_probersp23a_p2p23a(padapter, da); - - return _SUCCESS; -} -#endif /* CONFIG_8723AU_P2P */ - /**************************************************************************** Following are the callback functions for each subtype of the management frames @@ -676,46 +652,6 @@ unsigned int OnProbeReq23a(struct rtw_adapter *padapter, uint len = skb->len; u8 is_valid_p2p_probereq = false; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - u8 wifi_test_chk_rate = 1; - - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) && - !rtw_p2p_chk_state(pwdinfo, P2P_STATE_IDLE) && - !rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT) && - !rtw_p2p_chk_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH) && - !rtw_p2p_chk_state(pwdinfo, P2P_STATE_SCAN)) { - /* mcs_rate = 0 -> CCK 1M rate */ - /* mcs_rate = 1 -> CCK 2M rate */ - /* mcs_rate = 2 -> CCK 5.5M rate */ - /* mcs_rate = 3 -> CCK 11M rate */ - /* In the P2P mode, the driver should not support - the CCK rate */ - - /* IOT issue: Google Nexus7 use 1M rate to send - p2p_probe_req after GO nego completed and Nexus7 - is client */ - if (wifi_test_chk_rate == 1) { - if ((is_valid_p2p_probereq = - process_probe_req_p2p_ie23a(pwdinfo, pframe, - len)) == true) { - if (rtw_p2p_chk_role(pwdinfo, - P2P_ROLE_DEVICE)) { - u8 *sa = ieee80211_get_SA(hdr); - p2p_listen_state_process(padapter, sa); - return _SUCCESS; - } - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { - goto _continue; - } - } - } - } - -_continue: -#endif /* CONFIG_8723AU_P2P */ - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { return _SUCCESS; } @@ -761,56 +697,6 @@ unsigned int OnProbeRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; -#ifdef CONFIG_8723AU_P2P - struct sk_buff *skb = precv_frame->pkt; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif - -#ifdef CONFIG_8723AU_P2P - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ)) { - if (pwdinfo->tx_prov_disc_info.benable == true) { - if (ether_addr_equal(pwdinfo->tx_prov_disc_info.peerIFAddr, - hdr->addr2)) { - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) { - pwdinfo->tx_prov_disc_info.benable = false; - issue_p2p_provision_request23a(padapter, - pwdinfo->tx_prov_disc_info.ssid.ssid, - pwdinfo->tx_prov_disc_info.ssid.ssid_len, - pwdinfo->tx_prov_disc_info.peerDevAddr); - } - else if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE) || rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - { - pwdinfo->tx_prov_disc_info.benable = false; - issue_p2p_provision_request23a(padapter, - NULL, - 0, - pwdinfo->tx_prov_disc_info.peerDevAddr); - } - } - } - return _SUCCESS; - } else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING)) { - if (pwdinfo->nego_req_info.benable == true) { - DBG_8723A("[%s] P2P State is GONEGO ING!\n", __func__); - if (ether_addr_equal(pwdinfo->nego_req_info.peerDevAddr, - hdr->addr2)) { - pwdinfo->nego_req_info.benable = false; - issue_p2p_GO_request23a(padapter, pwdinfo->nego_req_info.peerDevAddr); - } - } - } else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_INVITE_REQ)) { - if (pwdinfo->invitereq_info.benable == true) { - DBG_8723A("[%s] P2P_STATE_TX_INVITE_REQ!\n", __func__); - if (ether_addr_equal( - pwdinfo->invitereq_info.peer_macaddr, - hdr->addr2)) { - pwdinfo->invitereq_info.benable = false; - issue_p2p_invitation_request23a(padapter, pwdinfo->invitereq_info.peer_macaddr); - } - } - } -#endif if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { report_survey_event23a(padapter, precv_frame); @@ -910,10 +796,6 @@ unsigned int OnBeacon23a(struct rtw_adapter *padapter, update_beacon23a_info(padapter, pframe, len, psta); } - -#ifdef CONFIG_8723AU_P2P - process_p2p_ps_ie23a(padapter, (pframe + sizeof(struct ieee80211_hdr_3addr)), (len - sizeof(struct ieee80211_hdr_3addr))); -#endif /* CONFIG_8723AU_P2P */ } } else if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { psta = rtw_get_stainfo23a(pstapriv, hdr->addr2); @@ -1276,14 +1158,6 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec uint pkt_len = skb->len; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; u16 frame_control; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - u8 p2p_status_code = P2P_STATUS_SUCCESS; - u8 *p2pie; - u32 p2pielen = 0; - u8 wfd_ie[MAX_WFD_IE_LEN] = { 0x00 }; - u32 wfd_ielen = 0; -#endif /* CONFIG_8723AU_P2P */ if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) return _FAIL; @@ -1645,39 +1519,6 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec if (status != WLAN_STATUS_SUCCESS) goto OnAssocReq23aFail; -#ifdef CONFIG_8723AU_P2P - pstat->is_p2p_device = false; - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - { - if ((p2pie = rtw_get_p2p_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset, pkt_len - sizeof(struct ieee80211_hdr_3addr) - ie_offset, NULL, &p2pielen))) - { - pstat->is_p2p_device = true; - if ((p2p_status_code = (u8)process_assoc_req_p2p_ie23a(pwdinfo, pframe, pkt_len, pstat))>0) - { - pstat->p2p_status_code = p2p_status_code; - status = WLAN_STATUS_CAPS_UNSUPPORTED; - goto OnAssocReq23aFail; - } - } -#ifdef CONFIG_8723AU_P2P - if (rtw_get_wfd_ie(pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset, pkt_len - sizeof(struct ieee80211_hdr_3addr) - ie_offset, wfd_ie, &wfd_ielen)) - { - u8 attr_content[ 10 ] = { 0x00 }; - u32 attr_contentlen = 0; - - DBG_8723A("[%s] WFD IE Found!!\n", __func__); - rtw_get_wfd_attr_content(wfd_ie, wfd_ielen, WFD_ATTR_DEVICE_INFO, attr_content, &attr_contentlen); - if (attr_contentlen) - { - pwdinfo->wfd_info->peer_rtsp_ctrlport = get_unaligned_be16(attr_content + 2); - DBG_8723A("[%s] Peer PORT NUM = %d\n", __func__, pwdinfo->wfd_info->peer_rtsp_ctrlport); - } - } -#endif - } - pstat->p2p_status_code = p2p_status_code; -#endif /* CONFIG_8723AU_P2P */ - /* TODO: identify_proprietary_vendor_ie(); */ /* Realtek proprietary IE */ /* identify if this is Broadcom sta */ @@ -1833,13 +1674,7 @@ unsigned int OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *prec { case WLAN_EID_VENDOR_SPECIFIC: if (!memcmp(pIE->data, WMM_PARA_OUI23A, 6))/* WMM */ - WMM_param_handler23a(padapter, pIE); -#if defined(CONFIG_8723AU_P2P) - else if (!memcmp(pIE->data, WFD_OUI23A, 4)) { /* WFD */ - DBG_8723A("[%s] Found WFD IE\n", __func__); - WFD_info_handler(padapter, pIE); - } -#endif + WMM_param_handler23a(padapter, pIE); break; case WLAN_EID_HT_CAPABILITY: /* HT caps */ @@ -1893,21 +1728,11 @@ unsigned int OnDeAuth23a(struct rtw_adapter *padapter, struct sk_buff *skb = precv_frame->pkt; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; u8 *pframe = skb->data; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* CONFIG_8723AU_P2P */ /* check A3 */ if (!ether_addr_equal(hdr->addr3, get_my_bssid23a(&pmlmeinfo->network))) return _SUCCESS; -#ifdef CONFIG_8723AU_P2P - if (pwdinfo->rx_invitereq_info.scan_op_ch_only) { - mod_timer(&pwdinfo->reset_ch_sitesurvey, - jiffies + msecs_to_jiffies(10)); - } -#endif /* CONFIG_8723AU_P2P */ - reason = le16_to_cpu(*(unsigned short *)(pframe + sizeof(struct ieee80211_hdr_3addr))); DBG_8723A("%s Reason code(%d)\n", __func__, reason); @@ -1959,22 +1784,11 @@ unsigned int OnDisassoc23a(struct rtw_adapter *padapter, struct recv_frame *prec struct sk_buff *skb = precv_frame->pkt; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; u8 *pframe = skb->data; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* CONFIG_8723AU_P2P */ /* check A3 */ if (!ether_addr_equal(hdr->addr3, get_my_bssid23a(&pmlmeinfo->network))) return _SUCCESS; -#ifdef CONFIG_8723AU_P2P - if (pwdinfo->rx_invitereq_info.scan_op_ch_only) - { - mod_timer(&pwdinfo->reset_ch_sitesurvey, - jiffies + msecs_to_jiffies(10)); - } -#endif /* CONFIG_8723AU_P2P */ - reason = le16_to_cpu(*(unsigned short *) (pframe + sizeof(struct ieee80211_hdr_3addr))); @@ -2115,2388 +1929,26 @@ unsigned int OnAction23a_back23a(struct rtw_adapter *padapter, struct recv_frame /* reason_code = frame_body[4] | (frame_body[5] << 8); */ reason_code = get_unaligned_le16(&frame_body[4]); - } else if ((frame_body[3] & BIT(3)) == BIT(3)) { - tid = (frame_body[3] >> 4) & 0x0F; - - preorder_ctrl = &psta->recvreorder_ctrl[tid]; - preorder_ctrl->enable = false; - preorder_ctrl->indicate_seq = 0xffff; - } - - DBG_8723A("%s(): DELBA: %x(%x)\n", __func__, - pmlmeinfo->agg_enable_bitmap, reason_code); - /* todo: how to notify the host while receiving - DELETE BA */ - break; - default: - break; - } - } - return _SUCCESS; -} - -#ifdef CONFIG_8723AU_P2P - -static int get_reg_classes_full_count(struct p2p_channels channel_list) { - int cnt = 0; - int i; - - for (i = 0; i < channel_list.reg_classes; i++) - cnt += channel_list.reg_class[i].channels; - - return cnt; -} - -void issue_p2p_GO_request23a(struct rtw_adapter *padapter, u8* raddr) -{ - unsigned char category = WLAN_CATEGORY_PUBLIC; - u8 action = P2P_PUB_ACTION_ACTION; - u32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_GO_NEGO_REQ; - u8 wpsie[ 255 ] = { 0x00 }, p2pie[ 255 ] = { 0x00 }; - u8 wpsielen = 0, p2pielen = 0; - u16 len_channellist_attr = 0; -#ifdef CONFIG_8723AU_P2P - u32 wfdielen = 0; -#endif /* CONFIG_8723AU_P2P */ - - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) - return; - - DBG_8723A("[%s] In\n", __func__); - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib23a(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; - - ether_addr_copy(pwlanhdr->addr1, raddr); - ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); - ether_addr_copy(pwlanhdr->addr3, myid(&padapter->eeprompriv)); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_ACTION); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *)&p2poui, - &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen); - pwdinfo->negotiation_dialog_token = 1; /*Initialize the dialog value*/ - pframe = rtw_set_fixed_ie23a(pframe, 1, - &pwdinfo->negotiation_dialog_token, - &pattrib->pktlen); - - /* WPS Section */ - wpsielen = 0; - /* WPS OUI */ - *(u32*) (wpsie) = cpu_to_be32(WPSOUI); - wpsielen += 4; - - /* WPS version */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0001); - wpsielen += 2; - - /* Value: */ - wpsie[wpsielen++] = WPS_VERSION_1; /* Version 1.0 */ - - /* Device Password ID */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_PWID); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0002); - wpsielen += 2; - - /* Value: */ - - if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_PEER_DISPLAY_PIN) - { - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_DPID_USER_SPEC); - } - else if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_SELF_DISPLAY_PIN) - { - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_DPID_REGISTRAR_SPEC); - } - else if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_PBC) - { - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_DPID_PBC); - } - - wpsielen += 2; - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, wpsielen, - (unsigned char *) wpsie, &pattrib->pktlen); - - /* P2P IE Section. */ - - /* P2P OUI */ - p2pielen = 0; - p2pie[p2pielen++] = 0x50; - p2pie[p2pielen++] = 0x6F; - p2pie[p2pielen++] = 0x9A; - p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20110306 */ - /* According to the P2P Specification, the group negoitation request frame should contain 9 P2P attributes */ - /* 1. P2P Capability */ - /* 2. Group Owner Intent */ - /* 3. Configuration Timeout */ - /* 4. Listen Channel */ - /* 5. Extended Listen Timing */ - /* 6. Intended P2P Interface Address */ - /* 7. Channel List */ - /* 8. P2P Device Info */ - /* 9. Operating Channel */ - - /* P2P Capability */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); - p2pielen += 2; - - /* Value: */ - /* Device Capability Bitmap, 1 byte */ - p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; - - /* Group Capability Bitmap, 1 byte */ - if (pwdinfo->persistent_supported) - { - p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN | P2P_GRPCAP_PERSISTENT_GROUP; - } - else - { - p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN; - } - - /* Group Owner Intent */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_GO_INTENT; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0001); - p2pielen += 2; - - /* Value: */ - /* Todo the tie breaker bit. */ - p2pie[p2pielen++] = ((pwdinfo->intent << 1) | BIT(0)); - - /* Configuration Timeout */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CONF_TIMEOUT; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); - p2pielen += 2; - - /* Value: */ - p2pie[p2pielen++] = 200; /* 2 seconds needed to be the P2P GO */ - p2pie[p2pielen++] = 200; /* 2 seconds needed to be the P2P Client */ - - /* Listen Channel */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_LISTEN_CH; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0005); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Operating Class */ - p2pie[p2pielen++] = 0x51; /* Copy from SD7 */ - - /* Channel Number */ - p2pie[p2pielen++] = pwdinfo->listen_channel; /* listening channel number */ - - /* Extended Listen Timing ATTR */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_EX_LISTEN_TIMING; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0004); - p2pielen += 2; - - /* Value: */ - /* Availability Period */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); - p2pielen += 2; - - /* Availability Interval */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); - p2pielen += 2; - - /* Intended P2P Interface Address */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_INTENTED_IF_ADDR; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(ETH_ALEN); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); - p2pielen += ETH_ALEN; - - /* Channel List */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CH_LIST; - - /* Length: */ - /* Country String(3) */ - /* + (Operating Class (1) + Number of Channels(1)) * Operation Classes (?) */ - /* + number of channels in all classes */ - len_channellist_attr = 3 - + (1 + 1) * (u16)(pmlmeext->channel_list.reg_classes) - + get_reg_classes_full_count(pmlmeext->channel_list); - - *(u16*) (p2pie + p2pielen) = cpu_to_le16(len_channellist_attr); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Channel Entry List */ - - { - int i, j; - for (j = 0; j < pmlmeext->channel_list.reg_classes; j++) { - /* Operating Class */ - p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].reg_class; - - /* Number of Channels */ - p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channels; - - /* Channel List */ - for (i = 0; i < pmlmeext->channel_list.reg_class[j].channels; i++) { - p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channel[i]; - } - } - } - - /* Device Info */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO; - - /* Length: */ - /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */ - /* + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); - p2pielen += 2; - - /* Value: */ - /* P2P Device Address */ - memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); - p2pielen += ETH_ALEN; - - /* Config Method */ - /* This field should be big endian. Noted by P2P specification. */ - - *(u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->supported_wps_cm); - - p2pielen += 2; - - /* Primary Device Type */ - /* Category ID */ - *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); - p2pielen += 2; - - /* OUI */ - *(u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI); - p2pielen += 4; - - /* Sub Category ID */ - *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); - p2pielen += 2; - - /* Number of Secondary Device Types */ - p2pie[p2pielen++] = 0x00; /* No Secondary Device Type List */ - - /* Device Name */ - /* Type: */ - *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); - p2pielen += 2; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, pwdinfo->device_name, - pwdinfo->device_name_len); - p2pielen += pwdinfo->device_name_len; - - /* Operating Channel */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0005); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Operating Class */ - if (pwdinfo->operating_channel <= 14) - { - /* Operating Class */ - p2pie[p2pielen++] = 0x51; - } - else if ((pwdinfo->operating_channel >= 36) && (pwdinfo->operating_channel <= 48)) - { - /* Operating Class */ - p2pie[p2pielen++] = 0x73; - } - else - { - /* Operating Class */ - p2pie[p2pielen++] = 0x7c; - } - - /* Channel Number */ - p2pie[p2pielen++] = pwdinfo->operating_channel; /* operating channel number */ - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, - (unsigned char *) p2pie, &pattrib->pktlen); - -#ifdef CONFIG_8723AU_P2P - wfdielen = build_nego_req_wfd_ie(pwdinfo, pframe); - pframe += wfdielen; - pattrib->pktlen += wfdielen; -#endif /* CONFIG_8723AU_P2P */ - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe23a(padapter, pmgntframe); - - return; -} - -static void issue_p2p_GO_response(struct rtw_adapter *padapter, u8* raddr, u8* frame_body, uint len, u8 result) -{ - - unsigned char category = WLAN_CATEGORY_PUBLIC; - u8 action = P2P_PUB_ACTION_ACTION; - u32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_GO_NEGO_RESP; - u8 wpsie[255] = { 0x00 }, p2pie[255] = { 0x00 }; - u8 p2pielen = 0; - uint wpsielen = 0; - u16 wps_devicepassword_id = 0x0000; - uint wps_devicepassword_id_len = 0; - u16 len_channellist_attr = 0; - int i, j; - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#ifdef CONFIG_8723AU_P2P - u32 wfdielen = 0; -#endif /* CONFIG_8723AU_P2P */ - - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) - return; - - DBG_8723A("[%s] In, result = %d\n", __func__, result); - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib23a(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; - - ether_addr_copy(pwlanhdr->addr1, raddr); - ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); - ether_addr_copy(pwlanhdr->addr3, myid(&padapter->eeprompriv)); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_ACTION); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *) &p2poui, - &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen); - /* The Dialog Token of provisioning discovery request frame. */ - pwdinfo->negotiation_dialog_token = frame_body[7]; - pframe = rtw_set_fixed_ie23a(pframe, 1, - &pwdinfo->negotiation_dialog_token, - &pattrib->pktlen); - - /* Commented by Albert 20110328 */ - /* Try to get the device password ID from the WPS IE of group - negotiation request frame */ - /* WiFi Direct test plan 5.1.15 */ - rtw_get_wps_ie23a(frame_body + _PUBLIC_ACTION_IE_OFFSET_, - len - _PUBLIC_ACTION_IE_OFFSET_, wpsie, &wpsielen); - rtw_get_wps_attr_content23a(wpsie, wpsielen, WPS_ATTR_DEVICE_PWID, - (u8 *)&wps_devicepassword_id, - &wps_devicepassword_id_len); - wps_devicepassword_id = be16_to_cpu(wps_devicepassword_id); - - memset(wpsie, 0x00, 255); - wpsielen = 0; - - /* WPS Section */ - wpsielen = 0; - /* WPS OUI */ - *(u32*) (wpsie) = cpu_to_be32(WPSOUI); - wpsielen += 4; - - /* WPS version */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0001); - wpsielen += 2; - - /* Value: */ - wpsie[wpsielen++] = WPS_VERSION_1; /* Version 1.0 */ - - /* Device Password ID */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_PWID); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0002); - wpsielen += 2; - - /* Value: */ - if (wps_devicepassword_id == WPS_DPID_USER_SPEC) { - *(u16*) (wpsie + wpsielen) = - cpu_to_be16(WPS_DPID_REGISTRAR_SPEC); - } else if (wps_devicepassword_id == WPS_DPID_REGISTRAR_SPEC) { - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_DPID_USER_SPEC); - } else { - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_DPID_PBC); - } - wpsielen += 2; - - /* Commented by Kurt 20120113 */ - /* If some device wants to do p2p handshake without sending prov_disc_req */ - /* We have to get peer_req_cm from here. */ - if (!memcmp(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "000", 3)) { - if (wps_devicepassword_id == WPS_DPID_USER_SPEC) { - memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "dis", 3); - } else if (wps_devicepassword_id == WPS_DPID_REGISTRAR_SPEC) { - memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pad", 3); - } else { - memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pbc", 3); - } - } - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, wpsielen, - (unsigned char *) wpsie, &pattrib->pktlen); - - /* P2P IE Section. */ - - /* P2P OUI */ - p2pielen = 0; - p2pie[p2pielen++] = 0x50; - p2pie[p2pielen++] = 0x6F; - p2pie[p2pielen++] = 0x9A; - p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20100908 */ - /* According to the P2P Specification, the group negoitation - response frame should contain 9 P2P attributes */ - /* 1. Status */ - /* 2. P2P Capability */ - /* 3. Group Owner Intent */ - /* 4. Configuration Timeout */ - /* 5. Operating Channel */ - /* 6. Intended P2P Interface Address */ - /* 7. Channel List */ - /* 8. Device Info */ - /* 9. Group ID (Only GO) */ - - /* ToDo: */ - - /* P2P Status */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_STATUS; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0001); - p2pielen += 2; - - /* Value: */ - p2pie[p2pielen++] = result; - - /* P2P Capability */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); - p2pielen += 2; - - /* Value: */ - /* Device Capability Bitmap, 1 byte */ - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) { - /* Commented by Albert 2011/03/08 */ - /* According to the P2P specification */ - /* if the sending device will be client, the P2P - Capability should be reserved of group negotation - response frame */ - p2pie[p2pielen++] = 0; - } else { - /* Be group owner or meet the error case */ - p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; - } - - /* Group Capability Bitmap, 1 byte */ - if (pwdinfo->persistent_supported) { - p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN | - P2P_GRPCAP_PERSISTENT_GROUP; - } else { - p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN; - } - - /* Group Owner Intent */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_GO_INTENT; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0001); - p2pielen += 2; - - /* Value: */ - if (pwdinfo->peer_intent & 0x01) { - /* Peer's tie breaker bit is 1, our tie breaker - bit should be 0 */ - p2pie[p2pielen++] = (pwdinfo->intent << 1); - } else { - /* Peer's tie breaker bit is 0, our tie breaker bit - should be 1 */ - p2pie[p2pielen++] = ((pwdinfo->intent << 1) | BIT(0)); - } - - /* Configuration Timeout */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CONF_TIMEOUT; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); - p2pielen += 2; - - /* Value: */ - /* 2 seconds needed to be the P2P GO */ - p2pie[p2pielen++] = 200; - /* 2 seconds needed to be the P2P Client */ - p2pie[p2pielen++] = 200; - - /* Operating Channel */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0005); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Operating Class */ - if (pwdinfo->operating_channel <= 14) { - /* Operating Class */ - p2pie[p2pielen++] = 0x51; - } else if ((pwdinfo->operating_channel >= 36) && - (pwdinfo->operating_channel <= 48)) { - /* Operating Class */ - p2pie[p2pielen++] = 0x73; - } else { - /* Operating Class */ - p2pie[p2pielen++] = 0x7c; - } - - /* Channel Number */ - /* operating channel number */ - p2pie[p2pielen++] = pwdinfo->operating_channel; - - /* Intended P2P Interface Address */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_INTENTED_IF_ADDR; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(ETH_ALEN); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); - p2pielen += ETH_ALEN; - - /* Channel List */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CH_LIST; - - /* Country String(3) */ - /* + (Operating Class (1) + Number of Channels(1)) * - Operation Classes (?) */ - /* + number of channels in all classes */ - len_channellist_attr = 3 + - (1 + 1) * (u16)pmlmeext->channel_list.reg_classes + - get_reg_classes_full_count(pmlmeext->channel_list); - - *(u16*) (p2pie + p2pielen) = cpu_to_le16(len_channellist_attr); - - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Channel Entry List */ - - for (j = 0; j < pmlmeext->channel_list.reg_classes; j++) { - /* Operating Class */ - p2pie[p2pielen++] = - pmlmeext->channel_list.reg_class[j].reg_class; - - /* Number of Channels */ - p2pie[p2pielen++] = - pmlmeext->channel_list.reg_class[j].channels; - - /* Channel List */ - for (i = 0; - i < pmlmeext->channel_list.reg_class[j].channels; i++) { - p2pie[p2pielen++] = - pmlmeext->channel_list.reg_class[j].channel[i]; - } - } - - /* Device Info */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO; - - /* Length: */ - /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + - Primary Device Type (8bytes) */ - /* + NumofSecondDevType (1byte) + WPS Device Name ID field - (2bytes) + WPS Device Name Len field (2bytes) */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); - p2pielen += 2; - - /* Value: */ - /* P2P Device Address */ - memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); - p2pielen += ETH_ALEN; - - /* Config Method */ - /* This field should be big endian. Noted by P2P specification. */ - - *(u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->supported_wps_cm); - - p2pielen += 2; - - /* Primary Device Type */ - /* Category ID */ - *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); - p2pielen += 2; - - /* OUI */ - *(u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI); - p2pielen += 4; - - /* Sub Category ID */ - *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); - p2pielen += 2; - - /* Number of Secondary Device Types */ - p2pie[p2pielen++] = 0x00; /* No Secondary Device Type List */ - - /* Device Name */ - /* Type: */ - *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); - p2pielen += 2; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, pwdinfo->device_name, - pwdinfo->device_name_len); - p2pielen += pwdinfo->device_name_len; - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - { - /* Group ID Attribute */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_GROUP_ID; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = - cpu_to_le16(ETH_ALEN + pwdinfo->nego_ssidlen); - p2pielen += 2; - - /* Value: */ - /* p2P Device Address */ - memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN); - p2pielen += ETH_ALEN; - - /* SSID */ - memcpy(p2pie + p2pielen, pwdinfo->nego_ssid, - pwdinfo->nego_ssidlen); - p2pielen += pwdinfo->nego_ssidlen; - - } - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, - (unsigned char *) p2pie, &pattrib->pktlen); - -#ifdef CONFIG_8723AU_P2P - wfdielen = build_nego_resp_wfd_ie(pwdinfo, pframe); - pframe += wfdielen; - pattrib->pktlen += wfdielen; -#endif /* CONFIG_8723AU_P2P */ - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe23a(padapter, pmgntframe); - - return; -} - -static void issue_p2p_GO_confirm(struct rtw_adapter *padapter, u8* raddr, - u8 result) -{ - - unsigned char category = WLAN_CATEGORY_PUBLIC; - u8 action = P2P_PUB_ACTION_ACTION; - u32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_GO_NEGO_CONF; - u8 p2pie[ 255 ] = { 0x00 }; - u8 p2pielen = 0; - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#ifdef CONFIG_8723AU_P2P - u32 wfdielen = 0; -#endif /* CONFIG_8723AU_P2P */ - - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) - return; - - DBG_8723A("[%s] In\n", __func__); - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib23a(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; - - ether_addr_copy(pwlanhdr->addr1, raddr); - ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); - ether_addr_copy(pwlanhdr->addr3, myid(&padapter->eeprompriv)); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_ACTION); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *)&p2poui, - &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, - &pwdinfo->negotiation_dialog_token, - &pattrib->pktlen); - /* P2P OUI */ - p2pielen = 0; - p2pie[p2pielen++] = 0x50; - p2pie[p2pielen++] = 0x6F; - p2pie[p2pielen++] = 0x9A; - p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20110306 */ - /* According to the P2P Specification, the group negoitation - request frame should contain 5 P2P attributes */ - /* 1. Status */ - /* 2. P2P Capability */ - /* 3. Operating Channel */ - /* 4. Channel List */ - /* 5. Group ID (if this WiFi is GO) */ - - /* P2P Status */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_STATUS; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0001); - p2pielen += 2; - - /* Value: */ - p2pie[p2pielen++] = result; - - /* P2P Capability */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); - p2pielen += 2; - - /* Value: */ - /* Device Capability Bitmap, 1 byte */ - p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; - - /* Group Capability Bitmap, 1 byte */ - if (pwdinfo->persistent_supported) { - p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN | - P2P_GRPCAP_PERSISTENT_GROUP; - } else { - p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN; - } - - /* Operating Channel */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0005); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) { - if (pwdinfo->peer_operating_ch <= 14) { - /* Operating Class */ - p2pie[p2pielen++] = 0x51; - } else if ((pwdinfo->peer_operating_ch >= 36) && - (pwdinfo->peer_operating_ch <= 48)) { - /* Operating Class */ - p2pie[p2pielen++] = 0x73; - } else { - /* Operating Class */ - p2pie[p2pielen++] = 0x7c; - } - - p2pie[p2pielen++] = pwdinfo->peer_operating_ch; - } else { - if (pwdinfo->operating_channel <= 14) { - /* Operating Class */ - p2pie[p2pielen++] = 0x51; - } - else if ((pwdinfo->operating_channel >= 36) && - (pwdinfo->operating_channel <= 48)) { - /* Operating Class */ - p2pie[p2pielen++] = 0x73; - } else { - /* Operating Class */ - p2pie[p2pielen++] = 0x7c; - } - - /* Channel Number */ - /* Use the listen channel as the operating channel */ - p2pie[p2pielen++] = pwdinfo->operating_channel; - } - - /* Channel List */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CH_LIST; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = - cpu_to_le16(pwdinfo->channel_list_attr_len); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, pwdinfo->channel_list_attr, - pwdinfo->channel_list_attr_len); - p2pielen += pwdinfo->channel_list_attr_len; - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { - /* Group ID Attribute */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_GROUP_ID; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = - cpu_to_le16(ETH_ALEN + pwdinfo->nego_ssidlen); - p2pielen += 2; - - /* Value: */ - /* p2P Device Address */ - memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN); - p2pielen += ETH_ALEN; - - /* SSID */ - memcpy(p2pie + p2pielen, pwdinfo->nego_ssid, - pwdinfo->nego_ssidlen); - p2pielen += pwdinfo->nego_ssidlen; - } - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, - (unsigned char *)p2pie, &pattrib->pktlen); - -#ifdef CONFIG_8723AU_P2P - wfdielen = build_nego_confirm_wfd_ie(pwdinfo, pframe); - pframe += wfdielen; - pattrib->pktlen += wfdielen; -#endif /* CONFIG_8723AU_P2P */ - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe23a(padapter, pmgntframe); - - return; -} - -void issue_p2p_invitation_request23a(struct rtw_adapter *padapter, u8* raddr) -{ - unsigned char category = WLAN_CATEGORY_PUBLIC; - u8 action = P2P_PUB_ACTION_ACTION; - u32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_INVIT_REQ; - u8 p2pie[ 255 ] = { 0x00 }; - u8 p2pielen = 0; - u8 dialogToken = 3; - u16 len_channellist_attr = 0; -#ifdef CONFIG_8723AU_P2P - u32 wfdielen = 0; -#endif /* CONFIG_8723AU_P2P */ - int i, j; - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) - return; - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib23a(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; - - ether_addr_copy(pwlanhdr->addr1, raddr); - ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); - ether_addr_copy(pwlanhdr->addr3, raddr); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_ACTION); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *) &p2poui, - &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &dialogToken, &pattrib->pktlen); - - /* P2P IE Section. */ - - /* P2P OUI */ - p2pielen = 0; - p2pie[p2pielen++] = 0x50; - p2pie[p2pielen++] = 0x6F; - p2pie[p2pielen++] = 0x9A; - p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20101011 */ - /* According to the P2P Specification, the P2P Invitation - request frame should contain 7 P2P attributes */ - /* 1. Configuration Timeout */ - /* 2. Invitation Flags */ - /* 3. Operating Channel (Only GO) */ - /* 4. P2P Group BSSID (Should be included if I am the GO) */ - /* 5. Channel List */ - /* 6. P2P Group ID */ - /* 7. P2P Device Info */ - - /* Configuration Timeout */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CONF_TIMEOUT; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); - p2pielen += 2; - - /* Value: */ - /* 2 seconds needed to be the P2P GO */ - p2pie[p2pielen++] = 200; - /* 2 seconds needed to be the P2P Client */ - p2pie[p2pielen++] = 200; - - /* Invitation Flags */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_INVITATION_FLAGS; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0001); - p2pielen += 2; - - /* Value: */ - p2pie[p2pielen++] = P2P_INVITATION_FLAGS_PERSISTENT; - - /* Operating Channel */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0005); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Operating Class */ - if (pwdinfo->invitereq_info.operating_ch <= 14) - p2pie[p2pielen++] = 0x51; - else if ((pwdinfo->invitereq_info.operating_ch >= 36) && - (pwdinfo->invitereq_info.operating_ch <= 48)) - p2pie[p2pielen++] = 0x73; - else - p2pie[p2pielen++] = 0x7c; - - /* Channel Number */ - /* operating channel number */ - p2pie[p2pielen++] = pwdinfo->invitereq_info.operating_ch; - - if (ether_addr_equal(myid(&padapter->eeprompriv), - pwdinfo->invitereq_info.go_bssid)) { - /* P2P Group BSSID */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_GROUP_BSSID; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(ETH_ALEN); - p2pielen += 2; - - /* Value: */ - /* P2P Device Address for GO */ - memcpy(p2pie + p2pielen, pwdinfo->invitereq_info.go_bssid, - ETH_ALEN); - p2pielen += ETH_ALEN; - } - - /* Channel List */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CH_LIST; - - /* Length: */ - /* Country String(3) */ - /* + (Operating Class (1) + Number of Channels(1)) * - Operation Classes (?) */ - /* + number of channels in all classes */ - len_channellist_attr = 3 + - (1 + 1) * (u16)pmlmeext->channel_list.reg_classes + - get_reg_classes_full_count(pmlmeext->channel_list); - - *(u16*) (p2pie + p2pielen) = cpu_to_le16(len_channellist_attr); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Channel Entry List */ - for (j = 0; j < pmlmeext->channel_list.reg_classes; j++) { - /* Operating Class */ - p2pie[p2pielen++] = - pmlmeext->channel_list.reg_class[j].reg_class; - - /* Number of Channels */ - p2pie[p2pielen++] = - pmlmeext->channel_list.reg_class[j].channels; - - /* Channel List */ - for (i = 0; - i < pmlmeext->channel_list.reg_class[j].channels; i++) { - p2pie[p2pielen++] = - pmlmeext->channel_list.reg_class[j].channel[i]; - } - } - - /* P2P Group ID */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_GROUP_ID; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = - cpu_to_le16(6 + pwdinfo->invitereq_info.ssidlen); - p2pielen += 2; - - /* Value: */ - /* P2P Device Address for GO */ - memcpy(p2pie + p2pielen, pwdinfo->invitereq_info.go_bssid, ETH_ALEN); - p2pielen += ETH_ALEN; - - /* SSID */ - memcpy(p2pie + p2pielen, pwdinfo->invitereq_info.go_ssid, - pwdinfo->invitereq_info.ssidlen); - p2pielen += pwdinfo->invitereq_info.ssidlen; - - /* Device Info */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO; - - /* Length: */ - /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + - Primary Device Type (8bytes) */ - /* + NumofSecondDevType (1byte) + WPS Device Name ID field - (2bytes) + WPS Device Name Len field (2bytes) */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); - p2pielen += 2; - - /* Value: */ - /* P2P Device Address */ - memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); - p2pielen += ETH_ALEN; - - /* Config Method */ - /* This field should be big endian. Noted by P2P specification. */ - *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_DISPLAY); - p2pielen += 2; - - /* Primary Device Type */ - /* Category ID */ - *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); - p2pielen += 2; - - /* OUI */ - *(u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI); - p2pielen += 4; - - /* Sub Category ID */ - *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); - p2pielen += 2; - - /* Number of Secondary Device Types */ - p2pie[p2pielen++] = 0x00; /* No Secondary Device Type List */ - - /* Device Name */ - /* Type: */ - *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); - p2pielen += 2; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, pwdinfo->device_name, - pwdinfo->device_name_len); - p2pielen += pwdinfo->device_name_len; - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, - (unsigned char *) p2pie, &pattrib->pktlen); - -#ifdef CONFIG_8723AU_P2P - wfdielen = build_invitation_req_wfd_ie(pwdinfo, pframe); - pframe += wfdielen; - pattrib->pktlen += wfdielen; -#endif /* CONFIG_8723AU_P2P */ - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe23a(padapter, pmgntframe); - - return; -} - -void issue_p2p_invitation_response23a(struct rtw_adapter *padapter, u8 *raddr, - u8 dialogToken, u8 status_code) -{ - unsigned char category = WLAN_CATEGORY_PUBLIC; - u8 action = P2P_PUB_ACTION_ACTION; - u32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_INVIT_RESP; - u8 p2pie[ 255 ] = { 0x00 }; - u8 p2pielen = 0; - u16 len_channellist_attr = 0; -#ifdef CONFIG_8723AU_P2P - u32 wfdielen = 0; -#endif /* CONFIG_8723AU_P2P */ - int i, j; - - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) - return; - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib23a(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; - - ether_addr_copy(pwlanhdr->addr1, raddr); - ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); - ether_addr_copy(pwlanhdr->addr3, raddr); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_ACTION); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *)&p2poui, - &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &dialogToken, &pattrib->pktlen); - - /* P2P IE Section. */ - - /* P2P OUI */ - p2pielen = 0; - p2pie[p2pielen++] = 0x50; - p2pie[p2pielen++] = 0x6F; - p2pie[p2pielen++] = 0x9A; - p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20101005 */ - /* According to the P2P Specification, the P2P Invitation - response frame should contain 5 P2P attributes */ - /* 1. Status */ - /* 2. Configuration Timeout */ - /* 3. Operating Channel (Only GO) */ - /* 4. P2P Group BSSID (Only GO) */ - /* 5. Channel List */ - - /* P2P Status */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_STATUS; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0001); - p2pielen += 2; - - /* Value: */ - /* When status code is P2P_STATUS_FAIL_INFO_UNAVAILABLE. */ - /* Sent the event receiving the P2P Invitation Req frame - to DMP UI. */ - /* DMP had to compare the MAC address to find out the profile. */ - /* So, the WiFi driver will send the - P2P_STATUS_FAIL_INFO_UNAVAILABLE to NB. */ - /* If the UI found the corresponding profile, the WiFi driver - sends the P2P Invitation Req */ - /* to NB to rebuild the persistent group. */ - p2pie[p2pielen++] = status_code; - - /* Configuration Timeout */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CONF_TIMEOUT; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); - p2pielen += 2; - - /* Value: */ - /* 2 seconds needed to be the P2P GO */ - p2pie[p2pielen++] = 200; - /* 2 seconds needed to be the P2P Client */ - p2pie[p2pielen++] = 200; - - if (status_code == P2P_STATUS_SUCCESS) { - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { - /* The P2P Invitation request frame asks this - Wi-Fi device to be the P2P GO */ - /* In this case, the P2P Invitation response - frame should carry the two more P2P attributes. */ - /* First one is operating channel attribute. */ - /* Second one is P2P Group BSSID attribute. */ - - /* Operating Channel */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0005); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" - section. */ - p2pie[p2pielen++] = 0x04; - - /* Operating Class */ - /* Copy from SD7 */ - p2pie[p2pielen++] = 0x51; - - /* Channel Number */ - /* operating channel number */ - p2pie[p2pielen++] = pwdinfo->operating_channel; - - /* P2P Group BSSID */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_GROUP_BSSID; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(ETH_ALEN); - p2pielen += 2; - - /* Value: */ - /* P2P Device Address for GO */ - memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), - ETH_ALEN); - p2pielen += ETH_ALEN; - } - - /* Channel List */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CH_LIST; - - /* Length: */ - /* Country String(3) */ - /* + (Operating Class (1) + Number of Channels(1)) * - Operation Classes (?) */ - /* + number of channels in all classes */ - len_channellist_attr = 3 + - (1 + 1) * (u16)pmlmeext->channel_list.reg_classes + - get_reg_classes_full_count(pmlmeext->channel_list); - - *(u16*) (p2pie + p2pielen) = cpu_to_le16(len_channellist_attr); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Channel Entry List */ - for (j = 0; j < pmlmeext->channel_list.reg_classes; j++) { - /* Operating Class */ - p2pie[p2pielen++] = - pmlmeext->channel_list.reg_class[j].reg_class; - - /* Number of Channels */ - p2pie[p2pielen++] = - pmlmeext->channel_list.reg_class[j].channels; - - /* Channel List */ - for (i = 0; - i < pmlmeext->channel_list.reg_class[j].channels; - i++) { - p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channel[i]; - } - } - } - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, - (unsigned char *)p2pie, &pattrib->pktlen); - -#ifdef CONFIG_8723AU_P2P - wfdielen = build_invitation_resp_wfd_ie(pwdinfo, pframe); - pframe += wfdielen; - pattrib->pktlen += wfdielen; -#endif /* CONFIG_8723AU_P2P */ - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe23a(padapter, pmgntframe); - - return; -} - -void issue_p2p_provision_request23a(struct rtw_adapter *padapter, u8 *pssid, - u8 ussidlen, u8 *pdev_raddr) -{ - unsigned char category = WLAN_CATEGORY_PUBLIC; - u8 action = P2P_PUB_ACTION_ACTION; - u8 dialogToken = 1; - u32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_PROVISION_DISC_REQ; - u8 wpsie[100] = { 0x00 }; - u8 wpsielen = 0; - u32 p2pielen = 0; -#ifdef CONFIG_8723AU_P2P - u32 wfdielen = 0; -#endif /* CONFIG_8723AU_P2P */ - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) - return; - - DBG_8723A("[%s] In\n", __func__); - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib23a(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; - - ether_addr_copy(pwlanhdr->addr1, pdev_raddr); - ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); - ether_addr_copy(pwlanhdr->addr3, pdev_raddr); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_ACTION); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *)&p2poui, - &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &dialogToken, &pattrib->pktlen); - - p2pielen = build_prov_disc_request_p2p_ie23a(pwdinfo, pframe, pssid, - ussidlen, pdev_raddr); - - pframe += p2pielen; - pattrib->pktlen += p2pielen; - - wpsielen = 0; - /* WPS OUI */ - *(u32*) (wpsie) = cpu_to_be32(WPSOUI); - wpsielen += 4; - - /* WPS version */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0001); - wpsielen += 2; - - /* Value: */ - wpsie[wpsielen++] = WPS_VERSION_1; /* Version 1.0 */ - - /* Config Method */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_CONF_METHOD); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0002); - wpsielen += 2; - - /* Value: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(pwdinfo->tx_prov_disc_info.wps_config_method_request); - wpsielen += 2; - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, wpsielen, - (unsigned char *) wpsie, &pattrib->pktlen); - -#ifdef CONFIG_8723AU_P2P - wfdielen = build_provdisc_req_wfd_ie(pwdinfo, pframe); - pframe += wfdielen; - pattrib->pktlen += wfdielen; -#endif /* CONFIG_8723AU_P2P */ - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe23a(padapter, pmgntframe); - - return; -} - -static u8 is_matched_in_profilelist(u8 *peermacaddr, - struct profile_info *profileinfo) -{ - u8 i, match_result = 0; - - DBG_8723A("[%s] peermac = %.2X %.2X %.2X %.2X %.2X %.2X\n", __func__, - peermacaddr[0], peermacaddr[1], peermacaddr[2], - peermacaddr[3], peermacaddr[4], peermacaddr[5]); - - for (i = 0; i < P2P_MAX_PERSISTENT_GROUP_NUM; i++, profileinfo++) { - DBG_8723A("[%s] profileinfo_mac = %.2X %.2X %.2X %.2X %.2X " - "%.2X\n", __func__, profileinfo->peermac[0], - profileinfo->peermac[1], profileinfo->peermac[2], - profileinfo->peermac[3], profileinfo->peermac[4], - profileinfo->peermac[5]); - if (ether_addr_equal(peermacaddr, profileinfo->peermac)) { - match_result = 1; - DBG_8723A("[%s] Match!\n", __func__); - break; - } - } - - return match_result; -} - -void issue_probersp23a_p2p23a(struct rtw_adapter *padapter, unsigned char *da) -{ - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; - unsigned char *mac; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - u16 beacon_interval = 100; - u16 capInfo = 0; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - u8 wpsie[255] = { 0x00 }; - u32 wpsielen = 0, p2pielen = 0; -#ifdef CONFIG_8723AU_P2P - u32 wfdielen = 0; -#endif /* CONFIG_8723AU_P2P */ - struct cfg80211_wifidirect_info *pcfg80211_wdinfo = - &padapter->cfg80211_wdinfo; - struct ieee80211_channel *ieee_ch = - &pcfg80211_wdinfo->remain_on_ch_channel; - u8 listen_channel = - (u8)ieee80211_frequency_to_channel(ieee_ch->center_freq); - - /* DBG_8723A("%s\n", __func__); */ - - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) - { - return; - } - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib23a(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - mac = myid(&padapter->eeprompriv); - - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; - ether_addr_copy(pwlanhdr->addr1, da); - ether_addr_copy(pwlanhdr->addr2, mac); - - /* Use the device address for BSSID field. */ - ether_addr_copy(pwlanhdr->addr3, mac); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(fctrl, WIFI_PROBERSP); - - pattrib->hdrlen = sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = pattrib->hdrlen; - pframe += pattrib->hdrlen; - - /* timestamp will be inserted by hardware */ - pframe += 8; - pattrib->pktlen += 8; - - /* beacon interval: 2 bytes */ - memcpy(pframe, (unsigned char *) &beacon_interval, 2); - pframe += 2; - pattrib->pktlen += 2; - - /* capability info: 2 bytes */ - /* ESS and IBSS bits must be 0 (defined in the 3.1.2.1.1 of - WiFi Direct Spec) */ - capInfo |= cap_ShortPremble; - capInfo |= cap_ShortSlot; - - memcpy(pframe, (unsigned char *) &capInfo, 2); - pframe += 2; - pattrib->pktlen += 2; - - /* SSID */ - pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID, 7, - pwdinfo->p2p_wildcard_ssid, &pattrib->pktlen); - - /* supported rates... */ - /* Use the OFDM rate in the P2P probe response frame. - (6(B), 9(B), 12, 18, 24, 36, 48, 54) */ - pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, 8, - pwdinfo->support_rate, &pattrib->pktlen); - - /* DS parameter set */ - if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled && - listen_channel != 0) { - pframe = rtw_set_ie23a(pframe, WLAN_EID_DS_PARAMS, 1, - (unsigned char *) &listen_channel, - &pattrib->pktlen); - } else { - pframe = rtw_set_ie23a(pframe, WLAN_EID_DS_PARAMS, 1, - (unsigned char *) - &pwdinfo->listen_channel, - &pattrib->pktlen); - } - - if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled) { - if (pmlmepriv->wps_probe_resp_ie && - pmlmepriv->p2p_probe_resp_ie) { - /* WPS IE */ - memcpy(pframe, pmlmepriv->wps_probe_resp_ie, - pmlmepriv->wps_probe_resp_ie_len); - pattrib->pktlen += pmlmepriv->wps_probe_resp_ie_len; - pframe += pmlmepriv->wps_probe_resp_ie_len; - - /* P2P IE */ - memcpy(pframe, pmlmepriv->p2p_probe_resp_ie, - pmlmepriv->p2p_probe_resp_ie_len); - pattrib->pktlen += pmlmepriv->p2p_probe_resp_ie_len; - pframe += pmlmepriv->p2p_probe_resp_ie_len; - } - } else { - - /* Todo: WPS IE */ - /* Noted by Albert 20100907 */ - /* According to the WPS specification, all the WPS - attribute is presented by Big Endian. */ - - wpsielen = 0; - /* WPS OUI */ - *(u32*) (wpsie) = cpu_to_be32(WPSOUI); - wpsielen += 4; - - /* WPS version */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0001); - wpsielen += 2; - - /* Value: */ - wpsie[wpsielen++] = WPS_VERSION_1; /* Version 1.0 */ - - /* WiFi Simple Config State */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = - cpu_to_be16(WPS_ATTR_SIMPLE_CONF_STATE); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0001); - wpsielen += 2; - - /* Value: */ - wpsie[wpsielen++] = WPS_WSC_STATE_NOT_CONFIG; - - /* Response Type */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_RESP_TYPE); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0001); - wpsielen += 2; - - /* Value: */ - wpsie[wpsielen++] = WPS_RESPONSE_TYPE_8021X; - - /* UUID-E */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_UUID_E); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0010); - wpsielen += 2; - - /* Value: */ - memcpy(wpsie + wpsielen, myid(&padapter->eeprompriv), ETH_ALEN); - wpsielen += 0x10; - - /* Manufacturer */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_MANUFACTURER); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0007); - wpsielen += 2; - - /* Value: */ - memcpy(wpsie + wpsielen, "Realtek", 7); - wpsielen += 7; - - /* Model Name */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_MODEL_NAME); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0006); - wpsielen += 2; - - /* Value: */ - memcpy(wpsie + wpsielen, "8192CU", 6); - wpsielen += 6; - - /* Model Number */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_MODEL_NUMBER); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0001); - wpsielen += 2; - - /* Value: */ - wpsie[ wpsielen++ ] = 0x31; /* character 1 */ - - /* Serial Number */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = - cpu_to_be16(WPS_ATTR_SERIAL_NUMBER); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(ETH_ALEN); - wpsielen += 2; - - /* Value: */ - memcpy(wpsie + wpsielen, "123456", ETH_ALEN); - wpsielen += ETH_ALEN; - - /* Primary Device Type */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = - cpu_to_be16(WPS_ATTR_PRIMARY_DEV_TYPE); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0008); - wpsielen += 2; - - /* Value: */ - /* Category ID */ - *(u16*) (wpsie + wpsielen) = - cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); - wpsielen += 2; - - /* OUI */ - *(u32*) (wpsie + wpsielen) = cpu_to_be32(WPSOUI); - wpsielen += 4; - - /* Sub Category ID */ - *(u16*) (wpsie + wpsielen) = - cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); - wpsielen += 2; - - /* Device Name */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = - cpu_to_be16(pwdinfo->device_name_len); - wpsielen += 2; - - /* Value: */ - if (pwdinfo->device_name_len) { - memcpy(wpsie + wpsielen, pwdinfo->device_name, - pwdinfo->device_name_len); - wpsielen += pwdinfo->device_name_len; - } - - /* Config Method */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_CONF_METHOD); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0002); - wpsielen += 2; - - /* Value: */ - *(u16*) (wpsie + wpsielen) = - cpu_to_be16(pwdinfo->supported_wps_cm); - wpsielen += 2; - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, - wpsielen, (unsigned char *)wpsie, - &pattrib->pktlen); - - p2pielen = build_probe_resp_p2p_ie23a(pwdinfo, pframe); - pframe += p2pielen; - pattrib->pktlen += p2pielen; - } - -#ifdef CONFIG_8723AU_P2P - if (pwdinfo->wfd_info->wfd_enable) { - wfdielen = build_probe_resp_wfd_ie(pwdinfo, pframe, 0); - pframe += wfdielen; - pattrib->pktlen += wfdielen; - } else if (pmlmepriv->wfd_probe_resp_ie && - pmlmepriv->wfd_probe_resp_ie_len > 0) { - /* WFD IE */ - memcpy(pframe, pmlmepriv->wfd_probe_resp_ie, - pmlmepriv->wfd_probe_resp_ie_len); - pattrib->pktlen += pmlmepriv->wfd_probe_resp_ie_len; - pframe += pmlmepriv->wfd_probe_resp_ie_len; - } -#endif /* CONFIG_8723AU_P2P */ - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe23a(padapter, pmgntframe); - - return; -} - -static int _issue23a_probereq_p2p(struct rtw_adapter *padapter, u8 *da, - int wait_ack) -{ - int ret = _FAIL; - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; - unsigned char *mac; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - u8 wpsie[255] = {0x00}, p2pie[255] = {0x00}; - u16 wpsielen = 0, p2pielen = 0; -#ifdef CONFIG_8723AU_P2P - u32 wfdielen = 0; -#endif /* CONFIG_8723AU_P2P */ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) - goto exit; - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib23a(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - mac = myid(&padapter->eeprompriv); - - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; - - if (da) { - ether_addr_copy(pwlanhdr->addr1, da); - ether_addr_copy(pwlanhdr->addr3, da); - } else { - if ((pwdinfo->p2p_info.scan_op_ch_only) || - (pwdinfo->rx_invitereq_info.scan_op_ch_only)) { - /* This two flags will be set when this is - only the P2P client mode. */ - ether_addr_copy(pwlanhdr->addr1, - pwdinfo->p2p_peer_interface_addr); - ether_addr_copy(pwlanhdr->addr3, - pwdinfo->p2p_peer_interface_addr); - } else { - /* broadcast probe request frame */ - ether_addr_copy(pwlanhdr->addr1, bc_addr); - ether_addr_copy(pwlanhdr->addr3, bc_addr); - } - } - ether_addr_copy(pwlanhdr->addr2, mac); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_PROBEREQ); - - pframe += sizeof (struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof (struct ieee80211_hdr_3addr); - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ)) { - pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID, - pwdinfo->tx_prov_disc_info.ssid.ssid_len, - pwdinfo->tx_prov_disc_info.ssid.ssid, - &pattrib->pktlen); - } else { - pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID, - P2P_WILDCARD_SSID_LEN, - pwdinfo->p2p_wildcard_ssid, - &pattrib->pktlen); - } - /* Use the OFDM rate in the P2P probe request frame. - (6(B), 9(B), 12(B), 24(B), 36, 48, 54) */ - pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, 8, - pwdinfo->support_rate, &pattrib->pktlen); - - if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled) { - if (pmlmepriv->wps_probe_req_ie && - pmlmepriv->p2p_probe_req_ie) { - /* WPS IE */ - memcpy(pframe, pmlmepriv->wps_probe_req_ie, - pmlmepriv->wps_probe_req_ie_len); - pattrib->pktlen += pmlmepriv->wps_probe_req_ie_len; - pframe += pmlmepriv->wps_probe_req_ie_len; - - /* P2P IE */ - memcpy(pframe, pmlmepriv->p2p_probe_req_ie, - pmlmepriv->p2p_probe_req_ie_len); - pattrib->pktlen += pmlmepriv->p2p_probe_req_ie_len; - pframe += pmlmepriv->p2p_probe_req_ie_len; - } - } else { - - /* WPS IE */ - /* Noted by Albert 20110221 */ - /* According to the WPS specification, all the WPS - attribute is presented by Big Endian. */ - - wpsielen = 0; - /* WPS OUI */ - *(u32*) (wpsie) = cpu_to_be32(WPSOUI); - wpsielen += 4; - - /* WPS version */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0001); - wpsielen += 2; - - /* Value: */ - wpsie[wpsielen++] = WPS_VERSION_1; /* Version 1.0 */ - - if (pmlmepriv->wps_probe_req_ie == NULL) { - /* UUID-E */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = - cpu_to_be16(WPS_ATTR_UUID_E); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0010); - wpsielen += 2; - - /* Value: */ - memcpy(wpsie + wpsielen, myid(&padapter->eeprompriv), - ETH_ALEN); - wpsielen += 0x10; - - /* Config Method */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = - cpu_to_be16(WPS_ATTR_CONF_METHOD); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0002); - wpsielen += 2; - - /* Value: */ - *(u16*) (wpsie + wpsielen) = - cpu_to_be16(pwdinfo->supported_wps_cm); - wpsielen += 2; - } - - /* Device Name */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = - cpu_to_be16(pwdinfo->device_name_len); - wpsielen += 2; - - /* Value: */ - memcpy(wpsie + wpsielen, pwdinfo->device_name, - pwdinfo->device_name_len); - wpsielen += pwdinfo->device_name_len; - - /* Primary Device Type */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = - cpu_to_be16(WPS_ATTR_PRIMARY_DEV_TYPE); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0008); - wpsielen += 2; - - /* Value: */ - /* Category ID */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_PDT_CID_RTK_WIDI); - wpsielen += 2; - - /* OUI */ - *(u32*) (wpsie + wpsielen) = cpu_to_be32(WPSOUI); - wpsielen += 4; - - /* Sub Category ID */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_PDT_SCID_RTK_DMP); - wpsielen += 2; - - /* Device Password ID */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_PWID); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0002); - wpsielen += 2; - - /* Value: */ - /* Registrar-specified */ - *(u16*) (wpsie + wpsielen) = - cpu_to_be16(WPS_DPID_REGISTRAR_SPEC); - wpsielen += 2; - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, - wpsielen, (unsigned char *)wpsie, - &pattrib->pktlen); - - /* P2P OUI */ - p2pielen = 0; - p2pie[p2pielen++] = 0x50; - p2pie[p2pielen++] = 0x6F; - p2pie[p2pielen++] = 0x9A; - p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20110221 */ - /* According to the P2P Specification, the probe request - frame should contain 5 P2P attributes */ - /* 1. P2P Capability */ - /* 2. P2P Device ID if this probe request wants to - find the specific P2P device */ - /* 3. Listen Channel */ - /* 4. Extended Listen Timing */ - /* 5. Operating Channel if this WiFi is working as - the group owner now */ - - /* P2P Capability */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); - p2pielen += 2; - - /* Value: */ - /* Device Capability Bitmap, 1 byte */ - p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; - - /* Group Capability Bitmap, 1 byte */ - if (pwdinfo->persistent_supported) - p2pie[p2pielen++] = P2P_GRPCAP_PERSISTENT_GROUP | - DMP_P2P_GRPCAP_SUPPORT; - else - p2pie[p2pielen++] = DMP_P2P_GRPCAP_SUPPORT; - - /* Listen Channel */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_LISTEN_CH; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0005); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Operating Class */ - p2pie[p2pielen++] = 0x51; /* Copy from SD7 */ - - /* Channel Number */ - /* listen channel */ - p2pie[p2pielen++] = pwdinfo->listen_channel; - - /* Extended Listen Timing */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_EX_LISTEN_TIMING; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0004); - p2pielen += 2; - - /* Value: */ - /* Availability Period */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); - p2pielen += 2; - - /* Availability Interval */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); - p2pielen += 2; - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { - /* Operating Channel (if this WiFi is working as - the group owner now) */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0005); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" - section. */ - p2pie[p2pielen++] = 0x04; - - /* Operating Class */ - p2pie[p2pielen++] = 0x51; /* Copy from SD7 */ - - /* Channel Number */ - /* operating channel number */ - p2pie[p2pielen++] = pwdinfo->operating_channel; - } - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, - p2pielen, (unsigned char *)p2pie, - &pattrib->pktlen); - - if (pmlmepriv->wps_probe_req_ie) { - /* WPS IE */ - memcpy(pframe, pmlmepriv->wps_probe_req_ie, - pmlmepriv->wps_probe_req_ie_len); - pattrib->pktlen += pmlmepriv->wps_probe_req_ie_len; - pframe += pmlmepriv->wps_probe_req_ie_len; - } - } - -#ifdef CONFIG_8723AU_P2P - if (pwdinfo->wfd_info->wfd_enable) { - wfdielen = build_probe_req_wfd_ie(pwdinfo, pframe); - pframe += wfdielen; - pattrib->pktlen += wfdielen; - } else if (pmlmepriv->wfd_probe_req_ie && - pmlmepriv->wfd_probe_req_ie_len>0) { - /* WFD IE */ - memcpy(pframe, pmlmepriv->wfd_probe_req_ie, - pmlmepriv->wfd_probe_req_ie_len); - pattrib->pktlen += pmlmepriv->wfd_probe_req_ie_len; - pframe += pmlmepriv->wfd_probe_req_ie_len; - } -#endif /* CONFIG_8723AU_P2P */ - - pattrib->last_txcmdsz = pattrib->pktlen; - - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("issuing probe_req, tx_len =%d\n", pattrib->last_txcmdsz)); - - if (wait_ack) { - ret = dump_mgntframe23a_and_wait_ack23a(padapter, pmgntframe); - } else { - dump_mgntframe23a(padapter, pmgntframe); - ret = _SUCCESS; - } - -exit: - return ret; -} - -inline void issue23a_probereq_p2p(struct rtw_adapter *adapter, u8 *da) -{ - _issue23a_probereq_p2p(adapter, da, false); -} - -int issue23a_probereq_p2p_ex(struct rtw_adapter *adapter, u8 *da, - int try_cnt, int wait_ms) -{ - int ret; - int i = 0; - unsigned long start = jiffies; - - do { - ret = _issue23a_probereq_p2p(adapter, da, - wait_ms > 0 ? true : false); - - i++; - - if (adapter->bDriverStopped || adapter->bSurpriseRemoved) - break; - - if (i < try_cnt && wait_ms > 0 && ret == _FAIL) - msleep(wait_ms); - - } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0))); + } else if ((frame_body[3] & BIT(3)) == BIT(3)) { + tid = (frame_body[3] >> 4) & 0x0F; - if (ret != _FAIL) { - ret = _SUCCESS; - goto exit; - } + preorder_ctrl = &psta->recvreorder_ctrl[tid]; + preorder_ctrl->enable = false; + preorder_ctrl->indicate_seq = 0xffff; + } - if (try_cnt && wait_ms) { - if (da) - DBG_8723A(FUNC_ADPT_FMT" to "MAC_FMT", ch:%u%s, %d/%d " - "in %u ms\n", FUNC_ADPT_ARG(adapter), - MAC_ARG(da), rtw_get_oper_ch23a(adapter), - ret == _SUCCESS?", acked":"", i, try_cnt, - jiffies_to_msecs(jiffies - start)); - else - DBG_8723A(FUNC_ADPT_FMT", ch:%u%s, %d/%d in %u ms\n", - FUNC_ADPT_ARG(adapter), - rtw_get_oper_ch23a(adapter), - ret == _SUCCESS?", acked":"", i, try_cnt, - jiffies_to_msecs(jiffies - start)); + DBG_8723A("%s(): DELBA: %x(%x)\n", __func__, + pmlmeinfo->agg_enable_bitmap, reason_code); + /* todo: how to notify the host while receiving + DELETE BA */ + break; + default: + break; + } } -exit: - return ret; + return _SUCCESS; } -#endif /* CONFIG_8723AU_P2P */ - static s32 rtw_action_public_decache(struct recv_frame *recv_frame, s32 token) { struct rtw_adapter *adapter = recv_frame->adapter; @@ -4543,15 +1995,6 @@ static unsigned int on_action_public23a_p2p(struct recv_frame *precv_frame) u8 *pframe = skb->data; u8 *frame_body; u8 dialogToken = 0; -#ifdef CONFIG_8723AU_P2P - struct rtw_adapter *padapter = precv_frame->adapter; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - uint len = skb->len; - u8 *p2p_ie; - u32 p2p_ielen; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - u8 result = P2P_STATUS_SUCCESS; -#endif /* CONFIG_8723AU_P2P */ frame_body = (unsigned char *) (pframe + sizeof(struct ieee80211_hdr_3addr)); @@ -4561,345 +2004,6 @@ static unsigned int on_action_public23a_p2p(struct recv_frame *precv_frame) if (rtw_action_public_decache(precv_frame, dialogToken) == _FAIL) return _FAIL; -#ifdef CONFIG_8723AU_P2P - del_timer_sync(&pwdinfo->reset_ch_sitesurvey); - if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled) { - rtw_cfg80211_rx_p2p_action_public(padapter, pframe, len); - } else { - /* Do nothing if the driver doesn't enable the P2P function. */ - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_IDLE)) - return _SUCCESS; - - len -= sizeof(struct ieee80211_hdr_3addr); - - switch (frame_body[ 6 ])/* OUI Subtype */ - { - case P2P_GO_NEGO_REQ: - DBG_8723A("[%s] Got GO Nego Req Frame\n", __func__); - memset(&pwdinfo->groupid_info, 0x00, sizeof(struct group_id_info)); - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_RX_PROVISION_DIS_REQ)) - { - rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); - } - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_FAIL)) - { - /* Commented by Albert 20110526 */ - /* In this case, this means the previous nego fail doesn't be reset yet. */ - del_timer_sync(&pwdinfo->restore_p2p_state_timer); - /* Restore the previous p2p state */ - rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); - DBG_8723A("[%s] Restore the previous p2p state to %d\n", __func__, rtw_p2p_state(pwdinfo)); - } - - /* Commented by Kurt 20110902 */ - /* Add if statement to avoid receiving duplicate prov disc req. such that pre_p2p_state would be covered. */ - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING)) - rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); - - /* Commented by Kurt 20120113 */ - /* Get peer_dev_addr here if peer doesn't issue prov_disc frame. */ - if (is_zero_ether_addr(pwdinfo->rx_prov_disc_info.peerDevAddr)) - ether_addr_copy(pwdinfo->rx_prov_disc_info.peerDevAddr, hdr->addr2); - - result = process_p2p_group_negotation_req23a(pwdinfo, frame_body, len); - issue_p2p_GO_response(padapter, hdr->addr2, - frame_body, len, result); - - /* Commented by Albert 20110718 */ - /* No matter negotiating or negotiation failure, the driver should set up the restore P2P state timer. */ - mod_timer(&pwdinfo->restore_p2p_state_timer, - jiffies + msecs_to_jiffies(5000)); - break; - - case P2P_GO_NEGO_RESP: - DBG_8723A("[%s] Got GO Nego Resp Frame\n", __func__); - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING)) - { - /* Commented by Albert 20110425 */ - /* The restore timer is enabled when issuing the nego request frame of rtw_p2p_connect function. */ - del_timer_sync(&pwdinfo->restore_p2p_state_timer); - pwdinfo->nego_req_info.benable = false; - result = process_p2p_group_negotation_resp23a(pwdinfo, frame_body, len); - issue_p2p_GO_confirm(pwdinfo->padapter, - hdr->addr2, - result); - if (result == P2P_STATUS_SUCCESS) { - if (rtw_p2p_role(pwdinfo) == - P2P_ROLE_CLIENT) { - pwdinfo->p2p_info.operation_ch[ 0 ] = pwdinfo->peer_operating_ch; - pwdinfo->p2p_info.scan_op_ch_only = 1; - mod_timer(&pwdinfo->reset_ch_sitesurvey2, jiffies + msecs_to_jiffies(P2P_RESET_SCAN_CH)); - } - } - - /* Reset the dialog token for group negotiation frames. */ - pwdinfo->negotiation_dialog_token = 1; - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_FAIL)) - { - mod_timer(&pwdinfo->restore_p2p_state_timer, jiffies + msecs_to_jiffies(5000)); - } - } else { - DBG_8723A("[%s] Skipped GO Nego Resp Frame (p2p_state != P2P_STATE_GONEGO_ING)\n", __func__); - } - - break; - - case P2P_GO_NEGO_CONF: - - DBG_8723A("[%s] Got GO Nego Confirm Frame\n", __func__); - result = process_p2p_group_negotation_confirm23a(pwdinfo, frame_body, len); - if (P2P_STATUS_SUCCESS == result) - { - if (rtw_p2p_role(pwdinfo) == P2P_ROLE_CLIENT) - { - pwdinfo->p2p_info.operation_ch[ 0 ] = pwdinfo->peer_operating_ch; - pwdinfo->p2p_info.scan_op_ch_only = 1; - mod_timer(&pwdinfo->reset_ch_sitesurvey2, jiffies + msecs_to_jiffies(P2P_RESET_SCAN_CH)); - } - } - break; - - case P2P_INVIT_REQ: - /* Added by Albert 2010/10/05 */ - /* Received the P2P Invite Request frame. */ - - DBG_8723A("[%s] Got invite request frame!\n", __func__); - if ((p2p_ie = rtw_get_p2p_ie23a(frame_body + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &p2p_ielen))) - { - /* Parse the necessary information from the P2P Invitation Request frame. */ - /* For example: The MAC address of sending this P2P Invitation Request frame. */ - u32 attr_contentlen = 0; - u8 status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE; - struct group_id_info group_id; - u8 invitation_flag = 0; - - rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_INVITATION_FLAGS, &invitation_flag, &attr_contentlen); - if (attr_contentlen) - { - - rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_BSSID, pwdinfo->p2p_peer_interface_addr, &attr_contentlen); - /* Commented by Albert 20120510 */ - /* Copy to the pwdinfo->p2p_peer_interface_addr. */ - /* So that the WFD UI (or Sigma) can get the peer interface address by using the following command. */ - /* #> iwpriv wlan0 p2p_get peer_ifa */ - /* After having the peer interface address, the sigma can find the correct conf file for wpa_supplicant. */ - - if (attr_contentlen) - { - DBG_8723A("[%s] GO's BSSID = %.2X %.2X %.2X %.2X %.2X %.2X\n", __func__, - pwdinfo->p2p_peer_interface_addr[0], pwdinfo->p2p_peer_interface_addr[1], - pwdinfo->p2p_peer_interface_addr[2], pwdinfo->p2p_peer_interface_addr[3], - pwdinfo->p2p_peer_interface_addr[4], pwdinfo->p2p_peer_interface_addr[5]); - } - - if (invitation_flag & P2P_INVITATION_FLAGS_PERSISTENT) - { - /* Re-invoke the persistent group. */ - - memset(&group_id, 0x00, sizeof(struct group_id_info)); - rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, (u8*) &group_id, &attr_contentlen); - if (attr_contentlen) { - if (ether_addr_equal(group_id.go_device_addr, myid(&padapter->eeprompriv))) { - /* The p2p device sending this p2p invitation request wants this Wi-Fi device to be the persistent GO. */ - rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_GO); - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - status_code = P2P_STATUS_SUCCESS; - } - else - { - /* The p2p device sending this p2p invitation request wants to be the persistent GO. */ - if (is_matched_in_profilelist(pwdinfo->p2p_peer_interface_addr, &pwdinfo->profileinfo[ 0 ])) - { - u8 operatingch_info[5] = { 0x00 }; - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen)) - { - if (rtw_ch_set_search_ch23a(padapter->mlmeextpriv.channel_set, (u32)operatingch_info[4])) - { - /* The operating channel is acceptable for this device. */ - pwdinfo->rx_invitereq_info.operation_ch[0]= operatingch_info[4]; - pwdinfo->rx_invitereq_info.scan_op_ch_only = 1; - mod_timer(&pwdinfo->reset_ch_sitesurvey, jiffies + msecs_to_jiffies(P2P_RESET_SCAN_CH)); - rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_MATCH); - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - status_code = P2P_STATUS_SUCCESS; - } - else - { - /* The operating channel isn't supported by this device. */ - rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_DISMATCH); - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - status_code = P2P_STATUS_FAIL_NO_COMMON_CH; - mod_timer(&pwdinfo->restore_p2p_state_timer, jiffies + msecs_to_jiffies(3000)); - } - } - else { - /* Commented by Albert 20121130 */ - /* Intel will use the different P2P IE to store the operating channel information */ - /* Workaround for Intel WiDi 3.5 */ - rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_MATCH); - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - status_code = P2P_STATUS_SUCCESS; - } - } - else - { - rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_DISMATCH); - - status_code = P2P_STATUS_FAIL_UNKNOWN_P2PGROUP; - } - } - } - else - { - DBG_8723A("[%s] P2P Group ID Attribute NOT FOUND!\n", __func__); - status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE; - } - } - else - { - /* Received the invitation to join a P2P group. */ - - memset(&group_id, 0x00, sizeof(struct group_id_info)); - rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, (u8*) &group_id, &attr_contentlen); - if (attr_contentlen) - { - if (ether_addr_equal(group_id.go_device_addr, myid(&padapter->eeprompriv))) { - /* In this case, the GO can't be myself. */ - rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_DISMATCH); - status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE; - } - else - { - /* The p2p device sending this p2p invitation request wants to join an existing P2P group */ - /* Commented by Albert 2012/06/28 */ - /* In this case, this Wi-Fi device should use the iwpriv command to get the peer device address. */ - /* The peer device address should be the destination address for the provisioning discovery request. */ - /* Then, this Wi-Fi device should use the iwpriv command to get the peer interface address. */ - /* The peer interface address should be the address for WPS mac address */ - ether_addr_copy(pwdinfo->p2p_peer_device_addr, group_id.go_device_addr); - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_JOIN); - status_code = P2P_STATUS_SUCCESS; - } - } - else - { - DBG_8723A("[%s] P2P Group ID Attribute NOT FOUND!\n", __func__); - status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE; - } - } - } - else - { - DBG_8723A("[%s] P2P Invitation Flags Attribute NOT FOUND!\n", __func__); - status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE; - } - - DBG_8723A("[%s] status_code = %d\n", __func__, status_code); - - pwdinfo->inviteresp_info.token = frame_body[ 7 ]; - issue_p2p_invitation_response23a(padapter, hdr->addr2, pwdinfo->inviteresp_info.token, status_code); - } - break; - - case P2P_INVIT_RESP: - { - u8 attr_content = 0x00; - u32 attr_contentlen = 0; - - DBG_8723A("[%s] Got invite response frame!\n", __func__); - del_timer_sync(&pwdinfo->restore_p2p_state_timer); - if ((p2p_ie = rtw_get_p2p_ie23a(frame_body + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &p2p_ielen))) - { - rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, &attr_content, &attr_contentlen); - - if (attr_contentlen == 1) - { - DBG_8723A("[%s] Status = %d\n", __func__, attr_content); - pwdinfo->invitereq_info.benable = false; - - if (attr_content == P2P_STATUS_SUCCESS) - { - if (ether_addr_equal(pwdinfo->invitereq_info.go_bssid, myid(&padapter->eeprompriv))) { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - } - else - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - } - rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_OK); - } - else - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_FAIL); - } - } - else - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_FAIL); - } - } - else - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_FAIL); - } - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_FAIL)) { - mod_timer(&pwdinfo->restore_p2p_state_timer, jiffies + msecs_to_jiffies(5000)); - } - break; - } - case P2P_DEVDISC_REQ: - - process_p2p_devdisc_req23a(pwdinfo, pframe, len); - - break; - - case P2P_DEVDISC_RESP: - - process_p2p_devdisc_resp23a(pwdinfo, pframe, len); - - break; - - case P2P_PROVISION_DISC_REQ: - DBG_8723A("[%s] Got Provisioning Discovery Request Frame\n", __func__); - process_p2p_provdisc_req23a(pwdinfo, pframe, len); - ether_addr_copy(pwdinfo->rx_prov_disc_info.peerDevAddr, hdr->addr2); - - /* 20110902 Kurt */ - /* Add the following statement to avoid receiving duplicate prov disc req. such that pre_p2p_state would be covered. */ - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_RX_PROVISION_DIS_REQ)) - rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); - - rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_PROVISION_DIS_REQ); - mod_timer(&pwdinfo->restore_p2p_state_timer, - jiffies + msecs_to_jiffies(P2P_PROVISION_TIMEOUT)); - break; - - case P2P_PROVISION_DISC_RESP: - /* Commented by Albert 20110707 */ - /* Should we check the pwdinfo->tx_prov_disc_info.bsent flag here?? */ - DBG_8723A("[%s] Got Provisioning Discovery Response Frame\n", __func__); - /* Commented by Albert 20110426 */ - /* The restore timer is enabled when issuing the provisioing request frame in rtw_p2p_prov_disc function. */ - del_timer_sync(&pwdinfo->restore_p2p_state_timer); - rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_PROVISION_DIS_RSP); - process_p2p_provdisc_resp23a(pwdinfo, pframe); - mod_timer(&pwdinfo->restore_p2p_state_timer, - jiffies + msecs_to_jiffies(P2P_PROVISION_TIMEOUT)); - break; - - } - } -#endif /* CONFIG_8723AU_P2P */ - return _SUCCESS; } @@ -4992,60 +2096,6 @@ unsigned int OnAction23a_wmm(struct rtw_adapter *padapter, unsigned int OnAction23a_p2p(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { -#ifdef CONFIG_8723AU_P2P - u8 *frame_body; - u8 category, OUI_Subtype, dialogToken = 0; - struct sk_buff *skb = precv_frame->pkt; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - u8 *pframe = skb->data; - uint len = skb->len; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - - DBG_8723A("%s\n", __func__); - - /* check RA matches or not */ - if (!ether_addr_equal(myid(&padapter->eeprompriv), hdr->addr1)) - return _SUCCESS; - - frame_body = (unsigned char *) - (pframe + sizeof(struct ieee80211_hdr_3addr)); - - category = frame_body[0]; - if (category != WLAN_CATEGORY_VENDOR_SPECIFIC) - return _SUCCESS; - - if (cpu_to_be32(*((u32*) (frame_body + 1))) != P2POUI) - return _SUCCESS; - - if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled) { - rtw_cfg80211_rx_action_p2p(padapter, pframe, len); - return _SUCCESS; - } else { - len -= sizeof(struct ieee80211_hdr_3addr); - OUI_Subtype = frame_body[5]; - dialogToken = frame_body[6]; - - switch (OUI_Subtype) - { - case P2P_NOTICE_OF_ABSENCE: - break; - - case P2P_PRESENCE_REQUEST: - process_p2p_presence_req23a(pwdinfo, pframe, len); - break; - - case P2P_PRESENCE_RESPONSE: - break; - - case P2P_GO_DISC_REQUEST: - break; - - default: - break; - } - } -#endif /* CONFIG_8723AU_P2P */ - return _SUCCESS; } @@ -5275,9 +2325,6 @@ void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms) struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* CONFIG_8723AU_P2P */ u8 *wps_ie; u32 wps_ielen; u8 sr = 0; @@ -5319,119 +2366,7 @@ void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms) if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { /* DBG_8723A("ie len =%d\n", cur_network->IELength); */ -#ifdef CONFIG_8723AU_P2P - /* for P2P : Primary Device Type & Device Name */ - u32 insert_len = 0; - wps_ie = rtw_get_wps_ie23a(cur_network->IEs + _FIXED_IE_LENGTH_, - cur_network->IELength - - _FIXED_IE_LENGTH_, NULL, &wps_ielen); - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO) && wps_ie && - wps_ielen > 0) { - uint wps_offset, remainder_ielen; - u8 *premainder_ie, *pframe_wscie; - - wps_offset = (uint)(wps_ie - cur_network->IEs); - - premainder_ie = wps_ie + wps_ielen; - - remainder_ielen = cur_network->IELength - wps_offset - - wps_ielen; - - if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled) { - if (pmlmepriv->wps_beacon_ie && - pmlmepriv->wps_beacon_ie_len>0) { - memcpy(pframe, cur_network->IEs, - wps_offset); - pframe += wps_offset; - pattrib->pktlen += wps_offset; - - memcpy(pframe, pmlmepriv->wps_beacon_ie, - pmlmepriv->wps_beacon_ie_len); - pframe += pmlmepriv->wps_beacon_ie_len; - pattrib->pktlen += - pmlmepriv->wps_beacon_ie_len; - - /* copy remainder_ie to pframe */ - memcpy(pframe, premainder_ie, - remainder_ielen); - pframe += remainder_ielen; - pattrib->pktlen += remainder_ielen; - } else { - memcpy(pframe, cur_network->IEs, - cur_network->IELength); - pframe += cur_network->IELength; - pattrib->pktlen += - cur_network->IELength; - } - } else { - pframe_wscie = pframe + wps_offset; - memcpy(pframe, cur_network->IEs, - wps_offset + wps_ielen); - pframe += (wps_offset + wps_ielen); - pattrib->pktlen += (wps_offset + wps_ielen); - - /* now pframe is end of wsc ie, insert Primary - Device Type & Device Name */ - /* Primary Device Type */ - /* Type: */ - *(u16*) (pframe + insert_len) = - cpu_to_be16(WPS_ATTR_PRIMARY_DEV_TYPE); - insert_len += 2; - - /* Length: */ - *(u16*) (pframe + insert_len) = - cpu_to_be16(0x0008); - insert_len += 2; - - /* Value: */ - /* Category ID */ - *(u16*) (pframe + insert_len) = - cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); - insert_len += 2; - - /* OUI */ - *(u32*) (pframe + insert_len) = - cpu_to_be32(WPSOUI); - insert_len += 4; - - /* Sub Category ID */ - *(u16*) (pframe + insert_len) = - cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); - insert_len += 2; - - /* Device Name */ - /* Type: */ - *(u16*) (pframe + insert_len) = - cpu_to_be16(WPS_ATTR_DEVICE_NAME); - insert_len += 2; - - /* Length: */ - *(u16*) (pframe + insert_len) = - cpu_to_be16(pwdinfo->device_name_len); - insert_len += 2; - - /* Value: */ - memcpy(pframe + insert_len, - pwdinfo->device_name, - pwdinfo->device_name_len); - insert_len += pwdinfo->device_name_len; - - /* update wsc ie length */ - *(pframe_wscie+1) = (wps_ielen -2) + insert_len; - - /* pframe move to end */ - pframe+= insert_len; - pattrib->pktlen += insert_len; - - /* copy remainder_ie to pframe */ - memcpy(pframe, premainder_ie, remainder_ielen); - pframe += remainder_ielen; - pattrib->pktlen += remainder_ielen; - } - } else -#endif /* CONFIG_8723AU_P2P */ - memcpy(pframe, cur_network->IEs, cur_network->IELength); + memcpy(pframe, cur_network->IEs, cur_network->IELength); len_diff = update_hidden_ssid(pframe + _BEACON_IE_OFFSET_, cur_network->IELength - _BEACON_IE_OFFSET_, @@ -5455,36 +2390,6 @@ void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms) else _clr_fwstate_(pmlmepriv, WIFI_UNDER_WPS); -#ifdef CONFIG_8723AU_P2P - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { - u32 len; - if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled) { - len = pmlmepriv->p2p_beacon_ie_len; - if (pmlmepriv->p2p_beacon_ie && len > 0) - memcpy(pframe, - pmlmepriv->p2p_beacon_ie, len); - } else - len = build_beacon_p2p_ie23a(pwdinfo, pframe); - - pframe += len; - pattrib->pktlen += len; - - if (true == pwdinfo->wfd_info->wfd_enable) { - len = build_beacon_wfd_ie(pwdinfo, pframe); - } else { - len = 0; - if (pmlmepriv->wfd_beacon_ie && - pmlmepriv->wfd_beacon_ie_len>0) { - len = pmlmepriv->wfd_beacon_ie_len; - memcpy(pframe, - pmlmepriv->wfd_beacon_ie, len); - } - } - pframe += len; - pattrib->pktlen += len; - } -#endif /* CONFIG_8723AU_P2P */ - goto _issue_bcn; } @@ -5591,17 +2496,12 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, int ssid_ielen_diff; u8 buf[MAX_IE_SZ]; u8 *ies; -#endif -#if defined(CONFIG_8723AU_AP_MODE) || defined(CONFIG_8723AU_P2P) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; #endif struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; unsigned int rate_len; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* CONFIG_8723AU_P2P */ /* DBG_8723A("%s\n", __func__); */ @@ -5788,38 +2688,6 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, /* todo:HT for adhoc */ } -#ifdef CONFIG_8723AU_P2P - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO) && is_valid_p2p_probereq) { - u32 len; - if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled) { - /* if pwdinfo->role == P2P_ROLE_DEVICE will call - issue_probersp23a_p2p23a() */ - len = pmlmepriv->p2p_go_probe_resp_ie_len; - if (pmlmepriv->p2p_go_probe_resp_ie && len>0) - memcpy(pframe, pmlmepriv->p2p_go_probe_resp_ie, - len); - } else - len = build_probe_resp_p2p_ie23a(pwdinfo, pframe); - - pframe += len; - pattrib->pktlen += len; - - if (true == pwdinfo->wfd_info->wfd_enable) { - len = build_probe_resp_wfd_ie(pwdinfo, pframe, 0); - } else { - len = 0; - if (pmlmepriv->wfd_probe_resp_ie && - pmlmepriv->wfd_probe_resp_ie_len > 0) { - len = pmlmepriv->wfd_probe_resp_ie_len; - memcpy(pframe, pmlmepriv->wfd_probe_resp_ie, - len); - } - } - pframe += len; - pattrib->pktlen += len; - } -#endif /* CONFIG_8723AU_P2P */ - pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe23a(padapter, pmgntframe); @@ -6154,10 +3022,6 @@ void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status, struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; u8 *ie = pnetwork->IEs; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - u32 wfdielen = 0; -#endif /* CONFIG_8723AU_P2P */ DBG_8723A("%s\n", __func__); @@ -6282,15 +3146,6 @@ void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status, pattrib->pktlen += pmlmepriv->wps_assoc_resp_ie_len; } -#ifdef CONFIG_8723AU_P2P - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO) && - pwdinfo->wfd_info->wfd_enable) { - wfdielen = build_assoc_resp_wfd_ie(pwdinfo, pframe); - pframe += wfdielen; - pattrib->pktlen += wfdielen; - } -#endif /* CONFIG_8723AU_P2P */ - pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe23a(padapter, pmgntframe); @@ -6315,12 +3170,6 @@ void issue_assocreq23a(struct rtw_adapter *padapter) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; int bssrate_len = 0, sta_bssrate_len = 0; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - u8 p2pie[255] = { 0x00 }; - u16 p2pielen = 0; - u32 wfdielen = 0; -#endif /* CONFIG_8723AU_P2P */ if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) goto exit; @@ -6554,191 +3403,6 @@ void issue_assocreq23a(struct rtw_adapter *padapter) pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, 6, REALTEK_96B_IE23A, &pattrib->pktlen); -#ifdef CONFIG_8723AU_P2P - - if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled) { - if (pmlmepriv->p2p_assoc_req_ie && - pmlmepriv->p2p_assoc_req_ie_len>0) { - memcpy(pframe, pmlmepriv->p2p_assoc_req_ie, - pmlmepriv->p2p_assoc_req_ie_len); - pframe += pmlmepriv->p2p_assoc_req_ie_len; - pattrib->pktlen += pmlmepriv->p2p_assoc_req_ie_len; - } - } else { - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) && - !rtw_p2p_chk_state(pwdinfo, P2P_STATE_IDLE)) { - /* Should add the P2P IE in the association - request frame. */ - /* P2P OUI */ - - p2pielen = 0; - p2pie[p2pielen++] = 0x50; - p2pie[p2pielen++] = 0x6F; - p2pie[p2pielen++] = 0x9A; - p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20101109 */ - /* According to the P2P Specification, the - association request frame should contain - 3 P2P attributes */ - /* 1. P2P Capability */ - /* 2. Extended Listen Timing */ - /* 3. Device Info */ - /* Commented by Albert 20110516 */ - /* 4. P2P Interface */ - - /* P2P Capability */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); - p2pielen += 2; - - /* Value: */ - /* Device Capability Bitmap, 1 byte */ - p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; - - /* Group Capability Bitmap, 1 byte */ - if (pwdinfo->persistent_supported) - p2pie[p2pielen++] = - P2P_GRPCAP_PERSISTENT_GROUP | - DMP_P2P_GRPCAP_SUPPORT; - else - p2pie[p2pielen++] = DMP_P2P_GRPCAP_SUPPORT; - - /* Extended Listen Timing */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_EX_LISTEN_TIMING; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0004); - p2pielen += 2; - - /* Value: */ - /* Availability Period */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); - p2pielen += 2; - - /* Availability Interval */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); - p2pielen += 2; - - /* Device Info */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO; - - /* Length: */ - /* 21 -> P2P Device Address (6bytes) + Config - Methods (2bytes) + Primary Device - Type (8bytes) */ - /* + NumofSecondDevType (1byte) + WPS Device - Name ID field (2bytes) + WPS Device Name - Len field (2bytes) */ - *(u16*) (p2pie + p2pielen) = - cpu_to_le16(21 + pwdinfo->device_name_len); - p2pielen += 2; - - /* Value: */ - /* P2P Device Address */ - memcpy(p2pie + p2pielen, - myid(&padapter->eeprompriv), ETH_ALEN); - p2pielen += ETH_ALEN; - - /* Config Method */ - /* This field should be big endian. - Noted by P2P specification. */ - if ((pwdinfo->ui_got_wps_info == - P2P_GOT_WPSINFO_PEER_DISPLAY_PIN) || - (pwdinfo->ui_got_wps_info == - P2P_GOT_WPSINFO_SELF_DISPLAY_PIN)) - *(u16*) (p2pie + p2pielen) = - cpu_to_be16(WPS_CONFIG_METHOD_DISPLAY); - else - *(u16*) (p2pie + p2pielen) = - cpu_to_be16(WPS_CONFIG_METHOD_PBC); - - p2pielen += 2; - - /* Primary Device Type */ - /* Category ID */ - *(u16*) (p2pie + p2pielen) = - cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); - p2pielen += 2; - - /* OUI */ - *(u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI); - p2pielen += 4; - - /* Sub Category ID */ - *(u16*) (p2pie + p2pielen) = - cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); - p2pielen += 2; - - /* Number of Secondary Device Types */ - /* No Secondary Device Type List */ - p2pie[p2pielen++] = 0x00; - - /* Device Name */ - /* Type: */ - *(u16*) (p2pie + p2pielen) = - cpu_to_be16(WPS_ATTR_DEVICE_NAME); - p2pielen += 2; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = - cpu_to_be16(pwdinfo->device_name_len); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, pwdinfo->device_name, - pwdinfo->device_name_len); - p2pielen += pwdinfo->device_name_len; - - /* P2P Interface */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_INTERFACE; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x000D); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, pwdinfo->device_addr, - ETH_ALEN); /* P2P Device Address */ - p2pielen += ETH_ALEN; - - /* P2P Interface Address Count */ - p2pie[p2pielen++] = 1; - - memcpy(p2pie + p2pielen, pwdinfo->device_addr, - ETH_ALEN); /* P2P Interface Address List */ - p2pielen += ETH_ALEN; - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, - p2pielen, (unsigned char *)p2pie, - &pattrib->pktlen); - - /* wfdielen = build_assoc_req_wfd_ie(pwdinfo, pframe);*/ - /* pframe += wfdielen; */ - /* pattrib->pktlen += wfdielen; */ - } - } - - if (true == pwdinfo->wfd_info->wfd_enable) { - wfdielen = build_assoc_req_wfd_ie(pwdinfo, pframe); - pframe += wfdielen; - pattrib->pktlen += wfdielen; - } else if (pmlmepriv->wfd_assoc_req_ie != NULL && - pmlmepriv->wfd_assoc_req_ie_len > 0) { - /* WFD IE */ - memcpy(pframe, pmlmepriv->wfd_assoc_req_ie, - pmlmepriv->wfd_assoc_req_ie_len); - pattrib->pktlen += pmlmepriv->wfd_assoc_req_ie_len; - pframe += pmlmepriv->wfd_assoc_req_ie_len; - } -#endif /* CONFIG_8723AU_P2P */ - pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe23a(padapter, pmgntframe); @@ -7023,20 +3687,9 @@ static int _issue_deauth23a(struct rtw_adapter *padapter, unsigned char *da, struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; int ret = _FAIL; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* CONFIG_8723AU_P2P */ /* DBG_8723A("%s to "MAC_FMT"\n", __func__, MAC_ARG(da)); */ -#ifdef CONFIG_8723AU_P2P - if (!(rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) && - (pwdinfo->rx_invitereq_info.scan_op_ch_only)) { - mod_timer(&pwdinfo->reset_ch_sitesurvey, - jiffies + msecs_to_jiffies(10)); - } -#endif /* CONFIG_8723AU_P2P */ - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) goto exit; @@ -7631,34 +4284,14 @@ void site_survey23a(struct rtw_adapter *padapter) enum rt_scan_type ScanType = SCAN_PASSIVE; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; + struct rtw_ieee80211_channel *ch; - if ((pwdinfo->rx_invitereq_info.scan_op_ch_only) || - (pwdinfo->p2p_info.scan_op_ch_only)) { - if (pwdinfo->rx_invitereq_info.scan_op_ch_only) - survey_channel = pwdinfo->rx_invitereq_info.operation_ch[pmlmeext->sitesurvey_res.channel_idx]; - else - survey_channel = pwdinfo->p2p_info.operation_ch[pmlmeext->sitesurvey_res.channel_idx]; - ScanType = SCAN_ACTIVE; - } else if (rtw_p2p_findphase_ex_is_social(pwdinfo)) { - /* The driver is in the find phase, it should go through the social channel. */ - int ch_set_idx; - survey_channel = pwdinfo->social_chan[pmlmeext->sitesurvey_res.channel_idx]; - ch_set_idx = rtw_ch_set_search_ch23a(pmlmeext->channel_set, survey_channel); - if (ch_set_idx >= 0) - ScanType = pmlmeext->channel_set[ch_set_idx].ScanType; - else - ScanType = SCAN_ACTIVE; - } else -#endif /* CONFIG_8723AU_P2P */ - { - struct rtw_ieee80211_channel *ch; - if (pmlmeext->sitesurvey_res.channel_idx < pmlmeext->sitesurvey_res.ch_num) { - ch = &pmlmeext->sitesurvey_res.ch[pmlmeext->sitesurvey_res.channel_idx]; - survey_channel = ch->hw_value; - ScanType = (ch->flags & IEEE80211_CHAN_NO_IR) ? SCAN_PASSIVE : SCAN_ACTIVE; -} + if (pmlmeext->sitesurvey_res.channel_idx < + pmlmeext->sitesurvey_res.ch_num) { + ch = &pmlmeext->sitesurvey_res.ch[pmlmeext->sitesurvey_res.channel_idx]; + survey_channel = ch->hw_value; + ScanType = (ch->flags & IEEE80211_CHAN_NO_IR) ? + SCAN_PASSIVE : SCAN_ACTIVE; } if (survey_channel != 0) { @@ -7672,112 +4305,59 @@ void site_survey23a(struct rtw_adapter *padapter) if (ScanType == SCAN_ACTIVE) /* obey the channel plan setting... */ { -#ifdef CONFIG_8723AU_P2P - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_SCAN) || - rtw_p2p_chk_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH) - ) - { - issue23a_probereq_p2p(padapter, NULL); - issue23a_probereq_p2p(padapter, NULL); - issue23a_probereq_p2p(padapter, NULL); - } - else -#endif /* CONFIG_8723AU_P2P */ - { - int i; - for (i = 0;isitesurvey_res.ssid[i].ssid_len) { - /* todo: to issue two probe req??? */ - issue_probereq23a(padapter, &pmlmeext->sitesurvey_res.ssid[i], NULL); - /* msleep(SURVEY_TO>>1); */ - issue_probereq23a(padapter, &pmlmeext->sitesurvey_res.ssid[i], NULL); - } - } - - if (pmlmeext->sitesurvey_res.scan_mode == SCAN_ACTIVE) { + int i; + for (i = 0;isitesurvey_res.ssid[i].ssid_len) { /* todo: to issue two probe req??? */ - issue_probereq23a(padapter, NULL, NULL); + issue_probereq23a(padapter, &pmlmeext->sitesurvey_res.ssid[i], NULL); /* msleep(SURVEY_TO>>1); */ - issue_probereq23a(padapter, NULL, NULL); + issue_probereq23a(padapter, &pmlmeext->sitesurvey_res.ssid[i], NULL); } } + + if (pmlmeext->sitesurvey_res.scan_mode == SCAN_ACTIVE) { + /* todo: to issue two probe req??? */ + issue_probereq23a(padapter, NULL, NULL); + /* msleep(SURVEY_TO>>1); */ + issue_probereq23a(padapter, NULL, NULL); + } } set_survey_timer(pmlmeext, pmlmeext->chan_scan_time); } else { - /* channel number is 0 or this channel is not valid. */ + pmlmeext->sitesurvey_res.state = SCAN_COMPLETE; + /* switch back to the original channel */ -#ifdef CONFIG_8723AU_P2P - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_SCAN) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH)) - { - if ((pwdinfo->rx_invitereq_info.scan_op_ch_only) || (pwdinfo->p2p_info.scan_op_ch_only)) - { - /* Set the find_phase_state_exchange_cnt to P2P_FINDPHASE_EX_CNT. */ - /* This will let the following flow to run the scanning end. */ - rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_MAX); - } - } - - if (rtw_p2p_findphase_ex_is_needed(pwdinfo)) - { - /* Set the P2P State to the listen state of find phase and set the current channel to the listen channel */ - set_channel_bwmode23a(padapter, pwdinfo->listen_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); - rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_LISTEN); - pmlmeext->sitesurvey_res.state = SCAN_DISABLE; - - /* restore RX GAIN */ - rtl8723a_set_initial_gain(padapter, 0xff); - /* turn on dynamic functions */ - rtl8723a_odm_support_ability_restore(padapter); - - mod_timer(&pwdinfo->find_phase_timer, jiffies + - msecs_to_jiffies(pwdinfo->listen_dwell * 100)); - } else -#endif /* CONFIG_8723AU_P2P */ - { -#ifdef CONFIG_8723AU_P2P - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_SCAN) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH)) - rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); - rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_NONE); -#endif /* CONFIG_8723AU_P2P */ - - pmlmeext->sitesurvey_res.state = SCAN_COMPLETE; - - /* switch back to the original channel */ - - set_channel_bwmode23a(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); - - /* flush 4-AC Queue after site_survey23a */ - /* val8 = 0; */ + set_channel_bwmode23a(padapter, pmlmeext->cur_channel, + pmlmeext->cur_ch_offset, + pmlmeext->cur_bwmode); - /* config MSR */ - Set_MSR23a(padapter, (pmlmeinfo->state & 0x3)); + /* flush 4-AC Queue after site_survey23a */ + /* val8 = 0; */ - /* restore RX GAIN */ - rtl8723a_set_initial_gain(padapter, 0xff); - /* turn on dynamic functions */ - rtl8723a_odm_support_ability_restore(padapter); - - if (is_client_associated_to_ap23a(padapter) == true) - { - issue_nulldata23a(padapter, NULL, 0, 3, 500); + /* config MSR */ + Set_MSR23a(padapter, (pmlmeinfo->state & 0x3)); - } + /* restore RX GAIN */ + rtl8723a_set_initial_gain(padapter, 0xff); + /* turn on dynamic functions */ + rtl8723a_odm_support_ability_restore(padapter); - rtl8723a_mlme_sitesurvey(padapter, 0); + if (is_client_associated_to_ap23a(padapter) == true) + issue_nulldata23a(padapter, NULL, 0, 3, 500); - report_surveydone_event23a(padapter); + rtl8723a_mlme_sitesurvey(padapter, 0); - pmlmeext->chan_scan_time = SURVEY_TO; - pmlmeext->sitesurvey_res.state = SCAN_DISABLE; + report_surveydone_event23a(padapter); - issue_action_BSSCoexistPacket(padapter); - issue_action_BSSCoexistPacket(padapter); - issue_action_BSSCoexistPacket(padapter); + pmlmeext->chan_scan_time = SURVEY_TO; + pmlmeext->sitesurvey_res.state = SCAN_DISABLE; - } + issue_action_BSSCoexistPacket(padapter); + issue_action_BSSCoexistPacket(padapter); + issue_action_BSSCoexistPacket(padapter); } return; @@ -8915,9 +5495,6 @@ void linked_status_chk23a(struct rtw_adapter *padapter) if ((psta = rtw_get_stainfo23a(pstapriv, pmlmeinfo->network.MacAddress)) != NULL) { bool is_p2p_enable = false; -#ifdef CONFIG_8723AU_P2P - is_p2p_enable = !rtw_p2p_chk_state(&padapter->wdinfo, P2P_STATE_NONE); -#endif if (chk_ap_is_alive(padapter, psta) == false) rx_chk = _FAIL; @@ -9031,32 +5608,17 @@ static void survey_timer_hdl(unsigned long data) struct sitesurvey_parm *psurveyPara; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* issue rtw_sitesurvey_cmd23a */ if (pmlmeext->sitesurvey_res.state > SCAN_START) { if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) pmlmeext->sitesurvey_res.channel_idx++; - if (pmlmeext->scan_abort == true) - { -#ifdef CONFIG_8723AU_P2P - if (!rtw_p2p_chk_state(&padapter->wdinfo, P2P_STATE_NONE)) - { - rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_MAX); - pmlmeext->sitesurvey_res.channel_idx = 3; - DBG_8723A("%s idx:%d, cnt:%u\n", __func__, - pmlmeext->sitesurvey_res.channel_idx, - pwdinfo->find_phase_state_exchange_cnt); - } else - #endif - { - pmlmeext->sitesurvey_res.channel_idx = pmlmeext->sitesurvey_res.ch_num; - DBG_8723A("%s idx:%d\n", __func__, - pmlmeext->sitesurvey_res.channel_idx); - } + if (pmlmeext->scan_abort == true) { + pmlmeext->sitesurvey_res.channel_idx = + pmlmeext->sitesurvey_res.ch_num; + DBG_8723A("%s idx:%d\n", __func__, + pmlmeext->sitesurvey_res.channel_idx); pmlmeext->scan_abort = false;/* reset */ } diff --git a/drivers/staging/rtl8723au/core/rtw_p2p.c b/drivers/staging/rtl8723au/core/rtw_p2p.c deleted file mode 100644 index 49c09089fd24..000000000000 --- a/drivers/staging/rtl8723au/core/rtw_p2p.c +++ /dev/null @@ -1,4016 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek 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. - * - ******************************************************************************/ -#define _RTW_P2P_C_ - -#include -#include -#include -#include - -#ifdef CONFIG_8723AU_P2P - -static int rtw_p2p_is_channel_list_ok(u8 desired_ch, u8* ch_list, u8 ch_cnt) -{ - int found = 0, i = 0; - - for (i = 0; i < ch_cnt; i++) - { - if (ch_list[ i ] == desired_ch) - { - found = 1; - break; - } - } - return found; -} - -static int is_any_client_associated(struct rtw_adapter *padapter) -{ - return padapter->stapriv.asoc_list_cnt ? true : false; -} - -static u32 go_add_group_info_attr(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - struct list_head *phead, *plist; - u32 len = 0; - u16 attr_len = 0; - u8 tmplen, *pdata_attr, *pstart, *pcur; - struct sta_info *psta; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct sta_priv *pstapriv = &padapter->stapriv; - - DBG_8723A("%s\n", __func__); - - pdata_attr = kzalloc(MAX_P2P_IE_LEN, GFP_ATOMIC); - - pstart = pdata_attr; - pcur = pdata_attr; - - spin_lock_bh(&pstapriv->asoc_list_lock); - phead = &pstapriv->asoc_list; - - list_for_each(plist, phead) { - psta = container_of(plist, struct sta_info, asoc_list); - - if (psta->is_p2p_device) - { - tmplen = 0; - - pcur++; - - /* P2P device address */ - memcpy(pcur, psta->dev_addr, ETH_ALEN); - pcur += ETH_ALEN; - - /* P2P interface address */ - memcpy(pcur, psta->hwaddr, ETH_ALEN); - pcur += ETH_ALEN; - - *pcur = psta->dev_cap; - pcur++; - - /* u16*)(pcur) = cpu_to_be16(psta->config_methods); */ - put_unaligned_be16(psta->config_methods, pcur); - pcur += 2; - - memcpy(pcur, psta->primary_dev_type, 8); - pcur += 8; - - *pcur = psta->num_of_secdev_type; - pcur++; - - memcpy(pcur, psta->secdev_types_list, psta->num_of_secdev_type*8); - pcur += psta->num_of_secdev_type*8; - - if (psta->dev_name_len>0) - { - /* u16*)(pcur) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); */ - put_unaligned_be16(WPS_ATTR_DEVICE_NAME, pcur); - pcur += 2; - - /* u16*)(pcur) = cpu_to_be16(psta->dev_name_len); */ - put_unaligned_be16(psta->dev_name_len, pcur); - pcur += 2; - - memcpy(pcur, psta->dev_name, psta->dev_name_len); - pcur += psta->dev_name_len; - } - - tmplen = (u8)(pcur-pstart); - - *pstart = (tmplen-1); - - attr_len += tmplen; - - /* pstart += tmplen; */ - pstart = pcur; - - } - - } - spin_unlock_bh(&pstapriv->asoc_list_lock); - - if (attr_len>0) - { - len = rtw_set_p2p_attr_content23a(pbuf, P2P_ATTR_GROUP_INFO, attr_len, pdata_attr); - } - - kfree(pdata_attr); - - return len; -} - -static void issue_group_disc_req(struct wifidirect_info *pwdinfo, u8 *da) -{ - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - unsigned char category = WLAN_CATEGORY_VENDOR_SPECIFIC;/* P2P action frame */ - u32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_GO_DISC_REQUEST; - u8 dialogToken = 0; - - DBG_8723A("[%s]\n", __func__); - - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) - { - return; - } - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib23a(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; - - memcpy(pwlanhdr->addr1, da, ETH_ALEN); - memcpy(pwlanhdr->addr2, pwdinfo->interface_addr, ETH_ALEN); - memcpy(pwlanhdr->addr3, pwdinfo->interface_addr, ETH_ALEN); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_ACTION); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - /* Build P2P action frame header */ - pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *)&p2poui, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &dialogToken, &pattrib->pktlen); - - /* there is no IE in this P2P action frame */ - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe23a(padapter, pmgntframe); -} - -static void issue_p2p_devdisc_resp(struct wifidirect_info *pwdinfo, u8 *da, u8 status, u8 dialogToken) -{ - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - unsigned char category = WLAN_CATEGORY_PUBLIC; - u8 action = P2P_PUB_ACTION_ACTION; - u32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_DEVDISC_RESP; - u8 p2pie[8] = { 0x00 }; - u32 p2pielen = 0; - - DBG_8723A("[%s]\n", __func__); - - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) - { - return; - } - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib23a(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; - - memcpy(pwlanhdr->addr1, da, ETH_ALEN); - memcpy(pwlanhdr->addr2, pwdinfo->device_addr, ETH_ALEN); - memcpy(pwlanhdr->addr3, pwdinfo->device_addr, ETH_ALEN); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_ACTION); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - /* Build P2P public action frame header */ - pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *) &p2poui, - &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &dialogToken, &pattrib->pktlen); - - /* Build P2P IE */ - /* P2P OUI */ - p2pielen = 0; - p2pie[ p2pielen++ ] = 0x50; - p2pie[ p2pielen++ ] = 0x6F; - p2pie[ p2pielen++ ] = 0x9A; - p2pie[ p2pielen++ ] = 0x09; /* WFA P2P v1.0 */ - - /* P2P_ATTR_STATUS */ - p2pielen += rtw_set_p2p_attr_content23a(&p2pie[p2pielen], P2P_ATTR_STATUS, 1, &status); - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, - p2pie, &pattrib->pktlen); - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe23a(padapter, pmgntframe); -} - -static void issue_p2p_provision_resp(struct wifidirect_info *pwdinfo, u8* raddr, u8* frame_body, u16 config_method) -{ - struct rtw_adapter *padapter = pwdinfo->padapter; - unsigned char category = WLAN_CATEGORY_PUBLIC; - u8 action = P2P_PUB_ACTION_ACTION; - u8 dialogToken = frame_body[7]; /* The Dialog Token of provisioning discovery request frame. */ - u32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_PROVISION_DISC_RESP; - u8 wpsie[ 100 ] = { 0x00 }; - u8 wpsielen = 0; -#ifdef CONFIG_8723AU_P2P - u32 wfdielen = 0; -#endif /* CONFIG_8723AU_P2P */ - - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) - return; - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib23a(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; - - memcpy(pwlanhdr->addr1, raddr, ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); - memcpy(pwlanhdr->addr3, myid(&padapter->eeprompriv), ETH_ALEN); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_ACTION); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *) &p2poui, - &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &dialogToken, &pattrib->pktlen); - - wpsielen = 0; - /* WPS OUI */ - /* u32*) (wpsie) = cpu_to_be32(WPSOUI); */ - put_unaligned_be32(WPSOUI, wpsie); - wpsielen += 4; - - /* Config Method */ - /* Type: */ - /* u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_CONF_METHOD); */ - put_unaligned_be16(WPS_ATTR_CONF_METHOD, wpsie + wpsielen); - wpsielen += 2; - - /* Length: */ - /* u16*) (wpsie + wpsielen) = cpu_to_be16(0x0002); */ - put_unaligned_be16(0x0002, wpsie + wpsielen); - wpsielen += 2; - - /* Value: */ - /* u16*) (wpsie + wpsielen) = cpu_to_be16(config_method); */ - put_unaligned_be16(config_method, wpsie + wpsielen); - wpsielen += 2; - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, wpsielen, - (unsigned char *) wpsie, &pattrib->pktlen); - -#ifdef CONFIG_8723AU_P2P - wfdielen = build_provdisc_resp_wfd_ie(pwdinfo, pframe); - pframe += wfdielen; - pattrib->pktlen += wfdielen; -#endif /* CONFIG_8723AU_P2P */ - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe23a(padapter, pmgntframe); - - return; -} - -static void issue_p2p_presence_resp(struct wifidirect_info *pwdinfo, u8 *da, u8 status, u8 dialogToken) -{ - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - unsigned char category = WLAN_CATEGORY_VENDOR_SPECIFIC;/* P2P action frame */ - u32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_PRESENCE_RESPONSE; - u8 p2pie[ MAX_P2P_IE_LEN] = { 0x00 }; - u8 noa_attr_content[32] = { 0x00 }; - u32 p2pielen = 0; - - DBG_8723A("[%s]\n", __func__); - - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) - { - return; - } - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib23a(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; - - memcpy(pwlanhdr->addr1, da, ETH_ALEN); - memcpy(pwlanhdr->addr2, pwdinfo->interface_addr, ETH_ALEN); - memcpy(pwlanhdr->addr3, pwdinfo->interface_addr, ETH_ALEN); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_ACTION); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - /* Build P2P action frame header */ - pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *) &p2poui, - &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &dialogToken, &pattrib->pktlen); - - /* Add P2P IE header */ - /* P2P OUI */ - p2pielen = 0; - p2pie[ p2pielen++ ] = 0x50; - p2pie[ p2pielen++ ] = 0x6F; - p2pie[ p2pielen++ ] = 0x9A; - p2pie[ p2pielen++ ] = 0x09; /* WFA P2P v1.0 */ - - /* Add Status attribute in P2P IE */ - p2pielen += rtw_set_p2p_attr_content23a(&p2pie[p2pielen], P2P_ATTR_STATUS, 1, &status); - - /* Add NoA attribute in P2P IE */ - noa_attr_content[0] = 0x1;/* index */ - noa_attr_content[1] = 0x0;/* CTWindow and OppPS Parameters */ - - /* todo: Notice of Absence Descriptor(s) */ - - p2pielen += rtw_set_p2p_attr_content23a(&p2pie[p2pielen], P2P_ATTR_NOA, 2, noa_attr_content); - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, - p2pie, &pattrib->pktlen); - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe23a(padapter, pmgntframe); -} - -u32 build_beacon_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u8 p2pie[ MAX_P2P_IE_LEN] = { 0x00 }; - u16 capability = 0; - u32 len = 0, p2pielen = 0; - - /* P2P OUI */ - p2pielen = 0; - p2pie[ p2pielen++ ] = 0x50; - p2pie[ p2pielen++ ] = 0x6F; - p2pie[ p2pielen++ ] = 0x9A; - p2pie[ p2pielen++ ] = 0x09; /* WFA P2P v1.0 */ - - /* According to the P2P Specification, the beacon frame should contain 3 P2P attributes */ - /* 1. P2P Capability */ - /* 2. P2P Device ID */ - /* 3. Notice of Absence (NOA) */ - - /* P2P Capability ATTR */ - /* Type: */ - /* Length: */ - /* Value: */ - /* Device Capability Bitmap, 1 byte */ - /* Be able to participate in additional P2P Groups and */ - /* support the P2P Invitation Procedure */ - /* Group Capability Bitmap, 1 byte */ - capability = P2P_DEVCAP_INVITATION_PROC|P2P_DEVCAP_CLIENT_DISCOVERABILITY; - capability |= ((P2P_GRPCAP_GO | P2P_GRPCAP_INTRABSS) << 8); - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_PROVISIONING_ING)) - capability |= (P2P_GRPCAP_GROUP_FORMATION<<8); - - capability = cpu_to_le16(capability); - - p2pielen += rtw_set_p2p_attr_content23a(&p2pie[p2pielen], P2P_ATTR_CAPABILITY, 2, (u8*)&capability); - - /* P2P Device ID ATTR */ - p2pielen += rtw_set_p2p_attr_content23a(&p2pie[p2pielen], P2P_ATTR_DEVICE_ID, ETH_ALEN, pwdinfo->device_addr); - - /* Notice of Absence ATTR */ - /* Type: */ - /* Length: */ - /* Value: */ - - /* go_add_noa_attr(pwdinfo); */ - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, p2pielen, - (unsigned char *) p2pie, &len); - - return len; -} - -#ifdef CONFIG_8723AU_P2P -u32 build_beacon_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 }; - u32 len = 0, wfdielen = 0; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wifi_display_info* pwfd_info = padapter->wdinfo.wfd_info; - - /* WFD OUI */ - wfdielen = 0; - wfdie[ wfdielen++ ] = 0x50; - wfdie[ wfdielen++ ] = 0x6F; - wfdie[ wfdielen++ ] = 0x9A; - wfdie[ wfdielen++ ] = 0x0A; /* WFA WFD v1.0 */ - - /* Commented by Albert 20110812 */ - /* According to the WFD Specification, the beacon frame should contain 4 WFD attributes */ - /* 1. WFD Device Information */ - /* 2. Associated BSSID */ - /* 3. Coupled Sink Information */ - - /* WFD Device Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value1: */ - /* WFD device information */ - - if (P2P_ROLE_GO == pwdinfo->role) - { - if (is_any_client_associated(pwdinfo->padapter)) - { - /* WFD primary sink + WiFi Direct mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_WSD, wfdie + wfdielen); - } - else - { - /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_SESSION_AVAIL | - WFD_DEVINFO_WSD, wfdie + wfdielen); - } - - } - else - { - /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_SESSION_AVAIL | - WFD_DEVINFO_WSD, wfdie + wfdielen); - } - - wfdielen += 2; - - /* Value2: */ - /* Session Management Control Port */ - /* Default TCP port for RTSP messages is 554 */ - put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen); - wfdielen += 2; - - /* Value3: */ - /* WFD Device Maximum Throughput */ - /* 300Mbps is the maximum throughput */ - put_unaligned_be16(300, wfdie + wfdielen); - wfdielen += 2; - - /* Associated BSSID ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Associated BSSID */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { - memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN); - } - else - { - memset(wfdie + wfdielen, 0x00, ETH_ALEN); - } - - wfdielen += ETH_ALEN; - - /* Coupled Sink Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0007, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Coupled Sink Status bitmap */ - /* Not coupled/available for Coupling */ - wfdie[ wfdielen++ ] = 0; - /* MAC Addr. */ - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, - (unsigned char *) wfdie, &len); - - return len; -} - -u32 build_probe_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 }; - u32 len = 0, wfdielen = 0; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wifi_display_info* pwfd_info = padapter->wdinfo.wfd_info; - - /* WFD OUI */ - wfdielen = 0; - wfdie[ wfdielen++ ] = 0x50; - wfdie[ wfdielen++ ] = 0x6F; - wfdie[ wfdielen++ ] = 0x9A; - wfdie[ wfdielen++ ] = 0x0A; /* WFA WFD v1.0 */ - - /* Commented by Albert 20110812 */ - /* According to the WFD Specification, the probe request frame should contain 4 WFD attributes */ - /* 1. WFD Device Information */ - /* 2. Associated BSSID */ - /* 3. Coupled Sink Information */ - - /* WFD Device Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value1: */ - /* WFD device information */ - - if (1 == pwdinfo->wfd_tdls_enable) - { - /* WFD primary sink + available for WFD session + WiFi TDLS mode + WSC (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_SESSION_AVAIL | - WFD_DEVINFO_WSD | - WFD_DEVINFO_PC_TDLS, wfdie + wfdielen); - } - else - { - /* WFD primary sink + available for WFD session + WiFi Direct mode + WSC (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_SESSION_AVAIL | - WFD_DEVINFO_WSD, wfdie + wfdielen); - } - - wfdielen += 2; - - /* Value2: */ - /* Session Management Control Port */ - /* Default TCP port for RTSP messages is 554 */ - put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen); - wfdielen += 2; - - /* Value3: */ - /* WFD Device Maximum Throughput */ - /* 300Mbps is the maximum throughput */ - put_unaligned_be16(300, wfdie + wfdielen); - wfdielen += 2; - - /* Associated BSSID ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Associated BSSID */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { - memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN); - } - else - { - memset(wfdie + wfdielen, 0x00, ETH_ALEN); - } - - wfdielen += ETH_ALEN; - - /* Coupled Sink Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0007, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Coupled Sink Status bitmap */ - /* Not coupled/available for Coupling */ - wfdie[ wfdielen++ ] = 0; - /* MAC Addr. */ - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, - (unsigned char *) wfdie, &len); - - return len; -} - -u32 build_probe_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 tunneled) -{ - u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 }; - u32 len = 0, wfdielen = 0; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wifi_display_info* pwfd_info = padapter->wdinfo.wfd_info; - - /* WFD OUI */ - wfdielen = 0; - wfdie[ wfdielen++ ] = 0x50; - wfdie[ wfdielen++ ] = 0x6F; - wfdie[ wfdielen++ ] = 0x9A; - wfdie[ wfdielen++ ] = 0x0A; /* WFA WFD v1.0 */ - - /* Commented by Albert 20110812 */ - /* According to the WFD Specification, the probe response frame should contain 4 WFD attributes */ - /* 1. WFD Device Information */ - /* 2. Associated BSSID */ - /* 3. Coupled Sink Information */ - /* 4. WFD Session Information */ - - /* WFD Device Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value1: */ - /* WFD device information */ - /* WFD primary sink + available for WFD session + WiFi Direct mode */ - - if (true == pwdinfo->session_available) - { - if (P2P_ROLE_GO == pwdinfo->role) - { - if (is_any_client_associated(pwdinfo->padapter)) - { - if (pwdinfo->wfd_tdls_enable) - { - /* TDLS mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | WFD_DEVINFO_WSD | WFD_DEVINFO_PC_TDLS | WFD_DEVINFO_HDCP_SUPPORT, wfdie + wfdielen); - } - else - { - /* WiFi Direct mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | WFD_DEVINFO_WSD | WFD_DEVINFO_HDCP_SUPPORT, wfdie + wfdielen); - } - } - else - { - if (pwdinfo->wfd_tdls_enable) - { - /* available for WFD session + TDLS mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD | WFD_DEVINFO_PC_TDLS | WFD_DEVINFO_HDCP_SUPPORT, wfdie + wfdielen); - } - else - { - /* available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD | WFD_DEVINFO_HDCP_SUPPORT, wfdie + wfdielen); - } - } - } - else - { - if (pwdinfo->wfd_tdls_enable) - { - /* available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_SESSION_AVAIL | - WFD_DEVINFO_WSD | - WFD_DEVINFO_PC_TDLS | - WFD_DEVINFO_HDCP_SUPPORT, - wfdie + wfdielen); - } - else - { - - /* available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_SESSION_AVAIL | - WFD_DEVINFO_WSD | - WFD_DEVINFO_HDCP_SUPPORT, - wfdie + wfdielen); - } - } - } - else - { - if (pwdinfo->wfd_tdls_enable) - { - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_WSD | - WFD_DEVINFO_PC_TDLS | - WFD_DEVINFO_HDCP_SUPPORT, - wfdie + wfdielen); - } - else - { - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_WSD | - WFD_DEVINFO_HDCP_SUPPORT, - wfdie + wfdielen); - } - - } - - wfdielen += 2; - - /* Value2: */ - /* Session Management Control Port */ - /* Default TCP port for RTSP messages is 554 */ - put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen); - wfdielen += 2; - - /* Value3: */ - /* WFD Device Maximum Throughput */ - /* 300Mbps is the maximum throughput */ - put_unaligned_be16(300, wfdie + wfdielen); - wfdielen += 2; - - /* Associated BSSID ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Associated BSSID */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { - memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN); - } - else - { - memset(wfdie + wfdielen, 0x00, ETH_ALEN); - } - - wfdielen += ETH_ALEN; - - /* Coupled Sink Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0007, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Coupled Sink Status bitmap */ - /* Not coupled/available for Coupling */ - wfdie[ wfdielen++ ] = 0; - /* MAC Addr. */ - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - { - /* WFD Session Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_SESSION_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0000, wfdie + wfdielen); - wfdielen += 2; - - /* Todo: to add the list of WFD device info descriptor in WFD group. */ - - } - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, - (unsigned char *) wfdie, &len); - - return len; -} - -u32 build_assoc_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 }; - u32 len = 0, wfdielen = 0; - struct rtw_adapter *padapter = NULL; - struct mlme_priv *pmlmepriv = NULL; - struct wifi_display_info *pwfd_info = NULL; - - /* WFD OUI */ - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_IDLE)) - { - return 0; - } - - padapter = pwdinfo->padapter; - pmlmepriv = &padapter->mlmepriv; - pwfd_info = padapter->wdinfo.wfd_info; - - wfdielen = 0; - wfdie[ wfdielen++ ] = 0x50; - wfdie[ wfdielen++ ] = 0x6F; - wfdie[ wfdielen++ ] = 0x9A; - wfdie[ wfdielen++ ] = 0x0A; /* WFA WFD v1.0 */ - - /* Commented by Albert 20110812 */ - /* According to the WFD Specification, the probe request frame should contain 4 WFD attributes */ - /* 1. WFD Device Information */ - /* 2. Associated BSSID */ - /* 3. Coupled Sink Information */ - - /* WFD Device Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value1: */ - /* WFD device information */ - /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_SESSION_AVAIL | - WFD_DEVINFO_WSD, wfdie + wfdielen); - wfdielen += 2; - - /* Value2: */ - /* Session Management Control Port */ - /* Default TCP port for RTSP messages is 554 */ - put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen); - wfdielen += 2; - - /* Value3: */ - /* WFD Device Maximum Throughput */ - /* 300Mbps is the maximum throughput */ - put_unaligned_be16(300, wfdie + wfdielen); - wfdielen += 2; - - /* Associated BSSID ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Associated BSSID */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { - memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN); - } - else - { - memset(wfdie + wfdielen, 0x00, ETH_ALEN); - } - - wfdielen += ETH_ALEN; - - /* Coupled Sink Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0007, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Coupled Sink Status bitmap */ - /* Not coupled/available for Coupling */ - wfdie[ wfdielen++ ] = 0; - /* MAC Addr. */ - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, - (unsigned char *) wfdie, &len); - - return len; -} - -u32 build_assoc_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 }; - u32 len = 0, wfdielen = 0; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wifi_display_info* pwfd_info = padapter->wdinfo.wfd_info; - - /* WFD OUI */ - wfdielen = 0; - wfdie[ wfdielen++ ] = 0x50; - wfdie[ wfdielen++ ] = 0x6F; - wfdie[ wfdielen++ ] = 0x9A; - wfdie[ wfdielen++ ] = 0x0A; /* WFA WFD v1.0 */ - - /* Commented by Albert 20110812 */ - /* According to the WFD Specification, the probe request frame should contain 4 WFD attributes */ - /* 1. WFD Device Information */ - /* 2. Associated BSSID */ - /* 3. Coupled Sink Information */ - - /* WFD Device Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value1: */ - /* WFD device information */ - /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_SESSION_AVAIL | - WFD_DEVINFO_WSD, wfdie + wfdielen); - wfdielen += 2; - - /* Value2: */ - /* Session Management Control Port */ - /* Default TCP port for RTSP messages is 554 */ - put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen); - wfdielen += 2; - - /* Value3: */ - /* WFD Device Maximum Throughput */ - /* 300Mbps is the maximum throughput */ - put_unaligned_be16(300, wfdie + wfdielen); - wfdielen += 2; - - /* Associated BSSID ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Associated BSSID */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { - memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN); - } - else - { - memset(wfdie + wfdielen, 0x00, ETH_ALEN); - } - - wfdielen += ETH_ALEN; - - /* Coupled Sink Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0007, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Coupled Sink Status bitmap */ - /* Not coupled/available for Coupling */ - wfdie[ wfdielen++ ] = 0; - /* MAC Addr. */ - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, - (unsigned char *) wfdie, &len); - - return len; -} - -u32 build_nego_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 }; - u32 len = 0, wfdielen = 0; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wifi_display_info* pwfd_info = padapter->wdinfo.wfd_info; - - /* WFD OUI */ - wfdielen = 0; - wfdie[ wfdielen++ ] = 0x50; - wfdie[ wfdielen++ ] = 0x6F; - wfdie[ wfdielen++ ] = 0x9A; - wfdie[ wfdielen++ ] = 0x0A; /* WFA WFD v1.0 */ - - /* Commented by Albert 20110825 */ - /* According to the WFD Specification, the negotiation request frame should contain 3 WFD attributes */ - /* 1. WFD Device Information */ - /* 2. Associated BSSID (Optional) */ - /* 3. Local IP Adress (Optional) */ - - /* WFD Device Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value1: */ - /* WFD device information */ - /* WFD primary sink + WiFi Direct mode + WSD (WFD Service Discovery) + WFD Session Available */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_WSD | WFD_DEVINFO_SESSION_AVAIL, - wfdie + wfdielen); - wfdielen += 2; - - /* Value2: */ - /* Session Management Control Port */ - /* Default TCP port for RTSP messages is 554 */ - put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen); - wfdielen += 2; - - /* Value3: */ - /* WFD Device Maximum Throughput */ - /* 300Mbps is the maximum throughput */ - put_unaligned_be16(300, wfdie + wfdielen); - wfdielen += 2; - - /* Associated BSSID ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Associated BSSID */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { - memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN); - } - else - { - memset(wfdie + wfdielen, 0x00, ETH_ALEN); - } - - wfdielen += ETH_ALEN; - - /* Coupled Sink Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0007, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Coupled Sink Status bitmap */ - /* Not coupled/available for Coupling */ - wfdie[ wfdielen++ ] = 0; - /* MAC Addr. */ - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, - (unsigned char *) wfdie, &len); - - return len; -} - -u32 build_nego_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 }; - u32 len = 0, wfdielen = 0; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wifi_display_info* pwfd_info = padapter->wdinfo.wfd_info; - - /* WFD OUI */ - wfdielen = 0; - wfdie[ wfdielen++ ] = 0x50; - wfdie[ wfdielen++ ] = 0x6F; - wfdie[ wfdielen++ ] = 0x9A; - wfdie[ wfdielen++ ] = 0x0A; /* WFA WFD v1.0 */ - - /* Commented by Albert 20110825 */ - /* According to the WFD Specification, the negotiation request frame should contain 3 WFD attributes */ - /* 1. WFD Device Information */ - /* 2. Associated BSSID (Optional) */ - /* 3. Local IP Adress (Optional) */ - - /* WFD Device Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value1: */ - /* WFD device information */ - /* WFD primary sink + WiFi Direct mode + WSD (WFD Service Discovery) + WFD Session Available */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_WSD | WFD_DEVINFO_SESSION_AVAIL, - wfdie + wfdielen); - wfdielen += 2; - - /* Value2: */ - /* Session Management Control Port */ - /* Default TCP port for RTSP messages is 554 */ - put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen); - wfdielen += 2; - - /* Value3: */ - /* WFD Device Maximum Throughput */ - /* 300Mbps is the maximum throughput */ - put_unaligned_be16(300, wfdie + wfdielen); - wfdielen += 2; - - /* Associated BSSID ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Associated BSSID */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { - memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN); - } - else - { - memset(wfdie + wfdielen, 0x00, ETH_ALEN); - } - - wfdielen += ETH_ALEN; - - /* Coupled Sink Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0007, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Coupled Sink Status bitmap */ - /* Not coupled/available for Coupling */ - wfdie[ wfdielen++ ] = 0; - /* MAC Addr. */ - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, - (unsigned char *) wfdie, &len); - - return len; -} - -u32 build_nego_confirm_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 }; - u32 len = 0, wfdielen = 0; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wifi_display_info* pwfd_info = padapter->wdinfo.wfd_info; - - /* WFD OUI */ - wfdielen = 0; - wfdie[ wfdielen++ ] = 0x50; - wfdie[ wfdielen++ ] = 0x6F; - wfdie[ wfdielen++ ] = 0x9A; - wfdie[ wfdielen++ ] = 0x0A; /* WFA WFD v1.0 */ - - /* Commented by Albert 20110825 */ - /* According to the WFD Specification, the negotiation request frame should contain 3 WFD attributes */ - /* 1. WFD Device Information */ - /* 2. Associated BSSID (Optional) */ - /* 3. Local IP Adress (Optional) */ - - /* WFD Device Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value1: */ - /* WFD device information */ - /* WFD primary sink + WiFi Direct mode + WSD (WFD Service Discovery) + WFD Session Available */ - put_unaligned_be16(pwfd_info->wfd_device_type | WFD_DEVINFO_WSD | - WFD_DEVINFO_SESSION_AVAIL, wfdie + wfdielen); - wfdielen += 2; - - /* Value2: */ - /* Session Management Control Port */ - /* Default TCP port for RTSP messages is 554 */ - put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen); - wfdielen += 2; - - /* Value3: */ - /* WFD Device Maximum Throughput */ - /* 300Mbps is the maximum throughput */ - put_unaligned_be16(300, wfdie + wfdielen); - wfdielen += 2; - - /* Associated BSSID ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Associated BSSID */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { - memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN); - } - else - { - memset(wfdie + wfdielen, 0x00, ETH_ALEN); - } - - wfdielen += ETH_ALEN; - - /* Coupled Sink Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0007, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Coupled Sink Status bitmap */ - /* Not coupled/available for Coupling */ - wfdie[ wfdielen++ ] = 0; - /* MAC Addr. */ - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, - (unsigned char *) wfdie, &len); - - return len; -} - -u32 build_invitation_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 }; - u32 len = 0, wfdielen = 0; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wifi_display_info* pwfd_info = padapter->wdinfo.wfd_info; - - /* WFD OUI */ - wfdielen = 0; - wfdie[ wfdielen++ ] = 0x50; - wfdie[ wfdielen++ ] = 0x6F; - wfdie[ wfdielen++ ] = 0x9A; - wfdie[ wfdielen++ ] = 0x0A; /* WFA WFD v1.0 */ - - /* Commented by Albert 20110825 */ - /* According to the WFD Specification, the provision discovery request frame should contain 3 WFD attributes */ - /* 1. WFD Device Information */ - /* 2. Associated BSSID (Optional) */ - /* 3. Local IP Adress (Optional) */ - - /* WFD Device Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value1: */ - /* WFD device information */ - /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD, - wfdie + wfdielen); - wfdielen += 2; - - /* Value2: */ - /* Session Management Control Port */ - /* Default TCP port for RTSP messages is 554 */ - put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen); - wfdielen += 2; - - /* Value3: */ - /* WFD Device Maximum Throughput */ - /* 300Mbps is the maximum throughput */ - put_unaligned_be16(300, wfdie + wfdielen); - wfdielen += 2; - - /* Associated BSSID ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Associated BSSID */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { - memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN); - } - else - { - memset(wfdie + wfdielen, 0x00, ETH_ALEN); - } - - wfdielen += ETH_ALEN; - - /* Coupled Sink Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0007, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Coupled Sink Status bitmap */ - /* Not coupled/available for Coupling */ - wfdie[ wfdielen++ ] = 0; - /* MAC Addr. */ - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - - if (P2P_ROLE_GO == pwdinfo->role) - { - /* WFD Session Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_SESSION_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0000, wfdie + wfdielen); - wfdielen += 2; - - /* Todo: to add the list of WFD device info descriptor in WFD group. */ - - } - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, - (unsigned char *) wfdie, &len); - - return len; -} - -u32 build_invitation_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 }; - u32 len = 0, wfdielen = 0; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wifi_display_info* pwfd_info = padapter->wdinfo.wfd_info; - - /* WFD OUI */ - wfdielen = 0; - wfdie[ wfdielen++ ] = 0x50; - wfdie[ wfdielen++ ] = 0x6F; - wfdie[ wfdielen++ ] = 0x9A; - wfdie[ wfdielen++ ] = 0x0A; /* WFA WFD v1.0 */ - - /* Commented by Albert 20110825 */ - /* According to the WFD Specification, the provision discovery request frame should contain 3 WFD attributes */ - /* 1. WFD Device Information */ - /* 2. Associated BSSID (Optional) */ - /* 3. Local IP Adress (Optional) */ - - /* WFD Device Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value1: */ - /* WFD device information */ - /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD, - wfdie + wfdielen); - wfdielen += 2; - - /* Value2: */ - /* Session Management Control Port */ - /* Default TCP port for RTSP messages is 554 */ - put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen); - wfdielen += 2; - - /* Value3: */ - /* WFD Device Maximum Throughput */ - /* 300Mbps is the maximum throughput */ - put_unaligned_be16(300, wfdie + wfdielen); - wfdielen += 2; - - /* Associated BSSID ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Associated BSSID */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { - memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN); - } - else - { - memset(wfdie + wfdielen, 0x00, ETH_ALEN); - } - - wfdielen += ETH_ALEN; - - /* Coupled Sink Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0007, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Coupled Sink Status bitmap */ - /* Not coupled/available for Coupling */ - wfdie[ wfdielen++ ] = 0; - /* MAC Addr. */ - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - - if (P2P_ROLE_GO == pwdinfo->role) - { - /* WFD Session Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_SESSION_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0000, wfdie + wfdielen); - wfdielen += 2; - - /* Todo: to add the list of WFD device info descriptor in WFD group. */ - - } - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, - (unsigned char *) wfdie, &len); - - return len; -} - -u32 build_provdisc_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 }; - u32 len = 0, wfdielen = 0; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wifi_display_info* pwfd_info = padapter->wdinfo.wfd_info; - - /* WFD OUI */ - wfdielen = 0; - wfdie[ wfdielen++ ] = 0x50; - wfdie[ wfdielen++ ] = 0x6F; - wfdie[ wfdielen++ ] = 0x9A; - wfdie[ wfdielen++ ] = 0x0A; /* WFA WFD v1.0 */ - - /* Commented by Albert 20110825 */ - /* According to the WFD Specification, the provision discovery request frame should contain 3 WFD attributes */ - /* 1. WFD Device Information */ - /* 2. Associated BSSID (Optional) */ - /* 3. Local IP Adress (Optional) */ - - /* WFD Device Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value1: */ - /* WFD device information */ - /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD, - wfdie + wfdielen); - wfdielen += 2; - - /* Value2: */ - /* Session Management Control Port */ - /* Default TCP port for RTSP messages is 554 */ - put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen); - wfdielen += 2; - - /* Value3: */ - /* WFD Device Maximum Throughput */ - /* 300Mbps is the maximum throughput */ - put_unaligned_be16(300, wfdie + wfdielen); - wfdielen += 2; - - /* Associated BSSID ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Associated BSSID */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { - memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN); - } - else - { - memset(wfdie + wfdielen, 0x00, ETH_ALEN); - } - - wfdielen += ETH_ALEN; - - /* Coupled Sink Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0007, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Coupled Sink Status bitmap */ - /* Not coupled/available for Coupling */ - wfdie[ wfdielen++ ] = 0; - /* MAC Addr. */ - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, - (unsigned char *) wfdie, &len); - - return len; -} - -u32 build_provdisc_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 }; - u32 len = 0, wfdielen = 0; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wifi_display_info* pwfd_info = padapter->wdinfo.wfd_info; - - /* WFD OUI */ - wfdielen = 0; - wfdie[ wfdielen++ ] = 0x50; - wfdie[ wfdielen++ ] = 0x6F; - wfdie[ wfdielen++ ] = 0x9A; - wfdie[ wfdielen++ ] = 0x0A; /* WFA WFD v1.0 */ - - /* Commented by Albert 20110825 */ - /* According to the WFD Specification, the provision discovery response frame should contain 3 WFD attributes */ - /* 1. WFD Device Information */ - /* 2. Associated BSSID (Optional) */ - /* 3. Local IP Adress (Optional) */ - - /* WFD Device Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value1: */ - /* WFD device information */ - /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD, - wfdie + wfdielen); - wfdielen += 2; - - /* Value2: */ - /* Session Management Control Port */ - /* Default TCP port for RTSP messages is 554 */ - put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen); - wfdielen += 2; - - /* Value3: */ - /* WFD Device Maximum Throughput */ - /* 300Mbps is the maximum throughput */ - put_unaligned_be16(300, wfdie + wfdielen); - wfdielen += 2; - - /* Associated BSSID ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Associated BSSID */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { - memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN); - } - else - { - memset(wfdie + wfdielen, 0x00, ETH_ALEN); - } - - wfdielen += ETH_ALEN; - - /* Coupled Sink Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0007, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Coupled Sink Status bitmap */ - /* Not coupled/available for Coupling */ - wfdie[ wfdielen++ ] = 0; - /* MAC Addr. */ - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, - (unsigned char *) wfdie, &len); - - return len; -} - -#endif /* CONFIG_8723AU_P2P */ - -u32 build_probe_resp_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u8 p2pie[ MAX_P2P_IE_LEN] = { 0x00 }; - u32 len = 0, p2pielen = 0; - - /* P2P OUI */ - p2pielen = 0; - p2pie[ p2pielen++ ] = 0x50; - p2pie[ p2pielen++ ] = 0x6F; - p2pie[ p2pielen++ ] = 0x9A; - p2pie[ p2pielen++ ] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20100907 */ - /* According to the P2P Specification, the probe response frame should contain 5 P2P attributes */ - /* 1. P2P Capability */ - /* 2. Extended Listen Timing */ - /* 3. Notice of Absence (NOA) (Only GO needs this) */ - /* 4. Device Info */ - /* 5. Group Info (Only GO need this) */ - - /* P2P Capability ATTR */ - /* Type: */ - p2pie[ p2pielen++ ] = P2P_ATTR_CAPABILITY; - - /* Length: */ - /* u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); */ - put_unaligned_le16(0x0002, p2pie + p2pielen); - p2pielen += 2; - - /* Value: */ - /* Device Capability Bitmap, 1 byte */ - p2pie[ p2pielen++ ] = DMP_P2P_DEVCAP_SUPPORT; - - /* Group Capability Bitmap, 1 byte */ - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - { - p2pie[ p2pielen ] = (P2P_GRPCAP_GO | P2P_GRPCAP_INTRABSS); - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_PROVISIONING_ING)) - p2pie[ p2pielen ] |= P2P_GRPCAP_GROUP_FORMATION; - - p2pielen++; - } - else if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE)) - { - /* Group Capability Bitmap, 1 byte */ - if (pwdinfo->persistent_supported) - p2pie[ p2pielen++ ] = P2P_GRPCAP_PERSISTENT_GROUP | DMP_P2P_GRPCAP_SUPPORT; - else - p2pie[ p2pielen++ ] = DMP_P2P_GRPCAP_SUPPORT; - } - - /* Extended Listen Timing ATTR */ - /* Type: */ - p2pie[ p2pielen++ ] = P2P_ATTR_EX_LISTEN_TIMING; - - /* Length: */ - /* u16*) (p2pie + p2pielen) = cpu_to_le16(0x0004); */ - put_unaligned_le16(0x0004, p2pie + p2pielen); - p2pielen += 2; - - /* Value: */ - /* Availability Period */ - /* u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); */ - put_unaligned_le16(0xFFFF, p2pie + p2pielen); - p2pielen += 2; - - /* Availability Interval */ - /* u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); */ - put_unaligned_le16(0xFFFF, p2pie + p2pielen); - p2pielen += 2; - - /* Notice of Absence ATTR */ - /* Type: */ - /* Length: */ - /* Value: */ - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - { - /* go_add_noa_attr(pwdinfo); */ - } - - /* Device Info ATTR */ - /* Type: */ - p2pie[ p2pielen++ ] = P2P_ATTR_DEVICE_INFO; - - /* Length: */ - /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */ - /* + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */ - /* u16*) (p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); */ - put_unaligned_le16(21 + pwdinfo->device_name_len, p2pie + p2pielen); - p2pielen += 2; - - /* Value: */ - /* P2P Device Address */ - memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN); - p2pielen += ETH_ALEN; - - /* Config Method */ - /* This field should be big endian. Noted by P2P specification. */ - /* u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->supported_wps_cm); */ - put_unaligned_be16(pwdinfo->supported_wps_cm, p2pie + p2pielen); - p2pielen += 2; - - /* Primary Device Type */ - /* Category ID */ - /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); */ - put_unaligned_be16(WPS_PDT_CID_MULIT_MEDIA, p2pie + p2pielen); - p2pielen += 2; - - /* OUI */ - /* u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI); */ - put_unaligned_be32(WPSOUI, p2pie + p2pielen); - p2pielen += 4; - - /* Sub Category ID */ - /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); */ - put_unaligned_be16(WPS_PDT_SCID_MEDIA_SERVER, p2pie + p2pielen); - p2pielen += 2; - - /* Number of Secondary Device Types */ - p2pie[ p2pielen++ ] = 0x00; /* No Secondary Device Type List */ - - /* Device Name */ - /* Type: */ - /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); */ - put_unaligned_be16(WPS_ATTR_DEVICE_NAME, p2pie + p2pielen); - p2pielen += 2; - - /* Length: */ - /* u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); */ - put_unaligned_be16(pwdinfo->device_name_len, p2pie + p2pielen); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, pwdinfo->device_name, pwdinfo->device_name_len); - p2pielen += pwdinfo->device_name_len; - - /* Group Info ATTR */ - /* Type: */ - /* Length: */ - /* Value: */ - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - { - p2pielen += go_add_group_info_attr(pwdinfo, p2pie + p2pielen); - } - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, p2pielen, - (unsigned char *) p2pie, &len); - - return len; -} - -u32 build_prov_disc_request_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf, u8* pssid, u8 ussidlen, u8* pdev_raddr) -{ - u8 p2pie[ MAX_P2P_IE_LEN] = { 0x00 }; - u32 len = 0, p2pielen = 0; - - /* P2P OUI */ - p2pielen = 0; - p2pie[ p2pielen++ ] = 0x50; - p2pie[ p2pielen++ ] = 0x6F; - p2pie[ p2pielen++ ] = 0x9A; - p2pie[ p2pielen++ ] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20110301 */ - /* According to the P2P Specification, the provision discovery request frame should contain 3 P2P attributes */ - /* 1. P2P Capability */ - /* 2. Device Info */ - /* 3. Group ID (When joining an operating P2P Group) */ - - /* P2P Capability ATTR */ - /* Type: */ - p2pie[ p2pielen++ ] = P2P_ATTR_CAPABILITY; - - /* Length: */ - /* u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); */ - put_unaligned_le16(0x0002, p2pie + p2pielen); - p2pielen += 2; - - /* Value: */ - /* Device Capability Bitmap, 1 byte */ - p2pie[ p2pielen++ ] = DMP_P2P_DEVCAP_SUPPORT; - - /* Group Capability Bitmap, 1 byte */ - if (pwdinfo->persistent_supported) - p2pie[ p2pielen++ ] = P2P_GRPCAP_PERSISTENT_GROUP | DMP_P2P_GRPCAP_SUPPORT; - else - p2pie[ p2pielen++ ] = DMP_P2P_GRPCAP_SUPPORT; - - /* Device Info ATTR */ - /* Type: */ - p2pie[ p2pielen++ ] = P2P_ATTR_DEVICE_INFO; - - /* Length: */ - /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */ - /* + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */ - /* u16*) (p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); */ - put_unaligned_le16(21 + pwdinfo->device_name_len, p2pie + p2pielen); - p2pielen += 2; - - /* Value: */ - /* P2P Device Address */ - memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN); - p2pielen += ETH_ALEN; - - /* Config Method */ - /* This field should be big endian. Noted by P2P specification. */ - if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_PBC) - { - /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_PBC); */ - put_unaligned_be16(WPS_CONFIG_METHOD_PBC, p2pie + p2pielen); - } - else - { - /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_DISPLAY); */ - put_unaligned_be16(WPS_CONFIG_METHOD_DISPLAY, p2pie + p2pielen); - } - - p2pielen += 2; - - /* Primary Device Type */ - /* Category ID */ - /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); */ - put_unaligned_be16(WPS_PDT_CID_MULIT_MEDIA, p2pie + p2pielen); - p2pielen += 2; - - /* OUI */ - /* u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI); */ - put_unaligned_be32(WPSOUI, p2pie + p2pielen); - p2pielen += 4; - - /* Sub Category ID */ - /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); */ - put_unaligned_be16(WPS_PDT_SCID_MEDIA_SERVER, p2pie + p2pielen); - p2pielen += 2; - - /* Number of Secondary Device Types */ - p2pie[ p2pielen++ ] = 0x00; /* No Secondary Device Type List */ - - /* Device Name */ - /* Type: */ - /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); */ - put_unaligned_be16(WPS_ATTR_DEVICE_NAME, p2pie + p2pielen); - p2pielen += 2; - - /* Length: */ - /* u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); */ - put_unaligned_be16(pwdinfo->device_name_len, p2pie + p2pielen); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, pwdinfo->device_name, pwdinfo->device_name_len); - p2pielen += pwdinfo->device_name_len; - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) - { - /* Added by Albert 2011/05/19 */ - /* In this case, the pdev_raddr is the device address of the group owner. */ - - /* P2P Group ID ATTR */ - /* Type: */ - p2pie[ p2pielen++ ] = P2P_ATTR_GROUP_ID; - - /* Length: */ - /* u16*) (p2pie + p2pielen) = cpu_to_le16(ETH_ALEN + ussidlen); */ - put_unaligned_le16(ETH_ALEN + ussidlen, p2pie + p2pielen); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, pdev_raddr, ETH_ALEN); - p2pielen += ETH_ALEN; - - memcpy(p2pie + p2pielen, pssid, ussidlen); - p2pielen += ussidlen; - - } - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, p2pielen, - (unsigned char *) p2pie, &len); - - return len; -} - -u32 build_assoc_resp_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 status_code) -{ - u8 p2pie[ MAX_P2P_IE_LEN] = { 0x00 }; - u32 len = 0, p2pielen = 0; - - /* P2P OUI */ - p2pielen = 0; - p2pie[ p2pielen++ ] = 0x50; - p2pie[ p2pielen++ ] = 0x6F; - p2pie[ p2pielen++ ] = 0x9A; - p2pie[ p2pielen++ ] = 0x09; /* WFA P2P v1.0 */ - - /* According to the P2P Specification, the Association response frame should contain 2 P2P attributes */ - /* 1. Status */ - /* 2. Extended Listen Timing (optional) */ - - /* Status ATTR */ - p2pielen += rtw_set_p2p_attr_content23a(&p2pie[p2pielen], P2P_ATTR_STATUS, 1, &status_code); - - /* Extended Listen Timing ATTR */ - /* Type: */ - /* Length: */ - /* Value: */ - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, p2pielen, - (unsigned char *) p2pie, &len); - - return len; -} - -u32 build_deauth_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u32 len = 0; - - return len; -} - -u32 process_probe_req_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) -{ - u8 *p; - u32 ret = false; - u8 *p2pie; - u32 p2pielen = 0; - int ssid_len = 0, rate_cnt = 0; - - p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + - _PROBEREQ_IE_OFFSET_, WLAN_EID_SUPP_RATES, - (int *)&rate_cnt, - len - sizeof(struct ieee80211_hdr_3addr) - - _PROBEREQ_IE_OFFSET_); - - if (rate_cnt <= 4) - { - int i, g_rate = 0; - - for (i = 0; i < rate_cnt; i++) - { - if (((*(p + 2 + i) & 0xff) != 0x02) && - ((*(p + 2 + i) & 0xff) != 0x04) && - ((*(p + 2 + i) & 0xff) != 0x0B) && - ((*(p + 2 + i) & 0xff) != 0x16)) - { - g_rate = 1; - } - } - - if (g_rate == 0) - { - /* There is no OFDM rate included in SupportedRates IE of this probe request frame */ - /* The driver should response this probe request. */ - return ret; - } - } - else - { - /* rate_cnt > 4 means the SupportRates IE contains the OFDM rate because the count of CCK rates are 4. */ - /* We should proceed the following check for this probe request. */ - } - - /* Added comments by Albert 20100906 */ - /* There are several items we should check here. */ - /* 1. This probe request frame must contain the P2P IE. (Done) */ - /* 2. This probe request frame must contain the wildcard SSID. (Done) */ - /* 3. Wildcard BSSID. (Todo) */ - /* 4. Destination Address. (Done in mgt_dispatcher23a function) */ - /* 5. Requested Device Type in WSC IE. (Todo) */ - /* 6. Device ID attribute in P2P IE. (Todo) */ - - p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + - _PROBEREQ_IE_OFFSET_, WLAN_EID_SSID, (int *)&ssid_len, - len - sizeof(struct ieee80211_hdr_3addr) - - _PROBEREQ_IE_OFFSET_); - - ssid_len &= 0xff; /* Just last 1 byte is valid for ssid len of the probe request */ - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE) || rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - { - if ((p2pie = rtw_get_p2p_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + _PROBEREQ_IE_OFFSET_, len - sizeof(struct ieee80211_hdr_3addr) - _PROBEREQ_IE_OFFSET_, NULL, &p2pielen))) - { - if ((p) && !memcmp((void *)(p+2), (void *)pwdinfo->p2p_wildcard_ssid, 7)) - { - /* todo: */ - /* Check Requested Device Type attributes in WSC IE. */ - /* Check Device ID attribute in P2P IE */ - - ret = true; - } - else if ((p != NULL) && (ssid_len == 0)) - { - ret = true; - } - } - else - { - /* non -p2p device */ - } - - } - - return ret; -} - -u32 process_assoc_req_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pframe, uint len, struct sta_info *psta) -{ - u8 status_code = P2P_STATUS_SUCCESS; - u8 *pbuf, *pattr_content = NULL; - u32 attr_contentlen = 0; - u16 cap_attr = 0; - unsigned short ie_offset; - u8 * ies; - u32 ies_len; - u8 * p2p_ie; - u32 p2p_ielen = 0; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe; - - if (!rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - return P2P_STATUS_FAIL_REQUEST_UNABLE; - - if (ieee80211_is_assoc_req(hdr->frame_control)) - ie_offset = _ASOCREQ_IE_OFFSET_; - else /* WIFI_REASSOCREQ */ - ie_offset = _REASOCREQ_IE_OFFSET_; - - ies = pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset; - ies_len = len - sizeof(struct ieee80211_hdr_3addr) - ie_offset; - - p2p_ie = rtw_get_p2p_ie23a(ies, ies_len, NULL, &p2p_ielen); - - if (!p2p_ie) - { - DBG_8723A("[%s] P2P IE not Found!!\n", __func__); - status_code = P2P_STATUS_FAIL_INVALID_PARAM; - } - else - { - DBG_8723A("[%s] P2P IE Found!!\n", __func__); - } - - while (p2p_ie) - { - /* Check P2P Capability ATTR */ - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_CAPABILITY, (u8*)&cap_attr, (uint*) &attr_contentlen)) - { - DBG_8723A("[%s] Got P2P Capability Attr!!\n", __func__); - cap_attr = le16_to_cpu(cap_attr); - psta->dev_cap = cap_attr&0xff; - } - - /* Check Extended Listen Timing ATTR */ - - /* Check P2P Device Info ATTR */ - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_DEVICE_INFO, NULL, (uint*)&attr_contentlen)) - { - DBG_8723A("[%s] Got P2P DEVICE INFO Attr!!\n", __func__); - pattr_content = pbuf = kzalloc(attr_contentlen, - GFP_ATOMIC); - if (pattr_content) { - u8 num_of_secdev_type; - u16 dev_name_len; - - rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_DEVICE_INFO, pattr_content, (uint*)&attr_contentlen); - - memcpy(psta->dev_addr, pattr_content, ETH_ALEN);/* P2P Device Address */ - - pattr_content += ETH_ALEN; - - memcpy(&psta->config_methods, pattr_content, 2);/* Config Methods */ - psta->config_methods = be16_to_cpu(psta->config_methods); - - pattr_content += 2; - - memcpy(psta->primary_dev_type, pattr_content, 8); - - pattr_content += 8; - - num_of_secdev_type = *pattr_content; - pattr_content += 1; - - if (num_of_secdev_type == 0) - { - psta->num_of_secdev_type = 0; - } - else - { - u32 len; - - psta->num_of_secdev_type = num_of_secdev_type; - - len = (sizeof(psta->secdev_types_list)<(num_of_secdev_type*8)) ? (sizeof(psta->secdev_types_list)) : (num_of_secdev_type*8); - - memcpy(psta->secdev_types_list, pattr_content, len); - - pattr_content += (num_of_secdev_type*8); - } - - /* dev_name_len = attr_contentlen - ETH_ALEN - 2 - 8 - 1 - (num_of_secdev_type*8); */ - psta->dev_name_len = 0; - if (WPS_ATTR_DEVICE_NAME == be16_to_cpu(*(u16*)pattr_content)) - { - dev_name_len = be16_to_cpu(*(u16*)(pattr_content+2)); - - psta->dev_name_len = (sizeof(psta->dev_name)dev_name):dev_name_len; - - memcpy(psta->dev_name, pattr_content+4, psta->dev_name_len); - } - - kfree(pbuf); - - } - - } - - /* Get the next P2P IE */ - p2p_ie = rtw_get_p2p_ie23a(p2p_ie+p2p_ielen, ies_len -(p2p_ie -ies + p2p_ielen), NULL, &p2p_ielen); - - } - - return status_code; -} - -u32 process_p2p_devdisc_req23a(struct wifidirect_info *pwdinfo, u8 *pframe, - uint len) -{ - u8 *frame_body; - u8 status, dialogToken; - struct sta_info *psta = NULL; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct sta_priv *pstapriv = &padapter->stapriv; - u8 *p2p_ie; - u32 p2p_ielen = 0; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) pframe; - - frame_body = (unsigned char *) - (pframe + sizeof(struct ieee80211_hdr_3addr)); - - dialogToken = frame_body[7]; - status = P2P_STATUS_FAIL_UNKNOWN_P2PGROUP; - - if ((p2p_ie = rtw_get_p2p_ie23a(frame_body + _PUBLIC_ACTION_IE_OFFSET_, - len - _PUBLIC_ACTION_IE_OFFSET_, NULL, - &p2p_ielen))) { - u8 groupid[38] = { 0x00 }; - u8 dev_addr[ETH_ALEN] = { 0x00 }; - u32 attr_contentlen = 0; - - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, - P2P_ATTR_GROUP_ID, groupid, - &attr_contentlen)) { - if (!memcmp(pwdinfo->device_addr, groupid, ETH_ALEN) && - !memcmp(pwdinfo->p2p_group_ssid, groupid + ETH_ALEN, - pwdinfo->p2p_group_ssid_len)) { - attr_contentlen = 0; - - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, - P2P_ATTR_DEVICE_ID, - dev_addr, - &attr_contentlen)) { - struct list_head *phead, *plist, *ptmp; - - spin_lock_bh(&pstapriv->asoc_list_lock); - phead = &pstapriv->asoc_list; - - list_for_each_safe(plist, ptmp, phead) { - psta = container_of(plist, struct sta_info, asoc_list); - - if (psta->is_p2p_device && (psta->dev_cap&P2P_DEVCAP_CLIENT_DISCOVERABILITY) && - !memcmp(psta->dev_addr, dev_addr, ETH_ALEN)) - { - /* spin_unlock_bh(&pstapriv->asoc_list_lock); */ - /* issue GO Discoverability Request */ - issue_group_disc_req(pwdinfo, psta->hwaddr); - /* spin_lock_bh(&pstapriv->asoc_list_lock); */ - status = P2P_STATUS_SUCCESS; - break; - } else { - status = P2P_STATUS_FAIL_INFO_UNAVAILABLE; - } - } - spin_unlock_bh(&pstapriv->asoc_list_lock); - } else { - status = P2P_STATUS_FAIL_INVALID_PARAM; - } - } else { - status = P2P_STATUS_FAIL_INVALID_PARAM; - } - } - } - - /* issue Device Discoverability Response */ - issue_p2p_devdisc_resp(pwdinfo, hdr->addr2, status, dialogToken); - - return (status == P2P_STATUS_SUCCESS) ? true:false; -} - -u32 process_p2p_devdisc_resp23a(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) -{ - return true; -} - -u8 process_p2p_provdisc_req23a(struct wifidirect_info *pwdinfo, - u8 *pframe, uint len) -{ - u8 *frame_body; - u8 *wpsie; - u8 *ptr = NULL; - uint wps_ielen = 0, attr_contentlen = 0; - u16 uconfig_method = 0; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe; - - frame_body = (pframe + sizeof(struct ieee80211_hdr_3addr)); - - wpsie = rtw_get_wps_ie23a(frame_body + _PUBLIC_ACTION_IE_OFFSET_, - len - _PUBLIC_ACTION_IE_OFFSET_, NULL, - &wps_ielen); - if (!wpsie) - goto out; - - if (!rtw_get_wps_attr_content23a(wpsie, wps_ielen, WPS_ATTR_CONF_METHOD, - (u8 *)&uconfig_method, &attr_contentlen)) - goto out; - - uconfig_method = be16_to_cpu(uconfig_method); - ptr = pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req; - - switch (uconfig_method) - { - case WPS_CM_DISPLYA: - memcpy(ptr, "dis", 3); - break; - - case WPS_CM_LABEL: - memcpy(ptr, "lab", 3); - break; - - case WPS_CM_PUSH_BUTTON: - memcpy(ptr, "pbc", 3); - break; - - case WPS_CM_KEYPAD: - memcpy(ptr, "pad", 3); - break; - } - issue_p2p_provision_resp(pwdinfo, hdr->addr2, frame_body, - uconfig_method); - -out: - DBG_8723A("[%s] config method = %s\n", __func__, ptr); - - return true; -} - -u8 process_p2p_provdisc_resp23a(struct wifidirect_info *pwdinfo, u8 *pframe) -{ - - return true; -} - -static u8 rtw_p2p_get_peer_ch_list(struct wifidirect_info *pwdinfo, u8 *ch_content, u8 ch_cnt, u8 *peer_ch_list) -{ - u8 i = 0, j = 0; - u8 temp = 0; - u8 ch_no = 0; - ch_content += 3; - ch_cnt -= 3; - - while(ch_cnt > 0) - { - ch_content += 1; - ch_cnt -= 1; - temp = *ch_content; - for (i = 0 ; i < temp ; i++, j++) - { - peer_ch_list[j] = *(ch_content + 1 + i); - } - ch_content += (temp + 1); - ch_cnt -= (temp + 1); - ch_no += temp ; - } - - return ch_no; -} - -static u8 rtw_p2p_ch_inclusion(struct mlme_ext_priv *pmlmeext, u8 *peer_ch_list, u8 peer_ch_num, u8 *ch_list_inclusioned) -{ - int i = 0, j = 0, temp = 0; - u8 ch_no = 0; - - for (i = 0; i < peer_ch_num; i++) - { - for (j = temp; j < pmlmeext->max_chan_nums; j++) - { - if (*(peer_ch_list + i) == pmlmeext->channel_set[ j ].ChannelNum) - { - ch_list_inclusioned[ ch_no++ ] = *(peer_ch_list + i); - temp = j; - break; - } - } - } - - return ch_no; -} - -u8 process_p2p_group_negotation_req23a(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) -{ - struct rtw_adapter *padapter = pwdinfo->padapter; - u8 result = P2P_STATUS_SUCCESS; - u32 p2p_ielen = 0, wps_ielen = 0; - u8 * ies; - u32 ies_len; - u8 *p2p_ie; - u8 *wpsie; - u16 wps_devicepassword_id = 0x0000; - uint wps_devicepassword_id_len = 0; -#ifdef CONFIG_8723AU_P2P - u8 wfd_ie[MAX_WFD_IE_LEN] = { 0x00 }; - u32 wfd_ielen = 0; -#endif /* CONFIG_8723AU_P2P */ - - if ((wpsie = rtw_get_wps_ie23a(pframe + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &wps_ielen))) - { - /* Commented by Kurt 20120113 */ - /* If some device wants to do p2p handshake without sending prov_disc_req */ - /* We have to get peer_req_cm from here. */ - if (!memcmp(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "000", 3)) - { - rtw_get_wps_attr_content23a(wpsie, wps_ielen, WPS_ATTR_DEVICE_PWID, (u8*) &wps_devicepassword_id, &wps_devicepassword_id_len); - wps_devicepassword_id = be16_to_cpu(wps_devicepassword_id); - - if (wps_devicepassword_id == WPS_DPID_USER_SPEC) - { - memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "dis", 3); - } - else if (wps_devicepassword_id == WPS_DPID_REGISTRAR_SPEC) - { - memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pad", 3); - } - else - { - memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pbc", 3); - } - } - } - else - { - DBG_8723A("[%s] WPS IE not Found!!\n", __func__); - result = P2P_STATUS_FAIL_INCOMPATIBLE_PARAM; - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); - return result; - } - - if (pwdinfo->ui_got_wps_info == P2P_NO_WPSINFO) - { - result = P2P_STATUS_FAIL_INFO_UNAVAILABLE; - rtw_p2p_set_state(pwdinfo, P2P_STATE_TX_INFOR_NOREADY); - return result; - } - - ies = pframe + _PUBLIC_ACTION_IE_OFFSET_; - ies_len = len - _PUBLIC_ACTION_IE_OFFSET_; - - p2p_ie = rtw_get_p2p_ie23a(ies, ies_len, NULL, &p2p_ielen); - - if (!p2p_ie) - { - DBG_8723A("[%s] P2P IE not Found!!\n", __func__); - result = P2P_STATUS_FAIL_INCOMPATIBLE_PARAM; - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); - } - - while (p2p_ie) - { - u8 attr_content = 0x00; - u32 attr_contentlen = 0; - u8 ch_content[50] = { 0x00 }; - uint ch_cnt = 0; - u8 peer_ch_list[50] = { 0x00 }; - u8 peer_ch_num = 0; - u8 ch_list_inclusioned[50] = { 0x00 }; - u8 ch_num_inclusioned = 0; - u16 cap_attr; - - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_ING); - - /* Check P2P Capability ATTR */ - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_CAPABILITY, (u8*)&cap_attr, (uint*)&attr_contentlen)) - cap_attr = le16_to_cpu(cap_attr); - - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_GO_INTENT, &attr_content, &attr_contentlen)) - { - DBG_8723A("[%s] GO Intent = %d, tie = %d\n", __func__, attr_content >> 1, attr_content & 0x01); - pwdinfo->peer_intent = attr_content; /* include both intent and tie breaker values. */ - - if (pwdinfo->intent == (pwdinfo->peer_intent >> 1)) - { - /* Try to match the tie breaker value */ - if (pwdinfo->intent == P2P_MAX_INTENT) - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - result = P2P_STATUS_FAIL_BOTH_GOINTENT_15; - } - else - { - if (attr_content & 0x01) - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - } - else - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - } - } - } - else if (pwdinfo->intent > (pwdinfo->peer_intent >> 1)) - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - } - else - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - } - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - { - /* Store the group id information. */ - memcpy(pwdinfo->groupid_info.go_device_addr, pwdinfo->device_addr, ETH_ALEN); - memcpy(pwdinfo->groupid_info.ssid, pwdinfo->nego_ssid, pwdinfo->nego_ssidlen); - } - } - - attr_contentlen = 0; - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_INTENTED_IF_ADDR, pwdinfo->p2p_peer_interface_addr, &attr_contentlen)) - { - if (attr_contentlen != ETH_ALEN) - { - memset(pwdinfo->p2p_peer_interface_addr, 0x00, ETH_ALEN); - } - } - - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_CH_LIST, ch_content, &ch_cnt)) - { - peer_ch_num = rtw_p2p_get_peer_ch_list(pwdinfo, ch_content, ch_cnt, peer_ch_list); - ch_num_inclusioned = rtw_p2p_ch_inclusion(&padapter->mlmeextpriv, peer_ch_list, peer_ch_num, ch_list_inclusioned); - - if (ch_num_inclusioned == 0) - { - DBG_8723A("[%s] No common channel in channel list!\n", __func__); - result = P2P_STATUS_FAIL_NO_COMMON_CH; - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); - break; - } - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - { - if (!rtw_p2p_is_channel_list_ok(pwdinfo->operating_channel, - ch_list_inclusioned, ch_num_inclusioned)) - { - { - u8 operatingch_info[5] = { 0x00 }, peer_operating_ch = 0; - attr_contentlen = 0; - - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen)) - { - peer_operating_ch = operatingch_info[4]; - } - - if (rtw_p2p_is_channel_list_ok(peer_operating_ch, - ch_list_inclusioned, ch_num_inclusioned)) - { - /** - * Change our operating channel as peer's for compatibility. - */ - pwdinfo->operating_channel = peer_operating_ch; - DBG_8723A("[%s] Change op ch to %02x as peer's\n", __func__, pwdinfo->operating_channel); - } - else - { - /* Take first channel of ch_list_inclusioned as operating channel */ - pwdinfo->operating_channel = ch_list_inclusioned[0]; - DBG_8723A("[%s] Change op ch to %02x\n", __func__, pwdinfo->operating_channel); - } - } - - } - } - } - - /* Get the next P2P IE */ - p2p_ie = rtw_get_p2p_ie23a(p2p_ie+p2p_ielen, ies_len -(p2p_ie -ies + p2p_ielen), NULL, &p2p_ielen); - } - -#ifdef CONFIG_8723AU_P2P - /* Added by Albert 20110823 */ - /* Try to get the TCP port information when receiving the negotiation request. */ - if (rtw_get_wfd_ie(pframe + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, wfd_ie, &wfd_ielen)) - { - u8 attr_content[ 10 ] = { 0x00 }; - u32 attr_contentlen = 0; - - DBG_8723A("[%s] WFD IE Found!!\n", __func__); - rtw_get_wfd_attr_content(wfd_ie, wfd_ielen, WFD_ATTR_DEVICE_INFO, attr_content, &attr_contentlen); - if (attr_contentlen) - { - pwdinfo->wfd_info->peer_rtsp_ctrlport = get_unaligned_be16(attr_content + 2); - DBG_8723A("[%s] Peer PORT NUM = %d\n", __func__, pwdinfo->wfd_info->peer_rtsp_ctrlport); - } - } -#endif /* CONFIG_8723AU_P2P */ - - return result; -} - -u8 process_p2p_group_negotation_resp23a(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) -{ - struct rtw_adapter *padapter = pwdinfo->padapter; - u8 result = P2P_STATUS_SUCCESS; - u32 p2p_ielen, wps_ielen; - u8 * ies; - u32 ies_len; - u8 * p2p_ie; -#ifdef CONFIG_8723AU_P2P - u8 wfd_ie[MAX_WFD_IE_LEN] = { 0x00 }; - u32 wfd_ielen = 0; -#endif /* CONFIG_8723AU_P2P */ - - ies = pframe + _PUBLIC_ACTION_IE_OFFSET_; - ies_len = len - _PUBLIC_ACTION_IE_OFFSET_; - - /* Be able to know which one is the P2P GO and which one is P2P client. */ - - if (rtw_get_wps_ie23a(ies, ies_len, NULL, &wps_ielen)) - { - - } - else - { - DBG_8723A("[%s] WPS IE not Found!!\n", __func__); - result = P2P_STATUS_FAIL_INCOMPATIBLE_PARAM; - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); - } - - p2p_ie = rtw_get_p2p_ie23a(ies, ies_len, NULL, &p2p_ielen); - if (!p2p_ie) - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); - result = P2P_STATUS_FAIL_INCOMPATIBLE_PARAM; - } - else - { - - u8 attr_content = 0x00; - u32 attr_contentlen = 0; - u8 operatingch_info[5] = { 0x00 }; - u8 groupid[ 38 ]; - u16 cap_attr; - u8 peer_ch_list[50] = { 0x00 }; - u8 peer_ch_num = 0; - u8 ch_list_inclusioned[50] = { 0x00 }; - u8 ch_num_inclusioned = 0; - - while (p2p_ie) /* Found the P2P IE. */ - { - - /* Check P2P Capability ATTR */ - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_CAPABILITY, (u8*)&cap_attr, (uint*)&attr_contentlen)) - cap_attr = le16_to_cpu(cap_attr); - - rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, &attr_content, &attr_contentlen); - if (attr_contentlen == 1) - { - DBG_8723A("[%s] Status = %d\n", __func__, attr_content); - if (attr_content == P2P_STATUS_SUCCESS) - { - /* Do nothing. */ - } - else - { - if (P2P_STATUS_FAIL_INFO_UNAVAILABLE == attr_content) { - rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INFOR_NOREADY); - } else { - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); - } - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - result = attr_content; - break; - } - } - - /* Try to get the peer's interface address */ - attr_contentlen = 0; - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_INTENTED_IF_ADDR, pwdinfo->p2p_peer_interface_addr, &attr_contentlen)) - { - if (attr_contentlen != ETH_ALEN) - { - memset(pwdinfo->p2p_peer_interface_addr, 0x00, ETH_ALEN); - } - } - - /* Try to get the peer's intent and tie breaker value. */ - attr_content = 0x00; - attr_contentlen = 0; - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_GO_INTENT, &attr_content, &attr_contentlen)) - { - DBG_8723A("[%s] GO Intent = %d, tie = %d\n", __func__, attr_content >> 1, attr_content & 0x01); - pwdinfo->peer_intent = attr_content; /* include both intent and tie breaker values. */ - - if (pwdinfo->intent == (pwdinfo->peer_intent >> 1)) - { - /* Try to match the tie breaker value */ - if (pwdinfo->intent == P2P_MAX_INTENT) - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - result = P2P_STATUS_FAIL_BOTH_GOINTENT_15; - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); - } - else - { - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); - rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); - if (attr_content & 0x01) - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - } - else - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - } - } - } - else if (pwdinfo->intent > (pwdinfo->peer_intent >> 1)) - { - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); - rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - } - else - { - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); - rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - } - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - { - /* Store the group id information. */ - memcpy(pwdinfo->groupid_info.go_device_addr, pwdinfo->device_addr, ETH_ALEN); - memcpy(pwdinfo->groupid_info.ssid, pwdinfo->nego_ssid, pwdinfo->nego_ssidlen); - - } - } - - /* Try to get the operation channel information */ - - attr_contentlen = 0; - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen)) - { - DBG_8723A("[%s] Peer's operating channel = %d\n", __func__, operatingch_info[4]); - pwdinfo->peer_operating_ch = operatingch_info[4]; - } - - /* Try to get the channel list information */ - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_CH_LIST, pwdinfo->channel_list_attr, &pwdinfo->channel_list_attr_len)) - { - DBG_8723A("[%s] channel list attribute found, len = %d\n", __func__, pwdinfo->channel_list_attr_len); - - peer_ch_num = rtw_p2p_get_peer_ch_list(pwdinfo, pwdinfo->channel_list_attr, pwdinfo->channel_list_attr_len, peer_ch_list); - ch_num_inclusioned = rtw_p2p_ch_inclusion(&padapter->mlmeextpriv, peer_ch_list, peer_ch_num, ch_list_inclusioned); - - if (ch_num_inclusioned == 0) - { - DBG_8723A("[%s] No common channel in channel list!\n", __func__); - result = P2P_STATUS_FAIL_NO_COMMON_CH; - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); - break; - } - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - { - if (!rtw_p2p_is_channel_list_ok(pwdinfo->operating_channel, - ch_list_inclusioned, ch_num_inclusioned)) - { - { - u8 operatingch_info[5] = { 0x00 }, peer_operating_ch = 0; - attr_contentlen = 0; - - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen)) - { - peer_operating_ch = operatingch_info[4]; - } - - if (rtw_p2p_is_channel_list_ok(peer_operating_ch, - ch_list_inclusioned, ch_num_inclusioned)) - { - /** - * Change our operating channel as peer's for compatibility. - */ - pwdinfo->operating_channel = peer_operating_ch; - DBG_8723A("[%s] Change op ch to %02x as peer's\n", __func__, pwdinfo->operating_channel); - } - else - { - /* Take first channel of ch_list_inclusioned as operating channel */ - pwdinfo->operating_channel = ch_list_inclusioned[0]; - DBG_8723A("[%s] Change op ch to %02x\n", __func__, pwdinfo->operating_channel); - } - } - - } - } - - } - else - { - DBG_8723A("[%s] channel list attribute not found!\n", __func__); - } - - /* Try to get the group id information if peer is GO */ - attr_contentlen = 0; - memset(groupid, 0x00, 38); - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, groupid, &attr_contentlen)) - { - memcpy(pwdinfo->groupid_info.go_device_addr, &groupid[0], ETH_ALEN); - memcpy(pwdinfo->groupid_info.ssid, &groupid[6], attr_contentlen - ETH_ALEN); - } - - /* Get the next P2P IE */ - p2p_ie = rtw_get_p2p_ie23a(p2p_ie+p2p_ielen, ies_len -(p2p_ie -ies + p2p_ielen), NULL, &p2p_ielen); - } - - } - -#ifdef CONFIG_8723AU_P2P - /* Added by Albert 20111122 */ - /* Try to get the TCP port information when receiving the negotiation response. */ - if (rtw_get_wfd_ie(pframe + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, wfd_ie, &wfd_ielen)) - { - u8 attr_content[ 10 ] = { 0x00 }; - u32 attr_contentlen = 0; - - DBG_8723A("[%s] WFD IE Found!!\n", __func__); - rtw_get_wfd_attr_content(wfd_ie, wfd_ielen, WFD_ATTR_DEVICE_INFO, attr_content, &attr_contentlen); - if (attr_contentlen) - { - pwdinfo->wfd_info->peer_rtsp_ctrlport = get_unaligned_be16(attr_content + 2); - DBG_8723A("[%s] Peer PORT NUM = %d\n", __func__, pwdinfo->wfd_info->peer_rtsp_ctrlport); - } - } -#endif /* CONFIG_8723AU_P2P */ - - return result; -} - -u8 process_p2p_group_negotation_confirm23a(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) -{ - u8 * ies; - u32 ies_len; - u8 * p2p_ie; - u32 p2p_ielen = 0; - u8 result = P2P_STATUS_SUCCESS; - ies = pframe + _PUBLIC_ACTION_IE_OFFSET_; - ies_len = len - _PUBLIC_ACTION_IE_OFFSET_; - - p2p_ie = rtw_get_p2p_ie23a(ies, ies_len, NULL, &p2p_ielen); - while (p2p_ie) /* Found the P2P IE. */ - { - u8 attr_content = 0x00, operatingch_info[5] = { 0x00 }; - u8 groupid[ 38 ] = { 0x00 }; - u32 attr_contentlen = 0; - - pwdinfo->negotiation_dialog_token = 1; - rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, &attr_content, &attr_contentlen); - if (attr_contentlen == 1) - { - DBG_8723A("[%s] Status = %d\n", __func__, attr_content); - result = attr_content; - - if (attr_content == P2P_STATUS_SUCCESS) - { - del_timer_sync(&pwdinfo->restore_p2p_state_timer); - - /* Commented by Albert 20100911 */ - /* Todo: Need to handle the case which both Intents are the same. */ - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); - rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); - if ((pwdinfo->intent) > (pwdinfo->peer_intent >> 1)) - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - } - else if ((pwdinfo->intent) < (pwdinfo->peer_intent >> 1)) - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - } - else - { - /* Have to compare the Tie Breaker */ - if (pwdinfo->peer_intent & 0x01) - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - } - else - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - } - } - } - else - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); - break; - } - } - - /* Try to get the group id information */ - attr_contentlen = 0; - memset(groupid, 0x00, 38); - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, groupid, &attr_contentlen)) - { - DBG_8723A("[%s] Ssid = %s, ssidlen = %zu\n", __func__, &groupid[ETH_ALEN], strlen(&groupid[ETH_ALEN])); - memcpy(pwdinfo->groupid_info.go_device_addr, &groupid[0], ETH_ALEN); - memcpy(pwdinfo->groupid_info.ssid, &groupid[6], attr_contentlen - ETH_ALEN); - } - - attr_contentlen = 0; - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen)) - { - DBG_8723A("[%s] Peer's operating channel = %d\n", __func__, operatingch_info[4]); - pwdinfo->peer_operating_ch = operatingch_info[4]; - } - - /* Get the next P2P IE */ - p2p_ie = rtw_get_p2p_ie23a(p2p_ie+p2p_ielen, ies_len -(p2p_ie -ies + p2p_ielen), NULL, &p2p_ielen); - - } - - return result; -} - -u8 process_p2p_presence_req23a(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) -{ - u8 *frame_body; - u8 dialogToken = 0; - u8 status = P2P_STATUS_SUCCESS; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) pframe; - - frame_body = (unsigned char *)(pframe + sizeof(struct ieee80211_hdr_3addr)); - - dialogToken = frame_body[6]; - - /* todo: check NoA attribute */ - - issue_p2p_presence_resp(pwdinfo, hdr->addr2, status, dialogToken); - - return true; -} - -static void find_phase_handler(struct rtw_adapter *padapter) -{ - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct cfg80211_ssid ssid; - u8 _status = 0; - - - - memset((unsigned char*)&ssid, 0, sizeof(struct cfg80211_ssid)); - memcpy(ssid.ssid, pwdinfo->p2p_wildcard_ssid, P2P_WILDCARD_SSID_LEN); - ssid.ssid_len = P2P_WILDCARD_SSID_LEN; - - rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH); - - spin_lock_bh(&pmlmepriv->lock); - _status = rtw_sitesurvey_cmd23a(padapter, &ssid, 1, NULL, 0); - spin_unlock_bh(&pmlmepriv->lock); - - -} - -void p2p_concurrent_handler(struct rtw_adapter* padapter); - -static void restore_p2p_state_handler(struct rtw_adapter *padapter) -{ - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_FAIL)) - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - - rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE)) { - /* In the P2P client mode, the driver should not switch back to its listen channel */ - /* because this P2P client should stay at the operating channel of P2P GO. */ - set_channel_bwmode23a(padapter, pwdinfo->listen_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); - } -} - -static void pre_tx_invitereq_handler(struct rtw_adapter *padapter) -{ - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - - set_channel_bwmode23a(padapter, pwdinfo->invitereq_info.peer_ch, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); - rtl8723a_mlme_sitesurvey(padapter, 1); - issue23a_probereq_p2p(padapter, NULL); - mod_timer(&pwdinfo->pre_tx_scan_timer, - jiffies + msecs_to_jiffies(P2P_TX_PRESCAN_TIMEOUT)); -} - -static void pre_tx_provdisc_handler(struct rtw_adapter *padapter) -{ - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - - set_channel_bwmode23a(padapter, - pwdinfo->tx_prov_disc_info.peer_channel_num[0], - HAL_PRIME_CHNL_OFFSET_DONT_CARE, - HT_CHANNEL_WIDTH_20); - rtl8723a_mlme_sitesurvey(padapter, 1); - issue23a_probereq_p2p(padapter, NULL); - mod_timer(&pwdinfo->pre_tx_scan_timer, - jiffies + msecs_to_jiffies(P2P_TX_PRESCAN_TIMEOUT)); -} - -static void pre_tx_negoreq_handler(struct rtw_adapter *padapter) -{ - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - - set_channel_bwmode23a(padapter, - pwdinfo->nego_req_info.peer_channel_num[0], - HAL_PRIME_CHNL_OFFSET_DONT_CARE, - HT_CHANNEL_WIDTH_20); - rtl8723a_mlme_sitesurvey(padapter, 1); - issue23a_probereq_p2p(padapter, NULL); - mod_timer(&pwdinfo->pre_tx_scan_timer, - jiffies + msecs_to_jiffies(P2P_TX_PRESCAN_TIMEOUT)); -} - -static void ro_ch_handler(struct rtw_adapter *padapter) -{ - struct cfg80211_wifidirect_info *pcfg80211_wdinfo = &padapter->cfg80211_wdinfo; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - - if (pcfg80211_wdinfo->restore_channel != pmlmeext->cur_channel) { - if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) - pmlmeext->cur_channel = pcfg80211_wdinfo->restore_channel; - - set_channel_bwmode23a(padapter, pmlmeext->cur_channel, - HAL_PRIME_CHNL_OFFSET_DONT_CARE, - HT_CHANNEL_WIDTH_20); - } - - rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); - - pcfg80211_wdinfo->is_ro_ch = false; - - DBG_8723A("cfg80211_remain_on_channel_expired\n"); - - rtw_cfg80211_remain_on_channel_expired(padapter, - pcfg80211_wdinfo->remain_on_ch_cookie, - &pcfg80211_wdinfo->remain_on_ch_channel, - pcfg80211_wdinfo->remain_on_ch_type, GFP_KERNEL); -} - -static void ro_ch_timer_process (unsigned long data) -{ - struct rtw_adapter *adapter = (struct rtw_adapter *)data; - - p2p_protocol_wk_cmd23a(adapter, P2P_RO_CH_WK); -} - -#ifdef CONFIG_8723AU_P2P -void rtw_append_wfd_ie(struct rtw_adapter *padapter, u8 *buf, u32* len) -{ - unsigned char *frame_body; - u8 category, action, OUI_Subtype, dialogToken = 0; - u32 wfdielen = 0; - - frame_body = (unsigned char *)(buf + sizeof(struct ieee80211_hdr_3addr)); - category = frame_body[0]; - - if (category == WLAN_CATEGORY_PUBLIC) { - action = frame_body[1]; - if (action == ACT_PUBLIC_VENDOR && - !memcmp(frame_body+2, P2P_OUI23A, 4)) { - OUI_Subtype = frame_body[6]; - dialogToken = frame_body[7]; - switch (OUI_Subtype)/* OUI Subtype */ { - case P2P_GO_NEGO_REQ: - wfdielen = build_nego_req_wfd_ie(&padapter->wdinfo, buf + (*len)); - (*len) += wfdielen; - break; - case P2P_GO_NEGO_RESP: - wfdielen = build_nego_resp_wfd_ie(&padapter->wdinfo, buf + (*len)); - (*len) += wfdielen; - break; - case P2P_GO_NEGO_CONF: - wfdielen = build_nego_confirm_wfd_ie(&padapter->wdinfo, buf + (*len)); - (*len) += wfdielen; - break; - case P2P_INVIT_REQ: - wfdielen = build_invitation_req_wfd_ie(&padapter->wdinfo, buf + (*len)); - (*len) += wfdielen; - break; - case P2P_INVIT_RESP: - wfdielen = build_invitation_resp_wfd_ie(&padapter->wdinfo, buf + (*len)); - (*len) += wfdielen; - break; - case P2P_DEVDISC_REQ: - break; - case P2P_DEVDISC_RESP: - break; - case P2P_PROVISION_DISC_REQ: - wfdielen = build_provdisc_req_wfd_ie(&padapter->wdinfo, buf + (*len)); - (*len) += wfdielen; - break; - case P2P_PROVISION_DISC_RESP: - wfdielen = build_provdisc_resp_wfd_ie(&padapter->wdinfo, buf + (*len)); - (*len) += wfdielen; - break; - default: - break; - } - } - } else if (category == WLAN_CATEGORY_VENDOR_SPECIFIC) { - OUI_Subtype = frame_body[5]; - dialogToken = frame_body[6]; - } else { - DBG_8723A("%s, action frame category =%d\n", __func__, category); - } -} -#endif - -int rtw_p2p_check_frames(struct rtw_adapter *padapter, const u8 *buf, u32 len, u8 tx) -{ - int is_p2p_frame = (-1); - unsigned char *frame_body; - u8 category, action, OUI_Subtype, dialogToken = 0; - u8 *p2p_ie = NULL; - uint p2p_ielen = 0; - struct rtw_wdev_priv *pwdev_priv = wdev_to_priv(padapter->rtw_wdev); - - frame_body = (unsigned char *)(buf + sizeof(struct ieee80211_hdr_3addr)); - category = frame_body[0]; - /* just for check */ - if (category == WLAN_CATEGORY_PUBLIC) - { - action = frame_body[1]; - if (action == ACT_PUBLIC_VENDOR && - !memcmp(frame_body+2, P2P_OUI23A, 4)) { - OUI_Subtype = frame_body[6]; - dialogToken = frame_body[7]; - is_p2p_frame = OUI_Subtype; - p2p_ie = rtw_get_p2p_ie23a( - (u8 *)buf+sizeof(struct ieee80211_hdr_3addr)+_PUBLIC_ACTION_IE_OFFSET_, - len-sizeof(struct ieee80211_hdr_3addr)-_PUBLIC_ACTION_IE_OFFSET_, - NULL, &p2p_ielen); - - switch (OUI_Subtype) {/* OUI Subtype */ - u8 *cont; - uint cont_len; - case P2P_GO_NEGO_REQ: - DBG_8723A("RTW_%s:P2P_GO_NEGO_REQ, dialogToken =%d\n", (tx == true)?"Tx":"Rx", dialogToken); - break; - case P2P_GO_NEGO_RESP: - cont = rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, NULL, &cont_len); - DBG_8723A("RTW_%s:P2P_GO_NEGO_RESP, dialogToken =%d, status:%d\n", (tx == true)?"Tx":"Rx", dialogToken, cont?*cont:-1); - - if (!tx) - pwdev_priv->provdisc_req_issued = false; - break; - case P2P_GO_NEGO_CONF: - cont = rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, NULL, &cont_len); - DBG_8723A("RTW_%s:P2P_GO_NEGO_CONF, dialogToken =%d, status:%d\n", - (tx == true)?"Tx":"Rx", dialogToken, cont?*cont:-1); - break; - case P2P_INVIT_REQ: - { - struct rtw_wdev_invit_info* invit_info = &pwdev_priv->invit_info; - int flags = -1; - int op_ch = 0; - - if ((cont = rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_INVITATION_FLAGS, NULL, &cont_len))) - flags = *cont; - if ((cont = rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, NULL, &cont_len))) - op_ch = *(cont+4); - - if (invit_info->token != dialogToken) - rtw_wdev_invit_info_init(invit_info); - - invit_info->token = dialogToken; - invit_info->flags = (flags ==-1) ? 0x0 : flags; - invit_info->req_op_ch = op_ch; - - DBG_8723A("RTW_%s:P2P_INVIT_REQ, dialogToken =%d, flags:0x%02x, op_ch:%d\n", - (tx) ? "Tx" : "Rx", dialogToken, flags, op_ch); - break; - } - case P2P_INVIT_RESP: - { - struct rtw_wdev_invit_info* invit_info = &pwdev_priv->invit_info; - int status = -1; - int op_ch = 0; - - if ((cont = rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, NULL, &cont_len))) - status = *cont; - if ((cont = rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, NULL, &cont_len))) - op_ch = *(cont+4); - - if (invit_info->token != dialogToken) { - rtw_wdev_invit_info_init(invit_info); - } else { - invit_info->token = 0; - invit_info->status = (status ==-1) ? 0xff : status; - invit_info->rsp_op_ch = op_ch; - } - - DBG_8723A("RTW_%s:P2P_INVIT_RESP, dialogToken =%d, status:%d, op_ch:%d\n", - (tx == true)?"Tx":"Rx", dialogToken, status, op_ch); - break; - } - case P2P_DEVDISC_REQ: - DBG_8723A("RTW_%s:P2P_DEVDISC_REQ, dialogToken =%d\n", (tx == true)?"Tx":"Rx", dialogToken); - break; - case P2P_DEVDISC_RESP: - cont = rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, NULL, &cont_len); - DBG_8723A("RTW_%s:P2P_DEVDISC_RESP, dialogToken =%d, status:%d\n", (tx == true)?"Tx":"Rx", dialogToken, cont?*cont:-1); - break; - case P2P_PROVISION_DISC_REQ: - { - size_t frame_body_len = len - sizeof(struct ieee80211_hdr_3addr); - u8 *p2p_ie; - uint p2p_ielen = 0; - uint contentlen = 0; - - DBG_8723A("RTW_%s:P2P_PROVISION_DISC_REQ, dialogToken =%d\n", (tx == true)?"Tx":"Rx", dialogToken); - - pwdev_priv->provdisc_req_issued = false; - - p2p_ie = rtw_get_p2p_ie23a(frame_body + _PUBLIC_ACTION_IE_OFFSET_, - frame_body_len - _PUBLIC_ACTION_IE_OFFSET_, - NULL, &p2p_ielen); - if (p2p_ie) { - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, NULL, &contentlen)) - pwdev_priv->provdisc_req_issued = false;/* case: p2p_client join p2p GO */ - else - pwdev_priv->provdisc_req_issued = true;/* case: p2p_devices connection before Nego req. */ - } - } - break; - case P2P_PROVISION_DISC_RESP: - DBG_8723A("RTW_%s:P2P_PROVISION_DISC_RESP, dialogToken =%d\n", (tx == true)?"Tx":"Rx", dialogToken); - break; - default: - DBG_8723A("RTW_%s:OUI_Subtype =%d, dialogToken =%d\n", (tx == true)?"Tx":"Rx", OUI_Subtype, dialogToken); - break; - } - - } - - } - else if (category == WLAN_CATEGORY_VENDOR_SPECIFIC) - { - OUI_Subtype = frame_body[5]; - dialogToken = frame_body[6]; - - is_p2p_frame = OUI_Subtype; - - switch (OUI_Subtype) { - case P2P_NOTICE_OF_ABSENCE: - DBG_8723A("RTW_%s:P2P_NOTICE_OF_ABSENCE, dialogToken =%d\n", (tx == true)?"TX":"RX", dialogToken); - break; - case P2P_PRESENCE_REQUEST: - DBG_8723A("RTW_%s:P2P_PRESENCE_REQUEST, dialogToken =%d\n", (tx == true)?"TX":"RX", dialogToken); - break; - case P2P_PRESENCE_RESPONSE: - DBG_8723A("RTW_%s:P2P_PRESENCE_RESPONSE, dialogToken =%d\n", (tx == true)?"TX":"RX", dialogToken); - break; - case P2P_GO_DISC_REQUEST: - DBG_8723A("RTW_%s:P2P_GO_DISC_REQUEST, dialogToken =%d\n", (tx == true)?"TX":"RX", dialogToken); - break; - default: - DBG_8723A("RTW_%s:OUI_Subtype =%d, dialogToken =%d\n", (tx == true)?"TX":"RX", OUI_Subtype, dialogToken); - break; - } - - } else { - DBG_8723A("RTW_%s:action frame category =%d\n", (tx == true)?"TX":"RX", category); - } - return is_p2p_frame; -} - -void rtw_init_cfg80211_wifidirect_info(struct rtw_adapter *padapter) -{ - struct cfg80211_wifidirect_info *pcfg80211_wdinfo = &padapter->cfg80211_wdinfo; - - memset(pcfg80211_wdinfo, 0x00, sizeof(struct cfg80211_wifidirect_info)); - - setup_timer(&pcfg80211_wdinfo->remain_on_ch_timer, - ro_ch_timer_process, (unsigned long)padapter); -} - -void p2p_protocol_wk_hdl23a(struct rtw_adapter *padapter, int intCmdType) -{ - switch (intCmdType) { - case P2P_FIND_PHASE_WK: - find_phase_handler(padapter); - break; - case P2P_RESTORE_STATE_WK: - restore_p2p_state_handler(padapter); - break; - case P2P_PRE_TX_PROVDISC_PROCESS_WK: - pre_tx_provdisc_handler(padapter); - break; - case P2P_PRE_TX_INVITEREQ_PROCESS_WK: - pre_tx_invitereq_handler(padapter); - break; - case P2P_PRE_TX_NEGOREQ_PROCESS_WK: - pre_tx_negoreq_handler(padapter); - break; - case P2P_RO_CH_WK: - ro_ch_handler(padapter); - break; - } -} - -#ifdef CONFIG_8723AU_P2P -void process_p2p_ps_ie23a(struct rtw_adapter *padapter, u8 *IEs, u32 IELength) -{ - u8 * ies; - u32 ies_len; - u8 * p2p_ie; - u32 p2p_ielen = 0; - u8 noa_attr[MAX_P2P_IE_LEN] = { 0x00 };/* NoA length should be n*(13) + 2 */ - u32 attr_contentlen = 0; - - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - u8 find_p2p = false, find_p2p_ps = false; - u8 noa_offset, noa_num, noa_index; - - - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - { - return; - } - if (IELength <= _BEACON_IE_OFFSET_) - return; - - ies = IEs + _BEACON_IE_OFFSET_; - ies_len = IELength - _BEACON_IE_OFFSET_; - - p2p_ie = rtw_get_p2p_ie23a(ies, ies_len, NULL, &p2p_ielen); - - while(p2p_ie) - { - find_p2p = true; - /* Get Notice of Absence IE. */ - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_NOA, noa_attr, &attr_contentlen)) - { - find_p2p_ps = true; - noa_index = noa_attr[0]; - - if ((pwdinfo->p2p_ps_mode == P2P_PS_NONE) || - (noa_index != pwdinfo->noa_index))/* if index change, driver should reconfigure related setting. */ - { - pwdinfo->noa_index = noa_index; - pwdinfo->opp_ps = noa_attr[1] >> 7; - pwdinfo->ctwindow = noa_attr[1] & 0x7F; - - noa_offset = 2; - noa_num = 0; - /* NoA length should be n*(13) + 2 */ - if (attr_contentlen > 2) - { - while(noa_offset < attr_contentlen) - { - /* memcpy(&wifidirect_info->noa_count[noa_num], &noa_attr[noa_offset], 1); */ - pwdinfo->noa_count[noa_num] = noa_attr[noa_offset]; - noa_offset += 1; - - memcpy(&pwdinfo->noa_duration[noa_num], &noa_attr[noa_offset], 4); - noa_offset += 4; - - memcpy(&pwdinfo->noa_interval[noa_num], &noa_attr[noa_offset], 4); - noa_offset += 4; - - memcpy(&pwdinfo->noa_start_time[noa_num], &noa_attr[noa_offset], 4); - noa_offset += 4; - - noa_num++; - } - } - pwdinfo->noa_num = noa_num; - - if (pwdinfo->opp_ps == 1) - { - pwdinfo->p2p_ps_mode = P2P_PS_CTWINDOW; - /* driver should wait LPS for entering CTWindow */ - if (padapter->pwrctrlpriv.bFwCurrentInPSMode == true) - { - p2p_ps_wk_cmd23a(padapter, P2P_PS_ENABLE, 1); - } - } - else if (pwdinfo->noa_num > 0) - { - pwdinfo->p2p_ps_mode = P2P_PS_NOA; - p2p_ps_wk_cmd23a(padapter, P2P_PS_ENABLE, 1); - } - else if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) - { - p2p_ps_wk_cmd23a(padapter, P2P_PS_DISABLE, 1); - } - } - - break; /* find target, just break. */ - } - - /* Get the next P2P IE */ - p2p_ie = rtw_get_p2p_ie23a(p2p_ie+p2p_ielen, ies_len -(p2p_ie -ies + p2p_ielen), NULL, &p2p_ielen); - - } - - if (find_p2p == true) - { - if ((pwdinfo->p2p_ps_mode > P2P_PS_NONE) && (find_p2p_ps == false)) - { - p2p_ps_wk_cmd23a(padapter, P2P_PS_DISABLE, 1); - } - } - - -} - -void p2p_ps_wk_hdl23a(struct rtw_adapter *padapter, u8 p2p_ps_state) -{ - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - - - - /* Pre action for p2p state */ - switch (p2p_ps_state) - { - case P2P_PS_DISABLE: - pwdinfo->p2p_ps_state = p2p_ps_state; - - rtl8723a_set_p2p_ps_offload_cmd(padapter, p2p_ps_state); - - pwdinfo->noa_index = 0; - pwdinfo->ctwindow = 0; - pwdinfo->opp_ps = 0; - pwdinfo->noa_num = 0; - pwdinfo->p2p_ps_mode = P2P_PS_NONE; - if (padapter->pwrctrlpriv.bFwCurrentInPSMode == true) { - if (pwrpriv->smart_ps == 0) { - pwrpriv->smart_ps = 2; - rtl8723a_set_FwPwrMode_cmd(padapter, padapter->pwrctrlpriv.pwr_mode); - } - } - break; - case P2P_PS_ENABLE: - if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) { - pwdinfo->p2p_ps_state = p2p_ps_state; - - if (pwdinfo->ctwindow > 0) { - if (pwrpriv->smart_ps != 0) { - pwrpriv->smart_ps = 0; - DBG_8723A("%s(): Enter CTW, change " - "SmartPS\n", __func__); - rtl8723a_set_FwPwrMode_cmd(padapter, padapter->pwrctrlpriv.pwr_mode); - } - } - rtl8723a_set_p2p_ps_offload_cmd(padapter, - p2p_ps_state); - } - break; - case P2P_PS_SCAN: - case P2P_PS_SCAN_DONE: - case P2P_PS_ALLSTASLEEP: - if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) { - pwdinfo->p2p_ps_state = p2p_ps_state; - rtl8723a_set_p2p_ps_offload_cmd(padapter, p2p_ps_state); - } - break; - default: - break; - } -} - -u8 p2p_ps_wk_cmd23a(struct rtw_adapter*padapter, u8 p2p_ps_state, u8 enqueue) -{ - struct cmd_obj *ph2c; - struct drvextra_cmd_parm *pdrvextra_cmd_parm; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; - - - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - return res; - - if (enqueue) { - ph2c = (struct cmd_obj *)kzalloc(sizeof(struct cmd_obj), - GFP_ATOMIC); - if (!ph2c) { - res = _FAIL; - goto exit; - } - - pdrvextra_cmd_parm = (struct drvextra_cmd_parm *) - kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC); - if (pdrvextra_cmd_parm == NULL) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - - pdrvextra_cmd_parm->ec_id = P2P_PS_WK_CID; - pdrvextra_cmd_parm->type_size = p2p_ps_state; - pdrvextra_cmd_parm->pbuf = NULL; - - init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); - - res = rtw_enqueue_cmd23a(pcmdpriv, ph2c); - } - else - { - p2p_ps_wk_hdl23a(padapter, p2p_ps_state); - } - -exit: - - - - return res; -} -#endif /* CONFIG_8723AU_P2P */ - -static void reset_ch_sitesurvey_timer_process(unsigned long data) -{ - struct rtw_adapter *adapter = (struct rtw_adapter *)data; - struct wifidirect_info *pwdinfo = &adapter->wdinfo; - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - return; - - DBG_8723A("[%s] In\n", __func__); - /* Reset the operation channel information */ - pwdinfo->rx_invitereq_info.operation_ch[0] = 0; - pwdinfo->rx_invitereq_info.scan_op_ch_only = 0; -} - -static void reset_ch_sitesurvey_timer_process2(unsigned long data) -{ - struct rtw_adapter *adapter = (struct rtw_adapter *)data; - struct wifidirect_info *pwdinfo = &adapter->wdinfo; - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - return; - - DBG_8723A("[%s] In\n", __func__); - /* Reset the operation channel information */ - pwdinfo->p2p_info.operation_ch[0] = 0; - pwdinfo->p2p_info.scan_op_ch_only = 0; -} - -static void restore_p2p_state_timer_process (unsigned long data) -{ - struct rtw_adapter *adapter = (struct rtw_adapter *)data; - struct wifidirect_info *pwdinfo = &adapter->wdinfo; - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - return; - - p2p_protocol_wk_cmd23a(adapter, P2P_RESTORE_STATE_WK); -} - -static void pre_tx_scan_timer_process (unsigned long data) -{ - struct rtw_adapter *adapter = (struct rtw_adapter *)data; - struct wifidirect_info *pwdinfo = &adapter->wdinfo; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - return; - - spin_lock_bh(&pmlmepriv->lock); - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ)) - { - if (true == pwdinfo->tx_prov_disc_info.benable) /* the provision discovery request frame is trigger to send or not */ - { - p2p_protocol_wk_cmd23a(adapter, P2P_PRE_TX_PROVDISC_PROCESS_WK); - /* issue23a_probereq_p2p(adapter, NULL); */ - /* _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); */ - } - } - else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING)) - { - if (true == pwdinfo->nego_req_info.benable) - { - p2p_protocol_wk_cmd23a(adapter, P2P_PRE_TX_NEGOREQ_PROCESS_WK); - } - } - else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_INVITE_REQ)) - { - if (true == pwdinfo->invitereq_info.benable) - { - p2p_protocol_wk_cmd23a(adapter, P2P_PRE_TX_INVITEREQ_PROCESS_WK); - } - } - else - { - DBG_8723A("[%s] p2p_state is %d, ignore!!\n", __func__, rtw_p2p_state(pwdinfo)); - } - - spin_unlock_bh(&pmlmepriv->lock); -} - -static void find_phase_timer_process (unsigned long data) -{ - struct rtw_adapter *adapter = (struct rtw_adapter *)data; - struct wifidirect_info *pwdinfo = &adapter->wdinfo; - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - return; - - adapter->wdinfo.find_phase_state_exchange_cnt++; - - p2p_protocol_wk_cmd23a(adapter, P2P_FIND_PHASE_WK); -} - -void reset_global_wifidirect_info23a(struct rtw_adapter *padapter) -{ - struct wifidirect_info *pwdinfo; - - pwdinfo = &padapter->wdinfo; - pwdinfo->persistent_supported = 0; - pwdinfo->session_available = true; - pwdinfo->wfd_tdls_enable = 0; - pwdinfo->wfd_tdls_weaksec = 0; -} - -#ifdef CONFIG_8723AU_P2P -int rtw_init_wifi_display_info(struct rtw_adapter* padapter) -{ - int res = _SUCCESS; - struct wifi_display_info *pwfd_info = &padapter->wfd_info; - - /* Used in P2P and TDLS */ - pwfd_info->rtsp_ctrlport = 554; - pwfd_info->peer_rtsp_ctrlport = 0; /* Reset to 0 */ - pwfd_info->wfd_enable = false; - pwfd_info->wfd_device_type = WFD_DEVINFO_PSINK; - pwfd_info->scan_result_type = SCAN_RESULT_P2P_ONLY; - - /* Used in P2P */ - pwfd_info->peer_session_avail = true; - pwfd_info->wfd_pc = false; - - /* Used in TDLS */ - memset(pwfd_info->ip_address, 0x00, 4); - memset(pwfd_info->peer_ip_address, 0x00, 4); - return res; -} -#endif /* CONFIG_8723AU_P2P */ - -void rtw_init_wifidirect_timers23a(struct rtw_adapter* padapter) -{ - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - - setup_timer(&pwdinfo->find_phase_timer, find_phase_timer_process, - (unsigned long)padapter); - setup_timer(&pwdinfo->restore_p2p_state_timer, - restore_p2p_state_timer_process, (unsigned long)padapter); - setup_timer(&pwdinfo->pre_tx_scan_timer, pre_tx_scan_timer_process, - (unsigned long)padapter); - setup_timer(&pwdinfo->reset_ch_sitesurvey, - reset_ch_sitesurvey_timer_process, (unsigned long)padapter); - setup_timer(&pwdinfo->reset_ch_sitesurvey2, - reset_ch_sitesurvey_timer_process2, - (unsigned long)padapter); -} - -void rtw_init_wifidirect_addrs23a(struct rtw_adapter* padapter, u8 *dev_addr, u8 *iface_addr) -{ -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - - /*init device&interface address */ - if (dev_addr) { - memcpy(pwdinfo->device_addr, dev_addr, ETH_ALEN); - } - if (iface_addr) { - memcpy(pwdinfo->interface_addr, iface_addr, ETH_ALEN); - } -#endif -} - -void init_wifidirect_info23a(struct rtw_adapter *padapter, enum P2P_ROLE role) -{ - struct wifidirect_info *pwdinfo; -#ifdef CONFIG_8723AU_P2P - struct wifi_display_info *pwfd_info = &padapter->wfd_info; -#endif - - pwdinfo = &padapter->wdinfo; - - pwdinfo->padapter = padapter; - - /* 1, 6, 11 are the social channel defined in the WiFi Direct specification. */ - pwdinfo->social_chan[0] = 1; - pwdinfo->social_chan[1] = 6; - pwdinfo->social_chan[2] = 11; - pwdinfo->social_chan[3] = 0; /* channel 0 for scanning ending in site survey function. */ - - /* Use the channel 11 as the listen channel */ - pwdinfo->listen_channel = 11; - - if (role == P2P_ROLE_DEVICE) - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - rtw_p2p_set_state(pwdinfo, P2P_STATE_LISTEN); - pwdinfo->intent = 1; - rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_LISTEN); - } - else if (role == P2P_ROLE_CLIENT) - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); - pwdinfo->intent = 1; - rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); - } - else if (role == P2P_ROLE_GO) - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); - pwdinfo->intent = 15; - rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); - } - -/* Use the OFDM rate in the P2P probe response frame. (6(B), 9(B), 12, 18, 24, 36, 48, 54) */ - pwdinfo->support_rate[0] = 0x8c; /* 6(B) */ - pwdinfo->support_rate[1] = 0x92; /* 9(B) */ - pwdinfo->support_rate[2] = 0x18; /* 12 */ - pwdinfo->support_rate[3] = 0x24; /* 18 */ - pwdinfo->support_rate[4] = 0x30; /* 24 */ - pwdinfo->support_rate[5] = 0x48; /* 36 */ - pwdinfo->support_rate[6] = 0x60; /* 48 */ - pwdinfo->support_rate[7] = 0x6c; /* 54 */ - - memcpy((void*) pwdinfo->p2p_wildcard_ssid, "DIRECT-", 7); - - memset(pwdinfo->device_name, 0x00, WPS_MAX_DEVICE_NAME_LEN); - pwdinfo->device_name_len = 0; - - memset(&pwdinfo->invitereq_info, 0x00, sizeof(struct tx_invite_req_info)); - pwdinfo->invitereq_info.token = 3; /* Token used for P2P invitation request frame. */ - - memset(&pwdinfo->inviteresp_info, 0x00, sizeof(struct tx_invite_resp_info)); - pwdinfo->inviteresp_info.token = 0; - - pwdinfo->profileindex = 0; - memset(&pwdinfo->profileinfo[ 0 ], 0x00, sizeof(struct profile_info) * P2P_MAX_PERSISTENT_GROUP_NUM); - - rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_NONE); - - pwdinfo->listen_dwell = (u8) ((jiffies % 3) + 1); - /* DBG_8723A("[%s] listen_dwell time is %d00ms\n", __func__, pwdinfo->listen_dwell); */ - - memset(&pwdinfo->tx_prov_disc_info, 0x00, sizeof(struct tx_provdisc_req_info)); - pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_NONE; - - memset(&pwdinfo->nego_req_info, 0x00, sizeof(struct tx_nego_req_info)); - - pwdinfo->device_password_id_for_nego = WPS_DPID_PBC; - pwdinfo->negotiation_dialog_token = 1; - - memset(pwdinfo->nego_ssid, 0x00, IEEE80211_MAX_SSID_LEN); - pwdinfo->nego_ssidlen = 0; - - pwdinfo->ui_got_wps_info = P2P_NO_WPSINFO; -#ifdef CONFIG_8723AU_P2P - pwdinfo->supported_wps_cm = WPS_CONFIG_METHOD_DISPLAY | WPS_CONFIG_METHOD_PBC; - pwdinfo->wfd_info = pwfd_info; -#else - pwdinfo->supported_wps_cm = WPS_CONFIG_METHOD_DISPLAY | WPS_CONFIG_METHOD_PBC | WPS_CONFIG_METHOD_KEYPAD; -#endif /* CONFIG_8723AU_P2P */ - pwdinfo->channel_list_attr_len = 0; - memset(pwdinfo->channel_list_attr, 0x00, 100); - - memset(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, 0x00, 4); - memset(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, '0', 3); - memset(&pwdinfo->groupid_info, 0x00, sizeof(struct group_id_info)); - pwdinfo->wfd_tdls_enable = 0; - memset(pwdinfo->p2p_peer_interface_addr, 0x00, ETH_ALEN); - memset(pwdinfo->p2p_peer_device_addr, 0x00, ETH_ALEN); - - pwdinfo->rx_invitereq_info.operation_ch[0] = 0; - pwdinfo->rx_invitereq_info.operation_ch[1] = 0; /* Used to indicate the scan end in site survey function */ - pwdinfo->rx_invitereq_info.scan_op_ch_only = 0; - pwdinfo->p2p_info.operation_ch[0] = 0; - pwdinfo->p2p_info.operation_ch[1] = 0; /* Used to indicate the scan end in site survey function */ - pwdinfo->p2p_info.scan_op_ch_only = 0; -} - -int rtw_p2p_enable23a(struct rtw_adapter *padapter, enum P2P_ROLE role) -{ - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - int ret = _SUCCESS; - - if (role == P2P_ROLE_DEVICE || role == P2P_ROLE_CLIENT || - role == P2P_ROLE_GO) { - /* leave IPS/Autosuspend */ - if (_FAIL == rtw_pwr_wakeup(padapter)) { - ret = _FAIL; - goto exit; - } - - /* Added by Albert 2011/03/22 */ - /* In the P2P mode, the driver should not support the b mode. */ - /* So, the Tx packet shouldn't use the CCK rate */ - update_tx_basic_rate23a(padapter, WIRELESS_11AGN); - - /* Enable P2P function */ - init_wifidirect_info23a(padapter, role); - - rtw_hal_set_odm_var23a(padapter, HAL_ODM_P2P_STATE, NULL, true); - #ifdef CONFIG_8723AU_P2P - rtw_hal_set_odm_var23a(padapter, HAL_ODM_WIFI_DISPLAY_STATE, NULL, true); - #endif - - } - else if (role == P2P_ROLE_DISABLE) - { - if (_FAIL == rtw_pwr_wakeup(padapter)) { - ret = _FAIL; - goto exit; - } - - /* Disable P2P function */ - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - { - del_timer_sync(&pwdinfo->find_phase_timer); - del_timer_sync(&pwdinfo->restore_p2p_state_timer); - del_timer_sync(&pwdinfo->pre_tx_scan_timer); - del_timer_sync(&pwdinfo->reset_ch_sitesurvey); - del_timer_sync(&pwdinfo->reset_ch_sitesurvey2); - reset_ch_sitesurvey_timer_process((unsigned long)padapter); - reset_ch_sitesurvey_timer_process2((unsigned long)padapter); - rtw_p2p_set_state(pwdinfo, P2P_STATE_NONE); - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DISABLE); - memset(&pwdinfo->rx_prov_disc_info, 0x00, sizeof(struct rx_provdisc_req_info)); - } - - rtw_hal_set_odm_var23a(padapter, HAL_ODM_P2P_STATE, NULL, false); - #ifdef CONFIG_8723AU_P2P - rtw_hal_set_odm_var23a(padapter, HAL_ODM_WIFI_DISPLAY_STATE, NULL, false); - #endif - - /* Restore to initial setting. */ - update_tx_basic_rate23a(padapter, padapter->registrypriv.wireless_mode); - } - -exit: - return ret; -} - -#endif /* CONFIG_8723AU_P2P */ diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index c14b8193ce02..77880547e80f 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -109,33 +109,30 @@ static bool rtw_pwr_unassociated_idle(struct rtw_adapter *adapter) struct rtw_adapter *buddy = adapter->pbuddy_adapter; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; struct xmit_priv *pxmit_priv = &adapter->xmitpriv; - struct wifidirect_info *pwdinfo = &adapter->wdinfo; bool ret = false; if (time_after_eq(adapter->pwrctrlpriv.ips_deny_time, jiffies)) goto exit; - if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE|WIFI_SITE_MONITOR) - || check_fwstate(pmlmepriv, WIFI_UNDER_LINKING|WIFI_UNDER_WPS) - || check_fwstate(pmlmepriv, WIFI_AP_STATE) - || check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE) - || !rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) - ) { + if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE|WIFI_SITE_MONITOR) || + check_fwstate(pmlmepriv, WIFI_UNDER_LINKING|WIFI_UNDER_WPS) || + check_fwstate(pmlmepriv, WIFI_AP_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE)){ goto exit; } /* consider buddy, if exist */ if (buddy) { struct mlme_priv *b_pmlmepriv = &buddy->mlmepriv; - struct wifidirect_info *b_pwdinfo = &buddy->wdinfo; - - if (check_fwstate(b_pmlmepriv, WIFI_ASOC_STATE|WIFI_SITE_MONITOR) - || check_fwstate(b_pmlmepriv, WIFI_UNDER_LINKING|WIFI_UNDER_WPS) - || check_fwstate(b_pmlmepriv, WIFI_AP_STATE) - || check_fwstate(b_pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE) - || !rtw_p2p_chk_state(b_pwdinfo, P2P_STATE_NONE) - ) { + + if (check_fwstate(b_pmlmepriv, + WIFI_ASOC_STATE|WIFI_SITE_MONITOR) || + check_fwstate(b_pmlmepriv, + WIFI_UNDER_LINKING|WIFI_UNDER_WPS) || + check_fwstate(b_pmlmepriv, WIFI_AP_STATE) || + check_fwstate(b_pmlmepriv, + WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE)) { goto exit; } } @@ -307,11 +304,6 @@ u8 PS_RDY_CHECK(struct rtw_adapter * padapter) void rtw_set_ps_mode23a(struct rtw_adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_ant_mode) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* CONFIG_8723AU_P2P */ - - RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, ("%s: PowerMode =%d Smart_PS =%d\n", @@ -334,17 +326,12 @@ void rtw_set_ps_mode23a(struct rtw_adapter *padapter, u8 ps_mode, u8 smart_ps, u } if (ps_mode == PS_MODE_ACTIVE) { -#ifdef CONFIG_8723AU_P2P - if (pwdinfo->opp_ps == 0) -#endif /* CONFIG_8723AU_P2P */ - { - DBG_8723A("rtw_set_ps_mode23a: Leave 802.11 power save\n"); + DBG_8723A("rtw_set_ps_mode23a: Leave 802.11 power save\n"); - pwrpriv->pwr_mode = ps_mode; - rtw_set_rpwm23a(padapter, PS_STATE_S4); - rtl8723a_set_FwPwrMode_cmd(padapter, ps_mode); - pwrpriv->bFwCurrentInPSMode = false; - } + pwrpriv->pwr_mode = ps_mode; + rtw_set_rpwm23a(padapter, PS_STATE_S4); + rtl8723a_set_FwPwrMode_cmd(padapter, ps_mode); + pwrpriv->bFwCurrentInPSMode = false; } else { if (PS_RDY_CHECK(padapter) #ifdef CONFIG_8723AU_BT_COEXIST @@ -359,12 +346,6 @@ void rtw_set_ps_mode23a(struct rtw_adapter *padapter, u8 ps_mode, u8 smart_ps, u pwrpriv->bcn_ant_mode = bcn_ant_mode; rtl8723a_set_FwPwrMode_cmd(padapter, ps_mode); -#ifdef CONFIG_8723AU_P2P - /* Set CTWindow after LPS */ - if (pwdinfo->opp_ps == 1) - p2p_ps_wk_cmd23a(padapter, P2P_PS_ENABLE, 0); -#endif /* CONFIG_8723AU_P2P */ - rtw_set_rpwm23a(padapter, PS_STATE_S2); } } @@ -464,10 +445,6 @@ void LeaveAllPowerSaveMode23a(struct rtw_adapter *Adapter) /* DBG_8723A("%s.....\n", __func__); */ if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { /* connect */ -#ifdef CONFIG_8723AU_P2P - p2p_ps_wk_cmd23a(Adapter, P2P_PS_DISABLE, enqueue); -#endif /* CONFIG_8723AU_P2P */ - rtw_lps_ctrl_wk_cmd23a(Adapter, LPS_CTRL_LEAVE, enqueue); } diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index f774b03f23d9..17e32071b514 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -498,32 +498,6 @@ void flush_all_cam_entry23a(struct rtw_adapter *padapter) memset((u8 *)(pmlmeinfo->FW_sta_info), 0, sizeof(pmlmeinfo->FW_sta_info)); } -#if defined(CONFIG_8723AU_P2P) && defined(CONFIG_8723AU_P2P) -int WFD_info_handler(struct rtw_adapter *padapter, struct ndis_802_11_var_ies * pIE) -{ - struct wifidirect_info *pwdinfo; - u8 wfd_ie[MAX_WFD_IE_LEN] = {0x00}; - u32 wfd_ielen = 0; - - pwdinfo = &padapter->wdinfo; - if (rtw_get_wfd_ie((u8 *) pIE, pIE->Length, wfd_ie, &wfd_ielen)) { - u8 attr_content[ 10 ] = { 0x00 }; - u32 attr_contentlen = 0; - - DBG_8723A("[%s] Found WFD IE\n", __func__); - rtw_get_wfd_attr_content(wfd_ie, wfd_ielen, WFD_ATTR_DEVICE_INFO, attr_content, &attr_contentlen); - if (attr_contentlen) { - pwdinfo->wfd_info->peer_rtsp_ctrlport = get_unaligned_be16(attr_content + 2); - DBG_8723A("[%s] Peer PORT NUM = %d\n", __func__, pwdinfo->wfd_info->peer_rtsp_ctrlport); - return true; - } - } else { - DBG_8723A("[%s] NO WFD IE\n", __func__); - } - return _FAIL; -} -#endif - int WMM_param_handler23a(struct rtw_adapter *padapter, struct ndis_802_11_var_ies * pIE) { /* struct registry_priv *pregpriv = &padapter->registrypriv; */ @@ -1371,15 +1345,6 @@ void set_sta_rate23a(struct rtw_adapter *padapter, struct sta_info *psta) void update_tx_basic_rate23a(struct rtw_adapter *padapter, u8 wirelessmode) { unsigned char supported_rates[NDIS_802_11_LENGTH_RATES_EX]; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info* pwdinfo = &padapter->wdinfo; - - /* Added by Albert 2011/03/22 */ - /* In the P2P mode, the driver should not support the b mode. */ - /* So, the Tx packet shouldn't use the CCK rate */ - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - return; -#endif /* CONFIG_8723AU_P2P */ memset(supported_rates, 0, NDIS_802_11_LENGTH_RATES_EX); diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c index 7a2284d96f4a..307963d9e7d0 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c @@ -776,76 +776,3 @@ void rtl8723a_set_BTCoex_AP_mode_FwRsvdPkt_cmd(struct rtw_adapter *padapter) } } #endif - -#ifdef CONFIG_8723AU_P2P -void rtl8723a_set_p2p_ps_offload_cmd(struct rtw_adapter *padapter, u8 p2p_ps_state) -{ - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - struct P2P_PS_Offload_t *p2p_ps_offload = &pHalData->p2p_ps_offload; - u8 i; - - switch (p2p_ps_state) { - case P2P_PS_DISABLE: - DBG_8723A("P2P_PS_DISABLE \n"); - memset(p2p_ps_offload, 0, 1); - break; - case P2P_PS_ENABLE: - DBG_8723A("P2P_PS_ENABLE \n"); - /* update CTWindow value. */ - if (pwdinfo->ctwindow > 0) { - p2p_ps_offload->CTWindow_En = 1; - rtw_write8(padapter, REG_P2P_CTWIN, pwdinfo->ctwindow); - } - - /* hw only support 2 set of NoA */ - for (i = 0; i < pwdinfo->noa_num; i++) { - /* To control the register setting for which NOA */ - rtw_write8(padapter, REG_NOA_DESC_SEL, (i << 4)); - if (i == 0) - p2p_ps_offload->NoA0_En = 1; - else - p2p_ps_offload->NoA1_En = 1; - - /* config P2P NoA Descriptor Register */ - rtw_write32(padapter, REG_NOA_DESC_DURATION, pwdinfo->noa_duration[i]); - - rtw_write32(padapter, REG_NOA_DESC_INTERVAL, pwdinfo->noa_interval[i]); - - rtw_write32(padapter, REG_NOA_DESC_START, pwdinfo->noa_start_time[i]); - - rtw_write8(padapter, REG_NOA_DESC_COUNT, pwdinfo->noa_count[i]); - } - - if ((pwdinfo->opp_ps == 1) || (pwdinfo->noa_num > 0)) { - /* rst p2p circuit */ - rtw_write8(padapter, REG_DUAL_TSF_RST, BIT(4)); - - p2p_ps_offload->Offload_En = 1; - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { - p2p_ps_offload->role = 1; - p2p_ps_offload->AllStaSleep = 0; - } else { - p2p_ps_offload->role = 0; - } - - p2p_ps_offload->discovery = 0; - } - break; - case P2P_PS_SCAN: - DBG_8723A("P2P_PS_SCAN \n"); - p2p_ps_offload->discovery = 1; - break; - case P2P_PS_SCAN_DONE: - DBG_8723A("P2P_PS_SCAN_DONE \n"); - p2p_ps_offload->discovery = 0; - pwdinfo->p2p_ps_state = P2P_PS_ENABLE; - break; - default: - break; - } - - FillH2CCmd(padapter, P2P_PS_OFFLOAD_EID, 1, (u8 *)p2p_ps_offload); -} -#endif /* CONFIG_8723AU_P2P */ diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_dm.c b/drivers/staging/rtl8723au/hal/rtl8723a_dm.c index 71ee47abcace..4ca7b8ec7b38 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_dm.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_dm.c @@ -219,13 +219,6 @@ rtl8723a_HalDmWatchDog( bFwCurrentInPSMode = Adapter->pwrctrlpriv.bFwCurrentInPSMode; bFwPSAwake = rtl8723a_get_fwlps_rf_on(Adapter); -#ifdef CONFIG_8723AU_P2P - /* Fw is under p2p powersaving mode, driver should stop dynamic mechanism. */ - /* modifed by thomas. 2011.06.11. */ - if (Adapter->wdinfo.p2p_ps_mode) - bFwPSAwake = false; -#endif /* CONFIG_8723AU_P2P */ - if ((hw_init_completed) && ((!bFwCurrentInPSMode) && bFwPSAwake)) { /* Calculate Tx/Rx statistics. */ dm_CheckStatistics(Adapter); diff --git a/drivers/staging/rtl8723au/include/drv_types.h b/drivers/staging/rtl8723au/include/drv_types.h index 14c7f2e915e0..de25e1a5eee8 100644 --- a/drivers/staging/rtl8723au/include/drv_types.h +++ b/drivers/staging/rtl8723au/include/drv_types.h @@ -55,7 +55,6 @@ enum _NIC_VERSION { #include #include #include -#include #include #include "ioctl_cfg80211.h" @@ -258,13 +257,7 @@ struct rtw_adapter { struct hostapd_priv *phostapdpriv; #endif - struct cfg80211_wifidirect_info cfg80211_wdinfo; u32 setband; - struct wifidirect_info wdinfo; - -#ifdef CONFIG_8723AU_P2P - struct wifi_display_info wfd_info; -#endif /* CONFIG_8723AU_P2P */ void *HalData; u32 hal_data_sz; @@ -316,10 +309,6 @@ struct rtw_adapter { u8 bRxRSSIDisplay; /* The driver will show the desired chan nor when this flag is 1. */ u8 bNotifyChannelChange; -#ifdef CONFIG_8723AU_P2P - /* driver will show current P2P status when the application reads it*/ - u8 bShowGetP2PState; -#endif struct rtw_adapter *pbuddy_adapter; /* extend to support multi interface */ diff --git a/drivers/staging/rtl8723au/include/ieee80211.h b/drivers/staging/rtl8723au/include/ieee80211.h index 61326e5e089c..f2824c3c2f9c 100644 --- a/drivers/staging/rtl8723au/include/ieee80211.h +++ b/drivers/staging/rtl8723au/include/ieee80211.h @@ -563,20 +563,6 @@ u8 *rtw_get_wps_attr_content23a(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , void dump_ies23a(u8 *buf, u32 buf_len); void dump_wps_ie23a(u8 *ie, u32 ie_len); -#ifdef CONFIG_8723AU_P2P -void dump_p2p_ie23a(u8 *ie, u32 ie_len); -u8 *rtw_get_p2p_ie23a(u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen); -u8 *rtw_get_p2p_attr23a(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id ,u8 *buf_attr, u32 *len_attr); -u8 *rtw_get_p2p_attr23a_content(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id ,u8 *buf_content, uint *len_content); -u32 rtw_set_p2p_attr_content23a(u8 *pbuf, u8 attr_id, u16 attr_len, u8 *pdata_attr); -void rtw_wlan_bssid_ex_remove_p2p_attr23a(struct wlan_bssid_ex *bss_ex, u8 attr_id); -#endif - -#ifdef CONFIG_8723AU_P2P -int rtw_get_wfd_ie(u8 *in_ie, int in_len, u8 *wfd_ie, uint *wfd_ielen); -int rtw_get_wfd_attr_content(u8 *wfd_ie, uint wfd_ielen, u8 target_attr_id ,u8 *attr_content, uint *attr_contentlen); -#endif /* CONFIG_8723AU_P2P */ - uint rtw_get_rateset_len23a(u8 *rateset); struct registry_priv; diff --git a/drivers/staging/rtl8723au/include/rtl8723a_cmd.h b/drivers/staging/rtl8723au/include/rtl8723a_cmd.h index 8fccbfc3a45c..09fa72340302 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_cmd.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_cmd.h @@ -151,10 +151,6 @@ u8 rtl8723a_set_rssi_cmd(struct rtw_adapter * padapter, u8 *param); u8 rtl8723a_set_raid_cmd(struct rtw_adapter * padapter, u32 mask, u8 arg); void rtl8723a_add_rateatid(struct rtw_adapter * padapter, u32 bitmap, u8 arg, u8 rssi_level); -#ifdef CONFIG_8723AU_P2P -void rtl8723a_set_p2p_ps_offload_cmd(struct rtw_adapter * padapter, u8 p2p_ps_state); -#endif /* CONFIG_8723AU_P2P */ - void CheckFwRsvdPageContent23a(struct rtw_adapter *padapter); #endif diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index ce11245fefd7..f6b4b7c7c22d 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -424,11 +424,6 @@ struct hal_data_8723a { bool bMACFuncEnable; -#ifdef CONFIG_8723AU_P2P - struct P2P_PS_Offload_t p2p_ps_offload; -#endif - - /* */ /* For USB Interface HAL related */ /* */ diff --git a/drivers/staging/rtl8723au/include/rtw_cmd.h b/drivers/staging/rtl8723au/include/rtw_cmd.h index f9caa3e35f57..ba6d572b81b3 100644 --- a/drivers/staging/rtl8723au/include/rtw_cmd.h +++ b/drivers/staging/rtl8723au/include/rtw_cmd.h @@ -106,9 +106,6 @@ u32 rtw_init_evt_priv23a (struct evt_priv *pevtpriv); void rtw_free_evt_priv23a (struct evt_priv *pevtpriv); void rtw_cmd_clr_isr23a(struct cmd_priv *pcmdpriv); void rtw_evt_notify_isr(struct evt_priv *pevtpriv); -#ifdef CONFIG_8723AU_P2P -u8 p2p_protocol_wk_cmd23a(struct rtw_adapter*padapter, int intCmdType ); -#endif /* CONFIG_8723AU_P2P */ enum rtw_drvextra_cmd_id { diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index 2d4f61b91943..0b48b05fc1ad 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -148,30 +148,6 @@ struct tx_invite_resp_info { u8 token; /* Used to record the dialog token of p2p invitation request frame. */ }; -#ifdef CONFIG_8723AU_P2P - -struct wifi_display_info { - u16 wfd_enable; /* Enable/Disable the WFD function. */ - u16 rtsp_ctrlport; /* TCP port number at which the this WFD device listens for RTSP messages */ - u16 peer_rtsp_ctrlport; /* TCP port number at which the peer WFD device listens for RTSP messages */ - /* This filed should be filled when receiving the gropu negotiation request */ - - u8 peer_session_avail; /* WFD session is available or not for the peer wfd device. */ - /* This variable will be set when sending the provisioning discovery request to peer WFD device. */ - /* And this variable will be reset when it is read by using the iwpriv p2p_get wfd_sa command. */ - u8 ip_address[4]; - u8 peer_ip_address[4]; - u8 wfd_pc; /* WFD preferred connection */ - /* 0 -> Prefer to use the P2P for WFD connection on peer side. */ - /* 1 -> Prefer to use the TDLS for WFD connection on peer side. */ - - u8 wfd_device_type;/* WFD Device Type */ - /* 0 -> WFD Source Device */ - /* 1 -> WFD Primary Sink Device */ - enum SCAN_RESULT_TYPE scan_result_type; /* Used when P2P is enable. This parameter will impact the scan result. */ -}; -#endif /* CONFIG_8723AU_P2P */ - struct tx_provdisc_req_info { u16 wps_config_method_request; /* Used when sending the provisioning request frame */ u16 peer_channel_num[2]; /* The channel number which the receiver stands. */ @@ -203,102 +179,6 @@ struct scan_limit_info { u8 operation_ch[2]; /* Store the operation channel of invitation request frame */ }; -struct cfg80211_wifidirect_info { - struct timer_list remain_on_ch_timer; - u8 restore_channel; - struct ieee80211_channel remain_on_ch_channel; - enum nl80211_channel_type remain_on_ch_type; - u64 remain_on_ch_cookie; - bool is_ro_ch; -}; - -struct wifidirect_info { - struct rtw_adapter *padapter; - struct timer_list find_phase_timer; - struct timer_list restore_p2p_state_timer; - - /* Used to do the scanning. After confirming the peer is availalble, the driver transmits the P2P frame to peer. */ - struct timer_list pre_tx_scan_timer; - struct timer_list reset_ch_sitesurvey; - struct timer_list reset_ch_sitesurvey2; /* Just for resetting the scan limit function by using p2p nego */ - struct tx_provdisc_req_info tx_prov_disc_info; - struct rx_provdisc_req_info rx_prov_disc_info; - struct tx_invite_req_info invitereq_info; - struct profile_info profileinfo[P2P_MAX_PERSISTENT_GROUP_NUM]; /* Store the profile information of persistent group */ - struct tx_invite_resp_info inviteresp_info; - struct tx_nego_req_info nego_req_info; - struct group_id_info groupid_info; /* Store the group id information when doing the group negotiation handshake. */ - struct scan_limit_info rx_invitereq_info; /* Used for get the limit scan channel from the Invitation procedure */ - struct scan_limit_info p2p_info; /* Used for get the limit scan channel from the P2P negotiation handshake */ -#ifdef CONFIG_8723AU_P2P - struct wifi_display_info *wfd_info; -#endif - enum P2P_ROLE role; - enum P2P_STATE pre_p2p_state; - enum P2P_STATE p2p_state; - u8 device_addr[ETH_ALEN]; /* The device address should be the mac address of this device. */ - u8 interface_addr[ETH_ALEN]; - u8 social_chan[4]; - u8 listen_channel; - u8 operating_channel; - u8 listen_dwell; /* This value should be between 1 and 3 */ - u8 support_rate[8]; - u8 p2p_wildcard_ssid[P2P_WILDCARD_SSID_LEN]; - u8 intent; /* should only include the intent value. */ - u8 p2p_peer_interface_addr[ETH_ALEN]; - u8 p2p_peer_device_addr[ETH_ALEN]; - u8 peer_intent; /* Included the intent value and tie breaker value. */ - u8 device_name[WPS_MAX_DEVICE_NAME_LEN]; /* Device name for displaying on searching device screen */ - u8 device_name_len; - u8 profileindex; /* Used to point to the index of profileinfo array */ - u8 peer_operating_ch; - u8 find_phase_state_exchange_cnt; - u16 device_password_id_for_nego; /* The device password ID for group negotation */ - u8 negotiation_dialog_token; - /* SSID information for group negotitation */ - u8 nego_ssid[IEEE80211_MAX_SSID_LEN]; - u8 nego_ssidlen; - u8 p2p_group_ssid[IEEE80211_MAX_SSID_LEN]; - u8 p2p_group_ssid_len; - u8 persistent_supported; /* Flag to know the persistent function should be supported or not. */ - /* In the Sigma test, the Sigma will provide this enable from the sta_set_p2p CAPI. */ - /* 0: disable */ - /* 1: enable */ - u8 session_available; /* Flag to set the WFD session available to enable or disable "by Sigma" */ - /* In the Sigma test, the Sigma will disable the session available by using the sta_preset CAPI. */ - /* 0: disable */ - /* 1: enable */ - - u8 wfd_tdls_enable; /* Flag to enable or disable the TDLS by WFD Sigma */ - /* 0: disable */ - /* 1: enable */ - u8 wfd_tdls_weaksec; /* Flag to enable or disable the weak security function for TDLS by WFD Sigma */ - /* 0: disable */ - /* In this case, the driver can't issue the tdsl setup request frame. */ - /* 1: enable */ - /* In this case, the driver can issue the tdls setup request frame */ - /* even the current security is weak security. */ - - enum P2P_WPSINFO ui_got_wps_info; /* This field will store the WPS value (PIN value or PBC) that UI had got from the user. */ - u16 supported_wps_cm; /* This field describes the WPS config method which this driver supported. */ - /* The value should be the combination of config method defined in page104 of WPS v2.0 spec. */ - uint channel_list_attr_len; /* This field will contain the length of body of P2P Channel List attribute of group negotitation response frame. */ - u8 channel_list_attr[100]; /* This field will contain the body of P2P Channel List attribute of group negotitation response frame. */ - /* We will use the channel_cnt and channel_list fields when constructing the group negotitation confirm frame. */ -#ifdef CONFIG_8723AU_P2P - enum P2P_PS_MODE p2p_ps_mode; /* indicate p2p ps mode */ - enum P2P_PS_STATE p2p_ps_state; /* indicate p2p ps state */ - u8 noa_index; /* Identifies and instance of Notice of Absence timing. */ - u8 ctwindow; /* Client traffic window. A period of time in TU after TBTT. */ - u8 opp_ps; /* opportunistic power save. */ - u8 noa_num; /* number of NoA descriptor in P2P IE. */ - u8 noa_count[P2P_MAX_NOA_NUM]; /* Count for owner, Type of client. */ - u32 noa_duration[P2P_MAX_NOA_NUM]; /* Max duration for owner, preferred or min acceptable duration for client. */ - u32 noa_interval[P2P_MAX_NOA_NUM]; /* Length of interval for owner, preferred or max acceptable interval of client. */ - u32 noa_start_time[P2P_MAX_NOA_NUM]; /* schedule expressed in terms of the lower 4 bytes of the TSF timer. */ -#endif /* CONFIG_8723AU_P2P */ -}; - struct tdls_ss_record { /* signal strength record */ u8 macaddr[ETH_ALEN]; u8 RxPWDBAll; @@ -324,9 +204,6 @@ struct tdls_info { u8 watchdog_count; u8 dev_discovered; /* WFD_TDLS: for sigma test */ u8 enable; -#ifdef CONFIG_8723AU_P2P - struct wifi_display_info *wfd_info; -#endif }; struct mlme_priv { diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 7729b2be25ae..9d9815dd6941 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -519,10 +519,6 @@ unsigned char check_assoc_AP23a(u8 *pframe, uint len); int WMM_param_handler23a(struct rtw_adapter *padapter, struct ndis_802_11_var_ies *pIE); -#ifdef CONFIG_8723AU_P2P -int WFD_info_handler(struct rtw_adapter *padapter, - struct ndis_802_11_var_ies *pIE); -#endif void WMMOnAssocRsp23a(struct rtw_adapter *padapter); void HT_caps_handler23a(struct rtw_adapter *padapter, @@ -587,18 +583,6 @@ s32 dump_mgntframe23a_and_wait(struct rtw_adapter *padapter, s32 dump_mgntframe23a_and_wait_ack23a(struct rtw_adapter *padapter, struct xmit_frame *pmgntframe); -#ifdef CONFIG_8723AU_P2P -void issue_probersp23a_p2p23a(struct rtw_adapter *padapter, unsigned char *da); -void issue_p2p_provision_request23a(struct rtw_adapter *padapter, u8 *pssid, - u8 ussidlen, u8* pdev_raddr); -void issue_p2p_GO_request23a(struct rtw_adapter *padapter, u8* raddr); -void issue23a_probereq_p2p(struct rtw_adapter *padapter, u8 *da); -int issue23a_probereq_p2p_ex(struct rtw_adapter *adapter, u8 *da, int try_cnt, - int wait_ms); -void issue_p2p_invitation_response23a(struct rtw_adapter *padapter, u8* raddr, - u8 dialogToken, u8 success); -void issue_p2p_invitation_request23a(struct rtw_adapter *padapter, u8* raddr); -#endif /* CONFIG_8723AU_P2P */ void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms); void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, u8 is_valid_p2p_probereq); diff --git a/drivers/staging/rtl8723au/include/rtw_p2p.h b/drivers/staging/rtl8723au/include/rtw_p2p.h deleted file mode 100644 index 93fdc658ff4d..000000000000 --- a/drivers/staging/rtl8723au/include/rtw_p2p.h +++ /dev/null @@ -1,158 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek 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. - * - ******************************************************************************/ -#ifndef __RTW_P2P_H_ -#define __RTW_P2P_H_ - -#include - -u32 build_beacon_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf); -u32 build_probe_resp_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf); -u32 build_prov_disc_request_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf, - u8 *pssid, u8 ussidlen, u8 *pdev_raddr); -u32 build_assoc_resp_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf, - u8 status_code); -u32 build_deauth_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf); -#ifdef CONFIG_8723AU_P2P -u32 build_probe_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); -u32 build_probe_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, - u8 tunneled); -u32 build_beacon_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); -u32 build_nego_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); -u32 build_nego_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); -u32 build_nego_confirm_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); -u32 build_invitation_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); -u32 build_invitation_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); -u32 build_assoc_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); -u32 build_assoc_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); -u32 build_provdisc_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); -u32 build_provdisc_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); -#endif /* CONFIG_8723AU_P2P */ - -u32 process_probe_req_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pframe, - uint len); -u32 process_assoc_req_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pframe, - uint len, struct sta_info *psta); -u32 process_p2p_devdisc_req23a(struct wifidirect_info *pwdinfo, u8 *pframe, - uint len); -u32 process_p2p_devdisc_resp23a(struct wifidirect_info *pwdinfo, u8 *pframe, - uint len); -u8 process_p2p_provdisc_req23a(struct wifidirect_info *pwdinfo, u8 *pframe, - uint len); -u8 process_p2p_provdisc_resp23a(struct wifidirect_info *pwdinfo, u8 *pframe); -u8 process_p2p_group_negotation_req23a(struct wifidirect_info *pwdinfo, - u8 *pframe, uint len); -u8 process_p2p_group_negotation_resp23a(struct wifidirect_info *pwdinfo, - u8 *pframe, uint len); -u8 process_p2p_group_negotation_confirm23a(struct wifidirect_info *pwdinfo, - u8 *pframe, uint len); -u8 process_p2p_presence_req23a(struct wifidirect_info *pwdinfo, - u8 *pframe, uint len); - -void p2p_protocol_wk_hdl23a(struct rtw_adapter *padapter, int cmdtype); - -#ifdef CONFIG_8723AU_P2P -void process_p2p_ps_ie23a(struct rtw_adapter *padapter, u8 *IEs, u32 IELength); -void p2p_ps_wk_hdl23a(struct rtw_adapter *padapter, u8 p2p_ps_state); -u8 p2p_ps_wk_cmd23a(struct rtw_adapter *padapter, u8 p2p_ps_state, u8 enqueue); -#endif /* CONFIG_8723AU_P2P */ - -void rtw_init_cfg80211_wifidirect_info(struct rtw_adapter *padapter); -int rtw_p2p_check_frames(struct rtw_adapter *padapter, const u8 *buf, - u32 len, u8 tx); -void rtw_append_wfd_ie(struct rtw_adapter *padapter, u8 *buf, u32 *len); - -void reset_global_wifidirect_info23a(struct rtw_adapter *padapter); -int rtw_init_wifi_display_info(struct rtw_adapter *padapter); -void rtw_init_wifidirect_timers23a(struct rtw_adapter *padapter); -void rtw_init_wifidirect_addrs23a(struct rtw_adapter *padapter, u8 *dev_addr, - u8 *iface_addr); -void init_wifidirect_info23a(struct rtw_adapter *padapter, enum P2P_ROLE role); -int rtw_p2p_enable23a(struct rtw_adapter *padapter, enum P2P_ROLE role); - -static inline void _rtw_p2p_set_state(struct wifidirect_info *wdinfo, - enum P2P_STATE state) -{ - if (wdinfo->p2p_state != state) { - /* wdinfo->pre_p2p_state = wdinfo->p2p_state; */ - wdinfo->p2p_state = state; - } -} - -static inline void _rtw_p2p_set_pre_state(struct wifidirect_info *wdinfo, - enum P2P_STATE state) -{ - if (wdinfo->pre_p2p_state != state) - wdinfo->pre_p2p_state = state; -} - -static inline void _rtw_p2p_set_role(struct wifidirect_info *wdinfo, - enum P2P_ROLE role) -{ - if (wdinfo->role != role) - wdinfo->role = role; -} - -static inline int _rtw_p2p_state(struct wifidirect_info *wdinfo) -{ - return wdinfo->p2p_state; -} - -static inline int _rtw_p2p_pre_state(struct wifidirect_info *wdinfo) -{ - return wdinfo->pre_p2p_state; -} - -static inline int _rtw_p2p_role(struct wifidirect_info *wdinfo) -{ - return wdinfo->role; -} - -static inline bool _rtw_p2p_chk_state(struct wifidirect_info *wdinfo, - enum P2P_STATE state) -{ - return wdinfo->p2p_state == state; -} - -static inline bool _rtw_p2p_chk_role(struct wifidirect_info *wdinfo, - enum P2P_ROLE role) -{ - return wdinfo->role == role; -} - -#define rtw_p2p_set_state(wdinfo, state) _rtw_p2p_set_state(wdinfo, state) -#define rtw_p2p_set_pre_state(wdinfo, state) \ - _rtw_p2p_set_pre_state(wdinfo, state) -#define rtw_p2p_set_role(wdinfo, role) _rtw_p2p_set_role(wdinfo, role) - -#define rtw_p2p_state(wdinfo) _rtw_p2p_state(wdinfo) -#define rtw_p2p_pre_state(wdinfo) _rtw_p2p_pre_state(wdinfo) -#define rtw_p2p_role(wdinfo) _rtw_p2p_role(wdinfo) -#define rtw_p2p_chk_state(wdinfo, state) _rtw_p2p_chk_state(wdinfo, state) -#define rtw_p2p_chk_role(wdinfo, role) _rtw_p2p_chk_role(wdinfo, role) - -#define rtw_p2p_findphase_ex_set(wdinfo, value) \ - ((wdinfo)->find_phase_state_exchange_cnt = (value)) - -/* is this find phase exchange for social channel scan? */ -#define rtw_p2p_findphase_ex_is_social(wdinfo) \ - ((wdinfo)->find_phase_state_exchange_cnt >= \ - P2P_FINDPHASE_EX_SOCIAL_FIRST) - -/* should we need find phase exchange anymore? */ -#define rtw_p2p_findphase_ex_is_needed(wdinfo) \ - ((wdinfo)->find_phase_state_exchange_cnt < P2P_FINDPHASE_EX_MAX && \ - (wdinfo)->find_phase_state_exchange_cnt != P2P_FINDPHASE_EX_NONE) - -#endif diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index 57e394543ec1..41af702121c4 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -636,23 +636,6 @@ enum P2P_PROTO_WK_ID { P2P_RO_CH_WK = 6, }; -#ifdef CONFIG_8723AU_P2P -enum P2P_PS_STATE { - P2P_PS_DISABLE = 0, - P2P_PS_ENABLE = 1, - P2P_PS_SCAN = 2, - P2P_PS_SCAN_DONE = 3, - P2P_PS_ALLSTASLEEP = 4, /* for P2P GO */ -}; - -enum P2P_PS_MODE { - P2P_PS_NONE = 0, - P2P_PS_CTWINDOW = 1, - P2P_PS_NOA = 2, - P2P_PS_MIX = 3, /* CTWindow and NoA */ -}; -#endif /* CONFIG_8723AU_P2P */ - /* =====================WFD Section===================== */ /* For Wi-Fi Display */ #define WFD_ATTR_DEVICE_INFO 0x00 diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index a0d59c7963d1..a3e17f99a278 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -357,9 +357,6 @@ void rtw_cfg80211_indicate_connect(struct rtw_adapter *padapter) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_network *cur_network = &pmlmepriv->cur_network; struct wireless_dev *pwdev = padapter->rtw_wdev; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif DBG_8723A("%s(padapter =%p)\n", __func__, padapter); @@ -370,17 +367,6 @@ void rtw_cfg80211_indicate_connect(struct rtw_adapter *padapter) if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) return; -#ifdef CONFIG_8723AU_P2P - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { - rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); - DBG_8723A("%s, role =%d, p2p_state =%d, pre_p2p_state =%d\n", - __func__, rtw_p2p_role(pwdinfo), - rtw_p2p_state(pwdinfo), rtw_p2p_pre_state(pwdinfo)); - } -#endif /* CONFIG_8723AU_P2P */ - if (rtw_to_roaming(padapter) > 0) { struct wiphy *wiphy = pwdev->wiphy; struct ieee80211_channel *notify_channel; @@ -429,9 +415,6 @@ void rtw_cfg80211_indicate_disconnect(struct rtw_adapter *padapter) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wireless_dev *pwdev = padapter->rtw_wdev; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif DBG_8723A("%s(padapter =%p)\n", __func__, padapter); @@ -442,21 +425,6 @@ void rtw_cfg80211_indicate_disconnect(struct rtw_adapter *padapter) if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) return; -#ifdef CONFIG_8723AU_P2P - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { - del_timer_sync(&pwdinfo->find_phase_timer); - del_timer_sync(&pwdinfo->restore_p2p_state_timer); - del_timer_sync(&pwdinfo->pre_tx_scan_timer); - - rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - - DBG_8723A("%s, role =%d, p2p_state =%d, pre_p2p_state =%d\n", - __func__, rtw_p2p_role(pwdinfo), - rtw_p2p_state(pwdinfo), rtw_p2p_pre_state(pwdinfo)); - } -#endif /* CONFIG_8723AU_P2P */ - if (!padapter->mlmepriv.not_indic_disco) { if (check_fwstate(&padapter->mlmepriv, WIFI_UNDER_LINKING)) { cfg80211_connect_result(padapter->pnetdev, NULL, NULL, @@ -921,11 +889,6 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, struct rtw_adapter *padapter = netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv *psecuritypriv = &padapter->securitypriv; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* CONFIG_8723AU_P2P */ - - DBG_8723A("%s\n", __func__); @@ -1080,15 +1043,6 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, rtw_set_key23a(padapter, &padapter->securitypriv, param->u.crypt.idx, 1); -#ifdef CONFIG_8723AU_P2P - if (rtw_p2p_chk_state - (pwdinfo, - P2P_STATE_PROVISIONING_ING)) { - rtw_p2p_set_state(pwdinfo, - P2P_STATE_PROVISIONING_DONE); - } -#endif /* CONFIG_8723AU_P2P */ - } } @@ -1350,9 +1304,6 @@ static int cfg80211_rtw_change_iface(struct wiphy *wiphy, struct rtw_adapter *padapter = wiphy_to_adapter(wiphy); struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct wireless_dev *rtw_wdev = wiphy_to_wdev(wiphy); -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif int ret = 0; u8 change = false; @@ -1384,34 +1335,10 @@ static int cfg80211_rtw_change_iface(struct wiphy *wiphy, case NL80211_IFTYPE_P2P_CLIENT: case NL80211_IFTYPE_STATION: networkType = Ndis802_11Infrastructure; -#ifdef CONFIG_8723AU_P2P - if (change && rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { - del_timer_sync(&pwdinfo->find_phase_timer); - del_timer_sync(&pwdinfo->restore_p2p_state_timer); - del_timer_sync(&pwdinfo->pre_tx_scan_timer); - - /* it means remove GO and change mode from AP(GO) - to station(P2P DEVICE) */ - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); - - DBG_8723A("%s, role =%d, p2p_state =%d, pre_p2p_state =" - "%d\n", __func__, rtw_p2p_role(pwdinfo), - rtw_p2p_state(pwdinfo), - rtw_p2p_pre_state(pwdinfo)); - } -#endif /* CONFIG_8723AU_P2P */ break; case NL80211_IFTYPE_P2P_GO: case NL80211_IFTYPE_AP: networkType = Ndis802_11APMode; -#ifdef CONFIG_8723AU_P2P - if (change && !rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { - /* it means P2P Group created, we will be GO - and change mode from P2P DEVICE to AP(GO) */ - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - } -#endif /* CONFIG_8723AU_P2P */ break; default: return -EOPNOTSUPP; @@ -1486,11 +1413,6 @@ static int rtw_cfg80211_set_probe_req_wpsp2pie(struct rtw_adapter *padapter, int ret = 0; uint wps_ielen = 0; u8 *wps_ie; -#ifdef CONFIG_8723AU_P2P - u32 p2p_ielen = 0; - u8 *p2p_ie; - u32 wfd_ielen = 0; -#endif struct mlme_priv *pmlmepriv = &padapter->mlmepriv; DBG_8723A("%s, ielen =%d\n", __func__, len); @@ -1516,56 +1438,6 @@ static int rtw_cfg80211_set_probe_req_wpsp2pie(struct rtw_adapter *padapter, memcpy(pmlmepriv->wps_probe_req_ie, wps_ie, wps_ielen); pmlmepriv->wps_probe_req_ie_len = wps_ielen; } -#ifdef CONFIG_8723AU_P2P - p2p_ie = rtw_get_p2p_ie23a(buf, len, NULL, &p2p_ielen); - if (p2p_ie) { - DBG_8723A("probe_req_p2p_ielen =%d\n", p2p_ielen); - - if (pmlmepriv->p2p_probe_req_ie) { - pmlmepriv->p2p_probe_req_ie_len = 0; - kfree(pmlmepriv->p2p_probe_req_ie); - pmlmepriv->p2p_probe_req_ie = NULL; - } - - pmlmepriv->p2p_probe_req_ie = - kmalloc(p2p_ielen, GFP_KERNEL); - if (pmlmepriv->p2p_probe_req_ie == NULL) { - DBG_8723A("%s()-%d: kmalloc() ERROR!\n", - __func__, __LINE__); - return -EINVAL; - - } - memcpy(pmlmepriv->p2p_probe_req_ie, p2p_ie, p2p_ielen); - pmlmepriv->p2p_probe_req_ie_len = p2p_ielen; - } -#endif /* CONFIG_8723AU_P2P */ - - /* buf += p2p_ielen; */ - /* len -= p2p_ielen; */ - -#ifdef CONFIG_8723AU_P2P - if (rtw_get_wfd_ie(buf, len, NULL, &wfd_ielen)) { - DBG_8723A("probe_req_wfd_ielen =%d\n", wfd_ielen); - - if (pmlmepriv->wfd_probe_req_ie) { - pmlmepriv->wfd_probe_req_ie_len = 0; - kfree(pmlmepriv->wfd_probe_req_ie); - pmlmepriv->wfd_probe_req_ie = NULL; - } - - pmlmepriv->wfd_probe_req_ie = - kmalloc(wfd_ielen, GFP_KERNEL); - if (pmlmepriv->wfd_probe_req_ie == NULL) { - DBG_8723A("%s()-%d: kmalloc() ERROR!\n", - __func__, __LINE__); - return -EINVAL; - - } - rtw_get_wfd_ie(buf, len, pmlmepriv->wfd_probe_req_ie, - &pmlmepriv->wfd_probe_req_ie_len); - } -#endif /* CONFIG_8723AU_P2P */ - } return ret; @@ -1583,10 +1455,6 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy, struct rtw_ieee80211_channel ch[RTW_CHANNEL_SCAN_AMOUNT]; struct rtw_wdev_priv *pwdev_priv = wdev_to_priv(padapter->rtw_wdev); struct cfg80211_ssid *ssids = request->ssids; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - int social_channel = 0; -#endif /* CONFIG_8723AU_P2P */ bool need_indicate_scan_done = false; DBG_8723A(FUNC_ADPT_FMT "\n", FUNC_ADPT_ARG(padapter)); @@ -1605,27 +1473,6 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy, need_indicate_scan_done = true; goto check_need_indicate_scan_done; } -#ifdef CONFIG_8723AU_P2P - if (!memcmp(ssids->ssid, "DIRECT-", 7) && - rtw_get_p2p_ie23a((u8 *) request->ie, request->ie_len, NULL, NULL)) { - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { - rtw_p2p_enable23a(padapter, P2P_ROLE_DEVICE); - wdev_to_priv(padapter->rtw_wdev)->p2p_enabled = true; - } else { - rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); - DBG_8723A("%s, role =%d, p2p_state =%d\n", __func__, - rtw_p2p_role(pwdinfo), - rtw_p2p_state(pwdinfo)); - } - rtw_p2p_set_state(pwdinfo, P2P_STATE_LISTEN); - - if (request->n_channels == 3 && - request->channels[0]->hw_value == 1 && - request->channels[1]->hw_value == 6 && - request->channels[2]->hw_value == 11) - social_channel = 1; - } -#endif /* CONFIG_8723AU_P2P */ if (request->ie && request->ie_len > 0) { rtw_cfg80211_set_probe_req_wpsp2pie(padapter, @@ -1651,20 +1498,6 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy, need_indicate_scan_done = true; goto check_need_indicate_scan_done; } -#ifdef CONFIG_8723AU_P2P - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) && - !rtw_p2p_chk_state(pwdinfo, P2P_STATE_IDLE)) { - rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH); - rtw_free_network_queue23a(padapter, true); - - if (social_channel == 0) - rtw_p2p_findphase_ex_set(pwdinfo, - P2P_FINDPHASE_EX_NONE); - else - rtw_p2p_findphase_ex_set(pwdinfo, - P2P_FINDPHASE_EX_SOCIAL_LAST); - } -#endif /* CONFIG_8723AU_P2P */ memset(ssid, 0, sizeof(struct cfg80211_ssid) * RTW_SSID_SCAN_AMOUNT); /* parsing request ssids, n_ssids */ @@ -2001,64 +1834,6 @@ static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie, } } -#ifdef CONFIG_8723AU_P2P - { /* check p2p_ie for assoc req; */ - uint p2p_ielen = 0; - u8 *p2p_ie; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - p2p_ie = rtw_get_p2p_ie23a(buf, ielen, NULL, &p2p_ielen); - if (p2p_ie) { - DBG_8723A("%s p2p_assoc_req_ielen =%d\n", __func__, - p2p_ielen); - - if (pmlmepriv->p2p_assoc_req_ie) { - pmlmepriv->p2p_assoc_req_ie_len = 0; - kfree(pmlmepriv->p2p_assoc_req_ie); - pmlmepriv->p2p_assoc_req_ie = NULL; - } - - pmlmepriv->p2p_assoc_req_ie = - kmalloc(p2p_ielen, GFP_KERNEL); - if (pmlmepriv->p2p_assoc_req_ie == NULL) { - DBG_8723A("%s()-%d: kmalloc() ERROR!\n", - __func__, __LINE__); - goto exit; - } - memcpy(pmlmepriv->p2p_assoc_req_ie, p2p_ie, p2p_ielen); - pmlmepriv->p2p_assoc_req_ie_len = p2p_ielen; - } - } -#endif /* CONFIG_8723AU_P2P */ - -#ifdef CONFIG_8723AU_P2P - { /* check wfd_ie for assoc req; */ - uint wfd_ielen = 0; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - if (rtw_get_wfd_ie(buf, ielen, NULL, &wfd_ielen)) { - DBG_8723A("%s wfd_assoc_req_ielen =%d\n", __func__, - wfd_ielen); - - if (pmlmepriv->wfd_assoc_req_ie) { - pmlmepriv->wfd_assoc_req_ie_len = 0; - kfree(pmlmepriv->wfd_assoc_req_ie); - pmlmepriv->wfd_assoc_req_ie = NULL; - } - - pmlmepriv->wfd_assoc_req_ie = - kmalloc(wfd_ielen, GFP_KERNEL); - if (pmlmepriv->wfd_assoc_req_ie == NULL) { - DBG_8723A("%s()-%d: kmalloc() ERROR!\n", - __func__, __LINE__); - goto exit; - } - rtw_get_wfd_ie(buf, ielen, pmlmepriv->wfd_assoc_req_ie, - &pmlmepriv->wfd_assoc_req_ie_len); - } - } -#endif /* CONFIG_8723AU_P2P */ - /* TKIP and AES disallow multicast packets until installing group key */ if (padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_ || padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_WTMIC_ || @@ -2707,9 +2482,6 @@ static int rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; u32 len = skb->len; u8 category, action; -#ifdef CONFIG_8723AU_P2P - int type = -1; -#endif if (rtw_action_frame_parse23a(skb->data, len, &category, &action) == false) { @@ -2721,19 +2493,12 @@ static int rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, DBG_8723A("RTW_Tx:da =" MAC_FMT " via " FUNC_NDEV_FMT "\n", MAC_ARG(dot11_hdr->addr1), FUNC_NDEV_ARG(ndev)); -#ifdef CONFIG_8723AU_P2P - type = rtw_p2p_check_frames(padapter, skb->data, len, true); - if (type >= 0) - goto dump; -#endif if (category == WLAN_CATEGORY_PUBLIC) DBG_8723A("RTW_Tx:%s\n", action_public_str23a(action)); else DBG_8723A("RTW_Tx:category(%u), action(%u)\n", category, action); -#ifdef CONFIG_8723AU_P2P -dump: -#endif + /* starting alloc mgmt frame to dump it */ pmgntframe = alloc_mgtxmitframe23a(pxmitpriv); if (pmgntframe == NULL) @@ -2749,16 +2514,6 @@ dump: pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; memcpy(pframe, skb->data, len); -#ifdef CONFIG_8723AU_P2P - if (type >= 0) { - struct wifi_display_info *pwfd_info; - - pwfd_info = padapter->wdinfo.wfd_info; - - if (pwfd_info->wfd_enable) - rtw_append_wfd_ie(padapter, pframe, &len); - } -#endif /* CONFIG_8723AU_P2P */ pattrib->pktlen = len; /* update seq number */ @@ -2944,10 +2699,6 @@ static int rtw_add_beacon(struct rtw_adapter *adapter, const u8 *head, int ret = 0; u8 *pbuf = NULL; uint len, wps_ielen = 0; -#ifdef CONFIG_8723AU_P2P - uint p2p_ielen = 0; - u8 got_p2p_ie = false; -#endif struct mlme_priv *pmlmepriv = &adapter->mlmepriv; /* struct sta_priv *pstapriv = &padapter->stapriv; */ @@ -2975,16 +2726,6 @@ static int rtw_add_beacon(struct rtw_adapter *adapter, const u8 *head, &wps_ielen)) DBG_8723A("add bcn, wps_ielen =%d\n", wps_ielen); -#ifdef CONFIG_8723AU_P2P - /* check p2p ie if inclued */ - if (rtw_get_p2p_ie23a - (pbuf + _FIXED_IE_LENGTH_, len - _FIXED_IE_LENGTH_, NULL, - &p2p_ielen)) { - DBG_8723A("got p2p_ie, len =%d\n", p2p_ielen); - got_p2p_ie = true; - } -#endif - /* pbss_network->IEs will not include p2p_ie, wfd ie */ rtw_ies_remove_ie23a(pbuf, &len, _BEACON_IE_OFFSET_, WLAN_EID_VENDOR_SPECIFIC, P2P_OUI23A, 4); @@ -2992,38 +2733,7 @@ static int rtw_add_beacon(struct rtw_adapter *adapter, const u8 *head, WLAN_EID_VENDOR_SPECIFIC, WFD_OUI23A, 4); if (rtw_check_beacon_data23a(adapter, pbuf, len) == _SUCCESS) { -#ifdef CONFIG_8723AU_P2P - /* check p2p if enable */ - if (got_p2p_ie == true) { - struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; - struct wifidirect_info *pwdinfo = &adapter->wdinfo; - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { - DBG_8723A("Enable P2P function for the first " - "time\n"); - rtw_p2p_enable23a(adapter, P2P_ROLE_GO); - wdev_to_priv(adapter->rtw_wdev)->p2p_enabled = - true; - } else { - del_timer_sync(&pwdinfo->find_phase_timer); - del_timer_sync(&pwdinfo-> - restore_p2p_state_timer); - del_timer_sync(&pwdinfo->pre_tx_scan_timer); - - DBG_8723A("enter GO Mode, p2p_ielen =%d\n", - p2p_ielen); - - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); - pwdinfo->intent = 15; - } - - pwdinfo->operating_channel = pmlmeext->cur_channel; - } -#endif /* CONFIG_8723AU_P2P */ - ret = 0; - } else { ret = -EINVAL; } @@ -3220,9 +2930,6 @@ static int cfg80211_rtw_change_bss(struct wiphy *wiphy, struct net_device *ndev, void rtw_cfg80211_rx_action_p2p(struct rtw_adapter *padapter, u8 *pmgmt_frame, uint frame_len) { -#ifdef CONFIG_8723AU_P2P - int type; -#endif s32 freq; int channel; u8 category, action; @@ -3230,17 +2937,9 @@ void rtw_cfg80211_rx_action_p2p(struct rtw_adapter *padapter, u8 *pmgmt_frame, channel = rtw_get_oper_ch23a(padapter); DBG_8723A("RTW_Rx:cur_ch =%d\n", channel); -#ifdef CONFIG_8723AU_P2P - type = rtw_p2p_check_frames(padapter, pmgmt_frame, frame_len, false); - if (type >= 0) - goto indicate; -#endif rtw_action_frame_parse23a(pmgmt_frame, frame_len, &category, &action); DBG_8723A("RTW_Rx:category(%u), action(%u)\n", category, action); -#ifdef CONFIG_8723AU_P2P -indicate: -#endif if (channel <= RTW_CH_MAX_2G_CHANNEL) freq = ieee80211_channel_to_frequency(channel, IEEE80211_BAND_2GHZ); @@ -3255,9 +2954,6 @@ indicate: void rtw_cfg80211_rx_p2p_action_public(struct rtw_adapter *padapter, u8 *pmgmt_frame, uint frame_len) { -#ifdef CONFIG_8723AU_P2P - int type; -#endif s32 freq; int channel; u8 category, action; @@ -3265,23 +2961,9 @@ void rtw_cfg80211_rx_p2p_action_public(struct rtw_adapter *padapter, channel = rtw_get_oper_ch23a(padapter); DBG_8723A("RTW_Rx:cur_ch =%d\n", channel); -#ifdef CONFIG_8723AU_P2P - type = rtw_p2p_check_frames(padapter, pmgmt_frame, frame_len, false); - if (type >= 0) { - switch (type) { - case P2P_GO_NEGO_CONF: - case P2P_PROVISION_DISC_RESP: - rtw_clear_scan_deny(padapter); - } - goto indicate; - } -#endif rtw_action_frame_parse23a(pmgmt_frame, frame_len, &category, &action); DBG_8723A("RTW_Rx:category(%u), action(%u)\n", category, action); -#ifdef CONFIG_8723AU_P2P -indicate: -#endif if (channel <= RTW_CH_MAX_2G_CHANNEL) freq = ieee80211_channel_to_frequency(channel, IEEE80211_BAND_2GHZ); @@ -3321,346 +3003,6 @@ void rtw_cfg80211_rx_action(struct rtw_adapter *adapter, u8 *frame, rtw_cfg80211_rx_mgmt(adapter, freq, 0, frame, frame_len, GFP_ATOMIC); } -#ifdef CONFIG_8723AU_P2P -void rtw_cfg80211_issue_p2p_provision_request23a(struct rtw_adapter *padapter, - const u8 *buf, size_t len) -{ - u16 wps_devicepassword_id = 0x0000; - uint wps_devicepassword_id_len = 0; - u8 wpsie[255] = { 0x00 }, p2p_ie[255] = { 0x00 }; - uint p2p_ielen = 0; - uint wpsielen = 0; - u32 devinfo_contentlen = 0; - u8 devinfo_content[64] = { 0x00 }; - u16 capability = 0; - uint capability_len = 0; - - unsigned char category = WLAN_CATEGORY_PUBLIC; - u8 action = P2P_PUB_ACTION_ACTION; - u8 dialogToken = 1; - u32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_PROVISION_DISC_REQ; - u32 p2pielen = 0; -#ifdef CONFIG_8723AU_P2P - u32 wfdielen = 0; -#endif /* CONFIG_8723AU_P2P */ - - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr, *hdr; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - u8 *frame_body = - (unsigned char *)(buf + sizeof(struct ieee80211_hdr_3addr)); - size_t frame_body_len = len - sizeof(struct ieee80211_hdr_3addr); - - DBG_8723A("[%s] In\n", __func__); - - hdr = (struct ieee80211_hdr *)buf; - /* prepare for building provision_request frame */ - memcpy(pwdinfo->tx_prov_disc_info.peerIFAddr, hdr->addr1, ETH_ALEN); - memcpy(pwdinfo->tx_prov_disc_info.peerDevAddr, hdr->addr1, ETH_ALEN); - - pwdinfo->tx_prov_disc_info.wps_config_method_request = - WPS_CM_PUSH_BUTTON; - - rtw_get_wps_ie23a(frame_body + _PUBLIC_ACTION_IE_OFFSET_, - frame_body_len - _PUBLIC_ACTION_IE_OFFSET_, wpsie, - &wpsielen); - rtw_get_wps_attr_content23a(wpsie, wpsielen, WPS_ATTR_DEVICE_PWID, - (u8 *)&wps_devicepassword_id, - &wps_devicepassword_id_len); - wps_devicepassword_id = be16_to_cpu(wps_devicepassword_id); - - switch (wps_devicepassword_id) { - case WPS_DPID_PIN: - pwdinfo->tx_prov_disc_info.wps_config_method_request = - WPS_CM_LABEL; - break; - case WPS_DPID_USER_SPEC: - pwdinfo->tx_prov_disc_info.wps_config_method_request = - WPS_CM_DISPLYA; - break; - case WPS_DPID_MACHINE_SPEC: - break; - case WPS_DPID_REKEY: - break; - case WPS_DPID_PBC: - pwdinfo->tx_prov_disc_info.wps_config_method_request = - WPS_CM_PUSH_BUTTON; - break; - case WPS_DPID_REGISTRAR_SPEC: - pwdinfo->tx_prov_disc_info.wps_config_method_request = - WPS_CM_KEYPAD; - break; - default: - break; - } - - if (rtw_get_p2p_ie23a(frame_body + _PUBLIC_ACTION_IE_OFFSET_, - frame_body_len - _PUBLIC_ACTION_IE_OFFSET_, - p2p_ie, &p2p_ielen)) { - rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, - P2P_ATTR_DEVICE_INFO, devinfo_content, - &devinfo_contentlen); - rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_CAPABILITY, - (u8 *)&capability, &capability_len); - } - - /* start to build provision_request frame */ - memset(wpsie, 0, sizeof(wpsie)); - memset(p2p_ie, 0, sizeof(p2p_ie)); - p2p_ielen = 0; - - pmgntframe = alloc_mgtxmitframe23a(pxmitpriv); - if (pmgntframe == NULL) - return; - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib23a(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *) (pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - pwlanhdr->frame_control = 0; - - memcpy(pwlanhdr->addr1, pwdinfo->tx_prov_disc_info.peerDevAddr, - ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); - memcpy(pwlanhdr->addr3, pwdinfo->tx_prov_disc_info.peerDevAddr, - ETH_ALEN); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_ACTION); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *)&p2poui, - &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &dialogToken, &pattrib->pktlen); - - /* build_prov_disc_request_p2p_ie23a */ - /* P2P OUI */ - p2pielen = 0; - p2p_ie[p2pielen++] = 0x50; - p2p_ie[p2pielen++] = 0x6F; - p2p_ie[p2pielen++] = 0x9A; - p2p_ie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20110301 */ - /* According to the P2P Specification, the provision discovery request frame should contain 3 P2P attributes */ - /* 1. P2P Capability */ - /* 2. Device Info */ - /* 3. Group ID ( When joining an operating P2P Group ) */ - - /* P2P Capability ATTR */ - /* Type: */ - p2p_ie[p2pielen++] = P2P_ATTR_CAPABILITY; - - /* Length: */ - put_unaligned_le16(0x0002, p2p_ie + p2pielen); - p2pielen += 2; - - /* Value: */ - /* Device Capability Bitmap, 1 byte */ - /* Group Capability Bitmap, 1 byte */ - memcpy(p2p_ie + p2pielen, &capability, 2); - p2pielen += 2; - - /* Device Info ATTR */ - /* Type: */ - p2p_ie[p2pielen++] = P2P_ATTR_DEVICE_INFO; - - /* Length: */ - put_unaligned_le16(devinfo_contentlen, p2p_ie + p2pielen); - p2pielen += 2; - - /* Value: */ - memcpy(p2p_ie + p2pielen, devinfo_content, devinfo_contentlen); - p2pielen += devinfo_contentlen; - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, - (unsigned char *)p2p_ie, &p2p_ielen); - pattrib->pktlen += p2p_ielen; - - wpsielen = 0; - /* WPS OUI */ - *(u32 *)(wpsie) = cpu_to_be32(WPSOUI); - wpsielen += 4; - - /* WPS version */ - /* Type: */ - *(u16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1); - wpsielen += 2; - - /* Length: */ - *(u16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001); - wpsielen += 2; - - /* Value: */ - wpsie[wpsielen++] = WPS_VERSION_1; /* Version 1.0 */ - - /* Config Method */ - /* Type: */ - *(u16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_CONF_METHOD); - wpsielen += 2; - - /* Length: */ - *(u16 *)(wpsie + wpsielen) = cpu_to_be16(0x0002); - wpsielen += 2; - - /* Value: */ - *(u16 *)(wpsie + wpsielen) = - cpu_to_be16(pwdinfo->tx_prov_disc_info.wps_config_method_request); - wpsielen += 2; - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, wpsielen, - (unsigned char *)wpsie, &pattrib->pktlen); - -#ifdef CONFIG_8723AU_P2P - wfdielen = build_provdisc_req_wfd_ie(pwdinfo, pframe); - pframe += wfdielen; - pattrib->pktlen += wfdielen; -#endif /* CONFIG_8723AU_P2P */ - - pattrib->last_txcmdsz = pattrib->pktlen; - - /* dump_mgntframe23a(padapter, pmgntframe); */ - if (dump_mgntframe23a_and_wait_ack23a(padapter, pmgntframe) != _SUCCESS) - DBG_8723A("%s, ack to\n", __func__); -} - -static s32 cfg80211_rtw_remain_on_channel(struct wiphy *wiphy, - struct wireless_dev *wdev, - struct ieee80211_channel *channel, - unsigned int duration, u64 *cookie) -{ - s32 err = 0; - struct rtw_adapter *padapter = wiphy_to_adapter(wiphy); - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - struct cfg80211_wifidirect_info *pcfg80211_wdinfo = - &padapter->cfg80211_wdinfo; - u8 remain_ch = - (u8) ieee80211_frequency_to_channel(channel->center_freq); - u8 ready_on_channel = false; - - DBG_8723A(FUNC_ADPT_FMT " ch:%u duration:%d\n", FUNC_ADPT_ARG(padapter), - remain_ch, duration); - - if (pcfg80211_wdinfo->is_ro_ch == true) { - DBG_8723A("%s, cancel ro ch timer\n", __func__); - - del_timer_sync(&padapter->cfg80211_wdinfo.remain_on_ch_timer); - -#ifdef CONFIG_8723AU_P2P - p2p_protocol_wk_hdl23a(padapter, P2P_RO_CH_WK); -#endif - } - - pcfg80211_wdinfo->is_ro_ch = true; - - if (_FAIL == rtw_pwr_wakeup(padapter)) { - err = -EFAULT; - goto exit; - } - - memcpy(&pcfg80211_wdinfo->remain_on_ch_channel, channel, - sizeof(struct ieee80211_channel)); - pcfg80211_wdinfo->remain_on_ch_cookie = *cookie; - - rtw_scan_abort23a(padapter); - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { - rtw_p2p_enable23a(padapter, P2P_ROLE_DEVICE); - wdev_to_priv(padapter->rtw_wdev)->p2p_enabled = true; - } else { - rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); - DBG_8723A("%s, role =%d, p2p_state =%d\n", __func__, - rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo)); - } - - rtw_p2p_set_state(pwdinfo, P2P_STATE_LISTEN); - - if (duration < 400) - duration = duration * 3; /* extend from exper. */ - - pcfg80211_wdinfo->restore_channel = pmlmeext->cur_channel; - - if (rtw_ch_set_search_ch23a(pmlmeext->channel_set, remain_ch) >= 0) { - if (remain_ch != pmlmeext->cur_channel) { - ready_on_channel = true; - } - } else { - DBG_8723A("%s remain_ch:%u not in channel plan!!!!\n", - __func__, remain_ch); - } - - /* call this after other things have been done */ - if (ready_on_channel == true) { - if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { - pmlmeext->cur_channel = remain_ch; - - set_channel_bwmode23a(padapter, remain_ch, - HAL_PRIME_CHNL_OFFSET_DONT_CARE, - HT_CHANNEL_WIDTH_20); - } - } - DBG_8723A("%s, set ro ch timer, duration =%d\n", __func__, duration); - mod_timer(&pcfg80211_wdinfo->remain_on_ch_timer, - jiffies + msecs_to_jiffies(duration)); - - rtw_cfg80211_ready_on_channel(padapter, *cookie, channel, channel_type, - duration, GFP_KERNEL); - - pwdinfo->listen_channel = pmlmeext->cur_channel; - -exit: - if (err) - pcfg80211_wdinfo->is_ro_ch = false; - - return err; -} - -static s32 cfg80211_rtw_cancel_remain_on_channel(struct wiphy *wiphy, - struct wireless_dev *wdev, - u64 cookie) -{ - s32 err = 0; - struct rtw_adapter *padapter = wiphy_to_adapter(wiphy); - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - struct cfg80211_wifidirect_info *pcfg80211_wdinfo = - &padapter->cfg80211_wdinfo; - - DBG_8723A(FUNC_ADPT_FMT "\n", FUNC_ADPT_ARG(padapter)); - - if (pcfg80211_wdinfo->is_ro_ch == true) { - DBG_8723A("%s, cancel ro ch timer\n", __func__); - del_timer_sync(&padapter->cfg80211_wdinfo.remain_on_ch_timer); -#ifdef CONFIG_8723AU_P2P - p2p_protocol_wk_hdl23a(padapter, P2P_RO_CH_WK); -#endif - } - - rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); - DBG_8723A("%s, role =%d, p2p_state =%d\n", __func__, - rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo)); - pcfg80211_wdinfo->is_ro_ch = false; - - return err; -} - -#endif /* CONFIG_8723AU_P2P */ - static int _cfg80211_rtw_mgmt_tx(struct rtw_adapter *padapter, u8 tx_ch, const u8 *buf, size_t len) { @@ -3672,7 +3014,6 @@ static int _cfg80211_rtw_mgmt_tx(struct rtw_adapter *padapter, u8 tx_ch, struct ieee80211_hdr *pwlanhdr; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - /* struct cfg80211_wifidirect_info *pcfg80211_wdinfo = &padapter->cfg80211_wdinfo; */ if (_FAIL == rtw_pwr_wakeup(padapter)) { ret = -EFAULT; @@ -3717,18 +3058,6 @@ static int _cfg80211_rtw_mgmt_tx(struct rtw_adapter *padapter, u8 tx_ch, pattrib->seqnum = pmlmeext->mgnt_seq; pmlmeext->mgnt_seq++; -#ifdef CONFIG_8723AU_P2P - { - struct wifi_display_info *pwfd_info; - - pwfd_info = padapter->wdinfo.wfd_info; - - if (true == pwfd_info->wfd_enable) { - rtw_append_wfd_ie(padapter, pframe, &pattrib->pktlen); - } - } -#endif /* CONFIG_8723AU_P2P */ - pattrib->last_txcmdsz = pattrib->pktlen; if (dump_mgntframe23a_and_wait_ack23a(padapter, pmgntframe) != _SUCCESS) { @@ -3798,20 +3127,12 @@ static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, DBG_8723A("RTW_Tx:tx_ch =%d, da =" MAC_FMT "\n", tx_ch, MAC_ARG(hdr->addr1)); -#ifdef CONFIG_8723AU_P2P - type = rtw_p2p_check_frames(padapter, buf, len, true); - if (type >= 0) - goto dump; -#endif if (category == WLAN_CATEGORY_PUBLIC) DBG_8723A("RTW_Tx:%s\n", action_public_str23a(action)); else DBG_8723A("RTW_Tx:category(%u), action(%u)\n", category, action); -#ifdef CONFIG_8723AU_P2P -dump: -#endif do { dump_cnt++; tx_ret = _cfg80211_rtw_mgmt_tx(padapter, tx_ch, buf, len); @@ -3861,11 +3182,6 @@ static int rtw_cfg80211_set_beacon_wpsp2pie(struct net_device *ndev, char *buf, int ret = 0; uint wps_ielen = 0; u8 *wps_ie; -#ifdef CONFIG_8723AU_P2P - u32 p2p_ielen = 0; - u32 wfd_ielen = 0; - u8 *p2p_ie; -#endif #ifdef CONFIG_8723AU_AP_MODE u8 wps_oui[8] = { 0x0, 0x50, 0xf2, 0x04 }; #endif @@ -3901,55 +3217,6 @@ static int rtw_cfg80211_set_beacon_wpsp2pie(struct net_device *ndev, char *buf, wps_oui, true); #endif } -#ifdef CONFIG_8723AU_P2P - p2p_ie = rtw_get_p2p_ie23a(buf, len, NULL, &p2p_ielen); - if (p2p_ie) { - DBG_8723A("bcn_p2p_ielen =%d\n", p2p_ielen); - - if (pmlmepriv->p2p_beacon_ie) { - pmlmepriv->p2p_beacon_ie_len = 0; - kfree(pmlmepriv->p2p_beacon_ie); - pmlmepriv->p2p_beacon_ie = NULL; - } - - pmlmepriv->p2p_beacon_ie = - kmalloc(p2p_ielen, GFP_KERNEL); - if (pmlmepriv->p2p_beacon_ie == NULL) { - DBG_8723A("%s()-%d: kmalloc() ERROR!\n", - __func__, __LINE__); - return -EINVAL; - } - - memcpy(pmlmepriv->p2p_beacon_ie, p2p_ie, p2p_ielen); - pmlmepriv->p2p_beacon_ie_len = p2p_ielen; - } -#endif /* CONFIG_8723AU_P2P */ - - /* buf += p2p_ielen; */ - /* len -= p2p_ielen; */ - -#ifdef CONFIG_8723AU_P2P - if (rtw_get_wfd_ie(buf, len, NULL, &wfd_ielen)) { - DBG_8723A("bcn_wfd_ielen =%d\n", wfd_ielen); - - if (pmlmepriv->wfd_beacon_ie) { - pmlmepriv->wfd_beacon_ie_len = 0; - kfree(pmlmepriv->wfd_beacon_ie); - pmlmepriv->wfd_beacon_ie = NULL; - } - - pmlmepriv->wfd_beacon_ie = - kmalloc(wfd_ielen, GFP_KERNEL); - if (pmlmepriv->wfd_beacon_ie == NULL) { - DBG_8723A("%s()-%d: kmalloc() ERROR!\n", - __func__, __LINE__); - return -EINVAL; - - } - rtw_get_wfd_ie(buf, len, pmlmepriv->wfd_beacon_ie, - &pmlmepriv->wfd_beacon_ie_len); - } -#endif /* CONFIG_8723AU_P2P */ pmlmeext->bstart_bss = true; @@ -3963,11 +3230,6 @@ static int rtw_cfg80211_set_probe_resp_wpsp2pie(struct net_device *net, { struct rtw_adapter *padapter = netdev_priv(net); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -#ifdef CONFIG_8723AU_P2P - u32 p2p_ielen = 0; - u8 *p2p_ie; - u32 wfd_ielen = 0; -#endif int ret = 0; uint wps_ielen = 0; u8 *wps_ie; @@ -4011,100 +3273,6 @@ static int rtw_cfg80211_set_probe_resp_wpsp2pie(struct net_device *net, } - /* buf += wps_ielen; */ - /* len -= wps_ielen; */ - -#ifdef CONFIG_8723AU_P2P - p2p_ie = rtw_get_p2p_ie23a(buf, len, NULL, &p2p_ielen); - if (p2p_ie) { - u8 is_GO = false; - u32 attr_contentlen = 0; - u16 cap_attr = 0; - - DBG_8723A("probe_resp_p2p_ielen =%d\n", p2p_ielen); - - /* Check P2P Capability ATTR */ - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, - P2P_ATTR_CAPABILITY, - (u8 *) &cap_attr, - (uint *) &attr_contentlen)) { - u8 grp_cap = 0; - /* DBG_8723A( "[%s] Got P2P Capability Attr!!\n", __func__ ); */ - cap_attr = le16_to_cpu(cap_attr); - grp_cap = (u8) ((cap_attr >> 8) & 0xff); - - is_GO = (grp_cap & BIT(0)) ? true : false; - - if (is_GO) - DBG_8723A - ("Got P2P Capability Attr, grp_cap" - "= 0x%x, is_GO\n", grp_cap); - } - - if (is_GO == false) { - if (pmlmepriv->p2p_probe_resp_ie) { - pmlmepriv->p2p_probe_resp_ie_len = 0; - kfree(pmlmepriv->p2p_probe_resp_ie); - pmlmepriv->p2p_probe_resp_ie = NULL; - } - - pmlmepriv->p2p_probe_resp_ie = - kmalloc(p2p_ielen, GFP_KERNEL); - if (pmlmepriv->p2p_probe_resp_ie == NULL) { - DBG_8723A("%s()-%d: kmalloc() ERROR!\n", - __func__, __LINE__); - return -EINVAL; - } - memcpy(pmlmepriv->p2p_probe_resp_ie, p2p_ie, - p2p_ielen); - pmlmepriv->p2p_probe_resp_ie_len = p2p_ielen; - } else { - if (pmlmepriv->p2p_go_probe_resp_ie) { - pmlmepriv->p2p_go_probe_resp_ie_len = 0; - kfree(pmlmepriv->p2p_go_probe_resp_ie); - pmlmepriv->p2p_go_probe_resp_ie = NULL; - } - - pmlmepriv->p2p_go_probe_resp_ie = - kmalloc(p2p_ielen, GFP_KERNEL); - if (pmlmepriv->p2p_go_probe_resp_ie == NULL) { - DBG_8723A("%s()-%d: kmalloc() ERROR!\n", - __func__, __LINE__); - return -EINVAL; - - } - memcpy(pmlmepriv->p2p_go_probe_resp_ie, - p2p_ie, p2p_ielen); - pmlmepriv->p2p_go_probe_resp_ie_len = p2p_ielen; - } - } -#endif /* CONFIG_8723AU_P2P */ - - /* buf += p2p_ielen; */ - /* len -= p2p_ielen; */ - -#ifdef CONFIG_8723AU_P2P - if (rtw_get_wfd_ie(buf, len, NULL, &wfd_ielen)) { - DBG_8723A("probe_resp_wfd_ielen =%d\n", wfd_ielen); - - if (pmlmepriv->wfd_probe_resp_ie) { - pmlmepriv->wfd_probe_resp_ie_len = 0; - kfree(pmlmepriv->wfd_probe_resp_ie); - pmlmepriv->wfd_probe_resp_ie = NULL; - } - - pmlmepriv->wfd_probe_resp_ie = - kmalloc(wfd_ielen, GFP_KERNEL); - if (pmlmepriv->wfd_probe_resp_ie == NULL) { - DBG_8723A("%s()-%d: kmalloc() ERROR!\n", - __func__, __LINE__); - return -EINVAL; - - } - rtw_get_wfd_ie(buf, len, pmlmepriv->wfd_probe_resp_ie, - &pmlmepriv->wfd_probe_resp_ie_len); - } -#endif /* CONFIG_8723AU_P2P */ } return ret; @@ -4145,17 +3313,10 @@ int rtw_cfg80211_set_mgnt_wpsp2pie(struct net_device *net, char *buf, int len, { int ret = 0; uint wps_ielen = 0; -#ifdef CONFIG_8723AU_P2P - u32 p2p_ielen = 0; -#endif DBG_8723A("%s, ielen =%d\n", __func__, len); - if ((rtw_get_wps_ie23a(buf, len, NULL, &wps_ielen) && (wps_ielen > 0)) -#ifdef CONFIG_8723AU_P2P - || (rtw_get_p2p_ie23a(buf, len, NULL, &p2p_ielen) && (p2p_ielen > 0)) -#endif - ) { + if (rtw_get_wps_ie23a(buf, len, NULL, &wps_ielen) && (wps_ielen > 0)) { if (net) { switch (type) { case 0x1: /* BEACON */ @@ -4218,11 +3379,6 @@ static struct cfg80211_ops rtw_cfg80211_ops = { .change_bss = cfg80211_rtw_change_bss, #endif /* CONFIG_8723AU_AP_MODE */ -#ifdef CONFIG_8723AU_P2P - .remain_on_channel = cfg80211_rtw_remain_on_channel, - .cancel_remain_on_channel = cfg80211_rtw_cancel_remain_on_channel, -#endif - .mgmt_tx = cfg80211_rtw_mgmt_tx, .mgmt_frame_register = cfg80211_rtw_mgmt_frame_register, }; @@ -4325,9 +3481,6 @@ static void rtw_cfg80211_preinit_wiphy(struct rtw_adapter *padapter, BIT(NL80211_IFTYPE_ADHOC) | #ifdef CONFIG_8723AU_AP_MODE BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR) | -#endif -#if defined(CONFIG_8723AU_P2P) - BIT(NL80211_IFTYPE_P2P_CLIENT) | BIT(NL80211_IFTYPE_P2P_GO) | #endif 0; diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index 7c7c2c93e413..49da7dd18171 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -455,9 +455,6 @@ static u8 rtw_init_default_value(struct rtw_adapter *padapter) padapter->bWritePortCancel = false; padapter->bRxRSSIDisplay = 0; padapter->bNotifyChannelChange = 0; -#ifdef CONFIG_8723AU_P2P - padapter->bShowGetP2PState = 1; -#endif return ret; } @@ -520,17 +517,6 @@ u8 rtw_init_drv_sw23a(struct rtw_adapter *padapter) goto exit; } -#ifdef CONFIG_8723AU_P2P - rtw_init_wifidirect_timers23a(padapter); - init_wifidirect_info23a(padapter, P2P_ROLE_DISABLE); - reset_global_wifidirect_info23a(padapter); - rtw_init_cfg80211_wifidirect_info(padapter); -#ifdef CONFIG_8723AU_P2P - if (rtw_init_wifi_display_info(padapter) == _FAIL) - RT_TRACE(_module_os_intfs_c_, _drv_err_, - ("\n Can't init init_wifi_display_info\n")); -#endif -#endif /* CONFIG_8723AU_P2P */ if (init_mlme_ext_priv23a(padapter) == _FAIL) { RT_TRACE(_module_os_intfs_c_, _drv_err_, @@ -599,10 +585,6 @@ void rtw_cancel_all_timer23a(struct rtw_adapter *padapter) del_timer_sync(&padapter->pwrctrlpriv.pwr_state_check_timer); -#ifdef CONFIG_8723AU_P2P - del_timer_sync(&padapter->cfg80211_wdinfo.remain_on_ch_timer); -#endif /* CONFIG_8723AU_P2P */ - del_timer_sync(&padapter->mlmepriv.set_scan_deny_timer); rtw_clear_scan_deny(padapter); RT_TRACE(_module_os_intfs_c_, _drv_info_, @@ -615,26 +597,8 @@ void rtw_cancel_all_timer23a(struct rtw_adapter *padapter) u8 rtw_free_drv_sw23a(struct rtw_adapter *padapter) { -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo; -#endif - RT_TRACE(_module_os_intfs_c_, _drv_info_, ("==>rtw_free_drv_sw23a")); - /* we can call rtw_p2p_enable23a here, but: - * 1. rtw_p2p_enable23a may have IO operation - * 2. rtw_p2p_enable23a is bundled with wext interface - */ -#ifdef CONFIG_8723AU_P2P - pwdinfo = &padapter->wdinfo; - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { - del_timer_sync(&pwdinfo->find_phase_timer); - del_timer_sync(&pwdinfo->restore_p2p_state_timer); - del_timer_sync(&pwdinfo->pre_tx_scan_timer); - rtw_p2p_set_state(pwdinfo, P2P_STATE_NONE); - } -#endif - free_mlme_ext_priv23a(&padapter->mlmeextpriv); rtw_free_cmd_priv23a(&padapter->cmdpriv); @@ -945,12 +909,6 @@ static int netdev_close(struct net_device *pnetdev) rtw_led_control(padapter, LED_CTL_POWER_OFF); } -#ifdef CONFIG_8723AU_P2P - if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled) - wdev_to_priv(padapter->rtw_wdev)->p2p_enabled = false; - rtw_p2p_enable23a(padapter, P2P_ROLE_DISABLE); -#endif /* CONFIG_8723AU_P2P */ - rtw_scan_abort23a(padapter); /* set this at the end */ padapter->rtw_wdev->iftype = NL80211_IFTYPE_MONITOR; diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index dd5899f21388..31ab34601bab 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -662,10 +662,6 @@ static struct rtw_adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, /* set mac addr */ rtw_macaddr_cfg23a(padapter->eeprompriv.mac_addr); -#ifdef CONFIG_8723AU_P2P - rtw_init_wifidirect_addrs23a(padapter, padapter->eeprompriv.mac_addr, - padapter->eeprompriv.mac_addr); -#endif DBG_8723A("bDriverStopped:%d, bSurpriseRemoved:%d, bup:%d, hw_init_completed:%d\n", padapter->bDriverStopped, padapter->bSurpriseRemoved, -- cgit v1.2.3 From bad69af0b9fd3d20b74de1202cf13b0e6c4878bb Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:36 +0200 Subject: staging: rtl8723au: Remove another stack of unused P2P related #defines Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/wifi.h | 169 ------------------------------- 1 file changed, 169 deletions(-) diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index 41af702121c4..57ad44ec0aa8 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -459,72 +459,6 @@ struct ADDBA_request { #define WPS_ASSOC_STATE_ASSOCIATION_FAILURE 0x03 #define WPS_ASSOC_STATE_IP_FAILURE 0x04 -/* =====================P2P Section===================== */ -/* For P2P */ -#define P2POUI 0x506F9A09 - -/* P2P Attribute ID */ -#define P2P_ATTR_STATUS 0x00 -#define P2P_ATTR_MINOR_REASON_CODE 0x01 -#define P2P_ATTR_CAPABILITY 0x02 -#define P2P_ATTR_DEVICE_ID 0x03 -#define P2P_ATTR_GO_INTENT 0x04 -#define P2P_ATTR_CONF_TIMEOUT 0x05 -#define P2P_ATTR_LISTEN_CH 0x06 -#define P2P_ATTR_GROUP_BSSID 0x07 -#define P2P_ATTR_EX_LISTEN_TIMING 0x08 -#define P2P_ATTR_INTENTED_IF_ADDR 0x09 -#define P2P_ATTR_MANAGEABILITY 0x0A -#define P2P_ATTR_CH_LIST 0x0B -#define P2P_ATTR_NOA 0x0C -#define P2P_ATTR_DEVICE_INFO 0x0D -#define P2P_ATTR_GROUP_INFO 0x0E -#define P2P_ATTR_GROUP_ID 0x0F -#define P2P_ATTR_INTERFACE 0x10 -#define P2P_ATTR_OPERATING_CH 0x11 -#define P2P_ATTR_INVITATION_FLAGS 0x12 - -/* Value of Status Attribute */ -#define P2P_STATUS_SUCCESS 0x00 -#define P2P_STATUS_FAIL_INFO_UNAVAILABLE 0x01 -#define P2P_STATUS_FAIL_INCOMPATIBLE_PARAM 0x02 -#define P2P_STATUS_FAIL_LIMIT_REACHED 0x03 -#define P2P_STATUS_FAIL_INVALID_PARAM 0x04 -#define P2P_STATUS_FAIL_REQUEST_UNABLE 0x05 -#define P2P_STATUS_FAIL_PREVOUS_PROTO_ERR 0x06 -#define P2P_STATUS_FAIL_NO_COMMON_CH 0x07 -#define P2P_STATUS_FAIL_UNKNOWN_P2PGROUP 0x08 -#define P2P_STATUS_FAIL_BOTH_GOINTENT_15 0x09 -#define P2P_STATUS_FAIL_INCOMPATIBLE_PROVSION 0x0A -#define P2P_STATUS_FAIL_USER_REJECT 0x0B - -/* Value of Inviation Flags Attribute */ -#define P2P_INVITATION_FLAGS_PERSISTENT BIT(0) - -#define DMP_P2P_DEVCAP_SUPPORT (P2P_DEVCAP_SERVICE_DISCOVERY | \ - P2P_DEVCAP_CLIENT_DISCOVERABILITY | \ - P2P_DEVCAP_CONCURRENT_OPERATION | \ - P2P_DEVCAP_INVITATION_PROC) - -#define DMP_P2P_GRPCAP_SUPPORT (P2P_GRPCAP_INTRABSS) - -/* Value of Device Capability Bitmap */ -#define P2P_DEVCAP_SERVICE_DISCOVERY BIT(0) -#define P2P_DEVCAP_CLIENT_DISCOVERABILITY BIT(1) -#define P2P_DEVCAP_CONCURRENT_OPERATION BIT(2) -#define P2P_DEVCAP_INFRA_MANAGED BIT(3) -#define P2P_DEVCAP_DEVICE_LIMIT BIT(4) -#define P2P_DEVCAP_INVITATION_PROC BIT(5) - -/* Value of Group Capability Bitmap */ -#define P2P_GRPCAP_GO BIT(0) -#define P2P_GRPCAP_PERSISTENT_GROUP BIT(1) -#define P2P_GRPCAP_GROUP_LIMIT BIT(2) -#define P2P_GRPCAP_INTRABSS BIT(3) -#define P2P_GRPCAP_CROSS_CONN BIT(4) -#define P2P_GRPCAP_PERSISTENT_RECONN BIT(5) -#define P2P_GRPCAP_GROUP_FORMATION BIT(6) - /* P2P Public Action Frame ( Management Frame ) */ #define P2P_PUB_ACTION_ACTION 0x09 @@ -539,37 +473,6 @@ struct ADDBA_request { #define P2P_PROVISION_DISC_REQ 7 #define P2P_PROVISION_DISC_RESP 8 -/* P2P Action Frame Type */ -#define P2P_NOTICE_OF_ABSENCE 0 -#define P2P_PRESENCE_REQUEST 1 -#define P2P_PRESENCE_RESPONSE 2 -#define P2P_GO_DISC_REQUEST 3 - - -#define P2P_MAX_PERSISTENT_GROUP_NUM 10 - -#define P2P_PROVISIONING_SCAN_CNT 3 - -#define P2P_WILDCARD_SSID_LEN 7 - -#define P2P_FINDPHASE_EX_NONE 0 /* default value, used when: (1)p2p disabed or (2)p2p enabled but only do 1 scan phase */ -#define P2P_FINDPHASE_EX_FULL 1 /* used when p2p enabled and want to do 1 scan phase and P2P_FINDPHASE_EX_MAX-1 find phase */ -#define P2P_FINDPHASE_EX_SOCIAL_FIRST (P2P_FINDPHASE_EX_FULL+1) -#define P2P_FINDPHASE_EX_MAX 4 -#define P2P_FINDPHASE_EX_SOCIAL_LAST P2P_FINDPHASE_EX_MAX - -#define P2P_PROVISION_TIMEOUT 5000 /*5 sec timeout for sending the provision discovery request */ -#define P2P_CONCURRENT_PROVISION_TIMEOUT 3000 /*3 sec timeout for sending the provision discovery request under concurrent mode */ -#define P2P_GO_NEGO_TIMEOUT 5000 /*5 sec timeout for receiving the group negotation response */ -#define P2P_CONCURRENT_GO_NEGO_TIMEOUT 3000 /*3 sec timeout for sending the negotiation request under concurrent mode */ -#define P2P_TX_PRESCAN_TIMEOUT 100 /*100ms */ -#define P2P_INVITE_TIMEOUT 5000 /*5 sec timeout for sending the invitation request */ -#define P2P_CONCURRENT_INVITE_TIMEOUT 3000 /*3 sec timeout for sending the invitation request under concurrent mode */ -#define P2P_RESET_SCAN_CH 25000 /*25 sec t/o to reset the scan channel ( based on channel plan ) */ -#define P2P_MAX_INTENT 15 - -#define P2P_MAX_NOA_NUM 2 - /* WPS Configuration Method */ #define WPS_CM_NONE 0x0000 #define WPS_CM_LABEL 0x0004 @@ -584,76 +487,4 @@ struct ADDBA_request { #define WPS_CM_SW_DISPLAY_PIN 0x2008 #define WPS_CM_LCD_DISPLAY_PIN 0x4008 -enum P2P_ROLE { - P2P_ROLE_DISABLE = 0, - P2P_ROLE_DEVICE = 1, - P2P_ROLE_CLIENT = 2, - P2P_ROLE_GO = 3 -}; - -enum P2P_STATE { - P2P_STATE_NONE = 0, /*P2P disable */ - P2P_STATE_IDLE = 1, /*P2P had enabled and do nothing */ - P2P_STATE_LISTEN = 2, /*In pure listen state */ - P2P_STATE_SCAN = 3, /*In scan phase */ - P2P_STATE_FIND_PHASE_LISTEN = 4, /*In the listen state of find phase */ - P2P_STATE_FIND_PHASE_SEARCH = 5, /*In the search state of find phase */ - P2P_STATE_TX_PROVISION_DIS_REQ = 6, /*In P2P provisioning discovery */ - P2P_STATE_RX_PROVISION_DIS_RSP = 7, - P2P_STATE_RX_PROVISION_DIS_REQ = 8, - P2P_STATE_GONEGO_ING = 9, /*Doing the group owner negoitation handshake */ - P2P_STATE_GONEGO_OK = 10, /*finish the group negoitation handshake with success */ - P2P_STATE_GONEGO_FAIL = 11, /*finish the group negoitation handshake with failure */ - P2P_STATE_RECV_INVITE_REQ_MATCH = 12, /*receiving the P2P Inviation request and match with the profile. */ - P2P_STATE_PROVISIONING_ING = 13, /*Doing the P2P WPS */ - P2P_STATE_PROVISIONING_DONE = 14, /*Finish the P2P WPS */ - P2P_STATE_TX_INVITE_REQ = 15, /*Transmit the P2P Invitation request */ - P2P_STATE_RX_INVITE_RESP_OK = 16, /*Receiving the P2P Invitation response */ - P2P_STATE_RECV_INVITE_REQ_DISMATCH = 17,/*receiving the P2P Inviation request and dismatch with the profile. */ - P2P_STATE_RECV_INVITE_REQ_GO = 18, /*receiving the P2P Inviation request and this wifi is GO. */ - P2P_STATE_RECV_INVITE_REQ_JOIN = 19, /*receiving the P2P Inviation request to join an existing P2P Group. */ - P2P_STATE_RX_INVITE_RESP_FAIL = 20, /*receiving the P2P Inviation response with failure */ - P2P_STATE_RX_INFOR_NOREADY = 21, /*receiving p2p negotiation response with information is not available */ - P2P_STATE_TX_INFOR_NOREADY = 22, /*sending p2p negotiation response with information is not available */ -}; - -enum P2P_WPSINFO { - P2P_NO_WPSINFO = 0, - P2P_GOT_WPSINFO_PEER_DISPLAY_PIN = 1, - P2P_GOT_WPSINFO_SELF_DISPLAY_PIN = 2, - P2P_GOT_WPSINFO_PBC = 3, -}; - -#define P2P_PRIVATE_IOCTL_SET_LEN 64 - -enum P2P_PROTO_WK_ID { - P2P_FIND_PHASE_WK = 0, - P2P_RESTORE_STATE_WK = 1, - P2P_PRE_TX_PROVDISC_PROCESS_WK = 2, - P2P_PRE_TX_NEGOREQ_PROCESS_WK = 3, - P2P_PRE_TX_INVITEREQ_PROCESS_WK = 4, - P2P_AP_P2P_CH_SWITCH_PROCESS_WK = 5, - P2P_RO_CH_WK = 6, -}; - -/* =====================WFD Section===================== */ -/* For Wi-Fi Display */ -#define WFD_ATTR_DEVICE_INFO 0x00 -#define WFD_ATTR_ASSOC_BSSID 0x01 -#define WFD_ATTR_COUPLED_SINK_INFO 0x06 -#define WFD_ATTR_LOCAL_IP_ADDR 0x08 -#define WFD_ATTR_SESSION_INFO 0x09 -#define WFD_ATTR_ALTER_MAC 0x0a - -/* For WFD Device Information Attribute */ -#define WFD_DEVINFO_SOURCE 0x0000 -#define WFD_DEVINFO_PSINK 0x0001 -#define WFD_DEVINFO_SSINK 0x0002 -#define WFD_DEVINFO_DUAL 0x0003 - -#define WFD_DEVINFO_SESSION_AVAIL 0x0010 -#define WFD_DEVINFO_WSD 0x0040 -#define WFD_DEVINFO_PC_TDLS 0x0080 -#define WFD_DEVINFO_HDCP_SUPPORT 0x0100 - #endif /* _WIFI_H_ */ -- cgit v1.2.3 From 7c2f97b2485fde4026c92301ba4d1d975d52b845 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:37 +0200 Subject: staging: rtl8723au: rtw_restructure_ht_ie23a(): use cfg80211_find_ie() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 67df0d7bd116..d4a78c8b05be 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -2207,11 +2207,12 @@ void rtw_joinbss_reset23a(struct rtw_adapter *padapter) /* the fucntion is >= passive_level */ unsigned int rtw_restructure_ht_ie23a(struct rtw_adapter *padapter, u8 *in_ie, - u8 *out_ie, uint in_len, uint *pout_len) + u8 *out_ie, uint in_len, uint *pout_len) { - u32 ielen, out_len; + u32 out_len; int max_rx_ampdu_factor; - unsigned char *p, *pframe; + unsigned char *pframe; + const u8 *p; struct ieee80211_ht_cap ht_capie; unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00}; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -2220,10 +2221,9 @@ unsigned int rtw_restructure_ht_ie23a(struct rtw_adapter *padapter, u8 *in_ie, phtpriv->ht_option = false; - p = rtw_get_ie23a(in_ie + 12, WLAN_EID_HT_CAPABILITY, &ielen, - in_len - 12); + p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, in_ie + 12, in_len -12); - if (p && ielen > 0) { + if (p && p[1] > 0) { u32 rx_packet_offset, max_recvbuf_sz; if (pqospriv->qos_option == 0) { out_len = *pout_len; @@ -2264,13 +2264,13 @@ unsigned int rtw_restructure_ht_ie23a(struct rtw_adapter *padapter, u8 *in_ie, phtpriv->ht_option = true; - p = rtw_get_ie23a(in_ie + 12, WLAN_EID_HT_OPERATION, &ielen, - in_len-12); - if (p && (ielen == sizeof(struct ieee80211_ht_addt_info))) { + p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, in_ie + 12, + in_len -12); + if (p && (p[1] == sizeof(struct ieee80211_ht_addt_info))) { out_len = *pout_len; pframe = rtw_set_ie23a(out_ie + out_len, WLAN_EID_HT_OPERATION, - ielen, p + 2 , pout_len); + p[1], p + 2 , pout_len); } } -- cgit v1.2.3 From 2403ea62b5bf274f0044d3abf427372f891742f9 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:38 +0200 Subject: staging: rtl8723au: rtw_update_ht_ie23a(): use cfg80211_find_ie() Switch to using cfg80211_find_ie() and remove commented out code. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 63 ++++++++++++++----------------- 1 file changed, 29 insertions(+), 34 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index d4a78c8b05be..24a4338aafe8 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -2280,18 +2280,14 @@ unsigned int rtw_restructure_ht_ie23a(struct rtw_adapter *padapter, u8 *in_ie, /* the fucntion is > passive_level (in critical_section) */ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len) { - u8 *p, max_ampdu_sz; - int len; - /* struct sta_info *bmc_sta, *psta; */ + u8 max_ampdu_sz; + const u8 *p; struct ieee80211_ht_cap *pht_capie; struct ieee80211_ht_addt_info *pht_addtinfo; - /* struct recv_reorder_ctrl *preorder_ctrl; */ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct ht_priv *phtpriv = &pmlmepriv->htpriv; - /* struct recv_priv *precvpriv = &padapter->recvpriv; */ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; struct registry_priv *pregistrypriv = &padapter->registrypriv; - /* struct wlan_network *pcur_network = &pmlmepriv->cur_network;; */ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (!phtpriv->ht_option) @@ -2302,45 +2298,43 @@ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len) DBG_8723A("+rtw_update_ht_cap23a()\n"); + /* Adjust pie + ie_len for our searches */ + pie += sizeof (struct ndis_802_11_fixed_ies); + ie_len -= sizeof (struct ndis_802_11_fixed_ies); + /* maybe needs check if ap supports rx ampdu. */ - if ((phtpriv->ampdu_enable == false) && (pregistrypriv->ampdu_enable == 1)) { + if (phtpriv->ampdu_enable == false && + pregistrypriv->ampdu_enable == 1) { if (pregistrypriv->wifi_spec == 1) phtpriv->ampdu_enable = false; else phtpriv->ampdu_enable = true; - } else if (pregistrypriv->ampdu_enable == 2) { + } else if (pregistrypriv->ampdu_enable == 2) phtpriv->ampdu_enable = true; - } /* check Max Rx A-MPDU Size */ - len = 0; - p = rtw_get_ie23a(pie+sizeof (struct ndis_802_11_fixed_ies), - WLAN_EID_HT_CAPABILITY, &len, - ie_len-sizeof (struct ndis_802_11_fixed_ies)); - if (p && len > 0) { - pht_capie = (struct ieee80211_ht_cap *)(p+2); - max_ampdu_sz = (pht_capie->ampdu_params_info & IEEE80211_HT_AMPDU_PARM_FACTOR); - max_ampdu_sz = 1 << (max_ampdu_sz+3); /* max_ampdu_sz (kbytes); */ - - /* DBG_8723A("rtw_update_ht_cap23a(): max_ampdu_sz =%d\n", max_ampdu_sz); */ - phtpriv->rx_ampdu_maxlen = max_ampdu_sz; + p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, pie, ie_len); + + if (p && p[1] > 0) { + pht_capie = (struct ieee80211_ht_cap *)(p + 2); + max_ampdu_sz = pht_capie->ampdu_params_info & + IEEE80211_HT_AMPDU_PARM_FACTOR; + /* max_ampdu_sz (kbytes); */ + max_ampdu_sz = 1 << (max_ampdu_sz + 3); + phtpriv->rx_ampdu_maxlen = max_ampdu_sz; } - len = 0; - p = rtw_get_ie23a(pie+sizeof (struct ndis_802_11_fixed_ies), - WLAN_EID_HT_OPERATION, &len, - ie_len-sizeof (struct ndis_802_11_fixed_ies)); - if (p && len>0) - { - pht_addtinfo = (struct ieee80211_ht_addt_info *)(p+2); + p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, pie, ie_len); + if (p && p[1] > 0) { + pht_addtinfo = (struct ieee80211_ht_addt_info *)(p + 2); /* todo: */ } /* update cur_bwmode & cur_ch_offset */ - if ((pregistrypriv->cbw40_enable) && - (pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info & BIT(1)) && - (pmlmeinfo->HT_info.infos[0] & BIT(2))) { + if (pregistrypriv->cbw40_enable && + (pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info & BIT(1)) && + (pmlmeinfo->HT_info.infos[0] & BIT(2))) { int i; u8 rf_type; @@ -2375,7 +2369,8 @@ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len) /* */ /* Config SM Power Save setting */ /* */ - pmlmeinfo->SM_PS = (pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info & 0x0C) >> 2; + pmlmeinfo->SM_PS = (pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info & + 0x0C) >> 2; if (pmlmeinfo->SM_PS == WLAN_HT_CAP_SM_PS_STATIC) DBG_8723A("%s(): WLAN_HT_CAP_SM_PS_STATIC\n", __func__); -- cgit v1.2.3 From 9f0e58664b376d086f1b3ad8ca5e584d20ebd608 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:39 +0200 Subject: staging: rtl8723au: OnProbeReq23a() Use cfg80211_find_ie() Switch to using cfg80211_find_ie() and tidy of the code. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 49 ++++++++++++--------------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 084003943396..5e4a55783f60 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -640,8 +640,7 @@ Following are the callback functions for each subtype of the management frames unsigned int OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { - unsigned int ielen; - unsigned char *p; + const u8 *ie; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -652,44 +651,38 @@ unsigned int OnProbeReq23a(struct rtw_adapter *padapter, uint len = skb->len; u8 is_valid_p2p_probereq = false; - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) return _SUCCESS; - } - if (check_fwstate(pmlmepriv, _FW_LINKED) == false && - check_fwstate(pmlmepriv, - WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE) == false) { + if (!check_fwstate(pmlmepriv, _FW_LINKED) && + !check_fwstate(pmlmepriv, + WIFI_ADHOC_MASTER_STATE | WIFI_AP_STATE)) return _SUCCESS; - } - p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + - _PROBEREQ_IE_OFFSET_, WLAN_EID_SSID, (int *)&ielen, - len - sizeof(struct ieee80211_hdr_3addr) - - _PROBEREQ_IE_OFFSET_); + pframe += (sizeof(struct ieee80211_hdr_3addr) + _PROBEREQ_IE_OFFSET_); + len -= (sizeof(struct ieee80211_hdr_3addr) + _PROBEREQ_IE_OFFSET_); + + ie = cfg80211_find_ie(WLAN_EID_SSID, pframe, len); /* check (wildcard) SSID */ - if (p) { - if (is_valid_p2p_probereq == true) { - goto _issue_probersp23a; - } + if (!ie) + goto out; - if ((ielen != 0 && - memcmp((void *)(p+2), cur->Ssid.ssid, - cur->Ssid.ssid_len)) || - (ielen == 0 && pmlmeinfo->hidden_ssid_mode)) { + if (is_valid_p2p_probereq == false) { + if ((ie[1] && + memcmp(ie + 2, cur->Ssid.ssid, cur->Ssid.ssid_len)) || + (ie[1] == 0 && pmlmeinfo->hidden_ssid_mode)) { return _SUCCESS; } + } -_issue_probersp23a: - - if (check_fwstate(pmlmepriv, _FW_LINKED) == true && - pmlmepriv->cur_network.join_res == true) { - /* DBG_8723A("+issue_probersp23a during ap mode\n"); */ - issue_probersp23a(padapter, ieee80211_get_SA(hdr), - is_valid_p2p_probereq); - } + if (check_fwstate(pmlmepriv, _FW_LINKED) && + pmlmepriv->cur_network.join_res) { + issue_probersp23a(padapter, ieee80211_get_SA(hdr), + is_valid_p2p_probereq); } +out: return _SUCCESS; } -- cgit v1.2.3 From b1b2bbbdc0bc429638dbf32615805f9b07f7ae87 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:40 +0200 Subject: staging: rtl8723au: OnAuth23() Use cfg80211_find_ie() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 49 +++++++++++++-------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 5e4a55783f60..8e7758fefe47 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -832,22 +832,23 @@ unsigned int OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { #ifdef CONFIG_8723AU_AP_MODE - unsigned int auth_mode, seq, ie_len; - unsigned char *sa, *p; - u16 algorithm; - int status; + unsigned int auth_mode, seq; + unsigned char *sa; + const u8 *p; + u16 algorithm; + int status; static struct sta_info stat; - struct sta_info *pstat = NULL; - struct sta_priv *pstapriv = &padapter->stapriv; + struct sta_info *pstat = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; struct security_priv *psecuritypriv = &padapter->securitypriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct sk_buff *skb = precv_frame->pkt; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; u8 *pframe = skb->data; uint len = skb->len; - if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE) return _FAIL; DBG_8723A("+OnAuth23a\n"); @@ -855,10 +856,12 @@ unsigned int OnAuth23a(struct rtw_adapter *padapter, sa = hdr->addr2; auth_mode = psecuritypriv->dot11AuthAlgrthm; - seq = cpu_to_le16(*(u16*)((unsigned long)pframe + - sizeof(struct ieee80211_hdr_3addr) + 2)); - algorithm = cpu_to_le16(*(u16*)((unsigned long)pframe + - sizeof(struct ieee80211_hdr_3addr))); + + pframe += sizeof(struct ieee80211_hdr_3addr); + len -= sizeof(struct ieee80211_hdr_3addr); + + seq = cpu_to_le16(*(u16 *)(pframe + 2)); + algorithm = cpu_to_le16(*(u16 *)pframe); DBG_8723A("auth alg =%x, seq =%X\n", algorithm, seq); @@ -909,8 +912,7 @@ unsigned int OnAuth23a(struct rtw_adapter *padapter, if (!list_empty(&pstat->asoc_list)) { list_del_init(&pstat->asoc_list); pstapriv->asoc_list_cnt--; - if (pstat->expire_to > 0) - { + if (pstat->expire_to > 0) { /* TODO: STA re_auth within expire_to */ } } @@ -962,23 +964,18 @@ unsigned int OnAuth23a(struct rtw_adapter *padapter, /* checking for challenging txt... */ DBG_8723A("checking for challenging txt...\n"); - p = rtw_get_ie23a(pframe + - sizeof(struct ieee80211_hdr_3addr) + - 4 + _AUTH_IE_OFFSET_, - WLAN_EID_CHALLENGE, - (int *)&ie_len, len - - sizeof(struct ieee80211_hdr_3addr) - - _AUTH_IE_OFFSET_ - 4); - - if ((p == NULL) || (ie_len<= 0)) { + p = cfg80211_find_ie(WLAN_EID_CHALLENGE, + pframe + 4 + _AUTH_IE_OFFSET_, + len - _AUTH_IE_OFFSET_ - 4); + if (!p || p[1] <= 0) { DBG_8723A("auth rejected because challenge " "failure!(1)\n"); status = WLAN_STATUS_CHALLENGE_FAIL; goto auth_fail; } - if (!memcmp((void *)(p + 2), pstat->chg_txt, 128)) { - pstat->state &= (~WIFI_FW_AUTH_STATE); + if (!memcmp(p + 2, pstat->chg_txt, 128)) { + pstat->state &= ~WIFI_FW_AUTH_STATE; pstat->state |= WIFI_FW_AUTH_SUCCESS; /* challenging txt is correct... */ pstat->expire_to = pstapriv->assoc_to; @@ -1000,7 +997,7 @@ unsigned int OnAuth23a(struct rtw_adapter *padapter, /* Now, we are going to issue_auth23a... */ pstat->auth_seq = seq + 1; - issue_auth23a(padapter, pstat, (unsigned short)WLAN_STATUS_SUCCESS); + issue_auth23a(padapter, pstat, WLAN_STATUS_SUCCESS); if (pstat->state & WIFI_FW_AUTH_SUCCESS) pstat->auth_seq = 0; -- cgit v1.2.3 From 781f65cbf58abe51071bc2c2a27dc89414027540 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:41 +0200 Subject: staging: rtl8723au: OnAuth23aClient23a() Use cfg80211_find_ie() Use cfg80211_find_ie() and tidy up the code Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 67 +++++++++++---------------- 1 file changed, 28 insertions(+), 39 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 8e7758fefe47..6db3d4622bc9 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1023,15 +1023,14 @@ auth_fail: unsigned int OnAuth23aClient23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { - unsigned int seq, len, status, algthm, offset; - unsigned char *p; - unsigned int go2asoc = 0; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + unsigned int seq, status, algthm, offset; + unsigned int go2asoc = 0; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct sk_buff *skb = precv_frame->pkt; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - u8 *pframe = skb->data; - uint pkt_len = skb->len; + const u8 *p, *pframe = skb->data; + int pkt_len = skb->len; DBG_8723A("%s\n", __func__); @@ -1045,15 +1044,17 @@ unsigned int OnAuth23aClient23a(struct rtw_adapter *padapter, offset = ieee80211_has_protected(hdr->frame_control) ? 4: 0; - algthm = le16_to_cpu(*(unsigned short *)((unsigned long)pframe + sizeof(struct ieee80211_hdr_3addr) + offset)); - seq = le16_to_cpu(*(unsigned short *)((unsigned long)pframe + sizeof(struct ieee80211_hdr_3addr) + offset + 2)); - status = le16_to_cpu(*(unsigned short *)((unsigned long)pframe + sizeof(struct ieee80211_hdr_3addr) + offset + 4)); + pframe += sizeof(struct ieee80211_hdr_3addr); + pkt_len -= sizeof(struct ieee80211_hdr_3addr); - if (status != 0) - { + algthm = le16_to_cpu(*(u16 *)(pframe + offset)); + seq = le16_to_cpu(*(u16 *)(pframe + offset + 2)); + status = le16_to_cpu(*(u16 *)(pframe + offset + 4)); + + if (status) { DBG_8723A("clnt auth fail, status: %d\n", status); - if (status == 13)/* pmlmeinfo->auth_algo == dot11AuthAlgrthm_Auto) */ - { + /* pmlmeinfo->auth_algo == dot11AuthAlgrthm_Auto) */ + if (status == 13) { if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) pmlmeinfo->auth_algo = dot11AuthAlgrthm_Open; else @@ -1065,53 +1066,41 @@ unsigned int OnAuth23aClient23a(struct rtw_adapter *padapter, goto authclnt_fail; } - if (seq == 2) - { - if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) - { - /* legendary shared system */ - p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + _AUTH_IE_OFFSET_, WLAN_EID_CHALLENGE, (int *)&len, - pkt_len - sizeof(struct ieee80211_hdr_3addr) - _AUTH_IE_OFFSET_); + if (seq == 2) { + if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) { + /* legendary shared system */ + p = cfg80211_find_ie(WLAN_EID_CHALLENGE, + pframe + _AUTH_IE_OFFSET_, + pkt_len - _AUTH_IE_OFFSET_); - if (p == NULL) - { + if (!p) { /* DBG_8723A("marc: no challenge text?\n"); */ goto authclnt_fail; } - memcpy((void *)(pmlmeinfo->chg_txt), (void *)(p + 2), len); + memcpy((void *)(pmlmeinfo->chg_txt), p + 2, p[1]); pmlmeinfo->auth_seq = 3; issue_auth23a(padapter, NULL, 0); set_link_timer(pmlmeext, REAUTH_TO); return _SUCCESS; - } - else - { + } else { /* open system */ go2asoc = 1; } - } - else if (seq == 4) - { + } else if (seq == 4) { if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) - { go2asoc = 1; - } else - { goto authclnt_fail; - } - } - else - { + } else { /* this is also illegal */ - /* DBG_8723A("marc: clnt auth failed due to illegal seq =%x\n", seq); */ + /* DBG_8723A("marc: clnt auth failed due to illegal seq =%x\n", + seq); */ goto authclnt_fail; } - if (go2asoc) - { + if (go2asoc) { DBG_8723A_LEVEL(_drv_always_, "auth success, start assoc\n"); start_clnt_assoc23a(padapter); return _SUCCESS; -- cgit v1.2.3 From d7a159959ebf64f489fe1422710f65be6a0e71db Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:42 +0200 Subject: staging: rtl8723au: OnAssocRsp23a() use ieee80211 header defines Use the proper ieee80211.h structs to parse the response instead of hard coded offsets. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 6db3d4622bc9..934a470b6ebf 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1596,19 +1596,20 @@ OnAssocReq23aFail: return _FAIL; } -unsigned int OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) +unsigned int OnAssocRsp23a(struct rtw_adapter *padapter, + struct recv_frame *precv_frame) { - uint i; - int res; - unsigned short status; struct ndis_802_11_var_ies *pIE; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct sk_buff *skb = precv_frame->pkt; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; + struct ieee80211_mgmt *pmgmt = (struct ieee80211_mgmt *) skb->data; + int res, i; + unsigned short status; u8 *pframe = skb->data; - uint pkt_len = skb->len; + int pkt_len = skb->len; DBG_8723A("%s\n", __func__); @@ -1626,8 +1627,8 @@ unsigned int OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *prec del_timer_sync(&pmlmeext->link_timer); /* status */ - if ((status = le16_to_cpu(*(unsigned short *)(pframe + sizeof(struct ieee80211_hdr_3addr) + 2))) > 0) - { + status = le16_to_cpu(pmgmt->u.assoc_resp.status_code); + if (status > 0) { DBG_8723A("assoc reject, status code: %d\n", status); pmlmeinfo->state = WIFI_FW_NULL_STATE; res = -4; @@ -1635,18 +1636,19 @@ unsigned int OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *prec } /* get capabilities */ - pmlmeinfo->capability = le16_to_cpu(*(unsigned short *)(pframe + sizeof(struct ieee80211_hdr_3addr))); + pmlmeinfo->capability = le16_to_cpu(pmgmt->u.assoc_resp.capab_info); /* set slot time */ pmlmeinfo->slotTime = (pmlmeinfo->capability & BIT(10))? 9: 20; /* AID */ - res = pmlmeinfo->aid = (int)(le16_to_cpu(*(unsigned short *)(pframe + sizeof(struct ieee80211_hdr_3addr) + 4))&0x3fff); + res = pmlmeinfo->aid = le16_to_cpu(pmgmt->u.assoc_resp.aid) & 0x3fff; /* following are moved to join event callback function */ /* to handle HT, WMM, rate adaptive, update MAC reg */ /* for not to handle the synchronous IO in the tasklet */ - for (i = (6 + sizeof(struct ieee80211_hdr_3addr)); i < pkt_len;) { + for (i = offsetof(struct ieee80211_mgmt, u.assoc_resp.variable); + i < pkt_len;) { pIE = (struct ndis_802_11_var_ies *)(pframe + i); switch (pIE->ElementID) @@ -1674,7 +1676,7 @@ unsigned int OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *prec i += (pIE->Length + 2); } - pmlmeinfo->state &= (~WIFI_FW_ASSOC_STATE); + pmlmeinfo->state &= ~WIFI_FW_ASSOC_STATE; pmlmeinfo->state |= WIFI_FW_ASSOC_SUCCESS; /* Update Basic Rate Table for spec, 2010-12-28 , by thomas */ -- cgit v1.2.3 From be47f78295eca082f8263aaba8ad7d5ab5e865fd Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:43 +0200 Subject: staging: rtl8723au: OnDeAuth23a() use ieee80211 header defines Use the proper ieee80211.h structs to parse the response instead of hard coded offsets. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 934a470b6ebf..0d282aff9f06 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1702,19 +1702,18 @@ report_assoc_result: unsigned int OnDeAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { - unsigned short reason; + unsigned short reason; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct sk_buff *skb = precv_frame->pkt; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - u8 *pframe = skb->data; + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; - /* check A3 */ - if (!ether_addr_equal(hdr->addr3, get_my_bssid23a(&pmlmeinfo->network))) + if (!ether_addr_equal(mgmt->bssid, + get_my_bssid23a(&pmlmeinfo->network))) return _SUCCESS; - reason = le16_to_cpu(*(unsigned short *)(pframe + sizeof(struct ieee80211_hdr_3addr))); + reason = le16_to_cpu(mgmt->u.deauth.reason_code); DBG_8723A("%s Reason code(%d)\n", __func__, reason); @@ -1724,9 +1723,9 @@ unsigned int OnDeAuth23a(struct rtw_adapter *padapter, struct sta_priv *pstapriv = &padapter->stapriv; DBG_8723A_LEVEL(_drv_always_, "ap recv deauth reason code(%d) " - "sta:%pM\n", reason, hdr->addr2); + "sta:%pM\n", reason, mgmt->sa); - psta = rtw_get_stainfo23a(pstapriv, hdr->addr2); + psta = rtw_get_stainfo23a(pstapriv, mgmt->sa); if (psta) { u8 updated = 0; @@ -1743,16 +1742,16 @@ unsigned int OnDeAuth23a(struct rtw_adapter *padapter, } return _SUCCESS; - } - else + } else #endif { DBG_8723A_LEVEL(_drv_always_, "sta recv deauth reason code(%d) " - "sta:%pM\n", reason, hdr->addr3); + "sta:%pM\n", reason, mgmt->bssid); - receive_disconnect23a(padapter, hdr->addr3, reason); + receive_disconnect23a(padapter, mgmt->bssid, reason); } pmlmepriv->LinkDetectInfo.bBusyTraffic = false; + return _SUCCESS; } -- cgit v1.2.3 From c8f260e3f6f581eb81349a3fdf43ad981ea34068 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:44 +0200 Subject: staging: rtl8723au: OnDisassoc23(): Use ieee80211_mgmt Use proper kernel ieee80211.h defined headers to parse the response. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 28 +++++++++++++-------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 0d282aff9f06..98a4e338d136 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1755,22 +1755,21 @@ unsigned int OnDeAuth23a(struct rtw_adapter *padapter, return _SUCCESS; } -unsigned int OnDisassoc23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) +unsigned int OnDisassoc23a(struct rtw_adapter *padapter, + struct recv_frame *precv_frame) { unsigned short reason; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct sk_buff *skb = precv_frame->pkt; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - u8 *pframe = skb->data; + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; - /* check A3 */ - if (!ether_addr_equal(hdr->addr3, get_my_bssid23a(&pmlmeinfo->network))) + if (!ether_addr_equal(mgmt->bssid, + get_my_bssid23a(&pmlmeinfo->network))) return _SUCCESS; - reason = le16_to_cpu(*(unsigned short *) - (pframe + sizeof(struct ieee80211_hdr_3addr))); + reason = le16_to_cpu(mgmt->u.disassoc.reason_code); DBG_8723A("%s Reason code(%d)\n", __func__, reason); @@ -1780,9 +1779,9 @@ unsigned int OnDisassoc23a(struct rtw_adapter *padapter, struct recv_frame *prec struct sta_priv *pstapriv = &padapter->stapriv; DBG_8723A_LEVEL(_drv_always_, "ap recv disassoc reason code(%d)" - " sta:%pM\n", reason, hdr->addr2); + " sta:%pM\n", reason, mgmt->sa); - psta = rtw_get_stainfo23a(pstapriv, hdr->addr2); + psta = rtw_get_stainfo23a(pstapriv, mgmt->sa); if (psta) { u8 updated = 0; @@ -1791,7 +1790,7 @@ unsigned int OnDisassoc23a(struct rtw_adapter *padapter, struct recv_frame *prec list_del_init(&psta->asoc_list); pstapriv->asoc_list_cnt--; updated = ap_free_sta23a(padapter, psta, - false, reason); + false, reason); } spin_unlock_bh(&pstapriv->asoc_list_lock); @@ -1799,14 +1798,13 @@ unsigned int OnDisassoc23a(struct rtw_adapter *padapter, struct recv_frame *prec } return _SUCCESS; - } - else + } else #endif { DBG_8723A_LEVEL(_drv_always_, "ap recv disassoc reason " - "code(%d) sta:%pM\n", reason, hdr->addr3); + "code(%d) sta:%pM\n", reason, mgmt->bssid); - receive_disconnect23a(padapter, hdr->addr3, reason); + receive_disconnect23a(padapter, mgmt->bssid, reason); } pmlmepriv->LinkDetectInfo.bBusyTraffic = false; return _SUCCESS; -- cgit v1.2.3 From 7ffdc3f5811cec96b5aebd858e6de249db6bc29a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:45 +0200 Subject: staging: rtl8723au: OnAction23_back23a() Use ieee80211_mgmt and bug fixes This converts OnAction23a_back23a() to using struct ieee80211_mgmt to parse the response packet. In addition this revealed a bug which has been fixed: case WLAN_ACTION_ADDBA_RESP: /* ADDBA response */ status = get_unaligned_le16(&frame_body[3]); tid = ((frame_body[5] >> 2) & 0x7); The above masks the tid to 3 bits, however per ieee80211.h, the tid is in fact 4 bits wide, as defined by IEEE80211_ADDBA_PARAM_TID_MASK (0x3c) Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 53 ++++++++++++++------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 98a4e338d136..fde6cd77e9fd 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1831,23 +1831,23 @@ unsigned int OnAction23a_dls(struct rtw_adapter *padapter, struct recv_frame *pr return _SUCCESS; } -unsigned int OnAction23a_back23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) +unsigned int OnAction23a_back23a(struct rtw_adapter *padapter, + struct recv_frame *precv_frame) { u8 *addr; struct sta_info *psta = NULL; struct recv_reorder_ctrl *preorder_ctrl; - unsigned char *frame_body; - unsigned char category, action; - unsigned short tid, status, reason_code = 0; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + unsigned char *frame_body; + unsigned char category, action; + unsigned short tid, status, capab, params, reason_code = 0; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct sk_buff *skb = precv_frame->pkt; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - u8 *pframe = skb->data; + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; struct sta_priv *pstapriv = &padapter->stapriv; /* check RA matches or not */ - if (!ether_addr_equal(myid(&padapter->eeprompriv), hdr->addr1)) + if (!ether_addr_equal(myid(&padapter->eeprompriv), mgmt->da)) return _SUCCESS; DBG_8723A("%s\n", __func__); @@ -1856,16 +1856,15 @@ unsigned int OnAction23a_back23a(struct rtw_adapter *padapter, struct recv_frame if (!(pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) return _SUCCESS; - addr = hdr->addr2; + addr = mgmt->sa; psta = rtw_get_stainfo23a(pstapriv, addr); if (!psta) return _SUCCESS; - frame_body = (unsigned char *) - (pframe + sizeof(struct ieee80211_hdr_3addr)); + frame_body = &mgmt->u.action.category; - category = frame_body[0]; + category = mgmt->u.action.category; if (category == WLAN_CATEGORY_BACK) { /* representing Block Ack */ if (!pmlmeinfo->HT_enable) return _SUCCESS; @@ -1887,8 +1886,11 @@ unsigned int OnAction23a_back23a(struct rtw_adapter *padapter, struct recv_frame } break; case WLAN_ACTION_ADDBA_RESP: /* ADDBA response */ - status = get_unaligned_le16(&frame_body[3]); - tid = ((frame_body[5] >> 2) & 0x7); + status = get_unaligned_le16( + &mgmt->u.action.u.addba_resp.status); + capab = get_unaligned_le16( + &mgmt->u.action.u.addba_resp.capab); + tid = (capab & IEEE80211_ADDBA_PARAM_TID_MASK) >> 2; if (status == 0) { /* successful */ DBG_8723A("agg_enable for TID =%d\n", tid); psta->htpriv.agg_enable_bitmap |= 1 << tid; @@ -1899,22 +1901,21 @@ unsigned int OnAction23a_back23a(struct rtw_adapter *padapter, struct recv_frame break; case WLAN_ACTION_DELBA: /* DELBA */ - if ((frame_body[3] & BIT(3)) == 0) { - psta->htpriv.agg_enable_bitmap &= - ~(1 << ((frame_body[3] >> 4) & 0xf)); - psta->htpriv.candidate_tid_bitmap &= - ~(1 << ((frame_body[3] >> 4) & 0xf)); + params = get_unaligned_le16( + &mgmt->u.action.u.delba.params); + tid = params >> 12; - /* reason_code = frame_body[4] | (frame_body[5] << 8); */ - reason_code = get_unaligned_le16(&frame_body[4]); - } else if ((frame_body[3] & BIT(3)) == BIT(3)) { - tid = (frame_body[3] >> 4) & 0x0F; - - preorder_ctrl = &psta->recvreorder_ctrl[tid]; + if (params & IEEE80211_DELBA_PARAM_INITIATOR_MASK) { + preorder_ctrl = &psta->recvreorder_ctrl[tid]; preorder_ctrl->enable = false; preorder_ctrl->indicate_seq = 0xffff; + } else { + psta->htpriv.agg_enable_bitmap &= ~(1 << tid); + psta->htpriv.candidate_tid_bitmap &= + ~(1 << tid); } - + reason_code = get_unaligned_le16( + &mgmt->u.action.u.delba.reason_code); DBG_8723A("%s(): DELBA: %x(%x)\n", __func__, pmlmeinfo->agg_enable_bitmap, reason_code); /* todo: how to notify the host while receiving -- cgit v1.2.3 From f9df1ea120a9630e27e7519251d3101a8944c746 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:46 +0200 Subject: staging: rtl8723au: process_80211d() use cfg80211_find_ie() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 152 ++++++++++++++------------ 1 file changed, 84 insertions(+), 68 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index fde6cd77e9fd..a8814d4bd575 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -4721,7 +4721,8 @@ unsigned int receive_disconnect23a(struct rtw_adapter *padapter, unsigned char * return _SUCCESS; } -static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *bssid) +static void process_80211d(struct rtw_adapter *padapter, + struct wlan_bssid_ex *bssid) { struct registry_priv *pregistrypriv; struct mlme_ext_priv *pmlmeext; @@ -4734,10 +4735,8 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b /* Adjust channel plan by AP Country IE */ if (pregistrypriv->enable80211d && - (!pmlmeext->update_channel_plan_by_ap_done)) - { - u8 *ie, *p; - u32 len; + !pmlmeext->update_channel_plan_by_ap_done) { + const u8 *ie, *p; struct rt_channel_plan chplan_ap; struct rt_channel_info chplan_sta[MAX_CHANNEL_NUM]; u8 country[4]; @@ -4745,33 +4744,34 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b u8 noc; /* number of channel */ u8 j, k; - ie = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, - WLAN_EID_COUNTRY, &len, - bssid->IELength - _FIXED_IE_LENGTH_); - if (!ie) return; - if (len < 6) return; + ie = cfg80211_find_ie(WLAN_EID_COUNTRY, + bssid->IEs + _FIXED_IE_LENGTH_, + bssid->IELength - _FIXED_IE_LENGTH_); + if (!ie || ie[1] < IEEE80211_COUNTRY_IE_MIN_LEN) + return; ie += 2; p = ie; - ie += len; + ie += ie[1]; - memset(country, 0, 4); memcpy(country, p, 3); + country[3] = '\0'; + p += 3; RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, - ("%s: 802.11d country =%s\n", __func__, country)); + ("%s: 802.11d country =%s\n", __func__, country)); i = 0; - while ((ie - p) >= 3) - { + while ((ie - p) >= 3) { fcn = *(p++); noc = *(p++); p++; - for (j = 0; j < noc; j++) - { - if (fcn <= 14) channel = fcn + j; /* 2.4 GHz */ - else channel = fcn + j*4; /* 5 GHz */ + for (j = 0; j < noc; j++) { + if (fcn <= 14) + channel = fcn + j; /* 2.4 GHz */ + else + channel = fcn + j * 4; /* 5 GHz */ chplan_ap.Channel[i++] = channel; } @@ -4785,45 +4785,55 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b i = j = k = 0; if (pregistrypriv->wireless_mode & WIRELESS_11G) { do { - if ((i == MAX_CHANNEL_NUM) || - (chplan_sta[i].ChannelNum == 0) || - (chplan_sta[i].ChannelNum > 14)) + if (i == MAX_CHANNEL_NUM || + chplan_sta[i].ChannelNum == 0 || + chplan_sta[i].ChannelNum > 14) break; - if ((j == chplan_ap.Len) || (chplan_ap.Channel[j] > 14)) + if (j == chplan_ap.Len || + chplan_ap.Channel[j] > 14) break; - if (chplan_sta[i].ChannelNum == chplan_ap.Channel[j]) { - chplan_new[k].ChannelNum = chplan_ap.Channel[j]; + if (chplan_sta[i].ChannelNum == + chplan_ap.Channel[j]) { + chplan_new[k].ChannelNum = + chplan_ap.Channel[j]; chplan_new[k].ScanType = SCAN_ACTIVE; i++; j++; k++; - } else if (chplan_sta[i].ChannelNum < chplan_ap.Channel[j]) { - chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; - chplan_new[k].ScanType = SCAN_PASSIVE; + } else if (chplan_sta[i].ChannelNum < + chplan_ap.Channel[j]) { + chplan_new[k].ChannelNum = + chplan_sta[i].ChannelNum; + chplan_new[k].ScanType = + SCAN_PASSIVE; i++; k++; - } else if (chplan_sta[i].ChannelNum > chplan_ap.Channel[j]) { - chplan_new[k].ChannelNum = chplan_ap.Channel[j]; - chplan_new[k].ScanType = SCAN_ACTIVE; + } else if (chplan_sta[i].ChannelNum > + chplan_ap.Channel[j]) { + chplan_new[k].ChannelNum = + chplan_ap.Channel[j]; + chplan_new[k].ScanType = + SCAN_ACTIVE; j++; k++; } } while (1); /* change AP not support channel to Passive scan */ - while ((i < MAX_CHANNEL_NUM) && - (chplan_sta[i].ChannelNum != 0) && - (chplan_sta[i].ChannelNum <= 14)) { - chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; + while (i < MAX_CHANNEL_NUM && + chplan_sta[i].ChannelNum != 0 && + chplan_sta[i].ChannelNum <= 14) { + chplan_new[k].ChannelNum = + chplan_sta[i].ChannelNum; chplan_new[k].ScanType = SCAN_PASSIVE; i++; k++; } /* add channel AP supported */ - while ((j < chplan_ap.Len) && (chplan_ap.Channel[j] <= 14)) { + while (j < chplan_ap.Len && chplan_ap.Channel[j] <= 14){ chplan_new[k].ChannelNum = chplan_ap.Channel[j]; chplan_new[k].ScanType = SCAN_ACTIVE; j++; @@ -4831,49 +4841,50 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b } } else { /* keep original STA 2.4G channel plan */ - while ((i < MAX_CHANNEL_NUM) && - (chplan_sta[i].ChannelNum != 0) && - (chplan_sta[i].ChannelNum <= 14)) { - chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; + while (i < MAX_CHANNEL_NUM && + chplan_sta[i].ChannelNum != 0 && + chplan_sta[i].ChannelNum <= 14) { + chplan_new[k].ChannelNum = + chplan_sta[i].ChannelNum; chplan_new[k].ScanType = chplan_sta[i].ScanType; i++; k++; } /* skip AP 2.4G channel plan */ - while ((j < chplan_ap.Len) && (chplan_ap.Channel[j] <= 14)) { + while (j < chplan_ap.Len && chplan_ap.Channel[j] <= 14) j++; - } } if (pregistrypriv->wireless_mode & WIRELESS_11A) { do { - if ((i == MAX_CHANNEL_NUM) || - (chplan_sta[i].ChannelNum == 0)) + if (i == MAX_CHANNEL_NUM || + chplan_sta[i].ChannelNum == 0) break; - if ((j == chplan_ap.Len) || (chplan_ap.Channel[j] == 0)) + if (j == chplan_ap.Len || + chplan_ap.Channel[j] == 0) break; - if (chplan_sta[i].ChannelNum == chplan_ap.Channel[j]) - { - chplan_new[k].ChannelNum = chplan_ap.Channel[j]; + if (chplan_sta[i].ChannelNum == + chplan_ap.Channel[j]) { + chplan_new[k].ChannelNum = + chplan_ap.Channel[j]; chplan_new[k].ScanType = SCAN_ACTIVE; i++; j++; k++; - } - else if (chplan_sta[i].ChannelNum < chplan_ap.Channel[j]) - { - chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; -/* chplan_new[k].ScanType = chplan_sta[i].ScanType; */ + } else if (chplan_sta[i].ChannelNum < + chplan_ap.Channel[j]) { + chplan_new[k].ChannelNum = + chplan_sta[i].ChannelNum; chplan_new[k].ScanType = SCAN_PASSIVE; i++; k++; - } - else if (chplan_sta[i].ChannelNum > chplan_ap.Channel[j]) - { - chplan_new[k].ChannelNum = chplan_ap.Channel[j]; + } else if (chplan_sta[i].ChannelNum > + chplan_ap.Channel[j]) { + chplan_new[k].ChannelNum = + chplan_ap.Channel[j]; chplan_new[k].ScanType = SCAN_ACTIVE; j++; k++; @@ -4881,15 +4892,17 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b } while (1); /* change AP not support channel to Passive scan */ - while ((i < MAX_CHANNEL_NUM) && (chplan_sta[i].ChannelNum != 0)) { - chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; + while (i < MAX_CHANNEL_NUM && + chplan_sta[i].ChannelNum != 0) { + chplan_new[k].ChannelNum = + chplan_sta[i].ChannelNum; chplan_new[k].ScanType = SCAN_PASSIVE; i++; k++; } /* add channel AP supported */ - while ((j < chplan_ap.Len) && (chplan_ap.Channel[j] != 0)) { + while (j < chplan_ap.Len && chplan_ap.Channel[j] != 0) { chplan_new[k].ChannelNum = chplan_ap.Channel[j]; chplan_new[k].ScanType = SCAN_ACTIVE; j++; @@ -4897,8 +4910,10 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b } } else { /* keep original STA 5G channel plan */ - while ((i < MAX_CHANNEL_NUM) && (chplan_sta[i].ChannelNum != 0)) { - chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; + while (i < MAX_CHANNEL_NUM && + chplan_sta[i].ChannelNum != 0) { + chplan_new[k].ChannelNum = + chplan_sta[i].ChannelNum; chplan_new[k].ScanType = chplan_sta[i].ScanType; i++; k++; @@ -4911,18 +4926,19 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b channel = bssid->Configuration.DSConfig; chplan_new = pmlmeext->channel_set; i = 0; - while ((i < MAX_CHANNEL_NUM) && (chplan_new[i].ChannelNum != 0)) { - if (chplan_new[i].ChannelNum == channel) - { + while (i < MAX_CHANNEL_NUM && chplan_new[i].ChannelNum != 0) { + if (chplan_new[i].ChannelNum == channel) { if (chplan_new[i].ScanType == SCAN_PASSIVE) { - /* 5G Bnad 2, 3 (DFS) doesn't change to active scan */ + /* 5G Bnad 2, 3 (DFS) doesn't change + to active scan */ if (channel >= 52 && channel <= 144) break; chplan_new[i].ScanType = SCAN_ACTIVE; RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, - ("%s: change channel %d scan type from passive to active\n", - __func__, channel)); + ("%s: change channel %d scan type " + "from passive to active\n", + __func__, channel)); } break; } -- cgit v1.2.3 From f73255d4d8d42967d8daa060d04e5dc2c50d984f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:47 +0200 Subject: staging: rtl8723au: collect_bss_info23a(): Convert to use cfg80211_fine_ie() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 157 +++++++++++++------------- 1 file changed, 76 insertions(+), 81 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index a8814d4bd575..81bdc915af92 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -4343,25 +4343,25 @@ void site_survey23a(struct rtw_adapter *padapter) } /* collect bss info from Beacon and Probe request/response frames. */ -u8 collect_bss_info23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame, struct wlan_bssid_ex *bssid) +u8 collect_bss_info23a(struct rtw_adapter *padapter, + struct recv_frame *precv_frame, + struct wlan_bssid_ex *bssid) { - int i; - u32 len; - u8 *p; - u16 val16; + int i, length; + const u8 *p; + u16 val16; struct sk_buff *skb = precv_frame->pkt; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - u8 *pframe = skb->data; - u32 packet_len = skb->len; + u8 *pframe = skb->data; + int packet_len = skb->len; u8 ie_offset; - struct registry_priv *pregistrypriv = &padapter->registrypriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct registry_priv *pregistrypriv = &padapter->registrypriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - len = packet_len - sizeof(struct ieee80211_hdr_3addr); + length = packet_len - sizeof(struct ieee80211_hdr_3addr); - if (len > MAX_IE_SZ) - { + if (length > MAX_IE_SZ) { /* DBG_8723A("IE too long for survey event\n"); */ return _FAIL; } @@ -4385,99 +4385,92 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, struct recv_frame *precv_fr } } - bssid->Length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + len; + bssid->Length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + length; /* below is to copy the information element */ - bssid->IELength = len; - memcpy(bssid->IEs, (pframe + sizeof(struct ieee80211_hdr_3addr)), bssid->IELength); + bssid->IELength = length; + memcpy(bssid->IEs, pframe + sizeof(struct ieee80211_hdr_3addr), + bssid->IELength); /* get the signal strength */ - bssid->Rssi = precv_frame->attrib.phy_info.RecvSignalPower; /* in dBM.raw data */ - bssid->PhyInfo.SignalQuality = precv_frame->attrib.phy_info.SignalQuality;/* in percentage */ - bssid->PhyInfo.SignalStrength = precv_frame->attrib.phy_info.SignalStrength;/* in percentage */ + /* in dBM.raw data */ + bssid->Rssi = precv_frame->attrib.phy_info.RecvSignalPower; + bssid->PhyInfo.SignalQuality = + precv_frame->attrib.phy_info.SignalQuality;/* in percentage */ + bssid->PhyInfo.SignalStrength = + precv_frame->attrib.phy_info.SignalStrength;/* in percentage */ /* checking SSID */ - if ((p = rtw_get_ie23a(bssid->IEs + ie_offset, WLAN_EID_SSID, &len, - bssid->IELength - ie_offset)) == NULL) - { + p = cfg80211_find_ie(WLAN_EID_SSID, bssid->IEs + ie_offset, + bssid->IELength - ie_offset); + + if (!p) { DBG_8723A("marc: cannot find SSID for survey event\n"); return _FAIL; } - if (*(p + 1)) { - if (len > IEEE80211_MAX_SSID_LEN) { - DBG_8723A("%s()-%d: IE too long (%d) for survey " - "event\n", __func__, __LINE__, len); - return _FAIL; - } - memcpy(bssid->Ssid.ssid, (p + 2), *(p + 1)); - bssid->Ssid.ssid_len = *(p + 1); - } else { - bssid->Ssid.ssid_len = 0; + if (p[1] > IEEE80211_MAX_SSID_LEN) { + DBG_8723A("%s()-%d: IE too long (%d) for survey " + "event\n", __func__, __LINE__, p[1]); + return _FAIL; } + memcpy(bssid->Ssid.ssid, p + 2, p[1]); + bssid->Ssid.ssid_len = p[1]; memset(bssid->SupportedRates, 0, NDIS_802_11_LENGTH_RATES_EX); /* checking rate info... */ i = 0; - p = rtw_get_ie23a(bssid->IEs + ie_offset, WLAN_EID_SUPP_RATES, &len, - bssid->IELength - ie_offset); - if (p != NULL) - { - if (len > NDIS_802_11_LENGTH_RATES_EX) - { - DBG_8723A("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len); + p = cfg80211_find_ie(WLAN_EID_SUPP_RATES, bssid->IEs + ie_offset, + bssid->IELength - ie_offset); + if (p) { + if (p[1] > NDIS_802_11_LENGTH_RATES_EX) { + DBG_8723A("%s()-%d: IE too long (%d) for survey " + "event\n", __func__, __LINE__, p[1]); return _FAIL; } - memcpy(bssid->SupportedRates, (p + 2), len); - i = len; + memcpy(bssid->SupportedRates, p + 2, p[1]); + i = p[1]; } - p = rtw_get_ie23a(bssid->IEs + ie_offset, WLAN_EID_EXT_SUPP_RATES, - &len, bssid->IELength - ie_offset); - if (p != NULL) - { - if (len > (NDIS_802_11_LENGTH_RATES_EX-i)) - { - DBG_8723A("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len); + p = cfg80211_find_ie(WLAN_EID_EXT_SUPP_RATES, bssid->IEs + ie_offset, + bssid->IELength - ie_offset); + if (p) { + if (p[1] > (NDIS_802_11_LENGTH_RATES_EX-i)) { + DBG_8723A("%s()-%d: IE too long (%d) for survey " + "event\n", __func__, __LINE__, p[1]); return _FAIL; } - memcpy(bssid->SupportedRates + i, (p + 2), len); + memcpy(bssid->SupportedRates + i, p + 2, p[1]); } - /* todo: */ - { - bssid->NetworkTypeInUse = Ndis802_11OFDM24; - } + bssid->NetworkTypeInUse = Ndis802_11OFDM24; if (bssid->IELength < 12) return _FAIL; /* Checking for DSConfig */ - p = rtw_get_ie23a(bssid->IEs + ie_offset, WLAN_EID_DS_PARAMS, &len, - bssid->IELength - ie_offset); + p = cfg80211_find_ie(WLAN_EID_DS_PARAMS, bssid->IEs + ie_offset, + bssid->IELength - ie_offset); bssid->Configuration.DSConfig = 0; bssid->Configuration.Length = 0; - if (p) - { - bssid->Configuration.DSConfig = *(p + 2); - } - else - {/* In 5G, some ap do not have DSSET IE */ + if (p) { + bssid->Configuration.DSConfig = p[2]; + } else {/* In 5G, some ap do not have DSSET IE */ /* checking HT info for channel */ - p = rtw_get_ie23a(bssid->IEs + ie_offset, - WLAN_EID_HT_OPERATION, &len, - bssid->IELength - ie_offset); - if (p) - { - struct HT_info_element *HT_info = (struct HT_info_element *)(p + 2); - bssid->Configuration.DSConfig = HT_info->primary_channel; - } - else - { /* use current channel */ - bssid->Configuration.DSConfig = rtw_get_oper_ch23a(padapter); + p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, + bssid->IEs + ie_offset, + bssid->IELength - ie_offset); + if (p) { + struct HT_info_element *HT_info = + (struct HT_info_element *)(p + 2); + bssid->Configuration.DSConfig = + HT_info->primary_channel; + } else { /* use current channel */ + bssid->Configuration.DSConfig = + rtw_get_oper_ch23a(padapter); } } @@ -4489,8 +4482,10 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, struct recv_frame *precv_fr return _SUCCESS; } - memcpy(&bssid->Configuration.BeaconPeriod, rtw_get_beacon_interval23a_from_ie(bssid->IEs), 2); - bssid->Configuration.BeaconPeriod = le32_to_cpu(bssid->Configuration.BeaconPeriod); + memcpy(&bssid->Configuration.BeaconPeriod, + rtw_get_beacon_interval23a_from_ie(bssid->IEs), 2); + bssid->Configuration.BeaconPeriod = + le32_to_cpu(bssid->Configuration.BeaconPeriod); val16 = rtw_get_capability23a(bssid); @@ -4510,21 +4505,21 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, struct recv_frame *precv_fr bssid->Configuration.ATIMWindow = 0; /* 20/40 BSS Coexistence check */ - if ((pregistrypriv->wifi_spec == 1) && (false == pmlmeinfo->bwmode_updated)) - { + if (pregistrypriv->wifi_spec == 1 && + pmlmeinfo->bwmode_updated == false) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - p = rtw_get_ie23a(bssid->IEs + ie_offset, WLAN_EID_HT_CAPABILITY, &len, bssid->IELength - ie_offset); - if (p && len > 0) { - struct HT_caps_element *pHT_caps; - pHT_caps = (struct HT_caps_element *)(p + 2); + p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, + bssid->IEs + ie_offset, + bssid->IELength - ie_offset); + if (p && p[1] > 0) { + struct HT_caps_element *pHT_caps; + pHT_caps = (struct HT_caps_element *)(p + 2); if (pHT_caps->u.HT_cap_element.HT_caps_info & BIT(14)) pmlmepriv->num_FortyMHzIntolerant++; } else - { pmlmepriv->num_sta_no_ht++; - } } -- cgit v1.2.3 From 78b7d04719249ba495696210d39de8c07ab028b5 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:48 +0200 Subject: staging: rtl8723au: issue_action_BSSCoexistPacket(): Clean + use cfg80211_find_ie() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 127 ++++++++++++-------------- 1 file changed, 57 insertions(+), 70 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 81bdc915af92..188cccc616c1 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -4014,24 +4014,26 @@ static void issue_action_BSSCoexistPacket(struct rtw_adapter *padapter) { struct list_head *plist, *phead, *ptmp; unsigned char category, action; - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; - struct wlan_network *pnetwork = NULL; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + u8 *pframe; + struct ieee80211_hdr *pwlanhdr; + unsigned short *fctrl; + struct wlan_network *pnetwork; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct rtw_queue *queue = &pmlmepriv->scanned_queue; + struct rtw_queue *queue = &pmlmepriv->scanned_queue; u8 InfoContent[16] = {0}; u8 ICS[8][15]; + int i; - if ((pmlmepriv->num_FortyMHzIntolerant == 0) || (pmlmepriv->num_sta_no_ht == 0)) + if (pmlmepriv->num_FortyMHzIntolerant == 0 || + pmlmepriv->num_sta_no_ht == 0) return; - if (true == pmlmeinfo->bwmode_updated) + if (pmlmeinfo->bwmode_updated) return; DBG_8723A("%s\n", __func__); @@ -4039,10 +4041,9 @@ static void issue_action_BSSCoexistPacket(struct rtw_adapter *padapter) category = WLAN_CATEGORY_PUBLIC; action = ACT_PUBLIC_BSSCOEXIST; - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) - { + pmgntframe = alloc_mgtxmitframe23a(pxmitpriv); + if (!pmgntframe) return; - } /* update attribute */ pattrib = &pmgntframe->attrib; @@ -4050,7 +4051,7 @@ static void issue_action_BSSCoexistPacket(struct rtw_adapter *padapter) memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pframe = (u8 *)pmgntframe->buf_addr + TXDESC_OFFSET; pwlanhdr = (struct ieee80211_hdr *)pframe; fctrl = &pwlanhdr->frame_control; @@ -4070,88 +4071,74 @@ static void issue_action_BSSCoexistPacket(struct rtw_adapter *padapter) pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen); pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen); - /* */ - if (pmlmepriv->num_FortyMHzIntolerant>0) - { - u8 iedata = 0; - - iedata |= BIT(2);/* 20 MHz BSS Width Request */ + if (pmlmepriv->num_FortyMHzIntolerant > 0) { + u8 iedata = BIT(2);/* 20 MHz BSS Width Request */ - pframe = rtw_set_ie23a(pframe, WLAN_EID_BSS_COEX_2040, 1, + pframe = rtw_set_ie23a(pframe, WLAN_EID_BSS_COEX_2040, 1, &iedata, &pattrib->pktlen); } - /* */ - memset(ICS, 0, sizeof(ICS)); - if (pmlmepriv->num_sta_no_ht>0) - { - int i; + if (pmlmepriv->num_sta_no_ht <= 0) + goto out; - spin_lock_bh(&pmlmepriv->scanned_queue.lock); + memset(ICS, 0, sizeof(ICS)); - phead = get_list_head(queue); - plist = phead->next; + spin_lock_bh(&pmlmepriv->scanned_queue.lock); - list_for_each_safe(plist, ptmp, phead) { - int len; - u8 *p; - struct wlan_bssid_ex *pbss_network; + phead = get_list_head(queue); + plist = phead->next; - pnetwork = container_of(plist, struct wlan_network, - list); + list_for_each_safe(plist, ptmp, phead) { + const u8 *p; + struct wlan_bssid_ex *pbss_network; - pbss_network = &pnetwork->network; + pnetwork = container_of(plist, struct wlan_network, list); - p = rtw_get_ie23a(pbss_network->IEs + _FIXED_IE_LENGTH_, - WLAN_EID_HT_CAPABILITY, &len, - pbss_network->IELength - - _FIXED_IE_LENGTH_); - if ((p == NULL) || (len == 0))/* non-HT */ - { - if ((pbss_network->Configuration.DSConfig<= 0) || (pbss_network->Configuration.DSConfig>14)) - continue; + pbss_network = &pnetwork->network; - ICS[0][pbss_network->Configuration.DSConfig]= 1; + p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, + pbss_network->IEs + _FIXED_IE_LENGTH_, + pbss_network->IELength -_FIXED_IE_LENGTH_); + if (!p || !p[1]) { /* non-HT */ + if (pbss_network->Configuration.DSConfig <= 0 || + pbss_network->Configuration.DSConfig > 14) + continue; - if (ICS[0][0] == 0) - ICS[0][0] = 1; - } + ICS[0][pbss_network->Configuration.DSConfig] = 1; + if (ICS[0][0] == 0) + ICS[0][0] = 1; } - spin_unlock_bh(&pmlmepriv->scanned_queue.lock); + } - for (i = 0;i<8;i++) - { - if (ICS[i][0] == 1) - { - int j, k = 0; + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); - InfoContent[k] = i; - /* SET_BSS_INTOLERANT_ELE_REG_CLASS(InfoContent, i); */ - k++; + for (i = 0; i < 8;i++) { + if (ICS[i][0] == 1) { + int j, k = 0; - for (j = 1;j<= 14;j++) - { - if (ICS[i][j]== 1) - { - if (k<16) - { - InfoContent[k] = j; /* channel number */ - /* SET_BSS_INTOLERANT_ELE_CHANNEL(InfoContent+k, j); */ - k++; - } + InfoContent[k] = i; + /* SET_BSS_INTOLERANT_ELE_REG_CLASS(InfoContent, i); */ + k++; + + for (j = 1; j <= 14; j++) { + if (ICS[i][j] == 1) { + if (k < 16) { + /* channel number */ + InfoContent[k] = j; + k++; } } - - pframe = rtw_set_ie23a(pframe, EID_BSSIntolerantChlReport, k, InfoContent, &pattrib->pktlen); - } + pframe = rtw_set_ie23a(pframe, + EID_BSSIntolerantChlReport, k, + InfoContent, &pattrib->pktlen); } - } +out: pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe23a(padapter, pmgntframe); -- cgit v1.2.3 From 0b2b676d590a07a3a4c1c5aceab59bbeea65a965 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:49 +0200 Subject: staging: rtl8723au: issue_assocreq23a(): General cleanups and use cfg80211_find_ie() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 77 +++++++++++++-------------- 1 file changed, 36 insertions(+), 41 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 188cccc616c1..368c7de03234 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -3136,11 +3136,11 @@ void issue_assocreq23a(struct rtw_adapter *padapter) int ret = _FAIL; struct xmit_frame *pmgntframe; struct pkt_attrib *pattrib; - unsigned char *pframe, *p; + unsigned char *pframe; + const u8 *p; struct ieee80211_hdr *pwlanhdr; unsigned short *fctrl; - unsigned short val16; - unsigned int i, j, ie_len, index = 0; + unsigned int i, j, index = 0; unsigned char rf_type, bssrate[NumRates], sta_bssrate[NumRates]; struct ndis_802_11_var_ies *pIE; struct registry_priv *pregpriv = &padapter->registrypriv; @@ -3148,9 +3148,11 @@ void issue_assocreq23a(struct rtw_adapter *padapter) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - int bssrate_len = 0, sta_bssrate_len = 0; + int bssrate_len = 0, sta_bssrate_len = 0, pie_len; + u8 * pie; - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) + pmgntframe = alloc_mgtxmitframe23a(pxmitpriv); + if (!pmgntframe) goto exit; /* update attribute */ @@ -3159,7 +3161,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pframe = (u8 *)pmgntframe->buf_addr + TXDESC_OFFSET; pwlanhdr = (struct ieee80211_hdr *)pframe; fctrl = &pwlanhdr->frame_control; @@ -3176,16 +3178,15 @@ void issue_assocreq23a(struct rtw_adapter *padapter) pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); /* caps */ - memcpy(pframe, rtw_get_capability23a_from_ie(pmlmeinfo->network.IEs), - 2); + memcpy(pframe, + rtw_get_capability23a_from_ie(pmlmeinfo->network.IEs), 2); pframe += 2; pattrib->pktlen += 2; /* listen interval */ /* todo: listen interval for power saving */ - val16 = cpu_to_le16(3); - memcpy(pframe, (unsigned char *)&val16, 2); + put_unaligned_le16(3, pframe); pframe += 2; pattrib->pktlen += 2; @@ -3225,7 +3226,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) Handlink WSG-4000 AP */ if ((pmlmeinfo->network.SupportedRates[i] | IEEE80211_BASIC_RATE_MASK) == - (sta_bssrate[j]|IEEE80211_BASIC_RATE_MASK)) { + (sta_bssrate[j] | IEEE80211_BASIC_RATE_MASK)) { /* DBG_8723A("match i = %d, j =%d\n", i, j); */ break; } @@ -3262,23 +3263,21 @@ void issue_assocreq23a(struct rtw_adapter *padapter) bssrate_len, bssrate, &pattrib->pktlen); /* RSN */ - p = rtw_get_ie23a((pmlmeinfo->network.IEs + - sizeof(struct ndis_802_11_fixed_ies)), WLAN_EID_RSN, - &ie_len, (pmlmeinfo->network.IELength - - sizeof(struct ndis_802_11_fixed_ies))); + pie = pmlmeinfo->network.IEs + sizeof(struct ndis_802_11_fixed_ies); + pie_len = pmlmeinfo->network.IELength - + sizeof(struct ndis_802_11_fixed_ies); + + p = cfg80211_find_ie(WLAN_EID_RSN, pie, pie_len); if (p) - pframe = rtw_set_ie23a(pframe, WLAN_EID_RSN, ie_len, (p + 2), + pframe = rtw_set_ie23a(pframe, WLAN_EID_RSN, p[1], p + 2, &pattrib->pktlen); /* HT caps */ if (padapter->mlmepriv.htpriv.ht_option == true) { - p = rtw_get_ie23a((pmlmeinfo->network.IEs + - sizeof(struct ndis_802_11_fixed_ies)), - WLAN_EID_HT_CAPABILITY, &ie_len, - (pmlmeinfo->network.IELength - - sizeof(struct ndis_802_11_fixed_ies))); - if ((p != NULL) && (!(is_ap_in_tkip23a(padapter)))) { - memcpy(&pmlmeinfo->HT_caps, (p + 2), + p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, pie, pie_len); + + if (p && !is_ap_in_tkip23a(padapter)) { + memcpy(&pmlmeinfo->HT_caps, p + 2, sizeof(struct HT_caps_element)); /* to disable 40M Hz support while gd_bw_40MHz_en = 0 */ @@ -3294,12 +3293,11 @@ void issue_assocreq23a(struct rtw_adapter *padapter) rf_type = rtl8723a_get_rf_type(padapter); /* switch (pregpriv->rf_config) */ - switch (rf_type) - { + switch (rf_type) { case RF_1T1R: - + /* RX STBC One spatial stream */ if (pregpriv->rx_stbc) - pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info |= cpu_to_le16(0x0100);/* RX STBC One spatial stream */ + pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info |= cpu_to_le16(0x0100); memcpy(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_rate_1R23A, 16); break; @@ -3307,18 +3305,17 @@ void issue_assocreq23a(struct rtw_adapter *padapter) case RF_2T2R: case RF_1T2R: default: - /* enable for 2.4/5 GHz */ - if ((pregpriv->rx_stbc == 0x3) || - ((pmlmeext->cur_wireless_mode & - WIRELESS_11_24N) && + if (pregpriv->rx_stbc == 0x3 || + (pmlmeext->cur_wireless_mode & + WIRELESS_11_24N && /* enable for 2.4GHz */ - (pregpriv->rx_stbc == 0x1)) || - ((pmlmeext->cur_wireless_mode & - WIRELESS_11_5N) && - (pregpriv->rx_stbc == 0x2)) || + pregpriv->rx_stbc == 0x1) || + (pmlmeext->cur_wireless_mode & + WIRELESS_11_5N && + pregpriv->rx_stbc == 0x2) || /* enable for 5GHz */ - (pregpriv->wifi_spec == 1)) { + pregpriv->wifi_spec == 1) { DBG_8723A("declare supporting RX " "STBC\n"); pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info |= cpu_to_le16(0x0200);/* RX STBC two spatial stream */ @@ -3338,8 +3335,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) #endif pframe = rtw_set_ie23a(pframe, WLAN_EID_HT_CAPABILITY, - ie_len, - (u8 *)&pmlmeinfo->HT_caps, + p[1], (u8 *)&pmlmeinfo->HT_caps, &pattrib->pktlen); } } @@ -3375,7 +3371,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) break; } - i += (pIE->Length + 2); + i += pIE->Length + 2; } if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) @@ -3393,8 +3389,7 @@ exit: kfree(pmlmepriv->assoc_req); pmlmepriv->assoc_req = kmalloc(pattrib->pktlen, GFP_ATOMIC); if (pmlmepriv->assoc_req) { - memcpy(pmlmepriv->assoc_req, pwlanhdr, - pattrib->pktlen); + memcpy(pmlmepriv->assoc_req, pwlanhdr, pattrib->pktlen); pmlmepriv->assoc_req_len = pattrib->pktlen; } } else -- cgit v1.2.3 From cfe4ecdc806bfdb49cf7c6d5bd5251d1d0e4ff63 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:50 +0200 Subject: staging: rtl8723au: issue_asocrsp23a(): Use cfg80211_find_ie() and cleanups Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 63 ++++++++++++++------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 368c7de03234..e5e6aa5f90c6 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -2993,18 +2993,20 @@ void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status, struct xmit_frame *pmgntframe; struct ieee80211_hdr *pwlanhdr; struct pkt_attrib *pattrib; - unsigned char *pbuf, *pframe; + unsigned char *pframe; unsigned short val; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; + const u8 *p; u8 *ie = pnetwork->IEs; DBG_8723A("%s\n", __func__); - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) + pmgntframe = alloc_mgtxmitframe23a(pxmitpriv); + if (!pmgntframe) return; /* update attribute */ @@ -3024,7 +3026,7 @@ void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status, SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); pmlmeext->mgnt_seq++; - if ((pkt_type == WIFI_ASSOCRSP) || (pkt_type == WIFI_REASSOCRSP)) + if (pkt_type == WIFI_ASSOCRSP || pkt_type == WIFI_REASSOCRSP) SetFrameSubType(pwlanhdr, pkt_type); else return; @@ -3060,52 +3062,53 @@ void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status, pstat->bssrateset + 8, &pattrib->pktlen); } - if ((pstat->flags & WLAN_STA_HT) && (pmlmepriv->htpriv.ht_option)) { - uint ie_len = 0; - + if (pstat->flags & WLAN_STA_HT && pmlmepriv->htpriv.ht_option) { /* FILL HT CAP INFO IE */ /* p = hostapd_eid_ht_capabilities_info(hapd, p); */ - pbuf = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, - WLAN_EID_HT_CAPABILITY, &ie_len, - pnetwork->IELength - _BEACON_IE_OFFSET_); - if (pbuf && ie_len>0) { - memcpy(pframe, pbuf, ie_len + 2); - pframe += (ie_len + 2); - pattrib->pktlen += (ie_len + 2); + p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, + ie + _BEACON_IE_OFFSET_, + pnetwork->IELength -_BEACON_IE_OFFSET_); + if (p && p[1]) { + memcpy(pframe, p, p[1] + 2); + pframe += (p[1] + 2); + pattrib->pktlen += (p[1] + 2); } /* FILL HT ADD INFO IE */ /* p = hostapd_eid_ht_operation(hapd, p); */ - pbuf = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, - WLAN_EID_HT_OPERATION, &ie_len, + p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, + ie + _BEACON_IE_OFFSET_, pnetwork->IELength - _BEACON_IE_OFFSET_); - if (pbuf && ie_len > 0) { - memcpy(pframe, pbuf, ie_len + 2); - pframe += (ie_len + 2); - pattrib->pktlen += (ie_len + 2); + if (p && p[1] > 0) { + memcpy(pframe, p, p[1] + 2); + pframe += (p[1] + 2); + pattrib->pktlen += (p[1] + 2); } } /* FILL WMM IE */ - if ((pstat->flags & WLAN_STA_WME) && pmlmepriv->qospriv.qos_option) { - uint ie_len = 0; + if (pstat->flags & WLAN_STA_WME && pmlmepriv->qospriv.qos_option) { unsigned char WMM_PARA_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; - - for (pbuf = ie + _BEACON_IE_OFFSET_; ; pbuf += (ie_len + 2)) { - pbuf = rtw_get_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, - &ie_len, (pnetwork->IELength - - _BEACON_IE_OFFSET_ - - (ie_len + 2))); - if (pbuf && !memcmp(pbuf + 2, WMM_PARA_IE, 6)) { - memcpy(pframe, pbuf, ie_len + 2); + int ie_len = 0; + + for (p = ie + _BEACON_IE_OFFSET_; ; p += (ie_len + 2)) { + p = cfg80211_find_ie(WLAN_EID_VENDOR_SPECIFIC, p, + pnetwork->IELength - + _BEACON_IE_OFFSET_ - (ie_len + 2)); + if (p) + ie_len = p[1]; + else + ie_len = 0; + if (p && !memcmp(p + 2, WMM_PARA_IE, 6)) { + memcpy(pframe, p, ie_len + 2); pframe += (ie_len + 2); pattrib->pktlen += (ie_len + 2); break; } - if ((!pbuf) || (ie_len == 0)) + if (!p || ie_len == 0) break; } } -- cgit v1.2.3 From 858e66584090b666d2f984864104bf31b70e65bb Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:51 +0200 Subject: staging: rtl8723au: issue_probersp23a(): various cleanups Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 35 +++++++++++++-------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index e5e6aa5f90c6..a66216fffaca 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -2484,8 +2484,8 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, /* DBG_8723A("%s\n", __func__); */ - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) - { + pmgntframe = alloc_mgtxmitframe23a(pxmitpriv); + if (!pmgntframe) { DBG_8723A("%s, alloc mgnt frame fail\n", __func__); return; } @@ -2496,7 +2496,7 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pframe = (u8 *)pmgntframe->buf_addr + TXDESC_OFFSET; pwlanhdr = (struct ieee80211_hdr *)pframe; mac = myid(&padapter->eeprompriv); @@ -2528,8 +2528,7 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, &wps_ielen); /* inerset & update wps_probe_resp_ie */ - if ((pmlmepriv->wps_probe_resp_ie != NULL) && pwps_ie && - (wps_ielen > 0)) { + if (pmlmepriv->wps_probe_resp_ie && pwps_ie && wps_ielen > 0) { uint wps_offset, remainder_ielen; u8 *premainder_ie; @@ -2546,14 +2545,14 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, /* to get ie data len */ wps_ielen = (uint)pmlmepriv->wps_probe_resp_ie[1]; - if ((wps_offset+wps_ielen+2)<= MAX_IE_SZ) { + if (wps_offset + wps_ielen + 2 <= MAX_IE_SZ) { memcpy(pframe, pmlmepriv->wps_probe_resp_ie, wps_ielen+2); pframe += wps_ielen+2; pattrib->pktlen += wps_ielen+2; } - if ((wps_offset+wps_ielen+2+remainder_ielen) <= + if (wps_offset + wps_ielen + 2 + remainder_ielen <= MAX_IE_SZ) { memcpy(pframe, premainder_ie, remainder_ielen); pframe += remainder_ielen; @@ -2569,9 +2568,9 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, ies = pmgntframe->buf_addr + TXDESC_OFFSET + sizeof(struct ieee80211_hdr_3addr); - ssid_ie = rtw_get_ie23a(ies+_FIXED_IE_LENGTH_, WLAN_EID_SSID, + ssid_ie = rtw_get_ie23a(ies + _FIXED_IE_LENGTH_, WLAN_EID_SSID, &ssid_ielen, - (pframe-ies)-_FIXED_IE_LENGTH_); + pframe - ies - _FIXED_IE_LENGTH_); ssid_ielen_diff = cur_network->Ssid.ssid_len - ssid_ielen; @@ -2579,20 +2578,19 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, uint remainder_ielen; u8 *remainder_ie; remainder_ie = ssid_ie + 2; - remainder_ielen = (pframe-remainder_ie); + remainder_ielen = pframe - remainder_ie; DBG_8723A_LEVEL(_drv_warning_, FUNC_ADPT_FMT " remainder_ielen > MAX_IE_SZ\n", FUNC_ADPT_ARG(padapter)); - if (remainder_ielen > MAX_IE_SZ) { + if (remainder_ielen > MAX_IE_SZ) remainder_ielen = MAX_IE_SZ; - } memcpy(buf, remainder_ie, remainder_ielen); - memcpy(remainder_ie+ssid_ielen_diff, buf, + memcpy(remainder_ie + ssid_ielen_diff, buf, remainder_ielen); - *(ssid_ie+1) = cur_network->Ssid.ssid_len; - memcpy(ssid_ie+2, cur_network->Ssid.ssid, + *(ssid_ie + 1) = cur_network->Ssid.ssid_len; + memcpy(ssid_ie + 2, cur_network->Ssid.ssid, cur_network->Ssid.ssid_len); pframe += ssid_ielen_diff; @@ -2626,8 +2624,9 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, /* SSID */ pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID, - cur_network->Ssid.ssid_len, - cur_network->Ssid.ssid, &pattrib->pktlen); + cur_network->Ssid.ssid_len, + cur_network->Ssid.ssid, + &pattrib->pktlen); /* supported rates... */ rate_len = rtw_get_rateset_len23a(cur_network->SupportedRates); @@ -2642,7 +2641,7 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, &cur_network->Configuration.DSConfig, &pattrib->pktlen); - if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { + if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { u8 erpinfo = 0; u32 ATIMWindow; /* IBSS Parameter Set... */ -- cgit v1.2.3 From da290c54610f49ef475f7f88668259216b08fc36 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:52 +0200 Subject: staging: rtl8723au: OnAssocReq23a(): Clean up and use more ieee80211.h This converts it to use struct ieee80211_mgmt and cfg80211_find_ie(). In addition fix a potential buffer overrun in the last loop searching through list WLAN_EID_VENDOR_SPECIFIC elements. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 276 ++++++++++++-------------- 1 file changed, 131 insertions(+), 145 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index a66216fffaca..5264c24470b0 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1119,13 +1119,12 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec u16 capab_info, listen_interval; struct rtw_ieee802_11_elems elems; struct sta_info *pstat; - unsigned char reassoc, *p, *pos, *wpa_ie; + unsigned char reassoc, *wpa_ie; unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01}; - int i, ie_len, wpa_ie_len, left; - unsigned char supportRate[16]; - int supportRateNum; - unsigned short status = WLAN_STATUS_SUCCESS; - unsigned short ie_offset; + int i, wpa_ie_len, left; + unsigned char supportRate[16]; + int supportRateNum; + unsigned short status = WLAN_STATUS_SUCCESS; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv *psecuritypriv = &padapter->securitypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -1133,61 +1132,56 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec struct wlan_bssid_ex *cur = &pmlmeinfo->network; struct sta_priv *pstapriv = &padapter->stapriv; struct sk_buff *skb = precv_frame->pkt; + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; + const u8 *p; + u8 *pos; u8 *pframe = skb->data; uint pkt_len = skb->len; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - u16 frame_control; - if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE) return _FAIL; - frame_control = hdr->frame_control; - if (ieee80211_is_assoc_req(frame_control)) { + left = pkt_len - sizeof(struct ieee80211_hdr_3addr); + if (ieee80211_is_assoc_req(mgmt->frame_control)) { reassoc = 0; - ie_offset = _ASOCREQ_IE_OFFSET_; + pos = mgmt->u.assoc_req.variable; + left -= _ASOCREQ_IE_OFFSET_; } else { /* WIFI_REASSOCREQ */ reassoc = 1; - ie_offset = _REASOCREQ_IE_OFFSET_; + pos = mgmt->u.reassoc_req.variable; + left -= _REASOCREQ_IE_OFFSET_; } - if (pkt_len < sizeof(struct ieee80211_hdr_3addr) + ie_offset) { - DBG_8723A("handle_assoc(reassoc =%d) - too short payload (len =%lu)" - "\n", reassoc, (unsigned long)pkt_len); + if (left < 0) { + DBG_8723A("handle_assoc(reassoc =%d) - too short payload " + "(len =%lu)\n", reassoc, (unsigned long)pkt_len); return _FAIL; } - pstat = rtw_get_stainfo23a(pstapriv, hdr->addr2); + pstat = rtw_get_stainfo23a(pstapriv, mgmt->sa); if (!pstat) { status = WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA; goto asoc_class2_error; } - capab_info = get_unaligned_le16(pframe + sizeof(struct ieee80211_hdr_3addr)); - /* capab_info = le16_to_cpu(*(unsigned short *)(pframe + sizeof(struct ieee80211_hdr_3addr))); */ - /* listen_interval = le16_to_cpu(*(unsigned short *)(pframe + sizeof(struct ieee80211_hdr_3addr)+2)); */ - listen_interval = get_unaligned_le16(pframe + sizeof(struct ieee80211_hdr_3addr)+2); - - left = pkt_len - (sizeof(struct ieee80211_hdr_3addr) + ie_offset); - pos = pframe + (sizeof(struct ieee80211_hdr_3addr) + ie_offset); + /* These two are located at the same offsets whether it's an + * assoc_req or a reassoc_req */ + capab_info = get_unaligned_le16(&mgmt->u.assoc_req.capab_info); + listen_interval = + get_unaligned_le16(&mgmt->u.assoc_req.listen_interval); DBG_8723A("%s\n", __func__); /* check if this stat has been successfully authenticated/assocated */ - if (!((pstat->state) & WIFI_FW_AUTH_SUCCESS)) - { - if (!((pstat->state) & WIFI_FW_ASSOC_SUCCESS)) - { + if (!(pstat->state & WIFI_FW_AUTH_SUCCESS)) { + if (!(pstat->state & WIFI_FW_ASSOC_SUCCESS)) { status = WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA; goto asoc_class2_error; - } - else - { + } else { pstat->state &= (~WIFI_FW_ASSOC_SUCCESS); pstat->state |= WIFI_FW_ASSOC_STATE; } - } - else - { + } else { pstat->state &= (~WIFI_FW_AUTH_SUCCESS); pstat->state |= WIFI_FW_ASSOC_STATE; } @@ -1195,42 +1189,37 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec pstat->capability = capab_info; /* now parse all ieee802_11 ie to point to elems */ - if (rtw_ieee802_11_parse_elems23a(pos, left, &elems, 1) == ParseFailed || - !elems.ssid) { + if (rtw_ieee802_11_parse_elems23a(pos, left, &elems, 1) == + ParseFailed || !elems.ssid) { DBG_8723A("STA " MAC_FMT " sent invalid association request\n", - MAC_ARG(pstat->hwaddr)); + MAC_ARG(pstat->hwaddr)); status = WLAN_STATUS_UNSPECIFIED_FAILURE; goto OnAssocReq23aFail; } /* now we should check all the fields... */ /* checking SSID */ - p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + - ie_offset, WLAN_EID_SSID, &ie_len, pkt_len - - sizeof(struct ieee80211_hdr_3addr) - ie_offset); - if (p == NULL) - { - status = WLAN_STATUS_UNSPECIFIED_FAILURE; - } - - if (ie_len == 0) /* broadcast ssid, however it is not allowed in assocreq */ + p = cfg80211_find_ie(WLAN_EID_SSID, pos, left); + if (!p || p[1] == 0) { + /* broadcast ssid, however it is not allowed in assocreq */ status = WLAN_STATUS_UNSPECIFIED_FAILURE; - else { + } else { /* check if ssid match */ - if (memcmp((void *)(p+2), cur->Ssid.ssid, cur->Ssid.ssid_len)) + if (memcmp(p + 2, cur->Ssid.ssid, cur->Ssid.ssid_len)) status = WLAN_STATUS_UNSPECIFIED_FAILURE; - if (ie_len != cur->Ssid.ssid_len) + if (p[1] != cur->Ssid.ssid_len) status = WLAN_STATUS_UNSPECIFIED_FAILURE; } - if (WLAN_STATUS_SUCCESS != status) + if (status != WLAN_STATUS_SUCCESS) goto OnAssocReq23aFail; /* check if the supported rate is ok */ - p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset, WLAN_EID_SUPP_RATES, &ie_len, pkt_len - sizeof(struct ieee80211_hdr_3addr) - ie_offset); - if (p == NULL) { - DBG_8723A("Rx a sta assoc-req which supported rate is empty!\n"); + p = cfg80211_find_ie(WLAN_EID_SUPP_RATES, pos, left); + if (!p) { + DBG_8723A("Rx a sta assoc-req which supported rate is " + "empty!\n"); /* use our own rate set as statoin used */ /* memcpy(supportRate, AP_BSSRATE, AP_BSSRATE_LEN); */ /* supportRateNum = AP_BSSRATE_LEN; */ @@ -1238,17 +1227,14 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec status = WLAN_STATUS_UNSPECIFIED_FAILURE; goto OnAssocReq23aFail; } else { - memcpy(supportRate, p+2, ie_len); - supportRateNum = ie_len; - - p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset, WLAN_EID_EXT_SUPP_RATES, &ie_len, - pkt_len - sizeof(struct ieee80211_hdr_3addr) - ie_offset); - if (p != NULL) { - - if (supportRateNum<= sizeof(supportRate)) - { - memcpy(supportRate+supportRateNum, p+2, ie_len); - supportRateNum += ie_len; + memcpy(supportRate, p + 2, p[1]); + supportRateNum = p[1]; + + p = cfg80211_find_ie(WLAN_EID_EXT_SUPP_RATES, pos, left); + if (!p) { + if (supportRateNum <= sizeof(supportRate)) { + memcpy(supportRate+supportRateNum, p + 2, p[1]); + supportRateNum += p[1]; } } } @@ -1269,42 +1255,46 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec pstat->wpa_pairwise_cipher = 0; pstat->wpa2_pairwise_cipher = 0; memset(pstat->wpa_ie, 0, sizeof(pstat->wpa_ie)); - if ((psecuritypriv->wpa_psk & BIT(1)) && elems.rsn_ie) { - + if (psecuritypriv->wpa_psk & BIT(1) && elems.rsn_ie) { int group_cipher = 0, pairwise_cipher = 0; wpa_ie = elems.rsn_ie; wpa_ie_len = elems.rsn_ie_len; - if (rtw_parse_wpa2_ie23a(wpa_ie-2, wpa_ie_len+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { + if (rtw_parse_wpa2_ie23a(wpa_ie - 2, wpa_ie_len + 2, + &group_cipher, &pairwise_cipher, + NULL) == _SUCCESS) { pstat->dot8021xalg = 1;/* psk, todo:802.1x */ pstat->wpa_psk |= BIT(1); - pstat->wpa2_group_cipher = group_cipher&psecuritypriv->wpa2_group_cipher; - pstat->wpa2_pairwise_cipher = pairwise_cipher&psecuritypriv->wpa2_pairwise_cipher; + pstat->wpa2_group_cipher = + group_cipher&psecuritypriv->wpa2_group_cipher; + pstat->wpa2_pairwise_cipher = + pairwise_cipher&psecuritypriv->wpa2_pairwise_cipher; if (!pstat->wpa2_group_cipher) status = WLAN_REASON_INVALID_GROUP_CIPHER; if (!pstat->wpa2_pairwise_cipher) status = WLAN_REASON_INVALID_PAIRWISE_CIPHER; - } else { + } else status = WLAN_STATUS_INVALID_IE; - } - - } else if ((psecuritypriv->wpa_psk & BIT(0)) && elems.wpa_ie) { - + } else if (psecuritypriv->wpa_psk & BIT(0) && elems.wpa_ie) { int group_cipher = 0, pairwise_cipher = 0; wpa_ie = elems.wpa_ie; wpa_ie_len = elems.wpa_ie_len; - if (rtw_parse_wpa_ie23a(wpa_ie-2, wpa_ie_len+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { + if (rtw_parse_wpa_ie23a(wpa_ie - 2, wpa_ie_len + 2, + &group_cipher, &pairwise_cipher, + NULL) == _SUCCESS) { pstat->dot8021xalg = 1;/* psk, todo:802.1x */ pstat->wpa_psk |= BIT(0); - pstat->wpa_group_cipher = group_cipher&psecuritypriv->wpa_group_cipher; - pstat->wpa_pairwise_cipher = pairwise_cipher&psecuritypriv->wpa_pairwise_cipher; + pstat->wpa_group_cipher = + group_cipher&psecuritypriv->wpa_group_cipher; + pstat->wpa_pairwise_cipher = + pairwise_cipher&psecuritypriv->wpa_pairwise_cipher; if (!pstat->wpa_group_cipher) status = WLAN_STATUS_INVALID_GROUP_CIPHER; @@ -1312,10 +1302,8 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec if (!pstat->wpa_pairwise_cipher) status = WLAN_STATUS_INVALID_PAIRWISE_CIPHER; - } else { + } else status = WLAN_STATUS_INVALID_IE; - } - } else { wpa_ie = NULL; wpa_ie_len = 0; @@ -1325,34 +1313,37 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec goto OnAssocReq23aFail; pstat->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS); - if (wpa_ie == NULL) { + if (!wpa_ie) { if (elems.wps_ie) { - DBG_8723A("STA included WPS IE in " - "(Re)Association Request - assume WPS is " - "used\n"); + DBG_8723A("STA included WPS IE in (Re)Association " + "Request - assume WPS is used\n"); pstat->flags |= WLAN_STA_WPS; } else { - DBG_8723A("STA did not include WPA/RSN IE " - "in (Re)Association Request - possible WPS " - "use\n"); + DBG_8723A("STA did not include WPA/RSN IE in (Re)" + "Association Request - possible WPS use\n"); pstat->flags |= WLAN_STA_MAYBE_WPS; } - /* AP support WPA/RSN, and sta is going to do WPS, but AP is not ready */ + /* AP support WPA/RSN, and sta is going to do WPS, but AP + is not ready */ /* that the selected registrar of AP is _FLASE */ - if ((psecuritypriv->wpa_psk > 0) && - (pstat->flags & (WLAN_STA_WPS|WLAN_STA_MAYBE_WPS))) { + if (psecuritypriv->wpa_psk > 0 && + pstat->flags & (WLAN_STA_WPS|WLAN_STA_MAYBE_WPS)) { if (pmlmepriv->wps_beacon_ie) { u8 selected_registrar = 0; - rtw_get_wps_attr_content23a(pmlmepriv->wps_beacon_ie, pmlmepriv->wps_beacon_ie_len, - WPS_ATTR_SELECTED_REGISTRAR, &selected_registrar, NULL); + rtw_get_wps_attr_content23a( + pmlmepriv->wps_beacon_ie, + pmlmepriv->wps_beacon_ie_len, + WPS_ATTR_SELECTED_REGISTRAR, + &selected_registrar, NULL); if (!selected_registrar) { - DBG_8723A("selected_registrar is false , or AP is not ready to do WPS\n"); + DBG_8723A("selected_registrar is false," + "or AP is not ready to do " + "WPS\n"); status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA; - goto OnAssocReq23aFail; } } @@ -1362,7 +1353,8 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec if (psecuritypriv->wpa_psk == 0) { DBG_8723A("STA " MAC_FMT ": WPA/RSN IE in association " - "request, but AP don't support WPA/RSN\n", MAC_ARG(pstat->hwaddr)); + "request, but AP don't support WPA/RSN\n", + MAC_ARG(pstat->hwaddr)); status = WLAN_STATUS_INVALID_IE; @@ -1376,11 +1368,12 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec pstat->flags |= WLAN_STA_WPS; copy_len = 0; } else { - copy_len = ((wpa_ie_len+2) > sizeof(pstat->wpa_ie)) ? (sizeof(pstat->wpa_ie)):(wpa_ie_len+2); + copy_len = ((wpa_ie_len + 2) > sizeof(pstat->wpa_ie)) ? + sizeof(pstat->wpa_ie) : (wpa_ie_len + 2); } - if (copy_len>0) - memcpy(pstat->wpa_ie, wpa_ie-2, copy_len); + if (copy_len > 0) + memcpy(pstat->wpa_ie, wpa_ie - 2, copy_len); } @@ -1393,48 +1386,45 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec pstat->uapsd_vi = 0; pstat->uapsd_be = 0; pstat->uapsd_bk = 0; - if (pmlmepriv->qospriv.qos_option) - { - p = pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset; ie_len = 0; - for (;;) - { - p = rtw_get_ie23a(p, WLAN_EID_VENDOR_SPECIFIC, &ie_len, - pkt_len - - sizeof(struct ieee80211_hdr_3addr) - - ie_offset); - if (p != NULL) { - if (!memcmp(p+2, WMM_IE, 6)) { - + if (pmlmepriv->qospriv.qos_option) { + u8 *end = pos + left; + p = pos; + + for (;;) { + left = end - p; + p = cfg80211_find_ie(WLAN_EID_VENDOR_SPECIFIC, p, left); + if (p) { + if (!memcmp(p + 2, WMM_IE, 6)) { pstat->flags |= WLAN_STA_WME; pstat->qos_option = 1; - pstat->qos_info = *(p+8); + pstat->qos_info = *(p + 8); - pstat->max_sp_len = (pstat->qos_info>>5)&0x3; + pstat->max_sp_len = + (pstat->qos_info >> 5) & 0x3; - if ((pstat->qos_info&0xf) != 0xf) + if ((pstat->qos_info & 0xf) != 0xf) pstat->has_legacy_ac = true; else pstat->has_legacy_ac = false; - if (pstat->qos_info&0xf) - { - if (pstat->qos_info&BIT(0)) + if (pstat->qos_info & 0xf) { + if (pstat->qos_info & BIT(0)) pstat->uapsd_vo = BIT(0)|BIT(1); else pstat->uapsd_vo = 0; - if (pstat->qos_info&BIT(1)) + if (pstat->qos_info & BIT(1)) pstat->uapsd_vi = BIT(0)|BIT(1); else pstat->uapsd_vi = 0; - if (pstat->qos_info&BIT(2)) + if (pstat->qos_info & BIT(2)) pstat->uapsd_bk = BIT(0)|BIT(1); else pstat->uapsd_bk = 0; - if (pstat->qos_info&BIT(3)) + if (pstat->qos_info & BIT(3)) pstat->uapsd_be = BIT(0)|BIT(1); else pstat->uapsd_be = 0; @@ -1443,45 +1433,41 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec break; } - } - else { + } else { break; } - p = p + ie_len + 2; + p = p + p[1] + 2; } } /* save HT capabilities in the sta object */ memset(&pstat->htpriv.ht_cap, 0, sizeof(struct ieee80211_ht_cap)); - if (elems.ht_capabilities && elems.ht_capabilities_len >= sizeof(struct ieee80211_ht_cap)) - { + if (elems.ht_capabilities && elems.ht_capabilities_len >= + sizeof(struct ieee80211_ht_cap)) { pstat->flags |= WLAN_STA_HT; pstat->flags |= WLAN_STA_WME; - memcpy(&pstat->htpriv.ht_cap, elems.ht_capabilities, sizeof(struct ieee80211_ht_cap)); - + memcpy(&pstat->htpriv.ht_cap, elems.ht_capabilities, + sizeof(struct ieee80211_ht_cap)); } else pstat->flags &= ~WLAN_STA_HT; - if ((pmlmepriv->htpriv.ht_option == false) && (pstat->flags&WLAN_STA_HT)) - { + if (pmlmepriv->htpriv.ht_option == false && pstat->flags & WLAN_STA_HT){ status = WLAN_STATUS_UNSPECIFIED_FAILURE; goto OnAssocReq23aFail; } - if ((pstat->flags & WLAN_STA_HT) && - ((pstat->wpa2_pairwise_cipher&WPA_CIPHER_TKIP) || - (pstat->wpa_pairwise_cipher&WPA_CIPHER_TKIP))) - { - DBG_8723A("HT: " MAC_FMT " tried to " - "use TKIP with HT association\n", MAC_ARG(pstat->hwaddr)); + if (pstat->flags & WLAN_STA_HT && + (pstat->wpa2_pairwise_cipher & WPA_CIPHER_TKIP || + pstat->wpa_pairwise_cipher & WPA_CIPHER_TKIP)) { + DBG_8723A("HT: " MAC_FMT " tried to use TKIP with HT " + "association\n", MAC_ARG(pstat->hwaddr)); /* status = WLAN_STATUS_CIPHER_REJECTED_PER_POLICY; */ /* goto OnAssocReq23aFail; */ } - /* */ pstat->flags |= WLAN_STA_NONERP; for (i = 0; i < pstat->bssratelen; i++) { if ((pstat->bssrateset[i] & 0x7f) > 22) { @@ -1523,14 +1509,13 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA; goto OnAssocReq23aFail; - } else { pstapriv->sta_aid[pstat->aid - 1] = pstat; DBG_8723A("allocate new AID = (%d)\n", pstat->aid); } } - pstat->state &= (~WIFI_FW_ASSOC_STATE); + pstat->state &= ~WIFI_FW_ASSOC_STATE; pstat->state |= WIFI_FW_ASSOC_SUCCESS; spin_lock_bh(&pstapriv->auth_list_lock); @@ -1549,18 +1534,20 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec spin_unlock_bh(&pstapriv->asoc_list_lock); /* now the station is qualified to join our BSS... */ - if (pstat && (pstat->state & WIFI_FW_ASSOC_SUCCESS) && - (WLAN_STATUS_SUCCESS == status)) { + if (pstat && pstat->state & WIFI_FW_ASSOC_SUCCESS && + status == WLAN_STATUS_SUCCESS) { #ifdef CONFIG_8723AU_AP_MODE /* 1 bss_cap_update & sta_info_update23a */ bss_cap_update_on_sta_join23a(padapter, pstat); sta_info_update23a(padapter, pstat); /* issue assoc rsp before notify station join event. */ - if (ieee80211_is_assoc_req(frame_control)) - issue_asocrsp23a(padapter, status, pstat, WIFI_ASSOCRSP); + if (ieee80211_is_assoc_req(mgmt->frame_control)) + issue_asocrsp23a(padapter, status, pstat, + WIFI_ASSOCRSP); else - issue_asocrsp23a(padapter, status, pstat, WIFI_REASSOCRSP); + issue_asocrsp23a(padapter, status, pstat, + WIFI_REASSOCRSP); /* 2 - report to upper layer */ DBG_8723A("indicate_sta_join_event to upper layer - hostapd\n"); @@ -1576,16 +1563,15 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec asoc_class2_error: #ifdef CONFIG_8723AU_AP_MODE - issue_deauth23a(padapter, hdr->addr2, status); + issue_deauth23a(padapter, mgmt->sa, status); #endif - return _FAIL; OnAssocReq23aFail: #ifdef CONFIG_8723AU_AP_MODE pstat->aid = 0; - if (ieee80211_is_assoc_req(frame_control)) + if (ieee80211_is_assoc_req(mgmt->frame_control)) issue_asocrsp23a(padapter, status, pstat, WIFI_ASSOCRSP); else issue_asocrsp23a(padapter, status, pstat, WIFI_REASSOCRSP); -- cgit v1.2.3 From e0facfa97c02330ca7f7e0751ab73175463bb85b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:53 +0200 Subject: staging: rtl8723au: Make mlme_handlers and action_handlers return int In addition, make them all static and move the prototypes to rtw_mlme_ext.c. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 96 +++++++++++++++--------- drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 26 +------ 2 files changed, 63 insertions(+), 59 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 5264c24470b0..7452b03ab74c 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -27,6 +27,28 @@ #include #endif +static int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnProbeRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int DoReserved23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnAtim23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnDisassoc23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnAuth23aClient23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnDeAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnAction23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); + +static int on_action_spct23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnAction23a_qos(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnAction23a_dls(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnAction23a_back23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int on_action_public23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnAction23a_ht(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnAction23a_wmm(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnAction23a_p2p(struct rtw_adapter *padapter, struct recv_frame *precv_frame); + static struct mlme_handler mlme_sta_tbl[]={ {"OnAssocReq23a", &OnAssocReq23a}, {"OnAssocRsp23a", &OnAssocRsp23a}, @@ -637,8 +659,8 @@ Following are the callback functions for each subtype of the management frames *****************************************************************************/ -unsigned int OnProbeReq23a(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int +OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { const u8 *ie; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -686,8 +708,8 @@ out: return _SUCCESS; } -unsigned int OnProbeRsp23a(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int +OnProbeRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -699,8 +721,8 @@ unsigned int OnProbeRsp23a(struct rtw_adapter *padapter, return _SUCCESS; } -unsigned int OnBeacon23a(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int +OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { int cam_idx; struct sta_info *psta; @@ -828,8 +850,8 @@ _END_ONBEACON_: return _SUCCESS; } -unsigned int OnAuth23a(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int +OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { #ifdef CONFIG_8723AU_AP_MODE unsigned int auth_mode, seq; @@ -1020,8 +1042,8 @@ auth_fail: return _FAIL; } -unsigned int OnAuth23aClient23a(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int +OnAuth23aClient23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { unsigned int seq, status, algthm, offset; unsigned int go2asoc = 0; @@ -1113,7 +1135,8 @@ authclnt_fail: return _FAIL; } -unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) +static int +OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { #ifdef CONFIG_8723AU_AP_MODE u16 capab_info, listen_interval; @@ -1582,8 +1605,8 @@ OnAssocReq23aFail: return _FAIL; } -unsigned int OnAssocRsp23a(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int +OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { struct ndis_802_11_var_ies *pIE; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -1685,8 +1708,8 @@ report_assoc_result: return _SUCCESS; } -unsigned int OnDeAuth23a(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int +OnDeAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { unsigned short reason; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -1741,8 +1764,8 @@ unsigned int OnDeAuth23a(struct rtw_adapter *padapter, return _SUCCESS; } -unsigned int OnDisassoc23a(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int +OnDisassoc23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { unsigned short reason; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -1796,29 +1819,33 @@ unsigned int OnDisassoc23a(struct rtw_adapter *padapter, return _SUCCESS; } -unsigned int OnAtim23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) +static int +OnAtim23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { DBG_8723A("%s\n", __func__); return _SUCCESS; } -unsigned int on_action_spct23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) +static int +on_action_spct23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { return _FAIL; } -unsigned int OnAction23a_qos(struct rtw_adapter *padapter, struct recv_frame *precv_frame) +static int +OnAction23a_qos(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { return _SUCCESS; } -unsigned int OnAction23a_dls(struct rtw_adapter *padapter, struct recv_frame *precv_frame) +static int +OnAction23a_dls(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { return _SUCCESS; } -unsigned int OnAction23a_back23a(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int OnAction23a_back23a(struct rtw_adapter *padapter, + struct recv_frame *precv_frame) { u8 *addr; struct sta_info *psta = NULL; @@ -2014,8 +2041,8 @@ exit: return ret; } -unsigned int on_action_public23a(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int on_action_public23a(struct rtw_adapter *padapter, + struct recv_frame *precv_frame) { unsigned int ret = _FAIL; struct sk_buff *skb = precv_frame->pkt; @@ -2046,26 +2073,26 @@ exit: return ret; } -unsigned int OnAction23a_ht(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int +OnAction23a_ht(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { return _SUCCESS; } -unsigned int OnAction23a_wmm(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int +OnAction23a_wmm(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { return _SUCCESS; } -unsigned int OnAction23a_p2p(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int +OnAction23a_p2p(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { return _SUCCESS; } -unsigned int OnAction23a(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int +OnAction23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { int i; unsigned char category; @@ -2090,8 +2117,7 @@ unsigned int OnAction23a(struct rtw_adapter *padapter, return _SUCCESS; } -unsigned int DoReserved23a(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +int DoReserved23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { return _SUCCESS; } diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 9d9815dd6941..7f1cef124ee8 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -262,13 +262,13 @@ enum SCAN_STATE { struct mlme_handler { char *str; - unsigned int (*func)(struct rtw_adapter *padapter, struct recv_frame *precv_frame); + int (*func)(struct rtw_adapter *padapter, struct recv_frame *precv_frame); }; struct action_handler { unsigned int num; char* str; - unsigned int (*func)(struct rtw_adapter *padapter, struct recv_frame *precv_frame); + int (*func)(struct rtw_adapter *padapter, struct recv_frame *precv_frame); }; struct ss_res @@ -615,28 +615,6 @@ void start_clnt_auth23a(struct rtw_adapter *padapter); void start_clnt_join23a(struct rtw_adapter *padapter); void start_create_ibss23a(struct rtw_adapter *padapter); -unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnProbeRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int DoReserved23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnAtim23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnDisassoc23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnAuth23aClient23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnDeAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnAction23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); - -unsigned int on_action_spct23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnAction23a_qos(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnAction23a_dls(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnAction23a_back23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int on_action_public23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnAction23a_ht(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnAction23a_wmm(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnAction23a_p2p(struct rtw_adapter *padapter, struct recv_frame *precv_frame); - void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, int join_res); void mlmeext_sta_del_event_callback23a(struct rtw_adapter *padapter); -- cgit v1.2.3 From 4bf954b2f93e5c0e5389d40fb34a0595038dc817 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:54 +0200 Subject: staging: rtl8723au: rtw_update_protection23a(): Use cfg80211_find_ie() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index c0eaf5e21057..e7252d16c989 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -1319,11 +1319,10 @@ s32 rtw_put_snap23a(u8 *data, u16 h_proto) void rtw_update_protection23a(struct rtw_adapter *padapter, u8 *ie, uint ie_len) { - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct registry_priv *pregistrypriv = &padapter->registrypriv; - uint protection; - u8 *perp; - int erp_len; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct registry_priv *pregistrypriv = &padapter->registrypriv; + uint protection; + const u8 *p; switch (pxmitpriv->vcs_setting) { case DISABLE_VCS: @@ -1333,11 +1332,11 @@ void rtw_update_protection23a(struct rtw_adapter *padapter, u8 *ie, uint ie_len) break; case AUTO_VCS: default: - perp = rtw_get_ie23a(ie, WLAN_EID_ERP_INFO, &erp_len, ie_len); - if (perp == NULL) { + p = cfg80211_find_ie(WLAN_EID_ERP_INFO, ie, ie_len); + if (!p) pxmitpriv->vcs = NONE_VCS; - } else { - protection = (*(perp + 2)) & BIT(1); + else { + protection = (*(p + 2)) & BIT(1); if (protection) { if (pregistrypriv->vcs_type == RTS_CTS) pxmitpriv->vcs = RTS_CTS; -- cgit v1.2.3 From f0fcc4f0fa2bc42f22cc4df664876571a13a7ff8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:55 +0200 Subject: staging: rtl8723au: rtw_get_cur_max_rate23a(): use cfg80211_find_ie() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ioctl_set.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c index 6468c1ca2528..619bef3af153 100644 --- a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c @@ -539,7 +539,7 @@ exit: u16 rtw_get_cur_max_rate23a(struct rtw_adapter *adapter) { int i = 0; - u8 *p; + const u8 *p; u16 rate = 0, max_rate = 0; struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -550,16 +550,16 @@ u16 rtw_get_cur_max_rate23a(struct rtw_adapter *adapter) u8 rf_type = 0; u8 bw_40MHz = 0, short_GI_20 = 0, short_GI_40 = 0; u16 mcs_rate = 0; - u32 ht_ielen = 0; if (!check_fwstate(pmlmepriv, _FW_LINKED) && !check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) return 0; if (pmlmeext->cur_wireless_mode & (WIRELESS_11_24N|WIRELESS_11_5N)) { - p = rtw_get_ie23a(&pcur_bss->IEs[12], WLAN_EID_HT_CAPABILITY, - &ht_ielen, pcur_bss->IELength - 12); - if (p && ht_ielen > 0) { + p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, + &pcur_bss->IEs[12], + pcur_bss->IELength - 12); + if (p && p[1] > 0) { pht_capie = (struct ieee80211_ht_cap *)(p + 2); memcpy(&mcs_rate, &pht_capie->mcs, 2); -- cgit v1.2.3 From ee79b56c0ef14d0a343982b292ccbeb91a98190f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:56 +0200 Subject: staging: rtl8723au: OnBeacon23a(): Use struct ieee80211_mgmt We always receive a struct ieee80211_mgmt frame here, using just ieee80211_hdr doesn't make sense. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 7452b03ab74c..fc0c938a8fce 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -731,7 +731,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct sta_priv *pstapriv = &padapter->stapriv; struct sk_buff *skb = precv_frame->pkt; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; u8 *pframe = skb->data; uint len = skb->len; struct wlan_bssid_ex *pbss; @@ -752,7 +752,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) DBG_8723A("[WIFIDBG] Error in ESR IE is detected in " "Beacon of BSSID: %pM. Fix the length of " "ESR IE to avoid failed Beacon parsing.\n", - hdr->addr3); + mgmt->bssid); *(p + 1) = ielen - 1; } } @@ -762,7 +762,8 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) return _SUCCESS; } - if (ether_addr_equal(hdr->addr3, get_my_bssid23a(&pmlmeinfo->network))){ + if (ether_addr_equal(mgmt->bssid, + get_my_bssid23a(&pmlmeinfo->network))){ if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { /* we should update current network before auth, or some IE is wrong */ @@ -792,7 +793,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) if (((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) && (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) { - psta = rtw_get_stainfo23a(pstapriv, hdr->addr2); + psta = rtw_get_stainfo23a(pstapriv, mgmt->sa); if (psta) { ret = rtw_check_bcn_info23a(padapter, pframe, len); @@ -813,7 +814,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) } } } else if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { - psta = rtw_get_stainfo23a(pstapriv, hdr->addr2); + psta = rtw_get_stainfo23a(pstapriv, mgmt->sa); if (psta) { /* update WMM, ERP in the beacon */ /* todo: the timer is used instead of the @@ -839,7 +840,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) update_TSF23a(pmlmeext, pframe, len); /* report sta add event */ - report_add_sta_event23a(padapter, hdr->addr2, + report_add_sta_event23a(padapter, mgmt->sa, cam_idx); } } -- cgit v1.2.3 From f96355b8f001a8142d46e69d828d4ab3ef694f91 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:57 +0200 Subject: staging: rtl8723au: OnBeacon23a(): Use ieee80211_mgmt to calculate ie location Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 30 ++++++++++++++------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index fc0c938a8fce..f810d8f8e384 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -726,23 +726,23 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { int cam_idx; struct sta_info *psta; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct sta_priv *pstapriv = &padapter->stapriv; struct sk_buff *skb = precv_frame->pkt; struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; u8 *pframe = skb->data; - uint len = skb->len; + int pkt_len = skb->len; struct wlan_bssid_ex *pbss; int ret = _SUCCESS; - u8 *p = NULL; + u8 *p, *pie; + int pie_len; u32 ielen = 0; - p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + - _BEACON_IE_OFFSET_, WLAN_EID_EXT_SUPP_RATES, &ielen, - len - sizeof(struct ieee80211_hdr_3addr) - - _BEACON_IE_OFFSET_); + pie = mgmt->u.beacon.variable; + pie_len = pkt_len - offsetof(struct ieee80211_mgmt, u.beacon.variable); + p = rtw_get_ie23a(pie, WLAN_EID_EXT_SUPP_RATES, &ielen, pie_len); if ((p != NULL) && (ielen > 0)) { if ((*(p + 1 + ielen) == 0x2D) && (*(p + 2 + ielen) != 0x2D)) { /* Invalid value 0x2D is detected in Extended Supported @@ -780,10 +780,10 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) } /* check the vendor of the assoc AP */ - pmlmeinfo->assoc_AP_vendor = check_assoc_AP23a(pframe + sizeof(struct ieee80211_hdr_3addr), len-sizeof(struct ieee80211_hdr_3addr)); + pmlmeinfo->assoc_AP_vendor = check_assoc_AP23a(pframe + sizeof(struct ieee80211_hdr_3addr), pkt_len-sizeof(struct ieee80211_hdr_3addr)); /* update TSF Value */ - update_TSF23a(pmlmeext, pframe, len); + update_TSF23a(pmlmeext, pframe, pkt_len); /* start auth */ start_clnt_auth23a(padapter); @@ -796,7 +796,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) psta = rtw_get_stainfo23a(pstapriv, mgmt->sa); if (psta) { ret = rtw_check_bcn_info23a(padapter, pframe, - len); + pkt_len); if (!ret) { DBG_8723A_LEVEL(_drv_always_, "ap has changed, " @@ -810,7 +810,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) if ((sta_rx_pkts(psta) & 0xf) == 0) { /* DBG_8723A("update_bcn_info\n"); */ update_beacon23a_info(padapter, pframe, - len, psta); + pkt_len, psta); } } } else if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { @@ -822,7 +822,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) if ((sta_rx_pkts(psta) & 0xf) == 0) { /* DBG_8723A("update_bcn_info\n"); */ update_beacon23a_info(padapter, pframe, - len, psta); + pkt_len, psta); } } else { /* allocate a new CAM entry for IBSS station */ @@ -831,13 +831,15 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) goto _END_ONBEACON_; /* get supported rate */ - if (update_sta_support_rate23a(padapter, (pframe + sizeof(struct ieee80211_hdr_3addr) + _BEACON_IE_OFFSET_), (len - sizeof(struct ieee80211_hdr_3addr) - _BEACON_IE_OFFSET_), cam_idx) == _FAIL) { + if (update_sta_support_rate23a(padapter, pie, + pie_len, + cam_idx) == _FAIL) { pmlmeinfo->FW_sta_info[cam_idx].status = 0; goto _END_ONBEACON_; } /* update TSF Value */ - update_TSF23a(pmlmeext, pframe, len); + update_TSF23a(pmlmeext, pframe, pkt_len); /* report sta add event */ report_add_sta_event23a(padapter, mgmt->sa, -- cgit v1.2.3 From c146551f1a96eba625e80889fb947e7bd769bb78 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:58 +0200 Subject: staging: rtl8723au: Make rtw_check_bcn_info23() take a ieee80211_mgmt pointer Clean up the code by passing a struct ieee80211_mgmt pointer instead of a raw frame pointer. In addition check we receive a beacon frame, anything else here is an error. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 24 +++++++++++++++--------- drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 3 ++- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index f810d8f8e384..a79861e4250c 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -795,7 +795,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) { psta = rtw_get_stainfo23a(pstapriv, mgmt->sa); if (psta) { - ret = rtw_check_bcn_info23a(padapter, pframe, + ret = rtw_check_bcn_info23a(padapter, mgmt, pkt_len); if (!ret) { DBG_8723A_LEVEL(_drv_always_, diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 17e32071b514..ac9d39a7c4f4 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -856,7 +856,8 @@ void VCS_update23a(struct rtw_adapter *padapter, struct sta_info *psta) } } -int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u8 *pframe, u32 packet_len) +int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, + struct ieee80211_mgmt *mgmt, u32 packet_len) { unsigned int len; unsigned char *p; @@ -874,12 +875,16 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u8 *pframe, u32 packet_le u32 bcn_channel; unsigned short ht_cap_info; unsigned char ht_info_infos_0; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) pframe; - u8 *pbssid = hdr->addr3; if (is_client_associated_to_ap23a(Adapter) == false) return true; + if (unlikely(!ieee80211_is_beacon(mgmt->frame_control))) { + printk(KERN_WARNING "%s: received a non beacon frame!\n", + __func__); + return false; + } + len = packet_len - sizeof(struct ieee80211_hdr_3addr); if (len > MAX_IE_SZ) { @@ -887,23 +892,24 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u8 *pframe, u32 packet_le return _FAIL; } - if (memcmp(cur_network->network.MacAddress, pbssid, 6)) { - DBG_8723A("Oops: rtw_check_network_encrypt linked but recv other bssid bcn\n" MAC_FMT MAC_FMT, - MAC_ARG(pbssid), MAC_ARG(cur_network->network.MacAddress)); + if (memcmp(cur_network->network.MacAddress, mgmt->bssid, 6)) { + DBG_8723A("Oops: rtw_check_network_encrypt linked but recv " + "other bssid bcn\n" MAC_FMT MAC_FMT, + MAC_ARG(mgmt->bssid), + MAC_ARG(cur_network->network.MacAddress)); return true; } bssid = (struct wlan_bssid_ex *)kzalloc(sizeof(struct wlan_bssid_ex), GFP_ATOMIC); - if (ieee80211_is_beacon(hdr->frame_control)) - bssid->reserved = 1; + bssid->reserved = 1; bssid->Length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + len; /* below is to copy the information element */ bssid->IELength = len; - memcpy(bssid->IEs, (pframe + sizeof(struct ieee80211_hdr_3addr)), bssid->IELength); + memcpy(bssid->IEs, &mgmt->u, bssid->IELength); /* check bw and channel offset */ /* parsing HT_CAP_IE */ diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 7f1cef124ee8..275f891b6c64 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -533,7 +533,8 @@ void VCS_update23a(struct rtw_adapter *padapter, struct sta_info *psta); void update_beacon23a_info(struct rtw_adapter *padapter, u8 *pframe, uint len, struct sta_info *psta); -int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u8 *pframe, u32 packet_len); +int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, + struct ieee80211_mgmt *mgmt, u32 packet_len); void update_IOT_info23a(struct rtw_adapter *padapter); void update_capinfo23a(struct rtw_adapter *Adapter, u16 updateCap); void update_wireless_mode23a(struct rtw_adapter * padapter); -- cgit v1.2.3 From 3ffa4355a212434a4884946996cbed76d255765f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:59 +0200 Subject: staging: rtl8723au: rtw_check_bcn_info23a(): Use cfg80211_find_ie() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 117 +++++++++++++------------ 1 file changed, 62 insertions(+), 55 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index ac9d39a7c4f4..ff5cbc99dc47 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -857,10 +857,8 @@ void VCS_update23a(struct rtw_adapter *padapter, struct sta_info *psta) } int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, - struct ieee80211_mgmt *mgmt, u32 packet_len) + struct ieee80211_mgmt *mgmt, u32 pkt_len) { - unsigned int len; - unsigned char *p; unsigned short val16; struct wlan_network *cur_network = &Adapter->mlmepriv.cur_network; u16 wpa_len = 0, rsn_len = 0; @@ -875,6 +873,9 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u32 bcn_channel; unsigned short ht_cap_info; unsigned char ht_info_infos_0; + int len, pie_len, ie_offset; + const u8 *p; + u8 *pie; if (is_client_associated_to_ap23a(Adapter) == false) return true; @@ -885,7 +886,7 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, return false; } - len = packet_len - sizeof(struct ieee80211_hdr_3addr); + len = pkt_len - sizeof(struct ieee80211_hdr_3addr); if (len > MAX_IE_SZ) { DBG_8723A("%s IE too long for survey event\n", __func__); @@ -913,70 +914,76 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, /* check bw and channel offset */ /* parsing HT_CAP_IE */ - p = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, - WLAN_EID_HT_CAPABILITY, - &len, bssid->IELength - _FIXED_IE_LENGTH_); - if (p && len>0) { - pht_cap = (struct ieee80211_ht_cap *)(p + 2); - ht_cap_info = pht_cap->cap_info; - } else { - ht_cap_info = 0; - } + ie_offset = offsetof(struct ieee80211_mgmt, u.beacon.variable) - + offsetof(struct ieee80211_mgmt, u); + pie = bssid->IEs + ie_offset; + pie_len = pkt_len - ie_offset; + + p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, pie, pie_len); + if (p && p[1] > 0) { + pht_cap = (struct ieee80211_ht_cap *)(p + 2); + ht_cap_info = pht_cap->cap_info; + } else + ht_cap_info = 0; + /* parsing HT_INFO_IE */ - p = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, WLAN_EID_HT_OPERATION, - &len, bssid->IELength - _FIXED_IE_LENGTH_); - if (p && len>0) { - pht_info = (struct HT_info_element *)(p + 2); - ht_info_infos_0 = pht_info->infos[0]; - } else { - ht_info_infos_0 = 0; - } + p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, pie, pie_len); + if (p && p[1] > 0) { + pht_info = (struct HT_info_element *)(p + 2); + ht_info_infos_0 = pht_info->infos[0]; + } else + ht_info_infos_0 = 0; + if (ht_cap_info != cur_network->BcnInfo.ht_cap_info || - ((ht_info_infos_0&0x03) != (cur_network->BcnInfo.ht_info_infos_0&0x03))) { - DBG_8723A("%s bcn now: ht_cap_info:%x ht_info_infos_0:%x\n", __func__, - ht_cap_info, ht_info_infos_0); - DBG_8723A("%s bcn link: ht_cap_info:%x ht_info_infos_0:%x\n", __func__, - cur_network->BcnInfo.ht_cap_info, cur_network->BcnInfo.ht_info_infos_0); - DBG_8723A("%s bw mode change, disconnect\n", __func__); - /* bcn_info_update */ - cur_network->BcnInfo.ht_cap_info = ht_cap_info; - cur_network->BcnInfo.ht_info_infos_0 = ht_info_infos_0; - /* to do : need to check that whether modify related register of BB or not */ + ((ht_info_infos_0 & 0x03) != + (cur_network->BcnInfo.ht_info_infos_0 & 0x03))) { + DBG_8723A("%s bcn now: ht_cap_info:%x ht_info_infos_0:%x\n", + __func__, ht_cap_info, ht_info_infos_0); + DBG_8723A("%s bcn link: ht_cap_info:%x ht_info_infos_0:%x\n", + __func__, cur_network->BcnInfo.ht_cap_info, + cur_network->BcnInfo.ht_info_infos_0); + DBG_8723A("%s bw mode change, disconnect\n", __func__); + /* bcn_info_update */ + cur_network->BcnInfo.ht_cap_info = ht_cap_info; + cur_network->BcnInfo.ht_info_infos_0 = ht_info_infos_0; + /* to do : need to check that whether modify related + register of BB or not */ } /* Checking for channel */ - p = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, WLAN_EID_DS_PARAMS, - &len, bssid->IELength - _FIXED_IE_LENGTH_); - if (p) { - bcn_channel = *(p + 2); - } else {/* In 5G, some ap do not have DSSET IE checking HT info for channel */ - p = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, - WLAN_EID_HT_OPERATION, &len, - bssid->IELength - _FIXED_IE_LENGTH_); - if (pht_info) { - bcn_channel = pht_info->primary_channel; - } else { /* we don't find channel IE, so don't check it */ - DBG_8723A("Oops: %s we don't find channel IE, so don't check it\n", __func__); - bcn_channel = Adapter->mlmeextpriv.cur_channel; - } + p = cfg80211_find_ie(WLAN_EID_DS_PARAMS, pie, pie_len); + if (p) + bcn_channel = p[2]; + else { + /* In 5G, some ap do not have DSSET IE checking HT + info for channel */ + p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, pie, pie_len); + + if (pht_info) + bcn_channel = pht_info->primary_channel; + else { /* we don't find channel IE, so don't check it */ + DBG_8723A("Oops: %s we don't find channel IE, so don't " + "check it\n", __func__); + bcn_channel = Adapter->mlmeextpriv.cur_channel; + } } if (bcn_channel != Adapter->mlmeextpriv.cur_channel) { - DBG_8723A("%s beacon channel:%d cur channel:%d disconnect\n", __func__, - bcn_channel, Adapter->mlmeextpriv.cur_channel); - goto _mismatch; + DBG_8723A("%s beacon channel:%d cur channel:%d disconnect\n", + __func__, bcn_channel, + Adapter->mlmeextpriv.cur_channel); + goto _mismatch; } /* checking SSID */ - if ((p = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, WLAN_EID_SSID, - &len, bssid->IELength - _FIXED_IE_LENGTH_)) == - NULL) { - DBG_8723A("%s marc: cannot find SSID for survey event\n", __func__); + p = cfg80211_find_ie(WLAN_EID_SSID, pie, pie_len); + if (!p) { + DBG_8723A("%s marc: cannot find SSID for survey event\n", + __func__); hidden_ssid = true; - } else { + } else hidden_ssid = false; - } - if ((NULL != p) && (false == hidden_ssid && (*(p + 1)))) { + if (p && (hidden_ssid == false && *(p + 1))) { memcpy(bssid->Ssid.ssid, (p + 2), *(p + 1)); bssid->Ssid.ssid_len = *(p + 1); } else { -- cgit v1.2.3 From 82695d5ca3a5633dbc2395e2bc9982520362a5f2 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:00 +0200 Subject: staging: rtl8723au: rtw_check_bcn_info23a(): Clean up code obfuscation There is no point doing a double check of the IE, either we found an WLAN_EID_SSID or we didn't. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index ff5cbc99dc47..43bfefcc1b7b 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -867,7 +867,6 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, int group_cipher = 0, pairwise_cipher = 0, is_8021x = 0; unsigned char *pbuf; u32 wpa_ielen = 0; - u32 hidden_ssid = 0; struct HT_info_element *pht_info = NULL; struct ieee80211_ht_cap *pht_cap = NULL; u32 bcn_channel; @@ -976,17 +975,12 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, /* checking SSID */ p = cfg80211_find_ie(WLAN_EID_SSID, pie, pie_len); - if (!p) { + if (p && p[1]) { + memcpy(bssid->Ssid.ssid, p + 2, p[1]); + bssid->Ssid.ssid_len = p[1]; + } else { DBG_8723A("%s marc: cannot find SSID for survey event\n", __func__); - hidden_ssid = true; - } else - hidden_ssid = false; - - if (p && (hidden_ssid == false && *(p + 1))) { - memcpy(bssid->Ssid.ssid, (p + 2), *(p + 1)); - bssid->Ssid.ssid_len = *(p + 1); - } else { bssid->Ssid.ssid_len = 0; bssid->Ssid.ssid[0] = '\0'; } -- cgit v1.2.3 From bf3502742533fea36d41f71dc1c341e0a0a2e167 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:01 +0200 Subject: staging: rtl8723au: update_sta_support_rate23a(): Use cfg80211_find_ie() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 43bfefcc1b7b..909acb97f16e 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -1570,26 +1570,25 @@ void update_bmc_sta_support_rate23a(struct rtw_adapter *padapter, u32 mac_id) } } -int update_sta_support_rate23a(struct rtw_adapter *padapter, u8 *pvar_ie, uint var_ie_len, int cam_idx) +int update_sta_support_rate23a(struct rtw_adapter *padapter, u8 *pvar_ie, + uint var_ie_len, int cam_idx) { - unsigned int ie_len; - struct ndis_802_11_var_ies *pIE; - int supportRateNum = 0; + int supportRateNum = 0; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + const u8 *p; - pIE = (struct ndis_802_11_var_ies *)rtw_get_ie23a(pvar_ie, - WLAN_EID_SUPP_RATES, - &ie_len, var_ie_len); - if (pIE == NULL) + p = cfg80211_find_ie(WLAN_EID_SUPP_RATES, pvar_ie, var_ie_len); + if (!p) return _FAIL; - memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates, pIE->data, ie_len); - supportRateNum = ie_len; + memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates, p + 2, p[1]); + supportRateNum = p[1]; - pIE = (struct ndis_802_11_var_ies *)rtw_get_ie23a(pvar_ie, WLAN_EID_EXT_SUPP_RATES, &ie_len, var_ie_len); - if (pIE) - memcpy((pmlmeinfo->FW_sta_info[cam_idx].SupportedRates + supportRateNum), pIE->data, ie_len); + p = cfg80211_find_ie(WLAN_EID_EXT_SUPP_RATES, pvar_ie, var_ie_len); + if (p) + memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates + + supportRateNum, p + 2, p[1]); return _SUCCESS; } -- cgit v1.2.3 From 731f9da74b49a939d2d8cc0197b4246b614bd2d6 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:02 +0200 Subject: staging: rtl8723au: start_bss_network(): Use cfg80211_find_ie() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index f04d9dfb4446..d049ba770900 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -646,11 +646,10 @@ static void update_hw_ht_param(struct rtw_adapter *padapter) static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) { - u8 *p; + const u8 *p; u8 val8, cur_channel, cur_bwmode, cur_ch_offset; u16 bcn_interval; u32 acparm; - int ie_len; struct registry_priv *pregpriv = &padapter->registrypriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv* psecuritypriv = &padapter->securitypriv; @@ -727,18 +726,21 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) DYNAMIC_ALL_FUNC_ENABLE); } /* set channel, bwmode */ - p = rtw_get_ie23a((pnetwork->IEs + sizeof(struct ndis_802_11_fixed_ies)), - WLAN_EID_HT_OPERATION, &ie_len, (pnetwork->IELength - - sizeof(struct ndis_802_11_fixed_ies))); - if (p && ie_len) { - pht_info = (struct HT_info_element *)(p+2); - - if ((pregpriv->cbw40_enable) && (pht_info->infos[0] & BIT(2))) { + p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, + pnetwork->IEs + + sizeof(struct ndis_802_11_fixed_ies), + pnetwork->IELength - + sizeof(struct ndis_802_11_fixed_ies)); + if (p && p[1]) { + pht_info = (struct HT_info_element *)(p + 2); + + if (pregpriv->cbw40_enable && pht_info->infos[0] & BIT(2)) { /* switch to the 40M Hz mode */ cur_bwmode = HT_CHANNEL_WIDTH_40; switch (pht_info->infos[0] & 0x3) { case 1: - /* pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; */ + /* pmlmeext->cur_ch_offset = + HAL_PRIME_CHNL_OFFSET_LOWER; */ cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; break; case 3: -- cgit v1.2.3 From 95c4345abf22a447c39efe41d3f66bfb645ce13c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:03 +0200 Subject: staging: rtl8723au: Use const * for parsing wpa IEs Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 15 ++++++++------- drivers/staging/rtl8723au/include/ieee80211.h | 8 ++++---- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index d7a6b47b49b3..88631a713a5d 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -514,7 +514,7 @@ unsigned char *rtw_get_wpa2_ie23a(unsigned char *pie, int *rsn_ie_len, int limit return rtw_get_ie23a(pie, _WPA2_IE_ID_, rsn_ie_len, limit); } -int rtw_get_wpa_cipher_suite23a(u8 *s) +int rtw_get_wpa_cipher_suite23a(const u8 *s) { if (!memcmp(s, WPA_CIPHER_SUITE_NONE23A, WPA_SELECTOR_LEN)) return WPA_CIPHER_NONE; @@ -530,7 +530,7 @@ int rtw_get_wpa_cipher_suite23a(u8 *s) return 0; } -int rtw_get_wpa2_cipher_suite23a(u8 *s) +int rtw_get_wpa2_cipher_suite23a(const u8 *s) { if (!memcmp(s, RSN_CIPHER_SUITE_NONE23A, RSN_SELECTOR_LEN)) return WPA_CIPHER_NONE; @@ -546,11 +546,11 @@ int rtw_get_wpa2_cipher_suite23a(u8 *s) return 0; } -int rtw_parse_wpa_ie23a(u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x) +int rtw_parse_wpa_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x) { int i, ret = _SUCCESS; int left, count; - u8 *pos; + const u8 *pos; u8 SUITE_1X[4] = {0x00, 0x50, 0xf2, 1}; if (wpa_ie_len <= 0) { @@ -626,12 +626,12 @@ int rtw_parse_wpa_ie23a(u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pair return ret; } -int rtw_parse_wpa2_ie23a(u8* rsn_ie, int rsn_ie_len, int *group_cipher, +int rtw_parse_wpa2_ie23a(const u8* rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x) { int i, ret = _SUCCESS; int left, count; - u8 *pos; + const u8 *pos; u8 SUITE_1X[4] = {0x00, 0x0f, 0xac, 0x01}; if (rsn_ie_len <= 0) { @@ -1277,10 +1277,11 @@ int ieee80211_is_empty_essid23a(const char *essid, int essid_len) static int rtw_get_cipher_info(struct wlan_network *pnetwork) { u32 wpa_ielen; - unsigned char *pbuf; + const u8 *pbuf; int group_cipher = 0, pairwise_cipher = 0, is8021x = 0; int ret = _FAIL; int r; + pbuf = rtw_get_wpa_ie23a(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength - 12); diff --git a/drivers/staging/rtl8723au/include/ieee80211.h b/drivers/staging/rtl8723au/include/ieee80211.h index f2824c3c2f9c..b82f3150cfcf 100644 --- a/drivers/staging/rtl8723au/include/ieee80211.h +++ b/drivers/staging/rtl8723au/include/ieee80211.h @@ -539,10 +539,10 @@ void rtw_set_supported_rate23a(u8* SupportedRates, uint mode) ; unsigned char *rtw_get_wpa_ie23a(unsigned char *pie, int *wpa_ie_len, int limit); unsigned char *rtw_get_wpa2_ie23a(unsigned char *pie, int *rsn_ie_len, int limit); -int rtw_get_wpa_cipher_suite23a(u8 *s); -int rtw_get_wpa2_cipher_suite23a(u8 *s); -int rtw_parse_wpa_ie23a(u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x); -int rtw_parse_wpa2_ie23a(u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x); +int rtw_get_wpa_cipher_suite23a(const u8 *s); +int rtw_get_wpa2_cipher_suite23a(const u8 *s); +int rtw_parse_wpa_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x); +int rtw_parse_wpa2_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x); int rtw_get_sec_ie23a(u8 *in_ie,uint in_len,u8 *rsn_ie,u16 *rsn_len,u8 *wpa_ie,u16 *wpa_len); -- cgit v1.2.3 From d7f03698271d71e510a0650c22c0155711ca9d0f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:04 +0200 Subject: staging: rtl8723au: rtw_get_cipher_info(): Convert to use cfg80211_* API Use cfg80211_find_ie() and cfg80211_find_vendor_ie() rather than own hacks. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index 88631a713a5d..f3904ec93917 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -1276,19 +1276,24 @@ int ieee80211_is_empty_essid23a(const char *essid, int essid_len) static int rtw_get_cipher_info(struct wlan_network *pnetwork) { - u32 wpa_ielen; const u8 *pbuf; int group_cipher = 0, pairwise_cipher = 0, is8021x = 0; int ret = _FAIL; - int r; + int r, offset, plen; + char *pie; - pbuf = rtw_get_wpa_ie23a(&pnetwork->network.IEs[12], &wpa_ielen, - pnetwork->network.IELength - 12); + offset = offsetof(struct ieee80211_mgmt, u.beacon.variable) - + offsetof(struct ieee80211_mgmt, u); + pie = &pnetwork->network.IEs[offset]; + plen = pnetwork->network.IELength - offset; - if (pbuf && (wpa_ielen > 0)) { + pbuf = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT, + WLAN_OUI_TYPE_MICROSOFT_WPA, pie, plen); + + if (pbuf && pbuf[1] > 0) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("rtw_get_cipher_info: wpa_ielen: %d", wpa_ielen)); - r = rtw_parse_wpa_ie23a(pbuf, wpa_ielen + 2, &group_cipher, + ("rtw_get_cipher_info: wpa_ielen: %d", pbuf[1])); + r = rtw_parse_wpa_ie23a(pbuf, pbuf[1] + 2, &group_cipher, &pairwise_cipher, &is8021x); if (r == _SUCCESS) { pnetwork->BcnInfo.pairwise_cipher = pairwise_cipher; @@ -1302,13 +1307,12 @@ static int rtw_get_cipher_info(struct wlan_network *pnetwork) ret = _SUCCESS; } } else { - pbuf = rtw_get_wpa2_ie23a(&pnetwork->network.IEs[12], &wpa_ielen, - pnetwork->network.IELength - 12); + pbuf = cfg80211_find_ie(WLAN_EID_RSN, pie, plen); - if (pbuf && (wpa_ielen > 0)) { + if (pbuf && pbuf[1] > 0) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("get RSN IE\n")); - r = rtw_parse_wpa2_ie23a(pbuf, wpa_ielen + 2, + r = rtw_parse_wpa2_ie23a(pbuf, pbuf[1] + 2, &group_cipher, &pairwise_cipher, &is8021x); if (r == _SUCCESS) { -- cgit v1.2.3 From c37618360ef53c814177357299b789db0db041a8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:05 +0200 Subject: staging: rtl8723au: rtw_check_bcn_info23a(): Remove excessive brackets Remove excessive brackets and some general cleanups Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 96 ++++++++++++++++---------- 1 file changed, 61 insertions(+), 35 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 909acb97f16e..9ed25c62918f 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -859,22 +859,22 @@ void VCS_update23a(struct rtw_adapter *padapter, struct sta_info *psta) int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, struct ieee80211_mgmt *mgmt, u32 pkt_len) { - unsigned short val16; struct wlan_network *cur_network = &Adapter->mlmepriv.cur_network; - u16 wpa_len = 0, rsn_len = 0; - u8 encryp_protocol = 0; + struct HT_info_element *pht_info; + struct ieee80211_ht_cap *pht_cap; struct wlan_bssid_ex *bssid; - int group_cipher = 0, pairwise_cipher = 0, is_8021x = 0; - unsigned char *pbuf; + unsigned short val16; + u16 wpa_len = 0, rsn_len = 0; + u8 encryp_protocol; + int group_cipher = 0, pairwise_cipher = 0, is_8021x = 0, r; u32 wpa_ielen = 0; - struct HT_info_element *pht_info = NULL; - struct ieee80211_ht_cap *pht_cap = NULL; u32 bcn_channel; - unsigned short ht_cap_info; - unsigned char ht_info_infos_0; + unsigned short ht_cap_info; + unsigned char ht_info_infos_0; int len, pie_len, ie_offset; const u8 *p; u8 *pie; + unsigned char *pbuf; if (is_client_associated_to_ap23a(Adapter) == false) return true; @@ -922,16 +922,20 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, if (p && p[1] > 0) { pht_cap = (struct ieee80211_ht_cap *)(p + 2); ht_cap_info = pht_cap->cap_info; - } else + } else { + pht_cap = NULL; ht_cap_info = 0; + } /* parsing HT_INFO_IE */ p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, pie, pie_len); if (p && p[1] > 0) { pht_info = (struct HT_info_element *)(p + 2); ht_info_infos_0 = pht_info->infos[0]; - } else + } else { + pht_info = NULL; ht_info_infos_0 = 0; + } if (ht_cap_info != cur_network->BcnInfo.ht_cap_info || ((ht_info_infos_0 & 0x03) != @@ -1011,60 +1015,82 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, bssid->Privacy = 0; RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("%s(): cur_network->network.Privacy is %d, bssid.Privacy is %d\n", - __func__, cur_network->network.Privacy, bssid->Privacy)); + ("%s(): cur_network->network.Privacy is %d, bssid.Privacy " + "is %d\n", __func__, cur_network->network.Privacy, + bssid->Privacy)); if (cur_network->network.Privacy != bssid->Privacy) { DBG_8723A("%s(), privacy is not match return FAIL\n", __func__); goto _mismatch; } - rtw_get_sec_ie23a(bssid->IEs, bssid->IELength, NULL,&rsn_len, NULL,&wpa_len); + rtw_get_sec_ie23a(bssid->IEs, bssid->IELength, NULL, &rsn_len, NULL, + &wpa_len); - if (rsn_len > 0) { + if (rsn_len > 0) encryp_protocol = ENCRYP_PROTOCOL_WPA2; - } else if (wpa_len > 0) { + else if (wpa_len > 0) encryp_protocol = ENCRYP_PROTOCOL_WPA; - } else { + else { if (bssid->Privacy) encryp_protocol = ENCRYP_PROTOCOL_WEP; + else + encryp_protocol = ENCRYP_PROTOCOL_OPENSYS; } if (cur_network->BcnInfo.encryp_protocol != encryp_protocol) { - DBG_8723A("%s(): enctyp is not match , return FAIL\n", __func__); + DBG_8723A("%s(): enctyp is not match, return FAIL\n", __func__); goto _mismatch; } - if (encryp_protocol == ENCRYP_PROTOCOL_WPA || encryp_protocol == ENCRYP_PROTOCOL_WPA2) { + if (encryp_protocol == ENCRYP_PROTOCOL_WPA || + encryp_protocol == ENCRYP_PROTOCOL_WPA2) { pbuf = rtw_get_wpa_ie23a(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12); if (pbuf && (wpa_ielen>0)) { - if (_SUCCESS == rtw_parse_wpa_ie23a(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is_8021x)) { + r = rtw_parse_wpa_ie23a(pbuf, wpa_ielen+2, + &group_cipher, + &pairwise_cipher, &is_8021x); + if (r == _SUCCESS) RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("%s pnetwork->pairwise_cipher: %d, group_cipher is %d, is_8021x is %d\n", __func__, - pairwise_cipher, group_cipher, is_8021x)); - } + ("%s pnetwork->pairwise_cipher: %d, " + "group_cipher is %d, is_8021x is " + "%d\n", __func__, pairwise_cipher, + group_cipher, is_8021x)); } else { pbuf = rtw_get_wpa2_ie23a(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12); - if (pbuf && (wpa_ielen>0)) { - if (_SUCCESS == rtw_parse_wpa2_ie23a(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is_8021x)) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("%s pnetwork->pairwise_cipher: %d, pnetwork->group_cipher is %d, is_802x is %d\n", - __func__, pairwise_cipher, group_cipher, is_8021x)); - } + if (pbuf && wpa_ielen > 0) { + r = rtw_parse_wpa2_ie23a(pbuf, wpa_ielen + 2, + &group_cipher, + &pairwise_cipher, + &is_8021x); + if (r == _SUCCESS) + RT_TRACE(_module_rtl871x_mlme_c_, + _drv_info_, + ("%s pnetwork->pairwise_cipher" + ": %d, pnetwork->group_cipher" + " is %d, is_802x is %d\n", + __func__, pairwise_cipher, + group_cipher, is_8021x)); } } RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, - ("%s cur_network->group_cipher is %d: %d\n", __func__, cur_network->BcnInfo.group_cipher, group_cipher)); - if (pairwise_cipher != cur_network->BcnInfo.pairwise_cipher || group_cipher != cur_network->BcnInfo.group_cipher) { - DBG_8723A("%s pairwise_cipher(%x:%x) or group_cipher(%x:%x) is not match , return FAIL\n", __func__, - pairwise_cipher, cur_network->BcnInfo.pairwise_cipher, - group_cipher, cur_network->BcnInfo.group_cipher); + ("%s cur_network->group_cipher is %d: %d\n", __func__, + cur_network->BcnInfo.group_cipher, group_cipher)); + if (pairwise_cipher != cur_network->BcnInfo.pairwise_cipher || + group_cipher != cur_network->BcnInfo.group_cipher) { + DBG_8723A("%s pairwise_cipher(%x:%x) or group_cipher " + "(%x:%x) is not match, return FAIL\n", + __func__, pairwise_cipher, + cur_network->BcnInfo.pairwise_cipher, + group_cipher, + cur_network->BcnInfo.group_cipher); goto _mismatch; } if (is_8021x != cur_network->BcnInfo.is_8021x) { - DBG_8723A("%s authentication is not match , return FAIL\n", __func__); + DBG_8723A("%s authentication is not match, return " + "FAIL\n", __func__); goto _mismatch; } } -- cgit v1.2.3 From f88ca60404f53af18e7a17a9ffab87c59410737c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:06 +0200 Subject: staging: rtl8723au: rtw_check_bcn_info23a(): Use cfg80211 to find WPA info Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 9ed25c62918f..e8127cb6c33a 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -867,14 +867,12 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u16 wpa_len = 0, rsn_len = 0; u8 encryp_protocol; int group_cipher = 0, pairwise_cipher = 0, is_8021x = 0, r; - u32 wpa_ielen = 0; u32 bcn_channel; unsigned short ht_cap_info; unsigned char ht_info_infos_0; int len, pie_len, ie_offset; const u8 *p; u8 *pie; - unsigned char *pbuf; if (is_client_associated_to_ap23a(Adapter) == false) return true; @@ -1044,10 +1042,11 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, if (encryp_protocol == ENCRYP_PROTOCOL_WPA || encryp_protocol == ENCRYP_PROTOCOL_WPA2) { - pbuf = rtw_get_wpa_ie23a(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12); - if (pbuf && (wpa_ielen>0)) { - r = rtw_parse_wpa_ie23a(pbuf, wpa_ielen+2, - &group_cipher, + p = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT, + WLAN_OUI_TYPE_MICROSOFT_WPA, + pie, pie_len); + if (p && p[1] > 0) { + r = rtw_parse_wpa_ie23a(p, p[1] + 2, &group_cipher, &pairwise_cipher, &is_8021x); if (r == _SUCCESS) RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, @@ -1056,10 +1055,10 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, "%d\n", __func__, pairwise_cipher, group_cipher, is_8021x)); } else { - pbuf = rtw_get_wpa2_ie23a(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12); + p = cfg80211_find_ie(WLAN_EID_RSN, pie, pie_len); - if (pbuf && wpa_ielen > 0) { - r = rtw_parse_wpa2_ie23a(pbuf, wpa_ielen + 2, + if (p && p[1] > 0) { + r = rtw_parse_wpa2_ie23a(p, p[1] + 2, &group_cipher, &pairwise_cipher, &is_8021x); -- cgit v1.2.3 From 58aedb498f8a9870ff871058d4b91d77457fc14c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:07 +0200 Subject: staging: rtl8723au: rtw_cfg80211_set_wpa_ie(): Use cfg80211_ API Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 34 +++++++++++------------ 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index a3e17f99a278..e5c0ba74ea66 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -1686,9 +1686,7 @@ static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie, u8 *buf = NULL, *pos = NULL; int group_cipher = 0, pairwise_cipher = 0; int ret = 0; - int wpa_ielen = 0; - int wpa2_ielen = 0; - u8 *pwpa, *pwpa2; + const u8 *pwpa, *pwpa2; int i; if (!pie || !ielen) { @@ -1723,33 +1721,35 @@ static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie, goto exit; } - pwpa = rtw_get_wpa_ie23a(buf, &wpa_ielen, ielen); - if (pwpa && wpa_ielen > 0) { - if (rtw_parse_wpa_ie23a(pwpa, wpa_ielen + 2, &group_cipher, - &pairwise_cipher, NULL) == _SUCCESS) { + pwpa = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT, + WLAN_OUI_TYPE_MICROSOFT_WPA, + buf, ielen); + if (pwpa && pwpa[1] > 0) { + if (rtw_parse_wpa_ie23a(pwpa, pwpa[1] + 2, &group_cipher, + &pairwise_cipher, NULL) == _SUCCESS) { padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPAPSK; - memcpy(padapter->securitypriv.supplicant_ie, &pwpa[0], - wpa_ielen + 2); + memcpy(padapter->securitypriv.supplicant_ie, pwpa, + pwpa[1] + 2); - DBG_8723A("got wpa_ie, wpa_ielen:%u\n", wpa_ielen); + DBG_8723A("got wpa_ie, wpa_ielen:%u\n", pwpa[1]); } } - pwpa2 = rtw_get_wpa2_ie23a(buf, &wpa2_ielen, ielen); - if (pwpa2 && wpa2_ielen > 0) { - if (rtw_parse_wpa2_ie23a (pwpa2, wpa2_ielen + 2, &group_cipher, - &pairwise_cipher, NULL) == _SUCCESS) { + pwpa2 = cfg80211_find_ie(WLAN_EID_RSN, buf, ielen); + if (pwpa2 && pwpa2[1] > 0) { + if (rtw_parse_wpa2_ie23a (pwpa2, pwpa2[1] + 2, &group_cipher, + &pairwise_cipher, NULL) == _SUCCESS) { padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPA2PSK; - memcpy(padapter->securitypriv.supplicant_ie, &pwpa2[0], - wpa2_ielen + 2); + memcpy(padapter->securitypriv.supplicant_ie, pwpa2, + pwpa2[1] + 2); - DBG_8723A("got wpa2_ie, wpa2_ielen:%u\n", wpa2_ielen); + DBG_8723A("got wpa2_ie, wpa2_ielen:%u\n", pwpa2[1]); } } -- cgit v1.2.3 From 9bf29cb9404c8368d7a501e5266e0cfcf0bce702 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:08 +0200 Subject: staging: rtl8723au: rtw_cfg80211_set_wpa_ie(): Remove unused variable 'pos' Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index e5c0ba74ea66..888077be6e8b 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -1683,7 +1683,7 @@ static int rtw_cfg80211_set_key_mgt(struct security_priv *psecuritypriv, static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie, size_t ielen) { - u8 *buf = NULL, *pos = NULL; + u8 *buf = NULL; int group_cipher = 0, pairwise_cipher = 0; int ret = 0; const u8 *pwpa, *pwpa2; @@ -1713,7 +1713,6 @@ static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie, buf[i], buf[i + 1], buf[i + 2], buf[i + 3], buf[i + 4], buf[i + 5], buf[i + 6], buf[i + 7]); - pos = buf; if (ielen < RSN_HEADER_LEN) { RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("Ie len too short %d\n", (int)ielen)); -- cgit v1.2.3 From fcff60e9209004b79f0c16845e83c08e1fefeaba Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:09 +0200 Subject: staging: rtl8723au: Remove obsolete rtw_get_wpa{2,}_ie23a() functions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 54 -------------------------- drivers/staging/rtl8723au/include/ieee80211.h | 2 - 2 files changed, 56 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index f3904ec93917..a28b81667993 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -460,60 +460,6 @@ int rtw_generate_ie23a(struct registry_priv *pregistrypriv) return sz; } -unsigned char *rtw_get_wpa_ie23a(unsigned char *pie, int *wpa_ie_len, int limit) -{ - int len; - u16 val16; - unsigned char wpa_oui_type[] = {0x00, 0x50, 0xf2, 0x01}; - u8 *pbuf = pie; - int limit_new = limit; - - while(1) { - pbuf = rtw_get_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, - &len, limit_new); - - if (pbuf) { - /* check if oui matches... */ - if (memcmp((pbuf + 2), wpa_oui_type, - sizeof(wpa_oui_type))) { - goto check_next_ie; - } - - /* check version... */ - memcpy((u8 *)&val16, (pbuf + 6), sizeof(val16)); - - val16 = le16_to_cpu(val16); - if (val16 != 0x0001) - goto check_next_ie; - - *wpa_ie_len = *(pbuf + 1); - - return pbuf; - } else { - *wpa_ie_len = 0; - return NULL; - } - -check_next_ie: - - limit_new = limit - (pbuf - pie) - 2 - len; - - if (limit_new <= 0) - break; - - pbuf += (2 + len); - } - - *wpa_ie_len = 0; - - return NULL; -} - -unsigned char *rtw_get_wpa2_ie23a(unsigned char *pie, int *rsn_ie_len, int limit) -{ - return rtw_get_ie23a(pie, _WPA2_IE_ID_, rsn_ie_len, limit); -} - int rtw_get_wpa_cipher_suite23a(const u8 *s) { if (!memcmp(s, WPA_CIPHER_SUITE_NONE23A, WPA_SELECTOR_LEN)) diff --git a/drivers/staging/rtl8723au/include/ieee80211.h b/drivers/staging/rtl8723au/include/ieee80211.h index b82f3150cfcf..e1117382e8fe 100644 --- a/drivers/staging/rtl8723au/include/ieee80211.h +++ b/drivers/staging/rtl8723au/include/ieee80211.h @@ -537,8 +537,6 @@ int rtw_ies_remove_ie23a(u8 *ies, uint *ies_len, uint offset, u8 eid, u8 *oui, u void rtw_set_supported_rate23a(u8* SupportedRates, uint mode) ; -unsigned char *rtw_get_wpa_ie23a(unsigned char *pie, int *wpa_ie_len, int limit); -unsigned char *rtw_get_wpa2_ie23a(unsigned char *pie, int *rsn_ie_len, int limit); int rtw_get_wpa_cipher_suite23a(const u8 *s); int rtw_get_wpa2_cipher_suite23a(const u8 *s); int rtw_parse_wpa_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x); -- cgit v1.2.3 From daa5d2f867f4a6e6a1c9b57c831c1fc2f59dedba Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:10 +0200 Subject: staging: rtl8723au: Remove unused for_each_ie() and dump_ies23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 15 --------------- drivers/staging/rtl8723au/include/ieee80211.h | 10 ---------- 2 files changed, 25 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index a28b81667993..930a9b189998 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -1164,21 +1164,6 @@ void rtw_macaddr_cfg23a(u8 *mac_addr) MAC_ARG(mac_addr)); } -void dump_ies23a(u8 *buf, u32 buf_len) { - u8* pos = (u8*)buf; - u8 id, len; - - while (pos-buf <= buf_len) { - id = *pos; - len = *(pos + 1); - - DBG_8723A("%s ID:%u, LEN:%u\n", __func__, id, len); - dump_wps_ie23a(pos, len); - - pos += (2 + len); - } -} - void dump_wps_ie23a(u8 *ie, u32 ie_len) { u8* pos = (u8*)ie; u16 id; diff --git a/drivers/staging/rtl8723au/include/ieee80211.h b/drivers/staging/rtl8723au/include/ieee80211.h index e1117382e8fe..bfa7e2dbbdcc 100644 --- a/drivers/staging/rtl8723au/include/ieee80211.h +++ b/drivers/staging/rtl8723au/include/ieee80211.h @@ -549,16 +549,6 @@ u8 *rtw_get_wps_ie23a(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen); u8 *rtw_get_wps_attr23a(u8 *wps_ie, uint wps_ielen, u16 target_attr_id ,u8 *buf_attr, u32 *len_attr); u8 *rtw_get_wps_attr_content23a(u8 *wps_ie, uint wps_ielen, u16 target_attr_id ,u8 *buf_content, uint *len_content); -/** - * for_each_ie - iterate over continuous IEs - * @ie: - * @buf: - * @buf_len: - */ -#define for_each_ie(ie, buf, buf_len) \ - for (ie = (void*)buf; (((u8*)ie) - ((u8*)buf) + 1) < buf_len; ie = (void*)(((u8*)ie) + *(((u8*)ie)+1) + 2)) - -void dump_ies23a(u8 *buf, u32 buf_len); void dump_wps_ie23a(u8 *ie, u32 ie_len); uint rtw_get_rateset_len23a(u8 *rateset); -- cgit v1.2.3 From 7964eba0d8df78cae4c843330153554c8e775de6 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:11 +0200 Subject: staging: rtl8723au: Remove multiple duplicate defines of the WPA OUI Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 3 +-- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 7 ++----- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 3 +-- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 6 +++--- drivers/staging/rtl8723au/include/osdep_service.h | 1 - drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 1 - 6 files changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index d049ba770900..bbf8b2eabdb3 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -21,7 +21,6 @@ #ifdef CONFIG_8723AU_AP_MODE -extern unsigned char RTW_WPA_OUI23A[]; extern unsigned char WMM_OUI23A[]; extern unsigned char WPS_OUI23A[]; extern unsigned char P2P_OUI23A[]; @@ -1303,7 +1302,7 @@ static void update_bcn_vendor_spec_ie(struct rtw_adapter *padapter, u8*oui) { DBG_8723A("%s\n", __func__); - if (!memcmp(RTW_WPA_OUI23A, oui, 4)) + if (!memcmp(RTW_WPA_OUI23A_TYPE, oui, 4)) { update_bcn_wpa_ie(padapter); } diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index 930a9b189998..8fc54c806e7d 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -497,7 +497,6 @@ int rtw_parse_wpa_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int int i, ret = _SUCCESS; int left, count; const u8 *pos; - u8 SUITE_1X[4] = {0x00, 0x50, 0xf2, 1}; if (wpa_ie_len <= 0) { /* No WPA IE - fail silently */ @@ -560,7 +559,7 @@ int rtw_parse_wpa_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int if (is_8021x) { if (left >= 6) { pos += 2; - if (!memcmp(pos, SUITE_1X, 4)) { + if (!memcmp(pos, RTW_WPA_OUI23A_TYPE, 4)) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s : there has 802.1x auth\n", __func__)); @@ -653,11 +652,9 @@ int rtw_get_sec_ie23a(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u16 *wpa_len) { u8 authmode, sec_idx, i; - u8 wpa_oui[4] = {0x0, 0x50, 0xf2, 0x01}; uint cnt; - /* Search required WPA or WPA2 IE and copy to sec_ie[ ] */ cnt = (_TIMESTAMP_ + _BEACON_ITERVAL_ + _CAPABILITY_); @@ -668,7 +665,7 @@ int rtw_get_sec_ie23a(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, authmode = in_ie[cnt]; if ((authmode == WLAN_EID_VENDOR_SPECIFIC) && - !memcmp(&in_ie[cnt+2], &wpa_oui[0], 4)) { + !memcmp(&in_ie[cnt+2], RTW_WPA_OUI23A_TYPE, 4)) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\n rtw_get_wpa_ie23a: sec_idx =%d " "in_ie[cnt+1]+2 =%d\n", diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index a79861e4250c..d08f12f6e9d3 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -87,7 +87,6 @@ static u8 null_addr[ETH_ALEN]= {0, 0, 0, 0, 0, 0}; /************************************************** OUI definitions for the vendor specific IE ***************************************************/ -unsigned char RTW_WPA_OUI23A[] = {0x00, 0x50, 0xf2, 0x01}; unsigned char WMM_OUI23A[] = {0x00, 0x50, 0xf2, 0x02}; unsigned char WPS_OUI23A[] = {0x00, 0x50, 0xf2, 0x04}; unsigned char P2P_OUI23A[] = {0x50, 0x6F, 0x9A, 0x09}; @@ -3366,7 +3365,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) switch (pIE->ElementID) { case WLAN_EID_VENDOR_SPECIFIC: - if (!memcmp(pIE->data, RTW_WPA_OUI23A, 4) || + if (!memcmp(pIE->data, RTW_WPA_OUI23A_TYPE, 4) || !memcmp(pIE->data, WMM_OUI23A, 4) || !memcmp(pIE->data, WPS_OUI23A, 4)) { if (!padapter->registrypriv.wifi_spec) { diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index e8127cb6c33a..84753f5ee231 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -1145,7 +1145,7 @@ unsigned int is_ap_in_tkip23a(struct rtw_adapter *padapter) switch (pIE->ElementID) { case WLAN_EID_VENDOR_SPECIFIC: - if ((!memcmp(pIE->data, RTW_WPA_OUI23A, 4)) && (!memcmp((pIE->data + 12), WPA_TKIP_CIPHER23A, 4))) + if ((!memcmp(pIE->data, RTW_WPA_OUI23A_TYPE, 4)) && (!memcmp((pIE->data + 12), WPA_TKIP_CIPHER23A, 4))) return true; break; case WLAN_EID_RSN: @@ -1176,7 +1176,7 @@ unsigned int should_forbid_n_rate23a(struct rtw_adapter * padapter) switch (pIE->ElementID) { case WLAN_EID_VENDOR_SPECIFIC: - if (!memcmp(pIE->data, RTW_WPA_OUI23A, 4) && + if (!memcmp(pIE->data, RTW_WPA_OUI23A_TYPE, 4) && ((!memcmp((pIE->data + 12), WPA_CIPHER_SUITE_CCMP23A, 4)) || (!memcmp((pIE->data + 16), WPA_CIPHER_SUITE_CCMP23A, 4)))) return false; @@ -1211,7 +1211,7 @@ unsigned int is_ap_in_wep23a(struct rtw_adapter *padapter) switch (pIE->ElementID) { case WLAN_EID_VENDOR_SPECIFIC: - if (!memcmp(pIE->data, RTW_WPA_OUI23A, 4)) + if (!memcmp(pIE->data, RTW_WPA_OUI23A_TYPE, 4)) return false; break; case WLAN_EID_RSN: diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index 92c954eb2179..40445bbafe77 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -137,7 +137,6 @@ void _rtw_vmfree(u8 *pbuf, u32 sz); extern unsigned char REALTEK_96B_IE23A[]; extern unsigned char MCS_rate_2R23A[16]; -extern unsigned char RTW_WPA_OUI23A[]; extern unsigned char WPA_TKIP_CIPHER23A[4]; extern unsigned char RSN_TKIP_CIPHER23A[4]; diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 275f891b6c64..13f580d9d96f 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -89,7 +89,6 @@ #define _54M_RATE_ 11 -extern unsigned char RTW_WPA_OUI23A[]; extern unsigned char WMM_OUI23A[]; extern unsigned char WPS_OUI23A[]; extern unsigned char WFD_OUI23A[]; -- cgit v1.2.3 From ab6fb7a503b03850524f70272545b6f4d6c747bb Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:12 +0200 Subject: staging: rtl8723au: update_bcn_vendor_spec_ie(): Go easy on those brackets Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index bbf8b2eabdb3..207a19e4dc9f 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -1303,25 +1303,15 @@ static void update_bcn_vendor_spec_ie(struct rtw_adapter *padapter, u8*oui) DBG_8723A("%s\n", __func__); if (!memcmp(RTW_WPA_OUI23A_TYPE, oui, 4)) - { update_bcn_wpa_ie(padapter); - } else if (!memcmp(WMM_OUI23A, oui, 4)) - { update_bcn_wmm_ie(padapter); - } else if (!memcmp(WPS_OUI23A, oui, 4)) - { update_bcn_wps_ie(padapter); - } else if (!memcmp(P2P_OUI23A, oui, 4)) - { update_bcn_p2p_ie(padapter); - } else - { DBG_8723A("unknown OUI type!\n"); - } } void update_beacon23a(struct rtw_adapter *padapter, u8 ie_id, u8 *oui, u8 tx) -- cgit v1.2.3 From 7d6925306c68c15a579e831d71bafe99a05eb9fa Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:13 +0200 Subject: staging: rtl8723au: OnAssocReq23a(): Simplify parsing crypto info from the IE This reduces the dependency of rtw_ieee802_11_parse_elems23a() which is only used in this function. Follow-on patches will remove the remaining dependencies and get rid of the function. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 107 +++++++++++++------------- 1 file changed, 54 insertions(+), 53 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index d08f12f6e9d3..fecbf2a300f3 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1144,7 +1144,7 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) u16 capab_info, listen_interval; struct rtw_ieee802_11_elems elems; struct sta_info *pstat; - unsigned char reassoc, *wpa_ie; + unsigned char reassoc; unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01}; int i, wpa_ie_len, left; unsigned char supportRate[16]; @@ -1158,10 +1158,11 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) struct sta_priv *pstapriv = &padapter->stapriv; struct sk_buff *skb = precv_frame->pkt; struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; - const u8 *p; + const u8 *p, *wpa_ie, *wps_ie; u8 *pos; u8 *pframe = skb->data; uint pkt_len = skb->len; + int r; if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE) return _FAIL; @@ -1280,66 +1281,68 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) pstat->wpa_pairwise_cipher = 0; pstat->wpa2_pairwise_cipher = 0; memset(pstat->wpa_ie, 0, sizeof(pstat->wpa_ie)); - if (psecuritypriv->wpa_psk & BIT(1) && elems.rsn_ie) { - int group_cipher = 0, pairwise_cipher = 0; - - wpa_ie = elems.rsn_ie; - wpa_ie_len = elems.rsn_ie_len; - - if (rtw_parse_wpa2_ie23a(wpa_ie - 2, wpa_ie_len + 2, - &group_cipher, &pairwise_cipher, - NULL) == _SUCCESS) { - pstat->dot8021xalg = 1;/* psk, todo:802.1x */ - pstat->wpa_psk |= BIT(1); - pstat->wpa2_group_cipher = - group_cipher&psecuritypriv->wpa2_group_cipher; - pstat->wpa2_pairwise_cipher = - pairwise_cipher&psecuritypriv->wpa2_pairwise_cipher; - - if (!pstat->wpa2_group_cipher) - status = WLAN_REASON_INVALID_GROUP_CIPHER; - - if (!pstat->wpa2_pairwise_cipher) - status = WLAN_REASON_INVALID_PAIRWISE_CIPHER; - } else - status = WLAN_STATUS_INVALID_IE; - } else if (psecuritypriv->wpa_psk & BIT(0) && elems.wpa_ie) { + wpa_ie = cfg80211_find_ie(WLAN_EID_RSN, pos, left); + if (!wpa_ie) + wpa_ie = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT, + WLAN_OUI_TYPE_MICROSOFT_WPA, + pos, left); + if (wpa_ie) { int group_cipher = 0, pairwise_cipher = 0; - wpa_ie = elems.wpa_ie; - wpa_ie_len = elems.wpa_ie_len; - - if (rtw_parse_wpa_ie23a(wpa_ie - 2, wpa_ie_len + 2, - &group_cipher, &pairwise_cipher, - NULL) == _SUCCESS) { - pstat->dot8021xalg = 1;/* psk, todo:802.1x */ - pstat->wpa_psk |= BIT(0); - - pstat->wpa_group_cipher = - group_cipher&psecuritypriv->wpa_group_cipher; - pstat->wpa_pairwise_cipher = - pairwise_cipher&psecuritypriv->wpa_pairwise_cipher; - + wpa_ie_len = wpa_ie[1]; + if (psecuritypriv->wpa_psk & BIT(1)) { + r = rtw_parse_wpa2_ie23a(wpa_ie, wpa_ie_len + 2, + &group_cipher, + &pairwise_cipher, NULL); + if (r == _SUCCESS) { + pstat->dot8021xalg = 1;/* psk, todo:802.1x */ + pstat->wpa_psk |= BIT(1); + + pstat->wpa2_group_cipher = group_cipher & + psecuritypriv->wpa2_group_cipher; + pstat->wpa2_pairwise_cipher = pairwise_cipher & + psecuritypriv->wpa2_pairwise_cipher; + } else + status = WLAN_STATUS_INVALID_IE; + } else if (psecuritypriv->wpa_psk & BIT(0)) { + r = rtw_parse_wpa_ie23a(wpa_ie, wpa_ie_len + 2, + &group_cipher, &pairwise_cipher, + NULL); + if (r == _SUCCESS) { + pstat->dot8021xalg = 1;/* psk, todo:802.1x */ + pstat->wpa_psk |= BIT(0); + + pstat->wpa_group_cipher = group_cipher & + psecuritypriv->wpa_group_cipher; + pstat->wpa_pairwise_cipher = pairwise_cipher & + psecuritypriv->wpa_pairwise_cipher; + } else + status = WLAN_STATUS_INVALID_IE; + } else { + wpa_ie = NULL; + wpa_ie_len = 0; + } + if (wpa_ie && status == WLAN_STATUS_SUCCESS) { if (!pstat->wpa_group_cipher) status = WLAN_STATUS_INVALID_GROUP_CIPHER; if (!pstat->wpa_pairwise_cipher) status = WLAN_STATUS_INVALID_PAIRWISE_CIPHER; - - } else - status = WLAN_STATUS_INVALID_IE; - } else { - wpa_ie = NULL; - wpa_ie_len = 0; + } } - if (WLAN_STATUS_SUCCESS != status) + if (status != WLAN_STATUS_SUCCESS) goto OnAssocReq23aFail; pstat->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS); + + wps_ie = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT, + WLAN_OUI_TYPE_MICROSOFT_WPS, + pos, left); + if (!wpa_ie) { - if (elems.wps_ie) { + if (wps_ie) { DBG_8723A("STA included WPS IE in (Re)Association " "Request - assume WPS is used\n"); pstat->flags |= WLAN_STA_WPS; @@ -1386,10 +1389,9 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) goto OnAssocReq23aFail; } - if (elems.wps_ie) { - DBG_8723A("STA included WPS IE in " - "(Re)Association Request - WPS is " - "used\n"); + if (wps_ie) { + DBG_8723A("STA included WPS IE in (Re)Association " + "Request - WPS is used\n"); pstat->flags |= WLAN_STA_WPS; copy_len = 0; } else { @@ -1399,7 +1401,6 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) if (copy_len > 0) memcpy(pstat->wpa_ie, wpa_ie - 2, copy_len); - } /* check if there is WMM IE & support WWM-PS */ -- cgit v1.2.3 From 49ae9a5c69e771383c10b78cfce8f1426bdecff0 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:14 +0200 Subject: staging: rtl8723au: OnAssocReq23a(): Don't check for presence of BSSID twice Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index fecbf2a300f3..e1e8f2831478 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1216,7 +1216,7 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) /* now parse all ieee802_11 ie to point to elems */ if (rtw_ieee802_11_parse_elems23a(pos, left, &elems, 1) == - ParseFailed || !elems.ssid) { + ParseFailed) { DBG_8723A("STA " MAC_FMT " sent invalid association request\n", MAC_ARG(pstat->hwaddr)); status = WLAN_STATUS_UNSPECIFIED_FAILURE; @@ -1227,8 +1227,11 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) /* checking SSID */ p = cfg80211_find_ie(WLAN_EID_SSID, pos, left); if (!p || p[1] == 0) { - /* broadcast ssid, however it is not allowed in assocreq */ + /* broadcast ssid, however it is not allowed in assocreq */ + DBG_8723A("STA " MAC_FMT " sent invalid association request " + "lacking an SSID\n", MAC_ARG(pstat->hwaddr)); status = WLAN_STATUS_UNSPECIFIED_FAILURE; + goto OnAssocReq23aFail; } else { /* check if ssid match */ if (memcmp(p + 2, cur->Ssid.ssid, cur->Ssid.ssid_len)) -- cgit v1.2.3 From 57ed7bbf7be701ce932512159afc09f4031ad165 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:15 +0200 Subject: staging: rtl8723au: OnAssocReq23a(): Use cfg80211_find_ie() to locate HT caps Use cfg80211 interface to search for HT capabilities. This was the last user of struct rtw_ieee802_11_elems, which can now be removed. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index e1e8f2831478..f0e24e33f5d8 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1471,13 +1471,14 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) /* save HT capabilities in the sta object */ memset(&pstat->htpriv.ht_cap, 0, sizeof(struct ieee80211_ht_cap)); - if (elems.ht_capabilities && elems.ht_capabilities_len >= - sizeof(struct ieee80211_ht_cap)) { + p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, pos, left); + + if (p && p[1] >= sizeof(struct ieee80211_ht_cap)) { pstat->flags |= WLAN_STA_HT; pstat->flags |= WLAN_STA_WME; - memcpy(&pstat->htpriv.ht_cap, elems.ht_capabilities, + memcpy(&pstat->htpriv.ht_cap, p + 2, sizeof(struct ieee80211_ht_cap)); } else pstat->flags &= ~WLAN_STA_HT; -- cgit v1.2.3 From 7e07583247d0b80e3ebb5ea7585ba2d29d26dec7 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:16 +0200 Subject: staging: rtl8723au: Remove struct rtw_ieee802_11_elems and related code This removes the double content tracking of data from IE elements. The relevant code to validate IEs is moved to rtw_mlme_ext.c as this is the only place where it is used. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 231 ------------------------- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 145 +++++++++++++++- drivers/staging/rtl8723au/include/ieee80211.h | 60 ------- 3 files changed, 139 insertions(+), 297 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index 8fc54c806e7d..b430e10214f3 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -884,237 +884,6 @@ u8 *rtw_get_wps_attr_content23a(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, return NULL; } -static int -rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen, - struct rtw_ieee802_11_elems *elems, - int show_errors) -{ - unsigned int oui; - - /* first 3 bytes in vendor specific information element are the IEEE - * OUI of the vendor. The following byte is used a vendor specific - * sub-type. */ - if (elen < 4) { - if (show_errors) { - DBG_8723A("short vendor specific " - "information element ignored (len =%lu)\n", - (unsigned long) elen); - } - return -1; - } - - oui = RTW_GET_BE24(pos); - switch (oui) { - case WLAN_OUI_MICROSOFT: - /* Microsoft/Wi-Fi information elements are further typed and - * subtyped */ - switch (pos[3]) { - case 1: - /* Microsoft OUI (00:50:F2) with OUI Type 1: - * real WPA information element */ - elems->wpa_ie = pos; - elems->wpa_ie_len = elen; - break; - case WME_OUI_TYPE: /* this is a Wi-Fi WME info. element */ - if (elen < 5) { - DBG_8723A("short WME " - "information element ignored " - "(len =%lu)\n", - (unsigned long) elen); - return -1; - } - switch (pos[4]) { - case WME_OUI_SUBTYPE_INFORMATION_ELEMENT: - case WME_OUI_SUBTYPE_PARAMETER_ELEMENT: - elems->wme = pos; - elems->wme_len = elen; - break; - case WME_OUI_SUBTYPE_TSPEC_ELEMENT: - elems->wme_tspec = pos; - elems->wme_tspec_len = elen; - break; - default: - DBG_8723A("unknown WME " - "information element ignored " - "(subtype =%d len =%lu)\n", - pos[4], (unsigned long) elen); - return -1; - } - break; - case 4: - /* Wi-Fi Protected Setup (WPS) IE */ - elems->wps_ie = pos; - elems->wps_ie_len = elen; - break; - default: - DBG_8723A("Unknown Microsoft " - "information element ignored " - "(type =%d len =%lu)\n", - pos[3], (unsigned long) elen); - return -1; - } - break; - - case OUI_BROADCOM: - switch (pos[3]) { - case VENDOR_HT_CAPAB_OUI_TYPE: - elems->vendor_ht_cap = pos; - elems->vendor_ht_cap_len = elen; - break; - default: - DBG_8723A("Unknown Broadcom " - "information element ignored " - "(type =%d len =%lu)\n", - pos[3], (unsigned long) elen); - return -1; - } - break; - - default: - DBG_8723A("unknown vendor specific information " - "element ignored (vendor OUI %02x:%02x:%02x " - "len =%lu)\n", - pos[0], pos[1], pos[2], (unsigned long) elen); - return -1; - } - - return 0; -} - -/** - * ieee802_11_parse_elems - Parse information elements in management frames - * @start: Pointer to the start of IEs - * @len: Length of IE buffer in octets - * @elems: Data structure for parsed elements - * @show_errors: Whether to show parsing errors in debug log - * Returns: Parsing result - */ -enum parse_res rtw_ieee802_11_parse_elems23a(u8 *start, uint len, - struct rtw_ieee802_11_elems *elems, - int show_errors) -{ - uint left = len; - u8 *pos = start; - int unknown = 0; - - memset(elems, 0, sizeof(*elems)); - - while (left >= 2) { - u8 id, elen; - - id = *pos++; - elen = *pos++; - left -= 2; - - if (elen > left) { - if (show_errors) { - DBG_8723A("IEEE 802.11 element " - "parse failed (id =%d elen =%d " - "left =%lu)\n", - id, elen, (unsigned long) left); - } - return ParseFailed; - } - - switch (id) { - case WLAN_EID_SSID: - elems->ssid = pos; - elems->ssid_len = elen; - break; - case WLAN_EID_SUPP_RATES: - elems->supp_rates = pos; - elems->supp_rates_len = elen; - break; - case WLAN_EID_FH_PARAMS: - elems->fh_params = pos; - elems->fh_params_len = elen; - break; - case WLAN_EID_DS_PARAMS: - elems->ds_params = pos; - elems->ds_params_len = elen; - break; - case WLAN_EID_CF_PARAMS: - elems->cf_params = pos; - elems->cf_params_len = elen; - break; - case WLAN_EID_TIM: - elems->tim = pos; - elems->tim_len = elen; - break; - case WLAN_EID_IBSS_PARAMS: - elems->ibss_params = pos; - elems->ibss_params_len = elen; - break; - case WLAN_EID_CHALLENGE: - elems->challenge = pos; - elems->challenge_len = elen; - break; - case WLAN_EID_ERP_INFO: - elems->erp_info = pos; - elems->erp_info_len = elen; - break; - case WLAN_EID_EXT_SUPP_RATES: - elems->ext_supp_rates = pos; - elems->ext_supp_rates_len = elen; - break; - case WLAN_EID_VENDOR_SPECIFIC: - if (rtw_ieee802_11_parse_vendor_specific(pos, elen, - elems, - show_errors)) - unknown++; - break; - case WLAN_EID_RSN: - elems->rsn_ie = pos; - elems->rsn_ie_len = elen; - break; - case WLAN_EID_PWR_CAPABILITY: - elems->power_cap = pos; - elems->power_cap_len = elen; - break; - case WLAN_EID_SUPPORTED_CHANNELS: - elems->supp_channels = pos; - elems->supp_channels_len = elen; - break; - case WLAN_EID_MOBILITY_DOMAIN: - elems->mdie = pos; - elems->mdie_len = elen; - break; - case WLAN_EID_FAST_BSS_TRANSITION: - elems->ftie = pos; - elems->ftie_len = elen; - break; - case WLAN_EID_TIMEOUT_INTERVAL: - elems->timeout_int = pos; - elems->timeout_int_len = elen; - break; - case WLAN_EID_HT_CAPABILITY: - elems->ht_capabilities = pos; - elems->ht_capabilities_len = elen; - break; - case WLAN_EID_HT_OPERATION: - elems->ht_operation = pos; - elems->ht_operation_len = elen; - break; - default: - unknown++; - if (!show_errors) - break; - DBG_8723A("IEEE 802.11 element parse " - "ignored unknown element (id =%d elen =%d)\n", - id, elen); - break; - } - - left -= elen; - pos += elen; - } - - if (left) - return ParseFailed; - - return unknown ? ParseUnknown : ParseOK; -} - static u8 key_char2num(u8 ch) { if ((ch >= '0') && (ch <= '9')) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index f0e24e33f5d8..8c48ca4a4905 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1137,12 +1137,146 @@ authclnt_fail: return _FAIL; } +#ifdef CONFIG_8723AU_AP_MODE +static int rtw_validate_vendor_specific_ies(const u8 *pos, int elen) +{ + unsigned int oui; + + /* first 3 bytes in vendor specific information element are the IEEE + * OUI of the vendor. The following byte is used a vendor specific + * sub-type. */ + if (elen < 4) { + DBG_8723A("short vendor specific information element " + "ignored (len =%i)\n", elen); + return -EINVAL; + } + + oui = RTW_GET_BE24(pos); + switch (oui) { + case WLAN_OUI_MICROSOFT: + /* Microsoft/Wi-Fi information elements are further typed and + * subtyped */ + switch (pos[3]) { + case 1: + /* Microsoft OUI (00:50:F2) with OUI Type 1: + * real WPA information element */ + break; + case WME_OUI_TYPE: /* this is a Wi-Fi WME info. element */ + if (elen < 5) { + DBG_8723A("short WME information element " + "ignored (len =%i)\n", elen); + return -EINVAL; + } + switch (pos[4]) { + case WME_OUI_SUBTYPE_INFORMATION_ELEMENT: + case WME_OUI_SUBTYPE_PARAMETER_ELEMENT: + break; + case WME_OUI_SUBTYPE_TSPEC_ELEMENT: + break; + default: + DBG_8723A("unknown WME information element " + "ignored (subtype =%d len =%i)\n", + pos[4], elen); + return -EINVAL; + } + break; + case 4: + /* Wi-Fi Protected Setup (WPS) IE */ + break; + default: + DBG_8723A("Unknown Microsoft information element " + "ignored (type =%d len =%i)\n", + pos[3], elen); + return -EINVAL; + } + break; + + case OUI_BROADCOM: + switch (pos[3]) { + case VENDOR_HT_CAPAB_OUI_TYPE: + break; + default: + DBG_8723A("Unknown Broadcom information element " + "ignored (type =%d len =%i)\n", pos[3], elen); + return -EINVAL; + } + break; + + default: + DBG_8723A("unknown vendor specific information element " + "ignored (vendor OUI %02x:%02x:%02x len =%i)\n", + pos[0], pos[1], pos[2], elen); + return -EINVAL; + } + + return 0; +} + +static int rtw_validate_frame_ies(const u8 *start, uint len) +{ + const u8 *pos = start; + int left = len; + int unknown = 0; + + while (left >= 2) { + u8 id, elen; + + id = *pos++; + elen = *pos++; + left -= 2; + + if (elen > left) { + DBG_8723A("%s: IEEE 802.11 failed (id =%d elen =%d " + "left =%i)\n", __func__, id, elen, left); + return -EINVAL; + } + + switch (id) { + case WLAN_EID_SSID: + case WLAN_EID_SUPP_RATES: + case WLAN_EID_FH_PARAMS: + case WLAN_EID_DS_PARAMS: + case WLAN_EID_CF_PARAMS: + case WLAN_EID_TIM: + case WLAN_EID_IBSS_PARAMS: + case WLAN_EID_CHALLENGE: + case WLAN_EID_ERP_INFO: + case WLAN_EID_EXT_SUPP_RATES: + case WLAN_EID_VENDOR_SPECIFIC: + if (rtw_validate_vendor_specific_ies(pos, elen)) + unknown++; + break; + case WLAN_EID_RSN: + case WLAN_EID_PWR_CAPABILITY: + case WLAN_EID_SUPPORTED_CHANNELS: + case WLAN_EID_MOBILITY_DOMAIN: + case WLAN_EID_FAST_BSS_TRANSITION: + case WLAN_EID_TIMEOUT_INTERVAL: + case WLAN_EID_HT_CAPABILITY: + case WLAN_EID_HT_OPERATION: + default: + unknown++; + DBG_8723A("%s IEEE 802.11 ignored unknown element " + "(id =%d elen =%d)\n", __func__, id, elen); + break; + } + + left -= elen; + pos += elen; + } + + if (left) + return -EINVAL; + + return 0; +} +#endif + static int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { #ifdef CONFIG_8723AU_AP_MODE u16 capab_info, listen_interval; - struct rtw_ieee802_11_elems elems; struct sta_info *pstat; unsigned char reassoc; unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01}; @@ -1158,8 +1292,7 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) struct sta_priv *pstapriv = &padapter->stapriv; struct sk_buff *skb = precv_frame->pkt; struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; - const u8 *p, *wpa_ie, *wps_ie; - u8 *pos; + const u8 *pos, *p, *wpa_ie, *wps_ie; u8 *pframe = skb->data; uint pkt_len = skb->len; int r; @@ -1215,8 +1348,8 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) pstat->capability = capab_info; /* now parse all ieee802_11 ie to point to elems */ - if (rtw_ieee802_11_parse_elems23a(pos, left, &elems, 1) == - ParseFailed) { + + if (rtw_validate_frame_ies(pos, left)) { DBG_8723A("STA " MAC_FMT " sent invalid association request\n", MAC_ARG(pstat->hwaddr)); status = WLAN_STATUS_UNSPECIFIED_FAILURE; @@ -1416,7 +1549,7 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) pstat->uapsd_be = 0; pstat->uapsd_bk = 0; if (pmlmepriv->qospriv.qos_option) { - u8 *end = pos + left; + const u8 *end = pos + left; p = pos; for (;;) { diff --git a/drivers/staging/rtl8723au/include/ieee80211.h b/drivers/staging/rtl8723au/include/ieee80211.h index bfa7e2dbbdcc..fcbe6ba59c27 100644 --- a/drivers/staging/rtl8723au/include/ieee80211.h +++ b/drivers/staging/rtl8723au/include/ieee80211.h @@ -457,66 +457,6 @@ struct rtw_ieee80211_channel { /*, (channel)->orig_mag*/ \ /*, (channel)->orig_mpwr*/ \ -/* Parsed Information Elements */ -struct rtw_ieee802_11_elems { - u8 *ssid; - u8 ssid_len; - u8 *supp_rates; - u8 supp_rates_len; - u8 *fh_params; - u8 fh_params_len; - u8 *ds_params; - u8 ds_params_len; - u8 *cf_params; - u8 cf_params_len; - u8 *tim; - u8 tim_len; - u8 *ibss_params; - u8 ibss_params_len; - u8 *challenge; - u8 challenge_len; - u8 *erp_info; - u8 erp_info_len; - u8 *ext_supp_rates; - u8 ext_supp_rates_len; - u8 *wpa_ie; - u8 wpa_ie_len; - u8 *rsn_ie; - u8 rsn_ie_len; - u8 *wme; - u8 wme_len; - u8 *wme_tspec; - u8 wme_tspec_len; - u8 *wps_ie; - u8 wps_ie_len; - u8 *power_cap; - u8 power_cap_len; - u8 *supp_channels; - u8 supp_channels_len; - u8 *mdie; - u8 mdie_len; - u8 *ftie; - u8 ftie_len; - u8 *timeout_int; - u8 timeout_int_len; - u8 *ht_capabilities; - u8 ht_capabilities_len; - u8 *ht_operation; - u8 ht_operation_len; - u8 *vendor_ht_cap; - u8 vendor_ht_cap_len; -}; - -enum parse_res { - ParseOK = 0, - ParseUnknown = 1, - ParseFailed = -1 -}; - -enum parse_res rtw_ieee802_11_parse_elems23a(u8 *start, uint len, - struct rtw_ieee802_11_elems *elems, - int show_errors); - u8 *rtw_set_fixed_ie23a(unsigned char *pbuf, unsigned int len, unsigned char *source, unsigned int *frlen); u8 *rtw_set_ie23a(u8 *pbuf, int index, uint len, const u8 *source, uint *frlen); -- cgit v1.2.3 From 5951a5c1b8b2a2d0dc106817c92658efddfbf922 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:17 +0200 Subject: staging: rtl8723au: Remove unused dump_wpsie23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 24 ------------------------ drivers/staging/rtl8723au/include/ieee80211.h | 2 -- 2 files changed, 26 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index b430e10214f3..e3fdbeba24fa 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -930,30 +930,6 @@ void rtw_macaddr_cfg23a(u8 *mac_addr) MAC_ARG(mac_addr)); } -void dump_wps_ie23a(u8 *ie, u32 ie_len) { - u8* pos = (u8*)ie; - u16 id; - u16 len; - - u8 *wps_ie; - uint wps_ielen; - - wps_ie = rtw_get_wps_ie23a(ie, ie_len, NULL, &wps_ielen); - if (wps_ie != ie || wps_ielen == 0) - return; - - pos+= 6; - while (pos-ie < ie_len) { - id = get_unaligned_be16(pos); - len = get_unaligned_be16(pos + 2); - - DBG_8723A("%s ID:0x%04x, LEN:%u\n", __func__, id, len); - - pos += (4 + len); - } -} - - /* Baron adds to avoid FreeBSD warning */ int ieee80211_is_empty_essid23a(const char *essid, int essid_len) { diff --git a/drivers/staging/rtl8723au/include/ieee80211.h b/drivers/staging/rtl8723au/include/ieee80211.h index fcbe6ba59c27..de7c1a7f6b0a 100644 --- a/drivers/staging/rtl8723au/include/ieee80211.h +++ b/drivers/staging/rtl8723au/include/ieee80211.h @@ -489,8 +489,6 @@ u8 *rtw_get_wps_ie23a(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen); u8 *rtw_get_wps_attr23a(u8 *wps_ie, uint wps_ielen, u16 target_attr_id ,u8 *buf_attr, u32 *len_attr); u8 *rtw_get_wps_attr_content23a(u8 *wps_ie, uint wps_ielen, u16 target_attr_id ,u8 *buf_content, uint *len_content); -void dump_wps_ie23a(u8 *ie, u32 ie_len); - uint rtw_get_rateset_len23a(u8 *rateset); struct registry_priv; -- cgit v1.2.3 From 30947bbc2711b0b96e2e0329a0e8df2991fdb80f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:18 +0200 Subject: staging: rtl8723au: Remove unused ieee880211_is_empty_essid() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 17 ----------------- drivers/staging/rtl8723au/include/ieee80211.h | 3 --- 2 files changed, 20 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index e3fdbeba24fa..8f91bdbc2bbf 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -930,23 +930,6 @@ void rtw_macaddr_cfg23a(u8 *mac_addr) MAC_ARG(mac_addr)); } -/* Baron adds to avoid FreeBSD warning */ -int ieee80211_is_empty_essid23a(const char *essid, int essid_len) -{ - /* Single white space is for Linksys APs */ - if (essid_len == 1 && essid[0] == ' ') - return 1; - - /* Otherwise, if the entire essid is 0, we assume it is hidden */ - while (essid_len) { - essid_len--; - if (essid[essid_len] != '\0') - return 0; - } - - return 1; -} - static int rtw_get_cipher_info(struct wlan_network *pnetwork) { const u8 *pbuf; diff --git a/drivers/staging/rtl8723au/include/ieee80211.h b/drivers/staging/rtl8723au/include/ieee80211.h index de7c1a7f6b0a..35fa3a6bf8ed 100644 --- a/drivers/staging/rtl8723au/include/ieee80211.h +++ b/drivers/staging/rtl8723au/include/ieee80211.h @@ -382,9 +382,6 @@ join_res: #define IEEE_G (1<<2) #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G) -/* Baron move to ieee80211.c */ -int ieee80211_is_empty_essid23a(const char *essid, int essid_len); - enum _PUBLIC_ACTION{ ACT_PUBLIC_BSSCOEXIST = 0, /* 20/40 BSS Coexistence */ ACT_PUBLIC_DSE_ENABLE = 1, -- cgit v1.2.3 From 29f79e057fcca0d45000b0260ac0d519985606eb Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:19 +0200 Subject: staging: rtl8723au: Remove some unused ieee80211 structs These are duplicated from the kernel headers and not used anymore Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/ieee80211.h | 47 --------------------------- 1 file changed, 47 deletions(-) diff --git a/drivers/staging/rtl8723au/include/ieee80211.h b/drivers/staging/rtl8723au/include/ieee80211.h index 35fa3a6bf8ed..76875f651d82 100644 --- a/drivers/staging/rtl8723au/include/ieee80211.h +++ b/drivers/staging/rtl8723au/include/ieee80211.h @@ -298,53 +298,6 @@ struct ieee80211_snap_hdr { #define WEP_KEY_LEN 13 - -/* - - 802.11 data frame from AP - - ,-------------------------------------------------------------------. -Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | - |------|------|---------|---------|---------|------|---------|------| -Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs | - | | tion | (BSSID) | | | ence | data | | - `-------------------------------------------------------------------' - -Total: 28-2340 bytes - -*/ - -struct ieee80211_header_data { - u16 frame_ctl; - u16 duration_id; - u8 addr1[6]; - u8 addr2[6]; - u8 addr3[6]; - u16 seq_ctrl; -}; - -struct ieee80211_info_element_hdr { - u8 id; - u8 len; -} __attribute__ ((packed)); - -struct ieee80211_info_element { - u8 id; - u8 len; - u8 data[0]; -} __attribute__ ((packed)); - - -struct ieee80211_txb { - u8 nr_frags; - u8 encrypted; - u16 reserved; - u16 frag_size; - u16 payload_size; - struct sk_buff *fragments[0]; -}; - - /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs * only use 8, and then use extended rates for the remaining supported * rates. Other APs, however, stick all of their supported rates on the -- cgit v1.2.3 From 43c34be13047dd53e70bc4759ff314424db7036b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:20 +0200 Subject: staging: rtl8723au: ioctl_cfg80211.c: Use eth_{zero,broadcast},addr() Use kernel provided macros instead of own hacks. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 888077be6e8b..cf44d295b66a 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -263,7 +263,6 @@ static int rtw_cfg80211_inform_bss(struct rtw_adapter *padapter, size_t len, bssinf_len = 0; struct ieee80211_hdr *pwlanhdr; unsigned short *fctrl; - u8 bc_addr[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; struct wireless_dev *wdev = padapter->rtw_wdev; struct wiphy *wiphy = wdev->wiphy; @@ -321,7 +320,7 @@ static int rtw_cfg80211_inform_bss(struct rtw_adapter *padapter, SetSeqNum(pwlanhdr, 0); if (pnetwork->network.reserved == 1) { /* WIFI_BEACON */ - memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); + eth_broadcast_addr(pwlanhdr->addr1); SetFrameSubType(pbuf, WIFI_BEACON); } else { memcpy(pwlanhdr->addr1, myid(&padapter->eeprompriv), ETH_ALEN); @@ -1101,7 +1100,7 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev, return -1; param->cmd = IEEE_CMD_SET_ENCRYPTION; - memset(param->sta_addr, 0xff, ETH_ALEN); + eth_broadcast_addr(param->sta_addr); switch (params->cipher) { case IW_AUTH_CIPHER_NONE: @@ -2255,8 +2254,7 @@ static int cfg80211_rtw_del_pmksa(struct wiphy *wiphy, if (!memcmp(psecuritypriv->PMKIDList[index].Bssid, pmksa->bssid, ETH_ALEN)) { /* BSSID is matched, the same AP => Remove this PMKID information and reset it. */ - memset(psecuritypriv->PMKIDList[index].Bssid, 0x00, - ETH_ALEN); + eth_zero_addr(psecuritypriv->PMKIDList[index].Bssid); memset(psecuritypriv->PMKIDList[index].PMKID, 0x00, WLAN_PMKID_LEN); psecuritypriv->PMKIDList[index].bUsed = false; -- cgit v1.2.3 From 07d2c3b8411a3674866a7e5b64a248db5ff3dc10 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:21 +0200 Subject: staging: rtl8723au: OnAssocReq23a(): use ieee80211_mgmt to calculate offset Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 8c48ca4a4905..0277ee63db0e 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1304,11 +1304,11 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) if (ieee80211_is_assoc_req(mgmt->frame_control)) { reassoc = 0; pos = mgmt->u.assoc_req.variable; - left -= _ASOCREQ_IE_OFFSET_; + left -= offsetof(struct ieee80211_mgmt, u.assoc_req.variable); } else { /* WIFI_REASSOCREQ */ reassoc = 1; pos = mgmt->u.reassoc_req.variable; - left -= _REASOCREQ_IE_OFFSET_; + left -= offsetof(struct ieee80211_mgmt, u.reassoc_req.variable); } if (left < 0) { -- cgit v1.2.3 From d3c6094950589f034b2dc5c5e1cefa5b160a20e8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:22 +0200 Subject: staging: rtl8723au: OnProbeReq23a(): Use struct ieee80211_mgmt Simplify parsing of probe request frame Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 0277ee63db0e..0264eda4bf62 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -667,9 +667,8 @@ OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *cur = &pmlmeinfo->network; struct sk_buff *skb = precv_frame->pkt; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - u8 *pframe = skb->data; - uint len = skb->len; + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; + int len = skb->len; u8 is_valid_p2p_probereq = false; if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) @@ -680,10 +679,15 @@ OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) WIFI_ADHOC_MASTER_STATE | WIFI_AP_STATE)) return _SUCCESS; - pframe += (sizeof(struct ieee80211_hdr_3addr) + _PROBEREQ_IE_OFFSET_); - len -= (sizeof(struct ieee80211_hdr_3addr) + _PROBEREQ_IE_OFFSET_); + if (unlikely(!ieee80211_is_probe_req(mgmt->frame_control))) { + printk(KERN_WARNING "%s: Received non probe request frame\n", + __func__); + return _FAIL; + } - ie = cfg80211_find_ie(WLAN_EID_SSID, pframe, len); + len -= offsetof(struct ieee80211_mgmt, u.probe_req.variable); + + ie = cfg80211_find_ie(WLAN_EID_SSID, mgmt->u.probe_req.variable, len); /* check (wildcard) SSID */ if (!ie) @@ -698,10 +702,8 @@ OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) } if (check_fwstate(pmlmepriv, _FW_LINKED) && - pmlmepriv->cur_network.join_res) { - issue_probersp23a(padapter, ieee80211_get_SA(hdr), - is_valid_p2p_probereq); - } + pmlmepriv->cur_network.join_res) + issue_probersp23a(padapter, mgmt->sa, is_valid_p2p_probereq); out: return _SUCCESS; -- cgit v1.2.3 From 8e64bc584d58a26d894eb51894c4d7e9b77411db Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:23 +0200 Subject: staging: rtl8723au: OnProbeReq23a(): is_valid_p2p_probereq is always false Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 0264eda4bf62..dd18dd9f8bfa 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -669,7 +669,6 @@ OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) struct sk_buff *skb = precv_frame->pkt; struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; int len = skb->len; - u8 is_valid_p2p_probereq = false; if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) return _SUCCESS; @@ -693,17 +692,14 @@ OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) if (!ie) goto out; - if (is_valid_p2p_probereq == false) { - if ((ie[1] && - memcmp(ie + 2, cur->Ssid.ssid, cur->Ssid.ssid_len)) || - (ie[1] == 0 && pmlmeinfo->hidden_ssid_mode)) { - return _SUCCESS; - } + if ((ie[1] && memcmp(ie + 2, cur->Ssid.ssid, cur->Ssid.ssid_len)) || + (ie[1] == 0 && pmlmeinfo->hidden_ssid_mode)) { + return _SUCCESS; } if (check_fwstate(pmlmepriv, _FW_LINKED) && pmlmepriv->cur_network.join_res) - issue_probersp23a(padapter, mgmt->sa, is_valid_p2p_probereq); + issue_probersp23a(padapter, mgmt->sa, false); out: return _SUCCESS; -- cgit v1.2.3 From 959226ac54b1b4cf9d6d2b496e097a29b4b1d338 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:24 +0200 Subject: staging: rtl8723au: Remove buggy function _rtw_report_sec_ie() This function was extremely buggy calling kmalloc(GFP_KERNEL) while holding a spin lock and then potentially overflowing the buffer it had allocated. Since the generated output wasn't used for anything, simply rip the whole thing out. Reported-by: Dan Carpenter Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 43 ------------------------------- 1 file changed, 43 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 24a4338aafe8..3599d0287365 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -1987,47 +1987,6 @@ static int rtw_append_pmkid(struct rtw_adapter *Adapter, int iEntry, return ie_len; } -static void -_rtw_report_sec_ie(struct rtw_adapter *adapter, u8 authmode, u8 *sec_ie) -{ - uint len; - u8 *buff, *p, i; - union iwreq_data wrqu; - - RT_TRACE(_module_mlme_osdep_c_, _drv_info_, - ("+_rtw_report_sec_ie, authmode =%d\n", authmode)); - - buff = NULL; - if (authmode == WLAN_EID_VENDOR_SPECIFIC) { - RT_TRACE(_module_mlme_osdep_c_, _drv_info_, - ("_rtw_report_sec_ie, authmode =%d\n", authmode)); - - buff = kzalloc(IW_CUSTOM_MAX, GFP_KERNEL); - if (!buff) - return; - p = buff; - - p += sprintf(p, "ASSOCINFO(ReqIEs ="); - - len = sec_ie[1]+2; - len = (len < IW_CUSTOM_MAX) ? len : IW_CUSTOM_MAX; - - for (i = 0; i < len; i++) - p += sprintf(p, "%02x", sec_ie[i]); - - p += sprintf(p, ")"); - - memset(&wrqu, 0, sizeof(wrqu)); - - wrqu.data.length = p-buff; - - wrqu.data.length = (wrqu.data.length < IW_CUSTOM_MAX) ? - wrqu.data.length : IW_CUSTOM_MAX; - - kfree(buff); - } -} - int rtw_restruct_sec_ie23a(struct rtw_adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len) { @@ -2064,8 +2023,6 @@ int rtw_restruct_sec_ie23a(struct rtw_adapter *adapter, u8 *in_ie, u8 *out_ie, memcpy(&out_ie[ielength], &psecuritypriv->supplicant_ie[0], psecuritypriv->supplicant_ie[1] + 2); ielength += psecuritypriv->supplicant_ie[1] + 2; - _rtw_report_sec_ie(adapter, authmode, - psecuritypriv->supplicant_ie); } iEntry = SecIsInPMKIDList(adapter, pmlmepriv->assoc_bssid); -- cgit v1.2.3 From 9aac910a1238c2cb15cdfe2b4529302b8a94f294 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:25 +0200 Subject: staging: rtl8723au: rtw_mlme.c: remove commented out debug code Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 3599d0287365..8c11fa18fe89 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -1591,8 +1591,6 @@ void rtw_clear_scan_deny(struct rtw_adapter *adapter) { struct mlme_priv *mlmepriv = &adapter->mlmepriv; atomic_set(&mlmepriv->set_scan_deny, 0); - if (0) - DBG_8723A(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(adapter)); } void rtw_set_scan_deny_timer_hdl(unsigned long data) @@ -1605,12 +1603,9 @@ void rtw_set_scan_deny(struct rtw_adapter *adapter, u32 ms) { struct mlme_priv *mlmepriv = &adapter->mlmepriv; - if (0) - DBG_8723A(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(adapter)); atomic_set(&mlmepriv->set_scan_deny, 1); mod_timer(&mlmepriv->set_scan_deny_timer, jiffies + msecs_to_jiffies(ms)); - } #if defined(IEEE80211_SCAN_RESULT_EXPIRE) -- cgit v1.2.3 From 9af36808d9697f48cbe5a0700b24fea33073290c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:26 +0200 Subject: staging: rtl8723au: OnBeacon23a() tidy up code Clean up the excessive if() levels at the end, and use struct ieee80211_mgmt to calculate pointers passed on to check_assoc_AP23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 157 +++++++++++++------------- 1 file changed, 79 insertions(+), 78 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index dd18dd9f8bfa..945b59271b11 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -740,8 +740,8 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) pie = mgmt->u.beacon.variable; pie_len = pkt_len - offsetof(struct ieee80211_mgmt, u.beacon.variable); p = rtw_get_ie23a(pie, WLAN_EID_EXT_SUPP_RATES, &ielen, pie_len); - if ((p != NULL) && (ielen > 0)) { - if ((*(p + 1 + ielen) == 0x2D) && (*(p + 2 + ielen) != 0x2D)) { + if (p && ielen > 0) { + if (p[1 + ielen] == 0x2D && p[2 + ielen] != 0x2D) { /* Invalid value 0x2D is detected in Extended Supported * Rates (ESR) IE. Try to fix the IE length to avoid * failed Beacon parsing. @@ -750,7 +750,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) "Beacon of BSSID: %pM. Fix the length of " "ESR IE to avoid failed Beacon parsing.\n", mgmt->bssid); - *(p + 1) = ielen - 1; + p[1] = ielen - 1; } } @@ -759,93 +759,94 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) return _SUCCESS; } - if (ether_addr_equal(mgmt->bssid, - get_my_bssid23a(&pmlmeinfo->network))){ - if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { - /* we should update current network before auth, - or some IE is wrong */ - pbss = (struct wlan_bssid_ex *) - kmalloc(sizeof(struct wlan_bssid_ex), - GFP_ATOMIC); - if (pbss) { - if (collect_bss_info23a(padapter, precv_frame, - pbss) == _SUCCESS) { - update_network23a(&pmlmepriv->cur_network.network, pbss, padapter, true); - rtw_get_bcn_info23a(&pmlmepriv->cur_network); - } - kfree(pbss); + if (!ether_addr_equal(mgmt->bssid, + get_my_bssid23a(&pmlmeinfo->network))) + goto out; + + if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { + /* we should update current network before auth, + or some IE is wrong */ + pbss = (struct wlan_bssid_ex *) + kmalloc(sizeof(struct wlan_bssid_ex), GFP_ATOMIC); + if (pbss) { + if (collect_bss_info23a(padapter, precv_frame, pbss) == + _SUCCESS) { + update_network23a( + &pmlmepriv->cur_network.network, pbss, + padapter, true); + rtw_get_bcn_info23a(&pmlmepriv->cur_network); } + kfree(pbss); + } - /* check the vendor of the assoc AP */ - pmlmeinfo->assoc_AP_vendor = check_assoc_AP23a(pframe + sizeof(struct ieee80211_hdr_3addr), pkt_len-sizeof(struct ieee80211_hdr_3addr)); + /* check the vendor of the assoc AP */ + pmlmeinfo->assoc_AP_vendor = + check_assoc_AP23a((u8 *)&mgmt->u.beacon, pkt_len - + offsetof(struct ieee80211_mgmt, u)); - /* update TSF Value */ - update_TSF23a(pmlmeext, pframe, pkt_len); + /* update TSF Value */ + update_TSF23a(pmlmeext, pframe, pkt_len); - /* start auth */ - start_clnt_auth23a(padapter); + /* start auth */ + start_clnt_auth23a(padapter); - return _SUCCESS; - } + return _SUCCESS; + } - if (((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) && - (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) { - psta = rtw_get_stainfo23a(pstapriv, mgmt->sa); - if (psta) { - ret = rtw_check_bcn_info23a(padapter, mgmt, - pkt_len); - if (!ret) { - DBG_8723A_LEVEL(_drv_always_, - "ap has changed, " - "disconnect now\n"); - receive_disconnect23a(padapter, pmlmeinfo->network.MacAddress, 65535); - return _SUCCESS; - } - /* update WMM, ERP in the beacon */ - /* todo: the timer is used instead of - the number of the beacon received */ - if ((sta_rx_pkts(psta) & 0xf) == 0) { - /* DBG_8723A("update_bcn_info\n"); */ - update_beacon23a_info(padapter, pframe, - pkt_len, psta); - } + if (((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) && + (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) { + psta = rtw_get_stainfo23a(pstapriv, mgmt->sa); + if (psta) { + ret = rtw_check_bcn_info23a(padapter, mgmt, pkt_len); + if (!ret) { + DBG_8723A_LEVEL(_drv_always_, "ap has changed, " + "disconnect now\n"); + receive_disconnect23a(padapter, pmlmeinfo->network.MacAddress, 65535); + return _SUCCESS; + } + /* update WMM, ERP in the beacon */ + /* todo: the timer is used instead of + the number of the beacon received */ + if ((sta_rx_pkts(psta) & 0xf) == 0) { + /* DBG_8723A("update_bcn_info\n"); */ + update_beacon23a_info(padapter, pframe, + pkt_len, psta); + } + } + } else if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { + psta = rtw_get_stainfo23a(pstapriv, mgmt->sa); + if (psta) { + /* update WMM, ERP in the beacon */ + /* todo: the timer is used instead of the + number of the beacon received */ + if ((sta_rx_pkts(psta) & 0xf) == 0) { + /* DBG_8723A("update_bcn_info\n"); */ + update_beacon23a_info(padapter, pframe, + pkt_len, psta); + } + } else { + /* allocate a new CAM entry for IBSS station */ + cam_idx = allocate_fw_sta_entry23a(padapter); + if (cam_idx == NUM_STA) + goto out; + + /* get supported rate */ + if (update_sta_support_rate23a(padapter, pie, pie_len, + cam_idx) == _FAIL) { + pmlmeinfo->FW_sta_info[cam_idx].status = 0; + goto out; } - } else if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { - psta = rtw_get_stainfo23a(pstapriv, mgmt->sa); - if (psta) { - /* update WMM, ERP in the beacon */ - /* todo: the timer is used instead of the - number of the beacon received */ - if ((sta_rx_pkts(psta) & 0xf) == 0) { - /* DBG_8723A("update_bcn_info\n"); */ - update_beacon23a_info(padapter, pframe, - pkt_len, psta); - } - } else { - /* allocate a new CAM entry for IBSS station */ - cam_idx = allocate_fw_sta_entry23a(padapter); - if (cam_idx == NUM_STA) - goto _END_ONBEACON_; - - /* get supported rate */ - if (update_sta_support_rate23a(padapter, pie, - pie_len, - cam_idx) == _FAIL) { - pmlmeinfo->FW_sta_info[cam_idx].status = 0; - goto _END_ONBEACON_; - } - /* update TSF Value */ - update_TSF23a(pmlmeext, pframe, pkt_len); + /* update TSF Value */ + update_TSF23a(pmlmeext, pframe, pkt_len); - /* report sta add event */ - report_add_sta_event23a(padapter, mgmt->sa, - cam_idx); - } + /* report sta add event */ + report_add_sta_event23a(padapter, mgmt->sa, + cam_idx); } } -_END_ONBEACON_: +out: return _SUCCESS; } -- cgit v1.2.3 From 04fad92a9e85f934c893a008de5d0f19dcf59f29 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:27 +0200 Subject: staging: rtl8723au: clean up update_TSF() Clean up and simplify update_TSF() using proper Linux functions and move it to rtw_mlme_ext.c which is the only user of it. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 13 ++++++++----- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 15 --------------- drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 1 - 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 945b59271b11..cb341529a1f3 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -249,6 +249,12 @@ static struct fwevent wlanevents[] = }; +static void +rtw_update_TSF(struct mlme_ext_priv *pmlmeext, struct ieee80211_mgmt *mgmt) +{ + pmlmeext->TSFValue = get_unaligned_le64(&mgmt->u.beacon.timestamp); +} + /* * Search the @param channel_num in given @param channel_set * @ch_set: the given channel set @@ -785,7 +791,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) offsetof(struct ieee80211_mgmt, u)); /* update TSF Value */ - update_TSF23a(pmlmeext, pframe, pkt_len); + rtw_update_TSF(pmlmeext, mgmt); /* start auth */ start_clnt_auth23a(padapter); @@ -838,7 +844,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) } /* update TSF Value */ - update_TSF23a(pmlmeext, pframe, pkt_len); + rtw_update_TSF(pmlmeext, mgmt); /* report sta add event */ report_add_sta_event23a(padapter, mgmt->sa, @@ -5492,9 +5498,6 @@ void mlmeext_sta_add_event_callback23a(struct rtw_adapter *padapter, struct sta_ } else/* adhoc client */ { - /* update TSF Value */ - /* update_TSF23a(pmlmeext, pframe, len); */ - /* correcting TSF */ correct_TSF23a(padapter, pmlmeext); diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 84753f5ee231..bf53973b2204 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -1643,21 +1643,6 @@ void process_addba_req23a(struct rtw_adapter *padapter, u8 *paddba_req, u8 *addr } } -void update_TSF23a(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len) -{ - u8 *pIE; - u32 *pbuf; - - pIE = pframe + sizeof(struct ieee80211_hdr_3addr); - pbuf = (u32 *)pIE; - - pmlmeext->TSFValue = le32_to_cpu(*(pbuf+1)); - - pmlmeext->TSFValue = pmlmeext->TSFValue << 32; - - pmlmeext->TSFValue |= le32_to_cpu(*pbuf); -} - void correct_TSF23a(struct rtw_adapter *padapter, struct mlme_ext_priv *pmlmeext) { diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 13f580d9d96f..cbea64938c54 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -635,7 +635,6 @@ int cckratesonly_included23a(unsigned char *rate, int ratelen); void process_addba_req23a(struct rtw_adapter *padapter, u8 *paddba_req, u8 *addr); -void update_TSF23a(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len); void correct_TSF23a(struct rtw_adapter *padapter, struct mlme_ext_priv *pmlmeext); struct cmd_hdl { -- cgit v1.2.3 From 0e9596992cfc1b3804d436ccbea97b66aeca00c0 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:28 +0200 Subject: staging: rtl8723au: update_TSF() remove unused argument and move to rtw_mlme_ext.c This is only called from rtw_mlme_ext.c, so move it that and declare it static. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 9 +++++++-- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 6 ------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index cb341529a1f3..2a3d3f7527c9 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -249,6 +249,11 @@ static struct fwevent wlanevents[] = }; +static void rtw_correct_TSF(struct rtw_adapter *padapter) +{ + hw_var_set_correct_tsf(padapter); +} + static void rtw_update_TSF(struct mlme_ext_priv *pmlmeext, struct ieee80211_mgmt *mgmt) { @@ -5472,7 +5477,7 @@ void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, int join_re if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) { /* correcting TSF */ - correct_TSF23a(padapter, pmlmeext); + rtw_correct_TSF(padapter); /* set_link_timer(pmlmeext, DISCONNECT_TO); */ } @@ -5499,7 +5504,7 @@ void mlmeext_sta_add_event_callback23a(struct rtw_adapter *padapter, struct sta_ else/* adhoc client */ { /* correcting TSF */ - correct_TSF23a(padapter, pmlmeext); + rtw_correct_TSF(padapter); /* start beacon */ if (send_beacon23a(padapter) == _FAIL) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index bf53973b2204..8824dd4fb55d 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -1643,12 +1643,6 @@ void process_addba_req23a(struct rtw_adapter *padapter, u8 *paddba_req, u8 *addr } } -void correct_TSF23a(struct rtw_adapter *padapter, - struct mlme_ext_priv *pmlmeext) -{ - hw_var_set_correct_tsf(padapter); -} - void beacon_timing_control23a(struct rtw_adapter *padapter) { rtw_hal_bcn_related_reg_setting23a(padapter); -- cgit v1.2.3 From f5f05715b2d2092e56d018bf2097bf03f1d147f5 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:29 +0200 Subject: staging: rtl8723au: OnAction23a(): Use struct ieee80211_mgmt instead of hardcoded offsets Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 2a3d3f7527c9..c113fe3afe2b 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -2245,16 +2245,12 @@ static int OnAction23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { int i; - unsigned char category; + u8 category; struct action_handler *ptable; - unsigned char *frame_body; struct sk_buff *skb = precv_frame->pkt; - u8 *pframe = skb->data; - - frame_body = (unsigned char *) - (pframe + sizeof(struct ieee80211_hdr_3addr)); + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; - category = frame_body[0]; + category = mgmt->u.action.category; for (i = 0; i < sizeof(OnAction23a_tbl) / sizeof(struct action_handler); i++) { -- cgit v1.2.3 From b30f74e0e06697e984c06b056769f52fc4354c0d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:30 +0200 Subject: staging: rtl8723au: OnAction23a_back23a(): Use struct ieee8011_mgmt to parse action frames Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index c113fe3afe2b..ab6b00e2568d 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -2000,7 +2000,6 @@ static int OnAction23a_back23a(struct rtw_adapter *padapter, u8 *addr; struct sta_info *psta = NULL; struct recv_reorder_ctrl *preorder_ctrl; - unsigned char *frame_body; unsigned char category, action; unsigned short tid, status, capab, params, reason_code = 0; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -2025,17 +2024,18 @@ static int OnAction23a_back23a(struct rtw_adapter *padapter, if (!psta) return _SUCCESS; - frame_body = &mgmt->u.action.category; - category = mgmt->u.action.category; if (category == WLAN_CATEGORY_BACK) { /* representing Block Ack */ if (!pmlmeinfo->HT_enable) return _SUCCESS; - action = frame_body[1]; + /* action_code is located in the same place for all + action events, so pick any */ + action = mgmt->u.action.u.wme_action.action_code; DBG_8723A("%s, action =%d\n", __func__, action); switch (action) { case WLAN_ACTION_ADDBA_REQ: /* ADDBA request */ - memcpy(&pmlmeinfo->ADDBA_req, &frame_body[2], + memcpy(&pmlmeinfo->ADDBA_req, + &mgmt->u.action.u.addba_req.dialog_token, sizeof(struct ADDBA_request)); process_addba_req23a(padapter, (u8 *)&pmlmeinfo->ADDBA_req, addr); -- cgit v1.2.3 From 6c8207a68545d0a63e5acca0df26e6523a1f7837 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:31 +0200 Subject: staging: rtl8723au: OnAssocRsp23a() use ieee80211_mgmt to obtain DA Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index ab6b00e2568d..b5c1ab0bf0be 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1763,7 +1763,6 @@ OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct sk_buff *skb = precv_frame->pkt; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; struct ieee80211_mgmt *pmgmt = (struct ieee80211_mgmt *) skb->data; int res, i; unsigned short status; @@ -1773,8 +1772,7 @@ OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) DBG_8723A("%s\n", __func__); /* check A1 matches or not */ - if (!ether_addr_equal(myid(&padapter->eeprompriv), - ieee80211_get_DA(hdr))) + if (!ether_addr_equal(myid(&padapter->eeprompriv), pmgmt->da)) return _SUCCESS; if (!(pmlmeinfo->state & (WIFI_FW_AUTH_SUCCESS | WIFI_FW_ASSOC_STATE))) -- cgit v1.2.3 From 580e756c603772a9a6732709da4389014d423132 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:32 +0200 Subject: staging: rtl8723au: OnAuth23aClient23a(): Clean up using struct ieee80211_mgmt Use 80211_mgmt to determine offsets within the received frame. This also removes a suspicious offset adjustment: offset = ieee80211_has_protected(hdr->frame_control) ? 4: 0; which didn't make any sense, since it was only applied to determining the auth, sequence number, and status, but wasn't applied to the location of the IEs. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 30 ++++++++++++--------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index b5c1ab0bf0be..cfb4660f5765 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1057,38 +1057,36 @@ auth_fail: static int OnAuth23aClient23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { - unsigned int seq, status, algthm, offset; + unsigned int seq, status, algthm; unsigned int go2asoc = 0; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct sk_buff *skb = precv_frame->pkt; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - const u8 *p, *pframe = skb->data; - int pkt_len = skb->len; + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; + const u8 *p; + u8 *pie; + int plen = skb->len; DBG_8723A("%s\n", __func__); /* check A1 matches or not */ - if (!ether_addr_equal(myid(&padapter->eeprompriv), - ieee80211_get_DA(hdr))) + if (!ether_addr_equal(myid(&padapter->eeprompriv), mgmt->da)) return _SUCCESS; if (!(pmlmeinfo->state & WIFI_FW_AUTH_STATE)) return _SUCCESS; - offset = ieee80211_has_protected(hdr->frame_control) ? 4: 0; - - pframe += sizeof(struct ieee80211_hdr_3addr); - pkt_len -= sizeof(struct ieee80211_hdr_3addr); + pie = mgmt->u.auth.variable; + plen -= offsetof(struct ieee80211_mgmt, u.auth.variable); - algthm = le16_to_cpu(*(u16 *)(pframe + offset)); - seq = le16_to_cpu(*(u16 *)(pframe + offset + 2)); - status = le16_to_cpu(*(u16 *)(pframe + offset + 4)); + algthm = le16_to_cpu(mgmt->u.auth.auth_alg); + seq = le16_to_cpu(mgmt->u.auth.auth_transaction); + status = le16_to_cpu(mgmt->u.auth.status_code); if (status) { DBG_8723A("clnt auth fail, status: %d\n", status); /* pmlmeinfo->auth_algo == dot11AuthAlgrthm_Auto) */ - if (status == 13) { + if (status == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG) { if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) pmlmeinfo->auth_algo = dot11AuthAlgrthm_Open; else @@ -1103,9 +1101,7 @@ OnAuth23aClient23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) if (seq == 2) { if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) { /* legendary shared system */ - p = cfg80211_find_ie(WLAN_EID_CHALLENGE, - pframe + _AUTH_IE_OFFSET_, - pkt_len - _AUTH_IE_OFFSET_); + p = cfg80211_find_ie(WLAN_EID_CHALLENGE, pie, plen); if (!p) { /* DBG_8723A("marc: no challenge text?\n"); */ -- cgit v1.2.3 From 78d23509822b05cedafbcbebee528c470690938a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:33 +0200 Subject: staging: rtl8723au: OnAuth23a(): ieee80211.h-ify Switch to using struct ieee80211_mgmt to obtain offsets. Again a bizarre +4 offset was applied for the IE scan which doesn't make sense, since this offset wasn't applied for the auth struct elements. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 34 ++++++++++++--------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index cfb4660f5765..4b20f07412f9 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -866,11 +866,6 @@ static int OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { #ifdef CONFIG_8723AU_AP_MODE - unsigned int auth_mode, seq; - unsigned char *sa; - const u8 *p; - u16 algorithm; - int status; static struct sta_info stat; struct sta_info *pstat = NULL; struct sta_priv *pstapriv = &padapter->stapriv; @@ -878,24 +873,27 @@ OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct sk_buff *skb = precv_frame->pkt; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - u8 *pframe = skb->data; - uint len = skb->len; + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; + u8 *pframe; + const u8 *p; + unsigned char *sa; + u16 auth_mode, seq, algorithm; + int status, len = skb->len; if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE) return _FAIL; DBG_8723A("+OnAuth23a\n"); - sa = hdr->addr2; + sa = mgmt->sa; auth_mode = psecuritypriv->dot11AuthAlgrthm; - pframe += sizeof(struct ieee80211_hdr_3addr); - len -= sizeof(struct ieee80211_hdr_3addr); + pframe = mgmt->u.auth.variable; + len = skb->len - offsetof(struct ieee80211_mgmt, u.auth.variable); - seq = cpu_to_le16(*(u16 *)(pframe + 2)); - algorithm = cpu_to_le16(*(u16 *)pframe); + seq = le16_to_cpu(mgmt->u.auth.auth_transaction); + algorithm = le16_to_cpu(mgmt->u.auth.auth_alg); DBG_8723A("auth alg =%x, seq =%X\n", algorithm, seq); @@ -906,8 +904,8 @@ OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) /* rx a shared-key auth but shared not enabled, or */ /* rx a open-system auth but shared-key is enabled */ - if ((algorithm > 0 && auth_mode == 0) || - (algorithm == 0 && auth_mode == 1)) { + if ((algorithm != WLAN_AUTH_OPEN && auth_mode == 0) || + (algorithm == WLAN_AUTH_OPEN && auth_mode == 1)) { DBG_8723A("auth rejected due to bad alg [alg =%d, auth_mib " "=%d] %02X%02X%02X%02X%02X%02X\n", algorithm, auth_mode, @@ -974,7 +972,7 @@ OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) goto auth_fail; } - if (algorithm == 0 && (auth_mode == 0 || auth_mode == 2)) { + if (algorithm == WLAN_AUTH_OPEN && (auth_mode == 0 || auth_mode == 2)) { if (seq == 1) { pstat->state &= ~WIFI_FW_AUTH_NULL; pstat->state |= WIFI_FW_AUTH_SUCCESS; @@ -998,9 +996,7 @@ OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) /* checking for challenging txt... */ DBG_8723A("checking for challenging txt...\n"); - p = cfg80211_find_ie(WLAN_EID_CHALLENGE, - pframe + 4 + _AUTH_IE_OFFSET_, - len - _AUTH_IE_OFFSET_ - 4); + p = cfg80211_find_ie(WLAN_EID_CHALLENGE, pframe, len); if (!p || p[1] <= 0) { DBG_8723A("auth rejected because challenge " "failure!(1)\n"); -- cgit v1.2.3 From 34df0dd99b9a9ab5d990adbe85c264a45010641c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:34 +0200 Subject: staging: rtl8723au: mgmt_dispatcher23a(): Use struct ieee80211_mgmt Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 4b20f07412f9..3f2f8f91d056 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -578,28 +578,28 @@ _mgt_dispatcher23a(struct rtw_adapter *padapter, struct mlme_handler *ptable, void mgt_dispatcher23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { - int index; struct mlme_handler *ptable; #ifdef CONFIG_8723AU_AP_MODE struct mlme_priv *pmlmepriv = &padapter->mlmepriv; #endif /* CONFIG_8723AU_AP_MODE */ struct sk_buff *skb = precv_frame->pkt; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - u16 stype; + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; struct sta_info *psta; + u16 stype; + int index; - if (!ieee80211_is_mgmt(hdr->frame_control)) + if (!ieee80211_is_mgmt(mgmt->frame_control)) return; /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ - if (!ether_addr_equal(hdr->addr1, myid(&padapter->eeprompriv)) && - !is_broadcast_ether_addr(hdr->addr1)) + if (!ether_addr_equal(mgmt->da, myid(&padapter->eeprompriv)) && + !is_broadcast_ether_addr(mgmt->da)) return; ptable = mlme_sta_tbl; - stype = le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_STYPE; + stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE; index = stype >> 4; if (index > 13) { @@ -610,10 +610,10 @@ void mgt_dispatcher23a(struct rtw_adapter *padapter, } ptable += index; - psta = rtw_get_stainfo23a(&padapter->stapriv, hdr->addr2); + psta = rtw_get_stainfo23a(&padapter->stapriv, mgmt->sa); if (psta) { - if (ieee80211_has_retry(hdr->frame_control)) { + if (ieee80211_has_retry(mgmt->frame_control)) { if (precv_frame->attrib.seq_num == psta->RxMgmtFrameSeqNum) { /* drop the duplicate management frame */ -- cgit v1.2.3 From 68e6831e6394cba73cf64f071a8a02f83c13c659 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:35 +0200 Subject: staging: rtl8723au: init_channel_set(): Restructure variable names Shorten variable names allowing for fewer broken lines due to the large number of indents. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 96 ++++++++++++--------------- 1 file changed, 44 insertions(+), 52 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 3f2f8f91d056..c2ab4c66607c 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -419,96 +419,88 @@ static void init_channel_list(struct rtw_adapter *padapter, channel_list->reg_classes = cla; } -static u8 init_channel_set(struct rtw_adapter* padapter, u8 ChannelPlan, - struct rt_channel_info *channel_set) +static u8 init_channel_set(struct rtw_adapter* padapter, u8 cplan, + struct rt_channel_info *c_set) { - u8 index, chanset_size = 0; - u8 b5GBand = false, b2_4GBand = false; - u8 Index2G = 0, Index5G = 0; + u8 i, ch_size = 0; + u8 b5GBand = false, b2_4GBand = false; + u8 Index2G = 0, Index5G = 0; - memset(channel_set, 0, sizeof(struct rt_channel_info)*MAX_CHANNEL_NUM); + memset(c_set, 0, sizeof(struct rt_channel_info) * MAX_CHANNEL_NUM); - if (ChannelPlan >= RT_CHANNEL_DOMAIN_MAX && - ChannelPlan != RT_CHANNEL_DOMAIN_REALTEK_DEFINE) { - DBG_8723A("ChannelPlan ID %x error !!!!!\n", ChannelPlan); - return chanset_size; + if (cplan >= RT_CHANNEL_DOMAIN_MAX && + cplan != RT_CHANNEL_DOMAIN_REALTEK_DEFINE) { + DBG_8723A("ChannelPlan ID %x error !!!!!\n", cplan); + return ch_size; } if (padapter->registrypriv.wireless_mode & WIRELESS_11G) { b2_4GBand = true; - if (RT_CHANNEL_DOMAIN_REALTEK_DEFINE == ChannelPlan) + if (RT_CHANNEL_DOMAIN_REALTEK_DEFINE == cplan) Index2G = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.Index2G; else - Index2G = RTW_ChannelPlanMap[ChannelPlan].Index2G; + Index2G = RTW_ChannelPlanMap[cplan].Index2G; } if (padapter->registrypriv.wireless_mode & WIRELESS_11A) { b5GBand = true; - if (RT_CHANNEL_DOMAIN_REALTEK_DEFINE == ChannelPlan) + if (RT_CHANNEL_DOMAIN_REALTEK_DEFINE == cplan) Index5G = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.Index5G; else - Index5G = RTW_ChannelPlanMap[ChannelPlan].Index5G; + Index5G = RTW_ChannelPlanMap[cplan].Index5G; } if (b2_4GBand) { - for (index = 0; index= 1 && - channel_set[chanset_size].ChannelNum <= 11) - channel_set[chanset_size].ScanType = - SCAN_ACTIVE; - else if ((channel_set[chanset_size].ChannelNum >= 12 && - channel_set[chanset_size].ChannelNum <= 14)) - channel_set[chanset_size].ScanType = - SCAN_PASSIVE; - } else if (RT_CHANNEL_DOMAIN_WORLD_WIDE_13 == - ChannelPlan || - RT_CHANNEL_DOMAIN_WORLD_WIDE_5G == - ChannelPlan || + RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G == cplan) { + if (c_set[ch_size].ChannelNum >= 1 && + c_set[ch_size].ChannelNum <= 11) + c_set[ch_size].ScanType = SCAN_ACTIVE; + else if (c_set[ch_size].ChannelNum >= 12 && + c_set[ch_size].ChannelNum <= 14) + c_set[ch_size].ScanType = SCAN_PASSIVE; + } else if (RT_CHANNEL_DOMAIN_WORLD_WIDE_13 == cplan || + RT_CHANNEL_DOMAIN_WORLD_WIDE_5G == cplan || RT_CHANNEL_DOMAIN_2G_WORLD == Index2G) { /* channel 12~13, passive scan */ - if (channel_set[chanset_size].ChannelNum <= 11) - channel_set[chanset_size].ScanType = - SCAN_ACTIVE; + if (c_set[ch_size].ChannelNum <= 11) + c_set[ch_size].ScanType = SCAN_ACTIVE; else - channel_set[chanset_size].ScanType = - SCAN_PASSIVE; + c_set[ch_size].ScanType = SCAN_PASSIVE; } else - channel_set[chanset_size].ScanType = - SCAN_ACTIVE; + c_set[ch_size].ScanType = SCAN_ACTIVE; - chanset_size++; + ch_size++; } } if (b5GBand) { - for (index = 0;index= 149) { - channel_set[chanset_size].ChannelNum = - RTW_ChannelPlan5G[Index5G].Channel[index]; - if (RT_CHANNEL_DOMAIN_WORLD_WIDE_5G == - ChannelPlan) { + for (i = 0; i < RTW_ChannelPlan5G[Index5G].Len; i++) { + if (RTW_ChannelPlan5G[Index5G].Channel[i] <= 48 || + RTW_ChannelPlan5G[Index5G].Channel[i] >= 149) { + c_set[ch_size].ChannelNum = + RTW_ChannelPlan5G[Index5G].Channel[i]; + if (RT_CHANNEL_DOMAIN_WORLD_WIDE_5G == cplan) { /* passive scan for all 5G channels */ - channel_set[chanset_size].ScanType = + c_set[ch_size].ScanType = SCAN_PASSIVE; } else - channel_set[chanset_size].ScanType = + c_set[ch_size].ScanType = SCAN_ACTIVE; DBG_8723A("%s(): channel_set[%d].ChannelNum = " - "%d\n", __func__, chanset_size, - channel_set[chanset_size].ChannelNum); - chanset_size++; + "%d\n", __func__, ch_size, + c_set[ch_size].ChannelNum); + ch_size++; } } } - return chanset_size; + return ch_size; } int init_mlme_ext_priv23a(struct rtw_adapter* padapter) -- cgit v1.2.3 From bc55ae446ffff66afa1744320331893ea39557ab Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:36 +0200 Subject: staging: rtl8723au: os_intfs.c: Declare a couple of local variables static Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/hal_intf.h | 4 ---- drivers/staging/rtl8723au/os_dep/os_intfs.c | 6 +++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 0b07e8b1f068..89516467f241 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -215,10 +215,6 @@ enum hardware_type { #define GET_EEPROM_EFUSE_PRIV(adapter) (&adapter->eeprompriv) -extern int rtw_ht_enable23A; -extern int rtw_cbw40_enable23A; -extern int rtw_ampdu_enable23A;/* for enable tx_ampdu */ - void rtw_hal_def_value_init23a(struct rtw_adapter *padapter); int pm_netdev_open23a(struct net_device *pnetdev, u8 bnormal); int rtw_resume_process23a(struct rtw_adapter *padapter); diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index 49da7dd18171..26882aac414f 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -65,10 +65,10 @@ static int rtw_acm_method;/* 0:By SW 1:By HW. */ static int rtw_wmm_enable = 1;/* default is set to enable the wmm. */ static int rtw_uapsd_enable; -int rtw_ht_enable23A = 1; +static int rtw_ht_enable23A = 1; /* 0 :diable, bit(0): enable 2.4g, bit(1): enable 5g */ -int rtw_cbw40_enable23A = 3; -int rtw_ampdu_enable23A = 1;/* for enable tx_ampdu */ +static int rtw_cbw40_enable23A = 3; +static int rtw_ampdu_enable23A = 1;/* for enable tx_ampdu */ /* 0: disable, bit(0):enable 2.4g, bit(1):enable 5g, default is set to enable * 2.4GHZ for IOT issue with bufflao's AP at 5GHZ */ -- cgit v1.2.3 From b809fc44c6220d5dd33796022d28f4c4fc461485 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:37 +0200 Subject: staging: rtl8188eu: usb_intf.c: No point processing an empty table In addition, this would globally disable HT if one device in the system would mark it unsupported. If any device ended up requiring this, it should be handled on a per-instance basis. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index 2e49cd583212..49a4ce44ada6 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -62,10 +62,6 @@ static struct usb_device_id rtw_usb_id_tbl[] = { MODULE_DEVICE_TABLE(usb, rtw_usb_id_tbl); -static struct specific_device_id specific_device_id_tbl[] = { - {} /* empty table for now */ -}; - struct rtw_usb_drv { struct usb_driver usbdrv; int drv_registered; @@ -360,28 +356,6 @@ static void rtw_dev_unload(struct adapter *padapter) RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-rtw_dev_unload\n")); } -static void process_spec_devid(const struct usb_device_id *pdid) -{ - u16 vid, pid; - u32 flags; - int i; - int num = sizeof(specific_device_id_tbl) / - sizeof(struct specific_device_id); - - for (i = 0; i < num; i++) { - vid = specific_device_id_tbl[i].idVendor; - pid = specific_device_id_tbl[i].idProduct; - flags = specific_device_id_tbl[i].flags; - - if ((pdid->idVendor == vid) && (pdid->idProduct == pid) && - (flags&SPEC_DEV_ID_DISABLE_HT)) { - rtw_ht_enable = 0; - rtw_cbw40_enable = 0; - rtw_ampdu_enable = 0; - } - } -} - int rtw_hw_suspend(struct adapter *padapter) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; @@ -781,9 +755,6 @@ static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_drv_init\n")); - /* step 0. */ - process_spec_devid(pdid); - /* Initialize dvobj_priv */ dvobj = usb_dvobj_init(pusb_intf); if (dvobj == NULL) { -- cgit v1.2.3 From 987bc3fed6e35aab00b9cef6d92607236ce719c3 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:38 +0200 Subject: staging: rtl8188eu: os_intfs.c: Mark a couple of variables static Mark these variables local to avoid namespace clash with other RTL drivers. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/xmit_osdep.h | 4 ---- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 6 +++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/xmit_osdep.h b/drivers/staging/rtl8188eu/include/xmit_osdep.h index 2ff622ba24f0..48bc5fca996d 100644 --- a/drivers/staging/rtl8188eu/include/xmit_osdep.h +++ b/drivers/staging/rtl8188eu/include/xmit_osdep.h @@ -32,10 +32,6 @@ struct pkt_file { size_t buf_len; }; -extern int rtw_ht_enable; -extern int rtw_cbw40_enable; -extern int rtw_ampdu_enable;/* for enable tx_ampdu */ - #define NR_XMITFRAME 256 struct xmit_priv; diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index b225d1c07210..9edb8e880ae8 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -84,9 +84,9 @@ static int rtw_uapsd_acbe_en; static int rtw_uapsd_acvi_en; static int rtw_uapsd_acvo_en; -int rtw_ht_enable = 1; -int rtw_cbw40_enable = 3; /* 0 :disable, bit(0): enable 2.4g, bit(1): enable 5g */ -int rtw_ampdu_enable = 1;/* for enable tx_ampdu */ +static int rtw_ht_enable = 1; +static int rtw_cbw40_enable = 3; /* 0 :disable, bit(0): enable 2.4g, bit(1): enable 5g */ +static int rtw_ampdu_enable = 1;/* for enable tx_ampdu */ static int rtw_rx_stbc = 1;/* 0: disable, bit(0):enable 2.4g, bit(1):enable 5g, default is set to enable 2.4GHZ for IOT issue with bufflao's AP at 5GHZ */ static int rtw_ampdu_amsdu;/* 0: disabled, 1:enabled, 2:auto */ -- cgit v1.2.3 From 76dc444185adc5f2a12dc713a337274593c76333 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:39 +0200 Subject: staging: rtl8723au: Clean up namespace clashes with rtl8188eu driver Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/os_intfs.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index 26882aac414f..fd9de2a60bf7 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -65,10 +65,10 @@ static int rtw_acm_method;/* 0:By SW 1:By HW. */ static int rtw_wmm_enable = 1;/* default is set to enable the wmm. */ static int rtw_uapsd_enable; -static int rtw_ht_enable23A = 1; +static int rtw_ht_enable = 1; /* 0 :diable, bit(0): enable 2.4g, bit(1): enable 5g */ -static int rtw_cbw40_enable23A = 3; -static int rtw_ampdu_enable23A = 1;/* for enable tx_ampdu */ +static int rtw_cbw40_enable = 3; +static int rtw_ampdu_enable = 1;/* for enable tx_ampdu */ /* 0: disable, bit(0):enable 2.4g, bit(1):enable 5g, default is set to enable * 2.4GHZ for IOT issue with bufflao's AP at 5GHZ */ @@ -129,9 +129,9 @@ module_param(rtw_wmm_enable, int, 0644); module_param(rtw_vrtl_carrier_sense, int, 0644); module_param(rtw_vcs_type, int, 0644); module_param(rtw_busy_thresh, int, 0644); -module_param(rtw_ht_enable23A, int, 0644); -module_param(rtw_cbw40_enable23A, int, 0644); -module_param(rtw_ampdu_enable23A, int, 0644); +module_param(rtw_ht_enable, int, 0644); +module_param(rtw_cbw40_enable, int, 0644); +module_param(rtw_ampdu_enable, int, 0644); module_param(rtw_rx_stbc, int, 0644); module_param(rtw_ampdu_amsdu, int, 0644); @@ -202,9 +202,9 @@ static uint loadparam(struct rtw_adapter *padapter, struct net_device *pnetdev) /* UAPSD */ registry_par->wmm_enable = (u8)rtw_wmm_enable; registry_par->uapsd_enable = (u8)rtw_uapsd_enable; - registry_par->ht_enable = (u8)rtw_ht_enable23A; - registry_par->cbw40_enable = (u8)rtw_cbw40_enable23A; - registry_par->ampdu_enable = (u8)rtw_ampdu_enable23A; + registry_par->ht_enable = (u8)rtw_ht_enable; + registry_par->cbw40_enable = (u8)rtw_cbw40_enable; + registry_par->ampdu_enable = (u8)rtw_ampdu_enable; registry_par->rx_stbc = (u8)rtw_rx_stbc; registry_par->ampdu_amsdu = (u8)rtw_ampdu_amsdu; registry_par->lowrate_two_xmit = (u8)rtw_lowrate_two_xmit; -- cgit v1.2.3 From 35a5c6f3a3c697c858b721aaf52218629286b5d7 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:40 +0200 Subject: staging: rtl8723au: Remove unused function rtw_os_read_port23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/recv_osdep.h | 2 -- drivers/staging/rtl8723au/os_dep/recv_linux.c | 12 ------------ 2 files changed, 14 deletions(-) diff --git a/drivers/staging/rtl8723au/include/recv_osdep.h b/drivers/staging/rtl8723au/include/recv_osdep.h index 15c94b6168bf..037ce5a64b92 100644 --- a/drivers/staging/rtl8723au/include/recv_osdep.h +++ b/drivers/staging/rtl8723au/include/recv_osdep.h @@ -38,8 +38,6 @@ void rtw_os_recv_resource_free(struct recv_priv *precvpriv); int rtw_os_recvbuf_resource_alloc23a(struct rtw_adapter *padapter, struct recv_buf *precvbuf); int rtw_os_recvbuf_resource_free23a(struct rtw_adapter *padapter, struct recv_buf *precvbuf); -void rtw_os_read_port23a(struct rtw_adapter *padapter, struct recv_buf *precvbuf); - void rtw_init_recv_timer23a(struct recv_reorder_ctrl *preorder_ctrl); #endif diff --git a/drivers/staging/rtl8723au/os_dep/recv_linux.c b/drivers/staging/rtl8723au/os_dep/recv_linux.c index 18572090ac48..1d54f9e4c4a9 100644 --- a/drivers/staging/rtl8723au/os_dep/recv_linux.c +++ b/drivers/staging/rtl8723au/os_dep/recv_linux.c @@ -204,18 +204,6 @@ _recv_indicatepkt_drop: return _FAIL; } -void rtw_os_read_port23a(struct rtw_adapter *padapter, struct recv_buf *precvbuf) -{ - struct recv_priv *precvpriv = &padapter->recvpriv; - - /* free skb in recv_buf */ - dev_kfree_skb_any(precvbuf->pskb); - - precvbuf->pskb = NULL; - - rtw_read_port(padapter, precvpriv->ff_hwaddr, 0, precvbuf); -} - void rtw_init_recv_timer23a(struct recv_reorder_ctrl *preorder_ctrl) { setup_timer(&preorder_ctrl->reordering_ctrl_timer, -- cgit v1.2.3 From 09ae6d750c267452060beceab2c27b7a03badf89 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:41 +0200 Subject: staging: rtl8723au: Remove unnecessary abstraction rtw_os_recv_resource_alloc23a() No point calling a function to NULL a pointer that was just cleared in the malloc call. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_recv.c | 2 -- drivers/staging/rtl8723au/include/recv_osdep.h | 2 -- drivers/staging/rtl8723au/os_dep/recv_linux.c | 11 ----------- 3 files changed, 15 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 5d81a8c18218..644c3a132e59 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -79,8 +79,6 @@ int _rtw_init_recv_priv23a(struct recv_priv *precvpriv, list_add_tail(&precvframe->list, &precvpriv->free_recv_queue.queue); - res = rtw_os_recv_resource_alloc23a(padapter, precvframe); - precvframe->adapter = padapter; precvframe++; } diff --git a/drivers/staging/rtl8723au/include/recv_osdep.h b/drivers/staging/rtl8723au/include/recv_osdep.h index 037ce5a64b92..39809befb88c 100644 --- a/drivers/staging/rtl8723au/include/recv_osdep.h +++ b/drivers/staging/rtl8723au/include/recv_osdep.h @@ -32,8 +32,6 @@ int rtw_init_recv_priv(struct recv_priv *precvpriv, struct rtw_adapter *padapter void rtw_free_recv_priv (struct recv_priv *precvpriv); int rtw_os_recv_resource_init(struct recv_priv *precvpriv, struct rtw_adapter *padapter); -int rtw_os_recv_resource_alloc23a(struct rtw_adapter *padapter, struct recv_frame *precvframe); -void rtw_os_recv_resource_free(struct recv_priv *precvpriv); int rtw_os_recvbuf_resource_alloc23a(struct rtw_adapter *padapter, struct recv_buf *precvbuf); int rtw_os_recvbuf_resource_free23a(struct rtw_adapter *padapter, struct recv_buf *precvbuf); diff --git a/drivers/staging/rtl8723au/os_dep/recv_linux.c b/drivers/staging/rtl8723au/os_dep/recv_linux.c index 1d54f9e4c4a9..321aa282e3f2 100644 --- a/drivers/staging/rtl8723au/os_dep/recv_linux.c +++ b/drivers/staging/rtl8723au/os_dep/recv_linux.c @@ -24,17 +24,6 @@ #include -/* alloc os related resource in struct recv_frame */ -int rtw_os_recv_resource_alloc23a(struct rtw_adapter *padapter, - struct recv_frame *precvframe) -{ - int res = _SUCCESS; - - precvframe->pkt = NULL; - - return res; -} - /* alloc os related resource in struct recv_buf */ int rtw_os_recvbuf_resource_alloc23a(struct rtw_adapter *padapter, struct recv_buf *precvbuf) -- cgit v1.2.3 From f466c400e78f785dee0b16b7198df0d4c601b162 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:42 +0200 Subject: staging: rtl8723au: Fold some resource allocation abstraction into their callers Fold rtw_os_recvbuf_resource_alloc23a() and rtw_os_recvbuf_resource_free23a() into the functions calling them. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723au_recv.c | 10 ++++++--- drivers/staging/rtl8723au/include/recv_osdep.h | 3 --- drivers/staging/rtl8723au/os_dep/recv_linux.c | 29 -------------------------- 3 files changed, 7 insertions(+), 35 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_recv.c b/drivers/staging/rtl8723au/hal/rtl8723au_recv.c index a7568bb65e2a..e1f17af78a12 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723au_recv.c +++ b/drivers/staging/rtl8723au/hal/rtl8723au_recv.c @@ -65,8 +65,8 @@ int rtl8723au_init_recv_priv(struct rtw_adapter *padapter) for (i = 0; i < NR_RECVBUFF; i++) { INIT_LIST_HEAD(&precvbuf->list); - res = rtw_os_recvbuf_resource_alloc23a(padapter, precvbuf); - if (res == _FAIL) + precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL); + if (!precvbuf->purb) break; precvbuf->adapter = padapter; @@ -109,7 +109,11 @@ void rtl8723au_free_recv_priv(struct rtw_adapter *padapter) precvbuf = (struct recv_buf *)precvpriv->precv_buf; for (i = 0; i < NR_RECVBUFF; i++) { - rtw_os_recvbuf_resource_free23a(padapter, precvbuf); + usb_free_urb(precvbuf->purb); + + if (precvbuf->pskb) + dev_kfree_skb_any(precvbuf->pskb); + precvbuf++; } diff --git a/drivers/staging/rtl8723au/include/recv_osdep.h b/drivers/staging/rtl8723au/include/recv_osdep.h index 39809befb88c..3a2cd8a3058d 100644 --- a/drivers/staging/rtl8723au/include/recv_osdep.h +++ b/drivers/staging/rtl8723au/include/recv_osdep.h @@ -33,9 +33,6 @@ void rtw_free_recv_priv (struct recv_priv *precvpriv); int rtw_os_recv_resource_init(struct recv_priv *precvpriv, struct rtw_adapter *padapter); -int rtw_os_recvbuf_resource_alloc23a(struct rtw_adapter *padapter, struct recv_buf *precvbuf); -int rtw_os_recvbuf_resource_free23a(struct rtw_adapter *padapter, struct recv_buf *precvbuf); - void rtw_init_recv_timer23a(struct recv_reorder_ctrl *preorder_ctrl); #endif diff --git a/drivers/staging/rtl8723au/os_dep/recv_linux.c b/drivers/staging/rtl8723au/os_dep/recv_linux.c index 321aa282e3f2..8fecbe38ca27 100644 --- a/drivers/staging/rtl8723au/os_dep/recv_linux.c +++ b/drivers/staging/rtl8723au/os_dep/recv_linux.c @@ -24,35 +24,6 @@ #include -/* alloc os related resource in struct recv_buf */ -int rtw_os_recvbuf_resource_alloc23a(struct rtw_adapter *padapter, - struct recv_buf *precvbuf) -{ - int res = _SUCCESS; - - precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL); - if (precvbuf->purb == NULL) - res = _FAIL; - - precvbuf->pskb = NULL; - - return res; -} - -/* free os related resource in struct recv_buf */ -int rtw_os_recvbuf_resource_free23a(struct rtw_adapter *padapter, - struct recv_buf *precvbuf) -{ - int ret = _SUCCESS; - - usb_free_urb(precvbuf->purb); - - if (precvbuf->pskb) - dev_kfree_skb_any(precvbuf->pskb); - - return ret; -} - void rtw_handle_tkip_mic_err23a(struct rtw_adapter *padapter, u8 bgroup) { enum nl80211_key_type key_type = 0; -- cgit v1.2.3 From c8bdc729c2cdeedb4e899983cd08df95dfd4504c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:43 +0200 Subject: staging: rtl8723au: Remove another unused prototype Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/recv_osdep.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8723au/include/recv_osdep.h b/drivers/staging/rtl8723au/include/recv_osdep.h index 3a2cd8a3058d..37a90cafce6a 100644 --- a/drivers/staging/rtl8723au/include/recv_osdep.h +++ b/drivers/staging/rtl8723au/include/recv_osdep.h @@ -23,7 +23,6 @@ void _rtw_free_recv_priv23a (struct recv_priv *precvpriv); int rtw_recv_entry23a(struct recv_frame *precv_frame); int rtw_recv_indicatepkt23a(struct rtw_adapter *adapter, struct recv_frame *precv_frame); -void rtw_recv_returnpacket(struct net_device *cnxt, struct sk_buff *preturnedpkt); void rtw_hostapd_mlme_rx23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); void rtw_handle_tkip_mic_err23a(struct rtw_adapter *padapter, u8 bgroup); -- cgit v1.2.3 From 684ad6ee72f98ddf541c976653b07c18e3a15bdc Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:44 +0200 Subject: staging: rtl8723au: Remove dummy function rtw_hostapd_mlme_rx23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 2 -- drivers/staging/rtl8723au/include/recv_osdep.h | 1 - drivers/staging/rtl8723au/os_dep/recv_linux.c | 5 ----- 3 files changed, 8 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index c2ab4c66607c..31022f2508c3 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -646,8 +646,6 @@ void mgt_dispatcher23a(struct rtw_adapter *padapter, break; default: _mgt_dispatcher23a(padapter, ptable, precv_frame); - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) - rtw_hostapd_mlme_rx23a(padapter, precv_frame); break; } #else diff --git a/drivers/staging/rtl8723au/include/recv_osdep.h b/drivers/staging/rtl8723au/include/recv_osdep.h index 37a90cafce6a..c2d3f1bd5948 100644 --- a/drivers/staging/rtl8723au/include/recv_osdep.h +++ b/drivers/staging/rtl8723au/include/recv_osdep.h @@ -24,7 +24,6 @@ void _rtw_free_recv_priv23a (struct recv_priv *precvpriv); int rtw_recv_entry23a(struct recv_frame *precv_frame); int rtw_recv_indicatepkt23a(struct rtw_adapter *adapter, struct recv_frame *precv_frame); -void rtw_hostapd_mlme_rx23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); void rtw_handle_tkip_mic_err23a(struct rtw_adapter *padapter, u8 bgroup); int rtw_init_recv_priv(struct recv_priv *precvpriv, struct rtw_adapter *padapter); diff --git a/drivers/staging/rtl8723au/os_dep/recv_linux.c b/drivers/staging/rtl8723au/os_dep/recv_linux.c index 8fecbe38ca27..528ed9253b14 100644 --- a/drivers/staging/rtl8723au/os_dep/recv_linux.c +++ b/drivers/staging/rtl8723au/os_dep/recv_linux.c @@ -69,11 +69,6 @@ void rtw_handle_tkip_mic_err23a(struct rtw_adapter *padapter, u8 bgroup) wrqu.data.length = sizeof(ev); } -void rtw_hostapd_mlme_rx23a(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) -{ -} - int rtw_recv_indicatepkt23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { -- cgit v1.2.3 From 480c865ed9e34c2e9362723c094e10b62068b8e4 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:45 +0200 Subject: staging: rtl8723au: rtw_mlme.c: Clean up mess Clean up spaghetti formatting and avoid NULL initializing variables where it isn't needed. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 1045 ++++++++++++++++------------- 1 file changed, 568 insertions(+), 477 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 8c11fa18fe89..8bb368499ce2 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -53,8 +53,11 @@ int _rtw_init_mlme_priv23a(struct rtw_adapter *padapter) pmlmepriv->nic_hdl = padapter; pmlmepriv->fw_state = 0; - pmlmepriv->cur_network.network.InfrastructureMode = Ndis802_11AutoUnknown; - pmlmepriv->scan_mode=SCAN_ACTIVE;/* 1: active, 0: pasive. Maybe someday we should rename this varable to "active_mode" (Jeff) */ + pmlmepriv->cur_network.network.InfrastructureMode = + Ndis802_11AutoUnknown; + /* 1: active, 0: pasive. Maybe someday we should rename this + varable to "active_mode" (Jeff) */ + pmlmepriv->scan_mode = SCAN_ACTIVE; spin_lock_init(&pmlmepriv->lock); _rtw_init_queue23a(&pmlmepriv->scanned_queue); @@ -72,11 +75,10 @@ int _rtw_init_mlme_priv23a(struct rtw_adapter *padapter) #ifdef CONFIG_8723AU_AP_MODE static void rtw_free_mlme_ie_data(u8 **ppie, u32 *plen) { - if(*ppie) - { + if (*ppie) { kfree(*ppie); *plen = 0; - *ppie=NULL; + *ppie = NULL; } } #endif @@ -86,30 +88,42 @@ void rtw23a_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv) #ifdef CONFIG_8723AU_AP_MODE kfree(pmlmepriv->assoc_req); kfree(pmlmepriv->assoc_rsp); - rtw_free_mlme_ie_data(&pmlmepriv->wps_beacon_ie, &pmlmepriv->wps_beacon_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_req_ie, &pmlmepriv->wps_probe_req_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_resp_ie, &pmlmepriv->wps_probe_resp_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->wps_assoc_resp_ie, &pmlmepriv->wps_assoc_resp_ie_len); - - rtw_free_mlme_ie_data(&pmlmepriv->p2p_beacon_ie, &pmlmepriv->p2p_beacon_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->p2p_probe_req_ie, &pmlmepriv->p2p_probe_req_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->p2p_probe_resp_ie, &pmlmepriv->p2p_probe_resp_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->p2p_go_probe_resp_ie, &pmlmepriv->p2p_go_probe_resp_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->p2p_assoc_req_ie, &pmlmepriv->p2p_assoc_req_ie_len); - - rtw_free_mlme_ie_data(&pmlmepriv->wfd_beacon_ie, &pmlmepriv->wfd_beacon_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->wfd_probe_req_ie, &pmlmepriv->wfd_probe_req_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->wfd_probe_resp_ie, &pmlmepriv->wfd_probe_resp_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->wfd_go_probe_resp_ie, &pmlmepriv->wfd_go_probe_resp_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->wfd_assoc_req_ie, &pmlmepriv->wfd_assoc_req_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wps_beacon_ie, + &pmlmepriv->wps_beacon_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_req_ie, + &pmlmepriv->wps_probe_req_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_resp_ie, + &pmlmepriv->wps_probe_resp_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wps_assoc_resp_ie, + &pmlmepriv->wps_assoc_resp_ie_len); + + rtw_free_mlme_ie_data(&pmlmepriv->p2p_beacon_ie, + &pmlmepriv->p2p_beacon_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->p2p_probe_req_ie, + &pmlmepriv->p2p_probe_req_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->p2p_probe_resp_ie, + &pmlmepriv->p2p_probe_resp_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->p2p_go_probe_resp_ie, + &pmlmepriv->p2p_go_probe_resp_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->p2p_assoc_req_ie, + &pmlmepriv->p2p_assoc_req_ie_len); + + rtw_free_mlme_ie_data(&pmlmepriv->wfd_beacon_ie, + &pmlmepriv->wfd_beacon_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wfd_probe_req_ie, + &pmlmepriv->wfd_probe_req_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wfd_probe_resp_ie, + &pmlmepriv->wfd_probe_resp_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wfd_go_probe_resp_ie, + &pmlmepriv->wfd_go_probe_resp_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wfd_assoc_req_ie, + &pmlmepriv->wfd_assoc_req_ie_len); #endif } void _rtw_free_mlme_priv23a(struct mlme_priv *pmlmepriv) { - rtw23a_free_mlme_priv_ie_data(pmlmepriv); - } struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv) @@ -150,10 +164,9 @@ void _rtw_free_network23a(struct mlme_priv *pmlmepriv, } void _rtw_free_network23a_nolock23a(struct mlme_priv *pmlmepriv, - struct wlan_network *pnetwork) + struct wlan_network *pnetwork) { - - if (pnetwork == NULL) + if (!pnetwork) return; if (pnetwork->fixed == true) @@ -165,9 +178,9 @@ void _rtw_free_network23a_nolock23a(struct mlme_priv *pmlmepriv, } /* - return the wlan_network with the matching addr + return the wlan_network with the matching addr - Shall be calle under atomic context... to avoid possible racing condition... + Shall be calle under atomic context... to avoid possible racing condition... */ struct wlan_network * _rtw_find_network23a(struct rtw_queue *scanned_queue, u8 *addr) @@ -194,7 +207,7 @@ _rtw_find_network23a(struct rtw_queue *scanned_queue, u8 *addr) plist = plist->next; } - if(plist == phead) + if (plist == phead) pnetwork = NULL; /* spin_unlock_bh(&scanned_queue->lock); */ @@ -208,7 +221,7 @@ void _rtw_free_network23a_queue23a(struct rtw_adapter *padapter, u8 isfreeall) { struct list_head *phead, *plist, *ptmp; struct wlan_network *pnetwork; - struct mlme_priv* pmlmepriv = &padapter->mlmepriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct rtw_queue *scanned_queue = &pmlmepriv->scanned_queue; spin_lock_bh(&scanned_queue->lock); @@ -222,20 +235,21 @@ void _rtw_free_network23a_queue23a(struct rtw_adapter *padapter, u8 isfreeall) } spin_unlock_bh(&scanned_queue->lock); - } -int rtw_if_up23a(struct rtw_adapter *padapter) { - +int rtw_if_up23a(struct rtw_adapter *padapter) +{ int res; - if(padapter->bDriverStopped || padapter->bSurpriseRemoved || - (check_fwstate(&padapter->mlmepriv, _FW_LINKED)== false)) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_if_up23a:bDriverStopped(%d) OR bSurpriseRemoved(%d)", padapter->bDriverStopped, padapter->bSurpriseRemoved)); - res=false; - } - else - res= true; + if (padapter->bDriverStopped || padapter->bSurpriseRemoved || + check_fwstate(&padapter->mlmepriv, _FW_LINKED) == false) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("rtw_if_up23a:bDriverStopped(%d) OR " + "bSurpriseRemoved(%d)", padapter->bDriverStopped, + padapter->bSurpriseRemoved)); + res = false; + } else + res = true; return res; } @@ -247,9 +261,9 @@ void rtw_generate_random_ibss23a(u8* pibss) pibss[0] = 0x02; /* in ad-hoc mode bit1 must set to 1 */ pibss[1] = 0x11; pibss[2] = 0x87; - pibss[3] = (u8)(curtime & 0xff) ;/* p[0]; */ - pibss[4] = (u8)((curtime>>8) & 0xff) ;/* p[1]; */ - pibss[5] = (u8)((curtime>>16) & 0xff) ;/* p[2]; */ + pibss[3] = curtime & 0xff;/* p[0]; */ + pibss[4] = (curtime >> 8) & 0xff;/* p[1]; */ + pibss[5] = (curtime >> 16) & 0xff;/* p[2]; */ return; } @@ -261,9 +275,9 @@ u8 *rtw_get_capability23a_from_ie(u8 *ie) u16 rtw_get_capability23a(struct wlan_bssid_ex *bss) { - u16 val; + u16 val; - memcpy((u8 *)&val, rtw_get_capability23a_from_ie(bss->IEs), 2); + memcpy(&val, rtw_get_capability23a_from_ie(bss->IEs), 2); return le16_to_cpu(val); } @@ -278,41 +292,35 @@ u8 *rtw_get_beacon_interval23a_from_ie(u8 *ie) return ie + 8; } -int rtw_init_mlme_priv23a (struct rtw_adapter *padapter)/* struct mlme_priv *pmlmepriv) */ +int rtw_init_mlme_priv23a (struct rtw_adapter *padapter) { int res; - res = _rtw_init_mlme_priv23a(padapter);/* (pmlmepriv); */ + res = _rtw_init_mlme_priv23a(padapter); return res; } void rtw_free_mlme_priv23a (struct mlme_priv *pmlmepriv) { - - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_free_mlme_priv23a\n")); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("rtw_free_mlme_priv23a\n")); _rtw_free_mlme_priv23a(pmlmepriv); - } -void rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork, u8 is_freeall); -void rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork, u8 is_freeall)/* struct wlan_network *pnetwork, _queue *free_queue) */ +void rtw_free_network(struct mlme_priv *pmlmepriv, + struct wlan_network *pnetwork, u8 is_freeall) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_free_network ==> ssid = %s\n\n" , pnetwork->network.Ssid.ssid)); _rtw_free_network23a(pmlmepriv, pnetwork, is_freeall); - } -void rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork); -void rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork) +void rtw_free_network_nolock(struct mlme_priv *pmlmepriv, + struct wlan_network *pnetwork) { - - /* RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_free_network ==> ssid = %s\n\n" , pnetwork->network.Ssid.ssid)); */ _rtw_free_network23a_nolock23a(pmlmepriv, pnetwork); - } void rtw_free_network_queue23a(struct rtw_adapter* dev, u8 isfreeall) @@ -323,9 +331,9 @@ void rtw_free_network_queue23a(struct rtw_adapter* dev, u8 isfreeall) } /* - return the wlan_network with the matching addr + return the wlan_network with the matching addr - Shall be calle under atomic context... to avoid possible racing condition... + Shall be calle under atomic context... to avoid possible racing condition... */ struct wlan_network * rtw_find_network23a(struct rtw_queue *scanned_queue, u8 *addr) @@ -337,25 +345,20 @@ rtw_find_network23a(struct rtw_queue *scanned_queue, u8 *addr) return pnetwork; } -int rtw_is_same_ibss23a(struct rtw_adapter *adapter, struct wlan_network *pnetwork) +int rtw_is_same_ibss23a(struct rtw_adapter *adapter, + struct wlan_network *pnetwork) { int ret = true; struct security_priv *psecuritypriv = &adapter->securitypriv; - if ((psecuritypriv->dot11PrivacyAlgrthm != _NO_PRIVACY_) && - (pnetwork->network.Privacy == 0)) - { + if (psecuritypriv->dot11PrivacyAlgrthm != _NO_PRIVACY_ && + pnetwork->network.Privacy == 0) ret = false; - } - else if ((psecuritypriv->dot11PrivacyAlgrthm == _NO_PRIVACY_) && - (pnetwork->network.Privacy == 1)) - { + else if (psecuritypriv->dot11PrivacyAlgrthm == _NO_PRIVACY_ && + pnetwork->network.Privacy == 1) ret = false; - } else - { ret = true; - } return ret; } @@ -363,18 +366,16 @@ int rtw_is_same_ibss23a(struct rtw_adapter *adapter, struct wlan_network *pnetwo inline int is_same_ess(struct wlan_bssid_ex *a, struct wlan_bssid_ex *b); inline int is_same_ess(struct wlan_bssid_ex *a, struct wlan_bssid_ex *b) { - /* RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("(%s,%d)(%s,%d)\n", */ - /* a->Ssid.Ssid, a->Ssid.SsidLength, b->Ssid.Ssid, b->Ssid.SsidLength)); */ return (a->Ssid.ssid_len == b->Ssid.ssid_len) && !memcmp(a->Ssid.ssid, b->Ssid.ssid, a->Ssid.ssid_len); } int is_same_network23a(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst) { - u16 s_cap, d_cap; + u16 s_cap, d_cap; - memcpy((u8 *)&s_cap, rtw_get_capability23a_from_ie(src->IEs), 2); - memcpy((u8 *)&d_cap, rtw_get_capability23a_from_ie(dst->IEs), 2); + memcpy(&s_cap, rtw_get_capability23a_from_ie(src->IEs), 2); + memcpy(&d_cap, rtw_get_capability23a_from_ie(dst->IEs), 2); s_cap = le16_to_cpu(s_cap); d_cap = le16_to_cpu(d_cap); @@ -389,10 +390,10 @@ int is_same_network23a(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst) (d_cap & WLAN_CAPABILITY_ESS))); } -struct wlan_network *rtw_get_oldest_wlan_network23a(struct rtw_queue *scanned_queue) +struct wlan_network * +rtw_get_oldest_wlan_network23a(struct rtw_queue *scanned_queue) { struct list_head *plist, *phead; - struct wlan_network *pwlan; struct wlan_network *oldest = NULL; @@ -412,7 +413,7 @@ struct wlan_network *rtw_get_oldest_wlan_network23a(struct rtw_queue *scanned_qu } void update_network23a(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, - struct rtw_adapter * padapter, bool update_ie) + struct rtw_adapter *padapter, bool update_ie) { u8 ss_ori = dst->PhyInfo.SignalStrength; u8 sq_ori = dst->PhyInfo.SignalQuality; @@ -426,30 +427,35 @@ void update_network23a(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, u8 sq_final; long rssi_final; - DBG_8723A("%s %s(%pM, ch%u) ss_ori:%3u, sq_ori:%3u, rssi_ori:%3ld, ss_smp:%3u, sq_smp:%3u, rssi_smp:%3ld\n", + DBG_8723A("%s %s(%pM, ch%u) ss_ori:%3u, sq_ori:%3u, rssi_ori:%3ld, " + "ss_smp:%3u, sq_smp:%3u, rssi_smp:%3ld\n", __func__, src->Ssid.ssid, src->MacAddress, src->Configuration.DSConfig, ss_ori, sq_ori, rssi_ori, ss_smp, sq_smp, rssi_smp ); /* The rule below is 1/5 for sample value, 4/5 for history value */ - if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) && is_same_network23a(&padapter->mlmepriv.cur_network.network, src)) { + if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) && + is_same_network23a(&padapter->mlmepriv.cur_network.network, src)) { /* Take the recvpriv's value for the connected AP*/ ss_final = padapter->recvpriv.signal_strength; sq_final = padapter->recvpriv.signal_qual; - /* the rssi value here is undecorated, and will be used for antenna diversity */ + /* the rssi value here is undecorated, and will be + used for antenna diversity */ if (sq_smp != 101) /* from the right channel */ rssi_final = (src->Rssi+dst->Rssi*4)/5; else rssi_final = rssi_ori; - } - else { + } else { if (sq_smp != 101) { /* from the right channel */ - ss_final = ((u32)(src->PhyInfo.SignalStrength)+(u32)(dst->PhyInfo.SignalStrength)*4)/5; - sq_final = ((u32)(src->PhyInfo.SignalQuality)+(u32)(dst->PhyInfo.SignalQuality)*4)/5; - rssi_final = (src->Rssi+dst->Rssi*4)/5; + ss_final = ((u32)src->PhyInfo.SignalStrength + + (u32)dst->PhyInfo.SignalStrength * 4) / 5; + sq_final = ((u32)src->PhyInfo.SignalQuality + + (u32)dst->PhyInfo.SignalQuality * 4) / 5; + rssi_final = src->Rssi+dst->Rssi * 4 / 5; } else { - /* bss info not receving from the right channel, use the original RX signal infos */ + /* bss info not receving from the right channel, use + the original RX signal infos */ ss_final = dst->PhyInfo.SignalStrength; sq_final = dst->PhyInfo.SignalQuality; rssi_final = dst->Rssi; @@ -458,35 +464,32 @@ void update_network23a(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, } if (update_ie) - memcpy((u8 *)dst, (u8 *)src, get_wlan_bssid_ex_sz(src)); + memcpy(dst, src, get_wlan_bssid_ex_sz(src)); dst->PhyInfo.SignalStrength = ss_final; dst->PhyInfo.SignalQuality = sq_final; dst->Rssi = rssi_final; - DBG_8723A("%s %s(%pM), SignalStrength:%u, SignalQuality:%u, RawRSSI:%ld\n", - __func__, dst->Ssid.ssid, dst->MacAddress, + DBG_8723A("%s %s(%pM), SignalStrength:%u, SignalQuality:%u, " + "RawRSSI:%ld\n", __func__, dst->Ssid.ssid, dst->MacAddress, dst->PhyInfo.SignalStrength, dst->PhyInfo.SignalQuality, dst->Rssi); - } -static void update_current_network(struct rtw_adapter *adapter, struct wlan_bssid_ex *pnetwork) +static void update_current_network(struct rtw_adapter *adapter, + struct wlan_bssid_ex *pnetwork) { - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - - if ((check_fwstate(pmlmepriv, _FW_LINKED)== true) && (is_same_network23a(&pmlmepriv->cur_network.network, pnetwork))) - { - /* RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,"Same Network\n"); */ + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - /* if(pmlmepriv->cur_network.network.IELength<= pnetwork->IELength) */ - { - update_network23a(&pmlmepriv->cur_network.network, pnetwork,adapter, true); - rtw_update_protection23a(adapter, (pmlmepriv->cur_network.network.IEs) + sizeof (struct ndis_802_11_fixed_ies), - pmlmepriv->cur_network.network.IELength); - } + if (check_fwstate(pmlmepriv, _FW_LINKED) && + is_same_network23a(&pmlmepriv->cur_network.network, pnetwork)) { + update_network23a(&pmlmepriv->cur_network.network, + pnetwork,adapter, true); + rtw_update_protection23a(adapter, + pmlmepriv->cur_network.network.IEs + + sizeof (struct ndis_802_11_fixed_ies), + pmlmepriv->cur_network.network.IELength); } - } /* @@ -494,7 +497,8 @@ static void update_current_network(struct rtw_adapter *adapter, struct wlan_bssi Caller must hold pmlmepriv->lock first. */ -void rtw_update_scanned_network23a(struct rtw_adapter *adapter, struct wlan_bssid_ex *target) +void rtw_update_scanned_network23a(struct rtw_adapter *adapter, + struct wlan_bssid_ex *target) { struct list_head *plist, *phead; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; @@ -561,19 +565,20 @@ void rtw_update_scanned_network23a(struct rtw_adapter *adapter, struct wlan_bssi /* target.reserved == 1, means that scanned network is * a bcn frame. */ - if ((pnetwork->network.IELength>target->IELength) && - (target->reserved == 1)) + if (pnetwork->network.IELength > target->IELength && + target->reserved == 1) update_ie = false; - update_network23a(&pnetwork->network, target,adapter, update_ie); + update_network23a(&pnetwork->network, target,adapter, + update_ie); } exit: spin_unlock_bh(&queue->lock); - } -void rtw_add_network(struct rtw_adapter *adapter, struct wlan_bssid_ex *pnetwork) +void rtw_add_network(struct rtw_adapter *adapter, + struct wlan_bssid_ex *pnetwork) { update_current_network(adapter, pnetwork); rtw_update_scanned_network23a(adapter, pnetwork); @@ -585,7 +590,8 @@ void rtw_add_network(struct rtw_adapter *adapter, struct wlan_bssid_ex *pnetwork /* (3) WMM */ /* (4) HT */ /* (5) others */ -int rtw_is_desired_network(struct rtw_adapter *adapter, struct wlan_network *pnetwork) +int rtw_is_desired_network(struct rtw_adapter *adapter, + struct wlan_network *pnetwork) { struct security_priv *psecuritypriv = &adapter->securitypriv; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; @@ -600,31 +606,31 @@ int rtw_is_desired_network(struct rtw_adapter *adapter, struct wlan_network *pne desired_encmode = psecuritypriv->ndisencryptstatus; privacy = pnetwork->network.Privacy; - if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) - { - if (rtw_get_wps_ie23a(pnetwork->network.IEs+_FIXED_IE_LENGTH_, pnetwork->network.IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen)!= NULL) - { + if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { + if (rtw_get_wps_ie23a(pnetwork->network.IEs + _FIXED_IE_LENGTH_, + pnetwork->network.IELength - + _FIXED_IE_LENGTH_, NULL, &wps_ielen)) return true; - } else - { return false; - } } - if (adapter->registrypriv.wifi_spec == 1) /* for correct flow of 8021X to do.... */ - { - if ((desired_encmode == Ndis802_11EncryptionDisabled) && (privacy != 0)) + if (adapter->registrypriv.wifi_spec == 1) { + /* for correct flow of 8021X to do.... */ + if (desired_encmode == Ndis802_11EncryptionDisabled && + privacy != 0) bselected = false; } - if ((desired_encmode != Ndis802_11EncryptionDisabled) && (privacy == 0)) { - DBG_8723A("desired_encmode: %d, privacy: %d\n", desired_encmode, privacy); + if (desired_encmode != Ndis802_11EncryptionDisabled && + privacy == 0) { + DBG_8723A("desired_encmode: %d, privacy: %d\n", + desired_encmode, privacy); bselected = false; } - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) - { - if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode) + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { + if (pnetwork->network.InfrastructureMode != + pmlmepriv->cur_network.network.InfrastructureMode) bselected = false; } @@ -632,15 +638,14 @@ int rtw_is_desired_network(struct rtw_adapter *adapter, struct wlan_network *pne } /* TODO: Perry : For Power Management */ -void rtw_atimdone_event_callback23a(struct rtw_adapter *adapter , u8 *pbuf) +void rtw_atimdone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) { - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("receive atimdone_evet\n")); return; } -void rtw_survey_event_cb23a(struct rtw_adapter *adapter, u8 *pbuf) +void rtw_survey_event_cb23a(struct rtw_adapter *adapter, u8 *pbuf) { u32 len; struct wlan_bssid_ex *pnetwork; @@ -648,31 +653,36 @@ void rtw_survey_event_cb23a(struct rtw_adapter *adapter, u8 *pbuf) pnetwork = (struct wlan_bssid_ex *)pbuf; - RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("rtw_survey_event_cb23a, ssid=%s\n", pnetwork->Ssid.ssid)); + RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_, + ("rtw_survey_event_cb23a, ssid=%s\n", pnetwork->Ssid.ssid)); len = get_wlan_bssid_ex_sz(pnetwork); - if(len > (sizeof(struct wlan_bssid_ex))) - { - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("\n ****rtw_survey_event_cb23a: return a wrong bss ***\n")); + if (len > (sizeof(struct wlan_bssid_ex))) { + RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_, + ("\n ****rtw_survey_event_cb23a: return a wrong " + "bss ***\n")); return; } spin_lock_bh(&pmlmepriv->lock); /* update IBSS_network 's timestamp */ - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) - { - /* RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,"rtw_survey_event_cb23a : WIFI_ADHOC_MASTER_STATE\n\n"); */ + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { + /* RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + "rtw_survey_event_cb23a : WIFI_ADHOC_MASTER_STATE\n\n"); */ if (ether_addr_equal(pmlmepriv->cur_network.network.MacAddress, pnetwork->MacAddress)) { - struct wlan_network* ibss_wlan = NULL; + struct wlan_network* ibss_wlan; - memcpy(pmlmepriv->cur_network.network.IEs, pnetwork->IEs, 8); + memcpy(pmlmepriv->cur_network.network.IEs, + pnetwork->IEs, 8); spin_lock_bh(&pmlmepriv->scanned_queue.lock); - ibss_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, pnetwork->MacAddress); - if (ibss_wlan) - { - memcpy(ibss_wlan->network.IEs , pnetwork->IEs, 8); + ibss_wlan = rtw_find_network23a( + &pmlmepriv->scanned_queue, + pnetwork->MacAddress); + if (ibss_wlan) { + memcpy(ibss_wlan->network.IEs, + pnetwork->IEs, 8); spin_unlock_bh(&pmlmepriv->scanned_queue.lock); goto exit; } @@ -681,8 +691,7 @@ void rtw_survey_event_cb23a(struct rtw_adapter *adapter, u8 *pbuf) } /* lock pmlmepriv->lock when you accessing network_q */ - if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == false) - { + if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == false) { if (pnetwork->Ssid.ssid[0] == 0) pnetwork->Ssid.ssid_len = 0; @@ -696,10 +705,12 @@ exit: return; } -void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) +void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) { struct mlme_priv *pmlmepriv = &adapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; + struct wlan_bssid_ex *pdev_network; + u8 *pibss; spin_lock_bh(&pmlmepriv->lock); @@ -709,7 +720,9 @@ void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) pmlmepriv->wps_probe_req_ie = NULL; } - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_surveydone_event_callback23a: fw_state:%x\n\n", get_fwstate(pmlmepriv))); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("rtw_surveydone_event_callback23a: fw_state:%x\n\n", + get_fwstate(pmlmepriv))); if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { del_timer_sync(&pmlmepriv->scan_to_timer); @@ -717,39 +730,53 @@ void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); } else { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("nic status =%x, survey done event comes too late!\n", get_fwstate(pmlmepriv))); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("nic status =%x, survey done event comes too late!\n", + get_fwstate(pmlmepriv))); } rtw_set_signal_stat_timer(&adapter->recvpriv); if (pmlmepriv->to_join == true) { - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { if (check_fwstate(pmlmepriv, _FW_LINKED) == false) { set_fwstate(pmlmepriv, _FW_UNDER_LINKING); - if (rtw_select_and_join_from_scanned_queue23a(pmlmepriv) == _SUCCESS) { + if (rtw_select_and_join_from_scanned_queue23a( + pmlmepriv) == _SUCCESS) { mod_timer(&pmlmepriv->assoc_timer, jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT)); } else { - struct wlan_bssid_ex *pdev_network = &adapter->registrypriv.dev_network; - u8 *pibss = adapter->registrypriv.dev_network.MacAddress; + pdev_network = &adapter->registrypriv.dev_network; + pibss = adapter->registrypriv.dev_network.MacAddress; - _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); + _clr_fwstate_(pmlmepriv, + _FW_UNDER_SURVEY); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("switching to adhoc master\n")); + RT_TRACE(_module_rtl871x_mlme_c_, + _drv_err_, + ("switching to adhoc " + "master\n")); - memset(&pdev_network->Ssid, 0, sizeof(struct cfg80211_ssid)); - memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct cfg80211_ssid)); + memset(&pdev_network->Ssid, 0, + sizeof(struct cfg80211_ssid)); + memcpy(&pdev_network->Ssid, + &pmlmepriv->assoc_ssid, + sizeof(struct cfg80211_ssid)); - rtw_update_registrypriv_dev_network23a(adapter); + rtw_update_registrypriv_dev_network23a( + adapter); rtw_generate_random_ibss23a(pibss); - pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE; + pmlmepriv->fw_state = + WIFI_ADHOC_MASTER_STATE; - if (rtw_createbss_cmd23a(adapter)!= _SUCCESS) - { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error =>rtw_createbss_cmd23a status FAIL\n")); - } + if (rtw_createbss_cmd23a(adapter) != + _SUCCESS) + RT_TRACE(_module_rtl871x_mlme_c_, + _drv_err_, + ("Error =>rtw_createbss_cmd23a" + " status FAIL\n")); pmlmepriv->to_join = false; } @@ -758,27 +785,32 @@ void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) int ret; set_fwstate(pmlmepriv, _FW_UNDER_LINKING); pmlmepriv->to_join = false; - ret = rtw_select_and_join_from_scanned_queue23a(pmlmepriv); + ret = rtw_select_and_join_from_scanned_queue23a( + pmlmepriv); if (ret == _SUCCESS) { unsigned long e; e = msecs_to_jiffies(MAX_JOIN_TIMEOUT); mod_timer(&pmlmepriv->assoc_timer, jiffies + e); - } else if (ret == 2)/* there is no need to wait for join */ - { + } else if (ret == 2) {/* there is no need to wait */ _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); rtw_indicate_connect23a(adapter); } else { - DBG_8723A("try_to_join, but select scanning queue fail, to_roaming:%d\n", rtw_to_roaming(adapter)); + DBG_8723A("try_to_join, but select scanning " + "queue fail, to_roaming:%d\n", + rtw_to_roaming(adapter)); if (rtw_to_roaming(adapter) != 0) { - if (--pmlmepriv->to_roaming == 0 - || _SUCCESS != rtw_sitesurvey_cmd23a(adapter, &pmlmepriv->assoc_ssid, 1, NULL, 0) - ) { + if (--pmlmepriv->to_roaming == 0 || + rtw_sitesurvey_cmd23a( + adapter, + &pmlmepriv->assoc_ssid, 1, + NULL, 0) != _SUCCESS) { rtw_set_roaming(adapter, 0); - rtw_free_assoc_resources23a(adapter, 1); - rtw_indicate_disconnect23a(adapter); - } else { + rtw_free_assoc_resources23a( + adapter, 1); + rtw_indicate_disconnect23a( + adapter); + } else pmlmepriv->to_join = true; - } } _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); } @@ -789,11 +821,10 @@ void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) rtw_os_xmit_schedule23a(adapter); - if(pmlmeext->sitesurvey_res.bss_cnt == 0) + if (pmlmeext->sitesurvey_res.bss_cnt == 0) rtw_hal_sreset_reset23a(adapter); rtw_cfg80211_surveydone_event_callback(adapter); - } void rtw_dummy_event_callback23a(struct rtw_adapter *adapter , u8 *pbuf) @@ -804,7 +835,7 @@ void rtw23a_fwdbg_event_callback(struct rtw_adapter *adapter , u8 *pbuf) { } -static void free_scanqueue(struct mlme_priv *pmlmepriv) +static void free_scanqueue(struct mlme_priv *pmlmepriv) { struct wlan_network *pnetwork; struct rtw_queue *scan_queue = &pmlmepriv->scanned_queue; @@ -822,42 +853,38 @@ static void free_scanqueue(struct mlme_priv *pmlmepriv) } spin_unlock_bh(&scan_queue->lock); - } /* -*rtw_free_assoc_resources23a: the caller has to lock pmlmepriv->lock -*/ -void rtw_free_assoc_resources23a(struct rtw_adapter *adapter, int lock_scanned_queue) + *rtw_free_assoc_resources23a: the caller has to lock pmlmepriv->lock + */ +void rtw_free_assoc_resources23a(struct rtw_adapter *adapter, + int lock_scanned_queue) { - struct wlan_network* pwlan = NULL; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - struct sta_priv *pstapriv = &adapter->stapriv; + struct wlan_network* pwlan; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct sta_priv *pstapriv = &adapter->stapriv; struct wlan_network *tgt_network = &pmlmepriv->cur_network; + struct sta_info* psta; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+rtw_free_assoc_resources23a\n")); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("tgt_network->network.MacAddress="MAC_FMT" ssid=%s\n", - MAC_ARG(tgt_network->network.MacAddress), tgt_network->network.Ssid.ssid)); - - if(check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_AP_STATE)) - { - struct sta_info* psta; - - psta = rtw_get_stainfo23a(&adapter->stapriv, tgt_network->network.MacAddress); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, + ("+rtw_free_assoc_resources23a\n")); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("tgt_network->network.MacAddress="MAC_FMT" ssid=%s\n", + MAC_ARG(tgt_network->network.MacAddress), + tgt_network->network.Ssid.ssid)); - { - spin_lock_bh(&pstapriv->sta_hash_lock); - rtw_free_stainfo23a(adapter, psta); - } + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_AP_STATE)) { + psta = rtw_get_stainfo23a(&adapter->stapriv, + tgt_network->network.MacAddress); + spin_lock_bh(&pstapriv->sta_hash_lock); + rtw_free_stainfo23a(adapter, psta); spin_unlock_bh(&pstapriv->sta_hash_lock); - } - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE)) - { - struct sta_info* psta; - + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE | + WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE)) { rtw_free_all_stainfo23a(adapter); psta = rtw_get_bcmc_stainfo23a(adapter); @@ -868,23 +895,25 @@ void rtw_free_assoc_resources23a(struct rtw_adapter *adapter, int lock_scanned_q rtw_init_bcmc_stainfo23a(adapter); } - if(lock_scanned_queue) + if (lock_scanned_queue) spin_lock_bh(&pmlmepriv->scanned_queue.lock); - pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); - if(pwlan) + pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue, + tgt_network->network.MacAddress); + if (pwlan) pwlan->fixed = false; else - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("rtw_free_assoc_resources23a : pwlan== NULL\n\n")); + RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_, + ("rtw_free_assoc_resources23a : pwlan== NULL\n")); - if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) && (adapter->stapriv.asoc_sta_count == 1)) + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) && + adapter->stapriv.asoc_sta_count == 1) rtw_free_network_nolock(pmlmepriv, pwlan); - if(lock_scanned_queue) + if (lock_scanned_queue) spin_unlock_bh(&pmlmepriv->scanned_queue.lock); pmlmepriv->key_mask = 0; - } /* @@ -892,13 +921,14 @@ void rtw_free_assoc_resources23a(struct rtw_adapter *adapter, int lock_scanned_q */ void rtw_indicate_connect23a(struct rtw_adapter *padapter) { - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_indicate_connect23a\n")); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("+rtw_indicate_connect23a\n")); pmlmepriv->to_join = false; - if(!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { + if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { set_fwstate(pmlmepriv, _FW_LINKED); rtw_led_control(padapter, LED_CTL_LINK); @@ -915,18 +945,20 @@ void rtw_indicate_connect23a(struct rtw_adapter *padapter) rtw_set_scan_deny(padapter, 3000); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("-rtw_indicate_connect23a: fw_state=0x%08x\n", get_fwstate(pmlmepriv))); - + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("-rtw_indicate_connect23a: fw_state=0x%08x\n", + get_fwstate(pmlmepriv))); } /* -*rtw_indicate_disconnect23a: the caller has to lock pmlmepriv->lock -*/ + *rtw_indicate_disconnect23a: the caller has to lock pmlmepriv->lock + */ void rtw_indicate_disconnect23a(struct rtw_adapter *padapter) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_indicate_disconnect23a\n")); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("+rtw_indicate_disconnect23a\n")); _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING|WIFI_UNDER_WPS); @@ -936,7 +968,7 @@ void rtw_indicate_disconnect23a(struct rtw_adapter *padapter) _clr_fwstate_(pmlmepriv, _FW_LINKED); if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) || - (rtw_to_roaming(padapter) <= 0)) { + rtw_to_roaming(padapter) <= 0) { rtw_os_indicate_disconnect23a(padapter); /* set ips_deny_time to avoid enter IPS before LPS leave */ @@ -952,7 +984,6 @@ void rtw_indicate_disconnect23a(struct rtw_adapter *padapter) } rtw_lps_ctrl_wk_cmd23a(padapter, LPS_CTRL_DISCONNECT, 1); - } void rtw_scan_abort23a(struct rtw_adapter *adapter) @@ -965,37 +996,39 @@ void rtw_scan_abort23a(struct rtw_adapter *adapter) pmlmeext->scan_abort = true; while (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) && jiffies_to_msecs(jiffies - start) <= 200) { - if (adapter->bDriverStopped || adapter->bSurpriseRemoved) break; - DBG_8723A(FUNC_NDEV_FMT"fw_state = _FW_UNDER_SURVEY!\n", FUNC_NDEV_ARG(adapter->pnetdev)); + DBG_8723A(FUNC_NDEV_FMT "fw_state = _FW_UNDER_SURVEY!\n", + FUNC_NDEV_ARG(adapter->pnetdev)); msleep(20); } if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { if (!adapter->bDriverStopped && !adapter->bSurpriseRemoved) - DBG_8723A(FUNC_NDEV_FMT"waiting for scan_abort time out!\n", FUNC_NDEV_ARG(adapter->pnetdev)); + DBG_8723A(FUNC_NDEV_FMT "waiting for scan_abort time " + "out!\n", FUNC_NDEV_ARG(adapter->pnetdev)); rtw_cfg80211_indicate_scan_done(wdev_to_priv(adapter->rtw_wdev), true); } pmlmeext->scan_abort = false; } -static struct sta_info *rtw_joinbss_update_stainfo(struct rtw_adapter *padapter, struct wlan_network *pnetwork) +static struct sta_info * +rtw_joinbss_update_stainfo(struct rtw_adapter *padapter, + struct wlan_network *pnetwork) { int i; - struct sta_info *bmc_sta, *psta = NULL; + struct sta_info *bmc_sta, *psta; struct recv_reorder_ctrl *preorder_ctrl; struct sta_priv *pstapriv = &padapter->stapriv; psta = rtw_get_stainfo23a(pstapriv, pnetwork->network.MacAddress); - if (psta == NULL) { - psta = rtw_alloc_stainfo23a(pstapriv, pnetwork->network.MacAddress); - } + if (!psta) + psta = rtw_alloc_stainfo23a(pstapriv, + pnetwork->network.MacAddress); - if (psta) /* update ptarget_sta */ - { + if (psta) { /* update ptarget_sta */ DBG_8723A("%s\n", __func__); psta->aid = pnetwork->join_res; @@ -1005,57 +1038,63 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct rtw_adapter *padapter, rtw_hal_set_odm_var23a(padapter, HAL_ODM_STA_INFO, psta, true); /* security related */ - if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) - { + if (padapter->securitypriv.dot11AuthAlgrthm == + dot11AuthAlgrthm_8021X) { padapter->securitypriv.binstallGrpkey = false; padapter->securitypriv.busetkipkey = false; padapter->securitypriv.bgrpkey_handshake = false; psta->ieee8021x_blocked = true; - psta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm; + psta->dot118021XPrivacy = + padapter->securitypriv.dot11PrivacyAlgrthm; - memset((u8 *)&psta->dot118021x_UncstKey, 0, sizeof (union Keytype)); + memset(&psta->dot118021x_UncstKey, 0, + sizeof (union Keytype)); - memset((u8 *)&psta->dot11tkiprxmickey, 0, sizeof (union Keytype)); - memset((u8 *)&psta->dot11tkiptxmickey, 0, sizeof (union Keytype)); + memset(&psta->dot11tkiprxmickey, 0, + sizeof (union Keytype)); + memset(&psta->dot11tkiptxmickey, 0, + sizeof (union Keytype)); - memset((u8 *)&psta->dot11txpn, 0, sizeof (union pn48)); - memset((u8 *)&psta->dot11rxpn, 0, sizeof (union pn48)); + memset(&psta->dot11txpn, 0, sizeof (union pn48)); + memset(&psta->dot11rxpn, 0, sizeof (union pn48)); } /* Commented by Albert 2012/07/21 */ /* When doing the WPS, the wps_ie_len won't equal to 0 */ - /* And the Wi-Fi driver shouldn't allow the data packet to be tramsmitted. */ - if (padapter->securitypriv.wps_ie_len != 0) - { + /* And the Wi-Fi driver shouldn't allow the data packet + to be tramsmitted. */ + if (padapter->securitypriv.wps_ie_len != 0) { psta->ieee8021x_blocked = true; padapter->securitypriv.wps_ie_len = 0; } - /* for A-MPDU Rx reordering buffer control for bmc_sta & sta_info */ - /* if A-MPDU Rx is enabled, reseting rx_ordering_ctrl wstart_b(indicate_seq) to default value = 0xffff */ + /* for A-MPDU Rx reordering buffer control for bmc_sta & + * sta_info */ + /* if A-MPDU Rx is enabled, reseting + rx_ordering_ctrl wstart_b(indicate_seq) to default + value = 0xffff */ /* todo: check if AP can send A-MPDU packets */ - for (i = 0; i < 16 ; i++) - { + for (i = 0; i < 16 ; i++) { /* preorder_ctrl = &precvpriv->recvreorder_ctrl[i]; */ preorder_ctrl = &psta->recvreorder_ctrl[i]; preorder_ctrl->enable = false; preorder_ctrl->indicate_seq = 0xffff; preorder_ctrl->wend_b = 0xffff; - preorder_ctrl->wsize_b = 64;/* max_ampdu_sz; ex. 32(kbytes) -> wsize_b = 32 */ + /* max_ampdu_sz; ex. 32(kbytes) -> wsize_b = 32 */ + preorder_ctrl->wsize_b = 64; } bmc_sta = rtw_get_bcmc_stainfo23a(padapter); - if (bmc_sta) - { - for (i = 0; i < 16 ; i++) - { - /* preorder_ctrl = &precvpriv->recvreorder_ctrl[i]; */ + if (bmc_sta) { + for (i = 0; i < 16 ; i++) { preorder_ctrl = &bmc_sta->recvreorder_ctrl[i]; preorder_ctrl->enable = false; preorder_ctrl->indicate_seq = 0xffff; preorder_ctrl->wend_b = 0xffff; - preorder_ctrl->wsize_b = 64;/* max_ampdu_sz; ex. 32(kbytes) -> wsize_b = 32 */ + /* max_ampdu_sz; ex. 32(kbytes) -> + wsize_b = 32 */ + preorder_ctrl->wsize_b = 64; } } @@ -1069,29 +1108,41 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct rtw_adapter *padapter, /* pnetwork : returns from rtw23a_joinbss_event_cb */ /* ptarget_wlan: found from scanned_queue */ -static void rtw_joinbss_update_network23a(struct rtw_adapter *padapter, struct wlan_network *ptarget_wlan, struct wlan_network *pnetwork) +static void +rtw_joinbss_update_network23a(struct rtw_adapter *padapter, + struct wlan_network *ptarget_wlan, + struct wlan_network *pnetwork) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_network *cur_network = &pmlmepriv->cur_network; DBG_8723A("%s\n", __func__); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\nfw_state:%x, BSSID:"MAC_FMT"\n" - , get_fwstate(pmlmepriv), MAC_ARG(pnetwork->network.MacAddress))); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("\nfw_state:%x, BSSID:"MAC_FMT"\n", get_fwstate(pmlmepriv), + MAC_ARG(pnetwork->network.MacAddress))); /* why not use ptarget_wlan?? */ - memcpy(&cur_network->network, &pnetwork->network, pnetwork->network.Length); + memcpy(&cur_network->network, &pnetwork->network, + pnetwork->network.Length); /* some IEs in pnetwork is wrong, so we should use ptarget_wlan IEs */ cur_network->network.IELength = ptarget_wlan->network.IELength; - memcpy(&cur_network->network.IEs[0], &ptarget_wlan->network.IEs[0], MAX_IE_SZ); + memcpy(&cur_network->network.IEs[0], &ptarget_wlan->network.IEs[0], + MAX_IE_SZ); cur_network->aid = pnetwork->join_res; rtw_set_signal_stat_timer(&padapter->recvpriv); - padapter->recvpriv.signal_strength = ptarget_wlan->network.PhyInfo.SignalStrength; - padapter->recvpriv.signal_qual = ptarget_wlan->network.PhyInfo.SignalQuality; - /* the ptarget_wlan->network.Rssi is raw data, we use ptarget_wlan->network.PhyInfo.SignalStrength instead (has scaled) */ - padapter->recvpriv.rssi = translate_percentage_to_dbm(ptarget_wlan->network.PhyInfo.SignalStrength); + padapter->recvpriv.signal_strength = + ptarget_wlan->network.PhyInfo.SignalStrength; + padapter->recvpriv.signal_qual = + ptarget_wlan->network.PhyInfo.SignalQuality; + /* + * the ptarget_wlan->network.Rssi is raw data, we use + * ptarget_wlan->network.PhyInfo.SignalStrength instead (has scaled) + */ + padapter->recvpriv.rssi = translate_percentage_to_dbm( + ptarget_wlan->network.PhyInfo.SignalStrength); DBG_8723A("%s signal_strength:%3u, rssi:%3d, signal_qual:%3u\n", __func__, padapter->recvpriv.signal_strength, padapter->recvpriv.rssi, padapter->recvpriv.signal_qual); @@ -1110,40 +1161,51 @@ static void rtw_joinbss_update_network23a(struct rtw_adapter *padapter, struct w break; default: pmlmepriv->fw_state = WIFI_NULL_STATE; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Invalid network_mode\n")); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("Invalid network_mode\n")); break; } - rtw_update_protection23a(padapter, (cur_network->network.IEs) + sizeof (struct ndis_802_11_fixed_ies), - (cur_network->network.IELength)); + rtw_update_protection23a(padapter, cur_network->network.IEs + + sizeof (struct ndis_802_11_fixed_ies), + cur_network->network.IELength); - rtw_update_ht_cap23a(padapter, cur_network->network.IEs, cur_network->network.IELength); + rtw_update_ht_cap23a(padapter, cur_network->network.IEs, + cur_network->network.IELength); } -/* Notes: the fucntion could be > passive_level (the same context as Rx tasklet) */ -/* pnetwork : returns from rtw23a_joinbss_event_cb */ -/* ptarget_wlan: found from scanned_queue */ -/* if join_res > 0, for (fw_state==WIFI_STATION_STATE), we check if "ptarget_sta" & "ptarget_wlan" exist. */ -/* if join_res > 0, for (fw_state==WIFI_ADHOC_STATE), we only check if "ptarget_wlan" exist. */ -/* if join_res > 0, update "cur_network->network" from "pnetwork->network" if (ptarget_wlan !=NULL). */ +/* + * Notes: + * the fucntion could be > passive_level (the same context as Rx tasklet) + * pnetwork : returns from rtw23a_joinbss_event_cb + * ptarget_wlan: found from scanned_queue + * if join_res > 0, for (fw_state==WIFI_STATION_STATE), + * we check if "ptarget_sta" & "ptarget_wlan" exist. + * if join_res > 0, for (fw_state==WIFI_ADHOC_STATE), + * we only check if "ptarget_wlan" exist. + * if join_res > 0, update "cur_network->network" from "pnetwork->network" + * if (ptarget_wlan !=NULL). + */ void rtw_joinbss_event_prehandle23a(struct rtw_adapter *adapter, u8 *pbuf) { - static u8 retry=0; - struct sta_info *ptarget_sta= NULL, *pcur_sta = NULL; - struct sta_priv *pstapriv = &adapter->stapriv; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - struct wlan_network *pnetwork = (struct wlan_network *)pbuf; + struct sta_info *ptarget_sta, *pcur_sta; + struct sta_priv *pstapriv = &adapter->stapriv; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct wlan_network *pnetwork = (struct wlan_network *)pbuf; struct wlan_network *cur_network = &pmlmepriv->cur_network; - struct wlan_network *pcur_wlan = NULL, *ptarget_wlan = NULL; - unsigned int the_same_macaddr = false; + struct wlan_network *pcur_wlan, *ptarget_wlan = NULL; + bool the_same_macaddr; - RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("joinbss event call back received with res=%d\n", pnetwork->join_res)); + RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_, + ("joinbss event call back received with res=%d\n", + pnetwork->join_res)); rtw_get_encrypt_decrypt_from_registrypriv23a(adapter); if (pmlmepriv->assoc_ssid.ssid_len == 0) { - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("@@@@@ joinbss event call back for Any SSid\n")); + RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_, + ("@@@@@ joinbss event call back for Any SSid\n")); } else { RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_, ("@@@@@ rtw23a_joinbss_event_cb for SSid:%s\n", @@ -1157,93 +1219,102 @@ void rtw_joinbss_event_prehandle23a(struct rtw_adapter *adapter, u8 *pbuf) the_same_macaddr = false; pnetwork->network.Length = get_wlan_bssid_ex_sz(&pnetwork->network); - if(pnetwork->network.Length > sizeof(struct wlan_bssid_ex)) - { - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("\n\n ***joinbss_evt_callback return a wrong bss ***\n\n")); + if (pnetwork->network.Length > sizeof(struct wlan_bssid_ex)) { + RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_, + ("\n\n ***joinbss_evt_callback return a wrong bss " + "***\n\n")); return; } spin_lock_bh(&pmlmepriv->lock); - RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("\n rtw23a_joinbss_event_cb !! _enter_critical\n")); + RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_, + ("\n rtw23a_joinbss_event_cb !! _enter_critical\n")); - if(pnetwork->join_res > 0) - { + if (pnetwork->join_res > 0) { spin_lock_bh(&pmlmepriv->scanned_queue.lock); - retry = 0; - if (check_fwstate(pmlmepriv,_FW_UNDER_LINKING)) - { + if (check_fwstate(pmlmepriv,_FW_UNDER_LINKING)) { /* s1. find ptarget_wlan */ - if(check_fwstate(pmlmepriv, _FW_LINKED)) - { - if(the_same_macaddr == true) - { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + if (the_same_macaddr == true) { ptarget_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); - } - else - { + } else { pcur_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); - if(pcur_wlan) pcur_wlan->fixed = false; + if (pcur_wlan) + pcur_wlan->fixed = false; pcur_sta = rtw_get_stainfo23a(pstapriv, cur_network->network.MacAddress); - if(pcur_sta) { + if (pcur_sta) { spin_lock_bh(&pstapriv->sta_hash_lock); - rtw_free_stainfo23a(adapter, pcur_sta); + rtw_free_stainfo23a(adapter, + pcur_sta); spin_unlock_bh(&pstapriv->sta_hash_lock); } ptarget_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, pnetwork->network.MacAddress); - if(check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { - if(ptarget_wlan) ptarget_wlan->fixed = true; + if (check_fwstate(pmlmepriv, + WIFI_STATION_STATE)) { + if (ptarget_wlan) + ptarget_wlan->fixed = + true; } } - } - else - { - ptarget_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, pnetwork->network.MacAddress); - if(check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { - if(ptarget_wlan) ptarget_wlan->fixed = true; + } else { + ptarget_wlan = rtw_find_network23a( + &pmlmepriv->scanned_queue, + pnetwork->network.MacAddress); + if (check_fwstate(pmlmepriv, + WIFI_STATION_STATE)) { + if (ptarget_wlan) + ptarget_wlan->fixed = true; } } /* s2. update cur_network */ - if(ptarget_wlan) - { - rtw_joinbss_update_network23a(adapter, ptarget_wlan, pnetwork); - } - else - { - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("Can't find ptarget_wlan when joinbss_event callback\n")); + if (ptarget_wlan) + rtw_joinbss_update_network23a(adapter, + ptarget_wlan, + pnetwork); + else { + RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_, + ("Can't find ptarget_wlan when " + "joinbss_event callback\n")); spin_unlock_bh(&pmlmepriv->scanned_queue.lock); goto ignore_joinbss_callback; } - /* s3. find ptarget_sta & update ptarget_sta after update cur_network only for station mode */ - if(check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) - { - ptarget_sta = rtw_joinbss_update_stainfo(adapter, pnetwork); - if(ptarget_sta==NULL) - { - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("Can't update stainfo when joinbss_event callback\n")); + /* s3. find ptarget_sta & update ptarget_sta after + update cur_network only for station mode */ + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { + ptarget_sta = rtw_joinbss_update_stainfo( + adapter, pnetwork); + if (!ptarget_sta) { + RT_TRACE(_module_rtl871x_mlme_c_, + _drv_err_, + ("Can't update stainfo when " + "joinbss_event callback\n")); spin_unlock_bh(&pmlmepriv->scanned_queue.lock); goto ignore_joinbss_callback; } } /* s4. indicate connect */ - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) - { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) rtw_indicate_connect23a(adapter); - } else { - /* adhoc mode will rtw_indicate_connect23a when rtw_stassoc_event_callback23a */ - RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("adhoc mode, fw_state:%x", get_fwstate(pmlmepriv))); + else { + /* adhoc mode will rtw_indicate_connect23a + when rtw_stassoc_event_callback23a */ + RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_, + ("adhoc mode, fw_state:%x", + get_fwstate(pmlmepriv))); } /* s5. Cancle assoc_timer */ del_timer_sync(&pmlmepriv->assoc_timer); - RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("Cancle assoc_timer\n")); + RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_, + ("Cancle assoc_timer\n")); } else { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw23a_joinbss_event_cb err: fw_state:%x", @@ -1252,20 +1323,19 @@ void rtw_joinbss_event_prehandle23a(struct rtw_adapter *adapter, u8 *pbuf) goto ignore_joinbss_callback; } spin_unlock_bh(&pmlmepriv->scanned_queue.lock); - } else if(pnetwork->join_res == -4) { + } else if (pnetwork->join_res == -4) { rtw_reset_securitypriv23a(adapter); mod_timer(&pmlmepriv->assoc_timer, jiffies + msecs_to_jiffies(1)); /* rtw_free_assoc_resources23a(adapter, 1); */ - if((check_fwstate(pmlmepriv, _FW_UNDER_LINKING))) { + if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, - ("fail! clear _FW_UNDER_LINKING ^^^fw_state=%x\n", - get_fwstate(pmlmepriv))); + ("fail! clear _FW_UNDER_LINKING ^^^fw_state=" + "%x\n", get_fwstate(pmlmepriv))); _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); } - } else { /* if join_res < 0 (join fails), then try again */ mod_timer(&pmlmepriv->assoc_timer, @@ -1280,28 +1350,26 @@ ignore_joinbss_callback: void rtw23a_joinbss_event_cb(struct rtw_adapter *adapter, u8 *pbuf) { - struct wlan_network *pnetwork = (struct wlan_network *)pbuf; + struct wlan_network *pnetwork = (struct wlan_network *)pbuf; mlmeext_joinbss_event_callback23a(adapter, pnetwork->join_res); rtw_os_xmit_schedule23a(adapter); - } void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) { struct sta_info *psta; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - struct stassoc_event *pstassoc = (struct stassoc_event*)pbuf; + struct stassoc_event *pstassoc = (struct stassoc_event*)pbuf; struct wlan_network *cur_network = &pmlmepriv->cur_network; - struct wlan_network *ptarget_wlan = NULL; + struct wlan_network *ptarget_wlan; - if(rtw_access_ctrl23a(adapter, pstassoc->macaddr) == false) + if (rtw_access_ctrl23a(adapter, pstassoc->macaddr) == false) return; #ifdef CONFIG_8723AU_AP_MODE - if(check_fwstate(pmlmepriv, WIFI_AP_STATE)) - { + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { psta = rtw_get_stainfo23a(&adapter->stapriv, pstassoc->macaddr); if (psta) { /* bss_cap_update_on_sta_join23a(adapter, psta); */ @@ -1315,13 +1383,19 @@ void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) psta = rtw_get_stainfo23a(&adapter->stapriv, pstassoc->macaddr); if (psta != NULL) { /* the sta have been in sta_info_queue => do nothing */ - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("Error: rtw_stassoc_event_callback23a: sta has been in sta_hash_queue\n")); - return; /* between drv has received this event before and fw have not yet to set key to CAM_ENTRY) */ + RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_, + ("Error: rtw_stassoc_event_callback23a: sta has " + "been in sta_hash_queue\n")); + /* between drv has received this event before and + fw have not yet to set key to CAM_ENTRY) */ + return; } psta = rtw_alloc_stainfo23a(&adapter->stapriv, pstassoc->macaddr); - if (psta == NULL) { - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("Can't alloc sta_info when rtw_stassoc_event_callback23a\n")); + if (!psta) { + RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_, + ("Can't alloc sta_info when " + "rtw_stassoc_event_callback23a\n")); return; } @@ -1331,23 +1405,25 @@ void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) /* psta->aid = (uint)pstassoc->cam_id; */ DBG_8723A("%s\n",__func__); /* for ad-hoc mode */ - rtw_hal_set_odm_var23a(adapter,HAL_ODM_STA_INFO,psta,true); + rtw_hal_set_odm_var23a(adapter, HAL_ODM_STA_INFO, psta, true); - if(adapter->securitypriv.dot11AuthAlgrthm==dot11AuthAlgrthm_8021X) - psta->dot118021XPrivacy = adapter->securitypriv.dot11PrivacyAlgrthm; + if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) + psta->dot118021XPrivacy = + adapter->securitypriv.dot11PrivacyAlgrthm; psta->ieee8021x_blocked = false; spin_lock_bh(&pmlmepriv->lock); - if ( (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)==true ) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)==true ) ) - { - if(adapter->stapriv.asoc_sta_count== 2) - { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { + if (adapter->stapriv.asoc_sta_count == 2) { spin_lock_bh(&pmlmepriv->scanned_queue.lock); - ptarget_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); - if(ptarget_wlan) ptarget_wlan->fixed = true; + ptarget_wlan = + rtw_find_network23a(&pmlmepriv->scanned_queue, + cur_network->network.MacAddress); + if (ptarget_wlan) + ptarget_wlan->fixed = true; spin_unlock_bh(&pmlmepriv->scanned_queue.lock); /* a sta + bc/mc_stainfo (not Ibss_stainfo) */ rtw_indicate_connect23a(adapter); @@ -1361,40 +1437,40 @@ void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) { - int mac_id=-1; + int mac_id; struct sta_info *psta; - struct wlan_network* pwlan = NULL; - struct wlan_bssid_ex *pdev_network=NULL; - u8* pibss = NULL; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - struct stadel_event *pstadel = (struct stadel_event*)pbuf; - struct sta_priv *pstapriv = &adapter->stapriv; + struct wlan_network* pwlan; + struct wlan_bssid_ex *pdev_network; + u8 *pibss; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct stadel_event *pstadel = (struct stadel_event *)pbuf; + struct sta_priv *pstapriv = &adapter->stapriv; struct wlan_network *tgt_network = &pmlmepriv->cur_network; psta = rtw_get_stainfo23a(&adapter->stapriv, pstadel->macaddr); - if(psta) + if (psta) mac_id = psta->mac_id; else mac_id = pstadel->mac_id; - DBG_8723A("%s(mac_id=%d)=" MAC_FMT "\n", __func__, mac_id, MAC_ARG(pstadel->macaddr)); + DBG_8723A("%s(mac_id=%d)=" MAC_FMT "\n", __func__, mac_id, + MAC_ARG(pstadel->macaddr)); if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) - { return; - } mlmeext_sta_del_event_callback23a(adapter); spin_lock_bh(&pmlmepriv->lock); - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) - { - if (rtw_to_roaming(adapter) > 0) - pmlmepriv->to_roaming--; /* this stadel_event is caused by roaming, decrease to_roaming */ - else if (rtw_to_roaming(adapter) == 0) + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { + if (rtw_to_roaming(adapter) > 0) { + /* this stadel_event is caused by roaming, + decrease to_roaming */ + pmlmepriv->to_roaming--; + } else if (rtw_to_roaming(adapter) == 0) rtw_set_roaming(adapter, adapter->registrypriv.max_roaming_times); - if (*((unsigned short *)(pstadel->rsvd)) != WLAN_REASON_EXPIRATION_CHK) + if (*((u16 *)pstadel->rsvd) != WLAN_REASON_EXPIRATION_CHK) rtw_set_roaming(adapter, 0); /* don't roam */ rtw_free_uc_swdec_pending_queue23a(adapter); @@ -1403,7 +1479,8 @@ void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) rtw_indicate_disconnect23a(adapter); spin_lock_bh(&pmlmepriv->scanned_queue.lock); /* remove the network entry in scanned_queue */ - pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); + pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue, + tgt_network->network.MacAddress); if (pwlan) { pwlan->fixed = false; rtw_free_network_nolock(pmlmepriv, pwlan); @@ -1414,21 +1491,21 @@ void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) } if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || - check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) - { + check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { spin_lock_bh(&pstapriv->sta_hash_lock); rtw_free_stainfo23a(adapter, psta); spin_unlock_bh(&pstapriv->sta_hash_lock); - if (adapter->stapriv.asoc_sta_count == 1) /* a sta + bc/mc_stainfo (not Ibss_stainfo) */ - { + /* a sta + bc/mc_stainfo (not Ibss_stainfo) */ + if (adapter->stapriv.asoc_sta_count == 1) { spin_lock_bh(&pmlmepriv->scanned_queue.lock); /* free old ibss network */ - /* pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue, pstadel->macaddr); */ - pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); - if (pwlan) - { + /* pwlan = rtw_find_network23a( + &pmlmepriv->scanned_queue, pstadel->macaddr); */ + pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue, + tgt_network->network.MacAddress); + if (pwlan) { pwlan->fixed = false; rtw_free_network_nolock(pmlmepriv, pwlan); } @@ -1437,7 +1514,8 @@ void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) pdev_network = &adapter->registrypriv.dev_network; pibss = adapter->registrypriv.dev_network.MacAddress; - memcpy(pdev_network, &tgt_network->network, get_wlan_bssid_ex_sz(&tgt_network->network)); + memcpy(pdev_network, &tgt_network->network, + get_wlan_bssid_ex_sz(&tgt_network->network)); memset(&pdev_network->Ssid, 0, sizeof(struct cfg80211_ssid)); @@ -1448,32 +1526,28 @@ void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) rtw_generate_random_ibss23a(pibss); - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) - { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { set_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE); _clr_fwstate_(pmlmepriv, WIFI_ADHOC_STATE); } - if (rtw_createbss_cmd23a(adapter)!= _SUCCESS) - { - - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("***Error =>stadel_event_callback: rtw_createbss_cmd23a status FAIL***\n ")); - + if (rtw_createbss_cmd23a(adapter) != _SUCCESS) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, + _drv_err_, + ("***Error =>stadel_event_callback: " + "rtw_createbss_cmd23a status " + "FAIL***\n")); } - } - } spin_unlock_bh(&pmlmepriv->lock); - } void rtw_cpwm_event_callback23a(struct rtw_adapter *padapter, u8 *pbuf) { - - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("+rtw_cpwm_event_callback23a !!!\n")); - + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("+rtw_cpwm_event_callback23a !!!\n")); } /* @@ -1488,23 +1562,26 @@ void rtw23a_join_to_handler (unsigned long data) DBG_8723A("%s, fw_state=%x\n", __func__, get_fwstate(pmlmepriv)); - if(adapter->bDriverStopped ||adapter->bSurpriseRemoved) + if (adapter->bDriverStopped ||adapter->bSurpriseRemoved) return; spin_lock_bh(&pmlmepriv->lock); if (rtw_to_roaming(adapter) > 0) { /* join timeout caused by roaming */ - while(1) { + while (1) { pmlmepriv->to_roaming--; if (rtw_to_roaming(adapter) != 0) { /* try another */ DBG_8723A("%s try another roaming\n", __func__); - if (_SUCCESS!= (do_join_r = rtw_do_join23a(adapter))) { - DBG_8723A("%s roaming do_join return %d\n", __func__ , do_join_r); + do_join_r = rtw_do_join23a(adapter); + if (do_join_r != _SUCCESS) { + DBG_8723A("%s roaming do_join return " + "%d\n", __func__ , do_join_r); continue; } break; } else { - DBG_8723A("%s We've try roaming but fail\n", __func__); + DBG_8723A("%s We've try roaming but fail\n", + __func__); rtw_indicate_disconnect23a(adapter); break; } @@ -1513,7 +1590,8 @@ void rtw23a_join_to_handler (unsigned long data) rtw_indicate_disconnect23a(adapter); free_scanqueue(pmlmepriv);/* */ - /* indicate disconnect for the case that join_timeout and check_fwstate != FW_LINKED */ + /* indicate disconnect for the case that join_timeout and + check_fwstate != FW_LINKED */ rtw_cfg80211_indicate_disconnect(adapter); } @@ -1530,7 +1608,8 @@ void rtw_scan_timeout_handler23a(unsigned long data) struct rtw_adapter *adapter = (struct rtw_adapter *)data; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - DBG_8723A(FUNC_ADPT_FMT" fw_state =%x\n", FUNC_ADPT_ARG(adapter), get_fwstate(pmlmepriv)); + DBG_8723A(FUNC_ADPT_FMT" fw_state =%x\n", FUNC_ADPT_ARG(adapter), + get_fwstate(pmlmepriv)); spin_lock_bh(&pmlmepriv->lock); @@ -1551,7 +1630,8 @@ static void rtw_auto_scan_handler(struct rtw_adapter *padapter) if (pmlmepriv->scan_interval == 0) { DBG_8723A("%s\n", __func__); rtw_set_802_11_bssid23a_list_scan(padapter, NULL, 0); - pmlmepriv->scan_interval = SCAN_INTERVAL;/* 30*2 sec = 60sec */ + /* 30*2 sec = 60sec */ + pmlmepriv->scan_interval = SCAN_INTERVAL; } } } @@ -1564,7 +1644,8 @@ void rtw_dynamic_check_timer_handler(unsigned long data) if (adapter->hw_init_completed == false) goto out; - if ((adapter->bDriverStopped == true)||(adapter->bSurpriseRemoved == true)) + if (adapter->bDriverStopped == true || + adapter->bSurpriseRemoved == true) goto out; if (adapter->net_closed == true) @@ -1615,15 +1696,19 @@ void rtw_set_scan_deny(struct rtw_adapter *adapter, u32 ms) #endif /* -* Select a new join candidate from the original @param candidate and @param competitor +* Select a new join candidate from the original @param candidate and +* @param competitor * @return true: candidate is updated * @return false: candidate is not updated */ -static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv - , struct wlan_network **candidate, struct wlan_network *competitor) +static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv, + struct wlan_network **candidate, + struct wlan_network *competitor) { int updated = false; - struct rtw_adapter *adapter = container_of(pmlmepriv, struct rtw_adapter, mlmepriv); + struct rtw_adapter *adapter; + + adapter = container_of(pmlmepriv, struct rtw_adapter, mlmepriv); /* check bssid, if needed */ if (pmlmepriv->assoc_by_bssid == true) { @@ -1642,7 +1727,7 @@ static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv goto exit; } - if (rtw_is_desired_network(adapter, competitor) == false) + if (rtw_is_desired_network(adapter, competitor) == false) goto exit; if (rtw_to_roaming(adapter) > 0) { @@ -1655,19 +1740,21 @@ static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv goto exit; } - if (*candidate == NULL ||(*candidate)->network.Rssinetwork.Rssi) { + if (!*candidate || + (*candidate)->network.Rssinetwork.Rssi) { *candidate = competitor; updated = true; } if (updated) { - DBG_8723A("[by_bssid:%u][assoc_ssid:%s][to_roaming:%u] new candidate: %s("MAC_FMT") rssi:%d\n", - pmlmepriv->assoc_by_bssid, - pmlmepriv->assoc_ssid.ssid, - rtw_to_roaming(adapter), - (*candidate)->network.Ssid.ssid, - MAC_ARG((*candidate)->network.MacAddress), - (int)(*candidate)->network.Rssi); + DBG_8723A("[by_bssid:%u][assoc_ssid:%s][to_roaming:%u] " + "new candidate: %s("MAC_FMT") rssi:%d\n", + pmlmepriv->assoc_by_bssid, + pmlmepriv->assoc_ssid.ssid, + rtw_to_roaming(adapter), + (*candidate)->network.Ssid.ssid, + MAC_ARG((*candidate)->network.MacAddress), + (int)(*candidate)->network.Rssi); } exit: @@ -1690,8 +1777,8 @@ int rtw_select_and_join_from_scanned_queue23a(struct mlme_priv *pmlmepriv) struct list_head *phead, *plist, *ptmp; struct rtw_adapter *adapter; struct rtw_queue *queue = &pmlmepriv->scanned_queue; - struct wlan_network *pnetwork = NULL; - struct wlan_network *candidate = NULL; + struct wlan_network *pnetwork; + struct wlan_network *candidate = NULL; spin_lock_bh(&pmlmepriv->scanned_queue.lock); phead = get_list_head(queue); @@ -1722,7 +1809,7 @@ int rtw_select_and_join_from_scanned_queue23a(struct mlme_priv *pmlmepriv) } /* check for situation of _FW_LINKED */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { DBG_8723A("%s: _FW_LINKED while ask_for_joinbss!!!\n", __func__); @@ -1740,7 +1827,7 @@ exit: } int rtw_set_auth23a(struct rtw_adapter * adapter, - struct security_priv *psecuritypriv) + struct security_priv *psecuritypriv) { struct cmd_obj* pcmd; struct setauth_parm *psetauthparm; @@ -1783,7 +1870,7 @@ exit: } int rtw_set_key23a(struct rtw_adapter *adapter, - struct security_priv *psecuritypriv, int keyid, u8 set_tx) + struct security_priv *psecuritypriv, int keyid, u8 set_tx) { u8 keylen; struct cmd_obj *pcmd; @@ -1808,9 +1895,9 @@ int rtw_set_key23a(struct rtw_adapter *adapter, psetkeyparm->algorithm = (unsigned char) psecuritypriv->dot118021XGrpPrivacy; RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, - ("\n rtw_set_key23a: psetkeyparm->algorithm = (unsigned " - "char)psecuritypriv->dot118021XGrpPrivacy =%d\n", - psetkeyparm->algorithm)); + ("\n rtw_set_key23a: psetkeyparm->algorithm = " + "(unsigned char)psecuritypriv->dot118021XGrpPrivacy " + "=%d\n", psetkeyparm->algorithm)); } else { psetkeyparm->algorithm = (u8)psecuritypriv->dot11PrivacyAlgrthm; RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, @@ -1855,8 +1942,8 @@ int rtw_set_key23a(struct rtw_adapter *adapter, break; default: RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, - ("\n rtw_set_key23a:psecuritypriv->dot11PrivacyAlgrthm = " - "%x (must be 1 or 2 or 4 or 5)\n", + ("\n rtw_set_key23a:psecuritypriv->dot11PrivacyAlgrthm" + " = %x (must be 1 or 2 or 4 or 5)\n", psecuritypriv->dot11PrivacyAlgrthm)); res = _FAIL; kfree(pcmd); @@ -1889,7 +1976,7 @@ int rtw_restruct_wmm_ie23a(struct rtw_adapter *adapter, u8 *in_ie, unsigned int i, j; i = 12; /* after the fixed IE */ - while(i < in_len) { + while (i < in_len) { ielength = initial_out_len; /* WMM element ID and OUI */ @@ -1940,11 +2027,11 @@ static int SecIsInPMKIDList(struct rtw_adapter *Adapter, u8 *bssid) i++; /* continue; */ } - } while(i < NUM_PMKID_CACHE); + } while (i < NUM_PMKID_CACHE); - if (i == NUM_PMKID_CACHE) { + if (i == NUM_PMKID_CACHE) i = -1;/* Could not find. */ - } else { + else { /* There is one Pre-Authentication Key for the specific BSSID. */ } @@ -1983,7 +2070,7 @@ static int rtw_append_pmkid(struct rtw_adapter *Adapter, int iEntry, } int rtw_restruct_sec_ie23a(struct rtw_adapter *adapter, u8 *in_ie, u8 *out_ie, - uint in_len) + uint in_len) { u8 authmode; uint ielength; @@ -1994,26 +2081,26 @@ int rtw_restruct_sec_ie23a(struct rtw_adapter *adapter, u8 *in_ie, u8 *out_ie, uint ndissecuritytype = psecuritypriv->ndisencryptstatus; RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, - ("+rtw_restruct_sec_ie23a: ndisauthmode=%d ndissecuritytype=%d\n", - ndisauthmode, ndissecuritytype)); + ("+rtw_restruct_sec_ie23a: ndisauthmode=%d " + "ndissecuritytype=%d\n", ndisauthmode, ndissecuritytype)); /* copy fixed ie only */ memcpy(out_ie, in_ie, 12); ielength = 12; - if ((ndisauthmode==Ndis802_11AuthModeWPA) || - (ndisauthmode==Ndis802_11AuthModeWPAPSK)) + if (ndisauthmode == Ndis802_11AuthModeWPA || + ndisauthmode == Ndis802_11AuthModeWPAPSK) authmode = WLAN_EID_VENDOR_SPECIFIC; - if ((ndisauthmode==Ndis802_11AuthModeWPA2) || - (ndisauthmode==Ndis802_11AuthModeWPA2PSK)) - authmode=_WPA2_IE_ID_; + if (ndisauthmode == Ndis802_11AuthModeWPA2 || + ndisauthmode == Ndis802_11AuthModeWPA2PSK) + authmode = _WPA2_IE_ID_; if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { memcpy(out_ie + ielength, psecuritypriv->wps_ie, psecuritypriv->wps_ie_len); ielength += psecuritypriv->wps_ie_len; - } else if ((authmode == WLAN_EID_VENDOR_SPECIFIC) || - (authmode==_WPA2_IE_ID_)) { + } else if (authmode == WLAN_EID_VENDOR_SPECIFIC || + authmode == _WPA2_IE_ID_) { /* copy RSN or SSN */ memcpy(&out_ie[ielength], &psecuritypriv->supplicant_ie[0], psecuritypriv->supplicant_ie[1] + 2); @@ -2021,13 +2108,12 @@ int rtw_restruct_sec_ie23a(struct rtw_adapter *adapter, u8 *in_ie, u8 *out_ie, } iEntry = SecIsInPMKIDList(adapter, pmlmepriv->assoc_bssid); - if (iEntry < 0) { + if (iEntry < 0) return ielength; - } else { - if (authmode == _WPA2_IE_ID_) { - ielength=rtw_append_pmkid(adapter, iEntry, - out_ie, ielength); - } + else { + if (authmode == _WPA2_IE_ID_) + ielength = rtw_append_pmkid(adapter, iEntry, + out_ie, ielength); } return ielength; @@ -2120,7 +2206,6 @@ void rtw_update_registrypriv_dev_network23a(struct rtw_adapter* adapter) /* notes: translate IELength & Length after assign the Length to cmdsz in createbss_cmd(); */ /* pdev_network->IELength = cpu_to_le32(sz); */ - } void rtw_get_encrypt_decrypt_from_registrypriv23a(struct rtw_adapter* adapter) @@ -2285,8 +2370,8 @@ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len) /* update cur_bwmode & cur_ch_offset */ if (pregistrypriv->cbw40_enable && - (pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info & BIT(1)) && - (pmlmeinfo->HT_info.infos[0] & BIT(2))) { + pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info & BIT(1) && + pmlmeinfo->HT_info.infos[0] & BIT(2)) { int i; u8 rf_type; @@ -2294,7 +2379,7 @@ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len) /* update the MCS rates */ for (i = 0; i < 16; i++) { - if ((rf_type == RF_1T1R) || (rf_type == RF_1T2R)) + if (rf_type == RF_1T1R || rf_type == RF_1T2R) pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= MCS_rate_1R23A[i]; else pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= MCS_rate_2R23A[i]; @@ -2332,52 +2417,52 @@ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len) pmlmeinfo->HT_protection = pmlmeinfo->HT_info.infos[1] & 0x3; } -void rtw_issue_addbareq_cmd23a(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe) +void rtw_issue_addbareq_cmd23a(struct rtw_adapter *padapter, + struct xmit_frame *pxmitframe) { u8 issued; int priority; - struct sta_info *psta = NULL; + struct sta_info *psta; struct ht_priv *phtpriv; struct pkt_attrib *pattrib = &pxmitframe->attrib; s32 bmcst = is_multicast_ether_addr(pattrib->ra); - if (bmcst || (padapter->mlmepriv.LinkDetectInfo.NumTxOkInPeriod<100)) + if (bmcst || padapter->mlmepriv.LinkDetectInfo.NumTxOkInPeriod < 100) return; priority = pattrib->priority; if (pattrib->psta) psta = pattrib->psta; - else - { + else { DBG_8723A("%s, call rtw_get_stainfo23a()\n", __func__); psta = rtw_get_stainfo23a(&padapter->stapriv, pattrib->ra); } - if (psta == NULL) - { + if (!psta) { DBG_8723A("%s, psta == NUL\n", __func__); return; } - if (!(psta->state &_FW_LINKED)) - { - DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, psta->state); + if (!(psta->state &_FW_LINKED)) { + DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n", + __func__, psta->state); return; } phtpriv = &psta->htpriv; - if ((phtpriv->ht_option == true) && (phtpriv->ampdu_enable == true)) - { + if (phtpriv->ht_option == true && phtpriv->ampdu_enable == true) { issued = (phtpriv->agg_enable_bitmap>>priority)&0x1; issued |= (phtpriv->candidate_tid_bitmap>>priority)&0x1; - if (0 == issued) - { - DBG_8723A("rtw_issue_addbareq_cmd23a, p =%d\n", priority); - psta->htpriv.candidate_tid_bitmap |= CHKBIT((u8)priority); - rtw_addbareq_cmd23a(padapter, (u8) priority, pattrib->ra); + if (issued == 0) { + DBG_8723A("rtw_issue_addbareq_cmd23a, p =%d\n", + priority); + psta->htpriv.candidate_tid_bitmap |= + CHKBIT((u8)priority); + rtw_addbareq_cmd23a(padapter, (u8) priority, + pattrib->ra); } } } @@ -2394,21 +2479,23 @@ inline u8 rtw_to_roaming(struct rtw_adapter *adapter) return adapter->mlmepriv.to_roaming; } -void rtw23a_roaming(struct rtw_adapter *padapter, struct wlan_network *tgt_network) +void rtw23a_roaming(struct rtw_adapter *padapter, + struct wlan_network *tgt_network) { - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; spin_lock_bh(&pmlmepriv->lock); _rtw23a_roaming(padapter, tgt_network); spin_unlock_bh(&pmlmepriv->lock); } -void _rtw23a_roaming(struct rtw_adapter *padapter, struct wlan_network *tgt_network) +void _rtw23a_roaming(struct rtw_adapter *padapter, + struct wlan_network *tgt_network) { - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_network *pnetwork; int do_join_r; - if (tgt_network != NULL) + if (tgt_network) pnetwork = tgt_network; else pnetwork = &pmlmepriv->cur_network; @@ -2423,17 +2510,21 @@ void _rtw23a_roaming(struct rtw_adapter *padapter, struct wlan_network *tgt_netw pmlmepriv->assoc_by_bssid = false; - while(1) { - if (_SUCCESS == (do_join_r = rtw_do_join23a(padapter))) { + while (1) { + do_join_r = rtw_do_join23a(padapter); + if (do_join_r == _SUCCESS) break; - } else { - DBG_8723A("roaming do_join return %d\n", do_join_r); + else { + DBG_8723A("roaming do_join return %d\n", + do_join_r); pmlmepriv->to_roaming--; - if (0 < rtw_to_roaming(padapter)) { + if (0 < rtw_to_roaming(padapter)) continue; - } else { - DBG_8723A("%s(%d) -to roaming fail, indicate_disconnect\n", __func__, __LINE__); + else { + DBG_8723A("%s(%d) -to roaming fail, " + "indicate_disconnect\n", + __func__, __LINE__); rtw_indicate_disconnect23a(padapter); break; } -- cgit v1.2.3 From 56828797acdb99d23b5e5e5c52e7d571d59b783f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:46 +0200 Subject: staging: rtl8723au: Fold rtw_to_roaming() into the code Simple read variable from a struct function, having it as an external function is just silly. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ioctl_set.c | 4 +-- drivers/staging/rtl8723au/core/rtw_mlme.c | 41 ++++++++++------------- drivers/staging/rtl8723au/include/rtw_mlme.h | 1 - drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 2 +- 4 files changed, 21 insertions(+), 27 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c index 619bef3af153..fe4926a4ced6 100644 --- a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c @@ -54,7 +54,7 @@ u8 rtw_do_join23a(struct rtw_adapter *padapter) /* we try to issue sitesurvey firstly */ if (pmlmepriv->LinkDetectInfo.bBusyTraffic == false || - rtw_to_roaming(padapter) > 0) { + padapter->mlmepriv.to_roaming > 0) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("rtw_do_join23a(): site survey if scanned_queue " "is empty\n.")); @@ -130,7 +130,7 @@ u8 rtw_do_join23a(struct rtw_adapter *padapter) queue */ /* we try to issue sitesurvey firstly */ if (pmlmepriv->LinkDetectInfo.bBusyTraffic == - false || rtw_to_roaming(padapter) > 0) { + false || padapter->mlmepriv.to_roaming > 0){ /* DBG_8723A("rtw_do_join23a() when no " "desired bss in scanning queue\n"); */ diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 8bb368499ce2..34d2164f1dd8 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -325,9 +325,7 @@ void rtw_free_network_nolock(struct mlme_priv *pmlmepriv, void rtw_free_network_queue23a(struct rtw_adapter* dev, u8 isfreeall) { - _rtw_free_network23a_queue23a(dev, isfreeall); - } /* @@ -729,7 +727,6 @@ void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); } else { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("nic status =%x, survey done event comes too late!\n", get_fwstate(pmlmepriv))); @@ -797,8 +794,8 @@ void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) } else { DBG_8723A("try_to_join, but select scanning " "queue fail, to_roaming:%d\n", - rtw_to_roaming(adapter)); - if (rtw_to_roaming(adapter) != 0) { + adapter->mlmepriv.to_roaming); + if (adapter->mlmepriv.to_roaming) { if (--pmlmepriv->to_roaming == 0 || rtw_sitesurvey_cmd23a( adapter, @@ -964,11 +961,11 @@ void rtw_indicate_disconnect23a(struct rtw_adapter *padapter) /* DBG_8723A("clear wps when %s\n", __func__); */ - if (rtw_to_roaming(padapter) > 0) + if (padapter->mlmepriv.to_roaming > 0) _clr_fwstate_(pmlmepriv, _FW_LINKED); if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) || - rtw_to_roaming(padapter) <= 0) { + padapter->mlmepriv.to_roaming <= 0) { rtw_os_indicate_disconnect23a(padapter); /* set ips_deny_time to avoid enter IPS before LPS leave */ @@ -1464,11 +1461,11 @@ void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) spin_lock_bh(&pmlmepriv->lock); if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { - if (rtw_to_roaming(adapter) > 0) { + if (adapter->mlmepriv.to_roaming > 0) { /* this stadel_event is caused by roaming, decrease to_roaming */ pmlmepriv->to_roaming--; - } else if (rtw_to_roaming(adapter) == 0) + } else if (adapter->mlmepriv.to_roaming == 0) rtw_set_roaming(adapter, adapter->registrypriv.max_roaming_times); if (*((u16 *)pstadel->rsvd) != WLAN_REASON_EXPIRATION_CHK) rtw_set_roaming(adapter, 0); /* don't roam */ @@ -1567,10 +1564,12 @@ void rtw23a_join_to_handler (unsigned long data) spin_lock_bh(&pmlmepriv->lock); - if (rtw_to_roaming(adapter) > 0) { /* join timeout caused by roaming */ + if (adapter->mlmepriv.to_roaming > 0) { + /* join timeout caused by roaming */ while (1) { pmlmepriv->to_roaming--; - if (rtw_to_roaming(adapter) != 0) { /* try another */ + if (adapter->mlmepriv.to_roaming != 0) { + /* try another */ DBG_8723A("%s try another roaming\n", __func__); do_join_r = rtw_do_join23a(adapter); if (do_join_r != _SUCCESS) { @@ -1730,7 +1729,7 @@ static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv, if (rtw_is_desired_network(adapter, competitor) == false) goto exit; - if (rtw_to_roaming(adapter) > 0) { + if (adapter->mlmepriv.to_roaming > 0) { unsigned int passed; passed = jiffies_to_msecs(jiffies - competitor->last_scanned); @@ -1751,7 +1750,7 @@ static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv, "new candidate: %s("MAC_FMT") rssi:%d\n", pmlmepriv->assoc_by_bssid, pmlmepriv->assoc_ssid.ssid, - rtw_to_roaming(adapter), + adapter->mlmepriv.to_roaming, (*candidate)->network.Ssid.ssid, MAC_ARG((*candidate)->network.MacAddress), (int)(*candidate)->network.Rssi); @@ -2474,11 +2473,6 @@ inline void rtw_set_roaming(struct rtw_adapter *adapter, u8 to_roaming) adapter->mlmepriv.to_roaming = to_roaming; } -inline u8 rtw_to_roaming(struct rtw_adapter *adapter) -{ - return adapter->mlmepriv.to_roaming; -} - void rtw23a_roaming(struct rtw_adapter *padapter, struct wlan_network *tgt_network) { @@ -2500,7 +2494,7 @@ void _rtw23a_roaming(struct rtw_adapter *padapter, else pnetwork = &pmlmepriv->cur_network; - if (0 < rtw_to_roaming(padapter)) { + if (padapter->mlmepriv.to_roaming > 0) { DBG_8723A("roaming from %s("MAC_FMT"), length:%d\n", pnetwork->network.Ssid.ssid, MAC_ARG(pnetwork->network.MacAddress), @@ -2519,7 +2513,7 @@ void _rtw23a_roaming(struct rtw_adapter *padapter, do_join_r); pmlmepriv->to_roaming--; - if (0 < rtw_to_roaming(padapter)) + if (padapter->mlmepriv.to_roaming > 0) continue; else { DBG_8723A("%s(%d) -to roaming fail, " @@ -2535,12 +2529,13 @@ void _rtw23a_roaming(struct rtw_adapter *padapter, int rtw_linked_check(struct rtw_adapter *padapter) { - if ((check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE)) || - (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE))) { + if (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) || + check_fwstate(&padapter->mlmepriv, + WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) { if (padapter->stapriv.asoc_sta_count > 2) return true; } else { /* Station mode */ - if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) == true) + if (check_fwstate(&padapter->mlmepriv, _FW_LINKED)) return true; } return false; diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index 0b48b05fc1ad..d4b43bdeeefc 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -494,6 +494,5 @@ void _rtw23a_roaming(struct rtw_adapter *adapter, void rtw23a_roaming(struct rtw_adapter *adapter, struct wlan_network *tgt_network); void rtw_set_roaming(struct rtw_adapter *adapter, u8 to_roaming); -u8 rtw_to_roaming(struct rtw_adapter *adapter); #endif /* __RTL871X_MLME_H_ */ diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index cf44d295b66a..4f4d69c742b1 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -366,7 +366,7 @@ void rtw_cfg80211_indicate_connect(struct rtw_adapter *padapter) if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) return; - if (rtw_to_roaming(padapter) > 0) { + if (padapter->mlmepriv.to_roaming > 0) { struct wiphy *wiphy = pwdev->wiphy; struct ieee80211_channel *notify_channel; u32 freq; -- cgit v1.2.3 From e418361c5bdc7e24dffab2460c873c1efd53a5f8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:47 +0200 Subject: staging: rtl8723au: Fold _rtw_free_mlme_priv23a() into rtw_free_mlme_priv23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 34d2164f1dd8..14c4196e7d1f 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -121,8 +121,11 @@ void rtw23a_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv) #endif } -void _rtw_free_mlme_priv23a(struct mlme_priv *pmlmepriv) +void rtw_free_mlme_priv23a(struct mlme_priv *pmlmepriv) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("rtw_free_mlme_priv23a\n")); + rtw23a_free_mlme_priv_ie_data(pmlmepriv); } @@ -301,13 +304,6 @@ int rtw_init_mlme_priv23a (struct rtw_adapter *padapter) return res; } -void rtw_free_mlme_priv23a (struct mlme_priv *pmlmepriv) -{ - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, - ("rtw_free_mlme_priv23a\n")); - _rtw_free_mlme_priv23a(pmlmepriv); -} - void rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork, u8 is_freeall) { -- cgit v1.2.3 From 7ca9ed219b48dbeaabf1f8f6092cfc58a259550c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:48 +0200 Subject: staging: rtl8723au: Remove unused function rtw_get_timestampe_from_ie23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 5 ----- drivers/staging/rtl8723au/include/rtw_mlme.h | 1 - drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 1 - 3 files changed, 7 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 14c4196e7d1f..0a2141bd32d9 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -285,11 +285,6 @@ u16 rtw_get_capability23a(struct wlan_bssid_ex *bss) return le16_to_cpu(val); } -u8 *rtw_get_timestampe_from_ie23a(u8 *ie) -{ - return ie + 0; -} - u8 *rtw_get_beacon_interval23a_from_ie(u8 *ie) { return ie + 8; diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index d4b43bdeeefc..0af91d02976f 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -472,7 +472,6 @@ int rtw_if_up23a(struct rtw_adapter *padapter); int rtw_linked_check(struct rtw_adapter *padapter); u8 *rtw_get_capability23a_from_ie(u8 *ie); -u8 *rtw_get_timestampe_from_ie23a(u8 *ie); u8 *rtw_get_beacon_interval23a_from_ie(u8 *ie); diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 4f4d69c742b1..5dbe3f43ab0e 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -288,7 +288,6 @@ static int rtw_cfg80211_inform_bss(struct rtw_adapter *padapter, notify_channel = ieee80211_get_channel(wiphy, freq); - /* rtw_get_timestampe_from_ie23a() */ notify_timestamp = jiffies_to_msecs(jiffies) * 1000; /* uSec */ notify_interval = -- cgit v1.2.3 From d944b7218b1f51ec5ae1a9346dcaa29fe31f31ac Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:49 +0200 Subject: staging: rtl8723au: collect_bss_info23a(): Use struct ieee80211_mgmt Somplify code by using struct ieee80211_mgmt to calculate offsets Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 52 +++++++++++++-------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 31022f2508c3..68991dca1cbf 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -4471,15 +4471,14 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, { int i, length; const u8 *p; - u16 val16; struct sk_buff *skb = precv_frame->pkt; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - u8 *pframe = skb->data; + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; int packet_len = skb->len; u8 ie_offset; struct registry_priv *pregistrypriv = &padapter->registrypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + u16 capab_info; length = packet_len - sizeof(struct ieee80211_hdr_3addr); @@ -4490,29 +4489,32 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, memset(bssid, 0, sizeof(struct wlan_bssid_ex)); - if (ieee80211_is_beacon(hdr->frame_control)) { + if (ieee80211_is_beacon(mgmt->frame_control)) { bssid->reserved = 1; - ie_offset = _BEACON_IE_OFFSET_; + ie_offset = offsetof(struct ieee80211_mgmt, u.beacon.variable); + capab_info = mgmt->u.beacon.capab_info; + } else if (ieee80211_is_probe_req(mgmt->frame_control)) { + ie_offset = offsetof(struct ieee80211_mgmt, + u.probe_req.variable); + bssid->reserved = 2; + capab_info = 0; + } else if (ieee80211_is_probe_resp(mgmt->frame_control)) { + ie_offset = offsetof(struct ieee80211_mgmt, + u.probe_resp.variable); + bssid->reserved = 3; + capab_info = mgmt->u.probe_resp.capab_info; } else { - /* FIXME : more type */ - if (ieee80211_is_probe_req(hdr->frame_control)) { - ie_offset = _PROBEREQ_IE_OFFSET_; - bssid->reserved = 2; - } else if (ieee80211_is_probe_resp(hdr->frame_control)) { - ie_offset = _PROBERSP_IE_OFFSET_; - bssid->reserved = 3; - } else { - bssid->reserved = 0; - ie_offset = _FIXED_IE_LENGTH_; - } + bssid->reserved = 0; + ie_offset = offsetof(struct ieee80211_mgmt, u.beacon.variable); + capab_info = mgmt->u.beacon.capab_info; } + ie_offset -= offsetof(struct ieee80211_mgmt, u); bssid->Length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + length; /* below is to copy the information element */ bssid->IELength = length; - memcpy(bssid->IEs, pframe + sizeof(struct ieee80211_hdr_3addr), - bssid->IELength); + memcpy(bssid->IEs, &mgmt->u, bssid->IELength); /* get the signal strength */ /* in dBM.raw data */ @@ -4596,10 +4598,10 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, } } - if (ieee80211_is_probe_req(hdr->frame_control)) { + if (ieee80211_is_probe_req(mgmt->frame_control)) { /* FIXME */ bssid->InfrastructureMode = Ndis802_11Infrastructure; - ether_addr_copy(bssid->MacAddress, hdr->addr2); + ether_addr_copy(bssid->MacAddress, mgmt->sa); bssid->Privacy = 1; return _SUCCESS; } @@ -4609,17 +4611,15 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, bssid->Configuration.BeaconPeriod = le32_to_cpu(bssid->Configuration.BeaconPeriod); - val16 = rtw_get_capability23a(bssid); - - if (val16 & BIT(0)) { + if (capab_info & BIT(0)) { bssid->InfrastructureMode = Ndis802_11Infrastructure; - ether_addr_copy(bssid->MacAddress, hdr->addr2); + ether_addr_copy(bssid->MacAddress, mgmt->sa); } else { bssid->InfrastructureMode = Ndis802_11IBSS; - ether_addr_copy(bssid->MacAddress, hdr->addr3); + ether_addr_copy(bssid->MacAddress, mgmt->bssid); } - if (val16 & BIT(4)) + if (capab_info & BIT(4)) bssid->Privacy = 1; else bssid->Privacy = 0; -- cgit v1.2.3 From afa7e480a9587b1b7f35cc2d08bae7c441dc8bc8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:50 +0200 Subject: staging: rtl8723au: Move rtw23a_roaming() so we can declare _rtw_roaming() static Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 111 ++++++++++++++------------- drivers/staging/rtl8723au/include/rtw_mlme.h | 2 - 2 files changed, 56 insertions(+), 57 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 0a2141bd32d9..fcb1add545bf 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -271,6 +271,61 @@ void rtw_generate_random_ibss23a(u8* pibss) return; } +static void _rtw_roaming(struct rtw_adapter *padapter, + struct wlan_network *tgt_network) +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct wlan_network *pnetwork; + int do_join_r; + + if (tgt_network) + pnetwork = tgt_network; + else + pnetwork = &pmlmepriv->cur_network; + + if (padapter->mlmepriv.to_roaming > 0) { + DBG_8723A("roaming from %s("MAC_FMT"), length:%d\n", + pnetwork->network.Ssid.ssid, + MAC_ARG(pnetwork->network.MacAddress), + pnetwork->network.Ssid.ssid_len); + memcpy(&pmlmepriv->assoc_ssid, &pnetwork->network.Ssid, + sizeof(struct cfg80211_ssid)); + + pmlmepriv->assoc_by_bssid = false; + + while (1) { + do_join_r = rtw_do_join23a(padapter); + if (do_join_r == _SUCCESS) + break; + else { + DBG_8723A("roaming do_join return %d\n", + do_join_r); + pmlmepriv->to_roaming--; + + if (padapter->mlmepriv.to_roaming > 0) + continue; + else { + DBG_8723A("%s(%d) -to roaming fail, " + "indicate_disconnect\n", + __func__, __LINE__); + rtw_indicate_disconnect23a(padapter); + break; + } + } + } + } +} + +void rtw23a_roaming(struct rtw_adapter *padapter, + struct wlan_network *tgt_network) +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + spin_lock_bh(&pmlmepriv->lock); + _rtw_roaming(padapter, tgt_network); + spin_unlock_bh(&pmlmepriv->lock); +} + u8 *rtw_get_capability23a_from_ie(u8 *ie) { return ie + 8 + 2; @@ -1475,7 +1530,7 @@ void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) } spin_unlock_bh(&pmlmepriv->scanned_queue.lock); - _rtw23a_roaming(adapter, tgt_network); + _rtw_roaming(adapter, tgt_network); } if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || @@ -2464,60 +2519,6 @@ inline void rtw_set_roaming(struct rtw_adapter *adapter, u8 to_roaming) adapter->mlmepriv.to_roaming = to_roaming; } -void rtw23a_roaming(struct rtw_adapter *padapter, - struct wlan_network *tgt_network) -{ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - spin_lock_bh(&pmlmepriv->lock); - _rtw23a_roaming(padapter, tgt_network); - spin_unlock_bh(&pmlmepriv->lock); -} -void _rtw23a_roaming(struct rtw_adapter *padapter, - struct wlan_network *tgt_network) -{ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wlan_network *pnetwork; - int do_join_r; - - if (tgt_network) - pnetwork = tgt_network; - else - pnetwork = &pmlmepriv->cur_network; - - if (padapter->mlmepriv.to_roaming > 0) { - DBG_8723A("roaming from %s("MAC_FMT"), length:%d\n", - pnetwork->network.Ssid.ssid, - MAC_ARG(pnetwork->network.MacAddress), - pnetwork->network.Ssid.ssid_len); - memcpy(&pmlmepriv->assoc_ssid, &pnetwork->network.Ssid, - sizeof(struct cfg80211_ssid)); - - pmlmepriv->assoc_by_bssid = false; - - while (1) { - do_join_r = rtw_do_join23a(padapter); - if (do_join_r == _SUCCESS) - break; - else { - DBG_8723A("roaming do_join return %d\n", - do_join_r); - pmlmepriv->to_roaming--; - - if (padapter->mlmepriv.to_roaming > 0) - continue; - else { - DBG_8723A("%s(%d) -to roaming fail, " - "indicate_disconnect\n", - __func__, __LINE__); - rtw_indicate_disconnect23a(padapter); - break; - } - } - } - } -} - int rtw_linked_check(struct rtw_adapter *padapter) { if (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) || diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index 0af91d02976f..6036503c00ea 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -488,8 +488,6 @@ int rtw_is_same_ibss23a(struct rtw_adapter *adapter, struct wlan_network *pnetwork); int is_same_network23a(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst); -void _rtw23a_roaming(struct rtw_adapter *adapter, - struct wlan_network *tgt_network); void rtw23a_roaming(struct rtw_adapter *adapter, struct wlan_network *tgt_network); void rtw_set_roaming(struct rtw_adapter *adapter, u8 to_roaming); -- cgit v1.2.3 From a9339fdd13d69b782dfaaa26e3122fac23e4fac5 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:51 +0200 Subject: staging: rtl8723au: Remove bogus inline from rtw_set_roaming() prototype Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index fcb1add545bf..e207f477b449 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -271,6 +271,13 @@ void rtw_generate_random_ibss23a(u8* pibss) return; } +void rtw_set_roaming(struct rtw_adapter *adapter, u8 to_roaming) +{ + if (to_roaming == 0) + adapter->mlmepriv.to_join = false; + adapter->mlmepriv.to_roaming = to_roaming; +} + static void _rtw_roaming(struct rtw_adapter *padapter, struct wlan_network *tgt_network) { @@ -2512,13 +2519,6 @@ void rtw_issue_addbareq_cmd23a(struct rtw_adapter *padapter, } } -inline void rtw_set_roaming(struct rtw_adapter *adapter, u8 to_roaming) -{ - if (to_roaming == 0) - adapter->mlmepriv.to_join = false; - adapter->mlmepriv.to_roaming = to_roaming; -} - int rtw_linked_check(struct rtw_adapter *padapter) { if (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) || -- cgit v1.2.3 From dff222670ebebf1a7f147a23ccb5fc0312f2ae7e Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:52 +0200 Subject: staging: rtl8723au: Make _rtw_free_network23() static Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 4 ++-- drivers/staging/rtl8723au/include/rtw_mlme.h | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index e207f477b449..4d21d623070e 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -146,8 +146,8 @@ struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv) return pnetwork; } -void _rtw_free_network23a(struct mlme_priv *pmlmepriv, - struct wlan_network *pnetwork, u8 isfreeall) +static void _rtw_free_network23a(struct mlme_priv *pmlmepriv, + struct wlan_network *pnetwork, u8 isfreeall) { u32 lifetime = SCANQUEUE_LIFETIME; diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index 6036503c00ea..3d6f7307e41e 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -458,8 +458,6 @@ void _rtw_free_mlme_priv23a(struct mlme_priv *pmlmepriv); struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv); -void _rtw_free_network23a(struct mlme_priv *pmlmepriv, - struct wlan_network *pnetwork, u8 isfreeall); void _rtw_free_network23a_nolock23a(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork); -- cgit v1.2.3 From 67c20cfbce53cf6df28681939d9a9621d2a85dfc Mon Sep 17 00:00:00 2001 From: Kristina Martšenko Date: Tue, 25 Mar 2014 01:45:09 +0200 Subject: staging: goldfish: switch from spinlock to mutex MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use a mutex instead of a spinlock in goldfish_nand.c, as suggested by the TODO list. Signed-off-by: Kristina Martšenko Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/goldfish/README | 1 - drivers/staging/goldfish/goldfish_nand.c | 15 +++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/staging/goldfish/README b/drivers/staging/goldfish/README index 93d65b0f0f83..183af0053234 100644 --- a/drivers/staging/goldfish/README +++ b/drivers/staging/goldfish/README @@ -5,7 +5,6 @@ Audio NAND ---- -- Switch from spinlock to mutex - Remove excess checking of parameters in calls - Use dma coherent memory not kmalloc/__pa for the memory (this is just a cleanliness issue not a correctness one) diff --git a/drivers/staging/goldfish/goldfish_nand.c b/drivers/staging/goldfish/goldfish_nand.c index eca0873098cd..7f606f7dec69 100644 --- a/drivers/staging/goldfish/goldfish_nand.c +++ b/drivers/staging/goldfish/goldfish_nand.c @@ -24,13 +24,14 @@ #include #include #include +#include #include #include "goldfish_nand_reg.h" struct goldfish_nand { - spinlock_t lock; + struct mutex lock; unsigned char __iomem *base; struct cmd_params *cmd_params; size_t mtd_count; @@ -77,10 +78,9 @@ static u32 goldfish_nand_cmd(struct mtd_info *mtd, enum nand_cmd cmd, { struct goldfish_nand *nand = mtd->priv; u32 rv; - unsigned long irq_flags; unsigned char __iomem *base = nand->base; - spin_lock_irqsave(&nand->lock, irq_flags); + mutex_lock(&nand->lock); if (goldfish_nand_cmd_with_params(mtd, cmd, addr, len, ptr, &rv)) { writel(mtd - nand->mtd, base + NAND_DEV); writel((u32)(addr >> 32), base + NAND_ADDR_HIGH); @@ -90,7 +90,7 @@ static u32 goldfish_nand_cmd(struct mtd_info *mtd, enum nand_cmd cmd, writel(cmd, base + NAND_COMMAND); rv = readl(base + NAND_RESULT); } - spin_unlock_irqrestore(&nand->lock, irq_flags); + mutex_unlock(&nand->lock); return rv; } @@ -307,12 +307,11 @@ static int goldfish_nand_init_device(struct platform_device *pdev, u32 name_len; u32 result; u32 flags; - unsigned long irq_flags; unsigned char __iomem *base = nand->base; struct mtd_info *mtd = &nand->mtd[id]; char *name; - spin_lock_irqsave(&nand->lock, irq_flags); + mutex_lock(&nand->lock); writel(id, base + NAND_DEV); flags = readl(base + NAND_DEV_FLAGS); name_len = readl(base + NAND_DEV_NAME_LEN); @@ -329,7 +328,7 @@ static int goldfish_nand_init_device(struct platform_device *pdev, "goldfish nand dev%d: size %llx, page %d, extra %d, erase %d\n", id, mtd->size, mtd->writesize, mtd->oobsize, mtd->erasesize); - spin_unlock_irqrestore(&nand->lock, irq_flags); + mutex_unlock(&nand->lock); mtd->priv = nand; @@ -405,7 +404,7 @@ static int goldfish_nand_probe(struct platform_device *pdev) if (nand == NULL) return -ENOMEM; - spin_lock_init(&nand->lock); + mutex_init(&nand->lock); nand->base = base; nand->mtd_count = num_dev; platform_set_drvdata(pdev, nand); -- cgit v1.2.3 From ef323812c9cfd5837afab13dde846bf208eb4cc3 Mon Sep 17 00:00:00 2001 From: Garret Kelly Date: Sun, 6 Apr 2014 23:47:31 -0400 Subject: staging: goldfish: Fix missing blank lines Fix two instances of the following checkpatch warning: WARNING: Missing a blank line after declarations Signed-off-by: Garret Kelly Signed-off-by: Greg Kroah-Hartman --- drivers/staging/goldfish/goldfish_audio.c | 1 + drivers/staging/goldfish/goldfish_nand.c | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/staging/goldfish/goldfish_audio.c b/drivers/staging/goldfish/goldfish_audio.c index f96dcec740ae..aca980ec3696 100644 --- a/drivers/staging/goldfish/goldfish_audio.c +++ b/drivers/staging/goldfish/goldfish_audio.c @@ -147,6 +147,7 @@ static ssize_t goldfish_audio_write(struct file *fp, const char __user *buf, while (count > 0) { ssize_t copy = count; + if (copy > WRITE_BUFFER_SIZE) copy = WRITE_BUFFER_SIZE; wait_event_interruptible(data->wait, (data->buffer_status & diff --git a/drivers/staging/goldfish/goldfish_nand.c b/drivers/staging/goldfish/goldfish_nand.c index 7f606f7dec69..2a292df71e7c 100644 --- a/drivers/staging/goldfish/goldfish_nand.c +++ b/drivers/staging/goldfish/goldfish_nand.c @@ -424,6 +424,7 @@ static int goldfish_nand_remove(struct platform_device *pdev) { struct goldfish_nand *nand = platform_get_drvdata(pdev); int i; + for (i = 0; i < nand->mtd_count; i++) { if (nand->mtd[i].name) mtd_device_unregister(&nand->mtd[i]); -- cgit v1.2.3 From 53d719f6a907ad7e2ca449fdaf9c9e175a623350 Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Thu, 17 Apr 2014 00:39:44 +0900 Subject: staging: android: uapi: fix coding style This patch fix checkpatch.pl warning and errors. Signed-off-by: Seunghun Lee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/uapi/ion.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/android/uapi/ion.h b/drivers/staging/android/uapi/ion.h index f09e7c154d69..6aa495673370 100644 --- a/drivers/staging/android/uapi/ion.h +++ b/drivers/staging/android/uapi/ion.h @@ -27,12 +27,12 @@ typedef int ion_user_handle_t; * @ION_HEAP_TYPE_SYSTEM: memory allocated via vmalloc * @ION_HEAP_TYPE_SYSTEM_CONTIG: memory allocated via kmalloc * @ION_HEAP_TYPE_CARVEOUT: memory allocated from a prereserved - * carveout heap, allocations are physically - * contiguous + * carveout heap, allocations are physically + * contiguous * @ION_HEAP_TYPE_DMA: memory allocated via DMA API * @ION_NUM_HEAPS: helper for iterating over heaps, a bit mask - * is used to identify the heaps, so only 32 - * total heap types are supported + * is used to identify the heaps, so only 32 + * total heap types are supported */ enum ion_heap_type { ION_HEAP_TYPE_SYSTEM, @@ -50,7 +50,7 @@ enum ion_heap_type { #define ION_HEAP_CARVEOUT_MASK (1 << ION_HEAP_TYPE_CARVEOUT) #define ION_HEAP_TYPE_DMA_MASK (1 << ION_HEAP_TYPE_DMA) -#define ION_NUM_HEAP_IDS sizeof(unsigned int) * 8 +#define ION_NUM_HEAP_IDS (sizeof(unsigned int) * 8) /** * allocation flags - the lower 16 bits are used by core ion, the upper 16 @@ -78,7 +78,7 @@ enum ion_heap_type { * @align: required alignment of the allocation * @heap_id_mask: mask of heap ids to allocate from * @flags: flags passed to heap - * @handle: pointer that will be populated with a cookie to use to + * @handle: pointer that will be populated with a cookie to use to * refer to this allocation * * Provided by userspace as an argument to the ioctl -- cgit v1.2.3 From 36c89c0a6bebafdde13099229dfe541380ce7612 Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Tue, 15 Apr 2014 12:03:05 +0200 Subject: staging: binder: add __user annotation in binder.c Add __user to binder_version to correct sparse warning. Reduce line size to fit to coding style. Signed-off-by: Mathieu Maret Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/binder.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c index cfe4bc8f05cb..1f5e2499ac1b 100644 --- a/drivers/staging/android/binder.c +++ b/drivers/staging/android/binder.c @@ -2683,16 +2683,20 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) binder_free_thread(proc, thread); thread = NULL; break; - case BINDER_VERSION: + case BINDER_VERSION: { + struct binder_version __user *ver = ubuf; + if (size != sizeof(struct binder_version)) { ret = -EINVAL; goto err; } - if (put_user(BINDER_CURRENT_PROTOCOL_VERSION, &((struct binder_version *)ubuf)->protocol_version)) { + if (put_user(BINDER_CURRENT_PROTOCOL_VERSION, + &ver->protocol_version)) { ret = -EINVAL; goto err; } break; + } default: ret = -EINVAL; goto err; -- cgit v1.2.3 From 22bfe7e89c9d070d9a8497ae239d4ef76045ff08 Mon Sep 17 00:00:00 2001 From: Julian Gindi Date: Sun, 13 Apr 2014 18:38:31 -0400 Subject: bcm: Fixing a few checkpatch issues in InterfaceMisc.h Just cleaned up a few issues presented by checkpatch in InterfaceMisc.h. I converted some spaces to tabs, and removed unnecessary whitespace. The kernel version I am using linux-next-20140411. Signed-off-by: Julian Gindi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/InterfaceMisc.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/bcm/InterfaceMisc.h b/drivers/staging/bcm/InterfaceMisc.h index bce6869a7478..efb686046153 100644 --- a/drivers/staging/bcm/InterfaceMisc.h +++ b/drivers/staging/bcm/InterfaceMisc.h @@ -14,13 +14,13 @@ InterfaceWRM(struct bcm_interface_adapter *psIntfAdapter, INT len); -int InterfaceFileDownload( PVOID psIntfAdapter, - struct file *flp, - unsigned int on_chip_loc); +int InterfaceFileDownload(PVOID psIntfAdapter, + struct file *flp, + unsigned int on_chip_loc); -int InterfaceFileReadbackFromChip( PVOID psIntfAdapter, - struct file *flp, - unsigned int on_chip_loc); +int InterfaceFileReadbackFromChip(PVOID psIntfAdapter, + struct file *flp, + unsigned int on_chip_loc); int BcmRDM(PVOID arg, -- cgit v1.2.3 From d766b4b50ae0c8156783089c69821072ef3c2f2d Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Fri, 21 Mar 2014 23:42:52 +0900 Subject: staging: lustre: Fix typo in lustre/include Fix spelling typo in comments within lustre/include. Signed-off-by: Masanari Iida Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h | 4 ++-- drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h | 2 +- drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h | 8 ++++---- drivers/staging/lustre/include/linux/lnet/lib-lnet.h | 2 +- drivers/staging/lustre/include/linux/lnet/lib-types.h | 6 +++--- drivers/staging/lustre/include/linux/lnet/lnetst.h | 2 +- drivers/staging/lustre/include/linux/lnet/types.h | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h index c87efb49ebc2..d116fdfc5c41 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h @@ -128,7 +128,7 @@ struct cfs_cpt_table *cfs_cpt_table_alloc(unsigned int ncpt); int cfs_cpt_number(struct cfs_cpt_table *cptab); /** - * return number of HW cores or hypter-threadings in a CPU partition \a cpt + * return number of HW cores or hyper-threadings in a CPU partition \a cpt */ int cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt); /** @@ -152,7 +152,7 @@ int cfs_cpt_of_cpu(struct cfs_cpt_table *cptab, int cpu); */ int cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt); /** - * add \a cpu to CPU partion @cpt of \a cptab, return 1 for success, + * add \a cpu to CPU partition @cpt of \a cptab, return 1 for success, * otherwise 0 is returned */ int cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu); diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h index 776e9c0e48c1..9e610a9ce51f 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h @@ -31,7 +31,7 @@ struct cfs_crypto_hash_type { char *cht_name; /**< hash algorithm name, equal to * format name for crypto api */ - unsigned int cht_key; /**< init key by default (vaild for + unsigned int cht_key; /**< init key by default (valid for * 4 bytes context like crc32, adler */ unsigned int cht_size; /**< hash digest size */ }; diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h index e5d5db255622..954164361ca4 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h @@ -59,8 +59,8 @@ /* * Ideally we would use HAVE_HASH_LONG for this, but on linux we configure * the linux kernel and user space at the same time, so we need to differentiate - * between them explicitely. If this is not needed on other architectures, then - * we'll need to move the functions to archi specific headers. + * between them explicitly. If this is not needed on other architectures, then + * we'll need to move the functions to architecture specific headers. */ #include @@ -86,7 +86,7 @@ union cfs_hash_lock { /** * cfs_hash_bucket is a container of: - * - lock, couter ... + * - lock, counter ... * - array of hash-head starting from hsb_head[0], hash-head can be one of * . cfs_hash_head_t * . cfs_hash_head_dep_t @@ -136,7 +136,7 @@ enum cfs_hash_tag { CFS_HASH_NO_BKTLOCK = 1 << 1, /** rwlock to protect bucket */ CFS_HASH_RW_BKTLOCK = 1 << 2, - /** spinlcok to protect bucket */ + /** spinlock to protect bucket */ CFS_HASH_SPIN_BKTLOCK = 1 << 3, /** always add new item to tail */ CFS_HASH_ADD_TAIL = 1 << 4, diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index 856fcfaafafa..06ff463e4af6 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -181,7 +181,7 @@ lnet_net_lock_current(void) #define MAX_PORTALS 64 /* these are only used by code with LNET_USE_LIB_FREELIST, but we still - * exported them to !LNET_USE_LIB_FREELIST for easy implemetation */ + * exported them to !LNET_USE_LIB_FREELIST for easy implementation */ #define LNET_FL_MAX_MES 2048 #define LNET_FL_MAX_MDS 2048 #define LNET_FL_MAX_EQS 512 diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index 1c13ef7df80e..a63654b660de 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -204,7 +204,7 @@ typedef struct lnet_msg { unsigned int msg_receiving:1; /* being received */ unsigned int msg_txcredit:1; /* taken an NI send credit */ unsigned int msg_peertxcredit:1; /* taken a peer send credit */ - unsigned int msg_rtrcredit:1; /* taken a globel router credit */ + unsigned int msg_rtrcredit:1; /* taken a global router credit */ unsigned int msg_peerrtrcredit:1; /* taken a peer router credit */ unsigned int msg_onactivelist:1; /* on the activelist */ @@ -342,7 +342,7 @@ typedef struct lnet_lnd { /* Start receiving 'mlen' bytes of payload data, skipping the following * 'rlen' - 'mlen' bytes. 'private' is the 'private' passed to - * lnet_parse(). Return non-zero for immedaite failure, otherwise + * lnet_parse(). Return non-zero for immediate failure, otherwise * complete later with lnet_finalize(). This also gives back a receive * credit if the LND does flow control. */ int (*lnd_recv)(struct lnet_ni *ni, void *private, lnet_msg_t *msg, @@ -594,7 +594,7 @@ struct lnet_match_table { unsigned int mt_cpt; unsigned int mt_portal; /* portal index */ /* match table is set as "enabled" if there's non-exhausted MD - * attached on mt_mhash, it's only valide for wildcard portal */ + * attached on mt_mhash, it's only valid for wildcard portal */ unsigned int mt_enabled; /* bitmap to flag whether MEs on mt_hash are exhausted or not */ __u64 mt_exhausted[LNET_MT_EXHAUSTED_BMAP]; diff --git a/drivers/staging/lustre/include/linux/lnet/lnetst.h b/drivers/staging/lustre/include/linux/lnet/lnetst.h index e060599314d5..87fe9ac76a6c 100644 --- a/drivers/staging/lustre/include/linux/lnet/lnetst.h +++ b/drivers/staging/lustre/include/linux/lnet/lnetst.h @@ -402,7 +402,7 @@ typedef struct { /* add stat in session */ typedef struct { int lstio_sta_key; /* IN: session key */ - int lstio_sta_timeout; /* IN: timeout for stat requst */ + int lstio_sta_timeout; /* IN: timeout for stat request */ int lstio_sta_nmlen; /* IN: group name length */ char *lstio_sta_namep; /* IN: group name */ int lstio_sta_count; /* IN: # of pid */ diff --git a/drivers/staging/lustre/include/linux/lnet/types.h b/drivers/staging/lustre/include/linux/lnet/types.h index c833ce8544d3..b19d98809b57 100644 --- a/drivers/staging/lustre/include/linux/lnet/types.h +++ b/drivers/staging/lustre/include/linux/lnet/types.h @@ -181,7 +181,7 @@ typedef struct { * address of an array of lnet_kiov_t and the length field specifies * the number of entries in the array. The length can't be bigger * than LNET_MAX_IOV. The lnet_kiov_t is used to describe page-based - * fragments that are not necessarily mapped in virtal memory. + * fragments that are not necessarily mapped in virtual memory. * - LNET_MD_IOVEC bit set: The start field points to the starting * address of an array of struct iovec and the length field specifies * the number of entries in the array. The length can't be bigger -- cgit v1.2.3 From f5e8269b5afacccf9a0262e9143097c31d9c1b57 Mon Sep 17 00:00:00 2001 From: John de la Garza Date: Mon, 24 Mar 2014 13:58:02 -0700 Subject: drivers:staging:lustre Fixed sparse warning: plain integer as NULL pointer Fixes these sparse warnings: drivers/staging/lustre/lustre/lmv/lproc_lmv.c:202:51: warning: Using plain integer as NULL pointer drivers/staging/lustre/lustre/lmv/lproc_lmv.c:203:51: warning: Using plain integer as NULL pointer drivers/staging/lustre/lustre/lmv/lproc_lmv.c:204:51: warning: Using plain integer as NULL pointer drivers/staging/lustre/lustre/lmv/lproc_lmv.c:205:51: warning: Using plain integer as NULL pointer drivers/staging/lustre/lustre/lmv/lproc_lmv.c:206:51: warning: Using plain integer as NULL pointer drivers/staging/lustre/lustre/lmv/lproc_lmv.c:207:11: warning: Using plain integer as NULL pointer drivers/staging/lustre/lustre/lmv/lproc_lmv.c:213:47: warning: Using plain integer as NULL pointer drivers/staging/lustre/lustre/lmv/lproc_lmv.c:214:11: warning: Using plain integer as NULL pointer Signed-off-by: John de la Garza Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lmv/lproc_lmv.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c index 5d5c3081c467..ae73c82ce499 100644 --- a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c +++ b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c @@ -200,19 +200,19 @@ static int lmv_target_seq_open(struct inode *inode, struct file *file) LPROC_SEQ_FOPS_RO_TYPE(lmv, uuid); struct lprocfs_vars lprocfs_lmv_obd_vars[] = { - { "numobd", &lmv_numobd_fops, 0, 0 }, - { "placement", &lmv_placement_fops, 0, 0 }, - { "activeobd", &lmv_activeobd_fops, 0, 0 }, - { "uuid", &lmv_uuid_fops, 0, 0 }, - { "desc_uuid", &lmv_desc_uuid_fops, 0, 0 }, - { 0 } + { "numobd", &lmv_numobd_fops, NULL, 0 }, + { "placement", &lmv_placement_fops, NULL, 0 }, + { "activeobd", &lmv_activeobd_fops, NULL, 0 }, + { "uuid", &lmv_uuid_fops, NULL, 0 }, + { "desc_uuid", &lmv_desc_uuid_fops, NULL, 0 }, + { NULL } }; LPROC_SEQ_FOPS_RO_TYPE(lmv, numrefs); static struct lprocfs_vars lprocfs_lmv_module_vars[] = { - { "num_refs", &lmv_numrefs_fops, 0, 0 }, - { 0 } + { "num_refs", &lmv_numrefs_fops, NULL, 0 }, + { NULL } }; struct file_operations lmv_proc_target_fops = { -- cgit v1.2.3 From f9bd9c1a08f852cd6ba6102d15ad94db2d6b595f Mon Sep 17 00:00:00 2001 From: Christoph Jaeger Date: Fri, 28 Mar 2014 00:21:07 +0100 Subject: staging: lustre: use __func__ instead of __FUNCTION__ __FUNCTION__ is gcc specific; use __func__ instead. Signed-off-by: Christoph Jaeger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h | 4 ++-- drivers/staging/lustre/lustre/include/linux/obd.h | 2 +- drivers/staging/lustre/lustre/include/lu_ref.h | 4 ++-- drivers/staging/lustre/lustre/include/lustre_dlm.h | 4 ++-- drivers/staging/lustre/lustre/obdclass/cl_lock.c | 2 +- drivers/staging/lustre/lustre/obdclass/genops.c | 4 ++-- drivers/staging/lustre/lustre/obdclass/linux/linux-module.c | 4 ++-- drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 4 ++-- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h index 2bd4885ce06c..b270d84def98 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h @@ -183,7 +183,7 @@ struct libcfs_debug_msg_data { do { \ (data)->msg_subsys = DEBUG_SUBSYSTEM; \ (data)->msg_file = __FILE__; \ - (data)->msg_fn = __FUNCTION__; \ + (data)->msg_fn = __func__; \ (data)->msg_line = __LINE__; \ (data)->msg_cdls = (cdls); \ (data)->msg_mask = (mask); \ @@ -193,7 +193,7 @@ do { \ static struct libcfs_debug_msg_data dataname = { \ .msg_subsys = DEBUG_SUBSYSTEM, \ .msg_file = __FILE__, \ - .msg_fn = __FUNCTION__, \ + .msg_fn = __func__, \ .msg_line = __LINE__, \ .msg_cdls = (cdls) }; \ dataname.msg_mask = (mask); diff --git a/drivers/staging/lustre/lustre/include/linux/obd.h b/drivers/staging/lustre/lustre/include/linux/obd.h index dc36f75eb635..fea7e6cd44c3 100644 --- a/drivers/staging/lustre/lustre/include/linux/obd.h +++ b/drivers/staging/lustre/lustre/include/linux/obd.h @@ -104,7 +104,7 @@ static inline void __client_obd_list_lock(client_obd_lock_t *lock, } #define client_obd_list_lock(lock) \ - __client_obd_list_lock(lock, __FUNCTION__, __LINE__) + __client_obd_list_lock(lock, __func__, __LINE__) static inline void client_obd_list_unlock(client_obd_lock_t *lock) { diff --git a/drivers/staging/lustre/lustre/include/lu_ref.h b/drivers/staging/lustre/lustre/include/lu_ref.h index 50a2a7f786dc..b451a888ca3a 100644 --- a/drivers/staging/lustre/lustre/include/lu_ref.h +++ b/drivers/staging/lustre/lustre/include/lu_ref.h @@ -69,12 +69,12 @@ * * // current thread acquired a temporary reference to foo. * foo_get(foo); - * lu_ref_add(&foo->reference, __FUNCTION__, current); + * lu_ref_add(&foo->reference, __func__, current); * * ... * * // temporary reference is released. - * lu_ref_del(&foo->reference, __FUNCTION__, current); + * lu_ref_del(&foo->reference, __func__, current); * foo_put(foo); * \endcode * diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index 3e25f001c07d..ed103133165e 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -1312,11 +1312,11 @@ int ldlm_lock_change_resource(struct ldlm_namespace *, struct ldlm_lock *, const struct ldlm_res_id *); #define LDLM_RESOURCE_ADDREF(res) do { \ - lu_ref_add_atomic(&(res)->lr_reference, __FUNCTION__, current); \ + lu_ref_add_atomic(&(res)->lr_reference, __func__, current); \ } while (0) #define LDLM_RESOURCE_DELREF(res) do { \ - lu_ref_del(&(res)->lr_reference, __FUNCTION__, current); \ + lu_ref_del(&(res)->lr_reference, __func__, current); \ } while (0) /* ldlm_request.c */ diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c index d795cef3f164..8eb1785645ba 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c @@ -139,7 +139,7 @@ static void cl_lock_trace0(int level, const struct lu_env *env, func, line); } #define cl_lock_trace(level, env, prefix, lock) \ - cl_lock_trace0(level, env, prefix, lock, __FUNCTION__, __LINE__) + cl_lock_trace0(level, env, prefix, lock, __func__, __LINE__) #define RETIP ((unsigned long)__builtin_return_address(0)) diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index f2bdea33041d..350b6f079d92 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -615,13 +615,13 @@ int class_notify_sptlrpc_conf(const char *fsname, int namelen) if (strncmp(obd->obd_name, fsname, namelen)) continue; - class_incref(obd, __FUNCTION__, obd); + class_incref(obd, __func__, obd); read_unlock(&obd_dev_lock); rc2 = obd_set_info_async(NULL, obd->obd_self_export, sizeof(KEY_SPTLRPC_CONF), KEY_SPTLRPC_CONF, 0, NULL, NULL); rc = rc ? rc : rc2; - class_decref(obd, __FUNCTION__, obd); + class_decref(obd, __func__, obd); read_lock(&obd_dev_lock); } read_unlock(&obd_dev_lock); diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c index ba20776ebfa1..e4e94cc1713d 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c @@ -244,7 +244,7 @@ static int obd_proc_health_seq_show(struct seq_file *m, void *v) if (obd->obd_stopping) continue; - class_incref(obd, __FUNCTION__, current); + class_incref(obd, __func__, current); read_unlock(&obd_dev_lock); if (obd_health_check(NULL, obd)) { @@ -252,7 +252,7 @@ static int obd_proc_health_seq_show(struct seq_file *m, void *v) obd->obd_name); rc++; } - class_decref(obd, __FUNCTION__, current); + class_decref(obd, __func__, current); read_lock(&obd_dev_lock); } read_unlock(&obd_dev_lock); diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 58f1c8bf25b0..7a422ff759bf 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -1190,7 +1190,7 @@ int lprocfs_wr_evict_client(struct file *file, const char *buffer, * the proc entries under the being destroyed export{}, so I have * to drop the lock at first here. * - jay, jxiong@clusterfs.com */ - class_incref(obd, __FUNCTION__, current); + class_incref(obd, __func__, current); if (strncmp(tmpbuf, "nid:", 4) == 0) obd_export_evict_by_nid(obd, tmpbuf + 4); @@ -1199,7 +1199,7 @@ int lprocfs_wr_evict_client(struct file *file, const char *buffer, else obd_export_evict_by_uuid(obd, tmpbuf); - class_decref(obd, __FUNCTION__, current); + class_decref(obd, __func__, current); out: OBD_FREE(kbuf, BUFLEN); -- cgit v1.2.3 From f51d7657cb62fe1457aa430cdfd3cddfe6272abb Mon Sep 17 00:00:00 2001 From: Joshua Baldock Date: Wed, 2 Apr 2014 19:12:57 +1100 Subject: Staging: lustre: Fixed errors reported by checkpatch.pl script for file ptllnd.h Added space after ',' as reported as error by checkpatch.pl script. Signed-off-by: Joshua Baldock Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/lnet/ptllnd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/include/linux/lnet/ptllnd.h b/drivers/staging/lustre/include/linux/lnet/ptllnd.h index 564f5d3a9b4d..313442a7ed3e 100644 --- a/drivers/staging/lustre/include/linux/lnet/ptllnd.h +++ b/drivers/staging/lustre/include/linux/lnet/ptllnd.h @@ -66,7 +66,7 @@ /*#define PTL_MD_LUSTRE_COMPLETION_SEMANTICS */ /* Can compare handles directly on Cray Portals */ -#define PtlHandleIsEqual(a,b) ((a) == (b)) +#define PtlHandleIsEqual(a, b) ((a) == (b)) /* Different error types on Cray Portals*/ #define ptl_err_t ptl_ni_fail_t -- cgit v1.2.3 From f0bd2c4695264f4660190761739dce6393c981b5 Mon Sep 17 00:00:00 2001 From: Joshua Baldock Date: Wed, 2 Apr 2014 19:12:58 +1100 Subject: Staging: lustre: Corrected styling errors reported by checkpatch.pl script on file ptllnd_wire.h Moved '{' from new line to same line as struct as advised by checkpatch.pl script. Signed-off-by: Joshua Baldock Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/lnet/ptllnd_wire.h | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/ptllnd_wire.h b/drivers/staging/lustre/include/linux/lnet/ptllnd_wire.h index 7d12b3a23a96..0d3ec5be0a00 100644 --- a/drivers/staging/lustre/include/linux/lnet/ptllnd_wire.h +++ b/drivers/staging/lustre/include/linux/lnet/ptllnd_wire.h @@ -64,26 +64,22 @@ * above is for bulk data transfer */ #define LNET_MSG_MATCHBITS 0 /* the value for the message channel */ -typedef struct -{ +typedef struct { lnet_hdr_t kptlim_hdr; /* portals header */ char kptlim_payload[0]; /* piggy-backed payload */ } WIRE_ATTR kptl_immediate_msg_t; -typedef struct -{ +typedef struct { lnet_hdr_t kptlrm_hdr; /* portals header */ __u64 kptlrm_matchbits; /* matchbits */ } WIRE_ATTR kptl_rdma_msg_t; -typedef struct -{ +typedef struct { __u64 kptlhm_matchbits; /* matchbits */ __u32 kptlhm_max_msg_size; /* max message size */ } WIRE_ATTR kptl_hello_msg_t; -typedef struct -{ +typedef struct { /* First 2 fields fixed FOR ALL TIME */ __u32 ptlm_magic; /* I'm a Portals LND message */ __u16 ptlm_version; /* this is my version number */ @@ -107,7 +103,7 @@ typedef struct } kptl_msg_t; /* kptl_msg_t::ptlm_credits is only a __u8 */ -#define PTLLND_MSG_MAX_CREDITS ((typeof(((kptl_msg_t*) 0)->ptlm_credits)) -1) +#define PTLLND_MSG_MAX_CREDITS ((typeof(((kptl_msg_t*) 0)->ptlm_credits)) - 1) #define PTLLND_MSG_MAGIC LNET_PROTO_PTL_MAGIC #define PTLLND_MSG_VERSION 0x04 -- cgit v1.2.3 From e4422943832a416cc63a1eee59f2adff42ed56ac Mon Sep 17 00:00:00 2001 From: Joshua Baldock Date: Wed, 2 Apr 2014 19:12:59 +1100 Subject: Staging: lustre: Fixed syntax errors reported by checkpatch.pl script for file types.h Added space after ',' and moved '{' to same line as struct as instructed by checkpatch.pl script. Signed-off-by: Joshua Baldock Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/lnet/types.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/types.h b/drivers/staging/lustre/include/linux/lnet/types.h index b19d98809b57..2add7976b3b2 100644 --- a/drivers/staging/lustre/include/linux/lnet/types.h +++ b/drivers/staging/lustre/include/linux/lnet/types.h @@ -112,7 +112,7 @@ static inline void LNetInvalidateHandle(lnet_handle_any_t *h) */ static inline int LNetHandleIsEqual (lnet_handle_any_t h1, lnet_handle_any_t h2) { - return (h1.cookie == h2.cookie); + return h1.cookie == h2.cookie; } /** @@ -122,7 +122,7 @@ static inline int LNetHandleIsEqual (lnet_handle_any_t h1, lnet_handle_any_t h2) */ static inline int LNetHandleIsInvalid(lnet_handle_any_t h) { - return (LNET_WIRE_HANDLE_COOKIE_NONE == h.cookie); + return LNET_WIRE_HANDLE_COOKIE_NONE == h.cookie; } /** @@ -381,7 +381,7 @@ typedef enum { #define LNET_SEQ_BASETYPE long typedef unsigned LNET_SEQ_BASETYPE lnet_seq_t; -#define LNET_SEQ_GT(a,b) (((signed LNET_SEQ_BASETYPE)((a) - (b))) > 0) +#define LNET_SEQ_GT(a, b) (((signed LNET_SEQ_BASETYPE)((a) - (b))) > 0) /** * Information about an event on a MD. -- cgit v1.2.3 From 81fb955d029927213ddd082bbf57e82f8ba20bd0 Mon Sep 17 00:00:00 2001 From: Denis Pithon Date: Mon, 14 Apr 2014 18:25:30 +0200 Subject: staging/lustre: fix sparse warning Fix sparse complaint: "Using plain integer as NULL pointer" Signed-off-by: Denis Pithon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/sec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index d80418057f29..b0a1c5a0d5cc 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -354,7 +354,7 @@ static int import_sec_check_expire(struct obd_import *imp) return 0; CDEBUG(D_SEC, "found delayed sec adapt expired, do it now\n"); - return sptlrpc_import_sec_adapt(imp, NULL, 0); + return sptlrpc_import_sec_adapt(imp, NULL, NULL); } static int import_sec_validate_get(struct obd_import *imp, -- cgit v1.2.3 From df3c9577f41c90a718616bb83b91fbd30f0eeeb5 Mon Sep 17 00:00:00 2001 From: Daeseok Youn Date: Mon, 7 Apr 2014 11:47:17 +0900 Subject: staging: lustre: use NULL instead of 0 for pointer Signed-off-by: Daeseok Youn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/obd_mount.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index 6f8ba54e9667..419a32361359 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -187,7 +187,7 @@ int lustre_start_simple(char *obdname, char *type, char *uuid, int rc; CDEBUG(D_MOUNT, "Starting obd %s (typ=%s)\n", obdname, type); - rc = do_lcfg(obdname, 0, LCFG_ATTACH, type, uuid, 0, 0); + rc = do_lcfg(obdname, 0, LCFG_ATTACH, type, uuid, NULL, NULL); if (rc) { CERROR("%s attach error %d\n", obdname, rc); return rc; @@ -195,7 +195,7 @@ int lustre_start_simple(char *obdname, char *type, char *uuid, rc = do_lcfg(obdname, 0, LCFG_SETUP, s1, s2, s3, s4); if (rc) { CERROR("%s setup error %d\n", obdname, rc); - do_lcfg(obdname, 0, LCFG_DETACH, 0, 0, 0, 0); + do_lcfg(obdname, 0, LCFG_DETACH, NULL, NULL, NULL, NULL); } return rc; } @@ -337,7 +337,8 @@ int lustre_start_mgc(struct super_block *sb) lnet_process_id_t id; while ((rc = LNetGetId(i++, &id)) != -ENOENT) { rc = do_lcfg(mgcname, id.nid, - LCFG_ADD_UUID, niduuid, 0,0,0); + LCFG_ADD_UUID, niduuid, + NULL, NULL, NULL); } } else { /* Use mgsnode= nids */ @@ -351,7 +352,8 @@ int lustre_start_mgc(struct super_block *sb) } while (class_parse_nid(ptr, &nid, &ptr) == 0) { rc = do_lcfg(mgcname, nid, - LCFG_ADD_UUID, niduuid, 0,0,0); + LCFG_ADD_UUID, niduuid, + NULL, NULL, NULL); i++; } } @@ -360,7 +362,7 @@ int lustre_start_mgc(struct super_block *sb) ptr = lsi->lsi_lmd->lmd_dev; while (class_parse_nid(ptr, &nid, &ptr) == 0) { rc = do_lcfg(mgcname, nid, - LCFG_ADD_UUID, niduuid, 0,0,0); + LCFG_ADD_UUID, niduuid, NULL, NULL, NULL); i++; /* Stop at the first failover nid */ if (*ptr == ':') @@ -396,13 +398,13 @@ int lustre_start_mgc(struct super_block *sb) while (class_parse_nid_quiet(ptr, &nid, &ptr) == 0) { j++; rc = do_lcfg(mgcname, nid, - LCFG_ADD_UUID, niduuid, 0,0,0); + LCFG_ADD_UUID, niduuid, NULL, NULL, NULL); if (*ptr == ':') break; } if (j > 0) { rc = do_lcfg(mgcname, 0, LCFG_ADD_CONN, - niduuid, 0, 0, 0); + niduuid, NULL, NULL, NULL); i++; } else { /* at ":/fsname" */ @@ -532,7 +534,7 @@ static int lustre_stop_mgc(struct super_block *sb) for (i = 0; i < lsi->lsi_lmd->lmd_mgs_failnodes; i++) { sprintf(ptr, "_%x", i); rc = do_lcfg(LUSTRE_MGC_OBDNAME, 0, LCFG_DEL_UUID, - niduuid, 0, 0, 0); + niduuid, NULL, NULL, NULL); if (rc) CERROR("del MDC UUID %s failed: rc = %d\n", niduuid, rc); -- cgit v1.2.3 From d130c00069f53651edf9067baa713fb5044b9b0a Mon Sep 17 00:00:00 2001 From: Mike Sampson Date: Sat, 5 Apr 2014 09:01:25 +1100 Subject: Staging: lustre: mark a variable static in workitem.c This fixes a sparse warning: warning: symbol 'cfs_wi_data' was not declared. Should it be static? Signed-off-by: Mike Sampson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/libcfs/workitem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/libcfs/workitem.c b/drivers/staging/lustre/lustre/libcfs/workitem.c index ba16fd5db704..0a03bf7ba3eb 100644 --- a/drivers/staging/lustre/lustre/libcfs/workitem.c +++ b/drivers/staging/lustre/lustre/libcfs/workitem.c @@ -75,7 +75,7 @@ typedef struct cfs_wi_sched { char ws_name[CFS_WS_NAME_LEN]; } cfs_wi_sched_t; -struct cfs_workitem_data { +static struct cfs_workitem_data { /** serialize */ spinlock_t wi_glock; /** list of all schedulers */ -- cgit v1.2.3 From a6b4699dbfe995cc8e5e6f07d61227a6a36bd5df Mon Sep 17 00:00:00 2001 From: Fabian Mewes Date: Mon, 24 Mar 2014 23:46:31 +0100 Subject: staging: line6: Add blank lines after declarations Use the more common kernel coding style. Signed-off-by: Fabian Mewes Reviewed-by: Stefan Hajnoczi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/line6/driver.c | 1 + drivers/staging/line6/playback.c | 5 +++++ drivers/staging/line6/toneport.c | 1 + 3 files changed, 7 insertions(+) diff --git a/drivers/staging/line6/driver.c b/drivers/staging/line6/driver.c index 77f1b421e957..ef511c76a6e3 100644 --- a/drivers/staging/line6/driver.c +++ b/drivers/staging/line6/driver.c @@ -124,6 +124,7 @@ static int line6_send_raw_message_async_part(struct message *msg, static int line6_start_listen(struct usb_line6 *line6) { int err; + usb_fill_int_urb(line6->urb_listen, line6->usbdev, usb_rcvintpipe(line6->usbdev, line6->ep_control_read), line6->buffer_listen, LINE6_BUFSIZE_LISTEN, diff --git a/drivers/staging/line6/playback.c b/drivers/staging/line6/playback.c index 41869caf19a7..0f72db5665fe 100644 --- a/drivers/staging/line6/playback.c +++ b/drivers/staging/line6/playback.c @@ -34,6 +34,7 @@ static void change_volume(struct urb *urb_out, int volume[], if (bytes_per_frame == 4) { short *p, *buf_end; + p = (short *)urb_out->transfer_buffer; buf_end = p + urb_out->transfer_buffer_length / sizeof(*p); @@ -48,6 +49,7 @@ static void change_volume(struct urb *urb_out, int volume[], for (; p < buf_end; p += 3) { int val; + val = p[0] + (p[1] << 8) + ((signed char)p[2] << 16); val = (val * volume[chn & 1]) >> 8; p[0] = val; @@ -116,6 +118,7 @@ static void add_monitor_signal(struct urb *urb_out, unsigned char *signal, if (bytes_per_frame == 4) { short *pi, *po, *buf_end; + pi = (short *)signal; po = (short *)urb_out->transfer_buffer; buf_end = po + urb_out->transfer_buffer_length / sizeof(*po); @@ -171,6 +174,7 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) if (fsize == 0) { int n; + line6pcm->count_out += frame_increment; n = line6pcm->count_out / frame_factor; line6pcm->count_out -= n * frame_factor; @@ -207,6 +211,7 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) copy the data to the temp buffer. */ int len; + len = runtime->buffer_size - line6pcm->pos_out; if (len > 0) { diff --git a/drivers/staging/line6/toneport.c b/drivers/staging/line6/toneport.c index af2e7e50c135..dcab6478a3b3 100644 --- a/drivers/staging/line6/toneport.c +++ b/drivers/staging/line6/toneport.c @@ -213,6 +213,7 @@ static int snd_toneport_source_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { const int size = ARRAY_SIZE(toneport_source_info); + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; uinfo->count = 1; uinfo->value.enumerated.items = size; -- cgit v1.2.3 From 5565c59e9b1b329f58e7b4a3e307a2bc7c12605c Mon Sep 17 00:00:00 2001 From: "L. Alberto Giménez" Date: Mon, 7 Apr 2014 00:12:30 +0200 Subject: staging/line6: Fix kzalloc coding style issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pass the actual variable to sizeof instead of a type definition. Signed-off-by: L. Alberto Giménez Acked-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- drivers/staging/line6/pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/line6/pcm.c b/drivers/staging/line6/pcm.c index 661080b3c39d..a3136b189ee5 100644 --- a/drivers/staging/line6/pcm.c +++ b/drivers/staging/line6/pcm.c @@ -475,7 +475,7 @@ int line6_init_pcm(struct usb_line6 *line6, MISSING_CASE; } - line6pcm = kzalloc(sizeof(struct snd_line6_pcm), GFP_KERNEL); + line6pcm = kzalloc(sizeof(*line6pcm), GFP_KERNEL); if (line6pcm == NULL) return -ENOMEM; -- cgit v1.2.3 From 449bb8125e3fd260f6b605a61f3df8b186bd5e55 Mon Sep 17 00:00:00 2001 From: Jason Cooper Date: Mon, 24 Mar 2014 01:48:58 +0000 Subject: staging: crypto: skein: import code from Skein3Fish.git This is a byte-for-byte copy of the skein implementation found at: https://github.com/wernerd/Skein3Fish.git Specifically, from the master branch at commit: 00e925444c2c Merge pull request #4 from csm/master The next commit will do the minimum necessary to build this code as a module. I've generated the sha256 sums of the files by: $ (cd drivers/staging/skein; find . -type f | sort | xargs sha256sum) bcd73168e5805b1b157dbf08863e6a8c217a7b270b6be1a361540591b00624e3 ./CMakeLists.txt e1adb97dd9e87bc7c05892ed7863a66d1d9fde6728a97a8b7b092709da664d29 ./include/brg_endian.h 240329b4ca4d829ac4d1490e96e83118e161e719e448c7e8dbf15735ab8a8e87 ./include/brg_types.h 0d8f16438f641fa365844a5991220eb04969f0a19c60dff08e10f521e74db5c3 ./include/skein.h 8f7362796e9e43f7619d51020d6faeedce786492b65bebd2ff6a833b621051cb ./include/skeinApi.h 90510d8a9f686c3bfbf6cf7737237e3fa263c1ed5046b0f19727ba55b9bffeb9 ./include/skein_iv.h 42c6c8eff8f364ee2f0de3177d468dbceba9c6a73222fea473fe6d603213806a ./include/skein_port.h 0154a4b8d54f5aa424b39a7ee668b31f2522b907bf3a8536fe46440b584531a1 ./include/threefishApi.h ac0fc0f95a48a716d30cf02e5adad77af17725a938f939cf94f6dfba42badeca ./skein.c 7af70b177bc63690f68eebceca2dbfef8a4473dcc847ae3525508c65c7d7bcc1 ./skeinApi.c d7ef7330be8253f7f061de3c36880dbc83b0f5d90c8f2b72d3478766f54fbff0 ./skeinBlockNo3F.c 8bb3d7864afc9eab5569949fb2799cb6f14e583ba00641313cf877a5aea1c763 ./skein_block.c 438e6cb59a0090166e8f1e39418c0a2d0036737a32c5e2822c2ed8b803e2132f ./threefish1024Block.c e812ec6f2881300e90c803cfd9d044e954f1ca64faa2fc17a709f56a2f122ff8 ./threefish256Block.c 926f680057e128cdd1feba4a8544c177a74420137af480267b949ae79f3d02b8 ./threefish512Block.c 19357f5d47e7183bc8558a8d0949a3f5a80a931848917d26f36eebb7d205f003 ./threefishApi.c Signed-off-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/CMakeLists.txt | 27 + drivers/staging/skein/include/brg_endian.h | 148 +++ drivers/staging/skein/include/brg_types.h | 188 ++++ drivers/staging/skein/include/skein.h | 327 ++++++ drivers/staging/skein/include/skeinApi.h | 239 +++++ drivers/staging/skein/include/skein_iv.h | 199 ++++ drivers/staging/skein/include/skein_port.h | 124 +++ drivers/staging/skein/include/threefishApi.h | 167 ++++ drivers/staging/skein/skein.c | 742 ++++++++++++++ drivers/staging/skein/skeinApi.c | 221 ++++ drivers/staging/skein/skeinBlockNo3F.c | 172 ++++ drivers/staging/skein/skein_block.c | 689 +++++++++++++ drivers/staging/skein/threefish1024Block.c | 1385 ++++++++++++++++++++++++++ drivers/staging/skein/threefish256Block.c | 349 +++++++ drivers/staging/skein/threefish512Block.c | 643 ++++++++++++ drivers/staging/skein/threefishApi.c | 79 ++ 16 files changed, 5699 insertions(+) create mode 100755 drivers/staging/skein/CMakeLists.txt create mode 100644 drivers/staging/skein/include/brg_endian.h create mode 100644 drivers/staging/skein/include/brg_types.h create mode 100644 drivers/staging/skein/include/skein.h create mode 100755 drivers/staging/skein/include/skeinApi.h create mode 100644 drivers/staging/skein/include/skein_iv.h create mode 100644 drivers/staging/skein/include/skein_port.h create mode 100644 drivers/staging/skein/include/threefishApi.h create mode 100644 drivers/staging/skein/skein.c create mode 100755 drivers/staging/skein/skeinApi.c create mode 100644 drivers/staging/skein/skeinBlockNo3F.c create mode 100644 drivers/staging/skein/skein_block.c create mode 100644 drivers/staging/skein/threefish1024Block.c create mode 100644 drivers/staging/skein/threefish256Block.c create mode 100644 drivers/staging/skein/threefish512Block.c create mode 100644 drivers/staging/skein/threefishApi.c diff --git a/drivers/staging/skein/CMakeLists.txt b/drivers/staging/skein/CMakeLists.txt new file mode 100755 index 000000000000..604aaa394cb1 --- /dev/null +++ b/drivers/staging/skein/CMakeLists.txt @@ -0,0 +1,27 @@ +cmake_minimum_required (VERSION 2.6) + +include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) + +# set(skeinBlock_src skein_block.c) +set(skeinBlock_src skeinBlockNo3F.c) + +set(skein_src + ${skeinBlock_src} + skein.c + skeinApi.c + ) + +set(threefish_src + threefishApi.c + threefish256Block.c + threefish512Block.c + threefish1024Block.c + ) +set(s3f_src ${skein_src} ${threefish_src}) + +add_library(skein3fish SHARED ${s3f_src}) +set_target_properties(skein3fish PROPERTIES VERSION ${VERSION} SOVERSION ${SOVERSION}) +target_link_libraries(skein3fish ${LIBS}) + +install(TARGETS skein3fish DESTINATION ${LIBDIRNAME}) + diff --git a/drivers/staging/skein/include/brg_endian.h b/drivers/staging/skein/include/brg_endian.h new file mode 100644 index 000000000000..978eb33f08cf --- /dev/null +++ b/drivers/staging/skein/include/brg_endian.h @@ -0,0 +1,148 @@ +/* + --------------------------------------------------------------------------- + Copyright (c) 2003, Dr Brian Gladman, Worcester, UK. All rights reserved. + + LICENSE TERMS + + The free distribution and use of this software in both source and binary + form is allowed (with or without changes) provided that: + + 1. distributions of this source code include the above copyright + notice, this list of conditions and the following disclaimer; + + 2. distributions in binary form include the above copyright + notice, this list of conditions and the following disclaimer + in the documentation and/or other associated materials; + + 3. the copyright holder's name is not used to endorse products + built using this software without specific written permission. + + ALTERNATIVELY, provided that this notice is retained in full, this product + may be distributed under the terms of the GNU General Public License (GPL), + in which case the provisions of the GPL apply INSTEAD OF those given above. + + DISCLAIMER + + This software is provided 'as is' with no explicit or implied warranties + in respect of its properties, including, but not limited to, correctness + and/or fitness for purpose. + --------------------------------------------------------------------------- + Issue 20/10/2006 +*/ + +#ifndef BRG_ENDIAN_H +#define BRG_ENDIAN_H + +#define IS_BIG_ENDIAN 4321 /* byte 0 is most significant (mc68k) */ +#define IS_LITTLE_ENDIAN 1234 /* byte 0 is least significant (i386) */ + +/* Include files where endian defines and byteswap functions may reside */ +#if defined( __FreeBSD__ ) || defined( __OpenBSD__ ) || defined( __NetBSD__ ) +# include +#elif defined( BSD ) && ( BSD >= 199103 ) || defined( __APPLE__ ) || \ + defined( __CYGWIN32__ ) || defined( __DJGPP__ ) || defined( __osf__ ) +# include +#elif defined( __linux__ ) || defined( __GNUC__ ) || defined( __GNU_LIBRARY__ ) +# if !defined( __MINGW32__ ) && !defined(AVR) +# include +# if !defined( __BEOS__ ) +# include +# endif +# endif +#endif + +/* Now attempt to set the define for platform byte order using any */ +/* of the four forms SYMBOL, _SYMBOL, __SYMBOL & __SYMBOL__, which */ +/* seem to encompass most endian symbol definitions */ + +#if defined( BIG_ENDIAN ) && defined( LITTLE_ENDIAN ) +# if defined( BYTE_ORDER ) && BYTE_ORDER == BIG_ENDIAN +# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN +# elif defined( BYTE_ORDER ) && BYTE_ORDER == LITTLE_ENDIAN +# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN +# endif +#elif defined( BIG_ENDIAN ) +# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN +#elif defined( LITTLE_ENDIAN ) +# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN +#endif + +#if defined( _BIG_ENDIAN ) && defined( _LITTLE_ENDIAN ) +# if defined( _BYTE_ORDER ) && _BYTE_ORDER == _BIG_ENDIAN +# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN +# elif defined( _BYTE_ORDER ) && _BYTE_ORDER == _LITTLE_ENDIAN +# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN +# endif +#elif defined( _BIG_ENDIAN ) +# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN +#elif defined( _LITTLE_ENDIAN ) +# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN +#endif + +#if defined( __BIG_ENDIAN ) && defined( __LITTLE_ENDIAN ) +# if defined( __BYTE_ORDER ) && __BYTE_ORDER == __BIG_ENDIAN +# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN +# elif defined( __BYTE_ORDER ) && __BYTE_ORDER == __LITTLE_ENDIAN +# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN +# endif +#elif defined( __BIG_ENDIAN ) +# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN +#elif defined( __LITTLE_ENDIAN ) +# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN +#endif + +#if defined( __BIG_ENDIAN__ ) && defined( __LITTLE_ENDIAN__ ) +# if defined( __BYTE_ORDER__ ) && __BYTE_ORDER__ == __BIG_ENDIAN__ +# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN +# elif defined( __BYTE_ORDER__ ) && __BYTE_ORDER__ == __LITTLE_ENDIAN__ +# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN +# endif +#elif defined( __BIG_ENDIAN__ ) +# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN +#elif defined( __LITTLE_ENDIAN__ ) +# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN +#endif + +/* if the platform byte order could not be determined, then try to */ +/* set this define using common machine defines */ +#if !defined(PLATFORM_BYTE_ORDER) + +#if defined( __alpha__ ) || defined( __alpha ) || defined( i386 ) || \ + defined( __i386__ ) || defined( _M_I86 ) || defined( _M_IX86 ) || \ + defined( __OS2__ ) || defined( sun386 ) || defined( __TURBOC__ ) || \ + defined( vax ) || defined( vms ) || defined( VMS ) || \ + defined( __VMS ) || defined( _M_X64 ) || defined( AVR ) +# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN + +#elif defined( AMIGA ) || defined( applec ) || defined( __AS400__ ) || \ + defined( _CRAY ) || defined( __hppa ) || defined( __hp9000 ) || \ + defined( ibm370 ) || defined( mc68000 ) || defined( m68k ) || \ + defined( __MRC__ ) || defined( __MVS__ ) || defined( __MWERKS__ ) || \ + defined( sparc ) || defined( __sparc) || defined( SYMANTEC_C ) || \ + defined( __VOS__ ) || defined( __TIGCC__ ) || defined( __TANDEM ) || \ + defined( THINK_C ) || defined( __VMCMS__ ) +# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN + +#elif 0 /* **** EDIT HERE IF NECESSARY **** */ +# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN +#elif 0 /* **** EDIT HERE IF NECESSARY **** */ +# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN +#else +# error Please edit lines 126 or 128 in brg_endian.h to set the platform byte order +#endif +#endif + +/* special handler for IA64, which may be either endianness (?) */ +/* here we assume little-endian, but this may need to be changed */ +#if defined(__ia64) || defined(__ia64__) || defined(_M_IA64) +# define PLATFORM_MUST_ALIGN (1) +#ifndef PLATFORM_BYTE_ORDER +# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN +#endif +#endif + +#ifndef PLATFORM_MUST_ALIGN +# define PLATFORM_MUST_ALIGN (0) +#endif + +#endif /* ifndef BRG_ENDIAN_H */ diff --git a/drivers/staging/skein/include/brg_types.h b/drivers/staging/skein/include/brg_types.h new file mode 100644 index 000000000000..d6d6cdab9fbf --- /dev/null +++ b/drivers/staging/skein/include/brg_types.h @@ -0,0 +1,188 @@ +/* + --------------------------------------------------------------------------- + Copyright (c) 1998-2006, Brian Gladman, Worcester, UK. All rights reserved. + + LICENSE TERMS + + The free distribution and use of this software in both source and binary + form is allowed (with or without changes) provided that: + + 1. distributions of this source code include the above copyright + notice, this list of conditions and the following disclaimer; + + 2. distributions in binary form include the above copyright + notice, this list of conditions and the following disclaimer + in the documentation and/or other associated materials; + + 3. the copyright holder's name is not used to endorse products + built using this software without specific written permission. + + ALTERNATIVELY, provided that this notice is retained in full, this product + may be distributed under the terms of the GNU General Public License (GPL), + in which case the provisions of the GPL apply INSTEAD OF those given above. + + DISCLAIMER + + This software is provided 'as is' with no explicit or implied warranties + in respect of its properties, including, but not limited to, correctness + and/or fitness for purpose. + --------------------------------------------------------------------------- + Issue 09/09/2006 + + The unsigned integer types defined here are of the form uint_t where + is the length of the type; for example, the unsigned 32-bit type is + 'uint_32t'. These are NOT the same as the 'C99 integer types' that are + defined in the inttypes.h and stdint.h headers since attempts to use these + types have shown that support for them is still highly variable. However, + since the latter are of the form uint_t, a regular expression search + and replace (in VC++ search on 'uint_{:z}t' and replace with 'uint\1_t') + can be used to convert the types used here to the C99 standard types. +*/ + +#ifndef BRG_TYPES_H +#define BRG_TYPES_H + +#if defined(__cplusplus) +extern "C" { +#endif + +#include + +#ifndef BRG_UI8 +# define BRG_UI8 +# if UCHAR_MAX == 255u + typedef unsigned char uint_8t; +# else +# error Please define uint_8t as an 8-bit unsigned integer type in brg_types.h +# endif +#endif + +#ifndef BRG_UI16 +# define BRG_UI16 +# if USHRT_MAX == 65535u + typedef unsigned short uint_16t; +# else +# error Please define uint_16t as a 16-bit unsigned short type in brg_types.h +# endif +#endif + +#ifndef BRG_UI32 +# define BRG_UI32 +# if UINT_MAX == 4294967295u +# define li_32(h) 0x##h##u + typedef unsigned int uint_32t; +# elif ULONG_MAX == 4294967295u +# define li_32(h) 0x##h##ul + typedef unsigned long uint_32t; +# elif defined( _CRAY ) +# error This code needs 32-bit data types, which Cray machines do not provide +# else +# error Please define uint_32t as a 32-bit unsigned integer type in brg_types.h +# endif +#endif + +#ifndef BRG_UI64 +# if defined( __BORLANDC__ ) && !defined( __MSDOS__ ) +# define BRG_UI64 +# define li_64(h) 0x##h##ui64 + typedef unsigned __int64 uint_64t; +# elif defined( _MSC_VER ) && ( _MSC_VER < 1300 ) /* 1300 == VC++ 7.0 */ +# define BRG_UI64 +# define li_64(h) 0x##h##ui64 + typedef unsigned __int64 uint_64t; +# elif defined( __sun ) && defined(ULONG_MAX) && ULONG_MAX == 0xfffffffful +# define BRG_UI64 +# define li_64(h) 0x##h##ull + typedef unsigned long long uint_64t; +# elif defined( UINT_MAX ) && UINT_MAX > 4294967295u +# if UINT_MAX == 18446744073709551615u +# define BRG_UI64 +# define li_64(h) 0x##h##u + typedef unsigned int uint_64t; +# endif +# elif defined( ULONG_MAX ) && ULONG_MAX > 4294967295u +# if ULONG_MAX == 18446744073709551615ul +# define BRG_UI64 +# define li_64(h) 0x##h##ul + typedef unsigned long uint_64t; +# endif +# elif defined( ULLONG_MAX ) && ULLONG_MAX > 4294967295u +# if ULLONG_MAX == 18446744073709551615ull +# define BRG_UI64 +# define li_64(h) 0x##h##ull + typedef unsigned long long uint_64t; +# endif +# elif defined( ULONG_LONG_MAX ) && ULONG_LONG_MAX > 4294967295u +# if ULONG_LONG_MAX == 18446744073709551615ull +# define BRG_UI64 +# define li_64(h) 0x##h##ull + typedef unsigned long long uint_64t; +# endif +# elif defined(__GNUC__) /* DLW: avoid mingw problem with -ansi */ +# define BRG_UI64 +# define li_64(h) 0x##h##ull + typedef unsigned long long uint_64t; +# endif +#endif + +#if defined( NEED_UINT_64T ) && !defined( BRG_UI64 ) +# error Please define uint_64t as an unsigned 64 bit type in brg_types.h +#endif + +#ifndef RETURN_VALUES +# define RETURN_VALUES +# if defined( DLL_EXPORT ) +# if defined( _MSC_VER ) || defined ( __INTEL_COMPILER ) +# define VOID_RETURN __declspec( dllexport ) void __stdcall +# define INT_RETURN __declspec( dllexport ) int __stdcall +# elif defined( __GNUC__ ) +# define VOID_RETURN __declspec( __dllexport__ ) void +# define INT_RETURN __declspec( __dllexport__ ) int +# else +# error Use of the DLL is only available on the Microsoft, Intel and GCC compilers +# endif +# elif defined( DLL_IMPORT ) +# if defined( _MSC_VER ) || defined ( __INTEL_COMPILER ) +# define VOID_RETURN __declspec( dllimport ) void __stdcall +# define INT_RETURN __declspec( dllimport ) int __stdcall +# elif defined( __GNUC__ ) +# define VOID_RETURN __declspec( __dllimport__ ) void +# define INT_RETURN __declspec( __dllimport__ ) int +# else +# error Use of the DLL is only available on the Microsoft, Intel and GCC compilers +# endif +# elif defined( __WATCOMC__ ) +# define VOID_RETURN void __cdecl +# define INT_RETURN int __cdecl +# else +# define VOID_RETURN void +# define INT_RETURN int +# endif +#endif + +/* These defines are used to declare buffers in a way that allows + faster operations on longer variables to be used. In all these + defines 'size' must be a power of 2 and >= 8 + + dec_unit_type(size,x) declares a variable 'x' of length + 'size' bits + + dec_bufr_type(size,bsize,x) declares a buffer 'x' of length 'bsize' + bytes defined as an array of variables + each of 'size' bits (bsize must be a + multiple of size / 8) + + ptr_cast(x,size) casts a pointer to a pointer to a + varaiable of length 'size' bits +*/ + +#define ui_type(size) uint_##size##t +#define dec_unit_type(size,x) typedef ui_type(size) x +#define dec_bufr_type(size,bsize,x) typedef ui_type(size) x[bsize / (size >> 3)] +#define ptr_cast(x,size) ((ui_type(size)*)(x)) + +#if defined(__cplusplus) +} +#endif + +#endif diff --git a/drivers/staging/skein/include/skein.h b/drivers/staging/skein/include/skein.h new file mode 100644 index 000000000000..f62d0deed17e --- /dev/null +++ b/drivers/staging/skein/include/skein.h @@ -0,0 +1,327 @@ +#ifndef _SKEIN_H_ +#define _SKEIN_H_ 1 +/************************************************************************** +** +** Interface declarations and internal definitions for Skein hashing. +** +** Source code author: Doug Whiting, 2008. +** +** This algorithm and source code is released to the public domain. +** +*************************************************************************** +** +** The following compile-time switches may be defined to control some +** tradeoffs between speed, code size, error checking, and security. +** +** The "default" note explains what happens when the switch is not defined. +** +** SKEIN_DEBUG -- make callouts from inside Skein code +** to examine/display intermediate values. +** [default: no callouts (no overhead)] +** +** SKEIN_ERR_CHECK -- how error checking is handled inside Skein +** code. If not defined, most error checking +** is disabled (for performance). Otherwise, +** the switch value is interpreted as: +** 0: use assert() to flag errors +** 1: return SKEIN_FAIL to flag errors +** +***************************************************************************/ +#ifdef __cplusplus +extern "C" +{ +#endif + +#include /* get size_t definition */ +#include /* get platform-specific definitions */ + +enum + { + SKEIN_SUCCESS = 0, /* return codes from Skein calls */ + SKEIN_FAIL = 1, + SKEIN_BAD_HASHLEN = 2 + }; + +#define SKEIN_MODIFIER_WORDS ( 2) /* number of modifier (tweak) words */ + +#define SKEIN_256_STATE_WORDS ( 4) +#define SKEIN_512_STATE_WORDS ( 8) +#define SKEIN1024_STATE_WORDS (16) +#define SKEIN_MAX_STATE_WORDS (16) + +#define SKEIN_256_STATE_BYTES ( 8*SKEIN_256_STATE_WORDS) +#define SKEIN_512_STATE_BYTES ( 8*SKEIN_512_STATE_WORDS) +#define SKEIN1024_STATE_BYTES ( 8*SKEIN1024_STATE_WORDS) + +#define SKEIN_256_STATE_BITS (64*SKEIN_256_STATE_WORDS) +#define SKEIN_512_STATE_BITS (64*SKEIN_512_STATE_WORDS) +#define SKEIN1024_STATE_BITS (64*SKEIN1024_STATE_WORDS) + +#define SKEIN_256_BLOCK_BYTES ( 8*SKEIN_256_STATE_WORDS) +#define SKEIN_512_BLOCK_BYTES ( 8*SKEIN_512_STATE_WORDS) +#define SKEIN1024_BLOCK_BYTES ( 8*SKEIN1024_STATE_WORDS) + +typedef struct + { + size_t hashBitLen; /* size of hash result, in bits */ + size_t bCnt; /* current byte count in buffer b[] */ + u64b_t T[SKEIN_MODIFIER_WORDS]; /* tweak words: T[0]=byte cnt, T[1]=flags */ + } Skein_Ctxt_Hdr_t; + +typedef struct /* 256-bit Skein hash context structure */ + { + Skein_Ctxt_Hdr_t h; /* common header context variables */ + u64b_t X[SKEIN_256_STATE_WORDS]; /* chaining variables */ + u08b_t b[SKEIN_256_BLOCK_BYTES]; /* partial block buffer (8-byte aligned) */ + } Skein_256_Ctxt_t; + +typedef struct /* 512-bit Skein hash context structure */ + { + Skein_Ctxt_Hdr_t h; /* common header context variables */ + u64b_t X[SKEIN_512_STATE_WORDS]; /* chaining variables */ + u08b_t b[SKEIN_512_BLOCK_BYTES]; /* partial block buffer (8-byte aligned) */ + } Skein_512_Ctxt_t; + +typedef struct /* 1024-bit Skein hash context structure */ + { + Skein_Ctxt_Hdr_t h; /* common header context variables */ + u64b_t X[SKEIN1024_STATE_WORDS]; /* chaining variables */ + u08b_t b[SKEIN1024_BLOCK_BYTES]; /* partial block buffer (8-byte aligned) */ + } Skein1024_Ctxt_t; + +/* Skein APIs for (incremental) "straight hashing" */ +int Skein_256_Init (Skein_256_Ctxt_t *ctx, size_t hashBitLen); +int Skein_512_Init (Skein_512_Ctxt_t *ctx, size_t hashBitLen); +int Skein1024_Init (Skein1024_Ctxt_t *ctx, size_t hashBitLen); + +int Skein_256_Update(Skein_256_Ctxt_t *ctx, const u08b_t *msg, size_t msgByteCnt); +int Skein_512_Update(Skein_512_Ctxt_t *ctx, const u08b_t *msg, size_t msgByteCnt); +int Skein1024_Update(Skein1024_Ctxt_t *ctx, const u08b_t *msg, size_t msgByteCnt); + +int Skein_256_Final (Skein_256_Ctxt_t *ctx, u08b_t * hashVal); +int Skein_512_Final (Skein_512_Ctxt_t *ctx, u08b_t * hashVal); +int Skein1024_Final (Skein1024_Ctxt_t *ctx, u08b_t * hashVal); + +/* +** Skein APIs for "extended" initialization: MAC keys, tree hashing. +** After an InitExt() call, just use Update/Final calls as with Init(). +** +** Notes: Same parameters as _Init() calls, plus treeInfo/key/keyBytes. +** When keyBytes == 0 and treeInfo == SKEIN_SEQUENTIAL, +** the results of InitExt() are identical to calling Init(). +** The function Init() may be called once to "precompute" the IV for +** a given hashBitLen value, then by saving a copy of the context +** the IV computation may be avoided in later calls. +** Similarly, the function InitExt() may be called once per MAC key +** to precompute the MAC IV, then a copy of the context saved and +** reused for each new MAC computation. +**/ +int Skein_256_InitExt(Skein_256_Ctxt_t *ctx, size_t hashBitLen, u64b_t treeInfo, const u08b_t *key, size_t keyBytes); +int Skein_512_InitExt(Skein_512_Ctxt_t *ctx, size_t hashBitLen, u64b_t treeInfo, const u08b_t *key, size_t keyBytes); +int Skein1024_InitExt(Skein1024_Ctxt_t *ctx, size_t hashBitLen, u64b_t treeInfo, const u08b_t *key, size_t keyBytes); + +/* +** Skein APIs for MAC and tree hash: +** Final_Pad: pad, do final block, but no OUTPUT type +** Output: do just the output stage +*/ +int Skein_256_Final_Pad(Skein_256_Ctxt_t *ctx, u08b_t * hashVal); +int Skein_512_Final_Pad(Skein_512_Ctxt_t *ctx, u08b_t * hashVal); +int Skein1024_Final_Pad(Skein1024_Ctxt_t *ctx, u08b_t * hashVal); + +#ifndef SKEIN_TREE_HASH +#define SKEIN_TREE_HASH (1) +#endif +#if SKEIN_TREE_HASH +int Skein_256_Output (Skein_256_Ctxt_t *ctx, u08b_t * hashVal); +int Skein_512_Output (Skein_512_Ctxt_t *ctx, u08b_t * hashVal); +int Skein1024_Output (Skein1024_Ctxt_t *ctx, u08b_t * hashVal); +#endif + +/***************************************************************** +** "Internal" Skein definitions +** -- not needed for sequential hashing API, but will be +** helpful for other uses of Skein (e.g., tree hash mode). +** -- included here so that they can be shared between +** reference and optimized code. +******************************************************************/ + +/* tweak word T[1]: bit field starting positions */ +#define SKEIN_T1_BIT(BIT) ((BIT) - 64) /* offset 64 because it's the second word */ + +#define SKEIN_T1_POS_TREE_LVL SKEIN_T1_BIT(112) /* bits 112..118: level in hash tree */ +#define SKEIN_T1_POS_BIT_PAD SKEIN_T1_BIT(119) /* bit 119 : partial final input byte */ +#define SKEIN_T1_POS_BLK_TYPE SKEIN_T1_BIT(120) /* bits 120..125: type field */ +#define SKEIN_T1_POS_FIRST SKEIN_T1_BIT(126) /* bits 126 : first block flag */ +#define SKEIN_T1_POS_FINAL SKEIN_T1_BIT(127) /* bit 127 : final block flag */ + +/* tweak word T[1]: flag bit definition(s) */ +#define SKEIN_T1_FLAG_FIRST (((u64b_t) 1 ) << SKEIN_T1_POS_FIRST) +#define SKEIN_T1_FLAG_FINAL (((u64b_t) 1 ) << SKEIN_T1_POS_FINAL) +#define SKEIN_T1_FLAG_BIT_PAD (((u64b_t) 1 ) << SKEIN_T1_POS_BIT_PAD) + +/* tweak word T[1]: tree level bit field mask */ +#define SKEIN_T1_TREE_LVL_MASK (((u64b_t)0x7F) << SKEIN_T1_POS_TREE_LVL) +#define SKEIN_T1_TREE_LEVEL(n) (((u64b_t) (n)) << SKEIN_T1_POS_TREE_LVL) + +/* tweak word T[1]: block type field */ +#define SKEIN_BLK_TYPE_KEY ( 0) /* key, for MAC and KDF */ +#define SKEIN_BLK_TYPE_CFG ( 4) /* configuration block */ +#define SKEIN_BLK_TYPE_PERS ( 8) /* personalization string */ +#define SKEIN_BLK_TYPE_PK (12) /* public key (for digital signature hashing) */ +#define SKEIN_BLK_TYPE_KDF (16) /* key identifier for KDF */ +#define SKEIN_BLK_TYPE_NONCE (20) /* nonce for PRNG */ +#define SKEIN_BLK_TYPE_MSG (48) /* message processing */ +#define SKEIN_BLK_TYPE_OUT (63) /* output stage */ +#define SKEIN_BLK_TYPE_MASK (63) /* bit field mask */ + +#define SKEIN_T1_BLK_TYPE(T) (((u64b_t) (SKEIN_BLK_TYPE_##T)) << SKEIN_T1_POS_BLK_TYPE) +#define SKEIN_T1_BLK_TYPE_KEY SKEIN_T1_BLK_TYPE(KEY) /* key, for MAC and KDF */ +#define SKEIN_T1_BLK_TYPE_CFG SKEIN_T1_BLK_TYPE(CFG) /* configuration block */ +#define SKEIN_T1_BLK_TYPE_PERS SKEIN_T1_BLK_TYPE(PERS) /* personalization string */ +#define SKEIN_T1_BLK_TYPE_PK SKEIN_T1_BLK_TYPE(PK) /* public key (for digital signature hashing) */ +#define SKEIN_T1_BLK_TYPE_KDF SKEIN_T1_BLK_TYPE(KDF) /* key identifier for KDF */ +#define SKEIN_T1_BLK_TYPE_NONCE SKEIN_T1_BLK_TYPE(NONCE)/* nonce for PRNG */ +#define SKEIN_T1_BLK_TYPE_MSG SKEIN_T1_BLK_TYPE(MSG) /* message processing */ +#define SKEIN_T1_BLK_TYPE_OUT SKEIN_T1_BLK_TYPE(OUT) /* output stage */ +#define SKEIN_T1_BLK_TYPE_MASK SKEIN_T1_BLK_TYPE(MASK) /* field bit mask */ + +#define SKEIN_T1_BLK_TYPE_CFG_FINAL (SKEIN_T1_BLK_TYPE_CFG | SKEIN_T1_FLAG_FINAL) +#define SKEIN_T1_BLK_TYPE_OUT_FINAL (SKEIN_T1_BLK_TYPE_OUT | SKEIN_T1_FLAG_FINAL) + +#define SKEIN_VERSION (1) + +#ifndef SKEIN_ID_STRING_LE /* allow compile-time personalization */ +#define SKEIN_ID_STRING_LE (0x33414853) /* "SHA3" (little-endian)*/ +#endif + +#define SKEIN_MK_64(hi32,lo32) ((lo32) + (((u64b_t) (hi32)) << 32)) +#define SKEIN_SCHEMA_VER SKEIN_MK_64(SKEIN_VERSION,SKEIN_ID_STRING_LE) +#define SKEIN_KS_PARITY SKEIN_MK_64(0x1BD11BDA,0xA9FC1A22) + +#define SKEIN_CFG_STR_LEN (4*8) + +/* bit field definitions in config block treeInfo word */ +#define SKEIN_CFG_TREE_LEAF_SIZE_POS ( 0) +#define SKEIN_CFG_TREE_NODE_SIZE_POS ( 8) +#define SKEIN_CFG_TREE_MAX_LEVEL_POS (16) + +#define SKEIN_CFG_TREE_LEAF_SIZE_MSK (((u64b_t) 0xFF) << SKEIN_CFG_TREE_LEAF_SIZE_POS) +#define SKEIN_CFG_TREE_NODE_SIZE_MSK (((u64b_t) 0xFF) << SKEIN_CFG_TREE_NODE_SIZE_POS) +#define SKEIN_CFG_TREE_MAX_LEVEL_MSK (((u64b_t) 0xFF) << SKEIN_CFG_TREE_MAX_LEVEL_POS) + +#define SKEIN_CFG_TREE_INFO(leaf,node,maxLvl) \ + ( (((u64b_t)(leaf )) << SKEIN_CFG_TREE_LEAF_SIZE_POS) | \ + (((u64b_t)(node )) << SKEIN_CFG_TREE_NODE_SIZE_POS) | \ + (((u64b_t)(maxLvl)) << SKEIN_CFG_TREE_MAX_LEVEL_POS) ) + +#define SKEIN_CFG_TREE_INFO_SEQUENTIAL SKEIN_CFG_TREE_INFO(0,0,0) /* use as treeInfo in InitExt() call for sequential processing */ + +/* +** Skein macros for getting/setting tweak words, etc. +** These are useful for partial input bytes, hash tree init/update, etc. +**/ +#define Skein_Get_Tweak(ctxPtr,TWK_NUM) ((ctxPtr)->h.T[TWK_NUM]) +#define Skein_Set_Tweak(ctxPtr,TWK_NUM,tVal) {(ctxPtr)->h.T[TWK_NUM] = (tVal);} + +#define Skein_Get_T0(ctxPtr) Skein_Get_Tweak(ctxPtr,0) +#define Skein_Get_T1(ctxPtr) Skein_Get_Tweak(ctxPtr,1) +#define Skein_Set_T0(ctxPtr,T0) Skein_Set_Tweak(ctxPtr,0,T0) +#define Skein_Set_T1(ctxPtr,T1) Skein_Set_Tweak(ctxPtr,1,T1) + +/* set both tweak words at once */ +#define Skein_Set_T0_T1(ctxPtr,T0,T1) \ + { \ + Skein_Set_T0(ctxPtr,(T0)); \ + Skein_Set_T1(ctxPtr,(T1)); \ + } + +#define Skein_Set_Type(ctxPtr,BLK_TYPE) \ + Skein_Set_T1(ctxPtr,SKEIN_T1_BLK_TYPE_##BLK_TYPE) + +/* set up for starting with a new type: h.T[0]=0; h.T[1] = NEW_TYPE; h.bCnt=0; */ +#define Skein_Start_New_Type(ctxPtr,BLK_TYPE) \ + { Skein_Set_T0_T1(ctxPtr,0,SKEIN_T1_FLAG_FIRST | SKEIN_T1_BLK_TYPE_##BLK_TYPE); (ctxPtr)->h.bCnt=0; } + +#define Skein_Clear_First_Flag(hdr) { (hdr).T[1] &= ~SKEIN_T1_FLAG_FIRST; } +#define Skein_Set_Bit_Pad_Flag(hdr) { (hdr).T[1] |= SKEIN_T1_FLAG_BIT_PAD; } + +#define Skein_Set_Tree_Level(hdr,height) { (hdr).T[1] |= SKEIN_T1_TREE_LEVEL(height);} + +/***************************************************************** +** "Internal" Skein definitions for debugging and error checking +******************************************************************/ +#ifdef SKEIN_DEBUG /* examine/display intermediate values? */ +#include "skein_debug.h" +#else /* default is no callouts */ +#define Skein_Show_Block(bits,ctx,X,blkPtr,wPtr,ksEvenPtr,ksOddPtr) +#define Skein_Show_Round(bits,ctx,r,X) +#define Skein_Show_R_Ptr(bits,ctx,r,X_ptr) +#define Skein_Show_Final(bits,ctx,cnt,outPtr) +#define Skein_Show_Key(bits,ctx,key,keyBytes) +#endif + +#ifndef SKEIN_ERR_CHECK /* run-time checks (e.g., bad params, uninitialized context)? */ +#define Skein_Assert(x,retCode)/* default: ignore all Asserts, for performance */ +#define Skein_assert(x) +#elif defined(SKEIN_ASSERT) +#include +#define Skein_Assert(x,retCode) assert(x) +#define Skein_assert(x) assert(x) +#else +#include +#define Skein_Assert(x,retCode) { if (!(x)) return retCode; } /* caller error */ +#define Skein_assert(x) assert(x) /* internal error */ +#endif + +/***************************************************************** +** Skein block function constants (shared across Ref and Opt code) +******************************************************************/ +enum + { + /* Skein_256 round rotation constants */ + R_256_0_0=14, R_256_0_1=16, + R_256_1_0=52, R_256_1_1=57, + R_256_2_0=23, R_256_2_1=40, + R_256_3_0= 5, R_256_3_1=37, + R_256_4_0=25, R_256_4_1=33, + R_256_5_0=46, R_256_5_1=12, + R_256_6_0=58, R_256_6_1=22, + R_256_7_0=32, R_256_7_1=32, + + /* Skein_512 round rotation constants */ + R_512_0_0=46, R_512_0_1=36, R_512_0_2=19, R_512_0_3=37, + R_512_1_0=33, R_512_1_1=27, R_512_1_2=14, R_512_1_3=42, + R_512_2_0=17, R_512_2_1=49, R_512_2_2=36, R_512_2_3=39, + R_512_3_0=44, R_512_3_1= 9, R_512_3_2=54, R_512_3_3=56, + R_512_4_0=39, R_512_4_1=30, R_512_4_2=34, R_512_4_3=24, + R_512_5_0=13, R_512_5_1=50, R_512_5_2=10, R_512_5_3=17, + R_512_6_0=25, R_512_6_1=29, R_512_6_2=39, R_512_6_3=43, + R_512_7_0= 8, R_512_7_1=35, R_512_7_2=56, R_512_7_3=22, + + /* Skein1024 round rotation constants */ + R1024_0_0=24, R1024_0_1=13, R1024_0_2= 8, R1024_0_3=47, R1024_0_4= 8, R1024_0_5=17, R1024_0_6=22, R1024_0_7=37, + R1024_1_0=38, R1024_1_1=19, R1024_1_2=10, R1024_1_3=55, R1024_1_4=49, R1024_1_5=18, R1024_1_6=23, R1024_1_7=52, + R1024_2_0=33, R1024_2_1= 4, R1024_2_2=51, R1024_2_3=13, R1024_2_4=34, R1024_2_5=41, R1024_2_6=59, R1024_2_7=17, + R1024_3_0= 5, R1024_3_1=20, R1024_3_2=48, R1024_3_3=41, R1024_3_4=47, R1024_3_5=28, R1024_3_6=16, R1024_3_7=25, + R1024_4_0=41, R1024_4_1= 9, R1024_4_2=37, R1024_4_3=31, R1024_4_4=12, R1024_4_5=47, R1024_4_6=44, R1024_4_7=30, + R1024_5_0=16, R1024_5_1=34, R1024_5_2=56, R1024_5_3=51, R1024_5_4= 4, R1024_5_5=53, R1024_5_6=42, R1024_5_7=41, + R1024_6_0=31, R1024_6_1=44, R1024_6_2=47, R1024_6_3=46, R1024_6_4=19, R1024_6_5=42, R1024_6_6=44, R1024_6_7=25, + R1024_7_0= 9, R1024_7_1=48, R1024_7_2=35, R1024_7_3=52, R1024_7_4=23, R1024_7_5=31, R1024_7_6=37, R1024_7_7=20 + }; + +#ifndef SKEIN_ROUNDS +#define SKEIN_256_ROUNDS_TOTAL (72) /* number of rounds for the different block sizes */ +#define SKEIN_512_ROUNDS_TOTAL (72) +#define SKEIN1024_ROUNDS_TOTAL (80) +#else /* allow command-line define in range 8*(5..14) */ +#define SKEIN_256_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS/100) + 5) % 10) + 5)) +#define SKEIN_512_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS/ 10) + 5) % 10) + 5)) +#define SKEIN1024_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS ) + 5) % 10) + 5)) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef _SKEIN_H_ */ diff --git a/drivers/staging/skein/include/skeinApi.h b/drivers/staging/skein/include/skeinApi.h new file mode 100755 index 000000000000..19c3225460fc --- /dev/null +++ b/drivers/staging/skein/include/skeinApi.h @@ -0,0 +1,239 @@ +/* +Copyright (c) 2010 Werner Dittmann + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef SKEINAPI_H +#define SKEINAPI_H + +/** + * @file skeinApi.h + * @brief A Skein API and its functions. + * @{ + * + * This API and the functions that implement this API simplify the usage + * of Skein. The design and the way to use the functions follow the openSSL + * design but at the same time take care of some Skein specific behaviour + * and possibilities. + * + * The functions enable applications to create a normal Skein hashes and + * message authentication codes (MAC). + * + * Using these functions is simple and straight forward: + * + * @code + * + * #include + * + * ... + * SkeinCtx_t ctx; // a Skein hash or MAC context + * + * // prepare context, here for a Skein with a state size of 512 bits. + * skeinCtxPrepare(&ctx, Skein512); + * + * // Initialize the context to set the requested hash length in bits + * // here request a output hash size of 31 bits (Skein supports variable + * // output sizes even very strange sizes) + * skeinInit(&ctx, 31); + * + * // Now update Skein with any number of message bits. A function that + * // takes a number of bytes is also available. + * skeinUpdateBits(&ctx, message, msgLength); + * + * // Now get the result of the Skein hash. The output buffer must be + * // large enough to hold the request number of output bits. The application + * // may now extract the bits. + * skeinFinal(&ctx, result); + * ... + * @endcode + * + * An application may use @c skeinReset to reset a Skein context and use + * it for creation of another hash with the same Skein state size and output + * bit length. In this case the API implementation restores some internal + * internal state data and saves a full Skein initialization round. + * + * To create a MAC the application just uses @c skeinMacInit instead of + * @c skeinInit. All other functions calls remain the same. + * + */ + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * Which Skein size to use + */ + typedef enum SkeinSize { + Skein256 = 256, /*!< Skein with 256 bit state */ + Skein512 = 512, /*!< Skein with 512 bit state */ + Skein1024 = 1024 /*!< Skein with 1024 bit state */ + } SkeinSize_t; + + /** + * Context for Skein. + * + * This structure was setup with some know-how of the internal + * Skein structures, in particular ordering of header and size dependent + * variables. If Skein implementation changes this, then adapt these + * structures as well. + */ + typedef struct SkeinCtx { + u64b_t skeinSize; + u64b_t XSave[SKEIN_MAX_STATE_WORDS]; /* save area for state variables */ + union { + Skein_Ctxt_Hdr_t h; + Skein_256_Ctxt_t s256; + Skein_512_Ctxt_t s512; + Skein1024_Ctxt_t s1024; + } m; + } SkeinCtx_t; + + /** + * Prepare a Skein context. + * + * An application must call this function before it can use the Skein + * context. The functions clears memory and initializes size dependent + * variables. + * + * @param ctx + * Pointer to a Skein context. + * @param size + * Which Skein size to use. + * @return + * SKEIN_SUCESS of SKEIN_FAIL + */ + int skeinCtxPrepare(SkeinCtx_t* ctx, SkeinSize_t size); + + /** + * Initialize a Skein context. + * + * Initializes the context with this data and saves the resulting Skein + * state variables for further use. + * + * @param ctx + * Pointer to a Skein context. + * @param hashBitLen + * Number of MAC hash bits to compute + * @return + * SKEIN_SUCESS of SKEIN_FAIL + * @see skeinReset + */ + int skeinInit(SkeinCtx_t* ctx, size_t hashBitLen); + + /** + * Resets a Skein context for further use. + * + * Restores the saved chaining variables to reset the Skein context. + * Thus applications can reuse the same setup to process several + * messages. This saves a complete Skein initialization cycle. + * + * @param ctx + * Pointer to a pre-initialized Skein MAC context + */ + void skeinReset(SkeinCtx_t* ctx); + + /** + * Initializes a Skein context for MAC usage. + * + * Initializes the context with this data and saves the resulting Skein + * state variables for further use. + * + * Applications call the normal Skein functions to update the MAC and + * get the final result. + * + * @param ctx + * Pointer to an empty or preinitialized Skein MAC context + * @param key + * Pointer to key bytes or NULL + * @param keyLen + * Length of the key in bytes or zero + * @param hashBitLen + * Number of MAC hash bits to compute + * @return + * SKEIN_SUCESS of SKEIN_FAIL + */ + int skeinMacInit(SkeinCtx_t* ctx, const uint8_t *key, size_t keyLen, + size_t hashBitLen); + + /** + * Update Skein with the next part of the message. + * + * @param ctx + * Pointer to initialized Skein context + * @param msg + * Pointer to the message. + * @param msgByteCnt + * Length of the message in @b bytes + * @return + * Success or error code. + */ + int skeinUpdate(SkeinCtx_t *ctx, const uint8_t *msg, + size_t msgByteCnt); + + /** + * Update the hash with a message bit string. + * + * Skein can handle data not only as bytes but also as bit strings of + * arbitrary length (up to its maximum design size). + * + * @param ctx + * Pointer to initialized Skein context + * @param msg + * Pointer to the message. + * @param msgBitCnt + * Length of the message in @b bits. + */ + int skeinUpdateBits(SkeinCtx_t *ctx, const uint8_t *msg, + size_t msgBitCnt); + + /** + * Finalize Skein and return the hash. + * + * Before an application can reuse a Skein setup the application must + * reset the Skein context. + * + * @param ctx + * Pointer to initialized Skein context + * @param hash + * Pointer to buffer that receives the hash. The buffer must be large + * enough to store @c hashBitLen bits. + * @return + * Success or error code. + * @see skeinReset + */ + int skeinFinal(SkeinCtx_t* ctx, uint8_t* hash); + +#ifdef __cplusplus +} +#endif + +/** + * @} + */ +#endif diff --git a/drivers/staging/skein/include/skein_iv.h b/drivers/staging/skein/include/skein_iv.h new file mode 100644 index 000000000000..bdb27078d846 --- /dev/null +++ b/drivers/staging/skein/include/skein_iv.h @@ -0,0 +1,199 @@ +#ifndef _SKEIN_IV_H_ +#define _SKEIN_IV_H_ + +#include /* get Skein macros and types */ + +/* +***************** Pre-computed Skein IVs ******************* +** +** NOTE: these values are not "magic" constants, but +** are generated using the Threefish block function. +** They are pre-computed here only for speed; i.e., to +** avoid the need for a Threefish call during Init(). +** +** The IV for any fixed hash length may be pre-computed. +** Only the most common values are included here. +** +************************************************************ +**/ + +#define MK_64 SKEIN_MK_64 + +/* blkSize = 256 bits. hashSize = 128 bits */ +const u64b_t SKEIN_256_IV_128[] = + { + MK_64(0xE1111906,0x964D7260), + MK_64(0x883DAAA7,0x7C8D811C), + MK_64(0x10080DF4,0x91960F7A), + MK_64(0xCCF7DDE5,0xB45BC1C2) + }; + +/* blkSize = 256 bits. hashSize = 160 bits */ +const u64b_t SKEIN_256_IV_160[] = + { + MK_64(0x14202314,0x72825E98), + MK_64(0x2AC4E9A2,0x5A77E590), + MK_64(0xD47A5856,0x8838D63E), + MK_64(0x2DD2E496,0x8586AB7D) + }; + +/* blkSize = 256 bits. hashSize = 224 bits */ +const u64b_t SKEIN_256_IV_224[] = + { + MK_64(0xC6098A8C,0x9AE5EA0B), + MK_64(0x876D5686,0x08C5191C), + MK_64(0x99CB88D7,0xD7F53884), + MK_64(0x384BDDB1,0xAEDDB5DE) + }; + +/* blkSize = 256 bits. hashSize = 256 bits */ +const u64b_t SKEIN_256_IV_256[] = + { + MK_64(0xFC9DA860,0xD048B449), + MK_64(0x2FCA6647,0x9FA7D833), + MK_64(0xB33BC389,0x6656840F), + MK_64(0x6A54E920,0xFDE8DA69) + }; + +/* blkSize = 512 bits. hashSize = 128 bits */ +const u64b_t SKEIN_512_IV_128[] = + { + MK_64(0xA8BC7BF3,0x6FBF9F52), + MK_64(0x1E9872CE,0xBD1AF0AA), + MK_64(0x309B1790,0xB32190D3), + MK_64(0xBCFBB854,0x3F94805C), + MK_64(0x0DA61BCD,0x6E31B11B), + MK_64(0x1A18EBEA,0xD46A32E3), + MK_64(0xA2CC5B18,0xCE84AA82), + MK_64(0x6982AB28,0x9D46982D) + }; + +/* blkSize = 512 bits. hashSize = 160 bits */ +const u64b_t SKEIN_512_IV_160[] = + { + MK_64(0x28B81A2A,0xE013BD91), + MK_64(0xC2F11668,0xB5BDF78F), + MK_64(0x1760D8F3,0xF6A56F12), + MK_64(0x4FB74758,0x8239904F), + MK_64(0x21EDE07F,0x7EAF5056), + MK_64(0xD908922E,0x63ED70B8), + MK_64(0xB8EC76FF,0xECCB52FA), + MK_64(0x01A47BB8,0xA3F27A6E) + }; + +/* blkSize = 512 bits. hashSize = 224 bits */ +const u64b_t SKEIN_512_IV_224[] = + { + MK_64(0xCCD06162,0x48677224), + MK_64(0xCBA65CF3,0xA92339EF), + MK_64(0x8CCD69D6,0x52FF4B64), + MK_64(0x398AED7B,0x3AB890B4), + MK_64(0x0F59D1B1,0x457D2BD0), + MK_64(0x6776FE65,0x75D4EB3D), + MK_64(0x99FBC70E,0x997413E9), + MK_64(0x9E2CFCCF,0xE1C41EF7) + }; + +/* blkSize = 512 bits. hashSize = 256 bits */ +const u64b_t SKEIN_512_IV_256[] = + { + MK_64(0xCCD044A1,0x2FDB3E13), + MK_64(0xE8359030,0x1A79A9EB), + MK_64(0x55AEA061,0x4F816E6F), + MK_64(0x2A2767A4,0xAE9B94DB), + MK_64(0xEC06025E,0x74DD7683), + MK_64(0xE7A436CD,0xC4746251), + MK_64(0xC36FBAF9,0x393AD185), + MK_64(0x3EEDBA18,0x33EDFC13) + }; + +/* blkSize = 512 bits. hashSize = 384 bits */ +const u64b_t SKEIN_512_IV_384[] = + { + MK_64(0xA3F6C6BF,0x3A75EF5F), + MK_64(0xB0FEF9CC,0xFD84FAA4), + MK_64(0x9D77DD66,0x3D770CFE), + MK_64(0xD798CBF3,0xB468FDDA), + MK_64(0x1BC4A666,0x8A0E4465), + MK_64(0x7ED7D434,0xE5807407), + MK_64(0x548FC1AC,0xD4EC44D6), + MK_64(0x266E1754,0x6AA18FF8) + }; + +/* blkSize = 512 bits. hashSize = 512 bits */ +const u64b_t SKEIN_512_IV_512[] = + { + MK_64(0x4903ADFF,0x749C51CE), + MK_64(0x0D95DE39,0x9746DF03), + MK_64(0x8FD19341,0x27C79BCE), + MK_64(0x9A255629,0xFF352CB1), + MK_64(0x5DB62599,0xDF6CA7B0), + MK_64(0xEABE394C,0xA9D5C3F4), + MK_64(0x991112C7,0x1A75B523), + MK_64(0xAE18A40B,0x660FCC33) + }; + +/* blkSize = 1024 bits. hashSize = 384 bits */ +const u64b_t SKEIN1024_IV_384[] = + { + MK_64(0x5102B6B8,0xC1894A35), + MK_64(0xFEEBC9E3,0xFE8AF11A), + MK_64(0x0C807F06,0xE32BED71), + MK_64(0x60C13A52,0xB41A91F6), + MK_64(0x9716D35D,0xD4917C38), + MK_64(0xE780DF12,0x6FD31D3A), + MK_64(0x797846B6,0xC898303A), + MK_64(0xB172C2A8,0xB3572A3B), + MK_64(0xC9BC8203,0xA6104A6C), + MK_64(0x65909338,0xD75624F4), + MK_64(0x94BCC568,0x4B3F81A0), + MK_64(0x3EBBF51E,0x10ECFD46), + MK_64(0x2DF50F0B,0xEEB08542), + MK_64(0x3B5A6530,0x0DBC6516), + MK_64(0x484B9CD2,0x167BBCE1), + MK_64(0x2D136947,0xD4CBAFEA) + }; + +/* blkSize = 1024 bits. hashSize = 512 bits */ +const u64b_t SKEIN1024_IV_512[] = + { + MK_64(0xCAEC0E5D,0x7C1B1B18), + MK_64(0xA01B0E04,0x5F03E802), + MK_64(0x33840451,0xED912885), + MK_64(0x374AFB04,0xEAEC2E1C), + MK_64(0xDF25A0E2,0x813581F7), + MK_64(0xE4004093,0x8B12F9D2), + MK_64(0xA662D539,0xC2ED39B6), + MK_64(0xFA8B85CF,0x45D8C75A), + MK_64(0x8316ED8E,0x29EDE796), + MK_64(0x053289C0,0x2E9F91B8), + MK_64(0xC3F8EF1D,0x6D518B73), + MK_64(0xBDCEC3C4,0xD5EF332E), + MK_64(0x549A7E52,0x22974487), + MK_64(0x67070872,0x5B749816), + MK_64(0xB9CD28FB,0xF0581BD1), + MK_64(0x0E2940B8,0x15804974) + }; + +/* blkSize = 1024 bits. hashSize = 1024 bits */ +const u64b_t SKEIN1024_IV_1024[] = + { + MK_64(0xD593DA07,0x41E72355), + MK_64(0x15B5E511,0xAC73E00C), + MK_64(0x5180E5AE,0xBAF2C4F0), + MK_64(0x03BD41D3,0xFCBCAFAF), + MK_64(0x1CAEC6FD,0x1983A898), + MK_64(0x6E510B8B,0xCDD0589F), + MK_64(0x77E2BDFD,0xC6394ADA), + MK_64(0xC11E1DB5,0x24DCB0A3), + MK_64(0xD6D14AF9,0xC6329AB5), + MK_64(0x6A9B0BFC,0x6EB67E0D), + MK_64(0x9243C60D,0xCCFF1332), + MK_64(0x1A1F1DDE,0x743F02D4), + MK_64(0x0996753C,0x10ED0BB8), + MK_64(0x6572DD22,0xF2B4969A), + MK_64(0x61FD3062,0xD00A579A), + MK_64(0x1DE0536E,0x8682E539) + }; + +#endif /* _SKEIN_IV_H_ */ diff --git a/drivers/staging/skein/include/skein_port.h b/drivers/staging/skein/include/skein_port.h new file mode 100644 index 000000000000..659a9486cb27 --- /dev/null +++ b/drivers/staging/skein/include/skein_port.h @@ -0,0 +1,124 @@ +#ifndef _SKEIN_PORT_H_ +#define _SKEIN_PORT_H_ +/******************************************************************* +** +** Platform-specific definitions for Skein hash function. +** +** Source code author: Doug Whiting, 2008. +** +** This algorithm and source code is released to the public domain. +** +** Many thanks to Brian Gladman for his portable header files. +** +** To port Skein to an "unsupported" platform, change the definitions +** in this file appropriately. +** +********************************************************************/ + +#include /* get integer type definitions */ + +typedef unsigned int uint_t; /* native unsigned integer */ +typedef uint_8t u08b_t; /* 8-bit unsigned integer */ +typedef uint_64t u64b_t; /* 64-bit unsigned integer */ + +#ifndef RotL_64 +#define RotL_64(x,N) (((x) << (N)) | ((x) >> (64-(N)))) +#endif + +/* + * Skein is "natively" little-endian (unlike SHA-xxx), for optimal + * performance on x86 CPUs. The Skein code requires the following + * definitions for dealing with endianness: + * + * SKEIN_NEED_SWAP: 0 for little-endian, 1 for big-endian + * Skein_Put64_LSB_First + * Skein_Get64_LSB_First + * Skein_Swap64 + * + * If SKEIN_NEED_SWAP is defined at compile time, it is used here + * along with the portable versions of Put64/Get64/Swap64, which + * are slow in general. + * + * Otherwise, an "auto-detect" of endianness is attempted below. + * If the default handling doesn't work well, the user may insert + * platform-specific code instead (e.g., for big-endian CPUs). + * + */ +#ifndef SKEIN_NEED_SWAP /* compile-time "override" for endianness? */ + +#include /* get endianness selection */ +#if PLATFORM_BYTE_ORDER == IS_BIG_ENDIAN + /* here for big-endian CPUs */ +#define SKEIN_NEED_SWAP (1) +#elif PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN + /* here for x86 and x86-64 CPUs (and other detected little-endian CPUs) */ +#define SKEIN_NEED_SWAP (0) +#if PLATFORM_MUST_ALIGN == 0 /* ok to use "fast" versions? */ +#define Skein_Put64_LSB_First(dst08,src64,bCnt) memcpy(dst08,src64,bCnt) +#define Skein_Get64_LSB_First(dst64,src08,wCnt) memcpy(dst64,src08,8*(wCnt)) +#endif +#else +#error "Skein needs endianness setting!" +#endif + +#endif /* ifndef SKEIN_NEED_SWAP */ + +/* + ****************************************************************** + * Provide any definitions still needed. + ****************************************************************** + */ +#ifndef Skein_Swap64 /* swap for big-endian, nop for little-endian */ +#if SKEIN_NEED_SWAP +#define Skein_Swap64(w64) \ + ( (( ((u64b_t)(w64)) & 0xFF) << 56) | \ + (((((u64b_t)(w64)) >> 8) & 0xFF) << 48) | \ + (((((u64b_t)(w64)) >>16) & 0xFF) << 40) | \ + (((((u64b_t)(w64)) >>24) & 0xFF) << 32) | \ + (((((u64b_t)(w64)) >>32) & 0xFF) << 24) | \ + (((((u64b_t)(w64)) >>40) & 0xFF) << 16) | \ + (((((u64b_t)(w64)) >>48) & 0xFF) << 8) | \ + (((((u64b_t)(w64)) >>56) & 0xFF) ) ) +#else +#define Skein_Swap64(w64) (w64) +#endif +#endif /* ifndef Skein_Swap64 */ + + +#ifndef Skein_Put64_LSB_First +void Skein_Put64_LSB_First(u08b_t *dst,const u64b_t *src,size_t bCnt) +#ifdef SKEIN_PORT_CODE /* instantiate the function code here? */ + { /* this version is fully portable (big-endian or little-endian), but slow */ + size_t n; + + for (n=0;n>3] >> (8*(n&7))); + } +#else + ; /* output only the function prototype */ +#endif +#endif /* ifndef Skein_Put64_LSB_First */ + + +#ifndef Skein_Get64_LSB_First +void Skein_Get64_LSB_First(u64b_t *dst,const u08b_t *src,size_t wCnt) +#ifdef SKEIN_PORT_CODE /* instantiate the function code here? */ + { /* this version is fully portable (big-endian or little-endian), but slow */ + size_t n; + + for (n=0;n<8*wCnt;n+=8) + dst[n/8] = (((u64b_t) src[n ]) ) + + (((u64b_t) src[n+1]) << 8) + + (((u64b_t) src[n+2]) << 16) + + (((u64b_t) src[n+3]) << 24) + + (((u64b_t) src[n+4]) << 32) + + (((u64b_t) src[n+5]) << 40) + + (((u64b_t) src[n+6]) << 48) + + (((u64b_t) src[n+7]) << 56) ; + } +#else + ; /* output only the function prototype */ +#endif +#endif /* ifndef Skein_Get64_LSB_First */ + +#endif /* ifndef _SKEIN_PORT_H_ */ diff --git a/drivers/staging/skein/include/threefishApi.h b/drivers/staging/skein/include/threefishApi.h new file mode 100644 index 000000000000..85afd72fe987 --- /dev/null +++ b/drivers/staging/skein/include/threefishApi.h @@ -0,0 +1,167 @@ + +#ifndef THREEFISHAPI_H +#define THREEFISHAPI_H + +/** + * @file threefishApi.h + * @brief A Threefish cipher API and its functions. + * @{ + * + * This API and the functions that implement this API simplify the usage + * of the Threefish cipher. The design and the way to use the functions + * follow the openSSL design but at the same time take care of some Threefish + * specific behaviour and possibilities. + * + * These are the low level functions that deal with Threefisch blocks only. + * Implementations for cipher modes such as ECB, CFB, or CBC may use these + * functions. + * +@code + // Threefish cipher context data + ThreefishKey_t keyCtx; + + // Initialize the context + threefishSetKey(&keyCtx, Threefish512, key, tweak); + + // Encrypt + threefishEncryptBlockBytes(&keyCtx, input, cipher); +@endcode + */ + +#include +#include + +#define KeyScheduleConst 0x1BD11BDAA9FC1A22L + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * Which Threefish size to use + */ + typedef enum ThreefishSize { + Threefish256 = 256, /*!< Skein with 256 bit state */ + Threefish512 = 512, /*!< Skein with 512 bit state */ + Threefish1024 = 1024 /*!< Skein with 1024 bit state */ + } ThreefishSize_t; + + /** + * Context for Threefish key and tweak words. + * + * This structure was setup with some know-how of the internal + * Skein structures, in particular ordering of header and size dependent + * variables. If Skein implementation changes this, the adapt these + * structures as well. + */ + typedef struct ThreefishKey { + u64b_t stateSize; + u64b_t key[SKEIN_MAX_STATE_WORDS+1]; /* max number of key words*/ + u64b_t tweak[3]; + } ThreefishKey_t; + + /** + * Set Threefish key and tweak data. + * + * This function sets the key and tweak data for the Threefish cipher of + * the given size. The key data must have the same length (number of bits) + * as the state size + * + * @param keyCtx + * Pointer to a Threefish key structure. + * @param size + * Which Skein size to use. + * @param keyData + * Pointer to the key words (word has 64 bits). + * @param tweak + * Pointer to the two tweak words (word has 64 bits). + */ + void threefishSetKey(ThreefishKey_t* keyCtx, ThreefishSize_t stateSize, uint64_t* keyData, uint64_t* tweak); + + /** + * Encrypt Threefisch block (bytes). + * + * The buffer must have at least the same length (number of bits) aas the + * state size for this key. The function uses the first @c stateSize bits + * of the input buffer, encrypts them and stores the result in the output + * buffer. + * + * @param keyCtx + * Pointer to a Threefish key structure. + * @param in + * Poionter to plaintext data buffer. + * @param out + * Pointer to cipher buffer. + */ + void threefishEncryptBlockBytes(ThreefishKey_t* keyCtx, uint8_t* in, uint8_t* out); + + /** + * Encrypt Threefisch block (words). + * + * The buffer must have at least the same length (number of bits) aas the + * state size for this key. The function uses the first @c stateSize bits + * of the input buffer, encrypts them and stores the result in the output + * buffer. + * + * The wordsize ist set to 64 bits. + * + * @param keyCtx + * Pointer to a Threefish key structure. + * @param in + * Poionter to plaintext data buffer. + * @param out + * Pointer to cipher buffer. + */ + void threefishEncryptBlockWords(ThreefishKey_t* keyCtx, uint64_t* in, uint64_t* out); + + /** + * Decrypt Threefisch block (bytes). + * + * The buffer must have at least the same length (number of bits) aas the + * state size for this key. The function uses the first @c stateSize bits + * of the input buffer, decrypts them and stores the result in the output + * buffer + * + * @param keyCtx + * Pointer to a Threefish key structure. + * @param in + * Poionter to cipher data buffer. + * @param out + * Pointer to plaintext buffer. + */ + void threefishDecryptBlockBytes(ThreefishKey_t* keyCtx, uint8_t* in, uint8_t* out); + + /** + * Decrypt Threefisch block (words). + * + * The buffer must have at least the same length (number of bits) aas the + * state size for this key. The function uses the first @c stateSize bits + * of the input buffer, encrypts them and stores the result in the output + * buffer. + * + * The wordsize ist set to 64 bits. + * + * @param keyCtx + * Pointer to a Threefish key structure. + * @param in + * Poionter to cipher data buffer. + * @param out + * Pointer to plaintext buffer. + */ + void threefishDecryptBlockWords(ThreefishKey_t* keyCtx, uint64_t* in, uint64_t* out); + + void threefishEncrypt256(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output); + void threefishEncrypt512(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output); + void threefishEncrypt1024(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output); + void threefishDecrypt256(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output); + void threefishDecrypt512(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output); + void threefishDecrypt1024(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output); +#ifdef __cplusplus +} +#endif + +/** + * @} + */ +#endif diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c new file mode 100644 index 000000000000..76933371183a --- /dev/null +++ b/drivers/staging/skein/skein.c @@ -0,0 +1,742 @@ +/*********************************************************************** +** +** Implementation of the Skein hash function. +** +** Source code author: Doug Whiting, 2008. +** +** This algorithm and source code is released to the public domain. +** +************************************************************************/ + +#define SKEIN_PORT_CODE /* instantiate any code in skein_port.h */ + +#include /* get the memcpy/memset functions */ +#include /* get the Skein API definitions */ +#include /* get precomputed IVs */ + +/*****************************************************************/ +/* External function to process blkCnt (nonzero) full block(s) of data. */ +void Skein_256_Process_Block(Skein_256_Ctxt_t *ctx,const u08b_t *blkPtr,size_t blkCnt,size_t byteCntAdd); +void Skein_512_Process_Block(Skein_512_Ctxt_t *ctx,const u08b_t *blkPtr,size_t blkCnt,size_t byteCntAdd); +void Skein1024_Process_Block(Skein1024_Ctxt_t *ctx,const u08b_t *blkPtr,size_t blkCnt,size_t byteCntAdd); + +/*****************************************************************/ +/* 256-bit Skein */ +/*****************************************************************/ + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* init the context for a straight hashing operation */ +int Skein_256_Init(Skein_256_Ctxt_t *ctx, size_t hashBitLen) +{ + union + { + u08b_t b[SKEIN_256_STATE_BYTES]; + u64b_t w[SKEIN_256_STATE_WORDS]; + } cfg; /* config block */ + + Skein_Assert(hashBitLen > 0,SKEIN_BAD_HASHLEN); + ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ + + switch (hashBitLen) + { /* use pre-computed values, where available */ + case 256: + memcpy(ctx->X,SKEIN_256_IV_256,sizeof(ctx->X)); + break; + case 224: + memcpy(ctx->X,SKEIN_256_IV_224,sizeof(ctx->X)); + break; + case 160: + memcpy(ctx->X,SKEIN_256_IV_160,sizeof(ctx->X)); + break; + case 128: + memcpy(ctx->X,SKEIN_256_IV_128,sizeof(ctx->X)); + break; + default: + /* here if there is no precomputed IV value available */ + /* build/process the config block, type == CONFIG (could be precomputed) */ + Skein_Start_New_Type(ctx,CFG_FINAL); /* set tweaks: T0=0; T1=CFG | FINAL */ + + cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); /* set the schema, version */ + cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ + cfg.w[2] = Skein_Swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); + memset(&cfg.w[3],0,sizeof(cfg) - 3*sizeof(cfg.w[0])); /* zero pad config block */ + + /* compute the initial chaining values from config block */ + memset(ctx->X,0,sizeof(ctx->X)); /* zero the chaining variables */ + Skein_256_Process_Block(ctx,cfg.b,1,SKEIN_CFG_STR_LEN); + break; + } + /* The chaining vars ctx->X are now initialized for the given hashBitLen. */ + /* Set up to process the data message portion of the hash (default) */ + Skein_Start_New_Type(ctx,MSG); /* T0=0, T1= MSG type */ + + return SKEIN_SUCCESS; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* init the context for a MAC and/or tree hash operation */ +/* [identical to Skein_256_Init() when keyBytes == 0 && treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ +int Skein_256_InitExt(Skein_256_Ctxt_t *ctx,size_t hashBitLen,u64b_t treeInfo, const u08b_t *key, size_t keyBytes) +{ + union + { + u08b_t b[SKEIN_256_STATE_BYTES]; + u64b_t w[SKEIN_256_STATE_WORDS]; + } cfg; /* config block */ + + Skein_Assert(hashBitLen > 0,SKEIN_BAD_HASHLEN); + Skein_Assert(keyBytes == 0 || key != NULL,SKEIN_FAIL); + + /* compute the initial chaining values ctx->X[], based on key */ + if (keyBytes == 0) /* is there a key? */ + { + memset(ctx->X,0,sizeof(ctx->X)); /* no key: use all zeroes as key for config block */ + } + else /* here to pre-process a key */ + { + Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); + /* do a mini-Init right here */ + ctx->h.hashBitLen=8*sizeof(ctx->X); /* set output hash bit count = state size */ + Skein_Start_New_Type(ctx,KEY); /* set tweaks: T0 = 0; T1 = KEY type */ + memset(ctx->X,0,sizeof(ctx->X)); /* zero the initial chaining variables */ + Skein_256_Update(ctx,key,keyBytes); /* hash the key */ + Skein_256_Final_Pad(ctx,cfg.b); /* put result into cfg.b[] */ + memcpy(ctx->X,cfg.b,sizeof(cfg.b)); /* copy over into ctx->X[] */ +#if SKEIN_NEED_SWAP + { + uint_t i; + for (i=0;iX[i] = Skein_Swap64(ctx->X[i]); + } +#endif + } + /* build/process the config block, type == CONFIG (could be precomputed for each key) */ + ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ + Skein_Start_New_Type(ctx,CFG_FINAL); + + memset(&cfg.w,0,sizeof(cfg.w)); /* pre-pad cfg.w[] with zeroes */ + cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); + cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ + cfg.w[2] = Skein_Swap64(treeInfo); /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ + + Skein_Show_Key(256,&ctx->h,key,keyBytes); + + /* compute the initial chaining values from config block */ + Skein_256_Process_Block(ctx,cfg.b,1,SKEIN_CFG_STR_LEN); + + /* The chaining vars ctx->X are now initialized */ + /* Set up to process the data message portion of the hash (default) */ + Skein_Start_New_Type(ctx,MSG); + + return SKEIN_SUCCESS; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* process the input bytes */ +int Skein_256_Update(Skein_256_Ctxt_t *ctx, const u08b_t *msg, size_t msgByteCnt) +{ + size_t n; + + Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ + + /* process full blocks, if any */ + if (msgByteCnt + ctx->h.bCnt > SKEIN_256_BLOCK_BYTES) + { + if (ctx->h.bCnt) /* finish up any buffered message data */ + { + n = SKEIN_256_BLOCK_BYTES - ctx->h.bCnt; /* # bytes free in buffer b[] */ + if (n) + { + Skein_assert(n < msgByteCnt); /* check on our logic here */ + memcpy(&ctx->b[ctx->h.bCnt],msg,n); + msgByteCnt -= n; + msg += n; + ctx->h.bCnt += n; + } + Skein_assert(ctx->h.bCnt == SKEIN_256_BLOCK_BYTES); + Skein_256_Process_Block(ctx,ctx->b,1,SKEIN_256_BLOCK_BYTES); + ctx->h.bCnt = 0; + } + /* now process any remaining full blocks, directly from input message data */ + if (msgByteCnt > SKEIN_256_BLOCK_BYTES) + { + n = (msgByteCnt-1) / SKEIN_256_BLOCK_BYTES; /* number of full blocks to process */ + Skein_256_Process_Block(ctx,msg,n,SKEIN_256_BLOCK_BYTES); + msgByteCnt -= n * SKEIN_256_BLOCK_BYTES; + msg += n * SKEIN_256_BLOCK_BYTES; + } + Skein_assert(ctx->h.bCnt == 0); + } + + /* copy any remaining source message data bytes into b[] */ + if (msgByteCnt) + { + Skein_assert(msgByteCnt + ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES); + memcpy(&ctx->b[ctx->h.bCnt],msg,msgByteCnt); + ctx->h.bCnt += msgByteCnt; + } + + return SKEIN_SUCCESS; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* finalize the hash computation and output the result */ +int Skein_256_Final(Skein_256_Ctxt_t *ctx, u08b_t *hashVal) +{ + size_t i,n,byteCnt; + u64b_t X[SKEIN_256_STATE_WORDS]; + Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ + + ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ + if (ctx->h.bCnt < SKEIN_256_BLOCK_BYTES) /* zero pad b[] if necessary */ + memset(&ctx->b[ctx->h.bCnt],0,SKEIN_256_BLOCK_BYTES - ctx->h.bCnt); + + Skein_256_Process_Block(ctx,ctx->b,1,ctx->h.bCnt); /* process the final block */ + + /* now output the result */ + byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ + + /* run Threefish in "counter mode" to generate output */ + memset(ctx->b,0,sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ + memcpy(X,ctx->X,sizeof(X)); /* keep a local copy of counter mode "key" */ + for (i=0;i*SKEIN_256_BLOCK_BYTES < byteCnt;i++) + { + ((u64b_t *)ctx->b)[0]= Skein_Swap64((u64b_t) i); /* build the counter block */ + Skein_Start_New_Type(ctx,OUT_FINAL); + Skein_256_Process_Block(ctx,ctx->b,1,sizeof(u64b_t)); /* run "counter mode" */ + n = byteCnt - i*SKEIN_256_BLOCK_BYTES; /* number of output bytes left to go */ + if (n >= SKEIN_256_BLOCK_BYTES) + n = SKEIN_256_BLOCK_BYTES; + Skein_Put64_LSB_First(hashVal+i*SKEIN_256_BLOCK_BYTES,ctx->X,n); /* "output" the ctr mode bytes */ + Skein_Show_Final(256,&ctx->h,n,hashVal+i*SKEIN_256_BLOCK_BYTES); + memcpy(ctx->X,X,sizeof(X)); /* restore the counter mode key for next time */ + } + return SKEIN_SUCCESS; +} + +/*****************************************************************/ +/* 512-bit Skein */ +/*****************************************************************/ + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* init the context for a straight hashing operation */ +int Skein_512_Init(Skein_512_Ctxt_t *ctx, size_t hashBitLen) +{ + union + { + u08b_t b[SKEIN_512_STATE_BYTES]; + u64b_t w[SKEIN_512_STATE_WORDS]; + } cfg; /* config block */ + + Skein_Assert(hashBitLen > 0,SKEIN_BAD_HASHLEN); + ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ + + switch (hashBitLen) + { /* use pre-computed values, where available */ + case 512: + memcpy(ctx->X,SKEIN_512_IV_512,sizeof(ctx->X)); + break; + case 384: + memcpy(ctx->X,SKEIN_512_IV_384,sizeof(ctx->X)); + break; + case 256: + memcpy(ctx->X,SKEIN_512_IV_256,sizeof(ctx->X)); + break; + case 224: + memcpy(ctx->X,SKEIN_512_IV_224,sizeof(ctx->X)); + break; + default: + /* here if there is no precomputed IV value available */ + /* build/process the config block, type == CONFIG (could be precomputed) */ + Skein_Start_New_Type(ctx,CFG_FINAL); /* set tweaks: T0=0; T1=CFG | FINAL */ + + cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); /* set the schema, version */ + cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ + cfg.w[2] = Skein_Swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); + memset(&cfg.w[3],0,sizeof(cfg) - 3*sizeof(cfg.w[0])); /* zero pad config block */ + + /* compute the initial chaining values from config block */ + memset(ctx->X,0,sizeof(ctx->X)); /* zero the chaining variables */ + Skein_512_Process_Block(ctx,cfg.b,1,SKEIN_CFG_STR_LEN); + break; + } + + /* The chaining vars ctx->X are now initialized for the given hashBitLen. */ + /* Set up to process the data message portion of the hash (default) */ + Skein_Start_New_Type(ctx,MSG); /* T0=0, T1= MSG type */ + + return SKEIN_SUCCESS; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* init the context for a MAC and/or tree hash operation */ +/* [identical to Skein_512_Init() when keyBytes == 0 && treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ +int Skein_512_InitExt(Skein_512_Ctxt_t *ctx,size_t hashBitLen,u64b_t treeInfo, const u08b_t *key, size_t keyBytes) +{ + union + { + u08b_t b[SKEIN_512_STATE_BYTES]; + u64b_t w[SKEIN_512_STATE_WORDS]; + } cfg; /* config block */ + + Skein_Assert(hashBitLen > 0,SKEIN_BAD_HASHLEN); + Skein_Assert(keyBytes == 0 || key != NULL,SKEIN_FAIL); + + /* compute the initial chaining values ctx->X[], based on key */ + if (keyBytes == 0) /* is there a key? */ + { + memset(ctx->X,0,sizeof(ctx->X)); /* no key: use all zeroes as key for config block */ + } + else /* here to pre-process a key */ + { + Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); + /* do a mini-Init right here */ + ctx->h.hashBitLen=8*sizeof(ctx->X); /* set output hash bit count = state size */ + Skein_Start_New_Type(ctx,KEY); /* set tweaks: T0 = 0; T1 = KEY type */ + memset(ctx->X,0,sizeof(ctx->X)); /* zero the initial chaining variables */ + Skein_512_Update(ctx,key,keyBytes); /* hash the key */ + Skein_512_Final_Pad(ctx,cfg.b); /* put result into cfg.b[] */ + memcpy(ctx->X,cfg.b,sizeof(cfg.b)); /* copy over into ctx->X[] */ +#if SKEIN_NEED_SWAP + { + uint_t i; + for (i=0;iX[i] = Skein_Swap64(ctx->X[i]); + } +#endif + } + /* build/process the config block, type == CONFIG (could be precomputed for each key) */ + ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ + Skein_Start_New_Type(ctx,CFG_FINAL); + + memset(&cfg.w,0,sizeof(cfg.w)); /* pre-pad cfg.w[] with zeroes */ + cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); + cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ + cfg.w[2] = Skein_Swap64(treeInfo); /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ + + Skein_Show_Key(512,&ctx->h,key,keyBytes); + + /* compute the initial chaining values from config block */ + Skein_512_Process_Block(ctx,cfg.b,1,SKEIN_CFG_STR_LEN); + + /* The chaining vars ctx->X are now initialized */ + /* Set up to process the data message portion of the hash (default) */ + Skein_Start_New_Type(ctx,MSG); + + return SKEIN_SUCCESS; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* process the input bytes */ +int Skein_512_Update(Skein_512_Ctxt_t *ctx, const u08b_t *msg, size_t msgByteCnt) +{ + size_t n; + + Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ + + /* process full blocks, if any */ + if (msgByteCnt + ctx->h.bCnt > SKEIN_512_BLOCK_BYTES) + { + if (ctx->h.bCnt) /* finish up any buffered message data */ + { + n = SKEIN_512_BLOCK_BYTES - ctx->h.bCnt; /* # bytes free in buffer b[] */ + if (n) + { + Skein_assert(n < msgByteCnt); /* check on our logic here */ + memcpy(&ctx->b[ctx->h.bCnt],msg,n); + msgByteCnt -= n; + msg += n; + ctx->h.bCnt += n; + } + Skein_assert(ctx->h.bCnt == SKEIN_512_BLOCK_BYTES); + Skein_512_Process_Block(ctx,ctx->b,1,SKEIN_512_BLOCK_BYTES); + ctx->h.bCnt = 0; + } + /* now process any remaining full blocks, directly from input message data */ + if (msgByteCnt > SKEIN_512_BLOCK_BYTES) + { + n = (msgByteCnt-1) / SKEIN_512_BLOCK_BYTES; /* number of full blocks to process */ + Skein_512_Process_Block(ctx,msg,n,SKEIN_512_BLOCK_BYTES); + msgByteCnt -= n * SKEIN_512_BLOCK_BYTES; + msg += n * SKEIN_512_BLOCK_BYTES; + } + Skein_assert(ctx->h.bCnt == 0); + } + + /* copy any remaining source message data bytes into b[] */ + if (msgByteCnt) + { + Skein_assert(msgByteCnt + ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES); + memcpy(&ctx->b[ctx->h.bCnt],msg,msgByteCnt); + ctx->h.bCnt += msgByteCnt; + } + + return SKEIN_SUCCESS; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* finalize the hash computation and output the result */ +int Skein_512_Final(Skein_512_Ctxt_t *ctx, u08b_t *hashVal) +{ + size_t i,n,byteCnt; + u64b_t X[SKEIN_512_STATE_WORDS]; + Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ + + ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ + if (ctx->h.bCnt < SKEIN_512_BLOCK_BYTES) /* zero pad b[] if necessary */ + memset(&ctx->b[ctx->h.bCnt],0,SKEIN_512_BLOCK_BYTES - ctx->h.bCnt); + + Skein_512_Process_Block(ctx,ctx->b,1,ctx->h.bCnt); /* process the final block */ + + /* now output the result */ + byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ + + /* run Threefish in "counter mode" to generate output */ + memset(ctx->b,0,sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ + memcpy(X,ctx->X,sizeof(X)); /* keep a local copy of counter mode "key" */ + for (i=0;i*SKEIN_512_BLOCK_BYTES < byteCnt;i++) + { + ((u64b_t *)ctx->b)[0]= Skein_Swap64((u64b_t) i); /* build the counter block */ + Skein_Start_New_Type(ctx,OUT_FINAL); + Skein_512_Process_Block(ctx,ctx->b,1,sizeof(u64b_t)); /* run "counter mode" */ + n = byteCnt - i*SKEIN_512_BLOCK_BYTES; /* number of output bytes left to go */ + if (n >= SKEIN_512_BLOCK_BYTES) + n = SKEIN_512_BLOCK_BYTES; + Skein_Put64_LSB_First(hashVal+i*SKEIN_512_BLOCK_BYTES,ctx->X,n); /* "output" the ctr mode bytes */ + Skein_Show_Final(512,&ctx->h,n,hashVal+i*SKEIN_512_BLOCK_BYTES); + memcpy(ctx->X,X,sizeof(X)); /* restore the counter mode key for next time */ + } + return SKEIN_SUCCESS; +} + +/*****************************************************************/ +/* 1024-bit Skein */ +/*****************************************************************/ + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* init the context for a straight hashing operation */ +int Skein1024_Init(Skein1024_Ctxt_t *ctx, size_t hashBitLen) +{ + union + { + u08b_t b[SKEIN1024_STATE_BYTES]; + u64b_t w[SKEIN1024_STATE_WORDS]; + } cfg; /* config block */ + + Skein_Assert(hashBitLen > 0,SKEIN_BAD_HASHLEN); + ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ + + switch (hashBitLen) + { /* use pre-computed values, where available */ + case 512: + memcpy(ctx->X,SKEIN1024_IV_512 ,sizeof(ctx->X)); + break; + case 384: + memcpy(ctx->X,SKEIN1024_IV_384 ,sizeof(ctx->X)); + break; + case 1024: + memcpy(ctx->X,SKEIN1024_IV_1024,sizeof(ctx->X)); + break; + default: + /* here if there is no precomputed IV value available */ + /* build/process the config block, type == CONFIG (could be precomputed) */ + Skein_Start_New_Type(ctx,CFG_FINAL); /* set tweaks: T0=0; T1=CFG | FINAL */ + + cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); /* set the schema, version */ + cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ + cfg.w[2] = Skein_Swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); + memset(&cfg.w[3],0,sizeof(cfg) - 3*sizeof(cfg.w[0])); /* zero pad config block */ + + /* compute the initial chaining values from config block */ + memset(ctx->X,0,sizeof(ctx->X)); /* zero the chaining variables */ + Skein1024_Process_Block(ctx,cfg.b,1,SKEIN_CFG_STR_LEN); + break; + } + + /* The chaining vars ctx->X are now initialized for the given hashBitLen. */ + /* Set up to process the data message portion of the hash (default) */ + Skein_Start_New_Type(ctx,MSG); /* T0=0, T1= MSG type */ + + return SKEIN_SUCCESS; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* init the context for a MAC and/or tree hash operation */ +/* [identical to Skein1024_Init() when keyBytes == 0 && treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ +int Skein1024_InitExt(Skein1024_Ctxt_t *ctx,size_t hashBitLen,u64b_t treeInfo, const u08b_t *key, size_t keyBytes) +{ + union + { + u08b_t b[SKEIN1024_STATE_BYTES]; + u64b_t w[SKEIN1024_STATE_WORDS]; + } cfg; /* config block */ + + Skein_Assert(hashBitLen > 0,SKEIN_BAD_HASHLEN); + Skein_Assert(keyBytes == 0 || key != NULL,SKEIN_FAIL); + + /* compute the initial chaining values ctx->X[], based on key */ + if (keyBytes == 0) /* is there a key? */ + { + memset(ctx->X,0,sizeof(ctx->X)); /* no key: use all zeroes as key for config block */ + } + else /* here to pre-process a key */ + { + Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); + /* do a mini-Init right here */ + ctx->h.hashBitLen=8*sizeof(ctx->X); /* set output hash bit count = state size */ + Skein_Start_New_Type(ctx,KEY); /* set tweaks: T0 = 0; T1 = KEY type */ + memset(ctx->X,0,sizeof(ctx->X)); /* zero the initial chaining variables */ + Skein1024_Update(ctx,key,keyBytes); /* hash the key */ + Skein1024_Final_Pad(ctx,cfg.b); /* put result into cfg.b[] */ + memcpy(ctx->X,cfg.b,sizeof(cfg.b)); /* copy over into ctx->X[] */ +#if SKEIN_NEED_SWAP + { + uint_t i; + for (i=0;iX[i] = Skein_Swap64(ctx->X[i]); + } +#endif + } + /* build/process the config block, type == CONFIG (could be precomputed for each key) */ + ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ + Skein_Start_New_Type(ctx,CFG_FINAL); + + memset(&cfg.w,0,sizeof(cfg.w)); /* pre-pad cfg.w[] with zeroes */ + cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); + cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ + cfg.w[2] = Skein_Swap64(treeInfo); /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ + + Skein_Show_Key(1024,&ctx->h,key,keyBytes); + + /* compute the initial chaining values from config block */ + Skein1024_Process_Block(ctx,cfg.b,1,SKEIN_CFG_STR_LEN); + + /* The chaining vars ctx->X are now initialized */ + /* Set up to process the data message portion of the hash (default) */ + Skein_Start_New_Type(ctx,MSG); + + return SKEIN_SUCCESS; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* process the input bytes */ +int Skein1024_Update(Skein1024_Ctxt_t *ctx, const u08b_t *msg, size_t msgByteCnt) +{ + size_t n; + + Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ + + /* process full blocks, if any */ + if (msgByteCnt + ctx->h.bCnt > SKEIN1024_BLOCK_BYTES) + { + if (ctx->h.bCnt) /* finish up any buffered message data */ + { + n = SKEIN1024_BLOCK_BYTES - ctx->h.bCnt; /* # bytes free in buffer b[] */ + if (n) + { + Skein_assert(n < msgByteCnt); /* check on our logic here */ + memcpy(&ctx->b[ctx->h.bCnt],msg,n); + msgByteCnt -= n; + msg += n; + ctx->h.bCnt += n; + } + Skein_assert(ctx->h.bCnt == SKEIN1024_BLOCK_BYTES); + Skein1024_Process_Block(ctx,ctx->b,1,SKEIN1024_BLOCK_BYTES); + ctx->h.bCnt = 0; + } + /* now process any remaining full blocks, directly from input message data */ + if (msgByteCnt > SKEIN1024_BLOCK_BYTES) + { + n = (msgByteCnt-1) / SKEIN1024_BLOCK_BYTES; /* number of full blocks to process */ + Skein1024_Process_Block(ctx,msg,n,SKEIN1024_BLOCK_BYTES); + msgByteCnt -= n * SKEIN1024_BLOCK_BYTES; + msg += n * SKEIN1024_BLOCK_BYTES; + } + Skein_assert(ctx->h.bCnt == 0); + } + + /* copy any remaining source message data bytes into b[] */ + if (msgByteCnt) + { + Skein_assert(msgByteCnt + ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES); + memcpy(&ctx->b[ctx->h.bCnt],msg,msgByteCnt); + ctx->h.bCnt += msgByteCnt; + } + + return SKEIN_SUCCESS; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* finalize the hash computation and output the result */ +int Skein1024_Final(Skein1024_Ctxt_t *ctx, u08b_t *hashVal) +{ + size_t i,n,byteCnt; + u64b_t X[SKEIN1024_STATE_WORDS]; + Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ + + ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ + if (ctx->h.bCnt < SKEIN1024_BLOCK_BYTES) /* zero pad b[] if necessary */ + memset(&ctx->b[ctx->h.bCnt],0,SKEIN1024_BLOCK_BYTES - ctx->h.bCnt); + + Skein1024_Process_Block(ctx,ctx->b,1,ctx->h.bCnt); /* process the final block */ + + /* now output the result */ + byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ + + /* run Threefish in "counter mode" to generate output */ + memset(ctx->b,0,sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ + memcpy(X,ctx->X,sizeof(X)); /* keep a local copy of counter mode "key" */ + for (i=0;i*SKEIN1024_BLOCK_BYTES < byteCnt;i++) + { + ((u64b_t *)ctx->b)[0]= Skein_Swap64((u64b_t) i); /* build the counter block */ + Skein_Start_New_Type(ctx,OUT_FINAL); + Skein1024_Process_Block(ctx,ctx->b,1,sizeof(u64b_t)); /* run "counter mode" */ + n = byteCnt - i*SKEIN1024_BLOCK_BYTES; /* number of output bytes left to go */ + if (n >= SKEIN1024_BLOCK_BYTES) + n = SKEIN1024_BLOCK_BYTES; + Skein_Put64_LSB_First(hashVal+i*SKEIN1024_BLOCK_BYTES,ctx->X,n); /* "output" the ctr mode bytes */ + Skein_Show_Final(1024,&ctx->h,n,hashVal+i*SKEIN1024_BLOCK_BYTES); + memcpy(ctx->X,X,sizeof(X)); /* restore the counter mode key for next time */ + } + return SKEIN_SUCCESS; +} + +/**************** Functions to support MAC/tree hashing ***************/ +/* (this code is identical for Optimized and Reference versions) */ + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* finalize the hash computation and output the block, no OUTPUT stage */ +int Skein_256_Final_Pad(Skein_256_Ctxt_t *ctx, u08b_t *hashVal) +{ + Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ + + ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ + if (ctx->h.bCnt < SKEIN_256_BLOCK_BYTES) /* zero pad b[] if necessary */ + memset(&ctx->b[ctx->h.bCnt],0,SKEIN_256_BLOCK_BYTES - ctx->h.bCnt); + Skein_256_Process_Block(ctx,ctx->b,1,ctx->h.bCnt); /* process the final block */ + + Skein_Put64_LSB_First(hashVal,ctx->X,SKEIN_256_BLOCK_BYTES); /* "output" the state bytes */ + + return SKEIN_SUCCESS; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* finalize the hash computation and output the block, no OUTPUT stage */ +int Skein_512_Final_Pad(Skein_512_Ctxt_t *ctx, u08b_t *hashVal) +{ + Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ + + ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ + if (ctx->h.bCnt < SKEIN_512_BLOCK_BYTES) /* zero pad b[] if necessary */ + memset(&ctx->b[ctx->h.bCnt],0,SKEIN_512_BLOCK_BYTES - ctx->h.bCnt); + Skein_512_Process_Block(ctx,ctx->b,1,ctx->h.bCnt); /* process the final block */ + + Skein_Put64_LSB_First(hashVal,ctx->X,SKEIN_512_BLOCK_BYTES); /* "output" the state bytes */ + + return SKEIN_SUCCESS; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* finalize the hash computation and output the block, no OUTPUT stage */ +int Skein1024_Final_Pad(Skein1024_Ctxt_t *ctx, u08b_t *hashVal) +{ + Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ + + ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ + if (ctx->h.bCnt < SKEIN1024_BLOCK_BYTES) /* zero pad b[] if necessary */ + memset(&ctx->b[ctx->h.bCnt],0,SKEIN1024_BLOCK_BYTES - ctx->h.bCnt); + Skein1024_Process_Block(ctx,ctx->b,1,ctx->h.bCnt); /* process the final block */ + + Skein_Put64_LSB_First(hashVal,ctx->X,SKEIN1024_BLOCK_BYTES); /* "output" the state bytes */ + + return SKEIN_SUCCESS; +} + +#if SKEIN_TREE_HASH +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* just do the OUTPUT stage */ +int Skein_256_Output(Skein_256_Ctxt_t *ctx, u08b_t *hashVal) +{ + size_t i,n,byteCnt; + u64b_t X[SKEIN_256_STATE_WORDS]; + Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ + + /* now output the result */ + byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ + + /* run Threefish in "counter mode" to generate output */ + memset(ctx->b,0,sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ + memcpy(X,ctx->X,sizeof(X)); /* keep a local copy of counter mode "key" */ + for (i=0;i*SKEIN_256_BLOCK_BYTES < byteCnt;i++) + { + ((u64b_t *)ctx->b)[0]= Skein_Swap64((u64b_t) i); /* build the counter block */ + Skein_Start_New_Type(ctx,OUT_FINAL); + Skein_256_Process_Block(ctx,ctx->b,1,sizeof(u64b_t)); /* run "counter mode" */ + n = byteCnt - i*SKEIN_256_BLOCK_BYTES; /* number of output bytes left to go */ + if (n >= SKEIN_256_BLOCK_BYTES) + n = SKEIN_256_BLOCK_BYTES; + Skein_Put64_LSB_First(hashVal+i*SKEIN_256_BLOCK_BYTES,ctx->X,n); /* "output" the ctr mode bytes */ + Skein_Show_Final(256,&ctx->h,n,hashVal+i*SKEIN_256_BLOCK_BYTES); + memcpy(ctx->X,X,sizeof(X)); /* restore the counter mode key for next time */ + } + return SKEIN_SUCCESS; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* just do the OUTPUT stage */ +int Skein_512_Output(Skein_512_Ctxt_t *ctx, u08b_t *hashVal) +{ + size_t i,n,byteCnt; + u64b_t X[SKEIN_512_STATE_WORDS]; + Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ + + /* now output the result */ + byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ + + /* run Threefish in "counter mode" to generate output */ + memset(ctx->b,0,sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ + memcpy(X,ctx->X,sizeof(X)); /* keep a local copy of counter mode "key" */ + for (i=0;i*SKEIN_512_BLOCK_BYTES < byteCnt;i++) + { + ((u64b_t *)ctx->b)[0]= Skein_Swap64((u64b_t) i); /* build the counter block */ + Skein_Start_New_Type(ctx,OUT_FINAL); + Skein_512_Process_Block(ctx,ctx->b,1,sizeof(u64b_t)); /* run "counter mode" */ + n = byteCnt - i*SKEIN_512_BLOCK_BYTES; /* number of output bytes left to go */ + if (n >= SKEIN_512_BLOCK_BYTES) + n = SKEIN_512_BLOCK_BYTES; + Skein_Put64_LSB_First(hashVal+i*SKEIN_512_BLOCK_BYTES,ctx->X,n); /* "output" the ctr mode bytes */ + Skein_Show_Final(256,&ctx->h,n,hashVal+i*SKEIN_512_BLOCK_BYTES); + memcpy(ctx->X,X,sizeof(X)); /* restore the counter mode key for next time */ + } + return SKEIN_SUCCESS; +} + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ +/* just do the OUTPUT stage */ +int Skein1024_Output(Skein1024_Ctxt_t *ctx, u08b_t *hashVal) +{ + size_t i,n,byteCnt; + u64b_t X[SKEIN1024_STATE_WORDS]; + Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ + + /* now output the result */ + byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ + + /* run Threefish in "counter mode" to generate output */ + memset(ctx->b,0,sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ + memcpy(X,ctx->X,sizeof(X)); /* keep a local copy of counter mode "key" */ + for (i=0;i*SKEIN1024_BLOCK_BYTES < byteCnt;i++) + { + ((u64b_t *)ctx->b)[0]= Skein_Swap64((u64b_t) i); /* build the counter block */ + Skein_Start_New_Type(ctx,OUT_FINAL); + Skein1024_Process_Block(ctx,ctx->b,1,sizeof(u64b_t)); /* run "counter mode" */ + n = byteCnt - i*SKEIN1024_BLOCK_BYTES; /* number of output bytes left to go */ + if (n >= SKEIN1024_BLOCK_BYTES) + n = SKEIN1024_BLOCK_BYTES; + Skein_Put64_LSB_First(hashVal+i*SKEIN1024_BLOCK_BYTES,ctx->X,n); /* "output" the ctr mode bytes */ + Skein_Show_Final(256,&ctx->h,n,hashVal+i*SKEIN1024_BLOCK_BYTES); + memcpy(ctx->X,X,sizeof(X)); /* restore the counter mode key for next time */ + } + return SKEIN_SUCCESS; +} +#endif diff --git a/drivers/staging/skein/skeinApi.c b/drivers/staging/skein/skeinApi.c new file mode 100755 index 000000000000..7b963758d32c --- /dev/null +++ b/drivers/staging/skein/skeinApi.c @@ -0,0 +1,221 @@ +/* +Copyright (c) 2010 Werner Dittmann + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#define SKEIN_ERR_CHECK 1 +#include +#include +#include + +int skeinCtxPrepare(SkeinCtx_t* ctx, SkeinSize_t size) +{ + Skein_Assert(ctx && size, SKEIN_FAIL); + + memset(ctx ,0, sizeof(SkeinCtx_t)); + ctx->skeinSize = size; + + return SKEIN_SUCCESS; +} + +int skeinInit(SkeinCtx_t* ctx, size_t hashBitLen) +{ + int ret = SKEIN_FAIL; + size_t Xlen = 0; + u64b_t* X = NULL; + uint64_t treeInfo = SKEIN_CFG_TREE_INFO_SEQUENTIAL; + + Skein_Assert(ctx, SKEIN_FAIL); + /* + * The following two lines rely of the fact that the real Skein contexts are + * a union in out context and thus have tha maximum memory available. + * The beauty of C :-) . + */ + X = ctx->m.s256.X; + Xlen = ctx->skeinSize/8; + /* + * If size is the same and hash bit length is zero then reuse + * the save chaining variables. + */ + switch (ctx->skeinSize) { + case Skein256: + ret = Skein_256_InitExt(&ctx->m.s256, hashBitLen, + treeInfo, NULL, 0); + break; + case Skein512: + ret = Skein_512_InitExt(&ctx->m.s512, hashBitLen, + treeInfo, NULL, 0); + break; + case Skein1024: + ret = Skein1024_InitExt(&ctx->m.s1024, hashBitLen, + treeInfo, NULL, 0); + break; + } + + if (ret == SKEIN_SUCCESS) { + /* Save chaining variables for this combination of size and hashBitLen */ + memcpy(ctx->XSave, X, Xlen); + } + return ret; +} + +int skeinMacInit(SkeinCtx_t* ctx, const uint8_t *key, size_t keyLen, + size_t hashBitLen) +{ + int ret = SKEIN_FAIL; + u64b_t* X = NULL; + size_t Xlen = 0; + uint64_t treeInfo = SKEIN_CFG_TREE_INFO_SEQUENTIAL; + + Skein_Assert(ctx, SKEIN_FAIL); + + X = ctx->m.s256.X; + Xlen = ctx->skeinSize/8; + + Skein_Assert(hashBitLen, SKEIN_BAD_HASHLEN); + + switch (ctx->skeinSize) { + case Skein256: + ret = Skein_256_InitExt(&ctx->m.s256, hashBitLen, + treeInfo, + (const u08b_t*)key, keyLen); + + break; + case Skein512: + ret = Skein_512_InitExt(&ctx->m.s512, hashBitLen, + treeInfo, + (const u08b_t*)key, keyLen); + break; + case Skein1024: + ret = Skein1024_InitExt(&ctx->m.s1024, hashBitLen, + treeInfo, + (const u08b_t*)key, keyLen); + + break; + } + if (ret == SKEIN_SUCCESS) { + /* Save chaining variables for this combination of key, keyLen, hashBitLen */ + memcpy(ctx->XSave, X, Xlen); + } + return ret; +} + +void skeinReset(SkeinCtx_t* ctx) +{ + size_t Xlen = 0; + u64b_t* X = NULL; + + /* + * The following two lines rely of the fact that the real Skein contexts are + * a union in out context and thus have tha maximum memory available. + * The beautiy of C :-) . + */ + X = ctx->m.s256.X; + Xlen = ctx->skeinSize/8; + /* Restore the chaing variable, reset byte counter */ + memcpy(X, ctx->XSave, Xlen); + + /* Setup context to process the message */ + Skein_Start_New_Type(&ctx->m, MSG); +} + +int skeinUpdate(SkeinCtx_t *ctx, const uint8_t *msg, + size_t msgByteCnt) +{ + int ret = SKEIN_FAIL; + Skein_Assert(ctx, SKEIN_FAIL); + + switch (ctx->skeinSize) { + case Skein256: + ret = Skein_256_Update(&ctx->m.s256, (const u08b_t*)msg, msgByteCnt); + break; + case Skein512: + ret = Skein_512_Update(&ctx->m.s512, (const u08b_t*)msg, msgByteCnt); + break; + case Skein1024: + ret = Skein1024_Update(&ctx->m.s1024, (const u08b_t*)msg, msgByteCnt); + break; + } + return ret; + +} + +int skeinUpdateBits(SkeinCtx_t *ctx, const uint8_t *msg, + size_t msgBitCnt) +{ + /* + * I've used the bit pad implementation from skein_test.c (see NIST CD) + * and modified it to use the convenience functions and added some pointer + * arithmetic. + */ + size_t length; + uint8_t mask; + uint8_t* up; + + /* only the final Update() call is allowed do partial bytes, else assert an error */ + Skein_Assert((ctx->m.h.T[1] & SKEIN_T1_FLAG_BIT_PAD) == 0 || msgBitCnt == 0, SKEIN_FAIL); + + /* if number of bits is a multiple of bytes - that's easy */ + if ((msgBitCnt & 0x7) == 0) { + return skeinUpdate(ctx, msg, msgBitCnt >> 3); + } + skeinUpdate(ctx, msg, (msgBitCnt >> 3) + 1); + + /* + * The next line rely on the fact that the real Skein contexts + * are a union in our context. After the addition the pointer points to + * Skein's real partial block buffer. + * If this layout ever changes we have to adapt this as well. + */ + up = (uint8_t*)ctx->m.s256.X + ctx->skeinSize / 8; + + Skein_Set_Bit_Pad_Flag(ctx->m.h); /* set tweak flag for the skeinFinal call */ + + /* now "pad" the final partial byte the way NIST likes */ + length = ctx->m.h.bCnt; /* get the bCnt value (same location for all block sizes) */ + Skein_assert(length != 0); /* internal sanity check: there IS a partial byte in the buffer! */ + mask = (uint8_t) (1u << (7 - (msgBitCnt & 7))); /* partial byte bit mask */ + up[length-1] = (uint8_t)((up[length-1] & (0-mask))|mask); /* apply bit padding on final byte (in the buffer) */ + + return SKEIN_SUCCESS; +} + +int skeinFinal(SkeinCtx_t* ctx, uint8_t* hash) +{ + int ret = SKEIN_FAIL; + Skein_Assert(ctx, SKEIN_FAIL); + + switch (ctx->skeinSize) { + case Skein256: + ret = Skein_256_Final(&ctx->m.s256, (u08b_t*)hash); + break; + case Skein512: + ret = Skein_512_Final(&ctx->m.s512, (u08b_t*)hash); + break; + case Skein1024: + ret = Skein1024_Final(&ctx->m.s1024, (u08b_t*)hash); + break; + } + return ret; +} diff --git a/drivers/staging/skein/skeinBlockNo3F.c b/drivers/staging/skein/skeinBlockNo3F.c new file mode 100644 index 000000000000..bf4f2bf33ebf --- /dev/null +++ b/drivers/staging/skein/skeinBlockNo3F.c @@ -0,0 +1,172 @@ + +#include +#include +#include + + +/***************************** Skein_256 ******************************/ +void Skein_256_Process_Block(Skein_256_Ctxt_t *ctx, const u08b_t *blkPtr, + size_t blkCnt, size_t byteCntAdd) +{ + ThreefishKey_t key; + u64b_t tweak[2]; + int i; + u64b_t w[SKEIN_256_STATE_WORDS]; /* local copy of input block */ + u64b_t words[3]; + + Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ + tweak[0] = ctx->h.T[0]; + tweak[1] = ctx->h.T[1]; + + do { + u64b_t carry = byteCntAdd; + + words[0] = tweak[0] & 0xffffffffL; + words[1] = ((tweak[0] >> 32) & 0xffffffffL); + words[2] = (tweak[1] & 0xffffffffL); + + for (i = 0; i < 3; i++) { + carry += words[i]; + words[i] = carry; + carry >>= 32; + } + tweak[0] = words[0] & 0xffffffffL; + tweak[0] |= (words[1] & 0xffffffffL) << 32; + tweak[1] |= words[2] & 0xffffffffL; + + threefishSetKey(&key, Threefish256, ctx->X, tweak); + + Skein_Get64_LSB_First(w, blkPtr, SKEIN_256_STATE_WORDS); /* get input block in little-endian format */ + + threefishEncryptBlockWords(&key, w, ctx->X); + + blkPtr += SKEIN_256_BLOCK_BYTES; + + /* do the final "feedforward" xor, update context chaining vars */ + ctx->X[0] = ctx->X[0] ^ w[0]; + ctx->X[1] = ctx->X[1] ^ w[1]; + ctx->X[2] = ctx->X[2] ^ w[2]; + ctx->X[3] = ctx->X[3] ^ w[3]; + + tweak[1] &= ~SKEIN_T1_FLAG_FIRST; + } while (--blkCnt); + + ctx->h.T[0] = tweak[0]; + ctx->h.T[1] = tweak[1]; +} + +void Skein_512_Process_Block(Skein_512_Ctxt_t *ctx, const u08b_t *blkPtr, + size_t blkCnt, size_t byteCntAdd) +{ + ThreefishKey_t key; + u64b_t tweak[2]; + int i; + u64b_t words[3]; + u64b_t w[SKEIN_512_STATE_WORDS]; /* local copy of input block */ + + Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ + tweak[0] = ctx->h.T[0]; + tweak[1] = ctx->h.T[1]; + + do { + u64b_t carry = byteCntAdd; + + words[0] = tweak[0] & 0xffffffffL; + words[1] = ((tweak[0] >> 32) & 0xffffffffL); + words[2] = (tweak[1] & 0xffffffffL); + + for (i = 0; i < 3; i++) { + carry += words[i]; + words[i] = carry; + carry >>= 32; + } + tweak[0] = words[0] & 0xffffffffL; + tweak[0] |= (words[1] & 0xffffffffL) << 32; + tweak[1] |= words[2] & 0xffffffffL; + + threefishSetKey(&key, Threefish512, ctx->X, tweak); + + Skein_Get64_LSB_First(w, blkPtr, SKEIN_512_STATE_WORDS); /* get input block in little-endian format */ + + threefishEncryptBlockWords(&key, w, ctx->X); + + blkPtr += SKEIN_512_BLOCK_BYTES; + + /* do the final "feedforward" xor, update context chaining vars */ + ctx->X[0] = ctx->X[0] ^ w[0]; + ctx->X[1] = ctx->X[1] ^ w[1]; + ctx->X[2] = ctx->X[2] ^ w[2]; + ctx->X[3] = ctx->X[3] ^ w[3]; + ctx->X[4] = ctx->X[4] ^ w[4]; + ctx->X[5] = ctx->X[5] ^ w[5]; + ctx->X[6] = ctx->X[6] ^ w[6]; + ctx->X[7] = ctx->X[7] ^ w[7]; + + tweak[1] &= ~SKEIN_T1_FLAG_FIRST; + } while (--blkCnt); + + ctx->h.T[0] = tweak[0]; + ctx->h.T[1] = tweak[1]; +} + +void Skein1024_Process_Block(Skein1024_Ctxt_t *ctx, const u08b_t *blkPtr, + size_t blkCnt, size_t byteCntAdd) +{ + ThreefishKey_t key; + u64b_t tweak[2]; + int i; + u64b_t words[3]; + u64b_t w[SKEIN1024_STATE_WORDS]; /* local copy of input block */ + + Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ + tweak[0] = ctx->h.T[0]; + tweak[1] = ctx->h.T[1]; + + do { + u64b_t carry = byteCntAdd; + + words[0] = tweak[0] & 0xffffffffL; + words[1] = ((tweak[0] >> 32) & 0xffffffffL); + words[2] = (tweak[1] & 0xffffffffL); + + for (i = 0; i < 3; i++) { + carry += words[i]; + words[i] = carry; + carry >>= 32; + } + tweak[0] = words[0] & 0xffffffffL; + tweak[0] |= (words[1] & 0xffffffffL) << 32; + tweak[1] |= words[2] & 0xffffffffL; + + threefishSetKey(&key, Threefish1024, ctx->X, tweak); + + Skein_Get64_LSB_First(w, blkPtr, SKEIN1024_STATE_WORDS); /* get input block in little-endian format */ + + threefishEncryptBlockWords(&key, w, ctx->X); + + blkPtr += SKEIN1024_BLOCK_BYTES; + + /* do the final "feedforward" xor, update context chaining vars */ + ctx->X[ 0] = ctx->X[ 0] ^ w[ 0]; + ctx->X[ 1] = ctx->X[ 1] ^ w[ 1]; + ctx->X[ 2] = ctx->X[ 2] ^ w[ 2]; + ctx->X[ 3] = ctx->X[ 3] ^ w[ 3]; + ctx->X[ 4] = ctx->X[ 4] ^ w[ 4]; + ctx->X[ 5] = ctx->X[ 5] ^ w[ 5]; + ctx->X[ 6] = ctx->X[ 6] ^ w[ 6]; + ctx->X[ 7] = ctx->X[ 7] ^ w[ 7]; + ctx->X[ 8] = ctx->X[ 8] ^ w[ 8]; + ctx->X[ 9] = ctx->X[ 9] ^ w[ 9]; + ctx->X[10] = ctx->X[10] ^ w[10]; + ctx->X[11] = ctx->X[11] ^ w[11]; + ctx->X[12] = ctx->X[12] ^ w[12]; + ctx->X[13] = ctx->X[13] ^ w[13]; + ctx->X[14] = ctx->X[14] ^ w[14]; + ctx->X[15] = ctx->X[15] ^ w[15]; + + tweak[1] &= ~SKEIN_T1_FLAG_FIRST; + } while (--blkCnt); + + ctx->h.T[0] = tweak[0]; + ctx->h.T[1] = tweak[1]; +} diff --git a/drivers/staging/skein/skein_block.c b/drivers/staging/skein/skein_block.c new file mode 100644 index 000000000000..af79218548ae --- /dev/null +++ b/drivers/staging/skein/skein_block.c @@ -0,0 +1,689 @@ +/*********************************************************************** +** +** Implementation of the Skein block functions. +** +** Source code author: Doug Whiting, 2008. +** +** This algorithm and source code is released to the public domain. +** +** Compile-time switches: +** +** SKEIN_USE_ASM -- set bits (256/512/1024) to select which +** versions use ASM code for block processing +** [default: use C for all block sizes] +** +************************************************************************/ + +#include +#include + +#ifndef SKEIN_USE_ASM +#define SKEIN_USE_ASM (0) /* default is all C code (no ASM) */ +#endif + +#ifndef SKEIN_LOOP +#define SKEIN_LOOP 001 /* default: unroll 256 and 512, but not 1024 */ +#endif + +#define BLK_BITS (WCNT*64) /* some useful definitions for code here */ +#define KW_TWK_BASE (0) +#define KW_KEY_BASE (3) +#define ks (kw + KW_KEY_BASE) +#define ts (kw + KW_TWK_BASE) + +#ifdef SKEIN_DEBUG +#define DebugSaveTweak(ctx) { ctx->h.T[0] = ts[0]; ctx->h.T[1] = ts[1]; } +#else +#define DebugSaveTweak(ctx) +#endif + +/***************************** Skein_256 ******************************/ +#if !(SKEIN_USE_ASM & 256) +void Skein_256_Process_Block(Skein_256_Ctxt_t *ctx,const u08b_t *blkPtr,size_t blkCnt,size_t byteCntAdd) + { /* do it in C */ + enum + { + WCNT = SKEIN_256_STATE_WORDS + }; +#undef RCNT +#define RCNT (SKEIN_256_ROUNDS_TOTAL/8) + +#ifdef SKEIN_LOOP /* configure how much to unroll the loop */ +#define SKEIN_UNROLL_256 (((SKEIN_LOOP)/100)%10) +#else +#define SKEIN_UNROLL_256 (0) +#endif + +#if SKEIN_UNROLL_256 +#if (RCNT % SKEIN_UNROLL_256) +#error "Invalid SKEIN_UNROLL_256" /* sanity check on unroll count */ +#endif + size_t r; + u64b_t kw[WCNT+4+RCNT*2]; /* key schedule words : chaining vars + tweak + "rotation"*/ +#else + u64b_t kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ +#endif + u64b_t X0,X1,X2,X3; /* local copy of context vars, for speed */ + u64b_t w [WCNT]; /* local copy of input block */ +#ifdef SKEIN_DEBUG + const u64b_t *Xptr[4]; /* use for debugging (help compiler put Xn in registers) */ + Xptr[0] = &X0; Xptr[1] = &X1; Xptr[2] = &X2; Xptr[3] = &X3; +#endif + Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ + ts[0] = ctx->h.T[0]; + ts[1] = ctx->h.T[1]; + do { + /* this implementation only supports 2**64 input bytes (no carry out here) */ + ts[0] += byteCntAdd; /* update processed length */ + + /* precompute the key schedule for this block */ + ks[0] = ctx->X[0]; + ks[1] = ctx->X[1]; + ks[2] = ctx->X[2]; + ks[3] = ctx->X[3]; + ks[4] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ SKEIN_KS_PARITY; + + ts[2] = ts[0] ^ ts[1]; + + Skein_Get64_LSB_First(w,blkPtr,WCNT); /* get input block in little-endian format */ + DebugSaveTweak(ctx); + Skein_Show_Block(BLK_BITS,&ctx->h,ctx->X,blkPtr,w,ks,ts); + + X0 = w[0] + ks[0]; /* do the first full key injection */ + X1 = w[1] + ks[1] + ts[0]; + X2 = w[2] + ks[2] + ts[1]; + X3 = w[3] + ks[3]; + + Skein_Show_R_Ptr(BLK_BITS,&ctx->h,SKEIN_RND_KEY_INITIAL,Xptr); /* show starting state values */ + + blkPtr += SKEIN_256_BLOCK_BYTES; + + /* run the rounds */ + +#define Round256(p0,p1,p2,p3,ROT,rNum) \ + X##p0 += X##p1; X##p1 = RotL_64(X##p1,ROT##_0); X##p1 ^= X##p0; \ + X##p2 += X##p3; X##p3 = RotL_64(X##p3,ROT##_1); X##p3 ^= X##p2; \ + +#if SKEIN_UNROLL_256 == 0 +#define R256(p0,p1,p2,p3,ROT,rNum) /* fully unrolled */ \ + Round256(p0,p1,p2,p3,ROT,rNum) \ + Skein_Show_R_Ptr(BLK_BITS,&ctx->h,rNum,Xptr); + +#define I256(R) \ + X0 += ks[((R)+1) % 5]; /* inject the key schedule value */ \ + X1 += ks[((R)+2) % 5] + ts[((R)+1) % 3]; \ + X2 += ks[((R)+3) % 5] + ts[((R)+2) % 3]; \ + X3 += ks[((R)+4) % 5] + (R)+1; \ + Skein_Show_R_Ptr(BLK_BITS,&ctx->h,SKEIN_RND_KEY_INJECT,Xptr); +#else /* looping version */ +#define R256(p0,p1,p2,p3,ROT,rNum) \ + Round256(p0,p1,p2,p3,ROT,rNum) \ + Skein_Show_R_Ptr(BLK_BITS,&ctx->h,4*(r-1)+rNum,Xptr); + +#define I256(R) \ + X0 += ks[r+(R)+0]; /* inject the key schedule value */ \ + X1 += ks[r+(R)+1] + ts[r+(R)+0]; \ + X2 += ks[r+(R)+2] + ts[r+(R)+1]; \ + X3 += ks[r+(R)+3] + r+(R) ; \ + ks[r + (R)+4 ] = ks[r+(R)-1]; /* rotate key schedule */\ + ts[r + (R)+2 ] = ts[r+(R)-1]; \ + Skein_Show_R_Ptr(BLK_BITS,&ctx->h,SKEIN_RND_KEY_INJECT,Xptr); + + for (r=1;r < 2*RCNT;r+=2*SKEIN_UNROLL_256) /* loop thru it */ +#endif + { +#define R256_8_rounds(R) \ + R256(0,1,2,3,R_256_0,8*(R) + 1); \ + R256(0,3,2,1,R_256_1,8*(R) + 2); \ + R256(0,1,2,3,R_256_2,8*(R) + 3); \ + R256(0,3,2,1,R_256_3,8*(R) + 4); \ + I256(2*(R)); \ + R256(0,1,2,3,R_256_4,8*(R) + 5); \ + R256(0,3,2,1,R_256_5,8*(R) + 6); \ + R256(0,1,2,3,R_256_6,8*(R) + 7); \ + R256(0,3,2,1,R_256_7,8*(R) + 8); \ + I256(2*(R)+1); + + R256_8_rounds( 0); + +#define R256_Unroll_R(NN) ((SKEIN_UNROLL_256 == 0 && SKEIN_256_ROUNDS_TOTAL/8 > (NN)) || (SKEIN_UNROLL_256 > (NN))) + + #if R256_Unroll_R( 1) + R256_8_rounds( 1); + #endif + #if R256_Unroll_R( 2) + R256_8_rounds( 2); + #endif + #if R256_Unroll_R( 3) + R256_8_rounds( 3); + #endif + #if R256_Unroll_R( 4) + R256_8_rounds( 4); + #endif + #if R256_Unroll_R( 5) + R256_8_rounds( 5); + #endif + #if R256_Unroll_R( 6) + R256_8_rounds( 6); + #endif + #if R256_Unroll_R( 7) + R256_8_rounds( 7); + #endif + #if R256_Unroll_R( 8) + R256_8_rounds( 8); + #endif + #if R256_Unroll_R( 9) + R256_8_rounds( 9); + #endif + #if R256_Unroll_R(10) + R256_8_rounds(10); + #endif + #if R256_Unroll_R(11) + R256_8_rounds(11); + #endif + #if R256_Unroll_R(12) + R256_8_rounds(12); + #endif + #if R256_Unroll_R(13) + R256_8_rounds(13); + #endif + #if R256_Unroll_R(14) + R256_8_rounds(14); + #endif + #if (SKEIN_UNROLL_256 > 14) +#error "need more unrolling in Skein_256_Process_Block" + #endif + } + /* do the final "feedforward" xor, update context chaining vars */ + ctx->X[0] = X0 ^ w[0]; + ctx->X[1] = X1 ^ w[1]; + ctx->X[2] = X2 ^ w[2]; + ctx->X[3] = X3 ^ w[3]; + + Skein_Show_Round(BLK_BITS,&ctx->h,SKEIN_RND_FEED_FWD,ctx->X); + + ts[1] &= ~SKEIN_T1_FLAG_FIRST; + } + while (--blkCnt); + ctx->h.T[0] = ts[0]; + ctx->h.T[1] = ts[1]; + } + +#if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF) +size_t Skein_256_Process_Block_CodeSize(void) + { + return ((u08b_t *) Skein_256_Process_Block_CodeSize) - + ((u08b_t *) Skein_256_Process_Block); + } +uint_t Skein_256_Unroll_Cnt(void) + { + return SKEIN_UNROLL_256; + } +#endif +#endif + +/***************************** Skein_512 ******************************/ +#if !(SKEIN_USE_ASM & 512) +void Skein_512_Process_Block(Skein_512_Ctxt_t *ctx,const u08b_t *blkPtr,size_t blkCnt,size_t byteCntAdd) + { /* do it in C */ + enum + { + WCNT = SKEIN_512_STATE_WORDS + }; +#undef RCNT +#define RCNT (SKEIN_512_ROUNDS_TOTAL/8) + +#ifdef SKEIN_LOOP /* configure how much to unroll the loop */ +#define SKEIN_UNROLL_512 (((SKEIN_LOOP)/10)%10) +#else +#define SKEIN_UNROLL_512 (0) +#endif + +#if SKEIN_UNROLL_512 +#if (RCNT % SKEIN_UNROLL_512) +#error "Invalid SKEIN_UNROLL_512" /* sanity check on unroll count */ +#endif + size_t r; + u64b_t kw[WCNT+4+RCNT*2]; /* key schedule words : chaining vars + tweak + "rotation"*/ +#else + u64b_t kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ +#endif + u64b_t X0,X1,X2,X3,X4,X5,X6,X7; /* local copy of vars, for speed */ + u64b_t w [WCNT]; /* local copy of input block */ +#ifdef SKEIN_DEBUG + const u64b_t *Xptr[8]; /* use for debugging (help compiler put Xn in registers) */ + Xptr[0] = &X0; Xptr[1] = &X1; Xptr[2] = &X2; Xptr[3] = &X3; + Xptr[4] = &X4; Xptr[5] = &X5; Xptr[6] = &X6; Xptr[7] = &X7; +#endif + + Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ + ts[0] = ctx->h.T[0]; + ts[1] = ctx->h.T[1]; + do { + /* this implementation only supports 2**64 input bytes (no carry out here) */ + ts[0] += byteCntAdd; /* update processed length */ + + /* precompute the key schedule for this block */ + ks[0] = ctx->X[0]; + ks[1] = ctx->X[1]; + ks[2] = ctx->X[2]; + ks[3] = ctx->X[3]; + ks[4] = ctx->X[4]; + ks[5] = ctx->X[5]; + ks[6] = ctx->X[6]; + ks[7] = ctx->X[7]; + ks[8] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ + ks[4] ^ ks[5] ^ ks[6] ^ ks[7] ^ SKEIN_KS_PARITY; + + ts[2] = ts[0] ^ ts[1]; + + Skein_Get64_LSB_First(w,blkPtr,WCNT); /* get input block in little-endian format */ + DebugSaveTweak(ctx); + Skein_Show_Block(BLK_BITS,&ctx->h,ctx->X,blkPtr,w,ks,ts); + + X0 = w[0] + ks[0]; /* do the first full key injection */ + X1 = w[1] + ks[1]; + X2 = w[2] + ks[2]; + X3 = w[3] + ks[3]; + X4 = w[4] + ks[4]; + X5 = w[5] + ks[5] + ts[0]; + X6 = w[6] + ks[6] + ts[1]; + X7 = w[7] + ks[7]; + + blkPtr += SKEIN_512_BLOCK_BYTES; + + Skein_Show_R_Ptr(BLK_BITS,&ctx->h,SKEIN_RND_KEY_INITIAL,Xptr); + /* run the rounds */ +#define Round512(p0,p1,p2,p3,p4,p5,p6,p7,ROT,rNum) \ + X##p0 += X##p1; X##p1 = RotL_64(X##p1,ROT##_0); X##p1 ^= X##p0; \ + X##p2 += X##p3; X##p3 = RotL_64(X##p3,ROT##_1); X##p3 ^= X##p2; \ + X##p4 += X##p5; X##p5 = RotL_64(X##p5,ROT##_2); X##p5 ^= X##p4; \ + X##p6 += X##p7; X##p7 = RotL_64(X##p7,ROT##_3); X##p7 ^= X##p6; \ + +#if SKEIN_UNROLL_512 == 0 +#define R512(p0,p1,p2,p3,p4,p5,p6,p7,ROT,rNum) /* unrolled */ \ + Round512(p0,p1,p2,p3,p4,p5,p6,p7,ROT,rNum) \ + Skein_Show_R_Ptr(BLK_BITS,&ctx->h,rNum,Xptr); + +#define I512(R) \ + X0 += ks[((R)+1) % 9]; /* inject the key schedule value */ \ + X1 += ks[((R)+2) % 9]; \ + X2 += ks[((R)+3) % 9]; \ + X3 += ks[((R)+4) % 9]; \ + X4 += ks[((R)+5) % 9]; \ + X5 += ks[((R)+6) % 9] + ts[((R)+1) % 3]; \ + X6 += ks[((R)+7) % 9] + ts[((R)+2) % 3]; \ + X7 += ks[((R)+8) % 9] + (R)+1; \ + Skein_Show_R_Ptr(BLK_BITS,&ctx->h,SKEIN_RND_KEY_INJECT,Xptr); +#else /* looping version */ +#define R512(p0,p1,p2,p3,p4,p5,p6,p7,ROT,rNum) \ + Round512(p0,p1,p2,p3,p4,p5,p6,p7,ROT,rNum) \ + Skein_Show_R_Ptr(BLK_BITS,&ctx->h,4*(r-1)+rNum,Xptr); + +#define I512(R) \ + X0 += ks[r+(R)+0]; /* inject the key schedule value */ \ + X1 += ks[r+(R)+1]; \ + X2 += ks[r+(R)+2]; \ + X3 += ks[r+(R)+3]; \ + X4 += ks[r+(R)+4]; \ + X5 += ks[r+(R)+5] + ts[r+(R)+0]; \ + X6 += ks[r+(R)+6] + ts[r+(R)+1]; \ + X7 += ks[r+(R)+7] + r+(R) ; \ + ks[r + (R)+8] = ks[r+(R)-1]; /* rotate key schedule */ \ + ts[r + (R)+2] = ts[r+(R)-1]; \ + Skein_Show_R_Ptr(BLK_BITS,&ctx->h,SKEIN_RND_KEY_INJECT,Xptr); + + for (r=1;r < 2*RCNT;r+=2*SKEIN_UNROLL_512) /* loop thru it */ +#endif /* end of looped code definitions */ + { +#define R512_8_rounds(R) /* do 8 full rounds */ \ + R512(0,1,2,3,4,5,6,7,R_512_0,8*(R)+ 1); \ + R512(2,1,4,7,6,5,0,3,R_512_1,8*(R)+ 2); \ + R512(4,1,6,3,0,5,2,7,R_512_2,8*(R)+ 3); \ + R512(6,1,0,7,2,5,4,3,R_512_3,8*(R)+ 4); \ + I512(2*(R)); \ + R512(0,1,2,3,4,5,6,7,R_512_4,8*(R)+ 5); \ + R512(2,1,4,7,6,5,0,3,R_512_5,8*(R)+ 6); \ + R512(4,1,6,3,0,5,2,7,R_512_6,8*(R)+ 7); \ + R512(6,1,0,7,2,5,4,3,R_512_7,8*(R)+ 8); \ + I512(2*(R)+1); /* and key injection */ + + R512_8_rounds( 0); + +#define R512_Unroll_R(NN) ((SKEIN_UNROLL_512 == 0 && SKEIN_512_ROUNDS_TOTAL/8 > (NN)) || (SKEIN_UNROLL_512 > (NN))) + + #if R512_Unroll_R( 1) + R512_8_rounds( 1); + #endif + #if R512_Unroll_R( 2) + R512_8_rounds( 2); + #endif + #if R512_Unroll_R( 3) + R512_8_rounds( 3); + #endif + #if R512_Unroll_R( 4) + R512_8_rounds( 4); + #endif + #if R512_Unroll_R( 5) + R512_8_rounds( 5); + #endif + #if R512_Unroll_R( 6) + R512_8_rounds( 6); + #endif + #if R512_Unroll_R( 7) + R512_8_rounds( 7); + #endif + #if R512_Unroll_R( 8) + R512_8_rounds( 8); + #endif + #if R512_Unroll_R( 9) + R512_8_rounds( 9); + #endif + #if R512_Unroll_R(10) + R512_8_rounds(10); + #endif + #if R512_Unroll_R(11) + R512_8_rounds(11); + #endif + #if R512_Unroll_R(12) + R512_8_rounds(12); + #endif + #if R512_Unroll_R(13) + R512_8_rounds(13); + #endif + #if R512_Unroll_R(14) + R512_8_rounds(14); + #endif + #if (SKEIN_UNROLL_512 > 14) +#error "need more unrolling in Skein_512_Process_Block" + #endif + } + + /* do the final "feedforward" xor, update context chaining vars */ + ctx->X[0] = X0 ^ w[0]; + ctx->X[1] = X1 ^ w[1]; + ctx->X[2] = X2 ^ w[2]; + ctx->X[3] = X3 ^ w[3]; + ctx->X[4] = X4 ^ w[4]; + ctx->X[5] = X5 ^ w[5]; + ctx->X[6] = X6 ^ w[6]; + ctx->X[7] = X7 ^ w[7]; + Skein_Show_Round(BLK_BITS,&ctx->h,SKEIN_RND_FEED_FWD,ctx->X); + + ts[1] &= ~SKEIN_T1_FLAG_FIRST; + } + while (--blkCnt); + ctx->h.T[0] = ts[0]; + ctx->h.T[1] = ts[1]; + } + +#if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF) +size_t Skein_512_Process_Block_CodeSize(void) + { + return ((u08b_t *) Skein_512_Process_Block_CodeSize) - + ((u08b_t *) Skein_512_Process_Block); + } +uint_t Skein_512_Unroll_Cnt(void) + { + return SKEIN_UNROLL_512; + } +#endif +#endif + +/***************************** Skein1024 ******************************/ +#if !(SKEIN_USE_ASM & 1024) +void Skein1024_Process_Block(Skein1024_Ctxt_t *ctx,const u08b_t *blkPtr,size_t blkCnt,size_t byteCntAdd) + { /* do it in C, always looping (unrolled is bigger AND slower!) */ + enum + { + WCNT = SKEIN1024_STATE_WORDS + }; +#undef RCNT +#define RCNT (SKEIN1024_ROUNDS_TOTAL/8) + +#ifdef SKEIN_LOOP /* configure how much to unroll the loop */ +#define SKEIN_UNROLL_1024 ((SKEIN_LOOP)%10) +#else +#define SKEIN_UNROLL_1024 (0) +#endif + +#if (SKEIN_UNROLL_1024 != 0) +#if (RCNT % SKEIN_UNROLL_1024) +#error "Invalid SKEIN_UNROLL_1024" /* sanity check on unroll count */ +#endif + size_t r; + u64b_t kw[WCNT+4+RCNT*2]; /* key schedule words : chaining vars + tweak + "rotation"*/ +#else + u64b_t kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ +#endif + + u64b_t X00,X01,X02,X03,X04,X05,X06,X07, /* local copy of vars, for speed */ + X08,X09,X10,X11,X12,X13,X14,X15; + u64b_t w [WCNT]; /* local copy of input block */ +#ifdef SKEIN_DEBUG + const u64b_t *Xptr[16]; /* use for debugging (help compiler put Xn in registers) */ + Xptr[ 0] = &X00; Xptr[ 1] = &X01; Xptr[ 2] = &X02; Xptr[ 3] = &X03; + Xptr[ 4] = &X04; Xptr[ 5] = &X05; Xptr[ 6] = &X06; Xptr[ 7] = &X07; + Xptr[ 8] = &X08; Xptr[ 9] = &X09; Xptr[10] = &X10; Xptr[11] = &X11; + Xptr[12] = &X12; Xptr[13] = &X13; Xptr[14] = &X14; Xptr[15] = &X15; +#endif + + Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ + ts[0] = ctx->h.T[0]; + ts[1] = ctx->h.T[1]; + do { + /* this implementation only supports 2**64 input bytes (no carry out here) */ + ts[0] += byteCntAdd; /* update processed length */ + + /* precompute the key schedule for this block */ + ks[ 0] = ctx->X[ 0]; + ks[ 1] = ctx->X[ 1]; + ks[ 2] = ctx->X[ 2]; + ks[ 3] = ctx->X[ 3]; + ks[ 4] = ctx->X[ 4]; + ks[ 5] = ctx->X[ 5]; + ks[ 6] = ctx->X[ 6]; + ks[ 7] = ctx->X[ 7]; + ks[ 8] = ctx->X[ 8]; + ks[ 9] = ctx->X[ 9]; + ks[10] = ctx->X[10]; + ks[11] = ctx->X[11]; + ks[12] = ctx->X[12]; + ks[13] = ctx->X[13]; + ks[14] = ctx->X[14]; + ks[15] = ctx->X[15]; + ks[16] = ks[ 0] ^ ks[ 1] ^ ks[ 2] ^ ks[ 3] ^ + ks[ 4] ^ ks[ 5] ^ ks[ 6] ^ ks[ 7] ^ + ks[ 8] ^ ks[ 9] ^ ks[10] ^ ks[11] ^ + ks[12] ^ ks[13] ^ ks[14] ^ ks[15] ^ SKEIN_KS_PARITY; + + ts[2] = ts[0] ^ ts[1]; + + Skein_Get64_LSB_First(w,blkPtr,WCNT); /* get input block in little-endian format */ + DebugSaveTweak(ctx); + Skein_Show_Block(BLK_BITS,&ctx->h,ctx->X,blkPtr,w,ks,ts); + + X00 = w[ 0] + ks[ 0]; /* do the first full key injection */ + X01 = w[ 1] + ks[ 1]; + X02 = w[ 2] + ks[ 2]; + X03 = w[ 3] + ks[ 3]; + X04 = w[ 4] + ks[ 4]; + X05 = w[ 5] + ks[ 5]; + X06 = w[ 6] + ks[ 6]; + X07 = w[ 7] + ks[ 7]; + X08 = w[ 8] + ks[ 8]; + X09 = w[ 9] + ks[ 9]; + X10 = w[10] + ks[10]; + X11 = w[11] + ks[11]; + X12 = w[12] + ks[12]; + X13 = w[13] + ks[13] + ts[0]; + X14 = w[14] + ks[14] + ts[1]; + X15 = w[15] + ks[15]; + + Skein_Show_R_Ptr(BLK_BITS,&ctx->h,SKEIN_RND_KEY_INITIAL,Xptr); + +#define Round1024(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,pA,pB,pC,pD,pE,pF,ROT,rNum) \ + X##p0 += X##p1; X##p1 = RotL_64(X##p1,ROT##_0); X##p1 ^= X##p0; \ + X##p2 += X##p3; X##p3 = RotL_64(X##p3,ROT##_1); X##p3 ^= X##p2; \ + X##p4 += X##p5; X##p5 = RotL_64(X##p5,ROT##_2); X##p5 ^= X##p4; \ + X##p6 += X##p7; X##p7 = RotL_64(X##p7,ROT##_3); X##p7 ^= X##p6; \ + X##p8 += X##p9; X##p9 = RotL_64(X##p9,ROT##_4); X##p9 ^= X##p8; \ + X##pA += X##pB; X##pB = RotL_64(X##pB,ROT##_5); X##pB ^= X##pA; \ + X##pC += X##pD; X##pD = RotL_64(X##pD,ROT##_6); X##pD ^= X##pC; \ + X##pE += X##pF; X##pF = RotL_64(X##pF,ROT##_7); X##pF ^= X##pE; \ + +#if SKEIN_UNROLL_1024 == 0 +#define R1024(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,pA,pB,pC,pD,pE,pF,ROT,rn) \ + Round1024(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,pA,pB,pC,pD,pE,pF,ROT,rn) \ + Skein_Show_R_Ptr(BLK_BITS,&ctx->h,rn,Xptr); + +#define I1024(R) \ + X00 += ks[((R)+ 1) % 17]; /* inject the key schedule value */ \ + X01 += ks[((R)+ 2) % 17]; \ + X02 += ks[((R)+ 3) % 17]; \ + X03 += ks[((R)+ 4) % 17]; \ + X04 += ks[((R)+ 5) % 17]; \ + X05 += ks[((R)+ 6) % 17]; \ + X06 += ks[((R)+ 7) % 17]; \ + X07 += ks[((R)+ 8) % 17]; \ + X08 += ks[((R)+ 9) % 17]; \ + X09 += ks[((R)+10) % 17]; \ + X10 += ks[((R)+11) % 17]; \ + X11 += ks[((R)+12) % 17]; \ + X12 += ks[((R)+13) % 17]; \ + X13 += ks[((R)+14) % 17] + ts[((R)+1) % 3]; \ + X14 += ks[((R)+15) % 17] + ts[((R)+2) % 3]; \ + X15 += ks[((R)+16) % 17] + (R)+1; \ + Skein_Show_R_Ptr(BLK_BITS,&ctx->h,SKEIN_RND_KEY_INJECT,Xptr); +#else /* looping version */ +#define R1024(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,pA,pB,pC,pD,pE,pF,ROT,rn) \ + Round1024(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,pA,pB,pC,pD,pE,pF,ROT,rn) \ + Skein_Show_R_Ptr(BLK_BITS,&ctx->h,4*(r-1)+rn,Xptr); + +#define I1024(R) \ + X00 += ks[r+(R)+ 0]; /* inject the key schedule value */ \ + X01 += ks[r+(R)+ 1]; \ + X02 += ks[r+(R)+ 2]; \ + X03 += ks[r+(R)+ 3]; \ + X04 += ks[r+(R)+ 4]; \ + X05 += ks[r+(R)+ 5]; \ + X06 += ks[r+(R)+ 6]; \ + X07 += ks[r+(R)+ 7]; \ + X08 += ks[r+(R)+ 8]; \ + X09 += ks[r+(R)+ 9]; \ + X10 += ks[r+(R)+10]; \ + X11 += ks[r+(R)+11]; \ + X12 += ks[r+(R)+12]; \ + X13 += ks[r+(R)+13] + ts[r+(R)+0]; \ + X14 += ks[r+(R)+14] + ts[r+(R)+1]; \ + X15 += ks[r+(R)+15] + r+(R) ; \ + ks[r + (R)+16] = ks[r+(R)-1]; /* rotate key schedule */ \ + ts[r + (R)+ 2] = ts[r+(R)-1]; \ + Skein_Show_R_Ptr(BLK_BITS,&ctx->h,SKEIN_RND_KEY_INJECT,Xptr); + + for (r=1;r <= 2*RCNT;r+=2*SKEIN_UNROLL_1024) /* loop thru it */ +#endif + { +#define R1024_8_rounds(R) /* do 8 full rounds */ \ + R1024(00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,R1024_0,8*(R) + 1); \ + R1024(00,09,02,13,06,11,04,15,10,07,12,03,14,05,08,01,R1024_1,8*(R) + 2); \ + R1024(00,07,02,05,04,03,06,01,12,15,14,13,08,11,10,09,R1024_2,8*(R) + 3); \ + R1024(00,15,02,11,06,13,04,09,14,01,08,05,10,03,12,07,R1024_3,8*(R) + 4); \ + I1024(2*(R)); \ + R1024(00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,R1024_4,8*(R) + 5); \ + R1024(00,09,02,13,06,11,04,15,10,07,12,03,14,05,08,01,R1024_5,8*(R) + 6); \ + R1024(00,07,02,05,04,03,06,01,12,15,14,13,08,11,10,09,R1024_6,8*(R) + 7); \ + R1024(00,15,02,11,06,13,04,09,14,01,08,05,10,03,12,07,R1024_7,8*(R) + 8); \ + I1024(2*(R)+1); + + R1024_8_rounds( 0); + +#define R1024_Unroll_R(NN) ((SKEIN_UNROLL_1024 == 0 && SKEIN1024_ROUNDS_TOTAL/8 > (NN)) || (SKEIN_UNROLL_1024 > (NN))) + + #if R1024_Unroll_R( 1) + R1024_8_rounds( 1); + #endif + #if R1024_Unroll_R( 2) + R1024_8_rounds( 2); + #endif + #if R1024_Unroll_R( 3) + R1024_8_rounds( 3); + #endif + #if R1024_Unroll_R( 4) + R1024_8_rounds( 4); + #endif + #if R1024_Unroll_R( 5) + R1024_8_rounds( 5); + #endif + #if R1024_Unroll_R( 6) + R1024_8_rounds( 6); + #endif + #if R1024_Unroll_R( 7) + R1024_8_rounds( 7); + #endif + #if R1024_Unroll_R( 8) + R1024_8_rounds( 8); + #endif + #if R1024_Unroll_R( 9) + R1024_8_rounds( 9); + #endif + #if R1024_Unroll_R(10) + R1024_8_rounds(10); + #endif + #if R1024_Unroll_R(11) + R1024_8_rounds(11); + #endif + #if R1024_Unroll_R(12) + R1024_8_rounds(12); + #endif + #if R1024_Unroll_R(13) + R1024_8_rounds(13); + #endif + #if R1024_Unroll_R(14) + R1024_8_rounds(14); + #endif + #if (SKEIN_UNROLL_1024 > 14) +#error "need more unrolling in Skein_1024_Process_Block" + #endif + } + /* do the final "feedforward" xor, update context chaining vars */ + + ctx->X[ 0] = X00 ^ w[ 0]; + ctx->X[ 1] = X01 ^ w[ 1]; + ctx->X[ 2] = X02 ^ w[ 2]; + ctx->X[ 3] = X03 ^ w[ 3]; + ctx->X[ 4] = X04 ^ w[ 4]; + ctx->X[ 5] = X05 ^ w[ 5]; + ctx->X[ 6] = X06 ^ w[ 6]; + ctx->X[ 7] = X07 ^ w[ 7]; + ctx->X[ 8] = X08 ^ w[ 8]; + ctx->X[ 9] = X09 ^ w[ 9]; + ctx->X[10] = X10 ^ w[10]; + ctx->X[11] = X11 ^ w[11]; + ctx->X[12] = X12 ^ w[12]; + ctx->X[13] = X13 ^ w[13]; + ctx->X[14] = X14 ^ w[14]; + ctx->X[15] = X15 ^ w[15]; + + Skein_Show_Round(BLK_BITS,&ctx->h,SKEIN_RND_FEED_FWD,ctx->X); + + ts[1] &= ~SKEIN_T1_FLAG_FIRST; + blkPtr += SKEIN1024_BLOCK_BYTES; + } + while (--blkCnt); + ctx->h.T[0] = ts[0]; + ctx->h.T[1] = ts[1]; + } + +#if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF) +size_t Skein1024_Process_Block_CodeSize(void) + { + return ((u08b_t *) Skein1024_Process_Block_CodeSize) - + ((u08b_t *) Skein1024_Process_Block); + } +uint_t Skein1024_Unroll_Cnt(void) + { + return SKEIN_UNROLL_1024; + } +#endif +#endif diff --git a/drivers/staging/skein/threefish1024Block.c b/drivers/staging/skein/threefish1024Block.c new file mode 100644 index 000000000000..8b43586f46bc --- /dev/null +++ b/drivers/staging/skein/threefish1024Block.c @@ -0,0 +1,1385 @@ +#include +#include +#include + + +void threefishEncrypt1024(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output) + { + + uint64_t b0 = input[0], b1 = input[1], + b2 = input[2], b3 = input[3], + b4 = input[4], b5 = input[5], + b6 = input[6], b7 = input[7], + b8 = input[8], b9 = input[9], + b10 = input[10], b11 = input[11], + b12 = input[12], b13 = input[13], + b14 = input[14], b15 = input[15]; + uint64_t k0 = keyCtx->key[0], k1 = keyCtx->key[1], + k2 = keyCtx->key[2], k3 = keyCtx->key[3], + k4 = keyCtx->key[4], k5 = keyCtx->key[5], + k6 = keyCtx->key[6], k7 = keyCtx->key[7], + k8 = keyCtx->key[8], k9 = keyCtx->key[9], + k10 = keyCtx->key[10], k11 = keyCtx->key[11], + k12 = keyCtx->key[12], k13 = keyCtx->key[13], + k14 = keyCtx->key[14], k15 = keyCtx->key[15], + k16 = keyCtx->key[16]; + uint64_t t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], + t2 = keyCtx->tweak[2]; + + b1 += k1; b0 += b1 + k0; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + b3 += k3; b2 += b3 + k2; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + b5 += k5; b4 += b5 + k4; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + b7 += k7; b6 += b7 + k6; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + b9 += k9; b8 += b9 + k8; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + b11 += k11; b10 += b11 + k10; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + b13 += k13 + t0; b12 += b13 + k12; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + b15 += k15; b14 += b15 + k14 + t1; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + b1 += k2; b0 += b1 + k1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + b3 += k4; b2 += b3 + k3; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + b5 += k6; b4 += b5 + k5; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + b7 += k8; b6 += b7 + k7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + b9 += k10; b8 += b9 + k9; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + b11 += k12; b10 += b11 + k11; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + b13 += k14 + t1; b12 += b13 + k13; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + b15 += k16 + 1; b14 += b15 + k15 + t2; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + b1 += k3; b0 += b1 + k2; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + b3 += k5; b2 += b3 + k4; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + b5 += k7; b4 += b5 + k6; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + b7 += k9; b6 += b7 + k8; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + b9 += k11; b8 += b9 + k10; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + b11 += k13; b10 += b11 + k12; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + b13 += k15 + t2; b12 += b13 + k14; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + b15 += k0 + 2; b14 += b15 + k16 + t0; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + b1 += k4; b0 += b1 + k3; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + b3 += k6; b2 += b3 + k5; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + b5 += k8; b4 += b5 + k7; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + b7 += k10; b6 += b7 + k9; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + b9 += k12; b8 += b9 + k11; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + b11 += k14; b10 += b11 + k13; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + b13 += k16 + t0; b12 += b13 + k15; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + b15 += k1 + 3; b14 += b15 + k0 + t1; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + b1 += k5; b0 += b1 + k4; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + b3 += k7; b2 += b3 + k6; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + b5 += k9; b4 += b5 + k8; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + b7 += k11; b6 += b7 + k10; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + b9 += k13; b8 += b9 + k12; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + b11 += k15; b10 += b11 + k14; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + b13 += k0 + t1; b12 += b13 + k16; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + b15 += k2 + 4; b14 += b15 + k1 + t2; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + b1 += k6; b0 += b1 + k5; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + b3 += k8; b2 += b3 + k7; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + b5 += k10; b4 += b5 + k9; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + b7 += k12; b6 += b7 + k11; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + b9 += k14; b8 += b9 + k13; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + b11 += k16; b10 += b11 + k15; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + b13 += k1 + t2; b12 += b13 + k0; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + b15 += k3 + 5; b14 += b15 + k2 + t0; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + b1 += k7; b0 += b1 + k6; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + b3 += k9; b2 += b3 + k8; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + b5 += k11; b4 += b5 + k10; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + b7 += k13; b6 += b7 + k12; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + b9 += k15; b8 += b9 + k14; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + b11 += k0; b10 += b11 + k16; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + b13 += k2 + t0; b12 += b13 + k1; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + b15 += k4 + 6; b14 += b15 + k3 + t1; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + b1 += k8; b0 += b1 + k7; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + b3 += k10; b2 += b3 + k9; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + b5 += k12; b4 += b5 + k11; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + b7 += k14; b6 += b7 + k13; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + b9 += k16; b8 += b9 + k15; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + b11 += k1; b10 += b11 + k0; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + b13 += k3 + t1; b12 += b13 + k2; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + b15 += k5 + 7; b14 += b15 + k4 + t2; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + b1 += k9; b0 += b1 + k8; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + b3 += k11; b2 += b3 + k10; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + b5 += k13; b4 += b5 + k12; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + b7 += k15; b6 += b7 + k14; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + b9 += k0; b8 += b9 + k16; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + b11 += k2; b10 += b11 + k1; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + b13 += k4 + t2; b12 += b13 + k3; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + b15 += k6 + 8; b14 += b15 + k5 + t0; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + b1 += k10; b0 += b1 + k9; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + b3 += k12; b2 += b3 + k11; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + b5 += k14; b4 += b5 + k13; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + b7 += k16; b6 += b7 + k15; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + b9 += k1; b8 += b9 + k0; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + b11 += k3; b10 += b11 + k2; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + b13 += k5 + t0; b12 += b13 + k4; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + b15 += k7 + 9; b14 += b15 + k6 + t1; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + b1 += k11; b0 += b1 + k10; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + b3 += k13; b2 += b3 + k12; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + b5 += k15; b4 += b5 + k14; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + b7 += k0; b6 += b7 + k16; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + b9 += k2; b8 += b9 + k1; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + b11 += k4; b10 += b11 + k3; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + b13 += k6 + t1; b12 += b13 + k5; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + b15 += k8 + 10; b14 += b15 + k7 + t2; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + b1 += k12; b0 += b1 + k11; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + b3 += k14; b2 += b3 + k13; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + b5 += k16; b4 += b5 + k15; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + b7 += k1; b6 += b7 + k0; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + b9 += k3; b8 += b9 + k2; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + b11 += k5; b10 += b11 + k4; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + b13 += k7 + t2; b12 += b13 + k6; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + b15 += k9 + 11; b14 += b15 + k8 + t0; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + b1 += k13; b0 += b1 + k12; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + b3 += k15; b2 += b3 + k14; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + b5 += k0; b4 += b5 + k16; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + b7 += k2; b6 += b7 + k1; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + b9 += k4; b8 += b9 + k3; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + b11 += k6; b10 += b11 + k5; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + b13 += k8 + t0; b12 += b13 + k7; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + b15 += k10 + 12; b14 += b15 + k9 + t1; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + b1 += k14; b0 += b1 + k13; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + b3 += k16; b2 += b3 + k15; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + b5 += k1; b4 += b5 + k0; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + b7 += k3; b6 += b7 + k2; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + b9 += k5; b8 += b9 + k4; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + b11 += k7; b10 += b11 + k6; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + b13 += k9 + t1; b12 += b13 + k8; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + b15 += k11 + 13; b14 += b15 + k10 + t2; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + b1 += k15; b0 += b1 + k14; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + b3 += k0; b2 += b3 + k16; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + b5 += k2; b4 += b5 + k1; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + b7 += k4; b6 += b7 + k3; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + b9 += k6; b8 += b9 + k5; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + b11 += k8; b10 += b11 + k7; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + b13 += k10 + t2; b12 += b13 + k9; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + b15 += k12 + 14; b14 += b15 + k11 + t0; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + b1 += k16; b0 += b1 + k15; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + b3 += k1; b2 += b3 + k0; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + b5 += k3; b4 += b5 + k2; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + b7 += k5; b6 += b7 + k4; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + b9 += k7; b8 += b9 + k6; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + b11 += k9; b10 += b11 + k8; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + b13 += k11 + t0; b12 += b13 + k10; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + b15 += k13 + 15; b14 += b15 + k12 + t1; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + b1 += k0; b0 += b1 + k16; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + b3 += k2; b2 += b3 + k1; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + b5 += k4; b4 += b5 + k3; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + b7 += k6; b6 += b7 + k5; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + b9 += k8; b8 += b9 + k7; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + b11 += k10; b10 += b11 + k9; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + b13 += k12 + t1; b12 += b13 + k11; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + b15 += k14 + 16; b14 += b15 + k13 + t2; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + b1 += k1; b0 += b1 + k0; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + b3 += k3; b2 += b3 + k2; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + b5 += k5; b4 += b5 + k4; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + b7 += k7; b6 += b7 + k6; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + b9 += k9; b8 += b9 + k8; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + b11 += k11; b10 += b11 + k10; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + b13 += k13 + t2; b12 += b13 + k12; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + b15 += k15 + 17; b14 += b15 + k14 + t0; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + b1 += k2; b0 += b1 + k1; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + b3 += k4; b2 += b3 + k3; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + b5 += k6; b4 += b5 + k5; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + b7 += k8; b6 += b7 + k7; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + b9 += k10; b8 += b9 + k9; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + b11 += k12; b10 += b11 + k11; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + b13 += k14 + t0; b12 += b13 + k13; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + b15 += k16 + 18; b14 += b15 + k15 + t1; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + b1 += k3; b0 += b1 + k2; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + b3 += k5; b2 += b3 + k4; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + b5 += k7; b4 += b5 + k6; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + b7 += k9; b6 += b7 + k8; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + b9 += k11; b8 += b9 + k10; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + b11 += k13; b10 += b11 + k12; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + b13 += k15 + t1; b12 += b13 + k14; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + b15 += k0 + 19; b14 += b15 + k16 + t2; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + output[0] = b0 + k3; + output[1] = b1 + k4; + output[2] = b2 + k5; + output[3] = b3 + k6; + output[4] = b4 + k7; + output[5] = b5 + k8; + output[6] = b6 + k9; + output[7] = b7 + k10; + output[8] = b8 + k11; + output[9] = b9 + k12; + output[10] = b10 + k13; + output[11] = b11 + k14; + output[12] = b12 + k15; + output[13] = b13 + k16 + t2; + output[14] = b14 + k0 + t0; + output[15] = b15 + k1 + 20; + } + +void threefishDecrypt1024(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output) +{ + + uint64_t b0 = input[0], b1 = input[1], + b2 = input[2], b3 = input[3], + b4 = input[4], b5 = input[5], + b6 = input[6], b7 = input[7], + b8 = input[8], b9 = input[9], + b10 = input[10], b11 = input[11], + b12 = input[12], b13 = input[13], + b14 = input[14], b15 = input[15]; + uint64_t k0 = keyCtx->key[0], k1 = keyCtx->key[1], + k2 = keyCtx->key[2], k3 = keyCtx->key[3], + k4 = keyCtx->key[4], k5 = keyCtx->key[5], + k6 = keyCtx->key[6], k7 = keyCtx->key[7], + k8 = keyCtx->key[8], k9 = keyCtx->key[9], + k10 = keyCtx->key[10], k11 = keyCtx->key[11], + k12 = keyCtx->key[12], k13 = keyCtx->key[13], + k14 = keyCtx->key[14], k15 = keyCtx->key[15], + k16 = keyCtx->key[16]; + uint64_t t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], + t2 = keyCtx->tweak[2]; + uint64_t tmp; + + b0 -= k3; + b1 -= k4; + b2 -= k5; + b3 -= k6; + b4 -= k7; + b5 -= k8; + b6 -= k9; + b7 -= k10; + b8 -= k11; + b9 -= k12; + b10 -= k13; + b11 -= k14; + b12 -= k15; + b13 -= k16 + t2; + b14 -= k0 + t0; + b15 -= k1 + 20; + tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k16 + t2; b15 -= k0 + 19; + tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k14; b13 -= k15 + t1; + tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k12; b11 -= k13; + tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k10; b9 -= k11; + tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k8; b7 -= k9; + tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k6; b5 -= k7; + tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k4; b3 -= k5; + tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k2; b1 -= k3; + tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k15 + t1; b15 -= k16 + 18; + tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k13; b13 -= k14 + t0; + tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k11; b11 -= k12; + tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k9; b9 -= k10; + tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k7; b7 -= k8; + tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k5; b5 -= k6; + tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k3; b3 -= k4; + tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k1; b1 -= k2; + tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k14 + t0; b15 -= k15 + 17; + tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k12; b13 -= k13 + t2; + tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k10; b11 -= k11; + tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k8; b9 -= k9; + tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k6; b7 -= k7; + tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k4; b5 -= k5; + tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k2; b3 -= k3; + tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k0; b1 -= k1; + tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k13 + t2; b15 -= k14 + 16; + tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k11; b13 -= k12 + t1; + tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k9; b11 -= k10; + tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k7; b9 -= k8; + tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k5; b7 -= k6; + tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k3; b5 -= k4; + tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k1; b3 -= k2; + tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k16; b1 -= k0; + tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k12 + t1; b15 -= k13 + 15; + tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k10; b13 -= k11 + t0; + tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k8; b11 -= k9; + tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k6; b9 -= k7; + tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k4; b7 -= k5; + tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k2; b5 -= k3; + tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k0; b3 -= k1; + tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k15; b1 -= k16; + tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k11 + t0; b15 -= k12 + 14; + tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k9; b13 -= k10 + t2; + tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k7; b11 -= k8; + tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k5; b9 -= k6; + tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k3; b7 -= k4; + tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k1; b5 -= k2; + tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k16; b3 -= k0; + tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k14; b1 -= k15; + tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k10 + t2; b15 -= k11 + 13; + tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k8; b13 -= k9 + t1; + tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k6; b11 -= k7; + tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k4; b9 -= k5; + tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k2; b7 -= k3; + tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k0; b5 -= k1; + tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k15; b3 -= k16; + tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k13; b1 -= k14; + tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k9 + t1; b15 -= k10 + 12; + tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k7; b13 -= k8 + t0; + tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k5; b11 -= k6; + tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k3; b9 -= k4; + tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k1; b7 -= k2; + tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k16; b5 -= k0; + tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k14; b3 -= k15; + tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k12; b1 -= k13; + tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k8 + t0; b15 -= k9 + 11; + tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k6; b13 -= k7 + t2; + tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k4; b11 -= k5; + tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k2; b9 -= k3; + tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k0; b7 -= k1; + tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k15; b5 -= k16; + tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k13; b3 -= k14; + tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k11; b1 -= k12; + tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k7 + t2; b15 -= k8 + 10; + tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k5; b13 -= k6 + t1; + tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k3; b11 -= k4; + tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k1; b9 -= k2; + tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k16; b7 -= k0; + tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k14; b5 -= k15; + tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k12; b3 -= k13; + tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k10; b1 -= k11; + tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k6 + t1; b15 -= k7 + 9; + tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k4; b13 -= k5 + t0; + tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k2; b11 -= k3; + tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k0; b9 -= k1; + tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k15; b7 -= k16; + tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k13; b5 -= k14; + tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k11; b3 -= k12; + tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k9; b1 -= k10; + tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k5 + t0; b15 -= k6 + 8; + tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k3; b13 -= k4 + t2; + tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k1; b11 -= k2; + tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k16; b9 -= k0; + tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k14; b7 -= k15; + tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k12; b5 -= k13; + tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k10; b3 -= k11; + tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k8; b1 -= k9; + tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k4 + t2; b15 -= k5 + 7; + tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k2; b13 -= k3 + t1; + tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k0; b11 -= k1; + tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k15; b9 -= k16; + tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k13; b7 -= k14; + tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k11; b5 -= k12; + tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k9; b3 -= k10; + tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k7; b1 -= k8; + tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k3 + t1; b15 -= k4 + 6; + tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k1; b13 -= k2 + t0; + tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k16; b11 -= k0; + tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k14; b9 -= k15; + tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k12; b7 -= k13; + tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k10; b5 -= k11; + tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k8; b3 -= k9; + tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k6; b1 -= k7; + tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k2 + t0; b15 -= k3 + 5; + tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k0; b13 -= k1 + t2; + tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k15; b11 -= k16; + tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k13; b9 -= k14; + tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k11; b7 -= k12; + tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k9; b5 -= k10; + tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k7; b3 -= k8; + tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k5; b1 -= k6; + tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k1 + t2; b15 -= k2 + 4; + tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k16; b13 -= k0 + t1; + tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k14; b11 -= k15; + tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k12; b9 -= k13; + tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k10; b7 -= k11; + tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k8; b5 -= k9; + tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k6; b3 -= k7; + tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k4; b1 -= k5; + tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k0 + t1; b15 -= k1 + 3; + tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k15; b13 -= k16 + t0; + tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k13; b11 -= k14; + tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k11; b9 -= k12; + tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k9; b7 -= k10; + tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k7; b5 -= k8; + tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k5; b3 -= k6; + tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k3; b1 -= k4; + tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k16 + t0; b15 -= k0 + 2; + tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k14; b13 -= k15 + t2; + tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k12; b11 -= k13; + tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k10; b9 -= k11; + tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k8; b7 -= k9; + tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k6; b5 -= k7; + tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k4; b3 -= k5; + tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k2; b1 -= k3; + tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k15 + t2; b15 -= k16 + 1; + tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k13; b13 -= k14 + t1; + tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k11; b11 -= k12; + tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k9; b9 -= k10; + tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k7; b7 -= k8; + tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k5; b5 -= k6; + tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k3; b3 -= k4; + tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k1; b1 -= k2; + tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k14 + t1; b15 -= k15; + tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k12; b13 -= k13 + t0; + tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k10; b11 -= k11; + tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k8; b9 -= k9; + tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k6; b7 -= k7; + tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k4; b5 -= k5; + tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k2; b3 -= k3; + tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k0; b1 -= k1; + + output[15] = b15; + output[14] = b14; + output[13] = b13; + output[12] = b12; + output[11] = b11; + output[10] = b10; + output[9] = b9; + output[8] = b8; + output[7] = b7; + output[6] = b6; + output[5] = b5; + output[4] = b4; + output[3] = b3; + output[2] = b2; + output[1] = b1; + output[0] = b0; +} diff --git a/drivers/staging/skein/threefish256Block.c b/drivers/staging/skein/threefish256Block.c new file mode 100644 index 000000000000..db2b81978c91 --- /dev/null +++ b/drivers/staging/skein/threefish256Block.c @@ -0,0 +1,349 @@ +#include +#include +#include + + +void threefishEncrypt256(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output) + { + + uint64_t b0 = input[0], b1 = input[1], + b2 = input[2], b3 = input[3]; + uint64_t k0 = keyCtx->key[0], k1 = keyCtx->key[1], + k2 = keyCtx->key[2], k3 = keyCtx->key[3], + k4 = keyCtx->key[4]; + uint64_t t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], + t2 = keyCtx->tweak[2]; + + b1 += k1 + t0; b0 += b1 + k0; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + b3 += k3; b2 += b3 + k2 + t1; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + b1 += k2 + t1; b0 += b1 + k1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + b3 += k4 + 1; b2 += b3 + k3 + t2; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + b1 += k3 + t2; b0 += b1 + k2; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + b3 += k0 + 2; b2 += b3 + k4 + t0; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + b1 += k4 + t0; b0 += b1 + k3; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + b3 += k1 + 3; b2 += b3 + k0 + t1; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + b1 += k0 + t1; b0 += b1 + k4; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + b3 += k2 + 4; b2 += b3 + k1 + t2; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + b1 += k1 + t2; b0 += b1 + k0; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + b3 += k3 + 5; b2 += b3 + k2 + t0; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + b1 += k2 + t0; b0 += b1 + k1; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + b3 += k4 + 6; b2 += b3 + k3 + t1; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + b1 += k3 + t1; b0 += b1 + k2; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + b3 += k0 + 7; b2 += b3 + k4 + t2; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + b1 += k4 + t2; b0 += b1 + k3; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + b3 += k1 + 8; b2 += b3 + k0 + t0; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + b1 += k0 + t0; b0 += b1 + k4; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + b3 += k2 + 9; b2 += b3 + k1 + t1; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + b1 += k1 + t1; b0 += b1 + k0; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + b3 += k3 + 10; b2 += b3 + k2 + t2; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + b1 += k2 + t2; b0 += b1 + k1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + b3 += k4 + 11; b2 += b3 + k3 + t0; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + b1 += k3 + t0; b0 += b1 + k2; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + b3 += k0 + 12; b2 += b3 + k4 + t1; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + b1 += k4 + t1; b0 += b1 + k3; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + b3 += k1 + 13; b2 += b3 + k0 + t2; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + b1 += k0 + t2; b0 += b1 + k4; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + b3 += k2 + 14; b2 += b3 + k1 + t0; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + b1 += k1 + t0; b0 += b1 + k0; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + b3 += k3 + 15; b2 += b3 + k2 + t1; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + b1 += k2 + t1; b0 += b1 + k1; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + b3 += k4 + 16; b2 += b3 + k3 + t2; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + b1 += k3 + t2; b0 += b1 + k2; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + b3 += k0 + 17; b2 += b3 + k4 + t0; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + output[0] = b0 + k3; + output[1] = b1 + k4 + t0; + output[2] = b2 + k0 + t1; + output[3] = b3 + k1 + 18; + } + +void threefishDecrypt256(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output) + { + uint64_t b0 = input[0], b1 = input[1], + b2 = input[2], b3 = input[3]; + uint64_t k0 = keyCtx->key[0], k1 = keyCtx->key[1], + k2 = keyCtx->key[2], k3 = keyCtx->key[3], + k4 = keyCtx->key[4]; + uint64_t t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], + t2 = keyCtx->tweak[2]; + + uint64_t tmp; + + b0 -= k3; + b1 -= k4 + t0; + b2 -= k0 + t1; + b3 -= k1 + 18; + tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k2; b1 -= k3 + t2; + tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k4 + t0; b3 -= k0 + 17; + tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k1; b1 -= k2 + t1; + tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k3 + t2; b3 -= k4 + 16; + + tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k0; b1 -= k1 + t0; + tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k2 + t1; b3 -= k3 + 15; + tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k4; b1 -= k0 + t2; + tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k1 + t0; b3 -= k2 + 14; + + tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k3; b1 -= k4 + t1; + tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k0 + t2; b3 -= k1 + 13; + tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k2; b1 -= k3 + t0; + tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k4 + t1; b3 -= k0 + 12; + + tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k1; b1 -= k2 + t2; + tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k3 + t0; b3 -= k4 + 11; + tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k0; b1 -= k1 + t1; + tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k2 + t2; b3 -= k3 + 10; + + tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k4; b1 -= k0 + t0; + tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k1 + t1; b3 -= k2 + 9; + tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k3; b1 -= k4 + t2; + tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k0 + t0; b3 -= k1 + 8; + + tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k2; b1 -= k3 + t1; + tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k4 + t2; b3 -= k0 + 7; + tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k1; b1 -= k2 + t0; + tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k3 + t1; b3 -= k4 + 6; + + tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k0; b1 -= k1 + t2; + tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k2 + t0; b3 -= k3 + 5; + tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k4; b1 -= k0 + t1; + tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k1 + t2; b3 -= k2 + 4; + + tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k3; b1 -= k4 + t0; + tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k0 + t1; b3 -= k1 + 3; + tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k2; b1 -= k3 + t2; + tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k4 + t0; b3 -= k0 + 2; + + tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k1; b1 -= k2 + t1; + tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k3 + t2; b3 -= k4 + 1; + tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k0; b1 -= k1 + t0; + tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k2 + t1; b3 -= k3; + + output[0] = b0; + output[1] = b1; + output[2] = b2; + output[3] = b3; + } diff --git a/drivers/staging/skein/threefish512Block.c b/drivers/staging/skein/threefish512Block.c new file mode 100644 index 000000000000..4fe708fea066 --- /dev/null +++ b/drivers/staging/skein/threefish512Block.c @@ -0,0 +1,643 @@ +#include +#include +#include + + +void threefishEncrypt512(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output) + { + + uint64_t b0 = input[0], b1 = input[1], + b2 = input[2], b3 = input[3], + b4 = input[4], b5 = input[5], + b6 = input[6], b7 = input[7]; + uint64_t k0 = keyCtx->key[0], k1 = keyCtx->key[1], + k2 = keyCtx->key[2], k3 = keyCtx->key[3], + k4 = keyCtx->key[4], k5 = keyCtx->key[5], + k6 = keyCtx->key[6], k7 = keyCtx->key[7], + k8 = keyCtx->key[8]; + uint64_t t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], + t2 = keyCtx->tweak[2]; + + b1 += k1; b0 += b1 + k0; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + b3 += k3; b2 += b3 + k2; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + b5 += k5 + t0; b4 += b5 + k4; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + b7 += k7; b6 += b7 + k6 + t1; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + b1 += k2; b0 += b1 + k1; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + b3 += k4; b2 += b3 + k3; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + b5 += k6 + t1; b4 += b5 + k5; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + b7 += k8 + 1; b6 += b7 + k7 + t2; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + b1 += k3; b0 += b1 + k2; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + b3 += k5; b2 += b3 + k4; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + b5 += k7 + t2; b4 += b5 + k6; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + b7 += k0 + 2; b6 += b7 + k8 + t0; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + b1 += k4; b0 += b1 + k3; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + b3 += k6; b2 += b3 + k5; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + b5 += k8 + t0; b4 += b5 + k7; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + b7 += k1 + 3; b6 += b7 + k0 + t1; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + b1 += k5; b0 += b1 + k4; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + b3 += k7; b2 += b3 + k6; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + b5 += k0 + t1; b4 += b5 + k8; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + b7 += k2 + 4; b6 += b7 + k1 + t2; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + b1 += k6; b0 += b1 + k5; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + b3 += k8; b2 += b3 + k7; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + b5 += k1 + t2; b4 += b5 + k0; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + b7 += k3 + 5; b6 += b7 + k2 + t0; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + b1 += k7; b0 += b1 + k6; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + b3 += k0; b2 += b3 + k8; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + b5 += k2 + t0; b4 += b5 + k1; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + b7 += k4 + 6; b6 += b7 + k3 + t1; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + b1 += k8; b0 += b1 + k7; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + b3 += k1; b2 += b3 + k0; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + b5 += k3 + t1; b4 += b5 + k2; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + b7 += k5 + 7; b6 += b7 + k4 + t2; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + b1 += k0; b0 += b1 + k8; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + b3 += k2; b2 += b3 + k1; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + b5 += k4 + t2; b4 += b5 + k3; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + b7 += k6 + 8; b6 += b7 + k5 + t0; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + b1 += k1; b0 += b1 + k0; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + b3 += k3; b2 += b3 + k2; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + b5 += k5 + t0; b4 += b5 + k4; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + b7 += k7 + 9; b6 += b7 + k6 + t1; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + b1 += k2; b0 += b1 + k1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + b3 += k4; b2 += b3 + k3; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + b5 += k6 + t1; b4 += b5 + k5; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + b7 += k8 + 10; b6 += b7 + k7 + t2; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + b1 += k3; b0 += b1 + k2; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + b3 += k5; b2 += b3 + k4; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + b5 += k7 + t2; b4 += b5 + k6; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + b7 += k0 + 11; b6 += b7 + k8 + t0; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + b1 += k4; b0 += b1 + k3; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + b3 += k6; b2 += b3 + k5; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + b5 += k8 + t0; b4 += b5 + k7; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + b7 += k1 + 12; b6 += b7 + k0 + t1; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + b1 += k5; b0 += b1 + k4; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + b3 += k7; b2 += b3 + k6; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + b5 += k0 + t1; b4 += b5 + k8; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + b7 += k2 + 13; b6 += b7 + k1 + t2; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + b1 += k6; b0 += b1 + k5; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + b3 += k8; b2 += b3 + k7; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + b5 += k1 + t2; b4 += b5 + k0; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + b7 += k3 + 14; b6 += b7 + k2 + t0; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + b1 += k7; b0 += b1 + k6; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + b3 += k0; b2 += b3 + k8; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + b5 += k2 + t0; b4 += b5 + k1; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + b7 += k4 + 15; b6 += b7 + k3 + t1; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + b1 += k8; b0 += b1 + k7; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + b3 += k1; b2 += b3 + k0; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + b5 += k3 + t1; b4 += b5 + k2; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + b7 += k5 + 16; b6 += b7 + k4 + t2; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + b1 += k0; b0 += b1 + k8; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + b3 += k2; b2 += b3 + k1; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + b5 += k4 + t2; b4 += b5 + k3; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + b7 += k6 + 17; b6 += b7 + k5 + t0; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + + output[0] = b0 + k0; + output[1] = b1 + k1; + output[2] = b2 + k2; + output[3] = b3 + k3; + output[4] = b4 + k4; + output[5] = b5 + k5 + t0; + output[6] = b6 + k6 + t1; + output[7] = b7 + k7 + 18; + } + +void threefishDecrypt512(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output) + { + + uint64_t b0 = input[0], b1 = input[1], + b2 = input[2], b3 = input[3], + b4 = input[4], b5 = input[5], + b6 = input[6], b7 = input[7]; + uint64_t k0 = keyCtx->key[0], k1 = keyCtx->key[1], + k2 = keyCtx->key[2], k3 = keyCtx->key[3], + k4 = keyCtx->key[4], k5 = keyCtx->key[5], + k6 = keyCtx->key[6], k7 = keyCtx->key[7], + k8 = keyCtx->key[8]; + uint64_t t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], + t2 = keyCtx->tweak[2]; + + uint64_t tmp; + + b0 -= k0; + b1 -= k1; + b2 -= k2; + b3 -= k3; + b4 -= k4; + b5 -= k5 + t0; + b6 -= k6 + t1; + b7 -= k7 + 18; + tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k5 + t0; b7 -= k6 + 17; + tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k3; b5 -= k4 + t2; + tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k1; b3 -= k2; + tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k8; b1 -= k0; + tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k4 + t2; b7 -= k5 + 16; + tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k2; b5 -= k3 + t1; + tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k0; b3 -= k1; + tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k7; b1 -= k8; + tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k3 + t1; b7 -= k4 + 15; + tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k1; b5 -= k2 + t0; + tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k8; b3 -= k0; + tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k6; b1 -= k7; + tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k2 + t0; b7 -= k3 + 14; + tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k0; b5 -= k1 + t2; + tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k7; b3 -= k8; + tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k5; b1 -= k6; + tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k1 + t2; b7 -= k2 + 13; + tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k8; b5 -= k0 + t1; + tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k6; b3 -= k7; + tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k4; b1 -= k5; + tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k0 + t1; b7 -= k1 + 12; + tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k7; b5 -= k8 + t0; + tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k5; b3 -= k6; + tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k3; b1 -= k4; + tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k8 + t0; b7 -= k0 + 11; + tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k6; b5 -= k7 + t2; + tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k4; b3 -= k5; + tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k2; b1 -= k3; + tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k7 + t2; b7 -= k8 + 10; + tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k5; b5 -= k6 + t1; + tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k3; b3 -= k4; + tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k1; b1 -= k2; + tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k6 + t1; b7 -= k7 + 9; + tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k4; b5 -= k5 + t0; + tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k2; b3 -= k3; + tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k0; b1 -= k1; + tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k5 + t0; b7 -= k6 + 8; + tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k3; b5 -= k4 + t2; + tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k1; b3 -= k2; + tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k8; b1 -= k0; + tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k4 + t2; b7 -= k5 + 7; + tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k2; b5 -= k3 + t1; + tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k0; b3 -= k1; + tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k7; b1 -= k8; + tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k3 + t1; b7 -= k4 + 6; + tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k1; b5 -= k2 + t0; + tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k8; b3 -= k0; + tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k6; b1 -= k7; + tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k2 + t0; b7 -= k3 + 5; + tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k0; b5 -= k1 + t2; + tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k7; b3 -= k8; + tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k5; b1 -= k6; + tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k1 + t2; b7 -= k2 + 4; + tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k8; b5 -= k0 + t1; + tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k6; b3 -= k7; + tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k4; b1 -= k5; + tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k0 + t1; b7 -= k1 + 3; + tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k7; b5 -= k8 + t0; + tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k5; b3 -= k6; + tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k3; b1 -= k4; + tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k8 + t0; b7 -= k0 + 2; + tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k6; b5 -= k7 + t2; + tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k4; b3 -= k5; + tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k2; b1 -= k3; + tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k7 + t2; b7 -= k8 + 1; + tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k5; b5 -= k6 + t1; + tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k3; b3 -= k4; + tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k1; b1 -= k2; + tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k6 + t1; b7 -= k7; + tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k4; b5 -= k5 + t0; + tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k2; b3 -= k3; + tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k0; b1 -= k1; + + output[0] = b0; + output[1] = b1; + output[2] = b2; + output[3] = b3; + + output[7] = b7; + output[6] = b6; + output[5] = b5; + output[4] = b4; +} diff --git a/drivers/staging/skein/threefishApi.c b/drivers/staging/skein/threefishApi.c new file mode 100644 index 000000000000..5afa0338aef4 --- /dev/null +++ b/drivers/staging/skein/threefishApi.c @@ -0,0 +1,79 @@ + + +#include +#include +#include + +void threefishSetKey(ThreefishKey_t* keyCtx, ThreefishSize_t stateSize, + uint64_t* keyData, uint64_t* tweak) +{ + int keyWords = stateSize / 64; + int i; + uint64_t parity = KeyScheduleConst; + + keyCtx->tweak[0] = tweak[0]; + keyCtx->tweak[1] = tweak[1]; + keyCtx->tweak[2] = tweak[0] ^ tweak[1]; + + for (i = 0; i < keyWords; i++) { + keyCtx->key[i] = keyData[i]; + parity ^= keyData[i]; + } + keyCtx->key[i] = parity; + keyCtx->stateSize = stateSize; +} + +void threefishEncryptBlockBytes(ThreefishKey_t* keyCtx, uint8_t* in, + uint8_t* out) +{ + u64b_t plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ + u64b_t cipher[SKEIN_MAX_STATE_WORDS]; + + Skein_Get64_LSB_First(plain, in, keyCtx->stateSize / 64); /* bytes to words */ + threefishEncryptBlockWords(keyCtx, plain, cipher); + Skein_Put64_LSB_First(out, cipher, keyCtx->stateSize / 8); /* words to bytes */ +} + +void threefishEncryptBlockWords(ThreefishKey_t* keyCtx, uint64_t* in, + uint64_t* out) +{ + switch (keyCtx->stateSize) { + case Threefish256: + threefishEncrypt256(keyCtx, in, out); + break; + case Threefish512: + threefishEncrypt512(keyCtx, in, out); + break; + case Threefish1024: + threefishEncrypt1024(keyCtx, in, out); + break; + } +} + +void threefishDecryptBlockBytes(ThreefishKey_t* keyCtx, uint8_t* in, + uint8_t* out) +{ + u64b_t plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ + u64b_t cipher[SKEIN_MAX_STATE_WORDS]; + + Skein_Get64_LSB_First(cipher, in, keyCtx->stateSize / 64); /* bytes to words */ + threefishDecryptBlockWords(keyCtx, cipher, plain); + Skein_Put64_LSB_First(out, plain, keyCtx->stateSize / 8); /* words to bytes */ +} + +void threefishDecryptBlockWords(ThreefishKey_t* keyCtx, uint64_t* in, + uint64_t* out) +{ + switch (keyCtx->stateSize) { + case Threefish256: + threefishDecrypt256(keyCtx, in, out); + break; + case Threefish512: + threefishDecrypt512(keyCtx, in, out); + break; + case Threefish1024: + threefishDecrypt1024(keyCtx, in, out); + break; + } +} + -- cgit v1.2.3 From c2c7426bfcf2473ed4cf7135c2b15bae9c13dd6e Mon Sep 17 00:00:00 2001 From: Jason Cooper Date: Mon, 24 Mar 2014 02:32:49 +0000 Subject: staging: crypto: skein: allow building statically These are the minimum changes required to get the code to build statically in the kernel. It's necessary to do this first so that we can empirically determine that future cleanup patches aren't changing the generated object code. Signed-off-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 + drivers/staging/Makefile | 1 + drivers/staging/skein/CMakeLists.txt | 27 ------------- drivers/staging/skein/Kconfig | 32 ++++++++++++++++ drivers/staging/skein/Makefile | 13 +++++++ drivers/staging/skein/include/brg_types.h | 57 ---------------------------- drivers/staging/skein/include/skein.h | 10 ----- drivers/staging/skein/include/skeinApi.h | 2 +- drivers/staging/skein/include/skein_port.h | 16 +------- drivers/staging/skein/include/threefishApi.h | 2 +- drivers/staging/skein/skein.c | 2 +- drivers/staging/skein/skeinApi.c | 4 +- drivers/staging/skein/skeinBlockNo3F.c | 2 +- drivers/staging/skein/skein_block.c | 2 +- drivers/staging/skein/threefish1024Block.c | 3 +- drivers/staging/skein/threefish256Block.c | 3 +- drivers/staging/skein/threefish512Block.c | 3 +- drivers/staging/skein/threefishApi.c | 3 +- 18 files changed, 59 insertions(+), 125 deletions(-) delete mode 100755 drivers/staging/skein/CMakeLists.txt create mode 100644 drivers/staging/skein/Kconfig create mode 100644 drivers/staging/skein/Makefile diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index ea5efb426f75..b597165092f8 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -146,6 +146,8 @@ source "drivers/staging/gs_fpgaboot/Kconfig" source "drivers/staging/nokia_h4p/Kconfig" +source "drivers/staging/skein/Kconfig" + source "drivers/staging/unisys/Kconfig" endif # STAGING diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 86e020c2ad0d..3860be7ee90d 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -65,4 +65,5 @@ obj-$(CONFIG_DGAP) += dgap/ obj-$(CONFIG_MTD_SPINAND_MT29F) += mt29f_spinand/ obj-$(CONFIG_GS_FPGABOOT) += gs_fpgaboot/ obj-$(CONFIG_BT_NOKIA_H4P) += nokia_h4p/ +obj-$(CONFIG_CRYPTO_SKEIN) += skein/ obj-$(CONFIG_UNISYSSPAR) += unisys/ diff --git a/drivers/staging/skein/CMakeLists.txt b/drivers/staging/skein/CMakeLists.txt deleted file mode 100755 index 604aaa394cb1..000000000000 --- a/drivers/staging/skein/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -cmake_minimum_required (VERSION 2.6) - -include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) - -# set(skeinBlock_src skein_block.c) -set(skeinBlock_src skeinBlockNo3F.c) - -set(skein_src - ${skeinBlock_src} - skein.c - skeinApi.c - ) - -set(threefish_src - threefishApi.c - threefish256Block.c - threefish512Block.c - threefish1024Block.c - ) -set(s3f_src ${skein_src} ${threefish_src}) - -add_library(skein3fish SHARED ${s3f_src}) -set_target_properties(skein3fish PROPERTIES VERSION ${VERSION} SOVERSION ${SOVERSION}) -target_link_libraries(skein3fish ${LIBS}) - -install(TARGETS skein3fish DESTINATION ${LIBDIRNAME}) - diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig new file mode 100644 index 000000000000..8f5a72a90ced --- /dev/null +++ b/drivers/staging/skein/Kconfig @@ -0,0 +1,32 @@ +config CRYPTO_SKEIN + bool "Skein digest algorithm" + depends on (X86 || UML_X86) && 64BIT + select CRYPTO_THREEFISH + select CRYPTO_HASH + help + Skein secure hash algorithm is one of 5 finalists from the NIST SHA3 + competition. + + Skein is optimized for modern, 64bit processors and is highly + customizable. See: + + http://www.skein-hash.info/sites/default/files/skein1.3.pdf + + for more information. This module depends on the threefish block + cipher module. + +config CRYPTO_THREEFISH + bool "Threefish tweakable block cipher" + depends on (X86 || UML_X86) && 64BIT + select CRYPTO_ALGAPI + help + Threefish cipher algorithm is the tweakable block cipher underneath + the Skein family of secure hash algorithms. Skein is one of 5 + finalists from the NIST SHA3 competition. + + Skein is optimized for modern, 64bit processors and is highly + customizable. See: + + http://www.skein-hash.info/sites/default/files/skein1.3.pdf + + for more information. diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile new file mode 100644 index 000000000000..2bb386e1e58c --- /dev/null +++ b/drivers/staging/skein/Makefile @@ -0,0 +1,13 @@ +# +# Makefile for the skein secure hash algorithm +# +subdir-ccflags-y := -I$(src)/include/ + +obj-$(CONFIG_CRYPTO_SKEIN) += skein.o \ + skeinApi.o \ + skein_block.o + +obj-$(CONFIG_CRYPTO_THREEFISH) += threefish1024Block.o \ + threefish256Block.o \ + threefish512Block.o \ + threefishApi.o diff --git a/drivers/staging/skein/include/brg_types.h b/drivers/staging/skein/include/brg_types.h index d6d6cdab9fbf..56064e9b656a 100644 --- a/drivers/staging/skein/include/brg_types.h +++ b/drivers/staging/skein/include/brg_types.h @@ -46,83 +46,26 @@ extern "C" { #endif -#include - #ifndef BRG_UI8 # define BRG_UI8 -# if UCHAR_MAX == 255u typedef unsigned char uint_8t; -# else -# error Please define uint_8t as an 8-bit unsigned integer type in brg_types.h -# endif #endif #ifndef BRG_UI16 # define BRG_UI16 -# if USHRT_MAX == 65535u typedef unsigned short uint_16t; -# else -# error Please define uint_16t as a 16-bit unsigned short type in brg_types.h -# endif #endif #ifndef BRG_UI32 # define BRG_UI32 -# if UINT_MAX == 4294967295u # define li_32(h) 0x##h##u typedef unsigned int uint_32t; -# elif ULONG_MAX == 4294967295u -# define li_32(h) 0x##h##ul - typedef unsigned long uint_32t; -# elif defined( _CRAY ) -# error This code needs 32-bit data types, which Cray machines do not provide -# else -# error Please define uint_32t as a 32-bit unsigned integer type in brg_types.h -# endif #endif #ifndef BRG_UI64 -# if defined( __BORLANDC__ ) && !defined( __MSDOS__ ) -# define BRG_UI64 -# define li_64(h) 0x##h##ui64 - typedef unsigned __int64 uint_64t; -# elif defined( _MSC_VER ) && ( _MSC_VER < 1300 ) /* 1300 == VC++ 7.0 */ -# define BRG_UI64 -# define li_64(h) 0x##h##ui64 - typedef unsigned __int64 uint_64t; -# elif defined( __sun ) && defined(ULONG_MAX) && ULONG_MAX == 0xfffffffful -# define BRG_UI64 -# define li_64(h) 0x##h##ull - typedef unsigned long long uint_64t; -# elif defined( UINT_MAX ) && UINT_MAX > 4294967295u -# if UINT_MAX == 18446744073709551615u -# define BRG_UI64 -# define li_64(h) 0x##h##u - typedef unsigned int uint_64t; -# endif -# elif defined( ULONG_MAX ) && ULONG_MAX > 4294967295u -# if ULONG_MAX == 18446744073709551615ul -# define BRG_UI64 -# define li_64(h) 0x##h##ul - typedef unsigned long uint_64t; -# endif -# elif defined( ULLONG_MAX ) && ULLONG_MAX > 4294967295u -# if ULLONG_MAX == 18446744073709551615ull -# define BRG_UI64 -# define li_64(h) 0x##h##ull - typedef unsigned long long uint_64t; -# endif -# elif defined( ULONG_LONG_MAX ) && ULONG_LONG_MAX > 4294967295u -# if ULONG_LONG_MAX == 18446744073709551615ull # define BRG_UI64 # define li_64(h) 0x##h##ull typedef unsigned long long uint_64t; -# endif -# elif defined(__GNUC__) /* DLW: avoid mingw problem with -ansi */ -# define BRG_UI64 -# define li_64(h) 0x##h##ull - typedef unsigned long long uint_64t; -# endif #endif #if defined( NEED_UINT_64T ) && !defined( BRG_UI64 ) diff --git a/drivers/staging/skein/include/skein.h b/drivers/staging/skein/include/skein.h index f62d0deed17e..fc9d0a0a9c0a 100644 --- a/drivers/staging/skein/include/skein.h +++ b/drivers/staging/skein/include/skein.h @@ -261,18 +261,8 @@ int Skein1024_Output (Skein1024_Ctxt_t *ctx, u08b_t * hashVal); #define Skein_Show_Key(bits,ctx,key,keyBytes) #endif -#ifndef SKEIN_ERR_CHECK /* run-time checks (e.g., bad params, uninitialized context)? */ #define Skein_Assert(x,retCode)/* default: ignore all Asserts, for performance */ #define Skein_assert(x) -#elif defined(SKEIN_ASSERT) -#include -#define Skein_Assert(x,retCode) assert(x) -#define Skein_assert(x) assert(x) -#else -#include -#define Skein_Assert(x,retCode) { if (!(x)) return retCode; } /* caller error */ -#define Skein_assert(x) assert(x) /* internal error */ -#endif /***************************************************************** ** Skein block function constants (shared across Ref and Opt code) diff --git a/drivers/staging/skein/include/skeinApi.h b/drivers/staging/skein/include/skeinApi.h index 19c3225460fc..734d27b79f01 100755 --- a/drivers/staging/skein/include/skeinApi.h +++ b/drivers/staging/skein/include/skeinApi.h @@ -78,8 +78,8 @@ OTHER DEALINGS IN THE SOFTWARE. * */ +#include #include -#include #ifdef __cplusplus extern "C" diff --git a/drivers/staging/skein/include/skein_port.h b/drivers/staging/skein/include/skein_port.h index 659a9486cb27..f2e18a1f34b4 100644 --- a/drivers/staging/skein/include/skein_port.h +++ b/drivers/staging/skein/include/skein_port.h @@ -44,24 +44,10 @@ typedef uint_64t u64b_t; /* 64-bit unsigned integer */ * platform-specific code instead (e.g., for big-endian CPUs). * */ -#ifndef SKEIN_NEED_SWAP /* compile-time "override" for endianness? */ - -#include /* get endianness selection */ -#if PLATFORM_BYTE_ORDER == IS_BIG_ENDIAN - /* here for big-endian CPUs */ -#define SKEIN_NEED_SWAP (1) -#elif PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN - /* here for x86 and x86-64 CPUs (and other detected little-endian CPUs) */ #define SKEIN_NEED_SWAP (0) -#if PLATFORM_MUST_ALIGN == 0 /* ok to use "fast" versions? */ +/* below two prototype assume we are handed aligned data */ #define Skein_Put64_LSB_First(dst08,src64,bCnt) memcpy(dst08,src64,bCnt) #define Skein_Get64_LSB_First(dst64,src08,wCnt) memcpy(dst64,src08,8*(wCnt)) -#endif -#else -#error "Skein needs endianness setting!" -#endif - -#endif /* ifndef SKEIN_NEED_SWAP */ /* ****************************************************************** diff --git a/drivers/staging/skein/include/threefishApi.h b/drivers/staging/skein/include/threefishApi.h index 85afd72fe987..dae270cf71d3 100644 --- a/drivers/staging/skein/include/threefishApi.h +++ b/drivers/staging/skein/include/threefishApi.h @@ -28,8 +28,8 @@ @endcode */ +#include #include -#include #define KeyScheduleConst 0x1BD11BDAA9FC1A22L diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c index 76933371183a..670c5b138c2b 100644 --- a/drivers/staging/skein/skein.c +++ b/drivers/staging/skein/skein.c @@ -10,7 +10,7 @@ #define SKEIN_PORT_CODE /* instantiate any code in skein_port.h */ -#include /* get the memcpy/memset functions */ +#include /* get the memcpy/memset functions */ #include /* get the Skein API definitions */ #include /* get precomputed IVs */ diff --git a/drivers/staging/skein/skeinApi.c b/drivers/staging/skein/skeinApi.c index 7b963758d32c..579b92efbf65 100755 --- a/drivers/staging/skein/skeinApi.c +++ b/drivers/staging/skein/skeinApi.c @@ -24,10 +24,8 @@ OTHER DEALINGS IN THE SOFTWARE. */ -#define SKEIN_ERR_CHECK 1 +#include #include -#include -#include int skeinCtxPrepare(SkeinCtx_t* ctx, SkeinSize_t size) { diff --git a/drivers/staging/skein/skeinBlockNo3F.c b/drivers/staging/skein/skeinBlockNo3F.c index bf4f2bf33ebf..4e73c8b7caa2 100644 --- a/drivers/staging/skein/skeinBlockNo3F.c +++ b/drivers/staging/skein/skeinBlockNo3F.c @@ -1,5 +1,5 @@ -#include +#include #include #include diff --git a/drivers/staging/skein/skein_block.c b/drivers/staging/skein/skein_block.c index af79218548ae..99348dae282a 100644 --- a/drivers/staging/skein/skein_block.c +++ b/drivers/staging/skein/skein_block.c @@ -14,7 +14,7 @@ ** ************************************************************************/ -#include +#include #include #ifndef SKEIN_USE_ASM diff --git a/drivers/staging/skein/threefish1024Block.c b/drivers/staging/skein/threefish1024Block.c index 8b43586f46bc..58a8c26a1f6f 100644 --- a/drivers/staging/skein/threefish1024Block.c +++ b/drivers/staging/skein/threefish1024Block.c @@ -1,6 +1,5 @@ +#include #include -#include -#include void threefishEncrypt1024(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output) diff --git a/drivers/staging/skein/threefish256Block.c b/drivers/staging/skein/threefish256Block.c index db2b81978c91..a7e06f905186 100644 --- a/drivers/staging/skein/threefish256Block.c +++ b/drivers/staging/skein/threefish256Block.c @@ -1,6 +1,5 @@ +#include #include -#include -#include void threefishEncrypt256(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output) diff --git a/drivers/staging/skein/threefish512Block.c b/drivers/staging/skein/threefish512Block.c index 4fe708fea066..3cbfcd9af5c9 100644 --- a/drivers/staging/skein/threefish512Block.c +++ b/drivers/staging/skein/threefish512Block.c @@ -1,6 +1,5 @@ +#include #include -#include -#include void threefishEncrypt512(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output) diff --git a/drivers/staging/skein/threefishApi.c b/drivers/staging/skein/threefishApi.c index 5afa0338aef4..968d3d21fe61 100644 --- a/drivers/staging/skein/threefishApi.c +++ b/drivers/staging/skein/threefishApi.c @@ -1,8 +1,7 @@ +#include #include -#include -#include void threefishSetKey(ThreefishKey_t* keyCtx, ThreefishSize_t stateSize, uint64_t* keyData, uint64_t* tweak) -- cgit v1.2.3 From 5057bbbe74a08d0f2bab5c6b7213fea67279f3a2 Mon Sep 17 00:00:00 2001 From: Jason Cooper Date: Mon, 24 Mar 2014 01:49:00 +0000 Subject: staging: crypto: skein: remove brg_*.h includes Signed-off-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/include/brg_endian.h | 148 ----------------------------- drivers/staging/skein/include/brg_types.h | 131 ------------------------- drivers/staging/skein/include/skein_port.h | 6 +- 3 files changed, 2 insertions(+), 283 deletions(-) delete mode 100644 drivers/staging/skein/include/brg_endian.h delete mode 100644 drivers/staging/skein/include/brg_types.h diff --git a/drivers/staging/skein/include/brg_endian.h b/drivers/staging/skein/include/brg_endian.h deleted file mode 100644 index 978eb33f08cf..000000000000 --- a/drivers/staging/skein/include/brg_endian.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - --------------------------------------------------------------------------- - Copyright (c) 2003, Dr Brian Gladman, Worcester, UK. All rights reserved. - - LICENSE TERMS - - The free distribution and use of this software in both source and binary - form is allowed (with or without changes) provided that: - - 1. distributions of this source code include the above copyright - notice, this list of conditions and the following disclaimer; - - 2. distributions in binary form include the above copyright - notice, this list of conditions and the following disclaimer - in the documentation and/or other associated materials; - - 3. the copyright holder's name is not used to endorse products - built using this software without specific written permission. - - ALTERNATIVELY, provided that this notice is retained in full, this product - may be distributed under the terms of the GNU General Public License (GPL), - in which case the provisions of the GPL apply INSTEAD OF those given above. - - DISCLAIMER - - This software is provided 'as is' with no explicit or implied warranties - in respect of its properties, including, but not limited to, correctness - and/or fitness for purpose. - --------------------------------------------------------------------------- - Issue 20/10/2006 -*/ - -#ifndef BRG_ENDIAN_H -#define BRG_ENDIAN_H - -#define IS_BIG_ENDIAN 4321 /* byte 0 is most significant (mc68k) */ -#define IS_LITTLE_ENDIAN 1234 /* byte 0 is least significant (i386) */ - -/* Include files where endian defines and byteswap functions may reside */ -#if defined( __FreeBSD__ ) || defined( __OpenBSD__ ) || defined( __NetBSD__ ) -# include -#elif defined( BSD ) && ( BSD >= 199103 ) || defined( __APPLE__ ) || \ - defined( __CYGWIN32__ ) || defined( __DJGPP__ ) || defined( __osf__ ) -# include -#elif defined( __linux__ ) || defined( __GNUC__ ) || defined( __GNU_LIBRARY__ ) -# if !defined( __MINGW32__ ) && !defined(AVR) -# include -# if !defined( __BEOS__ ) -# include -# endif -# endif -#endif - -/* Now attempt to set the define for platform byte order using any */ -/* of the four forms SYMBOL, _SYMBOL, __SYMBOL & __SYMBOL__, which */ -/* seem to encompass most endian symbol definitions */ - -#if defined( BIG_ENDIAN ) && defined( LITTLE_ENDIAN ) -# if defined( BYTE_ORDER ) && BYTE_ORDER == BIG_ENDIAN -# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN -# elif defined( BYTE_ORDER ) && BYTE_ORDER == LITTLE_ENDIAN -# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN -# endif -#elif defined( BIG_ENDIAN ) -# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN -#elif defined( LITTLE_ENDIAN ) -# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN -#endif - -#if defined( _BIG_ENDIAN ) && defined( _LITTLE_ENDIAN ) -# if defined( _BYTE_ORDER ) && _BYTE_ORDER == _BIG_ENDIAN -# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN -# elif defined( _BYTE_ORDER ) && _BYTE_ORDER == _LITTLE_ENDIAN -# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN -# endif -#elif defined( _BIG_ENDIAN ) -# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN -#elif defined( _LITTLE_ENDIAN ) -# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN -#endif - -#if defined( __BIG_ENDIAN ) && defined( __LITTLE_ENDIAN ) -# if defined( __BYTE_ORDER ) && __BYTE_ORDER == __BIG_ENDIAN -# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN -# elif defined( __BYTE_ORDER ) && __BYTE_ORDER == __LITTLE_ENDIAN -# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN -# endif -#elif defined( __BIG_ENDIAN ) -# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN -#elif defined( __LITTLE_ENDIAN ) -# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN -#endif - -#if defined( __BIG_ENDIAN__ ) && defined( __LITTLE_ENDIAN__ ) -# if defined( __BYTE_ORDER__ ) && __BYTE_ORDER__ == __BIG_ENDIAN__ -# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN -# elif defined( __BYTE_ORDER__ ) && __BYTE_ORDER__ == __LITTLE_ENDIAN__ -# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN -# endif -#elif defined( __BIG_ENDIAN__ ) -# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN -#elif defined( __LITTLE_ENDIAN__ ) -# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN -#endif - -/* if the platform byte order could not be determined, then try to */ -/* set this define using common machine defines */ -#if !defined(PLATFORM_BYTE_ORDER) - -#if defined( __alpha__ ) || defined( __alpha ) || defined( i386 ) || \ - defined( __i386__ ) || defined( _M_I86 ) || defined( _M_IX86 ) || \ - defined( __OS2__ ) || defined( sun386 ) || defined( __TURBOC__ ) || \ - defined( vax ) || defined( vms ) || defined( VMS ) || \ - defined( __VMS ) || defined( _M_X64 ) || defined( AVR ) -# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN - -#elif defined( AMIGA ) || defined( applec ) || defined( __AS400__ ) || \ - defined( _CRAY ) || defined( __hppa ) || defined( __hp9000 ) || \ - defined( ibm370 ) || defined( mc68000 ) || defined( m68k ) || \ - defined( __MRC__ ) || defined( __MVS__ ) || defined( __MWERKS__ ) || \ - defined( sparc ) || defined( __sparc) || defined( SYMANTEC_C ) || \ - defined( __VOS__ ) || defined( __TIGCC__ ) || defined( __TANDEM ) || \ - defined( THINK_C ) || defined( __VMCMS__ ) -# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN - -#elif 0 /* **** EDIT HERE IF NECESSARY **** */ -# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN -#elif 0 /* **** EDIT HERE IF NECESSARY **** */ -# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN -#else -# error Please edit lines 126 or 128 in brg_endian.h to set the platform byte order -#endif -#endif - -/* special handler for IA64, which may be either endianness (?) */ -/* here we assume little-endian, but this may need to be changed */ -#if defined(__ia64) || defined(__ia64__) || defined(_M_IA64) -# define PLATFORM_MUST_ALIGN (1) -#ifndef PLATFORM_BYTE_ORDER -# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN -#endif -#endif - -#ifndef PLATFORM_MUST_ALIGN -# define PLATFORM_MUST_ALIGN (0) -#endif - -#endif /* ifndef BRG_ENDIAN_H */ diff --git a/drivers/staging/skein/include/brg_types.h b/drivers/staging/skein/include/brg_types.h deleted file mode 100644 index 56064e9b656a..000000000000 --- a/drivers/staging/skein/include/brg_types.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - --------------------------------------------------------------------------- - Copyright (c) 1998-2006, Brian Gladman, Worcester, UK. All rights reserved. - - LICENSE TERMS - - The free distribution and use of this software in both source and binary - form is allowed (with or without changes) provided that: - - 1. distributions of this source code include the above copyright - notice, this list of conditions and the following disclaimer; - - 2. distributions in binary form include the above copyright - notice, this list of conditions and the following disclaimer - in the documentation and/or other associated materials; - - 3. the copyright holder's name is not used to endorse products - built using this software without specific written permission. - - ALTERNATIVELY, provided that this notice is retained in full, this product - may be distributed under the terms of the GNU General Public License (GPL), - in which case the provisions of the GPL apply INSTEAD OF those given above. - - DISCLAIMER - - This software is provided 'as is' with no explicit or implied warranties - in respect of its properties, including, but not limited to, correctness - and/or fitness for purpose. - --------------------------------------------------------------------------- - Issue 09/09/2006 - - The unsigned integer types defined here are of the form uint_t where - is the length of the type; for example, the unsigned 32-bit type is - 'uint_32t'. These are NOT the same as the 'C99 integer types' that are - defined in the inttypes.h and stdint.h headers since attempts to use these - types have shown that support for them is still highly variable. However, - since the latter are of the form uint_t, a regular expression search - and replace (in VC++ search on 'uint_{:z}t' and replace with 'uint\1_t') - can be used to convert the types used here to the C99 standard types. -*/ - -#ifndef BRG_TYPES_H -#define BRG_TYPES_H - -#if defined(__cplusplus) -extern "C" { -#endif - -#ifndef BRG_UI8 -# define BRG_UI8 - typedef unsigned char uint_8t; -#endif - -#ifndef BRG_UI16 -# define BRG_UI16 - typedef unsigned short uint_16t; -#endif - -#ifndef BRG_UI32 -# define BRG_UI32 -# define li_32(h) 0x##h##u - typedef unsigned int uint_32t; -#endif - -#ifndef BRG_UI64 -# define BRG_UI64 -# define li_64(h) 0x##h##ull - typedef unsigned long long uint_64t; -#endif - -#if defined( NEED_UINT_64T ) && !defined( BRG_UI64 ) -# error Please define uint_64t as an unsigned 64 bit type in brg_types.h -#endif - -#ifndef RETURN_VALUES -# define RETURN_VALUES -# if defined( DLL_EXPORT ) -# if defined( _MSC_VER ) || defined ( __INTEL_COMPILER ) -# define VOID_RETURN __declspec( dllexport ) void __stdcall -# define INT_RETURN __declspec( dllexport ) int __stdcall -# elif defined( __GNUC__ ) -# define VOID_RETURN __declspec( __dllexport__ ) void -# define INT_RETURN __declspec( __dllexport__ ) int -# else -# error Use of the DLL is only available on the Microsoft, Intel and GCC compilers -# endif -# elif defined( DLL_IMPORT ) -# if defined( _MSC_VER ) || defined ( __INTEL_COMPILER ) -# define VOID_RETURN __declspec( dllimport ) void __stdcall -# define INT_RETURN __declspec( dllimport ) int __stdcall -# elif defined( __GNUC__ ) -# define VOID_RETURN __declspec( __dllimport__ ) void -# define INT_RETURN __declspec( __dllimport__ ) int -# else -# error Use of the DLL is only available on the Microsoft, Intel and GCC compilers -# endif -# elif defined( __WATCOMC__ ) -# define VOID_RETURN void __cdecl -# define INT_RETURN int __cdecl -# else -# define VOID_RETURN void -# define INT_RETURN int -# endif -#endif - -/* These defines are used to declare buffers in a way that allows - faster operations on longer variables to be used. In all these - defines 'size' must be a power of 2 and >= 8 - - dec_unit_type(size,x) declares a variable 'x' of length - 'size' bits - - dec_bufr_type(size,bsize,x) declares a buffer 'x' of length 'bsize' - bytes defined as an array of variables - each of 'size' bits (bsize must be a - multiple of size / 8) - - ptr_cast(x,size) casts a pointer to a pointer to a - varaiable of length 'size' bits -*/ - -#define ui_type(size) uint_##size##t -#define dec_unit_type(size,x) typedef ui_type(size) x -#define dec_bufr_type(size,bsize,x) typedef ui_type(size) x[bsize / (size >> 3)] -#define ptr_cast(x,size) ((ui_type(size)*)(x)) - -#if defined(__cplusplus) -} -#endif - -#endif diff --git a/drivers/staging/skein/include/skein_port.h b/drivers/staging/skein/include/skein_port.h index f2e18a1f34b4..d963813ea125 100644 --- a/drivers/staging/skein/include/skein_port.h +++ b/drivers/staging/skein/include/skein_port.h @@ -15,11 +15,9 @@ ** ********************************************************************/ -#include /* get integer type definitions */ - typedef unsigned int uint_t; /* native unsigned integer */ -typedef uint_8t u08b_t; /* 8-bit unsigned integer */ -typedef uint_64t u64b_t; /* 64-bit unsigned integer */ +typedef uint8_t u08b_t; /* 8-bit unsigned integer */ +typedef uint64_t u64b_t; /* 64-bit unsigned integer */ #ifndef RotL_64 #define RotL_64(x,N) (((x) << (N)) | ((x) >> (64-(N)))) -- cgit v1.2.3 From da13dfd7e6e792497228cf650289a0d4d5690d38 Mon Sep 17 00:00:00 2001 From: Jason Cooper Date: Mon, 24 Mar 2014 01:49:01 +0000 Subject: staging: crypto: skein: remove skein_port.h Signed-off-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/include/skein.h | 14 +++- drivers/staging/skein/include/skein_port.h | 108 ----------------------------- drivers/staging/skein/skein.c | 21 ------ 3 files changed, 13 insertions(+), 130 deletions(-) delete mode 100644 drivers/staging/skein/include/skein_port.h diff --git a/drivers/staging/skein/include/skein.h b/drivers/staging/skein/include/skein.h index fc9d0a0a9c0a..f924a688e20a 100644 --- a/drivers/staging/skein/include/skein.h +++ b/drivers/staging/skein/include/skein.h @@ -33,7 +33,19 @@ extern "C" #endif #include /* get size_t definition */ -#include /* get platform-specific definitions */ + +typedef unsigned int uint_t; /* native unsigned integer */ +typedef uint8_t u08b_t; /* 8-bit unsigned integer */ +typedef uint64_t u64b_t; /* 64-bit unsigned integer */ + +#ifndef RotL_64 +#define RotL_64(x,N) (((x) << (N)) | ((x) >> (64-(N)))) +#endif + +/* below two prototype assume we are handed aligned data */ +#define Skein_Put64_LSB_First(dst08,src64,bCnt) memcpy(dst08,src64,bCnt) +#define Skein_Get64_LSB_First(dst64,src08,wCnt) memcpy(dst64,src08,8*(wCnt)) +#define Skein_Swap64(w64) (w64) enum { diff --git a/drivers/staging/skein/include/skein_port.h b/drivers/staging/skein/include/skein_port.h deleted file mode 100644 index d963813ea125..000000000000 --- a/drivers/staging/skein/include/skein_port.h +++ /dev/null @@ -1,108 +0,0 @@ -#ifndef _SKEIN_PORT_H_ -#define _SKEIN_PORT_H_ -/******************************************************************* -** -** Platform-specific definitions for Skein hash function. -** -** Source code author: Doug Whiting, 2008. -** -** This algorithm and source code is released to the public domain. -** -** Many thanks to Brian Gladman for his portable header files. -** -** To port Skein to an "unsupported" platform, change the definitions -** in this file appropriately. -** -********************************************************************/ - -typedef unsigned int uint_t; /* native unsigned integer */ -typedef uint8_t u08b_t; /* 8-bit unsigned integer */ -typedef uint64_t u64b_t; /* 64-bit unsigned integer */ - -#ifndef RotL_64 -#define RotL_64(x,N) (((x) << (N)) | ((x) >> (64-(N)))) -#endif - -/* - * Skein is "natively" little-endian (unlike SHA-xxx), for optimal - * performance on x86 CPUs. The Skein code requires the following - * definitions for dealing with endianness: - * - * SKEIN_NEED_SWAP: 0 for little-endian, 1 for big-endian - * Skein_Put64_LSB_First - * Skein_Get64_LSB_First - * Skein_Swap64 - * - * If SKEIN_NEED_SWAP is defined at compile time, it is used here - * along with the portable versions of Put64/Get64/Swap64, which - * are slow in general. - * - * Otherwise, an "auto-detect" of endianness is attempted below. - * If the default handling doesn't work well, the user may insert - * platform-specific code instead (e.g., for big-endian CPUs). - * - */ -#define SKEIN_NEED_SWAP (0) -/* below two prototype assume we are handed aligned data */ -#define Skein_Put64_LSB_First(dst08,src64,bCnt) memcpy(dst08,src64,bCnt) -#define Skein_Get64_LSB_First(dst64,src08,wCnt) memcpy(dst64,src08,8*(wCnt)) - -/* - ****************************************************************** - * Provide any definitions still needed. - ****************************************************************** - */ -#ifndef Skein_Swap64 /* swap for big-endian, nop for little-endian */ -#if SKEIN_NEED_SWAP -#define Skein_Swap64(w64) \ - ( (( ((u64b_t)(w64)) & 0xFF) << 56) | \ - (((((u64b_t)(w64)) >> 8) & 0xFF) << 48) | \ - (((((u64b_t)(w64)) >>16) & 0xFF) << 40) | \ - (((((u64b_t)(w64)) >>24) & 0xFF) << 32) | \ - (((((u64b_t)(w64)) >>32) & 0xFF) << 24) | \ - (((((u64b_t)(w64)) >>40) & 0xFF) << 16) | \ - (((((u64b_t)(w64)) >>48) & 0xFF) << 8) | \ - (((((u64b_t)(w64)) >>56) & 0xFF) ) ) -#else -#define Skein_Swap64(w64) (w64) -#endif -#endif /* ifndef Skein_Swap64 */ - - -#ifndef Skein_Put64_LSB_First -void Skein_Put64_LSB_First(u08b_t *dst,const u64b_t *src,size_t bCnt) -#ifdef SKEIN_PORT_CODE /* instantiate the function code here? */ - { /* this version is fully portable (big-endian or little-endian), but slow */ - size_t n; - - for (n=0;n>3] >> (8*(n&7))); - } -#else - ; /* output only the function prototype */ -#endif -#endif /* ifndef Skein_Put64_LSB_First */ - - -#ifndef Skein_Get64_LSB_First -void Skein_Get64_LSB_First(u64b_t *dst,const u08b_t *src,size_t wCnt) -#ifdef SKEIN_PORT_CODE /* instantiate the function code here? */ - { /* this version is fully portable (big-endian or little-endian), but slow */ - size_t n; - - for (n=0;n<8*wCnt;n+=8) - dst[n/8] = (((u64b_t) src[n ]) ) + - (((u64b_t) src[n+1]) << 8) + - (((u64b_t) src[n+2]) << 16) + - (((u64b_t) src[n+3]) << 24) + - (((u64b_t) src[n+4]) << 32) + - (((u64b_t) src[n+5]) << 40) + - (((u64b_t) src[n+6]) << 48) + - (((u64b_t) src[n+7]) << 56) ; - } -#else - ; /* output only the function prototype */ -#endif -#endif /* ifndef Skein_Get64_LSB_First */ - -#endif /* ifndef _SKEIN_PORT_H_ */ diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c index 670c5b138c2b..93a102b16e64 100644 --- a/drivers/staging/skein/skein.c +++ b/drivers/staging/skein/skein.c @@ -102,13 +102,6 @@ int Skein_256_InitExt(Skein_256_Ctxt_t *ctx,size_t hashBitLen,u64b_t treeInfo, c Skein_256_Update(ctx,key,keyBytes); /* hash the key */ Skein_256_Final_Pad(ctx,cfg.b); /* put result into cfg.b[] */ memcpy(ctx->X,cfg.b,sizeof(cfg.b)); /* copy over into ctx->X[] */ -#if SKEIN_NEED_SWAP - { - uint_t i; - for (i=0;iX[i] = Skein_Swap64(ctx->X[i]); - } -#endif } /* build/process the config block, type == CONFIG (could be precomputed for each key) */ ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ @@ -297,13 +290,6 @@ int Skein_512_InitExt(Skein_512_Ctxt_t *ctx,size_t hashBitLen,u64b_t treeInfo, c Skein_512_Update(ctx,key,keyBytes); /* hash the key */ Skein_512_Final_Pad(ctx,cfg.b); /* put result into cfg.b[] */ memcpy(ctx->X,cfg.b,sizeof(cfg.b)); /* copy over into ctx->X[] */ -#if SKEIN_NEED_SWAP - { - uint_t i; - for (i=0;iX[i] = Skein_Swap64(ctx->X[i]); - } -#endif } /* build/process the config block, type == CONFIG (could be precomputed for each key) */ ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ @@ -489,13 +475,6 @@ int Skein1024_InitExt(Skein1024_Ctxt_t *ctx,size_t hashBitLen,u64b_t treeInfo, c Skein1024_Update(ctx,key,keyBytes); /* hash the key */ Skein1024_Final_Pad(ctx,cfg.b); /* put result into cfg.b[] */ memcpy(ctx->X,cfg.b,sizeof(cfg.b)); /* copy over into ctx->X[] */ -#if SKEIN_NEED_SWAP - { - uint_t i; - for (i=0;iX[i] = Skein_Swap64(ctx->X[i]); - } -#endif } /* build/process the config block, type == CONFIG (could be precomputed for each key) */ ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ -- cgit v1.2.3 From 8eee37872e843d813485f2da59508412f40b6e6a Mon Sep 17 00:00:00 2001 From: Jason Cooper Date: Mon, 24 Mar 2014 01:49:02 +0000 Subject: staging: crypto: skein: remove __cplusplus and an unneeded stddef.h Signed-off-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/include/skein.h | 11 ----------- drivers/staging/skein/include/skeinApi.h | 9 --------- drivers/staging/skein/include/threefishApi.h | 9 --------- 3 files changed, 29 deletions(-) diff --git a/drivers/staging/skein/include/skein.h b/drivers/staging/skein/include/skein.h index f924a688e20a..43e3052525ac 100644 --- a/drivers/staging/skein/include/skein.h +++ b/drivers/staging/skein/include/skein.h @@ -27,13 +27,6 @@ ** 1: return SKEIN_FAIL to flag errors ** ***************************************************************************/ -#ifdef __cplusplus -extern "C" -{ -#endif - -#include /* get size_t definition */ - typedef unsigned int uint_t; /* native unsigned integer */ typedef uint8_t u08b_t; /* 8-bit unsigned integer */ typedef uint64_t u64b_t; /* 64-bit unsigned integer */ @@ -322,8 +315,4 @@ enum #define SKEIN1024_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS ) + 5) % 10) + 5)) #endif -#ifdef __cplusplus -} -#endif - #endif /* ifndef _SKEIN_H_ */ diff --git a/drivers/staging/skein/include/skeinApi.h b/drivers/staging/skein/include/skeinApi.h index 734d27b79f01..f55c67e81f2b 100755 --- a/drivers/staging/skein/include/skeinApi.h +++ b/drivers/staging/skein/include/skeinApi.h @@ -81,11 +81,6 @@ OTHER DEALINGS IN THE SOFTWARE. #include #include -#ifdef __cplusplus -extern "C" -{ -#endif - /** * Which Skein size to use */ @@ -229,10 +224,6 @@ extern "C" */ int skeinFinal(SkeinCtx_t* ctx, uint8_t* hash); -#ifdef __cplusplus -} -#endif - /** * @} */ diff --git a/drivers/staging/skein/include/threefishApi.h b/drivers/staging/skein/include/threefishApi.h index dae270cf71d3..aaecfe822142 100644 --- a/drivers/staging/skein/include/threefishApi.h +++ b/drivers/staging/skein/include/threefishApi.h @@ -33,11 +33,6 @@ #define KeyScheduleConst 0x1BD11BDAA9FC1A22L -#ifdef __cplusplus -extern "C" -{ -#endif - /** * Which Threefish size to use */ @@ -157,10 +152,6 @@ extern "C" void threefishDecrypt256(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output); void threefishDecrypt512(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output); void threefishDecrypt1024(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output); -#ifdef __cplusplus -} -#endif - /** * @} */ -- cgit v1.2.3 From 2ab31bba2d7c0f6db40ed91e314b6d2cb9a130bb Mon Sep 17 00:00:00 2001 From: Jason Cooper Date: Mon, 24 Mar 2014 01:49:03 +0000 Subject: staging: crypto: skein: remove unneeded typedefs Signed-off-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/include/skein.h | 73 ++++++++++----------- drivers/staging/skein/include/skeinApi.h | 4 +- drivers/staging/skein/include/skein_iv.h | 26 ++++---- drivers/staging/skein/include/threefishApi.h | 6 +- drivers/staging/skein/skein.c | 96 ++++++++++++++-------------- drivers/staging/skein/skeinApi.c | 24 +++---- drivers/staging/skein/skeinBlockNo3F.c | 30 ++++----- drivers/staging/skein/skein_block.c | 54 ++++++++-------- drivers/staging/skein/threefishApi.c | 8 +-- 9 files changed, 159 insertions(+), 162 deletions(-) diff --git a/drivers/staging/skein/include/skein.h b/drivers/staging/skein/include/skein.h index 43e3052525ac..5cf4c7fec467 100644 --- a/drivers/staging/skein/include/skein.h +++ b/drivers/staging/skein/include/skein.h @@ -27,9 +27,6 @@ ** 1: return SKEIN_FAIL to flag errors ** ***************************************************************************/ -typedef unsigned int uint_t; /* native unsigned integer */ -typedef uint8_t u08b_t; /* 8-bit unsigned integer */ -typedef uint64_t u64b_t; /* 64-bit unsigned integer */ #ifndef RotL_64 #define RotL_64(x,N) (((x) << (N)) | ((x) >> (64-(N)))) @@ -70,28 +67,28 @@ typedef struct { size_t hashBitLen; /* size of hash result, in bits */ size_t bCnt; /* current byte count in buffer b[] */ - u64b_t T[SKEIN_MODIFIER_WORDS]; /* tweak words: T[0]=byte cnt, T[1]=flags */ + u64 T[SKEIN_MODIFIER_WORDS]; /* tweak words: T[0]=byte cnt, T[1]=flags */ } Skein_Ctxt_Hdr_t; typedef struct /* 256-bit Skein hash context structure */ { Skein_Ctxt_Hdr_t h; /* common header context variables */ - u64b_t X[SKEIN_256_STATE_WORDS]; /* chaining variables */ - u08b_t b[SKEIN_256_BLOCK_BYTES]; /* partial block buffer (8-byte aligned) */ + u64 X[SKEIN_256_STATE_WORDS]; /* chaining variables */ + u8 b[SKEIN_256_BLOCK_BYTES]; /* partial block buffer (8-byte aligned) */ } Skein_256_Ctxt_t; typedef struct /* 512-bit Skein hash context structure */ { Skein_Ctxt_Hdr_t h; /* common header context variables */ - u64b_t X[SKEIN_512_STATE_WORDS]; /* chaining variables */ - u08b_t b[SKEIN_512_BLOCK_BYTES]; /* partial block buffer (8-byte aligned) */ + u64 X[SKEIN_512_STATE_WORDS]; /* chaining variables */ + u8 b[SKEIN_512_BLOCK_BYTES]; /* partial block buffer (8-byte aligned) */ } Skein_512_Ctxt_t; typedef struct /* 1024-bit Skein hash context structure */ { Skein_Ctxt_Hdr_t h; /* common header context variables */ - u64b_t X[SKEIN1024_STATE_WORDS]; /* chaining variables */ - u08b_t b[SKEIN1024_BLOCK_BYTES]; /* partial block buffer (8-byte aligned) */ + u64 X[SKEIN1024_STATE_WORDS]; /* chaining variables */ + u8 b[SKEIN1024_BLOCK_BYTES]; /* partial block buffer (8-byte aligned) */ } Skein1024_Ctxt_t; /* Skein APIs for (incremental) "straight hashing" */ @@ -99,13 +96,13 @@ int Skein_256_Init (Skein_256_Ctxt_t *ctx, size_t hashBitLen); int Skein_512_Init (Skein_512_Ctxt_t *ctx, size_t hashBitLen); int Skein1024_Init (Skein1024_Ctxt_t *ctx, size_t hashBitLen); -int Skein_256_Update(Skein_256_Ctxt_t *ctx, const u08b_t *msg, size_t msgByteCnt); -int Skein_512_Update(Skein_512_Ctxt_t *ctx, const u08b_t *msg, size_t msgByteCnt); -int Skein1024_Update(Skein1024_Ctxt_t *ctx, const u08b_t *msg, size_t msgByteCnt); +int Skein_256_Update(Skein_256_Ctxt_t *ctx, const u8 *msg, size_t msgByteCnt); +int Skein_512_Update(Skein_512_Ctxt_t *ctx, const u8 *msg, size_t msgByteCnt); +int Skein1024_Update(Skein1024_Ctxt_t *ctx, const u8 *msg, size_t msgByteCnt); -int Skein_256_Final (Skein_256_Ctxt_t *ctx, u08b_t * hashVal); -int Skein_512_Final (Skein_512_Ctxt_t *ctx, u08b_t * hashVal); -int Skein1024_Final (Skein1024_Ctxt_t *ctx, u08b_t * hashVal); +int Skein_256_Final (Skein_256_Ctxt_t *ctx, u8 * hashVal); +int Skein_512_Final (Skein_512_Ctxt_t *ctx, u8 * hashVal); +int Skein1024_Final (Skein1024_Ctxt_t *ctx, u8 * hashVal); /* ** Skein APIs for "extended" initialization: MAC keys, tree hashing. @@ -121,26 +118,26 @@ int Skein1024_Final (Skein1024_Ctxt_t *ctx, u08b_t * hashVal); ** to precompute the MAC IV, then a copy of the context saved and ** reused for each new MAC computation. **/ -int Skein_256_InitExt(Skein_256_Ctxt_t *ctx, size_t hashBitLen, u64b_t treeInfo, const u08b_t *key, size_t keyBytes); -int Skein_512_InitExt(Skein_512_Ctxt_t *ctx, size_t hashBitLen, u64b_t treeInfo, const u08b_t *key, size_t keyBytes); -int Skein1024_InitExt(Skein1024_Ctxt_t *ctx, size_t hashBitLen, u64b_t treeInfo, const u08b_t *key, size_t keyBytes); +int Skein_256_InitExt(Skein_256_Ctxt_t *ctx, size_t hashBitLen, u64 treeInfo, const u8 *key, size_t keyBytes); +int Skein_512_InitExt(Skein_512_Ctxt_t *ctx, size_t hashBitLen, u64 treeInfo, const u8 *key, size_t keyBytes); +int Skein1024_InitExt(Skein1024_Ctxt_t *ctx, size_t hashBitLen, u64 treeInfo, const u8 *key, size_t keyBytes); /* ** Skein APIs for MAC and tree hash: ** Final_Pad: pad, do final block, but no OUTPUT type ** Output: do just the output stage */ -int Skein_256_Final_Pad(Skein_256_Ctxt_t *ctx, u08b_t * hashVal); -int Skein_512_Final_Pad(Skein_512_Ctxt_t *ctx, u08b_t * hashVal); -int Skein1024_Final_Pad(Skein1024_Ctxt_t *ctx, u08b_t * hashVal); +int Skein_256_Final_Pad(Skein_256_Ctxt_t *ctx, u8 * hashVal); +int Skein_512_Final_Pad(Skein_512_Ctxt_t *ctx, u8 * hashVal); +int Skein1024_Final_Pad(Skein1024_Ctxt_t *ctx, u8 * hashVal); #ifndef SKEIN_TREE_HASH #define SKEIN_TREE_HASH (1) #endif #if SKEIN_TREE_HASH -int Skein_256_Output (Skein_256_Ctxt_t *ctx, u08b_t * hashVal); -int Skein_512_Output (Skein_512_Ctxt_t *ctx, u08b_t * hashVal); -int Skein1024_Output (Skein1024_Ctxt_t *ctx, u08b_t * hashVal); +int Skein_256_Output (Skein_256_Ctxt_t *ctx, u8 * hashVal); +int Skein_512_Output (Skein_512_Ctxt_t *ctx, u8 * hashVal); +int Skein1024_Output (Skein1024_Ctxt_t *ctx, u8 * hashVal); #endif /***************************************************************** @@ -161,13 +158,13 @@ int Skein1024_Output (Skein1024_Ctxt_t *ctx, u08b_t * hashVal); #define SKEIN_T1_POS_FINAL SKEIN_T1_BIT(127) /* bit 127 : final block flag */ /* tweak word T[1]: flag bit definition(s) */ -#define SKEIN_T1_FLAG_FIRST (((u64b_t) 1 ) << SKEIN_T1_POS_FIRST) -#define SKEIN_T1_FLAG_FINAL (((u64b_t) 1 ) << SKEIN_T1_POS_FINAL) -#define SKEIN_T1_FLAG_BIT_PAD (((u64b_t) 1 ) << SKEIN_T1_POS_BIT_PAD) +#define SKEIN_T1_FLAG_FIRST (((u64) 1 ) << SKEIN_T1_POS_FIRST) +#define SKEIN_T1_FLAG_FINAL (((u64) 1 ) << SKEIN_T1_POS_FINAL) +#define SKEIN_T1_FLAG_BIT_PAD (((u64) 1 ) << SKEIN_T1_POS_BIT_PAD) /* tweak word T[1]: tree level bit field mask */ -#define SKEIN_T1_TREE_LVL_MASK (((u64b_t)0x7F) << SKEIN_T1_POS_TREE_LVL) -#define SKEIN_T1_TREE_LEVEL(n) (((u64b_t) (n)) << SKEIN_T1_POS_TREE_LVL) +#define SKEIN_T1_TREE_LVL_MASK (((u64)0x7F) << SKEIN_T1_POS_TREE_LVL) +#define SKEIN_T1_TREE_LEVEL(n) (((u64) (n)) << SKEIN_T1_POS_TREE_LVL) /* tweak word T[1]: block type field */ #define SKEIN_BLK_TYPE_KEY ( 0) /* key, for MAC and KDF */ @@ -180,7 +177,7 @@ int Skein1024_Output (Skein1024_Ctxt_t *ctx, u08b_t * hashVal); #define SKEIN_BLK_TYPE_OUT (63) /* output stage */ #define SKEIN_BLK_TYPE_MASK (63) /* bit field mask */ -#define SKEIN_T1_BLK_TYPE(T) (((u64b_t) (SKEIN_BLK_TYPE_##T)) << SKEIN_T1_POS_BLK_TYPE) +#define SKEIN_T1_BLK_TYPE(T) (((u64) (SKEIN_BLK_TYPE_##T)) << SKEIN_T1_POS_BLK_TYPE) #define SKEIN_T1_BLK_TYPE_KEY SKEIN_T1_BLK_TYPE(KEY) /* key, for MAC and KDF */ #define SKEIN_T1_BLK_TYPE_CFG SKEIN_T1_BLK_TYPE(CFG) /* configuration block */ #define SKEIN_T1_BLK_TYPE_PERS SKEIN_T1_BLK_TYPE(PERS) /* personalization string */ @@ -200,7 +197,7 @@ int Skein1024_Output (Skein1024_Ctxt_t *ctx, u08b_t * hashVal); #define SKEIN_ID_STRING_LE (0x33414853) /* "SHA3" (little-endian)*/ #endif -#define SKEIN_MK_64(hi32,lo32) ((lo32) + (((u64b_t) (hi32)) << 32)) +#define SKEIN_MK_64(hi32,lo32) ((lo32) + (((u64) (hi32)) << 32)) #define SKEIN_SCHEMA_VER SKEIN_MK_64(SKEIN_VERSION,SKEIN_ID_STRING_LE) #define SKEIN_KS_PARITY SKEIN_MK_64(0x1BD11BDA,0xA9FC1A22) @@ -211,14 +208,14 @@ int Skein1024_Output (Skein1024_Ctxt_t *ctx, u08b_t * hashVal); #define SKEIN_CFG_TREE_NODE_SIZE_POS ( 8) #define SKEIN_CFG_TREE_MAX_LEVEL_POS (16) -#define SKEIN_CFG_TREE_LEAF_SIZE_MSK (((u64b_t) 0xFF) << SKEIN_CFG_TREE_LEAF_SIZE_POS) -#define SKEIN_CFG_TREE_NODE_SIZE_MSK (((u64b_t) 0xFF) << SKEIN_CFG_TREE_NODE_SIZE_POS) -#define SKEIN_CFG_TREE_MAX_LEVEL_MSK (((u64b_t) 0xFF) << SKEIN_CFG_TREE_MAX_LEVEL_POS) +#define SKEIN_CFG_TREE_LEAF_SIZE_MSK (((u64) 0xFF) << SKEIN_CFG_TREE_LEAF_SIZE_POS) +#define SKEIN_CFG_TREE_NODE_SIZE_MSK (((u64) 0xFF) << SKEIN_CFG_TREE_NODE_SIZE_POS) +#define SKEIN_CFG_TREE_MAX_LEVEL_MSK (((u64) 0xFF) << SKEIN_CFG_TREE_MAX_LEVEL_POS) #define SKEIN_CFG_TREE_INFO(leaf,node,maxLvl) \ - ( (((u64b_t)(leaf )) << SKEIN_CFG_TREE_LEAF_SIZE_POS) | \ - (((u64b_t)(node )) << SKEIN_CFG_TREE_NODE_SIZE_POS) | \ - (((u64b_t)(maxLvl)) << SKEIN_CFG_TREE_MAX_LEVEL_POS) ) + ( (((u64)(leaf )) << SKEIN_CFG_TREE_LEAF_SIZE_POS) | \ + (((u64)(node )) << SKEIN_CFG_TREE_NODE_SIZE_POS) | \ + (((u64)(maxLvl)) << SKEIN_CFG_TREE_MAX_LEVEL_POS) ) #define SKEIN_CFG_TREE_INFO_SEQUENTIAL SKEIN_CFG_TREE_INFO(0,0,0) /* use as treeInfo in InitExt() call for sequential processing */ diff --git a/drivers/staging/skein/include/skeinApi.h b/drivers/staging/skein/include/skeinApi.h index f55c67e81f2b..fb4a7c8e7f7a 100755 --- a/drivers/staging/skein/include/skeinApi.h +++ b/drivers/staging/skein/include/skeinApi.h @@ -99,8 +99,8 @@ OTHER DEALINGS IN THE SOFTWARE. * structures as well. */ typedef struct SkeinCtx { - u64b_t skeinSize; - u64b_t XSave[SKEIN_MAX_STATE_WORDS]; /* save area for state variables */ + u64 skeinSize; + u64 XSave[SKEIN_MAX_STATE_WORDS]; /* save area for state variables */ union { Skein_Ctxt_Hdr_t h; Skein_256_Ctxt_t s256; diff --git a/drivers/staging/skein/include/skein_iv.h b/drivers/staging/skein/include/skein_iv.h index bdb27078d846..1dc058142f38 100644 --- a/drivers/staging/skein/include/skein_iv.h +++ b/drivers/staging/skein/include/skein_iv.h @@ -20,7 +20,7 @@ #define MK_64 SKEIN_MK_64 /* blkSize = 256 bits. hashSize = 128 bits */ -const u64b_t SKEIN_256_IV_128[] = +const u64 SKEIN_256_IV_128[] = { MK_64(0xE1111906,0x964D7260), MK_64(0x883DAAA7,0x7C8D811C), @@ -29,7 +29,7 @@ const u64b_t SKEIN_256_IV_128[] = }; /* blkSize = 256 bits. hashSize = 160 bits */ -const u64b_t SKEIN_256_IV_160[] = +const u64 SKEIN_256_IV_160[] = { MK_64(0x14202314,0x72825E98), MK_64(0x2AC4E9A2,0x5A77E590), @@ -38,7 +38,7 @@ const u64b_t SKEIN_256_IV_160[] = }; /* blkSize = 256 bits. hashSize = 224 bits */ -const u64b_t SKEIN_256_IV_224[] = +const u64 SKEIN_256_IV_224[] = { MK_64(0xC6098A8C,0x9AE5EA0B), MK_64(0x876D5686,0x08C5191C), @@ -47,7 +47,7 @@ const u64b_t SKEIN_256_IV_224[] = }; /* blkSize = 256 bits. hashSize = 256 bits */ -const u64b_t SKEIN_256_IV_256[] = +const u64 SKEIN_256_IV_256[] = { MK_64(0xFC9DA860,0xD048B449), MK_64(0x2FCA6647,0x9FA7D833), @@ -56,7 +56,7 @@ const u64b_t SKEIN_256_IV_256[] = }; /* blkSize = 512 bits. hashSize = 128 bits */ -const u64b_t SKEIN_512_IV_128[] = +const u64 SKEIN_512_IV_128[] = { MK_64(0xA8BC7BF3,0x6FBF9F52), MK_64(0x1E9872CE,0xBD1AF0AA), @@ -69,7 +69,7 @@ const u64b_t SKEIN_512_IV_128[] = }; /* blkSize = 512 bits. hashSize = 160 bits */ -const u64b_t SKEIN_512_IV_160[] = +const u64 SKEIN_512_IV_160[] = { MK_64(0x28B81A2A,0xE013BD91), MK_64(0xC2F11668,0xB5BDF78F), @@ -82,7 +82,7 @@ const u64b_t SKEIN_512_IV_160[] = }; /* blkSize = 512 bits. hashSize = 224 bits */ -const u64b_t SKEIN_512_IV_224[] = +const u64 SKEIN_512_IV_224[] = { MK_64(0xCCD06162,0x48677224), MK_64(0xCBA65CF3,0xA92339EF), @@ -95,7 +95,7 @@ const u64b_t SKEIN_512_IV_224[] = }; /* blkSize = 512 bits. hashSize = 256 bits */ -const u64b_t SKEIN_512_IV_256[] = +const u64 SKEIN_512_IV_256[] = { MK_64(0xCCD044A1,0x2FDB3E13), MK_64(0xE8359030,0x1A79A9EB), @@ -108,7 +108,7 @@ const u64b_t SKEIN_512_IV_256[] = }; /* blkSize = 512 bits. hashSize = 384 bits */ -const u64b_t SKEIN_512_IV_384[] = +const u64 SKEIN_512_IV_384[] = { MK_64(0xA3F6C6BF,0x3A75EF5F), MK_64(0xB0FEF9CC,0xFD84FAA4), @@ -121,7 +121,7 @@ const u64b_t SKEIN_512_IV_384[] = }; /* blkSize = 512 bits. hashSize = 512 bits */ -const u64b_t SKEIN_512_IV_512[] = +const u64 SKEIN_512_IV_512[] = { MK_64(0x4903ADFF,0x749C51CE), MK_64(0x0D95DE39,0x9746DF03), @@ -134,7 +134,7 @@ const u64b_t SKEIN_512_IV_512[] = }; /* blkSize = 1024 bits. hashSize = 384 bits */ -const u64b_t SKEIN1024_IV_384[] = +const u64 SKEIN1024_IV_384[] = { MK_64(0x5102B6B8,0xC1894A35), MK_64(0xFEEBC9E3,0xFE8AF11A), @@ -155,7 +155,7 @@ const u64b_t SKEIN1024_IV_384[] = }; /* blkSize = 1024 bits. hashSize = 512 bits */ -const u64b_t SKEIN1024_IV_512[] = +const u64 SKEIN1024_IV_512[] = { MK_64(0xCAEC0E5D,0x7C1B1B18), MK_64(0xA01B0E04,0x5F03E802), @@ -176,7 +176,7 @@ const u64b_t SKEIN1024_IV_512[] = }; /* blkSize = 1024 bits. hashSize = 1024 bits */ -const u64b_t SKEIN1024_IV_1024[] = +const u64 SKEIN1024_IV_1024[] = { MK_64(0xD593DA07,0x41E72355), MK_64(0x15B5E511,0xAC73E00C), diff --git a/drivers/staging/skein/include/threefishApi.h b/drivers/staging/skein/include/threefishApi.h index aaecfe822142..0123a575b606 100644 --- a/drivers/staging/skein/include/threefishApi.h +++ b/drivers/staging/skein/include/threefishApi.h @@ -51,9 +51,9 @@ * structures as well. */ typedef struct ThreefishKey { - u64b_t stateSize; - u64b_t key[SKEIN_MAX_STATE_WORDS+1]; /* max number of key words*/ - u64b_t tweak[3]; + u64 stateSize; + u64 key[SKEIN_MAX_STATE_WORDS+1]; /* max number of key words*/ + u64 tweak[3]; } ThreefishKey_t; /** diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c index 93a102b16e64..593787c993c4 100644 --- a/drivers/staging/skein/skein.c +++ b/drivers/staging/skein/skein.c @@ -16,9 +16,9 @@ /*****************************************************************/ /* External function to process blkCnt (nonzero) full block(s) of data. */ -void Skein_256_Process_Block(Skein_256_Ctxt_t *ctx,const u08b_t *blkPtr,size_t blkCnt,size_t byteCntAdd); -void Skein_512_Process_Block(Skein_512_Ctxt_t *ctx,const u08b_t *blkPtr,size_t blkCnt,size_t byteCntAdd); -void Skein1024_Process_Block(Skein1024_Ctxt_t *ctx,const u08b_t *blkPtr,size_t blkCnt,size_t byteCntAdd); +void Skein_256_Process_Block(Skein_256_Ctxt_t *ctx,const u8 *blkPtr,size_t blkCnt,size_t byteCntAdd); +void Skein_512_Process_Block(Skein_512_Ctxt_t *ctx,const u8 *blkPtr,size_t blkCnt,size_t byteCntAdd); +void Skein1024_Process_Block(Skein1024_Ctxt_t *ctx,const u8 *blkPtr,size_t blkCnt,size_t byteCntAdd); /*****************************************************************/ /* 256-bit Skein */ @@ -30,8 +30,8 @@ int Skein_256_Init(Skein_256_Ctxt_t *ctx, size_t hashBitLen) { union { - u08b_t b[SKEIN_256_STATE_BYTES]; - u64b_t w[SKEIN_256_STATE_WORDS]; + u8 b[SKEIN_256_STATE_BYTES]; + u64 w[SKEIN_256_STATE_WORDS]; } cfg; /* config block */ Skein_Assert(hashBitLen > 0,SKEIN_BAD_HASHLEN); @@ -76,12 +76,12 @@ int Skein_256_Init(Skein_256_Ctxt_t *ctx, size_t hashBitLen) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a MAC and/or tree hash operation */ /* [identical to Skein_256_Init() when keyBytes == 0 && treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ -int Skein_256_InitExt(Skein_256_Ctxt_t *ctx,size_t hashBitLen,u64b_t treeInfo, const u08b_t *key, size_t keyBytes) +int Skein_256_InitExt(Skein_256_Ctxt_t *ctx,size_t hashBitLen,u64 treeInfo, const u8 *key, size_t keyBytes) { union { - u08b_t b[SKEIN_256_STATE_BYTES]; - u64b_t w[SKEIN_256_STATE_WORDS]; + u8 b[SKEIN_256_STATE_BYTES]; + u64 w[SKEIN_256_STATE_WORDS]; } cfg; /* config block */ Skein_Assert(hashBitLen > 0,SKEIN_BAD_HASHLEN); @@ -126,7 +126,7 @@ int Skein_256_InitExt(Skein_256_Ctxt_t *ctx,size_t hashBitLen,u64b_t treeInfo, c /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* process the input bytes */ -int Skein_256_Update(Skein_256_Ctxt_t *ctx, const u08b_t *msg, size_t msgByteCnt) +int Skein_256_Update(Skein_256_Ctxt_t *ctx, const u8 *msg, size_t msgByteCnt) { size_t n; @@ -174,10 +174,10 @@ int Skein_256_Update(Skein_256_Ctxt_t *ctx, const u08b_t *msg, size_t msgByteCnt /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the result */ -int Skein_256_Final(Skein_256_Ctxt_t *ctx, u08b_t *hashVal) +int Skein_256_Final(Skein_256_Ctxt_t *ctx, u8 *hashVal) { size_t i,n,byteCnt; - u64b_t X[SKEIN_256_STATE_WORDS]; + u64 X[SKEIN_256_STATE_WORDS]; Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ @@ -194,9 +194,9 @@ int Skein_256_Final(Skein_256_Ctxt_t *ctx, u08b_t *hashVal) memcpy(X,ctx->X,sizeof(X)); /* keep a local copy of counter mode "key" */ for (i=0;i*SKEIN_256_BLOCK_BYTES < byteCnt;i++) { - ((u64b_t *)ctx->b)[0]= Skein_Swap64((u64b_t) i); /* build the counter block */ + ((u64 *)ctx->b)[0]= Skein_Swap64((u64) i); /* build the counter block */ Skein_Start_New_Type(ctx,OUT_FINAL); - Skein_256_Process_Block(ctx,ctx->b,1,sizeof(u64b_t)); /* run "counter mode" */ + Skein_256_Process_Block(ctx,ctx->b,1,sizeof(u64)); /* run "counter mode" */ n = byteCnt - i*SKEIN_256_BLOCK_BYTES; /* number of output bytes left to go */ if (n >= SKEIN_256_BLOCK_BYTES) n = SKEIN_256_BLOCK_BYTES; @@ -217,8 +217,8 @@ int Skein_512_Init(Skein_512_Ctxt_t *ctx, size_t hashBitLen) { union { - u08b_t b[SKEIN_512_STATE_BYTES]; - u64b_t w[SKEIN_512_STATE_WORDS]; + u8 b[SKEIN_512_STATE_BYTES]; + u64 w[SKEIN_512_STATE_WORDS]; } cfg; /* config block */ Skein_Assert(hashBitLen > 0,SKEIN_BAD_HASHLEN); @@ -264,12 +264,12 @@ int Skein_512_Init(Skein_512_Ctxt_t *ctx, size_t hashBitLen) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a MAC and/or tree hash operation */ /* [identical to Skein_512_Init() when keyBytes == 0 && treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ -int Skein_512_InitExt(Skein_512_Ctxt_t *ctx,size_t hashBitLen,u64b_t treeInfo, const u08b_t *key, size_t keyBytes) +int Skein_512_InitExt(Skein_512_Ctxt_t *ctx,size_t hashBitLen,u64 treeInfo, const u8 *key, size_t keyBytes) { union { - u08b_t b[SKEIN_512_STATE_BYTES]; - u64b_t w[SKEIN_512_STATE_WORDS]; + u8 b[SKEIN_512_STATE_BYTES]; + u64 w[SKEIN_512_STATE_WORDS]; } cfg; /* config block */ Skein_Assert(hashBitLen > 0,SKEIN_BAD_HASHLEN); @@ -314,7 +314,7 @@ int Skein_512_InitExt(Skein_512_Ctxt_t *ctx,size_t hashBitLen,u64b_t treeInfo, c /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* process the input bytes */ -int Skein_512_Update(Skein_512_Ctxt_t *ctx, const u08b_t *msg, size_t msgByteCnt) +int Skein_512_Update(Skein_512_Ctxt_t *ctx, const u8 *msg, size_t msgByteCnt) { size_t n; @@ -362,10 +362,10 @@ int Skein_512_Update(Skein_512_Ctxt_t *ctx, const u08b_t *msg, size_t msgByteCnt /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the result */ -int Skein_512_Final(Skein_512_Ctxt_t *ctx, u08b_t *hashVal) +int Skein_512_Final(Skein_512_Ctxt_t *ctx, u8 *hashVal) { size_t i,n,byteCnt; - u64b_t X[SKEIN_512_STATE_WORDS]; + u64 X[SKEIN_512_STATE_WORDS]; Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ @@ -382,9 +382,9 @@ int Skein_512_Final(Skein_512_Ctxt_t *ctx, u08b_t *hashVal) memcpy(X,ctx->X,sizeof(X)); /* keep a local copy of counter mode "key" */ for (i=0;i*SKEIN_512_BLOCK_BYTES < byteCnt;i++) { - ((u64b_t *)ctx->b)[0]= Skein_Swap64((u64b_t) i); /* build the counter block */ + ((u64 *)ctx->b)[0]= Skein_Swap64((u64) i); /* build the counter block */ Skein_Start_New_Type(ctx,OUT_FINAL); - Skein_512_Process_Block(ctx,ctx->b,1,sizeof(u64b_t)); /* run "counter mode" */ + Skein_512_Process_Block(ctx,ctx->b,1,sizeof(u64)); /* run "counter mode" */ n = byteCnt - i*SKEIN_512_BLOCK_BYTES; /* number of output bytes left to go */ if (n >= SKEIN_512_BLOCK_BYTES) n = SKEIN_512_BLOCK_BYTES; @@ -405,8 +405,8 @@ int Skein1024_Init(Skein1024_Ctxt_t *ctx, size_t hashBitLen) { union { - u08b_t b[SKEIN1024_STATE_BYTES]; - u64b_t w[SKEIN1024_STATE_WORDS]; + u8 b[SKEIN1024_STATE_BYTES]; + u64 w[SKEIN1024_STATE_WORDS]; } cfg; /* config block */ Skein_Assert(hashBitLen > 0,SKEIN_BAD_HASHLEN); @@ -449,12 +449,12 @@ int Skein1024_Init(Skein1024_Ctxt_t *ctx, size_t hashBitLen) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a MAC and/or tree hash operation */ /* [identical to Skein1024_Init() when keyBytes == 0 && treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ -int Skein1024_InitExt(Skein1024_Ctxt_t *ctx,size_t hashBitLen,u64b_t treeInfo, const u08b_t *key, size_t keyBytes) +int Skein1024_InitExt(Skein1024_Ctxt_t *ctx,size_t hashBitLen,u64 treeInfo, const u8 *key, size_t keyBytes) { union { - u08b_t b[SKEIN1024_STATE_BYTES]; - u64b_t w[SKEIN1024_STATE_WORDS]; + u8 b[SKEIN1024_STATE_BYTES]; + u64 w[SKEIN1024_STATE_WORDS]; } cfg; /* config block */ Skein_Assert(hashBitLen > 0,SKEIN_BAD_HASHLEN); @@ -499,7 +499,7 @@ int Skein1024_InitExt(Skein1024_Ctxt_t *ctx,size_t hashBitLen,u64b_t treeInfo, c /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* process the input bytes */ -int Skein1024_Update(Skein1024_Ctxt_t *ctx, const u08b_t *msg, size_t msgByteCnt) +int Skein1024_Update(Skein1024_Ctxt_t *ctx, const u8 *msg, size_t msgByteCnt) { size_t n; @@ -547,10 +547,10 @@ int Skein1024_Update(Skein1024_Ctxt_t *ctx, const u08b_t *msg, size_t msgByteCnt /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the result */ -int Skein1024_Final(Skein1024_Ctxt_t *ctx, u08b_t *hashVal) +int Skein1024_Final(Skein1024_Ctxt_t *ctx, u8 *hashVal) { size_t i,n,byteCnt; - u64b_t X[SKEIN1024_STATE_WORDS]; + u64 X[SKEIN1024_STATE_WORDS]; Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ @@ -567,9 +567,9 @@ int Skein1024_Final(Skein1024_Ctxt_t *ctx, u08b_t *hashVal) memcpy(X,ctx->X,sizeof(X)); /* keep a local copy of counter mode "key" */ for (i=0;i*SKEIN1024_BLOCK_BYTES < byteCnt;i++) { - ((u64b_t *)ctx->b)[0]= Skein_Swap64((u64b_t) i); /* build the counter block */ + ((u64 *)ctx->b)[0]= Skein_Swap64((u64) i); /* build the counter block */ Skein_Start_New_Type(ctx,OUT_FINAL); - Skein1024_Process_Block(ctx,ctx->b,1,sizeof(u64b_t)); /* run "counter mode" */ + Skein1024_Process_Block(ctx,ctx->b,1,sizeof(u64)); /* run "counter mode" */ n = byteCnt - i*SKEIN1024_BLOCK_BYTES; /* number of output bytes left to go */ if (n >= SKEIN1024_BLOCK_BYTES) n = SKEIN1024_BLOCK_BYTES; @@ -585,7 +585,7 @@ int Skein1024_Final(Skein1024_Ctxt_t *ctx, u08b_t *hashVal) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the block, no OUTPUT stage */ -int Skein_256_Final_Pad(Skein_256_Ctxt_t *ctx, u08b_t *hashVal) +int Skein_256_Final_Pad(Skein_256_Ctxt_t *ctx, u8 *hashVal) { Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ @@ -601,7 +601,7 @@ int Skein_256_Final_Pad(Skein_256_Ctxt_t *ctx, u08b_t *hashVal) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the block, no OUTPUT stage */ -int Skein_512_Final_Pad(Skein_512_Ctxt_t *ctx, u08b_t *hashVal) +int Skein_512_Final_Pad(Skein_512_Ctxt_t *ctx, u8 *hashVal) { Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ @@ -617,7 +617,7 @@ int Skein_512_Final_Pad(Skein_512_Ctxt_t *ctx, u08b_t *hashVal) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the block, no OUTPUT stage */ -int Skein1024_Final_Pad(Skein1024_Ctxt_t *ctx, u08b_t *hashVal) +int Skein1024_Final_Pad(Skein1024_Ctxt_t *ctx, u8 *hashVal) { Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ @@ -634,10 +634,10 @@ int Skein1024_Final_Pad(Skein1024_Ctxt_t *ctx, u08b_t *hashVal) #if SKEIN_TREE_HASH /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* just do the OUTPUT stage */ -int Skein_256_Output(Skein_256_Ctxt_t *ctx, u08b_t *hashVal) +int Skein_256_Output(Skein_256_Ctxt_t *ctx, u8 *hashVal) { size_t i,n,byteCnt; - u64b_t X[SKEIN_256_STATE_WORDS]; + u64 X[SKEIN_256_STATE_WORDS]; Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ /* now output the result */ @@ -648,9 +648,9 @@ int Skein_256_Output(Skein_256_Ctxt_t *ctx, u08b_t *hashVal) memcpy(X,ctx->X,sizeof(X)); /* keep a local copy of counter mode "key" */ for (i=0;i*SKEIN_256_BLOCK_BYTES < byteCnt;i++) { - ((u64b_t *)ctx->b)[0]= Skein_Swap64((u64b_t) i); /* build the counter block */ + ((u64 *)ctx->b)[0]= Skein_Swap64((u64) i); /* build the counter block */ Skein_Start_New_Type(ctx,OUT_FINAL); - Skein_256_Process_Block(ctx,ctx->b,1,sizeof(u64b_t)); /* run "counter mode" */ + Skein_256_Process_Block(ctx,ctx->b,1,sizeof(u64)); /* run "counter mode" */ n = byteCnt - i*SKEIN_256_BLOCK_BYTES; /* number of output bytes left to go */ if (n >= SKEIN_256_BLOCK_BYTES) n = SKEIN_256_BLOCK_BYTES; @@ -663,10 +663,10 @@ int Skein_256_Output(Skein_256_Ctxt_t *ctx, u08b_t *hashVal) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* just do the OUTPUT stage */ -int Skein_512_Output(Skein_512_Ctxt_t *ctx, u08b_t *hashVal) +int Skein_512_Output(Skein_512_Ctxt_t *ctx, u8 *hashVal) { size_t i,n,byteCnt; - u64b_t X[SKEIN_512_STATE_WORDS]; + u64 X[SKEIN_512_STATE_WORDS]; Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ /* now output the result */ @@ -677,9 +677,9 @@ int Skein_512_Output(Skein_512_Ctxt_t *ctx, u08b_t *hashVal) memcpy(X,ctx->X,sizeof(X)); /* keep a local copy of counter mode "key" */ for (i=0;i*SKEIN_512_BLOCK_BYTES < byteCnt;i++) { - ((u64b_t *)ctx->b)[0]= Skein_Swap64((u64b_t) i); /* build the counter block */ + ((u64 *)ctx->b)[0]= Skein_Swap64((u64) i); /* build the counter block */ Skein_Start_New_Type(ctx,OUT_FINAL); - Skein_512_Process_Block(ctx,ctx->b,1,sizeof(u64b_t)); /* run "counter mode" */ + Skein_512_Process_Block(ctx,ctx->b,1,sizeof(u64)); /* run "counter mode" */ n = byteCnt - i*SKEIN_512_BLOCK_BYTES; /* number of output bytes left to go */ if (n >= SKEIN_512_BLOCK_BYTES) n = SKEIN_512_BLOCK_BYTES; @@ -692,10 +692,10 @@ int Skein_512_Output(Skein_512_Ctxt_t *ctx, u08b_t *hashVal) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* just do the OUTPUT stage */ -int Skein1024_Output(Skein1024_Ctxt_t *ctx, u08b_t *hashVal) +int Skein1024_Output(Skein1024_Ctxt_t *ctx, u8 *hashVal) { size_t i,n,byteCnt; - u64b_t X[SKEIN1024_STATE_WORDS]; + u64 X[SKEIN1024_STATE_WORDS]; Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ /* now output the result */ @@ -706,9 +706,9 @@ int Skein1024_Output(Skein1024_Ctxt_t *ctx, u08b_t *hashVal) memcpy(X,ctx->X,sizeof(X)); /* keep a local copy of counter mode "key" */ for (i=0;i*SKEIN1024_BLOCK_BYTES < byteCnt;i++) { - ((u64b_t *)ctx->b)[0]= Skein_Swap64((u64b_t) i); /* build the counter block */ + ((u64 *)ctx->b)[0]= Skein_Swap64((u64) i); /* build the counter block */ Skein_Start_New_Type(ctx,OUT_FINAL); - Skein1024_Process_Block(ctx,ctx->b,1,sizeof(u64b_t)); /* run "counter mode" */ + Skein1024_Process_Block(ctx,ctx->b,1,sizeof(u64)); /* run "counter mode" */ n = byteCnt - i*SKEIN1024_BLOCK_BYTES; /* number of output bytes left to go */ if (n >= SKEIN1024_BLOCK_BYTES) n = SKEIN1024_BLOCK_BYTES; diff --git a/drivers/staging/skein/skeinApi.c b/drivers/staging/skein/skeinApi.c index 579b92efbf65..ef021086bc61 100755 --- a/drivers/staging/skein/skeinApi.c +++ b/drivers/staging/skein/skeinApi.c @@ -41,7 +41,7 @@ int skeinInit(SkeinCtx_t* ctx, size_t hashBitLen) { int ret = SKEIN_FAIL; size_t Xlen = 0; - u64b_t* X = NULL; + u64* X = NULL; uint64_t treeInfo = SKEIN_CFG_TREE_INFO_SEQUENTIAL; Skein_Assert(ctx, SKEIN_FAIL); @@ -82,7 +82,7 @@ int skeinMacInit(SkeinCtx_t* ctx, const uint8_t *key, size_t keyLen, size_t hashBitLen) { int ret = SKEIN_FAIL; - u64b_t* X = NULL; + u64* X = NULL; size_t Xlen = 0; uint64_t treeInfo = SKEIN_CFG_TREE_INFO_SEQUENTIAL; @@ -97,18 +97,18 @@ int skeinMacInit(SkeinCtx_t* ctx, const uint8_t *key, size_t keyLen, case Skein256: ret = Skein_256_InitExt(&ctx->m.s256, hashBitLen, treeInfo, - (const u08b_t*)key, keyLen); + (const u8*)key, keyLen); break; case Skein512: ret = Skein_512_InitExt(&ctx->m.s512, hashBitLen, treeInfo, - (const u08b_t*)key, keyLen); + (const u8*)key, keyLen); break; case Skein1024: ret = Skein1024_InitExt(&ctx->m.s1024, hashBitLen, treeInfo, - (const u08b_t*)key, keyLen); + (const u8*)key, keyLen); break; } @@ -122,7 +122,7 @@ int skeinMacInit(SkeinCtx_t* ctx, const uint8_t *key, size_t keyLen, void skeinReset(SkeinCtx_t* ctx) { size_t Xlen = 0; - u64b_t* X = NULL; + u64* X = NULL; /* * The following two lines rely of the fact that the real Skein contexts are @@ -146,13 +146,13 @@ int skeinUpdate(SkeinCtx_t *ctx, const uint8_t *msg, switch (ctx->skeinSize) { case Skein256: - ret = Skein_256_Update(&ctx->m.s256, (const u08b_t*)msg, msgByteCnt); + ret = Skein_256_Update(&ctx->m.s256, (const u8*)msg, msgByteCnt); break; case Skein512: - ret = Skein_512_Update(&ctx->m.s512, (const u08b_t*)msg, msgByteCnt); + ret = Skein_512_Update(&ctx->m.s512, (const u8*)msg, msgByteCnt); break; case Skein1024: - ret = Skein1024_Update(&ctx->m.s1024, (const u08b_t*)msg, msgByteCnt); + ret = Skein1024_Update(&ctx->m.s1024, (const u8*)msg, msgByteCnt); break; } return ret; @@ -206,13 +206,13 @@ int skeinFinal(SkeinCtx_t* ctx, uint8_t* hash) switch (ctx->skeinSize) { case Skein256: - ret = Skein_256_Final(&ctx->m.s256, (u08b_t*)hash); + ret = Skein_256_Final(&ctx->m.s256, (u8*)hash); break; case Skein512: - ret = Skein_512_Final(&ctx->m.s512, (u08b_t*)hash); + ret = Skein_512_Final(&ctx->m.s512, (u8*)hash); break; case Skein1024: - ret = Skein1024_Final(&ctx->m.s1024, (u08b_t*)hash); + ret = Skein1024_Final(&ctx->m.s1024, (u8*)hash); break; } return ret; diff --git a/drivers/staging/skein/skeinBlockNo3F.c b/drivers/staging/skein/skeinBlockNo3F.c index 4e73c8b7caa2..9543c861d51b 100644 --- a/drivers/staging/skein/skeinBlockNo3F.c +++ b/drivers/staging/skein/skeinBlockNo3F.c @@ -5,21 +5,21 @@ /***************************** Skein_256 ******************************/ -void Skein_256_Process_Block(Skein_256_Ctxt_t *ctx, const u08b_t *blkPtr, +void Skein_256_Process_Block(Skein_256_Ctxt_t *ctx, const u8 *blkPtr, size_t blkCnt, size_t byteCntAdd) { ThreefishKey_t key; - u64b_t tweak[2]; + u64 tweak[2]; int i; - u64b_t w[SKEIN_256_STATE_WORDS]; /* local copy of input block */ - u64b_t words[3]; + u64 w[SKEIN_256_STATE_WORDS]; /* local copy of input block */ + u64 words[3]; Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ tweak[0] = ctx->h.T[0]; tweak[1] = ctx->h.T[1]; do { - u64b_t carry = byteCntAdd; + u64 carry = byteCntAdd; words[0] = tweak[0] & 0xffffffffL; words[1] = ((tweak[0] >> 32) & 0xffffffffL); @@ -55,21 +55,21 @@ void Skein_256_Process_Block(Skein_256_Ctxt_t *ctx, const u08b_t *blkPtr, ctx->h.T[1] = tweak[1]; } -void Skein_512_Process_Block(Skein_512_Ctxt_t *ctx, const u08b_t *blkPtr, +void Skein_512_Process_Block(Skein_512_Ctxt_t *ctx, const u8 *blkPtr, size_t blkCnt, size_t byteCntAdd) { ThreefishKey_t key; - u64b_t tweak[2]; + u64 tweak[2]; int i; - u64b_t words[3]; - u64b_t w[SKEIN_512_STATE_WORDS]; /* local copy of input block */ + u64 words[3]; + u64 w[SKEIN_512_STATE_WORDS]; /* local copy of input block */ Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ tweak[0] = ctx->h.T[0]; tweak[1] = ctx->h.T[1]; do { - u64b_t carry = byteCntAdd; + u64 carry = byteCntAdd; words[0] = tweak[0] & 0xffffffffL; words[1] = ((tweak[0] >> 32) & 0xffffffffL); @@ -109,21 +109,21 @@ void Skein_512_Process_Block(Skein_512_Ctxt_t *ctx, const u08b_t *blkPtr, ctx->h.T[1] = tweak[1]; } -void Skein1024_Process_Block(Skein1024_Ctxt_t *ctx, const u08b_t *blkPtr, +void Skein1024_Process_Block(Skein1024_Ctxt_t *ctx, const u8 *blkPtr, size_t blkCnt, size_t byteCntAdd) { ThreefishKey_t key; - u64b_t tweak[2]; + u64 tweak[2]; int i; - u64b_t words[3]; - u64b_t w[SKEIN1024_STATE_WORDS]; /* local copy of input block */ + u64 words[3]; + u64 w[SKEIN1024_STATE_WORDS]; /* local copy of input block */ Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ tweak[0] = ctx->h.T[0]; tweak[1] = ctx->h.T[1]; do { - u64b_t carry = byteCntAdd; + u64 carry = byteCntAdd; words[0] = tweak[0] & 0xffffffffL; words[1] = ((tweak[0] >> 32) & 0xffffffffL); diff --git a/drivers/staging/skein/skein_block.c b/drivers/staging/skein/skein_block.c index 99348dae282a..8d1519dcca78 100644 --- a/drivers/staging/skein/skein_block.c +++ b/drivers/staging/skein/skein_block.c @@ -39,7 +39,7 @@ /***************************** Skein_256 ******************************/ #if !(SKEIN_USE_ASM & 256) -void Skein_256_Process_Block(Skein_256_Ctxt_t *ctx,const u08b_t *blkPtr,size_t blkCnt,size_t byteCntAdd) +void Skein_256_Process_Block(Skein_256_Ctxt_t *ctx,const u8 *blkPtr,size_t blkCnt,size_t byteCntAdd) { /* do it in C */ enum { @@ -59,14 +59,14 @@ void Skein_256_Process_Block(Skein_256_Ctxt_t *ctx,const u08b_t *blkPtr,size_t b #error "Invalid SKEIN_UNROLL_256" /* sanity check on unroll count */ #endif size_t r; - u64b_t kw[WCNT+4+RCNT*2]; /* key schedule words : chaining vars + tweak + "rotation"*/ + u64 kw[WCNT+4+RCNT*2]; /* key schedule words : chaining vars + tweak + "rotation"*/ #else - u64b_t kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ + u64 kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ #endif - u64b_t X0,X1,X2,X3; /* local copy of context vars, for speed */ - u64b_t w [WCNT]; /* local copy of input block */ + u64 X0,X1,X2,X3; /* local copy of context vars, for speed */ + u64 w [WCNT]; /* local copy of input block */ #ifdef SKEIN_DEBUG - const u64b_t *Xptr[4]; /* use for debugging (help compiler put Xn in registers) */ + const u64 *Xptr[4]; /* use for debugging (help compiler put Xn in registers) */ Xptr[0] = &X0; Xptr[1] = &X1; Xptr[2] = &X2; Xptr[3] = &X3; #endif Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ @@ -212,10 +212,10 @@ void Skein_256_Process_Block(Skein_256_Ctxt_t *ctx,const u08b_t *blkPtr,size_t b #if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF) size_t Skein_256_Process_Block_CodeSize(void) { - return ((u08b_t *) Skein_256_Process_Block_CodeSize) - - ((u08b_t *) Skein_256_Process_Block); + return ((u8 *) Skein_256_Process_Block_CodeSize) - + ((u8 *) Skein_256_Process_Block); } -uint_t Skein_256_Unroll_Cnt(void) +unsigned int Skein_256_Unroll_Cnt(void) { return SKEIN_UNROLL_256; } @@ -224,7 +224,7 @@ uint_t Skein_256_Unroll_Cnt(void) /***************************** Skein_512 ******************************/ #if !(SKEIN_USE_ASM & 512) -void Skein_512_Process_Block(Skein_512_Ctxt_t *ctx,const u08b_t *blkPtr,size_t blkCnt,size_t byteCntAdd) +void Skein_512_Process_Block(Skein_512_Ctxt_t *ctx,const u8 *blkPtr,size_t blkCnt,size_t byteCntAdd) { /* do it in C */ enum { @@ -244,14 +244,14 @@ void Skein_512_Process_Block(Skein_512_Ctxt_t *ctx,const u08b_t *blkPtr,size_t b #error "Invalid SKEIN_UNROLL_512" /* sanity check on unroll count */ #endif size_t r; - u64b_t kw[WCNT+4+RCNT*2]; /* key schedule words : chaining vars + tweak + "rotation"*/ + u64 kw[WCNT+4+RCNT*2]; /* key schedule words : chaining vars + tweak + "rotation"*/ #else - u64b_t kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ + u64 kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ #endif - u64b_t X0,X1,X2,X3,X4,X5,X6,X7; /* local copy of vars, for speed */ - u64b_t w [WCNT]; /* local copy of input block */ + u64 X0,X1,X2,X3,X4,X5,X6,X7; /* local copy of vars, for speed */ + u64 w [WCNT]; /* local copy of input block */ #ifdef SKEIN_DEBUG - const u64b_t *Xptr[8]; /* use for debugging (help compiler put Xn in registers) */ + const u64 *Xptr[8]; /* use for debugging (help compiler put Xn in registers) */ Xptr[0] = &X0; Xptr[1] = &X1; Xptr[2] = &X2; Xptr[3] = &X3; Xptr[4] = &X4; Xptr[5] = &X5; Xptr[6] = &X6; Xptr[7] = &X7; #endif @@ -420,10 +420,10 @@ void Skein_512_Process_Block(Skein_512_Ctxt_t *ctx,const u08b_t *blkPtr,size_t b #if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF) size_t Skein_512_Process_Block_CodeSize(void) { - return ((u08b_t *) Skein_512_Process_Block_CodeSize) - - ((u08b_t *) Skein_512_Process_Block); + return ((u8 *) Skein_512_Process_Block_CodeSize) - + ((u8 *) Skein_512_Process_Block); } -uint_t Skein_512_Unroll_Cnt(void) +unsigned int Skein_512_Unroll_Cnt(void) { return SKEIN_UNROLL_512; } @@ -432,7 +432,7 @@ uint_t Skein_512_Unroll_Cnt(void) /***************************** Skein1024 ******************************/ #if !(SKEIN_USE_ASM & 1024) -void Skein1024_Process_Block(Skein1024_Ctxt_t *ctx,const u08b_t *blkPtr,size_t blkCnt,size_t byteCntAdd) +void Skein1024_Process_Block(Skein1024_Ctxt_t *ctx,const u8 *blkPtr,size_t blkCnt,size_t byteCntAdd) { /* do it in C, always looping (unrolled is bigger AND slower!) */ enum { @@ -452,16 +452,16 @@ void Skein1024_Process_Block(Skein1024_Ctxt_t *ctx,const u08b_t *blkPtr,size_t b #error "Invalid SKEIN_UNROLL_1024" /* sanity check on unroll count */ #endif size_t r; - u64b_t kw[WCNT+4+RCNT*2]; /* key schedule words : chaining vars + tweak + "rotation"*/ + u64 kw[WCNT+4+RCNT*2]; /* key schedule words : chaining vars + tweak + "rotation"*/ #else - u64b_t kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ + u64 kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ #endif - u64b_t X00,X01,X02,X03,X04,X05,X06,X07, /* local copy of vars, for speed */ + u64 X00,X01,X02,X03,X04,X05,X06,X07, /* local copy of vars, for speed */ X08,X09,X10,X11,X12,X13,X14,X15; - u64b_t w [WCNT]; /* local copy of input block */ + u64 w [WCNT]; /* local copy of input block */ #ifdef SKEIN_DEBUG - const u64b_t *Xptr[16]; /* use for debugging (help compiler put Xn in registers) */ + const u64 *Xptr[16]; /* use for debugging (help compiler put Xn in registers) */ Xptr[ 0] = &X00; Xptr[ 1] = &X01; Xptr[ 2] = &X02; Xptr[ 3] = &X03; Xptr[ 4] = &X04; Xptr[ 5] = &X05; Xptr[ 6] = &X06; Xptr[ 7] = &X07; Xptr[ 8] = &X08; Xptr[ 9] = &X09; Xptr[10] = &X10; Xptr[11] = &X11; @@ -678,10 +678,10 @@ void Skein1024_Process_Block(Skein1024_Ctxt_t *ctx,const u08b_t *blkPtr,size_t b #if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF) size_t Skein1024_Process_Block_CodeSize(void) { - return ((u08b_t *) Skein1024_Process_Block_CodeSize) - - ((u08b_t *) Skein1024_Process_Block); + return ((u8 *) Skein1024_Process_Block_CodeSize) - + ((u8 *) Skein1024_Process_Block); } -uint_t Skein1024_Unroll_Cnt(void) +unsigned int Skein1024_Unroll_Cnt(void) { return SKEIN_UNROLL_1024; } diff --git a/drivers/staging/skein/threefishApi.c b/drivers/staging/skein/threefishApi.c index 968d3d21fe61..ed19ee9e3425 100644 --- a/drivers/staging/skein/threefishApi.c +++ b/drivers/staging/skein/threefishApi.c @@ -25,8 +25,8 @@ void threefishSetKey(ThreefishKey_t* keyCtx, ThreefishSize_t stateSize, void threefishEncryptBlockBytes(ThreefishKey_t* keyCtx, uint8_t* in, uint8_t* out) { - u64b_t plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ - u64b_t cipher[SKEIN_MAX_STATE_WORDS]; + u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ + u64 cipher[SKEIN_MAX_STATE_WORDS]; Skein_Get64_LSB_First(plain, in, keyCtx->stateSize / 64); /* bytes to words */ threefishEncryptBlockWords(keyCtx, plain, cipher); @@ -52,8 +52,8 @@ void threefishEncryptBlockWords(ThreefishKey_t* keyCtx, uint64_t* in, void threefishDecryptBlockBytes(ThreefishKey_t* keyCtx, uint8_t* in, uint8_t* out) { - u64b_t plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ - u64b_t cipher[SKEIN_MAX_STATE_WORDS]; + u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ + u64 cipher[SKEIN_MAX_STATE_WORDS]; Skein_Get64_LSB_First(cipher, in, keyCtx->stateSize / 64); /* bytes to words */ threefishDecryptBlockWords(keyCtx, cipher, plain); -- cgit v1.2.3 From 11d9ffb2caecaf283a4619bd36e654314bc7632f Mon Sep 17 00:00:00 2001 From: Jason Cooper Date: Mon, 24 Mar 2014 01:49:04 +0000 Subject: staging: crypto: skein: remove all typedef {struct, enum} Signed-off-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/include/skein.h | 58 ++++++++++++++-------------- drivers/staging/skein/include/skeinApi.h | 32 +++++++-------- drivers/staging/skein/include/threefishApi.h | 32 +++++++-------- drivers/staging/skein/skein.c | 42 ++++++++++---------- drivers/staging/skein/skeinApi.c | 16 ++++---- drivers/staging/skein/skeinBlockNo3F.c | 12 +++--- drivers/staging/skein/skein_block.c | 6 +-- drivers/staging/skein/threefish1024Block.c | 4 +- drivers/staging/skein/threefish256Block.c | 4 +- drivers/staging/skein/threefish512Block.c | 4 +- drivers/staging/skein/threefishApi.c | 10 ++--- 11 files changed, 110 insertions(+), 110 deletions(-) diff --git a/drivers/staging/skein/include/skein.h b/drivers/staging/skein/include/skein.h index 5cf4c7fec467..635b6956a2bd 100644 --- a/drivers/staging/skein/include/skein.h +++ b/drivers/staging/skein/include/skein.h @@ -63,46 +63,46 @@ enum #define SKEIN_512_BLOCK_BYTES ( 8*SKEIN_512_STATE_WORDS) #define SKEIN1024_BLOCK_BYTES ( 8*SKEIN1024_STATE_WORDS) -typedef struct +struct skein_ctx_hdr { size_t hashBitLen; /* size of hash result, in bits */ size_t bCnt; /* current byte count in buffer b[] */ u64 T[SKEIN_MODIFIER_WORDS]; /* tweak words: T[0]=byte cnt, T[1]=flags */ - } Skein_Ctxt_Hdr_t; + }; -typedef struct /* 256-bit Skein hash context structure */ +struct skein_256_ctx /* 256-bit Skein hash context structure */ { - Skein_Ctxt_Hdr_t h; /* common header context variables */ + struct skein_ctx_hdr h; /* common header context variables */ u64 X[SKEIN_256_STATE_WORDS]; /* chaining variables */ u8 b[SKEIN_256_BLOCK_BYTES]; /* partial block buffer (8-byte aligned) */ - } Skein_256_Ctxt_t; + }; -typedef struct /* 512-bit Skein hash context structure */ +struct skein_512_ctx /* 512-bit Skein hash context structure */ { - Skein_Ctxt_Hdr_t h; /* common header context variables */ + struct skein_ctx_hdr h; /* common header context variables */ u64 X[SKEIN_512_STATE_WORDS]; /* chaining variables */ u8 b[SKEIN_512_BLOCK_BYTES]; /* partial block buffer (8-byte aligned) */ - } Skein_512_Ctxt_t; + }; -typedef struct /* 1024-bit Skein hash context structure */ +struct skein1024_ctx /* 1024-bit Skein hash context structure */ { - Skein_Ctxt_Hdr_t h; /* common header context variables */ + struct skein_ctx_hdr h; /* common header context variables */ u64 X[SKEIN1024_STATE_WORDS]; /* chaining variables */ u8 b[SKEIN1024_BLOCK_BYTES]; /* partial block buffer (8-byte aligned) */ - } Skein1024_Ctxt_t; + }; /* Skein APIs for (incremental) "straight hashing" */ -int Skein_256_Init (Skein_256_Ctxt_t *ctx, size_t hashBitLen); -int Skein_512_Init (Skein_512_Ctxt_t *ctx, size_t hashBitLen); -int Skein1024_Init (Skein1024_Ctxt_t *ctx, size_t hashBitLen); +int Skein_256_Init (struct skein_256_ctx *ctx, size_t hashBitLen); +int Skein_512_Init (struct skein_512_ctx *ctx, size_t hashBitLen); +int Skein1024_Init (struct skein1024_ctx *ctx, size_t hashBitLen); -int Skein_256_Update(Skein_256_Ctxt_t *ctx, const u8 *msg, size_t msgByteCnt); -int Skein_512_Update(Skein_512_Ctxt_t *ctx, const u8 *msg, size_t msgByteCnt); -int Skein1024_Update(Skein1024_Ctxt_t *ctx, const u8 *msg, size_t msgByteCnt); +int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg, size_t msgByteCnt); +int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg, size_t msgByteCnt); +int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg, size_t msgByteCnt); -int Skein_256_Final (Skein_256_Ctxt_t *ctx, u8 * hashVal); -int Skein_512_Final (Skein_512_Ctxt_t *ctx, u8 * hashVal); -int Skein1024_Final (Skein1024_Ctxt_t *ctx, u8 * hashVal); +int Skein_256_Final (struct skein_256_ctx *ctx, u8 * hashVal); +int Skein_512_Final (struct skein_512_ctx *ctx, u8 * hashVal); +int Skein1024_Final (struct skein1024_ctx *ctx, u8 * hashVal); /* ** Skein APIs for "extended" initialization: MAC keys, tree hashing. @@ -118,26 +118,26 @@ int Skein1024_Final (Skein1024_Ctxt_t *ctx, u8 * hashVal); ** to precompute the MAC IV, then a copy of the context saved and ** reused for each new MAC computation. **/ -int Skein_256_InitExt(Skein_256_Ctxt_t *ctx, size_t hashBitLen, u64 treeInfo, const u8 *key, size_t keyBytes); -int Skein_512_InitExt(Skein_512_Ctxt_t *ctx, size_t hashBitLen, u64 treeInfo, const u8 *key, size_t keyBytes); -int Skein1024_InitExt(Skein1024_Ctxt_t *ctx, size_t hashBitLen, u64 treeInfo, const u8 *key, size_t keyBytes); +int Skein_256_InitExt(struct skein_256_ctx *ctx, size_t hashBitLen, u64 treeInfo, const u8 *key, size_t keyBytes); +int Skein_512_InitExt(struct skein_512_ctx *ctx, size_t hashBitLen, u64 treeInfo, const u8 *key, size_t keyBytes); +int Skein1024_InitExt(struct skein1024_ctx *ctx, size_t hashBitLen, u64 treeInfo, const u8 *key, size_t keyBytes); /* ** Skein APIs for MAC and tree hash: ** Final_Pad: pad, do final block, but no OUTPUT type ** Output: do just the output stage */ -int Skein_256_Final_Pad(Skein_256_Ctxt_t *ctx, u8 * hashVal); -int Skein_512_Final_Pad(Skein_512_Ctxt_t *ctx, u8 * hashVal); -int Skein1024_Final_Pad(Skein1024_Ctxt_t *ctx, u8 * hashVal); +int Skein_256_Final_Pad(struct skein_256_ctx *ctx, u8 * hashVal); +int Skein_512_Final_Pad(struct skein_512_ctx *ctx, u8 * hashVal); +int Skein1024_Final_Pad(struct skein1024_ctx *ctx, u8 * hashVal); #ifndef SKEIN_TREE_HASH #define SKEIN_TREE_HASH (1) #endif #if SKEIN_TREE_HASH -int Skein_256_Output (Skein_256_Ctxt_t *ctx, u8 * hashVal); -int Skein_512_Output (Skein_512_Ctxt_t *ctx, u8 * hashVal); -int Skein1024_Output (Skein1024_Ctxt_t *ctx, u8 * hashVal); +int Skein_256_Output (struct skein_256_ctx *ctx, u8 * hashVal); +int Skein_512_Output (struct skein_512_ctx *ctx, u8 * hashVal); +int Skein1024_Output (struct skein1024_ctx *ctx, u8 * hashVal); #endif /***************************************************************** diff --git a/drivers/staging/skein/include/skeinApi.h b/drivers/staging/skein/include/skeinApi.h index fb4a7c8e7f7a..548c639431de 100755 --- a/drivers/staging/skein/include/skeinApi.h +++ b/drivers/staging/skein/include/skeinApi.h @@ -47,7 +47,7 @@ OTHER DEALINGS IN THE SOFTWARE. * #include * * ... - * SkeinCtx_t ctx; // a Skein hash or MAC context + * struct skein_ctx ctx; // a Skein hash or MAC context * * // prepare context, here for a Skein with a state size of 512 bits. * skeinCtxPrepare(&ctx, Skein512); @@ -84,11 +84,11 @@ OTHER DEALINGS IN THE SOFTWARE. /** * Which Skein size to use */ - typedef enum SkeinSize { + enum skein_size { Skein256 = 256, /*!< Skein with 256 bit state */ Skein512 = 512, /*!< Skein with 512 bit state */ Skein1024 = 1024 /*!< Skein with 1024 bit state */ - } SkeinSize_t; + }; /** * Context for Skein. @@ -98,16 +98,16 @@ OTHER DEALINGS IN THE SOFTWARE. * variables. If Skein implementation changes this, then adapt these * structures as well. */ - typedef struct SkeinCtx { + struct skein_ctx { u64 skeinSize; u64 XSave[SKEIN_MAX_STATE_WORDS]; /* save area for state variables */ union { - Skein_Ctxt_Hdr_t h; - Skein_256_Ctxt_t s256; - Skein_512_Ctxt_t s512; - Skein1024_Ctxt_t s1024; + struct skein_ctx_hdr h; + struct skein_256_ctx s256; + struct skein_512_ctx s512; + struct skein1024_ctx s1024; } m; - } SkeinCtx_t; + }; /** * Prepare a Skein context. @@ -123,7 +123,7 @@ OTHER DEALINGS IN THE SOFTWARE. * @return * SKEIN_SUCESS of SKEIN_FAIL */ - int skeinCtxPrepare(SkeinCtx_t* ctx, SkeinSize_t size); + int skeinCtxPrepare(struct skein_ctx* ctx, enum skein_size size); /** * Initialize a Skein context. @@ -139,7 +139,7 @@ OTHER DEALINGS IN THE SOFTWARE. * SKEIN_SUCESS of SKEIN_FAIL * @see skeinReset */ - int skeinInit(SkeinCtx_t* ctx, size_t hashBitLen); + int skeinInit(struct skein_ctx* ctx, size_t hashBitLen); /** * Resets a Skein context for further use. @@ -151,7 +151,7 @@ OTHER DEALINGS IN THE SOFTWARE. * @param ctx * Pointer to a pre-initialized Skein MAC context */ - void skeinReset(SkeinCtx_t* ctx); + void skeinReset(struct skein_ctx* ctx); /** * Initializes a Skein context for MAC usage. @@ -173,7 +173,7 @@ OTHER DEALINGS IN THE SOFTWARE. * @return * SKEIN_SUCESS of SKEIN_FAIL */ - int skeinMacInit(SkeinCtx_t* ctx, const uint8_t *key, size_t keyLen, + int skeinMacInit(struct skein_ctx* ctx, const uint8_t *key, size_t keyLen, size_t hashBitLen); /** @@ -188,7 +188,7 @@ OTHER DEALINGS IN THE SOFTWARE. * @return * Success or error code. */ - int skeinUpdate(SkeinCtx_t *ctx, const uint8_t *msg, + int skeinUpdate(struct skein_ctx *ctx, const uint8_t *msg, size_t msgByteCnt); /** @@ -204,7 +204,7 @@ OTHER DEALINGS IN THE SOFTWARE. * @param msgBitCnt * Length of the message in @b bits. */ - int skeinUpdateBits(SkeinCtx_t *ctx, const uint8_t *msg, + int skeinUpdateBits(struct skein_ctx *ctx, const uint8_t *msg, size_t msgBitCnt); /** @@ -222,7 +222,7 @@ OTHER DEALINGS IN THE SOFTWARE. * Success or error code. * @see skeinReset */ - int skeinFinal(SkeinCtx_t* ctx, uint8_t* hash); + int skeinFinal(struct skein_ctx* ctx, uint8_t* hash); /** * @} diff --git a/drivers/staging/skein/include/threefishApi.h b/drivers/staging/skein/include/threefishApi.h index 0123a575b606..4c1cd81f30c4 100644 --- a/drivers/staging/skein/include/threefishApi.h +++ b/drivers/staging/skein/include/threefishApi.h @@ -18,7 +18,7 @@ * @code // Threefish cipher context data - ThreefishKey_t keyCtx; + struct threefish_key keyCtx; // Initialize the context threefishSetKey(&keyCtx, Threefish512, key, tweak); @@ -36,11 +36,11 @@ /** * Which Threefish size to use */ - typedef enum ThreefishSize { + enum threefish_size { Threefish256 = 256, /*!< Skein with 256 bit state */ Threefish512 = 512, /*!< Skein with 512 bit state */ Threefish1024 = 1024 /*!< Skein with 1024 bit state */ - } ThreefishSize_t; + }; /** * Context for Threefish key and tweak words. @@ -50,11 +50,11 @@ * variables. If Skein implementation changes this, the adapt these * structures as well. */ - typedef struct ThreefishKey { + struct threefish_key { u64 stateSize; u64 key[SKEIN_MAX_STATE_WORDS+1]; /* max number of key words*/ u64 tweak[3]; - } ThreefishKey_t; + }; /** * Set Threefish key and tweak data. @@ -72,7 +72,7 @@ * @param tweak * Pointer to the two tweak words (word has 64 bits). */ - void threefishSetKey(ThreefishKey_t* keyCtx, ThreefishSize_t stateSize, uint64_t* keyData, uint64_t* tweak); + void threefishSetKey(struct threefish_key* keyCtx, enum threefish_size stateSize, uint64_t* keyData, uint64_t* tweak); /** * Encrypt Threefisch block (bytes). @@ -89,7 +89,7 @@ * @param out * Pointer to cipher buffer. */ - void threefishEncryptBlockBytes(ThreefishKey_t* keyCtx, uint8_t* in, uint8_t* out); + void threefishEncryptBlockBytes(struct threefish_key* keyCtx, uint8_t* in, uint8_t* out); /** * Encrypt Threefisch block (words). @@ -108,7 +108,7 @@ * @param out * Pointer to cipher buffer. */ - void threefishEncryptBlockWords(ThreefishKey_t* keyCtx, uint64_t* in, uint64_t* out); + void threefishEncryptBlockWords(struct threefish_key* keyCtx, uint64_t* in, uint64_t* out); /** * Decrypt Threefisch block (bytes). @@ -125,7 +125,7 @@ * @param out * Pointer to plaintext buffer. */ - void threefishDecryptBlockBytes(ThreefishKey_t* keyCtx, uint8_t* in, uint8_t* out); + void threefishDecryptBlockBytes(struct threefish_key* keyCtx, uint8_t* in, uint8_t* out); /** * Decrypt Threefisch block (words). @@ -144,14 +144,14 @@ * @param out * Pointer to plaintext buffer. */ - void threefishDecryptBlockWords(ThreefishKey_t* keyCtx, uint64_t* in, uint64_t* out); + void threefishDecryptBlockWords(struct threefish_key* keyCtx, uint64_t* in, uint64_t* out); - void threefishEncrypt256(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output); - void threefishEncrypt512(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output); - void threefishEncrypt1024(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output); - void threefishDecrypt256(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output); - void threefishDecrypt512(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output); - void threefishDecrypt1024(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output); + void threefishEncrypt256(struct threefish_key* keyCtx, uint64_t* input, uint64_t* output); + void threefishEncrypt512(struct threefish_key* keyCtx, uint64_t* input, uint64_t* output); + void threefishEncrypt1024(struct threefish_key* keyCtx, uint64_t* input, uint64_t* output); + void threefishDecrypt256(struct threefish_key* keyCtx, uint64_t* input, uint64_t* output); + void threefishDecrypt512(struct threefish_key* keyCtx, uint64_t* input, uint64_t* output); + void threefishDecrypt1024(struct threefish_key* keyCtx, uint64_t* input, uint64_t* output); /** * @} */ diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c index 593787c993c4..c1565377ff28 100644 --- a/drivers/staging/skein/skein.c +++ b/drivers/staging/skein/skein.c @@ -16,9 +16,9 @@ /*****************************************************************/ /* External function to process blkCnt (nonzero) full block(s) of data. */ -void Skein_256_Process_Block(Skein_256_Ctxt_t *ctx,const u8 *blkPtr,size_t blkCnt,size_t byteCntAdd); -void Skein_512_Process_Block(Skein_512_Ctxt_t *ctx,const u8 *blkPtr,size_t blkCnt,size_t byteCntAdd); -void Skein1024_Process_Block(Skein1024_Ctxt_t *ctx,const u8 *blkPtr,size_t blkCnt,size_t byteCntAdd); +void Skein_256_Process_Block(struct skein_256_ctx *ctx,const u8 *blkPtr,size_t blkCnt,size_t byteCntAdd); +void Skein_512_Process_Block(struct skein_512_ctx *ctx,const u8 *blkPtr,size_t blkCnt,size_t byteCntAdd); +void Skein1024_Process_Block(struct skein1024_ctx *ctx,const u8 *blkPtr,size_t blkCnt,size_t byteCntAdd); /*****************************************************************/ /* 256-bit Skein */ @@ -26,7 +26,7 @@ void Skein1024_Process_Block(Skein1024_Ctxt_t *ctx,const u8 *blkPtr,size_t bl /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a straight hashing operation */ -int Skein_256_Init(Skein_256_Ctxt_t *ctx, size_t hashBitLen) +int Skein_256_Init(struct skein_256_ctx *ctx, size_t hashBitLen) { union { @@ -76,7 +76,7 @@ int Skein_256_Init(Skein_256_Ctxt_t *ctx, size_t hashBitLen) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a MAC and/or tree hash operation */ /* [identical to Skein_256_Init() when keyBytes == 0 && treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ -int Skein_256_InitExt(Skein_256_Ctxt_t *ctx,size_t hashBitLen,u64 treeInfo, const u8 *key, size_t keyBytes) +int Skein_256_InitExt(struct skein_256_ctx *ctx,size_t hashBitLen,u64 treeInfo, const u8 *key, size_t keyBytes) { union { @@ -126,7 +126,7 @@ int Skein_256_InitExt(Skein_256_Ctxt_t *ctx,size_t hashBitLen,u64 treeInfo, cons /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* process the input bytes */ -int Skein_256_Update(Skein_256_Ctxt_t *ctx, const u8 *msg, size_t msgByteCnt) +int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg, size_t msgByteCnt) { size_t n; @@ -174,7 +174,7 @@ int Skein_256_Update(Skein_256_Ctxt_t *ctx, const u8 *msg, size_t msgByteCnt) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the result */ -int Skein_256_Final(Skein_256_Ctxt_t *ctx, u8 *hashVal) +int Skein_256_Final(struct skein_256_ctx *ctx, u8 *hashVal) { size_t i,n,byteCnt; u64 X[SKEIN_256_STATE_WORDS]; @@ -213,7 +213,7 @@ int Skein_256_Final(Skein_256_Ctxt_t *ctx, u8 *hashVal) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a straight hashing operation */ -int Skein_512_Init(Skein_512_Ctxt_t *ctx, size_t hashBitLen) +int Skein_512_Init(struct skein_512_ctx *ctx, size_t hashBitLen) { union { @@ -264,7 +264,7 @@ int Skein_512_Init(Skein_512_Ctxt_t *ctx, size_t hashBitLen) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a MAC and/or tree hash operation */ /* [identical to Skein_512_Init() when keyBytes == 0 && treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ -int Skein_512_InitExt(Skein_512_Ctxt_t *ctx,size_t hashBitLen,u64 treeInfo, const u8 *key, size_t keyBytes) +int Skein_512_InitExt(struct skein_512_ctx *ctx,size_t hashBitLen,u64 treeInfo, const u8 *key, size_t keyBytes) { union { @@ -314,7 +314,7 @@ int Skein_512_InitExt(Skein_512_Ctxt_t *ctx,size_t hashBitLen,u64 treeInfo, cons /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* process the input bytes */ -int Skein_512_Update(Skein_512_Ctxt_t *ctx, const u8 *msg, size_t msgByteCnt) +int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg, size_t msgByteCnt) { size_t n; @@ -362,7 +362,7 @@ int Skein_512_Update(Skein_512_Ctxt_t *ctx, const u8 *msg, size_t msgByteCnt) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the result */ -int Skein_512_Final(Skein_512_Ctxt_t *ctx, u8 *hashVal) +int Skein_512_Final(struct skein_512_ctx *ctx, u8 *hashVal) { size_t i,n,byteCnt; u64 X[SKEIN_512_STATE_WORDS]; @@ -401,7 +401,7 @@ int Skein_512_Final(Skein_512_Ctxt_t *ctx, u8 *hashVal) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a straight hashing operation */ -int Skein1024_Init(Skein1024_Ctxt_t *ctx, size_t hashBitLen) +int Skein1024_Init(struct skein1024_ctx *ctx, size_t hashBitLen) { union { @@ -449,7 +449,7 @@ int Skein1024_Init(Skein1024_Ctxt_t *ctx, size_t hashBitLen) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a MAC and/or tree hash operation */ /* [identical to Skein1024_Init() when keyBytes == 0 && treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ -int Skein1024_InitExt(Skein1024_Ctxt_t *ctx,size_t hashBitLen,u64 treeInfo, const u8 *key, size_t keyBytes) +int Skein1024_InitExt(struct skein1024_ctx *ctx,size_t hashBitLen,u64 treeInfo, const u8 *key, size_t keyBytes) { union { @@ -499,7 +499,7 @@ int Skein1024_InitExt(Skein1024_Ctxt_t *ctx,size_t hashBitLen,u64 treeInfo, cons /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* process the input bytes */ -int Skein1024_Update(Skein1024_Ctxt_t *ctx, const u8 *msg, size_t msgByteCnt) +int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg, size_t msgByteCnt) { size_t n; @@ -547,7 +547,7 @@ int Skein1024_Update(Skein1024_Ctxt_t *ctx, const u8 *msg, size_t msgByteCnt) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the result */ -int Skein1024_Final(Skein1024_Ctxt_t *ctx, u8 *hashVal) +int Skein1024_Final(struct skein1024_ctx *ctx, u8 *hashVal) { size_t i,n,byteCnt; u64 X[SKEIN1024_STATE_WORDS]; @@ -585,7 +585,7 @@ int Skein1024_Final(Skein1024_Ctxt_t *ctx, u8 *hashVal) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the block, no OUTPUT stage */ -int Skein_256_Final_Pad(Skein_256_Ctxt_t *ctx, u8 *hashVal) +int Skein_256_Final_Pad(struct skein_256_ctx *ctx, u8 *hashVal) { Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ @@ -601,7 +601,7 @@ int Skein_256_Final_Pad(Skein_256_Ctxt_t *ctx, u8 *hashVal) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the block, no OUTPUT stage */ -int Skein_512_Final_Pad(Skein_512_Ctxt_t *ctx, u8 *hashVal) +int Skein_512_Final_Pad(struct skein_512_ctx *ctx, u8 *hashVal) { Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ @@ -617,7 +617,7 @@ int Skein_512_Final_Pad(Skein_512_Ctxt_t *ctx, u8 *hashVal) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the block, no OUTPUT stage */ -int Skein1024_Final_Pad(Skein1024_Ctxt_t *ctx, u8 *hashVal) +int Skein1024_Final_Pad(struct skein1024_ctx *ctx, u8 *hashVal) { Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ @@ -634,7 +634,7 @@ int Skein1024_Final_Pad(Skein1024_Ctxt_t *ctx, u8 *hashVal) #if SKEIN_TREE_HASH /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* just do the OUTPUT stage */ -int Skein_256_Output(Skein_256_Ctxt_t *ctx, u8 *hashVal) +int Skein_256_Output(struct skein_256_ctx *ctx, u8 *hashVal) { size_t i,n,byteCnt; u64 X[SKEIN_256_STATE_WORDS]; @@ -663,7 +663,7 @@ int Skein_256_Output(Skein_256_Ctxt_t *ctx, u8 *hashVal) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* just do the OUTPUT stage */ -int Skein_512_Output(Skein_512_Ctxt_t *ctx, u8 *hashVal) +int Skein_512_Output(struct skein_512_ctx *ctx, u8 *hashVal) { size_t i,n,byteCnt; u64 X[SKEIN_512_STATE_WORDS]; @@ -692,7 +692,7 @@ int Skein_512_Output(Skein_512_Ctxt_t *ctx, u8 *hashVal) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* just do the OUTPUT stage */ -int Skein1024_Output(Skein1024_Ctxt_t *ctx, u8 *hashVal) +int Skein1024_Output(struct skein1024_ctx *ctx, u8 *hashVal) { size_t i,n,byteCnt; u64 X[SKEIN1024_STATE_WORDS]; diff --git a/drivers/staging/skein/skeinApi.c b/drivers/staging/skein/skeinApi.c index ef021086bc61..ce5c5ae575e7 100755 --- a/drivers/staging/skein/skeinApi.c +++ b/drivers/staging/skein/skeinApi.c @@ -27,17 +27,17 @@ OTHER DEALINGS IN THE SOFTWARE. #include #include -int skeinCtxPrepare(SkeinCtx_t* ctx, SkeinSize_t size) +int skeinCtxPrepare(struct skein_ctx* ctx, enum skein_size size) { Skein_Assert(ctx && size, SKEIN_FAIL); - memset(ctx ,0, sizeof(SkeinCtx_t)); + memset(ctx ,0, sizeof(struct skein_ctx)); ctx->skeinSize = size; return SKEIN_SUCCESS; } -int skeinInit(SkeinCtx_t* ctx, size_t hashBitLen) +int skeinInit(struct skein_ctx* ctx, size_t hashBitLen) { int ret = SKEIN_FAIL; size_t Xlen = 0; @@ -78,7 +78,7 @@ int skeinInit(SkeinCtx_t* ctx, size_t hashBitLen) return ret; } -int skeinMacInit(SkeinCtx_t* ctx, const uint8_t *key, size_t keyLen, +int skeinMacInit(struct skein_ctx* ctx, const uint8_t *key, size_t keyLen, size_t hashBitLen) { int ret = SKEIN_FAIL; @@ -119,7 +119,7 @@ int skeinMacInit(SkeinCtx_t* ctx, const uint8_t *key, size_t keyLen, return ret; } -void skeinReset(SkeinCtx_t* ctx) +void skeinReset(struct skein_ctx* ctx) { size_t Xlen = 0; u64* X = NULL; @@ -138,7 +138,7 @@ void skeinReset(SkeinCtx_t* ctx) Skein_Start_New_Type(&ctx->m, MSG); } -int skeinUpdate(SkeinCtx_t *ctx, const uint8_t *msg, +int skeinUpdate(struct skein_ctx *ctx, const uint8_t *msg, size_t msgByteCnt) { int ret = SKEIN_FAIL; @@ -159,7 +159,7 @@ int skeinUpdate(SkeinCtx_t *ctx, const uint8_t *msg, } -int skeinUpdateBits(SkeinCtx_t *ctx, const uint8_t *msg, +int skeinUpdateBits(struct skein_ctx *ctx, const uint8_t *msg, size_t msgBitCnt) { /* @@ -199,7 +199,7 @@ int skeinUpdateBits(SkeinCtx_t *ctx, const uint8_t *msg, return SKEIN_SUCCESS; } -int skeinFinal(SkeinCtx_t* ctx, uint8_t* hash) +int skeinFinal(struct skein_ctx* ctx, uint8_t* hash) { int ret = SKEIN_FAIL; Skein_Assert(ctx, SKEIN_FAIL); diff --git a/drivers/staging/skein/skeinBlockNo3F.c b/drivers/staging/skein/skeinBlockNo3F.c index 9543c861d51b..b483f3dbc27c 100644 --- a/drivers/staging/skein/skeinBlockNo3F.c +++ b/drivers/staging/skein/skeinBlockNo3F.c @@ -5,10 +5,10 @@ /***************************** Skein_256 ******************************/ -void Skein_256_Process_Block(Skein_256_Ctxt_t *ctx, const u8 *blkPtr, +void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, size_t blkCnt, size_t byteCntAdd) { - ThreefishKey_t key; + struct threefish_key key; u64 tweak[2]; int i; u64 w[SKEIN_256_STATE_WORDS]; /* local copy of input block */ @@ -55,10 +55,10 @@ void Skein_256_Process_Block(Skein_256_Ctxt_t *ctx, const u8 *blkPtr, ctx->h.T[1] = tweak[1]; } -void Skein_512_Process_Block(Skein_512_Ctxt_t *ctx, const u8 *blkPtr, +void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, size_t blkCnt, size_t byteCntAdd) { - ThreefishKey_t key; + struct threefish_key key; u64 tweak[2]; int i; u64 words[3]; @@ -109,10 +109,10 @@ void Skein_512_Process_Block(Skein_512_Ctxt_t *ctx, const u8 *blkPtr, ctx->h.T[1] = tweak[1]; } -void Skein1024_Process_Block(Skein1024_Ctxt_t *ctx, const u8 *blkPtr, +void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, size_t blkCnt, size_t byteCntAdd) { - ThreefishKey_t key; + struct threefish_key key; u64 tweak[2]; int i; u64 words[3]; diff --git a/drivers/staging/skein/skein_block.c b/drivers/staging/skein/skein_block.c index 8d1519dcca78..246af8156e90 100644 --- a/drivers/staging/skein/skein_block.c +++ b/drivers/staging/skein/skein_block.c @@ -39,7 +39,7 @@ /***************************** Skein_256 ******************************/ #if !(SKEIN_USE_ASM & 256) -void Skein_256_Process_Block(Skein_256_Ctxt_t *ctx,const u8 *blkPtr,size_t blkCnt,size_t byteCntAdd) +void Skein_256_Process_Block(struct skein_256_ctx *ctx,const u8 *blkPtr,size_t blkCnt,size_t byteCntAdd) { /* do it in C */ enum { @@ -224,7 +224,7 @@ unsigned int Skein_256_Unroll_Cnt(void) /***************************** Skein_512 ******************************/ #if !(SKEIN_USE_ASM & 512) -void Skein_512_Process_Block(Skein_512_Ctxt_t *ctx,const u8 *blkPtr,size_t blkCnt,size_t byteCntAdd) +void Skein_512_Process_Block(struct skein_512_ctx *ctx,const u8 *blkPtr,size_t blkCnt,size_t byteCntAdd) { /* do it in C */ enum { @@ -432,7 +432,7 @@ unsigned int Skein_512_Unroll_Cnt(void) /***************************** Skein1024 ******************************/ #if !(SKEIN_USE_ASM & 1024) -void Skein1024_Process_Block(Skein1024_Ctxt_t *ctx,const u8 *blkPtr,size_t blkCnt,size_t byteCntAdd) +void Skein1024_Process_Block(struct skein1024_ctx *ctx,const u8 *blkPtr,size_t blkCnt,size_t byteCntAdd) { /* do it in C, always looping (unrolled is bigger AND slower!) */ enum { diff --git a/drivers/staging/skein/threefish1024Block.c b/drivers/staging/skein/threefish1024Block.c index 58a8c26a1f6f..738ec523406b 100644 --- a/drivers/staging/skein/threefish1024Block.c +++ b/drivers/staging/skein/threefish1024Block.c @@ -2,7 +2,7 @@ #include -void threefishEncrypt1024(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output) +void threefishEncrypt1024(struct threefish_key* keyCtx, uint64_t* input, uint64_t* output) { uint64_t b0 = input[0], b1 = input[1], @@ -684,7 +684,7 @@ void threefishEncrypt1024(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* out output[15] = b15 + k1 + 20; } -void threefishDecrypt1024(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output) +void threefishDecrypt1024(struct threefish_key* keyCtx, uint64_t* input, uint64_t* output) { uint64_t b0 = input[0], b1 = input[1], diff --git a/drivers/staging/skein/threefish256Block.c b/drivers/staging/skein/threefish256Block.c index a7e06f905186..b81cb3a65b04 100644 --- a/drivers/staging/skein/threefish256Block.c +++ b/drivers/staging/skein/threefish256Block.c @@ -2,7 +2,7 @@ #include -void threefishEncrypt256(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output) +void threefishEncrypt256(struct threefish_key* keyCtx, uint64_t* input, uint64_t* output) { uint64_t b0 = input[0], b1 = input[1], @@ -172,7 +172,7 @@ void threefishEncrypt256(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* outp output[3] = b3 + k1 + 18; } -void threefishDecrypt256(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output) +void threefishDecrypt256(struct threefish_key* keyCtx, uint64_t* input, uint64_t* output) { uint64_t b0 = input[0], b1 = input[1], b2 = input[2], b3 = input[3]; diff --git a/drivers/staging/skein/threefish512Block.c b/drivers/staging/skein/threefish512Block.c index 3cbfcd9af5c9..7eed6aeb3742 100644 --- a/drivers/staging/skein/threefish512Block.c +++ b/drivers/staging/skein/threefish512Block.c @@ -2,7 +2,7 @@ #include -void threefishEncrypt512(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output) +void threefishEncrypt512(struct threefish_key* keyCtx, uint64_t* input, uint64_t* output) { uint64_t b0 = input[0], b1 = input[1], @@ -316,7 +316,7 @@ void threefishEncrypt512(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* outp output[7] = b7 + k7 + 18; } -void threefishDecrypt512(ThreefishKey_t* keyCtx, uint64_t* input, uint64_t* output) +void threefishDecrypt512(struct threefish_key* keyCtx, uint64_t* input, uint64_t* output) { uint64_t b0 = input[0], b1 = input[1], diff --git a/drivers/staging/skein/threefishApi.c b/drivers/staging/skein/threefishApi.c index ed19ee9e3425..5cd3eb9bd9f2 100644 --- a/drivers/staging/skein/threefishApi.c +++ b/drivers/staging/skein/threefishApi.c @@ -3,7 +3,7 @@ #include #include -void threefishSetKey(ThreefishKey_t* keyCtx, ThreefishSize_t stateSize, +void threefishSetKey(struct threefish_key* keyCtx, enum threefish_size stateSize, uint64_t* keyData, uint64_t* tweak) { int keyWords = stateSize / 64; @@ -22,7 +22,7 @@ void threefishSetKey(ThreefishKey_t* keyCtx, ThreefishSize_t stateSize, keyCtx->stateSize = stateSize; } -void threefishEncryptBlockBytes(ThreefishKey_t* keyCtx, uint8_t* in, +void threefishEncryptBlockBytes(struct threefish_key* keyCtx, uint8_t* in, uint8_t* out) { u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ @@ -33,7 +33,7 @@ void threefishEncryptBlockBytes(ThreefishKey_t* keyCtx, uint8_t* in, Skein_Put64_LSB_First(out, cipher, keyCtx->stateSize / 8); /* words to bytes */ } -void threefishEncryptBlockWords(ThreefishKey_t* keyCtx, uint64_t* in, +void threefishEncryptBlockWords(struct threefish_key* keyCtx, uint64_t* in, uint64_t* out) { switch (keyCtx->stateSize) { @@ -49,7 +49,7 @@ void threefishEncryptBlockWords(ThreefishKey_t* keyCtx, uint64_t* in, } } -void threefishDecryptBlockBytes(ThreefishKey_t* keyCtx, uint8_t* in, +void threefishDecryptBlockBytes(struct threefish_key* keyCtx, uint8_t* in, uint8_t* out) { u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ @@ -60,7 +60,7 @@ void threefishDecryptBlockBytes(ThreefishKey_t* keyCtx, uint8_t* in, Skein_Put64_LSB_First(out, plain, keyCtx->stateSize / 8); /* words to bytes */ } -void threefishDecryptBlockWords(ThreefishKey_t* keyCtx, uint64_t* in, +void threefishDecryptBlockWords(struct threefish_key* keyCtx, uint64_t* in, uint64_t* out) { switch (keyCtx->stateSize) { -- cgit v1.2.3 From b9761ccb553a07c6496cc9996ae213b6be0e6854 Mon Sep 17 00:00:00 2001 From: Jason Cooper Date: Mon, 24 Mar 2014 01:49:05 +0000 Subject: staging: crypto: skein: use u8, u64 vice uint*_t Signed-off-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/include/skeinApi.h | 8 ++++---- drivers/staging/skein/include/threefishApi.h | 22 +++++++++++----------- drivers/staging/skein/skeinApi.c | 22 +++++++++++----------- drivers/staging/skein/threefish1024Block.c | 18 +++++++++--------- drivers/staging/skein/threefish256Block.c | 18 +++++++++--------- drivers/staging/skein/threefish512Block.c | 18 +++++++++--------- drivers/staging/skein/threefishApi.c | 20 ++++++++++---------- 7 files changed, 63 insertions(+), 63 deletions(-) diff --git a/drivers/staging/skein/include/skeinApi.h b/drivers/staging/skein/include/skeinApi.h index 548c639431de..4ad294f7945d 100755 --- a/drivers/staging/skein/include/skeinApi.h +++ b/drivers/staging/skein/include/skeinApi.h @@ -173,7 +173,7 @@ OTHER DEALINGS IN THE SOFTWARE. * @return * SKEIN_SUCESS of SKEIN_FAIL */ - int skeinMacInit(struct skein_ctx* ctx, const uint8_t *key, size_t keyLen, + int skeinMacInit(struct skein_ctx* ctx, const u8 *key, size_t keyLen, size_t hashBitLen); /** @@ -188,7 +188,7 @@ OTHER DEALINGS IN THE SOFTWARE. * @return * Success or error code. */ - int skeinUpdate(struct skein_ctx *ctx, const uint8_t *msg, + int skeinUpdate(struct skein_ctx *ctx, const u8 *msg, size_t msgByteCnt); /** @@ -204,7 +204,7 @@ OTHER DEALINGS IN THE SOFTWARE. * @param msgBitCnt * Length of the message in @b bits. */ - int skeinUpdateBits(struct skein_ctx *ctx, const uint8_t *msg, + int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg, size_t msgBitCnt); /** @@ -222,7 +222,7 @@ OTHER DEALINGS IN THE SOFTWARE. * Success or error code. * @see skeinReset */ - int skeinFinal(struct skein_ctx* ctx, uint8_t* hash); + int skeinFinal(struct skein_ctx* ctx, u8* hash); /** * @} diff --git a/drivers/staging/skein/include/threefishApi.h b/drivers/staging/skein/include/threefishApi.h index 4c1cd81f30c4..194e313b6b62 100644 --- a/drivers/staging/skein/include/threefishApi.h +++ b/drivers/staging/skein/include/threefishApi.h @@ -72,7 +72,7 @@ * @param tweak * Pointer to the two tweak words (word has 64 bits). */ - void threefishSetKey(struct threefish_key* keyCtx, enum threefish_size stateSize, uint64_t* keyData, uint64_t* tweak); + void threefishSetKey(struct threefish_key* keyCtx, enum threefish_size stateSize, u64* keyData, u64* tweak); /** * Encrypt Threefisch block (bytes). @@ -89,7 +89,7 @@ * @param out * Pointer to cipher buffer. */ - void threefishEncryptBlockBytes(struct threefish_key* keyCtx, uint8_t* in, uint8_t* out); + void threefishEncryptBlockBytes(struct threefish_key* keyCtx, u8* in, u8* out); /** * Encrypt Threefisch block (words). @@ -108,7 +108,7 @@ * @param out * Pointer to cipher buffer. */ - void threefishEncryptBlockWords(struct threefish_key* keyCtx, uint64_t* in, uint64_t* out); + void threefishEncryptBlockWords(struct threefish_key* keyCtx, u64* in, u64* out); /** * Decrypt Threefisch block (bytes). @@ -125,7 +125,7 @@ * @param out * Pointer to plaintext buffer. */ - void threefishDecryptBlockBytes(struct threefish_key* keyCtx, uint8_t* in, uint8_t* out); + void threefishDecryptBlockBytes(struct threefish_key* keyCtx, u8* in, u8* out); /** * Decrypt Threefisch block (words). @@ -144,14 +144,14 @@ * @param out * Pointer to plaintext buffer. */ - void threefishDecryptBlockWords(struct threefish_key* keyCtx, uint64_t* in, uint64_t* out); + void threefishDecryptBlockWords(struct threefish_key* keyCtx, u64* in, u64* out); - void threefishEncrypt256(struct threefish_key* keyCtx, uint64_t* input, uint64_t* output); - void threefishEncrypt512(struct threefish_key* keyCtx, uint64_t* input, uint64_t* output); - void threefishEncrypt1024(struct threefish_key* keyCtx, uint64_t* input, uint64_t* output); - void threefishDecrypt256(struct threefish_key* keyCtx, uint64_t* input, uint64_t* output); - void threefishDecrypt512(struct threefish_key* keyCtx, uint64_t* input, uint64_t* output); - void threefishDecrypt1024(struct threefish_key* keyCtx, uint64_t* input, uint64_t* output); + void threefishEncrypt256(struct threefish_key* keyCtx, u64* input, u64* output); + void threefishEncrypt512(struct threefish_key* keyCtx, u64* input, u64* output); + void threefishEncrypt1024(struct threefish_key* keyCtx, u64* input, u64* output); + void threefishDecrypt256(struct threefish_key* keyCtx, u64* input, u64* output); + void threefishDecrypt512(struct threefish_key* keyCtx, u64* input, u64* output); + void threefishDecrypt1024(struct threefish_key* keyCtx, u64* input, u64* output); /** * @} */ diff --git a/drivers/staging/skein/skeinApi.c b/drivers/staging/skein/skeinApi.c index ce5c5ae575e7..6bd2da0eaa5f 100755 --- a/drivers/staging/skein/skeinApi.c +++ b/drivers/staging/skein/skeinApi.c @@ -42,7 +42,7 @@ int skeinInit(struct skein_ctx* ctx, size_t hashBitLen) int ret = SKEIN_FAIL; size_t Xlen = 0; u64* X = NULL; - uint64_t treeInfo = SKEIN_CFG_TREE_INFO_SEQUENTIAL; + u64 treeInfo = SKEIN_CFG_TREE_INFO_SEQUENTIAL; Skein_Assert(ctx, SKEIN_FAIL); /* @@ -78,13 +78,13 @@ int skeinInit(struct skein_ctx* ctx, size_t hashBitLen) return ret; } -int skeinMacInit(struct skein_ctx* ctx, const uint8_t *key, size_t keyLen, +int skeinMacInit(struct skein_ctx* ctx, const u8 *key, size_t keyLen, size_t hashBitLen) { int ret = SKEIN_FAIL; u64* X = NULL; size_t Xlen = 0; - uint64_t treeInfo = SKEIN_CFG_TREE_INFO_SEQUENTIAL; + u64 treeInfo = SKEIN_CFG_TREE_INFO_SEQUENTIAL; Skein_Assert(ctx, SKEIN_FAIL); @@ -138,7 +138,7 @@ void skeinReset(struct skein_ctx* ctx) Skein_Start_New_Type(&ctx->m, MSG); } -int skeinUpdate(struct skein_ctx *ctx, const uint8_t *msg, +int skeinUpdate(struct skein_ctx *ctx, const u8 *msg, size_t msgByteCnt) { int ret = SKEIN_FAIL; @@ -159,7 +159,7 @@ int skeinUpdate(struct skein_ctx *ctx, const uint8_t *msg, } -int skeinUpdateBits(struct skein_ctx *ctx, const uint8_t *msg, +int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg, size_t msgBitCnt) { /* @@ -168,8 +168,8 @@ int skeinUpdateBits(struct skein_ctx *ctx, const uint8_t *msg, * arithmetic. */ size_t length; - uint8_t mask; - uint8_t* up; + u8 mask; + u8* up; /* only the final Update() call is allowed do partial bytes, else assert an error */ Skein_Assert((ctx->m.h.T[1] & SKEIN_T1_FLAG_BIT_PAD) == 0 || msgBitCnt == 0, SKEIN_FAIL); @@ -186,20 +186,20 @@ int skeinUpdateBits(struct skein_ctx *ctx, const uint8_t *msg, * Skein's real partial block buffer. * If this layout ever changes we have to adapt this as well. */ - up = (uint8_t*)ctx->m.s256.X + ctx->skeinSize / 8; + up = (u8*)ctx->m.s256.X + ctx->skeinSize / 8; Skein_Set_Bit_Pad_Flag(ctx->m.h); /* set tweak flag for the skeinFinal call */ /* now "pad" the final partial byte the way NIST likes */ length = ctx->m.h.bCnt; /* get the bCnt value (same location for all block sizes) */ Skein_assert(length != 0); /* internal sanity check: there IS a partial byte in the buffer! */ - mask = (uint8_t) (1u << (7 - (msgBitCnt & 7))); /* partial byte bit mask */ - up[length-1] = (uint8_t)((up[length-1] & (0-mask))|mask); /* apply bit padding on final byte (in the buffer) */ + mask = (u8) (1u << (7 - (msgBitCnt & 7))); /* partial byte bit mask */ + up[length-1] = (u8)((up[length-1] & (0-mask))|mask); /* apply bit padding on final byte (in the buffer) */ return SKEIN_SUCCESS; } -int skeinFinal(struct skein_ctx* ctx, uint8_t* hash) +int skeinFinal(struct skein_ctx* ctx, u8* hash) { int ret = SKEIN_FAIL; Skein_Assert(ctx, SKEIN_FAIL); diff --git a/drivers/staging/skein/threefish1024Block.c b/drivers/staging/skein/threefish1024Block.c index 738ec523406b..9e821fcdb067 100644 --- a/drivers/staging/skein/threefish1024Block.c +++ b/drivers/staging/skein/threefish1024Block.c @@ -2,10 +2,10 @@ #include -void threefishEncrypt1024(struct threefish_key* keyCtx, uint64_t* input, uint64_t* output) +void threefishEncrypt1024(struct threefish_key* keyCtx, u64* input, u64* output) { - uint64_t b0 = input[0], b1 = input[1], + u64 b0 = input[0], b1 = input[1], b2 = input[2], b3 = input[3], b4 = input[4], b5 = input[5], b6 = input[6], b7 = input[7], @@ -13,7 +13,7 @@ void threefishEncrypt1024(struct threefish_key* keyCtx, uint64_t* input, uint64_ b10 = input[10], b11 = input[11], b12 = input[12], b13 = input[13], b14 = input[14], b15 = input[15]; - uint64_t k0 = keyCtx->key[0], k1 = keyCtx->key[1], + u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1], k2 = keyCtx->key[2], k3 = keyCtx->key[3], k4 = keyCtx->key[4], k5 = keyCtx->key[5], k6 = keyCtx->key[6], k7 = keyCtx->key[7], @@ -22,7 +22,7 @@ void threefishEncrypt1024(struct threefish_key* keyCtx, uint64_t* input, uint64_ k12 = keyCtx->key[12], k13 = keyCtx->key[13], k14 = keyCtx->key[14], k15 = keyCtx->key[15], k16 = keyCtx->key[16]; - uint64_t t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], + u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], t2 = keyCtx->tweak[2]; b1 += k1; b0 += b1 + k0; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; @@ -684,10 +684,10 @@ void threefishEncrypt1024(struct threefish_key* keyCtx, uint64_t* input, uint64_ output[15] = b15 + k1 + 20; } -void threefishDecrypt1024(struct threefish_key* keyCtx, uint64_t* input, uint64_t* output) +void threefishDecrypt1024(struct threefish_key* keyCtx, u64* input, u64* output) { - uint64_t b0 = input[0], b1 = input[1], + u64 b0 = input[0], b1 = input[1], b2 = input[2], b3 = input[3], b4 = input[4], b5 = input[5], b6 = input[6], b7 = input[7], @@ -695,7 +695,7 @@ void threefishDecrypt1024(struct threefish_key* keyCtx, uint64_t* input, uint64_ b10 = input[10], b11 = input[11], b12 = input[12], b13 = input[13], b14 = input[14], b15 = input[15]; - uint64_t k0 = keyCtx->key[0], k1 = keyCtx->key[1], + u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1], k2 = keyCtx->key[2], k3 = keyCtx->key[3], k4 = keyCtx->key[4], k5 = keyCtx->key[5], k6 = keyCtx->key[6], k7 = keyCtx->key[7], @@ -704,9 +704,9 @@ void threefishDecrypt1024(struct threefish_key* keyCtx, uint64_t* input, uint64_ k12 = keyCtx->key[12], k13 = keyCtx->key[13], k14 = keyCtx->key[14], k15 = keyCtx->key[15], k16 = keyCtx->key[16]; - uint64_t t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], + u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], t2 = keyCtx->tweak[2]; - uint64_t tmp; + u64 tmp; b0 -= k3; b1 -= k4; diff --git a/drivers/staging/skein/threefish256Block.c b/drivers/staging/skein/threefish256Block.c index b81cb3a65b04..68ac4c50f01e 100644 --- a/drivers/staging/skein/threefish256Block.c +++ b/drivers/staging/skein/threefish256Block.c @@ -2,15 +2,15 @@ #include -void threefishEncrypt256(struct threefish_key* keyCtx, uint64_t* input, uint64_t* output) +void threefishEncrypt256(struct threefish_key* keyCtx, u64* input, u64* output) { - uint64_t b0 = input[0], b1 = input[1], + u64 b0 = input[0], b1 = input[1], b2 = input[2], b3 = input[3]; - uint64_t k0 = keyCtx->key[0], k1 = keyCtx->key[1], + u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1], k2 = keyCtx->key[2], k3 = keyCtx->key[3], k4 = keyCtx->key[4]; - uint64_t t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], + u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], t2 = keyCtx->tweak[2]; b1 += k1 + t0; b0 += b1 + k0; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; @@ -172,17 +172,17 @@ void threefishEncrypt256(struct threefish_key* keyCtx, uint64_t* input, uint64_t output[3] = b3 + k1 + 18; } -void threefishDecrypt256(struct threefish_key* keyCtx, uint64_t* input, uint64_t* output) +void threefishDecrypt256(struct threefish_key* keyCtx, u64* input, u64* output) { - uint64_t b0 = input[0], b1 = input[1], + u64 b0 = input[0], b1 = input[1], b2 = input[2], b3 = input[3]; - uint64_t k0 = keyCtx->key[0], k1 = keyCtx->key[1], + u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1], k2 = keyCtx->key[2], k3 = keyCtx->key[3], k4 = keyCtx->key[4]; - uint64_t t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], + u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], t2 = keyCtx->tweak[2]; - uint64_t tmp; + u64 tmp; b0 -= k3; b1 -= k4 + t0; diff --git a/drivers/staging/skein/threefish512Block.c b/drivers/staging/skein/threefish512Block.c index 7eed6aeb3742..e94bb93722df 100644 --- a/drivers/staging/skein/threefish512Block.c +++ b/drivers/staging/skein/threefish512Block.c @@ -2,19 +2,19 @@ #include -void threefishEncrypt512(struct threefish_key* keyCtx, uint64_t* input, uint64_t* output) +void threefishEncrypt512(struct threefish_key* keyCtx, u64* input, u64* output) { - uint64_t b0 = input[0], b1 = input[1], + u64 b0 = input[0], b1 = input[1], b2 = input[2], b3 = input[3], b4 = input[4], b5 = input[5], b6 = input[6], b7 = input[7]; - uint64_t k0 = keyCtx->key[0], k1 = keyCtx->key[1], + u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1], k2 = keyCtx->key[2], k3 = keyCtx->key[3], k4 = keyCtx->key[4], k5 = keyCtx->key[5], k6 = keyCtx->key[6], k7 = keyCtx->key[7], k8 = keyCtx->key[8]; - uint64_t t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], + u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], t2 = keyCtx->tweak[2]; b1 += k1; b0 += b1 + k0; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; @@ -316,22 +316,22 @@ void threefishEncrypt512(struct threefish_key* keyCtx, uint64_t* input, uint64_t output[7] = b7 + k7 + 18; } -void threefishDecrypt512(struct threefish_key* keyCtx, uint64_t* input, uint64_t* output) +void threefishDecrypt512(struct threefish_key* keyCtx, u64* input, u64* output) { - uint64_t b0 = input[0], b1 = input[1], + u64 b0 = input[0], b1 = input[1], b2 = input[2], b3 = input[3], b4 = input[4], b5 = input[5], b6 = input[6], b7 = input[7]; - uint64_t k0 = keyCtx->key[0], k1 = keyCtx->key[1], + u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1], k2 = keyCtx->key[2], k3 = keyCtx->key[3], k4 = keyCtx->key[4], k5 = keyCtx->key[5], k6 = keyCtx->key[6], k7 = keyCtx->key[7], k8 = keyCtx->key[8]; - uint64_t t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], + u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], t2 = keyCtx->tweak[2]; - uint64_t tmp; + u64 tmp; b0 -= k0; b1 -= k1; diff --git a/drivers/staging/skein/threefishApi.c b/drivers/staging/skein/threefishApi.c index 5cd3eb9bd9f2..37f96215159d 100644 --- a/drivers/staging/skein/threefishApi.c +++ b/drivers/staging/skein/threefishApi.c @@ -4,11 +4,11 @@ #include void threefishSetKey(struct threefish_key* keyCtx, enum threefish_size stateSize, - uint64_t* keyData, uint64_t* tweak) + u64* keyData, u64* tweak) { int keyWords = stateSize / 64; int i; - uint64_t parity = KeyScheduleConst; + u64 parity = KeyScheduleConst; keyCtx->tweak[0] = tweak[0]; keyCtx->tweak[1] = tweak[1]; @@ -22,8 +22,8 @@ void threefishSetKey(struct threefish_key* keyCtx, enum threefish_size stateSize keyCtx->stateSize = stateSize; } -void threefishEncryptBlockBytes(struct threefish_key* keyCtx, uint8_t* in, - uint8_t* out) +void threefishEncryptBlockBytes(struct threefish_key* keyCtx, u8* in, + u8* out) { u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ u64 cipher[SKEIN_MAX_STATE_WORDS]; @@ -33,8 +33,8 @@ void threefishEncryptBlockBytes(struct threefish_key* keyCtx, uint8_t* in, Skein_Put64_LSB_First(out, cipher, keyCtx->stateSize / 8); /* words to bytes */ } -void threefishEncryptBlockWords(struct threefish_key* keyCtx, uint64_t* in, - uint64_t* out) +void threefishEncryptBlockWords(struct threefish_key* keyCtx, u64* in, + u64* out) { switch (keyCtx->stateSize) { case Threefish256: @@ -49,8 +49,8 @@ void threefishEncryptBlockWords(struct threefish_key* keyCtx, uint64_t* in, } } -void threefishDecryptBlockBytes(struct threefish_key* keyCtx, uint8_t* in, - uint8_t* out) +void threefishDecryptBlockBytes(struct threefish_key* keyCtx, u8* in, + u8* out) { u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ u64 cipher[SKEIN_MAX_STATE_WORDS]; @@ -60,8 +60,8 @@ void threefishDecryptBlockBytes(struct threefish_key* keyCtx, uint8_t* in, Skein_Put64_LSB_First(out, plain, keyCtx->stateSize / 8); /* words to bytes */ } -void threefishDecryptBlockWords(struct threefish_key* keyCtx, uint64_t* in, - uint64_t* out) +void threefishDecryptBlockWords(struct threefish_key* keyCtx, u64* in, + u64* out) { switch (keyCtx->stateSize) { case Threefish256: -- cgit v1.2.3 From cd4811a64cbb719e739ebf09ffb1bedc2d77cf76 Mon Sep 17 00:00:00 2001 From: Jason Cooper Date: Mon, 24 Mar 2014 01:49:06 +0000 Subject: staging: crypto: skein: fixup pointer whitespace Signed-off-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/include/skein.h | 18 +++++++++--------- drivers/staging/skein/include/skeinApi.h | 10 +++++----- drivers/staging/skein/include/threefishApi.h | 22 +++++++++++----------- drivers/staging/skein/skeinApi.c | 18 +++++++++--------- drivers/staging/skein/threefish1024Block.c | 4 ++-- drivers/staging/skein/threefish256Block.c | 4 ++-- drivers/staging/skein/threefish512Block.c | 4 ++-- drivers/staging/skein/threefishApi.c | 20 ++++++++++---------- 8 files changed, 50 insertions(+), 50 deletions(-) diff --git a/drivers/staging/skein/include/skein.h b/drivers/staging/skein/include/skein.h index 635b6956a2bd..2947fd5bcc15 100644 --- a/drivers/staging/skein/include/skein.h +++ b/drivers/staging/skein/include/skein.h @@ -100,9 +100,9 @@ int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg, size_t msgByteCn int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg, size_t msgByteCnt); int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg, size_t msgByteCnt); -int Skein_256_Final (struct skein_256_ctx *ctx, u8 * hashVal); -int Skein_512_Final (struct skein_512_ctx *ctx, u8 * hashVal); -int Skein1024_Final (struct skein1024_ctx *ctx, u8 * hashVal); +int Skein_256_Final (struct skein_256_ctx *ctx, u8 *hashVal); +int Skein_512_Final (struct skein_512_ctx *ctx, u8 *hashVal); +int Skein1024_Final (struct skein1024_ctx *ctx, u8 *hashVal); /* ** Skein APIs for "extended" initialization: MAC keys, tree hashing. @@ -127,17 +127,17 @@ int Skein1024_InitExt(struct skein1024_ctx *ctx, size_t hashBitLen, u64 treeInf ** Final_Pad: pad, do final block, but no OUTPUT type ** Output: do just the output stage */ -int Skein_256_Final_Pad(struct skein_256_ctx *ctx, u8 * hashVal); -int Skein_512_Final_Pad(struct skein_512_ctx *ctx, u8 * hashVal); -int Skein1024_Final_Pad(struct skein1024_ctx *ctx, u8 * hashVal); +int Skein_256_Final_Pad(struct skein_256_ctx *ctx, u8 *hashVal); +int Skein_512_Final_Pad(struct skein_512_ctx *ctx, u8 *hashVal); +int Skein1024_Final_Pad(struct skein1024_ctx *ctx, u8 *hashVal); #ifndef SKEIN_TREE_HASH #define SKEIN_TREE_HASH (1) #endif #if SKEIN_TREE_HASH -int Skein_256_Output (struct skein_256_ctx *ctx, u8 * hashVal); -int Skein_512_Output (struct skein_512_ctx *ctx, u8 * hashVal); -int Skein1024_Output (struct skein1024_ctx *ctx, u8 * hashVal); +int Skein_256_Output (struct skein_256_ctx *ctx, u8 *hashVal); +int Skein_512_Output (struct skein_512_ctx *ctx, u8 *hashVal); +int Skein1024_Output (struct skein1024_ctx *ctx, u8 *hashVal); #endif /***************************************************************** diff --git a/drivers/staging/skein/include/skeinApi.h b/drivers/staging/skein/include/skeinApi.h index 4ad294f7945d..2c52797918cf 100755 --- a/drivers/staging/skein/include/skeinApi.h +++ b/drivers/staging/skein/include/skeinApi.h @@ -123,7 +123,7 @@ OTHER DEALINGS IN THE SOFTWARE. * @return * SKEIN_SUCESS of SKEIN_FAIL */ - int skeinCtxPrepare(struct skein_ctx* ctx, enum skein_size size); + int skeinCtxPrepare(struct skein_ctx *ctx, enum skein_size size); /** * Initialize a Skein context. @@ -139,7 +139,7 @@ OTHER DEALINGS IN THE SOFTWARE. * SKEIN_SUCESS of SKEIN_FAIL * @see skeinReset */ - int skeinInit(struct skein_ctx* ctx, size_t hashBitLen); + int skeinInit(struct skein_ctx *ctx, size_t hashBitLen); /** * Resets a Skein context for further use. @@ -151,7 +151,7 @@ OTHER DEALINGS IN THE SOFTWARE. * @param ctx * Pointer to a pre-initialized Skein MAC context */ - void skeinReset(struct skein_ctx* ctx); + void skeinReset(struct skein_ctx *ctx); /** * Initializes a Skein context for MAC usage. @@ -173,7 +173,7 @@ OTHER DEALINGS IN THE SOFTWARE. * @return * SKEIN_SUCESS of SKEIN_FAIL */ - int skeinMacInit(struct skein_ctx* ctx, const u8 *key, size_t keyLen, + int skeinMacInit(struct skein_ctx *ctx, const u8 *key, size_t keyLen, size_t hashBitLen); /** @@ -222,7 +222,7 @@ OTHER DEALINGS IN THE SOFTWARE. * Success or error code. * @see skeinReset */ - int skeinFinal(struct skein_ctx* ctx, u8* hash); + int skeinFinal(struct skein_ctx *ctx, u8 *hash); /** * @} diff --git a/drivers/staging/skein/include/threefishApi.h b/drivers/staging/skein/include/threefishApi.h index 194e313b6b62..1f9e6e14f50b 100644 --- a/drivers/staging/skein/include/threefishApi.h +++ b/drivers/staging/skein/include/threefishApi.h @@ -72,7 +72,7 @@ * @param tweak * Pointer to the two tweak words (word has 64 bits). */ - void threefishSetKey(struct threefish_key* keyCtx, enum threefish_size stateSize, u64* keyData, u64* tweak); + void threefishSetKey(struct threefish_key *keyCtx, enum threefish_size stateSize, u64 *keyData, u64 *tweak); /** * Encrypt Threefisch block (bytes). @@ -89,7 +89,7 @@ * @param out * Pointer to cipher buffer. */ - void threefishEncryptBlockBytes(struct threefish_key* keyCtx, u8* in, u8* out); + void threefishEncryptBlockBytes(struct threefish_key *keyCtx, u8 *in, u8 *out); /** * Encrypt Threefisch block (words). @@ -108,7 +108,7 @@ * @param out * Pointer to cipher buffer. */ - void threefishEncryptBlockWords(struct threefish_key* keyCtx, u64* in, u64* out); + void threefishEncryptBlockWords(struct threefish_key *keyCtx, u64 *in, u64 *out); /** * Decrypt Threefisch block (bytes). @@ -125,7 +125,7 @@ * @param out * Pointer to plaintext buffer. */ - void threefishDecryptBlockBytes(struct threefish_key* keyCtx, u8* in, u8* out); + void threefishDecryptBlockBytes(struct threefish_key *keyCtx, u8 *in, u8 *out); /** * Decrypt Threefisch block (words). @@ -144,14 +144,14 @@ * @param out * Pointer to plaintext buffer. */ - void threefishDecryptBlockWords(struct threefish_key* keyCtx, u64* in, u64* out); + void threefishDecryptBlockWords(struct threefish_key *keyCtx, u64 *in, u64 *out); - void threefishEncrypt256(struct threefish_key* keyCtx, u64* input, u64* output); - void threefishEncrypt512(struct threefish_key* keyCtx, u64* input, u64* output); - void threefishEncrypt1024(struct threefish_key* keyCtx, u64* input, u64* output); - void threefishDecrypt256(struct threefish_key* keyCtx, u64* input, u64* output); - void threefishDecrypt512(struct threefish_key* keyCtx, u64* input, u64* output); - void threefishDecrypt1024(struct threefish_key* keyCtx, u64* input, u64* output); + void threefishEncrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output); + void threefishEncrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output); + void threefishEncrypt1024(struct threefish_key *keyCtx, u64 *input, u64 *output); + void threefishDecrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output); + void threefishDecrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output); + void threefishDecrypt1024(struct threefish_key *keyCtx, u64 *input, u64 *output); /** * @} */ diff --git a/drivers/staging/skein/skeinApi.c b/drivers/staging/skein/skeinApi.c index 6bd2da0eaa5f..df92806c4ec4 100755 --- a/drivers/staging/skein/skeinApi.c +++ b/drivers/staging/skein/skeinApi.c @@ -27,7 +27,7 @@ OTHER DEALINGS IN THE SOFTWARE. #include #include -int skeinCtxPrepare(struct skein_ctx* ctx, enum skein_size size) +int skeinCtxPrepare(struct skein_ctx *ctx, enum skein_size size) { Skein_Assert(ctx && size, SKEIN_FAIL); @@ -37,11 +37,11 @@ int skeinCtxPrepare(struct skein_ctx* ctx, enum skein_size size) return SKEIN_SUCCESS; } -int skeinInit(struct skein_ctx* ctx, size_t hashBitLen) +int skeinInit(struct skein_ctx *ctx, size_t hashBitLen) { int ret = SKEIN_FAIL; size_t Xlen = 0; - u64* X = NULL; + u64 *X = NULL; u64 treeInfo = SKEIN_CFG_TREE_INFO_SEQUENTIAL; Skein_Assert(ctx, SKEIN_FAIL); @@ -78,11 +78,11 @@ int skeinInit(struct skein_ctx* ctx, size_t hashBitLen) return ret; } -int skeinMacInit(struct skein_ctx* ctx, const u8 *key, size_t keyLen, +int skeinMacInit(struct skein_ctx *ctx, const u8 *key, size_t keyLen, size_t hashBitLen) { int ret = SKEIN_FAIL; - u64* X = NULL; + u64 *X = NULL; size_t Xlen = 0; u64 treeInfo = SKEIN_CFG_TREE_INFO_SEQUENTIAL; @@ -119,10 +119,10 @@ int skeinMacInit(struct skein_ctx* ctx, const u8 *key, size_t keyLen, return ret; } -void skeinReset(struct skein_ctx* ctx) +void skeinReset(struct skein_ctx *ctx) { size_t Xlen = 0; - u64* X = NULL; + u64 *X = NULL; /* * The following two lines rely of the fact that the real Skein contexts are @@ -169,7 +169,7 @@ int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg, */ size_t length; u8 mask; - u8* up; + u8 *up; /* only the final Update() call is allowed do partial bytes, else assert an error */ Skein_Assert((ctx->m.h.T[1] & SKEIN_T1_FLAG_BIT_PAD) == 0 || msgBitCnt == 0, SKEIN_FAIL); @@ -199,7 +199,7 @@ int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg, return SKEIN_SUCCESS; } -int skeinFinal(struct skein_ctx* ctx, u8* hash) +int skeinFinal(struct skein_ctx *ctx, u8 *hash) { int ret = SKEIN_FAIL; Skein_Assert(ctx, SKEIN_FAIL); diff --git a/drivers/staging/skein/threefish1024Block.c b/drivers/staging/skein/threefish1024Block.c index 9e821fcdb067..e3be37ea8024 100644 --- a/drivers/staging/skein/threefish1024Block.c +++ b/drivers/staging/skein/threefish1024Block.c @@ -2,7 +2,7 @@ #include -void threefishEncrypt1024(struct threefish_key* keyCtx, u64* input, u64* output) +void threefishEncrypt1024(struct threefish_key *keyCtx, u64 *input, u64 *output) { u64 b0 = input[0], b1 = input[1], @@ -684,7 +684,7 @@ void threefishEncrypt1024(struct threefish_key* keyCtx, u64* input, u64* output) output[15] = b15 + k1 + 20; } -void threefishDecrypt1024(struct threefish_key* keyCtx, u64* input, u64* output) +void threefishDecrypt1024(struct threefish_key *keyCtx, u64 *input, u64 *output) { u64 b0 = input[0], b1 = input[1], diff --git a/drivers/staging/skein/threefish256Block.c b/drivers/staging/skein/threefish256Block.c index 68ac4c50f01e..09ea5099bc76 100644 --- a/drivers/staging/skein/threefish256Block.c +++ b/drivers/staging/skein/threefish256Block.c @@ -2,7 +2,7 @@ #include -void threefishEncrypt256(struct threefish_key* keyCtx, u64* input, u64* output) +void threefishEncrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output) { u64 b0 = input[0], b1 = input[1], @@ -172,7 +172,7 @@ void threefishEncrypt256(struct threefish_key* keyCtx, u64* input, u64* output) output[3] = b3 + k1 + 18; } -void threefishDecrypt256(struct threefish_key* keyCtx, u64* input, u64* output) +void threefishDecrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output) { u64 b0 = input[0], b1 = input[1], b2 = input[2], b3 = input[3]; diff --git a/drivers/staging/skein/threefish512Block.c b/drivers/staging/skein/threefish512Block.c index e94bb93722df..5262f5a8f21b 100644 --- a/drivers/staging/skein/threefish512Block.c +++ b/drivers/staging/skein/threefish512Block.c @@ -2,7 +2,7 @@ #include -void threefishEncrypt512(struct threefish_key* keyCtx, u64* input, u64* output) +void threefishEncrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output) { u64 b0 = input[0], b1 = input[1], @@ -316,7 +316,7 @@ void threefishEncrypt512(struct threefish_key* keyCtx, u64* input, u64* output) output[7] = b7 + k7 + 18; } -void threefishDecrypt512(struct threefish_key* keyCtx, u64* input, u64* output) +void threefishDecrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output) { u64 b0 = input[0], b1 = input[1], diff --git a/drivers/staging/skein/threefishApi.c b/drivers/staging/skein/threefishApi.c index 37f96215159d..53f46f6cb9ca 100644 --- a/drivers/staging/skein/threefishApi.c +++ b/drivers/staging/skein/threefishApi.c @@ -3,8 +3,8 @@ #include #include -void threefishSetKey(struct threefish_key* keyCtx, enum threefish_size stateSize, - u64* keyData, u64* tweak) +void threefishSetKey(struct threefish_key *keyCtx, enum threefish_size stateSize, + u64 *keyData, u64 *tweak) { int keyWords = stateSize / 64; int i; @@ -22,8 +22,8 @@ void threefishSetKey(struct threefish_key* keyCtx, enum threefish_size stateSize keyCtx->stateSize = stateSize; } -void threefishEncryptBlockBytes(struct threefish_key* keyCtx, u8* in, - u8* out) +void threefishEncryptBlockBytes(struct threefish_key *keyCtx, u8 *in, + u8 *out) { u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ u64 cipher[SKEIN_MAX_STATE_WORDS]; @@ -33,8 +33,8 @@ void threefishEncryptBlockBytes(struct threefish_key* keyCtx, u8* in, Skein_Put64_LSB_First(out, cipher, keyCtx->stateSize / 8); /* words to bytes */ } -void threefishEncryptBlockWords(struct threefish_key* keyCtx, u64* in, - u64* out) +void threefishEncryptBlockWords(struct threefish_key *keyCtx, u64 *in, + u64 *out) { switch (keyCtx->stateSize) { case Threefish256: @@ -49,8 +49,8 @@ void threefishEncryptBlockWords(struct threefish_key* keyCtx, u64* in, } } -void threefishDecryptBlockBytes(struct threefish_key* keyCtx, u8* in, - u8* out) +void threefishDecryptBlockBytes(struct threefish_key *keyCtx, u8 *in, + u8 *out) { u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ u64 cipher[SKEIN_MAX_STATE_WORDS]; @@ -60,8 +60,8 @@ void threefishDecryptBlockBytes(struct threefish_key* keyCtx, u8* in, Skein_Put64_LSB_First(out, plain, keyCtx->stateSize / 8); /* words to bytes */ } -void threefishDecryptBlockWords(struct threefish_key* keyCtx, u64* in, - u64* out) +void threefishDecryptBlockWords(struct threefish_key *keyCtx, u64 *in, + u64 *out) { switch (keyCtx->stateSize) { case Threefish256: -- cgit v1.2.3 From a0d5dd84323522a3777b8269c2d17136b4587db4 Mon Sep 17 00:00:00 2001 From: Jason Cooper Date: Mon, 24 Mar 2014 01:49:07 +0000 Subject: staging: crypto: skein: cleanup whitespace around operators/punc. Signed-off-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/include/skein.h | 168 +++++----- drivers/staging/skein/include/skein_iv.h | 224 +++++++------- drivers/staging/skein/skein.c | 352 ++++++++++----------- drivers/staging/skein/skeinApi.c | 22 +- drivers/staging/skein/skeinBlockNo3F.c | 20 +- drivers/staging/skein/skein_block.c | 513 +++++++++++++++---------------- 6 files changed, 648 insertions(+), 651 deletions(-) diff --git a/drivers/staging/skein/include/skein.h b/drivers/staging/skein/include/skein.h index 2947fd5bcc15..18bb15824e41 100644 --- a/drivers/staging/skein/include/skein.h +++ b/drivers/staging/skein/include/skein.h @@ -29,12 +29,12 @@ ***************************************************************************/ #ifndef RotL_64 -#define RotL_64(x,N) (((x) << (N)) | ((x) >> (64-(N)))) +#define RotL_64(x, N) (((x) << (N)) | ((x) >> (64-(N)))) #endif /* below two prototype assume we are handed aligned data */ -#define Skein_Put64_LSB_First(dst08,src64,bCnt) memcpy(dst08,src64,bCnt) -#define Skein_Get64_LSB_First(dst64,src08,wCnt) memcpy(dst64,src08,8*(wCnt)) +#define Skein_Put64_LSB_First(dst08, src64, bCnt) memcpy(dst08, src64, bCnt) +#define Skein_Get64_LSB_First(dst64, src08, wCnt) memcpy(dst64, src08, 8*(wCnt)) #define Skein_Swap64(w64) (w64) enum @@ -44,24 +44,24 @@ enum SKEIN_BAD_HASHLEN = 2 }; -#define SKEIN_MODIFIER_WORDS ( 2) /* number of modifier (tweak) words */ +#define SKEIN_MODIFIER_WORDS (2) /* number of modifier (tweak) words */ -#define SKEIN_256_STATE_WORDS ( 4) -#define SKEIN_512_STATE_WORDS ( 8) +#define SKEIN_256_STATE_WORDS (4) +#define SKEIN_512_STATE_WORDS (8) #define SKEIN1024_STATE_WORDS (16) #define SKEIN_MAX_STATE_WORDS (16) -#define SKEIN_256_STATE_BYTES ( 8*SKEIN_256_STATE_WORDS) -#define SKEIN_512_STATE_BYTES ( 8*SKEIN_512_STATE_WORDS) -#define SKEIN1024_STATE_BYTES ( 8*SKEIN1024_STATE_WORDS) +#define SKEIN_256_STATE_BYTES (8*SKEIN_256_STATE_WORDS) +#define SKEIN_512_STATE_BYTES (8*SKEIN_512_STATE_WORDS) +#define SKEIN1024_STATE_BYTES (8*SKEIN1024_STATE_WORDS) #define SKEIN_256_STATE_BITS (64*SKEIN_256_STATE_WORDS) #define SKEIN_512_STATE_BITS (64*SKEIN_512_STATE_WORDS) #define SKEIN1024_STATE_BITS (64*SKEIN1024_STATE_WORDS) -#define SKEIN_256_BLOCK_BYTES ( 8*SKEIN_256_STATE_WORDS) -#define SKEIN_512_BLOCK_BYTES ( 8*SKEIN_512_STATE_WORDS) -#define SKEIN1024_BLOCK_BYTES ( 8*SKEIN1024_STATE_WORDS) +#define SKEIN_256_BLOCK_BYTES (8*SKEIN_256_STATE_WORDS) +#define SKEIN_512_BLOCK_BYTES (8*SKEIN_512_STATE_WORDS) +#define SKEIN1024_BLOCK_BYTES (8*SKEIN1024_STATE_WORDS) struct skein_ctx_hdr { @@ -92,17 +92,17 @@ struct skein1024_ctx /* 1024-bit Skein hash context }; /* Skein APIs for (incremental) "straight hashing" */ -int Skein_256_Init (struct skein_256_ctx *ctx, size_t hashBitLen); -int Skein_512_Init (struct skein_512_ctx *ctx, size_t hashBitLen); -int Skein1024_Init (struct skein1024_ctx *ctx, size_t hashBitLen); +int Skein_256_Init(struct skein_256_ctx *ctx, size_t hashBitLen); +int Skein_512_Init(struct skein_512_ctx *ctx, size_t hashBitLen); +int Skein1024_Init(struct skein1024_ctx *ctx, size_t hashBitLen); int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg, size_t msgByteCnt); int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg, size_t msgByteCnt); int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg, size_t msgByteCnt); -int Skein_256_Final (struct skein_256_ctx *ctx, u8 *hashVal); -int Skein_512_Final (struct skein_512_ctx *ctx, u8 *hashVal); -int Skein1024_Final (struct skein1024_ctx *ctx, u8 *hashVal); +int Skein_256_Final(struct skein_256_ctx *ctx, u8 *hashVal); +int Skein_512_Final(struct skein_512_ctx *ctx, u8 *hashVal); +int Skein1024_Final(struct skein1024_ctx *ctx, u8 *hashVal); /* ** Skein APIs for "extended" initialization: MAC keys, tree hashing. @@ -135,9 +135,9 @@ int Skein1024_Final_Pad(struct skein1024_ctx *ctx, u8 *hashVal); #define SKEIN_TREE_HASH (1) #endif #if SKEIN_TREE_HASH -int Skein_256_Output (struct skein_256_ctx *ctx, u8 *hashVal); -int Skein_512_Output (struct skein_512_ctx *ctx, u8 *hashVal); -int Skein1024_Output (struct skein1024_ctx *ctx, u8 *hashVal); +int Skein_256_Output(struct skein_256_ctx *ctx, u8 *hashVal); +int Skein_512_Output(struct skein_512_ctx *ctx, u8 *hashVal); +int Skein1024_Output(struct skein1024_ctx *ctx, u8 *hashVal); #endif /***************************************************************** @@ -158,18 +158,18 @@ int Skein1024_Output (struct skein1024_ctx *ctx, u8 *hashVal); #define SKEIN_T1_POS_FINAL SKEIN_T1_BIT(127) /* bit 127 : final block flag */ /* tweak word T[1]: flag bit definition(s) */ -#define SKEIN_T1_FLAG_FIRST (((u64) 1 ) << SKEIN_T1_POS_FIRST) -#define SKEIN_T1_FLAG_FINAL (((u64) 1 ) << SKEIN_T1_POS_FINAL) -#define SKEIN_T1_FLAG_BIT_PAD (((u64) 1 ) << SKEIN_T1_POS_BIT_PAD) +#define SKEIN_T1_FLAG_FIRST (((u64) 1) << SKEIN_T1_POS_FIRST) +#define SKEIN_T1_FLAG_FINAL (((u64) 1) << SKEIN_T1_POS_FINAL) +#define SKEIN_T1_FLAG_BIT_PAD (((u64) 1) << SKEIN_T1_POS_BIT_PAD) /* tweak word T[1]: tree level bit field mask */ #define SKEIN_T1_TREE_LVL_MASK (((u64)0x7F) << SKEIN_T1_POS_TREE_LVL) #define SKEIN_T1_TREE_LEVEL(n) (((u64) (n)) << SKEIN_T1_POS_TREE_LVL) /* tweak word T[1]: block type field */ -#define SKEIN_BLK_TYPE_KEY ( 0) /* key, for MAC and KDF */ -#define SKEIN_BLK_TYPE_CFG ( 4) /* configuration block */ -#define SKEIN_BLK_TYPE_PERS ( 8) /* personalization string */ +#define SKEIN_BLK_TYPE_KEY (0) /* key, for MAC and KDF */ +#define SKEIN_BLK_TYPE_CFG (4) /* configuration block */ +#define SKEIN_BLK_TYPE_PERS (8) /* personalization string */ #define SKEIN_BLK_TYPE_PK (12) /* public key (for digital signature hashing) */ #define SKEIN_BLK_TYPE_KDF (16) /* key identifier for KDF */ #define SKEIN_BLK_TYPE_NONCE (20) /* nonce for PRNG */ @@ -197,73 +197,73 @@ int Skein1024_Output (struct skein1024_ctx *ctx, u8 *hashVal); #define SKEIN_ID_STRING_LE (0x33414853) /* "SHA3" (little-endian)*/ #endif -#define SKEIN_MK_64(hi32,lo32) ((lo32) + (((u64) (hi32)) << 32)) -#define SKEIN_SCHEMA_VER SKEIN_MK_64(SKEIN_VERSION,SKEIN_ID_STRING_LE) -#define SKEIN_KS_PARITY SKEIN_MK_64(0x1BD11BDA,0xA9FC1A22) +#define SKEIN_MK_64(hi32, lo32) ((lo32) + (((u64) (hi32)) << 32)) +#define SKEIN_SCHEMA_VER SKEIN_MK_64(SKEIN_VERSION, SKEIN_ID_STRING_LE) +#define SKEIN_KS_PARITY SKEIN_MK_64(0x1BD11BDA, 0xA9FC1A22) #define SKEIN_CFG_STR_LEN (4*8) /* bit field definitions in config block treeInfo word */ -#define SKEIN_CFG_TREE_LEAF_SIZE_POS ( 0) -#define SKEIN_CFG_TREE_NODE_SIZE_POS ( 8) +#define SKEIN_CFG_TREE_LEAF_SIZE_POS (0) +#define SKEIN_CFG_TREE_NODE_SIZE_POS (8) #define SKEIN_CFG_TREE_MAX_LEVEL_POS (16) #define SKEIN_CFG_TREE_LEAF_SIZE_MSK (((u64) 0xFF) << SKEIN_CFG_TREE_LEAF_SIZE_POS) #define SKEIN_CFG_TREE_NODE_SIZE_MSK (((u64) 0xFF) << SKEIN_CFG_TREE_NODE_SIZE_POS) #define SKEIN_CFG_TREE_MAX_LEVEL_MSK (((u64) 0xFF) << SKEIN_CFG_TREE_MAX_LEVEL_POS) -#define SKEIN_CFG_TREE_INFO(leaf,node,maxLvl) \ - ( (((u64)(leaf )) << SKEIN_CFG_TREE_LEAF_SIZE_POS) | \ - (((u64)(node )) << SKEIN_CFG_TREE_NODE_SIZE_POS) | \ - (((u64)(maxLvl)) << SKEIN_CFG_TREE_MAX_LEVEL_POS) ) +#define SKEIN_CFG_TREE_INFO(leaf, node, maxLvl) \ + ((((u64)(leaf)) << SKEIN_CFG_TREE_LEAF_SIZE_POS) | \ + (((u64)(node)) << SKEIN_CFG_TREE_NODE_SIZE_POS) | \ + (((u64)(maxLvl)) << SKEIN_CFG_TREE_MAX_LEVEL_POS)) -#define SKEIN_CFG_TREE_INFO_SEQUENTIAL SKEIN_CFG_TREE_INFO(0,0,0) /* use as treeInfo in InitExt() call for sequential processing */ +#define SKEIN_CFG_TREE_INFO_SEQUENTIAL SKEIN_CFG_TREE_INFO(0, 0, 0) /* use as treeInfo in InitExt() call for sequential processing */ /* ** Skein macros for getting/setting tweak words, etc. ** These are useful for partial input bytes, hash tree init/update, etc. **/ -#define Skein_Get_Tweak(ctxPtr,TWK_NUM) ((ctxPtr)->h.T[TWK_NUM]) -#define Skein_Set_Tweak(ctxPtr,TWK_NUM,tVal) {(ctxPtr)->h.T[TWK_NUM] = (tVal);} +#define Skein_Get_Tweak(ctxPtr, TWK_NUM) ((ctxPtr)->h.T[TWK_NUM]) +#define Skein_Set_Tweak(ctxPtr, TWK_NUM, tVal) {(ctxPtr)->h.T[TWK_NUM] = (tVal); } -#define Skein_Get_T0(ctxPtr) Skein_Get_Tweak(ctxPtr,0) -#define Skein_Get_T1(ctxPtr) Skein_Get_Tweak(ctxPtr,1) -#define Skein_Set_T0(ctxPtr,T0) Skein_Set_Tweak(ctxPtr,0,T0) -#define Skein_Set_T1(ctxPtr,T1) Skein_Set_Tweak(ctxPtr,1,T1) +#define Skein_Get_T0(ctxPtr) Skein_Get_Tweak(ctxPtr, 0) +#define Skein_Get_T1(ctxPtr) Skein_Get_Tweak(ctxPtr, 1) +#define Skein_Set_T0(ctxPtr, T0) Skein_Set_Tweak(ctxPtr, 0, T0) +#define Skein_Set_T1(ctxPtr, T1) Skein_Set_Tweak(ctxPtr, 1, T1) /* set both tweak words at once */ -#define Skein_Set_T0_T1(ctxPtr,T0,T1) \ +#define Skein_Set_T0_T1(ctxPtr, T0, T1) \ { \ - Skein_Set_T0(ctxPtr,(T0)); \ - Skein_Set_T1(ctxPtr,(T1)); \ + Skein_Set_T0(ctxPtr, (T0)); \ + Skein_Set_T1(ctxPtr, (T1)); \ } -#define Skein_Set_Type(ctxPtr,BLK_TYPE) \ - Skein_Set_T1(ctxPtr,SKEIN_T1_BLK_TYPE_##BLK_TYPE) +#define Skein_Set_Type(ctxPtr, BLK_TYPE) \ + Skein_Set_T1(ctxPtr, SKEIN_T1_BLK_TYPE_##BLK_TYPE) /* set up for starting with a new type: h.T[0]=0; h.T[1] = NEW_TYPE; h.bCnt=0; */ -#define Skein_Start_New_Type(ctxPtr,BLK_TYPE) \ - { Skein_Set_T0_T1(ctxPtr,0,SKEIN_T1_FLAG_FIRST | SKEIN_T1_BLK_TYPE_##BLK_TYPE); (ctxPtr)->h.bCnt=0; } +#define Skein_Start_New_Type(ctxPtr, BLK_TYPE) \ + { Skein_Set_T0_T1(ctxPtr, 0, SKEIN_T1_FLAG_FIRST | SKEIN_T1_BLK_TYPE_##BLK_TYPE); (ctxPtr)->h.bCnt = 0; } #define Skein_Clear_First_Flag(hdr) { (hdr).T[1] &= ~SKEIN_T1_FLAG_FIRST; } #define Skein_Set_Bit_Pad_Flag(hdr) { (hdr).T[1] |= SKEIN_T1_FLAG_BIT_PAD; } -#define Skein_Set_Tree_Level(hdr,height) { (hdr).T[1] |= SKEIN_T1_TREE_LEVEL(height);} +#define Skein_Set_Tree_Level(hdr, height) { (hdr).T[1] |= SKEIN_T1_TREE_LEVEL(height); } /***************************************************************** ** "Internal" Skein definitions for debugging and error checking ******************************************************************/ -#ifdef SKEIN_DEBUG /* examine/display intermediate values? */ +#ifdef SKEIN_DEBUG /* examine/display intermediate values? */ #include "skein_debug.h" #else /* default is no callouts */ -#define Skein_Show_Block(bits,ctx,X,blkPtr,wPtr,ksEvenPtr,ksOddPtr) -#define Skein_Show_Round(bits,ctx,r,X) -#define Skein_Show_R_Ptr(bits,ctx,r,X_ptr) -#define Skein_Show_Final(bits,ctx,cnt,outPtr) -#define Skein_Show_Key(bits,ctx,key,keyBytes) +#define Skein_Show_Block(bits, ctx, X, blkPtr, wPtr, ksEvenPtr, ksOddPtr) +#define Skein_Show_Round(bits, ctx, r, X) +#define Skein_Show_R_Ptr(bits, ctx, r, X_ptr) +#define Skein_Show_Final(bits, ctx, cnt, outPtr) +#define Skein_Show_Key(bits, ctx, key, keyBytes) #endif -#define Skein_Assert(x,retCode)/* default: ignore all Asserts, for performance */ +#define Skein_Assert(x, retCode)/* default: ignore all Asserts, for performance */ #define Skein_assert(x) /***************************************************************** @@ -272,34 +272,34 @@ int Skein1024_Output (struct skein1024_ctx *ctx, u8 *hashVal); enum { /* Skein_256 round rotation constants */ - R_256_0_0=14, R_256_0_1=16, - R_256_1_0=52, R_256_1_1=57, - R_256_2_0=23, R_256_2_1=40, - R_256_3_0= 5, R_256_3_1=37, - R_256_4_0=25, R_256_4_1=33, - R_256_5_0=46, R_256_5_1=12, - R_256_6_0=58, R_256_6_1=22, - R_256_7_0=32, R_256_7_1=32, + R_256_0_0 = 14, R_256_0_1 = 16, + R_256_1_0 = 52, R_256_1_1 = 57, + R_256_2_0 = 23, R_256_2_1 = 40, + R_256_3_0 = 5, R_256_3_1 = 37, + R_256_4_0 = 25, R_256_4_1 = 33, + R_256_5_0 = 46, R_256_5_1 = 12, + R_256_6_0 = 58, R_256_6_1 = 22, + R_256_7_0 = 32, R_256_7_1 = 32, /* Skein_512 round rotation constants */ - R_512_0_0=46, R_512_0_1=36, R_512_0_2=19, R_512_0_3=37, - R_512_1_0=33, R_512_1_1=27, R_512_1_2=14, R_512_1_3=42, - R_512_2_0=17, R_512_2_1=49, R_512_2_2=36, R_512_2_3=39, - R_512_3_0=44, R_512_3_1= 9, R_512_3_2=54, R_512_3_3=56, - R_512_4_0=39, R_512_4_1=30, R_512_4_2=34, R_512_4_3=24, - R_512_5_0=13, R_512_5_1=50, R_512_5_2=10, R_512_5_3=17, - R_512_6_0=25, R_512_6_1=29, R_512_6_2=39, R_512_6_3=43, - R_512_7_0= 8, R_512_7_1=35, R_512_7_2=56, R_512_7_3=22, + R_512_0_0 = 46, R_512_0_1 = 36, R_512_0_2 = 19, R_512_0_3 = 37, + R_512_1_0 = 33, R_512_1_1 = 27, R_512_1_2 = 14, R_512_1_3 = 42, + R_512_2_0 = 17, R_512_2_1 = 49, R_512_2_2 = 36, R_512_2_3 = 39, + R_512_3_0 = 44, R_512_3_1 = 9, R_512_3_2 = 54, R_512_3_3 = 56, + R_512_4_0 = 39, R_512_4_1 = 30, R_512_4_2 = 34, R_512_4_3 = 24, + R_512_5_0 = 13, R_512_5_1 = 50, R_512_5_2 = 10, R_512_5_3 = 17, + R_512_6_0 = 25, R_512_6_1 = 29, R_512_6_2 = 39, R_512_6_3 = 43, + R_512_7_0 = 8, R_512_7_1 = 35, R_512_7_2 = 56, R_512_7_3 = 22, /* Skein1024 round rotation constants */ - R1024_0_0=24, R1024_0_1=13, R1024_0_2= 8, R1024_0_3=47, R1024_0_4= 8, R1024_0_5=17, R1024_0_6=22, R1024_0_7=37, - R1024_1_0=38, R1024_1_1=19, R1024_1_2=10, R1024_1_3=55, R1024_1_4=49, R1024_1_5=18, R1024_1_6=23, R1024_1_7=52, - R1024_2_0=33, R1024_2_1= 4, R1024_2_2=51, R1024_2_3=13, R1024_2_4=34, R1024_2_5=41, R1024_2_6=59, R1024_2_7=17, - R1024_3_0= 5, R1024_3_1=20, R1024_3_2=48, R1024_3_3=41, R1024_3_4=47, R1024_3_5=28, R1024_3_6=16, R1024_3_7=25, - R1024_4_0=41, R1024_4_1= 9, R1024_4_2=37, R1024_4_3=31, R1024_4_4=12, R1024_4_5=47, R1024_4_6=44, R1024_4_7=30, - R1024_5_0=16, R1024_5_1=34, R1024_5_2=56, R1024_5_3=51, R1024_5_4= 4, R1024_5_5=53, R1024_5_6=42, R1024_5_7=41, - R1024_6_0=31, R1024_6_1=44, R1024_6_2=47, R1024_6_3=46, R1024_6_4=19, R1024_6_5=42, R1024_6_6=44, R1024_6_7=25, - R1024_7_0= 9, R1024_7_1=48, R1024_7_2=35, R1024_7_3=52, R1024_7_4=23, R1024_7_5=31, R1024_7_6=37, R1024_7_7=20 + R1024_0_0 = 24, R1024_0_1 = 13, R1024_0_2 = 8, R1024_0_3 = 47, R1024_0_4 = 8, R1024_0_5 = 17, R1024_0_6 = 22, R1024_0_7 = 37, + R1024_1_0 = 38, R1024_1_1 = 19, R1024_1_2 = 10, R1024_1_3 = 55, R1024_1_4 = 49, R1024_1_5 = 18, R1024_1_6 = 23, R1024_1_7 = 52, + R1024_2_0 = 33, R1024_2_1 = 4, R1024_2_2 = 51, R1024_2_3 = 13, R1024_2_4 = 34, R1024_2_5 = 41, R1024_2_6 = 59, R1024_2_7 = 17, + R1024_3_0 = 5, R1024_3_1 = 20, R1024_3_2 = 48, R1024_3_3 = 41, R1024_3_4 = 47, R1024_3_5 = 28, R1024_3_6 = 16, R1024_3_7 = 25, + R1024_4_0 = 41, R1024_4_1 = 9, R1024_4_2 = 37, R1024_4_3 = 31, R1024_4_4 = 12, R1024_4_5 = 47, R1024_4_6 = 44, R1024_4_7 = 30, + R1024_5_0 = 16, R1024_5_1 = 34, R1024_5_2 = 56, R1024_5_3 = 51, R1024_5_4 = 4, R1024_5_5 = 53, R1024_5_6 = 42, R1024_5_7 = 41, + R1024_6_0 = 31, R1024_6_1 = 44, R1024_6_2 = 47, R1024_6_3 = 46, R1024_6_4 = 19, R1024_6_5 = 42, R1024_6_6 = 44, R1024_6_7 = 25, + R1024_7_0 = 9, R1024_7_1 = 48, R1024_7_2 = 35, R1024_7_3 = 52, R1024_7_4 = 23, R1024_7_5 = 31, R1024_7_6 = 37, R1024_7_7 = 20 }; #ifndef SKEIN_ROUNDS @@ -308,8 +308,8 @@ enum #define SKEIN1024_ROUNDS_TOTAL (80) #else /* allow command-line define in range 8*(5..14) */ #define SKEIN_256_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS/100) + 5) % 10) + 5)) -#define SKEIN_512_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS/ 10) + 5) % 10) + 5)) -#define SKEIN1024_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS ) + 5) % 10) + 5)) +#define SKEIN_512_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS/10) + 5) % 10) + 5)) +#define SKEIN1024_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS) + 5) % 10) + 5)) #endif #endif /* ifndef _SKEIN_H_ */ diff --git a/drivers/staging/skein/include/skein_iv.h b/drivers/staging/skein/include/skein_iv.h index 1dc058142f38..813bad528e3c 100644 --- a/drivers/staging/skein/include/skein_iv.h +++ b/drivers/staging/skein/include/skein_iv.h @@ -22,178 +22,178 @@ /* blkSize = 256 bits. hashSize = 128 bits */ const u64 SKEIN_256_IV_128[] = { - MK_64(0xE1111906,0x964D7260), - MK_64(0x883DAAA7,0x7C8D811C), - MK_64(0x10080DF4,0x91960F7A), - MK_64(0xCCF7DDE5,0xB45BC1C2) + MK_64(0xE1111906, 0x964D7260), + MK_64(0x883DAAA7, 0x7C8D811C), + MK_64(0x10080DF4, 0x91960F7A), + MK_64(0xCCF7DDE5, 0xB45BC1C2) }; /* blkSize = 256 bits. hashSize = 160 bits */ const u64 SKEIN_256_IV_160[] = { - MK_64(0x14202314,0x72825E98), - MK_64(0x2AC4E9A2,0x5A77E590), - MK_64(0xD47A5856,0x8838D63E), - MK_64(0x2DD2E496,0x8586AB7D) + MK_64(0x14202314, 0x72825E98), + MK_64(0x2AC4E9A2, 0x5A77E590), + MK_64(0xD47A5856, 0x8838D63E), + MK_64(0x2DD2E496, 0x8586AB7D) }; /* blkSize = 256 bits. hashSize = 224 bits */ const u64 SKEIN_256_IV_224[] = { - MK_64(0xC6098A8C,0x9AE5EA0B), - MK_64(0x876D5686,0x08C5191C), - MK_64(0x99CB88D7,0xD7F53884), - MK_64(0x384BDDB1,0xAEDDB5DE) + MK_64(0xC6098A8C, 0x9AE5EA0B), + MK_64(0x876D5686, 0x08C5191C), + MK_64(0x99CB88D7, 0xD7F53884), + MK_64(0x384BDDB1, 0xAEDDB5DE) }; /* blkSize = 256 bits. hashSize = 256 bits */ const u64 SKEIN_256_IV_256[] = { - MK_64(0xFC9DA860,0xD048B449), - MK_64(0x2FCA6647,0x9FA7D833), - MK_64(0xB33BC389,0x6656840F), - MK_64(0x6A54E920,0xFDE8DA69) + MK_64(0xFC9DA860, 0xD048B449), + MK_64(0x2FCA6647, 0x9FA7D833), + MK_64(0xB33BC389, 0x6656840F), + MK_64(0x6A54E920, 0xFDE8DA69) }; /* blkSize = 512 bits. hashSize = 128 bits */ const u64 SKEIN_512_IV_128[] = { - MK_64(0xA8BC7BF3,0x6FBF9F52), - MK_64(0x1E9872CE,0xBD1AF0AA), - MK_64(0x309B1790,0xB32190D3), - MK_64(0xBCFBB854,0x3F94805C), - MK_64(0x0DA61BCD,0x6E31B11B), - MK_64(0x1A18EBEA,0xD46A32E3), - MK_64(0xA2CC5B18,0xCE84AA82), - MK_64(0x6982AB28,0x9D46982D) + MK_64(0xA8BC7BF3, 0x6FBF9F52), + MK_64(0x1E9872CE, 0xBD1AF0AA), + MK_64(0x309B1790, 0xB32190D3), + MK_64(0xBCFBB854, 0x3F94805C), + MK_64(0x0DA61BCD, 0x6E31B11B), + MK_64(0x1A18EBEA, 0xD46A32E3), + MK_64(0xA2CC5B18, 0xCE84AA82), + MK_64(0x6982AB28, 0x9D46982D) }; /* blkSize = 512 bits. hashSize = 160 bits */ const u64 SKEIN_512_IV_160[] = { - MK_64(0x28B81A2A,0xE013BD91), - MK_64(0xC2F11668,0xB5BDF78F), - MK_64(0x1760D8F3,0xF6A56F12), - MK_64(0x4FB74758,0x8239904F), - MK_64(0x21EDE07F,0x7EAF5056), - MK_64(0xD908922E,0x63ED70B8), - MK_64(0xB8EC76FF,0xECCB52FA), - MK_64(0x01A47BB8,0xA3F27A6E) + MK_64(0x28B81A2A, 0xE013BD91), + MK_64(0xC2F11668, 0xB5BDF78F), + MK_64(0x1760D8F3, 0xF6A56F12), + MK_64(0x4FB74758, 0x8239904F), + MK_64(0x21EDE07F, 0x7EAF5056), + MK_64(0xD908922E, 0x63ED70B8), + MK_64(0xB8EC76FF, 0xECCB52FA), + MK_64(0x01A47BB8, 0xA3F27A6E) }; /* blkSize = 512 bits. hashSize = 224 bits */ const u64 SKEIN_512_IV_224[] = { - MK_64(0xCCD06162,0x48677224), - MK_64(0xCBA65CF3,0xA92339EF), - MK_64(0x8CCD69D6,0x52FF4B64), - MK_64(0x398AED7B,0x3AB890B4), - MK_64(0x0F59D1B1,0x457D2BD0), - MK_64(0x6776FE65,0x75D4EB3D), - MK_64(0x99FBC70E,0x997413E9), - MK_64(0x9E2CFCCF,0xE1C41EF7) + MK_64(0xCCD06162, 0x48677224), + MK_64(0xCBA65CF3, 0xA92339EF), + MK_64(0x8CCD69D6, 0x52FF4B64), + MK_64(0x398AED7B, 0x3AB890B4), + MK_64(0x0F59D1B1, 0x457D2BD0), + MK_64(0x6776FE65, 0x75D4EB3D), + MK_64(0x99FBC70E, 0x997413E9), + MK_64(0x9E2CFCCF, 0xE1C41EF7) }; /* blkSize = 512 bits. hashSize = 256 bits */ const u64 SKEIN_512_IV_256[] = { - MK_64(0xCCD044A1,0x2FDB3E13), - MK_64(0xE8359030,0x1A79A9EB), - MK_64(0x55AEA061,0x4F816E6F), - MK_64(0x2A2767A4,0xAE9B94DB), - MK_64(0xEC06025E,0x74DD7683), - MK_64(0xE7A436CD,0xC4746251), - MK_64(0xC36FBAF9,0x393AD185), - MK_64(0x3EEDBA18,0x33EDFC13) + MK_64(0xCCD044A1, 0x2FDB3E13), + MK_64(0xE8359030, 0x1A79A9EB), + MK_64(0x55AEA061, 0x4F816E6F), + MK_64(0x2A2767A4, 0xAE9B94DB), + MK_64(0xEC06025E, 0x74DD7683), + MK_64(0xE7A436CD, 0xC4746251), + MK_64(0xC36FBAF9, 0x393AD185), + MK_64(0x3EEDBA18, 0x33EDFC13) }; /* blkSize = 512 bits. hashSize = 384 bits */ const u64 SKEIN_512_IV_384[] = { - MK_64(0xA3F6C6BF,0x3A75EF5F), - MK_64(0xB0FEF9CC,0xFD84FAA4), - MK_64(0x9D77DD66,0x3D770CFE), - MK_64(0xD798CBF3,0xB468FDDA), - MK_64(0x1BC4A666,0x8A0E4465), - MK_64(0x7ED7D434,0xE5807407), - MK_64(0x548FC1AC,0xD4EC44D6), - MK_64(0x266E1754,0x6AA18FF8) + MK_64(0xA3F6C6BF, 0x3A75EF5F), + MK_64(0xB0FEF9CC, 0xFD84FAA4), + MK_64(0x9D77DD66, 0x3D770CFE), + MK_64(0xD798CBF3, 0xB468FDDA), + MK_64(0x1BC4A666, 0x8A0E4465), + MK_64(0x7ED7D434, 0xE5807407), + MK_64(0x548FC1AC, 0xD4EC44D6), + MK_64(0x266E1754, 0x6AA18FF8) }; /* blkSize = 512 bits. hashSize = 512 bits */ const u64 SKEIN_512_IV_512[] = { - MK_64(0x4903ADFF,0x749C51CE), - MK_64(0x0D95DE39,0x9746DF03), - MK_64(0x8FD19341,0x27C79BCE), - MK_64(0x9A255629,0xFF352CB1), - MK_64(0x5DB62599,0xDF6CA7B0), - MK_64(0xEABE394C,0xA9D5C3F4), - MK_64(0x991112C7,0x1A75B523), - MK_64(0xAE18A40B,0x660FCC33) + MK_64(0x4903ADFF, 0x749C51CE), + MK_64(0x0D95DE39, 0x9746DF03), + MK_64(0x8FD19341, 0x27C79BCE), + MK_64(0x9A255629, 0xFF352CB1), + MK_64(0x5DB62599, 0xDF6CA7B0), + MK_64(0xEABE394C, 0xA9D5C3F4), + MK_64(0x991112C7, 0x1A75B523), + MK_64(0xAE18A40B, 0x660FCC33) }; /* blkSize = 1024 bits. hashSize = 384 bits */ const u64 SKEIN1024_IV_384[] = { - MK_64(0x5102B6B8,0xC1894A35), - MK_64(0xFEEBC9E3,0xFE8AF11A), - MK_64(0x0C807F06,0xE32BED71), - MK_64(0x60C13A52,0xB41A91F6), - MK_64(0x9716D35D,0xD4917C38), - MK_64(0xE780DF12,0x6FD31D3A), - MK_64(0x797846B6,0xC898303A), - MK_64(0xB172C2A8,0xB3572A3B), - MK_64(0xC9BC8203,0xA6104A6C), - MK_64(0x65909338,0xD75624F4), - MK_64(0x94BCC568,0x4B3F81A0), - MK_64(0x3EBBF51E,0x10ECFD46), - MK_64(0x2DF50F0B,0xEEB08542), - MK_64(0x3B5A6530,0x0DBC6516), - MK_64(0x484B9CD2,0x167BBCE1), - MK_64(0x2D136947,0xD4CBAFEA) + MK_64(0x5102B6B8, 0xC1894A35), + MK_64(0xFEEBC9E3, 0xFE8AF11A), + MK_64(0x0C807F06, 0xE32BED71), + MK_64(0x60C13A52, 0xB41A91F6), + MK_64(0x9716D35D, 0xD4917C38), + MK_64(0xE780DF12, 0x6FD31D3A), + MK_64(0x797846B6, 0xC898303A), + MK_64(0xB172C2A8, 0xB3572A3B), + MK_64(0xC9BC8203, 0xA6104A6C), + MK_64(0x65909338, 0xD75624F4), + MK_64(0x94BCC568, 0x4B3F81A0), + MK_64(0x3EBBF51E, 0x10ECFD46), + MK_64(0x2DF50F0B, 0xEEB08542), + MK_64(0x3B5A6530, 0x0DBC6516), + MK_64(0x484B9CD2, 0x167BBCE1), + MK_64(0x2D136947, 0xD4CBAFEA) }; /* blkSize = 1024 bits. hashSize = 512 bits */ const u64 SKEIN1024_IV_512[] = { - MK_64(0xCAEC0E5D,0x7C1B1B18), - MK_64(0xA01B0E04,0x5F03E802), - MK_64(0x33840451,0xED912885), - MK_64(0x374AFB04,0xEAEC2E1C), - MK_64(0xDF25A0E2,0x813581F7), - MK_64(0xE4004093,0x8B12F9D2), - MK_64(0xA662D539,0xC2ED39B6), - MK_64(0xFA8B85CF,0x45D8C75A), - MK_64(0x8316ED8E,0x29EDE796), - MK_64(0x053289C0,0x2E9F91B8), - MK_64(0xC3F8EF1D,0x6D518B73), - MK_64(0xBDCEC3C4,0xD5EF332E), - MK_64(0x549A7E52,0x22974487), - MK_64(0x67070872,0x5B749816), - MK_64(0xB9CD28FB,0xF0581BD1), - MK_64(0x0E2940B8,0x15804974) + MK_64(0xCAEC0E5D, 0x7C1B1B18), + MK_64(0xA01B0E04, 0x5F03E802), + MK_64(0x33840451, 0xED912885), + MK_64(0x374AFB04, 0xEAEC2E1C), + MK_64(0xDF25A0E2, 0x813581F7), + MK_64(0xE4004093, 0x8B12F9D2), + MK_64(0xA662D539, 0xC2ED39B6), + MK_64(0xFA8B85CF, 0x45D8C75A), + MK_64(0x8316ED8E, 0x29EDE796), + MK_64(0x053289C0, 0x2E9F91B8), + MK_64(0xC3F8EF1D, 0x6D518B73), + MK_64(0xBDCEC3C4, 0xD5EF332E), + MK_64(0x549A7E52, 0x22974487), + MK_64(0x67070872, 0x5B749816), + MK_64(0xB9CD28FB, 0xF0581BD1), + MK_64(0x0E2940B8, 0x15804974) }; /* blkSize = 1024 bits. hashSize = 1024 bits */ const u64 SKEIN1024_IV_1024[] = { - MK_64(0xD593DA07,0x41E72355), - MK_64(0x15B5E511,0xAC73E00C), - MK_64(0x5180E5AE,0xBAF2C4F0), - MK_64(0x03BD41D3,0xFCBCAFAF), - MK_64(0x1CAEC6FD,0x1983A898), - MK_64(0x6E510B8B,0xCDD0589F), - MK_64(0x77E2BDFD,0xC6394ADA), - MK_64(0xC11E1DB5,0x24DCB0A3), - MK_64(0xD6D14AF9,0xC6329AB5), - MK_64(0x6A9B0BFC,0x6EB67E0D), - MK_64(0x9243C60D,0xCCFF1332), - MK_64(0x1A1F1DDE,0x743F02D4), - MK_64(0x0996753C,0x10ED0BB8), - MK_64(0x6572DD22,0xF2B4969A), - MK_64(0x61FD3062,0xD00A579A), - MK_64(0x1DE0536E,0x8682E539) + MK_64(0xD593DA07, 0x41E72355), + MK_64(0x15B5E511, 0xAC73E00C), + MK_64(0x5180E5AE, 0xBAF2C4F0), + MK_64(0x03BD41D3, 0xFCBCAFAF), + MK_64(0x1CAEC6FD, 0x1983A898), + MK_64(0x6E510B8B, 0xCDD0589F), + MK_64(0x77E2BDFD, 0xC6394ADA), + MK_64(0xC11E1DB5, 0x24DCB0A3), + MK_64(0xD6D14AF9, 0xC6329AB5), + MK_64(0x6A9B0BFC, 0x6EB67E0D), + MK_64(0x9243C60D, 0xCCFF1332), + MK_64(0x1A1F1DDE, 0x743F02D4), + MK_64(0x0996753C, 0x10ED0BB8), + MK_64(0x6572DD22, 0xF2B4969A), + MK_64(0x61FD3062, 0xD00A579A), + MK_64(0x1DE0536E, 0x8682E539) }; #endif /* _SKEIN_IV_H_ */ diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c index c1565377ff28..e2e5685157a0 100644 --- a/drivers/staging/skein/skein.c +++ b/drivers/staging/skein/skein.c @@ -16,9 +16,9 @@ /*****************************************************************/ /* External function to process blkCnt (nonzero) full block(s) of data. */ -void Skein_256_Process_Block(struct skein_256_ctx *ctx,const u8 *blkPtr,size_t blkCnt,size_t byteCntAdd); -void Skein_512_Process_Block(struct skein_512_ctx *ctx,const u8 *blkPtr,size_t blkCnt,size_t byteCntAdd); -void Skein1024_Process_Block(struct skein1024_ctx *ctx,const u8 *blkPtr,size_t blkCnt,size_t byteCntAdd); +void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, size_t blkCnt, size_t byteCntAdd); +void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, size_t blkCnt, size_t byteCntAdd); +void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, size_t blkCnt, size_t byteCntAdd); /*****************************************************************/ /* 256-bit Skein */ @@ -34,41 +34,41 @@ int Skein_256_Init(struct skein_256_ctx *ctx, size_t hashBitLen) u64 w[SKEIN_256_STATE_WORDS]; } cfg; /* config block */ - Skein_Assert(hashBitLen > 0,SKEIN_BAD_HASHLEN); + Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN); ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ switch (hashBitLen) { /* use pre-computed values, where available */ case 256: - memcpy(ctx->X,SKEIN_256_IV_256,sizeof(ctx->X)); + memcpy(ctx->X, SKEIN_256_IV_256, sizeof(ctx->X)); break; case 224: - memcpy(ctx->X,SKEIN_256_IV_224,sizeof(ctx->X)); + memcpy(ctx->X, SKEIN_256_IV_224, sizeof(ctx->X)); break; case 160: - memcpy(ctx->X,SKEIN_256_IV_160,sizeof(ctx->X)); + memcpy(ctx->X, SKEIN_256_IV_160, sizeof(ctx->X)); break; case 128: - memcpy(ctx->X,SKEIN_256_IV_128,sizeof(ctx->X)); + memcpy(ctx->X, SKEIN_256_IV_128, sizeof(ctx->X)); break; default: /* here if there is no precomputed IV value available */ /* build/process the config block, type == CONFIG (could be precomputed) */ - Skein_Start_New_Type(ctx,CFG_FINAL); /* set tweaks: T0=0; T1=CFG | FINAL */ + Skein_Start_New_Type(ctx, CFG_FINAL); /* set tweaks: T0=0; T1=CFG | FINAL */ cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); /* set the schema, version */ cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ cfg.w[2] = Skein_Swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); - memset(&cfg.w[3],0,sizeof(cfg) - 3*sizeof(cfg.w[0])); /* zero pad config block */ + memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); /* zero pad config block */ /* compute the initial chaining values from config block */ - memset(ctx->X,0,sizeof(ctx->X)); /* zero the chaining variables */ - Skein_256_Process_Block(ctx,cfg.b,1,SKEIN_CFG_STR_LEN); + memset(ctx->X, 0, sizeof(ctx->X)); /* zero the chaining variables */ + Skein_256_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); break; } /* The chaining vars ctx->X are now initialized for the given hashBitLen. */ /* Set up to process the data message portion of the hash (default) */ - Skein_Start_New_Type(ctx,MSG); /* T0=0, T1= MSG type */ + Skein_Start_New_Type(ctx, MSG); /* T0=0, T1= MSG type */ return SKEIN_SUCCESS; } @@ -76,7 +76,7 @@ int Skein_256_Init(struct skein_256_ctx *ctx, size_t hashBitLen) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a MAC and/or tree hash operation */ /* [identical to Skein_256_Init() when keyBytes == 0 && treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ -int Skein_256_InitExt(struct skein_256_ctx *ctx,size_t hashBitLen,u64 treeInfo, const u8 *key, size_t keyBytes) +int Skein_256_InitExt(struct skein_256_ctx *ctx, size_t hashBitLen, u64 treeInfo, const u8 *key, size_t keyBytes) { union { @@ -84,42 +84,42 @@ int Skein_256_InitExt(struct skein_256_ctx *ctx,size_t hashBitLen,u64 treeInfo, u64 w[SKEIN_256_STATE_WORDS]; } cfg; /* config block */ - Skein_Assert(hashBitLen > 0,SKEIN_BAD_HASHLEN); - Skein_Assert(keyBytes == 0 || key != NULL,SKEIN_FAIL); + Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN); + Skein_Assert(keyBytes == 0 || key != NULL, SKEIN_FAIL); /* compute the initial chaining values ctx->X[], based on key */ if (keyBytes == 0) /* is there a key? */ { - memset(ctx->X,0,sizeof(ctx->X)); /* no key: use all zeroes as key for config block */ + memset(ctx->X, 0, sizeof(ctx->X)); /* no key: use all zeroes as key for config block */ } else /* here to pre-process a key */ { Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); /* do a mini-Init right here */ - ctx->h.hashBitLen=8*sizeof(ctx->X); /* set output hash bit count = state size */ - Skein_Start_New_Type(ctx,KEY); /* set tweaks: T0 = 0; T1 = KEY type */ - memset(ctx->X,0,sizeof(ctx->X)); /* zero the initial chaining variables */ - Skein_256_Update(ctx,key,keyBytes); /* hash the key */ - Skein_256_Final_Pad(ctx,cfg.b); /* put result into cfg.b[] */ - memcpy(ctx->X,cfg.b,sizeof(cfg.b)); /* copy over into ctx->X[] */ + ctx->h.hashBitLen = 8*sizeof(ctx->X); /* set output hash bit count = state size */ + Skein_Start_New_Type(ctx, KEY); /* set tweaks: T0 = 0; T1 = KEY type */ + memset(ctx->X, 0, sizeof(ctx->X)); /* zero the initial chaining variables */ + Skein_256_Update(ctx, key, keyBytes); /* hash the key */ + Skein_256_Final_Pad(ctx, cfg.b); /* put result into cfg.b[] */ + memcpy(ctx->X, cfg.b, sizeof(cfg.b)); /* copy over into ctx->X[] */ } /* build/process the config block, type == CONFIG (could be precomputed for each key) */ ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ - Skein_Start_New_Type(ctx,CFG_FINAL); + Skein_Start_New_Type(ctx, CFG_FINAL); - memset(&cfg.w,0,sizeof(cfg.w)); /* pre-pad cfg.w[] with zeroes */ + memset(&cfg.w, 0, sizeof(cfg.w)); /* pre-pad cfg.w[] with zeroes */ cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ cfg.w[2] = Skein_Swap64(treeInfo); /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ - Skein_Show_Key(256,&ctx->h,key,keyBytes); + Skein_Show_Key(256, &ctx->h, key, keyBytes); /* compute the initial chaining values from config block */ - Skein_256_Process_Block(ctx,cfg.b,1,SKEIN_CFG_STR_LEN); + Skein_256_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); /* The chaining vars ctx->X are now initialized */ /* Set up to process the data message portion of the hash (default) */ - Skein_Start_New_Type(ctx,MSG); + Skein_Start_New_Type(ctx, MSG); return SKEIN_SUCCESS; } @@ -130,7 +130,7 @@ int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg, size_t msgByteCnt { size_t n; - Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ + Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ /* process full blocks, if any */ if (msgByteCnt + ctx->h.bCnt > SKEIN_256_BLOCK_BYTES) @@ -141,20 +141,20 @@ int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg, size_t msgByteCnt if (n) { Skein_assert(n < msgByteCnt); /* check on our logic here */ - memcpy(&ctx->b[ctx->h.bCnt],msg,n); + memcpy(&ctx->b[ctx->h.bCnt], msg, n); msgByteCnt -= n; msg += n; ctx->h.bCnt += n; } Skein_assert(ctx->h.bCnt == SKEIN_256_BLOCK_BYTES); - Skein_256_Process_Block(ctx,ctx->b,1,SKEIN_256_BLOCK_BYTES); + Skein_256_Process_Block(ctx, ctx->b, 1, SKEIN_256_BLOCK_BYTES); ctx->h.bCnt = 0; } /* now process any remaining full blocks, directly from input message data */ if (msgByteCnt > SKEIN_256_BLOCK_BYTES) { n = (msgByteCnt-1) / SKEIN_256_BLOCK_BYTES; /* number of full blocks to process */ - Skein_256_Process_Block(ctx,msg,n,SKEIN_256_BLOCK_BYTES); + Skein_256_Process_Block(ctx, msg, n, SKEIN_256_BLOCK_BYTES); msgByteCnt -= n * SKEIN_256_BLOCK_BYTES; msg += n * SKEIN_256_BLOCK_BYTES; } @@ -165,7 +165,7 @@ int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg, size_t msgByteCnt if (msgByteCnt) { Skein_assert(msgByteCnt + ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES); - memcpy(&ctx->b[ctx->h.bCnt],msg,msgByteCnt); + memcpy(&ctx->b[ctx->h.bCnt], msg, msgByteCnt); ctx->h.bCnt += msgByteCnt; } @@ -176,33 +176,33 @@ int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg, size_t msgByteCnt /* finalize the hash computation and output the result */ int Skein_256_Final(struct skein_256_ctx *ctx, u8 *hashVal) { - size_t i,n,byteCnt; + size_t i, n, byteCnt; u64 X[SKEIN_256_STATE_WORDS]; - Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ + Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ if (ctx->h.bCnt < SKEIN_256_BLOCK_BYTES) /* zero pad b[] if necessary */ - memset(&ctx->b[ctx->h.bCnt],0,SKEIN_256_BLOCK_BYTES - ctx->h.bCnt); + memset(&ctx->b[ctx->h.bCnt], 0, SKEIN_256_BLOCK_BYTES - ctx->h.bCnt); - Skein_256_Process_Block(ctx,ctx->b,1,ctx->h.bCnt); /* process the final block */ + Skein_256_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); /* process the final block */ /* now output the result */ byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ /* run Threefish in "counter mode" to generate output */ - memset(ctx->b,0,sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ - memcpy(X,ctx->X,sizeof(X)); /* keep a local copy of counter mode "key" */ - for (i=0;i*SKEIN_256_BLOCK_BYTES < byteCnt;i++) + memset(ctx->b, 0, sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ + memcpy(X, ctx->X, sizeof(X)); /* keep a local copy of counter mode "key" */ + for (i = 0; i*SKEIN_256_BLOCK_BYTES < byteCnt; i++) { - ((u64 *)ctx->b)[0]= Skein_Swap64((u64) i); /* build the counter block */ - Skein_Start_New_Type(ctx,OUT_FINAL); - Skein_256_Process_Block(ctx,ctx->b,1,sizeof(u64)); /* run "counter mode" */ + ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); /* build the counter block */ + Skein_Start_New_Type(ctx, OUT_FINAL); + Skein_256_Process_Block(ctx, ctx->b, 1, sizeof(u64)); /* run "counter mode" */ n = byteCnt - i*SKEIN_256_BLOCK_BYTES; /* number of output bytes left to go */ if (n >= SKEIN_256_BLOCK_BYTES) n = SKEIN_256_BLOCK_BYTES; - Skein_Put64_LSB_First(hashVal+i*SKEIN_256_BLOCK_BYTES,ctx->X,n); /* "output" the ctr mode bytes */ - Skein_Show_Final(256,&ctx->h,n,hashVal+i*SKEIN_256_BLOCK_BYTES); - memcpy(ctx->X,X,sizeof(X)); /* restore the counter mode key for next time */ + Skein_Put64_LSB_First(hashVal+i*SKEIN_256_BLOCK_BYTES, ctx->X, n); /* "output" the ctr mode bytes */ + Skein_Show_Final(256, &ctx->h, n, hashVal+i*SKEIN_256_BLOCK_BYTES); + memcpy(ctx->X, X, sizeof(X)); /* restore the counter mode key for next time */ } return SKEIN_SUCCESS; } @@ -221,42 +221,42 @@ int Skein_512_Init(struct skein_512_ctx *ctx, size_t hashBitLen) u64 w[SKEIN_512_STATE_WORDS]; } cfg; /* config block */ - Skein_Assert(hashBitLen > 0,SKEIN_BAD_HASHLEN); + Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN); ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ switch (hashBitLen) { /* use pre-computed values, where available */ case 512: - memcpy(ctx->X,SKEIN_512_IV_512,sizeof(ctx->X)); + memcpy(ctx->X, SKEIN_512_IV_512, sizeof(ctx->X)); break; case 384: - memcpy(ctx->X,SKEIN_512_IV_384,sizeof(ctx->X)); + memcpy(ctx->X, SKEIN_512_IV_384, sizeof(ctx->X)); break; case 256: - memcpy(ctx->X,SKEIN_512_IV_256,sizeof(ctx->X)); + memcpy(ctx->X, SKEIN_512_IV_256, sizeof(ctx->X)); break; case 224: - memcpy(ctx->X,SKEIN_512_IV_224,sizeof(ctx->X)); + memcpy(ctx->X, SKEIN_512_IV_224, sizeof(ctx->X)); break; default: /* here if there is no precomputed IV value available */ /* build/process the config block, type == CONFIG (could be precomputed) */ - Skein_Start_New_Type(ctx,CFG_FINAL); /* set tweaks: T0=0; T1=CFG | FINAL */ + Skein_Start_New_Type(ctx, CFG_FINAL); /* set tweaks: T0=0; T1=CFG | FINAL */ cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); /* set the schema, version */ cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ cfg.w[2] = Skein_Swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); - memset(&cfg.w[3],0,sizeof(cfg) - 3*sizeof(cfg.w[0])); /* zero pad config block */ + memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); /* zero pad config block */ /* compute the initial chaining values from config block */ - memset(ctx->X,0,sizeof(ctx->X)); /* zero the chaining variables */ - Skein_512_Process_Block(ctx,cfg.b,1,SKEIN_CFG_STR_LEN); + memset(ctx->X, 0, sizeof(ctx->X)); /* zero the chaining variables */ + Skein_512_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); break; } /* The chaining vars ctx->X are now initialized for the given hashBitLen. */ /* Set up to process the data message portion of the hash (default) */ - Skein_Start_New_Type(ctx,MSG); /* T0=0, T1= MSG type */ + Skein_Start_New_Type(ctx, MSG); /* T0=0, T1= MSG type */ return SKEIN_SUCCESS; } @@ -264,7 +264,7 @@ int Skein_512_Init(struct skein_512_ctx *ctx, size_t hashBitLen) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a MAC and/or tree hash operation */ /* [identical to Skein_512_Init() when keyBytes == 0 && treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ -int Skein_512_InitExt(struct skein_512_ctx *ctx,size_t hashBitLen,u64 treeInfo, const u8 *key, size_t keyBytes) +int Skein_512_InitExt(struct skein_512_ctx *ctx, size_t hashBitLen, u64 treeInfo, const u8 *key, size_t keyBytes) { union { @@ -272,42 +272,42 @@ int Skein_512_InitExt(struct skein_512_ctx *ctx,size_t hashBitLen,u64 treeInfo, u64 w[SKEIN_512_STATE_WORDS]; } cfg; /* config block */ - Skein_Assert(hashBitLen > 0,SKEIN_BAD_HASHLEN); - Skein_Assert(keyBytes == 0 || key != NULL,SKEIN_FAIL); + Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN); + Skein_Assert(keyBytes == 0 || key != NULL, SKEIN_FAIL); /* compute the initial chaining values ctx->X[], based on key */ if (keyBytes == 0) /* is there a key? */ { - memset(ctx->X,0,sizeof(ctx->X)); /* no key: use all zeroes as key for config block */ + memset(ctx->X, 0, sizeof(ctx->X)); /* no key: use all zeroes as key for config block */ } else /* here to pre-process a key */ { Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); /* do a mini-Init right here */ - ctx->h.hashBitLen=8*sizeof(ctx->X); /* set output hash bit count = state size */ - Skein_Start_New_Type(ctx,KEY); /* set tweaks: T0 = 0; T1 = KEY type */ - memset(ctx->X,0,sizeof(ctx->X)); /* zero the initial chaining variables */ - Skein_512_Update(ctx,key,keyBytes); /* hash the key */ - Skein_512_Final_Pad(ctx,cfg.b); /* put result into cfg.b[] */ - memcpy(ctx->X,cfg.b,sizeof(cfg.b)); /* copy over into ctx->X[] */ + ctx->h.hashBitLen = 8*sizeof(ctx->X); /* set output hash bit count = state size */ + Skein_Start_New_Type(ctx, KEY); /* set tweaks: T0 = 0; T1 = KEY type */ + memset(ctx->X, 0, sizeof(ctx->X)); /* zero the initial chaining variables */ + Skein_512_Update(ctx, key, keyBytes); /* hash the key */ + Skein_512_Final_Pad(ctx, cfg.b); /* put result into cfg.b[] */ + memcpy(ctx->X, cfg.b, sizeof(cfg.b)); /* copy over into ctx->X[] */ } /* build/process the config block, type == CONFIG (could be precomputed for each key) */ ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ - Skein_Start_New_Type(ctx,CFG_FINAL); + Skein_Start_New_Type(ctx, CFG_FINAL); - memset(&cfg.w,0,sizeof(cfg.w)); /* pre-pad cfg.w[] with zeroes */ + memset(&cfg.w, 0, sizeof(cfg.w)); /* pre-pad cfg.w[] with zeroes */ cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ cfg.w[2] = Skein_Swap64(treeInfo); /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ - Skein_Show_Key(512,&ctx->h,key,keyBytes); + Skein_Show_Key(512, &ctx->h, key, keyBytes); /* compute the initial chaining values from config block */ - Skein_512_Process_Block(ctx,cfg.b,1,SKEIN_CFG_STR_LEN); + Skein_512_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); /* The chaining vars ctx->X are now initialized */ /* Set up to process the data message portion of the hash (default) */ - Skein_Start_New_Type(ctx,MSG); + Skein_Start_New_Type(ctx, MSG); return SKEIN_SUCCESS; } @@ -318,7 +318,7 @@ int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg, size_t msgByteCnt { size_t n; - Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ + Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ /* process full blocks, if any */ if (msgByteCnt + ctx->h.bCnt > SKEIN_512_BLOCK_BYTES) @@ -329,20 +329,20 @@ int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg, size_t msgByteCnt if (n) { Skein_assert(n < msgByteCnt); /* check on our logic here */ - memcpy(&ctx->b[ctx->h.bCnt],msg,n); + memcpy(&ctx->b[ctx->h.bCnt], msg, n); msgByteCnt -= n; msg += n; ctx->h.bCnt += n; } Skein_assert(ctx->h.bCnt == SKEIN_512_BLOCK_BYTES); - Skein_512_Process_Block(ctx,ctx->b,1,SKEIN_512_BLOCK_BYTES); + Skein_512_Process_Block(ctx, ctx->b, 1, SKEIN_512_BLOCK_BYTES); ctx->h.bCnt = 0; } /* now process any remaining full blocks, directly from input message data */ if (msgByteCnt > SKEIN_512_BLOCK_BYTES) { n = (msgByteCnt-1) / SKEIN_512_BLOCK_BYTES; /* number of full blocks to process */ - Skein_512_Process_Block(ctx,msg,n,SKEIN_512_BLOCK_BYTES); + Skein_512_Process_Block(ctx, msg, n, SKEIN_512_BLOCK_BYTES); msgByteCnt -= n * SKEIN_512_BLOCK_BYTES; msg += n * SKEIN_512_BLOCK_BYTES; } @@ -353,7 +353,7 @@ int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg, size_t msgByteCnt if (msgByteCnt) { Skein_assert(msgByteCnt + ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES); - memcpy(&ctx->b[ctx->h.bCnt],msg,msgByteCnt); + memcpy(&ctx->b[ctx->h.bCnt], msg, msgByteCnt); ctx->h.bCnt += msgByteCnt; } @@ -364,33 +364,33 @@ int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg, size_t msgByteCnt /* finalize the hash computation and output the result */ int Skein_512_Final(struct skein_512_ctx *ctx, u8 *hashVal) { - size_t i,n,byteCnt; + size_t i, n, byteCnt; u64 X[SKEIN_512_STATE_WORDS]; - Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ + Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ if (ctx->h.bCnt < SKEIN_512_BLOCK_BYTES) /* zero pad b[] if necessary */ - memset(&ctx->b[ctx->h.bCnt],0,SKEIN_512_BLOCK_BYTES - ctx->h.bCnt); + memset(&ctx->b[ctx->h.bCnt], 0, SKEIN_512_BLOCK_BYTES - ctx->h.bCnt); - Skein_512_Process_Block(ctx,ctx->b,1,ctx->h.bCnt); /* process the final block */ + Skein_512_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); /* process the final block */ /* now output the result */ byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ /* run Threefish in "counter mode" to generate output */ - memset(ctx->b,0,sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ - memcpy(X,ctx->X,sizeof(X)); /* keep a local copy of counter mode "key" */ - for (i=0;i*SKEIN_512_BLOCK_BYTES < byteCnt;i++) + memset(ctx->b, 0, sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ + memcpy(X, ctx->X, sizeof(X)); /* keep a local copy of counter mode "key" */ + for (i = 0; i*SKEIN_512_BLOCK_BYTES < byteCnt; i++) { - ((u64 *)ctx->b)[0]= Skein_Swap64((u64) i); /* build the counter block */ - Skein_Start_New_Type(ctx,OUT_FINAL); - Skein_512_Process_Block(ctx,ctx->b,1,sizeof(u64)); /* run "counter mode" */ + ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); /* build the counter block */ + Skein_Start_New_Type(ctx, OUT_FINAL); + Skein_512_Process_Block(ctx, ctx->b, 1, sizeof(u64)); /* run "counter mode" */ n = byteCnt - i*SKEIN_512_BLOCK_BYTES; /* number of output bytes left to go */ if (n >= SKEIN_512_BLOCK_BYTES) n = SKEIN_512_BLOCK_BYTES; - Skein_Put64_LSB_First(hashVal+i*SKEIN_512_BLOCK_BYTES,ctx->X,n); /* "output" the ctr mode bytes */ - Skein_Show_Final(512,&ctx->h,n,hashVal+i*SKEIN_512_BLOCK_BYTES); - memcpy(ctx->X,X,sizeof(X)); /* restore the counter mode key for next time */ + Skein_Put64_LSB_First(hashVal+i*SKEIN_512_BLOCK_BYTES, ctx->X, n); /* "output" the ctr mode bytes */ + Skein_Show_Final(512, &ctx->h, n, hashVal+i*SKEIN_512_BLOCK_BYTES); + memcpy(ctx->X, X, sizeof(X)); /* restore the counter mode key for next time */ } return SKEIN_SUCCESS; } @@ -409,39 +409,39 @@ int Skein1024_Init(struct skein1024_ctx *ctx, size_t hashBitLen) u64 w[SKEIN1024_STATE_WORDS]; } cfg; /* config block */ - Skein_Assert(hashBitLen > 0,SKEIN_BAD_HASHLEN); + Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN); ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ switch (hashBitLen) { /* use pre-computed values, where available */ case 512: - memcpy(ctx->X,SKEIN1024_IV_512 ,sizeof(ctx->X)); + memcpy(ctx->X, SKEIN1024_IV_512, sizeof(ctx->X)); break; case 384: - memcpy(ctx->X,SKEIN1024_IV_384 ,sizeof(ctx->X)); + memcpy(ctx->X, SKEIN1024_IV_384, sizeof(ctx->X)); break; case 1024: - memcpy(ctx->X,SKEIN1024_IV_1024,sizeof(ctx->X)); + memcpy(ctx->X, SKEIN1024_IV_1024, sizeof(ctx->X)); break; default: /* here if there is no precomputed IV value available */ /* build/process the config block, type == CONFIG (could be precomputed) */ - Skein_Start_New_Type(ctx,CFG_FINAL); /* set tweaks: T0=0; T1=CFG | FINAL */ + Skein_Start_New_Type(ctx, CFG_FINAL); /* set tweaks: T0=0; T1=CFG | FINAL */ cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); /* set the schema, version */ cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ cfg.w[2] = Skein_Swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); - memset(&cfg.w[3],0,sizeof(cfg) - 3*sizeof(cfg.w[0])); /* zero pad config block */ + memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); /* zero pad config block */ /* compute the initial chaining values from config block */ - memset(ctx->X,0,sizeof(ctx->X)); /* zero the chaining variables */ - Skein1024_Process_Block(ctx,cfg.b,1,SKEIN_CFG_STR_LEN); + memset(ctx->X, 0, sizeof(ctx->X)); /* zero the chaining variables */ + Skein1024_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); break; } /* The chaining vars ctx->X are now initialized for the given hashBitLen. */ /* Set up to process the data message portion of the hash (default) */ - Skein_Start_New_Type(ctx,MSG); /* T0=0, T1= MSG type */ + Skein_Start_New_Type(ctx, MSG); /* T0=0, T1= MSG type */ return SKEIN_SUCCESS; } @@ -449,7 +449,7 @@ int Skein1024_Init(struct skein1024_ctx *ctx, size_t hashBitLen) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a MAC and/or tree hash operation */ /* [identical to Skein1024_Init() when keyBytes == 0 && treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ -int Skein1024_InitExt(struct skein1024_ctx *ctx,size_t hashBitLen,u64 treeInfo, const u8 *key, size_t keyBytes) +int Skein1024_InitExt(struct skein1024_ctx *ctx, size_t hashBitLen, u64 treeInfo, const u8 *key, size_t keyBytes) { union { @@ -457,42 +457,42 @@ int Skein1024_InitExt(struct skein1024_ctx *ctx,size_t hashBitLen,u64 treeInfo, u64 w[SKEIN1024_STATE_WORDS]; } cfg; /* config block */ - Skein_Assert(hashBitLen > 0,SKEIN_BAD_HASHLEN); - Skein_Assert(keyBytes == 0 || key != NULL,SKEIN_FAIL); + Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN); + Skein_Assert(keyBytes == 0 || key != NULL, SKEIN_FAIL); /* compute the initial chaining values ctx->X[], based on key */ if (keyBytes == 0) /* is there a key? */ { - memset(ctx->X,0,sizeof(ctx->X)); /* no key: use all zeroes as key for config block */ + memset(ctx->X, 0, sizeof(ctx->X)); /* no key: use all zeroes as key for config block */ } else /* here to pre-process a key */ { Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); /* do a mini-Init right here */ - ctx->h.hashBitLen=8*sizeof(ctx->X); /* set output hash bit count = state size */ - Skein_Start_New_Type(ctx,KEY); /* set tweaks: T0 = 0; T1 = KEY type */ - memset(ctx->X,0,sizeof(ctx->X)); /* zero the initial chaining variables */ - Skein1024_Update(ctx,key,keyBytes); /* hash the key */ - Skein1024_Final_Pad(ctx,cfg.b); /* put result into cfg.b[] */ - memcpy(ctx->X,cfg.b,sizeof(cfg.b)); /* copy over into ctx->X[] */ + ctx->h.hashBitLen = 8*sizeof(ctx->X); /* set output hash bit count = state size */ + Skein_Start_New_Type(ctx, KEY); /* set tweaks: T0 = 0; T1 = KEY type */ + memset(ctx->X, 0, sizeof(ctx->X)); /* zero the initial chaining variables */ + Skein1024_Update(ctx, key, keyBytes); /* hash the key */ + Skein1024_Final_Pad(ctx, cfg.b); /* put result into cfg.b[] */ + memcpy(ctx->X, cfg.b, sizeof(cfg.b)); /* copy over into ctx->X[] */ } /* build/process the config block, type == CONFIG (could be precomputed for each key) */ ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ - Skein_Start_New_Type(ctx,CFG_FINAL); + Skein_Start_New_Type(ctx, CFG_FINAL); - memset(&cfg.w,0,sizeof(cfg.w)); /* pre-pad cfg.w[] with zeroes */ + memset(&cfg.w, 0, sizeof(cfg.w)); /* pre-pad cfg.w[] with zeroes */ cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ cfg.w[2] = Skein_Swap64(treeInfo); /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ - Skein_Show_Key(1024,&ctx->h,key,keyBytes); + Skein_Show_Key(1024, &ctx->h, key, keyBytes); /* compute the initial chaining values from config block */ - Skein1024_Process_Block(ctx,cfg.b,1,SKEIN_CFG_STR_LEN); + Skein1024_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); /* The chaining vars ctx->X are now initialized */ /* Set up to process the data message portion of the hash (default) */ - Skein_Start_New_Type(ctx,MSG); + Skein_Start_New_Type(ctx, MSG); return SKEIN_SUCCESS; } @@ -503,7 +503,7 @@ int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg, size_t msgByteCnt { size_t n; - Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ + Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ /* process full blocks, if any */ if (msgByteCnt + ctx->h.bCnt > SKEIN1024_BLOCK_BYTES) @@ -514,20 +514,20 @@ int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg, size_t msgByteCnt if (n) { Skein_assert(n < msgByteCnt); /* check on our logic here */ - memcpy(&ctx->b[ctx->h.bCnt],msg,n); + memcpy(&ctx->b[ctx->h.bCnt], msg, n); msgByteCnt -= n; msg += n; ctx->h.bCnt += n; } Skein_assert(ctx->h.bCnt == SKEIN1024_BLOCK_BYTES); - Skein1024_Process_Block(ctx,ctx->b,1,SKEIN1024_BLOCK_BYTES); + Skein1024_Process_Block(ctx, ctx->b, 1, SKEIN1024_BLOCK_BYTES); ctx->h.bCnt = 0; } /* now process any remaining full blocks, directly from input message data */ if (msgByteCnt > SKEIN1024_BLOCK_BYTES) { n = (msgByteCnt-1) / SKEIN1024_BLOCK_BYTES; /* number of full blocks to process */ - Skein1024_Process_Block(ctx,msg,n,SKEIN1024_BLOCK_BYTES); + Skein1024_Process_Block(ctx, msg, n, SKEIN1024_BLOCK_BYTES); msgByteCnt -= n * SKEIN1024_BLOCK_BYTES; msg += n * SKEIN1024_BLOCK_BYTES; } @@ -538,7 +538,7 @@ int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg, size_t msgByteCnt if (msgByteCnt) { Skein_assert(msgByteCnt + ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES); - memcpy(&ctx->b[ctx->h.bCnt],msg,msgByteCnt); + memcpy(&ctx->b[ctx->h.bCnt], msg, msgByteCnt); ctx->h.bCnt += msgByteCnt; } @@ -549,33 +549,33 @@ int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg, size_t msgByteCnt /* finalize the hash computation and output the result */ int Skein1024_Final(struct skein1024_ctx *ctx, u8 *hashVal) { - size_t i,n,byteCnt; + size_t i, n, byteCnt; u64 X[SKEIN1024_STATE_WORDS]; - Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ + Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ if (ctx->h.bCnt < SKEIN1024_BLOCK_BYTES) /* zero pad b[] if necessary */ - memset(&ctx->b[ctx->h.bCnt],0,SKEIN1024_BLOCK_BYTES - ctx->h.bCnt); + memset(&ctx->b[ctx->h.bCnt], 0, SKEIN1024_BLOCK_BYTES - ctx->h.bCnt); - Skein1024_Process_Block(ctx,ctx->b,1,ctx->h.bCnt); /* process the final block */ + Skein1024_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); /* process the final block */ /* now output the result */ byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ /* run Threefish in "counter mode" to generate output */ - memset(ctx->b,0,sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ - memcpy(X,ctx->X,sizeof(X)); /* keep a local copy of counter mode "key" */ - for (i=0;i*SKEIN1024_BLOCK_BYTES < byteCnt;i++) + memset(ctx->b, 0, sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ + memcpy(X, ctx->X, sizeof(X)); /* keep a local copy of counter mode "key" */ + for (i = 0; i*SKEIN1024_BLOCK_BYTES < byteCnt; i++) { - ((u64 *)ctx->b)[0]= Skein_Swap64((u64) i); /* build the counter block */ - Skein_Start_New_Type(ctx,OUT_FINAL); - Skein1024_Process_Block(ctx,ctx->b,1,sizeof(u64)); /* run "counter mode" */ + ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); /* build the counter block */ + Skein_Start_New_Type(ctx, OUT_FINAL); + Skein1024_Process_Block(ctx, ctx->b, 1, sizeof(u64)); /* run "counter mode" */ n = byteCnt - i*SKEIN1024_BLOCK_BYTES; /* number of output bytes left to go */ if (n >= SKEIN1024_BLOCK_BYTES) n = SKEIN1024_BLOCK_BYTES; - Skein_Put64_LSB_First(hashVal+i*SKEIN1024_BLOCK_BYTES,ctx->X,n); /* "output" the ctr mode bytes */ - Skein_Show_Final(1024,&ctx->h,n,hashVal+i*SKEIN1024_BLOCK_BYTES); - memcpy(ctx->X,X,sizeof(X)); /* restore the counter mode key for next time */ + Skein_Put64_LSB_First(hashVal+i*SKEIN1024_BLOCK_BYTES, ctx->X, n); /* "output" the ctr mode bytes */ + Skein_Show_Final(1024, &ctx->h, n, hashVal+i*SKEIN1024_BLOCK_BYTES); + memcpy(ctx->X, X, sizeof(X)); /* restore the counter mode key for next time */ } return SKEIN_SUCCESS; } @@ -587,14 +587,14 @@ int Skein1024_Final(struct skein1024_ctx *ctx, u8 *hashVal) /* finalize the hash computation and output the block, no OUTPUT stage */ int Skein_256_Final_Pad(struct skein_256_ctx *ctx, u8 *hashVal) { - Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ + Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ if (ctx->h.bCnt < SKEIN_256_BLOCK_BYTES) /* zero pad b[] if necessary */ - memset(&ctx->b[ctx->h.bCnt],0,SKEIN_256_BLOCK_BYTES - ctx->h.bCnt); - Skein_256_Process_Block(ctx,ctx->b,1,ctx->h.bCnt); /* process the final block */ + memset(&ctx->b[ctx->h.bCnt], 0, SKEIN_256_BLOCK_BYTES - ctx->h.bCnt); + Skein_256_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); /* process the final block */ - Skein_Put64_LSB_First(hashVal,ctx->X,SKEIN_256_BLOCK_BYTES); /* "output" the state bytes */ + Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN_256_BLOCK_BYTES); /* "output" the state bytes */ return SKEIN_SUCCESS; } @@ -603,14 +603,14 @@ int Skein_256_Final_Pad(struct skein_256_ctx *ctx, u8 *hashVal) /* finalize the hash computation and output the block, no OUTPUT stage */ int Skein_512_Final_Pad(struct skein_512_ctx *ctx, u8 *hashVal) { - Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ + Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ if (ctx->h.bCnt < SKEIN_512_BLOCK_BYTES) /* zero pad b[] if necessary */ - memset(&ctx->b[ctx->h.bCnt],0,SKEIN_512_BLOCK_BYTES - ctx->h.bCnt); - Skein_512_Process_Block(ctx,ctx->b,1,ctx->h.bCnt); /* process the final block */ + memset(&ctx->b[ctx->h.bCnt], 0, SKEIN_512_BLOCK_BYTES - ctx->h.bCnt); + Skein_512_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); /* process the final block */ - Skein_Put64_LSB_First(hashVal,ctx->X,SKEIN_512_BLOCK_BYTES); /* "output" the state bytes */ + Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN_512_BLOCK_BYTES); /* "output" the state bytes */ return SKEIN_SUCCESS; } @@ -619,14 +619,14 @@ int Skein_512_Final_Pad(struct skein_512_ctx *ctx, u8 *hashVal) /* finalize the hash computation and output the block, no OUTPUT stage */ int Skein1024_Final_Pad(struct skein1024_ctx *ctx, u8 *hashVal) { - Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ + Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ if (ctx->h.bCnt < SKEIN1024_BLOCK_BYTES) /* zero pad b[] if necessary */ - memset(&ctx->b[ctx->h.bCnt],0,SKEIN1024_BLOCK_BYTES - ctx->h.bCnt); - Skein1024_Process_Block(ctx,ctx->b,1,ctx->h.bCnt); /* process the final block */ + memset(&ctx->b[ctx->h.bCnt], 0, SKEIN1024_BLOCK_BYTES - ctx->h.bCnt); + Skein1024_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); /* process the final block */ - Skein_Put64_LSB_First(hashVal,ctx->X,SKEIN1024_BLOCK_BYTES); /* "output" the state bytes */ + Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN1024_BLOCK_BYTES); /* "output" the state bytes */ return SKEIN_SUCCESS; } @@ -636,27 +636,27 @@ int Skein1024_Final_Pad(struct skein1024_ctx *ctx, u8 *hashVal) /* just do the OUTPUT stage */ int Skein_256_Output(struct skein_256_ctx *ctx, u8 *hashVal) { - size_t i,n,byteCnt; + size_t i, n, byteCnt; u64 X[SKEIN_256_STATE_WORDS]; - Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ + Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ /* now output the result */ byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ /* run Threefish in "counter mode" to generate output */ - memset(ctx->b,0,sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ - memcpy(X,ctx->X,sizeof(X)); /* keep a local copy of counter mode "key" */ - for (i=0;i*SKEIN_256_BLOCK_BYTES < byteCnt;i++) + memset(ctx->b, 0, sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ + memcpy(X, ctx->X, sizeof(X)); /* keep a local copy of counter mode "key" */ + for (i = 0; i*SKEIN_256_BLOCK_BYTES < byteCnt; i++) { - ((u64 *)ctx->b)[0]= Skein_Swap64((u64) i); /* build the counter block */ - Skein_Start_New_Type(ctx,OUT_FINAL); - Skein_256_Process_Block(ctx,ctx->b,1,sizeof(u64)); /* run "counter mode" */ + ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); /* build the counter block */ + Skein_Start_New_Type(ctx, OUT_FINAL); + Skein_256_Process_Block(ctx, ctx->b, 1, sizeof(u64)); /* run "counter mode" */ n = byteCnt - i*SKEIN_256_BLOCK_BYTES; /* number of output bytes left to go */ if (n >= SKEIN_256_BLOCK_BYTES) n = SKEIN_256_BLOCK_BYTES; - Skein_Put64_LSB_First(hashVal+i*SKEIN_256_BLOCK_BYTES,ctx->X,n); /* "output" the ctr mode bytes */ - Skein_Show_Final(256,&ctx->h,n,hashVal+i*SKEIN_256_BLOCK_BYTES); - memcpy(ctx->X,X,sizeof(X)); /* restore the counter mode key for next time */ + Skein_Put64_LSB_First(hashVal+i*SKEIN_256_BLOCK_BYTES, ctx->X, n); /* "output" the ctr mode bytes */ + Skein_Show_Final(256, &ctx->h, n, hashVal+i*SKEIN_256_BLOCK_BYTES); + memcpy(ctx->X, X, sizeof(X)); /* restore the counter mode key for next time */ } return SKEIN_SUCCESS; } @@ -665,27 +665,27 @@ int Skein_256_Output(struct skein_256_ctx *ctx, u8 *hashVal) /* just do the OUTPUT stage */ int Skein_512_Output(struct skein_512_ctx *ctx, u8 *hashVal) { - size_t i,n,byteCnt; + size_t i, n, byteCnt; u64 X[SKEIN_512_STATE_WORDS]; - Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ + Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ /* now output the result */ byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ /* run Threefish in "counter mode" to generate output */ - memset(ctx->b,0,sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ - memcpy(X,ctx->X,sizeof(X)); /* keep a local copy of counter mode "key" */ - for (i=0;i*SKEIN_512_BLOCK_BYTES < byteCnt;i++) + memset(ctx->b, 0, sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ + memcpy(X, ctx->X, sizeof(X)); /* keep a local copy of counter mode "key" */ + for (i = 0; i*SKEIN_512_BLOCK_BYTES < byteCnt; i++) { - ((u64 *)ctx->b)[0]= Skein_Swap64((u64) i); /* build the counter block */ - Skein_Start_New_Type(ctx,OUT_FINAL); - Skein_512_Process_Block(ctx,ctx->b,1,sizeof(u64)); /* run "counter mode" */ + ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); /* build the counter block */ + Skein_Start_New_Type(ctx, OUT_FINAL); + Skein_512_Process_Block(ctx, ctx->b, 1, sizeof(u64)); /* run "counter mode" */ n = byteCnt - i*SKEIN_512_BLOCK_BYTES; /* number of output bytes left to go */ if (n >= SKEIN_512_BLOCK_BYTES) n = SKEIN_512_BLOCK_BYTES; - Skein_Put64_LSB_First(hashVal+i*SKEIN_512_BLOCK_BYTES,ctx->X,n); /* "output" the ctr mode bytes */ - Skein_Show_Final(256,&ctx->h,n,hashVal+i*SKEIN_512_BLOCK_BYTES); - memcpy(ctx->X,X,sizeof(X)); /* restore the counter mode key for next time */ + Skein_Put64_LSB_First(hashVal+i*SKEIN_512_BLOCK_BYTES, ctx->X, n); /* "output" the ctr mode bytes */ + Skein_Show_Final(256, &ctx->h, n, hashVal+i*SKEIN_512_BLOCK_BYTES); + memcpy(ctx->X, X, sizeof(X)); /* restore the counter mode key for next time */ } return SKEIN_SUCCESS; } @@ -694,27 +694,27 @@ int Skein_512_Output(struct skein_512_ctx *ctx, u8 *hashVal) /* just do the OUTPUT stage */ int Skein1024_Output(struct skein1024_ctx *ctx, u8 *hashVal) { - size_t i,n,byteCnt; + size_t i, n, byteCnt; u64 X[SKEIN1024_STATE_WORDS]; - Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ + Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ /* now output the result */ byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ /* run Threefish in "counter mode" to generate output */ - memset(ctx->b,0,sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ - memcpy(X,ctx->X,sizeof(X)); /* keep a local copy of counter mode "key" */ - for (i=0;i*SKEIN1024_BLOCK_BYTES < byteCnt;i++) + memset(ctx->b, 0, sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ + memcpy(X, ctx->X, sizeof(X)); /* keep a local copy of counter mode "key" */ + for (i = 0; i*SKEIN1024_BLOCK_BYTES < byteCnt; i++) { - ((u64 *)ctx->b)[0]= Skein_Swap64((u64) i); /* build the counter block */ - Skein_Start_New_Type(ctx,OUT_FINAL); - Skein1024_Process_Block(ctx,ctx->b,1,sizeof(u64)); /* run "counter mode" */ + ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); /* build the counter block */ + Skein_Start_New_Type(ctx, OUT_FINAL); + Skein1024_Process_Block(ctx, ctx->b, 1, sizeof(u64)); /* run "counter mode" */ n = byteCnt - i*SKEIN1024_BLOCK_BYTES; /* number of output bytes left to go */ if (n >= SKEIN1024_BLOCK_BYTES) n = SKEIN1024_BLOCK_BYTES; - Skein_Put64_LSB_First(hashVal+i*SKEIN1024_BLOCK_BYTES,ctx->X,n); /* "output" the ctr mode bytes */ - Skein_Show_Final(256,&ctx->h,n,hashVal+i*SKEIN1024_BLOCK_BYTES); - memcpy(ctx->X,X,sizeof(X)); /* restore the counter mode key for next time */ + Skein_Put64_LSB_First(hashVal+i*SKEIN1024_BLOCK_BYTES, ctx->X, n); /* "output" the ctr mode bytes */ + Skein_Show_Final(256, &ctx->h, n, hashVal+i*SKEIN1024_BLOCK_BYTES); + memcpy(ctx->X, X, sizeof(X)); /* restore the counter mode key for next time */ } return SKEIN_SUCCESS; } diff --git a/drivers/staging/skein/skeinApi.c b/drivers/staging/skein/skeinApi.c index df92806c4ec4..a3f471be8db3 100755 --- a/drivers/staging/skein/skeinApi.c +++ b/drivers/staging/skein/skeinApi.c @@ -31,7 +31,7 @@ int skeinCtxPrepare(struct skein_ctx *ctx, enum skein_size size) { Skein_Assert(ctx && size, SKEIN_FAIL); - memset(ctx ,0, sizeof(struct skein_ctx)); + memset(ctx , 0, sizeof(struct skein_ctx)); ctx->skeinSize = size; return SKEIN_SUCCESS; @@ -97,18 +97,18 @@ int skeinMacInit(struct skein_ctx *ctx, const u8 *key, size_t keyLen, case Skein256: ret = Skein_256_InitExt(&ctx->m.s256, hashBitLen, treeInfo, - (const u8*)key, keyLen); + (const u8 *)key, keyLen); break; case Skein512: ret = Skein_512_InitExt(&ctx->m.s512, hashBitLen, treeInfo, - (const u8*)key, keyLen); + (const u8 *)key, keyLen); break; case Skein1024: ret = Skein1024_InitExt(&ctx->m.s1024, hashBitLen, treeInfo, - (const u8*)key, keyLen); + (const u8 *)key, keyLen); break; } @@ -146,13 +146,13 @@ int skeinUpdate(struct skein_ctx *ctx, const u8 *msg, switch (ctx->skeinSize) { case Skein256: - ret = Skein_256_Update(&ctx->m.s256, (const u8*)msg, msgByteCnt); + ret = Skein_256_Update(&ctx->m.s256, (const u8 *)msg, msgByteCnt); break; case Skein512: - ret = Skein_512_Update(&ctx->m.s512, (const u8*)msg, msgByteCnt); + ret = Skein_512_Update(&ctx->m.s512, (const u8 *)msg, msgByteCnt); break; case Skein1024: - ret = Skein1024_Update(&ctx->m.s1024, (const u8*)msg, msgByteCnt); + ret = Skein1024_Update(&ctx->m.s1024, (const u8 *)msg, msgByteCnt); break; } return ret; @@ -186,7 +186,7 @@ int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg, * Skein's real partial block buffer. * If this layout ever changes we have to adapt this as well. */ - up = (u8*)ctx->m.s256.X + ctx->skeinSize / 8; + up = (u8 *)ctx->m.s256.X + ctx->skeinSize / 8; Skein_Set_Bit_Pad_Flag(ctx->m.h); /* set tweak flag for the skeinFinal call */ @@ -206,13 +206,13 @@ int skeinFinal(struct skein_ctx *ctx, u8 *hash) switch (ctx->skeinSize) { case Skein256: - ret = Skein_256_Final(&ctx->m.s256, (u8*)hash); + ret = Skein_256_Final(&ctx->m.s256, (u8 *)hash); break; case Skein512: - ret = Skein_512_Final(&ctx->m.s512, (u8*)hash); + ret = Skein_512_Final(&ctx->m.s512, (u8 *)hash); break; case Skein1024: - ret = Skein1024_Final(&ctx->m.s1024, (u8*)hash); + ret = Skein1024_Final(&ctx->m.s1024, (u8 *)hash); break; } return ret; diff --git a/drivers/staging/skein/skeinBlockNo3F.c b/drivers/staging/skein/skeinBlockNo3F.c index b483f3dbc27c..d98933eeb0bf 100644 --- a/drivers/staging/skein/skeinBlockNo3F.c +++ b/drivers/staging/skein/skeinBlockNo3F.c @@ -147,16 +147,16 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, blkPtr += SKEIN1024_BLOCK_BYTES; /* do the final "feedforward" xor, update context chaining vars */ - ctx->X[ 0] = ctx->X[ 0] ^ w[ 0]; - ctx->X[ 1] = ctx->X[ 1] ^ w[ 1]; - ctx->X[ 2] = ctx->X[ 2] ^ w[ 2]; - ctx->X[ 3] = ctx->X[ 3] ^ w[ 3]; - ctx->X[ 4] = ctx->X[ 4] ^ w[ 4]; - ctx->X[ 5] = ctx->X[ 5] ^ w[ 5]; - ctx->X[ 6] = ctx->X[ 6] ^ w[ 6]; - ctx->X[ 7] = ctx->X[ 7] ^ w[ 7]; - ctx->X[ 8] = ctx->X[ 8] ^ w[ 8]; - ctx->X[ 9] = ctx->X[ 9] ^ w[ 9]; + ctx->X[0] = ctx->X[0] ^ w[0]; + ctx->X[1] = ctx->X[1] ^ w[1]; + ctx->X[2] = ctx->X[2] ^ w[2]; + ctx->X[3] = ctx->X[3] ^ w[3]; + ctx->X[4] = ctx->X[4] ^ w[4]; + ctx->X[5] = ctx->X[5] ^ w[5]; + ctx->X[6] = ctx->X[6] ^ w[6]; + ctx->X[7] = ctx->X[7] ^ w[7]; + ctx->X[8] = ctx->X[8] ^ w[8]; + ctx->X[9] = ctx->X[9] ^ w[9]; ctx->X[10] = ctx->X[10] ^ w[10]; ctx->X[11] = ctx->X[11] ^ w[11]; ctx->X[12] = ctx->X[12] ^ w[12]; diff --git a/drivers/staging/skein/skein_block.c b/drivers/staging/skein/skein_block.c index 246af8156e90..e62b6442783e 100644 --- a/drivers/staging/skein/skein_block.c +++ b/drivers/staging/skein/skein_block.c @@ -39,16 +39,15 @@ /***************************** Skein_256 ******************************/ #if !(SKEIN_USE_ASM & 256) -void Skein_256_Process_Block(struct skein_256_ctx *ctx,const u8 *blkPtr,size_t blkCnt,size_t byteCntAdd) +void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, size_t blkCnt, size_t byteCntAdd) { /* do it in C */ - enum - { + enum { WCNT = SKEIN_256_STATE_WORDS }; #undef RCNT #define RCNT (SKEIN_256_ROUNDS_TOTAL/8) -#ifdef SKEIN_LOOP /* configure how much to unroll the loop */ +#ifdef SKEIN_LOOP /* configure how much to unroll the loop */ #define SKEIN_UNROLL_256 (((SKEIN_LOOP)/100)%10) #else #define SKEIN_UNROLL_256 (0) @@ -63,8 +62,8 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx,const u8 *blkPtr,size_t b #else u64 kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ #endif - u64 X0,X1,X2,X3; /* local copy of context vars, for speed */ - u64 w [WCNT]; /* local copy of input block */ + u64 X0, X1, X2, X3; /* local copy of context vars, for speed */ + u64 w[WCNT]; /* local copy of input block */ #ifdef SKEIN_DEBUG const u64 *Xptr[4]; /* use for debugging (help compiler put Xn in registers) */ Xptr[0] = &X0; Xptr[1] = &X1; Xptr[2] = &X2; Xptr[3] = &X3; @@ -85,95 +84,95 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx,const u8 *blkPtr,size_t b ts[2] = ts[0] ^ ts[1]; - Skein_Get64_LSB_First(w,blkPtr,WCNT); /* get input block in little-endian format */ + Skein_Get64_LSB_First(w, blkPtr, WCNT); /* get input block in little-endian format */ DebugSaveTweak(ctx); - Skein_Show_Block(BLK_BITS,&ctx->h,ctx->X,blkPtr,w,ks,ts); + Skein_Show_Block(BLK_BITS, &ctx->h, ctx->X, blkPtr, w, ks, ts); X0 = w[0] + ks[0]; /* do the first full key injection */ X1 = w[1] + ks[1] + ts[0]; X2 = w[2] + ks[2] + ts[1]; X3 = w[3] + ks[3]; - Skein_Show_R_Ptr(BLK_BITS,&ctx->h,SKEIN_RND_KEY_INITIAL,Xptr); /* show starting state values */ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, Xptr); /* show starting state values */ blkPtr += SKEIN_256_BLOCK_BYTES; /* run the rounds */ -#define Round256(p0,p1,p2,p3,ROT,rNum) \ - X##p0 += X##p1; X##p1 = RotL_64(X##p1,ROT##_0); X##p1 ^= X##p0; \ - X##p2 += X##p3; X##p3 = RotL_64(X##p3,ROT##_1); X##p3 ^= X##p2; \ +#define Round256(p0, p1, p2, p3, ROT, rNum) \ + X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ + X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ #if SKEIN_UNROLL_256 == 0 -#define R256(p0,p1,p2,p3,ROT,rNum) /* fully unrolled */ \ - Round256(p0,p1,p2,p3,ROT,rNum) \ - Skein_Show_R_Ptr(BLK_BITS,&ctx->h,rNum,Xptr); +#define R256(p0, p1, p2, p3, ROT, rNum) /* fully unrolled */ \ + Round256(p0, p1, p2, p3, ROT, rNum) \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rNum, Xptr); #define I256(R) \ X0 += ks[((R)+1) % 5]; /* inject the key schedule value */ \ X1 += ks[((R)+2) % 5] + ts[((R)+1) % 3]; \ X2 += ks[((R)+3) % 5] + ts[((R)+2) % 3]; \ X3 += ks[((R)+4) % 5] + (R)+1; \ - Skein_Show_R_Ptr(BLK_BITS,&ctx->h,SKEIN_RND_KEY_INJECT,Xptr); + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); #else /* looping version */ -#define R256(p0,p1,p2,p3,ROT,rNum) \ - Round256(p0,p1,p2,p3,ROT,rNum) \ - Skein_Show_R_Ptr(BLK_BITS,&ctx->h,4*(r-1)+rNum,Xptr); +#define R256(p0, p1, p2, p3, ROT, rNum) \ + Round256(p0, p1, p2, p3, ROT, rNum) \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rNum, Xptr); #define I256(R) \ X0 += ks[r+(R)+0]; /* inject the key schedule value */ \ X1 += ks[r+(R)+1] + ts[r+(R)+0]; \ X2 += ks[r+(R)+2] + ts[r+(R)+1]; \ - X3 += ks[r+(R)+3] + r+(R) ; \ - ks[r + (R)+4 ] = ks[r+(R)-1]; /* rotate key schedule */\ - ts[r + (R)+2 ] = ts[r+(R)-1]; \ - Skein_Show_R_Ptr(BLK_BITS,&ctx->h,SKEIN_RND_KEY_INJECT,Xptr); + X3 += ks[r+(R)+3] + r+(R); \ + ks[r + (R) + 4] = ks[r + (R) - 1]; /* rotate key schedule */\ + ts[r + (R) + 2] = ts[r + (R) - 1]; \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); - for (r=1;r < 2*RCNT;r+=2*SKEIN_UNROLL_256) /* loop thru it */ + for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_256) /* loop thru it */ #endif { #define R256_8_rounds(R) \ - R256(0,1,2,3,R_256_0,8*(R) + 1); \ - R256(0,3,2,1,R_256_1,8*(R) + 2); \ - R256(0,1,2,3,R_256_2,8*(R) + 3); \ - R256(0,3,2,1,R_256_3,8*(R) + 4); \ - I256(2*(R)); \ - R256(0,1,2,3,R_256_4,8*(R) + 5); \ - R256(0,3,2,1,R_256_5,8*(R) + 6); \ - R256(0,1,2,3,R_256_6,8*(R) + 7); \ - R256(0,3,2,1,R_256_7,8*(R) + 8); \ - I256(2*(R)+1); - - R256_8_rounds( 0); + R256(0, 1, 2, 3, R_256_0, 8 * (R) + 1); \ + R256(0, 3, 2, 1, R_256_1, 8 * (R) + 2); \ + R256(0, 1, 2, 3, R_256_2, 8 * (R) + 3); \ + R256(0, 3, 2, 1, R_256_3, 8 * (R) + 4); \ + I256(2 * (R)); \ + R256(0, 1, 2, 3, R_256_4, 8 * (R) + 5); \ + R256(0, 3, 2, 1, R_256_5, 8 * (R) + 6); \ + R256(0, 1, 2, 3, R_256_6, 8 * (R) + 7); \ + R256(0, 3, 2, 1, R_256_7, 8 * (R) + 8); \ + I256(2 * (R) + 1); + + R256_8_rounds(0); #define R256_Unroll_R(NN) ((SKEIN_UNROLL_256 == 0 && SKEIN_256_ROUNDS_TOTAL/8 > (NN)) || (SKEIN_UNROLL_256 > (NN))) - #if R256_Unroll_R( 1) - R256_8_rounds( 1); + #if R256_Unroll_R(1) + R256_8_rounds(1); #endif - #if R256_Unroll_R( 2) - R256_8_rounds( 2); + #if R256_Unroll_R(2) + R256_8_rounds(2); #endif - #if R256_Unroll_R( 3) - R256_8_rounds( 3); + #if R256_Unroll_R(3) + R256_8_rounds(3); #endif - #if R256_Unroll_R( 4) - R256_8_rounds( 4); + #if R256_Unroll_R(4) + R256_8_rounds(4); #endif - #if R256_Unroll_R( 5) - R256_8_rounds( 5); + #if R256_Unroll_R(5) + R256_8_rounds(5); #endif - #if R256_Unroll_R( 6) - R256_8_rounds( 6); + #if R256_Unroll_R(6) + R256_8_rounds(6); #endif - #if R256_Unroll_R( 7) - R256_8_rounds( 7); + #if R256_Unroll_R(7) + R256_8_rounds(7); #endif - #if R256_Unroll_R( 8) - R256_8_rounds( 8); + #if R256_Unroll_R(8) + R256_8_rounds(8); #endif - #if R256_Unroll_R( 9) - R256_8_rounds( 9); + #if R256_Unroll_R(9) + R256_8_rounds(9); #endif #if R256_Unroll_R(10) R256_8_rounds(10); @@ -200,7 +199,7 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx,const u8 *blkPtr,size_t b ctx->X[2] = X2 ^ w[2]; ctx->X[3] = X3 ^ w[3]; - Skein_Show_Round(BLK_BITS,&ctx->h,SKEIN_RND_FEED_FWD,ctx->X); + Skein_Show_Round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X); ts[1] &= ~SKEIN_T1_FLAG_FIRST; } @@ -224,16 +223,15 @@ unsigned int Skein_256_Unroll_Cnt(void) /***************************** Skein_512 ******************************/ #if !(SKEIN_USE_ASM & 512) -void Skein_512_Process_Block(struct skein_512_ctx *ctx,const u8 *blkPtr,size_t blkCnt,size_t byteCntAdd) +void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, size_t blkCnt, size_t byteCntAdd) { /* do it in C */ - enum - { + enum { WCNT = SKEIN_512_STATE_WORDS }; #undef RCNT #define RCNT (SKEIN_512_ROUNDS_TOTAL/8) -#ifdef SKEIN_LOOP /* configure how much to unroll the loop */ +#ifdef SKEIN_LOOP /* configure how much to unroll the loop */ #define SKEIN_UNROLL_512 (((SKEIN_LOOP)/10)%10) #else #define SKEIN_UNROLL_512 (0) @@ -248,8 +246,8 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx,const u8 *blkPtr,size_t b #else u64 kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ #endif - u64 X0,X1,X2,X3,X4,X5,X6,X7; /* local copy of vars, for speed */ - u64 w [WCNT]; /* local copy of input block */ + u64 X0, X1, X2, X3, X4, X5, X6, X7; /* local copy of vars, for speed */ + u64 w[WCNT]; /* local copy of input block */ #ifdef SKEIN_DEBUG const u64 *Xptr[8]; /* use for debugging (help compiler put Xn in registers) */ Xptr[0] = &X0; Xptr[1] = &X1; Xptr[2] = &X2; Xptr[3] = &X3; @@ -277,9 +275,9 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx,const u8 *blkPtr,size_t b ts[2] = ts[0] ^ ts[1]; - Skein_Get64_LSB_First(w,blkPtr,WCNT); /* get input block in little-endian format */ + Skein_Get64_LSB_First(w, blkPtr, WCNT); /* get input block in little-endian format */ DebugSaveTweak(ctx); - Skein_Show_Block(BLK_BITS,&ctx->h,ctx->X,blkPtr,w,ks,ts); + Skein_Show_Block(BLK_BITS, &ctx->h, ctx->X, blkPtr, w, ks, ts); X0 = w[0] + ks[0]; /* do the first full key injection */ X1 = w[1] + ks[1]; @@ -292,92 +290,92 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx,const u8 *blkPtr,size_t b blkPtr += SKEIN_512_BLOCK_BYTES; - Skein_Show_R_Ptr(BLK_BITS,&ctx->h,SKEIN_RND_KEY_INITIAL,Xptr); + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, Xptr); /* run the rounds */ -#define Round512(p0,p1,p2,p3,p4,p5,p6,p7,ROT,rNum) \ - X##p0 += X##p1; X##p1 = RotL_64(X##p1,ROT##_0); X##p1 ^= X##p0; \ - X##p2 += X##p3; X##p3 = RotL_64(X##p3,ROT##_1); X##p3 ^= X##p2; \ - X##p4 += X##p5; X##p5 = RotL_64(X##p5,ROT##_2); X##p5 ^= X##p4; \ - X##p6 += X##p7; X##p7 = RotL_64(X##p7,ROT##_3); X##p7 ^= X##p6; \ +#define Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \ + X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ + X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ + X##p4 += X##p5; X##p5 = RotL_64(X##p5, ROT##_2); X##p5 ^= X##p4; \ + X##p6 += X##p7; X##p7 = RotL_64(X##p7, ROT##_3); X##p7 ^= X##p6; \ #if SKEIN_UNROLL_512 == 0 -#define R512(p0,p1,p2,p3,p4,p5,p6,p7,ROT,rNum) /* unrolled */ \ - Round512(p0,p1,p2,p3,p4,p5,p6,p7,ROT,rNum) \ - Skein_Show_R_Ptr(BLK_BITS,&ctx->h,rNum,Xptr); +#define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) /* unrolled */ \ + Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rNum, Xptr); #define I512(R) \ - X0 += ks[((R)+1) % 9]; /* inject the key schedule value */ \ - X1 += ks[((R)+2) % 9]; \ - X2 += ks[((R)+3) % 9]; \ - X3 += ks[((R)+4) % 9]; \ - X4 += ks[((R)+5) % 9]; \ - X5 += ks[((R)+6) % 9] + ts[((R)+1) % 3]; \ - X6 += ks[((R)+7) % 9] + ts[((R)+2) % 3]; \ - X7 += ks[((R)+8) % 9] + (R)+1; \ - Skein_Show_R_Ptr(BLK_BITS,&ctx->h,SKEIN_RND_KEY_INJECT,Xptr); + X0 += ks[((R) + 1) % 9]; /* inject the key schedule value */ \ + X1 += ks[((R) + 2) % 9]; \ + X2 += ks[((R) + 3) % 9]; \ + X3 += ks[((R) + 4) % 9]; \ + X4 += ks[((R) + 5) % 9]; \ + X5 += ks[((R) + 6) % 9] + ts[((R) + 1) % 3]; \ + X6 += ks[((R) + 7) % 9] + ts[((R) + 2) % 3]; \ + X7 += ks[((R) + 8) % 9] + (R) + 1; \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); #else /* looping version */ -#define R512(p0,p1,p2,p3,p4,p5,p6,p7,ROT,rNum) \ - Round512(p0,p1,p2,p3,p4,p5,p6,p7,ROT,rNum) \ - Skein_Show_R_Ptr(BLK_BITS,&ctx->h,4*(r-1)+rNum,Xptr); +#define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \ + Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rNum, Xptr); #define I512(R) \ - X0 += ks[r+(R)+0]; /* inject the key schedule value */ \ - X1 += ks[r+(R)+1]; \ - X2 += ks[r+(R)+2]; \ - X3 += ks[r+(R)+3]; \ - X4 += ks[r+(R)+4]; \ - X5 += ks[r+(R)+5] + ts[r+(R)+0]; \ - X6 += ks[r+(R)+6] + ts[r+(R)+1]; \ - X7 += ks[r+(R)+7] + r+(R) ; \ - ks[r + (R)+8] = ks[r+(R)-1]; /* rotate key schedule */ \ - ts[r + (R)+2] = ts[r+(R)-1]; \ - Skein_Show_R_Ptr(BLK_BITS,&ctx->h,SKEIN_RND_KEY_INJECT,Xptr); - - for (r=1;r < 2*RCNT;r+=2*SKEIN_UNROLL_512) /* loop thru it */ + X0 += ks[r + (R) + 0]; /* inject the key schedule value */ \ + X1 += ks[r + (R) + 1]; \ + X2 += ks[r + (R) + 2]; \ + X3 += ks[r + (R) + 3]; \ + X4 += ks[r + (R) + 4]; \ + X5 += ks[r + (R) + 5] + ts[r + (R) + 0]; \ + X6 += ks[r + (R) + 6] + ts[r + (R) + 1]; \ + X7 += ks[r + (R) + 7] + r + (R); \ + ks[r + (R) + 8] = ks[r + (R) - 1]; /* rotate key schedule */ \ + ts[r + (R) + 2] = ts[r + (R) - 1]; \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); + + for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_512) /* loop thru it */ #endif /* end of looped code definitions */ { #define R512_8_rounds(R) /* do 8 full rounds */ \ - R512(0,1,2,3,4,5,6,7,R_512_0,8*(R)+ 1); \ - R512(2,1,4,7,6,5,0,3,R_512_1,8*(R)+ 2); \ - R512(4,1,6,3,0,5,2,7,R_512_2,8*(R)+ 3); \ - R512(6,1,0,7,2,5,4,3,R_512_3,8*(R)+ 4); \ - I512(2*(R)); \ - R512(0,1,2,3,4,5,6,7,R_512_4,8*(R)+ 5); \ - R512(2,1,4,7,6,5,0,3,R_512_5,8*(R)+ 6); \ - R512(4,1,6,3,0,5,2,7,R_512_6,8*(R)+ 7); \ - R512(6,1,0,7,2,5,4,3,R_512_7,8*(R)+ 8); \ - I512(2*(R)+1); /* and key injection */ - - R512_8_rounds( 0); + R512(0, 1, 2, 3, 4, 5, 6, 7, R_512_0, 8 * (R) + 1); \ + R512(2, 1, 4, 7, 6, 5, 0, 3, R_512_1, 8 * (R) + 2); \ + R512(4, 1, 6, 3, 0, 5, 2, 7, R_512_2, 8 * (R) + 3); \ + R512(6, 1, 0, 7, 2, 5, 4, 3, R_512_3, 8 * (R) + 4); \ + I512(2 * (R)); \ + R512(0, 1, 2, 3, 4, 5, 6, 7, R_512_4, 8 * (R) + 5); \ + R512(2, 1, 4, 7, 6, 5, 0, 3, R_512_5, 8 * (R) + 6); \ + R512(4, 1, 6, 3, 0, 5, 2, 7, R_512_6, 8 * (R) + 7); \ + R512(6, 1, 0, 7, 2, 5, 4, 3, R_512_7, 8 * (R) + 8); \ + I512(2 * (R) + 1); /* and key injection */ + + R512_8_rounds(0); #define R512_Unroll_R(NN) ((SKEIN_UNROLL_512 == 0 && SKEIN_512_ROUNDS_TOTAL/8 > (NN)) || (SKEIN_UNROLL_512 > (NN))) - #if R512_Unroll_R( 1) - R512_8_rounds( 1); + #if R512_Unroll_R(1) + R512_8_rounds(1); #endif - #if R512_Unroll_R( 2) - R512_8_rounds( 2); + #if R512_Unroll_R(2) + R512_8_rounds(2); #endif - #if R512_Unroll_R( 3) - R512_8_rounds( 3); + #if R512_Unroll_R(3) + R512_8_rounds(3); #endif - #if R512_Unroll_R( 4) - R512_8_rounds( 4); + #if R512_Unroll_R(4) + R512_8_rounds(4); #endif - #if R512_Unroll_R( 5) - R512_8_rounds( 5); + #if R512_Unroll_R(5) + R512_8_rounds(5); #endif - #if R512_Unroll_R( 6) - R512_8_rounds( 6); + #if R512_Unroll_R(6) + R512_8_rounds(6); #endif - #if R512_Unroll_R( 7) - R512_8_rounds( 7); + #if R512_Unroll_R(7) + R512_8_rounds(7); #endif - #if R512_Unroll_R( 8) - R512_8_rounds( 8); + #if R512_Unroll_R(8) + R512_8_rounds(8); #endif - #if R512_Unroll_R( 9) - R512_8_rounds( 9); + #if R512_Unroll_R(9) + R512_8_rounds(9); #endif #if R512_Unroll_R(10) R512_8_rounds(10); @@ -408,7 +406,7 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx,const u8 *blkPtr,size_t b ctx->X[5] = X5 ^ w[5]; ctx->X[6] = X6 ^ w[6]; ctx->X[7] = X7 ^ w[7]; - Skein_Show_Round(BLK_BITS,&ctx->h,SKEIN_RND_FEED_FWD,ctx->X); + Skein_Show_Round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X); ts[1] &= ~SKEIN_T1_FLAG_FIRST; } @@ -432,16 +430,15 @@ unsigned int Skein_512_Unroll_Cnt(void) /***************************** Skein1024 ******************************/ #if !(SKEIN_USE_ASM & 1024) -void Skein1024_Process_Block(struct skein1024_ctx *ctx,const u8 *blkPtr,size_t blkCnt,size_t byteCntAdd) +void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, size_t blkCnt, size_t byteCntAdd) { /* do it in C, always looping (unrolled is bigger AND slower!) */ - enum - { + enum { WCNT = SKEIN1024_STATE_WORDS }; #undef RCNT #define RCNT (SKEIN1024_ROUNDS_TOTAL/8) -#ifdef SKEIN_LOOP /* configure how much to unroll the loop */ +#ifdef SKEIN_LOOP /* configure how much to unroll the loop */ #define SKEIN_UNROLL_1024 ((SKEIN_LOOP)%10) #else #define SKEIN_UNROLL_1024 (0) @@ -457,14 +454,14 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx,const u8 *blkPtr,size_t b u64 kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ #endif - u64 X00,X01,X02,X03,X04,X05,X06,X07, /* local copy of vars, for speed */ - X08,X09,X10,X11,X12,X13,X14,X15; - u64 w [WCNT]; /* local copy of input block */ + u64 X00, X01, X02, X03, X04, X05, X06, X07, /* local copy of vars, for speed */ + X08, X09, X10, X11, X12, X13, X14, X15; + u64 w[WCNT]; /* local copy of input block */ #ifdef SKEIN_DEBUG const u64 *Xptr[16]; /* use for debugging (help compiler put Xn in registers) */ - Xptr[ 0] = &X00; Xptr[ 1] = &X01; Xptr[ 2] = &X02; Xptr[ 3] = &X03; - Xptr[ 4] = &X04; Xptr[ 5] = &X05; Xptr[ 6] = &X06; Xptr[ 7] = &X07; - Xptr[ 8] = &X08; Xptr[ 9] = &X09; Xptr[10] = &X10; Xptr[11] = &X11; + Xptr[0] = &X00; Xptr[1] = &X01; Xptr[2] = &X02; Xptr[3] = &X03; + Xptr[4] = &X04; Xptr[5] = &X05; Xptr[6] = &X06; Xptr[7] = &X07; + Xptr[8] = &X08; Xptr[9] = &X09; Xptr[10] = &X10; Xptr[11] = &X11; Xptr[12] = &X12; Xptr[13] = &X13; Xptr[14] = &X14; Xptr[15] = &X15; #endif @@ -476,43 +473,43 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx,const u8 *blkPtr,size_t b ts[0] += byteCntAdd; /* update processed length */ /* precompute the key schedule for this block */ - ks[ 0] = ctx->X[ 0]; - ks[ 1] = ctx->X[ 1]; - ks[ 2] = ctx->X[ 2]; - ks[ 3] = ctx->X[ 3]; - ks[ 4] = ctx->X[ 4]; - ks[ 5] = ctx->X[ 5]; - ks[ 6] = ctx->X[ 6]; - ks[ 7] = ctx->X[ 7]; - ks[ 8] = ctx->X[ 8]; - ks[ 9] = ctx->X[ 9]; + ks[0] = ctx->X[0]; + ks[1] = ctx->X[1]; + ks[2] = ctx->X[2]; + ks[3] = ctx->X[3]; + ks[4] = ctx->X[4]; + ks[5] = ctx->X[5]; + ks[6] = ctx->X[6]; + ks[7] = ctx->X[7]; + ks[8] = ctx->X[8]; + ks[9] = ctx->X[9]; ks[10] = ctx->X[10]; ks[11] = ctx->X[11]; ks[12] = ctx->X[12]; ks[13] = ctx->X[13]; ks[14] = ctx->X[14]; ks[15] = ctx->X[15]; - ks[16] = ks[ 0] ^ ks[ 1] ^ ks[ 2] ^ ks[ 3] ^ - ks[ 4] ^ ks[ 5] ^ ks[ 6] ^ ks[ 7] ^ - ks[ 8] ^ ks[ 9] ^ ks[10] ^ ks[11] ^ + ks[16] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ + ks[4] ^ ks[5] ^ ks[6] ^ ks[7] ^ + ks[8] ^ ks[9] ^ ks[10] ^ ks[11] ^ ks[12] ^ ks[13] ^ ks[14] ^ ks[15] ^ SKEIN_KS_PARITY; ts[2] = ts[0] ^ ts[1]; - Skein_Get64_LSB_First(w,blkPtr,WCNT); /* get input block in little-endian format */ + Skein_Get64_LSB_First(w, blkPtr, WCNT); /* get input block in little-endian format */ DebugSaveTweak(ctx); - Skein_Show_Block(BLK_BITS,&ctx->h,ctx->X,blkPtr,w,ks,ts); - - X00 = w[ 0] + ks[ 0]; /* do the first full key injection */ - X01 = w[ 1] + ks[ 1]; - X02 = w[ 2] + ks[ 2]; - X03 = w[ 3] + ks[ 3]; - X04 = w[ 4] + ks[ 4]; - X05 = w[ 5] + ks[ 5]; - X06 = w[ 6] + ks[ 6]; - X07 = w[ 7] + ks[ 7]; - X08 = w[ 8] + ks[ 8]; - X09 = w[ 9] + ks[ 9]; + Skein_Show_Block(BLK_BITS, &ctx->h, ctx->X, blkPtr, w, ks, ts); + + X00 = w[0] + ks[0]; /* do the first full key injection */ + X01 = w[1] + ks[1]; + X02 = w[2] + ks[2]; + X03 = w[3] + ks[3]; + X04 = w[4] + ks[4]; + X05 = w[5] + ks[5]; + X06 = w[6] + ks[6]; + X07 = w[7] + ks[7]; + X08 = w[8] + ks[8]; + X09 = w[9] + ks[9]; X10 = w[10] + ks[10]; X11 = w[11] + ks[11]; X12 = w[12] + ks[12]; @@ -520,112 +517,112 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx,const u8 *blkPtr,size_t b X14 = w[14] + ks[14] + ts[1]; X15 = w[15] + ks[15]; - Skein_Show_R_Ptr(BLK_BITS,&ctx->h,SKEIN_RND_KEY_INITIAL,Xptr); + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, Xptr); -#define Round1024(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,pA,pB,pC,pD,pE,pF,ROT,rNum) \ - X##p0 += X##p1; X##p1 = RotL_64(X##p1,ROT##_0); X##p1 ^= X##p0; \ - X##p2 += X##p3; X##p3 = RotL_64(X##p3,ROT##_1); X##p3 ^= X##p2; \ - X##p4 += X##p5; X##p5 = RotL_64(X##p5,ROT##_2); X##p5 ^= X##p4; \ - X##p6 += X##p7; X##p7 = RotL_64(X##p7,ROT##_3); X##p7 ^= X##p6; \ - X##p8 += X##p9; X##p9 = RotL_64(X##p9,ROT##_4); X##p9 ^= X##p8; \ - X##pA += X##pB; X##pB = RotL_64(X##pB,ROT##_5); X##pB ^= X##pA; \ - X##pC += X##pD; X##pD = RotL_64(X##pD,ROT##_6); X##pD ^= X##pC; \ - X##pE += X##pF; X##pF = RotL_64(X##pF,ROT##_7); X##pF ^= X##pE; \ +#define Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, ROT, rNum) \ + X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ + X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ + X##p4 += X##p5; X##p5 = RotL_64(X##p5, ROT##_2); X##p5 ^= X##p4; \ + X##p6 += X##p7; X##p7 = RotL_64(X##p7, ROT##_3); X##p7 ^= X##p6; \ + X##p8 += X##p9; X##p9 = RotL_64(X##p9, ROT##_4); X##p9 ^= X##p8; \ + X##pA += X##pB; X##pB = RotL_64(X##pB, ROT##_5); X##pB ^= X##pA; \ + X##pC += X##pD; X##pD = RotL_64(X##pD, ROT##_6); X##pD ^= X##pC; \ + X##pE += X##pF; X##pF = RotL_64(X##pF, ROT##_7); X##pF ^= X##pE; \ #if SKEIN_UNROLL_1024 == 0 -#define R1024(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,pA,pB,pC,pD,pE,pF,ROT,rn) \ - Round1024(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,pA,pB,pC,pD,pE,pF,ROT,rn) \ - Skein_Show_R_Ptr(BLK_BITS,&ctx->h,rn,Xptr); - -#define I1024(R) \ - X00 += ks[((R)+ 1) % 17]; /* inject the key schedule value */ \ - X01 += ks[((R)+ 2) % 17]; \ - X02 += ks[((R)+ 3) % 17]; \ - X03 += ks[((R)+ 4) % 17]; \ - X04 += ks[((R)+ 5) % 17]; \ - X05 += ks[((R)+ 6) % 17]; \ - X06 += ks[((R)+ 7) % 17]; \ - X07 += ks[((R)+ 8) % 17]; \ - X08 += ks[((R)+ 9) % 17]; \ - X09 += ks[((R)+10) % 17]; \ - X10 += ks[((R)+11) % 17]; \ - X11 += ks[((R)+12) % 17]; \ - X12 += ks[((R)+13) % 17]; \ - X13 += ks[((R)+14) % 17] + ts[((R)+1) % 3]; \ - X14 += ks[((R)+15) % 17] + ts[((R)+2) % 3]; \ - X15 += ks[((R)+16) % 17] + (R)+1; \ - Skein_Show_R_Ptr(BLK_BITS,&ctx->h,SKEIN_RND_KEY_INJECT,Xptr); +#define R1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, ROT, rn) \ + Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, ROT, rn) \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rn, Xptr); + +#define I1024(R) \ + X00 += ks[((R) + 1) % 17]; /* inject the key schedule value */ \ + X01 += ks[((R) + 2) % 17]; \ + X02 += ks[((R) + 3) % 17]; \ + X03 += ks[((R) + 4) % 17]; \ + X04 += ks[((R) + 5) % 17]; \ + X05 += ks[((R) + 6) % 17]; \ + X06 += ks[((R) + 7) % 17]; \ + X07 += ks[((R) + 8) % 17]; \ + X08 += ks[((R) + 9) % 17]; \ + X09 += ks[((R) + 10) % 17]; \ + X10 += ks[((R) + 11) % 17]; \ + X11 += ks[((R) + 12) % 17]; \ + X12 += ks[((R) + 13) % 17]; \ + X13 += ks[((R) + 14) % 17] + ts[((R) + 1) % 3]; \ + X14 += ks[((R) + 15) % 17] + ts[((R) + 2) % 3]; \ + X15 += ks[((R) + 16) % 17] + (R) + 1; \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); #else /* looping version */ -#define R1024(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,pA,pB,pC,pD,pE,pF,ROT,rn) \ - Round1024(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,pA,pB,pC,pD,pE,pF,ROT,rn) \ - Skein_Show_R_Ptr(BLK_BITS,&ctx->h,4*(r-1)+rn,Xptr); +#define R1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, ROT, rn) \ + Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, ROT, rn) \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rn, Xptr); #define I1024(R) \ - X00 += ks[r+(R)+ 0]; /* inject the key schedule value */ \ - X01 += ks[r+(R)+ 1]; \ - X02 += ks[r+(R)+ 2]; \ - X03 += ks[r+(R)+ 3]; \ - X04 += ks[r+(R)+ 4]; \ - X05 += ks[r+(R)+ 5]; \ - X06 += ks[r+(R)+ 6]; \ - X07 += ks[r+(R)+ 7]; \ - X08 += ks[r+(R)+ 8]; \ - X09 += ks[r+(R)+ 9]; \ - X10 += ks[r+(R)+10]; \ - X11 += ks[r+(R)+11]; \ - X12 += ks[r+(R)+12]; \ - X13 += ks[r+(R)+13] + ts[r+(R)+0]; \ - X14 += ks[r+(R)+14] + ts[r+(R)+1]; \ - X15 += ks[r+(R)+15] + r+(R) ; \ - ks[r + (R)+16] = ks[r+(R)-1]; /* rotate key schedule */ \ - ts[r + (R)+ 2] = ts[r+(R)-1]; \ - Skein_Show_R_Ptr(BLK_BITS,&ctx->h,SKEIN_RND_KEY_INJECT,Xptr); - - for (r=1;r <= 2*RCNT;r+=2*SKEIN_UNROLL_1024) /* loop thru it */ + X00 += ks[r + (R) + 0]; /* inject the key schedule value */ \ + X01 += ks[r + (R) + 1]; \ + X02 += ks[r + (R) + 2]; \ + X03 += ks[r + (R) + 3]; \ + X04 += ks[r + (R) + 4]; \ + X05 += ks[r + (R) + 5]; \ + X06 += ks[r + (R) + 6]; \ + X07 += ks[r + (R) + 7]; \ + X08 += ks[r + (R) + 8]; \ + X09 += ks[r + (R) + 9]; \ + X10 += ks[r + (R) + 10]; \ + X11 += ks[r + (R) + 11]; \ + X12 += ks[r + (R) + 12]; \ + X13 += ks[r + (R) + 13] + ts[r + (R) + 0]; \ + X14 += ks[r + (R) + 14] + ts[r + (R) + 1]; \ + X15 += ks[r + (R) + 15] + r + (R); \ + ks[r + (R) + 16] = ks[r + (R) - 1]; /* rotate key schedule */\ + ts[r + (R) + 2] = ts[r + (R) - 1]; \ + Skein_Show_R_Ptr(BLK_BITSi, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); + + for (r = 1; r <= 2 * RCNT; r += 2 * SKEIN_UNROLL_1024) /* loop thru it */ #endif { #define R1024_8_rounds(R) /* do 8 full rounds */ \ - R1024(00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,R1024_0,8*(R) + 1); \ - R1024(00,09,02,13,06,11,04,15,10,07,12,03,14,05,08,01,R1024_1,8*(R) + 2); \ - R1024(00,07,02,05,04,03,06,01,12,15,14,13,08,11,10,09,R1024_2,8*(R) + 3); \ - R1024(00,15,02,11,06,13,04,09,14,01,08,05,10,03,12,07,R1024_3,8*(R) + 4); \ + R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, R1024_0, 8*(R) + 1); \ + R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, 05, 08, 01, R1024_1, 8*(R) + 2); \ + R1024(00, 07, 02, 05, 04, 03, 06, 01, 12, 15, 14, 13, 08, 11, 10, 09, R1024_2, 8*(R) + 3); \ + R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, 03, 12, 07, R1024_3, 8*(R) + 4); \ I1024(2*(R)); \ - R1024(00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,R1024_4,8*(R) + 5); \ - R1024(00,09,02,13,06,11,04,15,10,07,12,03,14,05,08,01,R1024_5,8*(R) + 6); \ - R1024(00,07,02,05,04,03,06,01,12,15,14,13,08,11,10,09,R1024_6,8*(R) + 7); \ - R1024(00,15,02,11,06,13,04,09,14,01,08,05,10,03,12,07,R1024_7,8*(R) + 8); \ + R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, R1024_4, 8*(R) + 5); \ + R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, 05, 08, 01, R1024_5, 8*(R) + 6); \ + R1024(00, 07, 02, 05, 04, 03, 06, 01, 12, 15, 14, 13, 08, 11, 10, 09, R1024_6, 8*(R) + 7); \ + R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, 03, 12, 07, R1024_7, 8*(R) + 8); \ I1024(2*(R)+1); - R1024_8_rounds( 0); + R1024_8_rounds(0); #define R1024_Unroll_R(NN) ((SKEIN_UNROLL_1024 == 0 && SKEIN1024_ROUNDS_TOTAL/8 > (NN)) || (SKEIN_UNROLL_1024 > (NN))) - #if R1024_Unroll_R( 1) - R1024_8_rounds( 1); + #if R1024_Unroll_R(1) + R1024_8_rounds(1); #endif - #if R1024_Unroll_R( 2) - R1024_8_rounds( 2); + #if R1024_Unroll_R(2) + R1024_8_rounds(2); #endif - #if R1024_Unroll_R( 3) - R1024_8_rounds( 3); + #if R1024_Unroll_R(3) + R1024_8_rounds(3); #endif - #if R1024_Unroll_R( 4) - R1024_8_rounds( 4); + #if R1024_Unroll_R(4) + R1024_8_rounds(4); #endif - #if R1024_Unroll_R( 5) - R1024_8_rounds( 5); + #if R1024_Unroll_R(5) + R1024_8_rounds(5); #endif - #if R1024_Unroll_R( 6) - R1024_8_rounds( 6); + #if R1024_Unroll_R(6) + R1024_8_rounds(6); #endif - #if R1024_Unroll_R( 7) - R1024_8_rounds( 7); + #if R1024_Unroll_R(7) + R1024_8_rounds(7); #endif - #if R1024_Unroll_R( 8) - R1024_8_rounds( 8); + #if R1024_Unroll_R(8) + R1024_8_rounds(8); #endif - #if R1024_Unroll_R( 9) - R1024_8_rounds( 9); + #if R1024_Unroll_R(9) + R1024_8_rounds(9); #endif #if R1024_Unroll_R(10) R1024_8_rounds(10); @@ -648,16 +645,16 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx,const u8 *blkPtr,size_t b } /* do the final "feedforward" xor, update context chaining vars */ - ctx->X[ 0] = X00 ^ w[ 0]; - ctx->X[ 1] = X01 ^ w[ 1]; - ctx->X[ 2] = X02 ^ w[ 2]; - ctx->X[ 3] = X03 ^ w[ 3]; - ctx->X[ 4] = X04 ^ w[ 4]; - ctx->X[ 5] = X05 ^ w[ 5]; - ctx->X[ 6] = X06 ^ w[ 6]; - ctx->X[ 7] = X07 ^ w[ 7]; - ctx->X[ 8] = X08 ^ w[ 8]; - ctx->X[ 9] = X09 ^ w[ 9]; + ctx->X[0] = X00 ^ w[0]; + ctx->X[1] = X01 ^ w[1]; + ctx->X[2] = X02 ^ w[2]; + ctx->X[3] = X03 ^ w[3]; + ctx->X[4] = X04 ^ w[4]; + ctx->X[5] = X05 ^ w[5]; + ctx->X[6] = X06 ^ w[6]; + ctx->X[7] = X07 ^ w[7]; + ctx->X[8] = X08 ^ w[8]; + ctx->X[9] = X09 ^ w[9]; ctx->X[10] = X10 ^ w[10]; ctx->X[11] = X11 ^ w[11]; ctx->X[12] = X12 ^ w[12]; @@ -665,7 +662,7 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx,const u8 *blkPtr,size_t b ctx->X[14] = X14 ^ w[14]; ctx->X[15] = X15 ^ w[15]; - Skein_Show_Round(BLK_BITS,&ctx->h,SKEIN_RND_FEED_FWD,ctx->X); + Skein_Show_Round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X); ts[1] &= ~SKEIN_T1_FLAG_FIRST; blkPtr += SKEIN1024_BLOCK_BYTES; -- cgit v1.2.3 From e6d336f5c68c7d83bb66aeaa29967f25e7adc8e4 Mon Sep 17 00:00:00 2001 From: Jason Cooper Date: Mon, 24 Mar 2014 01:49:08 +0000 Subject: staging: crypto: skein: dos2unix, remove executable perms $ find drivers/staging/skein -type f | xargs todos -d $ chmod -x drivers/staging/skein/skeinApi.c $ chmod -x drivers/staging/skein/include/skeinApi.h Signed-off-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/include/skeinApi.h | 0 drivers/staging/skein/skeinApi.c | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 drivers/staging/skein/include/skeinApi.h mode change 100755 => 100644 drivers/staging/skein/skeinApi.c diff --git a/drivers/staging/skein/include/skeinApi.h b/drivers/staging/skein/include/skeinApi.h old mode 100755 new mode 100644 diff --git a/drivers/staging/skein/skeinApi.c b/drivers/staging/skein/skeinApi.c old mode 100755 new mode 100644 -- cgit v1.2.3 From 39bd42b0855fa95ec923854cfeda58e3bbb77b4a Mon Sep 17 00:00:00 2001 From: Jason Cooper Date: Mon, 24 Mar 2014 01:49:09 +0000 Subject: staging: crypto: skein: fix leading whitespace Signed-off-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/include/skein.h | 136 +- drivers/staging/skein/include/skeinApi.h | 284 +-- drivers/staging/skein/include/skein_iv.h | 276 +-- drivers/staging/skein/include/threefishApi.h | 230 +-- drivers/staging/skein/skein.c | 1126 +++++------ drivers/staging/skein/skeinApi.c | 320 +-- drivers/staging/skein/skeinBlockNo3F.c | 286 +-- drivers/staging/skein/skein_block.c | 1012 +++++----- drivers/staging/skein/threefish1024Block.c | 2740 +++++++++++++------------- drivers/staging/skein/threefish256Block.c | 639 +++--- drivers/staging/skein/threefish512Block.c | 1254 ++++++------ drivers/staging/skein/threefishApi.c | 102 +- 12 files changed, 4200 insertions(+), 4205 deletions(-) diff --git a/drivers/staging/skein/include/skein.h b/drivers/staging/skein/include/skein.h index 18bb15824e41..906bcee41c39 100644 --- a/drivers/staging/skein/include/skein.h +++ b/drivers/staging/skein/include/skein.h @@ -38,11 +38,11 @@ #define Skein_Swap64(w64) (w64) enum - { - SKEIN_SUCCESS = 0, /* return codes from Skein calls */ - SKEIN_FAIL = 1, - SKEIN_BAD_HASHLEN = 2 - }; + { + SKEIN_SUCCESS = 0, /* return codes from Skein calls */ + SKEIN_FAIL = 1, + SKEIN_BAD_HASHLEN = 2 + }; #define SKEIN_MODIFIER_WORDS (2) /* number of modifier (tweak) words */ @@ -64,32 +64,32 @@ enum #define SKEIN1024_BLOCK_BYTES (8*SKEIN1024_STATE_WORDS) struct skein_ctx_hdr - { - size_t hashBitLen; /* size of hash result, in bits */ - size_t bCnt; /* current byte count in buffer b[] */ - u64 T[SKEIN_MODIFIER_WORDS]; /* tweak words: T[0]=byte cnt, T[1]=flags */ - }; + { + size_t hashBitLen; /* size of hash result, in bits */ + size_t bCnt; /* current byte count in buffer b[] */ + u64 T[SKEIN_MODIFIER_WORDS]; /* tweak words: T[0]=byte cnt, T[1]=flags */ + }; struct skein_256_ctx /* 256-bit Skein hash context structure */ - { - struct skein_ctx_hdr h; /* common header context variables */ - u64 X[SKEIN_256_STATE_WORDS]; /* chaining variables */ - u8 b[SKEIN_256_BLOCK_BYTES]; /* partial block buffer (8-byte aligned) */ - }; + { + struct skein_ctx_hdr h; /* common header context variables */ + u64 X[SKEIN_256_STATE_WORDS]; /* chaining variables */ + u8 b[SKEIN_256_BLOCK_BYTES]; /* partial block buffer (8-byte aligned) */ + }; struct skein_512_ctx /* 512-bit Skein hash context structure */ - { - struct skein_ctx_hdr h; /* common header context variables */ - u64 X[SKEIN_512_STATE_WORDS]; /* chaining variables */ - u8 b[SKEIN_512_BLOCK_BYTES]; /* partial block buffer (8-byte aligned) */ - }; + { + struct skein_ctx_hdr h; /* common header context variables */ + u64 X[SKEIN_512_STATE_WORDS]; /* chaining variables */ + u8 b[SKEIN_512_BLOCK_BYTES]; /* partial block buffer (8-byte aligned) */ + }; struct skein1024_ctx /* 1024-bit Skein hash context structure */ - { - struct skein_ctx_hdr h; /* common header context variables */ - u64 X[SKEIN1024_STATE_WORDS]; /* chaining variables */ - u8 b[SKEIN1024_BLOCK_BYTES]; /* partial block buffer (8-byte aligned) */ - }; + { + struct skein_ctx_hdr h; /* common header context variables */ + u64 X[SKEIN1024_STATE_WORDS]; /* chaining variables */ + u8 b[SKEIN1024_BLOCK_BYTES]; /* partial block buffer (8-byte aligned) */ + }; /* Skein APIs for (incremental) "straight hashing" */ int Skein_256_Init(struct skein_256_ctx *ctx, size_t hashBitLen); @@ -150,18 +150,18 @@ int Skein1024_Output(struct skein1024_ctx *ctx, u8 *hashVal); /* tweak word T[1]: bit field starting positions */ #define SKEIN_T1_BIT(BIT) ((BIT) - 64) /* offset 64 because it's the second word */ - + #define SKEIN_T1_POS_TREE_LVL SKEIN_T1_BIT(112) /* bits 112..118: level in hash tree */ #define SKEIN_T1_POS_BIT_PAD SKEIN_T1_BIT(119) /* bit 119 : partial final input byte */ #define SKEIN_T1_POS_BLK_TYPE SKEIN_T1_BIT(120) /* bits 120..125: type field */ #define SKEIN_T1_POS_FIRST SKEIN_T1_BIT(126) /* bits 126 : first block flag */ #define SKEIN_T1_POS_FINAL SKEIN_T1_BIT(127) /* bit 127 : final block flag */ - + /* tweak word T[1]: flag bit definition(s) */ #define SKEIN_T1_FLAG_FIRST (((u64) 1) << SKEIN_T1_POS_FIRST) #define SKEIN_T1_FLAG_FINAL (((u64) 1) << SKEIN_T1_POS_FINAL) #define SKEIN_T1_FLAG_BIT_PAD (((u64) 1) << SKEIN_T1_POS_BIT_PAD) - + /* tweak word T[1]: tree level bit field mask */ #define SKEIN_T1_TREE_LVL_MASK (((u64)0x7F) << SKEIN_T1_POS_TREE_LVL) #define SKEIN_T1_TREE_LEVEL(n) (((u64) (n)) << SKEIN_T1_POS_TREE_LVL) @@ -213,9 +213,9 @@ int Skein1024_Output(struct skein1024_ctx *ctx, u8 *hashVal); #define SKEIN_CFG_TREE_MAX_LEVEL_MSK (((u64) 0xFF) << SKEIN_CFG_TREE_MAX_LEVEL_POS) #define SKEIN_CFG_TREE_INFO(leaf, node, maxLvl) \ - ((((u64)(leaf)) << SKEIN_CFG_TREE_LEAF_SIZE_POS) | \ - (((u64)(node)) << SKEIN_CFG_TREE_NODE_SIZE_POS) | \ - (((u64)(maxLvl)) << SKEIN_CFG_TREE_MAX_LEVEL_POS)) + ((((u64)(leaf)) << SKEIN_CFG_TREE_LEAF_SIZE_POS) | \ + (((u64)(node)) << SKEIN_CFG_TREE_NODE_SIZE_POS) | \ + (((u64)(maxLvl)) << SKEIN_CFG_TREE_MAX_LEVEL_POS)) #define SKEIN_CFG_TREE_INFO_SEQUENTIAL SKEIN_CFG_TREE_INFO(0, 0, 0) /* use as treeInfo in InitExt() call for sequential processing */ @@ -233,17 +233,17 @@ int Skein1024_Output(struct skein1024_ctx *ctx, u8 *hashVal); /* set both tweak words at once */ #define Skein_Set_T0_T1(ctxPtr, T0, T1) \ - { \ - Skein_Set_T0(ctxPtr, (T0)); \ - Skein_Set_T1(ctxPtr, (T1)); \ - } + { \ + Skein_Set_T0(ctxPtr, (T0)); \ + Skein_Set_T1(ctxPtr, (T1)); \ + } #define Skein_Set_Type(ctxPtr, BLK_TYPE) \ - Skein_Set_T1(ctxPtr, SKEIN_T1_BLK_TYPE_##BLK_TYPE) + Skein_Set_T1(ctxPtr, SKEIN_T1_BLK_TYPE_##BLK_TYPE) /* set up for starting with a new type: h.T[0]=0; h.T[1] = NEW_TYPE; h.bCnt=0; */ #define Skein_Start_New_Type(ctxPtr, BLK_TYPE) \ - { Skein_Set_T0_T1(ctxPtr, 0, SKEIN_T1_FLAG_FIRST | SKEIN_T1_BLK_TYPE_##BLK_TYPE); (ctxPtr)->h.bCnt = 0; } + { Skein_Set_T0_T1(ctxPtr, 0, SKEIN_T1_FLAG_FIRST | SKEIN_T1_BLK_TYPE_##BLK_TYPE); (ctxPtr)->h.bCnt = 0; } #define Skein_Clear_First_Flag(hdr) { (hdr).T[1] &= ~SKEIN_T1_FLAG_FIRST; } #define Skein_Set_Bit_Pad_Flag(hdr) { (hdr).T[1] |= SKEIN_T1_FLAG_BIT_PAD; } @@ -270,37 +270,37 @@ int Skein1024_Output(struct skein1024_ctx *ctx, u8 *hashVal); ** Skein block function constants (shared across Ref and Opt code) ******************************************************************/ enum - { - /* Skein_256 round rotation constants */ - R_256_0_0 = 14, R_256_0_1 = 16, - R_256_1_0 = 52, R_256_1_1 = 57, - R_256_2_0 = 23, R_256_2_1 = 40, - R_256_3_0 = 5, R_256_3_1 = 37, - R_256_4_0 = 25, R_256_4_1 = 33, - R_256_5_0 = 46, R_256_5_1 = 12, - R_256_6_0 = 58, R_256_6_1 = 22, - R_256_7_0 = 32, R_256_7_1 = 32, - - /* Skein_512 round rotation constants */ - R_512_0_0 = 46, R_512_0_1 = 36, R_512_0_2 = 19, R_512_0_3 = 37, - R_512_1_0 = 33, R_512_1_1 = 27, R_512_1_2 = 14, R_512_1_3 = 42, - R_512_2_0 = 17, R_512_2_1 = 49, R_512_2_2 = 36, R_512_2_3 = 39, - R_512_3_0 = 44, R_512_3_1 = 9, R_512_3_2 = 54, R_512_3_3 = 56, - R_512_4_0 = 39, R_512_4_1 = 30, R_512_4_2 = 34, R_512_4_3 = 24, - R_512_5_0 = 13, R_512_5_1 = 50, R_512_5_2 = 10, R_512_5_3 = 17, - R_512_6_0 = 25, R_512_6_1 = 29, R_512_6_2 = 39, R_512_6_3 = 43, - R_512_7_0 = 8, R_512_7_1 = 35, R_512_7_2 = 56, R_512_7_3 = 22, - - /* Skein1024 round rotation constants */ - R1024_0_0 = 24, R1024_0_1 = 13, R1024_0_2 = 8, R1024_0_3 = 47, R1024_0_4 = 8, R1024_0_5 = 17, R1024_0_6 = 22, R1024_0_7 = 37, - R1024_1_0 = 38, R1024_1_1 = 19, R1024_1_2 = 10, R1024_1_3 = 55, R1024_1_4 = 49, R1024_1_5 = 18, R1024_1_6 = 23, R1024_1_7 = 52, - R1024_2_0 = 33, R1024_2_1 = 4, R1024_2_2 = 51, R1024_2_3 = 13, R1024_2_4 = 34, R1024_2_5 = 41, R1024_2_6 = 59, R1024_2_7 = 17, - R1024_3_0 = 5, R1024_3_1 = 20, R1024_3_2 = 48, R1024_3_3 = 41, R1024_3_4 = 47, R1024_3_5 = 28, R1024_3_6 = 16, R1024_3_7 = 25, - R1024_4_0 = 41, R1024_4_1 = 9, R1024_4_2 = 37, R1024_4_3 = 31, R1024_4_4 = 12, R1024_4_5 = 47, R1024_4_6 = 44, R1024_4_7 = 30, - R1024_5_0 = 16, R1024_5_1 = 34, R1024_5_2 = 56, R1024_5_3 = 51, R1024_5_4 = 4, R1024_5_5 = 53, R1024_5_6 = 42, R1024_5_7 = 41, - R1024_6_0 = 31, R1024_6_1 = 44, R1024_6_2 = 47, R1024_6_3 = 46, R1024_6_4 = 19, R1024_6_5 = 42, R1024_6_6 = 44, R1024_6_7 = 25, - R1024_7_0 = 9, R1024_7_1 = 48, R1024_7_2 = 35, R1024_7_3 = 52, R1024_7_4 = 23, R1024_7_5 = 31, R1024_7_6 = 37, R1024_7_7 = 20 - }; + { + /* Skein_256 round rotation constants */ + R_256_0_0 = 14, R_256_0_1 = 16, + R_256_1_0 = 52, R_256_1_1 = 57, + R_256_2_0 = 23, R_256_2_1 = 40, + R_256_3_0 = 5, R_256_3_1 = 37, + R_256_4_0 = 25, R_256_4_1 = 33, + R_256_5_0 = 46, R_256_5_1 = 12, + R_256_6_0 = 58, R_256_6_1 = 22, + R_256_7_0 = 32, R_256_7_1 = 32, + + /* Skein_512 round rotation constants */ + R_512_0_0 = 46, R_512_0_1 = 36, R_512_0_2 = 19, R_512_0_3 = 37, + R_512_1_0 = 33, R_512_1_1 = 27, R_512_1_2 = 14, R_512_1_3 = 42, + R_512_2_0 = 17, R_512_2_1 = 49, R_512_2_2 = 36, R_512_2_3 = 39, + R_512_3_0 = 44, R_512_3_1 = 9, R_512_3_2 = 54, R_512_3_3 = 56, + R_512_4_0 = 39, R_512_4_1 = 30, R_512_4_2 = 34, R_512_4_3 = 24, + R_512_5_0 = 13, R_512_5_1 = 50, R_512_5_2 = 10, R_512_5_3 = 17, + R_512_6_0 = 25, R_512_6_1 = 29, R_512_6_2 = 39, R_512_6_3 = 43, + R_512_7_0 = 8, R_512_7_1 = 35, R_512_7_2 = 56, R_512_7_3 = 22, + + /* Skein1024 round rotation constants */ + R1024_0_0 = 24, R1024_0_1 = 13, R1024_0_2 = 8, R1024_0_3 = 47, R1024_0_4 = 8, R1024_0_5 = 17, R1024_0_6 = 22, R1024_0_7 = 37, + R1024_1_0 = 38, R1024_1_1 = 19, R1024_1_2 = 10, R1024_1_3 = 55, R1024_1_4 = 49, R1024_1_5 = 18, R1024_1_6 = 23, R1024_1_7 = 52, + R1024_2_0 = 33, R1024_2_1 = 4, R1024_2_2 = 51, R1024_2_3 = 13, R1024_2_4 = 34, R1024_2_5 = 41, R1024_2_6 = 59, R1024_2_7 = 17, + R1024_3_0 = 5, R1024_3_1 = 20, R1024_3_2 = 48, R1024_3_3 = 41, R1024_3_4 = 47, R1024_3_5 = 28, R1024_3_6 = 16, R1024_3_7 = 25, + R1024_4_0 = 41, R1024_4_1 = 9, R1024_4_2 = 37, R1024_4_3 = 31, R1024_4_4 = 12, R1024_4_5 = 47, R1024_4_6 = 44, R1024_4_7 = 30, + R1024_5_0 = 16, R1024_5_1 = 34, R1024_5_2 = 56, R1024_5_3 = 51, R1024_5_4 = 4, R1024_5_5 = 53, R1024_5_6 = 42, R1024_5_7 = 41, + R1024_6_0 = 31, R1024_6_1 = 44, R1024_6_2 = 47, R1024_6_3 = 46, R1024_6_4 = 19, R1024_6_5 = 42, R1024_6_6 = 44, R1024_6_7 = 25, + R1024_7_0 = 9, R1024_7_1 = 48, R1024_7_2 = 35, R1024_7_3 = 52, R1024_7_4 = 23, R1024_7_5 = 31, R1024_7_6 = 37, R1024_7_7 = 20 + }; #ifndef SKEIN_ROUNDS #define SKEIN_256_ROUNDS_TOTAL (72) /* number of rounds for the different block sizes */ diff --git a/drivers/staging/skein/include/skeinApi.h b/drivers/staging/skein/include/skeinApi.h index 2c52797918cf..0d7d59eff460 100644 --- a/drivers/staging/skein/include/skeinApi.h +++ b/drivers/staging/skein/include/skeinApi.h @@ -81,148 +81,148 @@ OTHER DEALINGS IN THE SOFTWARE. #include #include - /** - * Which Skein size to use - */ - enum skein_size { - Skein256 = 256, /*!< Skein with 256 bit state */ - Skein512 = 512, /*!< Skein with 512 bit state */ - Skein1024 = 1024 /*!< Skein with 1024 bit state */ - }; - - /** - * Context for Skein. - * - * This structure was setup with some know-how of the internal - * Skein structures, in particular ordering of header and size dependent - * variables. If Skein implementation changes this, then adapt these - * structures as well. - */ - struct skein_ctx { - u64 skeinSize; - u64 XSave[SKEIN_MAX_STATE_WORDS]; /* save area for state variables */ - union { - struct skein_ctx_hdr h; - struct skein_256_ctx s256; - struct skein_512_ctx s512; - struct skein1024_ctx s1024; - } m; - }; - - /** - * Prepare a Skein context. - * - * An application must call this function before it can use the Skein - * context. The functions clears memory and initializes size dependent - * variables. - * - * @param ctx - * Pointer to a Skein context. - * @param size - * Which Skein size to use. - * @return - * SKEIN_SUCESS of SKEIN_FAIL - */ - int skeinCtxPrepare(struct skein_ctx *ctx, enum skein_size size); - - /** - * Initialize a Skein context. - * - * Initializes the context with this data and saves the resulting Skein - * state variables for further use. - * - * @param ctx - * Pointer to a Skein context. - * @param hashBitLen - * Number of MAC hash bits to compute - * @return - * SKEIN_SUCESS of SKEIN_FAIL - * @see skeinReset - */ - int skeinInit(struct skein_ctx *ctx, size_t hashBitLen); - - /** - * Resets a Skein context for further use. - * - * Restores the saved chaining variables to reset the Skein context. - * Thus applications can reuse the same setup to process several - * messages. This saves a complete Skein initialization cycle. - * - * @param ctx - * Pointer to a pre-initialized Skein MAC context - */ - void skeinReset(struct skein_ctx *ctx); - - /** - * Initializes a Skein context for MAC usage. - * - * Initializes the context with this data and saves the resulting Skein - * state variables for further use. - * - * Applications call the normal Skein functions to update the MAC and - * get the final result. - * - * @param ctx - * Pointer to an empty or preinitialized Skein MAC context - * @param key - * Pointer to key bytes or NULL - * @param keyLen - * Length of the key in bytes or zero - * @param hashBitLen - * Number of MAC hash bits to compute - * @return - * SKEIN_SUCESS of SKEIN_FAIL - */ - int skeinMacInit(struct skein_ctx *ctx, const u8 *key, size_t keyLen, - size_t hashBitLen); - - /** - * Update Skein with the next part of the message. - * - * @param ctx - * Pointer to initialized Skein context - * @param msg - * Pointer to the message. - * @param msgByteCnt - * Length of the message in @b bytes - * @return - * Success or error code. - */ - int skeinUpdate(struct skein_ctx *ctx, const u8 *msg, - size_t msgByteCnt); - - /** - * Update the hash with a message bit string. - * - * Skein can handle data not only as bytes but also as bit strings of - * arbitrary length (up to its maximum design size). - * - * @param ctx - * Pointer to initialized Skein context - * @param msg - * Pointer to the message. - * @param msgBitCnt - * Length of the message in @b bits. - */ - int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg, - size_t msgBitCnt); - - /** - * Finalize Skein and return the hash. - * - * Before an application can reuse a Skein setup the application must - * reset the Skein context. - * - * @param ctx - * Pointer to initialized Skein context - * @param hash - * Pointer to buffer that receives the hash. The buffer must be large - * enough to store @c hashBitLen bits. - * @return - * Success or error code. - * @see skeinReset - */ - int skeinFinal(struct skein_ctx *ctx, u8 *hash); +/** + * Which Skein size to use + */ +enum skein_size { + Skein256 = 256, /*!< Skein with 256 bit state */ + Skein512 = 512, /*!< Skein with 512 bit state */ + Skein1024 = 1024 /*!< Skein with 1024 bit state */ +}; + +/** + * Context for Skein. + * + * This structure was setup with some know-how of the internal + * Skein structures, in particular ordering of header and size dependent + * variables. If Skein implementation changes this, then adapt these + * structures as well. + */ +struct skein_ctx { + u64 skeinSize; + u64 XSave[SKEIN_MAX_STATE_WORDS]; /* save area for state variables */ + union { + struct skein_ctx_hdr h; + struct skein_256_ctx s256; + struct skein_512_ctx s512; + struct skein1024_ctx s1024; + } m; +}; + +/** + * Prepare a Skein context. + * + * An application must call this function before it can use the Skein + * context. The functions clears memory and initializes size dependent + * variables. + * + * @param ctx + * Pointer to a Skein context. + * @param size + * Which Skein size to use. + * @return + * SKEIN_SUCESS of SKEIN_FAIL + */ +int skeinCtxPrepare(struct skein_ctx *ctx, enum skein_size size); + +/** + * Initialize a Skein context. + * + * Initializes the context with this data and saves the resulting Skein + * state variables for further use. + * + * @param ctx + * Pointer to a Skein context. + * @param hashBitLen + * Number of MAC hash bits to compute + * @return + * SKEIN_SUCESS of SKEIN_FAIL + * @see skeinReset + */ +int skeinInit(struct skein_ctx *ctx, size_t hashBitLen); + +/** + * Resets a Skein context for further use. + * + * Restores the saved chaining variables to reset the Skein context. + * Thus applications can reuse the same setup to process several + * messages. This saves a complete Skein initialization cycle. + * + * @param ctx + * Pointer to a pre-initialized Skein MAC context + */ +void skeinReset(struct skein_ctx *ctx); + +/** + * Initializes a Skein context for MAC usage. + * + * Initializes the context with this data and saves the resulting Skein + * state variables for further use. + * + * Applications call the normal Skein functions to update the MAC and + * get the final result. + * + * @param ctx + * Pointer to an empty or preinitialized Skein MAC context + * @param key + * Pointer to key bytes or NULL + * @param keyLen + * Length of the key in bytes or zero + * @param hashBitLen + * Number of MAC hash bits to compute + * @return + * SKEIN_SUCESS of SKEIN_FAIL + */ +int skeinMacInit(struct skein_ctx *ctx, const u8 *key, size_t keyLen, + size_t hashBitLen); + +/** + * Update Skein with the next part of the message. + * + * @param ctx + * Pointer to initialized Skein context + * @param msg + * Pointer to the message. + * @param msgByteCnt + * Length of the message in @b bytes + * @return + * Success or error code. + */ +int skeinUpdate(struct skein_ctx *ctx, const u8 *msg, + size_t msgByteCnt); + +/** + * Update the hash with a message bit string. + * + * Skein can handle data not only as bytes but also as bit strings of + * arbitrary length (up to its maximum design size). + * + * @param ctx + * Pointer to initialized Skein context + * @param msg + * Pointer to the message. + * @param msgBitCnt + * Length of the message in @b bits. + */ +int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg, + size_t msgBitCnt); + +/** + * Finalize Skein and return the hash. + * + * Before an application can reuse a Skein setup the application must + * reset the Skein context. + * + * @param ctx + * Pointer to initialized Skein context + * @param hash + * Pointer to buffer that receives the hash. The buffer must be large + * enough to store @c hashBitLen bits. + * @return + * Success or error code. + * @see skeinReset + */ +int skeinFinal(struct skein_ctx *ctx, u8 *hash); /** * @} diff --git a/drivers/staging/skein/include/skein_iv.h b/drivers/staging/skein/include/skein_iv.h index 813bad528e3c..bbbba77c44d3 100644 --- a/drivers/staging/skein/include/skein_iv.h +++ b/drivers/staging/skein/include/skein_iv.h @@ -21,179 +21,179 @@ /* blkSize = 256 bits. hashSize = 128 bits */ const u64 SKEIN_256_IV_128[] = - { - MK_64(0xE1111906, 0x964D7260), - MK_64(0x883DAAA7, 0x7C8D811C), - MK_64(0x10080DF4, 0x91960F7A), - MK_64(0xCCF7DDE5, 0xB45BC1C2) - }; + { + MK_64(0xE1111906, 0x964D7260), + MK_64(0x883DAAA7, 0x7C8D811C), + MK_64(0x10080DF4, 0x91960F7A), + MK_64(0xCCF7DDE5, 0xB45BC1C2) + }; /* blkSize = 256 bits. hashSize = 160 bits */ const u64 SKEIN_256_IV_160[] = - { - MK_64(0x14202314, 0x72825E98), - MK_64(0x2AC4E9A2, 0x5A77E590), - MK_64(0xD47A5856, 0x8838D63E), - MK_64(0x2DD2E496, 0x8586AB7D) - }; + { + MK_64(0x14202314, 0x72825E98), + MK_64(0x2AC4E9A2, 0x5A77E590), + MK_64(0xD47A5856, 0x8838D63E), + MK_64(0x2DD2E496, 0x8586AB7D) + }; /* blkSize = 256 bits. hashSize = 224 bits */ const u64 SKEIN_256_IV_224[] = - { - MK_64(0xC6098A8C, 0x9AE5EA0B), - MK_64(0x876D5686, 0x08C5191C), - MK_64(0x99CB88D7, 0xD7F53884), - MK_64(0x384BDDB1, 0xAEDDB5DE) - }; + { + MK_64(0xC6098A8C, 0x9AE5EA0B), + MK_64(0x876D5686, 0x08C5191C), + MK_64(0x99CB88D7, 0xD7F53884), + MK_64(0x384BDDB1, 0xAEDDB5DE) + }; /* blkSize = 256 bits. hashSize = 256 bits */ const u64 SKEIN_256_IV_256[] = - { - MK_64(0xFC9DA860, 0xD048B449), - MK_64(0x2FCA6647, 0x9FA7D833), - MK_64(0xB33BC389, 0x6656840F), - MK_64(0x6A54E920, 0xFDE8DA69) - }; + { + MK_64(0xFC9DA860, 0xD048B449), + MK_64(0x2FCA6647, 0x9FA7D833), + MK_64(0xB33BC389, 0x6656840F), + MK_64(0x6A54E920, 0xFDE8DA69) + }; /* blkSize = 512 bits. hashSize = 128 bits */ const u64 SKEIN_512_IV_128[] = - { - MK_64(0xA8BC7BF3, 0x6FBF9F52), - MK_64(0x1E9872CE, 0xBD1AF0AA), - MK_64(0x309B1790, 0xB32190D3), - MK_64(0xBCFBB854, 0x3F94805C), - MK_64(0x0DA61BCD, 0x6E31B11B), - MK_64(0x1A18EBEA, 0xD46A32E3), - MK_64(0xA2CC5B18, 0xCE84AA82), - MK_64(0x6982AB28, 0x9D46982D) - }; + { + MK_64(0xA8BC7BF3, 0x6FBF9F52), + MK_64(0x1E9872CE, 0xBD1AF0AA), + MK_64(0x309B1790, 0xB32190D3), + MK_64(0xBCFBB854, 0x3F94805C), + MK_64(0x0DA61BCD, 0x6E31B11B), + MK_64(0x1A18EBEA, 0xD46A32E3), + MK_64(0xA2CC5B18, 0xCE84AA82), + MK_64(0x6982AB28, 0x9D46982D) + }; /* blkSize = 512 bits. hashSize = 160 bits */ const u64 SKEIN_512_IV_160[] = - { - MK_64(0x28B81A2A, 0xE013BD91), - MK_64(0xC2F11668, 0xB5BDF78F), - MK_64(0x1760D8F3, 0xF6A56F12), - MK_64(0x4FB74758, 0x8239904F), - MK_64(0x21EDE07F, 0x7EAF5056), - MK_64(0xD908922E, 0x63ED70B8), - MK_64(0xB8EC76FF, 0xECCB52FA), - MK_64(0x01A47BB8, 0xA3F27A6E) - }; + { + MK_64(0x28B81A2A, 0xE013BD91), + MK_64(0xC2F11668, 0xB5BDF78F), + MK_64(0x1760D8F3, 0xF6A56F12), + MK_64(0x4FB74758, 0x8239904F), + MK_64(0x21EDE07F, 0x7EAF5056), + MK_64(0xD908922E, 0x63ED70B8), + MK_64(0xB8EC76FF, 0xECCB52FA), + MK_64(0x01A47BB8, 0xA3F27A6E) + }; /* blkSize = 512 bits. hashSize = 224 bits */ const u64 SKEIN_512_IV_224[] = - { - MK_64(0xCCD06162, 0x48677224), - MK_64(0xCBA65CF3, 0xA92339EF), - MK_64(0x8CCD69D6, 0x52FF4B64), - MK_64(0x398AED7B, 0x3AB890B4), - MK_64(0x0F59D1B1, 0x457D2BD0), - MK_64(0x6776FE65, 0x75D4EB3D), - MK_64(0x99FBC70E, 0x997413E9), - MK_64(0x9E2CFCCF, 0xE1C41EF7) - }; + { + MK_64(0xCCD06162, 0x48677224), + MK_64(0xCBA65CF3, 0xA92339EF), + MK_64(0x8CCD69D6, 0x52FF4B64), + MK_64(0x398AED7B, 0x3AB890B4), + MK_64(0x0F59D1B1, 0x457D2BD0), + MK_64(0x6776FE65, 0x75D4EB3D), + MK_64(0x99FBC70E, 0x997413E9), + MK_64(0x9E2CFCCF, 0xE1C41EF7) + }; /* blkSize = 512 bits. hashSize = 256 bits */ const u64 SKEIN_512_IV_256[] = - { - MK_64(0xCCD044A1, 0x2FDB3E13), - MK_64(0xE8359030, 0x1A79A9EB), - MK_64(0x55AEA061, 0x4F816E6F), - MK_64(0x2A2767A4, 0xAE9B94DB), - MK_64(0xEC06025E, 0x74DD7683), - MK_64(0xE7A436CD, 0xC4746251), - MK_64(0xC36FBAF9, 0x393AD185), - MK_64(0x3EEDBA18, 0x33EDFC13) - }; + { + MK_64(0xCCD044A1, 0x2FDB3E13), + MK_64(0xE8359030, 0x1A79A9EB), + MK_64(0x55AEA061, 0x4F816E6F), + MK_64(0x2A2767A4, 0xAE9B94DB), + MK_64(0xEC06025E, 0x74DD7683), + MK_64(0xE7A436CD, 0xC4746251), + MK_64(0xC36FBAF9, 0x393AD185), + MK_64(0x3EEDBA18, 0x33EDFC13) + }; /* blkSize = 512 bits. hashSize = 384 bits */ const u64 SKEIN_512_IV_384[] = - { - MK_64(0xA3F6C6BF, 0x3A75EF5F), - MK_64(0xB0FEF9CC, 0xFD84FAA4), - MK_64(0x9D77DD66, 0x3D770CFE), - MK_64(0xD798CBF3, 0xB468FDDA), - MK_64(0x1BC4A666, 0x8A0E4465), - MK_64(0x7ED7D434, 0xE5807407), - MK_64(0x548FC1AC, 0xD4EC44D6), - MK_64(0x266E1754, 0x6AA18FF8) - }; + { + MK_64(0xA3F6C6BF, 0x3A75EF5F), + MK_64(0xB0FEF9CC, 0xFD84FAA4), + MK_64(0x9D77DD66, 0x3D770CFE), + MK_64(0xD798CBF3, 0xB468FDDA), + MK_64(0x1BC4A666, 0x8A0E4465), + MK_64(0x7ED7D434, 0xE5807407), + MK_64(0x548FC1AC, 0xD4EC44D6), + MK_64(0x266E1754, 0x6AA18FF8) + }; /* blkSize = 512 bits. hashSize = 512 bits */ const u64 SKEIN_512_IV_512[] = - { - MK_64(0x4903ADFF, 0x749C51CE), - MK_64(0x0D95DE39, 0x9746DF03), - MK_64(0x8FD19341, 0x27C79BCE), - MK_64(0x9A255629, 0xFF352CB1), - MK_64(0x5DB62599, 0xDF6CA7B0), - MK_64(0xEABE394C, 0xA9D5C3F4), - MK_64(0x991112C7, 0x1A75B523), - MK_64(0xAE18A40B, 0x660FCC33) - }; + { + MK_64(0x4903ADFF, 0x749C51CE), + MK_64(0x0D95DE39, 0x9746DF03), + MK_64(0x8FD19341, 0x27C79BCE), + MK_64(0x9A255629, 0xFF352CB1), + MK_64(0x5DB62599, 0xDF6CA7B0), + MK_64(0xEABE394C, 0xA9D5C3F4), + MK_64(0x991112C7, 0x1A75B523), + MK_64(0xAE18A40B, 0x660FCC33) + }; /* blkSize = 1024 bits. hashSize = 384 bits */ const u64 SKEIN1024_IV_384[] = - { - MK_64(0x5102B6B8, 0xC1894A35), - MK_64(0xFEEBC9E3, 0xFE8AF11A), - MK_64(0x0C807F06, 0xE32BED71), - MK_64(0x60C13A52, 0xB41A91F6), - MK_64(0x9716D35D, 0xD4917C38), - MK_64(0xE780DF12, 0x6FD31D3A), - MK_64(0x797846B6, 0xC898303A), - MK_64(0xB172C2A8, 0xB3572A3B), - MK_64(0xC9BC8203, 0xA6104A6C), - MK_64(0x65909338, 0xD75624F4), - MK_64(0x94BCC568, 0x4B3F81A0), - MK_64(0x3EBBF51E, 0x10ECFD46), - MK_64(0x2DF50F0B, 0xEEB08542), - MK_64(0x3B5A6530, 0x0DBC6516), - MK_64(0x484B9CD2, 0x167BBCE1), - MK_64(0x2D136947, 0xD4CBAFEA) - }; + { + MK_64(0x5102B6B8, 0xC1894A35), + MK_64(0xFEEBC9E3, 0xFE8AF11A), + MK_64(0x0C807F06, 0xE32BED71), + MK_64(0x60C13A52, 0xB41A91F6), + MK_64(0x9716D35D, 0xD4917C38), + MK_64(0xE780DF12, 0x6FD31D3A), + MK_64(0x797846B6, 0xC898303A), + MK_64(0xB172C2A8, 0xB3572A3B), + MK_64(0xC9BC8203, 0xA6104A6C), + MK_64(0x65909338, 0xD75624F4), + MK_64(0x94BCC568, 0x4B3F81A0), + MK_64(0x3EBBF51E, 0x10ECFD46), + MK_64(0x2DF50F0B, 0xEEB08542), + MK_64(0x3B5A6530, 0x0DBC6516), + MK_64(0x484B9CD2, 0x167BBCE1), + MK_64(0x2D136947, 0xD4CBAFEA) + }; /* blkSize = 1024 bits. hashSize = 512 bits */ const u64 SKEIN1024_IV_512[] = - { - MK_64(0xCAEC0E5D, 0x7C1B1B18), - MK_64(0xA01B0E04, 0x5F03E802), - MK_64(0x33840451, 0xED912885), - MK_64(0x374AFB04, 0xEAEC2E1C), - MK_64(0xDF25A0E2, 0x813581F7), - MK_64(0xE4004093, 0x8B12F9D2), - MK_64(0xA662D539, 0xC2ED39B6), - MK_64(0xFA8B85CF, 0x45D8C75A), - MK_64(0x8316ED8E, 0x29EDE796), - MK_64(0x053289C0, 0x2E9F91B8), - MK_64(0xC3F8EF1D, 0x6D518B73), - MK_64(0xBDCEC3C4, 0xD5EF332E), - MK_64(0x549A7E52, 0x22974487), - MK_64(0x67070872, 0x5B749816), - MK_64(0xB9CD28FB, 0xF0581BD1), - MK_64(0x0E2940B8, 0x15804974) - }; + { + MK_64(0xCAEC0E5D, 0x7C1B1B18), + MK_64(0xA01B0E04, 0x5F03E802), + MK_64(0x33840451, 0xED912885), + MK_64(0x374AFB04, 0xEAEC2E1C), + MK_64(0xDF25A0E2, 0x813581F7), + MK_64(0xE4004093, 0x8B12F9D2), + MK_64(0xA662D539, 0xC2ED39B6), + MK_64(0xFA8B85CF, 0x45D8C75A), + MK_64(0x8316ED8E, 0x29EDE796), + MK_64(0x053289C0, 0x2E9F91B8), + MK_64(0xC3F8EF1D, 0x6D518B73), + MK_64(0xBDCEC3C4, 0xD5EF332E), + MK_64(0x549A7E52, 0x22974487), + MK_64(0x67070872, 0x5B749816), + MK_64(0xB9CD28FB, 0xF0581BD1), + MK_64(0x0E2940B8, 0x15804974) + }; /* blkSize = 1024 bits. hashSize = 1024 bits */ const u64 SKEIN1024_IV_1024[] = - { - MK_64(0xD593DA07, 0x41E72355), - MK_64(0x15B5E511, 0xAC73E00C), - MK_64(0x5180E5AE, 0xBAF2C4F0), - MK_64(0x03BD41D3, 0xFCBCAFAF), - MK_64(0x1CAEC6FD, 0x1983A898), - MK_64(0x6E510B8B, 0xCDD0589F), - MK_64(0x77E2BDFD, 0xC6394ADA), - MK_64(0xC11E1DB5, 0x24DCB0A3), - MK_64(0xD6D14AF9, 0xC6329AB5), - MK_64(0x6A9B0BFC, 0x6EB67E0D), - MK_64(0x9243C60D, 0xCCFF1332), - MK_64(0x1A1F1DDE, 0x743F02D4), - MK_64(0x0996753C, 0x10ED0BB8), - MK_64(0x6572DD22, 0xF2B4969A), - MK_64(0x61FD3062, 0xD00A579A), - MK_64(0x1DE0536E, 0x8682E539) - }; + { + MK_64(0xD593DA07, 0x41E72355), + MK_64(0x15B5E511, 0xAC73E00C), + MK_64(0x5180E5AE, 0xBAF2C4F0), + MK_64(0x03BD41D3, 0xFCBCAFAF), + MK_64(0x1CAEC6FD, 0x1983A898), + MK_64(0x6E510B8B, 0xCDD0589F), + MK_64(0x77E2BDFD, 0xC6394ADA), + MK_64(0xC11E1DB5, 0x24DCB0A3), + MK_64(0xD6D14AF9, 0xC6329AB5), + MK_64(0x6A9B0BFC, 0x6EB67E0D), + MK_64(0x9243C60D, 0xCCFF1332), + MK_64(0x1A1F1DDE, 0x743F02D4), + MK_64(0x0996753C, 0x10ED0BB8), + MK_64(0x6572DD22, 0xF2B4969A), + MK_64(0x61FD3062, 0xD00A579A), + MK_64(0x1DE0536E, 0x8682E539) + }; #endif /* _SKEIN_IV_H_ */ diff --git a/drivers/staging/skein/include/threefishApi.h b/drivers/staging/skein/include/threefishApi.h index 1f9e6e14f50b..199257e37813 100644 --- a/drivers/staging/skein/include/threefishApi.h +++ b/drivers/staging/skein/include/threefishApi.h @@ -33,125 +33,125 @@ #define KeyScheduleConst 0x1BD11BDAA9FC1A22L - /** - * Which Threefish size to use - */ - enum threefish_size { - Threefish256 = 256, /*!< Skein with 256 bit state */ - Threefish512 = 512, /*!< Skein with 512 bit state */ - Threefish1024 = 1024 /*!< Skein with 1024 bit state */ - }; - - /** - * Context for Threefish key and tweak words. - * - * This structure was setup with some know-how of the internal - * Skein structures, in particular ordering of header and size dependent - * variables. If Skein implementation changes this, the adapt these - * structures as well. - */ - struct threefish_key { - u64 stateSize; - u64 key[SKEIN_MAX_STATE_WORDS+1]; /* max number of key words*/ - u64 tweak[3]; - }; +/** + * Which Threefish size to use + */ +enum threefish_size { + Threefish256 = 256, /*!< Skein with 256 bit state */ + Threefish512 = 512, /*!< Skein with 512 bit state */ + Threefish1024 = 1024 /*!< Skein with 1024 bit state */ +}; + +/** + * Context for Threefish key and tweak words. + * + * This structure was setup with some know-how of the internal + * Skein structures, in particular ordering of header and size dependent + * variables. If Skein implementation changes this, the adapt these + * structures as well. + */ +struct threefish_key { + u64 stateSize; + u64 key[SKEIN_MAX_STATE_WORDS+1]; /* max number of key words*/ + u64 tweak[3]; +}; + +/** + * Set Threefish key and tweak data. + * + * This function sets the key and tweak data for the Threefish cipher of + * the given size. The key data must have the same length (number of bits) + * as the state size + * + * @param keyCtx + * Pointer to a Threefish key structure. + * @param size + * Which Skein size to use. + * @param keyData + * Pointer to the key words (word has 64 bits). + * @param tweak + * Pointer to the two tweak words (word has 64 bits). + */ +void threefishSetKey(struct threefish_key *keyCtx, enum threefish_size stateSize, u64 *keyData, u64 *tweak); + +/** + * Encrypt Threefisch block (bytes). + * + * The buffer must have at least the same length (number of bits) aas the + * state size for this key. The function uses the first @c stateSize bits + * of the input buffer, encrypts them and stores the result in the output + * buffer. + * + * @param keyCtx + * Pointer to a Threefish key structure. + * @param in + * Poionter to plaintext data buffer. + * @param out + * Pointer to cipher buffer. + */ +void threefishEncryptBlockBytes(struct threefish_key *keyCtx, u8 *in, u8 *out); - /** - * Set Threefish key and tweak data. - * - * This function sets the key and tweak data for the Threefish cipher of - * the given size. The key data must have the same length (number of bits) - * as the state size - * - * @param keyCtx - * Pointer to a Threefish key structure. - * @param size - * Which Skein size to use. - * @param keyData - * Pointer to the key words (word has 64 bits). - * @param tweak - * Pointer to the two tweak words (word has 64 bits). - */ - void threefishSetKey(struct threefish_key *keyCtx, enum threefish_size stateSize, u64 *keyData, u64 *tweak); - - /** - * Encrypt Threefisch block (bytes). - * - * The buffer must have at least the same length (number of bits) aas the - * state size for this key. The function uses the first @c stateSize bits - * of the input buffer, encrypts them and stores the result in the output - * buffer. - * - * @param keyCtx - * Pointer to a Threefish key structure. - * @param in - * Poionter to plaintext data buffer. - * @param out - * Pointer to cipher buffer. - */ - void threefishEncryptBlockBytes(struct threefish_key *keyCtx, u8 *in, u8 *out); - - /** - * Encrypt Threefisch block (words). - * - * The buffer must have at least the same length (number of bits) aas the - * state size for this key. The function uses the first @c stateSize bits - * of the input buffer, encrypts them and stores the result in the output - * buffer. - * - * The wordsize ist set to 64 bits. - * - * @param keyCtx - * Pointer to a Threefish key structure. - * @param in - * Poionter to plaintext data buffer. - * @param out - * Pointer to cipher buffer. - */ - void threefishEncryptBlockWords(struct threefish_key *keyCtx, u64 *in, u64 *out); +/** + * Encrypt Threefisch block (words). + * + * The buffer must have at least the same length (number of bits) aas the + * state size for this key. The function uses the first @c stateSize bits + * of the input buffer, encrypts them and stores the result in the output + * buffer. + * + * The wordsize ist set to 64 bits. + * + * @param keyCtx + * Pointer to a Threefish key structure. + * @param in + * Poionter to plaintext data buffer. + * @param out + * Pointer to cipher buffer. + */ +void threefishEncryptBlockWords(struct threefish_key *keyCtx, u64 *in, u64 *out); - /** - * Decrypt Threefisch block (bytes). - * - * The buffer must have at least the same length (number of bits) aas the - * state size for this key. The function uses the first @c stateSize bits - * of the input buffer, decrypts them and stores the result in the output - * buffer - * - * @param keyCtx - * Pointer to a Threefish key structure. - * @param in - * Poionter to cipher data buffer. - * @param out - * Pointer to plaintext buffer. - */ - void threefishDecryptBlockBytes(struct threefish_key *keyCtx, u8 *in, u8 *out); +/** + * Decrypt Threefisch block (bytes). + * + * The buffer must have at least the same length (number of bits) aas the + * state size for this key. The function uses the first @c stateSize bits + * of the input buffer, decrypts them and stores the result in the output + * buffer + * + * @param keyCtx + * Pointer to a Threefish key structure. + * @param in + * Poionter to cipher data buffer. + * @param out + * Pointer to plaintext buffer. + */ +void threefishDecryptBlockBytes(struct threefish_key *keyCtx, u8 *in, u8 *out); - /** - * Decrypt Threefisch block (words). - * - * The buffer must have at least the same length (number of bits) aas the - * state size for this key. The function uses the first @c stateSize bits - * of the input buffer, encrypts them and stores the result in the output - * buffer. - * - * The wordsize ist set to 64 bits. - * - * @param keyCtx - * Pointer to a Threefish key structure. - * @param in - * Poionter to cipher data buffer. - * @param out - * Pointer to plaintext buffer. - */ - void threefishDecryptBlockWords(struct threefish_key *keyCtx, u64 *in, u64 *out); +/** + * Decrypt Threefisch block (words). + * + * The buffer must have at least the same length (number of bits) aas the + * state size for this key. The function uses the first @c stateSize bits + * of the input buffer, encrypts them and stores the result in the output + * buffer. + * + * The wordsize ist set to 64 bits. + * + * @param keyCtx + * Pointer to a Threefish key structure. + * @param in + * Poionter to cipher data buffer. + * @param out + * Pointer to plaintext buffer. + */ +void threefishDecryptBlockWords(struct threefish_key *keyCtx, u64 *in, u64 *out); - void threefishEncrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output); - void threefishEncrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output); - void threefishEncrypt1024(struct threefish_key *keyCtx, u64 *input, u64 *output); - void threefishDecrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output); - void threefishDecrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output); - void threefishDecrypt1024(struct threefish_key *keyCtx, u64 *input, u64 *output); +void threefishEncrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output); +void threefishEncrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output); +void threefishEncrypt1024(struct threefish_key *keyCtx, u64 *input, u64 *output); +void threefishDecrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output); +void threefishDecrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output); +void threefishDecrypt1024(struct threefish_key *keyCtx, u64 *input, u64 *output); /** * @} */ diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c index e2e5685157a0..3f0f32806181 100644 --- a/drivers/staging/skein/skein.c +++ b/drivers/staging/skein/skein.c @@ -28,49 +28,49 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, siz /* init the context for a straight hashing operation */ int Skein_256_Init(struct skein_256_ctx *ctx, size_t hashBitLen) { - union - { - u8 b[SKEIN_256_STATE_BYTES]; - u64 w[SKEIN_256_STATE_WORDS]; - } cfg; /* config block */ - - Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN); - ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ - - switch (hashBitLen) - { /* use pre-computed values, where available */ - case 256: - memcpy(ctx->X, SKEIN_256_IV_256, sizeof(ctx->X)); - break; - case 224: - memcpy(ctx->X, SKEIN_256_IV_224, sizeof(ctx->X)); - break; - case 160: - memcpy(ctx->X, SKEIN_256_IV_160, sizeof(ctx->X)); - break; - case 128: - memcpy(ctx->X, SKEIN_256_IV_128, sizeof(ctx->X)); - break; - default: - /* here if there is no precomputed IV value available */ - /* build/process the config block, type == CONFIG (could be precomputed) */ - Skein_Start_New_Type(ctx, CFG_FINAL); /* set tweaks: T0=0; T1=CFG | FINAL */ - - cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); /* set the schema, version */ - cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ - cfg.w[2] = Skein_Swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); - memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); /* zero pad config block */ - - /* compute the initial chaining values from config block */ - memset(ctx->X, 0, sizeof(ctx->X)); /* zero the chaining variables */ - Skein_256_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); - break; - } - /* The chaining vars ctx->X are now initialized for the given hashBitLen. */ - /* Set up to process the data message portion of the hash (default) */ - Skein_Start_New_Type(ctx, MSG); /* T0=0, T1= MSG type */ - - return SKEIN_SUCCESS; + union + { + u8 b[SKEIN_256_STATE_BYTES]; + u64 w[SKEIN_256_STATE_WORDS]; + } cfg; /* config block */ + + Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN); + ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ + + switch (hashBitLen) + { /* use pre-computed values, where available */ + case 256: + memcpy(ctx->X, SKEIN_256_IV_256, sizeof(ctx->X)); + break; + case 224: + memcpy(ctx->X, SKEIN_256_IV_224, sizeof(ctx->X)); + break; + case 160: + memcpy(ctx->X, SKEIN_256_IV_160, sizeof(ctx->X)); + break; + case 128: + memcpy(ctx->X, SKEIN_256_IV_128, sizeof(ctx->X)); + break; + default: + /* here if there is no precomputed IV value available */ + /* build/process the config block, type == CONFIG (could be precomputed) */ + Skein_Start_New_Type(ctx, CFG_FINAL); /* set tweaks: T0=0; T1=CFG | FINAL */ + + cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); /* set the schema, version */ + cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ + cfg.w[2] = Skein_Swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); + memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); /* zero pad config block */ + + /* compute the initial chaining values from config block */ + memset(ctx->X, 0, sizeof(ctx->X)); /* zero the chaining variables */ + Skein_256_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); + break; + } + /* The chaining vars ctx->X are now initialized for the given hashBitLen. */ + /* Set up to process the data message portion of the hash (default) */ + Skein_Start_New_Type(ctx, MSG); /* T0=0, T1= MSG type */ + + return SKEIN_SUCCESS; } /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ @@ -78,133 +78,133 @@ int Skein_256_Init(struct skein_256_ctx *ctx, size_t hashBitLen) /* [identical to Skein_256_Init() when keyBytes == 0 && treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ int Skein_256_InitExt(struct skein_256_ctx *ctx, size_t hashBitLen, u64 treeInfo, const u8 *key, size_t keyBytes) { - union - { - u8 b[SKEIN_256_STATE_BYTES]; - u64 w[SKEIN_256_STATE_WORDS]; - } cfg; /* config block */ - - Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN); - Skein_Assert(keyBytes == 0 || key != NULL, SKEIN_FAIL); - - /* compute the initial chaining values ctx->X[], based on key */ - if (keyBytes == 0) /* is there a key? */ - { - memset(ctx->X, 0, sizeof(ctx->X)); /* no key: use all zeroes as key for config block */ - } - else /* here to pre-process a key */ - { - Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); - /* do a mini-Init right here */ - ctx->h.hashBitLen = 8*sizeof(ctx->X); /* set output hash bit count = state size */ - Skein_Start_New_Type(ctx, KEY); /* set tweaks: T0 = 0; T1 = KEY type */ - memset(ctx->X, 0, sizeof(ctx->X)); /* zero the initial chaining variables */ - Skein_256_Update(ctx, key, keyBytes); /* hash the key */ - Skein_256_Final_Pad(ctx, cfg.b); /* put result into cfg.b[] */ - memcpy(ctx->X, cfg.b, sizeof(cfg.b)); /* copy over into ctx->X[] */ - } - /* build/process the config block, type == CONFIG (could be precomputed for each key) */ - ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ - Skein_Start_New_Type(ctx, CFG_FINAL); - - memset(&cfg.w, 0, sizeof(cfg.w)); /* pre-pad cfg.w[] with zeroes */ - cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); - cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ - cfg.w[2] = Skein_Swap64(treeInfo); /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ - - Skein_Show_Key(256, &ctx->h, key, keyBytes); - - /* compute the initial chaining values from config block */ - Skein_256_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); - - /* The chaining vars ctx->X are now initialized */ - /* Set up to process the data message portion of the hash (default) */ - Skein_Start_New_Type(ctx, MSG); - - return SKEIN_SUCCESS; + union + { + u8 b[SKEIN_256_STATE_BYTES]; + u64 w[SKEIN_256_STATE_WORDS]; + } cfg; /* config block */ + + Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN); + Skein_Assert(keyBytes == 0 || key != NULL, SKEIN_FAIL); + + /* compute the initial chaining values ctx->X[], based on key */ + if (keyBytes == 0) /* is there a key? */ + { + memset(ctx->X, 0, sizeof(ctx->X)); /* no key: use all zeroes as key for config block */ + } + else /* here to pre-process a key */ + { + Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); + /* do a mini-Init right here */ + ctx->h.hashBitLen = 8*sizeof(ctx->X); /* set output hash bit count = state size */ + Skein_Start_New_Type(ctx, KEY); /* set tweaks: T0 = 0; T1 = KEY type */ + memset(ctx->X, 0, sizeof(ctx->X)); /* zero the initial chaining variables */ + Skein_256_Update(ctx, key, keyBytes); /* hash the key */ + Skein_256_Final_Pad(ctx, cfg.b); /* put result into cfg.b[] */ + memcpy(ctx->X, cfg.b, sizeof(cfg.b)); /* copy over into ctx->X[] */ + } + /* build/process the config block, type == CONFIG (could be precomputed for each key) */ + ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ + Skein_Start_New_Type(ctx, CFG_FINAL); + + memset(&cfg.w, 0, sizeof(cfg.w)); /* pre-pad cfg.w[] with zeroes */ + cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); + cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ + cfg.w[2] = Skein_Swap64(treeInfo); /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ + + Skein_Show_Key(256, &ctx->h, key, keyBytes); + + /* compute the initial chaining values from config block */ + Skein_256_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); + + /* The chaining vars ctx->X are now initialized */ + /* Set up to process the data message portion of the hash (default) */ + Skein_Start_New_Type(ctx, MSG); + + return SKEIN_SUCCESS; } /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* process the input bytes */ int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg, size_t msgByteCnt) { - size_t n; - - Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ - - /* process full blocks, if any */ - if (msgByteCnt + ctx->h.bCnt > SKEIN_256_BLOCK_BYTES) - { - if (ctx->h.bCnt) /* finish up any buffered message data */ - { - n = SKEIN_256_BLOCK_BYTES - ctx->h.bCnt; /* # bytes free in buffer b[] */ - if (n) - { - Skein_assert(n < msgByteCnt); /* check on our logic here */ - memcpy(&ctx->b[ctx->h.bCnt], msg, n); - msgByteCnt -= n; - msg += n; - ctx->h.bCnt += n; - } - Skein_assert(ctx->h.bCnt == SKEIN_256_BLOCK_BYTES); - Skein_256_Process_Block(ctx, ctx->b, 1, SKEIN_256_BLOCK_BYTES); - ctx->h.bCnt = 0; - } - /* now process any remaining full blocks, directly from input message data */ - if (msgByteCnt > SKEIN_256_BLOCK_BYTES) - { - n = (msgByteCnt-1) / SKEIN_256_BLOCK_BYTES; /* number of full blocks to process */ - Skein_256_Process_Block(ctx, msg, n, SKEIN_256_BLOCK_BYTES); - msgByteCnt -= n * SKEIN_256_BLOCK_BYTES; - msg += n * SKEIN_256_BLOCK_BYTES; - } - Skein_assert(ctx->h.bCnt == 0); - } - - /* copy any remaining source message data bytes into b[] */ - if (msgByteCnt) - { - Skein_assert(msgByteCnt + ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES); - memcpy(&ctx->b[ctx->h.bCnt], msg, msgByteCnt); - ctx->h.bCnt += msgByteCnt; - } - - return SKEIN_SUCCESS; + size_t n; + + Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ + + /* process full blocks, if any */ + if (msgByteCnt + ctx->h.bCnt > SKEIN_256_BLOCK_BYTES) + { + if (ctx->h.bCnt) /* finish up any buffered message data */ + { + n = SKEIN_256_BLOCK_BYTES - ctx->h.bCnt; /* # bytes free in buffer b[] */ + if (n) + { + Skein_assert(n < msgByteCnt); /* check on our logic here */ + memcpy(&ctx->b[ctx->h.bCnt], msg, n); + msgByteCnt -= n; + msg += n; + ctx->h.bCnt += n; + } + Skein_assert(ctx->h.bCnt == SKEIN_256_BLOCK_BYTES); + Skein_256_Process_Block(ctx, ctx->b, 1, SKEIN_256_BLOCK_BYTES); + ctx->h.bCnt = 0; + } + /* now process any remaining full blocks, directly from input message data */ + if (msgByteCnt > SKEIN_256_BLOCK_BYTES) + { + n = (msgByteCnt-1) / SKEIN_256_BLOCK_BYTES; /* number of full blocks to process */ + Skein_256_Process_Block(ctx, msg, n, SKEIN_256_BLOCK_BYTES); + msgByteCnt -= n * SKEIN_256_BLOCK_BYTES; + msg += n * SKEIN_256_BLOCK_BYTES; + } + Skein_assert(ctx->h.bCnt == 0); + } + + /* copy any remaining source message data bytes into b[] */ + if (msgByteCnt) + { + Skein_assert(msgByteCnt + ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES); + memcpy(&ctx->b[ctx->h.bCnt], msg, msgByteCnt); + ctx->h.bCnt += msgByteCnt; + } + + return SKEIN_SUCCESS; } /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the result */ int Skein_256_Final(struct skein_256_ctx *ctx, u8 *hashVal) { - size_t i, n, byteCnt; - u64 X[SKEIN_256_STATE_WORDS]; - Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ - - ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ - if (ctx->h.bCnt < SKEIN_256_BLOCK_BYTES) /* zero pad b[] if necessary */ - memset(&ctx->b[ctx->h.bCnt], 0, SKEIN_256_BLOCK_BYTES - ctx->h.bCnt); - - Skein_256_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); /* process the final block */ - - /* now output the result */ - byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ - - /* run Threefish in "counter mode" to generate output */ - memset(ctx->b, 0, sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ - memcpy(X, ctx->X, sizeof(X)); /* keep a local copy of counter mode "key" */ - for (i = 0; i*SKEIN_256_BLOCK_BYTES < byteCnt; i++) - { - ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); /* build the counter block */ - Skein_Start_New_Type(ctx, OUT_FINAL); - Skein_256_Process_Block(ctx, ctx->b, 1, sizeof(u64)); /* run "counter mode" */ - n = byteCnt - i*SKEIN_256_BLOCK_BYTES; /* number of output bytes left to go */ - if (n >= SKEIN_256_BLOCK_BYTES) - n = SKEIN_256_BLOCK_BYTES; - Skein_Put64_LSB_First(hashVal+i*SKEIN_256_BLOCK_BYTES, ctx->X, n); /* "output" the ctr mode bytes */ - Skein_Show_Final(256, &ctx->h, n, hashVal+i*SKEIN_256_BLOCK_BYTES); - memcpy(ctx->X, X, sizeof(X)); /* restore the counter mode key for next time */ - } - return SKEIN_SUCCESS; + size_t i, n, byteCnt; + u64 X[SKEIN_256_STATE_WORDS]; + Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ + + ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ + if (ctx->h.bCnt < SKEIN_256_BLOCK_BYTES) /* zero pad b[] if necessary */ + memset(&ctx->b[ctx->h.bCnt], 0, SKEIN_256_BLOCK_BYTES - ctx->h.bCnt); + + Skein_256_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); /* process the final block */ + + /* now output the result */ + byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ + + /* run Threefish in "counter mode" to generate output */ + memset(ctx->b, 0, sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ + memcpy(X, ctx->X, sizeof(X)); /* keep a local copy of counter mode "key" */ + for (i = 0; i*SKEIN_256_BLOCK_BYTES < byteCnt; i++) + { + ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); /* build the counter block */ + Skein_Start_New_Type(ctx, OUT_FINAL); + Skein_256_Process_Block(ctx, ctx->b, 1, sizeof(u64)); /* run "counter mode" */ + n = byteCnt - i*SKEIN_256_BLOCK_BYTES; /* number of output bytes left to go */ + if (n >= SKEIN_256_BLOCK_BYTES) + n = SKEIN_256_BLOCK_BYTES; + Skein_Put64_LSB_First(hashVal+i*SKEIN_256_BLOCK_BYTES, ctx->X, n); /* "output" the ctr mode bytes */ + Skein_Show_Final(256, &ctx->h, n, hashVal+i*SKEIN_256_BLOCK_BYTES); + memcpy(ctx->X, X, sizeof(X)); /* restore the counter mode key for next time */ + } + return SKEIN_SUCCESS; } /*****************************************************************/ @@ -215,50 +215,50 @@ int Skein_256_Final(struct skein_256_ctx *ctx, u8 *hashVal) /* init the context for a straight hashing operation */ int Skein_512_Init(struct skein_512_ctx *ctx, size_t hashBitLen) { - union - { - u8 b[SKEIN_512_STATE_BYTES]; - u64 w[SKEIN_512_STATE_WORDS]; - } cfg; /* config block */ - - Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN); - ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ - - switch (hashBitLen) - { /* use pre-computed values, where available */ - case 512: - memcpy(ctx->X, SKEIN_512_IV_512, sizeof(ctx->X)); - break; - case 384: - memcpy(ctx->X, SKEIN_512_IV_384, sizeof(ctx->X)); - break; - case 256: - memcpy(ctx->X, SKEIN_512_IV_256, sizeof(ctx->X)); - break; - case 224: - memcpy(ctx->X, SKEIN_512_IV_224, sizeof(ctx->X)); - break; - default: - /* here if there is no precomputed IV value available */ - /* build/process the config block, type == CONFIG (could be precomputed) */ - Skein_Start_New_Type(ctx, CFG_FINAL); /* set tweaks: T0=0; T1=CFG | FINAL */ - - cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); /* set the schema, version */ - cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ - cfg.w[2] = Skein_Swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); - memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); /* zero pad config block */ - - /* compute the initial chaining values from config block */ - memset(ctx->X, 0, sizeof(ctx->X)); /* zero the chaining variables */ - Skein_512_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); - break; - } - - /* The chaining vars ctx->X are now initialized for the given hashBitLen. */ - /* Set up to process the data message portion of the hash (default) */ - Skein_Start_New_Type(ctx, MSG); /* T0=0, T1= MSG type */ - - return SKEIN_SUCCESS; + union + { + u8 b[SKEIN_512_STATE_BYTES]; + u64 w[SKEIN_512_STATE_WORDS]; + } cfg; /* config block */ + + Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN); + ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ + + switch (hashBitLen) + { /* use pre-computed values, where available */ + case 512: + memcpy(ctx->X, SKEIN_512_IV_512, sizeof(ctx->X)); + break; + case 384: + memcpy(ctx->X, SKEIN_512_IV_384, sizeof(ctx->X)); + break; + case 256: + memcpy(ctx->X, SKEIN_512_IV_256, sizeof(ctx->X)); + break; + case 224: + memcpy(ctx->X, SKEIN_512_IV_224, sizeof(ctx->X)); + break; + default: + /* here if there is no precomputed IV value available */ + /* build/process the config block, type == CONFIG (could be precomputed) */ + Skein_Start_New_Type(ctx, CFG_FINAL); /* set tweaks: T0=0; T1=CFG | FINAL */ + + cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); /* set the schema, version */ + cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ + cfg.w[2] = Skein_Swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); + memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); /* zero pad config block */ + + /* compute the initial chaining values from config block */ + memset(ctx->X, 0, sizeof(ctx->X)); /* zero the chaining variables */ + Skein_512_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); + break; + } + + /* The chaining vars ctx->X are now initialized for the given hashBitLen. */ + /* Set up to process the data message portion of the hash (default) */ + Skein_Start_New_Type(ctx, MSG); /* T0=0, T1= MSG type */ + + return SKEIN_SUCCESS; } /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ @@ -266,133 +266,133 @@ int Skein_512_Init(struct skein_512_ctx *ctx, size_t hashBitLen) /* [identical to Skein_512_Init() when keyBytes == 0 && treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ int Skein_512_InitExt(struct skein_512_ctx *ctx, size_t hashBitLen, u64 treeInfo, const u8 *key, size_t keyBytes) { - union - { - u8 b[SKEIN_512_STATE_BYTES]; - u64 w[SKEIN_512_STATE_WORDS]; - } cfg; /* config block */ - - Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN); - Skein_Assert(keyBytes == 0 || key != NULL, SKEIN_FAIL); - - /* compute the initial chaining values ctx->X[], based on key */ - if (keyBytes == 0) /* is there a key? */ - { - memset(ctx->X, 0, sizeof(ctx->X)); /* no key: use all zeroes as key for config block */ - } - else /* here to pre-process a key */ - { - Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); - /* do a mini-Init right here */ - ctx->h.hashBitLen = 8*sizeof(ctx->X); /* set output hash bit count = state size */ - Skein_Start_New_Type(ctx, KEY); /* set tweaks: T0 = 0; T1 = KEY type */ - memset(ctx->X, 0, sizeof(ctx->X)); /* zero the initial chaining variables */ - Skein_512_Update(ctx, key, keyBytes); /* hash the key */ - Skein_512_Final_Pad(ctx, cfg.b); /* put result into cfg.b[] */ - memcpy(ctx->X, cfg.b, sizeof(cfg.b)); /* copy over into ctx->X[] */ - } - /* build/process the config block, type == CONFIG (could be precomputed for each key) */ - ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ - Skein_Start_New_Type(ctx, CFG_FINAL); - - memset(&cfg.w, 0, sizeof(cfg.w)); /* pre-pad cfg.w[] with zeroes */ - cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); - cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ - cfg.w[2] = Skein_Swap64(treeInfo); /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ - - Skein_Show_Key(512, &ctx->h, key, keyBytes); - - /* compute the initial chaining values from config block */ - Skein_512_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); - - /* The chaining vars ctx->X are now initialized */ - /* Set up to process the data message portion of the hash (default) */ - Skein_Start_New_Type(ctx, MSG); - - return SKEIN_SUCCESS; + union + { + u8 b[SKEIN_512_STATE_BYTES]; + u64 w[SKEIN_512_STATE_WORDS]; + } cfg; /* config block */ + + Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN); + Skein_Assert(keyBytes == 0 || key != NULL, SKEIN_FAIL); + + /* compute the initial chaining values ctx->X[], based on key */ + if (keyBytes == 0) /* is there a key? */ + { + memset(ctx->X, 0, sizeof(ctx->X)); /* no key: use all zeroes as key for config block */ + } + else /* here to pre-process a key */ + { + Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); + /* do a mini-Init right here */ + ctx->h.hashBitLen = 8*sizeof(ctx->X); /* set output hash bit count = state size */ + Skein_Start_New_Type(ctx, KEY); /* set tweaks: T0 = 0; T1 = KEY type */ + memset(ctx->X, 0, sizeof(ctx->X)); /* zero the initial chaining variables */ + Skein_512_Update(ctx, key, keyBytes); /* hash the key */ + Skein_512_Final_Pad(ctx, cfg.b); /* put result into cfg.b[] */ + memcpy(ctx->X, cfg.b, sizeof(cfg.b)); /* copy over into ctx->X[] */ + } + /* build/process the config block, type == CONFIG (could be precomputed for each key) */ + ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ + Skein_Start_New_Type(ctx, CFG_FINAL); + + memset(&cfg.w, 0, sizeof(cfg.w)); /* pre-pad cfg.w[] with zeroes */ + cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); + cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ + cfg.w[2] = Skein_Swap64(treeInfo); /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ + + Skein_Show_Key(512, &ctx->h, key, keyBytes); + + /* compute the initial chaining values from config block */ + Skein_512_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); + + /* The chaining vars ctx->X are now initialized */ + /* Set up to process the data message portion of the hash (default) */ + Skein_Start_New_Type(ctx, MSG); + + return SKEIN_SUCCESS; } /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* process the input bytes */ int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg, size_t msgByteCnt) { - size_t n; - - Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ - - /* process full blocks, if any */ - if (msgByteCnt + ctx->h.bCnt > SKEIN_512_BLOCK_BYTES) - { - if (ctx->h.bCnt) /* finish up any buffered message data */ - { - n = SKEIN_512_BLOCK_BYTES - ctx->h.bCnt; /* # bytes free in buffer b[] */ - if (n) - { - Skein_assert(n < msgByteCnt); /* check on our logic here */ - memcpy(&ctx->b[ctx->h.bCnt], msg, n); - msgByteCnt -= n; - msg += n; - ctx->h.bCnt += n; - } - Skein_assert(ctx->h.bCnt == SKEIN_512_BLOCK_BYTES); - Skein_512_Process_Block(ctx, ctx->b, 1, SKEIN_512_BLOCK_BYTES); - ctx->h.bCnt = 0; - } - /* now process any remaining full blocks, directly from input message data */ - if (msgByteCnt > SKEIN_512_BLOCK_BYTES) - { - n = (msgByteCnt-1) / SKEIN_512_BLOCK_BYTES; /* number of full blocks to process */ - Skein_512_Process_Block(ctx, msg, n, SKEIN_512_BLOCK_BYTES); - msgByteCnt -= n * SKEIN_512_BLOCK_BYTES; - msg += n * SKEIN_512_BLOCK_BYTES; - } - Skein_assert(ctx->h.bCnt == 0); - } - - /* copy any remaining source message data bytes into b[] */ - if (msgByteCnt) - { - Skein_assert(msgByteCnt + ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES); - memcpy(&ctx->b[ctx->h.bCnt], msg, msgByteCnt); - ctx->h.bCnt += msgByteCnt; - } - - return SKEIN_SUCCESS; + size_t n; + + Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ + + /* process full blocks, if any */ + if (msgByteCnt + ctx->h.bCnt > SKEIN_512_BLOCK_BYTES) + { + if (ctx->h.bCnt) /* finish up any buffered message data */ + { + n = SKEIN_512_BLOCK_BYTES - ctx->h.bCnt; /* # bytes free in buffer b[] */ + if (n) + { + Skein_assert(n < msgByteCnt); /* check on our logic here */ + memcpy(&ctx->b[ctx->h.bCnt], msg, n); + msgByteCnt -= n; + msg += n; + ctx->h.bCnt += n; + } + Skein_assert(ctx->h.bCnt == SKEIN_512_BLOCK_BYTES); + Skein_512_Process_Block(ctx, ctx->b, 1, SKEIN_512_BLOCK_BYTES); + ctx->h.bCnt = 0; + } + /* now process any remaining full blocks, directly from input message data */ + if (msgByteCnt > SKEIN_512_BLOCK_BYTES) + { + n = (msgByteCnt-1) / SKEIN_512_BLOCK_BYTES; /* number of full blocks to process */ + Skein_512_Process_Block(ctx, msg, n, SKEIN_512_BLOCK_BYTES); + msgByteCnt -= n * SKEIN_512_BLOCK_BYTES; + msg += n * SKEIN_512_BLOCK_BYTES; + } + Skein_assert(ctx->h.bCnt == 0); + } + + /* copy any remaining source message data bytes into b[] */ + if (msgByteCnt) + { + Skein_assert(msgByteCnt + ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES); + memcpy(&ctx->b[ctx->h.bCnt], msg, msgByteCnt); + ctx->h.bCnt += msgByteCnt; + } + + return SKEIN_SUCCESS; } /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the result */ int Skein_512_Final(struct skein_512_ctx *ctx, u8 *hashVal) { - size_t i, n, byteCnt; - u64 X[SKEIN_512_STATE_WORDS]; - Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ - - ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ - if (ctx->h.bCnt < SKEIN_512_BLOCK_BYTES) /* zero pad b[] if necessary */ - memset(&ctx->b[ctx->h.bCnt], 0, SKEIN_512_BLOCK_BYTES - ctx->h.bCnt); - - Skein_512_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); /* process the final block */ - - /* now output the result */ - byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ - - /* run Threefish in "counter mode" to generate output */ - memset(ctx->b, 0, sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ - memcpy(X, ctx->X, sizeof(X)); /* keep a local copy of counter mode "key" */ - for (i = 0; i*SKEIN_512_BLOCK_BYTES < byteCnt; i++) - { - ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); /* build the counter block */ - Skein_Start_New_Type(ctx, OUT_FINAL); - Skein_512_Process_Block(ctx, ctx->b, 1, sizeof(u64)); /* run "counter mode" */ - n = byteCnt - i*SKEIN_512_BLOCK_BYTES; /* number of output bytes left to go */ - if (n >= SKEIN_512_BLOCK_BYTES) - n = SKEIN_512_BLOCK_BYTES; - Skein_Put64_LSB_First(hashVal+i*SKEIN_512_BLOCK_BYTES, ctx->X, n); /* "output" the ctr mode bytes */ - Skein_Show_Final(512, &ctx->h, n, hashVal+i*SKEIN_512_BLOCK_BYTES); - memcpy(ctx->X, X, sizeof(X)); /* restore the counter mode key for next time */ - } - return SKEIN_SUCCESS; + size_t i, n, byteCnt; + u64 X[SKEIN_512_STATE_WORDS]; + Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ + + ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ + if (ctx->h.bCnt < SKEIN_512_BLOCK_BYTES) /* zero pad b[] if necessary */ + memset(&ctx->b[ctx->h.bCnt], 0, SKEIN_512_BLOCK_BYTES - ctx->h.bCnt); + + Skein_512_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); /* process the final block */ + + /* now output the result */ + byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ + + /* run Threefish in "counter mode" to generate output */ + memset(ctx->b, 0, sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ + memcpy(X, ctx->X, sizeof(X)); /* keep a local copy of counter mode "key" */ + for (i = 0; i*SKEIN_512_BLOCK_BYTES < byteCnt; i++) + { + ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); /* build the counter block */ + Skein_Start_New_Type(ctx, OUT_FINAL); + Skein_512_Process_Block(ctx, ctx->b, 1, sizeof(u64)); /* run "counter mode" */ + n = byteCnt - i*SKEIN_512_BLOCK_BYTES; /* number of output bytes left to go */ + if (n >= SKEIN_512_BLOCK_BYTES) + n = SKEIN_512_BLOCK_BYTES; + Skein_Put64_LSB_First(hashVal+i*SKEIN_512_BLOCK_BYTES, ctx->X, n); /* "output" the ctr mode bytes */ + Skein_Show_Final(512, &ctx->h, n, hashVal+i*SKEIN_512_BLOCK_BYTES); + memcpy(ctx->X, X, sizeof(X)); /* restore the counter mode key for next time */ + } + return SKEIN_SUCCESS; } /*****************************************************************/ @@ -403,47 +403,47 @@ int Skein_512_Final(struct skein_512_ctx *ctx, u8 *hashVal) /* init the context for a straight hashing operation */ int Skein1024_Init(struct skein1024_ctx *ctx, size_t hashBitLen) { - union - { - u8 b[SKEIN1024_STATE_BYTES]; - u64 w[SKEIN1024_STATE_WORDS]; - } cfg; /* config block */ - - Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN); - ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ - - switch (hashBitLen) - { /* use pre-computed values, where available */ - case 512: - memcpy(ctx->X, SKEIN1024_IV_512, sizeof(ctx->X)); - break; - case 384: - memcpy(ctx->X, SKEIN1024_IV_384, sizeof(ctx->X)); - break; - case 1024: - memcpy(ctx->X, SKEIN1024_IV_1024, sizeof(ctx->X)); - break; - default: - /* here if there is no precomputed IV value available */ - /* build/process the config block, type == CONFIG (could be precomputed) */ - Skein_Start_New_Type(ctx, CFG_FINAL); /* set tweaks: T0=0; T1=CFG | FINAL */ - - cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); /* set the schema, version */ - cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ - cfg.w[2] = Skein_Swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); - memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); /* zero pad config block */ - - /* compute the initial chaining values from config block */ - memset(ctx->X, 0, sizeof(ctx->X)); /* zero the chaining variables */ - Skein1024_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); - break; - } - - /* The chaining vars ctx->X are now initialized for the given hashBitLen. */ - /* Set up to process the data message portion of the hash (default) */ - Skein_Start_New_Type(ctx, MSG); /* T0=0, T1= MSG type */ - - return SKEIN_SUCCESS; + union + { + u8 b[SKEIN1024_STATE_BYTES]; + u64 w[SKEIN1024_STATE_WORDS]; + } cfg; /* config block */ + + Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN); + ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ + + switch (hashBitLen) + { /* use pre-computed values, where available */ + case 512: + memcpy(ctx->X, SKEIN1024_IV_512, sizeof(ctx->X)); + break; + case 384: + memcpy(ctx->X, SKEIN1024_IV_384, sizeof(ctx->X)); + break; + case 1024: + memcpy(ctx->X, SKEIN1024_IV_1024, sizeof(ctx->X)); + break; + default: + /* here if there is no precomputed IV value available */ + /* build/process the config block, type == CONFIG (could be precomputed) */ + Skein_Start_New_Type(ctx, CFG_FINAL); /* set tweaks: T0=0; T1=CFG | FINAL */ + + cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); /* set the schema, version */ + cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ + cfg.w[2] = Skein_Swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); + memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); /* zero pad config block */ + + /* compute the initial chaining values from config block */ + memset(ctx->X, 0, sizeof(ctx->X)); /* zero the chaining variables */ + Skein1024_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); + break; + } + + /* The chaining vars ctx->X are now initialized for the given hashBitLen. */ + /* Set up to process the data message portion of the hash (default) */ + Skein_Start_New_Type(ctx, MSG); /* T0=0, T1= MSG type */ + + return SKEIN_SUCCESS; } /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ @@ -451,133 +451,133 @@ int Skein1024_Init(struct skein1024_ctx *ctx, size_t hashBitLen) /* [identical to Skein1024_Init() when keyBytes == 0 && treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ int Skein1024_InitExt(struct skein1024_ctx *ctx, size_t hashBitLen, u64 treeInfo, const u8 *key, size_t keyBytes) { - union - { - u8 b[SKEIN1024_STATE_BYTES]; - u64 w[SKEIN1024_STATE_WORDS]; - } cfg; /* config block */ - - Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN); - Skein_Assert(keyBytes == 0 || key != NULL, SKEIN_FAIL); - - /* compute the initial chaining values ctx->X[], based on key */ - if (keyBytes == 0) /* is there a key? */ - { - memset(ctx->X, 0, sizeof(ctx->X)); /* no key: use all zeroes as key for config block */ - } - else /* here to pre-process a key */ - { - Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); - /* do a mini-Init right here */ - ctx->h.hashBitLen = 8*sizeof(ctx->X); /* set output hash bit count = state size */ - Skein_Start_New_Type(ctx, KEY); /* set tweaks: T0 = 0; T1 = KEY type */ - memset(ctx->X, 0, sizeof(ctx->X)); /* zero the initial chaining variables */ - Skein1024_Update(ctx, key, keyBytes); /* hash the key */ - Skein1024_Final_Pad(ctx, cfg.b); /* put result into cfg.b[] */ - memcpy(ctx->X, cfg.b, sizeof(cfg.b)); /* copy over into ctx->X[] */ - } - /* build/process the config block, type == CONFIG (could be precomputed for each key) */ - ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ - Skein_Start_New_Type(ctx, CFG_FINAL); - - memset(&cfg.w, 0, sizeof(cfg.w)); /* pre-pad cfg.w[] with zeroes */ - cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); - cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ - cfg.w[2] = Skein_Swap64(treeInfo); /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ - - Skein_Show_Key(1024, &ctx->h, key, keyBytes); - - /* compute the initial chaining values from config block */ - Skein1024_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); - - /* The chaining vars ctx->X are now initialized */ - /* Set up to process the data message portion of the hash (default) */ - Skein_Start_New_Type(ctx, MSG); - - return SKEIN_SUCCESS; + union + { + u8 b[SKEIN1024_STATE_BYTES]; + u64 w[SKEIN1024_STATE_WORDS]; + } cfg; /* config block */ + + Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN); + Skein_Assert(keyBytes == 0 || key != NULL, SKEIN_FAIL); + + /* compute the initial chaining values ctx->X[], based on key */ + if (keyBytes == 0) /* is there a key? */ + { + memset(ctx->X, 0, sizeof(ctx->X)); /* no key: use all zeroes as key for config block */ + } + else /* here to pre-process a key */ + { + Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); + /* do a mini-Init right here */ + ctx->h.hashBitLen = 8*sizeof(ctx->X); /* set output hash bit count = state size */ + Skein_Start_New_Type(ctx, KEY); /* set tweaks: T0 = 0; T1 = KEY type */ + memset(ctx->X, 0, sizeof(ctx->X)); /* zero the initial chaining variables */ + Skein1024_Update(ctx, key, keyBytes); /* hash the key */ + Skein1024_Final_Pad(ctx, cfg.b); /* put result into cfg.b[] */ + memcpy(ctx->X, cfg.b, sizeof(cfg.b)); /* copy over into ctx->X[] */ + } + /* build/process the config block, type == CONFIG (could be precomputed for each key) */ + ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ + Skein_Start_New_Type(ctx, CFG_FINAL); + + memset(&cfg.w, 0, sizeof(cfg.w)); /* pre-pad cfg.w[] with zeroes */ + cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); + cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ + cfg.w[2] = Skein_Swap64(treeInfo); /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ + + Skein_Show_Key(1024, &ctx->h, key, keyBytes); + + /* compute the initial chaining values from config block */ + Skein1024_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); + + /* The chaining vars ctx->X are now initialized */ + /* Set up to process the data message portion of the hash (default) */ + Skein_Start_New_Type(ctx, MSG); + + return SKEIN_SUCCESS; } /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* process the input bytes */ int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg, size_t msgByteCnt) { - size_t n; - - Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ - - /* process full blocks, if any */ - if (msgByteCnt + ctx->h.bCnt > SKEIN1024_BLOCK_BYTES) - { - if (ctx->h.bCnt) /* finish up any buffered message data */ - { - n = SKEIN1024_BLOCK_BYTES - ctx->h.bCnt; /* # bytes free in buffer b[] */ - if (n) - { - Skein_assert(n < msgByteCnt); /* check on our logic here */ - memcpy(&ctx->b[ctx->h.bCnt], msg, n); - msgByteCnt -= n; - msg += n; - ctx->h.bCnt += n; - } - Skein_assert(ctx->h.bCnt == SKEIN1024_BLOCK_BYTES); - Skein1024_Process_Block(ctx, ctx->b, 1, SKEIN1024_BLOCK_BYTES); - ctx->h.bCnt = 0; - } - /* now process any remaining full blocks, directly from input message data */ - if (msgByteCnt > SKEIN1024_BLOCK_BYTES) - { - n = (msgByteCnt-1) / SKEIN1024_BLOCK_BYTES; /* number of full blocks to process */ - Skein1024_Process_Block(ctx, msg, n, SKEIN1024_BLOCK_BYTES); - msgByteCnt -= n * SKEIN1024_BLOCK_BYTES; - msg += n * SKEIN1024_BLOCK_BYTES; - } - Skein_assert(ctx->h.bCnt == 0); - } - - /* copy any remaining source message data bytes into b[] */ - if (msgByteCnt) - { - Skein_assert(msgByteCnt + ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES); - memcpy(&ctx->b[ctx->h.bCnt], msg, msgByteCnt); - ctx->h.bCnt += msgByteCnt; - } - - return SKEIN_SUCCESS; + size_t n; + + Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ + + /* process full blocks, if any */ + if (msgByteCnt + ctx->h.bCnt > SKEIN1024_BLOCK_BYTES) + { + if (ctx->h.bCnt) /* finish up any buffered message data */ + { + n = SKEIN1024_BLOCK_BYTES - ctx->h.bCnt; /* # bytes free in buffer b[] */ + if (n) + { + Skein_assert(n < msgByteCnt); /* check on our logic here */ + memcpy(&ctx->b[ctx->h.bCnt], msg, n); + msgByteCnt -= n; + msg += n; + ctx->h.bCnt += n; + } + Skein_assert(ctx->h.bCnt == SKEIN1024_BLOCK_BYTES); + Skein1024_Process_Block(ctx, ctx->b, 1, SKEIN1024_BLOCK_BYTES); + ctx->h.bCnt = 0; + } + /* now process any remaining full blocks, directly from input message data */ + if (msgByteCnt > SKEIN1024_BLOCK_BYTES) + { + n = (msgByteCnt-1) / SKEIN1024_BLOCK_BYTES; /* number of full blocks to process */ + Skein1024_Process_Block(ctx, msg, n, SKEIN1024_BLOCK_BYTES); + msgByteCnt -= n * SKEIN1024_BLOCK_BYTES; + msg += n * SKEIN1024_BLOCK_BYTES; + } + Skein_assert(ctx->h.bCnt == 0); + } + + /* copy any remaining source message data bytes into b[] */ + if (msgByteCnt) + { + Skein_assert(msgByteCnt + ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES); + memcpy(&ctx->b[ctx->h.bCnt], msg, msgByteCnt); + ctx->h.bCnt += msgByteCnt; + } + + return SKEIN_SUCCESS; } /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the result */ int Skein1024_Final(struct skein1024_ctx *ctx, u8 *hashVal) { - size_t i, n, byteCnt; - u64 X[SKEIN1024_STATE_WORDS]; - Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ - - ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ - if (ctx->h.bCnt < SKEIN1024_BLOCK_BYTES) /* zero pad b[] if necessary */ - memset(&ctx->b[ctx->h.bCnt], 0, SKEIN1024_BLOCK_BYTES - ctx->h.bCnt); - - Skein1024_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); /* process the final block */ - - /* now output the result */ - byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ - - /* run Threefish in "counter mode" to generate output */ - memset(ctx->b, 0, sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ - memcpy(X, ctx->X, sizeof(X)); /* keep a local copy of counter mode "key" */ - for (i = 0; i*SKEIN1024_BLOCK_BYTES < byteCnt; i++) - { - ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); /* build the counter block */ - Skein_Start_New_Type(ctx, OUT_FINAL); - Skein1024_Process_Block(ctx, ctx->b, 1, sizeof(u64)); /* run "counter mode" */ - n = byteCnt - i*SKEIN1024_BLOCK_BYTES; /* number of output bytes left to go */ - if (n >= SKEIN1024_BLOCK_BYTES) - n = SKEIN1024_BLOCK_BYTES; - Skein_Put64_LSB_First(hashVal+i*SKEIN1024_BLOCK_BYTES, ctx->X, n); /* "output" the ctr mode bytes */ - Skein_Show_Final(1024, &ctx->h, n, hashVal+i*SKEIN1024_BLOCK_BYTES); - memcpy(ctx->X, X, sizeof(X)); /* restore the counter mode key for next time */ - } - return SKEIN_SUCCESS; + size_t i, n, byteCnt; + u64 X[SKEIN1024_STATE_WORDS]; + Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ + + ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ + if (ctx->h.bCnt < SKEIN1024_BLOCK_BYTES) /* zero pad b[] if necessary */ + memset(&ctx->b[ctx->h.bCnt], 0, SKEIN1024_BLOCK_BYTES - ctx->h.bCnt); + + Skein1024_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); /* process the final block */ + + /* now output the result */ + byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ + + /* run Threefish in "counter mode" to generate output */ + memset(ctx->b, 0, sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ + memcpy(X, ctx->X, sizeof(X)); /* keep a local copy of counter mode "key" */ + for (i = 0; i*SKEIN1024_BLOCK_BYTES < byteCnt; i++) + { + ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); /* build the counter block */ + Skein_Start_New_Type(ctx, OUT_FINAL); + Skein1024_Process_Block(ctx, ctx->b, 1, sizeof(u64)); /* run "counter mode" */ + n = byteCnt - i*SKEIN1024_BLOCK_BYTES; /* number of output bytes left to go */ + if (n >= SKEIN1024_BLOCK_BYTES) + n = SKEIN1024_BLOCK_BYTES; + Skein_Put64_LSB_First(hashVal+i*SKEIN1024_BLOCK_BYTES, ctx->X, n); /* "output" the ctr mode bytes */ + Skein_Show_Final(1024, &ctx->h, n, hashVal+i*SKEIN1024_BLOCK_BYTES); + memcpy(ctx->X, X, sizeof(X)); /* restore the counter mode key for next time */ + } + return SKEIN_SUCCESS; } /**************** Functions to support MAC/tree hashing ***************/ @@ -587,48 +587,48 @@ int Skein1024_Final(struct skein1024_ctx *ctx, u8 *hashVal) /* finalize the hash computation and output the block, no OUTPUT stage */ int Skein_256_Final_Pad(struct skein_256_ctx *ctx, u8 *hashVal) { - Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ + Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ - ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ - if (ctx->h.bCnt < SKEIN_256_BLOCK_BYTES) /* zero pad b[] if necessary */ - memset(&ctx->b[ctx->h.bCnt], 0, SKEIN_256_BLOCK_BYTES - ctx->h.bCnt); - Skein_256_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); /* process the final block */ + ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ + if (ctx->h.bCnt < SKEIN_256_BLOCK_BYTES) /* zero pad b[] if necessary */ + memset(&ctx->b[ctx->h.bCnt], 0, SKEIN_256_BLOCK_BYTES - ctx->h.bCnt); + Skein_256_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); /* process the final block */ - Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN_256_BLOCK_BYTES); /* "output" the state bytes */ + Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN_256_BLOCK_BYTES); /* "output" the state bytes */ - return SKEIN_SUCCESS; + return SKEIN_SUCCESS; } /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the block, no OUTPUT stage */ int Skein_512_Final_Pad(struct skein_512_ctx *ctx, u8 *hashVal) { - Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ + Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ - ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ - if (ctx->h.bCnt < SKEIN_512_BLOCK_BYTES) /* zero pad b[] if necessary */ - memset(&ctx->b[ctx->h.bCnt], 0, SKEIN_512_BLOCK_BYTES - ctx->h.bCnt); - Skein_512_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); /* process the final block */ + ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ + if (ctx->h.bCnt < SKEIN_512_BLOCK_BYTES) /* zero pad b[] if necessary */ + memset(&ctx->b[ctx->h.bCnt], 0, SKEIN_512_BLOCK_BYTES - ctx->h.bCnt); + Skein_512_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); /* process the final block */ - Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN_512_BLOCK_BYTES); /* "output" the state bytes */ + Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN_512_BLOCK_BYTES); /* "output" the state bytes */ - return SKEIN_SUCCESS; + return SKEIN_SUCCESS; } /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the block, no OUTPUT stage */ int Skein1024_Final_Pad(struct skein1024_ctx *ctx, u8 *hashVal) { - Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ + Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ - ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ - if (ctx->h.bCnt < SKEIN1024_BLOCK_BYTES) /* zero pad b[] if necessary */ - memset(&ctx->b[ctx->h.bCnt], 0, SKEIN1024_BLOCK_BYTES - ctx->h.bCnt); - Skein1024_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); /* process the final block */ + ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ + if (ctx->h.bCnt < SKEIN1024_BLOCK_BYTES) /* zero pad b[] if necessary */ + memset(&ctx->b[ctx->h.bCnt], 0, SKEIN1024_BLOCK_BYTES - ctx->h.bCnt); + Skein1024_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); /* process the final block */ - Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN1024_BLOCK_BYTES); /* "output" the state bytes */ + Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN1024_BLOCK_BYTES); /* "output" the state bytes */ - return SKEIN_SUCCESS; + return SKEIN_SUCCESS; } #if SKEIN_TREE_HASH @@ -636,86 +636,86 @@ int Skein1024_Final_Pad(struct skein1024_ctx *ctx, u8 *hashVal) /* just do the OUTPUT stage */ int Skein_256_Output(struct skein_256_ctx *ctx, u8 *hashVal) { - size_t i, n, byteCnt; - u64 X[SKEIN_256_STATE_WORDS]; - Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ - - /* now output the result */ - byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ - - /* run Threefish in "counter mode" to generate output */ - memset(ctx->b, 0, sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ - memcpy(X, ctx->X, sizeof(X)); /* keep a local copy of counter mode "key" */ - for (i = 0; i*SKEIN_256_BLOCK_BYTES < byteCnt; i++) - { - ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); /* build the counter block */ - Skein_Start_New_Type(ctx, OUT_FINAL); - Skein_256_Process_Block(ctx, ctx->b, 1, sizeof(u64)); /* run "counter mode" */ - n = byteCnt - i*SKEIN_256_BLOCK_BYTES; /* number of output bytes left to go */ - if (n >= SKEIN_256_BLOCK_BYTES) - n = SKEIN_256_BLOCK_BYTES; - Skein_Put64_LSB_First(hashVal+i*SKEIN_256_BLOCK_BYTES, ctx->X, n); /* "output" the ctr mode bytes */ - Skein_Show_Final(256, &ctx->h, n, hashVal+i*SKEIN_256_BLOCK_BYTES); - memcpy(ctx->X, X, sizeof(X)); /* restore the counter mode key for next time */ - } - return SKEIN_SUCCESS; + size_t i, n, byteCnt; + u64 X[SKEIN_256_STATE_WORDS]; + Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ + + /* now output the result */ + byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ + + /* run Threefish in "counter mode" to generate output */ + memset(ctx->b, 0, sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ + memcpy(X, ctx->X, sizeof(X)); /* keep a local copy of counter mode "key" */ + for (i = 0; i*SKEIN_256_BLOCK_BYTES < byteCnt; i++) + { + ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); /* build the counter block */ + Skein_Start_New_Type(ctx, OUT_FINAL); + Skein_256_Process_Block(ctx, ctx->b, 1, sizeof(u64)); /* run "counter mode" */ + n = byteCnt - i*SKEIN_256_BLOCK_BYTES; /* number of output bytes left to go */ + if (n >= SKEIN_256_BLOCK_BYTES) + n = SKEIN_256_BLOCK_BYTES; + Skein_Put64_LSB_First(hashVal+i*SKEIN_256_BLOCK_BYTES, ctx->X, n); /* "output" the ctr mode bytes */ + Skein_Show_Final(256, &ctx->h, n, hashVal+i*SKEIN_256_BLOCK_BYTES); + memcpy(ctx->X, X, sizeof(X)); /* restore the counter mode key for next time */ + } + return SKEIN_SUCCESS; } /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* just do the OUTPUT stage */ int Skein_512_Output(struct skein_512_ctx *ctx, u8 *hashVal) { - size_t i, n, byteCnt; - u64 X[SKEIN_512_STATE_WORDS]; - Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ - - /* now output the result */ - byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ - - /* run Threefish in "counter mode" to generate output */ - memset(ctx->b, 0, sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ - memcpy(X, ctx->X, sizeof(X)); /* keep a local copy of counter mode "key" */ - for (i = 0; i*SKEIN_512_BLOCK_BYTES < byteCnt; i++) - { - ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); /* build the counter block */ - Skein_Start_New_Type(ctx, OUT_FINAL); - Skein_512_Process_Block(ctx, ctx->b, 1, sizeof(u64)); /* run "counter mode" */ - n = byteCnt - i*SKEIN_512_BLOCK_BYTES; /* number of output bytes left to go */ - if (n >= SKEIN_512_BLOCK_BYTES) - n = SKEIN_512_BLOCK_BYTES; - Skein_Put64_LSB_First(hashVal+i*SKEIN_512_BLOCK_BYTES, ctx->X, n); /* "output" the ctr mode bytes */ - Skein_Show_Final(256, &ctx->h, n, hashVal+i*SKEIN_512_BLOCK_BYTES); - memcpy(ctx->X, X, sizeof(X)); /* restore the counter mode key for next time */ - } - return SKEIN_SUCCESS; + size_t i, n, byteCnt; + u64 X[SKEIN_512_STATE_WORDS]; + Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ + + /* now output the result */ + byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ + + /* run Threefish in "counter mode" to generate output */ + memset(ctx->b, 0, sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ + memcpy(X, ctx->X, sizeof(X)); /* keep a local copy of counter mode "key" */ + for (i = 0; i*SKEIN_512_BLOCK_BYTES < byteCnt; i++) + { + ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); /* build the counter block */ + Skein_Start_New_Type(ctx, OUT_FINAL); + Skein_512_Process_Block(ctx, ctx->b, 1, sizeof(u64)); /* run "counter mode" */ + n = byteCnt - i*SKEIN_512_BLOCK_BYTES; /* number of output bytes left to go */ + if (n >= SKEIN_512_BLOCK_BYTES) + n = SKEIN_512_BLOCK_BYTES; + Skein_Put64_LSB_First(hashVal+i*SKEIN_512_BLOCK_BYTES, ctx->X, n); /* "output" the ctr mode bytes */ + Skein_Show_Final(256, &ctx->h, n, hashVal+i*SKEIN_512_BLOCK_BYTES); + memcpy(ctx->X, X, sizeof(X)); /* restore the counter mode key for next time */ + } + return SKEIN_SUCCESS; } /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* just do the OUTPUT stage */ int Skein1024_Output(struct skein1024_ctx *ctx, u8 *hashVal) { - size_t i, n, byteCnt; - u64 X[SKEIN1024_STATE_WORDS]; - Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ - - /* now output the result */ - byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ - - /* run Threefish in "counter mode" to generate output */ - memset(ctx->b, 0, sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ - memcpy(X, ctx->X, sizeof(X)); /* keep a local copy of counter mode "key" */ - for (i = 0; i*SKEIN1024_BLOCK_BYTES < byteCnt; i++) - { - ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); /* build the counter block */ - Skein_Start_New_Type(ctx, OUT_FINAL); - Skein1024_Process_Block(ctx, ctx->b, 1, sizeof(u64)); /* run "counter mode" */ - n = byteCnt - i*SKEIN1024_BLOCK_BYTES; /* number of output bytes left to go */ - if (n >= SKEIN1024_BLOCK_BYTES) - n = SKEIN1024_BLOCK_BYTES; - Skein_Put64_LSB_First(hashVal+i*SKEIN1024_BLOCK_BYTES, ctx->X, n); /* "output" the ctr mode bytes */ - Skein_Show_Final(256, &ctx->h, n, hashVal+i*SKEIN1024_BLOCK_BYTES); - memcpy(ctx->X, X, sizeof(X)); /* restore the counter mode key for next time */ - } - return SKEIN_SUCCESS; + size_t i, n, byteCnt; + u64 X[SKEIN1024_STATE_WORDS]; + Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ + + /* now output the result */ + byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ + + /* run Threefish in "counter mode" to generate output */ + memset(ctx->b, 0, sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ + memcpy(X, ctx->X, sizeof(X)); /* keep a local copy of counter mode "key" */ + for (i = 0; i*SKEIN1024_BLOCK_BYTES < byteCnt; i++) + { + ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); /* build the counter block */ + Skein_Start_New_Type(ctx, OUT_FINAL); + Skein1024_Process_Block(ctx, ctx->b, 1, sizeof(u64)); /* run "counter mode" */ + n = byteCnt - i*SKEIN1024_BLOCK_BYTES; /* number of output bytes left to go */ + if (n >= SKEIN1024_BLOCK_BYTES) + n = SKEIN1024_BLOCK_BYTES; + Skein_Put64_LSB_First(hashVal+i*SKEIN1024_BLOCK_BYTES, ctx->X, n); /* "output" the ctr mode bytes */ + Skein_Show_Final(256, &ctx->h, n, hashVal+i*SKEIN1024_BLOCK_BYTES); + memcpy(ctx->X, X, sizeof(X)); /* restore the counter mode key for next time */ + } + return SKEIN_SUCCESS; } #endif diff --git a/drivers/staging/skein/skeinApi.c b/drivers/staging/skein/skeinApi.c index a3f471be8db3..3ebb1d60ef93 100644 --- a/drivers/staging/skein/skeinApi.c +++ b/drivers/staging/skein/skeinApi.c @@ -29,191 +29,191 @@ OTHER DEALINGS IN THE SOFTWARE. int skeinCtxPrepare(struct skein_ctx *ctx, enum skein_size size) { - Skein_Assert(ctx && size, SKEIN_FAIL); + Skein_Assert(ctx && size, SKEIN_FAIL); - memset(ctx , 0, sizeof(struct skein_ctx)); - ctx->skeinSize = size; + memset(ctx , 0, sizeof(struct skein_ctx)); + ctx->skeinSize = size; - return SKEIN_SUCCESS; + return SKEIN_SUCCESS; } int skeinInit(struct skein_ctx *ctx, size_t hashBitLen) { - int ret = SKEIN_FAIL; - size_t Xlen = 0; - u64 *X = NULL; - u64 treeInfo = SKEIN_CFG_TREE_INFO_SEQUENTIAL; - - Skein_Assert(ctx, SKEIN_FAIL); - /* - * The following two lines rely of the fact that the real Skein contexts are - * a union in out context and thus have tha maximum memory available. - * The beauty of C :-) . - */ - X = ctx->m.s256.X; - Xlen = ctx->skeinSize/8; - /* - * If size is the same and hash bit length is zero then reuse - * the save chaining variables. - */ - switch (ctx->skeinSize) { - case Skein256: - ret = Skein_256_InitExt(&ctx->m.s256, hashBitLen, - treeInfo, NULL, 0); - break; - case Skein512: - ret = Skein_512_InitExt(&ctx->m.s512, hashBitLen, - treeInfo, NULL, 0); - break; - case Skein1024: - ret = Skein1024_InitExt(&ctx->m.s1024, hashBitLen, - treeInfo, NULL, 0); - break; - } - - if (ret == SKEIN_SUCCESS) { - /* Save chaining variables for this combination of size and hashBitLen */ - memcpy(ctx->XSave, X, Xlen); - } - return ret; + int ret = SKEIN_FAIL; + size_t Xlen = 0; + u64 *X = NULL; + u64 treeInfo = SKEIN_CFG_TREE_INFO_SEQUENTIAL; + + Skein_Assert(ctx, SKEIN_FAIL); + /* + * The following two lines rely of the fact that the real Skein contexts are + * a union in out context and thus have tha maximum memory available. + * The beauty of C :-) . + */ + X = ctx->m.s256.X; + Xlen = ctx->skeinSize/8; + /* + * If size is the same and hash bit length is zero then reuse + * the save chaining variables. + */ + switch (ctx->skeinSize) { + case Skein256: + ret = Skein_256_InitExt(&ctx->m.s256, hashBitLen, + treeInfo, NULL, 0); + break; + case Skein512: + ret = Skein_512_InitExt(&ctx->m.s512, hashBitLen, + treeInfo, NULL, 0); + break; + case Skein1024: + ret = Skein1024_InitExt(&ctx->m.s1024, hashBitLen, + treeInfo, NULL, 0); + break; + } + + if (ret == SKEIN_SUCCESS) { + /* Save chaining variables for this combination of size and hashBitLen */ + memcpy(ctx->XSave, X, Xlen); + } + return ret; } int skeinMacInit(struct skein_ctx *ctx, const u8 *key, size_t keyLen, - size_t hashBitLen) + size_t hashBitLen) { - int ret = SKEIN_FAIL; - u64 *X = NULL; - size_t Xlen = 0; - u64 treeInfo = SKEIN_CFG_TREE_INFO_SEQUENTIAL; - - Skein_Assert(ctx, SKEIN_FAIL); - - X = ctx->m.s256.X; - Xlen = ctx->skeinSize/8; - - Skein_Assert(hashBitLen, SKEIN_BAD_HASHLEN); - - switch (ctx->skeinSize) { - case Skein256: - ret = Skein_256_InitExt(&ctx->m.s256, hashBitLen, - treeInfo, - (const u8 *)key, keyLen); - - break; - case Skein512: - ret = Skein_512_InitExt(&ctx->m.s512, hashBitLen, - treeInfo, - (const u8 *)key, keyLen); - break; - case Skein1024: - ret = Skein1024_InitExt(&ctx->m.s1024, hashBitLen, - treeInfo, - (const u8 *)key, keyLen); - - break; - } - if (ret == SKEIN_SUCCESS) { - /* Save chaining variables for this combination of key, keyLen, hashBitLen */ - memcpy(ctx->XSave, X, Xlen); - } - return ret; + int ret = SKEIN_FAIL; + u64 *X = NULL; + size_t Xlen = 0; + u64 treeInfo = SKEIN_CFG_TREE_INFO_SEQUENTIAL; + + Skein_Assert(ctx, SKEIN_FAIL); + + X = ctx->m.s256.X; + Xlen = ctx->skeinSize/8; + + Skein_Assert(hashBitLen, SKEIN_BAD_HASHLEN); + + switch (ctx->skeinSize) { + case Skein256: + ret = Skein_256_InitExt(&ctx->m.s256, hashBitLen, + treeInfo, + (const u8 *)key, keyLen); + + break; + case Skein512: + ret = Skein_512_InitExt(&ctx->m.s512, hashBitLen, + treeInfo, + (const u8 *)key, keyLen); + break; + case Skein1024: + ret = Skein1024_InitExt(&ctx->m.s1024, hashBitLen, + treeInfo, + (const u8 *)key, keyLen); + + break; + } + if (ret == SKEIN_SUCCESS) { + /* Save chaining variables for this combination of key, keyLen, hashBitLen */ + memcpy(ctx->XSave, X, Xlen); + } + return ret; } void skeinReset(struct skein_ctx *ctx) { - size_t Xlen = 0; - u64 *X = NULL; - - /* - * The following two lines rely of the fact that the real Skein contexts are - * a union in out context and thus have tha maximum memory available. - * The beautiy of C :-) . - */ - X = ctx->m.s256.X; - Xlen = ctx->skeinSize/8; - /* Restore the chaing variable, reset byte counter */ - memcpy(X, ctx->XSave, Xlen); - - /* Setup context to process the message */ - Skein_Start_New_Type(&ctx->m, MSG); + size_t Xlen = 0; + u64 *X = NULL; + + /* + * The following two lines rely of the fact that the real Skein contexts are + * a union in out context and thus have tha maximum memory available. + * The beautiy of C :-) . + */ + X = ctx->m.s256.X; + Xlen = ctx->skeinSize/8; + /* Restore the chaing variable, reset byte counter */ + memcpy(X, ctx->XSave, Xlen); + + /* Setup context to process the message */ + Skein_Start_New_Type(&ctx->m, MSG); } int skeinUpdate(struct skein_ctx *ctx, const u8 *msg, - size_t msgByteCnt) + size_t msgByteCnt) { - int ret = SKEIN_FAIL; - Skein_Assert(ctx, SKEIN_FAIL); - - switch (ctx->skeinSize) { - case Skein256: - ret = Skein_256_Update(&ctx->m.s256, (const u8 *)msg, msgByteCnt); - break; - case Skein512: - ret = Skein_512_Update(&ctx->m.s512, (const u8 *)msg, msgByteCnt); - break; - case Skein1024: - ret = Skein1024_Update(&ctx->m.s1024, (const u8 *)msg, msgByteCnt); - break; - } - return ret; + int ret = SKEIN_FAIL; + Skein_Assert(ctx, SKEIN_FAIL); + + switch (ctx->skeinSize) { + case Skein256: + ret = Skein_256_Update(&ctx->m.s256, (const u8 *)msg, msgByteCnt); + break; + case Skein512: + ret = Skein_512_Update(&ctx->m.s512, (const u8 *)msg, msgByteCnt); + break; + case Skein1024: + ret = Skein1024_Update(&ctx->m.s1024, (const u8 *)msg, msgByteCnt); + break; + } + return ret; } int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg, - size_t msgBitCnt) + size_t msgBitCnt) { - /* - * I've used the bit pad implementation from skein_test.c (see NIST CD) - * and modified it to use the convenience functions and added some pointer - * arithmetic. - */ - size_t length; - u8 mask; - u8 *up; - - /* only the final Update() call is allowed do partial bytes, else assert an error */ - Skein_Assert((ctx->m.h.T[1] & SKEIN_T1_FLAG_BIT_PAD) == 0 || msgBitCnt == 0, SKEIN_FAIL); - - /* if number of bits is a multiple of bytes - that's easy */ - if ((msgBitCnt & 0x7) == 0) { - return skeinUpdate(ctx, msg, msgBitCnt >> 3); - } - skeinUpdate(ctx, msg, (msgBitCnt >> 3) + 1); - - /* - * The next line rely on the fact that the real Skein contexts - * are a union in our context. After the addition the pointer points to - * Skein's real partial block buffer. - * If this layout ever changes we have to adapt this as well. - */ - up = (u8 *)ctx->m.s256.X + ctx->skeinSize / 8; - - Skein_Set_Bit_Pad_Flag(ctx->m.h); /* set tweak flag for the skeinFinal call */ - - /* now "pad" the final partial byte the way NIST likes */ - length = ctx->m.h.bCnt; /* get the bCnt value (same location for all block sizes) */ - Skein_assert(length != 0); /* internal sanity check: there IS a partial byte in the buffer! */ - mask = (u8) (1u << (7 - (msgBitCnt & 7))); /* partial byte bit mask */ - up[length-1] = (u8)((up[length-1] & (0-mask))|mask); /* apply bit padding on final byte (in the buffer) */ - - return SKEIN_SUCCESS; + /* + * I've used the bit pad implementation from skein_test.c (see NIST CD) + * and modified it to use the convenience functions and added some pointer + * arithmetic. + */ + size_t length; + u8 mask; + u8 *up; + + /* only the final Update() call is allowed do partial bytes, else assert an error */ + Skein_Assert((ctx->m.h.T[1] & SKEIN_T1_FLAG_BIT_PAD) == 0 || msgBitCnt == 0, SKEIN_FAIL); + + /* if number of bits is a multiple of bytes - that's easy */ + if ((msgBitCnt & 0x7) == 0) { + return skeinUpdate(ctx, msg, msgBitCnt >> 3); + } + skeinUpdate(ctx, msg, (msgBitCnt >> 3) + 1); + + /* + * The next line rely on the fact that the real Skein contexts + * are a union in our context. After the addition the pointer points to + * Skein's real partial block buffer. + * If this layout ever changes we have to adapt this as well. + */ + up = (u8 *)ctx->m.s256.X + ctx->skeinSize / 8; + + Skein_Set_Bit_Pad_Flag(ctx->m.h); /* set tweak flag for the skeinFinal call */ + + /* now "pad" the final partial byte the way NIST likes */ + length = ctx->m.h.bCnt; /* get the bCnt value (same location for all block sizes) */ + Skein_assert(length != 0); /* internal sanity check: there IS a partial byte in the buffer! */ + mask = (u8) (1u << (7 - (msgBitCnt & 7))); /* partial byte bit mask */ + up[length-1] = (u8)((up[length-1] & (0-mask))|mask); /* apply bit padding on final byte (in the buffer) */ + + return SKEIN_SUCCESS; } int skeinFinal(struct skein_ctx *ctx, u8 *hash) { - int ret = SKEIN_FAIL; - Skein_Assert(ctx, SKEIN_FAIL); - - switch (ctx->skeinSize) { - case Skein256: - ret = Skein_256_Final(&ctx->m.s256, (u8 *)hash); - break; - case Skein512: - ret = Skein_512_Final(&ctx->m.s512, (u8 *)hash); - break; - case Skein1024: - ret = Skein1024_Final(&ctx->m.s1024, (u8 *)hash); - break; - } - return ret; + int ret = SKEIN_FAIL; + Skein_Assert(ctx, SKEIN_FAIL); + + switch (ctx->skeinSize) { + case Skein256: + ret = Skein_256_Final(&ctx->m.s256, (u8 *)hash); + break; + case Skein512: + ret = Skein_512_Final(&ctx->m.s512, (u8 *)hash); + break; + case Skein1024: + ret = Skein1024_Final(&ctx->m.s1024, (u8 *)hash); + break; + } + return ret; } diff --git a/drivers/staging/skein/skeinBlockNo3F.c b/drivers/staging/skein/skeinBlockNo3F.c index d98933eeb0bf..3c2878c966e1 100644 --- a/drivers/staging/skein/skeinBlockNo3F.c +++ b/drivers/staging/skein/skeinBlockNo3F.c @@ -6,167 +6,167 @@ /***************************** Skein_256 ******************************/ void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, - size_t blkCnt, size_t byteCntAdd) + size_t blkCnt, size_t byteCntAdd) { - struct threefish_key key; - u64 tweak[2]; - int i; - u64 w[SKEIN_256_STATE_WORDS]; /* local copy of input block */ - u64 words[3]; + struct threefish_key key; + u64 tweak[2]; + int i; + u64 w[SKEIN_256_STATE_WORDS]; /* local copy of input block */ + u64 words[3]; - Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ - tweak[0] = ctx->h.T[0]; - tweak[1] = ctx->h.T[1]; + Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ + tweak[0] = ctx->h.T[0]; + tweak[1] = ctx->h.T[1]; - do { - u64 carry = byteCntAdd; + do { + u64 carry = byteCntAdd; - words[0] = tweak[0] & 0xffffffffL; - words[1] = ((tweak[0] >> 32) & 0xffffffffL); - words[2] = (tweak[1] & 0xffffffffL); + words[0] = tweak[0] & 0xffffffffL; + words[1] = ((tweak[0] >> 32) & 0xffffffffL); + words[2] = (tweak[1] & 0xffffffffL); - for (i = 0; i < 3; i++) { - carry += words[i]; - words[i] = carry; - carry >>= 32; - } - tweak[0] = words[0] & 0xffffffffL; - tweak[0] |= (words[1] & 0xffffffffL) << 32; - tweak[1] |= words[2] & 0xffffffffL; + for (i = 0; i < 3; i++) { + carry += words[i]; + words[i] = carry; + carry >>= 32; + } + tweak[0] = words[0] & 0xffffffffL; + tweak[0] |= (words[1] & 0xffffffffL) << 32; + tweak[1] |= words[2] & 0xffffffffL; - threefishSetKey(&key, Threefish256, ctx->X, tweak); + threefishSetKey(&key, Threefish256, ctx->X, tweak); - Skein_Get64_LSB_First(w, blkPtr, SKEIN_256_STATE_WORDS); /* get input block in little-endian format */ + Skein_Get64_LSB_First(w, blkPtr, SKEIN_256_STATE_WORDS); /* get input block in little-endian format */ - threefishEncryptBlockWords(&key, w, ctx->X); + threefishEncryptBlockWords(&key, w, ctx->X); - blkPtr += SKEIN_256_BLOCK_BYTES; + blkPtr += SKEIN_256_BLOCK_BYTES; - /* do the final "feedforward" xor, update context chaining vars */ - ctx->X[0] = ctx->X[0] ^ w[0]; - ctx->X[1] = ctx->X[1] ^ w[1]; - ctx->X[2] = ctx->X[2] ^ w[2]; - ctx->X[3] = ctx->X[3] ^ w[3]; + /* do the final "feedforward" xor, update context chaining vars */ + ctx->X[0] = ctx->X[0] ^ w[0]; + ctx->X[1] = ctx->X[1] ^ w[1]; + ctx->X[2] = ctx->X[2] ^ w[2]; + ctx->X[3] = ctx->X[3] ^ w[3]; - tweak[1] &= ~SKEIN_T1_FLAG_FIRST; - } while (--blkCnt); + tweak[1] &= ~SKEIN_T1_FLAG_FIRST; + } while (--blkCnt); - ctx->h.T[0] = tweak[0]; - ctx->h.T[1] = tweak[1]; + ctx->h.T[0] = tweak[0]; + ctx->h.T[1] = tweak[1]; } void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, - size_t blkCnt, size_t byteCntAdd) + size_t blkCnt, size_t byteCntAdd) { - struct threefish_key key; - u64 tweak[2]; - int i; - u64 words[3]; - u64 w[SKEIN_512_STATE_WORDS]; /* local copy of input block */ - - Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ - tweak[0] = ctx->h.T[0]; - tweak[1] = ctx->h.T[1]; - - do { - u64 carry = byteCntAdd; - - words[0] = tweak[0] & 0xffffffffL; - words[1] = ((tweak[0] >> 32) & 0xffffffffL); - words[2] = (tweak[1] & 0xffffffffL); - - for (i = 0; i < 3; i++) { - carry += words[i]; - words[i] = carry; - carry >>= 32; - } - tweak[0] = words[0] & 0xffffffffL; - tweak[0] |= (words[1] & 0xffffffffL) << 32; - tweak[1] |= words[2] & 0xffffffffL; - - threefishSetKey(&key, Threefish512, ctx->X, tweak); - - Skein_Get64_LSB_First(w, blkPtr, SKEIN_512_STATE_WORDS); /* get input block in little-endian format */ - - threefishEncryptBlockWords(&key, w, ctx->X); - - blkPtr += SKEIN_512_BLOCK_BYTES; - - /* do the final "feedforward" xor, update context chaining vars */ - ctx->X[0] = ctx->X[0] ^ w[0]; - ctx->X[1] = ctx->X[1] ^ w[1]; - ctx->X[2] = ctx->X[2] ^ w[2]; - ctx->X[3] = ctx->X[3] ^ w[3]; - ctx->X[4] = ctx->X[4] ^ w[4]; - ctx->X[5] = ctx->X[5] ^ w[5]; - ctx->X[6] = ctx->X[6] ^ w[6]; - ctx->X[7] = ctx->X[7] ^ w[7]; - - tweak[1] &= ~SKEIN_T1_FLAG_FIRST; - } while (--blkCnt); - - ctx->h.T[0] = tweak[0]; - ctx->h.T[1] = tweak[1]; + struct threefish_key key; + u64 tweak[2]; + int i; + u64 words[3]; + u64 w[SKEIN_512_STATE_WORDS]; /* local copy of input block */ + + Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ + tweak[0] = ctx->h.T[0]; + tweak[1] = ctx->h.T[1]; + + do { + u64 carry = byteCntAdd; + + words[0] = tweak[0] & 0xffffffffL; + words[1] = ((tweak[0] >> 32) & 0xffffffffL); + words[2] = (tweak[1] & 0xffffffffL); + + for (i = 0; i < 3; i++) { + carry += words[i]; + words[i] = carry; + carry >>= 32; + } + tweak[0] = words[0] & 0xffffffffL; + tweak[0] |= (words[1] & 0xffffffffL) << 32; + tweak[1] |= words[2] & 0xffffffffL; + + threefishSetKey(&key, Threefish512, ctx->X, tweak); + + Skein_Get64_LSB_First(w, blkPtr, SKEIN_512_STATE_WORDS); /* get input block in little-endian format */ + + threefishEncryptBlockWords(&key, w, ctx->X); + + blkPtr += SKEIN_512_BLOCK_BYTES; + + /* do the final "feedforward" xor, update context chaining vars */ + ctx->X[0] = ctx->X[0] ^ w[0]; + ctx->X[1] = ctx->X[1] ^ w[1]; + ctx->X[2] = ctx->X[2] ^ w[2]; + ctx->X[3] = ctx->X[3] ^ w[3]; + ctx->X[4] = ctx->X[4] ^ w[4]; + ctx->X[5] = ctx->X[5] ^ w[5]; + ctx->X[6] = ctx->X[6] ^ w[6]; + ctx->X[7] = ctx->X[7] ^ w[7]; + + tweak[1] &= ~SKEIN_T1_FLAG_FIRST; + } while (--blkCnt); + + ctx->h.T[0] = tweak[0]; + ctx->h.T[1] = tweak[1]; } void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, - size_t blkCnt, size_t byteCntAdd) + size_t blkCnt, size_t byteCntAdd) { - struct threefish_key key; - u64 tweak[2]; - int i; - u64 words[3]; - u64 w[SKEIN1024_STATE_WORDS]; /* local copy of input block */ - - Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ - tweak[0] = ctx->h.T[0]; - tweak[1] = ctx->h.T[1]; - - do { - u64 carry = byteCntAdd; - - words[0] = tweak[0] & 0xffffffffL; - words[1] = ((tweak[0] >> 32) & 0xffffffffL); - words[2] = (tweak[1] & 0xffffffffL); - - for (i = 0; i < 3; i++) { - carry += words[i]; - words[i] = carry; - carry >>= 32; - } - tweak[0] = words[0] & 0xffffffffL; - tweak[0] |= (words[1] & 0xffffffffL) << 32; - tweak[1] |= words[2] & 0xffffffffL; - - threefishSetKey(&key, Threefish1024, ctx->X, tweak); - - Skein_Get64_LSB_First(w, blkPtr, SKEIN1024_STATE_WORDS); /* get input block in little-endian format */ - - threefishEncryptBlockWords(&key, w, ctx->X); - - blkPtr += SKEIN1024_BLOCK_BYTES; - - /* do the final "feedforward" xor, update context chaining vars */ - ctx->X[0] = ctx->X[0] ^ w[0]; - ctx->X[1] = ctx->X[1] ^ w[1]; - ctx->X[2] = ctx->X[2] ^ w[2]; - ctx->X[3] = ctx->X[3] ^ w[3]; - ctx->X[4] = ctx->X[4] ^ w[4]; - ctx->X[5] = ctx->X[5] ^ w[5]; - ctx->X[6] = ctx->X[6] ^ w[6]; - ctx->X[7] = ctx->X[7] ^ w[7]; - ctx->X[8] = ctx->X[8] ^ w[8]; - ctx->X[9] = ctx->X[9] ^ w[9]; - ctx->X[10] = ctx->X[10] ^ w[10]; - ctx->X[11] = ctx->X[11] ^ w[11]; - ctx->X[12] = ctx->X[12] ^ w[12]; - ctx->X[13] = ctx->X[13] ^ w[13]; - ctx->X[14] = ctx->X[14] ^ w[14]; - ctx->X[15] = ctx->X[15] ^ w[15]; - - tweak[1] &= ~SKEIN_T1_FLAG_FIRST; - } while (--blkCnt); - - ctx->h.T[0] = tweak[0]; - ctx->h.T[1] = tweak[1]; + struct threefish_key key; + u64 tweak[2]; + int i; + u64 words[3]; + u64 w[SKEIN1024_STATE_WORDS]; /* local copy of input block */ + + Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ + tweak[0] = ctx->h.T[0]; + tweak[1] = ctx->h.T[1]; + + do { + u64 carry = byteCntAdd; + + words[0] = tweak[0] & 0xffffffffL; + words[1] = ((tweak[0] >> 32) & 0xffffffffL); + words[2] = (tweak[1] & 0xffffffffL); + + for (i = 0; i < 3; i++) { + carry += words[i]; + words[i] = carry; + carry >>= 32; + } + tweak[0] = words[0] & 0xffffffffL; + tweak[0] |= (words[1] & 0xffffffffL) << 32; + tweak[1] |= words[2] & 0xffffffffL; + + threefishSetKey(&key, Threefish1024, ctx->X, tweak); + + Skein_Get64_LSB_First(w, blkPtr, SKEIN1024_STATE_WORDS); /* get input block in little-endian format */ + + threefishEncryptBlockWords(&key, w, ctx->X); + + blkPtr += SKEIN1024_BLOCK_BYTES; + + /* do the final "feedforward" xor, update context chaining vars */ + ctx->X[0] = ctx->X[0] ^ w[0]; + ctx->X[1] = ctx->X[1] ^ w[1]; + ctx->X[2] = ctx->X[2] ^ w[2]; + ctx->X[3] = ctx->X[3] ^ w[3]; + ctx->X[4] = ctx->X[4] ^ w[4]; + ctx->X[5] = ctx->X[5] ^ w[5]; + ctx->X[6] = ctx->X[6] ^ w[6]; + ctx->X[7] = ctx->X[7] ^ w[7]; + ctx->X[8] = ctx->X[8] ^ w[8]; + ctx->X[9] = ctx->X[9] ^ w[9]; + ctx->X[10] = ctx->X[10] ^ w[10]; + ctx->X[11] = ctx->X[11] ^ w[11]; + ctx->X[12] = ctx->X[12] ^ w[12]; + ctx->X[13] = ctx->X[13] ^ w[13]; + ctx->X[14] = ctx->X[14] ^ w[14]; + ctx->X[15] = ctx->X[15] ^ w[15]; + + tweak[1] &= ~SKEIN_T1_FLAG_FIRST; + } while (--blkCnt); + + ctx->h.T[0] = tweak[0]; + ctx->h.T[1] = tweak[1]; } diff --git a/drivers/staging/skein/skein_block.c b/drivers/staging/skein/skein_block.c index e62b6442783e..bb36860fafdf 100644 --- a/drivers/staging/skein/skein_block.c +++ b/drivers/staging/skein/skein_block.c @@ -40,10 +40,10 @@ /***************************** Skein_256 ******************************/ #if !(SKEIN_USE_ASM & 256) void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, size_t blkCnt, size_t byteCntAdd) - { /* do it in C */ - enum { - WCNT = SKEIN_256_STATE_WORDS - }; + { /* do it in C */ + enum { + WCNT = SKEIN_256_STATE_WORDS + }; #undef RCNT #define RCNT (SKEIN_256_ROUNDS_TOTAL/8) @@ -57,177 +57,177 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, size_t #if (RCNT % SKEIN_UNROLL_256) #error "Invalid SKEIN_UNROLL_256" /* sanity check on unroll count */ #endif - size_t r; - u64 kw[WCNT+4+RCNT*2]; /* key schedule words : chaining vars + tweak + "rotation"*/ + size_t r; + u64 kw[WCNT+4+RCNT*2]; /* key schedule words : chaining vars + tweak + "rotation"*/ #else - u64 kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ + u64 kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ #endif - u64 X0, X1, X2, X3; /* local copy of context vars, for speed */ - u64 w[WCNT]; /* local copy of input block */ + u64 X0, X1, X2, X3; /* local copy of context vars, for speed */ + u64 w[WCNT]; /* local copy of input block */ #ifdef SKEIN_DEBUG - const u64 *Xptr[4]; /* use for debugging (help compiler put Xn in registers) */ - Xptr[0] = &X0; Xptr[1] = &X1; Xptr[2] = &X2; Xptr[3] = &X3; + const u64 *Xptr[4]; /* use for debugging (help compiler put Xn in registers) */ + Xptr[0] = &X0; Xptr[1] = &X1; Xptr[2] = &X2; Xptr[3] = &X3; #endif - Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ - ts[0] = ctx->h.T[0]; - ts[1] = ctx->h.T[1]; - do { - /* this implementation only supports 2**64 input bytes (no carry out here) */ - ts[0] += byteCntAdd; /* update processed length */ + Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ + ts[0] = ctx->h.T[0]; + ts[1] = ctx->h.T[1]; + do { + /* this implementation only supports 2**64 input bytes (no carry out here) */ + ts[0] += byteCntAdd; /* update processed length */ - /* precompute the key schedule for this block */ - ks[0] = ctx->X[0]; - ks[1] = ctx->X[1]; - ks[2] = ctx->X[2]; - ks[3] = ctx->X[3]; - ks[4] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ SKEIN_KS_PARITY; + /* precompute the key schedule for this block */ + ks[0] = ctx->X[0]; + ks[1] = ctx->X[1]; + ks[2] = ctx->X[2]; + ks[3] = ctx->X[3]; + ks[4] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ SKEIN_KS_PARITY; - ts[2] = ts[0] ^ ts[1]; + ts[2] = ts[0] ^ ts[1]; - Skein_Get64_LSB_First(w, blkPtr, WCNT); /* get input block in little-endian format */ - DebugSaveTweak(ctx); - Skein_Show_Block(BLK_BITS, &ctx->h, ctx->X, blkPtr, w, ks, ts); + Skein_Get64_LSB_First(w, blkPtr, WCNT); /* get input block in little-endian format */ + DebugSaveTweak(ctx); + Skein_Show_Block(BLK_BITS, &ctx->h, ctx->X, blkPtr, w, ks, ts); - X0 = w[0] + ks[0]; /* do the first full key injection */ - X1 = w[1] + ks[1] + ts[0]; - X2 = w[2] + ks[2] + ts[1]; - X3 = w[3] + ks[3]; + X0 = w[0] + ks[0]; /* do the first full key injection */ + X1 = w[1] + ks[1] + ts[0]; + X2 = w[2] + ks[2] + ts[1]; + X3 = w[3] + ks[3]; - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, Xptr); /* show starting state values */ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, Xptr); /* show starting state values */ - blkPtr += SKEIN_256_BLOCK_BYTES; + blkPtr += SKEIN_256_BLOCK_BYTES; - /* run the rounds */ + /* run the rounds */ #define Round256(p0, p1, p2, p3, ROT, rNum) \ - X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ - X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ + X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ + X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ #if SKEIN_UNROLL_256 == 0 #define R256(p0, p1, p2, p3, ROT, rNum) /* fully unrolled */ \ - Round256(p0, p1, p2, p3, ROT, rNum) \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rNum, Xptr); + Round256(p0, p1, p2, p3, ROT, rNum) \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rNum, Xptr); #define I256(R) \ - X0 += ks[((R)+1) % 5]; /* inject the key schedule value */ \ - X1 += ks[((R)+2) % 5] + ts[((R)+1) % 3]; \ - X2 += ks[((R)+3) % 5] + ts[((R)+2) % 3]; \ - X3 += ks[((R)+4) % 5] + (R)+1; \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); + X0 += ks[((R)+1) % 5]; /* inject the key schedule value */ \ + X1 += ks[((R)+2) % 5] + ts[((R)+1) % 3]; \ + X2 += ks[((R)+3) % 5] + ts[((R)+2) % 3]; \ + X3 += ks[((R)+4) % 5] + (R)+1; \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); #else /* looping version */ #define R256(p0, p1, p2, p3, ROT, rNum) \ - Round256(p0, p1, p2, p3, ROT, rNum) \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rNum, Xptr); + Round256(p0, p1, p2, p3, ROT, rNum) \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rNum, Xptr); #define I256(R) \ - X0 += ks[r+(R)+0]; /* inject the key schedule value */ \ - X1 += ks[r+(R)+1] + ts[r+(R)+0]; \ - X2 += ks[r+(R)+2] + ts[r+(R)+1]; \ - X3 += ks[r+(R)+3] + r+(R); \ - ks[r + (R) + 4] = ks[r + (R) - 1]; /* rotate key schedule */\ - ts[r + (R) + 2] = ts[r + (R) - 1]; \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); - - for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_256) /* loop thru it */ + X0 += ks[r+(R)+0]; /* inject the key schedule value */ \ + X1 += ks[r+(R)+1] + ts[r+(R)+0]; \ + X2 += ks[r+(R)+2] + ts[r+(R)+1]; \ + X3 += ks[r+(R)+3] + r+(R); \ + ks[r + (R) + 4] = ks[r + (R) - 1]; /* rotate key schedule */\ + ts[r + (R) + 2] = ts[r + (R) - 1]; \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); + + for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_256) /* loop thru it */ #endif - { + { #define R256_8_rounds(R) \ - R256(0, 1, 2, 3, R_256_0, 8 * (R) + 1); \ - R256(0, 3, 2, 1, R_256_1, 8 * (R) + 2); \ - R256(0, 1, 2, 3, R_256_2, 8 * (R) + 3); \ - R256(0, 3, 2, 1, R_256_3, 8 * (R) + 4); \ - I256(2 * (R)); \ - R256(0, 1, 2, 3, R_256_4, 8 * (R) + 5); \ - R256(0, 3, 2, 1, R_256_5, 8 * (R) + 6); \ - R256(0, 1, 2, 3, R_256_6, 8 * (R) + 7); \ - R256(0, 3, 2, 1, R_256_7, 8 * (R) + 8); \ - I256(2 * (R) + 1); - - R256_8_rounds(0); + R256(0, 1, 2, 3, R_256_0, 8 * (R) + 1); \ + R256(0, 3, 2, 1, R_256_1, 8 * (R) + 2); \ + R256(0, 1, 2, 3, R_256_2, 8 * (R) + 3); \ + R256(0, 3, 2, 1, R_256_3, 8 * (R) + 4); \ + I256(2 * (R)); \ + R256(0, 1, 2, 3, R_256_4, 8 * (R) + 5); \ + R256(0, 3, 2, 1, R_256_5, 8 * (R) + 6); \ + R256(0, 1, 2, 3, R_256_6, 8 * (R) + 7); \ + R256(0, 3, 2, 1, R_256_7, 8 * (R) + 8); \ + I256(2 * (R) + 1); + + R256_8_rounds(0); #define R256_Unroll_R(NN) ((SKEIN_UNROLL_256 == 0 && SKEIN_256_ROUNDS_TOTAL/8 > (NN)) || (SKEIN_UNROLL_256 > (NN))) - #if R256_Unroll_R(1) - R256_8_rounds(1); - #endif - #if R256_Unroll_R(2) - R256_8_rounds(2); - #endif - #if R256_Unroll_R(3) - R256_8_rounds(3); - #endif - #if R256_Unroll_R(4) - R256_8_rounds(4); - #endif - #if R256_Unroll_R(5) - R256_8_rounds(5); - #endif - #if R256_Unroll_R(6) - R256_8_rounds(6); - #endif - #if R256_Unroll_R(7) - R256_8_rounds(7); - #endif - #if R256_Unroll_R(8) - R256_8_rounds(8); - #endif - #if R256_Unroll_R(9) - R256_8_rounds(9); - #endif - #if R256_Unroll_R(10) - R256_8_rounds(10); - #endif - #if R256_Unroll_R(11) - R256_8_rounds(11); - #endif - #if R256_Unroll_R(12) - R256_8_rounds(12); - #endif - #if R256_Unroll_R(13) - R256_8_rounds(13); - #endif - #if R256_Unroll_R(14) - R256_8_rounds(14); - #endif - #if (SKEIN_UNROLL_256 > 14) + #if R256_Unroll_R(1) + R256_8_rounds(1); + #endif + #if R256_Unroll_R(2) + R256_8_rounds(2); + #endif + #if R256_Unroll_R(3) + R256_8_rounds(3); + #endif + #if R256_Unroll_R(4) + R256_8_rounds(4); + #endif + #if R256_Unroll_R(5) + R256_8_rounds(5); + #endif + #if R256_Unroll_R(6) + R256_8_rounds(6); + #endif + #if R256_Unroll_R(7) + R256_8_rounds(7); + #endif + #if R256_Unroll_R(8) + R256_8_rounds(8); + #endif + #if R256_Unroll_R(9) + R256_8_rounds(9); + #endif + #if R256_Unroll_R(10) + R256_8_rounds(10); + #endif + #if R256_Unroll_R(11) + R256_8_rounds(11); + #endif + #if R256_Unroll_R(12) + R256_8_rounds(12); + #endif + #if R256_Unroll_R(13) + R256_8_rounds(13); + #endif + #if R256_Unroll_R(14) + R256_8_rounds(14); + #endif + #if (SKEIN_UNROLL_256 > 14) #error "need more unrolling in Skein_256_Process_Block" - #endif - } - /* do the final "feedforward" xor, update context chaining vars */ - ctx->X[0] = X0 ^ w[0]; - ctx->X[1] = X1 ^ w[1]; - ctx->X[2] = X2 ^ w[2]; - ctx->X[3] = X3 ^ w[3]; - - Skein_Show_Round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X); - - ts[1] &= ~SKEIN_T1_FLAG_FIRST; - } - while (--blkCnt); - ctx->h.T[0] = ts[0]; - ctx->h.T[1] = ts[1]; - } + #endif + } + /* do the final "feedforward" xor, update context chaining vars */ + ctx->X[0] = X0 ^ w[0]; + ctx->X[1] = X1 ^ w[1]; + ctx->X[2] = X2 ^ w[2]; + ctx->X[3] = X3 ^ w[3]; + + Skein_Show_Round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X); + + ts[1] &= ~SKEIN_T1_FLAG_FIRST; + } + while (--blkCnt); + ctx->h.T[0] = ts[0]; + ctx->h.T[1] = ts[1]; +} #if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF) size_t Skein_256_Process_Block_CodeSize(void) - { - return ((u8 *) Skein_256_Process_Block_CodeSize) - - ((u8 *) Skein_256_Process_Block); - } +{ + return ((u8 *) Skein_256_Process_Block_CodeSize) - + ((u8 *) Skein_256_Process_Block); +} unsigned int Skein_256_Unroll_Cnt(void) - { - return SKEIN_UNROLL_256; - } +{ + return SKEIN_UNROLL_256; +} #endif #endif /***************************** Skein_512 ******************************/ #if !(SKEIN_USE_ASM & 512) void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, size_t blkCnt, size_t byteCntAdd) - { /* do it in C */ - enum { - WCNT = SKEIN_512_STATE_WORDS - }; +{ /* do it in C */ + enum { + WCNT = SKEIN_512_STATE_WORDS + }; #undef RCNT #define RCNT (SKEIN_512_ROUNDS_TOTAL/8) @@ -241,200 +241,200 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, size_t #if (RCNT % SKEIN_UNROLL_512) #error "Invalid SKEIN_UNROLL_512" /* sanity check on unroll count */ #endif - size_t r; - u64 kw[WCNT+4+RCNT*2]; /* key schedule words : chaining vars + tweak + "rotation"*/ + size_t r; + u64 kw[WCNT+4+RCNT*2]; /* key schedule words : chaining vars + tweak + "rotation"*/ #else - u64 kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ + u64 kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ #endif - u64 X0, X1, X2, X3, X4, X5, X6, X7; /* local copy of vars, for speed */ - u64 w[WCNT]; /* local copy of input block */ + u64 X0, X1, X2, X3, X4, X5, X6, X7; /* local copy of vars, for speed */ + u64 w[WCNT]; /* local copy of input block */ #ifdef SKEIN_DEBUG - const u64 *Xptr[8]; /* use for debugging (help compiler put Xn in registers) */ - Xptr[0] = &X0; Xptr[1] = &X1; Xptr[2] = &X2; Xptr[3] = &X3; - Xptr[4] = &X4; Xptr[5] = &X5; Xptr[6] = &X6; Xptr[7] = &X7; + const u64 *Xptr[8]; /* use for debugging (help compiler put Xn in registers) */ + Xptr[0] = &X0; Xptr[1] = &X1; Xptr[2] = &X2; Xptr[3] = &X3; + Xptr[4] = &X4; Xptr[5] = &X5; Xptr[6] = &X6; Xptr[7] = &X7; #endif - Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ - ts[0] = ctx->h.T[0]; - ts[1] = ctx->h.T[1]; - do { - /* this implementation only supports 2**64 input bytes (no carry out here) */ - ts[0] += byteCntAdd; /* update processed length */ - - /* precompute the key schedule for this block */ - ks[0] = ctx->X[0]; - ks[1] = ctx->X[1]; - ks[2] = ctx->X[2]; - ks[3] = ctx->X[3]; - ks[4] = ctx->X[4]; - ks[5] = ctx->X[5]; - ks[6] = ctx->X[6]; - ks[7] = ctx->X[7]; - ks[8] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ - ks[4] ^ ks[5] ^ ks[6] ^ ks[7] ^ SKEIN_KS_PARITY; - - ts[2] = ts[0] ^ ts[1]; - - Skein_Get64_LSB_First(w, blkPtr, WCNT); /* get input block in little-endian format */ - DebugSaveTweak(ctx); - Skein_Show_Block(BLK_BITS, &ctx->h, ctx->X, blkPtr, w, ks, ts); - - X0 = w[0] + ks[0]; /* do the first full key injection */ - X1 = w[1] + ks[1]; - X2 = w[2] + ks[2]; - X3 = w[3] + ks[3]; - X4 = w[4] + ks[4]; - X5 = w[5] + ks[5] + ts[0]; - X6 = w[6] + ks[6] + ts[1]; - X7 = w[7] + ks[7]; - - blkPtr += SKEIN_512_BLOCK_BYTES; - - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, Xptr); - /* run the rounds */ + Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ + ts[0] = ctx->h.T[0]; + ts[1] = ctx->h.T[1]; + do { + /* this implementation only supports 2**64 input bytes (no carry out here) */ + ts[0] += byteCntAdd; /* update processed length */ + + /* precompute the key schedule for this block */ + ks[0] = ctx->X[0]; + ks[1] = ctx->X[1]; + ks[2] = ctx->X[2]; + ks[3] = ctx->X[3]; + ks[4] = ctx->X[4]; + ks[5] = ctx->X[5]; + ks[6] = ctx->X[6]; + ks[7] = ctx->X[7]; + ks[8] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ + ks[4] ^ ks[5] ^ ks[6] ^ ks[7] ^ SKEIN_KS_PARITY; + + ts[2] = ts[0] ^ ts[1]; + + Skein_Get64_LSB_First(w, blkPtr, WCNT); /* get input block in little-endian format */ + DebugSaveTweak(ctx); + Skein_Show_Block(BLK_BITS, &ctx->h, ctx->X, blkPtr, w, ks, ts); + + X0 = w[0] + ks[0]; /* do the first full key injection */ + X1 = w[1] + ks[1]; + X2 = w[2] + ks[2]; + X3 = w[3] + ks[3]; + X4 = w[4] + ks[4]; + X5 = w[5] + ks[5] + ts[0]; + X6 = w[6] + ks[6] + ts[1]; + X7 = w[7] + ks[7]; + + blkPtr += SKEIN_512_BLOCK_BYTES; + + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, Xptr); + /* run the rounds */ #define Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \ - X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ - X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ - X##p4 += X##p5; X##p5 = RotL_64(X##p5, ROT##_2); X##p5 ^= X##p4; \ - X##p6 += X##p7; X##p7 = RotL_64(X##p7, ROT##_3); X##p7 ^= X##p6; \ + X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ + X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ + X##p4 += X##p5; X##p5 = RotL_64(X##p5, ROT##_2); X##p5 ^= X##p4; \ + X##p6 += X##p7; X##p7 = RotL_64(X##p7, ROT##_3); X##p7 ^= X##p6; \ #if SKEIN_UNROLL_512 == 0 #define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) /* unrolled */ \ - Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rNum, Xptr); + Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rNum, Xptr); #define I512(R) \ - X0 += ks[((R) + 1) % 9]; /* inject the key schedule value */ \ - X1 += ks[((R) + 2) % 9]; \ - X2 += ks[((R) + 3) % 9]; \ - X3 += ks[((R) + 4) % 9]; \ - X4 += ks[((R) + 5) % 9]; \ - X5 += ks[((R) + 6) % 9] + ts[((R) + 1) % 3]; \ - X6 += ks[((R) + 7) % 9] + ts[((R) + 2) % 3]; \ - X7 += ks[((R) + 8) % 9] + (R) + 1; \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); + X0 += ks[((R) + 1) % 9]; /* inject the key schedule value */ \ + X1 += ks[((R) + 2) % 9]; \ + X2 += ks[((R) + 3) % 9]; \ + X3 += ks[((R) + 4) % 9]; \ + X4 += ks[((R) + 5) % 9]; \ + X5 += ks[((R) + 6) % 9] + ts[((R) + 1) % 3]; \ + X6 += ks[((R) + 7) % 9] + ts[((R) + 2) % 3]; \ + X7 += ks[((R) + 8) % 9] + (R) + 1; \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); #else /* looping version */ #define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \ - Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rNum, Xptr); + Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rNum, Xptr); #define I512(R) \ - X0 += ks[r + (R) + 0]; /* inject the key schedule value */ \ - X1 += ks[r + (R) + 1]; \ - X2 += ks[r + (R) + 2]; \ - X3 += ks[r + (R) + 3]; \ - X4 += ks[r + (R) + 4]; \ - X5 += ks[r + (R) + 5] + ts[r + (R) + 0]; \ - X6 += ks[r + (R) + 6] + ts[r + (R) + 1]; \ - X7 += ks[r + (R) + 7] + r + (R); \ - ks[r + (R) + 8] = ks[r + (R) - 1]; /* rotate key schedule */ \ - ts[r + (R) + 2] = ts[r + (R) - 1]; \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); - - for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_512) /* loop thru it */ + X0 += ks[r + (R) + 0]; /* inject the key schedule value */ \ + X1 += ks[r + (R) + 1]; \ + X2 += ks[r + (R) + 2]; \ + X3 += ks[r + (R) + 3]; \ + X4 += ks[r + (R) + 4]; \ + X5 += ks[r + (R) + 5] + ts[r + (R) + 0]; \ + X6 += ks[r + (R) + 6] + ts[r + (R) + 1]; \ + X7 += ks[r + (R) + 7] + r + (R); \ + ks[r + (R) + 8] = ks[r + (R) - 1]; /* rotate key schedule */ \ + ts[r + (R) + 2] = ts[r + (R) - 1]; \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); + + for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_512) /* loop thru it */ #endif /* end of looped code definitions */ - { + { #define R512_8_rounds(R) /* do 8 full rounds */ \ - R512(0, 1, 2, 3, 4, 5, 6, 7, R_512_0, 8 * (R) + 1); \ - R512(2, 1, 4, 7, 6, 5, 0, 3, R_512_1, 8 * (R) + 2); \ - R512(4, 1, 6, 3, 0, 5, 2, 7, R_512_2, 8 * (R) + 3); \ - R512(6, 1, 0, 7, 2, 5, 4, 3, R_512_3, 8 * (R) + 4); \ - I512(2 * (R)); \ - R512(0, 1, 2, 3, 4, 5, 6, 7, R_512_4, 8 * (R) + 5); \ - R512(2, 1, 4, 7, 6, 5, 0, 3, R_512_5, 8 * (R) + 6); \ - R512(4, 1, 6, 3, 0, 5, 2, 7, R_512_6, 8 * (R) + 7); \ - R512(6, 1, 0, 7, 2, 5, 4, 3, R_512_7, 8 * (R) + 8); \ - I512(2 * (R) + 1); /* and key injection */ - - R512_8_rounds(0); + R512(0, 1, 2, 3, 4, 5, 6, 7, R_512_0, 8 * (R) + 1); \ + R512(2, 1, 4, 7, 6, 5, 0, 3, R_512_1, 8 * (R) + 2); \ + R512(4, 1, 6, 3, 0, 5, 2, 7, R_512_2, 8 * (R) + 3); \ + R512(6, 1, 0, 7, 2, 5, 4, 3, R_512_3, 8 * (R) + 4); \ + I512(2 * (R)); \ + R512(0, 1, 2, 3, 4, 5, 6, 7, R_512_4, 8 * (R) + 5); \ + R512(2, 1, 4, 7, 6, 5, 0, 3, R_512_5, 8 * (R) + 6); \ + R512(4, 1, 6, 3, 0, 5, 2, 7, R_512_6, 8 * (R) + 7); \ + R512(6, 1, 0, 7, 2, 5, 4, 3, R_512_7, 8 * (R) + 8); \ + I512(2 * (R) + 1); /* and key injection */ + + R512_8_rounds(0); #define R512_Unroll_R(NN) ((SKEIN_UNROLL_512 == 0 && SKEIN_512_ROUNDS_TOTAL/8 > (NN)) || (SKEIN_UNROLL_512 > (NN))) - #if R512_Unroll_R(1) - R512_8_rounds(1); - #endif - #if R512_Unroll_R(2) - R512_8_rounds(2); - #endif - #if R512_Unroll_R(3) - R512_8_rounds(3); - #endif - #if R512_Unroll_R(4) - R512_8_rounds(4); - #endif - #if R512_Unroll_R(5) - R512_8_rounds(5); - #endif - #if R512_Unroll_R(6) - R512_8_rounds(6); - #endif - #if R512_Unroll_R(7) - R512_8_rounds(7); - #endif - #if R512_Unroll_R(8) - R512_8_rounds(8); - #endif - #if R512_Unroll_R(9) - R512_8_rounds(9); - #endif - #if R512_Unroll_R(10) - R512_8_rounds(10); - #endif - #if R512_Unroll_R(11) - R512_8_rounds(11); - #endif - #if R512_Unroll_R(12) - R512_8_rounds(12); - #endif - #if R512_Unroll_R(13) - R512_8_rounds(13); - #endif - #if R512_Unroll_R(14) - R512_8_rounds(14); - #endif - #if (SKEIN_UNROLL_512 > 14) + #if R512_Unroll_R(1) + R512_8_rounds(1); + #endif + #if R512_Unroll_R(2) + R512_8_rounds(2); + #endif + #if R512_Unroll_R(3) + R512_8_rounds(3); + #endif + #if R512_Unroll_R(4) + R512_8_rounds(4); + #endif + #if R512_Unroll_R(5) + R512_8_rounds(5); + #endif + #if R512_Unroll_R(6) + R512_8_rounds(6); + #endif + #if R512_Unroll_R(7) + R512_8_rounds(7); + #endif + #if R512_Unroll_R(8) + R512_8_rounds(8); + #endif + #if R512_Unroll_R(9) + R512_8_rounds(9); + #endif + #if R512_Unroll_R(10) + R512_8_rounds(10); + #endif + #if R512_Unroll_R(11) + R512_8_rounds(11); + #endif + #if R512_Unroll_R(12) + R512_8_rounds(12); + #endif + #if R512_Unroll_R(13) + R512_8_rounds(13); + #endif + #if R512_Unroll_R(14) + R512_8_rounds(14); + #endif + #if (SKEIN_UNROLL_512 > 14) #error "need more unrolling in Skein_512_Process_Block" - #endif - } - - /* do the final "feedforward" xor, update context chaining vars */ - ctx->X[0] = X0 ^ w[0]; - ctx->X[1] = X1 ^ w[1]; - ctx->X[2] = X2 ^ w[2]; - ctx->X[3] = X3 ^ w[3]; - ctx->X[4] = X4 ^ w[4]; - ctx->X[5] = X5 ^ w[5]; - ctx->X[6] = X6 ^ w[6]; - ctx->X[7] = X7 ^ w[7]; - Skein_Show_Round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X); - - ts[1] &= ~SKEIN_T1_FLAG_FIRST; - } - while (--blkCnt); - ctx->h.T[0] = ts[0]; - ctx->h.T[1] = ts[1]; - } + #endif + } + + /* do the final "feedforward" xor, update context chaining vars */ + ctx->X[0] = X0 ^ w[0]; + ctx->X[1] = X1 ^ w[1]; + ctx->X[2] = X2 ^ w[2]; + ctx->X[3] = X3 ^ w[3]; + ctx->X[4] = X4 ^ w[4]; + ctx->X[5] = X5 ^ w[5]; + ctx->X[6] = X6 ^ w[6]; + ctx->X[7] = X7 ^ w[7]; + Skein_Show_Round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X); + + ts[1] &= ~SKEIN_T1_FLAG_FIRST; + } + while (--blkCnt); + ctx->h.T[0] = ts[0]; + ctx->h.T[1] = ts[1]; +} #if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF) size_t Skein_512_Process_Block_CodeSize(void) - { - return ((u8 *) Skein_512_Process_Block_CodeSize) - - ((u8 *) Skein_512_Process_Block); - } +{ + return ((u8 *) Skein_512_Process_Block_CodeSize) - + ((u8 *) Skein_512_Process_Block); +} unsigned int Skein_512_Unroll_Cnt(void) - { - return SKEIN_UNROLL_512; - } +{ + return SKEIN_UNROLL_512; +} #endif #endif /***************************** Skein1024 ******************************/ #if !(SKEIN_USE_ASM & 1024) void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, size_t blkCnt, size_t byteCntAdd) - { /* do it in C, always looping (unrolled is bigger AND slower!) */ - enum { - WCNT = SKEIN1024_STATE_WORDS - }; +{ /* do it in C, always looping (unrolled is bigger AND slower!) */ + enum { + WCNT = SKEIN1024_STATE_WORDS + }; #undef RCNT #define RCNT (SKEIN1024_ROUNDS_TOTAL/8) @@ -448,239 +448,239 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, size_t #if (RCNT % SKEIN_UNROLL_1024) #error "Invalid SKEIN_UNROLL_1024" /* sanity check on unroll count */ #endif - size_t r; - u64 kw[WCNT+4+RCNT*2]; /* key schedule words : chaining vars + tweak + "rotation"*/ + size_t r; + u64 kw[WCNT+4+RCNT*2]; /* key schedule words : chaining vars + tweak + "rotation"*/ #else - u64 kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ + u64 kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ #endif - u64 X00, X01, X02, X03, X04, X05, X06, X07, /* local copy of vars, for speed */ - X08, X09, X10, X11, X12, X13, X14, X15; - u64 w[WCNT]; /* local copy of input block */ + u64 X00, X01, X02, X03, X04, X05, X06, X07, /* local copy of vars, for speed */ + X08, X09, X10, X11, X12, X13, X14, X15; + u64 w[WCNT]; /* local copy of input block */ #ifdef SKEIN_DEBUG - const u64 *Xptr[16]; /* use for debugging (help compiler put Xn in registers) */ - Xptr[0] = &X00; Xptr[1] = &X01; Xptr[2] = &X02; Xptr[3] = &X03; - Xptr[4] = &X04; Xptr[5] = &X05; Xptr[6] = &X06; Xptr[7] = &X07; - Xptr[8] = &X08; Xptr[9] = &X09; Xptr[10] = &X10; Xptr[11] = &X11; - Xptr[12] = &X12; Xptr[13] = &X13; Xptr[14] = &X14; Xptr[15] = &X15; + const u64 *Xptr[16]; /* use for debugging (help compiler put Xn in registers) */ + Xptr[0] = &X00; Xptr[1] = &X01; Xptr[2] = &X02; Xptr[3] = &X03; + Xptr[4] = &X04; Xptr[5] = &X05; Xptr[6] = &X06; Xptr[7] = &X07; + Xptr[8] = &X08; Xptr[9] = &X09; Xptr[10] = &X10; Xptr[11] = &X11; + Xptr[12] = &X12; Xptr[13] = &X13; Xptr[14] = &X14; Xptr[15] = &X15; #endif - Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ - ts[0] = ctx->h.T[0]; - ts[1] = ctx->h.T[1]; - do { - /* this implementation only supports 2**64 input bytes (no carry out here) */ - ts[0] += byteCntAdd; /* update processed length */ - - /* precompute the key schedule for this block */ - ks[0] = ctx->X[0]; - ks[1] = ctx->X[1]; - ks[2] = ctx->X[2]; - ks[3] = ctx->X[3]; - ks[4] = ctx->X[4]; - ks[5] = ctx->X[5]; - ks[6] = ctx->X[6]; - ks[7] = ctx->X[7]; - ks[8] = ctx->X[8]; - ks[9] = ctx->X[9]; - ks[10] = ctx->X[10]; - ks[11] = ctx->X[11]; - ks[12] = ctx->X[12]; - ks[13] = ctx->X[13]; - ks[14] = ctx->X[14]; - ks[15] = ctx->X[15]; - ks[16] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ - ks[4] ^ ks[5] ^ ks[6] ^ ks[7] ^ - ks[8] ^ ks[9] ^ ks[10] ^ ks[11] ^ - ks[12] ^ ks[13] ^ ks[14] ^ ks[15] ^ SKEIN_KS_PARITY; - - ts[2] = ts[0] ^ ts[1]; - - Skein_Get64_LSB_First(w, blkPtr, WCNT); /* get input block in little-endian format */ - DebugSaveTweak(ctx); - Skein_Show_Block(BLK_BITS, &ctx->h, ctx->X, blkPtr, w, ks, ts); - - X00 = w[0] + ks[0]; /* do the first full key injection */ - X01 = w[1] + ks[1]; - X02 = w[2] + ks[2]; - X03 = w[3] + ks[3]; - X04 = w[4] + ks[4]; - X05 = w[5] + ks[5]; - X06 = w[6] + ks[6]; - X07 = w[7] + ks[7]; - X08 = w[8] + ks[8]; - X09 = w[9] + ks[9]; - X10 = w[10] + ks[10]; - X11 = w[11] + ks[11]; - X12 = w[12] + ks[12]; - X13 = w[13] + ks[13] + ts[0]; - X14 = w[14] + ks[14] + ts[1]; - X15 = w[15] + ks[15]; - - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, Xptr); + Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ + ts[0] = ctx->h.T[0]; + ts[1] = ctx->h.T[1]; + do { + /* this implementation only supports 2**64 input bytes (no carry out here) */ + ts[0] += byteCntAdd; /* update processed length */ + + /* precompute the key schedule for this block */ + ks[0] = ctx->X[0]; + ks[1] = ctx->X[1]; + ks[2] = ctx->X[2]; + ks[3] = ctx->X[3]; + ks[4] = ctx->X[4]; + ks[5] = ctx->X[5]; + ks[6] = ctx->X[6]; + ks[7] = ctx->X[7]; + ks[8] = ctx->X[8]; + ks[9] = ctx->X[9]; + ks[10] = ctx->X[10]; + ks[11] = ctx->X[11]; + ks[12] = ctx->X[12]; + ks[13] = ctx->X[13]; + ks[14] = ctx->X[14]; + ks[15] = ctx->X[15]; + ks[16] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ + ks[4] ^ ks[5] ^ ks[6] ^ ks[7] ^ + ks[8] ^ ks[9] ^ ks[10] ^ ks[11] ^ + ks[12] ^ ks[13] ^ ks[14] ^ ks[15] ^ SKEIN_KS_PARITY; + + ts[2] = ts[0] ^ ts[1]; + + Skein_Get64_LSB_First(w, blkPtr, WCNT); /* get input block in little-endian format */ + DebugSaveTweak(ctx); + Skein_Show_Block(BLK_BITS, &ctx->h, ctx->X, blkPtr, w, ks, ts); + + X00 = w[0] + ks[0]; /* do the first full key injection */ + X01 = w[1] + ks[1]; + X02 = w[2] + ks[2]; + X03 = w[3] + ks[3]; + X04 = w[4] + ks[4]; + X05 = w[5] + ks[5]; + X06 = w[6] + ks[6]; + X07 = w[7] + ks[7]; + X08 = w[8] + ks[8]; + X09 = w[9] + ks[9]; + X10 = w[10] + ks[10]; + X11 = w[11] + ks[11]; + X12 = w[12] + ks[12]; + X13 = w[13] + ks[13] + ts[0]; + X14 = w[14] + ks[14] + ts[1]; + X15 = w[15] + ks[15]; + + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, Xptr); #define Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, ROT, rNum) \ - X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ - X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ - X##p4 += X##p5; X##p5 = RotL_64(X##p5, ROT##_2); X##p5 ^= X##p4; \ - X##p6 += X##p7; X##p7 = RotL_64(X##p7, ROT##_3); X##p7 ^= X##p6; \ - X##p8 += X##p9; X##p9 = RotL_64(X##p9, ROT##_4); X##p9 ^= X##p8; \ - X##pA += X##pB; X##pB = RotL_64(X##pB, ROT##_5); X##pB ^= X##pA; \ - X##pC += X##pD; X##pD = RotL_64(X##pD, ROT##_6); X##pD ^= X##pC; \ - X##pE += X##pF; X##pF = RotL_64(X##pF, ROT##_7); X##pF ^= X##pE; \ + X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ + X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ + X##p4 += X##p5; X##p5 = RotL_64(X##p5, ROT##_2); X##p5 ^= X##p4; \ + X##p6 += X##p7; X##p7 = RotL_64(X##p7, ROT##_3); X##p7 ^= X##p6; \ + X##p8 += X##p9; X##p9 = RotL_64(X##p9, ROT##_4); X##p9 ^= X##p8; \ + X##pA += X##pB; X##pB = RotL_64(X##pB, ROT##_5); X##pB ^= X##pA; \ + X##pC += X##pD; X##pD = RotL_64(X##pD, ROT##_6); X##pD ^= X##pC; \ + X##pE += X##pF; X##pF = RotL_64(X##pF, ROT##_7); X##pF ^= X##pE; \ #if SKEIN_UNROLL_1024 == 0 #define R1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, ROT, rn) \ - Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, ROT, rn) \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rn, Xptr); + Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, ROT, rn) \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rn, Xptr); #define I1024(R) \ - X00 += ks[((R) + 1) % 17]; /* inject the key schedule value */ \ - X01 += ks[((R) + 2) % 17]; \ - X02 += ks[((R) + 3) % 17]; \ - X03 += ks[((R) + 4) % 17]; \ - X04 += ks[((R) + 5) % 17]; \ - X05 += ks[((R) + 6) % 17]; \ - X06 += ks[((R) + 7) % 17]; \ - X07 += ks[((R) + 8) % 17]; \ - X08 += ks[((R) + 9) % 17]; \ - X09 += ks[((R) + 10) % 17]; \ - X10 += ks[((R) + 11) % 17]; \ - X11 += ks[((R) + 12) % 17]; \ - X12 += ks[((R) + 13) % 17]; \ - X13 += ks[((R) + 14) % 17] + ts[((R) + 1) % 3]; \ - X14 += ks[((R) + 15) % 17] + ts[((R) + 2) % 3]; \ - X15 += ks[((R) + 16) % 17] + (R) + 1; \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); + X00 += ks[((R) + 1) % 17]; /* inject the key schedule value */ \ + X01 += ks[((R) + 2) % 17]; \ + X02 += ks[((R) + 3) % 17]; \ + X03 += ks[((R) + 4) % 17]; \ + X04 += ks[((R) + 5) % 17]; \ + X05 += ks[((R) + 6) % 17]; \ + X06 += ks[((R) + 7) % 17]; \ + X07 += ks[((R) + 8) % 17]; \ + X08 += ks[((R) + 9) % 17]; \ + X09 += ks[((R) + 10) % 17]; \ + X10 += ks[((R) + 11) % 17]; \ + X11 += ks[((R) + 12) % 17]; \ + X12 += ks[((R) + 13) % 17]; \ + X13 += ks[((R) + 14) % 17] + ts[((R) + 1) % 3]; \ + X14 += ks[((R) + 15) % 17] + ts[((R) + 2) % 3]; \ + X15 += ks[((R) + 16) % 17] + (R) + 1; \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); #else /* looping version */ #define R1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, ROT, rn) \ - Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, ROT, rn) \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rn, Xptr); + Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, ROT, rn) \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rn, Xptr); #define I1024(R) \ - X00 += ks[r + (R) + 0]; /* inject the key schedule value */ \ - X01 += ks[r + (R) + 1]; \ - X02 += ks[r + (R) + 2]; \ - X03 += ks[r + (R) + 3]; \ - X04 += ks[r + (R) + 4]; \ - X05 += ks[r + (R) + 5]; \ - X06 += ks[r + (R) + 6]; \ - X07 += ks[r + (R) + 7]; \ - X08 += ks[r + (R) + 8]; \ - X09 += ks[r + (R) + 9]; \ - X10 += ks[r + (R) + 10]; \ - X11 += ks[r + (R) + 11]; \ - X12 += ks[r + (R) + 12]; \ - X13 += ks[r + (R) + 13] + ts[r + (R) + 0]; \ - X14 += ks[r + (R) + 14] + ts[r + (R) + 1]; \ - X15 += ks[r + (R) + 15] + r + (R); \ - ks[r + (R) + 16] = ks[r + (R) - 1]; /* rotate key schedule */\ - ts[r + (R) + 2] = ts[r + (R) - 1]; \ - Skein_Show_R_Ptr(BLK_BITSi, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); - - for (r = 1; r <= 2 * RCNT; r += 2 * SKEIN_UNROLL_1024) /* loop thru it */ + X00 += ks[r + (R) + 0]; /* inject the key schedule value */ \ + X01 += ks[r + (R) + 1]; \ + X02 += ks[r + (R) + 2]; \ + X03 += ks[r + (R) + 3]; \ + X04 += ks[r + (R) + 4]; \ + X05 += ks[r + (R) + 5]; \ + X06 += ks[r + (R) + 6]; \ + X07 += ks[r + (R) + 7]; \ + X08 += ks[r + (R) + 8]; \ + X09 += ks[r + (R) + 9]; \ + X10 += ks[r + (R) + 10]; \ + X11 += ks[r + (R) + 11]; \ + X12 += ks[r + (R) + 12]; \ + X13 += ks[r + (R) + 13] + ts[r + (R) + 0]; \ + X14 += ks[r + (R) + 14] + ts[r + (R) + 1]; \ + X15 += ks[r + (R) + 15] + r + (R); \ + ks[r + (R) + 16] = ks[r + (R) - 1]; /* rotate key schedule */\ + ts[r + (R) + 2] = ts[r + (R) - 1]; \ + Skein_Show_R_Ptr(BLK_BITSi, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); + + for (r = 1; r <= 2 * RCNT; r += 2 * SKEIN_UNROLL_1024) /* loop thru it */ #endif - { + { #define R1024_8_rounds(R) /* do 8 full rounds */ \ - R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, R1024_0, 8*(R) + 1); \ - R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, 05, 08, 01, R1024_1, 8*(R) + 2); \ - R1024(00, 07, 02, 05, 04, 03, 06, 01, 12, 15, 14, 13, 08, 11, 10, 09, R1024_2, 8*(R) + 3); \ - R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, 03, 12, 07, R1024_3, 8*(R) + 4); \ - I1024(2*(R)); \ - R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, R1024_4, 8*(R) + 5); \ - R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, 05, 08, 01, R1024_5, 8*(R) + 6); \ - R1024(00, 07, 02, 05, 04, 03, 06, 01, 12, 15, 14, 13, 08, 11, 10, 09, R1024_6, 8*(R) + 7); \ - R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, 03, 12, 07, R1024_7, 8*(R) + 8); \ - I1024(2*(R)+1); - - R1024_8_rounds(0); + R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, R1024_0, 8*(R) + 1); \ + R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, 05, 08, 01, R1024_1, 8*(R) + 2); \ + R1024(00, 07, 02, 05, 04, 03, 06, 01, 12, 15, 14, 13, 08, 11, 10, 09, R1024_2, 8*(R) + 3); \ + R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, 03, 12, 07, R1024_3, 8*(R) + 4); \ + I1024(2*(R)); \ + R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, R1024_4, 8*(R) + 5); \ + R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, 05, 08, 01, R1024_5, 8*(R) + 6); \ + R1024(00, 07, 02, 05, 04, 03, 06, 01, 12, 15, 14, 13, 08, 11, 10, 09, R1024_6, 8*(R) + 7); \ + R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, 03, 12, 07, R1024_7, 8*(R) + 8); \ + I1024(2*(R)+1); + + R1024_8_rounds(0); #define R1024_Unroll_R(NN) ((SKEIN_UNROLL_1024 == 0 && SKEIN1024_ROUNDS_TOTAL/8 > (NN)) || (SKEIN_UNROLL_1024 > (NN))) - #if R1024_Unroll_R(1) - R1024_8_rounds(1); - #endif - #if R1024_Unroll_R(2) - R1024_8_rounds(2); - #endif - #if R1024_Unroll_R(3) - R1024_8_rounds(3); - #endif - #if R1024_Unroll_R(4) - R1024_8_rounds(4); - #endif - #if R1024_Unroll_R(5) - R1024_8_rounds(5); - #endif - #if R1024_Unroll_R(6) - R1024_8_rounds(6); - #endif - #if R1024_Unroll_R(7) - R1024_8_rounds(7); - #endif - #if R1024_Unroll_R(8) - R1024_8_rounds(8); - #endif - #if R1024_Unroll_R(9) - R1024_8_rounds(9); - #endif - #if R1024_Unroll_R(10) - R1024_8_rounds(10); - #endif - #if R1024_Unroll_R(11) - R1024_8_rounds(11); - #endif - #if R1024_Unroll_R(12) - R1024_8_rounds(12); - #endif - #if R1024_Unroll_R(13) - R1024_8_rounds(13); - #endif - #if R1024_Unroll_R(14) - R1024_8_rounds(14); - #endif - #if (SKEIN_UNROLL_1024 > 14) + #if R1024_Unroll_R(1) + R1024_8_rounds(1); + #endif + #if R1024_Unroll_R(2) + R1024_8_rounds(2); + #endif + #if R1024_Unroll_R(3) + R1024_8_rounds(3); + #endif + #if R1024_Unroll_R(4) + R1024_8_rounds(4); + #endif + #if R1024_Unroll_R(5) + R1024_8_rounds(5); + #endif + #if R1024_Unroll_R(6) + R1024_8_rounds(6); + #endif + #if R1024_Unroll_R(7) + R1024_8_rounds(7); + #endif + #if R1024_Unroll_R(8) + R1024_8_rounds(8); + #endif + #if R1024_Unroll_R(9) + R1024_8_rounds(9); + #endif + #if R1024_Unroll_R(10) + R1024_8_rounds(10); + #endif + #if R1024_Unroll_R(11) + R1024_8_rounds(11); + #endif + #if R1024_Unroll_R(12) + R1024_8_rounds(12); + #endif + #if R1024_Unroll_R(13) + R1024_8_rounds(13); + #endif + #if R1024_Unroll_R(14) + R1024_8_rounds(14); + #endif +#if (SKEIN_UNROLL_1024 > 14) #error "need more unrolling in Skein_1024_Process_Block" #endif - } - /* do the final "feedforward" xor, update context chaining vars */ - - ctx->X[0] = X00 ^ w[0]; - ctx->X[1] = X01 ^ w[1]; - ctx->X[2] = X02 ^ w[2]; - ctx->X[3] = X03 ^ w[3]; - ctx->X[4] = X04 ^ w[4]; - ctx->X[5] = X05 ^ w[5]; - ctx->X[6] = X06 ^ w[6]; - ctx->X[7] = X07 ^ w[7]; - ctx->X[8] = X08 ^ w[8]; - ctx->X[9] = X09 ^ w[9]; - ctx->X[10] = X10 ^ w[10]; - ctx->X[11] = X11 ^ w[11]; - ctx->X[12] = X12 ^ w[12]; - ctx->X[13] = X13 ^ w[13]; - ctx->X[14] = X14 ^ w[14]; - ctx->X[15] = X15 ^ w[15]; - - Skein_Show_Round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X); - - ts[1] &= ~SKEIN_T1_FLAG_FIRST; - blkPtr += SKEIN1024_BLOCK_BYTES; - } - while (--blkCnt); - ctx->h.T[0] = ts[0]; - ctx->h.T[1] = ts[1]; - } + } + /* do the final "feedforward" xor, update context chaining vars */ + + ctx->X[0] = X00 ^ w[0]; + ctx->X[1] = X01 ^ w[1]; + ctx->X[2] = X02 ^ w[2]; + ctx->X[3] = X03 ^ w[3]; + ctx->X[4] = X04 ^ w[4]; + ctx->X[5] = X05 ^ w[5]; + ctx->X[6] = X06 ^ w[6]; + ctx->X[7] = X07 ^ w[7]; + ctx->X[8] = X08 ^ w[8]; + ctx->X[9] = X09 ^ w[9]; + ctx->X[10] = X10 ^ w[10]; + ctx->X[11] = X11 ^ w[11]; + ctx->X[12] = X12 ^ w[12]; + ctx->X[13] = X13 ^ w[13]; + ctx->X[14] = X14 ^ w[14]; + ctx->X[15] = X15 ^ w[15]; + + Skein_Show_Round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X); + + ts[1] &= ~SKEIN_T1_FLAG_FIRST; + blkPtr += SKEIN1024_BLOCK_BYTES; + } + while (--blkCnt); + ctx->h.T[0] = ts[0]; + ctx->h.T[1] = ts[1]; +} #if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF) size_t Skein1024_Process_Block_CodeSize(void) - { - return ((u8 *) Skein1024_Process_Block_CodeSize) - - ((u8 *) Skein1024_Process_Block); - } +{ + return ((u8 *) Skein1024_Process_Block_CodeSize) - + ((u8 *) Skein1024_Process_Block); +} unsigned int Skein1024_Unroll_Cnt(void) - { - return SKEIN_UNROLL_1024; - } +{ + return SKEIN_UNROLL_1024; +} #endif #endif diff --git a/drivers/staging/skein/threefish1024Block.c b/drivers/staging/skein/threefish1024Block.c index e3be37ea8024..1730a3120a0f 100644 --- a/drivers/staging/skein/threefish1024Block.c +++ b/drivers/staging/skein/threefish1024Block.c @@ -3,1382 +3,1380 @@ void threefishEncrypt1024(struct threefish_key *keyCtx, u64 *input, u64 *output) - { - - u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3], - b4 = input[4], b5 = input[5], - b6 = input[6], b7 = input[7], - b8 = input[8], b9 = input[9], - b10 = input[10], b11 = input[11], - b12 = input[12], b13 = input[13], - b14 = input[14], b15 = input[15]; - u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1], - k2 = keyCtx->key[2], k3 = keyCtx->key[3], - k4 = keyCtx->key[4], k5 = keyCtx->key[5], - k6 = keyCtx->key[6], k7 = keyCtx->key[7], - k8 = keyCtx->key[8], k9 = keyCtx->key[9], - k10 = keyCtx->key[10], k11 = keyCtx->key[11], - k12 = keyCtx->key[12], k13 = keyCtx->key[13], - k14 = keyCtx->key[14], k15 = keyCtx->key[15], - k16 = keyCtx->key[16]; - u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], - t2 = keyCtx->tweak[2]; +{ + u64 b0 = input[0], b1 = input[1], + b2 = input[2], b3 = input[3], + b4 = input[4], b5 = input[5], + b6 = input[6], b7 = input[7], + b8 = input[8], b9 = input[9], + b10 = input[10], b11 = input[11], + b12 = input[12], b13 = input[13], + b14 = input[14], b15 = input[15]; + u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1], + k2 = keyCtx->key[2], k3 = keyCtx->key[3], + k4 = keyCtx->key[4], k5 = keyCtx->key[5], + k6 = keyCtx->key[6], k7 = keyCtx->key[7], + k8 = keyCtx->key[8], k9 = keyCtx->key[9], + k10 = keyCtx->key[10], k11 = keyCtx->key[11], + k12 = keyCtx->key[12], k13 = keyCtx->key[13], + k14 = keyCtx->key[14], k15 = keyCtx->key[15], + k16 = keyCtx->key[16]; + u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], + t2 = keyCtx->tweak[2]; - b1 += k1; b0 += b1 + k0; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - b3 += k3; b2 += b3 + k2; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - b5 += k5; b4 += b5 + k4; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - b7 += k7; b6 += b7 + k6; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - b9 += k9; b8 += b9 + k8; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - b11 += k11; b10 += b11 + k10; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - b13 += k13 + t0; b12 += b13 + k12; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - b15 += k15; b14 += b15 + k14 + t1; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - b1 += k2; b0 += b1 + k1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - b3 += k4; b2 += b3 + k3; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - b5 += k6; b4 += b5 + k5; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - b7 += k8; b6 += b7 + k7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - b9 += k10; b8 += b9 + k9; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - b11 += k12; b10 += b11 + k11; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - b13 += k14 + t1; b12 += b13 + k13; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - b15 += k16 + 1; b14 += b15 + k15 + t2; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - b1 += k3; b0 += b1 + k2; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - b3 += k5; b2 += b3 + k4; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - b5 += k7; b4 += b5 + k6; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - b7 += k9; b6 += b7 + k8; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - b9 += k11; b8 += b9 + k10; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - b11 += k13; b10 += b11 + k12; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - b13 += k15 + t2; b12 += b13 + k14; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - b15 += k0 + 2; b14 += b15 + k16 + t0; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - b1 += k4; b0 += b1 + k3; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - b3 += k6; b2 += b3 + k5; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - b5 += k8; b4 += b5 + k7; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - b7 += k10; b6 += b7 + k9; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - b9 += k12; b8 += b9 + k11; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - b11 += k14; b10 += b11 + k13; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - b13 += k16 + t0; b12 += b13 + k15; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - b15 += k1 + 3; b14 += b15 + k0 + t1; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - b1 += k5; b0 += b1 + k4; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - b3 += k7; b2 += b3 + k6; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - b5 += k9; b4 += b5 + k8; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - b7 += k11; b6 += b7 + k10; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - b9 += k13; b8 += b9 + k12; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - b11 += k15; b10 += b11 + k14; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - b13 += k0 + t1; b12 += b13 + k16; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - b15 += k2 + 4; b14 += b15 + k1 + t2; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - b1 += k6; b0 += b1 + k5; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - b3 += k8; b2 += b3 + k7; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - b5 += k10; b4 += b5 + k9; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - b7 += k12; b6 += b7 + k11; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - b9 += k14; b8 += b9 + k13; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - b11 += k16; b10 += b11 + k15; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - b13 += k1 + t2; b12 += b13 + k0; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - b15 += k3 + 5; b14 += b15 + k2 + t0; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - b1 += k7; b0 += b1 + k6; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - b3 += k9; b2 += b3 + k8; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - b5 += k11; b4 += b5 + k10; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - b7 += k13; b6 += b7 + k12; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - b9 += k15; b8 += b9 + k14; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - b11 += k0; b10 += b11 + k16; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - b13 += k2 + t0; b12 += b13 + k1; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - b15 += k4 + 6; b14 += b15 + k3 + t1; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - b1 += k8; b0 += b1 + k7; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - b3 += k10; b2 += b3 + k9; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - b5 += k12; b4 += b5 + k11; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - b7 += k14; b6 += b7 + k13; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - b9 += k16; b8 += b9 + k15; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - b11 += k1; b10 += b11 + k0; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - b13 += k3 + t1; b12 += b13 + k2; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - b15 += k5 + 7; b14 += b15 + k4 + t2; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - b1 += k9; b0 += b1 + k8; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - b3 += k11; b2 += b3 + k10; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - b5 += k13; b4 += b5 + k12; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - b7 += k15; b6 += b7 + k14; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - b9 += k0; b8 += b9 + k16; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - b11 += k2; b10 += b11 + k1; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - b13 += k4 + t2; b12 += b13 + k3; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - b15 += k6 + 8; b14 += b15 + k5 + t0; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - b1 += k10; b0 += b1 + k9; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - b3 += k12; b2 += b3 + k11; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - b5 += k14; b4 += b5 + k13; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - b7 += k16; b6 += b7 + k15; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - b9 += k1; b8 += b9 + k0; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - b11 += k3; b10 += b11 + k2; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - b13 += k5 + t0; b12 += b13 + k4; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - b15 += k7 + 9; b14 += b15 + k6 + t1; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - b1 += k11; b0 += b1 + k10; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - b3 += k13; b2 += b3 + k12; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - b5 += k15; b4 += b5 + k14; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - b7 += k0; b6 += b7 + k16; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - b9 += k2; b8 += b9 + k1; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - b11 += k4; b10 += b11 + k3; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - b13 += k6 + t1; b12 += b13 + k5; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - b15 += k8 + 10; b14 += b15 + k7 + t2; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - b1 += k12; b0 += b1 + k11; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - b3 += k14; b2 += b3 + k13; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - b5 += k16; b4 += b5 + k15; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - b7 += k1; b6 += b7 + k0; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - b9 += k3; b8 += b9 + k2; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - b11 += k5; b10 += b11 + k4; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - b13 += k7 + t2; b12 += b13 + k6; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - b15 += k9 + 11; b14 += b15 + k8 + t0; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - b1 += k13; b0 += b1 + k12; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - b3 += k15; b2 += b3 + k14; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - b5 += k0; b4 += b5 + k16; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - b7 += k2; b6 += b7 + k1; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - b9 += k4; b8 += b9 + k3; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - b11 += k6; b10 += b11 + k5; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - b13 += k8 + t0; b12 += b13 + k7; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - b15 += k10 + 12; b14 += b15 + k9 + t1; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - b1 += k14; b0 += b1 + k13; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - b3 += k16; b2 += b3 + k15; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - b5 += k1; b4 += b5 + k0; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - b7 += k3; b6 += b7 + k2; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - b9 += k5; b8 += b9 + k4; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - b11 += k7; b10 += b11 + k6; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - b13 += k9 + t1; b12 += b13 + k8; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - b15 += k11 + 13; b14 += b15 + k10 + t2; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - b1 += k15; b0 += b1 + k14; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - b3 += k0; b2 += b3 + k16; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - b5 += k2; b4 += b5 + k1; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - b7 += k4; b6 += b7 + k3; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - b9 += k6; b8 += b9 + k5; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - b11 += k8; b10 += b11 + k7; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - b13 += k10 + t2; b12 += b13 + k9; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - b15 += k12 + 14; b14 += b15 + k11 + t0; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - b1 += k16; b0 += b1 + k15; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - b3 += k1; b2 += b3 + k0; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - b5 += k3; b4 += b5 + k2; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - b7 += k5; b6 += b7 + k4; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - b9 += k7; b8 += b9 + k6; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - b11 += k9; b10 += b11 + k8; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - b13 += k11 + t0; b12 += b13 + k10; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - b15 += k13 + 15; b14 += b15 + k12 + t1; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - b1 += k0; b0 += b1 + k16; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - b3 += k2; b2 += b3 + k1; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - b5 += k4; b4 += b5 + k3; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - b7 += k6; b6 += b7 + k5; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - b9 += k8; b8 += b9 + k7; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - b11 += k10; b10 += b11 + k9; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - b13 += k12 + t1; b12 += b13 + k11; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - b15 += k14 + 16; b14 += b15 + k13 + t2; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - b1 += k1; b0 += b1 + k0; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - b3 += k3; b2 += b3 + k2; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - b5 += k5; b4 += b5 + k4; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - b7 += k7; b6 += b7 + k6; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - b9 += k9; b8 += b9 + k8; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - b11 += k11; b10 += b11 + k10; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - b13 += k13 + t2; b12 += b13 + k12; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - b15 += k15 + 17; b14 += b15 + k14 + t0; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - b1 += k2; b0 += b1 + k1; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - b3 += k4; b2 += b3 + k3; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - b5 += k6; b4 += b5 + k5; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - b7 += k8; b6 += b7 + k7; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - b9 += k10; b8 += b9 + k9; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - b11 += k12; b10 += b11 + k11; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - b13 += k14 + t0; b12 += b13 + k13; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - b15 += k16 + 18; b14 += b15 + k15 + t1; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - b1 += k3; b0 += b1 + k2; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - b3 += k5; b2 += b3 + k4; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - b5 += k7; b4 += b5 + k6; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - b7 += k9; b6 += b7 + k8; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - b9 += k11; b8 += b9 + k10; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - b11 += k13; b10 += b11 + k12; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - b13 += k15 + t1; b12 += b13 + k14; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - b15 += k0 + 19; b14 += b15 + k16 + t2; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + b1 += k1; b0 += b1 + k0; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + b3 += k3; b2 += b3 + k2; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + b5 += k5; b4 += b5 + k4; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + b7 += k7; b6 += b7 + k6; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + b9 += k9; b8 += b9 + k8; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + b11 += k11; b10 += b11 + k10; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + b13 += k13 + t0; b12 += b13 + k12; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + b15 += k15; b14 += b15 + k14 + t1; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + b1 += k2; b0 += b1 + k1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + b3 += k4; b2 += b3 + k3; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + b5 += k6; b4 += b5 + k5; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + b7 += k8; b6 += b7 + k7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + b9 += k10; b8 += b9 + k9; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + b11 += k12; b10 += b11 + k11; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + b13 += k14 + t1; b12 += b13 + k13; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + b15 += k16 + 1; b14 += b15 + k15 + t2; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + b1 += k3; b0 += b1 + k2; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + b3 += k5; b2 += b3 + k4; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + b5 += k7; b4 += b5 + k6; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + b7 += k9; b6 += b7 + k8; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + b9 += k11; b8 += b9 + k10; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + b11 += k13; b10 += b11 + k12; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + b13 += k15 + t2; b12 += b13 + k14; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + b15 += k0 + 2; b14 += b15 + k16 + t0; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + b1 += k4; b0 += b1 + k3; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + b3 += k6; b2 += b3 + k5; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + b5 += k8; b4 += b5 + k7; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + b7 += k10; b6 += b7 + k9; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + b9 += k12; b8 += b9 + k11; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + b11 += k14; b10 += b11 + k13; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + b13 += k16 + t0; b12 += b13 + k15; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + b15 += k1 + 3; b14 += b15 + k0 + t1; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + b1 += k5; b0 += b1 + k4; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + b3 += k7; b2 += b3 + k6; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + b5 += k9; b4 += b5 + k8; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + b7 += k11; b6 += b7 + k10; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + b9 += k13; b8 += b9 + k12; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + b11 += k15; b10 += b11 + k14; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + b13 += k0 + t1; b12 += b13 + k16; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + b15 += k2 + 4; b14 += b15 + k1 + t2; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + b1 += k6; b0 += b1 + k5; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + b3 += k8; b2 += b3 + k7; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + b5 += k10; b4 += b5 + k9; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + b7 += k12; b6 += b7 + k11; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + b9 += k14; b8 += b9 + k13; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + b11 += k16; b10 += b11 + k15; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + b13 += k1 + t2; b12 += b13 + k0; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + b15 += k3 + 5; b14 += b15 + k2 + t0; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + b1 += k7; b0 += b1 + k6; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + b3 += k9; b2 += b3 + k8; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + b5 += k11; b4 += b5 + k10; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + b7 += k13; b6 += b7 + k12; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + b9 += k15; b8 += b9 + k14; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + b11 += k0; b10 += b11 + k16; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + b13 += k2 + t0; b12 += b13 + k1; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + b15 += k4 + 6; b14 += b15 + k3 + t1; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + b1 += k8; b0 += b1 + k7; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + b3 += k10; b2 += b3 + k9; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + b5 += k12; b4 += b5 + k11; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + b7 += k14; b6 += b7 + k13; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + b9 += k16; b8 += b9 + k15; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + b11 += k1; b10 += b11 + k0; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + b13 += k3 + t1; b12 += b13 + k2; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + b15 += k5 + 7; b14 += b15 + k4 + t2; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + b1 += k9; b0 += b1 + k8; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + b3 += k11; b2 += b3 + k10; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + b5 += k13; b4 += b5 + k12; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + b7 += k15; b6 += b7 + k14; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + b9 += k0; b8 += b9 + k16; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + b11 += k2; b10 += b11 + k1; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + b13 += k4 + t2; b12 += b13 + k3; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + b15 += k6 + 8; b14 += b15 + k5 + t0; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + b1 += k10; b0 += b1 + k9; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + b3 += k12; b2 += b3 + k11; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + b5 += k14; b4 += b5 + k13; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + b7 += k16; b6 += b7 + k15; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + b9 += k1; b8 += b9 + k0; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + b11 += k3; b10 += b11 + k2; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + b13 += k5 + t0; b12 += b13 + k4; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + b15 += k7 + 9; b14 += b15 + k6 + t1; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + b1 += k11; b0 += b1 + k10; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + b3 += k13; b2 += b3 + k12; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + b5 += k15; b4 += b5 + k14; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + b7 += k0; b6 += b7 + k16; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + b9 += k2; b8 += b9 + k1; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + b11 += k4; b10 += b11 + k3; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + b13 += k6 + t1; b12 += b13 + k5; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + b15 += k8 + 10; b14 += b15 + k7 + t2; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + b1 += k12; b0 += b1 + k11; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + b3 += k14; b2 += b3 + k13; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + b5 += k16; b4 += b5 + k15; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + b7 += k1; b6 += b7 + k0; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + b9 += k3; b8 += b9 + k2; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + b11 += k5; b10 += b11 + k4; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + b13 += k7 + t2; b12 += b13 + k6; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + b15 += k9 + 11; b14 += b15 + k8 + t0; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + b1 += k13; b0 += b1 + k12; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + b3 += k15; b2 += b3 + k14; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + b5 += k0; b4 += b5 + k16; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + b7 += k2; b6 += b7 + k1; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + b9 += k4; b8 += b9 + k3; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + b11 += k6; b10 += b11 + k5; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + b13 += k8 + t0; b12 += b13 + k7; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + b15 += k10 + 12; b14 += b15 + k9 + t1; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + b1 += k14; b0 += b1 + k13; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + b3 += k16; b2 += b3 + k15; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + b5 += k1; b4 += b5 + k0; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + b7 += k3; b6 += b7 + k2; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + b9 += k5; b8 += b9 + k4; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + b11 += k7; b10 += b11 + k6; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + b13 += k9 + t1; b12 += b13 + k8; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + b15 += k11 + 13; b14 += b15 + k10 + t2; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + b1 += k15; b0 += b1 + k14; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + b3 += k0; b2 += b3 + k16; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + b5 += k2; b4 += b5 + k1; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + b7 += k4; b6 += b7 + k3; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + b9 += k6; b8 += b9 + k5; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + b11 += k8; b10 += b11 + k7; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + b13 += k10 + t2; b12 += b13 + k9; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + b15 += k12 + 14; b14 += b15 + k11 + t0; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + b1 += k16; b0 += b1 + k15; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + b3 += k1; b2 += b3 + k0; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + b5 += k3; b4 += b5 + k2; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + b7 += k5; b6 += b7 + k4; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + b9 += k7; b8 += b9 + k6; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + b11 += k9; b10 += b11 + k8; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + b13 += k11 + t0; b12 += b13 + k10; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + b15 += k13 + 15; b14 += b15 + k12 + t1; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + b1 += k0; b0 += b1 + k16; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + b3 += k2; b2 += b3 + k1; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + b5 += k4; b4 += b5 + k3; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + b7 += k6; b6 += b7 + k5; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + b9 += k8; b8 += b9 + k7; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + b11 += k10; b10 += b11 + k9; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + b13 += k12 + t1; b12 += b13 + k11; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + b15 += k14 + 16; b14 += b15 + k13 + t2; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + b1 += k1; b0 += b1 + k0; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + b3 += k3; b2 += b3 + k2; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + b5 += k5; b4 += b5 + k4; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + b7 += k7; b6 += b7 + k6; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + b9 += k9; b8 += b9 + k8; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + b11 += k11; b10 += b11 + k10; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + b13 += k13 + t2; b12 += b13 + k12; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + b15 += k15 + 17; b14 += b15 + k14 + t0; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + b1 += k2; b0 += b1 + k1; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + b3 += k4; b2 += b3 + k3; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + b5 += k6; b4 += b5 + k5; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + b7 += k8; b6 += b7 + k7; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + b9 += k10; b8 += b9 + k9; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + b11 += k12; b10 += b11 + k11; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + b13 += k14 + t0; b12 += b13 + k13; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + b15 += k16 + 18; b14 += b15 + k15 + t1; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + b1 += k3; b0 += b1 + k2; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + b3 += k5; b2 += b3 + k4; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + b5 += k7; b4 += b5 + k6; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + b7 += k9; b6 += b7 + k8; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + b9 += k11; b8 += b9 + k10; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + b11 += k13; b10 += b11 + k12; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + b13 += k15 + t1; b12 += b13 + k14; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + b15 += k0 + 19; b14 += b15 + k16 + t2; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - output[0] = b0 + k3; - output[1] = b1 + k4; - output[2] = b2 + k5; - output[3] = b3 + k6; - output[4] = b4 + k7; - output[5] = b5 + k8; - output[6] = b6 + k9; - output[7] = b7 + k10; - output[8] = b8 + k11; - output[9] = b9 + k12; - output[10] = b10 + k13; - output[11] = b11 + k14; - output[12] = b12 + k15; - output[13] = b13 + k16 + t2; - output[14] = b14 + k0 + t0; - output[15] = b15 + k1 + 20; - } + output[0] = b0 + k3; + output[1] = b1 + k4; + output[2] = b2 + k5; + output[3] = b3 + k6; + output[4] = b4 + k7; + output[5] = b5 + k8; + output[6] = b6 + k9; + output[7] = b7 + k10; + output[8] = b8 + k11; + output[9] = b9 + k12; + output[10] = b10 + k13; + output[11] = b11 + k14; + output[12] = b12 + k15; + output[13] = b13 + k16 + t2; + output[14] = b14 + k0 + t0; + output[15] = b15 + k1 + 20; +} void threefishDecrypt1024(struct threefish_key *keyCtx, u64 *input, u64 *output) { + u64 b0 = input[0], b1 = input[1], + b2 = input[2], b3 = input[3], + b4 = input[4], b5 = input[5], + b6 = input[6], b7 = input[7], + b8 = input[8], b9 = input[9], + b10 = input[10], b11 = input[11], + b12 = input[12], b13 = input[13], + b14 = input[14], b15 = input[15]; + u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1], + k2 = keyCtx->key[2], k3 = keyCtx->key[3], + k4 = keyCtx->key[4], k5 = keyCtx->key[5], + k6 = keyCtx->key[6], k7 = keyCtx->key[7], + k8 = keyCtx->key[8], k9 = keyCtx->key[9], + k10 = keyCtx->key[10], k11 = keyCtx->key[11], + k12 = keyCtx->key[12], k13 = keyCtx->key[13], + k14 = keyCtx->key[14], k15 = keyCtx->key[15], + k16 = keyCtx->key[16]; + u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], + t2 = keyCtx->tweak[2]; + u64 tmp; - u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3], - b4 = input[4], b5 = input[5], - b6 = input[6], b7 = input[7], - b8 = input[8], b9 = input[9], - b10 = input[10], b11 = input[11], - b12 = input[12], b13 = input[13], - b14 = input[14], b15 = input[15]; - u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1], - k2 = keyCtx->key[2], k3 = keyCtx->key[3], - k4 = keyCtx->key[4], k5 = keyCtx->key[5], - k6 = keyCtx->key[6], k7 = keyCtx->key[7], - k8 = keyCtx->key[8], k9 = keyCtx->key[9], - k10 = keyCtx->key[10], k11 = keyCtx->key[11], - k12 = keyCtx->key[12], k13 = keyCtx->key[13], - k14 = keyCtx->key[14], k15 = keyCtx->key[15], - k16 = keyCtx->key[16]; - u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], - t2 = keyCtx->tweak[2]; - u64 tmp; - - b0 -= k3; - b1 -= k4; - b2 -= k5; - b3 -= k6; - b4 -= k7; - b5 -= k8; - b6 -= k9; - b7 -= k10; - b8 -= k11; - b9 -= k12; - b10 -= k13; - b11 -= k14; - b12 -= k15; - b13 -= k16 + t2; - b14 -= k0 + t0; - b15 -= k1 + 20; - tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k16 + t2; b15 -= k0 + 19; - tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k14; b13 -= k15 + t1; - tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k12; b11 -= k13; - tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k10; b9 -= k11; - tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k8; b7 -= k9; - tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k6; b5 -= k7; - tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k4; b3 -= k5; - tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k2; b1 -= k3; - tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k15 + t1; b15 -= k16 + 18; - tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k13; b13 -= k14 + t0; - tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k11; b11 -= k12; - tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k9; b9 -= k10; - tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k7; b7 -= k8; - tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k5; b5 -= k6; - tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k3; b3 -= k4; - tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k1; b1 -= k2; - tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k14 + t0; b15 -= k15 + 17; - tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k12; b13 -= k13 + t2; - tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k10; b11 -= k11; - tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k8; b9 -= k9; - tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k6; b7 -= k7; - tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k4; b5 -= k5; - tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k2; b3 -= k3; - tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k0; b1 -= k1; - tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k13 + t2; b15 -= k14 + 16; - tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k11; b13 -= k12 + t1; - tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k9; b11 -= k10; - tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k7; b9 -= k8; - tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k5; b7 -= k6; - tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k3; b5 -= k4; - tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k1; b3 -= k2; - tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k16; b1 -= k0; - tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k12 + t1; b15 -= k13 + 15; - tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k10; b13 -= k11 + t0; - tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k8; b11 -= k9; - tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k6; b9 -= k7; - tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k4; b7 -= k5; - tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k2; b5 -= k3; - tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k0; b3 -= k1; - tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k15; b1 -= k16; - tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k11 + t0; b15 -= k12 + 14; - tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k9; b13 -= k10 + t2; - tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k7; b11 -= k8; - tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k5; b9 -= k6; - tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k3; b7 -= k4; - tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k1; b5 -= k2; - tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k16; b3 -= k0; - tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k14; b1 -= k15; - tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k10 + t2; b15 -= k11 + 13; - tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k8; b13 -= k9 + t1; - tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k6; b11 -= k7; - tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k4; b9 -= k5; - tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k2; b7 -= k3; - tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k0; b5 -= k1; - tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k15; b3 -= k16; - tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k13; b1 -= k14; - tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k9 + t1; b15 -= k10 + 12; - tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k7; b13 -= k8 + t0; - tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k5; b11 -= k6; - tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k3; b9 -= k4; - tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k1; b7 -= k2; - tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k16; b5 -= k0; - tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k14; b3 -= k15; - tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k12; b1 -= k13; - tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k8 + t0; b15 -= k9 + 11; - tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k6; b13 -= k7 + t2; - tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k4; b11 -= k5; - tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k2; b9 -= k3; - tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k0; b7 -= k1; - tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k15; b5 -= k16; - tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k13; b3 -= k14; - tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k11; b1 -= k12; - tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k7 + t2; b15 -= k8 + 10; - tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k5; b13 -= k6 + t1; - tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k3; b11 -= k4; - tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k1; b9 -= k2; - tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k16; b7 -= k0; - tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k14; b5 -= k15; - tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k12; b3 -= k13; - tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k10; b1 -= k11; - tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k6 + t1; b15 -= k7 + 9; - tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k4; b13 -= k5 + t0; - tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k2; b11 -= k3; - tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k0; b9 -= k1; - tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k15; b7 -= k16; - tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k13; b5 -= k14; - tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k11; b3 -= k12; - tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k9; b1 -= k10; - tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k5 + t0; b15 -= k6 + 8; - tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k3; b13 -= k4 + t2; - tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k1; b11 -= k2; - tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k16; b9 -= k0; - tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k14; b7 -= k15; - tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k12; b5 -= k13; - tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k10; b3 -= k11; - tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k8; b1 -= k9; - tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k4 + t2; b15 -= k5 + 7; - tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k2; b13 -= k3 + t1; - tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k0; b11 -= k1; - tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k15; b9 -= k16; - tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k13; b7 -= k14; - tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k11; b5 -= k12; - tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k9; b3 -= k10; - tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k7; b1 -= k8; - tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k3 + t1; b15 -= k4 + 6; - tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k1; b13 -= k2 + t0; - tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k16; b11 -= k0; - tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k14; b9 -= k15; - tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k12; b7 -= k13; - tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k10; b5 -= k11; - tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k8; b3 -= k9; - tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k6; b1 -= k7; - tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k2 + t0; b15 -= k3 + 5; - tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k0; b13 -= k1 + t2; - tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k15; b11 -= k16; - tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k13; b9 -= k14; - tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k11; b7 -= k12; - tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k9; b5 -= k10; - tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k7; b3 -= k8; - tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k5; b1 -= k6; - tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k1 + t2; b15 -= k2 + 4; - tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k16; b13 -= k0 + t1; - tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k14; b11 -= k15; - tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k12; b9 -= k13; - tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k10; b7 -= k11; - tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k8; b5 -= k9; - tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k6; b3 -= k7; - tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k4; b1 -= k5; - tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k0 + t1; b15 -= k1 + 3; - tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k15; b13 -= k16 + t0; - tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k13; b11 -= k14; - tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k11; b9 -= k12; - tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k9; b7 -= k10; - tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k7; b5 -= k8; - tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k5; b3 -= k6; - tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k3; b1 -= k4; - tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k16 + t0; b15 -= k0 + 2; - tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k14; b13 -= k15 + t2; - tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k12; b11 -= k13; - tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k10; b9 -= k11; - tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k8; b7 -= k9; - tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k6; b5 -= k7; - tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k4; b3 -= k5; - tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k2; b1 -= k3; - tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k15 + t2; b15 -= k16 + 1; - tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k13; b13 -= k14 + t1; - tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k11; b11 -= k12; - tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k9; b9 -= k10; - tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k7; b7 -= k8; - tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k5; b5 -= k6; - tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k3; b3 -= k4; - tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k1; b1 -= k2; - tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k14 + t1; b15 -= k15; - tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k12; b13 -= k13 + t0; - tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k10; b11 -= k11; - tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k8; b9 -= k9; - tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k6; b7 -= k7; - tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k4; b5 -= k5; - tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k2; b3 -= k3; - tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k0; b1 -= k1; + b0 -= k3; + b1 -= k4; + b2 -= k5; + b3 -= k6; + b4 -= k7; + b5 -= k8; + b6 -= k9; + b7 -= k10; + b8 -= k11; + b9 -= k12; + b10 -= k13; + b11 -= k14; + b12 -= k15; + b13 -= k16 + t2; + b14 -= k0 + t0; + b15 -= k1 + 20; + tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k16 + t2; b15 -= k0 + 19; + tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k14; b13 -= k15 + t1; + tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k12; b11 -= k13; + tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k10; b9 -= k11; + tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k8; b7 -= k9; + tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k6; b5 -= k7; + tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k4; b3 -= k5; + tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k2; b1 -= k3; + tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k15 + t1; b15 -= k16 + 18; + tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k13; b13 -= k14 + t0; + tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k11; b11 -= k12; + tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k9; b9 -= k10; + tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k7; b7 -= k8; + tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k5; b5 -= k6; + tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k3; b3 -= k4; + tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k1; b1 -= k2; + tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k14 + t0; b15 -= k15 + 17; + tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k12; b13 -= k13 + t2; + tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k10; b11 -= k11; + tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k8; b9 -= k9; + tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k6; b7 -= k7; + tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k4; b5 -= k5; + tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k2; b3 -= k3; + tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k0; b1 -= k1; + tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k13 + t2; b15 -= k14 + 16; + tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k11; b13 -= k12 + t1; + tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k9; b11 -= k10; + tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k7; b9 -= k8; + tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k5; b7 -= k6; + tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k3; b5 -= k4; + tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k1; b3 -= k2; + tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k16; b1 -= k0; + tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k12 + t1; b15 -= k13 + 15; + tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k10; b13 -= k11 + t0; + tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k8; b11 -= k9; + tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k6; b9 -= k7; + tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k4; b7 -= k5; + tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k2; b5 -= k3; + tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k0; b3 -= k1; + tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k15; b1 -= k16; + tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k11 + t0; b15 -= k12 + 14; + tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k9; b13 -= k10 + t2; + tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k7; b11 -= k8; + tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k5; b9 -= k6; + tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k3; b7 -= k4; + tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k1; b5 -= k2; + tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k16; b3 -= k0; + tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k14; b1 -= k15; + tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k10 + t2; b15 -= k11 + 13; + tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k8; b13 -= k9 + t1; + tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k6; b11 -= k7; + tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k4; b9 -= k5; + tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k2; b7 -= k3; + tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k0; b5 -= k1; + tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k15; b3 -= k16; + tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k13; b1 -= k14; + tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k9 + t1; b15 -= k10 + 12; + tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k7; b13 -= k8 + t0; + tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k5; b11 -= k6; + tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k3; b9 -= k4; + tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k1; b7 -= k2; + tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k16; b5 -= k0; + tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k14; b3 -= k15; + tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k12; b1 -= k13; + tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k8 + t0; b15 -= k9 + 11; + tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k6; b13 -= k7 + t2; + tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k4; b11 -= k5; + tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k2; b9 -= k3; + tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k0; b7 -= k1; + tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k15; b5 -= k16; + tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k13; b3 -= k14; + tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k11; b1 -= k12; + tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k7 + t2; b15 -= k8 + 10; + tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k5; b13 -= k6 + t1; + tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k3; b11 -= k4; + tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k1; b9 -= k2; + tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k16; b7 -= k0; + tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k14; b5 -= k15; + tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k12; b3 -= k13; + tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k10; b1 -= k11; + tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k6 + t1; b15 -= k7 + 9; + tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k4; b13 -= k5 + t0; + tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k2; b11 -= k3; + tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k0; b9 -= k1; + tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k15; b7 -= k16; + tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k13; b5 -= k14; + tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k11; b3 -= k12; + tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k9; b1 -= k10; + tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k5 + t0; b15 -= k6 + 8; + tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k3; b13 -= k4 + t2; + tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k1; b11 -= k2; + tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k16; b9 -= k0; + tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k14; b7 -= k15; + tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k12; b5 -= k13; + tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k10; b3 -= k11; + tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k8; b1 -= k9; + tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k4 + t2; b15 -= k5 + 7; + tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k2; b13 -= k3 + t1; + tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k0; b11 -= k1; + tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k15; b9 -= k16; + tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k13; b7 -= k14; + tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k11; b5 -= k12; + tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k9; b3 -= k10; + tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k7; b1 -= k8; + tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k3 + t1; b15 -= k4 + 6; + tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k1; b13 -= k2 + t0; + tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k16; b11 -= k0; + tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k14; b9 -= k15; + tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k12; b7 -= k13; + tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k10; b5 -= k11; + tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k8; b3 -= k9; + tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k6; b1 -= k7; + tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k2 + t0; b15 -= k3 + 5; + tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k0; b13 -= k1 + t2; + tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k15; b11 -= k16; + tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k13; b9 -= k14; + tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k11; b7 -= k12; + tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k9; b5 -= k10; + tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k7; b3 -= k8; + tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k5; b1 -= k6; + tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k1 + t2; b15 -= k2 + 4; + tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k16; b13 -= k0 + t1; + tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k14; b11 -= k15; + tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k12; b9 -= k13; + tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k10; b7 -= k11; + tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k8; b5 -= k9; + tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k6; b3 -= k7; + tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k4; b1 -= k5; + tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k0 + t1; b15 -= k1 + 3; + tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k15; b13 -= k16 + t0; + tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k13; b11 -= k14; + tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k11; b9 -= k12; + tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k9; b7 -= k10; + tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k7; b5 -= k8; + tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k5; b3 -= k6; + tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k3; b1 -= k4; + tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k16 + t0; b15 -= k0 + 2; + tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k14; b13 -= k15 + t2; + tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k12; b11 -= k13; + tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k10; b9 -= k11; + tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k8; b7 -= k9; + tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k6; b5 -= k7; + tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k4; b3 -= k5; + tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k2; b1 -= k3; + tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k15 + t2; b15 -= k16 + 1; + tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k13; b13 -= k14 + t1; + tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k11; b11 -= k12; + tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k9; b9 -= k10; + tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k7; b7 -= k8; + tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k5; b5 -= k6; + tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k3; b3 -= k4; + tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k1; b1 -= k2; + tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; + tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; + tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; + tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; + tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; + tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; + tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; + tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; + tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; + tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; + tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; + tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; + tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; + tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; + tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; + tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; + tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; + tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; + tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; + tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; + tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; + tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; + tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k14 + t1; b15 -= k15; + tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k12; b13 -= k13 + t0; + tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k10; b11 -= k11; + tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k8; b9 -= k9; + tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k6; b7 -= k7; + tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k4; b5 -= k5; + tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k2; b3 -= k3; + tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k0; b1 -= k1; - output[15] = b15; - output[14] = b14; - output[13] = b13; - output[12] = b12; - output[11] = b11; - output[10] = b10; - output[9] = b9; - output[8] = b8; - output[7] = b7; - output[6] = b6; - output[5] = b5; - output[4] = b4; - output[3] = b3; - output[2] = b2; - output[1] = b1; - output[0] = b0; + output[15] = b15; + output[14] = b14; + output[13] = b13; + output[12] = b12; + output[11] = b11; + output[10] = b10; + output[9] = b9; + output[8] = b8; + output[7] = b7; + output[6] = b6; + output[5] = b5; + output[4] = b4; + output[3] = b3; + output[2] = b2; + output[1] = b1; + output[0] = b0; } diff --git a/drivers/staging/skein/threefish256Block.c b/drivers/staging/skein/threefish256Block.c index 09ea5099bc76..da3b8357e47f 100644 --- a/drivers/staging/skein/threefish256Block.c +++ b/drivers/staging/skein/threefish256Block.c @@ -3,346 +3,345 @@ void threefishEncrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output) - { +{ + u64 b0 = input[0], b1 = input[1], + b2 = input[2], b3 = input[3]; + u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1], + k2 = keyCtx->key[2], k3 = keyCtx->key[3], + k4 = keyCtx->key[4]; + u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], + t2 = keyCtx->tweak[2]; - u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3]; - u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1], - k2 = keyCtx->key[2], k3 = keyCtx->key[3], - k4 = keyCtx->key[4]; - u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], - t2 = keyCtx->tweak[2]; + b1 += k1 + t0; b0 += b1 + k0; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + b3 += k3; b2 += b3 + k2 + t1; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + b1 += k2 + t1; b0 += b1 + k1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + b3 += k4 + 1; b2 += b3 + k3 + t2; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - b1 += k1 + t0; b0 += b1 + k0; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - b3 += k3; b2 += b3 + k2 + t1; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - b1 += k2 + t1; b0 += b1 + k1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - b3 += k4 + 1; b2 += b3 + k3 + t2; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + b1 += k3 + t2; b0 += b1 + k2; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + b3 += k0 + 2; b2 += b3 + k4 + t0; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + b1 += k4 + t0; b0 += b1 + k3; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + b3 += k1 + 3; b2 += b3 + k0 + t1; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - b1 += k3 + t2; b0 += b1 + k2; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - b3 += k0 + 2; b2 += b3 + k4 + t0; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - b1 += k4 + t0; b0 += b1 + k3; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - b3 += k1 + 3; b2 += b3 + k0 + t1; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + b1 += k0 + t1; b0 += b1 + k4; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + b3 += k2 + 4; b2 += b3 + k1 + t2; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + b1 += k1 + t2; b0 += b1 + k0; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + b3 += k3 + 5; b2 += b3 + k2 + t0; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - b1 += k0 + t1; b0 += b1 + k4; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - b3 += k2 + 4; b2 += b3 + k1 + t2; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - b1 += k1 + t2; b0 += b1 + k0; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - b3 += k3 + 5; b2 += b3 + k2 + t0; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + b1 += k2 + t0; b0 += b1 + k1; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + b3 += k4 + 6; b2 += b3 + k3 + t1; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + b1 += k3 + t1; b0 += b1 + k2; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + b3 += k0 + 7; b2 += b3 + k4 + t2; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - b1 += k2 + t0; b0 += b1 + k1; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - b3 += k4 + 6; b2 += b3 + k3 + t1; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - b1 += k3 + t1; b0 += b1 + k2; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - b3 += k0 + 7; b2 += b3 + k4 + t2; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + b1 += k4 + t2; b0 += b1 + k3; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + b3 += k1 + 8; b2 += b3 + k0 + t0; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + b1 += k0 + t0; b0 += b1 + k4; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + b3 += k2 + 9; b2 += b3 + k1 + t1; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - b1 += k4 + t2; b0 += b1 + k3; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - b3 += k1 + 8; b2 += b3 + k0 + t0; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - b1 += k0 + t0; b0 += b1 + k4; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - b3 += k2 + 9; b2 += b3 + k1 + t1; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + b1 += k1 + t1; b0 += b1 + k0; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + b3 += k3 + 10; b2 += b3 + k2 + t2; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + b1 += k2 + t2; b0 += b1 + k1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + b3 += k4 + 11; b2 += b3 + k3 + t0; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - b1 += k1 + t1; b0 += b1 + k0; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - b3 += k3 + 10; b2 += b3 + k2 + t2; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - b1 += k2 + t2; b0 += b1 + k1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - b3 += k4 + 11; b2 += b3 + k3 + t0; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + b1 += k3 + t0; b0 += b1 + k2; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + b3 += k0 + 12; b2 += b3 + k4 + t1; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + b1 += k4 + t1; b0 += b1 + k3; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + b3 += k1 + 13; b2 += b3 + k0 + t2; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - b1 += k3 + t0; b0 += b1 + k2; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - b3 += k0 + 12; b2 += b3 + k4 + t1; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - b1 += k4 + t1; b0 += b1 + k3; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - b3 += k1 + 13; b2 += b3 + k0 + t2; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + b1 += k0 + t2; b0 += b1 + k4; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + b3 += k2 + 14; b2 += b3 + k1 + t0; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + b1 += k1 + t0; b0 += b1 + k0; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + b3 += k3 + 15; b2 += b3 + k2 + t1; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - b1 += k0 + t2; b0 += b1 + k4; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - b3 += k2 + 14; b2 += b3 + k1 + t0; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - b1 += k1 + t0; b0 += b1 + k0; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - b3 += k3 + 15; b2 += b3 + k2 + t1; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + b1 += k2 + t1; b0 += b1 + k1; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + b3 += k4 + 16; b2 += b3 + k3 + t2; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + b1 += k3 + t2; b0 += b1 + k2; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + b3 += k0 + 17; b2 += b3 + k4 + t0; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - b1 += k2 + t1; b0 += b1 + k1; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - b3 += k4 + 16; b2 += b3 + k3 + t2; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - b1 += k3 + t2; b0 += b1 + k2; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - b3 += k0 + 17; b2 += b3 + k4 + t0; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - - output[0] = b0 + k3; - output[1] = b1 + k4 + t0; - output[2] = b2 + k0 + t1; - output[3] = b3 + k1 + 18; - } + output[0] = b0 + k3; + output[1] = b1 + k4 + t0; + output[2] = b2 + k0 + t1; + output[3] = b3 + k1 + 18; +} void threefishDecrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output) - { - u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3]; - u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1], - k2 = keyCtx->key[2], k3 = keyCtx->key[3], - k4 = keyCtx->key[4]; - u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], - t2 = keyCtx->tweak[2]; +{ + u64 b0 = input[0], b1 = input[1], + b2 = input[2], b3 = input[3]; + u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1], + k2 = keyCtx->key[2], k3 = keyCtx->key[3], + k4 = keyCtx->key[4]; + u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], + t2 = keyCtx->tweak[2]; - u64 tmp; + u64 tmp; - b0 -= k3; - b1 -= k4 + t0; - b2 -= k0 + t1; - b3 -= k1 + 18; - tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k2; b1 -= k3 + t2; - tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k4 + t0; b3 -= k0 + 17; - tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k1; b1 -= k2 + t1; - tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k3 + t2; b3 -= k4 + 16; + b0 -= k3; + b1 -= k4 + t0; + b2 -= k0 + t1; + b3 -= k1 + 18; + tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k2; b1 -= k3 + t2; + tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k4 + t0; b3 -= k0 + 17; + tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k1; b1 -= k2 + t1; + tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k3 + t2; b3 -= k4 + 16; - tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k0; b1 -= k1 + t0; - tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k2 + t1; b3 -= k3 + 15; - tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k4; b1 -= k0 + t2; - tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k1 + t0; b3 -= k2 + 14; + tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k0; b1 -= k1 + t0; + tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k2 + t1; b3 -= k3 + 15; + tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k4; b1 -= k0 + t2; + tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k1 + t0; b3 -= k2 + 14; - tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k3; b1 -= k4 + t1; - tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k0 + t2; b3 -= k1 + 13; - tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k2; b1 -= k3 + t0; - tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k4 + t1; b3 -= k0 + 12; + tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k3; b1 -= k4 + t1; + tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k0 + t2; b3 -= k1 + 13; + tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k2; b1 -= k3 + t0; + tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k4 + t1; b3 -= k0 + 12; - tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k1; b1 -= k2 + t2; - tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k3 + t0; b3 -= k4 + 11; - tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k0; b1 -= k1 + t1; - tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k2 + t2; b3 -= k3 + 10; + tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k1; b1 -= k2 + t2; + tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k3 + t0; b3 -= k4 + 11; + tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k0; b1 -= k1 + t1; + tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k2 + t2; b3 -= k3 + 10; - tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k4; b1 -= k0 + t0; - tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k1 + t1; b3 -= k2 + 9; - tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k3; b1 -= k4 + t2; - tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k0 + t0; b3 -= k1 + 8; + tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k4; b1 -= k0 + t0; + tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k1 + t1; b3 -= k2 + 9; + tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k3; b1 -= k4 + t2; + tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k0 + t0; b3 -= k1 + 8; - tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k2; b1 -= k3 + t1; - tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k4 + t2; b3 -= k0 + 7; - tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k1; b1 -= k2 + t0; - tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k3 + t1; b3 -= k4 + 6; + tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k2; b1 -= k3 + t1; + tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k4 + t2; b3 -= k0 + 7; + tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k1; b1 -= k2 + t0; + tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k3 + t1; b3 -= k4 + 6; - tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k0; b1 -= k1 + t2; - tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k2 + t0; b3 -= k3 + 5; - tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k4; b1 -= k0 + t1; - tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k1 + t2; b3 -= k2 + 4; + tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k0; b1 -= k1 + t2; + tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k2 + t0; b3 -= k3 + 5; + tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k4; b1 -= k0 + t1; + tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k1 + t2; b3 -= k2 + 4; - tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k3; b1 -= k4 + t0; - tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k0 + t1; b3 -= k1 + 3; - tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k2; b1 -= k3 + t2; - tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k4 + t0; b3 -= k0 + 2; + tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k3; b1 -= k4 + t0; + tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k0 + t1; b3 -= k1 + 3; + tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k2; b1 -= k3 + t2; + tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k4 + t0; b3 -= k0 + 2; - tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k1; b1 -= k2 + t1; - tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k3 + t2; b3 -= k4 + 1; - tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k0; b1 -= k1 + t0; - tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k2 + t1; b3 -= k3; + tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k1; b1 -= k2 + t1; + tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k3 + t2; b3 -= k4 + 1; + tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; + tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; + tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; + tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; + tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k0; b1 -= k1 + t0; + tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k2 + t1; b3 -= k3; - output[0] = b0; - output[1] = b1; - output[2] = b2; - output[3] = b3; - } + output[0] = b0; + output[1] = b1; + output[2] = b2; + output[3] = b3; +} diff --git a/drivers/staging/skein/threefish512Block.c b/drivers/staging/skein/threefish512Block.c index 5262f5a8f21b..dc96ba279720 100644 --- a/drivers/staging/skein/threefish512Block.c +++ b/drivers/staging/skein/threefish512Block.c @@ -3,640 +3,638 @@ void threefishEncrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output) - { +{ + u64 b0 = input[0], b1 = input[1], + b2 = input[2], b3 = input[3], + b4 = input[4], b5 = input[5], + b6 = input[6], b7 = input[7]; + u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1], + k2 = keyCtx->key[2], k3 = keyCtx->key[3], + k4 = keyCtx->key[4], k5 = keyCtx->key[5], + k6 = keyCtx->key[6], k7 = keyCtx->key[7], + k8 = keyCtx->key[8]; + u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], + t2 = keyCtx->tweak[2]; - u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3], - b4 = input[4], b5 = input[5], - b6 = input[6], b7 = input[7]; - u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1], - k2 = keyCtx->key[2], k3 = keyCtx->key[3], - k4 = keyCtx->key[4], k5 = keyCtx->key[5], - k6 = keyCtx->key[6], k7 = keyCtx->key[7], - k8 = keyCtx->key[8]; - u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], - t2 = keyCtx->tweak[2]; + b1 += k1; b0 += b1 + k0; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + b3 += k3; b2 += b3 + k2; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + b5 += k5 + t0; b4 += b5 + k4; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + b7 += k7; b6 += b7 + k6 + t1; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + b1 += k2; b0 += b1 + k1; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + b3 += k4; b2 += b3 + k3; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + b5 += k6 + t1; b4 += b5 + k5; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + b7 += k8 + 1; b6 += b7 + k7 + t2; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + b1 += k3; b0 += b1 + k2; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + b3 += k5; b2 += b3 + k4; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + b5 += k7 + t2; b4 += b5 + k6; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + b7 += k0 + 2; b6 += b7 + k8 + t0; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + b1 += k4; b0 += b1 + k3; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + b3 += k6; b2 += b3 + k5; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + b5 += k8 + t0; b4 += b5 + k7; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + b7 += k1 + 3; b6 += b7 + k0 + t1; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + b1 += k5; b0 += b1 + k4; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + b3 += k7; b2 += b3 + k6; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + b5 += k0 + t1; b4 += b5 + k8; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + b7 += k2 + 4; b6 += b7 + k1 + t2; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + b1 += k6; b0 += b1 + k5; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + b3 += k8; b2 += b3 + k7; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + b5 += k1 + t2; b4 += b5 + k0; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + b7 += k3 + 5; b6 += b7 + k2 + t0; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + b1 += k7; b0 += b1 + k6; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + b3 += k0; b2 += b3 + k8; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + b5 += k2 + t0; b4 += b5 + k1; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + b7 += k4 + 6; b6 += b7 + k3 + t1; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + b1 += k8; b0 += b1 + k7; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + b3 += k1; b2 += b3 + k0; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + b5 += k3 + t1; b4 += b5 + k2; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + b7 += k5 + 7; b6 += b7 + k4 + t2; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + b1 += k0; b0 += b1 + k8; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + b3 += k2; b2 += b3 + k1; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + b5 += k4 + t2; b4 += b5 + k3; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + b7 += k6 + 8; b6 += b7 + k5 + t0; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + b1 += k1; b0 += b1 + k0; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + b3 += k3; b2 += b3 + k2; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + b5 += k5 + t0; b4 += b5 + k4; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + b7 += k7 + 9; b6 += b7 + k6 + t1; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + b1 += k2; b0 += b1 + k1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + b3 += k4; b2 += b3 + k3; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + b5 += k6 + t1; b4 += b5 + k5; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + b7 += k8 + 10; b6 += b7 + k7 + t2; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + b1 += k3; b0 += b1 + k2; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + b3 += k5; b2 += b3 + k4; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + b5 += k7 + t2; b4 += b5 + k6; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + b7 += k0 + 11; b6 += b7 + k8 + t0; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + b1 += k4; b0 += b1 + k3; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + b3 += k6; b2 += b3 + k5; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + b5 += k8 + t0; b4 += b5 + k7; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + b7 += k1 + 12; b6 += b7 + k0 + t1; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + b1 += k5; b0 += b1 + k4; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + b3 += k7; b2 += b3 + k6; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + b5 += k0 + t1; b4 += b5 + k8; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + b7 += k2 + 13; b6 += b7 + k1 + t2; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + b1 += k6; b0 += b1 + k5; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + b3 += k8; b2 += b3 + k7; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + b5 += k1 + t2; b4 += b5 + k0; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + b7 += k3 + 14; b6 += b7 + k2 + t0; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + b1 += k7; b0 += b1 + k6; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + b3 += k0; b2 += b3 + k8; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + b5 += k2 + t0; b4 += b5 + k1; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + b7 += k4 + 15; b6 += b7 + k3 + t1; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + b1 += k8; b0 += b1 + k7; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + b3 += k1; b2 += b3 + k0; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + b5 += k3 + t1; b4 += b5 + k2; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + b7 += k5 + 16; b6 += b7 + k4 + t2; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + b1 += k0; b0 += b1 + k8; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + b3 += k2; b2 += b3 + k1; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + b5 += k4 + t2; b4 += b5 + k3; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + b7 += k6 + 17; b6 += b7 + k5 + t0; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - b1 += k1; b0 += b1 + k0; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - b3 += k3; b2 += b3 + k2; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - b5 += k5 + t0; b4 += b5 + k4; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - b7 += k7; b6 += b7 + k6 + t1; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - b1 += k2; b0 += b1 + k1; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - b3 += k4; b2 += b3 + k3; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - b5 += k6 + t1; b4 += b5 + k5; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - b7 += k8 + 1; b6 += b7 + k7 + t2; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - b1 += k3; b0 += b1 + k2; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - b3 += k5; b2 += b3 + k4; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - b5 += k7 + t2; b4 += b5 + k6; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - b7 += k0 + 2; b6 += b7 + k8 + t0; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - b1 += k4; b0 += b1 + k3; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - b3 += k6; b2 += b3 + k5; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - b5 += k8 + t0; b4 += b5 + k7; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - b7 += k1 + 3; b6 += b7 + k0 + t1; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - b1 += k5; b0 += b1 + k4; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - b3 += k7; b2 += b3 + k6; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - b5 += k0 + t1; b4 += b5 + k8; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - b7 += k2 + 4; b6 += b7 + k1 + t2; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - b1 += k6; b0 += b1 + k5; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - b3 += k8; b2 += b3 + k7; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - b5 += k1 + t2; b4 += b5 + k0; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - b7 += k3 + 5; b6 += b7 + k2 + t0; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - b1 += k7; b0 += b1 + k6; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - b3 += k0; b2 += b3 + k8; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - b5 += k2 + t0; b4 += b5 + k1; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - b7 += k4 + 6; b6 += b7 + k3 + t1; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - b1 += k8; b0 += b1 + k7; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - b3 += k1; b2 += b3 + k0; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - b5 += k3 + t1; b4 += b5 + k2; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - b7 += k5 + 7; b6 += b7 + k4 + t2; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - b1 += k0; b0 += b1 + k8; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - b3 += k2; b2 += b3 + k1; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - b5 += k4 + t2; b4 += b5 + k3; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - b7 += k6 + 8; b6 += b7 + k5 + t0; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - b1 += k1; b0 += b1 + k0; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - b3 += k3; b2 += b3 + k2; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - b5 += k5 + t0; b4 += b5 + k4; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - b7 += k7 + 9; b6 += b7 + k6 + t1; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - b1 += k2; b0 += b1 + k1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - b3 += k4; b2 += b3 + k3; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - b5 += k6 + t1; b4 += b5 + k5; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - b7 += k8 + 10; b6 += b7 + k7 + t2; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - b1 += k3; b0 += b1 + k2; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - b3 += k5; b2 += b3 + k4; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - b5 += k7 + t2; b4 += b5 + k6; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - b7 += k0 + 11; b6 += b7 + k8 + t0; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - b1 += k4; b0 += b1 + k3; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - b3 += k6; b2 += b3 + k5; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - b5 += k8 + t0; b4 += b5 + k7; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - b7 += k1 + 12; b6 += b7 + k0 + t1; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - b1 += k5; b0 += b1 + k4; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - b3 += k7; b2 += b3 + k6; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - b5 += k0 + t1; b4 += b5 + k8; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - b7 += k2 + 13; b6 += b7 + k1 + t2; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - b1 += k6; b0 += b1 + k5; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - b3 += k8; b2 += b3 + k7; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - b5 += k1 + t2; b4 += b5 + k0; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - b7 += k3 + 14; b6 += b7 + k2 + t0; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - b1 += k7; b0 += b1 + k6; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - b3 += k0; b2 += b3 + k8; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - b5 += k2 + t0; b4 += b5 + k1; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - b7 += k4 + 15; b6 += b7 + k3 + t1; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - b1 += k8; b0 += b1 + k7; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - b3 += k1; b2 += b3 + k0; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - b5 += k3 + t1; b4 += b5 + k2; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - b7 += k5 + 16; b6 += b7 + k4 + t2; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - b1 += k0; b0 += b1 + k8; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - b3 += k2; b2 += b3 + k1; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - b5 += k4 + t2; b4 += b5 + k3; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - b7 += k6 + 17; b6 += b7 + k5 + t0; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - - output[0] = b0 + k0; - output[1] = b1 + k1; - output[2] = b2 + k2; - output[3] = b3 + k3; - output[4] = b4 + k4; - output[5] = b5 + k5 + t0; - output[6] = b6 + k6 + t1; - output[7] = b7 + k7 + 18; - } + output[0] = b0 + k0; + output[1] = b1 + k1; + output[2] = b2 + k2; + output[3] = b3 + k3; + output[4] = b4 + k4; + output[5] = b5 + k5 + t0; + output[6] = b6 + k6 + t1; + output[7] = b7 + k7 + 18; +} void threefishDecrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output) - { - - u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3], - b4 = input[4], b5 = input[5], - b6 = input[6], b7 = input[7]; - u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1], - k2 = keyCtx->key[2], k3 = keyCtx->key[3], - k4 = keyCtx->key[4], k5 = keyCtx->key[5], - k6 = keyCtx->key[6], k7 = keyCtx->key[7], - k8 = keyCtx->key[8]; - u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], - t2 = keyCtx->tweak[2]; +{ + u64 b0 = input[0], b1 = input[1], + b2 = input[2], b3 = input[3], + b4 = input[4], b5 = input[5], + b6 = input[6], b7 = input[7]; + u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1], + k2 = keyCtx->key[2], k3 = keyCtx->key[3], + k4 = keyCtx->key[4], k5 = keyCtx->key[5], + k6 = keyCtx->key[6], k7 = keyCtx->key[7], + k8 = keyCtx->key[8]; + u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], + t2 = keyCtx->tweak[2]; - u64 tmp; + u64 tmp; - b0 -= k0; - b1 -= k1; - b2 -= k2; - b3 -= k3; - b4 -= k4; - b5 -= k5 + t0; - b6 -= k6 + t1; - b7 -= k7 + 18; - tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k5 + t0; b7 -= k6 + 17; - tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k3; b5 -= k4 + t2; - tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k1; b3 -= k2; - tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k8; b1 -= k0; - tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k4 + t2; b7 -= k5 + 16; - tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k2; b5 -= k3 + t1; - tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k0; b3 -= k1; - tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k7; b1 -= k8; - tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k3 + t1; b7 -= k4 + 15; - tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k1; b5 -= k2 + t0; - tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k8; b3 -= k0; - tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k6; b1 -= k7; - tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k2 + t0; b7 -= k3 + 14; - tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k0; b5 -= k1 + t2; - tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k7; b3 -= k8; - tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k5; b1 -= k6; - tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k1 + t2; b7 -= k2 + 13; - tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k8; b5 -= k0 + t1; - tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k6; b3 -= k7; - tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k4; b1 -= k5; - tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k0 + t1; b7 -= k1 + 12; - tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k7; b5 -= k8 + t0; - tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k5; b3 -= k6; - tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k3; b1 -= k4; - tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k8 + t0; b7 -= k0 + 11; - tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k6; b5 -= k7 + t2; - tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k4; b3 -= k5; - tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k2; b1 -= k3; - tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k7 + t2; b7 -= k8 + 10; - tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k5; b5 -= k6 + t1; - tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k3; b3 -= k4; - tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k1; b1 -= k2; - tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k6 + t1; b7 -= k7 + 9; - tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k4; b5 -= k5 + t0; - tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k2; b3 -= k3; - tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k0; b1 -= k1; - tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k5 + t0; b7 -= k6 + 8; - tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k3; b5 -= k4 + t2; - tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k1; b3 -= k2; - tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k8; b1 -= k0; - tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k4 + t2; b7 -= k5 + 7; - tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k2; b5 -= k3 + t1; - tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k0; b3 -= k1; - tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k7; b1 -= k8; - tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k3 + t1; b7 -= k4 + 6; - tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k1; b5 -= k2 + t0; - tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k8; b3 -= k0; - tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k6; b1 -= k7; - tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k2 + t0; b7 -= k3 + 5; - tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k0; b5 -= k1 + t2; - tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k7; b3 -= k8; - tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k5; b1 -= k6; - tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k1 + t2; b7 -= k2 + 4; - tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k8; b5 -= k0 + t1; - tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k6; b3 -= k7; - tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k4; b1 -= k5; - tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k0 + t1; b7 -= k1 + 3; - tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k7; b5 -= k8 + t0; - tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k5; b3 -= k6; - tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k3; b1 -= k4; - tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k8 + t0; b7 -= k0 + 2; - tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k6; b5 -= k7 + t2; - tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k4; b3 -= k5; - tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k2; b1 -= k3; - tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k7 + t2; b7 -= k8 + 1; - tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k5; b5 -= k6 + t1; - tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k3; b3 -= k4; - tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k1; b1 -= k2; - tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k6 + t1; b7 -= k7; - tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k4; b5 -= k5 + t0; - tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k2; b3 -= k3; - tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k0; b1 -= k1; + b0 -= k0; + b1 -= k1; + b2 -= k2; + b3 -= k3; + b4 -= k4; + b5 -= k5 + t0; + b6 -= k6 + t1; + b7 -= k7 + 18; + tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k5 + t0; b7 -= k6 + 17; + tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k3; b5 -= k4 + t2; + tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k1; b3 -= k2; + tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k8; b1 -= k0; + tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k4 + t2; b7 -= k5 + 16; + tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k2; b5 -= k3 + t1; + tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k0; b3 -= k1; + tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k7; b1 -= k8; + tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k3 + t1; b7 -= k4 + 15; + tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k1; b5 -= k2 + t0; + tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k8; b3 -= k0; + tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k6; b1 -= k7; + tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k2 + t0; b7 -= k3 + 14; + tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k0; b5 -= k1 + t2; + tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k7; b3 -= k8; + tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k5; b1 -= k6; + tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k1 + t2; b7 -= k2 + 13; + tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k8; b5 -= k0 + t1; + tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k6; b3 -= k7; + tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k4; b1 -= k5; + tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k0 + t1; b7 -= k1 + 12; + tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k7; b5 -= k8 + t0; + tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k5; b3 -= k6; + tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k3; b1 -= k4; + tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k8 + t0; b7 -= k0 + 11; + tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k6; b5 -= k7 + t2; + tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k4; b3 -= k5; + tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k2; b1 -= k3; + tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k7 + t2; b7 -= k8 + 10; + tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k5; b5 -= k6 + t1; + tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k3; b3 -= k4; + tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k1; b1 -= k2; + tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k6 + t1; b7 -= k7 + 9; + tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k4; b5 -= k5 + t0; + tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k2; b3 -= k3; + tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k0; b1 -= k1; + tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k5 + t0; b7 -= k6 + 8; + tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k3; b5 -= k4 + t2; + tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k1; b3 -= k2; + tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k8; b1 -= k0; + tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k4 + t2; b7 -= k5 + 7; + tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k2; b5 -= k3 + t1; + tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k0; b3 -= k1; + tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k7; b1 -= k8; + tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k3 + t1; b7 -= k4 + 6; + tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k1; b5 -= k2 + t0; + tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k8; b3 -= k0; + tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k6; b1 -= k7; + tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k2 + t0; b7 -= k3 + 5; + tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k0; b5 -= k1 + t2; + tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k7; b3 -= k8; + tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k5; b1 -= k6; + tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k1 + t2; b7 -= k2 + 4; + tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k8; b5 -= k0 + t1; + tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k6; b3 -= k7; + tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k4; b1 -= k5; + tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k0 + t1; b7 -= k1 + 3; + tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k7; b5 -= k8 + t0; + tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k5; b3 -= k6; + tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k3; b1 -= k4; + tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k8 + t0; b7 -= k0 + 2; + tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k6; b5 -= k7 + t2; + tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k4; b3 -= k5; + tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k2; b1 -= k3; + tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k7 + t2; b7 -= k8 + 1; + tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k5; b5 -= k6 + t1; + tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k3; b3 -= k4; + tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k1; b1 -= k2; + tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; + tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; + tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; + tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; + tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; + tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; + tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; + tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; + tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; + tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; + tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; + tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; + tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k6 + t1; b7 -= k7; + tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k4; b5 -= k5 + t0; + tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k2; b3 -= k3; + tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k0; b1 -= k1; - output[0] = b0; - output[1] = b1; - output[2] = b2; - output[3] = b3; + output[0] = b0; + output[1] = b1; + output[2] = b2; + output[3] = b3; - output[7] = b7; - output[6] = b6; - output[5] = b5; - output[4] = b4; + output[7] = b7; + output[6] = b6; + output[5] = b5; + output[4] = b4; } diff --git a/drivers/staging/skein/threefishApi.c b/drivers/staging/skein/threefishApi.c index 53f46f6cb9ca..e8ce06a9122f 100644 --- a/drivers/staging/skein/threefishApi.c +++ b/drivers/staging/skein/threefishApi.c @@ -4,75 +4,75 @@ #include void threefishSetKey(struct threefish_key *keyCtx, enum threefish_size stateSize, - u64 *keyData, u64 *tweak) + u64 *keyData, u64 *tweak) { - int keyWords = stateSize / 64; - int i; - u64 parity = KeyScheduleConst; + int keyWords = stateSize / 64; + int i; + u64 parity = KeyScheduleConst; - keyCtx->tweak[0] = tweak[0]; - keyCtx->tweak[1] = tweak[1]; - keyCtx->tweak[2] = tweak[0] ^ tweak[1]; + keyCtx->tweak[0] = tweak[0]; + keyCtx->tweak[1] = tweak[1]; + keyCtx->tweak[2] = tweak[0] ^ tweak[1]; - for (i = 0; i < keyWords; i++) { - keyCtx->key[i] = keyData[i]; - parity ^= keyData[i]; - } - keyCtx->key[i] = parity; - keyCtx->stateSize = stateSize; + for (i = 0; i < keyWords; i++) { + keyCtx->key[i] = keyData[i]; + parity ^= keyData[i]; + } + keyCtx->key[i] = parity; + keyCtx->stateSize = stateSize; } void threefishEncryptBlockBytes(struct threefish_key *keyCtx, u8 *in, - u8 *out) + u8 *out) { - u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ - u64 cipher[SKEIN_MAX_STATE_WORDS]; - - Skein_Get64_LSB_First(plain, in, keyCtx->stateSize / 64); /* bytes to words */ - threefishEncryptBlockWords(keyCtx, plain, cipher); - Skein_Put64_LSB_First(out, cipher, keyCtx->stateSize / 8); /* words to bytes */ + u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ + u64 cipher[SKEIN_MAX_STATE_WORDS]; + + Skein_Get64_LSB_First(plain, in, keyCtx->stateSize / 64); /* bytes to words */ + threefishEncryptBlockWords(keyCtx, plain, cipher); + Skein_Put64_LSB_First(out, cipher, keyCtx->stateSize / 8); /* words to bytes */ } void threefishEncryptBlockWords(struct threefish_key *keyCtx, u64 *in, - u64 *out) + u64 *out) { - switch (keyCtx->stateSize) { - case Threefish256: - threefishEncrypt256(keyCtx, in, out); - break; - case Threefish512: - threefishEncrypt512(keyCtx, in, out); - break; - case Threefish1024: - threefishEncrypt1024(keyCtx, in, out); - break; - } + switch (keyCtx->stateSize) { + case Threefish256: + threefishEncrypt256(keyCtx, in, out); + break; + case Threefish512: + threefishEncrypt512(keyCtx, in, out); + break; + case Threefish1024: + threefishEncrypt1024(keyCtx, in, out); + break; + } } void threefishDecryptBlockBytes(struct threefish_key *keyCtx, u8 *in, - u8 *out) + u8 *out) { - u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ - u64 cipher[SKEIN_MAX_STATE_WORDS]; - - Skein_Get64_LSB_First(cipher, in, keyCtx->stateSize / 64); /* bytes to words */ - threefishDecryptBlockWords(keyCtx, cipher, plain); - Skein_Put64_LSB_First(out, plain, keyCtx->stateSize / 8); /* words to bytes */ + u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ + u64 cipher[SKEIN_MAX_STATE_WORDS]; + + Skein_Get64_LSB_First(cipher, in, keyCtx->stateSize / 64); /* bytes to words */ + threefishDecryptBlockWords(keyCtx, cipher, plain); + Skein_Put64_LSB_First(out, plain, keyCtx->stateSize / 8); /* words to bytes */ } void threefishDecryptBlockWords(struct threefish_key *keyCtx, u64 *in, - u64 *out) + u64 *out) { - switch (keyCtx->stateSize) { - case Threefish256: - threefishDecrypt256(keyCtx, in, out); - break; - case Threefish512: - threefishDecrypt512(keyCtx, in, out); - break; - case Threefish1024: - threefishDecrypt1024(keyCtx, in, out); - break; - } + switch (keyCtx->stateSize) { + case Threefish256: + threefishDecrypt256(keyCtx, in, out); + break; + case Threefish512: + threefishDecrypt512(keyCtx, in, out); + break; + case Threefish1024: + threefishDecrypt1024(keyCtx, in, out); + break; + } } -- cgit v1.2.3 From 06a620f09ec428796aa490547d743203ffc30e1d Mon Sep 17 00:00:00 2001 From: Jason Cooper Date: Mon, 24 Mar 2014 01:49:10 +0000 Subject: staging: crypto: skein: remove trailing whitespace Signed-off-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/include/skein.h | 16 +++++----- drivers/staging/skein/include/skeinApi.h | 44 ++++++++++++++-------------- drivers/staging/skein/include/threefishApi.h | 40 ++++++++++++------------- drivers/staging/skein/skeinBlockNo3F.c | 6 ++-- drivers/staging/skein/skein_block.c | 20 ++++++------- 5 files changed, 63 insertions(+), 63 deletions(-) diff --git a/drivers/staging/skein/include/skein.h b/drivers/staging/skein/include/skein.h index 906bcee41c39..dd9a210cf5dd 100644 --- a/drivers/staging/skein/include/skein.h +++ b/drivers/staging/skein/include/skein.h @@ -9,7 +9,7 @@ ** This algorithm and source code is released to the public domain. ** *************************************************************************** -** +** ** The following compile-time switches may be defined to control some ** tradeoffs between speed, code size, error checking, and security. ** @@ -20,8 +20,8 @@ ** [default: no callouts (no overhead)] ** ** SKEIN_ERR_CHECK -- how error checking is handled inside Skein -** code. If not defined, most error checking -** is disabled (for performance). Otherwise, +** code. If not defined, most error checking +** is disabled (for performance). Otherwise, ** the switch value is interpreted as: ** 0: use assert() to flag errors ** 1: return SKEIN_FAIL to flag errors @@ -109,12 +109,12 @@ int Skein1024_Final(struct skein1024_ctx *ctx, u8 *hashVal); ** After an InitExt() call, just use Update/Final calls as with Init(). ** ** Notes: Same parameters as _Init() calls, plus treeInfo/key/keyBytes. -** When keyBytes == 0 and treeInfo == SKEIN_SEQUENTIAL, +** When keyBytes == 0 and treeInfo == SKEIN_SEQUENTIAL, ** the results of InitExt() are identical to calling Init(). ** The function Init() may be called once to "precompute" the IV for ** a given hashBitLen value, then by saving a copy of the context ** the IV computation may be avoided in later calls. -** Similarly, the function InitExt() may be called once per MAC key +** Similarly, the function InitExt() may be called once per MAC key ** to precompute the MAC IV, then a copy of the context saved and ** reused for each new MAC computation. **/ @@ -142,7 +142,7 @@ int Skein1024_Output(struct skein1024_ctx *ctx, u8 *hashVal); /***************************************************************** ** "Internal" Skein definitions -** -- not needed for sequential hashing API, but will be +** -- not needed for sequential hashing API, but will be ** helpful for other uses of Skein (e.g., tree hash mode). ** -- included here so that they can be shared between ** reference and optimized code. @@ -269,8 +269,8 @@ int Skein1024_Output(struct skein1024_ctx *ctx, u8 *hashVal); /***************************************************************** ** Skein block function constants (shared across Ref and Opt code) ******************************************************************/ -enum - { +enum + { /* Skein_256 round rotation constants */ R_256_0_0 = 14, R_256_0_1 = 16, R_256_1_0 = 52, R_256_1_1 = 57, diff --git a/drivers/staging/skein/include/skeinApi.h b/drivers/staging/skein/include/skeinApi.h index 0d7d59eff460..ace931a67c23 100644 --- a/drivers/staging/skein/include/skeinApi.h +++ b/drivers/staging/skein/include/skeinApi.h @@ -36,46 +36,46 @@ OTHER DEALINGS IN THE SOFTWARE. * of Skein. The design and the way to use the functions follow the openSSL * design but at the same time take care of some Skein specific behaviour * and possibilities. - * + * * The functions enable applications to create a normal Skein hashes and * message authentication codes (MAC). - * + * * Using these functions is simple and straight forward: - * + * * @code - * + * * #include - * + * * ... * struct skein_ctx ctx; // a Skein hash or MAC context - * + * * // prepare context, here for a Skein with a state size of 512 bits. * skeinCtxPrepare(&ctx, Skein512); - * + * * // Initialize the context to set the requested hash length in bits * // here request a output hash size of 31 bits (Skein supports variable * // output sizes even very strange sizes) * skeinInit(&ctx, 31); - * + * * // Now update Skein with any number of message bits. A function that * // takes a number of bytes is also available. * skeinUpdateBits(&ctx, message, msgLength); - * + * * // Now get the result of the Skein hash. The output buffer must be * // large enough to hold the request number of output bits. The application * // may now extract the bits. * skeinFinal(&ctx, result); * ... * @endcode - * + * * An application may use @c skeinReset to reset a Skein context and use * it for creation of another hash with the same Skein state size and output * bit length. In this case the API implementation restores some internal * internal state data and saves a full Skein initialization round. - * - * To create a MAC the application just uses @c skeinMacInit instead of + * + * To create a MAC the application just uses @c skeinMacInit instead of * @c skeinInit. All other functions calls remain the same. - * + * */ #include @@ -111,7 +111,7 @@ struct skein_ctx { /** * Prepare a Skein context. - * + * * An application must call this function before it can use the Skein * context. The functions clears memory and initializes size dependent * variables. @@ -128,7 +128,7 @@ int skeinCtxPrepare(struct skein_ctx *ctx, enum skein_size size); /** * Initialize a Skein context. * - * Initializes the context with this data and saves the resulting Skein + * Initializes the context with this data and saves the resulting Skein * state variables for further use. * * @param ctx @@ -143,11 +143,11 @@ int skeinInit(struct skein_ctx *ctx, size_t hashBitLen); /** * Resets a Skein context for further use. - * - * Restores the saved chaining variables to reset the Skein context. - * Thus applications can reuse the same setup to process several + * + * Restores the saved chaining variables to reset the Skein context. + * Thus applications can reuse the same setup to process several * messages. This saves a complete Skein initialization cycle. - * + * * @param ctx * Pointer to a pre-initialized Skein MAC context */ @@ -155,8 +155,8 @@ void skeinReset(struct skein_ctx *ctx); /** * Initializes a Skein context for MAC usage. - * - * Initializes the context with this data and saves the resulting Skein + * + * Initializes the context with this data and saves the resulting Skein * state variables for further use. * * Applications call the normal Skein functions to update the MAC and @@ -209,7 +209,7 @@ int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg, /** * Finalize Skein and return the hash. - * + * * Before an application can reuse a Skein setup the application must * reset the Skein context. * diff --git a/drivers/staging/skein/include/threefishApi.h b/drivers/staging/skein/include/threefishApi.h index 199257e37813..5d92bbff8c9f 100644 --- a/drivers/staging/skein/include/threefishApi.h +++ b/drivers/staging/skein/include/threefishApi.h @@ -8,14 +8,14 @@ * @{ * * This API and the functions that implement this API simplify the usage - * of the Threefish cipher. The design and the way to use the functions + * of the Threefish cipher. The design and the way to use the functions * follow the openSSL design but at the same time take care of some Threefish * specific behaviour and possibilities. * * These are the low level functions that deal with Threefisch blocks only. - * Implementations for cipher modes such as ECB, CFB, or CBC may use these + * Implementations for cipher modes such as ECB, CFB, or CBC may use these * functions. - * + * @code // Threefish cipher context data struct threefish_key keyCtx; @@ -44,7 +44,7 @@ enum threefish_size { /** * Context for Threefish key and tweak words. - * + * * This structure was setup with some know-how of the internal * Skein structures, in particular ordering of header and size dependent * variables. If Skein implementation changes this, the adapt these @@ -58,10 +58,10 @@ struct threefish_key { /** * Set Threefish key and tweak data. - * + * * This function sets the key and tweak data for the Threefish cipher of * the given size. The key data must have the same length (number of bits) - * as the state size + * as the state size * * @param keyCtx * Pointer to a Threefish key structure. @@ -76,12 +76,12 @@ void threefishSetKey(struct threefish_key *keyCtx, enum threefish_size stateSize /** * Encrypt Threefisch block (bytes). - * - * The buffer must have at least the same length (number of bits) aas the + * + * The buffer must have at least the same length (number of bits) aas the * state size for this key. The function uses the first @c stateSize bits * of the input buffer, encrypts them and stores the result in the output * buffer. - * + * * @param keyCtx * Pointer to a Threefish key structure. * @param in @@ -93,14 +93,14 @@ void threefishEncryptBlockBytes(struct threefish_key *keyCtx, u8 *in, u8 *out); /** * Encrypt Threefisch block (words). - * - * The buffer must have at least the same length (number of bits) aas the + * + * The buffer must have at least the same length (number of bits) aas the * state size for this key. The function uses the first @c stateSize bits * of the input buffer, encrypts them and stores the result in the output * buffer. - * + * * The wordsize ist set to 64 bits. - * + * * @param keyCtx * Pointer to a Threefish key structure. * @param in @@ -112,12 +112,12 @@ void threefishEncryptBlockWords(struct threefish_key *keyCtx, u64 *in, u64 *out) /** * Decrypt Threefisch block (bytes). - * - * The buffer must have at least the same length (number of bits) aas the + * + * The buffer must have at least the same length (number of bits) aas the * state size for this key. The function uses the first @c stateSize bits * of the input buffer, decrypts them and stores the result in the output * buffer - * + * * @param keyCtx * Pointer to a Threefish key structure. * @param in @@ -129,14 +129,14 @@ void threefishDecryptBlockBytes(struct threefish_key *keyCtx, u8 *in, u8 *out); /** * Decrypt Threefisch block (words). - * - * The buffer must have at least the same length (number of bits) aas the + * + * The buffer must have at least the same length (number of bits) aas the * state size for this key. The function uses the first @c stateSize bits * of the input buffer, encrypts them and stores the result in the output * buffer. - * + * * The wordsize ist set to 64 bits. - * + * * @param keyCtx * Pointer to a Threefish key structure. * @param in diff --git a/drivers/staging/skein/skeinBlockNo3F.c b/drivers/staging/skein/skeinBlockNo3F.c index 3c2878c966e1..376cd63d8f83 100644 --- a/drivers/staging/skein/skeinBlockNo3F.c +++ b/drivers/staging/skein/skeinBlockNo3F.c @@ -29,7 +29,7 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, carry += words[i]; words[i] = carry; carry >>= 32; - } + } tweak[0] = words[0] & 0xffffffffL; tweak[0] |= (words[1] & 0xffffffffL) << 32; tweak[1] |= words[2] & 0xffffffffL; @@ -79,7 +79,7 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, carry += words[i]; words[i] = carry; carry >>= 32; - } + } tweak[0] = words[0] & 0xffffffffL; tweak[0] |= (words[1] & 0xffffffffL) << 32; tweak[1] |= words[2] & 0xffffffffL; @@ -133,7 +133,7 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, carry += words[i]; words[i] = carry; carry >>= 32; - } + } tweak[0] = words[0] & 0xffffffffL; tweak[0] |= (words[1] & 0xffffffffL) << 32; tweak[1] |= words[2] & 0xffffffffL; diff --git a/drivers/staging/skein/skein_block.c b/drivers/staging/skein/skein_block.c index bb36860fafdf..d315f547feae 100644 --- a/drivers/staging/skein/skein_block.c +++ b/drivers/staging/skein/skein_block.c @@ -28,7 +28,7 @@ #define BLK_BITS (WCNT*64) /* some useful definitions for code here */ #define KW_TWK_BASE (0) #define KW_KEY_BASE (3) -#define ks (kw + KW_KEY_BASE) +#define ks (kw + KW_KEY_BASE) #define ts (kw + KW_TWK_BASE) #ifdef SKEIN_DEBUG @@ -76,7 +76,7 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, size_t ts[0] += byteCntAdd; /* update processed length */ /* precompute the key schedule for this block */ - ks[0] = ctx->X[0]; + ks[0] = ctx->X[0]; ks[1] = ctx->X[1]; ks[2] = ctx->X[2]; ks[3] = ctx->X[3]; @@ -103,7 +103,7 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, size_t X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ -#if SKEIN_UNROLL_256 == 0 +#if SKEIN_UNROLL_256 == 0 #define R256(p0, p1, p2, p3, ROT, rNum) /* fully unrolled */ \ Round256(p0, p1, p2, p3, ROT, rNum) \ Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rNum, Xptr); @@ -129,8 +129,8 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, size_t Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_256) /* loop thru it */ -#endif - { +#endif + { #define R256_8_rounds(R) \ R256(0, 1, 2, 3, R_256_0, 8 * (R) + 1); \ R256(0, 3, 2, 1, R_256_1, 8 * (R) + 2); \ @@ -270,7 +270,7 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, size_t ks[5] = ctx->X[5]; ks[6] = ctx->X[6]; ks[7] = ctx->X[7]; - ks[8] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ + ks[8] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ ks[4] ^ ks[5] ^ ks[6] ^ ks[7] ^ SKEIN_KS_PARITY; ts[2] = ts[0] ^ ts[1]; @@ -298,7 +298,7 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, size_t X##p4 += X##p5; X##p5 = RotL_64(X##p5, ROT##_2); X##p5 ^= X##p4; \ X##p6 += X##p7; X##p7 = RotL_64(X##p7, ROT##_3); X##p7 ^= X##p6; \ -#if SKEIN_UNROLL_512 == 0 +#if SKEIN_UNROLL_512 == 0 #define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) /* unrolled */ \ Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \ Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rNum, Xptr); @@ -529,7 +529,7 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, size_t X##pC += X##pD; X##pD = RotL_64(X##pD, ROT##_6); X##pD ^= X##pC; \ X##pE += X##pF; X##pF = RotL_64(X##pF, ROT##_7); X##pF ^= X##pE; \ -#if SKEIN_UNROLL_1024 == 0 +#if SKEIN_UNROLL_1024 == 0 #define R1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, ROT, rn) \ Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, ROT, rn) \ Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rn, Xptr); @@ -551,7 +551,7 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, size_t X13 += ks[((R) + 14) % 17] + ts[((R) + 1) % 3]; \ X14 += ks[((R) + 15) % 17] + ts[((R) + 2) % 3]; \ X15 += ks[((R) + 16) % 17] + (R) + 1; \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); #else /* looping version */ #define R1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, ROT, rn) \ Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, ROT, rn) \ @@ -579,7 +579,7 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, size_t Skein_Show_R_Ptr(BLK_BITSi, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); for (r = 1; r <= 2 * RCNT; r += 2 * SKEIN_UNROLL_1024) /* loop thru it */ -#endif +#endif { #define R1024_8_rounds(R) /* do 8 full rounds */ \ R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, R1024_0, 8*(R) + 1); \ -- cgit v1.2.3 From 60eb817520c949543bcdccce2242c1b73372a45b Mon Sep 17 00:00:00 2001 From: Jason Cooper Date: Mon, 24 Mar 2014 01:49:11 +0000 Subject: staging: crypto: skein: cleanup >80 character lines Signed-off-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/include/skein.h | 175 +- drivers/staging/skein/include/threefishApi.h | 16 +- drivers/staging/skein/skein.c | 586 ++- drivers/staging/skein/skeinApi.c | 58 +- drivers/staging/skein/skeinBlockNo3F.c | 27 +- drivers/staging/skein/skein_block.c | 427 +- drivers/staging/skein/threefish1024Block.c | 6152 ++++++++++++++++++++------ drivers/staging/skein/threefish256Block.c | 1398 ++++-- drivers/staging/skein/threefish512Block.c | 2775 +++++++++--- drivers/staging/skein/threefishApi.c | 13 +- 10 files changed, 8919 insertions(+), 2708 deletions(-) diff --git a/drivers/staging/skein/include/skein.h b/drivers/staging/skein/include/skein.h index dd9a210cf5dd..f92dc40711d1 100644 --- a/drivers/staging/skein/include/skein.h +++ b/drivers/staging/skein/include/skein.h @@ -39,12 +39,12 @@ enum { - SKEIN_SUCCESS = 0, /* return codes from Skein calls */ + SKEIN_SUCCESS = 0, /* return codes from Skein calls */ SKEIN_FAIL = 1, SKEIN_BAD_HASHLEN = 2 }; -#define SKEIN_MODIFIER_WORDS (2) /* number of modifier (tweak) words */ +#define SKEIN_MODIFIER_WORDS (2) /* number of modifier (tweak) words */ #define SKEIN_256_STATE_WORDS (4) #define SKEIN_512_STATE_WORDS (8) @@ -65,30 +65,30 @@ enum struct skein_ctx_hdr { - size_t hashBitLen; /* size of hash result, in bits */ - size_t bCnt; /* current byte count in buffer b[] */ - u64 T[SKEIN_MODIFIER_WORDS]; /* tweak words: T[0]=byte cnt, T[1]=flags */ + size_t hashBitLen; /* size of hash result, in bits */ + size_t bCnt; /* current byte count in buffer b[] */ + u64 T[SKEIN_MODIFIER_WORDS]; /* tweak: T[0]=byte cnt, T[1]=flags */ }; -struct skein_256_ctx /* 256-bit Skein hash context structure */ +struct skein_256_ctx /* 256-bit Skein hash context structure */ { - struct skein_ctx_hdr h; /* common header context variables */ - u64 X[SKEIN_256_STATE_WORDS]; /* chaining variables */ - u8 b[SKEIN_256_BLOCK_BYTES]; /* partial block buffer (8-byte aligned) */ + struct skein_ctx_hdr h; /* common header context variables */ + u64 X[SKEIN_256_STATE_WORDS]; /* chaining variables */ + u8 b[SKEIN_256_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ }; -struct skein_512_ctx /* 512-bit Skein hash context structure */ +struct skein_512_ctx /* 512-bit Skein hash context structure */ { - struct skein_ctx_hdr h; /* common header context variables */ - u64 X[SKEIN_512_STATE_WORDS]; /* chaining variables */ - u8 b[SKEIN_512_BLOCK_BYTES]; /* partial block buffer (8-byte aligned) */ + struct skein_ctx_hdr h; /* common header context variables */ + u64 X[SKEIN_512_STATE_WORDS]; /* chaining variables */ + u8 b[SKEIN_512_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ }; -struct skein1024_ctx /* 1024-bit Skein hash context structure */ +struct skein1024_ctx /* 1024-bit Skein hash context structure */ { - struct skein_ctx_hdr h; /* common header context variables */ - u64 X[SKEIN1024_STATE_WORDS]; /* chaining variables */ - u8 b[SKEIN1024_BLOCK_BYTES]; /* partial block buffer (8-byte aligned) */ + struct skein_ctx_hdr h; /* common header context variables */ + u64 X[SKEIN1024_STATE_WORDS]; /* chaining variables */ + u8 b[SKEIN1024_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ }; /* Skein APIs for (incremental) "straight hashing" */ @@ -96,9 +96,12 @@ int Skein_256_Init(struct skein_256_ctx *ctx, size_t hashBitLen); int Skein_512_Init(struct skein_512_ctx *ctx, size_t hashBitLen); int Skein1024_Init(struct skein1024_ctx *ctx, size_t hashBitLen); -int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg, size_t msgByteCnt); -int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg, size_t msgByteCnt); -int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg, size_t msgByteCnt); +int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg, + size_t msgByteCnt); +int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg, + size_t msgByteCnt); +int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg, + size_t msgByteCnt); int Skein_256_Final(struct skein_256_ctx *ctx, u8 *hashVal); int Skein_512_Final(struct skein_512_ctx *ctx, u8 *hashVal); @@ -118,9 +121,12 @@ int Skein1024_Final(struct skein1024_ctx *ctx, u8 *hashVal); ** to precompute the MAC IV, then a copy of the context saved and ** reused for each new MAC computation. **/ -int Skein_256_InitExt(struct skein_256_ctx *ctx, size_t hashBitLen, u64 treeInfo, const u8 *key, size_t keyBytes); -int Skein_512_InitExt(struct skein_512_ctx *ctx, size_t hashBitLen, u64 treeInfo, const u8 *key, size_t keyBytes); -int Skein1024_InitExt(struct skein1024_ctx *ctx, size_t hashBitLen, u64 treeInfo, const u8 *key, size_t keyBytes); +int Skein_256_InitExt(struct skein_256_ctx *ctx, size_t hashBitLen, + u64 treeInfo, const u8 *key, size_t keyBytes); +int Skein_512_InitExt(struct skein_512_ctx *ctx, size_t hashBitLen, + u64 treeInfo, const u8 *key, size_t keyBytes); +int Skein1024_InitExt(struct skein1024_ctx *ctx, size_t hashBitLen, + u64 treeInfo, const u8 *key, size_t keyBytes); /* ** Skein APIs for MAC and tree hash: @@ -149,13 +155,13 @@ int Skein1024_Output(struct skein1024_ctx *ctx, u8 *hashVal); ******************************************************************/ /* tweak word T[1]: bit field starting positions */ -#define SKEIN_T1_BIT(BIT) ((BIT) - 64) /* offset 64 because it's the second word */ +#define SKEIN_T1_BIT(BIT) ((BIT) - 64) /* second word */ -#define SKEIN_T1_POS_TREE_LVL SKEIN_T1_BIT(112) /* bits 112..118: level in hash tree */ -#define SKEIN_T1_POS_BIT_PAD SKEIN_T1_BIT(119) /* bit 119 : partial final input byte */ -#define SKEIN_T1_POS_BLK_TYPE SKEIN_T1_BIT(120) /* bits 120..125: type field */ -#define SKEIN_T1_POS_FIRST SKEIN_T1_BIT(126) /* bits 126 : first block flag */ -#define SKEIN_T1_POS_FINAL SKEIN_T1_BIT(127) /* bit 127 : final block flag */ +#define SKEIN_T1_POS_TREE_LVL SKEIN_T1_BIT(112) /* 112..118 hash tree level */ +#define SKEIN_T1_POS_BIT_PAD SKEIN_T1_BIT(119) /* 119 part. final in byte */ +#define SKEIN_T1_POS_BLK_TYPE SKEIN_T1_BIT(120) /* 120..125 type field `*/ +#define SKEIN_T1_POS_FIRST SKEIN_T1_BIT(126) /* 126 first blk flag */ +#define SKEIN_T1_POS_FINAL SKEIN_T1_BIT(127) /* 127 final blk flag */ /* tweak word T[1]: flag bit definition(s) */ #define SKEIN_T1_FLAG_FIRST (((u64) 1) << SKEIN_T1_POS_FIRST) @@ -167,34 +173,37 @@ int Skein1024_Output(struct skein1024_ctx *ctx, u8 *hashVal); #define SKEIN_T1_TREE_LEVEL(n) (((u64) (n)) << SKEIN_T1_POS_TREE_LVL) /* tweak word T[1]: block type field */ -#define SKEIN_BLK_TYPE_KEY (0) /* key, for MAC and KDF */ -#define SKEIN_BLK_TYPE_CFG (4) /* configuration block */ -#define SKEIN_BLK_TYPE_PERS (8) /* personalization string */ -#define SKEIN_BLK_TYPE_PK (12) /* public key (for digital signature hashing) */ -#define SKEIN_BLK_TYPE_KDF (16) /* key identifier for KDF */ -#define SKEIN_BLK_TYPE_NONCE (20) /* nonce for PRNG */ -#define SKEIN_BLK_TYPE_MSG (48) /* message processing */ -#define SKEIN_BLK_TYPE_OUT (63) /* output stage */ -#define SKEIN_BLK_TYPE_MASK (63) /* bit field mask */ - -#define SKEIN_T1_BLK_TYPE(T) (((u64) (SKEIN_BLK_TYPE_##T)) << SKEIN_T1_POS_BLK_TYPE) -#define SKEIN_T1_BLK_TYPE_KEY SKEIN_T1_BLK_TYPE(KEY) /* key, for MAC and KDF */ -#define SKEIN_T1_BLK_TYPE_CFG SKEIN_T1_BLK_TYPE(CFG) /* configuration block */ -#define SKEIN_T1_BLK_TYPE_PERS SKEIN_T1_BLK_TYPE(PERS) /* personalization string */ -#define SKEIN_T1_BLK_TYPE_PK SKEIN_T1_BLK_TYPE(PK) /* public key (for digital signature hashing) */ -#define SKEIN_T1_BLK_TYPE_KDF SKEIN_T1_BLK_TYPE(KDF) /* key identifier for KDF */ +#define SKEIN_BLK_TYPE_KEY (0) /* key, for MAC and KDF */ +#define SKEIN_BLK_TYPE_CFG (4) /* configuration block */ +#define SKEIN_BLK_TYPE_PERS (8) /* personalization string */ +#define SKEIN_BLK_TYPE_PK (12) /* pubkey (for digital sigs) */ +#define SKEIN_BLK_TYPE_KDF (16) /* key identifier for KDF */ +#define SKEIN_BLK_TYPE_NONCE (20) /* nonce for PRNG */ +#define SKEIN_BLK_TYPE_MSG (48) /* message processing */ +#define SKEIN_BLK_TYPE_OUT (63) /* output stage */ +#define SKEIN_BLK_TYPE_MASK (63) /* bit field mask */ + +#define SKEIN_T1_BLK_TYPE(T) (((u64) (SKEIN_BLK_TYPE_##T)) << \ + SKEIN_T1_POS_BLK_TYPE) +#define SKEIN_T1_BLK_TYPE_KEY SKEIN_T1_BLK_TYPE(KEY) /* for MAC and KDF */ +#define SKEIN_T1_BLK_TYPE_CFG SKEIN_T1_BLK_TYPE(CFG) /* config block */ +#define SKEIN_T1_BLK_TYPE_PERS SKEIN_T1_BLK_TYPE(PERS) /* personalization */ +#define SKEIN_T1_BLK_TYPE_PK SKEIN_T1_BLK_TYPE(PK) /* pubkey (for sigs) */ +#define SKEIN_T1_BLK_TYPE_KDF SKEIN_T1_BLK_TYPE(KDF) /* key ident for KDF */ #define SKEIN_T1_BLK_TYPE_NONCE SKEIN_T1_BLK_TYPE(NONCE)/* nonce for PRNG */ #define SKEIN_T1_BLK_TYPE_MSG SKEIN_T1_BLK_TYPE(MSG) /* message processing */ #define SKEIN_T1_BLK_TYPE_OUT SKEIN_T1_BLK_TYPE(OUT) /* output stage */ #define SKEIN_T1_BLK_TYPE_MASK SKEIN_T1_BLK_TYPE(MASK) /* field bit mask */ -#define SKEIN_T1_BLK_TYPE_CFG_FINAL (SKEIN_T1_BLK_TYPE_CFG | SKEIN_T1_FLAG_FINAL) -#define SKEIN_T1_BLK_TYPE_OUT_FINAL (SKEIN_T1_BLK_TYPE_OUT | SKEIN_T1_FLAG_FINAL) +#define SKEIN_T1_BLK_TYPE_CFG_FINAL (SKEIN_T1_BLK_TYPE_CFG | \ + SKEIN_T1_FLAG_FINAL) +#define SKEIN_T1_BLK_TYPE_OUT_FINAL (SKEIN_T1_BLK_TYPE_OUT | \ + SKEIN_T1_FLAG_FINAL) #define SKEIN_VERSION (1) #ifndef SKEIN_ID_STRING_LE /* allow compile-time personalization */ -#define SKEIN_ID_STRING_LE (0x33414853) /* "SHA3" (little-endian)*/ +#define SKEIN_ID_STRING_LE (0x33414853) /* "SHA3" (little-endian)*/ #endif #define SKEIN_MK_64(hi32, lo32) ((lo32) + (((u64) (hi32)) << 32)) @@ -208,23 +217,29 @@ int Skein1024_Output(struct skein1024_ctx *ctx, u8 *hashVal); #define SKEIN_CFG_TREE_NODE_SIZE_POS (8) #define SKEIN_CFG_TREE_MAX_LEVEL_POS (16) -#define SKEIN_CFG_TREE_LEAF_SIZE_MSK (((u64) 0xFF) << SKEIN_CFG_TREE_LEAF_SIZE_POS) -#define SKEIN_CFG_TREE_NODE_SIZE_MSK (((u64) 0xFF) << SKEIN_CFG_TREE_NODE_SIZE_POS) -#define SKEIN_CFG_TREE_MAX_LEVEL_MSK (((u64) 0xFF) << SKEIN_CFG_TREE_MAX_LEVEL_POS) +#define SKEIN_CFG_TREE_LEAF_SIZE_MSK (((u64)0xFF) << \ + SKEIN_CFG_TREE_LEAF_SIZE_POS) +#define SKEIN_CFG_TREE_NODE_SIZE_MSK (((u64)0xFF) << \ + SKEIN_CFG_TREE_NODE_SIZE_POS) +#define SKEIN_CFG_TREE_MAX_LEVEL_MSK (((u64)0xFF) << \ + SKEIN_CFG_TREE_MAX_LEVEL_POS) #define SKEIN_CFG_TREE_INFO(leaf, node, maxLvl) \ ((((u64)(leaf)) << SKEIN_CFG_TREE_LEAF_SIZE_POS) | \ (((u64)(node)) << SKEIN_CFG_TREE_NODE_SIZE_POS) | \ (((u64)(maxLvl)) << SKEIN_CFG_TREE_MAX_LEVEL_POS)) -#define SKEIN_CFG_TREE_INFO_SEQUENTIAL SKEIN_CFG_TREE_INFO(0, 0, 0) /* use as treeInfo in InitExt() call for sequential processing */ +/* use as treeInfo in InitExt() call for sequential processing */ +#define SKEIN_CFG_TREE_INFO_SEQUENTIAL SKEIN_CFG_TREE_INFO(0, 0, 0) /* ** Skein macros for getting/setting tweak words, etc. ** These are useful for partial input bytes, hash tree init/update, etc. **/ #define Skein_Get_Tweak(ctxPtr, TWK_NUM) ((ctxPtr)->h.T[TWK_NUM]) -#define Skein_Set_Tweak(ctxPtr, TWK_NUM, tVal) {(ctxPtr)->h.T[TWK_NUM] = (tVal); } +#define Skein_Set_Tweak(ctxPtr, TWK_NUM, tVal) { \ + (ctxPtr)->h.T[TWK_NUM] = (tVal); \ + } #define Skein_Get_T0(ctxPtr) Skein_Get_Tweak(ctxPtr, 0) #define Skein_Get_T1(ctxPtr) Skein_Get_Tweak(ctxPtr, 1) @@ -241,14 +256,26 @@ int Skein1024_Output(struct skein1024_ctx *ctx, u8 *hashVal); #define Skein_Set_Type(ctxPtr, BLK_TYPE) \ Skein_Set_T1(ctxPtr, SKEIN_T1_BLK_TYPE_##BLK_TYPE) -/* set up for starting with a new type: h.T[0]=0; h.T[1] = NEW_TYPE; h.bCnt=0; */ -#define Skein_Start_New_Type(ctxPtr, BLK_TYPE) \ - { Skein_Set_T0_T1(ctxPtr, 0, SKEIN_T1_FLAG_FIRST | SKEIN_T1_BLK_TYPE_##BLK_TYPE); (ctxPtr)->h.bCnt = 0; } +/* + * setup for starting with a new type: + * h.T[0]=0; h.T[1] = NEW_TYPE; h.bCnt=0; + */ +#define Skein_Start_New_Type(ctxPtr, BLK_TYPE) { \ + Skein_Set_T0_T1(ctxPtr, 0, SKEIN_T1_FLAG_FIRST | \ + SKEIN_T1_BLK_TYPE_##BLK_TYPE); \ + (ctxPtr)->h.bCnt = 0; \ + } -#define Skein_Clear_First_Flag(hdr) { (hdr).T[1] &= ~SKEIN_T1_FLAG_FIRST; } -#define Skein_Set_Bit_Pad_Flag(hdr) { (hdr).T[1] |= SKEIN_T1_FLAG_BIT_PAD; } +#define Skein_Clear_First_Flag(hdr) { \ + (hdr).T[1] &= ~SKEIN_T1_FLAG_FIRST; \ + } +#define Skein_Set_Bit_Pad_Flag(hdr) { \ + (hdr).T[1] |= SKEIN_T1_FLAG_BIT_PAD; \ + } -#define Skein_Set_Tree_Level(hdr, height) { (hdr).T[1] |= SKEIN_T1_TREE_LEVEL(height); } +#define Skein_Set_Tree_Level(hdr, height) { \ + (hdr).T[1] |= SKEIN_T1_TREE_LEVEL(height); \ + } /***************************************************************** ** "Internal" Skein definitions for debugging and error checking @@ -263,7 +290,7 @@ int Skein1024_Output(struct skein1024_ctx *ctx, u8 *hashVal); #define Skein_Show_Key(bits, ctx, key, keyBytes) #endif -#define Skein_Assert(x, retCode)/* default: ignore all Asserts, for performance */ +#define Skein_Assert(x, retCode)/* ignore all Asserts, for performance */ #define Skein_assert(x) /***************************************************************** @@ -292,21 +319,29 @@ enum R_512_7_0 = 8, R_512_7_1 = 35, R_512_7_2 = 56, R_512_7_3 = 22, /* Skein1024 round rotation constants */ - R1024_0_0 = 24, R1024_0_1 = 13, R1024_0_2 = 8, R1024_0_3 = 47, R1024_0_4 = 8, R1024_0_5 = 17, R1024_0_6 = 22, R1024_0_7 = 37, - R1024_1_0 = 38, R1024_1_1 = 19, R1024_1_2 = 10, R1024_1_3 = 55, R1024_1_4 = 49, R1024_1_5 = 18, R1024_1_6 = 23, R1024_1_7 = 52, - R1024_2_0 = 33, R1024_2_1 = 4, R1024_2_2 = 51, R1024_2_3 = 13, R1024_2_4 = 34, R1024_2_5 = 41, R1024_2_6 = 59, R1024_2_7 = 17, - R1024_3_0 = 5, R1024_3_1 = 20, R1024_3_2 = 48, R1024_3_3 = 41, R1024_3_4 = 47, R1024_3_5 = 28, R1024_3_6 = 16, R1024_3_7 = 25, - R1024_4_0 = 41, R1024_4_1 = 9, R1024_4_2 = 37, R1024_4_3 = 31, R1024_4_4 = 12, R1024_4_5 = 47, R1024_4_6 = 44, R1024_4_7 = 30, - R1024_5_0 = 16, R1024_5_1 = 34, R1024_5_2 = 56, R1024_5_3 = 51, R1024_5_4 = 4, R1024_5_5 = 53, R1024_5_6 = 42, R1024_5_7 = 41, - R1024_6_0 = 31, R1024_6_1 = 44, R1024_6_2 = 47, R1024_6_3 = 46, R1024_6_4 = 19, R1024_6_5 = 42, R1024_6_6 = 44, R1024_6_7 = 25, - R1024_7_0 = 9, R1024_7_1 = 48, R1024_7_2 = 35, R1024_7_3 = 52, R1024_7_4 = 23, R1024_7_5 = 31, R1024_7_6 = 37, R1024_7_7 = 20 + R1024_0_0 = 24, R1024_0_1 = 13, R1024_0_2 = 8, R1024_0_3 = 47, + R1024_0_4 = 8, R1024_0_5 = 17, R1024_0_6 = 22, R1024_0_7 = 37, + R1024_1_0 = 38, R1024_1_1 = 19, R1024_1_2 = 10, R1024_1_3 = 55, + R1024_1_4 = 49, R1024_1_5 = 18, R1024_1_6 = 23, R1024_1_7 = 52, + R1024_2_0 = 33, R1024_2_1 = 4, R1024_2_2 = 51, R1024_2_3 = 13, + R1024_2_4 = 34, R1024_2_5 = 41, R1024_2_6 = 59, R1024_2_7 = 17, + R1024_3_0 = 5, R1024_3_1 = 20, R1024_3_2 = 48, R1024_3_3 = 41, + R1024_3_4 = 47, R1024_3_5 = 28, R1024_3_6 = 16, R1024_3_7 = 25, + R1024_4_0 = 41, R1024_4_1 = 9, R1024_4_2 = 37, R1024_4_3 = 31, + R1024_4_4 = 12, R1024_4_5 = 47, R1024_4_6 = 44, R1024_4_7 = 30, + R1024_5_0 = 16, R1024_5_1 = 34, R1024_5_2 = 56, R1024_5_3 = 51, + R1024_5_4 = 4, R1024_5_5 = 53, R1024_5_6 = 42, R1024_5_7 = 41, + R1024_6_0 = 31, R1024_6_1 = 44, R1024_6_2 = 47, R1024_6_3 = 46, + R1024_6_4 = 19, R1024_6_5 = 42, R1024_6_6 = 44, R1024_6_7 = 25, + R1024_7_0 = 9, R1024_7_1 = 48, R1024_7_2 = 35, R1024_7_3 = 52, + R1024_7_4 = 23, R1024_7_5 = 31, R1024_7_6 = 37, R1024_7_7 = 20 }; #ifndef SKEIN_ROUNDS -#define SKEIN_256_ROUNDS_TOTAL (72) /* number of rounds for the different block sizes */ +#define SKEIN_256_ROUNDS_TOTAL (72) /* # rounds for diff block sizes */ #define SKEIN_512_ROUNDS_TOTAL (72) #define SKEIN1024_ROUNDS_TOTAL (80) -#else /* allow command-line define in range 8*(5..14) */ +#else /* allow command-line define in range 8*(5..14) */ #define SKEIN_256_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS/100) + 5) % 10) + 5)) #define SKEIN_512_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS/10) + 5) % 10) + 5)) #define SKEIN1024_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS) + 5) % 10) + 5)) diff --git a/drivers/staging/skein/include/threefishApi.h b/drivers/staging/skein/include/threefishApi.h index 5d92bbff8c9f..e81675d7eac9 100644 --- a/drivers/staging/skein/include/threefishApi.h +++ b/drivers/staging/skein/include/threefishApi.h @@ -72,7 +72,9 @@ struct threefish_key { * @param tweak * Pointer to the two tweak words (word has 64 bits). */ -void threefishSetKey(struct threefish_key *keyCtx, enum threefish_size stateSize, u64 *keyData, u64 *tweak); +void threefishSetKey(struct threefish_key *keyCtx, + enum threefish_size stateSize, + u64 *keyData, u64 *tweak); /** * Encrypt Threefisch block (bytes). @@ -108,7 +110,8 @@ void threefishEncryptBlockBytes(struct threefish_key *keyCtx, u8 *in, u8 *out); * @param out * Pointer to cipher buffer. */ -void threefishEncryptBlockWords(struct threefish_key *keyCtx, u64 *in, u64 *out); +void threefishEncryptBlockWords(struct threefish_key *keyCtx, u64 *in, + u64 *out); /** * Decrypt Threefisch block (bytes). @@ -144,14 +147,17 @@ void threefishDecryptBlockBytes(struct threefish_key *keyCtx, u8 *in, u8 *out); * @param out * Pointer to plaintext buffer. */ -void threefishDecryptBlockWords(struct threefish_key *keyCtx, u64 *in, u64 *out); +void threefishDecryptBlockWords(struct threefish_key *keyCtx, u64 *in, + u64 *out); void threefishEncrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output); void threefishEncrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output); -void threefishEncrypt1024(struct threefish_key *keyCtx, u64 *input, u64 *output); +void threefishEncrypt1024(struct threefish_key *keyCtx, u64 *input, + u64 *output); void threefishDecrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output); void threefishDecrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output); -void threefishDecrypt1024(struct threefish_key *keyCtx, u64 *input, u64 *output); +void threefishDecrypt1024(struct threefish_key *keyCtx, u64 *input, + u64 *output); /** * @} */ diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c index 3f0f32806181..ed603ee7b170 100644 --- a/drivers/staging/skein/skein.c +++ b/drivers/staging/skein/skein.c @@ -16,9 +16,12 @@ /*****************************************************************/ /* External function to process blkCnt (nonzero) full block(s) of data. */ -void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, size_t blkCnt, size_t byteCntAdd); -void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, size_t blkCnt, size_t byteCntAdd); -void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, size_t blkCnt, size_t byteCntAdd); +void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, + size_t blkCnt, size_t byteCntAdd); +void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, + size_t blkCnt, size_t byteCntAdd); +void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, + size_t blkCnt, size_t byteCntAdd); /*****************************************************************/ /* 256-bit Skein */ @@ -53,20 +56,28 @@ int Skein_256_Init(struct skein_256_ctx *ctx, size_t hashBitLen) break; default: /* here if there is no precomputed IV value available */ - /* build/process the config block, type == CONFIG (could be precomputed) */ - Skein_Start_New_Type(ctx, CFG_FINAL); /* set tweaks: T0=0; T1=CFG | FINAL */ - - cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); /* set the schema, version */ - cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ + /* + * build/process the config block, type == CONFIG (could be + * precomputed) + */ + /* set tweaks: T0=0; T1=CFG | FINAL */ + Skein_Start_New_Type(ctx, CFG_FINAL); + + /* set the schema, version */ + cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); + /* hash result length in bits */ + cfg.w[1] = Skein_Swap64(hashBitLen); cfg.w[2] = Skein_Swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); - memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); /* zero pad config block */ + /* zero pad config block */ + memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); /* compute the initial chaining values from config block */ - memset(ctx->X, 0, sizeof(ctx->X)); /* zero the chaining variables */ + /* zero the chaining variables */ + memset(ctx->X, 0, sizeof(ctx->X)); Skein_256_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); break; } - /* The chaining vars ctx->X are now initialized for the given hashBitLen. */ + /* The chaining vars ctx->X are now initialized for hashBitLen. */ /* Set up to process the data message portion of the hash (default) */ Skein_Start_New_Type(ctx, MSG); /* T0=0, T1= MSG type */ @@ -75,42 +86,58 @@ int Skein_256_Init(struct skein_256_ctx *ctx, size_t hashBitLen) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a MAC and/or tree hash operation */ -/* [identical to Skein_256_Init() when keyBytes == 0 && treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ -int Skein_256_InitExt(struct skein_256_ctx *ctx, size_t hashBitLen, u64 treeInfo, const u8 *key, size_t keyBytes) +/* [identical to Skein_256_Init() when keyBytes == 0 && \ + * treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ +int Skein_256_InitExt(struct skein_256_ctx *ctx, size_t hashBitLen, + u64 treeInfo, const u8 *key, size_t keyBytes) { union { u8 b[SKEIN_256_STATE_BYTES]; u64 w[SKEIN_256_STATE_WORDS]; - } cfg; /* config block */ + } cfg; /* config block */ Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN); Skein_Assert(keyBytes == 0 || key != NULL, SKEIN_FAIL); /* compute the initial chaining values ctx->X[], based on key */ - if (keyBytes == 0) /* is there a key? */ + if (keyBytes == 0) /* is there a key? */ { - memset(ctx->X, 0, sizeof(ctx->X)); /* no key: use all zeroes as key for config block */ + /* no key: use all zeroes as key for config block */ + memset(ctx->X, 0, sizeof(ctx->X)); } - else /* here to pre-process a key */ + else /* here to pre-process a key */ { Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); /* do a mini-Init right here */ - ctx->h.hashBitLen = 8*sizeof(ctx->X); /* set output hash bit count = state size */ - Skein_Start_New_Type(ctx, KEY); /* set tweaks: T0 = 0; T1 = KEY type */ - memset(ctx->X, 0, sizeof(ctx->X)); /* zero the initial chaining variables */ - Skein_256_Update(ctx, key, keyBytes); /* hash the key */ - Skein_256_Final_Pad(ctx, cfg.b); /* put result into cfg.b[] */ - memcpy(ctx->X, cfg.b, sizeof(cfg.b)); /* copy over into ctx->X[] */ + /* set output hash bit count = state size */ + ctx->h.hashBitLen = 8*sizeof(ctx->X); + /* set tweaks: T0 = 0; T1 = KEY type */ + Skein_Start_New_Type(ctx, KEY); + /* zero the initial chaining variables */ + memset(ctx->X, 0, sizeof(ctx->X)); + /* hash the key */ + Skein_256_Update(ctx, key, keyBytes); + /* put result into cfg.b[] */ + Skein_256_Final_Pad(ctx, cfg.b); + /* copy over into ctx->X[] */ + memcpy(ctx->X, cfg.b, sizeof(cfg.b)); } - /* build/process the config block, type == CONFIG (could be precomputed for each key) */ - ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ + /* + * build/process the config block, type == CONFIG (could be + * precomputed for each key) + */ + /* output hash bit count */ + ctx->h.hashBitLen = hashBitLen; Skein_Start_New_Type(ctx, CFG_FINAL); - memset(&cfg.w, 0, sizeof(cfg.w)); /* pre-pad cfg.w[] with zeroes */ + /* pre-pad cfg.w[] with zeroes */ + memset(&cfg.w, 0, sizeof(cfg.w)); cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); - cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ - cfg.w[2] = Skein_Swap64(treeInfo); /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ + /* hash result length in bits */ + cfg.w[1] = Skein_Swap64(hashBitLen); + /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ + cfg.w[2] = Skein_Swap64(treeInfo); Skein_Show_Key(256, &ctx->h, key, keyBytes); @@ -126,35 +153,46 @@ int Skein_256_InitExt(struct skein_256_ctx *ctx, size_t hashBitLen, u64 treeInfo /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* process the input bytes */ -int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg, size_t msgByteCnt) +int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg, + size_t msgByteCnt) { size_t n; - Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ + /* catch uninitialized context */ + Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* process full blocks, if any */ if (msgByteCnt + ctx->h.bCnt > SKEIN_256_BLOCK_BYTES) { - if (ctx->h.bCnt) /* finish up any buffered message data */ + /* finish up any buffered message data */ + if (ctx->h.bCnt) { - n = SKEIN_256_BLOCK_BYTES - ctx->h.bCnt; /* # bytes free in buffer b[] */ + /* # bytes free in buffer b[] */ + n = SKEIN_256_BLOCK_BYTES - ctx->h.bCnt; if (n) { - Skein_assert(n < msgByteCnt); /* check on our logic here */ + /* check on our logic here */ + Skein_assert(n < msgByteCnt); memcpy(&ctx->b[ctx->h.bCnt], msg, n); msgByteCnt -= n; msg += n; ctx->h.bCnt += n; } Skein_assert(ctx->h.bCnt == SKEIN_256_BLOCK_BYTES); - Skein_256_Process_Block(ctx, ctx->b, 1, SKEIN_256_BLOCK_BYTES); + Skein_256_Process_Block(ctx, ctx->b, 1, + SKEIN_256_BLOCK_BYTES); ctx->h.bCnt = 0; } - /* now process any remaining full blocks, directly from input message data */ + /* + * now process any remaining full blocks, directly from input + * message data + */ if (msgByteCnt > SKEIN_256_BLOCK_BYTES) { - n = (msgByteCnt-1) / SKEIN_256_BLOCK_BYTES; /* number of full blocks to process */ - Skein_256_Process_Block(ctx, msg, n, SKEIN_256_BLOCK_BYTES); + /* number of full blocks to process */ + n = (msgByteCnt-1) / SKEIN_256_BLOCK_BYTES; + Skein_256_Process_Block(ctx, msg, n, + SKEIN_256_BLOCK_BYTES); msgByteCnt -= n * SKEIN_256_BLOCK_BYTES; msg += n * SKEIN_256_BLOCK_BYTES; } @@ -178,31 +216,46 @@ int Skein_256_Final(struct skein_256_ctx *ctx, u8 *hashVal) { size_t i, n, byteCnt; u64 X[SKEIN_256_STATE_WORDS]; - Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ + /* catch uninitialized context */ + Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); - ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ - if (ctx->h.bCnt < SKEIN_256_BLOCK_BYTES) /* zero pad b[] if necessary */ - memset(&ctx->b[ctx->h.bCnt], 0, SKEIN_256_BLOCK_BYTES - ctx->h.bCnt); + /* tag as the final block */ + ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; + /* zero pad b[] if necessary */ + if (ctx->h.bCnt < SKEIN_256_BLOCK_BYTES) + memset(&ctx->b[ctx->h.bCnt], 0, + SKEIN_256_BLOCK_BYTES - ctx->h.bCnt); - Skein_256_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); /* process the final block */ + /* process the final block */ + Skein_256_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); /* now output the result */ - byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ + /* total number of output bytes */ + byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* run Threefish in "counter mode" to generate output */ - memset(ctx->b, 0, sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ - memcpy(X, ctx->X, sizeof(X)); /* keep a local copy of counter mode "key" */ + /* zero out b[], so it can hold the counter */ + memset(ctx->b, 0, sizeof(ctx->b)); + /* keep a local copy of counter mode "key" */ + memcpy(X, ctx->X, sizeof(X)); for (i = 0; i*SKEIN_256_BLOCK_BYTES < byteCnt; i++) { - ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); /* build the counter block */ + /* build the counter block */ + ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); Skein_Start_New_Type(ctx, OUT_FINAL); - Skein_256_Process_Block(ctx, ctx->b, 1, sizeof(u64)); /* run "counter mode" */ - n = byteCnt - i*SKEIN_256_BLOCK_BYTES; /* number of output bytes left to go */ + /* run "counter mode" */ + Skein_256_Process_Block(ctx, ctx->b, 1, sizeof(u64)); + /* number of output bytes left to go */ + n = byteCnt - i*SKEIN_256_BLOCK_BYTES; if (n >= SKEIN_256_BLOCK_BYTES) n = SKEIN_256_BLOCK_BYTES; - Skein_Put64_LSB_First(hashVal+i*SKEIN_256_BLOCK_BYTES, ctx->X, n); /* "output" the ctr mode bytes */ - Skein_Show_Final(256, &ctx->h, n, hashVal+i*SKEIN_256_BLOCK_BYTES); - memcpy(ctx->X, X, sizeof(X)); /* restore the counter mode key for next time */ + /* "output" the ctr mode bytes */ + Skein_Put64_LSB_First(hashVal+i*SKEIN_256_BLOCK_BYTES, ctx->X, + n); + Skein_Show_Final(256, &ctx->h, n, + hashVal+i*SKEIN_256_BLOCK_BYTES); + /* restore the counter mode key for next time */ + memcpy(ctx->X, X, sizeof(X)); } return SKEIN_SUCCESS; } @@ -240,21 +293,32 @@ int Skein_512_Init(struct skein_512_ctx *ctx, size_t hashBitLen) break; default: /* here if there is no precomputed IV value available */ - /* build/process the config block, type == CONFIG (could be precomputed) */ - Skein_Start_New_Type(ctx, CFG_FINAL); /* set tweaks: T0=0; T1=CFG | FINAL */ - - cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); /* set the schema, version */ - cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ + /* + * build/process the config block, type == CONFIG (could be + * precomputed) + */ + /* set tweaks: T0=0; T1=CFG | FINAL */ + Skein_Start_New_Type(ctx, CFG_FINAL); + + /* set the schema, version */ + cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); + /* hash result length in bits */ + cfg.w[1] = Skein_Swap64(hashBitLen); cfg.w[2] = Skein_Swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); - memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); /* zero pad config block */ + /* zero pad config block */ + memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); /* compute the initial chaining values from config block */ - memset(ctx->X, 0, sizeof(ctx->X)); /* zero the chaining variables */ + /* zero the chaining variables */ + memset(ctx->X, 0, sizeof(ctx->X)); Skein_512_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); break; } - /* The chaining vars ctx->X are now initialized for the given hashBitLen. */ + /* + * The chaining vars ctx->X are now initialized for the given + * hashBitLen. + */ /* Set up to process the data message portion of the hash (default) */ Skein_Start_New_Type(ctx, MSG); /* T0=0, T1= MSG type */ @@ -263,8 +327,10 @@ int Skein_512_Init(struct skein_512_ctx *ctx, size_t hashBitLen) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a MAC and/or tree hash operation */ -/* [identical to Skein_512_Init() when keyBytes == 0 && treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ -int Skein_512_InitExt(struct skein_512_ctx *ctx, size_t hashBitLen, u64 treeInfo, const u8 *key, size_t keyBytes) +/* [identical to Skein_512_Init() when keyBytes == 0 && \ + * treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ +int Skein_512_InitExt(struct skein_512_ctx *ctx, size_t hashBitLen, + u64 treeInfo, const u8 *key, size_t keyBytes) { union { @@ -278,27 +344,40 @@ int Skein_512_InitExt(struct skein_512_ctx *ctx, size_t hashBitLen, u64 treeInfo /* compute the initial chaining values ctx->X[], based on key */ if (keyBytes == 0) /* is there a key? */ { - memset(ctx->X, 0, sizeof(ctx->X)); /* no key: use all zeroes as key for config block */ + /* no key: use all zeroes as key for config block */ + memset(ctx->X, 0, sizeof(ctx->X)); } - else /* here to pre-process a key */ + else /* here to pre-process a key */ { Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); /* do a mini-Init right here */ - ctx->h.hashBitLen = 8*sizeof(ctx->X); /* set output hash bit count = state size */ - Skein_Start_New_Type(ctx, KEY); /* set tweaks: T0 = 0; T1 = KEY type */ - memset(ctx->X, 0, sizeof(ctx->X)); /* zero the initial chaining variables */ - Skein_512_Update(ctx, key, keyBytes); /* hash the key */ - Skein_512_Final_Pad(ctx, cfg.b); /* put result into cfg.b[] */ - memcpy(ctx->X, cfg.b, sizeof(cfg.b)); /* copy over into ctx->X[] */ + /* set output hash bit count = state size */ + ctx->h.hashBitLen = 8*sizeof(ctx->X); + /* set tweaks: T0 = 0; T1 = KEY type */ + Skein_Start_New_Type(ctx, KEY); + /* zero the initial chaining variables */ + memset(ctx->X, 0, sizeof(ctx->X)); + /* hash the key */ + Skein_512_Update(ctx, key, keyBytes); + /* put result into cfg.b[] */ + Skein_512_Final_Pad(ctx, cfg.b); + /* copy over into ctx->X[] */ + memcpy(ctx->X, cfg.b, sizeof(cfg.b)); } - /* build/process the config block, type == CONFIG (could be precomputed for each key) */ + /* + * build/process the config block, type == CONFIG (could be + * precomputed for each key) + */ ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ Skein_Start_New_Type(ctx, CFG_FINAL); - memset(&cfg.w, 0, sizeof(cfg.w)); /* pre-pad cfg.w[] with zeroes */ + /* pre-pad cfg.w[] with zeroes */ + memset(&cfg.w, 0, sizeof(cfg.w)); cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); - cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ - cfg.w[2] = Skein_Swap64(treeInfo); /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ + /* hash result length in bits */ + cfg.w[1] = Skein_Swap64(hashBitLen); + /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ + cfg.w[2] = Skein_Swap64(treeInfo); Skein_Show_Key(512, &ctx->h, key, keyBytes); @@ -314,35 +393,46 @@ int Skein_512_InitExt(struct skein_512_ctx *ctx, size_t hashBitLen, u64 treeInfo /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* process the input bytes */ -int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg, size_t msgByteCnt) +int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg, + size_t msgByteCnt) { size_t n; - Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ + /* catch uninitialized context */ + Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* process full blocks, if any */ if (msgByteCnt + ctx->h.bCnt > SKEIN_512_BLOCK_BYTES) { - if (ctx->h.bCnt) /* finish up any buffered message data */ + /* finish up any buffered message data */ + if (ctx->h.bCnt) { - n = SKEIN_512_BLOCK_BYTES - ctx->h.bCnt; /* # bytes free in buffer b[] */ + /* # bytes free in buffer b[] */ + n = SKEIN_512_BLOCK_BYTES - ctx->h.bCnt; if (n) { - Skein_assert(n < msgByteCnt); /* check on our logic here */ + /* check on our logic here */ + Skein_assert(n < msgByteCnt); memcpy(&ctx->b[ctx->h.bCnt], msg, n); msgByteCnt -= n; msg += n; ctx->h.bCnt += n; } Skein_assert(ctx->h.bCnt == SKEIN_512_BLOCK_BYTES); - Skein_512_Process_Block(ctx, ctx->b, 1, SKEIN_512_BLOCK_BYTES); + Skein_512_Process_Block(ctx, ctx->b, 1, + SKEIN_512_BLOCK_BYTES); ctx->h.bCnt = 0; } - /* now process any remaining full blocks, directly from input message data */ + /* + * now process any remaining full blocks, directly from input + * message data + */ if (msgByteCnt > SKEIN_512_BLOCK_BYTES) { - n = (msgByteCnt-1) / SKEIN_512_BLOCK_BYTES; /* number of full blocks to process */ - Skein_512_Process_Block(ctx, msg, n, SKEIN_512_BLOCK_BYTES); + /* number of full blocks to process */ + n = (msgByteCnt-1) / SKEIN_512_BLOCK_BYTES; + Skein_512_Process_Block(ctx, msg, n, + SKEIN_512_BLOCK_BYTES); msgByteCnt -= n * SKEIN_512_BLOCK_BYTES; msg += n * SKEIN_512_BLOCK_BYTES; } @@ -366,31 +456,46 @@ int Skein_512_Final(struct skein_512_ctx *ctx, u8 *hashVal) { size_t i, n, byteCnt; u64 X[SKEIN_512_STATE_WORDS]; - Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ + /* catch uninitialized context */ + Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); - ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ - if (ctx->h.bCnt < SKEIN_512_BLOCK_BYTES) /* zero pad b[] if necessary */ - memset(&ctx->b[ctx->h.bCnt], 0, SKEIN_512_BLOCK_BYTES - ctx->h.bCnt); + /* tag as the final block */ + ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; + /* zero pad b[] if necessary */ + if (ctx->h.bCnt < SKEIN_512_BLOCK_BYTES) + memset(&ctx->b[ctx->h.bCnt], 0, + SKEIN_512_BLOCK_BYTES - ctx->h.bCnt); - Skein_512_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); /* process the final block */ + /* process the final block */ + Skein_512_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); /* now output the result */ - byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ + /* total number of output bytes */ + byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* run Threefish in "counter mode" to generate output */ - memset(ctx->b, 0, sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ - memcpy(X, ctx->X, sizeof(X)); /* keep a local copy of counter mode "key" */ + /* zero out b[], so it can hold the counter */ + memset(ctx->b, 0, sizeof(ctx->b)); + /* keep a local copy of counter mode "key" */ + memcpy(X, ctx->X, sizeof(X)); for (i = 0; i*SKEIN_512_BLOCK_BYTES < byteCnt; i++) { - ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); /* build the counter block */ + /* build the counter block */ + ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); Skein_Start_New_Type(ctx, OUT_FINAL); - Skein_512_Process_Block(ctx, ctx->b, 1, sizeof(u64)); /* run "counter mode" */ - n = byteCnt - i*SKEIN_512_BLOCK_BYTES; /* number of output bytes left to go */ + /* run "counter mode" */ + Skein_512_Process_Block(ctx, ctx->b, 1, sizeof(u64)); + /* number of output bytes left to go */ + n = byteCnt - i*SKEIN_512_BLOCK_BYTES; if (n >= SKEIN_512_BLOCK_BYTES) n = SKEIN_512_BLOCK_BYTES; - Skein_Put64_LSB_First(hashVal+i*SKEIN_512_BLOCK_BYTES, ctx->X, n); /* "output" the ctr mode bytes */ - Skein_Show_Final(512, &ctx->h, n, hashVal+i*SKEIN_512_BLOCK_BYTES); - memcpy(ctx->X, X, sizeof(X)); /* restore the counter mode key for next time */ + /* "output" the ctr mode bytes */ + Skein_Put64_LSB_First(hashVal+i*SKEIN_512_BLOCK_BYTES, ctx->X, + n); + Skein_Show_Final(512, &ctx->h, n, + hashVal+i*SKEIN_512_BLOCK_BYTES); + /* restore the counter mode key for next time */ + memcpy(ctx->X, X, sizeof(X)); } return SKEIN_SUCCESS; } @@ -425,21 +530,29 @@ int Skein1024_Init(struct skein1024_ctx *ctx, size_t hashBitLen) break; default: /* here if there is no precomputed IV value available */ - /* build/process the config block, type == CONFIG (could be precomputed) */ - Skein_Start_New_Type(ctx, CFG_FINAL); /* set tweaks: T0=0; T1=CFG | FINAL */ - - cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); /* set the schema, version */ - cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ + /* + * build/process the config block, type == CONFIG + * (could be precomputed) + */ + /* set tweaks: T0=0; T1=CFG | FINAL */ + Skein_Start_New_Type(ctx, CFG_FINAL); + + /* set the schema, version */ + cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); + /* hash result length in bits */ + cfg.w[1] = Skein_Swap64(hashBitLen); cfg.w[2] = Skein_Swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); - memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); /* zero pad config block */ + /* zero pad config block */ + memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); /* compute the initial chaining values from config block */ - memset(ctx->X, 0, sizeof(ctx->X)); /* zero the chaining variables */ + /* zero the chaining variables */ + memset(ctx->X, 0, sizeof(ctx->X)); Skein1024_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); break; } - /* The chaining vars ctx->X are now initialized for the given hashBitLen. */ + /* The chaining vars ctx->X are now initialized for the hashBitLen. */ /* Set up to process the data message portion of the hash (default) */ Skein_Start_New_Type(ctx, MSG); /* T0=0, T1= MSG type */ @@ -448,8 +561,10 @@ int Skein1024_Init(struct skein1024_ctx *ctx, size_t hashBitLen) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a MAC and/or tree hash operation */ -/* [identical to Skein1024_Init() when keyBytes == 0 && treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ -int Skein1024_InitExt(struct skein1024_ctx *ctx, size_t hashBitLen, u64 treeInfo, const u8 *key, size_t keyBytes) +/* [identical to Skein1024_Init() when keyBytes == 0 && \ + * treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ +int Skein1024_InitExt(struct skein1024_ctx *ctx, size_t hashBitLen, + u64 treeInfo, const u8 *key, size_t keyBytes) { union { @@ -463,27 +578,41 @@ int Skein1024_InitExt(struct skein1024_ctx *ctx, size_t hashBitLen, u64 treeInfo /* compute the initial chaining values ctx->X[], based on key */ if (keyBytes == 0) /* is there a key? */ { - memset(ctx->X, 0, sizeof(ctx->X)); /* no key: use all zeroes as key for config block */ + /* no key: use all zeroes as key for config block */ + memset(ctx->X, 0, sizeof(ctx->X)); } - else /* here to pre-process a key */ + else /* here to pre-process a key */ { Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); /* do a mini-Init right here */ - ctx->h.hashBitLen = 8*sizeof(ctx->X); /* set output hash bit count = state size */ - Skein_Start_New_Type(ctx, KEY); /* set tweaks: T0 = 0; T1 = KEY type */ - memset(ctx->X, 0, sizeof(ctx->X)); /* zero the initial chaining variables */ - Skein1024_Update(ctx, key, keyBytes); /* hash the key */ - Skein1024_Final_Pad(ctx, cfg.b); /* put result into cfg.b[] */ - memcpy(ctx->X, cfg.b, sizeof(cfg.b)); /* copy over into ctx->X[] */ + /* set output hash bit count = state size */ + ctx->h.hashBitLen = 8*sizeof(ctx->X); + /* set tweaks: T0 = 0; T1 = KEY type */ + Skein_Start_New_Type(ctx, KEY); + /* zero the initial chaining variables */ + memset(ctx->X, 0, sizeof(ctx->X)); + /* hash the key */ + Skein1024_Update(ctx, key, keyBytes); + /* put result into cfg.b[] */ + Skein1024_Final_Pad(ctx, cfg.b); + /* copy over into ctx->X[] */ + memcpy(ctx->X, cfg.b, sizeof(cfg.b)); } - /* build/process the config block, type == CONFIG (could be precomputed for each key) */ - ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ + /* + * build/process the config block, type == CONFIG (could be + * precomputed for each key) + */ + /* output hash bit count */ + ctx->h.hashBitLen = hashBitLen; Skein_Start_New_Type(ctx, CFG_FINAL); - memset(&cfg.w, 0, sizeof(cfg.w)); /* pre-pad cfg.w[] with zeroes */ + /* pre-pad cfg.w[] with zeroes */ + memset(&cfg.w, 0, sizeof(cfg.w)); cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); - cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ - cfg.w[2] = Skein_Swap64(treeInfo); /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ + /* hash result length in bits */ + cfg.w[1] = Skein_Swap64(hashBitLen); + /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ + cfg.w[2] = Skein_Swap64(treeInfo); Skein_Show_Key(1024, &ctx->h, key, keyBytes); @@ -499,35 +628,46 @@ int Skein1024_InitExt(struct skein1024_ctx *ctx, size_t hashBitLen, u64 treeInfo /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* process the input bytes */ -int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg, size_t msgByteCnt) +int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg, + size_t msgByteCnt) { size_t n; - Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ + /* catch uninitialized context */ + Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); /* process full blocks, if any */ if (msgByteCnt + ctx->h.bCnt > SKEIN1024_BLOCK_BYTES) { - if (ctx->h.bCnt) /* finish up any buffered message data */ + /* finish up any buffered message data */ + if (ctx->h.bCnt) { - n = SKEIN1024_BLOCK_BYTES - ctx->h.bCnt; /* # bytes free in buffer b[] */ + /* # bytes free in buffer b[] */ + n = SKEIN1024_BLOCK_BYTES - ctx->h.bCnt; if (n) { - Skein_assert(n < msgByteCnt); /* check on our logic here */ + /* check on our logic here */ + Skein_assert(n < msgByteCnt); memcpy(&ctx->b[ctx->h.bCnt], msg, n); msgByteCnt -= n; msg += n; ctx->h.bCnt += n; } Skein_assert(ctx->h.bCnt == SKEIN1024_BLOCK_BYTES); - Skein1024_Process_Block(ctx, ctx->b, 1, SKEIN1024_BLOCK_BYTES); + Skein1024_Process_Block(ctx, ctx->b, 1, + SKEIN1024_BLOCK_BYTES); ctx->h.bCnt = 0; } - /* now process any remaining full blocks, directly from input message data */ + /* + * now process any remaining full blocks, directly from input + * message data + */ if (msgByteCnt > SKEIN1024_BLOCK_BYTES) { - n = (msgByteCnt-1) / SKEIN1024_BLOCK_BYTES; /* number of full blocks to process */ - Skein1024_Process_Block(ctx, msg, n, SKEIN1024_BLOCK_BYTES); + /* number of full blocks to process */ + n = (msgByteCnt-1) / SKEIN1024_BLOCK_BYTES; + Skein1024_Process_Block(ctx, msg, n, + SKEIN1024_BLOCK_BYTES); msgByteCnt -= n * SKEIN1024_BLOCK_BYTES; msg += n * SKEIN1024_BLOCK_BYTES; } @@ -551,31 +691,46 @@ int Skein1024_Final(struct skein1024_ctx *ctx, u8 *hashVal) { size_t i, n, byteCnt; u64 X[SKEIN1024_STATE_WORDS]; - Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ + /* catch uninitialized context */ + Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); - ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ - if (ctx->h.bCnt < SKEIN1024_BLOCK_BYTES) /* zero pad b[] if necessary */ - memset(&ctx->b[ctx->h.bCnt], 0, SKEIN1024_BLOCK_BYTES - ctx->h.bCnt); + /* tag as the final block */ + ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; + /* zero pad b[] if necessary */ + if (ctx->h.bCnt < SKEIN1024_BLOCK_BYTES) + memset(&ctx->b[ctx->h.bCnt], 0, + SKEIN1024_BLOCK_BYTES - ctx->h.bCnt); - Skein1024_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); /* process the final block */ + /* process the final block */ + Skein1024_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); /* now output the result */ - byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ + /* total number of output bytes */ + byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* run Threefish in "counter mode" to generate output */ - memset(ctx->b, 0, sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ - memcpy(X, ctx->X, sizeof(X)); /* keep a local copy of counter mode "key" */ + /* zero out b[], so it can hold the counter */ + memset(ctx->b, 0, sizeof(ctx->b)); + /* keep a local copy of counter mode "key" */ + memcpy(X, ctx->X, sizeof(X)); for (i = 0; i*SKEIN1024_BLOCK_BYTES < byteCnt; i++) { - ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); /* build the counter block */ + /* build the counter block */ + ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); Skein_Start_New_Type(ctx, OUT_FINAL); - Skein1024_Process_Block(ctx, ctx->b, 1, sizeof(u64)); /* run "counter mode" */ - n = byteCnt - i*SKEIN1024_BLOCK_BYTES; /* number of output bytes left to go */ + /* run "counter mode" */ + Skein1024_Process_Block(ctx, ctx->b, 1, sizeof(u64)); + /* number of output bytes left to go */ + n = byteCnt - i*SKEIN1024_BLOCK_BYTES; if (n >= SKEIN1024_BLOCK_BYTES) n = SKEIN1024_BLOCK_BYTES; - Skein_Put64_LSB_First(hashVal+i*SKEIN1024_BLOCK_BYTES, ctx->X, n); /* "output" the ctr mode bytes */ - Skein_Show_Final(1024, &ctx->h, n, hashVal+i*SKEIN1024_BLOCK_BYTES); - memcpy(ctx->X, X, sizeof(X)); /* restore the counter mode key for next time */ + /* "output" the ctr mode bytes */ + Skein_Put64_LSB_First(hashVal+i*SKEIN1024_BLOCK_BYTES, ctx->X, + n); + Skein_Show_Final(1024, &ctx->h, n, + hashVal+i*SKEIN1024_BLOCK_BYTES); + /* restore the counter mode key for next time */ + memcpy(ctx->X, X, sizeof(X)); } return SKEIN_SUCCESS; } @@ -587,14 +742,20 @@ int Skein1024_Final(struct skein1024_ctx *ctx, u8 *hashVal) /* finalize the hash computation and output the block, no OUTPUT stage */ int Skein_256_Final_Pad(struct skein_256_ctx *ctx, u8 *hashVal) { - Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ + /* catch uninitialized context */ + Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); - ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ - if (ctx->h.bCnt < SKEIN_256_BLOCK_BYTES) /* zero pad b[] if necessary */ - memset(&ctx->b[ctx->h.bCnt], 0, SKEIN_256_BLOCK_BYTES - ctx->h.bCnt); - Skein_256_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); /* process the final block */ + /* tag as the final block */ + ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; + /* zero pad b[] if necessary */ + if (ctx->h.bCnt < SKEIN_256_BLOCK_BYTES) + memset(&ctx->b[ctx->h.bCnt], 0, + SKEIN_256_BLOCK_BYTES - ctx->h.bCnt); + /* process the final block */ + Skein_256_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); - Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN_256_BLOCK_BYTES); /* "output" the state bytes */ + /* "output" the state bytes */ + Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN_256_BLOCK_BYTES); return SKEIN_SUCCESS; } @@ -603,14 +764,20 @@ int Skein_256_Final_Pad(struct skein_256_ctx *ctx, u8 *hashVal) /* finalize the hash computation and output the block, no OUTPUT stage */ int Skein_512_Final_Pad(struct skein_512_ctx *ctx, u8 *hashVal) { - Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ + /* catch uninitialized context */ + Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); - ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ - if (ctx->h.bCnt < SKEIN_512_BLOCK_BYTES) /* zero pad b[] if necessary */ - memset(&ctx->b[ctx->h.bCnt], 0, SKEIN_512_BLOCK_BYTES - ctx->h.bCnt); - Skein_512_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); /* process the final block */ + /* tag as the final block */ + ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; + /* zero pad b[] if necessary */ + if (ctx->h.bCnt < SKEIN_512_BLOCK_BYTES) + memset(&ctx->b[ctx->h.bCnt], 0, + SKEIN_512_BLOCK_BYTES - ctx->h.bCnt); + /* process the final block */ + Skein_512_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); - Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN_512_BLOCK_BYTES); /* "output" the state bytes */ + /* "output" the state bytes */ + Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN_512_BLOCK_BYTES); return SKEIN_SUCCESS; } @@ -619,14 +786,20 @@ int Skein_512_Final_Pad(struct skein_512_ctx *ctx, u8 *hashVal) /* finalize the hash computation and output the block, no OUTPUT stage */ int Skein1024_Final_Pad(struct skein1024_ctx *ctx, u8 *hashVal) { - Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ + /* catch uninitialized context */ + Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); - ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ - if (ctx->h.bCnt < SKEIN1024_BLOCK_BYTES) /* zero pad b[] if necessary */ - memset(&ctx->b[ctx->h.bCnt], 0, SKEIN1024_BLOCK_BYTES - ctx->h.bCnt); - Skein1024_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); /* process the final block */ + /* tag as the final block */ + ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; + /* zero pad b[] if necessary */ + if (ctx->h.bCnt < SKEIN1024_BLOCK_BYTES) + memset(&ctx->b[ctx->h.bCnt], 0, + SKEIN1024_BLOCK_BYTES - ctx->h.bCnt); + /* process the final block */ + Skein1024_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); - Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN1024_BLOCK_BYTES); /* "output" the state bytes */ + /* "output" the state bytes */ + Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN1024_BLOCK_BYTES); return SKEIN_SUCCESS; } @@ -638,25 +811,36 @@ int Skein_256_Output(struct skein_256_ctx *ctx, u8 *hashVal) { size_t i, n, byteCnt; u64 X[SKEIN_256_STATE_WORDS]; - Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ + /* catch uninitialized context */ + Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* now output the result */ - byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ + /* total number of output bytes */ + byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* run Threefish in "counter mode" to generate output */ - memset(ctx->b, 0, sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ - memcpy(X, ctx->X, sizeof(X)); /* keep a local copy of counter mode "key" */ + /* zero out b[], so it can hold the counter */ + memset(ctx->b, 0, sizeof(ctx->b)); + /* keep a local copy of counter mode "key" */ + memcpy(X, ctx->X, sizeof(X)); for (i = 0; i*SKEIN_256_BLOCK_BYTES < byteCnt; i++) { - ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); /* build the counter block */ + /* build the counter block */ + ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); Skein_Start_New_Type(ctx, OUT_FINAL); - Skein_256_Process_Block(ctx, ctx->b, 1, sizeof(u64)); /* run "counter mode" */ - n = byteCnt - i*SKEIN_256_BLOCK_BYTES; /* number of output bytes left to go */ + /* run "counter mode" */ + Skein_256_Process_Block(ctx, ctx->b, 1, sizeof(u64)); + /* number of output bytes left to go */ + n = byteCnt - i*SKEIN_256_BLOCK_BYTES; if (n >= SKEIN_256_BLOCK_BYTES) n = SKEIN_256_BLOCK_BYTES; - Skein_Put64_LSB_First(hashVal+i*SKEIN_256_BLOCK_BYTES, ctx->X, n); /* "output" the ctr mode bytes */ - Skein_Show_Final(256, &ctx->h, n, hashVal+i*SKEIN_256_BLOCK_BYTES); - memcpy(ctx->X, X, sizeof(X)); /* restore the counter mode key for next time */ + /* "output" the ctr mode bytes */ + Skein_Put64_LSB_First(hashVal+i*SKEIN_256_BLOCK_BYTES, ctx->X, + n); + Skein_Show_Final(256, &ctx->h, n, + hashVal+i*SKEIN_256_BLOCK_BYTES); + /* restore the counter mode key for next time */ + memcpy(ctx->X, X, sizeof(X)); } return SKEIN_SUCCESS; } @@ -667,25 +851,36 @@ int Skein_512_Output(struct skein_512_ctx *ctx, u8 *hashVal) { size_t i, n, byteCnt; u64 X[SKEIN_512_STATE_WORDS]; - Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ + /* catch uninitialized context */ + Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* now output the result */ - byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ + /* total number of output bytes */ + byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* run Threefish in "counter mode" to generate output */ - memset(ctx->b, 0, sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ - memcpy(X, ctx->X, sizeof(X)); /* keep a local copy of counter mode "key" */ + /* zero out b[], so it can hold the counter */ + memset(ctx->b, 0, sizeof(ctx->b)); + /* keep a local copy of counter mode "key" */ + memcpy(X, ctx->X, sizeof(X)); for (i = 0; i*SKEIN_512_BLOCK_BYTES < byteCnt; i++) { - ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); /* build the counter block */ + /* build the counter block */ + ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); Skein_Start_New_Type(ctx, OUT_FINAL); - Skein_512_Process_Block(ctx, ctx->b, 1, sizeof(u64)); /* run "counter mode" */ - n = byteCnt - i*SKEIN_512_BLOCK_BYTES; /* number of output bytes left to go */ + /* run "counter mode" */ + Skein_512_Process_Block(ctx, ctx->b, 1, sizeof(u64)); + /* number of output bytes left to go */ + n = byteCnt - i*SKEIN_512_BLOCK_BYTES; if (n >= SKEIN_512_BLOCK_BYTES) n = SKEIN_512_BLOCK_BYTES; - Skein_Put64_LSB_First(hashVal+i*SKEIN_512_BLOCK_BYTES, ctx->X, n); /* "output" the ctr mode bytes */ - Skein_Show_Final(256, &ctx->h, n, hashVal+i*SKEIN_512_BLOCK_BYTES); - memcpy(ctx->X, X, sizeof(X)); /* restore the counter mode key for next time */ + /* "output" the ctr mode bytes */ + Skein_Put64_LSB_First(hashVal+i*SKEIN_512_BLOCK_BYTES, ctx->X, + n); + Skein_Show_Final(256, &ctx->h, n, + hashVal+i*SKEIN_512_BLOCK_BYTES); + /* restore the counter mode key for next time */ + memcpy(ctx->X, X, sizeof(X)); } return SKEIN_SUCCESS; } @@ -696,25 +891,36 @@ int Skein1024_Output(struct skein1024_ctx *ctx, u8 *hashVal) { size_t i, n, byteCnt; u64 X[SKEIN1024_STATE_WORDS]; - Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); /* catch uninitialized context */ + /* catch uninitialized context */ + Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); /* now output the result */ - byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ + /* total number of output bytes */ + byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* run Threefish in "counter mode" to generate output */ - memset(ctx->b, 0, sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ - memcpy(X, ctx->X, sizeof(X)); /* keep a local copy of counter mode "key" */ + /* zero out b[], so it can hold the counter */ + memset(ctx->b, 0, sizeof(ctx->b)); + /* keep a local copy of counter mode "key" */ + memcpy(X, ctx->X, sizeof(X)); for (i = 0; i*SKEIN1024_BLOCK_BYTES < byteCnt; i++) { - ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); /* build the counter block */ + /* build the counter block */ + ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); Skein_Start_New_Type(ctx, OUT_FINAL); - Skein1024_Process_Block(ctx, ctx->b, 1, sizeof(u64)); /* run "counter mode" */ - n = byteCnt - i*SKEIN1024_BLOCK_BYTES; /* number of output bytes left to go */ + /* run "counter mode" */ + Skein1024_Process_Block(ctx, ctx->b, 1, sizeof(u64)); + /* number of output bytes left to go */ + n = byteCnt - i*SKEIN1024_BLOCK_BYTES; if (n >= SKEIN1024_BLOCK_BYTES) n = SKEIN1024_BLOCK_BYTES; - Skein_Put64_LSB_First(hashVal+i*SKEIN1024_BLOCK_BYTES, ctx->X, n); /* "output" the ctr mode bytes */ - Skein_Show_Final(256, &ctx->h, n, hashVal+i*SKEIN1024_BLOCK_BYTES); - memcpy(ctx->X, X, sizeof(X)); /* restore the counter mode key for next time */ + /* "output" the ctr mode bytes */ + Skein_Put64_LSB_First(hashVal+i*SKEIN1024_BLOCK_BYTES, ctx->X, + n); + Skein_Show_Final(256, &ctx->h, n, + hashVal+i*SKEIN1024_BLOCK_BYTES); + /* restore the counter mode key for next time */ + memcpy(ctx->X, X, sizeof(X)); } return SKEIN_SUCCESS; } diff --git a/drivers/staging/skein/skeinApi.c b/drivers/staging/skein/skeinApi.c index 3ebb1d60ef93..f0015d5b10f5 100644 --- a/drivers/staging/skein/skeinApi.c +++ b/drivers/staging/skein/skeinApi.c @@ -46,9 +46,9 @@ int skeinInit(struct skein_ctx *ctx, size_t hashBitLen) Skein_Assert(ctx, SKEIN_FAIL); /* - * The following two lines rely of the fact that the real Skein contexts are - * a union in out context and thus have tha maximum memory available. - * The beauty of C :-) . + * The following two lines rely of the fact that the real Skein + * contexts are a union in out context and thus have tha maximum + * memory available. The beauty of C :-) . */ X = ctx->m.s256.X; Xlen = ctx->skeinSize/8; @@ -72,7 +72,10 @@ int skeinInit(struct skein_ctx *ctx, size_t hashBitLen) } if (ret == SKEIN_SUCCESS) { - /* Save chaining variables for this combination of size and hashBitLen */ + /* + * Save chaining variables for this combination of size and + * hashBitLen + */ memcpy(ctx->XSave, X, Xlen); } return ret; @@ -113,7 +116,10 @@ int skeinMacInit(struct skein_ctx *ctx, const u8 *key, size_t keyLen, break; } if (ret == SKEIN_SUCCESS) { - /* Save chaining variables for this combination of key, keyLen, hashBitLen */ + /* + * Save chaining variables for this combination of key, + * keyLen, hashBitLen + */ memcpy(ctx->XSave, X, Xlen); } return ret; @@ -125,9 +131,9 @@ void skeinReset(struct skein_ctx *ctx) u64 *X = NULL; /* - * The following two lines rely of the fact that the real Skein contexts are - * a union in out context and thus have tha maximum memory available. - * The beautiy of C :-) . + * The following two lines rely of the fact that the real Skein + * contexts are a union in out context and thus have tha maximum + * memory available. The beautiy of C :-) . */ X = ctx->m.s256.X; Xlen = ctx->skeinSize/8; @@ -146,13 +152,16 @@ int skeinUpdate(struct skein_ctx *ctx, const u8 *msg, switch (ctx->skeinSize) { case Skein256: - ret = Skein_256_Update(&ctx->m.s256, (const u8 *)msg, msgByteCnt); + ret = Skein_256_Update(&ctx->m.s256, (const u8 *)msg, + msgByteCnt); break; case Skein512: - ret = Skein_512_Update(&ctx->m.s512, (const u8 *)msg, msgByteCnt); + ret = Skein_512_Update(&ctx->m.s512, (const u8 *)msg, + msgByteCnt); break; case Skein1024: - ret = Skein1024_Update(&ctx->m.s1024, (const u8 *)msg, msgByteCnt); + ret = Skein1024_Update(&ctx->m.s1024, (const u8 *)msg, + msgByteCnt); break; } return ret; @@ -164,15 +173,19 @@ int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg, { /* * I've used the bit pad implementation from skein_test.c (see NIST CD) - * and modified it to use the convenience functions and added some pointer - * arithmetic. + * and modified it to use the convenience functions and added some + * pointer arithmetic. */ size_t length; u8 mask; u8 *up; - /* only the final Update() call is allowed do partial bytes, else assert an error */ - Skein_Assert((ctx->m.h.T[1] & SKEIN_T1_FLAG_BIT_PAD) == 0 || msgBitCnt == 0, SKEIN_FAIL); + /* + * only the final Update() call is allowed do partial bytes, else + * assert an error + */ + Skein_Assert((ctx->m.h.T[1] & SKEIN_T1_FLAG_BIT_PAD) == 0 || + msgBitCnt == 0, SKEIN_FAIL); /* if number of bits is a multiple of bytes - that's easy */ if ((msgBitCnt & 0x7) == 0) { @@ -188,13 +201,18 @@ int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg, */ up = (u8 *)ctx->m.s256.X + ctx->skeinSize / 8; - Skein_Set_Bit_Pad_Flag(ctx->m.h); /* set tweak flag for the skeinFinal call */ + /* set tweak flag for the skeinFinal call */ + Skein_Set_Bit_Pad_Flag(ctx->m.h); /* now "pad" the final partial byte the way NIST likes */ - length = ctx->m.h.bCnt; /* get the bCnt value (same location for all block sizes) */ - Skein_assert(length != 0); /* internal sanity check: there IS a partial byte in the buffer! */ - mask = (u8) (1u << (7 - (msgBitCnt & 7))); /* partial byte bit mask */ - up[length-1] = (u8)((up[length-1] & (0-mask))|mask); /* apply bit padding on final byte (in the buffer) */ + /* get the bCnt value (same location for all block sizes) */ + length = ctx->m.h.bCnt; + /* internal sanity check: there IS a partial byte in the buffer! */ + Skein_assert(length != 0); + /* partial byte bit mask */ + mask = (u8) (1u << (7 - (msgBitCnt & 7))); + /* apply bit padding on final byte (in the buffer) */ + up[length-1] = (u8)((up[length-1] & (0-mask))|mask); return SKEIN_SUCCESS; } diff --git a/drivers/staging/skein/skeinBlockNo3F.c b/drivers/staging/skein/skeinBlockNo3F.c index 376cd63d8f83..69176389fef9 100644 --- a/drivers/staging/skein/skeinBlockNo3F.c +++ b/drivers/staging/skein/skeinBlockNo3F.c @@ -11,10 +11,10 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, struct threefish_key key; u64 tweak[2]; int i; - u64 w[SKEIN_256_STATE_WORDS]; /* local copy of input block */ + u64 w[SKEIN_256_STATE_WORDS]; /* local copy of input block */ u64 words[3]; - Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ + Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ tweak[0] = ctx->h.T[0]; tweak[1] = ctx->h.T[1]; @@ -36,13 +36,14 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, threefishSetKey(&key, Threefish256, ctx->X, tweak); - Skein_Get64_LSB_First(w, blkPtr, SKEIN_256_STATE_WORDS); /* get input block in little-endian format */ + /* get input block in little-endian format */ + Skein_Get64_LSB_First(w, blkPtr, SKEIN_256_STATE_WORDS); threefishEncryptBlockWords(&key, w, ctx->X); blkPtr += SKEIN_256_BLOCK_BYTES; - /* do the final "feedforward" xor, update context chaining vars */ + /* do the final "feedforward" xor, update ctx chaining vars */ ctx->X[0] = ctx->X[0] ^ w[0]; ctx->X[1] = ctx->X[1] ^ w[1]; ctx->X[2] = ctx->X[2] ^ w[2]; @@ -62,9 +63,9 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, u64 tweak[2]; int i; u64 words[3]; - u64 w[SKEIN_512_STATE_WORDS]; /* local copy of input block */ + u64 w[SKEIN_512_STATE_WORDS]; /* local copy of input block */ - Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ + Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ tweak[0] = ctx->h.T[0]; tweak[1] = ctx->h.T[1]; @@ -86,13 +87,14 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, threefishSetKey(&key, Threefish512, ctx->X, tweak); - Skein_Get64_LSB_First(w, blkPtr, SKEIN_512_STATE_WORDS); /* get input block in little-endian format */ + /* get input block in little-endian format */ + Skein_Get64_LSB_First(w, blkPtr, SKEIN_512_STATE_WORDS); threefishEncryptBlockWords(&key, w, ctx->X); blkPtr += SKEIN_512_BLOCK_BYTES; - /* do the final "feedforward" xor, update context chaining vars */ + /* do the final "feedforward" xor, update ctx chaining vars */ ctx->X[0] = ctx->X[0] ^ w[0]; ctx->X[1] = ctx->X[1] ^ w[1]; ctx->X[2] = ctx->X[2] ^ w[2]; @@ -116,9 +118,9 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, u64 tweak[2]; int i; u64 words[3]; - u64 w[SKEIN1024_STATE_WORDS]; /* local copy of input block */ + u64 w[SKEIN1024_STATE_WORDS]; /* local copy of input block */ - Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ + Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ tweak[0] = ctx->h.T[0]; tweak[1] = ctx->h.T[1]; @@ -140,13 +142,14 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, threefishSetKey(&key, Threefish1024, ctx->X, tweak); - Skein_Get64_LSB_First(w, blkPtr, SKEIN1024_STATE_WORDS); /* get input block in little-endian format */ + /* get input block in little-endian format */ + Skein_Get64_LSB_First(w, blkPtr, SKEIN1024_STATE_WORDS); threefishEncryptBlockWords(&key, w, ctx->X); blkPtr += SKEIN1024_BLOCK_BYTES; - /* do the final "feedforward" xor, update context chaining vars */ + /* do the final "feedforward" xor, update ctx chaining vars */ ctx->X[0] = ctx->X[0] ^ w[0]; ctx->X[1] = ctx->X[1] ^ w[1]; ctx->X[2] = ctx->X[2] ^ w[2]; diff --git a/drivers/staging/skein/skein_block.c b/drivers/staging/skein/skein_block.c index d315f547feae..780b4936f783 100644 --- a/drivers/staging/skein/skein_block.c +++ b/drivers/staging/skein/skein_block.c @@ -18,14 +18,14 @@ #include #ifndef SKEIN_USE_ASM -#define SKEIN_USE_ASM (0) /* default is all C code (no ASM) */ +#define SKEIN_USE_ASM (0) /* default is all C code (no ASM) */ #endif #ifndef SKEIN_LOOP -#define SKEIN_LOOP 001 /* default: unroll 256 and 512, but not 1024 */ +#define SKEIN_LOOP 001 /* default: unroll 256 and 512, but not 1024 */ #endif -#define BLK_BITS (WCNT*64) /* some useful definitions for code here */ +#define BLK_BITS (WCNT*64) /* some useful definitions for code here */ #define KW_TWK_BASE (0) #define KW_KEY_BASE (3) #define ks (kw + KW_KEY_BASE) @@ -39,7 +39,8 @@ /***************************** Skein_256 ******************************/ #if !(SKEIN_USE_ASM & 256) -void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, size_t blkCnt, size_t byteCntAdd) +void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, + size_t blkCnt, size_t byteCntAdd) { /* do it in C */ enum { WCNT = SKEIN_256_STATE_WORDS @@ -47,7 +48,7 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, size_t #undef RCNT #define RCNT (SKEIN_256_ROUNDS_TOTAL/8) -#ifdef SKEIN_LOOP /* configure how much to unroll the loop */ +#ifdef SKEIN_LOOP /* configure how much to unroll the loop */ #define SKEIN_UNROLL_256 (((SKEIN_LOOP)/100)%10) #else #define SKEIN_UNROLL_256 (0) @@ -55,25 +56,28 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, size_t #if SKEIN_UNROLL_256 #if (RCNT % SKEIN_UNROLL_256) -#error "Invalid SKEIN_UNROLL_256" /* sanity check on unroll count */ +#error "Invalid SKEIN_UNROLL_256" /* sanity check on unroll count */ #endif size_t r; - u64 kw[WCNT+4+RCNT*2]; /* key schedule words : chaining vars + tweak + "rotation"*/ + u64 kw[WCNT+4+RCNT*2]; /* key schedule: chaining vars + tweak + "rot"*/ #else - u64 kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ + u64 kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ #endif - u64 X0, X1, X2, X3; /* local copy of context vars, for speed */ - u64 w[WCNT]; /* local copy of input block */ + u64 X0, X1, X2, X3; /* local copy of context vars, for speed */ + u64 w[WCNT]; /* local copy of input block */ #ifdef SKEIN_DEBUG - const u64 *Xptr[4]; /* use for debugging (help compiler put Xn in registers) */ + const u64 *Xptr[4]; /* use for debugging (help cc put Xn in regs) */ Xptr[0] = &X0; Xptr[1] = &X1; Xptr[2] = &X2; Xptr[3] = &X3; #endif - Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ + Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ ts[0] = ctx->h.T[0]; ts[1] = ctx->h.T[1]; do { - /* this implementation only supports 2**64 input bytes (no carry out here) */ - ts[0] += byteCntAdd; /* update processed length */ + /* + * this implementation only supports 2**64 input bytes + * (no carry out here) + */ + ts[0] += byteCntAdd; /* update processed length */ /* precompute the key schedule for this block */ ks[0] = ctx->X[0]; @@ -84,16 +88,19 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, size_t ts[2] = ts[0] ^ ts[1]; - Skein_Get64_LSB_First(w, blkPtr, WCNT); /* get input block in little-endian format */ + /* get input block in little-endian format */ + Skein_Get64_LSB_First(w, blkPtr, WCNT); DebugSaveTweak(ctx); Skein_Show_Block(BLK_BITS, &ctx->h, ctx->X, blkPtr, w, ks, ts); - X0 = w[0] + ks[0]; /* do the first full key injection */ + X0 = w[0] + ks[0]; /* do the first full key injection */ X1 = w[1] + ks[1] + ts[0]; X2 = w[2] + ks[2] + ts[1]; X3 = w[3] + ks[3]; - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, Xptr); /* show starting state values */ + /* show starting state values */ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, + Xptr); blkPtr += SKEIN_256_BLOCK_BYTES; @@ -104,31 +111,34 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, size_t X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ #if SKEIN_UNROLL_256 == 0 -#define R256(p0, p1, p2, p3, ROT, rNum) /* fully unrolled */ \ - Round256(p0, p1, p2, p3, ROT, rNum) \ +#define R256(p0, p1, p2, p3, ROT, rNum) /* fully unrolled */ \ + Round256(p0, p1, p2, p3, ROT, rNum) \ Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rNum, Xptr); -#define I256(R) \ - X0 += ks[((R)+1) % 5]; /* inject the key schedule value */ \ - X1 += ks[((R)+2) % 5] + ts[((R)+1) % 3]; \ - X2 += ks[((R)+3) % 5] + ts[((R)+2) % 3]; \ - X3 += ks[((R)+4) % 5] + (R)+1; \ +#define I256(R) \ + /* inject the key schedule value */ \ + X0 += ks[((R)+1) % 5]; \ + X1 += ks[((R)+2) % 5] + ts[((R)+1) % 3]; \ + X2 += ks[((R)+3) % 5] + ts[((R)+2) % 3]; \ + X3 += ks[((R)+4) % 5] + (R)+1; \ Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); -#else /* looping version */ -#define R256(p0, p1, p2, p3, ROT, rNum) \ - Round256(p0, p1, p2, p3, ROT, rNum) \ +#else /* looping version */ +#define R256(p0, p1, p2, p3, ROT, rNum) \ + Round256(p0, p1, p2, p3, ROT, rNum) \ Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rNum, Xptr); -#define I256(R) \ - X0 += ks[r+(R)+0]; /* inject the key schedule value */ \ - X1 += ks[r+(R)+1] + ts[r+(R)+0]; \ - X2 += ks[r+(R)+2] + ts[r+(R)+1]; \ - X3 += ks[r+(R)+3] + r+(R); \ - ks[r + (R) + 4] = ks[r + (R) - 1]; /* rotate key schedule */\ - ts[r + (R) + 2] = ts[r + (R) - 1]; \ +#define I256(R) \ + /* inject the key schedule value */ \ + X0 += ks[r+(R)+0]; \ + X1 += ks[r+(R)+1] + ts[r+(R)+0]; \ + X2 += ks[r+(R)+2] + ts[r+(R)+1]; \ + X3 += ks[r+(R)+3] + r+(R); \ + /* rotate key schedule */ \ + ks[r + (R) + 4] = ks[r + (R) - 1]; \ + ts[r + (R) + 2] = ts[r + (R) - 1]; \ Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); - for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_256) /* loop thru it */ + for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_256) #endif { #define R256_8_rounds(R) \ @@ -145,7 +155,10 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, size_t R256_8_rounds(0); -#define R256_Unroll_R(NN) ((SKEIN_UNROLL_256 == 0 && SKEIN_256_ROUNDS_TOTAL/8 > (NN)) || (SKEIN_UNROLL_256 > (NN))) +#define R256_Unroll_R(NN) \ + ((SKEIN_UNROLL_256 == 0 && \ + SKEIN_256_ROUNDS_TOTAL/8 > (NN)) || \ + (SKEIN_UNROLL_256 > (NN))) #if R256_Unroll_R(1) R256_8_rounds(1); @@ -193,7 +206,7 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, size_t #error "need more unrolling in Skein_256_Process_Block" #endif } - /* do the final "feedforward" xor, update context chaining vars */ + /* do the final "feedforward" xor, update context chaining */ ctx->X[0] = X0 ^ w[0]; ctx->X[1] = X1 ^ w[1]; ctx->X[2] = X2 ^ w[2]; @@ -223,7 +236,8 @@ unsigned int Skein_256_Unroll_Cnt(void) /***************************** Skein_512 ******************************/ #if !(SKEIN_USE_ASM & 512) -void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, size_t blkCnt, size_t byteCntAdd) +void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, + size_t blkCnt, size_t byteCntAdd) { /* do it in C */ enum { WCNT = SKEIN_512_STATE_WORDS @@ -231,7 +245,7 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, size_t #undef RCNT #define RCNT (SKEIN_512_ROUNDS_TOTAL/8) -#ifdef SKEIN_LOOP /* configure how much to unroll the loop */ +#ifdef SKEIN_LOOP /* configure how much to unroll the loop */ #define SKEIN_UNROLL_512 (((SKEIN_LOOP)/10)%10) #else #define SKEIN_UNROLL_512 (0) @@ -239,27 +253,30 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, size_t #if SKEIN_UNROLL_512 #if (RCNT % SKEIN_UNROLL_512) -#error "Invalid SKEIN_UNROLL_512" /* sanity check on unroll count */ +#error "Invalid SKEIN_UNROLL_512" /* sanity check on unroll count */ #endif size_t r; - u64 kw[WCNT+4+RCNT*2]; /* key schedule words : chaining vars + tweak + "rotation"*/ + u64 kw[WCNT+4+RCNT*2]; /* key sched: chaining vars + tweak + "rot"*/ #else - u64 kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ + u64 kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ #endif - u64 X0, X1, X2, X3, X4, X5, X6, X7; /* local copy of vars, for speed */ - u64 w[WCNT]; /* local copy of input block */ + u64 X0, X1, X2, X3, X4, X5, X6, X7; /* local copies, for speed */ + u64 w[WCNT]; /* local copy of input block */ #ifdef SKEIN_DEBUG - const u64 *Xptr[8]; /* use for debugging (help compiler put Xn in registers) */ + const u64 *Xptr[8]; /* use for debugging (help cc put Xn in regs) */ Xptr[0] = &X0; Xptr[1] = &X1; Xptr[2] = &X2; Xptr[3] = &X3; Xptr[4] = &X4; Xptr[5] = &X5; Xptr[6] = &X6; Xptr[7] = &X7; #endif - Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ + Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ ts[0] = ctx->h.T[0]; ts[1] = ctx->h.T[1]; do { - /* this implementation only supports 2**64 input bytes (no carry out here) */ - ts[0] += byteCntAdd; /* update processed length */ + /* + * this implementation only supports 2**64 input bytes + * (no carry out here) + */ + ts[0] += byteCntAdd; /* update processed length */ /* precompute the key schedule for this block */ ks[0] = ctx->X[0]; @@ -275,11 +292,12 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, size_t ts[2] = ts[0] ^ ts[1]; - Skein_Get64_LSB_First(w, blkPtr, WCNT); /* get input block in little-endian format */ + /* get input block in little-endian format */ + Skein_Get64_LSB_First(w, blkPtr, WCNT); DebugSaveTweak(ctx); Skein_Show_Block(BLK_BITS, &ctx->h, ctx->X, blkPtr, w, ks, ts); - X0 = w[0] + ks[0]; /* do the first full key injection */ + X0 = w[0] + ks[0]; /* do the first full key injection */ X1 = w[1] + ks[1]; X2 = w[2] + ks[2]; X3 = w[3] + ks[3]; @@ -290,65 +308,72 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, size_t blkPtr += SKEIN_512_BLOCK_BYTES; - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, Xptr); + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, + Xptr); /* run the rounds */ -#define Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \ - X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ - X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ - X##p4 += X##p5; X##p5 = RotL_64(X##p5, ROT##_2); X##p5 ^= X##p4; \ - X##p6 += X##p7; X##p7 = RotL_64(X##p7, ROT##_3); X##p7 ^= X##p6; \ +#define Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \ + X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ + X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ + X##p4 += X##p5; X##p5 = RotL_64(X##p5, ROT##_2); X##p5 ^= X##p4; \ + X##p6 += X##p7; X##p7 = RotL_64(X##p7, ROT##_3); X##p7 ^= X##p6; \ #if SKEIN_UNROLL_512 == 0 -#define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) /* unrolled */ \ - Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rNum, Xptr); - -#define I512(R) \ - X0 += ks[((R) + 1) % 9]; /* inject the key schedule value */ \ - X1 += ks[((R) + 2) % 9]; \ - X2 += ks[((R) + 3) % 9]; \ - X3 += ks[((R) + 4) % 9]; \ - X4 += ks[((R) + 5) % 9]; \ - X5 += ks[((R) + 6) % 9] + ts[((R) + 1) % 3]; \ - X6 += ks[((R) + 7) % 9] + ts[((R) + 2) % 3]; \ - X7 += ks[((R) + 8) % 9] + (R) + 1; \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); -#else /* looping version */ -#define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \ - Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rNum, Xptr); - -#define I512(R) \ - X0 += ks[r + (R) + 0]; /* inject the key schedule value */ \ - X1 += ks[r + (R) + 1]; \ - X2 += ks[r + (R) + 2]; \ - X3 += ks[r + (R) + 3]; \ - X4 += ks[r + (R) + 4]; \ - X5 += ks[r + (R) + 5] + ts[r + (R) + 0]; \ - X6 += ks[r + (R) + 6] + ts[r + (R) + 1]; \ - X7 += ks[r + (R) + 7] + r + (R); \ - ks[r + (R) + 8] = ks[r + (R) - 1]; /* rotate key schedule */ \ - ts[r + (R) + 2] = ts[r + (R) - 1]; \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); - - for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_512) /* loop thru it */ -#endif /* end of looped code definitions */ +#define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) /* unrolled */ \ + Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rNum, Xptr); + +#define I512(R) \ + /* inject the key schedule value */ \ + X0 += ks[((R) + 1) % 9]; \ + X1 += ks[((R) + 2) % 9]; \ + X2 += ks[((R) + 3) % 9]; \ + X3 += ks[((R) + 4) % 9]; \ + X4 += ks[((R) + 5) % 9]; \ + X5 += ks[((R) + 6) % 9] + ts[((R) + 1) % 3]; \ + X6 += ks[((R) + 7) % 9] + ts[((R) + 2) % 3]; \ + X7 += ks[((R) + 8) % 9] + (R) + 1; \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); +#else /* looping version */ +#define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \ + Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rNum, Xptr); + +#define I512(R) \ + /* inject the key schedule value */ \ + X0 += ks[r + (R) + 0]; \ + X1 += ks[r + (R) + 1]; \ + X2 += ks[r + (R) + 2]; \ + X3 += ks[r + (R) + 3]; \ + X4 += ks[r + (R) + 4]; \ + X5 += ks[r + (R) + 5] + ts[r + (R) + 0]; \ + X6 += ks[r + (R) + 6] + ts[r + (R) + 1]; \ + X7 += ks[r + (R) + 7] + r + (R); \ + /* rotate key schedule */ \ + ks[r + (R) + 8] = ks[r + (R) - 1]; \ + ts[r + (R) + 2] = ts[r + (R) - 1]; \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); + + for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_512) +#endif /* end of looped code definitions */ { #define R512_8_rounds(R) /* do 8 full rounds */ \ - R512(0, 1, 2, 3, 4, 5, 6, 7, R_512_0, 8 * (R) + 1); \ - R512(2, 1, 4, 7, 6, 5, 0, 3, R_512_1, 8 * (R) + 2); \ - R512(4, 1, 6, 3, 0, 5, 2, 7, R_512_2, 8 * (R) + 3); \ - R512(6, 1, 0, 7, 2, 5, 4, 3, R_512_3, 8 * (R) + 4); \ - I512(2 * (R)); \ - R512(0, 1, 2, 3, 4, 5, 6, 7, R_512_4, 8 * (R) + 5); \ - R512(2, 1, 4, 7, 6, 5, 0, 3, R_512_5, 8 * (R) + 6); \ - R512(4, 1, 6, 3, 0, 5, 2, 7, R_512_6, 8 * (R) + 7); \ - R512(6, 1, 0, 7, 2, 5, 4, 3, R_512_7, 8 * (R) + 8); \ - I512(2 * (R) + 1); /* and key injection */ + R512(0, 1, 2, 3, 4, 5, 6, 7, R_512_0, 8 * (R) + 1); \ + R512(2, 1, 4, 7, 6, 5, 0, 3, R_512_1, 8 * (R) + 2); \ + R512(4, 1, 6, 3, 0, 5, 2, 7, R_512_2, 8 * (R) + 3); \ + R512(6, 1, 0, 7, 2, 5, 4, 3, R_512_3, 8 * (R) + 4); \ + I512(2 * (R)); \ + R512(0, 1, 2, 3, 4, 5, 6, 7, R_512_4, 8 * (R) + 5); \ + R512(2, 1, 4, 7, 6, 5, 0, 3, R_512_5, 8 * (R) + 6); \ + R512(4, 1, 6, 3, 0, 5, 2, 7, R_512_6, 8 * (R) + 7); \ + R512(6, 1, 0, 7, 2, 5, 4, 3, R_512_7, 8 * (R) + 8); \ + I512(2 * (R) + 1); /* and key injection */ R512_8_rounds(0); -#define R512_Unroll_R(NN) ((SKEIN_UNROLL_512 == 0 && SKEIN_512_ROUNDS_TOTAL/8 > (NN)) || (SKEIN_UNROLL_512 > (NN))) +#define R512_Unroll_R(NN) \ + ((SKEIN_UNROLL_512 == 0 && \ + SKEIN_512_ROUNDS_TOTAL/8 > (NN)) || \ + (SKEIN_UNROLL_512 > (NN))) #if R512_Unroll_R(1) R512_8_rounds(1); @@ -397,7 +422,7 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, size_t #endif } - /* do the final "feedforward" xor, update context chaining vars */ + /* do the final "feedforward" xor, update context chaining */ ctx->X[0] = X0 ^ w[0]; ctx->X[1] = X1 ^ w[1]; ctx->X[2] = X2 ^ w[2]; @@ -430,7 +455,8 @@ unsigned int Skein_512_Unroll_Cnt(void) /***************************** Skein1024 ******************************/ #if !(SKEIN_USE_ASM & 1024) -void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, size_t blkCnt, size_t byteCntAdd) +void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, \ + size_t blkCnt, size_t byteCntAdd) { /* do it in C, always looping (unrolled is bigger AND slower!) */ enum { WCNT = SKEIN1024_STATE_WORDS @@ -438,7 +464,7 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, size_t #undef RCNT #define RCNT (SKEIN1024_ROUNDS_TOTAL/8) -#ifdef SKEIN_LOOP /* configure how much to unroll the loop */ +#ifdef SKEIN_LOOP /* configure how much to unroll the loop */ #define SKEIN_UNROLL_1024 ((SKEIN_LOOP)%10) #else #define SKEIN_UNROLL_1024 (0) @@ -446,31 +472,35 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, size_t #if (SKEIN_UNROLL_1024 != 0) #if (RCNT % SKEIN_UNROLL_1024) -#error "Invalid SKEIN_UNROLL_1024" /* sanity check on unroll count */ +#error "Invalid SKEIN_UNROLL_1024" /* sanity check on unroll count */ #endif size_t r; - u64 kw[WCNT+4+RCNT*2]; /* key schedule words : chaining vars + tweak + "rotation"*/ + u64 kw[WCNT+4+RCNT*2]; /* key sched: chaining vars + tweak + "rot" */ #else - u64 kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ + u64 kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ #endif - u64 X00, X01, X02, X03, X04, X05, X06, X07, /* local copy of vars, for speed */ - X08, X09, X10, X11, X12, X13, X14, X15; - u64 w[WCNT]; /* local copy of input block */ + /* local copy of vars, for speed */ + u64 X00, X01, X02, X03, X04, X05, X06, X07, + X08, X09, X10, X11, X12, X13, X14, X15; + u64 w[WCNT]; /* local copy of input block */ #ifdef SKEIN_DEBUG - const u64 *Xptr[16]; /* use for debugging (help compiler put Xn in registers) */ + const u64 *Xptr[16]; /* use for debugging (help cc put Xn in regs) */ Xptr[0] = &X00; Xptr[1] = &X01; Xptr[2] = &X02; Xptr[3] = &X03; Xptr[4] = &X04; Xptr[5] = &X05; Xptr[6] = &X06; Xptr[7] = &X07; Xptr[8] = &X08; Xptr[9] = &X09; Xptr[10] = &X10; Xptr[11] = &X11; Xptr[12] = &X12; Xptr[13] = &X13; Xptr[14] = &X14; Xptr[15] = &X15; #endif - Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ + Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ ts[0] = ctx->h.T[0]; ts[1] = ctx->h.T[1]; do { - /* this implementation only supports 2**64 input bytes (no carry out here) */ - ts[0] += byteCntAdd; /* update processed length */ + /* + * this implementation only supports 2**64 input bytes + * (no carry out here) + */ + ts[0] += byteCntAdd; /* update processed length */ /* precompute the key schedule for this block */ ks[0] = ctx->X[0]; @@ -496,11 +526,12 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, size_t ts[2] = ts[0] ^ ts[1]; - Skein_Get64_LSB_First(w, blkPtr, WCNT); /* get input block in little-endian format */ + /* get input block in little-endian format */ + Skein_Get64_LSB_First(w, blkPtr, WCNT); DebugSaveTweak(ctx); Skein_Show_Block(BLK_BITS, &ctx->h, ctx->X, blkPtr, w, ks, ts); - X00 = w[0] + ks[0]; /* do the first full key injection */ + X00 = w[0] + ks[0]; /* do the first full key injection */ X01 = w[1] + ks[1]; X02 = w[2] + ks[2]; X03 = w[3] + ks[3]; @@ -517,85 +548,105 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, size_t X14 = w[14] + ks[14] + ts[1]; X15 = w[15] + ks[15]; - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, Xptr); + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, + Xptr); -#define Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, ROT, rNum) \ - X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ - X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ - X##p4 += X##p5; X##p5 = RotL_64(X##p5, ROT##_2); X##p5 ^= X##p4; \ - X##p6 += X##p7; X##p7 = RotL_64(X##p7, ROT##_3); X##p7 ^= X##p6; \ - X##p8 += X##p9; X##p9 = RotL_64(X##p9, ROT##_4); X##p9 ^= X##p8; \ - X##pA += X##pB; X##pB = RotL_64(X##pB, ROT##_5); X##pB ^= X##pA; \ - X##pC += X##pD; X##pD = RotL_64(X##pD, ROT##_6); X##pD ^= X##pC; \ - X##pE += X##pF; X##pF = RotL_64(X##pF, ROT##_7); X##pF ^= X##pE; \ +#define Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ + pF, ROT, rNum) \ + X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ + X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ + X##p4 += X##p5; X##p5 = RotL_64(X##p5, ROT##_2); X##p5 ^= X##p4; \ + X##p6 += X##p7; X##p7 = RotL_64(X##p7, ROT##_3); X##p7 ^= X##p6; \ + X##p8 += X##p9; X##p9 = RotL_64(X##p9, ROT##_4); X##p9 ^= X##p8; \ + X##pA += X##pB; X##pB = RotL_64(X##pB, ROT##_5); X##pB ^= X##pA; \ + X##pC += X##pD; X##pD = RotL_64(X##pD, ROT##_6); X##pD ^= X##pC; \ + X##pE += X##pF; X##pF = RotL_64(X##pF, ROT##_7); X##pF ^= X##pE; \ #if SKEIN_UNROLL_1024 == 0 -#define R1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, ROT, rn) \ - Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, ROT, rn) \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rn, Xptr); - -#define I1024(R) \ - X00 += ks[((R) + 1) % 17]; /* inject the key schedule value */ \ - X01 += ks[((R) + 2) % 17]; \ - X02 += ks[((R) + 3) % 17]; \ - X03 += ks[((R) + 4) % 17]; \ - X04 += ks[((R) + 5) % 17]; \ - X05 += ks[((R) + 6) % 17]; \ - X06 += ks[((R) + 7) % 17]; \ - X07 += ks[((R) + 8) % 17]; \ - X08 += ks[((R) + 9) % 17]; \ - X09 += ks[((R) + 10) % 17]; \ - X10 += ks[((R) + 11) % 17]; \ - X11 += ks[((R) + 12) % 17]; \ - X12 += ks[((R) + 13) % 17]; \ - X13 += ks[((R) + 14) % 17] + ts[((R) + 1) % 3]; \ - X14 += ks[((R) + 15) % 17] + ts[((R) + 2) % 3]; \ - X15 += ks[((R) + 16) % 17] + (R) + 1; \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); -#else /* looping version */ -#define R1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, ROT, rn) \ - Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, ROT, rn) \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rn, Xptr); - -#define I1024(R) \ - X00 += ks[r + (R) + 0]; /* inject the key schedule value */ \ - X01 += ks[r + (R) + 1]; \ - X02 += ks[r + (R) + 2]; \ - X03 += ks[r + (R) + 3]; \ - X04 += ks[r + (R) + 4]; \ - X05 += ks[r + (R) + 5]; \ - X06 += ks[r + (R) + 6]; \ - X07 += ks[r + (R) + 7]; \ - X08 += ks[r + (R) + 8]; \ - X09 += ks[r + (R) + 9]; \ - X10 += ks[r + (R) + 10]; \ - X11 += ks[r + (R) + 11]; \ - X12 += ks[r + (R) + 12]; \ - X13 += ks[r + (R) + 13] + ts[r + (R) + 0]; \ - X14 += ks[r + (R) + 14] + ts[r + (R) + 1]; \ - X15 += ks[r + (R) + 15] + r + (R); \ - ks[r + (R) + 16] = ks[r + (R) - 1]; /* rotate key schedule */\ - ts[r + (R) + 2] = ts[r + (R) - 1]; \ - Skein_Show_R_Ptr(BLK_BITSi, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); - - for (r = 1; r <= 2 * RCNT; r += 2 * SKEIN_UNROLL_1024) /* loop thru it */ +#define R1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, \ + ROT, rn) \ + Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ + pF, ROT, rn) \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rn, Xptr); + +#define I1024(R) \ + /* inject the key schedule value */ \ + X00 += ks[((R) + 1) % 17]; \ + X01 += ks[((R) + 2) % 17]; \ + X02 += ks[((R) + 3) % 17]; \ + X03 += ks[((R) + 4) % 17]; \ + X04 += ks[((R) + 5) % 17]; \ + X05 += ks[((R) + 6) % 17]; \ + X06 += ks[((R) + 7) % 17]; \ + X07 += ks[((R) + 8) % 17]; \ + X08 += ks[((R) + 9) % 17]; \ + X09 += ks[((R) + 10) % 17]; \ + X10 += ks[((R) + 11) % 17]; \ + X11 += ks[((R) + 12) % 17]; \ + X12 += ks[((R) + 13) % 17]; \ + X13 += ks[((R) + 14) % 17] + ts[((R) + 1) % 3]; \ + X14 += ks[((R) + 15) % 17] + ts[((R) + 2) % 3]; \ + X15 += ks[((R) + 16) % 17] + (R) + 1; \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); +#else /* looping version */ +#define R1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, \ + ROT, rn) \ + Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ + pF, ROT, rn) \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rn, Xptr); + +#define I1024(R) \ + /* inject the key schedule value */ \ + X00 += ks[r + (R) + 0]; \ + X01 += ks[r + (R) + 1]; \ + X02 += ks[r + (R) + 2]; \ + X03 += ks[r + (R) + 3]; \ + X04 += ks[r + (R) + 4]; \ + X05 += ks[r + (R) + 5]; \ + X06 += ks[r + (R) + 6]; \ + X07 += ks[r + (R) + 7]; \ + X08 += ks[r + (R) + 8]; \ + X09 += ks[r + (R) + 9]; \ + X10 += ks[r + (R) + 10]; \ + X11 += ks[r + (R) + 11]; \ + X12 += ks[r + (R) + 12]; \ + X13 += ks[r + (R) + 13] + ts[r + (R) + 0]; \ + X14 += ks[r + (R) + 14] + ts[r + (R) + 1]; \ + X15 += ks[r + (R) + 15] + r + (R); \ + /* rotate key schedule */ \ + ks[r + (R) + 16] = ks[r + (R) - 1]; \ + ts[r + (R) + 2] = ts[r + (R) - 1]; \ + Skein_Show_R_Ptr(BLK_BITSi, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); + + for (r = 1; r <= 2 * RCNT; r += 2 * SKEIN_UNROLL_1024) #endif { -#define R1024_8_rounds(R) /* do 8 full rounds */ \ - R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, R1024_0, 8*(R) + 1); \ - R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, 05, 08, 01, R1024_1, 8*(R) + 2); \ - R1024(00, 07, 02, 05, 04, 03, 06, 01, 12, 15, 14, 13, 08, 11, 10, 09, R1024_2, 8*(R) + 3); \ - R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, 03, 12, 07, R1024_3, 8*(R) + 4); \ - I1024(2*(R)); \ - R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, R1024_4, 8*(R) + 5); \ - R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, 05, 08, 01, R1024_5, 8*(R) + 6); \ - R1024(00, 07, 02, 05, 04, 03, 06, 01, 12, 15, 14, 13, 08, 11, 10, 09, R1024_6, 8*(R) + 7); \ - R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, 03, 12, 07, R1024_7, 8*(R) + 8); \ - I1024(2*(R)+1); +#define R1024_8_rounds(R) \ + R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, \ + R1024_0, 8*(R) + 1); \ + R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, 05, 08, 01, \ + R1024_1, 8*(R) + 2); \ + R1024(00, 07, 02, 05, 04, 03, 06, 01, 12, 15, 14, 13, 08, 11, 10, 09, \ + R1024_2, 8*(R) + 3); \ + R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, 03, 12, 07, \ + R1024_3, 8*(R) + 4); \ + I1024(2*(R)); \ + R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, \ + R1024_4, 8*(R) + 5); \ + R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, 05, 08, 01, \ + R1024_5, 8*(R) + 6); \ + R1024(00, 07, 02, 05, 04, 03, 06, 01, 12, 15, 14, 13, 08, 11, 10, 09, \ + R1024_6, 8*(R) + 7); \ + R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, 03, 12, 07, \ + R1024_7, 8*(R) + 8); \ + I1024(2*(R)+1); R1024_8_rounds(0); -#define R1024_Unroll_R(NN) ((SKEIN_UNROLL_1024 == 0 && SKEIN1024_ROUNDS_TOTAL/8 > (NN)) || (SKEIN_UNROLL_1024 > (NN))) +#define R1024_Unroll_R(NN) \ + ((SKEIN_UNROLL_1024 == 0 && \ + SKEIN1024_ROUNDS_TOTAL/8 > (NN)) || \ + (SKEIN_UNROLL_1024 > (NN))) #if R1024_Unroll_R(1) R1024_8_rounds(1); @@ -643,7 +694,7 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, size_t #error "need more unrolling in Skein_1024_Process_Block" #endif } - /* do the final "feedforward" xor, update context chaining vars */ + /* do the final "feedforward" xor, update context chaining */ ctx->X[0] = X00 ^ w[0]; ctx->X[1] = X01 ^ w[1]; diff --git a/drivers/staging/skein/threefish1024Block.c b/drivers/staging/skein/threefish1024Block.c index 1730a3120a0f..fe7517b2008c 100644 --- a/drivers/staging/skein/threefish1024Block.c +++ b/drivers/staging/skein/threefish1024Block.c @@ -24,646 +24,2085 @@ void threefishEncrypt1024(struct threefish_key *keyCtx, u64 *input, u64 *output) u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], t2 = keyCtx->tweak[2]; - b1 += k1; b0 += b1 + k0; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - b3 += k3; b2 += b3 + k2; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - b5 += k5; b4 += b5 + k4; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - b7 += k7; b6 += b7 + k6; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - b9 += k9; b8 += b9 + k8; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - b11 += k11; b10 += b11 + k10; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - b13 += k13 + t0; b12 += b13 + k12; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - b15 += k15; b14 += b15 + k14 + t1; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - b1 += k2; b0 += b1 + k1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - b3 += k4; b2 += b3 + k3; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - b5 += k6; b4 += b5 + k5; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - b7 += k8; b6 += b7 + k7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - b9 += k10; b8 += b9 + k9; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - b11 += k12; b10 += b11 + k11; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - b13 += k14 + t1; b12 += b13 + k13; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - b15 += k16 + 1; b14 += b15 + k15 + t2; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - b1 += k3; b0 += b1 + k2; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - b3 += k5; b2 += b3 + k4; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - b5 += k7; b4 += b5 + k6; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - b7 += k9; b6 += b7 + k8; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - b9 += k11; b8 += b9 + k10; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - b11 += k13; b10 += b11 + k12; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - b13 += k15 + t2; b12 += b13 + k14; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - b15 += k0 + 2; b14 += b15 + k16 + t0; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - b1 += k4; b0 += b1 + k3; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - b3 += k6; b2 += b3 + k5; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - b5 += k8; b4 += b5 + k7; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - b7 += k10; b6 += b7 + k9; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - b9 += k12; b8 += b9 + k11; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - b11 += k14; b10 += b11 + k13; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - b13 += k16 + t0; b12 += b13 + k15; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - b15 += k1 + 3; b14 += b15 + k0 + t1; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - b1 += k5; b0 += b1 + k4; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - b3 += k7; b2 += b3 + k6; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - b5 += k9; b4 += b5 + k8; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - b7 += k11; b6 += b7 + k10; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - b9 += k13; b8 += b9 + k12; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - b11 += k15; b10 += b11 + k14; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - b13 += k0 + t1; b12 += b13 + k16; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - b15 += k2 + 4; b14 += b15 + k1 + t2; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - b1 += k6; b0 += b1 + k5; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - b3 += k8; b2 += b3 + k7; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - b5 += k10; b4 += b5 + k9; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - b7 += k12; b6 += b7 + k11; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - b9 += k14; b8 += b9 + k13; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - b11 += k16; b10 += b11 + k15; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - b13 += k1 + t2; b12 += b13 + k0; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - b15 += k3 + 5; b14 += b15 + k2 + t0; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - b1 += k7; b0 += b1 + k6; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - b3 += k9; b2 += b3 + k8; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - b5 += k11; b4 += b5 + k10; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - b7 += k13; b6 += b7 + k12; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - b9 += k15; b8 += b9 + k14; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - b11 += k0; b10 += b11 + k16; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - b13 += k2 + t0; b12 += b13 + k1; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - b15 += k4 + 6; b14 += b15 + k3 + t1; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - b1 += k8; b0 += b1 + k7; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - b3 += k10; b2 += b3 + k9; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - b5 += k12; b4 += b5 + k11; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - b7 += k14; b6 += b7 + k13; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - b9 += k16; b8 += b9 + k15; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - b11 += k1; b10 += b11 + k0; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - b13 += k3 + t1; b12 += b13 + k2; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - b15 += k5 + 7; b14 += b15 + k4 + t2; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - b1 += k9; b0 += b1 + k8; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - b3 += k11; b2 += b3 + k10; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - b5 += k13; b4 += b5 + k12; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - b7 += k15; b6 += b7 + k14; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - b9 += k0; b8 += b9 + k16; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - b11 += k2; b10 += b11 + k1; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - b13 += k4 + t2; b12 += b13 + k3; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - b15 += k6 + 8; b14 += b15 + k5 + t0; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - b1 += k10; b0 += b1 + k9; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - b3 += k12; b2 += b3 + k11; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - b5 += k14; b4 += b5 + k13; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - b7 += k16; b6 += b7 + k15; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - b9 += k1; b8 += b9 + k0; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - b11 += k3; b10 += b11 + k2; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - b13 += k5 + t0; b12 += b13 + k4; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - b15 += k7 + 9; b14 += b15 + k6 + t1; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - b1 += k11; b0 += b1 + k10; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - b3 += k13; b2 += b3 + k12; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - b5 += k15; b4 += b5 + k14; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - b7 += k0; b6 += b7 + k16; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - b9 += k2; b8 += b9 + k1; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - b11 += k4; b10 += b11 + k3; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - b13 += k6 + t1; b12 += b13 + k5; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - b15 += k8 + 10; b14 += b15 + k7 + t2; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - b1 += k12; b0 += b1 + k11; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - b3 += k14; b2 += b3 + k13; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - b5 += k16; b4 += b5 + k15; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - b7 += k1; b6 += b7 + k0; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - b9 += k3; b8 += b9 + k2; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - b11 += k5; b10 += b11 + k4; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - b13 += k7 + t2; b12 += b13 + k6; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - b15 += k9 + 11; b14 += b15 + k8 + t0; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - b1 += k13; b0 += b1 + k12; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - b3 += k15; b2 += b3 + k14; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - b5 += k0; b4 += b5 + k16; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - b7 += k2; b6 += b7 + k1; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - b9 += k4; b8 += b9 + k3; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - b11 += k6; b10 += b11 + k5; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - b13 += k8 + t0; b12 += b13 + k7; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - b15 += k10 + 12; b14 += b15 + k9 + t1; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - b1 += k14; b0 += b1 + k13; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - b3 += k16; b2 += b3 + k15; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - b5 += k1; b4 += b5 + k0; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - b7 += k3; b6 += b7 + k2; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - b9 += k5; b8 += b9 + k4; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - b11 += k7; b10 += b11 + k6; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - b13 += k9 + t1; b12 += b13 + k8; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - b15 += k11 + 13; b14 += b15 + k10 + t2; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - b1 += k15; b0 += b1 + k14; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - b3 += k0; b2 += b3 + k16; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - b5 += k2; b4 += b5 + k1; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - b7 += k4; b6 += b7 + k3; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - b9 += k6; b8 += b9 + k5; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - b11 += k8; b10 += b11 + k7; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - b13 += k10 + t2; b12 += b13 + k9; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - b15 += k12 + 14; b14 += b15 + k11 + t0; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - b1 += k16; b0 += b1 + k15; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - b3 += k1; b2 += b3 + k0; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - b5 += k3; b4 += b5 + k2; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - b7 += k5; b6 += b7 + k4; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - b9 += k7; b8 += b9 + k6; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - b11 += k9; b10 += b11 + k8; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - b13 += k11 + t0; b12 += b13 + k10; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - b15 += k13 + 15; b14 += b15 + k12 + t1; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - b1 += k0; b0 += b1 + k16; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - b3 += k2; b2 += b3 + k1; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - b5 += k4; b4 += b5 + k3; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - b7 += k6; b6 += b7 + k5; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - b9 += k8; b8 += b9 + k7; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - b11 += k10; b10 += b11 + k9; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - b13 += k12 + t1; b12 += b13 + k11; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - b15 += k14 + 16; b14 += b15 + k13 + t2; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - b1 += k1; b0 += b1 + k0; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - b3 += k3; b2 += b3 + k2; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - b5 += k5; b4 += b5 + k4; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - b7 += k7; b6 += b7 + k6; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - b9 += k9; b8 += b9 + k8; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - b11 += k11; b10 += b11 + k10; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - b13 += k13 + t2; b12 += b13 + k12; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - b15 += k15 + 17; b14 += b15 + k14 + t0; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - b1 += k2; b0 += b1 + k1; b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - b3 += k4; b2 += b3 + k3; b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - b5 += k6; b4 += b5 + k5; b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - b7 += k8; b6 += b7 + k7; b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - b9 += k10; b8 += b9 + k9; b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - b11 += k12; b10 += b11 + k11; b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - b13 += k14 + t0; b12 += b13 + k13; b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - b15 += k16 + 18; b14 += b15 + k15 + t1; b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - b0 += b9; b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - b2 += b13; b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - b6 += b11; b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - b4 += b15; b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - b10 += b7; b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - b12 += b3; b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - b14 += b5; b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - b8 += b1; b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - b0 += b7; b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - b2 += b5; b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - b4 += b3; b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - b6 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - b12 += b15; b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - b14 += b13; b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - b8 += b11; b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - b10 += b9; b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - b0 += b15; b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - b2 += b11; b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - b6 += b13; b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - b4 += b9; b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - b14 += b1; b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - b8 += b5; b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - b10 += b3; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - b12 += b7; b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - b1 += k3; b0 += b1 + k2; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - b3 += k5; b2 += b3 + k4; b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - b5 += k7; b4 += b5 + k6; b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - b7 += k9; b6 += b7 + k8; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - b9 += k11; b8 += b9 + k10; b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - b11 += k13; b10 += b11 + k12; b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - b13 += k15 + t1; b12 += b13 + k14; b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - b15 += k0 + 19; b14 += b15 + k16 + t2; b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - b0 += b9; b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - b2 += b13; b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - b6 += b11; b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - b4 += b15; b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - b10 += b7; b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - b12 += b3; b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - b14 += b5; b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - b8 += b1; b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - b0 += b7; b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - b2 += b5; b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - b4 += b3; b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - b6 += b1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - b12 += b15; b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - b14 += b13; b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - b8 += b11; b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - b10 += b9; b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - b0 += b15; b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - b2 += b11; b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - b6 += b13; b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - b4 += b9; b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - b14 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - b8 += b5; b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - b10 += b3; b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - b12 += b7; b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + b1 += k1; + b0 += b1 + k0; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k3; + b2 += b3 + k2; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k5; + b4 += b5 + k4; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k7; + b6 += b7 + k6; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k9; + b8 += b9 + k8; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k11; + b10 += b11 + k10; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k13 + t0; + b12 += b13 + k12; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k15; + b14 += b15 + k14 + t1; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k2; + b0 += b1 + k1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k4; + b2 += b3 + k3; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k6; + b4 += b5 + k5; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k8; + b6 += b7 + k7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k10; + b8 += b9 + k9; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k12; + b10 += b11 + k11; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k14 + t1; + b12 += b13 + k13; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k16 + 1; + b14 += b15 + k15 + t2; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + b1 += k3; + b0 += b1 + k2; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k5; + b2 += b3 + k4; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k7; + b4 += b5 + k6; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k9; + b6 += b7 + k8; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k11; + b8 += b9 + k10; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k13; + b10 += b11 + k12; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k15 + t2; + b12 += b13 + k14; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k0 + 2; + b14 += b15 + k16 + t0; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k4; + b0 += b1 + k3; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k6; + b2 += b3 + k5; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k8; + b4 += b5 + k7; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k10; + b6 += b7 + k9; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k12; + b8 += b9 + k11; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k14; + b10 += b11 + k13; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k16 + t0; + b12 += b13 + k15; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k1 + 3; + b14 += b15 + k0 + t1; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + b1 += k5; + b0 += b1 + k4; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k7; + b2 += b3 + k6; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k9; + b4 += b5 + k8; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k11; + b6 += b7 + k10; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k13; + b8 += b9 + k12; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k15; + b10 += b11 + k14; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k0 + t1; + b12 += b13 + k16; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k2 + 4; + b14 += b15 + k1 + t2; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k6; + b0 += b1 + k5; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k8; + b2 += b3 + k7; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k10; + b4 += b5 + k9; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k12; + b6 += b7 + k11; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k14; + b8 += b9 + k13; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k16; + b10 += b11 + k15; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k1 + t2; + b12 += b13 + k0; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k3 + 5; + b14 += b15 + k2 + t0; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + b1 += k7; + b0 += b1 + k6; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k9; + b2 += b3 + k8; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k11; + b4 += b5 + k10; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k13; + b6 += b7 + k12; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k15; + b8 += b9 + k14; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k0; + b10 += b11 + k16; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k2 + t0; + b12 += b13 + k1; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k4 + 6; + b14 += b15 + k3 + t1; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k8; + b0 += b1 + k7; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k10; + b2 += b3 + k9; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k12; + b4 += b5 + k11; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k14; + b6 += b7 + k13; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k16; + b8 += b9 + k15; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k1; + b10 += b11 + k0; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k3 + t1; + b12 += b13 + k2; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k5 + 7; + b14 += b15 + k4 + t2; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + b1 += k9; + b0 += b1 + k8; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k11; + b2 += b3 + k10; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k13; + b4 += b5 + k12; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k15; + b6 += b7 + k14; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k0; + b8 += b9 + k16; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k2; + b10 += b11 + k1; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k4 + t2; + b12 += b13 + k3; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k6 + 8; + b14 += b15 + k5 + t0; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k10; + b0 += b1 + k9; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k12; + b2 += b3 + k11; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k14; + b4 += b5 + k13; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k16; + b6 += b7 + k15; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k1; + b8 += b9 + k0; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k3; + b10 += b11 + k2; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k5 + t0; + b12 += b13 + k4; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k7 + 9; + b14 += b15 + k6 + t1; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + b1 += k11; + b0 += b1 + k10; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k13; + b2 += b3 + k12; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k15; + b4 += b5 + k14; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k0; + b6 += b7 + k16; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k2; + b8 += b9 + k1; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k4; + b10 += b11 + k3; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k6 + t1; + b12 += b13 + k5; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k8 + 10; + b14 += b15 + k7 + t2; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k12; + b0 += b1 + k11; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k14; + b2 += b3 + k13; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k16; + b4 += b5 + k15; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k1; + b6 += b7 + k0; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k3; + b8 += b9 + k2; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k5; + b10 += b11 + k4; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k7 + t2; + b12 += b13 + k6; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k9 + 11; + b14 += b15 + k8 + t0; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + b1 += k13; + b0 += b1 + k12; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k15; + b2 += b3 + k14; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k0; + b4 += b5 + k16; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k2; + b6 += b7 + k1; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k4; + b8 += b9 + k3; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k6; + b10 += b11 + k5; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k8 + t0; + b12 += b13 + k7; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k10 + 12; + b14 += b15 + k9 + t1; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k14; + b0 += b1 + k13; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k16; + b2 += b3 + k15; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k1; + b4 += b5 + k0; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k3; + b6 += b7 + k2; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k5; + b8 += b9 + k4; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k7; + b10 += b11 + k6; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k9 + t1; + b12 += b13 + k8; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k11 + 13; + b14 += b15 + k10 + t2; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + b1 += k15; + b0 += b1 + k14; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k0; + b2 += b3 + k16; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k2; + b4 += b5 + k1; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k4; + b6 += b7 + k3; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k6; + b8 += b9 + k5; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k8; + b10 += b11 + k7; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k10 + t2; + b12 += b13 + k9; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k12 + 14; + b14 += b15 + k11 + t0; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k16; + b0 += b1 + k15; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k1; + b2 += b3 + k0; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k3; + b4 += b5 + k2; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k5; + b6 += b7 + k4; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k7; + b8 += b9 + k6; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k9; + b10 += b11 + k8; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k11 + t0; + b12 += b13 + k10; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k13 + 15; + b14 += b15 + k12 + t1; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + b1 += k0; + b0 += b1 + k16; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k2; + b2 += b3 + k1; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k4; + b4 += b5 + k3; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k6; + b6 += b7 + k5; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k8; + b8 += b9 + k7; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k10; + b10 += b11 + k9; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k12 + t1; + b12 += b13 + k11; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k14 + 16; + b14 += b15 + k13 + t2; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k1; + b0 += b1 + k0; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k3; + b2 += b3 + k2; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k5; + b4 += b5 + k4; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k7; + b6 += b7 + k6; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k9; + b8 += b9 + k8; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k11; + b10 += b11 + k10; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k13 + t2; + b12 += b13 + k12; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k15 + 17; + b14 += b15 + k14 + t0; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + b1 += k2; + b0 += b1 + k1; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k4; + b2 += b3 + k3; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k6; + b4 += b5 + k5; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k8; + b6 += b7 + k7; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k10; + b8 += b9 + k9; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k12; + b10 += b11 + k11; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k14 + t0; + b12 += b13 + k13; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k16 + 18; + b14 += b15 + k15 + t1; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k3; + b0 += b1 + k2; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k5; + b2 += b3 + k4; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k7; + b4 += b5 + k6; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k9; + b6 += b7 + k8; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k11; + b8 += b9 + k10; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k13; + b10 += b11 + k12; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k15 + t1; + b12 += b13 + k14; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k0 + 19; + b14 += b15 + k16 + t2; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; output[0] = b0 + k3; output[1] = b1 + k4; @@ -683,685 +2122,2764 @@ void threefishEncrypt1024(struct threefish_key *keyCtx, u64 *input, u64 *output) output[15] = b15 + k1 + 20; } -void threefishDecrypt1024(struct threefish_key *keyCtx, u64 *input, u64 *output) -{ - u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3], - b4 = input[4], b5 = input[5], - b6 = input[6], b7 = input[7], - b8 = input[8], b9 = input[9], - b10 = input[10], b11 = input[11], - b12 = input[12], b13 = input[13], - b14 = input[14], b15 = input[15]; - u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1], - k2 = keyCtx->key[2], k3 = keyCtx->key[3], - k4 = keyCtx->key[4], k5 = keyCtx->key[5], - k6 = keyCtx->key[6], k7 = keyCtx->key[7], - k8 = keyCtx->key[8], k9 = keyCtx->key[9], - k10 = keyCtx->key[10], k11 = keyCtx->key[11], - k12 = keyCtx->key[12], k13 = keyCtx->key[13], - k14 = keyCtx->key[14], k15 = keyCtx->key[15], - k16 = keyCtx->key[16]; - u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], - t2 = keyCtx->tweak[2]; - u64 tmp; +void threefishDecrypt1024(struct threefish_key *keyCtx, u64 *input, u64 *output) +{ + u64 b0 = input[0], b1 = input[1], + b2 = input[2], b3 = input[3], + b4 = input[4], b5 = input[5], + b6 = input[6], b7 = input[7], + b8 = input[8], b9 = input[9], + b10 = input[10], b11 = input[11], + b12 = input[12], b13 = input[13], + b14 = input[14], b15 = input[15]; + u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1], + k2 = keyCtx->key[2], k3 = keyCtx->key[3], + k4 = keyCtx->key[4], k5 = keyCtx->key[5], + k6 = keyCtx->key[6], k7 = keyCtx->key[7], + k8 = keyCtx->key[8], k9 = keyCtx->key[9], + k10 = keyCtx->key[10], k11 = keyCtx->key[11], + k12 = keyCtx->key[12], k13 = keyCtx->key[13], + k14 = keyCtx->key[14], k15 = keyCtx->key[15], + k16 = keyCtx->key[16]; + u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], + t2 = keyCtx->tweak[2]; + u64 tmp; + + b0 -= k3; + b1 -= k4; + b2 -= k5; + b3 -= k6; + b4 -= k7; + b5 -= k8; + b6 -= k9; + b7 -= k10; + b8 -= k11; + b9 -= k12; + b10 -= k13; + b11 -= k14; + b12 -= k15; + b13 -= k16 + t2; + b14 -= k0 + t0; + b15 -= k1 + 20; + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k16 + t2; + b15 -= k0 + 19; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k14; + b13 -= k15 + t1; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k12; + b11 -= k13; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k10; + b9 -= k11; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k8; + b7 -= k9; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k6; + b5 -= k7; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k4; + b3 -= k5; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k2; + b1 -= k3; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k15 + t1; + b15 -= k16 + 18; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k13; + b13 -= k14 + t0; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k11; + b11 -= k12; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k9; + b9 -= k10; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k7; + b7 -= k8; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k5; + b5 -= k6; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k3; + b3 -= k4; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k1; + b1 -= k2; + + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k14 + t0; + b15 -= k15 + 17; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k12; + b13 -= k13 + t2; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k10; + b11 -= k11; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k8; + b9 -= k9; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k6; + b7 -= k7; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k4; + b5 -= k5; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k2; + b3 -= k3; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k0; + b1 -= k1; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k13 + t2; + b15 -= k14 + 16; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k11; + b13 -= k12 + t1; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k9; + b11 -= k10; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k7; + b9 -= k8; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k5; + b7 -= k6; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k3; + b5 -= k4; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k1; + b3 -= k2; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k16; + b1 -= k0; + + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k12 + t1; + b15 -= k13 + 15; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k10; + b13 -= k11 + t0; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k8; + b11 -= k9; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k6; + b9 -= k7; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k4; + b7 -= k5; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k2; + b5 -= k3; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k0; + b3 -= k1; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k15; + b1 -= k16; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k11 + t0; + b15 -= k12 + 14; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k9; + b13 -= k10 + t2; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k7; + b11 -= k8; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k5; + b9 -= k6; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k3; + b7 -= k4; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k1; + b5 -= k2; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k16; + b3 -= k0; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k14; + b1 -= k15; + + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k10 + t2; + b15 -= k11 + 13; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k8; + b13 -= k9 + t1; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k6; + b11 -= k7; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k4; + b9 -= k5; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k2; + b7 -= k3; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k0; + b5 -= k1; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k15; + b3 -= k16; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k13; + b1 -= k14; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k9 + t1; + b15 -= k10 + 12; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k7; + b13 -= k8 + t0; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k5; + b11 -= k6; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k3; + b9 -= k4; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k1; + b7 -= k2; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k16; + b5 -= k0; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k14; + b3 -= k15; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k12; + b1 -= k13; + + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k8 + t0; + b15 -= k9 + 11; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k6; + b13 -= k7 + t2; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k4; + b11 -= k5; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k2; + b9 -= k3; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k0; + b7 -= k1; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k15; + b5 -= k16; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k13; + b3 -= k14; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k11; + b1 -= k12; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k7 + t2; + b15 -= k8 + 10; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k5; + b13 -= k6 + t1; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k3; + b11 -= k4; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k1; + b9 -= k2; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k16; + b7 -= k0; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k14; + b5 -= k15; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k12; + b3 -= k13; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k10; + b1 -= k11; + + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k6 + t1; + b15 -= k7 + 9; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k4; + b13 -= k5 + t0; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k2; + b11 -= k3; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k0; + b9 -= k1; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k15; + b7 -= k16; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k13; + b5 -= k14; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k11; + b3 -= k12; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k9; + b1 -= k10; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k5 + t0; + b15 -= k6 + 8; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k3; + b13 -= k4 + t2; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k1; + b11 -= k2; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k16; + b9 -= k0; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k14; + b7 -= k15; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k12; + b5 -= k13; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k10; + b3 -= k11; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k8; + b1 -= k9; + + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k4 + t2; + b15 -= k5 + 7; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k2; + b13 -= k3 + t1; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k0; + b11 -= k1; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k15; + b9 -= k16; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k13; + b7 -= k14; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k11; + b5 -= k12; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k9; + b3 -= k10; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k7; + b1 -= k8; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; - b0 -= k3; - b1 -= k4; - b2 -= k5; - b3 -= k6; - b4 -= k7; - b5 -= k8; - b6 -= k9; - b7 -= k10; - b8 -= k11; - b9 -= k12; - b10 -= k13; + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k3 + t1; + b15 -= k4 + 6; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k1; + b13 -= k2 + t0; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k16; + b11 -= k0; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k14; + b9 -= k15; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k12; + b7 -= k13; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k10; + b5 -= k11; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k8; + b3 -= k9; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k6; + b1 -= k7; + + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k2 + t0; + b15 -= k3 + 5; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k0; + b13 -= k1 + t2; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k15; + b11 -= k16; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k13; + b9 -= k14; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k11; + b7 -= k12; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k9; + b5 -= k10; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k7; + b3 -= k8; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k5; + b1 -= k6; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k1 + t2; + b15 -= k2 + 4; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k16; + b13 -= k0 + t1; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k14; + b11 -= k15; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k12; + b9 -= k13; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k10; + b7 -= k11; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k8; + b5 -= k9; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k6; + b3 -= k7; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k4; + b1 -= k5; + + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k0 + t1; + b15 -= k1 + 3; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k15; + b13 -= k16 + t0; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k13; b11 -= k14; - b12 -= k15; - b13 -= k16 + t2; - b14 -= k0 + t0; - b15 -= k1 + 20; - tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k16 + t2; b15 -= k0 + 19; - tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k14; b13 -= k15 + t1; - tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k12; b11 -= k13; - tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k10; b9 -= k11; - tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k8; b7 -= k9; - tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k6; b5 -= k7; - tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k4; b3 -= k5; - tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k2; b1 -= k3; - tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k15 + t1; b15 -= k16 + 18; - tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k13; b13 -= k14 + t0; - tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k11; b11 -= k12; - tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k9; b9 -= k10; - tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k7; b7 -= k8; - tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k5; b5 -= k6; - tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k3; b3 -= k4; - tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k1; b1 -= k2; - tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k14 + t0; b15 -= k15 + 17; - tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k12; b13 -= k13 + t2; - tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k10; b11 -= k11; - tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k8; b9 -= k9; - tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k6; b7 -= k7; - tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k4; b5 -= k5; - tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k2; b3 -= k3; - tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k0; b1 -= k1; - tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k13 + t2; b15 -= k14 + 16; - tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k11; b13 -= k12 + t1; - tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k9; b11 -= k10; - tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k7; b9 -= k8; - tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k5; b7 -= k6; - tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k3; b5 -= k4; - tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k1; b3 -= k2; - tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k16; b1 -= k0; - tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k12 + t1; b15 -= k13 + 15; - tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k10; b13 -= k11 + t0; - tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k8; b11 -= k9; - tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k6; b9 -= k7; - tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k4; b7 -= k5; - tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k2; b5 -= k3; - tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k0; b3 -= k1; - tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k15; b1 -= k16; - tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k11 + t0; b15 -= k12 + 14; - tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k9; b13 -= k10 + t2; - tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k7; b11 -= k8; - tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k5; b9 -= k6; - tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k3; b7 -= k4; - tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k1; b5 -= k2; - tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k16; b3 -= k0; - tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k14; b1 -= k15; - tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k10 + t2; b15 -= k11 + 13; - tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k8; b13 -= k9 + t1; - tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k6; b11 -= k7; - tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k4; b9 -= k5; - tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k2; b7 -= k3; - tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k0; b5 -= k1; - tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k15; b3 -= k16; - tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k13; b1 -= k14; - tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k9 + t1; b15 -= k10 + 12; - tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k7; b13 -= k8 + t0; - tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k5; b11 -= k6; - tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k3; b9 -= k4; - tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k1; b7 -= k2; - tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k16; b5 -= k0; - tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k14; b3 -= k15; - tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k12; b1 -= k13; - tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k8 + t0; b15 -= k9 + 11; - tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k6; b13 -= k7 + t2; - tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k4; b11 -= k5; - tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k2; b9 -= k3; - tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k0; b7 -= k1; - tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k15; b5 -= k16; - tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k13; b3 -= k14; - tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k11; b1 -= k12; - tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k7 + t2; b15 -= k8 + 10; - tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k5; b13 -= k6 + t1; - tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k3; b11 -= k4; - tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k1; b9 -= k2; - tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k16; b7 -= k0; - tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k14; b5 -= k15; - tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k12; b3 -= k13; - tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k10; b1 -= k11; - tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k6 + t1; b15 -= k7 + 9; - tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k4; b13 -= k5 + t0; - tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k2; b11 -= k3; - tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k0; b9 -= k1; - tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k15; b7 -= k16; - tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k13; b5 -= k14; - tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k11; b3 -= k12; - tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k9; b1 -= k10; - tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k5 + t0; b15 -= k6 + 8; - tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k3; b13 -= k4 + t2; - tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k1; b11 -= k2; - tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k16; b9 -= k0; - tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k14; b7 -= k15; - tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k12; b5 -= k13; - tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k10; b3 -= k11; - tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k8; b1 -= k9; - tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k4 + t2; b15 -= k5 + 7; - tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k2; b13 -= k3 + t1; - tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k0; b11 -= k1; - tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k15; b9 -= k16; - tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k13; b7 -= k14; - tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k11; b5 -= k12; - tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k9; b3 -= k10; - tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k7; b1 -= k8; - tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k3 + t1; b15 -= k4 + 6; - tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k1; b13 -= k2 + t0; - tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k16; b11 -= k0; - tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k14; b9 -= k15; - tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k12; b7 -= k13; - tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k10; b5 -= k11; - tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k8; b3 -= k9; - tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k6; b1 -= k7; - tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k2 + t0; b15 -= k3 + 5; - tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k0; b13 -= k1 + t2; - tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k15; b11 -= k16; - tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k13; b9 -= k14; - tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k11; b7 -= k12; - tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k9; b5 -= k10; - tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k7; b3 -= k8; - tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k5; b1 -= k6; - tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k1 + t2; b15 -= k2 + 4; - tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k16; b13 -= k0 + t1; - tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k14; b11 -= k15; - tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k12; b9 -= k13; - tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k10; b7 -= k11; - tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k8; b5 -= k9; - tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k6; b3 -= k7; - tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k4; b1 -= k5; - tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k0 + t1; b15 -= k1 + 3; - tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k15; b13 -= k16 + t0; - tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k13; b11 -= k14; - tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k11; b9 -= k12; - tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k9; b7 -= k10; - tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k7; b5 -= k8; - tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k5; b3 -= k6; - tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k3; b1 -= k4; - tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k16 + t0; b15 -= k0 + 2; - tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k14; b13 -= k15 + t2; - tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k12; b11 -= k13; - tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k10; b9 -= k11; - tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k8; b7 -= k9; - tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k6; b5 -= k7; - tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k4; b3 -= k5; - tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k2; b1 -= k3; - tmp = b7 ^ b12; b7 = (tmp >> 20) | (tmp << (64 - 20)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 37) | (tmp << (64 - 37)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 31) | (tmp << (64 - 31)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 52) | (tmp << (64 - 52)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 35) | (tmp << (64 - 35)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 48) | (tmp << (64 - 48)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 25) | (tmp << (64 - 25)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 44) | (tmp << (64 - 44)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 19) | (tmp << (64 - 19)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 46) | (tmp << (64 - 46)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 47) | (tmp << (64 - 47)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 44) | (tmp << (64 - 44)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 31) | (tmp << (64 - 31)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 41) | (tmp << (64 - 41)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 42) | (tmp << (64 - 42)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 53) | (tmp << (64 - 53)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 4) | (tmp << (64 - 4)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 56) | (tmp << (64 - 56)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 34) | (tmp << (64 - 34)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 16) | (tmp << (64 - 16)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 30) | (tmp << (64 - 30)); b14 -= b15 + k15 + t2; b15 -= k16 + 1; - tmp = b13 ^ b12; b13 = (tmp >> 44) | (tmp << (64 - 44)); b12 -= b13 + k13; b13 -= k14 + t1; - tmp = b11 ^ b10; b11 = (tmp >> 47) | (tmp << (64 - 47)); b10 -= b11 + k11; b11 -= k12; - tmp = b9 ^ b8; b9 = (tmp >> 12) | (tmp << (64 - 12)); b8 -= b9 + k9; b9 -= k10; - tmp = b7 ^ b6; b7 = (tmp >> 31) | (tmp << (64 - 31)); b6 -= b7 + k7; b7 -= k8; - tmp = b5 ^ b4; b5 = (tmp >> 37) | (tmp << (64 - 37)); b4 -= b5 + k5; b5 -= k6; - tmp = b3 ^ b2; b3 = (tmp >> 9) | (tmp << (64 - 9)); b2 -= b3 + k3; b3 -= k4; - tmp = b1 ^ b0; b1 = (tmp >> 41) | (tmp << (64 - 41)); b0 -= b1 + k1; b1 -= k2; - tmp = b7 ^ b12; b7 = (tmp >> 25) | (tmp << (64 - 25)); b12 -= b7; - tmp = b3 ^ b10; b3 = (tmp >> 16) | (tmp << (64 - 16)); b10 -= b3; - tmp = b5 ^ b8; b5 = (tmp >> 28) | (tmp << (64 - 28)); b8 -= b5; - tmp = b1 ^ b14; b1 = (tmp >> 47) | (tmp << (64 - 47)); b14 -= b1; - tmp = b9 ^ b4; b9 = (tmp >> 41) | (tmp << (64 - 41)); b4 -= b9; - tmp = b13 ^ b6; b13 = (tmp >> 48) | (tmp << (64 - 48)); b6 -= b13; - tmp = b11 ^ b2; b11 = (tmp >> 20) | (tmp << (64 - 20)); b2 -= b11; - tmp = b15 ^ b0; b15 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b15; - tmp = b9 ^ b10; b9 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b9; - tmp = b11 ^ b8; b11 = (tmp >> 59) | (tmp << (64 - 59)); b8 -= b11; - tmp = b13 ^ b14; b13 = (tmp >> 41) | (tmp << (64 - 41)); b14 -= b13; - tmp = b15 ^ b12; b15 = (tmp >> 34) | (tmp << (64 - 34)); b12 -= b15; - tmp = b1 ^ b6; b1 = (tmp >> 13) | (tmp << (64 - 13)); b6 -= b1; - tmp = b3 ^ b4; b3 = (tmp >> 51) | (tmp << (64 - 51)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 4) | (tmp << (64 - 4)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 33) | (tmp << (64 - 33)); b0 -= b7; - tmp = b1 ^ b8; b1 = (tmp >> 52) | (tmp << (64 - 52)); b8 -= b1; - tmp = b5 ^ b14; b5 = (tmp >> 23) | (tmp << (64 - 23)); b14 -= b5; - tmp = b3 ^ b12; b3 = (tmp >> 18) | (tmp << (64 - 18)); b12 -= b3; - tmp = b7 ^ b10; b7 = (tmp >> 49) | (tmp << (64 - 49)); b10 -= b7; - tmp = b15 ^ b4; b15 = (tmp >> 55) | (tmp << (64 - 55)); b4 -= b15; - tmp = b11 ^ b6; b11 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b11; - tmp = b13 ^ b2; b13 = (tmp >> 19) | (tmp << (64 - 19)); b2 -= b13; - tmp = b9 ^ b0; b9 = (tmp >> 38) | (tmp << (64 - 38)); b0 -= b9; - tmp = b15 ^ b14; b15 = (tmp >> 37) | (tmp << (64 - 37)); b14 -= b15 + k14 + t1; b15 -= k15; - tmp = b13 ^ b12; b13 = (tmp >> 22) | (tmp << (64 - 22)); b12 -= b13 + k12; b13 -= k13 + t0; - tmp = b11 ^ b10; b11 = (tmp >> 17) | (tmp << (64 - 17)); b10 -= b11 + k10; b11 -= k11; - tmp = b9 ^ b8; b9 = (tmp >> 8) | (tmp << (64 - 8)); b8 -= b9 + k8; b9 -= k9; - tmp = b7 ^ b6; b7 = (tmp >> 47) | (tmp << (64 - 47)); b6 -= b7 + k6; b7 -= k7; - tmp = b5 ^ b4; b5 = (tmp >> 8) | (tmp << (64 - 8)); b4 -= b5 + k4; b5 -= k5; - tmp = b3 ^ b2; b3 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b3 + k2; b3 -= k3; - tmp = b1 ^ b0; b1 = (tmp >> 24) | (tmp << (64 - 24)); b0 -= b1 + k0; b1 -= k1; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k11; + b9 -= k12; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k9; + b7 -= k10; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k7; + b5 -= k8; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k5; + b3 -= k6; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k3; + b1 -= k4; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k16 + t0; + b15 -= k0 + 2; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k14; + b13 -= k15 + t2; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k12; + b11 -= k13; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k10; + b9 -= k11; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k8; + b7 -= k9; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k6; + b5 -= k7; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k4; + b3 -= k5; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k2; + b1 -= k3; + + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k15 + t2; + b15 -= k16 + 1; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k13; + b13 -= k14 + t1; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k11; + b11 -= k12; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k9; + b9 -= k10; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k7; + b7 -= k8; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k5; + b5 -= k6; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k3; + b3 -= k4; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k1; + b1 -= k2; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k14 + t1; + b15 -= k15; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k12; + b13 -= k13 + t0; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k10; + b11 -= k11; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k8; + b9 -= k9; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k6; + b7 -= k7; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k4; + b5 -= k5; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k2; + b3 -= k3; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k0; + b1 -= k1; output[15] = b15; output[14] = b14; diff --git a/drivers/staging/skein/threefish256Block.c b/drivers/staging/skein/threefish256Block.c index da3b8357e47f..2ae746a641ae 100644 --- a/drivers/staging/skein/threefish256Block.c +++ b/drivers/staging/skein/threefish256Block.c @@ -12,158 +12,481 @@ void threefishEncrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output) u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], t2 = keyCtx->tweak[2]; - b1 += k1 + t0; b0 += b1 + k0; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - b3 += k3; b2 += b3 + k2 + t1; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - b1 += k2 + t1; b0 += b1 + k1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - b3 += k4 + 1; b2 += b3 + k3 + t2; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - - b1 += k3 + t2; b0 += b1 + k2; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - b3 += k0 + 2; b2 += b3 + k4 + t0; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - b1 += k4 + t0; b0 += b1 + k3; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - b3 += k1 + 3; b2 += b3 + k0 + t1; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - - b1 += k0 + t1; b0 += b1 + k4; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - b3 += k2 + 4; b2 += b3 + k1 + t2; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - b1 += k1 + t2; b0 += b1 + k0; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - b3 += k3 + 5; b2 += b3 + k2 + t0; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - - b1 += k2 + t0; b0 += b1 + k1; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - b3 += k4 + 6; b2 += b3 + k3 + t1; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - b1 += k3 + t1; b0 += b1 + k2; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - b3 += k0 + 7; b2 += b3 + k4 + t2; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - - b1 += k4 + t2; b0 += b1 + k3; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - b3 += k1 + 8; b2 += b3 + k0 + t0; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - b1 += k0 + t0; b0 += b1 + k4; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - b3 += k2 + 9; b2 += b3 + k1 + t1; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - - b1 += k1 + t1; b0 += b1 + k0; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - b3 += k3 + 10; b2 += b3 + k2 + t2; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - b1 += k2 + t2; b0 += b1 + k1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - b3 += k4 + 11; b2 += b3 + k3 + t0; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - - b1 += k3 + t0; b0 += b1 + k2; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - b3 += k0 + 12; b2 += b3 + k4 + t1; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - b1 += k4 + t1; b0 += b1 + k3; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - b3 += k1 + 13; b2 += b3 + k0 + t2; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - - b1 += k0 + t2; b0 += b1 + k4; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - b3 += k2 + 14; b2 += b3 + k1 + t0; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - b1 += k1 + t0; b0 += b1 + k0; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - b3 += k3 + 15; b2 += b3 + k2 + t1; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - - b1 += k2 + t1; b0 += b1 + k1; b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - b3 += k4 + 16; b2 += b3 + k3 + t2; b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - b0 += b3; b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - b2 += b1; b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - b0 += b1; b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - b2 += b3; b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - b0 += b3; b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - b2 += b1; b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - b1 += k3 + t2; b0 += b1 + k2; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - b3 += k0 + 17; b2 += b3 + k4 + t0; b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - b0 += b3; b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - b2 += b1; b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - b0 += b1; b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - b2 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - b0 += b3; b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - b2 += b1; b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + b1 += k1 + t0; + b0 += b1 + k0; + b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + + b3 += k3; + b2 += b3 + k2 + t1; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + + b0 += b3; + b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + + b2 += b1; + b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + + b0 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + + b2 += b3; + b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + + b0 += b3; + b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + + b2 += b1; + b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + + b1 += k2 + t1; + b0 += b1 + k1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + + b3 += k4 + 1; + b2 += b3 + k3 + t2; + b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + + b0 += b3; + b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + + b2 += b1; + b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + + b0 += b1; + b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + + b2 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + + b0 += b3; + b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + + b2 += b1; + b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + + b1 += k3 + t2; + b0 += b1 + k2; + b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + + b3 += k0 + 2; + b2 += b3 + k4 + t0; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + + b0 += b3; + b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + + b2 += b1; + b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + + b0 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + + b2 += b3; + b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + + b0 += b3; + b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + + b2 += b1; + b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + + b1 += k4 + t0; + b0 += b1 + k3; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + + b3 += k1 + 3; + b2 += b3 + k0 + t1; + b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + + b0 += b3; + b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + + b2 += b1; + b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + + b0 += b1; + b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + + b2 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + + b0 += b3; + b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + + b2 += b1; + b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + + b1 += k0 + t1; + b0 += b1 + k4; + b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + + b3 += k2 + 4; + b2 += b3 + k1 + t2; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + + b0 += b3; + b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + + b2 += b1; + b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + + b0 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + + b2 += b3; + b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + + b0 += b3; + b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + + b2 += b1; + b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + + b1 += k1 + t2; + b0 += b1 + k0; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + + b3 += k3 + 5; + b2 += b3 + k2 + t0; + b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + + b0 += b3; + b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + + b2 += b1; + b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + + b0 += b1; + b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + + b2 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + + b0 += b3; + b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + + b2 += b1; + b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + + b1 += k2 + t0; + b0 += b1 + k1; + b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + + b3 += k4 + 6; + b2 += b3 + k3 + t1; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + + b0 += b3; + b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + + b2 += b1; + b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + + b0 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + + b2 += b3; + b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + + b0 += b3; + b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + + b2 += b1; + b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + + b1 += k3 + t1; + b0 += b1 + k2; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + + b3 += k0 + 7; + b2 += b3 + k4 + t2; + b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + + b0 += b3; + b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + + b2 += b1; + b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + + b0 += b1; + b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + + b2 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + + b0 += b3; + b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + + b2 += b1; + b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + + b1 += k4 + t2; + b0 += b1 + k3; + b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + + b3 += k1 + 8; + b2 += b3 + k0 + t0; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + + b0 += b3; + b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + + b2 += b1; + b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + + b0 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + + b2 += b3; + b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + + b0 += b3; + b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + + b2 += b1; + b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + + b1 += k0 + t0; + b0 += b1 + k4; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + + b3 += k2 + 9; + b2 += b3 + k1 + t1; + b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + + b0 += b3; + b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + + b2 += b1; + b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + + b0 += b1; + b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + + b2 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + + b0 += b3; + b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + + b2 += b1; + b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + + b1 += k1 + t1; + b0 += b1 + k0; + b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + + b3 += k3 + 10; + b2 += b3 + k2 + t2; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + + b0 += b3; + b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + + b2 += b1; + b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + + b0 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + + b2 += b3; + b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + + b0 += b3; + b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + + b2 += b1; + b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + + b1 += k2 + t2; + b0 += b1 + k1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + + b3 += k4 + 11; + b2 += b3 + k3 + t0; + b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + + b0 += b3; + b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + + b2 += b1; + b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + + b0 += b1; + b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + + b2 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + + b0 += b3; + b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + + b2 += b1; + b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + + b1 += k3 + t0; + b0 += b1 + k2; + b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + + b3 += k0 + 12; + b2 += b3 + k4 + t1; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + + b0 += b3; + b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + + b2 += b1; + b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + + b0 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + + b2 += b3; + b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + + b0 += b3; + b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + + b2 += b1; + b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + + b1 += k4 + t1; + b0 += b1 + k3; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + + b3 += k1 + 13; + b2 += b3 + k0 + t2; + b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + + b0 += b3; + b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + + b2 += b1; + b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + + b0 += b1; + b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + + b2 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + + b0 += b3; + b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + + b2 += b1; + b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + + b1 += k0 + t2; + b0 += b1 + k4; + b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + + b3 += k2 + 14; + b2 += b3 + k1 + t0; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + + b0 += b3; + b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + + b2 += b1; + b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + + b0 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + + b2 += b3; + b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + + b0 += b3; + b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + + b2 += b1; + b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + + b1 += k1 + t0; + b0 += b1 + k0; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + + b3 += k3 + 15; + b2 += b3 + k2 + t1; + b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + + b0 += b3; + b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + + b2 += b1; + b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + + b0 += b1; + b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + + b2 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + + b0 += b3; + b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + + b2 += b1; + b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + + b1 += k2 + t1; + b0 += b1 + k1; + b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + + b3 += k4 + 16; + b2 += b3 + k3 + t2; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + + b0 += b3; + b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + + b2 += b1; + b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + + b0 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + + b2 += b3; + b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + + b0 += b3; + b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + + b2 += b1; + b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + + b1 += k3 + t2; + b0 += b1 + k2; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + + b3 += k0 + 17; + b2 += b3 + k4 + t0; + b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + + b0 += b3; + b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + + b2 += b1; + b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + + b0 += b1; + b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + + b2 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + + b0 += b3; + b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + + b2 += b1; + b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; output[0] = b0 + k3; output[1] = b1 + k4 + t0; @@ -187,158 +510,625 @@ void threefishDecrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output) b1 -= k4 + t0; b2 -= k0 + t1; b3 -= k1 + 18; - tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k2; b1 -= k3 + t2; - tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k4 + t0; b3 -= k0 + 17; - tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k1; b1 -= k2 + t1; - tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k3 + t2; b3 -= k4 + 16; - - tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k0; b1 -= k1 + t0; - tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k2 + t1; b3 -= k3 + 15; - tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k4; b1 -= k0 + t2; - tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k1 + t0; b3 -= k2 + 14; - - tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k3; b1 -= k4 + t1; - tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k0 + t2; b3 -= k1 + 13; - tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k2; b1 -= k3 + t0; - tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k4 + t1; b3 -= k0 + 12; - - tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k1; b1 -= k2 + t2; - tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k3 + t0; b3 -= k4 + 11; - tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k0; b1 -= k1 + t1; - tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k2 + t2; b3 -= k3 + 10; - - tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k4; b1 -= k0 + t0; - tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k1 + t1; b3 -= k2 + 9; - tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k3; b1 -= k4 + t2; - tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k0 + t0; b3 -= k1 + 8; - - tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k2; b1 -= k3 + t1; - tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k4 + t2; b3 -= k0 + 7; - tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k1; b1 -= k2 + t0; - tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k3 + t1; b3 -= k4 + 6; - - tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k0; b1 -= k1 + t2; - tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k2 + t0; b3 -= k3 + 5; - tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k4; b1 -= k0 + t1; - tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k1 + t2; b3 -= k2 + 4; - - tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k3; b1 -= k4 + t0; - tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k0 + t1; b3 -= k1 + 3; - tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k2; b1 -= k3 + t2; - tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k4 + t0; b3 -= k0 + 2; - - tmp = b3 ^ b0; b3 = (tmp >> 32) | (tmp << (64 - 32)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 32) | (tmp << (64 - 32)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 58) | (tmp << (64 - 58)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 22) | (tmp << (64 - 22)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 12) | (tmp << (64 - 12)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 25) | (tmp << (64 - 25)); b0 -= b1 + k1; b1 -= k2 + t1; - tmp = b3 ^ b2; b3 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b3 + k3 + t2; b3 -= k4 + 1; - tmp = b3 ^ b0; b3 = (tmp >> 5) | (tmp << (64 - 5)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 37) | (tmp << (64 - 37)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 23) | (tmp << (64 - 23)); b0 -= b1; - tmp = b3 ^ b2; b3 = (tmp >> 40) | (tmp << (64 - 40)); b2 -= b3; - tmp = b3 ^ b0; b3 = (tmp >> 52) | (tmp << (64 - 52)); b0 -= b3; - tmp = b1 ^ b2; b1 = (tmp >> 57) | (tmp << (64 - 57)); b2 -= b1; - tmp = b1 ^ b0; b1 = (tmp >> 14) | (tmp << (64 - 14)); b0 -= b1 + k0; b1 -= k1 + t0; - tmp = b3 ^ b2; b3 = (tmp >> 16) | (tmp << (64 - 16)); b2 -= b3 + k2 + t1; b3 -= k3; + tmp = b3 ^ b0; + b3 = (tmp >> 32) | (tmp << (64 - 32)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 32) | (tmp << (64 - 32)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 58) | (tmp << (64 - 58)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 12) | (tmp << (64 - 12)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b0 -= b1 + k2; + b1 -= k3 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b3 + k4 + t0; + b3 -= k0 + 17; + + tmp = b3 ^ b0; + b3 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 37) | (tmp << (64 - 37)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 40) | (tmp << (64 - 40)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 52) | (tmp << (64 - 52)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 57) | (tmp << (64 - 57)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 14) | (tmp << (64 - 14)); + b0 -= b1 + k1; + b1 -= k2 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b2 -= b3 + k3 + t2; + b3 -= k4 + 16; + + + tmp = b3 ^ b0; + b3 = (tmp >> 32) | (tmp << (64 - 32)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 32) | (tmp << (64 - 32)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 58) | (tmp << (64 - 58)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 12) | (tmp << (64 - 12)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b0 -= b1 + k0; + b1 -= k1 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b3 + k2 + t1; + b3 -= k3 + 15; + + tmp = b3 ^ b0; + b3 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 37) | (tmp << (64 - 37)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 40) | (tmp << (64 - 40)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 52) | (tmp << (64 - 52)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 57) | (tmp << (64 - 57)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 14) | (tmp << (64 - 14)); + b0 -= b1 + k4; + b1 -= k0 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b2 -= b3 + k1 + t0; + b3 -= k2 + 14; + + + tmp = b3 ^ b0; + b3 = (tmp >> 32) | (tmp << (64 - 32)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 32) | (tmp << (64 - 32)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 58) | (tmp << (64 - 58)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 12) | (tmp << (64 - 12)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b0 -= b1 + k3; + b1 -= k4 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b3 + k0 + t2; + b3 -= k1 + 13; + + tmp = b3 ^ b0; + b3 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 37) | (tmp << (64 - 37)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 40) | (tmp << (64 - 40)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 52) | (tmp << (64 - 52)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 57) | (tmp << (64 - 57)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 14) | (tmp << (64 - 14)); + b0 -= b1 + k2; + b1 -= k3 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b2 -= b3 + k4 + t1; + b3 -= k0 + 12; + + + tmp = b3 ^ b0; + b3 = (tmp >> 32) | (tmp << (64 - 32)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 32) | (tmp << (64 - 32)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 58) | (tmp << (64 - 58)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 12) | (tmp << (64 - 12)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b0 -= b1 + k1; + b1 -= k2 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b3 + k3 + t0; + b3 -= k4 + 11; + + tmp = b3 ^ b0; + b3 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 37) | (tmp << (64 - 37)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 40) | (tmp << (64 - 40)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 52) | (tmp << (64 - 52)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 57) | (tmp << (64 - 57)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 14) | (tmp << (64 - 14)); + b0 -= b1 + k0; + b1 -= k1 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b2 -= b3 + k2 + t2; + b3 -= k3 + 10; + + + tmp = b3 ^ b0; + b3 = (tmp >> 32) | (tmp << (64 - 32)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 32) | (tmp << (64 - 32)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 58) | (tmp << (64 - 58)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 12) | (tmp << (64 - 12)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b0 -= b1 + k4; + b1 -= k0 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b3 + k1 + t1; + b3 -= k2 + 9; + + tmp = b3 ^ b0; + b3 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 37) | (tmp << (64 - 37)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 40) | (tmp << (64 - 40)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 52) | (tmp << (64 - 52)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 57) | (tmp << (64 - 57)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 14) | (tmp << (64 - 14)); + b0 -= b1 + k3; + b1 -= k4 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b2 -= b3 + k0 + t0; + b3 -= k1 + 8; + + + tmp = b3 ^ b0; + b3 = (tmp >> 32) | (tmp << (64 - 32)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 32) | (tmp << (64 - 32)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 58) | (tmp << (64 - 58)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 12) | (tmp << (64 - 12)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b0 -= b1 + k2; + b1 -= k3 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b3 + k4 + t2; + b3 -= k0 + 7; + + tmp = b3 ^ b0; + b3 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 37) | (tmp << (64 - 37)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 40) | (tmp << (64 - 40)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 52) | (tmp << (64 - 52)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 57) | (tmp << (64 - 57)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 14) | (tmp << (64 - 14)); + b0 -= b1 + k1; + b1 -= k2 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b2 -= b3 + k3 + t1; + b3 -= k4 + 6; + + + tmp = b3 ^ b0; + b3 = (tmp >> 32) | (tmp << (64 - 32)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 32) | (tmp << (64 - 32)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 58) | (tmp << (64 - 58)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 12) | (tmp << (64 - 12)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b0 -= b1 + k0; + b1 -= k1 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b3 + k2 + t0; + b3 -= k3 + 5; + + tmp = b3 ^ b0; + b3 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 37) | (tmp << (64 - 37)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 40) | (tmp << (64 - 40)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 52) | (tmp << (64 - 52)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 57) | (tmp << (64 - 57)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 14) | (tmp << (64 - 14)); + b0 -= b1 + k4; + b1 -= k0 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b2 -= b3 + k1 + t2; + b3 -= k2 + 4; + + + tmp = b3 ^ b0; + b3 = (tmp >> 32) | (tmp << (64 - 32)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 32) | (tmp << (64 - 32)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 58) | (tmp << (64 - 58)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 12) | (tmp << (64 - 12)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b0 -= b1 + k3; + b1 -= k4 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b3 + k0 + t1; + b3 -= k1 + 3; + + tmp = b3 ^ b0; + b3 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 37) | (tmp << (64 - 37)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 40) | (tmp << (64 - 40)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 52) | (tmp << (64 - 52)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 57) | (tmp << (64 - 57)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 14) | (tmp << (64 - 14)); + b0 -= b1 + k2; + b1 -= k3 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b2 -= b3 + k4 + t0; + b3 -= k0 + 2; + + + tmp = b3 ^ b0; + b3 = (tmp >> 32) | (tmp << (64 - 32)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 32) | (tmp << (64 - 32)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 58) | (tmp << (64 - 58)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 12) | (tmp << (64 - 12)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b0 -= b1 + k1; + b1 -= k2 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b3 + k3 + t2; + b3 -= k4 + 1; + + tmp = b3 ^ b0; + b3 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 37) | (tmp << (64 - 37)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 40) | (tmp << (64 - 40)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 52) | (tmp << (64 - 52)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 57) | (tmp << (64 - 57)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 14) | (tmp << (64 - 14)); + b0 -= b1 + k0; + b1 -= k1 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b2 -= b3 + k2 + t1; + b3 -= k3; output[0] = b0; output[1] = b1; diff --git a/drivers/staging/skein/threefish512Block.c b/drivers/staging/skein/threefish512Block.c index dc96ba279720..f428fd6e1719 100644 --- a/drivers/staging/skein/threefish512Block.c +++ b/drivers/staging/skein/threefish512Block.c @@ -16,294 +16,941 @@ void threefishEncrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output) u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], t2 = keyCtx->tweak[2]; - b1 += k1; b0 += b1 + k0; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - b3 += k3; b2 += b3 + k2; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - b5 += k5 + t0; b4 += b5 + k4; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - b7 += k7; b6 += b7 + k6 + t1; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - b1 += k2; b0 += b1 + k1; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - b3 += k4; b2 += b3 + k3; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - b5 += k6 + t1; b4 += b5 + k5; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - b7 += k8 + 1; b6 += b7 + k7 + t2; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - b1 += k3; b0 += b1 + k2; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - b3 += k5; b2 += b3 + k4; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - b5 += k7 + t2; b4 += b5 + k6; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - b7 += k0 + 2; b6 += b7 + k8 + t0; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - b1 += k4; b0 += b1 + k3; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - b3 += k6; b2 += b3 + k5; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - b5 += k8 + t0; b4 += b5 + k7; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - b7 += k1 + 3; b6 += b7 + k0 + t1; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - b1 += k5; b0 += b1 + k4; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - b3 += k7; b2 += b3 + k6; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - b5 += k0 + t1; b4 += b5 + k8; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - b7 += k2 + 4; b6 += b7 + k1 + t2; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - b1 += k6; b0 += b1 + k5; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - b3 += k8; b2 += b3 + k7; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - b5 += k1 + t2; b4 += b5 + k0; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - b7 += k3 + 5; b6 += b7 + k2 + t0; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - b1 += k7; b0 += b1 + k6; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - b3 += k0; b2 += b3 + k8; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - b5 += k2 + t0; b4 += b5 + k1; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - b7 += k4 + 6; b6 += b7 + k3 + t1; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - b1 += k8; b0 += b1 + k7; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - b3 += k1; b2 += b3 + k0; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - b5 += k3 + t1; b4 += b5 + k2; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - b7 += k5 + 7; b6 += b7 + k4 + t2; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - b1 += k0; b0 += b1 + k8; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - b3 += k2; b2 += b3 + k1; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - b5 += k4 + t2; b4 += b5 + k3; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - b7 += k6 + 8; b6 += b7 + k5 + t0; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - b1 += k1; b0 += b1 + k0; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - b3 += k3; b2 += b3 + k2; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - b5 += k5 + t0; b4 += b5 + k4; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - b7 += k7 + 9; b6 += b7 + k6 + t1; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - b1 += k2; b0 += b1 + k1; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - b3 += k4; b2 += b3 + k3; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - b5 += k6 + t1; b4 += b5 + k5; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - b7 += k8 + 10; b6 += b7 + k7 + t2; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - b1 += k3; b0 += b1 + k2; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - b3 += k5; b2 += b3 + k4; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - b5 += k7 + t2; b4 += b5 + k6; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - b7 += k0 + 11; b6 += b7 + k8 + t0; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - b1 += k4; b0 += b1 + k3; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - b3 += k6; b2 += b3 + k5; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - b5 += k8 + t0; b4 += b5 + k7; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - b7 += k1 + 12; b6 += b7 + k0 + t1; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - b1 += k5; b0 += b1 + k4; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - b3 += k7; b2 += b3 + k6; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - b5 += k0 + t1; b4 += b5 + k8; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - b7 += k2 + 13; b6 += b7 + k1 + t2; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - b1 += k6; b0 += b1 + k5; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - b3 += k8; b2 += b3 + k7; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - b5 += k1 + t2; b4 += b5 + k0; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - b7 += k3 + 14; b6 += b7 + k2 + t0; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - b1 += k7; b0 += b1 + k6; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - b3 += k0; b2 += b3 + k8; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - b5 += k2 + t0; b4 += b5 + k1; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - b7 += k4 + 15; b6 += b7 + k3 + t1; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - b1 += k8; b0 += b1 + k7; b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - b3 += k1; b2 += b3 + k0; b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - b5 += k3 + t1; b4 += b5 + k2; b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - b7 += k5 + 16; b6 += b7 + k4 + t2; b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - b2 += b1; b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - b4 += b7; b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - b6 += b5; b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - b0 += b3; b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - b4 += b1; b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - b6 += b3; b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - b0 += b5; b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - b2 += b7; b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - b6 += b1; b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - b0 += b7; b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - b2 += b5; b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - b4 += b3; b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - b1 += k0; b0 += b1 + k8; b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - b3 += k2; b2 += b3 + k1; b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - b5 += k4 + t2; b4 += b5 + k3; b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - b7 += k6 + 17; b6 += b7 + k5 + t0; b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - b2 += b1; b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - b4 += b7; b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - b6 += b5; b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - b0 += b3; b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - b4 += b1; b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - b6 += b3; b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - b0 += b5; b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - b2 += b7; b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - b6 += b1; b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - b0 += b7; b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - b2 += b5; b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - b4 += b3; b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + b1 += k1; + b0 += b1 + k0; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + + b3 += k3; + b2 += b3 + k2; + b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + + b5 += k5 + t0; + b4 += b5 + k4; + b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + + b7 += k7; + b6 += b7 + k6 + t1; + b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + + b2 += b1; + b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + + b4 += b7; + b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + + b6 += b5; + b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + + b0 += b3; + b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + + b4 += b1; + b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + + b6 += b3; + b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + + b0 += b5; + b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + + b2 += b7; + b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + + b6 += b1; + b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + + b0 += b7; + b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + + b2 += b5; + b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + + b4 += b3; + b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + + b1 += k2; + b0 += b1 + k1; + b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + + b3 += k4; + b2 += b3 + k3; + b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + + b5 += k6 + t1; + b4 += b5 + k5; + b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + + b7 += k8 + 1; + b6 += b7 + k7 + t2; + b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + + b2 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + + b4 += b7; + b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + + b6 += b5; + b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + + b0 += b3; + b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + + b4 += b1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + + b6 += b3; + b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + + b0 += b5; + b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + + b2 += b7; + b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + + b6 += b1; + b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + + b0 += b7; + b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + + b2 += b5; + b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + + b4 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + + b1 += k3; + b0 += b1 + k2; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + + b3 += k5; + b2 += b3 + k4; + b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + + b5 += k7 + t2; + b4 += b5 + k6; + b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + + b7 += k0 + 2; + b6 += b7 + k8 + t0; + b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + + b2 += b1; + b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + + b4 += b7; + b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + + b6 += b5; + b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + + b0 += b3; + b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + + b4 += b1; + b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + + b6 += b3; + b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + + b0 += b5; + b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + + b2 += b7; + b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + + b6 += b1; + b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + + b0 += b7; + b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + + b2 += b5; + b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + + b4 += b3; + b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + + b1 += k4; + b0 += b1 + k3; + b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + + b3 += k6; + b2 += b3 + k5; + b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + + b5 += k8 + t0; + b4 += b5 + k7; + b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + + b7 += k1 + 3; + b6 += b7 + k0 + t1; + b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + + b2 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + + b4 += b7; + b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + + b6 += b5; + b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + + b0 += b3; + b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + + b4 += b1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + + b6 += b3; + b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + + b0 += b5; + b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + + b2 += b7; + b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + + b6 += b1; + b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + + b0 += b7; + b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + + b2 += b5; + b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + + b4 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + + b1 += k5; + b0 += b1 + k4; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + + b3 += k7; + b2 += b3 + k6; + b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + + b5 += k0 + t1; + b4 += b5 + k8; + b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + + b7 += k2 + 4; + b6 += b7 + k1 + t2; + b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + + b2 += b1; + b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + + b4 += b7; + b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + + b6 += b5; + b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + + b0 += b3; + b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + + b4 += b1; + b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + + b6 += b3; + b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + + b0 += b5; + b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + + b2 += b7; + b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + + b6 += b1; + b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + + b0 += b7; + b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + + b2 += b5; + b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + + b4 += b3; + b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + + b1 += k6; + b0 += b1 + k5; + b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + + b3 += k8; + b2 += b3 + k7; + b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + + b5 += k1 + t2; + b4 += b5 + k0; + b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + + b7 += k3 + 5; + b6 += b7 + k2 + t0; + b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + + b2 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + + b4 += b7; + b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + + b6 += b5; + b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + + b0 += b3; + b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + + b4 += b1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + + b6 += b3; + b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + + b0 += b5; + b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + + b2 += b7; + b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + + b6 += b1; + b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + + b0 += b7; + b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + + b2 += b5; + b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + + b4 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + + b1 += k7; + b0 += b1 + k6; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + + b3 += k0; + b2 += b3 + k8; + b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + + b5 += k2 + t0; + b4 += b5 + k1; + b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + + b7 += k4 + 6; + b6 += b7 + k3 + t1; + b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + + b2 += b1; + b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + + b4 += b7; + b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + + b6 += b5; + b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + + b0 += b3; + b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + + b4 += b1; + b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + + b6 += b3; + b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + + b0 += b5; + b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + + b2 += b7; + b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + + b6 += b1; + b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + + b0 += b7; + b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + + b2 += b5; + b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + + b4 += b3; + b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + + b1 += k8; + b0 += b1 + k7; + b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + + b3 += k1; + b2 += b3 + k0; + b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + + b5 += k3 + t1; + b4 += b5 + k2; + b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + + b7 += k5 + 7; + b6 += b7 + k4 + t2; + b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + + b2 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + + b4 += b7; + b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + + b6 += b5; + b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + + b0 += b3; + b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + + b4 += b1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + + b6 += b3; + b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + + b0 += b5; + b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + + b2 += b7; + b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + + b6 += b1; + b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + + b0 += b7; + b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + + b2 += b5; + b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + + b4 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + + b1 += k0; + b0 += b1 + k8; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + + b3 += k2; + b2 += b3 + k1; + b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + + b5 += k4 + t2; + b4 += b5 + k3; + b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + + b7 += k6 + 8; + b6 += b7 + k5 + t0; + b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + + b2 += b1; + b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + + b4 += b7; + b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + + b6 += b5; + b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + + b0 += b3; + b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + + b4 += b1; + b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + + b6 += b3; + b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + + b0 += b5; + b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + + b2 += b7; + b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + + b6 += b1; + b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + + b0 += b7; + b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + + b2 += b5; + b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + + b4 += b3; + b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + + b1 += k1; + b0 += b1 + k0; + b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + + b3 += k3; + b2 += b3 + k2; + b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + + b5 += k5 + t0; + b4 += b5 + k4; + b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + + b7 += k7 + 9; + b6 += b7 + k6 + t1; + b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + + b2 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + + b4 += b7; + b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + + b6 += b5; + b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + + b0 += b3; + b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + + b4 += b1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + + b6 += b3; + b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + + b0 += b5; + b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + + b2 += b7; + b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + + b6 += b1; + b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + + b0 += b7; + b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + + b2 += b5; + b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + + b4 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + + b1 += k2; + b0 += b1 + k1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + + b3 += k4; + b2 += b3 + k3; + b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + + b5 += k6 + t1; + b4 += b5 + k5; + b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + + b7 += k8 + 10; + b6 += b7 + k7 + t2; + b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + + b2 += b1; + b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + + b4 += b7; + b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + + b6 += b5; + b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + + b0 += b3; + b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + + b4 += b1; + b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + + b6 += b3; + b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + + b0 += b5; + b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + + b2 += b7; + b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + + b6 += b1; + b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + + b0 += b7; + b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + + b2 += b5; + b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + + b4 += b3; + b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + + b1 += k3; + b0 += b1 + k2; + b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + + b3 += k5; + b2 += b3 + k4; + b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + + b5 += k7 + t2; + b4 += b5 + k6; + b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + + b7 += k0 + 11; + b6 += b7 + k8 + t0; + b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + + b2 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + + b4 += b7; + b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + + b6 += b5; + b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + + b0 += b3; + b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + + b4 += b1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + + b6 += b3; + b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + + b0 += b5; + b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + + b2 += b7; + b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + + b6 += b1; + b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + + b0 += b7; + b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + + b2 += b5; + b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + + b4 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + + b1 += k4; + b0 += b1 + k3; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + + b3 += k6; + b2 += b3 + k5; + b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + + b5 += k8 + t0; + b4 += b5 + k7; + b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + + b7 += k1 + 12; + b6 += b7 + k0 + t1; + b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + + b2 += b1; + b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + + b4 += b7; + b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + + b6 += b5; + b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + + b0 += b3; + b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + + b4 += b1; + b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + + b6 += b3; + b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + + b0 += b5; + b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + + b2 += b7; + b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + + b6 += b1; + b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + + b0 += b7; + b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + + b2 += b5; + b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + + b4 += b3; + b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + + b1 += k5; + b0 += b1 + k4; + b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + + b3 += k7; + b2 += b3 + k6; + b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + + b5 += k0 + t1; + b4 += b5 + k8; + b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + + b7 += k2 + 13; + b6 += b7 + k1 + t2; + b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + + b2 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + + b4 += b7; + b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + + b6 += b5; + b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + + b0 += b3; + b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + + b4 += b1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + + b6 += b3; + b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + + b0 += b5; + b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + + b2 += b7; + b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + + b6 += b1; + b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + + b0 += b7; + b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + + b2 += b5; + b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + + b4 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + + b1 += k6; + b0 += b1 + k5; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + + b3 += k8; + b2 += b3 + k7; + b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + + b5 += k1 + t2; + b4 += b5 + k0; + b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + + b7 += k3 + 14; + b6 += b7 + k2 + t0; + b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + + b2 += b1; + b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + + b4 += b7; + b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + + b6 += b5; + b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + + b0 += b3; + b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + + b4 += b1; + b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + + b6 += b3; + b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + + b0 += b5; + b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + + b2 += b7; + b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + + b6 += b1; + b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + + b0 += b7; + b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + + b2 += b5; + b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + + b4 += b3; + b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + + b1 += k7; + b0 += b1 + k6; + b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + + b3 += k0; + b2 += b3 + k8; + b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + + b5 += k2 + t0; + b4 += b5 + k1; + b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + + b7 += k4 + 15; + b6 += b7 + k3 + t1; + b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + + b2 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + + b4 += b7; + b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + + b6 += b5; + b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + + b0 += b3; + b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + + b4 += b1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + + b6 += b3; + b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + + b0 += b5; + b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + + b2 += b7; + b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + + b6 += b1; + b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + + b0 += b7; + b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + + b2 += b5; + b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + + b4 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + + b1 += k8; + b0 += b1 + k7; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + + b3 += k1; + b2 += b3 + k0; + b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + + b5 += k3 + t1; + b4 += b5 + k2; + b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + + b7 += k5 + 16; + b6 += b7 + k4 + t2; + b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + + b2 += b1; + b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + + b4 += b7; + b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + + b6 += b5; + b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + + b0 += b3; + b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + + b4 += b1; + b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + + b6 += b3; + b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + + b0 += b5; + b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + + b2 += b7; + b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + + b6 += b1; + b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + + b0 += b7; + b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + + b2 += b5; + b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + + b4 += b3; + b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + + b1 += k0; + b0 += b1 + k8; + b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + + b3 += k2; + b2 += b3 + k1; + b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + + b5 += k4 + t2; + b4 += b5 + k3; + b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + + b7 += k6 + 17; + b6 += b7 + k5 + t0; + b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + + b2 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + + b4 += b7; + b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + + b6 += b5; + b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + + b0 += b3; + b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + + b4 += b1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + + b6 += b3; + b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + + b0 += b5; + b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + + b2 += b7; + b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + + b6 += b1; + b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + + b0 += b7; + b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + + b2 += b5; + b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + + b4 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; output[0] = b0 + k0; output[1] = b1 + k1; @@ -315,318 +962,1254 @@ void threefishEncrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output) output[7] = b7 + k7 + 18; } -void threefishDecrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output) -{ - u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3], - b4 = input[4], b5 = input[5], - b6 = input[6], b7 = input[7]; - u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1], - k2 = keyCtx->key[2], k3 = keyCtx->key[3], - k4 = keyCtx->key[4], k5 = keyCtx->key[5], - k6 = keyCtx->key[6], k7 = keyCtx->key[7], - k8 = keyCtx->key[8]; - u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], - t2 = keyCtx->tweak[2]; +void threefishDecrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output) +{ + u64 b0 = input[0], b1 = input[1], + b2 = input[2], b3 = input[3], + b4 = input[4], b5 = input[5], + b6 = input[6], b7 = input[7]; + u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1], + k2 = keyCtx->key[2], k3 = keyCtx->key[3], + k4 = keyCtx->key[4], k5 = keyCtx->key[5], + k6 = keyCtx->key[6], k7 = keyCtx->key[7], + k8 = keyCtx->key[8]; + u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], + t2 = keyCtx->tweak[2]; + + u64 tmp; + + b0 -= k0; + b1 -= k1; + b2 -= k2; + b3 -= k3; + b4 -= k4; + b5 -= k5 + t0; + b6 -= k6 + t1; + b7 -= k7 + 18; + + tmp = b3 ^ b4; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 56) | (tmp << (64 - 56)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 35) | (tmp << (64 - 35)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 8) | (tmp << (64 - 8)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 43) | (tmp << (64 - 43)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 29) | (tmp << (64 - 29)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 17) | (tmp << (64 - 17)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 50) | (tmp << (64 - 50)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 24) | (tmp << (64 - 24)); + b6 -= b7 + k5 + t0; + b7 -= k6 + 17; + + tmp = b5 ^ b4; + b5 = (tmp >> 34) | (tmp << (64 - 34)); + b4 -= b5 + k3; + b5 -= k4 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 30) | (tmp << (64 - 30)); + b2 -= b3 + k1; + b3 -= k2; + + tmp = b1 ^ b0; + b1 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b1 + k8; + b1 -= k0; + + tmp = b3 ^ b4; + b3 = (tmp >> 56) | (tmp << (64 - 56)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 54) | (tmp << (64 - 54)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 44) | (tmp << (64 - 44)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 39) | (tmp << (64 - 39)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 36) | (tmp << (64 - 36)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 49) | (tmp << (64 - 49)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 17) | (tmp << (64 - 17)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 42) | (tmp << (64 - 42)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 14) | (tmp << (64 - 14)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 27) | (tmp << (64 - 27)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 37) | (tmp << (64 - 37)); + b6 -= b7 + k4 + t2; + b7 -= k5 + 16; + + tmp = b5 ^ b4; + b5 = (tmp >> 19) | (tmp << (64 - 19)); + b4 -= b5 + k2; + b5 -= k3 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 36) | (tmp << (64 - 36)); + b2 -= b3 + k0; + b3 -= k1; + + tmp = b1 ^ b0; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b1 + k7; + b1 -= k8; + + tmp = b3 ^ b4; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 56) | (tmp << (64 - 56)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 35) | (tmp << (64 - 35)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 8) | (tmp << (64 - 8)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 43) | (tmp << (64 - 43)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 29) | (tmp << (64 - 29)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 17) | (tmp << (64 - 17)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 50) | (tmp << (64 - 50)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 24) | (tmp << (64 - 24)); + b6 -= b7 + k3 + t1; + b7 -= k4 + 15; + + tmp = b5 ^ b4; + b5 = (tmp >> 34) | (tmp << (64 - 34)); + b4 -= b5 + k1; + b5 -= k2 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 30) | (tmp << (64 - 30)); + b2 -= b3 + k8; + b3 -= k0; + + tmp = b1 ^ b0; + b1 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b1 + k6; + b1 -= k7; + + tmp = b3 ^ b4; + b3 = (tmp >> 56) | (tmp << (64 - 56)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 54) | (tmp << (64 - 54)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 44) | (tmp << (64 - 44)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 39) | (tmp << (64 - 39)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 36) | (tmp << (64 - 36)); + b0 -= b5; - u64 tmp; + tmp = b3 ^ b6; + b3 = (tmp >> 49) | (tmp << (64 - 49)); + b6 -= b3; - b0 -= k0; - b1 -= k1; - b2 -= k2; + tmp = b1 ^ b4; + b1 = (tmp >> 17) | (tmp << (64 - 17)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 42) | (tmp << (64 - 42)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 14) | (tmp << (64 - 14)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 27) | (tmp << (64 - 27)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 37) | (tmp << (64 - 37)); + b6 -= b7 + k2 + t0; + b7 -= k3 + 14; + + tmp = b5 ^ b4; + b5 = (tmp >> 19) | (tmp << (64 - 19)); + b4 -= b5 + k0; + b5 -= k1 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 36) | (tmp << (64 - 36)); + b2 -= b3 + k7; + b3 -= k8; + + tmp = b1 ^ b0; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b1 + k5; + b1 -= k6; + + tmp = b3 ^ b4; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 56) | (tmp << (64 - 56)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 35) | (tmp << (64 - 35)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 8) | (tmp << (64 - 8)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 43) | (tmp << (64 - 43)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 29) | (tmp << (64 - 29)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 17) | (tmp << (64 - 17)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 50) | (tmp << (64 - 50)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 24) | (tmp << (64 - 24)); + b6 -= b7 + k1 + t2; + b7 -= k2 + 13; + + tmp = b5 ^ b4; + b5 = (tmp >> 34) | (tmp << (64 - 34)); + b4 -= b5 + k8; + b5 -= k0 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 30) | (tmp << (64 - 30)); + b2 -= b3 + k6; + b3 -= k7; + + tmp = b1 ^ b0; + b1 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b1 + k4; + b1 -= k5; + + tmp = b3 ^ b4; + b3 = (tmp >> 56) | (tmp << (64 - 56)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 54) | (tmp << (64 - 54)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 44) | (tmp << (64 - 44)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 39) | (tmp << (64 - 39)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 36) | (tmp << (64 - 36)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 49) | (tmp << (64 - 49)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 17) | (tmp << (64 - 17)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 42) | (tmp << (64 - 42)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 14) | (tmp << (64 - 14)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 27) | (tmp << (64 - 27)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 37) | (tmp << (64 - 37)); + b6 -= b7 + k0 + t1; + b7 -= k1 + 12; + + tmp = b5 ^ b4; + b5 = (tmp >> 19) | (tmp << (64 - 19)); + b4 -= b5 + k7; + b5 -= k8 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 36) | (tmp << (64 - 36)); + b2 -= b3 + k5; + b3 -= k6; + + tmp = b1 ^ b0; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b1 + k3; + b1 -= k4; + + tmp = b3 ^ b4; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 56) | (tmp << (64 - 56)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 35) | (tmp << (64 - 35)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 8) | (tmp << (64 - 8)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 43) | (tmp << (64 - 43)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 29) | (tmp << (64 - 29)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 17) | (tmp << (64 - 17)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 50) | (tmp << (64 - 50)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 24) | (tmp << (64 - 24)); + b6 -= b7 + k8 + t0; + b7 -= k0 + 11; + + tmp = b5 ^ b4; + b5 = (tmp >> 34) | (tmp << (64 - 34)); + b4 -= b5 + k6; + b5 -= k7 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 30) | (tmp << (64 - 30)); + b2 -= b3 + k4; + b3 -= k5; + + tmp = b1 ^ b0; + b1 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b1 + k2; + b1 -= k3; + + tmp = b3 ^ b4; + b3 = (tmp >> 56) | (tmp << (64 - 56)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 54) | (tmp << (64 - 54)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 44) | (tmp << (64 - 44)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 39) | (tmp << (64 - 39)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 36) | (tmp << (64 - 36)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 49) | (tmp << (64 - 49)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 17) | (tmp << (64 - 17)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 42) | (tmp << (64 - 42)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 14) | (tmp << (64 - 14)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 27) | (tmp << (64 - 27)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 37) | (tmp << (64 - 37)); + b6 -= b7 + k7 + t2; + b7 -= k8 + 10; + + tmp = b5 ^ b4; + b5 = (tmp >> 19) | (tmp << (64 - 19)); + b4 -= b5 + k5; + b5 -= k6 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 36) | (tmp << (64 - 36)); + b2 -= b3 + k3; + b3 -= k4; + + tmp = b1 ^ b0; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b1 + k1; + b1 -= k2; + + tmp = b3 ^ b4; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 56) | (tmp << (64 - 56)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 35) | (tmp << (64 - 35)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 8) | (tmp << (64 - 8)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 43) | (tmp << (64 - 43)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 29) | (tmp << (64 - 29)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 17) | (tmp << (64 - 17)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 50) | (tmp << (64 - 50)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 24) | (tmp << (64 - 24)); + b6 -= b7 + k6 + t1; + b7 -= k7 + 9; + + tmp = b5 ^ b4; + b5 = (tmp >> 34) | (tmp << (64 - 34)); + b4 -= b5 + k4; + b5 -= k5 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 30) | (tmp << (64 - 30)); + b2 -= b3 + k2; b3 -= k3; - b4 -= k4; + + tmp = b1 ^ b0; + b1 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b1 + k0; + b1 -= k1; + + tmp = b3 ^ b4; + b3 = (tmp >> 56) | (tmp << (64 - 56)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 54) | (tmp << (64 - 54)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 44) | (tmp << (64 - 44)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 39) | (tmp << (64 - 39)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 36) | (tmp << (64 - 36)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 49) | (tmp << (64 - 49)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 17) | (tmp << (64 - 17)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 42) | (tmp << (64 - 42)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 14) | (tmp << (64 - 14)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 27) | (tmp << (64 - 27)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 37) | (tmp << (64 - 37)); + b6 -= b7 + k5 + t0; + b7 -= k6 + 8; + + tmp = b5 ^ b4; + b5 = (tmp >> 19) | (tmp << (64 - 19)); + b4 -= b5 + k3; + b5 -= k4 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 36) | (tmp << (64 - 36)); + b2 -= b3 + k1; + b3 -= k2; + + tmp = b1 ^ b0; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b1 + k8; + b1 -= k0; + + tmp = b3 ^ b4; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 56) | (tmp << (64 - 56)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 35) | (tmp << (64 - 35)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 8) | (tmp << (64 - 8)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 43) | (tmp << (64 - 43)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 29) | (tmp << (64 - 29)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 17) | (tmp << (64 - 17)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 50) | (tmp << (64 - 50)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 24) | (tmp << (64 - 24)); + b6 -= b7 + k4 + t2; + b7 -= k5 + 7; + + tmp = b5 ^ b4; + b5 = (tmp >> 34) | (tmp << (64 - 34)); + b4 -= b5 + k2; + b5 -= k3 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 30) | (tmp << (64 - 30)); + b2 -= b3 + k0; + b3 -= k1; + + tmp = b1 ^ b0; + b1 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b1 + k7; + b1 -= k8; + + tmp = b3 ^ b4; + b3 = (tmp >> 56) | (tmp << (64 - 56)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 54) | (tmp << (64 - 54)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 44) | (tmp << (64 - 44)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 39) | (tmp << (64 - 39)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 36) | (tmp << (64 - 36)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 49) | (tmp << (64 - 49)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 17) | (tmp << (64 - 17)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 42) | (tmp << (64 - 42)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 14) | (tmp << (64 - 14)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 27) | (tmp << (64 - 27)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 37) | (tmp << (64 - 37)); + b6 -= b7 + k3 + t1; + b7 -= k4 + 6; + + tmp = b5 ^ b4; + b5 = (tmp >> 19) | (tmp << (64 - 19)); + b4 -= b5 + k1; + b5 -= k2 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 36) | (tmp << (64 - 36)); + b2 -= b3 + k8; + b3 -= k0; + + tmp = b1 ^ b0; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b1 + k6; + b1 -= k7; + + tmp = b3 ^ b4; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 56) | (tmp << (64 - 56)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 35) | (tmp << (64 - 35)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 8) | (tmp << (64 - 8)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 43) | (tmp << (64 - 43)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 29) | (tmp << (64 - 29)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 17) | (tmp << (64 - 17)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 50) | (tmp << (64 - 50)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 24) | (tmp << (64 - 24)); + b6 -= b7 + k2 + t0; + b7 -= k3 + 5; + + tmp = b5 ^ b4; + b5 = (tmp >> 34) | (tmp << (64 - 34)); + b4 -= b5 + k0; + b5 -= k1 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 30) | (tmp << (64 - 30)); + b2 -= b3 + k7; + b3 -= k8; + + tmp = b1 ^ b0; + b1 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b1 + k5; + b1 -= k6; + + tmp = b3 ^ b4; + b3 = (tmp >> 56) | (tmp << (64 - 56)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 54) | (tmp << (64 - 54)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 44) | (tmp << (64 - 44)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 39) | (tmp << (64 - 39)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 36) | (tmp << (64 - 36)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 49) | (tmp << (64 - 49)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 17) | (tmp << (64 - 17)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 42) | (tmp << (64 - 42)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 14) | (tmp << (64 - 14)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 27) | (tmp << (64 - 27)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 37) | (tmp << (64 - 37)); + b6 -= b7 + k1 + t2; + b7 -= k2 + 4; + + tmp = b5 ^ b4; + b5 = (tmp >> 19) | (tmp << (64 - 19)); + b4 -= b5 + k8; + b5 -= k0 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 36) | (tmp << (64 - 36)); + b2 -= b3 + k6; + b3 -= k7; + + tmp = b1 ^ b0; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b1 + k4; + b1 -= k5; + + tmp = b3 ^ b4; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 56) | (tmp << (64 - 56)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 35) | (tmp << (64 - 35)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 8) | (tmp << (64 - 8)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 43) | (tmp << (64 - 43)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 29) | (tmp << (64 - 29)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 17) | (tmp << (64 - 17)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 50) | (tmp << (64 - 50)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 24) | (tmp << (64 - 24)); + b6 -= b7 + k0 + t1; + b7 -= k1 + 3; + + tmp = b5 ^ b4; + b5 = (tmp >> 34) | (tmp << (64 - 34)); + b4 -= b5 + k7; + b5 -= k8 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 30) | (tmp << (64 - 30)); + b2 -= b3 + k5; + b3 -= k6; + + tmp = b1 ^ b0; + b1 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b1 + k3; + b1 -= k4; + + tmp = b3 ^ b4; + b3 = (tmp >> 56) | (tmp << (64 - 56)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 54) | (tmp << (64 - 54)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 44) | (tmp << (64 - 44)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 39) | (tmp << (64 - 39)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 36) | (tmp << (64 - 36)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 49) | (tmp << (64 - 49)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 17) | (tmp << (64 - 17)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 42) | (tmp << (64 - 42)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 14) | (tmp << (64 - 14)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 27) | (tmp << (64 - 27)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 37) | (tmp << (64 - 37)); + b6 -= b7 + k8 + t0; + b7 -= k0 + 2; + + tmp = b5 ^ b4; + b5 = (tmp >> 19) | (tmp << (64 - 19)); + b4 -= b5 + k6; + b5 -= k7 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 36) | (tmp << (64 - 36)); + b2 -= b3 + k4; + b3 -= k5; + + tmp = b1 ^ b0; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b1 + k2; + b1 -= k3; + + tmp = b3 ^ b4; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 56) | (tmp << (64 - 56)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 35) | (tmp << (64 - 35)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 8) | (tmp << (64 - 8)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 43) | (tmp << (64 - 43)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 29) | (tmp << (64 - 29)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 17) | (tmp << (64 - 17)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 50) | (tmp << (64 - 50)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 24) | (tmp << (64 - 24)); + b6 -= b7 + k7 + t2; + b7 -= k8 + 1; + + tmp = b5 ^ b4; + b5 = (tmp >> 34) | (tmp << (64 - 34)); + b4 -= b5 + k5; + b5 -= k6 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 30) | (tmp << (64 - 30)); + b2 -= b3 + k3; + b3 -= k4; + + tmp = b1 ^ b0; + b1 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b1 + k1; + b1 -= k2; + + tmp = b3 ^ b4; + b3 = (tmp >> 56) | (tmp << (64 - 56)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 54) | (tmp << (64 - 54)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 44) | (tmp << (64 - 44)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 39) | (tmp << (64 - 39)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 36) | (tmp << (64 - 36)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 49) | (tmp << (64 - 49)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 17) | (tmp << (64 - 17)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 42) | (tmp << (64 - 42)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 14) | (tmp << (64 - 14)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 27) | (tmp << (64 - 27)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 37) | (tmp << (64 - 37)); + b6 -= b7 + k6 + t1; + b7 -= k7; + + tmp = b5 ^ b4; + b5 = (tmp >> 19) | (tmp << (64 - 19)); + b4 -= b5 + k4; b5 -= k5 + t0; - b6 -= k6 + t1; - b7 -= k7 + 18; - tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k5 + t0; b7 -= k6 + 17; - tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k3; b5 -= k4 + t2; - tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k1; b3 -= k2; - tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k8; b1 -= k0; - tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k4 + t2; b7 -= k5 + 16; - tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k2; b5 -= k3 + t1; - tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k0; b3 -= k1; - tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k7; b1 -= k8; - tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k3 + t1; b7 -= k4 + 15; - tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k1; b5 -= k2 + t0; - tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k8; b3 -= k0; - tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k6; b1 -= k7; - tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k2 + t0; b7 -= k3 + 14; - tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k0; b5 -= k1 + t2; - tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k7; b3 -= k8; - tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k5; b1 -= k6; - tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k1 + t2; b7 -= k2 + 13; - tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k8; b5 -= k0 + t1; - tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k6; b3 -= k7; - tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k4; b1 -= k5; - tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k0 + t1; b7 -= k1 + 12; - tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k7; b5 -= k8 + t0; - tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k5; b3 -= k6; - tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k3; b1 -= k4; - tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k8 + t0; b7 -= k0 + 11; - tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k6; b5 -= k7 + t2; - tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k4; b3 -= k5; - tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k2; b1 -= k3; - tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k7 + t2; b7 -= k8 + 10; - tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k5; b5 -= k6 + t1; - tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k3; b3 -= k4; - tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k1; b1 -= k2; - tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k6 + t1; b7 -= k7 + 9; - tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k4; b5 -= k5 + t0; - tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k2; b3 -= k3; - tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k0; b1 -= k1; - tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k5 + t0; b7 -= k6 + 8; - tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k3; b5 -= k4 + t2; - tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k1; b3 -= k2; - tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k8; b1 -= k0; - tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k4 + t2; b7 -= k5 + 7; - tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k2; b5 -= k3 + t1; - tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k0; b3 -= k1; - tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k7; b1 -= k8; - tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k3 + t1; b7 -= k4 + 6; - tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k1; b5 -= k2 + t0; - tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k8; b3 -= k0; - tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k6; b1 -= k7; - tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k2 + t0; b7 -= k3 + 5; - tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k0; b5 -= k1 + t2; - tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k7; b3 -= k8; - tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k5; b1 -= k6; - tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k1 + t2; b7 -= k2 + 4; - tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k8; b5 -= k0 + t1; - tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k6; b3 -= k7; - tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k4; b1 -= k5; - tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k0 + t1; b7 -= k1 + 3; - tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k7; b5 -= k8 + t0; - tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k5; b3 -= k6; - tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k3; b1 -= k4; - tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k8 + t0; b7 -= k0 + 2; - tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k6; b5 -= k7 + t2; - tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k4; b3 -= k5; - tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k2; b1 -= k3; - tmp = b3 ^ b4; b3 = (tmp >> 22) | (tmp << (64 - 22)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 56) | (tmp << (64 - 56)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 35) | (tmp << (64 - 35)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 8) | (tmp << (64 - 8)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 43) | (tmp << (64 - 43)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 29) | (tmp << (64 - 29)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 25) | (tmp << (64 - 25)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 17) | (tmp << (64 - 17)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 10) | (tmp << (64 - 10)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 50) | (tmp << (64 - 50)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 13) | (tmp << (64 - 13)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 24) | (tmp << (64 - 24)); b6 -= b7 + k7 + t2; b7 -= k8 + 1; - tmp = b5 ^ b4; b5 = (tmp >> 34) | (tmp << (64 - 34)); b4 -= b5 + k5; b5 -= k6 + t1; - tmp = b3 ^ b2; b3 = (tmp >> 30) | (tmp << (64 - 30)); b2 -= b3 + k3; b3 -= k4; - tmp = b1 ^ b0; b1 = (tmp >> 39) | (tmp << (64 - 39)); b0 -= b1 + k1; b1 -= k2; - tmp = b3 ^ b4; b3 = (tmp >> 56) | (tmp << (64 - 56)); b4 -= b3; - tmp = b5 ^ b2; b5 = (tmp >> 54) | (tmp << (64 - 54)); b2 -= b5; - tmp = b7 ^ b0; b7 = (tmp >> 9) | (tmp << (64 - 9)); b0 -= b7; - tmp = b1 ^ b6; b1 = (tmp >> 44) | (tmp << (64 - 44)); b6 -= b1; - tmp = b7 ^ b2; b7 = (tmp >> 39) | (tmp << (64 - 39)); b2 -= b7; - tmp = b5 ^ b0; b5 = (tmp >> 36) | (tmp << (64 - 36)); b0 -= b5; - tmp = b3 ^ b6; b3 = (tmp >> 49) | (tmp << (64 - 49)); b6 -= b3; - tmp = b1 ^ b4; b1 = (tmp >> 17) | (tmp << (64 - 17)); b4 -= b1; - tmp = b3 ^ b0; b3 = (tmp >> 42) | (tmp << (64 - 42)); b0 -= b3; - tmp = b5 ^ b6; b5 = (tmp >> 14) | (tmp << (64 - 14)); b6 -= b5; - tmp = b7 ^ b4; b7 = (tmp >> 27) | (tmp << (64 - 27)); b4 -= b7; - tmp = b1 ^ b2; b1 = (tmp >> 33) | (tmp << (64 - 33)); b2 -= b1; - tmp = b7 ^ b6; b7 = (tmp >> 37) | (tmp << (64 - 37)); b6 -= b7 + k6 + t1; b7 -= k7; - tmp = b5 ^ b4; b5 = (tmp >> 19) | (tmp << (64 - 19)); b4 -= b5 + k4; b5 -= k5 + t0; - tmp = b3 ^ b2; b3 = (tmp >> 36) | (tmp << (64 - 36)); b2 -= b3 + k2; b3 -= k3; - tmp = b1 ^ b0; b1 = (tmp >> 46) | (tmp << (64 - 46)); b0 -= b1 + k0; b1 -= k1; + + tmp = b3 ^ b2; + b3 = (tmp >> 36) | (tmp << (64 - 36)); + b2 -= b3 + k2; + b3 -= k3; + + tmp = b1 ^ b0; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b1 + k0; + b1 -= k1; output[0] = b0; output[1] = b1; diff --git a/drivers/staging/skein/threefishApi.c b/drivers/staging/skein/threefishApi.c index e8ce06a9122f..1e70f66b7032 100644 --- a/drivers/staging/skein/threefishApi.c +++ b/drivers/staging/skein/threefishApi.c @@ -3,8 +3,9 @@ #include #include -void threefishSetKey(struct threefish_key *keyCtx, enum threefish_size stateSize, - u64 *keyData, u64 *tweak) +void threefishSetKey(struct threefish_key *keyCtx, + enum threefish_size stateSize, + u64 *keyData, u64 *tweak) { int keyWords = stateSize / 64; int i; @@ -28,9 +29,9 @@ void threefishEncryptBlockBytes(struct threefish_key *keyCtx, u8 *in, u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ u64 cipher[SKEIN_MAX_STATE_WORDS]; - Skein_Get64_LSB_First(plain, in, keyCtx->stateSize / 64); /* bytes to words */ + Skein_Get64_LSB_First(plain, in, keyCtx->stateSize / 64); threefishEncryptBlockWords(keyCtx, plain, cipher); - Skein_Put64_LSB_First(out, cipher, keyCtx->stateSize / 8); /* words to bytes */ + Skein_Put64_LSB_First(out, cipher, keyCtx->stateSize / 8); } void threefishEncryptBlockWords(struct threefish_key *keyCtx, u64 *in, @@ -55,9 +56,9 @@ void threefishDecryptBlockBytes(struct threefish_key *keyCtx, u8 *in, u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ u64 cipher[SKEIN_MAX_STATE_WORDS]; - Skein_Get64_LSB_First(cipher, in, keyCtx->stateSize / 64); /* bytes to words */ + Skein_Get64_LSB_First(cipher, in, keyCtx->stateSize / 64); threefishDecryptBlockWords(keyCtx, cipher, plain); - Skein_Put64_LSB_First(out, plain, keyCtx->stateSize / 8); /* words to bytes */ + Skein_Put64_LSB_First(out, plain, keyCtx->stateSize / 8); } void threefishDecryptBlockWords(struct threefish_key *keyCtx, u64 *in, -- cgit v1.2.3 From 51cc00fd1eb05175b488e40ed8504833b05c02f0 Mon Sep 17 00:00:00 2001 From: Jason Cooper Date: Mon, 24 Mar 2014 01:49:12 +0000 Subject: staging: crypto: skein: fix do/while brace formatting Signed-off-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/skein_block.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/staging/skein/skein_block.c b/drivers/staging/skein/skein_block.c index 780b4936f783..6e0f4a21aae3 100644 --- a/drivers/staging/skein/skein_block.c +++ b/drivers/staging/skein/skein_block.c @@ -215,8 +215,7 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, Skein_Show_Round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X); ts[1] &= ~SKEIN_T1_FLAG_FIRST; - } - while (--blkCnt); + } while (--blkCnt); ctx->h.T[0] = ts[0]; ctx->h.T[1] = ts[1]; } @@ -434,8 +433,7 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, Skein_Show_Round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X); ts[1] &= ~SKEIN_T1_FLAG_FIRST; - } - while (--blkCnt); + } while (--blkCnt); ctx->h.T[0] = ts[0]; ctx->h.T[1] = ts[1]; } @@ -717,8 +715,7 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, \ ts[1] &= ~SKEIN_T1_FLAG_FIRST; blkPtr += SKEIN1024_BLOCK_BYTES; - } - while (--blkCnt); + } while (--blkCnt); ctx->h.T[0] = ts[0]; ctx->h.T[1] = ts[1]; } -- cgit v1.2.3 From 161a2afdf50ade4558f31dbbd371480a057e6f08 Mon Sep 17 00:00:00 2001 From: Jason Cooper Date: Mon, 24 Mar 2014 01:49:13 +0000 Subject: staging: crypto: skein: fix brace placement errors Signed-off-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/include/skein.h | 30 ++++----- drivers/staging/skein/include/skein_iv.h | 65 ++++++++---------- drivers/staging/skein/skein.c | 111 ++++++++++--------------------- 3 files changed, 74 insertions(+), 132 deletions(-) diff --git a/drivers/staging/skein/include/skein.h b/drivers/staging/skein/include/skein.h index f92dc40711d1..0a2abcecd2f7 100644 --- a/drivers/staging/skein/include/skein.h +++ b/drivers/staging/skein/include/skein.h @@ -37,12 +37,11 @@ #define Skein_Get64_LSB_First(dst64, src08, wCnt) memcpy(dst64, src08, 8*(wCnt)) #define Skein_Swap64(w64) (w64) -enum - { +enum { SKEIN_SUCCESS = 0, /* return codes from Skein calls */ SKEIN_FAIL = 1, SKEIN_BAD_HASHLEN = 2 - }; +}; #define SKEIN_MODIFIER_WORDS (2) /* number of modifier (tweak) words */ @@ -63,33 +62,29 @@ enum #define SKEIN_512_BLOCK_BYTES (8*SKEIN_512_STATE_WORDS) #define SKEIN1024_BLOCK_BYTES (8*SKEIN1024_STATE_WORDS) -struct skein_ctx_hdr - { +struct skein_ctx_hdr { size_t hashBitLen; /* size of hash result, in bits */ size_t bCnt; /* current byte count in buffer b[] */ u64 T[SKEIN_MODIFIER_WORDS]; /* tweak: T[0]=byte cnt, T[1]=flags */ - }; +}; -struct skein_256_ctx /* 256-bit Skein hash context structure */ - { +struct skein_256_ctx { /* 256-bit Skein hash context structure */ struct skein_ctx_hdr h; /* common header context variables */ u64 X[SKEIN_256_STATE_WORDS]; /* chaining variables */ u8 b[SKEIN_256_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ - }; +}; -struct skein_512_ctx /* 512-bit Skein hash context structure */ - { +struct skein_512_ctx { /* 512-bit Skein hash context structure */ struct skein_ctx_hdr h; /* common header context variables */ u64 X[SKEIN_512_STATE_WORDS]; /* chaining variables */ u8 b[SKEIN_512_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ - }; +}; -struct skein1024_ctx /* 1024-bit Skein hash context structure */ - { +struct skein1024_ctx { /* 1024-bit Skein hash context structure */ struct skein_ctx_hdr h; /* common header context variables */ u64 X[SKEIN1024_STATE_WORDS]; /* chaining variables */ u8 b[SKEIN1024_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ - }; +}; /* Skein APIs for (incremental) "straight hashing" */ int Skein_256_Init(struct skein_256_ctx *ctx, size_t hashBitLen); @@ -296,8 +291,7 @@ int Skein1024_Output(struct skein1024_ctx *ctx, u8 *hashVal); /***************************************************************** ** Skein block function constants (shared across Ref and Opt code) ******************************************************************/ -enum - { +enum { /* Skein_256 round rotation constants */ R_256_0_0 = 14, R_256_0_1 = 16, R_256_1_0 = 52, R_256_1_1 = 57, @@ -335,7 +329,7 @@ enum R1024_6_4 = 19, R1024_6_5 = 42, R1024_6_6 = 44, R1024_6_7 = 25, R1024_7_0 = 9, R1024_7_1 = 48, R1024_7_2 = 35, R1024_7_3 = 52, R1024_7_4 = 23, R1024_7_5 = 31, R1024_7_6 = 37, R1024_7_7 = 20 - }; +}; #ifndef SKEIN_ROUNDS #define SKEIN_256_ROUNDS_TOTAL (72) /* # rounds for diff block sizes */ diff --git a/drivers/staging/skein/include/skein_iv.h b/drivers/staging/skein/include/skein_iv.h index bbbba77c44d3..8dd5e4d88a1d 100644 --- a/drivers/staging/skein/include/skein_iv.h +++ b/drivers/staging/skein/include/skein_iv.h @@ -20,44 +20,39 @@ #define MK_64 SKEIN_MK_64 /* blkSize = 256 bits. hashSize = 128 bits */ -const u64 SKEIN_256_IV_128[] = - { +const u64 SKEIN_256_IV_128[] = { MK_64(0xE1111906, 0x964D7260), MK_64(0x883DAAA7, 0x7C8D811C), MK_64(0x10080DF4, 0x91960F7A), MK_64(0xCCF7DDE5, 0xB45BC1C2) - }; +}; /* blkSize = 256 bits. hashSize = 160 bits */ -const u64 SKEIN_256_IV_160[] = - { +const u64 SKEIN_256_IV_160[] = { MK_64(0x14202314, 0x72825E98), MK_64(0x2AC4E9A2, 0x5A77E590), MK_64(0xD47A5856, 0x8838D63E), MK_64(0x2DD2E496, 0x8586AB7D) - }; +}; /* blkSize = 256 bits. hashSize = 224 bits */ -const u64 SKEIN_256_IV_224[] = - { +const u64 SKEIN_256_IV_224[] = { MK_64(0xC6098A8C, 0x9AE5EA0B), MK_64(0x876D5686, 0x08C5191C), MK_64(0x99CB88D7, 0xD7F53884), MK_64(0x384BDDB1, 0xAEDDB5DE) - }; +}; /* blkSize = 256 bits. hashSize = 256 bits */ -const u64 SKEIN_256_IV_256[] = - { +const u64 SKEIN_256_IV_256[] = { MK_64(0xFC9DA860, 0xD048B449), MK_64(0x2FCA6647, 0x9FA7D833), MK_64(0xB33BC389, 0x6656840F), MK_64(0x6A54E920, 0xFDE8DA69) - }; +}; /* blkSize = 512 bits. hashSize = 128 bits */ -const u64 SKEIN_512_IV_128[] = - { +const u64 SKEIN_512_IV_128[] = { MK_64(0xA8BC7BF3, 0x6FBF9F52), MK_64(0x1E9872CE, 0xBD1AF0AA), MK_64(0x309B1790, 0xB32190D3), @@ -66,11 +61,10 @@ const u64 SKEIN_512_IV_128[] = MK_64(0x1A18EBEA, 0xD46A32E3), MK_64(0xA2CC5B18, 0xCE84AA82), MK_64(0x6982AB28, 0x9D46982D) - }; +}; /* blkSize = 512 bits. hashSize = 160 bits */ -const u64 SKEIN_512_IV_160[] = - { +const u64 SKEIN_512_IV_160[] = { MK_64(0x28B81A2A, 0xE013BD91), MK_64(0xC2F11668, 0xB5BDF78F), MK_64(0x1760D8F3, 0xF6A56F12), @@ -79,11 +73,10 @@ const u64 SKEIN_512_IV_160[] = MK_64(0xD908922E, 0x63ED70B8), MK_64(0xB8EC76FF, 0xECCB52FA), MK_64(0x01A47BB8, 0xA3F27A6E) - }; +}; /* blkSize = 512 bits. hashSize = 224 bits */ -const u64 SKEIN_512_IV_224[] = - { +const u64 SKEIN_512_IV_224[] = { MK_64(0xCCD06162, 0x48677224), MK_64(0xCBA65CF3, 0xA92339EF), MK_64(0x8CCD69D6, 0x52FF4B64), @@ -92,11 +85,10 @@ const u64 SKEIN_512_IV_224[] = MK_64(0x6776FE65, 0x75D4EB3D), MK_64(0x99FBC70E, 0x997413E9), MK_64(0x9E2CFCCF, 0xE1C41EF7) - }; +}; /* blkSize = 512 bits. hashSize = 256 bits */ -const u64 SKEIN_512_IV_256[] = - { +const u64 SKEIN_512_IV_256[] = { MK_64(0xCCD044A1, 0x2FDB3E13), MK_64(0xE8359030, 0x1A79A9EB), MK_64(0x55AEA061, 0x4F816E6F), @@ -105,11 +97,10 @@ const u64 SKEIN_512_IV_256[] = MK_64(0xE7A436CD, 0xC4746251), MK_64(0xC36FBAF9, 0x393AD185), MK_64(0x3EEDBA18, 0x33EDFC13) - }; +}; /* blkSize = 512 bits. hashSize = 384 bits */ -const u64 SKEIN_512_IV_384[] = - { +const u64 SKEIN_512_IV_384[] = { MK_64(0xA3F6C6BF, 0x3A75EF5F), MK_64(0xB0FEF9CC, 0xFD84FAA4), MK_64(0x9D77DD66, 0x3D770CFE), @@ -118,11 +109,10 @@ const u64 SKEIN_512_IV_384[] = MK_64(0x7ED7D434, 0xE5807407), MK_64(0x548FC1AC, 0xD4EC44D6), MK_64(0x266E1754, 0x6AA18FF8) - }; +}; /* blkSize = 512 bits. hashSize = 512 bits */ -const u64 SKEIN_512_IV_512[] = - { +const u64 SKEIN_512_IV_512[] = { MK_64(0x4903ADFF, 0x749C51CE), MK_64(0x0D95DE39, 0x9746DF03), MK_64(0x8FD19341, 0x27C79BCE), @@ -131,11 +121,10 @@ const u64 SKEIN_512_IV_512[] = MK_64(0xEABE394C, 0xA9D5C3F4), MK_64(0x991112C7, 0x1A75B523), MK_64(0xAE18A40B, 0x660FCC33) - }; +}; /* blkSize = 1024 bits. hashSize = 384 bits */ -const u64 SKEIN1024_IV_384[] = - { +const u64 SKEIN1024_IV_384[] = { MK_64(0x5102B6B8, 0xC1894A35), MK_64(0xFEEBC9E3, 0xFE8AF11A), MK_64(0x0C807F06, 0xE32BED71), @@ -152,11 +141,10 @@ const u64 SKEIN1024_IV_384[] = MK_64(0x3B5A6530, 0x0DBC6516), MK_64(0x484B9CD2, 0x167BBCE1), MK_64(0x2D136947, 0xD4CBAFEA) - }; +}; /* blkSize = 1024 bits. hashSize = 512 bits */ -const u64 SKEIN1024_IV_512[] = - { +const u64 SKEIN1024_IV_512[] = { MK_64(0xCAEC0E5D, 0x7C1B1B18), MK_64(0xA01B0E04, 0x5F03E802), MK_64(0x33840451, 0xED912885), @@ -173,11 +161,10 @@ const u64 SKEIN1024_IV_512[] = MK_64(0x67070872, 0x5B749816), MK_64(0xB9CD28FB, 0xF0581BD1), MK_64(0x0E2940B8, 0x15804974) - }; +}; /* blkSize = 1024 bits. hashSize = 1024 bits */ -const u64 SKEIN1024_IV_1024[] = - { +const u64 SKEIN1024_IV_1024[] = { MK_64(0xD593DA07, 0x41E72355), MK_64(0x15B5E511, 0xAC73E00C), MK_64(0x5180E5AE, 0xBAF2C4F0), @@ -194,6 +181,6 @@ const u64 SKEIN1024_IV_1024[] = MK_64(0x6572DD22, 0xF2B4969A), MK_64(0x61FD3062, 0xD00A579A), MK_64(0x1DE0536E, 0x8682E539) - }; +}; #endif /* _SKEIN_IV_H_ */ diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c index ed603ee7b170..0d8c70c02c6f 100644 --- a/drivers/staging/skein/skein.c +++ b/drivers/staging/skein/skein.c @@ -31,8 +31,7 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, /* init the context for a straight hashing operation */ int Skein_256_Init(struct skein_256_ctx *ctx, size_t hashBitLen) { - union - { + union { u8 b[SKEIN_256_STATE_BYTES]; u64 w[SKEIN_256_STATE_WORDS]; } cfg; /* config block */ @@ -40,8 +39,7 @@ int Skein_256_Init(struct skein_256_ctx *ctx, size_t hashBitLen) Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN); ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ - switch (hashBitLen) - { /* use pre-computed values, where available */ + switch (hashBitLen) { /* use pre-computed values, where available */ case 256: memcpy(ctx->X, SKEIN_256_IV_256, sizeof(ctx->X)); break; @@ -91,8 +89,7 @@ int Skein_256_Init(struct skein_256_ctx *ctx, size_t hashBitLen) int Skein_256_InitExt(struct skein_256_ctx *ctx, size_t hashBitLen, u64 treeInfo, const u8 *key, size_t keyBytes) { - union - { + union { u8 b[SKEIN_256_STATE_BYTES]; u64 w[SKEIN_256_STATE_WORDS]; } cfg; /* config block */ @@ -101,13 +98,10 @@ int Skein_256_InitExt(struct skein_256_ctx *ctx, size_t hashBitLen, Skein_Assert(keyBytes == 0 || key != NULL, SKEIN_FAIL); /* compute the initial chaining values ctx->X[], based on key */ - if (keyBytes == 0) /* is there a key? */ - { + if (keyBytes == 0) { /* is there a key? */ /* no key: use all zeroes as key for config block */ memset(ctx->X, 0, sizeof(ctx->X)); - } - else /* here to pre-process a key */ - { + } else { /* here to pre-process a key */ Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); /* do a mini-Init right here */ /* set output hash bit count = state size */ @@ -162,15 +156,12 @@ int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg, Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* process full blocks, if any */ - if (msgByteCnt + ctx->h.bCnt > SKEIN_256_BLOCK_BYTES) - { + if (msgByteCnt + ctx->h.bCnt > SKEIN_256_BLOCK_BYTES) { /* finish up any buffered message data */ - if (ctx->h.bCnt) - { + if (ctx->h.bCnt) { /* # bytes free in buffer b[] */ n = SKEIN_256_BLOCK_BYTES - ctx->h.bCnt; - if (n) - { + if (n) { /* check on our logic here */ Skein_assert(n < msgByteCnt); memcpy(&ctx->b[ctx->h.bCnt], msg, n); @@ -187,8 +178,7 @@ int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg, * now process any remaining full blocks, directly from input * message data */ - if (msgByteCnt > SKEIN_256_BLOCK_BYTES) - { + if (msgByteCnt > SKEIN_256_BLOCK_BYTES) { /* number of full blocks to process */ n = (msgByteCnt-1) / SKEIN_256_BLOCK_BYTES; Skein_256_Process_Block(ctx, msg, n, @@ -200,8 +190,7 @@ int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg, } /* copy any remaining source message data bytes into b[] */ - if (msgByteCnt) - { + if (msgByteCnt) { Skein_assert(msgByteCnt + ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES); memcpy(&ctx->b[ctx->h.bCnt], msg, msgByteCnt); ctx->h.bCnt += msgByteCnt; @@ -238,8 +227,7 @@ int Skein_256_Final(struct skein_256_ctx *ctx, u8 *hashVal) memset(ctx->b, 0, sizeof(ctx->b)); /* keep a local copy of counter mode "key" */ memcpy(X, ctx->X, sizeof(X)); - for (i = 0; i*SKEIN_256_BLOCK_BYTES < byteCnt; i++) - { + for (i = 0; i*SKEIN_256_BLOCK_BYTES < byteCnt; i++) { /* build the counter block */ ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); Skein_Start_New_Type(ctx, OUT_FINAL); @@ -268,8 +256,7 @@ int Skein_256_Final(struct skein_256_ctx *ctx, u8 *hashVal) /* init the context for a straight hashing operation */ int Skein_512_Init(struct skein_512_ctx *ctx, size_t hashBitLen) { - union - { + union { u8 b[SKEIN_512_STATE_BYTES]; u64 w[SKEIN_512_STATE_WORDS]; } cfg; /* config block */ @@ -277,8 +264,7 @@ int Skein_512_Init(struct skein_512_ctx *ctx, size_t hashBitLen) Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN); ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ - switch (hashBitLen) - { /* use pre-computed values, where available */ + switch (hashBitLen) { /* use pre-computed values, where available */ case 512: memcpy(ctx->X, SKEIN_512_IV_512, sizeof(ctx->X)); break; @@ -332,8 +318,7 @@ int Skein_512_Init(struct skein_512_ctx *ctx, size_t hashBitLen) int Skein_512_InitExt(struct skein_512_ctx *ctx, size_t hashBitLen, u64 treeInfo, const u8 *key, size_t keyBytes) { - union - { + union { u8 b[SKEIN_512_STATE_BYTES]; u64 w[SKEIN_512_STATE_WORDS]; } cfg; /* config block */ @@ -342,13 +327,10 @@ int Skein_512_InitExt(struct skein_512_ctx *ctx, size_t hashBitLen, Skein_Assert(keyBytes == 0 || key != NULL, SKEIN_FAIL); /* compute the initial chaining values ctx->X[], based on key */ - if (keyBytes == 0) /* is there a key? */ - { + if (keyBytes == 0) { /* is there a key? */ /* no key: use all zeroes as key for config block */ memset(ctx->X, 0, sizeof(ctx->X)); - } - else /* here to pre-process a key */ - { + } else { /* here to pre-process a key */ Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); /* do a mini-Init right here */ /* set output hash bit count = state size */ @@ -402,15 +384,12 @@ int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg, Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* process full blocks, if any */ - if (msgByteCnt + ctx->h.bCnt > SKEIN_512_BLOCK_BYTES) - { + if (msgByteCnt + ctx->h.bCnt > SKEIN_512_BLOCK_BYTES) { /* finish up any buffered message data */ - if (ctx->h.bCnt) - { + if (ctx->h.bCnt) { /* # bytes free in buffer b[] */ n = SKEIN_512_BLOCK_BYTES - ctx->h.bCnt; - if (n) - { + if (n) { /* check on our logic here */ Skein_assert(n < msgByteCnt); memcpy(&ctx->b[ctx->h.bCnt], msg, n); @@ -427,8 +406,7 @@ int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg, * now process any remaining full blocks, directly from input * message data */ - if (msgByteCnt > SKEIN_512_BLOCK_BYTES) - { + if (msgByteCnt > SKEIN_512_BLOCK_BYTES) { /* number of full blocks to process */ n = (msgByteCnt-1) / SKEIN_512_BLOCK_BYTES; Skein_512_Process_Block(ctx, msg, n, @@ -440,8 +418,7 @@ int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg, } /* copy any remaining source message data bytes into b[] */ - if (msgByteCnt) - { + if (msgByteCnt) { Skein_assert(msgByteCnt + ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES); memcpy(&ctx->b[ctx->h.bCnt], msg, msgByteCnt); ctx->h.bCnt += msgByteCnt; @@ -478,8 +455,7 @@ int Skein_512_Final(struct skein_512_ctx *ctx, u8 *hashVal) memset(ctx->b, 0, sizeof(ctx->b)); /* keep a local copy of counter mode "key" */ memcpy(X, ctx->X, sizeof(X)); - for (i = 0; i*SKEIN_512_BLOCK_BYTES < byteCnt; i++) - { + for (i = 0; i*SKEIN_512_BLOCK_BYTES < byteCnt; i++) { /* build the counter block */ ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); Skein_Start_New_Type(ctx, OUT_FINAL); @@ -508,8 +484,7 @@ int Skein_512_Final(struct skein_512_ctx *ctx, u8 *hashVal) /* init the context for a straight hashing operation */ int Skein1024_Init(struct skein1024_ctx *ctx, size_t hashBitLen) { - union - { + union { u8 b[SKEIN1024_STATE_BYTES]; u64 w[SKEIN1024_STATE_WORDS]; } cfg; /* config block */ @@ -517,8 +492,7 @@ int Skein1024_Init(struct skein1024_ctx *ctx, size_t hashBitLen) Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN); ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ - switch (hashBitLen) - { /* use pre-computed values, where available */ + switch (hashBitLen) { /* use pre-computed values, where available */ case 512: memcpy(ctx->X, SKEIN1024_IV_512, sizeof(ctx->X)); break; @@ -566,8 +540,7 @@ int Skein1024_Init(struct skein1024_ctx *ctx, size_t hashBitLen) int Skein1024_InitExt(struct skein1024_ctx *ctx, size_t hashBitLen, u64 treeInfo, const u8 *key, size_t keyBytes) { - union - { + union { u8 b[SKEIN1024_STATE_BYTES]; u64 w[SKEIN1024_STATE_WORDS]; } cfg; /* config block */ @@ -576,13 +549,10 @@ int Skein1024_InitExt(struct skein1024_ctx *ctx, size_t hashBitLen, Skein_Assert(keyBytes == 0 || key != NULL, SKEIN_FAIL); /* compute the initial chaining values ctx->X[], based on key */ - if (keyBytes == 0) /* is there a key? */ - { + if (keyBytes == 0) { /* is there a key? */ /* no key: use all zeroes as key for config block */ memset(ctx->X, 0, sizeof(ctx->X)); - } - else /* here to pre-process a key */ - { + } else { /* here to pre-process a key */ Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); /* do a mini-Init right here */ /* set output hash bit count = state size */ @@ -637,15 +607,12 @@ int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg, Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); /* process full blocks, if any */ - if (msgByteCnt + ctx->h.bCnt > SKEIN1024_BLOCK_BYTES) - { + if (msgByteCnt + ctx->h.bCnt > SKEIN1024_BLOCK_BYTES) { /* finish up any buffered message data */ - if (ctx->h.bCnt) - { + if (ctx->h.bCnt) { /* # bytes free in buffer b[] */ n = SKEIN1024_BLOCK_BYTES - ctx->h.bCnt; - if (n) - { + if (n) { /* check on our logic here */ Skein_assert(n < msgByteCnt); memcpy(&ctx->b[ctx->h.bCnt], msg, n); @@ -662,8 +629,7 @@ int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg, * now process any remaining full blocks, directly from input * message data */ - if (msgByteCnt > SKEIN1024_BLOCK_BYTES) - { + if (msgByteCnt > SKEIN1024_BLOCK_BYTES) { /* number of full blocks to process */ n = (msgByteCnt-1) / SKEIN1024_BLOCK_BYTES; Skein1024_Process_Block(ctx, msg, n, @@ -675,8 +641,7 @@ int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg, } /* copy any remaining source message data bytes into b[] */ - if (msgByteCnt) - { + if (msgByteCnt) { Skein_assert(msgByteCnt + ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES); memcpy(&ctx->b[ctx->h.bCnt], msg, msgByteCnt); ctx->h.bCnt += msgByteCnt; @@ -713,8 +678,7 @@ int Skein1024_Final(struct skein1024_ctx *ctx, u8 *hashVal) memset(ctx->b, 0, sizeof(ctx->b)); /* keep a local copy of counter mode "key" */ memcpy(X, ctx->X, sizeof(X)); - for (i = 0; i*SKEIN1024_BLOCK_BYTES < byteCnt; i++) - { + for (i = 0; i*SKEIN1024_BLOCK_BYTES < byteCnt; i++) { /* build the counter block */ ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); Skein_Start_New_Type(ctx, OUT_FINAL); @@ -823,8 +787,7 @@ int Skein_256_Output(struct skein_256_ctx *ctx, u8 *hashVal) memset(ctx->b, 0, sizeof(ctx->b)); /* keep a local copy of counter mode "key" */ memcpy(X, ctx->X, sizeof(X)); - for (i = 0; i*SKEIN_256_BLOCK_BYTES < byteCnt; i++) - { + for (i = 0; i*SKEIN_256_BLOCK_BYTES < byteCnt; i++) { /* build the counter block */ ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); Skein_Start_New_Type(ctx, OUT_FINAL); @@ -863,8 +826,7 @@ int Skein_512_Output(struct skein_512_ctx *ctx, u8 *hashVal) memset(ctx->b, 0, sizeof(ctx->b)); /* keep a local copy of counter mode "key" */ memcpy(X, ctx->X, sizeof(X)); - for (i = 0; i*SKEIN_512_BLOCK_BYTES < byteCnt; i++) - { + for (i = 0; i*SKEIN_512_BLOCK_BYTES < byteCnt; i++) { /* build the counter block */ ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); Skein_Start_New_Type(ctx, OUT_FINAL); @@ -903,8 +865,7 @@ int Skein1024_Output(struct skein1024_ctx *ctx, u8 *hashVal) memset(ctx->b, 0, sizeof(ctx->b)); /* keep a local copy of counter mode "key" */ memcpy(X, ctx->X, sizeof(X)); - for (i = 0; i*SKEIN1024_BLOCK_BYTES < byteCnt; i++) - { + for (i = 0; i*SKEIN1024_BLOCK_BYTES < byteCnt; i++) { /* build the counter block */ ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); Skein_Start_New_Type(ctx, OUT_FINAL); -- cgit v1.2.3 From 522e358d2d4f31319478386f7ff79156a246740d Mon Sep 17 00:00:00 2001 From: Jason Cooper Date: Mon, 24 Mar 2014 01:49:14 +0000 Subject: staging: crypto: skein: wrap multi-line macros in do-while loops Signed-off-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/skein_block.c | 66 ++++++++++++++++++++++++++++--------- 1 file changed, 51 insertions(+), 15 deletions(-) diff --git a/drivers/staging/skein/skein_block.c b/drivers/staging/skein/skein_block.c index 6e0f4a21aae3..707a21ae53c6 100644 --- a/drivers/staging/skein/skein_block.c +++ b/drivers/staging/skein/skein_block.c @@ -107,27 +107,36 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, /* run the rounds */ #define Round256(p0, p1, p2, p3, ROT, rNum) \ +do { \ X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ +} while (0) #if SKEIN_UNROLL_256 == 0 #define R256(p0, p1, p2, p3, ROT, rNum) /* fully unrolled */ \ +do { \ Round256(p0, p1, p2, p3, ROT, rNum) \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rNum, Xptr); + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rNum, Xptr); \ +} while (0) #define I256(R) \ +do { \ /* inject the key schedule value */ \ X0 += ks[((R)+1) % 5]; \ X1 += ks[((R)+2) % 5] + ts[((R)+1) % 3]; \ X2 += ks[((R)+3) % 5] + ts[((R)+2) % 3]; \ X3 += ks[((R)+4) % 5] + (R)+1; \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); \ +} while (0) #else /* looping version */ #define R256(p0, p1, p2, p3, ROT, rNum) \ +do { \ Round256(p0, p1, p2, p3, ROT, rNum) \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rNum, Xptr); + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rNum, Xptr); \ +} while (0) #define I256(R) \ +do { \ /* inject the key schedule value */ \ X0 += ks[r+(R)+0]; \ X1 += ks[r+(R)+1] + ts[r+(R)+0]; \ @@ -136,12 +145,14 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, /* rotate key schedule */ \ ks[r + (R) + 4] = ks[r + (R) - 1]; \ ts[r + (R) + 2] = ts[r + (R) - 1]; \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); \ +} while (0) for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_256) #endif { #define R256_8_rounds(R) \ +do { \ R256(0, 1, 2, 3, R_256_0, 8 * (R) + 1); \ R256(0, 3, 2, 1, R_256_1, 8 * (R) + 2); \ R256(0, 1, 2, 3, R_256_2, 8 * (R) + 3); \ @@ -151,7 +162,8 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, R256(0, 3, 2, 1, R_256_5, 8 * (R) + 6); \ R256(0, 1, 2, 3, R_256_6, 8 * (R) + 7); \ R256(0, 3, 2, 1, R_256_7, 8 * (R) + 8); \ - I256(2 * (R) + 1); + I256(2 * (R) + 1); \ +} while (0) R256_8_rounds(0); @@ -311,17 +323,22 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, Xptr); /* run the rounds */ #define Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \ +do { \ X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ X##p4 += X##p5; X##p5 = RotL_64(X##p5, ROT##_2); X##p5 ^= X##p4; \ X##p6 += X##p7; X##p7 = RotL_64(X##p7, ROT##_3); X##p7 ^= X##p6; \ +} while (0) #if SKEIN_UNROLL_512 == 0 #define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) /* unrolled */ \ +do { \ Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rNum, Xptr); + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rNum, Xptr); \ +} while (0) #define I512(R) \ +do { \ /* inject the key schedule value */ \ X0 += ks[((R) + 1) % 9]; \ X1 += ks[((R) + 2) % 9]; \ @@ -331,13 +348,17 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, X5 += ks[((R) + 6) % 9] + ts[((R) + 1) % 3]; \ X6 += ks[((R) + 7) % 9] + ts[((R) + 2) % 3]; \ X7 += ks[((R) + 8) % 9] + (R) + 1; \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); \ +} while (0) #else /* looping version */ #define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \ +do { \ Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rNum, Xptr); + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rNum, Xptr); \ +} while (0) #define I512(R) \ +do { \ /* inject the key schedule value */ \ X0 += ks[r + (R) + 0]; \ X1 += ks[r + (R) + 1]; \ @@ -350,12 +371,14 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, /* rotate key schedule */ \ ks[r + (R) + 8] = ks[r + (R) - 1]; \ ts[r + (R) + 2] = ts[r + (R) - 1]; \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); \ +} while (0) for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_512) #endif /* end of looped code definitions */ { #define R512_8_rounds(R) /* do 8 full rounds */ \ +do { \ R512(0, 1, 2, 3, 4, 5, 6, 7, R_512_0, 8 * (R) + 1); \ R512(2, 1, 4, 7, 6, 5, 0, 3, R_512_1, 8 * (R) + 2); \ R512(4, 1, 6, 3, 0, 5, 2, 7, R_512_2, 8 * (R) + 3); \ @@ -365,7 +388,8 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, R512(2, 1, 4, 7, 6, 5, 0, 3, R_512_5, 8 * (R) + 6); \ R512(4, 1, 6, 3, 0, 5, 2, 7, R_512_6, 8 * (R) + 7); \ R512(6, 1, 0, 7, 2, 5, 4, 3, R_512_7, 8 * (R) + 8); \ - I512(2 * (R) + 1); /* and key injection */ + I512(2 * (R) + 1); /* and key injection */ \ +} while (0) R512_8_rounds(0); @@ -551,6 +575,7 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, \ #define Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ pF, ROT, rNum) \ +do { \ X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ X##p4 += X##p5; X##p5 = RotL_64(X##p5, ROT##_2); X##p5 ^= X##p4; \ @@ -559,15 +584,19 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, \ X##pA += X##pB; X##pB = RotL_64(X##pB, ROT##_5); X##pB ^= X##pA; \ X##pC += X##pD; X##pD = RotL_64(X##pD, ROT##_6); X##pD ^= X##pC; \ X##pE += X##pF; X##pF = RotL_64(X##pF, ROT##_7); X##pF ^= X##pE; \ +} while (0) #if SKEIN_UNROLL_1024 == 0 #define R1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, \ ROT, rn) \ +do { \ Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ pF, ROT, rn) \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rn, Xptr); + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rn, Xptr); \ +} while (0) #define I1024(R) \ +do { \ /* inject the key schedule value */ \ X00 += ks[((R) + 1) % 17]; \ X01 += ks[((R) + 2) % 17]; \ @@ -585,15 +614,19 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, \ X13 += ks[((R) + 14) % 17] + ts[((R) + 1) % 3]; \ X14 += ks[((R) + 15) % 17] + ts[((R) + 2) % 3]; \ X15 += ks[((R) + 16) % 17] + (R) + 1; \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); \ +} while (0) #else /* looping version */ #define R1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, \ ROT, rn) \ +do { \ Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ pF, ROT, rn) \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rn, Xptr); + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rn, Xptr); \ +} while (0) #define I1024(R) \ +do { \ /* inject the key schedule value */ \ X00 += ks[r + (R) + 0]; \ X01 += ks[r + (R) + 1]; \ @@ -614,12 +647,14 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, \ /* rotate key schedule */ \ ks[r + (R) + 16] = ks[r + (R) - 1]; \ ts[r + (R) + 2] = ts[r + (R) - 1]; \ - Skein_Show_R_Ptr(BLK_BITSi, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); + Skein_Show_R_Ptr(BLK_BITSi, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); \ +} while (0) for (r = 1; r <= 2 * RCNT; r += 2 * SKEIN_UNROLL_1024) #endif { #define R1024_8_rounds(R) \ +do { \ R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, \ R1024_0, 8*(R) + 1); \ R1024(00, 09, 02, 13, 06, 11, 04, 15, 10, 07, 12, 03, 14, 05, 08, 01, \ @@ -637,7 +672,8 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, \ R1024_6, 8*(R) + 7); \ R1024(00, 15, 02, 11, 06, 13, 04, 09, 14, 01, 08, 05, 10, 03, 12, 07, \ R1024_7, 8*(R) + 8); \ - I1024(2*(R)+1); + I1024(2*(R)+1); \ +} while (0) R1024_8_rounds(0); -- cgit v1.2.3 From 906b492e770dd36b3dcb518e47e36eee1f944465 Mon Sep 17 00:00:00 2001 From: Jason Cooper Date: Mon, 24 Mar 2014 01:49:15 +0000 Subject: staging: crypto: skein: remove externs from .c files Signed-off-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/include/skein_block.h | 22 ++++++++++++++++++++++ drivers/staging/skein/skein.c | 10 +--------- 2 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 drivers/staging/skein/include/skein_block.h diff --git a/drivers/staging/skein/include/skein_block.h b/drivers/staging/skein/include/skein_block.h new file mode 100644 index 000000000000..b15c079b5bd4 --- /dev/null +++ b/drivers/staging/skein/include/skein_block.h @@ -0,0 +1,22 @@ +/*********************************************************************** +** +** Implementation of the Skein hash function. +** +** Source code author: Doug Whiting, 2008. +** +** This algorithm and source code is released to the public domain. +** +************************************************************************/ +#ifndef _SKEIN_BLOCK_H_ +#define _SKEIN_BLOCK_H_ + +#include /* get the Skein API definitions */ + +void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, + size_t blkCnt, size_t byteCntAdd); +void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, + size_t blkCnt, size_t byteCntAdd); +void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, + size_t blkCnt, size_t byteCntAdd); + +#endif diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c index 0d8c70c02c6f..096b86bf9430 100644 --- a/drivers/staging/skein/skein.c +++ b/drivers/staging/skein/skein.c @@ -13,15 +13,7 @@ #include /* get the memcpy/memset functions */ #include /* get the Skein API definitions */ #include /* get precomputed IVs */ - -/*****************************************************************/ -/* External function to process blkCnt (nonzero) full block(s) of data. */ -void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, - size_t blkCnt, size_t byteCntAdd); -void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, - size_t blkCnt, size_t byteCntAdd); -void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, - size_t blkCnt, size_t byteCntAdd); +#include /*****************************************************************/ /* 256-bit Skein */ -- cgit v1.2.3 From 7584a878712cce21d309e4caf1229b7f4345e8e9 Mon Sep 17 00:00:00 2001 From: Jason Cooper Date: Mon, 24 Mar 2014 01:49:16 +0000 Subject: staging: crypto: skein: remove braces from single-statement block Signed-off-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/skeinApi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/skein/skeinApi.c b/drivers/staging/skein/skeinApi.c index f0015d5b10f5..dd109bf6f7b9 100644 --- a/drivers/staging/skein/skeinApi.c +++ b/drivers/staging/skein/skeinApi.c @@ -188,9 +188,9 @@ int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg, msgBitCnt == 0, SKEIN_FAIL); /* if number of bits is a multiple of bytes - that's easy */ - if ((msgBitCnt & 0x7) == 0) { + if ((msgBitCnt & 0x7) == 0) return skeinUpdate(ctx, msg, msgBitCnt >> 3); - } + skeinUpdate(ctx, msg, (msgBitCnt >> 3) + 1); /* -- cgit v1.2.3 From fc9824747c2062515f987fb391c8cf275cd2260d Mon Sep 17 00:00:00 2001 From: Jason Cooper Date: Mon, 24 Mar 2014 01:49:17 +0000 Subject: staging: crypto: skein: remove unnecessary line continuation Signed-off-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/skein_block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/skein/skein_block.c b/drivers/staging/skein/skein_block.c index 707a21ae53c6..fd96ca0ad0ed 100644 --- a/drivers/staging/skein/skein_block.c +++ b/drivers/staging/skein/skein_block.c @@ -477,7 +477,7 @@ unsigned int Skein_512_Unroll_Cnt(void) /***************************** Skein1024 ******************************/ #if !(SKEIN_USE_ASM & 1024) -void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, \ +void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, size_t blkCnt, size_t byteCntAdd) { /* do it in C, always looping (unrolled is bigger AND slower!) */ enum { -- cgit v1.2.3 From c5ace7bf7a4d44348583e810db7998a4fe499bc6 Mon Sep 17 00:00:00 2001 From: Jason Cooper Date: Mon, 24 Mar 2014 01:49:18 +0000 Subject: staging: crypto: skein: add TODO file Signed-off-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/TODO | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 drivers/staging/skein/TODO diff --git a/drivers/staging/skein/TODO b/drivers/staging/skein/TODO new file mode 100644 index 000000000000..f5c167a305ae --- /dev/null +++ b/drivers/staging/skein/TODO @@ -0,0 +1,11 @@ +skein/threefish TODO + + - rename camelcase vars + - rename camelcase functions + - rename files + - move macros into appropriate header files + - add / pass test vectors + - module support + +Please send patches to Jason Cooper in addition to the +staging tree mailinglist. -- cgit v1.2.3 From ea143c4f6a84af0866f7be98f6a0b12ecd71b5bb Mon Sep 17 00:00:00 2001 From: Hayato Suzuki Date: Wed, 16 Apr 2014 20:57:14 +0900 Subject: staging: speakup: fix typo in kobjects.c Correct spelling typo in kobjects.c Signed-off-by: Hayato Suzuki Acked-by: Samuel Thibault Signed-off-by: Greg Kroah-Hartman --- drivers/staging/speakup/kobjects.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c index 1ca91f7092b1..7495b890b6f0 100644 --- a/drivers/staging/speakup/kobjects.c +++ b/drivers/staging/speakup/kobjects.c @@ -641,7 +641,7 @@ ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr, if (kstrtol(cp, 10, &value) == 0) ret = spk_set_num_var(value, param, len); else - pr_warn("overflow or parsing error has occured"); + pr_warn("overflow or parsing error has occurred"); if (ret == -ERANGE) { var_data = param->data; pr_warn("value for %s out of range, expect %d to %d\n", -- cgit v1.2.3 From 542ef8a6fbf664e502808ff486b30f6e65e2fd82 Mon Sep 17 00:00:00 2001 From: Matei Oprea Date: Sun, 23 Mar 2014 14:13:16 +0200 Subject: staging: cxt1e1: hwprobe: fix incorrect type in assignment This patch fixes "incorrect type in argument 1" warning from sparse. Signed-off-by: Matei Oprea Cc: ROSEdu Kernel Community Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cxt1e1/hwprobe.c | 6 +++--- drivers/staging/cxt1e1/pmcc4_private.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/cxt1e1/hwprobe.c b/drivers/staging/cxt1e1/hwprobe.c index 9b4198b1e634..1a145ea1fa65 100644 --- a/drivers/staging/cxt1e1/hwprobe.c +++ b/drivers/staging/cxt1e1/hwprobe.c @@ -174,12 +174,12 @@ cleanup_ioremap(void) if (hi->pci_slot == 0xff) break; if (hi->addr_mapped[0]) { - iounmap((void *)(hi->addr_mapped[0])); + iounmap(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])); + iounmap(hi->addr_mapped[1]); release_mem_region((long) hi->addr[1], hi->len[1]); hi->addr_mapped[1] = 0; } @@ -329,7 +329,7 @@ c4hw_attach_all(void) return -ENOMEM; } - hi->addr_mapped[j] = (unsigned long)ioremap(hi->addr[j], hi->len[j]); + hi->addr_mapped[j] = ioremap(hi->addr[j], hi->len[j]); if (!hi->addr_mapped[j]) { pr_warning("%s: ioremap fails, addr=0x%lx, len=0x%lx ?\n", hi->devname, hi->addr[j], hi->len[j]); diff --git a/drivers/staging/cxt1e1/pmcc4_private.h b/drivers/staging/cxt1e1/pmcc4_private.h index eb28f095ff8c..451f12f5b04c 100644 --- a/drivers/staging/cxt1e1/pmcc4_private.h +++ b/drivers/staging/cxt1e1/pmcc4_private.h @@ -262,7 +262,7 @@ struct s_hdw_info struct pci_dev *pdev[2]; unsigned long addr[2]; - unsigned long addr_mapped[2]; + void __iomem *addr_mapped[2]; unsigned long len[2]; union -- cgit v1.2.3 From 9200b4dadb5d7540fb89c2b70034c94e90eb07a3 Mon Sep 17 00:00:00 2001 From: Michael Welling Date: Sun, 23 Mar 2014 11:14:27 -0500 Subject: STAGING: cxt1e1: Remove sparse warnings Removes sparse warnings by including a header and adding static to some functions. Signed-off-by: Michael Welling Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cxt1e1/pmc93x6_eeprom.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/staging/cxt1e1/pmc93x6_eeprom.c b/drivers/staging/cxt1e1/pmc93x6_eeprom.c index 78cc1709ebdb..e16f0d615678 100644 --- a/drivers/staging/cxt1e1/pmc93x6_eeprom.c +++ b/drivers/staging/cxt1e1/pmc93x6_eeprom.c @@ -28,6 +28,7 @@ #include "sbecom_inline_linux.h" #include "pmcc4.h" #include "sbe_promformat.h" +#include "pmc93x6_eeprom.h" #ifndef TRUE #define TRUE 1 @@ -154,7 +155,7 @@ eeprom_delay (void) * the data to the EEPROM. */ -void +static void eeprom_put_byte (long addr, long data, int count) { u_int32_t output; @@ -179,7 +180,7 @@ eeprom_put_byte (long addr, long data, int count) * from the EEPROM. */ -u_int32_t +static u_int32_t eeprom_get_byte (long addr) { u_int32_t input; @@ -252,7 +253,7 @@ enable_pmc_eeprom (long addr) * the contents of the specified location to the calling routine. */ -u_int32_t +static u_int32_t pmc_eeprom_read (long addr, long mem_offset) { u_int32_t data; /* Data from chip */ @@ -292,7 +293,7 @@ pmc_eeprom_read (long addr, long mem_offset) * operation succeeded. */ -int +static int pmc_eeprom_write (long addr, long mem_offset, u_int32_t data) { volatile u_int32_t temp; @@ -360,7 +361,7 @@ pmc_eeprom_write (long addr, long mem_offset, u_int32_t data) *------------------------------------------------------------------------ */ -long +static long pmcGetBuffValue (char *ptr, int size) { long value = 0; @@ -381,7 +382,7 @@ pmcGetBuffValue (char *ptr, int size) *------------------------------------------------------------------------ */ -void +static void pmcSetBuffValue (char *ptr, long value, int size) { int index = size; @@ -429,7 +430,7 @@ pmc_eeprom_write_buffer (long addr, long mem_offset, char *dest_ptr, int size) *------------------------------------------------------------------------ */ -u_int32_t +static u_int32_t pmcCalcCrc_T01 (void *bufp) { FLD_TYPE2 *buf = bufp; @@ -448,7 +449,7 @@ pmcCalcCrc_T01 (void *bufp) return ~crc; } -u_int32_t +static u_int32_t pmcCalcCrc_T02 (void *bufp) { FLD_TYPE2 *buf = bufp; -- cgit v1.2.3 From 50fd8b1fa39d1c9cd7d570281449d68a4baf7e13 Mon Sep 17 00:00:00 2001 From: Michael Welling Date: Sun, 23 Mar 2014 11:14:59 -0500 Subject: STAGING: cxt1e1: Indentation fixes Indentation fixes using Lindent. Signed-off-by: Michael Welling Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cxt1e1/pmc93x6_eeprom.c | 481 ++++++++++++++------------------ 1 file changed, 217 insertions(+), 264 deletions(-) diff --git a/drivers/staging/cxt1e1/pmc93x6_eeprom.c b/drivers/staging/cxt1e1/pmc93x6_eeprom.c index e16f0d615678..a027708994ae 100644 --- a/drivers/staging/cxt1e1/pmc93x6_eeprom.c +++ b/drivers/staging/cxt1e1/pmc93x6_eeprom.c @@ -44,10 +44,9 @@ * 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 */ - +#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 ** @@ -55,27 +54,25 @@ ** */ -#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_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 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 */ - +#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 */ - +#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 @@ -83,29 +80,26 @@ */ static unsigned char ByteReverse[256]; -static int ByteReverseBuilt = FALSE; - +static int ByteReverseBuilt = FALSE; /*------------------------------------------------------------------------ * mfg_template - initial serial EEPROM data structure *------------------------------------------------------------------------ */ -static u8 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]; */ +static u8 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 *------------------------------------------------------------------------ @@ -114,39 +108,35 @@ static u8 mfg_template[sizeof(FLD_TYPE2)] = * (the MSB becomes the LSB etc.). */ -static void -BuildByteReverse (void) +static void BuildByteReverse(void) { - long half; /* Used to build by powers to 2 */ - int i; + long half; /* Used to build by powers to 2 */ + int i; - ByteReverse[0] = 0; + 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)); + for (half = 1; half < sizeof(ByteReverse); half <<= 1) + for (i = 0; i < half; i++) + ByteReverse[half + i] = + (char)(ByteReverse[i] | (0x80 / half)); - ByteReverseBuilt = TRUE; + ByteReverseBuilt = TRUE; } - /*------------------------------------------------------------------------ * eeprom_delay - small delay for EEPROM timing *------------------------------------------------------------------------ */ -static void -eeprom_delay (void) +static void eeprom_delay(void) { - int timeout; + int timeout; - for (timeout = 20; timeout; --timeout) - { - OS_uwait_dummy (); - } + for (timeout = 20; timeout; --timeout) { + OS_uwait_dummy(); + } } - /*------------------------------------------------------------------------ * eeprom_put_byte - Send a byte to the EEPROM serially *------------------------------------------------------------------------ @@ -155,23 +145,20 @@ eeprom_delay (void) * the data to the EEPROM. */ -static void -eeprom_put_byte (long addr, long data, int count) +static void eeprom_put_byte(long addr, long data, int count) { - u_int32_t output; + 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; + 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_delay(); + pci_write_32((u_int32_t *) addr, output); /* Output it */ + } } - /*------------------------------------------------------------------------ * eeprom_get_byte - Receive a byte from the EEPROM serially *------------------------------------------------------------------------ @@ -180,12 +167,11 @@ eeprom_put_byte (long addr, long data, int count) * from the EEPROM. */ -static u_int32_t -eeprom_get_byte (long addr) +static u_int32_t eeprom_get_byte(long addr) { - u_int32_t input; - u_int32_t data; - int count; + u_int32_t input; + u_int32_t data; + int count; /* Start the Reading of DATA ** @@ -193,24 +179,22 @@ eeprom_get_byte (long addr) ** EPLD and read on the next read access to the EEPROM. */ - input = pci_read_32 ((u_int32_t *) addr); + 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 = 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; + data <<= 1; /* Shift data over */ + data |= (input & EPROM_ACTIVE_IN_BIT) ? 1 : 0; - } + } - return data; + return data; } - /*------------------------------------------------------------------------ * disable_pmc_eeprom - Disable writes to the EEPROM *------------------------------------------------------------------------ @@ -218,16 +202,14 @@ eeprom_get_byte (long addr) * Issue the EEPROM command to disable writes. */ -static void -disable_pmc_eeprom (long addr) +static void disable_pmc_eeprom(long addr) { - eeprom_put_byte (addr, EPROM_EWDS, SIZE_ADDR_OP); + eeprom_put_byte(addr, EPROM_EWDS, SIZE_ADDR_OP); - pci_write_32 ((u_int32_t *) addr, 0); /* this removes Chip Select - * from EEPROM */ + pci_write_32((u_int32_t *) addr, 0); /* this removes Chip Select + * from EEPROM */ } - /*------------------------------------------------------------------------ * enable_pmc_eeprom - Enable writes to the EEPROM *------------------------------------------------------------------------ @@ -235,16 +217,14 @@ disable_pmc_eeprom (long addr) * Issue the EEPROM command to enable writes. */ -static void -enable_pmc_eeprom (long addr) +static void enable_pmc_eeprom(long addr) { - eeprom_put_byte (addr, EPROM_EWEN, SIZE_ADDR_OP); + eeprom_put_byte(addr, EPROM_EWEN, SIZE_ADDR_OP); - pci_write_32 ((u_int32_t *) addr, 0); /* this removes Chip Select - * from EEPROM */ + pci_write_32((u_int32_t *) addr, 0); /* this removes Chip Select + * from EEPROM */ } - /*------------------------------------------------------------------------ * pmc_eeprom_read - EEPROM location read *------------------------------------------------------------------------ @@ -253,35 +233,33 @@ enable_pmc_eeprom (long addr) * the contents of the specified location to the calling routine. */ -static u_int32_t -pmc_eeprom_read (long addr, long mem_offset) +static u_int32_t pmc_eeprom_read(long addr, long mem_offset) { - u_int32_t data; /* Data from chip */ + u_int32_t data; /* Data from chip */ - if (!ByteReverseBuilt) - BuildByteReverse (); + 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 */ + 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 */ + eeprom_put_byte(addr, mem_offset, SIZE_ADDR_OP); /* Output chip address */ - data = eeprom_get_byte (addr); /* Read chip data */ + data = eeprom_get_byte(addr); /* Read chip data */ - pci_write_32 ((u_int32_t *) addr, 0); /* Remove Chip Select from - * EEPROM */ + pci_write_32((u_int32_t *) addr, 0); /* Remove Chip Select from + * EEPROM */ - return (data & 0x000000FF); + return (data & 0x000000FF); } - /*------------------------------------------------------------------------ * pmc_eeprom_write - EEPROM location write *------------------------------------------------------------------------ @@ -293,32 +271,31 @@ pmc_eeprom_read (long addr, long mem_offset) * operation succeeded. */ -static int -pmc_eeprom_write (long addr, long mem_offset, u_int32_t data) +static int pmc_eeprom_write(long addr, long mem_offset, u_int32_t data) { - volatile u_int32_t temp; - int count; + volatile u_int32_t temp; + int count; - if (!ByteReverseBuilt) - BuildByteReverse (); + 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 */ + 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 */ + 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 */ + 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 */ + 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. @@ -326,156 +303,135 @@ pmc_eeprom_write (long addr, long mem_offset, u_int32_t data) ** 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); + 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 *------------------------------------------------------------------------ */ -static long -pmcGetBuffValue (char *ptr, int size) +static long pmcGetBuffValue(char *ptr, int size) { - long value = 0; - int index; + long value = 0; + int index; - for (index = 0; index < size; ++index) - { - value <<= 8; - value |= ptr[index] & 0xFF; - } + for (index = 0; index < size; ++index) { + value <<= 8; + value |= ptr[index] & 0xFF; + } - return value; + return value; } - /*------------------------------------------------------------------------ * pmcSetBuffValue - save the specified value to buffer *------------------------------------------------------------------------ */ -static void -pmcSetBuffValue (char *ptr, long value, int size) +static void pmcSetBuffValue(char *ptr, long value, int size) { - int index = size; + int index = size; - while (--index >= 0) - { - ptr[index] = (char) (value & 0xFF); - value >>= 8; - } + 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) +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++); + 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) +pmc_eeprom_write_buffer(long addr, long mem_offset, char *dest_ptr, int size) { - enable_pmc_eeprom (addr); + enable_pmc_eeprom(addr); - while (--size >= 0) - pmc_eeprom_write (addr, mem_offset++, *dest_ptr++); + while (--size >= 0) + pmc_eeprom_write(addr, mem_offset++, *dest_ptr++); - disable_pmc_eeprom (addr); + disable_pmc_eeprom(addr); } - /*------------------------------------------------------------------------ * pmcCalcCrc - calculate the CRC for the serial EEPROM structure *------------------------------------------------------------------------ */ -static u_int32_t -pmcCalcCrc_T01 (void *bufp) +static u_int32_t pmcCalcCrc_T01(void *bufp) { - FLD_TYPE2 *buf = bufp; - u_int32_t crc; /* CRC of the structure */ + 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); + /* 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 - pr_info("sbeCrc: crc 1 calculated as %08x\n", crc); /* RLD DEBUG */ + pr_info("sbeCrc: crc 1 calculated as %08x\n", crc); /* RLD DEBUG */ #endif - return ~crc; + return ~crc; } -static u_int32_t -pmcCalcCrc_T02 (void *bufp) +static 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); + 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 - pr_info("sbeCrc: crc 2 calculated as %08x\n", crc); /* RLD DEBUG */ + pr_info("sbeCrc: crc 2 calculated as %08x\n", crc); /* RLD DEBUG */ #endif - return crc; + return crc; } - /*------------------------------------------------------------------------ * pmc_init_seeprom - initialize the serial EEPROM structure *------------------------------------------------------------------------ @@ -486,64 +442,61 @@ pmcCalcCrc_T02 (void *bufp) * serial number field. */ -void -pmc_init_seeprom (u_int32_t addr, u_int32_t serialNum) +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; + PROMFORMAT buffer; /* Memory image of structure */ + u_int32_t crc; /* CRC of structure */ + time_t createTime; - createTime = get_seconds (); + createTime = get_seconds(); - /* use template data */ - memcpy(&buffer.fldType2, mfg_template, sizeof(buffer.fldType2)); + /* use template data */ + memcpy(&buffer.fldType2, mfg_template, sizeof(buffer.fldType2)); - /* Update serial number field in buffer */ - pmcSetBuffValue (&buffer.fldType2.Serial[3], serialNum, 3); + /* 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 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); + /* 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) - pr_info("[%02X] = %02X\n", i, buffer.bytes[i] & 0xFF); + for (i = 0; i < sizeof(FLD_TYPE2); ++i) + pr_info("[%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)); + /* Write structure to serial EEPROM */ + pmc_eeprom_write_buffer(addr, EE_MFG, (char *)&buffer, + sizeof(FLD_TYPE2)); } - -char -pmc_verify_cksum (void *bufp) +char pmc_verify_cksum(void *bufp) { - FLD_TYPE1 *buf1 = bufp; - FLD_TYPE2 *buf2 = bufp; - u_int32_t crc1, crc2; /* CRC read from EEPROM */ + 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)); + /* Retrieve contents of CRC field */ + crc1 = pmcGetBuffValue(&buf1->Crc32[0], sizeof(buf1->Crc32)); #ifdef EEPROM_TYPE_DEBUG - pr_info("EEPROM: chksum 1 reads as %08x\n", crc1); /* RLD DEBUG */ + pr_info("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 */ + 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)); + crc2 = pmcGetBuffValue(&buf2->Crc32[0], sizeof(buf2->Crc32)); #ifdef EEPROM_TYPE_DEBUG - pr_info("EEPROM: chksum 2 reads as %08x\n", crc2); /* RLD DEBUG */ + pr_info("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 */ + 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 */ + return PROM_FORMAT_Unk; /* failed to validate */ } - /*** End-of-File ***/ -- cgit v1.2.3 From f30629812efe943e6652a82d4773d18a19f694f9 Mon Sep 17 00:00:00 2001 From: Michael Welling Date: Sun, 23 Mar 2014 11:16:02 -0500 Subject: STAGING: cxt1e1: Fixes comment blocks Comment block fixes. Signed-off-by: Michael Welling Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cxt1e1/pmc93x6_eeprom.c | 155 +++++++++++++++++++------------- 1 file changed, 93 insertions(+), 62 deletions(-) diff --git a/drivers/staging/cxt1e1/pmc93x6_eeprom.c b/drivers/staging/cxt1e1/pmc93x6_eeprom.c index a027708994ae..572bd2e8a1e9 100644 --- a/drivers/staging/cxt1e1/pmc93x6_eeprom.c +++ b/drivers/staging/cxt1e1/pmc93x6_eeprom.c @@ -49,10 +49,10 @@ #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) -** -*/ + * + * 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) */ @@ -110,7 +110,8 @@ static u8 mfg_template[sizeof(FLD_TYPE2)] = { static void BuildByteReverse(void) { - long half; /* Used to build by powers to 2 */ + /* Used to build by powers to 2 */ + long half; int i; ByteReverse[0] = 0; @@ -150,12 +151,15 @@ static 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 */ + /* Get next data bit */ + output = (data & EPROM_ACTIVE_OUT_BIT) ? 1 : 0; + /* Add Chip Select */ + output |= EPROM_ENCS; data >>= 1; eeprom_delay(); - pci_write_32((u_int32_t *) addr, output); /* Output it */ + /* Output it */ + pci_write_32((u_int32_t *) addr, output); } } @@ -174,10 +178,10 @@ static u_int32_t eeprom_get_byte(long addr) 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. -*/ + * + * 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); @@ -187,7 +191,8 @@ static u_int32_t eeprom_get_byte(long addr) eeprom_delay(); input = pci_read_32((u_int32_t *) addr); - data <<= 1; /* Shift data over */ + /* Shift data over */ + data <<= 1; data |= (input & EPROM_ACTIVE_IN_BIT) ? 1 : 0; } @@ -206,8 +211,8 @@ 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 */ + /* this removes Chip Select from EEPROM */ + pci_write_32((u_int32_t *) addr, 0); } /*------------------------------------------------------------------------ @@ -221,8 +226,8 @@ 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 */ + /* this removes Chip Select from EEPROM */ + pci_write_32((u_int32_t *) addr, 0); } /*------------------------------------------------------------------------ @@ -235,27 +240,35 @@ static void enable_pmc_eeprom(long addr) static u_int32_t pmc_eeprom_read(long addr, long mem_offset) { - u_int32_t data; /* Data from chip */ + /* Data from chip */ + u_int32_t data; if (!ByteReverseBuilt) BuildByteReverse(); - mem_offset = ByteReverse[0x7F & mem_offset]; /* Reverse address */ + /* Reverse address */ + mem_offset = ByteReverse[0x7F & mem_offset]; + /* - * 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. + * 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 */ + /* Shift for command */ + mem_offset <<= 2; + /* Add command */ + mem_offset |= EPROM_READ; - data = eeprom_get_byte(addr); /* Read chip data */ + /* Output chip address */ + eeprom_put_byte(addr, mem_offset, SIZE_ADDR_OP); - pci_write_32((u_int32_t *) addr, 0); /* Remove Chip Select from - * EEPROM */ + /* Read chip data */ + data = eeprom_get_byte(addr); + + /* Remove Chip Select from EEPROM */ + pci_write_32((u_int32_t *) addr, 0); return (data & 0x000000FF); } @@ -279,38 +292,48 @@ static int pmc_eeprom_write(long addr, long mem_offset, u_int32_t data) if (!ByteReverseBuilt) BuildByteReverse(); - mem_offset = ByteReverse[0x7F & mem_offset]; /* Reverse address */ + /* Reverse address */ + mem_offset = ByteReverse[0x7F & mem_offset]; + /* - * 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. + * 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 */ + /* Shift for command */ + mem_offset <<= 2; + /* Add command */ + mem_offset |= EPROM_WRITE; - data = ByteReverse[0xFF & data]; /* Reverse data */ - eeprom_put_byte(addr, data, NUM_OF_BITS); /* Output chip data */ + /* Output chip address */ + eeprom_put_byte(addr, mem_offset, SIZE_ADDR_OP); - pci_write_32((u_int32_t *) addr, 0); /* Remove Chip Select from - * EEPROM */ + /* Reverse data */ + data = ByteReverse[0xFF & data]; + /* Output chip data */ + eeprom_put_byte(addr, data, NUM_OF_BITS); + + /* Remove Chip Select from EEPROM */ + pci_write_32((u_int32_t *) addr, 0); /* -** 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 */ + * 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. + */ + /* Re-enable Chip Select */ + pci_write_32((u_int32_t *) addr, EPROM_ENCS); + /* discard first read */ + temp = pci_read_32((u_int32_t *) addr); 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 */ + /* Remove Chip Select from EEPROM */ + pci_write_32((u_int32_t *) addr, 0); return (1); } } @@ -398,7 +421,8 @@ pmc_eeprom_write_buffer(long addr, long mem_offset, char *dest_ptr, int size) static u_int32_t pmcCalcCrc_T01(void *bufp) { FLD_TYPE2 *buf = bufp; - u_int32_t crc; /* CRC of the structure */ + /* CRC of the structure */ + u_int32_t crc; /* Calc CRC for type and length fields */ sbeCrc((u_int8_t *) & buf->type, @@ -406,7 +430,8 @@ static u_int32_t pmcCalcCrc_T01(void *bufp) (u_int32_t) 0, (u_int32_t *) & crc); #ifdef EEPROM_TYPE_DEBUG - pr_info("sbeCrc: crc 1 calculated as %08x\n", crc); /* RLD DEBUG */ + /* RLD DEBUG */ + pr_info("sbeCrc: crc 1 calculated as %08x\n", crc); #endif return ~crc; } @@ -414,7 +439,8 @@ static u_int32_t pmcCalcCrc_T01(void *bufp) static u_int32_t pmcCalcCrc_T02(void *bufp) { FLD_TYPE2 *buf = bufp; - u_int32_t crc; /* CRC of the structure */ + /* CRC of the structure */ + u_int32_t crc; /* Calc CRC for type and length fields */ sbeCrc((u_int8_t *) & buf->type, @@ -427,7 +453,8 @@ static u_int32_t pmcCalcCrc_T02(void *bufp) (u_int32_t) crc, (u_int32_t *) & crc); #ifdef EEPROM_TYPE_DEBUG - pr_info("sbeCrc: crc 2 calculated as %08x\n", crc); /* RLD DEBUG */ + /* RLD DEBUG */ + pr_info("sbeCrc: crc 2 calculated as %08x\n", crc); #endif return crc; } @@ -444,8 +471,10 @@ static u_int32_t pmcCalcCrc_T02(void *bufp) 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 */ + /* Memory image of structure */ + PROMFORMAT buffer; + /* CRC of structure */ + u_int32_t crc; time_t createTime; createTime = get_seconds(); @@ -477,12 +506,14 @@ char pmc_verify_cksum(void *bufp) { FLD_TYPE1 *buf1 = bufp; FLD_TYPE2 *buf2 = bufp; - u_int32_t crc1, crc2; /* CRC read from EEPROM */ + /* CRC read from EEPROM */ + u_int32_t crc1, crc2; /* Retrieve contents of CRC field */ crc1 = pmcGetBuffValue(&buf1->Crc32[0], sizeof(buf1->Crc32)); #ifdef EEPROM_TYPE_DEBUG - pr_info("EEPROM: chksum 1 reads as %08x\n", crc1); /* RLD DEBUG */ + /* RLD DEBUG */ + pr_info("EEPROM: chksum 1 reads as %08x\n", crc1); #endif if ((buf1->type == PROM_FORMAT_TYPE1) && (pmcCalcCrc_T01((void *)buf1) == crc1)) @@ -490,13 +521,13 @@ char pmc_verify_cksum(void *bufp) crc2 = pmcGetBuffValue(&buf2->Crc32[0], sizeof(buf2->Crc32)); #ifdef EEPROM_TYPE_DEBUG - pr_info("EEPROM: chksum 2 reads as %08x\n", crc2); /* RLD DEBUG */ + /* RLD DEBUG */ + pr_info("EEPROM: chksum 2 reads as %08x\n", crc2); #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 */ + /* failed to validate */ + return PROM_FORMAT_Unk; } - -/*** End-of-File ***/ -- cgit v1.2.3 From 447d7403a6f304540bb7fcfa000fc3e56594edf1 Mon Sep 17 00:00:00 2001 From: Michael Welling Date: Sun, 23 Mar 2014 11:16:36 -0500 Subject: STAGING: cxt1e1: Remove volatile variable Removes volatile variable. Signed-off-by: Michael Welling Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cxt1e1/pmc93x6_eeprom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/cxt1e1/pmc93x6_eeprom.c b/drivers/staging/cxt1e1/pmc93x6_eeprom.c index 572bd2e8a1e9..ab6fa73363ac 100644 --- a/drivers/staging/cxt1e1/pmc93x6_eeprom.c +++ b/drivers/staging/cxt1e1/pmc93x6_eeprom.c @@ -286,7 +286,7 @@ static u_int32_t pmc_eeprom_read(long addr, long mem_offset) static int pmc_eeprom_write(long addr, long mem_offset, u_int32_t data) { - volatile u_int32_t temp; + u_int32_t temp; int count; if (!ByteReverseBuilt) -- cgit v1.2.3 From 63809f5eeaf321dbb3abe326a72b706593c6c2f4 Mon Sep 17 00:00:00 2001 From: Michael Welling Date: Sun, 23 Mar 2014 11:17:29 -0500 Subject: STAGING: cxt1e1: Formatting fixes checkpatch issues Removes spaces before & where needed. Signed-off-by: Michael Welling Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cxt1e1/pmc93x6_eeprom.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/cxt1e1/pmc93x6_eeprom.c b/drivers/staging/cxt1e1/pmc93x6_eeprom.c index ab6fa73363ac..d7d240a1747b 100644 --- a/drivers/staging/cxt1e1/pmc93x6_eeprom.c +++ b/drivers/staging/cxt1e1/pmc93x6_eeprom.c @@ -425,9 +425,9 @@ static u_int32_t pmcCalcCrc_T01(void *bufp) u_int32_t crc; /* Calc CRC for type and length fields */ - sbeCrc((u_int8_t *) & buf->type, + sbeCrc((u_int8_t *) &buf->type, (u_int32_t) STRUCT_OFFSET(FLD_TYPE1, Crc32), - (u_int32_t) 0, (u_int32_t *) & crc); + (u_int32_t) 0, (u_int32_t *) &crc); #ifdef EEPROM_TYPE_DEBUG /* RLD DEBUG */ @@ -443,14 +443,14 @@ static u_int32_t pmcCalcCrc_T02(void *bufp) u_int32_t crc; /* Calc CRC for type and length fields */ - sbeCrc((u_int8_t *) & buf->type, + sbeCrc((u_int8_t *) &buf->type, (u_int32_t) STRUCT_OFFSET(FLD_TYPE2, Crc32), - (u_int32_t) 0, (u_int32_t *) & crc); + (u_int32_t) 0, (u_int32_t *) &crc); /* Calc CRC for remaining fields */ - sbeCrc((u_int8_t *) & buf->Id[0], + 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); + (u_int32_t) crc, (u_int32_t *) &crc); #ifdef EEPROM_TYPE_DEBUG /* RLD DEBUG */ -- cgit v1.2.3 From eef74d4aaada31e7c39c10a03cb709238c3ba037 Mon Sep 17 00:00:00 2001 From: Michael Welling Date: Sun, 23 Mar 2014 11:17:59 -0500 Subject: STAGING: cxt1e1: More formatting fixes Removes parens as are not necessary for return. Signed-off-by: Michael Welling Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cxt1e1/pmc93x6_eeprom.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/cxt1e1/pmc93x6_eeprom.c b/drivers/staging/cxt1e1/pmc93x6_eeprom.c index d7d240a1747b..615349936314 100644 --- a/drivers/staging/cxt1e1/pmc93x6_eeprom.c +++ b/drivers/staging/cxt1e1/pmc93x6_eeprom.c @@ -334,7 +334,7 @@ static int pmc_eeprom_write(long addr, long mem_offset, u_int32_t data) if (temp & EPROM_ACTIVE_IN_BIT) { /* Remove Chip Select from EEPROM */ pci_write_32((u_int32_t *) addr, 0); - return (1); + return 1; } } count = 1000; @@ -347,9 +347,9 @@ static int pmc_eeprom_write(long addr, long mem_offset, u_int32_t data) } if (count == -1) - return (2); + return 2; - return (0); + return 0; } /*------------------------------------------------------------------------ -- cgit v1.2.3 From 4786c87a1ec339ee9383e7f91a0aac2e7799ea67 Mon Sep 17 00:00:00 2001 From: Michael Welling Date: Sun, 23 Mar 2014 11:18:26 -0500 Subject: STAGING: cxt1e1: Remove curly braces Removes unnecessary curly braces from for loop in eeprom_delay. Signed-off-by: Michael Welling Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cxt1e1/pmc93x6_eeprom.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/cxt1e1/pmc93x6_eeprom.c b/drivers/staging/cxt1e1/pmc93x6_eeprom.c index 615349936314..ba588f1b2110 100644 --- a/drivers/staging/cxt1e1/pmc93x6_eeprom.c +++ b/drivers/staging/cxt1e1/pmc93x6_eeprom.c @@ -133,9 +133,8 @@ static void eeprom_delay(void) { int timeout; - for (timeout = 20; timeout; --timeout) { + for (timeout = 20; timeout; --timeout) OS_uwait_dummy(); - } } /*------------------------------------------------------------------------ -- cgit v1.2.3 From 693d963430cfdee131f870b5f8d6a44e4337ae81 Mon Sep 17 00:00:00 2001 From: Daeseok Youn Date: Fri, 18 Apr 2014 09:31:35 +0900 Subject: staging: cxt1e1: replace OS_kmalloc/OS_kfree with kzalloc/kfree Replace OS_kmalloc/OS_kfree with kzalloc/kfree. And also some allocation doesn't need to use GFP_DMA so just use GFP_KERNEL. c4_new() function is never called, remove it. Signed-off-by: Daeseok Youn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cxt1e1/hwprobe.c | 2 +- drivers/staging/cxt1e1/linux.c | 21 ++++++------- drivers/staging/cxt1e1/musycc.c | 12 ++++--- drivers/staging/cxt1e1/pmcc4_drv.c | 47 ++++++---------------------- drivers/staging/cxt1e1/sbecom_inline_linux.h | 23 +------------- drivers/staging/cxt1e1/sbecrc.c | 5 +-- drivers/staging/cxt1e1/sbeproc.c | 2 +- 7 files changed, 32 insertions(+), 80 deletions(-) diff --git a/drivers/staging/cxt1e1/hwprobe.c b/drivers/staging/cxt1e1/hwprobe.c index 1a145ea1fa65..cc2151e0acd7 100644 --- a/drivers/staging/cxt1e1/hwprobe.c +++ b/drivers/staging/cxt1e1/hwprobe.c @@ -205,7 +205,7 @@ cleanup_devs(void) #ifdef CONFIG_SBE_PMCC4_NCOMM free_irq(hi->pdev[1]->irq, hi->ndev); #endif - OS_kfree(hi->ndev); + kfree(hi->ndev); } } diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c index b02f5ade6661..4b4609db9f89 100644 --- a/drivers/staging/cxt1e1/linux.c +++ b/drivers/staging/cxt1e1/linux.c @@ -60,7 +60,6 @@ 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); @@ -418,7 +417,7 @@ create_chan(struct net_device *ndev, ci_t *ci, struct c4_priv *priv; /* allocate then fill in private data structure */ - priv = OS_kmalloc(sizeof(struct c4_priv)); + priv = kzalloc(sizeof(struct c4_priv), GFP_KERNEL); if (!priv) { pr_warning("%s: no memory for net_device !\n", ci->devname); @@ -428,7 +427,7 @@ create_chan(struct net_device *ndev, ci_t *ci, if (!dev) { pr_warning("%s: no memory for hdlc_device !\n", ci->devname); - OS_kfree(priv); + kfree(priv); return NULL; } priv->ci = ci; @@ -972,8 +971,8 @@ c4_add_dev(hdw_info_t *hi, int brdno, unsigned long f0, unsigned long f1, if (register_netdev(ndev) || (c4_init(ci, (u_char *) f0, (u_char *) f1) != SBE_DRVR_SUCCESS)) { - OS_kfree(netdev_priv(ndev)); - OS_kfree(ndev); + kfree(netdev_priv(ndev)); + kfree(ndev); error_flag = -ENODEV; return NULL; } @@ -998,8 +997,8 @@ c4_add_dev(hdw_info_t *hi, int brdno, unsigned long f0, unsigned long f1, pr_warning("%s: MUSYCC could not get irq: %d\n", ndev->name, irq0); unregister_netdev(ndev); - OS_kfree(netdev_priv(ndev)); - OS_kfree(ndev); + kfree(netdev_priv(ndev)); + kfree(ndev); error_flag = -EIO; return NULL; } @@ -1008,8 +1007,8 @@ c4_add_dev(hdw_info_t *hi, int brdno, unsigned long f0, unsigned long f1, pr_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); + kfree(netdev_priv(ndev)); + kfree(ndev); error_flag = -EIO; return NULL; } @@ -1068,8 +1067,8 @@ c4_add_dev(hdw_info_t *hi, int brdno, unsigned long f0, unsigned long f1, unregister_netdev(ndev); free_irq(irq1, ndev); free_irq(irq0, ndev); - OS_kfree(netdev_priv(ndev)); - OS_kfree(ndev); + kfree(netdev_priv(ndev)); + kfree(ndev); /* failure, error_flag is set */ return NULL; } diff --git a/drivers/staging/cxt1e1/musycc.c b/drivers/staging/cxt1e1/musycc.c index 7b4f6f2108e3..872cdae02704 100644 --- a/drivers/staging/cxt1e1/musycc.c +++ b/drivers/staging/cxt1e1/musycc.c @@ -744,7 +744,8 @@ musycc_init(ci_t *ci) #define INT_QUEUE_BOUNDARY 4 - regaddr = OS_kmalloc((INT_QUEUE_SIZE + 1) * sizeof(u_int32_t)); + regaddr = kzalloc((INT_QUEUE_SIZE + 1) * sizeof(u_int32_t), + GFP_KERNEL | GFP_DMA); if (!regaddr) return -ENOMEM; ci->iqd_p_saved = regaddr; /* save orig value for free's usage */ @@ -765,11 +766,12 @@ musycc_init(ci_t *ci) #define GROUP_BOUNDARY 0x800 - regaddr = OS_kmalloc(sizeof(struct musycc_groupr) + GROUP_BOUNDARY); + regaddr = kzalloc(sizeof(struct musycc_groupr) + GROUP_BOUNDARY, + GFP_KERNEL | GFP_DMA); if (!regaddr) { for (gchan = 0; gchan < i; gchan++) { pi = &ci->port[gchan]; - OS_kfree(pi->reg); + kfree(pi->reg); pi->reg = NULL; } return -ENOMEM; @@ -1576,10 +1578,10 @@ musycc_chan_down(ci_t *dummy, int channum) if (ch->mdr[i].mem_token) OS_mem_token_free(ch->mdr[i].mem_token); - OS_kfree(ch->mdr); + kfree(ch->mdr); ch->mdr = NULL; ch->rxd_num = 0; - OS_kfree(ch->mdt); + kfree(ch->mdt); ch->mdt = NULL; ch->txd_num = 0; diff --git a/drivers/staging/cxt1e1/pmcc4_drv.c b/drivers/staging/cxt1e1/pmcc4_drv.c index 621a72926475..76bebdd18b3a 100644 --- a/drivers/staging/cxt1e1/pmcc4_drv.c +++ b/drivers/staging/cxt1e1/pmcc4_drv.c @@ -122,35 +122,6 @@ c4_find_chan (int channum) return NULL; } - -ci_t *__init -c4_new (void *hi) -{ - ci_t *ci; - -#ifdef SBE_MAP_DEBUG - pr_warning("c4_new() entered, ci needs %u.\n", - (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 - pr_warning("failed CI malloc, size %u.\n", - (unsigned int) sizeof (ci_t)); - - if (!CI) - 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) @@ -485,12 +456,12 @@ c4_cleanup (void) for (j = 0; j < MUSYCC_NCHANS; j++) { if (pi->chan[j]) - OS_kfree (pi->chan[j]); /* free mch_t struct */ + kfree(pi->chan[j]); /* free mch_t struct */ } - OS_kfree (pi->regram_saved); + kfree(pi->regram_saved); } - OS_kfree (ci->iqd_p_saved); - OS_kfree (ci); + kfree(ci->iqd_p_saved); + kfree(ci); ci = next; /* cleanup next board, if any */ } } @@ -619,7 +590,7 @@ c4_init (ci_t *ci, u_char *func0, u_char *func1) /* allocate channel structures for this port */ for (j = 0; j < MUSYCC_NCHANS; j++) { - ch = OS_kmalloc (sizeof (mch_t)); + ch = kzalloc(sizeof(mch_t), GFP_KERNEL | GFP_DMA); if (ch) { pi->chan[j] = ch; @@ -1368,8 +1339,8 @@ c4_chan_up (ci_t *ci, int channum) 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); + ch->mdr = kzalloc(sizeof(struct mdesc) * rxnum, GFP_KERNEL | GFP_DMA); + ch->mdt = kzalloc(sizeof(struct mdesc) * txnum, GFP_KERNEL | GFP_DMA); if (ch->p.chan_mode == CFG_CH_PROTO_TRANS) tmp = __constant_cpu_to_le32 (cxt1e1_max_mru | EOBIRQ_ENABLE); else @@ -1462,10 +1433,10 @@ errfree: i--; OS_mem_token_free (ch->mdr[i].mem_token); } - OS_kfree (ch->mdt); + kfree(ch->mdt); ch->mdt = NULL; ch->txd_num = 0; - OS_kfree (ch->mdr); + kfree(ch->mdr); ch->mdr = NULL; ch->rxd_num = 0; ch->state = DOWN; diff --git a/drivers/staging/cxt1e1/sbecom_inline_linux.h b/drivers/staging/cxt1e1/sbecom_inline_linux.h index ba3ff3efe063..f5835c29ef32 100644 --- a/drivers/staging/cxt1e1/sbecom_inline_linux.h +++ b/drivers/staging/cxt1e1/sbecom_inline_linux.h @@ -39,27 +39,6 @@ void pci_write_32 (u_int32_t *p, u_int32_t v); * 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 */ /****************/ @@ -197,7 +176,7 @@ static inline int OS_free_watchdog (struct watchdog *wd) { OS_stop_watchdog (wd); - OS_kfree (wd); + kfree(wd); return 0; } diff --git a/drivers/staging/cxt1e1/sbecrc.c b/drivers/staging/cxt1e1/sbecrc.c index 81fa8a3a462c..a51780f60484 100644 --- a/drivers/staging/cxt1e1/sbecrc.c +++ b/drivers/staging/cxt1e1/sbecrc.c @@ -101,7 +101,8 @@ sbeCrc(u_int8_t *buffer, /* data buffer to crc */ tbl = &CRCTable; genCrcTable(tbl); #else - tbl = (u_int32_t *) OS_kmalloc(CRC_TABLE_ENTRIES * sizeof(u_int32_t)); + tbl = kzalloc(CRC_TABLE_ENTRIES * sizeof(u_int32_t), + GFP_KERNEL); if (!tbl) { *result = 0; /* dummy up return value due to malloc * failure */ @@ -125,7 +126,7 @@ sbeCrc(u_int8_t *buffer, /* data buffer to crc */ #ifndef STATIC_CRC_TABLE crcTableInit = 0; - OS_kfree(tbl); + kfree(tbl); #endif } diff --git a/drivers/staging/cxt1e1/sbeproc.c b/drivers/staging/cxt1e1/sbeproc.c index 840c647fbf41..1c2e52e8b5fe 100644 --- a/drivers/staging/cxt1e1/sbeproc.c +++ b/drivers/staging/cxt1e1/sbeproc.c @@ -72,7 +72,7 @@ static int sbecom_proc_get_sbe_info(struct seq_file *m, void *v) char *spd; struct sbe_brd_info *bip; - bip = OS_kmalloc(sizeof(struct sbe_brd_info)); + bip = kzalloc(sizeof(struct sbe_brd_info), GFP_KERNEL | GFP_DMA); if (!bip) return -ENOMEM; -- cgit v1.2.3 From d1a9107116b2bda2b08eeb8b076fd862a644c831 Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld Date: Sun, 6 Apr 2014 17:46:04 +0200 Subject: staging: rtl8187se: Fix warning symbol should be static This patch solves some sparse warnings about "symbol [...] was not declared. Should it be static?" by including the correct header files. Signed-off-by: Jonas Hahnfeld Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8187se/ieee80211/ieee80211_crypt.c | 1 + drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c | 1 + drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_wep.c | 1 + drivers/staging/rtl8187se/r8180_wx.c | 1 + 4 files changed, 4 insertions(+) diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt.c index 101f0c0cdb0a..03462c318e15 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt.c @@ -19,6 +19,7 @@ #include #include +#include "../r8180.h" #include "ieee80211.h" MODULE_AUTHOR("Jouni Malinen"); diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c index 4fe253818630..7eae3d9f5edc 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c @@ -21,6 +21,7 @@ #include #include +#include "../r8180.h" #include "ieee80211.h" #include diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_wep.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_wep.c index f25367224941..288f86c887f2 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_wep.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_wep.c @@ -17,6 +17,7 @@ #include #include +#include "../r8180.h" #include "ieee80211.h" #include diff --git a/drivers/staging/rtl8187se/r8180_wx.c b/drivers/staging/rtl8187se/r8180_wx.c index b55249170f18..57bf01fd733f 100644 --- a/drivers/staging/rtl8187se/r8180_wx.c +++ b/drivers/staging/rtl8187se/r8180_wx.c @@ -20,6 +20,7 @@ #include "r8180.h" #include "r8180_hw.h" +#include "r8180_wx.h" #include #include "ieee80211/dot11d.h" -- cgit v1.2.3 From 26827c836c272a88492b0d426cf60f00d0005b19 Mon Sep 17 00:00:00 2001 From: Martin Kepplinger Date: Wed, 9 Apr 2014 09:25:55 +0200 Subject: staging: rtl8187se: fix pointer and return statement's syntax Use the common kernel coding style. Signed-off-by: Martin Kepplinger Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c index 0dc5ae414270..e6257b3b5aa8 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c @@ -180,7 +180,7 @@ static inline int ieee80211_put_snap(u8 *data, u16 h_proto) int ieee80211_encrypt_fragment(struct ieee80211_device *ieee, struct sk_buff *frag, int hdr_len) { - struct ieee80211_crypt_data* crypt = ieee->crypt[ieee->tx_keyidx]; + struct ieee80211_crypt_data *crypt = ieee->crypt[ieee->tx_keyidx]; int res; /* @@ -285,7 +285,7 @@ static int ieee80211_classify(struct sk_buff *skb, if (!network->QoS_Enable) { skb->priority = 0; - return(wme_UP); + return wme_UP; } if (eh->ether_type == __constant_htons(ETHERTYPE_IP)) { @@ -304,7 +304,7 @@ static int ieee80211_classify(struct sk_buff *skb, } skb->priority = wme_UP; - return(wme_UP); + return wme_UP; } /* SKBs are added to the ieee->tx_queue. */ -- cgit v1.2.3 From 038dcf12b6ca9dcf3e8e50d13326f7b4ef6a196f Mon Sep 17 00:00:00 2001 From: Jake Edge Date: Sun, 13 Apr 2014 11:10:45 -0600 Subject: staging/rtl8187se fix sparse complaints Fix the following sparse complaints: drivers/staging/rtl8187se//ieee80211/ieee80211_crypt.c:201:5: warning: symbol 'ieee80211_crypto_init' was not declared. Should it be static? drivers/staging/rtl8187se//ieee80211/ieee80211_crypt.c:222:6: warning: symbol 'ieee80211_crypto_deinit' was not declared. Should it be static? drivers/staging/rtl8187se//ieee80211/ieee80211_crypt_ccmp.c:446:5: warning: symbol 'ieee80211_crypto_ccmp_init' was not declared. Should it be static? drivers/staging/rtl8187se//ieee80211/ieee80211_crypt_ccmp.c:452:6: warning: symbol 'ieee80211_crypto_ccmp_exit' was not declared. Should it be static? drivers/staging/rtl8187se//ieee80211/ieee80211_crypt_wep.c:264:5: warning: symbol 'ieee80211_crypto_wep_init' was not declared. Should it be static? drivers/staging/rtl8187se//ieee80211/ieee80211_crypt_wep.c:269:6: warning: symbol 'ieee80211_crypto_wep_exit' was not declared. Should it be static? by adding an include file into source files and moving some declarations around into the proper header files. Signed-off-by: Jake Edge Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8187se/ieee80211/ieee80211_crypt.h | 9 +++++++++ drivers/staging/rtl8187se/r8180.h | 9 --------- drivers/staging/rtl8187se/r8180_core.c | 1 + 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt.h b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt.h index 0b4ea431982d..8fe787363d21 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt.h +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt.h @@ -83,4 +83,13 @@ void ieee80211_crypt_deinit_handler(unsigned long); void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, struct ieee80211_crypt_data **crypt); +/* fun with the built-in ieee80211 stack... */ +int ieee80211_crypto_init(void); +void ieee80211_crypto_deinit(void); +int ieee80211_crypto_tkip_init(void); +void ieee80211_crypto_tkip_exit(void); +int ieee80211_crypto_ccmp_init(void); +void ieee80211_crypto_ccmp_exit(void); +int ieee80211_crypto_wep_init(void); +void ieee80211_crypto_wep_exit(void); #endif diff --git a/drivers/staging/rtl8187se/r8180.h b/drivers/staging/rtl8187se/r8180.h index 9f931dba1d82..cf510b65a98a 100644 --- a/drivers/staging/rtl8187se/r8180.h +++ b/drivers/staging/rtl8187se/r8180.h @@ -629,12 +629,3 @@ bool MgntActSet_RF_State(struct net_device *dev, enum rt_rf_power_state StateToS #endif -/* fun with the built-in ieee80211 stack... */ -extern int ieee80211_crypto_init(void); -extern void ieee80211_crypto_deinit(void); -extern int ieee80211_crypto_tkip_init(void); -extern void ieee80211_crypto_tkip_exit(void); -extern int ieee80211_crypto_ccmp_init(void); -extern void ieee80211_crypto_ccmp_exit(void); -extern int ieee80211_crypto_wep_init(void); -extern void ieee80211_crypto_wep_exit(void); diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c index a6022d4e7573..cbdff00323f2 100644 --- a/drivers/staging/rtl8187se/r8180_core.c +++ b/drivers/staging/rtl8187se/r8180_core.c @@ -47,6 +47,7 @@ #include "r8180_dm.h" #include "ieee80211/dot11d.h" +#include "ieee80211/ieee80211_crypt.h" static struct pci_device_id rtl8180_pci_id_tbl[] = { { -- cgit v1.2.3 From fbfaccff4f522260ca1ce859a9ca63f96c2256a7 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 22 Mar 2014 09:01:23 +0000 Subject: staging: vt6656: rxtx.c: s_vFillTxKey Replace dwRevIVCounter Fix base type to __le32 and remove camel case. Camel case change dwRevIVCounter -> rev_iv_counter Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 3840323858fc..9f80a7a0d3a2 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -184,28 +184,28 @@ static void s_vFillTxKey(struct vnt_private *pDevice, u32 *pdwIV = (u32 *)pbyIVHead; u32 *pdwExtIV = (u32 *)((u8 *)pbyIVHead + 4); struct ieee80211_hdr *pMACHeader = (struct ieee80211_hdr *)pbyHdrBuf; - u32 dwRevIVCounter; + __le32 rev_iv_counter; /* Fill TXKEY */ if (pTransmitKey == NULL) return; - dwRevIVCounter = cpu_to_le32(pDevice->dwIVCounter); + rev_iv_counter = cpu_to_le32(pDevice->dwIVCounter); *pdwIV = pDevice->dwIVCounter; pDevice->byKeyIndex = pTransmitKey->dwKeyIndex & 0xf; switch (pTransmitKey->byCipherSuite) { case KEY_CTL_WEP: if (pTransmitKey->uKeyLength == WLAN_WEP232_KEYLEN) { - memcpy(pDevice->abyPRNG, (u8 *)&dwRevIVCounter, 3); + memcpy(pDevice->abyPRNG, (u8 *)&rev_iv_counter, 3); memcpy(pDevice->abyPRNG + 3, pTransmitKey->abyKey, pTransmitKey->uKeyLength); } else { - memcpy(pbyBuf, (u8 *)&dwRevIVCounter, 3); + memcpy(pbyBuf, (u8 *)&rev_iv_counter, 3); memcpy(pbyBuf + 3, pTransmitKey->abyKey, pTransmitKey->uKeyLength); if (pTransmitKey->uKeyLength == WLAN_WEP40_KEYLEN) { - memcpy(pbyBuf+8, (u8 *)&dwRevIVCounter, 3); + memcpy(pbyBuf+8, (u8 *)&rev_iv_counter, 3); memcpy(pbyBuf+11, pTransmitKey->abyKey, pTransmitKey->uKeyLength); } -- cgit v1.2.3 From fb453db9bfbe23e71c654392e40a30a7bc9958cd Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 22 Mar 2014 09:01:24 +0000 Subject: staging: vt6656: rxtx s_vFillTxKey Fix pdwIV base type Use base type __le32 and endian correct changed values. Correct endian conversions to cpu_to_le32. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 9f80a7a0d3a2..f2f96ee35073 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -181,7 +181,7 @@ static void s_vFillTxKey(struct vnt_private *pDevice, struct vnt_mic_hdr *mic_hdr) { u8 *pbyBuf = (u8 *)&fifo_head->adwTxKey[0]; - u32 *pdwIV = (u32 *)pbyIVHead; + __le32 *pdwIV = (__le32 *)pbyIVHead; u32 *pdwExtIV = (u32 *)((u8 *)pbyIVHead + 4); struct ieee80211_hdr *pMACHeader = (struct ieee80211_hdr *)pbyHdrBuf; __le32 rev_iv_counter; @@ -191,7 +191,7 @@ static void s_vFillTxKey(struct vnt_private *pDevice, return; rev_iv_counter = cpu_to_le32(pDevice->dwIVCounter); - *pdwIV = pDevice->dwIVCounter; + *pdwIV = cpu_to_le32(pDevice->dwIVCounter); pDevice->byKeyIndex = pTransmitKey->dwKeyIndex & 0xf; switch (pTransmitKey->byCipherSuite) { @@ -213,9 +213,8 @@ static void s_vFillTxKey(struct vnt_private *pDevice, memcpy(pDevice->abyPRNG, pbyBuf, 16); } /* Append IV after Mac Header */ - *pdwIV &= WEP_IV_MASK; - *pdwIV |= (u32)pDevice->byKeyIndex << 30; - *pdwIV = cpu_to_le32(*pdwIV); + *pdwIV &= cpu_to_le32(WEP_IV_MASK); + *pdwIV |= cpu_to_le32((u32)pDevice->byKeyIndex << 30); pDevice->dwIVCounter++; if (pDevice->dwIVCounter > WEP_IV_MASK) @@ -256,7 +255,7 @@ static void s_vFillTxKey(struct vnt_private *pDevice, *(pbyIVHead+3) = (u8)(((pDevice->byKeyIndex << 6) & 0xc0) | 0x20); - *pdwIV |= cpu_to_le16((u16)(pTransmitKey->wTSC15_0)); + *pdwIV |= cpu_to_le32((u32)(pTransmitKey->wTSC15_0)); /* Append IV&ExtIV after Mac Header */ *pdwExtIV = cpu_to_le32(pTransmitKey->dwTSC47_16); -- cgit v1.2.3 From 2fbb230c8a488f7e0d9f5328fd11770702b8ddf4 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 22 Mar 2014 09:01:25 +0000 Subject: staging: vt6656: rxtx: s_vFillTxKey Fix base type pdwExtIV Use base type to __le32. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index f2f96ee35073..43e13e2766ed 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -182,7 +182,7 @@ static void s_vFillTxKey(struct vnt_private *pDevice, { u8 *pbyBuf = (u8 *)&fifo_head->adwTxKey[0]; __le32 *pdwIV = (__le32 *)pbyIVHead; - u32 *pdwExtIV = (u32 *)((u8 *)pbyIVHead + 4); + __le32 *pdwExtIV = (__le32 *)((u8 *)pbyIVHead + 4); struct ieee80211_hdr *pMACHeader = (struct ieee80211_hdr *)pbyHdrBuf; __le32 rev_iv_counter; -- cgit v1.2.3 From 5d4fe75704df3ac3a8f908163f2e9988f4c16dd0 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 22 Mar 2014 09:01:26 +0000 Subject: staging: vt6656: rxtx: s_vFillTxKey fix pMACHeader sparse warning Endian convert __le16 pMACHeader->frame_control and pMACHeader->seq_ctrl back to cpu. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 43e13e2766ed..9706e1846dbd 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -282,9 +282,10 @@ static void s_vFillTxKey(struct vnt_private *pDevice, /* MICHDR2 */ memcpy(mic_hdr->addr3, pMACHeader->addr3, ETH_ALEN); - mic_hdr->frame_control = cpu_to_le16(pMACHeader->frame_control - & 0xc78f); - mic_hdr->seq_ctrl = cpu_to_le16(pMACHeader->seq_ctrl & 0xf); + mic_hdr->frame_control = cpu_to_le16( + le16_to_cpu(pMACHeader->frame_control) & 0xc78f); + mic_hdr->seq_ctrl = cpu_to_le16( + le16_to_cpu(pMACHeader->seq_ctrl) & 0xf); if (ieee80211_has_a4(pMACHeader->frame_control)) memcpy(mic_hdr->addr4, pMACHeader->addr4, ETH_ALEN); -- cgit v1.2.3 From 5846251d0e5a2027acc5f09b826ba4008cc282cc Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 22 Mar 2014 09:01:27 +0000 Subject: staging: vt6656: rxtx Replace struct vnt_tx_fifo_head wTimeStamp Replace with time_stamp with base type __le16 In s_bPacketToWirelessUsb endian correct DEFAULT_MSDU_LIFETIME_RES_64us Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 6 +++--- drivers/staging/vt6656/rxtx.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 9706e1846dbd..1624efbcca1a 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -1008,7 +1008,7 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK; } - pTxBufHead->wTimeStamp = DEFAULT_MSDU_LIFETIME_RES_64us; + pTxBufHead->time_stamp = cpu_to_le16(DEFAULT_MSDU_LIFETIME_RES_64us); //Set FRAGCTL_MACHDCNT cbMACHdLen = WLAN_HDR_ADDR3_LEN; @@ -1431,7 +1431,7 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, } pTxBufHead->wFIFOCtl |= FIFOCTL_TMOEN; - pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us); + pTxBufHead->time_stamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us); if (is_multicast_ether_addr(pPacket->p80211Header->sA3.abyAddr1)) { bNeedACK = false; @@ -1800,7 +1800,7 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) } pTxBufHead->wFIFOCtl |= FIFOCTL_TMOEN; - pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us); + pTxBufHead->time_stamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us); if (is_multicast_ether_addr(p80211Header->sA3.abyAddr1)) { bNeedACK = false; diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h index 6d6539d29d04..d7e42731df32 100644 --- a/drivers/staging/vt6656/rxtx.h +++ b/drivers/staging/vt6656/rxtx.h @@ -217,7 +217,7 @@ union vnt_tx_head { struct vnt_tx_fifo_head { u32 adwTxKey[4]; u16 wFIFOCtl; - u16 wTimeStamp; + __le16 time_stamp; u16 wFragCtl; u16 wReserved; } __packed; -- cgit v1.2.3 From ca3475968a6fc0a648bf642ac7a976be777c4a37 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 22 Mar 2014 09:01:28 +0000 Subject: staging: vt6656: rxtx struct vnt_tx_buffer Replace wTxByteCount Replace with tx_byte_count with base type __le16. In nsDMA_tx_packet and bRelayPacketSend provide endian correction. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 8 ++++---- drivers/staging/vt6656/rxtx.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 1624efbcca1a..c17c3dad9437 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -1605,7 +1605,7 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, } } - pTX_Buffer->wTxByteCount = cpu_to_le16((u16)(cbReqCount)); + pTX_Buffer->tx_byte_count = cpu_to_le16((u16)(cbReqCount)); pTX_Buffer->byPKTNO = (u8) (((wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); pTX_Buffer->byType = 0x00; @@ -2045,7 +2045,7 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) } } - pTX_Buffer->wTxByteCount = cpu_to_le16((u16)(cbReqCount)); + pTX_Buffer->tx_byte_count = cpu_to_le16((u16)(cbReqCount)); pTX_Buffer->byPKTNO = (u8) (((wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); pTX_Buffer->byType = 0x00; @@ -2437,7 +2437,7 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, } pTX_Buffer->byPKTNO = (u8) (((pDevice->wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); - pTX_Buffer->wTxByteCount = (u16)BytesToWrite; + pTX_Buffer->tx_byte_count = cpu_to_le16((u16)BytesToWrite); pContext->pPacket = skb; pContext->type = CONTEXT_DATA_PACKET; @@ -2591,7 +2591,7 @@ int bRelayPacketSend(struct vnt_private *pDevice, u8 *pbySkbData, u32 uDataLen, } pTX_Buffer->byPKTNO = (u8) (((pDevice->wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); - pTX_Buffer->wTxByteCount = (u16)BytesToWrite; + pTX_Buffer->tx_byte_count = cpu_to_le16((u16)BytesToWrite); pContext->pPacket = NULL; pContext->type = CONTEXT_DATA_PACKET; diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h index d7e42731df32..0233761bdb74 100644 --- a/drivers/staging/vt6656/rxtx.h +++ b/drivers/staging/vt6656/rxtx.h @@ -225,7 +225,7 @@ struct vnt_tx_fifo_head { struct vnt_tx_buffer { u8 byType; u8 byPKTNO; - u16 wTxByteCount; + __le16 tx_byte_count; struct vnt_tx_fifo_head fifo_head; union vnt_tx_head tx_head; } __packed; -- cgit v1.2.3 From fad8e4aeac9d085e020241b30bde0197ae821f0a Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 22 Mar 2014 09:01:29 +0000 Subject: staging : vt6656: rxtx struct vnt_beacon_buffer Replace wTxByteCount Replace with tx_byte_count with base type __le16 Provide endian correction in csBeacon_xmit of cbReqCount Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 2 +- drivers/staging/vt6656/rxtx.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index c17c3dad9437..4bb13a7c75f2 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -1697,7 +1697,7 @@ CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, cbReqCount = cbHeaderSize + WLAN_HDR_ADDR3_LEN + cbFrameBodySize; - pTX_Buffer->wTxByteCount = (u16)cbReqCount; + pTX_Buffer->tx_byte_count = cpu_to_le16((u16)cbReqCount); pTX_Buffer->byPKTNO = (u8) (((wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); pTX_Buffer->byType = 0x01; diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h index 0233761bdb74..779c6722d1b8 100644 --- a/drivers/staging/vt6656/rxtx.h +++ b/drivers/staging/vt6656/rxtx.h @@ -241,7 +241,7 @@ struct vnt_tx_short_buf_head { struct vnt_beacon_buffer { u8 byType; u8 byPKTNO; - u16 wTxByteCount; + __le16 tx_byte_count; struct vnt_tx_short_buf_head short_head; struct ieee80211_hdr hdr; } __packed; -- cgit v1.2.3 From 03a9cf3418fa95fcba65bcbdfd68dc84f7e916bb Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 22 Mar 2014 09:01:30 +0000 Subject: staging: vt6656: rxtx Replace vnt_tx_fifo_head wReserved At run time wReserved has the value of wCurrentRate. Replace with current_rate with __le16 base type and endian correct wCurrentRate. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 2 +- drivers/staging/vt6656/rxtx.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 4bb13a7c75f2..2b67b1bdd90b 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -800,7 +800,7 @@ static u16 s_vGenerateTxParameter(struct vnt_private *pDevice, u16 wFifoCtl; u8 byFBOption = AUTO_FB_NONE; - pFifoHead->wReserved = wCurrentRate; + pFifoHead->current_rate = cpu_to_le16(wCurrentRate); wFifoCtl = pFifoHead->wFIFOCtl; if (wFifoCtl & FIFOCTL_AUTO_FB_0) diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h index 779c6722d1b8..4dfb2e0c6ae7 100644 --- a/drivers/staging/vt6656/rxtx.h +++ b/drivers/staging/vt6656/rxtx.h @@ -219,7 +219,7 @@ struct vnt_tx_fifo_head { u16 wFIFOCtl; __le16 time_stamp; u16 wFragCtl; - u16 wReserved; + __le16 current_rate; } __packed; struct vnt_tx_buffer { -- cgit v1.2.3 From f4554d3b0e46ca126a22f556cf840543d16e308b Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 22 Mar 2014 09:01:31 +0000 Subject: staging: vt6656: vnt_fill_ieee80211_rts replace TYPE_CTL_RTS macro Replace with IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS from linux/ieee80211.h to get value of TYPE_CTL_RTS and endian correct to frame_control. Remove old macros in tether.h Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 3 ++- drivers/staging/vt6656/tether.h | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 2b67b1bdd90b..ac60999bc067 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -551,7 +551,8 @@ static int vnt_fill_ieee80211_rts(struct vnt_private *priv, __le16 duration) { rts->duration = duration; - rts->frame_control = TYPE_CTL_RTS; + rts->frame_control = + cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS); if (priv->op_mode == NL80211_IFTYPE_ADHOC || priv->op_mode == NL80211_IFTYPE_AP) diff --git a/drivers/staging/vt6656/tether.h b/drivers/staging/vt6656/tether.h index aec6b568a4a9..f42eddae7bb5 100644 --- a/drivers/staging/vt6656/tether.h +++ b/drivers/staging/vt6656/tether.h @@ -60,7 +60,6 @@ #define TYPE_DATE_NULL 0x4800 #define TYPE_CTL_PSPOLL 0xa400 -#define TYPE_CTL_RTS 0xb400 #define TYPE_CTL_CTS 0xc400 #define TYPE_CTL_ACK 0xd400 @@ -91,7 +90,6 @@ #define TYPE_DATE_NULL 0x0048 #define TYPE_CTL_PSPOLL 0x00a4 -#define TYPE_CTL_RTS 0x00b4 #define TYPE_CTL_CTS 0x00c4 #define TYPE_CTL_ACK 0x00d4 -- cgit v1.2.3 From d9560ae53b3337ee97f989959014ce1248a4c170 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 22 Mar 2014 09:01:32 +0000 Subject: staging: vt6656: rxtx s_vFillCTSHead replace TYPE_CTL_CTS macro Replace with IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS from linux/ieee80211.h to get value of TYPE_CTL_CTS and endian correct to frame_control. Remove old macros in tether.h Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 8 ++++++-- drivers/staging/vt6656/tether.h | 2 -- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index ac60999bc067..1ff14469df99 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -742,7 +742,9 @@ static u16 s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, pDevice->tx_rate_fb1, bNeedAck, byFBOption); /* Get CTS Frame body */ pBuf->data.duration = pBuf->duration_ba; - pBuf->data.frame_control = TYPE_CTL_CTS; + pBuf->data.frame_control = + cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS); + memcpy(pBuf->data.ra, pDevice->abyCurrentNetAddr, ETH_ALEN); return vnt_rxtx_datahead_g_fb(pDevice, byPktType, wCurrentRate, @@ -758,7 +760,9 @@ static u16 s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, wCurrentRate, bNeedAck, byFBOption); /*Get CTS Frame body*/ pBuf->data.duration = pBuf->duration_ba; - pBuf->data.frame_control = TYPE_CTL_CTS; + pBuf->data.frame_control = + cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS); + memcpy(pBuf->data.ra, pDevice->abyCurrentNetAddr, ETH_ALEN); return vnt_rxtx_datahead_g(pDevice, byPktType, wCurrentRate, diff --git a/drivers/staging/vt6656/tether.h b/drivers/staging/vt6656/tether.h index f42eddae7bb5..f57fcfdc24d5 100644 --- a/drivers/staging/vt6656/tether.h +++ b/drivers/staging/vt6656/tether.h @@ -60,7 +60,6 @@ #define TYPE_DATE_NULL 0x4800 #define TYPE_CTL_PSPOLL 0xa400 -#define TYPE_CTL_CTS 0xc400 #define TYPE_CTL_ACK 0xd400 #else //if LITTLE_ENDIAN @@ -90,7 +89,6 @@ #define TYPE_DATE_NULL 0x0048 #define TYPE_CTL_PSPOLL 0x00a4 -#define TYPE_CTL_CTS 0x00c4 #define TYPE_CTL_ACK 0x00d4 #endif //#ifdef __BIG_ENDIAN -- cgit v1.2.3 From eb0eb66846bbd19b2154e7902386061f0bcd17f5 Mon Sep 17 00:00:00 2001 From: Ioana Ileana Date: Mon, 24 Mar 2014 14:58:05 +0100 Subject: staging: vt6655: fix sparse warning Added missing static qualifier Signed-off-by: Ioana Ileana Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/datarate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vt6655/datarate.c b/drivers/staging/vt6655/datarate.c index c9a89cd7633c..2d760da626bb 100644 --- a/drivers/staging/vt6655/datarate.c +++ b/drivers/staging/vt6655/datarate.c @@ -51,7 +51,7 @@ extern unsigned short TxRate_iwconfig; //2008-5-8 by chester /*--------------------- Static Variables --------------------------*/ //static int msglevel =MSG_LEVEL_DEBUG; static int msglevel = MSG_LEVEL_INFO; -const unsigned char acbyIERate[MAX_RATE] = +static const unsigned char acbyIERate[MAX_RATE] = {0x02, 0x04, 0x0B, 0x16, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C}; #define AUTORATE_TXOK_CNT 0x0400 -- cgit v1.2.3 From f2ca407b9677eb24e824dc78586d102d8c57f37d Mon Sep 17 00:00:00 2001 From: Cédric Cabessa Date: Wed, 26 Mar 2014 17:49:01 +0100 Subject: staging: vt6655,vt6656: fix sparse error "unexpected unlock" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédric Cabessa Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/wpactl.c | 3 ++- drivers/staging/vt6656/firmware.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vt6655/wpactl.c b/drivers/staging/vt6655/wpactl.c index d17224f39b4d..9f0715cc6367 100644 --- a/drivers/staging/vt6655/wpactl.c +++ b/drivers/staging/vt6655/wpactl.c @@ -188,7 +188,8 @@ int wpa_set_wpadev(PSDevice pDevice, int val) * */ -int wpa_set_keys(PSDevice pDevice, void *ctx, bool fcpfkernel) +int wpa_set_keys(PSDevice pDevice, void *ctx, + bool fcpfkernel) __must_hold(&pDevice->lock) { struct viawget_wpa_param *param = ctx; PSMgmtObject pMgmt = pDevice->pMgmt; diff --git a/drivers/staging/vt6656/firmware.c b/drivers/staging/vt6656/firmware.c index cd2ea76c8b1e..15c1e861c84b 100644 --- a/drivers/staging/vt6656/firmware.c +++ b/drivers/staging/vt6656/firmware.c @@ -31,6 +31,7 @@ * */ +#include #include "firmware.h" #include "control.h" #include "rndis.h" @@ -43,7 +44,7 @@ static int msglevel = MSG_LEVEL_INFO; #define FIRMWARE_CHUNK_SIZE 0x400 -int FIRMWAREbDownload(struct vnt_private *pDevice) +int FIRMWAREbDownload(struct vnt_private *pDevice) __must_hold(&pDevice->lock) { struct device *dev = &pDevice->usb->dev; const struct firmware *fw; -- cgit v1.2.3 From c720dadab70daf9005c85b084a3f7e983f0fb0cb Mon Sep 17 00:00:00 2001 From: Guido Martínez Date: Wed, 2 Apr 2014 14:53:01 -0300 Subject: staging: vt6655: fix DBG_PRT and PRINT_K macros MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wrap both macros inside a 'do { ... } while(0)' to prevent breakage if used within another 'if'. Also fix a usage of DBG_PRT with a missing semicolon. Signed-off-by: Guido Martínez Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 13 +++++++++++-- drivers/staging/vt6655/wpactl.c | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 062c3a374b99..985c3c19a4a7 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -148,8 +148,17 @@ /*--------------------- Export Types ------------------------------*/ -#define DBG_PRT(l, p, args...) { if (l <= msglevel) printk(p, ##args); } -#define PRINT_K(p, args...) { if (PRIVATE_Message) printk(p, ##args); } +#define DBG_PRT(l, p, args...) \ +do { \ + if (l <= msglevel) \ + printk(p, ##args); \ +} while (0) + +#define PRINT_K(p, args...) \ +do { \ + if (PRIVATE_Message) \ + printk(p, ##args); \ +} while (0) //0:11A 1:11B 2:11G typedef enum _VIA_BB_TYPE diff --git a/drivers/staging/vt6655/wpactl.c b/drivers/staging/vt6655/wpactl.c index 9f0715cc6367..a3a663fd7afa 100644 --- a/drivers/staging/vt6655/wpactl.c +++ b/drivers/staging/vt6655/wpactl.c @@ -680,7 +680,7 @@ static int wpa_get_scan(PSDevice pDevice, ret = -EFAULT; } param->u.scan_results.scan_count = count; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " param->u.scan_results.scan_count = %d\n", count) + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " param->u.scan_results.scan_count = %d\n", count); kfree(pBuf); return ret; -- cgit v1.2.3 From 3248c07c7b308787b332b319efc0530dc9886011 Mon Sep 17 00:00:00 2001 From: Guido Martínez Date: Wed, 2 Apr 2014 14:53:02 -0300 Subject: staging: vt6655: remove mention of nonexistent function CARDbSetBasicRate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Comments mention a function CARDbSetBasicRate, but it never existed in the source tree. Remove all mention of it. Signed-off-by: Guido Martínez Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index db38ca051130..e7227954f2fe 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -24,7 +24,6 @@ * vUpdateIFS - Update slotTime,SIFS,DIFS, and EIFS * CARDvUpdateBasicTopRate - Update BasicTopRate * CARDbAddBasicRate - Add to BasicRateSet - * CARDbSetBasicRate - Set Basic Tx Rate * CARDbIsOFDMinBasicRate - Check if any OFDM rate is in BasicRateSet * CARDvSetLoopbackMode - Set Loopback mode * CARDbSoftwareReset - Sortware reset NIC @@ -1877,19 +1876,6 @@ void CARDvUpdateBasicTopRate(void *pDeviceHandler) pDevice->byTopCCKBasicRate = byTopCCK; } -/* - * Description: Set NIC Tx Basic Rate - * - * Parameters: - * In: - * pDevice - The adapter to be set - * wBasicRate - Basic Rate to be set - * Out: - * none - * - * Return Value: true if succeeded; false if failed. - * - */ bool CARDbAddBasicRate(void *pDeviceHandler, unsigned short wRateIdx) { PSDevice pDevice = (PSDevice) pDeviceHandler; -- cgit v1.2.3 From 30d991dd44ded3288c373246f9fd8eaee291584a Mon Sep 17 00:00:00 2001 From: Jimmy Li Date: Tue, 8 Apr 2014 21:35:02 +0800 Subject: Staging: vt6655: iwctl.c: fix a sparse warning fix a sparse warning and do some clean up. iwctl.c:1846:35: expected restricted gfp_t [usertype] flags Signed-off-by: Jimmy Li Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/iwctl.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/staging/vt6655/iwctl.c b/drivers/staging/vt6655/iwctl.c index ac3fc16704c1..a601c47a3803 100644 --- a/drivers/staging/vt6655/iwctl.c +++ b/drivers/staging/vt6655/iwctl.c @@ -1835,19 +1835,14 @@ int iwctl_siwencodeext(struct net_device *dev, size_t seq_len = 0, key_len = 0; // // int ii; - u8 *buf; - size_t blen; u8 key_array[64]; int ret = 0; PRINT_K("SIOCSIWENCODEEXT...... \n"); - blen = sizeof(*param); - buf = kmalloc((int)blen, (int)GFP_KERNEL); - if (buf == NULL) + param = kzalloc(sizeof(*param), GFP_KERNEL); + if (param == NULL) return -ENOMEM; - memset(buf, 0, blen); - param = (struct viawget_wpa_param *)buf; //recover alg_name switch (ext->alg) { -- cgit v1.2.3 From 6b2a01696489cf9c0d98b85dca0aed7ae280e855 Mon Sep 17 00:00:00 2001 From: Neil Armstrong Date: Fri, 11 Apr 2014 14:59:55 +0200 Subject: staging: vt6656: fix bad symbol declaration With sparse, the following error appears : CHECK drivers/staging/vt6656/aes_ccmp.c drivers/staging/vt6656/aes_ccmp.c:221:6: warning: symbol 'AESbGenCCMP' was not declared. Should it be static? Add correct include header in order to have function declaration. Signed-off-by: Neil 'Superna' Armstrong Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/aes_ccmp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/vt6656/aes_ccmp.c b/drivers/staging/vt6656/aes_ccmp.c index e2bfa8d266cd..a9d51687db7f 100644 --- a/drivers/staging/vt6656/aes_ccmp.c +++ b/drivers/staging/vt6656/aes_ccmp.c @@ -32,6 +32,7 @@ #include "device.h" #include "80211hdr.h" +#include "aes_ccmp.h" /* * SBOX Table -- cgit v1.2.3 From 77be4f47886fec14986f265e1ae08dd08a928032 Mon Sep 17 00:00:00 2001 From: Silvio Fricke Date: Sat, 12 Apr 2014 02:30:24 +0200 Subject: staging: vt6655: removed incorrect casting in wpactl.c This patch fixes the following type of sparse warnings: drivers/staging/vt6655/wpactl.c:596:47: warning: cast from restricted gfp_t drivers/staging/vt6655/wpactl.c:638:68: warning: cast from restricted gfp_t drivers/staging/vt6655/wpactl.c:860:42: warning: cast from restricted gfp_t Signed-off-by: Silvio Fricke Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/wpactl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vt6655/wpactl.c b/drivers/staging/vt6655/wpactl.c index a3a663fd7afa..1f72589cf718 100644 --- a/drivers/staging/vt6655/wpactl.c +++ b/drivers/staging/vt6655/wpactl.c @@ -594,7 +594,7 @@ static int wpa_get_scan(PSDevice pDevice, unsigned char *ptempBSS; - ptempBSS = kmalloc(sizeof(KnownBSS), (int)GFP_ATOMIC); + ptempBSS = kmalloc(sizeof(KnownBSS), GFP_ATOMIC); if (ptempBSS == NULL) { printk(KERN_ERR "bubble sort kmalloc memory fail@@@\n"); @@ -636,7 +636,7 @@ static int wpa_get_scan(PSDevice pDevice, count++; } - pBuf = kcalloc(count, sizeof(struct viawget_scan_result), (int)GFP_ATOMIC); + pBuf = kcalloc(count, sizeof(struct viawget_scan_result), GFP_ATOMIC); if (pBuf == NULL) { ret = -ENOMEM; @@ -858,7 +858,7 @@ int wpa_ioctl(PSDevice pDevice, struct iw_point *p) p->length > VIAWGET_WPA_MAX_BUF_SIZE || !p->pointer) return -EINVAL; - param = kmalloc((int)p->length, (int)GFP_KERNEL); + param = kmalloc((int)p->length, GFP_KERNEL); if (param == NULL) return -ENOMEM; -- cgit v1.2.3 From b47eb6cd8fb1b37d8a02ad7414a08fce2f477330 Mon Sep 17 00:00:00 2001 From: Silvio Fricke Date: Sat, 12 Apr 2014 02:30:25 +0200 Subject: staging: vt6655: removed incorrect casting in ioctl.c This patch fixes the following type of sparse warnings: drivers/staging/vt6655/ioctl.c:308:104: warning: cast from restricted gfp_t drivers/staging/vt6655/ioctl.c:579:109: warning: cast from restricted gfp_t Signed-off-by: Silvio Fricke Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/ioctl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vt6655/ioctl.c b/drivers/staging/vt6655/ioctl.c index b5cd2e44e53d..1de5d2c907d2 100644 --- a/drivers/staging/vt6655/ioctl.c +++ b/drivers/staging/vt6655/ioctl.c @@ -305,7 +305,8 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) result = -EINVAL; break; } - pList = (PSBSSIDList)kmalloc(sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)), (int)GFP_ATOMIC); + pList = (PSBSSIDList)kmalloc(sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)), + GFP_ATOMIC); if (pList == NULL) { result = -ENOMEM; break; @@ -576,7 +577,8 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) result = -EINVAL; break; } - pNodeList = (PSNodeList)kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), (int)GFP_ATOMIC); + pNodeList = (PSNodeList)kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), + GFP_ATOMIC); if (pNodeList == NULL) { result = -ENOMEM; break; -- cgit v1.2.3 From 14dbfb6831fb3df28ce532ac666f17f3607009cb Mon Sep 17 00:00:00 2001 From: Gulsah Kose Date: Sat, 22 Mar 2014 19:57:18 +0200 Subject: staging: sbe-2t3e3: Fix line over 80 characters in cpld.c Fix checkpatch.pl issues with line over 80 characters in cpld.c Signed-off-by: Gulsah Kose Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sbe-2t3e3/cpld.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/sbe-2t3e3/cpld.c b/drivers/staging/sbe-2t3e3/cpld.c index c6370d3d637f..a93b05bf992c 100644 --- a/drivers/staging/sbe-2t3e3/cpld.c +++ b/drivers/staging/sbe-2t3e3/cpld.c @@ -30,7 +30,8 @@ static inline void cpld_set_bit(struct channel *channel, unsigned reg, u32 bit) spin_unlock_irqrestore(&channel->card->bootrom_lock, flags); } -static inline void cpld_clear_bit(struct channel *channel, unsigned reg, u32 bit) +static inline void cpld_clear_bit(struct channel *channel, + unsigned reg, u32 bit) { unsigned long flags; spin_lock_irqsave(&channel->card->bootrom_lock, flags); -- cgit v1.2.3 From e112f89bcc231d6ce1857a1a028c350c3fa869ed Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Wed, 26 Mar 2014 22:33:41 +0100 Subject: staging: panel: replace del_timer by del_timer_sync Use del_timer_sync to ensure that the timer is stopped on all CPUs before the driver exists. This change was suggested by Thomas Gleixner. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @r@ declarer name module_exit; identifier ex; @@ module_exit(ex); @@ identifier r.ex; @@ ex(...) { <... - del_timer + del_timer_sync (...) ...> } // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index 08f9a4896116..a53f94e7e9c3 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -2298,7 +2298,7 @@ static void __exit panel_cleanup_module(void) unregister_reboot_notifier(&panel_notifier); if (scan_timer.function != NULL) - del_timer(&scan_timer); + del_timer_sync(&scan_timer); if (pprt != NULL) { if (keypad_enabled) { -- cgit v1.2.3 From 70a8c3eb8546cefe40fb0bc7991e8899b7b91075 Mon Sep 17 00:00:00 2001 From: Bastien Armand Date: Fri, 18 Apr 2014 18:10:57 +0200 Subject: staging: panel: fix sparse warnings in lcd_write This patch fixes two sparse warnings related to lcd_write : warning: incorrect type in argument 1 (different address spaces) warning: incorrect type in initializer (incompatible argument 2 (different address spaces)) lcd_write can be used from kernel space (in panel_lcd_print) or from user space. So we introduce the lcd_write_char function that will write a char to the device. We modify lcd_write and panel_lcd_print to use it. Finally we add __user annotation missing in lcd_write. Signed-off-by: Bastien Armand Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 205 ++++++++++++++++++++++-------------------- 1 file changed, 109 insertions(+), 96 deletions(-) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index a53f94e7e9c3..e2e3c6bc3a6c 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -1217,111 +1217,113 @@ static inline int handle_lcd_special_code(void) return processed; } +static void lcd_write_char(char c) +{ + /* first, we'll test if we're in escape mode */ + if ((c != '\n') && lcd_escape_len >= 0) { + /* yes, let's add this char to the buffer */ + lcd_escape[lcd_escape_len++] = c; + lcd_escape[lcd_escape_len] = 0; + } else { + /* aborts any previous escape sequence */ + lcd_escape_len = -1; + + switch (c) { + case LCD_ESCAPE_CHAR: + /* start of an escape sequence */ + lcd_escape_len = 0; + lcd_escape[lcd_escape_len] = 0; + break; + case '\b': + /* go back one char and clear it */ + if (lcd_addr_x > 0) { + /* check if we're not at the + end of the line */ + if (lcd_addr_x < lcd_bwidth) + /* back one char */ + lcd_write_cmd(0x10); + lcd_addr_x--; + } + /* replace with a space */ + lcd_write_data(' '); + /* back one char again */ + lcd_write_cmd(0x10); + break; + case '\014': + /* quickly clear the display */ + lcd_clear_fast(); + break; + case '\n': + /* flush the remainder of the current line and + go to the beginning of the next line */ + for (; lcd_addr_x < lcd_bwidth; lcd_addr_x++) + lcd_write_data(' '); + lcd_addr_x = 0; + lcd_addr_y = (lcd_addr_y + 1) % lcd_height; + lcd_gotoxy(); + break; + case '\r': + /* go to the beginning of the same line */ + lcd_addr_x = 0; + lcd_gotoxy(); + break; + case '\t': + /* print a space instead of the tab */ + lcd_print(' '); + break; + default: + /* simply print this char */ + lcd_print(c); + break; + } + } + + /* now we'll see if we're in an escape mode and if the current + escape sequence can be understood. */ + if (lcd_escape_len >= 2) { + int processed = 0; + + if (!strcmp(lcd_escape, "[2J")) { + /* clear the display */ + lcd_clear_fast(); + processed = 1; + } else if (!strcmp(lcd_escape, "[H")) { + /* cursor to home */ + lcd_addr_x = lcd_addr_y = 0; + lcd_gotoxy(); + processed = 1; + } + /* codes starting with ^[[L */ + else if ((lcd_escape_len >= 3) && + (lcd_escape[0] == '[') && + (lcd_escape[1] == 'L')) { + processed = handle_lcd_special_code(); + } + + /* LCD special escape codes */ + /* flush the escape sequence if it's been processed + or if it is getting too long. */ + if (processed || (lcd_escape_len >= LCD_ESCAPE_LEN)) + lcd_escape_len = -1; + } /* escape codes */ +} + static ssize_t lcd_write(struct file *file, - const char *buf, size_t count, loff_t *ppos) + const char __user *buf, size_t count, loff_t *ppos) { - const char *tmp = buf; + const char __user *tmp = buf; char c; - for (; count-- > 0; (ppos ? (*ppos)++ : 0), ++tmp) { + for (; count-- > 0; (*ppos)++, tmp++) { if (!in_interrupt() && (((count + 1) & 0x1f) == 0)) /* let's be a little nice with other processes that need some CPU */ schedule(); - if (ppos == NULL && file == NULL) - /* let's not use get_user() from the kernel ! */ - c = *tmp; - else if (get_user(c, tmp)) + if (get_user(c, buf)) return -EFAULT; - /* first, we'll test if we're in escape mode */ - if ((c != '\n') && lcd_escape_len >= 0) { - /* yes, let's add this char to the buffer */ - lcd_escape[lcd_escape_len++] = c; - lcd_escape[lcd_escape_len] = 0; - } else { - /* aborts any previous escape sequence */ - lcd_escape_len = -1; - - switch (c) { - case LCD_ESCAPE_CHAR: - /* start of an escape sequence */ - lcd_escape_len = 0; - lcd_escape[lcd_escape_len] = 0; - break; - case '\b': - /* go back one char and clear it */ - if (lcd_addr_x > 0) { - /* check if we're not at the - end of the line */ - if (lcd_addr_x < lcd_bwidth) - /* back one char */ - lcd_write_cmd(0x10); - lcd_addr_x--; - } - /* replace with a space */ - lcd_write_data(' '); - /* back one char again */ - lcd_write_cmd(0x10); - break; - case '\014': - /* quickly clear the display */ - lcd_clear_fast(); - break; - case '\n': - /* flush the remainder of the current line and - go to the beginning of the next line */ - for (; lcd_addr_x < lcd_bwidth; lcd_addr_x++) - lcd_write_data(' '); - lcd_addr_x = 0; - lcd_addr_y = (lcd_addr_y + 1) % lcd_height; - lcd_gotoxy(); - break; - case '\r': - /* go to the beginning of the same line */ - lcd_addr_x = 0; - lcd_gotoxy(); - break; - case '\t': - /* print a space instead of the tab */ - lcd_print(' '); - break; - default: - /* simply print this char */ - lcd_print(c); - break; - } - } - - /* now we'll see if we're in an escape mode and if the current - escape sequence can be understood. */ - if (lcd_escape_len >= 2) { - int processed = 0; - - if (!strcmp(lcd_escape, "[2J")) { - /* clear the display */ - lcd_clear_fast(); - processed = 1; - } else if (!strcmp(lcd_escape, "[H")) { - /* cursor to home */ - lcd_addr_x = lcd_addr_y = 0; - lcd_gotoxy(); - processed = 1; - } - /* codes starting with ^[[L */ - else if ((lcd_escape_len >= 3) && - (lcd_escape[0] == '[') && - (lcd_escape[1] == 'L')) { - processed = handle_lcd_special_code(); - } - - /* LCD special escape codes */ - /* flush the escape sequence if it's been processed - or if it is getting too long. */ - if (processed || (lcd_escape_len >= LCD_ESCAPE_LEN)) - lcd_escape_len = -1; - } /* escape codes */ + lcd_write_char(c); } return tmp - buf; @@ -1365,8 +1367,19 @@ static struct miscdevice lcd_dev = { /* public function usable from the kernel for any purpose */ static void panel_lcd_print(const char *s) { - if (lcd_enabled && lcd_initialized) - lcd_write(NULL, s, strlen(s), NULL); + const char *tmp = s; + int count = strlen(s); + + if (lcd_enabled && lcd_initialized) { + for (; count-- > 0; tmp++) { + if (!in_interrupt() && (((count + 1) & 0x1f) == 0)) + /* let's be a little nice with other processes + that need some CPU */ + schedule(); + + lcd_write_char(*tmp); + } + } } /* initialize the LCD driver */ -- cgit v1.2.3 From cce75f412fa39c71debfbdb1aa20673c4c04396e Mon Sep 17 00:00:00 2001 From: Bastien Armand Date: Fri, 18 Apr 2014 18:10:08 +0200 Subject: staging: panel: fix sparse warnings in keypad_read This patch fixes two sparse warnings related to keypad_read : warning: incorrect type in argument 1 (different address spaces) warning: incorrect type in initializer (incompatible argument 2 (different address spaces)) Signed-off-by: Bastien Armand Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index e2e3c6bc3a6c..a5087cbfdef4 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -1584,11 +1584,11 @@ static void lcd_init(void) */ static ssize_t keypad_read(struct file *file, - char *buf, size_t count, loff_t *ppos) + char __user *buf, size_t count, loff_t *ppos) { unsigned i = *ppos; - char *tmp = buf; + char __user *tmp = buf; if (keypad_buflen == 0) { if (file->f_flags & O_NONBLOCK) -- cgit v1.2.3 From c3ed0afc621f3eaa27519d083efb7c2304fd89a6 Mon Sep 17 00:00:00 2001 From: Bastien Armand Date: Fri, 4 Apr 2014 21:45:07 +0200 Subject: staging: panel: add blank lines after declarations This patch fixes "Missing a blank line after declarations" checkpatch warnings in panel.c. Signed-off-by: Bastien Armand Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index a5087cbfdef4..136671a50d6e 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -867,6 +867,7 @@ static void lcd_print(char c) static void lcd_clear_fast_s(void) { int pos; + lcd_addr_x = lcd_addr_y = 0; lcd_gotoxy(); @@ -887,6 +888,7 @@ static void lcd_clear_fast_s(void) static void lcd_clear_fast_p8(void) { int pos; + lcd_addr_x = lcd_addr_y = 0; lcd_gotoxy(); @@ -922,6 +924,7 @@ static void lcd_clear_fast_p8(void) static void lcd_clear_fast_tilcd(void) { int pos; + lcd_addr_x = lcd_addr_y = 0; lcd_gotoxy(); @@ -1092,6 +1095,7 @@ static inline int handle_lcd_special_code(void) break; case 'k': { /* kill end of line */ int x; + for (x = lcd_addr_x; x < lcd_bwidth; x++) lcd_write_data(' '); @@ -1760,16 +1764,20 @@ static inline int input_state_high(struct logical_input *input) if (input->high_timer == 0) { char *press_str = input->u.kbd.press_str; + if (press_str[0]) { int s = sizeof(input->u.kbd.press_str); + keypad_send_key(press_str, s); } } if (input->u.kbd.repeat_str[0]) { char *repeat_str = input->u.kbd.repeat_str; + if (input->high_timer >= KEYPAD_REP_START) { int s = sizeof(input->u.kbd.repeat_str); + input->high_timer -= KEYPAD_REP_DELAY; keypad_send_key(repeat_str, s); } @@ -1807,8 +1815,10 @@ static inline void input_state_falling(struct logical_input *input) if (input->u.kbd.repeat_str[0]) { char *repeat_str = input->u.kbd.repeat_str; + if (input->high_timer >= KEYPAD_REP_START) { int s = sizeof(input->u.kbd.repeat_str); + input->high_timer -= KEYPAD_REP_DELAY; keypad_send_key(repeat_str, s); } @@ -1824,12 +1834,15 @@ static inline void input_state_falling(struct logical_input *input) /* call release event */ if (input->type == INPUT_TYPE_STD) { void (*release_fct)(int) = input->u.std.release_fct; + if (release_fct != NULL) release_fct(input->u.std.release_data); } else if (input->type == INPUT_TYPE_KBD) { char *release_str = input->u.kbd.release_str; + if (release_str[0]) { int s = sizeof(input->u.kbd.release_str); + keypad_send_key(release_str, s); } } @@ -1946,6 +1959,7 @@ static int input_name2mask(const char *name, pmask_t *mask, pmask_t *value, om = im = m = v = 0ULL; while (*name) { int in, out, bit, neg; + for (in = 0; (in < sizeof(sigtab)) && (sigtab[in] != *name); in++) ; @@ -2053,6 +2067,7 @@ static struct logical_input *panel_bind_callback(char *name, static void keypad_init(void) { int keynum; + init_waitqueue_head(&keypad_read_wait); keypad_buflen = 0; /* flushes any eventual noisy keystroke */ -- cgit v1.2.3 From 938acb99ce6c8883075c4c6e64409dd765bdb9e9 Mon Sep 17 00:00:00 2001 From: Bojan Prtvar Date: Thu, 3 Apr 2014 00:24:10 +0200 Subject: staging: vme: Fix a small coding style issue in vme_user.c The checkpatch.pl complains about missing blank line after declaration. This patch silence the warning. Signed-off-by: Bojan Prtvar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vme/devices/vme_user.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c index 792792715673..481192a2f4e2 100644 --- a/drivers/staging/vme/devices/vme_user.c +++ b/drivers/staging/vme/devices/vme_user.c @@ -791,6 +791,7 @@ static int vme_user_probe(struct vme_dev *vdev) /* Add sysfs Entries */ for (i = 0; i < VME_DEVS; i++) { int num; + switch (type[i]) { case MASTER_MINOR: sprintf(name, "bus/vme/m%%d"); -- cgit v1.2.3 From f1552cbdc7d3cb42f3c9e88b2ad6cd5bfe90881a Mon Sep 17 00:00:00 2001 From: Bojan Prtvar Date: Thu, 3 Apr 2014 18:56:10 +0200 Subject: staging: vme: Simplfy string usage in vme_user_probe() We can avoid usage of sprintf() and magic-sized array with simple pointer assignment. Signed-off-by: Bojan Prtvar Reviewed-by: wharms Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vme/devices/vme_user.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c index 481192a2f4e2..5fa7f831dabd 100644 --- a/drivers/staging/vme/devices/vme_user.c +++ b/drivers/staging/vme/devices/vme_user.c @@ -684,7 +684,7 @@ static int vme_user_match(struct vme_dev *vdev) static int vme_user_probe(struct vme_dev *vdev) { int i, err; - char name[12]; + char *name; /* Save pointer to the bridge device */ if (vme_user_bridge != NULL) { @@ -794,13 +794,13 @@ static int vme_user_probe(struct vme_dev *vdev) switch (type[i]) { case MASTER_MINOR: - sprintf(name, "bus/vme/m%%d"); + name = "bus/vme/m%d"; break; case CONTROL_MINOR: - sprintf(name, "bus/vme/ctl"); + name = "bus/vme/ctl"; break; case SLAVE_MINOR: - sprintf(name, "bus/vme/s%%d"); + name = "bus/vme/s%d"; break; default: err = -EINVAL; -- cgit v1.2.3 From 776ed179769d9e51c92cd480a00eee9800949b7f Mon Sep 17 00:00:00 2001 From: Pascal COMBES Date: Tue, 15 Apr 2014 21:21:07 +0200 Subject: Staging: crystalhd: Fix alignement in crystalhd_lnx.c Signed-off-by: Pascal COMBES Signed-off-by: Greg Kroah-Hartman --- drivers/staging/crystalhd/crystalhd_lnx.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/staging/crystalhd/crystalhd_lnx.c b/drivers/staging/crystalhd/crystalhd_lnx.c index 20be9571990a..fd7f08abbbdf 100644 --- a/drivers/staging/crystalhd/crystalhd_lnx.c +++ b/drivers/staging/crystalhd/crystalhd_lnx.c @@ -112,7 +112,7 @@ static void chd_dec_free_iodata(struct crystalhd_adp *adp, } static inline int crystalhd_user_data(void __user *ud, void *dr, - int size, int set) + int size, int set) { int rc; @@ -135,7 +135,8 @@ static inline int crystalhd_user_data(void __user *ud, void *dr, } static int chd_dec_fetch_cdata(struct crystalhd_adp *adp, - struct crystalhd_ioctl_data *io, uint32_t m_sz, unsigned long ua) + struct crystalhd_ioctl_data *io, uint32_t m_sz, + unsigned long ua) { unsigned long ua_off; int rc = 0; @@ -154,7 +155,7 @@ static int chd_dec_fetch_cdata(struct crystalhd_adp *adp, io->add_cdata_sz = m_sz; ua_off = ua + sizeof(io->udata); rc = crystalhd_user_data((void __user *)ua_off, io->add_cdata, - io->add_cdata_sz, 0); + io->add_cdata_sz, 0); if (rc) { BCMLOG_ERR("failed to pull add_cdata sz:%x ua_off:%x\n", io->add_cdata_sz, (unsigned int)ua_off); @@ -167,7 +168,8 @@ static int chd_dec_fetch_cdata(struct crystalhd_adp *adp, } static int chd_dec_release_cdata(struct crystalhd_adp *adp, - struct crystalhd_ioctl_data *io, unsigned long ua) + struct crystalhd_ioctl_data *io, + unsigned long ua) { unsigned long ua_off; int rc; @@ -180,7 +182,7 @@ static int chd_dec_release_cdata(struct crystalhd_adp *adp, if (io->cmd != BCM_IOC_FW_DOWNLOAD) { ua_off = ua + sizeof(io->udata); rc = crystalhd_user_data((void __user *)ua_off, io->add_cdata, - io->add_cdata_sz, 1); + io->add_cdata_sz, 1); if (rc) { BCMLOG_ERR( "failed to push add_cdata sz:%x ua_off:%x\n", @@ -210,7 +212,7 @@ static int chd_dec_proc_user_data(struct crystalhd_adp *adp, } rc = crystalhd_user_data((void __user *)ua, &io->udata, - sizeof(io->udata), set); + sizeof(io->udata), set); if (rc) { BCMLOG_ERR("failed to %s iodata\n", (set ? "set" : "get")); return rc; @@ -382,7 +384,7 @@ static int chd_dec_init_chdev(struct crystalhd_adp *adp) } dev = device_create(crystalhd_class, NULL, - MKDEV(adp->chd_dec_major, 0), NULL, "crystalhd"); + MKDEV(adp->chd_dec_major, 0), NULL, "crystalhd"); if (IS_ERR(dev)) { rc = PTR_ERR(dev); BCMLOG_ERR("failed to create device\n"); @@ -398,7 +400,7 @@ static int chd_dec_init_chdev(struct crystalhd_adp *adp) /* Allocate general purpose ioctl pool. */ for (i = 0; i < CHD_IODATA_POOL_SZ; i++) { temp = kzalloc(sizeof(struct crystalhd_ioctl_data), - GFP_KERNEL); + GFP_KERNEL); if (!temp) { BCMLOG_ERR("ioctl data pool kzalloc failed\n"); rc = -ENOMEM; @@ -549,9 +551,9 @@ static int chd_dec_pci_probe(struct pci_dev *pdev, enum BC_STATUS sts = BC_STS_SUCCESS; BCMLOG(BCMLOG_DBG, - "PCI_INFO: Vendor:0x%04x Device:0x%04x s_vendor:0x%04x s_device: 0x%04x\n", - pdev->vendor, pdev->device, pdev->subsystem_vendor, - pdev->subsystem_device); + "PCI_INFO: Vendor:0x%04x Device:0x%04x s_vendor:0x%04x s_device: 0x%04x\n", + pdev->vendor, pdev->device, pdev->subsystem_vendor, + pdev->subsystem_device); pinfo = kzalloc(sizeof(struct crystalhd_adp), GFP_KERNEL); if (!pinfo) { -- cgit v1.2.3 From 9744f06bf2ecfa34ec2a1575b32d06723934c653 Mon Sep 17 00:00:00 2001 From: Pascal COMBES Date: Tue, 15 Apr 2014 21:21:18 +0200 Subject: Staging: crystalhd: Removed cast in crystalhd_lnx.c Removed useless (because automatic) cast from void * in crystalhd_lnx.c Signed-off-by: Pascal COMBES Signed-off-by: Greg Kroah-Hartman --- drivers/staging/crystalhd/crystalhd_lnx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/crystalhd/crystalhd_lnx.c b/drivers/staging/crystalhd/crystalhd_lnx.c index fd7f08abbbdf..0e432bcf7c13 100644 --- a/drivers/staging/crystalhd/crystalhd_lnx.c +++ b/drivers/staging/crystalhd/crystalhd_lnx.c @@ -28,7 +28,7 @@ static struct crystalhd_adp *g_adp_info; static irqreturn_t chd_dec_isr(int irq, void *arg) { - struct crystalhd_adp *adp = (struct crystalhd_adp *) arg; + struct crystalhd_adp *adp = arg; int rc = 0; if (adp) rc = crystalhd_cmd_interrupt(&adp->cmds); -- cgit v1.2.3 From b8dd8654d9162e90c4179698f42e6edfec30dc1d Mon Sep 17 00:00:00 2001 From: Pascal COMBES Date: Tue, 15 Apr 2014 21:21:37 +0200 Subject: Staging: crystalhd: Improve kzalloc calls in crystalhd_lnx.c Replace sizeof(type) by sizeof(variable) in crystalhd_lnx.c. Signed-off-by: Pascal COMBES Signed-off-by: Greg Kroah-Hartman --- drivers/staging/crystalhd/crystalhd_lnx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/crystalhd/crystalhd_lnx.c b/drivers/staging/crystalhd/crystalhd_lnx.c index 0e432bcf7c13..e6fb331c6735 100644 --- a/drivers/staging/crystalhd/crystalhd_lnx.c +++ b/drivers/staging/crystalhd/crystalhd_lnx.c @@ -399,8 +399,7 @@ static int chd_dec_init_chdev(struct crystalhd_adp *adp) /* Allocate general purpose ioctl pool. */ for (i = 0; i < CHD_IODATA_POOL_SZ; i++) { - temp = kzalloc(sizeof(struct crystalhd_ioctl_data), - GFP_KERNEL); + temp = kzalloc(sizeof(*temp), GFP_KERNEL); if (!temp) { BCMLOG_ERR("ioctl data pool kzalloc failed\n"); rc = -ENOMEM; @@ -555,7 +554,7 @@ static int chd_dec_pci_probe(struct pci_dev *pdev, pdev->vendor, pdev->device, pdev->subsystem_vendor, pdev->subsystem_device); - pinfo = kzalloc(sizeof(struct crystalhd_adp), GFP_KERNEL); + pinfo = kzalloc(sizeof(*pinfo), GFP_KERNEL); if (!pinfo) { BCMLOG_ERR("Failed to allocate memory\n"); return -ENOMEM; -- cgit v1.2.3 From e347fa5f4271769bc31fb462631c213aa3824588 Mon Sep 17 00:00:00 2001 From: "Marcos A. Di Pietro" Date: Thu, 17 Apr 2014 08:12:17 -0400 Subject: Staging:bcm: Fixes coding style issues in drivers/staging/bcm/Qos.c Fixes code style errors in drivers/staging/bcm/Qos.c Signed-off-by: Marcos A. Di Pietro Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Qos.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/staging/bcm/Qos.c b/drivers/staging/bcm/Qos.c index 09e548aef812..64ae92b13160 100644 --- a/drivers/staging/bcm/Qos.c +++ b/drivers/staging/bcm/Qos.c @@ -4,11 +4,18 @@ This file contains the routines related to Quality of Service. */ #include "headers.h" -static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter, PVOID pvEthPayload, struct bcm_eth_packet_info *pstEthCsPktInfo); -static bool EThCSClassifyPkt(struct bcm_mini_adapter *Adapter, struct sk_buff* skb, struct bcm_eth_packet_info *pstEthCsPktInfo, struct bcm_classifier_rule *pstClassifierRule, B_UINT8 EthCSCupport); - -static USHORT IpVersion4(struct bcm_mini_adapter *Adapter, struct iphdr *iphd, - struct bcm_classifier_rule *pstClassifierRule); +static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter, + PVOID pvEthPayload, + struct bcm_eth_packet_info *pstEthCsPktInfo); + +static bool EThCSClassifyPkt(struct bcm_mini_adapter *Adapter, + struct sk_buff *skb, + struct bcm_eth_packet_info *pstEthCsPktInfo, + struct bcm_classifier_rule *pstClassifierRule, + B_UINT8 EthCSCupport); + +static USHORT IpVersion4(struct bcm_mini_adapter *Adapter, struct iphdr *iphd, + struct bcm_classifier_rule *pstClassifierRule); static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex); -- cgit v1.2.3 From c9b1420c397314a4855af70aadb79450d1bd6fe0 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Tue, 15 Apr 2014 00:53:55 -0500 Subject: staging: comedi: addi_apci_1564: remove use of devpriv->iobase devpriv->iobase is currently being used to hold the iobase address used to read/write the board's registers. The same address is stored in the comedi_device dev->iobase. We use that instead. The eventual goal is to decrease the driver's use of the struct addi_private, so that it may eventually use a much slimmer specialized private struct instead, as the other addi_apci_* drivers do. Signed-off-by: Chase Southwood Reviewed-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci1564.c | 79 +++++++++++----------- 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c index 9c86b02eb6da..4db3bea4e20a 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c @@ -76,7 +76,7 @@ #define APCI1564_TIMER_WARN_TIMEBASE_REG 0x64 /* - * devpriv->iobase Register Map + * dev>iobase Register Map */ #define APCI1564_TCW_REG(x) (0x00 + ((x) * 0x20)) #define APCI1564_TCW_RELOAD_REG(x) (0x04 + ((x) * 0x20)) @@ -239,13 +239,13 @@ static int apci1564_timer_config(struct comedi_device *dev, outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DO_IRQ_REG); outl(0x0, devpriv->i_IobaseAmcc + APCI1564_WDOG_IRQ_REG); outl(0x0, - devpriv->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER1)); + dev->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER1)); outl(0x0, - devpriv->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER2)); + dev->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER2)); outl(0x0, - devpriv->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER3)); + dev->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER3)); outl(0x0, - devpriv->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER4)); + dev->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER4)); } else { /* disable Timer interrupt */ outl(0x0, devpriv->i_IobaseAmcc + APCI1564_TIMER_CTRL_REG); @@ -266,13 +266,13 @@ static int apci1564_timer_config(struct comedi_device *dev, devpriv->b_ModeSelectRegister = data[5]; /* First Stop The Counter */ - ul_Command1 = inl(devpriv->iobase + APCI1564_TCW_CTRL_REG(data[5] - 1)); + ul_Command1 = inl(dev->iobase + APCI1564_TCW_CTRL_REG(data[5] - 1)); ul_Command1 = ul_Command1 & 0xFFFFF9FEUL; /* Stop The Timer */ - outl(ul_Command1, devpriv->iobase + APCI1564_TCW_CTRL_REG(data[5] - 1)); + outl(ul_Command1, dev->iobase + APCI1564_TCW_CTRL_REG(data[5] - 1)); /* Set the reload value */ - outl(data[3], devpriv->iobase + APCI1564_TCW_RELOAD_REG(data[5] - 1)); + outl(data[3], dev->iobase + APCI1564_TCW_RELOAD_REG(data[5] - 1)); /* Set the mode : */ /* - Disable the hardware */ @@ -285,15 +285,15 @@ static int apci1564_timer_config(struct comedi_device *dev, ul_Command1 = (ul_Command1 & 0xFFFC19E2UL) | 0x80000UL | (unsigned int) ((unsigned int) data[4] << 16UL); - outl(ul_Command1, devpriv->iobase + APCI1564_TCW_CTRL_REG(data[5] - 1)); + outl(ul_Command1, dev->iobase + APCI1564_TCW_CTRL_REG(data[5] - 1)); /* Enable or Disable Interrupt */ ul_Command1 = (ul_Command1 & 0xFFFFF9FD) | (data[1] << 1); - outl(ul_Command1, devpriv->iobase + APCI1564_TCW_CTRL_REG(data[5] - 1)); + outl(ul_Command1, dev->iobase + APCI1564_TCW_CTRL_REG(data[5] - 1)); /* Set the Up/Down selection */ ul_Command1 = (ul_Command1 & 0xFFFBF9FFUL) | (data[6] << 18); - outl(ul_Command1, devpriv->iobase + APCI1564_TCW_CTRL_REG(data[5] - 1)); + outl(ul_Command1, dev->iobase + APCI1564_TCW_CTRL_REG(data[5] - 1)); } else { dev_err(dev->class_dev, "Invalid subdevice.\n"); } @@ -349,8 +349,8 @@ static int apci1564_timer_write(struct comedi_device *dev, } if (devpriv->b_TimerSelectMode == ADDIDATA_COUNTER) { ul_Command1 = - inl(devpriv->iobase + - APCI1564_TCW_CTRL_REG(devpriv->b_ModeSelectRegister - 1)); + inl(dev->iobase + + APCI1564_TCW_CTRL_REG(devpriv->b_ModeSelectRegister - 1)); if (data[1] == 1) { /* Start the Counter subdevice */ ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x1UL; @@ -362,9 +362,8 @@ static int apci1564_timer_write(struct comedi_device *dev, /* Clears the Counter subdevice */ ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x400; } - outl(ul_Command1, - devpriv->iobase + - APCI1564_TCW_CTRL_REG(devpriv->b_ModeSelectRegister - 1)); + outl(ul_Command1, dev->iobase + + APCI1564_TCW_CTRL_REG(devpriv->b_ModeSelectRegister - 1)); } return insn->n; } @@ -393,11 +392,11 @@ static int apci1564_timer_read(struct comedi_device *dev, } else if (devpriv->b_TimerSelectMode == ADDIDATA_COUNTER) { /* Read the Counter Actual Value. */ data[0] = - inl(devpriv->iobase + - APCI1564_TCW_REG(devpriv->b_ModeSelectRegister - 1)); + inl(dev->iobase + + APCI1564_TCW_REG(devpriv->b_ModeSelectRegister - 1)); ul_Command1 = - inl(devpriv->iobase + - APCI1564_TCW_STATUS_REG(devpriv->b_ModeSelectRegister - 1)); + inl(dev->iobase + + APCI1564_TCW_STATUS_REG(devpriv->b_ModeSelectRegister - 1)); /* Get the software trigger status */ data[1] = (unsigned char) ((ul_Command1 >> 1) & 1); @@ -446,13 +445,13 @@ static void apci1564_interrupt(int irq, void *d) ui_DO = inl(devpriv->i_IobaseAmcc + APCI1564_DO_IRQ_REG) & 0x01; ui_Timer = inl(devpriv->i_IobaseAmcc + APCI1564_TIMER_IRQ_REG) & 0x01; ui_C1 = - inl(devpriv->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER1)) & 0x1; + inl(dev->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER1)) & 0x1; ui_C2 = - inl(devpriv->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER2)) & 0x1; + inl(dev->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER2)) & 0x1; ui_C3 = - inl(devpriv->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER3)) & 0x1; + inl(dev->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER3)) & 0x1; ui_C4 = - inl(devpriv->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER4)) & 0x1; + inl(dev->iobase + APCI1564_TCW_IRQ_REG(APCI1564_COUNTER4)) & 0x1; if (ui_DI == 0 && ui_DO == 0 && ui_Timer == 0 && ui_C1 == 0 && ui_C2 == 0 && ui_C3 == 0 && ui_C4 == 0) { dev_err(dev->class_dev, "Interrupt from unknown source.\n"); @@ -506,16 +505,16 @@ static void apci1564_interrupt(int irq, void *d) /* Disable Counter Interrupt */ ul_Command2 = - inl(devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER1)); + inl(dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER1)); outl(0x0, - devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER1)); + dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER1)); /* Send a signal to from kernel to user space */ send_sig(SIGIO, devpriv->tsk_Current, 0); /* Enable Counter Interrupt */ outl(ul_Command2, - devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER1)); + dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER1)); } } @@ -525,16 +524,16 @@ static void apci1564_interrupt(int irq, void *d) /* Disable Counter Interrupt */ ul_Command2 = - inl(devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER2)); + inl(dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER2)); outl(0x0, - devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER2)); + dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER2)); /* Send a signal to from kernel to user space */ send_sig(SIGIO, devpriv->tsk_Current, 0); /* Enable Counter Interrupt */ outl(ul_Command2, - devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER2)); + dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER2)); } } @@ -544,16 +543,16 @@ static void apci1564_interrupt(int irq, void *d) /* Disable Counter Interrupt */ ul_Command2 = - inl(devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER3)); + inl(dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER3)); outl(0x0, - devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER3)); + dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER3)); /* Send a signal to from kernel to user space */ send_sig(SIGIO, devpriv->tsk_Current, 0); /* Enable Counter Interrupt */ outl(ul_Command2, - devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER3)); + dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER3)); } } @@ -563,16 +562,16 @@ static void apci1564_interrupt(int irq, void *d) /* Disable Counter Interrupt */ ul_Command2 = - inl(devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER4)); + inl(dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER4)); outl(0x0, - devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER4)); + dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER4)); /* Send a signal to from kernel to user space */ send_sig(SIGIO, devpriv->tsk_Current, 0); /* Enable Counter Interrupt */ outl(ul_Command2, - devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER4)); + dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER4)); } } return; @@ -599,9 +598,9 @@ static int apci1564_reset(struct comedi_device *dev) outl(0x0, devpriv->i_IobaseAmcc + APCI1564_TIMER_REG); outl(0x0, devpriv->i_IobaseAmcc + APCI1564_TIMER_CTRL_REG); - outl(0x0, devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER1)); - outl(0x0, devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER2)); - outl(0x0, devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER3)); - outl(0x0, devpriv->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER4)); + outl(0x0, dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER1)); + outl(0x0, dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER2)); + outl(0x0, dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER3)); + outl(0x0, dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER4)); return 0; } -- cgit v1.2.3 From 8802cd842db76d29dd24bbe555f82b478b0fd469 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 16 Apr 2014 14:19:07 -0700 Subject: staging: comedi: adl_pci9111: factor out chanlist checking from (*do_cmdtest) Step 5 of the (*do_cmdtest) validates that the cmd->chanlist is compatible with the hardware. For aesthetics, factor out the step 5 code for the analog input async command support. Tidy up the factored out code. To minimize the noise, change the comedi_err(), which is a wrapper around dev_err(), to dev_dbg(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9111.c | 68 ++++++++++++++++------------ 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index a29ceacb966d..575af7444716 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -314,6 +314,41 @@ static int pci9111_ai_cancel(struct comedi_device *dev, return 0; } +static int pci9111_ai_check_chanlist(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) +{ + unsigned int range0 = CR_RANGE(cmd->chanlist[0]); + unsigned int aref0 = CR_AREF(cmd->chanlist[0]); + int i; + + for (i = 1; i < cmd->chanlist_len; i++) { + unsigned int chan = CR_CHAN(cmd->chanlist[i]); + unsigned int range = CR_RANGE(cmd->chanlist[i]); + unsigned int aref = CR_AREF(cmd->chanlist[i]); + + if (chan != i) { + dev_dbg(dev->class_dev, + "entries in chanlist must be consecutive channels,counting upwards from 0\n"); + return -EINVAL; + } + + if (range != range0) { + dev_dbg(dev->class_dev, + "entries in chanlist must all have the same gain\n"); + return -EINVAL; + } + + if (aref != aref0) { + dev_dbg(dev->class_dev, + "entries in chanlist must all have the same reference\n"); + return -EINVAL; + } + } + + return 0; +} + static int pci9111_ai_do_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) @@ -321,8 +356,6 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev, struct pci9111_private_data *dev_private = dev->private; int tmp; int error = 0; - int range, reference; - int i; /* Step 1 : check if triggers are trivially valid */ @@ -426,34 +459,9 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev, if (error) return 4; - /* Step 5 : check channel list */ - - if (cmd->chanlist) { - - range = CR_RANGE(cmd->chanlist[0]); - reference = CR_AREF(cmd->chanlist[0]); - - if (cmd->chanlist_len > 1) { - for (i = 0; i < cmd->chanlist_len; i++) { - if (CR_CHAN(cmd->chanlist[i]) != i) { - comedi_error(dev, - "entries in chanlist must be consecutive " - "channels,counting upwards from 0\n"); - error++; - } - if (CR_RANGE(cmd->chanlist[i]) != range) { - comedi_error(dev, - "entries in chanlist must all have the same gain\n"); - error++; - } - if (CR_AREF(cmd->chanlist[i]) != reference) { - comedi_error(dev, - "entries in chanlist must all have the same reference\n"); - error++; - } - } - } - } + /* Step 5: check channel list if it exists */ + if (cmd->chanlist && cmd->chanlist_len > 0) + error |= pci9111_ai_check_chanlist(dev, s, cmd); if (error) return 5; -- cgit v1.2.3 From febb63b6a43008621fa3465bee2a715ac6dd2b09 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 16 Apr 2014 14:19:08 -0700 Subject: staging: comedi: amplc_pci224: factor out chanlist checking from (*do_cmdtest) Step 5 of the (*do_cmdtest) validates that the cmd->chanlist is compatible with the hardware. For aesthetics, factor the step 5 code for the analog output async command support. Tidy up the factored out code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci224.c | 76 ++++++++++++--------------- 1 file changed, 34 insertions(+), 42 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index 29e01e280039..e99829e58635 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -687,6 +687,37 @@ pci224_ao_inttrig_start(struct comedi_device *dev, struct comedi_subdevice *s, return 1; } +static int pci224_ao_check_chanlist(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) +{ + unsigned int range0 = CR_RANGE(cmd->chanlist[0]); + unsigned int chan_mask = 0; + int i; + + for (i = 0; i < cmd->chanlist_len; i++) { + unsigned int chan = CR_CHAN(cmd->chanlist[i]); + unsigned int range = CR_RANGE(cmd->chanlist[i]); + + if (chan_mask & (1 << chan)) { + dev_dbg(dev->class_dev, + "%s: entries in chanlist must contain no duplicate channels\n", + __func__); + return -EINVAL; + } + chan_mask |= (1 << chan); + + if (range != range0) { + dev_dbg(dev->class_dev, + "%s: entries in chanlist must all have the same range index\n", + __func__); + return -EINVAL; + } + } + + return 0; +} + #define MAX_SCAN_PERIOD 0xFFFFFFFFU #define MIN_SCAN_PERIOD 2500 #define CONVERT_PERIOD 625 @@ -871,48 +902,9 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, if (err) return 4; - /* Step 5: check channel list. */ - - if (cmd->chanlist && (cmd->chanlist_len > 0)) { - unsigned int range; - enum { range_err = 1, dupchan_err = 2, }; - unsigned errors; - unsigned int n; - unsigned int ch; - - /* - * Check all channels have the same range index. Don't care - * about analogue reference, as we can't configure it. - * - * Check the list has no duplicate channels. - */ - range = CR_RANGE(cmd->chanlist[0]); - errors = 0; - tmp = 0; - for (n = 0; n < cmd->chanlist_len; n++) { - ch = CR_CHAN(cmd->chanlist[n]); - if (tmp & (1U << ch)) - errors |= dupchan_err; - - tmp |= (1U << ch); - if (CR_RANGE(cmd->chanlist[n]) != range) - errors |= range_err; - - } - if (errors) { - if (errors & dupchan_err) { - dev_dbg(dev->class_dev, - "%s: entries in chanlist must contain no duplicate channels\n", - __func__); - } - if (errors & range_err) { - dev_dbg(dev->class_dev, - "%s: entries in chanlist must all have the same range index\n", - __func__); - } - err++; - } - } + /* Step 5: check channel list if it exists */ + if (cmd->chanlist && cmd->chanlist_len > 0) + err |= pci224_ao_check_chanlist(dev, s, cmd); if (err) return 5; -- cgit v1.2.3 From e39a9704687efef22810c68defa9a4410dbd74c9 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 16 Apr 2014 14:19:09 -0700 Subject: staging: comedi: amplc_pci230: factor out chanlist checking from (*do_cmdtest) Step 5 of the (*do_cmdtest) validates that the cmd->chanlist is compatible with the hardware. For aesthetics, factor out the step 5 code for the analog output and analog input async command support. Tidy up the factored out code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci230.c | 313 ++++++++++++-------------- 1 file changed, 141 insertions(+), 172 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 99e60835dc4a..7149f471f542 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -953,6 +953,38 @@ static int pci230_ao_rinsn(struct comedi_device *dev, return i; } +static int pci230_ao_check_chanlist(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) +{ + unsigned int prev_chan = CR_CHAN(cmd->chanlist[0]); + unsigned int range0 = CR_RANGE(cmd->chanlist[0]); + int i; + + for (i = 1; i < cmd->chanlist_len; i++) { + unsigned int chan = CR_CHAN(cmd->chanlist[i]); + unsigned int range = CR_RANGE(cmd->chanlist[i]); + + if (chan < prev_chan) { + dev_dbg(dev->class_dev, + "%s: channel numbers must increase\n", + __func__); + return -EINVAL; + } + + if (range != range0) { + dev_dbg(dev->class_dev, + "%s: channels must have the same range\n", + __func__); + return -EINVAL; + } + + prev_chan = chan; + } + + return 0; +} + static int pci230_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { @@ -1065,48 +1097,9 @@ static int pci230_ao_cmdtest(struct comedi_device *dev, if (err) return 4; - /* Step 5: check channel list if it exists. */ - - if (cmd->chanlist && cmd->chanlist_len > 0) { - enum { - seq_err = (1 << 0), - range_err = (1 << 1) - }; - unsigned int errors; - unsigned int n; - unsigned int chan, prev_chan; - unsigned int range, first_range; - - prev_chan = CR_CHAN(cmd->chanlist[0]); - first_range = CR_RANGE(cmd->chanlist[0]); - errors = 0; - for (n = 1; n < cmd->chanlist_len; n++) { - chan = CR_CHAN(cmd->chanlist[n]); - range = CR_RANGE(cmd->chanlist[n]); - /* Channel numbers must strictly increase. */ - if (chan < prev_chan) - errors |= seq_err; - - /* Ranges must be the same. */ - if (range != first_range) - errors |= range_err; - - prev_chan = chan; - } - if (errors != 0) { - err++; - if ((errors & seq_err) != 0) { - dev_dbg(dev->class_dev, - "%s: channel numbers must increase\n", - __func__); - } - if ((errors & range_err) != 0) { - dev_dbg(dev->class_dev, - "%s: channels must have the same range\n", - __func__); - } - } - } + /* Step 5: check channel list if it exists */ + if (cmd->chanlist && cmd->chanlist_len > 0) + err |= pci230_ao_check_chanlist(dev, s, cmd); if (err) return 5; @@ -1552,6 +1545,109 @@ static int pci230_ai_check_scan_period(struct comedi_cmd *cmd) return !err; } +static int pci230_ai_check_chanlist(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) +{ + struct pci230_private *devpriv = dev->private; + unsigned int max_diff_chan = (s->n_chan / 2) - 1; + unsigned int prev_chan = 0; + unsigned int prev_range = 0; + unsigned int prev_aref = 0; + unsigned int prev_polarity = 0; + unsigned int subseq_len = 0; + int i; + + for (i = 0; i < cmd->chanlist_len; i++) { + unsigned int chanspec = cmd->chanlist[i]; + unsigned int chan = CR_CHAN(chanspec); + unsigned int range = CR_RANGE(chanspec); + unsigned int aref = CR_AREF(chanspec); + unsigned int polarity = pci230_ai_bipolar[range]; + + if (aref == AREF_DIFF && chan >= max_diff_chan) { + dev_dbg(dev->class_dev, + "%s: differential channel number out of range 0 to %u\n", + __func__, max_diff_chan); + return -EINVAL; + } + + if (i > 0) { + /* + * Channel numbers must strictly increase or + * subsequence must repeat exactly. + */ + if (chan <= prev_chan && subseq_len == 0) + subseq_len = i; + + if (subseq_len > 0 && + cmd->chanlist[i % subseq_len] != chanspec) { + dev_dbg(dev->class_dev, + "%s: channel numbers must increase or sequence must repeat exactly\n", + __func__); + return -EINVAL; + } + + if (aref != prev_aref) { + dev_dbg(dev->class_dev, + "%s: channel sequence analogue references must be all the same (single-ended or differential)\n", + __func__); + return -EINVAL; + } + + if (polarity != prev_polarity) { + dev_dbg(dev->class_dev, + "%s: channel sequence ranges must be all bipolar or all unipolar\n", + __func__); + return -EINVAL; + } + + if (aref != AREF_DIFF && range != prev_range && + ((chan ^ prev_chan) & ~1) == 0) { + dev_dbg(dev->class_dev, + "%s: single-ended channel pairs must have the same range\n", + __func__); + return -EINVAL; + } + } + prev_chan = chan; + prev_range = range; + prev_aref = aref; + prev_polarity = polarity; + } + + if (subseq_len == 0) + subseq_len = cmd->chanlist_len; + + if ((cmd->chanlist_len % subseq_len) != 0) { + dev_dbg(dev->class_dev, + "%s: sequence must repeat exactly\n", __func__); + return -EINVAL; + } + + /* + * Buggy PCI230+ or PCI260+ requires channel 0 to be (first) in the + * sequence if the sequence contains more than one channel. Hardware + * versions 1 and 2 have the bug. There is no hardware version 3. + * + * Actually, there are two firmwares that report themselves as + * hardware version 1 (the boards have different ADC chips with + * slightly different timing requirements, which was supposed to + * be invisible to software). The first one doesn't seem to have + * the bug, but the second one does, and we can't tell them apart! + */ + if (devpriv->hwver > 0 && devpriv->hwver < 4) { + if (subseq_len > 1 && CR_CHAN(cmd->chanlist[0]) != 0) { + dev_info(dev->class_dev, + "amplc_pci230: ai_cmdtest: Buggy PCI230+/260+ h/w version %u requires first channel of multi-channel sequence to be 0 (corrected in h/w version 4)\n", + devpriv->hwver); + return -EINVAL; + } + } + + return 0; +} + static int pci230_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { @@ -1740,136 +1836,9 @@ static int pci230_ai_cmdtest(struct comedi_device *dev, if (err) return 4; - /* Step 5: check channel list if it exists. */ - - if (cmd->chanlist && cmd->chanlist_len > 0) { - enum { - seq_err = 1 << 0, - rangepair_err = 1 << 1, - polarity_err = 1 << 2, - aref_err = 1 << 3, - diffchan_err = 1 << 4, - buggy_chan0_err = 1 << 5 - }; - unsigned int errors; - unsigned int chan, prev_chan; - unsigned int range, prev_range; - unsigned int polarity, prev_polarity; - unsigned int aref, prev_aref; - unsigned int subseq_len; - unsigned int n; - - subseq_len = 0; - errors = 0; - prev_chan = prev_aref = prev_range = prev_polarity = 0; - for (n = 0; n < cmd->chanlist_len; n++) { - chan = CR_CHAN(cmd->chanlist[n]); - range = CR_RANGE(cmd->chanlist[n]); - aref = CR_AREF(cmd->chanlist[n]); - polarity = pci230_ai_bipolar[range]; - /* Only the first half of the channels are available if - * differential. (These are remapped in software. In - * hardware, only the even channels are available.) */ - if ((aref == AREF_DIFF) - && (chan >= (s->n_chan / 2))) { - errors |= diffchan_err; - } - if (n > 0) { - /* Channel numbers must strictly increase or - * subsequence must repeat exactly. */ - if ((chan <= prev_chan) - && (subseq_len == 0)) { - subseq_len = n; - } - if ((subseq_len > 0) - && (cmd->chanlist[n] != - cmd->chanlist[n % subseq_len])) { - errors |= seq_err; - } - /* Channels must have same AREF. */ - if (aref != prev_aref) - errors |= aref_err; - - /* Channel ranges must have same polarity. */ - if (polarity != prev_polarity) - errors |= polarity_err; - - /* Single-ended channel pairs must have same - * range. */ - if ((aref != AREF_DIFF) - && (((chan ^ prev_chan) & ~1) == 0) - && (range != prev_range)) { - errors |= rangepair_err; - } - } - prev_chan = chan; - prev_range = range; - prev_aref = aref; - prev_polarity = polarity; - } - if (subseq_len == 0) { - /* Subsequence is whole sequence. */ - subseq_len = n; - } - /* If channel list is a repeating subsequence, need a whole - * number of repeats. */ - if ((n % subseq_len) != 0) - errors |= seq_err; - - if ((devpriv->hwver > 0) && (devpriv->hwver < 4)) { - /* - * Buggy PCI230+ or PCI260+ requires channel 0 to be - * (first) in the sequence if the sequence contains - * more than one channel. Hardware versions 1 and 2 - * have the bug. There is no hardware version 3. - * - * Actually, there are two firmwares that report - * themselves as hardware version 1 (the boards - * have different ADC chips with slightly different - * timing requirements, which was supposed to be - * invisible to software). The first one doesn't - * seem to have the bug, but the second one - * does, and we can't tell them apart! - */ - if ((subseq_len > 1) - && (CR_CHAN(cmd->chanlist[0]) != 0)) { - errors |= buggy_chan0_err; - } - } - if (errors != 0) { - err++; - if ((errors & seq_err) != 0) { - dev_dbg(dev->class_dev, - "%s: channel numbers must increase or sequence must repeat exactly\n", - __func__); - } - if ((errors & rangepair_err) != 0) { - dev_dbg(dev->class_dev, - "%s: single-ended channel pairs must have the same range\n", - __func__); - } - if ((errors & polarity_err) != 0) { - dev_dbg(dev->class_dev, - "%s: channel sequence ranges must be all bipolar or all unipolar\n", - __func__); - } - if ((errors & aref_err) != 0) { - dev_dbg(dev->class_dev, - "%s: channel sequence analogue references must be all the same (single-ended or differential)\n", - __func__); - } - if ((errors & diffchan_err) != 0) { - dev_dbg(dev->class_dev, - "%s: differential channel number out of range 0 to %u\n", - __func__, (s->n_chan / 2) - 1); - } - if ((errors & buggy_chan0_err) != 0) { - dev_info(dev->class_dev, - "amplc_pci230: ai_cmdtest: Buggy PCI230+/260+ h/w version %u requires first channel of multi-channel sequence to be 0 (corrected in h/w version 4)\n", - devpriv->hwver); - } - } - } + /* Step 5: check channel list if it exists */ + if (cmd->chanlist && cmd->chanlist_len > 0) + err |= pci230_ai_check_chanlist(dev, s, cmd); if (err) return 5; -- cgit v1.2.3 From e74592e0c01c6b9dc9c87146b7a894cfcb84d382 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 16 Apr 2014 14:19:10 -0700 Subject: staging: comedi: cb_pcidas: factor out chanlist checking from (*do_cmdtest) Step 5 of the (*do_cmdtest) validates that the cmd->chanlist is compatible with the hardware. For aesthetics, factor out the step 5 code for the analog input and analog output async command support. Tidy up the factored out code. To minimize the noise, change the comedi_error(), which is a wrapper around dev_err(), to dev_dbg(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas.c | 80 +++++++++++++++++++----------- 1 file changed, 52 insertions(+), 28 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index 83a265f3408c..70d926707777 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -803,6 +803,33 @@ static int trimpot_read_insn(struct comedi_device *dev, return 1; } +static int cb_pcidas_ai_check_chanlist(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) +{ + unsigned int chan0 = CR_CHAN(cmd->chanlist[0]); + unsigned int range0 = CR_RANGE(cmd->chanlist[0]); + int i; + + for (i = 1; i < cmd->chanlist_len; i++) { + unsigned int chan = CR_CHAN(cmd->chanlist[i]); + unsigned int range = CR_RANGE(cmd->chanlist[i]); + + if (chan != (chan0 + i) % s->n_chan) { + dev_dbg(dev->class_dev, + "entries in chanlist must be consecutive channels, counting upwards\n"); + return -EINVAL; + } + + if (range != range0) { + dev_dbg(dev->class_dev, + "entries in chanlist must all have the same gain\n"); + return -EINVAL; + } + } + return 0; +} + static int cb_pcidas_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) @@ -811,7 +838,6 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev, struct cb_pcidas_private *devpriv = dev->private; int err = 0; int tmp; - int i, gain, start_chan; /* Step 1 : check if triggers are trivially valid */ @@ -907,24 +933,9 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev, if (err) return 4; - /* check channel/gain list against card's limitations */ - if (cmd->chanlist) { - gain = CR_RANGE(cmd->chanlist[0]); - start_chan = CR_CHAN(cmd->chanlist[0]); - for (i = 1; i < cmd->chanlist_len; i++) { - 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"); - err++; - } - if (CR_RANGE(cmd->chanlist[i]) != gain) { - comedi_error(dev, - "entries in chanlist must all have the same gain\n"); - err++; - } - } - } + /* Step 5: check channel list if it exists */ + if (cmd->chanlist && cmd->chanlist_len > 0) + err |= cb_pcidas_ai_check_chanlist(dev, s, cmd); if (err) return 5; @@ -1035,6 +1046,25 @@ static int cb_pcidas_ai_cmd(struct comedi_device *dev, return 0; } +static int cb_pcidas_ao_check_chanlist(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) +{ + unsigned int chan0 = CR_CHAN(cmd->chanlist[0]); + + if (cmd->chanlist_len > 1) { + unsigned int chan1 = CR_CHAN(cmd->chanlist[1]); + + if (chan0 != 0 || chan1 != 1) { + dev_dbg(dev->class_dev, + "channels must be ordered channel 0, channel 1 in chanlist\n"); + return -EINVAL; + } + } + + return 0; +} + static int cb_pcidas_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) @@ -1097,15 +1127,9 @@ static int cb_pcidas_ao_cmdtest(struct comedi_device *dev, if (err) return 4; - /* check channel/gain list against card's limitations */ - if (cmd->chanlist && cmd->chanlist_len > 1) { - if (CR_CHAN(cmd->chanlist[0]) != 0 || - CR_CHAN(cmd->chanlist[1]) != 1) { - comedi_error(dev, - "channels must be ordered channel 0, channel 1 in chanlist\n"); - err++; - } - } + /* Step 5: check channel list if it exists */ + if (cmd->chanlist && cmd->chanlist_len > 0) + err |= cb_pcidas_ao_check_chanlist(dev, s, cmd); if (err) return 5; -- cgit v1.2.3 From e300e4fb86e46810b9478161101d63ab6f6d3fae Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 16 Apr 2014 14:19:11 -0700 Subject: staging: comedi: cb_pcidas64: factor out chanlist checking from (*do_cmdtest) Step 5 of the (*do_cmdtest) validates that the cmd->chanlist is compatible with the hardware. For aesthetics, factor out the step 5 code for the analog input and analog output async command support. Tidy up the factored out code. To minimize the noise, change the comedi_error(), which is a wrapper around dev_err(), to dev_dbg(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 110 ++++++++++++++++----------- 1 file changed, 66 insertions(+), 44 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index f9afcbe1da54..0a2b928bcbe8 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -1995,14 +1995,52 @@ static void check_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd) return; } +static int cb_pcidas64_ai_check_chanlist(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) +{ + const struct pcidas64_board *board = comedi_board(dev); + unsigned int aref0 = CR_AREF(cmd->chanlist[0]); + int i; + + for (i = 1; i < cmd->chanlist_len; i++) { + unsigned int aref = CR_AREF(cmd->chanlist[i]); + + if (aref != aref0) { + dev_dbg(dev->class_dev, + "all elements in chanlist must use the same analog reference\n"); + return -EINVAL; + } + } + + if (board->layout == LAYOUT_4020) { + unsigned int chan0 = CR_CHAN(cmd->chanlist[0]); + + for (i = 1; i < cmd->chanlist_len; i++) { + unsigned int chan = CR_CHAN(cmd->chanlist[i]); + + if (chan != (chan0 + i)) { + dev_dbg(dev->class_dev, + "chanlist must use consecutive channels\n"); + return -EINVAL; + } + } + if (cmd->chanlist_len == 3) { + dev_dbg(dev->class_dev, + "chanlist cannot be 3 channels long, use 1, 2, or 4 channels\n"); + return -EINVAL; + } + } + + return 0; +} + static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { const struct pcidas64_board *thisboard = comedi_board(dev); int err = 0; unsigned int tmp_arg, tmp_arg2; - int i; - int aref; unsigned int triggers; /* Step 1 : check if triggers are trivially valid */ @@ -2098,36 +2136,9 @@ static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, if (err) return 4; - /* make sure user is doesn't change analog reference mid chanlist */ - if (cmd->chanlist) { - aref = CR_AREF(cmd->chanlist[0]); - for (i = 1; i < cmd->chanlist_len; i++) { - if (aref != CR_AREF(cmd->chanlist[i])) { - comedi_error(dev, - "all elements in chanlist must use the same analog reference"); - err++; - break; - } - } - /* check 4020 chanlist */ - if (thisboard->layout == LAYOUT_4020) { - unsigned int first_channel = CR_CHAN(cmd->chanlist[0]); - for (i = 1; i < cmd->chanlist_len; i++) { - if (CR_CHAN(cmd->chanlist[i]) != - first_channel + i) { - comedi_error(dev, - "chanlist must use consecutive channels"); - err++; - break; - } - } - if (cmd->chanlist_len == 3) { - comedi_error(dev, - "chanlist cannot be 3 channels long, use 1, 2, or 4 channels"); - err++; - } - } - } + /* Step 5: check channel list if it exists */ + if (cmd->chanlist && cmd->chanlist_len > 0) + err |= cb_pcidas64_ai_check_chanlist(dev, s, cmd); if (err) return 5; @@ -3247,13 +3258,32 @@ static int ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) return 0; } +static int cb_pcidas64_ao_check_chanlist(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) +{ + unsigned int chan0 = CR_CHAN(cmd->chanlist[0]); + int i; + + for (i = 1; i < cmd->chanlist_len; i++) { + unsigned int chan = CR_CHAN(cmd->chanlist[i]); + + if (chan != (chan0 + i)) { + dev_dbg(dev->class_dev, + "chanlist must use consecutive channels\n"); + return -EINVAL; + } + } + + return 0; +} + static int ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { const struct pcidas64_board *thisboard = comedi_board(dev); int err = 0; unsigned int tmp_arg; - int i; /* Step 1 : check if triggers are trivially valid */ @@ -3315,17 +3345,9 @@ static int ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, if (err) return 4; - if (cmd->chanlist) { - unsigned int first_channel = CR_CHAN(cmd->chanlist[0]); - for (i = 1; i < cmd->chanlist_len; i++) { - if (CR_CHAN(cmd->chanlist[i]) != first_channel + i) { - comedi_error(dev, - "chanlist must use consecutive channels"); - err++; - break; - } - } - } + /* Step 5: check channel list if it exists */ + if (cmd->chanlist && cmd->chanlist_len > 0) + err |= cb_pcidas64_ao_check_chanlist(dev, s, cmd); if (err) return 5; -- cgit v1.2.3 From f207eda15f49fd84aaf18db8927fd51a93970fbf Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 16 Apr 2014 14:19:12 -0700 Subject: staging: comedi: das16: factor out chanlist checking from (*do_cmdtest) Step 5 of the (*do_cmdtest) validates that the cmd->chanlist is compatible with the hardware. For aesthetics, factor out the step 5 code for the analog input async command support. Tidy up the factored out code. To minimize the noise, change the dev_err() to dev_dbg(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 51 +++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 6a7d652ff564..eb774c3ef17f 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -600,13 +600,40 @@ static void das16_timer_interrupt(unsigned long arg) mod_timer(&devpriv->timer, jiffies + timer_period()); } +static int das16_ai_check_chanlist(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) +{ + unsigned int chan0 = CR_CHAN(cmd->chanlist[0]); + unsigned int range0 = CR_RANGE(cmd->chanlist[0]); + int i; + + for (i = 1; i < cmd->chanlist_len; i++) { + unsigned int chan = CR_CHAN(cmd->chanlist[i]); + unsigned int range = CR_RANGE(cmd->chanlist[i]); + + if (chan != ((chan0 + i) % s->n_chan)) { + dev_dbg(dev->class_dev, + "entries in chanlist must be consecutive channels, counting upwards\n"); + return -EINVAL; + } + + if (range != range0) { + dev_dbg(dev->class_dev, + "entries in chanlist must all have the same gain\n"); + return -EINVAL; + } + } + + return 0; +} + static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { const struct das16_board *board = comedi_board(dev); struct das16_private_struct *devpriv = dev->private; int err = 0, tmp; - int gain, start_chan, i; int mask; /* Step 1 : check if triggers are trivially valid */ @@ -693,24 +720,10 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, if (err) return 4; - /* check channel/gain list against card's limitations */ - if (cmd->chanlist) { - gain = CR_RANGE(cmd->chanlist[0]); - start_chan = CR_CHAN(cmd->chanlist[0]); - for (i = 1; i < cmd->chanlist_len; i++) { - if (CR_CHAN(cmd->chanlist[i]) != - (start_chan + i) % s->n_chan) { - dev_err(dev->class_dev, - "entries in chanlist must be consecutive channels, counting upwards\n"); - err++; - } - if (CR_RANGE(cmd->chanlist[i]) != gain) { - dev_err(dev->class_dev, - "entries in chanlist must all have the same gain\n"); - err++; - } - } - } + /* Step 5: check channel list if it exists */ + if (cmd->chanlist && cmd->chanlist_len > 0) + err |= das16_ai_check_chanlist(dev, s, cmd); + if (err) return 5; -- cgit v1.2.3 From f71a28320d7bc7d8b712a10bc1553b06ec4c0487 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 16 Apr 2014 14:19:13 -0700 Subject: staging: comedi: das16m1: factor out chanlist checking from (*do_cmdtest) Step 5 of the (*do_cmdtest) validates that the cmd->chanlist is compatible with the hardware. For aesthetics, factor out the step 5 code for the analog input async command support. Tidy up the factored out code. To minimize the noise, change the comedi_error(), which is a wrapper around dev_err(), to dev_dbg(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 49 +++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index 779225831dc0..a9cd21068ea8 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -150,11 +150,39 @@ static void munge_sample_array(unsigned short *array, unsigned int num_elements) array[i] = munge_sample(array[i]); } +static int das16m1_ai_check_chanlist(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) +{ + int i; + + if (cmd->chanlist_len == 1) + return 0; + + if ((cmd->chanlist_len % 2) != 0) { + dev_dbg(dev->class_dev, + "chanlist must be of even length or length 1\n"); + return -EINVAL; + } + + for (i = 0; i < cmd->chanlist_len; i++) { + unsigned int chan = CR_CHAN(cmd->chanlist[i]); + + if ((i % 2) != (chan % 2)) { + dev_dbg(dev->class_dev, + "even/odd channels must go have even/odd chanlist indices\n"); + return -EINVAL; + } + } + + return 0; +} + static int das16m1_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { struct das16m1_private_struct *devpriv = dev->private; - unsigned int err = 0, tmp, i; + unsigned int err = 0, tmp; /* Step 1 : check if triggers are trivially valid */ @@ -216,22 +244,9 @@ static int das16m1_cmd_test(struct comedi_device *dev, if (err) return 4; - /* check chanlist against board's peculiarities */ - if (cmd->chanlist && cmd->chanlist_len > 1) { - for (i = 0; i < cmd->chanlist_len; i++) { - /* even/odd channels must go into even/odd queue addresses */ - if ((i % 2) != (CR_CHAN(cmd->chanlist[i]) % 2)) { - comedi_error(dev, "bad chanlist:\n" - " even/odd channels must go have even/odd chanlist indices"); - err++; - } - } - if ((cmd->chanlist_len % 2) != 0) { - comedi_error(dev, - "chanlist must be of even length or length 1"); - err++; - } - } + /* Step 5: check channel list if it exists */ + if (cmd->chanlist && cmd->chanlist_len > 0) + err |= das16m1_ai_check_chanlist(dev, s, cmd); if (err) return 5; -- cgit v1.2.3 From 8c3ca59af3ec7326a1d6b07ed56edc5e729a36ab Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 16 Apr 2014 14:19:14 -0700 Subject: staging: comedi: das1800: factor out chanlist checking from (*do_cmdtest) Step 5 of the (*do_cmdtest) validates that the cmd->chanlist is compatible with the hardware. For aesthetics, factor out the step 5 code for the analog input async command support. Tidy up the factored out code. To minimize the noise, change the comedi_error(), which is a wrapper around dev_err(), to dev_dbg(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 37 ++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 8e975d6b06db..d581029146cb 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -757,6 +757,26 @@ static unsigned int burst_convert_arg(unsigned int convert_arg, int round_mode) return micro_sec * 1000; } +static int das1800_ai_check_chanlist(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) +{ + unsigned int unipolar0 = CR_RANGE(cmd->chanlist[0]) & UNIPOLAR; + int i; + + for (i = 1; i < cmd->chanlist_len; i++) { + unsigned int unipolar = CR_RANGE(cmd->chanlist[i]) & UNIPOLAR; + + if (unipolar != unipolar0) { + dev_dbg(dev->class_dev, + "unipolar and bipolar ranges cannot be mixed in the chanlist\n"); + return -EINVAL; + } + } + + return 0; +} + /* test analog input cmd */ static int das1800_ai_do_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, @@ -766,8 +786,6 @@ static int das1800_ai_do_cmdtest(struct comedi_device *dev, struct das1800_private *devpriv = dev->private; int err = 0; unsigned int tmp_arg; - int i; - int unipolar; /* Step 1 : check if triggers are trivially valid */ @@ -873,18 +891,9 @@ static int das1800_ai_do_cmdtest(struct comedi_device *dev, if (err) return 4; - /* make sure user is not trying to mix unipolar and bipolar ranges */ - if (cmd->chanlist) { - unipolar = CR_RANGE(cmd->chanlist[0]) & UNIPOLAR; - for (i = 1; i < cmd->chanlist_len; i++) { - if (unipolar != (CR_RANGE(cmd->chanlist[i]) & UNIPOLAR)) { - comedi_error(dev, - "unipolar and bipolar ranges cannot be mixed in the chanlist"); - err++; - break; - } - } - } + /* Step 5: check channel list if it exists */ + if (cmd->chanlist && cmd->chanlist_len > 0) + err |= das1800_ai_check_chanlist(dev, s, cmd); if (err) return 5; -- cgit v1.2.3 From 1626657f35f5b2973fa50f16fb49e20a626cb636 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 16 Apr 2014 14:19:15 -0700 Subject: staging: comedi: das800: factor out chanlist checking from (*do_cmdtest) Step 5 of the (*do_cmdtest) validates that the cmd->chanlist is compatible with the hardware. For aesthetics, factor out the step 5 code for the analog input async command support. Tidy up the factored out code. To minimize the noise, change the dev_err() to dev_dbg(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das800.c | 52 ++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c index 3e408370dcf3..b23a12ce7651 100644 --- a/drivers/staging/comedi/drivers/das800.c +++ b/drivers/staging/comedi/drivers/das800.c @@ -300,6 +300,34 @@ static int das800_cancel(struct comedi_device *dev, struct comedi_subdevice *s) return 0; } +static int das800_ai_check_chanlist(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) +{ + unsigned int chan0 = CR_CHAN(cmd->chanlist[0]); + unsigned int range0 = CR_RANGE(cmd->chanlist[0]); + int i; + + for (i = 1; i < cmd->chanlist_len; i++) { + unsigned int chan = CR_CHAN(cmd->chanlist[i]); + unsigned int range = CR_RANGE(cmd->chanlist[i]); + + if (chan != (chan0 + i) % s->n_chan) { + dev_dbg(dev->class_dev, + "chanlist must be consecutive, counting upwards\n"); + return -EINVAL; + } + + if (range != range0) { + dev_dbg(dev->class_dev, + "chanlist must all have the same gain\n"); + return -EINVAL; + } + } + + return 0; +} + static int das800_ai_do_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) @@ -366,27 +394,9 @@ static int das800_ai_do_cmdtest(struct comedi_device *dev, if (err) return 4; - /* check channel/gain list against card's limitations */ - if (cmd->chanlist) { - unsigned int chan = CR_CHAN(cmd->chanlist[0]); - unsigned int range = CR_RANGE(cmd->chanlist[0]); - unsigned int next; - int i; - - for (i = 1; i < cmd->chanlist_len; i++) { - next = cmd->chanlist[i]; - if (CR_CHAN(next) != (chan + i) % N_CHAN_AI) { - dev_err(dev->class_dev, - "chanlist must be consecutive, counting upwards\n"); - err++; - } - if (CR_RANGE(next) != range) { - dev_err(dev->class_dev, - "chanlist must all have the same gain\n"); - err++; - } - } - } + /* Step 5: check channel list if it exists */ + if (cmd->chanlist && cmd->chanlist_len > 0) + err |= das800_ai_check_chanlist(dev, s, cmd); if (err) return 5; -- cgit v1.2.3 From 869149961951afccb103d43217282756b17f2f96 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 16 Apr 2014 14:19:16 -0700 Subject: staging: comedi: dmm32at: factor out chanlist checking from (*do_cmdtest) Step 5 of the (*do_cmdtest) validates that the cmd->chanlist is compatible with the hardware. For aesthetics, factor out the step 5 code for the analog input async command support. Tidy up the factored out code. To minimize the noise, change the comedi_error(), which is a wrapper around dev_err(), to dev_dbg(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 51 +++++++++++++++++++------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index c8a36eb5f015..68260e6658e4 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -243,13 +243,39 @@ static int dmm32at_ns_to_timer(unsigned int *ns, int round) return *ns; } +static int dmm32at_ai_check_chanlist(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) +{ + unsigned int chan0 = CR_CHAN(cmd->chanlist[0]); + unsigned int range0 = CR_RANGE(cmd->chanlist[0]); + int i; + + for (i = 1; i < cmd->chanlist_len; i++) { + unsigned int chan = CR_CHAN(cmd->chanlist[i]); + unsigned int range = CR_RANGE(cmd->chanlist[i]); + + if (chan != (chan0 + i) % s->n_chan) { + dev_dbg(dev->class_dev, + "entries in chanlist must be consecutive channels, counting upwards\n"); + return -EINVAL; + } + if (range != range0) { + dev_dbg(dev->class_dev, + "entries in chanlist must all have the same gain\n"); + return -EINVAL; + } + } + + return 0; +} + static int dmm32at_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { int err = 0; int tmp; - int start_chan, gain, i; /* Step 1 : check if triggers are trivially valid */ @@ -349,26 +375,9 @@ static int dmm32at_ai_cmdtest(struct comedi_device *dev, if (err) return 4; - /* step 5 check the channel list, the channel list for this - board must be consecutive and gains must be the same */ - - if (cmd->chanlist) { - gain = CR_RANGE(cmd->chanlist[0]); - start_chan = CR_CHAN(cmd->chanlist[0]); - for (i = 1; i < cmd->chanlist_len; i++) { - 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"); - err++; - } - if (CR_RANGE(cmd->chanlist[i]) != gain) { - comedi_error(dev, - "entries in chanlist must all have the same gain\n"); - err++; - } - } - } + /* Step 5: check channel list if it exists */ + if (cmd->chanlist && cmd->chanlist_len > 0) + err |= dmm32at_ai_check_chanlist(dev, s, cmd); if (err) return 5; -- cgit v1.2.3 From 198b21c642a4c0dbf44d805742ff52aa25756216 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 16 Apr 2014 14:19:17 -0700 Subject: staging: comedi: gsc_hpdi: factor out chanlist checking from (*do_cmdtest) Step 5 of the (*do_cmdtest) validates that the cmd->chanlist is compatible with the hardware. For aesthetics, factor out the step 5 code for the async command support. Tidy up the factored out code. To minimize the noise, change the dev_err() to dev_dbg(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/gsc_hpdi.c | 34 ++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index 08d7655e24e7..bae4e9709135 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -360,12 +360,30 @@ static int gsc_hpdi_cmd(struct comedi_device *dev, return 0; } +static int gsc_hpdi_check_chanlist(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) +{ + int i; + + for (i = 0; i < cmd->chanlist_len; i++) { + unsigned int chan = CR_CHAN(cmd->chanlist[i]); + + if (chan != i) { + dev_dbg(dev->class_dev, + "chanlist must be ch 0 to 31 in order\n"); + return -EINVAL; + } + } + + return 0; +} + static int gsc_hpdi_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { int err = 0; - int i; if (s->io_bits) return -EINVAL; @@ -411,17 +429,9 @@ static int gsc_hpdi_cmd_test(struct comedi_device *dev, if (err) return 4; - /* step 5: complain about special chanlist considerations */ - - for (i = 0; i < cmd->chanlist_len; i++) { - if (CR_CHAN(cmd->chanlist[i]) != i) { - /* XXX could support 8 or 16 channels */ - dev_err(dev->class_dev, - "chanlist must be ch 0 to 31 in order"); - err |= -EINVAL; - break; - } - } + /* Step 5: check channel list if it exists */ + if (cmd->chanlist && cmd->chanlist_len > 0) + err |= gsc_hpdi_check_chanlist(dev, s, cmd); if (err) return 5; -- cgit v1.2.3 From 8f61419f1dc2def067e941e077f0f7cf0244f90e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 16 Apr 2014 14:19:18 -0700 Subject: staging: comedi: ni_at_a2150: factor out chanlist checking from (*do_cmdtest) Step 5 of the (*do_cmdtest) validates that the cmd->chanlist is compatible with the hardware. For aesthetics, factor out the step 5 code for the analog input async command support. Tidy up the factored out code. To minimize the noise, change the comedi_error(), which is a wrapper around dev_err(), to dev_dbg(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_at_a2150.c | 74 +++++++++++++++++----------- 1 file changed, 45 insertions(+), 29 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/staging/comedi/drivers/ni_at_a2150.c index 4e39b1f63d81..afbf251ba270 100644 --- a/drivers/staging/comedi/drivers/ni_at_a2150.c +++ b/drivers/staging/comedi/drivers/ni_at_a2150.c @@ -287,14 +287,54 @@ static int a2150_cancel(struct comedi_device *dev, struct comedi_subdevice *s) return 0; } +static int a2150_ai_check_chanlist(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) +{ + unsigned int chan0 = CR_CHAN(cmd->chanlist[0]); + unsigned int aref0 = CR_AREF(cmd->chanlist[0]); + int i; + + if (cmd->chanlist_len == 2 && (chan0 == 1 || chan0 == 3)) { + dev_dbg(dev->class_dev, + "length 2 chanlist must be channels 0,1 or channels 2,3\n"); + return -EINVAL; + } + + if (cmd->chanlist_len == 3) { + dev_dbg(dev->class_dev, + "chanlist must have 1,2 or 4 channels\n"); + return -EINVAL; + } + + for (i = 1; i < cmd->chanlist_len; i++) { + unsigned int chan = CR_CHAN(cmd->chanlist[i]); + unsigned int aref = CR_AREF(cmd->chanlist[i]); + + if (chan != (chan0 + i)) { + dev_dbg(dev->class_dev, + "entries in chanlist must be consecutive channels, counting upwards\n"); + return -EINVAL; + } + + if (chan == 2) + aref0 = aref; + if (aref != aref0) { + dev_dbg(dev->class_dev, + "channels 0/1 and 2/3 must have the same analog reference\n"); + return -EINVAL; + } + } + + return 0; +} + static int a2150_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { const struct a2150_board *thisboard = comedi_board(dev); int err = 0; int tmp; - int startChan; - int i; /* Step 1 : check if triggers are trivially valid */ @@ -348,33 +388,9 @@ static int a2150_ai_cmdtest(struct comedi_device *dev, if (err) return 4; - /* check channel/gain list against card's limitations */ - if (cmd->chanlist) { - startChan = CR_CHAN(cmd->chanlist[0]); - for (i = 1; i < cmd->chanlist_len; i++) { - if (CR_CHAN(cmd->chanlist[i]) != (startChan + i)) { - comedi_error(dev, - "entries in chanlist must be consecutive channels, counting upwards\n"); - err++; - } - } - if (cmd->chanlist_len == 2 && CR_CHAN(cmd->chanlist[0]) == 1) { - comedi_error(dev, - "length 2 chanlist must be channels 0,1 or channels 2,3"); - err++; - } - if (cmd->chanlist_len == 3) { - comedi_error(dev, - "chanlist must have 1,2 or 4 channels"); - err++; - } - if (CR_AREF(cmd->chanlist[0]) != CR_AREF(cmd->chanlist[1]) || - CR_AREF(cmd->chanlist[2]) != CR_AREF(cmd->chanlist[3])) { - comedi_error(dev, - "channels 0/1 and 2/3 must have the same analog reference"); - err++; - } - } + /* Step 5: check channel list if it exists */ + if (cmd->chanlist && cmd->chanlist_len > 0) + err |= a2150_ai_check_chanlist(dev, s, cmd); if (err) return 5; -- cgit v1.2.3 From 368c2dcd2e311bb31deb96024d260f6dec7b3f86 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 16 Apr 2014 14:19:19 -0700 Subject: staging: comedi: ni_mio_common: factor out chanlist checking from (*do_cmdtest) Step 5 of the (*do_cmdtest) validates that the cmd->chanlist is compatible with the hardware. Remove the unnecessary step 5 code in the analog output async command support. For aesthetics, factor out the step 5 code for the "cdio" async command support. Tidy up the factored out code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 31 ++++++++++++++++---------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 8a0e3b7236ad..2e26622edee5 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -3304,11 +3304,6 @@ static int ni_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, if (err) return 4; - /* step 5: fix up chanlist */ - - if (err) - return 5; - return 0; } @@ -3439,12 +3434,27 @@ static int ni_m_series_dio_insn_bits(struct comedi_device *dev, return insn->n; } +static int ni_cdio_check_chanlist(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) +{ + int i; + + for (i = 0; i < cmd->chanlist_len; ++i) { + unsigned int chan = CR_CHAN(cmd->chanlist[i]); + + if (chan != i) + return -EINVAL; + } + + return 0; +} + static int ni_cdio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { int err = 0; int tmp; - unsigned i; /* Step 1 : check if triggers are trivially valid */ @@ -3484,12 +3494,9 @@ static int ni_cdio_cmdtest(struct comedi_device *dev, if (err) return 4; - /* step 5: check chanlist */ - - for (i = 0; i < cmd->chanlist_len; ++i) { - if (cmd->chanlist[i] != i) - err = 1; - } + /* Step 5: check channel list if it exists */ + if (cmd->chanlist && cmd->chanlist_len > 0) + err |= ni_cdio_check_chanlist(dev, s, cmd); if (err) return 5; -- cgit v1.2.3 From 926e5073c788f1abfefe067c15b41107387b76ae Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 16 Apr 2014 14:19:20 -0700 Subject: staging: comedi: me4000: tidy up the chanlist checking The ai_check_chanlist() function validates that the cmd->chanlist is compatible with the hardware. This is step 5 of the (*do_cmdtest). For aesthetics, rename this function so it has namespace associated with the driver and tidy up the code. To minimize the noise, change the dev_err() to dev_dbg(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/me4000.c | 75 ++++++++++----------------------- 1 file changed, 22 insertions(+), 53 deletions(-) diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c index f02b31b317ec..e1465559756f 100644 --- a/drivers/staging/comedi/drivers/me4000.c +++ b/drivers/staging/comedi/drivers/me4000.c @@ -598,67 +598,35 @@ static int me4000_ai_cancel(struct comedi_device *dev, return 0; } -static int ai_check_chanlist(struct comedi_device *dev, - struct comedi_subdevice *s, struct comedi_cmd *cmd) +static int me4000_ai_check_chanlist(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) { - const struct me4000_board *thisboard = comedi_board(dev); - int aref; + const struct me4000_board *board = comedi_board(dev); + unsigned int max_diff_chan = board->ai_diff_nchan; + unsigned int aref0 = CR_AREF(cmd->chanlist[0]); int i; - /* Check whether a channel list is available */ - if (!cmd->chanlist_len) { - dev_err(dev->class_dev, "No channel list available\n"); - return -EINVAL; - } - - /* Check the channel list size */ - if (cmd->chanlist_len > ME4000_AI_CHANNEL_LIST_COUNT) { - dev_err(dev->class_dev, "Channel list is to large\n"); - return -EINVAL; - } - - /* Check the pointer */ - if (!cmd->chanlist) { - dev_err(dev->class_dev, "NULL pointer to channel list\n"); - return -EFAULT; - } - - /* Check whether aref is equal for all entries */ - aref = CR_AREF(cmd->chanlist[0]); for (i = 0; i < cmd->chanlist_len; i++) { - if (CR_AREF(cmd->chanlist[i]) != aref) { - dev_err(dev->class_dev, + unsigned int chan = CR_CHAN(cmd->chanlist[i]); + unsigned int range = CR_RANGE(cmd->chanlist[i]); + unsigned int aref = CR_AREF(cmd->chanlist[i]); + + if (aref != aref0) { + dev_dbg(dev->class_dev, "Mode is not equal for all entries\n"); return -EINVAL; } - } - /* Check whether channels are available for this ending */ - if (aref == SDF_DIFF) { - for (i = 0; i < cmd->chanlist_len; i++) { - if (CR_CHAN(cmd->chanlist[i]) >= - thisboard->ai_diff_nchan) { - dev_err(dev->class_dev, + if (aref == SDF_DIFF) { + if (chan >= max_diff_chan) { + dev_dbg(dev->class_dev, "Channel number to high\n"); return -EINVAL; } - } - } else { - for (i = 0; i < cmd->chanlist_len; i++) { - if (CR_CHAN(cmd->chanlist[i]) >= thisboard->ai_nchan) { - dev_err(dev->class_dev, - "Channel number to high\n"); - return -EINVAL; - } - } - } - /* Check if bipolar is set for all entries when in differential mode */ - if (aref == SDF_DIFF) { - for (i = 0; i < cmd->chanlist_len; i++) { - if (CR_RANGE(cmd->chanlist[i]) != 1 && - CR_RANGE(cmd->chanlist[i]) != 2) { - dev_err(dev->class_dev, + if (!comedi_range_is_bipolar(s, range)) { + dev_dbg(dev->class_dev, "Bipolar is not selected in differential mode\n"); return -EINVAL; } @@ -1091,10 +1059,11 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev, if (err) return 4; - /* - * Stage 5. Check the channel list. - */ - if (ai_check_chanlist(dev, s, cmd)) + /* Step 5: check channel list if it exists */ + if (cmd->chanlist && cmd->chanlist_len > 0) + err |= me4000_ai_check_chanlist(dev, s, cmd); + + if (err) return 5; return 0; -- cgit v1.2.3 From 5089b058966c4f6a5ca33556ca8c3bc88be0ab4c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 16 Apr 2014 14:19:21 -0700 Subject: staging: comedi: ni_labpc: tidy up the chanlist checking The labpc_ai_chanlist_invalid() function validates that the cmd->chanlist is compatible with the hardware. This is step 5 of the (*do_cmdtest). For aesthetics, rename this function and tidy up the code. To minimize the noise, change the comedi_error(), which is a wrapper around dev_err(), to dev_dbg(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc.c | 84 ++++++++++++++----------------- 1 file changed, 38 insertions(+), 46 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index f4216e825f03..f80ca3278314 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -546,72 +546,60 @@ static enum scan_mode labpc_ai_scan_mode(const struct comedi_cmd *cmd) return 0; } -static int labpc_ai_chanlist_invalid(const struct comedi_device *dev, - const struct comedi_cmd *cmd, - enum scan_mode mode) +static int labpc_ai_check_chanlist(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) { - int channel, range, aref, i; - - if (cmd->chanlist == NULL) - return 0; + enum scan_mode mode = labpc_ai_scan_mode(cmd); + unsigned int chan0 = CR_CHAN(cmd->chanlist[0]); + unsigned int range0 = CR_RANGE(cmd->chanlist[0]); + unsigned int aref0 = CR_AREF(cmd->chanlist[0]); + int i; if (mode == MODE_SINGLE_CHAN) return 0; - if (mode == MODE_SINGLE_CHAN_INTERVAL) { - if (cmd->chanlist_len > 0xff) { - comedi_error(dev, - "ni_labpc: chanlist too long for single channel interval mode\n"); - return 1; - } - } - - channel = CR_CHAN(cmd->chanlist[0]); - range = CR_RANGE(cmd->chanlist[0]); - aref = CR_AREF(cmd->chanlist[0]); - for (i = 0; i < cmd->chanlist_len; i++) { + unsigned int chan = CR_CHAN(cmd->chanlist[i]); + unsigned int range = CR_RANGE(cmd->chanlist[i]); + unsigned int aref = CR_AREF(cmd->chanlist[i]); switch (mode) { + case MODE_SINGLE_CHAN: + break; case MODE_SINGLE_CHAN_INTERVAL: - if (CR_CHAN(cmd->chanlist[i]) != channel) { - comedi_error(dev, - "channel scanning order specified in chanlist is not supported by hardware.\n"); - return 1; + if (chan != chan0) { + dev_dbg(dev->class_dev, + "channel scanning order specified in chanlist is not supported by hardware\n"); + return -EINVAL; } break; case MODE_MULT_CHAN_UP: - if (CR_CHAN(cmd->chanlist[i]) != i) { - comedi_error(dev, - "channel scanning order specified in chanlist is not supported by hardware.\n"); - return 1; + if (chan != i) { + dev_dbg(dev->class_dev, + "channel scanning order specified in chanlist is not supported by hardware\n"); + return -EINVAL; } break; case MODE_MULT_CHAN_DOWN: - if (CR_CHAN(cmd->chanlist[i]) != - cmd->chanlist_len - i - 1) { - comedi_error(dev, - "channel scanning order specified in chanlist is not supported by hardware.\n"); - return 1; + if (chan != (cmd->chanlist_len - i - 1)) { + dev_dbg(dev->class_dev, + "channel scanning order specified in chanlist is not supported by hardware\n"); + return -EINVAL; } break; - default: - dev_err(dev->class_dev, - "ni_labpc: bug! in chanlist check\n"); - return 1; - break; } - if (CR_RANGE(cmd->chanlist[i]) != range) { - comedi_error(dev, - "entries in chanlist must all have the same range\n"); - return 1; + if (range != range0) { + dev_dbg(dev->class_dev, + "entries in chanlist must all have the same range\n"); + return -EINVAL; } - if (CR_AREF(cmd->chanlist[i]) != aref) { - comedi_error(dev, - "entries in chanlist must all have the same reference\n"); - return 1; + if (aref != aref0) { + dev_dbg(dev->class_dev, + "entries in chanlist must all have the same reference\n"); + return -EINVAL; } } @@ -711,7 +699,11 @@ static int labpc_ai_cmdtest(struct comedi_device *dev, if (err) return 4; - if (labpc_ai_chanlist_invalid(dev, cmd, mode)) + /* Step 5: check channel list if it exists */ + if (cmd->chanlist && cmd->chanlist_len > 0) + err |= labpc_ai_check_chanlist(dev, s, cmd); + + if (err) return 5; return 0; -- cgit v1.2.3 From 860b7c398a744c1eef42a59b661e870aca12d9be Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Apr 2014 10:07:46 -0700 Subject: staging: comedi: drivers: core validates chanlist_len max The comedi core checks if the (cmd->chanlist_len > s->len_chanlist) when the comedi_cmd is copied from user to kernel space by __comedi_get_user_cmd(). If so, the core returns -EINVAL and will not call the subdevice (*do_cmdtest) and (*do_cmd). Remove the unnecessary "max" checks in the comedi driver (*do_cmdtest) and helper functions. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 3 --- drivers/staging/comedi/drivers/adl_pci9118.c | 2 -- drivers/staging/comedi/drivers/pcl812.c | 1 - drivers/staging/comedi/drivers/rtd520.c | 4 ---- 4 files changed, 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 70e8f426285c..66c24e41d0ff 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -734,7 +734,6 @@ static int apci3120_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { - const struct addi_board *this_board = comedi_board(dev); int err = 0; /* Step 1 : check if triggers are trivially valid */ @@ -779,8 +778,6 @@ static int apci3120_ai_cmdtest(struct comedi_device *dev, } err |= cfc_check_trigger_arg_min(&cmd->chanlist_len, 1); - err |= cfc_check_trigger_arg_max(&cmd->chanlist_len, - this_board->i_AiChannelList); if (cmd->stop_src == TRIG_COUNT) err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1); diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index b6abef6ceab7..53bbc59f6176 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -1259,8 +1259,6 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev, err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0); err |= cfc_check_trigger_arg_min(&cmd->chanlist_len, 1); - err |= cfc_check_trigger_arg_max(&cmd->chanlist_len, - this_board->n_aichanlist); err |= cfc_check_trigger_arg_min(&cmd->scan_end_arg, cmd->chanlist_len); diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 5cc01fe45cf2..0cf115e54308 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -761,7 +761,6 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev, err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0); err |= cfc_check_trigger_arg_min(&cmd->chanlist_len, 1); - err |= cfc_check_trigger_arg_max(&cmd->chanlist_len, MAX_CHANLIST_LEN); err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); if (cmd->stop_src == TRIG_COUNT) diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c index cd3fdf973bdd..1b1c166c8e9b 100644 --- a/drivers/staging/comedi/drivers/rtd520.c +++ b/drivers/staging/comedi/drivers/rtd520.c @@ -891,10 +891,6 @@ static int rtd_ai_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ - if (cmd->chanlist_len > RTD_MAX_CHANLIST) { - cmd->chanlist_len = RTD_MAX_CHANLIST; - err++; - } if (cmd->scan_begin_src == TRIG_TIMER) { tmp = cmd->scan_begin_arg; rtd_ns_to_timer(&cmd->scan_begin_arg, -- cgit v1.2.3 From f50cebb9baa5fd0e561f436bd53ffa35df16edb2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Apr 2014 10:07:47 -0700 Subject: staging: comedi: drivers: properly validate cmd->scan_end_arg When the async command 'scan_end_src' is TRIG_COUNT the 'scan_end_arg' is the cmd->chanlist_len. Fix a couple open-coded drivers. Add the check to the drivers that do not validate this command argument. The core validates that the cmd->chanlist_len is <= s->len_chanlist. During the post config after the attach the core also make sure that the s->len_chanlist is initialized. For clarity, initialize the s->len_chanlist in a couple drivers that are relying on the core to initialize it to '1'. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/8255.c | 3 ++- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 1 + drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c | 5 +++++ drivers/staging/comedi/drivers/addi_apci_1032.c | 3 ++- drivers/staging/comedi/drivers/amplc_pc236.c | 3 ++- drivers/staging/comedi/drivers/comedi_parport.c | 3 ++- drivers/staging/comedi/drivers/dt282x.c | 2 +- drivers/staging/comedi/drivers/ni_6527.c | 3 ++- drivers/staging/comedi/drivers/ni_65xx.c | 3 ++- drivers/staging/comedi/drivers/pcl726.c | 3 ++- drivers/staging/comedi/drivers/rtd520.c | 2 ++ 11 files changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/8255.c b/drivers/staging/comedi/drivers/8255.c index 48817f087d97..1d53e241e84d 100644 --- a/drivers/staging/comedi/drivers/8255.c +++ b/drivers/staging/comedi/drivers/8255.c @@ -231,7 +231,7 @@ static int subdev_8255_cmdtest(struct comedi_device *dev, err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0); err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0); - err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, 1); + err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0); if (err) @@ -298,6 +298,7 @@ int subdev_8255_init_irq(struct comedi_device *dev, struct comedi_subdevice *s, if (ret) return ret; + s->len_chanlist = 1; s->do_cmdtest = subdev_8255_cmdtest; s->do_cmd = subdev_8255_cmd; s->cancel = subdev_8255_cancel; diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 66c24e41d0ff..7ead23e34e8e 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -778,6 +778,7 @@ static int apci3120_ai_cmdtest(struct comedi_device *dev, } err |= cfc_check_trigger_arg_min(&cmd->chanlist_len, 1); + err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); if (cmd->stop_src == TRIG_COUNT) err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1); diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c index 0536d8373861..76a66820775e 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c @@ -2270,6 +2270,11 @@ static int apci3200_ai_cmdtest(struct comedi_device *dev, apci3200_reset(dev); return 2; } + + /* Step 3: check if arguments are trivially valid */ + + err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); + /* i_FirstChannel=cmd->chanlist[0]; */ s_BoardInfos[dev->minor].i_FirstChannel = cmd->chanlist[0]; /* i_LastChannel=cmd->chanlist[1]; */ diff --git a/drivers/staging/comedi/drivers/addi_apci_1032.c b/drivers/staging/comedi/drivers/addi_apci_1032.c index d6a5424654fc..c242afc9134d 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1032.c +++ b/drivers/staging/comedi/drivers/addi_apci_1032.c @@ -198,7 +198,7 @@ static int apci1032_cos_cmdtest(struct comedi_device *dev, err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0); err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0); - err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, 1); + err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0); if (err) @@ -332,6 +332,7 @@ static int apci1032_auto_attach(struct comedi_device *dev, s->range_table = &range_digital; s->insn_config = apci1032_cos_insn_config; s->insn_bits = apci1032_cos_insn_bits; + s->len_chanlist = 1; s->do_cmdtest = apci1032_cos_cmdtest; s->do_cmd = apci1032_cos_cmd; s->cancel = apci1032_cos_cancel; diff --git a/drivers/staging/comedi/drivers/amplc_pc236.c b/drivers/staging/comedi/drivers/amplc_pc236.c index b21d7b48f1da..2834d0a9342a 100644 --- a/drivers/staging/comedi/drivers/amplc_pc236.c +++ b/drivers/staging/comedi/drivers/amplc_pc236.c @@ -314,7 +314,7 @@ static int pc236_intr_cmdtest(struct comedi_device *dev, err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0); err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0); - err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, 1); + err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0); if (err) @@ -402,6 +402,7 @@ static int pc236_common_attach(struct comedi_device *dev, unsigned long iobase, s->maxdata = 1; s->range_table = &range_digital; s->insn_bits = pc236_intr_insn; + s->len_chanlist = 1; s->do_cmdtest = pc236_intr_cmdtest; s->do_cmd = pc236_intr_cmd; s->cancel = pc236_intr_cancel; diff --git a/drivers/staging/comedi/drivers/comedi_parport.c b/drivers/staging/comedi/drivers/comedi_parport.c index 9de81c7712fb..50723b940630 100644 --- a/drivers/staging/comedi/drivers/comedi_parport.c +++ b/drivers/staging/comedi/drivers/comedi_parport.c @@ -181,7 +181,7 @@ static int parport_intr_cmdtest(struct comedi_device *dev, err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0); err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0); - err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, 1); + err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0); if (err) @@ -295,6 +295,7 @@ static int parport_attach(struct comedi_device *dev, s->maxdata = 1; s->range_table = &range_digital; s->insn_bits = parport_intr_insn_bits; + s->len_chanlist = 1; s->do_cmdtest = parport_intr_cmdtest; s->do_cmd = parport_intr_cmd; s->cancel = parport_intr_cancel; diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index 16cc100531e5..b1154f0641d2 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -852,7 +852,7 @@ static int dt282x_ao_cmdtest(struct comedi_device *dev, err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, 5000); err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0); - err |= cfc_check_trigger_arg_max(&cmd->scan_end_arg, 2); + err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); if (cmd->stop_src == TRIG_COUNT) { /* any count is allowed */ diff --git a/drivers/staging/comedi/drivers/ni_6527.c b/drivers/staging/comedi/drivers/ni_6527.c index 860fc81fb11c..2b2dafe29c05 100644 --- a/drivers/staging/comedi/drivers/ni_6527.c +++ b/drivers/staging/comedi/drivers/ni_6527.c @@ -253,7 +253,7 @@ static int ni6527_intr_cmdtest(struct comedi_device *dev, err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0); err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0); - err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, 1); + err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0); if (err) @@ -421,6 +421,7 @@ static int ni6527_auto_attach(struct comedi_device *dev, s->range_table = &range_digital; s->insn_config = ni6527_intr_insn_config; s->insn_bits = ni6527_intr_insn_bits; + s->len_chanlist = 1; s->do_cmdtest = ni6527_intr_cmdtest; s->do_cmd = ni6527_intr_cmd; s->cancel = ni6527_intr_cancel; diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c index 6e42001f686e..2051a7c5de10 100644 --- a/drivers/staging/comedi/drivers/ni_65xx.c +++ b/drivers/staging/comedi/drivers/ni_65xx.c @@ -473,7 +473,7 @@ static int ni_65xx_intr_cmdtest(struct comedi_device *dev, err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0); err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0); - err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, 1); + err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0); if (err) @@ -671,6 +671,7 @@ static int ni_65xx_auto_attach(struct comedi_device *dev, s->n_chan = 1; s->range_table = &range_unknown; s->maxdata = 1; + s->len_chanlist = 1; s->do_cmdtest = ni_65xx_intr_cmdtest; s->do_cmd = ni_65xx_intr_cmd; s->cancel = ni_65xx_intr_cancel; diff --git a/drivers/staging/comedi/drivers/pcl726.c b/drivers/staging/comedi/drivers/pcl726.c index cf9568ee46e4..07ff1e22e61c 100644 --- a/drivers/staging/comedi/drivers/pcl726.c +++ b/drivers/staging/comedi/drivers/pcl726.c @@ -197,7 +197,7 @@ static int pcl726_intr_cmdtest(struct comedi_device *dev, err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0); err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0); - err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, 1); + err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0); if (err) @@ -430,6 +430,7 @@ static int pcl726_attach(struct comedi_device *dev, s->maxdata = 1; s->range_table = &range_digital; s->insn_bits = pcl726_intr_insn_bits; + s->len_chanlist = 1; s->do_cmdtest = pcl726_intr_cmdtest; s->do_cmd = pcl726_intr_cmd; s->cancel = pcl726_intr_cancel; diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c index 1b1c166c8e9b..e7c2e34624d9 100644 --- a/drivers/staging/comedi/drivers/rtd520.c +++ b/drivers/staging/comedi/drivers/rtd520.c @@ -878,6 +878,8 @@ static int rtd_ai_cmdtest(struct comedi_device *dev, err |= cfc_check_trigger_arg_max(&cmd->convert_arg, 9); } + err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); + if (cmd->stop_src == TRIG_COUNT) { /* TODO check for rounding error due to counter wrap */ } else { -- cgit v1.2.3 From 7c9fc34ea3ed02d7d8356094ac179e1c63ae443b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Apr 2014 10:07:48 -0700 Subject: staging: comedi: addi_apci_3xxx: fix ai subdevice 'len_chanlist' Due to a driver limitation, the (*do_cmdtest) for the analog input subdevice overrides the cmd->chanlist_len to force single channel chanlists. But, the cmd->scan_end_arg was already validated before this happens. Instead of fixing the (*do_cmdtest) just set the subdevice len_chanlist to 1 to limit the chanlist size. Move the comment also. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3xxx.c | 40 ++++++++++++------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c index 6dc11c407f57..64c37b65ba27 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c +++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c @@ -573,26 +573,6 @@ static int apci3xxx_ai_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ - /* - * FIXME: The hardware supports multiple scan modes but the original - * addi-data driver only supported reading a single channel with - * interrupts. Need a proper datasheet to fix this. - * - * The following scan modes are supported by the hardware: - * 1) Single software scan - * 2) Single hardware triggered scan - * 3) Continuous software scan - * 4) Continuous software scan with timer delay - * 5) Continuous hardware triggered scan - * 6) Continuous hardware triggered scan with timer delay - * - * For now, limit the chanlist to a single channel. - */ - if (cmd->chanlist_len > 1) { - cmd->chanlist_len = 1; - err |= -EINVAL; - } - tmp = cmd->convert_arg; err |= apci3xxx_ai_ns_to_timer(dev, &cmd->convert_arg, cmd->flags & TRIG_ROUND_MASK); @@ -842,12 +822,30 @@ static int apci3xxx_auto_attach(struct comedi_device *dev, s->subdev_flags = SDF_READABLE | board->ai_subdev_flags; s->n_chan = board->ai_n_chan; s->maxdata = board->ai_maxdata; - s->len_chanlist = s->n_chan; s->range_table = &apci3xxx_ai_range; s->insn_read = apci3xxx_ai_insn_read; if (dev->irq) { + /* + * FIXME: The hardware supports multiple scan modes + * but the original addi-data driver only supported + * reading a single channel with interrupts. Need a + * proper datasheet to fix this. + * + * The following scan modes are supported by the + * hardware: + * 1) Single software scan + * 2) Single hardware triggered scan + * 3) Continuous software scan + * 4) Continuous software scan with timer delay + * 5) Continuous hardware triggered scan + * 6) Continuous hardware triggered scan with timer + * delay + * + * For now, limit the chanlist to a single channel. + */ dev->read_subdev = s; s->subdev_flags |= SDF_CMD_READ; + s->len_chanlist = 1; s->do_cmdtest = apci3xxx_ai_cmdtest; s->do_cmd = apci3xxx_ai_cmd; s->cancel = apci3xxx_ai_cancel; -- cgit v1.2.3 From c50a39824d350c3f9c3ba5edc2ffdf0b3b743cb7 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Apr 2014 10:07:49 -0700 Subject: staging: comedi: adl_pci9111: rename local var in pci9111_ai_do_cmd_test() For aesthetics, rename the local variable 'error' to 'err'. This is the normal name for this local variable in (*do_cmdtest) functions. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9111.c | 57 ++++++++++++++-------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index 575af7444716..6fc85932643c 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -354,68 +354,67 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev, struct comedi_cmd *cmd) { struct pci9111_private_data *dev_private = dev->private; + int err = 0; int tmp; - int error = 0; /* Step 1 : check if triggers are trivially valid */ - error |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW); - error |= cfc_check_trigger_src(&cmd->scan_begin_src, + err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW); + err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_TIMER | TRIG_FOLLOW | TRIG_EXT); - error |= cfc_check_trigger_src(&cmd->convert_src, + err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_TIMER | TRIG_EXT); - error |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT); - error |= cfc_check_trigger_src(&cmd->stop_src, + err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT); + err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE); - if (error) + if (err) return 1; /* Step 2a : make sure trigger sources are unique */ - error |= cfc_check_trigger_is_unique(cmd->scan_begin_src); - error |= cfc_check_trigger_is_unique(cmd->convert_src); - error |= cfc_check_trigger_is_unique(cmd->stop_src); + err |= cfc_check_trigger_is_unique(cmd->scan_begin_src); + err |= cfc_check_trigger_is_unique(cmd->convert_src); + err |= cfc_check_trigger_is_unique(cmd->stop_src); /* Step 2b : and mutually compatible */ if ((cmd->convert_src == TRIG_TIMER) && !((cmd->scan_begin_src == TRIG_TIMER) || (cmd->scan_begin_src == TRIG_FOLLOW))) - error |= -EINVAL; + err |= -EINVAL; if ((cmd->convert_src == TRIG_EXT) && !((cmd->scan_begin_src == TRIG_EXT) || (cmd->scan_begin_src == TRIG_FOLLOW))) - error |= -EINVAL; + err |= -EINVAL; - if (error) + if (err) return 2; /* Step 3: check if arguments are trivially valid */ - error |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); + err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); if (cmd->convert_src == TRIG_TIMER) - error |= cfc_check_trigger_arg_min(&cmd->convert_arg, + err |= cfc_check_trigger_arg_min(&cmd->convert_arg, PCI9111_AI_ACQUISITION_PERIOD_MIN_NS); else /* TRIG_EXT */ - error |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0); + err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0); if (cmd->scan_begin_src == TRIG_TIMER) - error |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, + err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, PCI9111_AI_ACQUISITION_PERIOD_MIN_NS); else /* TRIG_FOLLOW || TRIG_EXT */ - error |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0); + err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0); - error |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, - cmd->chanlist_len); + err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); if (cmd->stop_src == TRIG_COUNT) - error |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1); + err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1); else /* TRIG_NONE */ - error |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0); + err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0); - if (error) + if (err) return 3; /* Step 4 : fix up any arguments */ @@ -427,7 +426,7 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev, &dev_private->div2, &cmd->convert_arg, cmd->flags); if (tmp != cmd->convert_arg) - error++; + err |= -EINVAL; } /* There's only one timer on this card, so the scan_begin timer must */ /* be a multiple of chanlist_len*convert_arg */ @@ -447,23 +446,23 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev, scan_begin_arg = scan_factor * scan_begin_min; if (cmd->scan_begin_arg != scan_begin_arg) { cmd->scan_begin_arg = scan_begin_arg; - error++; + err |= -EINVAL; } } else { cmd->scan_begin_arg = scan_begin_min; - error++; + err |= -EINVAL; } } } - if (error) + if (err) return 4; /* Step 5: check channel list if it exists */ if (cmd->chanlist && cmd->chanlist_len > 0) - error |= pci9111_ai_check_chanlist(dev, s, cmd); + err |= pci9111_ai_check_chanlist(dev, s, cmd); - if (error) + if (err) return 5; return 0; -- cgit v1.2.3 From 6e1d1f336e2103b31f1cecb63bb791427af7b9ec Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Apr 2014 10:07:50 -0700 Subject: staging: comedi: comedi_test: ao subdevice does not support async commands The comedi_subdevices array is kzalloc()'d so the async command callbacks do not need to be set to NULL when the analog output subdevice is initialized. Also, remove the initialzation of the subdevice 'len_chanlist' since this value is only used by the async commands. The core will default it to 1. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_test.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c index cd9562556d2c..ad5014a4074e 100644 --- a/drivers/staging/comedi/drivers/comedi_test.c +++ b/drivers/staging/comedi/drivers/comedi_test.c @@ -413,11 +413,7 @@ static int waveform_attach(struct comedi_device *dev, s->n_chan = N_CHANS; s->maxdata = 0xffff; s->range_table = &waveform_ai_ranges; - s->len_chanlist = s->n_chan * 2; s->insn_write = waveform_ao_insn_write; - s->do_cmd = NULL; - s->do_cmdtest = NULL; - s->cancel = NULL; /* Our default loopback value is just a 0V flatline */ for (i = 0; i < s->n_chan; i++) -- cgit v1.2.3 From 9b799edccbfb8c8973e8b55e8a0bfdc70c707f21 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Apr 2014 10:07:51 -0700 Subject: staging: comedi: hwdrv_apci3200: properly validata the ai cmd->start_arg The async command 'arguments' should be trivially validated in Step 3 of the (*do_cmdtest) not Step 2b. Move the validataion in this driver to the proper place. This driver supports two cmd->start_src values, TRIG_NOW and TRIG_EXT. TRIG_NOW sources should always have an arg of 0. The arg for TRIG_EXT sources is driver specific. Properly validate the cmd->start_arg based on the cmd->start_src. Remove the noise when the arg is invalid and modify the cmd->start_arg so that a valid value is returned to the user. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3200.c | 38 +++++++++++++--------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c index 76a66820775e..9b8851c7e072 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c @@ -2221,12 +2221,11 @@ static int apci3200_ai_cmdtest(struct comedi_device *dev, unsigned int ui_ConvertTimeBase = 0; unsigned int ui_DelayTime = 0; unsigned int ui_DelayTimeBase = 0; - int i_Triggermode = 0; - int i_TriggerEdge = 0; int i_NbrOfChannel = 0; int i_Cpt = 0; double d_ConversionTimeForAllChannels = 0.0; double d_SCANTimeNewUnit = 0.0; + unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -2253,19 +2252,6 @@ static int apci3200_ai_cmdtest(struct comedi_device *dev, /* Step 2b : and mutually compatible */ - if (cmd->start_src == TRIG_EXT) { - i_TriggerEdge = cmd->start_arg & 0xFFFF; - i_Triggermode = cmd->start_arg >> 16; - if (i_TriggerEdge < 1 || i_TriggerEdge > 3) { - err++; - printk("\nThe trigger edge selection is in error\n"); - } - if (i_Triggermode != 2) { - err++; - printk("\nThe trigger mode selection is in error\n"); - } - } - if (err) { apci3200_reset(dev); return 2; @@ -2273,6 +2259,28 @@ static int apci3200_ai_cmdtest(struct comedi_device *dev, /* Step 3: check if arguments are trivially valid */ + switch (cmd->start_src) { + case TRIG_NOW: + err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); + break; + case TRIG_EXT: + /* validate the trigger edge selection */ + arg = cmd->start_arg & 0xffff; + if (arg < 1 || arg > 3) { + cmd->start_arg &= ~0xffff; + cmd->start_arg |= 1; + err |= -EINVAL; + } + /* validate the trigger mode selection */ + arg = cmd->start_arg >> 16; + if (arg != 2) { + cmd->start_arg &= ~(0xffff << 16); + cmd->start_arg |= (2 << 16); + err |= -EINVAL; + } + break; + } + err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len); /* i_FirstChannel=cmd->chanlist[0]; */ -- cgit v1.2.3 From 01dc2a05f46280f825378be0bee8a2f13ca12c0a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Apr 2014 10:07:52 -0700 Subject: staging: comedi: adl_pci9118: fix the ai cmd->start_arg validation and use This driver supports three cmd->start_src values, TRIG_NOW, TRIG_EXT, and TRIG_INT. TRIG_NOW sources should always have an arg of 0 and arg for TRIG_EXT sources is driver specific. This driver does not use the cmd->start_arg with the TRIG_EXT source so a trivial value of 0 is good. When the cmd->start_src is TRIG_INT the cmd->start_arg is actually the valid trig_num that is passed to the async (*inttrig) callback. This driver allows any value to be used and currently carries that value in the private data. Refactor the (*do_cmdtest) so that the trivial validation of the cmd->start_arg is clear. Refactor the (*inttrig) so that the cmd->start_arg is used directly to check the trig_num and remove the then unused 'ai_inttrig_start' member from the private data. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 53bbc59f6176..4be5f67cf14a 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -411,7 +411,6 @@ struct pci9118_private { */ 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 */ }; static int check_channel_list(struct comedi_device *dev, @@ -1135,11 +1134,13 @@ static irqreturn_t interrupt_pci9118(int irq, void *d) } static int pci9118_ai_inttrig(struct comedi_device *dev, - struct comedi_subdevice *s, unsigned int trignum) + struct comedi_subdevice *s, + unsigned int trig_num) { struct pci9118_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; - if (trignum != devpriv->ai_inttrig_start) + if (trig_num != cmd->start_arg) return -EINVAL; devpriv->ai12_startstop &= ~START_AI_INT; @@ -1221,8 +1222,15 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev, /* Step 3: check if arguments are trivially valid */ - if (cmd->start_src & (TRIG_NOW | TRIG_EXT)) + switch (cmd->start_src) { + case TRIG_NOW: + case TRIG_EXT: err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); + break; + case TRIG_INT: + /* start_arg is the internal trigger (any value) */ + break; + } if (cmd->scan_begin_src & (TRIG_FOLLOW | TRIG_EXT)) err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0); @@ -1627,7 +1635,6 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) } if (cmd->start_src == TRIG_INT) { devpriv->ai12_startstop |= START_AI_INT; - devpriv->ai_inttrig_start = cmd->start_arg; s->async->inttrig = pci9118_ai_inttrig; } #if 0 -- cgit v1.2.3 From ebe0f68eddc2e351b3b8b865f478592f231baaea Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Apr 2014 10:07:53 -0700 Subject: staging: comedi: amplc_dio200_common: fix the cmd->start_arg use This driver supports two cmd->start_src values, TRIG_NOW and TRIG_INT. TRIG_NOW sources should always have an arg of 0. For TRIG_INT sources, the cmd->start_arg is actually the valid trig_num that is passed to the async (*inttrig) callback. This driver trivially validates the arg for both sources to be 0. Refactor the (*inttrig) so that the cmd->start_arg is used to check the trig_num instead of the open coded value. For aesthetics, refactor the (*do_cmd) to use if/else instead of the switch when handling the cmd->start_src. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/amplc_dio200_common.c | 27 ++++++++-------------- 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index 818a0d7e3d58..4ac320884ac6 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -281,22 +281,18 @@ static int dio200_start_intr(struct comedi_device *dev, return retval; } -/* - * Internal trigger function to start acquisition for an 'INTERRUPT' subdevice. - */ -static int -dio200_inttrig_start_intr(struct comedi_device *dev, struct comedi_subdevice *s, - unsigned int trignum) +static int dio200_inttrig_start_intr(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned int trig_num) { - struct dio200_subdev_intr *subpriv; + struct dio200_subdev_intr *subpriv = s->private; + struct comedi_cmd *cmd = &s->async->cmd; unsigned long flags; int event = 0; - if (trignum != 0) + if (trig_num != cmd->start_arg) return -EINVAL; - subpriv = s->private; - spin_lock_irqsave(&subpriv->spinlock, flags); s->async->inttrig = NULL; if (subpriv->active) @@ -528,16 +524,11 @@ static int dio200_subdev_intr_cmd(struct comedi_device *dev, break; } - /* Set up start of acquisition. */ - switch (cmd->start_src) { - case TRIG_INT: + if (cmd->start_src == TRIG_INT) s->async->inttrig = dio200_inttrig_start_intr; - break; - default: - /* TRIG_NOW */ + else /* TRIG_NOW */ event = dio200_start_intr(dev, s); - break; - } + spin_unlock_irqrestore(&subpriv->spinlock, flags); if (event) -- cgit v1.2.3 From 9fba5ead79b996f97e80a670eabab75538a7422a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Apr 2014 10:07:54 -0700 Subject: staging: comedi: amplc_pci224: fix the ao cmd->start_arg use This driver supports two cmd->start_src values, TRIG_INT and TRIG_EXT. For TRIG_INT sources, the cmd->start_arg is actually the valid trig_num that is passed to the async (*inttrig) callback. This driver trivially validates the arg for this source to be 0. Refactor the (*inttrig) so that the cmd->start_arg is used to check the trig_num instead of the open coded value. For aesthetics, refactor the (*do_cmd) to use if/else instead of the switch when handling the cmd->start_src. All code paths do the spin lock/unlock so move those out of the if/else. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci224.c | 31 ++++++++++----------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index e99829e58635..3b9a8b9ae39c 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -671,14 +671,13 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, cfc_handle_events(dev, s); } -/* - * Internal trigger function to start acquisition on AO subdevice. - */ -static int -pci224_ao_inttrig_start(struct comedi_device *dev, struct comedi_subdevice *s, - unsigned int trignum) +static int pci224_ao_inttrig_start(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned int trig_num) { - if (trignum != 0) + struct comedi_cmd *cmd = &s->async->cmd; + + if (trig_num != cmd->start_arg) return -EINVAL; s->async->inttrig = NULL; @@ -1053,23 +1052,15 @@ static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) break; } - /* - * Sort out start of acquisition. - */ - switch (cmd->start_src) { - case TRIG_INT: - spin_lock_irqsave(&devpriv->ao_spinlock, flags); - s->async->inttrig = &pci224_ao_inttrig_start; - spin_unlock_irqrestore(&devpriv->ao_spinlock, flags); - break; - case TRIG_EXT: + spin_lock_irqsave(&devpriv->ao_spinlock, flags); + if (cmd->start_src == TRIG_INT) { + s->async->inttrig = pci224_ao_inttrig_start; + } else { /* TRIG_EXT */ /* Enable external interrupt trigger to start acquisition. */ - spin_lock_irqsave(&devpriv->ao_spinlock, flags); devpriv->intsce |= PCI224_INTR_EXT; outb(devpriv->intsce, devpriv->iobase1 + PCI224_INT_SCE); - spin_unlock_irqrestore(&devpriv->ao_spinlock, flags); - break; } + spin_unlock_irqrestore(&devpriv->ao_spinlock, flags); return 0; } -- cgit v1.2.3 From 2cc3460d51947987713451ad9423ba230cbfec00 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Apr 2014 10:07:55 -0700 Subject: staging: comedi: amplc_pci230: fix the ai/ao cmd->start_arg use for TRIG_INT This driver trivially validates the cmd->start_arg for all cmd->start_src values to be 0. For TRIG_INT source, the cmd->start_arg is actually the valid trig_num that is passed to the async (*inttrig) callback. Refactor the (*inttrig) functions so that the cmd->start_arg is used to check the trig_num instead of the open coded values. For aesthetics, refactor the ai (*do_cmd) to remove some unnecessary {}. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci230.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 7149f471f542..d7ffd18206f9 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -1427,7 +1427,9 @@ static int pci230_ao_inttrig_start(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int trig_num) { - if (trig_num != 0) + struct comedi_cmd *cmd = &s->async->cmd; + + if (trig_num != cmd->start_src) return -EINVAL; s->async->inttrig = NULL; @@ -2146,7 +2148,9 @@ static int pci230_ai_inttrig_start(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int trig_num) { - if (trig_num != 0) + struct comedi_cmd *cmd = &s->async->cmd; + + if (trig_num != cmd->start_arg) return -EINVAL; s->async->inttrig = NULL; @@ -2432,12 +2436,10 @@ static int pci230_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) } } - if (cmd->start_src == TRIG_INT) { + if (cmd->start_src == TRIG_INT) s->async->inttrig = pci230_ai_inttrig_start; - } else { - /* TRIG_NOW */ + else /* TRIG_NOW */ pci230_ai_start(dev, s); - } return 0; } -- cgit v1.2.3 From 96997b0efa8b82162f78a294669de44320a8c87f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Apr 2014 10:07:56 -0700 Subject: staging: comedi: cb_pcidas: clarify the ai cmd->start_arg validation This driver supports two cmd->start_src values, TRIG_NOW and TRIG_EXT. For aesthetics, replace the default case when validating the cmd->start_arg with the proper case statement. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index 70d926707777..523378fbf302 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -872,9 +872,12 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev, if (err) return 2; - /* step 3: arguments are trivially compatible */ + /* Step 3: check if arguments are trivially valid */ switch (cmd->start_src) { + case TRIG_NOW: + err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); + break; case TRIG_EXT: /* External trigger, only CR_EDGE and CR_INVERT flags allowed */ if ((cmd->start_arg @@ -888,9 +891,6 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev, err |= -EINVAL; } break; - default: - err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); - break; } if (cmd->scan_begin_src == TRIG_TIMER) -- cgit v1.2.3 From 384e483fb9d487bb318acc7098f61d3feffa4d79 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Apr 2014 10:07:57 -0700 Subject: staging: comedi: cb_pcidas: fix the ao cmd->start_arg use for TRIG_INT This driver only supports a cmd->start_src of TRIG_INT for ai commands. The cmd->start_arg is trivially validated to be 0. For TRIG_INT source, the cmd->start_arg is actually the valid trig_num that is passed to the async (*inttrig) callback. Refactor the (*inttrig) function so that the cmd->start_arg is used to check the trig_num instead of the open coded value. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index 523378fbf302..26fc00e552a8 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -1169,7 +1169,7 @@ static int cb_pcidas_ao_inttrig(struct comedi_device *dev, struct comedi_cmd *cmd = &s->async->cmd; unsigned long flags; - if (trig_num != 0) + if (trig_num != cmd->start_arg) return -EINVAL; /* load up fifo */ -- cgit v1.2.3 From 020cb120c1c434f69d1af096ca17b690100b3b07 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Apr 2014 10:07:58 -0700 Subject: staging: comedi: cb_pcidas64: validate the ai/ao cmd->start_arg The cmd->start_arg should be trivially validated in Step 3 of the (*do_cmdtest) functions. Add the necessary code. For the analog output, a cmd->start_src of TRIG_NOW and TRIG_INT is supported. For both sources the cmd->start_arg is validated to be 0. For a TRIG_INT source, the cmd->start_Arg is actually the valid trig_num that is passed to the async (*inttrig) callback. Refactor the (*inttrig) function so that the cmd->start_arg is used to check the trig_num instead of the open coded value. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 0a2b928bcbe8..4061f0481de2 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -2087,6 +2087,18 @@ static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, /* Step 3: check if arguments are trivially valid */ + switch (cmd->start_src) { + case TRIG_NOW: + err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); + break; + case TRIG_EXT: + /* + * start_arg is the CR_CHAN | CR_INVERT of the + * external trigger. + */ + break; + } + if (cmd->convert_src == TRIG_TIMER) { if (thisboard->layout == LAYOUT_4020) { err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0); @@ -3215,7 +3227,7 @@ static int ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd = &s->async->cmd; int retval; - if (trig_num != 0) + if (trig_num != cmd->start_arg) return -EINVAL; retval = prep_ao_dma(dev, cmd); @@ -3315,6 +3327,8 @@ static int ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, /* Step 3: check if arguments are trivially valid */ + err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); + if (cmd->scan_begin_src == TRIG_TIMER) { err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, thisboard->ao_scan_speed); -- cgit v1.2.3 From bdbca9b562a2e892b77811ef2b70e1981e26b7e2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Apr 2014 10:07:59 -0700 Subject: staging: comedi: dt282x: fix the ao cmd->start_arg use for TRIG_INT This driver only supports a cmd->start_src of TRIG_INT for ao commands. The cmd->start_arg is trivially validated to be 0. For TRIG_INT source, the cmd->start_arg is actually the valid trig_num that is passed to the async (*inttrig) callback. Refactor the (*inttrig) function so that the cmd->start_arg is used to check the trig_num instead of the open coded value. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt282x.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index b1154f0641d2..474f52dac15d 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -878,12 +878,14 @@ static int dt282x_ao_cmdtest(struct comedi_device *dev, } static int dt282x_ao_inttrig(struct comedi_device *dev, - struct comedi_subdevice *s, unsigned int x) + struct comedi_subdevice *s, + unsigned int trig_num) { struct dt282x_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; int size; - if (x != 0) + if (trig_num != cmd->start_src) return -EINVAL; size = cfc_read_array_from_buffer(s, devpriv->dma[0].buf, -- cgit v1.2.3 From 4264cb64069e1c746483938c09e0df1099befd8b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Apr 2014 10:08:00 -0700 Subject: staging: comedi: gsc_hpdi: validate the cmd->start_arg The cmd->start_arg should be trivially validated in Step 3 of the (*do_cmdtest) functions. Add the necessary code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/gsc_hpdi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index bae4e9709135..22333c1ad88c 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -410,6 +410,8 @@ static int gsc_hpdi_cmd_test(struct comedi_device *dev, /* Step 3: check if arguments are trivially valid */ + err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); + if (!cmd->chanlist_len || !cmd->chanlist) { cmd->chanlist_len = 32; err |= -EINVAL; -- cgit v1.2.3 From 025b918731e4ee46ee8a27073281b2db715f79e2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Apr 2014 10:08:01 -0700 Subject: staging: comedi: me4000: validate the cmd->start_arg The cmd->start_arg should be trivially validated in Step 3 of the (*do_cmdtest) functions. Add the necessary code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/me4000.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c index e1465559756f..f43221fcd15e 100644 --- a/drivers/staging/comedi/drivers/me4000.c +++ b/drivers/staging/comedi/drivers/me4000.c @@ -918,6 +918,8 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev, /* Step 3: check if arguments are trivially valid */ + err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); + if (cmd->chanlist_len < 1) { cmd->chanlist_len = 1; err |= -EINVAL; -- cgit v1.2.3 From e702c66c0724c09e8efb87cb6fff8100e988cdb0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Apr 2014 10:08:02 -0700 Subject: staging: comedi: ni_pcidio: fix the cmd->start_arg use for TRIG_INT This driver only a cmd->start_src of TRIG_NOW or TRIG_INT. The cmd->start_arg is trivially validated for both sources to be 0. For a TRIG_INT source, the cmd->start_arg is actually the valid trig_num that is passed to the async (*inttrig) callback. Refactor the (*inttrig) function so that the cmd->start_arg is used to check the trig_num instead of the open coded value. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_pcidio.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c index 85ac2d964f5c..962c2353a79f 100644 --- a/drivers/staging/comedi/drivers/ni_pcidio.c +++ b/drivers/staging/comedi/drivers/ni_pcidio.c @@ -773,11 +773,13 @@ static int setup_mite_dma(struct comedi_device *dev, struct comedi_subdevice *s) } static int ni_pcidio_inttrig(struct comedi_device *dev, - struct comedi_subdevice *s, unsigned int trignum) + struct comedi_subdevice *s, + unsigned int trig_num) { struct nidio96_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; - if (trignum != 0) + if (trig_num != cmd->start_arg) return -EINVAL; writeb(devpriv->OpModeBits, devpriv->mite->daq_io_addr + OpMode); -- cgit v1.2.3 From 6a760394d7eb70a810bf472289473f915eb6da0d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Apr 2014 10:08:03 -0700 Subject: staging: comedi: ni_tiocmd: clarify the cmd->start_arg validation and use This driver supportes cmd->start_src sources of TRIG_NOW, TRIG_INT, TRIG_OTHER, and TRIG_EXT. Refactor the (*do_cmdtest) to clarify the trivial validation of the cmd->start_arg. For a TRIG_INT source, the cmd->start_arg is actually the valid trig_num that is passed to the async (*inttrig) callback. Refactor the (*inttrig) function so that the cmd->start_arg is used to check the trig_num instead of the open coded value. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tiocmd.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tiocmd.c b/drivers/staging/comedi/drivers/ni_tiocmd.c index 7d64f8892f08..b9d23db4004b 100644 --- a/drivers/staging/comedi/drivers/ni_tiocmd.c +++ b/drivers/staging/comedi/drivers/ni_tiocmd.c @@ -89,14 +89,16 @@ static void ni_tio_configure_dma(struct ni_gpct *counter, short enable, static int ni_tio_input_inttrig(struct comedi_device *dev, struct comedi_subdevice *s, - unsigned int trignum) + unsigned int trig_num) { + struct ni_gpct *counter = s->private; + struct comedi_cmd *cmd = &s->async->cmd; unsigned long flags; int retval = 0; - struct ni_gpct *counter = s->private; BUG_ON(counter == NULL); - if (trignum != 0) + + if (trig_num != cmd->start_src) return -EINVAL; spin_lock_irqsave(&counter->lock, flags); @@ -271,8 +273,16 @@ int ni_tio_cmdtest(struct comedi_device *dev, /* Step 3: check if arguments are trivially valid */ - if (cmd->start_src != TRIG_EXT) + switch (cmd->start_src) { + case TRIG_NOW: + case TRIG_INT: + case TRIG_OTHER: err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); + break; + case TRIG_EXT: + /* start_arg is the start_trigger passed to ni_tio_arm() */ + break; + } if (cmd->scan_begin_src != TRIG_EXT) err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0); -- cgit v1.2.3 From c55881686302a5e7f19b82f0a163beec2cc314c3 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Apr 2014 10:08:04 -0700 Subject: staging: comedi: ni_labpc: clarify the cmd->start_arg validation This driver supports cmd->start_src sources of TRIG_NOW and TRIG_EXT. Refactor the (*do_cmdtest) to clarify the trivial validation of the cmd->start_arg. This also fixes a bug, the cmd->start_src has the trigger not the cmd->start_arg. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index f80ca3278314..fc9d31420956 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -649,8 +649,14 @@ static int labpc_ai_cmdtest(struct comedi_device *dev, /* Step 3: check if arguments are trivially valid */ - if (cmd->start_arg == TRIG_NOW) + switch (cmd->start_src) { + case TRIG_NOW: err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); + break; + case TRIG_EXT: + /* start_arg value is ignored */ + break; + } if (!cmd->chanlist_len) err |= -EINVAL; -- cgit v1.2.3 From 725ce0d4738172c1cccea233111bf078785d660a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Apr 2014 10:08:05 -0700 Subject: staging: comedi: pcmmio: fix the cmd->start_arg use for TRIG_INT This driver supports a cmd->start_src of TRIG_NOW or TRIG_INT. The cmd->start_arg is trivially validated for both sources to be 0. For a TRIG_INT source, the cmd->start_arg is actually the valid trig_num that is used by the async (*inttrig) callback. Refactor the (*inttrig) function so that the cmd->start_arg is used to check the trig_num instead of the open coded value. For aesthetics, refactor the (*do_cmd) to use if/else instead if the switch when handling the cmd->start_src. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcmmio.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c index e89bca845349..bb29ecfcfef4 100644 --- a/drivers/staging/comedi/drivers/pcmmio.c +++ b/drivers/staging/comedi/drivers/pcmmio.c @@ -464,18 +464,16 @@ static int pcmmio_cancel(struct comedi_device *dev, struct comedi_subdevice *s) return 0; } -/* - * Internal trigger function to start acquisition for an 'INTERRUPT' subdevice. - */ -static int -pcmmio_inttrig_start_intr(struct comedi_device *dev, struct comedi_subdevice *s, - unsigned int trignum) +static int pcmmio_inttrig_start_intr(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned int trig_num) { struct pcmmio_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; unsigned long flags; int event = 0; - if (trignum != 0) + if (trig_num != cmd->start_arg) return -EINVAL; spin_lock_irqsave(&devpriv->spinlock, flags); @@ -517,15 +515,11 @@ static int pcmmio_cmd(struct comedi_device *dev, struct comedi_subdevice *s) } /* Set up start of acquisition. */ - switch (cmd->start_src) { - case TRIG_INT: + if (cmd->start_src == TRIG_INT) s->async->inttrig = pcmmio_inttrig_start_intr; - break; - default: - /* TRIG_NOW */ + else /* TRIG_NOW */ event = pcmmio_start_intr(dev, s); - break; - } + spin_unlock_irqrestore(&devpriv->spinlock, flags); if (event) -- cgit v1.2.3 From cb789b8014dc4b35622d9ed18fb1b492a0f43355 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Apr 2014 10:08:06 -0700 Subject: staging: comedi: pcmuio: fix the cmd->start_arg use for TRIG_INT This driver supports a cmd->start_src of TRIG_NOW or TRIG_INT. The cmd->start_arg is trivially validated for both sources to be 0. For a TRIG_INT source, the cmd->start_arg is actually the valid trig_num that is used by the async (*inttrig) callback. Refactor the (*inttrig) function so that the cmd->start_arg is used to check the trig_num instead of the open coded value. For aesthetics, refactor the (*do_cmd) to use if/else instead if the switch when handling the cmd->start_src. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcmuio.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcmuio.c b/drivers/staging/comedi/drivers/pcmuio.c index a8f390f7a874..ea45424e8410 100644 --- a/drivers/staging/comedi/drivers/pcmuio.c +++ b/drivers/staging/comedi/drivers/pcmuio.c @@ -460,20 +460,18 @@ static int pcmuio_cancel(struct comedi_device *dev, struct comedi_subdevice *s) return 0; } -/* - * Internal trigger function to start acquisition for an 'INTERRUPT' subdevice. - */ -static int -pcmuio_inttrig_start_intr(struct comedi_device *dev, struct comedi_subdevice *s, - unsigned int trignum) +static int pcmuio_inttrig_start_intr(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned int trig_num) { struct pcmuio_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; int asic = pcmuio_subdevice_to_asic(s); struct pcmuio_asic *chip = &devpriv->asics[asic]; unsigned long flags; int event = 0; - if (trignum != 0) + if (trig_num != cmd->start_arg) return -EINVAL; spin_lock_irqsave(&chip->spinlock, flags); @@ -518,15 +516,11 @@ static int pcmuio_cmd(struct comedi_device *dev, struct comedi_subdevice *s) } /* Set up start of acquisition. */ - switch (cmd->start_src) { - case TRIG_INT: + if (cmd->start_src == TRIG_INT) s->async->inttrig = pcmuio_inttrig_start_intr; - break; - default: - /* TRIG_NOW */ + else /* TRIG_NOW */ event = pcmuio_start_intr(dev, s); - break; - } + spin_unlock_irqrestore(&chip->spinlock, flags); if (event) -- cgit v1.2.3 From 478da5c9ad51c48653b395b64d4c62a616dfb872 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Apr 2014 10:08:07 -0700 Subject: staging: comedi: s626: clarify the cmd->start_arg validation and use This driver supports a cmd->start_src of TRIG_NOW, TRIG_INT or TRIG_EXT. Clarify the cmd->start_arg validation in Step 3 of the (*do_cmdtest). For a TRIG_INT source, the cmd->start_arg is actually the valid trig_num that is used by the async (*inttrig) callback. Refactor the (*inttrig) function so that the cmd->start_arg is used to check the trig_num instead of the open coded value. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/s626.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index 6da43de51eb3..647b9e50bd74 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c @@ -2076,9 +2076,12 @@ static int s626_ai_load_polllist(uint8_t *ppl, struct comedi_cmd *cmd) } static int s626_ai_inttrig(struct comedi_device *dev, - struct comedi_subdevice *s, unsigned int trignum) + struct comedi_subdevice *s, + unsigned int trig_num) { - if (trignum != 0) + struct comedi_cmd *cmd = &s->async->cmd; + + if (trig_num != cmd->start_arg) return -EINVAL; /* Start executing the RPS program */ @@ -2314,12 +2317,18 @@ static int s626_ai_cmdtest(struct comedi_device *dev, if (err) return 2; - /* step 3: make sure arguments are trivially compatible */ + /* Step 3: check if arguments are trivially valid */ - if (cmd->start_src != TRIG_EXT) + switch (cmd->start_src) { + case TRIG_NOW: + case TRIG_INT: err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); - if (cmd->start_src == TRIG_EXT) + break; + case TRIG_EXT: err |= cfc_check_trigger_arg_max(&cmd->start_arg, 39); + break; + } + if (cmd->scan_begin_src == TRIG_EXT) err |= cfc_check_trigger_arg_max(&cmd->scan_begin_arg, 39); if (cmd->convert_src == TRIG_EXT) -- cgit v1.2.3 From b9b5b74eb3e3dc91bb7dc994dd2271b102a104cc Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Apr 2014 10:08:08 -0700 Subject: staging: comedi: usbduxsigma: fix the ai/ao cmd->start_arg use for TRIG_INT For both ai and ao commands this driver supports a cmd->start_src of TRIG_NOW or TRIG_INT. The cmd->start_arg is trivially validated for both sources to be 0. For a TRIG_INT source, the cmd->start_arg is actually the valid trig_num that is used by the async (*inttrig) callback. Refactor the (*inttrig) functions so that the cmd->start_arg is used to check the trig_num instead of the open coded values. For aesthetics, remove some unnecessary comments in the (*do_cmd) functions. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxsigma.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c index 88c60b6020c4..b57c974e5cb6 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -663,12 +663,13 @@ static int usbduxsigma_receive_cmd(struct comedi_device *dev, int command) static int usbduxsigma_ai_inttrig(struct comedi_device *dev, struct comedi_subdevice *s, - unsigned int trignum) + unsigned int trig_num) { struct usbduxsigma_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; int ret; - if (trignum != 0) + if (trig_num != cmd->start_arg) return -EINVAL; down(&devpriv->sem); @@ -738,7 +739,6 @@ static int usbduxsigma_ai_cmd(struct comedi_device *dev, } s->async->inttrig = NULL; } else { /* TRIG_INT */ - /* wait for an internal signal and submit the urbs later */ s->async->inttrig = usbduxsigma_ai_inttrig; } @@ -856,12 +856,13 @@ static int usbduxsigma_ao_insn_write(struct comedi_device *dev, static int usbduxsigma_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s, - unsigned int trignum) + unsigned int trig_num) { struct usbduxsigma_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; int ret; - if (trignum != 0) + if (trig_num != cmd->start_arg) return -EINVAL; down(&devpriv->sem); @@ -1027,7 +1028,6 @@ static int usbduxsigma_ao_cmd(struct comedi_device *dev, } s->async->inttrig = NULL; } else { /* TRIG_INT */ - /* wait for an internal signal and submit the urbs later */ s->async->inttrig = usbduxsigma_ao_inttrig; } -- cgit v1.2.3 From 95194590a71c6b17853c30be9f53227e4648b363 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Apr 2014 10:08:09 -0700 Subject: staging: comedi: usbduxfast: fix the cmd->start_arg validation and use This driver supports cmd->start_src values of TRIG_NOW, TRIG_EXT, and TRIG_INT. Currently the cmd->start_arg is only validated for TRIG_NOW. For TRIG_EXT sources, the cmd->start_src is driver specific. For a TRIG_INT source, the cmd->start_arg is actually the valid trig_num that is used by the async (*inttrig) callback. The cmd->start_arg is currently not use in the driver. Just trivially validate it to be 0 for all cmd->start_src values. Refactor the (*inttrig) function so that the cmd->start_arg is used to check the trig_num instead of the open coded value. For aesthetics, remove some unnecessary comments in the (*do_cmd) function. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxfast.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c index d6fae11ee4e0..a4d7bfbcc6b9 100644 --- a/drivers/staging/comedi/drivers/usbduxfast.c +++ b/drivers/staging/comedi/drivers/usbduxfast.c @@ -398,8 +398,7 @@ static int usbduxfast_ai_cmdtest(struct comedi_device *dev, /* Step 3: check if arguments are trivially valid */ - if (cmd->start_src == TRIG_NOW) - err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); + err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); if (!cmd->chanlist_len) err |= -EINVAL; @@ -451,21 +450,20 @@ static int usbduxfast_ai_cmdtest(struct comedi_device *dev, static int usbduxfast_ai_inttrig(struct comedi_device *dev, struct comedi_subdevice *s, - unsigned int trignum) + unsigned int trig_num) { struct usbduxfast_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; int ret; if (!devpriv) return -EFAULT; + if (trig_num != cmd->start_arg) + return -EINVAL; + down(&devpriv->sem); - if (trignum != 0) { - dev_err(dev->class_dev, "invalid trignum\n"); - up(&devpriv->sem); - return -EINVAL; - } if (!devpriv->ai_cmd_running) { devpriv->ai_cmd_running = 1; ret = usbduxfast_submit_urb(dev); @@ -837,12 +835,7 @@ static int usbduxfast_ai_cmd(struct comedi_device *dev, return ret; } s->async->inttrig = NULL; - } else { - /* - * TRIG_INT - * don't enable the acquision operation - * wait for an internal signal - */ + } else { /* TRIG_INT */ s->async->inttrig = usbduxfast_ai_inttrig; } up(&devpriv->sem); -- cgit v1.2.3 From 7d8b7b4d92bc05d49966adb158b43655e687e20b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Apr 2014 10:08:10 -0700 Subject: staging: comedi: usbdux: fix the cmd->start_arg use For all cmd->start_src values this driver trivially validates that the cmd->start_arg is 0. For a TRIG_INT source, the cmd->start_arg is actually the valid trig_num that is used by the async (*inttrig) callback. Refactor the (*inttrig) functions so that the cmd->start_arg is used to check the trig_num instead of the open coded values. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 71db683098d6..ce528f847600 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -692,15 +692,16 @@ static int receive_dux_commands(struct comedi_device *dev, unsigned int command) static int usbdux_ai_inttrig(struct comedi_device *dev, struct comedi_subdevice *s, - unsigned int trignum) + unsigned int trig_num) { struct usbdux_private *devpriv = dev->private; - int ret = -EINVAL; + struct comedi_cmd *cmd = &s->async->cmd; + int ret; - down(&devpriv->sem); + if (trig_num != cmd->start_arg) + return -EINVAL; - if (trignum != 0) - goto ai_trig_exit; + down(&devpriv->sem); if (!devpriv->ai_cmd_running) { devpriv->ai_cmd_running = 1; @@ -913,15 +914,16 @@ ao_write_exit: static int usbdux_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s, - unsigned int trignum) + unsigned int trig_num) { struct usbdux_private *devpriv = dev->private; - int ret = -EINVAL; + struct comedi_cmd *cmd = &s->async->cmd; + int ret; - down(&devpriv->sem); + if (trig_num != cmd->start_arg) + return -EINVAL; - if (trignum != 0) - goto ao_trig_exit; + down(&devpriv->sem); if (!devpriv->ao_cmd_running) { devpriv->ao_cmd_running = 1; -- cgit v1.2.3 From ebb657babfa9b0b1978c1998e93865772ee9bb27 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Apr 2014 10:08:11 -0700 Subject: staging: comedi: ni_mio_common: clarify the cmd->start_arg validation and use Clarify the cmd->start_arg validation in Step 3 of the (*do_cmdtest) functions. For a TRIG_INT source, the cmd->start_arg is actually the valid trig_num that is used by the async (*inttrig) callbacks. Refactor the (*inttrig) functions so that the cmd->start_arg is used to check the trig_num instead of the open coded values. For aesthetics, refactor the (*do_cmd) functions to use if/else instead of the switch to handle the cmd->start_src. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 74 +++++++++++++++----------- 1 file changed, 42 insertions(+), 32 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 2e26622edee5..087b533625df 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -2080,7 +2080,7 @@ static int ni_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, const struct ni_board_struct *board = comedi_board(dev); struct ni_private *devpriv = dev->private; int err = 0; - int tmp; + unsigned int tmp; unsigned int sources; /* Step 1 : check if triggers are trivially valid */ @@ -2119,17 +2119,19 @@ static int ni_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, /* Step 3: check if arguments are trivially valid */ - if (cmd->start_src == TRIG_EXT) { - /* external trigger */ - unsigned int tmp = CR_CHAN(cmd->start_arg); + switch (cmd->start_src) { + case TRIG_NOW: + case TRIG_INT: + err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); + break; + case TRIG_EXT: + tmp = CR_CHAN(cmd->start_arg); if (tmp > 16) tmp = 16; tmp |= (cmd->start_arg & (CR_INVERT | CR_EDGE)); err |= cfc_check_trigger_arg_is(&cmd->start_arg, tmp); - } else { - /* true for both TRIG_NOW and TRIG_INT */ - err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); + break; } if (cmd->scan_begin_src == TRIG_TIMER) { @@ -2510,30 +2512,28 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) } #endif - switch (cmd->start_src) { - case TRIG_NOW: + if (cmd->start_src == TRIG_NOW) { /* AI_START1_Pulse */ devpriv->stc_writew(dev, AI_START1_Pulse | devpriv->ai_cmd2, AI_Command_2_Register); s->async->inttrig = NULL; - break; - case TRIG_EXT: + } else if (cmd->start_src == TRIG_EXT) { s->async->inttrig = NULL; - break; - case TRIG_INT: - s->async->inttrig = &ni_ai_inttrig; - break; + } else { /* TRIG_INT */ + s->async->inttrig = ni_ai_inttrig; } return 0; } -static int ni_ai_inttrig(struct comedi_device *dev, struct comedi_subdevice *s, - unsigned int trignum) +static int ni_ai_inttrig(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned int trig_num) { struct ni_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; - if (trignum != 0) + if (trig_num != cmd->start_arg) return -EINVAL; devpriv->stc_writew(dev, AI_START1_Pulse | devpriv->ai_cmd2, @@ -2946,17 +2946,19 @@ static int ni_ao_insn_config(struct comedi_device *dev, return -EINVAL; } -static int ni_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s, - unsigned int trignum) +static int ni_ao_inttrig(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned int trig_num) { const struct ni_board_struct *board __maybe_unused = comedi_board(dev); struct ni_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; int ret; int interrupt_b_bits; int i; static const int timeout = 1000; - if (trignum != 0) + if (trig_num != cmd->start_arg) return -EINVAL; /* Null trig at beginning prevent ao start trigger from executing more than @@ -3217,7 +3219,7 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) AO_BC_TC_Interrupt_Enable, 1); } - s->async->inttrig = &ni_ao_inttrig; + s->async->inttrig = ni_ao_inttrig; return 0; } @@ -3228,7 +3230,7 @@ static int ni_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, const struct ni_board_struct *board = comedi_board(dev); struct ni_private *devpriv = dev->private; int err = 0; - int tmp; + unsigned int tmp; /* Step 1 : check if triggers are trivially valid */ @@ -3258,17 +3260,18 @@ static int ni_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, /* Step 3: check if arguments are trivially valid */ - if (cmd->start_src == TRIG_EXT) { - /* external trigger */ - unsigned int tmp = CR_CHAN(cmd->start_arg); + switch (cmd->start_src) { + case TRIG_INT: + err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); + break; + case TRIG_EXT: + tmp = CR_CHAN(cmd->start_arg); if (tmp > 18) tmp = 18; tmp |= (cmd->start_arg & (CR_INVERT | CR_EDGE)); err |= cfc_check_trigger_arg_is(&cmd->start_arg, tmp); - } else { - /* true for both TRIG_NOW and TRIG_INT */ - err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0); + break; } if (cmd->scan_begin_src == TRIG_TIMER) { @@ -3537,21 +3540,28 @@ static int ni_cdio_cmd(struct comedi_device *dev, struct comedi_subdevice *s) retval = ni_request_cdo_mite_channel(dev); if (retval < 0) return retval; - s->async->inttrig = &ni_cdo_inttrig; + + s->async->inttrig = ni_cdo_inttrig; + return 0; } -static int ni_cdo_inttrig(struct comedi_device *dev, struct comedi_subdevice *s, - unsigned int trignum) +static int ni_cdo_inttrig(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned int trig_num) { #ifdef PCIDMA struct ni_private *devpriv = dev->private; unsigned long flags; #endif + struct comedi_cmd *cmd = &s->async->cmd; int retval = 0; unsigned i; const unsigned timeout = 1000; + if (trig_num != cmd->start_arg) + return -EINVAL; + s->async->inttrig = NULL; /* read alloc the entire buffer */ -- cgit v1.2.3 From e3c5be2bdae553ddefacc636496f2df21aee31ee Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Tue, 22 Apr 2014 12:23:00 +0100 Subject: staging: iio: Fix typo in iio Correct spelling typo in comment within staging/iio Signed-off-by: Masanari Iida Acked-by: Randy Dunlap Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad799x.c | 2 +- drivers/staging/iio/adc/ad7606.h | 4 ++-- drivers/staging/iio/adc/ad7816.c | 2 +- drivers/staging/iio/addac/adt7316.c | 4 ++-- drivers/staging/iio/cdc/ad7152.c | 2 +- drivers/staging/iio/cdc/ad7746.c | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c index bcbf6102efed..16a8b14b1921 100644 --- a/drivers/iio/adc/ad799x.c +++ b/drivers/iio/adc/ad799x.c @@ -102,7 +102,7 @@ enum { }; /** - * struct ad799x_chip_info - chip specifc information + * struct ad799x_chip_info - chip specific information * @channel: channel specification * @num_channels: number of channels * @monitor_mode: whether the chip supports monitor interrupts diff --git a/drivers/staging/iio/adc/ad7606.h b/drivers/staging/iio/adc/ad7606.h index 93c7299e8353..ec89d055cf58 100644 --- a/drivers/staging/iio/adc/ad7606.h +++ b/drivers/staging/iio/adc/ad7606.h @@ -14,7 +14,7 @@ */ /** - * struct ad7606_platform_data - platform/board specifc information + * struct ad7606_platform_data - platform/board specific information * @default_os: default oversampling value {0, 2, 4, 8, 16, 32, 64} * @default_range: default range +/-{5000, 10000} mVolt * @gpio_convst: number of gpio connected to the CONVST pin @@ -41,7 +41,7 @@ struct ad7606_platform_data { }; /** - * struct ad7606_chip_info - chip specifc information + * struct ad7606_chip_info - chip specific information * @name: identification string for chip * @int_vref_mv: the internal reference voltage * @channels: channel specification diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c index 2369cf28412e..158d770f961a 100644 --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c @@ -40,7 +40,7 @@ /* - * struct ad7816_chip_info - chip specifc information + * struct ad7816_chip_info - chip specific information */ struct ad7816_chip_info { diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 16a8201228ff..6806d424e8d1 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -172,7 +172,7 @@ #define ID_ADT75XX 0x10 /* - * struct adt7316_chip_info - chip specifc information + * struct adt7316_chip_info - chip specific information */ struct adt7316_chip_info { @@ -208,7 +208,7 @@ struct adt7316_chip_info { (ADT7316_TEMP_INT_MASK) /* - * struct adt7316_chip_info - chip specifc information + * struct adt7316_chip_info - chip specific information */ struct adt7316_limit_regs { diff --git a/drivers/staging/iio/cdc/ad7152.c b/drivers/staging/iio/cdc/ad7152.c index f2c309d1eb59..87110d940e9a 100644 --- a/drivers/staging/iio/cdc/ad7152.c +++ b/drivers/staging/iio/cdc/ad7152.c @@ -78,7 +78,7 @@ enum { }; /* - * struct ad7152_chip_info - chip specifc information + * struct ad7152_chip_info - chip specific information */ struct ad7152_chip_info { diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c index cbb1588d591f..e6e9eaa9eab5 100644 --- a/drivers/staging/iio/cdc/ad7746.c +++ b/drivers/staging/iio/cdc/ad7746.c @@ -91,7 +91,7 @@ #define AD7746_CAPDAC_DACP(x) ((x) & 0x7F) /* - * struct ad7746_chip_info - chip specifc information + * struct ad7746_chip_info - chip specific information */ struct ad7746_chip_info { -- cgit v1.2.3 From a7fa5e4e0316ba3f74c4b2c77c00b6242dbaa91a Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 25 Apr 2014 13:59:57 -0700 Subject: staging: remove sbe-2t3e3 driver. It never really got cleaned up properly, and no one is working on it, so remove it. If someone wants to pick it up, this can be easily reverted. Cc: Krzysztof Halasa Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 - drivers/staging/Makefile | 1 - drivers/staging/sbe-2t3e3/2t3e3.h | 889 ----------------------------------- drivers/staging/sbe-2t3e3/Kconfig | 13 - drivers/staging/sbe-2t3e3/Makefile | 4 - drivers/staging/sbe-2t3e3/TODO | 6 - drivers/staging/sbe-2t3e3/cpld.c | 352 -------------- drivers/staging/sbe-2t3e3/ctrl.c | 350 -------------- drivers/staging/sbe-2t3e3/ctrl.h | 131 ------ drivers/staging/sbe-2t3e3/dc.c | 460 ------------------ drivers/staging/sbe-2t3e3/exar7250.c | 185 -------- drivers/staging/sbe-2t3e3/exar7300.c | 165 ------- drivers/staging/sbe-2t3e3/intr.c | 579 ----------------------- drivers/staging/sbe-2t3e3/io.c | 330 ------------- drivers/staging/sbe-2t3e3/main.c | 172 ------- drivers/staging/sbe-2t3e3/maps.c | 101 ---- drivers/staging/sbe-2t3e3/module.c | 208 -------- drivers/staging/sbe-2t3e3/netdev.c | 143 ------ 18 files changed, 4091 deletions(-) delete mode 100644 drivers/staging/sbe-2t3e3/2t3e3.h delete mode 100644 drivers/staging/sbe-2t3e3/Kconfig delete mode 100644 drivers/staging/sbe-2t3e3/Makefile delete mode 100644 drivers/staging/sbe-2t3e3/TODO delete mode 100644 drivers/staging/sbe-2t3e3/cpld.c delete mode 100644 drivers/staging/sbe-2t3e3/ctrl.c delete mode 100644 drivers/staging/sbe-2t3e3/ctrl.h delete mode 100644 drivers/staging/sbe-2t3e3/dc.c delete mode 100644 drivers/staging/sbe-2t3e3/exar7250.c delete mode 100644 drivers/staging/sbe-2t3e3/exar7300.c delete mode 100644 drivers/staging/sbe-2t3e3/intr.c delete mode 100644 drivers/staging/sbe-2t3e3/io.c delete mode 100644 drivers/staging/sbe-2t3e3/main.c delete mode 100644 drivers/staging/sbe-2t3e3/maps.c delete mode 100644 drivers/staging/sbe-2t3e3/module.c delete mode 100644 drivers/staging/sbe-2t3e3/netdev.c diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index e62be2b0b16d..0c3887778f38 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -90,8 +90,6 @@ source "drivers/staging/tidspbridge/Kconfig" source "drivers/staging/quickstart/Kconfig" -source "drivers/staging/sbe-2t3e3/Kconfig" - source "drivers/staging/keucr/Kconfig" source "drivers/staging/bcm/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 35edbe293631..7bf91a616066 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -39,7 +39,6 @@ obj-$(CONFIG_CXT1E1) += cxt1e1/ obj-$(CONFIG_FB_XGI) += xgifb/ obj-$(CONFIG_TIDSPBRIDGE) += tidspbridge/ obj-$(CONFIG_ACPI_QUICKSTART) += quickstart/ -obj-$(CONFIG_SBE_2T3E3) += sbe-2t3e3/ obj-$(CONFIG_USB_ENESTORAGE) += keucr/ obj-$(CONFIG_BCM_WIMAX) += bcm/ obj-$(CONFIG_FT1000) += ft1000/ diff --git a/drivers/staging/sbe-2t3e3/2t3e3.h b/drivers/staging/sbe-2t3e3/2t3e3.h deleted file mode 100644 index e7bf721f3fd1..000000000000 --- a/drivers/staging/sbe-2t3e3/2t3e3.h +++ /dev/null @@ -1,889 +0,0 @@ -/* - * SBE 2T3E3 synchronous serial card driver for Linux - * - * Copyright (C) 2009-2010 Krzysztof Halasa - * - * 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 code is based on a driver written by SBE Inc. - */ - -#ifndef T3E3_H -#define T3E3_H - -#include -#include -#include -#include -#include -#include "ctrl.h" - -/************************************************************** - * 21143 - **************************************************************/ - -/* CSR */ -#define SBE_2T3E3_21143_REG_BUS_MODE 0 -#define SBE_2T3E3_21143_REG_TRANSMIT_POLL_DEMAND 1 -#define SBE_2T3E3_21143_REG_RECEIVE_POLL_DEMAND 2 -#define SBE_2T3E3_21143_REG_RECEIVE_LIST_BASE_ADDRESS 3 -#define SBE_2T3E3_21143_REG_TRANSMIT_LIST_BASE_ADDRESS 4 -#define SBE_2T3E3_21143_REG_STATUS 5 -#define SBE_2T3E3_21143_REG_OPERATION_MODE 6 -#define SBE_2T3E3_21143_REG_INTERRUPT_ENABLE 7 -#define SBE_2T3E3_21143_REG_MISSED_FRAMES_AND_OVERFLOW_COUNTER 8 -#define SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT 9 -#define SBE_2T3E3_21143_REG_BOOT_ROM_PROGRAMMING_ADDRESS 10 -#define SBE_2T3E3_21143_REG_GENERAL_PURPOSE_TIMER_AND_INTERRUPT_MITIGATION_CONTROL 11 -#define SBE_2T3E3_21143_REG_SIA_STATUS 12 -#define SBE_2T3E3_21143_REG_SIA_CONNECTIVITY 13 -#define SBE_2T3E3_21143_REG_SIA_TRANSMIT_AND_RECEIVE 14 -#define SBE_2T3E3_21143_REG_SIA_AND_GENERAL_PURPOSE_PORT 15 -#define SBE_2T3E3_21143_REG_MAX 16 - -/* CSR0 - BUS_MODE */ -#define SBE_2T3E3_21143_VAL_WRITE_AND_INVALIDATE_ENABLE 0x01000000 -#define SBE_2T3E3_21143_VAL_READ_LINE_ENABLE 0x00800000 -#define SBE_2T3E3_21143_VAL_READ_MULTIPLE_ENABLE 0x00200000 -#define SBE_2T3E3_21143_VAL_TRANSMIT_AUTOMATIC_POLLING_200us 0x00020000 -#define SBE_2T3E3_21143_VAL_TRANSMIT_AUTOMATIC_POLLING_DISABLED 0x00000000 -#define SBE_2T3E3_21143_VAL_CACHE_ALIGNMENT_32 0x0000c000 -#define SBE_2T3E3_21143_VAL_CACHE_ALIGNMENT_16 0x00008000 -#define SBE_2T3E3_21143_VAL_CACHE_ALIGNMENT_8 0x00004000 -#define SBE_2T3E3_21143_VAL_BUS_ARBITRATION_RR 0x00000002 -#define SBE_2T3E3_21143_VAL_SOFTWARE_RESET 0x00000001 - -/* CSR5 - STATUS */ -#define SBE_2T3E3_21143_VAL_GENERAL_PURPOSE_PORT_INTERRUPT 0x04000000 -#define SBE_2T3E3_21143_VAL_ERROR_BITS 0x03800000 -#define SBE_2T3E3_21143_VAL_PARITY_ERROR 0x00000000 -#define SBE_2T3E3_21143_VAL_MASTER_ABORT 0x00800000 -#define SBE_2T3E3_21143_VAL_TARGET_ABORT 0x01000000 -#define SBE_2T3E3_21143_VAL_TRANSMISSION_PROCESS_STATE 0x00700000 -#define SBE_2T3E3_21143_VAL_TX_STOPPED 0x00000000 -#define SBE_2T3E3_21143_VAL_TX_SUSPENDED 0x00600000 -#define SBE_2T3E3_21143_VAL_RECEIVE_PROCESS_STATE 0x000e0000 -#define SBE_2T3E3_21143_VAL_RX_STOPPED 0x00000000 -#define SBE_2T3E3_21143_VAL_RX_SUSPENDED 0x000a0000 -#define SBE_2T3E3_21143_VAL_NORMAL_INTERRUPT_SUMMARY 0x00010000 -#define SBE_2T3E3_21143_VAL_ABNORMAL_INTERRUPT_SUMMARY 0x00008000 -#define SBE_2T3E3_21143_VAL_EARLY_RECEIVE_INTERRUPT 0x00004000 -#define SBE_2T3E3_21143_VAL_FATAL_BUS_ERROR 0x00002000 -#define SBE_2T3E3_21143_VAL_GENERAL_PURPOSE_TIMER_EXPIRED 0x00000800 -#define SBE_2T3E3_21143_VAL_EARLY_TRANSMIT_INTERRUPT 0x00000400 -#define SBE_2T3E3_21143_VAL_RECEIVE_WATCHDOG_TIMEOUT 0x00000200 -#define SBE_2T3E3_21143_VAL_RECEIVE_PROCESS_STOPPED 0x00000100 -#define SBE_2T3E3_21143_VAL_RECEIVE_BUFFER_UNAVAILABLE 0x00000080 -#define SBE_2T3E3_21143_VAL_RECEIVE_INTERRUPT 0x00000040 -#define SBE_2T3E3_21143_VAL_TRANSMIT_UNDERFLOW 0x00000020 -#define SBE_2T3E3_21143_VAL_TRANSMIT_JABBER_TIMEOUT 0x00000008 -#define SBE_2T3E3_21143_VAL_TRANSMIT_BUFFER_UNAVAILABLE 0x00000004 -#define SBE_2T3E3_21143_VAL_TRANSMIT_PROCESS_STOPPED 0x00000002 -#define SBE_2T3E3_21143_VAL_TRANSMIT_INTERRUPT 0x00000001 - -/* CSR6 - OPERATION_MODE */ -#define SBE_2T3E3_21143_VAL_SPECIAL_CAPTURE_EFFECT_ENABLE 0x80000000 -#define SBE_2T3E3_21143_VAL_RECEIVE_ALL 0x40000000 -#define SBE_2T3E3_21143_VAL_MUST_BE_ONE 0x02000000 -#define SBE_2T3E3_21143_VAL_SCRAMBLER_MODE 0x01000000 -#define SBE_2T3E3_21143_VAL_PCS_FUNCTION 0x00800000 -#define SBE_2T3E3_21143_VAL_TRANSMIT_THRESHOLD_MODE_10Mbs 0x00400000 -#define SBE_2T3E3_21143_VAL_TRANSMIT_THRESHOLD_MODE_100Mbs 0x00000000 -#define SBE_2T3E3_21143_VAL_STORE_AND_FORWARD 0x00200000 -#define SBE_2T3E3_21143_VAL_HEARTBEAT_DISABLE 0x00080000 -#define SBE_2T3E3_21143_VAL_PORT_SELECT 0x00040000 -#define SBE_2T3E3_21143_VAL_CAPTURE_EFFECT_ENABLE 0x00020000 -#define SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS 0x0000c000 -#define SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_1 0x00000000 -#define SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_2 0x00004000 -#define SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_3 0x00008000 -#define SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_4 0x0000c000 -#define SBE_2T3E3_21143_VAL_TRANSMISSION_START 0x00002000 -#define SBE_2T3E3_21143_VAL_OPERATING_MODE 0x00000c00 -#define SBE_2T3E3_21143_VAL_LOOPBACK_OFF 0x00000000 -#define SBE_2T3E3_21143_VAL_LOOPBACK_EXTERNAL 0x00000800 -#define SBE_2T3E3_21143_VAL_LOOPBACK_INTERNAL 0x00000400 -#define SBE_2T3E3_21143_VAL_FULL_DUPLEX_MODE 0x00000200 -#define SBE_2T3E3_21143_VAL_PASS_ALL_MULTICAST 0x00000080 -#define SBE_2T3E3_21143_VAL_PROMISCUOUS_MODE 0x00000040 -#define SBE_2T3E3_21143_VAL_PASS_BAD_FRAMES 0x00000008 -#define SBE_2T3E3_21143_VAL_RECEIVE_START 0x00000002 - -/* CSR7 - INTERRUPT_ENABLE */ -#define SBE_2T3E3_21143_VAL_LINK_CHANGED_ENABLE 0x08000000 -#define SBE_2T3E3_21143_VAL_GENERAL_PURPOSE_PORT_ENABLE 0x04000000 -#define SBE_2T3E3_21143_VAL_NORMAL_INTERRUPT_SUMMARY_ENABLE 0x00010000 -#define SBE_2T3E3_21143_VAL_ABNORMAL_INTERRUPT_SUMMARY_ENABLE 0x00008000 -#define SBE_2T3E3_21143_VAL_EARLY_RECEIVE_INTERRUPT_ENABLE 0x00004000 -#define SBE_2T3E3_21143_VAL_FATAL_BUS_ERROR_ENABLE 0x00002000 -#define SBE_2T3E3_21143_VAL_LINK_FAIL_ENABLE 0x00001000 -#define SBE_2T3E3_21143_VAL_GENERAL_PURPOSE_TIMER_ENABLE 0x00000800 -#define SBE_2T3E3_21143_VAL_EARLY_TRANSMIT_INTERRUPT_ENABLE 0x00000400 -#define SBE_2T3E3_21143_VAL_RECEIVE_WATCHDOG_TIMEOUT_ENABLE 0x00000200 -#define SBE_2T3E3_21143_VAL_RECEIVE_STOPPED_ENABLE 0x00000100 -#define SBE_2T3E3_21143_VAL_RECEIVE_BUFFER_UNAVAILABLE_ENABLE 0x00000080 -#define SBE_2T3E3_21143_VAL_RECEIVE_INTERRUPT_ENABLE 0x00000040 -#define SBE_2T3E3_21143_VAL_TRANSMIT_UNDERFLOW_INTERRUPT_ENABLE 0x00000020 -#define SBE_2T3E3_21143_VAL_TRANSMIT_JABBER_TIMEOUT_ENABLE 0x00000008 -#define SBE_2T3E3_21143_VAL_TRANSMIT_BUFFER_UNAVAILABLE_ENABLE 0x00000004 -#define SBE_2T3E3_21143_VAL_TRANSMIT_STOPPED_ENABLE 0x00000002 -#define SBE_2T3E3_21143_VAL_TRANSMIT_INTERRUPT_ENABLE 0x00000001 - -/* CSR8 - MISSED_FRAMES_AND_OVERFLOW_COUNTER */ -#define SBE_2T3E3_21143_VAL_OVERFLOW_COUNTER_OVERFLOW 0x10000000 -#define SBE_2T3E3_21143_VAL_OVERFLOW_COUNTER 0x0ffe0000 -#define SBE_2T3E3_21143_VAL_MISSED_FRAME_OVERFLOW 0x00010000 -#define SBE_2T3E3_21143_VAL_MISSED_FRAMES_COUNTER 0x0000ffff - -/* CSR9 - BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT */ -#define SBE_2T3E3_21143_VAL_MII_MANAGEMENT_DATA_IN 0x00080000 -#define SBE_2T3E3_21143_VAL_MII_MANAGEMENT_READ_MODE 0x00040000 -#define SBE_2T3E3_21143_VAL_MII_MANAGEMENT_DATA_OUT 0x00020000 -#define SBE_2T3E3_21143_VAL_MII_MANAGEMENT_CLOCK 0x00010000 -#define SBE_2T3E3_21143_VAL_READ_OPERATION 0x00004000 -#define SBE_2T3E3_21143_VAL_WRITE_OPERATION 0x00002000 -#define SBE_2T3E3_21143_VAL_BOOT_ROM_SELECT 0x00001000 -#define SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT 0x00000800 -#define SBE_2T3E3_21143_VAL_BOOT_ROM_DATA 0x000000ff -#define SBE_2T3E3_21143_VAL_SERIAL_ROM_DATA_OUT 0x00000008 -#define SBE_2T3E3_21143_VAL_SERIAL_ROM_DATA_IN 0x00000004 -#define SBE_2T3E3_21143_VAL_SERIAL_ROM_CLOCK 0x00000002 -#define SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT 0x00000001 - -/* CSR11 - GENERAL_PURPOSE_TIMER_AND_INTERRUPT_MITIGATION_CONTROL */ -#define SBE_2T3E3_21143_VAL_CYCLE_SIZE 0x80000000 -#define SBE_2T3E3_21143_VAL_TRANSMIT_TIMER 0x78000000 -#define SBE_2T3E3_21143_VAL_NUMBER_OF_TRANSMIT_PACKETS 0x07000000 -#define SBE_2T3E3_21143_VAL_RECEIVE_TIMER 0x00f00000 -#define SBE_2T3E3_21143_VAL_NUMBER_OF_RECEIVE_PACKETS 0x000e0000 -#define SBE_2T3E3_21143_VAL_CONTINUOUS_MODE 0x00010000 -#define SBE_2T3E3_21143_VAL_TIMER_VALUE 0x0000ffff - -/* CSR12 - SIA_STATUS */ -#define SBE_2T3E3_21143_VAL_10BASE_T_RECEIVE_PORT_ACTIVITY 0x00000200 -#define SBE_2T3E3_21143_VAL_AUI_RECEIVE_PORT_ACTIVITY 0x00000100 -#define SBE_2T3E3_21143_VAL_10Mbs_LINK_STATUS 0x00000004 -#define SBE_2T3E3_21143_VAL_100Mbs_LINK_STATUS 0x00000002 -#define SBE_2T3E3_21143_VAL_MII_RECEIVE_PORT_ACTIVITY 0x00000001 - -/* CSR13 - SIA_CONNECTIVITY */ -#define SBE_2T3E3_21143_VAL_10BASE_T_OR_AUI 0x00000008 -#define SBE_2T3E3_21143_VAL_SIA_RESET 0x00000001 - -/* CSR14 - SIA_TRANSMIT_AND_RECEIVE */ -#define SBE_2T3E3_21143_VAL_100BASE_TX_FULL_DUPLEX 0x00020000 -#define SBE_2T3E3_21143_VAL_COLLISION_DETECT_ENABLE 0x00000400 -#define SBE_2T3E3_21143_VAL_COLLISION_SQUELCH_ENABLE 0x00000200 -#define SBE_2T3E3_21143_VAL_RECEIVE_SQUELCH_ENABLE 0x00000100 -#define SBE_2T3E3_21143_VAL_LINK_PULSE_SEND_ENABLE 0x00000004 -#define SBE_2T3E3_21143_VAL_ENCODER_ENABLE 0x00000001 - -/* CSR15 - SIA_AND_GENERAL_PURPOSE_PORT */ -#define SBE_2T3E3_21143_VAL_RECEIVE_WATCHDOG_DISABLE 0x00000010 -#define SBE_2T3E3_21143_VAL_AUI_BNC_MODE 0x00000008 -#define SBE_2T3E3_21143_VAL_HOST_UNJAB 0x00000002 -#define SBE_2T3E3_21143_VAL_JABBER_DISABLE 0x00000001 - -/************************************************************** - * CPLD - **************************************************************/ - -/* reg_map indexes */ -#define SBE_2T3E3_CPLD_REG_PCRA 0 -#define SBE_2T3E3_CPLD_REG_PCRB 1 -#define SBE_2T3E3_CPLD_REG_PLCR 2 -#define SBE_2T3E3_CPLD_REG_PLTR 3 -#define SBE_2T3E3_CPLD_REG_PPFR 4 -#define SBE_2T3E3_CPLD_REG_BOARD_ID 5 -#define SBE_2T3E3_CPLD_REG_FPGA_VERSION 6 -#define SBE_2T3E3_CPLD_REG_FRAMER_BASE_ADDRESS 7 -#define SBE_2T3E3_CPLD_REG_SERIAL_CHIP_SELECT 8 -#define SBE_2T3E3_CPLD_REG_STATIC_RESET 9 -#define SBE_2T3E3_CPLD_REG_PULSE_RESET 10 -#define SBE_2T3E3_CPLD_REG_FPGA_RECONFIGURATION 11 -#define SBE_2T3E3_CPLD_REG_LEDR 12 -#define SBE_2T3E3_CPLD_REG_PICSR 13 -#define SBE_2T3E3_CPLD_REG_PIER 14 -#define SBE_2T3E3_CPLD_REG_PCRC 15 -#define SBE_2T3E3_CPLD_REG_PBWF 16 -#define SBE_2T3E3_CPLD_REG_PBWL 17 - -#define SBE_2T3E3_CPLD_REG_MAX 18 - -/**********/ - -/* val_map indexes */ -#define SBE_2T3E3_CPLD_VAL_LIU_SELECT 0 -#define SBE_2T3E3_CPLD_VAL_DAC_SELECT 1 -#define SBE_2T3E3_CPLD_VAL_LOOP_TIMING_SOURCE 2 -#define SBE_2T3E3_CPLD_VAL_LIU_FRAMER_RESET 3 - -/* PCRA */ -#define SBE_2T3E3_CPLD_VAL_CRC32 0x40 -#define SBE_2T3E3_CPLD_VAL_TRANSPARENT_MODE 0x20 -#define SBE_2T3E3_CPLD_VAL_REAR_PANEL 0x10 -#define SBE_2T3E3_CPLD_VAL_RAW_MODE 0x08 -#define SBE_2T3E3_CPLD_VAL_ALT 0x04 -#define SBE_2T3E3_CPLD_VAL_LOOP_TIMING 0x02 -#define SBE_2T3E3_CPLD_VAL_LOCAL_CLOCK_E3 0x01 - -/* PCRB */ -#define SBE_2T3E3_CPLD_VAL_PAD_COUNT 0x30 -#define SBE_2T3E3_CPLD_VAL_PAD_COUNT_1 0x00 -#define SBE_2T3E3_CPLD_VAL_PAD_COUNT_2 0x10 -#define SBE_2T3E3_CPLD_VAL_PAD_COUNT_3 0x20 -#define SBE_2T3E3_CPLD_VAL_PAD_COUNT_4 0x30 -#define SBE_2T3E3_CPLD_VAL_SCRAMBLER_TYPE 0x02 -#define SBE_2T3E3_CPLD_VAL_SCRAMBLER_ENABLE 0x01 - -/* PCRC */ -#define SBE_2T3E3_CPLD_VAL_FRACTIONAL_MODE_NONE 0x00 -#define SBE_2T3E3_CPLD_VAL_FRACTIONAL_MODE_0 0x01 -#define SBE_2T3E3_CPLD_VAL_FRACTIONAL_MODE_1 0x11 -#define SBE_2T3E3_CPLD_VAL_FRACTIONAL_MODE_2 0x21 - -/* PLTR */ -#define SBE_2T3E3_CPLD_VAL_LCV_COUNTER 0xff - -/* SCSR */ -#define SBE_2T3E3_CPLD_VAL_EEPROM_SELECT 0x10 - -/* PICSR */ -#define SBE_2T3E3_CPLD_VAL_LOSS_OF_SIGNAL_THRESHOLD_LEVEL_1 0x80 -#define SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_SIGNAL_CHANGE 0x40 -#define SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_ETHERNET_ASSERTED 0x20 -#define SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_FRAMER_ASSERTED 0x10 -#define SBE_2T3E3_CPLD_VAL_LCV_LIMIT_EXCEEDED 0x08 -#define SBE_2T3E3_CPLD_VAL_DMO_SIGNAL_DETECTED 0x04 -#define SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_LOCK_DETECTED 0x02 -#define SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_SIGNAL_DETECTED 0x01 - -/* PIER */ -#define SBE_2T3E3_CPLD_VAL_RECEIVE_LOS_CHANGE_ENABLE 0x40 -#define SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_ETHERNET_ENABLE 0x20 -#define SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_FRAMER_ENABLE 0x10 -#define SBE_2T3E3_CPLD_VAL_LCV_INTERRUPT_ENABLE 0x08 -#define SBE_2T3E3_CPLD_VAL_DMO_ENABLE 0x04 -#define SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_LOCK_ENABLE 0x02 -#define SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_SIGNAL_ENABLE 0x01 - -/************************************************************** - * Framer - **************************************************************/ - -/* reg_map indexes */ -/* common */ -#define SBE_2T3E3_FRAMER_REG_OPERATING_MODE 0 -#define SBE_2T3E3_FRAMER_REG_IO_CONTROL 1 -#define SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_ENABLE 2 -#define SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_STATUS 3 -#define SBE_2T3E3_FRAMER_REG_PMON_LCV_EVENT_COUNT_MSB 28 -#define SBE_2T3E3_FRAMER_REG_PMON_LCV_EVENT_COUNT_LSB 29 -#define SBE_2T3E3_FRAMER_REG_PMON_FRAMING_BIT_ERROR_EVENT_COUNT_MSB 30 -#define SBE_2T3E3_FRAMER_REG_PMON_FRAMING_BIT_ERROR_EVENT_COUNT_LSB 31 -#define SBE_2T3E3_FRAMER_REG_PMON_PARITY_ERROR_EVENT_COUNT_MSB 32 -#define SBE_2T3E3_FRAMER_REG_PMON_PARITY_ERROR_EVENT_COUNT_LSB 33 -#define SBE_2T3E3_FRAMER_REG_PMON_FEBE_EVENT_COUNT_MSB 34 -#define SBE_2T3E3_FRAMER_REG_PMON_FEBE_EVENT_COUNT_LSB 35 -#define SBE_2T3E3_FRAMER_REG_PMON_CP_BIT_ERROR_EVENT_COUNT_MSB 36 -#define SBE_2T3E3_FRAMER_REG_PMON_CP_BIT_ERROR_EVENT_COUNT_LSB 37 -#define SBE_2T3E3_FRAMER_REG_PMON_HOLDING_REGISTER 38 -#define SBE_2T3E3_FRAMER_REG_ONE_SECOND_ERROR_STATUS 39 -#define SBE_2T3E3_FRAMER_REG_LCV_ONE_SECOND_ACCUMULATOR_MSB 40 -#define SBE_2T3E3_FRAMER_REG_LCV_ONE_SECOND_ACCUMULATOR_LSB 41 -#define SBE_2T3E3_FRAMER_REG_FRAME_PARITY_ERROR_ONE_SECOND_ACCUMULATOR_MSB 42 -#define SBE_2T3E3_FRAMER_REG_FRAME_PARITY_ERROR_ONE_SECOND_ACCUMULATOR_LSB 43 -#define SBE_2T3E3_FRAMER_REG_FRAME_CP_BIT_ERROR_ONE_SECOND_ACCUMULATOR_MSB 44 -#define SBE_2T3E3_FRAMER_REG_FRAME_CP_BIT_ERROR_ONE_SECOND_ACCUMULATOR_LSB 45 -#define SBE_2T3E3_FRAMER_REG_LINE_INTERFACE_DRIVE 46 -#define SBE_2T3E3_FRAMER_REG_LINE_INTERFACE_SCAN 47 - -/* T3 */ -#define SBE_2T3E3_FRAMER_REG_T3_RX_CONFIGURATION_STATUS 4 -#define SBE_2T3E3_FRAMER_REG_T3_RX_STATUS 5 -#define SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_ENABLE 6 -#define SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_STATUS 7 -#define SBE_2T3E3_FRAMER_REG_T3_RX_SYNC_DETECT_ENABLE 8 -#define SBE_2T3E3_FRAMER_REG_T3_RX_FEAC 10 -#define SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS 11 -#define SBE_2T3E3_FRAMER_REG_T3_RX_LAPD_CONTROL 12 -#define SBE_2T3E3_FRAMER_REG_T3_RX_LAPD_STATUS 13 -#define SBE_2T3E3_FRAMER_REG_T3_TX_CONFIGURATION 16 -#define SBE_2T3E3_FRAMER_REG_T3_TX_FEAC_CONFIGURATION_STATUS 17 -#define SBE_2T3E3_FRAMER_REG_T3_TX_FEAC 18 -#define SBE_2T3E3_FRAMER_REG_T3_TX_LAPD_CONFIGURATION 19 -#define SBE_2T3E3_FRAMER_REG_T3_TX_LAPD_STATUS 20 -#define SBE_2T3E3_FRAMER_REG_T3_TX_MBIT_MASK 21 -#define SBE_2T3E3_FRAMER_REG_T3_TX_FBIT_MASK 22 -#define SBE_2T3E3_FRAMER_REG_T3_TX_FBIT_MASK_2 23 -#define SBE_2T3E3_FRAMER_REG_T3_TX_FBIT_MASK_3 24 - -/* E3 */ -#define SBE_2T3E3_FRAMER_REG_E3_RX_CONFIGURATION_STATUS_1 4 -#define SBE_2T3E3_FRAMER_REG_E3_RX_CONFIGURATION_STATUS_2 5 -#define SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_1 6 -#define SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_2 7 -#define SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_1 8 -#define SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_2 9 -#define SBE_2T3E3_FRAMER_REG_E3_RX_LAPD_CONTROL 12 -#define SBE_2T3E3_FRAMER_REG_E3_RX_LAPD_STATUS 13 -#define SBE_2T3E3_FRAMER_REG_E3_RX_NR_BYTE 14 -#define SBE_2T3E3_FRAMER_REG_E3_RX_SERVICE_BITS 14 -#define SBE_2T3E3_FRAMER_REG_E3_RX_GC_BYTE 15 -#define SBE_2T3E3_FRAMER_REG_E3_TX_CONFIGURATION 16 -#define SBE_2T3E3_FRAMER_REG_E3_TX_LAPD_CONFIGURATION 19 -#define SBE_2T3E3_FRAMER_REG_E3_TX_LAPD_STATUS 19 -#define SBE_2T3E3_FRAMER_REG_E3_TX_GC_BYTE 21 -#define SBE_2T3E3_FRAMER_REG_E3_TX_SERVICE_BITS 21 -#define SBE_2T3E3_FRAMER_REG_E3_TX_MA_BYTE 22 -#define SBE_2T3E3_FRAMER_REG_E3_TX_NR_BYTE 23 -#define SBE_2T3E3_FRAMER_REG_E3_TX_FA1_ERROR_MASK 25 -#define SBE_2T3E3_FRAMER_REG_E3_TX_FAS_ERROR_MASK_UPPER 25 -#define SBE_2T3E3_FRAMER_REG_E3_TX_FA2_ERROR_MASK 26 -#define SBE_2T3E3_FRAMER_REG_E3_TX_FAS_ERROR_MASK_LOWER 26 -#define SBE_2T3E3_FRAMER_REG_E3_TX_BIP8_MASK 27 -#define SBE_2T3E3_FRAMER_REG_E3_TX_BIP4_MASK 27 - -#define SBE_2T3E3_FRAMER_REG_MAX 48 - -/**********/ - -/* OPERATING_MODE */ -#define SBE_2T3E3_FRAMER_VAL_LOCAL_LOOPBACK_MODE 0x80 -#define SBE_2T3E3_FRAMER_VAL_T3_E3_SELECT 0x40 -#define SBE_2T3E3_FRAMER_VAL_INTERNAL_LOS_ENABLE 0x20 -#define SBE_2T3E3_FRAMER_VAL_RESET 0x10 -#define SBE_2T3E3_FRAMER_VAL_INTERRUPT_ENABLE_RESET 0x08 -#define SBE_2T3E3_FRAMER_VAL_FRAME_FORMAT_SELECT 0x04 -#define SBE_2T3E3_FRAMER_VAL_TIMING_ASYNCH_TXINCLK 0x03 -#define SBE_2T3E3_FRAMER_VAL_E3_G751 0x00 -#define SBE_2T3E3_FRAMER_VAL_E3_G832 0x04 -#define SBE_2T3E3_FRAMER_VAL_T3_CBIT 0x40 -#define SBE_2T3E3_FRAMER_VAL_T3_M13 0x44 -#define SBE_2T3E3_FRAMER_VAL_LOOPBACK_ON 0x80 -#define SBE_2T3E3_FRAMER_VAL_LOOPBACK_OFF 0x00 - -/* IO_CONTROL */ -#define SBE_2T3E3_FRAMER_VAL_DISABLE_TX_LOSS_OF_CLOCK 0x80 -#define SBE_2T3E3_FRAMER_VAL_LOSS_OF_CLOCK_STATUS 0x40 -#define SBE_2T3E3_FRAMER_VAL_DISABLE_RX_LOSS_OF_CLOCK 0x20 -#define SBE_2T3E3_FRAMER_VAL_AMI_LINE_CODE 0x10 -#define SBE_2T3E3_FRAMER_VAL_UNIPOLAR 0x08 -#define SBE_2T3E3_FRAMER_VAL_TX_LINE_CLOCK_INVERT 0x04 -#define SBE_2T3E3_FRAMER_VAL_RX_LINE_CLOCK_INVERT 0x02 -#define SBE_2T3E3_FRAMER_VAL_REFRAME 0x01 - -/* BLOCK_INTERRUPT_ENABLE */ -#define SBE_2T3E3_FRAMER_VAL_RX_INTERRUPT_ENABLE 0x80 -#define SBE_2T3E3_FRAMER_VAL_TX_INTERRUPT_ENABLE 0x02 -#define SBE_2T3E3_FRAMER_VAL_ONE_SECOND_INTERRUPT_ENABLE 0x01 - -/* BLOCK_INTERRUPT_STATUS */ -#define SBE_2T3E3_FRAMER_VAL_RX_INTERRUPT_STATUS 0x80 -#define SBE_2T3E3_FRAMER_VAL_TX_INTERRUPT_STATUS 0x02 -#define SBE_2T3E3_FRAMER_VAL_ONE_SECOND_INTERRUPT_STATUS 0x01 - -/**********/ - -/* T3_RX_CONFIGURATION_STATUS */ -#define SBE_2T3E3_FRAMER_VAL_T3_RX_AIS 0x80 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_LOS 0x40 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_IDLE 0x20 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_OOF 0x10 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_FRAMING_ON_PARITY 0x04 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_F_SYNC_ALGO 0x02 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_M_SYNC_ALGO 0x01 - -/* T3_RX_STATUS */ -#define SBE_2T3E3_FRAMER_VAL_T3_RX_FERF 0x10 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_AIC 0x04 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_FEBE 0x07 - -/* T3_RX_INTERRUPT_ENABLE */ -#define SBE_2T3E3_FRAMER_VAL_T3_RX_CP_BIT_ERROR_INTERRUPT_ENABLE 0x80 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_LOS_INTERRUPT_ENABLE 0x40 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_AIS_INTERRUPT_ENABLE 0x20 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_IDLE_INTERRUPT_ENABLE 0x10 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_FERF_INTERRUPT_ENABLE 0x08 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_AIC_INTERRUPT_ENABLE 0x04 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_OOF_INTERRUPT_ENABLE 0x02 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_P_BIT_INTERRUPT_ENABLE 0x01 - -/* T3_RX_INTERRUPT_STATUS */ -#define SBE_2T3E3_FRAMER_VAL_T3_RX_CP_BIT_ERROR_INTERRUPT_STATUS 0x80 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_LOS_INTERRUPT_STATUS 0x40 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_AIS_INTERRUPT_STATUS 0x20 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_IDLE_INTERRUPT_STATUS 0x10 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_FERF_INTERRUPT_STATUS 0x08 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_AIC_INTERRUPT_STATUS 0x04 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_OOF_INTERRUPT_STATUS 0x02 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_P_BIT_INTERRUPT_STATUS 0x01 - -/* T3_RX_FEAC_INTERRUPT_ENABLE_STATUS */ -#define SBE_2T3E3_FRAMER_VAL_T3_RX_FEAC_VALID 0x10 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_FEAC_REMOVE_INTERRUPT_ENABLE 0x08 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_FEAC_REMOVE_INTERRUPT_STATUS 0x04 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_FEAC_VALID_INTERRUPT_ENABLE 0x02 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_FEAC_VALID_INTERRUPT_STATUS 0x01 - -/* T3_RX_LAPD_CONTROL */ -#define SBE_2T3E3_FRAMER_VAL_T3_RX_LAPD_ENABLE 0x04 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_LAPD_INTERRUPT_ENABLE 0x02 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_LAPD_INTERRUPT_STATUS 0x01 - -/* T3_RX_LAPD_STATUS */ -#define SBE_2T3E3_FRAMER_VAL_T3_RX_ABORT 0x40 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_LAPD_TYPE 0x30 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_CR_TYPE 0x08 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_FCS_ERROR 0x04 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_END_OF_MESSAGE 0x02 -#define SBE_2T3E3_FRAMER_VAL_T3_RX_FLAG_PRESENT 0x01 - -/* T3_TX_CONFIGURATION */ -#define SBE_2T3E3_FRAMER_VAL_T3_TX_YELLOW_ALARM 0x80 -#define SBE_2T3E3_FRAMER_VAL_T3_TX_X_BIT 0x40 -#define SBE_2T3E3_FRAMER_VAL_T3_TX_IDLE 0x20 -#define SBE_2T3E3_FRAMER_VAL_T3_TX_AIS 0x10 -#define SBE_2T3E3_FRAMER_VAL_T3_TX_LOS 0x08 -#define SBE_2T3E3_FRAMER_VAL_T3_TX_FERF_ON_LOS 0x04 -#define SBE_2T3E3_FRAMER_VAL_T3_TX_FERF_ON_OOF 0x02 -#define SBE_2T3E3_FRAMER_VAL_T3_TX_FERF_ON_AIS 0x01 - -/* T3_TX_FEAC_CONFIGURATION_STATUS */ -#define SBE_2T3E3_FRAMER_VAL_T3_TX_FEAC_INTERRUPT_ENABLE 0x10 -#define SBE_2T3E3_FRAMER_VAL_T3_TX_FEAC_INTERRUPT_STATUS 0x08 -#define SBE_2T3E3_FRAMER_VAL_T3_TX_FEAC_ENABLE 0x04 -#define SBE_2T3E3_FRAMER_VAL_T3_TX_FEAC_GO 0x02 -#define SBE_2T3E3_FRAMER_VAL_T3_TX_FEAC_BUSY 0x01 - -/* T3_TX_LAPD_STATUS */ -#define SBE_2T3E3_FRAMER_VAL_T3_TX_DL_START 0x08 -#define SBE_2T3E3_FRAMER_VAL_T3_TX_DL_BUSY 0x04 -#define SBE_2T3E3_FRAMER_VAL_T3_TX_LAPD_INTERRUPT_ENABLE 0x02 -#define SBE_2T3E3_FRAMER_VAL_T3_TX_LAPD_INTERRUPT_STATUS 0x01 - -/**********/ - -/* E3_RX_CONFIGURATION_STATUS_1 */ -#define SBE_2T3E3_FRAMER_VAL_E3_RX_PAYLOAD_TYPE 0xe0 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_FERF_ALGO 0x10 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_T_MARK_ALGO 0x08 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_PAYLOAD_EXPECTED 0x07 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_BIP4 0x01 - -/* E3_RX_CONFIGURATION_STATUS_2 */ -#define SBE_2T3E3_FRAMER_VAL_E3_RX_LOF_ALGO 0x80 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_LOF 0x40 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_OOF 0x20 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_LOS 0x10 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_AIS 0x08 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_PAYLOAD_UNSTABLE 0x04 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_T_MARK 0x02 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_FERF 0x01 - -/* E3_RX_INTERRUPT_ENABLE_1 */ -#define SBE_2T3E3_FRAMER_VAL_E3_RX_COFA_INTERRUPT_ENABLE 0x10 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_OOF_INTERRUPT_ENABLE 0x08 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_LOF_INTERRUPT_ENABLE 0x04 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_LOS_INTERRUPT_ENABLE 0x02 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_AIS_INTERRUPT_ENABLE 0x01 - -/* E3_RX_INTERRUPT_ENABLE_2 */ -#define SBE_2T3E3_FRAMER_VAL_E3_RX_TTB_CHANGE_INTERRUPT_ENABLE 0x40 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_FEBE_INTERRUPT_ENABLE 0x10 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_FERF_INTERRUPT_ENABLE 0x08 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_BIP8_ERROR_INTERRUPT_ENABLE 0x04 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_BIP4_ERROR_INTERRUPT_ENABLE 0x04 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_FRAMING_BYTE_ERROR_INTERRUPT_ENABLE 0x02 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_PAYLOAD_MISMATCH_INTERRUPT_ENABLE 0x01 - -/* E3_RX_INTERRUPT_STATUS_1 */ -#define SBE_2T3E3_FRAMER_VAL_E3_RX_COFA_INTERRUPT_STATUS 0x10 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_OOF_INTERRUPT_STATUS 0x08 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_LOF_INTERRUPT_STATUS 0x04 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_LOS_INTERRUPT_STATUS 0x02 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_AIS_INTERRUPT_STATUS 0x01 - -/* E3_RX_INTERRUPT_STATUS_2 */ -#define SBE_2T3E3_FRAMER_VAL_E3_RX_TTB_CHANGE_INTERRUPT_STATUS 0x40 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_FEBE_INTERRUPT_STATUS 0x10 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_FERF_INTERRUPT_STATUS 0x08 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_BIP8_ERROR_INTERRUPT_STATUS 0x04 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_BIP4_ERROR_INTERRUPT_STATUS 0x04 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_FRAMING_BYTE_ERROR_INTERRUPT_STATUS 0x02 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_PAYLOAD_MISMATCH_INTERRUPT_STATUS 0x01 - -/* E3_RX_LAPD_CONTROL */ -#define SBE_2T3E3_FRAMER_VAL_E3_RX_DL_FROM_NR 0x08 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_LAPD_ENABLE 0x04 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_LAPD_INTERRUPT_ENABLE 0x02 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_LAPD_INTERRUPT_STATUS 0x01 - -/* E3_RX_LAPD_STATUS */ -#define SBE_2T3E3_FRAMER_VAL_E3_RX_ABORT 0x40 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_LAPD_TYPE 0x30 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_CR_TYPE 0x08 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_FCS_ERROR 0x04 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_END_OF_MESSAGE 0x02 -#define SBE_2T3E3_FRAMER_VAL_E3_RX_FLAG_PRESENT 0x01 - -/* E3_TX_CONFIGURATION */ -#define SBE_2T3E3_FRAMER_VAL_E3_TX_BIP4_ENABLE 0x80 -#define SBE_2T3E3_FRAMER_VAL_E3_TX_A_SOURCE_SELECT 0x60 -#define SBE_2T3E3_FRAMER_VAL_E3_TX_DL_IN_NR 0x10 -#define SBE_2T3E3_FRAMER_VAL_E3_TX_N_SOURCE_SELECT 0x18 -#define SBE_2T3E3_FRAMER_VAL_E3_TX_AIS_ENABLE 0x04 -#define SBE_2T3E3_FRAMER_VAL_E3_TX_LOS_ENABLE 0x02 -#define SBE_2T3E3_FRAMER_VAL_E3_TX_MA_RX 0x01 -#define SBE_2T3E3_FRAMER_VAL_E3_TX_FAS_SOURCE_SELECT 0x01 - -/* E3_TX_LAPD_CONFIGURATION */ -#define SBE_2T3E3_FRAMER_VAL_E3_TX_AUTO_RETRANSMIT 0x08 -#define SBE_2T3E3_FRAMER_VAL_E3_TX_LAPD_MESSAGE_LENGTH 0x02 -#define SBE_2T3E3_FRAMER_VAL_E3_TX_LAPD_ENABLE 0x01 - -/* E3_TX_LAPD_STATUS_INTERRUPT */ -#define SBE_2T3E3_FRAMER_VAL_E3_TX_DL_START 0x08 -#define SBE_2T3E3_FRAMER_VAL_E3_TX_DL_BUSY 0x04 -#define SBE_2T3E3_FRAMER_VAL_E3_TX_LAPD_INTERRUPT_ENABLE 0x02 -#define SBE_2T3E3_FRAMER_VAL_E3_TX_LAPD_INTERRUPT_STATUS 0x01 - - - - - - -/************************************************************** - * LIU - **************************************************************/ - -/* reg_map indexes */ -#define SBE_2T3E3_LIU_REG_REG0 0 -#define SBE_2T3E3_LIU_REG_REG1 1 -#define SBE_2T3E3_LIU_REG_REG2 2 -#define SBE_2T3E3_LIU_REG_REG3 3 -#define SBE_2T3E3_LIU_REG_REG4 4 - -#define SBE_2T3E3_LIU_REG_MAX 5 - -/**********/ - -/* REG0 */ -#define SBE_2T3E3_LIU_VAL_RECEIVE_LOSS_OF_LOCK_STATUS 0x10 -#define SBE_2T3E3_LIU_VAL_RECEIVE_LOSS_OF_SIGNAL_STATUS 0x08 -#define SBE_2T3E3_LIU_VAL_ANALOG_LOSS_OF_SIGNAL_STATUS 0x04 -#define SBE_2T3E3_LIU_VAL_DIGITAL_LOSS_OF_SIGNAL_STATUS 0x02 -#define SBE_2T3E3_LIU_VAL_DMO_STATUS 0x01 - -/* REG1 */ -#define SBE_2T3E3_LIU_VAL_TRANSMITTER_OFF 0x10 -#define SBE_2T3E3_LIU_VAL_TRANSMIT_ALL_ONES 0x08 -#define SBE_2T3E3_LIU_VAL_TRANSMIT_CLOCK_INVERT 0x04 -#define SBE_2T3E3_LIU_VAL_TRANSMIT_LEVEL_SELECT 0x02 -#define SBE_2T3E3_LIU_VAL_TRANSMIT_BINARY_DATA 0x01 - -/* REG2 */ -#define SBE_2T3E3_LIU_VAL_DECODER_DISABLE 0x10 -#define SBE_2T3E3_LIU_VAL_ENCODER_DISABLE 0x08 -#define SBE_2T3E3_LIU_VAL_ANALOG_LOSS_OF_SIGNAL_DISABLE 0x04 -#define SBE_2T3E3_LIU_VAL_DIGITAL_LOSS_OF_SIGNAL_DISABLE 0x02 -#define SBE_2T3E3_LIU_VAL_RECEIVE_EQUALIZATION_DISABLE 0x01 - -/* REG3 */ -#define SBE_2T3E3_LIU_VAL_RECEIVE_BINARY_DATA 0x10 -#define SBE_2T3E3_LIU_VAL_RECOVERED_DATA_MUTING 0x08 -#define SBE_2T3E3_LIU_VAL_RECEIVE_CLOCK_OUTPUT_2 0x04 -#define SBE_2T3E3_LIU_VAL_INVERT_RECEIVE_CLOCK_2 0x02 -#define SBE_2T3E3_LIU_VAL_INVERT_RECEIVE_CLOCK_1 0x01 - -/* REG4 */ -#define SBE_2T3E3_LIU_VAL_T3_MODE_SELECT 0x00 -#define SBE_2T3E3_LIU_VAL_E3_MODE_SELECT 0x04 -#define SBE_2T3E3_LIU_VAL_LOCAL_LOOPBACK 0x02 -#define SBE_2T3E3_LIU_VAL_REMOTE_LOOPBACK 0x01 -#define SBE_2T3E3_LIU_VAL_LOOPBACK_OFF 0x00 -#define SBE_2T3E3_LIU_VAL_LOOPBACK_REMOTE 0x01 -#define SBE_2T3E3_LIU_VAL_LOOPBACK_ANALOG 0x02 -#define SBE_2T3E3_LIU_VAL_LOOPBACK_DIGITAL 0x03 - -/********************************************************************** - * - * descriptor list and data buffer - * - **********************************************************************/ -struct t3e3_rx_desc { - u32 rdes0; - u32 rdes1; - u32 rdes2; - u32 rdes3; -}; - -#define SBE_2T3E3_RX_DESC_RING_SIZE 64 - -/* RDES0 */ -#define SBE_2T3E3_RX_DESC_21143_OWN 0X80000000 -#define SBE_2T3E3_RX_DESC_FRAME_LENGTH 0x3fff0000 -#define SBE_2T3E3_RX_DESC_FRAME_LENGTH_SHIFT 16 -#define SBE_2T3E3_RX_DESC_ERROR_SUMMARY 0x00008000 -#define SBE_2T3E3_RX_DESC_DESC_ERROR 0x00004000 -#define SBE_2T3E3_RX_DESC_DATA_TYPE 0x00003000 -#define SBE_2T3E3_RX_DESC_RUNT_FRAME 0x00000800 -#define SBE_2T3E3_RX_DESC_FIRST_DESC 0x00000200 -#define SBE_2T3E3_RX_DESC_LAST_DESC 0x00000100 -#define SBE_2T3E3_RX_DESC_FRAME_TOO_LONG 0x00000080 -#define SBE_2T3E3_RX_DESC_COLLISION_SEEN 0x00000040 -#define SBE_2T3E3_RX_DESC_FRAME_TYPE 0x00000020 -#define SBE_2T3E3_RX_DESC_RECEIVE_WATCHDOG 0x00000010 -#define SBE_2T3E3_RX_DESC_MII_ERROR 0x00000008 -#define SBE_2T3E3_RX_DESC_DRIBBLING_BIT 0x00000004 -#define SBE_2T3E3_RX_DESC_CRC_ERROR 0x00000002 - -/* RDES1 */ -#define SBE_2T3E3_RX_DESC_END_OF_RING 0x02000000 -#define SBE_2T3E3_RX_DESC_SECOND_ADDRESS_CHAINED 0x01000000 -#define SBE_2T3E3_RX_DESC_BUFFER_2_SIZE 0x003ff800 -#define SBE_2T3E3_RX_DESC_BUFFER_1_SIZE 0x000007ff - -/*********************/ - -struct t3e3_tx_desc { - u32 tdes0; - u32 tdes1; - u32 tdes2; - u32 tdes3; -}; - -#define SBE_2T3E3_TX_DESC_RING_SIZE 256 - -/* TDES0 */ -#define SBE_2T3E3_TX_DESC_21143_OWN 0x80000000 -#define SBE_2T3E3_TX_DESC_ERROR_SUMMARY 0x00008000 -#define SBE_2T3E3_TX_DESC_TRANSMIT_JABBER_TIMEOUT 0x00004000 -#define SBE_2T3E3_TX_DESC_LOSS_OF_CARRIER 0x00000800 -#define SBE_2T3E3_TX_DESC_NO_CARRIER 0x00000400 -#define SBE_2T3E3_TX_DESC_LINK_FAIL_REPORT 0x00000004 -#define SBE_2T3E3_TX_DESC_UNDERFLOW_ERROR 0x00000002 -#define SBE_2T3E3_TX_DESC_DEFFERED 0x00000001 - -/* TDES1 */ -#define SBE_2T3E3_TX_DESC_INTERRUPT_ON_COMPLETION 0x80000000 -#define SBE_2T3E3_TX_DESC_LAST_SEGMENT 0x40000000 -#define SBE_2T3E3_TX_DESC_FIRST_SEGMENT 0x20000000 -#define SBE_2T3E3_TX_DESC_CRC_DISABLE 0x04000000 -#define SBE_2T3E3_TX_DESC_END_OF_RING 0x02000000 -#define SBE_2T3E3_TX_DESC_SECOND_ADDRESS_CHAINED 0x01000000 -#define SBE_2T3E3_TX_DESC_DISABLE_PADDING 0x00800000 -#define SBE_2T3E3_TX_DESC_BUFFER_2_SIZE 0x003ff800 -#define SBE_2T3E3_TX_DESC_BUFFER_1_SIZE 0x000007ff - - -#define SBE_2T3E3_MTU 1600 -#define SBE_2T3E3_CRC16_LENGTH 2 -#define SBE_2T3E3_CRC32_LENGTH 4 - -#define MCLBYTES (SBE_2T3E3_MTU + 128) - -struct channel { - struct pci_dev *pdev; - struct net_device *dev; - struct card *card; - unsigned long addr; /* DECchip */ - - int leds; - - /* pci specific */ - struct { - u32 slot; /* should be 0 or 1 */ - u32 command; - u8 cache_size; - } h; - - /* statistics */ - struct t3e3_stats s; - - /* running */ - struct { - u32 flags; - } r; - - /* parameters */ - struct t3e3_param p; - - u32 liu_regs[SBE_2T3E3_LIU_REG_MAX]; /* LIU registers */ - u32 framer_regs[SBE_2T3E3_FRAMER_REG_MAX]; /* Framer registers */ - - /* Ethernet Controller */ - struct { - u_int16_t card_serial_number[3]; - - u32 reg[SBE_2T3E3_21143_REG_MAX]; /* registers i.e. CSR */ - - u32 interrupt_enable_mask; - - /* receive chain/ring */ - struct t3e3_rx_desc *rx_ring; - struct sk_buff *rx_data[SBE_2T3E3_RX_DESC_RING_SIZE]; - u32 rx_ring_current_read; - - /* transmit chain/ring */ - struct t3e3_tx_desc *tx_ring; - struct sk_buff *tx_data[SBE_2T3E3_TX_DESC_RING_SIZE]; - u32 tx_ring_current_read; - u32 tx_ring_current_write; - int tx_full; - int tx_free_cnt; - spinlock_t tx_lock; - } ether; - - int32_t interrupt_active; - int32_t rcv_count; -}; - -struct card { - spinlock_t bootrom_lock; - unsigned long bootrom_addr; - struct timer_list timer; /* for updating LEDs */ - struct channel channels[0]; -}; - -#define SBE_2T3E3_FLAG_NETWORK_UP 0x00000001 -#define SBE_2T3E3_FLAG_NO_ERROR_MESSAGES 0x00000002 - -extern const u32 cpld_reg_map[][2]; -extern const u32 cpld_val_map[][2]; -extern const u32 t3e3_framer_reg_map[]; -extern const u32 t3e3_liu_reg_map[]; - -void t3e3_init(struct channel *); -void t3e3_if_up(struct channel *); -void t3e3_if_down(struct channel *); -int t3e3_if_start_xmit(struct sk_buff *skb, struct net_device *dev); -void t3e3_if_config(struct channel *, u32, char *, struct t3e3_resp *, int *); -void t3e3_set_frame_type(struct channel *, u32); -u32 t3e3_eeprom_read_word(struct channel *, u32); -void t3e3_read_card_serial_number(struct channel *); - -/* interrupt handlers */ -irqreturn_t t3e3_intr(int irq, void *dev_instance); -void dc_intr(struct channel *); -void dc_intr_rx(struct channel *); -void dc_intr_tx(struct channel *); -void dc_intr_tx_underflow(struct channel *); -void exar7250_intr(struct channel *); -void exar7250_E3_intr(struct channel *, u32); -void exar7250_T3_intr(struct channel *, u32); - -/* Ethernet controller */ -u32 bootrom_read(struct channel *, u32); -void bootrom_write(struct channel *, u32, u32); -void dc_init(struct channel *); -void dc_start(struct channel *); -void dc_stop(struct channel *); -void dc_start_intr(struct channel *); -void dc_stop_intr(struct channel *); -void dc_reset(struct channel *); -void dc_restart(struct channel *); -void dc_receiver_onoff(struct channel *, u32); -void dc_transmitter_onoff(struct channel *, u32); -void dc_set_loopback(struct channel *, u32); -void dc_clear_descriptor_list(struct channel *); -void dc_drop_descriptor_list(struct channel *); -void dc_set_output_port(struct channel *); -void t3e3_sc_init(struct channel *); - -/* CPLD */ -void cpld_init(struct channel *sc); -u32 cpld_read(struct channel *sc, u32 reg); -void cpld_set_crc(struct channel *, u32); -void cpld_start_intr(struct channel *); -void cpld_stop_intr(struct channel *); -void cpld_set_clock(struct channel *sc, u32 mode); -void cpld_set_scrambler(struct channel *, u32); -void cpld_select_panel(struct channel *, u32); -void cpld_set_frame_mode(struct channel *, u32); -void cpld_set_frame_type(struct channel *, u32); -void cpld_set_pad_count(struct channel *, u32); -void cpld_set_fractional_mode(struct channel *, u32, u32, u32); -void cpld_LOS_update(struct channel *); - -/* Framer */ -extern u32 exar7250_read(struct channel *, u32); -extern void exar7250_write(struct channel *, u32, u32); -void exar7250_init(struct channel *); -void exar7250_start_intr(struct channel *, u32); -void exar7250_stop_intr(struct channel *, u32); -void exar7250_set_frame_type(struct channel *, u32); -void exar7250_set_loopback(struct channel *, u32); -void exar7250_unipolar_onoff(struct channel *, u32); - -/* LIU */ -u32 exar7300_read(struct channel *, u32); -void exar7300_write(struct channel *, u32, u32); -void exar7300_init(struct channel *); -void exar7300_line_build_out_onoff(struct channel *, u32); -void exar7300_set_frame_type(struct channel *, u32); -void exar7300_set_loopback(struct channel *, u32); -void exar7300_transmit_all_ones_onoff(struct channel *, u32); -void exar7300_receive_equalization_onoff(struct channel *, u32); -void exar7300_unipolar_onoff(struct channel *, u32); - -void update_led(struct channel *, int); -int setup_device(struct net_device *dev, struct channel *sc); - -static inline int has_two_ports(struct pci_dev *pdev) -{ - return pdev->subsystem_device == PCI_SUBDEVICE_ID_SBE_2T3E3_P0; -} - -#define dev_to_priv(dev) (*(struct channel **) ((hdlc_device *)(dev) + 1)) - -static inline u32 dc_read(unsigned long addr, u32 reg) -{ - return inl(addr + (reg << 3)); -} - -static inline void dc_write(unsigned long addr, u32 reg, u32 val) -{ - outl(val, addr + (reg << 3)); -} - -static inline void dc_set_bits(unsigned long addr, u32 reg, u32 bits) -{ - dc_write(addr, reg, dc_read(addr, reg) | bits); -} - -static inline void dc_clear_bits(unsigned long addr, u32 reg, u32 bits) -{ - dc_write(addr, reg, dc_read(addr, reg) & ~bits); -} - -#define CPLD_MAP_REG(reg, sc) (cpld_reg_map[(reg)][(sc)->h.slot]) - -static inline void cpld_write(struct channel *channel, unsigned reg, u32 val) -{ - unsigned long flags; - spin_lock_irqsave(&channel->card->bootrom_lock, flags); - bootrom_write(channel, CPLD_MAP_REG(reg, channel), val); - spin_unlock_irqrestore(&channel->card->bootrom_lock, flags); -} - -#define exar7250_set_bit(sc, reg, bit) \ - exar7250_write((sc), (reg), \ - exar7250_read(sc, reg) | (bit)) - -#define exar7250_clear_bit(sc, reg, bit) \ - exar7250_write((sc), (reg), \ - exar7250_read(sc, reg) & ~(bit)) - -#define exar7300_set_bit(sc, reg, bit) \ - exar7300_write((sc), (reg), \ - exar7300_read(sc, reg) | (bit)) - -#define exar7300_clear_bit(sc, reg, bit) \ - exar7300_write((sc), (reg), \ - exar7300_read(sc, reg) & ~(bit)) - - -#endif /* T3E3_H */ diff --git a/drivers/staging/sbe-2t3e3/Kconfig b/drivers/staging/sbe-2t3e3/Kconfig deleted file mode 100644 index 8ec86cfc6bf8..000000000000 --- a/drivers/staging/sbe-2t3e3/Kconfig +++ /dev/null @@ -1,13 +0,0 @@ -config SBE_2T3E3 - tristate "SBE wanPMC-2T3E3 support" - depends on HDLC && PCI - help - Driver for wanPMC-2T3E3 cards by SBE Inc. - - If you have such a card, say Y here and see - . - - To compile this as a module, choose M here: the - module will be called sbe-2t3e3. - - If unsure, say N. diff --git a/drivers/staging/sbe-2t3e3/Makefile b/drivers/staging/sbe-2t3e3/Makefile deleted file mode 100644 index cce2a7af626b..000000000000 --- a/drivers/staging/sbe-2t3e3/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -obj-$(CONFIG_SBE_2T3E3) += sbe-2t3e3.o - -sbe-2t3e3-y := module.o netdev.o maps.o \ - main.o cpld.o intr.o ctrl.o io.o dc.o exar7250.o exar7300.o diff --git a/drivers/staging/sbe-2t3e3/TODO b/drivers/staging/sbe-2t3e3/TODO deleted file mode 100644 index 624b20f70cf8..000000000000 --- a/drivers/staging/sbe-2t3e3/TODO +++ /dev/null @@ -1,6 +0,0 @@ -TODO: - - additional cleaning and tests - - wait for the new configuration interface in generic HDLC layer and - when available, convert the driver to it - -Please send patches to Krzysztof Halasa . \ No newline at end of file diff --git a/drivers/staging/sbe-2t3e3/cpld.c b/drivers/staging/sbe-2t3e3/cpld.c deleted file mode 100644 index a93b05bf992c..000000000000 --- a/drivers/staging/sbe-2t3e3/cpld.c +++ /dev/null @@ -1,352 +0,0 @@ -/* - * SBE 2T3E3 synchronous serial card driver for Linux - * - * Copyright (C) 2009-2010 Krzysztof Halasa - * - * 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 code is based on a driver written by SBE Inc. - */ - -#include -#include "2t3e3.h" -#include "ctrl.h" - -#define bootrom_set_bit(sc, reg, bit) \ - bootrom_write((sc), (reg), \ - bootrom_read((sc), (reg)) | (bit)) - -#define bootrom_clear_bit(sc, reg, bit) \ - bootrom_write((sc), (reg), \ - bootrom_read((sc), (reg)) & ~(bit)) - -static inline void cpld_set_bit(struct channel *channel, unsigned reg, u32 bit) -{ - unsigned long flags; - spin_lock_irqsave(&channel->card->bootrom_lock, flags); - bootrom_set_bit(channel, CPLD_MAP_REG(reg, channel), bit); - spin_unlock_irqrestore(&channel->card->bootrom_lock, flags); -} - -static inline void cpld_clear_bit(struct channel *channel, - unsigned reg, u32 bit) -{ - unsigned long flags; - spin_lock_irqsave(&channel->card->bootrom_lock, flags); - bootrom_clear_bit(channel, CPLD_MAP_REG(reg, channel), bit); - spin_unlock_irqrestore(&channel->card->bootrom_lock, flags); -} - -void cpld_init(struct channel *sc) -{ - u32 val; - - /* PCRA */ - val = SBE_2T3E3_CPLD_VAL_CRC32 | - cpld_val_map[SBE_2T3E3_CPLD_VAL_LOOP_TIMING_SOURCE][sc->h.slot]; - cpld_write(sc, SBE_2T3E3_CPLD_REG_PCRA, val); - - /* PCRB */ - val = 0; - cpld_write(sc, SBE_2T3E3_CPLD_REG_PCRB, val); - - /* PCRC */ - val = 0; - cpld_write(sc, SBE_2T3E3_CPLD_REG_PCRC, val); - - /* PBWF */ - val = 0; - cpld_write(sc, SBE_2T3E3_CPLD_REG_PBWF, val); - - /* PBWL */ - val = 0; - cpld_write(sc, SBE_2T3E3_CPLD_REG_PBWL, val); - - /* PLTR */ - val = SBE_2T3E3_CPLD_VAL_LCV_COUNTER; - cpld_write(sc, SBE_2T3E3_CPLD_REG_PLTR, val); - udelay(1000); - - /* PLCR */ - val = 0; - cpld_write(sc, SBE_2T3E3_CPLD_REG_PLCR, val); - udelay(1000); - - /* PPFR */ - val = 0x55; - cpld_write(sc, SBE_2T3E3_CPLD_REG_PPFR, val); - /* TODO: this doesn't work!!! */ - - /* SERIAL_CHIP_SELECT */ - val = 0; - cpld_write(sc, SBE_2T3E3_CPLD_REG_SERIAL_CHIP_SELECT, val); - - /* PICSR */ - val = SBE_2T3E3_CPLD_VAL_DMO_SIGNAL_DETECTED | - SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_LOCK_DETECTED | - SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_SIGNAL_DETECTED; - cpld_write(sc, SBE_2T3E3_CPLD_REG_PICSR, val); - - cpld_start_intr(sc); - - udelay(1000); -} - -void cpld_start_intr(struct channel *sc) -{ - u32 val; - - /* PIER */ - val = SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_ETHERNET_ENABLE | - SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_FRAMER_ENABLE; - cpld_write(sc, SBE_2T3E3_CPLD_REG_PIER, val); -} - -void cpld_stop_intr(struct channel *sc) -{ - u32 val; - - /* PIER */ - val = 0; - cpld_write(sc, SBE_2T3E3_CPLD_REG_PIER, val); -} - -void cpld_set_frame_mode(struct channel *sc, u32 mode) -{ - if (sc->p.frame_mode == mode) - return; - - switch (mode) { - case SBE_2T3E3_FRAME_MODE_HDLC: - cpld_clear_bit(sc, SBE_2T3E3_CPLD_REG_PCRA, - SBE_2T3E3_CPLD_VAL_TRANSPARENT_MODE | - SBE_2T3E3_CPLD_VAL_RAW_MODE); - exar7250_unipolar_onoff(sc, SBE_2T3E3_OFF); - exar7300_unipolar_onoff(sc, SBE_2T3E3_OFF); - break; - case SBE_2T3E3_FRAME_MODE_TRANSPARENT: - cpld_clear_bit(sc, SBE_2T3E3_CPLD_REG_PCRA, - SBE_2T3E3_CPLD_VAL_RAW_MODE); - cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRA, - SBE_2T3E3_CPLD_VAL_TRANSPARENT_MODE); - exar7250_unipolar_onoff(sc, SBE_2T3E3_OFF); - exar7300_unipolar_onoff(sc, SBE_2T3E3_OFF); - break; - case SBE_2T3E3_FRAME_MODE_RAW: - cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRA, - SBE_2T3E3_CPLD_VAL_RAW_MODE); - exar7250_unipolar_onoff(sc, SBE_2T3E3_ON); - exar7300_unipolar_onoff(sc, SBE_2T3E3_ON); - break; - default: - return; - } - - sc->p.frame_mode = mode; -} - -/* set rate of the local clock */ -void cpld_set_frame_type(struct channel *sc, u32 type) -{ - switch (type) { - case SBE_2T3E3_FRAME_TYPE_E3_G751: - case SBE_2T3E3_FRAME_TYPE_E3_G832: - cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRA, - SBE_2T3E3_CPLD_VAL_LOCAL_CLOCK_E3); - break; - case SBE_2T3E3_FRAME_TYPE_T3_CBIT: - case SBE_2T3E3_FRAME_TYPE_T3_M13: - cpld_clear_bit(sc, SBE_2T3E3_CPLD_REG_PCRA, - SBE_2T3E3_CPLD_VAL_LOCAL_CLOCK_E3); - break; - default: - return; - } -} - -void cpld_set_scrambler(struct channel *sc, u32 mode) -{ - if (sc->p.scrambler == mode) - return; - - switch (mode) { - case SBE_2T3E3_SCRAMBLER_OFF: - cpld_clear_bit(sc, SBE_2T3E3_CPLD_REG_PCRB, - SBE_2T3E3_CPLD_VAL_SCRAMBLER_ENABLE); - break; - case SBE_2T3E3_SCRAMBLER_LARSCOM: - cpld_clear_bit(sc, SBE_2T3E3_CPLD_REG_PCRB, - SBE_2T3E3_CPLD_VAL_SCRAMBLER_TYPE); - cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRB, - SBE_2T3E3_CPLD_VAL_SCRAMBLER_ENABLE); - break; - case SBE_2T3E3_SCRAMBLER_ADC_KENTROX_DIGITAL: - cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRB, - SBE_2T3E3_CPLD_VAL_SCRAMBLER_TYPE); - cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRB, - SBE_2T3E3_CPLD_VAL_SCRAMBLER_ENABLE); - break; - default: - return; - } - - sc->p.scrambler = mode; -} - - -void cpld_set_crc(struct channel *sc, u32 crc) -{ - if (sc->p.crc == crc) - return; - - switch (crc) { - case SBE_2T3E3_CRC_16: - cpld_clear_bit(sc, SBE_2T3E3_CPLD_REG_PCRA, - SBE_2T3E3_CPLD_VAL_CRC32); - break; - case SBE_2T3E3_CRC_32: - cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRA, - SBE_2T3E3_CPLD_VAL_CRC32); - break; - default: - return; - } - - sc->p.crc = crc; -} - - -void cpld_select_panel(struct channel *sc, u32 panel) -{ - if (sc->p.panel == panel) - return; - switch (panel) { - case SBE_2T3E3_PANEL_FRONT: - cpld_clear_bit(sc, SBE_2T3E3_CPLD_REG_PCRA, - SBE_2T3E3_CPLD_VAL_REAR_PANEL); - break; - case SBE_2T3E3_PANEL_REAR: - cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRA, - SBE_2T3E3_CPLD_VAL_REAR_PANEL); - break; - default: - return; - } - - udelay(100); - - sc->p.panel = panel; -} - - -void cpld_set_clock(struct channel *sc, u32 mode) -{ - if (sc->p.clock_source == mode) - return; - - switch (mode) { - case SBE_2T3E3_TIMING_LOCAL: - cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRA, - SBE_2T3E3_CPLD_VAL_ALT); - break; - case SBE_2T3E3_TIMING_LOOP: - cpld_clear_bit(sc, SBE_2T3E3_CPLD_REG_PCRA, - SBE_2T3E3_CPLD_VAL_ALT); - break; - default: - return; - } - - sc->p.clock_source = mode; -} - -void cpld_set_pad_count(struct channel *sc, u32 count) -{ - u32 val; - - if (sc->p.pad_count == count) - return; - - switch (count) { - case SBE_2T3E3_PAD_COUNT_1: - val = SBE_2T3E3_CPLD_VAL_PAD_COUNT_1; - break; - case SBE_2T3E3_PAD_COUNT_2: - val = SBE_2T3E3_CPLD_VAL_PAD_COUNT_2; - break; - case SBE_2T3E3_PAD_COUNT_3: - val = SBE_2T3E3_CPLD_VAL_PAD_COUNT_3; - break; - case SBE_2T3E3_PAD_COUNT_4: - val = SBE_2T3E3_CPLD_VAL_PAD_COUNT_4; - break; - default: - return; - } - - cpld_clear_bit(sc, SBE_2T3E3_CPLD_REG_PCRB, - SBE_2T3E3_CPLD_VAL_PAD_COUNT); - cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRB, val); - sc->p.pad_count = count; -} - -void cpld_LOS_update(struct channel *sc) -{ - u_int8_t los; - - cpld_write(sc, SBE_2T3E3_CPLD_REG_PICSR, - SBE_2T3E3_CPLD_VAL_DMO_SIGNAL_DETECTED | - SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_LOCK_DETECTED | - SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_SIGNAL_DETECTED); - los = cpld_read(sc, SBE_2T3E3_CPLD_REG_PICSR) & - SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_SIGNAL_DETECTED; - - if (los != sc->s.LOS) - dev_info(&sc->pdev->dev, "SBE 2T3E3: LOS status: %s\n", - los ? "Loss of signal" : "Signal OK"); - sc->s.LOS = los; -} - -void cpld_set_fractional_mode(struct channel *sc, u32 mode, - u32 start, u32 stop) -{ - if (mode == SBE_2T3E3_FRACTIONAL_MODE_NONE) { - start = 0; - stop = 0; - } - - if (sc->p.fractional_mode == mode && sc->p.bandwidth_start == start && - sc->p.bandwidth_stop == stop) - return; - - switch (mode) { - case SBE_2T3E3_FRACTIONAL_MODE_NONE: - cpld_write(sc, SBE_2T3E3_CPLD_REG_PCRC, - SBE_2T3E3_CPLD_VAL_FRACTIONAL_MODE_NONE); - break; - case SBE_2T3E3_FRACTIONAL_MODE_0: - cpld_write(sc, SBE_2T3E3_CPLD_REG_PCRC, - SBE_2T3E3_CPLD_VAL_FRACTIONAL_MODE_0); - break; - case SBE_2T3E3_FRACTIONAL_MODE_1: - cpld_write(sc, SBE_2T3E3_CPLD_REG_PCRC, - SBE_2T3E3_CPLD_VAL_FRACTIONAL_MODE_1); - break; - case SBE_2T3E3_FRACTIONAL_MODE_2: - cpld_write(sc, SBE_2T3E3_CPLD_REG_PCRC, - SBE_2T3E3_CPLD_VAL_FRACTIONAL_MODE_2); - break; - default: - netdev_err(sc->dev, "wrong mode in set_fractional_mode\n"); - return; - } - - cpld_write(sc, SBE_2T3E3_CPLD_REG_PBWF, start); - cpld_write(sc, SBE_2T3E3_CPLD_REG_PBWL, stop); - - sc->p.fractional_mode = mode; - sc->p.bandwidth_start = start; - sc->p.bandwidth_stop = stop; -} diff --git a/drivers/staging/sbe-2t3e3/ctrl.c b/drivers/staging/sbe-2t3e3/ctrl.c deleted file mode 100644 index e0964ac9e7d7..000000000000 --- a/drivers/staging/sbe-2t3e3/ctrl.c +++ /dev/null @@ -1,350 +0,0 @@ -/* - * SBE 2T3E3 synchronous serial card driver for Linux - * - * Copyright (C) 2009-2010 Krzysztof Halasa - * - * 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 code is based on a driver written by SBE Inc. - */ - -#include -#include "2t3e3.h" -#include "ctrl.h" - -void t3e3_set_frame_type(struct channel *sc, u32 mode) -{ - if (sc->p.frame_type == mode) - return; - - if (sc->r.flags & SBE_2T3E3_FLAG_NETWORK_UP) { - dev_err(&sc->pdev->dev, "SBE 2T3E3: changing frame type during active connection\n"); - return; - } - - exar7300_set_frame_type(sc, mode); - exar7250_set_frame_type(sc, mode); - cpld_set_frame_type(sc, mode); - - sc->p.frame_type = mode; -} - -static void t3e3_set_loopback(struct channel *sc, u32 mode) -{ - u32 tx, rx; - - if (sc->p.loopback == mode) - return; - - tx = sc->p.transmitter_on; - rx = sc->p.receiver_on; - if (tx == SBE_2T3E3_ON) - dc_transmitter_onoff(sc, SBE_2T3E3_OFF); - if (rx == SBE_2T3E3_ON) - dc_receiver_onoff(sc, SBE_2T3E3_OFF); - - /* stop current loopback if any exists */ - switch (sc->p.loopback) { - case SBE_2T3E3_LOOPBACK_NONE: - break; - case SBE_2T3E3_LOOPBACK_ETHERNET: - dc_set_loopback(sc, SBE_2T3E3_21143_VAL_LOOPBACK_OFF); - break; - case SBE_2T3E3_LOOPBACK_FRAMER: - exar7250_set_loopback(sc, SBE_2T3E3_FRAMER_VAL_LOOPBACK_OFF); - break; - case SBE_2T3E3_LOOPBACK_LIU_DIGITAL: - case SBE_2T3E3_LOOPBACK_LIU_ANALOG: - case SBE_2T3E3_LOOPBACK_LIU_REMOTE: - exar7300_set_loopback(sc, SBE_2T3E3_LIU_VAL_LOOPBACK_OFF); - break; - default: - return; - } - - switch (mode) { - case SBE_2T3E3_LOOPBACK_NONE: - break; - case SBE_2T3E3_LOOPBACK_ETHERNET: - dc_set_loopback(sc, SBE_2T3E3_21143_VAL_LOOPBACK_INTERNAL); - break; - case SBE_2T3E3_LOOPBACK_FRAMER: - exar7250_set_loopback(sc, SBE_2T3E3_FRAMER_VAL_LOOPBACK_ON); - break; - case SBE_2T3E3_LOOPBACK_LIU_DIGITAL: - exar7300_set_loopback(sc, SBE_2T3E3_LIU_VAL_LOOPBACK_DIGITAL); - break; - case SBE_2T3E3_LOOPBACK_LIU_ANALOG: - exar7300_set_loopback(sc, SBE_2T3E3_LIU_VAL_LOOPBACK_ANALOG); - break; - case SBE_2T3E3_LOOPBACK_LIU_REMOTE: - exar7300_set_loopback(sc, SBE_2T3E3_LIU_VAL_LOOPBACK_REMOTE); - break; - default: - return; - } - - sc->p.loopback = mode; - - if (tx == SBE_2T3E3_ON) - dc_transmitter_onoff(sc, SBE_2T3E3_ON); - if (rx == SBE_2T3E3_ON) - dc_receiver_onoff(sc, SBE_2T3E3_ON); -} - - -static void t3e3_reg_read(struct channel *sc, u32 *reg, u32 *val) -{ - u32 i; - - *val = 0; - - switch (reg[0]) { - case SBE_2T3E3_CHIP_21143: - if (!(reg[1] & 7)) - *val = dc_read(sc->addr, reg[1] / 8); - break; - case SBE_2T3E3_CHIP_CPLD: - for (i = 0; i < SBE_2T3E3_CPLD_REG_MAX; i++) - if (cpld_reg_map[i][sc->h.slot] == reg[1]) { - *val = cpld_read(sc, i); - break; - } - break; - case SBE_2T3E3_CHIP_FRAMER: - for (i = 0; i < SBE_2T3E3_FRAMER_REG_MAX; i++) - if (t3e3_framer_reg_map[i] == reg[1]) { - *val = exar7250_read(sc, i); - break; - } - break; - case SBE_2T3E3_CHIP_LIU: - for (i = 0; i < SBE_2T3E3_LIU_REG_MAX; i++) - if (t3e3_liu_reg_map[i] == reg[1]) { - *val = exar7300_read(sc, i); - break; - } - break; - default: - break; - } -} - -static void t3e3_reg_write(struct channel *sc, u32 *reg) -{ - u32 i; - - switch (reg[0]) { - case SBE_2T3E3_CHIP_21143: - dc_write(sc->addr, reg[1], reg[2]); - break; - case SBE_2T3E3_CHIP_CPLD: - for (i = 0; i < SBE_2T3E3_CPLD_REG_MAX; i++) - if (cpld_reg_map[i][sc->h.slot] == reg[1]) { - cpld_write(sc, i, reg[2]); - break; - } - break; - case SBE_2T3E3_CHIP_FRAMER: - for (i = 0; i < SBE_2T3E3_FRAMER_REG_MAX; i++) - if (t3e3_framer_reg_map[i] == reg[1]) { - exar7250_write(sc, i, reg[2]); - break; - } - break; - case SBE_2T3E3_CHIP_LIU: - for (i = 0; i < SBE_2T3E3_LIU_REG_MAX; i++) - if (t3e3_liu_reg_map[i] == reg[1]) { - exar7300_write(sc, i, reg[2]); - break; - } - break; - } -} - -static void t3e3_port_get(struct channel *sc, struct t3e3_param *param) -{ - memcpy(param, &(sc->p), sizeof(struct t3e3_param)); -} - -static void t3e3_port_set(struct channel *sc, struct t3e3_param *param) -{ - if (param->frame_mode != 0xff) - cpld_set_frame_mode(sc, param->frame_mode); - - if (param->fractional_mode != 0xff) - cpld_set_fractional_mode(sc, param->fractional_mode, - param->bandwidth_start, - param->bandwidth_stop); - - if (param->pad_count != 0xff) - cpld_set_pad_count(sc, param->pad_count); - - if (param->crc != 0xff) - cpld_set_crc(sc, param->crc); - - if (param->receiver_on != 0xff) - dc_receiver_onoff(sc, param->receiver_on); - - if (param->transmitter_on != 0xff) - dc_transmitter_onoff(sc, param->transmitter_on); - - if (param->frame_type != 0xff) - t3e3_set_frame_type(sc, param->frame_type); - - if (param->panel != 0xff) - cpld_select_panel(sc, param->panel); - - if (param->line_build_out != 0xff) - exar7300_line_build_out_onoff(sc, param->line_build_out); - - if (param->receive_equalization != 0xff) - exar7300_receive_equalization_onoff(sc, param->receive_equalization); - - if (param->transmit_all_ones != 0xff) - exar7300_transmit_all_ones_onoff(sc, param->transmit_all_ones); - - if (param->loopback != 0xff) - t3e3_set_loopback(sc, param->loopback); - - if (param->clock_source != 0xff) - cpld_set_clock(sc, param->clock_source); - - if (param->scrambler != 0xff) - cpld_set_scrambler(sc, param->scrambler); -} - -static void t3e3_port_get_stats(struct channel *sc, struct t3e3_stats *stats) -{ - u32 result; - - sc->s.LOC = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_IO_CONTROL) - & SBE_2T3E3_FRAMER_VAL_LOSS_OF_CLOCK_STATUS ? 1 : 0; - - switch (sc->p.frame_type) { - case SBE_2T3E3_FRAME_TYPE_E3_G751: - case SBE_2T3E3_FRAME_TYPE_E3_G832: - result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_CONFIGURATION_STATUS_2); - sc->s.LOF = result & SBE_2T3E3_FRAMER_VAL_E3_RX_LOF ? 1 : 0; - sc->s.OOF = result & SBE_2T3E3_FRAMER_VAL_E3_RX_OOF ? 1 : 0; - - cpld_LOS_update(sc); - - sc->s.AIS = result & SBE_2T3E3_FRAMER_VAL_E3_RX_AIS ? 1 : 0; - sc->s.FERF = result & SBE_2T3E3_FRAMER_VAL_E3_RX_FERF ? 1 : 0; - break; - - case SBE_2T3E3_FRAME_TYPE_T3_CBIT: - case SBE_2T3E3_FRAME_TYPE_T3_M13: - result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_CONFIGURATION_STATUS); - sc->s.AIS = result & SBE_2T3E3_FRAMER_VAL_T3_RX_AIS ? 1 : 0; - - cpld_LOS_update(sc); - - sc->s.IDLE = result & SBE_2T3E3_FRAMER_VAL_T3_RX_IDLE ? 1 : 0; - sc->s.OOF = result & SBE_2T3E3_FRAMER_VAL_T3_RX_OOF ? 1 : 0; - - result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_STATUS); - sc->s.FERF = result & SBE_2T3E3_FRAMER_VAL_T3_RX_FERF ? 1 : 0; - sc->s.AIC = result & SBE_2T3E3_FRAMER_VAL_T3_RX_AIC ? 1 : 0; - sc->s.FEBE_code = result & SBE_2T3E3_FRAMER_VAL_T3_RX_FEBE; - - sc->s.FEAC = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC); - break; - - default: - break; - } - - result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_LCV_EVENT_COUNT_MSB) << 8; - result += exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_HOLDING_REGISTER); - sc->s.LCV += result; - - result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_FRAMING_BIT_ERROR_EVENT_COUNT_MSB) << 8; - result += exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_HOLDING_REGISTER); - sc->s.FRAMING_BIT += result; - - result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_PARITY_ERROR_EVENT_COUNT_MSB) << 8; - result += exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_HOLDING_REGISTER); - sc->s.PARITY_ERROR += result; - - result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_FEBE_EVENT_COUNT_MSB) << 8; - result += exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_HOLDING_REGISTER); - sc->s.FEBE_count += result; - - result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_CP_BIT_ERROR_EVENT_COUNT_MSB) << 8; - result += exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_HOLDING_REGISTER); - sc->s.CP_BIT += result; - - memcpy(stats, &(sc->s), sizeof(struct t3e3_stats)); -} - -static void t3e3_port_del_stats(struct channel *sc) -{ - memset(&(sc->s), 0, sizeof(struct t3e3_stats)); -} - -void t3e3_if_config(struct channel *sc, u32 cmd, char *set, - struct t3e3_resp *ret, int *rlen) -{ - struct t3e3_param *param = (struct t3e3_param *)set; - u32 *data = (u32 *)set; - - /* turn off all interrupt */ - /* cpld_stop_intr(sc); */ - - switch (cmd) { - case SBE_2T3E3_PORT_GET: - t3e3_port_get(sc, &(ret->u.param)); - *rlen = sizeof(ret->u.param); - break; - case SBE_2T3E3_PORT_SET: - t3e3_port_set(sc, param); - *rlen = 0; - break; - case SBE_2T3E3_PORT_GET_STATS: - t3e3_port_get_stats(sc, &(ret->u.stats)); - *rlen = sizeof(ret->u.stats); - break; - case SBE_2T3E3_PORT_DEL_STATS: - t3e3_port_del_stats(sc); - *rlen = 0; - break; - case SBE_2T3E3_PORT_READ_REGS: - t3e3_reg_read(sc, data, &(ret->u.data)); - *rlen = sizeof(ret->u.data); - break; - case SBE_2T3E3_PORT_WRITE_REGS: - t3e3_reg_write(sc, data); - *rlen = 0; - break; - case SBE_2T3E3_LOG_LEVEL: - *rlen = 0; - break; - default: - *rlen = 0; - break; - } -} - -void t3e3_sc_init(struct channel *sc) -{ - memset(sc, 0, sizeof(*sc)); - - sc->p.frame_mode = SBE_2T3E3_FRAME_MODE_HDLC; - sc->p.fractional_mode = SBE_2T3E3_FRACTIONAL_MODE_NONE; - sc->p.crc = SBE_2T3E3_CRC_32; - sc->p.receiver_on = SBE_2T3E3_OFF; - sc->p.transmitter_on = SBE_2T3E3_OFF; - sc->p.frame_type = SBE_2T3E3_FRAME_TYPE_T3_CBIT; - sc->p.panel = SBE_2T3E3_PANEL_FRONT; - sc->p.line_build_out = SBE_2T3E3_OFF; - sc->p.receive_equalization = SBE_2T3E3_OFF; - sc->p.transmit_all_ones = SBE_2T3E3_OFF; - sc->p.loopback = SBE_2T3E3_LOOPBACK_NONE; - sc->p.clock_source = SBE_2T3E3_TIMING_LOCAL; - sc->p.scrambler = SBE_2T3E3_SCRAMBLER_OFF; - sc->p.pad_count = SBE_2T3E3_PAD_COUNT_1; -} diff --git a/drivers/staging/sbe-2t3e3/ctrl.h b/drivers/staging/sbe-2t3e3/ctrl.h deleted file mode 100644 index 41f144d75c36..000000000000 --- a/drivers/staging/sbe-2t3e3/ctrl.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * SBE 2T3E3 synchronous serial card driver for Linux - * - * Copyright (C) 2009-2010 Krzysztof Halasa - * - * 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 code is based on a driver written by SBE Inc. - */ - -#ifndef CTRL_H -#define CTRL_H - -#define SBE_2T3E3_OFF 0 -#define SBE_2T3E3_ON 1 - -#define SBE_2T3E3_LED_NONE 0 -#define SBE_2T3E3_LED_GREEN 1 -#define SBE_2T3E3_LED_YELLOW 2 - -#define SBE_2T3E3_CABLE_LENGTH_LESS_THAN_255_FEET 0 -#define SBE_2T3E3_CABLE_LENGTH_GREATER_THAN_255_FEET 1 - -#define SBE_2T3E3_CRC_16 0 -#define SBE_2T3E3_CRC_32 1 - -#define SBE_2T3E3_PANEL_FRONT 0 -#define SBE_2T3E3_PANEL_REAR 1 - -#define SBE_2T3E3_FRAME_MODE_HDLC 0 -#define SBE_2T3E3_FRAME_MODE_TRANSPARENT 1 -#define SBE_2T3E3_FRAME_MODE_RAW 2 - -#define SBE_2T3E3_FRAME_TYPE_E3_G751 0 -#define SBE_2T3E3_FRAME_TYPE_E3_G832 1 -#define SBE_2T3E3_FRAME_TYPE_T3_CBIT 2 -#define SBE_2T3E3_FRAME_TYPE_T3_M13 3 - -#define SBE_2T3E3_FRACTIONAL_MODE_NONE 0 -#define SBE_2T3E3_FRACTIONAL_MODE_0 1 -#define SBE_2T3E3_FRACTIONAL_MODE_1 2 -#define SBE_2T3E3_FRACTIONAL_MODE_2 3 - -#define SBE_2T3E3_SCRAMBLER_OFF 0 -#define SBE_2T3E3_SCRAMBLER_LARSCOM 1 -#define SBE_2T3E3_SCRAMBLER_ADC_KENTROX_DIGITAL 2 - -#define SBE_2T3E3_TIMING_LOCAL 0 -#define SBE_2T3E3_TIMING_LOOP 1 - -#define SBE_2T3E3_LOOPBACK_NONE 0 -#define SBE_2T3E3_LOOPBACK_ETHERNET 1 -#define SBE_2T3E3_LOOPBACK_FRAMER 2 -#define SBE_2T3E3_LOOPBACK_LIU_DIGITAL 3 -#define SBE_2T3E3_LOOPBACK_LIU_ANALOG 4 -#define SBE_2T3E3_LOOPBACK_LIU_REMOTE 5 - -#define SBE_2T3E3_PAD_COUNT_1 1 -#define SBE_2T3E3_PAD_COUNT_2 2 -#define SBE_2T3E3_PAD_COUNT_3 3 -#define SBE_2T3E3_PAD_COUNT_4 4 - -#define SBE_2T3E3_CHIP_21143 0 -#define SBE_2T3E3_CHIP_CPLD 1 -#define SBE_2T3E3_CHIP_FRAMER 2 -#define SBE_2T3E3_CHIP_LIU 3 - -#define SBE_2T3E3_LOG_LEVEL_NONE 0 -#define SBE_2T3E3_LOG_LEVEL_ERROR 1 -#define SBE_2T3E3_LOG_LEVEL_WARNING 2 -#define SBE_2T3E3_LOG_LEVEL_INFO 3 - -/* commands */ -#define SBE_2T3E3_PORT_GET 0 -#define SBE_2T3E3_PORT_SET 1 -#define SBE_2T3E3_PORT_GET_STATS 2 -#define SBE_2T3E3_PORT_DEL_STATS 3 -#define SBE_2T3E3_PORT_READ_REGS 4 -#define SBE_2T3E3_LOG_LEVEL 5 -#define SBE_2T3E3_PORT_WRITE_REGS 6 - -#define NG_SBE_2T3E3_NODE_TYPE "sbe2T3E3" -#define NG_SBE_2T3E3_COOKIE 0x03800891 - -struct t3e3_param { - u_int8_t frame_mode; /* FRAME_MODE_* */ - u_int8_t crc; /* CRC_* */ - u_int8_t receiver_on; /* ON/OFF */ - u_int8_t transmitter_on; /* ON/OFF */ - u_int8_t frame_type; /* FRAME_TYPE_* */ - u_int8_t panel; /* PANEL_* */ - u_int8_t line_build_out; /* ON/OFF */ - u_int8_t receive_equalization; /* ON/OFF */ - u_int8_t transmit_all_ones; /* ON/OFF */ - u_int8_t loopback; /* LOOPBACK_* */ - u_int8_t clock_source; /* TIMING_* */ - u_int8_t scrambler; /* SCRAMBLER_* */ - u_int8_t pad_count; /* PAD_COUNT_* */ - u_int8_t log_level; /* LOG_LEVEL_* - unused */ - u_int8_t fractional_mode; /* FRACTIONAL_MODE_* */ - u_int8_t bandwidth_start; /* 0-255 */ - u_int8_t bandwidth_stop; /* 0-255 */ -}; - -struct t3e3_stats { - u_int64_t in_bytes; - u32 in_packets, in_dropped; - u32 in_errors, in_error_desc, in_error_coll, in_error_drib, - in_error_crc, in_error_mii; - u_int64_t out_bytes; - u32 out_packets, out_dropped; - u32 out_errors, out_error_jab, out_error_lost_carr, - out_error_no_carr, out_error_link_fail, out_error_underflow, - out_error_dereferred; - u_int8_t LOC, LOF, OOF, LOS, AIS, FERF, IDLE, AIC, FEAC; - u_int16_t FEBE_code; - u32 LCV, FRAMING_BIT, PARITY_ERROR, FEBE_count, CP_BIT; -}; - - -struct t3e3_resp { - union { - struct t3e3_param param; - struct t3e3_stats stats; - u32 data; - } u; -}; - -#endif /* CTRL_H */ diff --git a/drivers/staging/sbe-2t3e3/dc.c b/drivers/staging/sbe-2t3e3/dc.c deleted file mode 100644 index 02510f67ac45..000000000000 --- a/drivers/staging/sbe-2t3e3/dc.c +++ /dev/null @@ -1,460 +0,0 @@ -/* - * SBE 2T3E3 synchronous serial card driver for Linux - * - * Copyright (C) 2009-2010 Krzysztof Halasa - * - * 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 code is based on a driver written by SBE Inc. - */ - -#include -#include -#include -#include -#include "2t3e3.h" -#include "ctrl.h" - -static int dc_init_descriptor_list(struct channel *sc); - -void dc_init(struct channel *sc) -{ - u32 val; - - dc_stop(sc); - /*dc_reset(sc);*/ /* do not want to reset here */ - - /* - * BUS_MODE (CSR0) - */ - val = SBE_2T3E3_21143_VAL_READ_LINE_ENABLE | - SBE_2T3E3_21143_VAL_READ_MULTIPLE_ENABLE | - SBE_2T3E3_21143_VAL_TRANSMIT_AUTOMATIC_POLLING_200us | - SBE_2T3E3_21143_VAL_BUS_ARBITRATION_RR; - - if (sc->h.command & 16) - val |= SBE_2T3E3_21143_VAL_WRITE_AND_INVALIDATE_ENABLE; - - switch (sc->h.cache_size) { - case 32: - val |= SBE_2T3E3_21143_VAL_CACHE_ALIGNMENT_32; - break; - case 16: - val |= SBE_2T3E3_21143_VAL_CACHE_ALIGNMENT_16; - break; - case 8: - val |= SBE_2T3E3_21143_VAL_CACHE_ALIGNMENT_8; - break; - default: - break; - } - - dc_write(sc->addr, SBE_2T3E3_21143_REG_BUS_MODE, val); - - /* OPERATION_MODE (CSR6) */ - val = SBE_2T3E3_21143_VAL_RECEIVE_ALL | - SBE_2T3E3_21143_VAL_MUST_BE_ONE | - SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_1 | - SBE_2T3E3_21143_VAL_LOOPBACK_OFF | - SBE_2T3E3_21143_VAL_PASS_ALL_MULTICAST | - SBE_2T3E3_21143_VAL_PROMISCUOUS_MODE | - SBE_2T3E3_21143_VAL_PASS_BAD_FRAMES; - dc_write(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE, val); - if (sc->p.loopback == SBE_2T3E3_LOOPBACK_ETHERNET) - sc->p.loopback = SBE_2T3E3_LOOPBACK_NONE; - - /* - * GENERAL_PURPOSE_TIMER_AND_INTERRUPT_MITIGATION_CONTROL (CSR11) - */ - val = SBE_2T3E3_21143_VAL_CYCLE_SIZE | - SBE_2T3E3_21143_VAL_TRANSMIT_TIMER | - SBE_2T3E3_21143_VAL_NUMBER_OF_TRANSMIT_PACKETS | - SBE_2T3E3_21143_VAL_RECEIVE_TIMER | - SBE_2T3E3_21143_VAL_NUMBER_OF_RECEIVE_PACKETS; - dc_write(sc->addr, SBE_2T3E3_21143_REG_GENERAL_PURPOSE_TIMER_AND_INTERRUPT_MITIGATION_CONTROL, val); - - /* prepare descriptors and data for receive and transmit processes */ - if (dc_init_descriptor_list(sc) != 0) - return; - - /* clear ethernet interrupts status */ - dc_write(sc->addr, SBE_2T3E3_21143_REG_STATUS, 0xFFFFFFFF); - - /* SIA mode registers */ - dc_set_output_port(sc); -} - -void dc_start(struct channel *sc) -{ - u32 val; - - if (!(sc->r.flags & SBE_2T3E3_FLAG_NETWORK_UP)) - return; - - dc_init(sc); - - /* get actual LOS and OOF status */ - switch (sc->p.frame_type) { - case SBE_2T3E3_FRAME_TYPE_E3_G751: - case SBE_2T3E3_FRAME_TYPE_E3_G832: - val = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_CONFIGURATION_STATUS_2); - dev_dbg(&sc->pdev->dev, "Start Framer Rx Status = %02X\n", val); - sc->s.OOF = val & SBE_2T3E3_FRAMER_VAL_E3_RX_OOF ? 1 : 0; - break; - case SBE_2T3E3_FRAME_TYPE_T3_CBIT: - case SBE_2T3E3_FRAME_TYPE_T3_M13: - val = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_CONFIGURATION_STATUS); - dev_dbg(&sc->pdev->dev, "Start Framer Rx Status = %02X\n", val); - sc->s.OOF = val & SBE_2T3E3_FRAMER_VAL_T3_RX_OOF ? 1 : 0; - break; - default: - break; - } - cpld_LOS_update(sc); - - /* start receive and transmit processes */ - dc_transmitter_onoff(sc, SBE_2T3E3_ON); - dc_receiver_onoff(sc, SBE_2T3E3_ON); - - /* start interrupts */ - dc_start_intr(sc); -} - -#define MAX_INT_WAIT_CNT 12000 -void dc_stop(struct channel *sc) -{ - int wcnt; - - /* stop receive and transmit processes */ - dc_receiver_onoff(sc, SBE_2T3E3_OFF); - dc_transmitter_onoff(sc, SBE_2T3E3_OFF); - - /* turn off ethernet interrupts */ - dc_stop_intr(sc); - - /* wait to ensure the interrupts have been completed */ - for (wcnt = 0; wcnt < MAX_INT_WAIT_CNT; wcnt++) { - udelay(5); - if (!sc->interrupt_active) - break; - } - if (wcnt >= MAX_INT_WAIT_CNT) - dev_warn(&sc->pdev->dev, "SBE 2T3E3: Interrupt active too long\n"); - - /* clear all receive/transmit data */ - dc_drop_descriptor_list(sc); -} - -void dc_start_intr(struct channel *sc) -{ - if (sc->p.loopback == SBE_2T3E3_LOOPBACK_NONE && sc->s.OOF) - return; - - if (sc->p.receiver_on || sc->p.transmitter_on) { - if (!sc->ether.interrupt_enable_mask) - dc_write(sc->addr, SBE_2T3E3_21143_REG_STATUS, 0xFFFFFFFF); - - sc->ether.interrupt_enable_mask = - SBE_2T3E3_21143_VAL_NORMAL_INTERRUPT_SUMMARY_ENABLE | - SBE_2T3E3_21143_VAL_ABNORMAL_INTERRUPT_SUMMARY_ENABLE | - SBE_2T3E3_21143_VAL_RECEIVE_STOPPED_ENABLE | - SBE_2T3E3_21143_VAL_RECEIVE_BUFFER_UNAVAILABLE_ENABLE | - SBE_2T3E3_21143_VAL_RECEIVE_INTERRUPT_ENABLE | - SBE_2T3E3_21143_VAL_TRANSMIT_UNDERFLOW_INTERRUPT_ENABLE | - SBE_2T3E3_21143_VAL_TRANSMIT_BUFFER_UNAVAILABLE_ENABLE | - SBE_2T3E3_21143_VAL_TRANSMIT_STOPPED_ENABLE | - SBE_2T3E3_21143_VAL_TRANSMIT_INTERRUPT_ENABLE; - - dc_write(sc->addr, SBE_2T3E3_21143_REG_INTERRUPT_ENABLE, - sc->ether.interrupt_enable_mask); - } -} - -void dc_stop_intr(struct channel *sc) -{ - sc->ether.interrupt_enable_mask = 0; - dc_write(sc->addr, SBE_2T3E3_21143_REG_INTERRUPT_ENABLE, 0); -} - -void dc_reset(struct channel *sc) -{ - /* turn off ethernet interrupts */ - dc_write(sc->addr, SBE_2T3E3_21143_REG_INTERRUPT_ENABLE, 0); - dc_write(sc->addr, SBE_2T3E3_21143_REG_STATUS, 0xFFFFFFFF); - - /* software reset */ - dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_BUS_MODE, - SBE_2T3E3_21143_VAL_SOFTWARE_RESET); - udelay(4); /* 50 PCI cycles < 2us */ - - /* clear hardware configuration */ - dc_write(sc->addr, SBE_2T3E3_21143_REG_BUS_MODE, 0); - - /* clear software configuration */ - dc_write(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE, 0); - - /* turn off SIA reset */ - dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_SIA_CONNECTIVITY, - SBE_2T3E3_21143_VAL_SIA_RESET); - dc_write(sc->addr, SBE_2T3E3_21143_REG_SIA_TRANSMIT_AND_RECEIVE, 0); - dc_write(sc->addr, SBE_2T3E3_21143_REG_SIA_AND_GENERAL_PURPOSE_PORT, 0); -} - - -void dc_receiver_onoff(struct channel *sc, u32 mode) -{ - u32 i, state = 0; - - if (sc->p.receiver_on == mode) - return; - - switch (mode) { - case SBE_2T3E3_OFF: - if (dc_read(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE) & - SBE_2T3E3_21143_VAL_RECEIVE_START) { - dc_clear_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE, - SBE_2T3E3_21143_VAL_RECEIVE_START); - - for (i = 0; i < 16; i++) { - state = dc_read(sc->addr, SBE_2T3E3_21143_REG_STATUS) & - SBE_2T3E3_21143_VAL_RECEIVE_PROCESS_STATE; - if (state == SBE_2T3E3_21143_VAL_RX_STOPPED) - break; - udelay(5); - } - if (state != SBE_2T3E3_21143_VAL_RX_STOPPED) - dev_warn(&sc->pdev->dev, "SBE 2T3E3: Rx failed to stop\n"); - else - dev_info(&sc->pdev->dev, "SBE 2T3E3: Rx off\n"); - } - break; - case SBE_2T3E3_ON: - dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE, - SBE_2T3E3_21143_VAL_RECEIVE_START); - udelay(100); - dc_write(sc->addr, SBE_2T3E3_21143_REG_RECEIVE_POLL_DEMAND, 0xFFFFFFFF); - break; - default: - return; - } - - sc->p.receiver_on = mode; -} - -void dc_transmitter_onoff(struct channel *sc, u32 mode) -{ - u32 i, state = 0; - - if (sc->p.transmitter_on == mode) - return; - - switch (mode) { - case SBE_2T3E3_OFF: - if (dc_read(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE) & - SBE_2T3E3_21143_VAL_TRANSMISSION_START) { - dc_clear_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE, - SBE_2T3E3_21143_VAL_TRANSMISSION_START); - - for (i = 0; i < 16; i++) { - state = dc_read(sc->addr, SBE_2T3E3_21143_REG_STATUS) & - SBE_2T3E3_21143_VAL_TRANSMISSION_PROCESS_STATE; - if (state == SBE_2T3E3_21143_VAL_TX_STOPPED) - break; - udelay(5); - } - if (state != SBE_2T3E3_21143_VAL_TX_STOPPED) - dev_warn(&sc->pdev->dev, "SBE 2T3E3: Tx failed to stop\n"); - } - break; - case SBE_2T3E3_ON: - dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE, - SBE_2T3E3_21143_VAL_TRANSMISSION_START); - udelay(100); - dc_write(sc->addr, SBE_2T3E3_21143_REG_TRANSMIT_POLL_DEMAND, 0xFFFFFFFF); - break; - default: - return; - } - - sc->p.transmitter_on = mode; -} - - - -void dc_set_loopback(struct channel *sc, u32 mode) -{ - u32 val; - - switch (mode) { - case SBE_2T3E3_21143_VAL_LOOPBACK_OFF: - case SBE_2T3E3_21143_VAL_LOOPBACK_INTERNAL: - break; - default: - return; - } - - /* select loopback mode */ - val = dc_read(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE) & - ~SBE_2T3E3_21143_VAL_OPERATING_MODE; - val |= mode; - dc_write(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE, val); - - if (mode == SBE_2T3E3_21143_VAL_LOOPBACK_OFF) - dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE, - SBE_2T3E3_21143_VAL_FULL_DUPLEX_MODE); - else - dc_clear_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE, - SBE_2T3E3_21143_VAL_FULL_DUPLEX_MODE); -} - -static int dc_init_descriptor_list(struct channel *sc) -{ - u32 i, j; - struct sk_buff *m; - - if (sc->ether.rx_ring == NULL) - sc->ether.rx_ring = kcalloc(SBE_2T3E3_RX_DESC_RING_SIZE, - sizeof(struct t3e3_rx_desc), GFP_KERNEL); - if (sc->ether.rx_ring == NULL) - return -ENOMEM; - - if (sc->ether.tx_ring == NULL) - sc->ether.tx_ring = kcalloc(SBE_2T3E3_TX_DESC_RING_SIZE, - sizeof(struct t3e3_tx_desc), GFP_KERNEL); - if (sc->ether.tx_ring == NULL) { - kfree(sc->ether.rx_ring); - sc->ether.rx_ring = NULL; - return -ENOMEM; - } - - - /* - * Receive ring - */ - for (i = 0; i < SBE_2T3E3_RX_DESC_RING_SIZE; i++) { - sc->ether.rx_ring[i].rdes0 = SBE_2T3E3_RX_DESC_21143_OWN; - sc->ether.rx_ring[i].rdes1 = - SBE_2T3E3_RX_DESC_SECOND_ADDRESS_CHAINED | SBE_2T3E3_MTU; - - if (sc->ether.rx_data[i] == NULL) { - m = dev_alloc_skb(MCLBYTES); - if (!m) { - for (j = 0; j < i; j++) { - dev_kfree_skb_any(sc->ether.rx_data[j]); - sc->ether.rx_data[j] = NULL; - } - kfree(sc->ether.rx_ring); - sc->ether.rx_ring = NULL; - kfree(sc->ether.tx_ring); - sc->ether.tx_ring = NULL; - dev_err(&sc->pdev->dev, "SBE 2T3E3: token_alloc err:" - " no buffer space for RX ring\n"); - return -ENOBUFS; - } - sc->ether.rx_data[i] = m; - } - sc->ether.rx_ring[i].rdes2 = virt_to_phys(sc->ether.rx_data[i]->data); - - sc->ether.rx_ring[i].rdes3 = virt_to_phys( - &sc->ether.rx_ring[(i + 1) % SBE_2T3E3_RX_DESC_RING_SIZE]); - } - sc->ether.rx_ring[SBE_2T3E3_RX_DESC_RING_SIZE - 1].rdes1 |= - SBE_2T3E3_RX_DESC_END_OF_RING; - sc->ether.rx_ring_current_read = 0; - - dc_write(sc->addr, SBE_2T3E3_21143_REG_RECEIVE_LIST_BASE_ADDRESS, - virt_to_phys(&sc->ether.rx_ring[0])); - - /* - * Transmit ring - */ - for (i = 0; i < SBE_2T3E3_TX_DESC_RING_SIZE; i++) { - sc->ether.tx_ring[i].tdes0 = 0; - sc->ether.tx_ring[i].tdes1 = SBE_2T3E3_TX_DESC_SECOND_ADDRESS_CHAINED | - SBE_2T3E3_TX_DESC_DISABLE_PADDING; - - sc->ether.tx_ring[i].tdes2 = 0; - sc->ether.tx_data[i] = NULL; - - sc->ether.tx_ring[i].tdes3 = virt_to_phys( - &sc->ether.tx_ring[(i + 1) % SBE_2T3E3_TX_DESC_RING_SIZE]); - } - sc->ether.tx_ring[SBE_2T3E3_TX_DESC_RING_SIZE - 1].tdes1 |= - SBE_2T3E3_TX_DESC_END_OF_RING; - - dc_write(sc->addr, SBE_2T3E3_21143_REG_TRANSMIT_LIST_BASE_ADDRESS, - virt_to_phys(&sc->ether.tx_ring[0])); - sc->ether.tx_ring_current_read = 0; - sc->ether.tx_ring_current_write = 0; - sc->ether.tx_free_cnt = SBE_2T3E3_TX_DESC_RING_SIZE; - spin_lock_init(&sc->ether.tx_lock); - - return 0; -} - -void dc_clear_descriptor_list(struct channel *sc) -{ - u32 i; - - /* clear CSR3 and CSR4 */ - dc_write(sc->addr, SBE_2T3E3_21143_REG_RECEIVE_LIST_BASE_ADDRESS, 0); - dc_write(sc->addr, SBE_2T3E3_21143_REG_TRANSMIT_LIST_BASE_ADDRESS, 0); - - /* free all data buffers on TX ring */ - for (i = 0; i < SBE_2T3E3_TX_DESC_RING_SIZE; i++) { - if (sc->ether.tx_data[i] != NULL) { - dev_kfree_skb_any(sc->ether.tx_data[i]); - sc->ether.tx_data[i] = NULL; - } - } -} - -void dc_drop_descriptor_list(struct channel *sc) -{ - u32 i; - - dc_clear_descriptor_list(sc); - - /* free all data buffers on RX ring */ - for (i = 0; i < SBE_2T3E3_RX_DESC_RING_SIZE; i++) { - if (sc->ether.rx_data[i] != NULL) { - dev_kfree_skb_any(sc->ether.rx_data[i]); - sc->ether.rx_data[i] = NULL; - } - } - - kfree(sc->ether.rx_ring); - sc->ether.rx_ring = NULL; - kfree(sc->ether.tx_ring); - sc->ether.tx_ring = NULL; -} - - -void dc_set_output_port(struct channel *sc) -{ - dc_clear_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE, - SBE_2T3E3_21143_VAL_PORT_SELECT); - - dc_write(sc->addr, SBE_2T3E3_21143_REG_SIA_STATUS, 0x00000301); - dc_write(sc->addr, SBE_2T3E3_21143_REG_SIA_CONNECTIVITY, 0); - dc_write(sc->addr, SBE_2T3E3_21143_REG_SIA_TRANSMIT_AND_RECEIVE, 0); - dc_write(sc->addr, SBE_2T3E3_21143_REG_SIA_AND_GENERAL_PURPOSE_PORT, 0x08000011); - - dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE, - SBE_2T3E3_21143_VAL_TRANSMIT_THRESHOLD_MODE_100Mbs | - SBE_2T3E3_21143_VAL_HEARTBEAT_DISABLE | - SBE_2T3E3_21143_VAL_PORT_SELECT | - SBE_2T3E3_21143_VAL_FULL_DUPLEX_MODE); -} - -void dc_restart(struct channel *sc) -{ - dev_warn(&sc->pdev->dev, "SBE 2T3E3: 21143 restart\n"); - - dc_stop(sc); - dc_reset(sc); - dc_init(sc); /* stop + reset + init */ - dc_start(sc); -} diff --git a/drivers/staging/sbe-2t3e3/exar7250.c b/drivers/staging/sbe-2t3e3/exar7250.c deleted file mode 100644 index e3ddd140207e..000000000000 --- a/drivers/staging/sbe-2t3e3/exar7250.c +++ /dev/null @@ -1,185 +0,0 @@ -/* - * SBE 2T3E3 synchronous serial card driver for Linux - * - * Copyright (C) 2009-2010 Krzysztof Halasa - * - * 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 code is based on a driver written by SBE Inc. - */ - -#include "2t3e3.h" -#include "ctrl.h" - -void exar7250_init(struct channel *sc) -{ - exar7250_write(sc, SBE_2T3E3_FRAMER_REG_OPERATING_MODE, - SBE_2T3E3_FRAMER_VAL_T3_CBIT | - SBE_2T3E3_FRAMER_VAL_INTERRUPT_ENABLE_RESET | - SBE_2T3E3_FRAMER_VAL_TIMING_ASYNCH_TXINCLK); - - exar7250_write(sc, SBE_2T3E3_FRAMER_REG_IO_CONTROL, - SBE_2T3E3_FRAMER_VAL_DISABLE_TX_LOSS_OF_CLOCK | - SBE_2T3E3_FRAMER_VAL_DISABLE_RX_LOSS_OF_CLOCK | - SBE_2T3E3_FRAMER_VAL_AMI_LINE_CODE | - SBE_2T3E3_FRAMER_VAL_RX_LINE_CLOCK_INVERT); - - exar7250_set_frame_type(sc, SBE_2T3E3_FRAME_TYPE_T3_CBIT); -} - -void exar7250_set_frame_type(struct channel *sc, u32 type) -{ - u32 val; - - switch (type) { - case SBE_2T3E3_FRAME_TYPE_E3_G751: - case SBE_2T3E3_FRAME_TYPE_E3_G832: - case SBE_2T3E3_FRAME_TYPE_T3_CBIT: - case SBE_2T3E3_FRAME_TYPE_T3_M13: - break; - default: - return; - } - - exar7250_stop_intr(sc, type); - - val = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_OPERATING_MODE); - val &= ~(SBE_2T3E3_FRAMER_VAL_LOCAL_LOOPBACK_MODE | - SBE_2T3E3_FRAMER_VAL_T3_E3_SELECT | - SBE_2T3E3_FRAMER_VAL_FRAME_FORMAT_SELECT); - switch (type) { - case SBE_2T3E3_FRAME_TYPE_E3_G751: - val |= SBE_2T3E3_FRAMER_VAL_E3_G751; - break; - case SBE_2T3E3_FRAME_TYPE_E3_G832: - val |= SBE_2T3E3_FRAMER_VAL_E3_G832; - break; - case SBE_2T3E3_FRAME_TYPE_T3_CBIT: - val |= SBE_2T3E3_FRAMER_VAL_T3_CBIT; - break; - case SBE_2T3E3_FRAME_TYPE_T3_M13: - val |= SBE_2T3E3_FRAMER_VAL_T3_M13; - break; - default: - return; - } - exar7250_write(sc, SBE_2T3E3_FRAMER_REG_OPERATING_MODE, val); - exar7250_start_intr(sc, type); -} - - -void exar7250_start_intr(struct channel *sc, u32 type) -{ - u32 val; - - switch (type) { - case SBE_2T3E3_FRAME_TYPE_E3_G751: - case SBE_2T3E3_FRAME_TYPE_E3_G832: - val = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_CONFIGURATION_STATUS_2); - - cpld_LOS_update(sc); - - sc->s.OOF = val & SBE_2T3E3_FRAMER_VAL_E3_RX_OOF ? 1 : 0; - exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_1); - exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_1, - SBE_2T3E3_FRAMER_VAL_E3_RX_OOF_INTERRUPT_ENABLE | - SBE_2T3E3_FRAMER_VAL_E3_RX_LOS_INTERRUPT_ENABLE); - - exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_2); - break; - - case SBE_2T3E3_FRAME_TYPE_T3_CBIT: - case SBE_2T3E3_FRAME_TYPE_T3_M13: - val = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_CONFIGURATION_STATUS); - - cpld_LOS_update(sc); - - sc->s.OOF = val & SBE_2T3E3_FRAMER_VAL_T3_RX_OOF ? 1 : 0; - - exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_STATUS); - exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_ENABLE, - SBE_2T3E3_FRAMER_VAL_T3_RX_LOS_INTERRUPT_ENABLE | - SBE_2T3E3_FRAMER_VAL_T3_RX_OOF_INTERRUPT_ENABLE); - - exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS); - - exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_LAPD_CONTROL, 0); - break; - - default: - return; - } - - exar7250_read(sc, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_STATUS); - exar7250_write(sc, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_ENABLE, - SBE_2T3E3_FRAMER_VAL_RX_INTERRUPT_ENABLE | - SBE_2T3E3_FRAMER_VAL_TX_INTERRUPT_ENABLE); -} - - -void exar7250_stop_intr(struct channel *sc, u32 type) -{ - exar7250_write(sc, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_ENABLE, 0); - exar7250_read(sc, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_STATUS); - - switch (type) { - case SBE_2T3E3_FRAME_TYPE_E3_G751: - case SBE_2T3E3_FRAME_TYPE_E3_G832: - exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_1, 0); - exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_1); - exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_2, 0); - exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_2); - exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_RX_LAPD_CONTROL, 0); - exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_LAPD_CONTROL); - exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_TX_LAPD_STATUS, 0); - exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_TX_LAPD_STATUS); - break; - - case SBE_2T3E3_FRAME_TYPE_T3_CBIT: - case SBE_2T3E3_FRAME_TYPE_T3_M13: - exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_ENABLE, 0); - exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_STATUS); - exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS, 0); - exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS); - exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_LAPD_CONTROL, 0); - exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_LAPD_CONTROL); - exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_TX_FEAC_CONFIGURATION_STATUS, 0); - exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_TX_FEAC_CONFIGURATION_STATUS); - exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_TX_LAPD_STATUS, 0); - exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_TX_LAPD_STATUS); - break; - } -} - - - - -void exar7250_unipolar_onoff(struct channel *sc, u32 mode) -{ - switch (mode) { - case SBE_2T3E3_OFF: - exar7300_clear_bit(sc, SBE_2T3E3_FRAMER_REG_IO_CONTROL, - SBE_2T3E3_FRAMER_VAL_UNIPOLAR); - break; - case SBE_2T3E3_ON: - exar7300_set_bit(sc, SBE_2T3E3_FRAMER_REG_IO_CONTROL, - SBE_2T3E3_FRAMER_VAL_UNIPOLAR); - break; - } -} - -void exar7250_set_loopback(struct channel *sc, u32 mode) -{ - switch (mode) { - case SBE_2T3E3_FRAMER_VAL_LOOPBACK_OFF: - exar7300_clear_bit(sc, SBE_2T3E3_FRAMER_REG_OPERATING_MODE, - SBE_2T3E3_FRAMER_VAL_LOCAL_LOOPBACK_MODE); - break; - case SBE_2T3E3_FRAMER_VAL_LOOPBACK_ON: - exar7300_set_bit(sc, SBE_2T3E3_FRAMER_REG_OPERATING_MODE, - SBE_2T3E3_FRAMER_VAL_LOCAL_LOOPBACK_MODE); - break; - } -} diff --git a/drivers/staging/sbe-2t3e3/exar7300.c b/drivers/staging/sbe-2t3e3/exar7300.c deleted file mode 100644 index cd229998a62e..000000000000 --- a/drivers/staging/sbe-2t3e3/exar7300.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * SBE 2T3E3 synchronous serial card driver for Linux - * - * Copyright (C) 2009-2010 Krzysztof Halasa - * - * 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 code is based on a driver written by SBE Inc. - */ - -#include "2t3e3.h" -#include "ctrl.h" - -void exar7300_init(struct channel *sc) -{ - exar7300_write(sc, SBE_2T3E3_LIU_REG_REG1, 0); - - /* enable line decodeer and encoder */ - exar7300_write(sc, SBE_2T3E3_LIU_REG_REG2, 0); - exar7300_write(sc, SBE_2T3E3_LIU_REG_REG3, 0); - exar7300_write(sc, SBE_2T3E3_LIU_REG_REG4, - SBE_2T3E3_LIU_VAL_T3_MODE_SELECT | - SBE_2T3E3_LIU_VAL_LOOPBACK_OFF); -} - -void exar7300_set_loopback(struct channel *sc, u32 mode) -{ - u32 val; - - switch (mode) { - case SBE_2T3E3_LIU_VAL_LOOPBACK_OFF: - case SBE_2T3E3_LIU_VAL_LOOPBACK_REMOTE: - case SBE_2T3E3_LIU_VAL_LOOPBACK_ANALOG: - case SBE_2T3E3_LIU_VAL_LOOPBACK_DIGITAL: - break; - default: - return; - } - - val = exar7300_read(sc, SBE_2T3E3_LIU_REG_REG4); - val &= ~(SBE_2T3E3_LIU_VAL_LOCAL_LOOPBACK | SBE_2T3E3_LIU_VAL_REMOTE_LOOPBACK); - val |= mode; - exar7300_write(sc, SBE_2T3E3_LIU_REG_REG4, val); -} - -void exar7300_set_frame_type(struct channel *sc, u32 type) -{ - u32 val; - - switch (type) { - case SBE_2T3E3_FRAME_TYPE_T3_CBIT: - case SBE_2T3E3_FRAME_TYPE_T3_M13: - case SBE_2T3E3_FRAME_TYPE_E3_G751: - case SBE_2T3E3_FRAME_TYPE_E3_G832: - break; - default: - return; - } - - val = exar7300_read(sc, SBE_2T3E3_LIU_REG_REG4); - val &= ~(SBE_2T3E3_LIU_VAL_T3_MODE_SELECT | - SBE_2T3E3_LIU_VAL_E3_MODE_SELECT); - - switch (type) { - case SBE_2T3E3_FRAME_TYPE_T3_CBIT: - case SBE_2T3E3_FRAME_TYPE_T3_M13: - val |= SBE_2T3E3_LIU_VAL_T3_MODE_SELECT; - break; - case SBE_2T3E3_FRAME_TYPE_E3_G751: - case SBE_2T3E3_FRAME_TYPE_E3_G832: - val |= SBE_2T3E3_LIU_VAL_E3_MODE_SELECT; - break; - default: - return; - } - - exar7300_write(sc, SBE_2T3E3_LIU_REG_REG4, val); -} - - -void exar7300_transmit_all_ones_onoff(struct channel *sc, u32 mode) -{ - if (sc->p.transmit_all_ones == mode) - return; - - switch (mode) { - case SBE_2T3E3_ON: - exar7300_set_bit(sc, SBE_2T3E3_LIU_REG_REG1, - SBE_2T3E3_LIU_VAL_TRANSMIT_ALL_ONES); - break; - case SBE_2T3E3_OFF: - exar7300_clear_bit(sc, SBE_2T3E3_LIU_REG_REG1, - SBE_2T3E3_LIU_VAL_TRANSMIT_ALL_ONES); - break; - default: - return; - } - - sc->p.transmit_all_ones = mode; -} - -void exar7300_receive_equalization_onoff(struct channel *sc, u32 mode) -{ - if (sc->p.receive_equalization == mode) - return; - - switch (mode) { - case SBE_2T3E3_OFF: - exar7300_set_bit(sc, SBE_2T3E3_LIU_REG_REG2, - SBE_2T3E3_LIU_VAL_RECEIVE_EQUALIZATION_DISABLE); - break; - case SBE_2T3E3_ON: - exar7300_clear_bit(sc, SBE_2T3E3_LIU_REG_REG2, - SBE_2T3E3_LIU_VAL_RECEIVE_EQUALIZATION_DISABLE); - break; - default: - return; - } - - sc->p.receive_equalization = mode; -} - -void exar7300_line_build_out_onoff(struct channel *sc, u32 mode) -{ - if (sc->p.line_build_out == mode) - return; - - switch (mode) { - case SBE_2T3E3_OFF: - exar7300_set_bit(sc, SBE_2T3E3_LIU_REG_REG1, - SBE_2T3E3_LIU_VAL_TRANSMIT_LEVEL_SELECT); - exar7300_receive_equalization_onoff(sc, SBE_2T3E3_OFF); - break; - case SBE_2T3E3_ON: - exar7300_clear_bit(sc, SBE_2T3E3_LIU_REG_REG1, - SBE_2T3E3_LIU_VAL_TRANSMIT_LEVEL_SELECT); - exar7300_receive_equalization_onoff(sc, SBE_2T3E3_ON); - break; - default: - return; - } - - sc->p.line_build_out = mode; -} - -/* TODO - what about encoder in raw mode??? disable it too? */ -void exar7300_unipolar_onoff(struct channel *sc, u32 mode) -{ - switch (mode) { - case SBE_2T3E3_OFF: - exar7300_clear_bit(sc, SBE_2T3E3_LIU_REG_REG3, - SBE_2T3E3_LIU_VAL_DECODER_DISABLE); - exar7300_clear_bit(sc, SBE_2T3E3_LIU_REG_REG1, - SBE_2T3E3_LIU_VAL_TRANSMIT_BINARY_DATA); - break; - case SBE_2T3E3_ON: - exar7300_set_bit(sc, SBE_2T3E3_LIU_REG_REG3, - SBE_2T3E3_LIU_VAL_DECODER_DISABLE); - exar7300_set_bit(sc, SBE_2T3E3_LIU_REG_REG1, - SBE_2T3E3_LIU_VAL_TRANSMIT_BINARY_DATA); - break; - } -} diff --git a/drivers/staging/sbe-2t3e3/intr.c b/drivers/staging/sbe-2t3e3/intr.c deleted file mode 100644 index 1bf74b788008..000000000000 --- a/drivers/staging/sbe-2t3e3/intr.c +++ /dev/null @@ -1,579 +0,0 @@ -/* - * SBE 2T3E3 synchronous serial card driver for Linux - * - * Copyright (C) 2009-2010 Krzysztof Halasa - * - * 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 code is based on a driver written by SBE Inc. - */ - -#include -#include -#include -#include "2t3e3.h" - -irqreturn_t t3e3_intr(int irq, void *dev_instance) -{ - struct channel *sc = dev_to_priv(dev_instance); - u32 val; - irqreturn_t ret = IRQ_NONE; - - sc->interrupt_active = 1; - - val = cpld_read(sc, SBE_2T3E3_CPLD_REG_PICSR); - - if (val & SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_SIGNAL_CHANGE) { - dev_dbg(&sc->pdev->dev, - "Rx LOS Chng Int r=%02x (LOS|OOF=%02x)\n", - val, (sc->s.LOS << 4) | sc->s.OOF); - cpld_LOS_update(sc); - ret = IRQ_HANDLED; - } - - if (val & SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_ETHERNET_ASSERTED) { - dc_intr(sc); - ret = IRQ_HANDLED; - } - - if (val & SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_FRAMER_ASSERTED) { - exar7250_intr(sc); - ret = IRQ_HANDLED; - } - - /* - we don't care about other interrupt sources (DMO, LOS, LCV) because - they are handled by Framer too - */ - - sc->interrupt_active = 0; - return ret; -} - -void dc_intr(struct channel *sc) -{ - u32 val; - - /* disable ethernet interrupts */ - /* grrr this clears interrupt summary bits !!! */ - dc_write(sc->addr, SBE_2T3E3_21143_REG_INTERRUPT_ENABLE, 0); - - while ((val = dc_read(sc->addr, SBE_2T3E3_21143_REG_STATUS)) & - (SBE_2T3E3_21143_VAL_RECEIVE_PROCESS_STOPPED | - SBE_2T3E3_21143_VAL_RECEIVE_BUFFER_UNAVAILABLE | - SBE_2T3E3_21143_VAL_RECEIVE_INTERRUPT | - SBE_2T3E3_21143_VAL_TRANSMIT_UNDERFLOW | - SBE_2T3E3_21143_VAL_TRANSMIT_BUFFER_UNAVAILABLE | - SBE_2T3E3_21143_VAL_TRANSMIT_PROCESS_STOPPED | - SBE_2T3E3_21143_VAL_TRANSMIT_INTERRUPT)) { - dc_write(sc->addr, SBE_2T3E3_21143_REG_STATUS, val); - - dev_dbg(&sc->pdev->dev, "SBE 2T3E3: Ethernet controller interrupt! (CSR5 = %08X)\n", - val); - - if (val & (SBE_2T3E3_21143_VAL_RECEIVE_INTERRUPT | - SBE_2T3E3_21143_VAL_RECEIVE_BUFFER_UNAVAILABLE | - SBE_2T3E3_21143_VAL_RECEIVE_PROCESS_STOPPED)) { - if (val & SBE_2T3E3_21143_VAL_RECEIVE_INTERRUPT) - dev_dbg(&sc->pdev->dev, - "Receive interrupt (LOS=%d, OOF=%d)\n", - sc->s.LOS, sc->s.OOF); - if (val & SBE_2T3E3_21143_VAL_RECEIVE_BUFFER_UNAVAILABLE) - dev_dbg(&sc->pdev->dev, - "Receive buffer unavailable\n"); - if (val & SBE_2T3E3_21143_VAL_RECEIVE_PROCESS_STOPPED) - dev_dbg(&sc->pdev->dev, - "Receive process stopped\n"); - dc_intr_rx(sc); - } - - if (val & SBE_2T3E3_21143_VAL_TRANSMIT_UNDERFLOW) { - dev_dbg(&sc->pdev->dev, "Transmit underflow\n"); - dc_intr_tx_underflow(sc); - } - - if (val & (SBE_2T3E3_21143_VAL_TRANSMIT_BUFFER_UNAVAILABLE | - SBE_2T3E3_21143_VAL_TRANSMIT_INTERRUPT | - SBE_2T3E3_21143_VAL_TRANSMIT_PROCESS_STOPPED)) { - if (val & SBE_2T3E3_21143_VAL_TRANSMIT_INTERRUPT) - dev_dbg(&sc->pdev->dev, "Transmit interrupt\n"); - if (val & SBE_2T3E3_21143_VAL_TRANSMIT_BUFFER_UNAVAILABLE) - dev_dbg(&sc->pdev->dev, - "Transmit buffer unavailable\n"); - if (val & SBE_2T3E3_21143_VAL_TRANSMIT_PROCESS_STOPPED) - dev_dbg(&sc->pdev->dev, - "Transmit process stopped\n"); - dc_intr_tx(sc); - } - } - - /* enable ethernet interrupts */ - dc_write(sc->addr, SBE_2T3E3_21143_REG_INTERRUPT_ENABLE, - sc->ether.interrupt_enable_mask); -} - -void dc_intr_rx(struct channel *sc) -{ - u32 current_read; - u32 error_mask, error; - struct t3e3_rx_desc *current_desc; - struct sk_buff *m, *m2; - unsigned rcv_len; - - sc->rcv_count++; /* for the activity LED */ - - current_read = sc->ether.rx_ring_current_read; - dev_dbg(&sc->pdev->dev, "intr_rx current_read = %d\n", current_read); - - /* when ethernet loopback is set, ignore framer signals */ - if ((sc->p.loopback != SBE_2T3E3_LOOPBACK_ETHERNET) && sc->s.OOF) { - while (!(sc->ether.rx_ring[current_read].rdes0 & - SBE_2T3E3_RX_DESC_21143_OWN)) { - current_desc = &sc->ether.rx_ring[current_read]; - current_desc->rdes1 &= SBE_2T3E3_RX_DESC_END_OF_RING | - SBE_2T3E3_RX_DESC_SECOND_ADDRESS_CHAINED; - current_desc->rdes1 |= SBE_2T3E3_MTU; - current_desc->rdes0 = SBE_2T3E3_RX_DESC_21143_OWN; - current_read = (current_read + 1) % SBE_2T3E3_RX_DESC_RING_SIZE; - } - sc->ether.rx_ring_current_read = current_read; - return; - } - - while (!(sc->ether.rx_ring[current_read].rdes0 & - SBE_2T3E3_RX_DESC_21143_OWN)) { - current_desc = &sc->ether.rx_ring[current_read]; - - dev_dbg(&sc->pdev->dev, "rdes0: %08X rdes1: %08X\n", - current_desc->rdes0, current_desc->rdes1); - - m = sc->ether.rx_data[current_read]; - rcv_len = (current_desc->rdes0 & SBE_2T3E3_RX_DESC_FRAME_LENGTH) >> - SBE_2T3E3_RX_DESC_FRAME_LENGTH_SHIFT; - - dev_dbg(&sc->pdev->dev, "mbuf was received (mbuf len = %d)\n", - rcv_len); - - switch (sc->p.crc) { - case SBE_2T3E3_CRC_16: - rcv_len -= SBE_2T3E3_CRC16_LENGTH; - break; - case SBE_2T3E3_CRC_32: - rcv_len -= SBE_2T3E3_CRC32_LENGTH; - break; - default: - break; - } - - if (current_desc->rdes0 & SBE_2T3E3_RX_DESC_LAST_DESC) { - - /* TODO: is collision possible? */ - error_mask = SBE_2T3E3_RX_DESC_DESC_ERROR | - SBE_2T3E3_RX_DESC_COLLISION_SEEN | - SBE_2T3E3_RX_DESC_DRIBBLING_BIT; - - switch (sc->p.frame_mode) { - case SBE_2T3E3_FRAME_MODE_HDLC: - error_mask |= SBE_2T3E3_RX_DESC_MII_ERROR; - if (sc->p.crc == SBE_2T3E3_CRC_32) - error_mask |= SBE_2T3E3_RX_DESC_CRC_ERROR; - break; - case SBE_2T3E3_FRAME_MODE_TRANSPARENT: - case SBE_2T3E3_FRAME_MODE_RAW: - break; - default: - error_mask = 0; - } - - if (sc->s.LOS) { - error_mask &= ~(SBE_2T3E3_RX_DESC_DRIBBLING_BIT | - SBE_2T3E3_RX_DESC_MII_ERROR); - } - - error = current_desc->rdes0 & error_mask; - if (error) { - sc->s.in_errors++; - dev_dbg(&sc->pdev->dev, - "error interrupt: NO_ERROR_MESSAGE = %d\n", - sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES ? 1 : 0); - - current_desc->rdes1 &= SBE_2T3E3_RX_DESC_END_OF_RING | - SBE_2T3E3_RX_DESC_SECOND_ADDRESS_CHAINED; - current_desc->rdes1 |= SBE_2T3E3_MTU; - current_desc->rdes0 = SBE_2T3E3_RX_DESC_21143_OWN; - - if (error & SBE_2T3E3_RX_DESC_DESC_ERROR) { - if (!(sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES)) - dev_err(&sc->pdev->dev, - "SBE 2T3E3: descriptor error\n"); - sc->s.in_error_desc++; - } - - if (error & SBE_2T3E3_RX_DESC_COLLISION_SEEN) { - if (!(sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES)) - dev_err(&sc->pdev->dev, - "SBE 2T3E3: collision seen\n"); - sc->s.in_error_coll++; - } else { - if (error & SBE_2T3E3_RX_DESC_DRIBBLING_BIT) { - if (!(sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES)) - dev_err(&sc->pdev->dev, - "SBE 2T3E3: dribbling bits error\n"); - sc->s.in_error_drib++; - } - - if (error & SBE_2T3E3_RX_DESC_CRC_ERROR) { - if (!(sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES)) - dev_err(&sc->pdev->dev, - "SBE 2T3E3: crc error\n"); - sc->s.in_error_crc++; - } - } - - if (error & SBE_2T3E3_RX_DESC_MII_ERROR) { - if (!(sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES)) - dev_err(&sc->pdev->dev, "SBE 2T3E3: mii error\n"); - sc->s.in_error_mii++; - } - - current_read = (current_read + 1) % SBE_2T3E3_RX_DESC_RING_SIZE; - sc->r.flags |= SBE_2T3E3_FLAG_NO_ERROR_MESSAGES; - continue; - } - } - - current_desc->rdes1 &= SBE_2T3E3_RX_DESC_END_OF_RING | - SBE_2T3E3_RX_DESC_SECOND_ADDRESS_CHAINED; - current_desc->rdes1 |= SBE_2T3E3_MTU; - - if (rcv_len > 1600) { - sc->s.in_errors++; - sc->s.in_dropped++; - if (!(sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES)) - dev_err(&sc->pdev->dev, "SBE 2T3E3: oversized rx: rdes0 = %08X\n", - current_desc->rdes0); - } else { - m2 = dev_alloc_skb(MCLBYTES); - if (m2 != NULL) { - current_desc->rdes2 = virt_to_phys(m2->data); - sc->ether.rx_data[current_read] = m2; - sc->s.in_packets++; - sc->s.in_bytes += rcv_len; - m->dev = sc->dev; - skb_put(m, rcv_len); - skb_reset_mac_header(m); - m->protocol = hdlc_type_trans(m, m->dev); - netif_rx(m); - - /* good packet was received so we will show error messages again... */ - if (sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES) { - dev_dbg(&sc->pdev->dev, - "setting ERROR_MESSAGES->0\n"); - sc->r.flags &= ~SBE_2T3E3_FLAG_NO_ERROR_MESSAGES; - } - - } else { - sc->s.in_errors++; - sc->s.in_dropped++; - } - } - current_desc->rdes0 = SBE_2T3E3_RX_DESC_21143_OWN; - current_read = (current_read + 1) % SBE_2T3E3_RX_DESC_RING_SIZE; - } - - sc->ether.rx_ring_current_read = current_read; - - dc_write(sc->addr, SBE_2T3E3_21143_REG_RECEIVE_POLL_DEMAND, 0xFFFFFFFF); -} - -void dc_intr_tx(struct channel *sc) -{ - u32 current_read, current_write; - u32 last_segment, error; - struct t3e3_tx_desc *current_desc; - - spin_lock(&sc->ether.tx_lock); - - current_read = sc->ether.tx_ring_current_read; - current_write = sc->ether.tx_ring_current_write; - - while (current_read != current_write) { - current_desc = &sc->ether.tx_ring[current_read]; - - if (current_desc->tdes0 & SBE_2T3E3_RX_DESC_21143_OWN) - break; - - dev_dbg(&sc->pdev->dev, - "txeof: tdes0 = %08X tdes1 = %08X\n", - current_desc->tdes0, current_desc->tdes1); - - error = current_desc->tdes0 & (SBE_2T3E3_TX_DESC_ERROR_SUMMARY | - SBE_2T3E3_TX_DESC_TRANSMIT_JABBER_TIMEOUT | - SBE_2T3E3_TX_DESC_LOSS_OF_CARRIER | - SBE_2T3E3_TX_DESC_NO_CARRIER | - SBE_2T3E3_TX_DESC_LINK_FAIL_REPORT | - SBE_2T3E3_TX_DESC_UNDERFLOW_ERROR | - SBE_2T3E3_TX_DESC_DEFFERED); - - last_segment = current_desc->tdes1 & SBE_2T3E3_TX_DESC_LAST_SEGMENT; - - current_desc->tdes0 = 0; - current_desc->tdes1 &= SBE_2T3E3_TX_DESC_END_OF_RING | - SBE_2T3E3_TX_DESC_SECOND_ADDRESS_CHAINED; - current_desc->tdes2 = 0; - sc->ether.tx_free_cnt++; - - if (last_segment != SBE_2T3E3_TX_DESC_LAST_SEGMENT) { - current_read = (current_read + 1) % SBE_2T3E3_TX_DESC_RING_SIZE; - continue; - } - - - if (sc->ether.tx_data[current_read]) { - sc->s.out_packets++; - sc->s.out_bytes += sc->ether.tx_data[current_read]->len; - dev_kfree_skb_any(sc->ether.tx_data[current_read]); - sc->ether.tx_data[current_read] = NULL; - } - - if (error > 0) { - sc->s.out_errors++; - - if (error & SBE_2T3E3_TX_DESC_TRANSMIT_JABBER_TIMEOUT) { - dev_err(&sc->pdev->dev, "SBE 2T3E3: transmit jabber timeout\n"); - sc->s.out_error_jab++; - } - - if (sc->p.loopback != SBE_2T3E3_LOOPBACK_ETHERNET) { - if (error & SBE_2T3E3_TX_DESC_LOSS_OF_CARRIER) { - dev_err(&sc->pdev->dev, "SBE 2T3E3: loss of carrier\n"); - sc->s.out_error_lost_carr++; - } - - if (error & SBE_2T3E3_TX_DESC_NO_CARRIER) { - dev_err(&sc->pdev->dev, "SBE 2T3E3: no carrier\n"); - sc->s.out_error_no_carr++; - } - } - - if (error & SBE_2T3E3_TX_DESC_LINK_FAIL_REPORT) { - dev_err(&sc->pdev->dev, "SBE 2T3E3: link fail report\n"); - sc->s.out_error_link_fail++; - } - - if (error & SBE_2T3E3_TX_DESC_UNDERFLOW_ERROR) { - dev_err(&sc->pdev->dev, "SBE 2T3E3:" - " transmission underflow error\n"); - sc->s.out_error_underflow++; - spin_unlock(&sc->ether.tx_lock); - - dc_restart(sc); - return; - } - - if (error & SBE_2T3E3_TX_DESC_DEFFERED) { - dev_err(&sc->pdev->dev, "SBE 2T3E3: transmission deferred\n"); - sc->s.out_error_dereferred++; - } - } - - current_read = (current_read + 1) % SBE_2T3E3_TX_DESC_RING_SIZE; - } - - sc->ether.tx_ring_current_read = current_read; - - /* Relieve flow control when the TX queue is drained at least half way */ - if (sc->ether.tx_full && - (sc->ether.tx_free_cnt >= (SBE_2T3E3_TX_DESC_RING_SIZE / 2))) { - sc->ether.tx_full = 0; - netif_wake_queue(sc->dev); - } - spin_unlock(&sc->ether.tx_lock); -} - - -void dc_intr_tx_underflow(struct channel *sc) -{ - u32 val; - - dc_transmitter_onoff(sc, SBE_2T3E3_OFF); - - val = dc_read(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE); - dc_clear_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE, - SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS); - - switch (val & SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS) { - case SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_1: - dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE, - SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_2); - break; - case SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_2: - dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE, - SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_3); - break; - case SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_3: - dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE, - SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_4); - break; - case SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_4: - default: - dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE, - SBE_2T3E3_21143_VAL_STORE_AND_FORWARD); - break; - } - - dc_transmitter_onoff(sc, SBE_2T3E3_ON); -} - - - - -void exar7250_intr(struct channel *sc) -{ - u32 status, old_OOF; - - old_OOF = sc->s.OOF; - - status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_STATUS); - dev_dbg(&sc->pdev->dev, "SBE 2T3E3: Framer interrupt! (REG[0x05] = %02X)\n", status); - - switch (sc->p.frame_type) { - case SBE_2T3E3_FRAME_TYPE_E3_G751: - case SBE_2T3E3_FRAME_TYPE_E3_G832: - exar7250_E3_intr(sc, status); - break; - - case SBE_2T3E3_FRAME_TYPE_T3_CBIT: - case SBE_2T3E3_FRAME_TYPE_T3_M13: - exar7250_T3_intr(sc, status); - break; - - default: - break; - } - - if (sc->s.OOF != old_OOF) { - if (sc->s.OOF) { - if (sc->p.loopback == SBE_2T3E3_LOOPBACK_NONE) { - dev_dbg(&sc->pdev->dev, "SBE 2T3E3: Disabling eth interrupts\n"); - /* turn off ethernet interrupts */ - dc_stop_intr(sc); - } - } else if (sc->r.flags & SBE_2T3E3_FLAG_NETWORK_UP) { - dev_dbg(&sc->pdev->dev, "SBE 2T3E3: Enabling eth interrupts\n"); - /* start interrupts */ - sc->s.OOF = 1; - dc_intr_rx(sc); - sc->s.OOF = 0; - if (sc->p.receiver_on) { - dc_receiver_onoff(sc, SBE_2T3E3_OFF); - dc_receiver_onoff(sc, SBE_2T3E3_ON); - } - dc_start_intr(sc); - } - } -} - - -void exar7250_T3_intr(struct channel *sc, u32 block_status) -{ - u32 status, result; - - if (block_status & SBE_2T3E3_FRAMER_VAL_RX_INTERRUPT_STATUS) { - status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_STATUS); - - if (status) { - dev_dbg(&sc->pdev->dev, - "Framer interrupt T3 RX (REG[0x13] = %02X)\n", - status); - - result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_CONFIGURATION_STATUS); - - cpld_LOS_update(sc); - - if (status & SBE_2T3E3_FRAMER_VAL_T3_RX_OOF_INTERRUPT_STATUS) { - sc->s.OOF = result & SBE_2T3E3_FRAMER_VAL_T3_RX_OOF ? 1 : 0; - dev_dbg(&sc->pdev->dev, - "Framer interrupt T3: OOF (%d)\n", - sc->s.OOF); - } - - exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_ENABLE, - SBE_2T3E3_FRAMER_VAL_T3_RX_LOS_INTERRUPT_ENABLE | - SBE_2T3E3_FRAMER_VAL_T3_RX_OOF_INTERRUPT_ENABLE); - } - - status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS); - if (status) { - dev_dbg(&sc->pdev->dev, - "Framer interrupt T3 RX (REG[0x17] = %02X)\n", - status); - } - - status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_LAPD_CONTROL); - if (status) - dev_dbg(&sc->pdev->dev, - "Framer interrupt T3 RX (REG[0x18] = %02X)\n", - status); - } - - - if (block_status & SBE_2T3E3_FRAMER_VAL_TX_INTERRUPT_STATUS) { - status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_TX_FEAC_CONFIGURATION_STATUS); - dev_dbg(&sc->pdev->dev, "SBE 2T3E3: Framer interrupt T3 TX (REG[0x31] = %02X)\n", - status); - - status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_TX_LAPD_STATUS); - dev_dbg(&sc->pdev->dev, "SBE 2T3E3: Framer interrupt T3 TX (REG[0x34] = %02X)\n", - status); - } -} - - -void exar7250_E3_intr(struct channel *sc, u32 block_status) -{ - u32 status, result; - - if (block_status & SBE_2T3E3_FRAMER_VAL_RX_INTERRUPT_STATUS) { - status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_1); - - if (status) { - dev_dbg(&sc->pdev->dev, - "Framer interrupt E3 RX (REG[0x14] = %02X)\n", - status); - - result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_CONFIGURATION_STATUS_2); - - cpld_LOS_update(sc); - - if (status & SBE_2T3E3_FRAMER_VAL_E3_RX_OOF_INTERRUPT_STATUS) { - sc->s.OOF = result & SBE_2T3E3_FRAMER_VAL_E3_RX_OOF ? 1 : 0; - dev_dbg(&sc->pdev->dev, - "Framer interrupt E3: OOF (%d)\n", - sc->s.OOF); - } - - exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_1, - SBE_2T3E3_FRAMER_VAL_E3_RX_OOF_INTERRUPT_ENABLE | - SBE_2T3E3_FRAMER_VAL_E3_RX_LOS_INTERRUPT_ENABLE - ); - } - - status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_2); - if (status) { - dev_dbg(&sc->pdev->dev, - "Framer interrupt E3 RX (REG[0x15] = %02X)\n", - status); - - } - - } - - if (block_status & SBE_2T3E3_FRAMER_VAL_TX_INTERRUPT_STATUS) { - status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_TX_LAPD_STATUS); - dev_dbg(&sc->pdev->dev, "SBE 2T3E3: Framer interrupt E3 TX (REG[0x34] = %02X)\n", - status); - } -} diff --git a/drivers/staging/sbe-2t3e3/io.c b/drivers/staging/sbe-2t3e3/io.c deleted file mode 100644 index c9947b165b31..000000000000 --- a/drivers/staging/sbe-2t3e3/io.c +++ /dev/null @@ -1,330 +0,0 @@ -/* - * SBE 2T3E3 synchronous serial card driver for Linux - * - * Copyright (C) 2009-2010 Krzysztof Halasa - * - * 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 code is based on a driver written by SBE Inc. - */ - -#include -#include "2t3e3.h" -#include "ctrl.h" - -/* All access to registers done via the 21143 on port 0 must be - * protected via the card->bootrom_lock. */ - -/* private define to be used here only - must be protected by card->bootrom_lock */ -#define cpld_write_nolock(channel, reg, val) \ - bootrom_write((channel), CPLD_MAP_REG(reg, channel), val) - -u32 cpld_read(struct channel *channel, u32 reg) -{ - unsigned long flags; - u32 val; - - spin_lock_irqsave(&channel->card->bootrom_lock, flags); - val = bootrom_read((channel), CPLD_MAP_REG(reg, channel)); - spin_unlock_irqrestore(&channel->card->bootrom_lock, flags); - return val; -} - -/**************************************** - * Access via BootROM port - ****************************************/ - -u32 bootrom_read(struct channel *channel, u32 reg) -{ - unsigned long addr = channel->card->bootrom_addr; - u32 result; - - /* select BootROM address */ - dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_PROGRAMMING_ADDRESS, reg & 0x3FFFF); - - /* select reading from BootROM */ - dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, - SBE_2T3E3_21143_VAL_READ_OPERATION | - SBE_2T3E3_21143_VAL_BOOT_ROM_SELECT); - - udelay(2); /* 20 PCI cycles */ - - /* read from BootROM */ - result = dc_read(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT) & 0xff; - - /* reset CSR9 */ - dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, 0); - - return result; -} - -void bootrom_write(struct channel *channel, u32 reg, u32 val) -{ - unsigned long addr = channel->card->bootrom_addr; - - /* select BootROM address */ - dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_PROGRAMMING_ADDRESS, reg & 0x3FFFF); - - /* select writting to BootROM */ - dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, - SBE_2T3E3_21143_VAL_WRITE_OPERATION | - SBE_2T3E3_21143_VAL_BOOT_ROM_SELECT | - (val & 0xff)); - - udelay(2); /* 20 PCI cycles */ - - /* reset CSR9 */ - dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, 0); -} - - -/**************************************** - * Access via Serial I/O port - ****************************************/ - -static u32 serialrom_read_bit(struct channel *channel) -{ - unsigned long addr = channel->card->bootrom_addr; - u32 bit; - - dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, - SBE_2T3E3_21143_VAL_READ_OPERATION | - SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT | - SBE_2T3E3_21143_VAL_SERIAL_ROM_CLOCK | - SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT); /* clock high */ - - bit = (dc_read(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT) & - SBE_2T3E3_21143_VAL_SERIAL_ROM_DATA_OUT) > 0 ? 1 : 0; - - dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, - SBE_2T3E3_21143_VAL_READ_OPERATION | - SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT | - SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT); /* clock low */ - - return bit; -} - -static void serialrom_write_bit(struct channel *channel, u32 bit) -{ - unsigned long addr = channel->card->bootrom_addr; - u32 lastbit = -1; - - bit &= 1; - - if (bit != lastbit) { - dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, - SBE_2T3E3_21143_VAL_WRITE_OPERATION | - SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT | - SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT | - (bit << 2)); /* clock low */ - - lastbit = bit; - } - - dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, - SBE_2T3E3_21143_VAL_WRITE_OPERATION | - SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT | - SBE_2T3E3_21143_VAL_SERIAL_ROM_CLOCK | - SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT | - (bit << 2)); /* clock high */ - - dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, - SBE_2T3E3_21143_VAL_WRITE_OPERATION | - SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT | - SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT | - (bit << 2)); /* clock low */ -} - -/**************************************** - * Access to SerialROM (eeprom) - ****************************************/ - -u32 t3e3_eeprom_read_word(struct channel *channel, u32 address) -{ - unsigned long addr = channel->card->bootrom_addr; - u32 i, val; - unsigned long flags; - - address &= 0x3f; - - spin_lock_irqsave(&channel->card->bootrom_lock, flags); - - /* select correct Serial Chip */ - cpld_write_nolock(channel, SBE_2T3E3_CPLD_REG_SERIAL_CHIP_SELECT, - SBE_2T3E3_CPLD_VAL_EEPROM_SELECT); - - /* select reading from Serial I/O Bus */ - dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, - SBE_2T3E3_21143_VAL_READ_OPERATION | - SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT | - SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT); /* clock low */ - - /* select read operation */ - serialrom_write_bit(channel, 0); - serialrom_write_bit(channel, 1); - serialrom_write_bit(channel, 1); - serialrom_write_bit(channel, 0); - - for (i = 0x20; i; i >>= 1) - serialrom_write_bit(channel, address & i ? 1 : 0); - - val = 0; - for (i = 0x8000; i; i >>= 1) - val |= (serialrom_read_bit(channel) ? i : 0); - - /* Reset 21143's CSR9 */ - dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, - SBE_2T3E3_21143_VAL_READ_OPERATION | - SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT | - SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT); /* clock low */ - dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, 0); - - /* Unselect Serial Chip */ - cpld_write_nolock(channel, SBE_2T3E3_CPLD_REG_SERIAL_CHIP_SELECT, 0); - - spin_unlock_irqrestore(&channel->card->bootrom_lock, flags); - - return ntohs(val); -} - - -/**************************************** - * Access to Framer - ****************************************/ - -u32 exar7250_read(struct channel *channel, u32 reg) -{ - u32 result; - unsigned long flags; - - spin_lock_irqsave(&channel->card->bootrom_lock, flags); - - result = bootrom_read(channel, cpld_reg_map[SBE_2T3E3_CPLD_REG_FRAMER_BASE_ADDRESS] - [channel->h.slot] + (t3e3_framer_reg_map[reg] << 2)); - - spin_unlock_irqrestore(&channel->card->bootrom_lock, flags); - - return result; -} - -void exar7250_write(struct channel *channel, u32 reg, u32 val) -{ - unsigned long flags; - - val &= 0xff; - channel->framer_regs[reg] = val; - - spin_lock_irqsave(&channel->card->bootrom_lock, flags); - - bootrom_write(channel, cpld_reg_map[SBE_2T3E3_CPLD_REG_FRAMER_BASE_ADDRESS] - [channel->h.slot] + (t3e3_framer_reg_map[reg] << 2), val); - - spin_unlock_irqrestore(&channel->card->bootrom_lock, flags); -} - - -/**************************************** - * Access to LIU - ****************************************/ - -u32 exar7300_read(struct channel *channel, u32 reg) -{ - unsigned long addr = channel->card->bootrom_addr, flags; - u32 i, val; - - /* select correct Serial Chip */ - - spin_lock_irqsave(&channel->card->bootrom_lock, flags); - - cpld_write_nolock(channel, SBE_2T3E3_CPLD_REG_SERIAL_CHIP_SELECT, - cpld_val_map[SBE_2T3E3_CPLD_VAL_LIU_SELECT][channel->h.slot]); - - /* select reading from Serial I/O Bus */ - dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, - SBE_2T3E3_21143_VAL_READ_OPERATION | - SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT | - SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT); /* clock low */ - - /* select read operation */ - serialrom_write_bit(channel, 1); - - /* Exar7300 register address is 4 bit long */ - reg = t3e3_liu_reg_map[reg]; - for (i = 0; i < 4; i++, reg >>= 1) /* 4 bits of SerialROM address */ - serialrom_write_bit(channel, reg & 1); - for (i = 0; i < 3; i++) /* remaining 3 bits of SerialROM address */ - serialrom_write_bit(channel, 0); - - val = 0; /* Exar7300 register value is 5 bit long */ - for (i = 0; i < 8; i++) /* 8 bits of SerialROM value */ - val += (serialrom_read_bit(channel) << i); - - /* Reset 21143's CSR9 */ - dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, - SBE_2T3E3_21143_VAL_READ_OPERATION | - SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT | - SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT); /* clock low */ - dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, 0); - - /* Unselect Serial Chip */ - cpld_write_nolock(channel, SBE_2T3E3_CPLD_REG_SERIAL_CHIP_SELECT, 0); - - spin_unlock_irqrestore(&channel->card->bootrom_lock, flags); - - return val; -} - -void exar7300_write(struct channel *channel, u32 reg, u32 val) -{ - unsigned long addr = channel->card->bootrom_addr, flags; - u32 i; - - channel->liu_regs[reg] = val; - - /* select correct Serial Chip */ - - spin_lock_irqsave(&channel->card->bootrom_lock, flags); - - cpld_write_nolock(channel, SBE_2T3E3_CPLD_REG_SERIAL_CHIP_SELECT, - cpld_val_map[SBE_2T3E3_CPLD_VAL_LIU_SELECT][channel->h.slot]); - - /* select writting to Serial I/O Bus */ - dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, - SBE_2T3E3_21143_VAL_WRITE_OPERATION | - SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT | - SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT); /* clock low */ - - /* select write operation */ - serialrom_write_bit(channel, 0); - - /* Exar7300 register address is 4 bit long */ - reg = t3e3_liu_reg_map[reg]; - for (i = 0; i < 4; i++) { /* 4 bits */ - serialrom_write_bit(channel, reg & 1); - reg >>= 1; - } - for (i = 0; i < 3; i++) /* remaining 3 bits of SerialROM address */ - serialrom_write_bit(channel, 0); - - /* Exar7300 register value is 5 bit long */ - for (i = 0; i < 5; i++) { - serialrom_write_bit(channel, val & 1); - val >>= 1; - } - for (i = 0; i < 3; i++) /* remaining 3 bits of SerialROM value */ - serialrom_write_bit(channel, 0); - - /* Reset 21143_CSR9 */ - dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, - SBE_2T3E3_21143_VAL_WRITE_OPERATION | - SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT | - SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT); /* clock low */ - dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, 0); - - /* Unselect Serial Chip */ - cpld_write_nolock(channel, SBE_2T3E3_CPLD_REG_SERIAL_CHIP_SELECT, 0); - - spin_unlock_irqrestore(&channel->card->bootrom_lock, flags); -} diff --git a/drivers/staging/sbe-2t3e3/main.c b/drivers/staging/sbe-2t3e3/main.c deleted file mode 100644 index c8e039860dc4..000000000000 --- a/drivers/staging/sbe-2t3e3/main.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - * SBE 2T3E3 synchronous serial card driver for Linux - * - * Copyright (C) 2009-2010 Krzysztof Halasa - * - * 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 code is based on a driver written by SBE Inc. - */ - -#include -#include -#include "2t3e3.h" - -void t3e3_init(struct channel *sc) -{ - cpld_init(sc); - dc_reset(sc); - dc_init(sc); - exar7250_init(sc); - exar7300_init(sc); -} - -int t3e3_if_start_xmit(struct sk_buff *skb, struct net_device *dev) -{ - struct channel *sc = dev_to_priv(dev); - u32 current_write, last_write; - unsigned long flags; - struct sk_buff *skb2; - - if (skb == NULL) { - sc->s.out_errors++; - return 0; - } - - if (sc->p.transmitter_on != SBE_2T3E3_ON) { - sc->s.out_errors++; - sc->s.out_dropped++; - dev_kfree_skb_any(skb); - return 0; - } - - if (sc->s.OOF && sc->p.loopback == SBE_2T3E3_LOOPBACK_NONE) { - sc->s.out_dropped++; - dev_kfree_skb_any(skb); - return 0; - } - - spin_lock_irqsave(&sc->ether.tx_lock, flags); - - current_write = sc->ether.tx_ring_current_write; - for (skb2 = skb; skb2 != NULL; skb2 = NULL) { - if (skb2->len) { - if ((sc->ether.tx_ring[current_write].tdes1 & - SBE_2T3E3_TX_DESC_BUFFER_1_SIZE) > 0) - break; - current_write = (current_write + 1) % SBE_2T3E3_TX_DESC_RING_SIZE; - /* - * Leave at least 1 tx desc free so that dc_intr_tx() can - * identify empty list - */ - if (current_write == sc->ether.tx_ring_current_read) - break; - } - } - if (skb2 != NULL) { - netif_stop_queue(sc->dev); - sc->ether.tx_full = 1; - dev_dbg(&sc->pdev->dev, "SBE 2T3E3: out of descriptors\n"); - spin_unlock_irqrestore(&sc->ether.tx_lock, flags); - return NETDEV_TX_BUSY; - } - - current_write = last_write = sc->ether.tx_ring_current_write; - dev_dbg(&sc->pdev->dev, "sending mbuf (current_write = %d)\n", - current_write); - - for (skb2 = skb; skb2 != NULL; skb2 = NULL) { - if (skb2->len) { - dev_dbg(&sc->pdev->dev, - "sending mbuf (len = %d, next = %p)\n", - skb2->len, NULL); - - sc->ether.tx_free_cnt--; - sc->ether.tx_ring[current_write].tdes0 = 0; - sc->ether.tx_ring[current_write].tdes1 &= - SBE_2T3E3_TX_DESC_END_OF_RING | - SBE_2T3E3_TX_DESC_SECOND_ADDRESS_CHAINED; -/* DISABLE_PADDING sometimes gets lost somehow, hands off... */ - sc->ether.tx_ring[current_write].tdes1 |= - SBE_2T3E3_TX_DESC_DISABLE_PADDING | skb2->len; - - if (current_write == sc->ether.tx_ring_current_write) { - sc->ether.tx_ring[current_write].tdes1 |= - SBE_2T3E3_TX_DESC_FIRST_SEGMENT; - } else { - sc->ether.tx_ring[current_write].tdes0 = - SBE_2T3E3_TX_DESC_21143_OWN; - } - - sc->ether.tx_ring[current_write].tdes2 = virt_to_phys(skb2->data); - sc->ether.tx_data[current_write] = NULL; - - last_write = current_write; - current_write = (current_write + 1) % SBE_2T3E3_TX_DESC_RING_SIZE; - } - } - - sc->ether.tx_data[last_write] = skb; - sc->ether.tx_ring[last_write].tdes1 |= - SBE_2T3E3_TX_DESC_LAST_SEGMENT | - SBE_2T3E3_TX_DESC_INTERRUPT_ON_COMPLETION; - sc->ether.tx_ring[sc->ether.tx_ring_current_write].tdes0 |= - SBE_2T3E3_TX_DESC_21143_OWN; - sc->ether.tx_ring_current_write = current_write; - - dev_dbg(&sc->pdev->dev, "txput: tdes0 = %08X tdes1 = %08X\n", - sc->ether.tx_ring[last_write].tdes0, - sc->ether.tx_ring[last_write].tdes1); - - dc_write(sc->addr, SBE_2T3E3_21143_REG_TRANSMIT_POLL_DEMAND, - 0xffffffff); - - spin_unlock_irqrestore(&sc->ether.tx_lock, flags); - return 0; -} - - -void t3e3_read_card_serial_number(struct channel *sc) -{ - u32 i; - - for (i = 0; i < 3; i++) - sc->ether.card_serial_number[i] = t3e3_eeprom_read_word(sc, 10 + i); - - netdev_info(sc->dev, "SBE wanPMC-2T3E3 serial number: %04X%04X%04X\n", - sc->ether.card_serial_number[0], - sc->ether.card_serial_number[1], - sc->ether.card_serial_number[2]); -} - -/* - bit 0 led1 (green) - bit 1 led1 (yellow) - - bit 2 led2 (green) - bit 3 led2 (yellow) - - bit 4 led3 (green) - bit 5 led3 (yellow) - - bit 6 led4 (green) - bit 7 led4 (yellow) -*/ - -void update_led(struct channel *sc, int blinker) -{ - int leds; - if (sc->s.LOS) - leds = 0; /* led1 = off */ - else if (sc->s.OOF) - leds = 2; /* led1 = yellow */ - else if ((blinker & 1) && sc->rcv_count) { - leds = 0; /* led1 = off */ - sc->rcv_count = 0; - } else - leds = 1; /* led1 = green */ - cpld_write(sc, SBE_2T3E3_CPLD_REG_LEDR, leds); - sc->leds = leds; -} diff --git a/drivers/staging/sbe-2t3e3/maps.c b/drivers/staging/sbe-2t3e3/maps.c deleted file mode 100644 index e5494502cde1..000000000000 --- a/drivers/staging/sbe-2t3e3/maps.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * SBE 2T3E3 synchronous serial card driver for Linux - * - * Copyright (C) 2009-2010 Krzysztof Halasa - * - * 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 code is based on a driver written by SBE Inc. - */ - -#include -#include "2t3e3.h" - -const u32 cpld_reg_map[][2] = { - { 0x0000, 0x0080 }, /* 0 - Port Control Register A (PCRA) */ - { 0x0004, 0x0084 }, /* 1 - Port Control Register B (PCRB) */ - { 0x0008, 0x0088 }, /* 2 - LCV Count Register (PLCR) */ - { 0x000c, 0x008c }, /* 3 - LCV Threshold register (PLTR) */ - { 0x0010, 0x0090 }, /* 4 - Payload Fill Register (PPFR) */ - { 0x0200, 0x0200 }, /* 5 - Board ID / FPGA Programming Status Register */ - { 0x0204, 0x0204 }, /* 6 - FPGA Version Register */ - { 0x0800, 0x1000 }, /* 7 - Framer Registers Base Address */ - { 0x2000, 0x2000 }, /* 8 - Serial Chip Select Register */ - { 0x2004, 0x2004 }, /* 9 - Static Reset Register */ - { 0x2008, 0x2008 }, /* 10 - Pulse Reset Register */ - { 0x200c, 0x200c }, /* 11 - FPGA Reconfiguration Register */ - { 0x2010, 0x2014 }, /* 12 - LED Register (LEDR) */ - { 0x2018, 0x201c }, /* 13 - LIU Control and Status Register (PISCR) */ - { 0x2020, 0x2024 }, /* 14 - Interrupt Enable Register (PIER) */ - { 0x0068, 0x00e8 }, /* 15 - Port Control Register C (PCRC) */ - { 0x006c, 0x00ec }, /* 16 - Port Bandwidth Start (PBWF) */ - { 0x0070, 0x00f0 }, /* 17 - Port Bandwidth Stop (PBWL) */ -}; - -const u32 cpld_val_map[][2] = { - { 0x01, 0x02 }, /* LIU1 / LIU2 select for Serial Chip Select */ - { 0x04, 0x08 }, /* DAC1 / DAC2 select for Serial Chip Select */ - { 0x00, 0x04 }, /* LOOP1 / LOOP2 - select of loop timing source */ - { 0x01, 0x02 } /* PORT1 / PORT2 - select LIU and Framer for reset */ -}; - -const u32 t3e3_framer_reg_map[] = { - 0x00, /* 0 - OPERATING_MODE */ - 0x01, /* 1 - IO_CONTROL */ - 0x04, /* 2 - BLOCK_INTERRUPT_ENABLE */ - 0x05, /* 3 - BLOCK_INTERRUPT_STATUS */ - 0x10, /* 4 - T3_RX_CONFIGURATION_STATUS, E3_RX_CONFIGURATION_STATUS_1 */ - 0x11, /* 5 - T3_RX_STATUS, E3_RX_CONFIGURATION_STATUS_2 */ - 0x12, /* 6 - T3_RX_INTERRUPT_ENABLE, E3_RX_INTERRUPT_ENABLE_1 */ - 0x13, /* 7 - T3_RX_INTERRUPT_STATUS, E3_RX_INTERRUPT_ENABLE_2 */ - 0x14, /* 8 - T3_RX_SYNC_DETECT_ENABLE, E3_RX_INTERRUPT_STATUS_1 */ - 0x15, /* 9 - E3_RX_INTERRUPT_STATUS_2 */ - 0x16, /* 10 - T3_RX_FEAC */ - 0x17, /* 11 - T3_RX_FEAC_INTERRUPT_ENABLE_STATUS */ - 0x18, /* 12 - T3_RX_LAPD_CONTROL, E3_RX_LAPD_CONTROL */ - 0x19, /* 13 - T3_RX_LAPD_STATUS, E3_RX_LAPD_STATUS */ - 0x1a, /* 14 - E3_RX_NR_BYTE, E3_RX_SERVICE_BITS */ - 0x1b, /* 15 - E3_RX_GC_BYTE */ - 0x30, /* 16 - T3_TX_CONFIGURATION, E3_TX_CONFIGURATION */ - 0x31, /* 17 - T3_TX_FEAC_CONFIGURATION_STATUS */ - 0x32, /* 18 - T3_TX_FEAC */ - 0x33, /* 19 - T3_TX_LAPD_CONFIGURATION, E3_TX_LAPD_CONFIGURATION */ - 0x34, /* 20 - T3_TX_LAPD_STATUS, E3_TX_LAPD_STATUS_INTERRUPT */ - 0x35, /* 21 - T3_TX_MBIT_MASK, E3_TX_GC_BYTE, E3_TX_SERVICE_BITS */ - 0x36, /* 22 - T3_TX_FBIT_MASK, E3_TX_MA_BYTE */ - 0x37, /* 23 - T3_TX_FBIT_MASK_2, E3_TX_NR_BYTE */ - 0x38, /* 24 - T3_TX_FBIT_MASK_3 */ - 0x48, /* 25 - E3_TX_FA1_ERROR_MASK, E3_TX_FAS_ERROR_MASK_UPPER */ - 0x49, /* 26 - E3_TX_FA2_ERROR_MASK, E3_TX_FAS_ERROR_MASK_LOWER */ - 0x4a, /* 27 - E3_TX_BIP8_MASK, E3_TX_BIP4_MASK */ - 0x50, /* 28 - PMON_LCV_EVENT_COUNT_MSB */ - 0x51, /* 29 - PMON_LCV_EVENT_COUNT_LSB */ - 0x52, /* 30 - PMON_FRAMING_BIT_ERROR_EVENT_COUNT_MSB */ - 0x53, /* 31 - PMON_FRAMING_BIT_ERROR_EVENT_COUNT_LSB */ - 0x54, /* 32 - PMON_PARITY_ERROR_EVENT_COUNT_MSB */ - 0x55, /* 33 - PMON_PARITY_ERROR_EVENT_COUNT_LSB */ - 0x56, /* 34 - PMON_FEBE_EVENT_COUNT_MSB */ - 0x57, /* 35 - PMON_FEBE_EVENT_COUNT_LSB */ - 0x58, /* 36 - PMON_CP_BIT_ERROR_EVENT_COUNT_MSB */ - 0x59, /* 37 - PMON_CP_BIT_ERROR_EVENT_COUNT_LSB */ - 0x6c, /* 38 - PMON_HOLDING_REGISTER */ - 0x6d, /* 39 - ONE_SECOND_ERROR_STATUS */ - 0x6e, /* 40 - LCV_ONE_SECOND_ACCUMULATOR_MSB */ - 0x6f, /* 41 - LCV_ONE_SECOND_ACCUMULATOR_LSB */ - 0x70, /* 42 - FRAME_PARITY_ERROR_ONE_SECOND_ACCUMULATOR_MSB */ - 0x71, /* 43 - FRAME_PARITY_ERROR_ONE_SECOND_ACCUMULATOR_LSB */ - 0x72, /* 44 - FRAME_CP_BIT_ERROR_ONE_SECOND_ACCUMULATOR_MSB */ - 0x73, /* 45 - FRAME_CP_BIT_ERROR_ONE_SECOND_ACCUMULATOR_LSB */ - 0x80, /* 46 - LINE_INTERFACE_DRIVE */ - 0x81 /* 47 - LINE_INTERFACE_SCAN */ -}; - -const u32 t3e3_liu_reg_map[] = { - 0x00, /* REG0 */ - 0x01, /* REG1 */ - 0x02, /* REG2 */ - 0x03, /* REG3 */ - 0x04 /* REG4 */ -}; diff --git a/drivers/staging/sbe-2t3e3/module.c b/drivers/staging/sbe-2t3e3/module.c deleted file mode 100644 index a6f93a43d216..000000000000 --- a/drivers/staging/sbe-2t3e3/module.c +++ /dev/null @@ -1,208 +0,0 @@ -/* - * SBE 2T3E3 synchronous serial card driver for Linux - * - * Copyright (C) 2009-2010 Krzysztof Halasa - * - * 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 code is based on a driver written by SBE Inc. - */ - -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include -#include -#include -#include -#include -#include -#include -#include "2t3e3.h" - -static void check_leds(unsigned long arg) -{ - struct card *card = (struct card *)arg; - struct channel *channel0 = &card->channels[0]; - static int blinker; - - update_led(channel0, ++blinker); - if (has_two_ports(channel0->pdev)) - update_led(&card->channels[1], blinker); - - card->timer.expires = jiffies + HZ / 10; - add_timer(&card->timer); -} - -static void t3e3_remove_channel(struct channel *channel) -{ - struct pci_dev *pdev = channel->pdev; - struct net_device *dev = channel->dev; - - /* system hangs if board asserts irq while module is unloaded */ - cpld_stop_intr(channel); - free_irq(dev->irq, dev); - dc_drop_descriptor_list(channel); - unregister_hdlc_device(dev); - free_netdev(dev); - pci_release_regions(pdev); - pci_disable_device(pdev); - pci_set_drvdata(pdev, NULL); -} - -static int t3e3_init_channel(struct channel *channel, struct pci_dev *pdev, struct card *card) -{ - struct net_device *dev; - unsigned int val; - int err; - - err = pci_enable_device(pdev); - if (err) - return err; - - err = pci_request_regions(pdev, "SBE 2T3E3"); - if (err) - goto disable; - - dev = alloc_hdlcdev(channel); - if (!dev) { - pr_err("Out of memory\n"); - err = -ENOMEM; - goto free_regions; - } - - t3e3_sc_init(channel); - dev_to_priv(dev) = channel; - - channel->pdev = pdev; - channel->dev = dev; - channel->card = card; - channel->addr = pci_resource_start(pdev, 0); - if (pdev->subsystem_device == PCI_SUBDEVICE_ID_SBE_2T3E3_P1) - channel->h.slot = 1; - else - channel->h.slot = 0; - - err = setup_device(dev, channel); - if (err) - goto free_dev; - - pci_read_config_dword(channel->pdev, 0x40, &val); /* mask sleep mode */ - pci_write_config_dword(channel->pdev, 0x40, val & 0x3FFFFFFF); - - pci_read_config_byte(channel->pdev, PCI_CACHE_LINE_SIZE, &channel->h.cache_size); - pci_read_config_dword(channel->pdev, PCI_COMMAND, &channel->h.command); - t3e3_init(channel); - - err = request_irq(dev->irq, &t3e3_intr, IRQF_SHARED, dev->name, dev); - if (err) { - netdev_warn(channel->dev, "%s: could not get irq: %d\n", - dev->name, dev->irq); - goto unregister_dev; - } - - pci_set_drvdata(pdev, channel); - return 0; - -unregister_dev: - unregister_hdlc_device(dev); -free_dev: - free_netdev(dev); -free_regions: - pci_release_regions(pdev); -disable: - pci_disable_device(pdev); - return err; -} - -static void t3e3_remove_card(struct pci_dev *pdev) -{ - struct channel *channel0 = pci_get_drvdata(pdev); - struct card *card = channel0->card; - - del_timer_sync(&card->timer); - if (has_two_ports(channel0->pdev)) { - t3e3_remove_channel(&card->channels[1]); - pci_dev_put(card->channels[1].pdev); - } - t3e3_remove_channel(channel0); - kfree(card); -} - -static int t3e3_init_card(struct pci_dev *pdev, const struct pci_device_id *ent) -{ - /* pdev points to channel #0 */ - struct pci_dev *pdev1 = NULL; - struct card *card; - int channels = 1, err; - - if (has_two_ports(pdev)) { - while ((pdev1 = pci_get_subsys(PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21142, - PCI_VENDOR_ID_SBE, PCI_SUBDEVICE_ID_SBE_2T3E3_P1, - pdev1))) - if (pdev1->bus == pdev->bus && - pdev1->devfn == pdev->devfn + 8 /* next device on the same bus */) - break; /* found the second channel */ - - if (!pdev1) { - dev_err(&pdev->dev, "Can't find the second channel\n"); - return -EFAULT; - } - channels = 2; - /* holds the reference for pdev1 */ - } - - card = kzalloc(sizeof(struct card) + channels * sizeof(struct channel), - GFP_KERNEL); - if (!card) - return -ENOBUFS; - - spin_lock_init(&card->bootrom_lock); - card->bootrom_addr = pci_resource_start(pdev, 0); - - err = t3e3_init_channel(&card->channels[0], pdev, card); - if (err) - goto free_card; - - if (channels == 2) { - err = t3e3_init_channel(&card->channels[1], pdev1, card); - if (err) { - t3e3_remove_channel(&card->channels[0]); - goto free_card; - } - } - - /* start LED timer */ - init_timer(&card->timer); - card->timer.function = check_leds; - card->timer.expires = jiffies + HZ / 10; - card->timer.data = (unsigned long)card; - add_timer(&card->timer); - return 0; - -free_card: - kfree(card); - return err; -} - -static struct pci_device_id t3e3_pci_tbl[] = { - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21142, - PCI_VENDOR_ID_SBE, PCI_SUBDEVICE_ID_SBE_T3E3, 0, 0, 0 }, - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21142, - PCI_VENDOR_ID_SBE, PCI_SUBDEVICE_ID_SBE_2T3E3_P0, 0, 0, 0 }, - /* channel 1 will be initialized after channel 0 */ - { 0, } -}; - -static struct pci_driver t3e3_pci_driver = { - .name = "SBE T3E3", - .id_table = t3e3_pci_tbl, - .probe = t3e3_init_card, - .remove = t3e3_remove_card, -}; - -module_pci_driver(t3e3_pci_driver); -MODULE_LICENSE("GPL"); -MODULE_DEVICE_TABLE(pci, t3e3_pci_tbl); diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c deleted file mode 100644 index fe6c9513c9cd..000000000000 --- a/drivers/staging/sbe-2t3e3/netdev.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * SBE 2T3E3 synchronous serial card driver for Linux - * - * Copyright (C) 2009-2010 Krzysztof Halasa - * - * 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 code is based on a driver written by SBE Inc. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "2t3e3.h" - -static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) -{ - struct channel *sc = dev_to_priv(dev); - int cmd_2t3e3, len, rlen; - struct t3e3_param param; - struct t3e3_resp resp; - void __user *data = ifr->ifr_data + sizeof(cmd_2t3e3) + sizeof(len); - - if (cmd == SIOCWANDEV) - return hdlc_ioctl(dev, ifr, cmd); - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - if (cmd != SIOCDEVPRIVATE + 15) - return -EINVAL; - - if (copy_from_user(&cmd_2t3e3, ifr->ifr_data, sizeof(cmd_2t3e3))) - return -EFAULT; - if (copy_from_user(&len, ifr->ifr_data + sizeof(cmd_2t3e3), sizeof(len))) - return -EFAULT; - - if (len > sizeof(param)) - return -EFAULT; - - if (len) - if (copy_from_user(¶m, data, len)) - return -EFAULT; - - t3e3_if_config(sc, cmd_2t3e3, (char *)¶m, &resp, &rlen); - - if (rlen) - if (copy_to_user(data, &resp, rlen)) - return -EFAULT; - - return 0; -} - -static struct net_device_stats *t3e3_get_stats(struct net_device *dev) -{ - struct net_device_stats *nstats = &dev->stats; - struct channel *sc = dev_to_priv(dev); - struct t3e3_stats *stats = &sc->s; - - memset(nstats, 0, sizeof(struct net_device_stats)); - nstats->rx_packets = stats->in_packets; - nstats->tx_packets = stats->out_packets; - nstats->rx_bytes = stats->in_bytes; - nstats->tx_bytes = stats->out_bytes; - - nstats->rx_errors = stats->in_errors; - nstats->tx_errors = stats->out_errors; - nstats->rx_crc_errors = stats->in_error_crc; - - - nstats->rx_dropped = stats->in_dropped; - nstats->tx_dropped = stats->out_dropped; - nstats->tx_carrier_errors = stats->out_error_lost_carr + - stats->out_error_no_carr; - - return nstats; -} - -static int t3e3_open(struct net_device *dev) -{ - struct channel *sc = dev_to_priv(dev); - int ret = hdlc_open(dev); - - if (ret) - return ret; - - sc->r.flags |= SBE_2T3E3_FLAG_NETWORK_UP; - dc_start(dev_to_priv(dev)); - netif_start_queue(dev); - try_module_get(THIS_MODULE); - return 0; -} - -static int t3e3_close(struct net_device *dev) -{ - struct channel *sc = dev_to_priv(dev); - hdlc_close(dev); - netif_stop_queue(dev); - dc_stop(sc); - sc->r.flags &= ~SBE_2T3E3_FLAG_NETWORK_UP; - module_put(THIS_MODULE); - return 0; -} - -static int t3e3_attach(struct net_device *dev, unsigned short foo1, - unsigned short foo2) -{ - return 0; -} - -static const struct net_device_ops t3e3_ops = { - .ndo_open = t3e3_open, - .ndo_stop = t3e3_close, - .ndo_change_mtu = hdlc_change_mtu, - .ndo_start_xmit = hdlc_start_xmit, - .ndo_do_ioctl = t3e3_ioctl, - .ndo_get_stats = t3e3_get_stats, -}; - -int setup_device(struct net_device *dev, struct channel *sc) -{ - hdlc_device *hdlc = dev_to_hdlc(dev); - int retval; - - dev->base_addr = pci_resource_start(sc->pdev, 0); - dev->irq = sc->pdev->irq; - dev->netdev_ops = &t3e3_ops; - dev->tx_queue_len = 100; - hdlc->xmit = t3e3_if_start_xmit; - hdlc->attach = t3e3_attach; - retval = register_hdlc_device(dev); - if (retval) { - dev_err(&sc->pdev->dev, "error registering HDLC device\n"); - return retval; - } - return 0; -} -- cgit v1.2.3 From 340bb3df6d967193a09cc42afd18585d89ff9ba9 Mon Sep 17 00:00:00 2001 From: Dominique van den Broeck Date: Sat, 12 Apr 2014 15:18:12 +0200 Subject: fwserial: (coding style) open parenthesis alignments Style-only modifications to make checkpatch.pl --file --strict a bit happier. Open parenthesis alignments. Signed-off-by: Dominique van den Broeck Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fwserial/dma_fifo.c | 28 ++++++++++++++-------------- drivers/staging/fwserial/fwserial.c | 8 ++++---- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/staging/fwserial/dma_fifo.c b/drivers/staging/fwserial/dma_fifo.c index 5e8463445504..528d0b9e7849 100644 --- a/drivers/staging/fwserial/dma_fifo.c +++ b/drivers/staging/fwserial/dma_fifo.c @@ -169,9 +169,9 @@ int dma_fifo_in(struct dma_fifo *fifo, const void *src, int n) memcpy(fifo->data, src + l, n - l); if (FAIL(fifo, addr_check(fifo->done, fifo->in, fifo->in + n) || - fifo->avail < n, - "fifo corrupt: in:%u out:%u done:%u n:%d avail:%d", - fifo->in, fifo->out, fifo->done, n, fifo->avail)) + fifo->avail < n, + "fifo corrupt: in:%u out:%u done:%u n:%d avail:%d", + fifo->in, fifo->out, fifo->done, n, fifo->avail)) return -ENXIO; fifo->in += n; @@ -236,12 +236,12 @@ int dma_fifo_out_pend(struct dma_fifo *fifo, struct dma_pending *pended) ++fifo->open; if (FAIL(fifo, fifo->open > fifo->open_limit, - "past open limit:%d (limit:%d)", - fifo->open, fifo->open_limit)) + "past open limit:%d (limit:%d)", + fifo->open, fifo->open_limit)) return -ENXIO; if (FAIL(fifo, fifo->out & (fifo->align - 1), - "fifo out unaligned:%u (align:%u)", - fifo->out, fifo->align)) + "fifo out unaligned:%u (align:%u)", + fifo->out, fifo->align)) return -ENXIO; return len - n; @@ -264,8 +264,8 @@ int dma_fifo_out_complete(struct dma_fifo *fifo, struct dma_pending *complete) return -EINVAL; if (FAIL(fifo, list_empty(&fifo->pending) != (fifo->open == 0), - "pending list disagrees with open count:%d", - fifo->open)) + "pending list disagrees with open count:%d", + fifo->open)) return -ENXIO; tmp = complete->data; @@ -282,10 +282,10 @@ int dma_fifo_out_complete(struct dma_fifo *fifo, struct dma_pending *complete) } if (FAIL(fifo, pending->out != fifo->done || - addr_check(fifo->in, fifo->done, pending->next), - "in:%u out:%u done:%u saved:%u next:%u", - fifo->in, fifo->out, fifo->done, pending->out, - pending->next)) + addr_check(fifo->in, fifo->done, pending->next), + "in:%u out:%u done:%u saved:%u next:%u", + fifo->in, fifo->out, fifo->done, pending->out, + pending->next)) return -ENXIO; list_del_init(&pending->link); @@ -300,7 +300,7 @@ int dma_fifo_out_complete(struct dma_fifo *fifo, struct dma_pending *complete) if (FAIL(fifo, fifo->open < 0, "open dma:%d < 0", fifo->open)) return -ENXIO; if (FAIL(fifo, fifo->avail > fifo->size, "fifo avail:%d > size:%d", - fifo->avail, fifo->size)) + fifo->avail, fifo->size)) return -ENXIO; return 0; diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c index b22142ee5262..db3d6c7ff219 100644 --- a/drivers/staging/fwserial/fwserial.c +++ b/drivers/staging/fwserial/fwserial.c @@ -530,7 +530,7 @@ static void fwtty_emit_breaks(struct work_struct *work) while (n) { t = min(n, 16); c = tty_insert_flip_string_fixed_flag(&port->port, buf, - TTY_BREAK, t); + TTY_BREAK, t); n -= c; brk += c; if (c < t) @@ -741,7 +741,7 @@ static int fwtty_tx(struct fwtty_port *port, bool drain) /* try to write as many dma transactions out as possible */ n = -EAGAIN; while (!tty->stopped && !tty->hw_stopped && - !test_bit(STOP_TX, &port->flags)) { + !test_bit(STOP_TX, &port->flags)) { txn = kmem_cache_alloc(fwtty_txn_cache, GFP_ATOMIC); if (!txn) { n = -ENOMEM; @@ -884,7 +884,7 @@ static void fwserial_destroy(struct kref *kref) for (j = 0; j < num_ports; ++i, ++j) { port_table_corrupt |= port_table[i] != ports[j]; WARN_ONCE(port_table_corrupt, "port_table[%d]: %p != ports[%d]: %p", - i, port_table[i], j, ports[j]); + i, port_table[i], j, ports[j]); port_table[i] = NULL; } @@ -1257,7 +1257,7 @@ static int set_serial_info(struct fwtty_port *port, return -EFAULT; if (tmp.irq != 0 || tmp.port != 0 || tmp.custom_divisor != 0 || - tmp.baud_base != 400000000) + tmp.baud_base != 400000000) return -EPERM; if (!capable(CAP_SYS_ADMIN)) { -- cgit v1.2.3 From ea595e76c02a71d34c5536be1c64de114a5ac598 Mon Sep 17 00:00:00 2001 From: Dominique van den Broeck Date: Sat, 12 Apr 2014 15:18:13 +0200 Subject: fwserial: (coding style) if/else bracket matching Style-only modifications to make checkpatch.pl --file --strict a bit happier. if/else bracket matching (either none or both options should be bracketed). Signed-off-by: Dominique van den Broeck Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fwserial/fwserial.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c index db3d6c7ff219..3862ddf29891 100644 --- a/drivers/staging/fwserial/fwserial.c +++ b/drivers/staging/fwserial/fwserial.c @@ -638,9 +638,9 @@ static void fwtty_port_handler(struct fw_card *card, switch (tcode) { case TCODE_WRITE_QUADLET_REQUEST: - if (addr != port->rx_handler.offset || len != 4) + if (addr != port->rx_handler.offset || len != 4) { rcode = RCODE_ADDRESS_ERROR; - else { + } else { fwtty_update_port_status(port, *(unsigned *)data); rcode = RCODE_COMPLETE; } @@ -756,11 +756,11 @@ static int fwtty_tx(struct fwtty_port *port, bool drain) if (n < 0) { kmem_cache_free(fwtty_txn_cache, txn); - if (n == -EAGAIN) + if (n == -EAGAIN) { ++port->stats.tx_stall; - else if (n == -ENODATA) + } else if (n == -ENODATA) { fwtty_profile_data(port->stats.txns, 0); - else { + } else { ++port->stats.fifo_errs; fwtty_err_ratelimited(port, "fifo err: %d\n", n); @@ -1264,8 +1264,9 @@ static int set_serial_info(struct fwtty_port *port, if (((tmp.flags & ~ASYNC_USR_MASK) != (port->port.flags & ~ASYNC_USR_MASK))) return -EPERM; - } else + } else { port->port.close_delay = tmp.close_delay * HZ / 100; + } return 0; } @@ -1308,9 +1309,9 @@ static void fwtty_set_termios(struct tty_struct *tty, struct ktermios *old) spin_lock_bh(&port->lock); baud = set_termios(port, tty); - if ((baud == 0) && (old->c_cflag & CBAUD)) + if ((baud == 0) && (old->c_cflag & CBAUD)) { port->mctrl &= ~(TIOCM_DTR | TIOCM_RTS); - else if ((baud != 0) && !(old->c_cflag & CBAUD)) { + } else if ((baud != 0) && !(old->c_cflag & CBAUD)) { if (C_CRTSCTS(tty) || !test_bit(TTY_THROTTLED, &tty->flags)) port->mctrl |= TIOCM_DTR | TIOCM_RTS; else @@ -1733,8 +1734,9 @@ static inline int fwserial_send_mgmt_sync(struct fwtty_peer *peer, rcode == RCODE_GENERATION) { fwtty_dbg(&peer->unit, "mgmt write error: %d\n", rcode); continue; - } else + } else { break; + } } while (--tries > 0); return rcode; } @@ -2744,9 +2746,9 @@ static int fwserial_parse_mgmt_write(struct fwtty_peer *peer, break; case FWSC_VIRT_CABLE_UNPLUG_RSP: - if (peer->state != FWPS_UNPLUG_PENDING) + if (peer->state != FWPS_UNPLUG_PENDING) { rcode = RCODE_CONFLICT_ERROR; - else { + } else { if (be16_to_cpu(pkt->hdr.code) & FWSC_RSP_NACK) fwtty_notice(&peer->unit, "NACK unplug?\n"); port = peer_revert_state(peer); -- cgit v1.2.3 From d949210a6cb2a03c4480d3f1bdf70eb2eaa42989 Mon Sep 17 00:00:00 2001 From: Dominique van den Broeck Date: Sat, 12 Apr 2014 15:18:14 +0200 Subject: fwserial: (coding style) useless "extern" & space Style-only modifications to make checkpatch.pl --file --strict a bit happier. Removed useless "extern" in dma_fifo.h ; Removed one supernumerary space. Signed-off-by: Dominique van den Broeck Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fwserial/dma_fifo.h | 18 +++++++++--------- drivers/staging/fwserial/fwserial.c | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/fwserial/dma_fifo.h b/drivers/staging/fwserial/dma_fifo.h index a113fe1e6f19..1dfe75daba41 100644 --- a/drivers/staging/fwserial/dma_fifo.h +++ b/drivers/staging/fwserial/dma_fifo.h @@ -85,15 +85,15 @@ static inline bool dp_is_completed(struct dma_pending *dp) return (unsigned long)dp->data & 1UL; } -extern void dma_fifo_init(struct dma_fifo *fifo); -extern int dma_fifo_alloc(struct dma_fifo *fifo, int size, unsigned align, - int tx_limit, int open_limit, gfp_t gfp_mask); -extern void dma_fifo_free(struct dma_fifo *fifo); -extern void dma_fifo_reset(struct dma_fifo *fifo); -extern int dma_fifo_in(struct dma_fifo *fifo, const void *src, int n); -extern int dma_fifo_out_pend(struct dma_fifo *fifo, struct dma_pending *pended); -extern int dma_fifo_out_complete(struct dma_fifo *fifo, - struct dma_pending *complete); +void dma_fifo_init(struct dma_fifo *fifo); +int dma_fifo_alloc(struct dma_fifo *fifo, int size, unsigned align, + int tx_limit, int open_limit, gfp_t gfp_mask); +void dma_fifo_free(struct dma_fifo *fifo); +void dma_fifo_reset(struct dma_fifo *fifo); +int dma_fifo_in(struct dma_fifo *fifo, const void *src, int n); +int dma_fifo_out_pend(struct dma_fifo *fifo, struct dma_pending *pended); +int dma_fifo_out_complete(struct dma_fifo *fifo, + struct dma_pending *complete); /* returns the # of used bytes in the fifo */ static inline int dma_fifo_level(struct dma_fifo *fifo) diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c index 3862ddf29891..ebe3259ac4b7 100644 --- a/drivers/staging/fwserial/fwserial.c +++ b/drivers/staging/fwserial/fwserial.c @@ -1820,7 +1820,7 @@ static void fwserial_release_port(struct fwtty_port *port, bool reset) static void fwserial_plug_timeout(unsigned long data) { - struct fwtty_peer *peer = (struct fwtty_peer *) data; + struct fwtty_peer *peer = (struct fwtty_peer *)data; struct fwtty_port *port; spin_lock_bh(&peer->lock); -- cgit v1.2.3 From cb790747383ddcebf3791219356701a40383a3a9 Mon Sep 17 00:00:00 2001 From: Dominique van den Broeck Date: Sat, 12 Apr 2014 15:18:15 +0200 Subject: fwserial: (coding style) removing FSF postal address Style-only modifications to make checkpatch.pl --file --strict a bit happier. Removing FSF postal address from file top comment since it has changed in the past, as stated by checkpatch.pl. Signed-off-by: Dominique van den Broeck Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fwserial/dma_fifo.c | 4 ---- drivers/staging/fwserial/dma_fifo.h | 4 ---- drivers/staging/fwserial/fwserial.c | 4 ---- 3 files changed, 12 deletions(-) diff --git a/drivers/staging/fwserial/dma_fifo.c b/drivers/staging/fwserial/dma_fifo.c index 528d0b9e7849..027906249598 100644 --- a/drivers/staging/fwserial/dma_fifo.c +++ b/drivers/staging/fwserial/dma_fifo.c @@ -12,10 +12,6 @@ * 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 diff --git a/drivers/staging/fwserial/dma_fifo.h b/drivers/staging/fwserial/dma_fifo.h index 1dfe75daba41..410988224f89 100644 --- a/drivers/staging/fwserial/dma_fifo.h +++ b/drivers/staging/fwserial/dma_fifo.h @@ -12,10 +12,6 @@ * 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 _DMA_FIFO_H_ diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c index ebe3259ac4b7..9758c351026f 100644 --- a/drivers/staging/fwserial/fwserial.c +++ b/drivers/staging/fwserial/fwserial.c @@ -12,10 +12,6 @@ * 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) KBUILD_MODNAME ": " fmt -- cgit v1.2.3 From e8429b0913a08d5779b93f5dc5e017cd48026b8b Mon Sep 17 00:00:00 2001 From: Monam Agarwal Date: Mon, 24 Mar 2014 00:08:22 +0530 Subject: drivers/staging: Use RCU_INIT_POINTER(x, NULL) in fwserial/fwserial.c This patch replaces rcu_assign_pointer(x, NULL) with RCU_INIT_POINTER(x, NULL) The rcu_assign_pointer() ensures that the initialization of a structure is carried out before storing a pointer to that structure. And in the case of the NULL pointer, there is no structure to initialize. So, rcu_assign_pointer(p, NULL) can be safely converted to RCU_INIT_POINTER(p, NULL) Signed-off-by: Monam Agarwal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fwserial/fwserial.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c index 9758c351026f..384758b11e3c 100644 --- a/drivers/staging/fwserial/fwserial.c +++ b/drivers/staging/fwserial/fwserial.c @@ -1807,7 +1807,7 @@ static void fwserial_release_port(struct fwtty_port *port, bool reset) port->max_payload = link_speed_to_max_payload(SCODE_100); dma_fifo_change_tx_limit(&port->tx_fifo, port->max_payload); - rcu_assign_pointer(port->peer, NULL); + RCU_INIT_POINTER(port->peer, NULL); spin_unlock_bh(&port->lock); if (port->port.console && port->fwcon_ops->notify != NULL) @@ -2240,7 +2240,7 @@ static int fwserial_create(struct fw_unit *unit) port->max_payload = link_speed_to_max_payload(SCODE_100); dma_fifo_init(&port->tx_fifo); - rcu_assign_pointer(port->peer, NULL); + RCU_INIT_POINTER(port->peer, NULL); serial->ports[i] = port; /* get unique bus addr region for port's status & recv fifo */ -- cgit v1.2.3 From 0fb21b2c1a057139c096f36d7dce4d38977f3129 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 23 Apr 2014 15:52:30 -0700 Subject: staging: comedi: adl_pci9111: clarify Step 2b of the (*do_cmdtest) This step of the (*do_cmdtest) verifies that the selected trigger sources are mutually compatible. For this driver the scan_begin_src must be TRIG_FOLLOW or the same source as the convert_src. Simplify the logic to clarify this. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9111.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index 6fc85932643c..9225a382a2ae 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -379,14 +379,10 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev, /* Step 2b : and mutually compatible */ - if ((cmd->convert_src == TRIG_TIMER) && - !((cmd->scan_begin_src == TRIG_TIMER) || - (cmd->scan_begin_src == TRIG_FOLLOW))) - err |= -EINVAL; - if ((cmd->convert_src == TRIG_EXT) && - !((cmd->scan_begin_src == TRIG_EXT) || - (cmd->scan_begin_src == TRIG_FOLLOW))) - err |= -EINVAL; + if (cmd->scan_begin_src != TRIG_FOLLOW) { + if (cmd->scan_begin_src != cmd->convert_src) + err |= -EINVAL; + } if (err) return 2; -- cgit v1.2.3 From a5c9c71f8901b4ce61fd858bdcca5a8f2750b296 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 23 Apr 2014 15:52:31 -0700 Subject: staging: comedi: cb_pcidas64: remove unnecessary Step 2b test in (*do_cmdtest) This test is unnecessary. The cfc_check_trigger_src() in Step 1 ensures that the trigger source is one of these values and Step 2 makes sure it's only one of these values. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 4061f0481de2..0e13ac9f3473 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -2078,9 +2078,6 @@ static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, if (cmd->convert_src == TRIG_EXT && cmd->scan_begin_src == TRIG_TIMER) err |= -EINVAL; - if (cmd->stop_src != TRIG_COUNT && - cmd->stop_src != TRIG_NONE && cmd->stop_src != TRIG_EXT) - err |= -EINVAL; if (err) return 2; -- cgit v1.2.3 From 8f266f47c2c9fc17b0271a06d6eb321bee44980c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 23 Apr 2014 15:52:32 -0700 Subject: staging: comedi: me4000: remove unnecessary Step 2b test in (*do_cmdtest) This test is unnecessary. It covers all the possible combinations of the scan_end_src and stop_src triggers so the final else can never be reached. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/me4000.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c index f43221fcd15e..5fc4850afb74 100644 --- a/drivers/staging/comedi/drivers/me4000.c +++ b/drivers/staging/comedi/drivers/me4000.c @@ -902,17 +902,6 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev, err |= -EINVAL; } - if (cmd->stop_src == TRIG_NONE && cmd->scan_end_src == TRIG_NONE) { - } else if (cmd->stop_src == TRIG_COUNT && - cmd->scan_end_src == TRIG_NONE) { - } else if (cmd->stop_src == TRIG_NONE && - cmd->scan_end_src == TRIG_COUNT) { - } else if (cmd->stop_src == TRIG_COUNT && - cmd->scan_end_src == TRIG_COUNT) { - } else { - err |= -EINVAL; - } - if (err) return 2; -- cgit v1.2.3 From 170b09b03b6ed4a1a89d9d83d1eac0e2f733f633 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Thu, 17 Apr 2014 01:33:03 -0500 Subject: staging: comedi: addi_apci_1564: tidy up apci1564_reset() The reset function for this driver is a bit of a mess; clean it up to ensure that it is functioning properly. Signed-off-by: Chase Southwood Reviewed-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci1564.c | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c index 4db3bea4e20a..7976a22ae94d 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c @@ -21,6 +21,8 @@ * */ +#include "../addi_watchdog.h" + #define APCI1564_ADDRESS_RANGE 128 /* Digital Input IRQ Function Selection */ @@ -581,26 +583,30 @@ static int apci1564_reset(struct comedi_device *dev) { struct addi_private *devpriv = dev->private; - /* disable the interrupts */ + ui_Type = 0; + + /* Disable the input interrupts and reset status register */ outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DI_IRQ_REG); - /* Reset the interrupt status register */ inl(devpriv->i_IobaseAmcc + APCI1564_DI_INT_STATUS_REG); - /* Disable the and/or interrupt */ outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DI_INT_MODE1_REG); outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DI_INT_MODE2_REG); - devpriv->b_DigitalOutputRegister = 0; - ui_Type = 0; - /* Resets the output channels */ + + /* Reset the output channels and disable interrupts */ outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DO_REG); - /* Disables the interrupt. */ outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DO_INT_CTRL_REG); - outl(0x0, devpriv->i_IobaseAmcc + APCI1564_WDOG_RELOAD_REG); - outl(0x0, devpriv->i_IobaseAmcc + APCI1564_TIMER_REG); + + /* Reset the watchdog registers */ + addi_watchdog_reset(devpriv->i_IobaseAmcc + APCI1564_WDOG_REG); + + /* Reset the timer registers */ outl(0x0, devpriv->i_IobaseAmcc + APCI1564_TIMER_CTRL_REG); + outl(0x0, devpriv->i_IobaseAmcc + APCI1564_TIMER_RELOAD_REG); + /* Reset the counter registers */ outl(0x0, dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER1)); outl(0x0, dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER2)); outl(0x0, dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER3)); outl(0x0, dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER4)); + return 0; } -- cgit v1.2.3 From 5aae190100727086d7a752cd9d2f3889ff7359fe Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 23 Apr 2014 15:57:16 -0700 Subject: staging: comedi: amplc_pci224: remove pci224_cascade_ns_to_timer() This function is just a wrapper around i8253_cascade_ns_to_timer(). Remove it. Signed-off-by: H Hartley Sweeten Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci224.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index 3b9a8b9ae39c..a34bd9db10c0 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -466,16 +466,6 @@ pci224_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, return i; } -/* - * Just a wrapper for the inline function 'i8253_cascade_ns_to_timer'. - */ -static void -pci224_cascade_ns_to_timer(int osc_base, unsigned int *d1, unsigned int *d2, - unsigned int *nanosec, int round_mode) -{ - i8253_cascade_ns_to_timer(osc_base, d1, d2, nanosec, round_mode); -} - /* * Kills a command running on the AO subdevice. */ @@ -886,10 +876,10 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, /* Use two timers. */ div1 = devpriv->cached_div1; div2 = devpriv->cached_div2; - pci224_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, - &div1, &div2, - &cmd->scan_begin_arg, - round_mode); + i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, + &div1, &div2, + &cmd->scan_begin_arg, + round_mode); devpriv->cached_div1 = div1; devpriv->cached_div2 = div2; } @@ -1001,9 +991,9 @@ static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) /* Use two timers. */ div1 = devpriv->cached_div1; div2 = devpriv->cached_div2; - pci224_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, - &div1, &div2, - &ns, round_mode); + i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, + &div1, &div2, + &ns, round_mode); } /* -- cgit v1.2.3 From 40d948be0ae3e40ddc0aba7b1f34f9bfd1a8bb90 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 23 Apr 2014 15:57:17 -0700 Subject: staging: comedi: amplc_pci224: factor out the 'start pacer' code To clarify the analog output (*do_cmd) function, factor out the code that starts the pacer. Signed-off-by: H Hartley Sweeten Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci224.c | 142 +++++++++++++------------- 1 file changed, 73 insertions(+), 69 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index a34bd9db10c0..727fc225ad46 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -901,9 +901,77 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, return 0; } -/* - * 'do_cmd' function for AO subdevice. - */ +static void pci224_ao_start_pacer(struct comedi_device *dev, + struct comedi_subdevice *s) +{ + struct pci224_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; + unsigned int div1, div2, round; + unsigned int ns = cmd->scan_begin_arg; + int round_mode = cmd->flags & TRIG_ROUND_MASK; + + /* Check whether to use a single timer. */ + switch (round_mode) { + case TRIG_ROUND_NEAREST: + default: + round = I8254_OSC_BASE_10MHZ / 2; + break; + case TRIG_ROUND_DOWN: + round = 0; + break; + case TRIG_ROUND_UP: + round = I8254_OSC_BASE_10MHZ - 1; + break; + } + /* Be careful to avoid overflow! */ + div2 = cmd->scan_begin_arg / I8254_OSC_BASE_10MHZ; + div2 += (round + cmd->scan_begin_arg % I8254_OSC_BASE_10MHZ) / + I8254_OSC_BASE_10MHZ; + if (div2 <= 0x10000) { + /* A single timer will suffice. */ + if (div2 < 2) + div2 = 2; + div2 &= 0xffff; + div1 = 1; /* Flag that single timer to be used. */ + } else { + /* Use two timers. */ + div1 = devpriv->cached_div1; + div2 = devpriv->cached_div2; + i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, + &div1, &div2, + &ns, round_mode); + } + + /* + * The output of timer Z2-0 will be used as the scan trigger + * source. + */ + /* Make sure Z2-0 is gated on. */ + outb(GAT_CONFIG(0, GAT_VCC), + devpriv->iobase1 + PCI224_ZGAT_SCE); + if (div1 == 1) { + /* Not cascading. Z2-0 needs 10 MHz clock. */ + outb(CLK_CONFIG(0, CLK_10MHZ), + devpriv->iobase1 + PCI224_ZCLK_SCE); + } else { + /* Cascading with Z2-2. */ + /* Make sure Z2-2 is gated on. */ + outb(GAT_CONFIG(2, GAT_VCC), + devpriv->iobase1 + PCI224_ZGAT_SCE); + /* Z2-2 needs 10 MHz clock. */ + outb(CLK_CONFIG(2, CLK_10MHZ), + devpriv->iobase1 + PCI224_ZCLK_SCE); + /* Load Z2-2 mode (2) and counter (div1). */ + i8254_load(devpriv->iobase1 + PCI224_Z2_CT0, 0, + 2, div1, 2); + /* Z2-0 is clocked from Z2-2's output. */ + outb(CLK_CONFIG(0, CLK_OUTNM1), + devpriv->iobase1 + PCI224_ZCLK_SCE); + } + /* Load Z2-0 mode (2) and counter (div2). */ + i8254_load(devpriv->iobase1 + PCI224_Z2_CT0, 0, 0, div2, 2); +} + static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct pci224_private *devpriv = dev->private; @@ -959,72 +1027,8 @@ static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) outw(devpriv->daccon | PCI224_DACCON_FIFORESET, dev->iobase + PCI224_DACCON); - if (cmd->scan_begin_src == TRIG_TIMER) { - unsigned int div1, div2, round; - unsigned int ns = cmd->scan_begin_arg; - int round_mode = cmd->flags & TRIG_ROUND_MASK; - - /* Check whether to use a single timer. */ - switch (round_mode) { - case TRIG_ROUND_NEAREST: - default: - round = I8254_OSC_BASE_10MHZ / 2; - break; - case TRIG_ROUND_DOWN: - round = 0; - break; - case TRIG_ROUND_UP: - round = I8254_OSC_BASE_10MHZ - 1; - break; - } - /* Be careful to avoid overflow! */ - div2 = cmd->scan_begin_arg / I8254_OSC_BASE_10MHZ; - div2 += (round + cmd->scan_begin_arg % I8254_OSC_BASE_10MHZ) / - I8254_OSC_BASE_10MHZ; - if (div2 <= 0x10000) { - /* A single timer will suffice. */ - if (div2 < 2) - div2 = 2; - div2 &= 0xffff; - div1 = 1; /* Flag that single timer to be used. */ - } else { - /* Use two timers. */ - div1 = devpriv->cached_div1; - div2 = devpriv->cached_div2; - i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, - &div1, &div2, - &ns, round_mode); - } - - /* - * The output of timer Z2-0 will be used as the scan trigger - * source. - */ - /* Make sure Z2-0 is gated on. */ - outb(GAT_CONFIG(0, GAT_VCC), - devpriv->iobase1 + PCI224_ZGAT_SCE); - if (div1 == 1) { - /* Not cascading. Z2-0 needs 10 MHz clock. */ - outb(CLK_CONFIG(0, CLK_10MHZ), - devpriv->iobase1 + PCI224_ZCLK_SCE); - } else { - /* Cascading with Z2-2. */ - /* Make sure Z2-2 is gated on. */ - outb(GAT_CONFIG(2, GAT_VCC), - devpriv->iobase1 + PCI224_ZGAT_SCE); - /* Z2-2 needs 10 MHz clock. */ - outb(CLK_CONFIG(2, CLK_10MHZ), - devpriv->iobase1 + PCI224_ZCLK_SCE); - /* Load Z2-2 mode (2) and counter (div1). */ - i8254_load(devpriv->iobase1 + PCI224_Z2_CT0, 0, - 2, div1, 2); - /* Z2-0 is clocked from Z2-2's output. */ - outb(CLK_CONFIG(0, CLK_OUTNM1), - devpriv->iobase1 + PCI224_ZCLK_SCE); - } - /* Load Z2-0 mode (2) and counter (div2). */ - i8254_load(devpriv->iobase1 + PCI224_Z2_CT0, 0, 0, div2, 2); - } + if (cmd->scan_begin_src == TRIG_TIMER) + pci224_ao_start_pacer(dev, s); /* * Sort out end of acquisition. -- cgit v1.2.3 From afb2bf149ac80b6d59e4139c936352ec90f45559 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 23 Apr 2014 15:57:18 -0700 Subject: staging: comedi: amplc_pci224: always cascade the 8254 timers The 8254 timers are only used in this driver to generate the analog output pacer. To simplify the driver, always cascade the timers. Signed-off-by: H Hartley Sweeten Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci224.c | 123 ++++++-------------------- 1 file changed, 25 insertions(+), 98 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index 727fc225ad46..37a81b72633f 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -841,51 +841,15 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, /* Step 4: fix up any arguments. */ if (cmd->scan_begin_src == TRIG_TIMER) { - unsigned int div1, div2, round; - int round_mode = cmd->flags & TRIG_ROUND_MASK; - tmp = cmd->scan_begin_arg; - /* Check whether to use a single timer. */ - switch (round_mode) { - case TRIG_ROUND_NEAREST: - default: - round = I8254_OSC_BASE_10MHZ / 2; - break; - case TRIG_ROUND_DOWN: - round = 0; - break; - case TRIG_ROUND_UP: - round = I8254_OSC_BASE_10MHZ - 1; - break; - } - /* Be careful to avoid overflow! */ - div2 = cmd->scan_begin_arg / I8254_OSC_BASE_10MHZ; - div2 += (round + cmd->scan_begin_arg % I8254_OSC_BASE_10MHZ) / - I8254_OSC_BASE_10MHZ; - if (div2 <= 0x10000) { - /* A single timer will suffice. */ - if (div2 < 2) - div2 = 2; - cmd->scan_begin_arg = div2 * I8254_OSC_BASE_10MHZ; - if (cmd->scan_begin_arg < div2 || - cmd->scan_begin_arg < I8254_OSC_BASE_10MHZ) { - /* Overflow! */ - cmd->scan_begin_arg = MAX_SCAN_PERIOD; - } - } else { - /* Use two timers. */ - div1 = devpriv->cached_div1; - div2 = devpriv->cached_div2; - i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, - &div1, &div2, - &cmd->scan_begin_arg, - round_mode); - devpriv->cached_div1 = div1; - devpriv->cached_div2 = div2; - } + /* Use two timers. */ + i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, + &devpriv->cached_div1, + &devpriv->cached_div2, + &cmd->scan_begin_arg, + cmd->flags); if (tmp != cmd->scan_begin_arg) err++; - } if (err) @@ -906,70 +870,33 @@ static void pci224_ao_start_pacer(struct comedi_device *dev, { struct pci224_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - unsigned int div1, div2, round; - unsigned int ns = cmd->scan_begin_arg; - int round_mode = cmd->flags & TRIG_ROUND_MASK; - /* Check whether to use a single timer. */ - switch (round_mode) { - case TRIG_ROUND_NEAREST: - default: - round = I8254_OSC_BASE_10MHZ / 2; - break; - case TRIG_ROUND_DOWN: - round = 0; - break; - case TRIG_ROUND_UP: - round = I8254_OSC_BASE_10MHZ - 1; - break; - } - /* Be careful to avoid overflow! */ - div2 = cmd->scan_begin_arg / I8254_OSC_BASE_10MHZ; - div2 += (round + cmd->scan_begin_arg % I8254_OSC_BASE_10MHZ) / - I8254_OSC_BASE_10MHZ; - if (div2 <= 0x10000) { - /* A single timer will suffice. */ - if (div2 < 2) - div2 = 2; - div2 &= 0xffff; - div1 = 1; /* Flag that single timer to be used. */ - } else { - /* Use two timers. */ - div1 = devpriv->cached_div1; - div2 = devpriv->cached_div2; - i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, - &div1, &div2, - &ns, round_mode); - } + /* Use two timers. */ + i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, + &devpriv->cached_div1, + &devpriv->cached_div2, + &cmd->scan_begin_arg, + cmd->flags); /* * The output of timer Z2-0 will be used as the scan trigger * source. */ /* Make sure Z2-0 is gated on. */ - outb(GAT_CONFIG(0, GAT_VCC), - devpriv->iobase1 + PCI224_ZGAT_SCE); - if (div1 == 1) { - /* Not cascading. Z2-0 needs 10 MHz clock. */ - outb(CLK_CONFIG(0, CLK_10MHZ), - devpriv->iobase1 + PCI224_ZCLK_SCE); - } else { - /* Cascading with Z2-2. */ - /* Make sure Z2-2 is gated on. */ - outb(GAT_CONFIG(2, GAT_VCC), - devpriv->iobase1 + PCI224_ZGAT_SCE); - /* Z2-2 needs 10 MHz clock. */ - outb(CLK_CONFIG(2, CLK_10MHZ), - devpriv->iobase1 + PCI224_ZCLK_SCE); - /* Load Z2-2 mode (2) and counter (div1). */ - i8254_load(devpriv->iobase1 + PCI224_Z2_CT0, 0, - 2, div1, 2); - /* Z2-0 is clocked from Z2-2's output. */ - outb(CLK_CONFIG(0, CLK_OUTNM1), - devpriv->iobase1 + PCI224_ZCLK_SCE); - } + outb(GAT_CONFIG(0, GAT_VCC), devpriv->iobase1 + PCI224_ZGAT_SCE); + /* Cascading with Z2-2. */ + /* Make sure Z2-2 is gated on. */ + outb(GAT_CONFIG(2, GAT_VCC), devpriv->iobase1 + PCI224_ZGAT_SCE); + /* Z2-2 needs 10 MHz clock. */ + outb(CLK_CONFIG(2, CLK_10MHZ), devpriv->iobase1 + PCI224_ZCLK_SCE); + /* Load Z2-2 mode (2) and counter (div1). */ + i8254_load(devpriv->iobase1 + PCI224_Z2_CT0, 0, + 2, devpriv->cached_div1, 2); + /* Z2-0 is clocked from Z2-2's output. */ + outb(CLK_CONFIG(0, CLK_OUTNM1), devpriv->iobase1 + PCI224_ZCLK_SCE); /* Load Z2-0 mode (2) and counter (div2). */ - i8254_load(devpriv->iobase1 + PCI224_Z2_CT0, 0, 0, div2, 2); + i8254_load(devpriv->iobase1 + PCI224_Z2_CT0, 0, + 0, devpriv->cached_div2, 2); } static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) -- cgit v1.2.3 From 43268701b50e7dbbad767e118e0023c703c7e3da Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 23 Apr 2014 15:57:19 -0700 Subject: staging: comedi: amplc_pci224: only calc the pacer divisors once When the cmd->scan_begin_src == TRIG_TIMER the divisors needed to generate the pacer time are calculated in the (*do_cmdtest) to validate the cmd->scan_begin_arg. The core always does the (*do_cmdtest) before the (*do_cmd) so there is no reason to recalc the divisors. Signed-off-by: H Hartley Sweeten Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci224.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index 37a81b72633f..f0b04cac4a6e 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -869,14 +869,6 @@ static void pci224_ao_start_pacer(struct comedi_device *dev, struct comedi_subdevice *s) { struct pci224_private *devpriv = dev->private; - struct comedi_cmd *cmd = &s->async->cmd; - - /* Use two timers. */ - i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, - &devpriv->cached_div1, - &devpriv->cached_div2, - &cmd->scan_begin_arg, - cmd->flags); /* * The output of timer Z2-0 will be used as the scan trigger -- cgit v1.2.3 From b30c3e824ebaa142bf7361c567612727d24af717 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Thu, 24 Apr 2014 02:19:01 -0500 Subject: staging: comedi: addi_apci_1564: separate from addi_common.c Using the addi-data "common" code in addi_apci_1564 introduces a lot of bloat. By separating this driver off from addi_common.c, a lot of the common code can be stripped out. This patch copies the code over from addi_common.c, and removes the #include of the file. The auto_attach function from the common code replaces the one that was previously in this driver, though renamed to that it stays within the namespace associated with this driver, and the detach function has been renamed for this reason as well. Signed-off-by: Chase Southwood Reviewed-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1564.c | 245 +++++++++++++++++++++++- 1 file changed, 240 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 11aa0bd5d7b1..792916d230e1 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -9,7 +9,6 @@ #include "addi-data/addi_eeprom.c" #include "addi-data/hwdrv_apci1564.c" -#include "addi-data/addi_common.c" static const struct addi_board apci1564_boardtypes[] = { { @@ -34,19 +33,255 @@ static const struct addi_board apci1564_boardtypes[] = { }, }; +static int i_ADDIDATA_InsnReadEeprom(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + const struct addi_board *this_board = comedi_board(dev); + struct addi_private *devpriv = dev->private; + unsigned short w_Address = CR_CHAN(insn->chanspec); + unsigned short w_Data; + + w_Data = addi_eeprom_readw(devpriv->i_IobaseAmcc, + this_board->pc_EepromChip, 2 * w_Address); + data[0] = w_Data; + + return insn->n; +} + +static irqreturn_t v_ADDI_Interrupt(int irq, void *d) +{ + struct comedi_device *dev = d; + const struct addi_board *this_board = comedi_board(dev); + + this_board->interrupt(irq, d); + return IRQ_RETVAL(1); +} + +static int i_ADDI_Reset(struct comedi_device *dev) +{ + const struct addi_board *this_board = comedi_board(dev); + + this_board->reset(dev); + return 0; +} + static int apci1564_auto_attach(struct comedi_device *dev, - unsigned long context) + unsigned long context_unused) +{ + struct pci_dev *pcidev = comedi_to_pci_dev(dev); + const struct addi_board *this_board = comedi_board(dev); + struct addi_private *devpriv; + struct comedi_subdevice *s; + int ret, n_subdevices; + unsigned int dw_Dummy; + + dev->board_name = this_board->pc_DriverName; + + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); + if (!devpriv) + return -ENOMEM; + + ret = comedi_pci_enable(dev); + if (ret) + return ret; + + if (this_board->i_IorangeBase1) + dev->iobase = pci_resource_start(pcidev, 1); + else + dev->iobase = pci_resource_start(pcidev, 0); + + devpriv->iobase = dev->iobase; + devpriv->i_IobaseAmcc = pci_resource_start(pcidev, 0); + devpriv->i_IobaseAddon = pci_resource_start(pcidev, 2); + devpriv->i_IobaseReserved = pci_resource_start(pcidev, 3); + + /* Initialize parameters that can be overridden in EEPROM */ + devpriv->s_EeParameters.i_NbrAiChannel = this_board->i_NbrAiChannel; + devpriv->s_EeParameters.i_NbrAoChannel = this_board->i_NbrAoChannel; + devpriv->s_EeParameters.i_AiMaxdata = this_board->i_AiMaxdata; + devpriv->s_EeParameters.i_AoMaxdata = this_board->i_AoMaxdata; + devpriv->s_EeParameters.i_NbrDiChannel = this_board->i_NbrDiChannel; + devpriv->s_EeParameters.i_NbrDoChannel = this_board->i_NbrDoChannel; + devpriv->s_EeParameters.i_DoMaxdata = this_board->i_DoMaxdata; + devpriv->s_EeParameters.i_Timer = this_board->i_Timer; + devpriv->s_EeParameters.ui_MinAcquisitiontimeNs = + this_board->ui_MinAcquisitiontimeNs; + devpriv->s_EeParameters.ui_MinDelaytimeNs = + this_board->ui_MinDelaytimeNs; + + /* ## */ + + if (pcidev->irq > 0) { + ret = request_irq(pcidev->irq, v_ADDI_Interrupt, IRQF_SHARED, + dev->board_name, dev); + if (ret == 0) + dev->irq = pcidev->irq; + } + + /* Read eepeom and fill addi_board Structure */ + + if (this_board->i_PCIEeprom) { + if (!(strcmp(this_board->pc_EepromChip, "S5920"))) { + /* Set 3 wait stait */ + if (!(strcmp(dev->board_name, "apci035"))) + outl(0x80808082, devpriv->i_IobaseAmcc + 0x60); + else + outl(0x83838383, devpriv->i_IobaseAmcc + 0x60); + + /* Enable the interrupt for the controller */ + dw_Dummy = inl(devpriv->i_IobaseAmcc + 0x38); + outl(dw_Dummy | 0x2000, devpriv->i_IobaseAmcc + 0x38); + } + addi_eeprom_read_info(dev, pci_resource_start(pcidev, 0)); + } + + n_subdevices = 7; + ret = comedi_alloc_subdevices(dev, n_subdevices); + if (ret) + return ret; + + /* Allocate and Initialise AI Subdevice Structures */ + s = &dev->subdevices[0]; + if ((devpriv->s_EeParameters.i_NbrAiChannel) + || (this_board->i_NbrAiChannelDiff)) { + dev->read_subdev = s; + s->type = COMEDI_SUBD_AI; + s->subdev_flags = + SDF_READABLE | SDF_COMMON | SDF_GROUND + | SDF_DIFF; + if (devpriv->s_EeParameters.i_NbrAiChannel) { + s->n_chan = + devpriv->s_EeParameters.i_NbrAiChannel; + devpriv->b_SingelDiff = 0; + } else { + s->n_chan = this_board->i_NbrAiChannelDiff; + devpriv->b_SingelDiff = 1; + } + s->maxdata = devpriv->s_EeParameters.i_AiMaxdata; + s->len_chanlist = this_board->i_AiChannelList; + s->range_table = this_board->pr_AiRangelist; + + s->insn_config = this_board->ai_config; + s->insn_read = this_board->ai_read; + s->insn_write = this_board->ai_write; + s->insn_bits = this_board->ai_bits; + s->do_cmdtest = this_board->ai_cmdtest; + s->do_cmd = this_board->ai_cmd; + s->cancel = this_board->ai_cancel; + + } else { + s->type = COMEDI_SUBD_UNUSED; + } + + /* Allocate and Initialise AO Subdevice Structures */ + s = &dev->subdevices[1]; + if (devpriv->s_EeParameters.i_NbrAoChannel) { + s->type = COMEDI_SUBD_AO; + s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; + s->n_chan = devpriv->s_EeParameters.i_NbrAoChannel; + s->maxdata = devpriv->s_EeParameters.i_AoMaxdata; + s->len_chanlist = + devpriv->s_EeParameters.i_NbrAoChannel; + s->insn_write = this_board->ao_write; + } else { + s->type = COMEDI_SUBD_UNUSED; + } + /* Allocate and Initialise DI Subdevice Structures */ + s = &dev->subdevices[2]; + if (devpriv->s_EeParameters.i_NbrDiChannel) { + s->type = COMEDI_SUBD_DI; + s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON; + s->n_chan = devpriv->s_EeParameters.i_NbrDiChannel; + s->maxdata = 1; + s->len_chanlist = + devpriv->s_EeParameters.i_NbrDiChannel; + s->range_table = &range_digital; + s->insn_config = this_board->di_config; + s->insn_read = this_board->di_read; + s->insn_write = this_board->di_write; + s->insn_bits = this_board->di_bits; + } else { + s->type = COMEDI_SUBD_UNUSED; + } + /* Allocate and Initialise DO Subdevice Structures */ + s = &dev->subdevices[3]; + if (devpriv->s_EeParameters.i_NbrDoChannel) { + s->type = COMEDI_SUBD_DO; + s->subdev_flags = + SDF_READABLE | SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; + s->n_chan = devpriv->s_EeParameters.i_NbrDoChannel; + s->maxdata = devpriv->s_EeParameters.i_DoMaxdata; + s->len_chanlist = + devpriv->s_EeParameters.i_NbrDoChannel; + s->range_table = &range_digital; + + /* insn_config - for digital output memory */ + s->insn_config = this_board->do_config; + s->insn_write = this_board->do_write; + s->insn_bits = this_board->do_bits; + s->insn_read = this_board->do_read; + } else { + s->type = COMEDI_SUBD_UNUSED; + } + + /* Allocate and Initialise Timer Subdevice Structures */ + s = &dev->subdevices[4]; + if (devpriv->s_EeParameters.i_Timer) { + s->type = COMEDI_SUBD_TIMER; + s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; + s->n_chan = 1; + s->maxdata = 0; + s->len_chanlist = 1; + s->range_table = &range_digital; + + s->insn_write = this_board->timer_write; + s->insn_read = this_board->timer_read; + s->insn_config = this_board->timer_config; + s->insn_bits = this_board->timer_bits; + } else { + s->type = COMEDI_SUBD_UNUSED; + } + + /* Allocate and Initialise TTL */ + s = &dev->subdevices[5]; + s->type = COMEDI_SUBD_UNUSED; + + /* EEPROM */ + s = &dev->subdevices[6]; + if (this_board->i_PCIEeprom) { + s->type = COMEDI_SUBD_MEMORY; + s->subdev_flags = SDF_READABLE | SDF_INTERNAL; + s->n_chan = 256; + s->maxdata = 0xffff; + s->insn_read = i_ADDIDATA_InsnReadEeprom; + } else { + s->type = COMEDI_SUBD_UNUSED; + } + + i_ADDI_Reset(dev); + return 0; +} + +static void apci1564_detach(struct comedi_device *dev) { - dev->board_ptr = &apci1564_boardtypes[0]; + struct addi_private *devpriv = dev->private; - return addi_auto_attach(dev, context); + if (devpriv) { + if (dev->iobase) + i_ADDI_Reset(dev); + if (dev->irq) + free_irq(dev->irq, dev); + } + comedi_pci_disable(dev); } static struct comedi_driver apci1564_driver = { .driver_name = "addi_apci_1564", .module = THIS_MODULE, .auto_attach = apci1564_auto_attach, - .detach = i_ADDI_Detach, + .detach = apci1564_detach, }; static int apci1564_pci_probe(struct pci_dev *dev, -- cgit v1.2.3 From 0ca26722f5b5bb2a763be65c38021cb6dc8289a4 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Fri, 25 Apr 2014 03:17:06 -0500 Subject: staging: comedi: addi_apci_1564: board does not have analog inputs This board does not have analog inputs. Remove the subdevice init for them. Signed-off-by: Chase Southwood Reviewed-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1564.c | 31 +------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 792916d230e1..eee10cc68af1 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -144,36 +144,7 @@ static int apci1564_auto_attach(struct comedi_device *dev, /* Allocate and Initialise AI Subdevice Structures */ s = &dev->subdevices[0]; - if ((devpriv->s_EeParameters.i_NbrAiChannel) - || (this_board->i_NbrAiChannelDiff)) { - dev->read_subdev = s; - s->type = COMEDI_SUBD_AI; - s->subdev_flags = - SDF_READABLE | SDF_COMMON | SDF_GROUND - | SDF_DIFF; - if (devpriv->s_EeParameters.i_NbrAiChannel) { - s->n_chan = - devpriv->s_EeParameters.i_NbrAiChannel; - devpriv->b_SingelDiff = 0; - } else { - s->n_chan = this_board->i_NbrAiChannelDiff; - devpriv->b_SingelDiff = 1; - } - s->maxdata = devpriv->s_EeParameters.i_AiMaxdata; - s->len_chanlist = this_board->i_AiChannelList; - s->range_table = this_board->pr_AiRangelist; - - s->insn_config = this_board->ai_config; - s->insn_read = this_board->ai_read; - s->insn_write = this_board->ai_write; - s->insn_bits = this_board->ai_bits; - s->do_cmdtest = this_board->ai_cmdtest; - s->do_cmd = this_board->ai_cmd; - s->cancel = this_board->ai_cancel; - - } else { - s->type = COMEDI_SUBD_UNUSED; - } + s->type = COMEDI_SUBD_UNUSED; /* Allocate and Initialise AO Subdevice Structures */ s = &dev->subdevices[1]; -- cgit v1.2.3 From 66037ce98d911bc2b15b23128e4447ea719f26e3 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Fri, 25 Apr 2014 03:18:10 -0500 Subject: staging: comedi: addi_apci_1564: board does not have analog outputs The board supported by this driver does not have analog outputs. Remove the subdevice init for it. Signed-off-by: Chase Southwood Reviewed-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1564.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index eee10cc68af1..5f6d3b56fad2 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -148,17 +148,8 @@ static int apci1564_auto_attach(struct comedi_device *dev, /* Allocate and Initialise AO Subdevice Structures */ s = &dev->subdevices[1]; - if (devpriv->s_EeParameters.i_NbrAoChannel) { - s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = devpriv->s_EeParameters.i_NbrAoChannel; - s->maxdata = devpriv->s_EeParameters.i_AoMaxdata; - s->len_chanlist = - devpriv->s_EeParameters.i_NbrAoChannel; - s->insn_write = this_board->ao_write; - } else { - s->type = COMEDI_SUBD_UNUSED; - } + s->type = COMEDI_SUBD_UNUSED; + /* Allocate and Initialise DI Subdevice Structures */ s = &dev->subdevices[2]; if (devpriv->s_EeParameters.i_NbrDiChannel) { -- cgit v1.2.3 From 060e3fe398479c067e8edcee5862500534cb75dd Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 23 Apr 2014 16:06:51 -0700 Subject: staging: comedi: adv_pci1710: remove 'ai_timer2' from private data This member of the private data is set to 0 but it is never used. Just remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 28ec48548317..0d0ec794fe6b 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -320,7 +320,6 @@ struct pci1710_private { unsigned int ai_flags; /* flaglist */ unsigned int ai_data_len; /* len of data buffer */ unsigned int ai_timer1; /* timers */ - unsigned int ai_timer2; unsigned short ao_data[4]; /* data output buffer */ unsigned int cnt0_write_wait; /* after a write, wait for update of the * internal state */ @@ -1129,7 +1128,6 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_flags = cmd->flags; devpriv->ai_data_len = s->async->prealloc_bufsz; devpriv->ai_timer1 = 0; - devpriv->ai_timer2 = 0; if (cmd->stop_src == TRIG_COUNT) devpriv->ai_scans = cmd->stop_arg; -- cgit v1.2.3 From cd0164e61680c2b643f34ced0955bff54ffe8f46 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 23 Apr 2014 16:06:52 -0700 Subject: staging: comedi: adv_pci1710: remove 'ai_timer1' from private data This member of the private data is just a copy of the cmd->convert_arg. Use that instead and remove the unnecessary sanity checking since it was already validated in the (*do_cmdtest). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 0d0ec794fe6b..c1e0e417a6ce 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -319,7 +319,6 @@ struct pci1710_private { unsigned int *ai_chanlist; /* actaul chanlist */ unsigned int ai_flags; /* flaglist */ unsigned int ai_data_len; /* len of data buffer */ - unsigned int ai_timer1; /* timers */ unsigned short ao_data[4]; /* data output buffer */ unsigned int cnt0_write_wait; /* after a write, wait for update of the * internal state */ @@ -956,8 +955,8 @@ static irqreturn_t interrupt_service_pci1710(int irq, void *d) static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev, struct comedi_subdevice *s) { - const struct boardtype *this_board = comedi_board(dev); struct pci1710_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; unsigned int divisor1 = 0, divisor2 = 0; unsigned int seglen; @@ -998,8 +997,6 @@ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev, switch (mode) { case 1: case 2: - if (devpriv->ai_timer1 < this_board->ai_ns_min) - devpriv->ai_timer1 = this_board->ai_ns_min; devpriv->CntrlReg |= Control_PACER | Control_IRQEN; if (mode == 2) { devpriv->ai_et_CntrlReg = devpriv->CntrlReg; @@ -1012,7 +1009,7 @@ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev, } i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, &divisor1, &divisor2, - &devpriv->ai_timer1, + &cmd->convert_arg, devpriv->ai_flags); outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL); if (mode != 2) { @@ -1127,7 +1124,6 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_chanlist = cmd->chanlist; devpriv->ai_flags = cmd->flags; devpriv->ai_data_len = s->async->prealloc_bufsz; - devpriv->ai_timer1 = 0; if (cmd->stop_src == TRIG_COUNT) devpriv->ai_scans = cmd->stop_arg; @@ -1137,7 +1133,6 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (cmd->scan_begin_src == TRIG_FOLLOW) { /* mode 1, 2, 3 */ if (cmd->convert_src == TRIG_TIMER) { /* mode 1 and 2 */ - devpriv->ai_timer1 = cmd->convert_arg; return pci171x_ai_docmd_and_mode(cmd->start_src == TRIG_EXT ? 2 : 1, dev, s); -- cgit v1.2.3 From 4d486e753dd6b5e235f95f1ff063028541e3087d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 23 Apr 2014 16:06:53 -0700 Subject: staging: comedi: adv_pci1710: remove 'ai_flags' from private data This member of the private data is just a copy of the cmd->flags. Use that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index c1e0e417a6ce..447addd26359 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -317,7 +317,6 @@ struct pci1710_private { unsigned int ai_scans; /* len of scanlist */ unsigned int ai_n_chan; /* how many channels is measured */ unsigned int *ai_chanlist; /* actaul chanlist */ - unsigned int ai_flags; /* flaglist */ unsigned int ai_data_len; /* len of data buffer */ unsigned short ao_data[4]; /* data output buffer */ unsigned int cnt0_write_wait; /* after a write, wait for update of the @@ -981,7 +980,7 @@ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev, devpriv->CntrlReg &= Control_CNT0; /* don't we want wake up every scan? devpriv->ai_eos=1; */ - if ((devpriv->ai_flags & TRIG_WAKE_EOS)) { + if (cmd->flags & TRIG_WAKE_EOS) { devpriv->ai_eos = 1; } else { devpriv->CntrlReg |= Control_ONEFH; @@ -1010,7 +1009,7 @@ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev, i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, &divisor1, &divisor2, &cmd->convert_arg, - devpriv->ai_flags); + cmd->flags); outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL); if (mode != 2) { /* start pacer */ @@ -1122,7 +1121,6 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_n_chan = cmd->chanlist_len; devpriv->ai_chanlist = cmd->chanlist; - devpriv->ai_flags = cmd->flags; devpriv->ai_data_len = s->async->prealloc_bufsz; if (cmd->stop_src == TRIG_COUNT) -- cgit v1.2.3 From 1f2706828d7e534a9751bcc63f9a5797fdc38284 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 23 Apr 2014 16:06:54 -0700 Subject: staging: comedi: adv_pci1710: remove 'ai_chanlist' from private data This member of the private data is just a copy of the cmd->chanlist. Use that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 447addd26359..4d2bdc1d52ed 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -316,7 +316,6 @@ struct pci1710_private { unsigned char da_ranges; /* copy of D/A outpit range register */ unsigned int ai_scans; /* len of scanlist */ unsigned int ai_n_chan; /* how many channels is measured */ - unsigned int *ai_chanlist; /* actaul chanlist */ unsigned int ai_data_len; /* len of data buffer */ unsigned short ao_data[4]; /* data output buffer */ unsigned int cnt0_write_wait; /* after a write, wait for update of the @@ -961,11 +960,11 @@ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev, start_pacer(dev, -1, 0, 0); /* stop pacer */ - seglen = check_channel_list(dev, s, devpriv->ai_chanlist, + seglen = check_channel_list(dev, s, cmd->chanlist, devpriv->ai_n_chan); if (seglen < 1) return -EINVAL; - setup_channel_list(dev, s, devpriv->ai_chanlist, + setup_channel_list(dev, s, cmd->chanlist, devpriv->ai_n_chan, seglen); outb(0, dev->iobase + PCI171x_CLRFIFO); @@ -1120,7 +1119,6 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) struct comedi_cmd *cmd = &s->async->cmd; devpriv->ai_n_chan = cmd->chanlist_len; - devpriv->ai_chanlist = cmd->chanlist; devpriv->ai_data_len = s->async->prealloc_bufsz; if (cmd->stop_src == TRIG_COUNT) -- cgit v1.2.3 From aaf483b18b8c17467141f2d7d57a15aed521e262 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 23 Apr 2014 16:06:55 -0700 Subject: staging: comedi: adv_pci1710: remove 'ai_n_chan' from private data This member of the private data is just a copy of the cmd->chanlist_len. Use that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 4d2bdc1d52ed..707def02c29b 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -315,7 +315,6 @@ struct pci1710_private { unsigned char act_chanlist_pos; /* actual position in MUX list */ unsigned char da_ranges; /* copy of D/A outpit range register */ unsigned int ai_scans; /* len of scanlist */ - unsigned int ai_n_chan; /* how many channels is measured */ unsigned int ai_data_len; /* len of data buffer */ unsigned short ao_data[4]; /* data output buffer */ unsigned int cnt0_write_wait; /* after a write, wait for update of the @@ -746,6 +745,7 @@ static void interrupt_pci1710_every_sample(void *d) struct comedi_device *dev = d; struct pci1710_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; + struct comedi_cmd *cmd = &s->async->cmd; int m; #ifdef PCI171x_PARANOIDCHECK const struct boardtype *this_board = comedi_board(dev); @@ -794,7 +794,7 @@ 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 >= cmd->chanlist_len) s->async->cur_chan = 0; @@ -822,6 +822,7 @@ static int move_block_from_fifo(struct comedi_device *dev, struct comedi_subdevice *s, int n, int turn) { struct pci1710_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; int i, j; #ifdef PCI171x_PARANOIDCHECK const struct boardtype *this_board = comedi_board(dev); @@ -851,7 +852,7 @@ static int move_block_from_fifo(struct comedi_device *dev, inw(dev->iobase + PCI171x_AD_DATA) & 0x0fff); #endif j++; - if (j >= devpriv->ai_n_chan) { + if (j >= cmd->chanlist_len) { j = 0; devpriv->ai_act_scan++; } @@ -960,12 +961,10 @@ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev, start_pacer(dev, -1, 0, 0); /* stop pacer */ - seglen = check_channel_list(dev, s, cmd->chanlist, - devpriv->ai_n_chan); + seglen = check_channel_list(dev, s, cmd->chanlist, cmd->chanlist_len); if (seglen < 1) return -EINVAL; - setup_channel_list(dev, s, cmd->chanlist, - devpriv->ai_n_chan, seglen); + setup_channel_list(dev, s, cmd->chanlist, cmd->chanlist_len, seglen); outb(0, dev->iobase + PCI171x_CLRFIFO); outb(0, dev->iobase + PCI171x_CLRINT); @@ -1118,7 +1117,6 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) struct pci1710_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - devpriv->ai_n_chan = cmd->chanlist_len; devpriv->ai_data_len = s->async->prealloc_bufsz; if (cmd->stop_src == TRIG_COUNT) -- cgit v1.2.3 From 07d93d1a9d4417f990d6f510491401f572a81a38 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 23 Apr 2014 16:06:56 -0700 Subject: staging: comedi: adv_pci1710: remove 'ai_scans' from private data This member of the private data is just a copy of the cmd->stop_arg. Use that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 707def02c29b..8fcc67a1c19e 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -314,7 +314,6 @@ struct pci1710_private { unsigned char act_chanlist_len; /* len of scanlist */ unsigned char act_chanlist_pos; /* actual position in MUX list */ unsigned char da_ranges; /* copy of D/A outpit range register */ - unsigned int ai_scans; /* len of scanlist */ unsigned int ai_data_len; /* len of data buffer */ unsigned short ao_data[4]; /* data output buffer */ unsigned int cnt0_write_wait; /* after a write, wait for update of the @@ -801,7 +800,7 @@ static void interrupt_pci1710_every_sample(void *d) if (s->async->cur_chan == 0) { /* one scan done */ devpriv->ai_act_scan++; if ((!devpriv->neverending_ai) && - (devpriv->ai_act_scan >= devpriv->ai_scans)) { + (devpriv->ai_act_scan >= cmd->stop_arg)) { /* all data sampled */ s->async->events |= COMEDI_CB_EOA; cfc_handle_events(dev, s); @@ -870,6 +869,7 @@ static void interrupt_pci1710_half_fifo(void *d) const struct boardtype *this_board = comedi_board(dev); struct pci1710_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; + struct comedi_cmd *cmd = &s->async->cmd; int m, samplesinbuf; m = inw(dev->iobase + PCI171x_STATUS); @@ -901,8 +901,8 @@ static void interrupt_pci1710_half_fifo(void *d) } if (!devpriv->neverending_ai) - if (devpriv->ai_act_scan >= devpriv->ai_scans) { /* all data - sampled */ + if (devpriv->ai_act_scan >= cmd->stop_arg) { + /* all data sampled */ s->async->events |= COMEDI_CB_EOA; cfc_handle_events(dev, s); return; @@ -985,7 +985,7 @@ 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 (cmd->stop_arg == 0) devpriv->neverending_ai = 1; /* well, user want neverending */ else @@ -1119,12 +1119,6 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_data_len = s->async->prealloc_bufsz; - if (cmd->stop_src == TRIG_COUNT) - devpriv->ai_scans = cmd->stop_arg; - 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 */ return pci171x_ai_docmd_and_mode(cmd->start_src == -- cgit v1.2.3 From 4b1fea003cdfb4ebe0764b484f1f808b7e2e5071 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 23 Apr 2014 16:06:57 -0700 Subject: staging: comedi: adv_pci1710: remove 'ai_data_len' from private data This member of the private data is just a copy of the s->async->prealloc_bufsz. Use that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 8fcc67a1c19e..9ce05353d12b 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -314,7 +314,6 @@ struct pci1710_private { unsigned char act_chanlist_len; /* len of scanlist */ unsigned char act_chanlist_pos; /* actual position in MUX list */ unsigned char da_ranges; /* copy of D/A outpit range register */ - unsigned int ai_data_len; /* len of data buffer */ unsigned short ao_data[4]; /* data output buffer */ unsigned int cnt0_write_wait; /* after a write, wait for update of the * internal state */ @@ -888,8 +887,8 @@ static void interrupt_pci1710_half_fifo(void *d) } samplesinbuf = this_board->fifo_half_size; - if (samplesinbuf * sizeof(short) >= devpriv->ai_data_len) { - m = devpriv->ai_data_len / sizeof(short); + if (samplesinbuf * sizeof(short) >= s->async->prealloc_bufsz) { + m = s->async->prealloc_bufsz / sizeof(short); if (move_block_from_fifo(dev, s, m, 0)) return; samplesinbuf -= m; @@ -1114,11 +1113,8 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev, */ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { - struct pci1710_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - devpriv->ai_data_len = s->async->prealloc_bufsz; - if (cmd->scan_begin_src == TRIG_FOLLOW) { /* mode 1, 2, 3 */ if (cmd->convert_src == TRIG_TIMER) { /* mode 1 and 2 */ return pci171x_ai_docmd_and_mode(cmd->start_src == -- cgit v1.2.3 From c56cad003decb41d5690ab7b5b74b89d3e3471ba Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 23 Apr 2014 16:06:58 -0700 Subject: staging: comedi: adv_pci1710: cmd->scan_begin_src can only be TRIG_FOLLOW In Step 1 of the (*do_cmdtest), the cmd->scan_begin_src is checked to only allow TRIG_FOLLOW. The (*do_cmd) does not need to recheck this. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 9ce05353d12b..60b926e5062a 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -1115,15 +1115,13 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct comedi_cmd *cmd = &s->async->cmd; - if (cmd->scan_begin_src == TRIG_FOLLOW) { /* mode 1, 2, 3 */ - if (cmd->convert_src == TRIG_TIMER) { /* mode 1 and 2 */ - return pci171x_ai_docmd_and_mode(cmd->start_src == - TRIG_EXT ? 2 : 1, dev, - s); - } - if (cmd->convert_src == TRIG_EXT) { /* mode 3 */ - return pci171x_ai_docmd_and_mode(3, dev, s); - } + if (cmd->convert_src == TRIG_TIMER) { /* mode 1 and 2 */ + return pci171x_ai_docmd_and_mode(cmd->start_src == + TRIG_EXT ? 2 : 1, dev, + s); + } + if (cmd->convert_src == TRIG_EXT) { /* mode 3 */ + return pci171x_ai_docmd_and_mode(3, dev, s); } return -1; -- cgit v1.2.3 From eec2f4efb1d8bbe072b6918da3afdcfdf8259492 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 23 Apr 2014 16:06:59 -0700 Subject: staging: comedi: adv_pci1710: absorb pci171x_ai_docmd_and_mode() This helper function is called by the ai (*do_cmd) to setup and start the async command based on the "mode" of operation. This "mode" is determined by the cmd convert_src and start_src. Move this "mode" determination and combine the functions. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 35 +++++++++------------------- 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 60b926e5062a..6ab78bb629be 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -947,16 +947,22 @@ static irqreturn_t interrupt_service_pci1710(int irq, void *d) return IRQ_HANDLED; } -/* -============================================================================== -*/ -static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev, - struct comedi_subdevice *s) +static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct pci1710_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; unsigned int divisor1 = 0, divisor2 = 0; unsigned int seglen; + int mode; + + if (cmd->convert_src == TRIG_TIMER) { + if (cmd->start_src == TRIG_EXT) + mode = 2; + else + mode = 1; + } else { /* TRIG_EXT */ + mode = 3; + } start_pacer(dev, -1, 0, 0); /* stop pacer */ @@ -1108,25 +1114,6 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev, return 0; } -/* -============================================================================== -*/ -static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) -{ - struct comedi_cmd *cmd = &s->async->cmd; - - if (cmd->convert_src == TRIG_TIMER) { /* mode 1 and 2 */ - return pci171x_ai_docmd_and_mode(cmd->start_src == - TRIG_EXT ? 2 : 1, dev, - s); - } - if (cmd->convert_src == TRIG_EXT) { /* mode 3 */ - return pci171x_ai_docmd_and_mode(3, dev, s); - } - - return -1; -} - /* ============================================================================== */ -- cgit v1.2.3 From 6572c3f2f557034c571ab4cd645bc18646d0b5ce Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 23 Apr 2014 16:07:00 -0700 Subject: staging: comedi: adv_pci1710: remove 'ai_do' from private data This member of the private data is set to the "mode" that the ai command is operating in but nothing uses it. Just remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 6ab78bb629be..24dcc2e86dee 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -301,7 +301,6 @@ struct pci1710_private { char neverending_ai; /* we do unlimited AI */ unsigned int CntrlReg; /* Control register */ 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_act_chan; /* actual position in actual scan */ unsigned int ai_buf_ptr; /* data buffer ptr in samples */ @@ -726,7 +725,6 @@ static int pci171x_ai_cancel(struct comedi_device *dev, break; } - devpriv->ai_do = 0; devpriv->ai_act_scan = 0; s->async->cur_chan = 0; devpriv->ai_buf_ptr = 0; @@ -974,8 +972,6 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) outb(0, dev->iobase + PCI171x_CLRFIFO); outb(0, dev->iobase + PCI171x_CLRINT); - devpriv->ai_do = mode; - devpriv->ai_act_scan = 0; s->async->cur_chan = 0; devpriv->ai_buf_ptr = 0; -- cgit v1.2.3 From 7cc054d0b1ff4cc96f43101fee9bcec21c725c32 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 23 Apr 2014 16:07:01 -0700 Subject: staging: comedi: adv_pci1710: rename check_channel_list() For aesthetics, rename this function so it has namespace associated with the driver. Also, change it's parameters. The cmd->chanlist and cmd->chanlist_len are always passed, just pass the comedi_cmd pointer instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 24dcc2e86dee..765b1f00255b 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -332,12 +332,14 @@ static const unsigned int muxonechan[] = { If it's ok, then program scan/gain logic. This works for all cards. */ -static int check_channel_list(struct comedi_device *dev, - struct comedi_subdevice *s, - unsigned int *chanlist, unsigned int n_chan) +static int pci171x_ai_check_chanlist(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) { unsigned int chansegment[32]; unsigned int i, nowmustbechan, seglen, segpos; + unsigned int *chanlist = cmd->chanlist; + unsigned int n_chan = cmd->chanlist_len; /* correct channel and range number check itself comedi/range.c */ if (n_chan < 1) { @@ -964,7 +966,7 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) start_pacer(dev, -1, 0, 0); /* stop pacer */ - seglen = check_channel_list(dev, s, cmd->chanlist, cmd->chanlist_len); + seglen = pci171x_ai_check_chanlist(dev, s, cmd); if (seglen < 1) return -EINVAL; setup_channel_list(dev, s, cmd->chanlist, cmd->chanlist_len, seglen); @@ -1099,13 +1101,10 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev, if (err) return 4; - /* step 5: complain about special chanlist considerations */ + /* Step 5: check channel list */ - if (cmd->chanlist) { - if (!check_channel_list(dev, s, cmd->chanlist, - cmd->chanlist_len)) - return 5; /* incorrect channels list */ - } + if (!pci171x_ai_check_chanlist(dev, s, cmd)) + return 5; return 0; } -- cgit v1.2.3 From cad7aa13a34dc83daa95ae5f9deca794021b4a2a Mon Sep 17 00:00:00 2001 From: Vitaly Osipov Date: Tue, 22 Apr 2014 23:25:21 +1000 Subject: staging:lustre: use gfp_t instead of int Fixed several sparse "warning: incorrect type" by replacing int declarations with gfp_t Signed-off-by: Vitaly Osipov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/libcfs/libcfs.h | 1 + drivers/staging/lustre/lustre/libcfs/module.c | 3 ++- drivers/staging/lustre/lustre/libcfs/tracefile.c | 4 ++-- drivers/staging/lustre/lustre/libcfs/tracefile.h | 2 +- drivers/staging/lustre/lustre/obdecho/echo_client.c | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h index 4a6c7da72174..26b53f6420e5 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h @@ -42,6 +42,7 @@ #endif #include +#include #include "curproc.h" diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c index 24ae26d5def3..b16ee08fe742 100644 --- a/drivers/staging/lustre/lustre/libcfs/module.c +++ b/drivers/staging/lustre/lustre/libcfs/module.c @@ -87,7 +87,8 @@ kportal_memhog_free (struct libcfs_device_userstate *ldu) } int -kportal_memhog_alloc (struct libcfs_device_userstate *ldu, int npages, int flags) +kportal_memhog_alloc(struct libcfs_device_userstate *ldu, int npages, + gfp_t flags) { struct page **level0p; struct page **level1p; diff --git a/drivers/staging/lustre/lustre/libcfs/tracefile.c b/drivers/staging/lustre/lustre/libcfs/tracefile.c index c8599eefeb76..50d421816c4c 100644 --- a/drivers/staging/lustre/lustre/libcfs/tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/tracefile.c @@ -66,7 +66,7 @@ cfs_tage_from_list(struct list_head *list) return list_entry(list, struct cfs_trace_page, linkage); } -static struct cfs_trace_page *cfs_tage_alloc(int gfp) +static struct cfs_trace_page *cfs_tage_alloc(gfp_t gfp) { struct page *page; struct cfs_trace_page *tage; @@ -114,7 +114,7 @@ static void cfs_tage_to_tail(struct cfs_trace_page *tage, list_move_tail(&tage->linkage, queue); } -int cfs_trace_refill_stock(struct cfs_trace_cpu_data *tcd, int gfp, +int cfs_trace_refill_stock(struct cfs_trace_cpu_data *tcd, gfp_t gfp, struct list_head *stock) { int i; diff --git a/drivers/staging/lustre/lustre/libcfs/tracefile.h b/drivers/staging/lustre/lustre/libcfs/tracefile.h index 7e8d17c12b5b..55ecfc9f201b 100644 --- a/drivers/staging/lustre/lustre/libcfs/tracefile.h +++ b/drivers/staging/lustre/lustre/libcfs/tracefile.h @@ -307,7 +307,7 @@ cfs_trace_put_tcd (struct cfs_trace_cpu_data *tcd) put_cpu(); } -int cfs_trace_refill_stock(struct cfs_trace_cpu_data *tcd, int gfp, +int cfs_trace_refill_stock(struct cfs_trace_cpu_data *tcd, gfp_t gfp, struct list_head *stock); diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index 754aa8e55665..a7f5e41ebf77 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -2432,7 +2432,7 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, int i; int rc; int verify; - int gfp_mask; + gfp_t gfp_mask; int brw_flags = 0; verify = (ostid_id(&oa->o_oi) != ECHO_PERSISTENT_OBJID && -- cgit v1.2.3 From 2e5ed7fdfb23566cc3d85ce028b2f446c7bf057b Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 25 Apr 2014 00:49:13 +0300 Subject: staging: lustre: improve length checks in ioctls We copy "hdr->ioc_len" from the user twice but we only verify that it's within the limit on the first copy. Otherwise we could read unmapped memory and Oops. Signed-off-by: Dan Carpenter Reviewed-by: Peng Tao Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/libcfs/linux/linux-module.c | 4 ++++ drivers/staging/lustre/lustre/obdclass/linux/linux-module.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c index e6eae0666f0d..9a3b07bd2fac 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c @@ -44,6 +44,7 @@ int libcfs_ioctl_getdata(char *buf, char *end, void *arg) { struct libcfs_ioctl_hdr *hdr; struct libcfs_ioctl_data *data; + int orig_len; int err; hdr = (struct libcfs_ioctl_hdr *)buf; @@ -69,9 +70,12 @@ int libcfs_ioctl_getdata(char *buf, char *end, void *arg) return -EINVAL; } + orig_len = hdr->ioc_len; err = copy_from_user(buf, (void *)arg, hdr->ioc_len); if (err) return err; + if (orig_len != data->ioc_len) + return -EINVAL; if (libcfs_ioctl_is_invalid(data)) { CERROR("PORTALS: ioctl not correctly formatted\n"); diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c index e4e94cc1713d..dec10377f222 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c @@ -122,6 +122,8 @@ int obd_ioctl_getdata(char **buf, int *len, void *arg) OBD_FREE_LARGE(*buf, hdr.ioc_len); return err; } + if (hdr.ioc_len != data->ioc_len) + return -EINVAL; if (obd_ioctl_is_invalid(data)) { CERROR("ioctl not correctly formatted\n"); -- cgit v1.2.3 From 3eb8446051390179697687e5cd70298f3ea6bc2b Mon Sep 17 00:00:00 2001 From: Fabio Falzoi Date: Fri, 25 Apr 2014 11:41:41 +0200 Subject: Staging: lustre: Avoid using 0 instead of NULL Fixed the following sparse complaints: drivers/staging/lustre/lustre/ptlrpc/../../lustre/ldlm/ldlm_pool.c:755:9: warning: Using plain integer as NULL pointer drivers/staging/lustre/lustre/ptlrpc/../../lustre/ldlm/ldlm_pool.c:757:9: warning: Using plain integer as NULL pointer drivers/staging/lustre/lustre/ptlrpc/../../lustre/ldlm/ldlm_pool.c:758:9: warning: Using plain integer as NULL pointer drivers/staging/lustre/lustre/ptlrpc/../../lustre/ldlm/ldlm_pool.c:759:9: warning: Using plain integer as NULL pointer drivers/staging/lustre/lustre/ptlrpc/../../lustre/ldlm/ldlm_pool.c:760:9: warning: Using plain integer as NULL pointer drivers/staging/lustre/lustre/ptlrpc/../../lustre/ldlm/ldlm_pool.c:762:9: warning: Using plain integer as NULL pointer drivers/staging/lustre/lustre/ptlrpc/../../lustre/ldlm/ldlm_pool.c:764:9: warning: Using plain integer as NULL pointer drivers/staging/lustre/lustre/ptlrpc/../../lustre/ldlm/ldlm_pool.c:765:9: warning: Using plain integer as NULL pointer drivers/staging/lustre/lustre/ptlrpc/../../lustre/ldlm/ldlm_pool.c:766:9: warning: Using plain integer as NULL pointer drivers/staging/lustre/lustre/ptlrpc/../../lustre/ldlm/ldlm_pool.c:768:9: warning: Using plain integer as NULL pointer Signed-off-by: Fabio Falzoi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index 6758646f575f..5fa9ef441389 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -718,7 +718,7 @@ LPROC_SEQ_FOPS_RO(lprocfs_grant_speed); snprintf(var_name, MAX_STRING_SIZE, #name); \ pool_vars[0].data = var; \ pool_vars[0].fops = ops; \ - lprocfs_add_vars(pl->pl_proc_dir, pool_vars, 0);\ + lprocfs_add_vars(pl->pl_proc_dir, pool_vars, NULL);\ } while (0) static int ldlm_pool_proc_init(struct ldlm_pool *pl) -- cgit v1.2.3 From b9c98cfa717c3912595cee424ba9d9b98db9ced1 Mon Sep 17 00:00:00 2001 From: Fabio Falzoi Date: Fri, 25 Apr 2014 11:41:42 +0200 Subject: Staging: lustre: ops structs should be declared static Fixed the following sparse complaints: drivers/staging/lustre/lustre/ptlrpc/../../lustre/ldlm/ldlm_pool.c:549:22: warning: symbol 'ldlm_srv_pool_ops' was not declared. Should it be static? drivers/staging/lustre/lustre/ptlrpc/../../lustre/ldlm/ldlm_pool.c:555:22: warning: symbol 'ldlm_cli_pool_ops' was not declared. Should it be static? drivers/staging/lustre/lustre/ptlrpc/../../lustre/ldlm/ldlm_pool.c:681:1: warning: symbol 'lprocfs_pool_state_fops' was not declared. Should it be static? drivers/staging/lustre/lustre/ptlrpc/../../lustre/ldlm/ldlm_pool.c:697:1: warning: symbol 'lprocfs_grant_plan_fops' was not declared. Should it be static? drivers/staging/lustre/lustre/ptlrpc/../../lustre/ldlm/ldlm_pool.c:700:1: warning: symbol 'lprocfs_wr_recalc_period' was not declared. Should it be static? drivers/staging/lustre/lustre/ptlrpc/../../lustre/ldlm/ldlm_pool.c:708:1: warning: symbol 'lprocfs_recalc_period_fops' was not declared. Should it be static? drivers/staging/lustre/lustre/ptlrpc/../../lustre/ldlm/ldlm_pool.c:710:1: warning: symbol 'ldlm_pool_u64_fops' was not declared. Should it be static? drivers/staging/lustre/lustre/ptlrpc/../../lustre/ldlm/ldlm_pool.c:711:1: warning: symbol 'ldlm_pool_atomic_fops' was not declared. Should it be static? drivers/staging/lustre/lustre/ptlrpc/../../lustre/ldlm/ldlm_pool.c:712:1: warning: symbol 'ldlm_pool_rw_atomic_fops' was not declared. Should it be static? drivers/staging/lustre/lustre/ptlrpc/../../lustre/ldlm/ldlm_pool.c:714:1: warning: symbol 'lprocfs_grant_speed_fops' was not declared. Should it be static? Signed-off-by: Fabio Falzoi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/lprocfs_status.h | 4 ++-- drivers/staging/lustre/lustre/include/lustre_dlm.h | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_internal.h | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 4 ++-- drivers/staging/lustre/lustre/llite/lproc_llite.c | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 428e3e4ce05c..9ce12c78d47a 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -687,7 +687,7 @@ static int name##_single_open(cfs_inode_t *inode, struct file *file) \ { \ return single_open(file, name##_seq_show, PDE_DATA(inode)); \ } \ -struct file_operations name##_fops = { \ +static struct file_operations name##_fops = { \ .owner = THIS_MODULE, \ .open = name##_single_open, \ .read = seq_read, \ @@ -730,7 +730,7 @@ struct file_operations name##_fops = { \ { \ return single_open(file, NULL, PDE_DATA(inode)); \ } \ - struct file_operations name##_##type##_fops = { \ + static struct file_operations name##_##type##_fops = { \ .open = name##_##type##_open, \ .write = name##_##type##_write, \ .release = lprocfs_single_release, \ diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index ed103133165e..154b1e11e29c 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -260,7 +260,7 @@ struct ldlm_pool { /** Recalculation period for pool. */ time_t pl_recalc_period; /** Recalculation and shrink operations. */ - struct ldlm_pool_ops *pl_ops; + const struct ldlm_pool_ops *pl_ops; /** Number of planned locks for next period. */ int pl_grant_plan; /** Pool statistics. */ diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h index 8cd79633dea3..f997566ef11e 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h @@ -247,7 +247,7 @@ typedef enum ldlm_policy_res ldlm_policy_res_t; struct __##var##__dummy_read {;} /* semicolon catcher */ #define LDLM_POOL_PROC_WRITER(var, type) \ - int lprocfs_wr_##var(struct file *file, const char *buffer, \ + static int lprocfs_wr_##var(struct file *file, const char *buffer, \ unsigned long count, void *data) \ { \ struct ldlm_pool *pl = data; \ diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index 5fa9ef441389..ccb1e04d3cda 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -546,13 +546,13 @@ static int ldlm_cli_pool_shrink(struct ldlm_pool *pl, return ldlm_cancel_lru(ns, nr, LCF_ASYNC, LDLM_CANCEL_SHRINK); } -struct ldlm_pool_ops ldlm_srv_pool_ops = { +static const struct ldlm_pool_ops ldlm_srv_pool_ops = { .po_recalc = ldlm_srv_pool_recalc, .po_shrink = ldlm_srv_pool_shrink, .po_setup = ldlm_srv_pool_setup }; -struct ldlm_pool_ops ldlm_cli_pool_ops = { +static const struct ldlm_pool_ops ldlm_cli_pool_ops = { .po_recalc = ldlm_cli_pool_recalc, .po_shrink = ldlm_cli_pool_shrink }; diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index a9a104a6a4ee..021deb918f38 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -44,9 +44,9 @@ /* /proc/lustre/llite mount point registration */ extern struct file_operations vvp_dump_pgcache_file_ops; -struct file_operations ll_rw_extents_stats_fops; -struct file_operations ll_rw_extents_stats_pp_fops; -struct file_operations ll_rw_offset_stats_fops; +static struct file_operations ll_rw_extents_stats_fops; +static struct file_operations ll_rw_extents_stats_pp_fops; +static struct file_operations ll_rw_offset_stats_fops; static int ll_blksize_seq_show(struct seq_file *m, void *v) { -- cgit v1.2.3 From 5802572e54539d0e994ae2db865fd58234cebd76 Mon Sep 17 00:00:00 2001 From: Fabio Falzoi Date: Fri, 25 Apr 2014 11:41:43 +0200 Subject: Staging: lustre: gfp_mask should be of gfp_t type Fixed the following sparse complaints: drivers/staging/lustre/lustre/ptlrpc/../../lustre/ldlm/ldlm_pool.c:1039:61: warning: restricted gfp_t degrades to integer drivers/staging/lustre/lustre/ptlrpc/../../lustre/ldlm/ldlm_pool.c:1092:61: warning: restricted gfp_t degrades to integer drivers/staging/lustre/lustre/ptlrpc/../../lustre/ldlm/ldlm_pool.c:1136:58: warning: incorrect type in argument 2 (different base types) expected unsigned int [unsigned] gfp_mask got restricted gfp_t [usertype] gfp_mask drivers/staging/lustre/lustre/ptlrpc/../../lustre/ldlm/ldlm_pool.c:1142:34: warning: incorrect type in argument 3 (different base types) expected unsigned int [unsigned] gfp_mask got restricted gfp_t [usertype] gfp_mask drivers/staging/lustre/lustre/ptlrpc/../../lustre/ldlm/ldlm_pool.c:1147:58: warning: incorrect type in argument 2 (different base types) expected unsigned int [unsigned] gfp_mask got restricted gfp_t [usertype] gfp_mask drivers/staging/lustre/lustre/ptlrpc/../../lustre/ldlm/ldlm_pool.c:1153:34: warning: incorrect type in argument 3 (different base types) expected unsigned int [unsigned] gfp_mask got restricted gfp_t [usertype] gfp_mask Signed-off-by: Fabio Falzoi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/lustre_dlm.h | 4 ++-- drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index 154b1e11e29c..e28e31a26369 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -212,7 +212,7 @@ struct ldlm_pool_ops { int (*po_recalc)(struct ldlm_pool *pl); /** Cancel at least \a nr locks from pool \a pl */ int (*po_shrink)(struct ldlm_pool *pl, int nr, - unsigned int gfp_mask); + gfp_t gfp_mask); int (*po_setup)(struct ldlm_pool *pl, int limit); }; @@ -1463,7 +1463,7 @@ void ldlm_pools_fini(void); int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns, int idx, ldlm_side_t client); int ldlm_pool_shrink(struct ldlm_pool *pl, int nr, - unsigned int gfp_mask); + gfp_t gfp_mask); void ldlm_pool_fini(struct ldlm_pool *pl); int ldlm_pool_setup(struct ldlm_pool *pl, int limit); int ldlm_pool_recalc(struct ldlm_pool *pl); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index ccb1e04d3cda..2cc698179b63 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -378,7 +378,7 @@ static int ldlm_srv_pool_recalc(struct ldlm_pool *pl) * locks smaller in next 10h. */ static int ldlm_srv_pool_shrink(struct ldlm_pool *pl, - int nr, unsigned int gfp_mask) + int nr, gfp_t gfp_mask) { __u32 limit; @@ -518,7 +518,7 @@ static int ldlm_cli_pool_recalc(struct ldlm_pool *pl) * passed \a pl according to \a nr and \a gfp_mask. */ static int ldlm_cli_pool_shrink(struct ldlm_pool *pl, - int nr, unsigned int gfp_mask) + int nr, gfp_t gfp_mask) { struct ldlm_namespace *ns; int unused; @@ -603,7 +603,7 @@ int ldlm_pool_recalc(struct ldlm_pool *pl) * freeable locks. Otherwise, return the number of canceled locks. */ int ldlm_pool_shrink(struct ldlm_pool *pl, int nr, - unsigned int gfp_mask) + gfp_t gfp_mask) { int cancel = 0; @@ -1029,7 +1029,7 @@ static struct completion ldlm_pools_comp; * count locks from all namespaces (if possible). Returns number of * cached locks. */ -static unsigned long ldlm_pools_count(ldlm_side_t client, unsigned int gfp_mask) +static unsigned long ldlm_pools_count(ldlm_side_t client, gfp_t gfp_mask) { int total = 0, nr_ns; struct ldlm_namespace *ns; @@ -1082,7 +1082,7 @@ static unsigned long ldlm_pools_count(ldlm_side_t client, unsigned int gfp_mask) return total; } -static unsigned long ldlm_pools_scan(ldlm_side_t client, int nr, unsigned int gfp_mask) +static unsigned long ldlm_pools_scan(ldlm_side_t client, int nr, gfp_t gfp_mask) { unsigned long freed = 0; int tmp, nr_ns; -- cgit v1.2.3 From d7a33d74e9913bd4d2580aff67ed7051935f546b Mon Sep 17 00:00:00 2001 From: Bintian Wang Date: Tue, 22 Apr 2014 17:22:58 +0800 Subject: staging/android: Remove ram_console.h ram_console is replaced by pstore and pstore_ram drivers, and there is no code to use this head file, so remove it. Signed-off-by: Bintian Wang Acked-by: Colin Cross Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ram_console.h | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 drivers/staging/android/ram_console.h diff --git a/drivers/staging/android/ram_console.h b/drivers/staging/android/ram_console.h deleted file mode 100644 index 9f1125c11066..000000000000 --- a/drivers/staging/android/ram_console.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2010 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * - */ - -#ifndef _INCLUDE_LINUX_PLATFORM_DATA_RAM_CONSOLE_H_ -#define _INCLUDE_LINUX_PLATFORM_DATA_RAM_CONSOLE_H_ - -struct ram_console_platform_data { - const char *bootinfo; -}; - -#endif /* _INCLUDE_LINUX_PLATFORM_DATA_RAM_CONSOLE_H_ */ -- cgit v1.2.3 From b6152016003b2cc2370899558bf2e7de4ebd0b09 Mon Sep 17 00:00:00 2001 From: Gioh Kim Date: Fri, 25 Apr 2014 08:24:24 +0900 Subject: Staging: android: ion: duplicated clearing of sg_table Because sg_table is cleared in sg_alloc_table via memset we don't need to use kzalloc to allocate sg_table. Signed-off-by: Gioh Kim Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion_carveout_heap.c | 2 +- drivers/staging/android/ion/ion_chunk_heap.c | 2 +- drivers/staging/android/ion/ion_system_heap.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/android/ion/ion_carveout_heap.c b/drivers/staging/android/ion/ion_carveout_heap.c index 3cb05b9b0e93..dcb6f2196c87 100644 --- a/drivers/staging/android/ion/ion_carveout_heap.c +++ b/drivers/staging/android/ion/ion_carveout_heap.c @@ -81,7 +81,7 @@ static int ion_carveout_heap_allocate(struct ion_heap *heap, if (align > PAGE_SIZE) return -EINVAL; - table = kzalloc(sizeof(struct sg_table), GFP_KERNEL); + table = kmalloc(sizeof(struct sg_table), GFP_KERNEL); if (!table) return -ENOMEM; ret = sg_alloc_table(table, 1, GFP_KERNEL); diff --git a/drivers/staging/android/ion/ion_chunk_heap.c b/drivers/staging/android/ion/ion_chunk_heap.c index d40f5f831808..3f2c12ba4d14 100644 --- a/drivers/staging/android/ion/ion_chunk_heap.c +++ b/drivers/staging/android/ion/ion_chunk_heap.c @@ -55,7 +55,7 @@ static int ion_chunk_heap_allocate(struct ion_heap *heap, if (allocated_size > chunk_heap->size - chunk_heap->allocated) return -ENOMEM; - table = kzalloc(sizeof(struct sg_table), GFP_KERNEL); + table = kmalloc(sizeof(struct sg_table), GFP_KERNEL); if (!table) return -ENOMEM; ret = sg_alloc_table(table, num_chunks, GFP_KERNEL); diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c index c92363356ae1..0663a7fbfa60 100644 --- a/drivers/staging/android/ion/ion_system_heap.c +++ b/drivers/staging/android/ion/ion_system_heap.c @@ -166,7 +166,7 @@ static int ion_system_heap_allocate(struct ion_heap *heap, max_order = info->order; i++; } - table = kzalloc(sizeof(struct sg_table), GFP_KERNEL); + table = kmalloc(sizeof(struct sg_table), GFP_KERNEL); if (!table) goto err; @@ -356,7 +356,7 @@ static int ion_system_contig_heap_allocate(struct ion_heap *heap, for (i = len >> PAGE_SHIFT; i < (1 << order); i++) __free_page(page + i); - table = kzalloc(sizeof(struct sg_table), GFP_KERNEL); + table = kmalloc(sizeof(struct sg_table), GFP_KERNEL); if (!table) { ret = -ENOMEM; goto out; -- cgit v1.2.3 From 8c4842d68217d592056bdd879366d8547fa55643 Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld Date: Wed, 26 Mar 2014 20:56:53 +0100 Subject: staging: keucr: Fix warning about missing blank lines after declarations This patches fixes two warnings of checkpatch.pl, both of the type WARNING: Missing a blank line after declarations Signed-off-by: Jonas Hahnfeld Signed-off-by: Greg Kroah-Hartman --- drivers/staging/keucr/smilsub.c | 1 + drivers/staging/keucr/transport.c | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/staging/keucr/smilsub.c b/drivers/staging/keucr/smilsub.c index 44ced8265039..e981f14f3bf9 100644 --- a/drivers/staging/keucr/smilsub.c +++ b/drivers/staging/keucr/smilsub.c @@ -133,6 +133,7 @@ void Set_D_LogBlockAddr(u8 *redundant) void Set_D_FailBlock(u8 *redundant) { char i; + for (i = 0; i < REDTSIZE; i++) *redundant++ = (u8)((i == REDT_BLOCK) ? 0xF0 : 0xFF); } diff --git a/drivers/staging/keucr/transport.c b/drivers/staging/keucr/transport.c index ae9414755d2f..5e59525271f8 100644 --- a/drivers/staging/keucr/transport.c +++ b/drivers/staging/keucr/transport.c @@ -669,6 +669,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) /* R/W data */ if (transfer_length) { unsigned int pipe; + if (srb->sc_data_direction == DMA_FROM_DEVICE) pipe = us->recv_bulk_pipe; else -- cgit v1.2.3 From b7b1462ec43d774501c70e1b85f3ce53fd8ee0c7 Mon Sep 17 00:00:00 2001 From: Rui Miguel Silva Date: Sat, 12 Apr 2014 01:33:11 +0100 Subject: staging: keucr: fix sparse warning fix sparse warning: drivers/staging/keucr/smilmain.c:163:5: warning: symbol 'Check_D_MediaFmt' was not declared. Should it be static? by declaring it in the right header. And remove duplication of definition of SM_INIT Signed-off-by: Rui Miguel Silva Signed-off-by: Greg Kroah-Hartman --- drivers/staging/keucr/init.c | 1 + drivers/staging/keucr/init.h | 1 - drivers/staging/keucr/smil.h | 3 +-- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/keucr/init.c b/drivers/staging/keucr/init.c index e61183906548..1e7449d6d120 100644 --- a/drivers/staging/keucr/init.c +++ b/drivers/staging/keucr/init.c @@ -9,6 +9,7 @@ #include "usb.h" #include "scsiglue.h" #include "transport.h" +#include "smil.h" #include "init.h" /* diff --git a/drivers/staging/keucr/init.h b/drivers/staging/keucr/init.h index 98d2e3ba8545..32c724df621d 100644 --- a/drivers/staging/keucr/init.h +++ b/drivers/staging/keucr/init.h @@ -1,7 +1,6 @@ #include "common.h" extern u32 MediaChange; -extern int Check_D_MediaFmt(struct us_data *); diff --git a/drivers/staging/keucr/smil.h b/drivers/staging/keucr/smil.h index 39951738d231..f938759337e6 100644 --- a/drivers/staging/keucr/smil.h +++ b/drivers/staging/keucr/smil.h @@ -204,6 +204,7 @@ extern struct keucr_media_area CisArea; int Init_D_SmartMedia(void); int Pwoff_D_SmartMedia(void); int Check_D_SmartMedia(void); +int Check_D_MediaFmt(struct us_data *); int Check_D_Parameter(struct us_data *, u16 *, u8 *, u8 *); int Media_D_ReadSector(struct us_data *, u32, u16, u8 *); int Media_D_WriteSector(struct us_data *, u32, u16, u8 *); @@ -284,6 +285,4 @@ u8 correct_data(u8 *, u8 *, u8, u8, u8); int _Correct_D_SwECC(u8 *, u8 *, u8 *); void _Calculate_D_SwECC(u8 *, u8 *); -void SM_Init(void); - #endif /* already included */ -- cgit v1.2.3 From 5494f95bad1d7c7a238feee8e2bf5a6db8f9c54e Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Tue, 15 Apr 2014 01:56:32 +0900 Subject: staging: unisys: Fix format string mismatch in virthba.c Fix format string mismatch in info_proc_read() within virthba.c. Signed-off-by: Masanari Iida Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virthba/virthba.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c index 817b11dfa19c..cc8a032869ae 100644 --- a/drivers/staging/unisys/virthba/virthba.c +++ b/drivers/staging/unisys/virthba/virthba.c @@ -1400,7 +1400,7 @@ info_proc_read(struct file *file, char __user *buf, size_t len, loff_t *offset) virthbainfo = VirtHbasOpen[i].virthbainfo; length += sprintf(vbuf + length, "CHANSOCK is not defined.\n"); - length += sprintf(vbuf + length, "MaxBuffLen:%d\n", MaxBuffLen); + length += sprintf(vbuf + length, "MaxBuffLen:%u\n", MaxBuffLen); length += sprintf(vbuf + length, "\nvirthba result queue poll wait:%d usecs.\n", rsltq_wait_usecs); -- cgit v1.2.3 From fb90c6095f6d4c86ac2e3d5aacece544dde39b5c Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Tue, 15 Apr 2014 01:56:33 +0900 Subject: staging: unisys: Fix typo in comment and printk Fix spelling typo in comments and printk within unisys. Signed-off-by: Masanari Iida Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/common-spar/include/channels/channel.h | 2 +- drivers/staging/unisys/common-spar/include/channels/diagchannel.h | 2 +- drivers/staging/unisys/common-spar/include/channels/iochannel.h | 2 +- drivers/staging/unisys/include/commontypes.h | 2 +- drivers/staging/unisys/include/guestlinuxdebug.h | 4 ++-- drivers/staging/unisys/virthba/virthba.c | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index aee204172b21..6a5d1c0e6bd3 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -24,7 +24,7 @@ */ /* define the following to prevent include nesting in kernel header - * files of similar abreviated content + * files of similar abbreviated content */ #define __SUPERVISOR_CHANNEL_H__ diff --git a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h index c93515eb211d..424ef28739fe 100644 --- a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h @@ -356,7 +356,7 @@ typedef enum { *IsChannelInitialized: 1 iff SignalInit was called for this channel; otherwise * 0, and assume the channel is not ready for use yet. * - * Reserved: Padding to allign the fields in this structure. + * Reserved: Padding to align the fields in this structure. * *SubsystemSeverityFilter: Level of severity on a subsystem basis that controls * whether events are logged. Any event's severity for a diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index 8de1d249d55f..6098f45f1e19 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -192,7 +192,7 @@ typedef enum { NET_RCV_POST = 0, /* submit buffer to hold receiving /* uisnic -> virtnic */ NET_MACADDR, /* indicates the client has requested to update * its MAC addr */ - NET_MACADDR_ACK, /* Mac addres */ + NET_MACADDR_ACK, /* MAC address */ } NET_TYPES; diff --git a/drivers/staging/unisys/include/commontypes.h b/drivers/staging/unisys/include/commontypes.h index ef12af4a72db..4f71b365e519 100644 --- a/drivers/staging/unisys/include/commontypes.h +++ b/drivers/staging/unisys/include/commontypes.h @@ -17,7 +17,7 @@ #define _COMMONTYPES_H_ /* define the following to prevent include nesting in kernel header files of - * similar abreviated content */ + * similar abbreviated content */ #define _SUPERVISOR_COMMONTYPES_H_ #ifdef __KERNEL__ diff --git a/drivers/staging/unisys/include/guestlinuxdebug.h b/drivers/staging/unisys/include/guestlinuxdebug.h index c3de8496e5d6..cd3896043b6d 100644 --- a/drivers/staging/unisys/include/guestlinuxdebug.h +++ b/drivers/staging/unisys/include/guestlinuxdebug.h @@ -17,7 +17,7 @@ #define __GUESTLINUXDEBUG_H__ /* -* This file contains supporting interface for "vmcallinterface.h", particuarly +* This file contains supporting interface for "vmcallinterface.h", particularly * regarding adding additional structure and functionality to linux * ISSUE_IO_VMCALL_POSTCODE_SEVERITY */ @@ -142,7 +142,7 @@ typedef enum { /* POSTCODE event identifier tuples */ * Please also note that the resulting postcode is in hex, so if you are * searching for the __LINE__ number, convert it first to decimal. The line * number combined with driver and type of call, will allow you to track down - * exactly what line an error occured on, or where the last driver + * exactly what line an error occurred on, or where the last driver * entered/exited from. */ diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c index cc8a032869ae..a3f046cb6b56 100644 --- a/drivers/staging/unisys/virthba/virthba.c +++ b/drivers/staging/unisys/virthba/virthba.c @@ -1046,7 +1046,7 @@ static int virthba_slave_alloc(struct scsi_device *scsidev) { /* this called by the midlayer before scan for new devices - - * LLD can alloc any struc & do init if needed. + * LLD can alloc any struct & do init if needed. */ struct virtdisk_info *vdisk; struct virtdisk_info *tmpvdisk; @@ -1534,7 +1534,7 @@ virthba_serverup(struct virtpci_dev *virtpcidev) virtpcidev->deviceNo); if (!virthbainfo->serverdown) { - DBGINF("Server up message recieved while server is already up.\n"); + DBGINF("Server up message received while server is already up.\n"); return 1; } if (virthbainfo->serverchangingstate) { -- cgit v1.2.3 From f6d0c1e62b111bef3be279e4bf1bc2a6d560e205 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Wed, 23 Apr 2014 14:58:34 -0400 Subject: staging: unisys: fix copyright notices This patch changes all of the various representations of the copyright symbol to (C). Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/channels/channel.c | 2 +- drivers/staging/unisys/channels/chanstub.c | 2 +- drivers/staging/unisys/channels/chanstub.h | 2 +- drivers/staging/unisys/common-spar/include/channels/channel.h | 2 +- drivers/staging/unisys/common-spar/include/channels/channel_guid.h | 2 +- drivers/staging/unisys/common-spar/include/channels/controlframework.h | 2 +- drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h | 2 +- drivers/staging/unisys/common-spar/include/channels/diagchannel.h | 2 +- drivers/staging/unisys/common-spar/include/channels/iochannel.h | 2 +- drivers/staging/unisys/common-spar/include/channels/vbuschannel.h | 2 +- drivers/staging/unisys/common-spar/include/controlvmcompletionstatus.h | 2 +- .../staging/unisys/common-spar/include/diagnostics/appos_subsystems.h | 2 +- drivers/staging/unisys/common-spar/include/iovmcall_gnuc.h | 2 +- drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h | 2 +- drivers/staging/unisys/common-spar/include/version.h | 2 +- drivers/staging/unisys/common-spar/include/vmcallinterface.h | 2 +- drivers/staging/unisys/include/commontypes.h | 2 +- drivers/staging/unisys/include/guestlinuxdebug.h | 2 +- drivers/staging/unisys/include/guidutils.h | 2 +- drivers/staging/unisys/include/periodic_work.h | 2 +- drivers/staging/unisys/include/procobjecttree.h | 2 +- drivers/staging/unisys/include/sparstop.h | 2 +- drivers/staging/unisys/include/timskmod.h | 2 +- drivers/staging/unisys/include/timskmodutils.h | 2 +- drivers/staging/unisys/include/uisqueue.h | 2 +- drivers/staging/unisys/include/uisthread.h | 2 +- drivers/staging/unisys/include/uisutils.h | 2 +- drivers/staging/unisys/include/uniklog.h | 2 +- drivers/staging/unisys/uislib/uislib.c | 2 +- drivers/staging/unisys/uislib/uisqueue.c | 2 +- drivers/staging/unisys/uislib/uisthread.c | 2 +- drivers/staging/unisys/uislib/uisutils.c | 2 +- drivers/staging/unisys/virthba/virthba.c | 2 +- drivers/staging/unisys/virthba/virthba.h | 2 +- drivers/staging/unisys/virtpci/virtpci.c | 2 +- drivers/staging/unisys/virtpci/virtpci.h | 2 +- drivers/staging/unisys/visorchannel/globals.h | 2 +- drivers/staging/unisys/visorchannel/visorchannel.h | 2 +- drivers/staging/unisys/visorchannel/visorchannel_funcs.c | 2 +- drivers/staging/unisys/visorchannel/visorchannel_main.c | 2 +- drivers/staging/unisys/visorchipset/controlvm.h | 2 +- drivers/staging/unisys/visorchipset/controlvm_direct.c | 2 +- drivers/staging/unisys/visorchipset/file.c | 2 +- drivers/staging/unisys/visorchipset/file.h | 2 +- drivers/staging/unisys/visorchipset/globals.h | 2 +- drivers/staging/unisys/visorchipset/parser.c | 2 +- drivers/staging/unisys/visorchipset/parser.h | 2 +- drivers/staging/unisys/visorchipset/testing.h | 2 +- drivers/staging/unisys/visorchipset/visorchipset.h | 2 +- drivers/staging/unisys/visorchipset/visorchipset_main.c | 2 +- drivers/staging/unisys/visorchipset/visorchipset_umode.h | 2 +- drivers/staging/unisys/visorutil/charqueue.c | 2 +- drivers/staging/unisys/visorutil/charqueue.h | 2 +- drivers/staging/unisys/visorutil/easyproc.c | 2 +- drivers/staging/unisys/visorutil/easyproc.h | 2 +- drivers/staging/unisys/visorutil/memregion.h | 2 +- drivers/staging/unisys/visorutil/memregion_direct.c | 2 +- drivers/staging/unisys/visorutil/periodic_work.c | 2 +- drivers/staging/unisys/visorutil/procobjecttree.c | 2 +- drivers/staging/unisys/visorutil/visorkmodutils.c | 2 +- 60 files changed, 60 insertions(+), 60 deletions(-) diff --git a/drivers/staging/unisys/channels/channel.c b/drivers/staging/unisys/channels/channel.c index f6452595b742..7223a14082ba 100644 --- a/drivers/staging/unisys/channels/channel.c +++ b/drivers/staging/unisys/channels/channel.c @@ -1,4 +1,4 @@ -/* Copyright © 2010 - 2013 UNISYS CORPORATION +/* Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/channels/chanstub.c b/drivers/staging/unisys/channels/chanstub.c index f504f49a436a..45ac55d3fe1c 100644 --- a/drivers/staging/unisys/channels/chanstub.c +++ b/drivers/staging/unisys/channels/chanstub.c @@ -1,4 +1,4 @@ -/* Copyright © 2010 - 2013 UNISYS CORPORATION +/* Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/channels/chanstub.h b/drivers/staging/unisys/channels/chanstub.h index 8d727debca67..bdee5d529f6b 100644 --- a/drivers/staging/unisys/channels/chanstub.h +++ b/drivers/staging/unisys/channels/chanstub.h @@ -1,4 +1,4 @@ -/* Copyright © 2010 - 2013 UNISYS CORPORATION +/* Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index 6a5d1c0e6bd3..baa0e501e6b4 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -1,4 +1,4 @@ -/* Copyright © 2010 - 2013 UNISYS CORPORATION +/* Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/common-spar/include/channels/channel_guid.h b/drivers/staging/unisys/common-spar/include/channels/channel_guid.h index ae0dc2b2ad14..1f1f48e8f1c9 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel_guid.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel_guid.h @@ -1,4 +1,4 @@ -/* Copyright © 2010 - 2013 UNISYS CORPORATION +/* Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/common-spar/include/channels/controlframework.h b/drivers/staging/unisys/common-spar/include/channels/controlframework.h index 512643348349..1a1c5053fcf8 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlframework.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlframework.h @@ -1,4 +1,4 @@ -/* Copyright © 2010 - 2013 UNISYS CORPORATION +/* Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index 47f1c4fa1e7e..17beec231d70 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -1,4 +1,4 @@ -/* Copyright © 2010 - 2013 UNISYS CORPORATION +/* Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h index 424ef28739fe..83f1cc7b443f 100644 --- a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h @@ -1,4 +1,4 @@ -/* Copyright © 2010 - 2013 UNISYS CORPORATION +/* Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index 6098f45f1e19..8cbf04d40f78 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -1,4 +1,4 @@ -/* Copyright © 2010 - 2013 UNISYS CORPORATION */ +/* Copyright (C) 2010 - 2013 UNISYS CORPORATION */ /* All rights reserved. */ #ifndef __IOCHANNEL_H__ #define __IOCHANNEL_H__ diff --git a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h index 99dbbcf3d11e..7643042c0ce2 100644 --- a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h @@ -1,4 +1,4 @@ -/* Copyright © 2010 - 2013 UNISYS CORPORATION +/* Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/common-spar/include/controlvmcompletionstatus.h b/drivers/staging/unisys/common-spar/include/controlvmcompletionstatus.h index de30d321d982..db77d6f626a1 100644 --- a/drivers/staging/unisys/common-spar/include/controlvmcompletionstatus.h +++ b/drivers/staging/unisys/common-spar/include/controlvmcompletionstatus.h @@ -1,6 +1,6 @@ /* controlvmcompletionstatus.c * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All Rights Reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/common-spar/include/diagnostics/appos_subsystems.h b/drivers/staging/unisys/common-spar/include/diagnostics/appos_subsystems.h index 4c6294d20606..18cc9ed2748b 100644 --- a/drivers/staging/unisys/common-spar/include/diagnostics/appos_subsystems.h +++ b/drivers/staging/unisys/common-spar/include/diagnostics/appos_subsystems.h @@ -1,4 +1,4 @@ -/* Copyright © 2010 - 2013 UNISYS CORPORATION +/* Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/common-spar/include/iovmcall_gnuc.h b/drivers/staging/unisys/common-spar/include/iovmcall_gnuc.h index 7304e9a0648c..fe9598c941a6 100644 --- a/drivers/staging/unisys/common-spar/include/iovmcall_gnuc.h +++ b/drivers/staging/unisys/common-spar/include/iovmcall_gnuc.h @@ -1,4 +1,4 @@ -/* Copyright © 2010 - 2013 UNISYS CORPORATION +/* Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h b/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h index ae708faaa94d..8c0259a2cbce 100644 --- a/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h +++ b/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h @@ -1,4 +1,4 @@ -/* Copyright © 2010 - 2013 UNISYS CORPORATION +/* Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/common-spar/include/version.h b/drivers/staging/unisys/common-spar/include/version.h index 00b0ebb09eae..f25208fc3ed1 100644 --- a/drivers/staging/unisys/common-spar/include/version.h +++ b/drivers/staging/unisys/common-spar/include/version.h @@ -1,4 +1,4 @@ -/* Copyright © 2010 - 2013 UNISYS CORPORATION +/* Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/common-spar/include/vmcallinterface.h b/drivers/staging/unisys/common-spar/include/vmcallinterface.h index 14c404367fa7..c5c10f3f1eb4 100644 --- a/drivers/staging/unisys/common-spar/include/vmcallinterface.h +++ b/drivers/staging/unisys/common-spar/include/vmcallinterface.h @@ -1,4 +1,4 @@ -/* Copyright © 2010 - 2013 UNISYS CORPORATION +/* Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/include/commontypes.h b/drivers/staging/unisys/include/commontypes.h index 4f71b365e519..3a8f302c87db 100644 --- a/drivers/staging/unisys/include/commontypes.h +++ b/drivers/staging/unisys/include/commontypes.h @@ -1,4 +1,4 @@ -/* Copyright © 2010 - 2013 UNISYS CORPORATION +/* Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/include/guestlinuxdebug.h b/drivers/staging/unisys/include/guestlinuxdebug.h index cd3896043b6d..efc4005368b0 100644 --- a/drivers/staging/unisys/include/guestlinuxdebug.h +++ b/drivers/staging/unisys/include/guestlinuxdebug.h @@ -1,4 +1,4 @@ -/* Copyright © 2010 - 2013 UNISYS CORPORATION +/* Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/include/guidutils.h b/drivers/staging/unisys/include/guidutils.h index 75caf929cd6d..adeb92d8dd4d 100644 --- a/drivers/staging/unisys/include/guidutils.h +++ b/drivers/staging/unisys/include/guidutils.h @@ -1,4 +1,4 @@ -/* Copyright © 2010 - 2013 UNISYS CORPORATION +/* Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/include/periodic_work.h b/drivers/staging/unisys/include/periodic_work.h index 6c7190bdcd66..418ba634e1a2 100644 --- a/drivers/staging/unisys/include/periodic_work.h +++ b/drivers/staging/unisys/include/periodic_work.h @@ -1,6 +1,6 @@ /* periodic_work.h * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/include/procobjecttree.h b/drivers/staging/unisys/include/procobjecttree.h index c81d11287e68..1174056ec3d9 100644 --- a/drivers/staging/unisys/include/procobjecttree.h +++ b/drivers/staging/unisys/include/procobjecttree.h @@ -1,6 +1,6 @@ /* procobjecttree.h * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/include/sparstop.h b/drivers/staging/unisys/include/sparstop.h index 3603ac607643..05837399a741 100644 --- a/drivers/staging/unisys/include/sparstop.h +++ b/drivers/staging/unisys/include/sparstop.h @@ -1,6 +1,6 @@ /* sparstop.h * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/include/timskmod.h b/drivers/staging/unisys/include/timskmod.h index 5fd5ad514464..ecf1a6fac7a1 100644 --- a/drivers/staging/unisys/include/timskmod.h +++ b/drivers/staging/unisys/include/timskmod.h @@ -1,6 +1,6 @@ /* timskmod.h * - * Copyright � 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/include/timskmodutils.h b/drivers/staging/unisys/include/timskmodutils.h index 2d81d46bf11e..0045d559d1b9 100644 --- a/drivers/staging/unisys/include/timskmodutils.h +++ b/drivers/staging/unisys/include/timskmodutils.h @@ -1,6 +1,6 @@ /* timskmodutils.h * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/include/uisqueue.h b/drivers/staging/unisys/include/uisqueue.h index 6dab3900994a..d7793a84903e 100644 --- a/drivers/staging/unisys/include/uisqueue.h +++ b/drivers/staging/unisys/include/uisqueue.h @@ -1,6 +1,6 @@ /* uisqueue.h * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/include/uisthread.h b/drivers/staging/unisys/include/uisthread.h index 2b1fba759098..26837771b43f 100644 --- a/drivers/staging/unisys/include/uisthread.h +++ b/drivers/staging/unisys/include/uisthread.h @@ -1,6 +1,6 @@ /* uisthread.h * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index 5fdab3a3464a..f4774c05f909 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -1,6 +1,6 @@ /* uisutils.h * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/include/uniklog.h b/drivers/staging/unisys/include/uniklog.h index 4d7b87cefa61..6178cc46f7c1 100644 --- a/drivers/staging/unisys/include/uniklog.h +++ b/drivers/staging/unisys/include/uniklog.h @@ -1,6 +1,6 @@ /* uniklog.h * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 3152a2180c45..0e1a58ab28b1 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -1,6 +1,6 @@ /* uislib.c * - * Copyright � 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/uislib/uisqueue.c b/drivers/staging/unisys/uislib/uisqueue.c index 40598ff1f4f2..d4a6074cfaf0 100644 --- a/drivers/staging/unisys/uislib/uisqueue.c +++ b/drivers/staging/unisys/uislib/uisqueue.c @@ -1,6 +1,6 @@ /* uisqueue.c * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/uislib/uisthread.c b/drivers/staging/unisys/uislib/uisthread.c index 782b06aad56d..c93ab04c3cfc 100644 --- a/drivers/staging/unisys/uislib/uisthread.c +++ b/drivers/staging/unisys/uislib/uisthread.c @@ -1,6 +1,6 @@ /* uisthread.c * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/uislib/uisutils.c b/drivers/staging/unisys/uislib/uisutils.c index 3178f75e1ebe..b49647ccc9d0 100644 --- a/drivers/staging/unisys/uislib/uisutils.c +++ b/drivers/staging/unisys/uislib/uisutils.c @@ -1,6 +1,6 @@ /* uisutils.c * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c index a3f046cb6b56..2755b4e9e769 100644 --- a/drivers/staging/unisys/virthba/virthba.c +++ b/drivers/staging/unisys/virthba/virthba.c @@ -1,6 +1,6 @@ /* virthba.c * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/virthba/virthba.h b/drivers/staging/unisys/virthba/virthba.h index 88b797439a16..d4b809b0c7bc 100644 --- a/drivers/staging/unisys/virthba/virthba.h +++ b/drivers/staging/unisys/virthba/virthba.h @@ -1,6 +1,6 @@ /* virthba.h * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index 8e34650b00b5..21f8bd5fdff9 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -1,6 +1,6 @@ /* virtpci.c * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/virtpci/virtpci.h b/drivers/staging/unisys/virtpci/virtpci.h index b8fd07bc5435..b695c4b8e8bd 100644 --- a/drivers/staging/unisys/virtpci/virtpci.h +++ b/drivers/staging/unisys/virtpci/virtpci.h @@ -1,6 +1,6 @@ /* virtpci.h * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/visorchannel/globals.h b/drivers/staging/unisys/visorchannel/globals.h index 668f832ca566..07653b8dea7b 100644 --- a/drivers/staging/unisys/visorchannel/globals.h +++ b/drivers/staging/unisys/visorchannel/globals.h @@ -1,6 +1,6 @@ /* globals.h * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/visorchannel/visorchannel.h b/drivers/staging/unisys/visorchannel/visorchannel.h index 62d29a233fd0..a8c2ebd0c99a 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel.h +++ b/drivers/staging/unisys/visorchannel/visorchannel.h @@ -1,6 +1,6 @@ /* visorchannel.h * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c index 053681616ba3..4427d01b1126 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c +++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c @@ -1,6 +1,6 @@ /* visorchannel_funcs.c * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/visorchannel/visorchannel_main.c b/drivers/staging/unisys/visorchannel/visorchannel_main.c index 482ee0ac1c16..1a092570602e 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel_main.c +++ b/drivers/staging/unisys/visorchannel/visorchannel_main.c @@ -1,6 +1,6 @@ /* visorchannel_main.c * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/visorchipset/controlvm.h b/drivers/staging/unisys/visorchipset/controlvm.h index 873fa12dfe6f..012891c3f21d 100644 --- a/drivers/staging/unisys/visorchipset/controlvm.h +++ b/drivers/staging/unisys/visorchipset/controlvm.h @@ -1,6 +1,6 @@ /* controlvm.h * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/visorchipset/controlvm_direct.c b/drivers/staging/unisys/visorchipset/controlvm_direct.c index b911ea85c093..cd10e3a2a07f 100644 --- a/drivers/staging/unisys/visorchipset/controlvm_direct.c +++ b/drivers/staging/unisys/visorchipset/controlvm_direct.c @@ -1,6 +1,6 @@ /* controlvm_direct.c * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/visorchipset/file.c b/drivers/staging/unisys/visorchipset/file.c index e214a1153282..fccc4f0c3a49 100644 --- a/drivers/staging/unisys/visorchipset/file.c +++ b/drivers/staging/unisys/visorchipset/file.c @@ -1,6 +1,6 @@ /* file.c * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/visorchipset/file.h b/drivers/staging/unisys/visorchipset/file.h index 597282aa9a06..21bb906242e1 100644 --- a/drivers/staging/unisys/visorchipset/file.h +++ b/drivers/staging/unisys/visorchipset/file.h @@ -1,6 +1,6 @@ /* file.h * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/visorchipset/globals.h b/drivers/staging/unisys/visorchipset/globals.h index a0e6d4fc03ae..0fe14599f185 100644 --- a/drivers/staging/unisys/visorchipset/globals.h +++ b/drivers/staging/unisys/visorchipset/globals.h @@ -1,6 +1,6 @@ /* globals.h * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/visorchipset/parser.c b/drivers/staging/unisys/visorchipset/parser.c index b408d415bd8c..948fbb8ed09c 100644 --- a/drivers/staging/unisys/visorchipset/parser.c +++ b/drivers/staging/unisys/visorchipset/parser.c @@ -1,6 +1,6 @@ /* parser.c * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/visorchipset/parser.h b/drivers/staging/unisys/visorchipset/parser.h index a0cc50a533cd..3e4aedc580ce 100644 --- a/drivers/staging/unisys/visorchipset/parser.h +++ b/drivers/staging/unisys/visorchipset/parser.h @@ -1,6 +1,6 @@ /* parser.h * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/visorchipset/testing.h b/drivers/staging/unisys/visorchipset/testing.h index a44f5556cb21..ad378b82cf99 100644 --- a/drivers/staging/unisys/visorchipset/testing.h +++ b/drivers/staging/unisys/visorchipset/testing.h @@ -1,6 +1,6 @@ /* testing.h * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index d95825dc5414..06646e4e3f1e 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -1,6 +1,6 @@ /* visorchipset.h * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index c475e256e34b..1895dc459643 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -1,6 +1,6 @@ /* visorchipset_main.c * - * Copyright � 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/visorchipset/visorchipset_umode.h b/drivers/staging/unisys/visorchipset/visorchipset_umode.h index 259e840376a5..06ba5b7e4254 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_umode.h +++ b/drivers/staging/unisys/visorchipset/visorchipset_umode.h @@ -1,6 +1,6 @@ /* visorchipset_umode.h * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/visorutil/charqueue.c b/drivers/staging/unisys/visorutil/charqueue.c index 0ceede129e87..61600e1955b3 100644 --- a/drivers/staging/unisys/visorutil/charqueue.c +++ b/drivers/staging/unisys/visorutil/charqueue.c @@ -1,6 +1,6 @@ /* charqueue.c * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/visorutil/charqueue.h b/drivers/staging/unisys/visorutil/charqueue.h index e82ae0bc8959..d6f16587a364 100644 --- a/drivers/staging/unisys/visorutil/charqueue.h +++ b/drivers/staging/unisys/visorutil/charqueue.h @@ -1,6 +1,6 @@ /* charqueue.h * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/visorutil/easyproc.c b/drivers/staging/unisys/visorutil/easyproc.c index 60b6b83d1b20..43df5988f0b8 100644 --- a/drivers/staging/unisys/visorutil/easyproc.c +++ b/drivers/staging/unisys/visorutil/easyproc.c @@ -1,4 +1,4 @@ -/* Copyright © 2010 - 2013 UNISYS CORPORATION +/* Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/visorutil/easyproc.h b/drivers/staging/unisys/visorutil/easyproc.h index 1cef1fd33d53..6ce7d5eb6ad1 100644 --- a/drivers/staging/unisys/visorutil/easyproc.h +++ b/drivers/staging/unisys/visorutil/easyproc.h @@ -1,6 +1,6 @@ /* easyproc.h * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/visorutil/memregion.h b/drivers/staging/unisys/visorutil/memregion.h index bb122dbeafbc..796631652b77 100644 --- a/drivers/staging/unisys/visorutil/memregion.h +++ b/drivers/staging/unisys/visorutil/memregion.h @@ -1,6 +1,6 @@ /* memregion.h * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c index 2c1061d55ee9..d39fde9c1a60 100644 --- a/drivers/staging/unisys/visorutil/memregion_direct.c +++ b/drivers/staging/unisys/visorutil/memregion_direct.c @@ -1,6 +1,6 @@ /* memregion_direct.c * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/visorutil/periodic_work.c b/drivers/staging/unisys/visorutil/periodic_work.c index 0670a3174682..0251b83aa55c 100644 --- a/drivers/staging/unisys/visorutil/periodic_work.c +++ b/drivers/staging/unisys/visorutil/periodic_work.c @@ -1,6 +1,6 @@ /* periodic_work.c * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/visorutil/procobjecttree.c b/drivers/staging/unisys/visorutil/procobjecttree.c index 67a19e1c7b02..2f874e0ab339 100644 --- a/drivers/staging/unisys/visorutil/procobjecttree.c +++ b/drivers/staging/unisys/visorutil/procobjecttree.c @@ -1,6 +1,6 @@ /* procobjecttree.c * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify diff --git a/drivers/staging/unisys/visorutil/visorkmodutils.c b/drivers/staging/unisys/visorutil/visorkmodutils.c index a7d1e94ca3c3..e802e75a4696 100644 --- a/drivers/staging/unisys/visorutil/visorkmodutils.c +++ b/drivers/staging/unisys/visorutil/visorkmodutils.c @@ -1,6 +1,6 @@ /* timskmodutils.c * - * Copyright © 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify -- cgit v1.2.3 From 87995171ac35995c4b5f2801d81a5facd8e006d6 Mon Sep 17 00:00:00 2001 From: Ken Cox Date: Thu, 24 Apr 2014 13:57:11 -0500 Subject: Staging: unisys: virthba: add MODULE_DEVICE_TABLE Add x86_cpu_id struct and call to MODULE_DEVICE_TABLE so this module will be auto loaded on boot. Signed-off-by: Ken Cox Tested-by: Ken Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virthba/virthba.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c index 2755b4e9e769..a13e79e287f4 100644 --- a/drivers/staging/unisys/virthba/virthba.c +++ b/drivers/staging/unisys/virthba/virthba.c @@ -82,6 +82,14 @@ static int virthba_ioctl(struct scsi_device *dev, int cmd, void __user *arg); static int virthba_queue_command_lck(struct scsi_cmnd *scsicmd, void (*virthba_cmnd_done)(struct scsi_cmnd *)); +static const struct x86_cpu_id unisys_spar_ids[] = { + { X86_VENDOR_INTEL, 6, 62, X86_FEATURE_ANY }, + {} +}; + +/* Autoload */ +MODULE_DEVICE_TABLE(x86cpu, unisys_spar_ids); + #ifdef DEF_SCSI_QCMD DEF_SCSI_QCMD(virthba_queue_command) #else -- cgit v1.2.3 From bfdaa39f42e6f7b364f3c499af9a67b1d8186c8b Mon Sep 17 00:00:00 2001 From: SeongJae Park Date: Wed, 26 Mar 2014 23:24:06 +0900 Subject: staging: silicom: remove BP_PROC_SUPPORT dependant code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some code is hide inside #ifdef BP_PROC_SUPPORT and it never defined anywhere. And, it made defined but not used function which calling code was hide inside #ifdef BP_PROC_SUPPORT and caused following build warning: drivers/staging/silicom/bpctl_mod.c:6786:12: warning: ‘bp_proc_create’ defined but not used [-Wunused-function] static int bp_proc_create(void) ^ Fix the warning and remove code complexity by remove whole code inside #ifdef BP_PROC_SUPPORT. Signed-off-by: SeongJae Park Signed-off-by: Greg Kroah-Hartman --- drivers/staging/silicom/bpctl_mod.c | 39 ------------------------------------- 1 file changed, 39 deletions(-) diff --git a/drivers/staging/silicom/bpctl_mod.c b/drivers/staging/silicom/bpctl_mod.c index 6b9365b28e8a..530d6214de74 100644 --- a/drivers/staging/silicom/bpctl_mod.c +++ b/drivers/staging/silicom/bpctl_mod.c @@ -119,7 +119,6 @@ static void if_scan_init(void); static int bypass_proc_create_dev_sd(struct bpctl_dev *pbp_device_block); static int bypass_proc_remove_dev_sd(struct bpctl_dev *pbp_device_block); -static int bp_proc_create(void); static int is_bypass_fn(struct bpctl_dev *pbpctl_dev); static int get_dev_idx_bsf(int bus, int slot, int func); @@ -6399,25 +6398,6 @@ static int __init bypass_init_module(void) } register_netdevice_notifier(&bp_notifier_block); -#ifdef BP_PROC_SUPPORT - { - int i = 0; - /* unsigned long flags; */ - /* rcu_read_lock(); */ - bp_proc_create(); - for (i = 0; i < device_num; i++) { - if (bpctl_dev_arr[i].ifindex) { - /* spin_lock_irqsave(&bpvm_lock, flags); */ - bypass_proc_remove_dev_sd(&bpctl_dev_arr[i]); - bypass_proc_create_dev_sd(&bpctl_dev_arr[i]); - /* spin_unlock_irqrestore(&bpvm_lock, flags); */ - } - - } - /* rcu_read_unlock(); */ - } -#endif - return 0; } @@ -6431,13 +6411,6 @@ static void __exit bypass_cleanup_module(void) for (i = 0; i < device_num; i++) { /* unsigned long flags; */ -#ifdef BP_PROC_SUPPORT -/* spin_lock_irqsave(&bpvm_lock, flags); - rcu_read_lock(); */ - bypass_proc_remove_dev_sd(&bpctl_dev_arr[i]); -/* spin_unlock_irqrestore(&bpvm_lock, flags); - rcu_read_unlock(); */ -#endif remove_bypass_wd_auto(&bpctl_dev_arr[i]); bpctl_dev_arr[i].reset_time = 0; @@ -6783,18 +6756,6 @@ EXPORT_SYMBOL(bp_if_scan_sd); static struct proc_dir_entry *bp_procfs_dir; -static int bp_proc_create(void) -{ - bp_procfs_dir = proc_mkdir(BP_PROC_DIR, init_net.proc_net); - if (bp_procfs_dir == (struct proc_dir_entry *)0) { - printk(KERN_DEBUG - "Could not create procfs nicinfo directory %s\n", - BP_PROC_DIR); - return -1; - } - return 0; -} - static int procfs_add(char *proc_name, const struct file_operations *fops, struct bpctl_dev *dev) { -- cgit v1.2.3 From 2f4285d17d3a5ae42e2811005dbcd4818d5d6ebe Mon Sep 17 00:00:00 2001 From: Neil Armstrong Date: Tue, 1 Apr 2014 15:03:44 +0200 Subject: Staging: silicom: fix dangerous if condition in bpctl_mod.c checkpatch script returns the following warning: ERROR: do not use assignment in if condition + if (((dev_num = get_dev_idx(dev->ifindex)) == -1) | This patch fixes the if condition by splitting it. Signed-off-by: Neil Armstrong Signed-off-by: Greg Kroah-Hartman --- drivers/staging/silicom/bpctl_mod.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/staging/silicom/bpctl_mod.c b/drivers/staging/silicom/bpctl_mod.c index 530d6214de74..7f3d884d4ddd 100644 --- a/drivers/staging/silicom/bpctl_mod.c +++ b/drivers/staging/silicom/bpctl_mod.c @@ -219,8 +219,12 @@ static int bp_device_event(struct notifier_block *unused, if (netif_carrier_ok(dev)) return NOTIFY_DONE; - if (((dev_num = get_dev_idx(dev->ifindex)) == -1) || - (!(pbpctl_dev = &bpctl_dev_arr[dev_num]))) + dev_num = get_dev_idx(dev->ifindex); + if (dev_num == -1) + return NOTIFY_DONE; + + pbpctl_dev = &bpctl_dev_arr[dev_num]; + if (!pbpctl_dev) return NOTIFY_DONE; if ((is_bypass_fn(pbpctl_dev)) == 1) -- cgit v1.2.3 From 5397db900a3e67a86b21860289e80b5a8d8de4cf Mon Sep 17 00:00:00 2001 From: Daeseok Youn Date: Wed, 23 Apr 2014 17:18:42 +0900 Subject: staging: silicom: remove redundant pci_get_drvdata() call The pci_get_drvdata() and checking NULL for dev are called twice in while loop in is_bypass_dev(). Signed-off-by: Daeseok Youn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/silicom/bypasslib/bypass.c | 51 ++++++++++++++---------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/drivers/staging/silicom/bypasslib/bypass.c b/drivers/staging/silicom/bypasslib/bypass.c index 09e00dac04f3..a58251f5a8f8 100644 --- a/drivers/staging/silicom/bypasslib/bypass.c +++ b/drivers/staging/silicom/bypasslib/bypass.c @@ -149,38 +149,33 @@ static int is_bypass_dev(int if_index) while ((pdev = pci_get_class(PCI_CLASS_NETWORK_ETHERNET << 8, pdev))) { dev = pci_get_drvdata(pdev); - if (dev != NULL) { - dev = pci_get_drvdata(pdev); - if ((dev != NULL) && (dev->ifindex == if_index)) { - if ((pdev->vendor == SILICOM_VID) && - (pdev->device >= SILICOM_BP_PID_MIN) && - (pdev->device <= SILICOM_BP_PID_MAX)) { - goto send_cmd; - } + if ((dev != NULL) && (dev->ifindex == if_index)) { + if ((pdev->vendor == SILICOM_VID) && + (pdev->device >= SILICOM_BP_PID_MIN) && + (pdev->device <= SILICOM_BP_PID_MAX)) { + goto send_cmd; + } #if defined(BP_VENDOR_SUPPORT) && defined(ETHTOOL_GDRVINFO) - else { - struct ethtool_drvinfo info; - const struct ethtool_ops *ops = - dev->ethtool_ops; - int k = 0; - - if (ops->get_drvinfo) { - memset(&info, 0, sizeof(info)); - info.cmd = ETHTOOL_GDRVINFO; - ops->get_drvinfo(dev, &info); - for (; bp_desc_array[k]; k++) - if (! - (strcmp - (bp_desc_array[k], - info.driver))) - goto send_cmd; - - } + else { + struct ethtool_drvinfo info; + const struct ethtool_ops *ops = + dev->ethtool_ops; + int k = 0; + + if (ops->get_drvinfo) { + memset(&info, 0, sizeof(info)); + info.cmd = ETHTOOL_GDRVINFO; + ops->get_drvinfo(dev, &info); + for (; bp_desc_array[k]; k++) + if (!(strcmp(bp_desc_array[k], + info.driver))) + goto send_cmd; } -#endif - return -1; + } +#endif + return -1; } } send_cmd: -- cgit v1.2.3 From e7dad54f76e2f29ec181bfac9b4ca6d922e25d67 Mon Sep 17 00:00:00 2001 From: huanqi chi Date: Sat, 5 Apr 2014 13:53:27 +0800 Subject: staging rtl8188eu: add a blank line after declarations fix a coding style issue: Missing a blank line after declarations Signed-off-by: huanqi chi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_br_ext.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/rtl8188eu/core/rtw_br_ext.c b/drivers/staging/rtl8188eu/core/rtw_br_ext.c index e843c6bd4525..f97f05f4165e 100644 --- a/drivers/staging/rtl8188eu/core/rtw_br_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_br_ext.c @@ -442,6 +442,7 @@ static void __nat25_db_print(struct adapter *priv) void nat25_db_cleanup(struct adapter *priv) { int i; + spin_lock_bh(&priv->br_ext_lock); for (i = 0; i < NAT25_HASH_SIZE; i++) { -- cgit v1.2.3 From a8d0df262cd58ff2eff4461be8ab9a79d2d7f440 Mon Sep 17 00:00:00 2001 From: Loïc Pellegrino Date: Sun, 6 Apr 2014 14:03:39 +0100 Subject: staging: rtl8192u: Fix indentation problems MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix coding style problems (incorrect indentation). Signed-off-by: Loïc Pellegrino Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8190_rtl8256.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192u/r8190_rtl8256.c b/drivers/staging/rtl8192u/r8190_rtl8256.c index 40b14a2d1cdb..08e1bc90555a 100644 --- a/drivers/staging/rtl8192u/r8190_rtl8256.c +++ b/drivers/staging/rtl8192u/r8190_rtl8256.c @@ -32,7 +32,7 @@ void PHY_SetRF8256Bandwidth(struct net_device *dev , HT_CHANNEL_WIDTH Bandwidth) for(eRFPath = 0; eRFPath NumTotalRFPath; eRFPath++) { if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath)) - continue; + continue; pPhyReg = &priv->PHYRegDef[eRFPath]; @@ -249,7 +249,7 @@ void PHY_SetRF8256CCKTxPower(struct net_device *dev, u8 powerlevel) if(priv->CustomerID == RT_CID_819x_Netcore) TxAGC = 0x22; else - TxAGC += priv->CckPwEnl; + TxAGC += priv->CckPwEnl; } if(TxAGC > 0x24) -- cgit v1.2.3 From 9dbd79aeb9842144d9a114a979a12c0949ee11eb Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 7 Apr 2014 09:31:21 +0300 Subject: Staging: rtl8188eu: overflow in update_sta_support_rate() The ->SupportedRates[] array has NDIS_802_11_LENGTH_RATES_EX (16) elements. Since "ie_len" comes from then network and can go up to 255 then it means we should add a range check to prevent memory corruption. Fixes: d6846af679e0 ('staging: r8188eu: Add files for new driver - part 7') Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index 3dd90599fd4b..6c9e9a16b2e9 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -1599,13 +1599,18 @@ int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, uint var_ie_l pIE = (struct ndis_802_11_var_ie *)rtw_get_ie(pvar_ie, _SUPPORTEDRATES_IE_, &ie_len, var_ie_len); if (pIE == NULL) return _FAIL; + if (ie_len > NDIS_802_11_LENGTH_RATES_EX) + return _FAIL; memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates, pIE->data, ie_len); supportRateNum = ie_len; pIE = (struct ndis_802_11_var_ie *)rtw_get_ie(pvar_ie, _EXT_SUPPORTEDRATES_IE_, &ie_len, var_ie_len); - if (pIE) + if (pIE) { + if (supportRateNum + ie_len > NDIS_802_11_LENGTH_RATES_EX) + return _FAIL; memcpy((pmlmeinfo->FW_sta_info[cam_idx].SupportedRates + supportRateNum), pIE->data, ie_len); + } return _SUCCESS; } -- cgit v1.2.3 From 82671db89c01c2c5d8a40284b5975b6a09d62d7b Mon Sep 17 00:00:00 2001 From: Paul McQuade Date: Wed, 9 Apr 2014 21:01:29 +0100 Subject: Staging:rtl8192e:rtl819x_BAProc:Remove whitespaces ERROR: spaces required around that '=' (ctx:OxW) Signed-off-by: Paul McQuade Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl819x_BAProc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index adc6cc7ca3d6..2aecdbd624fb 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -109,9 +109,9 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst, BAReq->frame_ctl = cpu_to_le16(RTLLIB_STYPE_MANAGE_ACT); tag = (u8 *)skb_put(skb, 9); - *tag ++= ACT_CAT_BA; - *tag ++= type; - *tag ++= pBA->DialogToken; + *tag++ = ACT_CAT_BA; + *tag++ = type; + *tag++ = pBA->DialogToken; if (ACT_ADDBARSP == type) { RT_TRACE(COMP_DBG, "====>to send ADDBARSP\n"); @@ -175,8 +175,8 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst, tag = (u8 *)skb_put(skb, 6); - *tag ++= ACT_CAT_BA; - *tag ++= ACT_DELBA; + *tag++ = ACT_CAT_BA; + *tag++ = ACT_DELBA; tmp = DelbaParamSet.shortData; memcpy(tag, (u8 *)&tmp, 2); -- cgit v1.2.3 From 5169af2309f42bb4cb0ebfefe6bf8bc888d4ce33 Mon Sep 17 00:00:00 2001 From: Joel Pelaez Jorge Date: Sat, 19 Apr 2014 22:32:32 -0500 Subject: Staging: rtl8192e: Fix declaration of symbols The two declarations with issues in rtl_wx.h: * function: struct iw_statistics *r8192_get_wireless_stats(); * variable: extern struct iw_handler_def r8192_wx_handlers_def; The symbol 'r8192_get_wireless_stats' is declared as 'extern' but it is only used in the local scope. The declaration is deleted of rtl_wx.h, fixing the conflict with the 'extern' and 'static' scope. The symbol 'r8192_wx_handlers_def' was fixed of some issues related to variable declaration marked as 'extern' implicitly, causing this sparse warning: drivers/staging/rtl8192e/rtl8192e/rtl_wx.c:1323:24: warning: symbol 'r8192_wx_handlers_def' was not declared. Should it be static? Resolved incluing the fixed header to rtl_wx.c Also, isn't declared as constant variable, so it declared as such. And delete unnecessary cast in rtl_core.c. Signed-off-by: Joel Pelaez Jorge Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 3 +-- drivers/staging/rtl8192e/rtl8192e/rtl_wx.c | 3 ++- drivers/staging/rtl8192e/rtl8192e/rtl_wx.h | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index c01abc23213e..fa087b654ebc 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -2926,8 +2926,7 @@ static int rtl8192_pci_probe(struct pci_dev *pdev, dev->netdev_ops = &rtl8192_netdev_ops; - dev->wireless_handlers = (struct iw_handler_def *) - &r8192_wx_handlers_def; + dev->wireless_handlers = &r8192_wx_handlers_def; dev->ethtool_ops = &rtl819x_ethtool_ops; dev->type = ARPHRD_ETHER; diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c index 498995d833e7..7d8fcdeafb55 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c @@ -19,6 +19,7 @@ #include #include "rtl_core.h" +#include "rtl_wx.h" #define RATE_COUNT 12 static u32 rtl8192_rates[] = { @@ -1320,7 +1321,7 @@ static struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev) return wstats; } -struct iw_handler_def r8192_wx_handlers_def = { +const struct iw_handler_def r8192_wx_handlers_def = { .standard = r8192_wx_handlers, .num_standard = ARRAY_SIZE(r8192_wx_handlers), .private = r8192_private_handler, diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.h b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.h index 6a51a25ec87d..58398517f5b3 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.h @@ -24,8 +24,7 @@ struct net_device; struct iw_handler_def; struct iw_statistics; -extern struct iw_handler_def r8192_wx_handlers_def; -struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev); +extern const struct iw_handler_def r8192_wx_handlers_def; u16 rtl8192_11n_user_show_rates(struct net_device *dev); #endif -- cgit v1.2.3 From 6d09e0efeff6606873f65677dcf098dd8ffb4a5f Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sat, 19 Apr 2014 15:35:42 +0100 Subject: staging: rtl8821ae: Remove file #if 1 All code in this file is encapsulated in a useless #if 1 declaration, remove it. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c b/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c index 115908928ae4..eadfa05a1f5b 100644 --- a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c +++ b/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c @@ -12,7 +12,7 @@ * include files **************************************************************/ #include "halbt_precomp.h" -#if 1 + /************************************************************** * Global variables, these are static variables **************************************************************/ @@ -4237,6 +4237,3 @@ void ex_halbtc8192e2ant_periodical(struct btc_coexist *btcoexist) #endif } - -#endif - -- cgit v1.2.3 From 88a6733980d13958b572666c1b0979d7fe17440c Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sat, 19 Apr 2014 15:35:43 +0100 Subject: staging: rtl8821ae: Remove unused functions Remove functions not being called from anywhere: halbtc8192e2ant_set_adc_backoff() halbtc8192e2ant_adc_backoff() Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8821ae/btcoexist/halbtc8192e2ant.c | 38 ---------------------- 1 file changed, 38 deletions(-) diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c b/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c index eadfa05a1f5b..f1b8f4fca798 100644 --- a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c +++ b/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c @@ -1041,44 +1041,6 @@ void halbtc8192e2ant_DacSwing(struct btc_coexist *btcoexist, coex_dm->pre_dac_swing_lvl = coex_dm->cur_dac_swing_lvl; } -void halbtc8192e2ant_set_adc_backoff(struct btc_coexist *btcoexist, - bool adc_backoff) -{ - if(adc_backoff) - { - BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, - "[BTCoex], BB BackOff Level On!\n"); - btcoexist->btc_write_1byte_bitmask(btcoexist, 0xc05, 0x30, 0x3); - } - else - { - BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, - "[BTCoex], BB BackOff Level Off!\n"); - btcoexist->btc_write_1byte_bitmask(btcoexist, 0xc05, 0x30, 0x1); - } -} - -void halbtc8192e2ant_adc_backoff(struct btc_coexist *btcoexist, - bool force_exec, bool adc_backoff) -{ - BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, - "[BTCoex], %s turn AdcBackOff = %s\n", - (force_exec? "force to":""), ((adc_backoff)? "ON":"OFF")); - coex_dm->cur_adc_back_off = adc_backoff; - - if (!force_exec) { - BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, - "[BTCoex], bPreAdcBackOff=%d, bCurAdcBackOff=%d\n", - coex_dm->pre_adc_back_off, coex_dm->cur_adc_back_off); - - if (coex_dm->pre_adc_back_off == coex_dm->cur_adc_back_off) - return; - } - halbtc8192e2ant_set_adc_backoff(btcoexist, coex_dm->cur_adc_back_off); - - coex_dm->pre_adc_back_off = coex_dm->cur_adc_back_off; -} - void halbtc8192e2ant_set_agc_table(struct btc_coexist *btcoexist, bool agc_table_en) { -- cgit v1.2.3 From 35c9e7fd57f2efeab2a7b92d0799fd161e7e4eb6 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sat, 19 Apr 2014 15:35:44 +0100 Subject: staging: rtl8821ae: Fix halbtc8192e2ant.c 'should it be static?' sparse warnings In halbtc8192e2ant.c, fix all instances of the sparse warning: warning: symbol 'xxx' was not declared. Should it be static? Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8821ae/btcoexist/halbtc8192e2ant.c | 218 +++++++++++---------- 1 file changed, 114 insertions(+), 104 deletions(-) diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c b/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c index f1b8f4fca798..dae372d74b1c 100644 --- a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c +++ b/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c @@ -21,14 +21,14 @@ static struct coex_dm_8192e_2ant *coex_dm = &glcoex_dm_8192e_2ant; static struct coex_sta_8192e_2ant glcoex_sta_8192e_2ant; static struct coex_sta_8192e_2ant *coex_sta = &glcoex_sta_8192e_2ant; -const char *const GLBtInfoSrc8192e2Ant[]={ +static const char *const GLBtInfoSrc8192e2Ant[]={ "BT Info[wifi fw]", "BT Info[bt rsp]", "BT Info[bt auto report]", }; -u32 glcoex_ver_date_8192e_2ant = 20130902; -u32 glcoex_ver_8192e_2ant = 0x34; +static u32 glcoex_ver_date_8192e_2ant = 20130902; +static u32 glcoex_ver_8192e_2ant = 0x34; /************************************************************** * local function proto type if needed @@ -36,7 +36,8 @@ u32 glcoex_ver_8192e_2ant = 0x34; /************************************************************** * local function start with halbtc8192e2ant_ **************************************************************/ -u8 halbtc8192e2ant_btrssi_state(u8 level_num, u8 rssi_thresh, u8 rssi_thresh1) +static u8 halbtc8192e2ant_btrssi_state(u8 level_num, u8 rssi_thresh, + u8 rssi_thresh1) { int btrssi=0; u8 btrssi_state = coex_sta->pre_bt_rssi_state; @@ -132,8 +133,9 @@ u8 halbtc8192e2ant_btrssi_state(u8 level_num, u8 rssi_thresh, u8 rssi_thresh1) return btrssi_state; } -u8 halbtc8192e2ant_wifirssi_state(struct btc_coexist * btcoexist, u8 index, - u8 level_num, u8 rssi_thresh, u8 rssi_thresh1) +static u8 halbtc8192e2ant_wifirssi_state(struct btc_coexist * btcoexist, + u8 index, u8 level_num, + u8 rssi_thresh, u8 rssi_thresh1) { int wifirssi = 0; u8 wifirssi_state = coex_sta->pre_wifi_rssi_state[index]; @@ -234,7 +236,7 @@ u8 halbtc8192e2ant_wifirssi_state(struct btc_coexist * btcoexist, u8 index, return wifirssi_state; } -void halbtc8192e2ant_monitor_bt_enable_disable(struct btc_coexist *btcoexist) +static void halbtc8192e2ant_monitor_bt_enable_disable(struct btc_coexist *btcoexist) { static bool pre_bt_disabled = false; static u32 bt_disable_cnt = 0; @@ -283,7 +285,7 @@ void halbtc8192e2ant_monitor_bt_enable_disable(struct btc_coexist *btcoexist) } } -u32 halbtc8192e2ant_decidera_mask(struct btc_coexist *btcoexist, +static u32 halbtc8192e2ant_decidera_mask(struct btc_coexist *btcoexist, u8 sstype, u32 ra_masktype) { u32 disra_mask = 0x0; @@ -314,8 +316,8 @@ u32 halbtc8192e2ant_decidera_mask(struct btc_coexist *btcoexist, return disra_mask; } -void halbtc8192e2ant_Updatera_mask(struct btc_coexist *btcoexist, - bool force_exec, u32 dis_ratemask) +static void halbtc8192e2ant_Updatera_mask(struct btc_coexist *btcoexist, + bool force_exec, u32 dis_ratemask) { coex_dm->curra_mask = dis_ratemask; @@ -325,8 +327,8 @@ void halbtc8192e2ant_Updatera_mask(struct btc_coexist *btcoexist, coex_dm->prera_mask = coex_dm->curra_mask; } -void halbtc8192e2ant_autorate_fallback_retry(struct btc_coexist *btcoexist, - bool force_exec, u8 type) +static void halbtc8192e2ant_autorate_fallback_retry(struct btc_coexist *btcoexist, + bool force_exec, u8 type) { bool wifi_under_bmode = false; @@ -364,8 +366,8 @@ void halbtc8192e2ant_autorate_fallback_retry(struct btc_coexist *btcoexist, coex_dm->pre_arfrtype = coex_dm->cur_arfrtype; } -void halbtc8192e2ant_retrylimit(struct btc_coexist *btcoexist, - bool force_exec, u8 type) +static void halbtc8192e2ant_retrylimit(struct btc_coexist *btcoexist, + bool force_exec, u8 type) { coex_dm->cur_retrylimit_type = type; @@ -388,8 +390,8 @@ void halbtc8192e2ant_retrylimit(struct btc_coexist *btcoexist, coex_dm->pre_retrylimit_type = coex_dm->cur_retrylimit_type; } -void halbtc8192e2ant_ampdu_maxtime(struct btc_coexist *btcoexist, - bool force_exec, u8 type) +static void halbtc8192e2ant_ampdu_maxtime(struct btc_coexist *btcoexist, + bool force_exec, u8 type) { coex_dm->cur_ampdutime_type = type; @@ -411,9 +413,10 @@ void halbtc8192e2ant_ampdu_maxtime(struct btc_coexist *btcoexist, coex_dm->pre_ampdutime_type = coex_dm->cur_ampdutime_type; } -void halbtc8192e2ant_limited_tx(struct btc_coexist *btcoexist, - bool force_exec, u8 ra_masktype, u8 arfr_type, - u8 retrylimit_type, u8 ampdutime_type) +static void halbtc8192e2ant_limited_tx(struct btc_coexist *btcoexist, + bool force_exec, u8 ra_masktype, + u8 arfr_type, u8 retrylimit_type, + u8 ampdutime_type) { u32 disra_mask = 0x0; @@ -429,10 +432,10 @@ void halbtc8192e2ant_limited_tx(struct btc_coexist *btcoexist, halbtc8192e2ant_ampdu_maxtime(btcoexist, force_exec, ampdutime_type); } -void halbtc8192e2ant_limited_rx(struct btc_coexist *btcoexist, - bool force_exec, bool rej_ap_agg_pkt, - bool b_bt_ctrl_agg_buf_size, - u8 agg_buf_size) +static void halbtc8192e2ant_limited_rx(struct btc_coexist *btcoexist, + bool force_exec, bool rej_ap_agg_pkt, + bool b_bt_ctrl_agg_buf_size, + u8 agg_buf_size) { bool reject_rx_agg = rej_ap_agg_pkt; bool bt_ctrl_rx_agg_size = b_bt_ctrl_agg_buf_size; @@ -455,7 +458,7 @@ void halbtc8192e2ant_limited_rx(struct btc_coexist *btcoexist, } -void halbtc8192e2ant_monitor_bt_ctr(struct btc_coexist *btcoexist) +static void halbtc8192e2ant_monitor_bt_ctr(struct btc_coexist *btcoexist) { u32 reg_hp_txrx, reg_lp_txrx, u32tmp; u32 reg_hp_tx = 0, reg_hp_rx = 0, reg_lp_tx = 0, reg_lp_rx = 0; @@ -487,7 +490,7 @@ void halbtc8192e2ant_monitor_bt_ctr(struct btc_coexist *btcoexist) btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc); } -void halbtc8192e2ant_querybt_info(struct btc_coexist *btcoexist) +static void halbtc8192e2ant_querybt_info(struct btc_coexist *btcoexist) { u8 h2c_parameter[1] ={0}; @@ -502,7 +505,7 @@ void halbtc8192e2ant_querybt_info(struct btc_coexist *btcoexist) btcoexist->btc_fill_h2c(btcoexist, 0x61, 1, h2c_parameter); } -bool halbtc8192e2ant_iswifi_status_changed(struct btc_coexist *btcoexist) +static bool halbtc8192e2ant_iswifi_status_changed(struct btc_coexist *btcoexist) { static bool pre_wifi_busy = false; static bool pre_under_4way = false, pre_bt_hson = false; @@ -534,7 +537,7 @@ bool halbtc8192e2ant_iswifi_status_changed(struct btc_coexist *btcoexist) return false; } -void halbtc8192e2ant_update_btlink_info(struct btc_coexist *btcoexist) +static void halbtc8192e2ant_update_btlink_info(struct btc_coexist *btcoexist) { struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; bool bt_hson = false; @@ -590,7 +593,7 @@ void halbtc8192e2ant_update_btlink_info(struct btc_coexist *btcoexist) bt_link_info->hid_only = false; } -u8 halbtc8192e2ant_action_algorithm(struct btc_coexist *btcoexist) +static u8 halbtc8192e2ant_action_algorithm(struct btc_coexist *btcoexist) { struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; struct btc_stack_info *stack_info = &btcoexist->stack_info; @@ -777,8 +780,8 @@ u8 halbtc8192e2ant_action_algorithm(struct btc_coexist *btcoexist) return algorithm; } -void halbtc8192e2ant_setfw_dac_swinglevel(struct btc_coexist *btcoexist, - u8 dac_swinglvl) +static void halbtc8192e2ant_setfw_dac_swinglevel(struct btc_coexist *btcoexist, + u8 dac_swinglvl) { u8 h2c_parameter[1] ={0}; @@ -794,8 +797,8 @@ void halbtc8192e2ant_setfw_dac_swinglevel(struct btc_coexist *btcoexist, btcoexist->btc_fill_h2c(btcoexist, 0x64, 1, h2c_parameter); } -void halbtc8192e2ant_set_fwdec_btpwr(struct btc_coexist *btcoexist, - u8 dec_btpwr_lvl) +static void halbtc8192e2ant_set_fwdec_btpwr(struct btc_coexist *btcoexist, + u8 dec_btpwr_lvl) { u8 h2c_parameter[1] ={0}; @@ -808,8 +811,8 @@ void halbtc8192e2ant_set_fwdec_btpwr(struct btc_coexist *btcoexist, btcoexist->btc_fill_h2c(btcoexist, 0x62, 1, h2c_parameter); } -void halbtc8192e2ant_dec_btpwr(struct btc_coexist *btcoexist, - bool force_exec, u8 dec_btpwr_lvl) +static void halbtc8192e2ant_dec_btpwr(struct btc_coexist *btcoexist, + bool force_exec, u8 dec_btpwr_lvl) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, "[BTCoex], %s Dec BT power level = %d\n", @@ -826,8 +829,8 @@ void halbtc8192e2ant_dec_btpwr(struct btc_coexist *btcoexist, coex_dm->pre_dec_bt_pwr = coex_dm->cur_dec_bt_pwr; } -void halbtc8192e2ant_set_bt_autoreport(struct btc_coexist *btcoexist, - bool enable_autoreport) +static void halbtc8192e2ant_set_bt_autoreport(struct btc_coexist *btcoexist, + bool enable_autoreport) { u8 h2c_parameter[1] ={0}; @@ -844,8 +847,9 @@ void halbtc8192e2ant_set_bt_autoreport(struct btc_coexist *btcoexist, btcoexist->btc_fill_h2c(btcoexist, 0x68, 1, h2c_parameter); } -void halbtc8192e2ant_bt_autoreport(struct btc_coexist *btcoexist, - bool force_exec, bool enable_autoreport) +static void halbtc8192e2ant_bt_autoreport(struct btc_coexist *btcoexist, + bool force_exec, + bool enable_autoreport) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, "[BTCoex], %s BT Auto report = %s\n", @@ -868,8 +872,8 @@ void halbtc8192e2ant_bt_autoreport(struct btc_coexist *btcoexist, coex_dm->pre_bt_auto_report = coex_dm->cur_bt_auto_report; } -void halbtc8192e2ant_fw_dac_swinglvl(struct btc_coexist *btcoexist, - bool force_exec, u8 fw_dac_swinglvl) +static void halbtc8192e2ant_fw_dac_swinglvl(struct btc_coexist *btcoexist, + bool force_exec, u8 fw_dac_swinglvl) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, "[BTCoex], %s set FW Dac Swing level = %d\n", @@ -893,8 +897,8 @@ void halbtc8192e2ant_fw_dac_swinglvl(struct btc_coexist *btcoexist, coex_dm->pre_fw_dac_swing_lvl = coex_dm->cur_fw_dac_swing_lvl; } -void halbtc8192e2ant_set_sw_rf_rx_lpf_corner(struct btc_coexist *btcoexist, - bool rx_rf_shrink_on) +static void halbtc8192e2ant_set_sw_rf_rx_lpf_corner(struct btc_coexist *btcoexist, + bool rx_rf_shrink_on) { if (rx_rf_shrink_on) { /* Shrink RF Rx LPF corner */ @@ -915,8 +919,8 @@ void halbtc8192e2ant_set_sw_rf_rx_lpf_corner(struct btc_coexist *btcoexist, } } -void halbtc8192e2ant_rf_shrink(struct btc_coexist *btcoexist, - bool force_exec, bool rx_rf_shrink_on) +static void halbtc8192e2ant_rf_shrink(struct btc_coexist *btcoexist, + bool force_exec, bool rx_rf_shrink_on) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, "[BTCoex], %s turn Rx RF Shrink = %s\n", @@ -939,7 +943,7 @@ void halbtc8192e2ant_rf_shrink(struct btc_coexist *btcoexist, coex_dm->pre_rf_rx_lpf_shrink = coex_dm->cur_rf_rx_lpf_shrink; } -void halbtc8192e2ant_set_sw_penalty_tx_rateadaptive( +static void halbtc8192e2ant_set_sw_penalty_tx_rateadaptive( struct btc_coexist *btcoexist, bool low_penalty_ra) { @@ -963,8 +967,8 @@ void halbtc8192e2ant_set_sw_penalty_tx_rateadaptive( btcoexist->btc_fill_h2c(btcoexist, 0x69, 6, h2c_parameter); } -void halbtc8192e2ant_low_penalty_ra(struct btc_coexist *btcoexist, - bool force_exec, bool low_penalty_ra) +static void halbtc8192e2ant_low_penalty_ra(struct btc_coexist *btcoexist, + bool force_exec, bool low_penalty_ra) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, "[BTCoex], %s turn LowPenaltyRA = %s\n", @@ -987,8 +991,8 @@ void halbtc8192e2ant_low_penalty_ra(struct btc_coexist *btcoexist, coex_dm->pre_low_penalty_ra = coex_dm->cur_low_penalty_ra; } -void halbtc8192e2ant_set_dac_swingreg(struct btc_coexist *btcoexist, - u32 level) +static void halbtc8192e2ant_set_dac_swingreg(struct btc_coexist *btcoexist, + u32 level) { u8 val = (u8)level; @@ -997,9 +1001,9 @@ void halbtc8192e2ant_set_dac_swingreg(struct btc_coexist *btcoexist, btcoexist->btc_write_1byte_bitmask(btcoexist, 0x883, 0x3e, val); } -void halbtc8192e2ant_setsw_fulltime_dacswing(struct btc_coexist *btcoexist, - bool sw_dac_swingon, - u32 sw_dac_swinglvl) +static void halbtc8192e2ant_setsw_fulltime_dacswing(struct btc_coexist *btcoexist, + bool sw_dac_swingon, + u32 sw_dac_swinglvl) { if (sw_dac_swingon) halbtc8192e2ant_set_dac_swingreg(btcoexist, sw_dac_swinglvl); @@ -1007,10 +1011,9 @@ void halbtc8192e2ant_setsw_fulltime_dacswing(struct btc_coexist *btcoexist, halbtc8192e2ant_set_dac_swingreg(btcoexist, 0x18); } - -void halbtc8192e2ant_DacSwing(struct btc_coexist *btcoexist, - bool force_exec, bool dac_swingon, - u32 dac_swinglvl) +static void halbtc8192e2ant_DacSwing(struct btc_coexist *btcoexist, + bool force_exec, bool dac_swingon, + u32 dac_swinglvl) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, "[BTCoex], %s turn DacSwing=%s, dac_swinglvl=0x%x\n", @@ -1041,8 +1044,8 @@ void halbtc8192e2ant_DacSwing(struct btc_coexist *btcoexist, coex_dm->pre_dac_swing_lvl = coex_dm->cur_dac_swing_lvl; } -void halbtc8192e2ant_set_agc_table(struct btc_coexist *btcoexist, - bool agc_table_en) +static void halbtc8192e2ant_set_agc_table(struct btc_coexist *btcoexist, + bool agc_table_en) { /* BB AGC Gain Table */ @@ -1067,8 +1070,8 @@ void halbtc8192e2ant_set_agc_table(struct btc_coexist *btcoexist, } } -void halbtc8192e2ant_AgcTable(struct btc_coexist *btcoexist, - bool force_exec, bool agc_table_en) +static void halbtc8192e2ant_AgcTable(struct btc_coexist *btcoexist, + bool force_exec, bool agc_table_en) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, "[BTCoex], %s %s Agc Table\n", @@ -1089,9 +1092,9 @@ void halbtc8192e2ant_AgcTable(struct btc_coexist *btcoexist, coex_dm->pre_agc_table_en = coex_dm->cur_agc_table_en; } -void halbtc8192e2ant_set_coex_table(struct btc_coexist *btcoexist, - u32 val0x6c0, u32 val0x6c4, - u32 val0x6c8, u8 val0x6cc) +static void halbtc8192e2ant_set_coex_table(struct btc_coexist *btcoexist, + u32 val0x6c0, u32 val0x6c4, + u32 val0x6c8, u8 val0x6cc) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, "[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0); @@ -1110,9 +1113,10 @@ void halbtc8192e2ant_set_coex_table(struct btc_coexist *btcoexist, btcoexist->btc_write_1byte(btcoexist, 0x6cc, val0x6cc); } -void halbtc8192e2ant_coex_table(struct btc_coexist *btcoexist, bool force_exec, - u32 val0x6c0, u32 val0x6c4, - u32 val0x6c8, u8 val0x6cc) +static void halbtc8192e2ant_coex_table(struct btc_coexist *btcoexist, + bool force_exec, + u32 val0x6c0, u32 val0x6c4, + u32 val0x6c8, u8 val0x6cc) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, "[BTCoex], %s write Coex Table 0x6c0=0x%x, ", @@ -1154,8 +1158,8 @@ void halbtc8192e2ant_coex_table(struct btc_coexist *btcoexist, bool force_exec, coex_dm->pre_val0x6cc = coex_dm->cur_val0x6cc; } -void halbtc8192e2ant_coex_table_with_type(struct btc_coexist *btcoexist, - bool force_exec, u8 type) +static void halbtc8192e2ant_coex_table_with_type(struct btc_coexist *btcoexist, + bool force_exec, u8 type) { switch (type) { case 0: @@ -1183,8 +1187,8 @@ void halbtc8192e2ant_coex_table_with_type(struct btc_coexist *btcoexist, } } -void halbtc8192e2ant_set_fw_ignore_wlanact(struct btc_coexist *btcoexist, - bool enable) +static void halbtc8192e2ant_set_fw_ignore_wlanact(struct btc_coexist *btcoexist, + bool enable) { u8 h2c_parameter[1] ={0}; @@ -1198,8 +1202,8 @@ void halbtc8192e2ant_set_fw_ignore_wlanact(struct btc_coexist *btcoexist, btcoexist->btc_fill_h2c(btcoexist, 0x63, 1, h2c_parameter); } -void halbtc8192e2ant_IgnoreWlanAct(struct btc_coexist *btcoexist, - bool force_exec, bool enable) +static void halbtc8192e2ant_IgnoreWlanAct(struct btc_coexist *btcoexist, + bool force_exec, bool enable) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, "[BTCoex], %s turn Ignore WlanAct %s\n", @@ -1223,8 +1227,8 @@ void halbtc8192e2ant_IgnoreWlanAct(struct btc_coexist *btcoexist, coex_dm->pre_ignore_wlan_act = coex_dm->cur_ignore_wlan_act; } -void halbtc8192e2ant_SetFwPstdma(struct btc_coexist *btcoexist, u8 byte1, - u8 byte2, u8 byte3, u8 byte4, u8 byte5) +static void halbtc8192e2ant_SetFwPstdma(struct btc_coexist *btcoexist, u8 byte1, + u8 byte2, u8 byte3, u8 byte4, u8 byte5) { u8 h2c_parameter[5] ={0}; @@ -1249,24 +1253,28 @@ void halbtc8192e2ant_SetFwPstdma(struct btc_coexist *btcoexist, u8 byte1, btcoexist->btc_fill_h2c(btcoexist, 0x60, 5, h2c_parameter); } -void halbtc8192e2ant_sw_mechanism1(struct btc_coexist *btcoexist, - bool shrink_rx_lpf, bool low_penalty_ra, - bool limited_dig, bool btlan_constrain) +static void halbtc8192e2ant_sw_mechanism1(struct btc_coexist *btcoexist, + bool shrink_rx_lpf, + bool low_penalty_ra, + bool limited_dig, + bool btlan_constrain) { halbtc8192e2ant_rf_shrink(btcoexist, NORMAL_EXEC, shrink_rx_lpf); } -void halbtc8192e2ant_sw_mechanism2(struct btc_coexist *btcoexist, - bool agc_table_shift, bool adc_backoff, - bool sw_dac_swing, u32 dac_swinglvl) +static void halbtc8192e2ant_sw_mechanism2(struct btc_coexist *btcoexist, + bool agc_table_shift, + bool adc_backoff, + bool sw_dac_swing, + u32 dac_swinglvl) { halbtc8192e2ant_AgcTable(btcoexist, NORMAL_EXEC, agc_table_shift); halbtc8192e2ant_DacSwing(btcoexist, NORMAL_EXEC, sw_dac_swing, dac_swinglvl); } -void halbtc8192e2ant_ps_tdma(struct btc_coexist *btcoexist, - bool force_exec, bool turn_on, u8 type) +static void halbtc8192e2ant_ps_tdma(struct btc_coexist *btcoexist, + bool force_exec, bool turn_on, u8 type) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, @@ -1402,7 +1410,8 @@ void halbtc8192e2ant_ps_tdma(struct btc_coexist *btcoexist, coex_dm->pre_ps_tdma = coex_dm->cur_ps_tdma; } -void halbtc8192e2ant_set_switch_sstype(struct btc_coexist *btcoexist, u8 sstype) +static void halbtc8192e2ant_set_switch_sstype(struct btc_coexist *btcoexist, + u8 sstype) { u8 mimops = BTC_MIMO_PS_DYNAMIC; u32 disra_mask = 0x0; @@ -1437,7 +1446,7 @@ void halbtc8192e2ant_set_switch_sstype(struct btc_coexist *btcoexist, u8 sstype) btcoexist->btc_set(btcoexist, BTC_SET_ACT_SEND_MIMO_PS, &mimops); } -void halbtc8192e2ant_switch_sstype(struct btc_coexist *btcoexist, +static void halbtc8192e2ant_switch_sstype(struct btc_coexist *btcoexist, bool force_exec, u8 new_sstype) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, @@ -1454,7 +1463,7 @@ void halbtc8192e2ant_switch_sstype(struct btc_coexist *btcoexist, coex_dm->pre_sstype = coex_dm->cur_sstype; } -void halbtc8192e2ant_coex_alloff(struct btc_coexist *btcoexist) +static void halbtc8192e2ant_coex_alloff(struct btc_coexist *btcoexist) { /* fw all off */ halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1); @@ -1469,7 +1478,7 @@ void halbtc8192e2ant_coex_alloff(struct btc_coexist *btcoexist) halbtc8192e2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0); } -void halbtc8192e2ant_init_coex_dm(struct btc_coexist *btcoexist) +static void halbtc8192e2ant_init_coex_dm(struct btc_coexist *btcoexist) { /* force to reset coex mechanism */ @@ -1484,7 +1493,7 @@ void halbtc8192e2ant_init_coex_dm(struct btc_coexist *btcoexist) halbtc8192e2ant_sw_mechanism2(btcoexist, false, false, false, 0x18); } -void halbtc8192e2ant_action_bt_inquiry(struct btc_coexist *btcoexist) +static void halbtc8192e2ant_action_bt_inquiry(struct btc_coexist *btcoexist) { bool low_pwr_disable = true; @@ -1502,7 +1511,7 @@ void halbtc8192e2ant_action_bt_inquiry(struct btc_coexist *btcoexist) halbtc8192e2ant_sw_mechanism2(btcoexist, false, false, false, 0x18); } -bool halbtc8192e2ant_is_common_action(struct btc_coexist *btcoexist) +static bool halbtc8192e2ant_is_common_action(struct btc_coexist *btcoexist) { struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; bool common = false, wifi_connected = false, wifi_busy = false; @@ -1647,9 +1656,9 @@ bool halbtc8192e2ant_is_common_action(struct btc_coexist *btcoexist) return common; } -void halbtc8192e2ant_tdma_duration_adjust(struct btc_coexist *btcoexist, - bool sco_hid, bool tx_pause, - u8 max_interval) +static void halbtc8192e2ant_tdma_duration_adjust(struct btc_coexist *btcoexist, + bool sco_hid, bool tx_pause, + u8 max_interval) { static int up, dn, m, n, wait_cnt; /* 0: no change, +1: increase WiFi duration, @@ -2704,7 +2713,7 @@ void halbtc8192e2ant_tdma_duration_adjust(struct btc_coexist *btcoexist, } /* SCO only or SCO+PAN(HS) */ -void halbtc8192e2ant_action_sco(struct btc_coexist *btcoexist) +static void halbtc8192e2ant_action_sco(struct btc_coexist *btcoexist) { u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_STAY_LOW; u32 wifi_bw; @@ -2766,7 +2775,7 @@ void halbtc8192e2ant_action_sco(struct btc_coexist *btcoexist) } } -void halbtc8192e2ant_action_sco_pan(struct btc_coexist *btcoexist) +static void halbtc8192e2ant_action_sco_pan(struct btc_coexist *btcoexist) { u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_STAY_LOW; u32 wifi_bw; @@ -2828,7 +2837,7 @@ void halbtc8192e2ant_action_sco_pan(struct btc_coexist *btcoexist) } } -void halbtc8192e2ant_action_hid(struct btc_coexist *btcoexist) +static void halbtc8192e2ant_action_hid(struct btc_coexist *btcoexist) { u8 wifirssi_state, btrssi_state=BTC_RSSI_STATE_HIGH; u32 wifi_bw; @@ -2890,7 +2899,7 @@ void halbtc8192e2ant_action_hid(struct btc_coexist *btcoexist) } /* A2DP only / PAN(EDR) only/ A2DP+PAN(HS) */ -void halbtc8192e2ant_action_a2dp(struct btc_coexist *btcoexist) +static void halbtc8192e2ant_action_a2dp(struct btc_coexist *btcoexist) { u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH; u32 wifi_bw; @@ -2979,7 +2988,7 @@ void halbtc8192e2ant_action_a2dp(struct btc_coexist *btcoexist) } } -void halbtc8192e2ant_action_a2dp_pan_hs(struct btc_coexist *btcoexist) +static void halbtc8192e2ant_action_a2dp_pan_hs(struct btc_coexist *btcoexist) { u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH; u32 wifi_bw; @@ -3040,7 +3049,7 @@ void halbtc8192e2ant_action_a2dp_pan_hs(struct btc_coexist *btcoexist) } } -void halbtc8192e2ant_action_pan_edr(struct btc_coexist *btcoexist) +static void halbtc8192e2ant_action_pan_edr(struct btc_coexist *btcoexist) { u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH; u32 wifi_bw; @@ -3101,7 +3110,7 @@ void halbtc8192e2ant_action_pan_edr(struct btc_coexist *btcoexist) } /* PAN(HS) only */ -void halbtc8192e2ant_action_pan_hs(struct btc_coexist *btcoexist) +static void halbtc8192e2ant_action_pan_hs(struct btc_coexist *btcoexist) { u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH; u32 wifi_bw; @@ -3159,7 +3168,7 @@ void halbtc8192e2ant_action_pan_hs(struct btc_coexist *btcoexist) } /* PAN(EDR)+A2DP */ -void halbtc8192e2ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist) +static void halbtc8192e2ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist) { u8 wifirssi_state, btrssi_state=BTC_RSSI_STATE_HIGH; u32 wifi_bw; @@ -3222,7 +3231,7 @@ void halbtc8192e2ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist) } } -void halbtc8192e2ant_action_pan_edr_hid(struct btc_coexist *btcoexist) +static void halbtc8192e2ant_action_pan_edr_hid(struct btc_coexist *btcoexist) { u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH; u32 wifi_bw; @@ -3284,7 +3293,7 @@ void halbtc8192e2ant_action_pan_edr_hid(struct btc_coexist *btcoexist) } /* HID+A2DP+PAN(EDR) */ -void halbtc8192e2ant_action_hid_a2dp_pan_edr(struct btc_coexist *btcoexist) +static void halbtc8192e2ant_action_hid_a2dp_pan_edr(struct btc_coexist *btcoexist) { u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH; u32 wifi_bw; @@ -3345,7 +3354,7 @@ void halbtc8192e2ant_action_hid_a2dp_pan_edr(struct btc_coexist *btcoexist) } } -void halbtc8192e2ant_action_hid_a2dp(struct btc_coexist *btcoexist) +static void halbtc8192e2ant_action_hid_a2dp(struct btc_coexist *btcoexist) { u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH; u32 wifi_bw; @@ -3404,7 +3413,7 @@ void halbtc8192e2ant_action_hid_a2dp(struct btc_coexist *btcoexist) } } -void halbtc8192e2ant_run_coexist_mechanism(struct btc_coexist *btcoexist) +static void halbtc8192e2ant_run_coexist_mechanism(struct btc_coexist *btcoexist) { u8 algorithm = 0; @@ -3514,7 +3523,8 @@ void halbtc8192e2ant_run_coexist_mechanism(struct btc_coexist *btcoexist) } } -void halbtc8192e2ant_init_hwconfig(struct btc_coexist *btcoexist, bool backup) +static void halbtc8192e2ant_init_hwconfig(struct btc_coexist *btcoexist, + bool backup) { u16 u16tmp = 0; u8 u8tmp = 0; -- cgit v1.2.3 From 09c6e8794f70dde4e23125594cd18bb9762100a2 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sat, 19 Apr 2014 15:35:45 +0100 Subject: staging: rtl8821ae: Fix halbtc8192e2ant.c 'defined but not used' sparse warnings Sparse complains about halbtc8192e2ant_low_penalty_ra() not being used, and subsequently halbtc8192e2ant_set_sw_penalty_tx_rateadaptive() when this is removed. remove both functions. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8821ae/btcoexist/halbtc8192e2ant.c | 48 ---------------------- 1 file changed, 48 deletions(-) diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c b/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c index dae372d74b1c..964a29d3ba88 100644 --- a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c +++ b/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c @@ -943,54 +943,6 @@ static void halbtc8192e2ant_rf_shrink(struct btc_coexist *btcoexist, coex_dm->pre_rf_rx_lpf_shrink = coex_dm->cur_rf_rx_lpf_shrink; } -static void halbtc8192e2ant_set_sw_penalty_tx_rateadaptive( - struct btc_coexist *btcoexist, - bool low_penalty_ra) -{ - u8 h2c_parameter[6] ={0}; - - h2c_parameter[0] = 0x6; /* opCode, 0x6= Retry_Penalty */ - - if (low_penalty_ra) { - h2c_parameter[1] |= BIT0; - /* normal rate except MCS7/6/5, OFDM54/48/36 */ - h2c_parameter[2] = 0x00; - h2c_parameter[3] = 0xf7; /* MCS7 or OFDM54 */ - h2c_parameter[4] = 0xf8; /* MCS6 or OFDM48 */ - h2c_parameter[5] = 0xf9; /* MCS5 or OFDM36 */ - } - - BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, - "[BTCoex], set WiFi Low-Penalty Retry: %s", - (low_penalty_ra? "ON!!":"OFF!!")); - - btcoexist->btc_fill_h2c(btcoexist, 0x69, 6, h2c_parameter); -} - -static void halbtc8192e2ant_low_penalty_ra(struct btc_coexist *btcoexist, - bool force_exec, bool low_penalty_ra) -{ - BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, - "[BTCoex], %s turn LowPenaltyRA = %s\n", - (force_exec? "force to":""), ((low_penalty_ra)? "ON":"OFF")); - coex_dm->cur_low_penalty_ra = low_penalty_ra; - - if (!force_exec) { - BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, - "[BTCoex] bPreLowPenaltyRa=%d, bCurLowPenaltyRa=%d\n", - coex_dm->pre_low_penalty_ra, - coex_dm->cur_low_penalty_ra); - - if (coex_dm->pre_low_penalty_ra == - coex_dm->cur_low_penalty_ra) - return; - } - halbtc8192e2ant_set_sw_penalty_tx_rateadaptive(btcoexist, - coex_dm->cur_low_penalty_ra); - - coex_dm->pre_low_penalty_ra = coex_dm->cur_low_penalty_ra; -} - static void halbtc8192e2ant_set_dac_swingreg(struct btc_coexist *btcoexist, u32 level) { -- cgit v1.2.3 From 6149647db3eb2cadbf05825d0aa4f2f40eff7fdb Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sat, 19 Apr 2014 15:35:46 +0100 Subject: staging: rtl8821ae: Remove declaration assignment to zero We set btrssi to zero and then immediately assign it. Assign it on declaration instead. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c b/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c index 964a29d3ba88..637759eb46ba 100644 --- a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c +++ b/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c @@ -39,11 +39,9 @@ static u32 glcoex_ver_8192e_2ant = 0x34; static u8 halbtc8192e2ant_btrssi_state(u8 level_num, u8 rssi_thresh, u8 rssi_thresh1) { - int btrssi=0; + int btrssi = coex_sta->bt_rssi; u8 btrssi_state = coex_sta->pre_bt_rssi_state; - btrssi = coex_sta->bt_rssi; - if (level_num == 2) { if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) || (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW)) { -- cgit v1.2.3 From 7d753415d83bde57bbdde50349310ba4fe64a877 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sat, 19 Apr 2014 15:35:47 +0100 Subject: staging: rtl8821ae: Fix checkpatch whitespace issues Whitespace changes only to appease checkpatch warnings. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8821ae/btcoexist/halbtc8192e2ant.c | 100 ++++++++++----------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c b/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c index 637759eb46ba..9d137c007375 100644 --- a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c +++ b/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c @@ -21,7 +21,7 @@ static struct coex_dm_8192e_2ant *coex_dm = &glcoex_dm_8192e_2ant; static struct coex_sta_8192e_2ant glcoex_sta_8192e_2ant; static struct coex_sta_8192e_2ant *coex_sta = &glcoex_sta_8192e_2ant; -static const char *const GLBtInfoSrc8192e2Ant[]={ +static const char *const GLBtInfoSrc8192e2Ant[] = { "BT Info[wifi fw]", "BT Info[bt rsp]", "BT Info[bt auto report]", @@ -81,7 +81,7 @@ static u8 halbtc8192e2ant_btrssi_state(u8 level_num, u8 rssi_thresh, (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW)) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, "BT Rssi pre state=LOW\n"); - if(btrssi >= (rssi_thresh + + if (btrssi >= (rssi_thresh + BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT)) { btrssi_state = BTC_RSSI_STATE_MEDIUM; BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, @@ -131,7 +131,7 @@ static u8 halbtc8192e2ant_btrssi_state(u8 level_num, u8 rssi_thresh, return btrssi_state; } -static u8 halbtc8192e2ant_wifirssi_state(struct btc_coexist * btcoexist, +static u8 halbtc8192e2ant_wifirssi_state(struct btc_coexist *btcoexist, u8 index, u8 level_num, u8 rssi_thresh, u8 rssi_thresh1) { @@ -296,13 +296,13 @@ static u32 halbtc8192e2ant_decidera_mask(struct btc_coexist *btcoexist, disra_mask = 0xfff00000;/* disable 2ss */ break; case 1: /* disable cck 1/2 */ - if(sstype == 2) + if (sstype == 2) disra_mask = 0x00000003;/* enable 2ss */ else disra_mask = 0xfff00003;/* disable 2ss */ break; case 2: /* disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4 */ - if(sstype == 2) + if (sstype == 2) disra_mask = 0x0001f1f7;/* enable 2ss */ else disra_mask = 0xfff1f1f7;/* disable 2ss */ @@ -490,7 +490,7 @@ static void halbtc8192e2ant_monitor_bt_ctr(struct btc_coexist *btcoexist) static void halbtc8192e2ant_querybt_info(struct btc_coexist *btcoexist) { - u8 h2c_parameter[1] ={0}; + u8 h2c_parameter[1] = {0}; coex_sta->c2h_bt_info_req_sent = true; @@ -595,7 +595,7 @@ static u8 halbtc8192e2ant_action_algorithm(struct btc_coexist *btcoexist) { struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; struct btc_stack_info *stack_info = &btcoexist->stack_info; - bool bt_hson=false; + bool bt_hson = false; u8 algorithm = BT_8192E_2ANT_COEX_ALGO_UNDEFINED; u8 numOfDiffProfile = 0; @@ -781,7 +781,7 @@ static u8 halbtc8192e2ant_action_algorithm(struct btc_coexist *btcoexist) static void halbtc8192e2ant_setfw_dac_swinglevel(struct btc_coexist *btcoexist, u8 dac_swinglvl) { - u8 h2c_parameter[1] ={0}; + u8 h2c_parameter[1] = {0}; /* There are several type of dacswing * 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6 */ @@ -798,7 +798,7 @@ static void halbtc8192e2ant_setfw_dac_swinglevel(struct btc_coexist *btcoexist, static void halbtc8192e2ant_set_fwdec_btpwr(struct btc_coexist *btcoexist, u8 dec_btpwr_lvl) { - u8 h2c_parameter[1] ={0}; + u8 h2c_parameter[1] = {0}; h2c_parameter[0] = dec_btpwr_lvl; @@ -814,7 +814,7 @@ static void halbtc8192e2ant_dec_btpwr(struct btc_coexist *btcoexist, { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, "[BTCoex], %s Dec BT power level = %d\n", - (force_exec? "force to":""), dec_btpwr_lvl); + (force_exec ? "force to":""), dec_btpwr_lvl); coex_dm->cur_dec_bt_pwr = dec_btpwr_lvl; if (!force_exec) { @@ -830,7 +830,7 @@ static void halbtc8192e2ant_dec_btpwr(struct btc_coexist *btcoexist, static void halbtc8192e2ant_set_bt_autoreport(struct btc_coexist *btcoexist, bool enable_autoreport) { - u8 h2c_parameter[1] ={0}; + u8 h2c_parameter[1] = {0}; h2c_parameter[0] = 0; @@ -839,7 +839,7 @@ static void halbtc8192e2ant_set_bt_autoreport(struct btc_coexist *btcoexist, BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, "[BTCoex], BT FW auto report : %s, FW write 0x68=0x%x\n", - (enable_autoreport? "Enabled!!":"Disabled!!"), + (enable_autoreport ? "Enabled!!":"Disabled!!"), h2c_parameter[0]); btcoexist->btc_fill_h2c(btcoexist, 0x68, 1, h2c_parameter); @@ -851,8 +851,8 @@ static void halbtc8192e2ant_bt_autoreport(struct btc_coexist *btcoexist, { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, "[BTCoex], %s BT Auto report = %s\n", - (force_exec? "force to":""), - ((enable_autoreport)? "Enabled":"Disabled")); + (force_exec ? "force to":""), + ((enable_autoreport) ? "Enabled":"Disabled")); coex_dm->cur_bt_auto_report = enable_autoreport; if (!force_exec) { @@ -875,7 +875,7 @@ static void halbtc8192e2ant_fw_dac_swinglvl(struct btc_coexist *btcoexist, { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, "[BTCoex], %s set FW Dac Swing level = %d\n", - (force_exec? "force to":""), fw_dac_swinglvl); + (force_exec ? "force to":""), fw_dac_swinglvl); coex_dm->cur_fw_dac_swing_lvl = fw_dac_swinglvl; if (!force_exec) { @@ -922,7 +922,7 @@ static void halbtc8192e2ant_rf_shrink(struct btc_coexist *btcoexist, { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, "[BTCoex], %s turn Rx RF Shrink = %s\n", - (force_exec? "force to":""), ((rx_rf_shrink_on)? "ON":"OFF")); + (force_exec ? "force to":""), ((rx_rf_shrink_on) ? "ON":"OFF")); coex_dm->cur_rf_rx_lpf_shrink = rx_rf_shrink_on; if (!force_exec) { @@ -967,8 +967,8 @@ static void halbtc8192e2ant_DacSwing(struct btc_coexist *btcoexist, { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, "[BTCoex], %s turn DacSwing=%s, dac_swinglvl=0x%x\n", - (force_exec? "force to":""), - ((dac_swingon)? "ON":"OFF"), dac_swinglvl); + (force_exec ? "force to":""), + ((dac_swingon) ? "ON":"OFF"), dac_swinglvl); coex_dm->cur_dac_swing_on = dac_swingon; coex_dm->cur_dac_swing_lvl = dac_swinglvl; @@ -1025,8 +1025,8 @@ static void halbtc8192e2ant_AgcTable(struct btc_coexist *btcoexist, { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, "[BTCoex], %s %s Agc Table\n", - (force_exec? "force to":""), - ((agc_table_en)? "Enable":"Disable")); + (force_exec ? "force to":""), + ((agc_table_en) ? "Enable":"Disable")); coex_dm->cur_agc_table_en = agc_table_en; if (!force_exec) { @@ -1070,7 +1070,7 @@ static void halbtc8192e2ant_coex_table(struct btc_coexist *btcoexist, { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, "[BTCoex], %s write Coex Table 0x6c0=0x%x, ", - (force_exec? "force to":""), val0x6c0); + (force_exec ? "force to":""), val0x6c0); BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, "0x6c4=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n", val0x6c4, val0x6c8, val0x6cc); @@ -1140,7 +1140,7 @@ static void halbtc8192e2ant_coex_table_with_type(struct btc_coexist *btcoexist, static void halbtc8192e2ant_set_fw_ignore_wlanact(struct btc_coexist *btcoexist, bool enable) { - u8 h2c_parameter[1] ={0}; + u8 h2c_parameter[1] = {0}; if (enable) h2c_parameter[0] |= BIT0; /* function enable */ @@ -1157,7 +1157,7 @@ static void halbtc8192e2ant_IgnoreWlanAct(struct btc_coexist *btcoexist, { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, "[BTCoex], %s turn Ignore WlanAct %s\n", - (force_exec? "force to":""), (enable? "ON":"OFF")); + (force_exec ? "force to":""), (enable ? "ON":"OFF")); coex_dm->cur_ignore_wlan_act = enable; if (!force_exec) { @@ -1180,7 +1180,7 @@ static void halbtc8192e2ant_IgnoreWlanAct(struct btc_coexist *btcoexist, static void halbtc8192e2ant_SetFwPstdma(struct btc_coexist *btcoexist, u8 byte1, u8 byte2, u8 byte3, u8 byte4, u8 byte5) { - u8 h2c_parameter[5] ={0}; + u8 h2c_parameter[5] = {0}; h2c_parameter[0] = byte1; h2c_parameter[1] = byte2; @@ -1229,7 +1229,7 @@ static void halbtc8192e2ant_ps_tdma(struct btc_coexist *btcoexist, BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, "[BTCoex], %s turn %s PS TDMA, type=%d\n", - (force_exec? "force to":""), (turn_on? "ON":"OFF"), type); + (force_exec ? "force to":""), (turn_on ? "ON":"OFF"), type); coex_dm->cur_ps_tdma_on = turn_on; coex_dm->cur_ps_tdma = type; @@ -1382,7 +1382,7 @@ static void halbtc8192e2ant_set_switch_sstype(struct btc_coexist *btcoexist, /* switch cck patch */ btcoexist->btc_write_1byte_bitmask(btcoexist, 0xe77, 0x4, 0x1); btcoexist->btc_write_1byte(btcoexist, 0xa07, 0x81); - mimops=BTC_MIMO_PS_STATIC; + mimops = BTC_MIMO_PS_STATIC; } else if (sstype == 2) { halbtc8192e2ant_ps_tdma(btcoexist, FORCE_EXEC, false, 0); btcoexist->btc_write_1byte(btcoexist, 0xc04, 0x33); @@ -1390,7 +1390,7 @@ static void halbtc8192e2ant_set_switch_sstype(struct btc_coexist *btcoexist, btcoexist->btc_write_4byte(btcoexist, 0x90c, 0x81121313); btcoexist->btc_write_1byte_bitmask(btcoexist, 0xe77, 0x4, 0x0); btcoexist->btc_write_1byte(btcoexist, 0xa07, 0x41); - mimops=BTC_MIMO_PS_DYNAMIC; + mimops = BTC_MIMO_PS_DYNAMIC; } /* set rx 1ss or 2ss */ btcoexist->btc_set(btcoexist, BTC_SET_ACT_SEND_MIMO_PS, &mimops); @@ -1401,7 +1401,7 @@ static void halbtc8192e2ant_switch_sstype(struct btc_coexist *btcoexist, { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], %s Switch SS Type = %d\n", - (force_exec? "force to":""), new_sstype); + (force_exec ? "force to":""), new_sstype); coex_dm->cur_sstype = new_sstype; if (!force_exec) { @@ -1720,7 +1720,7 @@ static void halbtc8192e2ant_tdma_duration_adjust(struct btc_coexist *btcoexist, up = 0; dn = 0; m = 1; - n= 3; + n = 3; result = 0; wait_cnt = 0; } else { @@ -2337,21 +2337,21 @@ static void halbtc8192e2ant_tdma_duration_adjust(struct btc_coexist *btcoexist, true, 2); coex_dm->ps_tdma_du_adj_type = 2; - } else if(coex_dm->cur_ps_tdma == 12) { + } else if (coex_dm->cur_ps_tdma == 12) { halbtc8192e2ant_ps_tdma( btcoexist, NORMAL_EXEC, true, 11); coex_dm->ps_tdma_du_adj_type = 11; - } else if(coex_dm->cur_ps_tdma == 11) { + } else if (coex_dm->cur_ps_tdma == 11) { halbtc8192e2ant_ps_tdma( btcoexist, NORMAL_EXEC, true, 10); coex_dm->ps_tdma_du_adj_type = 10; - } else if(coex_dm->cur_ps_tdma == 10) { + } else if (coex_dm->cur_ps_tdma == 10) { halbtc8192e2ant_ps_tdma( btcoexist, NORMAL_EXEC, @@ -2642,7 +2642,7 @@ static void halbtc8192e2ant_tdma_duration_adjust(struct btc_coexist *btcoexist, if (coex_dm->cur_ps_tdma != coex_dm->ps_tdma_du_adj_type) { bool scan = false, link = false, roam = false; BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, - "[BTCoex], PsTdma type dismatch!!!, " ); + "[BTCoex], PsTdma type dismatch!!!, "); BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, "curPsTdma=%d, recordPsTdma=%d\n", coex_dm->cur_ps_tdma, coex_dm->ps_tdma_du_adj_type); @@ -2651,7 +2651,7 @@ static void halbtc8192e2ant_tdma_duration_adjust(struct btc_coexist *btcoexist, btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link); btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam); - if ( !scan && !link && !roam) + if (!scan && !link && !roam) halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, coex_dm->ps_tdma_du_adj_type); @@ -2789,7 +2789,7 @@ static void halbtc8192e2ant_action_sco_pan(struct btc_coexist *btcoexist) static void halbtc8192e2ant_action_hid(struct btc_coexist *btcoexist) { - u8 wifirssi_state, btrssi_state=BTC_RSSI_STATE_HIGH; + u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH; u32 wifi_bw; wifirssi_state = halbtc8192e2ant_wifirssi_state(btcoexist, 0, 2, 15, 0); @@ -3120,7 +3120,7 @@ static void halbtc8192e2ant_action_pan_hs(struct btc_coexist *btcoexist) /* PAN(EDR)+A2DP */ static void halbtc8192e2ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist) { - u8 wifirssi_state, btrssi_state=BTC_RSSI_STATE_HIGH; + u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH; u32 wifi_bw; wifirssi_state = halbtc8192e2ant_wifirssi_state(btcoexist, 0, 2, 15, 0); @@ -3393,7 +3393,7 @@ static void halbtc8192e2ant_run_coexist_mechanism(struct btc_coexist *btcoexist) coex_dm->cur_algorithm = algorithm; BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, - "[BTCoex], Algorithm = %d \n", coex_dm->cur_algorithm); + "[BTCoex], Algorithm = %d\n", coex_dm->cur_algorithm); if (halbtc8192e2ant_is_common_action(btcoexist)) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, @@ -3571,7 +3571,7 @@ void ex_halbtc8192e2ant_init_coex_dm(struct btc_coexist *btcoexist) void ex_halbtc8192e2ant_display_coex_info(struct btc_coexist *btcoexist) { struct btc_board_info *board_info = &btcoexist->board_info; - struct btc_stack_info*stack_info = &btcoexist->stack_info; + struct btc_stack_info *stack_info = &btcoexist->stack_info; u8 *cli_buf = btcoexist->cli_buf; u8 u8tmp[4], i, bt_info_ext, ps_tdma_case = 0; u16 u16tmp[4]; @@ -3688,7 +3688,7 @@ void ex_halbtc8192e2ant_display_coex_info(struct btc_coexist *btcoexist) (bt_info_ext&BIT0) ? "Basic rate" : "EDR rate"); CL_PRINTF(cli_buf); - for (i=0; ibt_info_c2h_cnt[i]) { CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x ", @@ -3833,7 +3833,7 @@ void ex_halbtc8192e2ant_display_coex_info(struct btc_coexist *btcoexist) "0x774(lp rx[31:16]/tx[15:0])", coex_sta->low_priority_rx, coex_sta->low_priority_tx); CL_PRINTF(cli_buf); -#if(BT_AUTO_REPORT_ONLY_8192E_2ANT == 1) +#if (BT_AUTO_REPORT_ONLY_8192E_2ANT == 1) halbtc8192e2ant_monitor_bt_ctr(btcoexist); #endif btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_COEX_STATISTICS); @@ -3872,7 +3872,7 @@ void ex_halbtc8192e2ant_scan_notify(struct btc_coexist *btcoexist, u8 type) if (BTC_SCAN_START == type) BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, "[BTCoex], SCAN START notify\n"); - else if(BTC_SCAN_FINISH == type) + else if (BTC_SCAN_FINISH == type) BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, "[BTCoex], SCAN FINISH notify\n"); } @@ -3882,7 +3882,7 @@ void ex_halbtc8192e2ant_connect_notify(struct btc_coexist *btcoexist, u8 type) if (BTC_ASSOCIATE_START == type) BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, "[BTCoex], CONNECT START notify\n"); - else if(BTC_ASSOCIATE_FINISH == type) + else if (BTC_ASSOCIATE_FINISH == type) BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, "[BTCoex], CONNECT FINISH notify\n"); } @@ -3890,7 +3890,7 @@ void ex_halbtc8192e2ant_connect_notify(struct btc_coexist *btcoexist, u8 type) void ex_halbtc8192e2ant_media_status_notify(struct btc_coexist *btcoexist, u8 type) { - u8 h2c_parameter[3] ={0}; + u8 h2c_parameter[3] = {0}; u32 wifi_bw; u8 wifi_center_chnl; @@ -3941,7 +3941,7 @@ void ex_halbtc8192e2ant_special_packet_notify(struct btc_coexist *btcoexist, } void ex_halbtc8192e2ant_bt_info_notify(struct btc_coexist *btcoexist, - u8 *tmp_buf, u8 length ) + u8 *tmp_buf, u8 length) { u8 bt_info = 0; u8 i, rspSource = 0; @@ -4011,7 +4011,7 @@ void ex_halbtc8192e2ant_bt_info_notify(struct btc_coexist *btcoexist, * do nothing here. */ } -#if(BT_AUTO_REPORT_ONLY_8192E_2ANT == 0) +#if (BT_AUTO_REPORT_ONLY_8192E_2ANT == 0) if ((coex_sta->bt_info_ext & BIT4)) { /* BT auto report already enabled, do nothing */ } else { @@ -4022,7 +4022,7 @@ void ex_halbtc8192e2ant_bt_info_notify(struct btc_coexist *btcoexist, } /* check BIT2 first ==> check if bt is under inquiry or page scan */ - if(bt_info & BT_INFO_8192E_2ANT_B_INQ_PAGE) + if (bt_info & BT_INFO_8192E_2ANT_B_INQ_PAGE) coex_sta->c2h_bt_inquiry_page = true; else coex_sta->c2h_bt_inquiry_page = false; @@ -4103,7 +4103,7 @@ void ex_halbtc8192e2ant_stack_operation_notify(struct btc_coexist *btcoexist, if (BTC_STACK_OP_INQ_PAGE_PAIR_START == type) BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, "[BTCoex] StackOP Inquiry/page/pair start notify\n"); - else if(BTC_STACK_OP_INQ_PAGE_PAIR_FINISH == type) + else if (BTC_STACK_OP_INQ_PAGE_PAIR_FINISH == type) BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, "[BTCoex] StackOP Inquiry/page/pair finish notify\n"); } @@ -4120,8 +4120,8 @@ void ex_halbtc8192e2ant_periodical(struct btc_coexist *btcoexist) { static u8 dis_ver_info_cnt = 0; u32 fw_ver = 0, bt_patch_ver = 0; - struct btc_board_info *board_info=&btcoexist->board_info; - struct btc_stack_info *stack_info=&btcoexist->stack_info; + struct btc_board_info *board_info = &btcoexist->board_info; + struct btc_stack_info *stack_info = &btcoexist->stack_info; BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "=======================Periodical=======================\n"); @@ -4148,7 +4148,7 @@ void ex_halbtc8192e2ant_periodical(struct btc_coexist *btcoexist) "************************************************\n"); } -#if(BT_AUTO_REPORT_ONLY_8192E_2ANT == 0) +#if (BT_AUTO_REPORT_ONLY_8192E_2ANT == 0) halbtc8192e2ant_querybt_info(btcoexist); halbtc8192e2ant_monitor_bt_ctr(btcoexist); halbtc8192e2ant_monitor_bt_enable_disable(btcoexist); -- cgit v1.2.3 From a668d5d575e9ff7b04af3ce0610b822ac19b932f Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sat, 19 Apr 2014 15:35:48 +0100 Subject: staging: rtl8821ae: halbtc8192e2ant.c fix checkpatch leading spaces/tabs issues Fix checkpatch issues relating to using leading spaces instead of tabs. Whitespace changes only. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8821ae/btcoexist/halbtc8192e2ant.c | 42 +++++++++++----------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c b/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c index 9d137c007375..db4869213005 100644 --- a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c +++ b/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c @@ -156,8 +156,8 @@ static u8 halbtc8192e2ant_wifirssi_state(struct btc_coexist *btcoexist, BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, "wifi RSSI state stay at Low\n"); - } - } else { + } + } else { if (wifirssi < rssi_thresh) { wifirssi_state = BTC_RSSI_STATE_LOW; BTC_PRINT(BTC_MSG_ALGORITHM, @@ -1011,7 +1011,7 @@ static void halbtc8192e2ant_set_agc_table(struct btc_coexist *btcoexist, } else { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, "[BTCoex], BB Agc Table Off!\n"); - btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xaa1A0001); + btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xaa1A0001); btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa91B0001); btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa81C0001); btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa71D0001); @@ -1087,7 +1087,7 @@ static void halbtc8192e2ant_coex_table(struct btc_coexist *btcoexist, "preVal0x6c8=0x%x, preVal0x6cc=0x%x !!\n", coex_dm->pre_val0x6c8, coex_dm->pre_val0x6cc); BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, - "[BTCoex], curVal0x6c0=0x%x, curVal0x6c4=0x%x, \n", + "[BTCoex], curVal0x6c0=0x%x, curVal0x6c4=0x%x,\n", coex_dm->cur_val0x6c0, coex_dm->cur_val0x6c4); BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, "curVal0x6c8=0x%x, curVal0x6cc=0x%x !!\n", @@ -1507,7 +1507,7 @@ static bool halbtc8192e2ant_is_common_action(struct btc_coexist *btcoexist) halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, 6); halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0); - halbtc8192e2ant_sw_mechanism1(btcoexist, false, false, false, + halbtc8192e2ant_sw_mechanism1(btcoexist, false, false, false, false); halbtc8192e2ant_sw_mechanism2(btcoexist, false, false, false, 0x18); @@ -2037,7 +2037,7 @@ static void halbtc8192e2ant_tdma_duration_adjust(struct btc_coexist *btcoexist, 12; } } else if (result == 1) { - if (coex_dm->cur_ps_tdma == 4) { + if (coex_dm->cur_ps_tdma == 4) { halbtc8192e2ant_ps_tdma( btcoexist, NORMAL_EXEC, @@ -2827,7 +2827,7 @@ static void halbtc8192e2ant_action_hid(struct btc_coexist *btcoexist) halbtc8192e2ant_sw_mechanism2(btcoexist, true, false, false, 0x18); } else { - halbtc8192e2ant_sw_mechanism1(btcoexist, true, true, + halbtc8192e2ant_sw_mechanism1(btcoexist, true, true, false, false); halbtc8192e2ant_sw_mechanism2(btcoexist, false, false, false, 0x18); @@ -2839,8 +2839,8 @@ static void halbtc8192e2ant_action_hid(struct btc_coexist *btcoexist) false, false); halbtc8192e2ant_sw_mechanism2(btcoexist, true, false, false, 0x18); - } else { - halbtc8192e2ant_sw_mechanism1(btcoexist, false, true, + } else { + halbtc8192e2ant_sw_mechanism1(btcoexist, false, true, false, false); halbtc8192e2ant_sw_mechanism2(btcoexist, false, false, false, 0x18); @@ -2912,7 +2912,7 @@ static void halbtc8192e2ant_action_a2dp(struct btc_coexist *btcoexist) if (BTC_WIFI_BW_HT40 == wifi_bw) { if ((wifirssi_state == BTC_RSSI_STATE_HIGH) || (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) { - halbtc8192e2ant_sw_mechanism1(btcoexist, true, false, + halbtc8192e2ant_sw_mechanism1(btcoexist, true, false, false, false); halbtc8192e2ant_sw_mechanism2(btcoexist, true, false, false, 0x18); @@ -2973,7 +2973,7 @@ static void halbtc8192e2ant_action_a2dp_pan_hs(struct btc_coexist *btcoexist) if (BTC_WIFI_BW_HT40 == wifi_bw) { if ((wifirssi_state == BTC_RSSI_STATE_HIGH) || (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) { - halbtc8192e2ant_sw_mechanism1(btcoexist, true, false, + halbtc8192e2ant_sw_mechanism1(btcoexist, true, false, false, false); halbtc8192e2ant_sw_mechanism2(btcoexist, true, false, true, 0x6); @@ -3201,15 +3201,15 @@ static void halbtc8192e2ant_action_pan_edr_hid(struct btc_coexist *btcoexist) if ((btrssi_state == BTC_RSSI_STATE_LOW) || (btrssi_state == BTC_RSSI_STATE_STAY_LOW)) { halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0); - halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14); + halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14); } else if ((btrssi_state == BTC_RSSI_STATE_MEDIUM) || (btrssi_state == BTC_RSSI_STATE_STAY_MEDIUM)) { halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 2); - halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 10); + halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 10); } else if ((btrssi_state == BTC_RSSI_STATE_HIGH) || (btrssi_state == BTC_RSSI_STATE_STAY_HIGH)) { halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 4); - halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 10); + halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 10); } /* sw mechanism */ @@ -3324,7 +3324,7 @@ static void halbtc8192e2ant_action_hid_a2dp(struct btc_coexist *btcoexist) halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0); halbtc8192e2ant_tdma_duration_adjust(btcoexist, true, true, 2); } else if ((btrssi_state == BTC_RSSI_STATE_MEDIUM) || - (btrssi_state == BTC_RSSI_STATE_STAY_MEDIUM)) { + (btrssi_state == BTC_RSSI_STATE_STAY_MEDIUM)) { halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 2); halbtc8192e2ant_tdma_duration_adjust(btcoexist, true, false, 2); } else if ((btrssi_state == BTC_RSSI_STATE_HIGH) || @@ -3657,9 +3657,9 @@ void ex_halbtc8192e2ant_display_coex_info(struct btc_coexist *btcoexist) CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %s/ %s ", "Wifi status", (wifi_under_5g ? "5G" : "2.4G"), ((BTC_WIFI_BW_LEGACY == wifi_bw) ? "Legacy" : - (((BTC_WIFI_BW_HT40 == wifi_bw) ? "HT40" : "HT20"))), + (((BTC_WIFI_BW_HT40 == wifi_bw) ? "HT40" : "HT20"))), ((!wifi_busy) ? "idle" : - ((BTC_WIFI_TRAFFIC_TX == wifi_traffic_dir) ? + ((BTC_WIFI_TRAFFIC_TX == wifi_traffic_dir) ? "uplink" : "downlink"))); CL_PRINTF(cli_buf); @@ -3936,9 +3936,9 @@ void ex_halbtc8192e2ant_special_packet_notify(struct btc_coexist *btcoexist, u8 type) { if (type == BTC_PACKET_DHCP) - BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, "[BTCoex], DHCP Packet notify\n"); - } +} void ex_halbtc8192e2ant_bt_info_notify(struct btc_coexist *btcoexist, u8 *tmp_buf, u8 length) @@ -4102,10 +4102,10 @@ void ex_halbtc8192e2ant_stack_operation_notify(struct btc_coexist *btcoexist, { if (BTC_STACK_OP_INQ_PAGE_PAIR_START == type) BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, - "[BTCoex] StackOP Inquiry/page/pair start notify\n"); + "[BTCoex] StackOP Inquiry/page/pair start notify\n"); else if (BTC_STACK_OP_INQ_PAGE_PAIR_FINISH == type) BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, - "[BTCoex] StackOP Inquiry/page/pair finish notify\n"); + "[BTCoex] StackOP Inquiry/page/pair finish notify\n"); } void ex_halbtc8192e2ant_halt_notify(struct btc_coexist *btcoexist) -- cgit v1.2.3 From 7801e8d67fcaa562c4396b14133862cae1ce1186 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sat, 19 Apr 2014 15:35:49 +0100 Subject: staging: rtl8821ae: Fix indetentation of switch case statements Fixes checkpatch error: ERROR: switch and case should be at the same indent + switch (coex_dm->cur_retrylimit_type) { + case 0: /* normal mode */ [...] + case 1: /* retry limit=8 */ [...] + default: Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8821ae/btcoexist/halbtc8192e2ant.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c b/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c index db4869213005..244b3c6255d2 100644 --- a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c +++ b/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c @@ -372,16 +372,16 @@ static void halbtc8192e2ant_retrylimit(struct btc_coexist *btcoexist, if (force_exec || (coex_dm->pre_retrylimit_type != coex_dm->cur_retrylimit_type)) { switch (coex_dm->cur_retrylimit_type) { - case 0: /* normal mode */ - btcoexist->btc_write_2byte(btcoexist, 0x42a, - coex_dm->backup_retrylimit); - break; - case 1: /* retry limit=8 */ - btcoexist->btc_write_2byte(btcoexist, 0x42a, - 0x0808); - break; - default: - break; + case 0: /* normal mode */ + btcoexist->btc_write_2byte(btcoexist, 0x42a, + coex_dm->backup_retrylimit); + break; + case 1: /* retry limit=8 */ + btcoexist->btc_write_2byte(btcoexist, 0x42a, + 0x0808); + break; + default: + break; } } -- cgit v1.2.3 From 5332a5e0fa5e903e931b8567afb2e890c56a892a Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Sat, 19 Apr 2014 15:35:50 +0100 Subject: staging: rtl8821ae: don't initialise statics to 0 or NULL in halbtc8192e2ant.c Fixes all checkpatch errors reporting that statics shouldn't be initialised to their defualt values. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c b/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c index 244b3c6255d2..81706f4087f0 100644 --- a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c +++ b/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c @@ -236,8 +236,8 @@ static u8 halbtc8192e2ant_wifirssi_state(struct btc_coexist *btcoexist, static void halbtc8192e2ant_monitor_bt_enable_disable(struct btc_coexist *btcoexist) { - static bool pre_bt_disabled = false; - static u32 bt_disable_cnt = 0; + static bool pre_bt_disabled; + static u32 bt_disable_cnt; bool bt_active = true, bt_disabled = false; /* This function check if bt is disabled */ @@ -505,8 +505,8 @@ static void halbtc8192e2ant_querybt_info(struct btc_coexist *btcoexist) static bool halbtc8192e2ant_iswifi_status_changed(struct btc_coexist *btcoexist) { - static bool pre_wifi_busy = false; - static bool pre_under_4way = false, pre_bt_hson = false; + static bool pre_wifi_busy; + static bool pre_under_4way, pre_bt_hson; bool wifi_busy = false, under_4way = false, bt_hson = false; bool wifi_connected = false; @@ -4118,7 +4118,7 @@ void ex_halbtc8192e2ant_halt_notify(struct btc_coexist *btcoexist) void ex_halbtc8192e2ant_periodical(struct btc_coexist *btcoexist) { - static u8 dis_ver_info_cnt = 0; + static u8 dis_ver_info_cnt; u32 fw_ver = 0, bt_patch_ver = 0; struct btc_board_info *board_info = &btcoexist->board_info; struct btc_stack_info *stack_info = &btcoexist->stack_info; -- cgit v1.2.3 From 948315ab87599208efcc44e416d4a0739a3fd97f Mon Sep 17 00:00:00 2001 From: Konrad Zapalowicz Date: Sat, 19 Apr 2014 18:21:27 +0200 Subject: staging: rtl8188eu: fix spaces instead of tabs for rtw_p2p.c This commit fixes the following checkpatch errors: rtl8188eu/core/rtw_p2p.c - 1508: ERROR: code indent should use tabs where possible - 1509: ERROR: code indent should use tabs where possible - 1510: ERROR: code indent should use tabs where possible Signed-off-by: Konrad Zapalowicz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_p2p.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_p2p.c b/drivers/staging/rtl8188eu/core/rtw_p2p.c index 9425c4991ccd..0a15f8cf0d36 100644 --- a/drivers/staging/rtl8188eu/core/rtw_p2p.c +++ b/drivers/staging/rtl8188eu/core/rtw_p2p.c @@ -1505,9 +1505,9 @@ static void find_phase_handler(struct adapter *padapter) rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH); - spin_lock_bh(&pmlmepriv->lock); - rtw_sitesurvey_cmd(padapter, &ssid, 1, NULL, 0); - spin_unlock_bh(&pmlmepriv->lock); + spin_lock_bh(&pmlmepriv->lock); + rtw_sitesurvey_cmd(padapter, &ssid, 1, NULL, 0); + spin_unlock_bh(&pmlmepriv->lock); } void p2p_concurrent_handler(struct adapter *padapter); -- cgit v1.2.3 From 79bbb1b8a176f8e823e889f9f5653ea4e03f5791 Mon Sep 17 00:00:00 2001 From: Konrad Zapalowicz Date: Sat, 19 Apr 2014 18:21:28 +0200 Subject: staging: rtl8188eu: fix spaces instead of tabs for rtw_recv.c This commit fixes the following checkpatch errors: rtl8188eu/core/rtw_recv.c - 1874: ERROR: code indent should use tabs where possible Signed-off-by: Konrad Zapalowicz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_recv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index e305d43ebd06..5c1d2d28eb9d 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -1871,7 +1871,7 @@ static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reor return true; prhdr = container_of(plist, struct recv_frame, list); - pattrib = &prhdr->attrib; + pattrib = &prhdr->attrib; preorder_ctrl->indicate_seq = pattrib->seq_num; } -- cgit v1.2.3 From 07c7c7d28b28321329a80f3d5d3ca4be84598161 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 20 Apr 2014 14:17:09 +0530 Subject: staging: rtl8188eu: Remove empty header file drv_types_linux.h is empty, so remove the header file and its reference. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/drv_types.h | 1 - .../staging/rtl8188eu/include/drv_types_linux.h | 24 ---------------------- 2 files changed, 25 deletions(-) delete mode 100644 drivers/staging/rtl8188eu/include/drv_types_linux.h diff --git a/drivers/staging/rtl8188eu/include/drv_types.h b/drivers/staging/rtl8188eu/include/drv_types.h index 936c196699af..10cc1a1bcab9 100644 --- a/drivers/staging/rtl8188eu/include/drv_types.h +++ b/drivers/staging/rtl8188eu/include/drv_types.h @@ -31,7 +31,6 @@ #include #include -#include #include #include #include diff --git a/drivers/staging/rtl8188eu/include/drv_types_linux.h b/drivers/staging/rtl8188eu/include/drv_types_linux.h deleted file mode 100644 index 812b7440d4b0..000000000000 --- a/drivers/staging/rtl8188eu/include/drv_types_linux.h +++ /dev/null @@ -1,24 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#ifndef __DRV_TYPES_LINUX_H__ -#define __DRV_TYPES_LINUX_H__ - - -#endif -- cgit v1.2.3 From 105dec7db1836e1f6f6c15fd62290176f71aa506 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 20 Apr 2014 14:17:10 +0530 Subject: staging: rtl8188eu: Remove rtw_led_blink_cmd() function. rtw_led_blink_cmd() isn't being used by driver. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_cmd.c | 35 ----------------------------- drivers/staging/rtl8188eu/include/rtw_cmd.h | 1 - 2 files changed, 36 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c index c2fb050337d5..1e0b8b49fc12 100644 --- a/drivers/staging/rtl8188eu/core/rtw_cmd.c +++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c @@ -1431,41 +1431,6 @@ exit: return res; } -u8 rtw_led_blink_cmd(struct adapter *padapter, struct LED_871x *pLed) -{ - struct cmd_obj *pcmdobj; - struct LedBlink_param *ledBlink_param; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - - u8 res = _SUCCESS; - - - RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_led_blink_cmd\n")); - - pcmdobj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (pcmdobj == NULL) { - res = _FAIL; - goto exit; - } - - ledBlink_param = (struct LedBlink_param *)rtw_zmalloc(sizeof(struct LedBlink_param)); - if (ledBlink_param == NULL) { - kfree(pcmdobj); - res = _FAIL; - goto exit; - } - - ledBlink_param->pLed = pLed; - - init_h2fwcmd_w_parm_no_rsp(pcmdobj, ledBlink_param, GEN_CMD_CODE(_LedBlink)); - res = rtw_enqueue_cmd(pcmdpriv, pcmdobj); - -exit: - - - return res; -} - u8 rtw_set_csa_cmd(struct adapter *padapter, u8 new_ch_no) { struct cmd_obj *pcmdobj; diff --git a/drivers/staging/rtl8188eu/include/rtw_cmd.h b/drivers/staging/rtl8188eu/include/rtw_cmd.h index 3d347029ff7a..66467f711a59 100644 --- a/drivers/staging/rtl8188eu/include/rtw_cmd.h +++ b/drivers/staging/rtl8188eu/include/rtw_cmd.h @@ -807,7 +807,6 @@ u8 rtw_chk_hi_queue_cmd(struct adapter *padapter); u8 rtw_set_ch_cmd(struct adapter *padapter, u8 ch, u8 bw, u8 ch_offset, u8 enqueue); u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue); -u8 rtw_led_blink_cmd(struct adapter *padapter, struct LED_871x *pLed); u8 rtw_set_csa_cmd(struct adapter *padapter, u8 new_ch_no); u8 rtw_tdls_cmd(struct adapter *padapter, u8 *addr, u8 option); -- cgit v1.2.3 From 74391e12be734ebcc6fc601fe1f68c208d9d6c14 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 20 Apr 2014 14:17:11 +0530 Subject: staging: rtl8188eu: Remove _ReadLEDSetting() function. _ReadLEDSetting() doesn't read led settings this function actually initialize member variables of struct led_priv, we should do that inside rtl8188eu_InitSwLeds(). Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188eu_led.c | 4 ++++ drivers/staging/rtl8188eu/hal/usb_halinit.c | 12 ------------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c index 08dfd94163e6..01eeb7080717 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c @@ -92,8 +92,12 @@ exit: void rtl8188eu_InitSwLeds(struct adapter *padapter) { struct led_priv *pledpriv = &(padapter->ledpriv); + struct hal_data_8188e *haldata = GET_HAL_DATA(padapter); + pledpriv->bRegUseLed = true; + pledpriv->LedStrategy = SW_LED_MODE1; pledpriv->LedControlHandler = LedControl8188eu; + haldata->bLedOpenDrain = true; InitLed871x(padapter, &(pledpriv->SwLed0), LED_PIN_LED0); diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index c92067f0ef15..0dfd62b6378a 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -1129,16 +1129,6 @@ static unsigned int rtl8188eu_inirp_deinit(struct adapter *Adapter) /* EEPROM/EFUSE Content Parsing */ /* */ /* */ -static void _ReadLEDSetting(struct adapter *Adapter, u8 *PROMContent, bool AutoloadFail) -{ - struct led_priv *pledpriv = &(Adapter->ledpriv); - struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); - - pledpriv->bRegUseLed = true; - pledpriv->LedStrategy = SW_LED_MODE1; - haldata->bLedOpenDrain = true;/* Support Open-drain arrangement for controlling the LED. */ -} - static void Hal_EfuseParsePIDVID_8188EU(struct adapter *adapt, u8 *hwinfo, bool AutoLoadFail) { struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); @@ -1215,8 +1205,6 @@ readAdapterInfo_8188EU( /* */ Hal_InitChannelPlan(adapt); Hal_CustomizeByCustomerID_8188EU(adapt); - - _ReadLEDSetting(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); } static void _ReadPROMContent( -- cgit v1.2.3 From 59eb69768a0e882e49c551bf8912be34fd129285 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 20 Apr 2014 14:17:12 +0530 Subject: staging: rtl8188eu: Remove _InitHWLed() function. _InitHWLed() function does nothing. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/usb_halinit.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index 0dfd62b6378a..617e4c68dfa1 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -424,18 +424,6 @@ static void _InitBeaconMaxError(struct adapter *Adapter, bool InfraMode) { } -static void _InitHWLed(struct adapter *Adapter) -{ - struct led_priv *pledpriv = &(Adapter->ledpriv); - - if (pledpriv->LedStrategy != HW_LED) - return; - -/* HW led control */ -/* to do .... */ -/* must consider cases of antenna diversity/ commbo card/solo card/mini card */ -} - static void _InitRDGSetting(struct adapter *Adapter) { rtw_write8(Adapter, REG_RD_CTRL, 0xFF); @@ -870,8 +858,6 @@ static u32 rtl8188eu_hal_init(struct adapter *Adapter) rtw_write16(Adapter, REG_PKT_VO_VI_LIFE_TIME, 0x0400); /* unit: 256us. 256ms */ rtw_write16(Adapter, REG_PKT_BE_BK_LIFE_TIME, 0x0400); /* unit: 256us. 256ms */ - _InitHWLed(Adapter); - /* Keep RfRegChnlVal for later use. */ haldata->RfRegChnlVal[0] = PHY_QueryRFReg(Adapter, (enum rf_radio_path)0, RF_CHNLBW, bRFRegOffsetMask); haldata->RfRegChnlVal[1] = PHY_QueryRFReg(Adapter, (enum rf_radio_path)1, RF_CHNLBW, bRFRegOffsetMask); -- cgit v1.2.3 From 87e28d690d4af55b80517cbd8a7571391be4d98f Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 20 Apr 2014 14:17:13 +0530 Subject: staging: rtl8188eu: Simplify led blinking strategy code. driver has code to blink the led in 7 different ways. struct led_priv contains an enum LED_STRATEGY_871x variable which is initialized to SW_LED_MODE1 inside rtl8188eu_InitSwLeds() function. it means driver is hard coded to use only SW_LED_MODE1 blinking strategy. so we can remove the code related to other blinking strategies e.g. SW_LED_MODE[0|2|3|4|5|6]. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_led.c | 1412 +++--------------------------- 1 file changed, 101 insertions(+), 1311 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_led.c b/drivers/staging/rtl8188eu/core/rtw_led.c index 42b41ab1bce1..c42e17647b90 100644 --- a/drivers/staging/rtl8188eu/core/rtw_led.c +++ b/drivers/staging/rtl8188eu/core/rtw_led.c @@ -40,7 +40,6 @@ void BlinkTimerCallback(void *data) /* */ /* Description: */ /* Callback function of LED BlinkWorkItem. */ -/* We dispatch acture LED blink action according to LedStrategy. */ /* */ void BlinkWorkItemCallback(struct work_struct *work) { @@ -101,87 +100,6 @@ void DeInitLed871x(struct LED_871x *pLed) /* It toggle off LED and schedule corresponding timer if necessary. */ /* */ -static void SwLedBlink(struct LED_871x *pLed) -{ - struct adapter *padapter = pLed->padapter; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - u8 bStopBlinking = false; - - /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) { - SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } else { - SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); - } - - /* Determine if we shall change LED state again. */ - pLed->BlinkTimes--; - switch (pLed->CurrLedState) { - case LED_BLINK_NORMAL: - if (pLed->BlinkTimes == 0) - bStopBlinking = true; - break; - case LED_BLINK_StartToBlink: - if (check_fwstate(pmlmepriv, _FW_LINKED) && check_fwstate(pmlmepriv, WIFI_STATION_STATE)) - bStopBlinking = true; - if (check_fwstate(pmlmepriv, _FW_LINKED) && - (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || - check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))) - bStopBlinking = true; - else if (pLed->BlinkTimes == 0) - bStopBlinking = true; - break; - case LED_BLINK_WPS: - if (pLed->BlinkTimes == 0) - bStopBlinking = true; - break; - default: - bStopBlinking = true; - break; - } - - if (bStopBlinking) { - /* if (padapter->pwrctrlpriv.cpwm >= PS_STATE_S2) */ - if (0) { - SwLedOff(padapter, pLed); - } else if ((check_fwstate(pmlmepriv, _FW_LINKED)) && (!pLed->bLedOn)) { - SwLedOn(padapter, pLed); - } else if ((check_fwstate(pmlmepriv, _FW_LINKED)) && pLed->bLedOn) { - SwLedOff(padapter, pLed); - } - pLed->BlinkTimes = 0; - pLed->bLedBlinkInProgress = false; - } else { - /* Assign LED state to toggle. */ - if (pLed->BlinkingLedState == RTW_LED_ON) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - - /* Schedule a timer to toggle LED state. */ - switch (pLed->CurrLedState) { - case LED_BLINK_NORMAL: - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); - break; - case LED_BLINK_SLOWLY: - case LED_BLINK_StartToBlink: - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); - break; - case LED_BLINK_WPS: - if (pLed->BlinkingLedState == RTW_LED_ON) - _set_timer(&(pLed->BlinkTimer), LED_BLINK_LONG_INTERVAL); - else - _set_timer(&(pLed->BlinkTimer), LED_BLINK_LONG_INTERVAL); - break; - default: - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); - break; - } - } -} - static void SwLedBlink1(struct LED_871x *pLed) { struct adapter *padapter = pLed->padapter; @@ -277,1051 +195,115 @@ static void SwLedBlink1(struct LED_871x *pLed) } pLed->BlinkTimes = 0; pLed->bLedBlinkInProgress = false; - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); - } - break; - case LED_BLINK_WPS: - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); - break; - case LED_BLINK_WPS_STOP: /* WPS success */ - if (pLed->BlinkingLedState == RTW_LED_ON) - bStopBlinking = false; - else - bStopBlinking = true; - - if (bStopBlinking) { - pLed->bLedLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_NORMAL; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - - pLed->bLedWPSBlinkInProgress = false; - } else { - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); - } - break; - default: - break; - } -} - -static void SwLedBlink2(struct LED_871x *pLed) -{ - struct adapter *padapter = pLed->padapter; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - u8 bStopBlinking = false; - - /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) { - SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } else { - SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); - } - - switch (pLed->CurrLedState) { - case LED_BLINK_SCAN: - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) - bStopBlinking = true; - if (bStopBlinking) { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff(padapter, pLed); - } else if (check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop scan blink CurrLedState %d\n", pLed->CurrLedState)); - - } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop scan blink CurrLedState %d\n", pLed->CurrLedState)); - } - pLed->bLedScanBlinkInProgress = false; - } else { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff(padapter, pLed); - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); - } - } - break; - case LED_BLINK_TXRX: - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) - bStopBlinking = true; - if (bStopBlinking) { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff(padapter, pLed); - } else if (check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop CurrLedState %d\n", pLed->CurrLedState)); - } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop CurrLedState %d\n", pLed->CurrLedState)); - } - pLed->bLedBlinkInProgress = false; - } else { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff(padapter, pLed); - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); - } - } - break; - default: - break; - } -} - -static void SwLedBlink3(struct LED_871x *pLed) -{ - struct adapter *padapter = pLed->padapter; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - u8 bStopBlinking = false; - - /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) { - SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } else { - if (pLed->CurrLedState != LED_BLINK_WPS_STOP) - SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); - } - - switch (pLed->CurrLedState) { - case LED_BLINK_SCAN: - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) - bStopBlinking = true; - if (bStopBlinking) { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff(padapter, pLed); - } else if (check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - if (!pLed->bLedOn) - SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - if (pLed->bLedOn) - SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } - pLed->bLedScanBlinkInProgress = false; - } else { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff(padapter, pLed); - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); - } - } - break; - case LED_BLINK_TXRX: - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) - bStopBlinking = true; - if (bStopBlinking) { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff(padapter, pLed); - } else if (check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - if (!pLed->bLedOn) - SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - - if (pLed->bLedOn) - SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } - pLed->bLedBlinkInProgress = false; - } else { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff(padapter, pLed); - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); - } - } - break; - case LED_BLINK_WPS: - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); - break; - case LED_BLINK_WPS_STOP: /* WPS success */ - if (pLed->BlinkingLedState == RTW_LED_ON) { - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); - bStopBlinking = false; - } else { - bStopBlinking = true; - } - if (bStopBlinking) { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff(padapter, pLed); - } else { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } - pLed->bLedWPSBlinkInProgress = false; - } - break; - default: - break; - } -} - -static void SwLedBlink4(struct LED_871x *pLed) -{ - struct adapter *padapter = pLed->padapter; - struct led_priv *ledpriv = &(padapter->ledpriv); - struct LED_871x *pLed1 = &(ledpriv->SwLed1); - u8 bStopBlinking = false; - - /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) { - SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } else { - SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); - } - - if (!pLed1->bLedWPSBlinkInProgress && pLed1->BlinkingLedState == LED_UNKNOWN) { - pLed1->BlinkingLedState = RTW_LED_OFF; - pLed1->CurrLedState = RTW_LED_OFF; - SwLedOff(padapter, pLed1); - } - - switch (pLed->CurrLedState) { - case LED_BLINK_SLOWLY: - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); - break; - case LED_BLINK_StartToBlink: - if (pLed->bLedOn) { - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); - } else { - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); - } - break; - case LED_BLINK_SCAN: - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) - bStopBlinking = false; - if (bStopBlinking) { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { - SwLedOff(padapter, pLed); - } else { - pLed->bLedNoLinkBlinkInProgress = false; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); - } - pLed->bLedScanBlinkInProgress = false; - } else { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { - SwLedOff(padapter, pLed); - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); - } - } - break; - case LED_BLINK_TXRX: - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) - bStopBlinking = true; - if (bStopBlinking) { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { - SwLedOff(padapter, pLed); - } else { - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); - } - pLed->bLedBlinkInProgress = false; - } else { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { - SwLedOff(padapter, pLed); - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); - } - } - break; - case LED_BLINK_WPS: - if (pLed->bLedOn) { - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); - } else { - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); - } - break; - case LED_BLINK_WPS_STOP: /* WPS authentication fail */ - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); - break; - case LED_BLINK_WPS_STOP_OVERLAP: /* WPS session overlap */ - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) { - if (pLed->bLedOn) - pLed->BlinkTimes = 1; - else - bStopBlinking = true; - } - - if (bStopBlinking) { - pLed->BlinkTimes = 10; - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); - } - break; - default: - break; - } - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("SwLedBlink4 CurrLedState %d\n", pLed->CurrLedState)); -} - -static void SwLedBlink5(struct LED_871x *pLed) -{ - struct adapter *padapter = pLed->padapter; - u8 bStopBlinking = false; - - /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) { - SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } else { - SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); - } - - switch (pLed->CurrLedState) { - case LED_BLINK_SCAN: - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) - bStopBlinking = true; - - if (bStopBlinking) { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - if (pLed->bLedOn) - SwLedOff(padapter, pLed); - } else { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - if (!pLed->bLedOn) - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); - } - - pLed->bLedScanBlinkInProgress = false; - } else { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { - SwLedOff(padapter, pLed); - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); - } - } - break; - case LED_BLINK_TXRX: - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) - bStopBlinking = true; - - if (bStopBlinking) { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - if (pLed->bLedOn) - SwLedOff(padapter, pLed); - } else { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - if (!pLed->bLedOn) - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); - } - - pLed->bLedBlinkInProgress = false; - } else { - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { - SwLedOff(padapter, pLed); - } else { - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); - } - } - break; - - default: - break; - } - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("SwLedBlink5 CurrLedState %d\n", pLed->CurrLedState)); -} - -static void SwLedBlink6(struct LED_871x *pLed) -{ - struct adapter *padapter = pLed->padapter; - - /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) { - SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } else { - SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); - } - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("<==== blink6\n")); -} - - /* ALPHA, added by chiyoko, 20090106 */ -static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAction) -{ - struct led_priv *ledpriv = &(padapter->ledpriv); - struct LED_871x *pLed = &(ledpriv->SwLed0); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - - switch (LedAction) { - case LED_CTL_POWER_ON: - case LED_CTL_START_TO_LINK: - case LED_CTL_NO_LINK: - if (!pLed->bLedNoLinkBlinkInProgress) { - if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) - return; - if (pLed->bLedLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); - } - break; - case LED_CTL_LINK: - if (!pLed->bLedLinkBlinkInProgress) { - if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) - return; - if (pLed->bLedNoLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - pLed->bLedLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_NORMAL; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); - } - break; - case LED_CTL_SITE_SURVEY: - if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && (check_fwstate(pmlmepriv, _FW_LINKED))) { - ; - } else if (!pLed->bLedScanBlinkInProgress) { - if (IS_LED_WPS_BLINKING(pLed)) - return; - if (pLed->bLedNoLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - pLed->bLedScanBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SCAN; - pLed->BlinkTimes = 24; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); - } - break; - case LED_CTL_TX: - case LED_CTL_RX: - if (!pLed->bLedBlinkInProgress) { - if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) - return; - if (pLed->bLedNoLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedLinkBlinkInProgress = false; - } - pLed->bLedBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_TXRX; - pLed->BlinkTimes = 2; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); - } - break; - case LED_CTL_START_WPS: /* wait until xinpin finish */ - case LED_CTL_START_WPS_BOTTON: - if (!pLed->bLedWPSBlinkInProgress) { - if (pLed->bLedNoLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedScanBlinkInProgress = false; - } - pLed->bLedWPSBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_WPS; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); - } - break; - case LED_CTL_STOP_WPS: - if (pLed->bLedNoLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedScanBlinkInProgress = false; - } - if (pLed->bLedWPSBlinkInProgress) - _cancel_timer_ex(&(pLed->BlinkTimer)); - else - pLed->bLedWPSBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_WPS_STOP; - if (pLed->bLedOn) { - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); - } else { - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), 0); - } - break; - case LED_CTL_STOP_WPS_FAIL: - if (pLed->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedWPSBlinkInProgress = false; - } - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); - break; - case LED_CTL_POWER_OFF: - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - if (pLed->bLedNoLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedWPSBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedScanBlinkInProgress = false; - } - SwLedOff(padapter, pLed); - break; - default: - break; - } - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Led %d\n", pLed->CurrLedState)); -} - - /* Arcadyan/Sitecom , added by chiyoko, 20090216 */ -static void SwLedControlMode2(struct adapter *padapter, enum LED_CTL_MODE LedAction) -{ - struct led_priv *ledpriv = &(padapter->ledpriv); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct LED_871x *pLed = &(ledpriv->SwLed0); - - switch (LedAction) { - case LED_CTL_SITE_SURVEY: - if (pmlmepriv->LinkDetectInfo.bBusyTraffic) { - } else if (!pLed->bLedScanBlinkInProgress) { - if (IS_LED_WPS_BLINKING(pLed)) - return; - - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - pLed->bLedScanBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SCAN; - pLed->BlinkTimes = 24; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); - } - break; - case LED_CTL_TX: - case LED_CTL_RX: - if ((!pLed->bLedBlinkInProgress) && (check_fwstate(pmlmepriv, _FW_LINKED))) { - if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) - return; - pLed->bLedBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_TXRX; - pLed->BlinkTimes = 2; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); - } - break; - case LED_CTL_LINK: - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedScanBlinkInProgress = false; - } - _set_timer(&(pLed->BlinkTimer), 0); - break; - case LED_CTL_START_WPS: /* wait until xinpin finish */ - case LED_CTL_START_WPS_BOTTON: - if (!pLed->bLedWPSBlinkInProgress) { - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedScanBlinkInProgress = false; - } - pLed->bLedWPSBlinkInProgress = true; - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), 0); - } - break; - case LED_CTL_STOP_WPS: - pLed->bLedWPSBlinkInProgress = false; - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff(padapter, pLed); - } else { - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), 0); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } - break; - case LED_CTL_STOP_WPS_FAIL: - pLed->bLedWPSBlinkInProgress = false; - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff(padapter, pLed); - } else { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), 0); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } - break; - case LED_CTL_START_TO_LINK: - case LED_CTL_NO_LINK: - if (!IS_LED_BLINKING(pLed)) { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), 0); - } - break; - case LED_CTL_POWER_OFF: - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedScanBlinkInProgress = false; - } - if (pLed->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedWPSBlinkInProgress = false; - } - - _set_timer(&(pLed->BlinkTimer), 0); - break; - default: - break; - } - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); -} - - /* COREGA, added by chiyoko, 20090316 */ - static void SwLedControlMode3(struct adapter *padapter, enum LED_CTL_MODE LedAction) -{ - struct led_priv *ledpriv = &(padapter->ledpriv); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct LED_871x *pLed = &(ledpriv->SwLed0); - - switch (LedAction) { - case LED_CTL_SITE_SURVEY: - if (pmlmepriv->LinkDetectInfo.bBusyTraffic) { - } else if (!pLed->bLedScanBlinkInProgress) { - if (IS_LED_WPS_BLINKING(pLed)) - return; - - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - pLed->bLedScanBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SCAN; - pLed->BlinkTimes = 24; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); - } - break; - case LED_CTL_TX: - case LED_CTL_RX: - if ((!pLed->bLedBlinkInProgress) && (check_fwstate(pmlmepriv, _FW_LINKED))) { - if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) - return; - pLed->bLedBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_TXRX; - pLed->BlinkTimes = 2; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); - } - break; - case LED_CTL_LINK: - if (IS_LED_WPS_BLINKING(pLed)) - return; - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedScanBlinkInProgress = false; - } - - _set_timer(&(pLed->BlinkTimer), 0); - break; - case LED_CTL_START_WPS: /* wait until xinpin finish */ - case LED_CTL_START_WPS_BOTTON: - if (!pLed->bLedWPSBlinkInProgress) { - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedScanBlinkInProgress = false; - } - pLed->bLedWPSBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_WPS; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); - } - break; - case LED_CTL_STOP_WPS: - if (pLed->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedWPSBlinkInProgress = false; - } else { - pLed->bLedWPSBlinkInProgress = true; - } - - pLed->CurrLedState = LED_BLINK_WPS_STOP; - if (pLed->bLedOn) { - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); - } else { - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), 0); - } - break; - case LED_CTL_STOP_WPS_FAIL: - if (pLed->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedWPSBlinkInProgress = false; - } - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), 0); - break; - case LED_CTL_START_TO_LINK: - case LED_CTL_NO_LINK: - if (!IS_LED_BLINKING(pLed)) { - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), 0); - } - break; - case LED_CTL_POWER_OFF: - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedScanBlinkInProgress = false; + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); } - if (pLed->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + break; + case LED_BLINK_WPS: + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + break; + case LED_BLINK_WPS_STOP: /* WPS success */ + if (pLed->BlinkingLedState == RTW_LED_ON) + bStopBlinking = false; + else + bStopBlinking = true; + + if (bStopBlinking) { + pLed->bLedLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_NORMAL; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + pLed->bLedWPSBlinkInProgress = false; + } else { + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); } - - _set_timer(&(pLed->BlinkTimer), 0); break; default: break; } - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, - ("CurrLedState %d\n", pLed->CurrLedState)); } - /* Edimax-Belkin, added by chiyoko, 20090413 */ -static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAction) + /* ALPHA, added by chiyoko, 20090106 */ +static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAction) { struct led_priv *ledpriv = &(padapter->ledpriv); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct LED_871x *pLed = &(ledpriv->SwLed0); - struct LED_871x *pLed1 = &(ledpriv->SwLed1); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); switch (LedAction) { + case LED_CTL_POWER_ON: case LED_CTL_START_TO_LINK: - if (pLed1->bLedWPSBlinkInProgress) { - pLed1->bLedWPSBlinkInProgress = false; - _cancel_timer_ex(&(pLed1->BlinkTimer)); - - pLed1->BlinkingLedState = RTW_LED_OFF; - pLed1->CurrLedState = RTW_LED_OFF; - - if (pLed1->bLedOn) - _set_timer(&(pLed->BlinkTimer), 0); - } - - if (!pLed->bLedStartToLinkBlinkInProgress) { + case LED_CTL_NO_LINK: + if (!pLed->bLedNoLinkBlinkInProgress) { if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) return; - if (pLed->bLedBlinkInProgress) { + if (pLed->bLedLinkBlinkInProgress) { _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; + pLed->bLedLinkBlinkInProgress = false; } - if (pLed->bLedNoLinkBlinkInProgress) { + if (pLed->bLedBlinkInProgress) { _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedNoLinkBlinkInProgress = false; + pLed->bLedBlinkInProgress = false; } - pLed->bLedStartToLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_StartToBlink; - if (pLed->bLedOn) { + pLed->bLedNoLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); - } else { + else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); - } + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); } break; case LED_CTL_LINK: - case LED_CTL_NO_LINK: - /* LED1 settings */ - if (LedAction == LED_CTL_LINK) { - if (pLed1->bLedWPSBlinkInProgress) { - pLed1->bLedWPSBlinkInProgress = false; - _cancel_timer_ex(&(pLed1->BlinkTimer)); - - pLed1->BlinkingLedState = RTW_LED_OFF; - pLed1->CurrLedState = RTW_LED_OFF; - - if (pLed1->bLedOn) - _set_timer(&(pLed->BlinkTimer), 0); - } - } - - if (!pLed->bLedNoLinkBlinkInProgress) { + if (!pLed->bLedLinkBlinkInProgress) { if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) return; + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } if (pLed->bLedBlinkInProgress) { _cancel_timer_ex(&(pLed->BlinkTimer)); pLed->bLedBlinkInProgress = false; } - - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; + pLed->bLedLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_NORMAL; if (pLed->bLedOn) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); } break; case LED_CTL_SITE_SURVEY: if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && (check_fwstate(pmlmepriv, _FW_LINKED))) { + ; } else if (!pLed->bLedScanBlinkInProgress) { if (IS_LED_WPS_BLINKING(pLed)) return; - if (pLed->bLedNoLinkBlinkInProgress) { _cancel_timer_ex(&(pLed->BlinkTimer)); pLed->bLedNoLinkBlinkInProgress = false; } + if (pLed->bLedLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedLinkBlinkInProgress = false; + } if (pLed->bLedBlinkInProgress) { _cancel_timer_ex(&(pLed->BlinkTimer)); pLed->bLedBlinkInProgress = false; @@ -1334,7 +316,7 @@ static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAct else pLed->BlinkingLedState = RTW_LED_ON; _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); - } + } break; case LED_CTL_TX: case LED_CTL_RX: @@ -1345,6 +327,10 @@ static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAct _cancel_timer_ex(&(pLed->BlinkTimer)); pLed->bLedNoLinkBlinkInProgress = false; } + if (pLed->bLedLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedLinkBlinkInProgress = false; + } pLed->bLedBlinkInProgress = true; pLed->CurrLedState = LED_BLINK_TXRX; pLed->BlinkTimes = 2; @@ -1357,22 +343,15 @@ static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAct break; case LED_CTL_START_WPS: /* wait until xinpin finish */ case LED_CTL_START_WPS_BOTTON: - if (pLed1->bLedWPSBlinkInProgress) { - pLed1->bLedWPSBlinkInProgress = false; - _cancel_timer_ex(&(pLed1->BlinkTimer)); - - pLed1->BlinkingLedState = RTW_LED_OFF; - pLed1->CurrLedState = RTW_LED_OFF; - - if (pLed1->bLedOn) - _set_timer(&(pLed->BlinkTimer), 0); - } - - if (!pLed->bLedWPSBlinkInProgress) { + if (!pLed->bLedWPSBlinkInProgress) { if (pLed->bLedNoLinkBlinkInProgress) { _cancel_timer_ex(&(pLed->BlinkTimer)); pLed->bLedNoLinkBlinkInProgress = false; } + if (pLed->bLedLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedLinkBlinkInProgress = false; + } if (pLed->bLedBlinkInProgress) { _cancel_timer_ex(&(pLed->BlinkTimer)); pLed->bLedBlinkInProgress = false; @@ -1383,56 +362,44 @@ static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAct } pLed->bLedWPSBlinkInProgress = true; pLed->CurrLedState = LED_BLINK_WPS; - if (pLed->bLedOn) { + if (pLed->bLedOn) pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); - } else { + else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); - } - } + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } break; - case LED_CTL_STOP_WPS: /* WPS connect success */ - if (pLed->bLedWPSBlinkInProgress) { + case LED_CTL_STOP_WPS: + if (pLed->bLedNoLinkBlinkInProgress) { _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedWPSBlinkInProgress = false; + pLed->bLedNoLinkBlinkInProgress = false; } - - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); - - break; - case LED_CTL_STOP_WPS_FAIL: /* WPS authentication fail */ - if (pLed->bLedWPSBlinkInProgress) { + if (pLed->bLedLinkBlinkInProgress) { _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedWPSBlinkInProgress = false; + pLed->bLedLinkBlinkInProgress = false; } - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + if (pLed->bLedWPSBlinkInProgress) + _cancel_timer_ex(&(pLed->BlinkTimer)); else + pLed->bLedWPSBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_WPS_STOP; + if (pLed->bLedOn) { + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); + } else { pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); - - /* LED1 settings */ - if (pLed1->bLedWPSBlinkInProgress) - _cancel_timer_ex(&(pLed1->BlinkTimer)); - else - pLed1->bLedWPSBlinkInProgress = true; - pLed1->CurrLedState = LED_BLINK_WPS_STOP; - if (pLed1->bLedOn) - pLed1->BlinkingLedState = RTW_LED_OFF; - else - pLed1->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + _set_timer(&(pLed->BlinkTimer), 0); + } break; - case LED_CTL_STOP_WPS_FAIL_OVERLAP: /* WPS session overlap */ + case LED_CTL_STOP_WPS_FAIL: if (pLed->bLedWPSBlinkInProgress) { _cancel_timer_ex(&(pLed->BlinkTimer)); pLed->bLedWPSBlinkInProgress = false; @@ -1444,24 +411,10 @@ static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAct else pLed->BlinkingLedState = RTW_LED_ON; _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); - - /* LED1 settings */ - if (pLed1->bLedWPSBlinkInProgress) - _cancel_timer_ex(&(pLed1->BlinkTimer)); - else - pLed1->bLedWPSBlinkInProgress = true; - pLed1->CurrLedState = LED_BLINK_WPS_STOP_OVERLAP; - pLed1->BlinkTimes = 10; - if (pLed1->bLedOn) - pLed1->BlinkingLedState = RTW_LED_OFF; - else - pLed1->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); break; case LED_CTL_POWER_OFF: pLed->CurrLedState = RTW_LED_OFF; pLed->BlinkingLedState = RTW_LED_OFF; - if (pLed->bLedNoLinkBlinkInProgress) { _cancel_timer_ex(&(pLed->BlinkTimer)); pLed->bLedNoLinkBlinkInProgress = false; @@ -1482,87 +435,6 @@ static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAct _cancel_timer_ex(&(pLed->BlinkTimer)); pLed->bLedScanBlinkInProgress = false; } - if (pLed->bLedStartToLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedStartToLinkBlinkInProgress = false; - } - if (pLed1->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&(pLed1->BlinkTimer)); - pLed1->bLedWPSBlinkInProgress = false; - } - pLed1->BlinkingLedState = LED_UNKNOWN; - SwLedOff(padapter, pLed); - SwLedOff(padapter, pLed1); - break; - default: - break; - } - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Led %d\n", pLed->CurrLedState)); -} - - - - /* Sercomm-Belkin, added by chiyoko, 20090415 */ -static void -SwLedControlMode5( - struct adapter *padapter, - enum LED_CTL_MODE LedAction -) -{ - struct led_priv *ledpriv = &(padapter->ledpriv); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct LED_871x *pLed = &(ledpriv->SwLed0); - - switch (LedAction) { - case LED_CTL_POWER_ON: - case LED_CTL_NO_LINK: - case LED_CTL_LINK: /* solid blue */ - pLed->CurrLedState = RTW_LED_ON; - pLed->BlinkingLedState = RTW_LED_ON; - - _set_timer(&(pLed->BlinkTimer), 0); - break; - case LED_CTL_SITE_SURVEY: - if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && (check_fwstate(pmlmepriv, _FW_LINKED))) { - } else if (!pLed->bLedScanBlinkInProgress) { - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } - pLed->bLedScanBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SCAN; - pLed->BlinkTimes = 24; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); - } - break; - case LED_CTL_TX: - case LED_CTL_RX: - if (!pLed->bLedBlinkInProgress) { - if (pLed->CurrLedState == LED_BLINK_SCAN) - return; - pLed->bLedBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_TXRX; - pLed->BlinkTimes = 2; - if (pLed->bLedOn) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); - } - break; - case LED_CTL_POWER_OFF: - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - - if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); - pLed->bLedBlinkInProgress = false; - } SwLedOff(padapter, pLed); break; default: @@ -1572,73 +444,18 @@ SwLedControlMode5( RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Led %d\n", pLed->CurrLedState)); } - /* WNC-Corega, added by chiyoko, 20090902 */ -static void -SwLedControlMode6( - struct adapter *padapter, - enum LED_CTL_MODE LedAction -) -{ - struct led_priv *ledpriv = &(padapter->ledpriv); - struct LED_871x *pLed0 = &(ledpriv->SwLed0); - - switch (LedAction) { - case LED_CTL_POWER_ON: - case LED_CTL_LINK: - case LED_CTL_NO_LINK: - _cancel_timer_ex(&(pLed0->BlinkTimer)); - pLed0->CurrLedState = RTW_LED_ON; - pLed0->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed0->BlinkTimer), 0); - break; - case LED_CTL_POWER_OFF: - SwLedOff(padapter, pLed0); - break; - default: - break; - } - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("ledcontrol 6 Led %d\n", pLed0->CurrLedState)); -} - /* */ /* Description: */ /* Handler function of LED Blinking. */ -/* We dispatch acture LED blink action according to LedStrategy. */ /* */ void BlinkHandler(struct LED_871x *pLed) { struct adapter *padapter = pLed->padapter; - struct led_priv *ledpriv = &(padapter->ledpriv); if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped)) return; - switch (ledpriv->LedStrategy) { - case SW_LED_MODE0: - SwLedBlink(pLed); - break; - case SW_LED_MODE1: - SwLedBlink1(pLed); - break; - case SW_LED_MODE2: - SwLedBlink2(pLed); - break; - case SW_LED_MODE3: - SwLedBlink3(pLed); - break; - case SW_LED_MODE4: - SwLedBlink4(pLed); - break; - case SW_LED_MODE5: - SwLedBlink5(pLed); - break; - case SW_LED_MODE6: - SwLedBlink6(pLed); - break; - default: - break; - } + SwLedBlink1(pLed); } void LedControl8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction) @@ -1661,32 +478,5 @@ void LedControl8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction) LedAction == LED_CTL_POWER_ON)) return; - switch (ledpriv->LedStrategy) { - case SW_LED_MODE0: - break; - case SW_LED_MODE1: - SwLedControlMode1(padapter, LedAction); - break; - case SW_LED_MODE2: - SwLedControlMode2(padapter, LedAction); - break; - case SW_LED_MODE3: - SwLedControlMode3(padapter, LedAction); - break; - case SW_LED_MODE4: - SwLedControlMode4(padapter, LedAction); - break; - case SW_LED_MODE5: - SwLedControlMode5(padapter, LedAction); - break; - case SW_LED_MODE6: - SwLedControlMode6(padapter, LedAction); - break; - default: - break; - } - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, - ("LedStrategy:%d, LedAction %d\n", - ledpriv->LedStrategy, LedAction)); + SwLedControlMode1(padapter, LedAction); } -- cgit v1.2.3 From f54c06bf31946d34d11b016c0f23a6ac61c342ee Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 20 Apr 2014 14:17:14 +0530 Subject: staging: rtl8188eu: Remove enum LED_STRATEGY_871x . Now driver has only one type of led blinking strategy, so we don't need enum LED_STRATEGY_871x variable to store led blinking strategy type. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188eu_led.c | 1 - drivers/staging/rtl8188eu/include/rtw_led.h | 18 ------------------ 2 files changed, 19 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c index 01eeb7080717..e3c86f7162cf 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c @@ -95,7 +95,6 @@ void rtl8188eu_InitSwLeds(struct adapter *padapter) struct hal_data_8188e *haldata = GET_HAL_DATA(padapter); pledpriv->bRegUseLed = true; - pledpriv->LedStrategy = SW_LED_MODE1; pledpriv->LedControlHandler = LedControl8188eu; haldata->bLedOpenDrain = true; diff --git a/drivers/staging/rtl8188eu/include/rtw_led.h b/drivers/staging/rtl8188eu/include/rtw_led.h index 0da4e27a70fa..690c82aea1cd 100644 --- a/drivers/staging/rtl8188eu/include/rtw_led.h +++ b/drivers/staging/rtl8188eu/include/rtw_led.h @@ -143,30 +143,12 @@ struct LED_871x { (((struct LED_871x *)_LED_871x)->bLedWPSBlinkInProgress || \ ((struct LED_871x *)_LED_871x)->bLedScanBlinkInProgress) -/* LED customization. */ - -enum LED_STRATEGY_871x { - SW_LED_MODE0 = 0, /* SW control 1 LED via GPIO0. It is default option.*/ - SW_LED_MODE1 = 1, /* 2 LEDs, through LED0 and LED1. For ALPHA. */ - SW_LED_MODE2 = 2, /* SW control 1 LED via GPIO0, customized for AzWave - * 8187 minicard. */ - SW_LED_MODE3 = 3, /* SW control 1 LED via GPIO0, customized for Sercomm - * Printer Server case. */ - SW_LED_MODE4 = 4, /* for Edimax / Belkin */ - SW_LED_MODE5 = 5, /* for Sercomm / Belkin */ - SW_LED_MODE6 = 6, /* for 88CU minicard, porting from ce SW_LED_MODE7 */ - HW_LED = 50, /* HW control 2 LEDs, LED0 and LED1 (there are 4 - * different control modes, see MAC.CONFIG1 for details.)*/ - LED_ST_NONE = 99, -}; - void LedControl8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction); struct led_priv{ /* add for led control */ struct LED_871x SwLed0; struct LED_871x SwLed1; - enum LED_STRATEGY_871x LedStrategy; u8 bRegUseLed; void (*LedControlHandler)(struct adapter *padapter, enum LED_CTL_MODE LedAction); -- cgit v1.2.3 From 373b61b615d95f78db37e41e1ce4ae76efad2907 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 20 Apr 2014 14:17:15 +0530 Subject: staging: rtl8188eu: refactor led related structures. struct led_priv contains two variables SwLed0 and SwLed1 but only SwLed0 is being used by SwLedControlModel1() function. SwLedControlModel1() function performs led operations. This patch removes SwLed1 and code which uses SwLed1. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_led.c | 3 +- drivers/staging/rtl8188eu/hal/rtl8188eu_led.c | 40 ++++++--------------------- drivers/staging/rtl8188eu/include/rtw_led.h | 14 +--------- 3 files changed, 11 insertions(+), 46 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_led.c b/drivers/staging/rtl8188eu/core/rtw_led.c index c42e17647b90..87d6f063476b 100644 --- a/drivers/staging/rtl8188eu/core/rtw_led.c +++ b/drivers/staging/rtl8188eu/core/rtw_led.c @@ -70,10 +70,9 @@ void ResetLedStatus(struct LED_871x *pLed) /*Description: */ /* Initialize an LED_871x object. */ -void InitLed871x(struct adapter *padapter, struct LED_871x *pLed, enum LED_PIN_871x LedPin) +void InitLed871x(struct adapter *padapter, struct LED_871x *pLed) { pLed->padapter = padapter; - pLed->LedPin = LedPin; ResetLedStatus(pLed); diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c index e3c86f7162cf..77dce584f0db 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c @@ -35,16 +35,7 @@ void SwLedOn(struct adapter *padapter, struct LED_871x *pLed) if (padapter->bSurpriseRemoved || padapter->bDriverStopped) return; LedCfg = rtw_read8(padapter, REG_LEDCFG2); - switch (pLed->LedPin) { - case LED_PIN_LED0: - rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0xf0)|BIT5|BIT6); /* SW control led0 on. */ - break; - case LED_PIN_LED1: - rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0x0f)|BIT5); /* SW control led1 on. */ - break; - default: - break; - } + rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0xf0)|BIT5|BIT6); /* SW control led0 on. */ pLed->bLedOn = true; } @@ -60,25 +51,15 @@ void SwLedOff(struct adapter *padapter, struct LED_871x *pLed) LedCfg = rtw_read8(padapter, REG_LEDCFG2);/* 0x4E */ - switch (pLed->LedPin) { - case LED_PIN_LED0: - if (pHalData->bLedOpenDrain) { + if (pHalData->bLedOpenDrain) { /* Open-drain arrangement for controlling the LED) */ - LedCfg &= 0x90; /* Set to software control. */ - rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3)); - LedCfg = rtw_read8(padapter, REG_MAC_PINMUX_CFG); - LedCfg &= 0xFE; - rtw_write8(padapter, REG_MAC_PINMUX_CFG, LedCfg); - } else { - rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3|BIT5|BIT6)); - } - break; - case LED_PIN_LED1: - LedCfg &= 0x0f; /* Set to software control. */ + LedCfg &= 0x90; /* Set to software control. */ rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3)); - break; - default: - break; + LedCfg = rtw_read8(padapter, REG_MAC_PINMUX_CFG); + LedCfg &= 0xFE; + rtw_write8(padapter, REG_MAC_PINMUX_CFG, LedCfg); + } else { + rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3|BIT5|BIT6)); } exit: pLed->bLedOn = false; @@ -98,9 +79,7 @@ void rtl8188eu_InitSwLeds(struct adapter *padapter) pledpriv->LedControlHandler = LedControl8188eu; haldata->bLedOpenDrain = true; - InitLed871x(padapter, &(pledpriv->SwLed0), LED_PIN_LED0); - - InitLed871x(padapter, &(pledpriv->SwLed1), LED_PIN_LED1); + InitLed871x(padapter, &(pledpriv->SwLed0)); } /* Description: */ @@ -110,5 +89,4 @@ void rtl8188eu_DeInitSwLeds(struct adapter *padapter) struct led_priv *ledpriv = &(padapter->ledpriv); DeInitLed871x(&(ledpriv->SwLed0)); - DeInitLed871x(&(ledpriv->SwLed1)); } diff --git a/drivers/staging/rtl8188eu/include/rtw_led.h b/drivers/staging/rtl8188eu/include/rtw_led.h index 690c82aea1cd..ed1c687f8079 100644 --- a/drivers/staging/rtl8188eu/include/rtw_led.h +++ b/drivers/staging/rtl8188eu/include/rtw_led.h @@ -96,19 +96,9 @@ enum LED_STATE_871x { LED_BLINK_ALWAYS_ON = 16, }; -enum LED_PIN_871x { - LED_PIN_NULL = 0, - LED_PIN_LED0 = 1, - LED_PIN_LED1 = 2, - LED_PIN_LED2 = 3, - LED_PIN_GPIO0 = 4, -}; - struct LED_871x { struct adapter *padapter; - enum LED_PIN_871x LedPin; /* Identify how to implement this - * SW led. */ enum LED_STATE_871x CurrLedState; /* Current LED state. */ enum LED_STATE_871x BlinkingLedState; /* Next state for blinking, * either RTW_LED_ON or RTW_LED_OFF are. */ @@ -148,7 +138,6 @@ void LedControl8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction); struct led_priv{ /* add for led control */ struct LED_871x SwLed0; - struct LED_871x SwLed1; u8 bRegUseLed; void (*LedControlHandler)(struct adapter *padapter, enum LED_CTL_MODE LedAction); @@ -166,8 +155,7 @@ void BlinkWorkItemCallback(struct work_struct *work); void ResetLedStatus(struct LED_871x *pLed); -void InitLed871x(struct adapter *padapter, struct LED_871x *pLed, - enum LED_PIN_871x LedPin); +void InitLed871x(struct adapter *padapter, struct LED_871x *pLed); void DeInitLed871x(struct LED_871x *pLed); -- cgit v1.2.3 From 129aadd55dd824af8d34ba988e94642f75e1a233 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 20 Apr 2014 14:17:16 +0530 Subject: staging: rtl8188eu: Remove unused macros. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/rtw_led.h | 31 ----------------------------- 1 file changed, 31 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/rtw_led.h b/drivers/staging/rtl8188eu/include/rtw_led.h index ed1c687f8079..2f81fabc3c02 100644 --- a/drivers/staging/rtl8188eu/include/rtw_led.h +++ b/drivers/staging/rtl8188eu/include/rtw_led.h @@ -23,39 +23,12 @@ #include #include -#define MSECS(t) (HZ * ((t) / 1000) + (HZ * ((t) % 1000)) / 1000) - -#define LED_BLINK_NORMAL_INTERVAL 100 -#define LED_BLINK_SLOWLY_INTERVAL 200 -#define LED_BLINK_LONG_INTERVAL 400 - #define LED_BLINK_NO_LINK_INTERVAL_ALPHA 1000 #define LED_BLINK_LINK_INTERVAL_ALPHA 500 /* 500 */ #define LED_BLINK_SCAN_INTERVAL_ALPHA 180 /* 150 */ #define LED_BLINK_FASTER_INTERVAL_ALPHA 50 #define LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA 5000 -#define LED_BLINK_NORMAL_INTERVAL_NETTRONIX 100 -#define LED_BLINK_SLOWLY_INTERVAL_NETTRONIX 2000 - -#define LED_BLINK_SLOWLY_INTERVAL_PORNET 1000 -#define LED_BLINK_NORMAL_INTERVAL_PORNET 100 - -#define LED_BLINK_FAST_INTERVAL_BITLAND 30 - -/* 060403, rcnjko: Customized for AzWave. */ -#define LED_CM2_BLINK_ON_INTERVAL 250 -#define LED_CM2_BLINK_OFF_INTERVAL 4750 - -#define LED_CM8_BLINK_INTERVAL 500 /* for QMI */ -#define LED_CM8_BLINK_OFF_INTERVAL 3750 /* for QMI */ - -/* 080124, lanhsin: Customized for RunTop */ -#define LED_RunTop_BLINK_INTERVAL 300 - -/* 060421, rcnjko: Customized for Sercomm Printer Server case. */ -#define LED_CM3_BLINK_INTERVAL 1500 - enum LED_CTL_MODE { LED_CTL_POWER_ON = 1, LED_CTL_LINK = 2, @@ -129,10 +102,6 @@ struct LED_871x { ((struct LED_871x *)_LED_871x)->CurrLedState == LED_BLINK_WPS_STOP || \ ((struct LED_871x *)_LED_871x)->bLedWPSBlinkInProgress) -#define IS_LED_BLINKING(_LED_871x) \ - (((struct LED_871x *)_LED_871x)->bLedWPSBlinkInProgress || \ - ((struct LED_871x *)_LED_871x)->bLedScanBlinkInProgress) - void LedControl8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction); struct led_priv{ -- cgit v1.2.3 From a1d17945ccb5db701fd69ce0368269260fafe6e1 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 20 Apr 2014 14:17:17 +0530 Subject: staging: rtl8188eu: Remove unused enum LED_STATE_871x members. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/rtw_led.h | 30 ++++++++++------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/rtw_led.h b/drivers/staging/rtl8188eu/include/rtw_led.h index 2f81fabc3c02..2ad7e4a8f243 100644 --- a/drivers/staging/rtl8188eu/include/rtw_led.h +++ b/drivers/staging/rtl8188eu/include/rtw_led.h @@ -47,26 +47,16 @@ enum LED_CTL_MODE { }; enum LED_STATE_871x { - LED_UNKNOWN = 0, - RTW_LED_ON = 1, - RTW_LED_OFF = 2, - LED_BLINK_NORMAL = 3, - LED_BLINK_SLOWLY = 4, - LED_BLINK_POWER_ON = 5, - LED_BLINK_SCAN = 6, /* LED is blinking during scanning period, - * the # of times to blink is depend on time - * for scanning. */ - LED_BLINK_NO_LINK = 7, /* LED is blinking during no link state. */ - LED_BLINK_StartToBlink = 8,/* Customzied for Sercomm Printer - * Server case */ - LED_BLINK_TXRX = 9, - LED_BLINK_WPS = 10, /* LED is blinkg during WPS communication */ - LED_BLINK_WPS_STOP = 11, /* for ALPHA */ - LED_BLINK_WPS_STOP_OVERLAP = 12, /* for BELKIN */ - LED_BLINK_RUNTOP = 13, /* Customized for RunTop */ - LED_BLINK_CAMEO = 14, - LED_BLINK_XAVI = 15, - LED_BLINK_ALWAYS_ON = 16, + LED_UNKNOWN, + RTW_LED_ON, + RTW_LED_OFF, + LED_BLINK_NORMAL, + LED_BLINK_SLOWLY, + LED_BLINK_POWER_ON, + LED_BLINK_SCAN, + LED_BLINK_TXRX, + LED_BLINK_WPS, + LED_BLINK_WPS_STOP }; struct LED_871x { -- cgit v1.2.3 From b0cf96dfac9a61e6b5f9ad9a8a770957c1e1f9b6 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 20 Apr 2014 14:17:18 +0530 Subject: staging: rtl8188eu: Remove unused enum LED_CTL_MODE members. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/rtw_led.h | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/rtw_led.h b/drivers/staging/rtl8188eu/include/rtw_led.h index 2ad7e4a8f243..c5194b620da4 100644 --- a/drivers/staging/rtl8188eu/include/rtw_led.h +++ b/drivers/staging/rtl8188eu/include/rtw_led.h @@ -30,20 +30,18 @@ #define LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA 5000 enum LED_CTL_MODE { - LED_CTL_POWER_ON = 1, - LED_CTL_LINK = 2, - LED_CTL_NO_LINK = 3, - LED_CTL_TX = 4, - LED_CTL_RX = 5, - LED_CTL_SITE_SURVEY = 6, - LED_CTL_POWER_OFF = 7, - LED_CTL_START_TO_LINK = 8, - LED_CTL_START_WPS = 9, - LED_CTL_STOP_WPS = 10, - LED_CTL_START_WPS_BOTTON = 11, /* added for runtop */ - LED_CTL_STOP_WPS_FAIL = 12, /* added for ALPHA */ - LED_CTL_STOP_WPS_FAIL_OVERLAP = 13, /* added for BELKIN */ - LED_CTL_CONNECTION_NO_TRANSFER = 14, + LED_CTL_POWER_ON, + LED_CTL_LINK, + LED_CTL_NO_LINK, + LED_CTL_TX, + LED_CTL_RX , + LED_CTL_SITE_SURVEY, + LED_CTL_POWER_OFF, + LED_CTL_START_TO_LINK, + LED_CTL_START_WPS, + LED_CTL_STOP_WPS, + LED_CTL_START_WPS_BOTTON, + LED_CTL_STOP_WPS_FAIL }; enum LED_STATE_871x { -- cgit v1.2.3 From 8659596730f78a835439e4293e04a48da3d7c657 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Fri, 25 Apr 2014 01:48:40 +0900 Subject: staging: rtl8192e: A word in printk is split into 2 lines A word in printk is split into two lines. Change it into one line. Signed-off-by: Masanari Iida Reviewed-by: James Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl819x_BAProc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c index 2aecdbd624fb..48a142b82d90 100644 --- a/drivers/staging/rtl8192e/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c @@ -230,8 +230,8 @@ static void rtllib_send_DELBA(struct rtllib_device *ieee, u8 *dst, if (skb) softmac_mgmt_xmit(skb, ieee); else - RTLLIB_DEBUG(RTLLIB_DL_ERR, "alloc skb error in func" - "tion %s()\n", __func__); + RTLLIB_DEBUG(RTLLIB_DL_ERR, "alloc skb error in function" + " %s()\n", __func__); return ; } -- cgit v1.2.3 From 430fb250902b7d563216077bc018108dd20cf8fa Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Fri, 25 Apr 2014 01:48:41 +0900 Subject: staging: rtl8192e: Fix typo in rtl8192e Fix spelling typo in comments within rtl8192e. Signed-off-by: Masanari Iida Reviewed-by: James Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c | 2 +- drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c | 2 +- drivers/staging/rtl8192e/rtl8192e/rtl_wx.c | 2 +- drivers/staging/rtl8192e/rtl819x_TSProc.c | 2 +- drivers/staging/rtl8192e/rtllib_rx.c | 2 +- drivers/staging/rtl8192e/rtllib_softmac.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c index 5f10e4075d39..79d86b9e8009 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c @@ -373,7 +373,7 @@ u32 cmpk_message_handle_rx(struct net_device *dev, default: RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():" - "unknow CMD Element\n"); + "unknown CMD Element\n"); return 1; } diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c index 5d6d304c9c01..b4bfafe5c4a1 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c @@ -1555,7 +1555,7 @@ static bool SetRFPowerState8190(struct net_device *dev, default: bResult = false; - RT_TRACE(COMP_ERR, "SetRFPowerState8190(): unknow state" + RT_TRACE(COMP_ERR, "SetRFPowerState8190(): unknown state" " to set: 0x%X!!!\n", eRFPowerState); break; } diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c index 7d8fcdeafb55..de7609716435 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c @@ -1214,7 +1214,7 @@ static iw_handler r8192_wx_handlers[] = { }; /* - * the following rule need to be follwing, + * the following rule need to be following, * Odd : get (world access), * even : set (root access) * */ diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index 29608e5488a4..52b297724fb1 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -79,7 +79,7 @@ static void RxPktPendingTimeout(unsigned long data) if (index > REORDER_WIN_SIZE) { RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket():" - " Rx Reorer struct buffer full!!\n"); + " Rx Reorder struct buffer full!!\n"); spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); return; diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 6c8a8e12b2b5..7413816dd92b 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -712,7 +712,7 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee, if (index > REORDER_WIN_SIZE) { RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket():" - " Rx Reorer struct buffer full!!\n"); + " Rx Reorder struct buffer full!!\n"); spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags); return; diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 4bf72bc1ba7b..d65cba428941 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -543,7 +543,7 @@ void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh) goto out; /* scan completed */ } while (!ieee->active_channel_map[ch]); - /* this fuction can be called in two situations + /* this function can be called in two situations * 1- We have switched to ad-hoc mode and we are * performing a complete syncro scan before conclude * there are no interesting cell and to create a -- cgit v1.2.3 From 84fcb4b3a3716662ee2f7e0c8270241c71baeb97 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Thu, 24 Apr 2014 03:16:05 +0100 Subject: Staging: rtl8192e: Remove built-in firmware images The driver can already use request_firmware() to load firmware, and always does so. There is code in init_firmware() to use the static firmware images, but it's unreachable! Remove the data and simplify init_firmware() accordingly. Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/Kconfig | 1 + .../staging/rtl8192e/rtl8192e/r8192E_firmware.c | 95 +- .../staging/rtl8192e/rtl8192e/r8192E_firmware.h | 5 - drivers/staging/rtl8192e/rtl8192e/r8192E_hwimg.c | 2771 -------------------- drivers/staging/rtl8192e/rtl8192e/rtl_core.h | 1 - 5 files changed, 34 insertions(+), 2839 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/Kconfig b/drivers/staging/rtl8192e/rtl8192e/Kconfig index ad82bc348a75..282e293da18f 100644 --- a/drivers/staging/rtl8192e/rtl8192e/Kconfig +++ b/drivers/staging/rtl8192e/rtl8192e/Kconfig @@ -5,4 +5,5 @@ config RTL8192E select WIRELESS_EXT select WEXT_PRIV select CRYPTO + select FW_LOADER ---help--- diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c index abcd22f8fdda..1a95d1f87f94 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c @@ -228,13 +228,6 @@ bool init_firmware(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); bool rt_status = true; - u8 *firmware_img_buf[3] = { &Rtl8192PciEFwBootArray[0], - &Rtl8192PciEFwMainArray[0], - &Rtl8192PciEFwDataArray[0]}; - - u32 firmware_img_len[3] = { sizeof(Rtl8192PciEFwBootArray), - sizeof(Rtl8192PciEFwMainArray), - sizeof(Rtl8192PciEFwDataArray)}; u32 file_length = 0; u8 *mapped_file = NULL; u8 init_step = 0; @@ -257,77 +250,55 @@ bool init_firmware(struct net_device *dev) " firmware state\n"); } - priv->firmware_source = FW_SOURCE_IMG_FILE; for (init_step = starting_state; init_step <= FW_INIT_STEP2_DATA; init_step++) { if (rst_opt == OPT_SYSTEM_RESET) { - switch (priv->firmware_source) { - case FW_SOURCE_IMG_FILE: - { - if (pfirmware->firmware_buf_size[init_step] == 0) { - const char *fw_name[3] = { - RTL8192E_BOOT_IMG_FW, - RTL8192E_MAIN_IMG_FW, - RTL8192E_DATA_IMG_FW - }; - const struct firmware *fw_entry; - int rc; - rc = request_firmware(&fw_entry, - fw_name[init_step], &priv->pdev->dev); - if (rc < 0) { - RT_TRACE(COMP_FIRMWARE, "request firm" - "ware fail!\n"); - goto download_firmware_fail; - } - if (fw_entry->size > + if (pfirmware->firmware_buf_size[init_step] == 0) { + const char *fw_name[3] = { + RTL8192E_BOOT_IMG_FW, + RTL8192E_MAIN_IMG_FW, + RTL8192E_DATA_IMG_FW + }; + const struct firmware *fw_entry; + int rc; + rc = request_firmware(&fw_entry, + fw_name[init_step], + &priv->pdev->dev); + if (rc < 0) { + RT_TRACE(COMP_FIRMWARE, "request firmware fail!\n"); + goto download_firmware_fail; + } + if (fw_entry->size > sizeof(pfirmware->firmware_buf[init_step])) { - RT_TRACE(COMP_FIRMWARE, "img file size " + RT_TRACE(COMP_FIRMWARE, "img file size " "exceed the container struct " "buffer fail!\n"); - goto download_firmware_fail; - } + goto download_firmware_fail; + } - if (init_step != FW_INIT_STEP1_MAIN) { - memcpy(pfirmware->firmware_buf[init_step], + if (init_step != FW_INIT_STEP1_MAIN) { + memcpy(pfirmware->firmware_buf[init_step], fw_entry->data, fw_entry->size); - pfirmware->firmware_buf_size[init_step] = - fw_entry->size; + pfirmware->firmware_buf_size[init_step] = + fw_entry->size; - } else { - memset(pfirmware->firmware_buf[init_step], + } else { + memset(pfirmware->firmware_buf[init_step], 0, 128); - memcpy(&pfirmware->firmware_buf[init_step][128], + memcpy(&pfirmware->firmware_buf[init_step][128], fw_entry->data, fw_entry->size); - pfirmware->firmware_buf_size[init_step] = - fw_entry->size + 128; - } - - if (rst_opt == OPT_SYSTEM_RESET) - release_firmware(fw_entry); + pfirmware->firmware_buf_size[init_step] = + fw_entry->size + 128; } - mapped_file = pfirmware->firmware_buf[init_step]; - file_length = pfirmware->firmware_buf_size[init_step]; - break; - } - case FW_SOURCE_HEADER_FILE: - mapped_file = firmware_img_buf[init_step]; - file_length = firmware_img_len[init_step]; - if (init_step == FW_INIT_STEP2_DATA) { - memcpy(pfirmware->firmware_buf[init_step], mapped_file, file_length); - pfirmware->firmware_buf_size[init_step] = file_length; - } - break; - default: - break; + if (rst_opt == OPT_SYSTEM_RESET) + release_firmware(fw_entry); } - - - } else if (rst_opt == OPT_FIRMWARE_RESET) { - mapped_file = pfirmware->firmware_buf[init_step]; - file_length = pfirmware->firmware_buf_size[init_step]; } + mapped_file = pfirmware->firmware_buf[init_step]; + file_length = pfirmware->firmware_buf_size[init_step]; + rt_status = fw_download_code(dev, mapped_file, file_length); if (!rt_status) { goto download_firmware_fail; diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.h b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.h index 06d6abc8345c..94fa16b4993d 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.h +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.h @@ -43,11 +43,6 @@ enum desc_packet_type { DESC_PACKET_TYPE_NORMAL = 1, }; -enum firmware_source { - FW_SOURCE_IMG_FILE = 0, - FW_SOURCE_HEADER_FILE = 1, -}; - enum firmware_status { FW_STATUS_0_INIT = 0, FW_STATUS_1_MOVE_BOOT_CODE = 1, diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_hwimg.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_hwimg.c index 08e7dbb6694b..6767b5965c17 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_hwimg.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_hwimg.c @@ -20,2777 +20,6 @@ #include "r8192E_hwimg.h" -u8 Rtl8192PciEFwBootArray[BootArrayLengthPciE] = { -0x10,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x3c,0x08,0xbf,0xc0,0x25,0x08,0x00,0x08, -0x3c,0x09,0xb0,0x03,0xad,0x28,0x00,0x20,0x40,0x80,0x68,0x00,0x00,0x00,0x00,0x00, -0x3c,0x0a,0xd0,0x00,0x40,0x8a,0x60,0x00,0x00,0x00,0x00,0x00,0x3c,0x08,0x80,0x01, -0x25,0x08,0xa8,0x04,0x24,0x09,0x00,0x01,0x3c,0x01,0x7f,0xff,0x34,0x21,0xff,0xff, -0x01,0x01,0x50,0x24,0x00,0x09,0x48,0x40,0x35,0x29,0x00,0x01,0x01,0x2a,0x10,0x2b, -0x14,0x40,0xff,0xfc,0x00,0x00,0x00,0x00,0x3c,0x0a,0x00,0x00,0x25,0x4a,0x00,0x00, -0x4c,0x8a,0x00,0x00,0x4c,0x89,0x08,0x00,0x00,0x00,0x00,0x00,0x3c,0x08,0x80,0x01, -0x25,0x08,0xa8,0x04,0x3c,0x01,0x80,0x00,0x01,0x21,0x48,0x25,0x3c,0x0a,0xbf,0xc0, -0x25,0x4a,0x00,0x7c,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,0xad,0x00,0x00,0x00, -0x21,0x08,0x00,0x04,0x01,0x09,0x10,0x2b,0x14,0x40,0xff,0xf8,0x00,0x00,0x00,0x00, -0x3c,0x08,0x80,0x01,0x25,0x08,0x7f,0xff,0x24,0x09,0x00,0x01,0x3c,0x01,0x7f,0xff, -0x34,0x21,0xff,0xff,0x01,0x01,0x50,0x24,0x00,0x09,0x48,0x40,0x35,0x29,0x00,0x01, -0x01,0x2a,0x10,0x2b,0x14,0x40,0xff,0xfc,0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x01, -0x25,0x4a,0x00,0x00,0x3c,0x01,0x7f,0xff,0x34,0x21,0xff,0xff,0x01,0x41,0x50,0x24, -0x3c,0x09,0x00,0x01,0x35,0x29,0x7f,0xff,0x4c,0x8a,0x20,0x00,0x4c,0x89,0x28,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x08,0x04,0x10, -0x00,0x00,0x00,0x00,0x40,0x88,0xa0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x3c,0x08,0xbf,0xc0,0x00,0x00,0x00,0x00,0x8d,0x09,0x00,0x00,0x00,0x00,0x00,0x00, -0x3c,0x0a,0xbf,0xc0,0x25,0x4a,0x01,0x20,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20, -0x3c,0x08,0xb0,0x03,0x8d,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x35,0x29,0x00,0x10, -0xad,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x08,0x80,0x00,0x25,0x08,0x4b,0x94, -0x01,0x00,0x00,0x08,0x00,0x00,0x00,0x00,}; - -u8 Rtl8192PciEFwMainArray[MainArrayLengthPciE] = { -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x40,0x04,0x68,0x00,0x40,0x05,0x70,0x00,0x40,0x06,0x40,0x00,0x0c,0x00,0x12,0x98, -0x00,0x00,0x00,0x00,0x40,0x1a,0x68,0x00,0x33,0x5b,0x00,0x3c,0x17,0x60,0x00,0x09, -0x00,0x00,0x00,0x00,0x40,0x1b,0x60,0x00,0x00,0x00,0x00,0x00,0x03,0x5b,0xd0,0x24, -0x40,0x1a,0x70,0x00,0x03,0x40,0x00,0x08,0x42,0x00,0x00,0x10,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x3c,0x02,0xff,0xff,0x34,0x42,0xff,0xff,0x8c,0x43,0x00,0x00, -0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x00,0xd0, -0xac,0x62,0x00,0x00,0x00,0x00,0x20,0x21,0x27,0x85,0x8b,0x70,0x00,0x85,0x18,0x21, -0x24,0x84,0x00,0x01,0x28,0x82,0x00,0x0a,0x14,0x40,0xff,0xfc,0xa0,0x60,0x00,0x00, -0x27,0x82,0x8b,0x7a,0x24,0x04,0x00,0x06,0x24,0x84,0xff,0xff,0xa4,0x40,0x00,0x00, -0x04,0x81,0xff,0xfd,0x24,0x42,0x00,0x02,0x24,0x02,0x00,0x03,0xa3,0x82,0x8b,0x70, -0x24,0x02,0x00,0x0a,0x24,0x03,0x09,0xc4,0xa3,0x82,0x8b,0x72,0x24,0x02,0x00,0x04, -0x24,0x04,0x00,0x01,0x24,0x05,0x00,0x02,0xa7,0x83,0x8b,0x86,0xa3,0x82,0x8b,0x78, -0x24,0x03,0x04,0x00,0x24,0x02,0x02,0x00,0xaf,0x83,0x8b,0x8c,0xa3,0x85,0x8b,0x79, -0xa7,0x82,0x8b,0x7a,0xa7,0x84,0x8b,0x7c,0xaf,0x84,0x8b,0x88,0xa3,0x84,0x8b,0x71, -0xa3,0x80,0x8b,0x73,0xa3,0x80,0x8b,0x74,0xa3,0x80,0x8b,0x75,0xa3,0x84,0x8b,0x76, -0xa3,0x85,0x8b,0x77,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03, -0x3c,0x02,0x80,0x00,0x24,0x42,0x01,0x7c,0x34,0x63,0x00,0x20,0xac,0x62,0x00,0x00, -0x27,0x84,0x8b,0x98,0x00,0x00,0x10,0x21,0x24,0x42,0x00,0x01,0x00,0x02,0x16,0x00, -0x00,0x02,0x16,0x03,0x28,0x43,0x00,0x03,0xac,0x80,0xff,0xfc,0xa0,0x80,0x00,0x00, -0x14,0x60,0xff,0xf9,0x24,0x84,0x00,0x0c,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, -0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x01,0xc0, -0x3c,0x08,0xb0,0x03,0xac,0x62,0x00,0x00,0x35,0x08,0x00,0x70,0x8d,0x02,0x00,0x00, -0x00,0xa0,0x48,0x21,0x00,0x04,0x26,0x00,0x00,0x02,0x2a,0x43,0x00,0x06,0x36,0x00, -0x00,0x07,0x3e,0x00,0x00,0x02,0x12,0x03,0x29,0x23,0x00,0x03,0x00,0x04,0x56,0x03, -0x00,0x06,0x36,0x03,0x00,0x07,0x3e,0x03,0x30,0x48,0x00,0x01,0x10,0x60,0x00,0x11, -0x30,0xa5,0x00,0x07,0x24,0x02,0x00,0x02,0x00,0x49,0x10,0x23,0x00,0x45,0x10,0x07, -0x30,0x42,0x00,0x01,0x10,0x40,0x00,0x66,0x00,0x00,0x00,0x00,0x8f,0xa2,0x00,0x10, -0x00,0x00,0x00,0x00,0x00,0x02,0x21,0x43,0x11,0x00,0x00,0x10,0x00,0x07,0x20,0x0b, -0x15,0x20,0x00,0x06,0x24,0x02,0x00,0x01,0x3c,0x02,0xb0,0x05,0x34,0x42,0x01,0x20, -0xa4,0x44,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x11,0x22,0x00,0x04, -0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x05,0x08,0x00,0x00,0x94,0x34,0x42,0x01,0x24, -0x3c,0x02,0xb0,0x05,0x08,0x00,0x00,0x94,0x34,0x42,0x01,0x22,0x15,0x20,0x00,0x54, -0x24,0x02,0x00,0x01,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x74,0x90,0x43,0x00,0x00, -0x00,0x00,0x00,0x00,0xaf,0x83,0x8b,0x94,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x70, -0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x6b,0x00,0x08,0x11,0x60,0x00,0x18, -0x00,0x09,0x28,0x40,0x00,0x00,0x40,0x21,0x27,0x85,0x8b,0x90,0x8c,0xa3,0x00,0x00, -0x8c,0xa2,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x62,0x38,0x23,0x00,0x43,0x10,0x2a, -0x10,0x40,0x00,0x3d,0x00,0x00,0x00,0x00,0xac,0xa7,0x00,0x00,0x25,0x02,0x00,0x01, -0x00,0x02,0x16,0x00,0x00,0x02,0x46,0x03,0x29,0x03,0x00,0x03,0x14,0x60,0xff,0xf3, -0x24,0xa5,0x00,0x0c,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x70,0x90,0x62,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x4b,0x10,0x23,0xa0,0x62,0x00,0x00,0x00,0x09,0x28,0x40, -0x00,0xa9,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x8b,0x98,0x00,0x0a,0x20,0x0b, -0x00,0x43,0x18,0x21,0x10,0xc0,0x00,0x05,0x00,0x00,0x38,0x21,0x80,0x62,0x00,0x01, -0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x80,0x62,0x00,0x00, -0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x03,0x00,0xa9,0x10,0x21,0x24,0x07,0x00,0x01, -0x00,0xa9,0x10,0x21,0x00,0x02,0x30,0x80,0x27,0x82,0x8b,0x98,0xa0,0x67,0x00,0x01, -0x00,0xc2,0x38,0x21,0x80,0xe3,0x00,0x01,0x00,0x00,0x00,0x00,0x10,0x60,0x00,0x07, -0x00,0x00,0x00,0x00,0x27,0x83,0x8b,0x90,0x00,0xc3,0x18,0x21,0x8c,0x62,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x44,0x10,0x21,0xac,0x62,0x00,0x00,0x27,0x85,0x8b,0x94, -0x27,0x82,0x8b,0x90,0x00,0xc5,0x28,0x21,0x00,0xc2,0x10,0x21,0x8c,0x43,0x00,0x00, -0x8c,0xa4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x64,0x18,0x2a,0x14,0x60,0x00,0x03, -0x24,0x02,0x00,0x01,0x03,0xe0,0x00,0x08,0xa0,0xe2,0x00,0x00,0xa0,0xe0,0x00,0x00, -0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0xb7,0xac,0xa0,0x00,0x00, -0x11,0x22,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x7c, -0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0xaf,0x83,0x8b,0xac,0x08,0x00,0x00,0xa7, -0x3c,0x02,0xb0,0x03,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x78,0x90,0x43,0x00,0x00, -0x00,0x00,0x00,0x00,0xaf,0x83,0x8b,0xa0,0x08,0x00,0x00,0xa7,0x3c,0x02,0xb0,0x03, -0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x04,0x10, -0x3c,0x05,0xb0,0x03,0xac,0x62,0x00,0x00,0x34,0xa5,0x00,0x70,0x8c,0xa2,0x00,0x00, -0x90,0x84,0x00,0x08,0x3c,0x06,0xb0,0x03,0x00,0x02,0x16,0x00,0x2c,0x83,0x00,0x03, -0x34,0xc6,0x00,0x72,0x24,0x07,0x00,0x01,0x10,0x60,0x00,0x11,0x00,0x02,0x2f,0xc2, -0x90,0xc2,0x00,0x00,0x00,0x00,0x18,0x21,0x00,0x02,0x16,0x00,0x10,0xa7,0x00,0x09, -0x00,0x02,0x16,0x03,0x14,0x80,0x00,0x0c,0x30,0x43,0x00,0x03,0x83,0x82,0x8b,0x98, -0x00,0x00,0x00,0x00,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x00,0x02,0x16,0x00, -0x00,0x02,0x1e,0x03,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x72,0xa0,0x43,0x00,0x00, -0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0x45,0x00,0x05,0x10,0x87,0x00,0x04, -0x30,0x43,0x00,0x06,0x93,0x82,0x8b,0xb0,0x08,0x00,0x01,0x1f,0x00,0x43,0x10,0x21, -0x83,0x82,0x8b,0xa4,0x00,0x00,0x00,0x00,0x00,0x02,0x10,0x40,0x08,0x00,0x01,0x1f, -0x00,0x45,0x10,0x21,0x10,0x80,0x00,0x05,0x00,0x00,0x18,0x21,0x24,0x63,0x00,0x01, -0x00,0x64,0x10,0x2b,0x14,0x40,0xff,0xfd,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, -0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x24,0x42,0x04,0xe4, -0x3c,0x04,0xb0,0x02,0x34,0x63,0x00,0x20,0xac,0x62,0x00,0x00,0x34,0x84,0x00,0x08, -0x24,0x02,0x00,0x01,0xaf,0x84,0x8b,0xc0,0xa3,0x82,0x8b,0xd0,0xa7,0x80,0x8b,0xc4, -0xa7,0x80,0x8b,0xc6,0xaf,0x80,0x8b,0xc8,0xaf,0x80,0x8b,0xcc,0x03,0xe0,0x00,0x08, -0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20, -0x24,0x42,0x05,0x24,0x3c,0x04,0xb0,0x03,0xac,0x62,0x00,0x00,0x34,0x84,0x00,0xac, -0x80,0xa2,0x00,0x15,0x8c,0x83,0x00,0x00,0x27,0xbd,0xff,0xf0,0x00,0x43,0x10,0x21, -0xac,0x82,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x10,0x3c,0x02,0xb0,0x03, -0x3c,0x03,0x80,0x00,0x34,0x42,0x00,0x20,0x24,0x63,0x05,0x5c,0x27,0xbd,0xff,0xe0, -0xac,0x43,0x00,0x00,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x18, -0x8f,0x90,0x8b,0xc0,0x0c,0x00,0x02,0x98,0x00,0x80,0x88,0x21,0x14,0x40,0x00,0x2a, -0x3c,0x02,0x00,0x80,0x16,0x20,0x00,0x02,0x34,0x42,0x02,0x01,0x24,0x02,0x02,0x01, -0xae,0x02,0x00,0x00,0x97,0x84,0x8b,0xc4,0x97,0x82,0x8b,0xc6,0x3c,0x03,0xb0,0x02, -0x00,0x83,0x20,0x21,0x24,0x42,0x00,0x04,0xa7,0x82,0x8b,0xc6,0xa4,0x82,0x00,0x00, -0x8f,0x84,0x8b,0xc8,0x8f,0x82,0x8b,0xc0,0x93,0x85,0x8b,0x72,0x24,0x84,0x00,0x01, -0x24,0x42,0x00,0x04,0x24,0x03,0x8f,0xff,0x3c,0x07,0xb0,0x06,0x3c,0x06,0xb0,0x03, -0x00,0x43,0x10,0x24,0x00,0x85,0x28,0x2a,0x34,0xe7,0x80,0x18,0xaf,0x82,0x8b,0xc0, -0xaf,0x84,0x8b,0xc8,0x10,0xa0,0x00,0x08,0x34,0xc6,0x01,0x08,0x8f,0x83,0x8b,0xcc, -0x8f,0x84,0x8b,0x8c,0x8c,0xc2,0x00,0x00,0x00,0x64,0x18,0x21,0x00,0x43,0x10,0x2b, -0x14,0x40,0x00,0x09,0x00,0x00,0x00,0x00,0x8c,0xe2,0x00,0x00,0x3c,0x03,0x0f,0x00, -0x3c,0x04,0x04,0x00,0x00,0x43,0x10,0x24,0x10,0x44,0x00,0x03,0x00,0x00,0x00,0x00, -0x0c,0x00,0x04,0x96,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x27,0xbd,0xff,0xd8,0x3c,0x02,0xb0,0x03, -0x3c,0x03,0x80,0x00,0x24,0x63,0x06,0x48,0xaf,0xb0,0x00,0x10,0x34,0x42,0x00,0x20, -0x8f,0x90,0x8b,0xc0,0xac,0x43,0x00,0x00,0xaf,0xb3,0x00,0x1c,0xaf,0xb2,0x00,0x18, -0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x20,0x00,0x80,0x88,0x21,0x00,0xa0,0x90,0x21, -0x0c,0x00,0x02,0x98,0x00,0xc0,0x98,0x21,0x24,0x07,0x8f,0xff,0x14,0x40,0x00,0x19, -0x26,0x03,0x00,0x04,0x24,0x02,0x0e,0x03,0xae,0x02,0x00,0x00,0x00,0x67,0x80,0x24, -0x26,0x02,0x00,0x04,0xae,0x11,0x00,0x00,0x00,0x47,0x80,0x24,0x97,0x86,0x8b,0xc4, -0x26,0x03,0x00,0x04,0xae,0x12,0x00,0x00,0x00,0x67,0x80,0x24,0xae,0x13,0x00,0x00, -0x8f,0x84,0x8b,0xc0,0x3c,0x02,0xb0,0x02,0x97,0x85,0x8b,0xc6,0x00,0xc2,0x30,0x21, -0x8f,0x82,0x8b,0xc8,0x24,0x84,0x00,0x10,0x24,0xa5,0x00,0x10,0x00,0x87,0x20,0x24, -0x24,0x42,0x00,0x01,0xa7,0x85,0x8b,0xc6,0xaf,0x84,0x8b,0xc0,0xaf,0x82,0x8b,0xc8, -0xa4,0xc5,0x00,0x00,0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10, -0x94,0x82,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x42,0xe0,0x00,0x14,0x40,0x00,0x14, -0x00,0x00,0x00,0x00,0x90,0x82,0x00,0x02,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xfc, -0x00,0x82,0x28,0x21,0x8c,0xa4,0x00,0x00,0x3c,0x02,0x00,0x70,0x8c,0xa6,0x00,0x08, -0x00,0x82,0x10,0x21,0x2c,0x43,0x00,0x06,0x10,0x60,0x00,0x09,0x3c,0x03,0x80,0x01, -0x00,0x02,0x10,0x80,0x24,0x63,0x01,0xe8,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00,0xaf,0x86,0x80,0x14, -0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18, -0x8c,0xa4,0x00,0x00,0x0c,0x00,0x17,0x84,0x00,0x00,0x00,0x00,0x08,0x00,0x01,0xdc, -0x00,0x00,0x00,0x00,0x0c,0x00,0x24,0x49,0x00,0xc0,0x20,0x21,0x08,0x00,0x01,0xdc, -0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x08,0x8c,0x44,0x00,0x00, -0x8f,0x82,0x80,0x18,0x3c,0x03,0x00,0x0f,0x34,0x63,0x42,0x40,0x00,0x43,0x10,0x21, -0x00,0x82,0x20,0x2b,0x10,0x80,0x00,0x09,0x24,0x03,0x00,0x05,0x8f,0x82,0x83,0x60, -0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xaf,0x82,0x83,0x60,0x10,0x43,0x00,0x03, -0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03, -0x8c,0x63,0x01,0x08,0x24,0x02,0x00,0x01,0xa3,0x82,0x80,0x11,0xaf,0x80,0x83,0x60, -0xaf,0x83,0x80,0x18,0x08,0x00,0x01,0xf9,0x00,0x00,0x00,0x00,0x30,0x84,0x00,0xff, -0x14,0x80,0x00,0x2f,0x00,0x00,0x00,0x00,0x8f,0x82,0x80,0x14,0xa3,0x85,0x83,0x93, -0x10,0x40,0x00,0x2b,0x2c,0xa2,0x00,0x04,0x14,0x40,0x00,0x06,0x00,0x05,0x10,0x40, -0x24,0xa2,0xff,0xfc,0x2c,0x42,0x00,0x08,0x10,0x40,0x00,0x09,0x24,0xa2,0xff,0xf0, -0x00,0x05,0x10,0x40,0x27,0x84,0x83,0x9c,0x00,0x44,0x10,0x21,0x94,0x43,0x00,0x00, -0x00,0x00,0x00,0x00,0x24,0x63,0x00,0x01,0x03,0xe0,0x00,0x08,0xa4,0x43,0x00,0x00, -0x2c,0x42,0x00,0x10,0x14,0x40,0x00,0x0a,0x00,0x05,0x10,0x40,0x24,0xa2,0xff,0xe0, -0x2c,0x42,0x00,0x10,0x14,0x40,0x00,0x06,0x00,0x05,0x10,0x40,0x24,0xa2,0xff,0xd0, -0x2c,0x42,0x00,0x10,0x10,0x40,0x00,0x09,0x24,0xa2,0xff,0xc0,0x00,0x05,0x10,0x40, -0x27,0x84,0x83,0x9c,0x00,0x44,0x10,0x21,0x94,0x43,0xff,0xf8,0x00,0x00,0x00,0x00, -0x24,0x63,0x00,0x01,0x03,0xe0,0x00,0x08,0xa4,0x43,0xff,0xf8,0x2c,0x42,0x00,0x10, -0x10,0x40,0x00,0x07,0x00,0x05,0x10,0x40,0x27,0x84,0x83,0x9c,0x00,0x44,0x10,0x21, -0x94,0x43,0xff,0xf8,0x00,0x00,0x00,0x00,0x24,0x63,0x00,0x01,0xa4,0x43,0xff,0xf8, -0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x8f,0x86,0x8b,0xc0,0x8f,0x82,0x80,0x14, -0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10,0x10,0x40,0x00,0x2a,0x00,0xc0,0x38,0x21, -0x24,0x02,0x00,0x07,0x24,0x03,0xff,0x9c,0xa3,0x82,0x83,0x9b,0xa3,0x83,0x83,0x9a, -0x27,0x8a,0x83,0x98,0x00,0x00,0x20,0x21,0x24,0x09,0x8f,0xff,0x00,0x04,0x10,0x80, -0x00,0x4a,0x28,0x21,0x8c,0xa2,0x00,0x00,0x24,0xe3,0x00,0x04,0x24,0x88,0x00,0x01, -0xac,0xe2,0x00,0x00,0x10,0x80,0x00,0x02,0x00,0x69,0x38,0x24,0xac,0xa0,0x00,0x00, -0x31,0x04,0x00,0xff,0x2c,0x82,0x00,0x27,0x14,0x40,0xff,0xf5,0x00,0x04,0x10,0x80, -0x97,0x83,0x8b,0xc6,0x97,0x85,0x8b,0xc4,0x3c,0x02,0xb0,0x02,0x24,0x63,0x00,0x9c, -0x00,0xa2,0x28,0x21,0x3c,0x04,0xb0,0x06,0xa7,0x83,0x8b,0xc6,0x34,0x84,0x80,0x18, -0xa4,0xa3,0x00,0x00,0x8c,0x85,0x00,0x00,0x24,0x02,0x8f,0xff,0x24,0xc6,0x00,0x9c, -0x3c,0x03,0x0f,0x00,0x00,0xc2,0x30,0x24,0x00,0xa3,0x28,0x24,0x3c,0x02,0x04,0x00, -0xaf,0x86,0x8b,0xc0,0x10,0xa2,0x00,0x03,0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0x96, -0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x18,0x8f,0x86,0x8b,0xc0,0x27,0xbd,0xff,0xc8,0x24,0x02,0x00,0x08, -0x24,0x03,0x00,0x20,0xaf,0xbf,0x00,0x30,0xa3,0xa2,0x00,0x13,0xa3,0xa3,0x00,0x12, -0xa7,0xa4,0x00,0x10,0x00,0xc0,0x28,0x21,0x27,0xa9,0x00,0x10,0x00,0x00,0x38,0x21, -0x24,0x08,0x8f,0xff,0x00,0x07,0x10,0x80,0x00,0x49,0x10,0x21,0x8c,0x44,0x00,0x00, -0x24,0xe3,0x00,0x01,0x30,0x67,0x00,0xff,0x24,0xa2,0x00,0x04,0x2c,0xe3,0x00,0x08, -0xac,0xa4,0x00,0x00,0x14,0x60,0xff,0xf7,0x00,0x48,0x28,0x24,0x97,0x83,0x8b,0xc6, -0x97,0x85,0x8b,0xc4,0x3c,0x02,0xb0,0x02,0x24,0x63,0x00,0x20,0x00,0xa2,0x28,0x21, -0x3c,0x04,0xb0,0x06,0xa7,0x83,0x8b,0xc6,0x34,0x84,0x80,0x18,0xa4,0xa3,0x00,0x00, -0x8c,0x85,0x00,0x00,0x24,0x02,0x8f,0xff,0x24,0xc6,0x00,0x20,0x3c,0x03,0x0f,0x00, -0x00,0xc2,0x30,0x24,0x00,0xa3,0x28,0x24,0x3c,0x02,0x04,0x00,0xaf,0x86,0x8b,0xc0, -0x10,0xa2,0x00,0x03,0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0x96,0x00,0x00,0x00,0x00, -0x8f,0xbf,0x00,0x30,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38, -0x93,0x82,0x8b,0xd0,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x11,0x24,0x06,0x00,0x01, -0x8f,0x82,0x8b,0xc8,0x3c,0x05,0xb0,0x06,0x3c,0x04,0xb0,0x03,0x34,0xa5,0x80,0x18, -0x34,0x84,0x01,0x08,0x14,0x40,0x00,0x09,0x00,0x00,0x30,0x21,0x97,0x82,0x8b,0xc4, -0x8c,0x84,0x00,0x00,0x3c,0x03,0xb0,0x02,0x00,0x43,0x10,0x21,0xaf,0x84,0x8b,0xcc, -0xa7,0x80,0x8b,0xc6,0xac,0x40,0x00,0x00,0xac,0x40,0x00,0x04,0x8c,0xa2,0x00,0x00, -0x03,0xe0,0x00,0x08,0x00,0xc0,0x10,0x21,0x8f,0x86,0x8b,0xc0,0x8f,0x82,0x8b,0xc8, -0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10,0x00,0xc0,0x40,0x21,0x14,0x40,0x00,0x0a, -0x00,0x40,0x50,0x21,0x00,0x00,0x38,0x21,0x27,0x89,0x83,0x68,0x24,0xe2,0x00,0x01, -0x00,0x07,0x18,0x80,0x30,0x47,0x00,0xff,0x00,0x69,0x18,0x21,0x2c,0xe2,0x00,0x0a, -0x14,0x40,0xff,0xfa,0xac,0x60,0x00,0x00,0x3c,0x02,0x00,0x80,0x10,0x82,0x00,0x6f, -0x00,0x00,0x00,0x00,0x97,0x82,0x83,0x6e,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01, -0xa7,0x82,0x83,0x6e,0x90,0xa3,0x00,0x15,0x97,0x82,0x83,0x70,0x00,0x03,0x1e,0x00, -0x00,0x03,0x1e,0x03,0x00,0x43,0x10,0x21,0xa7,0x82,0x83,0x70,0x8c,0xa4,0x00,0x20, -0x3c,0x02,0x00,0x60,0x3c,0x03,0x00,0x20,0x00,0x82,0x20,0x24,0x10,0x83,0x00,0x54, -0x00,0x00,0x00,0x00,0x14,0x80,0x00,0x47,0x00,0x00,0x00,0x00,0x97,0x82,0x83,0x74, -0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xa7,0x82,0x83,0x74,0x84,0xa3,0x00,0x06, -0x8f,0x82,0x83,0x84,0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x21,0xaf,0x82,0x83,0x84, -0x25,0x42,0x00,0x01,0x28,0x43,0x27,0x10,0xaf,0x82,0x8b,0xc8,0x10,0x60,0x00,0x09, -0x24,0x02,0x00,0x04,0x93,0x83,0x80,0x11,0x24,0x02,0x00,0x01,0x10,0x62,0x00,0x05, -0x24,0x02,0x00,0x04,0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x18,0x24,0x03,0x00,0x28,0xa3,0x83,0x83,0x6a,0xa3,0x82,0x83,0x6b, -0x90,0xa2,0x00,0x18,0x93,0x83,0x83,0x93,0x00,0x00,0x38,0x21,0x00,0x02,0x16,0x00, -0x00,0x02,0x16,0x03,0xa7,0x82,0x83,0x7e,0xa3,0x83,0x83,0x8c,0x27,0x89,0x83,0x68, -0x24,0x05,0x8f,0xff,0x00,0x07,0x10,0x80,0x00,0x49,0x10,0x21,0x8c,0x44,0x00,0x00, -0x24,0xe3,0x00,0x01,0x30,0x67,0x00,0xff,0x25,0x02,0x00,0x04,0x2c,0xe3,0x00,0x0a, -0xad,0x04,0x00,0x00,0x14,0x60,0xff,0xf7,0x00,0x45,0x40,0x24,0x97,0x83,0x8b,0xc6, -0x97,0x85,0x8b,0xc4,0x3c,0x02,0xb0,0x02,0x24,0x63,0x00,0x28,0x00,0xa2,0x28,0x21, -0x3c,0x04,0xb0,0x06,0xa7,0x83,0x8b,0xc6,0x34,0x84,0x80,0x18,0xa4,0xa3,0x00,0x00, -0x8c,0x85,0x00,0x00,0x24,0x02,0x8f,0xff,0x24,0xc6,0x00,0x28,0x3c,0x03,0x0f,0x00, -0x00,0xc2,0x30,0x24,0x00,0xa3,0x28,0x24,0x3c,0x02,0x04,0x00,0xaf,0x86,0x8b,0xc0, -0x10,0xa2,0x00,0x03,0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0x96,0x00,0x00,0x00,0x00, -0x0c,0x00,0x02,0x36,0x00,0x00,0x00,0x00,0xa3,0x80,0x80,0x11,0x08,0x00,0x02,0xe5, -0x00,0x00,0x00,0x00,0x97,0x82,0x83,0x76,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01, -0xa7,0x82,0x83,0x76,0x84,0xa3,0x00,0x06,0x8f,0x82,0x83,0x88,0x00,0x00,0x00,0x00, -0x00,0x43,0x10,0x21,0xaf,0x82,0x83,0x88,0x08,0x00,0x02,0xdd,0x25,0x42,0x00,0x01, -0x97,0x82,0x83,0x72,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xa7,0x82,0x83,0x72, -0x84,0xa3,0x00,0x06,0x8f,0x82,0x83,0x80,0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x21, -0xaf,0x82,0x83,0x80,0x08,0x00,0x02,0xdd,0x25,0x42,0x00,0x01,0x97,0x82,0x83,0x6c, -0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xa7,0x82,0x83,0x6c,0x08,0x00,0x02,0xc5, -0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xd0,0xaf,0xbf,0x00,0x28,0x8c,0xa3,0x00,0x20, -0x8f,0x8a,0x8b,0xc0,0x3c,0x02,0x00,0x10,0x00,0x62,0x10,0x24,0x00,0xa0,0x38,0x21, -0x01,0x40,0x48,0x21,0x10,0x40,0x00,0x3d,0x00,0x80,0x28,0x21,0x8c,0xe4,0x00,0x1c, -0x34,0xa5,0x12,0x06,0xaf,0xa5,0x00,0x10,0x8c,0x82,0x00,0x08,0x00,0x03,0x1c,0x42, -0x30,0x63,0x00,0x30,0x00,0x02,0x13,0x02,0x30,0x42,0x00,0x40,0x00,0x43,0x10,0x25, -0x90,0xe6,0x00,0x10,0x90,0xe4,0x00,0x13,0x94,0xe8,0x00,0x0c,0x94,0xe3,0x00,0x1a, -0x00,0x02,0x16,0x00,0x90,0xe7,0x00,0x12,0x00,0xa2,0x28,0x25,0x24,0x02,0x12,0x34, -0xa7,0xa2,0x00,0x1c,0x24,0x02,0x56,0x78,0xaf,0xa5,0x00,0x10,0xa3,0xa6,0x00,0x18, -0xa3,0xa7,0x00,0x1f,0xa7,0xa3,0x00,0x1a,0xa3,0xa4,0x00,0x19,0xa7,0xa8,0x00,0x20, -0xa7,0xa2,0x00,0x22,0x00,0x00,0x28,0x21,0x27,0xa7,0x00,0x10,0x24,0x06,0x8f,0xff, -0x00,0x05,0x10,0x80,0x00,0x47,0x10,0x21,0x8c,0x44,0x00,0x00,0x24,0xa3,0x00,0x01, -0x30,0x65,0x00,0xff,0x25,0x22,0x00,0x04,0x2c,0xa3,0x00,0x05,0xad,0x24,0x00,0x00, -0x14,0x60,0xff,0xf7,0x00,0x46,0x48,0x24,0x97,0x83,0x8b,0xc6,0x97,0x85,0x8b,0xc4, -0x3c,0x02,0xb0,0x02,0x24,0x63,0x00,0x14,0x00,0xa2,0x28,0x21,0x3c,0x04,0xb0,0x06, -0xa7,0x83,0x8b,0xc6,0x34,0x84,0x80,0x18,0xa4,0xa3,0x00,0x00,0x8c,0x85,0x00,0x00, -0x24,0x02,0x8f,0xff,0x25,0x46,0x00,0x14,0x3c,0x03,0x0f,0x00,0x00,0xc2,0x50,0x24, -0x00,0xa3,0x28,0x24,0x3c,0x02,0x04,0x00,0xaf,0x8a,0x8b,0xc0,0x10,0xa2,0x00,0x03, -0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0x96,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x28, -0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x30,0x3c,0x05,0xb0,0x03, -0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xc8,0x00,0x04,0x22,0x00,0x34,0xa5,0x00,0x20, -0x24,0x42,0x0d,0xfc,0x3c,0x03,0xb0,0x00,0xaf,0xb5,0x00,0x24,0xaf,0xb4,0x00,0x20, -0xaf,0xb2,0x00,0x18,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x30,0x00,0x83,0x80,0x21, -0xaf,0xb7,0x00,0x2c,0xaf,0xb6,0x00,0x28,0xaf,0xb3,0x00,0x1c,0xaf,0xb1,0x00,0x14, -0xac,0xa2,0x00,0x00,0x8e,0x09,0x00,0x00,0x00,0x00,0x90,0x21,0x26,0x10,0x00,0x08, -0x00,0x09,0xa6,0x02,0x12,0x80,0x00,0x13,0x00,0x00,0xa8,0x21,0x24,0x13,0x00,0x02, -0x3c,0x16,0x00,0xff,0x3c,0x17,0xff,0x00,0x8e,0x09,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x09,0x12,0x02,0x24,0x42,0x00,0x02,0x31,0x25,0x00,0xff,0x10,0xb3,0x00,0x76, -0x30,0x51,0x00,0xff,0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x18,0x00,0x00,0x00,0x00, -0x02,0x51,0x10,0x21,0x30,0x52,0xff,0xff,0x02,0x54,0x18,0x2b,0x14,0x60,0xff,0xf2, -0x02,0x11,0x80,0x21,0x12,0xa0,0x00,0x0a,0x3c,0x02,0xb0,0x06,0x34,0x42,0x80,0x18, -0x8c,0x43,0x00,0x00,0x3c,0x04,0x0f,0x00,0x3c,0x02,0x04,0x00,0x00,0x64,0x18,0x24, -0x10,0x62,0x00,0x03,0x00,0x00,0x00,0x00,0x0c,0x00,0x04,0x96,0x00,0x00,0x00,0x00, -0x8f,0xbf,0x00,0x30,0x7b,0xb6,0x01,0x7c,0x7b,0xb4,0x01,0x3c,0x7b,0xb2,0x00,0xfc, -0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38,0x8e,0x09,0x00,0x04, -0x24,0x15,0x00,0x01,0x8e,0x06,0x00,0x0c,0x00,0x09,0x11,0x42,0x00,0x09,0x18,0xc2, -0x30,0x48,0x00,0x03,0x00,0x09,0x14,0x02,0x30,0x6c,0x00,0x03,0x00,0x09,0x26,0x02, -0x11,0x15,0x00,0x45,0x30,0x43,0x00,0x0f,0x29,0x02,0x00,0x02,0x14,0x40,0x00,0x26, -0x00,0x00,0x00,0x00,0x11,0x13,0x00,0x0f,0x00,0x00,0x38,0x21,0x00,0x07,0x22,0x02, -0x30,0x84,0xff,0x00,0x3c,0x03,0x00,0xff,0x00,0x07,0x2e,0x02,0x00,0x07,0x12,0x00, -0x00,0x43,0x10,0x24,0x00,0xa4,0x28,0x25,0x00,0xa2,0x28,0x25,0x00,0x07,0x1e,0x00, -0x00,0xa3,0x28,0x25,0x0c,0x00,0x01,0x92,0x01,0x20,0x20,0x21,0x08,0x00,0x03,0xa5, -0x02,0x51,0x10,0x21,0x11,0x95,0x00,0x0f,0x00,0x00,0x00,0x00,0x11,0x88,0x00,0x07, -0x00,0x00,0x00,0x00,0x00,0x04,0x10,0x80,0x27,0x83,0x8b,0x70,0x00,0x43,0x10,0x21, -0x8c,0x47,0x00,0x18,0x08,0x00,0x03,0xcc,0x00,0x07,0x22,0x02,0x00,0x04,0x10,0x40, -0x27,0x83,0x8b,0x78,0x00,0x43,0x10,0x21,0x94,0x47,0x00,0x02,0x08,0x00,0x03,0xcc, -0x00,0x07,0x22,0x02,0x27,0x82,0x8b,0x70,0x00,0x82,0x10,0x21,0x90,0x47,0x00,0x00, -0x08,0x00,0x03,0xcc,0x00,0x07,0x22,0x02,0x15,0x00,0xff,0xdc,0x00,0x00,0x38,0x21, -0x10,0x75,0x00,0x05,0x00,0x80,0x38,0x21,0x00,0x65,0x18,0x26,0x24,0x82,0x01,0x00, -0x00,0x00,0x38,0x21,0x00,0x43,0x38,0x0a,0x24,0x02,0x00,0x01,0x11,0x82,0x00,0x0e, -0x3c,0x02,0xb0,0x03,0x24,0x02,0x00,0x02,0x11,0x82,0x00,0x06,0x00,0x00,0x00,0x00, -0x3c,0x02,0xb0,0x03,0x00,0xe2,0x10,0x21,0x8c,0x47,0x00,0x00,0x08,0x00,0x03,0xcc, -0x00,0x07,0x22,0x02,0x3c,0x02,0xb0,0x03,0x00,0xe2,0x10,0x21,0x94,0x43,0x00,0x00, -0x08,0x00,0x03,0xcb,0x30,0x67,0xff,0xff,0x00,0xe2,0x10,0x21,0x90,0x43,0x00,0x00, -0x08,0x00,0x03,0xcb,0x30,0x67,0x00,0xff,0x30,0x62,0x00,0x03,0x00,0x02,0x12,0x00, -0x11,0x95,0x00,0x07,0x00,0x44,0x38,0x21,0x11,0x93,0x00,0x03,0x00,0x00,0x00,0x00, -0x08,0x00,0x03,0xfd,0x3c,0x02,0xb0,0x0a,0x08,0x00,0x04,0x02,0x3c,0x02,0xb0,0x0a, -0x08,0x00,0x04,0x06,0x3c,0x02,0xb0,0x0a,0x8e,0x09,0x00,0x04,0x8e,0x02,0x00,0x08, -0x8e,0x03,0x00,0x0c,0x00,0x09,0x41,0x42,0x00,0x02,0x22,0x02,0x00,0x03,0x3a,0x02, -0x30,0x84,0xff,0x00,0x30,0xe7,0xff,0x00,0x00,0x02,0x5e,0x02,0x00,0x02,0x32,0x00, -0x00,0x03,0x56,0x02,0x00,0x03,0x2a,0x00,0x01,0x64,0x58,0x25,0x00,0xd6,0x30,0x24, -0x01,0x47,0x50,0x25,0x00,0x02,0x16,0x00,0x00,0xb6,0x28,0x24,0x00,0x03,0x1e,0x00, -0x01,0x66,0x58,0x25,0x01,0x45,0x50,0x25,0x00,0x57,0x10,0x24,0x00,0x77,0x18,0x24, -0x01,0x62,0x38,0x25,0x01,0x43,0x30,0x25,0x00,0x09,0x10,0xc2,0x00,0x09,0x1c,0x02, -0x31,0x08,0x00,0x03,0x30,0x4c,0x00,0x03,0x30,0x63,0x00,0x0f,0x00,0x09,0x26,0x02, -0x00,0xe0,0x58,0x21,0x15,0x00,0x00,0x28,0x00,0xc0,0x50,0x21,0x24,0x02,0x00,0x01, -0x10,0x62,0x00,0x06,0x00,0x80,0x28,0x21,0x24,0x02,0x00,0x03,0x14,0x62,0xff,0x69, -0x02,0x51,0x10,0x21,0x24,0x85,0x01,0x00,0x24,0x02,0x00,0x01,0x11,0x82,0x00,0x15, -0x24,0x02,0x00,0x02,0x11,0x82,0x00,0x0a,0x3c,0x03,0xb0,0x03,0x00,0xa3,0x18,0x21, -0x8c,0x62,0x00,0x00,0x00,0x0a,0x20,0x27,0x01,0x6a,0x28,0x24,0x00,0x44,0x10,0x24, -0x00,0x45,0x10,0x25,0xac,0x62,0x00,0x00,0x08,0x00,0x03,0xa5,0x02,0x51,0x10,0x21, -0x00,0xa3,0x18,0x21,0x94,0x62,0x00,0x00,0x00,0x0a,0x20,0x27,0x01,0x6a,0x28,0x24, -0x00,0x44,0x10,0x24,0x00,0x45,0x10,0x25,0xa4,0x62,0x00,0x00,0x08,0x00,0x03,0xa5, -0x02,0x51,0x10,0x21,0x3c,0x03,0xb0,0x03,0x00,0xa3,0x18,0x21,0x90,0x62,0x00,0x00, -0x00,0x0a,0x20,0x27,0x01,0x6a,0x28,0x24,0x00,0x44,0x10,0x24,0x00,0x45,0x10,0x25, -0x08,0x00,0x03,0xa4,0xa0,0x62,0x00,0x00,0x24,0x02,0x00,0x01,0x11,0x02,0x00,0x21, -0x00,0x00,0x00,0x00,0x15,0x13,0xff,0x42,0x00,0x00,0x00,0x00,0x11,0x82,0x00,0x17, -0x00,0x00,0x00,0x00,0x11,0x88,0x00,0x0b,0x00,0x00,0x00,0x00,0x27,0x83,0x8b,0x70, -0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21,0x8c,0x82,0x00,0x18,0x00,0x06,0x18,0x27, -0x00,0xe6,0x28,0x24,0x00,0x43,0x10,0x24,0x00,0x45,0x10,0x25,0x08,0x00,0x03,0xa4, -0xac,0x82,0x00,0x18,0x27,0x83,0x8b,0x78,0x00,0x04,0x20,0x40,0x00,0x83,0x20,0x21, -0x94,0x82,0x00,0x02,0x00,0x06,0x18,0x27,0x00,0xe6,0x28,0x24,0x00,0x43,0x10,0x24, -0x00,0x45,0x10,0x25,0x08,0x00,0x03,0xa4,0xa4,0x82,0x00,0x02,0x27,0x83,0x8b,0x70, -0x00,0x83,0x18,0x21,0x90,0x62,0x00,0x00,0x00,0x06,0x20,0x27,0x08,0x00,0x04,0x5a, -0x00,0xe6,0x28,0x24,0x30,0x62,0x00,0x07,0x00,0x02,0x12,0x00,0x11,0x88,0x00,0x0f, -0x00,0x44,0x10,0x21,0x11,0x93,0x00,0x07,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x0a, -0x00,0x43,0x18,0x21,0x8c,0x62,0x00,0x00,0x00,0x06,0x20,0x27,0x08,0x00,0x04,0x47, -0x00,0xe6,0x28,0x24,0x3c,0x03,0xb0,0x0a,0x00,0x43,0x18,0x21,0x94,0x62,0x00,0x00, -0x00,0x06,0x20,0x27,0x08,0x00,0x04,0x50,0x00,0xe6,0x28,0x24,0x3c,0x03,0xb0,0x0a, -0x08,0x00,0x04,0x7d,0x00,0x43,0x18,0x21,0x97,0x85,0x8b,0xc4,0x3c,0x07,0xb0,0x02, -0x3c,0x04,0xb0,0x03,0x3c,0x02,0x80,0x00,0x00,0xa7,0x28,0x21,0x34,0x84,0x00,0x20, -0x24,0x42,0x12,0x58,0x24,0x03,0xff,0x80,0xac,0x82,0x00,0x00,0xa0,0xa3,0x00,0x07, -0x97,0x82,0x8b,0xc6,0x97,0x85,0x8b,0xc4,0x3c,0x06,0xb0,0x06,0x30,0x42,0xff,0xf8, -0x24,0x42,0x00,0x10,0x00,0xa2,0x10,0x21,0x30,0x42,0x0f,0xff,0x24,0x44,0x00,0x08, -0x30,0x84,0x0f,0xff,0x00,0x05,0x28,0xc2,0x3c,0x03,0x00,0x40,0x00,0xa3,0x28,0x25, -0x00,0x87,0x20,0x21,0x34,0xc6,0x80,0x18,0xac,0xc5,0x00,0x00,0xaf,0x84,0x8b,0xc0, -0xa7,0x82,0x8b,0xc4,0xa7,0x80,0x8b,0xc6,0xaf,0x80,0x8b,0xc8,0x03,0xe0,0x00,0x08, -0x00,0x00,0x00,0x00,0x30,0xa5,0x00,0xff,0x30,0x84,0x00,0xff,0x24,0x02,0x00,0x01, -0x00,0xe0,0x48,0x21,0x30,0xc6,0x00,0xff,0x8f,0xa7,0x00,0x10,0x10,0x82,0x00,0x07, -0x00,0xa0,0x40,0x21,0x24,0x02,0x00,0x03,0x10,0x82,0x00,0x03,0x00,0x00,0x00,0x00, -0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x24,0xa8,0x01,0x00,0x3c,0x03,0xb0,0x03, -0x24,0x02,0x00,0x01,0x00,0x07,0x20,0x27,0x01,0x27,0x28,0x24,0x10,0xc2,0x00,0x14, -0x01,0x03,0x18,0x21,0x24,0x02,0x00,0x02,0x10,0xc2,0x00,0x09,0x00,0x07,0x50,0x27, -0x3c,0x03,0xb0,0x03,0x01,0x03,0x18,0x21,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x4a,0x10,0x24,0x00,0x45,0x10,0x25,0x08,0x00,0x04,0xe1,0xac,0x62,0x00,0x00, -0x3c,0x03,0xb0,0x03,0x01,0x03,0x18,0x21,0x94,0x62,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x4a,0x10,0x24,0x00,0x45,0x10,0x25,0x03,0xe0,0x00,0x08,0xa4,0x62,0x00,0x00, -0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x10,0x24,0x00,0x45,0x10,0x25, -0xa0,0x62,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0x84,0x00,0x07, -0x00,0x04,0x22,0x00,0x30,0xa5,0x00,0xff,0x00,0x85,0x28,0x21,0x3c,0x02,0xb0,0x0a, -0x00,0xa2,0x40,0x21,0x30,0xc6,0x00,0xff,0x24,0x02,0x00,0x01,0x8f,0xa4,0x00,0x10, -0x10,0xc2,0x00,0x14,0x24,0x02,0x00,0x02,0x00,0x04,0x50,0x27,0x10,0xc2,0x00,0x09, -0x00,0xe4,0x48,0x24,0x3c,0x03,0xb0,0x0a,0x00,0xa3,0x18,0x21,0x8c,0x62,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x4a,0x10,0x24,0x00,0x49,0x10,0x25,0x03,0xe0,0x00,0x08, -0xac,0x62,0x00,0x00,0x3c,0x03,0xb0,0x0a,0x00,0xa3,0x18,0x21,0x94,0x62,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x4a,0x10,0x24,0x00,0x49,0x10,0x25,0x03,0xe0,0x00,0x08, -0xa4,0x62,0x00,0x00,0x91,0x02,0x00,0x00,0x00,0x04,0x18,0x27,0x00,0xe4,0x20,0x24, -0x00,0x43,0x10,0x24,0x00,0x44,0x10,0x25,0x03,0xe0,0x00,0x08,0xa1,0x02,0x00,0x00, -0x30,0xa9,0x00,0xff,0x27,0x83,0x8b,0x70,0x30,0x85,0x00,0xff,0x24,0x02,0x00,0x01, -0x00,0x07,0x50,0x27,0x00,0xc7,0x40,0x24,0x11,0x22,0x00,0x17,0x00,0xa3,0x18,0x21, -0x00,0x05,0x20,0x40,0x27,0x82,0x8b,0x70,0x00,0x05,0x28,0x80,0x27,0x83,0x8b,0x78, -0x00,0x83,0x50,0x21,0x00,0xa2,0x20,0x21,0x24,0x02,0x00,0x02,0x00,0x07,0x40,0x27, -0x11,0x22,0x00,0x07,0x00,0xc7,0x28,0x24,0x8c,0x82,0x00,0x18,0x00,0x00,0x00,0x00, -0x00,0x48,0x10,0x24,0x00,0x45,0x10,0x25,0x03,0xe0,0x00,0x08,0xac,0x82,0x00,0x18, -0x95,0x42,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x48,0x10,0x24,0x00,0x45,0x10,0x25, -0x03,0xe0,0x00,0x08,0xa5,0x42,0x00,0x02,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x4a,0x10,0x24,0x00,0x48,0x10,0x25,0x03,0xe0,0x00,0x08,0xa0,0x62,0x00,0x00, -0x00,0x04,0x32,0x02,0x30,0xc6,0xff,0x00,0x00,0x04,0x16,0x02,0x00,0x04,0x1a,0x00, -0x3c,0x05,0x00,0xff,0x00,0x65,0x18,0x24,0x00,0x46,0x10,0x25,0x00,0x43,0x10,0x25, -0x00,0x04,0x26,0x00,0x03,0xe0,0x00,0x08,0x00,0x44,0x10,0x25,0x3c,0x03,0xb0,0x03, -0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xe8,0x34,0x63,0x00,0x20,0x24,0x42,0x14,0xdc, -0x3c,0x04,0xb0,0x03,0xaf,0xbf,0x00,0x14,0xac,0x62,0x00,0x00,0xaf,0xb0,0x00,0x10, -0x34,0x84,0x00,0x2c,0x8c,0x83,0x00,0x00,0xa7,0x80,0xbc,0x00,0x00,0x03,0x12,0x02, -0x00,0x03,0x2d,0x02,0x30,0x42,0x0f,0xff,0xa3,0x83,0xbc,0x08,0xa7,0x85,0xbc,0x0c, -0xa7,0x82,0xbc,0x0a,0xa7,0x80,0xbc,0x02,0xa7,0x80,0xbc,0x04,0xa7,0x80,0xbc,0x06, -0x0c,0x00,0x06,0xd1,0x24,0x04,0x05,0x00,0x3c,0x05,0x08,0x00,0x00,0x45,0x28,0x25, -0x24,0x04,0x05,0x00,0x0c,0x00,0x06,0xbf,0x00,0x40,0x80,0x21,0x3c,0x02,0xf7,0xff, -0x34,0x42,0xff,0xff,0x02,0x02,0x80,0x24,0x02,0x00,0x28,0x21,0x0c,0x00,0x06,0xbf, -0x24,0x04,0x05,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0xb0,0x03,0x34,0x42,0x01,0x08, -0x34,0x63,0x01,0x18,0x8c,0x45,0x00,0x00,0x8c,0x64,0x00,0x00,0x3c,0x02,0x00,0x0f, -0x3c,0x03,0x00,0x4c,0x30,0x84,0x02,0x00,0x34,0x63,0x4b,0x40,0xaf,0x85,0xbc,0x10, -0x10,0x80,0x00,0x06,0x34,0x42,0x42,0x40,0xaf,0x83,0xbc,0x14,0x8f,0xbf,0x00,0x14, -0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0xaf,0x82,0xbc,0x14, -0x08,0x00,0x05,0x67,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00, -0x27,0xbd,0xff,0xc8,0x34,0x63,0x00,0x20,0x24,0x42,0x15,0xb8,0x30,0x84,0x00,0xff, -0xaf,0xbf,0x00,0x30,0xaf,0xb7,0x00,0x2c,0xaf,0xb6,0x00,0x28,0xaf,0xb5,0x00,0x24, -0xaf,0xb4,0x00,0x20,0xaf,0xb3,0x00,0x1c,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14, -0xaf,0xb0,0x00,0x10,0xac,0x62,0x00,0x00,0x10,0x80,0x00,0x1c,0x24,0x02,0x00,0x02, -0x10,0x82,0x00,0x08,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x30,0x7b,0xb6,0x01,0x7c, -0x7b,0xb4,0x01,0x3c,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x38,0xa7,0x80,0xbc,0x00,0xa7,0x80,0xbc,0x02,0xa7,0x80,0xbc,0x04, -0xa7,0x80,0xbc,0x06,0x0c,0x00,0x06,0xd1,0x24,0x04,0x05,0x00,0x3c,0x05,0x08,0x00, -0x00,0x45,0x28,0x25,0x24,0x04,0x05,0x00,0x0c,0x00,0x06,0xbf,0x00,0x40,0x80,0x21, -0x3c,0x05,0xf7,0xff,0x34,0xa5,0xff,0xff,0x02,0x05,0x28,0x24,0x0c,0x00,0x06,0xbf, -0x24,0x04,0x05,0x00,0x08,0x00,0x05,0x82,0x00,0x00,0x00,0x00,0x0c,0x00,0x06,0xd1, -0x24,0x04,0x05,0xa0,0x24,0x04,0x05,0xa4,0x0c,0x00,0x06,0xd1,0x00,0x02,0xbc,0x02, -0x24,0x04,0x05,0xa8,0x00,0x02,0xb4,0x02,0x0c,0x00,0x06,0xd1,0x30,0x55,0xff,0xff, -0x00,0x40,0x80,0x21,0x97,0x84,0xbc,0x00,0x97,0x82,0xbc,0x02,0x97,0x83,0xbc,0x06, -0x02,0xe4,0x20,0x23,0x02,0xa2,0x10,0x23,0x00,0x82,0x20,0x21,0x97,0x82,0xbc,0x04, -0x32,0x14,0xff,0xff,0x02,0x83,0x18,0x23,0x02,0xc2,0x10,0x23,0x00,0x82,0x20,0x21, -0x93,0x82,0xbc,0x08,0x00,0x83,0x20,0x21,0x30,0x84,0xff,0xff,0x00,0x82,0x10,0x2b, -0x14,0x40,0x00,0xaa,0x00,0x00,0x00,0x00,0x97,0x82,0xbc,0x0c,0x00,0x00,0x00,0x00, -0x00,0x44,0x10,0x2b,0x14,0x40,0x00,0x7f,0x00,0x00,0x00,0x00,0x97,0x82,0xbc,0x0a, -0x00,0x00,0x00,0x00,0x00,0x44,0x10,0x2b,0x10,0x40,0x00,0x3a,0x00,0x00,0x00,0x00, -0x0c,0x00,0x06,0xd1,0x24,0x04,0x04,0x50,0x30,0x51,0x00,0x7f,0x00,0x40,0x80,0x21, -0x2e,0x22,0x00,0x32,0x10,0x40,0x00,0x13,0x24,0x02,0x00,0x20,0x12,0x22,0x00,0x17, -0x24,0x02,0xff,0x80,0x02,0x02,0x10,0x24,0x26,0x31,0x00,0x01,0x00,0x51,0x80,0x25, -0x02,0x00,0x28,0x21,0x0c,0x00,0x06,0xbf,0x24,0x04,0x04,0x50,0x02,0x00,0x28,0x21, -0x0c,0x00,0x06,0xbf,0x24,0x04,0x04,0x58,0x02,0x00,0x28,0x21,0x0c,0x00,0x06,0xbf, -0x24,0x04,0x04,0x60,0x02,0x00,0x28,0x21,0x24,0x04,0x04,0x68,0x0c,0x00,0x06,0xbf, -0x00,0x00,0x00,0x00,0xa7,0x97,0xbc,0x00,0xa7,0x95,0xbc,0x02,0xa7,0x96,0xbc,0x04, -0xa7,0x94,0xbc,0x06,0x08,0x00,0x05,0x82,0x00,0x00,0x00,0x00,0x0c,0x00,0x06,0xd1, -0x24,0x04,0x02,0x08,0x3c,0x04,0x00,0xc0,0x00,0x40,0x28,0x21,0x00,0x44,0x10,0x24, -0x00,0x02,0x15,0x82,0x24,0x03,0x00,0x03,0x10,0x43,0x00,0x07,0x00,0x00,0x00,0x00, -0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff,0x00,0xa2,0x10,0x24,0x00,0x44,0x28,0x25, -0x0c,0x00,0x06,0xbf,0x24,0x04,0x02,0x08,0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x2c, -0x00,0x40,0x90,0x21,0x3c,0x02,0xff,0xff,0x34,0x42,0x3f,0xff,0x02,0x42,0x90,0x24, -0x02,0x40,0x28,0x21,0x0c,0x00,0x06,0xbf,0x24,0x04,0x02,0x2c,0x08,0x00,0x05,0xc9, -0x24,0x02,0xff,0x80,0x0c,0x00,0x06,0xd1,0x24,0x04,0x04,0x50,0x30,0x51,0x00,0x7f, -0x24,0x02,0x00,0x20,0x16,0x22,0xff,0xdb,0x00,0x00,0x00,0x00,0x0c,0x00,0x06,0xd1, -0x24,0x04,0x02,0x2c,0x34,0x52,0x40,0x00,0x02,0x40,0x28,0x21,0x0c,0x00,0x06,0xbf, -0x24,0x04,0x02,0x2c,0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x58,0x24,0x04,0x02,0x5c, -0x0c,0x00,0x06,0xd1,0x00,0x02,0x9e,0x02,0x30,0x43,0x00,0xff,0x00,0x13,0x12,0x00, -0x00,0x43,0x10,0x25,0x2c,0x43,0x00,0x04,0x14,0x60,0x00,0x1d,0x2c,0x42,0x00,0x11, -0x10,0x40,0x00,0x0b,0x00,0x00,0x00,0x00,0x3c,0x02,0xff,0xff,0x34,0x42,0x3f,0xff, -0x02,0x42,0x90,0x24,0x02,0x40,0x28,0x21,0x24,0x04,0x02,0x2c,0x0c,0x00,0x06,0xbf, -0x36,0x52,0x80,0x00,0x02,0x40,0x28,0x21,0x08,0x00,0x05,0xd7,0x24,0x04,0x02,0x2c, -0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x08,0x3c,0x04,0x00,0xc0,0x00,0x40,0x28,0x21, -0x00,0x44,0x10,0x24,0x00,0x02,0x15,0x82,0x24,0x03,0x00,0x02,0x14,0x43,0xff,0xee, -0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff,0x00,0xa2,0x10,0x24,0x00,0x44,0x28,0x25, -0x0c,0x00,0x06,0xbf,0x24,0x04,0x02,0x08,0x08,0x00,0x06,0x13,0x3c,0x02,0xff,0xff, -0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x08,0x00,0x40,0x28,0x21,0x00,0x02,0x15,0x82, -0x30,0x42,0x00,0x03,0x24,0x03,0x00,0x03,0x14,0x43,0xff,0xdf,0x3c,0x02,0xff,0x3f, -0x34,0x42,0xff,0xff,0x00,0xa2,0x10,0x24,0x3c,0x03,0x00,0x80,0x08,0x00,0x06,0x28, -0x00,0x43,0x28,0x25,0x0c,0x00,0x06,0xd1,0x24,0x04,0x04,0x50,0x30,0x51,0x00,0x7f, -0x00,0x40,0x80,0x21,0x2e,0x22,0x00,0x32,0x10,0x40,0xff,0x9a,0x24,0x02,0x00,0x20, -0x12,0x22,0x00,0x04,0x24,0x02,0xff,0x80,0x02,0x02,0x10,0x24,0x08,0x00,0x05,0xcb, -0x26,0x31,0x00,0x02,0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x08,0x3c,0x04,0x00,0xc0, -0x00,0x40,0x28,0x21,0x00,0x44,0x10,0x24,0x00,0x02,0x15,0x82,0x24,0x03,0x00,0x03, -0x10,0x43,0x00,0x07,0x00,0x00,0x00,0x00,0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff, -0x00,0xa2,0x10,0x24,0x00,0x44,0x28,0x25,0x0c,0x00,0x06,0xbf,0x24,0x04,0x02,0x08, -0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x2c,0x00,0x40,0x90,0x21,0x3c,0x02,0xff,0xff, -0x34,0x42,0x3f,0xff,0x02,0x42,0x90,0x24,0x02,0x40,0x28,0x21,0x0c,0x00,0x06,0xbf, -0x24,0x04,0x02,0x2c,0x08,0x00,0x06,0x42,0x24,0x02,0xff,0x80,0x0c,0x00,0x06,0xd1, -0x24,0x04,0x04,0x50,0x00,0x40,0x80,0x21,0x30,0x51,0x00,0x7f,0x24,0x02,0x00,0x20, -0x12,0x22,0x00,0x1d,0x2e,0x22,0x00,0x21,0x14,0x40,0xff,0x72,0x24,0x02,0xff,0x80, -0x02,0x02,0x10,0x24,0x26,0x31,0xff,0xff,0x00,0x51,0x80,0x25,0x24,0x04,0x04,0x50, -0x0c,0x00,0x06,0xbf,0x02,0x00,0x28,0x21,0x24,0x04,0x04,0x58,0x0c,0x00,0x06,0xbf, -0x02,0x00,0x28,0x21,0x24,0x04,0x04,0x60,0x0c,0x00,0x06,0xbf,0x02,0x00,0x28,0x21, -0x02,0x00,0x28,0x21,0x0c,0x00,0x06,0xbf,0x24,0x04,0x04,0x68,0x24,0x02,0x00,0x20, -0x16,0x22,0xff,0x60,0x00,0x00,0x00,0x00,0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x2c, -0x00,0x40,0x90,0x21,0x3c,0x02,0xff,0xff,0x34,0x42,0x3f,0xff,0x02,0x42,0x10,0x24, -0x08,0x00,0x06,0x19,0x34,0x52,0x80,0x00,0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x2c, -0x34,0x52,0x40,0x00,0x02,0x40,0x28,0x21,0x0c,0x00,0x06,0xbf,0x24,0x04,0x02,0x2c, -0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x58,0x24,0x04,0x02,0x5c,0x0c,0x00,0x06,0xd1, -0x00,0x02,0x9e,0x02,0x30,0x43,0x00,0xff,0x00,0x13,0x12,0x00,0x00,0x43,0x10,0x25, -0x2c,0x43,0x00,0x04,0x14,0x60,0x00,0x20,0x2c,0x42,0x00,0x11,0x10,0x40,0x00,0x0d, -0x00,0x00,0x00,0x00,0x3c,0x02,0xff,0xff,0x34,0x42,0x3f,0xff,0x02,0x42,0x90,0x24, -0x02,0x40,0x28,0x21,0x24,0x04,0x02,0x2c,0x0c,0x00,0x06,0xbf,0x36,0x52,0x80,0x00, -0x02,0x40,0x28,0x21,0x0c,0x00,0x06,0xbf,0x24,0x04,0x02,0x2c,0x08,0x00,0x06,0x66, -0x2e,0x22,0x00,0x21,0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x08,0x3c,0x04,0x00,0xc0, -0x00,0x40,0x28,0x21,0x00,0x44,0x10,0x24,0x00,0x02,0x15,0x82,0x24,0x03,0x00,0x02, -0x14,0x43,0xff,0xec,0x00,0x00,0x00,0x00,0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff, -0x00,0xa2,0x10,0x24,0x00,0x44,0x28,0x25,0x0c,0x00,0x06,0xbf,0x24,0x04,0x02,0x08, -0x08,0x00,0x06,0x96,0x3c,0x02,0xff,0xff,0x0c,0x00,0x06,0xd1,0x24,0x04,0x02,0x08, -0x00,0x40,0x28,0x21,0x00,0x02,0x15,0x82,0x30,0x42,0x00,0x03,0x24,0x03,0x00,0x03, -0x14,0x43,0xff,0xdc,0x3c,0x03,0x00,0x80,0x3c,0x02,0xff,0x3f,0x34,0x42,0xff,0xff, -0x00,0xa2,0x10,0x24,0x08,0x00,0x06,0xae,0x00,0x43,0x28,0x25,0x30,0x83,0x00,0x03, -0x00,0x04,0x20,0x40,0x00,0x83,0x20,0x23,0x3c,0x02,0xb0,0x0a,0x00,0x82,0x20,0x21, -0x3c,0x06,0x00,0x01,0xac,0x85,0x00,0x00,0x24,0x07,0x00,0x01,0x00,0x00,0x28,0x21, -0x34,0xc6,0x86,0x9f,0x8c,0x82,0x10,0x00,0x24,0xa5,0x00,0x01,0x10,0x47,0x00,0x03, -0x00,0xc5,0x18,0x2b,0x10,0x60,0xff,0xfb,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08, -0x00,0x00,0x00,0x00,0x30,0x83,0x00,0x03,0x00,0x04,0x20,0x40,0x3c,0x02,0xb0,0x0a, -0x00,0x83,0x20,0x23,0x00,0x82,0x20,0x21,0x3c,0x06,0x00,0x01,0x24,0x02,0xff,0xff, -0xac,0x82,0x10,0x00,0x00,0x00,0x28,0x21,0x24,0x07,0x00,0x01,0x34,0xc6,0x86,0x9f, -0x8c,0x82,0x10,0x00,0x24,0xa5,0x00,0x01,0x10,0x47,0x00,0x03,0x00,0xc5,0x18,0x2b, -0x10,0x60,0xff,0xfb,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x00,0x03,0xe0,0x00,0x08, -0x00,0x00,0x00,0x00,0x3c,0x05,0xb0,0x03,0x3c,0x02,0x80,0x00,0x24,0x42,0x1b,0x94, -0x24,0x03,0x00,0x01,0x34,0xa5,0x00,0x20,0x3c,0x06,0xb0,0x03,0xac,0xa2,0x00,0x00, -0x34,0xc6,0x01,0x04,0xa0,0x83,0x00,0x48,0xa0,0x80,0x00,0x04,0xa0,0x80,0x00,0x05, -0xa0,0x80,0x00,0x06,0xa0,0x80,0x00,0x07,0xa0,0x80,0x00,0x08,0xa0,0x80,0x00,0x09, -0xa0,0x80,0x00,0x0a,0xa0,0x80,0x00,0x11,0xa0,0x80,0x00,0x13,0xa0,0x80,0x00,0x49, -0x94,0xc2,0x00,0x00,0xac,0x80,0x00,0x00,0xa0,0x80,0x00,0x4e,0x00,0x02,0x14,0x00, -0x00,0x02,0x14,0x03,0x30,0x43,0x00,0xff,0x30,0x42,0xff,0x00,0xa4,0x82,0x00,0x44, -0xa4,0x83,0x00,0x46,0xac,0x80,0x00,0x24,0xac,0x80,0x00,0x28,0xac,0x80,0x00,0x2c, -0xac,0x80,0x00,0x30,0xac,0x80,0x00,0x34,0xac,0x80,0x00,0x38,0xac,0x80,0x00,0x3c, -0x03,0xe0,0x00,0x08,0xac,0x80,0x00,0x40,0x84,0x83,0x00,0x0c,0x3c,0x07,0xb0,0x03, -0x34,0xe7,0x00,0x20,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80, -0x27,0x83,0x90,0x04,0x00,0x43,0x10,0x21,0x8c,0x48,0x00,0x18,0x3c,0x02,0x80,0x00, -0x24,0x42,0x1c,0x28,0xac,0xe2,0x00,0x00,0x8d,0x03,0x00,0x08,0x80,0x82,0x00,0x13, -0x00,0x05,0x2c,0x00,0x00,0x03,0x1e,0x02,0x00,0x02,0x12,0x00,0x30,0x63,0x00,0x7e, -0x00,0x62,0x18,0x21,0x00,0x65,0x18,0x21,0x3c,0x02,0xc0,0x00,0x3c,0x05,0xb0,0x05, -0x34,0x42,0x04,0x00,0x24,0x63,0x00,0x01,0x3c,0x07,0xb0,0x05,0x3c,0x08,0xb0,0x05, -0x34,0xa5,0x04,0x20,0xac,0xa3,0x00,0x00,0x00,0xc2,0x30,0x21,0x34,0xe7,0x04,0x24, -0x35,0x08,0x02,0x28,0x24,0x02,0x00,0x01,0x24,0x03,0x00,0x20,0xac,0xe6,0x00,0x00, -0xac,0x82,0x00,0x3c,0x03,0xe0,0x00,0x08,0xa1,0x03,0x00,0x00,0x27,0xbd,0xff,0xa8, -0x00,0x07,0x60,0x80,0x27,0x82,0xb4,0x00,0xaf,0xbe,0x00,0x50,0xaf,0xb7,0x00,0x4c, -0xaf,0xb5,0x00,0x44,0xaf,0xb4,0x00,0x40,0xaf,0xbf,0x00,0x54,0xaf,0xb6,0x00,0x48, -0xaf,0xb3,0x00,0x3c,0xaf,0xb2,0x00,0x38,0xaf,0xb1,0x00,0x34,0xaf,0xb0,0x00,0x30, -0x01,0x82,0x10,0x21,0x8c,0x43,0x00,0x00,0x00,0xe0,0x70,0x21,0x3c,0x02,0x80,0x00, -0x94,0x73,0x00,0x14,0x3c,0x07,0xb0,0x03,0x34,0xe7,0x00,0x20,0x24,0x42,0x1c,0xbc, -0x3c,0x03,0xb0,0x05,0xac,0xe2,0x00,0x00,0x34,0x63,0x01,0x28,0x90,0x67,0x00,0x00, -0x00,0x13,0xa8,0xc0,0x02,0xb3,0x18,0x21,0x27,0x82,0x90,0x04,0x00,0x03,0x18,0x80, -0x00,0x62,0x18,0x21,0x00,0x05,0x2c,0x00,0x00,0x07,0x3e,0x00,0x28,0xc2,0x00,0x03, -0x00,0xc0,0xa0,0x21,0x00,0x80,0x78,0x21,0x00,0x05,0xbc,0x03,0x8c,0x68,0x00,0x18, -0x02,0xa0,0x58,0x21,0x10,0x40,0x01,0x81,0x00,0x07,0xf6,0x03,0x00,0xde,0x10,0x07, -0x30,0x5e,0x00,0x01,0x01,0x73,0x10,0x21,0x27,0x83,0x90,0x08,0x00,0x02,0x10,0x80, -0x00,0x43,0x10,0x21,0x80,0x4d,0x00,0x06,0x8d,0x03,0x00,0x00,0x8d,0x02,0x00,0x04, -0x8d,0x0a,0x00,0x08,0x8d,0x03,0x00,0x0c,0xaf,0xa2,0x00,0x20,0x11,0xa0,0x01,0x71, -0xaf,0xa3,0x00,0x18,0x27,0x82,0xb4,0x00,0x01,0x82,0x10,0x21,0x8c,0x44,0x00,0x00, -0x00,0x00,0x00,0x00,0x90,0x83,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x04, -0x14,0x60,0x00,0x12,0x00,0x00,0xb0,0x21,0x3c,0x02,0xb0,0x09,0x34,0x42,0x01,0x46, -0x90,0x43,0x00,0x00,0x2a,0x84,0x00,0x04,0x10,0x80,0x01,0x56,0x30,0x65,0x00,0x01, -0x91,0xe2,0x00,0x09,0x00,0x00,0x00,0x00,0x12,0x82,0x00,0x02,0x00,0x00,0x00,0x00, -0x00,0x00,0x28,0x21,0x14,0xa0,0x00,0x03,0x00,0x00,0x38,0x21,0x13,0xc0,0x00,0x03, -0x38,0xf6,0x00,0x01,0x24,0x07,0x00,0x01,0x38,0xf6,0x00,0x01,0x01,0x73,0x10,0x21, -0x00,0x02,0x30,0x80,0x27,0x83,0x90,0x10,0x00,0xc3,0x48,0x21,0x91,0x25,0x00,0x00, -0x8f,0xa4,0x00,0x20,0x2c,0xa3,0x00,0x04,0x00,0x04,0x11,0xc3,0x30,0x42,0x00,0x01, -0x00,0x03,0xb0,0x0b,0x12,0xc0,0x00,0xd8,0xaf,0xa2,0x00,0x24,0x93,0x90,0xbb,0xea, -0x00,0x0a,0x16,0x42,0x30,0x52,0x00,0x3f,0x2e,0x06,0x00,0x0c,0x10,0xc0,0x00,0xc0, -0x00,0xa0,0x20,0x21,0x2c,0xa2,0x00,0x10,0x14,0x40,0x00,0x04,0x00,0x90,0x10,0x2b, -0x30,0xa2,0x00,0x07,0x24,0x44,0x00,0x04,0x00,0x90,0x10,0x2b,0x10,0x40,0x00,0x0b, -0x01,0x73,0x10,0x21,0x27,0x85,0xbb,0x1c,0x00,0x10,0x10,0x40,0x00,0x50,0x10,0x21, -0x00,0x45,0x10,0x21,0x90,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x18,0x2b, -0x14,0x60,0xff,0xfa,0x00,0x10,0x10,0x40,0x01,0x73,0x10,0x21,0x00,0x02,0x10,0x80, -0x27,0x83,0x90,0x08,0x00,0x43,0x10,0x21,0x31,0xa4,0x00,0x01,0x10,0x80,0x00,0xa5, -0xa0,0x50,0x00,0x07,0x3c,0x04,0xb0,0x05,0x34,0x84,0x00,0x08,0x24,0x02,0x00,0x01, -0x3c,0x03,0x80,0x00,0xa1,0xe2,0x00,0x4e,0xac,0x83,0x00,0x00,0x8c,0x85,0x00,0x00, -0x3c,0x02,0x00,0xf0,0x3c,0x03,0x40,0xf0,0x34,0x42,0xf0,0x00,0x34,0x63,0xf0,0x00, -0x24,0x17,0x00,0x0e,0x24,0x13,0x01,0x06,0xac,0x82,0x00,0x00,0xac,0x83,0x00,0x00, -0x27,0x82,0xb4,0x00,0x01,0x82,0x10,0x21,0x8c,0x43,0x00,0x00,0x24,0x05,0x00,0x01, -0xaf,0xa5,0x00,0x1c,0x90,0x62,0x00,0x16,0x00,0x13,0xa8,0xc0,0x32,0x51,0x00,0x02, -0x34,0x42,0x00,0x04,0xa0,0x62,0x00,0x16,0x8f,0xa3,0x00,0x20,0x8f,0xa4,0x00,0x18, -0x00,0x03,0x13,0x43,0x00,0x04,0x1a,0x02,0x30,0x47,0x00,0x01,0x12,0x20,0x00,0x04, -0x30,0x64,0x07,0xff,0x2e,0x03,0x00,0x04,0x32,0x42,0x00,0x33,0x00,0x43,0x90,0x0b, -0x8f,0xa5,0x00,0x24,0x8f,0xa6,0x00,0x1c,0x00,0x12,0x10,0x40,0x00,0x05,0x19,0xc0, -0x00,0x47,0x10,0x21,0x00,0x06,0x2a,0x80,0x00,0x43,0x10,0x21,0x00,0x10,0x32,0x00, -0x00,0x04,0x24,0x80,0x02,0x65,0x28,0x21,0x00,0xa4,0x28,0x21,0x00,0x46,0x10,0x21, -0x00,0x17,0x1c,0x00,0x3c,0x04,0xc0,0x00,0x00,0x43,0x30,0x21,0x16,0x80,0x00,0x29, -0x00,0xa4,0x28,0x21,0x3c,0x02,0xb0,0x05,0x34,0x42,0x04,0x00,0x3c,0x03,0xb0,0x05, -0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00,0x34,0x63,0x04,0x04,0x34,0x84,0x02,0x28, -0x24,0x02,0x00,0x01,0xac,0x65,0x00,0x00,0xa0,0x82,0x00,0x00,0x3c,0x02,0xb0,0x09, -0x34,0x42,0x01,0x46,0x90,0x44,0x00,0x00,0x91,0xe3,0x00,0x09,0x30,0x86,0x00,0x01, -0x02,0x83,0x18,0x26,0x00,0x03,0x30,0x0b,0x14,0xc0,0x00,0x03,0x00,0x00,0x28,0x21, -0x13,0xc0,0x00,0x03,0x02,0xb3,0x10,0x21,0x24,0x05,0x00,0x01,0x02,0xb3,0x10,0x21, -0x27,0x83,0x90,0x08,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x84,0x48,0x00,0x04, -0x00,0xa0,0x30,0x21,0x00,0xe0,0x20,0x21,0x02,0x80,0x28,0x21,0x02,0xc0,0x38,0x21, -0x0c,0x00,0x00,0x70,0xaf,0xa8,0x00,0x10,0x7b,0xbe,0x02,0xbc,0x7b,0xb6,0x02,0x7c, -0x7b,0xb4,0x02,0x3c,0x7b,0xb2,0x01,0xfc,0x7b,0xb0,0x01,0xbc,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x58,0x24,0x02,0x00,0x01,0x12,0x82,0x00,0x3d,0x3c,0x02,0xb0,0x05, -0x24,0x02,0x00,0x02,0x12,0x82,0x00,0x31,0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x03, -0x12,0x82,0x00,0x25,0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x10,0x12,0x82,0x00,0x19, -0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x11,0x12,0x82,0x00,0x0d,0x3c,0x02,0xb0,0x05, -0x24,0x02,0x00,0x12,0x16,0x82,0xff,0xd1,0x3c,0x02,0xb0,0x05,0x3c,0x03,0xb0,0x05, -0x34,0x42,0x04,0x20,0x3c,0x04,0xb0,0x05,0x34,0x63,0x04,0x24,0xac,0x46,0x00,0x00, -0x34,0x84,0x02,0x28,0xac,0x65,0x00,0x00,0x08,0x00,0x07,0xe6,0x24,0x02,0x00,0x20, -0x34,0x42,0x04,0x40,0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00, -0x34,0x63,0x04,0x44,0x34,0x84,0x02,0x28,0x24,0x02,0x00,0x40,0x08,0x00,0x07,0xe6, -0xac,0x65,0x00,0x00,0x34,0x42,0x04,0x28,0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05, -0xac,0x46,0x00,0x00,0x34,0x63,0x04,0x2c,0x34,0x84,0x02,0x28,0x24,0x02,0xff,0x80, -0x08,0x00,0x07,0xe6,0xac,0x65,0x00,0x00,0x34,0x42,0x04,0x18,0x3c,0x03,0xb0,0x05, -0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00,0x34,0x63,0x04,0x1c,0x34,0x84,0x02,0x28, -0x24,0x02,0x00,0x08,0x08,0x00,0x07,0xe6,0xac,0x65,0x00,0x00,0x34,0x42,0x04,0x10, -0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00,0x34,0x63,0x04,0x14, -0x34,0x84,0x02,0x28,0x24,0x02,0x00,0x04,0x08,0x00,0x07,0xe6,0xac,0x65,0x00,0x00, -0x34,0x42,0x04,0x08,0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,0xac,0x46,0x00,0x00, -0x34,0x63,0x04,0x0c,0x34,0x84,0x02,0x28,0x24,0x02,0x00,0x02,0x08,0x00,0x07,0xe6, -0xac,0x65,0x00,0x00,0x24,0x17,0x00,0x14,0x08,0x00,0x07,0xb8,0x24,0x13,0x01,0x02, -0x30,0xa2,0x00,0x07,0x24,0x44,0x00,0x0c,0x00,0x90,0x18,0x2b,0x10,0x60,0x00,0x0c, -0x26,0x02,0x00,0x04,0x27,0x85,0xbb,0x1c,0x00,0x10,0x10,0x40,0x00,0x50,0x10,0x21, -0x00,0x45,0x10,0x21,0x90,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x18,0x2b, -0x14,0x60,0xff,0xfa,0x00,0x10,0x10,0x40,0x2e,0x06,0x00,0x0c,0x26,0x02,0x00,0x04, -0x08,0x00,0x07,0xa2,0x00,0x46,0x80,0x0a,0x27,0x82,0xb4,0x00,0x01,0x82,0x20,0x21, -0x8c,0x87,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0xe2,0x00,0x19,0x00,0x00,0x00,0x00, -0x14,0x40,0x00,0x07,0x00,0x00,0x00,0x00,0x27,0x82,0x90,0x20,0x00,0xc2,0x10,0x21, -0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x60,0x00,0x14,0x00,0x00,0x00,0x00, -0x90,0xe3,0x00,0x16,0x27,0x82,0x90,0x08,0x00,0xc2,0x10,0x21,0x34,0x63,0x00,0x20, -0x90,0x50,0x00,0x07,0xa0,0xe3,0x00,0x16,0x8c,0x84,0x00,0x00,0x00,0x0a,0x1e,0x42, -0x24,0x06,0x00,0x01,0x90,0x82,0x00,0x16,0x30,0x71,0x00,0x02,0x30,0x72,0x00,0x3f, -0x30,0x42,0x00,0xfb,0x24,0x17,0x00,0x18,0x24,0x13,0x01,0x03,0x24,0x15,0x08,0x18, -0xaf,0xa6,0x00,0x1c,0x08,0x00,0x07,0xc2,0xa0,0x82,0x00,0x16,0x8d,0x02,0x00,0x04, -0x00,0x0a,0x1c,0x42,0x30,0x42,0x00,0x10,0x14,0x40,0x00,0x15,0x30,0x72,0x00,0x3f, -0x81,0x22,0x00,0x05,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x11,0x30,0x72,0x00,0x3e, -0x27,0x83,0x90,0x18,0x00,0xc3,0x18,0x21,0x80,0x64,0x00,0x00,0x27,0x83,0xb5,0x78, -0x00,0x04,0x11,0x00,0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x23, -0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x05,0x90,0x43,0x00,0x04, -0x00,0x00,0x00,0x00,0x00,0x64,0x18,0x24,0x30,0x63,0x00,0x01,0x02,0x43,0x90,0x25, -0x27,0x85,0xb4,0x00,0x01,0x85,0x28,0x21,0x8c,0xa6,0x00,0x00,0x01,0x73,0x10,0x21, -0x27,0x83,0x90,0x10,0x90,0xc4,0x00,0x16,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21, -0x30,0x84,0x00,0xdf,0x90,0x50,0x00,0x00,0xa0,0xc4,0x00,0x16,0x80,0xc6,0x00,0x12, -0x8c,0xa3,0x00,0x00,0x2d,0xc4,0x00,0x02,0xaf,0xa6,0x00,0x1c,0x90,0x62,0x00,0x16, -0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xfb,0x14,0x80,0x00,0x06,0xa0,0x62,0x00,0x16, -0x24,0x02,0x00,0x06,0x11,0xc2,0x00,0x03,0x24,0x02,0x00,0x04,0x15,0xc2,0xff,0x0e, -0x32,0x51,0x00,0x02,0x32,0x51,0x00,0x02,0x2e,0x02,0x00,0x0c,0x14,0x40,0x00,0x0f, -0x00,0x11,0x18,0x2b,0x32,0x02,0x00,0x0f,0x34,0x42,0x00,0x10,0x00,0x03,0x19,0x00, -0x00,0x43,0x18,0x21,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xe0,0xa0,0x43,0x00,0x00, -0x00,0x00,0x20,0x21,0x02,0x00,0x28,0x21,0x0c,0x00,0x02,0x03,0xaf,0xaf,0x00,0x28, -0x8f,0xaf,0x00,0x28,0x08,0x00,0x07,0xc2,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0xbd, -0x32,0x03,0x00,0xff,0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x42,0x90,0x62,0x00,0x00, -0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x0f,0x14,0x40,0xfe,0xaa,0x00,0x00,0x00,0x00, -0x91,0xe2,0x00,0x09,0x00,0x00,0x00,0x00,0x02,0x82,0x10,0x26,0x08,0x00,0x07,0x79, -0x00,0x02,0x28,0x0b,0x08,0x00,0x07,0x7f,0x00,0x00,0xb0,0x21,0x24,0x02,0x00,0x10, -0x10,0xc2,0x00,0x08,0x24,0x02,0x00,0x11,0x10,0xc2,0xfe,0x7d,0x00,0x07,0x17,0x83, -0x24,0x02,0x00,0x12,0x14,0xc2,0xfe,0x7b,0x00,0x07,0x17,0x43,0x08,0x00,0x07,0x59, -0x30,0x5e,0x00,0x01,0x08,0x00,0x07,0x59,0x00,0x07,0xf7,0xc2,0x00,0x04,0x10,0x40, -0x27,0x83,0x80,0x1c,0x00,0x43,0x10,0x21,0x00,0x80,0x40,0x21,0x94,0x44,0x00,0x00, -0x2d,0x07,0x00,0x04,0x24,0xc2,0x00,0x03,0x00,0x47,0x30,0x0a,0x00,0x86,0x00,0x18, -0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x23,0x8c, -0xac,0x62,0x00,0x00,0x2d,0x06,0x00,0x10,0x00,0x00,0x20,0x12,0x00,0x04,0x22,0x42, -0x24,0x84,0x00,0x01,0x24,0x83,0x00,0xc0,0x10,0xe0,0x00,0x0b,0x24,0x82,0x00,0x60, -0x00,0x40,0x20,0x21,0x00,0x65,0x20,0x0a,0x3c,0x03,0xb0,0x03,0x34,0x63,0x01,0x00, -0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x00,0x44,0x20,0x04, -0x03,0xe0,0x00,0x08,0x00,0x80,0x10,0x21,0x24,0x85,0x00,0x28,0x24,0x83,0x00,0x24, -0x31,0x02,0x00,0x08,0x14,0xc0,0xff,0xf4,0x24,0x84,0x00,0x14,0x00,0x60,0x20,0x21, -0x08,0x00,0x08,0xfa,0x00,0xa2,0x20,0x0b,0x27,0xbd,0xff,0xe0,0x3c,0x03,0xb0,0x03, -0x3c,0x02,0x80,0x00,0xaf,0xb0,0x00,0x10,0x24,0x42,0x24,0x28,0x00,0x80,0x80,0x21, -0x34,0x63,0x00,0x20,0x3c,0x04,0xb0,0x03,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14, -0xaf,0xbf,0x00,0x1c,0x83,0xb1,0x00,0x33,0x83,0xa8,0x00,0x37,0x34,0x84,0x01,0x10, -0xac,0x62,0x00,0x00,0x2e,0x02,0x00,0x10,0x00,0xe0,0x90,0x21,0x8c,0x87,0x00,0x00, -0x14,0x40,0x00,0x0c,0x2e,0x02,0x00,0x0c,0x3c,0x02,0x00,0x0f,0x34,0x42,0xf0,0x00, -0x00,0xe2,0x10,0x24,0x14,0x40,0x00,0x37,0x32,0x02,0x00,0x08,0x32,0x02,0x00,0x07, -0x27,0x83,0x80,0xcc,0x00,0x43,0x10,0x21,0x90,0x50,0x00,0x00,0x00,0x00,0x00,0x00, -0x2e,0x02,0x00,0x0c,0x14,0x40,0x00,0x03,0x02,0x00,0x20,0x21,0x32,0x02,0x00,0x0f, -0x24,0x44,0x00,0x0c,0x00,0x87,0x10,0x06,0x30,0x42,0x00,0x01,0x14,0x40,0x00,0x07, -0x2c,0x82,0x00,0x0c,0x00,0x04,0x10,0x80,0x27,0x83,0xb4,0x50,0x00,0x43,0x10,0x21, -0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0x82,0x00,0x0c,0x14,0x40,0x00,0x05, -0x00,0x05,0x10,0x40,0x00,0x46,0x10,0x21,0x00,0x02,0x11,0x00,0x00,0x82,0x10,0x21, -0x24,0x44,0x00,0x04,0x15,0x00,0x00,0x02,0x24,0x06,0x00,0x20,0x24,0x06,0x00,0x0e, -0x0c,0x00,0x08,0xe3,0x00,0x00,0x00,0x00,0x00,0x40,0x30,0x21,0x3c,0x02,0xb0,0x03, -0x34,0x42,0x01,0x00,0x90,0x43,0x00,0x00,0x2e,0x04,0x00,0x04,0x24,0x02,0x00,0x10, -0x24,0x05,0x00,0x0a,0x00,0x44,0x28,0x0a,0x30,0x63,0x00,0x01,0x14,0x60,0x00,0x02, -0x00,0x05,0x10,0x40,0x00,0xa0,0x10,0x21,0x30,0x45,0x00,0xff,0x00,0xc5,0x10,0x21, -0x24,0x46,0x00,0x46,0x02,0x26,0x18,0x04,0xa6,0x43,0x00,0x00,0x8f,0xbf,0x00,0x1c, -0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x00,0xc0,0x10,0x21,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x20,0x10,0x40,0xff,0xcf,0x2e,0x02,0x00,0x0c,0x32,0x02,0x00,0x07, -0x27,0x83,0x80,0xc4,0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x00,0x08,0x00,0x09,0x28, -0x02,0x04,0x80,0x23,0x27,0xbd,0xff,0xb8,0x00,0x05,0x38,0x80,0x27,0x82,0xb4,0x00, -0xaf,0xbe,0x00,0x40,0xaf,0xb6,0x00,0x38,0xaf,0xb3,0x00,0x2c,0xaf,0xbf,0x00,0x44, -0xaf,0xb7,0x00,0x3c,0xaf,0xb5,0x00,0x34,0xaf,0xb4,0x00,0x30,0xaf,0xb2,0x00,0x28, -0xaf,0xb1,0x00,0x24,0xaf,0xb0,0x00,0x20,0x00,0xe2,0x38,0x21,0x8c,0xe6,0x00,0x00, -0xaf,0xa5,0x00,0x4c,0x3c,0x02,0x80,0x00,0x3c,0x05,0xb0,0x03,0x34,0xa5,0x00,0x20, -0x24,0x42,0x25,0x84,0x24,0x03,0x00,0x01,0xac,0xa2,0x00,0x00,0xa0,0xc3,0x00,0x12, -0x8c,0xe5,0x00,0x00,0x94,0xc3,0x00,0x06,0x90,0xa2,0x00,0x16,0xa4,0xc3,0x00,0x14, -0x27,0x83,0x90,0x00,0x34,0x42,0x00,0x08,0xa0,0xa2,0x00,0x16,0x8c,0xe8,0x00,0x00, -0xaf,0xa4,0x00,0x48,0x27,0x82,0x90,0x04,0x95,0x11,0x00,0x14,0x00,0x00,0x00,0x00, -0x00,0x11,0x98,0xc0,0x02,0x71,0x20,0x21,0x00,0x04,0x20,0x80,0x00,0x82,0x10,0x21, -0x8c,0x52,0x00,0x18,0x00,0x83,0x18,0x21,0x84,0x75,0x00,0x06,0x8e,0x45,0x00,0x08, -0x8e,0x46,0x00,0x04,0x8e,0x47,0x00,0x04,0x00,0x05,0x1c,0x82,0x00,0x06,0x31,0x42, -0x27,0x82,0x90,0x10,0x30,0x63,0x00,0x01,0x30,0xc6,0x00,0x01,0x00,0x82,0x20,0x21, -0xa5,0x15,0x00,0x1a,0x00,0x05,0x14,0x42,0xaf,0xa3,0x00,0x18,0xaf,0xa6,0x00,0x1c, -0x30,0xe7,0x00,0x10,0x30,0x56,0x00,0x01,0x80,0x97,0x00,0x06,0x14,0xe0,0x00,0x47, -0x00,0x05,0xf7,0xc2,0x80,0x82,0x00,0x05,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x44, -0x02,0x71,0x10,0x21,0x93,0x90,0xbb,0xe9,0x00,0x00,0x00,0x00,0x2e,0x02,0x00,0x0c, -0x14,0x40,0x00,0x06,0x02,0x00,0x20,0x21,0x00,0x16,0x10,0x40,0x00,0x43,0x10,0x21, -0x00,0x02,0x11,0x00,0x02,0x02,0x10,0x21,0x24,0x44,0x00,0x04,0x02,0x71,0x10,0x21, -0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x10,0x00,0x43,0x10,0x21,0x00,0x80,0x80,0x21, -0xa0,0x44,0x00,0x03,0xa0,0x44,0x00,0x00,0x02,0x00,0x20,0x21,0x02,0xc0,0x28,0x21, -0x0c,0x00,0x08,0xe3,0x02,0xa0,0x30,0x21,0x02,0x71,0x18,0x21,0x00,0x03,0x88,0x80, -0x00,0x40,0xa0,0x21,0x27,0x82,0x90,0x20,0x02,0x22,0x10,0x21,0x8c,0x44,0x00,0x00, -0x26,0xe3,0x00,0x02,0x00,0x03,0x17,0xc2,0x00,0x62,0x18,0x21,0x00,0x04,0x25,0xc2, -0x00,0x03,0x18,0x43,0x30,0x84,0x00,0x01,0x00,0x03,0x18,0x40,0x03,0xc4,0x20,0x24, -0x14,0x80,0x00,0x15,0x02,0x43,0x38,0x21,0x3c,0x08,0xb0,0x03,0x35,0x08,0x00,0x28, -0x8d,0x03,0x00,0x00,0x8f,0xa6,0x00,0x4c,0x8f,0xa4,0x00,0x48,0x27,0x82,0x90,0x08, -0x02,0x22,0x10,0x21,0x24,0x63,0x00,0x01,0x02,0xa0,0x28,0x21,0xa4,0x54,0x00,0x04, -0x00,0xc0,0x38,0x21,0x0c,0x00,0x07,0x2f,0xad,0x03,0x00,0x00,0x7b,0xbe,0x02,0x3c, -0x7b,0xb6,0x01,0xfc,0x7b,0xb4,0x01,0xbc,0x7b,0xb2,0x01,0x7c,0x7b,0xb0,0x01,0x3c, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x48,0x8f,0xa2,0x00,0x1c,0x8f,0xa6,0x00,0x18, -0x02,0x00,0x20,0x21,0x02,0xc0,0x28,0x21,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x09,0x0a, -0xaf,0xa0,0x00,0x14,0x08,0x00,0x09,0xc6,0x02,0x82,0xa0,0x21,0x02,0x71,0x10,0x21, -0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x10,0x00,0x43,0x10,0x21,0x90,0x50,0x00,0x00, -0x08,0x00,0x09,0xb2,0xa0,0x50,0x00,0x03,0x27,0xbd,0xff,0xb8,0xaf,0xb1,0x00,0x24, -0x8f,0xb1,0x00,0x5c,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20, -0x24,0x42,0x27,0xa8,0xaf,0xbe,0x00,0x40,0xaf,0xb7,0x00,0x3c,0xaf,0xb6,0x00,0x38, -0xaf,0xb5,0x00,0x34,0xaf,0xb4,0x00,0x30,0xaf,0xa5,0x00,0x4c,0x8f,0xb5,0x00,0x58, -0xaf,0xbf,0x00,0x44,0xaf,0xb3,0x00,0x2c,0xaf,0xb2,0x00,0x28,0xaf,0xb0,0x00,0x20, -0x00,0xe0,0xb0,0x21,0xac,0x62,0x00,0x00,0x00,0x80,0xf0,0x21,0x00,0x00,0xb8,0x21, -0x16,0x20,0x00,0x2b,0x00,0x00,0xa0,0x21,0x27,0x85,0xb4,0x00,0x00,0x07,0x10,0x80, -0x00,0x45,0x10,0x21,0x8c,0x53,0x00,0x00,0x00,0x15,0x18,0x80,0x00,0x65,0x18,0x21, -0x92,0x62,0x00,0x16,0x8c,0x72,0x00,0x00,0x30,0x42,0x00,0x03,0x14,0x40,0x00,0x2d, -0x00,0x00,0x00,0x00,0x92,0x42,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x03, -0x14,0x40,0x00,0x28,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x34,0x00,0x00,0x00,0x00, -0x14,0x40,0x00,0x18,0x02,0x20,0x10,0x21,0x8c,0x82,0x00,0x38,0x00,0x00,0x00,0x00, -0x14,0x40,0x00,0x14,0x02,0x20,0x10,0x21,0x8c,0x82,0x00,0x3c,0x00,0x00,0x00,0x00, -0x14,0x40,0x00,0x0f,0x3c,0x03,0xb0,0x09,0x3c,0x05,0xb0,0x05,0x34,0x63,0x01,0x44, -0x34,0xa5,0x02,0x52,0x94,0x66,0x00,0x00,0x90,0xa2,0x00,0x00,0x8f,0xa3,0x00,0x4c, -0x00,0x00,0x00,0x00,0x00,0x62,0x10,0x06,0x30,0x42,0x00,0x01,0x10,0x40,0x00,0x04, -0x30,0xc6,0xff,0xff,0x2c,0xc2,0x00,0x41,0x10,0x40,0x00,0x09,0x24,0x05,0x00,0x14, -0x02,0x20,0x10,0x21,0x7b,0xbe,0x02,0x3c,0x7b,0xb6,0x01,0xfc,0x7b,0xb4,0x01,0xbc, -0x7b,0xb2,0x01,0x7c,0x7b,0xb0,0x01,0x3c,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x48, -0x0c,0x00,0x07,0x0a,0x24,0x06,0x01,0x07,0x24,0x02,0x00,0x01,0x08,0x00,0x0a,0x2c, -0xa3,0xc2,0x00,0x11,0x10,0xc0,0x00,0x1c,0x24,0x02,0x00,0x01,0x10,0xc2,0x00,0x17, -0x00,0xc0,0x88,0x21,0x96,0x54,0x00,0x1a,0x02,0xa0,0xb8,0x21,0x12,0x20,0xff,0xed, -0x02,0x20,0x10,0x21,0x27,0x83,0xb4,0x00,0x00,0x17,0x10,0x80,0x00,0x43,0x10,0x21, -0x8c,0x44,0x00,0x00,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x28,0x80,0x86,0x00,0x12, -0x8c,0x62,0x00,0x00,0x00,0x14,0x2c,0x00,0x00,0x05,0x2c,0x03,0x00,0x46,0x10,0x21, -0x8f,0xa6,0x00,0x4c,0x02,0xe0,0x38,0x21,0x03,0xc0,0x20,0x21,0x0c,0x00,0x07,0x2f, -0xac,0x62,0x00,0x00,0x08,0x00,0x0a,0x2c,0xaf,0xd1,0x00,0x40,0x96,0x74,0x00,0x1a, -0x08,0x00,0x0a,0x3f,0x02,0xc0,0xb8,0x21,0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x08, -0x8c,0x50,0x00,0x00,0x02,0x60,0x20,0x21,0x0c,0x00,0x1e,0xf3,0x02,0x00,0x28,0x21, -0x30,0x42,0x00,0xff,0x02,0x00,0x28,0x21,0x02,0x40,0x20,0x21,0x0c,0x00,0x1e,0xf3, -0xaf,0xa2,0x00,0x18,0x8f,0xa4,0x00,0x18,0x00,0x00,0x00,0x00,0x10,0x80,0x00,0xed, -0x30,0x50,0x00,0xff,0x12,0x00,0x00,0x18,0x24,0x11,0x00,0x01,0x96,0x63,0x00,0x14, -0x96,0x44,0x00,0x14,0x27,0x85,0x90,0x00,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21, -0x00,0x02,0x10,0x80,0x00,0x45,0x10,0x21,0x00,0x04,0x18,0xc0,0x8c,0x46,0x00,0x08, -0x00,0x64,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x65,0x18,0x21,0x00,0x06,0x17,0x02, -0x24,0x04,0x00,0xff,0x8c,0x63,0x00,0x08,0x10,0x44,0x00,0xd6,0x00,0x03,0x17,0x02, -0x10,0x44,0x00,0xd5,0x3c,0x02,0x80,0x00,0x00,0x66,0x18,0x2b,0x24,0x11,0x00,0x02, -0x24,0x02,0x00,0x01,0x00,0x43,0x88,0x0a,0x24,0x02,0x00,0x01,0x12,0x22,0x00,0x5a, -0x24,0x02,0x00,0x02,0x16,0x22,0xff,0xbd,0x00,0x00,0x00,0x00,0x96,0x49,0x00,0x14, -0x27,0x82,0x90,0x04,0x02,0xa0,0xb8,0x21,0x00,0x09,0x50,0xc0,0x01,0x49,0x18,0x21, -0x00,0x03,0x40,0x80,0x01,0x02,0x10,0x21,0x8c,0x43,0x00,0x18,0x00,0x00,0x00,0x00, -0x8c,0x65,0x00,0x08,0x8c,0x62,0x00,0x0c,0x8c,0x62,0x00,0x04,0x00,0x05,0x24,0x42, -0x00,0x05,0x1c,0x82,0x30,0x42,0x00,0x10,0x30,0x66,0x00,0x01,0x14,0x40,0x00,0x41, -0x30,0x87,0x00,0x01,0x27,0x82,0x90,0x18,0x01,0x02,0x10,0x21,0x80,0x44,0x00,0x00, -0x27,0x82,0xb5,0x78,0x00,0x04,0x19,0x00,0x00,0x64,0x18,0x23,0x00,0x03,0x18,0x80, -0x00,0x64,0x18,0x23,0x00,0x03,0x18,0x80,0x00,0x62,0x10,0x21,0x90,0x45,0x00,0x05, -0x27,0x84,0xb4,0xa0,0x00,0x64,0x18,0x21,0x90,0x63,0x00,0x00,0x10,0xa0,0x00,0x2b, -0x2c,0x64,0x00,0x0c,0x14,0x80,0x00,0x04,0x00,0x60,0x10,0x21,0x00,0x06,0x11,0x00, -0x00,0x62,0x10,0x21,0x24,0x42,0x00,0x24,0x3c,0x01,0xb0,0x03,0xa0,0x22,0x00,0xe1, -0x14,0x80,0x00,0x06,0x00,0x60,0x28,0x21,0x00,0x07,0x10,0x40,0x00,0x46,0x10,0x21, -0x00,0x02,0x11,0x00,0x00,0x62,0x10,0x21,0x24,0x45,0x00,0x04,0x01,0x49,0x10,0x21, -0x27,0x83,0x90,0x10,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x00,0xa0,0x18,0x21, -0xa0,0x45,0x00,0x03,0xa0,0x45,0x00,0x00,0x24,0x02,0x00,0x08,0x12,0x02,0x00,0x0b, -0x24,0x02,0x00,0x01,0x00,0x60,0x28,0x21,0x02,0x40,0x20,0x21,0x0c,0x00,0x1f,0x6f, -0xaf,0xa2,0x00,0x10,0x30,0x54,0xff,0xff,0x92,0x42,0x00,0x16,0x00,0x00,0x00,0x00, -0x02,0x02,0x10,0x25,0x08,0x00,0x0a,0x3f,0xa2,0x42,0x00,0x16,0x00,0x60,0x28,0x21, -0x02,0x40,0x20,0x21,0x0c,0x00,0x1f,0x20,0xaf,0xa0,0x00,0x10,0x08,0x00,0x0a,0xc2, -0x30,0x54,0xff,0xff,0x08,0x00,0x0a,0xaa,0x00,0x60,0x10,0x21,0x14,0x80,0xff,0xfd, -0x00,0x00,0x00,0x00,0x00,0x06,0x11,0x00,0x00,0x62,0x10,0x21,0x08,0x00,0x0a,0xaa, -0x24,0x42,0x00,0x04,0x27,0x82,0x90,0x10,0x01,0x02,0x10,0x21,0x90,0x43,0x00,0x00, -0x08,0x00,0x0a,0xba,0xa0,0x43,0x00,0x03,0x96,0x69,0x00,0x14,0x02,0xc0,0xb8,0x21, -0x24,0x0b,0x00,0x01,0x00,0x09,0x10,0xc0,0x00,0x49,0x18,0x21,0x00,0x03,0x40,0x80, -0x00,0x40,0x50,0x21,0x27,0x82,0x90,0x04,0x01,0x02,0x10,0x21,0x8c,0x43,0x00,0x18, -0x00,0x00,0x00,0x00,0x8c,0x65,0x00,0x08,0x8c,0x62,0x00,0x0c,0x8c,0x62,0x00,0x04, -0x00,0x05,0x24,0x42,0x00,0x05,0x1c,0x82,0x30,0x42,0x00,0x10,0x30,0x66,0x00,0x01, -0x10,0x40,0x00,0x0d,0x30,0x87,0x00,0x01,0x27,0x82,0x90,0x18,0x01,0x02,0x10,0x21, -0x80,0x43,0x00,0x00,0x00,0x00,0x58,0x21,0x00,0x03,0x11,0x00,0x00,0x43,0x10,0x23, -0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x23,0x00,0x02,0x10,0x80,0x27,0x83,0xb5,0x70, -0x00,0x43,0x10,0x21,0xa0,0x40,0x00,0x04,0x11,0x60,0x00,0x4f,0x00,0x00,0x00,0x00, -0x01,0x49,0x10,0x21,0x00,0x02,0x20,0x80,0x27,0x85,0x90,0x10,0x00,0x85,0x10,0x21, -0x80,0x43,0x00,0x05,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x42,0x01,0x49,0x10,0x21, -0x27,0x82,0x90,0x18,0x00,0x82,0x10,0x21,0x80,0x44,0x00,0x00,0x27,0x82,0xb5,0x78, -0x00,0x04,0x19,0x00,0x00,0x64,0x18,0x23,0x00,0x03,0x18,0x80,0x00,0x64,0x18,0x23, -0x00,0x03,0x18,0x80,0x00,0x62,0x10,0x21,0x90,0x45,0x00,0x05,0x27,0x84,0xb4,0xa0, -0x00,0x64,0x18,0x21,0x90,0x63,0x00,0x00,0x10,0xa0,0x00,0x2c,0x2c,0x64,0x00,0x0c, -0x14,0x80,0x00,0x04,0x00,0x60,0x10,0x21,0x00,0x06,0x11,0x00,0x00,0x62,0x10,0x21, -0x24,0x42,0x00,0x24,0x3c,0x01,0xb0,0x03,0xa0,0x22,0x00,0xe1,0x14,0x80,0x00,0x06, -0x00,0x60,0x28,0x21,0x00,0x07,0x10,0x40,0x00,0x46,0x10,0x21,0x00,0x02,0x11,0x00, -0x00,0x62,0x10,0x21,0x24,0x45,0x00,0x04,0x01,0x49,0x10,0x21,0x27,0x83,0x90,0x10, -0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x00,0xa0,0x18,0x21,0xa0,0x45,0x00,0x03, -0xa0,0x45,0x00,0x00,0x8f,0xa4,0x00,0x18,0x24,0x02,0x00,0x08,0x10,0x82,0x00,0x0c, -0x00,0x60,0x28,0x21,0x24,0x02,0x00,0x01,0x02,0x60,0x20,0x21,0x0c,0x00,0x1f,0x6f, -0xaf,0xa2,0x00,0x10,0x8f,0xa3,0x00,0x18,0x30,0x54,0xff,0xff,0x92,0x62,0x00,0x16, -0x00,0x00,0x00,0x00,0x00,0x62,0x10,0x25,0x08,0x00,0x0a,0x3f,0xa2,0x62,0x00,0x16, -0x02,0x60,0x20,0x21,0x0c,0x00,0x1f,0x20,0xaf,0xa0,0x00,0x10,0x08,0x00,0x0b,0x31, -0x00,0x00,0x00,0x00,0x08,0x00,0x0b,0x19,0x00,0x60,0x10,0x21,0x14,0x80,0xff,0xfd, -0x00,0x00,0x00,0x00,0x00,0x06,0x11,0x00,0x00,0x62,0x10,0x21,0x08,0x00,0x0b,0x19, -0x24,0x42,0x00,0x04,0x00,0x02,0x10,0x80,0x00,0x45,0x10,0x21,0x90,0x43,0x00,0x00, -0x08,0x00,0x0b,0x29,0xa0,0x43,0x00,0x03,0x27,0x85,0x90,0x10,0x08,0x00,0x0b,0x45, -0x01,0x49,0x10,0x21,0x3c,0x02,0x80,0x00,0x00,0x62,0x18,0x26,0x08,0x00,0x0a,0x7a, -0x00,0xc2,0x30,0x26,0x12,0x00,0xff,0x2d,0x24,0x02,0x00,0x01,0x08,0x00,0x0a,0x7f, -0x24,0x11,0x00,0x02,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xd0, -0x24,0x42,0x2d,0x54,0x34,0x63,0x00,0x20,0x3c,0x05,0xb0,0x05,0xaf,0xb3,0x00,0x24, -0xaf,0xb2,0x00,0x20,0xaf,0xb1,0x00,0x1c,0xaf,0xbf,0x00,0x28,0xaf,0xb0,0x00,0x18, -0xac,0x62,0x00,0x00,0x34,0xa5,0x02,0x42,0x90,0xa2,0x00,0x00,0x00,0x80,0x90,0x21, -0x24,0x11,0x00,0x10,0x30,0x53,0x00,0xff,0x24,0x02,0x00,0x10,0x12,0x22,0x00,0xcf, -0x00,0x00,0x18,0x21,0x24,0x02,0x00,0x11,0x12,0x22,0x00,0xc1,0x24,0x02,0x00,0x12, -0x12,0x22,0x00,0xb4,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0xad,0xae,0x43,0x00,0x40, -0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2c,0x8c,0x44,0x00,0x00,0x3c,0x03,0x00,0x02, -0x34,0x63,0x00,0xff,0x00,0x83,0x80,0x24,0x00,0x10,0x14,0x43,0x10,0x40,0x00,0x05, -0x00,0x00,0x00,0x00,0x8e,0x42,0x00,0x34,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x92, -0x00,0x00,0x00,0x00,0x93,0x83,0x8b,0x71,0x00,0x00,0x00,0x00,0x30,0x62,0x00,0x02, -0x10,0x40,0x00,0x04,0x32,0x10,0x00,0xff,0x00,0x10,0x11,0xc3,0x14,0x40,0x00,0x86, -0x00,0x00,0x00,0x00,0x16,0x00,0x00,0x15,0x02,0x00,0x10,0x21,0x26,0x22,0x00,0x01, -0x30,0x51,0x00,0xff,0x2e,0x23,0x00,0x13,0x14,0x60,0xff,0xdb,0x24,0x03,0x00,0x02, -0x12,0x63,0x00,0x73,0x24,0x02,0x00,0x05,0x2a,0x62,0x00,0x03,0x10,0x40,0x00,0x58, -0x24,0x02,0x00,0x04,0x24,0x02,0x00,0x01,0x12,0x62,0x00,0x4b,0x02,0x40,0x20,0x21, -0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2c,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00, -0x30,0x70,0x00,0xff,0x12,0x00,0x00,0x06,0x02,0x00,0x10,0x21,0x8f,0xbf,0x00,0x28, -0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x30, -0x92,0x46,0x00,0x04,0x8e,0x43,0x00,0x24,0x24,0x02,0x00,0x07,0x02,0x40,0x20,0x21, -0x00,0x00,0x28,0x21,0x24,0x07,0x00,0x06,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x09,0xea, -0xaf,0xa3,0x00,0x14,0xae,0x42,0x00,0x24,0x3c,0x02,0xb0,0x05,0x8c,0x42,0x02,0x2c, -0x00,0x00,0x00,0x00,0x30,0x50,0x00,0xff,0x16,0x00,0xff,0xec,0x02,0x00,0x10,0x21, -0x92,0x46,0x00,0x05,0x8e,0x43,0x00,0x28,0x24,0x02,0x00,0x05,0x02,0x40,0x20,0x21, -0x24,0x05,0x00,0x01,0x24,0x07,0x00,0x04,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x09,0xea, -0xaf,0xa3,0x00,0x14,0xae,0x42,0x00,0x28,0x3c,0x02,0xb0,0x05,0x8c,0x42,0x02,0x2c, -0x00,0x00,0x00,0x00,0x30,0x50,0x00,0xff,0x16,0x00,0xff,0xdc,0x02,0x00,0x10,0x21, -0x92,0x46,0x00,0x06,0x8e,0x43,0x00,0x2c,0x24,0x02,0x00,0x03,0x02,0x40,0x20,0x21, -0x24,0x05,0x00,0x02,0x00,0x00,0x38,0x21,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x09,0xea, -0xaf,0xa3,0x00,0x14,0xae,0x42,0x00,0x2c,0x3c,0x02,0xb0,0x05,0x8c,0x42,0x02,0x2c, -0x00,0x00,0x00,0x00,0x30,0x50,0x00,0xff,0x16,0x00,0xff,0xcc,0x02,0x00,0x10,0x21, -0x92,0x46,0x00,0x07,0x8e,0x43,0x00,0x30,0x24,0x02,0x00,0x02,0x02,0x40,0x20,0x21, -0x24,0x05,0x00,0x03,0x24,0x07,0x00,0x01,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x09,0xea, -0xaf,0xa3,0x00,0x14,0xae,0x42,0x00,0x30,0x3c,0x02,0xb0,0x05,0x8c,0x42,0x02,0x2c, -0x08,0x00,0x0b,0x9b,0x30,0x42,0x00,0xff,0x92,0x46,0x00,0x04,0x8e,0x43,0x00,0x24, -0x24,0x02,0x00,0x07,0x00,0x00,0x28,0x21,0x24,0x07,0x00,0x06,0xaf,0xa2,0x00,0x10, -0x0c,0x00,0x09,0xea,0xaf,0xa3,0x00,0x14,0x08,0x00,0x0b,0x94,0xae,0x42,0x00,0x24, -0x12,0x62,0x00,0x0d,0x24,0x02,0x00,0x03,0x24,0x02,0x00,0x08,0x16,0x62,0xff,0xa8, -0x02,0x40,0x20,0x21,0x92,0x46,0x00,0x07,0x8e,0x42,0x00,0x30,0x24,0x05,0x00,0x03, -0x24,0x07,0x00,0x01,0xaf,0xa3,0x00,0x10,0x0c,0x00,0x09,0xea,0xaf,0xa2,0x00,0x14, -0x08,0x00,0x0b,0x94,0xae,0x42,0x00,0x30,0x92,0x46,0x00,0x06,0x8e,0x43,0x00,0x2c, -0x02,0x40,0x20,0x21,0x24,0x05,0x00,0x02,0x00,0x00,0x38,0x21,0xaf,0xa2,0x00,0x10, -0x0c,0x00,0x09,0xea,0xaf,0xa3,0x00,0x14,0x08,0x00,0x0b,0x94,0xae,0x42,0x00,0x2c, -0x92,0x46,0x00,0x05,0x8e,0x43,0x00,0x28,0x02,0x40,0x20,0x21,0x24,0x05,0x00,0x01, -0x24,0x07,0x00,0x04,0xaf,0xa2,0x00,0x10,0x0c,0x00,0x09,0xea,0xaf,0xa3,0x00,0x14, -0x08,0x00,0x0b,0x94,0xae,0x42,0x00,0x28,0x0c,0x00,0x01,0x57,0x24,0x04,0x00,0x01, -0x08,0x00,0x0b,0x85,0x00,0x00,0x00,0x00,0x8f,0x84,0xb4,0x40,0xae,0x40,0x00,0x34, -0x94,0x85,0x00,0x14,0x0c,0x00,0x1b,0x66,0x00,0x00,0x00,0x00,0x93,0x83,0x8b,0x71, -0x00,0x00,0x00,0x00,0x30,0x62,0x00,0x02,0x10,0x40,0xff,0x69,0x00,0x00,0x00,0x00, -0x0c,0x00,0x01,0x57,0x00,0x00,0x20,0x21,0x08,0x00,0x0b,0x7d,0x00,0x00,0x00,0x00, -0x02,0x40,0x20,0x21,0x0c,0x00,0x09,0x61,0x02,0x20,0x28,0x21,0x08,0x00,0x0b,0x71, -0x3c,0x02,0xb0,0x05,0x8e,0x42,0x00,0x3c,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x4a, -0x00,0x00,0x00,0x00,0x8f,0x82,0xb4,0x48,0x00,0x00,0x00,0x00,0x90,0x42,0x00,0x0a, -0x00,0x00,0x00,0x00,0x00,0x02,0x18,0x2b,0x08,0x00,0x0b,0x6e,0xae,0x43,0x00,0x3c, -0x8e,0x42,0x00,0x38,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x3d,0x24,0x02,0x00,0x12, -0x8f,0x82,0xb4,0x44,0x00,0x00,0x00,0x00,0x90,0x42,0x00,0x0a,0x00,0x00,0x00,0x00, -0x00,0x02,0x18,0x2b,0x08,0x00,0x0b,0x6e,0xae,0x43,0x00,0x38,0x8e,0x42,0x00,0x34, -0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x30,0x24,0x02,0x00,0x11,0x8f,0x82,0xb4,0x40, -0x00,0x00,0x00,0x00,0x90,0x42,0x00,0x0a,0x00,0x00,0x00,0x00,0x00,0x02,0x18,0x2b, -0x08,0x00,0x0b,0x6e,0xae,0x43,0x00,0x34,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00, -0x27,0xbd,0xff,0xe0,0x34,0x63,0x00,0x20,0x24,0x42,0x31,0x08,0x3c,0x08,0xb0,0x03, -0xaf,0xb1,0x00,0x14,0xac,0x62,0x00,0x00,0x35,0x08,0x01,0x00,0xaf,0xbf,0x00,0x18, -0xaf,0xb0,0x00,0x10,0x91,0x03,0x00,0x00,0x00,0xa0,0x48,0x21,0x24,0x11,0x00,0x0a, -0x2c,0xa5,0x00,0x04,0x24,0x02,0x00,0x10,0x00,0x45,0x88,0x0a,0x30,0x63,0x00,0x01, -0x00,0xc0,0x28,0x21,0x14,0x60,0x00,0x02,0x00,0x11,0x40,0x40,0x02,0x20,0x40,0x21, -0x84,0x83,0x00,0x0c,0x31,0x11,0x00,0xff,0x01,0x20,0x20,0x21,0x00,0x03,0x10,0xc0, -0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x08,0x00,0x43,0x10,0x21, -0x84,0x43,0x00,0x04,0x24,0x06,0x00,0x0e,0x10,0xe0,0x00,0x06,0x02,0x23,0x80,0x21, -0x02,0x00,0x10,0x21,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x20,0x0c,0x00,0x08,0xe3,0x00,0x00,0x00,0x00,0x02,0x11,0x18,0x21, -0x08,0x00,0x0c,0x64,0x00,0x62,0x80,0x21,0x27,0xbd,0xff,0xd0,0xaf,0xbf,0x00,0x28, -0xaf,0xb4,0x00,0x20,0xaf,0xb3,0x00,0x1c,0xaf,0xb2,0x00,0x18,0xaf,0xb5,0x00,0x24, -0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0x84,0x82,0x00,0x0c,0x3c,0x06,0xb0,0x03, -0x34,0xc6,0x00,0x20,0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21,0x00,0x03,0x18,0x80, -0x27,0x82,0x90,0x04,0x00,0x62,0x10,0x21,0x8c,0x55,0x00,0x18,0x3c,0x02,0x80,0x00, -0x24,0x42,0x31,0xb8,0xac,0xc2,0x00,0x00,0x8e,0xb0,0x00,0x08,0x27,0x82,0x90,0x08, -0x00,0x62,0x18,0x21,0x90,0x71,0x00,0x07,0x00,0x10,0x86,0x43,0x32,0x10,0x00,0x01, -0x00,0xa0,0x38,0x21,0x02,0x00,0x30,0x21,0x00,0xa0,0x98,0x21,0x02,0x20,0x28,0x21, -0x0c,0x00,0x0c,0x42,0x00,0x80,0x90,0x21,0x02,0x20,0x20,0x21,0x02,0x00,0x28,0x21, -0x24,0x06,0x00,0x14,0x0c,0x00,0x08,0xe3,0x00,0x40,0xa0,0x21,0x86,0x43,0x00,0x0c, -0x3c,0x09,0xb0,0x09,0x3c,0x08,0xb0,0x09,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21, -0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x10,0x00,0x43,0x10,0x21,0x80,0x43,0x00,0x06, -0x3c,0x07,0xb0,0x09,0x3c,0x05,0xb0,0x09,0x28,0x62,0x00,0x00,0x24,0x64,0x00,0x03, -0x00,0x82,0x18,0x0b,0x00,0x03,0x18,0x83,0x3c,0x02,0xb0,0x09,0x00,0x03,0x18,0x80, -0x34,0x42,0x01,0x02,0x35,0x29,0x01,0x10,0x35,0x08,0x01,0x14,0x34,0xe7,0x01,0x20, -0x34,0xa5,0x01,0x24,0xa4,0x54,0x00,0x00,0x12,0x60,0x00,0x11,0x02,0xa3,0xa8,0x21, -0x8e,0xa2,0x00,0x0c,0x8e,0xa3,0x00,0x08,0x00,0x02,0x14,0x00,0x00,0x03,0x1c,0x02, -0x00,0x43,0x10,0x21,0xad,0x22,0x00,0x00,0x8e,0xa3,0x00,0x0c,0x00,0x00,0x00,0x00, -0x00,0x03,0x1c,0x02,0xa5,0x03,0x00,0x00,0x8f,0xbf,0x00,0x28,0x7b,0xb4,0x01,0x3c, -0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x30, -0x8e,0xa2,0x00,0x04,0x00,0x00,0x00,0x00,0xad,0x22,0x00,0x00,0x8e,0xa4,0x00,0x08, -0x00,0x00,0x00,0x00,0xa5,0x04,0x00,0x00,0x7a,0xa2,0x00,0x7c,0x00,0x00,0x00,0x00, -0x00,0x03,0x1c,0x00,0x00,0x02,0x14,0x02,0x00,0x62,0x18,0x21,0xac,0xe3,0x00,0x00, -0x8e,0xa2,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x02,0x14,0x02,0x08,0x00,0x0c,0xb6, -0xa4,0xa2,0x00,0x00,0x27,0xbd,0xff,0xe0,0xaf,0xb2,0x00,0x18,0xaf,0xb0,0x00,0x10, -0xaf,0xbf,0x00,0x1c,0xaf,0xb1,0x00,0x14,0x84,0x82,0x00,0x0c,0x00,0x80,0x90,0x21, -0x3c,0x05,0xb0,0x03,0x00,0x02,0x20,0xc0,0x00,0x82,0x20,0x21,0x00,0x04,0x20,0x80, -0x27,0x82,0x90,0x04,0x00,0x82,0x10,0x21,0x8c,0x51,0x00,0x18,0x3c,0x02,0x80,0x00, -0x34,0xa5,0x00,0x20,0x24,0x42,0x33,0x34,0x27,0x83,0x90,0x08,0xac,0xa2,0x00,0x00, -0x00,0x83,0x20,0x21,0x3c,0x02,0xb0,0x03,0x90,0x86,0x00,0x07,0x34,0x42,0x01,0x00, -0x8e,0x23,0x00,0x08,0x90,0x44,0x00,0x00,0x2c,0xc5,0x00,0x04,0x24,0x02,0x00,0x10, -0x24,0x10,0x00,0x0a,0x00,0x45,0x80,0x0a,0x00,0x03,0x1e,0x43,0x30,0x84,0x00,0x01, -0x30,0x65,0x00,0x01,0x14,0x80,0x00,0x02,0x00,0x10,0x10,0x40,0x02,0x00,0x10,0x21, -0x00,0xc0,0x20,0x21,0x24,0x06,0x00,0x20,0x0c,0x00,0x08,0xe3,0x30,0x50,0x00,0xff, -0x86,0x44,0x00,0x0c,0x27,0x85,0x90,0x10,0x3c,0x06,0xb0,0x09,0x00,0x04,0x18,0xc0, -0x00,0x64,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x65,0x18,0x21,0x80,0x64,0x00,0x06, -0x00,0x50,0x10,0x21,0x34,0xc6,0x01,0x02,0x24,0x85,0x00,0x03,0x28,0x83,0x00,0x00, -0x00,0xa3,0x20,0x0b,0x00,0x04,0x20,0x83,0x00,0x04,0x20,0x80,0xa4,0xc2,0x00,0x00, -0x02,0x24,0x20,0x21,0x8c,0x83,0x00,0x04,0x3c,0x02,0xb0,0x09,0x34,0x42,0x01,0x10, -0xac,0x43,0x00,0x00,0x8c,0x86,0x00,0x08,0x3c,0x02,0xb0,0x09,0x34,0x42,0x01,0x14, -0xa4,0x46,0x00,0x00,0x8c,0x85,0x00,0x0c,0x8c,0x82,0x00,0x08,0x3c,0x06,0xb0,0x09, -0x00,0x05,0x2c,0x00,0x00,0x02,0x14,0x02,0x00,0xa2,0x28,0x21,0x34,0xc6,0x01,0x20, -0xac,0xc5,0x00,0x00,0x8c,0x83,0x00,0x0c,0x3c,0x05,0xb0,0x09,0x34,0xa5,0x01,0x24, -0x00,0x03,0x1c,0x02,0xa4,0xa3,0x00,0x00,0x92,0x42,0x00,0x0a,0x3c,0x03,0xb0,0x09, -0x34,0x63,0x01,0x30,0x00,0x02,0x13,0x00,0x24,0x42,0x00,0x04,0x30,0x42,0xff,0xff, -0xa4,0x62,0x00,0x00,0x86,0x44,0x00,0x0c,0x27,0x83,0x90,0x18,0x8f,0xbf,0x00,0x1c, -0x00,0x04,0x10,0xc0,0x00,0x44,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21, -0x94,0x44,0x00,0x02,0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x3c,0x05,0xb0,0x09, -0x34,0xa5,0x01,0x32,0xa4,0xa4,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20, -0x27,0xbd,0xff,0xe0,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x00,0xaf,0xb0,0x00,0x10, -0x34,0x42,0x00,0x20,0x00,0xa0,0x80,0x21,0x24,0x63,0x34,0xc0,0x00,0x05,0x2c,0x43, -0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x18,0xac,0x43,0x00,0x00,0x10,0xa0,0x00,0x05, -0x00,0x80,0x88,0x21,0x8c,0x82,0x00,0x34,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0xb6, -0x00,0x00,0x00,0x00,0x32,0x10,0x00,0xff,0x12,0x00,0x00,0x4c,0x00,0x00,0x10,0x21, -0x24,0x02,0x00,0x08,0x12,0x02,0x00,0xa3,0x2a,0x02,0x00,0x09,0x10,0x40,0x00,0x89, -0x24,0x02,0x00,0x40,0x24,0x04,0x00,0x02,0x12,0x04,0x00,0x79,0x2a,0x02,0x00,0x03, -0x10,0x40,0x00,0x69,0x24,0x02,0x00,0x04,0x24,0x02,0x00,0x01,0x12,0x02,0x00,0x5a, -0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x05,0x34,0x42,0x00,0x08,0x3c,0x03,0x80,0x00, -0xa2,0x20,0x00,0x4e,0xac,0x43,0x00,0x00,0x82,0x24,0x00,0x11,0x92,0x27,0x00,0x11, -0x10,0x80,0x00,0x4e,0x00,0x00,0x00,0x00,0x92,0x26,0x00,0x0a,0x24,0x02,0x00,0x12, -0x10,0x46,0x00,0x09,0x30,0xc2,0x00,0xff,0x27,0x83,0xb4,0x00,0x00,0x02,0x10,0x80, -0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x94,0x83,0x00,0x14, -0x00,0x00,0x00,0x00,0xa6,0x23,0x00,0x0c,0x3c,0x02,0xb0,0x09,0x34,0x42,0x00,0x40, -0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x03,0xa2,0x23,0x00,0x10, -0x14,0x60,0x00,0x2b,0x30,0x65,0x00,0x01,0x30,0xc2,0x00,0xff,0x27,0x83,0xb4,0x00, -0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x82,0x23,0x00,0x12, -0x90,0x82,0x00,0x16,0x00,0x00,0x00,0x00,0x00,0x02,0x11,0x42,0x30,0x42,0x00,0x01, -0x00,0x62,0x18,0x21,0x00,0x03,0x26,0x00,0x14,0x80,0x00,0x18,0xa2,0x23,0x00,0x12, -0x00,0x07,0x16,0x00,0x14,0x40,0x00,0x11,0x24,0x02,0x00,0x01,0x96,0x23,0x00,0x0c, -0x27,0x84,0x90,0x10,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80, -0x00,0x44,0x10,0x21,0x80,0x45,0x00,0x06,0x00,0x03,0x1a,0x00,0x3c,0x02,0xb0,0x00, -0x00,0x65,0x18,0x21,0x00,0x62,0x18,0x21,0x90,0x64,0x00,0x00,0x90,0x62,0x00,0x04, -0xa2,0x20,0x00,0x15,0xa3,0x80,0x8b,0xd4,0x24,0x02,0x00,0x01,0x8f,0xbf,0x00,0x18, -0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x0c,0x00,0x0c,0xcd, -0x02,0x20,0x20,0x21,0x92,0x27,0x00,0x11,0x08,0x00,0x0d,0x7d,0x00,0x07,0x16,0x00, -0x0c,0x00,0x0c,0x6e,0x02,0x20,0x20,0x21,0x86,0x23,0x00,0x0c,0x27,0x84,0x90,0x08, -0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x44,0x20,0x21, -0x90,0x85,0x00,0x07,0x27,0x83,0x90,0x10,0x00,0x43,0x10,0x21,0xa2,0x25,0x00,0x13, -0x90,0x83,0x00,0x07,0x08,0x00,0x0d,0x95,0xa0,0x43,0x00,0x02,0x92,0x26,0x00,0x0a, -0x08,0x00,0x0d,0x5e,0x30,0xc2,0x00,0xff,0x8e,0x22,0x00,0x24,0x00,0x00,0x00,0x00, -0x10,0x50,0x00,0x07,0xa2,0x20,0x00,0x08,0x24,0x02,0x00,0x07,0xa2,0x22,0x00,0x0a, -0x92,0x22,0x00,0x27,0xae,0x20,0x00,0x24,0x08,0x00,0x0d,0x51,0xa2,0x22,0x00,0x04, -0x08,0x00,0x0d,0xaf,0x24,0x02,0x00,0x06,0x16,0x02,0xff,0x9b,0x3c,0x02,0xb0,0x05, -0x8e,0x23,0x00,0x2c,0x24,0x02,0x00,0x01,0x10,0x62,0x00,0x07,0xa2,0x24,0x00,0x08, -0x24,0x02,0x00,0x03,0xa2,0x22,0x00,0x0a,0x92,0x22,0x00,0x2f,0xae,0x20,0x00,0x2c, -0x08,0x00,0x0d,0x51,0xa2,0x22,0x00,0x06,0x08,0x00,0x0d,0xbe,0xa2,0x20,0x00,0x0a, -0x8e,0x22,0x00,0x28,0x24,0x03,0x00,0x01,0x24,0x04,0x00,0x01,0x10,0x44,0x00,0x07, -0xa2,0x23,0x00,0x08,0x24,0x02,0x00,0x05,0xa2,0x22,0x00,0x0a,0x92,0x22,0x00,0x2b, -0xae,0x20,0x00,0x28,0x08,0x00,0x0d,0x51,0xa2,0x22,0x00,0x05,0x08,0x00,0x0d,0xca, -0x24,0x02,0x00,0x04,0x12,0x02,0x00,0x12,0x2a,0x02,0x00,0x41,0x10,0x40,0x00,0x09, -0x24,0x02,0x00,0x80,0x24,0x02,0x00,0x20,0x16,0x02,0xff,0x7b,0x3c,0x02,0xb0,0x05, -0x24,0x02,0x00,0x12,0xa2,0x22,0x00,0x0a,0xa2,0x22,0x00,0x08,0x08,0x00,0x0d,0x51, -0xae,0x20,0x00,0x3c,0x16,0x02,0xff,0x74,0x3c,0x02,0xb0,0x05,0x24,0x02,0x00,0x10, -0xa2,0x22,0x00,0x0a,0xa2,0x22,0x00,0x08,0x08,0x00,0x0d,0x51,0xae,0x20,0x00,0x34, -0x24,0x02,0x00,0x11,0xa2,0x22,0x00,0x0a,0xa2,0x22,0x00,0x08,0x08,0x00,0x0d,0x51, -0xae,0x20,0x00,0x38,0x8e,0x24,0x00,0x30,0x24,0x02,0x00,0x03,0x24,0x03,0x00,0x01, -0x10,0x83,0x00,0x07,0xa2,0x22,0x00,0x08,0x24,0x02,0x00,0x02,0xa2,0x22,0x00,0x0a, -0x92,0x22,0x00,0x33,0xae,0x20,0x00,0x30,0x08,0x00,0x0d,0x51,0xa2,0x22,0x00,0x07, -0x08,0x00,0x0d,0xf0,0xa2,0x24,0x00,0x0a,0x8f,0x84,0xb4,0x40,0xae,0x20,0x00,0x34, -0x94,0x85,0x00,0x14,0x0c,0x00,0x1b,0x66,0x32,0x10,0x00,0xff,0x08,0x00,0x0d,0x42, -0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x24,0x42,0x37,0xf4, -0x34,0x63,0x00,0x20,0xac,0x62,0x00,0x00,0x80,0xa2,0x00,0x15,0x3c,0x06,0xb0,0x05, -0x10,0x40,0x00,0x0a,0x34,0xc6,0x02,0x54,0x83,0x83,0x8b,0xd4,0x00,0x00,0x00,0x00, -0xac,0x83,0x00,0x24,0x8c,0xc2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x17,0x42, -0x30,0x42,0x00,0x01,0x03,0xe0,0x00,0x08,0xac,0x82,0x00,0x28,0x8c,0x82,0x00,0x2c, -0x3c,0x06,0xb0,0x05,0x34,0xc6,0x04,0x50,0x00,0x02,0x18,0x43,0x30,0x63,0x00,0x01, -0x10,0x40,0x00,0x04,0x30,0x45,0x00,0x01,0xac,0x83,0x00,0x28,0x03,0xe0,0x00,0x08, -0xac,0x85,0x00,0x24,0x90,0xc2,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff, -0x30,0x43,0x00,0x02,0x30,0x42,0x00,0x01,0xac,0x83,0x00,0x28,0x03,0xe0,0x00,0x08, -0xac,0x82,0x00,0x24,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xd8, -0x34,0x63,0x00,0x20,0x24,0x42,0x38,0x84,0xac,0x62,0x00,0x00,0xaf,0xb1,0x00,0x1c, -0xaf,0xbf,0x00,0x20,0xaf,0xb0,0x00,0x18,0x90,0xa6,0x00,0x0a,0x27,0x83,0xb4,0x00, -0x00,0xa0,0x88,0x21,0x00,0x06,0x10,0x80,0x00,0x43,0x10,0x21,0x8c,0x50,0x00,0x00, -0x80,0xa5,0x00,0x11,0x92,0x03,0x00,0x12,0x10,0xa0,0x00,0x04,0xa2,0x20,0x00,0x15, -0x24,0x02,0x00,0x12,0x10,0xc2,0x00,0xda,0x00,0x00,0x00,0x00,0x82,0x22,0x00,0x12, -0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x67,0x00,0x00,0x00,0x00,0xa2,0x20,0x00,0x12, -0xa2,0x00,0x00,0x19,0x86,0x23,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x03,0x10,0xc0, -0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x20,0x00,0x43,0x10,0x21, -0xa0,0x40,0x00,0x00,0x92,0x03,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0xdf, -0xa2,0x03,0x00,0x16,0x82,0x02,0x00,0x12,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x20, -0x00,0x00,0x00,0x00,0x92,0x23,0x00,0x08,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x45, -0x24,0x02,0x00,0x01,0xa2,0x20,0x00,0x04,0x92,0x08,0x00,0x04,0x00,0x00,0x00,0x00, -0x15,0x00,0x00,0x1e,0x24,0x02,0x00,0x01,0x92,0x07,0x00,0x0a,0xa2,0x02,0x00,0x17, -0x92,0x02,0x00,0x16,0x30,0xe3,0x00,0xff,0x30,0x42,0x00,0xe4,0x10,0x60,0x00,0x03, -0xa2,0x02,0x00,0x16,0x34,0x42,0x00,0x01,0xa2,0x02,0x00,0x16,0x11,0x00,0x00,0x05, -0x00,0x00,0x00,0x00,0x92,0x02,0x00,0x16,0x00,0x00,0x00,0x00,0x34,0x42,0x00,0x02, -0xa2,0x02,0x00,0x16,0x92,0x02,0x00,0x17,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x08, -0x00,0x00,0x00,0x00,0x96,0x02,0x00,0x06,0x00,0x00,0x00,0x00,0xa6,0x02,0x00,0x14, -0x8f,0xbf,0x00,0x20,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28, -0x96,0x02,0x00,0x00,0x08,0x00,0x0e,0x6c,0xa6,0x02,0x00,0x14,0x92,0x07,0x00,0x0a, -0x00,0x00,0x00,0x00,0x14,0xe0,0x00,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0x0e,0x58, -0xa2,0x00,0x00,0x17,0x96,0x04,0x00,0x00,0x96,0x05,0x00,0x06,0x27,0x86,0x90,0x00, -0x00,0x04,0x18,0xc0,0x00,0x64,0x18,0x21,0x00,0x05,0x10,0xc0,0x00,0x45,0x10,0x21, -0x00,0x03,0x18,0x80,0x00,0x66,0x18,0x21,0x00,0x02,0x10,0x80,0x00,0x46,0x10,0x21, -0x8c,0x66,0x00,0x08,0x8c,0x45,0x00,0x08,0x3c,0x03,0x80,0x00,0x00,0xc3,0x20,0x24, -0x10,0x80,0x00,0x08,0x00,0xa3,0x10,0x24,0x10,0x40,0x00,0x04,0x00,0x00,0x18,0x21, -0x10,0x80,0x00,0x02,0x24,0x03,0x00,0x01,0x00,0xa6,0x18,0x2b,0x08,0x00,0x0e,0x58, -0xa2,0x03,0x00,0x17,0x10,0x40,0xff,0xfd,0x00,0xa6,0x18,0x2b,0x08,0x00,0x0e,0x8c, -0x00,0x00,0x00,0x00,0x10,0x62,0x00,0x09,0x24,0x02,0x00,0x02,0x10,0x62,0x00,0x05, -0x24,0x02,0x00,0x03,0x14,0x62,0xff,0xb8,0x00,0x00,0x00,0x00,0x08,0x00,0x0e,0x52, -0xa2,0x20,0x00,0x07,0x08,0x00,0x0e,0x52,0xa2,0x20,0x00,0x06,0x08,0x00,0x0e,0x52, -0xa2,0x20,0x00,0x05,0x82,0x22,0x00,0x10,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x69, -0x2c,0x62,0x00,0x02,0x10,0x40,0x00,0x49,0x3c,0x02,0xb0,0x09,0x92,0x25,0x00,0x08, -0x00,0x00,0x00,0x00,0x30,0xa6,0x00,0xff,0x2c,0xc2,0x00,0x04,0x10,0x40,0x00,0x3b, -0x2c,0xc2,0x00,0x10,0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00, -0x24,0x02,0x00,0x01,0x00,0xc2,0x10,0x04,0x00,0x02,0x10,0x27,0x00,0x62,0x18,0x24, -0xa0,0x83,0x00,0x00,0x86,0x23,0x00,0x0c,0x96,0x26,0x00,0x0c,0x00,0x03,0x10,0xc0, -0x00,0x43,0x10,0x21,0x00,0x02,0x28,0x80,0x27,0x83,0x90,0x04,0x00,0xa3,0x18,0x21, -0x8c,0x64,0x00,0x18,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x04,0x00,0x00,0x00,0x00, -0x30,0x42,0x00,0x10,0x10,0x40,0x00,0x18,0x24,0x07,0x00,0x01,0x93,0x82,0x8b,0x71, -0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x14,0x40,0x00,0x0a,0x24,0x05,0x00,0x24, -0x00,0x06,0x2c,0x00,0x00,0x05,0x2c,0x03,0x0c,0x00,0x1b,0x66,0x02,0x00,0x20,0x21, -0x92,0x02,0x00,0x16,0xa2,0x00,0x00,0x12,0x30,0x42,0x00,0xe7,0x08,0x00,0x0e,0x49, -0xa2,0x02,0x00,0x16,0xf0,0xc5,0x00,0x06,0x00,0x00,0x28,0x12,0x27,0x82,0x90,0x00, -0x00,0xa2,0x28,0x21,0x0c,0x00,0x01,0x49,0x3c,0x04,0x00,0x80,0x96,0x26,0x00,0x0c, -0x08,0x00,0x0e,0xc9,0x00,0x06,0x2c,0x00,0x27,0x83,0x90,0x10,0x27,0x82,0x90,0x18, -0x00,0xa2,0x10,0x21,0x00,0xa3,0x18,0x21,0x90,0x44,0x00,0x00,0x90,0x65,0x00,0x05, -0x93,0x82,0x80,0x10,0x00,0x00,0x30,0x21,0x0c,0x00,0x21,0x9a,0xaf,0xa2,0x00,0x10, -0x96,0x26,0x00,0x0c,0x08,0x00,0x0e,0xc3,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xcd, -0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x30,0xa5,0x00,0x0f, -0x24,0x02,0x00,0x80,0x08,0x00,0x0e,0xb2,0x00,0xa2,0x10,0x07,0x86,0x26,0x00,0x0c, -0x3c,0x03,0xb0,0x09,0x34,0x42,0x01,0x72,0x34,0x63,0x01,0x78,0x94,0x47,0x00,0x00, -0x8c,0x65,0x00,0x00,0x00,0x06,0x10,0xc0,0x00,0x46,0x10,0x21,0x3c,0x04,0xb0,0x09, -0xae,0x25,0x00,0x1c,0x34,0x84,0x01,0x7c,0x27,0x83,0x90,0x04,0x00,0x02,0x10,0x80, -0x8c,0x85,0x00,0x00,0x00,0x43,0x10,0x21,0x8c,0x43,0x00,0x18,0xae,0x25,0x00,0x20, -0xa6,0x27,0x00,0x18,0x8c,0x66,0x00,0x08,0x02,0x20,0x20,0x21,0x0c,0x00,0x0f,0x19, -0x00,0x00,0x28,0x21,0x86,0x25,0x00,0x18,0x8e,0x26,0x00,0x1c,0x8e,0x27,0x00,0x20, -0x02,0x20,0x20,0x21,0x0c,0x00,0x1c,0x68,0xaf,0xa2,0x00,0x10,0x08,0x00,0x0e,0x49, -0xa2,0x02,0x00,0x12,0x92,0x22,0x00,0x08,0x08,0x00,0x0e,0x49,0xa2,0x22,0x00,0x09, -0xa2,0x20,0x00,0x11,0x80,0x82,0x00,0x50,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x03, -0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xd0,0xac,0x40,0x00,0x00,0x08,0x00,0x0e,0x49, -0xa0,0x80,0x00,0x50,0x94,0x8a,0x00,0x0c,0x24,0x03,0x00,0x24,0x00,0x80,0x70,0x21, -0x3c,0x02,0x80,0x00,0x3c,0x04,0xb0,0x03,0x24,0x42,0x3c,0x64,0xf1,0x43,0x00,0x06, -0x34,0x84,0x00,0x20,0x00,0x00,0x18,0x12,0x00,0xa0,0x68,0x21,0xac,0x82,0x00,0x00, -0x27,0x85,0x90,0x10,0x27,0x82,0x90,0x0f,0x27,0xbd,0xff,0xf8,0x00,0x62,0x60,0x21, -0x00,0x65,0x58,0x21,0x00,0x00,0xc0,0x21,0x11,0xa0,0x00,0xcc,0x00,0x00,0x78,0x21, -0x00,0x0a,0x1c,0x00,0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21, -0x00,0x02,0x10,0x80,0x00,0x45,0x10,0x21,0x91,0x87,0x00,0x00,0x80,0x48,0x00,0x04, -0x03,0xa0,0x60,0x21,0x00,0x0a,0x1c,0x00,0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0, -0x00,0x43,0x10,0x21,0x00,0x02,0x48,0x80,0x27,0x83,0x90,0x04,0xa3,0xa7,0x00,0x00, -0x01,0x23,0x18,0x21,0x8c,0x64,0x00,0x18,0x25,0x02,0xff,0xff,0x00,0x48,0x40,0x0b, -0x8c,0x83,0x00,0x04,0x2d,0x05,0x00,0x07,0x24,0x02,0x00,0x06,0x30,0x63,0x00,0x08, -0x14,0x60,0x00,0x35,0x00,0x45,0x40,0x0a,0x93,0xa7,0x00,0x00,0x27,0x82,0x90,0x18, -0x01,0x22,0x10,0x21,0x30,0xe3,0x00,0xf0,0x38,0x63,0x00,0x50,0x30,0xe5,0x00,0xff, -0x00,0x05,0x20,0x2b,0x00,0x03,0x18,0x2b,0x00,0x64,0x18,0x24,0x90,0x49,0x00,0x00, -0x10,0x60,0x00,0x16,0x30,0xe4,0x00,0x0f,0x24,0x02,0x00,0x04,0x10,0xa2,0x00,0x9d, -0x00,0x00,0x00,0x00,0x11,0xa0,0x00,0x3a,0x2c,0xa2,0x00,0x0c,0x10,0x40,0x00,0x02, -0x24,0x84,0x00,0x0c,0x00,0xe0,0x20,0x21,0x30,0x84,0x00,0xff,0x00,0x04,0x10,0x40, -0x27,0x83,0xbb,0x1c,0x00,0x44,0x10,0x21,0x00,0x43,0x10,0x21,0x90,0x47,0x00,0x00, -0x00,0x00,0x00,0x00,0x2c,0xe3,0x00,0x0c,0xa3,0xa7,0x00,0x00,0x10,0x60,0x00,0x02, -0x24,0xe2,0x00,0x04,0x00,0xe0,0x10,0x21,0xa3,0xa2,0x00,0x00,0x91,0x65,0x00,0x00, -0x91,0x82,0x00,0x00,0x30,0xa3,0x00,0xff,0x00,0x62,0x10,0x2b,0x10,0x40,0x00,0x0e, -0x2c,0x62,0x00,0x0c,0x14,0x40,0x00,0x03,0x00,0x60,0x20,0x21,0x30,0xa2,0x00,0x0f, -0x24,0x44,0x00,0x0c,0x00,0x04,0x10,0x40,0x00,0x44,0x20,0x21,0x27,0x83,0xbb,0x1c, -0x00,0x83,0x18,0x21,0x90,0x62,0x00,0x02,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x05, -0x00,0x09,0x11,0x00,0xa1,0x85,0x00,0x00,0x93,0xa2,0x00,0x00,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x08,0x00,0x49,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x49,0x10,0x23, -0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x21,0x27,0x83,0xb4,0xa8,0x00,0x43,0x10,0x21, -0x90,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0x83,0x00,0x0c,0x14,0x60,0x00,0x06, -0x00,0x80,0x10,0x21,0x00,0x18,0x10,0x40,0x00,0x4f,0x10,0x21,0x00,0x02,0x11,0x00, -0x00,0x82,0x10,0x21,0x24,0x42,0x00,0x04,0x08,0x00,0x0f,0x7a,0xa1,0x82,0x00,0x00, -0x8f,0x8d,0x81,0x5c,0x00,0x00,0x00,0x00,0x01,0xa8,0x10,0x21,0x90,0x43,0x00,0x00, -0x00,0x00,0x00,0x00,0x10,0x60,0xff,0xd1,0x00,0x00,0x28,0x21,0x00,0x06,0x74,0x82, -0x30,0xe2,0x00,0xff,0x2c,0x42,0x00,0x0c,0x14,0x40,0x00,0x03,0x00,0xe0,0x10,0x21, -0x30,0xe2,0x00,0x0f,0x24,0x42,0x00,0x0c,0x30,0x44,0x00,0xff,0xa3,0xa2,0x00,0x00, -0x24,0x02,0x00,0x0c,0x10,0x82,0x00,0x0d,0x00,0x09,0x11,0x00,0x00,0x49,0x10,0x23, -0x00,0x02,0x10,0x80,0x00,0x04,0x18,0x40,0x00,0x49,0x10,0x23,0x00,0x64,0x18,0x21, -0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x27,0x84,0xb4,0xa8,0x00,0x44,0x10,0x21, -0x90,0x47,0x00,0x00,0x00,0x00,0x00,0x00,0xa3,0xa7,0x00,0x00,0x00,0x0a,0x1c,0x00, -0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80, -0x27,0x83,0x90,0x04,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x18,0x00,0x00,0x00,0x00, -0x8c,0x83,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x10,0x14,0x60,0x00,0x33, -0x00,0x06,0x14,0x42,0x00,0x09,0x11,0x00,0x00,0x49,0x10,0x23,0x00,0x02,0x10,0x80, -0x00,0x49,0x10,0x23,0x27,0x83,0xb5,0x78,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21, -0x90,0x44,0x00,0x04,0x90,0x43,0x00,0x05,0x00,0x00,0x00,0x00,0x00,0x64,0xc0,0x24, -0x93,0xa7,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0xe2,0x00,0x0f,0x10,0x40,0x00,0x0f, -0x31,0xcf,0x00,0x01,0x00,0x0a,0x1c,0x00,0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0, -0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x84,0x90,0x00,0x00,0x44,0x10,0x21, -0x84,0x43,0x00,0x06,0x00,0x00,0x00,0x00,0x28,0x63,0x06,0x41,0x14,0x60,0x00,0x04, -0x30,0xe2,0x00,0xff,0x24,0x07,0x00,0x0f,0xa3,0xa7,0x00,0x00,0x30,0xe2,0x00,0xff, -0x2c,0x42,0x00,0x0c,0x14,0x40,0x00,0x06,0x00,0xe0,0x10,0x21,0x00,0x18,0x10,0x40, -0x00,0x4f,0x10,0x21,0x00,0x02,0x11,0x00,0x00,0x47,0x10,0x21,0x24,0x42,0x00,0x04, -0xa3,0xa2,0x00,0x00,0x00,0x40,0x38,0x21,0x01,0xa8,0x10,0x21,0x90,0x43,0x00,0x00, -0x24,0xa4,0x00,0x01,0x30,0x85,0xff,0xff,0x00,0xa3,0x18,0x2b,0x14,0x60,0xff,0xad, -0x30,0xe2,0x00,0xff,0x08,0x00,0x0f,0x67,0x00,0x00,0x00,0x00,0x08,0x00,0x0f,0xc8, -0x30,0x58,0x00,0x01,0x81,0xc2,0x00,0x48,0x00,0x00,0x00,0x00,0x10,0x40,0xff,0x73, -0x00,0x00,0x00,0x00,0x08,0x00,0x0f,0x55,0x00,0x00,0x00,0x00,0x00,0x0a,0x1c,0x00, -0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80, -0x00,0x45,0x10,0x21,0x80,0x48,0x00,0x05,0x91,0x67,0x00,0x00,0x08,0x00,0x0f,0x35, -0x03,0xa0,0x58,0x21,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20, -0x24,0x42,0x40,0x04,0x03,0xe0,0x00,0x08,0xac,0x62,0x00,0x00,0x27,0xbd,0xff,0xc0, -0xaf,0xb7,0x00,0x34,0xaf,0xb6,0x00,0x30,0xaf,0xb5,0x00,0x2c,0xaf,0xb4,0x00,0x28, -0xaf,0xb3,0x00,0x24,0xaf,0xb2,0x00,0x20,0xaf,0xbf,0x00,0x3c,0xaf,0xbe,0x00,0x38, -0xaf,0xb1,0x00,0x1c,0xaf,0xb0,0x00,0x18,0x84,0x82,0x00,0x0c,0x27,0x93,0x90,0x04, -0x3c,0x05,0xb0,0x03,0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21,0x00,0x03,0x18,0x80, -0x00,0x73,0x10,0x21,0x8c,0x5e,0x00,0x18,0x3c,0x02,0x80,0x00,0x34,0xa5,0x00,0x20, -0x24,0x42,0x40,0x1c,0xac,0xa2,0x00,0x00,0x8f,0xd0,0x00,0x08,0x27,0x95,0x90,0x10, -0x00,0x75,0x18,0x21,0x00,0x00,0x28,0x21,0x02,0x00,0x30,0x21,0x90,0x71,0x00,0x00, -0x0c,0x00,0x0f,0x19,0x00,0x80,0xb0,0x21,0x00,0x40,0x90,0x21,0x00,0x10,0x14,0x42, -0x30,0x54,0x00,0x01,0x02,0x40,0x20,0x21,0x00,0x10,0x14,0x82,0x02,0x80,0x28,0x21, -0x12,0x51,0x00,0x23,0x00,0x10,0xbf,0xc2,0x86,0xc3,0x00,0x0c,0x30,0x50,0x00,0x01, -0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x55,0x10,0x21, -0xa0,0x52,0x00,0x00,0x86,0xc3,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x03,0x10,0xc0, -0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x53,0x30,0x21,0x8c,0xc7,0x00,0x18, -0x27,0x83,0x90,0x00,0x00,0x43,0x10,0x21,0x8c,0xe3,0x00,0x04,0x84,0x46,0x00,0x06, -0x00,0x03,0x19,0x42,0x0c,0x00,0x08,0xe3,0x30,0x73,0x00,0x01,0x00,0x40,0x88,0x21, -0x02,0x40,0x20,0x21,0x02,0x80,0x28,0x21,0x16,0xe0,0x00,0x10,0x02,0x00,0x30,0x21, -0x86,0xc2,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21, -0x00,0x03,0x18,0x80,0x27,0x82,0x90,0x08,0x00,0x62,0x18,0x21,0xa4,0x71,0x00,0x04, -0x7b,0xbe,0x01,0xfc,0x7b,0xb6,0x01,0xbc,0x7b,0xb4,0x01,0x7c,0x7b,0xb2,0x01,0x3c, -0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40,0x86,0xc3,0x00,0x0c, -0xaf,0xb3,0x00,0x10,0xaf,0xa0,0x00,0x14,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21, -0x00,0x02,0x10,0x80,0x00,0x55,0x10,0x21,0x80,0x47,0x00,0x06,0x00,0x00,0x00,0x00, -0x24,0xe7,0x00,0x02,0x00,0x07,0x17,0xc2,0x00,0xe2,0x38,0x21,0x00,0x07,0x38,0x43, -0x00,0x07,0x38,0x40,0x0c,0x00,0x09,0x0a,0x03,0xc7,0x38,0x21,0x08,0x00,0x10,0x48, -0x02,0x22,0x88,0x21,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0xd0, -0x34,0x63,0x00,0x20,0x24,0x42,0x41,0xa4,0xaf,0xb2,0x00,0x20,0xac,0x62,0x00,0x00, -0xaf,0xbf,0x00,0x28,0xaf,0xb3,0x00,0x24,0xaf,0xb1,0x00,0x1c,0xaf,0xb0,0x00,0x18, -0x3c,0x02,0xb0,0x03,0x90,0x83,0x00,0x0a,0x34,0x42,0x01,0x04,0x94,0x45,0x00,0x00, -0x00,0x03,0x18,0x80,0x27,0x82,0xb4,0x00,0x00,0x62,0x18,0x21,0x30,0xa6,0xff,0xff, -0x8c,0x71,0x00,0x00,0x80,0x85,0x00,0x12,0x30,0xc9,0x00,0xff,0x00,0x06,0x32,0x02, -0xa4,0x86,0x00,0x44,0xa4,0x89,0x00,0x46,0x82,0x22,0x00,0x12,0x00,0x80,0x90,0x21, -0x10,0xa0,0x00,0x1b,0xa0,0x80,0x00,0x15,0x00,0xc5,0x10,0x2a,0x10,0x40,0x00,0x14, -0x00,0x00,0x00,0x00,0xa2,0x20,0x00,0x19,0x84,0x83,0x00,0x0c,0x00,0x00,0x00,0x00, -0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x20, -0x00,0x43,0x10,0x21,0xa0,0x40,0x00,0x00,0xa0,0x80,0x00,0x12,0x92,0x22,0x00,0x16, -0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xdf,0xa2,0x22,0x00,0x16,0x8f,0xbf,0x00,0x28, -0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x30, -0x0c,0x00,0x10,0x01,0x00,0x00,0x00,0x00,0x08,0x00,0x10,0x97,0x00,0x00,0x00,0x00, -0x28,0x42,0x00,0x02,0x10,0x40,0x01,0x76,0x00,0x00,0x28,0x21,0x94,0x87,0x00,0x0c, -0x00,0x00,0x00,0x00,0x00,0xe0,0x10,0x21,0x00,0x02,0x14,0x00,0x00,0x02,0x14,0x03, -0x00,0x07,0x24,0x00,0x00,0x04,0x24,0x03,0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21, -0x00,0x04,0x28,0xc0,0x00,0xa4,0x28,0x21,0x27,0x82,0x90,0x20,0x00,0x03,0x18,0x80, -0x00,0x62,0x18,0x21,0x00,0x05,0x28,0x80,0x27,0x82,0x90,0x08,0x00,0xa2,0x10,0x21, -0x8c,0x68,0x00,0x00,0x80,0x44,0x00,0x06,0x27,0x82,0x90,0x10,0x00,0x08,0x1d,0x02, -0x00,0xa2,0x28,0x21,0x38,0x84,0x00,0x00,0x30,0x63,0x00,0x01,0x01,0x24,0x30,0x0b, -0x80,0xaa,0x00,0x04,0x80,0xa9,0x00,0x05,0x10,0x60,0x00,0x02,0x00,0x08,0x14,0x02, -0x30,0x46,0x00,0x0f,0x15,0x20,0x00,0x28,0x01,0x49,0x10,0x21,0x15,0x40,0x00,0x11, -0x30,0xe3,0xff,0xff,0x92,0x45,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0xa8,0x00,0xff, -0x2d,0x02,0x00,0x04,0x10,0x40,0x01,0x46,0x2d,0x02,0x00,0x10,0x3c,0x04,0xb0,0x05, -0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x24,0x02,0x00,0x01,0x01,0x02,0x10,0x04, -0x00,0x62,0x18,0x25,0xa0,0x83,0x00,0x00,0x96,0x47,0x00,0x0c,0x00,0x00,0x00,0x00, -0x30,0xe3,0xff,0xff,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x27,0x84,0x90,0x10, -0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x21,0x80,0x45,0x00,0x06,0x00,0x03,0x1a,0x00, -0x3c,0x04,0xb0,0x00,0x00,0x65,0x18,0x21,0x00,0x64,0x20,0x21,0x94,0x82,0x00,0x00, -0x82,0x43,0x00,0x10,0x00,0x02,0x14,0x00,0x14,0x60,0x00,0x06,0x00,0x02,0x3c,0x03, -0x30,0xe2,0x00,0x04,0x14,0x40,0x00,0x04,0x01,0x49,0x10,0x21,0x34,0xe2,0x08,0x00, -0xa4,0x82,0x00,0x00,0x01,0x49,0x10,0x21,0x00,0x02,0x16,0x00,0x00,0x02,0x16,0x03, -0x00,0x46,0x10,0x2a,0x10,0x40,0x00,0x7c,0x00,0x00,0x00,0x00,0x82,0x42,0x00,0x10, -0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0e,0x00,0x00,0x00,0x00,0x86,0x43,0x00,0x0c, -0x25,0x44,0x00,0x01,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80, -0x27,0x83,0x90,0x10,0x00,0x43,0x10,0x21,0xa0,0x44,0x00,0x04,0x92,0x23,0x00,0x16, -0x02,0x40,0x20,0x21,0x30,0x63,0x00,0xfb,0x08,0x00,0x10,0x9c,0xa2,0x23,0x00,0x16, -0x86,0x43,0x00,0x0c,0x25,0x24,0x00,0x01,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21, -0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x10,0x00,0x43,0x10,0x21,0xa0,0x44,0x00,0x05, -0x86,0x45,0x00,0x0c,0x0c,0x00,0x1e,0xea,0x02,0x20,0x20,0x21,0x10,0x40,0x00,0x5a, -0x00,0x00,0x00,0x00,0x92,0x45,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0xa6,0x00,0xff, -0x2c,0xc2,0x00,0x04,0x10,0x40,0x00,0x4c,0x2c,0xc2,0x00,0x10,0x3c,0x04,0xb0,0x05, -0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x24,0x02,0x00,0x01,0x00,0xc2,0x10,0x04, -0x00,0x02,0x10,0x27,0x00,0x62,0x18,0x24,0xa0,0x83,0x00,0x00,0x92,0x45,0x00,0x08, -0x00,0x00,0x00,0x00,0x30,0xa5,0x00,0xff,0x14,0xa0,0x00,0x33,0x24,0x02,0x00,0x01, -0xa2,0x40,0x00,0x04,0x92,0x22,0x00,0x04,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x0c, -0x24,0x02,0x00,0x01,0xa2,0x22,0x00,0x17,0x92,0x22,0x00,0x17,0x00,0x00,0x00,0x00, -0x10,0x40,0x00,0x04,0x00,0x00,0x00,0x00,0x96,0x22,0x00,0x06,0x08,0x00,0x10,0x97, -0xa6,0x22,0x00,0x14,0x96,0x22,0x00,0x00,0x08,0x00,0x10,0x97,0xa6,0x22,0x00,0x14, -0x92,0x22,0x00,0x0a,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x03,0x00,0x00,0x00,0x00, -0x08,0x00,0x11,0x26,0xa2,0x20,0x00,0x17,0x96,0x24,0x00,0x00,0x96,0x25,0x00,0x06, -0x27,0x86,0x90,0x00,0x00,0x04,0x18,0xc0,0x00,0x64,0x18,0x21,0x00,0x05,0x10,0xc0, -0x00,0x45,0x10,0x21,0x00,0x03,0x18,0x80,0x00,0x66,0x18,0x21,0x00,0x02,0x10,0x80, -0x00,0x46,0x10,0x21,0x8c,0x65,0x00,0x08,0x8c,0x44,0x00,0x08,0x3c,0x03,0x80,0x00, -0x00,0xa3,0x30,0x24,0x10,0xc0,0x00,0x08,0x00,0x83,0x10,0x24,0x10,0x40,0x00,0x04, -0x00,0x00,0x18,0x21,0x10,0xc0,0x00,0x02,0x24,0x03,0x00,0x01,0x00,0x85,0x18,0x2b, -0x08,0x00,0x11,0x26,0xa2,0x23,0x00,0x17,0x10,0x40,0xff,0xfd,0x00,0x85,0x18,0x2b, -0x08,0x00,0x11,0x49,0x00,0x00,0x00,0x00,0x10,0xa2,0x00,0x09,0x24,0x02,0x00,0x02, -0x10,0xa2,0x00,0x05,0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xca,0x00,0x00,0x00,0x00, -0x08,0x00,0x11,0x21,0xa2,0x40,0x00,0x07,0x08,0x00,0x11,0x21,0xa2,0x40,0x00,0x06, -0x08,0x00,0x11,0x21,0xa2,0x40,0x00,0x05,0x14,0x40,0xff,0xbe,0x3c,0x04,0xb0,0x05, -0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x30,0xa5,0x00,0x0f,0x24,0x02,0x00,0x80, -0x08,0x00,0x11,0x18,0x00,0xa2,0x10,0x07,0x0c,0x00,0x10,0x07,0x02,0x40,0x20,0x21, -0x08,0x00,0x10,0x97,0x00,0x00,0x00,0x00,0x92,0x45,0x00,0x08,0x00,0x00,0x00,0x00, -0x30,0xa6,0x00,0xff,0x2c,0xc2,0x00,0x04,0x10,0x40,0x00,0x99,0x2c,0xc2,0x00,0x10, -0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00,0x24,0x02,0x00,0x01, -0x00,0xc2,0x10,0x04,0x00,0x02,0x10,0x27,0x00,0x62,0x18,0x24,0xa0,0x83,0x00,0x00, -0x92,0x45,0x00,0x08,0x00,0x00,0x00,0x00,0x30,0xa5,0x00,0xff,0x14,0xa0,0x00,0x80, -0x24,0x02,0x00,0x01,0xa2,0x40,0x00,0x04,0x86,0x43,0x00,0x0c,0x27,0x93,0x90,0x04, -0x96,0x47,0x00,0x0c,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x28,0x80, -0x00,0xb3,0x18,0x21,0x8c,0x64,0x00,0x18,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x04, -0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x10,0x10,0x40,0x00,0x64,0x00,0x00,0x30,0x21, -0x00,0x07,0x1c,0x00,0x00,0x03,0x1c,0x03,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21, -0x00,0x02,0x10,0x80,0x00,0x53,0x10,0x21,0x8c,0x43,0x00,0x18,0x93,0x82,0x8b,0x71, -0x8c,0x64,0x00,0x04,0x30,0x42,0x00,0x01,0x00,0x04,0x21,0x42,0x14,0x40,0x00,0x4d, -0x30,0x90,0x00,0x01,0x00,0x07,0x2c,0x00,0x00,0x05,0x2c,0x03,0x0c,0x00,0x1b,0x66, -0x02,0x20,0x20,0x21,0x96,0x26,0x00,0x06,0x12,0x00,0x00,0x14,0x30,0xc5,0xff,0xff, -0x02,0x60,0x90,0x21,0x00,0x05,0x10,0xc0,0x00,0x45,0x10,0x21,0x00,0x02,0x10,0x80, -0x00,0x52,0x18,0x21,0x92,0x22,0x00,0x0a,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0b, -0x02,0x20,0x20,0x21,0x8c,0x63,0x00,0x18,0x00,0x00,0x00,0x00,0x8c,0x62,0x00,0x04, -0x00,0x00,0x00,0x00,0x00,0x02,0x11,0x42,0x0c,0x00,0x1b,0x66,0x30,0x50,0x00,0x01, -0x96,0x26,0x00,0x06,0x16,0x00,0xff,0xef,0x30,0xc5,0xff,0xff,0x92,0x22,0x00,0x04, -0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x0d,0x24,0x02,0x00,0x01,0xa2,0x22,0x00,0x17, -0x92,0x22,0x00,0x17,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x05,0x00,0x00,0x00,0x00, -0xa6,0x26,0x00,0x14,0x92,0x22,0x00,0x16,0x08,0x00,0x10,0x96,0x30,0x42,0x00,0xc3, -0x96,0x22,0x00,0x00,0x08,0x00,0x11,0xbd,0xa6,0x22,0x00,0x14,0x92,0x22,0x00,0x0a, -0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0x11,0xb8, -0xa2,0x20,0x00,0x17,0x96,0x24,0x00,0x00,0x30,0xc5,0xff,0xff,0x00,0x05,0x18,0xc0, -0x00,0x04,0x10,0xc0,0x00,0x44,0x10,0x21,0x00,0x65,0x18,0x21,0x27,0x84,0x90,0x00, -0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x21,0x00,0x03,0x18,0x80,0x8c,0x45,0x00,0x08, -0x00,0x64,0x18,0x21,0x8c,0x64,0x00,0x08,0x3c,0x02,0x80,0x00,0x00,0xa2,0x38,0x24, -0x10,0xe0,0x00,0x08,0x00,0x82,0x10,0x24,0x10,0x40,0x00,0x04,0x00,0x00,0x18,0x21, -0x10,0xe0,0x00,0x02,0x24,0x03,0x00,0x01,0x00,0x85,0x18,0x2b,0x08,0x00,0x11,0xb8, -0xa2,0x23,0x00,0x17,0x10,0x40,0xff,0xfd,0x00,0x85,0x18,0x2b,0x08,0x00,0x11,0xdc, -0x00,0x00,0x00,0x00,0x24,0x05,0x00,0x24,0xf0,0xe5,0x00,0x06,0x00,0x00,0x28,0x12, -0x27,0x82,0x90,0x00,0x00,0xa2,0x28,0x21,0x0c,0x00,0x01,0x49,0x00,0x00,0x20,0x21, -0x96,0x47,0x00,0x0c,0x08,0x00,0x11,0x9a,0x00,0x07,0x2c,0x00,0x27,0x83,0x90,0x10, -0x27,0x82,0x90,0x18,0x00,0xa2,0x10,0x21,0x00,0xa3,0x18,0x21,0x90,0x44,0x00,0x00, -0x90,0x65,0x00,0x05,0x93,0x82,0x80,0x10,0x24,0x07,0x00,0x01,0x0c,0x00,0x21,0x9a, -0xaf,0xa2,0x00,0x10,0x96,0x47,0x00,0x0c,0x08,0x00,0x11,0x8d,0x00,0x07,0x1c,0x00, -0x10,0xa2,0x00,0x09,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x05,0x24,0x02,0x00,0x03, -0x14,0xa2,0xff,0x7d,0x00,0x00,0x00,0x00,0x08,0x00,0x11,0x7e,0xa2,0x40,0x00,0x07, -0x08,0x00,0x11,0x7e,0xa2,0x40,0x00,0x06,0x08,0x00,0x11,0x7e,0xa2,0x40,0x00,0x05, -0x14,0x40,0xff,0x71,0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00, -0x30,0xa5,0x00,0x0f,0x24,0x02,0x00,0x80,0x08,0x00,0x11,0x75,0x00,0xa2,0x10,0x07, -0x14,0x40,0xfe,0xc3,0x3c,0x04,0xb0,0x05,0x34,0x84,0x02,0x29,0x90,0x83,0x00,0x00, -0x30,0xa5,0x00,0x0f,0x24,0x02,0x00,0x80,0x08,0x00,0x10,0xd0,0x00,0xa2,0x10,0x07, -0x84,0x83,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21, -0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x04,0x00,0x43,0x10,0x21,0x8c,0x47,0x00,0x18, -0x00,0x00,0x00,0x00,0x8c,0xe6,0x00,0x08,0x0c,0x00,0x0f,0x19,0x00,0x00,0x00,0x00, -0x02,0x40,0x20,0x21,0x00,0x00,0x28,0x21,0x00,0x00,0x30,0x21,0x00,0x00,0x38,0x21, -0x0c,0x00,0x1c,0x68,0xaf,0xa2,0x00,0x10,0x00,0x02,0x1e,0x00,0x14,0x60,0xfe,0x6b, -0xa2,0x22,0x00,0x12,0x92,0x43,0x00,0x08,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x40, -0x24,0x02,0x00,0x01,0xa2,0x40,0x00,0x04,0x92,0x28,0x00,0x04,0x00,0x00,0x00,0x00, -0x15,0x00,0x00,0x19,0x24,0x02,0x00,0x01,0x92,0x27,0x00,0x0a,0xa2,0x22,0x00,0x17, -0x92,0x22,0x00,0x17,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x10,0x00,0x00,0x00,0x00, -0x96,0x22,0x00,0x06,0x00,0x00,0x00,0x00,0xa6,0x22,0x00,0x14,0x92,0x22,0x00,0x16, -0x30,0xe3,0x00,0xff,0x30,0x42,0x00,0xc0,0x10,0x60,0x00,0x03,0xa2,0x22,0x00,0x16, -0x34,0x42,0x00,0x01,0xa2,0x22,0x00,0x16,0x11,0x00,0xfe,0x50,0x00,0x00,0x00,0x00, -0x92,0x22,0x00,0x16,0x08,0x00,0x10,0x96,0x34,0x42,0x00,0x02,0x96,0x22,0x00,0x00, -0x08,0x00,0x12,0x3f,0xa6,0x22,0x00,0x14,0x92,0x27,0x00,0x0a,0x00,0x00,0x00,0x00, -0x14,0xe0,0x00,0x03,0x00,0x00,0x00,0x00,0x08,0x00,0x12,0x38,0xa2,0x20,0x00,0x17, -0x96,0x24,0x00,0x00,0x96,0x25,0x00,0x06,0x27,0x86,0x90,0x00,0x00,0x04,0x18,0xc0, -0x00,0x64,0x18,0x21,0x00,0x05,0x10,0xc0,0x00,0x45,0x10,0x21,0x00,0x03,0x18,0x80, -0x00,0x66,0x18,0x21,0x00,0x02,0x10,0x80,0x00,0x46,0x10,0x21,0x8c,0x65,0x00,0x08, -0x8c,0x44,0x00,0x08,0x3c,0x03,0x80,0x00,0x00,0xa3,0x30,0x24,0x10,0xc0,0x00,0x08, -0x00,0x83,0x10,0x24,0x10,0x40,0x00,0x04,0x00,0x00,0x18,0x21,0x10,0xc0,0x00,0x02, -0x24,0x03,0x00,0x01,0x00,0x85,0x18,0x2b,0x08,0x00,0x12,0x38,0xa2,0x23,0x00,0x17, -0x10,0x40,0xff,0xfd,0x00,0x85,0x18,0x2b,0x08,0x00,0x12,0x67,0x00,0x00,0x00,0x00, -0x10,0x62,0x00,0x09,0x24,0x02,0x00,0x02,0x10,0x62,0x00,0x05,0x24,0x02,0x00,0x03, -0x14,0x62,0xff,0xbd,0x00,0x00,0x00,0x00,0x08,0x00,0x12,0x32,0xa2,0x40,0x00,0x07, -0x08,0x00,0x12,0x32,0xa2,0x40,0x00,0x06,0x08,0x00,0x12,0x32,0xa2,0x40,0x00,0x05, -0x3c,0x02,0x80,0x00,0x00,0x82,0x30,0x24,0x10,0xc0,0x00,0x08,0x00,0xa2,0x18,0x24, -0x10,0x60,0x00,0x04,0x00,0x00,0x10,0x21,0x10,0xc0,0x00,0x02,0x24,0x02,0x00,0x01, -0x00,0xa4,0x10,0x2b,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x10,0x60,0xff,0xfd, -0x00,0xa4,0x10,0x2b,0x08,0x00,0x12,0x82,0x00,0x00,0x00,0x00,0x30,0x82,0xff,0xff, -0x00,0x02,0x18,0xc0,0x00,0x62,0x18,0x21,0x27,0x84,0x90,0x10,0x00,0x03,0x18,0x80, -0x00,0x64,0x18,0x21,0x80,0x66,0x00,0x06,0x00,0x02,0x12,0x00,0x3c,0x03,0xb0,0x00, -0x00,0x46,0x10,0x21,0x00,0x45,0x10,0x21,0x03,0xe0,0x00,0x08,0x00,0x43,0x10,0x21, -0x27,0xbd,0xff,0xe0,0x30,0x82,0x00,0x7c,0x30,0x84,0xff,0x00,0xaf,0xbf,0x00,0x1c, -0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0x14,0x40,0x00,0x41, -0x00,0x04,0x22,0x03,0x24,0x02,0x00,0x04,0x3c,0x10,0xb0,0x03,0x8e,0x10,0x00,0x00, -0x10,0x82,0x00,0x32,0x24,0x02,0x00,0x08,0x10,0x82,0x00,0x03,0x32,0x02,0x00,0x20, -0x08,0x00,0x12,0xa8,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x17,0x3c,0x02,0xb0,0x06, -0x34,0x42,0x80,0x24,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x67,0x00,0xff, -0x10,0xe0,0x00,0x23,0x00,0x00,0x88,0x21,0x8f,0x85,0x8f,0xe0,0x00,0x40,0x30,0x21, -0x94,0xa2,0x00,0x08,0x8c,0xc3,0x00,0x00,0x26,0x31,0x00,0x01,0x24,0x42,0x00,0x02, -0x30,0x42,0x01,0xff,0x34,0x63,0x01,0x00,0x02,0x27,0x20,0x2a,0xa4,0xa2,0x00,0x08, -0x14,0x80,0xff,0xf7,0xac,0xc3,0x00,0x00,0x84,0xa3,0x00,0x08,0x3c,0x02,0xb0,0x03, -0x34,0x42,0x00,0x30,0xac,0x43,0x00,0x00,0x27,0x92,0xb4,0x00,0x24,0x11,0x00,0x12, -0x8e,0x44,0x00,0x00,0x26,0x31,0xff,0xff,0x90,0x82,0x00,0x10,0x00,0x00,0x00,0x00, -0x10,0x40,0x00,0x03,0x26,0x52,0x00,0x04,0x0c,0x00,0x18,0xd0,0x00,0x00,0x00,0x00, -0x06,0x21,0xff,0xf7,0x24,0x02,0xff,0xdf,0x02,0x02,0x80,0x24,0x3c,0x01,0xb0,0x03, -0x0c,0x00,0x13,0x1c,0xac,0x30,0x00,0x00,0x08,0x00,0x12,0xa8,0x00,0x00,0x00,0x00, -0x8f,0x85,0x8f,0xe0,0x08,0x00,0x12,0xbe,0x00,0x00,0x00,0x00,0x24,0x02,0xff,0x95, -0x3c,0x03,0xb0,0x03,0x02,0x02,0x80,0x24,0x34,0x63,0x00,0x30,0x3c,0x01,0xb0,0x03, -0xac,0x30,0x00,0x00,0x0c,0x00,0x12,0xe5,0xac,0x60,0x00,0x00,0x08,0x00,0x12,0xa8, -0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x50,0x08,0x00,0x12,0xa8, -0xac,0x46,0x00,0x00,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x4b,0x94,0x3c,0x0b,0xb0,0x03, -0xad,0x6a,0x00,0x20,0x3c,0x08,0x80,0x01,0x25,0x08,0x00,0x00,0x3c,0x09,0x80,0x01, -0x25,0x29,0x03,0x50,0x11,0x09,0x00,0x10,0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x00, -0x25,0x4a,0x4b,0xbc,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,0x3c,0x08,0xb0,0x06, -0x35,0x08,0x80,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x8d,0x09,0x00,0x00, -0x00,0x00,0x00,0x00,0x31,0x29,0x00,0x01,0x00,0x00,0x00,0x00,0x24,0x01,0x00,0x01, -0x15,0x21,0xff,0xf2,0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x4b,0xf8, -0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20,0x3c,0x02,0xb0,0x03,0x8c,0x43,0x00,0x00, -0x00,0x00,0x00,0x00,0x34,0x63,0x00,0x40,0x00,0x00,0x00,0x00,0xac,0x43,0x00,0x00, -0x00,0x00,0x00,0x00,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x4c,0x24,0x3c,0x0b,0xb0,0x03, -0xad,0x6a,0x00,0x20,0x3c,0x02,0x80,0x01,0x24,0x42,0x00,0x00,0x3c,0x03,0x80,0x01, -0x24,0x63,0x03,0x50,0x3c,0x04,0xb0,0x00,0x8c,0x85,0x00,0x00,0x00,0x00,0x00,0x00, -0xac,0x45,0x00,0x00,0x24,0x42,0x00,0x04,0x24,0x84,0x00,0x04,0x00,0x43,0x08,0x2a, -0x14,0x20,0xff,0xf9,0x00,0x00,0x00,0x00,0x0c,0x00,0x13,0x1c,0x00,0x00,0x00,0x00, -0x3c,0x0a,0x80,0x00,0x25,0x4a,0x4c,0x70,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20, -0x3c,0x02,0x80,0x01,0x24,0x42,0x03,0x50,0x3c,0x03,0x80,0x01,0x24,0x63,0x3f,0x24, -0xac,0x40,0x00,0x00,0xac,0x40,0x00,0x04,0xac,0x40,0x00,0x08,0xac,0x40,0x00,0x0c, -0x24,0x42,0x00,0x10,0x00,0x43,0x08,0x2a,0x14,0x20,0xff,0xf9,0x00,0x00,0x00,0x00, -0x3c,0x0a,0x80,0x00,0x25,0x4a,0x4c,0xb0,0x3c,0x0b,0xb0,0x03,0xad,0x6a,0x00,0x20, -0x3c,0x1c,0x80,0x01,0x27,0x9c,0x7f,0xf0,0x27,0x9d,0x8b,0xe0,0x00,0x00,0x00,0x00, -0x27,0x9d,0x8f,0xc8,0x3c,0x0a,0x80,0x00,0x25,0x4a,0x4c,0xd4,0x3c,0x0b,0xb0,0x03, -0xad,0x6a,0x00,0x20,0x40,0x80,0x68,0x00,0x40,0x08,0x60,0x00,0x00,0x00,0x00,0x00, -0x35,0x08,0xff,0x01,0x40,0x88,0x60,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x15,0x62, -0x00,0x00,0x00,0x00,0x24,0x84,0xf8,0x00,0x30,0x87,0x00,0x03,0x00,0x04,0x30,0x40, -0x00,0xc7,0x20,0x23,0x3c,0x02,0xb0,0x0a,0x27,0xbd,0xff,0xe0,0x24,0x03,0xff,0xff, -0x00,0x82,0x20,0x21,0xaf,0xb1,0x00,0x14,0xac,0x83,0x10,0x00,0xaf,0xbf,0x00,0x18, -0xaf,0xb0,0x00,0x10,0x00,0xa0,0x88,0x21,0x24,0x03,0x00,0x01,0x8c,0x82,0x10,0x00, -0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x00,0xc7,0x10,0x23,0x3c,0x03,0xb0,0x0a, -0x00,0x43,0x10,0x21,0x8c,0x50,0x00,0x00,0x0c,0x00,0x13,0x99,0x02,0x20,0x20,0x21, -0x02,0x11,0x80,0x24,0x00,0x50,0x80,0x06,0x02,0x00,0x10,0x21,0x8f,0xbf,0x00,0x18, -0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x27,0xbd,0xff,0xd8, -0xaf,0xb2,0x00,0x18,0x00,0xa0,0x90,0x21,0x24,0x05,0xff,0xff,0xaf,0xb3,0x00,0x1c, -0xaf,0xbf,0x00,0x20,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0x00,0xc0,0x98,0x21, -0x12,0x45,0x00,0x23,0x24,0x84,0xf8,0x00,0x30,0x83,0x00,0x03,0x00,0x04,0x10,0x40, -0x00,0x40,0x88,0x21,0x00,0x60,0x20,0x21,0x00,0x43,0x10,0x23,0x3c,0x03,0xb0,0x0a, -0x00,0x43,0x10,0x21,0xac,0x45,0x10,0x00,0x00,0x40,0x18,0x21,0x24,0x05,0x00,0x01, -0x8c,0x62,0x10,0x00,0x00,0x00,0x00,0x00,0x14,0x45,0xff,0xfd,0x3c,0x02,0xb0,0x0a, -0x02,0x24,0x88,0x23,0x02,0x22,0x88,0x21,0x8e,0x30,0x00,0x00,0x0c,0x00,0x13,0x99, -0x02,0x40,0x20,0x21,0x00,0x12,0x18,0x27,0x02,0x03,0x80,0x24,0x00,0x53,0x10,0x04, -0x02,0x02,0x80,0x25,0xae,0x30,0x00,0x00,0x24,0x03,0x00,0x01,0x8e,0x22,0x10,0x00, -0x00,0x00,0x00,0x00,0x14,0x43,0xff,0xfd,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x20, -0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28, -0x30,0x82,0x00,0x03,0x00,0x04,0x18,0x40,0x00,0x62,0x18,0x23,0x3c,0x04,0xb0,0x0a, -0x00,0x64,0x18,0x21,0xac,0x66,0x00,0x00,0x24,0x04,0x00,0x01,0x8c,0x62,0x10,0x00, -0x00,0x00,0x00,0x00,0x14,0x44,0xff,0xfd,0x00,0x00,0x00,0x00,0x08,0x00,0x13,0x87, -0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x21,0x00,0x64,0x10,0x06,0x30,0x42,0x00,0x01, -0x14,0x40,0x00,0x05,0x00,0x00,0x00,0x00,0x24,0x63,0x00,0x01,0x2c,0x62,0x00,0x20, -0x14,0x40,0xff,0xf9,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21, -0x27,0xbd,0xff,0xe0,0x3c,0x03,0xb0,0x05,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14, -0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x1c,0x00,0x80,0x90,0x21,0x00,0xa0,0x80,0x21, -0x00,0xc0,0x88,0x21,0x34,0x63,0x02,0x2e,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00, -0x30,0x42,0x00,0x01,0x14,0x40,0xff,0xfc,0x24,0x04,0x08,0x24,0x3c,0x05,0x00,0xc0, -0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x03,0x24,0x04,0x08,0x34,0x3c,0x05,0x00,0xc0, -0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x03,0x3c,0x02,0xc0,0x00,0x00,0x10,0x1c,0x00, -0x34,0x42,0x04,0x00,0x3c,0x04,0xb0,0x05,0x3c,0x05,0xb0,0x05,0x24,0x63,0x16,0x09, -0x02,0x22,0x10,0x21,0x34,0x84,0x04,0x20,0x34,0xa5,0x04,0x24,0x3c,0x06,0xb0,0x05, -0xac,0x83,0x00,0x00,0x24,0x07,0x00,0x01,0xac,0xa2,0x00,0x00,0x34,0xc6,0x02,0x28, -0x24,0x02,0x00,0x20,0xae,0x47,0x00,0x3c,0x24,0x04,0x08,0x24,0xa0,0xc2,0x00,0x00, -0x3c,0x05,0x00,0xc0,0xa2,0x47,0x00,0x11,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x01, -0x24,0x04,0x08,0x34,0x3c,0x05,0x00,0xc0,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x01, -0x8f,0xbf,0x00,0x1c,0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x20,0x24,0x02,0x00,0x06,0xac,0x82,0x00,0x0c,0xa0,0x80,0x00,0x50, -0xac,0x80,0x00,0x00,0xac,0x80,0x00,0x04,0xac,0x80,0x00,0x08,0xac,0x80,0x00,0x14, -0xac,0x80,0x00,0x18,0xac,0x80,0x00,0x1c,0xa4,0x80,0x00,0x20,0xac,0x80,0x00,0x24, -0xac,0x80,0x00,0x28,0xac,0x80,0x00,0x2c,0xa0,0x80,0x00,0x30,0xa0,0x80,0x00,0x31, -0xac,0x80,0x00,0x34,0xac,0x80,0x00,0x38,0xa0,0x80,0x00,0x3c,0xac,0x82,0x00,0x10, -0xa0,0x80,0x00,0x44,0xac,0x80,0x00,0x48,0x03,0xe0,0x00,0x08,0xac,0x80,0x00,0x4c, -0x3c,0x04,0xb0,0x06,0x34,0x84,0x80,0x00,0x8c,0x83,0x00,0x00,0x3c,0x02,0x12,0x00, -0x3c,0x05,0xb0,0x03,0x00,0x62,0x18,0x25,0x34,0xa5,0x00,0x8b,0x24,0x02,0xff,0x80, -0xac,0x83,0x00,0x00,0x03,0xe0,0x00,0x08,0xa0,0xa2,0x00,0x00,0x3c,0x04,0xb0,0x03, -0x34,0x84,0x00,0x0b,0x24,0x02,0x00,0x22,0x3c,0x05,0xb0,0x01,0x3c,0x06,0x45,0x67, -0x3c,0x0a,0xb0,0x09,0xa0,0x82,0x00,0x00,0x34,0xa5,0x00,0x04,0x34,0xc6,0x89,0xaa, -0x35,0x4a,0x00,0x04,0x24,0x02,0x01,0x23,0x3c,0x0b,0xb0,0x09,0x3c,0x07,0x01,0x23, -0x3c,0x0c,0xb0,0x09,0x3c,0x01,0xb0,0x01,0xac,0x20,0x00,0x00,0x27,0xbd,0xff,0xe0, -0xac,0xa0,0x00,0x00,0x35,0x6b,0x00,0x08,0x3c,0x01,0xb0,0x09,0xac,0x26,0x00,0x00, -0x34,0xe7,0x45,0x66,0xa5,0x42,0x00,0x00,0x35,0x8c,0x00,0x0c,0x24,0x02,0xcd,0xef, -0x3c,0x0d,0xb0,0x09,0x3c,0x08,0xcd,0xef,0x3c,0x0e,0xb0,0x09,0xad,0x67,0x00,0x00, -0xaf,0xb7,0x00,0x1c,0xa5,0x82,0x00,0x00,0xaf,0xb6,0x00,0x18,0xaf,0xb5,0x00,0x14, -0xaf,0xb4,0x00,0x10,0xaf,0xb3,0x00,0x0c,0xaf,0xb2,0x00,0x08,0xaf,0xb1,0x00,0x04, -0xaf,0xb0,0x00,0x00,0x35,0xad,0x00,0x10,0x35,0x08,0x01,0x22,0x35,0xce,0x00,0x14, -0x24,0x02,0x89,0xab,0x3c,0x0f,0xb0,0x09,0x3c,0x09,0x89,0xab,0x3c,0x10,0xb0,0x09, -0x3c,0x11,0xb0,0x09,0x3c,0x12,0xb0,0x09,0x3c,0x13,0xb0,0x09,0x3c,0x14,0xb0,0x09, -0x3c,0x15,0xb0,0x09,0x3c,0x16,0xb0,0x09,0x3c,0x17,0xb0,0x09,0xad,0xa8,0x00,0x00, -0x24,0x03,0xff,0xff,0xa5,0xc2,0x00,0x00,0x35,0xef,0x00,0x18,0x35,0x29,0xcd,0xee, -0x36,0x10,0x00,0x1c,0x36,0x31,0x00,0x20,0x36,0x52,0x00,0x24,0x36,0x73,0x00,0x28, -0x36,0x94,0x00,0x2c,0x36,0xb5,0x00,0x30,0x36,0xd6,0x00,0x34,0x36,0xf7,0x00,0x38, -0x24,0x02,0x45,0x67,0xad,0xe9,0x00,0x00,0xa6,0x02,0x00,0x00,0xae,0x23,0x00,0x00, -0x8f,0xb0,0x00,0x00,0xa6,0x43,0x00,0x00,0x8f,0xb1,0x00,0x04,0xae,0x63,0x00,0x00, -0x8f,0xb2,0x00,0x08,0xa6,0x83,0x00,0x00,0x8f,0xb3,0x00,0x0c,0xae,0xa3,0x00,0x00, -0x8f,0xb4,0x00,0x10,0xa6,0xc3,0x00,0x00,0x8f,0xb5,0x00,0x14,0xae,0xe3,0x00,0x00, -0x7b,0xb6,0x00,0xfc,0x3c,0x18,0xb0,0x09,0x37,0x18,0x00,0x3c,0xa7,0x03,0x00,0x00, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00, -0x34,0x63,0x00,0x20,0x24,0x42,0x51,0x48,0xac,0x62,0x00,0x00,0x8c,0x83,0x00,0x34, -0x34,0x02,0xff,0xff,0x00,0x43,0x10,0x2a,0x14,0x40,0x01,0x04,0x00,0x80,0x28,0x21, -0x8c,0x86,0x00,0x08,0x24,0x02,0x00,0x03,0x10,0xc2,0x00,0xf7,0x00,0x00,0x00,0x00, -0x8c,0xa2,0x00,0x2c,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x4f,0x24,0x02,0x00,0x06, -0x3c,0x03,0xb0,0x05,0x34,0x63,0x04,0x50,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00, -0x30,0x42,0x00,0xff,0x14,0x40,0x00,0xdd,0xac,0xa2,0x00,0x2c,0x24,0x02,0x00,0x01, -0x10,0xc2,0x00,0xdc,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xc2,0x00,0xca, -0x00,0x00,0x00,0x00,0x8c,0xa7,0x00,0x04,0x24,0x02,0x00,0x02,0x10,0xe2,0x00,0xc0, -0x00,0x00,0x00,0x00,0x8c,0xa2,0x00,0x14,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x09, -0x24,0x02,0x00,0x01,0x3c,0x03,0xb0,0x09,0x34,0x63,0x01,0x60,0x90,0x62,0x00,0x00, -0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0x10,0x40,0x00,0x05,0xac,0xa2,0x00,0x14, -0x24,0x02,0x00,0x01,0xac,0xa2,0x00,0x00,0x03,0xe0,0x00,0x08,0xac,0xa0,0x00,0x14, -0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xd0,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00, -0x04,0x61,0x00,0x19,0x3c,0x02,0xb0,0x03,0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x2e, -0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x14,0x40,0x00,0x12, -0x3c,0x02,0xb0,0x03,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x42,0x90,0x43,0x00,0x00, -0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x0c,0x3c,0x02,0xb0,0x03,0x80,0xa2,0x00,0x50, -0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x08,0x3c,0x02,0xb0,0x03,0x14,0xc0,0x00,0x07, -0x34,0x42,0x00,0x3f,0x24,0x02,0x00,0x0e,0x24,0x03,0x00,0x01,0xac,0xa2,0x00,0x00, -0x03,0xe0,0x00,0x08,0xa0,0xa3,0x00,0x50,0x34,0x42,0x00,0x3f,0x90,0x44,0x00,0x00, -0x24,0x03,0x00,0x01,0x10,0x64,0x00,0x7f,0x3c,0x03,0xb0,0x05,0x80,0xa2,0x00,0x31, -0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0a,0x3c,0x02,0xb0,0x06,0x34,0x42,0x80,0x18, -0x8c,0x43,0x00,0x00,0x3c,0x04,0xf0,0x00,0x3c,0x02,0x80,0x00,0x00,0x64,0x18,0x24, -0x10,0x62,0x00,0x03,0x24,0x02,0x00,0x09,0x03,0xe0,0x00,0x08,0xac,0xa2,0x00,0x00, -0x8c,0xa2,0x00,0x40,0x00,0x00,0x00,0x00,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00, -0x10,0x60,0x00,0x09,0x3c,0x03,0xb0,0x03,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2c, -0x8c,0x43,0x00,0x00,0x3c,0x04,0x00,0x02,0x00,0x64,0x18,0x24,0x14,0x60,0xff,0xf2, -0x24,0x02,0x00,0x10,0x3c,0x03,0xb0,0x03,0x34,0x63,0x02,0x01,0x90,0x62,0x00,0x00, -0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x80,0x10,0x40,0x00,0x0e,0x00,0x00,0x00,0x00, -0x8c,0xa3,0x00,0x0c,0x00,0x00,0x00,0x00,0xac,0xa3,0x00,0x10,0x3c,0x02,0xb0,0x03, -0x90,0x42,0x02,0x01,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x0f,0xac,0xa2,0x00,0x0c, -0x90,0xa3,0x00,0x0f,0x24,0x02,0x00,0x0d,0x3c,0x01,0xb0,0x03,0x08,0x00,0x14,0xb2, -0xa0,0x23,0x02,0x01,0x3c,0x02,0xb0,0x09,0x34,0x42,0x01,0x80,0x90,0x44,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x04,0x1e,0x00,0x00,0x03,0x1e,0x03,0x10,0x60,0x00,0x15, -0xa0,0xa4,0x00,0x44,0x24,0x02,0x00,0x01,0x10,0x62,0x00,0x0b,0x24,0x02,0x00,0x02, -0x10,0x62,0x00,0x03,0x24,0x03,0x00,0x0d,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, -0x8c,0xa2,0x00,0x0c,0xac,0xa3,0x00,0x00,0x24,0x03,0x00,0x04,0xac,0xa2,0x00,0x10, -0x03,0xe0,0x00,0x08,0xac,0xa3,0x00,0x0c,0x24,0x02,0x00,0x0d,0xac,0xa2,0x00,0x00, -0x24,0x03,0x00,0x04,0x24,0x02,0x00,0x06,0xac,0xa3,0x00,0x10,0x03,0xe0,0x00,0x08, -0xac,0xa2,0x00,0x0c,0x8c,0xa3,0x00,0x38,0x24,0x04,0x00,0x01,0x10,0x64,0x00,0x2d, -0x24,0x02,0x00,0x02,0x10,0x60,0x00,0x19,0x00,0x00,0x00,0x00,0x10,0x62,0x00,0x10, -0x24,0x02,0x00,0x04,0x10,0x62,0x00,0x04,0x00,0x00,0x00,0x00,0xac,0xa0,0x00,0x38, -0x03,0xe0,0x00,0x08,0xac,0xa0,0x00,0x00,0x10,0xe4,0x00,0x07,0x24,0x02,0x00,0x03, -0x80,0xa2,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x02,0x18,0x0b,0xac,0xa3,0x00,0x00, -0x03,0xe0,0x00,0x08,0xac,0xa0,0x00,0x38,0x08,0x00,0x15,0x04,0xac,0xa2,0x00,0x00, -0x10,0xe4,0x00,0x02,0x24,0x02,0x00,0x03,0x24,0x02,0x00,0x0c,0xac,0xa2,0x00,0x00, -0x24,0x02,0x00,0x04,0x03,0xe0,0x00,0x08,0xac,0xa2,0x00,0x38,0x10,0xe4,0x00,0x0e, -0x3c,0x03,0xb0,0x06,0x34,0x63,0x80,0x24,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00, -0x30,0x42,0x00,0xff,0x10,0x40,0x00,0x06,0xac,0xa2,0x00,0x18,0x24,0x02,0x00,0x02, -0xac,0xa2,0x00,0x00,0xac,0xa0,0x00,0x18,0x08,0x00,0x15,0x0d,0x24,0x02,0x00,0x01, -0x08,0x00,0x15,0x1a,0xac,0xa0,0x00,0x00,0x24,0x02,0x00,0x03,0x08,0x00,0x15,0x1a, -0xac,0xa2,0x00,0x00,0x24,0x03,0x00,0x0b,0xac,0xa2,0x00,0x38,0x03,0xe0,0x00,0x08, -0xac,0xa3,0x00,0x00,0x34,0x63,0x02,0x2e,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00, -0x30,0x42,0x00,0x01,0x14,0x40,0xff,0x7d,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x42, -0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x60,0xff,0x78,0x00,0x00,0x00,0x00, -0x10,0xc0,0xff,0x81,0x24,0x02,0x00,0x0e,0x08,0x00,0x14,0xa7,0x00,0x00,0x00,0x00, -0x80,0xa2,0x00,0x30,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x3e,0x24,0x02,0x00,0x04, -0x08,0x00,0x14,0xb2,0x00,0x00,0x00,0x00,0x84,0xa2,0x00,0x20,0x00,0x00,0x00,0x00, -0x10,0x40,0xff,0x75,0x24,0x02,0x00,0x06,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2e, -0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x01,0x30,0x63,0x00,0xff, -0x00,0x60,0x10,0x21,0x14,0x40,0xff,0x2b,0xa4,0xa3,0x00,0x20,0x08,0x00,0x14,0xb2, -0x24,0x02,0x00,0x06,0x8c,0xa2,0x00,0x1c,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0x66, -0x24,0x02,0x00,0x05,0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x2c,0x8c,0x62,0x00,0x00, -0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0x10,0x40,0xff,0x1b,0xac,0xa2,0x00,0x1c, -0x08,0x00,0x14,0xb2,0x24,0x02,0x00,0x05,0x3c,0x02,0xb0,0x05,0x8c,0x42,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x02,0x17,0x42,0x30,0x42,0x00,0x01,0x14,0x40,0xff,0x56, -0x24,0x02,0x00,0x06,0x08,0x00,0x14,0x60,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x0a, -0x03,0xe0,0x00,0x08,0xac,0x82,0x00,0x00,0x27,0xbd,0xff,0xd8,0xaf,0xb0,0x00,0x10, -0x27,0x90,0x86,0x58,0xaf,0xbf,0x00,0x20,0xaf,0xb3,0x00,0x1c,0xaf,0xb2,0x00,0x18, -0x0c,0x00,0x29,0xd5,0xaf,0xb1,0x00,0x14,0xaf,0x90,0x8f,0xe0,0x48,0x02,0x00,0x00, -0x0c,0x00,0x13,0xf0,0x00,0x00,0x00,0x00,0x0c,0x00,0x18,0x1f,0x02,0x00,0x20,0x21, -0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x3a,0x94,0x43,0x00,0x00,0x00,0x00,0x00,0x00, -0xa3,0x83,0x8f,0xe4,0x0c,0x00,0x00,0x34,0x00,0x00,0x00,0x00,0x0c,0x00,0x13,0xfb, -0x00,0x00,0x00,0x00,0x27,0x84,0x84,0x98,0x0c,0x00,0x27,0x59,0x00,0x00,0x00,0x00, -0x93,0x84,0x80,0x10,0x0c,0x00,0x21,0x3f,0x00,0x00,0x00,0x00,0x27,0x84,0x89,0x18, -0x0c,0x00,0x06,0xe5,0x00,0x00,0x00,0x00,0x0c,0x00,0x01,0x39,0x00,0x00,0x00,0x00, -0x27,0x84,0x84,0x40,0x0c,0x00,0x13,0xd9,0x00,0x00,0x00,0x00,0x27,0x82,0x89,0x4c, -0xaf,0x82,0x84,0x80,0x0c,0x00,0x00,0x5f,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03, -0x34,0x63,0x01,0x08,0x3c,0x04,0xb0,0x09,0x3c,0x05,0xb0,0x09,0x8c,0x66,0x00,0x00, -0x34,0x84,0x01,0x68,0x34,0xa5,0x01,0x40,0x24,0x02,0xc8,0x80,0x24,0x03,0x00,0x0a, -0xa4,0x82,0x00,0x00,0xa4,0xa3,0x00,0x00,0x3c,0x04,0xb0,0x03,0x8c,0x82,0x00,0x00, -0x8f,0x85,0x84,0x40,0xaf,0x86,0x84,0x38,0x34,0x42,0x00,0x20,0xac,0x82,0x00,0x00, -0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x58,0x8c,0x43,0x00,0x00,0x2c,0xa4,0x00,0x11, -0x34,0x63,0x01,0x00,0xac,0x43,0x00,0x00,0x10,0x80,0xff,0xfa,0x3c,0x02,0xb0,0x03, -0x3c,0x03,0x80,0x01,0x00,0x05,0x10,0x80,0x24,0x63,0x02,0x00,0x00,0x43,0x10,0x21, -0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00, -0x27,0x84,0x84,0x98,0x0c,0x00,0x26,0x8e,0x00,0x00,0x00,0x00,0x27,0x84,0x84,0x40, -0x0c,0x00,0x14,0x52,0x00,0x00,0x00,0x00,0x93,0x83,0x81,0xf1,0x24,0x02,0x00,0x01, -0x10,0x62,0x00,0x08,0x00,0x00,0x00,0x00,0x8f,0x85,0x84,0x40,0x8f,0x82,0x84,0x74, -0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x01,0xaf,0x82,0x84,0x74,0x08,0x00,0x15,0x9d, -0x3c,0x02,0xb0,0x03,0x27,0x84,0x84,0x98,0x0c,0x00,0x27,0x0d,0x00,0x00,0x00,0x00, -0x08,0x00,0x15,0xb6,0x00,0x00,0x00,0x00,0x27,0x84,0x84,0x98,0x0c,0x00,0x28,0xdd, -0x00,0x00,0x00,0x00,0xa3,0x82,0x84,0x71,0x8f,0x82,0x84,0x74,0xaf,0x80,0x84,0x40, -0x24,0x42,0x00,0x01,0xaf,0x82,0x84,0x74,0x08,0x00,0x15,0x9c,0x00,0x00,0x28,0x21, -0x27,0x84,0x86,0x58,0x0c,0x00,0x19,0x5b,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff, -0x14,0x40,0x00,0x05,0x3c,0x03,0xb0,0x05,0xaf,0x80,0x84,0x40,0xaf,0x80,0x84,0x44, -0x08,0x00,0x15,0xb6,0x00,0x00,0x00,0x00,0x34,0x63,0x04,0x50,0x90,0x62,0x00,0x00, -0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0xaf,0x82,0x84,0x6c,0x14,0x40,0x00,0x20, -0x24,0x02,0x00,0x01,0x8f,0x84,0x84,0x48,0x00,0x00,0x00,0x00,0x10,0x82,0x00,0x20, -0x3c,0x03,0xb0,0x09,0x34,0x63,0x01,0x60,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00, -0x30,0x42,0x00,0xff,0xaf,0x82,0x84,0x54,0x14,0x40,0x00,0x15,0x24,0x02,0x00,0x01, -0x24,0x02,0x00,0x02,0x10,0x82,0x00,0x07,0x00,0x00,0x00,0x00,0x24,0x05,0x00,0x03, -0x24,0x02,0x00,0x01,0xaf,0x82,0x84,0x44,0xaf,0x85,0x84,0x40,0x08,0x00,0x15,0xb6, -0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2e,0x90,0x43,0x00,0x00, -0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x01,0x30,0x63,0x00,0xff,0x00,0x60,0x10,0x21, -0xa7,0x83,0x84,0x60,0x14,0x40,0xff,0xf1,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, -0xaf,0x82,0x84,0x44,0xaf,0x80,0x84,0x40,0x08,0x00,0x15,0xb6,0x00,0x00,0x00,0x00, -0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x2c,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00, -0x30,0x42,0x00,0xff,0xaf,0x82,0x84,0x5c,0x14,0x40,0xff,0xf5,0x24,0x02,0x00,0x01, -0x08,0x00,0x15,0xe1,0x3c,0x03,0xb0,0x09,0x27,0x84,0x86,0x58,0x0c,0x00,0x1a,0xd1, -0x00,0x00,0x00,0x00,0x83,0x82,0x84,0x70,0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xec, -0x24,0x02,0x00,0x02,0x3c,0x03,0xb0,0x05,0x34,0x63,0x04,0x50,0x90,0x62,0x00,0x00, -0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0xaf,0x82,0x84,0x6c,0x14,0x40,0xff,0xe4, -0x24,0x02,0x00,0x02,0x8f,0x84,0x84,0x48,0x24,0x02,0x00,0x01,0x10,0x82,0x00,0x12, -0x24,0x02,0x00,0x02,0x10,0x82,0x00,0x04,0x00,0x00,0x00,0x00,0x24,0x05,0x00,0x04, -0x08,0x00,0x15,0xed,0x24,0x02,0x00,0x02,0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2e, -0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x01,0x30,0x63,0x00,0xff, -0x00,0x60,0x10,0x21,0xa7,0x83,0x84,0x60,0x14,0x40,0xff,0xf4,0x00,0x00,0x00,0x00, -0x08,0x00,0x15,0xfc,0x24,0x02,0x00,0x02,0x3c,0x03,0xb0,0x05,0x34,0x63,0x02,0x2c, -0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xff,0xaf,0x82,0x84,0x5c, -0x14,0x40,0xff,0xf7,0x00,0x00,0x00,0x00,0x08,0x00,0x16,0x1d,0x24,0x02,0x00,0x02, -0x27,0x84,0x89,0x18,0x0c,0x00,0x0b,0x55,0x00,0x00,0x00,0x00,0x8f,0x83,0x84,0x44, -0xaf,0x82,0x84,0x5c,0x38,0x64,0x00,0x02,0x00,0x04,0x18,0x0a,0xaf,0x83,0x84,0x44, -0x14,0x40,0xff,0xad,0x24,0x05,0x00,0x05,0x8f,0x82,0x89,0x58,0xaf,0x80,0x84,0x40, -0x10,0x40,0x00,0x02,0x24,0x04,0x00,0x01,0xaf,0x84,0x84,0x48,0x93,0x82,0x89,0x66, -0x00,0x00,0x00,0x00,0x10,0x40,0xff,0x6c,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x05, -0x34,0x42,0x00,0x08,0x8c,0x43,0x00,0x00,0x3c,0x04,0x20,0x00,0x00,0x64,0x18,0x24, -0x10,0x60,0xff,0x65,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xa0, -0x8c,0x43,0x00,0x00,0x3c,0x04,0x80,0x00,0xaf,0x80,0x89,0x40,0x24,0x63,0x00,0x01, -0xac,0x43,0x00,0x00,0x3c,0x01,0xb0,0x05,0xac,0x24,0x00,0x08,0xaf,0x80,0x89,0x3c, -0xaf,0x80,0x89,0x44,0xaf,0x80,0x89,0x48,0xaf,0x80,0x89,0x54,0xaf,0x80,0x89,0x4c, -0x08,0x00,0x15,0xb6,0x00,0x00,0x00,0x00,0x83,0x82,0x84,0x90,0x00,0x00,0x00,0x00, -0x10,0x40,0x00,0x02,0x24,0x02,0x00,0x20,0xaf,0x82,0x84,0x5c,0x8f,0x85,0x84,0x5c, -0x27,0x84,0x89,0x18,0x0c,0x00,0x0d,0x30,0x00,0x00,0x00,0x00,0x00,0x02,0x1e,0x00, -0xa3,0x82,0x84,0x70,0xaf,0x80,0x84,0x5c,0x10,0x60,0xff,0x8e,0x00,0x00,0x00,0x00, -0x3c,0x02,0xb0,0x05,0x34,0x42,0x02,0x2e,0x90,0x43,0x00,0x00,0x00,0x00,0x00,0x00, -0x30,0x63,0x00,0x01,0x30,0x63,0x00,0xff,0x00,0x60,0x10,0x21,0xa7,0x83,0x84,0x60, -0x10,0x40,0x00,0x04,0x24,0x04,0x00,0x02,0xaf,0x84,0x84,0x48,0x08,0x00,0x15,0xfd, -0x00,0x00,0x00,0x00,0x08,0x00,0x15,0xee,0x24,0x05,0x00,0x06,0x27,0x84,0x84,0x40, -0x27,0x85,0x89,0x18,0x0c,0x00,0x0d,0xfd,0x00,0x00,0x00,0x00,0x8f,0x82,0x84,0x64, -0xaf,0x80,0x84,0x6c,0x14,0x40,0x00,0x19,0x00,0x40,0x18,0x21,0x8f,0x82,0x84,0x68, -0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x15,0x24,0x02,0x00,0x02,0x8f,0x83,0x84,0x48, -0x00,0x00,0x00,0x00,0x10,0x62,0x00,0x0b,0x3c,0x02,0x40,0x00,0x8f,0x83,0x84,0x44, -0x24,0x02,0x00,0x01,0x10,0x62,0x00,0x02,0x24,0x05,0x00,0x03,0x24,0x05,0x00,0x06, -0xaf,0x85,0x84,0x40,0x24,0x04,0x00,0x03,0xaf,0x84,0x84,0x48,0x08,0x00,0x15,0xb6, -0x00,0x00,0x00,0x00,0x34,0x42,0x00,0x14,0x3c,0x01,0xb0,0x05,0xac,0x22,0x00,0x00, -0xaf,0x80,0x84,0x40,0x08,0x00,0x16,0x96,0x24,0x04,0x00,0x03,0x10,0x60,0x00,0x10, -0x00,0x00,0x00,0x00,0x27,0x85,0x89,0x18,0x27,0x84,0x84,0x40,0x0c,0x00,0x0e,0x21, -0x00,0x00,0x00,0x00,0x8f,0x83,0x84,0x44,0x24,0x02,0x00,0x01,0xa3,0x80,0x84,0x70, -0xaf,0x80,0x84,0x48,0x10,0x62,0x00,0x02,0x24,0x05,0x00,0x03,0x24,0x05,0x00,0x04, -0xaf,0x85,0x84,0x40,0xaf,0x80,0x84,0x64,0x08,0x00,0x15,0xb6,0x00,0x00,0x00,0x00, -0x83,0x82,0x84,0x90,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x04,0x00,0x00,0x00,0x00, -0x27,0x84,0x89,0x18,0x0c,0x00,0x10,0x69,0x00,0x00,0x00,0x00,0x8f,0x82,0x84,0x44, -0xa3,0x80,0x84,0x70,0xaf,0x80,0x84,0x40,0xaf,0x80,0x84,0x48,0x14,0x40,0x00,0x03, -0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0xaf,0x82,0x84,0x44,0xaf,0x80,0x84,0x68, -0x08,0x00,0x15,0xb6,0x00,0x00,0x00,0x00,0x27,0x84,0x84,0x40,0x27,0x85,0x89,0x18, -0x0c,0x00,0x0e,0x21,0x00,0x00,0x00,0x00,0x8f,0x82,0x84,0x44,0xa3,0x80,0x84,0x70, -0xaf,0x80,0x84,0x40,0xaf,0x80,0x84,0x48,0x14,0x40,0xfe,0xeb,0x00,0x00,0x00,0x00, -0x24,0x02,0x00,0x02,0xaf,0x82,0x84,0x44,0x08,0x00,0x15,0xb6,0x00,0x00,0x00,0x00, -0x27,0x84,0x89,0x18,0x0c,0x00,0x10,0x69,0x00,0x00,0x00,0x00,0x08,0x00,0x16,0xc6, -0x00,0x00,0x00,0x00,0x27,0x84,0x84,0x98,0x0c,0x00,0x29,0x73,0x00,0x00,0x00,0x00, -0x08,0x00,0x15,0xc5,0x00,0x00,0x00,0x00,0x0c,0x00,0x24,0x05,0x00,0x00,0x00,0x00, -0x0c,0x00,0x26,0xff,0x00,0x00,0x00,0x00,0x0c,0x00,0x18,0x11,0x00,0x00,0x00,0x00, -0x93,0x83,0xbc,0x18,0x00,0x00,0x00,0x00,0x14,0x60,0x00,0x2b,0x3c,0x02,0xb0,0x03, -0x34,0x42,0x01,0x08,0x8c,0x44,0x00,0x00,0x8f,0x83,0xbc,0x10,0x8f,0x82,0xbc,0x14, -0x00,0x83,0x18,0x23,0x00,0x43,0x10,0x2b,0x10,0x40,0x00,0x23,0x3c,0x02,0xb0,0x03, -0x24,0x04,0x05,0xa0,0x34,0x42,0x01,0x18,0x8c,0x42,0x00,0x00,0x0c,0x00,0x06,0xd1, -0x00,0x00,0x00,0x00,0x24,0x04,0x05,0xa4,0x0c,0x00,0x06,0xd1,0x00,0x02,0x84,0x02, -0x30,0x51,0xff,0xff,0x24,0x04,0x05,0xa8,0x00,0x02,0x94,0x02,0x0c,0x00,0x06,0xd1, -0x3a,0x10,0xff,0xff,0x3a,0x31,0xff,0xff,0x30,0x42,0xff,0xff,0x2e,0x10,0x00,0x01, -0x2e,0x31,0x00,0x01,0x3a,0x52,0xff,0xff,0x02,0x11,0x80,0x25,0x2e,0x52,0x00,0x01, -0x38,0x42,0xff,0xff,0x02,0x12,0x80,0x25,0x2c,0x42,0x00,0x01,0x02,0x02,0x80,0x25, -0x16,0x00,0x00,0x02,0x24,0x04,0x00,0x02,0x00,0x00,0x20,0x21,0x0c,0x00,0x05,0x6e, -0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x08,0x8c,0x43,0x00,0x00, -0x00,0x00,0x00,0x00,0xaf,0x83,0xbc,0x10,0x0c,0x00,0x01,0xe9,0x00,0x00,0x00,0x00, -0xaf,0x80,0x84,0x40,0xaf,0x80,0x84,0x74,0x08,0x00,0x15,0x9c,0x00,0x00,0x28,0x21, -0x27,0x90,0xb4,0x00,0x24,0x11,0x00,0x12,0x8e,0x04,0x00,0x00,0x00,0x00,0x00,0x00, -0x90,0x82,0x00,0x10,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x03,0x00,0x00,0x00,0x00, -0x0c,0x00,0x18,0xd0,0x00,0x00,0x00,0x00,0x26,0x31,0xff,0xff,0x06,0x21,0xff,0xf6, -0x26,0x10,0x00,0x04,0xaf,0x80,0x84,0x40,0x08,0x00,0x15,0xb7,0x00,0x00,0x28,0x21, -0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x08,0x8c,0x44,0x00,0x00,0x8f,0x82,0x84,0x38, -0x00,0x04,0x19,0xc2,0x00,0x02,0x11,0xc2,0x10,0x62,0xff,0xf6,0x00,0x00,0x00,0x00, -0x3c,0x02,0xb0,0x03,0x34,0x42,0x01,0x02,0x90,0x43,0x00,0x00,0x3c,0x12,0xb0,0x05, -0xaf,0x84,0x84,0x38,0x30,0x63,0x00,0xff,0x00,0x03,0x11,0x40,0x00,0x43,0x10,0x23, -0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x00,0x02,0x99,0x00,0x00,0x00,0x88,0x21, -0x36,0x52,0x02,0x2c,0x27,0x90,0xb4,0x00,0x8e,0x04,0x00,0x00,0x00,0x00,0x00,0x00, -0x90,0x83,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x62,0x00,0x03,0x10,0x40,0x00,0x06, -0x30,0x62,0x00,0x1c,0x14,0x40,0x00,0x04,0x00,0x00,0x00,0x00,0x8f,0x85,0x84,0x38, -0x0c,0x00,0x1e,0x94,0x02,0x60,0x30,0x21,0x8e,0x42,0x00,0x00,0x00,0x00,0x00,0x00, -0x30,0x42,0x00,0xff,0x14,0x40,0xff,0xd7,0x00,0x00,0x00,0x00,0x26,0x31,0x00,0x01, -0x2a,0x22,0x00,0x13,0x14,0x40,0xff,0xec,0x26,0x10,0x00,0x04,0x08,0x00,0x17,0x21, -0x00,0x00,0x00,0x00,0x8f,0x84,0x84,0x4c,0x27,0x85,0x89,0x18,0x0c,0x00,0x17,0xa4, -0x00,0x00,0x00,0x00,0x8f,0x83,0x84,0x4c,0x24,0x02,0x00,0x04,0x14,0x62,0xfe,0xa5, -0x00,0x00,0x00,0x00,0x08,0x00,0x15,0xee,0x24,0x05,0x00,0x05,0x3c,0x02,0xb0,0x03, -0x34,0x42,0x00,0x3f,0x90,0x44,0x00,0x00,0x24,0x03,0x00,0x01,0x10,0x64,0x00,0x08, -0x00,0x00,0x00,0x00,0x27,0x84,0x89,0x18,0x0c,0x00,0x24,0x2c,0x00,0x00,0x00,0x00, -0x24,0x05,0x00,0x05,0xaf,0x85,0x84,0x40,0x08,0x00,0x15,0xb7,0x00,0x00,0x00,0x00, -0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x14,0x8c,0x44,0x00,0x00,0x0c,0x00,0x24,0x49, -0x00,0x00,0x00,0x00,0x08,0x00,0x17,0x65,0x24,0x05,0x00,0x05,0x8f,0x82,0x89,0x4c, -0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0d,0x00,0x00,0x00,0x00,0x8f,0x84,0xb4,0x40, -0xaf,0x80,0x89,0x4c,0x94,0x85,0x00,0x14,0x0c,0x00,0x1b,0x66,0x00,0x00,0x00,0x00, -0x93,0x82,0x8b,0x71,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x02,0x10,0x40,0x00,0x03, -0x00,0x00,0x00,0x00,0x0c,0x00,0x01,0x57,0x00,0x00,0x20,0x21,0x8f,0x84,0xb4,0x40, -0x0c,0x00,0x18,0xd0,0x00,0x00,0x00,0x00,0x08,0x00,0x17,0x21,0x00,0x00,0x00,0x00, -0x3c,0x02,0xff,0x90,0x27,0xbd,0xff,0xe8,0x00,0x80,0x18,0x21,0x34,0x42,0x00,0x01, -0x27,0x84,0x89,0x18,0x10,0x62,0x00,0x05,0xaf,0xbf,0x00,0x10,0x8f,0xbf,0x00,0x10, -0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x0c,0x00,0x06,0xe5, -0x00,0x00,0x00,0x00,0x27,0x84,0x86,0x58,0x0c,0x00,0x18,0x1f,0x00,0x00,0x00,0x00, -0x27,0x84,0x84,0x40,0x0c,0x00,0x13,0xd9,0x00,0x00,0x00,0x00,0x08,0x00,0x17,0x8b, -0x00,0x00,0x00,0x00,0x8f,0x82,0x89,0x58,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x05, -0x00,0x00,0x18,0x21,0x8f,0x82,0x84,0x48,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x02, -0x00,0x00,0x00,0x00,0x24,0x03,0x00,0x01,0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21, -0x27,0xbd,0xff,0xe0,0x3c,0x06,0xb0,0x03,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10, -0x34,0xc6,0x00,0x5f,0xaf,0xbf,0x00,0x18,0x90,0xc3,0x00,0x00,0x3c,0x07,0xb0,0x03, -0x34,0xe7,0x00,0x5d,0x34,0x63,0x00,0x01,0x3c,0x09,0xb0,0x03,0x24,0x02,0x00,0x01, -0xa0,0xc3,0x00,0x00,0x00,0x80,0x80,0x21,0xa0,0xe2,0x00,0x00,0x00,0xa0,0x88,0x21, -0x35,0x29,0x00,0x5e,0x00,0xe0,0x40,0x21,0x24,0x04,0x00,0x01,0x91,0x22,0x00,0x00, -0x91,0x03,0x00,0x00,0x30,0x42,0x00,0x01,0x14,0x83,0x00,0x03,0x30,0x42,0x00,0x01, -0x14,0x40,0xff,0xfa,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x04,0x12,0x02,0x00,0x2c, -0x24,0x05,0x0f,0x00,0x24,0x02,0x00,0x06,0x12,0x02,0x00,0x08,0x24,0x05,0x00,0x0f, -0x3c,0x02,0xb0,0x03,0x34,0x42,0x02,0x00,0xa0,0x50,0x00,0x00,0x8f,0xbf,0x00,0x18, -0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x24,0x04,0x0c,0x04, -0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x0f,0x24,0x04,0x0d,0x04,0x24,0x05,0x00,0x0f, -0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x0f,0x24,0x04,0x08,0x80,0x24,0x05,0x1e,0x00, -0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x0f,0x24,0x04,0x08,0x8c,0x24,0x05,0x0f,0x00, -0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x0f,0x24,0x04,0x08,0x24,0x3c,0x05,0x00,0x30, -0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x02,0x24,0x04,0x08,0x2c,0x3c,0x05,0x00,0x30, -0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x02,0x24,0x04,0x08,0x34,0x3c,0x05,0x00,0x30, -0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x02,0x24,0x04,0x08,0x3c,0x3c,0x05,0x00,0x30, -0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x02,0x08,0x00,0x17,0xc5,0x3c,0x02,0xb0,0x03, -0x24,0x04,0x08,0x8c,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x04,0x24,0x04,0x08,0x80, -0x24,0x05,0x1e,0x00,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x04,0x24,0x04,0x0c,0x04, -0x24,0x05,0x00,0x0f,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x04,0x24,0x04,0x0d,0x04, -0x24,0x05,0x00,0x0f,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x04,0x24,0x04,0x08,0x24, -0x3c,0x05,0x00,0x30,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x03,0x24,0x04,0x08,0x2c, -0x3c,0x05,0x00,0x30,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x03,0x24,0x04,0x08,0x34, -0x3c,0x05,0x00,0x30,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x02,0x3c,0x05,0x00,0x30, -0x24,0x06,0x00,0x03,0x0c,0x00,0x13,0x5f,0x24,0x04,0x08,0x3c,0x02,0x20,0x20,0x21, -0x24,0x05,0x00,0x14,0x0c,0x00,0x13,0xa4,0x24,0x06,0x01,0x07,0x08,0x00,0x17,0xc5, -0x3c,0x02,0xb0,0x03,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x73,0x90,0x62,0x00,0x00, -0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x02,0x14,0x40,0x00,0x04,0x00,0x00,0x00,0x00, -0xa3,0x80,0x81,0x58,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, -0xa3,0x82,0x81,0x58,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03, -0x3c,0x02,0x80,0x00,0x00,0x80,0x70,0x21,0x34,0x63,0x00,0x20,0x24,0x42,0x60,0x7c, -0x3c,0x04,0xb0,0x03,0xac,0x62,0x00,0x00,0x34,0x84,0x00,0x30,0xad,0xc0,0x02,0xb8, -0x8c,0x83,0x00,0x00,0x24,0x02,0x00,0xff,0xa5,0xc0,0x00,0x0a,0x00,0x00,0x30,0x21, -0xa7,0x82,0x8f,0xf0,0x27,0x88,0x90,0x00,0xa5,0xc3,0x00,0x08,0x3c,0x07,0xb0,0x08, -0x30,0xc2,0xff,0xff,0x00,0x02,0x20,0xc0,0x24,0xc3,0x00,0x01,0x00,0x82,0x10,0x21, -0x00,0x60,0x30,0x21,0x00,0x02,0x10,0x80,0x30,0x63,0xff,0xff,0x00,0x48,0x10,0x21, -0x00,0x87,0x20,0x21,0x28,0xc5,0x00,0xff,0xac,0x83,0x00,0x00,0x14,0xa0,0xff,0xf4, -0xa4,0x43,0x00,0x00,0x3c,0x02,0xb0,0x08,0x34,0x03,0xff,0xff,0x25,0xc4,0x00,0x0c, -0x24,0x0a,0x00,0x02,0x34,0x42,0x07,0xf8,0x3c,0x06,0xb0,0x03,0xa7,0x83,0xb3,0xdc, -0xac,0x43,0x00,0x00,0xaf,0x84,0xb4,0x00,0x34,0xc6,0x00,0x64,0xa0,0x8a,0x00,0x18, -0x94,0xc5,0x00,0x00,0x8f,0x82,0xb4,0x00,0x25,0xc4,0x00,0x30,0x24,0x08,0x00,0x03, -0x3c,0x03,0xb0,0x03,0xa0,0x45,0x00,0x21,0x34,0x63,0x00,0x66,0xaf,0x84,0xb4,0x04, -0xa0,0x88,0x00,0x18,0x94,0x65,0x00,0x00,0x8f,0x82,0xb4,0x04,0x25,0xc4,0x00,0x54, -0x25,0xc7,0x00,0x78,0xa0,0x45,0x00,0x21,0xaf,0x84,0xb4,0x08,0xa0,0x88,0x00,0x18, -0x94,0x65,0x00,0x00,0x8f,0x82,0xb4,0x08,0x25,0xc8,0x00,0x9c,0x24,0x09,0x00,0x01, -0xa0,0x45,0x00,0x21,0xaf,0x87,0xb4,0x0c,0xa0,0xea,0x00,0x18,0x94,0xc4,0x00,0x00, -0x8f,0x82,0xb4,0x0c,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x62,0xa0,0x44,0x00,0x21, -0xaf,0x88,0xb4,0x10,0xa1,0x09,0x00,0x18,0x94,0x65,0x00,0x00,0x8f,0x82,0xb4,0x10, -0x25,0xc4,0x00,0xc0,0x3c,0x06,0xb0,0x03,0xa0,0x45,0x00,0x21,0xaf,0x84,0xb4,0x14, -0xa0,0x89,0x00,0x18,0x94,0x65,0x00,0x00,0x8f,0x82,0xb4,0x14,0x25,0xc4,0x00,0xe4, -0x34,0xc6,0x00,0x60,0xa0,0x45,0x00,0x21,0xaf,0x84,0xb4,0x18,0xa0,0x80,0x00,0x18, -0x94,0xc5,0x00,0x00,0x8f,0x82,0xb4,0x18,0x25,0xc3,0x01,0x08,0x25,0xc7,0x01,0x2c, -0xa0,0x45,0x00,0x21,0xaf,0x83,0xb4,0x1c,0xa0,0x60,0x00,0x18,0x94,0xc8,0x00,0x00, -0x8f,0x82,0xb4,0x1c,0x25,0xc4,0x01,0x50,0x25,0xc5,0x01,0x74,0xa0,0x48,0x00,0x21, -0x25,0xc6,0x01,0x98,0x25,0xc9,0x01,0xbc,0x25,0xca,0x01,0xe0,0x25,0xcb,0x02,0x04, -0x25,0xcc,0x02,0x28,0x25,0xcd,0x02,0x4c,0x24,0x02,0x00,0x10,0x3c,0x03,0xb0,0x03, -0xaf,0x87,0xb4,0x20,0x34,0x63,0x00,0x38,0xa0,0xe0,0x00,0x18,0xaf,0x84,0xb4,0x24, -0xa0,0x80,0x00,0x18,0xaf,0x85,0xb4,0x28,0xa0,0xa0,0x00,0x18,0xaf,0x86,0xb4,0x2c, -0xa0,0xc0,0x00,0x18,0xaf,0x89,0xb4,0x30,0xa1,0x20,0x00,0x18,0xaf,0x8a,0xb4,0x34, -0xa1,0x40,0x00,0x18,0xaf,0x8b,0xb4,0x38,0xa1,0x60,0x00,0x18,0xaf,0x8c,0xb4,0x3c, -0xa1,0x80,0x00,0x18,0xaf,0x8d,0xb4,0x40,0xa1,0xa2,0x00,0x18,0x94,0x64,0x00,0x00, -0x8f,0x82,0xb4,0x40,0x25,0xc5,0x02,0x70,0x3c,0x03,0xb0,0x03,0xa0,0x44,0x00,0x21, -0x24,0x02,0x00,0x11,0xaf,0x85,0xb4,0x44,0x34,0x63,0x00,0x6e,0xa0,0xa2,0x00,0x18, -0x94,0x64,0x00,0x00,0x8f,0x82,0xb4,0x44,0x25,0xc5,0x02,0x94,0x3c,0x03,0xb0,0x03, -0xa0,0x44,0x00,0x21,0x24,0x02,0x00,0x12,0xaf,0x85,0xb4,0x48,0x34,0x63,0x00,0x6c, -0xa0,0xa2,0x00,0x18,0x94,0x64,0x00,0x00,0x8f,0x82,0xb4,0x48,0x24,0x05,0xff,0xff, -0x24,0x07,0x00,0x01,0xa0,0x44,0x00,0x21,0x24,0x06,0x00,0x12,0x27,0x84,0xb4,0x00, -0x8c,0x82,0x00,0x00,0x24,0xc6,0xff,0xff,0xa0,0x40,0x00,0x04,0x8c,0x83,0x00,0x00, -0xa4,0x45,0x00,0x00,0xa4,0x45,0x00,0x02,0xa0,0x60,0x00,0x0a,0x8c,0x82,0x00,0x00, -0xa4,0x65,0x00,0x06,0xa4,0x65,0x00,0x08,0xa0,0x40,0x00,0x10,0x8c,0x83,0x00,0x00, -0xa4,0x45,0x00,0x0c,0xa4,0x45,0x00,0x0e,0xa0,0x60,0x00,0x12,0x8c,0x82,0x00,0x00, -0x00,0x00,0x00,0x00,0xa0,0x40,0x00,0x16,0x8c,0x83,0x00,0x00,0xa4,0x45,0x00,0x14, -0xa0,0x67,0x00,0x17,0x8c,0x82,0x00,0x00,0x24,0x84,0x00,0x04,0xa0,0x40,0x00,0x20, -0x04,0xc1,0xff,0xe7,0xac,0x40,0x00,0x1c,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, -0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x00,0x34,0x42,0x00,0x20,0x24,0x63,0x63,0x40, -0xac,0x43,0x00,0x00,0x90,0x82,0x00,0x10,0x00,0x80,0x60,0x21,0x10,0x40,0x00,0x56, -0x00,0x00,0x70,0x21,0x97,0x82,0x8f,0xf0,0x94,0x8a,0x00,0x0c,0x27,0x87,0x90,0x00, -0x00,0x02,0x40,0xc0,0x01,0x02,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x47,0x10,0x21, -0x90,0x8b,0x00,0x18,0xa4,0x4a,0x00,0x00,0x94,0x83,0x00,0x0e,0x39,0x64,0x00,0x10, -0x2c,0x84,0x00,0x01,0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x34,0x85,0x00,0x02, -0x39,0x63,0x00,0x11,0x00,0x83,0x28,0x0b,0x34,0xa3,0x00,0x08,0x39,0x64,0x00,0x12, -0x00,0x02,0x10,0x80,0x00,0xa4,0x18,0x0b,0x00,0x47,0x10,0x21,0x94,0x49,0x00,0x04, -0x34,0x64,0x00,0x20,0x00,0x6b,0x20,0x0b,0x34,0x83,0x00,0x40,0x39,0x62,0x00,0x01, -0x00,0x82,0x18,0x0b,0x00,0x09,0x30,0xc0,0x34,0x64,0x00,0x80,0x00,0xc9,0x28,0x21, -0x39,0x62,0x00,0x02,0x00,0x60,0x68,0x21,0x00,0x82,0x68,0x0a,0x00,0x05,0x28,0x80, -0x3c,0x02,0xb0,0x08,0x00,0xa7,0x28,0x21,0x00,0xc2,0x30,0x21,0x01,0x02,0x40,0x21, -0x34,0x03,0xff,0xff,0x35,0xa4,0x01,0x00,0x39,0x62,0x00,0x03,0x2d,0x67,0x00,0x13, -0xad,0x0a,0x00,0x00,0xa4,0xa3,0x00,0x00,0xac,0xc3,0x00,0x00,0xa7,0x89,0x8f,0xf0, -0x10,0xe0,0x00,0x0f,0x00,0x82,0x68,0x0a,0x3c,0x03,0x80,0x01,0x00,0x0b,0x10,0x80, -0x24,0x63,0x02,0x44,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x60, -0x94,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x14,0x00,0x00,0x02,0x74,0x03, -0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x3a,0x94,0x44,0x00,0x00,0x93,0x83,0x8f,0xe4, -0x91,0x82,0x00,0x21,0x01,0xc4,0x20,0x21,0x91,0x85,0x00,0x10,0x00,0x04,0x24,0x00, -0x00,0x62,0x18,0x21,0x00,0x04,0x74,0x03,0x00,0x6e,0x18,0x23,0x00,0x65,0x10,0x2a, -0x00,0xa2,0x18,0x0a,0x00,0x0d,0x24,0x00,0x3c,0x02,0xb0,0x06,0x24,0x05,0xff,0xff, -0x00,0x64,0x18,0x25,0x34,0x42,0x80,0x20,0xac,0x43,0x00,0x00,0xa5,0x85,0x00,0x0e, -0xa1,0x80,0x00,0x10,0xa5,0x85,0x00,0x0c,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, -0x3c,0x03,0xb0,0x03,0x08,0x00,0x19,0x14,0x34,0x63,0x00,0x62,0x3c,0x03,0xb0,0x03, -0x08,0x00,0x19,0x14,0x34,0x63,0x00,0x64,0x3c,0x03,0xb0,0x03,0x08,0x00,0x19,0x14, -0x34,0x63,0x00,0x66,0x3c,0x03,0xb0,0x03,0x08,0x00,0x19,0x14,0x34,0x63,0x00,0x38, -0x3c,0x03,0xb0,0x03,0x08,0x00,0x19,0x14,0x34,0x63,0x00,0x6e,0x3c,0x03,0xb0,0x03, -0x08,0x00,0x19,0x14,0x34,0x63,0x00,0x6c,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00, -0x34,0x63,0x00,0x20,0x24,0x42,0x65,0x08,0x00,0x05,0x28,0x40,0xac,0x62,0x00,0x00, -0x00,0xa6,0x28,0x21,0x2c,0xe2,0x00,0x10,0x14,0x80,0x00,0x06,0x00,0x00,0x18,0x21, -0x10,0x40,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0xe0,0x18,0x21,0x03,0xe0,0x00,0x08, -0x00,0x60,0x10,0x21,0x24,0x02,0x00,0x20,0x10,0xe2,0x00,0x06,0x2c,0xe4,0x00,0x10, -0x24,0xa2,0x00,0x01,0x10,0x80,0xff,0xf9,0x00,0x02,0x11,0x00,0x08,0x00,0x19,0x4f, -0x00,0x47,0x18,0x21,0x08,0x00,0x19,0x4f,0x24,0xa3,0x00,0x50,0x27,0xbd,0xff,0xc8, -0xaf,0xb3,0x00,0x1c,0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x30, -0xaf,0xb7,0x00,0x2c,0xaf,0xb6,0x00,0x28,0xaf,0xb5,0x00,0x24,0xaf,0xb4,0x00,0x20, -0xaf,0xb0,0x00,0x10,0x00,0x80,0x88,0x21,0x84,0x84,0x00,0x08,0x3c,0x05,0xb0,0x03, -0x3c,0x02,0x80,0x00,0x34,0xa5,0x00,0x20,0x24,0x42,0x65,0x6c,0x3c,0x03,0xb0,0x06, -0x00,0x04,0x20,0x80,0xac,0xa2,0x00,0x00,0x00,0x83,0x20,0x21,0x3c,0x06,0xb0,0x06, -0x8c,0x82,0x00,0x00,0x34,0xc6,0x80,0x24,0x8c,0x88,0x00,0x00,0x8c,0xc4,0x00,0x00, -0x96,0x25,0x00,0x08,0x30,0x52,0xff,0xff,0x00,0x08,0x44,0x02,0x34,0x84,0x01,0x00, -0x3c,0x02,0xb0,0x00,0x00,0x08,0x18,0xc0,0x00,0x12,0x3a,0x00,0xac,0xc4,0x00,0x00, -0x00,0xe2,0x38,0x21,0xae,0x32,0x02,0xb8,0x00,0x68,0x18,0x21,0x24,0xa5,0x00,0x02, -0x8c,0xf6,0x00,0x00,0x30,0xa5,0x01,0xff,0x8c,0xf4,0x00,0x04,0x27,0x86,0x90,0x00, -0x00,0x03,0x18,0x80,0x00,0x12,0x98,0xc0,0xa6,0x25,0x00,0x08,0x00,0x66,0x18,0x21, -0x02,0x72,0x10,0x21,0x94,0x65,0x00,0x00,0x00,0x02,0x48,0x80,0x01,0x26,0x30,0x21, -0x24,0x02,0xff,0xff,0x00,0x14,0x1a,0x02,0x27,0x84,0x90,0x10,0xa4,0xc2,0x00,0x02, -0x30,0x63,0x00,0x1f,0x24,0x02,0x00,0x10,0x01,0x24,0x20,0x21,0xa4,0xc8,0x00,0x04, -0x8c,0xf0,0x00,0x08,0xa6,0x23,0x00,0x06,0xa6,0x25,0x00,0x0a,0xa0,0x82,0x00,0x06, -0x86,0x25,0x00,0x06,0x27,0x82,0x90,0x04,0x01,0x22,0x10,0x21,0x24,0x03,0x00,0x13, -0x10,0xa3,0x00,0xee,0xac,0x47,0x00,0x18,0x3c,0x03,0xb0,0x03,0x34,0x63,0x01,0x00, -0xa6,0x20,0x00,0x02,0x3c,0x02,0xb0,0x03,0x90,0x64,0x00,0x00,0x34,0x42,0x01,0x08, -0x8c,0x45,0x00,0x00,0x00,0x10,0x1b,0xc2,0x00,0x04,0x20,0x82,0x30,0x63,0x00,0x01, -0xac,0xc5,0x00,0x08,0x10,0x60,0x00,0xc7,0x30,0x97,0x00,0x01,0x00,0x10,0x16,0x82, -0x30,0x46,0x00,0x01,0x00,0x10,0x12,0x02,0x00,0x10,0x19,0xc2,0x00,0x10,0x26,0x02, -0x00,0x10,0x2e,0x42,0x30,0x48,0x00,0x7f,0x24,0x02,0x00,0x01,0x30,0x75,0x00,0x01, -0x30,0x84,0x00,0x01,0x10,0xc2,0x00,0xb3,0x30,0xa3,0x00,0x01,0x00,0x60,0x28,0x21, -0x0c,0x00,0x19,0x42,0x01,0x00,0x38,0x21,0x02,0x72,0x18,0x21,0x00,0x03,0x18,0x80, -0x2c,0x46,0x00,0x54,0x27,0x85,0x90,0x10,0x27,0x84,0x90,0x08,0x00,0x06,0x10,0x0a, -0x00,0x65,0x28,0x21,0x26,0xa6,0x00,0x02,0x00,0x64,0x18,0x21,0xa0,0xa2,0x00,0x02, -0xa0,0x66,0x00,0x06,0xa0,0x62,0x00,0x07,0xa0,0xa2,0x00,0x01,0x02,0x72,0x28,0x21, -0x00,0x05,0x28,0x80,0x27,0x82,0x90,0x04,0x00,0xa2,0x58,0x21,0x8d,0x64,0x00,0x18, -0x00,0x10,0x15,0xc2,0x30,0x42,0x00,0x01,0x8c,0x83,0x00,0x0c,0x27,0x84,0x90,0x20, -0x00,0xa4,0x48,0x21,0xa6,0x22,0x00,0x00,0xa6,0x36,0x00,0x04,0x8d,0x26,0x00,0x00, -0x00,0x03,0x19,0x42,0x3c,0x02,0xff,0xef,0x34,0x42,0xff,0xff,0x30,0x63,0x00,0x01, -0x00,0xc2,0x40,0x24,0x00,0x03,0x1d,0x00,0x01,0x03,0x40,0x25,0x00,0x08,0x15,0x02, -0x00,0x14,0x19,0x82,0x00,0x14,0x25,0x82,0x00,0x10,0x34,0x42,0x00,0x10,0x3c,0x82, -0x00,0x10,0x2c,0x02,0x30,0x42,0x00,0x01,0x30,0xcd,0x00,0x01,0x30,0x6c,0x00,0x01, -0x30,0xe6,0x00,0x01,0x30,0x8a,0x00,0x03,0x32,0x94,0x00,0x07,0x30,0xa5,0x00,0x01, -0xad,0x28,0x00,0x00,0x10,0x40,0x00,0x0b,0x32,0x07,0x00,0x7f,0x8d,0x64,0x00,0x18, -0x3c,0x03,0xff,0xf0,0x34,0x63,0xff,0xff,0x8c,0x82,0x00,0x0c,0x01,0x03,0x18,0x24, -0x00,0x02,0x13,0x82,0x30,0x42,0x00,0x0f,0x00,0x02,0x14,0x00,0x00,0x62,0x18,0x25, -0xad,0x23,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xc2,0x00,0x6a,0x00,0x00,0x00,0x00, -0x15,0x80,0x00,0x03,0x00,0x00,0x00,0x00,0x15,0x40,0x00,0x5b,0x24,0x02,0x00,0x01, -0x96,0x22,0x00,0x04,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x04,0xa6,0x22,0x00,0x04, -0x00,0xa0,0x20,0x21,0x0c,0x00,0x19,0x42,0x01,0xa0,0x28,0x21,0x02,0x72,0x18,0x21, -0x00,0x03,0x40,0x80,0x2c,0x45,0x00,0x54,0x27,0x84,0x90,0x10,0x01,0x04,0x20,0x21, -0x00,0x05,0x10,0x0a,0xa0,0x82,0x00,0x00,0xa0,0x80,0x00,0x04,0xa0,0x80,0x00,0x05, -0x96,0x23,0x00,0x04,0x27,0x82,0x90,0x00,0x01,0x02,0x10,0x21,0xa4,0x43,0x00,0x06, -0x27,0x82,0x90,0x04,0x92,0x26,0x00,0x01,0x01,0x02,0x10,0x21,0x8c,0x45,0x00,0x18, -0x27,0x83,0x90,0x20,0x01,0x03,0x18,0x21,0xa0,0x60,0x00,0x00,0xa0,0x86,0x00,0x07, -0x94,0xa2,0x00,0x10,0x24,0x03,0x00,0x04,0x30,0x42,0x00,0x0f,0x10,0x43,0x00,0x36, -0x24,0xa5,0x00,0x10,0x94,0xa3,0x00,0x16,0x27,0x87,0x90,0x18,0x01,0x07,0x10,0x21, -0xa4,0x43,0x00,0x02,0x94,0xa2,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01, -0x14,0x40,0x00,0x24,0x02,0x72,0x20,0x21,0x94,0xa2,0x00,0x00,0x24,0x03,0x00,0xa4, -0x30,0x42,0x00,0xff,0x10,0x43,0x00,0x1f,0x00,0x00,0x00,0x00,0x94,0xa2,0x00,0x00, -0x24,0x03,0x00,0x88,0x30,0x42,0x00,0x88,0x10,0x43,0x00,0x14,0x02,0x72,0x18,0x21, -0x27,0x84,0x90,0x20,0x00,0x03,0x18,0x80,0x00,0x64,0x18,0x21,0x8c,0x62,0x00,0x00, -0x3c,0x04,0x00,0x80,0x00,0x44,0x10,0x25,0xac,0x62,0x00,0x00,0x02,0x72,0x10,0x21, -0x00,0x02,0x10,0x80,0x00,0x47,0x10,0x21,0xa0,0x54,0x00,0x00,0x8f,0xbf,0x00,0x30, -0x7b,0xb6,0x01,0x7c,0x7b,0xb4,0x01,0x3c,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc, -0x24,0x02,0x00,0x01,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38,0x94,0xa2,0x00,0x18, -0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x60,0x10,0x40,0xff,0xe9,0x02,0x72,0x18,0x21, -0x02,0x72,0x20,0x21,0x27,0x82,0x90,0x20,0x00,0x04,0x20,0x80,0x00,0x82,0x20,0x21, -0x8c,0x83,0x00,0x00,0x3c,0x02,0xff,0x7f,0x34,0x42,0xff,0xff,0x00,0x62,0x18,0x24, -0x08,0x00,0x1a,0x37,0xac,0x83,0x00,0x00,0x27,0x87,0x90,0x18,0x01,0x07,0x10,0x21, -0x08,0x00,0x1a,0x21,0xa4,0x40,0x00,0x02,0x11,0x42,0x00,0x07,0x00,0x00,0x00,0x00, -0x2d,0x42,0x00,0x02,0x14,0x40,0xff,0xa7,0x00,0xa0,0x20,0x21,0x96,0x22,0x00,0x04, -0x08,0x00,0x19,0xff,0x24,0x42,0x00,0x0c,0x96,0x22,0x00,0x04,0x08,0x00,0x19,0xff, -0x24,0x42,0x00,0x08,0x16,0xe6,0xff,0x96,0x3c,0x02,0xff,0xfb,0x8d,0x63,0x00,0x18, -0x34,0x42,0xff,0xff,0x02,0x02,0x10,0x24,0xac,0x62,0x00,0x08,0x08,0x00,0x19,0xf8, -0x00,0x00,0x30,0x21,0x16,0xe6,0xff,0x4e,0x00,0x60,0x28,0x21,0x3c,0x02,0xfb,0xff, -0x34,0x42,0xff,0xff,0x02,0x02,0x10,0x24,0xac,0xe2,0x00,0x08,0x08,0x00,0x19,0xb7, -0x00,0x00,0x30,0x21,0x93,0x87,0xbb,0x14,0x00,0x10,0x1e,0x42,0x00,0x10,0x26,0x82, -0x27,0x82,0x90,0x08,0x2c,0xe5,0x00,0x0c,0x01,0x22,0x48,0x21,0x30,0x63,0x00,0x01, -0x30,0x86,0x00,0x01,0x14,0xa0,0x00,0x06,0x00,0xe0,0x40,0x21,0x00,0x03,0x10,0x40, -0x00,0x46,0x10,0x21,0x00,0x02,0x11,0x00,0x00,0xe2,0x10,0x21,0x24,0x48,0x00,0x04, -0x02,0x72,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x84,0x90,0x10,0x27,0x83,0x90,0x08, -0x00,0x44,0x20,0x21,0x00,0x43,0x10,0x21,0xa1,0x28,0x00,0x07,0xa0,0x40,0x00,0x06, -0xa0,0x80,0x00,0x02,0x08,0x00,0x19,0xc7,0xa0,0x80,0x00,0x01,0x24,0x02,0x00,0x01, -0xa6,0x22,0x00,0x02,0x0c,0x00,0x01,0xc2,0x00,0xe0,0x20,0x21,0x08,0x00,0x1a,0x3b, -0x00,0x00,0x00,0x00,0x30,0xa7,0xff,0xff,0x00,0x07,0x18,0xc0,0x00,0x67,0x18,0x21, -0x3c,0x06,0xb0,0x03,0x3c,0x02,0x80,0x00,0x24,0x42,0x6a,0x44,0x27,0x85,0x90,0x10, -0x00,0x03,0x18,0x80,0x34,0xc6,0x00,0x20,0x00,0x65,0x18,0x21,0xac,0xc2,0x00,0x00, -0x80,0x62,0x00,0x07,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x29,0x00,0x80,0x28,0x21, -0x90,0x82,0x00,0x16,0x00,0x00,0x00,0x00,0x34,0x42,0x00,0x02,0x30,0x43,0x00,0x01, -0x14,0x60,0x00,0x02,0xa0,0x82,0x00,0x16,0xa0,0x80,0x00,0x17,0x90,0xa2,0x00,0x04, -0x3c,0x03,0xb0,0x03,0x27,0x86,0x90,0x00,0x14,0x40,0x00,0x06,0x34,0x63,0x00,0x20, -0x24,0x02,0x00,0x01,0xa0,0xa2,0x00,0x04,0xa4,0xa7,0x00,0x02,0x03,0xe0,0x00,0x08, -0xa4,0xa7,0x00,0x00,0x94,0xa4,0x00,0x02,0x3c,0x02,0x80,0x01,0x24,0x42,0x82,0x6c, -0xac,0x62,0x00,0x00,0x00,0x04,0x18,0xc0,0x00,0x64,0x18,0x21,0x00,0x03,0x18,0x80, -0x00,0x66,0x18,0x21,0x94,0x62,0x00,0x04,0xa4,0x67,0x00,0x02,0x3c,0x03,0xb0,0x08, -0x00,0x02,0x20,0xc0,0x00,0x82,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x46,0x10,0x21, -0x00,0x83,0x20,0x21,0xa4,0x47,0x00,0x00,0xac,0x87,0x00,0x00,0x90,0xa2,0x00,0x04, -0xa4,0xa7,0x00,0x02,0x24,0x42,0x00,0x01,0x03,0xe0,0x00,0x08,0xa0,0xa2,0x00,0x04, -0x90,0x82,0x00,0x16,0x24,0x85,0x00,0x06,0x34,0x42,0x00,0x01,0x30,0x43,0x00,0x02, -0x14,0x60,0xff,0xda,0xa0,0x82,0x00,0x16,0x24,0x02,0x00,0x01,0x08,0x00,0x1a,0xa7, -0xa0,0x82,0x00,0x17,0x27,0xbd,0xff,0xe8,0xaf,0xbf,0x00,0x10,0x00,0x80,0x38,0x21, -0x84,0x84,0x00,0x02,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x3c,0x0a,0xb0,0x06, -0x34,0x63,0x00,0x20,0x24,0x42,0x6b,0x44,0x3c,0x0b,0xb0,0x08,0x27,0x89,0x90,0x00, -0x34,0x0c,0xff,0xff,0x35,0x4a,0x80,0x20,0x10,0x80,0x00,0x30,0xac,0x62,0x00,0x00, -0x97,0x82,0x8f,0xf0,0x94,0xe6,0x02,0xba,0x00,0x02,0x18,0xc0,0x00,0x6b,0x28,0x21, -0xac,0xa6,0x00,0x00,0x8c,0xe4,0x02,0xb8,0x00,0x62,0x18,0x21,0x00,0x03,0x18,0x80, -0x00,0x04,0x10,0xc0,0x00,0x44,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x49,0x10,0x21, -0x94,0x48,0x00,0x04,0x00,0x69,0x18,0x21,0xa4,0x66,0x00,0x00,0x00,0x08,0x28,0xc0, -0x00,0xab,0x10,0x21,0xac,0x4c,0x00,0x00,0x8c,0xe4,0x02,0xb8,0x27,0x82,0x90,0x04, -0x00,0xa8,0x28,0x21,0x00,0x04,0x18,0xc0,0x00,0x64,0x18,0x21,0x00,0x03,0x18,0x80, -0x00,0x62,0x10,0x21,0x8c,0x46,0x00,0x18,0x27,0x84,0x90,0x10,0x00,0x64,0x18,0x21, -0x8c,0xc2,0x00,0x00,0x80,0x67,0x00,0x06,0x00,0x05,0x28,0x80,0x30,0x42,0xff,0xff, -0x00,0x47,0x10,0x21,0x30,0x43,0x00,0xff,0x00,0x03,0x18,0x2b,0x00,0x02,0x12,0x02, -0x00,0x43,0x10,0x21,0x3c,0x04,0x00,0x04,0x00,0xa9,0x28,0x21,0x00,0x44,0x10,0x25, -0xa4,0xac,0x00,0x00,0xad,0x42,0x00,0x00,0xa7,0x88,0x8f,0xf0,0x8f,0xbf,0x00,0x10, -0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x84,0xe3,0x00,0x06, -0x27,0x82,0xb4,0x00,0x94,0xe5,0x02,0xba,0x00,0x03,0x18,0x80,0x00,0x62,0x18,0x21, -0x8c,0x64,0x00,0x00,0x0c,0x00,0x1a,0x91,0x00,0x00,0x00,0x00,0x08,0x00,0x1b,0x0b, -0x00,0x00,0x00,0x00,0x94,0x88,0x00,0x00,0x00,0x80,0x58,0x21,0x27,0x8a,0x90,0x00, -0x00,0x08,0x18,0xc0,0x00,0x68,0x18,0x21,0x3c,0x04,0xb0,0x03,0x00,0x03,0x18,0x80, -0x3c,0x02,0x80,0x00,0x00,0x6a,0x18,0x21,0x34,0x84,0x00,0x20,0x24,0x42,0x6c,0x64, -0x30,0xa5,0xff,0xff,0xac,0x82,0x00,0x00,0x94,0x67,0x00,0x02,0x11,0x05,0x00,0x35, -0x24,0x04,0x00,0x01,0x91,0x66,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x86,0x10,0x2a, -0x10,0x40,0x00,0x10,0x00,0xc0,0x48,0x21,0x3c,0x0d,0xb0,0x03,0x01,0x40,0x60,0x21, -0x35,0xad,0x00,0x20,0x10,0xe5,0x00,0x0d,0x24,0x84,0x00,0x01,0x00,0x07,0x10,0xc0, -0x00,0x47,0x10,0x21,0x00,0x02,0x10,0x80,0x01,0x20,0x30,0x21,0x00,0x4a,0x10,0x21, -0x00,0x86,0x18,0x2a,0x00,0xe0,0x40,0x21,0x94,0x47,0x00,0x02,0x14,0x60,0xff,0xf5, -0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x10,0x21,0x00,0x08,0x20,0xc0, -0x00,0x88,0x20,0x21,0x24,0xc2,0xff,0xff,0x00,0x04,0x20,0x80,0xa1,0x62,0x00,0x04, -0x00,0x8c,0x20,0x21,0x94,0x83,0x00,0x04,0x00,0x07,0x10,0xc0,0x00,0x47,0x10,0x21, -0x00,0x02,0x10,0x80,0x00,0x4c,0x10,0x21,0x00,0x03,0x28,0xc0,0x94,0x46,0x00,0x02, -0x00,0xa3,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x6c,0x18,0x21,0xa4,0x66,0x00,0x00, -0xa4,0x86,0x00,0x02,0x95,0x64,0x00,0x02,0x3c,0x03,0xb0,0x08,0x3c,0x02,0x80,0x01, -0x00,0xa3,0x28,0x21,0x24,0x42,0x82,0x6c,0xad,0xa2,0x00,0x00,0x10,0x87,0x00,0x03, -0xac,0xa6,0x00,0x00,0x03,0xe0,0x00,0x08,0x24,0x02,0x00,0x01,0x08,0x00,0x1b,0x59, -0xa5,0x68,0x00,0x02,0x91,0x62,0x00,0x04,0xa5,0x67,0x00,0x00,0x24,0x42,0xff,0xff, -0x30,0x43,0x00,0xff,0x14,0x60,0xff,0xf7,0xa1,0x62,0x00,0x04,0x24,0x02,0xff,0xff, -0x08,0x00,0x1b,0x59,0xa5,0x62,0x00,0x02,0x00,0x05,0x40,0xc0,0x01,0x05,0x30,0x21, -0x27,0xbd,0xff,0xd8,0x00,0x06,0x30,0x80,0x27,0x82,0x90,0x04,0xaf,0xb2,0x00,0x18, -0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x20,0xaf,0xb3,0x00,0x1c,0xaf,0xb0,0x00,0x10, -0x00,0xc2,0x10,0x21,0x8c,0x47,0x00,0x18,0x00,0xa0,0x90,0x21,0x3c,0x02,0x80,0x00, -0x3c,0x05,0xb0,0x03,0x34,0xa5,0x00,0x20,0x24,0x42,0x6d,0x98,0xac,0xa2,0x00,0x00, -0x27,0x83,0x90,0x10,0x00,0xc3,0x30,0x21,0x8c,0xe2,0x00,0x00,0x80,0xc5,0x00,0x06, -0x00,0x80,0x88,0x21,0x30,0x42,0xff,0xff,0x00,0x45,0x10,0x21,0x30,0x43,0x00,0xff, -0x10,0x60,0x00,0x02,0x00,0x02,0x12,0x02,0x24,0x42,0x00,0x01,0x30,0x53,0x00,0xff, -0x01,0x12,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x10,0x00,0x43,0x10,0x21, -0x80,0x44,0x00,0x07,0x00,0x00,0x00,0x00,0x10,0x80,0x00,0x4b,0x26,0x24,0x00,0x06, -0x32,0x50,0xff,0xff,0x02,0x20,0x20,0x21,0x0c,0x00,0x1b,0x19,0x02,0x00,0x28,0x21, -0x92,0x22,0x00,0x10,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x2e,0x3c,0x03,0xb0,0x08, -0x3c,0x09,0x80,0x01,0x27,0x88,0x90,0x00,0xa6,0x32,0x00,0x0c,0x00,0x10,0x20,0xc0, -0x00,0x90,0x20,0x21,0x00,0x04,0x20,0x80,0x00,0x88,0x20,0x21,0x94,0x82,0x00,0x04, -0x3c,0x03,0xb0,0x08,0x3c,0x07,0xb0,0x03,0x00,0x02,0x28,0xc0,0x00,0xa2,0x10,0x21, -0x00,0x02,0x10,0x80,0x00,0x48,0x10,0x21,0x00,0xa3,0x28,0x21,0x25,0x26,0x82,0x6c, -0x34,0x03,0xff,0xff,0x34,0xe7,0x00,0x20,0xac,0xe6,0x00,0x00,0xa4,0x83,0x00,0x02, -0xa4,0x43,0x00,0x00,0xac,0xa3,0x00,0x00,0x92,0x22,0x00,0x10,0x92,0x23,0x00,0x0a, -0xa6,0x32,0x00,0x0e,0x02,0x62,0x10,0x21,0x14,0x60,0x00,0x05,0xa2,0x22,0x00,0x10, -0x92,0x22,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xfe,0xa2,0x22,0x00,0x16, -0x92,0x22,0x00,0x04,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x05,0x00,0x00,0x00,0x00, -0x92,0x22,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xfd,0xa2,0x22,0x00,0x16, -0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x28,0x96,0x22,0x00,0x0e,0x27,0x88,0x90,0x00,0x00,0x02,0x20,0xc0, -0x00,0x82,0x20,0x21,0x00,0x04,0x20,0x80,0x00,0x88,0x20,0x21,0x94,0x82,0x00,0x04, -0x3c,0x06,0xb0,0x03,0x3c,0x09,0x80,0x01,0x00,0x02,0x28,0xc0,0x00,0xa2,0x10,0x21, -0x00,0x02,0x10,0x80,0x00,0xa3,0x28,0x21,0x00,0x48,0x10,0x21,0x34,0xc6,0x00,0x20, -0x25,0x23,0x82,0x6c,0xac,0xc3,0x00,0x00,0xa4,0x50,0x00,0x00,0xac,0xb0,0x00,0x00, -0x08,0x00,0x1b,0x97,0xa4,0x90,0x00,0x02,0x08,0x00,0x1b,0x8e,0x32,0x50,0xff,0xff, -0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00,0x24,0x42,0x6f,0x60,0x34,0x63,0x00,0x20, -0xac,0x62,0x00,0x00,0x90,0x82,0x00,0x04,0x97,0xaa,0x00,0x12,0x00,0x80,0x60,0x21, -0x30,0xa8,0xff,0xff,0x00,0x4a,0x20,0x23,0x34,0x09,0xff,0xff,0x30,0xcf,0xff,0xff, -0x30,0xee,0xff,0xff,0x11,0x09,0x00,0x73,0xa1,0x84,0x00,0x04,0x00,0x0e,0xc0,0xc0, -0x00,0x08,0x10,0xc0,0x00,0x48,0x10,0x21,0x03,0x0e,0x20,0x21,0x27,0x8d,0x90,0x00, -0x00,0x04,0x20,0x80,0x00,0x02,0x10,0x80,0x00,0x4d,0x10,0x21,0x00,0x8d,0x20,0x21, -0x94,0x86,0x00,0x02,0x94,0x43,0x00,0x04,0x3c,0x19,0x80,0x01,0xa4,0x46,0x00,0x02, -0x00,0x03,0x28,0xc0,0x00,0xa3,0x18,0x21,0x94,0x87,0x00,0x02,0x3c,0x02,0xb0,0x08, -0x00,0x03,0x18,0x80,0x00,0xa2,0x28,0x21,0x00,0x6d,0x18,0x21,0x27,0x22,0x82,0x6c, -0x3c,0x01,0xb0,0x03,0xac,0x22,0x00,0x20,0xa4,0x66,0x00,0x00,0x10,0xe9,0x00,0x57, -0xac,0xa6,0x00,0x00,0x01,0xe0,0x30,0x21,0x11,0x40,0x00,0x1d,0x00,0x00,0x48,0x21, -0x01,0x40,0x38,0x21,0x27,0x8b,0x90,0x04,0x27,0x8a,0x90,0x10,0x00,0x06,0x40,0xc0, -0x01,0x06,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x6b,0x10,0x21,0x8c,0x44,0x00,0x18, -0x00,0x6a,0x18,0x21,0x80,0x65,0x00,0x06,0x8c,0x82,0x00,0x00,0x00,0x00,0x00,0x00, -0x30,0x42,0xff,0xff,0x00,0x45,0x10,0x21,0x30,0x44,0x00,0xff,0x00,0x02,0x12,0x02, -0x01,0x22,0x18,0x21,0x24,0x62,0x00,0x01,0x14,0x80,0x00,0x02,0x30,0x49,0x00,0xff, -0x30,0x69,0x00,0xff,0x01,0x06,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x4d,0x10,0x21, -0x24,0xe7,0xff,0xff,0x94,0x46,0x00,0x02,0x14,0xe0,0xff,0xe9,0x00,0x06,0x40,0xc0, -0x91,0x82,0x00,0x10,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x20,0x3c,0x06,0xb0,0x03, -0xa5,0x8f,0x00,0x0c,0x03,0x0e,0x20,0x21,0x00,0x04,0x20,0x80,0x00,0x8d,0x20,0x21, -0x94,0x82,0x00,0x04,0x3c,0x03,0xb0,0x08,0x3c,0x07,0xb0,0x03,0x00,0x02,0x28,0xc0, -0x00,0xa2,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x4d,0x10,0x21,0x00,0xa3,0x28,0x21, -0x27,0x26,0x82,0x6c,0x34,0x03,0xff,0xff,0x34,0xe7,0x00,0x20,0xac,0xe6,0x00,0x00, -0xa4,0x83,0x00,0x02,0xa4,0x43,0x00,0x00,0xac,0xa3,0x00,0x00,0x91,0x82,0x00,0x10, -0x91,0x83,0x00,0x04,0xa5,0x8e,0x00,0x0e,0x01,0x22,0x10,0x21,0x14,0x60,0x00,0x05, -0xa1,0x82,0x00,0x10,0x91,0x82,0x00,0x16,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0xfd, -0xa1,0x82,0x00,0x16,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x95,0x82,0x00,0x0e, -0x3c,0x03,0xb0,0x08,0x00,0x02,0x20,0xc0,0x00,0x82,0x20,0x21,0x00,0x04,0x20,0x80, -0x00,0x8d,0x20,0x21,0x94,0x82,0x00,0x04,0x34,0xc6,0x00,0x20,0x27,0x27,0x82,0x6c, -0x00,0x02,0x28,0xc0,0x00,0xa2,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0xa3,0x28,0x21, -0x00,0x4d,0x10,0x21,0xac,0xc7,0x00,0x00,0xa4,0x8f,0x00,0x02,0xa4,0x4f,0x00,0x00, -0xac,0xaf,0x00,0x00,0x08,0x00,0x1c,0x26,0x03,0x0e,0x20,0x21,0x08,0x00,0x1c,0x01, -0xa5,0x88,0x00,0x02,0x00,0x0e,0xc0,0xc0,0x03,0x0e,0x10,0x21,0x00,0x02,0x10,0x80, -0x27,0x8d,0x90,0x00,0x00,0x4d,0x10,0x21,0x94,0x43,0x00,0x02,0x30,0x84,0x00,0xff, -0x14,0x80,0x00,0x05,0xa5,0x83,0x00,0x00,0x24,0x02,0xff,0xff,0x3c,0x19,0x80,0x01, -0x08,0x00,0x1c,0x01,0xa5,0x82,0x00,0x02,0x08,0x00,0x1c,0x01,0x3c,0x19,0x80,0x01, -0x3c,0x08,0xb0,0x03,0x3c,0x02,0x80,0x00,0x27,0xbd,0xff,0x78,0x35,0x08,0x00,0x20, -0x24,0x42,0x71,0xa0,0xaf,0xb2,0x00,0x68,0xaf,0xb1,0x00,0x64,0xaf,0xb0,0x00,0x60, -0xad,0x02,0x00,0x00,0xaf,0xbf,0x00,0x84,0xaf,0xbe,0x00,0x80,0xaf,0xb7,0x00,0x7c, -0xaf,0xb6,0x00,0x78,0xaf,0xb5,0x00,0x74,0xaf,0xb4,0x00,0x70,0xaf,0xb3,0x00,0x6c, -0xaf,0xa4,0x00,0x88,0x90,0x83,0x00,0x0a,0x27,0x82,0xb4,0x00,0xaf,0xa6,0x00,0x90, -0x00,0x03,0x18,0x80,0x00,0x62,0x18,0x21,0x8c,0x63,0x00,0x00,0xaf,0xa7,0x00,0x94, -0x27,0x86,0x90,0x04,0xaf,0xa3,0x00,0x1c,0x94,0x63,0x00,0x14,0x30,0xb1,0xff,0xff, -0x24,0x08,0x00,0x01,0x00,0x03,0x20,0xc0,0xaf,0xa3,0x00,0x18,0x00,0x83,0x18,0x21, -0xaf,0xa4,0x00,0x54,0x00,0x03,0x18,0x80,0x27,0x84,0x90,0x10,0x00,0x64,0x20,0x21, -0x80,0x82,0x00,0x06,0x00,0x66,0x18,0x21,0x8c,0x66,0x00,0x18,0x24,0x42,0x00,0x02, -0x00,0x02,0x1f,0xc2,0x8c,0xc4,0x00,0x08,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43, -0x00,0x02,0x10,0x40,0x00,0x04,0x2f,0xc2,0x00,0x04,0x1c,0x82,0x00,0xc2,0x38,0x21, -0x00,0x04,0x24,0x42,0x8f,0xa2,0x00,0x1c,0x30,0x63,0x00,0x01,0x30,0x84,0x00,0x01, -0xaf,0xa5,0x00,0x3c,0xaf,0xa3,0x00,0x34,0xaf,0xa4,0x00,0x38,0xaf,0xa0,0x00,0x40, -0xaf,0xa0,0x00,0x44,0xaf,0xa0,0x00,0x50,0xaf,0xa8,0x00,0x20,0x80,0x42,0x00,0x12, -0x8f,0xb2,0x00,0x18,0xaf,0xa2,0x00,0x28,0x8c,0xd0,0x00,0x0c,0x14,0xa0,0x01,0xe4, -0x00,0x60,0x30,0x21,0x00,0x10,0x10,0x82,0x30,0x45,0x00,0x07,0x10,0xa0,0x00,0x11, -0xaf,0xa0,0x00,0x30,0x8f,0xa4,0x00,0x98,0x27,0x82,0x80,0x1c,0x00,0x04,0x18,0x40, -0x00,0x62,0x18,0x21,0x24,0xa2,0x00,0x06,0x8f,0xa5,0x00,0x20,0x94,0x64,0x00,0x00, -0x00,0x45,0x10,0x04,0x00,0x44,0x00,0x1a,0x14,0x80,0x00,0x02,0x00,0x00,0x00,0x00, -0x00,0x07,0x00,0x0d,0x00,0x00,0x10,0x12,0x24,0x42,0x00,0x20,0x30,0x42,0xff,0xfc, -0xaf,0xa2,0x00,0x30,0x8f,0xa3,0x00,0x18,0x8f,0xa4,0x00,0x28,0x34,0x02,0xff,0xff, -0xaf,0xa0,0x00,0x2c,0xaf,0xa2,0x00,0x48,0xaf,0xa3,0x00,0x4c,0x00,0x60,0xf0,0x21, -0x00,0x00,0xb8,0x21,0x18,0x80,0x00,0x48,0xaf,0xa0,0x00,0x24,0x00,0x11,0x89,0x02, -0xaf,0xb1,0x00,0x58,0x00,0x80,0xa8,0x21,0x00,0x12,0x10,0xc0,0x00,0x52,0x18,0x21, -0x00,0x03,0x80,0x80,0x27,0x85,0x90,0x00,0x02,0x40,0x20,0x21,0x00,0x40,0xa0,0x21, -0x02,0x05,0x10,0x21,0x94,0x56,0x00,0x02,0x0c,0x00,0x12,0x8b,0x00,0x00,0x28,0x21, -0x90,0x42,0x00,0x00,0x24,0x03,0x00,0x08,0x30,0x42,0x00,0x0c,0x10,0x43,0x01,0x9e, -0x24,0x04,0x00,0x01,0x24,0x02,0x00,0x01,0x10,0x82,0x01,0x7c,0x3c,0x02,0xb0,0x03, -0x8f,0xa6,0x00,0x88,0x34,0x42,0x01,0x04,0x84,0xc5,0x00,0x0c,0x02,0x92,0x18,0x21, -0x94,0x46,0x00,0x00,0x00,0x05,0x20,0xc0,0x00,0x85,0x20,0x21,0x00,0x03,0x18,0x80, -0x27,0x82,0x90,0x10,0x27,0x85,0x90,0x08,0x00,0x65,0x28,0x21,0x00,0x62,0x18,0x21, -0x80,0x71,0x00,0x05,0x80,0x73,0x00,0x04,0x8f,0xa3,0x00,0x88,0x30,0xd0,0xff,0xff, -0x00,0x10,0x3a,0x03,0x32,0x08,0x00,0xff,0x27,0x82,0x90,0x20,0x00,0x04,0x20,0x80, -0x80,0xa6,0x00,0x06,0x00,0x82,0x20,0x21,0xa4,0x67,0x00,0x44,0xa4,0x68,0x00,0x46, -0x8c,0x84,0x00,0x00,0x38,0xc6,0x00,0x00,0x01,0x00,0x80,0x21,0x00,0x04,0x15,0x02, -0x30,0x42,0x00,0x01,0x10,0x40,0x00,0x03,0x00,0xe6,0x80,0x0a,0x00,0x04,0x14,0x02, -0x30,0x50,0x00,0x0f,0x12,0x20,0x01,0x50,0x02,0x40,0x20,0x21,0x02,0x71,0x10,0x21, -0x00,0x50,0x10,0x2a,0x14,0x40,0x00,0xed,0x02,0x92,0x10,0x21,0x93,0x82,0x8b,0x71, -0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01,0x14,0x40,0x00,0xe0,0x02,0x92,0x28,0x21, -0x26,0xe2,0x00,0x01,0x30,0x57,0xff,0xff,0x02,0x40,0xf0,0x21,0x26,0xb5,0xff,0xff, -0x16,0xa0,0xff,0xbd,0x02,0xc0,0x90,0x21,0x16,0xe0,0x00,0xd0,0x00,0x00,0x00,0x00, -0x8f,0xa3,0x00,0x98,0x00,0x00,0x00,0x00,0x2c,0x62,0x00,0x10,0x10,0x40,0x00,0x2e, -0x00,0x00,0x00,0x00,0x8f,0xa4,0x00,0x24,0x00,0x00,0x00,0x00,0x18,0x80,0x00,0x2a, -0x24,0x03,0x00,0x01,0x8f,0xa5,0x00,0x1c,0x27,0x84,0x90,0x04,0x94,0xb2,0x00,0x14, -0xa0,0xa3,0x00,0x12,0x8f,0xa6,0x00,0x3c,0x00,0x12,0x10,0xc0,0x00,0x52,0x10,0x21, -0x00,0x02,0x80,0x80,0x27,0x82,0x90,0x10,0x02,0x02,0x10,0x21,0x80,0x43,0x00,0x06, -0x02,0x04,0x20,0x21,0x8c,0x85,0x00,0x18,0x24,0x63,0x00,0x02,0x00,0x03,0x17,0xc2, -0x00,0x62,0x18,0x21,0x00,0x03,0x18,0x43,0x00,0x03,0x18,0x40,0x14,0xc0,0x00,0x0e, -0x00,0xa3,0x38,0x21,0x27,0x82,0x90,0x00,0x02,0x02,0x10,0x21,0x94,0x43,0x00,0x06, -0x8f,0xa8,0x00,0x1c,0x24,0x02,0x00,0x01,0xa5,0x03,0x00,0x1a,0x7b,0xbe,0x04,0x3c, -0x7b,0xb6,0x03,0xfc,0x7b,0xb4,0x03,0xbc,0x7b,0xb2,0x03,0x7c,0x7b,0xb0,0x03,0x3c, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x88,0x8f,0xa4,0x00,0x98,0x8f,0xa5,0x00,0x38, -0x8f,0xa6,0x00,0x34,0xaf,0xa0,0x00,0x10,0x0c,0x00,0x09,0x0a,0xaf,0xa0,0x00,0x14, -0x08,0x00,0x1d,0x2d,0x00,0x00,0x00,0x00,0x8f,0xa3,0x00,0x44,0x93,0x82,0x81,0x58, -0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x61,0x30,0x69,0x00,0x03,0x8f,0xa4,0x00,0x24, -0x8f,0xa5,0x00,0x28,0x00,0x00,0x00,0x00,0x00,0x85,0x10,0x2a,0x10,0x40,0x00,0x8f, -0x00,0x00,0x00,0x00,0x8f,0xa6,0x00,0x1c,0x00,0x00,0x00,0x00,0x90,0xc4,0x00,0x04, -0x00,0x00,0x00,0x00,0x30,0x83,0x00,0xff,0x00,0xa3,0x10,0x2a,0x10,0x40,0x00,0x87, -0x00,0x00,0x00,0x00,0x8f,0xa8,0x00,0x24,0x00,0x00,0x00,0x00,0x11,0x00,0x00,0x83, -0x00,0x65,0x10,0x23,0x00,0xa8,0x18,0x23,0x00,0x62,0x10,0x2a,0x14,0x40,0x00,0x7d, -0x30,0x63,0x00,0xff,0x00,0x85,0x10,0x23,0x30,0x42,0x00,0xff,0xaf,0xa2,0x00,0x50, -0x8f,0xa2,0x00,0x50,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x73,0x00,0x00,0xa8,0x21, -0x27,0x8c,0x90,0x00,0x3c,0x0b,0x80,0xff,0x24,0x10,0x00,0x04,0x27,0x91,0x90,0x04, -0x35,0x6b,0xff,0xff,0x3c,0x0d,0x7f,0x00,0x27,0x8e,0x90,0x10,0x01,0x80,0x78,0x21, -0x00,0x12,0x30,0xc0,0x00,0xd2,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x4c,0x10,0x21, -0x94,0x42,0x00,0x06,0x8f,0xa3,0x00,0x2c,0x8f,0xa4,0x00,0x30,0xaf,0xa2,0x00,0x44, -0x8f,0xa5,0x00,0x44,0x30,0x49,0x00,0x03,0x02,0x09,0x10,0x23,0x30,0x42,0x00,0x03, -0x00,0xa2,0x10,0x21,0x8f,0xa8,0x00,0x30,0x24,0x42,0x00,0x04,0x30,0x42,0xff,0xff, -0x00,0x64,0x38,0x21,0x01,0x02,0x28,0x23,0x00,0x62,0x18,0x21,0x00,0x48,0x10,0x2b, -0x10,0x40,0x00,0x52,0x00,0x00,0x20,0x21,0x30,0xe7,0xff,0xff,0x30,0xa4,0xff,0xff, -0xaf,0xa7,0x00,0x2c,0x00,0xd2,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x51,0x18,0x21, -0x8c,0x65,0x00,0x18,0x00,0x04,0x25,0x40,0x00,0x8d,0x20,0x24,0x8c,0xa8,0x00,0x04, -0x00,0x4e,0x18,0x21,0x00,0x4f,0x50,0x21,0x01,0x0b,0x40,0x24,0x01,0x04,0x40,0x25, -0xac,0xa8,0x00,0x04,0x8f,0xa4,0x00,0x98,0x8f,0xa2,0x00,0x50,0x26,0xb5,0x00,0x01, -0xa0,0x64,0x00,0x00,0x8c,0xa4,0x00,0x08,0x00,0x00,0x00,0x00,0x04,0x81,0x00,0x0c, -0x02,0xa2,0x30,0x2a,0x80,0x62,0x00,0x06,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x02, -0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43,0x00,0x02,0x10,0x40, -0x00,0xa2,0x38,0x21,0x8f,0xa5,0x00,0x40,0x00,0x00,0x00,0x00,0xa4,0xe5,0x00,0x00, -0x95,0x52,0x00,0x02,0x14,0xc0,0xff,0xc7,0x00,0x12,0x30,0xc0,0x8f,0xa4,0x00,0x24, -0x8f,0xa5,0x00,0x50,0x8f,0xa6,0x00,0x1c,0x8f,0xa3,0x00,0x2c,0x00,0x85,0x80,0x21, -0xa0,0xd0,0x00,0x12,0x00,0x09,0x10,0x23,0x30,0x42,0x00,0x03,0x8f,0xa8,0x00,0x88, -0x00,0x62,0x10,0x23,0xa4,0xc2,0x00,0x1a,0x85,0x03,0x00,0x0c,0x00,0x00,0x00,0x00, -0x00,0x03,0x10,0xc0,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x04, -0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x18,0x00,0x00,0x00,0x00,0x8c,0x83,0x00,0x04, -0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x10,0x14,0x60,0xff,0x74,0x02,0x00,0x10,0x21, -0x8f,0xa3,0x00,0x54,0x8f,0xa4,0x00,0x18,0x8f,0xa5,0x00,0x24,0x00,0x64,0x10,0x21, -0x00,0x02,0x10,0x80,0x27,0x83,0x90,0x18,0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x00, -0x10,0xa0,0x00,0x03,0x00,0x00,0x30,0x21,0x08,0x00,0x1d,0x33,0x02,0x00,0x10,0x21, -0x93,0x82,0x80,0x10,0x00,0x00,0x28,0x21,0x00,0x00,0x38,0x21,0x0c,0x00,0x21,0x9a, -0xaf,0xa2,0x00,0x10,0x08,0x00,0x1d,0x33,0x02,0x00,0x10,0x21,0x30,0x63,0xff,0xff, -0x08,0x00,0x1d,0x85,0xaf,0xa3,0x00,0x2c,0x8f,0xa8,0x00,0x44,0x08,0x00,0x1d,0xa7, -0x31,0x09,0x00,0x03,0x08,0x00,0x1d,0x60,0xaf,0xa3,0x00,0x50,0x8f,0xa6,0x00,0x44, -0xaf,0xa0,0x00,0x50,0x08,0x00,0x1d,0xa7,0x30,0xc9,0x00,0x03,0x8f,0xa5,0x00,0x48, -0x8f,0xa6,0x00,0x4c,0x8f,0xa4,0x00,0x1c,0x03,0xc0,0x38,0x21,0x0c,0x00,0x1b,0xd8, -0xaf,0xb7,0x00,0x10,0x08,0x00,0x1d,0x10,0x00,0x00,0x00,0x00,0x00,0x05,0x28,0x80, -0x27,0x82,0x90,0x00,0x00,0xa2,0x28,0x21,0x00,0x00,0x20,0x21,0x0c,0x00,0x01,0x49, -0x00,0x00,0x00,0x00,0x08,0x00,0x1d,0x09,0x26,0xe2,0x00,0x01,0x00,0x02,0x80,0x80, -0x27,0x83,0x90,0x10,0x8f,0xa4,0x00,0x1c,0x02,0x03,0x18,0x21,0x26,0x31,0x00,0x01, -0x02,0x40,0x28,0x21,0x0c,0x00,0x1e,0xea,0xa0,0x71,0x00,0x05,0x14,0x40,0xff,0x13, -0x00,0x00,0x00,0x00,0x16,0xe0,0x00,0x4d,0x03,0xc0,0x38,0x21,0x8f,0xa4,0x00,0x24, -0x8f,0xa5,0x00,0x20,0x24,0x02,0x00,0x01,0x24,0x84,0x00,0x01,0xaf,0xb2,0x00,0x48, -0xaf,0xb6,0x00,0x4c,0x02,0xc0,0xf0,0x21,0x10,0xa2,0x00,0x41,0xaf,0xa4,0x00,0x24, -0x27,0x82,0x90,0x00,0x02,0x02,0x10,0x21,0x94,0x42,0x00,0x06,0x8f,0xa4,0x00,0x30, -0xaf,0xa0,0x00,0x20,0xaf,0xa2,0x00,0x44,0x30,0x49,0x00,0x03,0x8f,0xa8,0x00,0x44, -0x00,0x09,0x10,0x23,0x30,0x42,0x00,0x03,0x01,0x02,0x10,0x21,0x24,0x42,0x00,0x04, -0x30,0x42,0xff,0xff,0x00,0x44,0x18,0x2b,0x10,0x60,0x00,0x2b,0x00,0x00,0x00,0x00, -0x8f,0xa5,0x00,0x2c,0x00,0x82,0x10,0x23,0x00,0xa4,0x18,0x21,0x30,0x63,0xff,0xff, -0x30,0x44,0xff,0xff,0xaf,0xa3,0x00,0x2c,0x02,0x92,0x28,0x21,0x00,0x05,0x28,0x80, -0x27,0x82,0x90,0x04,0x00,0xa2,0x10,0x21,0x8c,0x46,0x00,0x18,0x3c,0x03,0x80,0xff, -0x3c,0x02,0x7f,0x00,0x8c,0xc8,0x00,0x04,0x00,0x04,0x25,0x40,0x34,0x63,0xff,0xff, -0x00,0x82,0x20,0x24,0x01,0x03,0x40,0x24,0x01,0x04,0x40,0x25,0xac,0xc8,0x00,0x04, -0x8f,0xa8,0x00,0x98,0x27,0x82,0x90,0x10,0x00,0xa2,0x10,0x21,0xa0,0x48,0x00,0x00, -0x8c,0xc4,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x04,0x27,0xc2,0x10,0x80,0xfe,0xdb, -0xaf,0xa4,0x00,0x3c,0x80,0x42,0x00,0x06,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x02, -0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43,0x00,0x02,0x10,0x40, -0x00,0xc2,0x38,0x21,0x8f,0xa2,0x00,0x40,0x00,0x00,0x00,0x00,0xa4,0xe2,0x00,0x00, -0x08,0x00,0x1d,0x0c,0x26,0xb5,0xff,0xff,0x8f,0xa6,0x00,0x2c,0x00,0x00,0x20,0x21, -0x00,0xc2,0x10,0x21,0x30,0x42,0xff,0xff,0x08,0x00,0x1e,0x1a,0xaf,0xa2,0x00,0x2c, -0x8f,0xa6,0x00,0x1c,0x08,0x00,0x1e,0x04,0xa4,0xd2,0x00,0x14,0x8f,0xa5,0x00,0x48, -0x8f,0xa6,0x00,0x4c,0x8f,0xa4,0x00,0x1c,0x0c,0x00,0x1b,0xd8,0xaf,0xb7,0x00,0x10, -0x08,0x00,0x1d,0xfb,0x00,0x00,0xb8,0x21,0x0c,0x00,0x12,0x8b,0x00,0x00,0x28,0x21, -0x00,0x40,0x18,0x21,0x94,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x34,0x42,0x08,0x00, -0xa4,0x62,0x00,0x00,0x08,0x00,0x1d,0x00,0x02,0x71,0x10,0x21,0x02,0x92,0x18,0x21, -0x00,0x03,0x80,0x80,0x27,0x82,0x90,0x04,0x02,0x02,0x10,0x21,0x8c,0x44,0x00,0x18, -0x00,0x00,0x00,0x00,0x8c,0x83,0x00,0x04,0x00,0x00,0x00,0x00,0x30,0x63,0x00,0x10, -0x10,0x60,0x00,0x09,0x24,0x06,0x00,0x01,0x93,0x82,0x8b,0x71,0x00,0x00,0x00,0x00, -0x30,0x42,0x00,0x01,0x10,0x40,0xfe,0xa2,0x3c,0x04,0x00,0x80,0x27,0x85,0x90,0x00, -0x08,0x00,0x1d,0xeb,0x02,0x05,0x28,0x21,0x27,0x83,0x90,0x18,0x27,0x82,0x90,0x10, -0x02,0x03,0x18,0x21,0x02,0x02,0x10,0x21,0x90,0x64,0x00,0x00,0x90,0x45,0x00,0x05, -0x93,0x83,0x80,0x10,0x00,0x00,0x38,0x21,0x0c,0x00,0x21,0x9a,0xaf,0xa3,0x00,0x10, -0x08,0x00,0x1e,0x62,0x00,0x00,0x00,0x00,0x27,0x82,0x90,0x18,0x02,0x02,0x10,0x21, -0x94,0x43,0x00,0x02,0x8f,0xa6,0x00,0x58,0x00,0x03,0x19,0x02,0x00,0x66,0x18,0x23, -0x30,0x63,0x0f,0xff,0x28,0x62,0x00,0x20,0x10,0x40,0x00,0x06,0x28,0x62,0x00,0x40, -0x8f,0xa8,0x00,0x90,0x00,0x00,0x00,0x00,0x00,0x68,0x10,0x06,0x08,0x00,0x1c,0xd9, -0x30,0x44,0x00,0x01,0x10,0x40,0x00,0x04,0x00,0x00,0x00,0x00,0x8f,0xa4,0x00,0x94, -0x08,0x00,0x1e,0x83,0x00,0x64,0x10,0x06,0x08,0x00,0x1c,0xd9,0x00,0x00,0x20,0x21, -0x8f,0xa4,0x00,0x98,0x8f,0xa5,0x00,0x38,0xaf,0xa0,0x00,0x10,0x0c,0x00,0x09,0x0a, -0xaf,0xa8,0x00,0x14,0x30,0x42,0xff,0xff,0x08,0x00,0x1c,0xa9,0xaf,0xa2,0x00,0x40, -0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x00,0x27,0xbd,0xff,0xe0,0x34,0x42,0x00,0x20, -0x24,0x63,0x7a,0x50,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x18, -0xac,0x43,0x00,0x00,0x90,0x82,0x00,0x0a,0x00,0x80,0x80,0x21,0x14,0x40,0x00,0x45, -0x00,0x00,0x88,0x21,0x92,0x02,0x00,0x04,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x3c, -0x00,0x00,0x00,0x00,0x12,0x20,0x00,0x18,0x00,0x00,0x00,0x00,0x92,0x02,0x00,0x16, -0x92,0x05,0x00,0x0a,0x30,0x42,0x00,0xfc,0x10,0xa0,0x00,0x03,0xa2,0x02,0x00,0x16, -0x34,0x42,0x00,0x01,0xa2,0x02,0x00,0x16,0x92,0x04,0x00,0x04,0x00,0x00,0x00,0x00, -0x30,0x83,0x00,0xff,0x10,0x60,0x00,0x05,0x00,0x00,0x00,0x00,0x92,0x02,0x00,0x16, -0x00,0x00,0x00,0x00,0x34,0x42,0x00,0x02,0xa2,0x02,0x00,0x16,0x10,0x60,0x00,0x0a, -0x00,0x00,0x00,0x00,0x14,0xa0,0x00,0x08,0x00,0x00,0x00,0x00,0x96,0x02,0x00,0x00, -0xa2,0x00,0x00,0x17,0xa6,0x02,0x00,0x14,0x8f,0xbf,0x00,0x18,0x7b,0xb0,0x00,0xbc, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x14,0x80,0x00,0x05,0x24,0x02,0x00,0x01, -0x96,0x03,0x00,0x06,0xa2,0x02,0x00,0x17,0x08,0x00,0x1e,0xbe,0xa6,0x03,0x00,0x14, -0x96,0x04,0x00,0x00,0x96,0x05,0x00,0x06,0x27,0x86,0x90,0x00,0x00,0x04,0x10,0xc0, -0x00,0x05,0x18,0xc0,0x00,0x44,0x10,0x21,0x00,0x65,0x18,0x21,0x00,0x02,0x10,0x80, -0x00,0x03,0x18,0x80,0x00,0x66,0x18,0x21,0x00,0x46,0x10,0x21,0x8c,0x65,0x00,0x08, -0x8c,0x44,0x00,0x08,0x0c,0x00,0x12,0x7c,0x00,0x00,0x00,0x00,0x30,0x43,0x00,0xff, -0x10,0x60,0x00,0x04,0xa2,0x02,0x00,0x17,0x96,0x02,0x00,0x06,0x08,0x00,0x1e,0xbe, -0xa6,0x02,0x00,0x14,0x96,0x02,0x00,0x00,0x08,0x00,0x1e,0xbe,0xa6,0x02,0x00,0x14, -0x96,0x05,0x00,0x00,0x0c,0x00,0x1e,0xea,0x02,0x00,0x20,0x21,0x08,0x00,0x1e,0xa5, -0x02,0x22,0x88,0x21,0x94,0x85,0x00,0x06,0x0c,0x00,0x1e,0xea,0x00,0x00,0x00,0x00, -0x08,0x00,0x1e,0xa1,0x00,0x40,0x88,0x21,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x00, -0x34,0x63,0x00,0x20,0x24,0x42,0x7b,0xa8,0x27,0xbd,0xff,0xf0,0xac,0x62,0x00,0x00, -0x00,0x00,0x10,0x21,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x10,0x3c,0x03,0xb0,0x03, -0x3c,0x02,0x80,0x00,0x34,0x63,0x00,0x20,0x24,0x42,0x7b,0xcc,0xac,0x62,0x00,0x00, -0x90,0x89,0x00,0x0a,0x00,0x80,0x30,0x21,0x11,0x20,0x00,0x05,0x00,0xa0,0x50,0x21, -0x90,0x82,0x00,0x17,0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x1b,0x00,0x00,0x00,0x00, -0x90,0xc7,0x00,0x04,0x00,0x00,0x00,0x00,0x10,0xe0,0x00,0x1b,0x00,0x00,0x00,0x00, -0x94,0xc8,0x00,0x00,0x27,0x83,0x90,0x00,0x93,0x85,0x8b,0x70,0x00,0x08,0x10,0xc0, -0x00,0x48,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x08, -0x00,0xe5,0x28,0x2b,0x10,0xa0,0x00,0x06,0x01,0x44,0x18,0x23,0x8f,0x82,0x8b,0x88, -0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x2b,0x10,0x40,0x00,0x05,0x00,0x00,0x00,0x00, -0x24,0x03,0x00,0x10,0xa4,0xc8,0x00,0x14,0x03,0xe0,0x00,0x08,0x00,0x60,0x10,0x21, -0x11,0x20,0x00,0x05,0x00,0x00,0x00,0x00,0x94,0xc2,0x00,0x06,0x24,0x03,0x00,0x08, -0x08,0x00,0x1f,0x16,0xa4,0xc2,0x00,0x14,0x08,0x00,0x1f,0x16,0x00,0x00,0x18,0x21, -0x27,0xbd,0xff,0xc8,0xaf,0xb5,0x00,0x2c,0xaf,0xb4,0x00,0x28,0xaf,0xb3,0x00,0x24, -0xaf,0xb0,0x00,0x18,0xaf,0xbf,0x00,0x30,0xaf,0xb2,0x00,0x20,0xaf,0xb1,0x00,0x1c, -0x94,0x91,0x00,0x06,0x00,0x80,0xa0,0x21,0x3c,0x02,0x80,0x00,0x3c,0x04,0xb0,0x03, -0x00,0x11,0xa8,0xc0,0x34,0x84,0x00,0x20,0x24,0x42,0x7c,0x80,0x02,0xb1,0x48,0x21, -0xac,0x82,0x00,0x00,0x00,0x09,0x48,0x80,0x24,0x03,0x00,0x01,0x27,0x82,0x90,0x10, -0xa2,0x83,0x00,0x12,0x01,0x22,0x10,0x21,0x27,0x84,0x90,0x04,0x01,0x24,0x20,0x21, -0x80,0x48,0x00,0x06,0x8c,0x8a,0x00,0x18,0x27,0x83,0x90,0x20,0x01,0x23,0x48,0x21, -0x8d,0x24,0x00,0x00,0x25,0x08,0x00,0x02,0x8d,0x42,0x00,0x00,0x8d,0x49,0x00,0x04, -0x00,0x08,0x17,0xc2,0x8d,0x43,0x00,0x08,0x01,0x02,0x40,0x21,0x00,0x04,0x25,0xc2, -0x00,0x08,0x40,0x43,0x30,0x84,0x00,0x01,0x00,0x03,0x1f,0xc2,0x00,0x08,0x40,0x40, -0x00,0xe0,0x80,0x21,0x00,0x64,0x18,0x24,0x00,0x09,0x49,0x42,0x01,0x48,0x10,0x21, -0x00,0xa0,0x98,0x21,0x00,0xa0,0x20,0x21,0x00,0x40,0x38,0x21,0x02,0x00,0x28,0x21, -0x14,0x60,0x00,0x19,0x31,0x29,0x00,0x01,0x94,0x42,0x00,0x00,0x02,0xb1,0x88,0x21, -0x02,0x00,0x28,0x21,0x00,0x11,0x88,0x80,0x27,0x90,0x90,0x00,0x02,0x30,0x80,0x21, -0x96,0x03,0x00,0x06,0x30,0x52,0xff,0xff,0x02,0x60,0x20,0x21,0x00,0x60,0x30,0x21, -0xa6,0x83,0x00,0x1a,0x27,0x82,0x90,0x08,0x0c,0x00,0x08,0xe3,0x02,0x22,0x88,0x21, -0x00,0x52,0x10,0x21,0x96,0x03,0x00,0x06,0xa6,0x22,0x00,0x04,0x8f,0xbf,0x00,0x30, -0x7b,0xb4,0x01,0x7c,0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x00,0x60,0x10,0x21, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x38,0xaf,0xa9,0x00,0x10,0x0c,0x00,0x09,0x0a, -0xaf,0xa0,0x00,0x14,0x08,0x00,0x1f,0x54,0x02,0xb1,0x88,0x21,0x27,0xbd,0xff,0xc0, -0xaf,0xbe,0x00,0x38,0xaf,0xb7,0x00,0x34,0xaf,0xb6,0x00,0x30,0xaf,0xb5,0x00,0x2c, -0xaf,0xb3,0x00,0x24,0xaf,0xb1,0x00,0x1c,0xaf,0xbf,0x00,0x3c,0xaf,0xb4,0x00,0x28, -0xaf,0xb2,0x00,0x20,0xaf,0xb0,0x00,0x18,0x94,0x90,0x00,0x00,0x3c,0x08,0xb0,0x03, -0x35,0x08,0x00,0x20,0x00,0x10,0x10,0xc0,0x00,0x50,0x18,0x21,0x00,0x40,0x88,0x21, -0x3c,0x02,0x80,0x00,0x00,0x03,0x48,0x80,0x24,0x42,0x7d,0xbc,0x00,0x80,0x98,0x21, -0x27,0x84,0x90,0x10,0x01,0x24,0x20,0x21,0x93,0xb7,0x00,0x53,0xad,0x02,0x00,0x00, -0x80,0x83,0x00,0x06,0x27,0x82,0x90,0x04,0x01,0x22,0x10,0x21,0x8c,0x44,0x00,0x18, -0x24,0x63,0x00,0x02,0x00,0x03,0x17,0xc2,0x8c,0x88,0x00,0x08,0x00,0x62,0x18,0x21, -0x00,0x03,0x18,0x43,0x00,0x03,0x18,0x40,0xaf,0xa7,0x00,0x4c,0x2c,0xa2,0x00,0x10, -0x00,0xa0,0xa8,0x21,0x00,0x83,0x50,0x21,0x00,0x08,0x47,0xc2,0x00,0xc0,0x58,0x21, -0x00,0x00,0xb0,0x21,0x8c,0x92,0x00,0x0c,0x14,0x40,0x00,0x13,0x00,0x00,0xf0,0x21, -0x92,0x67,0x00,0x04,0x24,0x14,0x00,0x01,0x12,0x87,0x00,0x10,0x02,0x30,0x10,0x21, -0x27,0x83,0x90,0x18,0x01,0x23,0x18,0x21,0x80,0x64,0x00,0x00,0x27,0x83,0xb5,0x70, -0x00,0x04,0x11,0x00,0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x23, -0x00,0x02,0x10,0x80,0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x04,0x00,0x00,0x00,0x00, -0x10,0x80,0x00,0x23,0x00,0x00,0x00,0x00,0x02,0x30,0x10,0x21,0x00,0x02,0x80,0x80, -0x24,0x04,0x00,0x01,0x27,0x83,0x90,0x20,0xa2,0x64,0x00,0x12,0x02,0x03,0x18,0x21, -0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x15,0xc2,0x30,0x42,0x00,0x01, -0x01,0x02,0x10,0x24,0x14,0x40,0x00,0x0e,0x02,0xa0,0x20,0x21,0x27,0x82,0x90,0x00, -0x02,0x02,0x10,0x21,0x94,0x43,0x00,0x06,0x00,0x00,0x00,0x00,0xa6,0x63,0x00,0x1a, -0x94,0x42,0x00,0x06,0x7b,0xbe,0x01,0xfc,0x7b,0xb6,0x01,0xbc,0x7b,0xb4,0x01,0x7c, -0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40, -0x8f,0xa5,0x00,0x4c,0x01,0x60,0x30,0x21,0x01,0x40,0x38,0x21,0xaf,0xa0,0x00,0x10, -0x0c,0x00,0x09,0x0a,0xaf,0xa0,0x00,0x14,0x08,0x00,0x1f,0xbb,0x00,0x00,0x00,0x00, -0x27,0x83,0x90,0x20,0x01,0x23,0x18,0x21,0x8c,0x62,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x02,0x15,0xc2,0x30,0x42,0x00,0x01,0x01,0x02,0x10,0x24,0x14,0x40,0x00,0xaf, -0x00,0xa0,0x20,0x21,0x32,0x4f,0x00,0x03,0x00,0x12,0x10,0x82,0x25,0xe3,0x00,0x0d, -0x30,0x45,0x00,0x07,0x00,0x74,0x78,0x04,0x10,0xa0,0x00,0x0e,0x00,0x00,0x90,0x21, -0x27,0x82,0x80,0x1c,0x00,0x15,0x18,0x40,0x00,0x62,0x18,0x21,0x94,0x64,0x00,0x00, -0x24,0xa2,0x00,0x06,0x00,0x54,0x10,0x04,0x00,0x44,0x00,0x1a,0x14,0x80,0x00,0x02, -0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x0d,0x00,0x00,0x10,0x12,0x24,0x42,0x00,0x20, -0x30,0x52,0xff,0xfc,0x02,0x30,0x10,0x21,0x27,0x83,0x90,0x10,0x00,0x02,0x10,0x80, -0x00,0x43,0x10,0x21,0x90,0x44,0x00,0x03,0x00,0x00,0x00,0x00,0x30,0x83,0x00,0xff, -0x2c,0x62,0x00,0x0c,0x14,0x40,0x00,0x04,0x2c,0x62,0x00,0x19,0x30,0x82,0x00,0x0f, -0x24,0x43,0x00,0x0c,0x2c,0x62,0x00,0x19,0x10,0x40,0x00,0x19,0x24,0x0e,0x00,0x20, -0x24,0x62,0xff,0xe9,0x2c,0x42,0x00,0x02,0x14,0x40,0x00,0x15,0x24,0x0e,0x00,0x10, -0x24,0x62,0xff,0xeb,0x2c,0x42,0x00,0x02,0x14,0x40,0x00,0x11,0x24,0x0e,0x00,0x08, -0x24,0x02,0x00,0x14,0x10,0x62,0x00,0x0e,0x24,0x0e,0x00,0x02,0x24,0x62,0xff,0xef, -0x2c,0x42,0x00,0x03,0x14,0x40,0x00,0x0a,0x24,0x0e,0x00,0x10,0x24,0x62,0xff,0xf1, -0x2c,0x42,0x00,0x02,0x14,0x40,0x00,0x06,0x24,0x0e,0x00,0x08,0x24,0x62,0xff,0xf3, -0x2c,0x42,0x00,0x02,0x24,0x0e,0x00,0x04,0x24,0x03,0x00,0x02,0x00,0x62,0x70,0x0a, -0x30,0xe2,0x00,0xff,0x00,0x00,0x48,0x21,0x00,0x00,0x68,0x21,0x10,0x40,0x00,0x6d, -0x00,0x00,0x58,0x21,0x3c,0x14,0x80,0xff,0x27,0x99,0x90,0x00,0x01,0xf2,0xc0,0x23, -0x36,0x94,0xff,0xff,0x01,0xc9,0x10,0x2a,0x14,0x40,0x00,0x64,0x24,0x03,0x00,0x04, -0x00,0x10,0x28,0xc0,0x00,0xb0,0x10,0x21,0x00,0x02,0x10,0x80,0x00,0x59,0x10,0x21, -0x94,0x56,0x00,0x06,0x00,0x00,0x00,0x00,0x32,0xcc,0x00,0x03,0x00,0x6c,0x10,0x23, -0x30,0x42,0x00,0x03,0x02,0xc2,0x10,0x21,0x24,0x42,0x00,0x04,0x30,0x51,0xff,0xff, -0x02,0x32,0x18,0x2b,0x10,0x60,0x00,0x4d,0x01,0xf1,0x10,0x23,0x02,0x51,0x10,0x23, -0x01,0x78,0x18,0x2b,0x10,0x60,0x00,0x34,0x30,0x44,0xff,0xff,0x29,0x22,0x00,0x40, -0x10,0x40,0x00,0x31,0x01,0x72,0x18,0x21,0x25,0x22,0x00,0x01,0x00,0x02,0x16,0x00, -0x00,0x02,0x4e,0x03,0x00,0xb0,0x10,0x21,0x00,0x02,0x30,0x80,0x27,0x82,0x90,0x04, -0x30,0x6b,0xff,0xff,0x00,0xc2,0x18,0x21,0x8c,0x67,0x00,0x18,0x00,0x04,0x25,0x40, -0x3c,0x03,0x7f,0x00,0x8c,0xe2,0x00,0x04,0x00,0x83,0x20,0x24,0x27,0x83,0x90,0x10, -0x00,0x54,0x10,0x24,0x00,0xc3,0x28,0x21,0x00,0x44,0x10,0x25,0xac,0xe2,0x00,0x04, -0x16,0xe0,0x00,0x02,0xa0,0xb5,0x00,0x00,0xa0,0xb5,0x00,0x03,0x27,0x84,0x90,0x20, -0x00,0xc4,0x18,0x21,0x8c,0x62,0x00,0x00,0x8c,0xe8,0x00,0x08,0x00,0x02,0x15,0xc2, -0x00,0x08,0x47,0xc2,0x30,0x42,0x00,0x01,0x01,0x02,0x10,0x24,0x10,0x40,0x00,0x0a, -0x00,0x00,0x00,0x00,0x80,0xa2,0x00,0x06,0x00,0x00,0x00,0x00,0x24,0x42,0x00,0x02, -0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43,0x00,0x02,0x10,0x40, -0x00,0xe2,0x50,0x21,0xa5,0x5e,0x00,0x00,0x92,0x62,0x00,0x04,0x25,0xad,0x00,0x01, -0x27,0x84,0x90,0x00,0x00,0xc4,0x18,0x21,0x01,0xa2,0x10,0x2a,0x94,0x70,0x00,0x02, -0x14,0x40,0xff,0xb8,0x00,0x00,0x00,0x00,0x96,0x63,0x00,0x14,0x00,0x0c,0x10,0x23, -0xa2,0x69,0x00,0x12,0x30,0x42,0x00,0x03,0x01,0x62,0x10,0x23,0x00,0x03,0x80,0xc0, -0x8f,0xa5,0x00,0x4c,0x30,0x4b,0xff,0xff,0x02,0x03,0x80,0x21,0x27,0x82,0x90,0x08, -0x00,0x10,0x80,0x80,0xa6,0x6b,0x00,0x1a,0x02,0xa0,0x20,0x21,0x01,0x60,0x30,0x21, -0x01,0x60,0x88,0x21,0x0c,0x00,0x08,0xe3,0x02,0x02,0x80,0x21,0x00,0x5e,0x10,0x21, -0xa6,0x02,0x00,0x04,0x08,0x00,0x1f,0xc1,0x02,0x20,0x10,0x21,0x01,0x62,0x10,0x2b, -0x10,0x40,0xff,0xe9,0x00,0x00,0x20,0x21,0x29,0x22,0x00,0x40,0x10,0x40,0xff,0xe6, -0x01,0x71,0x18,0x21,0x08,0x00,0x20,0x37,0x25,0x22,0x00,0x01,0x08,0x00,0x20,0x66, -0x32,0xcc,0x00,0x03,0x08,0x00,0x20,0x66,0x00,0x00,0x60,0x21,0x8f,0xa5,0x00,0x4c, -0x01,0x40,0x38,0x21,0xaf,0xa0,0x00,0x10,0x0c,0x00,0x09,0x0a,0xaf,0xb4,0x00,0x14, -0x92,0x67,0x00,0x04,0x08,0x00,0x1f,0xd9,0x30,0x5e,0xff,0xff,0x30,0x84,0xff,0xff, -0x00,0x04,0x30,0xc0,0x00,0xc4,0x20,0x21,0x00,0x04,0x20,0x80,0x27,0x82,0x90,0x00, -0x3c,0x03,0xb0,0x08,0x30,0xa5,0xff,0xff,0x00,0x82,0x20,0x21,0x00,0xc3,0x30,0x21, -0xac,0xc5,0x00,0x00,0x03,0xe0,0x00,0x08,0xa4,0x85,0x00,0x00,0x30,0x84,0xff,0xff, -0x00,0x04,0x30,0xc0,0x00,0xc4,0x30,0x21,0x27,0x88,0x90,0x00,0x00,0x06,0x30,0x80, -0x00,0xc8,0x30,0x21,0x94,0xc3,0x00,0x04,0x3c,0x02,0xb0,0x08,0x3c,0x07,0xb0,0x03, -0x00,0x03,0x20,0xc0,0x00,0x83,0x18,0x21,0x00,0x03,0x18,0x80,0x00,0x82,0x20,0x21, -0x3c,0x02,0x80,0x01,0x30,0xa5,0xff,0xff,0x00,0x68,0x18,0x21,0x34,0xe7,0x00,0x20, -0x24,0x42,0x82,0x6c,0xac,0xe2,0x00,0x00,0xa4,0xc5,0x00,0x02,0xa4,0x65,0x00,0x00, -0x03,0xe0,0x00,0x08,0xac,0x85,0x00,0x00,0x30,0x84,0xff,0xff,0x00,0x04,0x10,0xc0, -0x00,0x44,0x10,0x21,0x27,0x89,0x90,0x00,0x00,0x02,0x10,0x80,0x00,0x49,0x10,0x21, -0x97,0x83,0x8f,0xf0,0x94,0x4a,0x00,0x04,0x3c,0x02,0xb0,0x08,0x00,0x03,0x38,0xc0, -0x00,0x0a,0x40,0xc0,0x00,0xe3,0x18,0x21,0x01,0x0a,0x28,0x21,0x00,0xe2,0x38,0x21, -0x01,0x02,0x40,0x21,0x00,0x03,0x18,0x80,0x00,0x05,0x28,0x80,0x3c,0x06,0xb0,0x03, -0x3c,0x02,0x80,0x01,0x00,0xa9,0x28,0x21,0x00,0x69,0x18,0x21,0x34,0xc6,0x00,0x20, -0x34,0x09,0xff,0xff,0x24,0x42,0x82,0xc8,0xac,0xc2,0x00,0x00,0xa4,0x64,0x00,0x00, -0xac,0xe4,0x00,0x00,0xa4,0xa9,0x00,0x00,0xad,0x09,0x00,0x00,0xa7,0x8a,0x8f,0xf0, -0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01, -0x34,0x63,0x00,0x20,0x24,0x42,0x83,0x48,0x3c,0x04,0xb0,0x03,0xac,0x62,0x00,0x00, -0x34,0x84,0x01,0x10,0x8c,0x82,0x00,0x00,0x97,0x83,0x81,0x60,0x30,0x42,0xff,0xff, -0x10,0x62,0x00,0x16,0x24,0x0a,0x00,0x01,0xa7,0x82,0x81,0x60,0xaf,0x80,0xb4,0x50, -0x00,0x40,0x28,0x21,0x24,0x06,0x00,0x01,0x27,0x84,0xb4,0x54,0x25,0x43,0xff,0xff, -0x00,0x66,0x10,0x04,0x00,0xa2,0x10,0x24,0x14,0x40,0x00,0x07,0x00,0x00,0x00,0x00, -0x8c,0x83,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0x66,0x10,0x04,0x00,0xa2,0x10,0x24, -0x38,0x42,0x00,0x00,0x01,0x42,0x18,0x0a,0x25,0x4a,0x00,0x01,0x2d,0x42,0x00,0x14, -0xac,0x83,0x00,0x00,0x14,0x40,0xff,0xf1,0x24,0x84,0x00,0x04,0x3c,0x0b,0xb0,0x03, -0x00,0x00,0x50,0x21,0x3c,0x0c,0x80,0x00,0x27,0x89,0xb4,0xa0,0x35,0x6b,0x01,0x20, -0x8d,0x68,0x00,0x00,0x8d,0x23,0x00,0x04,0x01,0x0c,0x10,0x24,0x00,0x02,0x17,0xc2, -0x11,0x03,0x00,0x37,0xa1,0x22,0x00,0xdc,0xa1,0x20,0x00,0xd5,0xa1,0x20,0x00,0xd6, -0x01,0x20,0x30,0x21,0x00,0x00,0x38,0x21,0x00,0x00,0x28,0x21,0x01,0x20,0x20,0x21, -0x00,0xa8,0x10,0x06,0x30,0x42,0x00,0x01,0x10,0xe0,0x00,0x10,0xa0,0x82,0x00,0x0a, -0x90,0x82,0x00,0x07,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x31,0x24,0xa2,0xff,0xff, -0xa0,0x82,0x00,0x08,0x90,0x82,0x00,0x0a,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x09, -0x00,0x00,0x00,0x00,0x90,0x83,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x03,0x10,0x40, -0x00,0x43,0x10,0x21,0x00,0x46,0x10,0x21,0xa0,0x45,0x00,0x09,0x90,0x82,0x00,0x0a, -0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x07,0x00,0x00,0x00,0x00,0x14,0xe0,0x00,0x04, -0x00,0x00,0x00,0x00,0xa0,0xc5,0x00,0xd5,0x24,0x07,0x00,0x01,0xa0,0x85,0x00,0x08, -0xa0,0xc5,0x00,0xd6,0x24,0xa5,0x00,0x01,0x2c,0xa2,0x00,0x1c,0x14,0x40,0xff,0xe0, -0x24,0x84,0x00,0x03,0x90,0xc4,0x00,0xd5,0x00,0x00,0x28,0x21,0x00,0xa4,0x10,0x2b, -0x10,0x40,0x00,0x0b,0x00,0x00,0x00,0x00,0x00,0xc0,0x18,0x21,0xa0,0x64,0x00,0x08, -0x90,0xc2,0x00,0xd5,0x24,0xa5,0x00,0x01,0xa0,0x62,0x00,0x09,0x90,0xc4,0x00,0xd5, -0x00,0x00,0x00,0x00,0x00,0xa4,0x10,0x2b,0x14,0x40,0xff,0xf8,0x24,0x63,0x00,0x03, -0x25,0x4a,0x00,0x01,0x2d,0x42,0x00,0x08,0xad,0x28,0x00,0x04,0x25,0x6b,0x00,0x04, -0x14,0x40,0xff,0xbf,0x25,0x29,0x00,0xec,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, -0x90,0x82,0x00,0x05,0x08,0x00,0x21,0x0d,0xa0,0x82,0x00,0x08,0x97,0x85,0x8b,0x7a, -0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01,0x27,0xbd,0xff,0xe8,0x34,0x63,0x00,0x20, -0x24,0x42,0x84,0xfc,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0xac,0x62,0x00,0x00, -0x30,0x90,0x00,0xff,0x00,0x05,0x28,0x42,0x00,0x00,0x48,0x21,0x27,0x8f,0xb4,0xa4, -0x00,0x00,0x50,0x21,0x00,0x00,0x58,0x21,0x27,0x98,0xb5,0x84,0x27,0x99,0xb5,0x80, -0x27,0x8e,0xb5,0x7e,0x27,0x8c,0xb4,0xa8,0x27,0x8d,0xb5,0x00,0x27,0x88,0xb5,0x78, -0x00,0x0a,0x18,0x80,0x01,0x6f,0x10,0x21,0xac,0x40,0x00,0x00,0xac,0x45,0x00,0x58, -0x00,0x6e,0x20,0x21,0x00,0x78,0x10,0x21,0xa1,0x00,0xff,0xfc,0xad,0x00,0x00,0x00, -0xa1,0x00,0x00,0x04,0xa1,0x00,0x00,0x05,0xad,0x00,0xff,0xf8,0x00,0x79,0x18,0x21, -0x24,0x06,0x00,0x01,0x24,0xc6,0xff,0xff,0xa0,0x80,0x00,0x00,0xa4,0x60,0x00,0x00, -0xac,0x40,0x00,0x00,0x24,0x63,0x00,0x02,0x24,0x42,0x00,0x04,0x04,0xc1,0xff,0xf9, -0x24,0x84,0x00,0x01,0x00,0x0a,0x10,0x80,0x00,0x4d,0x20,0x21,0x00,0x00,0x30,0x21, -0x00,0x4c,0x18,0x21,0x27,0x87,0x81,0x64,0x8c,0xe2,0x00,0x00,0x24,0xe7,0x00,0x04, -0xac,0x82,0x00,0x00,0xa0,0x66,0x00,0x00,0xa0,0x66,0x00,0x01,0x24,0xc6,0x00,0x01, -0x28,0xc2,0x00,0x1c,0xa0,0x60,0x00,0x02,0x24,0x84,0x00,0x04,0x14,0x40,0xff,0xf6, -0x24,0x63,0x00,0x03,0x25,0x29,0x00,0x01,0x29,0x22,0x00,0x08,0x25,0x4a,0x00,0x3b, -0x25,0x08,0x00,0xec,0x14,0x40,0xff,0xd6,0x25,0x6b,0x00,0xec,0xa7,0x80,0x81,0x60, -0x00,0x00,0x48,0x21,0x27,0x83,0xb4,0x50,0xac,0x69,0x00,0x00,0x25,0x29,0x00,0x01, -0x29,0x22,0x00,0x0c,0x14,0x40,0xff,0xfc,0x24,0x63,0x00,0x04,0x0c,0x00,0x20,0xd2, -0x00,0x00,0x00,0x00,0x2e,0x04,0x00,0x14,0x27,0x83,0xb4,0xa0,0x24,0x09,0x00,0x07, -0x10,0x80,0x00,0x0a,0x00,0x00,0x00,0x00,0x90,0x62,0x00,0xd5,0x25,0x29,0xff,0xff, -0xa0,0x62,0x00,0x00,0x05,0x21,0xff,0xfa,0x24,0x63,0x00,0xec,0x8f,0xbf,0x00,0x14, -0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x90,0x62,0x00,0xd6, -0x08,0x00,0x21,0x90,0x25,0x29,0xff,0xff,0x30,0x84,0x00,0xff,0x00,0x04,0x11,0x00, -0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80,0x00,0x44,0x10,0x23,0x00,0x02,0x10,0x80, -0x27,0x83,0xb4,0xa0,0x00,0x43,0x60,0x21,0x3c,0x04,0xb0,0x03,0x3c,0x02,0x80,0x01, -0x34,0x84,0x00,0x20,0x24,0x42,0x86,0x68,0x30,0xc6,0x00,0xff,0x93,0xaa,0x00,0x13, -0x30,0xa5,0x00,0xff,0x30,0xe7,0x00,0xff,0xac,0x82,0x00,0x00,0x10,0xc0,0x00,0xe8, -0x25,0x8f,0x00,0xd0,0x91,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x42,0xff,0xfc, -0x2c,0x43,0x00,0x18,0x10,0x60,0x00,0xc7,0x3c,0x03,0x80,0x01,0x00,0x02,0x10,0x80, -0x24,0x63,0x02,0x90,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x30,0x14,0x40,0x00,0x1c, -0x00,0x00,0x00,0x00,0x10,0xa0,0x00,0x17,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, -0x10,0xa2,0x00,0x11,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x0c, -0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x06,0x00,0x00,0x00,0x00, -0x8d,0x82,0x00,0xd0,0x00,0x00,0x00,0x00,0x24,0x42,0xff,0xe0,0x03,0xe0,0x00,0x08, -0xad,0x82,0x00,0xd0,0x8d,0x82,0x00,0xd0,0x08,0x00,0x21,0xcb,0x24,0x42,0xff,0xe8, -0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,0x08,0x00,0x21,0xcb, -0x24,0x42,0x00,0x01,0x8d,0x82,0x00,0xd0,0x08,0x00,0x21,0xcb,0x24,0x42,0x00,0x02, -0x10,0xa0,0xff,0xf9,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0x00,0x0a, -0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xe9,0x00,0x00,0x00,0x00, -0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0xe6,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0, -0x08,0x00,0x21,0xcb,0x24,0x42,0xff,0xd0,0x8d,0x82,0x00,0xd0,0x08,0x00,0x21,0xcb, -0x24,0x42,0xff,0xfc,0x10,0xa0,0xff,0xeb,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, -0x10,0xa2,0xff,0xe5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xe0, -0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xdb,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0, -0x08,0x00,0x21,0xcb,0x24,0x42,0xff,0xf8,0x2d,0x42,0x00,0x19,0x14,0x40,0xff,0xc5, -0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xdb,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, -0x10,0xa2,0xff,0xd5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xd0, -0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0xf1,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0, -0x08,0x00,0x21,0xcb,0x24,0x42,0xff,0xf0,0x2d,0x42,0x00,0x1b,0x10,0x40,0xff,0xf1, -0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xcb,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, -0x10,0xa2,0xff,0xc5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x14,0xa2,0xff,0xb5, -0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,0x08,0x00,0x21,0xcb,0x24,0x42,0xff,0xf4, -0x2d,0x42,0x00,0x1e,0x10,0x40,0xff,0xe3,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xbd, -0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xb5,0x24,0x02,0x00,0x02, -0x10,0xa2,0xff,0xd6,0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xc6,0x24,0x02,0x00,0x03, -0x2d,0x42,0x00,0x23,0x10,0x40,0xff,0xd7,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xae, -0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xa9,0x24,0x02,0x00,0x02, -0x14,0xa2,0xff,0xb7,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0x03,0x00,0x00,0x00,0x00, -0x2d,0x42,0x00,0x25,0x10,0x40,0xff,0xcb,0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xd8, -0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x16,0x14,0x40,0x00,0x0e,0x00,0x00,0x00,0x00, -0x10,0xa0,0xff,0xa0,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x9a, -0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x95,0x24,0x02,0x00,0x03, -0x14,0xa2,0xff,0xb6,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,0x08,0x00,0x21,0xcb, -0x24,0x42,0xff,0xfa,0x10,0xa0,0xff,0x93,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, -0x10,0xa2,0xff,0x8d,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x88, -0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xf3,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x17, -0x14,0x40,0xff,0xac,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0x34,0x00,0x00,0x00,0x00, -0x2d,0x42,0x00,0x19,0x10,0x40,0xff,0xe2,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0x81, -0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x7b,0x00,0x00,0x00,0x00, -0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x76,0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0x97, -0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xc8,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0x51, -0x2d,0x42,0x00,0x1b,0x2d,0x42,0x00,0x1e,0x10,0x40,0xff,0xde,0x00,0x00,0x00,0x00, -0x10,0xa0,0xff,0x70,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x6a, -0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x65,0x24,0x02,0x00,0x03, -0x10,0xa2,0xff,0x96,0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xc8,0x00,0x00,0x00,0x00, -0x2d,0x42,0x00,0x23,0x14,0x40,0xff,0xf2,0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xf9, -0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xf7,0x2d,0x42,0x00,0x25,0x08,0x00,0x22,0x2d, -0x2d,0x42,0x00,0x27,0x10,0xa0,0xff,0x5b,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, -0x10,0xa2,0xff,0x55,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x50, -0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0x71,0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xe6, -0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x27,0x14,0x40,0xff,0xad,0x00,0x00,0x00,0x00, -0x08,0x00,0x22,0x79,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x2a,0x14,0x40,0xff,0xd8, -0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xe9,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x2c, -0x14,0x40,0xff,0x78,0x00,0x00,0x00,0x00,0x08,0x00,0x21,0xbd,0x00,0x00,0x00,0x00, -0x91,0x86,0x00,0x00,0x91,0x83,0x00,0xd4,0x25,0x8d,0x00,0x5c,0x30,0xc4,0x00,0xff, -0x00,0x04,0x10,0x40,0x00,0x44,0x10,0x21,0x00,0x04,0x48,0x80,0x01,0x82,0x58,0x21, -0x01,0x89,0x40,0x21,0x25,0x78,0x00,0x08,0x10,0x60,0x00,0x37,0x25,0x0e,0x00,0x60, -0x2c,0xa2,0x00,0x03,0x14,0x40,0x00,0x25,0x00,0x00,0x00,0x00,0x91,0x82,0x00,0xdd, -0x00,0x00,0x00,0x00,0x14,0x40,0x00,0x1e,0x00,0x00,0x00,0x00,0x27,0x87,0x81,0x64, -0x01,0x27,0x10,0x21,0x8c,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0xad,0x03,0x00,0x60, -0x91,0x62,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x40,0x30,0x21,0xa1,0x82,0x00,0x00, -0x30,0xc2,0x00,0xff,0x00,0x02,0x10,0x80,0x00,0x47,0x10,0x21,0x8c,0x43,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x03,0x18,0x42,0xad,0xa3,0x00,0x00,0x91,0x84,0x00,0x00, -0x8d,0xc5,0x00,0x00,0x00,0x04,0x20,0x80,0x00,0x87,0x10,0x21,0x8c,0x43,0x00,0x00, -0x00,0x05,0x28,0x40,0x00,0x8c,0x20,0x21,0x00,0x03,0x18,0x80,0x00,0xa3,0x10,0x2b, -0x00,0x62,0x28,0x0a,0xac,0x85,0x00,0x60,0x03,0xe0,0x00,0x08,0xa1,0x80,0x00,0xd4, -0x27,0x87,0x81,0x64,0x08,0x00,0x22,0xb0,0xa1,0x80,0x00,0xdd,0x27,0x82,0x81,0xd4, -0x8d,0x83,0x00,0xd8,0x00,0x82,0x10,0x21,0x90,0x44,0x00,0x00,0x24,0x63,0x00,0x01, -0x00,0x64,0x20,0x2b,0x14,0x80,0xff,0x02,0xad,0x83,0x00,0xd8,0x8d,0x02,0x00,0x60, -0xa1,0x80,0x00,0xd4,0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43, -0x03,0xe0,0x00,0x08,0xad,0x82,0x00,0x5c,0x10,0xe0,0x00,0x1d,0x24,0x83,0xff,0xfc, -0x2c,0x62,0x00,0x18,0x10,0x40,0x01,0x10,0x00,0x03,0x10,0x80,0x3c,0x03,0x80,0x01, -0x24,0x63,0x02,0xf0,0x00,0x43,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x80,0x00,0x08,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x30,0x14,0x40,0x00,0x65, -0x00,0x00,0x00,0x00,0x10,0xa0,0x00,0x60,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, -0x10,0xa2,0x00,0x5a,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x08, -0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x51,0x00,0x00,0x00,0x00, -0x8d,0x82,0x00,0xd0,0x00,0x00,0x00,0x00,0x24,0x42,0xff,0xe0,0xad,0x82,0x00,0xd0, -0x8d,0xe3,0x00,0x00,0x8d,0xa2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x21, -0xad,0xa2,0x00,0x00,0xad,0xe0,0x00,0x00,0x8d,0xa3,0x00,0x00,0x8d,0xc4,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x83,0x10,0x2a,0x10,0x40,0x00,0x22,0x00,0x00,0x00,0x00, -0x93,0x05,0x00,0x01,0x91,0x82,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x45,0x00,0x05, -0x24,0x02,0x00,0x01,0xa1,0x85,0x00,0x00,0xa1,0x82,0x00,0xd4,0x03,0xe0,0x00,0x08, -0xad,0x80,0x00,0xd8,0x91,0x82,0x00,0xdd,0x24,0x03,0x00,0x01,0x10,0x43,0x00,0x05, -0x00,0x00,0x00,0x00,0xa1,0x83,0x00,0xd4,0xad,0x80,0x00,0xd8,0x03,0xe0,0x00,0x08, -0xa1,0x83,0x00,0xdd,0x00,0x04,0x17,0xc2,0x00,0x82,0x10,0x21,0x00,0x02,0x10,0x43, -0xad,0xa2,0x00,0x00,0x91,0x83,0x00,0x00,0x27,0x82,0x81,0x64,0x8d,0xc5,0x00,0x00, -0x00,0x03,0x18,0x80,0x00,0x62,0x18,0x21,0x8c,0x64,0x00,0x00,0x00,0x05,0x28,0x40, -0x00,0x04,0x18,0x80,0x00,0xa3,0x10,0x2b,0x00,0x62,0x28,0x0a,0x08,0x00,0x22,0xc2, -0xad,0xc5,0x00,0x00,0x97,0x82,0x8b,0x7c,0x00,0x00,0x00,0x00,0x00,0x62,0x10,0x2a, -0x10,0x40,0xfe,0xab,0x00,0x00,0x00,0x00,0x91,0x82,0x00,0xdd,0x00,0x00,0x00,0x00, -0x14,0x40,0x00,0x15,0x00,0x00,0x00,0x00,0x91,0x83,0x00,0x00,0x27,0x82,0x81,0x64, -0x00,0x03,0x18,0x80,0x00,0x62,0x10,0x21,0x8c,0x44,0x00,0x00,0x00,0x6c,0x18,0x21, -0xac,0x64,0x00,0x60,0x93,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x10,0x80, -0x01,0x82,0x10,0x21,0x24,0x4e,0x00,0x60,0xa1,0x85,0x00,0x00,0x8d,0xc2,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x02,0x1f,0xc2,0x00,0x43,0x10,0x21,0x00,0x02,0x10,0x43, -0x03,0xe0,0x00,0x08,0xad,0xa2,0x00,0x00,0x08,0x00,0x23,0x37,0xa1,0x80,0x00,0xdd, -0x8d,0x82,0x00,0xd0,0x08,0x00,0x22,0xf3,0x24,0x42,0xff,0xe8,0x8d,0x82,0x00,0xd0, -0x08,0x00,0x22,0xf3,0x24,0x42,0x00,0x01,0x8d,0x82,0x00,0xd0,0x08,0x00,0x22,0xf3, -0x24,0x42,0x00,0x02,0x10,0xa0,0xff,0xf9,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, -0x10,0xa2,0x00,0x0a,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xa0, -0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0x9d,0x00,0x00,0x00,0x00, -0x8d,0x82,0x00,0xd0,0x08,0x00,0x22,0xf3,0x24,0x42,0xff,0xd0,0x8d,0x82,0x00,0xd0, -0x08,0x00,0x22,0xf3,0x24,0x42,0xff,0xfc,0x10,0xa0,0xff,0xeb,0x00,0x00,0x00,0x00, -0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xe5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02, -0x10,0xa2,0xff,0x93,0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xdd,0x00,0x00,0x00,0x00, -0x8d,0x82,0x00,0xd0,0x08,0x00,0x22,0xf3,0x24,0x42,0xff,0xf8,0x2d,0x42,0x00,0x19, -0x14,0x40,0xff,0x7c,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xdb,0x00,0x00,0x00,0x00, -0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xd5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02, -0x10,0xa2,0xff,0x83,0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0xf1,0x00,0x00,0x00,0x00, -0x8d,0x82,0x00,0xd0,0x08,0x00,0x22,0xf3,0x24,0x42,0xff,0xf0,0x2d,0x42,0x00,0x1b, -0x10,0x40,0xff,0xf1,0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xcb,0x00,0x00,0x00,0x00, -0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0xc5,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02, -0x14,0xa2,0xff,0x6c,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0,0x08,0x00,0x22,0xf3, -0x24,0x42,0xff,0xf4,0x2d,0x42,0x00,0x1e,0x10,0x40,0xff,0xe3,0x00,0x00,0x00,0x00, -0x10,0xa0,0xff,0xbd,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x68, -0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0xd6,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0xee, -0x24,0x02,0x00,0x03,0x2d,0x42,0x00,0x23,0x10,0x40,0xff,0xd7,0x00,0x00,0x00,0x00, -0x10,0xa0,0xff,0xae,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x5c, -0x24,0x02,0x00,0x02,0x14,0xa2,0xff,0xb7,0x00,0x00,0x00,0x00,0x08,0x00,0x23,0x74, -0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x25,0x10,0x40,0xff,0xcb,0x00,0x00,0x00,0x00, -0x08,0x00,0x23,0x49,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x16,0x14,0x40,0x00,0x0e, -0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0xa0,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, -0x10,0xa2,0xff,0x9a,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x48, -0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0xb6,0x00,0x00,0x00,0x00,0x8d,0x82,0x00,0xd0, -0x08,0x00,0x22,0xf3,0x24,0x42,0xff,0xfa,0x10,0xa0,0xff,0x93,0x00,0x00,0x00,0x00, -0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x8d,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02, -0x10,0xa2,0xff,0x3b,0x00,0x00,0x00,0x00,0x08,0x00,0x23,0x64,0x00,0x00,0x00,0x00, -0x2d,0x42,0x00,0x17,0x14,0x40,0xff,0xac,0x00,0x00,0x00,0x00,0x08,0x00,0x23,0xa5, -0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x19,0x10,0x40,0xff,0xe2,0x00,0x00,0x00,0x00, -0x10,0xa0,0xff,0x81,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x7b, -0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x29,0x24,0x02,0x00,0x03, -0x10,0xa2,0xff,0x97,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0xf0,0x00,0x00,0x00,0x00, -0x08,0x00,0x23,0xc2,0x2d,0x42,0x00,0x1b,0x2d,0x42,0x00,0x1e,0x10,0x40,0xff,0xde, -0x00,0x00,0x00,0x00,0x10,0xa0,0xff,0x70,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01, -0x10,0xa2,0xff,0x6a,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0xa2,0xff,0x18, -0x24,0x02,0x00,0x03,0x10,0xa2,0xff,0x96,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0xf0, -0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x23,0x14,0x40,0xff,0xf2,0x00,0x00,0x00,0x00, -0x08,0x00,0x23,0x6a,0x00,0x00,0x00,0x00,0x08,0x00,0x23,0x68,0x2d,0x42,0x00,0x25, -0x08,0x00,0x23,0x9e,0x2d,0x42,0x00,0x27,0x10,0xa0,0xff,0x5b,0x00,0x00,0x00,0x00, -0x24,0x02,0x00,0x01,0x10,0xa2,0xff,0x55,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02, -0x10,0xa2,0xff,0x03,0x24,0x02,0x00,0x03,0x14,0xa2,0xff,0x71,0x00,0x00,0x00,0x00, -0x08,0x00,0x23,0x57,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x27,0x14,0x40,0xff,0xad, -0x00,0x00,0x00,0x00,0x08,0x00,0x23,0xea,0x00,0x00,0x00,0x00,0x2d,0x42,0x00,0x2a, -0x14,0x40,0xff,0xd8,0x00,0x00,0x00,0x00,0x08,0x00,0x23,0x5a,0x00,0x00,0x00,0x00, -0x2d,0x42,0x00,0x2c,0x14,0x40,0xff,0x78,0x00,0x00,0x00,0x00,0x08,0x00,0x22,0xe5, -0x00,0x00,0x00,0x00,0x27,0xbd,0xff,0xe8,0x3c,0x02,0xb0,0x03,0xaf,0xbf,0x00,0x14, -0xaf,0xb0,0x00,0x10,0x34,0x42,0x01,0x18,0x3c,0x03,0xb0,0x03,0x8c,0x50,0x00,0x00, -0x34,0x63,0x01,0x2c,0x90,0x62,0x00,0x00,0x32,0x05,0x00,0x01,0xa3,0x82,0x80,0x10, -0x14,0xa0,0x00,0x14,0x30,0x44,0x00,0xff,0x32,0x02,0x01,0x00,0x14,0x40,0x00,0x09, -0x00,0x00,0x00,0x00,0x32,0x02,0x08,0x00,0x10,0x40,0x00,0x02,0x24,0x02,0x00,0x01, -0xa3,0x82,0xbc,0x18,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x18,0x0c,0x00,0x05,0x37,0x00,0x00,0x00,0x00,0x26,0x02,0xff,0x00, -0xa3,0x80,0xbc,0x18,0x3c,0x01,0xb0,0x03,0xac,0x22,0x01,0x18,0x08,0x00,0x24,0x16, -0x32,0x02,0x08,0x00,0x0c,0x00,0x21,0x3f,0x00,0x00,0x00,0x00,0x26,0x02,0xff,0xff, -0x3c,0x01,0xb0,0x03,0xac,0x22,0x01,0x18,0x08,0x00,0x24,0x13,0x32,0x02,0x01,0x00, -0x27,0xbd,0xff,0xe0,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0xd0,0xaf,0xbf,0x00,0x18, -0x8c,0x43,0x00,0x00,0x3c,0x02,0x00,0x40,0x24,0x07,0x0f,0xff,0x00,0x03,0x33,0x02, -0x00,0x03,0x2d,0x02,0x00,0x03,0x43,0x02,0x30,0x69,0x0f,0xff,0x00,0x62,0x18,0x24, -0x30,0xa5,0x00,0x03,0x30,0xc6,0x00,0xff,0x10,0x60,0x00,0x08,0x31,0x08,0x00,0xff, -0x01,0x00,0x30,0x21,0x0c,0x00,0x24,0xdf,0xaf,0xa9,0x00,0x10,0x8f,0xbf,0x00,0x18, -0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x0c,0x00,0x25,0x31, -0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0xd4,0x08,0x00,0x24,0x3f, -0xac,0x62,0x00,0x00,0x27,0xbd,0xff,0xc0,0x3c,0x02,0xb0,0x03,0xaf,0xbe,0x00,0x38, -0xaf,0xb5,0x00,0x2c,0xaf,0xb1,0x00,0x1c,0xaf,0xb0,0x00,0x18,0xaf,0xbf,0x00,0x3c, -0xaf,0xb7,0x00,0x34,0xaf,0xb6,0x00,0x30,0xaf,0xb4,0x00,0x28,0xaf,0xb3,0x00,0x24, -0xaf,0xb2,0x00,0x20,0x34,0x42,0x00,0x3f,0x90,0x43,0x00,0x00,0x00,0x80,0x80,0x21, -0x00,0x00,0xf0,0x21,0x00,0x00,0x88,0x21,0x10,0x60,0x00,0x76,0x00,0x00,0xa8,0x21, -0x3c,0x01,0xb0,0x03,0xa0,0x20,0x00,0x3f,0x00,0x10,0x12,0x02,0x24,0x04,0x06,0x14, -0x0c,0x00,0x06,0xd1,0x30,0x54,0x00,0x0f,0x24,0x04,0x06,0x14,0x0c,0x00,0x06,0xd1, -0xaf,0xa2,0x00,0x10,0x3c,0x03,0x00,0xff,0x34,0x63,0xff,0xff,0x32,0x10,0x00,0x7f, -0x00,0x43,0x10,0x24,0x00,0x10,0x86,0x00,0x02,0x02,0x80,0x25,0x02,0x00,0x28,0x21, -0x24,0x04,0x06,0x14,0x3c,0x13,0xbf,0xff,0x0c,0x00,0x06,0xbf,0x3c,0x16,0xb0,0x03, -0x00,0x00,0x90,0x21,0x3c,0x17,0x40,0x00,0x36,0x73,0xff,0xff,0x36,0xd6,0x00,0x3e, -0x0c,0x00,0x06,0xd1,0x24,0x04,0x04,0x00,0x00,0x57,0x10,0x25,0x00,0x40,0x28,0x21, -0x0c,0x00,0x06,0xbf,0x24,0x04,0x04,0x00,0x00,0x00,0x80,0x21,0x0c,0x00,0x25,0xf9, -0x00,0x00,0x00,0x00,0x26,0x03,0x00,0x01,0x10,0x40,0x00,0x46,0x30,0x70,0x00,0xff, -0x12,0x00,0xff,0xfa,0x00,0x00,0x00,0x00,0x0c,0x00,0x06,0xd1,0x24,0x04,0x04,0x00, -0x00,0x53,0x10,0x24,0x00,0x40,0x28,0x21,0x0c,0x00,0x06,0xbf,0x24,0x04,0x04,0x00, -0x24,0x02,0x00,0x01,0x12,0x82,0x00,0x37,0x00,0x00,0x00,0x00,0x12,0x80,0x00,0x35, -0x00,0x00,0x00,0x00,0x32,0x31,0x00,0x7f,0x12,0x20,0x00,0x04,0x24,0x03,0x00,0x04, -0x27,0xc2,0x00,0x01,0x30,0x5e,0x00,0xff,0x02,0xb1,0xa8,0x21,0x12,0x43,0x00,0x2a, -0x3c,0x03,0xb0,0x03,0x02,0x43,0x10,0x21,0xa0,0x51,0x00,0x34,0x26,0x42,0x00,0x01, -0x30,0x52,0x00,0xff,0x2e,0x43,0x00,0x05,0x14,0x60,0xff,0xd9,0x00,0x00,0x00,0x00, -0x8f,0xa5,0x00,0x10,0x0c,0x00,0x06,0xbf,0x24,0x04,0x06,0x14,0x12,0xa0,0x00,0x0e, -0x3c,0x02,0xb0,0x03,0x13,0xc0,0x00,0x0d,0x34,0x42,0x00,0x3c,0x00,0x15,0x10,0x40, -0x00,0x55,0x10,0x21,0x00,0x02,0x10,0xc0,0x00,0x55,0x10,0x21,0x00,0x02,0xa8,0x80, -0x02,0xbe,0x00,0x1b,0x17,0xc0,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x0d, -0x00,0x00,0xa8,0x12,0x3c,0x02,0xb0,0x03,0x34,0x42,0x00,0x3c,0x3c,0x03,0xb0,0x03, -0x3c,0x04,0xb0,0x03,0xa4,0x55,0x00,0x00,0x34,0x63,0x00,0x1c,0x34,0x84,0x00,0x1d, -0x24,0x02,0x00,0x01,0xa0,0x60,0x00,0x00,0xa0,0x82,0x00,0x00,0x7b,0xbe,0x01,0xfc, -0x7b,0xb6,0x01,0xbc,0x7b,0xb4,0x01,0x7c,0x7b,0xb2,0x01,0x3c,0x7b,0xb0,0x00,0xfc, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x40,0xa2,0xd1,0x00,0x00,0x08,0x00,0x24,0x98, -0x26,0x42,0x00,0x01,0x0c,0x00,0x06,0xd1,0x24,0x04,0x04,0xfc,0x08,0x00,0x24,0x8d, -0x00,0x40,0x88,0x21,0x3c,0x03,0xb0,0x03,0x34,0x63,0x00,0x3c,0x3c,0x04,0xb0,0x03, -0x3c,0x05,0xb0,0x03,0xa4,0x60,0x00,0x00,0x34,0x84,0x00,0x1c,0x34,0xa5,0x00,0x1d, -0x24,0x02,0x00,0x02,0x24,0x03,0x00,0x01,0xa0,0x82,0x00,0x00,0x08,0x00,0x24,0xb7, -0xa0,0xa3,0x00,0x00,0x0c,0x00,0x17,0x99,0x00,0x00,0x00,0x00,0x10,0x40,0xff,0x8b, -0x00,0x10,0x12,0x02,0x3c,0x02,0xb0,0x03,0x3c,0x04,0xb0,0x03,0x34,0x42,0x00,0x3c, -0x34,0x84,0x00,0x14,0x24,0x03,0x00,0x01,0xa4,0x40,0x00,0x00,0x3c,0x01,0xb0,0x03, -0xa0,0x23,0x00,0x3f,0x08,0x00,0x24,0xb7,0xac,0x90,0x00,0x00,0x27,0xbd,0xff,0xd8, -0xaf,0xb0,0x00,0x10,0x30,0xd0,0x00,0xff,0x2e,0x02,0x00,0x2e,0xaf,0xb2,0x00,0x18, -0xaf,0xb1,0x00,0x14,0xaf,0xbf,0x00,0x20,0xaf,0xb3,0x00,0x1c,0x30,0xb1,0x00,0xff, -0x14,0x40,0x00,0x06,0x00,0x80,0x90,0x21,0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc, -0x7b,0xb0,0x00,0xbc,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,0x2e,0x13,0x00,0x10, -0x24,0x05,0x00,0x14,0x0c,0x00,0x13,0xa4,0x24,0x06,0x01,0x07,0x12,0x60,0x00,0x38, -0x02,0x00,0x30,0x21,0x8f,0xa2,0x00,0x38,0x30,0xc3,0x00,0x3f,0x3c,0x04,0xb0,0x09, -0x00,0x02,0x14,0x00,0x00,0x43,0x30,0x25,0x34,0x84,0x01,0x60,0x90,0x82,0x00,0x00, -0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xfd,0x24,0x02,0x00,0x01,0x12,0x22,0x00,0x2a, -0x2a,0x22,0x00,0x02,0x14,0x40,0x00,0x24,0x24,0x02,0x00,0x02,0x12,0x22,0x00,0x20, -0x24,0x02,0x00,0x03,0x12,0x22,0x00,0x19,0x00,0x00,0x00,0x00,0x16,0x60,0xff,0xe2, -0x24,0x02,0x00,0x01,0x12,0x22,0x00,0x13,0x2a,0x22,0x00,0x02,0x14,0x40,0x00,0x0d, -0x24,0x02,0x00,0x02,0x12,0x22,0x00,0x09,0x24,0x02,0x00,0x03,0x16,0x22,0xff,0xda, -0x00,0x00,0x00,0x00,0x24,0x04,0x08,0x4c,0x24,0x05,0xff,0xff,0x0c,0x00,0x13,0x5f, -0x3c,0x06,0x0c,0xb8,0x08,0x00,0x24,0xea,0x00,0x00,0x00,0x00,0x08,0x00,0x25,0x12, -0x24,0x04,0x08,0x48,0x16,0x20,0xff,0xd0,0x00,0x00,0x00,0x00,0x08,0x00,0x25,0x12, -0x24,0x04,0x08,0x40,0x08,0x00,0x25,0x12,0x24,0x04,0x08,0x44,0x24,0x04,0x08,0x4c, -0x0c,0x00,0x13,0x5f,0x24,0x05,0xff,0xff,0x08,0x00,0x25,0x07,0x00,0x00,0x00,0x00, -0x08,0x00,0x25,0x20,0x24,0x04,0x08,0x48,0x16,0x20,0xff,0xe0,0x00,0x00,0x00,0x00, -0x08,0x00,0x25,0x20,0x24,0x04,0x08,0x40,0x08,0x00,0x25,0x20,0x24,0x04,0x08,0x44, -0x02,0x40,0x20,0x21,0x0c,0x00,0x25,0x71,0x02,0x20,0x28,0x21,0x08,0x00,0x24,0xf5, -0x00,0x40,0x30,0x21,0x27,0xbd,0xff,0xd8,0x2c,0xc2,0x00,0x2e,0xaf,0xb2,0x00,0x18, -0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x20,0xaf,0xb3,0x00,0x1c, -0x00,0xc0,0x80,0x21,0x30,0xb1,0x00,0xff,0x00,0x80,0x90,0x21,0x14,0x40,0x00,0x07, -0x00,0x00,0x18,0x21,0x8f,0xbf,0x00,0x20,0x7b,0xb2,0x00,0xfc,0x7b,0xb0,0x00,0xbc, -0x00,0x60,0x10,0x21,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x28,0x2e,0x13,0x00,0x10, -0x24,0x05,0x00,0x14,0x0c,0x00,0x13,0xa4,0x24,0x06,0x01,0x07,0x12,0x60,0x00,0x24, -0x02,0x00,0x30,0x21,0x3c,0x03,0xb0,0x09,0x34,0x63,0x01,0x60,0x90,0x62,0x00,0x00, -0x00,0x00,0x00,0x00,0x14,0x40,0xff,0xfd,0x30,0xc5,0x00,0x3f,0x0c,0x00,0x25,0xae, -0x02,0x20,0x20,0x21,0x16,0x60,0x00,0x0a,0x00,0x40,0x80,0x21,0x24,0x02,0x00,0x01, -0x12,0x22,0x00,0x15,0x2a,0x22,0x00,0x02,0x14,0x40,0x00,0x0f,0x24,0x02,0x00,0x02, -0x12,0x22,0x00,0x0b,0x24,0x02,0x00,0x03,0x12,0x22,0x00,0x03,0x00,0x00,0x00,0x00, -0x08,0x00,0x25,0x3d,0x02,0x00,0x18,0x21,0x24,0x04,0x08,0x4c,0x24,0x05,0xff,0xff, -0x0c,0x00,0x13,0x5f,0x3c,0x06,0x0c,0xb8,0x08,0x00,0x25,0x3d,0x02,0x00,0x18,0x21, -0x08,0x00,0x25,0x5f,0x24,0x04,0x08,0x48,0x16,0x20,0xff,0xf5,0x00,0x00,0x00,0x00, -0x08,0x00,0x25,0x5f,0x24,0x04,0x08,0x40,0x08,0x00,0x25,0x5f,0x24,0x04,0x08,0x44, -0x02,0x40,0x20,0x21,0x0c,0x00,0x25,0x71,0x02,0x20,0x28,0x21,0x08,0x00,0x25,0x49, -0x00,0x40,0x30,0x21,0x27,0xbd,0xff,0xe8,0x2c,0xc2,0x00,0x1f,0xaf,0xb0,0x00,0x10, -0xaf,0xbf,0x00,0x14,0x00,0xc0,0x80,0x21,0x14,0x40,0x00,0x1d,0x30,0xa5,0x00,0xff, -0x24,0x02,0x00,0x01,0x10,0xa2,0x00,0x18,0x28,0xa2,0x00,0x02,0x14,0x40,0x00,0x12, -0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x0e,0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x07, -0x24,0x04,0x08,0x4c,0x26,0x10,0xff,0xe2,0x02,0x00,0x10,0x21,0x8f,0xbf,0x00,0x14, -0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x24,0x05,0xff,0xff, -0x0c,0x00,0x13,0x5f,0x3c,0x06,0x0d,0xf8,0x08,0x00,0x25,0x82,0x26,0x10,0xff,0xe2, -0x08,0x00,0x25,0x87,0x24,0x04,0x08,0x48,0x14,0xa0,0xff,0xf2,0x24,0x04,0x08,0x40, -0x08,0x00,0x25,0x88,0x24,0x05,0xff,0xff,0x08,0x00,0x25,0x87,0x24,0x04,0x08,0x44, -0x2c,0xc2,0x00,0x10,0x14,0x40,0xff,0xec,0x24,0x02,0x00,0x01,0x10,0xa2,0x00,0x14, -0x28,0xa2,0x00,0x02,0x14,0x40,0x00,0x0e,0x24,0x02,0x00,0x02,0x10,0xa2,0x00,0x0a, -0x24,0x02,0x00,0x03,0x10,0xa2,0x00,0x03,0x24,0x04,0x08,0x4c,0x08,0x00,0x25,0x82, -0x26,0x10,0xff,0xf1,0x24,0x05,0xff,0xff,0x0c,0x00,0x13,0x5f,0x3c,0x06,0x0d,0xb8, -0x08,0x00,0x25,0x82,0x26,0x10,0xff,0xf1,0x08,0x00,0x25,0xa1,0x24,0x04,0x08,0x48, -0x14,0xa0,0xff,0xf6,0x24,0x04,0x08,0x40,0x08,0x00,0x25,0xa2,0x24,0x05,0xff,0xff, -0x08,0x00,0x25,0xa1,0x24,0x04,0x08,0x44,0x27,0xbd,0xff,0xe8,0x30,0x84,0x00,0xff, -0x24,0x02,0x00,0x01,0x10,0x82,0x00,0x39,0xaf,0xbf,0x00,0x10,0x28,0x82,0x00,0x02, -0x14,0x40,0x00,0x27,0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x02,0x10,0x82,0x00,0x17, -0x00,0xa0,0x30,0x21,0x24,0x02,0x00,0x03,0x10,0x82,0x00,0x05,0x24,0x04,0x08,0x3c, -0x8f,0xbf,0x00,0x10,0x00,0x00,0x00,0x00,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18, -0x0c,0x00,0x13,0x5f,0x3c,0x05,0x3f,0x00,0x24,0x04,0x08,0x3c,0x3c,0x05,0x80,0x00, -0x0c,0x00,0x13,0x5f,0x00,0x00,0x30,0x21,0x24,0x04,0x08,0x3c,0x3c,0x05,0x80,0x00, -0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x01,0x24,0x04,0x08,0xac,0x0c,0x00,0x13,0x41, -0x24,0x05,0x0f,0xff,0x08,0x00,0x25,0xbc,0x00,0x00,0x00,0x00,0x24,0x04,0x08,0x34, -0x0c,0x00,0x13,0x5f,0x3c,0x05,0x3f,0x00,0x24,0x04,0x08,0x34,0x3c,0x05,0x80,0x00, -0x0c,0x00,0x13,0x5f,0x00,0x00,0x30,0x21,0x24,0x04,0x08,0x34,0x3c,0x05,0x80,0x00, -0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x01,0x08,0x00,0x25,0xcb,0x24,0x04,0x08,0xa8, -0x14,0x80,0xff,0xdf,0x00,0xa0,0x30,0x21,0x24,0x04,0x08,0x24,0x0c,0x00,0x13,0x5f, -0x3c,0x05,0x3f,0x00,0x24,0x04,0x08,0x24,0x3c,0x05,0x80,0x00,0x0c,0x00,0x13,0x5f, -0x00,0x00,0x30,0x21,0x24,0x04,0x08,0x24,0x3c,0x05,0x80,0x00,0x0c,0x00,0x13,0x5f, -0x24,0x06,0x00,0x01,0x08,0x00,0x25,0xcb,0x24,0x04,0x08,0xa0,0x00,0xa0,0x30,0x21, -0x24,0x04,0x08,0x2c,0x0c,0x00,0x13,0x5f,0x3c,0x05,0x3f,0x00,0x24,0x04,0x08,0x2c, -0x3c,0x05,0x80,0x00,0x0c,0x00,0x13,0x5f,0x00,0x00,0x30,0x21,0x24,0x04,0x08,0x2c, -0x3c,0x05,0x80,0x00,0x0c,0x00,0x13,0x5f,0x24,0x06,0x00,0x01,0x08,0x00,0x25,0xcb, -0x24,0x04,0x08,0xa4,0x3c,0x05,0x00,0x14,0x3c,0x02,0xb0,0x05,0x34,0x42,0x04,0x20, -0x3c,0x06,0xc0,0x00,0x3c,0x03,0xb0,0x05,0x3c,0x04,0xb0,0x05,0x34,0xa5,0x17,0x09, -0xac,0x45,0x00,0x00,0x34,0xc6,0x05,0x07,0x34,0x63,0x04,0x24,0x34,0x84,0x02,0x28, -0x3c,0x07,0xb0,0x05,0x24,0x02,0x00,0x20,0xac,0x66,0x00,0x00,0x34,0xe7,0x04,0x50, -0xa0,0x82,0x00,0x00,0x90,0xe2,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x03, -0x10,0x40,0xff,0xfc,0x24,0x02,0x00,0x01,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, -0x93,0x85,0x81,0xf1,0x24,0x02,0x00,0x01,0x14,0xa2,0x00,0x53,0x00,0x80,0x40,0x21, -0x8c,0x89,0x00,0x04,0x3c,0x02,0xb0,0x01,0x01,0x22,0x30,0x21,0x8c,0xc3,0x00,0x04, -0x3c,0x02,0x01,0x00,0x00,0x62,0x10,0x24,0x10,0x40,0x00,0x4b,0x30,0x62,0x00,0x08, -0x10,0x45,0x00,0x59,0x00,0x00,0x00,0x00,0x94,0xc2,0x00,0x38,0x24,0x03,0x00,0xb4, -0x30,0x44,0x00,0xff,0x10,0x83,0x00,0x61,0x24,0x02,0x00,0xc4,0x10,0x82,0x00,0x54, -0x24,0x02,0x00,0x94,0x10,0x82,0x00,0x45,0x00,0x00,0x00,0x00,0x94,0xc2,0x00,0x38, -0x00,0x00,0x00,0x00,0x30,0x47,0xff,0xff,0x30,0xe3,0x40,0xff,0x24,0x02,0x40,0x88, -0x14,0x62,0x00,0x39,0x30,0xe3,0x03,0x00,0x24,0x02,0x03,0x00,0x10,0x62,0x00,0x38, -0x00,0x00,0x00,0x00,0x94,0xc2,0x00,0x56,0x00,0x00,0x00,0x00,0x30,0x47,0xff,0xff, -0x30,0xe2,0x00,0x80,0x14,0x40,0x00,0x30,0x3c,0x02,0xb0,0x01,0x01,0x22,0x30,0x21, -0x94,0xc3,0x00,0x60,0x24,0x02,0x00,0x08,0x14,0x43,0x00,0x3b,0x00,0x00,0x00,0x00, -0x90,0xc2,0x00,0x62,0x24,0x03,0x00,0x04,0x00,0x02,0x39,0x02,0x10,0xe3,0x00,0x15, -0x24,0x02,0x00,0x06,0x14,0xe2,0x00,0x34,0x00,0x00,0x00,0x00,0x8d,0x05,0x01,0xac, -0x94,0xc4,0x00,0x66,0x27,0x82,0x89,0x68,0x00,0x05,0x28,0x80,0x30,0x87,0xff,0xff, -0x00,0xa2,0x28,0x21,0x00,0x07,0x1a,0x00,0x8c,0xa4,0x00,0x00,0x00,0x07,0x12,0x02, -0x00,0x43,0x10,0x25,0x24,0x42,0x00,0x5e,0x24,0x03,0xc0,0x00,0x30,0x47,0xff,0xff, -0x00,0x83,0x20,0x24,0x00,0x87,0x20,0x25,0xac,0xa4,0x00,0x00,0x08,0x00,0x26,0x76, -0xad,0x07,0x00,0x10,0x8d,0x05,0x01,0xac,0x94,0xc4,0x00,0x64,0x27,0x82,0x89,0x68, -0x00,0x05,0x28,0x80,0x30,0x87,0xff,0xff,0x00,0xa2,0x28,0x21,0x00,0x07,0x1a,0x00, -0x8c,0xa4,0x00,0x00,0x00,0x07,0x12,0x02,0x00,0x43,0x10,0x25,0x24,0x42,0x00,0x36, -0x3c,0x03,0xff,0xff,0x30,0x47,0xff,0xff,0x00,0x83,0x20,0x24,0x00,0x87,0x20,0x25, -0xac,0xa4,0x00,0x00,0xad,0x07,0x00,0x10,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, -0x94,0xc2,0x00,0x50,0x08,0x00,0x26,0x34,0x30,0x47,0xff,0xff,0x8d,0x04,0x01,0xac, -0x27,0x83,0x89,0x68,0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21,0x8c,0x82,0x00,0x00, -0x3c,0x03,0xff,0xff,0x00,0x43,0x10,0x24,0x34,0x42,0x00,0x2e,0xac,0x82,0x00,0x00, -0x24,0x03,0x00,0x2e,0xad,0x03,0x00,0x10,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, -0x8d,0x04,0x01,0xac,0x27,0x83,0x89,0x68,0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21, -0x8c,0x82,0x00,0x00,0x3c,0x03,0xff,0xff,0x00,0x43,0x10,0x24,0x34,0x42,0x00,0x0e, -0x24,0x03,0x00,0x0e,0x08,0x00,0x26,0x75,0xac,0x82,0x00,0x00,0x8d,0x04,0x01,0xac, -0x27,0x83,0x89,0x68,0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21,0x8c,0x82,0x00,0x00, -0x3c,0x03,0xff,0xff,0x00,0x43,0x10,0x24,0x34,0x42,0x00,0x14,0x24,0x03,0x00,0x14, -0x08,0x00,0x26,0x75,0xac,0x82,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, -0x30,0xc6,0x00,0xff,0x00,0x06,0x48,0x40,0x01,0x26,0x10,0x21,0x00,0x02,0x10,0x80, -0x27,0x8b,0xbc,0x30,0x27,0x83,0xbc,0x36,0x00,0x4b,0x40,0x21,0x00,0x43,0x10,0x21, -0x94,0x47,0x00,0x00,0x30,0xa2,0x3f,0xff,0x10,0xe2,0x00,0x29,0x30,0x8a,0xff,0xff, -0x95,0x02,0x00,0x02,0x24,0x03,0x00,0x01,0x00,0x02,0x11,0x82,0x30,0x42,0x00,0x01, -0x10,0x43,0x00,0x18,0x00,0x00,0x00,0x00,0x01,0x26,0x10,0x21,0x00,0x02,0x10,0x80, -0x00,0x4b,0x30,0x21,0x94,0xc4,0x00,0x02,0x27,0x83,0xbc,0x36,0x27,0x85,0xbc,0x34, -0x00,0x45,0x28,0x21,0x30,0x84,0xff,0xdf,0x00,0x43,0x10,0x21,0xa4,0xc4,0x00,0x02, -0xa4,0x40,0x00,0x00,0xa4,0xa0,0x00,0x00,0x94,0xc3,0x00,0x02,0x3c,0x04,0xb0,0x01, -0x01,0x44,0x20,0x21,0x30,0x63,0xff,0xbf,0xa4,0xc3,0x00,0x02,0xa0,0xc0,0x00,0x00, -0x8c,0x82,0x00,0x04,0x24,0x03,0xf0,0xff,0x00,0x43,0x10,0x24,0x03,0xe0,0x00,0x08, -0xac,0x82,0x00,0x04,0x24,0x02,0xc0,0x00,0x91,0x04,0x00,0x01,0x00,0xa2,0x10,0x24, -0x00,0x47,0x28,0x25,0x3c,0x03,0xb0,0x01,0x24,0x02,0x00,0x02,0x14,0x82,0xff,0xe2, -0x01,0x43,0x18,0x21,0xac,0x65,0x00,0x00,0x08,0x00,0x26,0xa3,0x01,0x26,0x10,0x21, -0x08,0x00,0x26,0xa3,0x01,0x26,0x10,0x21,0x93,0x83,0x81,0xf1,0x24,0x02,0x00,0x01, -0x14,0x62,0x00,0x0d,0x3c,0x02,0xb0,0x01,0x8c,0x84,0x00,0x04,0x3c,0x06,0xb0,0x09, -0x00,0x82,0x20,0x21,0x8c,0x85,0x00,0x08,0x8c,0x83,0x00,0x04,0x3c,0x02,0x01,0x00, -0x34,0xc6,0x01,0x00,0x00,0x62,0x18,0x24,0x14,0x60,0x00,0x05,0x30,0xa5,0x20,0x00, -0x24,0x02,0x00,0x06,0xa0,0xc2,0x00,0x00,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00, -0x3c,0x03,0xb0,0x09,0x10,0xa0,0xff,0xfc,0x34,0x63,0x01,0x00,0x24,0x02,0x00,0x0e, -0x08,0x00,0x26,0xd6,0xa0,0x62,0x00,0x00,0x3c,0x02,0xb0,0x01,0x30,0xa5,0xff,0xff, -0x00,0xa2,0x28,0x21,0x8c,0xa3,0x00,0x00,0x3c,0x02,0x10,0x00,0x00,0x80,0x30,0x21, -0x00,0x62,0x18,0x24,0x8c,0xa2,0x00,0x04,0x10,0x60,0x00,0x04,0x00,0x00,0x00,0x00, -0x30,0x42,0x80,0x00,0x10,0x40,0x00,0x13,0x00,0x00,0x00,0x00,0x8c,0xc2,0x01,0xa8, -0x00,0x00,0x00,0x00,0x24,0x44,0x00,0x01,0x28,0x83,0x00,0x00,0x24,0x42,0x00,0x40, -0x00,0x83,0x10,0x0a,0x93,0x83,0x81,0xf0,0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80, -0x00,0x82,0x20,0x23,0x24,0x63,0xff,0xff,0xac,0xc4,0x01,0xa8,0xa3,0x83,0x81,0xf0, -0x8c,0xc4,0x01,0xac,0x8c,0xc2,0x01,0xa8,0x00,0x00,0x00,0x00,0x00,0x44,0x10,0x26, -0x00,0x02,0x10,0x2b,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x3c,0x03,0xb0,0x03, -0x34,0x63,0x00,0x73,0x90,0x62,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x42,0x00,0x01, -0x14,0x40,0x00,0x04,0x00,0x00,0x00,0x00,0xa3,0x80,0x81,0xf1,0x03,0xe0,0x00,0x08, -0x00,0x00,0x00,0x00,0x24,0x02,0x00,0x01,0xa3,0x82,0x81,0xf1,0x03,0xe0,0x00,0x08, -0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x04,0x3c,0x05,0xb0,0x01,0x00,0x80,0x50,0x21, -0x00,0x45,0x10,0x21,0x8c,0x43,0x00,0x04,0x24,0x02,0x00,0x05,0x00,0x03,0x1a,0x02, -0x30,0x69,0x00,0x0f,0x11,0x22,0x00,0x0b,0x24,0x02,0x00,0x07,0x11,0x22,0x00,0x09, -0x24,0x02,0x00,0x0a,0x11,0x22,0x00,0x07,0x24,0x02,0x00,0x0b,0x11,0x22,0x00,0x05, -0x24,0x02,0x00,0x01,0x93,0x83,0x81,0xf0,0x3c,0x04,0xb0,0x06,0x10,0x62,0x00,0x03, -0x34,0x84,0x80,0x18,0x03,0xe0,0x00,0x08,0x00,0x00,0x00,0x00,0x8c,0x82,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x02,0x17,0x02,0x14,0x40,0xff,0xfa,0x00,0x00,0x00,0x00, -0x8d,0x43,0x01,0xa8,0x27,0x82,0x89,0x68,0x00,0x03,0x18,0x80,0x00,0x6a,0x20,0x21, -0x8c,0x87,0x00,0xa8,0x00,0x62,0x18,0x21,0x8c,0x68,0x00,0x00,0x00,0xe5,0x28,0x21, -0x8c,0xa9,0x00,0x00,0x3c,0x02,0xff,0xff,0x27,0x83,0x8a,0x68,0x01,0x22,0x10,0x24, -0x00,0x48,0x10,0x25,0xac,0xa2,0x00,0x00,0x8d,0x44,0x01,0xa8,0x00,0x07,0x30,0xc2, -0x3c,0x02,0x00,0x80,0x00,0x04,0x20,0x80,0x00,0x83,0x20,0x21,0x00,0x06,0x32,0x00, -0x8c,0xa9,0x00,0x04,0x00,0xc2,0x30,0x25,0x8c,0x82,0x00,0x00,0x3c,0x03,0x80,0x00, -0x01,0x22,0x10,0x25,0x00,0x43,0x10,0x25,0xac,0xa2,0x00,0x04,0xaf,0x87,0xbc,0x20, -0x8c,0xa2,0x00,0x00,0x00,0x00,0x00,0x00,0xaf,0x82,0xbc,0x28,0x8c,0xa3,0x00,0x04, -0x3c,0x01,0xb0,0x07,0xac,0x26,0x80,0x18,0x8d,0x42,0x01,0xa8,0xaf,0x83,0xbc,0x24, -0x93,0x85,0x81,0xf0,0x24,0x44,0x00,0x01,0x28,0x83,0x00,0x00,0x24,0x42,0x00,0x40, -0x00,0x83,0x10,0x0a,0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,0x24,0xa5,0xff,0xff, -0x00,0x82,0x20,0x23,0xad,0x44,0x01,0xa8,0xa3,0x85,0x81,0xf0,0x08,0x00,0x27,0x21, -0x00,0x00,0x00,0x00,0x3c,0x05,0xb0,0x03,0x3c,0x02,0x80,0x01,0x34,0xa5,0x00,0x20, -0x24,0x42,0x9d,0x64,0xac,0xa2,0x00,0x00,0x24,0x02,0x00,0x02,0x24,0x03,0x00,0x20, -0xac,0x82,0x00,0x64,0x3c,0x02,0x80,0x01,0xac,0x83,0x00,0x60,0xac,0x80,0x00,0x00, -0xac,0x80,0x00,0x04,0xac,0x80,0x00,0x08,0xac,0x80,0x00,0x4c,0xac,0x80,0x00,0x50, -0xac,0x80,0x00,0x54,0xac,0x80,0x00,0x0c,0xac,0x80,0x00,0x58,0xa0,0x80,0x00,0x5c, -0x24,0x42,0x9e,0x28,0x24,0x83,0x00,0x68,0x24,0x05,0x00,0x0f,0x24,0xa5,0xff,0xff, -0xac,0x62,0x00,0x00,0x04,0xa1,0xff,0xfd,0x24,0x63,0x00,0x04,0x3c,0x02,0x80,0x01, -0x24,0x42,0x9f,0x10,0xac,0x82,0x00,0x78,0x3c,0x03,0x80,0x01,0x3c,0x02,0x80,0x01, -0x24,0x63,0xa0,0x9c,0x24,0x42,0xa0,0x08,0xac,0x83,0x00,0x88,0xac,0x82,0x00,0x98, -0x3c,0x03,0x80,0x01,0x3c,0x02,0x80,0x01,0x24,0x63,0xa1,0x44,0x24,0x42,0xa2,0x5c, -0xac,0x83,0x00,0xa0,0xac,0x82,0x00,0xa4,0xa0,0x80,0x01,0xba,0xac,0x80,0x01,0xa8, -0xac,0x80,0x01,0xac,0xac,0x80,0x01,0xb0,0xac,0x80,0x01,0xb4,0xa0,0x80,0x01,0xb8, -0x03,0xe0,0x00,0x08,0xa0,0x80,0x01,0xb9,0x3c,0x03,0xb0,0x03,0x3c,0x02,0x80,0x01, -0x34,0x63,0x00,0x20,0x24,0x42,0x9e,0x28,0x03,0xe0,0x00,0x08,0xac,0x62,0x00,0x00, -0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x34,0x42,0x00,0x20,0x24,0x63,0x9e,0x40, -0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x10,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x11, -0x00,0x80,0x28,0x21,0x8c,0x82,0x00,0x14,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0d, -0x00,0x00,0x00,0x00,0x8c,0x84,0x00,0x10,0x8c,0xa3,0x00,0x14,0x8c,0xa2,0x00,0x04, -0x00,0x83,0x20,0x21,0x00,0x44,0x10,0x21,0x30,0x43,0x00,0xff,0x00,0x03,0x18,0x2b, -0x00,0x02,0x12,0x02,0x00,0x43,0x10,0x21,0x00,0x02,0x12,0x00,0x30,0x42,0x3f,0xff, -0xac,0xa2,0x00,0x04,0xac,0xa0,0x00,0x00,0xac,0xa0,0x00,0x4c,0xac,0xa0,0x00,0x50, -0xac,0xa0,0x00,0x54,0x03,0xe0,0x00,0x08,0xac,0xa0,0x00,0x0c,0x3c,0x03,0xb0,0x03, -0x3c,0x02,0x80,0x01,0x34,0x63,0x00,0x20,0x24,0x42,0x9e,0xbc,0xac,0x62,0x00,0x00, -0x8c,0x86,0x00,0x04,0x3c,0x02,0xb0,0x01,0x24,0x03,0x00,0x01,0x00,0xc2,0x10,0x21, -0x8c,0x45,0x00,0x00,0xac,0x83,0x00,0x4c,0x00,0x05,0x14,0x02,0x30,0xa3,0x3f,0xff, -0x30,0x42,0x00,0xff,0xac,0x83,0x00,0x10,0xac,0x82,0x00,0x14,0x8c,0x83,0x00,0x14, -0xac,0x85,0x00,0x40,0x00,0xc3,0x30,0x21,0x03,0xe0,0x00,0x08,0xac,0x86,0x00,0x08, -0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20, -0x24,0x63,0x9f,0x10,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00, -0x8c,0x82,0x00,0x4c,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x0a,0x00,0x80,0x80,0x21, -0xae,0x00,0x00,0x00,0xae,0x00,0x00,0x4c,0xae,0x00,0x00,0x50,0xae,0x00,0x00,0x54, -0xae,0x00,0x00,0x0c,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x18,0x0c,0x00,0x27,0xaf,0x00,0x00,0x00,0x00,0x08,0x00,0x27,0xd1, -0xae,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8, -0x34,0x42,0x00,0x20,0x24,0x63,0x9f,0x74,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14, -0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x4c,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x16, -0x00,0x80,0x80,0x21,0x8e,0x03,0x00,0x08,0x3c,0x02,0xb0,0x01,0x8e,0x04,0x00,0x44, -0x00,0x62,0x18,0x21,0x90,0x65,0x00,0x00,0x24,0x02,0x00,0x01,0xae,0x02,0x00,0x50, -0x30,0xa3,0x00,0xff,0x00,0x03,0x10,0x82,0x00,0x04,0x23,0x02,0x30,0x84,0x00,0x0f, -0x30,0x42,0x00,0x03,0x00,0x03,0x19,0x02,0xae,0x04,0x00,0x34,0xae,0x02,0x00,0x2c, -0xae,0x03,0x00,0x30,0xa2,0x05,0x00,0x48,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10, -0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x0c,0x00,0x27,0xaf,0x00,0x00,0x00,0x00, -0x08,0x00,0x27,0xe9,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01, -0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20,0x24,0x63,0xa0,0x08,0xaf,0xb0,0x00,0x10, -0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x50,0x00,0x00,0x00,0x00, -0x10,0x40,0x00,0x16,0x00,0x80,0x80,0x21,0x92,0x03,0x00,0x44,0x8e,0x02,0x00,0x40, -0x83,0x85,0x8b,0xd4,0x92,0x04,0x00,0x41,0x30,0x63,0x00,0x01,0x00,0x02,0x16,0x02, -0xae,0x04,0x00,0x14,0x00,0x00,0x30,0x21,0xae,0x02,0x00,0x18,0x10,0xa0,0x00,0x04, -0xae,0x03,0x00,0x3c,0x10,0x60,0x00,0x03,0x24,0x02,0x00,0x01,0x24,0x06,0x00,0x01, -0x24,0x02,0x00,0x01,0xa3,0x86,0x8b,0xd4,0x8f,0xbf,0x00,0x14,0xae,0x02,0x00,0x54, -0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x0c,0x00,0x27,0xdd, -0x00,0x00,0x00,0x00,0x08,0x00,0x28,0x0e,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03, -0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20,0x24,0x63,0xa0,0x9c, -0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x50, -0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x1b,0x00,0x80,0x80,0x21,0x3c,0x02,0xb0,0x03, -0x8c,0x42,0x00,0x00,0x92,0x04,0x00,0x44,0x8e,0x03,0x00,0x40,0x83,0x86,0x8b,0xd4, -0x92,0x05,0x00,0x41,0x30,0x42,0x08,0x00,0x30,0x84,0x00,0x01,0x00,0x02,0x12,0xc2, -0x00,0x03,0x1e,0x02,0x00,0x82,0x20,0x25,0xae,0x05,0x00,0x14,0x00,0x00,0x38,0x21, -0xae,0x03,0x00,0x18,0x10,0xc0,0x00,0x04,0xae,0x04,0x00,0x3c,0x10,0x80,0x00,0x03, -0x24,0x02,0x00,0x01,0x24,0x07,0x00,0x01,0x24,0x02,0x00,0x01,0xa3,0x87,0x8b,0xd4, -0x8f,0xbf,0x00,0x14,0xae,0x02,0x00,0x54,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x18,0x0c,0x00,0x27,0xdd,0x00,0x00,0x00,0x00,0x08,0x00,0x28,0x33, -0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8, -0x34,0x42,0x00,0x20,0x24,0x63,0xa1,0x44,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14, -0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x54,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x37, -0x00,0x80,0x80,0x21,0x8e,0x04,0x00,0x04,0x8e,0x03,0x00,0x44,0x3c,0x02,0x80,0x00, -0x3c,0x05,0xb0,0x01,0x34,0x42,0x00,0x10,0x00,0x85,0x20,0x21,0x00,0x62,0x18,0x25, -0xac,0x83,0x00,0x04,0x8e,0x02,0x00,0x04,0x8e,0x03,0x01,0xac,0x02,0x00,0x20,0x21, -0x00,0x45,0x10,0x21,0x8c,0x46,0x00,0x00,0x00,0x03,0x18,0x80,0x27,0x82,0x89,0x68, -0x00,0x62,0x18,0x21,0xac,0x66,0x00,0x00,0x8e,0x02,0x00,0x04,0x8e,0x03,0x01,0xac, -0x00,0x45,0x10,0x21,0x8c,0x46,0x00,0x04,0x00,0x03,0x18,0x80,0x27,0x82,0x8a,0x68, -0x00,0x62,0x18,0x21,0x0c,0x00,0x26,0x10,0xac,0x66,0x00,0x00,0x8e,0x03,0x01,0xac, -0x8e,0x07,0x00,0x04,0x3c,0x06,0xb0,0x03,0x24,0x65,0x00,0x01,0x28,0xa4,0x00,0x00, -0x24,0x62,0x00,0x40,0x00,0xa4,0x10,0x0a,0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80, -0x00,0x03,0x18,0x80,0x00,0xa2,0x28,0x23,0x00,0x70,0x18,0x21,0xae,0x05,0x01,0xac, -0xac,0x67,0x00,0xa8,0x34,0xc6,0x00,0x30,0x8c,0xc3,0x00,0x00,0x93,0x82,0x81,0xf0, -0x02,0x00,0x20,0x21,0x24,0x63,0x00,0x01,0x24,0x42,0x00,0x01,0xac,0xc3,0x00,0x00, -0xa3,0x82,0x81,0xf0,0x0c,0x00,0x27,0x90,0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x14, -0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x18,0x0c,0x00,0x28,0x27, -0x00,0x00,0x00,0x00,0x08,0x00,0x28,0x5d,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03, -0x3c,0x03,0x80,0x01,0x27,0xbd,0xff,0xe8,0x34,0x42,0x00,0x20,0x24,0x63,0xa2,0x5c, -0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x14,0xac,0x43,0x00,0x00,0x8c,0x82,0x00,0x54, -0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x37,0x00,0x80,0x80,0x21,0x8e,0x04,0x00,0x04, -0x8e,0x03,0x00,0x44,0x3c,0x02,0x80,0x00,0x3c,0x05,0xb0,0x01,0x34,0x42,0x00,0x10, -0x00,0x85,0x20,0x21,0x00,0x62,0x18,0x25,0xac,0x83,0x00,0x04,0x8e,0x02,0x00,0x04, -0x8e,0x03,0x01,0xac,0x02,0x00,0x20,0x21,0x00,0x45,0x10,0x21,0x8c,0x46,0x00,0x00, -0x00,0x03,0x18,0x80,0x27,0x82,0x89,0x68,0x00,0x62,0x18,0x21,0xac,0x66,0x00,0x00, -0x8e,0x02,0x00,0x04,0x8e,0x03,0x01,0xac,0x00,0x45,0x10,0x21,0x8c,0x46,0x00,0x04, -0x00,0x03,0x18,0x80,0x27,0x82,0x8a,0x68,0x00,0x62,0x18,0x21,0x0c,0x00,0x26,0x10, -0xac,0x66,0x00,0x00,0x8e,0x03,0x01,0xac,0x8e,0x07,0x00,0x04,0x3c,0x06,0xb0,0x03, -0x24,0x65,0x00,0x01,0x28,0xa4,0x00,0x00,0x24,0x62,0x00,0x40,0x00,0xa4,0x10,0x0a, -0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,0x00,0x03,0x18,0x80,0x00,0xa2,0x28,0x23, -0x00,0x70,0x18,0x21,0xae,0x05,0x01,0xac,0xac,0x67,0x00,0xa8,0x34,0xc6,0x00,0x30, -0x8c,0xc3,0x00,0x00,0x93,0x82,0x81,0xf0,0x02,0x00,0x20,0x21,0x24,0x63,0x00,0x01, -0x24,0x42,0x00,0x01,0xac,0xc3,0x00,0x00,0xa3,0x82,0x81,0xf0,0x0c,0x00,0x27,0x90, -0x00,0x00,0x00,0x00,0x8f,0xbf,0x00,0x14,0x8f,0xb0,0x00,0x10,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x18,0x0c,0x00,0x28,0x27,0x00,0x00,0x00,0x00,0x08,0x00,0x28,0xa3, -0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03,0x3c,0x03,0x80,0x01,0x34,0x42,0x00,0x20, -0x24,0x63,0xa3,0x74,0x27,0xbd,0xff,0xe0,0xac,0x43,0x00,0x00,0x3c,0x02,0x80,0x01, -0xaf,0xb2,0x00,0x18,0xaf,0xb1,0x00,0x14,0xaf,0xb0,0x00,0x10,0xaf,0xbf,0x00,0x1c, -0x00,0x80,0x80,0x21,0x24,0x52,0x9e,0x28,0x00,0x00,0x88,0x21,0x3c,0x03,0xb0,0x09, -0x34,0x63,0x00,0x06,0x8e,0x06,0x00,0x04,0x90,0x62,0x00,0x00,0x00,0x06,0x22,0x02, -0x00,0x44,0x10,0x23,0x24,0x44,0x00,0x40,0x28,0x83,0x00,0x00,0x24,0x42,0x00,0x7f, -0x00,0x83,0x10,0x0a,0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,0x24,0x84,0xff,0xff, -0x10,0x44,0x00,0x68,0x00,0x00,0x28,0x21,0x3c,0x02,0xb0,0x01,0x00,0xc2,0x10,0x21, -0x8c,0x44,0x00,0x04,0x3c,0x03,0x7c,0x00,0x34,0x63,0x00,0xf0,0x00,0x83,0x18,0x24, -0xae,0x04,0x00,0x44,0x8c,0x44,0x00,0x00,0x10,0x60,0x00,0x69,0x00,0x00,0x38,0x21, -0x3c,0x09,0xb0,0x03,0x3c,0x06,0x7c,0x00,0x35,0x29,0x00,0x99,0x3c,0x0a,0xb0,0x01, -0x24,0x08,0x00,0x40,0x34,0xc6,0x00,0xf0,0x3c,0x0b,0xff,0xff,0x3c,0x0c,0x28,0x38, -0x16,0x20,0x00,0x06,0x24,0xa5,0x00,0x01,0x93,0x82,0x81,0xf6,0x24,0x11,0x00,0x01, -0x24,0x42,0x00,0x01,0xa1,0x22,0x00,0x00,0xa3,0x82,0x81,0xf6,0x8e,0x02,0x00,0x04, -0x24,0x07,0x00,0x01,0x24,0x42,0x01,0x00,0x30,0x42,0x3f,0xff,0xae,0x02,0x00,0x04, -0x00,0x4a,0x10,0x21,0x8c,0x43,0x00,0x04,0x00,0x00,0x00,0x00,0xae,0x03,0x00,0x44, -0x8c,0x44,0x00,0x00,0x10,0xa8,0x00,0x2d,0x00,0x66,0x18,0x24,0x14,0x60,0xff,0xec, -0x00,0x8b,0x10,0x24,0x14,0x4c,0xff,0xea,0x24,0x02,0x00,0x01,0x10,0xe2,0x00,0x2f, -0x3c,0x03,0xb0,0x09,0x8e,0x02,0x00,0x44,0x8e,0x04,0x00,0x60,0x00,0x02,0x1e,0x42, -0x00,0x02,0x12,0x02,0x30,0x42,0x00,0x0f,0x30,0x63,0x00,0x01,0xae,0x02,0x00,0x00, -0x10,0x44,0x00,0x1a,0xae,0x03,0x00,0x58,0x8e,0x02,0x00,0x64,0x8e,0x04,0x00,0x58, -0x00,0x00,0x00,0x00,0x10,0x82,0x00,0x05,0x00,0x00,0x00,0x00,0xae,0x00,0x00,0x4c, -0xae,0x00,0x00,0x50,0xae,0x00,0x00,0x54,0xae,0x00,0x00,0x0c,0x8e,0x03,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x03,0x10,0x80,0x00,0x50,0x10,0x21,0x8c,0x42,0x00,0x68, -0x00,0x00,0x00,0x00,0x10,0x52,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x40,0xf8,0x09, -0x02,0x00,0x20,0x21,0x8e,0x04,0x00,0x58,0x8e,0x03,0x00,0x00,0x00,0x00,0x00,0x00, -0xae,0x03,0x00,0x60,0x08,0x00,0x28,0xeb,0xae,0x04,0x00,0x64,0x8e,0x02,0x00,0x64, -0x00,0x00,0x00,0x00,0x14,0x62,0xff,0xe5,0x00,0x00,0x00,0x00,0x7a,0x02,0x0d,0x7c, -0x8f,0xbf,0x00,0x1c,0x8f,0xb2,0x00,0x18,0x7b,0xb0,0x00,0xbc,0x00,0x43,0x10,0x26, -0x00,0x02,0x10,0x2b,0x03,0xe0,0x00,0x08,0x27,0xbd,0x00,0x20,0x34,0x63,0x00,0x06, -0x8e,0x04,0x00,0x04,0x90,0x62,0x00,0x00,0x00,0x04,0x22,0x02,0x00,0x44,0x10,0x23, -0x24,0x44,0x00,0x40,0x28,0x83,0x00,0x00,0x24,0x42,0x00,0x7f,0x00,0x83,0x10,0x0a, -0x00,0x02,0x11,0x83,0x00,0x02,0x11,0x80,0x00,0x82,0x20,0x23,0x14,0x87,0xff,0xc5, -0x00,0x00,0x00,0x00,0x8e,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x2c,0x62,0x00,0x03, -0x14,0x40,0x00,0x05,0x24,0x02,0x00,0x0d,0x10,0x62,0x00,0x03,0x24,0x02,0x00,0x01, -0x08,0x00,0x29,0x4b,0xa2,0x02,0x00,0x5c,0x08,0x00,0x29,0x4b,0xa2,0x00,0x00,0x5c, -0x3c,0x02,0xff,0xff,0x00,0x82,0x10,0x24,0x3c,0x03,0x28,0x38,0x14,0x43,0xff,0x94, -0x24,0x02,0x00,0x01,0x08,0x00,0x29,0x23,0x00,0x00,0x00,0x00,0x3c,0x02,0xb0,0x03, -0x3c,0x03,0x80,0x01,0x34,0x42,0x00,0x20,0x24,0x63,0xa5,0xcc,0xac,0x43,0x00,0x00, -0x8c,0x83,0x01,0xa8,0x8c,0x82,0x01,0xac,0x00,0x80,0x40,0x21,0x10,0x62,0x00,0x20, -0x00,0x00,0x20,0x21,0x93,0x82,0x81,0xf1,0x00,0x03,0x28,0x80,0x3c,0x07,0xb0,0x06, -0x00,0xa8,0x18,0x21,0x24,0x04,0x00,0x01,0x8c,0x66,0x00,0xa8,0x10,0x44,0x00,0x1c, -0x34,0xe7,0x80,0x18,0x3c,0x05,0xb0,0x01,0xaf,0x86,0xbc,0x20,0x00,0xc5,0x28,0x21, -0x8c,0xa3,0x00,0x00,0x00,0x06,0x20,0xc2,0x3c,0x02,0x00,0x80,0x00,0x04,0x22,0x00, -0x00,0x82,0x20,0x25,0xaf,0x83,0xbc,0x28,0x8c,0xa2,0x00,0x04,0xac,0xe4,0x00,0x00, -0x8d,0x03,0x01,0xa8,0xaf,0x82,0xbc,0x24,0x24,0x64,0x00,0x01,0x04,0x80,0x00,0x0a, -0x00,0x80,0x10,0x21,0x00,0x02,0x11,0x83,0x8d,0x03,0x01,0xac,0x00,0x02,0x11,0x80, -0x00,0x82,0x10,0x23,0x00,0x43,0x18,0x26,0xad,0x02,0x01,0xa8,0x00,0x03,0x20,0x2b, -0x03,0xe0,0x00,0x08,0x00,0x80,0x10,0x21,0x08,0x00,0x29,0x95,0x24,0x62,0x00,0x40, -0x27,0x82,0x89,0x68,0x00,0x06,0x20,0xc2,0x00,0x04,0x22,0x00,0x00,0xa2,0x48,0x21, -0x3c,0x02,0x00,0x80,0x00,0x82,0x58,0x25,0x93,0x82,0x81,0xf0,0x3c,0x0a,0xb0,0x06, -0x3c,0x03,0xb0,0x01,0x2c,0x42,0x00,0x02,0x00,0xc3,0x38,0x21,0x35,0x4a,0x80,0x18, -0x14,0x40,0xff,0xef,0x00,0x00,0x20,0x21,0x8c,0xe5,0x00,0x00,0x8d,0x23,0x00,0x00, -0x24,0x02,0xc0,0x00,0x00,0xa2,0x10,0x24,0x00,0x43,0x10,0x25,0xac,0xe2,0x00,0x00, -0x8d,0x04,0x01,0xa8,0x27,0x83,0x8a,0x68,0x8c,0xe5,0x00,0x04,0x00,0x04,0x20,0x80, -0x00,0x83,0x20,0x21,0x8c,0x82,0x00,0x00,0x3c,0x03,0x80,0x00,0x00,0xa2,0x10,0x25, -0x00,0x43,0x10,0x25,0xac,0xe2,0x00,0x04,0xaf,0x86,0xbc,0x20,0x8c,0xe2,0x00,0x00, -0x93,0x85,0x81,0xf0,0xaf,0x82,0xbc,0x28,0x8c,0xe3,0x00,0x04,0xad,0x4b,0x00,0x00, -0x8d,0x02,0x01,0xa8,0xaf,0x83,0xbc,0x24,0x24,0xa5,0xff,0xff,0x24,0x44,0x00,0x01, -0x28,0x83,0x00,0x00,0x24,0x42,0x00,0x40,0x00,0x83,0x10,0x0a,0x00,0x02,0x11,0x83, -0x00,0x02,0x11,0x80,0x00,0x82,0x20,0x23,0xad,0x04,0x01,0xa8,0xa3,0x85,0x81,0xf0, -0x79,0x02,0x0d,0x7c,0x00,0x00,0x00,0x00,0x00,0x43,0x10,0x26,0x08,0x00,0x29,0x9c, -0x00,0x02,0x20,0x2b,0x3c,0x04,0xb0,0x03,0x3c,0x06,0xb0,0x07,0x3c,0x02,0x80,0x01, -0x34,0xc6,0x00,0x18,0x34,0x84,0x00,0x20,0x24,0x42,0xa7,0x54,0x24,0x03,0xff,0x83, -0xac,0x82,0x00,0x00,0xa0,0xc3,0x00,0x00,0x90,0xc4,0x00,0x00,0x27,0xbd,0xff,0xf8, -0x3c,0x03,0xb0,0x07,0x24,0x02,0xff,0x82,0xa3,0xa4,0x00,0x00,0xa0,0x62,0x00,0x00, -0x90,0x64,0x00,0x00,0x3c,0x02,0xb0,0x07,0x34,0x42,0x00,0x08,0xa3,0xa4,0x00,0x01, -0xa0,0x40,0x00,0x00,0x90,0x43,0x00,0x00,0x24,0x02,0x00,0x03,0x3c,0x05,0xb0,0x07, -0xa3,0xa3,0x00,0x00,0xa0,0xc2,0x00,0x00,0x90,0xc4,0x00,0x00,0x34,0xa5,0x00,0x10, -0x24,0x02,0x00,0x06,0x3c,0x03,0xb0,0x07,0xa3,0xa4,0x00,0x00,0x34,0x63,0x00,0x38, -0xa0,0xa2,0x00,0x00,0x90,0x64,0x00,0x00,0x3c,0x02,0xb0,0x07,0x34,0x42,0x00,0x20, -0xa3,0xa4,0x00,0x00,0xa0,0xa0,0x00,0x00,0x90,0xa3,0x00,0x00,0xaf,0x82,0xbf,0x30, -0xa3,0xa3,0x00,0x00,0xa0,0x40,0x00,0x00,0x90,0x43,0x00,0x00,0x03,0xe0,0x00,0x08, -0x27,0xbd,0x00,0x08,}; - -u8 Rtl8192PciEFwDataArray[DataArrayLengthPciE] = { -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x10,0x00,0x08,0x00, -0x02,0xe9,0x01,0x74,0x02,0xab,0x01,0xc7,0x01,0x55,0x00,0xe4,0x00,0xab,0x00,0x72, -0x00,0x55,0x00,0x4c,0x00,0x4c,0x00,0x4c,0x00,0x4c,0x00,0x4c,0x02,0x76,0x01,0x3b, -0x00,0xd2,0x00,0x9e,0x00,0x69,0x00,0x4f,0x00,0x46,0x00,0x3f,0x01,0x3b,0x00,0x9e, -0x00,0x69,0x00,0x4f,0x00,0x35,0x00,0x27,0x00,0x23,0x00,0x20,0x01,0x2f,0x00,0x98, -0x00,0x65,0x00,0x4c,0x00,0x33,0x00,0x26,0x00,0x22,0x00,0x1e,0x00,0x98,0x00,0x4c, -0x00,0x33,0x00,0x26,0x00,0x19,0x00,0x13,0x00,0x11,0x00,0x0f,0x02,0x39,0x01,0x1c, -0x00,0xbd,0x00,0x8e,0x00,0x5f,0x00,0x47,0x00,0x3f,0x00,0x39,0x01,0x1c,0x00,0x8e, -0x00,0x5f,0x00,0x47,0x00,0x2f,0x00,0x23,0x00,0x20,0x00,0x1c,0x01,0x11,0x00,0x89, -0x00,0x5b,0x00,0x44,0x00,0x2e,0x00,0x22,0x00,0x1e,0x00,0x1b,0x00,0x89,0x00,0x44, -0x00,0x2e,0x00,0x22,0x00,0x17,0x00,0x11,0x00,0x0f,0x00,0x0e,0x02,0xab,0x02,0xab, -0x02,0x66,0x02,0x66,0x07,0x06,0x06,0x06,0x05,0x06,0x07,0x08,0x04,0x06,0x07,0x08, -0x09,0x0a,0x0b,0x0b,0x49,0x6e,0x74,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x54,0x4c, -0x42,0x4d,0x4f,0x44,0x00,0x00,0x00,0x00,0x54,0x4c,0x42,0x4c,0x5f,0x64,0x61,0x74, -0x61,0x00,0x54,0x4c,0x42,0x53,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x64,0x45,0x4c, -0x5f,0x64,0x61,0x74,0x61,0x00,0x41,0x64,0x45,0x53,0x00,0x00,0x00,0x00,0x00,0x00, -0x45,0x78,0x63,0x43,0x6f,0x64,0x65,0x36,0x00,0x00,0x45,0x78,0x63,0x43,0x6f,0x64, -0x65,0x37,0x00,0x00,0x53,0x79,0x73,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x70, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x52,0x49,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x43,0x70,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4f,0x76,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x01,0x0b,0x63, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x2c, -0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x48,0x00,0x00,0x00,0x60, -0x00,0x00,0x00,0x90,0x00,0x00,0x00,0xc0,0x00,0x00,0x01,0x20,0x00,0x00,0x01,0x80, -0x00,0x00,0x01,0xb0,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x68,0x00,0x00,0x00,0x9c, -0x00,0x00,0x00,0xd0,0x00,0x00,0x01,0x38,0x00,0x00,0x01,0xa0,0x00,0x00,0x01,0xd4, -0x00,0x00,0x02,0x08,0x00,0x00,0x00,0x68,0x00,0x00,0x00,0xd0,0x00,0x00,0x01,0x38, -0x00,0x00,0x01,0xa0,0x00,0x00,0x02,0x6f,0x00,0x00,0x03,0x40,0x00,0x00,0x03,0xa8, -0x00,0x00,0x04,0x10,0x01,0x01,0x01,0x02,0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04, -0x01,0x01,0x02,0x02,0x03,0x03,0x04,0x04,0x02,0x03,0x03,0x04,0x05,0x06,0x07,0x08, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x07,0x6c,0x80,0x00,0x07,0x80, -0x80,0x00,0x07,0x80,0x80,0x00,0x07,0x70,0x80,0x00,0x07,0x70,0x80,0x00,0x07,0x94, -0x80,0x00,0x56,0xb0,0x80,0x00,0x57,0x08,0x80,0x00,0x57,0x30,0x80,0x00,0x58,0x28, -0x80,0x00,0x58,0xe0,0x80,0x00,0x59,0x88,0x80,0x00,0x59,0xfc,0x80,0x00,0x5b,0x08, -0x80,0x00,0x5b,0x40,0x80,0x00,0x5b,0x54,0x80,0x00,0x5b,0x68,0x80,0x00,0x5c,0x50, -0x80,0x00,0x5c,0x90,0x80,0x00,0x5d,0x44,0x80,0x00,0x5d,0x6c,0x80,0x00,0x56,0x70, -0x80,0x00,0x5d,0xbc,0x80,0x00,0x64,0x48,0x80,0x00,0x64,0xc0,0x80,0x00,0x64,0xcc, -0x80,0x00,0x64,0xd8,0x80,0x00,0x64,0x60,0x80,0x00,0x64,0x60,0x80,0x00,0x64,0x60, -0x80,0x00,0x64,0x60,0x80,0x00,0x64,0x60,0x80,0x00,0x64,0x60,0x80,0x00,0x64,0x60, -0x80,0x00,0x64,0x60,0x80,0x00,0x64,0x60,0x80,0x00,0x64,0x60,0x80,0x00,0x64,0x60, -0x80,0x00,0x64,0x60,0x80,0x00,0x64,0xe4,0x80,0x00,0x64,0xf0,0x80,0x00,0x64,0xfc, -0x80,0x00,0x87,0xa4,0x80,0x00,0x87,0xa4,0x80,0x00,0x87,0xa4,0x80,0x00,0x87,0xd8, -0x80,0x00,0x88,0x18,0x80,0x00,0x88,0x50,0x80,0x00,0x88,0x80,0x80,0x00,0x88,0xb0, -0x80,0x00,0x88,0xc4,0x80,0x00,0x89,0x2c,0x80,0x00,0x89,0x40,0x80,0x00,0x89,0x7c, -0x80,0x00,0x89,0x84,0x80,0x00,0x89,0xc0,0x80,0x00,0x89,0xd4,0x80,0x00,0x89,0xdc, -0x80,0x00,0x89,0xe4,0x80,0x00,0x89,0xe4,0x80,0x00,0x89,0xe4,0x80,0x00,0x89,0xe4, -0x80,0x00,0x8a,0x14,0x80,0x00,0x8a,0x28,0x80,0x00,0x8a,0x3c,0x80,0x00,0x86,0xe8, -0x80,0x00,0x8d,0x68,0x80,0x00,0x8d,0x68,0x80,0x00,0x8d,0x68,0x80,0x00,0x8d,0x9c, -0x80,0x00,0x8d,0xdc,0x80,0x00,0x8e,0x14,0x80,0x00,0x8e,0x44,0x80,0x00,0x8e,0x74, -0x80,0x00,0x8e,0x88,0x80,0x00,0x8e,0xf0,0x80,0x00,0x8f,0x04,0x80,0x00,0x8f,0x40, -0x80,0x00,0x8f,0x48,0x80,0x00,0x8f,0x84,0x80,0x00,0x8f,0x98,0x80,0x00,0x8f,0xa0, -0x80,0x00,0x8f,0xa8,0x80,0x00,0x8f,0xa8,0x80,0x00,0x8f,0xa8,0x80,0x00,0x8f,0xa8, -0x80,0x00,0x8f,0xd8,0x80,0x00,0x8f,0xec,0x80,0x00,0x90,0x00,0x80,0x00,0x8b,0x88, -}; - u32 Rtl8192PciEPHY_REGArray[PHY_REGArrayLengthPciE] = {0x0,}; u32 Rtl8192PciEPHY_REG_1T2RArray[PHY_REG_1T2RArrayLengthPciE] = { diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h index 35fc1164effd..d1438c2f8980 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h @@ -582,7 +582,6 @@ struct r8192_priv { struct rt_firmware *pFirmware; enum rtl819x_loopback LoopbackMode; - enum firmware_source firmware_source; struct timer_list watch_dog_timer; struct timer_list fsync_timer; -- cgit v1.2.3 From 4ada11147e446c56a7bd12e519777db12764d293 Mon Sep 17 00:00:00 2001 From: Anders Darander Date: Wed, 23 Apr 2014 15:09:50 +0200 Subject: staging/rtl8821ae: fix sparse address space warning Change the definition of pci_mem_start|end from correct from pci_io(un)map's point of view. Signed-off-by: Anders Darander Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/pci.c | 14 +++++++------- drivers/staging/rtl8821ae/wifi.h | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8821ae/pci.c b/drivers/staging/rtl8821ae/pci.c index a562aa60d595..94f72832a838 100644 --- a/drivers/staging/rtl8821ae/pci.c +++ b/drivers/staging/rtl8821ae/pci.c @@ -2313,16 +2313,16 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev, /*shared mem start */ rtlpriv->io.pci_mem_start = - (unsigned long)pci_iomap(pdev, + pci_iomap(pdev, rtlpriv->cfg->bar_id, pmem_len); - if (rtlpriv->io.pci_mem_start == 0) { + if (rtlpriv->io.pci_mem_start == NULL) { RT_ASSERT(false, ("Can't map PCI mem\n")); goto fail2; } RT_TRACE(COMP_INIT, DBG_DMESG, ("mem mapped space: start: 0x%08lx len:%08lx " - "flags:%08lx, after map:0x%08lx\n", + "flags:%08lx, after map:0x%p\n", pmem_start, pmem_len, pmem_flags, rtlpriv->io.pci_mem_start)); @@ -2415,8 +2415,8 @@ fail3: rtl_deinit_core(hw); ieee80211_free_hw(hw); - if (rtlpriv->io.pci_mem_start != 0) - pci_iounmap(pdev, (void *)rtlpriv->io.pci_mem_start); + if (rtlpriv->io.pci_mem_start != NULL) + pci_iounmap(pdev, rtlpriv->io.pci_mem_start); fail2: pci_release_regions(pdev); @@ -2478,8 +2478,8 @@ void rtl_pci_disconnect(struct pci_dev *pdev) pci_disable_msi(rtlpci->pdev); list_del(&rtlpriv->list); - if (rtlpriv->io.pci_mem_start != 0) { - pci_iounmap(pdev, (void *)rtlpriv->io.pci_mem_start); + if (rtlpriv->io.pci_mem_start != NULL) { + pci_iounmap(pdev, rtlpriv->io.pci_mem_start); pci_release_regions(pdev); } diff --git a/drivers/staging/rtl8821ae/wifi.h b/drivers/staging/rtl8821ae/wifi.h index 17a9d9f8781d..e8250dad613b 100644 --- a/drivers/staging/rtl8821ae/wifi.h +++ b/drivers/staging/rtl8821ae/wifi.h @@ -1086,8 +1086,8 @@ struct rtl_io { struct device *dev; /*PCI MEM map */ - unsigned long pci_mem_end; /*shared mem end */ - unsigned long pci_mem_start; /*shared mem start */ + void __iomem *pci_mem_end; /*shared mem end */ + void __iomem *pci_mem_start; /*shared mem start */ /*PCI IO map */ unsigned long pci_base_addr; /*device I/O address */ -- cgit v1.2.3 From bcadb1dcb123e634a3e40019a5fe80c93f520e9f Mon Sep 17 00:00:00 2001 From: Monam Agarwal Date: Thu, 27 Mar 2014 20:01:01 +0530 Subject: Staging: slicoss: Fix smatch warning in slicoss.c This patch fixes following smatch warning: slicoss/slicoss.c:1429 slic_cmdq_addcmdpage() error: we previously assumed 'pslic_handle' could be null Signed-off-by: Monam Agarwal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/slicoss/slicoss.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index e27b88f02ccd..f350e6028ed2 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -1422,8 +1422,7 @@ static void slic_cmdq_addcmdpage(struct adapter *adapter, u32 *page) spin_lock_irqsave(&adapter->handle_lock.lock, adapter->handle_lock.flags); pslic_handle = adapter->pfree_slic_handles; - if (pslic_handle) - adapter->pfree_slic_handles = pslic_handle->next; + adapter->pfree_slic_handles = pslic_handle->next; spin_unlock_irqrestore(&adapter->handle_lock.lock, adapter->handle_lock.flags); pslic_handle->type = SLIC_HANDLE_CMD; -- cgit v1.2.3 From d63bc1fb0fa3f37afbbe5ba98d9070b78357169b Mon Sep 17 00:00:00 2001 From: Toby Smith Date: Wed, 2 Apr 2014 10:43:05 +1000 Subject: staging: netlogic: fix missing a blank line after declarations Fix checkpatch.pl issues with missing blank line after declarations. Signed-off-by: Toby Smith Signed-off-by: Greg Kroah-Hartman --- drivers/staging/netlogic/xlr_net.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/netlogic/xlr_net.c b/drivers/staging/netlogic/xlr_net.c index c83e3375104b..75d7c63cb413 100644 --- a/drivers/staging/netlogic/xlr_net.c +++ b/drivers/staging/netlogic/xlr_net.c @@ -268,6 +268,7 @@ static void xlr_make_tx_desc(struct nlm_fmn_msg *msg, unsigned long addr, unsigned long physkb = virt_to_phys(skb); int cpu_core = nlm_core_id(); int fr_stn_id = cpu_core * 8 + XLR_FB_STN; /* FB to 6th bucket */ + msg->msg0 = (((u64)1 << 63) | /* End of packet descriptor */ ((u64)127 << 54) | /* No Free back */ (u64)skb->len << 40 | /* Length of data */ -- cgit v1.2.3 From 9e74d2926a283dac17d3ab22ca982aab3a4a05d8 Mon Sep 17 00:00:00 2001 From: Emil Renner Berthing Date: Sat, 29 Mar 2014 13:57:44 +0100 Subject: staging: imx-drm: add LVDS666 support for parallel display Support the LVDS666 format on the IPUv3 parallel display. This makes the screen work on my Hercules eCAFE Slim HD. Signed-off-by: Emil Renner Berthing Signed-off-by: Greg Kroah-Hartman --- .../devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt | 1 + drivers/staging/imx-drm/ipu-v3/ipu-dc.c | 9 +++++++++ drivers/staging/imx-drm/parallel-display.c | 2 ++ 3 files changed, 12 insertions(+) diff --git a/Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt b/Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt index 3be5ce7a9654..e75f0e549fff 100644 --- a/Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt +++ b/Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt @@ -61,6 +61,7 @@ Required properties: Optional properties: - interface_pix_fmt: How this display is connected to the display interface. Currently supported types: "rgb24", "rgb565", "bgr666" + and "lvds666". - edid: verbatim EDID data block describing attached display. - ddc: phandle describing the i2c bus handling the display data channel diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-dc.c b/drivers/staging/imx-drm/ipu-v3/ipu-dc.c index d5de8bb5c803..07514dc1f66f 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-dc.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-dc.c @@ -91,6 +91,7 @@ enum ipu_dc_map { IPU_DC_MAP_RGB565, IPU_DC_MAP_GBR24, /* TVEv2 */ IPU_DC_MAP_BGR666, + IPU_DC_MAP_LVDS666, IPU_DC_MAP_BGR24, }; @@ -153,6 +154,8 @@ static int ipu_pixfmt_to_map(u32 fmt) return IPU_DC_MAP_GBR24; case V4L2_PIX_FMT_BGR666: return IPU_DC_MAP_BGR666; + case v4l2_fourcc('L', 'V', 'D', '6'): + return IPU_DC_MAP_LVDS666; case V4L2_PIX_FMT_BGR24: return IPU_DC_MAP_BGR24; default: @@ -398,6 +401,12 @@ int ipu_dc_init(struct ipu_soc *ipu, struct device *dev, ipu_dc_map_config(priv, IPU_DC_MAP_BGR666, 1, 11, 0xfc); /* green */ ipu_dc_map_config(priv, IPU_DC_MAP_BGR666, 2, 17, 0xfc); /* red */ + /* lvds666 */ + ipu_dc_map_clear(priv, IPU_DC_MAP_LVDS666); + ipu_dc_map_config(priv, IPU_DC_MAP_LVDS666, 0, 5, 0xfc); /* blue */ + ipu_dc_map_config(priv, IPU_DC_MAP_LVDS666, 1, 13, 0xfc); /* green */ + ipu_dc_map_config(priv, IPU_DC_MAP_LVDS666, 2, 21, 0xfc); /* red */ + /* bgr24 */ ipu_dc_map_clear(priv, IPU_DC_MAP_BGR24); ipu_dc_map_config(priv, IPU_DC_MAP_BGR24, 2, 7, 0xff); /* red */ diff --git a/drivers/staging/imx-drm/parallel-display.c b/drivers/staging/imx-drm/parallel-display.c index c60b6c645f42..eaf4dda1a0c4 100644 --- a/drivers/staging/imx-drm/parallel-display.c +++ b/drivers/staging/imx-drm/parallel-display.c @@ -219,6 +219,8 @@ static int imx_pd_bind(struct device *dev, struct device *master, void *data) imxpd->interface_pix_fmt = V4L2_PIX_FMT_RGB565; else if (!strcmp(fmt, "bgr666")) imxpd->interface_pix_fmt = V4L2_PIX_FMT_BGR666; + else if (!strcmp(fmt, "lvds666")) + imxpd->interface_pix_fmt = v4l2_fourcc('L', 'V', 'D', '6'); } panel_node = of_parse_phandle(np, "fsl,panel", 0); -- cgit v1.2.3 From 0e6bcf3a1539eff7a7c16af18de65f186b177ea4 Mon Sep 17 00:00:00 2001 From: Emil Renner Berthing Date: Sun, 30 Mar 2014 00:21:21 +0100 Subject: staging: imx-drm: imx-hdmi: clean up hdmi_phy_wait_i2c_done Simplify hdmi_phy_wait_i2c_done so the call to hdmi_readb is only done in one place. Also check for timout before waiting as suggested by Troy Kisky. This also fixes a checkpatch warning. Signed-off-by: Emil Renner Berthing Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/imx-hdmi.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/imx-drm/imx-hdmi.c b/drivers/staging/imx-drm/imx-hdmi.c index d47dedd2cdb4..13071330acad 100644 --- a/drivers/staging/imx-drm/imx-hdmi.c +++ b/drivers/staging/imx-drm/imx-hdmi.c @@ -659,13 +659,10 @@ static inline void hdmi_phy_test_dout(struct imx_hdmi *hdmi, static bool hdmi_phy_wait_i2c_done(struct imx_hdmi *hdmi, int msec) { - unsigned char val = 0; - val = hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3; - while (!val) { - udelay(1000); + while ((hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3) == 0) { if (msec-- == 0) return false; - val = hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3; + udelay(1000); } return true; } -- cgit v1.2.3 From 539e26cbbd9070d14e25db025fb716cda1cd07da Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Sat, 5 Apr 2014 12:40:45 -0300 Subject: imx-hdmi: Propagate the real error code on platform_get_irq() failure No need to return a 'fake' return value on platform_get_irq() failure. Signed-off-by: Fabio Estevam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/imx-hdmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/imx-drm/imx-hdmi.c b/drivers/staging/imx-drm/imx-hdmi.c index 13071330acad..0e638210d827 100644 --- a/drivers/staging/imx-drm/imx-hdmi.c +++ b/drivers/staging/imx-drm/imx-hdmi.c @@ -1625,7 +1625,7 @@ static int imx_hdmi_bind(struct device *dev, struct device *master, void *data) irq = platform_get_irq(pdev, 0); if (irq < 0) - return -EINVAL; + return irq; ret = devm_request_threaded_irq(dev, irq, imx_hdmi_hardirq, imx_hdmi_irq, IRQF_SHARED, -- cgit v1.2.3 From 60d857bffcac67c77a33c06d8dfe405f3a293d2b Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Mon, 7 Apr 2014 10:22:36 +0200 Subject: imx-drm: imx-drm-core: Fix imx_drm_encoder_get_mux_id The decoder mux id is equal to the port id of the encoder's input port that is connected to the given crtc, not to the endpoint id (which is arbitrary and usually zero). Signed-off-by: Philipp Zabel Tested-by: Shawn Guo Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/imx-drm-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index 4144a75e5f71..bc7f8bd227c7 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -517,7 +517,7 @@ int imx_drm_encoder_get_mux_id(struct device_node *node, of_node_put(port); if (port == imx_crtc->port) { ret = of_graph_parse_endpoint(ep, &endpoint); - return ret ? ret : endpoint.id; + return ret ? ret : endpoint.port; } } while (ep); -- cgit v1.2.3 From 98dbeadaf050335df8655d8d9be7a324b6cd896e Mon Sep 17 00:00:00 2001 From: Russell King Date: Fri, 18 Apr 2014 10:46:45 +0100 Subject: imx-drm: fix hdmi hotplug detection initial state The initial state at boot is assumed to be disconnected, and we hope to receive an interrupt to update the status. Let's be more explicit about the current state - reading the PHY status register tells us the current level of the hotplug signal, which we can report back in the _detect() method. Signed-off-by: Russell King Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/imx-hdmi.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/staging/imx-drm/imx-hdmi.c b/drivers/staging/imx-drm/imx-hdmi.c index 0e638210d827..886a0d49031b 100644 --- a/drivers/staging/imx-drm/imx-hdmi.c +++ b/drivers/staging/imx-drm/imx-hdmi.c @@ -120,8 +120,6 @@ struct imx_hdmi { struct clk *isfr_clk; struct clk *iahb_clk; - enum drm_connector_status connector_status; - struct hdmi_data_info hdmi_data; int vic; @@ -1379,7 +1377,9 @@ static enum drm_connector_status imx_hdmi_connector_detect(struct drm_connector { struct imx_hdmi *hdmi = container_of(connector, struct imx_hdmi, connector); - return hdmi->connector_status; + + return hdmi_readb(hdmi, HDMI_PHY_STAT0) & HDMI_PHY_HPD ? + connector_status_connected : connector_status_disconnected; } static int imx_hdmi_connector_get_modes(struct drm_connector *connector) @@ -1521,7 +1521,6 @@ static irqreturn_t imx_hdmi_irq(int irq, void *dev_id) hdmi_modb(hdmi, 0, HDMI_PHY_HPD, HDMI_PHY_POL0); - hdmi->connector_status = connector_status_connected; imx_hdmi_poweron(hdmi); } else { dev_dbg(hdmi->dev, "EVENT=plugout\n"); @@ -1529,7 +1528,6 @@ static irqreturn_t imx_hdmi_irq(int irq, void *dev_id) hdmi_modb(hdmi, HDMI_PHY_HPD, HDMI_PHY_HPD, HDMI_PHY_POL0); - hdmi->connector_status = connector_status_disconnected; imx_hdmi_poweroff(hdmi); } drm_helper_hpd_irq_event(hdmi->connector.dev); @@ -1603,7 +1601,6 @@ static int imx_hdmi_bind(struct device *dev, struct device *master, void *data) return -ENOMEM; hdmi->dev = dev; - hdmi->connector_status = connector_status_disconnected; hdmi->sample_rate = 48000; hdmi->ratio = 100; -- cgit v1.2.3 From 838201aa0f69cebabda70c6275f60cc46132c46e Mon Sep 17 00:00:00 2001 From: Antoine Schweitzer-Chaput Date: Fri, 18 Apr 2014 23:20:06 +0200 Subject: Staging: imx-drm: Fix some lines over 80 characters Signed-off-by: Antoine Schweitzer-Chaput Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/ipu-v3/ipu-common.c | 6 ++++-- drivers/staging/imx-drm/ipu-v3/ipu-dc.c | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-common.c b/drivers/staging/imx-drm/ipu-v3/ipu-common.c index ca85d3d70ae3..0ea00de2cc9a 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-common.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-common.c @@ -900,7 +900,8 @@ static void ipu_irq_handle(struct ipu_soc *ipu, const int *regs, int num_regs) status &= ipu_cm_read(ipu, IPU_INT_CTRL(regs[i])); for_each_set_bit(bit, &status, 32) { - irq = irq_linear_revmap(ipu->domain, regs[i] * 32 + bit); + irq = irq_linear_revmap(ipu->domain, + regs[i] * 32 + bit); if (irq) generic_handle_irq(irq); } @@ -1053,7 +1054,8 @@ static int ipu_irq_init(struct ipu_soc *ipu) } ret = irq_alloc_domain_generic_chips(ipu->domain, 32, 1, "IPU", - handle_level_irq, 0, IRQF_VALID, 0); + handle_level_irq, 0, + IRQF_VALID, 0); if (ret < 0) { dev_err(ipu->dev, "failed to alloc generic irq chips\n"); irq_domain_remove(ipu->domain); diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-dc.c b/drivers/staging/imx-drm/ipu-v3/ipu-dc.c index 07514dc1f66f..55f1b6b083d1 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-dc.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-dc.c @@ -370,7 +370,8 @@ int ipu_dc_init(struct ipu_soc *ipu, struct device *dev, writel(DC_WR_CH_CONF_WORD_SIZE_24 | DC_WR_CH_CONF_DISP_ID_PARALLEL(0), priv->channels[5].base + DC_WR_CH_CONF); - writel(DC_GEN_SYNC_1_6_SYNC | DC_GEN_SYNC_PRIORITY_1, priv->dc_reg + DC_GEN); + writel(DC_GEN_SYNC_1_6_SYNC | DC_GEN_SYNC_PRIORITY_1, + priv->dc_reg + DC_GEN); ipu->dc_priv = priv; -- cgit v1.2.3 From 694683f6319216105508862031eced3e54b95da2 Mon Sep 17 00:00:00 2001 From: Vitor Braga Date: Sun, 30 Mar 2014 00:44:59 -0300 Subject: staging: xgifb coding style cleanup This fixes "missing a blank line after declaration" warnings from checkpatch.pl for driver xgifb. The driver has no remaining errors or warnings from checkpatch.pl Signed-off-by: Vitor Braga Reviewed-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 2 ++ drivers/staging/xgifb/vb_init.c | 2 ++ drivers/staging/xgifb/vb_setmode.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 466804687fc0..a62d4dd4ce82 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -66,6 +66,7 @@ static int XGIfb_mode_rate_to_dclock(struct vb_device_info *XGI_Pr, unsigned short ModeIdIndex = 0, ClockIndex = 0; unsigned short RefreshRateTableIndex = 0; int Clock; + InitTo330Pointer(HwDeviceExtension->jChipType, XGI_Pr); XGI_SearchModeID(ModeNo, &ModeIdIndex); @@ -95,6 +96,7 @@ static int XGIfb_mode_rate_to_ddata(struct vb_device_info *XGI_Pr, unsigned short HRE, HBE, HRS, HDE; unsigned char sr_data, cr_data, cr_data2; int B, C, D, F, temp, j; + InitTo330Pointer(HwDeviceExtension->jChipType, XGI_Pr); if (!XGI_SearchModeID(ModeNo, &ModeIdIndex)) return 0; diff --git a/drivers/staging/xgifb/vb_init.c b/drivers/staging/xgifb/vb_init.c index 21541720e05c..ff210ddcbf9e 100644 --- a/drivers/staging/xgifb/vb_init.c +++ b/drivers/staging/xgifb/vb_init.c @@ -130,6 +130,7 @@ static void XGINew_DDRII_Bootup_XG27( unsigned long P3c4, struct vb_device_info *pVBInfo) { unsigned long P3d4 = P3c4 + 0x10; + pVBInfo->ram_type = XGINew_GetXG20DRAMType(HwDeviceExtension, pVBInfo); XGINew_SetMemoryClock(pVBInfo); @@ -389,6 +390,7 @@ static void XGI_SetDRAM_Helper(unsigned long P3d4, u8 seed, u8 temp2, u8 reg, u8 shift_factor, u8 mask1, u8 mask2) { u8 j; + for (j = 0; j < 4; j++) { temp2 |= (((seed >> (2 * j)) & 0x03) << shift_factor); xgifb_reg_set(P3d4, reg, temp2); diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index 400c726753fa..c638c8febee9 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -49,6 +49,7 @@ void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo) if (ChipType == XG27) { unsigned char temp; + pVBInfo->MCLKData = XGI27New_MCLKData; pVBInfo->CR40 = XGI27_cr41; pVBInfo->XGINew_CR97 = 0xc1; @@ -5222,6 +5223,7 @@ void XGI_SenseCRT1(struct vb_device_info *pVBInfo) unsigned short temp; int i; + xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); /* to fix XG42 single LCD sense to CRT+LCD */ -- cgit v1.2.3 From bbb591a743a5af788bce78d1749a159493006292 Mon Sep 17 00:00:00 2001 From: Denis Pithon Date: Tue, 1 Apr 2014 18:43:17 +0200 Subject: staging/wlan-ng: improve readability of usb_prism_tbl[] Minor changes to nicely line up device entries. Signed-off-by: Denis Pithon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/prism2usb.c | 118 ++++++++++++++---------------------- 1 file changed, 47 insertions(+), 71 deletions(-) diff --git a/drivers/staging/wlan-ng/prism2usb.c b/drivers/staging/wlan-ng/prism2usb.c index 4739c14d8359..9f2427c0f121 100644 --- a/drivers/staging/wlan-ng/prism2usb.c +++ b/drivers/staging/wlan-ng/prism2usb.c @@ -4,80 +4,56 @@ #include "prism2sta.c" #include "prism2fw.c" -#define PRISM_USB_DEVICE(vid, pid, name) \ - USB_DEVICE(vid, pid), \ - .driver_info = (unsigned long) name +#define PRISM_DEV(vid, pid, name) \ + { USB_DEVICE(vid, pid), \ + .driver_info = (unsigned long) name } static struct usb_device_id usb_prism_tbl[] = { - {PRISM_USB_DEVICE(0x04bb, 0x0922, "IOData AirPort WN-B11/USBS")}, - {PRISM_USB_DEVICE(0x07aa, 0x0012, "Corega Wireless LAN USB Stick-11")}, - {PRISM_USB_DEVICE(0x09aa, 0x3642, "Prism2.x 11Mbps WLAN USB Adapter")}, - {PRISM_USB_DEVICE - (0x1668, 0x0408, "Actiontec Prism2.5 11Mbps WLAN USB Adapter")}, - {PRISM_USB_DEVICE - (0x1668, 0x0421, "Actiontec Prism2.5 11Mbps WLAN USB Adapter")}, - {PRISM_USB_DEVICE - (0x1915, 0x2236, "Linksys WUSB11v3.0 11Mbps WLAN USB Adapter")}, - {PRISM_USB_DEVICE - (0x066b, 0x2212, "Linksys WUSB11v2.5 11Mbps WLAN USB Adapter")}, - {PRISM_USB_DEVICE - (0x066b, 0x2213, "Linksys WUSB12v1.1 11Mbps WLAN USB Adapter")}, - {PRISM_USB_DEVICE - (0x067c, 0x1022, "Siemens SpeedStream 1022 11Mbps WLAN USB Adapter")}, - {PRISM_USB_DEVICE - (0x049f, 0x0033, - "Compaq/Intel W100 PRO/Wireless 11Mbps multiport WLAN Adapter")}, - {PRISM_USB_DEVICE - (0x0411, 0x0016, "Melco WLI-USB-S11 11Mbps WLAN Adapter")}, - {PRISM_USB_DEVICE - (0x08de, 0x7a01, "PRISM25 IEEE 802.11 Mini USB Adapter")}, - {PRISM_USB_DEVICE - (0x8086, 0x1111, "Intel PRO/Wireless 2011B LAN USB Adapter")}, - {PRISM_USB_DEVICE - (0x0d8e, 0x7a01, "PRISM25 IEEE 802.11 Mini USB Adapter")}, - {PRISM_USB_DEVICE - (0x045e, 0x006e, "Microsoft MN510 Wireless USB Adapter")}, - {PRISM_USB_DEVICE(0x0967, 0x0204, "Acer Warplink USB Adapter")}, - {PRISM_USB_DEVICE - (0x0cde, 0x0002, "Z-Com 725/726 Prism2.5 USB/USB Integrated")}, - {PRISM_USB_DEVICE - (0x0cde, 0x0005, "Z-Com Xl735 Wireless 802.11b USB Adapter")}, - {PRISM_USB_DEVICE - (0x413c, 0x8100, "Dell TrueMobile 1180 Wireless USB Adapter")}, - {PRISM_USB_DEVICE - (0x0b3b, 0x1601, "ALLNET 0193 11Mbps WLAN USB Adapter")}, - {PRISM_USB_DEVICE - (0x0b3b, 0x1602, "ZyXEL ZyAIR B200 Wireless USB Adapter")}, - {PRISM_USB_DEVICE - (0x0baf, 0x00eb, "USRobotics USR1120 Wireless USB Adapter")}, - {PRISM_USB_DEVICE - (0x0411, 0x0027, "Melco WLI-USB-KS11G 11Mbps WLAN Adapter")}, - {PRISM_USB_DEVICE - (0x04f1, 0x3009, "JVC MP-XP7250 Builtin USB WLAN Adapter")}, - {PRISM_USB_DEVICE(0x0846, 0x4110, "NetGear MA111")}, - {PRISM_USB_DEVICE(0x03f3, 0x0020, "Adaptec AWN-8020 USB WLAN Adapter")}, - {PRISM_USB_DEVICE(0x2821, 0x3300, "ASUS-WL140 Wireless USB Adapter")}, - {PRISM_USB_DEVICE(0x2001, 0x3700, "DWL-122 Wireless USB Adapter")}, - {PRISM_USB_DEVICE - (0x2001, 0x3702, "DWL-120 Rev F Wireless USB Adapter")}, - {PRISM_USB_DEVICE(0x50c2, 0x4013, "Averatec USB WLAN Adapter")}, - {PRISM_USB_DEVICE(0x2c02, 0x14ea, "Planex GW-US11H WLAN USB Adapter")}, - {PRISM_USB_DEVICE(0x124a, 0x168b, "Airvast PRISM3 WLAN USB Adapter")}, - {PRISM_USB_DEVICE(0x083a, 0x3503, "T-Sinus 111 USB WLAN Adapter")}, - {PRISM_USB_DEVICE(0x2821, 0x3300, "Hawking HighDB USB Adapter")}, - {PRISM_USB_DEVICE - (0x0411, 0x0044, "Melco WLI-USB-KB11 11Mbps WLAN Adapter")}, - {PRISM_USB_DEVICE(0x1668, 0x6106, "ROPEX FreeLan 802.11b USB Adapter")}, - {PRISM_USB_DEVICE - (0x124a, 0x4017, "Pheenet WL-503IA 802.11b USB Adapter")}, - {PRISM_USB_DEVICE(0x0bb2, 0x0302, "Ambit Microsystems Corp.")}, - {PRISM_USB_DEVICE - (0x9016, 0x182d, "Sitecom WL-022 802.11b USB Adapter")}, - {PRISM_USB_DEVICE - (0x0543, 0x0f01, "ViewSonic Airsync USB Adapter 11Mbps (Prism2.5)")}, - { /* terminator */ } + PRISM_DEV(0x04bb, 0x0922, "IOData AirPort WN-B11/USBS"), + PRISM_DEV(0x07aa, 0x0012, "Corega Wireless LAN USB Stick-11"), + PRISM_DEV(0x09aa, 0x3642, "Prism2.x 11Mbps WLAN USB Adapter"), + PRISM_DEV(0x1668, 0x0408, "Actiontec Prism2.5 11Mbps WLAN USB Adapter"), + PRISM_DEV(0x1668, 0x0421, "Actiontec Prism2.5 11Mbps WLAN USB Adapter"), + PRISM_DEV(0x1915, 0x2236, "Linksys WUSB11v3.0 11Mbps WLAN USB Adapter"), + PRISM_DEV(0x066b, 0x2212, "Linksys WUSB11v2.5 11Mbps WLAN USB Adapter"), + PRISM_DEV(0x066b, 0x2213, "Linksys WUSB12v1.1 11Mbps WLAN USB Adapter"), + PRISM_DEV(0x0411, 0x0016, "Melco WLI-USB-S11 11Mbps WLAN Adapter"), + PRISM_DEV(0x08de, 0x7a01, "PRISM25 IEEE 802.11 Mini USB Adapter"), + PRISM_DEV(0x8086, 0x1111, "Intel PRO/Wireless 2011B LAN USB Adapter"), + PRISM_DEV(0x0d8e, 0x7a01, "PRISM25 IEEE 802.11 Mini USB Adapter"), + PRISM_DEV(0x045e, 0x006e, "Microsoft MN510 Wireless USB Adapter"), + PRISM_DEV(0x0967, 0x0204, "Acer Warplink USB Adapter"), + PRISM_DEV(0x0cde, 0x0002, "Z-Com 725/726 Prism2.5 USB/USB Integrated"), + PRISM_DEV(0x0cde, 0x0005, "Z-Com Xl735 Wireless 802.11b USB Adapter"), + PRISM_DEV(0x413c, 0x8100, "Dell TrueMobile 1180 Wireless USB Adapter"), + PRISM_DEV(0x0b3b, 0x1601, "ALLNET 0193 11Mbps WLAN USB Adapter"), + PRISM_DEV(0x0b3b, 0x1602, "ZyXEL ZyAIR B200 Wireless USB Adapter"), + PRISM_DEV(0x0baf, 0x00eb, "USRobotics USR1120 Wireless USB Adapter"), + PRISM_DEV(0x0411, 0x0027, "Melco WLI-USB-KS11G 11Mbps WLAN Adapter"), + PRISM_DEV(0x04f1, 0x3009, "JVC MP-XP7250 Builtin USB WLAN Adapter"), + PRISM_DEV(0x0846, 0x4110, "NetGear MA111"), + PRISM_DEV(0x03f3, 0x0020, "Adaptec AWN-8020 USB WLAN Adapter"), + PRISM_DEV(0x2821, 0x3300, "ASUS-WL140 Wireless USB Adapter"), + PRISM_DEV(0x2001, 0x3700, "DWL-122 Wireless USB Adapter"), + PRISM_DEV(0x2001, 0x3702, "DWL-120 Rev F Wireless USB Adapter"), + PRISM_DEV(0x50c2, 0x4013, "Averatec USB WLAN Adapter"), + PRISM_DEV(0x2c02, 0x14ea, "Planex GW-US11H WLAN USB Adapter"), + PRISM_DEV(0x124a, 0x168b, "Airvast PRISM3 WLAN USB Adapter"), + PRISM_DEV(0x083a, 0x3503, "T-Sinus 111 USB WLAN Adapter"), + PRISM_DEV(0x2821, 0x3300, "Hawking HighDB USB Adapter"), + PRISM_DEV(0x0411, 0x0044, "Melco WLI-USB-KB11 11Mbps WLAN Adapter"), + PRISM_DEV(0x1668, 0x6106, "ROPEX FreeLan 802.11b USB Adapter"), + PRISM_DEV(0x124a, 0x4017, "Pheenet WL-503IA 802.11b USB Adapter"), + PRISM_DEV(0x0bb2, 0x0302, "Ambit Microsystems Corp."), + PRISM_DEV(0x9016, 0x182d, "Sitecom WL-022 802.11b USB Adapter"), + PRISM_DEV(0x0543, 0x0f01, + "ViewSonic Airsync USB Adapter 11Mbps (Prism2.5)"), + PRISM_DEV(0x067c, 0x1022, + "Siemens SpeedStream 1022 11Mbps WLAN USB Adapter"), + PRISM_DEV(0x049f, 0x0033, + "Compaq/Intel W100 PRO/Wireless 11Mbps multiport WLAN Adapter"), + { } /* terminator */ }; - MODULE_DEVICE_TABLE(usb, usb_prism_tbl); /*---------------------------------------------------------------- -- cgit v1.2.3 From 9864f111a6581649ed607c12990ce493f97b91db Mon Sep 17 00:00:00 2001 From: Denis Pithon Date: Tue, 1 Apr 2014 18:43:18 +0200 Subject: staging/wlan-ng: remove obsolete comments prism2sta_probe_usb() and prism2sta_disconnect_usb() header comments are erroneous and useless. Removed. Signed-off-by: Denis Pithon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/prism2usb.c | 40 ------------------------------------- 1 file changed, 40 deletions(-) diff --git a/drivers/staging/wlan-ng/prism2usb.c b/drivers/staging/wlan-ng/prism2usb.c index 9f2427c0f121..613c3120d9fe 100644 --- a/drivers/staging/wlan-ng/prism2usb.c +++ b/drivers/staging/wlan-ng/prism2usb.c @@ -56,27 +56,6 @@ static struct usb_device_id usb_prism_tbl[] = { }; MODULE_DEVICE_TABLE(usb, usb_prism_tbl); -/*---------------------------------------------------------------- -* prism2sta_probe_usb -* -* Probe routine called by the USB subsystem. -* -* Arguments: -* dev ptr to the usb_device struct -* ifnum interface number being offered -* -* Returns: -* NULL - we're not claiming the device+interface -* non-NULL - we are claiming the device+interface and -* this is a ptr to the data we want back -* when disconnect is called. -* -* Side effects: -* -* Call context: -* I'm not sure, assume it's interrupt. -* -----------------------------------------------------------------*/ static int prism2sta_probe_usb(struct usb_interface *interface, const struct usb_device_id *id) { @@ -152,25 +131,6 @@ done: return result; } -/*---------------------------------------------------------------- -* prism2sta_disconnect_usb -* -* Called when a device previously claimed by probe is removed -* from the USB. -* -* Arguments: -* dev ptr to the usb_device struct -* ptr ptr returned by probe() when the device -* was claimed. -* -* Returns: -* Nothing -* -* Side effects: -* -* Call context: -* process -----------------------------------------------------------------*/ static void prism2sta_disconnect_usb(struct usb_interface *interface) { wlandevice_t *wlandev; -- cgit v1.2.3 From 58612c608f41a24c58ce082986da3e30ce2fff37 Mon Sep 17 00:00:00 2001 From: Denis Pithon Date: Tue, 1 Apr 2014 18:43:19 +0200 Subject: staging/wlan-ng: fix small coding style issues Delete some unneeded blank lines and add few ones to make checkpatch.pl happy. Signed-off-by: Denis Pithon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/prism2usb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/wlan-ng/prism2usb.c b/drivers/staging/wlan-ng/prism2usb.c index 613c3120d9fe..e92bbc12bb06 100644 --- a/drivers/staging/wlan-ng/prism2usb.c +++ b/drivers/staging/wlan-ng/prism2usb.c @@ -96,7 +96,8 @@ static int prism2sta_probe_usb(struct usb_interface *interface, prism2_reset_settletime, 0); if (result != 0) { result = -EIO; - dev_err(&interface->dev, "hfa384x_corereset() failed.\n"); + dev_err(&interface->dev, + "hfa384x_corereset() failed.\n"); goto failed_reset; } } @@ -136,7 +137,6 @@ static void prism2sta_disconnect_usb(struct usb_interface *interface) wlandevice_t *wlandev; wlandev = (wlandevice_t *) usb_get_intfdata(interface); - if (wlandev != NULL) { LIST_HEAD(cleanlist); struct list_head *entry; @@ -228,6 +228,7 @@ static int prism2sta_suspend(struct usb_interface *interface, { hfa384x_t *hw = NULL; wlandevice_t *wlandev; + wlandev = (wlandevice_t *) usb_get_intfdata(interface); if (!wlandev) return -ENODEV; @@ -250,6 +251,7 @@ static int prism2sta_resume(struct usb_interface *interface) int result = 0; hfa384x_t *hw = NULL; wlandevice_t *wlandev; + wlandev = (wlandevice_t *) usb_get_intfdata(interface); if (!wlandev) return -ENODEV; -- cgit v1.2.3 From 85de9d17c485c4196f74d45de2206d4802f8a3be Mon Sep 17 00:00:00 2001 From: Denis Carikli Date: Mon, 7 Apr 2014 14:44:43 +0200 Subject: imx-drm: match ipu_di_signal_cfg's clk_pol with its description. According to the datasheet, setting the di0_polarity_disp_clk field in the GENERAL di register sets the output clock polarity to active high. Signed-off-by: Denis Carikli Signed-off-by: Russell King --- drivers/staging/imx-drm/ipu-v3/ipu-di.c | 2 +- drivers/staging/imx-drm/ipuv3-crtc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-di.c b/drivers/staging/imx-drm/ipu-v3/ipu-di.c index 82a9ebad697c..849b3e120ef0 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-di.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-di.c @@ -595,7 +595,7 @@ int ipu_di_init_sync_panel(struct ipu_di *di, struct ipu_di_signal_cfg *sig) } } - if (!sig->clk_pol) + if (sig->clk_pol) di_gen |= DI_GEN_POLARITY_DISP_CLK; ipu_di_write(di, di_gen, DI_GENERAL); diff --git a/drivers/staging/imx-drm/ipuv3-crtc.c b/drivers/staging/imx-drm/ipuv3-crtc.c index c48f640db006..f2c9cd040043 100644 --- a/drivers/staging/imx-drm/ipuv3-crtc.c +++ b/drivers/staging/imx-drm/ipuv3-crtc.c @@ -158,7 +158,7 @@ static int ipu_crtc_mode_set(struct drm_crtc *crtc, sig_cfg.Vsync_pol = 1; sig_cfg.enable_pol = 1; - sig_cfg.clk_pol = 1; + sig_cfg.clk_pol = 0; sig_cfg.width = mode->hdisplay; sig_cfg.height = mode->vdisplay; sig_cfg.pixel_fmt = out_pixel_fmt; -- cgit v1.2.3 From 861a50c17260be2583309ef448dc728a4729549b Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Mon, 14 Apr 2014 23:53:16 +0200 Subject: imx-drm: ipu-common: add ipu_map_irq to request non-IDMAC interrupts This allows to request the DC related interrupts. Signed-off-by: Philipp Zabel Signed-off-by: Russell King --- drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h | 1 + drivers/staging/imx-drm/ipu-v3/ipu-common.c | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h b/drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h index c4d14ead5837..2966e425990e 100644 --- a/drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h +++ b/drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h @@ -76,6 +76,7 @@ enum ipu_channel_irq { IPU_IRQ_EOS = 192, }; +int ipu_map_irq(struct ipu_soc *ipu, int irq); int ipu_idmac_channel_irq(struct ipu_soc *ipu, struct ipuv3_channel *channel, enum ipu_channel_irq irq); diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-common.c b/drivers/staging/imx-drm/ipu-v3/ipu-common.c index ca85d3d70ae3..058551795677 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-common.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-common.c @@ -933,15 +933,22 @@ static void ipu_err_irq_handler(unsigned int irq, struct irq_desc *desc) chained_irq_exit(chip, desc); } -int ipu_idmac_channel_irq(struct ipu_soc *ipu, struct ipuv3_channel *channel, - enum ipu_channel_irq irq_type) +int ipu_map_irq(struct ipu_soc *ipu, int irq) { - int irq = irq_linear_revmap(ipu->domain, irq_type + channel->num); + int virq; - if (!irq) - irq = irq_create_mapping(ipu->domain, irq_type + channel->num); + virq = irq_linear_revmap(ipu->domain, irq); + if (!virq) + virq = irq_create_mapping(ipu->domain, irq); + + return virq; +} +EXPORT_SYMBOL_GPL(ipu_map_irq); - return irq; +int ipu_idmac_channel_irq(struct ipu_soc *ipu, struct ipuv3_channel *channel, + enum ipu_channel_irq irq_type) +{ + return ipu_map_irq(ipu, irq_type + channel->num); } EXPORT_SYMBOL_GPL(ipu_idmac_channel_irq); -- cgit v1.2.3 From 17075504688baf04567fc47c4a2a6ab8684b13e9 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Mon, 14 Apr 2014 23:53:17 +0200 Subject: imx-drm: ipu-common: add helpers to check for a busy IDMAC channel and to busywait for an interrupt Signed-off-by: Philipp Zabel Signed-off-by: Russell King --- drivers/staging/imx-drm/ipu-v3/ipu-common.c | 22 ++++++++++++++++++++++ drivers/staging/imx-drm/ipu-v3/ipu-prv.h | 3 +++ 2 files changed, 25 insertions(+) diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-common.c b/drivers/staging/imx-drm/ipu-v3/ipu-common.c index 058551795677..8fb4c207f3f1 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-common.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-common.c @@ -697,6 +697,12 @@ int ipu_idmac_enable_channel(struct ipuv3_channel *channel) } EXPORT_SYMBOL_GPL(ipu_idmac_enable_channel); +bool ipu_idmac_channel_busy(struct ipu_soc *ipu, unsigned int chno) +{ + return (ipu_idmac_read(ipu, IDMAC_CHA_BUSY(chno)) & idma_mask(chno)); +} +EXPORT_SYMBOL_GPL(ipu_idmac_channel_busy); + int ipu_idmac_wait_busy(struct ipuv3_channel *channel, int ms) { struct ipu_soc *ipu = channel->ipu; @@ -714,6 +720,22 @@ int ipu_idmac_wait_busy(struct ipuv3_channel *channel, int ms) } EXPORT_SYMBOL_GPL(ipu_idmac_wait_busy); +int ipu_wait_interrupt(struct ipu_soc *ipu, int irq, int ms) +{ + unsigned long timeout; + + timeout = jiffies + msecs_to_jiffies(ms); + ipu_cm_write(ipu, BIT(irq % 32), IPU_INT_STAT(irq / 32)); + while (!(ipu_cm_read(ipu, IPU_INT_STAT(irq / 32) & BIT(irq % 32)))) { + if (time_after(jiffies, timeout)) + return -ETIMEDOUT; + cpu_relax(); + } + + return 0; +} +EXPORT_SYMBOL_GPL(ipu_wait_interrupt); + int ipu_idmac_disable_channel(struct ipuv3_channel *channel) { struct ipu_soc *ipu = channel->ipu; diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-prv.h b/drivers/staging/imx-drm/ipu-v3/ipu-prv.h index 4df00501adc2..bfc1b3366488 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-prv.h +++ b/drivers/staging/imx-drm/ipu-v3/ipu-prv.h @@ -185,6 +185,9 @@ void ipu_srm_dp_sync_update(struct ipu_soc *ipu); int ipu_module_enable(struct ipu_soc *ipu, u32 mask); int ipu_module_disable(struct ipu_soc *ipu, u32 mask); +bool ipu_idmac_channel_busy(struct ipu_soc *ipu, unsigned int chno); +int ipu_wait_interrupt(struct ipu_soc *ipu, int irq, int ms); + int ipu_di_init(struct ipu_soc *ipu, struct device *dev, int id, unsigned long base, u32 module, struct clk *ipu_clk); void ipu_di_exit(struct ipu_soc *ipu, int id); -- cgit v1.2.3 From 47348661c4e03480dc99a29c371b5fa930d1bb55 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Mon, 14 Apr 2014 23:53:18 +0200 Subject: imx-drm: ipu-dmfc: wait for FIFOs to run empty before disabling Disabling the DMFC module while there is still data in the FIFOs could cause the "new frame before end of frame" error state when the DMFC is enabled again. Signed-off-by: Philipp Zabel Signed-off-by: Russell King --- drivers/staging/imx-drm/ipu-v3/ipu-dmfc.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-dmfc.c b/drivers/staging/imx-drm/ipu-v3/ipu-dmfc.c index 45213017fa4b..59f182b28fc1 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-dmfc.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-dmfc.c @@ -28,7 +28,12 @@ #define DMFC_GENERAL1 0x0014 #define DMFC_GENERAL2 0x0018 #define DMFC_IC_CTRL 0x001c -#define DMFC_STAT 0x0020 +#define DMFC_WR_CHAN_ALT 0x0020 +#define DMFC_WR_CHAN_DEF_ALT 0x0024 +#define DMFC_DP_CHAN_ALT 0x0028 +#define DMFC_DP_CHAN_DEF_ALT 0x002c +#define DMFC_GENERAL1_ALT 0x0030 +#define DMFC_STAT 0x0034 #define DMFC_WR_CHAN_1_28 0 #define DMFC_WR_CHAN_2_41 8 @@ -133,6 +138,20 @@ int ipu_dmfc_enable_channel(struct dmfc_channel *dmfc) } EXPORT_SYMBOL_GPL(ipu_dmfc_enable_channel); +static void ipu_dmfc_wait_fifos(struct ipu_dmfc_priv *priv) +{ + unsigned long timeout = jiffies + msecs_to_jiffies(1000); + + while ((readl(priv->base + DMFC_STAT) & 0x02fff000) != 0x02fff000) { + if (time_after(jiffies, timeout)) { + dev_warn(priv->dev, + "Timeout waiting for DMFC FIFOs to clear\n"); + break; + } + cpu_relax(); + } +} + void ipu_dmfc_disable_channel(struct dmfc_channel *dmfc) { struct ipu_dmfc_priv *priv = dmfc->priv; @@ -141,8 +160,10 @@ void ipu_dmfc_disable_channel(struct dmfc_channel *dmfc) priv->use_count--; - if (!priv->use_count) + if (!priv->use_count) { + ipu_dmfc_wait_fifos(priv); ipu_module_disable(priv->ipu, IPU_CONF_DMFC_EN); + } if (priv->use_count < 0) priv->use_count = 0; -- cgit v1.2.3 From 1dee9a9e53860a674abe5a4ee02949fa447ba2d5 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Mon, 14 Apr 2014 23:53:19 +0200 Subject: imx-drm: ipu-dc: wait for DC_FC_1 / DP_SF_END interrupt Wait for the DC Frame Complete or DP Sync Flow End interrupts before disabling DC channels. Signed-off-by: Philipp Zabel Signed-off-by: Russell King --- drivers/staging/imx-drm/ipu-v3/ipu-dc.c | 71 +++++++++++++++++++++++---------- 1 file changed, 50 insertions(+), 21 deletions(-) diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-dc.c b/drivers/staging/imx-drm/ipu-v3/ipu-dc.c index d5de8bb5c803..280e494aee81 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-dc.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-dc.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "../imx-drm.h" @@ -110,6 +111,9 @@ struct ipu_dc_priv { struct device *dev; struct ipu_dc channels[IPU_DC_NUM_CHANNELS]; struct mutex mutex; + struct completion comp; + int dc_irq; + int dp_irq; }; static void dc_link_event(struct ipu_dc *dc, int event, int addr, int priority) @@ -239,38 +243,46 @@ void ipu_dc_enable_channel(struct ipu_dc *dc) } EXPORT_SYMBOL_GPL(ipu_dc_enable_channel); +static irqreturn_t dc_irq_handler(int irq, void *dev_id) +{ + struct ipu_dc *dc = dev_id; + u32 reg; + + reg = readl(dc->base + DC_WR_CH_CONF); + reg &= ~DC_WR_CH_CONF_PROG_TYPE_MASK; + writel(reg, dc->base + DC_WR_CH_CONF); + + /* The Freescale BSP kernel clears DIx_COUNTER_RELEASE here */ + + complete(&dc->priv->comp); + return IRQ_HANDLED; +} + void ipu_dc_disable_channel(struct ipu_dc *dc) { struct ipu_dc_priv *priv = dc->priv; + int irq, ret; u32 val; - int irq = 0, timeout = 50; + /* TODO: Handle MEM_FG_SYNC differently from MEM_BG_SYNC */ if (dc->chno == 1) - irq = IPU_IRQ_DC_FC_1; + irq = priv->dc_irq; else if (dc->chno == 5) - irq = IPU_IRQ_DP_SF_END; + irq = priv->dp_irq; else return; - /* should wait for the interrupt here */ - mdelay(50); + init_completion(&priv->comp); + enable_irq(irq); + ret = wait_for_completion_timeout(&priv->comp, msecs_to_jiffies(50)); + disable_irq(irq); + if (ret <= 0) { + dev_warn(priv->dev, "DC stop timeout after 50 ms\n"); - if (dc->di == 0) - val = 0x00000002; - else - val = 0x00000020; - - /* Wait for DC triple buffer to empty */ - while ((readl(priv->dc_reg + DC_STAT) & val) != val) { - usleep_range(2000, 20000); - timeout -= 2; - if (timeout <= 0) - break; + val = readl(dc->base + DC_WR_CH_CONF); + val &= ~DC_WR_CH_CONF_PROG_TYPE_MASK; + writel(val, dc->base + DC_WR_CH_CONF); } - - val = readl(dc->base + DC_WR_CH_CONF); - val &= ~DC_WR_CH_CONF_PROG_TYPE_MASK; - writel(val, dc->base + DC_WR_CH_CONF); } EXPORT_SYMBOL_GPL(ipu_dc_disable_channel); @@ -340,7 +352,7 @@ int ipu_dc_init(struct ipu_soc *ipu, struct device *dev, struct ipu_dc_priv *priv; static int channel_offsets[] = { 0, 0x1c, 0x38, 0x54, 0x58, 0x5c, 0x78, 0, 0x94, 0xb4}; - int i; + int i, ret; priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) @@ -361,6 +373,23 @@ int ipu_dc_init(struct ipu_soc *ipu, struct device *dev, priv->channels[i].base = priv->dc_reg + channel_offsets[i]; } + priv->dc_irq = ipu_map_irq(ipu, IPU_IRQ_DC_FC_1); + if (!priv->dc_irq) + return -EINVAL; + ret = devm_request_irq(dev, priv->dc_irq, dc_irq_handler, 0, NULL, + &priv->channels[1]); + if (ret < 0) + return ret; + disable_irq(priv->dc_irq); + priv->dp_irq = ipu_map_irq(ipu, IPU_IRQ_DP_SF_END); + if (!priv->dp_irq) + return -EINVAL; + ret = devm_request_irq(dev, priv->dp_irq, dc_irq_handler, 0, NULL, + &priv->channels[5]); + if (ret < 0) + return ret; + disable_irq(priv->dp_irq); + writel(DC_WR_CH_CONF_WORD_SIZE_24 | DC_WR_CH_CONF_DISP_ID_PARALLEL(1) | DC_WR_CH_CONF_PROG_DI_ID, priv->channels[1].base + DC_WR_CH_CONF); -- cgit v1.2.3 From 285bbb018f0b2332ac7f76dd7e1bfb761bf5d85b Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Mon, 14 Apr 2014 23:53:20 +0200 Subject: imx-drm: ipu-dp: split disabling the DP foreground channel from disabling the DP module The former has to be done before disabling the DMFC, the latter has to be done afterwards. Otherwise the DMFC FIFOs never get cleared properly. Signed-off-by: Philipp Zabel Signed-off-by: Russell King --- drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h | 2 + drivers/staging/imx-drm/ipu-v3/ipu-dp.c | 68 +++++++++++++++++++---------- drivers/staging/imx-drm/ipuv3-plane.c | 4 ++ 3 files changed, 51 insertions(+), 23 deletions(-) diff --git a/drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h b/drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h index 2966e425990e..8678ad18a3ef 100644 --- a/drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h +++ b/drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h @@ -153,8 +153,10 @@ void ipu_dmfc_put(struct dmfc_channel *dmfc); struct ipu_dp *ipu_dp_get(struct ipu_soc *ipu, unsigned int flow); void ipu_dp_put(struct ipu_dp *); +int ipu_dp_enable(struct ipu_soc *ipu); int ipu_dp_enable_channel(struct ipu_dp *dp); void ipu_dp_disable_channel(struct ipu_dp *dp); +void ipu_dp_disable(struct ipu_soc *ipu); int ipu_dp_setup_channel(struct ipu_dp *dp, enum ipu_color_space in, enum ipu_color_space out); int ipu_dp_set_window_pos(struct ipu_dp *, u16 x_pos, u16 y_pos); diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-dp.c b/drivers/staging/imx-drm/ipu-v3/ipu-dp.c index 58f87c8d7c07..6980fa125517 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-dp.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-dp.c @@ -215,10 +215,9 @@ int ipu_dp_setup_channel(struct ipu_dp *dp, } EXPORT_SYMBOL_GPL(ipu_dp_setup_channel); -int ipu_dp_enable_channel(struct ipu_dp *dp) +int ipu_dp_enable(struct ipu_soc *ipu) { - struct ipu_flow *flow = to_flow(dp); - struct ipu_dp_priv *priv = flow->priv; + struct ipu_dp_priv *priv = ipu->dp_priv; mutex_lock(&priv->mutex); @@ -227,15 +226,28 @@ int ipu_dp_enable_channel(struct ipu_dp *dp) priv->use_count++; - if (dp->foreground) { - u32 reg; + mutex_unlock(&priv->mutex); - reg = readl(flow->base + DP_COM_CONF); - reg |= DP_COM_CONF_FG_EN; - writel(reg, flow->base + DP_COM_CONF); + return 0; +} +EXPORT_SYMBOL_GPL(ipu_dp_enable); - ipu_srm_dp_sync_update(priv->ipu); - } +int ipu_dp_enable_channel(struct ipu_dp *dp) +{ + struct ipu_flow *flow = to_flow(dp); + struct ipu_dp_priv *priv = flow->priv; + u32 reg; + + if (!dp->foreground) + return 0; + + mutex_lock(&priv->mutex); + + reg = readl(flow->base + DP_COM_CONF); + reg |= DP_COM_CONF_FG_EN; + writel(reg, flow->base + DP_COM_CONF); + + ipu_srm_dp_sync_update(priv->ipu); mutex_unlock(&priv->mutex); @@ -247,25 +259,35 @@ void ipu_dp_disable_channel(struct ipu_dp *dp) { struct ipu_flow *flow = to_flow(dp); struct ipu_dp_priv *priv = flow->priv; + u32 reg, csc; + + if (!dp->foreground) + return; mutex_lock(&priv->mutex); - priv->use_count--; + reg = readl(flow->base + DP_COM_CONF); + csc = reg & DP_COM_CONF_CSC_DEF_MASK; + if (csc == DP_COM_CONF_CSC_DEF_FG) + reg &= ~DP_COM_CONF_CSC_DEF_MASK; - if (dp->foreground) { - u32 reg, csc; + reg &= ~DP_COM_CONF_FG_EN; + writel(reg, flow->base + DP_COM_CONF); - reg = readl(flow->base + DP_COM_CONF); - csc = reg & DP_COM_CONF_CSC_DEF_MASK; - if (csc == DP_COM_CONF_CSC_DEF_FG) - reg &= ~DP_COM_CONF_CSC_DEF_MASK; + writel(0, flow->base + DP_FG_POS); + ipu_srm_dp_sync_update(priv->ipu); - reg &= ~DP_COM_CONF_FG_EN; - writel(reg, flow->base + DP_COM_CONF); + mutex_unlock(&priv->mutex); +} +EXPORT_SYMBOL_GPL(ipu_dp_disable_channel); - writel(0, flow->base + DP_FG_POS); - ipu_srm_dp_sync_update(priv->ipu); - } +void ipu_dp_disable(struct ipu_soc *ipu) +{ + struct ipu_dp_priv *priv = ipu->dp_priv; + + mutex_lock(&priv->mutex); + + priv->use_count--; if (!priv->use_count) ipu_module_disable(priv->ipu, IPU_CONF_DP_EN); @@ -275,7 +297,7 @@ void ipu_dp_disable_channel(struct ipu_dp *dp) mutex_unlock(&priv->mutex); } -EXPORT_SYMBOL_GPL(ipu_dp_disable_channel); +EXPORT_SYMBOL_GPL(ipu_dp_disable); struct ipu_dp *ipu_dp_get(struct ipu_soc *ipu, unsigned int flow) { diff --git a/drivers/staging/imx-drm/ipuv3-plane.c b/drivers/staging/imx-drm/ipuv3-plane.c index 27a8d735dae0..5697e59ddf1d 100644 --- a/drivers/staging/imx-drm/ipuv3-plane.c +++ b/drivers/staging/imx-drm/ipuv3-plane.c @@ -239,6 +239,8 @@ err_out: void ipu_plane_enable(struct ipu_plane *ipu_plane) { + if (ipu_plane->dp) + ipu_dp_enable(ipu_plane->ipu); ipu_dmfc_enable_channel(ipu_plane->dmfc); ipu_idmac_enable_channel(ipu_plane->ipu_ch); if (ipu_plane->dp) @@ -257,6 +259,8 @@ void ipu_plane_disable(struct ipu_plane *ipu_plane) ipu_dp_disable_channel(ipu_plane->dp); ipu_idmac_disable_channel(ipu_plane->ipu_ch); ipu_dmfc_disable_channel(ipu_plane->dmfc); + if (ipu_plane->dp) + ipu_dp_disable(ipu_plane->ipu); } static void ipu_plane_dpms(struct ipu_plane *ipu_plane, int mode) -- cgit v1.2.3 From 216ddd608fb4f993d2f80ddbf1297abe10935a89 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Mon, 14 Apr 2014 23:53:21 +0200 Subject: imx-drm: imx-dp: when disabling the DP foreground channel, wait until the DP background channel is finished before disabling the IDMAC channel Signed-off-by: Philipp Zabel Signed-off-by: Russell King --- drivers/staging/imx-drm/ipu-v3/ipu-dp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-dp.c b/drivers/staging/imx-drm/ipu-v3/ipu-dp.c index 6980fa125517..d90f82a87d19 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-dp.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-dp.c @@ -277,6 +277,9 @@ void ipu_dp_disable_channel(struct ipu_dp *dp) writel(0, flow->base + DP_FG_POS); ipu_srm_dp_sync_update(priv->ipu); + if (ipu_idmac_channel_busy(priv->ipu, IPUV3_CHANNEL_MEM_BG_SYNC)) + ipu_wait_interrupt(priv->ipu, IPU_IRQ_DP_SF_END, 50); + mutex_unlock(&priv->mutex); } EXPORT_SYMBOL_GPL(ipu_dp_disable_channel); -- cgit v1.2.3 From c115edb87f0666b924d8139b2fb0396b03c6ac5d Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Mon, 14 Apr 2014 23:53:22 +0200 Subject: imx-drm: ipuv3-crtc: change display enable/disable order Now that ipu_dc_disable_channel correctly waits for the channel to finish, we can reorder the enable/disable order to first stop the DC and DI and only then disable the IDMAC. Enabling is done the other way around: IDMAC first, then DC, then DI. This avoids an issue where sometimes the channel would not correctly start, leading to non-working LVDS displays. Signed-off-by: Philipp Zabel Signed-off-by: Russell King --- drivers/staging/imx-drm/ipuv3-crtc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/staging/imx-drm/ipuv3-crtc.c b/drivers/staging/imx-drm/ipuv3-crtc.c index f2c9cd040043..ab667a191a36 100644 --- a/drivers/staging/imx-drm/ipuv3-crtc.c +++ b/drivers/staging/imx-drm/ipuv3-crtc.c @@ -63,9 +63,11 @@ static void ipu_fb_enable(struct ipu_crtc *ipu_crtc) if (ipu_crtc->enabled) return; - ipu_di_enable(ipu_crtc->di); - ipu_dc_enable_channel(ipu_crtc->dc); + /* TODO: Enable DC module here, right now it is never disabled */ ipu_plane_enable(ipu_crtc->plane[0]); + /* Start DC channel and DI after IDMAC */ + ipu_dc_enable_channel(ipu_crtc->dc); + ipu_di_enable(ipu_crtc->di); ipu_crtc->enabled = 1; } @@ -75,9 +77,11 @@ static void ipu_fb_disable(struct ipu_crtc *ipu_crtc) if (!ipu_crtc->enabled) return; - ipu_plane_disable(ipu_crtc->plane[0]); + /* Stop DC channel and DI before IDMAC */ ipu_dc_disable_channel(ipu_crtc->dc); ipu_di_disable(ipu_crtc->di); + ipu_plane_disable(ipu_crtc->plane[0]); + /* TODO: Disable DC module here */ ipu_crtc->enabled = 0; } -- cgit v1.2.3 From 1e6d486be4ea3f17c99c933703f53a6d566292a9 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Mon, 14 Apr 2014 23:53:23 +0200 Subject: imx-drm: ipu-dc: disable DC module when not in use Signed-off-by: Philipp Zabel Signed-off-by: Russell King --- drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h | 2 ++ drivers/staging/imx-drm/ipu-v3/ipu-dc.c | 14 ++++++++++++-- drivers/staging/imx-drm/ipuv3-crtc.c | 8 ++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h b/drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h index 8678ad18a3ef..c2c6fab05eaa 100644 --- a/drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h +++ b/drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h @@ -115,8 +115,10 @@ struct ipu_dc *ipu_dc_get(struct ipu_soc *ipu, int channel); void ipu_dc_put(struct ipu_dc *dc); int ipu_dc_init_sync(struct ipu_dc *dc, struct ipu_di *di, bool interlaced, u32 pixel_fmt, u32 width); +void ipu_dc_enable(struct ipu_soc *ipu); void ipu_dc_enable_channel(struct ipu_dc *dc); void ipu_dc_disable_channel(struct ipu_dc *dc); +void ipu_dc_disable(struct ipu_soc *ipu); /* * IPU Display Interface (di) functions diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-dc.c b/drivers/staging/imx-drm/ipu-v3/ipu-dc.c index 280e494aee81..93b2709f81e1 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-dc.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-dc.c @@ -224,12 +224,16 @@ int ipu_dc_init_sync(struct ipu_dc *dc, struct ipu_di *di, bool interlaced, writel(0x0, dc->base + DC_WR_CH_ADDR); writel(width, priv->dc_reg + DC_DISP_CONF2(dc->di)); - ipu_module_enable(priv->ipu, IPU_CONF_DC_EN); - return 0; } EXPORT_SYMBOL_GPL(ipu_dc_init_sync); +void ipu_dc_enable(struct ipu_soc *ipu) +{ + ipu_module_enable(ipu, IPU_CONF_DC_EN); +} +EXPORT_SYMBOL_GPL(ipu_dc_enable); + void ipu_dc_enable_channel(struct ipu_dc *dc) { int di; @@ -286,6 +290,12 @@ void ipu_dc_disable_channel(struct ipu_dc *dc) } EXPORT_SYMBOL_GPL(ipu_dc_disable_channel); +void ipu_dc_disable(struct ipu_soc *ipu) +{ + ipu_module_disable(ipu, IPU_CONF_DC_EN); +} +EXPORT_SYMBOL_GPL(ipu_dc_disable); + static void ipu_dc_map_config(struct ipu_dc_priv *priv, enum ipu_dc_map map, int byte_num, int offset, int mask) { diff --git a/drivers/staging/imx-drm/ipuv3-crtc.c b/drivers/staging/imx-drm/ipuv3-crtc.c index ab667a191a36..47bec5e17358 100644 --- a/drivers/staging/imx-drm/ipuv3-crtc.c +++ b/drivers/staging/imx-drm/ipuv3-crtc.c @@ -60,10 +60,12 @@ struct ipu_crtc { static void ipu_fb_enable(struct ipu_crtc *ipu_crtc) { + struct ipu_soc *ipu = dev_get_drvdata(ipu_crtc->dev->parent); + if (ipu_crtc->enabled) return; - /* TODO: Enable DC module here, right now it is never disabled */ + ipu_dc_enable(ipu); ipu_plane_enable(ipu_crtc->plane[0]); /* Start DC channel and DI after IDMAC */ ipu_dc_enable_channel(ipu_crtc->dc); @@ -74,6 +76,8 @@ static void ipu_fb_enable(struct ipu_crtc *ipu_crtc) static void ipu_fb_disable(struct ipu_crtc *ipu_crtc) { + struct ipu_soc *ipu = dev_get_drvdata(ipu_crtc->dev->parent); + if (!ipu_crtc->enabled) return; @@ -81,7 +85,7 @@ static void ipu_fb_disable(struct ipu_crtc *ipu_crtc) ipu_dc_disable_channel(ipu_crtc->dc); ipu_di_disable(ipu_crtc->di); ipu_plane_disable(ipu_crtc->plane[0]); - /* TODO: Disable DC module here */ + ipu_dc_disable(ipu); ipu_crtc->enabled = 0; } -- cgit v1.2.3 From 4f544ced19b3d300ac11414b68a676a2c42f6d06 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Sun, 13 Apr 2014 20:08:00 +0100 Subject: iio: st_sensors: announce registered sensors It is pretty helpful to know already from dmesg that a certain device is successfully registered, instead of having to browse sysfs to see if it's actually there. Cc: Lee Jones Cc: Denis CIOCCA Signed-off-by: Linus Walleij Signed-off-by: Jonathan Cameron --- drivers/iio/accel/st_accel_core.c | 3 +++ drivers/iio/gyro/st_gyro_core.c | 3 +++ drivers/iio/magnetometer/st_magn_core.c | 3 +++ drivers/iio/pressure/st_pressure_core.c | 3 +++ 4 files changed, 12 insertions(+) diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c index 38caedc76b98..4e06fcf5b891 100644 --- a/drivers/iio/accel/st_accel_core.c +++ b/drivers/iio/accel/st_accel_core.c @@ -496,6 +496,9 @@ int st_accel_common_probe(struct iio_dev *indio_dev, if (err) goto st_accel_device_register_error; + dev_info(&indio_dev->dev, "registered accelerometer %s\n", + indio_dev->name); + return 0; st_accel_device_register_error: diff --git a/drivers/iio/gyro/st_gyro_core.c b/drivers/iio/gyro/st_gyro_core.c index a8e174a47bc4..bc71f4d1e2ce 100644 --- a/drivers/iio/gyro/st_gyro_core.c +++ b/drivers/iio/gyro/st_gyro_core.c @@ -344,6 +344,9 @@ int st_gyro_common_probe(struct iio_dev *indio_dev, if (err) goto st_gyro_device_register_error; + dev_info(&indio_dev->dev, "registered gyroscope %s\n", + indio_dev->name); + return 0; st_gyro_device_register_error: diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c index 52bbcfa1e077..8e33a7682d33 100644 --- a/drivers/iio/magnetometer/st_magn_core.c +++ b/drivers/iio/magnetometer/st_magn_core.c @@ -387,6 +387,9 @@ int st_magn_common_probe(struct iio_dev *indio_dev, if (err) goto st_magn_device_register_error; + dev_info(&indio_dev->dev, "registered magnetometer %s\n", + indio_dev->name); + return 0; st_magn_device_register_error: diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 7418768ed49c..013becbe8f47 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -474,6 +474,9 @@ int st_press_common_probe(struct iio_dev *indio_dev, if (err) goto st_press_device_register_error; + dev_info(&indio_dev->dev, "registered pressure sensor %s\n", + indio_dev->name); + return err; st_press_device_register_error: -- cgit v1.2.3 From ea7e586bdd331fd6fba2b6f9fd3777928c2814d8 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Sun, 13 Apr 2014 20:08:00 +0100 Subject: iio: st_sensors: move regulator retrieveal to core Currently the pressure sensor has code to retrieve and enable two regulators for Vdd and Vdd IO, but actually these voltage inputs are found on all of these ST sensors, so move the regulator handling to the core and make sure all the ST sensors call these functions on probe() and remove() to enable/disable power. Here also mover over to obtaining the regulator from the *parent* device of the IIO device, as the IIO device is created on-the-fly in this very subsystem it very unlikely evert have any regulators attached to it whatsoever. It is much more likely that the parent is a platform device, possibly instantiated from a device tree, which in turn have Vdd and Vdd IO supplied assigned to it. Cc: Lee Jones Cc: Denis CIOCCA Signed-off-by: Linus Walleij Signed-off-by: Jonathan Cameron --- drivers/iio/accel/st_accel_core.c | 4 +++ drivers/iio/common/st_sensors/st_sensors_core.c | 37 +++++++++++++++++++++++ drivers/iio/gyro/st_gyro_core.c | 4 +++ drivers/iio/magnetometer/st_magn_core.c | 4 +++ drivers/iio/pressure/st_pressure_core.c | 39 ++----------------------- include/linux/iio/common/st_sensors.h | 4 +++ 6 files changed, 55 insertions(+), 37 deletions(-) diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c index 4e06fcf5b891..a2abf7c2ce3b 100644 --- a/drivers/iio/accel/st_accel_core.c +++ b/drivers/iio/accel/st_accel_core.c @@ -459,6 +459,8 @@ int st_accel_common_probe(struct iio_dev *indio_dev, indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &accel_info; + st_sensors_power_enable(indio_dev); + err = st_sensors_check_device_support(indio_dev, ARRAY_SIZE(st_accel_sensors), st_accel_sensors); if (err < 0) @@ -515,6 +517,8 @@ void st_accel_common_remove(struct iio_dev *indio_dev) { struct st_sensor_data *adata = iio_priv(indio_dev); + st_sensors_power_disable(indio_dev); + iio_device_unregister(indio_dev); if (adata->get_irq_data_ready(indio_dev) > 0) st_sensors_deallocate_trigger(indio_dev); diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c index 7ba1ef270213..e8b932fed70e 100644 --- a/drivers/iio/common/st_sensors/st_sensors_core.c +++ b/drivers/iio/common/st_sensors/st_sensors_core.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -198,6 +199,42 @@ int st_sensors_set_axis_enable(struct iio_dev *indio_dev, u8 axis_enable) } EXPORT_SYMBOL(st_sensors_set_axis_enable); +void st_sensors_power_enable(struct iio_dev *indio_dev) +{ + struct st_sensor_data *pdata = iio_priv(indio_dev); + int err; + + /* Regulators not mandatory, but if requested we should enable them. */ + pdata->vdd = devm_regulator_get_optional(indio_dev->dev.parent, "vdd"); + if (!IS_ERR(pdata->vdd)) { + err = regulator_enable(pdata->vdd); + if (err != 0) + dev_warn(&indio_dev->dev, + "Failed to enable specified Vdd supply\n"); + } + + pdata->vdd_io = devm_regulator_get_optional(indio_dev->dev.parent, "vddio"); + if (!IS_ERR(pdata->vdd_io)) { + err = regulator_enable(pdata->vdd_io); + if (err != 0) + dev_warn(&indio_dev->dev, + "Failed to enable specified Vdd_IO supply\n"); + } +} +EXPORT_SYMBOL(st_sensors_power_enable); + +void st_sensors_power_disable(struct iio_dev *indio_dev) +{ + struct st_sensor_data *pdata = iio_priv(indio_dev); + + if (!IS_ERR(pdata->vdd)) + regulator_disable(pdata->vdd); + + if (!IS_ERR(pdata->vdd_io)) + regulator_disable(pdata->vdd_io); +} +EXPORT_SYMBOL(st_sensors_power_disable); + static int st_sensors_set_drdy_int_pin(struct iio_dev *indio_dev, struct st_sensors_platform_data *pdata) { diff --git a/drivers/iio/gyro/st_gyro_core.c b/drivers/iio/gyro/st_gyro_core.c index bc71f4d1e2ce..ed74a9069989 100644 --- a/drivers/iio/gyro/st_gyro_core.c +++ b/drivers/iio/gyro/st_gyro_core.c @@ -311,6 +311,8 @@ int st_gyro_common_probe(struct iio_dev *indio_dev, indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &gyro_info; + st_sensors_power_enable(indio_dev); + err = st_sensors_check_device_support(indio_dev, ARRAY_SIZE(st_gyro_sensors), st_gyro_sensors); if (err < 0) @@ -363,6 +365,8 @@ void st_gyro_common_remove(struct iio_dev *indio_dev) { struct st_sensor_data *gdata = iio_priv(indio_dev); + st_sensors_power_disable(indio_dev); + iio_device_unregister(indio_dev); if (gdata->get_irq_data_ready(indio_dev) > 0) st_sensors_deallocate_trigger(indio_dev); diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c index 8e33a7682d33..240a21dd0c61 100644 --- a/drivers/iio/magnetometer/st_magn_core.c +++ b/drivers/iio/magnetometer/st_magn_core.c @@ -355,6 +355,8 @@ int st_magn_common_probe(struct iio_dev *indio_dev, indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &magn_info; + st_sensors_power_enable(indio_dev); + err = st_sensors_check_device_support(indio_dev, ARRAY_SIZE(st_magn_sensors), st_magn_sensors); if (err < 0) @@ -406,6 +408,8 @@ void st_magn_common_remove(struct iio_dev *indio_dev) { struct st_sensor_data *mdata = iio_priv(indio_dev); + st_sensors_power_disable(indio_dev); + iio_device_unregister(indio_dev); if (mdata->get_irq_data_ready(indio_dev) > 0) st_sensors_deallocate_trigger(indio_dev); diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 013becbe8f47..cd7e01f3a93b 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include @@ -387,40 +386,6 @@ static const struct iio_trigger_ops st_press_trigger_ops = { #define ST_PRESS_TRIGGER_OPS NULL #endif -static void st_press_power_enable(struct iio_dev *indio_dev) -{ - struct st_sensor_data *pdata = iio_priv(indio_dev); - int err; - - /* Regulators not mandatory, but if requested we should enable them. */ - pdata->vdd = devm_regulator_get_optional(&indio_dev->dev, "vdd"); - if (!IS_ERR(pdata->vdd)) { - err = regulator_enable(pdata->vdd); - if (err != 0) - dev_warn(&indio_dev->dev, - "Failed to enable specified Vdd supply\n"); - } - - pdata->vdd_io = devm_regulator_get_optional(&indio_dev->dev, "vddio"); - if (!IS_ERR(pdata->vdd_io)) { - err = regulator_enable(pdata->vdd_io); - if (err != 0) - dev_warn(&indio_dev->dev, - "Failed to enable specified Vdd_IO supply\n"); - } -} - -static void st_press_power_disable(struct iio_dev *indio_dev) -{ - struct st_sensor_data *pdata = iio_priv(indio_dev); - - if (!IS_ERR(pdata->vdd)) - regulator_disable(pdata->vdd); - - if (!IS_ERR(pdata->vdd_io)) - regulator_disable(pdata->vdd_io); -} - int st_press_common_probe(struct iio_dev *indio_dev, struct st_sensors_platform_data *plat_data) { @@ -431,7 +396,7 @@ int st_press_common_probe(struct iio_dev *indio_dev, indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &press_info; - st_press_power_enable(indio_dev); + st_sensors_power_enable(indio_dev); err = st_sensors_check_device_support(indio_dev, ARRAY_SIZE(st_press_sensors), @@ -493,7 +458,7 @@ void st_press_common_remove(struct iio_dev *indio_dev) { struct st_sensor_data *pdata = iio_priv(indio_dev); - st_press_power_disable(indio_dev); + st_sensors_power_disable(indio_dev); iio_device_unregister(indio_dev); if (pdata->get_irq_data_ready(indio_dev) > 0) diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h index 3c005eb3a0a4..96f51f0e0096 100644 --- a/include/linux/iio/common/st_sensors.h +++ b/include/linux/iio/common/st_sensors.h @@ -269,6 +269,10 @@ int st_sensors_set_enable(struct iio_dev *indio_dev, bool enable); int st_sensors_set_axis_enable(struct iio_dev *indio_dev, u8 axis_enable); +void st_sensors_power_enable(struct iio_dev *indio_dev); + +void st_sensors_power_disable(struct iio_dev *indio_dev); + int st_sensors_set_odr(struct iio_dev *indio_dev, unsigned int odr); int st_sensors_set_dataready_irq(struct iio_dev *indio_dev, bool enable); -- cgit v1.2.3 From 0426a2230ec23d6f3980f98d4855afb616047ce3 Mon Sep 17 00:00:00 2001 From: Thomas Vegas Date: Sat, 26 Apr 2014 11:20:09 +0200 Subject: staging: cxt1e1: Avoid using 0 instead of NULL Fixed the following sparse warnings: drivers/staging/cxt1e1/hwprobe.c:162:38: warning: Using plain integer as NULL pointer drivers/staging/cxt1e1/hwprobe.c:163:38: warning: Using plain integer as NULL pointer drivers/staging/cxt1e1/hwprobe.c:179:46: warning: Using plain integer as NULL pointer drivers/staging/cxt1e1/hwprobe.c:184:46: warning: Using plain integer as NULL pointer Signed-off-by: Thomas Vegas Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cxt1e1/hwprobe.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/cxt1e1/hwprobe.c b/drivers/staging/cxt1e1/hwprobe.c index cc2151e0acd7..4fa27c8931b1 100644 --- a/drivers/staging/cxt1e1/hwprobe.c +++ b/drivers/staging/cxt1e1/hwprobe.c @@ -159,8 +159,8 @@ prep_hdw_info(void) hi->ndev = NULL; hi->addr[0] = 0L; hi->addr[1] = 0L; - hi->addr_mapped[0] = 0L; - hi->addr_mapped[1] = 0L; + hi->addr_mapped[0] = NULL; + hi->addr_mapped[1] = NULL; } } @@ -176,12 +176,12 @@ cleanup_ioremap(void) if (hi->addr_mapped[0]) { iounmap(hi->addr_mapped[0]); release_mem_region((long) hi->addr[0], hi->len[0]); - hi->addr_mapped[0] = 0; + hi->addr_mapped[0] = NULL; } if (hi->addr_mapped[1]) { iounmap(hi->addr_mapped[1]); release_mem_region((long) hi->addr[1], hi->len[1]); - hi->addr_mapped[1] = 0; + hi->addr_mapped[1] = NULL; } } } -- cgit v1.2.3 From 7591ba8be2c695d651c55f37981880c77b804498 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:54:48 +0200 Subject: staging: rtl8723au: Add MAINTAINERS entry Signed-off-by: Jes Sorensen Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index e67ea2442041..da6867988988 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8479,6 +8479,13 @@ M: Florian Schilhabel . S: Odd Fixes F: drivers/staging/rtl8712/ +STAGING - REALTEK RTL8723U WIRELESS DRIVER +M: Larry Finger +M: Jes Sorensen +L: linux-wireless@vger.kernel.org +S: Maintained +F: drivers/staging/rtl8723au/ + STAGING - SILICON MOTION SM7XX FRAME BUFFER DRIVER M: Teddy Wang S: Odd Fixes -- cgit v1.2.3 From 5bd28bc2e4748d828a03dabd6122f004e31b9e98 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:54:49 +0200 Subject: staging: rtl8723au: Check kmalloc return value and fix size of memcpy() Check kmalloc() return before dereferencing bssid in rtw_check_bcn_info23a() and use the correct size to copy rtw_basic_rate_ofdm in update_bmc_sta_support_rate23a() Reported-by: Dan Carpenter Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 68991dca1cbf..3a729a0a85b5 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -4510,7 +4510,7 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, } ie_offset -= offsetof(struct ieee80211_mgmt, u); - bssid->Length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + length; + bssid->Length = offsetof(struct wlan_bssid_ex, IEs) + length; /* below is to copy the information element */ bssid->IELength = length; diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 646e468a630d..f2d77123cbc0 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -899,15 +899,17 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, } bssid = (struct wlan_bssid_ex *)kzalloc(sizeof(struct wlan_bssid_ex), - GFP_ATOMIC); + GFP_ATOMIC); + if (!bssid) + return _FAIL; bssid->reserved = 1; - bssid->Length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + len; + bssid->Length = offsetof(struct wlan_bssid_ex, IEs) + len; /* below is to copy the information element */ bssid->IELength = len; - memcpy(bssid->IEs, &mgmt->u, bssid->IELength); + memcpy(bssid->IEs, &mgmt->u, len); /* check bw and channel offset */ /* parsing HT_CAP_IE */ @@ -1589,9 +1591,11 @@ void update_bmc_sta_support_rate23a(struct rtw_adapter *padapter, u32 mac_id) if (pmlmeext->cur_wireless_mode & WIRELESS_11B) { /* Only B, B/G, and B/G/N AP could use CCK rate */ - memcpy((pmlmeinfo->FW_sta_info[mac_id].SupportedRates), rtw_basic_rate_cck, 4); + memcpy((pmlmeinfo->FW_sta_info[mac_id].SupportedRates), + rtw_basic_rate_cck, 4); } else { - memcpy((pmlmeinfo->FW_sta_info[mac_id].SupportedRates), rtw_basic_rate_ofdm, 4); + memcpy((pmlmeinfo->FW_sta_info[mac_id].SupportedRates), + rtw_basic_rate_ofdm, 3); } } -- cgit v1.2.3 From 0b682c9bb68acb56b2cfbb086b0ad04470c77306 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:54:50 +0200 Subject: staging: rtl8723au: Fix incorrect pointer test introduced in previous commit Commit da290c54610f49ef475f7f88668259216b08fc36 inverted the check of the return value when converting to use cfg80211_find_ie(). Reported-by: Dan Carpenter Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 3a729a0a85b5..21d112093fe1 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1385,7 +1385,7 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) supportRateNum = p[1]; p = cfg80211_find_ie(WLAN_EID_EXT_SUPP_RATES, pos, left); - if (!p) { + if (p) { if (supportRateNum <= sizeof(supportRate)) { memcpy(supportRate+supportRateNum, p + 2, p[1]); supportRateNum += p[1]; -- cgit v1.2.3 From 79a76349d59ab9cba7a9ea0abadbdac42bfee1b2 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:54:51 +0200 Subject: staging: rtl8723au: collect_bss_info23a(): Eliminate smatch warning Make length an unsigned int. This should avoid Smatch warning that 'length' can go negative. Reported-by: Dan Carpenter Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 21d112093fe1..e49170b3bb7a 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -4469,18 +4469,18 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame, struct wlan_bssid_ex *bssid) { - int i, length; + int i; const u8 *p; struct sk_buff *skb = precv_frame->pkt; struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; - int packet_len = skb->len; + unsigned int length; u8 ie_offset; struct registry_priv *pregistrypriv = &padapter->registrypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u16 capab_info; - length = packet_len - sizeof(struct ieee80211_hdr_3addr); + length = skb->len - sizeof(struct ieee80211_hdr_3addr); if (length > MAX_IE_SZ) { /* DBG_8723A("IE too long for survey event\n"); */ -- cgit v1.2.3 From 17979959ba5602d7acaa5c0f93a92c534ad4724d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:54:52 +0200 Subject: staging: rtl8723au: process_80211d(): Fix order of advancing array pos Fix smatch warning from advancing array index before reading out the value of the array. Reported-by: Dan Carpenter Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index e49170b3bb7a..00a7a63f960c 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -4867,9 +4867,9 @@ static void process_80211d(struct rtw_adapter *padapter, if (!ie || ie[1] < IEEE80211_COUNTRY_IE_MIN_LEN) return; - ie += 2; - p = ie; + p = ie + 2; ie += ie[1]; + ie += 2; memcpy(country, p, 3); country[3] = '\0'; -- cgit v1.2.3 From 8282aeb63f981a0add994c57a75e472e1ba4f525 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:54:53 +0200 Subject: staging: rtl8723au: rtw_check_beacon_data23a(): Make len unsigned int Making len unsigned int fixes a warning caused by smatch getting confused that len could be negative. Reported-by: Dan Carpenter Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 5 +++-- drivers/staging/rtl8723au/include/rtw_ap.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 207a19e4dc9f..77ee182f3e4f 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -783,7 +783,8 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) update_bmc_sta(padapter); } -int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, int len) +int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, + unsigned int len) { int ret = _SUCCESS; u8 *p; @@ -819,7 +820,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, int len) if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) return _FAIL; - if (len>MAX_IE_SZ) + if (len > MAX_IE_SZ) return _FAIL; pbss_network->IELength = len; diff --git a/drivers/staging/rtl8723au/include/rtw_ap.h b/drivers/staging/rtl8723au/include/rtw_ap.h index 7bcadff02ef9..8d9be5a36eae 100644 --- a/drivers/staging/rtl8723au/include/rtw_ap.h +++ b/drivers/staging/rtl8723au/include/rtw_ap.h @@ -32,7 +32,7 @@ void update_beacon23a(struct rtw_adapter *padapter, u8 ie_id, u8 *oui, u8 tx); void add_RATid23a(struct rtw_adapter *padapter, struct sta_info *psta, u8 rssi_level); void expire_timeout_chk23a(struct rtw_adapter *padapter); void update_sta_info23a_apmode23a(struct rtw_adapter *padapter, struct sta_info *psta); -int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, int len); +int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, unsigned int len); void rtw_ap_restore_network(struct rtw_adapter *padapter); void rtw_set_macaddr_acl23a(struct rtw_adapter *padapter, int mode); int rtw_acl_add_sta23a(struct rtw_adapter *padapter, u8 *addr); -- cgit v1.2.3 From fbde4129175fd2896ffc9c5363ee1a7a65541e76 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:54:54 +0200 Subject: staging: rtl8723au: c2h_wk_callback(): Use GFP_KERNEL, and check return value It is safe to use GFP_KERNEL in a workqueue handler, and check the return value. If the malloc fails, skip and try again. Reported-by: Dan Carpenter Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index cb15ddaae12e..068374a911fc 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -1536,7 +1536,9 @@ static void c2h_wk_callback(struct work_struct *work) /* This C2H event is read, clear it */ c2h_evt_clear23a(adapter); } else if ((c2h_evt = (struct c2h_evt_hdr *) - kmalloc(16, GFP_ATOMIC))) { + kmalloc(16, GFP_KERNEL))) { + if (!c2h_evt) + continue; /* This C2H event is not read, read & clear now */ if (c2h_evt_read23a(adapter, (u8*)c2h_evt) != _SUCCESS) continue; -- cgit v1.2.3 From f844717c6a5b30ed605e6fbfcab685c6d2e58592 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:54:55 +0200 Subject: staging: rtl8723au: rtw_cfg80211_inform_bss() fix Smatch warning Check the size of pnetwork->network.IELenght correctly to avoid Smatch warning. Reported-by: Dan Carpenter Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 5dbe3f43ab0e..74ac86a0333f 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -260,7 +260,7 @@ static int rtw_cfg80211_inform_bss(struct rtw_adapter *padapter, size_t notify_ielen; s32 notify_signal; u8 buf[MAX_BSSINFO_LEN], *pbuf; - size_t len, bssinf_len = 0; + size_t len; struct ieee80211_hdr *pwlanhdr; unsigned short *fctrl; @@ -270,11 +270,9 @@ static int rtw_cfg80211_inform_bss(struct rtw_adapter *padapter, /* DBG_8723A("%s\n", __func__); */ - bssinf_len = - pnetwork->network.IELength + sizeof(struct ieee80211_hdr_3addr); - if (bssinf_len > MAX_BSSINFO_LEN) { + if (pnetwork->network.IELength > MAX_IE_SZ) { DBG_8723A("%s IE Length too long > %d byte\n", __func__, - MAX_BSSINFO_LEN); + MAX_IE_SZ); goto exit; } -- cgit v1.2.3 From 6f1c59bf2c00eeba0f9ad9ce176cce731de1a8e5 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:54:56 +0200 Subject: staging: rtl8723au: cfg80211_rtw_add_key() return -ENOMEM on kmalloc failure Reported-by: Dan Carpenter Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 74ac86a0333f..0866ab59a399 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -1077,7 +1077,7 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev, { char *alg_name; u32 param_len; - struct ieee_param *param = NULL; + struct ieee_param *param; int ret = 0; struct wireless_dev *rtw_wdev = wiphy_to_wdev(wiphy); struct rtw_adapter *padapter = wiphy_to_adapter(wiphy); @@ -1093,8 +1093,8 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev, param_len = sizeof(struct ieee_param) + params->key_len; param = kzalloc(param_len, GFP_KERNEL); - if (param == NULL) - return -1; + if (!param) + return -ENOMEM; param->cmd = IEEE_CMD_SET_ENCRYPTION; eth_broadcast_addr(param->sta_addr); -- cgit v1.2.3 From d97e2d2b55525853d02a318f7f8a6ca214e24699 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:54:57 +0200 Subject: staging: rtl8723au: Use a workqueue for command handling Rewrite the old thread based code to use a workqueue instead. This removes a pile of complexity, locks and queues and eliminates problem that cmd handling could have been killed from userspace. This was suggested by Tejun Heo - thanks! Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 211 ++++++---------------- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 12 +- drivers/staging/rtl8723au/include/rtw_cmd.h | 11 +- drivers/staging/rtl8723au/os_dep/os_intfs.c | 15 +- 4 files changed, 67 insertions(+), 182 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 068374a911fc..813897f82185 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -176,13 +176,6 @@ int rtw_init_cmd_priv23a(struct cmd_priv *pcmdpriv) { int res = _SUCCESS; - sema_init(&pcmdpriv->cmd_queue_sema, 0); - sema_init(&pcmdpriv->terminate_cmdthread_sema, 0); - - _rtw_init_queue23a(&pcmdpriv->cmd_queue); - - pcmdpriv->cmd_seq = 1; - pcmdpriv->cmd_allocated_buf = kzalloc(MAX_CMDSZ + CMDBUFF_ALIGN_SZ, GFP_KERNEL); @@ -209,6 +202,11 @@ int rtw_init_cmd_priv23a(struct cmd_priv *pcmdpriv) pcmdpriv->cmd_done_cnt = 0; pcmdpriv->rsp_cnt = 0; + + pcmdpriv->wq = alloc_workqueue("rtl8723au", 0, 1); + if (!pcmdpriv->wq) + res = _FAIL; + exit: return res; @@ -260,32 +258,6 @@ void _rtw_free_cmd_priv23a(struct cmd_priv *pcmdpriv) } } -/* -Calling Context: -rtw_enqueue_cmd23a can only be called between kernel thread, -since only spin_lock is used. - -ISR/Call-Back functions can't call this sub-function. -*/ - -int _rtw_enqueue_cmd23a(struct rtw_queue *queue, struct cmd_obj *obj) -{ - unsigned long irqL; - - if (obj == NULL) - goto exit; - - spin_lock_irqsave(&queue->lock, irqL); - - list_add_tail(&obj->list, &queue->queue); - - spin_unlock_irqrestore(&queue->lock, irqL); - -exit: - - return _SUCCESS; -} - u32 rtw_init_evt_priv23a(struct evt_priv *pevtpriv) { int res; @@ -330,21 +302,21 @@ static int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) if (cmd_obj->cmdcode == GEN_CMD_CODE(_SetChannelPlan)) bAllow = true; - if ((pcmdpriv->padapter->hw_init_completed == false && - bAllow == false) || pcmdpriv->cmdthd_running == false) + if (pcmdpriv->padapter->hw_init_completed == false && bAllow == false) return _FAIL; return _SUCCESS; } -u32 rtw_enqueue_cmd23a(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) +static void rtw_cmd_work(struct work_struct *work); + +int rtw_enqueue_cmd23a(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) { int res = _FAIL; - struct rtw_adapter *padapter = pcmdpriv->padapter; if (!cmd_obj) goto exit; - cmd_obj->padapter = padapter; + cmd_obj->padapter = pcmdpriv->padapter; res = rtw_cmd_filter(pcmdpriv, cmd_obj); if (res == _FAIL) { @@ -352,32 +324,18 @@ u32 rtw_enqueue_cmd23a(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) goto exit; } - res = _rtw_enqueue_cmd23a(&pcmdpriv->cmd_queue, cmd_obj); + INIT_WORK(&cmd_obj->work, rtw_cmd_work); - if (res == _SUCCESS) - up(&pcmdpriv->cmd_queue_sema); + res = queue_work(pcmdpriv->wq, &cmd_obj->work); + if (!res) { + printk(KERN_ERR "%s: Call to queue_work() failed\n", __func__); + res = _FAIL; + } else + res = _SUCCESS; exit: - return res; -} -static struct cmd_obj *rtw_dequeue_cmd(struct cmd_priv *pcmdpriv) -{ - struct cmd_obj *obj; - struct rtw_queue *queue = &pcmdpriv->cmd_queue; - unsigned long irqL; - - spin_lock_irqsave(&queue->lock, irqL); - if (list_empty(&queue->queue)) - obj = NULL; - else { - obj = container_of((&queue->queue)->next, struct cmd_obj, list); - list_del_init(&obj->list); - } - - spin_unlock_irqrestore(&queue->lock, irqL); - - return obj; + return res; } void rtw_cmd_clr_isr23a(struct cmd_priv *pcmdpriv) @@ -404,116 +362,65 @@ void rtw_free_cmd_obj23a(struct cmd_obj *pcmd) kfree(pcmd); } -int rtw_cmd_thread23a(void *context) +static void rtw_cmd_work(struct work_struct *work) { - u8 ret; - struct cmd_obj *pcmd; - u8 *pcmdbuf, *prspbuf; u8 (*cmd_hdl)(struct rtw_adapter *padapter, u8* pbuf); void (*pcmd_callback)(struct rtw_adapter *dev, struct cmd_obj *pcmd); - struct rtw_adapter *padapter = (struct rtw_adapter *)context; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - - allow_signal(SIGTERM); + struct cmd_priv *pcmdpriv; + struct cmd_obj *pcmd = container_of(work, struct cmd_obj, work); + u8 *pcmdbuf; + pcmdpriv = &pcmd->padapter->cmdpriv; pcmdbuf = pcmdpriv->cmd_buf; - prspbuf = pcmdpriv->rsp_buf; - pcmdpriv->cmdthd_running = true; - up(&pcmdpriv->terminate_cmdthread_sema); - - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, - ("start r871x rtw_cmd_thread23a !!!!\n")); - - while(1) { - if (down_interruptible(&pcmdpriv->cmd_queue_sema)) - break; -_next: - if ((padapter->bDriverStopped == true) || - (padapter->bSurpriseRemoved == true)) { - DBG_8723A("%s: DriverStopped(%d) SurpriseRemoved(%d) " - "break at line %d\n", __func__, - padapter->bDriverStopped, - padapter->bSurpriseRemoved, __LINE__); - break; - } - - if (!(pcmd = rtw_dequeue_cmd(pcmdpriv))) - continue; - - if (rtw_cmd_filter(pcmdpriv, pcmd) == _FAIL) { - pcmd->res = H2C_DROPPED; - goto post_process; - } - - pcmdpriv->cmd_issued_cnt++; - - pcmd->cmdsz = ALIGN(pcmd->cmdsz, 4); + if (rtw_cmd_filter(pcmdpriv, pcmd) == _FAIL) { + pcmd->res = H2C_DROPPED; + goto post_process; + } - memcpy(pcmdbuf, pcmd->parmbuf, pcmd->cmdsz); + pcmdpriv->cmd_issued_cnt++; - if (pcmd->cmdcode < (sizeof(wlancmds)/sizeof(struct cmd_hdl))) { - cmd_hdl = wlancmds[pcmd->cmdcode].h2cfuns; + pcmd->cmdsz = ALIGN(pcmd->cmdsz, 4); - if (cmd_hdl) { - ret = cmd_hdl(pcmd->padapter, pcmdbuf); - pcmd->res = ret; - } + memcpy(pcmdbuf, pcmd->parmbuf, pcmd->cmdsz); - pcmdpriv->cmd_seq++; - } else - pcmd->res = H2C_PARAMETERS_ERROR; + if (pcmd->cmdcode < (sizeof(wlancmds)/sizeof(struct cmd_hdl))) { + cmd_hdl = wlancmds[pcmd->cmdcode].h2cfuns; - cmd_hdl = NULL; + if (cmd_hdl) + pcmd->res = cmd_hdl(pcmd->padapter, pcmdbuf); + else + pcmd->res = H2C_DROPPED; + } else + pcmd->res = H2C_PARAMETERS_ERROR; post_process: - /* call callback function for post-processed */ - if (pcmd->cmdcode < (sizeof(rtw_cmd_callback) / - sizeof(struct _cmd_callback))) { - pcmd_callback = - rtw_cmd_callback[pcmd->cmdcode].callback; - if (!pcmd_callback) { - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, - ("mlme_cmd_hdl(): pcmd_callback = " - "0x%p, cmdcode = 0x%x\n", - pcmd_callback, pcmd->cmdcode)); - rtw_free_cmd_obj23a(pcmd); - } else { - /* todo: !!! fill rsp_buf to pcmd->rsp - if (pcmd->rsp!= NULL) */ - /* need conider that free cmd_obj in - rtw_cmd_callback */ - pcmd_callback(pcmd->padapter, pcmd); - } - } else { - RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, - ("%s: cmdcode = 0x%x callback not defined!\n", - __func__, pcmd->cmdcode)); + /* call callback function for post-processed */ + if (pcmd->cmdcode < (sizeof(rtw_cmd_callback) / + sizeof(struct _cmd_callback))) { + pcmd_callback = rtw_cmd_callback[pcmd->cmdcode].callback; + if (!pcmd_callback) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, + ("mlme_cmd_hdl(): pcmd_callback = 0x%p, " + "cmdcode = 0x%x\n", + pcmd_callback, pcmd->cmdcode)); rtw_free_cmd_obj23a(pcmd); + } else { + /* todo: !!! fill rsp_buf to pcmd->rsp + if (pcmd->rsp!= NULL) */ + /* need conider that free cmd_obj in + rtw_cmd_callback */ + pcmd_callback(pcmd->padapter, pcmd); } - - if (signal_pending (current)) - flush_signals(current); - - goto _next; - - } - pcmdpriv->cmdthd_running = false; - - /* free all cmd_obj resources */ - do { - pcmd = rtw_dequeue_cmd(pcmdpriv); - if (!pcmd) - break; - + } else { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, + ("%s: cmdcode = 0x%x callback not defined!\n", + __func__, pcmd->cmdcode)); rtw_free_cmd_obj23a(pcmd); - } while(1); - - up(&pcmdpriv->terminate_cmdthread_sema); - - complete_and_exit(NULL, 0); + } } + u8 rtw_sitesurvey_cmd23a(struct rtw_adapter *padapter, struct cfg80211_ssid *ssid, int ssid_num, struct rtw_ieee80211_channel *ch, int ch_num) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 0a86923e7def..346aeca7ec9c 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1738,8 +1738,8 @@ void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc) &rtl8723a_SetBeaconRelatedRegisters; pHalFunc->Add_RateATid = &rtl8723a_add_rateatid; - pHalFunc->run_thread = &rtl8723a_start_thread; - pHalFunc->cancel_thread = &rtl8723a_stop_thread; + pHalFunc->run_thread = NULL; + pHalFunc->cancel_thread = NULL; pHalFunc->read_bbreg = &PHY_QueryBBReg; pHalFunc->write_bbreg = &PHY_SetBBReg; @@ -3187,11 +3187,3 @@ void rtl8723a_clone_haldata(struct rtw_adapter *dst_adapter, memcpy(dst_adapter->HalData, src_adapter->HalData, dst_adapter->hal_data_sz); } - -void rtl8723a_start_thread(struct rtw_adapter *padapter) -{ -} - -void rtl8723a_stop_thread(struct rtw_adapter *padapter) -{ -} diff --git a/drivers/staging/rtl8723au/include/rtw_cmd.h b/drivers/staging/rtl8723au/include/rtw_cmd.h index ba6d572b81b3..8f2b9a4ea729 100644 --- a/drivers/staging/rtl8723au/include/rtw_cmd.h +++ b/drivers/staging/rtl8723au/include/rtw_cmd.h @@ -34,6 +34,7 @@ #define CMDBUFF_ALIGN_SZ 512 struct cmd_obj { + struct work_struct work; struct rtw_adapter *padapter; u16 cmdcode; u8 res; @@ -41,16 +42,11 @@ struct cmd_obj { u32 cmdsz; u8 *rsp; u32 rspsz; - /* struct semaphore cmd_sem; */ struct list_head list; }; struct cmd_priv { - struct semaphore cmd_queue_sema; - /* struct semaphore cmd_done_sema; */ - struct semaphore terminate_cmdthread_sema; - struct rtw_queue cmd_queue; - u8 cmd_seq; + struct workqueue_struct *wq; u8 *cmd_buf; /* shall be non-paged, and 4 bytes aligned */ u8 *cmd_allocated_buf; u8 *rsp_buf; /* shall be non-paged, and 4 bytes aligned */ @@ -58,7 +54,6 @@ struct cmd_priv { u32 cmd_issued_cnt; u32 cmd_done_cnt; u32 rsp_cnt; - u8 cmdthd_running; struct rtw_adapter *padapter; }; @@ -94,7 +89,7 @@ struct c2h_evt_hdr { #define c2h_evt_exist(c2h_evt) ((c2h_evt)->id || (c2h_evt)->plen) -u32 rtw_enqueue_cmd23a(struct cmd_priv *pcmdpriv, struct cmd_obj *obj); +int rtw_enqueue_cmd23a(struct cmd_priv *pcmdpriv, struct cmd_obj *obj); void rtw_free_cmd_obj23a(struct cmd_obj *pcmd); int rtw_cmd_thread23a(void *context); diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index fd9de2a60bf7..23e0a3f01424 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -383,14 +383,7 @@ u32 rtw_start_drv_threads23a(struct rtw_adapter *padapter) RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_start_drv_threads23a\n")); - padapter->cmdThread = kthread_run(rtw_cmd_thread23a, padapter, - "RTW_CMD_THREAD"); - if (IS_ERR(padapter->cmdThread)) { - _status = _FAIL; - } else { - /* wait for cmd_thread to run */ - down(&padapter->cmdpriv.terminate_cmdthread_sema); - } + rtw_hal_start_thread23a(padapter); return _status; } @@ -399,10 +392,8 @@ void rtw_stop_drv_threads23a(struct rtw_adapter *padapter) { RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_stop_drv_threads23a\n")); - /* Below is to termindate rtw_cmd_thread23a & event_thread... */ - up(&padapter->cmdpriv.cmd_queue_sema); - if (padapter->cmdThread) - down(&padapter->cmdpriv.terminate_cmdthread_sema); + flush_workqueue(padapter->cmdpriv.wq); + rtw_hal_stop_thread23a(padapter); } -- cgit v1.2.3 From fdedd9fab0bc6999d788d658a014842e4c223a68 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:54:58 +0200 Subject: staging: rtl8723au: Remove obsolete hal thread handling code Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_intf.c | 13 ------------ drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 2 -- drivers/staging/rtl8723au/include/hal_intf.h | 4 ---- drivers/staging/rtl8723au/include/osdep_intf.h | 2 -- drivers/staging/rtl8723au/os_dep/os_intfs.c | 26 ----------------------- drivers/staging/rtl8723au/os_dep/usb_intf.c | 2 +- 6 files changed, 1 insertion(+), 48 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index 04cc53424b51..dad16bc7804b 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -262,19 +262,6 @@ void rtw_hal_add_ra_tid23a(struct rtw_adapter *padapter, u32 bitmap, u8 arg, u8 padapter->HalFunc.Add_RateATid(padapter, bitmap, arg, rssi_level); } -/* Start specifical interface thread */ -void rtw_hal_start_thread23a(struct rtw_adapter *padapter) -{ - if (padapter->HalFunc.run_thread) - padapter->HalFunc.run_thread(padapter); -} -/* Start specifical interface thread */ -void rtw_hal_stop_thread23a(struct rtw_adapter *padapter) -{ - if (padapter->HalFunc.cancel_thread) - padapter->HalFunc.cancel_thread(padapter); -} - u32 rtw_hal_read_bbreg23a(struct rtw_adapter *padapter, u32 RegAddr, u32 BitMask) { u32 data = 0; diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 346aeca7ec9c..934f18dbd941 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1738,8 +1738,6 @@ void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc) &rtl8723a_SetBeaconRelatedRegisters; pHalFunc->Add_RateATid = &rtl8723a_add_rateatid; - pHalFunc->run_thread = NULL; - pHalFunc->cancel_thread = NULL; pHalFunc->read_bbreg = &PHY_QueryBBReg; pHalFunc->write_bbreg = &PHY_SetBBReg; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 89516467f241..1df82b6853be 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -123,8 +123,6 @@ struct hal_ops { void (*Add_RateATid)(struct rtw_adapter *padapter, u32 bitmap, u8 arg, u8 rssi_level); - void (*run_thread)(struct rtw_adapter *padapter); - void (*cancel_thread)(struct rtw_adapter *padapter); u8 (*interface_ps_func)(struct rtw_adapter *padapter, enum hal_intf_ps_func efunc_id, u8 *val); @@ -274,8 +272,6 @@ void rtw_hal_free_recv_priv23a(struct rtw_adapter *padapter); void rtw_hal_update_ra_mask23a(struct sta_info *psta, u8 rssi_level); void rtw_hal_add_ra_tid23a(struct rtw_adapter *padapter, u32 bitmap, u8 arg, u8 rssi_level); void rtw_hal_clone_data(struct rtw_adapter *dst_padapter, struct rtw_adapter *src_padapter); -void rtw_hal_start_thread23a(struct rtw_adapter *padapter); -void rtw_hal_stop_thread23a(struct rtw_adapter *padapter); void rtw_hal_bcn_related_reg_setting23a(struct rtw_adapter *padapter); diff --git a/drivers/staging/rtl8723au/include/osdep_intf.h b/drivers/staging/rtl8723au/include/osdep_intf.h index b603cf532900..d3e22635e9ea 100644 --- a/drivers/staging/rtl8723au/include/osdep_intf.h +++ b/drivers/staging/rtl8723au/include/osdep_intf.h @@ -26,8 +26,6 @@ u8 rtw_init_drv_sw23a(struct rtw_adapter *padapter); u8 rtw_free_drv_sw23a(struct rtw_adapter *padapter); u8 rtw_reset_drv_sw23a(struct rtw_adapter *padapter); -u32 rtw_start_drv_threads23a(struct rtw_adapter *padapter); -void rtw_stop_drv_threads23a (struct rtw_adapter *padapter); void rtw_cancel_all_timer23a(struct rtw_adapter *padapter); int rtw_init_netdev23a_name23a(struct net_device *pnetdev, const char *ifname); diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index 23e0a3f01424..2b2df95923b5 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -377,26 +377,6 @@ struct net_device *rtw_init_netdev23a(struct rtw_adapter *old_padapter) return pnetdev; } -u32 rtw_start_drv_threads23a(struct rtw_adapter *padapter) -{ - u32 _status = _SUCCESS; - - RT_TRACE(_module_os_intfs_c_, _drv_info_, - ("+rtw_start_drv_threads23a\n")); - - rtw_hal_start_thread23a(padapter); - return _status; -} - -void rtw_stop_drv_threads23a(struct rtw_adapter *padapter) -{ - RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_stop_drv_threads23a\n")); - - flush_workqueue(padapter->cmdpriv.wq); - - rtw_hal_stop_thread23a(padapter); -} - static u8 rtw_init_default_value(struct rtw_adapter *padapter) { struct registry_priv *pregistrypriv = &padapter->registrypriv; @@ -714,12 +694,6 @@ int netdev_open23a(struct net_device *pnetdev) DBG_8723A("MAC Address = "MAC_FMT"\n", MAC_ARG(pnetdev->dev_addr)); - status = rtw_start_drv_threads23a(padapter); - if (status == _FAIL) { - DBG_8723A("Initialize driver software resource Failed!\n"); - goto netdev_open23a_error; - } - if (init_hw_mlme_ext23a(padapter) == _FAIL) { DBG_8723A("can't init mlme_ext_priv\n"); goto netdev_open23a_error; diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index 31ab34601bab..d71641dab2cc 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -333,7 +333,7 @@ static void rtw_dev_unload(struct rtw_adapter *padapter) /* s4. */ if (!padapter->pwrctrlpriv.bInternalAutoSuspend) - rtw_stop_drv_threads23a(padapter); + flush_workqueue(padapter->cmdpriv.wq); /* s5. */ if (!padapter->bSurpriseRemoved) { -- cgit v1.2.3 From f39a3d1598ec156331d84c125bfbddab6822f36f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:54:59 +0200 Subject: staging: rtl8723au: Fold _rtw_free_cmd_priv23a() into rtw_free_cmd_priv23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 14 +++++--------- drivers/staging/rtl8723au/include/cmd_osdep.h | 1 - 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 813897f82185..0032e36adb16 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -250,14 +250,6 @@ void _rtw_free_evt_priv23a (struct evt_priv *pevtpriv) ("-_rtw_free_evt_priv23a\n")); } -void _rtw_free_cmd_priv23a(struct cmd_priv *pcmdpriv) -{ - if (pcmdpriv) { - kfree(pcmdpriv->cmd_allocated_buf); - kfree(pcmdpriv->rsp_allocated_buf); - } -} - u32 rtw_init_evt_priv23a(struct evt_priv *pevtpriv) { int res; @@ -278,7 +270,11 @@ void rtw_free_cmd_priv23a(struct cmd_priv *pcmdpriv) { RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("rtw_free_cmd_priv23a\n")); - _rtw_free_cmd_priv23a(pcmdpriv); + + if (pcmdpriv) { + kfree(pcmdpriv->cmd_allocated_buf); + kfree(pcmdpriv->rsp_allocated_buf); + } } static int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) diff --git a/drivers/staging/rtl8723au/include/cmd_osdep.h b/drivers/staging/rtl8723au/include/cmd_osdep.h index 4866bee04054..6d24e425afb2 100644 --- a/drivers/staging/rtl8723au/include/cmd_osdep.h +++ b/drivers/staging/rtl8723au/include/cmd_osdep.h @@ -20,7 +20,6 @@ int _rtw_init_evt_priv23a(struct evt_priv *pevtpriv); void _rtw_free_evt_priv23a(struct evt_priv *pevtpriv); -void _rtw_free_cmd_priv23a(struct cmd_priv *pcmdpriv); int _rtw_enqueue_cmd23a(struct rtw_queue *queue, struct cmd_obj *obj); #endif -- cgit v1.2.3 From fc8ae7e548937bd95119b7bc0c1f0acb238a1535 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:00 +0200 Subject: staging: rtl8723au: Fold _rtw_free_evt_priv23a() into rtw_free_evt_priv23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 34 +++++++++------------------ drivers/staging/rtl8723au/include/cmd_osdep.h | 1 - 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 0032e36adb16..d3b2ea1cd48b 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -230,26 +230,6 @@ int _rtw_init_evt_priv23a(struct evt_priv *pevtpriv) return res; } -void _rtw_free_evt_priv23a (struct evt_priv *pevtpriv) -{ - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, - ("+_rtw_free_evt_priv23a\n")); - cancel_work_sync(&pevtpriv->c2h_wk); - while(pevtpriv->c2h_wk_alive) - msleep(10); - - while (!rtw_cbuf_empty23a(pevtpriv->c2h_queue)) { - void *c2h; - if ((c2h = rtw_cbuf_pop23a(pevtpriv->c2h_queue)) != NULL && - c2h != (void *)pevtpriv) { - kfree(c2h); - } - } - - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, - ("-_rtw_free_evt_priv23a\n")); -} - u32 rtw_init_evt_priv23a(struct evt_priv *pevtpriv) { int res; @@ -261,9 +241,17 @@ u32 rtw_init_evt_priv23a(struct evt_priv *pevtpriv) void rtw_free_evt_priv23a(struct evt_priv *pevtpriv) { - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, - ("rtw_free_evt_priv23a\n")); - _rtw_free_evt_priv23a(pevtpriv); + cancel_work_sync(&pevtpriv->c2h_wk); + while (pevtpriv->c2h_wk_alive) + msleep(10); + + while (!rtw_cbuf_empty23a(pevtpriv->c2h_queue)) { + void *c2h; + if ((c2h = rtw_cbuf_pop23a(pevtpriv->c2h_queue)) != NULL && + c2h != (void *)pevtpriv) { + kfree(c2h); + } + } } void rtw_free_cmd_priv23a(struct cmd_priv *pcmdpriv) diff --git a/drivers/staging/rtl8723au/include/cmd_osdep.h b/drivers/staging/rtl8723au/include/cmd_osdep.h index 6d24e425afb2..fd7ac4d67dc9 100644 --- a/drivers/staging/rtl8723au/include/cmd_osdep.h +++ b/drivers/staging/rtl8723au/include/cmd_osdep.h @@ -19,7 +19,6 @@ #include int _rtw_init_evt_priv23a(struct evt_priv *pevtpriv); -void _rtw_free_evt_priv23a(struct evt_priv *pevtpriv); int _rtw_enqueue_cmd23a(struct rtw_queue *queue, struct cmd_obj *obj); #endif -- cgit v1.2.3 From ab033fdb262f688f6521caed82cb8f47f6b9e98f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:01 +0200 Subject: staging: rtl8723au: Fold _rtw_init_evt_priv23a() into rtw_init_evt_priv23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 16 +++------------- drivers/staging/rtl8723au/include/cmd_osdep.h | 1 - 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index d3b2ea1cd48b..4f9988d794a9 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -215,10 +215,9 @@ exit: /* forward definition */ static void c2h_wk_callback(struct work_struct *work); -int _rtw_init_evt_priv23a(struct evt_priv *pevtpriv) -{ - int res = _SUCCESS; +u32 rtw_init_evt_priv23a(struct evt_priv *pevtpriv) +{ /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */ atomic_set(&pevtpriv->event_seq, 0); pevtpriv->evt_done_cnt = 0; @@ -227,16 +226,7 @@ int _rtw_init_evt_priv23a(struct evt_priv *pevtpriv) pevtpriv->c2h_wk_alive = false; pevtpriv->c2h_queue = rtw_cbuf_alloc23a(C2H_QUEUE_MAX_LEN + 1); - return res; -} - -u32 rtw_init_evt_priv23a(struct evt_priv *pevtpriv) -{ - int res; - - res = _rtw_init_evt_priv23a(pevtpriv); - - return res; + return _SUCCESS; } void rtw_free_evt_priv23a(struct evt_priv *pevtpriv) diff --git a/drivers/staging/rtl8723au/include/cmd_osdep.h b/drivers/staging/rtl8723au/include/cmd_osdep.h index fd7ac4d67dc9..d21382ec506e 100644 --- a/drivers/staging/rtl8723au/include/cmd_osdep.h +++ b/drivers/staging/rtl8723au/include/cmd_osdep.h @@ -18,7 +18,6 @@ #include #include -int _rtw_init_evt_priv23a(struct evt_priv *pevtpriv); int _rtw_enqueue_cmd23a(struct rtw_queue *queue, struct cmd_obj *obj); #endif -- cgit v1.2.3 From b1d49bd427f4c9b62db4df9c0de028a003cc2a10 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:02 +0200 Subject: staging: rtl8723au: Remove obsolete header file cmd_osdep.h Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 1 - drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 1 - drivers/staging/rtl8723au/include/cmd_osdep.h | 23 ----------------------- 3 files changed, 25 deletions(-) delete mode 100644 drivers/staging/rtl8723au/include/cmd_osdep.h diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 4f9988d794a9..a2b733c3802f 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c index 307963d9e7d0..be9d724c827e 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/staging/rtl8723au/include/cmd_osdep.h b/drivers/staging/rtl8723au/include/cmd_osdep.h deleted file mode 100644 index d21382ec506e..000000000000 --- a/drivers/staging/rtl8723au/include/cmd_osdep.h +++ /dev/null @@ -1,23 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek 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. - * - ******************************************************************************/ -#ifndef __CMD_OSDEP_H_ -#define __CMD_OSDEP_H_ - -#include -#include - -int _rtw_enqueue_cmd23a(struct rtw_queue *queue, struct cmd_obj *obj); - -#endif -- cgit v1.2.3 From 9e8ccf78de272a8105a59140e084a33f3dd449e6 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:03 +0200 Subject: staging: rtl8723au: Remove unused list_head from struct cmd_obj Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 2 -- drivers/staging/rtl8723au/core/rtw_mlme.c | 4 ---- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 10 ---------- drivers/staging/rtl8723au/include/rtw_cmd.h | 2 -- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 2 -- 5 files changed, 20 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index a2b733c3802f..50476fa40bd3 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -514,7 +514,6 @@ u8 rtw_createbss_cmd23a(struct rtw_adapter *padapter) goto exit; } - INIT_LIST_HEAD(&pcmd->list); pcmd->cmdcode = _CreateBss_CMD_; pcmd->parmbuf = (unsigned char *)pdev_network; pcmd->cmdsz = get_wlan_bssid_ex_sz((struct wlan_bssid_ex*)pdev_network); @@ -688,7 +687,6 @@ u8 rtw_joinbss_cmd23a(struct rtw_adapter *padapter, /* get cmdsz before endian conversion */ pcmd->cmdsz = get_wlan_bssid_ex_sz(psecnetwork); - INIT_LIST_HEAD(&pcmd->list); pcmd->cmdcode = _JoinBss_CMD_;/* GEN_CMD_CODE(_JoinBss) */ pcmd->parmbuf = (unsigned char *)psecnetwork; pcmd->rsp = NULL; diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 4d21d623070e..97f1706fd3cb 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -1908,8 +1908,6 @@ int rtw_set_auth23a(struct rtw_adapter * adapter, pcmd->rsp = NULL; pcmd->rspsz = 0; - INIT_LIST_HEAD(&pcmd->list); - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_, ("after enqueue set_auth_cmd, auth_mode=%x\n", psecuritypriv->dot11AuthAlgrthm)); @@ -2009,8 +2007,6 @@ int rtw_set_key23a(struct rtw_adapter *adapter, pcmd->rsp = NULL; pcmd->rspsz = 0; - INIT_LIST_HEAD(&pcmd->list); - /* sema_init(&pcmd->cmd_sem, 0); */ res = rtw_enqueue_cmd23a(pcmdpriv, pcmd); diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 00a7a63f960c..ff558808a456 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -5097,8 +5097,6 @@ void report_survey_event23a(struct rtw_adapter *padapter, struct recv_frame *pre return; } - INIT_LIST_HEAD(&pcmd_obj->list); - pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT); pcmd_obj->cmdsz = cmdsz; pcmd_obj->parmbuf = pevtcmd; @@ -5150,8 +5148,6 @@ void report_surveydone_event23a(struct rtw_adapter *padapter) return; } - INIT_LIST_HEAD(&pcmd_obj->list); - pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT); pcmd_obj->cmdsz = cmdsz; pcmd_obj->parmbuf = pevtcmd; @@ -5197,8 +5193,6 @@ void report_join_res23a(struct rtw_adapter *padapter, int res) return; } - INIT_LIST_HEAD(&pcmd_obj->list); - pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT); pcmd_obj->cmdsz = cmdsz; pcmd_obj->parmbuf = pevtcmd; @@ -5249,8 +5243,6 @@ void report_del_sta_event23a(struct rtw_adapter *padapter, unsigned char* MacAdd return; } - INIT_LIST_HEAD(&pcmd_obj->list); - pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT); pcmd_obj->cmdsz = cmdsz; pcmd_obj->parmbuf = pevtcmd; @@ -5305,8 +5297,6 @@ void report_add_sta_event23a(struct rtw_adapter *padapter, unsigned char* MacAdd return; } - INIT_LIST_HEAD(&pcmd_obj->list); - pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT); pcmd_obj->cmdsz = cmdsz; pcmd_obj->parmbuf = pevtcmd; diff --git a/drivers/staging/rtl8723au/include/rtw_cmd.h b/drivers/staging/rtl8723au/include/rtw_cmd.h index 8f2b9a4ea729..85a6fcaef420 100644 --- a/drivers/staging/rtl8723au/include/rtw_cmd.h +++ b/drivers/staging/rtl8723au/include/rtw_cmd.h @@ -42,7 +42,6 @@ struct cmd_obj { u32 cmdsz; u8 *rsp; u32 rspsz; - struct list_head list; }; struct cmd_priv { @@ -72,7 +71,6 @@ struct evt_priv { #define init_h2fwcmd_w_parm_no_rsp(pcmd, pparm, code) \ do {\ - INIT_LIST_HEAD(&pcmd->list);\ pcmd->cmdcode = code;\ pcmd->parmbuf = (u8 *)(pparm);\ pcmd->cmdsz = sizeof (*pparm);\ diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 0866ab59a399..221d15205b1e 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -522,8 +522,6 @@ static int set_group_key(struct rtw_adapter *padapter, u8 *key, u8 alg, pcmd->rsp = NULL; pcmd->rspsz = 0; - INIT_LIST_HEAD(&pcmd->list); - res = rtw_enqueue_cmd23a(pcmdpriv, pcmd); exit: -- cgit v1.2.3 From cd190293d632cfccdd07e2a31bdbcf53041615bc Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:04 +0200 Subject: staging: rtl8723au: Remove unused #define FREE_CMDOBJ_SZ Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtw_cmd.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8723au/include/rtw_cmd.h b/drivers/staging/rtl8723au/include/rtw_cmd.h index 85a6fcaef420..b7b967fd441a 100644 --- a/drivers/staging/rtl8723au/include/rtw_cmd.h +++ b/drivers/staging/rtl8723au/include/rtw_cmd.h @@ -25,8 +25,6 @@ #include /* */ -#define FREE_CMDOBJ_SZ 128 - #define MAX_CMDSZ 1024 #define MAX_RSPSZ 512 #define MAX_EVTSZ 1024 -- cgit v1.2.3 From b25b7b32ecfd8eec83f3dcd6c0d0b9362964dd43 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:05 +0200 Subject: staging: rtl8723au: Make cmd handlers take a const u8 * as their data argument Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 4 +-- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 36 +++++++++---------- drivers/staging/rtl8723au/include/rtw_cmd.h | 2 +- drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 44 ++++++++++++------------ 4 files changed, 43 insertions(+), 43 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 50476fa40bd3..b9e38dc6a26c 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -337,7 +337,7 @@ void rtw_free_cmd_obj23a(struct cmd_obj *pcmd) static void rtw_cmd_work(struct work_struct *work) { - u8 (*cmd_hdl)(struct rtw_adapter *padapter, u8* pbuf); + u8 (*cmd_hdl)(struct rtw_adapter *padapter, const u8 *pbuf); void (*pcmd_callback)(struct rtw_adapter *dev, struct cmd_obj *pcmd); struct cmd_priv *pcmdpriv; struct cmd_obj *pcmd = container_of(work, struct cmd_obj, work); @@ -1444,7 +1444,7 @@ static void c2h_wk_callback(struct work_struct *work) evtpriv->c2h_wk_alive = false; } -u8 rtw_drvextra_cmd_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf) +u8 rtw_drvextra_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { struct drvextra_cmd_parm *pdrvextra_cmd; diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index ff558808a456..4ac1821bd9a4 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -5834,12 +5834,12 @@ void init_mlme_ext_timer23a(struct rtw_adapter *padapter) (unsigned long)padapter); } -u8 NULL_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) +u8 NULL_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { return H2C_SUCCESS; } -u8 setopmode_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) +u8 setopmode_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { u8 type; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -5864,7 +5864,7 @@ u8 setopmode_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) return H2C_SUCCESS; } -u8 createbss_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) +u8 createbss_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -5920,7 +5920,7 @@ u8 createbss_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) return H2C_SUCCESS; } -u8 join_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) +u8 join_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { struct ndis_802_11_var_ies * pIE; struct registry_priv *pregpriv = &padapter->registrypriv; @@ -6043,7 +6043,7 @@ u8 join_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) return H2C_SUCCESS; } -u8 disconnect_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf) +u8 disconnect_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { struct disconnect_parm *param = (struct disconnect_parm *)pbuf; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -6154,7 +6154,7 @@ static int rtw_scan_ch_decision(struct rtw_adapter *padapter, struct rtw_ieee802 return j; } -u8 sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) +u8 sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct sitesurvey_parm *pparm = (struct sitesurvey_parm *)pbuf; @@ -6236,7 +6236,7 @@ u8 sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) return H2C_SUCCESS; } -u8 setauth_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf) +u8 setauth_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { struct setauth_parm *pparm = (struct setauth_parm *)pbuf; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -6250,7 +6250,7 @@ u8 setauth_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf) return H2C_SUCCESS; } -u8 setkey_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) +u8 setkey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { unsigned short ctrl; struct setkey_parm *pparm = (struct setkey_parm *)pbuf; @@ -6275,7 +6275,7 @@ u8 setkey_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) return H2C_SUCCESS; } -u8 set_stakey_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) +u8 set_stakey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { u16 ctrl = 0; u8 cam_id;/* cam_entry */ @@ -6362,7 +6362,7 @@ u8 set_stakey_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) return H2C_SUCCESS; } -u8 add_ba_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf) +u8 add_ba_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { struct addBaReq_parm *pparm = (struct addBaReq_parm *)pbuf; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -6432,7 +6432,7 @@ exit: return res; } -u8 mlme_evt_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf) +u8 mlme_evt_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { u8 evt_code, evt_seq; u16 evt_sz; @@ -6475,7 +6475,7 @@ _abort_event_: return H2C_SUCCESS; } -u8 h2c_msg_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf) +u8 h2c_msg_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { if (!pbuf) return H2C_PARAMETERS_ERROR; @@ -6483,7 +6483,7 @@ u8 h2c_msg_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf) return H2C_SUCCESS; } -u8 tx_beacon_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf) +u8 tx_beacon_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { if (send_beacon23a(padapter) == _FAIL) { @@ -6542,7 +6542,7 @@ u8 tx_beacon_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf) return H2C_SUCCESS; } -u8 set_ch_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) +u8 set_ch_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { struct set_ch_parm *set_ch_parm; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -6565,7 +6565,7 @@ u8 set_ch_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) return H2C_SUCCESS; } -u8 set_chplan_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf) +u8 set_chplan_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { struct SetChannelPlan_param *setChannelPlan_param; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -6581,7 +6581,7 @@ u8 set_chplan_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf) return H2C_SUCCESS; } -u8 led_blink_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf) +u8 led_blink_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { struct LedBlink_param *ledBlink_param; @@ -6593,7 +6593,7 @@ u8 led_blink_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf) return H2C_SUCCESS; } -u8 set_csa_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf) +u8 set_csa_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { return H2C_REJECTED; } @@ -6611,7 +6611,7 @@ u8 set_csa_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf) /* TDLS_CKALV_PH1 : check alive timer phase1 */ /* TDLS_CKALV_PH2 : check alive timer phase2 */ /* TDLS_FREE_STA : free tdls sta */ -u8 tdls_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf) +u8 tdls_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { return H2C_REJECTED; } diff --git a/drivers/staging/rtl8723au/include/rtw_cmd.h b/drivers/staging/rtl8723au/include/rtw_cmd.h index b7b967fd441a..3ecb971c6e39 100644 --- a/drivers/staging/rtl8723au/include/rtw_cmd.h +++ b/drivers/staging/rtl8723au/include/rtw_cmd.h @@ -719,7 +719,7 @@ u8 rtw_tdls_cmd(struct rtw_adapter*padapter, u8 *addr, u8 option); u8 rtw_c2h_wk_cmd23a(struct rtw_adapter *padapter, u8 *c2h_evt); -u8 rtw_drvextra_cmd_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf); +u8 rtw_drvextra_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); void rtw_survey_cmd_callback23a(struct rtw_adapter *padapter, struct cmd_obj *pcmd); void rtw_disassoc_cmd23a_callback(struct rtw_adapter *padapter, struct cmd_obj *pcmd); diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index cbea64938c54..8a287c231034 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -639,7 +639,7 @@ void correct_TSF23a(struct rtw_adapter *padapter, struct mlme_ext_priv *pmlmeext struct cmd_hdl { uint parmsize; - u8 (*h2cfuns)(struct rtw_adapter *padapter, u8 *pbuf); + u8 (*h2cfuns)(struct rtw_adapter *padapter, const u8 *pbuf); }; @@ -651,27 +651,27 @@ u8 read_rfreg_hdl(struct rtw_adapter *padapter, u8 *pbuf); u8 write_rfreg_hdl(struct rtw_adapter *padapter, u8 *pbuf); -u8 NULL_hdl23a(struct rtw_adapter *padapter, u8 *pbuf); -u8 join_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf); -u8 disconnect_hdl23a(struct rtw_adapter *padapter, u8 *pbuf); -u8 createbss_hdl23a(struct rtw_adapter *padapter, u8 *pbuf); -u8 setopmode_hdl23a(struct rtw_adapter *padapter, u8 *pbuf); -u8 sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf); -u8 setauth_hdl23a(struct rtw_adapter *padapter, u8 *pbuf); -u8 setkey_hdl23a(struct rtw_adapter *padapter, u8 *pbuf); -u8 set_stakey_hdl23a(struct rtw_adapter *padapter, u8 *pbuf); -u8 set_assocsta_hdl(struct rtw_adapter *padapter, u8 *pbuf); -u8 del_assocsta_hdl(struct rtw_adapter *padapter, u8 *pbuf); -u8 add_ba_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf); - -u8 mlme_evt_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf); -u8 h2c_msg_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf); -u8 tx_beacon_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf); -u8 set_ch_hdl23a(struct rtw_adapter *padapter, u8 *pbuf); -u8 set_chplan_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf); -u8 led_blink_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf); -u8 set_csa_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf); /* Kurt: Handling DFS channel switch announcement ie. */ -u8 tdls_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf); +u8 NULL_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +u8 join_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +u8 disconnect_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +u8 createbss_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +u8 setopmode_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +u8 sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +u8 setauth_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +u8 setkey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +u8 set_stakey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +u8 set_assocsta_hdl(struct rtw_adapter *padapter, const u8 *pbuf); +u8 del_assocsta_hdl(struct rtw_adapter *padapter, const u8 *pbuf); +u8 add_ba_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); + +u8 mlme_evt_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +u8 h2c_msg_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +u8 tx_beacon_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +u8 set_ch_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +u8 set_chplan_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +u8 led_blink_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +u8 set_csa_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); /* Kurt: Handling DFS channel switch announcement ie. */ +u8 tdls_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); #define GEN_DRV_CMD_HANDLER(size, cmd) {size, &cmd ## _hdl23a}, #define GEN_MLME_EXT_HANDLER(size, cmd) {size, cmd}, -- cgit v1.2.3 From 0348dc74f6689825c16db40fbe0ce6ad2da5bab9 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:06 +0200 Subject: staging: rtl8723au: Preserve const attribute of cmd handler argument Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 8 ++++-- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 33 +++++++++++++----------- drivers/staging/rtl8723au/core/rtw_sta_mgt.c | 4 +-- drivers/staging/rtl8723au/hal/hal_com.c | 2 +- drivers/staging/rtl8723au/include/hal_com.h | 2 +- drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 5 ++-- drivers/staging/rtl8723au/include/sta_info.h | 4 +-- 7 files changed, 33 insertions(+), 25 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index b9e38dc6a26c..508576ef1eb2 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -1446,7 +1446,7 @@ static void c2h_wk_callback(struct work_struct *work) u8 rtw_drvextra_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { - struct drvextra_cmd_parm *pdrvextra_cmd; + const struct drvextra_cmd_parm *pdrvextra_cmd; if (!pbuf) return H2C_PARAMETERS_ERROR; @@ -1482,7 +1482,11 @@ u8 rtw_drvextra_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) if (pdrvextra_cmd->pbuf && (pdrvextra_cmd->type_size > 0)) { kfree(pdrvextra_cmd->pbuf); - pdrvextra_cmd->pbuf = NULL; + /* + * No need to set pdrvextra_cmd->pbuf = NULL as we were + * operating on a copy of the original pcmd->parmbuf + * created in rtw_cmd_work(). + */ } return H2C_SUCCESS; diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 4ac1821bd9a4..303b76f9e196 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -3959,7 +3959,8 @@ void issue_action_spct_ch_switch23a(struct rtw_adapter *padapter, dump_mgntframe23a(padapter, pmgntframe); } -void issue_action_BA23a(struct rtw_adapter *padapter, unsigned char *raddr, +void issue_action_BA23a(struct rtw_adapter *padapter, + const unsigned char *raddr, unsigned char action, unsigned short status) { u8 category = WLAN_CATEGORY_BACK; @@ -5844,7 +5845,7 @@ u8 setopmode_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) u8 type; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct setopmode_parm *psetop = (struct setopmode_parm *)pbuf; + const struct setopmode_parm *psetop = (struct setopmode_parm *)pbuf; if (psetop->mode == Ndis802_11APMode) { pmlmeinfo->state = WIFI_FW_AP_STATE; @@ -5869,7 +5870,7 @@ u8 createbss_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; - struct wlan_bssid_ex *pparm = (struct wlan_bssid_ex *)pbuf; + const struct wlan_bssid_ex *pparm = (struct wlan_bssid_ex *)pbuf; /* u32 initialgain; */ if (pparm->InfrastructureMode == Ndis802_11APMode) { @@ -5927,7 +5928,7 @@ u8 join_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; - struct wlan_bssid_ex *pparm = (struct wlan_bssid_ex *)pbuf; + const struct wlan_bssid_ex *pparm = (struct wlan_bssid_ex *)pbuf; struct HT_info_element *pht_info; u32 i; /* u32 initialgain; */ @@ -6045,7 +6046,7 @@ u8 join_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) u8 disconnect_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { - struct disconnect_parm *param = (struct disconnect_parm *)pbuf; + const struct disconnect_parm *param = (struct disconnect_parm *)pbuf; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; @@ -6089,8 +6090,10 @@ u8 disconnect_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) return H2C_SUCCESS; } -static int rtw_scan_ch_decision(struct rtw_adapter *padapter, struct rtw_ieee80211_channel *out, - u32 out_num, struct rtw_ieee80211_channel *in, u32 in_num) +static int +rtw_scan_ch_decision(struct rtw_adapter *padapter, + struct rtw_ieee80211_channel *out, u32 out_num, + const struct rtw_ieee80211_channel *in, u32 in_num) { int i, j; int scan_ch_num = 0; @@ -6157,7 +6160,7 @@ static int rtw_scan_ch_decision(struct rtw_adapter *padapter, struct rtw_ieee802 u8 sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct sitesurvey_parm *pparm = (struct sitesurvey_parm *)pbuf; + const struct sitesurvey_parm *pparm = (struct sitesurvey_parm *)pbuf; u8 bdelayscan = false; u32 initialgain; u32 i; @@ -6238,7 +6241,7 @@ u8 sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) u8 setauth_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { - struct setauth_parm *pparm = (struct setauth_parm *)pbuf; + const struct setauth_parm *pparm = (struct setauth_parm *)pbuf; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -6253,7 +6256,7 @@ u8 setauth_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) u8 setkey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { unsigned short ctrl; - struct setkey_parm *pparm = (struct setkey_parm *)pbuf; + const struct setkey_parm *pparm = (struct setkey_parm *)pbuf; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; unsigned char null_sta[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; @@ -6281,7 +6284,7 @@ u8 set_stakey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) u8 cam_id;/* cam_entry */ struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct set_stakey_parm *pparm = (struct set_stakey_parm *)pbuf; + const struct set_stakey_parm *pparm = (struct set_stakey_parm *)pbuf; /* cam_entry: */ /* 0~3 for default key */ @@ -6364,7 +6367,7 @@ u8 set_stakey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) u8 add_ba_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { - struct addBaReq_parm *pparm = (struct addBaReq_parm *)pbuf; + const struct addBaReq_parm *pparm = (struct addBaReq_parm *)pbuf; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -6436,7 +6439,7 @@ u8 mlme_evt_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { u8 evt_code, evt_seq; u16 evt_sz; - uint *peventbuf; + const uint *peventbuf; void (*event_callback)(struct rtw_adapter *dev, u8 *pbuf); struct evt_priv *pevt_priv = &padapter->evtpriv; @@ -6544,7 +6547,7 @@ u8 tx_beacon_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) u8 set_ch_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { - struct set_ch_parm *set_ch_parm; + const struct set_ch_parm *set_ch_parm; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; if (!pbuf) @@ -6567,7 +6570,7 @@ u8 set_ch_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) u8 set_chplan_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { - struct SetChannelPlan_param *setChannelPlan_param; + const struct SetChannelPlan_param *setChannelPlan_param; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; if (!pbuf) diff --git a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c index 451b58f47287..a64c350591c2 100644 --- a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c @@ -405,12 +405,12 @@ void rtw_free_all_stainfo23a(struct rtw_adapter *padapter) } /* any station allocated can be searched by hash list */ -struct sta_info *rtw_get_stainfo23a(struct sta_priv *pstapriv, u8 *hwaddr) +struct sta_info *rtw_get_stainfo23a(struct sta_priv *pstapriv, const u8 *hwaddr) { struct list_head *plist, *phead; struct sta_info *psta = NULL; u32 index; - u8 *addr; + const u8 *addr; u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; if (hwaddr == NULL) diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index d1701a35bc90..8e08977e929b 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -686,7 +686,7 @@ void rtl8723a_cam_invalid_all(struct rtw_adapter *padapter) } void rtl8723a_cam_write(struct rtw_adapter *padapter, - u8 entry, u16 ctrl, u8 *mac, u8 *key) + u8 entry, u16 ctrl, const u8 *mac, const u8 *key) { u32 cmd; unsigned int i, val, addr; diff --git a/drivers/staging/rtl8723au/include/hal_com.h b/drivers/staging/rtl8723au/include/hal_com.h index 5f050a346a8a..4a161e26c8dc 100644 --- a/drivers/staging/rtl8723au/include/hal_com.h +++ b/drivers/staging/rtl8723au/include/hal_com.h @@ -184,7 +184,7 @@ void rtl8723a_set_sec_cfg(struct rtw_adapter *padapter, u8 sec); void rtl8723a_cam_empty_entry(struct rtw_adapter *padapter, u8 ucIndex); void rtl8723a_cam_invalid_all(struct rtw_adapter *padapter); void rtl8723a_cam_write(struct rtw_adapter *padapter, - u8 entry, u16 ctrl, u8 *mac, u8 *key); + u8 entry, u16 ctrl, const u8 *mac, const u8 *key); void rtl8723a_fifo_cleanup(struct rtw_adapter *padapter); void rtl8723a_set_apfm_on_mac(struct rtw_adapter *padapter, u8 val); void rtl8723a_bcn_valid(struct rtw_adapter *padapter); diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 8a287c231034..26d360178eac 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -605,8 +605,9 @@ int issue_deauth23a_ex23a(struct rtw_adapter *padapter, u8 *da, unsigned short r int try_cnt, int wait_ms); void issue_action_spct_ch_switch23a(struct rtw_adapter *padapter, u8 *ra, u8 new_ch, u8 ch_offset); -void issue_action_BA23a(struct rtw_adapter *padapter, unsigned char *raddr, - unsigned char action, unsigned short status); +void issue_action_BA23a(struct rtw_adapter *padapter, + const unsigned char *raddr, + unsigned char action, unsigned short status); unsigned int send_delba23a(struct rtw_adapter *padapter, u8 initiator, u8 *addr); unsigned int send_beacon23a(struct rtw_adapter *padapter); diff --git a/drivers/staging/rtl8723au/include/sta_info.h b/drivers/staging/rtl8723au/include/sta_info.h index ffbc9e3f2156..c02947f6bd9b 100644 --- a/drivers/staging/rtl8723au/include/sta_info.h +++ b/drivers/staging/rtl8723au/include/sta_info.h @@ -349,7 +349,7 @@ struct sta_priv { struct wlan_acl_pool acl_list; }; -static inline u32 wifi_mac_hash(u8 *mac) +static inline u32 wifi_mac_hash(const u8 *mac) { u32 x; @@ -377,7 +377,7 @@ struct sta_info *rtw_get_stainfo23a_by_offset23a(struct sta_priv *stapriv, struct sta_info *rtw_alloc_stainfo23a(struct sta_priv *pstapriv, u8 *hwaddr); u32 rtw_free_stainfo23a(struct rtw_adapter *padapter, struct sta_info *psta); void rtw_free_all_stainfo23a(struct rtw_adapter *padapter); -struct sta_info *rtw_get_stainfo23a(struct sta_priv *pstapriv, u8 *hwaddr); +struct sta_info *rtw_get_stainfo23a(struct sta_priv *pstapriv, const u8 *hwaddr); u32 rtw_init_bcmc_stainfo23a(struct rtw_adapter *padapter); struct sta_info *rtw_get_bcmc_stainfo23a(struct rtw_adapter *padapter); u8 rtw_access_ctrl23a(struct rtw_adapter *padapter, u8 *mac_addr); -- cgit v1.2.3 From ea4190b163fb4ff918d64f21e000cab038e9f41e Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:07 +0200 Subject: staging: rtl8723au: rtw_joinbss_cmd23a(): Remove unnecessary typecast and remove use-once variable t_len. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 508576ef1eb2..9e0a5ea9ba75 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -530,10 +530,9 @@ exit: } u8 rtw_joinbss_cmd23a(struct rtw_adapter *padapter, - struct wlan_network * pnetwork) + struct wlan_network *pnetwork) { u8 *auth, res = _SUCCESS; - uint t_len = 0; struct wlan_bssid_ex *psecnetwork; struct cmd_obj *pcmd; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; @@ -567,8 +566,6 @@ u8 rtw_joinbss_cmd23a(struct rtw_adapter *padapter, "fail!!!\n")); goto exit; } - /* for IEs is fix buf size */ - t_len = sizeof(struct wlan_bssid_ex); /* for hidden ap to set fw_state here */ if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE)) { @@ -586,7 +583,7 @@ u8 rtw_joinbss_cmd23a(struct rtw_adapter *padapter, } } - psecnetwork = (struct wlan_bssid_ex *)&psecuritypriv->sec_bss; + psecnetwork = &psecuritypriv->sec_bss; if (!psecnetwork) { if (pcmd) kfree(pcmd); @@ -599,7 +596,7 @@ u8 rtw_joinbss_cmd23a(struct rtw_adapter *padapter, goto exit; } - memset(psecnetwork, 0, t_len); + memset(psecnetwork, 0, sizeof(struct wlan_bssid_ex)); memcpy(psecnetwork, &pnetwork->network, get_wlan_bssid_ex_sz(&pnetwork->network)); -- cgit v1.2.3 From aab26454e91ec5cc69c9eb32d824ef69d127fdc9 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:08 +0200 Subject: staging: rtl8723au: rtw_createbss_cmd23a(): Remove unnecessary typecast Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 9e0a5ea9ba75..8ce4148a3a49 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -516,7 +516,7 @@ u8 rtw_createbss_cmd23a(struct rtw_adapter *padapter) pcmd->cmdcode = _CreateBss_CMD_; pcmd->parmbuf = (unsigned char *)pdev_network; - pcmd->cmdsz = get_wlan_bssid_ex_sz((struct wlan_bssid_ex*)pdev_network); + pcmd->cmdsz = get_wlan_bssid_ex_sz(pdev_network); pcmd->rsp = NULL; pcmd->rspsz = 0; -- cgit v1.2.3 From 520179558a83335be07357ae9d2969b1736ca63d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:09 +0200 Subject: staging: rtl8723au: Remove unnecessary typecasts of struct wlan_bssid_ex objects Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 10 +++++----- drivers/staging/rtl8723au/core/rtw_mlme.c | 2 +- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 77ee182f3e4f..7459825c2abe 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -361,7 +361,7 @@ void add_RATid23a(struct rtw_adapter *padapter, struct sta_info *psta, u8 rssi_l unsigned int tx_ra_bitmap = 0; struct ht_priv *psta_ht = NULL; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wlan_bssid_ex *pcur_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; + struct wlan_bssid_ex *pcur_network = &pmlmepriv->cur_network.network; if (psta) psta_ht = &psta->htpriv; @@ -459,7 +459,7 @@ static void update_bmc_sta(struct rtw_adapter *padapter) int i, supportRateNum = 0; unsigned int tx_ra_bitmap = 0; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wlan_bssid_ex *pcur_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; + struct wlan_bssid_ex *pcur_network = &pmlmepriv->cur_network.network; struct sta_info *psta = rtw_get_bcmc_stainfo23a(padapter); if (psta) @@ -652,7 +652,7 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) struct registry_priv *pregpriv = &padapter->registrypriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv* psecuritypriv = &padapter->securitypriv; - struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; + struct wlan_bssid_ex *pnetwork = &pmlmepriv->cur_network.network; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *pnetwork_mlmeext = &pmlmeinfo->network; @@ -766,7 +766,7 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) update_wireless_mode23a(padapter); /* udpate capability after cur_wireless_mode updated */ - update_capinfo23a(padapter, rtw_get_capability23a((struct wlan_bssid_ex *)pnetwork)); + update_capinfo23a(padapter, rtw_get_capability23a(pnetwork)); /* let pnetwork_mlmeext == pnetwork_mlme. */ memcpy(pnetwork_mlmeext, pnetwork, pnetwork->Length); @@ -1047,7 +1047,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, HT_info_handler23a(padapter, (struct ndis_802_11_var_ies *)pHT_info_ie); } - pbss_network->Length = get_wlan_bssid_ex_sz((struct wlan_bssid_ex *)pbss_network); + pbss_network->Length = get_wlan_bssid_ex_sz(pbss_network); /* issue beacon to start bss network */ start_bss_network(padapter, (u8*)pbss_network); diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 97f1706fd3cb..b205d0f2e8f4 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -2249,7 +2249,7 @@ void rtw_update_registrypriv_dev_network23a(struct rtw_adapter* adapter) pdev_network->IELength = sz; pdev_network->Length = - get_wlan_bssid_ex_sz((struct wlan_bssid_ex *)pdev_network); + get_wlan_bssid_ex_sz(pdev_network); /* notes: translate IELength & Length after assign the Length to cmdsz in createbss_cmd(); */ diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index f2d77123cbc0..a971c3d67a69 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -1007,7 +1007,7 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, } /* check encryption info */ - val16 = rtw_get_capability23a((struct wlan_bssid_ex *)bssid); + val16 = rtw_get_capability23a(bssid); if (val16 & BIT(4)) bssid->Privacy = 1; @@ -1141,7 +1141,7 @@ unsigned int is_ap_in_tkip23a(struct rtw_adapter *padapter) struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; - if (rtw_get_capability23a((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY) { + if (rtw_get_capability23a(cur_network) & WLAN_CAPABILITY_PRIVACY) { for (i = sizeof(struct ndis_802_11_fixed_ies); i < pmlmeinfo->network.IELength;) { pIE = (struct ndis_802_11_var_ies *)(pmlmeinfo->network.IEs + i); @@ -1172,7 +1172,7 @@ unsigned int should_forbid_n_rate23a(struct rtw_adapter * padapter) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_bssid_ex *cur_network = &pmlmepriv->cur_network.network; - if (rtw_get_capability23a((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY) { + if (rtw_get_capability23a(cur_network) & WLAN_CAPABILITY_PRIVACY) { for (i = sizeof(struct ndis_802_11_fixed_ies); i < cur_network->IELength;) { pIE = (struct ndis_802_11_var_ies *)(cur_network->IEs + i); @@ -1207,7 +1207,7 @@ unsigned int is_ap_in_wep23a(struct rtw_adapter *padapter) struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; - if (rtw_get_capability23a((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY) { + if (rtw_get_capability23a(cur_network) & WLAN_CAPABILITY_PRIVACY) { for (i = sizeof(struct ndis_802_11_fixed_ies); i < pmlmeinfo->network.IELength;) { pIE = (struct ndis_802_11_var_ies *)(pmlmeinfo->network.IEs + i); -- cgit v1.2.3 From 7d620c81fa113d0a61d07d29cdc6fabeb7ef0eb5 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:10 +0200 Subject: staging: rtl8723au: rtw_set_802_11_infrastructure_mode23a(): Make it readable Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ioctl_set.c | 78 +++++++++++++------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c index fe4926a4ced6..b03266bc1f3c 100644 --- a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c @@ -280,27 +280,26 @@ exit: } u8 rtw_set_802_11_infrastructure_mode23a(struct rtw_adapter* padapter, - enum ndis_802_11_net_infra networktype) + enum ndis_802_11_net_infra networktype) { - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wlan_network *cur_network = &pmlmepriv->cur_network; - enum ndis_802_11_net_infra* pold_state = &cur_network->network.InfrastructureMode; - + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct wlan_network *cur_network = &pmlmepriv->cur_network; + enum ndis_802_11_net_infra* pold_state; + pold_state = &cur_network->network.InfrastructureMode; RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_notice_, - ("+rtw_set_802_11_infrastructure_mode23a: old =%d new =%d fw_state = 0x%08x\n", + ("+rtw_set_802_11_infrastructure_mode23a: old =%d new =%d " + "fw_state = 0x%08x\n", *pold_state, networktype, get_fwstate(pmlmepriv))); - if (*pold_state != networktype) - { + if (*pold_state != networktype) { spin_lock_bh(&pmlmepriv->lock); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, (" change mode!")); - /* DBG_8723A("change mode, old_mode =%d, new_mode =%d, fw_state = 0x%x\n", *pold_state, networktype, get_fwstate(pmlmepriv)); */ + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, + (" change mode!")); - if (*pold_state == Ndis802_11APMode) - { + if (*pold_state == Ndis802_11APMode) { /* change to other mode from Ndis802_11APMode */ cur_network->join_res = -1; @@ -309,18 +308,21 @@ u8 rtw_set_802_11_infrastructure_mode23a(struct rtw_adapter* padapter, #endif } - if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) ||(*pold_state == Ndis802_11IBSS)) + if (check_fwstate(pmlmepriv, _FW_LINKED) || + *pold_state == Ndis802_11IBSS) rtw_disassoc_cmd23a(padapter, 0, true); - if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) + if (check_fwstate(pmlmepriv, _FW_LINKED) || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) rtw_free_assoc_resources23a(padapter, 1); - if ((*pold_state == Ndis802_11Infrastructure) ||(*pold_state == Ndis802_11IBSS)) - { - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { - rtw_indicate_disconnect23a(padapter); /* will clr Linked_state; before this function, we must have chked whether issue dis-assoc_cmd or not */ + if (*pold_state == Ndis802_11Infrastructure || + *pold_state == Ndis802_11IBSS) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + /* will clr Linked_state; before this function, + we must have chked whether issue + dis-assoc_cmd or not */ + rtw_indicate_disconnect23a(padapter); } } @@ -330,38 +332,36 @@ u8 rtw_set_802_11_infrastructure_mode23a(struct rtw_adapter* padapter, switch (networktype) { - case Ndis802_11IBSS: - set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); - break; + case Ndis802_11IBSS: + set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); + break; - case Ndis802_11Infrastructure: - set_fwstate(pmlmepriv, WIFI_STATION_STATE); - break; + case Ndis802_11Infrastructure: + set_fwstate(pmlmepriv, WIFI_STATION_STATE); + break; - case Ndis802_11APMode: - set_fwstate(pmlmepriv, WIFI_AP_STATE); + case Ndis802_11APMode: + set_fwstate(pmlmepriv, WIFI_AP_STATE); #ifdef CONFIG_8723AU_AP_MODE - start_ap_mode23a(padapter); - /* rtw_indicate_connect23a(padapter); */ + start_ap_mode23a(padapter); + /* rtw_indicate_connect23a(padapter); */ #endif + break; - break; - - case Ndis802_11AutoUnknown: - case Ndis802_11InfrastructureMax: - break; + case Ndis802_11AutoUnknown: + case Ndis802_11InfrastructureMax: + break; } /* SecClearAllKeys(adapter); */ - /* RT_TRACE(COMP_OID_SET, DBG_LOUD, ("set_infrastructure: fw_state:%x after changing mode\n", */ - /* get_fwstate(pmlmepriv))); */ + /* RT_TRACE(COMP_OID_SET, DBG_LOUD, + ("set_infrastructure: fw_state:%x after changing mode\n", */ + /* get_fwstate(pmlmepriv))); */ spin_unlock_bh(&pmlmepriv->lock); } - - return true; } -- cgit v1.2.3 From 4d435952bd8de317b9b1ef46de0c34ed21ad759f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:11 +0200 Subject: staging: rtl8723au: Make some of the bt-coexist code less unreadable Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 274 +++++++++++++-------- 1 file changed, 175 insertions(+), 99 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index 69041efe5c36..0d1452757a09 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -5762,13 +5762,17 @@ static void btdm_1AntCoexProcessForWifiConnect(struct rtw_adapter *padapter) pBtdm8723 = &pBtCoex->btdm1Ant; BtState = pBtCoex->c2hBtInfo; - RTPRINT(FBT, BT_TRACE, ("[BTCoex], WiFi is %s\n", BTDM_IsWifiBusy(padapter)?"Busy":"IDLE")); - RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT is %s\n", BtStateString[BtState])); + RTPRINT(FBT, BT_TRACE, ("[BTCoex], WiFi is %s\n", + BTDM_IsWifiBusy(padapter)?"Busy":"IDLE")); + RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT is %s\n", + BtStateString[BtState])); padapter->pwrctrlpriv.btcoex_rfon = false; - if ((!BTDM_IsWifiBusy(padapter)) && (!check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE)) && - ((BtState == BT_INFO_STATE_NO_CONNECTION) || (BtState == BT_INFO_STATE_CONNECT_IDLE))) { + if (!BTDM_IsWifiBusy(padapter) && + !check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) && + (BtState == BT_INFO_STATE_NO_CONNECTION || + BtState == BT_INFO_STATE_CONNECT_IDLE)) { switch (BtState) { case BT_INFO_STATE_NO_CONNECTION: _btdm_1AntSetPSTDMA(padapter, true, 2, 0x26, false, 9); @@ -5787,20 +5791,25 @@ static void btdm_1AntCoexProcessForWifiConnect(struct rtw_adapter *padapter) rtw_write32(padapter, 0x6c4, 0x5a5a5a5a); break; case BT_INFO_STATE_ACL_INQ_OR_PAG: - RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT PROFILE is BT_INFO_STATE_ACL_INQ_OR_PAG\n")); + RTPRINT(FBT, BT_TRACE, + ("[BTCoex], BT PROFILE is " + "BT_INFO_STATE_ACL_INQ_OR_PAG\n")); case BT_INFO_STATE_INQ_OR_PAG: padapter->pwrctrlpriv.btcoex_rfon = true; btdm_1AntSetPSTDMA(padapter, true, 0, true, 30); break; case BT_INFO_STATE_SCO_ONLY_BUSY: case BT_INFO_STATE_ACL_SCO_BUSY: - if (true == pBtCoex->bC2hBtInquiryPage) { - btdm_1AntSetPSTDMA(padapter, false, 0, true, 32); - } else { + if (true == pBtCoex->bC2hBtInquiryPage) + btdm_1AntSetPSTDMA(padapter, false, 0, + true, 32); + else { #ifdef BTCOEX_CMCC_TEST - btdm_1AntSetPSTDMA(padapter, false, 0, true, 23); + btdm_1AntSetPSTDMA(padapter, false, 0, + true, 23); #else /* !BTCOEX_CMCC_TEST */ - btdm_1AntSetPSTDMA(padapter, false, 0, false, 8); + btdm_1AntSetPSTDMA(padapter, false, 0, + false, 8); rtw_write32(padapter, 0x6c0, 0x5a5a5a5a); rtw_write32(padapter, 0x6c4, 0x5a5a5a5a); #endif /* !BTCOEX_CMCC_TEST */ @@ -5809,19 +5818,28 @@ static void btdm_1AntCoexProcessForWifiConnect(struct rtw_adapter *padapter) case BT_INFO_STATE_ACL_ONLY_BUSY: padapter->pwrctrlpriv.btcoex_rfon = true; if (pBtCoex->c2hBtProfile == BT_INFO_HID) { - RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT PROFILE is HID\n")); + RTPRINT(FBT, BT_TRACE, + ("[BTCoex], BT PROFILE is HID\n")); btdm_1AntSetPSTDMA(padapter, true, 0, true, 31); } else if (pBtCoex->c2hBtProfile == BT_INFO_FTP) { - RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT PROFILE is FTP/OPP\n")); + RTPRINT(FBT, BT_TRACE, + ("[BTCoex], BT PROFILE is FTP/OPP\n")); btdm_1AntSetPSTDMA(padapter, true, 0, true, 3); } else if (pBtCoex->c2hBtProfile == (BT_INFO_A2DP|BT_INFO_FTP)) { - RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT PROFILE is A2DP_FTP\n")); + RTPRINT(FBT, BT_TRACE, + ("[BTCoex], BT PROFILE is A2DP_FTP\n")); btdm_1AntSetPSTDMA(padapter, true, 0, true, 11); } else { if (pBtCoex->c2hBtProfile == BT_INFO_A2DP) - RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT PROFILE is A2DP\n")); + RTPRINT(FBT, BT_TRACE, + ("[BTCoex], BT PROFILE is " + "A2DP\n")); else - RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT PROFILE is UNKNOWN(0x%02X)! Use A2DP Profile\n", pBtCoex->c2hBtProfile)); + RTPRINT(FBT, BT_TRACE, + ("[BTCoex], BT PROFILE is " + "UNKNOWN(0x%02X)! Use A2DP " + "Profile\n", + pBtCoex->c2hBtProfile)); btdm_1AntTdmaDurationAdjustForACL(padapter); } break; @@ -5831,13 +5849,14 @@ static void btdm_1AntCoexProcessForWifiConnect(struct rtw_adapter *padapter) pBtdm8723->psTdmaGlobalCnt++; } -static void btdm_1AntUpdateHalRAMask(struct rtw_adapter *padapter, u32 mac_id, u32 filter) +static void +btdm_1AntUpdateHalRAMask(struct rtw_adapter *padapter, u32 mac_id, u32 filter) { u8 init_rate = 0; u8 raid; u32 mask; u8 shortGIrate = false; - int supportRateNum = 0; + int supportRateNum = 0; struct sta_info *psta; struct hal_data_8723a *pHalData; struct dm_priv *pdmpriv; @@ -5845,7 +5864,8 @@ static void btdm_1AntUpdateHalRAMask(struct rtw_adapter *padapter, u32 mac_id, u struct mlme_ext_info *pmlmeinfo; struct wlan_bssid_ex *cur_network; - RTPRINT(FBT, BT_TRACE, ("[BTCoex], %s, MACID =%d, filter = 0x%08x!!\n", __func__, mac_id, filter)); + RTPRINT(FBT, BT_TRACE, ("[BTCoex], %s, MACID =%d, filter = 0x%08x!!\n", + __func__, mac_id, filter)); pHalData = GET_HAL_DATA(padapter); pdmpriv = &pHalData->dmpriv; @@ -5854,13 +5874,15 @@ static void btdm_1AntUpdateHalRAMask(struct rtw_adapter *padapter, u32 mac_id, u cur_network = &pmlmeinfo->network; if (mac_id >= NUM_STA) { /* CAM_SIZE */ - RTPRINT(FBT, BT_TRACE, ("[BTCoex], %s, MACID =%d illegal!!\n", __func__, mac_id)); + RTPRINT(FBT, BT_TRACE, ("[BTCoex], %s, MACID =%d illegal!!\n", + __func__, mac_id)); return; } psta = pmlmeinfo->FW_sta_info[mac_id].psta; - if (psta == NULL) { - RTPRINT(FBT, BT_TRACE, ("[BTCoex], %s, Can't find station!!\n", __func__)); + if (!psta) { + RTPRINT(FBT, BT_TRACE, ("[BTCoex], %s, Can't find station!!\n", + __func__)); return; } @@ -5868,19 +5890,26 @@ static void btdm_1AntUpdateHalRAMask(struct rtw_adapter *padapter, u32 mac_id, u switch (mac_id) { case 0:/* for infra mode */ - supportRateNum = rtw_get_rateset_len23a(cur_network->SupportedRates); - mask = update_supported_rate23a(cur_network->SupportedRates, supportRateNum); - mask |= (pmlmeinfo->HT_enable) ? update_MSC_rate23a(&pmlmeinfo->HT_caps):0; + supportRateNum = + rtw_get_rateset_len23a(cur_network->SupportedRates); + mask = update_supported_rate23a(cur_network->SupportedRates, + supportRateNum); + mask |= (pmlmeinfo->HT_enable) ? + update_MSC_rate23a(&pmlmeinfo->HT_caps):0; if (support_short_GI23a(padapter, &pmlmeinfo->HT_caps)) shortGIrate = true; break; case 1:/* for broadcast/multicast */ - supportRateNum = rtw_get_rateset_len23a(pmlmeinfo->FW_sta_info[mac_id].SupportedRates); - mask = update_basic_rate23a(cur_network->SupportedRates, supportRateNum); + supportRateNum = rtw_get_rateset_len23a( + pmlmeinfo->FW_sta_info[mac_id].SupportedRates); + mask = update_basic_rate23a(cur_network->SupportedRates, + supportRateNum); break; default: /* for each sta in IBSS */ - supportRateNum = rtw_get_rateset_len23a(pmlmeinfo->FW_sta_info[mac_id].SupportedRates); - mask = update_supported_rate23a(cur_network->SupportedRates, supportRateNum); + supportRateNum = rtw_get_rateset_len23a( + pmlmeinfo->FW_sta_info[mac_id].SupportedRates); + mask = update_supported_rate23a(cur_network->SupportedRates, + supportRateNum); break; } mask |= ((raid<<28)&0xf0000000); @@ -5897,8 +5926,8 @@ static void btdm_1AntUpdateHalRAMask(struct rtw_adapter *padapter, u32 mac_id, u arg |= BIT(5); RTPRINT(FBT, BT_TRACE, - ("[BTCoex], Update FW RAID entry, MASK = 0x%08x, arg = 0x%02x\n", - mask, arg)); + ("[BTCoex], Update FW RAID entry, MASK = 0x%08x, " + "arg = 0x%02x\n", mask, arg)); rtl8723a_set_raid_cmd(padapter, mask, arg); } else { @@ -5912,7 +5941,8 @@ static void btdm_1AntUpdateHalRAMask(struct rtw_adapter *padapter, u32 mac_id, u pdmpriv->INIDATA_RATE[mac_id] = init_rate; } -static void btdm_1AntUpdateHalRAMaskForSCO(struct rtw_adapter *padapter, u8 forceUpdate) +static void +btdm_1AntUpdateHalRAMaskForSCO(struct rtw_adapter *padapter, u8 forceUpdate) { struct btdm_8723a_1ant *pBtdm8723; struct sta_priv *pstapriv; @@ -5923,7 +5953,7 @@ static void btdm_1AntUpdateHalRAMaskForSCO(struct rtw_adapter *padapter, u8 forc pBtdm8723 = &GET_HAL_DATA(padapter)->bt_coexist.halCoex8723.btdm1Ant; - if ((pBtdm8723->bRAChanged == true) && (forceUpdate == false)) + if (pBtdm8723->bRAChanged == true && forceUpdate == false) return; pstapriv = &padapter->stapriv; @@ -5966,9 +5996,13 @@ static void btdm_1AntRecoverHalRAMask(struct rtw_adapter *padapter) static void btdm_1AntBTStateChangeHandler(struct rtw_adapter *padapter, - enum bt_state_1ant oldState, enum bt_state_1ant newState) + enum bt_state_1ant oldState, + enum bt_state_1ant newState) { - RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT state change, %s => %s\n", BtStateString[oldState], BtStateString[newState])); + struct hal_data_8723a *phaldata; + RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT state change, %s => %s\n", + BtStateString[oldState], + BtStateString[newState])); /* BT default ignore wlan active, */ /* WiFi MUST disable this when BT is enable */ @@ -5985,22 +6019,23 @@ btdm_1AntBTStateChangeHandler(struct rtw_adapter *padapter, btdm_1AntRecoverHalRAMask(padapter); } } else { - GET_HAL_DATA(padapter)->bt_coexist.halCoex8723.btdm1Ant.bRAChanged = false; + phaldata = GET_HAL_DATA(padapter); + phaldata->bt_coexist.halCoex8723.btdm1Ant.bRAChanged = false; } if (oldState == newState) return; if (oldState == BT_INFO_STATE_ACL_ONLY_BUSY) { - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - pHalData->bt_coexist.halCoex8723.btdm1Ant.psTdmaMonitorCnt = 0; - pHalData->bt_coexist.halCoex8723.btdm1Ant.psTdmaMonitorCntForSCO = 0; + struct hal_data_8723a *Hal = GET_HAL_DATA(padapter); + Hal->bt_coexist.halCoex8723.btdm1Ant.psTdmaMonitorCnt = 0; + Hal->bt_coexist.halCoex8723.btdm1Ant.psTdmaMonitorCntForSCO = 0; } if ((oldState == BT_INFO_STATE_SCO_ONLY_BUSY) || (oldState == BT_INFO_STATE_ACL_SCO_BUSY)) { - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - pHalData->bt_coexist.halCoex8723.btdm1Ant.psTdmaMonitorCntForSCO = 0; + struct hal_data_8723a *Hal = GET_HAL_DATA(padapter); + Hal->bt_coexist.halCoex8723.btdm1Ant.psTdmaMonitorCntForSCO = 0; } /* Active 2Ant mechanism when BT Connected */ @@ -6008,14 +6043,16 @@ btdm_1AntBTStateChangeHandler(struct rtw_adapter *padapter, (oldState == BT_INFO_STATE_NO_CONNECTION)) { if ((newState != BT_INFO_STATE_DISABLED) && (newState != BT_INFO_STATE_NO_CONNECTION)) { - BTDM_SetSwRfRxLpfCorner(padapter, BT_RF_RX_LPF_CORNER_SHRINK); + BTDM_SetSwRfRxLpfCorner(padapter, + BT_RF_RX_LPF_CORNER_SHRINK); BTDM_AGCTable(padapter, BT_AGCTABLE_ON); BTDM_BBBackOffLevel(padapter, BT_BB_BACKOFF_ON); } } else { if ((newState == BT_INFO_STATE_DISABLED) || (newState == BT_INFO_STATE_NO_CONNECTION)) { - BTDM_SetSwRfRxLpfCorner(padapter, BT_RF_RX_LPF_CORNER_RESUME); + BTDM_SetSwRfRxLpfCorner(padapter, + BT_RF_RX_LPF_CORNER_RESUME); BTDM_AGCTable(padapter, BT_AGCTABLE_OFF); BTDM_BBBackOffLevel(padapter, BT_BB_BACKOFF_OFF); } @@ -6036,17 +6073,23 @@ static void btdm_1AntBtCoexistHandler(struct rtw_adapter *padapter) RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT is disabled\n")); if (BTDM_IsWifiConnectionExist(padapter)) { - RTPRINT(FBT, BT_TRACE, ("[BTCoex], wifi is connected\n")); + RTPRINT(FBT, BT_TRACE, + ("[BTCoex], wifi is connected\n")); if (BTDM_IsWifiBusy(padapter)) { - RTPRINT(FBT, BT_TRACE, ("[BTCoex], Wifi is busy\n")); - btdm_1AntSetPSTDMA(padapter, false, 0, false, 9); + RTPRINT(FBT, BT_TRACE, + ("[BTCoex], Wifi is busy\n")); + btdm_1AntSetPSTDMA(padapter, false, 0, + false, 9); } else { - RTPRINT(FBT, BT_TRACE, ("[BTCoex], Wifi is idle\n")); - _btdm_1AntSetPSTDMA(padapter, true, 2, 1, false, 9); + RTPRINT(FBT, BT_TRACE, + ("[BTCoex], Wifi is idle\n")); + _btdm_1AntSetPSTDMA(padapter, true, 2, 1, + false, 9); } } else { - RTPRINT(FBT, BT_TRACE, ("[BTCoex], wifi is disconnected\n")); + RTPRINT(FBT, BT_TRACE, + ("[BTCoex], wifi is disconnected\n")); btdm_1AntSetPSTDMA(padapter, false, 0, false, 9); } @@ -6054,24 +6097,29 @@ static void btdm_1AntBtCoexistHandler(struct rtw_adapter *padapter) RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT is enabled\n")); if (BTDM_IsWifiConnectionExist(padapter)) { - RTPRINT(FBT, BT_TRACE, ("[BTCoex], wifi is connected\n")); + RTPRINT(FBT, BT_TRACE, + ("[BTCoex], wifi is connected\n")); btdm_1AntWifiParaAdjust(padapter, true); btdm_1AntCoexProcessForWifiConnect(padapter); } else { - RTPRINT(FBT, BT_TRACE, ("[BTCoex], wifi is disconnected\n")); + RTPRINT(FBT, BT_TRACE, + ("[BTCoex], wifi is disconnected\n")); - /* Antenna switch at BT side(0x870 = 0x300, 0x860 = 0x210) after PSTDMA off */ + /* Antenna switch at BT side(0x870 = 0x300, + 0x860 = 0x210) after PSTDMA off */ btdm_1AntWifiParaAdjust(padapter, false); btdm_1AntSetPSTDMA(padapter, false, 0, false, 0); } } - btdm_1AntBTStateChangeHandler(padapter, pBtCoex8723->prec2hBtInfo, pBtCoex8723->c2hBtInfo); + btdm_1AntBTStateChangeHandler(padapter, pBtCoex8723->prec2hBtInfo, + pBtCoex8723->c2hBtInfo); pBtCoex8723->prec2hBtInfo = pBtCoex8723->c2hBtInfo; } -void BTDM_1AntSignalCompensation(struct rtw_adapter *padapter, u8 *rssi_wifi, u8 *rssi_bt) +void BTDM_1AntSignalCompensation(struct rtw_adapter *padapter, + u8 *rssi_wifi, u8 *rssi_bt) { struct hal_data_8723a *pHalData; struct btdm_8723a_1ant *pBtdm8723; @@ -6117,14 +6165,19 @@ void BTDM_1AntSignalCompensation(struct rtw_adapter *padapter, u8 *rssi_wifi, u8 } if (rssi_wifi && RSSI_WiFi_Cmpnstn) { - RTPRINT(FBT, BT_TRACE, ("[BTCoex], 1AntSgnlCmpnstn, case %d, WiFiCmpnstn =%d(%d => %d)\n", - pBtdm8723->curPsTdma, RSSI_WiFi_Cmpnstn, *rssi_wifi, *rssi_wifi+RSSI_WiFi_Cmpnstn)); + RTPRINT(FBT, BT_TRACE, + ("[BTCoex], 1AntSgnlCmpnstn, case %d, WiFiCmpnstn " + "=%d(%d => %d)\n", pBtdm8723->curPsTdma, + RSSI_WiFi_Cmpnstn, *rssi_wifi, + *rssi_wifi+RSSI_WiFi_Cmpnstn)); *rssi_wifi += RSSI_WiFi_Cmpnstn; } if (rssi_bt && RSSI_BT_Cmpnstn) { - RTPRINT(FBT, BT_TRACE, ("[BTCoex], 1AntSgnlCmpnstn, case %d, BTCmpnstn =%d(%d => %d)\n", - pBtdm8723->curPsTdma, RSSI_BT_Cmpnstn, *rssi_bt, *rssi_bt+RSSI_BT_Cmpnstn)); + RTPRINT(FBT, BT_TRACE, + ("[BTCoex], 1AntSgnlCmpnstn, case %d, BTCmpnstn " + "=%d(%d => %d)\n", pBtdm8723->curPsTdma, + RSSI_BT_Cmpnstn, *rssi_bt, *rssi_bt+RSSI_BT_Cmpnstn)); *rssi_bt += RSSI_BT_Cmpnstn; } } @@ -6160,7 +6213,8 @@ static void BTDM_1AntForHalt(struct rtw_adapter *padapter) { RTPRINT(FBT, BT_TRACE, ("\n[BTCoex], 1Ant for halt\n")); - GET_HAL_DATA(padapter)->bt_coexist.halCoex8723.btdm1Ant.bWiFiHalt = true; + GET_HAL_DATA(padapter)->bt_coexist.halCoex8723.btdm1Ant.bWiFiHalt = + true; btdm_1AntWifiParaAdjust(padapter, false); @@ -6178,7 +6232,8 @@ static void BTDM_1AntLpsLeave(struct rtw_adapter *padapter) RTPRINT(FBT, BT_TRACE, ("\n[BTCoex], 1Ant for LPS Leave\n")); /* Prevent from entering LPS again */ - GET_HAL_DATA(padapter)->bt_coexist.halCoex8723.btdm1Ant.bWiFiHalt = true; + GET_HAL_DATA(padapter)->bt_coexist.halCoex8723.btdm1Ant.bWiFiHalt = + true; btdm_1AntSetPSTDMA(padapter, false, 0, false, 8); /*btdm_1AntPsTdma(padapter, false, 8); */ @@ -6188,13 +6243,14 @@ static void BTDM_1AntWifiAssociateNotify(struct rtw_adapter *padapter, u8 type) { struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - RTPRINT(FBT, BT_TRACE, ("\n[BTCoex], 1Ant for associate, type =%d\n", type)); + RTPRINT(FBT, BT_TRACE, + ("\n[BTCoex], 1Ant for associate, type =%d\n", type)); if (type) { rtl8723a_CheckAntenna_Selection(padapter); - if (BT_IsBtDisabled(padapter)) { + if (BT_IsBtDisabled(padapter)) btdm_1AntSetPSTDMA(padapter, false, 0, false, 9); - } else { + else { struct bt_coexist_8723a *pBtCoex; u8 BtState; @@ -6203,20 +6259,24 @@ static void BTDM_1AntWifiAssociateNotify(struct rtw_adapter *padapter, u8 type) btdm_1AntTSFSwitch(padapter, true); - if ((BtState == BT_INFO_STATE_NO_CONNECTION) || - (BtState == BT_INFO_STATE_CONNECT_IDLE)) { - btdm_1AntSetPSTDMA(padapter, false, 0, true, 28); - } else if ((BtState == BT_INFO_STATE_SCO_ONLY_BUSY) || - (BtState == BT_INFO_STATE_ACL_SCO_BUSY)) { - btdm_1AntSetPSTDMA(padapter, false, 0, false, 8); + if (BtState == BT_INFO_STATE_NO_CONNECTION || + BtState == BT_INFO_STATE_CONNECT_IDLE) { + btdm_1AntSetPSTDMA(padapter, false, 0, + true, 28); + } else if (BtState == BT_INFO_STATE_SCO_ONLY_BUSY || + BtState == BT_INFO_STATE_ACL_SCO_BUSY) { + btdm_1AntSetPSTDMA(padapter, false, 0, + false, 8); rtw_write32(padapter, 0x6c0, 0x5a5a5a5a); rtw_write32(padapter, 0x6c4, 0x5a5a5a5a); - } else if ((BtState == BT_INFO_STATE_ACL_ONLY_BUSY) || - (BtState == BT_INFO_STATE_ACL_INQ_OR_PAG)) { + } else if (BtState == BT_INFO_STATE_ACL_ONLY_BUSY || + BtState == BT_INFO_STATE_ACL_INQ_OR_PAG) { if (pBtCoex->c2hBtProfile == BT_INFO_HID) - btdm_1AntSetPSTDMA(padapter, false, 0, true, 35); + btdm_1AntSetPSTDMA(padapter, false, 0, + true, 35); else - btdm_1AntSetPSTDMA(padapter, false, 0, true, 29); + btdm_1AntSetPSTDMA(padapter, false, 0, + true, 29); } } } else { @@ -6239,22 +6299,24 @@ BTDM_1AntMediaStatusNotify(struct rtw_adapter *padapter, pBtCoex = &GET_HAL_DATA(padapter)->bt_coexist.halCoex8723; - RTPRINT(FBT, BT_TRACE, ("\n\n[BTCoex]******************************\n")); + RTPRINT(FBT, BT_TRACE, + ("\n\n[BTCoex]******************************\n")); RTPRINT(FBT, BT_TRACE, ("[BTCoex], MediaStatus, WiFi %s !!\n", mstatus == RT_MEDIA_CONNECT?"CONNECT":"DISCONNECT")); RTPRINT(FBT, BT_TRACE, ("[BTCoex]******************************\n")); if (RT_MEDIA_CONNECT == mstatus) { if (check_fwstate(&padapter->mlmepriv, WIFI_STATION_STATE)) { - if ((pBtCoex->c2hBtInfo == BT_INFO_STATE_SCO_ONLY_BUSY) || - (pBtCoex->c2hBtInfo == BT_INFO_STATE_ACL_SCO_BUSY)) + if (pBtCoex->c2hBtInfo == BT_INFO_STATE_SCO_ONLY_BUSY || + pBtCoex->c2hBtInfo == BT_INFO_STATE_ACL_SCO_BUSY) btdm_1AntUpdateHalRAMaskForSCO(padapter, true); } padapter->pwrctrlpriv.DelayLPSLastTimeStamp = jiffies; BTDM_1AntForDhcp(padapter); } else { - /* DBG_8723A("%s rtl8723a_DeinitAntenna_Selection\n", __func__); */ + /* DBG_8723A("%s rtl8723a_DeinitAntenna_Selection\n", + __func__); */ rtl8723a_DeinitAntenna_Selection(padapter); btdm_1AntBtCoexistHandler(padapter); pBtCoex->btdm1Ant.bRAChanged = false; @@ -6274,8 +6336,10 @@ void BTDM_1AntForDhcp(struct rtw_adapter *padapter) pBtdm8723 = &pBtCoex->btdm1Ant; RTPRINT(FBT, BT_TRACE, ("\n[BTCoex], 1Ant for DHCP\n")); - RTPRINT(FBT, BT_TRACE, ("[BTCoex], 1Ant for DHCP, WiFi is %s\n", BTDM_IsWifiBusy(padapter)?"Busy":"IDLE")); - RTPRINT(FBT, BT_TRACE, ("[BTCoex], 1Ant for DHCP, %s\n", BtStateString[BtState])); + RTPRINT(FBT, BT_TRACE, ("[BTCoex], 1Ant for DHCP, WiFi is %s\n", + BTDM_IsWifiBusy(padapter)?"Busy":"IDLE")); + RTPRINT(FBT, BT_TRACE, ("[BTCoex], 1Ant for DHCP, %s\n", + BtStateString[BtState])); BTDM_1AntWifiAssociateNotify(padapter, true); } @@ -6292,9 +6356,12 @@ static void BTDM_1AntWifiScanNotify(struct rtw_adapter *padapter, u8 scanType) pBtCoex = &pHalData->bt_coexist.halCoex8723; pBtdm8723 = &pBtCoex->btdm1Ant; - RTPRINT(FBT, BT_TRACE, ("\n[BTCoex], 1Ant for wifi scan =%d!!\n", scanType)); - RTPRINT(FBT, BT_TRACE, ("[BTCoex], 1Ant for wifi scan, WiFi is %s\n", BTDM_IsWifiBusy(padapter)?"Busy":"IDLE")); - RTPRINT(FBT, BT_TRACE, ("[BTCoex], 1Ant for wifi scan, %s\n", BtStateString[BtState])); + RTPRINT(FBT, BT_TRACE, ("\n[BTCoex], 1Ant for wifi scan =%d!!\n", + scanType)); + RTPRINT(FBT, BT_TRACE, ("[BTCoex], 1Ant for wifi scan, WiFi is %s\n", + BTDM_IsWifiBusy(padapter)?"Busy":"IDLE")); + RTPRINT(FBT, BT_TRACE, ("[BTCoex], 1Ant for wifi scan, %s\n", + BtStateString[BtState])); if (scanType) { rtl8723a_CheckAntenna_Selection(padapter); @@ -6306,10 +6373,13 @@ static void BTDM_1AntWifiScanNotify(struct rtw_adapter *padapter, u8 scanType) if ((BtState == BT_INFO_STATE_SCO_ONLY_BUSY) || (BtState == BT_INFO_STATE_ACL_SCO_BUSY)) { if (pBtCoex->bC2hBtInquiryPage) { - btdm_1AntSetPSTDMA(padapter, false, 0, true, 32); + btdm_1AntSetPSTDMA(padapter, false, 0, + true, 32); } else { - padapter->pwrctrlpriv.btcoex_rfon = true; - btdm_1AntSetPSTDMA(padapter, true, 0, true, 33); + padapter->pwrctrlpriv.btcoex_rfon = + true; + btdm_1AntSetPSTDMA(padapter, true, 0, + true, 33); } } else if (true == pBtCoex->bC2hBtInquiryPage) { padapter->pwrctrlpriv.btcoex_rfon = true; @@ -6317,9 +6387,11 @@ static void BTDM_1AntWifiScanNotify(struct rtw_adapter *padapter, u8 scanType) } else if (BtState == BT_INFO_STATE_ACL_ONLY_BUSY) { padapter->pwrctrlpriv.btcoex_rfon = true; if (pBtCoex->c2hBtProfile == BT_INFO_HID) - btdm_1AntSetPSTDMA(padapter, true, 0, true, 34); + btdm_1AntSetPSTDMA(padapter, true, 0, + true, 34); else - btdm_1AntSetPSTDMA(padapter, true, 0, true, 4); + btdm_1AntSetPSTDMA(padapter, true, 0, + true, 4); } else { padapter->pwrctrlpriv.btcoex_rfon = true; btdm_1AntSetPSTDMA(padapter, true, 0, true, 5); @@ -6363,16 +6435,18 @@ static void BTDM_1AntFwC2hBtInfo8723A(struct rtw_adapter *padapter) pBtCoex->bC2hBtInquiryPage = false; btState &= ~BIT(2); - if (!(btState & BIT(0))) { + if (!(btState & BIT(0))) pBtCoex->c2hBtInfo = BT_INFO_STATE_NO_CONNECTION; - } else { - if (btState == 0x1) { + else { + if (btState == 0x1) pBtCoex->c2hBtInfo = BT_INFO_STATE_CONNECT_IDLE; - } else if (btState == 0x9) { + else if (btState == 0x9) { if (pBtCoex->bC2hBtInquiryPage == true) - pBtCoex->c2hBtInfo = BT_INFO_STATE_ACL_INQ_OR_PAG; + pBtCoex->c2hBtInfo = + BT_INFO_STATE_ACL_INQ_OR_PAG; else - pBtCoex->c2hBtInfo = BT_INFO_STATE_ACL_ONLY_BUSY; + pBtCoex->c2hBtInfo = + BT_INFO_STATE_ACL_ONLY_BUSY; pBtMgnt->ExtConfig.bBTBusy = true; } else if (btState == 0x3) { pBtCoex->c2hBtInfo = BT_INFO_STATE_SCO_ONLY_BUSY; @@ -6380,15 +6454,15 @@ static void BTDM_1AntFwC2hBtInfo8723A(struct rtw_adapter *padapter) } else if (btState == 0xb) { pBtCoex->c2hBtInfo = BT_INFO_STATE_ACL_SCO_BUSY; pBtMgnt->ExtConfig.bBTBusy = true; - } else { + } else pBtCoex->c2hBtInfo = BT_INFO_STATE_MAX; - } if (pBtMgnt->ExtConfig.bBTBusy) - pHalData->bt_coexist.CurrentState &= ~BT_COEX_STATE_BT_IDLE; + pHalData->bt_coexist.CurrentState &= + ~BT_COEX_STATE_BT_IDLE; } - if ((BT_INFO_STATE_NO_CONNECTION == pBtCoex->c2hBtInfo) || - (BT_INFO_STATE_CONNECT_IDLE == pBtCoex->c2hBtInfo)) { + if (BT_INFO_STATE_NO_CONNECTION == pBtCoex->c2hBtInfo || + BT_INFO_STATE_CONNECT_IDLE == pBtCoex->c2hBtInfo) { if (pBtCoex->bC2hBtInquiryPage) pBtCoex->c2hBtInfo = BT_INFO_STATE_INQ_OR_PAG; } @@ -6411,12 +6485,14 @@ void BTDM_1AntBtCoexist8723A(struct rtw_adapter *padapter) if (check_fwstate(pmlmepriv, WIFI_SITE_MONITOR)) { /* already done in BTDM_1AntForScan() */ - RTPRINT(FBT, BT_TRACE, ("[BTCoex], wifi is under scan progress!!\n")); + RTPRINT(FBT, BT_TRACE, + ("[BTCoex], wifi is under scan progress!!\n")); return; } if (check_fwstate(pmlmepriv, WIFI_UNDER_LINKING)) { - RTPRINT(FBT, BT_TRACE, ("[BTCoex], wifi is under link progress!!\n")); + RTPRINT(FBT, BT_TRACE, + ("[BTCoex], wifi is under link progress!!\n")); return; } -- cgit v1.2.3 From fecb32d446345078d51d348f21816398bd6d8af4 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sat, 26 Apr 2014 18:55:12 +0200 Subject: staging: r8723au: Fix sparse errors in os_dep/osdep_service.c Sparse reports drivers/staging/rtl8723au/os_dep/osdep_service.c:24:20: error: Bad character constant drivers/staging/rtl8723au/os_dep/osdep_service.c:25:0: error: Bad character constant The constant in question is never used. Signed-off-by: Larry Finger Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/osdep_service.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/osdep_service.c b/drivers/staging/rtl8723au/os_dep/osdep_service.c index b89e779fa045..4a937a7f1d11 100644 --- a/drivers/staging/rtl8723au/os_dep/osdep_service.c +++ b/drivers/staging/rtl8723au/os_dep/osdep_service.c @@ -21,8 +21,6 @@ #include #include -#define RT_TAG ('1178') - /* * Translate the OS dependent @param error_code to OS independent RTW_STATUS_CODE23a * @return: one of RTW_STATUS_CODE23a -- cgit v1.2.3 From 73302d7f7420f359a74f9b7dca37f2484a69371f Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sat, 26 Apr 2014 18:55:13 +0200 Subject: staging: r8723au: Fix sparse warning in os_dep/os_intfs.c Sparse reports the following: drivers/staging/rtl8723au/os_dep/os_intfs.c:321:14: warning: restricted __be16 degrades to integer Signed-off-by: Larry Finger Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/os_intfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index 2b2df95923b5..4347896e1df1 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -311,14 +311,14 @@ static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb, u16 rtw_recv_select_queue23a(struct sk_buff *skb) { struct iphdr *piphdr; + struct ethhdr *eth = (struct ethhdr *)skb->data; unsigned int dscp; - u16 eth_type; + u16 eth_type = get_unaligned_be16(ð->h_proto); u32 priority; u8 *pdata = skb->data; - memcpy(ð_type, pdata + (ETH_ALEN << 1), 2); switch (eth_type) { - case htons(ETH_P_IP): + case ETH_P_IP: piphdr = (struct iphdr *)(pdata + ETH_HLEN); dscp = piphdr->tos & 0xfc; priority = dscp >> 5; -- cgit v1.2.3 From caa90ab1a93635121f21c003995ec2c834fb15d9 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sat, 26 Apr 2014 18:55:14 +0200 Subject: staging: r8723au: Fix endian issues with TX and RX descriptors All descriptors are __le32, not unsigned int. The following sparse warnings are fixed: drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2626:24: warning: invalid assignment: &= drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2626:24: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2626:24: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2632:24: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2632:24: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2632:24: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2873:22: warning: incorrect type in assignment (different base types) drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2873:22: expected unsigned int [unsigned] txdw0 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2873:22: got restricted __le32 [usertype] drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2874:22: warning: incorrect type in assignment (different base types) drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2874:22: expected unsigned int [unsigned] txdw1 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2874:22: got restricted __le32 [usertype] drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2875:22: warning: incorrect type in assignment (different base types) drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2875:22: expected unsigned int [unsigned] txdw2 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2875:22: got restricted __le32 [usertype] drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2876:22: warning: incorrect type in assignment (different base types) drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2876:22: expected unsigned int [unsigned] txdw3 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2876:22: got restricted __le32 [usertype] drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2877:22: warning: incorrect type in assignment (different base types) drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2877:22: expected unsigned int [unsigned] txdw4 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2877:22: got restricted __le32 [usertype] drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2878:22: warning: incorrect type in assignment (different base types) drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2878:22: expected unsigned int [unsigned] txdw5 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2878:22: got restricted __le32 [usertype] drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2879:22: warning: incorrect type in assignment (different base types) drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2879:22: expected unsigned int [unsigned] txdw6 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2879:22: got restricted __le32 [usertype] drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2880:22: warning: incorrect type in assignment (different base types) drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2880:22: expected unsigned int [unsigned] txdw7 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2880:22: got restricted __le32 [usertype] drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2903:24: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2903:24: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2903:24: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2906:24: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2906:24: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2906:24: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2910:24: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2910:24: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2910:24: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2914:24: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2914:24: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2914:24: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2919:32: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2919:32: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2919:32: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2922:32: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2922:32: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2922:32: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2924:32: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2924:32: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2924:32: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2928:32: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2928:32: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2928:32: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2932:24: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2932:24: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2932:24: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_recv.c:145:24: warning: cast to restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_recv.c:146:24: warning: cast to restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_recv.c:147:24: warning: cast to restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_recv.c:148:24: warning: cast to restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_recv.c:149:24: warning: cast to restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_recv.c:150:24: warning: cast to restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:77:32: warning: invalid assignment: &= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:77:32: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:77:32: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:82:32: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:82:32: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:82:32: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:92:40: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:92:40: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:92:40: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:97:40: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:97:40: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:97:40: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:100:40: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:100:40: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:100:40: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:183:32: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:183:32: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:183:32: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:186:32: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:186:32: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:186:32: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:188:32: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:188:32: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:188:32: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:193:40: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:193:40: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:193:40: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:195:40: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:195:40: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:195:40: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:200:32: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:200:32: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:200:32: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:204:40: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:204:40: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:204:40: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:214:40: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:214:40: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:214:40: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:215:40: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:215:40: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:215:40: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:218:40: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:218:40: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:218:40: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:224:40: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:224:40: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:224:40: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:226:40: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:226:40: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:226:40: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:229:48: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:229:48: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:229:48: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:231:40: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:231:40: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:231:40: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:235:32: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:235:32: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:235:32: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:238:32: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:238:32: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:238:32: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:240:32: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:240:32: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:240:32: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:245:40: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:245:40: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:245:40: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:248:32: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:248:32: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:248:32: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:251:32: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:251:32: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:251:32: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:254:32: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:254:32: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:254:32: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:255:32: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:255:32: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:255:32: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:257:32: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:257:32: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:257:32: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:264:32: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:264:32: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:264:32: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:266:32: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:266:32: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:266:32: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:271:32: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:271:32: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:271:32: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:274:32: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:274:32: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:274:32: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:277:32: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:277:32: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:277:32: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:288:32: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:288:32: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:288:32: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:290:32: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:290:32: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:290:32: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:294:24: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:294:24: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:294:24: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:295:24: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:295:24: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:295:24: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:296:24: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:296:24: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:296:24: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:299:32: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:299:32: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:299:32: right side has type restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:306:32: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:306:32: left side has type unsigned int drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:306:32: right side has type restricted __le32 drivers/staging/rtl8723au/hal/usb_ops_linux.c:473:20: warning: cast to restricted __le32 drivers/staging/rtl8723au/hal/usb_ops_linux.c:590:36: warning: cast to restricted __le32 The following new warnings are temporarily added: drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2873:24: warning: cast from restricted __le32 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2874:24: warning: cast from restricted __le32 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2875:24: warning: cast from restricted __le32 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2876:24: warning: cast from restricted __le32 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2877:24: warning: cast from restricted __le32 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2878:24: warning: cast from restricted __le32 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2879:24: warning: cast from restricted __le32 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c:2880:24: warning: cast from restricted __le32 drivers/staging/rtl8723au/hal/rtl8723au_recv.c:145:22: warning: incorrect type in assignment (different base types) drivers/staging/rtl8723au/hal/rtl8723au_recv.c:145:22: expected restricted __le32 [usertype] rxdw0 drivers/staging/rtl8723au/hal/rtl8723au_recv.c:145:22: got unsigned int [unsigned] [usertype] drivers/staging/rtl8723au/hal/rtl8723au_recv.c:146:22: warning: incorrect type in assignment (different base types) drivers/staging/rtl8723au/hal/rtl8723au_recv.c:146:22: expected restricted __le32 [usertype] rxdw1 drivers/staging/rtl8723au/hal/rtl8723au_recv.c:146:22: got unsigned int [unsigned] [usertype] drivers/staging/rtl8723au/hal/rtl8723au_recv.c:147:22: warning: incorrect type in assignment (different base types) drivers/staging/rtl8723au/hal/rtl8723au_recv.c:147:22: expected restricted __le32 [usertype] rxdw2 drivers/staging/rtl8723au/hal/rtl8723au_recv.c:147:22: got unsigned int [unsigned] [usertype] drivers/staging/rtl8723au/hal/rtl8723au_recv.c:148:22: warning: incorrect type in assignment (different base types) drivers/staging/rtl8723au/hal/rtl8723au_recv.c:148:22: expected restricted __le32 [usertype] rxdw3 drivers/staging/rtl8723au/hal/rtl8723au_recv.c:148:22: got unsigned int [unsigned] [usertype] drivers/staging/rtl8723au/hal/rtl8723au_recv.c:149:22: warning: incorrect type in assignment (different base types) drivers/staging/rtl8723au/hal/rtl8723au_recv.c:149:22: expected restricted __le32 [usertype] rxdw4 drivers/staging/rtl8723au/hal/rtl8723au_recv.c:149:22: got unsigned int [unsigned] [usertype] drivers/staging/rtl8723au/hal/rtl8723au_recv.c:150:22: warning: incorrect type in assignment (different base types) drivers/staging/rtl8723au/hal/rtl8723au_recv.c:150:22: expected restricted __le32 [usertype] rxdw5 drivers/staging/rtl8723au/hal/rtl8723au_recv.c:150:22: got unsigned int [unsigned] [usertype] drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:211:51: warning: incorrect type in argument 2 (different base types) drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:211:51: expected unsigned int [usertype] *pdw drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:211:51: got restricted __le32 * drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:212:51: warning: incorrect type in argument 2 (different base types) drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:212:51: expected unsigned int [usertype] *pdw drivers/staging/rtl8723au/hal/rtl8723au_xmit.c:212:51: got restricted __le32 * Signed-off-by: Larry Finger Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtw_recv.h | 12 ++++++------ drivers/staging/rtl8723au/include/rtw_xmit.h | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rtl8723au/include/rtw_recv.h b/drivers/staging/rtl8723au/include/rtw_recv.h index d1866a6e831f..1f18af8dcc04 100644 --- a/drivers/staging/rtl8723au/include/rtw_recv.h +++ b/drivers/staging/rtl8723au/include/rtw_recv.h @@ -152,12 +152,12 @@ struct rx_pkt_attrib { #define RXDESC_OFFSET RXDESC_SIZE struct recv_stat { - unsigned int rxdw0; - unsigned int rxdw1; - unsigned int rxdw2; - unsigned int rxdw3; - unsigned int rxdw4; - unsigned int rxdw5; + __le32 rxdw0; + __le32 rxdw1; + __le32 rxdw2; + __le32 rxdw3; + __le32 rxdw4; + __le32 rxdw5; }; /* accesser of recv_priv: rtw_recv_entry23a(dispatch / passive level); \ diff --git a/drivers/staging/rtl8723au/include/rtw_xmit.h b/drivers/staging/rtl8723au/include/rtw_xmit.h index 65a33a07c8ee..5b879764518f 100644 --- a/drivers/staging/rtl8723au/include/rtw_xmit.h +++ b/drivers/staging/rtl8723au/include/rtw_xmit.h @@ -92,14 +92,14 @@ do { \ struct tx_desc { /* DWORD 0 */ - unsigned int txdw0; - unsigned int txdw1; - unsigned int txdw2; - unsigned int txdw3; - unsigned int txdw4; - unsigned int txdw5; - unsigned int txdw6; - unsigned int txdw7; + __le32 txdw0; + __le32 txdw1; + __le32 txdw2; + __le32 txdw3; + __le32 txdw4; + __le32 txdw5; + __le32 txdw6; + __le32 txdw7; }; union txdesc { -- cgit v1.2.3 From 74714a59ca0137e8527a8bcdbb7787f201d30464 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sat, 26 Apr 2014 18:55:15 +0200 Subject: staging: r8723au: Fix endian issues in hal/rtl8723au_recv.c The following sparse warnings are fixed: drivers/staging/rtl8723au/hal/rtl8723au_recv.c:145:22: warning: incorrect type in assignment (different base types) drivers/staging/rtl8723au/hal/rtl8723au_recv.c:145:22: expected restricted __le32 [usertype] rxdw0 drivers/staging/rtl8723au/hal/rtl8723au_recv.c:145:22: got unsigned int [unsigned] [usertype] drivers/staging/rtl8723au/hal/rtl8723au_recv.c:146:22: warning: incorrect type in assignment (different base types) drivers/staging/rtl8723au/hal/rtl8723au_recv.c:146:22: expected restricted __le32 [usertype] rxdw1 drivers/staging/rtl8723au/hal/rtl8723au_recv.c:146:22: got unsigned int [unsigned] [usertype] drivers/staging/rtl8723au/hal/rtl8723au_recv.c:147:22: warning: incorrect type in assignment (different base types) drivers/staging/rtl8723au/hal/rtl8723au_recv.c:147:22: expected restricted __le32 [usertype] rxdw2 drivers/staging/rtl8723au/hal/rtl8723au_recv.c:147:22: got unsigned int [unsigned] [usertype] drivers/staging/rtl8723au/hal/rtl8723au_recv.c:148:22: warning: incorrect type in assignment (different base types) drivers/staging/rtl8723au/hal/rtl8723au_recv.c:148:22: expected restricted __le32 [usertype] rxdw3 drivers/staging/rtl8723au/hal/rtl8723au_recv.c:148:22: got unsigned int [unsigned] [usertype] drivers/staging/rtl8723au/hal/rtl8723au_recv.c:149:22: warning: incorrect type in assignment (different base types) drivers/staging/rtl8723au/hal/rtl8723au_recv.c:149:22: expected restricted __le32 [usertype] rxdw4 drivers/staging/rtl8723au/hal/rtl8723au_recv.c:149:22: got unsigned int [unsigned] [usertype] drivers/staging/rtl8723au/hal/rtl8723au_recv.c:150:22: warning: incorrect type in assignment (different base types) drivers/staging/rtl8723au/hal/rtl8723au_recv.c:150:22: expected restricted __le32 [usertype] rxdw5 drivers/staging/rtl8723au/hal/rtl8723au_recv.c:150:22: got unsigned int [unsigned] [usertype] Signed-off-by: Larry Finger Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723au_recv.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_recv.c b/drivers/staging/rtl8723au/hal/rtl8723au_recv.c index e1f17af78a12..1b5b83619c89 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723au_recv.c +++ b/drivers/staging/rtl8723au/hal/rtl8723au_recv.c @@ -135,11 +135,20 @@ void rtl8723au_free_recv_priv(struct rtw_adapter *padapter) skb_queue_purge(&precvpriv->free_recv_skb_queue); } +struct recv_stat_cpu { + u32 rxdw0; + u32 rxdw1; + u32 rxdw2; + u32 rxdw3; + u32 rxdw4; + u32 rxdw5; +}; + void update_recvframe_attrib(struct recv_frame *precvframe, struct recv_stat *prxstat) { struct rx_pkt_attrib *pattrib; - struct recv_stat report; + struct recv_stat_cpu report; struct rxreport_8723a *prxreport; report.rxdw0 = le32_to_cpu(prxstat->rxdw0); -- cgit v1.2.3 From 69d9ff1ac630a7ed121ef81a0a94d99e06c25119 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sat, 26 Apr 2014 18:55:16 +0200 Subject: staging: r8723au: Fix endian errors in descriptor get and set macros There are several macros used to get and set portions of the RX and TX descriptor information that need to be converted to be endian correct. The following sparse warnings are fixed: drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2477:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2477:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2479:9: warning: invalid assignment: &= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2479:9: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2479:9: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2479:9: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2479:9: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2479:9: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2649:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2649:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2651:9: warning: invalid assignment: &= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2651:9: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2651:9: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2651:9: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2651:9: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2651:9: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2863:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2863:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2865:9: warning: invalid assignment: &= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2865:9: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2865:9: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2865:9: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2865:9: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2865:9: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2996:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2996:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2998:9: warning: invalid assignment: &= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2998:9: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2998:9: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2998:9: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2998:9: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2998:9: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3105:25: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3105:25: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3105:25: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3164:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3164:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3167:17: warning: invalid assignment: &= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3167:17: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3167:17: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3167:17: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3167:17: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3167:17: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3313:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3313:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3315:9: warning: invalid assignment: &= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3315:9: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3315:9: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3315:9: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3315:9: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3315:9: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3581:17: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3581:17: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3581:17: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3583:17: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3583:17: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3583:17: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3586:17: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3586:17: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3586:17: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3592:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3592:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3594:9: warning: invalid assignment: &= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3594:9: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3594:9: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3594:9: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3594:9: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3594:9: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3702:17: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3702:17: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3702:17: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3704:17: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3704:17: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3704:17: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3707:17: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3707:17: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3707:17: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3711:9: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3711:9: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3711:9: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3713:9: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3713:9: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3713:9: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3715:9: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3715:9: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3715:9: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3721:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3721:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3723:9: warning: invalid assignment: &= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3723:9: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3723:9: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3723:9: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3723:9: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3723:9: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3827:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3827:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3829:9: warning: invalid assignment: &= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3829:9: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3829:9: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3829:9: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3829:9: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3829:9: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3938:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3938:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3940:9: warning: invalid assignment: &= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3940:9: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3940:9: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3940:9: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3940:9: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3940:9: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4010:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4010:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4012:9: warning: invalid assignment: &= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4012:9: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4012:9: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4012:9: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4012:9: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4012:9: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4199:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4199:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4201:9: warning: invalid assignment: &= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4201:9: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4201:9: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4201:9: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4201:9: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4201:9: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4509:28: warning: too many warnings drivers/staging/rtl8723au/core/rtw_xmit.c:940:9: warning: invalid assignment: &= drivers/staging/rtl8723au/core/rtw_xmit.c:940:9: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_xmit.c:940:9: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_xmit.c:940:9: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_xmit.c:940:9: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_xmit.c:940:9: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_xmit.c:946:25: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_xmit.c:946:25: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_xmit.c:946:25: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_xmit.c:957:25: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_xmit.c:957:25: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_xmit.c:957:25: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_xmit.c:980:25: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_xmit.c:980:25: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_xmit.c:980:25: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_xmit.c:982:25: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_xmit.c:982:25: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_xmit.c:982:25: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_xmit.c:986:33: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_xmit.c:986:33: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_xmit.c:986:33: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_xmit.c:987:25: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_xmit.c:987:25: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_xmit.c:987:25: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_xmit.c:988:25: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_xmit.c:988:25: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_xmit.c:988:25: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_xmit.c:997:25: warning: cast to restricted __le16 drivers/staging/rtl8723au/core/rtw_xmit.c:997:25: warning: cast to restricted __le16 drivers/staging/rtl8723au/core/rtw_xmit.c:1176:17: warning: invalid assignment: |= drivers/staging/rtl8723au/core/rtw_xmit.c:1176:17: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_xmit.c:1176:17: right side has type restricted __le16 drivers/staging/rtl8723au/core/rtw_xmit.c:1260:25: warning: invalid assignment: &= drivers/staging/rtl8723au/core/rtw_xmit.c:1260:25: left side has type unsigned short drivers/staging/rtl8723au/core/rtw_xmit.c:1260:25: right side has type fouled restricted __le16 drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:224:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:224:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:226:9: warning: invalid assignment: &= drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:226:9: left side has type unsigned short drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:226:9: right side has type restricted __le16 drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:226:9: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:226:9: left side has type unsigned short drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:226:9: right side has type restricted __le16 drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:316:9: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:316:9: left side has type unsigned short drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:316:9: right side has type restricted __le16 drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:317:9: warning: invalid assignment: &= drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:317:9: left side has type unsigned short drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:317:9: right side has type restricted __le16 drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:317:9: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:317:9: left side has type unsigned short drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:317:9: right side has type restricted __le16 drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:320:9: warning: incorrect type in assignment (different base types) drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:320:9: expected unsigned short [unsigned] [short] drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:320:9: got restricted __le16 [usertype] drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:354:17: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:354:17: left side has type unsigned short drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:354:17: right side has type restricted __le16 drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:358:17: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:358:17: left side has type unsigned short drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:358:17: right side has type restricted __le16 drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:366:17: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:366:17: left side has type unsigned short drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:366:17: right side has type restricted __le16 drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:382:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:382:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:387:17: warning: invalid assignment: &= drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:387:17: left side has type unsigned short drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:387:17: right side has type restricted __le16 drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:387:17: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:387:17: left side has type unsigned short drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:387:17: right side has type restricted __le16 drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:390:17: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:390:17: left side has type unsigned short drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:390:17: right side has type restricted __le16 drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:391:17: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:391:17: left side has type unsigned short drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:391:17: right side has type restricted __le16 drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:395:17: warning: invalid assignment: &= drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:395:17: left side has type unsigned short drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:395:17: right side has type restricted __le16 drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:395:17: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:395:17: left side has type unsigned short drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:395:17: right side has type restricted __le16 drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:426:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:426:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:427:9: warning: invalid assignment: &= drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:427:9: left side has type unsigned short drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:427:9: right side has type restricted __le16 drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:427:9: warning: invalid assignment: |= drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:427:9: left side has type unsigned short drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:427:9: right side has type restricted __le16 drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c:319:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c:319:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c:323:17: warning: invalid assignment: &= drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c:323:17: left side has type unsigned short drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c:323:17: right side has type restricted __le16 drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c:323:17: warning: invalid assignment: |= drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c:323:17: left side has type unsigned short drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c:323:17: right side has type restricted __le16 drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c:326:17: warning: invalid assignment: &= drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c:326:17: left side has type unsigned short drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c:326:17: right side has type restricted __le16 drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c:326:17: warning: invalid assignment: |= drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c:326:17: left side has type unsigned short drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c:326:17: right side has type restricted __le16 drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c:2368:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c:2368:9: warning: cast to restricted __le16 drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c:2370:9: warning: invalid assignment: &= drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c:2370:9: left side has type unsigned short drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c:2370:9: right side has type restricted __le16 drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c:2370:9: warning: invalid assignment: |= drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c:2370:9: left side has type unsigned short drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c:2370:9: right side has type restricted __le16 The following new warnings were temporarily added: drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4509:28: warning: incorrect type in assignment (different base types) drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4509:28: expected unsigned short [unsigned] [assigned] [usertype] capab_info drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4509:28: got restricted __le16 [usertype] capab_info drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4612:17: warning: cast to restricted __le32 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:5549:6: warning: symbol 'linked23a_rx_sig_stren_disp' was not declared. Should it be static? Signed-off-by: Larry Finger Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/wifi.h | 40 ++++++++++++++++---------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index 57ad44ec0aa8..aebc05d8a123 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -82,42 +82,42 @@ enum WIFI_REG_DOMAIN { #define SetToDs(pbuf) \ - (*(unsigned short *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_TODS)) + (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_TODS)) #define SetFrDs(pbuf) \ - (*(unsigned short *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_FROMDS)) + (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_FROMDS)) #define get_tofr_ds(pframe) ((ieee80211_has_tods(pframe) << 1) | \ ieee80211_has_fromds(pframe)) #define SetMFrag(pbuf) \ - (*(unsigned short *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) + (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) #define ClearMFrag(pbuf) \ - (*(unsigned short *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_MOREFRAGS))) + (*(__le16 *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_MOREFRAGS))) #define SetRetry(pbuf) \ - (*(unsigned short *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_RETRY)) + (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_RETRY)) #define SetPwrMgt(pbuf) \ - (*(unsigned short *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_PM)) + (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_PM)) #define SetMData(pbuf) \ - (*(unsigned short *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_MOREDATA)) + (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_MOREDATA)) #define SetPrivacy(pbuf) \ - (*(unsigned short *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_PROTECTED)) + (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_PROTECTED)) #define SetFrameType(pbuf, type) \ do { \ - *(unsigned short *)(pbuf) &= __constant_cpu_to_le16(~(BIT(3) | BIT(2))); \ - *(unsigned short *)(pbuf) |= __constant_cpu_to_le16(type); \ + *(__le16 *)(pbuf) &= __constant_cpu_to_le16(~(BIT(3) | BIT(2))); \ + *(__le16 *)(pbuf) |= __constant_cpu_to_le16(type); \ } while (0) #define SetFrameSubType(pbuf, type) \ do { \ - *(unsigned short *)(pbuf) &= cpu_to_le16(~(BIT(7) | BIT(6) | BIT(5) | BIT(4) | BIT(3) | BIT(2))); \ - *(unsigned short *)(pbuf) |= cpu_to_le16(type); \ + *(__le16 *)(pbuf) &= cpu_to_le16(~(BIT(7) | BIT(6) | BIT(5) | BIT(4) | BIT(3) | BIT(2))); \ + *(__le16 *)(pbuf) |= cpu_to_le16(type); \ } while (0) #define GetTupleCache(pbuf) (cpu_to_le16(*(unsigned short *)((unsigned long)(pbuf) + 22))) @@ -131,26 +131,26 @@ enum WIFI_REG_DOMAIN { #define SetSeqNum(pbuf, num) \ do { \ - *(unsigned short *)((unsigned long)(pbuf) + 22) = \ - ((*(unsigned short *)((unsigned long)(pbuf) + 22)) & le16_to_cpu((unsigned short)0x000f)) | \ - le16_to_cpu((unsigned short)(0xfff0 & (num << 4))); \ + *(__le16 *)((size_t)(pbuf) + 22) = \ + ((*(__le16 *)((size_t)(pbuf) + 22)) & cpu_to_le16((unsigned short)0x000f)) | \ + cpu_to_le16((unsigned short)(0xfff0 & (num << 4))); \ } while (0) #define SetDuration(pbuf, dur) \ - (*(unsigned short *)((unsigned long)(pbuf) + 2) = \ + (*(__le16 *)((unsigned long)(pbuf) + 2) = \ cpu_to_le16(0xffff & (dur))) #define SetPriority(pbuf, tid) \ - (*(unsigned short *)(pbuf) |= cpu_to_le16(tid & 0xf)) + (*(__le16 *)(pbuf) |= cpu_to_le16(tid & 0xf)) #define SetEOSP(pbuf, eosp) \ - (*(unsigned short *)(pbuf) |= cpu_to_le16((eosp & 1) << 4)) + (*(__le16 *)(pbuf) |= cpu_to_le16((eosp & 1) << 4)) #define SetAckpolicy(pbuf, ack) \ - (*(unsigned short *)(pbuf) |= cpu_to_le16((ack & 3) << 5)) + (*(__le16 *)(pbuf) |= cpu_to_le16((ack & 3) << 5)) #define SetAMsdu(pbuf, amsdu) \ - (*(unsigned short *)(pbuf) |= cpu_to_le16((amsdu & 1) << 7)) + (*(__le16 *)(pbuf) |= cpu_to_le16((amsdu & 1) << 7)) #define GetAid(pbuf) \ (cpu_to_le16(*(unsigned short *)((unsigned long)(pbuf) + 2)) & \ -- cgit v1.2.3 From c0b99bed167c80281dc5aa757776ccddda8250f6 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sat, 26 Apr 2014 18:55:17 +0200 Subject: staging: r8723au: Set undeclared routines to static The following sparse warnings are fixed: drivers/staging/rtl8723au/core/rtw_cmd.c:1211:6: warning: symbol 'dynamic_chk_wk_hdl' was not declared. Should it be static? drivers/staging/rtl8723au/core/rtw_cmd.c:1238:6: warning: symbol 'lps_ctrl_wk_hdl' was not declared. Should it be static? drivers/staging/rtl8723au/core/rtw_cmd.c:1812:6: warning: symbol 'rtw_getrttbl_cmd_cmdrsp_callback' was not declared. Should it be static? drivers/staging/rtl8723au/core/rtw_mlme.c:364:6: warning: symbol 'rtw_free_network' was not declared. Should it be static? drivers/staging/rtl8723au/core/rtw_mlme.c:373:6: warning: symbol 'rtw_free_network_nolock' was not declared. Should it be static? drivers/staging/rtl8723au/core/rtw_mlme.c:631:6: warning: symbol 'rtw_add_network' was not declared. Should it be static? drivers/staging/rtl8723au/core/rtw_mlme.c:644:5: warning: symbol 'rtw_is_desired_network' was not declared. Should it be static? drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2246:5: warning: symbol 'DoReserved23a' was not declared. Should it be static? drivers/staging/rtl8723au/core/rtw_mlme_ext.c:5549:6: warning: symbol 'linked23a_rx_sig_stren_disp' was not declared. Should it be static? drivers/staging/rtl8723au/core/rtw_pwrctrl.c:272:4: warning: symbol 'PS_RDY_CHECK' was not declared. Should it be static? drivers/staging/rtl8723au/core/rtw_recv.c:1937:5: warning: symbol 'enqueue_reorder_recvframe23a' was not declared. Should it be static? drivers/staging/rtl8723au/core/rtw_sta_mgt.c:24:6: warning: symbol '_rtw_init_stainfo' was not declared. Should it be static? drivers/staging/rtl8723au/core/rtw_sta_mgt.c:112:6: warning: symbol 'rtw_mfree_all_stainfo' was not declared. Should it be static? drivers/staging/rtl8723au/core/rtw_sta_mgt.c:127:6: warning: symbol 'rtw_mfree_sta_priv_lock' was not declared. Should it be static? drivers/staging/rtl8723au/core/rtw_wlan_util.c:143:15: warning: symbol 'ratetbl_val_2wifirate' was not declared. Should it be static? drivers/staging/rtl8723au/core/rtw_wlan_util.c:188:5: warning: symbol 'is_basicrate' was not declared. Should it be static? drivers/staging/rtl8723au/core/rtw_wlan_util.c:206:14: warning: symbol 'ratetbl2rateset' was not declared. Should it be static? Three of the above routines were not used and were deleted. Signed-off-by: Larry Finger Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 10 ++-------- drivers/staging/rtl8723au/core/rtw_mlme.c | 21 ++++++--------------- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 5 +++-- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 2 +- drivers/staging/rtl8723au/core/rtw_recv.c | 4 ++-- drivers/staging/rtl8723au/core/rtw_sta_mgt.c | 6 +++--- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 25 +++++++------------------ 7 files changed, 24 insertions(+), 49 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 8ce4148a3a49..c87671b60690 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -1083,7 +1083,7 @@ static void traffic_status_watchdog(struct rtw_adapter *padapter) pmlmepriv->LinkDetectInfo.bHigherBusyTxTraffic = bHigherBusyTxTraffic; } -void dynamic_chk_wk_hdl(struct rtw_adapter *padapter, u8 *pbuf, int sz) +static void dynamic_chk_wk_hdl(struct rtw_adapter *padapter, u8 *pbuf, int sz) { struct mlme_priv *pmlmepriv; @@ -1110,7 +1110,7 @@ void dynamic_chk_wk_hdl(struct rtw_adapter *padapter, u8 *pbuf, int sz) #endif } -void lps_ctrl_wk_hdl(struct rtw_adapter *padapter, u8 lps_ctrl_type) +static void lps_ctrl_wk_hdl(struct rtw_adapter *padapter, u8 lps_ctrl_type) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -1689,9 +1689,3 @@ void rtw_setassocsta_cmdrsp_callback23a(struct rtw_adapter *padapter, exit: rtw_free_cmd_obj23a(pcmd); } - -void rtw_getrttbl_cmd_cmdrsp_callback(struct rtw_adapter *padapter, - struct cmd_obj *pcmd) -{ - rtw_free_cmd_obj23a(pcmd); -} diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index b205d0f2e8f4..1f7f061ca1dd 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -361,17 +361,8 @@ int rtw_init_mlme_priv23a (struct rtw_adapter *padapter) return res; } -void rtw_free_network(struct mlme_priv *pmlmepriv, - struct wlan_network *pnetwork, u8 is_freeall) -{ - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, - ("rtw_free_network ==> ssid = %s\n\n" , - pnetwork->network.Ssid.ssid)); - _rtw_free_network23a(pmlmepriv, pnetwork, is_freeall); -} - -void rtw_free_network_nolock(struct mlme_priv *pmlmepriv, - struct wlan_network *pnetwork) +static void rtw_free_network_nolock(struct mlme_priv *pmlmepriv, + struct wlan_network *pnetwork) { _rtw_free_network23a_nolock23a(pmlmepriv, pnetwork); } @@ -628,8 +619,8 @@ exit: spin_unlock_bh(&queue->lock); } -void rtw_add_network(struct rtw_adapter *adapter, - struct wlan_bssid_ex *pnetwork) +static void rtw_add_network(struct rtw_adapter *adapter, + struct wlan_bssid_ex *pnetwork) { update_current_network(adapter, pnetwork); rtw_update_scanned_network23a(adapter, pnetwork); @@ -641,8 +632,8 @@ void rtw_add_network(struct rtw_adapter *adapter, /* (3) WMM */ /* (4) HT */ /* (5) others */ -int rtw_is_desired_network(struct rtw_adapter *adapter, - struct wlan_network *pnetwork) +static int rtw_is_desired_network(struct rtw_adapter *adapter, + struct wlan_network *pnetwork) { struct security_priv *psecuritypriv = &adapter->securitypriv; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 303b76f9e196..40fcf36d54bd 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -2243,7 +2243,8 @@ OnAction23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) return _SUCCESS; } -int DoReserved23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) +static int DoReserved23a(struct rtw_adapter *padapter, + struct recv_frame *precv_frame) { return _SUCCESS; } @@ -5537,7 +5538,7 @@ void mlmeext_sta_del_event_callback23a(struct rtw_adapter *padapter) Following are the functions for the timer handlers *****************************************************************************/ -void linked23a_rx_sig_stren_disp(struct rtw_adapter *padapter) +static void linked23a_rx_sig_stren_disp(struct rtw_adapter *padapter) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index 77880547e80f..7370a391ed96 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -269,7 +269,7 @@ void rtw_set_rpwm23a(struct rtw_adapter *padapter, u8 pslv) } -u8 PS_RDY_CHECK(struct rtw_adapter * padapter) +static u8 PS_RDY_CHECK(struct rtw_adapter * padapter) { unsigned long delta_time; struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 644c3a132e59..3791bbbdc582 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -1934,8 +1934,8 @@ int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_num) return true; } -int enqueue_reorder_recvframe23a(struct recv_reorder_ctrl *preorder_ctrl, - struct recv_frame *prframe) +static int enqueue_reorder_recvframe23a(struct recv_reorder_ctrl *preorder_ctrl, + struct recv_frame *prframe) { struct rx_pkt_attrib *pattrib = &prframe->attrib; struct rtw_queue *ppending_recvframe_queue; diff --git a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c index a64c350591c2..53dd3207ecef 100644 --- a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c @@ -21,7 +21,7 @@ #include #include -void _rtw_init_stainfo(struct sta_info *psta) +static void _rtw_init_stainfo(struct sta_info *psta) { memset((u8 *)psta, 0, sizeof (struct sta_info)); spin_lock_init(&psta->lock); @@ -109,7 +109,7 @@ inline struct sta_info *rtw_get_stainfo23a_by_offset23a(struct sta_priv *stapriv } /* this function is used to free the memory of lock || sema for all stainfos */ -void rtw_mfree_all_stainfo(struct sta_priv *pstapriv) +static void rtw_mfree_all_stainfo(struct sta_priv *pstapriv) { struct list_head *plist, *phead; struct sta_info *psta; @@ -124,7 +124,7 @@ void rtw_mfree_all_stainfo(struct sta_priv *pstapriv) spin_unlock_bh(&pstapriv->sta_hash_lock); } -void rtw_mfree_sta_priv_lock(struct sta_priv *pstapriv) +static void rtw_mfree_sta_priv_lock(struct sta_priv *pstapriv) { rtw_mfree_all_stainfo(pstapriv); /* be done before free sta_hash_lock */ } diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index a971c3d67a69..09f3a66010d9 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -140,7 +140,7 @@ u8 judge_network_type23a(struct rtw_adapter *padapter, unsigned char *rate, int return network_type; } -unsigned char ratetbl_val_2wifirate(unsigned char rate) +static unsigned char ratetbl_val_2wifirate(unsigned char rate) { unsigned char val = 0; @@ -185,7 +185,7 @@ unsigned char ratetbl_val_2wifirate(unsigned char rate) return val; } -int is_basicrate(struct rtw_adapter *padapter, unsigned char rate) +static int is_basicrate(struct rtw_adapter *padapter, unsigned char rate) { int i; unsigned char val; @@ -203,7 +203,8 @@ int is_basicrate(struct rtw_adapter *padapter, unsigned char rate) return false; } -unsigned int ratetbl2rateset(struct rtw_adapter *padapter, unsigned char *rateset) +static unsigned int ratetbl2rateset(struct rtw_adapter *padapter, + unsigned char *rateset) { int i; unsigned char rate; @@ -1232,7 +1233,7 @@ unsigned int is_ap_in_wep23a(struct rtw_adapter *padapter) } } -int wifirate2_ratetbl_inx23a(unsigned char rate) +static int wifirate2_ratetbl_inx23a(unsigned char rate) { int inx = 0; rate = rate & 0x7f; @@ -1346,25 +1347,13 @@ unsigned char get_highest_rate_idx23a(u32 mask) return rate_idx; } -unsigned char get_highest_mcs_rate(struct HT_caps_element *pHT_caps) -{ - int i, mcs_rate; - - mcs_rate = (pHT_caps->u.HT_cap_element.MCS_rate[0] | (pHT_caps->u.HT_cap_element.MCS_rate[1] << 8)); - - for (i = 15; i >= 0; i--) { - if (mcs_rate & (0x1 << i)) - break; - } - return i; -} - void Update_RA_Entry23a(struct rtw_adapter *padapter, struct sta_info *psta) { rtw_hal_update_ra_mask23a(psta, 0); } -void enable_rate_adaptive(struct rtw_adapter *padapter, struct sta_info *psta) +static void enable_rate_adaptive(struct rtw_adapter *padapter, + struct sta_info *psta) { Update_RA_Entry23a(padapter, psta); } -- cgit v1.2.3 From a96ae6f41c1208e4754be575cfa97566d3f7c55e Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sat, 26 Apr 2014 18:55:18 +0200 Subject: staging: r8723au: Fix sparse warnings in core/rtw_ap.c The following warnings are fixed: drivers/staging/rtl8723au/core/rtw_ap.c:79:23: warning: incorrect type in assignment (different base types) drivers/staging/rtl8723au/core/rtw_ap.c:79:23: expected unsigned short [unsigned] [usertype] tim_bitmap_le drivers/staging/rtl8723au/core/rtw_ap.c:79:23: got restricted __le16 [usertype] drivers/staging/rtl8723au/core/rtw_ap.c:1441:37: warning: restricted __le16 degrades to integer Signed-off-by: Larry Finger Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 7459825c2abe..23be15cc76bc 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -73,7 +73,7 @@ static void update_BCNTIM(struct rtw_adapter *padapter) struct wlan_bssid_ex *pnetwork_mlmeext = &pmlmeinfo->network; unsigned char *pie = pnetwork_mlmeext->IEs; u8 *p, *dst_ie, *premainder_ie = NULL, *pbackup_remainder_ie = NULL; - u16 tim_bitmap_le; + __le16 tim_bitmap_le; uint offset, tmp_len, tim_ielen, tim_ie_offset, remainder_ielen; tim_bitmap_le = cpu_to_le16(pstapriv->tim_bitmap); @@ -1439,8 +1439,9 @@ static int rtw_ht_operation_update(struct rtw_adapter *padapter) if (pmlmepriv->num_sta_no_ht || (pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT)) new_op_mode = OP_MODE_MIXED; - else if ((phtpriv_ap->ht_cap.cap_info & IEEE80211_HT_CAP_SUP_WIDTH_20_40) - && pmlmepriv->num_sta_ht_20mhz) + else if ((le16_to_cpu(phtpriv_ap->ht_cap.cap_info) & + IEEE80211_HT_CAP_SUP_WIDTH_20_40) && + pmlmepriv->num_sta_ht_20mhz) new_op_mode = OP_MODE_20MHZ_HT_STA_ASSOCED; else if (pmlmepriv->olbc_ht) new_op_mode = OP_MODE_MAY_BE_LEGACY_STAS; -- cgit v1.2.3 From b93eb5c565884370134cd392ff227755519cecda Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:19 +0200 Subject: staging: rtl8723au: Remove unused usb write_async calls Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_io.c | 33 ------------------------------ drivers/staging/rtl8723au/include/rtw_io.h | 17 --------------- 2 files changed, 50 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_io.c b/drivers/staging/rtl8723au/core/rtw_io.c index 1cae8d7659b9..e53179fa505c 100644 --- a/drivers/staging/rtl8723au/core/rtw_io.c +++ b/drivers/staging/rtl8723au/core/rtw_io.c @@ -118,39 +118,6 @@ int _rtw_writeN23a(struct rtw_adapter *adapter, u32 addr , u32 length , u8 *pdat return RTW_STATUS_CODE23a(ret); } -int _rtw_write823a_async23a(struct rtw_adapter *adapter, u32 addr, u8 val) -{ - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; - int ret; - - ret = pintfhdl->io_ops._write8_async(pintfhdl, addr, val); - - return RTW_STATUS_CODE23a(ret); -} -int _rtw_write1623a_async(struct rtw_adapter *adapter, u32 addr, u16 val) -{ - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; - int ret; - - val = cpu_to_le16(val); - ret = pintfhdl->io_ops._write16_async(pintfhdl, addr, val); - - return RTW_STATUS_CODE23a(ret); -} -int _rtw_write3223a_async23a(struct rtw_adapter *adapter, u32 addr, u32 val) -{ - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; - int ret; - - val = cpu_to_le32(val); - ret = pintfhdl->io_ops._write32_async(pintfhdl, addr, val); - - return RTW_STATUS_CODE23a(ret); -} - void _rtw_read_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem) { struct io_priv *pio_priv = &adapter->iopriv; diff --git a/drivers/staging/rtl8723au/include/rtw_io.h b/drivers/staging/rtl8723au/include/rtw_io.h index 8d39d800267d..eea6dc27c105 100644 --- a/drivers/staging/rtl8723au/include/rtw_io.h +++ b/drivers/staging/rtl8723au/include/rtw_io.h @@ -111,10 +111,6 @@ struct _io_ops int (*_write32)(struct intf_hdl *pintfhdl, u32 addr, u32 val); int (*_writeN)(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata); - int (*_write8_async)(struct intf_hdl *pintfhdl, u32 addr, u8 val); - int (*_write16_async)(struct intf_hdl *pintfhdl, u32 addr, u16 val); - int (*_write32_async)(struct intf_hdl *pintfhdl, u32 addr, u32 val); - void (*_read_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); void (*_write_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); @@ -129,7 +125,6 @@ struct _io_ops void (*_read_port_cancel)(struct intf_hdl *pintfhdl); void (*_write_port_cancel)(struct intf_hdl *pintfhdl); - }; struct io_req { @@ -315,10 +310,6 @@ int _rtw_write1623a(struct rtw_adapter *adapter, u32 addr, u16 val); int _rtw_write3223a(struct rtw_adapter *adapter, u32 addr, u32 val); int _rtw_writeN23a(struct rtw_adapter *adapter, u32 addr, u32 length, u8 *pdata); -int _rtw_write823a_async23a(struct rtw_adapter *adapter, u32 addr, u8 val); -int _rtw_write1623a_async(struct rtw_adapter *adapter, u32 addr, u16 val); -int _rtw_write3223a_async23a(struct rtw_adapter *adapter, u32 addr, u32 val); - void _rtw_write_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem); u32 _rtw_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct xmit_buf *pmem); u32 _rtw_write_port23a_and_wait23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct xmit_buf *pmem, int timeout_ms); @@ -349,10 +340,6 @@ int dbg_rtw_writeN23a(struct rtw_adapter *adapter, u32 addr ,u32 length , u8 *da #define rtw_write32(adapter, addr, val) dbg_rtw_write3223a((adapter), (addr), (val), __FUNCTION__, __LINE__) #define rtw_writeN(adapter, addr, length, data) dbg_rtw_writeN23a((adapter), (addr), (length), (data), __FUNCTION__, __LINE__) -#define rtw_write8_async(adapter, addr, val) _rtw_write823a_async23a((adapter), (addr), (val)) -#define rtw_write16_async(adapter, addr, val) _rtw_write1623a_async((adapter), (addr), (val)) -#define rtw_write32_async(adapter, addr, val) _rtw_write3223a_async23a((adapter), (addr), (val)) - #define rtw_write_mem(adapter, addr, cnt, mem) _rtw_write_mem23a((adapter), addr, cnt, mem) #define rtw_write_port(adapter, addr, cnt, mem) _rtw_write_port23a(adapter, addr, cnt, mem) #define rtw_write_port_and_wait(adapter, addr, cnt, mem, timeout_ms) _rtw_write_port23a_and_wait23a((adapter), (addr), (cnt), (mem), (timeout_ms)) @@ -370,10 +357,6 @@ int dbg_rtw_writeN23a(struct rtw_adapter *adapter, u32 addr ,u32 length , u8 *da #define rtw_write32(adapter, addr, val) _rtw_write3223a((adapter), (addr), (val)) #define rtw_writeN(adapter, addr, length, data) _rtw_writeN23a((adapter), (addr), (length), (data)) -#define rtw_write8_async(adapter, addr, val) _rtw_write823a_async23a((adapter), (addr), (val)) -#define rtw_write16_async(adapter, addr, val) _rtw_write1623a_async((adapter), (addr), (val)) -#define rtw_write32_async(adapter, addr, val) _rtw_write3223a_async23a((adapter), (addr), (val)) - #define rtw_write_mem(adapter, addr, cnt, mem) _rtw_write_mem23a((adapter), (addr), (cnt), (mem)) #define rtw_write_port(adapter, addr, cnt, mem) _rtw_write_port23a((adapter), (addr), (cnt), (mem)) #define rtw_write_port_and_wait(adapter, addr, cnt, mem, timeout_ms) _rtw_write_port23a_and_wait23a((adapter), (addr), (cnt), (mem), (timeout_ms)) -- cgit v1.2.3 From e32c7cd01b3023cd753ef9870ac31aaeb665883b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:20 +0200 Subject: staging: rtl8723au: Remove wrapper around rtl8723au_set_intf_ops() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/usb_ops.h | 1 - drivers/staging/rtl8723au/os_dep/usb_intf.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/include/usb_ops.h b/drivers/staging/rtl8723au/include/usb_ops.h index 55d1380f9036..21950541a2f1 100644 --- a/drivers/staging/rtl8723au/include/usb_ops.h +++ b/drivers/staging/rtl8723au/include/usb_ops.h @@ -46,7 +46,6 @@ void rtl8723au_set_hw_type(struct rtw_adapter *padapter); #define hal_set_hw_type rtl8723au_set_hw_type void rtl8723au_set_intf_ops(struct _io_ops *pops); -#define usb_set_intf_ops rtl8723au_set_intf_ops void rtl8723au_recv_tasklet(void *priv); diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index d71641dab2cc..9f819ea8e53c 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -623,7 +623,7 @@ static struct rtw_adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, padapter->intf_stop = &usb_intf_stop; /* step init_io_priv */ - rtw_init_io_priv23a(padapter, usb_set_intf_ops); + rtw_init_io_priv23a(padapter, rtl8723au_set_intf_ops); /* step read_chip_version */ rtw_hal_read_chip_version23a(padapter); -- cgit v1.2.3 From 5827c6555ce5edfba003deedc00cc30efca600f7 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:21 +0200 Subject: staging: rtl8723au: Fold rtw_init_io_priv23a() into rtl8723au_set_intf_ops() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_io.c | 18 ------------------ drivers/staging/rtl8723au/hal/usb_ops_linux.c | 9 ++++++++- drivers/staging/rtl8723au/include/rtw_io.h | 2 -- drivers/staging/rtl8723au/include/usb_ops.h | 2 +- drivers/staging/rtl8723au/os_dep/usb_intf.c | 2 +- 5 files changed, 10 insertions(+), 23 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_io.c b/drivers/staging/rtl8723au/core/rtw_io.c index e53179fa505c..ef859fbcdd9e 100644 --- a/drivers/staging/rtl8723au/core/rtw_io.c +++ b/drivers/staging/rtl8723au/core/rtw_io.c @@ -213,21 +213,3 @@ void _rtw_write_port23a_cancel(struct rtw_adapter *adapter) if (_write_port_cancel) _write_port_cancel(pintfhdl); } - -int rtw_init_io_priv23a(struct rtw_adapter *padapter, - void (*set_intf_ops)(struct _io_ops *pops)) -{ - struct io_priv *piopriv = &padapter->iopriv; - struct intf_hdl *pintf = &piopriv->intf; - - if (set_intf_ops == NULL) - return _FAIL; - - piopriv->padapter = padapter; - pintf->padapter = padapter; - pintf->pintf_dev = adapter_to_dvobj(padapter); - - set_intf_ops(&pintf->io_ops); - - return _SUCCESS; -} diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index 0311cdf77ff1..a785bb5c2183 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -815,8 +815,15 @@ void rtl8723au_xmit_tasklet(void *priv) } } -void rtl8723au_set_intf_ops(struct _io_ops *pops) +void rtl8723au_set_intf_ops(struct rtw_adapter *padapter) { + struct io_priv *piopriv = &padapter->iopriv; + struct intf_hdl *pintf = &piopriv->intf; + struct _io_ops *pops = &pintf->io_ops; + + piopriv->padapter = padapter; + pintf->padapter = padapter; + pintf->pintf_dev = adapter_to_dvobj(padapter); memset((u8 *)pops, 0, sizeof(struct _io_ops)); diff --git a/drivers/staging/rtl8723au/include/rtw_io.h b/drivers/staging/rtl8723au/include/rtw_io.h index eea6dc27c105..0072b810ea51 100644 --- a/drivers/staging/rtl8723au/include/rtw_io.h +++ b/drivers/staging/rtl8723au/include/rtw_io.h @@ -373,8 +373,6 @@ void ioreq_write8(struct rtw_adapter *adapter, u32 addr, u8 val); void ioreq_write16(struct rtw_adapter *adapter, u32 addr, u16 val); void ioreq_write32(struct rtw_adapter *adapter, u32 addr, u32 val); -int rtw_init_io_priv23a(struct rtw_adapter *padapter, void (*set_intf_ops)(struct _io_ops *pops)); - uint alloc_io_queue(struct rtw_adapter *adapter); void free_io_queue(struct rtw_adapter *adapter); void async_bus_io(struct io_queue *pio_q); diff --git a/drivers/staging/rtl8723au/include/usb_ops.h b/drivers/staging/rtl8723au/include/usb_ops.h index 21950541a2f1..1013406c9c77 100644 --- a/drivers/staging/rtl8723au/include/usb_ops.h +++ b/drivers/staging/rtl8723au/include/usb_ops.h @@ -45,7 +45,7 @@ enum { void rtl8723au_set_hw_type(struct rtw_adapter *padapter); #define hal_set_hw_type rtl8723au_set_hw_type -void rtl8723au_set_intf_ops(struct _io_ops *pops); +void rtl8723au_set_intf_ops(struct rtw_adapter *padapter); void rtl8723au_recv_tasklet(void *priv); diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index 9f819ea8e53c..87ba2073ede4 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -623,7 +623,7 @@ static struct rtw_adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, padapter->intf_stop = &usb_intf_stop; /* step init_io_priv */ - rtw_init_io_priv23a(padapter, rtl8723au_set_intf_ops); + rtl8723au_set_intf_ops(padapter); /* step read_chip_version */ rtw_hal_read_chip_version23a(padapter); -- cgit v1.2.3 From 4427ddb22543d4718458b46432b43ed5a8b6918d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:22 +0200 Subject: staging: rtl8723au: Remove unused ioreq_* prototypes Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtw_io.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/rtl8723au/include/rtw_io.h b/drivers/staging/rtl8723au/include/rtw_io.h index 0072b810ea51..c1bb30b6b55e 100644 --- a/drivers/staging/rtl8723au/include/rtw_io.h +++ b/drivers/staging/rtl8723au/include/rtw_io.h @@ -365,14 +365,6 @@ int dbg_rtw_writeN23a(struct rtw_adapter *adapter, u32 addr ,u32 length , u8 *da void rtw_write_scsi(struct rtw_adapter *adapter, u32 cnt, u8 *pmem); -/* ioreq */ -void ioreq_read8(struct rtw_adapter *adapter, u32 addr, u8 *pval); -void ioreq_read16(struct rtw_adapter *adapter, u32 addr, u16 *pval); -void ioreq_read32(struct rtw_adapter *adapter, u32 addr, u32 *pval); -void ioreq_write8(struct rtw_adapter *adapter, u32 addr, u8 val); -void ioreq_write16(struct rtw_adapter *adapter, u32 addr, u16 val); -void ioreq_write32(struct rtw_adapter *adapter, u32 addr, u32 val); - uint alloc_io_queue(struct rtw_adapter *adapter); void free_io_queue(struct rtw_adapter *adapter); void async_bus_io(struct io_queue *pio_q); -- cgit v1.2.3 From 2e409f2450f7b99ff06865a50593b3dffcde9cd8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:23 +0200 Subject: staging: rtl8723au: Not sure what a write_scsi function is doing in a WiFi driver Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtw_io.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/rtl8723au/include/rtw_io.h b/drivers/staging/rtl8723au/include/rtw_io.h index c1bb30b6b55e..4a6bb072436c 100644 --- a/drivers/staging/rtl8723au/include/rtw_io.h +++ b/drivers/staging/rtl8723au/include/rtw_io.h @@ -121,8 +121,6 @@ struct _io_ops u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, struct recv_buf *rbuf); u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, struct xmit_buf *pmem); - u32 (*_write_scsi)(struct intf_hdl *pintfhdl,u32 cnt, u8 *pmem); - void (*_read_port_cancel)(struct intf_hdl *pintfhdl); void (*_write_port_cancel)(struct intf_hdl *pintfhdl); }; @@ -363,8 +361,6 @@ int dbg_rtw_writeN23a(struct rtw_adapter *adapter, u32 addr ,u32 length , u8 *da #define rtw_write_port_cancel(adapter) _rtw_write_port23a_cancel((adapter)) #endif /* DBG_IO */ -void rtw_write_scsi(struct rtw_adapter *adapter, u32 cnt, u8 *pmem); - uint alloc_io_queue(struct rtw_adapter *adapter); void free_io_queue(struct rtw_adapter *adapter); void async_bus_io(struct io_queue *pio_q); -- cgit v1.2.3 From fa27c805ae79875b1a4bf3eca91349d8ac41456b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:24 +0200 Subject: staging: rtl8723au: Remove _rtw_write_port_and_wait() functions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_io.c | 17 ----------------- drivers/staging/rtl8723au/include/rtw_io.h | 3 --- 2 files changed, 20 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_io.c b/drivers/staging/rtl8723au/core/rtw_io.c index ef859fbcdd9e..e862f584900a 100644 --- a/drivers/staging/rtl8723au/core/rtw_io.c +++ b/drivers/staging/rtl8723au/core/rtw_io.c @@ -185,23 +185,6 @@ u32 _rtw_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, return ret; } -u32 _rtw_write_port23a_and_wait23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, - struct xmit_buf *pxmitbuf, int timeout_ms) -{ - int ret = _SUCCESS; - struct submit_ctx sctx; - - rtw_sctx_init23a(&sctx, timeout_ms); - pxmitbuf->sctx = &sctx; - - ret = _rtw_write_port23a(adapter, addr, cnt, pxmitbuf); - - if (ret == _SUCCESS) - ret = rtw_sctx_wait23a(&sctx); - - return ret; -} - void _rtw_write_port23a_cancel(struct rtw_adapter *adapter) { void (*_write_port_cancel)(struct intf_hdl *pintfhdl); diff --git a/drivers/staging/rtl8723au/include/rtw_io.h b/drivers/staging/rtl8723au/include/rtw_io.h index 4a6bb072436c..2ab31fb6d9aa 100644 --- a/drivers/staging/rtl8723au/include/rtw_io.h +++ b/drivers/staging/rtl8723au/include/rtw_io.h @@ -310,7 +310,6 @@ int _rtw_writeN23a(struct rtw_adapter *adapter, u32 addr, u32 length, u8 *pdata) void _rtw_write_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem); u32 _rtw_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct xmit_buf *pmem); -u32 _rtw_write_port23a_and_wait23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct xmit_buf *pmem, int timeout_ms); void _rtw_write_port23a_cancel(struct rtw_adapter *adapter); #ifdef DBG_IO @@ -340,7 +339,6 @@ int dbg_rtw_writeN23a(struct rtw_adapter *adapter, u32 addr ,u32 length , u8 *da #define rtw_write_mem(adapter, addr, cnt, mem) _rtw_write_mem23a((adapter), addr, cnt, mem) #define rtw_write_port(adapter, addr, cnt, mem) _rtw_write_port23a(adapter, addr, cnt, mem) -#define rtw_write_port_and_wait(adapter, addr, cnt, mem, timeout_ms) _rtw_write_port23a_and_wait23a((adapter), (addr), (cnt), (mem), (timeout_ms)) #define rtw_write_port_cancel(adapter) _rtw_write_port23a_cancel(adapter) #else /* DBG_IO */ #define rtw_read8(adapter, addr) _rtw_read823a((adapter), (addr)) @@ -357,7 +355,6 @@ int dbg_rtw_writeN23a(struct rtw_adapter *adapter, u32 addr ,u32 length , u8 *da #define rtw_write_mem(adapter, addr, cnt, mem) _rtw_write_mem23a((adapter), (addr), (cnt), (mem)) #define rtw_write_port(adapter, addr, cnt, mem) _rtw_write_port23a((adapter), (addr), (cnt), (mem)) -#define rtw_write_port_and_wait(adapter, addr, cnt, mem, timeout_ms) _rtw_write_port23a_and_wait23a((adapter), (addr), (cnt), (mem), (timeout_ms)) #define rtw_write_port_cancel(adapter) _rtw_write_port23a_cancel((adapter)) #endif /* DBG_IO */ -- cgit v1.2.3 From c25ef5eaf1055442acf936bc9d3a6df794e59c5b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:25 +0200 Subject: staging: rtl8723au: Remove all references to unused io_queue Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/drv_types.h | 1 - drivers/staging/rtl8723au/include/rtw_io.h | 27 --------------------------- 2 files changed, 28 deletions(-) diff --git a/drivers/staging/rtl8723au/include/drv_types.h b/drivers/staging/rtl8723au/include/drv_types.h index de25e1a5eee8..99ede3fed8d5 100644 --- a/drivers/staging/rtl8723au/include/drv_types.h +++ b/drivers/staging/rtl8723au/include/drv_types.h @@ -242,7 +242,6 @@ struct rtw_adapter { struct mlme_ext_priv mlmeextpriv; struct cmd_priv cmdpriv; struct evt_priv evtpriv; - /* struct io_queue *pio_queue; */ struct io_priv iopriv; struct xmit_priv xmitpriv; struct recv_priv recvpriv; diff --git a/drivers/staging/rtl8723au/include/rtw_io.h b/drivers/staging/rtl8723au/include/rtw_io.h index 2ab31fb6d9aa..f11557cbdfd8 100644 --- a/drivers/staging/rtl8723au/include/rtw_io.h +++ b/drivers/staging/rtl8723au/include/rtw_io.h @@ -98,7 +98,6 @@ struct intf_priv; struct intf_hdl; -struct io_queue; struct _io_ops { @@ -114,8 +113,6 @@ struct _io_ops void (*_read_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); void (*_write_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); - void (*_sync_irp_protocol_rw)(struct io_queue *pio_q); - u32 (*_read_interrupt)(struct intf_hdl *pintfhdl, u32 addr); u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, struct recv_buf *rbuf); @@ -265,16 +262,6 @@ Below is the data structure used by _io_handler */ -struct io_queue { - spinlock_t lock; - struct list_head free_ioreqs; - struct list_head pending; /* The io_req list that will be served in the single protocol read/write. */ - struct list_head processing; - u8 *free_ioreqs_buf; /* 4-byte aligned */ - u8 *pallocated_free_ioreqs_buf; - struct intf_hdl intf; -}; - struct io_priv{ struct rtw_adapter *padapter; @@ -283,13 +270,6 @@ struct io_priv{ }; -uint ioreq_flush(struct rtw_adapter *adapter, struct io_queue *ioqueue); -void sync_ioreq_enqueue(struct io_req *preq,struct io_queue *ioqueue); -uint sync_ioreq_flush(struct rtw_adapter *adapter, struct io_queue *ioqueue); - -uint free_ioreq(struct io_req *preq, struct io_queue *pio_queue); -struct io_req *alloc_ioreq(struct io_queue *pio_q); - uint register_intf_hdl(u8 *dev, struct intf_hdl *pintfhdl); void unregister_intf_hdl(struct intf_hdl *pintfhdl); @@ -358,13 +338,6 @@ int dbg_rtw_writeN23a(struct rtw_adapter *adapter, u32 addr ,u32 length , u8 *da #define rtw_write_port_cancel(adapter) _rtw_write_port23a_cancel((adapter)) #endif /* DBG_IO */ -uint alloc_io_queue(struct rtw_adapter *adapter); -void free_io_queue(struct rtw_adapter *adapter); -void async_bus_io(struct io_queue *pio_q); -void bus_sync_io(struct io_queue *pio_q); -u32 _ioreq2rwmem(struct io_queue *pio_q); -void dev_power_down(struct rtw_adapter * Adapter, u8 bpwrup); - #define PlatformEFIOWrite1Byte(_a,_b,_c) \ rtw_write8(_a,_b,_c) #define PlatformEFIOWrite2Byte(_a,_b,_c) \ -- cgit v1.2.3 From a0cae30aaf13751816c408400eb6162b75ac2b4c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:26 +0200 Subject: staging: rtl8723au: Remove some leftover pointers from struct rtw_adapter Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/drv_types.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/rtl8723au/include/drv_types.h b/drivers/staging/rtl8723au/include/drv_types.h index 99ede3fed8d5..8ad2ae4a1947 100644 --- a/drivers/staging/rtl8723au/include/drv_types.h +++ b/drivers/staging/rtl8723au/include/drv_types.h @@ -275,11 +275,6 @@ struct rtw_adapter { u8 init_adpt_in_progress; u8 bHaltInProgress; - void *cmdThread; - void *evtThread; - void *xmitThread; - void *recvThread; - void (*intf_start)(struct rtw_adapter *adapter); void (*intf_stop)(struct rtw_adapter *adapter); -- cgit v1.2.3 From 4d593d22b99af7ca1a3621451b172f1516ea5350 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:27 +0200 Subject: staging: rtl8723au: bRxRSSIDisplay is always set to zero Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 25 ------------------------- drivers/staging/rtl8723au/include/drv_types.h | 1 - drivers/staging/rtl8723au/os_dep/os_intfs.c | 2 -- 3 files changed, 28 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 40fcf36d54bd..abaedd21fe03 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -5533,28 +5533,6 @@ void mlmeext_sta_del_event_callback23a(struct rtw_adapter *padapter) } } -/**************************************************************************** - -Following are the functions for the timer handlers - -*****************************************************************************/ -static void linked23a_rx_sig_stren_disp(struct rtw_adapter *padapter) -{ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - u8 mac_id; - int UndecoratedSmoothedPWDB; - if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) - mac_id = 0; - else if ((pmlmeinfo->state&0x03) == _HW_STATE_AP_) - mac_id = 2; - - rtw_hal_get_def_var23a(padapter, HW_DEF_RA_INFO_DUMP,&mac_id); - - rtw_hal_get_def_var23a(padapter, HAL_DEF_UNDERCORATEDSMOOTHEDPWDB, &UndecoratedSmoothedPWDB); - DBG_8723A("UndecoratedSmoothedPWDB:%d\n", UndecoratedSmoothedPWDB); -} - static u8 chk_ap_is_alive(struct rtw_adapter *padapter, struct sta_info *psta) { u8 ret = false; @@ -5579,9 +5557,6 @@ void linked_status_chk23a(struct rtw_adapter *padapter) struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct sta_priv *pstapriv = &padapter->stapriv; - if (padapter->bRxRSSIDisplay) - linked23a_rx_sig_stren_disp(padapter); - rtw_hal_sreset_linked_status_check23a(padapter); if (is_client_associated_to_ap23a(padapter)) diff --git a/drivers/staging/rtl8723au/include/drv_types.h b/drivers/staging/rtl8723au/include/drv_types.h index 8ad2ae4a1947..b82d5a1fe602 100644 --- a/drivers/staging/rtl8723au/include/drv_types.h +++ b/drivers/staging/rtl8723au/include/drv_types.h @@ -300,7 +300,6 @@ struct rtw_adapter { u8 bBTFWReady; u8 bReadPortCancel; u8 bWritePortCancel; - u8 bRxRSSIDisplay; /* The driver will show the desired chan nor when this flag is 1. */ u8 bNotifyChannelChange; struct rtw_adapter *pbuddy_adapter; diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index 4347896e1df1..dd401e6ce415 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -424,7 +424,6 @@ static u8 rtw_init_default_value(struct rtw_adapter *padapter) /* misc. */ padapter->bReadPortCancel = false; padapter->bWritePortCancel = false; - padapter->bRxRSSIDisplay = 0; padapter->bNotifyChannelChange = 0; return ret; } @@ -439,7 +438,6 @@ u8 rtw_reset_drv_sw23a(struct rtw_adapter *padapter) rtw_hal_def_value_init23a(padapter); padapter->bReadPortCancel = false; padapter->bWritePortCancel = false; - padapter->bRxRSSIDisplay = 0; pmlmepriv->scan_interval = SCAN_INTERVAL;/* 30*2 sec = 60sec */ padapter->xmitpriv.tx_pkts = 0; -- cgit v1.2.3 From 1dbe119b82b7902d0626347a455319f9004166e4 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:28 +0200 Subject: staging: rtl8723au: Remove unused struct rtw_adapter * from struct io_priv Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_ops_linux.c | 1 - drivers/staging/rtl8723au/include/rtw_io.h | 4 ---- 2 files changed, 5 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index a785bb5c2183..1a67255887af 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -821,7 +821,6 @@ void rtl8723au_set_intf_ops(struct rtw_adapter *padapter) struct intf_hdl *pintf = &piopriv->intf; struct _io_ops *pops = &pintf->io_ops; - piopriv->padapter = padapter; pintf->padapter = padapter; pintf->pintf_dev = adapter_to_dvobj(padapter); diff --git a/drivers/staging/rtl8723au/include/rtw_io.h b/drivers/staging/rtl8723au/include/rtw_io.h index f11557cbdfd8..f0f97b447d9e 100644 --- a/drivers/staging/rtl8723au/include/rtw_io.h +++ b/drivers/staging/rtl8723au/include/rtw_io.h @@ -263,11 +263,7 @@ Below is the data structure used by _io_handler */ struct io_priv{ - - struct rtw_adapter *padapter; - struct intf_hdl intf; - }; uint register_intf_hdl(u8 *dev, struct intf_hdl *pintfhdl); -- cgit v1.2.3 From 520106f61e164f07f88844ab20a5c709b9716dd4 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:29 +0200 Subject: staging: rtl8723au: Get rid of struct io_priv No point wrapping struct intf_hdl into struct io_priv just for the sake of it. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_io.c | 40 ++++++++++----------------- drivers/staging/rtl8723au/hal/usb_halinit.c | 2 +- drivers/staging/rtl8723au/hal/usb_ops_linux.c | 3 +- drivers/staging/rtl8723au/include/drv_types.h | 2 +- drivers/staging/rtl8723au/include/rtw_io.h | 10 ------- drivers/staging/rtl8723au/os_dep/usb_intf.c | 1 - 6 files changed, 17 insertions(+), 41 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_io.c b/drivers/staging/rtl8723au/core/rtw_io.c index e862f584900a..442a86b69e04 100644 --- a/drivers/staging/rtl8723au/core/rtw_io.c +++ b/drivers/staging/rtl8723au/core/rtw_io.c @@ -44,8 +44,7 @@ jackson@realtek.com.tw u8 _rtw_read823a(struct rtw_adapter *adapter, u32 addr) { u8 r_val; - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; + struct intf_hdl *pintfhdl = &adapter->intf; r_val = pintfhdl->io_ops._read8(pintfhdl, addr); @@ -55,8 +54,7 @@ u8 _rtw_read823a(struct rtw_adapter *adapter, u32 addr) u16 _rtw_read1623a(struct rtw_adapter *adapter, u32 addr) { u16 r_val; - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; + struct intf_hdl *pintfhdl = &adapter->intf; r_val = pintfhdl->io_ops._read16(pintfhdl, addr); @@ -66,8 +64,7 @@ u16 _rtw_read1623a(struct rtw_adapter *adapter, u32 addr) u32 _rtw_read3223a(struct rtw_adapter *adapter, u32 addr) { u32 r_val; - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; + struct intf_hdl *pintfhdl = &adapter->intf; r_val = pintfhdl->io_ops._read32(pintfhdl, addr); @@ -76,8 +73,7 @@ u32 _rtw_read3223a(struct rtw_adapter *adapter, u32 addr) int _rtw_write823a(struct rtw_adapter *adapter, u32 addr, u8 val) { - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; + struct intf_hdl *pintfhdl = &adapter->intf; int ret; ret = pintfhdl->io_ops._write8(pintfhdl, addr, val); @@ -87,8 +83,7 @@ int _rtw_write823a(struct rtw_adapter *adapter, u32 addr, u8 val) int _rtw_write1623a(struct rtw_adapter *adapter, u32 addr, u16 val) { - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; + struct intf_hdl *pintfhdl = &adapter->intf; int ret; val = cpu_to_le16(val); @@ -96,10 +91,10 @@ int _rtw_write1623a(struct rtw_adapter *adapter, u32 addr, u16 val) return RTW_STATUS_CODE23a(ret); } + int _rtw_write3223a(struct rtw_adapter *adapter, u32 addr, u32 val) { - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; + struct intf_hdl *pintfhdl = &adapter->intf; int ret; val = cpu_to_le32(val); @@ -110,8 +105,7 @@ int _rtw_write3223a(struct rtw_adapter *adapter, u32 addr, u32 val) int _rtw_writeN23a(struct rtw_adapter *adapter, u32 addr , u32 length , u8 *pdata) { - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = (struct intf_hdl*)&pio_priv->intf; + struct intf_hdl *pintfhdl = &adapter->intf; int ret; ret = pintfhdl->io_ops._writeN(pintfhdl, addr, length, pdata); @@ -120,8 +114,7 @@ int _rtw_writeN23a(struct rtw_adapter *adapter, u32 addr , u32 length , u8 *pdat } void _rtw_read_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem) { - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; + struct intf_hdl *pintfhdl = &adapter->intf; if ((adapter->bDriverStopped == true) || (adapter->bSurpriseRemoved == true)) { @@ -137,8 +130,7 @@ void _rtw_read_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem) void _rtw_write_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem) { - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; + struct intf_hdl *pintfhdl = &adapter->intf; pintfhdl->io_ops._write_mem(pintfhdl, addr, cnt, pmem); } @@ -146,8 +138,7 @@ void _rtw_write_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem) void _rtw_read_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct recv_buf *rbuf) { - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; + struct intf_hdl *pintfhdl = &adapter->intf; if ((adapter->bDriverStopped == true) || (adapter->bSurpriseRemoved == true)) { @@ -164,8 +155,7 @@ void _rtw_read_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, void _rtw_read_port23a_cancel(struct rtw_adapter *adapter) { void (*_read_port_cancel)(struct intf_hdl *pintfhdl); - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; + struct intf_hdl *pintfhdl = &adapter->intf; _read_port_cancel = pintfhdl->io_ops._read_port_cancel; @@ -176,8 +166,7 @@ void _rtw_read_port23a_cancel(struct rtw_adapter *adapter) u32 _rtw_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct xmit_buf *xbuf) { - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; + struct intf_hdl *pintfhdl = &adapter->intf; u32 ret = _SUCCESS; ret = pintfhdl->io_ops._write_port(pintfhdl, addr, cnt, xbuf); @@ -188,8 +177,7 @@ u32 _rtw_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, void _rtw_write_port23a_cancel(struct rtw_adapter *adapter) { void (*_write_port_cancel)(struct intf_hdl *pintfhdl); - struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &pio_priv->intf; + struct intf_hdl *pintfhdl = &adapter->intf; _write_port_cancel = pintfhdl->io_ops._write_port_cancel; diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 0a6e343373ff..f5b1b10bed58 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1227,7 +1227,7 @@ static unsigned int rtl8723au_inirp_init(struct rtw_adapter *Adapter) u8 i; struct recv_buf *precvbuf; uint status; - struct intf_hdl *pintfhdl = &Adapter->iopriv.intf; + struct intf_hdl *pintfhdl = &Adapter->intf; struct recv_priv *precvpriv = &Adapter->recvpriv; u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, struct recv_buf *rbuf); diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index 1a67255887af..c861a791f43d 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -817,8 +817,7 @@ void rtl8723au_xmit_tasklet(void *priv) void rtl8723au_set_intf_ops(struct rtw_adapter *padapter) { - struct io_priv *piopriv = &padapter->iopriv; - struct intf_hdl *pintf = &piopriv->intf; + struct intf_hdl *pintf = &padapter->intf; struct _io_ops *pops = &pintf->io_ops; pintf->padapter = padapter; diff --git a/drivers/staging/rtl8723au/include/drv_types.h b/drivers/staging/rtl8723au/include/drv_types.h index b82d5a1fe602..1e06a37e8af5 100644 --- a/drivers/staging/rtl8723au/include/drv_types.h +++ b/drivers/staging/rtl8723au/include/drv_types.h @@ -242,7 +242,7 @@ struct rtw_adapter { struct mlme_ext_priv mlmeextpriv; struct cmd_priv cmdpriv; struct evt_priv evtpriv; - struct io_priv iopriv; + struct intf_hdl intf; struct xmit_priv xmitpriv; struct recv_priv recvpriv; struct sta_priv stapriv; diff --git a/drivers/staging/rtl8723au/include/rtw_io.h b/drivers/staging/rtl8723au/include/rtw_io.h index f0f97b447d9e..86ecbea77ed3 100644 --- a/drivers/staging/rtl8723au/include/rtw_io.h +++ b/drivers/staging/rtl8723au/include/rtw_io.h @@ -256,16 +256,6 @@ struct reg_protocol_wt { }; - -/* -Below is the data structure used by _io_handler - -*/ - -struct io_priv{ - struct intf_hdl intf; -}; - uint register_intf_hdl(u8 *dev, struct intf_hdl *pintfhdl); void unregister_intf_hdl(struct intf_hdl *pintfhdl); diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index 87ba2073ede4..797393a70810 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -622,7 +622,6 @@ static struct rtw_adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, padapter->intf_start = &usb_intf_start; padapter->intf_stop = &usb_intf_stop; - /* step init_io_priv */ rtl8723au_set_intf_ops(padapter); /* step read_chip_version */ -- cgit v1.2.3 From ad0fb71b20524cf48db036d6909fef9e1456011b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:30 +0200 Subject: staging: rtl8723au: Remove unused pintf_dev entry from struct intf_hdl Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_ops_linux.c | 1 - drivers/staging/rtl8723au/include/rtw_io.h | 2 -- 2 files changed, 3 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index c861a791f43d..4b23e8a6e194 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -821,7 +821,6 @@ void rtl8723au_set_intf_ops(struct rtw_adapter *padapter) struct _io_ops *pops = &pintf->io_ops; pintf->padapter = padapter; - pintf->pintf_dev = adapter_to_dvobj(padapter); memset((u8 *)pops, 0, sizeof(struct _io_ops)); diff --git a/drivers/staging/rtl8723au/include/rtw_io.h b/drivers/staging/rtl8723au/include/rtw_io.h index 86ecbea77ed3..2abc24d429cd 100644 --- a/drivers/staging/rtl8723au/include/rtw_io.h +++ b/drivers/staging/rtl8723au/include/rtw_io.h @@ -137,10 +137,8 @@ struct io_req { struct intf_hdl { struct rtw_adapter *padapter; - struct dvobj_priv *pintf_dev;/* pointer to &(padapter->dvobjpriv); */ struct _io_ops io_ops; - }; struct reg_protocol_rd { -- cgit v1.2.3 From 45c64aa030f5b2674f4ab25e336d22a7029863b1 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:31 +0200 Subject: staging: rtl8723au: Pass a struct rtw_adapter * to the USB functions This lowers the dependency on struct intf_hdl so we can start getting rid of if. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_io.c | 30 +++++++------- drivers/staging/rtl8723au/hal/usb_halinit.c | 8 ++-- drivers/staging/rtl8723au/hal/usb_ops_linux.c | 49 +++++++++++++---------- drivers/staging/rtl8723au/include/rtw_io.h | 28 ++++++------- drivers/staging/rtl8723au/include/usb_ops_linux.h | 12 +++--- drivers/staging/rtl8723au/os_dep/usb_ops_linux.c | 15 +++---- 6 files changed, 73 insertions(+), 69 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_io.c b/drivers/staging/rtl8723au/core/rtw_io.c index 442a86b69e04..0f424f946dbb 100644 --- a/drivers/staging/rtl8723au/core/rtw_io.c +++ b/drivers/staging/rtl8723au/core/rtw_io.c @@ -46,7 +46,7 @@ u8 _rtw_read823a(struct rtw_adapter *adapter, u32 addr) u8 r_val; struct intf_hdl *pintfhdl = &adapter->intf; - r_val = pintfhdl->io_ops._read8(pintfhdl, addr); + r_val = pintfhdl->io_ops._read8(adapter, addr); return r_val; } @@ -56,7 +56,7 @@ u16 _rtw_read1623a(struct rtw_adapter *adapter, u32 addr) u16 r_val; struct intf_hdl *pintfhdl = &adapter->intf; - r_val = pintfhdl->io_ops._read16(pintfhdl, addr); + r_val = pintfhdl->io_ops._read16(adapter, addr); return le16_to_cpu(r_val); } @@ -66,7 +66,7 @@ u32 _rtw_read3223a(struct rtw_adapter *adapter, u32 addr) u32 r_val; struct intf_hdl *pintfhdl = &adapter->intf; - r_val = pintfhdl->io_ops._read32(pintfhdl, addr); + r_val = pintfhdl->io_ops._read32(adapter, addr); return le32_to_cpu(r_val); } @@ -76,7 +76,7 @@ int _rtw_write823a(struct rtw_adapter *adapter, u32 addr, u8 val) struct intf_hdl *pintfhdl = &adapter->intf; int ret; - ret = pintfhdl->io_ops._write8(pintfhdl, addr, val); + ret = pintfhdl->io_ops._write8(adapter, addr, val); return RTW_STATUS_CODE23a(ret); } @@ -87,7 +87,7 @@ int _rtw_write1623a(struct rtw_adapter *adapter, u32 addr, u16 val) int ret; val = cpu_to_le16(val); - ret = pintfhdl->io_ops._write16(pintfhdl, addr, val); + ret = pintfhdl->io_ops._write16(adapter, addr, val); return RTW_STATUS_CODE23a(ret); } @@ -98,7 +98,7 @@ int _rtw_write3223a(struct rtw_adapter *adapter, u32 addr, u32 val) int ret; val = cpu_to_le32(val); - ret = pintfhdl->io_ops._write32(pintfhdl, addr, val); + ret = pintfhdl->io_ops._write32(adapter, addr, val); return RTW_STATUS_CODE23a(ret); } @@ -108,7 +108,7 @@ int _rtw_writeN23a(struct rtw_adapter *adapter, u32 addr , u32 length , u8 *pdat struct intf_hdl *pintfhdl = &adapter->intf; int ret; - ret = pintfhdl->io_ops._writeN(pintfhdl, addr, length, pdata); + ret = pintfhdl->io_ops._writeN(adapter, addr, length, pdata); return RTW_STATUS_CODE23a(ret); } @@ -125,14 +125,14 @@ void _rtw_read_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem) return; } - pintfhdl->io_ops._read_mem(pintfhdl, addr, cnt, pmem); + pintfhdl->io_ops._read_mem(adapter, addr, cnt, pmem); } void _rtw_write_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem) { struct intf_hdl *pintfhdl = &adapter->intf; - pintfhdl->io_ops._write_mem(pintfhdl, addr, cnt, pmem); + pintfhdl->io_ops._write_mem(adapter, addr, cnt, pmem); } void _rtw_read_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, @@ -149,18 +149,18 @@ void _rtw_read_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, return; } - pintfhdl->io_ops._read_port(pintfhdl, addr, cnt, rbuf); + pintfhdl->io_ops._read_port(adapter, addr, cnt, rbuf); } void _rtw_read_port23a_cancel(struct rtw_adapter *adapter) { - void (*_read_port_cancel)(struct intf_hdl *pintfhdl); + void (*_read_port_cancel)(struct rtw_adapter *adapter); struct intf_hdl *pintfhdl = &adapter->intf; _read_port_cancel = pintfhdl->io_ops._read_port_cancel; if (_read_port_cancel) - _read_port_cancel(pintfhdl); + _read_port_cancel(adapter); } u32 _rtw_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, @@ -169,18 +169,18 @@ u32 _rtw_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct intf_hdl *pintfhdl = &adapter->intf; u32 ret = _SUCCESS; - ret = pintfhdl->io_ops._write_port(pintfhdl, addr, cnt, xbuf); + ret = pintfhdl->io_ops._write_port(adapter, addr, cnt, xbuf); return ret; } void _rtw_write_port23a_cancel(struct rtw_adapter *adapter) { - void (*_write_port_cancel)(struct intf_hdl *pintfhdl); + void (*_write_port_cancel)(struct rtw_adapter *adapter); struct intf_hdl *pintfhdl = &adapter->intf; _write_port_cancel = pintfhdl->io_ops._write_port_cancel; if (_write_port_cancel) - _write_port_cancel(pintfhdl); + _write_port_cancel(adapter); } diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index f5b1b10bed58..1dd2a08a0963 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1229,9 +1229,9 @@ static unsigned int rtl8723au_inirp_init(struct rtw_adapter *Adapter) uint status; struct intf_hdl *pintfhdl = &Adapter->intf; struct recv_priv *precvpriv = &Adapter->recvpriv; - u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, + u32 (*_read_port)(struct rtw_adapter *padapter, u32 addr, u32 cnt, struct recv_buf *rbuf); - u32 (*_read_interrupt)(struct intf_hdl *pintfhdl, u32 addr); + u32 (*_read_interrupt)(struct rtw_adapter *padapter, u32 addr); struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); _read_port = pintfhdl->io_ops._read_port; @@ -1245,7 +1245,7 @@ static unsigned int rtl8723au_inirp_init(struct rtw_adapter *Adapter) /* issue Rx irp to receive data */ precvbuf = (struct recv_buf *)precvpriv->precv_buf; for (i = 0; i < NR_RECVBUFF; i++) { - if (_read_port(pintfhdl, precvpriv->ff_hwaddr, 0, precvbuf) == + if (_read_port(Adapter, precvpriv->ff_hwaddr, 0, precvbuf) == false) { RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("usb_rx_init: usb_read_port error\n")); @@ -1256,7 +1256,7 @@ static unsigned int rtl8723au_inirp_init(struct rtw_adapter *Adapter) precvpriv->free_recv_buf_queue_cnt--; } _read_interrupt = pintfhdl->io_ops._read_interrupt; - if (_read_interrupt(pintfhdl, RECV_INT_IN_ADDR) == false) { + if (_read_interrupt(Adapter, RECV_INT_IN_ADDR) == false) { RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("usb_rx_init: usb_read_interrupt error\n")); status = _FAIL; diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index 4b23e8a6e194..29e67a8e85cb 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -22,9 +22,10 @@ #include #include -static int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u8 request, u16 value, u16 index, void *pdata, u16 len, u8 requesttype) +static int usbctrl_vendorreq(struct rtw_adapter *padapter, u8 request, + u16 value, u16 index, void *pdata, u16 len, + u8 requesttype) { - struct rtw_adapter *padapter = pintfhdl->padapter ; struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter); struct usb_device *udev = pdvobjpriv->pusbdev; @@ -124,7 +125,7 @@ exit: return status; } -static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) +static u8 usb_read8(struct rtw_adapter *padapter, u32 addr) { u8 request; u8 requesttype; @@ -140,12 +141,13 @@ static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) wvalue = (u16)(addr&0x0000ffff); len = 1; - usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + usbctrl_vendorreq(padapter, request, wvalue, index, &data, + len, requesttype); return data; } -static u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr) +static u16 usb_read16(struct rtw_adapter *padapter, u32 addr) { u8 request; u8 requesttype; @@ -161,12 +163,13 @@ static u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr) wvalue = (u16)(addr&0x0000ffff); len = 2; - usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + usbctrl_vendorreq(padapter, request, wvalue, index, &data, + len, requesttype); return data; } -static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) +static u32 usb_read32(struct rtw_adapter *padapter, u32 addr) { u8 request; u8 requesttype; @@ -182,12 +185,13 @@ static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) wvalue = (u16)(addr&0x0000ffff); len = 4; - usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + usbctrl_vendorreq(padapter, request, wvalue, index, &data, + len, requesttype); return data; } -static int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) +static int usb_write8(struct rtw_adapter *padapter, u32 addr, u8 val) { u8 request; u8 requesttype; @@ -206,12 +210,13 @@ static int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) data = val; - ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + ret = usbctrl_vendorreq(padapter, request, wvalue, index, &data, + len, requesttype); return ret; } -static int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) +static int usb_write16(struct rtw_adapter *padapter, u32 addr, u16 val) { u8 request; u8 requesttype; @@ -230,11 +235,12 @@ static int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) data = val; - ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + ret = usbctrl_vendorreq(padapter, request, wvalue, index, &data, + len, requesttype); return ret; } -static int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) +static int usb_write32(struct rtw_adapter *padapter, u32 addr, u32 val) { u8 request; u8 requesttype; @@ -252,12 +258,14 @@ static int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) len = 4; data = val; - ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + ret = usbctrl_vendorreq(padapter, request, wvalue, index, &data, + len, requesttype); return ret; } -static int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata) +static int usb_writeN(struct rtw_adapter *padapter, + u32 addr, u32 length, u8 *pdata) { u8 request; u8 requesttype; @@ -273,9 +281,10 @@ static int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata wvalue = (u16)(addr&0x0000ffff); len = length; - memcpy(buf, pdata, len); + memcpy(buf, pdata, len); - ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, buf, len, requesttype); + ret = usbctrl_vendorreq(padapter, request, wvalue, index, buf, + len, requesttype); return ret; } @@ -423,12 +432,11 @@ urb_submit: } } -static u32 usb_read_interrupt(struct intf_hdl *pintfhdl, u32 addr) +static u32 usb_read_interrupt(struct rtw_adapter *adapter, u32 addr) { int err; unsigned int pipe; u32 ret = _SUCCESS; - struct rtw_adapter *adapter = pintfhdl->padapter; struct dvobj_priv *pdvobj = adapter_to_dvobj(adapter); struct recv_priv *precvpriv = &adapter->recvpriv; struct usb_device *pusbd = pdvobj->pusbdev; @@ -720,7 +728,7 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) } } -static u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, +static u32 usb_read_port(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct recv_buf *precvbuf) { int err; @@ -729,7 +737,6 @@ static u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, unsigned long alignment = 0; u32 ret = _SUCCESS; struct urb *purb = NULL; - struct rtw_adapter *adapter = pintfhdl->padapter; struct dvobj_priv *pdvobj = adapter_to_dvobj(adapter); struct recv_priv *precvpriv = &adapter->recvpriv; struct usb_device *pusbd = pdvobj->pusbdev; diff --git a/drivers/staging/rtl8723au/include/rtw_io.h b/drivers/staging/rtl8723au/include/rtw_io.h index 2abc24d429cd..7b710d748516 100644 --- a/drivers/staging/rtl8723au/include/rtw_io.h +++ b/drivers/staging/rtl8723au/include/rtw_io.h @@ -101,25 +101,25 @@ struct intf_hdl; struct _io_ops { - u8 (*_read8)(struct intf_hdl *pintfhdl, u32 addr); - u16 (*_read16)(struct intf_hdl *pintfhdl, u32 addr); - u32 (*_read32)(struct intf_hdl *pintfhdl, u32 addr); + u8 (*_read8)(struct rtw_adapter *adapter, u32 addr); + u16 (*_read16)(struct rtw_adapter *adapter, u32 addr); + u32 (*_read32)(struct rtw_adapter *adapter, u32 addr); - int (*_write8)(struct intf_hdl *pintfhdl, u32 addr, u8 val); - int (*_write16)(struct intf_hdl *pintfhdl, u32 addr, u16 val); - int (*_write32)(struct intf_hdl *pintfhdl, u32 addr, u32 val); - int (*_writeN)(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata); + int (*_write8)(struct rtw_adapter *adapter, u32 addr, u8 val); + int (*_write16)(struct rtw_adapter *adapter, u32 addr, u16 val); + int (*_write32)(struct rtw_adapter *adapter, u32 addr, u32 val); + int (*_writeN)(struct rtw_adapter *adapter, u32 addr, u32 length, u8 *pdata); - void (*_read_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); - void (*_write_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); + void (*_read_mem)(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem); + void (*_write_mem)(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem); - u32 (*_read_interrupt)(struct intf_hdl *pintfhdl, u32 addr); + u32 (*_read_interrupt)(struct rtw_adapter *adapter, u32 addr); - u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, struct recv_buf *rbuf); - u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, struct xmit_buf *pmem); + u32 (*_read_port)(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct recv_buf *rbuf); + u32 (*_write_port)(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct xmit_buf *pmem); - void (*_read_port_cancel)(struct intf_hdl *pintfhdl); - void (*_write_port_cancel)(struct intf_hdl *pintfhdl); + void (*_read_port_cancel)(struct rtw_adapter *adapter); + void (*_write_port_cancel)(struct rtw_adapter *adapter); }; struct io_req { diff --git a/drivers/staging/rtl8723au/include/usb_ops_linux.h b/drivers/staging/rtl8723au/include/usb_ops_linux.h index 8f5c59eace5a..0eb33e01c78c 100644 --- a/drivers/staging/rtl8723au/include/usb_ops_linux.h +++ b/drivers/staging/rtl8723au/include/usb_ops_linux.h @@ -34,13 +34,13 @@ unsigned int ffaddr2pipehdl23a(struct dvobj_priv *pdvobj, u32 addr); -void usb_read_mem23a(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem); -void usb_write_mem23a(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem); +void usb_read_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *rmem); +void usb_write_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *wmem); -void usb_read_port_cancel23a(struct intf_hdl *pintfhdl); +void usb_read_port_cancel23a(struct rtw_adapter *adapter); -u32 usb_write_port23a(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, - struct xmit_buf *wmem); -void usb_write_port23a_cancel(struct intf_hdl *pintfhdl); +u32 usb_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, + struct xmit_buf *wmem); +void usb_write_port23a_cancel(struct rtw_adapter *adapter); #endif diff --git a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c index c49160e477d8..b88f72f0f06b 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c @@ -41,18 +41,17 @@ struct zero_bulkout_context { void *padapter; }; -void usb_read_mem23a(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) +void usb_read_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *rmem) { } -void usb_write_mem23a(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem) +void usb_write_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *wmem) { } -void usb_read_port_cancel23a(struct intf_hdl *pintfhdl) +void usb_read_port_cancel23a(struct rtw_adapter *padapter) { struct recv_buf *precvbuf; - struct rtw_adapter *padapter = pintfhdl->padapter; int i; precvbuf = (struct recv_buf *)padapter->recvpriv.precv_buf; @@ -161,11 +160,10 @@ check_completion: tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); } -u32 usb_write_port23a(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, - struct xmit_buf *pxmitbuf) +u32 usb_write_port23a(struct rtw_adapter *padapter, u32 addr, u32 cnt, + struct xmit_buf *pxmitbuf) { struct urb *purb = NULL; - struct rtw_adapter *padapter = (struct rtw_adapter *)pintfhdl->padapter; struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter); struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct xmit_frame *pxmitframe = (struct xmit_frame *)pxmitbuf->priv_data; @@ -255,9 +253,8 @@ exit: return ret; } -void usb_write_port23a_cancel(struct intf_hdl *pintfhdl) +void usb_write_port23a_cancel(struct rtw_adapter *padapter) { - struct rtw_adapter *padapter = pintfhdl->padapter; struct xmit_buf *pxmitbuf; struct list_head *plist; int j; -- cgit v1.2.3 From 64cb819b06b79bf9b47d9bd6adc5d074b9336d00 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:32 +0200 Subject: staging: rtl8723au: Remove unused rtw_adapter * from struct intf_hdl struct intf_hdl is now purely a wrapper around struct _io_ops, so we can get rid of it in the next patch. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_ops_linux.c | 2 -- drivers/staging/rtl8723au/include/rtw_io.h | 2 -- 2 files changed, 4 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index 29e67a8e85cb..b5332888226c 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -827,8 +827,6 @@ void rtl8723au_set_intf_ops(struct rtw_adapter *padapter) struct intf_hdl *pintf = &padapter->intf; struct _io_ops *pops = &pintf->io_ops; - pintf->padapter = padapter; - memset((u8 *)pops, 0, sizeof(struct _io_ops)); pops->_read8 = &usb_read8; diff --git a/drivers/staging/rtl8723au/include/rtw_io.h b/drivers/staging/rtl8723au/include/rtw_io.h index 7b710d748516..54f930deda3c 100644 --- a/drivers/staging/rtl8723au/include/rtw_io.h +++ b/drivers/staging/rtl8723au/include/rtw_io.h @@ -136,8 +136,6 @@ struct io_req { }; struct intf_hdl { - struct rtw_adapter *padapter; - struct _io_ops io_ops; }; -- cgit v1.2.3 From b939da9c0dfe292766efe9921429d7584c8dd60a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:33 +0200 Subject: staging: rtl8723au: Remove another two unused prototypes Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtw_io.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/rtl8723au/include/rtw_io.h b/drivers/staging/rtl8723au/include/rtw_io.h index 54f930deda3c..745d0ef25af3 100644 --- a/drivers/staging/rtl8723au/include/rtw_io.h +++ b/drivers/staging/rtl8723au/include/rtw_io.h @@ -252,9 +252,6 @@ struct reg_protocol_wt { }; -uint register_intf_hdl(u8 *dev, struct intf_hdl *pintfhdl); -void unregister_intf_hdl(struct intf_hdl *pintfhdl); - void _rtw_attrib_read(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem); void _rtw_attrib_write(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem); -- cgit v1.2.3 From 28c71e23d2b43a2e687edd9342dca24a21b777e6 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:34 +0200 Subject: staging: rtl8723au: Eliminate struct intf_hdl Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_io.c | 54 +++++++++++++-------------- drivers/staging/rtl8723au/hal/usb_halinit.c | 6 +-- drivers/staging/rtl8723au/hal/usb_ops_linux.c | 3 +- drivers/staging/rtl8723au/include/drv_types.h | 2 +- drivers/staging/rtl8723au/include/rtw_io.h | 5 --- 5 files changed, 32 insertions(+), 38 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_io.c b/drivers/staging/rtl8723au/core/rtw_io.c index 0f424f946dbb..01022113950a 100644 --- a/drivers/staging/rtl8723au/core/rtw_io.c +++ b/drivers/staging/rtl8723au/core/rtw_io.c @@ -44,9 +44,9 @@ jackson@realtek.com.tw u8 _rtw_read823a(struct rtw_adapter *adapter, u32 addr) { u8 r_val; - struct intf_hdl *pintfhdl = &adapter->intf; + struct _io_ops *io_ops = &adapter->io_ops; - r_val = pintfhdl->io_ops._read8(adapter, addr); + r_val = io_ops->_read8(adapter, addr); return r_val; } @@ -54,9 +54,9 @@ u8 _rtw_read823a(struct rtw_adapter *adapter, u32 addr) u16 _rtw_read1623a(struct rtw_adapter *adapter, u32 addr) { u16 r_val; - struct intf_hdl *pintfhdl = &adapter->intf; + struct _io_ops *io_ops = &adapter->io_ops; - r_val = pintfhdl->io_ops._read16(adapter, addr); + r_val = io_ops->_read16(adapter, addr); return le16_to_cpu(r_val); } @@ -64,57 +64,57 @@ u16 _rtw_read1623a(struct rtw_adapter *adapter, u32 addr) u32 _rtw_read3223a(struct rtw_adapter *adapter, u32 addr) { u32 r_val; - struct intf_hdl *pintfhdl = &adapter->intf; + struct _io_ops *io_ops = &adapter->io_ops; - r_val = pintfhdl->io_ops._read32(adapter, addr); + r_val = io_ops->_read32(adapter, addr); return le32_to_cpu(r_val); } int _rtw_write823a(struct rtw_adapter *adapter, u32 addr, u8 val) { - struct intf_hdl *pintfhdl = &adapter->intf; + struct _io_ops *io_ops = &adapter->io_ops; int ret; - ret = pintfhdl->io_ops._write8(adapter, addr, val); + ret = io_ops->_write8(adapter, addr, val); return RTW_STATUS_CODE23a(ret); } int _rtw_write1623a(struct rtw_adapter *adapter, u32 addr, u16 val) { - struct intf_hdl *pintfhdl = &adapter->intf; + struct _io_ops *io_ops = &adapter->io_ops; int ret; val = cpu_to_le16(val); - ret = pintfhdl->io_ops._write16(adapter, addr, val); + ret = io_ops->_write16(adapter, addr, val); return RTW_STATUS_CODE23a(ret); } int _rtw_write3223a(struct rtw_adapter *adapter, u32 addr, u32 val) { - struct intf_hdl *pintfhdl = &adapter->intf; + struct _io_ops *io_ops = &adapter->io_ops; int ret; val = cpu_to_le32(val); - ret = pintfhdl->io_ops._write32(adapter, addr, val); + ret = io_ops->_write32(adapter, addr, val); return RTW_STATUS_CODE23a(ret); } int _rtw_writeN23a(struct rtw_adapter *adapter, u32 addr , u32 length , u8 *pdata) { - struct intf_hdl *pintfhdl = &adapter->intf; + struct _io_ops *io_ops = &adapter->io_ops; int ret; - ret = pintfhdl->io_ops._writeN(adapter, addr, length, pdata); + ret = io_ops->_writeN(adapter, addr, length, pdata); return RTW_STATUS_CODE23a(ret); } void _rtw_read_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem) { - struct intf_hdl *pintfhdl = &adapter->intf; + struct _io_ops *io_ops = &adapter->io_ops; if ((adapter->bDriverStopped == true) || (adapter->bSurpriseRemoved == true)) { @@ -125,20 +125,20 @@ void _rtw_read_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem) return; } - pintfhdl->io_ops._read_mem(adapter, addr, cnt, pmem); + io_ops->_read_mem(adapter, addr, cnt, pmem); } void _rtw_write_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem) { - struct intf_hdl *pintfhdl = &adapter->intf; + struct _io_ops *io_ops = &adapter->io_ops; - pintfhdl->io_ops._write_mem(adapter, addr, cnt, pmem); + io_ops->_write_mem(adapter, addr, cnt, pmem); } void _rtw_read_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, - struct recv_buf *rbuf) + struct recv_buf *rbuf) { - struct intf_hdl *pintfhdl = &adapter->intf; + struct _io_ops *io_ops = &adapter->io_ops; if ((adapter->bDriverStopped == true) || (adapter->bSurpriseRemoved == true)) { @@ -149,15 +149,15 @@ void _rtw_read_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, return; } - pintfhdl->io_ops._read_port(adapter, addr, cnt, rbuf); + io_ops->_read_port(adapter, addr, cnt, rbuf); } void _rtw_read_port23a_cancel(struct rtw_adapter *adapter) { void (*_read_port_cancel)(struct rtw_adapter *adapter); - struct intf_hdl *pintfhdl = &adapter->intf; + struct _io_ops *io_ops = &adapter->io_ops; - _read_port_cancel = pintfhdl->io_ops._read_port_cancel; + _read_port_cancel = io_ops->_read_port_cancel; if (_read_port_cancel) _read_port_cancel(adapter); @@ -166,10 +166,10 @@ void _rtw_read_port23a_cancel(struct rtw_adapter *adapter) u32 _rtw_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct xmit_buf *xbuf) { - struct intf_hdl *pintfhdl = &adapter->intf; + struct _io_ops *io_ops = &adapter->io_ops; u32 ret = _SUCCESS; - ret = pintfhdl->io_ops._write_port(adapter, addr, cnt, xbuf); + ret = io_ops->_write_port(adapter, addr, cnt, xbuf); return ret; } @@ -177,9 +177,9 @@ u32 _rtw_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, void _rtw_write_port23a_cancel(struct rtw_adapter *adapter) { void (*_write_port_cancel)(struct rtw_adapter *adapter); - struct intf_hdl *pintfhdl = &adapter->intf; + struct _io_ops *io_ops = &adapter->io_ops; - _write_port_cancel = pintfhdl->io_ops._write_port_cancel; + _write_port_cancel = io_ops->_write_port_cancel; if (_write_port_cancel) _write_port_cancel(adapter); diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 1dd2a08a0963..f300349e88cf 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1227,14 +1227,14 @@ static unsigned int rtl8723au_inirp_init(struct rtw_adapter *Adapter) u8 i; struct recv_buf *precvbuf; uint status; - struct intf_hdl *pintfhdl = &Adapter->intf; + struct _io_ops *io_ops = &Adapter->io_ops; struct recv_priv *precvpriv = &Adapter->recvpriv; u32 (*_read_port)(struct rtw_adapter *padapter, u32 addr, u32 cnt, struct recv_buf *rbuf); u32 (*_read_interrupt)(struct rtw_adapter *padapter, u32 addr); struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); - _read_port = pintfhdl->io_ops._read_port; + _read_port = io_ops->_read_port; status = _SUCCESS; @@ -1255,7 +1255,7 @@ static unsigned int rtl8723au_inirp_init(struct rtw_adapter *Adapter) precvbuf++; precvpriv->free_recv_buf_queue_cnt--; } - _read_interrupt = pintfhdl->io_ops._read_interrupt; + _read_interrupt = io_ops->_read_interrupt; if (_read_interrupt(Adapter, RECV_INT_IN_ADDR) == false) { RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("usb_rx_init: usb_read_interrupt error\n")); diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index b5332888226c..12997a5cd7a8 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -824,8 +824,7 @@ void rtl8723au_xmit_tasklet(void *priv) void rtl8723au_set_intf_ops(struct rtw_adapter *padapter) { - struct intf_hdl *pintf = &padapter->intf; - struct _io_ops *pops = &pintf->io_ops; + struct _io_ops *pops = &padapter->io_ops; memset((u8 *)pops, 0, sizeof(struct _io_ops)); diff --git a/drivers/staging/rtl8723au/include/drv_types.h b/drivers/staging/rtl8723au/include/drv_types.h index 1e06a37e8af5..c2c192410aa5 100644 --- a/drivers/staging/rtl8723au/include/drv_types.h +++ b/drivers/staging/rtl8723au/include/drv_types.h @@ -242,7 +242,7 @@ struct rtw_adapter { struct mlme_ext_priv mlmeextpriv; struct cmd_priv cmdpriv; struct evt_priv evtpriv; - struct intf_hdl intf; + struct _io_ops io_ops; struct xmit_priv xmitpriv; struct recv_priv recvpriv; struct sta_priv stapriv; diff --git a/drivers/staging/rtl8723au/include/rtw_io.h b/drivers/staging/rtl8723au/include/rtw_io.h index 745d0ef25af3..fffe028750c2 100644 --- a/drivers/staging/rtl8723au/include/rtw_io.h +++ b/drivers/staging/rtl8723au/include/rtw_io.h @@ -97,7 +97,6 @@ #define _INTF_ASYNC_ BIT(0) /* support async io */ struct intf_priv; -struct intf_hdl; struct _io_ops { @@ -135,10 +134,6 @@ struct io_req { u8 *cnxt; }; -struct intf_hdl { - struct _io_ops io_ops; -}; - struct reg_protocol_rd { #ifdef __LITTLE_ENDIAN -- cgit v1.2.3 From f033c87649b930a85670d97a23fa20f4f9d5d2f4 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:35 +0200 Subject: staging: rtl8723au: Remove unused entries from struct dvobj_priv Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 1 - drivers/staging/rtl8723au/include/drv_types.h | 4 ---- 2 files changed, 5 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 934f18dbd941..5660834a7dd8 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -2042,7 +2042,6 @@ static void _ResetDigitalProcedure1_92C(struct rtw_adapter *padapter, are trying to enter IPS/HW&SW radio off. For S3/S4/S5/Disable, we can stop 8051 because */ /* we will init FW when power on again. */ - /* if (!pDevice->RegUsbSS) */ /* If we want to SS mode, we can not reset 8051. */ if (rtw_read8(padapter, REG_MCUFWDL) & BIT1) { /* IF fw in RAM code, do reset */ diff --git a/drivers/staging/rtl8723au/include/drv_types.h b/drivers/staging/rtl8723au/include/drv_types.h index c2c192410aa5..ec8d60b9b249 100644 --- a/drivers/staging/rtl8723au/include/drv_types.h +++ b/drivers/staging/rtl8723au/include/drv_types.h @@ -186,8 +186,6 @@ struct dvobj_priv { int RtOutPipe[3]; u8 Queue2Pipe[HW_QUEUE_ENTRY];/* for out pipe mapping */ - u8 irq_alloc; - /*-------- below is for USB INTERFACE --------*/ u8 nr_endpoint; @@ -196,8 +194,6 @@ struct dvobj_priv { u8 RtNumOutPipes; int ep_num[5]; /* endpoint number */ - int RegUsbSS; - struct semaphore usb_suspend_sema; struct mutex usb_vendor_req_mutex; -- cgit v1.2.3 From 4d899d6347e0ebd8ab85b9266cd0a86ed87f2d3a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:36 +0200 Subject: staging: rtl8723au: Remove unused struct specific_device_id Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/drv_types.h | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/staging/rtl8723au/include/drv_types.h b/drivers/staging/rtl8723au/include/drv_types.h index ec8d60b9b249..519f888d89d6 100644 --- a/drivers/staging/rtl8723au/include/drv_types.h +++ b/drivers/staging/rtl8723au/include/drv_types.h @@ -59,21 +59,6 @@ enum _NIC_VERSION { #include "ioctl_cfg80211.h" -#define SPEC_DEV_ID_NONE BIT(0) -#define SPEC_DEV_ID_DISABLE_HT BIT(1) -#define SPEC_DEV_ID_ENABLE_PS BIT(2) -#define SPEC_DEV_ID_RF_CONFIG_1T1R BIT(3) -#define SPEC_DEV_ID_RF_CONFIG_2T2R BIT(4) -#define SPEC_DEV_ID_ASSIGN_IFNAME BIT(5) - -struct specific_device_id { - u32 flags; - - u16 idVendor; - u16 idProduct; - -}; - struct registry_priv { u8 chip_version; u8 rfintfs; -- cgit v1.2.3 From 7fb79ab959a25bdc771043af46620316f09ffc1a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:37 +0200 Subject: staging: rtl8723au: Remove another pile of unused entries from struct rtw_adapter Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/drv_types.h | 14 -------------- drivers/staging/rtl8723au/os_dep/os_intfs.c | 6 ------ 2 files changed, 20 deletions(-) diff --git a/drivers/staging/rtl8723au/include/drv_types.h b/drivers/staging/rtl8723au/include/drv_types.h index 519f888d89d6..bec8fd7126d1 100644 --- a/drivers/staging/rtl8723au/include/drv_types.h +++ b/drivers/staging/rtl8723au/include/drv_types.h @@ -262,17 +262,8 @@ struct rtw_adapter { struct net_device *pnetdev; /* used by rtw_rereg_nd_name related function */ - struct rereg_nd_name_data { - struct net_device *old_pnetdev; - char old_ifname[IFNAMSIZ]; - u8 old_ips_mode; - u8 old_bRegUseLed; - } rereg_nd_name_priv; - int bup; struct net_device_stats stats; - struct iw_statistics iwstats; - struct proc_dir_entry *dir_dev;/* for proc directory */ struct wireless_dev *rtw_wdev; int net_closed; @@ -289,11 +280,6 @@ struct rtw_adapter { /* IFACE_ID0 is equals to PRIMARY_ADAPTER */ /* IFACE_ID1 is equals to SECONDARY_ADAPTER */ u8 iface_id; - - u8 fix_rate; - - unsigned char in_cta_test; - }; #define adapter_to_dvobj(adapter) (adapter->dvobj) diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index dd401e6ce415..25fce303c37b 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -588,12 +588,6 @@ u8 rtw_free_drv_sw23a(struct rtw_adapter *padapter) RT_TRACE(_module_os_intfs_c_, _drv_info_, ("<== rtw_free_drv_sw23a\n")); - /* free the old_pnetdev */ - if (padapter->rereg_nd_name_priv.old_pnetdev) { - free_netdev(padapter->rereg_nd_name_priv.old_pnetdev); - padapter->rereg_nd_name_priv.old_pnetdev = NULL; - } - /* clear pbuddy_adapter to avoid access wrong pointer. */ if (padapter->pbuddy_adapter != NULL) padapter->pbuddy_adapter->pbuddy_adapter = NULL; -- cgit v1.2.3 From b52f88d901fe7eaedcc455d13ea8db0ed3fc93c2 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:38 +0200 Subject: staging: rtl8723au: from hal_ops 'interface_ps_func' Lots of hoops for a dummy function which was never called Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 8 -------- drivers/staging/rtl8723au/hal/hal_intf.c | 7 ------- drivers/staging/rtl8723au/hal/usb_halinit.c | 7 ------- drivers/staging/rtl8723au/include/hal_intf.h | 11 ----------- drivers/staging/rtl8723au/include/rtw_pwrctrl.h | 2 -- 5 files changed, 35 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index 7370a391ed96..8a95ae1d353c 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -497,14 +497,6 @@ void rtw_free_pwrctrl_priv(struct rtw_adapter *adapter) { } -u8 rtw_interface_ps_func23a(struct rtw_adapter *padapter, enum hal_intf_ps_func efunc_id, u8* val) -{ - u8 bResult = true; - rtw_hal_intf_ps_func23a(padapter, efunc_id, val); - - return bResult; -} - inline void rtw_set_ips_deny23a(struct rtw_adapter *padapter, u32 ms) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index dad16bc7804b..2868c720a4f5 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -178,13 +178,6 @@ u32 rtw_hal_inirp_deinit23a(struct rtw_adapter *padapter) } -u8 rtw_hal_intf_ps_func23a(struct rtw_adapter *padapter, enum hal_intf_ps_func efunc_id, u8 *val) -{ - if (padapter->HalFunc.interface_ps_func) - return padapter->HalFunc.interface_ps_func(padapter, efunc_id, val); - return _FAIL; -} - s32 rtw_hal_xmit23aframe_enqueue(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe) { if (padapter->HalFunc.hal_xmitframe_enqueue) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index f300349e88cf..20c11353a610 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1739,12 +1739,6 @@ static void rtl8723au_init_default_value(struct rtw_adapter *padapter) rtl8723a_init_default_value(padapter); } -static u8 rtl8192cu_ps_func(struct rtw_adapter *Adapter, - enum hal_intf_ps_func efunc_id, u8 *val) -{ - return true; -} - int rtl8723au_set_hal_ops(struct rtw_adapter *padapter) { struct hal_ops *pHalFunc = &padapter->HalFunc; @@ -1779,7 +1773,6 @@ int rtl8723au_set_hal_ops(struct rtw_adapter *padapter) pHalFunc->hal_xmit = &rtl8723au_hal_xmit; pHalFunc->mgnt_xmit = &rtl8723au_mgnt_xmit; pHalFunc->hal_xmitframe_enqueue = &rtl8723au_hal_xmitframe_enqueue; - pHalFunc->interface_ps_func = &rtl8192cu_ps_func; rtl8723a_set_hal_ops(pHalFunc); return 0; } diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 1df82b6853be..5567a8589c8e 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -60,11 +60,6 @@ enum hal_odm_variable { HAL_ODM_WIFI_DISPLAY_STATE, }; -enum hal_intf_ps_func { - HAL_USB_SELECT_SUSPEND, - HAL_MAX_ID, -}; - struct hal_ops { u32 (*hal_power_on)(struct rtw_adapter *padapter); u32 (*hal_init)(struct rtw_adapter *padapter); @@ -124,9 +119,6 @@ struct hal_ops { void (*Add_RateATid)(struct rtw_adapter *padapter, u32 bitmap, u8 arg, u8 rssi_level); - u8 (*interface_ps_func)(struct rtw_adapter *padapter, - enum hal_intf_ps_func efunc_id, u8 *val); - s32 (*hal_xmit)(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe); s32 (*mgnt_xmit)(struct rtw_adapter *padapter, @@ -253,9 +245,6 @@ void rtw_hal_disable_interrupt23a(struct rtw_adapter *padapter); u32 rtw_hal_inirp_init23a(struct rtw_adapter *padapter); u32 rtw_hal_inirp_deinit23a(struct rtw_adapter *padapter); -u8 rtw_hal_intf_ps_func23a(struct rtw_adapter *padapter, - enum hal_intf_ps_func efunc_id, u8 *val); - s32 rtw_hal_xmit23aframe_enqueue(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe); s32 rtw_hal_xmit23a(struct rtw_adapter *padapter, diff --git a/drivers/staging/rtl8723au/include/rtw_pwrctrl.h b/drivers/staging/rtl8723au/include/rtw_pwrctrl.h index e0da87d4d3d6..062c38255566 100644 --- a/drivers/staging/rtl8723au/include/rtw_pwrctrl.h +++ b/drivers/staging/rtl8723au/include/rtw_pwrctrl.h @@ -250,8 +250,6 @@ s32 LPS_RF_ON_check23a(struct rtw_adapter *padapter, u32 delay_ms); void LPS_Enter23a(struct rtw_adapter *padapter); void LPS_Leave23a(struct rtw_adapter *padapter); -u8 rtw_interface_ps_func23a(struct rtw_adapter *padapter, - enum hal_intf_ps_func efunc_id, u8 *val); void rtw_set_ips_deny23a(struct rtw_adapter *padapter, u32 ms); int _rtw_pwr_wakeup23a(struct rtw_adapter *padapter, u32 ips_deffer_ms, const char *caller); -- cgit v1.2.3 From 1c9f76d47448033f1b9f420b04ae186cf996a0ed Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:39 +0200 Subject: staging: rtl8723au: struct pwrctrl_priv remove unused entry b_hw_radio_off Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtw_pwrctrl.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8723au/include/rtw_pwrctrl.h b/drivers/staging/rtl8723au/include/rtw_pwrctrl.h index 062c38255566..44a7d4f97e09 100644 --- a/drivers/staging/rtl8723au/include/rtw_pwrctrl.h +++ b/drivers/staging/rtl8723au/include/rtw_pwrctrl.h @@ -165,7 +165,6 @@ struct pwrctrl_priv { struct work_struct cpwm_event; u8 bpower_saving; - u8 b_hw_radio_off; u8 reg_rfoff; u8 reg_pdnmode; /* powerdown mode */ u32 rfoff_reason; -- cgit v1.2.3 From 46ea77269910ef270b67c8b8636f69adad250ae6 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:40 +0200 Subject: staging: rtl8723au: Remove unused hal interface for accessing bb regs Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_intf.c | 13 ------------- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 2 -- drivers/staging/rtl8723au/include/hal_intf.h | 6 ------ 3 files changed, 21 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index 2868c720a4f5..1931f428722f 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -255,19 +255,6 @@ void rtw_hal_add_ra_tid23a(struct rtw_adapter *padapter, u32 bitmap, u8 arg, u8 padapter->HalFunc.Add_RateATid(padapter, bitmap, arg, rssi_level); } -u32 rtw_hal_read_bbreg23a(struct rtw_adapter *padapter, u32 RegAddr, u32 BitMask) -{ - u32 data = 0; - if (padapter->HalFunc.read_bbreg) - data = padapter->HalFunc.read_bbreg(padapter, RegAddr, BitMask); - return data; -} -void rtw_hal_write_bbreg23a(struct rtw_adapter *padapter, u32 RegAddr, u32 BitMask, u32 Data) -{ - if (padapter->HalFunc.write_bbreg) - padapter->HalFunc.write_bbreg(padapter, RegAddr, BitMask, Data); -} - u32 rtw_hal_read_rfreg23a(struct rtw_adapter *padapter, u32 eRFPath, u32 RegAddr, u32 BitMask) { u32 data = 0; diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 5660834a7dd8..ee05bc00655a 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1739,8 +1739,6 @@ void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc) pHalFunc->Add_RateATid = &rtl8723a_add_rateatid; - pHalFunc->read_bbreg = &PHY_QueryBBReg; - pHalFunc->write_bbreg = &PHY_SetBBReg; pHalFunc->read_rfreg = &PHY_QueryRFReg; pHalFunc->write_rfreg = &PHY_SetRFReg; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 5567a8589c8e..52b33fe61b3f 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -126,10 +126,6 @@ struct hal_ops { s32 (*hal_xmitframe_enqueue)(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe); - u32 (*read_bbreg)(struct rtw_adapter *padapter, u32 RegAddr, - u32 BitMask); - void (*write_bbreg)(struct rtw_adapter *padapter, u32 RegAddr, - u32 BitMask, u32 Data); u32 (*read_rfreg)(struct rtw_adapter *padapter, u32 eRFPath, u32 RegAddr, u32 BitMask); void (*write_rfreg)(struct rtw_adapter *padapter, u32 eRFPath, @@ -264,8 +260,6 @@ void rtw_hal_clone_data(struct rtw_adapter *dst_padapter, struct rtw_adapter *sr void rtw_hal_bcn_related_reg_setting23a(struct rtw_adapter *padapter); -u32 rtw_hal_read_bbreg23a(struct rtw_adapter *padapter, u32 RegAddr, u32 BitMask); -void rtw_hal_write_bbreg23a(struct rtw_adapter *padapter, u32 RegAddr, u32 BitMask, u32 Data); u32 rtw_hal_read_rfreg23a(struct rtw_adapter *padapter, u32 eRFPath, u32 RegAddr, u32 BitMask); void rtw_hal_write_rfreg23a(struct rtw_adapter *padapter, u32 eRFPath, u32 RegAddr, u32 BitMask, u32 Data); -- cgit v1.2.3 From 6a235443be58fbdfebb02f536c6338ba82ab399a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:41 +0200 Subject: staging: rtl8723au: Make rtw_get_capability23a_from_ie() return __le 16 * This should make sparse happier. Reported-by: Larry Finger Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 4 ++-- drivers/staging/rtl8723au/core/rtw_mlme.c | 11 ++++------- drivers/staging/rtl8723au/include/rtw_mlme.h | 2 +- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index 8f91bdbc2bbf..7c899d8e6db0 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -1004,8 +1004,8 @@ void rtw_get_bcn_info23a(struct wlan_network *pnetwork) unsigned int len; unsigned char *p; - memcpy(&cap, rtw_get_capability23a_from_ie(pnetwork->network.IEs), 2); - cap = le16_to_cpu(cap); + cap = get_unaligned_le16( + rtw_get_capability23a_from_ie(pnetwork->network.IEs)); if (cap & WLAN_CAPABILITY_PRIVACY) { bencrypt = 1; pnetwork->network.Privacy = 1; diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 1f7f061ca1dd..dd42d4f5e7f1 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -333,9 +333,9 @@ void rtw23a_roaming(struct rtw_adapter *padapter, spin_unlock_bh(&pmlmepriv->lock); } -u8 *rtw_get_capability23a_from_ie(u8 *ie) +__le16 *rtw_get_capability23a_from_ie(u8 *ie) { - return ie + 8 + 2; + return (__le16 *)(ie + 8 + 2); } u16 rtw_get_capability23a(struct wlan_bssid_ex *bss) @@ -416,11 +416,8 @@ int is_same_network23a(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst) { u16 s_cap, d_cap; - memcpy(&s_cap, rtw_get_capability23a_from_ie(src->IEs), 2); - memcpy(&d_cap, rtw_get_capability23a_from_ie(dst->IEs), 2); - - s_cap = le16_to_cpu(s_cap); - d_cap = le16_to_cpu(d_cap); + s_cap = get_unaligned_le16(rtw_get_capability23a_from_ie(src->IEs)); + d_cap = get_unaligned_le16(rtw_get_capability23a_from_ie(dst->IEs)); return ((src->Ssid.ssid_len == dst->Ssid.ssid_len) && /* (src->Configuration.DSConfig == dst->Configuration.DSConfig) && */ diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index 3d6f7307e41e..55242c2f6636 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -469,7 +469,7 @@ int rtw_if_up23a(struct rtw_adapter *padapter); int rtw_linked_check(struct rtw_adapter *padapter); -u8 *rtw_get_capability23a_from_ie(u8 *ie); +__le16 *rtw_get_capability23a_from_ie(u8 *ie); u8 *rtw_get_beacon_interval23a_from_ie(u8 *ie); diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 221d15205b1e..14331e474f0b 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -292,7 +292,7 @@ static int rtw_cfg80211_inform_bss(struct rtw_adapter *padapter, le16_to_cpu(*(u16 *) rtw_get_beacon_interval23a_from_ie(pnetwork->network.IEs)); notify_capability = - le16_to_cpu(*(u16 *) + get_unaligned_le16( rtw_get_capability23a_from_ie(pnetwork->network.IEs)); notify_ie = pnetwork->network.IEs + _FIXED_IE_LENGTH_; -- cgit v1.2.3 From 507a755dd78b782ed6e274803950759f81faf574 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sat, 26 Apr 2014 18:55:42 +0200 Subject: staging: r8723au: Fix endian errors for frame control The following locations in the code treat the frame control as u16 rather than the correct __le16: drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2471:15: expected unsigned short *fctrl drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2644:15: expected unsigned short *fctrl drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2849:15: expected unsigned short *fctrl drivers/staging/rtl8723au/core/rtw_mlme_ext.c:2994:15: expected unsigned short *fctrl drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3308:15: expected unsigned short *fctrl drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3578:15: expected unsigned short *fctrl drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3699:15: expected unsigned short *fctrl drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3821:15: expected unsigned short *fctrl drivers/staging/rtl8723au/core/rtw_mlme_ext.c:3932:15: expected unsigned short *fctrl drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4004:15: expected unsigned short [usertype] *fctrl drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4194:15: expected unsigned short *fctrl drivers/staging/rtl8723au/core/rtw_xmit.c:911:23: expected unsigned short [usertype] *fctrl drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:216:15: expected unsigned short [usertype] *fctrl drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:313:15: expected unsigned short [usertype] *fctrl drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:350:15: expected unsigned short [usertype] *fctrl drivers/staging/rtl8723au/hal/rtl8723a_cmd.c:419:15: expected unsigned short [usertype] *fctrl drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c:314:15: expected unsigned short *fctrl drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c:2357:15: expected unsigned short *fctrl Signed-off-by: Larry Finger Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 25 ++++++++++++----------- drivers/staging/rtl8723au/core/rtw_xmit.c | 2 +- drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 8 ++++---- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 4 ++-- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index abaedd21fe03..eb7b98e2e5be 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -2435,7 +2435,7 @@ void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms) struct pkt_attrib *pattrib; unsigned char *pframe; struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; + __le16 *fctrl; unsigned int rate_len; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -2603,7 +2603,7 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, struct pkt_attrib *pattrib; unsigned char *pframe; struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; + __le16 *fctrl; unsigned char *mac, *bssid; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; #ifdef CONFIG_8723AU_AP_MODE @@ -2820,7 +2820,7 @@ static int _issue_probereq23a(struct rtw_adapter *padapter, struct pkt_attrib *pattrib; unsigned char *pframe; struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; + __le16 *fctrl; unsigned char *mac; unsigned char bssrate[NumRates]; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; @@ -2846,7 +2846,7 @@ static int _issue_probereq23a(struct rtw_adapter *padapter, mac = myid(&padapter->eeprompriv); - fctrl = &pwlanhdr->frame_control; + fctrl = &pwlanhdr->frame_control; *fctrl = 0; if (da) { @@ -2971,7 +2971,7 @@ void issue_auth23a(struct rtw_adapter *padapter, struct sta_info *psta, struct pkt_attrib *pattrib; unsigned char *pframe; struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; + __le16 *fctrl; unsigned int val32; unsigned short val16; int use_shared_key = 0; @@ -3280,7 +3280,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) unsigned char *pframe; const u8 *p; struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; + __le16 *fctrl; unsigned int i, j, index = 0; unsigned char rf_type, bssrate[NumRates], sta_bssrate[NumRates]; struct ndis_802_11_var_ies *pIE; @@ -3548,7 +3548,7 @@ static int _issue_nulldata23a(struct rtw_adapter *padapter, unsigned char *da, struct pkt_attrib *pattrib; unsigned char *pframe; struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; + __le16 *fctrl; struct xmit_priv *pxmitpriv; struct mlme_ext_priv *pmlmeext; struct mlme_ext_info *pmlmeinfo; @@ -3671,7 +3671,8 @@ static int _issue_qos_nulldata23a(struct rtw_adapter *padapter, struct pkt_attrib *pattrib; unsigned char *pframe; struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl, *qc; + __le16 *fctrl; + u16 *qc; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -3797,7 +3798,7 @@ static int _issue_deauth23a(struct rtw_adapter *padapter, unsigned char *da, struct pkt_attrib *pattrib; unsigned char *pframe; struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; + __le16 *fctrl; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -3908,7 +3909,7 @@ void issue_action_spct_ch_switch23a(struct rtw_adapter *padapter, struct pkt_attrib *pattrib; unsigned char *pframe; struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; + __le16 *fctrl; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; u8 category, action; @@ -3975,7 +3976,7 @@ void issue_action_BA23a(struct rtw_adapter *padapter, struct pkt_attrib *pattrib; u8 *pframe; struct ieee80211_hdr *pwlanhdr; - u16 *fctrl; + __le16 *fctrl; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -4155,7 +4156,7 @@ static void issue_action_BSSCoexistPacket(struct rtw_adapter *padapter) struct pkt_attrib *pattrib; u8 *pframe; struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; + __le16 *fctrl; struct wlan_network *pnetwork; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index e7252d16c989..31a44feaab1d 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -908,7 +908,7 @@ s32 rtw_make_wlanhdr23a(struct rtw_adapter *padapter, u8 *hdr, struct qos_priv *pqospriv = &pmlmepriv->qospriv; u8 qos_option = false; int res = _SUCCESS; - u16 *fctrl = &pwlanhdr->frame_control; + __le16 *fctrl = &pwlanhdr->frame_control; struct sta_info *psta; diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c index be9d724c827e..ffd6b73eb6a8 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c @@ -202,7 +202,7 @@ void rtl8723a_set_FwPwrMode_cmd(struct rtw_adapter *padapter, u8 Mode) static void ConstructBeacon(struct rtw_adapter *padapter, u8 *pframe, u32 *pLength) { struct ieee80211_hdr *pwlanhdr; - u16 *fctrl; + __le16 *fctrl; u32 rate_len, pktlen; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -303,7 +303,7 @@ _ConstructBeacon: static void ConstructPSPoll(struct rtw_adapter *padapter, u8 *pframe, u32 *pLength) { struct ieee80211_hdr *pwlanhdr; - u16 *fctrl; + __le16 *fctrl; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -338,7 +338,7 @@ static void ConstructNullFunctionData( u8 bForcePowerSave) { struct ieee80211_hdr *pwlanhdr; - u16 *fctrl; + __le16 *fctrl; u32 pktlen; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_network *cur_network = &pmlmepriv->cur_network; @@ -402,7 +402,7 @@ static void ConstructNullFunctionData( static void ConstructProbeRsp(struct rtw_adapter *padapter, u8 *pframe, u32 *pLength, u8 *StaAddr, bool bHideSSID) { struct ieee80211_hdr *pwlanhdr; - u16 *fctrl; + __le16 *fctrl; u8 *mac, *bssid; u32 pktlen; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 14331e474f0b..ca100dcc2763 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -262,7 +262,7 @@ static int rtw_cfg80211_inform_bss(struct rtw_adapter *padapter, u8 buf[MAX_BSSINFO_LEN], *pbuf; size_t len; struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; + __le16 *fctrl; struct wireless_dev *wdev = padapter->rtw_wdev; struct wiphy *wiphy = wdev->wiphy; @@ -2332,7 +2332,7 @@ void rtw_cfg80211_indicate_sta_disassoc(struct rtw_adapter *padapter, u8 *pmgmt_frame; uint frame_len; struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; + __le16 *fctrl; u8 mgmt_buf[128] = { 0 }; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; -- cgit v1.2.3 From d7cfe7c85579059e55068ecc69c9baf483883246 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:43 +0200 Subject: staging: rtl8723au: Make sparse happy - make rtw_get_beacon_interval23a_from_ie return __le16 * Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 5 +++-- drivers/staging/rtl8723au/core/rtw_mlme.c | 4 ++-- drivers/staging/rtl8723au/include/rtw_mlme.h | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 23be15cc76bc..be8b0e893dac 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -791,6 +791,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, u8 *pHT_caps_ie = NULL; u8 *pHT_info_ie = NULL; struct sta_info *psta = NULL; + __le16 *pbeacon; u16 cap, ht_cap = false; uint ie_len = 0; int group_cipher, pairwise_cipher; @@ -838,8 +839,8 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, /* beacon interval */ /* ie + 8; 8: TimeStamp, 2: Beacon Interval 2:Capability */ - p = rtw_get_beacon_interval23a_from_ie(ie); - pbss_network->Configuration.BeaconPeriod = get_unaligned_le16(p); + pbeacon = rtw_get_beacon_interval23a_from_ie(ie); + pbss_network->Configuration.BeaconPeriod = get_unaligned_le16(pbeacon); /* capability */ cap = get_unaligned_le16(ie); diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index dd42d4f5e7f1..7e37929abf5c 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -347,9 +347,9 @@ u16 rtw_get_capability23a(struct wlan_bssid_ex *bss) return le16_to_cpu(val); } -u8 *rtw_get_beacon_interval23a_from_ie(u8 *ie) +__le16 *rtw_get_beacon_interval23a_from_ie(u8 *ie) { - return ie + 8; + return (__le16 *)(ie + 8); } int rtw_init_mlme_priv23a (struct rtw_adapter *padapter) diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index 55242c2f6636..9689feea41c3 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -470,7 +470,7 @@ int rtw_if_up23a(struct rtw_adapter *padapter); int rtw_linked_check(struct rtw_adapter *padapter); __le16 *rtw_get_capability23a_from_ie(u8 *ie); -u8 *rtw_get_beacon_interval23a_from_ie(u8 *ie); +__le16 *rtw_get_beacon_interval23a_from_ie(u8 *ie); void rtw_joinbss_reset23a(struct rtw_adapter *padapter); -- cgit v1.2.3 From 819d1815667dbcadc7a8b98d94d9dbc76645e62f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:44 +0200 Subject: staging: rtl8723au: Eliminate the 217th copy of the microsoft OUI Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index be8b0e893dac..9b31412b7521 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -797,7 +797,6 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, int group_cipher, pairwise_cipher; u8 channel, network_type, supportRate[NDIS_802_11_LENGTH_RATES_EX]; int supportRateNum = 0; - u8 OUI1[] = {0x00, 0x50, 0xf2, 0x01}; u8 WMM_PARA_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; struct registry_priv *pregistrypriv = &padapter->registrypriv; struct security_priv *psecuritypriv = &padapter->securitypriv; @@ -929,7 +928,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, p = rtw_get_ie23a(p, WLAN_EID_VENDOR_SPECIFIC, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); - if ((p) && (!memcmp(p+2, OUI1, 4))) { + if ((p) && (!memcmp(p+2, RTW_WPA_OUI23A_TYPE, 4))) { if (rtw_parse_wpa_ie23a(p, ie_len+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; -- cgit v1.2.3 From 1ffc7622a53a8cd5625c57767d01fea1e27aef3d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:45 +0200 Subject: staging: rtl8723au: Remove redundant checks of WPA OUI All callers get here by searching for the WPA OUI first, so no point checking for it once we get here. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index 7c899d8e6db0..b56055eb433b 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -503,11 +503,8 @@ int rtw_parse_wpa_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int return _FAIL; } - if ((*wpa_ie != WLAN_EID_VENDOR_SPECIFIC) || - (*(wpa_ie+1) != (u8)(wpa_ie_len - 2)) || - memcmp(wpa_ie + 2, RTW_WPA_OUI23A_TYPE, WPA_SELECTOR_LEN)) { + if (wpa_ie[1] != (u8)(wpa_ie_len - 2)) return _FAIL; - } pos = wpa_ie; -- cgit v1.2.3 From a7efff217fd5ea9b8931bf8f52eb123877b4c4d9 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:46 +0200 Subject: staging: rtl8723au: Fold _rtw_init_mlme_priv23a() into rtw_init_mlme_priv23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 11 +---------- drivers/staging/rtl8723au/include/rtw_mlme.h | 2 -- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 7e37929abf5c..381438c7da49 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -45,7 +45,7 @@ static void rtw_init_mlme_timer(struct rtw_adapter *padapter) rtw_set_scan_deny_timer_hdl, (unsigned long)padapter); } -int _rtw_init_mlme_priv23a(struct rtw_adapter *padapter) +int rtw_init_mlme_priv23a(struct rtw_adapter *padapter) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; int res = _SUCCESS; @@ -352,15 +352,6 @@ __le16 *rtw_get_beacon_interval23a_from_ie(u8 *ie) return (__le16 *)(ie + 8); } -int rtw_init_mlme_priv23a (struct rtw_adapter *padapter) -{ - int res; - - res = _rtw_init_mlme_priv23a(padapter); - - return res; -} - static void rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork) { diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index 9689feea41c3..dc52e9da7bf1 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -450,8 +450,6 @@ void rtw_clear_scan_deny(struct rtw_adapter *adapter); void rtw_set_scan_deny_timer_hdl(unsigned long data); void rtw_set_scan_deny(struct rtw_adapter *adapter, u32 ms); -int _rtw_init_mlme_priv23a(struct rtw_adapter *padapter); - void rtw23a_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv); void _rtw_free_mlme_priv23a(struct mlme_priv *pmlmepriv); -- cgit v1.2.3 From 8c47af2280ce431f17f0dd615766153935b62be6 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:47 +0200 Subject: staging: rtl8723au: Fold _rtw_free_network23a_queue23a() into rtw_free_network_queue23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 7 +------ drivers/staging/rtl8723au/include/rtw_mlme.h | 2 -- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 381438c7da49..8ae2bbf590b2 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -220,7 +220,7 @@ exit: return pnetwork; } -void _rtw_free_network23a_queue23a(struct rtw_adapter *padapter, u8 isfreeall) +void rtw_free_network_queue23a(struct rtw_adapter *padapter, u8 isfreeall) { struct list_head *phead, *plist, *ptmp; struct wlan_network *pnetwork; @@ -358,11 +358,6 @@ static void rtw_free_network_nolock(struct mlme_priv *pmlmepriv, _rtw_free_network23a_nolock23a(pmlmepriv, pnetwork); } -void rtw_free_network_queue23a(struct rtw_adapter* dev, u8 isfreeall) -{ - _rtw_free_network23a_queue23a(dev, isfreeall); -} - /* return the wlan_network with the matching addr diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index dc52e9da7bf1..29ffcbbd5764 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -461,8 +461,6 @@ void _rtw_free_network23a_nolock23a(struct mlme_priv *pmlmepriv, struct wlan_network *_rtw_find_network23a(struct rtw_queue *scanned_queue, u8 *addr); -void _rtw_free_network23a_queue23a(struct rtw_adapter *padapter, u8 isfreeall); - int rtw_if_up23a(struct rtw_adapter *padapter); int rtw_linked_check(struct rtw_adapter *padapter); -- cgit v1.2.3 From f56d96857bb248b2f5795b6809efb749ebb07c28 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:48 +0200 Subject: staging: rtl8723au: Fold _rtw_find_network23a() into rtw_find_network23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 17 +---------------- drivers/staging/rtl8723au/include/rtw_mlme.h | 2 -- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 8ae2bbf590b2..536250476566 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -186,7 +186,7 @@ void _rtw_free_network23a_nolock23a(struct mlme_priv *pmlmepriv, Shall be calle under atomic context... to avoid possible racing condition... */ struct wlan_network * -_rtw_find_network23a(struct rtw_queue *scanned_queue, u8 *addr) +rtw_find_network23a(struct rtw_queue *scanned_queue, u8 *addr) { struct list_head *phead, *plist; struct wlan_network *pnetwork = NULL; @@ -358,21 +358,6 @@ static void rtw_free_network_nolock(struct mlme_priv *pmlmepriv, _rtw_free_network23a_nolock23a(pmlmepriv, pnetwork); } -/* - return the wlan_network with the matching addr - - Shall be calle under atomic context... to avoid possible racing condition... -*/ -struct wlan_network * -rtw_find_network23a(struct rtw_queue *scanned_queue, u8 *addr) -{ - struct wlan_network *pnetwork; - - pnetwork = _rtw_find_network23a(scanned_queue, addr); - - return pnetwork; -} - int rtw_is_same_ibss23a(struct rtw_adapter *adapter, struct wlan_network *pnetwork) { diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index 29ffcbbd5764..b1aca7d6244a 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -459,8 +459,6 @@ struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv); void _rtw_free_network23a_nolock23a(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork); -struct wlan_network *_rtw_find_network23a(struct rtw_queue *scanned_queue, u8 *addr); - int rtw_if_up23a(struct rtw_adapter *padapter); int rtw_linked_check(struct rtw_adapter *padapter); -- cgit v1.2.3 From 503ee6287472e109837ff8233fc7fd3cbac306fc Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:49 +0200 Subject: staging: rtl8723au: _rtw_free_network23a(): Remove write-only variable 'lifetime' Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 536250476566..93be98a49398 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -149,18 +149,12 @@ struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv) static void _rtw_free_network23a(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork, u8 isfreeall) { - u32 lifetime = SCANQUEUE_LIFETIME; - if (!pnetwork) return; if (pnetwork->fixed == true) return; - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) - lifetime = 1; - list_del_init(&pnetwork->list); kfree(pnetwork); -- cgit v1.2.3 From 2ccac5f60002ff7521fd3fc602640f31da8cb580 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:50 +0200 Subject: staging: rtl8723au: _rtw_free_network23a(): Remove unused argument 'isfreeall' Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 93be98a49398..aff4123983b2 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -147,7 +147,7 @@ struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv) } static void _rtw_free_network23a(struct mlme_priv *pmlmepriv, - struct wlan_network *pnetwork, u8 isfreeall) + struct wlan_network *pnetwork) { if (!pnetwork) return; @@ -228,7 +228,7 @@ void rtw_free_network_queue23a(struct rtw_adapter *padapter, u8 isfreeall) list_for_each_safe(plist, ptmp, phead) { pnetwork = container_of(plist, struct wlan_network, list); - _rtw_free_network23a(pmlmepriv,pnetwork, isfreeall); + _rtw_free_network23a(pmlmepriv, pnetwork); } spin_unlock_bh(&scanned_queue->lock); -- cgit v1.2.3 From 528e5c1dc78b9b4429f06d148014c048538019b5 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:51 +0200 Subject: staging: rtl8723au: rtw_free_network_queue23a() eliminate unused argument 'isfreeall' Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 2 +- drivers/staging/rtl8723au/core/rtw_mlme.c | 2 +- drivers/staging/rtl8723au/include/rtw_mlme.h | 2 +- drivers/staging/rtl8723au/os_dep/os_intfs.c | 2 +- drivers/staging/rtl8723au/os_dep/usb_intf.c | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index c87671b60690..5b3ac6901147 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -417,7 +417,7 @@ u8 rtw_sitesurvey_cmd23a(struct rtw_adapter *padapter, return _FAIL; } - rtw_free_network_queue23a(padapter, false); + rtw_free_network_queue23a(padapter); RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("%s: flush network queue\n", __func__)); diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index aff4123983b2..b39945ef02da 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -214,7 +214,7 @@ exit: return pnetwork; } -void rtw_free_network_queue23a(struct rtw_adapter *padapter, u8 isfreeall) +void rtw_free_network_queue23a(struct rtw_adapter *padapter) { struct list_head *phead, *plist, *ptmp; struct wlan_network *pnetwork; diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index b1aca7d6244a..744c15bd6c5a 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -345,7 +345,7 @@ void rtw_cpwm_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf); int event_thread(void *context); void rtw23a_join_to_handler(unsigned long); -void rtw_free_network_queue23a(struct rtw_adapter *adapter, u8 isfreeall); +void rtw_free_network_queue23a(struct rtw_adapter *adapter); int rtw_init_mlme_priv23a(struct rtw_adapter *adapter); void rtw_free_mlme_priv23a(struct mlme_priv *pmlmepriv); diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index 25fce303c37b..7c4c0a54b238 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -861,7 +861,7 @@ static int netdev_close(struct net_device *pnetdev) /* s2-3. */ rtw_free_assoc_resources23a(padapter, 1); /* s2-4. */ - rtw_free_network_queue23a(padapter, true); + rtw_free_network_queue23a(padapter); /* Close LED */ rtw_led_control(padapter, LED_CTL_POWER_OFF); } diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index 797393a70810..7d5233b993f1 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -396,7 +396,7 @@ int rtw_hw_suspend23a(struct rtw_adapter *padapter) rtw_free_assoc_resources23a(padapter, 1); /* s2-4. */ - rtw_free_network_queue23a(padapter, true); + rtw_free_network_queue23a(padapter); rtw_ips_dev_unload23a(padapter); pwrpriv->rf_pwrstate = rf_off; pwrpriv->bips_processing = false; @@ -500,7 +500,7 @@ static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message) /* s2-3. */ rtw_free_assoc_resources23a(padapter, 1); /* s2-4. */ - rtw_free_network_queue23a(padapter, true); + rtw_free_network_queue23a(padapter); rtw_dev_unload(padapter); up(&pwrpriv->lock); -- cgit v1.2.3 From 2d5eafc179403b30af1d30bea932aebf375fb513 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sat, 26 Apr 2014 18:55:52 +0200 Subject: staging: rtl8723au: Get rid of _rtw_free_network23a_nolock23a() _rtw_free_network23a() and _rtw_free_network23a_nolock23a() are now identical - one copy should do. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 16 +--------------- drivers/staging/rtl8723au/include/rtw_mlme.h | 3 --- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index b39945ef02da..8d64cb02ee8e 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -160,20 +160,6 @@ static void _rtw_free_network23a(struct mlme_priv *pmlmepriv, kfree(pnetwork); } -void _rtw_free_network23a_nolock23a(struct mlme_priv *pmlmepriv, - struct wlan_network *pnetwork) -{ - if (!pnetwork) - return; - - if (pnetwork->fixed == true) - return; - - list_del_init(&pnetwork->list); - - kfree(pnetwork); -} - /* return the wlan_network with the matching addr @@ -349,7 +335,7 @@ __le16 *rtw_get_beacon_interval23a_from_ie(u8 *ie) static void rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork) { - _rtw_free_network23a_nolock23a(pmlmepriv, pnetwork); + _rtw_free_network23a(pmlmepriv, pnetwork); } int rtw_is_same_ibss23a(struct rtw_adapter *adapter, diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index 744c15bd6c5a..38203f16aee8 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -456,9 +456,6 @@ void _rtw_free_mlme_priv23a(struct mlme_priv *pmlmepriv); struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv); -void _rtw_free_network23a_nolock23a(struct mlme_priv *pmlmepriv, - struct wlan_network *pnetwork); - int rtw_if_up23a(struct rtw_adapter *padapter); int rtw_linked_check(struct rtw_adapter *padapter); -- cgit v1.2.3 From a34041af9e2167e56035a801c384687fcb05a577 Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Sun, 27 Apr 2014 13:06:25 -0400 Subject: staging/lustre/ptlrpc: Fix assertion failure of null_alloc_rs() lustre_get_emerg_rs() set the size of the reply buffer to zero by mistake, which will cause LBUG in null_alloc_rs() when memory pressure is high. This patch fix this problem and adds a size check to avoid the problem of insufficient buffer size. Signed-off-by: Li Xi Signed-off-by: Patrick Farrell Reviewed-on: http://review.whamcloud.com/8200 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3680 Reviewed-by: John L. Hammond Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/pack_generic.c | 1 + drivers/staging/lustre/lustre/ptlrpc/sec.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c index 45c0b84621e4..cddeeb6bb23d 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c @@ -300,6 +300,7 @@ lustre_get_emerg_rs(struct ptlrpc_service_part *svcpt) spin_unlock(&svcpt->scp_rep_lock); memset(rs, 0, svcpt->scp_service->srv_max_reply_size); + rs->rs_size = svcpt->scp_service->srv_max_reply_size; rs->rs_svcpt = svcpt; rs->rs_prealloc = 1; out: diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index b0a1c5a0d5cc..5e7539292f5e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -2086,8 +2086,18 @@ int sptlrpc_svc_alloc_rs(struct ptlrpc_request *req, int msglen) rc = policy->sp_sops->alloc_rs(req, msglen); if (unlikely(rc == -ENOMEM)) { + struct ptlrpc_service_part *svcpt = req->rq_rqbd->rqbd_svcpt; + if (svcpt->scp_service->srv_max_reply_size < + msglen + sizeof(struct ptlrpc_reply_state)) { + /* Just return failure if the size is too big */ + CERROR("size of message is too big (%zd), %d allowed", + msglen + sizeof(struct ptlrpc_reply_state), + svcpt->scp_service->srv_max_reply_size); + return -ENOMEM; + } + /* failed alloc, try emergency pool */ - rs = lustre_get_emerg_rs(req->rq_rqbd->rqbd_svcpt); + rs = lustre_get_emerg_rs(svcpt); if (rs == NULL) return -ENOMEM; -- cgit v1.2.3 From c547b70a2477bc31ba384fa64e63907e6ee4cfc3 Mon Sep 17 00:00:00 2001 From: Cheng Shao Date: Sun, 27 Apr 2014 13:06:26 -0400 Subject: staging/lustre/ptlrpc: Remove log message about export timer update Function ptlrpc_update_export_timer generates lots of D_HA level log messages whenever the export timer gets updated. Those log messages are found little use for issue investigations, and it will take space in the Lustre log buffer. We are removing it now. Xyratex-bug-id: MRP-733 Signed-off-by: Cheng Shao Reviewed-on: http://review.whamcloud.com/9147 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4590 Reviewed-by: Andreas Dilger Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/service.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 192adec5382a..5873c03b8e77 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -1042,9 +1042,6 @@ static void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay) return; exp->exp_last_request_time = new_time; - CDEBUG(D_HA, "updating export %s at "CFS_TIME_T" exp %p\n", - exp->exp_client_uuid.uuid, - exp->exp_last_request_time, exp); /* exports may get disconnected from the chain even though the export has references, so we must keep the spin lock while -- cgit v1.2.3 From 0b291b9a98460e5e2bc7e3c3f04dec269e1b28fe Mon Sep 17 00:00:00 2001 From: Hongchao Zhang Date: Sun, 27 Apr 2014 13:06:29 -0400 Subject: staging/lustre/osc: don't activate deactivated obd_import In ptlrpc_activate_import(), obd_import->imp_deactive should be checked if it is deactivated, otherwise it will trigger an LBUG in ptlrpc_invalidate_import(): ptlrpc_invalidate_import() ASSERTION(imp->imp_invalid) failed Signed-off-by: Hongchao Zhang Reviewed-on: http://review.whamcloud.com/8747 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4386 Reviewed-by: Andreas Dilger Reviewed-by: Fan Yong Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/import.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index 537aa6204a51..a04a1cc87809 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -381,6 +381,11 @@ void ptlrpc_activate_import(struct obd_import *imp) struct obd_device *obd = imp->imp_obd; spin_lock(&imp->imp_lock); + if (imp->imp_deactive != 0) { + spin_unlock(&imp->imp_lock); + return; + } + imp->imp_invalid = 0; spin_unlock(&imp->imp_lock); obd_import_event(obd, imp, IMP_EVENT_ACTIVE); -- cgit v1.2.3 From b3d0dfe5abccf79dfe2f5c8cf46b26764b809976 Mon Sep 17 00:00:00 2001 From: Matt Ezell Date: Sun, 27 Apr 2014 13:06:30 -0400 Subject: staging/lustre/lnet: Dropped messages are not accounted correctly LNET messages that are dropped are not accounted for correctly in /proc/sys/lnet/stats. What I assume to be a simple typo is causing drop_length to be double-counted and drop_count to never be incremented. Signed-off-by: Matt Ezell Reviewed-on: http://review.whamcloud.com/9096 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4577 Reviewed-by: James Nunez Reviewed-by: James Simmons Reviewed-by: Isaac Huang Reviewed-by: Liang Zhen Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/lnet/api-ni.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 45c23194081b..3f3c341c1197 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -338,7 +338,7 @@ lnet_counters_get(lnet_counters_t *counters) counters->send_count += ctr->send_count; counters->recv_count += ctr->recv_count; counters->route_count += ctr->route_count; - counters->drop_length += ctr->drop_length; + counters->drop_count += ctr->drop_count; counters->send_length += ctr->send_length; counters->recv_length += ctr->recv_length; counters->route_length += ctr->route_length; -- cgit v1.2.3 From 88e4ff862daa4d484de0462d1c95683ad627fe23 Mon Sep 17 00:00:00 2001 From: Li Xi Date: Sun, 27 Apr 2014 13:06:31 -0400 Subject: staging/lustre/ldlm: Hold lock when clearing flag This patch moves lock's skip flag clearing from lru-delete to lru-add code to prevent clearing lock's flag without resource lock protection. Signed-off-by: Li Xi Signed-off-by: Bobi Jam Reviewed-on: http://review.whamcloud.com/8772 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4269 Reviewed-by: Andreas Dilger Reviewed-by: Jinshan Xiong Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 0548aca45e8e..1066e00d541f 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -232,8 +232,6 @@ int ldlm_lock_remove_from_lru_nolock(struct ldlm_lock *lock) LASSERT(lock->l_resource->lr_type != LDLM_FLOCK); list_del_init(&lock->l_lru); - if (lock->l_flags & LDLM_FL_SKIPPED) - lock->l_flags &= ~LDLM_FL_SKIPPED; LASSERT(ns->ns_nr_unused > 0); ns->ns_nr_unused--; rc = 1; @@ -271,6 +269,8 @@ void ldlm_lock_add_to_lru_nolock(struct ldlm_lock *lock) LASSERT(list_empty(&lock->l_lru)); LASSERT(lock->l_resource->lr_type != LDLM_FLOCK); list_add_tail(&lock->l_lru, &ns->ns_unused_list); + if (lock->l_flags & LDLM_FL_SKIPPED) + lock->l_flags &= ~LDLM_FL_SKIPPED; LASSERT(ns->ns_nr_unused >= 0); ns->ns_nr_unused++; } -- cgit v1.2.3 From 34554afc055a381b6a963ce6cb4542c95ac5a875 Mon Sep 17 00:00:00 2001 From: Niu Yawei Date: Sun, 27 Apr 2014 13:06:32 -0400 Subject: staging/lustre/clio: clear nowait flag agl lock re-enqueue The LDLM_FL_BLOCK_NOWAIT flag should be cleared when re-enqueue the agl lock as normal glimpse, otherwise, it won't get size back if there is conflicting locks on other client. Signed-off-by: Niu Yawei Reviewed-on: http://review.whamcloud.com/9249 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4597 Reviewed-by: Bobi Jam Reviewed-by: Jinshan Xiong Reviewed-by: Ned Bass Reviewed-by: Fan Yong Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/osc/osc_lock.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index ef7b9c2b208e..1c6cafa3de70 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -1192,6 +1192,7 @@ static int osc_lock_wait(const struct lu_env *env, LASSERT(olck->ols_agl); olck->ols_agl = 0; + olck->ols_flags &= ~LDLM_FL_BLOCK_NOWAIT; rc = osc_lock_enqueue(env, slice, NULL, CEF_ASYNC | CEF_MUST); if (rc != 0) return rc; -- cgit v1.2.3 From 88291a7a6b3beb8a471cf347c4f36c85f9fc59e5 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Sun, 27 Apr 2014 13:06:33 -0400 Subject: staging/lustre/ptlrpc: don't try to recover no_recov connection If a connection has been stopped with ptlrpc_pinger_del_import() and marked obd_no_recov, don't reconnect in ptlrpc_disconnect_import() if the import is already disconnected. Otherwise, without the pinger it will just wait there indefinitely for the reconnection that will never happen. Put the obd_no_recov check inside ptlrpc_import_in_recovery() so that any threads waiting on the connection to recover would also be broken out of their sleep if obd_no_recov is set. Signed-off-by: Andreas Dilger Reviewed-on: http://review.whamcloud.com/8996 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4413 Reviewed-by: Nathaniel Clark Reviewed-by: wangdi Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/import.c | 29 +++++++++++++++++--------- drivers/staging/lustre/lustre/ptlrpc/recover.c | 5 ++++- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index a04a1cc87809..b231452d6215 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -1404,26 +1404,33 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose) { struct ptlrpc_request *req; int rq_opc, rc = 0; - int nowait = imp->imp_obd->obd_force; - if (nowait) + if (imp->imp_obd->obd_force) GOTO(set_state, rc); switch (imp->imp_connect_op) { - case OST_CONNECT: rq_opc = OST_DISCONNECT; break; - case MDS_CONNECT: rq_opc = MDS_DISCONNECT; break; - case MGS_CONNECT: rq_opc = MGS_DISCONNECT; break; + case OST_CONNECT: + rq_opc = OST_DISCONNECT; + break; + case MDS_CONNECT: + rq_opc = MDS_DISCONNECT; + break; + case MGS_CONNECT: + rq_opc = MGS_DISCONNECT; + break; default: - CERROR("don't know how to disconnect from %s (connect_op %d)\n", - obd2cli_tgt(imp->imp_obd), imp->imp_connect_op); - return -EINVAL; + rc = -EINVAL; + CERROR("%s: don't know how to disconnect from %s " + "(connect_op %d): rc = %d\n", + imp->imp_obd->obd_name, obd2cli_tgt(imp->imp_obd), + imp->imp_connect_op, rc); + return rc; } if (ptlrpc_import_in_recovery(imp)) { struct l_wait_info lwi; cfs_duration_t timeout; - if (AT_OFF) { if (imp->imp_server_timeout) timeout = cfs_time_seconds(obd_timeout / 2); @@ -1446,7 +1453,6 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose) spin_lock(&imp->imp_lock); if (imp->imp_state != LUSTRE_IMP_FULL) GOTO(out, 0); - spin_unlock(&imp->imp_lock); req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_DISCONNECT, @@ -1479,6 +1485,9 @@ out: memset(&imp->imp_remote_handle, 0, sizeof(imp->imp_remote_handle)); spin_unlock(&imp->imp_lock); + if (rc == -ETIMEDOUT || rc == -ENOTCONN || rc == -ESHUTDOWN) + rc = 0; + return rc; } EXPORT_SYMBOL(ptlrpc_disconnect_import); diff --git a/drivers/staging/lustre/lustre/ptlrpc/recover.c b/drivers/staging/lustre/lustre/ptlrpc/recover.c index 48ae328ce24e..4cff2f7ba412 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/recover.c +++ b/drivers/staging/lustre/lustre/ptlrpc/recover.c @@ -369,11 +369,14 @@ EXPORT_SYMBOL(ptlrpc_recover_import); int ptlrpc_import_in_recovery(struct obd_import *imp) { int in_recovery = 1; + spin_lock(&imp->imp_lock); if (imp->imp_state == LUSTRE_IMP_FULL || imp->imp_state == LUSTRE_IMP_CLOSED || - imp->imp_state == LUSTRE_IMP_DISCON) + imp->imp_state == LUSTRE_IMP_DISCON || + imp->imp_obd->obd_no_recov) in_recovery = 0; spin_unlock(&imp->imp_lock); + return in_recovery; } -- cgit v1.2.3 From 0dd08092c2ed1f949adc10638784c3212cdb59c3 Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Sun, 27 Apr 2014 13:06:34 -0400 Subject: staging/lustre/gss: fix few issues found by Klocwork Insight tool Array 'message_buf' of size 500 may use index value(s) -1 Object 'enc_key.data' was freed at line 164 after being freed by calling 'free' at line 150. Also there are 3 similar errors on line(s) 164. Suspicious dereference of pointer 'vmsg' before NULL check at line 187. Also there are 2 similar errors on line(s) 196, 205. Suspicious dereference of pointer 'rmsg' before NULL check at line 191. Also there are 2 similar errors on line(s) 200, 209. Signed-off-by: Dmitry Eremin Reviewed-on: http://review.whamcloud.com/9274 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4629 Reviewed-by: John L. Hammond Reviewed-by: James Simmons Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/gss/gss_bulk.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_bulk.c index 7852bf30a3a0..93794bd928cb 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_bulk.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_bulk.c @@ -176,31 +176,31 @@ int gss_cli_ctx_unwrap_bulk(struct ptlrpc_cli_ctx *ctx, switch (SPTLRPC_FLVR_SVC(req->rq_flvr.sf_rpc)) { case SPTLRPC_SVC_NULL: vmsg = req->rq_repdata; + LASSERT(vmsg != NULL && vmsg->lm_bufcount >= 3); voff = vmsg->lm_bufcount - 1; - LASSERT(vmsg && vmsg->lm_bufcount >= 3); rmsg = req->rq_reqbuf; + LASSERT(rmsg != NULL && rmsg->lm_bufcount >= 3); roff = rmsg->lm_bufcount - 1; /* last segment */ - LASSERT(rmsg && rmsg->lm_bufcount >= 3); break; case SPTLRPC_SVC_AUTH: case SPTLRPC_SVC_INTG: vmsg = req->rq_repdata; + LASSERT(vmsg != NULL && vmsg->lm_bufcount >= 4); voff = vmsg->lm_bufcount - 2; - LASSERT(vmsg && vmsg->lm_bufcount >= 4); rmsg = req->rq_reqbuf; + LASSERT(rmsg != NULL && rmsg->lm_bufcount >= 4); roff = rmsg->lm_bufcount - 2; /* second last segment */ - LASSERT(rmsg && rmsg->lm_bufcount >= 4); break; case SPTLRPC_SVC_PRIV: vmsg = req->rq_repdata; + LASSERT(vmsg != NULL && vmsg->lm_bufcount >= 2); voff = vmsg->lm_bufcount - 1; - LASSERT(vmsg && vmsg->lm_bufcount >= 2); rmsg = req->rq_clrbuf; + LASSERT(rmsg != NULL && rmsg->lm_bufcount >= 2); roff = rmsg->lm_bufcount - 1; /* last segment */ - LASSERT(rmsg && rmsg->lm_bufcount >= 2); break; default: LBUG(); -- cgit v1.2.3 From 35b2e1b720172d5aa5e2de57dfc905b1f075f150 Mon Sep 17 00:00:00 2001 From: Andriy Skulysh Date: Sun, 27 Apr 2014 13:06:35 -0400 Subject: staging/lustre/ptlrpc: add rpc_cache Add rpc_cache for allocating ptlrpc_requests. Xyratex-bug-id: MRP-689 Signed-off-by: Andriy Skulysh Signed-off-by: Niu Yawei Reviewed-on: http://review.whamcloud.com/6874 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2424 Reviewed-by: Andreas Dilger Reviewed-by: Lai Siyao Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/client.c | 42 ++++++++++++++++++---- drivers/staging/lustre/lustre/ptlrpc/events.c | 2 +- .../staging/lustre/lustre/ptlrpc/ptlrpc_internal.h | 4 +++ .../staging/lustre/lustre/ptlrpc/ptlrpc_module.c | 32 ++++++++++++----- drivers/staging/lustre/lustre/ptlrpc/sec.c | 10 +++--- drivers/staging/lustre/lustre/ptlrpc/service.c | 13 ++++--- 6 files changed, 75 insertions(+), 28 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 4c9e00695087..5bee8206d70b 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -379,6 +379,34 @@ static int ptlrpc_at_recv_early_reply(struct ptlrpc_request *req) return rc; } +struct kmem_cache *request_cache; + +int ptlrpc_request_cache_init(void) +{ + request_cache = kmem_cache_create("ptlrpc_cache", + sizeof(struct ptlrpc_request), + 0, SLAB_HWCACHE_ALIGN, NULL); + return request_cache == NULL ? -ENOMEM : 0; +} + +void ptlrpc_request_cache_fini(void) +{ + kmem_cache_destroy(request_cache); +} + +struct ptlrpc_request *ptlrpc_request_cache_alloc(int flags) +{ + struct ptlrpc_request *req; + + OBD_SLAB_ALLOC_PTR_GFP(req, request_cache, flags); + return req; +} + +void ptlrpc_request_cache_free(struct ptlrpc_request *req) +{ + OBD_SLAB_FREE_PTR(req, request_cache); +} + /** * Wind down request pool \a pool. * Frees all requests from the pool too @@ -397,7 +425,7 @@ void ptlrpc_free_rq_pool(struct ptlrpc_request_pool *pool) LASSERT(req->rq_reqbuf); LASSERT(req->rq_reqbuf_len == pool->prp_rq_size); OBD_FREE_LARGE(req->rq_reqbuf, pool->prp_rq_size); - OBD_FREE(req, sizeof(*req)); + ptlrpc_request_cache_free(req); } spin_unlock(&pool->prp_lock); OBD_FREE(pool, sizeof(*pool)); @@ -427,12 +455,12 @@ void ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq) struct lustre_msg *msg; spin_unlock(&pool->prp_lock); - OBD_ALLOC(req, sizeof(struct ptlrpc_request)); + req = ptlrpc_request_cache_alloc(__GFP_IO); if (!req) return; OBD_ALLOC_LARGE(msg, size); if (!msg) { - OBD_FREE(req, sizeof(struct ptlrpc_request)); + ptlrpc_request_cache_free(req); return; } req->rq_reqbuf = msg; @@ -668,7 +696,7 @@ struct ptlrpc_request *__ptlrpc_request_alloc(struct obd_import *imp, request = ptlrpc_prep_req_from_pool(pool); if (!request) - OBD_ALLOC_PTR(request); + request = ptlrpc_request_cache_alloc(__GFP_IO); if (request) { LASSERTF((unsigned long)imp > 0x1000, "%p", imp); @@ -739,7 +767,7 @@ void ptlrpc_request_free(struct ptlrpc_request *request) if (request->rq_pool) __ptlrpc_free_req_to_pool(request); else - OBD_FREE_PTR(request); + ptlrpc_request_cache_free(request); } EXPORT_SYMBOL(ptlrpc_request_free); @@ -2233,7 +2261,7 @@ static void __ptlrpc_free_req(struct ptlrpc_request *request, int locked) if (request->rq_pool) __ptlrpc_free_req_to_pool(request); else - OBD_FREE(request, sizeof(*request)); + ptlrpc_request_cache_free(request); } static int __ptlrpc_req_finished(struct ptlrpc_request *request, int locked); @@ -3023,7 +3051,7 @@ void *ptlrpcd_alloc_work(struct obd_import *imp, return ERR_PTR(-EINVAL); /* copy some code from deprecated fakereq. */ - OBD_ALLOC_PTR(req); + req = ptlrpc_request_cache_alloc(__GFP_IO); if (req == NULL) { CERROR("ptlrpc: run out of memory!\n"); return ERR_PTR(-ENOMEM); diff --git a/drivers/staging/lustre/lustre/ptlrpc/events.c b/drivers/staging/lustre/lustre/ptlrpc/events.c index 6ea0a491cfb3..aa85239f6cd5 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/events.c +++ b/drivers/staging/lustre/lustre/ptlrpc/events.c @@ -307,7 +307,7 @@ void request_in_callback(lnet_event_t *ev) /* We moaned above already... */ return; } - OBD_ALLOC_GFP(req, sizeof(*req), ALLOC_ATOMIC_TRY); + req = ptlrpc_request_cache_alloc(ALLOC_ATOMIC_TRY); if (req == NULL) { CERROR("Can't allocate incoming request descriptor: " "Dropping %s RPC from %s\n", diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h index e3b5a920bca2..7c9405530596 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h @@ -55,6 +55,10 @@ int ptlrpcd_start(int index, int max, const char *name, struct ptlrpcd_ctl *pc); /* client.c */ struct ptlrpc_bulk_desc *ptlrpc_new_bulk(unsigned npages, unsigned max_brw, unsigned type, unsigned portal); +int ptlrpc_request_cache_init(void); +void ptlrpc_request_cache_fini(void); +struct ptlrpc_request *ptlrpc_request_cache_alloc(int flags); +void ptlrpc_request_cache_free(struct ptlrpc_request *req); void ptlrpc_init_xid(void); /* events.c */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c index 0efd35887a15..251ae75c2dd9 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c @@ -73,29 +73,34 @@ __init int ptlrpc_init(void) return rc; cleanup_phase = 1; + rc = ptlrpc_request_cache_init(); + if (rc) + GOTO(cleanup, rc); + cleanup_phase = 2; rc = ptlrpc_init_portals(); if (rc) GOTO(cleanup, rc); - cleanup_phase = 2; + + cleanup_phase = 3; rc = ptlrpc_connection_init(); if (rc) GOTO(cleanup, rc); - cleanup_phase = 3; + cleanup_phase = 4; ptlrpc_put_connection_superhack = ptlrpc_connection_put; rc = ptlrpc_start_pinger(); if (rc) GOTO(cleanup, rc); - cleanup_phase = 4; + cleanup_phase = 5; rc = ldlm_init(); if (rc) GOTO(cleanup, rc); - cleanup_phase = 5; + cleanup_phase = 6; rc = sptlrpc_init(); if (rc) GOTO(cleanup, rc); @@ -115,19 +120,29 @@ cleanup: switch (cleanup_phase) { case 8: ptlrpc_nrs_fini(); + /* Fall through */ case 7: sptlrpc_fini(); - case 5: + /* Fall through */ + case 6: ldlm_exit(); - case 4: + /* Fall through */ + case 5: ptlrpc_stop_pinger(); - case 3: + /* Fall through */ + case 4: ptlrpc_connection_fini(); - case 2: + /* Fall through */ + case 3: ptlrpc_exit_portals(); + /* Fall through */ + case 2: + ptlrpc_request_cache_fini(); + /* Fall through */ case 1: ptlrpc_hr_fini(); req_layout_fini(); + /* Fall through */ default: ; } @@ -142,6 +157,7 @@ static void __exit ptlrpc_exit(void) ldlm_exit(); ptlrpc_stop_pinger(); ptlrpc_exit_portals(); + ptlrpc_request_cache_fini(); ptlrpc_hr_fini(); ptlrpc_connection_fini(); } diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index 5e7539292f5e..3772ab10026a 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -904,7 +904,7 @@ int sptlrpc_import_check_ctx(struct obd_import *imp) return -EACCES; } - OBD_ALLOC_PTR(req); + req = ptlrpc_request_cache_alloc(__GFP_IO); if (!req) return -ENOMEM; @@ -920,7 +920,7 @@ int sptlrpc_import_check_ctx(struct obd_import *imp) rc = sptlrpc_req_refresh_ctx(req, 0); LASSERT(list_empty(&req->rq_ctx_chain)); sptlrpc_cli_ctx_put(req->rq_cli_ctx, 1); - OBD_FREE_PTR(req); + ptlrpc_request_cache_free(req); return rc; } @@ -1088,7 +1088,7 @@ int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req, int early_bufsz, early_size; int rc; - OBD_ALLOC_PTR(early_req); + early_req = ptlrpc_request_cache_alloc(__GFP_IO); if (early_req == NULL) return -ENOMEM; @@ -1160,7 +1160,7 @@ err_ctx: err_buf: OBD_FREE_LARGE(early_buf, early_bufsz); err_req: - OBD_FREE_PTR(early_req); + ptlrpc_request_cache_free(early_req); return rc; } @@ -1177,7 +1177,7 @@ void sptlrpc_cli_finish_early_reply(struct ptlrpc_request *early_req) sptlrpc_cli_ctx_put(early_req->rq_cli_ctx, 1); OBD_FREE_LARGE(early_req->rq_repbuf, early_req->rq_repbuf_len); - OBD_FREE_PTR(early_req); + ptlrpc_request_cache_free(early_req); } /************************************************** diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 5873c03b8e77..4dd2bcba43f7 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -842,7 +842,7 @@ static void ptlrpc_server_free_request(struct ptlrpc_request *req) /* NB request buffers use an embedded * req if the incoming req unlinked the * MD; this isn't one of them! */ - OBD_FREE(req, sizeof(*req)); + ptlrpc_request_cache_free(req); } } @@ -1305,14 +1305,12 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) } newdl = cfs_time_current_sec() + at_get(&svcpt->scp_at_estimate); - OBD_ALLOC(reqcopy, sizeof(*reqcopy)); + reqcopy = ptlrpc_request_cache_alloc(__GFP_IO); if (reqcopy == NULL) return -ENOMEM; OBD_ALLOC_LARGE(reqmsg, req->rq_reqlen); - if (!reqmsg) { - OBD_FREE(reqcopy, sizeof(*reqcopy)); - return -ENOMEM; - } + if (!reqmsg) + GOTO(out_free, rc = -ENOMEM); *reqcopy = *req; reqcopy->rq_reply_state = NULL; @@ -1369,7 +1367,8 @@ out_put: out: sptlrpc_svc_ctx_decref(reqcopy); OBD_FREE_LARGE(reqmsg, req->rq_reqlen); - OBD_FREE(reqcopy, sizeof(*reqcopy)); +out_free: + ptlrpc_request_cache_free(reqcopy); return rc; } -- cgit v1.2.3 From 0be19afa74b73a2132dc02b4fea0c6b5a2e29151 Mon Sep 17 00:00:00 2001 From: Ann Koehler Date: Sun, 27 Apr 2014 13:06:36 -0400 Subject: staging/lustre: restore __GFP_WAIT flag to memalloc calls In Lustre 2.4, the flags passed to the memory allocation functions are translated from CFS enumeration values types to the kernel GFP values by calling cfs_alloc_flags_to_gfp(). This function adds __GFP_WAIT to all flags except CFS_ALLOC_ATOMIC. In 2.5, when the cfs wrappers were dropped, cfs_alloc_flags_to_gfp() was removed and the CFS_ALLOC_xxxx was simply replaced with __GFP_xxxx. This means that most memory allocation calls are missing the __GFP_WAIT flag. The result is that Lustre experiences more ENOMEM errors, many of which the higher levels of Lustre do not handle robustly. Notes GFP_NOFS = __GFP_WAIT | __GFP_IO. So the patch replaces __GFP_IO with GFP_NOFS. Patch does not add __GFP_WAIT to GFP_IOFS. GFP_IOFS was not used in Lustre 2.4 so it has never been used with __GFP_WAIT. Signed-off-by: Ann Koehler Signed-off-by: Emoly Liu Reviewed-on: http://review.whamcloud.com/9223 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4357 Reviewed-by: Liang Zhen Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/include/linux/libcfs/libcfs_private.h | 4 ++-- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 2 +- drivers/staging/lustre/lustre/include/obd_class.h | 2 +- drivers/staging/lustre/lustre/include/obd_support.h | 10 +++++----- drivers/staging/lustre/lustre/lclient/lcommon_cl.c | 13 ++++++------- drivers/staging/lustre/lustre/ldlm/ldlm_extent.c | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 6 +++--- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 2 +- drivers/staging/lustre/lustre/llite/file.c | 2 +- drivers/staging/lustre/lustre/llite/super25.c | 2 +- drivers/staging/lustre/lustre/llite/vvp_dev.c | 4 ++-- drivers/staging/lustre/lustre/llite/xattr_cache.c | 2 +- drivers/staging/lustre/lustre/lov/lov_dev.c | 6 +++--- drivers/staging/lustre/lustre/lov/lov_ea.c | 2 +- drivers/staging/lustre/lustre/lov/lov_lock.c | 6 +++--- drivers/staging/lustre/lustre/lov/lov_object.c | 2 +- drivers/staging/lustre/lustre/lov/lovsub_dev.c | 2 +- drivers/staging/lustre/lustre/lov/lovsub_lock.c | 2 +- drivers/staging/lustre/lustre/lov/lovsub_object.c | 2 +- drivers/staging/lustre/lustre/obdclass/cl_lock.c | 2 +- drivers/staging/lustre/lustre/obdclass/cl_object.c | 2 +- drivers/staging/lustre/lustre/obdclass/cl_page.c | 2 +- drivers/staging/lustre/lustre/obdclass/genops.c | 2 +- drivers/staging/lustre/lustre/obdecho/echo_client.c | 8 ++++---- drivers/staging/lustre/lustre/osc/osc_dev.c | 4 ++-- drivers/staging/lustre/lustre/osc/osc_io.c | 2 +- drivers/staging/lustre/lustre/osc/osc_lock.c | 2 +- drivers/staging/lustre/lustre/osc/osc_object.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/client.c | 6 +++--- drivers/staging/lustre/lustre/ptlrpc/nrs.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/sec.c | 4 ++-- drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/service.c | 2 +- 33 files changed, 57 insertions(+), 58 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h index dddccca120c9..740bfcd2f09a 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h @@ -153,7 +153,7 @@ do { \ * default allocator */ #define LIBCFS_ALLOC(ptr, size) \ - LIBCFS_ALLOC_GFP(ptr, size, __GFP_IO) + LIBCFS_ALLOC_GFP(ptr, size, GFP_NOFS) /** * non-sleeping allocator @@ -177,7 +177,7 @@ do { \ /** default numa allocator */ #define LIBCFS_CPT_ALLOC(ptr, cptab, cpt, size) \ - LIBCFS_CPT_ALLOC_GFP(ptr, cptab, cpt, size, __GFP_IO) + LIBCFS_CPT_ALLOC_GFP(ptr, cptab, cpt, size, GFP_NOFS) #define LIBCFS_FREE(ptr, size) \ do { \ diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index 0061c8afa206..892c41991f83 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -1141,7 +1141,7 @@ kiblnd_alloc_pages(kib_pages_t **pp, int cpt, int npages) for (i = 0; i < npages; i++) { p->ibp_pages[i] = alloc_pages_node( cfs_cpt_spread_node(lnet_cpt_table(), cpt), - __GFP_IO, 0); + GFP_NOFS, 0); if (p->ibp_pages[i] == NULL) { CERROR("Can't allocate page %d of %d\n", i, npages); kiblnd_free_pages(p); diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 9d1f266e55e4..6c8e1ab9e6b4 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -2133,7 +2133,7 @@ extern struct kmem_cache *obdo_cachep; #define OBDO_ALLOC(ptr) \ do { \ - OBD_SLAB_ALLOC_PTR_GFP((ptr), obdo_cachep, __GFP_IO); \ + OBD_SLAB_ALLOC_PTR_GFP((ptr), obdo_cachep, GFP_NOFS); \ } while(0) #define OBDO_FREE(ptr) \ diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h index 5ec336968fc8..cc5af509b261 100644 --- a/drivers/staging/lustre/lustre/include/obd_support.h +++ b/drivers/staging/lustre/lustre/include/obd_support.h @@ -641,8 +641,8 @@ do { \ #define OBD_ALLOC_GFP(ptr, size, gfp_mask) \ __OBD_MALLOC_VERBOSE(ptr, NULL, 0, size, gfp_mask) -#define OBD_ALLOC(ptr, size) OBD_ALLOC_GFP(ptr, size, __GFP_IO) -#define OBD_ALLOC_WAIT(ptr, size) OBD_ALLOC_GFP(ptr, size, GFP_IOFS) +#define OBD_ALLOC(ptr, size) OBD_ALLOC_GFP(ptr, size, GFP_NOFS) +#define OBD_ALLOC_WAIT(ptr, size) OBD_ALLOC_GFP(ptr, size, GFP_KERNEL) #define OBD_ALLOC_PTR(ptr) OBD_ALLOC(ptr, sizeof(*(ptr))) #define OBD_ALLOC_PTR_WAIT(ptr) OBD_ALLOC_WAIT(ptr, sizeof(*(ptr))) @@ -650,7 +650,7 @@ do { \ __OBD_MALLOC_VERBOSE(ptr, cptab, cpt, size, gfp_mask) #define OBD_CPT_ALLOC(ptr, cptab, cpt, size) \ - OBD_CPT_ALLOC_GFP(ptr, cptab, cpt, size, __GFP_IO) + OBD_CPT_ALLOC_GFP(ptr, cptab, cpt, size, GFP_NOFS) #define OBD_CPT_ALLOC_PTR(ptr, cptab, cpt) \ OBD_CPT_ALLOC(ptr, cptab, cpt, sizeof(*(ptr))) @@ -793,10 +793,10 @@ do { \ } while(0) #define OBD_SLAB_ALLOC(ptr, slab, size) \ - OBD_SLAB_ALLOC_GFP(ptr, slab, size, __GFP_IO) + OBD_SLAB_ALLOC_GFP(ptr, slab, size, GFP_NOFS) #define OBD_SLAB_CPT_ALLOC(ptr, slab, cptab, cpt, size) \ - OBD_SLAB_CPT_ALLOC_GFP(ptr, slab, cptab, cpt, size, __GFP_IO) + OBD_SLAB_CPT_ALLOC_GFP(ptr, slab, cptab, cpt, size, GFP_NOFS) #define OBD_SLAB_ALLOC_PTR(ptr, slab) \ OBD_SLAB_ALLOC(ptr, slab, sizeof(*(ptr))) diff --git a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c index 6907a16dbbd1..12812fcc70b1 100644 --- a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c +++ b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c @@ -112,12 +112,11 @@ static struct lu_kmem_descr ccc_caches[] = { * */ -void *ccc_key_init(const struct lu_context *ctx, - struct lu_context_key *key) +void *ccc_key_init(const struct lu_context *ctx, struct lu_context_key *key) { struct ccc_thread_info *info; - OBD_SLAB_ALLOC_PTR_GFP(info, ccc_thread_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(info, ccc_thread_kmem, GFP_NOFS); if (info == NULL) info = ERR_PTR(-ENOMEM); return info; @@ -135,7 +134,7 @@ void *ccc_session_key_init(const struct lu_context *ctx, { struct ccc_session *session; - OBD_SLAB_ALLOC_PTR_GFP(session, ccc_session_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(session, ccc_session_kmem, GFP_NOFS); if (session == NULL) session = ERR_PTR(-ENOMEM); return session; @@ -251,7 +250,7 @@ int ccc_req_init(const struct lu_env *env, struct cl_device *dev, struct ccc_req *vrq; int result; - OBD_SLAB_ALLOC_PTR_GFP(vrq, ccc_req_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(vrq, ccc_req_kmem, GFP_NOFS); if (vrq != NULL) { cl_req_slice_add(req, &vrq->crq_cl, dev, &ccc_req_ops); result = 0; @@ -327,7 +326,7 @@ struct lu_object *ccc_object_alloc(const struct lu_env *env, struct ccc_object *vob; struct lu_object *obj; - OBD_SLAB_ALLOC_PTR_GFP(vob, ccc_object_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(vob, ccc_object_kmem, GFP_NOFS); if (vob != NULL) { struct cl_object_header *hdr; @@ -396,7 +395,7 @@ int ccc_lock_init(const struct lu_env *env, CLOBINVRNT(env, obj, ccc_object_invariant(obj)); - OBD_SLAB_ALLOC_PTR_GFP(clk, ccc_lock_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(clk, ccc_lock_kmem, GFP_NOFS); if (clk != NULL) { cl_lock_slice_add(lock, &clk->clk_cl, obj, lkops); result = 0; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c index ac5d66aa7f02..bde3a82ce0dd 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c @@ -104,7 +104,7 @@ struct ldlm_interval *ldlm_interval_alloc(struct ldlm_lock *lock) struct ldlm_interval *node; LASSERT(lock->l_resource->lr_type == LDLM_EXTENT); - OBD_SLAB_ALLOC_PTR_GFP(node, ldlm_interval_slab, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(node, ldlm_interval_slab, GFP_NOFS); if (node == NULL) return NULL; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 1066e00d541f..1b3f5c1eb808 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -437,7 +437,7 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource) if (resource == NULL) LBUG(); - OBD_SLAB_ALLOC_PTR_GFP(lock, ldlm_lock_slab, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(lock, ldlm_lock_slab, GFP_NOFS); if (lock == NULL) return NULL; @@ -1624,7 +1624,7 @@ ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *ns, * have to allocate the interval node early otherwise we can't regrant * this lock in the future. - jay */ if (!local && (*flags & LDLM_FL_REPLAY) && res->lr_type == LDLM_EXTENT) - OBD_SLAB_ALLOC_PTR_GFP(node, ldlm_interval_slab, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(node, ldlm_interval_slab, GFP_NOFS); lock_res_and_lock(lock); if (local && lock->l_req_mode == lock->l_granted_mode) { @@ -2146,7 +2146,7 @@ struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode, /* I can't check the type of lock here because the bitlock of lock * is not held here, so do the allocation blindly. -jay */ - OBD_SLAB_ALLOC_PTR_GFP(node, ldlm_interval_slab, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(node, ldlm_interval_slab, GFP_NOFS); if (node == NULL) /* Actually, this causes EDEADLOCK to be returned */ return NULL; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 2824d4a9a85b..a4cec5e63ce0 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -1014,7 +1014,7 @@ static struct ldlm_resource *ldlm_resource_new(void) struct ldlm_resource *res; int idx; - OBD_SLAB_ALLOC_PTR_GFP(res, ldlm_resource_slab, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(res, ldlm_resource_slab, GFP_NOFS); if (res == NULL) return NULL; diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 8e844a6371e0..d01c864053f2 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -54,7 +54,7 @@ struct ll_file_data *ll_file_data_get(void) { struct ll_file_data *fd; - OBD_SLAB_ALLOC_PTR_GFP(fd, ll_file_data_slab, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(fd, ll_file_data_slab, GFP_NOFS); if (fd == NULL) return NULL; fd->fd_write_failed = false; diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c index e21e1c760a8e..58bb8f21dbe5 100644 --- a/drivers/staging/lustre/lustre/llite/super25.c +++ b/drivers/staging/lustre/lustre/llite/super25.c @@ -52,7 +52,7 @@ static struct inode *ll_alloc_inode(struct super_block *sb) { struct ll_inode_info *lli; ll_stats_ops_tally(ll_s2sbi(sb), LPROC_LL_ALLOC_INODE, 1); - OBD_SLAB_ALLOC_PTR_GFP(lli, ll_inode_cachep, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(lli, ll_inode_cachep, GFP_NOFS); if (lli == NULL) return NULL; diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c index c4d1580b7be5..a9778b874e30 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_dev.c +++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c @@ -80,7 +80,7 @@ static void *vvp_key_init(const struct lu_context *ctx, { struct vvp_thread_info *info; - OBD_SLAB_ALLOC_PTR_GFP(info, vvp_thread_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(info, vvp_thread_kmem, GFP_NOFS); if (info == NULL) info = ERR_PTR(-ENOMEM); return info; @@ -98,7 +98,7 @@ static void *vvp_session_key_init(const struct lu_context *ctx, { struct vvp_session *session; - OBD_SLAB_ALLOC_PTR_GFP(session, vvp_session_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(session, vvp_session_kmem, GFP_NOFS); if (session == NULL) session = ERR_PTR(-ENOMEM); return session; diff --git a/drivers/staging/lustre/lustre/llite/xattr_cache.c b/drivers/staging/lustre/lustre/llite/xattr_cache.c index 4defa2fd83b3..dfd19f801013 100644 --- a/drivers/staging/lustre/lustre/llite/xattr_cache.c +++ b/drivers/staging/lustre/lustre/llite/xattr_cache.c @@ -120,7 +120,7 @@ static int ll_xattr_cache_add(struct list_head *cache, return -EPROTO; } - OBD_SLAB_ALLOC_PTR_GFP(xattr, xattr_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(xattr, xattr_kmem, GFP_NOFS); if (xattr == NULL) { CDEBUG(D_CACHE, "failed to allocate xattr\n"); return -ENOMEM; diff --git a/drivers/staging/lustre/lustre/lov/lov_dev.c b/drivers/staging/lustre/lustre/lov/lov_dev.c index 1f33b04b0c38..53e5781ba1d9 100644 --- a/drivers/staging/lustre/lustre/lov/lov_dev.c +++ b/drivers/staging/lustre/lustre/lov/lov_dev.c @@ -143,7 +143,7 @@ static void *lov_key_init(const struct lu_context *ctx, { struct lov_thread_info *info; - OBD_SLAB_ALLOC_PTR_GFP(info, lov_thread_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(info, lov_thread_kmem, GFP_NOFS); if (info != NULL) INIT_LIST_HEAD(&info->lti_closure.clc_list); else @@ -170,7 +170,7 @@ static void *lov_session_key_init(const struct lu_context *ctx, { struct lov_session *info; - OBD_SLAB_ALLOC_PTR_GFP(info, lov_session_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(info, lov_session_kmem, GFP_NOFS); if (info == NULL) info = ERR_PTR(-ENOMEM); return info; @@ -260,7 +260,7 @@ static int lov_req_init(const struct lu_env *env, struct cl_device *dev, struct lov_req *lr; int result; - OBD_SLAB_ALLOC_PTR_GFP(lr, lov_req_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(lr, lov_req_kmem, GFP_NOFS); if (lr != NULL) { cl_req_slice_add(req, &lr->lr_cl, dev, &lov_req_ops); result = 0; diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c b/drivers/staging/lustre/lustre/lov/lov_ea.c index 6f356e025543..b91cb2ab8e21 100644 --- a/drivers/staging/lustre/lustre/lov/lov_ea.c +++ b/drivers/staging/lustre/lustre/lov/lov_ea.c @@ -101,7 +101,7 @@ struct lov_stripe_md *lsm_alloc_plain(__u16 stripe_count, int *size) return NULL; for (i = 0; i < stripe_count; i++) { - OBD_SLAB_ALLOC_PTR_GFP(loi, lov_oinfo_slab, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(loi, lov_oinfo_slab, GFP_NOFS); if (loi == NULL) goto err; lsm->lsm_oinfo[i] = loi; diff --git a/drivers/staging/lustre/lustre/lov/lov_lock.c b/drivers/staging/lustre/lustre/lov/lov_lock.c index ed2726e523e8..0bbe141bf4e4 100644 --- a/drivers/staging/lustre/lustre/lov/lov_lock.c +++ b/drivers/staging/lustre/lustre/lov/lov_lock.c @@ -144,7 +144,7 @@ static struct cl_lock *lov_sublock_alloc(const struct lu_env *env, LASSERT(idx < lck->lls_nr); - OBD_SLAB_ALLOC_PTR_GFP(link, lov_lock_link_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(link, lov_lock_link_kmem, GFP_NOFS); if (link != NULL) { struct lov_sublock_env *subenv; struct lov_lock_sub *lls; @@ -1159,7 +1159,7 @@ int lov_lock_init_raid0(const struct lu_env *env, struct cl_object *obj, struct lov_lock *lck; int result; - OBD_SLAB_ALLOC_PTR_GFP(lck, lov_lock_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(lck, lov_lock_kmem, GFP_NOFS); if (lck != NULL) { cl_lock_slice_add(lock, &lck->lls_cl, obj, &lov_lock_ops); result = lov_lock_sub_init(env, lck, io); @@ -1194,7 +1194,7 @@ int lov_lock_init_empty(const struct lu_env *env, struct cl_object *obj, struct lov_lock *lck; int result = -ENOMEM; - OBD_SLAB_ALLOC_PTR_GFP(lck, lov_lock_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(lck, lov_lock_kmem, GFP_NOFS); if (lck != NULL) { cl_lock_slice_add(lock, &lck->lls_cl, obj, &lov_empty_lock_ops); lck->lls_orig = lock->cll_descr; diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c index d6b2cb45b938..f20e497c5404 100644 --- a/drivers/staging/lustre/lustre/lov/lov_object.c +++ b/drivers/staging/lustre/lustre/lov/lov_object.c @@ -885,7 +885,7 @@ struct lu_object *lov_object_alloc(const struct lu_env *env, struct lov_object *lov; struct lu_object *obj; - OBD_SLAB_ALLOC_PTR_GFP(lov, lov_object_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(lov, lov_object_kmem, GFP_NOFS); if (lov != NULL) { obj = lov2lu(lov); lu_object_init(obj, NULL, dev); diff --git a/drivers/staging/lustre/lustre/lov/lovsub_dev.c b/drivers/staging/lustre/lustre/lov/lovsub_dev.c index 926c35a25ceb..52fb6c162ad7 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_dev.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_dev.c @@ -146,7 +146,7 @@ static int lovsub_req_init(const struct lu_env *env, struct cl_device *dev, struct lovsub_req *lsr; int result; - OBD_SLAB_ALLOC_PTR_GFP(lsr, lovsub_req_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(lsr, lovsub_req_kmem, GFP_NOFS); if (lsr != NULL) { cl_req_slice_add(req, &lsr->lsrq_cl, dev, &lovsub_req_ops); result = 0; diff --git a/drivers/staging/lustre/lustre/lov/lovsub_lock.c b/drivers/staging/lustre/lustre/lov/lovsub_lock.c index 80305aa61712..62b696d25d81 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_lock.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_lock.c @@ -453,7 +453,7 @@ int lovsub_lock_init(const struct lu_env *env, struct cl_object *obj, struct lovsub_lock *lsk; int result; - OBD_SLAB_ALLOC_PTR_GFP(lsk, lovsub_lock_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(lsk, lovsub_lock_kmem, GFP_NOFS); if (lsk != NULL) { INIT_LIST_HEAD(&lsk->lss_parents); cl_lock_slice_add(lock, &lsk->lss_cl, obj, &lovsub_lock_ops); diff --git a/drivers/staging/lustre/lustre/lov/lovsub_object.c b/drivers/staging/lustre/lustre/lov/lovsub_object.c index 89760b3bf3f7..57e3629fccee 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_object.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_object.c @@ -145,7 +145,7 @@ struct lu_object *lovsub_object_alloc(const struct lu_env *env, struct lovsub_object *los; struct lu_object *obj; - OBD_SLAB_ALLOC_PTR_GFP(los, lovsub_object_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(los, lovsub_object_kmem, GFP_NOFS); if (los != NULL) { struct cl_object_header *hdr; diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c index 8eb1785645ba..918f433b22d9 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c @@ -360,7 +360,7 @@ static struct cl_lock *cl_lock_alloc(const struct lu_env *env, struct cl_lock *lock; struct lu_object_header *head; - OBD_SLAB_ALLOC_PTR_GFP(lock, cl_lock_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(lock, cl_lock_kmem, GFP_NOFS); if (lock != NULL) { atomic_set(&lock->cll_ref, 1); lock->cll_descr = *descr; diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c index 0fc256f59e92..2837cbc8865d 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c @@ -684,7 +684,7 @@ static struct lu_env *cl_env_new(__u32 ctx_tags, __u32 ses_tags, void *debug) struct lu_env *env; struct cl_env *cle; - OBD_SLAB_ALLOC_PTR_GFP(cle, cl_env_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(cle, cl_env_kmem, GFP_NOFS); if (cle != NULL) { int rc; diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index 2a5ce376e577..a4b04cba0b24 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -292,7 +292,7 @@ static struct cl_page *cl_page_alloc(const struct lu_env *env, struct lu_object_header *head; OBD_ALLOC_GFP(page, cl_object_header(o)->coh_page_bufsize, - __GFP_IO); + GFP_NOFS); if (page != NULL) { int result = 0; atomic_set(&page->cp_ref, 1); diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index 350b6f079d92..3210ad8184b9 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -72,7 +72,7 @@ static struct obd_device *obd_device_alloc(void) { struct obd_device *obd; - OBD_SLAB_ALLOC_PTR_GFP(obd, obd_device_cachep, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(obd, obd_device_cachep, GFP_NOFS); if (obd != NULL) { obd->obd_magic = OBD_DEVICE_MAGIC; } diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index a7f5e41ebf77..0eb39f25d9c2 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -428,7 +428,7 @@ static int echo_lock_init(const struct lu_env *env, { struct echo_lock *el; - OBD_SLAB_ALLOC_PTR_GFP(el, echo_lock_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(el, echo_lock_kmem, GFP_NOFS); if (el != NULL) { cl_lock_slice_add(lock, &el->el_cl, obj, &echo_lock_ops); el->el_object = cl2echo_obj(obj); @@ -599,7 +599,7 @@ static struct lu_object *echo_object_alloc(const struct lu_env *env, /* we're the top dev. */ LASSERT(hdr == NULL); - OBD_SLAB_ALLOC_PTR_GFP(eco, echo_object_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(eco, echo_object_kmem, GFP_NOFS); if (eco != NULL) { struct cl_object_header *hdr = &eco->eo_hdr; @@ -663,7 +663,7 @@ static void *echo_thread_key_init(const struct lu_context *ctx, { struct echo_thread_info *info; - OBD_SLAB_ALLOC_PTR_GFP(info, echo_thread_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(info, echo_thread_kmem, GFP_NOFS); if (info == NULL) info = ERR_PTR(-ENOMEM); return info; @@ -693,7 +693,7 @@ static void *echo_session_key_init(const struct lu_context *ctx, { struct echo_session_info *session; - OBD_SLAB_ALLOC_PTR_GFP(session, echo_session_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(session, echo_session_kmem, GFP_NOFS); if (session == NULL) session = ERR_PTR(-ENOMEM); return session; diff --git a/drivers/staging/lustre/lustre/osc/osc_dev.c b/drivers/staging/lustre/lustre/osc/osc_dev.c index 35f257867637..6a6483920c4d 100644 --- a/drivers/staging/lustre/lustre/osc/osc_dev.c +++ b/drivers/staging/lustre/lustre/osc/osc_dev.c @@ -122,7 +122,7 @@ static void *osc_key_init(const struct lu_context *ctx, { struct osc_thread_info *info; - OBD_SLAB_ALLOC_PTR_GFP(info, osc_thread_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(info, osc_thread_kmem, GFP_NOFS); if (info == NULL) info = ERR_PTR(-ENOMEM); return info; @@ -146,7 +146,7 @@ static void *osc_session_init(const struct lu_context *ctx, { struct osc_session *info; - OBD_SLAB_ALLOC_PTR_GFP(info, osc_session_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(info, osc_session_kmem, GFP_NOFS); if (info == NULL) info = ERR_PTR(-ENOMEM); return info; diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index 5f3c545418d1..6744dc620840 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/drivers/staging/lustre/lustre/osc/osc_io.c @@ -812,7 +812,7 @@ int osc_req_init(const struct lu_env *env, struct cl_device *dev, struct osc_req *or; int result; - OBD_SLAB_ALLOC_PTR_GFP(or, osc_req_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(or, osc_req_kmem, GFP_NOFS); if (or != NULL) { cl_req_slice_add(req, &or->or_cl, dev, &osc_req_ops); result = 0; diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index 1c6cafa3de70..a46129bec17a 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -1559,7 +1559,7 @@ int osc_lock_init(const struct lu_env *env, struct osc_lock *clk; int result; - OBD_SLAB_ALLOC_PTR_GFP(clk, osc_lock_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(clk, osc_lock_kmem, GFP_NOFS); if (clk != NULL) { __u32 enqflags = lock->cll_descr.cld_enq_flags; diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c index 9d34de873fac..f9bfdc820125 100644 --- a/drivers/staging/lustre/lustre/osc/osc_object.c +++ b/drivers/staging/lustre/lustre/osc/osc_object.c @@ -260,7 +260,7 @@ struct lu_object *osc_object_alloc(const struct lu_env *env, struct osc_object *osc; struct lu_object *obj; - OBD_SLAB_ALLOC_PTR_GFP(osc, osc_object_kmem, __GFP_IO); + OBD_SLAB_ALLOC_PTR_GFP(osc, osc_object_kmem, GFP_NOFS); if (osc != NULL) { obj = osc2lu(osc); lu_object_init(obj, NULL, dev); diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 5bee8206d70b..20987723bb56 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -455,7 +455,7 @@ void ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq) struct lustre_msg *msg; spin_unlock(&pool->prp_lock); - req = ptlrpc_request_cache_alloc(__GFP_IO); + req = ptlrpc_request_cache_alloc(GFP_NOFS); if (!req) return; OBD_ALLOC_LARGE(msg, size); @@ -696,7 +696,7 @@ struct ptlrpc_request *__ptlrpc_request_alloc(struct obd_import *imp, request = ptlrpc_prep_req_from_pool(pool); if (!request) - request = ptlrpc_request_cache_alloc(__GFP_IO); + request = ptlrpc_request_cache_alloc(GFP_NOFS); if (request) { LASSERTF((unsigned long)imp > 0x1000, "%p", imp); @@ -3051,7 +3051,7 @@ void *ptlrpcd_alloc_work(struct obd_import *imp, return ERR_PTR(-EINVAL); /* copy some code from deprecated fakereq. */ - req = ptlrpc_request_cache_alloc(__GFP_IO); + req = ptlrpc_request_cache_alloc(GFP_NOFS); if (req == NULL) { CERROR("ptlrpc: run out of memory!\n"); return ERR_PTR(-ENOMEM); diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c b/drivers/staging/lustre/lustre/ptlrpc/nrs.c index bcba1c8e8693..12151aa2a1e5 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs.c @@ -746,7 +746,7 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs, LASSERT(desc->pd_compat != NULL); OBD_CPT_ALLOC_GFP(policy, svcpt->scp_service->srv_cptable, - svcpt->scp_cpt, sizeof(*policy), __GFP_IO); + svcpt->scp_cpt, sizeof(*policy), GFP_NOFS); if (policy == NULL) return -ENOMEM; diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index 3772ab10026a..28ac824a73fb 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -904,7 +904,7 @@ int sptlrpc_import_check_ctx(struct obd_import *imp) return -EACCES; } - req = ptlrpc_request_cache_alloc(__GFP_IO); + req = ptlrpc_request_cache_alloc(GFP_NOFS); if (!req) return -ENOMEM; @@ -1088,7 +1088,7 @@ int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req, int early_bufsz, early_size; int rc; - early_req = ptlrpc_request_cache_alloc(__GFP_IO); + early_req = ptlrpc_request_cache_alloc(GFP_NOFS); if (early_req == NULL) return -ENOMEM; diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c index 965668132747..1d46b5e2b0bc 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c @@ -421,7 +421,7 @@ static int enc_pools_add_pages(int npages) goto out_pools; for (j = 0; j < PAGES_PER_POOL && alloced < npages; j++) { - pools[i][j] = alloc_page(__GFP_IO | + pools[i][j] = alloc_page(GFP_NOFS | __GFP_HIGHMEM); if (pools[i][j] == NULL) goto out_pools; diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 4dd2bcba43f7..5d0eb6cb587c 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -1305,7 +1305,7 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) } newdl = cfs_time_current_sec() + at_get(&svcpt->scp_at_estimate); - reqcopy = ptlrpc_request_cache_alloc(__GFP_IO); + reqcopy = ptlrpc_request_cache_alloc(GFP_NOFS); if (reqcopy == NULL) return -ENOMEM; OBD_ALLOC_LARGE(reqmsg, req->rq_reqlen); -- cgit v1.2.3 From e49634bbf2eb3d4cd31b562433af2104b25021c1 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Sun, 27 Apr 2014 13:06:38 -0400 Subject: staging/lustre: quiet console permission error messages Quiet some common console error messages for permission errors that can be hit in common cases. Signed-off-by: Andreas Dilger Reviewed-on: http://review.whamcloud.com/8988 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4522 Reviewed-by: Jinshan Xiong Reviewed-by: Faccini Bruno Reviewed-by: Bob Glossman Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/file.c | 7 ++++--- drivers/staging/lustre/lustre/mdc/mdc_locks.c | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index d01c864053f2..c991ea5673bc 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -2882,9 +2882,10 @@ static int ll_inode_revalidate_fini(struct inode *inode, int rc) if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode)) return 0; } else if (rc != 0) { - CERROR("%s: revalidate FID "DFID" error: rc = %d\n", - ll_get_fsname(inode->i_sb, NULL, 0), - PFID(ll_inode2fid(inode)), rc); + CDEBUG_LIMIT((rc == -EACCES || rc == -EIDRM) ? D_INFO : D_ERROR, + "%s: revalidate FID "DFID" error: rc = %d\n", + ll_get_fsname(inode->i_sb, NULL, 0), + PFID(ll_inode2fid(inode)), rc); } return rc; diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index 53022ec390f0..f86f69729042 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -893,7 +893,10 @@ resend: mdc_put_rpc_lock(obddev->u.cli.cl_rpc_lock, it); if (rc < 0) { - CERROR("ldlm_cli_enqueue: %d\n", rc); + CDEBUG_LIMIT((rc == -EACCES || rc == -EIDRM) ? D_INFO : D_ERROR, + "%s: ldlm_cli_enqueue failed: rc = %d\n", + obddev->obd_name, rc); + mdc_clear_replay_flag(req, rc); ptlrpc_req_finished(req); return rc; -- cgit v1.2.3 From a5d490c2de02a2d34cd9fd34f7cd12f992a1e6e1 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Sun, 27 Apr 2014 13:06:39 -0400 Subject: staging/lustre/lov: remove unused lov llog code Remove the unused functions lov_llog_init(), lov_llog_finish(), their supporting functions, and the file lov_log.c. Signed-off-by: John L. Hammond Reviewed-on: http://review.whamcloud.com/8539 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2675 Reviewed-by: Andreas Dilger Reviewed-by: Mike Pershin Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lov/Makefile | 2 +- drivers/staging/lustre/lustre/lov/lov_internal.h | 4 - drivers/staging/lustre/lustre/lov/lov_log.c | 272 ----------------------- drivers/staging/lustre/lustre/lov/lov_obd.c | 9 +- 4 files changed, 3 insertions(+), 284 deletions(-) delete mode 100644 drivers/staging/lustre/lustre/lov/lov_log.c diff --git a/drivers/staging/lustre/lustre/lov/Makefile b/drivers/staging/lustre/lustre/lov/Makefile index 9a5f26d5558d..a908edb533d3 100644 --- a/drivers/staging/lustre/lustre/lov/Makefile +++ b/drivers/staging/lustre/lustre/lov/Makefile @@ -1,5 +1,5 @@ obj-$(CONFIG_LUSTRE_FS) += lov.o -lov-y := lov_log.o lov_obd.o lov_pack.o lov_offset.o lov_merge.o \ +lov-y := lov_obd.o lov_pack.o lov_offset.o lov_merge.o \ lov_request.o lov_ea.o lov_dev.o lov_object.o lov_page.o \ lov_lock.o lov_io.o lovsub_dev.o lovsub_object.o lovsub_page.o \ lovsub_lock.o lovsub_io.o lov_pool.o diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h index 2b22a03c038e..10e18c287447 100644 --- a/drivers/staging/lustre/lustre/lov/lov_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_internal.h @@ -251,10 +251,6 @@ int lov_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg, __u32 *indexp, int *genp); int lov_del_target(struct obd_device *obd, __u32 index, struct obd_uuid *uuidp, int gen); -/* lov_log.c */ -int lov_llog_init(struct obd_device *obd, struct obd_llog_group *olg, - struct obd_device *tgt, int *idx); -int lov_llog_finish(struct obd_device *obd, int count); /* lov_pack.c */ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmm, diff --git a/drivers/staging/lustre/lustre/lov/lov_log.c b/drivers/staging/lustre/lustre/lov/lov_log.c deleted file mode 100644 index 3eedd935d1bc..000000000000 --- a/drivers/staging/lustre/lustre/lov/lov_log.c +++ /dev/null @@ -1,272 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * 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 version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2012, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/lov/lov_log.c - * - * Author: Phil Schwan - * Author: Peter Braam - * Author: Mike Shaver - */ - -#define DEBUG_SUBSYSTEM S_LOV -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "lov_internal.h" - -/* Add log records for each OSC that this object is striped over, and return - * cookies for each one. We _would_ have nice abstraction here, except that - * we need to keep cookies in stripe order, even if some are NULL, so that - * the right cookies are passed back to the right OSTs at the client side. - * Unset cookies should be all-zero (which will never occur naturally). */ -static int lov_llog_origin_add(const struct lu_env *env, - struct llog_ctxt *ctxt, - struct llog_rec_hdr *rec, - struct lov_stripe_md *lsm, - struct llog_cookie *logcookies, int numcookies) -{ - struct obd_device *obd = ctxt->loc_obd; - struct lov_obd *lov = &obd->u.lov; - int i, rc = 0, cookies = 0; - - LASSERTF(logcookies && numcookies >= lsm->lsm_stripe_count, - "logcookies %p, numcookies %d lsm->lsm_stripe_count %d \n", - logcookies, numcookies, lsm->lsm_stripe_count); - - for (i = 0; i < lsm->lsm_stripe_count; i++) { - struct lov_oinfo *loi = lsm->lsm_oinfo[i]; - struct obd_device *child = - lov->lov_tgts[loi->loi_ost_idx]->ltd_exp->exp_obd; - struct llog_ctxt *cctxt = llog_get_context(child, ctxt->loc_idx); - - /* fill mds unlink/setattr log record */ - switch (rec->lrh_type) { - case MDS_UNLINK_REC: { - struct llog_unlink_rec *lur = (struct llog_unlink_rec *)rec; - lur->lur_oid = ostid_id(&loi->loi_oi); - lur->lur_oseq = (__u32)ostid_seq(&loi->loi_oi); - break; - } - case MDS_SETATTR64_REC: { - struct llog_setattr64_rec *lsr = (struct llog_setattr64_rec *)rec; - lsr->lsr_oi = loi->loi_oi; - break; - } - default: - break; - } - - /* inject error in llog_obd_add() below */ - if (OBD_FAIL_CHECK(OBD_FAIL_MDS_FAIL_LOV_LOG_ADD)) { - llog_ctxt_put(cctxt); - cctxt = NULL; - } - rc = llog_obd_add(env, cctxt, rec, NULL, logcookies + cookies, - numcookies - cookies); - llog_ctxt_put(cctxt); - if (rc < 0) { - CERROR("Can't add llog (rc = %d) for stripe %d\n", - rc, cookies); - memset(logcookies + cookies, 0, - sizeof(struct llog_cookie)); - rc = 1; /* skip this cookie */ - } - /* Note that rc is always 1 if llog_obd_add was successful */ - cookies += rc; - } - return cookies; -} - -static int lov_llog_origin_connect(struct llog_ctxt *ctxt, - struct llog_logid *logid, - struct llog_gen *gen, - struct obd_uuid *uuid) -{ - struct obd_device *obd = ctxt->loc_obd; - struct lov_obd *lov = &obd->u.lov; - int i, rc = 0, err = 0; - - obd_getref(obd); - for (i = 0; i < lov->desc.ld_tgt_count; i++) { - struct obd_device *child; - struct llog_ctxt *cctxt; - - if (!lov->lov_tgts[i] || !lov->lov_tgts[i]->ltd_active) - continue; - if (uuid && !obd_uuid_equals(uuid, &lov->lov_tgts[i]->ltd_uuid)) - continue; - CDEBUG(D_CONFIG, "connect %d/%d\n", i, lov->desc.ld_tgt_count); - child = lov->lov_tgts[i]->ltd_exp->exp_obd; - cctxt = llog_get_context(child, ctxt->loc_idx); - rc = llog_connect(cctxt, logid, gen, uuid); - llog_ctxt_put(cctxt); - - if (rc) { - CERROR("error osc_llog_connect tgt %d (%d)\n", i, rc); - if (!err) - err = rc; - } - } - obd_putref(obd); - - return err; -} - -/* the replicators commit callback */ -static int lov_llog_repl_cancel(const struct lu_env *env, - struct llog_ctxt *ctxt, - struct lov_stripe_md *lsm, - int count, struct llog_cookie *cookies, - int flags) -{ - struct lov_obd *lov; - struct obd_device *obd = ctxt->loc_obd; - int rc = 0, i; - - LASSERT(lsm != NULL); - LASSERT(count == lsm->lsm_stripe_count); - - lov = &obd->u.lov; - obd_getref(obd); - for (i = 0; i < count; i++, cookies++) { - struct lov_oinfo *loi = lsm->lsm_oinfo[i]; - struct obd_device *child = - lov->lov_tgts[loi->loi_ost_idx]->ltd_exp->exp_obd; - struct llog_ctxt *cctxt = - llog_get_context(child, ctxt->loc_idx); - int err; - - err = llog_cancel(env, cctxt, NULL, 1, cookies, flags); - llog_ctxt_put(cctxt); - if (err && lov->lov_tgts[loi->loi_ost_idx]->ltd_active) { - CERROR("%s: objid "DOSTID" subobj "DOSTID - " on OST idx %d: rc = %d\n", - obd->obd_name, POSTID(&lsm->lsm_oi), - POSTID(&loi->loi_oi), loi->loi_ost_idx, err); - if (!rc) - rc = err; - } - } - obd_putref(obd); - return rc; -} - -static struct llog_operations lov_mds_ost_orig_logops = { - .lop_obd_add = lov_llog_origin_add, - .lop_connect = lov_llog_origin_connect, -}; - -static struct llog_operations lov_size_repl_logops = { - .lop_cancel = lov_llog_repl_cancel, -}; - -int lov_llog_init(struct obd_device *obd, struct obd_llog_group *olg, - struct obd_device *disk_obd, int *index) -{ - struct lov_obd *lov = &obd->u.lov; - struct obd_device *child; - int i, rc = 0; - - LASSERT(olg == &obd->obd_olg); - rc = llog_setup(NULL, obd, olg, LLOG_MDS_OST_ORIG_CTXT, disk_obd, - &lov_mds_ost_orig_logops); - if (rc) - return rc; - - rc = llog_setup(NULL, obd, olg, LLOG_SIZE_REPL_CTXT, disk_obd, - &lov_size_repl_logops); - if (rc) - GOTO(err_cleanup, rc); - - obd_getref(obd); - /* count may not match lov->desc.ld_tgt_count during dynamic ost add */ - for (i = 0; i < lov->desc.ld_tgt_count; i++) { - if (!lov->lov_tgts[i]) - continue; - - if (index && i != *index) - continue; - - child = lov->lov_tgts[i]->ltd_obd; - rc = obd_llog_init(child, &child->obd_olg, disk_obd, &i); - if (rc) - CERROR("error osc_llog_init idx %d osc '%s' tgt '%s' " - "(rc=%d)\n", i, child->obd_name, - disk_obd->obd_name, rc); - rc = 0; - } - obd_putref(obd); - GOTO(err_cleanup, rc); -err_cleanup: - if (rc) { - struct llog_ctxt *ctxt = - llog_get_context(obd, LLOG_SIZE_REPL_CTXT); - if (ctxt) - llog_cleanup(NULL, ctxt); - ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT); - if (ctxt) - llog_cleanup(NULL, ctxt); - } - return rc; -} - -int lov_llog_finish(struct obd_device *obd, int count) -{ - struct llog_ctxt *ctxt; - - /* cleanup our llogs only if the ctxts have been setup - * (client lov doesn't setup, mds lov does). */ - ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT); - if (ctxt) - llog_cleanup(NULL, ctxt); - - ctxt = llog_get_context(obd, LLOG_SIZE_REPL_CTXT); - if (ctxt) - llog_cleanup(NULL, ctxt); - - /* lov->tgt llogs are cleaned during osc_cleanup. */ - return 0; -} diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 02509d0cb106..f66ba576ed4d 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -59,7 +59,6 @@ #include #include /* for cl_client_lru */ #include -#include #include #include "lov_internal.h" @@ -861,12 +860,10 @@ static int lov_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) } break; } - case OBD_CLEANUP_EXPORTS: - rc = obd_llog_finish(obd, 0); - if (rc != 0) - CERROR("failed to cleanup llogging subsystems\n"); + default: break; } + return rc; } @@ -2808,8 +2805,6 @@ struct obd_ops lov_obd_ops = { .o_get_info = lov_get_info, .o_set_info_async = lov_set_info_async, .o_extent_calc = lov_extent_calc, - .o_llog_init = lov_llog_init, - .o_llog_finish = lov_llog_finish, .o_notify = lov_notify, .o_pool_new = lov_pool_new, .o_pool_rem = lov_pool_remove, -- cgit v1.2.3 From 081b726563585f3d55dedb2649b17f0c15a36f82 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Sun, 27 Apr 2014 13:06:40 -0400 Subject: staging/lustre/obdclass: remove uses of lov_stripe_md Remove the unused function llog_obd_add(). Remove the unused count and parameters from llog_cancel(). Move dump_lsm() from obdclass to the only module that uses it (lov). Remove obd_lov.h. Signed-off-by: John L. Hammond Reviewed-on: http://review.whamcloud.com/8545 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2675 Reviewed-by: Bobi Jam Reviewed-by: Mike Pershin Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lustre/lustre_idl.h | 26 +++++ .../staging/lustre/lustre/include/lustre_debug.h | 1 - drivers/staging/lustre/lustre/include/lustre_log.h | 10 -- drivers/staging/lustre/lustre/include/obd.h | 7 ++ drivers/staging/lustre/lustre/include/obd_class.h | 9 -- drivers/staging/lustre/lustre/include/obd_lov.h | 116 --------------------- drivers/staging/lustre/lustre/lov/lov_ea.c | 12 ++- drivers/staging/lustre/lustre/lov/lov_internal.h | 33 +++++- drivers/staging/lustre/lustre/lov/lov_merge.c | 2 - drivers/staging/lustre/lustre/lov/lov_obd.c | 9 +- drivers/staging/lustre/lustre/lov/lov_object.c | 1 - drivers/staging/lustre/lustre/lov/lov_offset.c | 1 - drivers/staging/lustre/lustre/lov/lov_pack.c | 10 +- drivers/staging/lustre/lustre/lov/lov_request.c | 1 - drivers/staging/lustre/lustre/obdclass/debug.c | 12 --- drivers/staging/lustre/lustre/obdclass/llog_obd.c | 29 +----- .../staging/lustre/lustre/obdecho/echo_client.c | 1 - drivers/staging/lustre/lustre/osc/osc_request.c | 1 - drivers/staging/lustre/lustre/ptlrpc/recover.c | 1 - 19 files changed, 85 insertions(+), 197 deletions(-) delete mode 100644 drivers/staging/lustre/lustre/include/obd_lov.h diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index 87905bbc68e1..abd29bfa3713 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -1682,6 +1682,30 @@ static inline __u32 lov_mds_md_size(__u16 stripes, __u32 lmm_magic) stripes * sizeof(struct lov_ost_data_v1); } +static inline __u32 +lov_mds_md_max_stripe_count(size_t buf_size, __u32 lmm_magic) +{ + switch (lmm_magic) { + case LOV_MAGIC_V1: { + struct lov_mds_md_v1 lmm; + + if (buf_size < sizeof(lmm)) + return 0; + + return (buf_size - sizeof(lmm)) / sizeof(lmm.lmm_objects[0]); + } + case LOV_MAGIC_V3: { + struct lov_mds_md_v3 lmm; + + if (buf_size < sizeof(lmm)) + return 0; + + return (buf_size - sizeof(lmm)) / sizeof(lmm.lmm_objects[0]); + } + default: + return 0; + } +} #define OBD_MD_FLID (0x00000001ULL) /* object ID */ #define OBD_MD_FLATIME (0x00000002ULL) /* access time */ @@ -2681,6 +2705,8 @@ enum seq_op { * protocol, this will limit the max number of OSTs per LOV */ #define LOV_DESC_MAGIC 0xB0CCDE5C +#define LOV_DESC_QOS_MAXAGE_DEFAULT 5 /* Seconds */ +#define LOV_DESC_STRIPE_SIZE_DEFAULT (1 << LNET_MTU_BITS) /* LOV settings descriptor (should only contain static info) */ struct lov_desc { diff --git a/drivers/staging/lustre/lustre/include/lustre_debug.h b/drivers/staging/lustre/lustre/include/lustre_debug.h index 7ec91edd6800..6146ccb8cce0 100644 --- a/drivers/staging/lustre/lustre/include/lustre_debug.h +++ b/drivers/staging/lustre/lustre/include/lustre_debug.h @@ -48,7 +48,6 @@ /* lib/debug.c */ void dump_lniobuf(struct niobuf_local *lnb); int dump_req(struct ptlrpc_request *req); -void dump_lsm(int level, struct lov_stripe_md *lsm); int block_debug_setup(void *addr, int len, __u64 off, __u64 id); int block_debug_check(char *who, void *addr, int len, __u64 off, __u64 id); diff --git a/drivers/staging/lustre/lustre/include/lustre_log.h b/drivers/staging/lustre/lustre/include/lustre_log.h index 896c7576aa0f..1a9a9228b795 100644 --- a/drivers/staging/lustre/lustre/include/lustre_log.h +++ b/drivers/staging/lustre/lustre/include/lustre_log.h @@ -206,11 +206,7 @@ int llog_setup(const struct lu_env *env, struct obd_device *obd, int __llog_ctxt_put(const struct lu_env *env, struct llog_ctxt *ctxt); int llog_cleanup(const struct lu_env *env, struct llog_ctxt *); int llog_sync(struct llog_ctxt *ctxt, struct obd_export *exp, int flags); -int llog_obd_add(const struct lu_env *env, struct llog_ctxt *ctxt, - struct llog_rec_hdr *rec, struct lov_stripe_md *lsm, - struct llog_cookie *logcookies, int numcookies); int llog_cancel(const struct lu_env *env, struct llog_ctxt *ctxt, - struct lov_stripe_md *lsm, int count, struct llog_cookie *cookies, int flags); int obd_llog_init(struct obd_device *obd, struct obd_llog_group *olg, @@ -242,7 +238,6 @@ struct llog_operations { int flags); int (*lop_cleanup)(const struct lu_env *env, struct llog_ctxt *ctxt); int (*lop_cancel)(const struct lu_env *env, struct llog_ctxt *ctxt, - struct lov_stripe_md *lsm, int count, struct llog_cookie *cookies, int flags); int (*lop_connect)(struct llog_ctxt *ctxt, struct llog_logid *logid, struct llog_gen *gen, struct obd_uuid *uuid); @@ -296,11 +291,6 @@ struct llog_operations { int (*lop_add)(const struct lu_env *env, struct llog_handle *lgh, struct llog_rec_hdr *rec, struct llog_cookie *cookie, void *buf, struct thandle *th); - /* Old llog_add version, used in MDS-LOV-OSC now and will gone with - * LOD/OSP replacement */ - int (*lop_obd_add)(const struct lu_env *env, struct llog_ctxt *ctxt, - struct llog_rec_hdr *rec, struct lov_stripe_md *lsm, - struct llog_cookie *logcookies, int numcookies); }; /* In-memory descriptor for a log object or log catalog */ diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 72cf3fe4b0c9..75fdf195389a 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -132,6 +132,13 @@ static inline bool lsm_has_objects(struct lov_stripe_md *lsm) return true; } +static inline int lov_stripe_md_size(unsigned int stripe_count) +{ + struct lov_stripe_md lsm; + + return sizeof(lsm) + stripe_count * sizeof(lsm.lsm_oinfo[0]); +} + struct obd_info; typedef int (*obd_enqueue_update_f)(void *cookie, int rc); diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 6c8e1ab9e6b4..956abe7035e4 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -711,15 +711,6 @@ static inline int obd_size_diskmd(struct obd_export *exp, return obd_packmd(exp, NULL, mem_src); } -/* helper functions */ -static inline int obd_alloc_diskmd(struct obd_export *exp, - struct lov_mds_md **disk_tgt) -{ - LASSERT(disk_tgt); - LASSERT(*disk_tgt == NULL); - return obd_packmd(exp, disk_tgt, NULL); -} - static inline int obd_free_diskmd(struct obd_export *exp, struct lov_mds_md **disk_tgt) { diff --git a/drivers/staging/lustre/lustre/include/obd_lov.h b/drivers/staging/lustre/lustre/include/obd_lov.h deleted file mode 100644 index 235718b366dc..000000000000 --- a/drivers/staging/lustre/lustre/include/obd_lov.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * 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 version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2011, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#ifndef _OBD_LOV_H__ -#define _OBD_LOV_H__ - -#define LOV_DEFAULT_STRIPE_SIZE (1 << LNET_MTU_BITS) - -static inline int lov_stripe_md_size(__u16 stripes) -{ - return sizeof(struct lov_stripe_md) + stripes*sizeof(struct lov_oinfo*); -} - -struct lov_version_size { - __u32 lvs_magic; - size_t lvs_lmm_size; - size_t lvs_lod_size; -}; - -static inline __u32 lov_mds_md_stripecnt(int ea_size, __u32 lmm_magic) -{ - static const struct lov_version_size lmm_ver_size[] = { - { .lvs_magic = LOV_MAGIC_V3, - .lvs_lmm_size = sizeof(struct lov_mds_md_v3), - .lvs_lod_size = sizeof(struct lov_ost_data_v1) }, - { .lvs_magic = LOV_MAGIC_V1, - .lvs_lmm_size = sizeof(struct lov_mds_md_v1), - .lvs_lod_size = sizeof(struct lov_ost_data_v1)} }; - int i; - - for (i = 0; i < ARRAY_SIZE(lmm_ver_size); i++) { - if (lmm_magic == lmm_ver_size[i].lvs_magic) { - if (ea_size <= lmm_ver_size[i].lvs_lmm_size) - return 0; - return (ea_size - lmm_ver_size[i].lvs_lmm_size) / - lmm_ver_size[i].lvs_lod_size; - } - } - - /* Invalid LOV magic, so no stripes could fit */ - return 0; -} - -/* lov_do_div64(a, b) returns a % b, and a = a / b. - * The 32-bit code is LOV-specific due to knowing about stripe limits in - * order to reduce the divisor to a 32-bit number. If the divisor is - * already a 32-bit value the compiler handles this directly. */ -#if BITS_PER_LONG > 32 -# define lov_do_div64(n,base) ({ \ - uint64_t __base = (base); \ - uint64_t __rem; \ - __rem = ((uint64_t)(n)) % __base; \ - (n) = ((uint64_t)(n)) / __base; \ - __rem; \ - }) -#else -# define lov_do_div64(n,base) ({ \ - uint64_t __rem; \ - if ((sizeof(base) > 4) && (((base) & 0xffffffff00000000ULL) != 0)) { \ - int __remainder; \ - LASSERTF(!((base) & (LOV_MIN_STRIPE_SIZE - 1)), "64 bit lov " \ - "division %llu / %llu\n", (n), (uint64_t)(base)); \ - __remainder = (n) & (LOV_MIN_STRIPE_SIZE - 1); \ - (n) >>= LOV_MIN_STRIPE_BITS; \ - __rem = do_div(n, (base) >> LOV_MIN_STRIPE_BITS); \ - __rem <<= LOV_MIN_STRIPE_BITS; \ - __rem += __remainder; \ - } else { \ - __rem = do_div(n, base); \ - } \ - __rem; \ - }) -#endif - -#define IOC_LOV_TYPE 'g' -#define IOC_LOV_MIN_NR 50 -#define IOC_LOV_SET_OSC_ACTIVE _IOWR('g', 50, long) -#define IOC_LOV_MAX_NR 50 - -#define QOS_DEFAULT_THRESHOLD 10 /* MB */ -#define QOS_DEFAULT_MAXAGE 5 /* Seconds */ - -#endif diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c b/drivers/staging/lustre/lustre/lov/lov_ea.c index b91cb2ab8e21..a0c148e31f69 100644 --- a/drivers/staging/lustre/lustre/lov/lov_ea.c +++ b/drivers/staging/lustre/lustre/lov/lov_ea.c @@ -44,7 +44,6 @@ #include #include -#include #include #include "lov_internal.h" @@ -346,3 +345,14 @@ const struct lsm_operations lsm_v3_ops = { .lsm_lmm_verify = lsm_lmm_verify_v3, .lsm_unpackmd = lsm_unpackmd_v3, }; + +void dump_lsm(unsigned int level, const struct lov_stripe_md *lsm) +{ + CDEBUG(level, "lsm %p, objid "DOSTID", maxbytes "LPX64", magic 0x%08X," + " stripe_size %u, stripe_count %u, refc: %d," + " layout_gen %u, pool ["LOV_POOLNAMEF"]\n", lsm, + POSTID(&lsm->lsm_oi), lsm->lsm_maxbytes, lsm->lsm_magic, + lsm->lsm_stripe_size, lsm->lsm_stripe_count, + atomic_read(&lsm->lsm_refc), lsm->lsm_layout_gen, + lsm->lsm_pool_name); +} diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h index 10e18c287447..38508a5c827f 100644 --- a/drivers/staging/lustre/lustre/lov/lov_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_internal.h @@ -38,9 +38,39 @@ #define LOV_INTERNAL_H #include -#include #include +/* lov_do_div64(a, b) returns a % b, and a = a / b. + * The 32-bit code is LOV-specific due to knowing about stripe limits in + * order to reduce the divisor to a 32-bit number. If the divisor is + * already a 32-bit value the compiler handles this directly. */ +#if BITS_PER_LONG == 64 +# define lov_do_div64(n, base) ({ \ + uint64_t __base = (base); \ + uint64_t __rem; \ + __rem = ((uint64_t)(n)) % __base; \ + (n) = ((uint64_t)(n)) / __base; \ + __rem; \ +}) +#elif BITS_PER_LONG == 32 +# define lov_do_div64(n, base) ({ \ + uint64_t __rem; \ + if ((sizeof(base) > 4) && (((base) & 0xffffffff00000000ULL) != 0)) { \ + int __remainder; \ + LASSERTF(!((base) & (LOV_MIN_STRIPE_SIZE - 1)), "64 bit lov " \ + "division %llu / %llu\n", (n), (uint64_t)(base)); \ + __remainder = (n) & (LOV_MIN_STRIPE_SIZE - 1); \ + (n) >>= LOV_MIN_STRIPE_BITS; \ + __rem = do_div(n, (base) >> LOV_MIN_STRIPE_BITS); \ + __rem <<= LOV_MIN_STRIPE_BITS; \ + __rem += __remainder; \ + } else { \ + __rem = do_div(n, base); \ + } \ + __rem; \ +}) +#endif + struct lov_lock_handles { struct portals_handle llh_handle; atomic_t llh_refcount; @@ -275,6 +305,7 @@ void lov_dump_lmm(int level, void *lmm); /* lov_ea.c */ struct lov_stripe_md *lsm_alloc_plain(__u16 stripe_count, int *size); void lsm_free_plain(struct lov_stripe_md *lsm); +void dump_lsm(unsigned int level, const struct lov_stripe_md *lsm); int lovea_destroy_object(struct lov_obd *lov, struct lov_stripe_md *lsm, struct obdo *oa, void *data); diff --git a/drivers/staging/lustre/lustre/lov/lov_merge.c b/drivers/staging/lustre/lustre/lov/lov_merge.c index 9defa55d9919..0a14cee67b88 100644 --- a/drivers/staging/lustre/lustre/lov/lov_merge.c +++ b/drivers/staging/lustre/lustre/lov/lov_merge.c @@ -39,8 +39,6 @@ #include #include -#include - #include "lov_internal.h" /** Merge the lock value block(&lvb) attributes and KMS from each of the diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index f66ba576ed4d..dbd971a1344f 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -50,9 +50,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -725,8 +723,8 @@ void lov_fix_desc_stripe_size(__u64 *val) if (*val != 0) LCONSOLE_INFO("Increasing default stripe size to " "minimum %u\n", - LOV_DEFAULT_STRIPE_SIZE); - *val = LOV_DEFAULT_STRIPE_SIZE; + LOV_DESC_STRIPE_SIZE_DEFAULT); + *val = LOV_DESC_STRIPE_SIZE_DEFAULT; } else if (*val & (LOV_MIN_STRIPE_SIZE - 1)) { *val &= ~(LOV_MIN_STRIPE_SIZE - 1); LCONSOLE_WARN("Changing default stripe size to "LPU64" (a " @@ -752,9 +750,8 @@ void lov_fix_desc_pattern(__u32 *val) void lov_fix_desc_qos_maxage(__u32 *val) { - /* fix qos_maxage */ if (*val == 0) - *val = QOS_DEFAULT_MAXAGE; + *val = LOV_DESC_QOS_MAXAGE_DEFAULT; } void lov_fix_desc(struct lov_desc *desc) diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c index f20e497c5404..992c80ab3d53 100644 --- a/drivers/staging/lustre/lustre/lov/lov_object.c +++ b/drivers/staging/lustre/lustre/lov/lov_object.c @@ -42,7 +42,6 @@ #define DEBUG_SUBSYSTEM S_LOV #include "lov_cl_internal.h" -#include /** \addtogroup lov * @{ diff --git a/drivers/staging/lustre/lustre/lov/lov_offset.c b/drivers/staging/lustre/lustre/lov/lov_offset.c index 04863a7c5e0b..379568f8245c 100644 --- a/drivers/staging/lustre/lustre/lov/lov_offset.c +++ b/drivers/staging/lustre/lustre/lov/lov_offset.c @@ -39,7 +39,6 @@ #include #include -#include #include "lov_internal.h" diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c index 74200cf1b331..59ab7c30ffbf 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pack.c +++ b/drivers/staging/lustre/lustre/lov/lov_pack.c @@ -44,7 +44,6 @@ #include #include -#include #include #include #include @@ -177,8 +176,9 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, * Anyway, this is pretty inaccurate since ld_tgt_count now * represents max index and we should rely on the actual number * of OSTs instead */ - stripe_count = lov_mds_md_stripecnt(lov->lov_ocd.ocd_max_easize, - lmm_magic); + stripe_count = lov_mds_md_max_stripe_count( + lov->lov_ocd.ocd_max_easize, lmm_magic); + if (stripe_count > lov->desc.ld_tgt_count) stripe_count = lov->desc.ld_tgt_count; } @@ -264,8 +264,8 @@ __u16 lov_get_stripecnt(struct lov_obd *lov, __u32 magic, __u16 stripe_count) * larger EA sizes */ if (lov->lov_ocd.ocd_connect_flags & OBD_CONNECT_MAX_EASIZE && lov->lov_ocd.ocd_max_easize) - max_stripes = lov_mds_md_stripecnt(lov->lov_ocd.ocd_max_easize, - magic); + max_stripes = lov_mds_md_max_stripe_count( + lov->lov_ocd.ocd_max_easize, magic); if (stripe_count > max_stripes) stripe_count = max_stripes; diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c index a5481d7eb5d6..bd6490d0129c 100644 --- a/drivers/staging/lustre/lustre/lov/lov_request.c +++ b/drivers/staging/lustre/lustre/lov/lov_request.c @@ -39,7 +39,6 @@ #include #include -#include #include #include "lov_internal.h" diff --git a/drivers/staging/lustre/lustre/obdclass/debug.c b/drivers/staging/lustre/lustre/obdclass/debug.c index 15f71bbb7276..a4e7e754177f 100644 --- a/drivers/staging/lustre/lustre/obdclass/debug.c +++ b/drivers/staging/lustre/lustre/obdclass/debug.c @@ -56,18 +56,6 @@ void dump_lniobuf(struct niobuf_local *nb) } EXPORT_SYMBOL(dump_lniobuf); -void dump_lsm(int level, struct lov_stripe_md *lsm) -{ - CDEBUG(level, "lsm %p, objid "DOSTID", maxbytes "LPX64", magic 0x%08X," - " stripe_size %u, stripe_count %u, refc: %d," - " layout_gen %u, pool ["LOV_POOLNAMEF"]\n", lsm, - POSTID(&lsm->lsm_oi), lsm->lsm_maxbytes, lsm->lsm_magic, - lsm->lsm_stripe_size, lsm->lsm_stripe_count, - atomic_read(&lsm->lsm_refc), lsm->lsm_layout_gen, - lsm->lsm_pool_name); -} -EXPORT_SYMBOL(dump_lsm); - #define LPDS sizeof(__u64) int block_debug_setup(void *addr, int len, __u64 off, __u64 id) { diff --git a/drivers/staging/lustre/lustre/obdclass/llog_obd.c b/drivers/staging/lustre/lustre/obdclass/llog_obd.c index 71817af75396..2c6d81eb5c65 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_obd.c @@ -226,34 +226,7 @@ int llog_sync(struct llog_ctxt *ctxt, struct obd_export *exp, int flags) } EXPORT_SYMBOL(llog_sync); -int llog_obd_add(const struct lu_env *env, struct llog_ctxt *ctxt, - struct llog_rec_hdr *rec, struct lov_stripe_md *lsm, - struct llog_cookie *logcookies, int numcookies) -{ - int raised, rc; - - if (!ctxt) { - CERROR("No ctxt\n"); - return -ENODEV; - } - - if (ctxt->loc_flags & LLOG_CTXT_FLAG_UNINITIALIZED) - return -ENXIO; - - CTXT_CHECK_OP(ctxt, obd_add, -EOPNOTSUPP); - raised = cfs_cap_raised(CFS_CAP_SYS_RESOURCE); - if (!raised) - cfs_cap_raise(CFS_CAP_SYS_RESOURCE); - rc = CTXTP(ctxt, obd_add)(env, ctxt, rec, lsm, logcookies, - numcookies); - if (!raised) - cfs_cap_lower(CFS_CAP_SYS_RESOURCE); - return rc; -} -EXPORT_SYMBOL(llog_obd_add); - int llog_cancel(const struct lu_env *env, struct llog_ctxt *ctxt, - struct lov_stripe_md *lsm, int count, struct llog_cookie *cookies, int flags) { int rc; @@ -264,7 +237,7 @@ int llog_cancel(const struct lu_env *env, struct llog_ctxt *ctxt, } CTXT_CHECK_OP(ctxt, cancel, -EOPNOTSUPP); - rc = CTXTP(ctxt, cancel)(env, ctxt, lsm, count, cookies, flags); + rc = CTXTP(ctxt, cancel)(env, ctxt, cookies, flags); return rc; } EXPORT_SYMBOL(llog_cancel); diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index 0eb39f25d9c2..cdc46719bbd4 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -47,7 +47,6 @@ #include #include #include -#include #include "echo_internal.h" diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index ee6953ac7353..294db843012b 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -44,7 +44,6 @@ #include #include #include -#include #include #include diff --git a/drivers/staging/lustre/lustre/ptlrpc/recover.c b/drivers/staging/lustre/lustre/ptlrpc/recover.c index 4cff2f7ba412..9cec8a649dc3 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/recover.c +++ b/drivers/staging/lustre/lustre/ptlrpc/recover.c @@ -49,7 +49,6 @@ #include #include #include -#include /* for IOC_LOV_SET_OSC_ACTIVE */ #include #include "ptlrpc_internal.h" -- cgit v1.2.3 From 5d0d422e72ad22fd9d8fd2828166d7f8fa642adb Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Sun, 27 Apr 2014 13:06:41 -0400 Subject: staging/lustre/hsm: count NULL terminator in hai_zero/hal_size If fsname is 8-byte aligned, hai_zero fails to count the ending NULL terminator causing hai to directly attached after fsname and future hai_zero will return a different position for first hai. Signed-off-by: Peng Tao Reviewed-on: http://review.whamcloud.com/9431 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4689 Reviewed-by: Andreas Dilger Reviewed-by: Jinshan Xiong Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/lustre/lustre_user.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h index f5f369e603de..95c754f2075f 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h @@ -1106,7 +1106,8 @@ static inline struct hsm_action_item * hai_zero(struct hsm_action_list *hal) { return (struct hsm_action_item *)(hal->hal_fsname + cfs_size_round(strlen(hal-> \ - hal_fsname))); + hal_fsname) + + 1)); } /* Return pointer to next hai */ static inline struct hsm_action_item * hai_next(struct hsm_action_item *hai) @@ -1121,7 +1122,7 @@ static inline int hal_size(struct hsm_action_list *hal) int i, sz; struct hsm_action_item *hai; - sz = sizeof(*hal) + cfs_size_round(strlen(hal->hal_fsname)); + sz = sizeof(*hal) + cfs_size_round(strlen(hal->hal_fsname) + 1); hai = hai_zero(hal); for (i = 0; i < hal->hal_count; i++, hai = hai_next(hai)) sz += cfs_size_round(hai->hai_len); -- cgit v1.2.3 From e55c447647c26cb666fce054894f9faeb69d21b2 Mon Sep 17 00:00:00 2001 From: James Nunez Date: Sun, 27 Apr 2014 13:06:42 -0400 Subject: staging/lustre/hsm: HSM requests not delivered The total size of an HSM archive request may exceed the desired (LNET) message. When this happens, it can hang the client and not allow the archive request to succeed. Before we know the total size of the hsm_action_items, we need to limit the size of the reguest. Doing this limits the number of items that can be sent in one archive request. We'e reduced the size allowed for the user archive request to MDS_MAXREQSIZE/3. Signed-off-by: James Nunez Reviewed-on: http://review.whamcloud.com/9393 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4639 Reviewed-by: John L. Hammond Reviewed-by: Jinshan Xiong Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/lustre_net.h | 2 ++ drivers/staging/lustre/lustre/llite/dir.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index 745adbb74cfc..7640e179e39d 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -264,6 +264,8 @@ #define LDLM_MAXREQSIZE (5 * 1024) #define LDLM_MAXREPSIZE (1024) +#define MDS_MAXREQSIZE (5 * 1024) /* >= 4736 */ + #define OST_MAXREQSIZE (5 * 1024) /* Macro to hide a typecast. */ diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 7fbc18e3e654..c391b60394e4 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -1804,6 +1804,11 @@ out_rmdir: /* Compute the whole struct size */ totalsize = hur_len(hur); OBD_FREE_PTR(hur); + + /* Final size will be more than double totalsize */ + if (totalsize >= MDS_MAXREQSIZE / 3) + return -E2BIG; + OBD_ALLOC_LARGE(hur, totalsize); if (hur == NULL) return -ENOMEM; -- cgit v1.2.3 From 0667dfffc7692f60b9953668579918006af6908f Mon Sep 17 00:00:00 2001 From: Li Xi Date: Sun, 27 Apr 2014 13:06:43 -0400 Subject: staging/lustre: fix permission problem of setfacl Setxattr does not check the permission when setting ACL xattrs. This will cause security problem because any user can walk around permission checking by changing ACL rules. Signed-off-by: Li Xi Reviewed-on: http://review.whamcloud.com/9473 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4704 Reviewed-by: Andreas Dilger Reviewed-by: Bob Glossman Reviewed-by: John L. Hammond Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/xattr.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index b1ed4d9ea6be..67a1de41c5b2 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -124,6 +124,11 @@ int ll_setxattr_common(struct inode *inode, const char *name, if (rc) return rc; + if ((xattr_type == XATTR_ACL_ACCESS_T || + xattr_type == XATTR_ACL_DEFAULT_T) && + !inode_owner_or_capable(inode)) + return -EPERM; + /* b10667: ignore lustre special xattr for now */ if ((xattr_type == XATTR_TRUSTED_T && strcmp(name, "trusted.lov") == 0) || (xattr_type == XATTR_LUSTRE_T && strcmp(name, "lustre.lov") == 0)) -- cgit v1.2.3 From 8d97deb97dde884eb08d0c3b69ccfcc5a43b1350 Mon Sep 17 00:00:00 2001 From: Bobi Jam Date: Sun, 27 Apr 2014 13:06:44 -0400 Subject: staging/lustre/llite: issue OST_SYNC for fsync() The last parameter @datasync of fsync() has following indication: * if datasync=0, we'd always flush data and metadata * if datasync=1, we'd always flush data while does not flush modifed metadata unless that metadata is needed in order to allow a subsequent data retrieval to be correctly handled. For example, a change to the file size would require a metadata flush. Lustre client can not tell the difference easily, and would issue MDS_SYNC and OST_SYNC in all cases. Signed-off-by: Bobi Jam Reviewed-on: http://review.whamcloud.com/8684 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4388 Reviewed-by: Andreas Dilger Reviewed-by: Jinshan Xiong Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index c991ea5673bc..872c878e3b8f 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -2653,7 +2653,7 @@ int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync) if (!err) ptlrpc_req_finished(req); - if (datasync && S_ISREG(inode->i_mode)) { + if (S_ISREG(inode->i_mode)) { struct ll_file_data *fd = LUSTRE_FPRIVATE(file); err = cl_sync_file_range(inode, 0, OBD_OBJECT_EOF, -- cgit v1.2.3 From 178ba1e0d00aca671f9a8f5f41d28fc0fe717752 Mon Sep 17 00:00:00 2001 From: Bobi Jam Date: Sun, 27 Apr 2014 13:06:45 -0400 Subject: staging/lustre/llite: deadlock taking lli_trunc_sem during file write File write before io loop will take lli_trun_sem read semaphore to protect osc_extent, while after generic_file_aio_write() done, it could possible need to kill suid or sgid, which will call ll_setattr_raw() to change the inode's attribute, and it does not involve size. So the ll_truc_sem write semaphore should be constrained around ll_setattr_ost() to not come across the lli_trunc_sem read semaphore get from the normal file write path. Signed-off-by: Bobi Jam Reviewed-on: http://review.whamcloud.com/9267 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4627 Reviewed-by: Lai Siyao Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/llite_lib.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 7c4fd97a7fa0..373a24f5d5d7 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -1449,7 +1449,6 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import) if (attr->ia_valid & ATTR_SIZE) inode_dio_write_done(inode); mutex_unlock(&inode->i_mutex); - down_write(&lli->lli_trunc_sem); } memcpy(&op_data->op_attr, attr, sizeof(*attr)); @@ -1513,7 +1512,11 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import) * excessive to send mtime/atime updates to OSTs when not * setting times to past, but it is necessary due to possible * time de-synchronization between MDT inode and OST objects */ + if (attr->ia_valid & ATTR_SIZE) + down_write(&lli->lli_trunc_sem); rc = ll_setattr_ost(inode, attr); + if (attr->ia_valid & ATTR_SIZE) + up_write(&lli->lli_trunc_sem); out: if (op_data) { if (op_data->op_ioepoch) { @@ -1524,7 +1527,6 @@ out: ll_finish_md_op_data(op_data); } if (!S_ISDIR(inode->i_mode)) { - up_write(&lli->lli_trunc_sem); mutex_lock(&inode->i_mutex); if ((attr->ia_valid & ATTR_SIZE) && !hsm_import) inode_dio_wait(inode); -- cgit v1.2.3 From e69cd00cb3b3ce49954947ee3f78ba887d7ac8d0 Mon Sep 17 00:00:00 2001 From: Jinshan Xiong Date: Sun, 27 Apr 2014 13:06:46 -0400 Subject: staging/lustre/lov: to not hold sub locks at initialization Otherwise, it will cause deadlock because it essentially holds some sub locks and then to request others in an arbitrary order. Signed-off-by: Jinshan Xiong Reviewed-on: http://review.whamcloud.com/9152 Reviewed-by: Lai Siyao Reviewed-by: Bobi Jam Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lov/lov_lock.c | 36 +--------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_lock.c b/drivers/staging/lustre/lustre/lov/lov_lock.c index 0bbe141bf4e4..08ac3745f0da 100644 --- a/drivers/staging/lustre/lustre/lov/lov_lock.c +++ b/drivers/staging/lustre/lustre/lov/lov_lock.c @@ -346,41 +346,7 @@ static int lov_lock_sub_init(const struct lu_env *env, } } LASSERT(nr == lck->lls_nr); - /* - * Then, create sub-locks. Once at least one sub-lock was created, - * top-lock can be reached by other threads. - */ - for (i = 0; i < lck->lls_nr; ++i) { - struct cl_lock *sublock; - struct lov_lock_link *link; - if (lck->lls_sub[i].sub_lock == NULL) { - sublock = lov_sublock_alloc(env, io, lck, i, &link); - if (IS_ERR(sublock)) { - result = PTR_ERR(sublock); - break; - } - cl_lock_get_trust(sublock); - cl_lock_mutex_get(env, sublock); - cl_lock_mutex_get(env, parent); - /* - * recheck under mutex that sub-lock wasn't created - * concurrently, and that top-lock is still alive. - */ - if (lck->lls_sub[i].sub_lock == NULL && - parent->cll_state < CLS_FREEING) { - lov_sublock_adopt(env, lck, sublock, i, link); - cl_lock_mutex_put(env, parent); - } else { - OBD_SLAB_FREE_PTR(link, lov_lock_link_kmem); - cl_lock_mutex_put(env, parent); - cl_lock_unhold(env, sublock, - "lov-parent", parent); - } - cl_lock_mutex_put(env, sublock); - cl_lock_put(env, sublock); - } - } /* * Some sub-locks can be missing at this point. This is not a problem, * because enqueue will create them anyway. Main duty of this function @@ -533,7 +499,7 @@ static int lov_lock_enqueue_one(const struct lu_env *env, struct lov_lock *lck, static int lov_sublock_fill(const struct lu_env *env, struct cl_lock *parent, struct cl_io *io, struct lov_lock *lck, int idx) { - struct lov_lock_link *link; + struct lov_lock_link *link = NULL; struct cl_lock *sublock; int result; -- cgit v1.2.3 From 44779340c6dcb8c858955c02b3aeef7d6b28a684 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Sun, 27 Apr 2014 13:06:47 -0400 Subject: staging/lustre: Limit reply buffer size When allocating a reply buffer for the striping information don't assume the unlikely worst case. Instead, assume the common case and size the buffer based on the observed default ea/cookie size. The default size is initialized to a single stripe and allowed to grow up to an entire page if needed. This means that for smallish filesystems (less than ~21 OSTs) where the worst case striping information can fit in a single page there is effectively no change. Only for larger filesystem will the default be less than the maximum. This has a number of advantages. * By limiting the default reply buffer size we avoid always vmalloc()'ing the buffer because it exceeds four pages in size and instead kmalloc() it. This prevents the client from thrashing on the global vmalloc() spin lock. * A reply buffer of exactly the right size (no larger) is allocated in the overflow case. These larger reply buffers are still unlikely to exceed the 16k limit where a vmalloc() will occur. * Saves memory in the common case. Wide striped files exceeded the default are expected to be the exception. The reason this patch works is because the ptlrpc layer is smart enough to reallocate the reply buffer when an overflow occurs. Therefore the client doesn't have to drop the incoming reply and send a new request with a larger reply buffer. It's also worth mentioning that the reply buffer always contains a significant amount of extra padding because they are rounded up to the nearest power of two. This means that even files striped wider than the default have a good chance of fitting in the allocated reply buffer. Also remove client eadatasize check in mdt xattr packing because as said above client can handle -EOVERFLOW. Signed-off-by: Brian Behlendorf Signed-off-by: Lai Siyao Reviewed-on: http://review.whamcloud.com/6339 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3338 Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Reviewed-by: Bob Glossman Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/lustre_mdc.h | 23 ++++++--- drivers/staging/lustre/lustre/include/obd.h | 15 ++++-- drivers/staging/lustre/lustre/include/obd_class.h | 5 +- .../staging/lustre/lustre/lclient/lcommon_misc.c | 15 ++++-- drivers/staging/lustre/lustre/llite/dir.c | 2 +- drivers/staging/lustre/lustre/llite/file.c | 8 ++-- .../staging/lustre/lustre/llite/llite_internal.h | 8 ++-- drivers/staging/lustre/lustre/llite/llite_lib.c | 39 ++++++++++++++++ drivers/staging/lustre/lustre/llite/llite_nfs.c | 4 +- drivers/staging/lustre/lustre/llite/lproc_llite.c | 54 ++++++++++++++++++++-- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 25 ++++++---- drivers/staging/lustre/lustre/mdc/mdc_locks.c | 10 ++-- drivers/staging/lustre/lustre/mdc/mdc_reint.c | 8 ++-- drivers/staging/lustre/lustre/mdc/mdc_request.c | 49 +++++++++++++++++--- 14 files changed, 206 insertions(+), 59 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_mdc.h b/drivers/staging/lustre/lustre/include/lustre_mdc.h index 468f36344a34..66765d4d201d 100644 --- a/drivers/staging/lustre/lustre/include/lustre_mdc.h +++ b/drivers/staging/lustre/lustre/include/lustre_mdc.h @@ -140,17 +140,26 @@ static inline void mdc_put_rpc_lock(struct mdc_rpc_lock *lck, mutex_unlock(&lck->rpcl_mutex); } +/* Update the maximum observed easize and cookiesize. The default easize + * and cookiesize is initialized to the minimum value but allowed to grow + * up to a single page in size if required to handle the common case. + */ static inline void mdc_update_max_ea_from_body(struct obd_export *exp, struct mdt_body *body) { if (body->valid & OBD_MD_FLMODEASIZE) { - if (exp->exp_obd->u.cli.cl_max_mds_easize < body->max_mdsize) - exp->exp_obd->u.cli.cl_max_mds_easize = - body->max_mdsize; - if (exp->exp_obd->u.cli.cl_max_mds_cookiesize < - body->max_cookiesize) - exp->exp_obd->u.cli.cl_max_mds_cookiesize = - body->max_cookiesize; + struct client_obd *cli = &exp->exp_obd->u.cli; + + if (cli->cl_max_mds_easize < body->max_mdsize) { + cli->cl_max_mds_easize = body->max_mdsize; + cli->cl_default_mds_easize = + min_t(__u32, body->max_mdsize, PAGE_CACHE_SIZE); + } + if (cli->cl_max_mds_cookiesize < body->max_cookiesize) { + cli->cl_max_mds_cookiesize = body->max_cookiesize; + cli->cl_default_mds_cookiesize = + min_t(__u32, body->max_cookiesize, PAGE_CACHE_SIZE); + } } } diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 75fdf195389a..7ed5fcd7f86d 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -316,9 +316,10 @@ struct client_obd { int cl_conn_count; /* max_mds_easize is purely a performance thing so we don't have to * call obd_size_diskmd() all the time. */ - int cl_default_mds_easize; - int cl_max_mds_easize; - int cl_max_mds_cookiesize; + int cl_default_mds_easize; + int cl_max_mds_easize; + int cl_default_mds_cookiesize; + int cl_max_mds_cookiesize; enum lustre_sec_part cl_sp_me; enum lustre_sec_part cl_sp_to; @@ -605,6 +606,7 @@ struct lmv_obd { int max_easize; int max_def_easize; int max_cookiesize; + int max_def_cookiesize; int server_timeout; int tgts_size; /* size of tgts array */ @@ -996,7 +998,10 @@ enum obd_cleanup_stage { #define KEY_LOCK_TO_STRIPE "lock_to_stripe" #define KEY_LOVDESC "lovdesc" #define KEY_LOV_IDX "lov_idx" -#define KEY_MAX_EASIZE "max_easize" +#define KEY_MAX_EASIZE "max_easize" +#define KEY_DEFAULT_EASIZE "default_easize" +#define KEY_MAX_COOKIESIZE "max_cookiesize" +#define KEY_DEFAULT_COOKIESIZE "default_cookiesize" #define KEY_MDS_CONN "mds_conn" #define KEY_MGSSEC "mgssec" #define KEY_NEXT_ID "next_id" @@ -1390,7 +1395,7 @@ struct md_ops { const char *, int, int, int, struct ptlrpc_request **); - int (*m_init_ea_size)(struct obd_export *, int, int, int); + int (*m_init_ea_size)(struct obd_export *, int, int, int, int); int (*m_get_lustre_md)(struct obd_export *, struct ptlrpc_request *, struct obd_export *, struct obd_export *, diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 956abe7035e4..61ba370794f8 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -2046,12 +2046,13 @@ static inline ldlm_mode_t md_lock_match(struct obd_export *exp, __u64 flags, } static inline int md_init_ea_size(struct obd_export *exp, int easize, - int def_asize, int cookiesize) + int def_asize, int cookiesize, + int def_cookiesize) { EXP_CHECK_MD_OP(exp, init_ea_size); EXP_MD_COUNTER_INCREMENT(exp, init_ea_size); return MDP(exp->exp_obd, init_ea_size)(exp, easize, def_asize, - cookiesize); + cookiesize, def_cookiesize); } static inline int md_get_remote_perm(struct obd_export *exp, diff --git a/drivers/staging/lustre/lustre/lclient/lcommon_misc.c b/drivers/staging/lustre/lustre/lclient/lcommon_misc.c index e04c2d37c249..21de1cd2afba 100644 --- a/drivers/staging/lustre/lustre/lclient/lcommon_misc.c +++ b/drivers/staging/lustre/lustre/lclient/lcommon_misc.c @@ -56,7 +56,7 @@ int cl_init_ea_size(struct obd_export *md_exp, struct obd_export *dt_exp) __u32 valsize = sizeof(struct lov_desc); int rc, easize, def_easize, cookiesize; struct lov_desc desc; - __u16 stripes; + __u16 stripes, def_stripes; rc = obd_get_info(NULL, dt_exp, sizeof(KEY_LOVDESC), KEY_LOVDESC, &valsize, &desc, NULL); @@ -67,15 +67,20 @@ int cl_init_ea_size(struct obd_export *md_exp, struct obd_export *dt_exp) lsm.lsm_stripe_count = stripes; easize = obd_size_diskmd(dt_exp, &lsm); - lsm.lsm_stripe_count = desc.ld_default_stripe_count; + def_stripes = min_t(__u32, desc.ld_default_stripe_count, + LOV_MAX_STRIPE_COUNT); + lsm.lsm_stripe_count = def_stripes; def_easize = obd_size_diskmd(dt_exp, &lsm); cookiesize = stripes * sizeof(struct llog_cookie); - CDEBUG(D_HA, "updating max_mdsize/max_cookiesize: %d/%d\n", - easize, cookiesize); + /* default cookiesize is 0 because from 2.4 server doesn't send + * llog cookies to client. */ + CDEBUG(D_HA, + "updating def/max_easize: %d/%d def/max_cookiesize: 0/%d\n", + def_easize, easize, cookiesize); - rc = md_init_ea_size(md_exp, easize, def_easize, cookiesize); + rc = md_init_ea_size(md_exp, easize, def_easize, cookiesize, 0); return rc; } diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index c391b60394e4..f7d306520123 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -795,7 +795,7 @@ int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmmp, int rc, lmmsize; struct md_op_data *op_data; - rc = ll_get_max_mdsize(sbi, &lmmsize); + rc = ll_get_default_mdsize(sbi, &lmmsize); if (rc) return rc; diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 872c878e3b8f..166321c0e992 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -1440,7 +1440,7 @@ int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename, struct md_op_data *op_data; int rc, lmmsize; - rc = ll_get_max_mdsize(sbi, &lmmsize); + rc = ll_get_default_mdsize(sbi, &lmmsize); if (rc) return rc; @@ -2957,7 +2957,7 @@ int __ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, int ealen = 0; if (S_ISREG(inode->i_mode)) { - rc = ll_get_max_mdsize(sbi, &ealen); + rc = ll_get_default_mdsize(sbi, &ealen); if (rc) return rc; valid |= OBD_MD_FLEASIZE | OBD_MD_FLMODEASIZE; @@ -3359,7 +3359,7 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock) * layout here. Please note that we can't use the LVB buffer in * completion AST because it doesn't have a large enough buffer */ oc = ll_mdscapa_get(inode); - rc = ll_get_max_mdsize(sbi, &lmmsize); + rc = ll_get_default_mdsize(sbi, &lmmsize); if (rc == 0) rc = md_getxattr(sbi->ll_md_exp, ll_inode2fid(inode), oc, OBD_MD_FLXATTR, XATTR_NAME_LOV, NULL, 0, @@ -3369,7 +3369,7 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock) return rc; body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); - if (body == NULL || body->eadatasize > lmmsize) + if (body == NULL) GOTO(out, rc = -EPROTO); lmmsize = body->eadatasize; diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 69aba0afca41..4663e824c282 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -865,6 +865,9 @@ void lustre_dump_dentry(struct dentry *, int recur); void lustre_dump_inode(struct inode *); int ll_obd_statfs(struct inode *inode, void *arg); int ll_get_max_mdsize(struct ll_sb_info *sbi, int *max_mdsize); +int ll_get_default_mdsize(struct ll_sb_info *sbi, int *default_mdsize); +int ll_get_max_cookiesize(struct ll_sb_info *sbi, int *max_cookiesize); +int ll_get_default_cookiesize(struct ll_sb_info *sbi, int *default_cookiesize); int ll_process_config(struct lustre_cfg *lcfg); struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data, struct inode *i1, struct inode *i2, @@ -1127,11 +1130,6 @@ static inline struct lu_fid *ll_inode2fid(struct inode *inode) return fid; } -static inline int ll_mds_max_easize(struct super_block *sb) -{ - return sbi2mdc(ll_s2sbi(sb))->cl_max_mds_easize; -} - static inline __u64 ll_file_maxbytes(struct inode *inode) { return ll_i2info(inode)->lli_maxbytes; diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 373a24f5d5d7..582fafcfdf3a 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -634,6 +634,45 @@ int ll_get_max_mdsize(struct ll_sb_info *sbi, int *lmmsize) return rc; } +int ll_get_default_mdsize(struct ll_sb_info *sbi, int *lmmsize) +{ + int size, rc; + + size = sizeof(int); + rc = obd_get_info(NULL, sbi->ll_md_exp, sizeof(KEY_DEFAULT_EASIZE), + KEY_DEFAULT_EASIZE, &size, lmmsize, NULL); + if (rc) + CERROR("Get default mdsize error rc %d\n", rc); + + return rc; +} + +int ll_get_max_cookiesize(struct ll_sb_info *sbi, int *lmmsize) +{ + int size, rc; + + size = sizeof(int); + rc = obd_get_info(NULL, sbi->ll_md_exp, sizeof(KEY_MAX_COOKIESIZE), + KEY_MAX_COOKIESIZE, &size, lmmsize, NULL); + if (rc) + CERROR("Get max cookiesize error rc %d\n", rc); + + return rc; +} + +int ll_get_default_cookiesize(struct ll_sb_info *sbi, int *lmmsize) +{ + int size, rc; + + size = sizeof(int); + rc = obd_get_info(NULL, sbi->ll_md_exp, sizeof(KEY_DEFAULT_COOKIESIZE), + KEY_DEFAULT_COOKIESIZE, &size, lmmsize, NULL); + if (rc) + CERROR("Get default cookiesize error rc %d\n", rc); + + return rc; +} + void ll_dump_inode(struct inode *inode) { struct ll_d_hlist_node *tmp; diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c index 3580069789fc..e0e112b710d7 100644 --- a/drivers/staging/lustre/lustre/llite/llite_nfs.c +++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c @@ -98,7 +98,7 @@ struct inode *search_inode_for_lustre(struct super_block *sb, if (inode) return inode; - rc = ll_get_max_mdsize(sbi, &eadatalen); + rc = ll_get_default_mdsize(sbi, &eadatalen); if (rc) return ERR_PTR(rc); @@ -290,7 +290,7 @@ static struct dentry *ll_get_parent(struct dentry *dchild) CDEBUG(D_INFO, "getting parent for (%lu,"DFID")\n", dir->i_ino, PFID(ll_inode2fid(dir))); - rc = ll_get_max_mdsize(sbi, &lmmsize); + rc = ll_get_default_mdsize(sbi, &lmmsize); if (rc != 0) return ERR_PTR(rc); diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 021deb918f38..f291254d0c80 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -681,7 +681,7 @@ static ssize_t ll_lazystatfs_seq_write(struct file *file, const char *buffer, } LPROC_SEQ_FOPS(ll_lazystatfs); -static int ll_maxea_size_seq_show(struct seq_file *m, void *v) +static int ll_max_easize_seq_show(struct seq_file *m, void *v) { struct super_block *sb = m->private; struct ll_sb_info *sbi = ll_s2sbi(sb); @@ -694,7 +694,52 @@ static int ll_maxea_size_seq_show(struct seq_file *m, void *v) return seq_printf(m, "%u\n", ealen); } -LPROC_SEQ_FOPS_RO(ll_maxea_size); +LPROC_SEQ_FOPS_RO(ll_max_easize); + +static int ll_defult_easize_seq_show(struct seq_file *m, void *v) +{ + struct super_block *sb = m->private; + struct ll_sb_info *sbi = ll_s2sbi(sb); + unsigned int ealen; + int rc; + + rc = ll_get_default_mdsize(sbi, &ealen); + if (rc) + return rc; + + return seq_printf(m, "%u\n", ealen); +} +LPROC_SEQ_FOPS_RO(ll_defult_easize); + +static int ll_max_cookiesize_seq_show(struct seq_file *m, void *v) +{ + struct super_block *sb = m->private; + struct ll_sb_info *sbi = ll_s2sbi(sb); + unsigned int cookielen; + int rc; + + rc = ll_get_max_cookiesize(sbi, &cookielen); + if (rc) + return rc; + + return seq_printf(m, "%u\n", cookielen); +} +LPROC_SEQ_FOPS_RO(ll_max_cookiesize); + +static int ll_defult_cookiesize_seq_show(struct seq_file *m, void *v) +{ + struct super_block *sb = m->private; + struct ll_sb_info *sbi = ll_s2sbi(sb); + unsigned int cookielen; + int rc; + + rc = ll_get_default_cookiesize(sbi, &cookielen); + if (rc) + return rc; + + return seq_printf(m, "%u\n", cookielen); +} +LPROC_SEQ_FOPS_RO(ll_defult_cookiesize); static int ll_sbi_flags_seq_show(struct seq_file *m, void *v) { @@ -781,7 +826,10 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = { { "statahead_agl", &ll_statahead_agl_fops, 0 }, { "statahead_stats", &ll_statahead_stats_fops, 0, 0 }, { "lazystatfs", &ll_lazystatfs_fops, 0 }, - { "max_easize", &ll_maxea_size_fops, 0, 0 }, + { "max_easize", &ll_max_easize_fops, 0, 0 }, + { "default_easize", &ll_defult_easize_fops, 0, 0 }, + { "max_cookiesize", &ll_max_cookiesize_fops, 0, 0 }, + { "default_cookiesize", &ll_defult_cookiesize_fops, 0, 0 }, { "sbi_flags", &ll_sbi_flags_fops, 0, 0 }, { "xattr_cache", &ll_xattr_cache_fops, 0, 0 }, { 0 } diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 3ba0a0a1d945..4edf8a31221c 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -280,7 +280,7 @@ static void lmv_set_timeouts(struct obd_device *obd) } static int lmv_init_ea_size(struct obd_export *exp, int easize, - int def_easize, int cookiesize) + int def_easize, int cookiesize, int def_cookiesize) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; @@ -300,6 +300,10 @@ static int lmv_init_ea_size(struct obd_export *exp, int easize, lmv->max_cookiesize = cookiesize; change = 1; } + if (lmv->max_def_cookiesize < def_cookiesize) { + lmv->max_def_cookiesize = def_cookiesize; + change = 1; + } if (change == 0) return 0; @@ -315,7 +319,7 @@ static int lmv_init_ea_size(struct obd_export *exp, int easize, } rc = md_init_ea_size(lmv->tgts[i]->ltd_exp, easize, def_easize, - cookiesize); + cookiesize, def_cookiesize); if (rc) { CERROR("%s: obd_init_ea_size() failed on MDT target %d:" " rc = %d.\n", obd->obd_name, i, rc); @@ -400,8 +404,8 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) tgt->ltd_exp = mdc_exp; lmv->desc.ld_active_tgt_count++; - md_init_ea_size(tgt->ltd_exp, lmv->max_easize, - lmv->max_def_easize, lmv->max_cookiesize); + md_init_ea_size(tgt->ltd_exp, lmv->max_easize, lmv->max_def_easize, + lmv->max_cookiesize, lmv->max_def_cookiesize); CDEBUG(D_CONFIG, "Connected to %s(%s) successfully (%d)\n", mdc_obd->obd_name, mdc_obd->obd_uuid.uuid, @@ -527,9 +531,8 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp, spin_unlock(&lmv->lmv_lock); } else { int easize = sizeof(struct lmv_stripe_md) + - lmv->desc.ld_tgt_count * - sizeof(struct lu_fid); - lmv_init_ea_size(obd->obd_self_export, easize, 0, 0); + lmv->desc.ld_tgt_count * sizeof(struct lu_fid); + lmv_init_ea_size(obd->obd_self_export, easize, 0, 0, 0); } } @@ -578,7 +581,7 @@ int lmv_check_connect(struct obd_device *obd) class_export_put(lmv->exp); lmv->connected = 1; easize = lmv_get_easize(lmv); - lmv_init_ea_size(obd->obd_self_export, easize, 0, 0); + lmv_init_ea_size(obd->obd_self_export, easize, 0, 0, 0); lmv_init_unlock(lmv); return 0; @@ -2340,7 +2343,11 @@ static int lmv_get_info(const struct lu_env *env, struct obd_export *exp, return 0; } return -EINVAL; - } else if (KEY_IS(KEY_MAX_EASIZE) || KEY_IS(KEY_CONN_DATA)) { + } else if (KEY_IS(KEY_MAX_EASIZE) || + KEY_IS(KEY_DEFAULT_EASIZE) || + KEY_IS(KEY_MAX_COOKIESIZE) || + KEY_IS(KEY_DEFAULT_COOKIESIZE) || + KEY_IS(KEY_CONN_DATA)) { rc = lmv_check_connect(obd); if (rc) return rc; diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index f86f69729042..41a18f546dc9 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -442,9 +442,9 @@ static struct ptlrpc_request *mdc_intent_unlink_pack(struct obd_export *exp, mdc_unlink_pack(req, op_data); req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER, - obddev->u.cli.cl_max_mds_easize); + obddev->u.cli.cl_default_mds_easize); req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER, - obddev->u.cli.cl_max_mds_cookiesize); + obddev->u.cli.cl_default_mds_cookiesize); ptlrpc_request_set_replen(req); return req; } @@ -484,10 +484,10 @@ static struct ptlrpc_request *mdc_intent_getattr_pack(struct obd_export *exp, /* pack the intended request */ mdc_getattr_pack(req, valid, it->it_flags, op_data, - obddev->u.cli.cl_max_mds_easize); + obddev->u.cli.cl_default_mds_easize); req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER, - obddev->u.cli.cl_max_mds_easize); + obddev->u.cli.cl_default_mds_easize); if (client_is_remote(exp)) req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER, sizeof(struct mdt_remote_perm)); @@ -528,7 +528,7 @@ static struct ptlrpc_request *mdc_intent_layout_pack(struct obd_export *exp, layout->li_opc = LAYOUT_INTENT_ACCESS; req_capsule_set_size(&req->rq_pill, &RMF_DLM_LVB, RCL_SERVER, - obd->u.cli.cl_max_mds_easize); + obd->u.cli.cl_default_mds_easize); ptlrpc_request_set_replen(req); return req; } diff --git a/drivers/staging/lustre/lustre/mdc/mdc_reint.c b/drivers/staging/lustre/lustre/mdc/mdc_reint.c index d79aa1641fef..19f20c1b66b9 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_reint.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_reint.c @@ -357,9 +357,9 @@ int mdc_unlink(struct obd_export *exp, struct md_op_data *op_data, mdc_unlink_pack(req, op_data); req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER, - obd->u.cli.cl_max_mds_easize); + obd->u.cli.cl_default_mds_easize); req_capsule_set_size(&req->rq_pill, &RMF_LOGCOOKIES, RCL_SERVER, - obd->u.cli.cl_max_mds_cookiesize); + obd->u.cli.cl_default_mds_cookiesize); ptlrpc_request_set_replen(req); *request = req; @@ -470,9 +470,9 @@ int mdc_rename(struct obd_export *exp, struct md_op_data *op_data, mdc_rename_pack(req, op_data, old, oldlen, new, newlen); req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER, - obd->u.cli.cl_max_mds_easize); + obd->u.cli.cl_default_mds_easize); req_capsule_set_size(&req->rq_pill, &RMF_LOGCOOKIES, RCL_SERVER, - obd->u.cli.cl_max_mds_cookiesize); + obd->u.cli.cl_default_mds_cookiesize); ptlrpc_request_set_replen(req); rc = mdc_reint(req, obd->u.cli.cl_rpc_lock, LUSTRE_IMP_FULL); diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index bde9f93c149b..fca43cf1d671 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -903,9 +903,9 @@ int mdc_close(struct obd_export *exp, struct md_op_data *op_data, mdc_close_pack(req, op_data); req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER, - obd->u.cli.cl_max_mds_easize); + obd->u.cli.cl_default_mds_easize); req_capsule_set_size(&req->rq_pill, &RMF_LOGCOOKIES, RCL_SERVER, - obd->u.cli.cl_max_mds_cookiesize); + obd->u.cli.cl_default_mds_cookiesize); ptlrpc_request_set_replen(req); @@ -2153,12 +2153,40 @@ int mdc_get_info(const struct lu_env *env, struct obd_export *exp, if (*vallen != sizeof(int)) return -EINVAL; - mdsize = *(int*)val; + mdsize = *(int *)val; if (mdsize > exp->exp_obd->u.cli.cl_max_mds_easize) exp->exp_obd->u.cli.cl_max_mds_easize = mdsize; max_easize = val; *max_easize = exp->exp_obd->u.cli.cl_max_mds_easize; return 0; + } else if (KEY_IS(KEY_DEFAULT_EASIZE)) { + int *default_easize; + + if (*vallen != sizeof(int)) + return -EINVAL; + default_easize = val; + *default_easize = exp->exp_obd->u.cli.cl_default_mds_easize; + return 0; + } else if (KEY_IS(KEY_MAX_COOKIESIZE)) { + int mdsize, *max_cookiesize; + + if (*vallen != sizeof(int)) + return -EINVAL; + mdsize = *(int *)val; + if (mdsize > exp->exp_obd->u.cli.cl_max_mds_cookiesize) + exp->exp_obd->u.cli.cl_max_mds_cookiesize = mdsize; + max_cookiesize = val; + *max_cookiesize = exp->exp_obd->u.cli.cl_max_mds_cookiesize; + return 0; + } else if (KEY_IS(KEY_DEFAULT_COOKIESIZE)) { + int *default_cookiesize; + + if (*vallen != sizeof(int)) + return -EINVAL; + default_cookiesize = val; + *default_cookiesize = + exp->exp_obd->u.cli.cl_default_mds_cookiesize; + return 0; } else if (KEY_IS(KEY_CONN_DATA)) { struct obd_import *imp = class_exp2cliimp(exp); struct obd_connect_data *data = val; @@ -2439,11 +2467,15 @@ err_rpc_lock: } /* Initialize the default and maximum LOV EA and cookie sizes. This allows - * us to make MDS RPCs with large enough reply buffers to hold the - * maximum-sized (= maximum striped) EA and cookie without having to - * calculate this (via a call into the LOV + OSCs) each time we make an RPC. */ + * us to make MDS RPCs with large enough reply buffers to hold a default + * sized EA and cookie without having to calculate this (via a call into the + * LOV + OSCs) each time we make an RPC. The maximum size is also tracked + * but not used to avoid wastefully vmalloc()'ing large reply buffers when + * a large number of stripes is possible. If a larger reply buffer is + * required it will be reallocated in the ptlrpc layer due to overflow. + */ static int mdc_init_ea_size(struct obd_export *exp, int easize, - int def_easize, int cookiesize) + int def_easize, int cookiesize, int def_cookiesize) { struct obd_device *obd = exp->exp_obd; struct client_obd *cli = &obd->u.cli; @@ -2457,6 +2489,9 @@ static int mdc_init_ea_size(struct obd_export *exp, int easize, if (cli->cl_max_mds_cookiesize < cookiesize) cli->cl_max_mds_cookiesize = cookiesize; + if (cli->cl_default_mds_cookiesize < def_cookiesize) + cli->cl_default_mds_cookiesize = def_cookiesize; + return 0; } -- cgit v1.2.3 From 717d1c2ee31e28af834278e0ace4b48f086c3c6a Mon Sep 17 00:00:00 2001 From: "Christopher J. Morrone" Date: Sun, 27 Apr 2014 13:06:48 -0400 Subject: staging/lustre/llite: Avoid statahead thread start/stop deadlocks The statahead and statahead agl threads blindly set their thread state to SVC_RUNNING without checking the state first. If, for instance, another thread sets the state to SVC_STOPPING that stop signal will now have been lost. Deadlock ensues. We also partly improve the sai reference counting, because a race exists where the ll_stop_statahead thread can drop the default reference, and the statahead thread can exit and drop its reference as well. With no references on the sai, the final put will poison and free the buffer. The original do_statahead_enter() function may then continue to access the buffer after it is freed because it did not take a reference of its own. We add a local reference to address that. Signed-off-by: Christopher J. Morrone Reviewed-on: http://review.whamcloud.com/9358 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4624 Reviewed-by: Lai Siyao Reviewed-by: Fan Yong Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/statahead.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index c8624b5a9875..74d95b04d235 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -964,7 +964,11 @@ static int ll_agl_thread(void *arg) atomic_inc(&sbi->ll_agl_total); spin_lock(&plli->lli_agl_lock); sai->sai_agl_valid = 1; - thread_set_flags(thread, SVC_RUNNING); + if (thread_is_init(thread)) + /* If someone else has changed the thread state + * (e.g. already changed to SVC_STOPPING), we can't just + * blindly overwrite that setting. */ + thread_set_flags(thread, SVC_RUNNING); spin_unlock(&plli->lli_agl_lock); wake_up(&thread->t_ctl_waitq); @@ -1058,7 +1062,11 @@ static int ll_statahead_thread(void *arg) atomic_inc(&sbi->ll_sa_total); spin_lock(&plli->lli_sa_lock); - thread_set_flags(thread, SVC_RUNNING); + if (thread_is_init(thread)) + /* If someone else has changed the thread state + * (e.g. already changed to SVC_STOPPING), we can't just + * blindly overwrite that setting. */ + thread_set_flags(thread, SVC_RUNNING); spin_unlock(&plli->lli_sa_lock); wake_up(&thread->t_ctl_waitq); @@ -1658,6 +1666,12 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, CDEBUG(D_READA, "start statahead thread: [pid %d] [parent %.*s]\n", current_pid(), parent->d_name.len, parent->d_name.name); + /* The sai buffer already has one reference taken at allocation time, + * but as soon as we expose the sai by attaching it to the lli that + * default reference can be dropped by another thread calling + * ll_stop_statahead. We need to take a local reference to protect + * the sai buffer while we intend to access it. */ + ll_sai_get(sai); lli->lli_sai = sai; plli = ll_i2info(parent->d_inode); @@ -1670,6 +1684,9 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, lli->lli_opendir_key = NULL; thread_set_flags(thread, SVC_STOPPED); thread_set_flags(&sai->sai_agl_thread, SVC_STOPPED); + /* Drop both our own local reference and the default + * reference from allocation time. */ + ll_sai_put(sai); ll_sai_put(sai); LASSERT(lli->lli_sai == NULL); return -EAGAIN; @@ -1678,6 +1695,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, l_wait_event(thread->t_ctl_waitq, thread_is_running(thread) || thread_is_stopped(thread), &lwi); + ll_sai_put(sai); /* * We don't stat-ahead for the first dirent since we are already in -- cgit v1.2.3 From 9fc3b028b9518bd09fe24219cb2f9c439a1848fc Mon Sep 17 00:00:00 2001 From: "Christopher J. Morrone" Date: Sun, 27 Apr 2014 13:06:49 -0400 Subject: stagaing/lustre: Improve statahead debug messages The statahead debug messages include the pid of the current process in their body. This is both redudant (because all lustre log messages contain the pid), and sometimes downright misleading. For instance the messages would say something like "stopping statahead thread 3446". One would probably think that 3446 is the pid of the process that is being stopped, but in fact it was the pid of the caller issuing the stop signal. We remove all superfluous pids from the messages. Next we have the ll_statahead_thread() and the ll_agl_thread() record their respective pids in their respective ptlrpc_thread structures. This allows to print the pid of the thread that we are trying to stop (which is actually useful info) from other threads, such as those calling ll_stop_statahead(). Signed-off-by: Christopher J. Morrone Reviewed-on: http://review.whamcloud.com/9360 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4624 Reviewed-by: Fan Yong Reviewed-by: Lai Siyao Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/statahead.c | 38 +++++++++++++------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index 74d95b04d235..51c532756a7c 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -958,8 +958,9 @@ static int ll_agl_thread(void *arg) struct ptlrpc_thread *thread = &sai->sai_agl_thread; struct l_wait_info lwi = { 0 }; - CDEBUG(D_READA, "agl thread started: [pid %d] [parent %.*s]\n", - current_pid(), parent->d_name.len, parent->d_name.name); + thread->t_pid = current_pid(); + CDEBUG(D_READA, "agl thread started: sai %p, parent %.*s\n", + sai, parent->d_name.len, parent->d_name.name); atomic_inc(&sbi->ll_agl_total); spin_lock(&plli->lli_agl_lock); @@ -1008,8 +1009,8 @@ static int ll_agl_thread(void *arg) spin_unlock(&plli->lli_agl_lock); wake_up(&thread->t_ctl_waitq); ll_sai_put(sai); - CDEBUG(D_READA, "agl thread stopped: [pid %d] [parent %.*s]\n", - current_pid(), parent->d_name.len, parent->d_name.name); + CDEBUG(D_READA, "agl thread stopped: sai %p, parent %.*s\n", + sai, parent->d_name.len, parent->d_name.name); return 0; } @@ -1020,8 +1021,8 @@ static void ll_start_agl(struct dentry *parent, struct ll_statahead_info *sai) struct ll_inode_info *plli; struct task_struct *task; - CDEBUG(D_READA, "start agl thread: [pid %d] [parent %.*s]\n", - current_pid(), parent->d_name.len, parent->d_name.name); + CDEBUG(D_READA, "start agl thread: sai %p, parent %.*s\n", + sai, parent->d_name.len, parent->d_name.name); plli = ll_i2info(parent->d_inode); task = kthread_run(ll_agl_thread, parent, @@ -1054,8 +1055,9 @@ static int ll_statahead_thread(void *arg) struct ll_dir_chain chain; struct l_wait_info lwi = { 0 }; - CDEBUG(D_READA, "statahead thread started: [pid %d] [parent %.*s]\n", - current_pid(), parent->d_name.len, parent->d_name.name); + thread->t_pid = current_pid(); + CDEBUG(D_READA, "statahead thread starting: sai %p, parent %.*s\n", + sai, parent->d_name.len, parent->d_name.name); if (sbi->ll_flags & LL_SBI_AGL_ENABLED) ll_start_agl(parent, sai); @@ -1247,8 +1249,8 @@ out: spin_unlock(&plli->lli_agl_lock); wake_up(&agl_thread->t_ctl_waitq); - CDEBUG(D_READA, "stop agl thread: [pid %d]\n", - current_pid()); + CDEBUG(D_READA, "stop agl thread: sai %p pid %u\n", + sai, (unsigned int)agl_thread->t_pid); l_wait_event(agl_thread->t_ctl_waitq, thread_is_stopped(agl_thread), &lwi); @@ -1274,8 +1276,8 @@ out: wake_up(&thread->t_ctl_waitq); ll_sai_put(sai); dput(parent); - CDEBUG(D_READA, "statahead thread stopped: [pid %d] [parent %.*s]\n", - current_pid(), parent->d_name.len, parent->d_name.name); + CDEBUG(D_READA, "statahead thread stopped: sai %p, parent %.*s\n", + sai, parent->d_name.len, parent->d_name.name); return rc; } @@ -1306,8 +1308,8 @@ void ll_stop_statahead(struct inode *dir, void *key) spin_unlock(&lli->lli_sa_lock); wake_up(&thread->t_ctl_waitq); - CDEBUG(D_READA, "stop statahead thread: [pid %d]\n", - current_pid()); + CDEBUG(D_READA, "stop statahead thread: sai %p pid %u\n", + lli->lli_sai, (unsigned int)thread->t_pid); l_wait_event(thread->t_ctl_waitq, thread_is_stopped(thread), &lwi); @@ -1481,10 +1483,10 @@ ll_sai_unplug(struct ll_statahead_info *sai, struct ll_sa_entry *entry) CDEBUG(D_READA, "Statahead for dir "DFID" hit " "ratio too low: hit/miss "LPU64"/"LPU64 ", sent/replied "LPU64"/"LPU64", stopping " - "statahead thread: pid %d\n", + "statahead thread\n", PFID(&lli->lli_fid), sai->sai_hit, sai->sai_miss, sai->sai_sent, - sai->sai_replied, current_pid()); + sai->sai_replied); spin_lock(&lli->lli_sa_lock); if (!thread_is_stopped(thread)) thread_set_flags(thread, SVC_STOPPING); @@ -1663,8 +1665,8 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, GOTO(out, rc = -EAGAIN); } - CDEBUG(D_READA, "start statahead thread: [pid %d] [parent %.*s]\n", - current_pid(), parent->d_name.len, parent->d_name.name); + CDEBUG(D_READA, "start statahead thread: sai %p, parent %.*s\n", + sai, parent->d_name.len, parent->d_name.name); /* The sai buffer already has one reference taken at allocation time, * but as soon as we expose the sai by attaching it to the lli that -- cgit v1.2.3 From 09aed8a59cb659f6cbdf5b1f5c3174e7e3d306aa Mon Sep 17 00:00:00 2001 From: Jinshan Xiong Date: Sun, 27 Apr 2014 13:06:50 -0400 Subject: staging/lustre/llite: access layout version under a lock We used to access layout version under the protection of ldlm lock, this introduces extra overhead for dlm lock matching. In this patch, lli_layout_lock is introduced to access the layout version. Also, when a layout lock is losing, we should tear down mmap of the correspoding inode to avoid stale data accessing in the future. This is part of technical verification of replication. Signed-off-by: Jinshan Xiong Reviewed-on: http://review.whamcloud.com/8689 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3254 Reviewed-by: Lai Siyao Reviewed-by: Bobi Jam Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/file.c | 22 ++++----------- .../staging/lustre/lustre/llite/llite_internal.h | 21 ++++++++++++++- drivers/staging/lustre/lustre/llite/llite_lib.c | 3 ++- drivers/staging/lustre/lustre/llite/vvp_io.c | 2 +- drivers/staging/lustre/lustre/llite/vvp_object.c | 31 ++++++++++++++++------ 5 files changed, 51 insertions(+), 28 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 166321c0e992..e3bc2b0173ca 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -3436,7 +3436,7 @@ static int ll_layout_lock_set(struct lustre_handle *lockh, ldlm_mode_t mode, if (lvb_ready) { /* layout_gen must be valid if layout lock is not * cancelled and stripe has already set */ - *gen = lli->lli_layout_gen; + *gen = ll_layout_version_get(lli); rc = 0; } GOTO(out, rc); @@ -3534,32 +3534,20 @@ int ll_layout_refresh(struct inode *inode, __u32 *gen) }; int rc; - *gen = lli->lli_layout_gen; - if (!(sbi->ll_flags & LL_SBI_LAYOUT_LOCK)) + *gen = ll_layout_version_get(lli); + if (!(sbi->ll_flags & LL_SBI_LAYOUT_LOCK) || *gen != LL_LAYOUT_GEN_NONE) return 0; /* sanity checks */ LASSERT(fid_is_sane(ll_inode2fid(inode))); LASSERT(S_ISREG(inode->i_mode)); - /* mostly layout lock is caching on the local side, so try to match - * it before grabbing layout lock mutex. */ - mode = ll_take_md_lock(inode, MDS_INODELOCK_LAYOUT, &lockh, 0, - LCK_CR | LCK_CW | LCK_PR | LCK_PW); - if (mode != 0) { /* hit cached lock */ - rc = ll_layout_lock_set(&lockh, mode, inode, gen, false); - if (rc == 0) - return 0; - - /* better hold lli_layout_mutex to try again otherwise - * it will have starvation problem. */ - } - /* take layout lock mutex to enqueue layout lock exclusively. */ mutex_lock(&lli->lli_layout_mutex); again: - /* try again. Maybe somebody else has done this. */ + /* mostly layout lock is caching on the local side, so try to match + * it before grabbing layout lock mutex. */ mode = ll_take_md_lock(inode, MDS_INODELOCK_LAYOUT, &lockh, 0, LCK_CR | LCK_CW | LCK_PR | LCK_PW); if (mode != 0) { /* hit cached lock */ diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 4663e824c282..d2f8250b87f1 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -280,14 +280,33 @@ struct ll_inode_info { /* mutex to request for layout lock exclusively. */ struct mutex lli_layout_mutex; - /* valid only inside LAYOUT ibits lock, protected by lli_layout_mutex */ + /* Layout version, protected by lli_layout_lock */ __u32 lli_layout_gen; + spinlock_t lli_layout_lock; struct rw_semaphore lli_xattrs_list_rwsem; struct mutex lli_xattrs_enq_lock; struct list_head lli_xattrs;/* ll_xattr_entry->xe_list */ }; +static inline __u32 ll_layout_version_get(struct ll_inode_info *lli) +{ + __u32 gen; + + spin_lock(&lli->lli_layout_lock); + gen = lli->lli_layout_gen; + spin_unlock(&lli->lli_layout_lock); + + return gen; +} + +static inline void ll_layout_version_set(struct ll_inode_info *lli, __u32 gen) +{ + spin_lock(&lli->lli_layout_lock); + lli->lli_layout_gen = gen; + spin_unlock(&lli->lli_layout_lock); +} + int ll_xattr_cache_destroy(struct inode *inode); int ll_xattr_cache_get(struct inode *inode, diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 582fafcfdf3a..befc30b22bc1 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -966,7 +966,8 @@ void ll_lli_init(struct ll_inode_info *lli) mutex_init(&lli->lli_och_mutex); spin_lock_init(&lli->lli_agl_lock); lli->lli_has_smd = false; - lli->lli_layout_gen = LL_LAYOUT_GEN_NONE; + spin_lock_init(&lli->lli_layout_lock); + ll_layout_version_set(lli, LL_LAYOUT_GEN_NONE); lli->lli_clob = NULL; init_rwsem(&lli->lli_xattrs_list_rwsem); diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index c7d70091246e..5156ab829090 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c @@ -80,7 +80,7 @@ static bool can_populate_pages(const struct lu_env *env, struct cl_io *io, case CIT_WRITE: /* don't need lock here to check lli_layout_gen as we have held * extent lock and GROUP lock has to hold to swap layout */ - if (lli->lli_layout_gen != cio->cui_layout_gen) { + if (ll_layout_version_get(lli) != cio->cui_layout_gen) { io->ci_need_restart = 1; /* this will return application a short read/write */ io->ci_continue = 0; diff --git a/drivers/staging/lustre/lustre/llite/vvp_object.c b/drivers/staging/lustre/lustre/llite/vvp_object.c index 25973dedd9a2..554a5dd2155c 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_object.c +++ b/drivers/staging/lustre/lustre/llite/vvp_object.c @@ -126,7 +126,22 @@ int vvp_conf_set(const struct lu_env *env, struct cl_object *obj, struct ll_inode_info *lli = ll_i2info(conf->coc_inode); if (conf->coc_opc == OBJECT_CONF_INVALIDATE) { - lli->lli_layout_gen = LL_LAYOUT_GEN_NONE; + CDEBUG(D_VFSTRACE, DFID ": losing layout lock\n", + PFID(&lli->lli_fid)); + + ll_layout_version_set(lli, LL_LAYOUT_GEN_NONE); + + /* Clean up page mmap for this inode. + * The reason for us to do this is that if the page has + * already been installed into memory space, the process + * can access it without interacting with lustre, so this + * page may be stale due to layout change, and the process + * will never be notified. + * This operation is expensive but mmap processes have to pay + * a price themselves. */ + unmap_mapping_range(conf->coc_inode->i_mapping, + 0, OBD_OBJECT_EOF, 0); + return 0; } @@ -134,18 +149,18 @@ int vvp_conf_set(const struct lu_env *env, struct cl_object *obj, return 0; if (conf->u.coc_md != NULL && conf->u.coc_md->lsm != NULL) { - CDEBUG(D_VFSTRACE, "layout lock change: %u -> %u\n", - lli->lli_layout_gen, - conf->u.coc_md->lsm->lsm_layout_gen); + CDEBUG(D_VFSTRACE, DFID ": layout version change: %u -> %u\n", + PFID(&lli->lli_fid), lli->lli_layout_gen, + conf->u.coc_md->lsm->lsm_layout_gen); lli->lli_has_smd = lsm_has_objects(conf->u.coc_md->lsm); - lli->lli_layout_gen = conf->u.coc_md->lsm->lsm_layout_gen; + ll_layout_version_set(lli, conf->u.coc_md->lsm->lsm_layout_gen); } else { - CDEBUG(D_VFSTRACE, "layout lock destroyed: %u.\n", - lli->lli_layout_gen); + CDEBUG(D_VFSTRACE, DFID ": layout nuked: %u.\n", + PFID(&lli->lli_fid), lli->lli_layout_gen); lli->lli_has_smd = false; - lli->lli_layout_gen = LL_LAYOUT_GEN_EMPTY; + ll_layout_version_set(lli, LL_LAYOUT_GEN_EMPTY); } return 0; } -- cgit v1.2.3 From a700f975356b845869ba3c2baab0d8430d00921a Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Sun, 27 Apr 2014 13:06:51 -0400 Subject: staging/lustre: shrink lu_object_header by 8 bytes on x86_64 Locate the loh_flags and loh_ref fields together in lu_object_header to avoid holes and shrink the structure by 8 bytes. Signed-off-by: Andreas Dilger Reviewed-on: http://review.whamcloud.com/9185 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3059 Reviewed-by: Alex Zhuravlev Reviewed-by: Liang Zhen Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/lu_object.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h index 6773bca1e0d8..98149f5da153 100644 --- a/drivers/staging/lustre/lustre/include/lu_object.h +++ b/drivers/staging/lustre/lustre/include/lu_object.h @@ -515,6 +515,10 @@ enum lu_object_header_attr { * whether object is backed by persistent storage entity. */ struct lu_object_header { + /** + * Fid, uniquely identifying this object. + */ + struct lu_fid loh_fid; /** * Object flags from enum lu_object_header_flags. Set and checked * atomically. @@ -524,10 +528,6 @@ struct lu_object_header { * Object reference count. Protected by lu_site::ls_guard. */ atomic_t loh_ref; - /** - * Fid, uniquely identifying this object. - */ - struct lu_fid loh_fid; /** * Common object attributes, cached for efficiency. From enum * lu_object_header_attr. -- cgit v1.2.3 From f85065e534fe8ba6de9b3443c4beacbc3a6ec32d Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Sun, 27 Apr 2014 13:06:52 -0400 Subject: staging/lustre/ldlm: fix NULL pointer dereference Pointer '*exp' returned from call to function 'class_conn2export' at line 523 may be NULL and may be dereferenced at line 543. Signed-off-by: Dmitry Eremin Reviewed-on: http://review.whamcloud.com/9323 ntel-bug-id: https://jira.hpdd.intel.com/browse/LU-4629 Reviewed-by: John L. Hammond Reviewed-by: James Simmons Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/ldlm_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c index 1a8c0d7005c7..42f5f1e54fcc 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c @@ -514,7 +514,7 @@ int client_connect_import(const struct lu_env *env, LASSERT (imp->imp_state == LUSTRE_IMP_DISCON); GOTO(out_ldlm, rc); } - LASSERT((*exp)->exp_connection); + LASSERT(*exp != NULL && (*exp)->exp_connection); if (data) { LASSERTF((ocd->ocd_connect_flags & data->ocd_connect_flags) == -- cgit v1.2.3 From ba0e1b53726d233360960e7ae7f65b3be32042a9 Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Sun, 27 Apr 2014 13:06:54 -0400 Subject: staging/lustre/mdc: fix issue found by Klocwork Insight tool Pointer 'mod' checked for NULL at line 160 may be dereferenced at line 208. Signed-off-by: Dmitry Eremin Reviewed-on: http://review.whamcloud.com/9387 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4629 Reviewed-by: Lai Siyao Reviewed-by: John L. Hammond Reviewed-by: Fan Yong Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/mdc/mdc_reint.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/mdc/mdc_reint.c b/drivers/staging/lustre/lustre/mdc/mdc_reint.c index 19f20c1b66b9..08e80940ee4d 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_reint.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_reint.c @@ -199,7 +199,8 @@ int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data, *request = req; if (rc && req->rq_commit_cb) { /* Put an extra reference on \var mod on error case. */ - obd_mod_put(*mod); + if (mod != NULL && *mod != NULL) + obd_mod_put(*mod); req->rq_commit_cb(req); } return rc; -- cgit v1.2.3 From 16e9f6d48bf6400ca3541a20aee5ec7bb414e1e4 Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Sun, 27 Apr 2014 13:06:55 -0400 Subject: staging/lustre/libcfs: fix issues found by Klocwork Insight tool sscanf format specification '%u' expects type 'unsigned int *' for 'u', but parameter 3 has a different type 'int*'. Signed-off-by: Dmitry Eremin Reviewed-on: http://review.whamcloud.com/9400 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4629 Reviewed-by: John L. Hammond Reviewed-by: James Simmons Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c | 2 +- drivers/staging/lustre/lustre/libcfs/nidstrings.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c index 77b1ef64ecc0..d169374eb98d 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c @@ -881,7 +881,7 @@ cfs_cpt_table_create_pattern(char *pattern) break; } - if (sscanf(str, "%u%n", &cpt, &n) < 1) { + if (sscanf(str, "%d%n", &cpt, &n) < 1) { CERROR("Invalid cpu pattern %s\n", str); goto failed; } diff --git a/drivers/staging/lustre/lustre/libcfs/nidstrings.c b/drivers/staging/lustre/lustre/libcfs/nidstrings.c index cfb274fc9cbd..87705ae4480f 100644 --- a/drivers/staging/lustre/lustre/libcfs/nidstrings.c +++ b/drivers/staging/lustre/lustre/libcfs/nidstrings.c @@ -227,11 +227,11 @@ libcfs_ip_addr2str(__u32 addr, char *str) int libcfs_ip_str2addr(const char *str, int nob, __u32 *addr) { - int a; - int b; - int c; - int d; - int n = nob; /* XscanfX */ + unsigned int a; + unsigned int b; + unsigned int c; + unsigned int d; + int n = nob; /* XscanfX */ /* numeric IP? */ if (sscanf(str, "%u.%u.%u.%u%n", &a, &b, &c, &d, &n) >= 4 && @@ -419,7 +419,7 @@ libcfs_str2net_internal(const char *str, __u32 *net) { struct netstrfns *uninitialized_var(nf); int nob; - int netnum; + unsigned int netnum; int i; for (i = 0; i < libcfs_nnetstrfns; i++) { -- cgit v1.2.3 From 526cdb4f3e2ed9c42bb1d866069c4dfe42f4a03d Mon Sep 17 00:00:00 2001 From: Liang Zhen Date: Sun, 27 Apr 2014 13:06:56 -0400 Subject: staging/lustre/lnet: NI shutdown may loop forever lnet_shutdown_lndnis() may enter endless loop if there is a busy NI, this is injected by LNet SMP improvements. It's fixed in this patch. Signed-off-by: Liang Zhen Reviewed-on: http://review.whamcloud.com/9706 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4780 Reviewed-by: Isaac Huang Reviewed-by: Bobi Jam Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/lnet/api-ni.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 3f3c341c1197..85b8d815282d 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -986,12 +986,11 @@ lnet_shutdown_lndnis (void) break; } - while (!list_empty(&ni->ni_list)) { + if (!list_empty(&ni->ni_list)) { lnet_net_unlock(LNET_LOCK_EX); ++i; if ((i & (-i)) == i) { - CDEBUG(D_WARNING, - "Waiting for zombie LNI %s\n", + CDEBUG(D_WARNING, "Waiting for zombie LNI %s\n", libcfs_nid2str(ni->ni_nid)); } set_current_state(TASK_UNINTERRUPTIBLE); @@ -1016,6 +1015,8 @@ lnet_shutdown_lndnis (void) libcfs_nid2str(ni->ni_nid)); lnet_ni_free(ni); + i = 2; + lnet_net_lock(LNET_LOCK_EX); } -- cgit v1.2.3 From 20c53d8252b2d4357c5c3ac44c020962fafa0cfb Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Sun, 27 Apr 2014 13:06:57 -0400 Subject: staging/lustre: remove lustre/include/ioctl.h Remove the nowhere included header lustre/include/ioctl.h. Signed-off-by: John L. Hammond Reviewed-on: http://review.whamcloud.com/9757 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2675 Reviewed-by: Bob Glossman Reviewed-by: Dmitry Eremin Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/ioctl.h | 106 -------------------------- 1 file changed, 106 deletions(-) delete mode 100644 drivers/staging/lustre/lustre/include/ioctl.h diff --git a/drivers/staging/lustre/lustre/include/ioctl.h b/drivers/staging/lustre/lustre/include/ioctl.h deleted file mode 100644 index b986920926bd..000000000000 --- a/drivers/staging/lustre/lustre/include/ioctl.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * 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 version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#ifndef _IOWR - -/* On i386 and x86_64, _ASM_I386_IOCTL_H is defined by the kernel's ioctl.h, - * and on newer kernels this header is shared as _ASM_GENERIC_IOCTL_H. - * - * We can avoid any problems with the kernel header being included again by - * defining _ASM_I386_IOCTL_H here so that a later occurrence of - * does not include the kernel's ioctl.h after this one. b=14746 */ -#define _ASM_I386_IOCTL_H -#define _ASM_GENERIC_IOCTL_H - -/* ioctl command encoding: 32 bits total, command in lower 16 bits, - * size of the parameter structure in the lower 14 bits of the - * upper 16 bits. - * Encoding the size of the parameter structure in the ioctl request - * The highest 2 bits are reserved for indicating the ``access mode''. - * NOTE: This limits the max parameter size to 16kB -1 ! - */ - -/* - * The following is for compatibility across the various Linux - * platforms. The i386 ioctl numbering scheme doesn't really enforce - * a type field. De facto, however, the top 8 bits of the lower 16 - * bits are indeed used as a type field, so we might just as well make - * this explicit here. Please be sure to use the decoding macros - * below from now on. - */ -#define _IOC_NRBITS 8 -#define _IOC_TYPEBITS 8 -#define _IOC_SIZEBITS 14 -#define _IOC_DIRBITS 2 - -#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) -#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) -#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) -#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) - -#define _IOC_NRSHIFT 0 -#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) -#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) -#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) - -/* - * Direction bits. - */ -#define _IOC_NONE 0U -#define _IOC_WRITE 1U -#define _IOC_READ 2U - -#define _IOC(dir,type,nr,size) (((dir) << _IOC_DIRSHIFT) | ((type) << _IOC_TYPESHIFT) | ((nr) << _IOC_NRSHIFT) | ((size) << _IOC_SIZESHIFT)) - -/* used to create numbers */ -#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) -#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size)) -#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size)) -#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size)) - -/* used to decode ioctl numbers.. */ -#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) -#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK) -#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK) -#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK) - -/* ...and for the drivers/sound files... */ - -#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT) -#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT) -#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT) -#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT) -#define IOCSIZE_SHIFT (_IOC_SIZESHIFT) - -#endif /* _IOWR */ -- cgit v1.2.3 From 5426ba66e1a802c74d11e76454f1151233e43bb1 Mon Sep 17 00:00:00 2001 From: Li Xi Date: Sun, 27 Apr 2014 13:06:58 -0400 Subject: staging/lustre/libcfs: add CPU table functions for uniprocessor Some CPU table functions for uniprocessor architecture is missing. Signed-off-by: Li Xi Signed-off-by: James Simmons Reviewed-on: http://review.whamcloud.com/8873 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4199 Reviewed-by: Bob Glossman Reviewed-by: Dmitry Eremin Reviewed-by: Liang Zhen Reviewed-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/include/linux/libcfs/libcfs_cpu.h | 5 +++++ .../lustre/include/linux/libcfs/linux/linux-mem.h | 5 +++++ drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c | 21 +++++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h index d116fdfc5c41..a140e5d91860 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h @@ -202,6 +202,11 @@ void cfs_cpt_clear(struct cfs_cpt_table *cptab, int cpt); */ int cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt); +/** + * return number of HTs in the same core of \a cpu + */ +int cfs_cpu_ht_nsiblings(int cpu); + /** * iterate over all CPU partitions in \a cptab */ diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-mem.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-mem.h index 2af15d41e77a..72c76ad96ce9 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-mem.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-mem.h @@ -53,6 +53,11 @@ #include #include +#ifndef HAVE_LIBCFS_CPT +/* Need this for cfs_cpt_table */ +#include +#endif + #define CFS_PAGE_MASK (~((__u64)PAGE_CACHE_SIZE-1)) #define page_index(p) ((p)->index) diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c b/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c index 1fb37008cda2..d985e83ba2c3 100644 --- a/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c +++ b/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c @@ -74,6 +74,20 @@ cfs_cpt_table_free(struct cfs_cpt_table *cptab) } EXPORT_SYMBOL(cfs_cpt_table_free); +int +cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len) +{ + int rc = 0; + + rc = snprintf(buf, len, "%d\t: %d\n", 0, 0); + len -= rc; + if (len <= 0) + return -EFBIG; + + return rc; +} +EXPORT_SYMBOL(cfs_cpt_table_print); + int cfs_cpt_number(struct cfs_cpt_table *cptab) { @@ -160,6 +174,13 @@ cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt) } EXPORT_SYMBOL(cfs_cpt_spread_node); +int +cfs_cpu_ht_nsiblings(int cpu) +{ + return 1; +} +EXPORT_SYMBOL(cfs_cpu_ht_nsiblings); + int cfs_cpt_current(struct cfs_cpt_table *cptab, int remap) { -- cgit v1.2.3 From 6246dab1d0d3a91614eb0360e51d9e98b919dbb1 Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Sun, 27 Apr 2014 13:06:59 -0400 Subject: staging/lustre: replace semaphores with mutexes It's just optimization. The mutex subsystem is slightly faster and has better scalability for contended workloads. Remove the lustre_lock and it's accessor functions l_lock(), l_unlock(), l_lock_init(), and l_has_lock() since they have not been used by the code since Lustre 1.6. Signed-off-by: Dmitry Eremin Reviewed-on: http://review.whamcloud.com/9294 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4588 Reviewed-by: Andreas Dilger Reviewed-by: John L. Hammond Reviewed-by: James Simmons Reviewed-by: Alex Zhuravlev Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/lustre_lib.h | 13 ------------- drivers/staging/lustre/lustre/include/obd.h | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_lib.c | 2 +- drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c | 16 ++++++++-------- drivers/staging/lustre/lustre/mgc/mgc_request.c | 8 ++++---- 5 files changed, 14 insertions(+), 27 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_lib.h b/drivers/staging/lustre/lustre/include/lustre_lib.h index 0368ca6ffcc1..bdc981214805 100644 --- a/drivers/staging/lustre/lustre/include/lustre_lib.h +++ b/drivers/staging/lustre/lustre/include/lustre_lib.h @@ -94,19 +94,6 @@ struct obd_client_handle { void statfs_pack(struct obd_statfs *osfs, struct kstatfs *sfs); void statfs_unpack(struct kstatfs *sfs, struct obd_statfs *osfs); -/* l_lock.c */ -struct lustre_lock { - int l_depth; - struct task_struct *l_owner; - struct semaphore l_sem; - spinlock_t l_spin; -}; - -void l_lock_init(struct lustre_lock *); -void l_lock(struct lustre_lock *); -void l_unlock(struct lustre_lock *); -int l_has_lock(struct lustre_lock *); - /* * For md echo client */ diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 7ed5fcd7f86d..d5c4613f182d 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -406,7 +406,7 @@ struct client_obd { struct mdc_rpc_lock *cl_close_lock; /* mgc datastruct */ - struct semaphore cl_mgc_sem; + struct mutex cl_mgc_mutex; struct local_oid_storage *cl_mgc_los; struct dt_object *cl_mgc_configs_dir; atomic_t cl_mgc_refcount; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c index 42f5f1e54fcc..8bb59155968f 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c @@ -325,7 +325,7 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) } init_rwsem(&cli->cl_sem); - sema_init(&cli->cl_mgc_sem, 1); + mutex_init(&cli->cl_mgc_mutex); cli->cl_conn_count = 0; memcpy(server_uuid.uuid, lustre_cfg_buf(lcfg, 2), min_t(unsigned int, LUSTRE_CFG_BUFLEN(lcfg, 2), diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c index d169374eb98d..fc21210d77ec 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c @@ -71,7 +71,7 @@ struct cfs_cpt_data { /* reserved for hotplug */ unsigned long cpt_version; /* mutex to protect cpt_cpumask */ - struct semaphore cpt_mutex; + struct mutex cpt_mutex; /* scratch buffer for set/unset_node */ cpumask_t *cpt_cpumask; }; @@ -420,14 +420,14 @@ cfs_cpt_set_node(struct cfs_cpt_table *cptab, int cpt, int node) return 0; } - down(&cpt_data.cpt_mutex); + mutex_lock(&cpt_data.cpt_mutex); mask = cpt_data.cpt_cpumask; cfs_node_to_cpumask(node, mask); rc = cfs_cpt_set_cpumask(cptab, cpt, mask); - up(&cpt_data.cpt_mutex); + mutex_unlock(&cpt_data.cpt_mutex); return rc; } @@ -444,14 +444,14 @@ cfs_cpt_unset_node(struct cfs_cpt_table *cptab, int cpt, int node) return; } - down(&cpt_data.cpt_mutex); + mutex_lock(&cpt_data.cpt_mutex); mask = cpt_data.cpt_cpumask; cfs_node_to_cpumask(node, mask); cfs_cpt_unset_cpumask(cptab, cpt, mask); - up(&cpt_data.cpt_mutex); + mutex_unlock(&cpt_data.cpt_mutex); } EXPORT_SYMBOL(cfs_cpt_unset_node); @@ -969,11 +969,11 @@ cfs_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) break; } - down(&cpt_data.cpt_mutex); + mutex_lock(&cpt_data.cpt_mutex); /* if all HTs in a core are offline, it may break affinity */ cfs_cpu_ht_siblings(cpu, cpt_data.cpt_cpumask); warn = any_online_cpu(*cpt_data.cpt_cpumask) >= nr_cpu_ids; - up(&cpt_data.cpt_mutex); + mutex_unlock(&cpt_data.cpt_mutex); CDEBUG(warn ? D_WARNING : D_INFO, "Lustre: can't support CPU plug-out well now, " "performance and stability could be impacted " @@ -1017,7 +1017,7 @@ cfs_cpu_init(void) } spin_lock_init(&cpt_data.cpt_lock); - sema_init(&cpt_data.cpt_mutex, 1); + mutex_init(&cpt_data.cpt_mutex); #ifdef CONFIG_HOTPLUG_CPU register_hotcpu_notifier(&cfs_cpu_notifier); diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index de9fb1433edd..a806aeffe026 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -672,8 +672,8 @@ static int mgc_fs_setup(struct obd_device *obd, struct super_block *sb) if (env == NULL) return -ENOMEM; - /* The mgc fs exclusion sem. Only one fs can be setup at a time. */ - down(&cli->cl_mgc_sem); + /* The mgc fs exclusion mutex. Only one fs can be setup at a time. */ + mutex_lock(&cli->cl_mgc_mutex); cfs_cleanup_group_info(); @@ -727,7 +727,7 @@ out_los: if (rc < 0) { local_oid_storage_fini(env, cli->cl_mgc_los); cli->cl_mgc_los = NULL; - up(&cli->cl_mgc_sem); + mutex_unlock(&cli->cl_mgc_mutex); } out_env: lu_env_fini(env); @@ -759,7 +759,7 @@ static int mgc_fs_cleanup(struct obd_device *obd) unlock: class_decref(obd, "mgc_fs", obd); - up(&cli->cl_mgc_sem); + mutex_unlock(&cli->cl_mgc_mutex); return 0; } -- cgit v1.2.3 From 47a57bde2a79cbf5a7fe106d74b8a19531000413 Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Sun, 27 Apr 2014 13:07:00 -0400 Subject: staging/lustre/clio: replace semaphore with mutex According https://www.kernel.org/doc/Documentation/mutex-design.txt: - the mutex subsystem is slightly faster and has better scalability for contended workloads. In terms of 'ops per CPU cycle', the semaphore kernel performed 551 ops/sec per 1% of CPU time used, while the mutex kernel performed 3825 ops/sec per 1% of CPU time used - it was 6.9 times more efficient. - there are no fastpath tradeoffs, the mutex fastpath is just as tight as the semaphore fastpath. On x86, the locking fastpath is 2 instructions. - 'struct mutex' semantics are well-defined and are enforced if CONFIG_DEBUG_MUTEXES is turned on. Semaphores on the other hand have virtually no debugging code or instrumentation. One more benefit of mutex is optimistic spinning. It try to spin for acquisition when there are no pending waiters and the lock owner is currently running on a (different) CPU. The rationale is that if the lock owner is running, it is likely to release the lock soon. This significantly reduce amount of context switches when locked region is small and we have high contention. Signed-off-by: Dmitry Eremin Reviewed-on: http://review.whamcloud.com/9095 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4257 Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/llite_internal.h | 10 ++++------ drivers/staging/lustre/lustre/llite/llite_lib.c | 12 +++--------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index d2f8250b87f1..f4b15bf84236 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -211,8 +211,7 @@ struct ll_inode_info { /* for non-directory */ struct { - struct semaphore f_size_sem; - void *f_size_sem_owner; + struct mutex f_size_mutex; char *f_symlink_name; __u64 f_maxbytes; /* @@ -249,8 +248,7 @@ struct ll_inode_info { char f_jobid[JOBSTATS_JOBID_SIZE]; } f; -#define lli_size_sem u.f.f_size_sem -#define lli_size_sem_owner u.f.f_size_sem_owner +#define lli_size_mutex u.f.f_size_mutex #define lli_symlink_name u.f.f_symlink_name #define lli_maxbytes u.f.f_maxbytes #define lli_trunc_sem u.f.f_trunc_sem @@ -319,7 +317,7 @@ int ll_xattr_cache_get(struct inode *inode, * Locking to guarantee consistency of non-atomic updates to long long i_size, * consistency between file size and KMS. * - * Implemented by ->lli_size_sem and ->lsm_lock, nested in that order. + * Implemented by ->lli_size_mutex and ->lsm_lock, nested in that order. */ void ll_inode_size_lock(struct inode *inode); @@ -1448,7 +1446,7 @@ static inline void cl_isize_unlock(struct inode *inode) static inline void cl_isize_write_nolock(struct inode *inode, loff_t kms) { - LASSERT(down_trylock(&ll_i2info(inode)->lli_size_sem) != 0); + LASSERT(mutex_is_locked(&ll_i2info(inode)->lli_size_mutex)); i_size_write(inode, kms); } diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index befc30b22bc1..34df5d937007 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -982,8 +982,7 @@ void ll_lli_init(struct ll_inode_info *lli) spin_lock_init(&lli->lli_sa_lock); lli->lli_opendir_pid = 0; } else { - sema_init(&lli->lli_size_sem, 1); - lli->lli_size_sem_owner = NULL; + mutex_init(&lli->lli_size_mutex); lli->lli_symlink_name = NULL; init_rwsem(&lli->lli_trunc_sem); mutex_init(&lli->lli_write_mutex); @@ -1700,10 +1699,7 @@ void ll_inode_size_lock(struct inode *inode) LASSERT(!S_ISDIR(inode->i_mode)); lli = ll_i2info(inode); - LASSERT(lli->lli_size_sem_owner != current); - down(&lli->lli_size_sem); - LASSERT(lli->lli_size_sem_owner == NULL); - lli->lli_size_sem_owner = current; + mutex_lock(&lli->lli_size_mutex); } void ll_inode_size_unlock(struct inode *inode) @@ -1711,9 +1707,7 @@ void ll_inode_size_unlock(struct inode *inode) struct ll_inode_info *lli; lli = ll_i2info(inode); - LASSERT(lli->lli_size_sem_owner == current); - lli->lli_size_sem_owner = NULL; - up(&lli->lli_size_sem); + mutex_unlock(&lli->lli_size_mutex); } void ll_update_inode(struct inode *inode, struct lustre_md *md) -- cgit v1.2.3 From 73b8990780e3aa0a31326fb1ae338646620176d1 Mon Sep 17 00:00:00 2001 From: Ryan Haasken Date: Sun, 27 Apr 2014 13:07:01 -0400 Subject: staging/lustre/llite: Do not rate limit dirty page discard warning Messages which are printed by ll_dirty_page_discard_warn() should not be rate limited. If they are rate limited, some files which may be corrupted on client eviction will not be reported to the user. This patch changes the CWARN to a CDEBUG to disable console message rate limiting for this message. The dirty page discard warnings are already limited on a per-file basis by the function vvp_vmpage_error which calls ll_dirty_page_discard_warn only if the ccc_object's cob_discard_page_warned == 0. Signed-off-by: Ryan Haasken Reviewed-on: http://review.whamcloud.com/9752 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4799 Reviewed-by: Cory Spitz Reviewed-by: Ann Koehler Reviewed-by: Chris Horn Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/llite_lib.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 34df5d937007..dbb14135b47f 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -2456,11 +2456,12 @@ void ll_dirty_page_discard_warn(struct page *page, int ioret) path = ll_d_path(dentry, buf, PAGE_SIZE); } - CWARN("%s: dirty page discard: %s/fid: "DFID"/%s may get corrupted " - "(rc %d)\n", ll_get_fsname(page->mapping->host->i_sb, NULL, 0), - s2lsi(page->mapping->host->i_sb)->lsi_lmd->lmd_dev, - PFID(&obj->cob_header.coh_lu.loh_fid), - (path && !IS_ERR(path)) ? path : "", ioret); + CDEBUG(D_WARNING, + "%s: dirty page discard: %s/fid: "DFID"/%s may get corrupted " + "(rc %d)\n", ll_get_fsname(page->mapping->host->i_sb, NULL, 0), + s2lsi(page->mapping->host->i_sb)->lsi_lmd->lmd_dev, + PFID(&obj->cob_header.coh_lu.loh_fid), + (path && !IS_ERR(path)) ? path : "", ioret); if (dentry != NULL) dput(dentry); -- cgit v1.2.3 From 4de665c1b308c256c0c32f950afe350b8c153583 Mon Sep 17 00:00:00 2001 From: Bob Glossman Date: Sun, 27 Apr 2014 13:07:02 -0400 Subject: staging/lustre/lloop: avoid panic during blockdev_info Change the LL_IOC_LLOOP_INFO ioctl in the lustre lloop device driver to return an error instead of causing panics with LASSERT(). Signed-off-by: Bob Glossman Reviewed-on: http://review.whamcloud.com/9888 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4863 Reviewed-by: Nathaniel Clark Reviewed-by: Andreas Dilger Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/lloop.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/lloop.c b/drivers/staging/lustre/lustre/llite/lloop.c index f78eda235c7a..437adaff0c0a 100644 --- a/drivers/staging/lustre/lustre/llite/lloop.c +++ b/drivers/staging/lustre/lustre/llite/lloop.c @@ -624,7 +624,10 @@ static int lo_ioctl(struct block_device *bdev, fmode_t mode, case LL_IOC_LLOOP_INFO: { struct lu_fid fid; - LASSERT(lo->lo_backing_file != NULL); + if (lo->lo_backing_file == NULL) { + err = -ENOENT; + break; + } if (inode == NULL) inode = lo->lo_backing_file->f_dentry->d_inode; if (lo->lo_state == LLOOP_BOUND) -- cgit v1.2.3 From 8d67c821d96c8cfaa2ae05f346f1b2a07f0c15ec Mon Sep 17 00:00:00 2001 From: Jinshan Xiong Date: Sun, 27 Apr 2014 13:07:03 -0400 Subject: staging/lustre/clio: Solve a race in cl_lock_put It's not atomic to check the last reference and state of cl_lock in cl_lock_put(). This can cause a problem that an using lock is freed, if the process is preempted between atomic_dec_and_test() and (lock->cll_state == CLS_FREEING). This problem can be solved by holding a refcount by coh_locks. In this case, it can be sure that if the lock refcount reaches zero, nobody else can have any chance to use it again. Signed-off-by: Jinshan Xiong Reviewed-on: http://review.whamcloud.com/9881 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4558 Reviewed-by: Bobi Jam Reviewed-by: Lai Siyao Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/cl_lock.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c index 918f433b22d9..f8040a8923b2 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c @@ -533,6 +533,7 @@ static struct cl_lock *cl_lock_find(const struct lu_env *env, spin_lock(&head->coh_lock_guard); ghost = cl_lock_lookup(env, obj, io, need); if (ghost == NULL) { + cl_lock_get_trust(lock); list_add_tail(&lock->cll_linkage, &head->coh_locks); spin_unlock(&head->coh_lock_guard); @@ -791,15 +792,22 @@ static void cl_lock_delete0(const struct lu_env *env, struct cl_lock *lock) LINVRNT(cl_lock_invariant(env, lock)); if (lock->cll_state < CLS_FREEING) { + bool in_cache; + LASSERT(lock->cll_state != CLS_INTRANSIT); cl_lock_state_set(env, lock, CLS_FREEING); head = cl_object_header(lock->cll_descr.cld_obj); spin_lock(&head->coh_lock_guard); - list_del_init(&lock->cll_linkage); + in_cache = !list_empty(&lock->cll_linkage); + if (in_cache) + list_del_init(&lock->cll_linkage); spin_unlock(&head->coh_lock_guard); + if (in_cache) /* coh_locks cache holds a refcount. */ + cl_lock_put(env, lock); + /* * From now on, no new references to this lock can be acquired * by cl_lock_lookup(). -- cgit v1.2.3 From 2c5808367ca0646d013a5f8b6882c737c5b930f9 Mon Sep 17 00:00:00 2001 From: wang di Date: Sun, 27 Apr 2014 13:07:04 -0400 Subject: staging/lustre/mdc: use cl_max_mds_md to pack getattr RPC In some cases, cl_default_mds_easize might be zero, especially for MDC connected to non-MDT0, then mdc might pack getattr RPC with zero eadatasize. If client is trying to access remote striped directory with zero eadatasize, MDT will not return layout information of the striped direcotry, which will be mis-regarded as non-striped directory. So we should use cl_max_mds_easize if cl_default_mds_easize is zero. Signed-off-by: wang di Reviewed-on: http://review.whamcloud.com/9862 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4847 Reviewed-by: Andreas Dilger Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/mdc/mdc_locks.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index 41a18f546dc9..1a8cd98ad6d7 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -462,6 +462,7 @@ static struct ptlrpc_request *mdc_intent_getattr_pack(struct obd_export *exp, OBD_MD_FLRMTPERM : OBD_MD_FLACL); struct ldlm_intent *lit; int rc; + int easize; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_INTENT_GETATTR); @@ -482,12 +483,15 @@ static struct ptlrpc_request *mdc_intent_getattr_pack(struct obd_export *exp, lit = req_capsule_client_get(&req->rq_pill, &RMF_LDLM_INTENT); lit->opc = (__u64)it->it_op; + if (obddev->u.cli.cl_default_mds_easize > 0) + easize = obddev->u.cli.cl_default_mds_easize; + else + easize = obddev->u.cli.cl_max_mds_easize; + /* pack the intended request */ - mdc_getattr_pack(req, valid, it->it_flags, op_data, - obddev->u.cli.cl_default_mds_easize); + mdc_getattr_pack(req, valid, it->it_flags, op_data, easize); - req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER, - obddev->u.cli.cl_default_mds_easize); + req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER, easize); if (client_is_remote(exp)) req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER, sizeof(struct mdt_remote_perm)); -- cgit v1.2.3 From 2d95f10e50da3eadd3f0a54f8b4b03db37ce879c Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Sun, 27 Apr 2014 13:07:05 -0400 Subject: staging/lustre/llite: remove dead code In llite remove unused declarations, parameters, types, and unused, get-only, or set-only structure members. Add static and const qualifiers to declarations where possible. Signed-off-by: John L. Hammond Reviewed-on: http://review.whamcloud.com/9767 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2675 Reviewed-by: Lai Siyao Reviewed-by: Jinshan Xiong Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lclient/lcommon_cl.c | 4 +- drivers/staging/lustre/lustre/llite/dcache.c | 26 ++-- drivers/staging/lustre/lustre/llite/dir.c | 8 +- drivers/staging/lustre/lustre/llite/file.c | 89 ++++++------- drivers/staging/lustre/lustre/llite/llite_capa.c | 4 +- .../staging/lustre/lustre/llite/llite_internal.h | 138 ++++----------------- drivers/staging/lustre/lustre/llite/llite_lib.c | 64 +--------- drivers/staging/lustre/lustre/llite/llite_mmap.c | 23 +--- drivers/staging/lustre/lustre/llite/lloop.c | 5 - drivers/staging/lustre/lustre/llite/lproc_llite.c | 4 +- drivers/staging/lustre/lustre/llite/namei.c | 40 ++---- drivers/staging/lustre/lustre/llite/remote_perm.c | 2 +- drivers/staging/lustre/lustre/llite/rw.c | 7 -- drivers/staging/lustre/lustre/llite/rw26.c | 15 +-- drivers/staging/lustre/lustre/llite/statahead.c | 8 -- drivers/staging/lustre/lustre/llite/super25.c | 7 +- drivers/staging/lustre/lustre/llite/vvp_dev.c | 6 +- drivers/staging/lustre/lustre/llite/vvp_internal.h | 2 +- drivers/staging/lustre/lustre/llite/vvp_io.c | 2 +- drivers/staging/lustre/lustre/llite/vvp_object.c | 4 +- drivers/staging/lustre/lustre/llite/xattr_cache.c | 2 +- 21 files changed, 125 insertions(+), 335 deletions(-) diff --git a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c index 12812fcc70b1..dc24cfa58037 100644 --- a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c +++ b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c @@ -63,7 +63,7 @@ #include "../llite/llite_internal.h" -const struct cl_req_operations ccc_req_ops; +static const struct cl_req_operations ccc_req_ops; /* * ccc_ prefix stands for "Common Client Code". @@ -962,7 +962,7 @@ void ccc_req_attr_set(const struct lu_env *env, JOBSTATS_JOBID_SIZE); } -const struct cl_req_operations ccc_req_ops = { +static const struct cl_req_operations ccc_req_ops = { .cro_attr_set = ccc_req_attr_set, .cro_completion = ccc_req_completion }; diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c index 8b5508086174..7d520d8f4a69 100644 --- a/drivers/staging/lustre/lustre/llite/dcache.c +++ b/drivers/staging/lustre/lustre/llite/dcache.c @@ -69,8 +69,7 @@ static void ll_release(struct dentry *de) ll_intent_release(lld->lld_it); OBD_FREE(lld->lld_it, sizeof(*lld->lld_it)); } - LASSERT(lld->lld_cwd_count == 0); - LASSERT(lld->lld_mnt_count == 0); + de->d_fsdata = NULL; call_rcu(&lld->lld_rcu_head, free_dentry_data); } @@ -82,8 +81,9 @@ static void ll_release(struct dentry *de) * an AST before calling d_revalidate_it(). The dentry still exists (marked * INVALID) so d_lookup() matches it, but we have no lock on it (so * lock_match() fails) and we spin around real_lookup(). */ -int ll_dcompare(const struct dentry *parent, const struct dentry *dentry, - unsigned int len, const char *str, const struct qstr *name) +static int ll_dcompare(const struct dentry *parent, const struct dentry *dentry, + unsigned int len, const char *str, + const struct qstr *name) { if (len != name->len) return 1; @@ -238,7 +238,8 @@ void ll_intent_release(struct lookup_intent *it) ll_intent_drop_lock(it); /* We are still holding extra reference on a request, need to free it */ if (it_disposition(it, DISP_ENQ_OPEN_REF)) - ptlrpc_req_finished(it->d.lustre.it_data); /* ll_file_open */ + ptlrpc_req_finished(it->d.lustre.it_data); /* ll_file_open */ + if (it_disposition(it, DISP_ENQ_CREATE_REF)) /* create rec */ ptlrpc_req_finished(it->d.lustre.it_data); @@ -316,15 +317,6 @@ void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry) } } -void ll_frob_intent(struct lookup_intent **itp, struct lookup_intent *deft) -{ - struct lookup_intent *it = *itp; - - if (!it || it->it_op == IT_GETXATTR) - it = *itp = deft; - -} - static int ll_revalidate_dentry(struct dentry *dentry, unsigned int lookup_flags) { @@ -356,7 +348,7 @@ static int ll_revalidate_dentry(struct dentry *dentry, /* * Always trust cached dentries. Update statahead window if necessary. */ -int ll_revalidate_nd(struct dentry *dentry, unsigned int flags) +static int ll_revalidate_nd(struct dentry *dentry, unsigned int flags) { int rc; @@ -368,7 +360,7 @@ int ll_revalidate_nd(struct dentry *dentry, unsigned int flags) } -void ll_d_iput(struct dentry *de, struct inode *inode) +static void ll_d_iput(struct dentry *de, struct inode *inode) { LASSERT(inode); if (!find_cbdata(inode)) @@ -376,7 +368,7 @@ void ll_d_iput(struct dentry *de, struct inode *inode) iput(inode); } -struct dentry_operations ll_d_ops = { +const struct dentry_operations ll_d_ops = { .d_revalidate = ll_revalidate_nd, .d_release = ll_release, .d_delete = ll_ddelete, diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index f7d306520123..ae6f61aa4da6 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -632,7 +632,7 @@ out: return rc; } -int ll_send_mgc_param(struct obd_export *mgc, char *string) +static int ll_send_mgc_param(struct obd_export *mgc, char *string) { struct mgs_send_param *msp; int rc = 0; @@ -1964,17 +1964,17 @@ out: return ret; } -int ll_dir_open(struct inode *inode, struct file *file) +static int ll_dir_open(struct inode *inode, struct file *file) { return ll_file_open(inode, file); } -int ll_dir_release(struct inode *inode, struct file *file) +static int ll_dir_release(struct inode *inode, struct file *file) { return ll_file_release(inode, file); } -struct file_operations ll_dir_operations = { +const struct file_operations ll_dir_operations = { .llseek = ll_dir_seek, .open = ll_dir_open, .release = ll_dir_release, diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index e3bc2b0173ca..4d8f6a0144bb 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -50,7 +50,17 @@ #include "cl_object.h" -struct ll_file_data *ll_file_data_get(void) +static int +ll_put_grouplock(struct inode *inode, struct file *file, unsigned long arg); + +static int ll_lease_close(struct obd_client_handle *och, struct inode *inode, + bool *lease_broken); + +static enum llioc_iter +ll_iocontrol_call(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg, int *rcp); + +static struct ll_file_data *ll_file_data_get(void) { struct ll_file_data *fd; @@ -247,8 +257,8 @@ int ll_md_real_close(struct inode *inode, fmode_t fmode) return rc; } -int ll_md_close(struct obd_export *md_exp, struct inode *inode, - struct file *file) +static int ll_md_close(struct obd_export *md_exp, struct inode *inode, + struct file *file) { struct ll_file_data *fd = LUSTRE_FPRIVATE(file); struct ll_inode_info *lli = ll_i2info(inode); @@ -482,8 +492,8 @@ static int ll_och_fill(struct obd_export *md_exp, struct lookup_intent *it, return md_set_open_replay_data(md_exp, och, it); } -int ll_local_open(struct file *file, struct lookup_intent *it, - struct ll_file_data *fd, struct obd_client_handle *och) +static int ll_local_open(struct file *file, struct lookup_intent *it, + struct ll_file_data *fd, struct obd_client_handle *och) { struct inode *inode = file->f_dentry->d_inode; struct ll_inode_info *lli = ll_i2info(inode); @@ -733,8 +743,9 @@ static int ll_md_blocking_lease_ast(struct ldlm_lock *lock, /** * Acquire a lease and open the file. */ -struct obd_client_handle *ll_lease_open(struct inode *inode, struct file *file, - fmode_t fmode, __u64 open_flags) +static struct obd_client_handle * +ll_lease_open(struct inode *inode, struct file *file, fmode_t fmode, + __u64 open_flags) { struct lookup_intent it = { .it_op = IT_OPEN }; struct ll_sb_info *sbi = ll_i2sbi(inode); @@ -862,14 +873,13 @@ out: OBD_FREE_PTR(och); return ERR_PTR(rc); } -EXPORT_SYMBOL(ll_lease_open); /** * Release lease and close the file. * It will check if the lease has ever broken. */ -int ll_lease_close(struct obd_client_handle *och, struct inode *inode, - bool *lease_broken) +static int ll_lease_close(struct obd_client_handle *och, struct inode *inode, + bool *lease_broken) { struct ldlm_lock *lock; bool cancelled = true; @@ -895,7 +905,6 @@ int ll_lease_close(struct obd_client_handle *och, struct inode *inode, NULL); return rc; } -EXPORT_SYMBOL(ll_lease_close); /* Fills the obdo with the attributes for the lsm */ static int ll_lsm_getattr(struct lov_stripe_md *lsm, struct obd_export *exp, @@ -1590,7 +1599,8 @@ static int ll_lov_getstripe(struct inode *inode, unsigned long arg) return rc; } -int ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg) +static int +ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg) { struct ll_inode_info *lli = ll_i2info(inode); struct ll_file_data *fd = LUSTRE_FPRIVATE(file); @@ -1710,8 +1720,8 @@ out: * Get size for inode for which FIEMAP mapping is requested. * Make the FIEMAP get_info call and returns the result. */ -int ll_do_fiemap(struct inode *inode, struct ll_user_fiemap *fiemap, - int num_bytes) +static int ll_do_fiemap(struct inode *inode, struct ll_user_fiemap *fiemap, + int num_bytes) { struct obd_export *exp = ll_i2dtexp(inode); struct lov_stripe_md *lsm = NULL; @@ -2190,7 +2200,8 @@ out: return rc; } -long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +static long +ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { struct inode *inode = file->f_dentry->d_inode; struct ll_file_data *fd = LUSTRE_FPRIVATE(file); @@ -2509,7 +2520,7 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } -loff_t ll_file_seek(struct file *file, loff_t offset, int origin) +static loff_t ll_file_seek(struct file *file, loff_t offset, int origin) { struct inode *inode = file->f_dentry->d_inode; loff_t retval, eof = 0; @@ -2533,7 +2544,7 @@ loff_t ll_file_seek(struct file *file, loff_t offset, int origin) return retval; } -int ll_flush(struct file *file, fl_owner_t id) +static int ll_flush(struct file *file, fl_owner_t id) { struct inode *inode = file->f_dentry->d_inode; struct ll_inode_info *lli = ll_i2info(inode); @@ -2670,7 +2681,8 @@ int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync) return rc; } -int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) +static int +ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) { struct inode *inode = file->f_dentry->d_inode; struct ll_sb_info *sbi = ll_i2sbi(inode); @@ -2799,7 +2811,8 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) return rc; } -int ll_file_noflock(struct file *file, int cmd, struct file_lock *file_lock) +static int +ll_file_noflock(struct file *file, int cmd, struct file_lock *file_lock) { return -ENOSYS; } @@ -2891,8 +2904,7 @@ static int ll_inode_revalidate_fini(struct inode *inode, int rc) return rc; } -int __ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, - __u64 ibits) +static int __ll_inode_revalidate(struct dentry *dentry, __u64 ibits) { struct inode *inode = dentry->d_inode; struct ptlrpc_request *req = NULL; @@ -2987,13 +2999,12 @@ out: return rc; } -int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, - __u64 ibits) +static int ll_inode_revalidate(struct dentry *dentry, __u64 ibits) { struct inode *inode = dentry->d_inode; int rc; - rc = __ll_inode_revalidate_it(dentry, it, ibits); + rc = __ll_inode_revalidate(dentry, ibits); if (rc != 0) return rc; @@ -3016,16 +3027,15 @@ int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, return rc; } -int ll_getattr_it(struct vfsmount *mnt, struct dentry *de, - struct lookup_intent *it, struct kstat *stat) +int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat) { struct inode *inode = de->d_inode; struct ll_sb_info *sbi = ll_i2sbi(inode); struct ll_inode_info *lli = ll_i2info(inode); int res = 0; - res = ll_inode_revalidate_it(de, it, MDS_INODELOCK_UPDATE | - MDS_INODELOCK_LOOKUP); + res = ll_inode_revalidate(de, MDS_INODELOCK_UPDATE | + MDS_INODELOCK_LOOKUP); ll_stats_ops_tally(sbi, LPROC_LL_GETATTR, 1); if (res) @@ -3051,15 +3061,9 @@ int ll_getattr_it(struct vfsmount *mnt, struct dentry *de, return 0; } -int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat) -{ - struct lookup_intent it = { .it_op = IT_GETATTR }; - - return ll_getattr_it(mnt, de, &it, stat); -} -int ll_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, - __u64 start, __u64 len) +static int ll_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, + __u64 start, __u64 len) { int rc; size_t num_bytes; @@ -3091,7 +3095,7 @@ int ll_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, return rc; } -struct posix_acl * ll_get_acl(struct inode *inode, int type) +struct posix_acl *ll_get_acl(struct inode *inode, int type) { struct ll_inode_info *lli = ll_i2info(inode); struct posix_acl *acl = NULL; @@ -3118,10 +3122,8 @@ int ll_inode_permission(struct inode *inode, int mask) * need to do it before permission check. */ if (inode == inode->i_sb->s_root->d_inode) { - struct lookup_intent it = { .it_op = IT_LOOKUP }; - - rc = __ll_inode_revalidate_it(inode->i_sb->s_root, &it, - MDS_INODELOCK_LOOKUP); + rc = __ll_inode_revalidate(inode->i_sb->s_root, + MDS_INODELOCK_LOOKUP); if (rc) return rc; } @@ -3273,8 +3275,9 @@ void ll_iocontrol_unregister(void *magic) EXPORT_SYMBOL(ll_iocontrol_register); EXPORT_SYMBOL(ll_iocontrol_unregister); -enum llioc_iter ll_iocontrol_call(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg, int *rcp) +static enum llioc_iter +ll_iocontrol_call(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg, int *rcp) { enum llioc_iter ret = LLIOC_CONT; struct llioc_data *data; diff --git a/drivers/staging/lustre/lustre/llite/llite_capa.c b/drivers/staging/lustre/lustre/llite/llite_capa.c index edd512b20ee3..d06d0b1ab08a 100644 --- a/drivers/staging/lustre/lustre/llite/llite_capa.c +++ b/drivers/staging/lustre/lustre/llite/llite_capa.c @@ -68,6 +68,8 @@ static unsigned long long ll_capa_renewal_noent = 0; static unsigned long long ll_capa_renewal_failed = 0; static unsigned long long ll_capa_renewal_retries = 0; +static int ll_update_capa(struct obd_capa *ocapa, struct lustre_capa *capa); + static inline void update_capa_timer(struct obd_capa *ocapa, cfs_time_t expiry) { if (cfs_time_before(expiry, ll_capa_timer.expires) || @@ -515,7 +517,7 @@ static inline void delay_capa_renew(struct obd_capa *oc, cfs_time_t delay) oc->c_expiry = cfs_time_add(oc->c_expiry, cfs_time_seconds(delay)); } -int ll_update_capa(struct obd_capa *ocapa, struct lustre_capa *capa) +static int ll_update_capa(struct obd_capa *ocapa, struct lustre_capa *capa) { struct inode *inode = ocapa->u.cli.inode; int rc = 0; diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index f4b15bf84236..dde7632ba01f 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -71,10 +71,6 @@ #define LUSTRE_FPRIVATE(file) ((file)->private_data) struct ll_dentry_data { - int lld_cwd_count; - int lld_mnt_count; - struct obd_client_handle lld_cwd_och; - struct obd_client_handle lld_mnt_och; struct lookup_intent *lld_it; unsigned int lld_sa_generation; unsigned int lld_invalid:1; @@ -83,8 +79,6 @@ struct ll_dentry_data { #define ll_d2d(de) ((struct ll_dentry_data*)((de)->d_fsdata)) -extern struct file_operations ll_pgcache_seq_fops; - #define LLI_INODE_MAGIC 0x111d0de5 #define LLI_INODE_DEAD 0xdeadd00d @@ -120,16 +114,12 @@ enum lli_flags { /* Sizeon-on-MDS attributes are changed. An attribute update needs to * be sent to MDS. */ LLIF_SOM_DIRTY = (1 << 3), - /* File is contented */ - LLIF_CONTENDED = (1 << 4), - /* Truncate uses server lock for this file */ - LLIF_SRVLOCK = (1 << 5), /* File data is modified. */ - LLIF_DATA_MODIFIED = (1 << 6), + LLIF_DATA_MODIFIED = (1 << 4), /* File is being restored */ - LLIF_FILE_RESTORING = (1 << 7), + LLIF_FILE_RESTORING = (1 << 5), /* Xattr cache is attached to the file */ - LLIF_XATTR_CACHE = (1 << 8), + LLIF_XATTR_CACHE = (1 << 6), }; struct ll_inode_info { @@ -194,7 +184,6 @@ struct ll_inode_info { * cleanup the dir readahead. */ void *d_opendir_key; struct ll_statahead_info *d_sai; - struct posix_acl *d_def_acl; /* protect statahead stuff. */ spinlock_t d_sa_lock; /* "opendir_pid" is the token when lookup/revalid @@ -205,7 +194,6 @@ struct ll_inode_info { #define lli_readdir_mutex u.d.d_readdir_mutex #define lli_opendir_key u.d.d_opendir_key #define lli_sai u.d.d_sai -#define lli_def_acl u.d.d_def_acl #define lli_sa_lock u.d.d_sa_lock #define lli_opendir_pid u.d.d_opendir_pid @@ -232,11 +220,6 @@ struct ll_inode_info { /* for writepage() only to communicate to fsync */ int f_async_rc; - /* volatile file criteria is based on file name, this - * flag is used to keep the test result, so the strcmp - * is done only once - */ - bool f_volatile; /* * whenever a process try to read/write the file, the * jobid of the process will be saved here, and it'll @@ -259,7 +242,6 @@ struct ll_inode_info { #define lli_agl_index u.f.f_agl_index #define lli_async_rc u.f.f_async_rc #define lli_jobid u.f.f_jobid -#define lli_volatile u.f.f_volatile } u; @@ -459,10 +441,6 @@ enum stats_track_type { "xattr", \ } -/* default value for ll_sb_info->contention_time */ -#define SBI_DEFAULT_CONTENTION_SECONDS 60 -/* default value for lockless_truncate_enable */ -#define SBI_DEFAULT_LOCKLESS_TRUNCATE_ENABLE 1 #define RCE_HASHES 32 struct rmtacl_ctl_entry { @@ -673,12 +651,6 @@ static inline struct inode *ll_info2i(struct ll_inode_info *lli) return &lli->lli_vfs_inode; } -struct it_cb_data { - struct inode *icbd_parent; - struct dentry **icbd_childp; - obd_id hash; -}; - __u32 ll_i2suppgid(struct inode *i); void ll_i2gids(__u32 *suppgids, struct inode *i1,struct inode *i2); @@ -686,21 +658,13 @@ static inline int ll_need_32bit_api(struct ll_sb_info *sbi) { #if BITS_PER_LONG == 32 return 1; +#elif defined(CONFIG_COMPAT) + return unlikely(is_compat_task() || (sbi->ll_flags & LL_SBI_32BIT_API)); #else - return unlikely( -#ifdef CONFIG_COMPAT - is_compat_task() || -#endif - (sbi->ll_flags & LL_SBI_32BIT_API) - ); + return unlikely(sbi->ll_flags & LL_SBI_32BIT_API); #endif } -#define LLAP_MAGIC 98764321 - -extern struct kmem_cache *ll_async_page_slab; -extern size_t ll_async_page_slab_size; - void ll_ra_read_in(struct file *f, struct ll_ra_read *rar); void ll_ra_read_ex(struct file *f, struct ll_ra_read *rar); struct ll_ra_read *ll_ra_read_get(struct file *f); @@ -733,14 +697,16 @@ static inline void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, /* llite/dir.c */ void ll_release_page(struct page *page, int remove); -extern struct file_operations ll_dir_operations; -extern struct inode_operations ll_dir_inode_operations; +extern const struct file_operations ll_dir_operations; +extern const struct inode_operations ll_dir_inode_operations; struct page *ll_get_dir_page(struct inode *dir, __u64 hash, struct ll_dir_chain *chain); int ll_dir_read(struct inode *inode, struct dir_context *ctx); int ll_get_mdt_idx(struct inode *inode); /* llite/namei.c */ +extern const struct inode_operations ll_special_inode_operations; + int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir); struct inode *ll_iget(struct super_block *sb, ino_t hash, @@ -755,43 +721,34 @@ int ll_prepare_write(struct file *, struct page *, unsigned from, unsigned to); int ll_commit_write(struct file *, struct page *, unsigned from, unsigned to); int ll_writepage(struct page *page, struct writeback_control *wbc); int ll_writepages(struct address_space *, struct writeback_control *wbc); -void ll_removepage(struct page *page); int ll_readpage(struct file *file, struct page *page); void ll_readahead_init(struct inode *inode, struct ll_readahead_state *ras); -int ll_file_punch(struct inode *, loff_t, int); -ssize_t ll_file_lockless_io(struct file *, char *, size_t, loff_t *, int); -void ll_clear_file_contended(struct inode*); -int ll_sync_page_range(struct inode *, struct address_space *, loff_t, size_t); int ll_readahead(const struct lu_env *env, struct cl_io *io, struct ll_readahead_state *ras, struct address_space *mapping, struct cl_page_list *queue, int flags); +#ifndef MS_HAS_NEW_AOPS +extern const struct address_space_operations ll_aops; +#else +extern const struct address_space_operations_ext ll_aops; +#endif + /* llite/file.c */ extern struct file_operations ll_file_operations; extern struct file_operations ll_file_operations_flock; extern struct file_operations ll_file_operations_noflock; extern struct inode_operations ll_file_inode_operations; -extern int ll_inode_revalidate_it(struct dentry *, struct lookup_intent *, - __u64); extern int ll_have_md_lock(struct inode *inode, __u64 *bits, ldlm_mode_t l_req_mode); extern ldlm_mode_t ll_take_md_lock(struct inode *inode, __u64 bits, struct lustre_handle *lockh, __u64 flags, ldlm_mode_t mode); -int __ll_inode_revalidate_it(struct dentry *, struct lookup_intent *, - __u64 bits); -int ll_revalidate_nd(struct dentry *dentry, unsigned int flags); int ll_file_open(struct inode *inode, struct file *file); int ll_file_release(struct inode *inode, struct file *file); int ll_glimpse_ioctl(struct ll_sb_info *sbi, struct lov_stripe_md *lsm, lstat_t *st); void ll_ioepoch_open(struct ll_inode_info *lli, __u64 ioepoch); -int ll_local_open(struct file *file, - struct lookup_intent *it, struct ll_file_data *fd, - struct obd_client_handle *och); int ll_release_openhandle(struct dentry *, struct lookup_intent *); -int ll_md_close(struct obd_export *md_exp, struct inode *inode, - struct file *file); int ll_md_real_close(struct inode *inode, fmode_t fmode); void ll_ioepoch_close(struct inode *inode, struct md_op_data *op_data, struct obd_client_handle **och, unsigned long flags); @@ -799,15 +756,10 @@ void ll_done_writing_attr(struct inode *inode, struct md_op_data *op_data); int ll_som_update(struct inode *inode, struct md_op_data *op_data); int ll_inode_getattr(struct inode *inode, struct obdo *obdo, __u64 ioepoch, int sync); -int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data, - struct md_open_data **mod); void ll_pack_inode2opdata(struct inode *inode, struct md_op_data *op_data, struct lustre_handle *fh); -int ll_getattr_it(struct vfsmount *mnt, struct dentry *de, - struct lookup_intent *it, struct kstat *stat); int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat); -struct ll_file_data *ll_file_data_get(void); -struct posix_acl * ll_get_acl(struct inode *inode, int type); +struct posix_acl *ll_get_acl(struct inode *inode, int type); int ll_inode_permission(struct inode *inode, int mask); @@ -822,44 +774,30 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump, int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmmp, int *lmm_size, struct ptlrpc_request **request); int ll_fsync(struct file *file, loff_t start, loff_t end, int data); -int ll_do_fiemap(struct inode *inode, struct ll_user_fiemap *fiemap, - int num_bytes); int ll_merge_lvb(const struct lu_env *env, struct inode *inode); -int ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg); -int ll_put_grouplock(struct inode *inode, struct file *file, unsigned long arg); int ll_fid2path(struct inode *inode, void *arg); int ll_data_version(struct inode *inode, __u64 *data_version, int extent_lock); int ll_hsm_release(struct inode *inode); -struct obd_client_handle *ll_lease_open(struct inode *inode, struct file *file, - fmode_t mode, __u64 flags); -int ll_lease_close(struct obd_client_handle *och, struct inode *inode, - bool *lease_broken); - /* llite/dcache.c */ int ll_d_init(struct dentry *de); -extern struct dentry_operations ll_d_ops; +extern const struct dentry_operations ll_d_ops; void ll_intent_drop_lock(struct lookup_intent *); void ll_intent_release(struct lookup_intent *); void ll_invalidate_aliases(struct inode *); -void ll_frob_intent(struct lookup_intent **itp, struct lookup_intent *deft); void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry); -int ll_dcompare(const struct dentry *parent, const struct dentry *dentry, - unsigned int len, const char *str, const struct qstr *d_name); int ll_revalidate_it_finish(struct ptlrpc_request *request, struct lookup_intent *it, struct dentry *de); /* llite/llite_lib.c */ extern struct super_operations lustre_super_operations; -char *ll_read_opt(const char *opt, char *data); void ll_lli_init(struct ll_inode_info *lli); int ll_fill_super(struct super_block *sb, struct vfsmount *mnt); void ll_put_super(struct super_block *sb); void ll_kill_super(struct super_block *sb); struct inode *ll_inode_from_resource_lock(struct ldlm_lock *lock); -struct inode *ll_inode_from_lock(struct ldlm_lock *lock); void ll_clear_inode(struct inode *inode); int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import); int ll_setattr(struct dentry *de, struct iattr *attr); @@ -879,7 +817,6 @@ void ll_dirty_page_discard_warn(struct page *page, int ioret); int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req, struct super_block *, struct lookup_intent *); void lustre_dump_dentry(struct dentry *, int recur); -void lustre_dump_inode(struct inode *); int ll_obd_statfs(struct inode *inode, void *arg); int ll_get_max_mdsize(struct ll_sb_info *sbi, int *max_mdsize); int ll_get_default_mdsize(struct ll_sb_info *sbi, int *default_mdsize); @@ -901,15 +838,6 @@ void get_uuid2fsid(const char *name, int len, __kernel_fsid_t *fsid); struct inode *search_inode_for_lustre(struct super_block *sb, const struct lu_fid *fid); -/* llite/special.c */ -extern struct inode_operations ll_special_inode_operations; -extern struct file_operations ll_special_chr_inode_fops; -extern struct file_operations ll_special_chr_file_fops; -extern struct file_operations ll_special_blk_inode_fops; -extern struct file_operations ll_special_fifo_inode_fops; -extern struct file_operations ll_special_fifo_file_fops; -extern struct file_operations ll_special_sock_inode_fops; - /* llite/symlink.c */ extern struct inode_operations ll_fast_symlink_inode_operations; @@ -977,11 +905,6 @@ struct vvp_io { * Set when cui_bead has been initialized. */ int cui_ra_window_set; - /** - * Partially truncated page, that vvp_io_trunc_start() keeps locked - * across truncate. - */ - struct cl_page *cui_partpage; }; /** @@ -1010,12 +933,9 @@ struct ll_cl_context { struct cl_page *lcc_page; struct lu_env *lcc_env; int lcc_refcheck; - int lcc_created; }; struct vvp_thread_info { - struct ost_lvb vti_lvb; - struct cl_2queue vti_queue; struct iovec vti_local_iov; struct vvp_io_args vti_args; struct ra_io_arg vti_ria; @@ -1062,25 +982,17 @@ static inline struct vvp_io *vvp_env_io(const struct lu_env *env) return &vvp_env_session(env)->vs_ios; } +int vvp_global_init(void); +void vvp_global_fini(void); + void ll_queue_done_writing(struct inode *inode, unsigned long flags); void ll_close_thread_shutdown(struct ll_close_queue *lcq); int ll_close_thread_start(struct ll_close_queue **lcq_ret); /* llite/llite_mmap.c */ -typedef struct rb_root rb_root_t; -typedef struct rb_node rb_node_t; - -struct ll_lock_tree_node; -struct ll_lock_tree { - rb_root_t lt_root; - struct list_head lt_locked_list; - struct ll_file_data *lt_fd; -}; int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last); int ll_file_mmap(struct file * file, struct vm_area_struct * vma); -struct ll_lock_tree_node * ll_node_from_inode(struct inode *inode, __u64 start, - __u64 end, ldlm_mode_t mode); void policy_from_vma(ldlm_policy_data_t *policy, struct vm_area_struct *vma, unsigned long addr, size_t count); struct vm_area_struct *our_vma(struct mm_struct *mm, unsigned long addr, @@ -1164,7 +1076,6 @@ int ll_removexattr(struct dentry *dentry, const char *name); extern struct kmem_cache *ll_remote_perm_cachep; extern struct kmem_cache *ll_rmtperm_hash_cachep; -struct hlist_head *alloc_rmtperm_hash(void); void free_rmtperm_hash(struct hlist_head *hash); int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm); int lustre_check_remote_perm(struct inode *inode, int mask); @@ -1177,7 +1088,6 @@ void ll_capa_thread_stop(void); void ll_capa_timer_callback(unsigned long unused); struct obd_capa *ll_add_capa(struct inode *inode, struct obd_capa *ocapa); -int ll_update_capa(struct obd_capa *ocapa, struct lustre_capa *capa); void ll_capa_open(struct inode *inode); void ll_capa_close(struct inode *inode); @@ -1197,14 +1107,12 @@ extern struct lu_device_type vvp_device_type; */ int cl_sb_init(struct super_block *sb); int cl_sb_fini(struct super_block *sb); -enum cl_lock_mode vvp_mode_from_vma(struct vm_area_struct *vma); void ll_io_init(struct cl_io *io, const struct file *file, int write); void ras_update(struct ll_sb_info *sbi, struct inode *inode, struct ll_readahead_state *ras, unsigned long index, unsigned hit); void ll_ra_count_put(struct ll_sb_info *sbi, unsigned long len); -int ll_is_file_contended(struct file *file); void ll_ra_stats_inc(struct address_space *mapping, enum ra_stat which); /* llite/llite_rmtacl.c */ @@ -1277,7 +1185,6 @@ struct ll_statahead_info { unsigned int sai_skip_hidden;/* skipped hidden dentry count */ unsigned int sai_ls_all:1, /* "ls -al", do stat-ahead for * hidden entries */ - sai_in_readpage:1,/* statahead is in readdir()*/ sai_agl_valid:1;/* AGL is valid for the dir */ wait_queue_head_t sai_waitq; /* stat-ahead wait queue */ struct ptlrpc_thread sai_thread; /* stat-ahead thread */ @@ -1402,9 +1309,6 @@ typedef enum llioc_iter (*llioc_callback_t)(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg, void *magic, int *rcp); -enum llioc_iter ll_iocontrol_call(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg, int *rcp); - /* export functions */ /* Register ioctl block dynamatically for a regular file. * diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index dbb14135b47f..7372986ac145 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -58,14 +58,8 @@ struct kmem_cache *ll_file_data_slab; struct proc_dir_entry *proc_lustre_fs_root; -LIST_HEAD(ll_super_blocks); -DEFINE_SPINLOCK(ll_sb_lock); - -#ifndef MS_HAS_NEW_AOPS -extern struct address_space_operations ll_aops; -#else -extern struct address_space_operations_ext ll_aops; -#endif +static LIST_HEAD(ll_super_blocks); +static DEFINE_SPINLOCK(ll_sb_lock); #ifndef log2 #define log2(n) ffz(~(n)) @@ -143,7 +137,7 @@ static struct ll_sb_info *ll_init_sbi(void) return sbi; } -void ll_free_sbi(struct super_block *sb) +static void ll_free_sbi(struct super_block *sb) { struct ll_sb_info *sbi = ll_s2sbi(sb); @@ -673,7 +667,7 @@ int ll_get_default_cookiesize(struct ll_sb_info *sbi, int *lmmsize) return rc; } -void ll_dump_inode(struct inode *inode) +static void ll_dump_inode(struct inode *inode) { struct ll_d_hlist_node *tmp; int dentry_count = 0; @@ -716,7 +710,7 @@ void lustre_dump_dentry(struct dentry *dentry, int recur) } } -void client_common_put_super(struct super_block *sb) +static void client_common_put_super(struct super_block *sb) { struct ll_sb_info *sbi = ll_s2sbi(sb); @@ -765,30 +759,6 @@ void ll_kill_super(struct super_block *sb) } } -char *ll_read_opt(const char *opt, char *data) -{ - char *value; - char *retval; - - CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data); - if (strncmp(opt, data, strlen(opt))) - return NULL; - value = strchr(data, '='); - if (value == NULL) - return NULL; - - value++; - OBD_ALLOC(retval, strlen(value) + 1); - if (!retval) { - CERROR("out of memory!\n"); - return NULL; - } - - memcpy(retval, value, strlen(value)+1); - CDEBUG(D_SUPER, "Assigned option: %s, value %s\n", opt, retval); - return retval; -} - static inline int ll_set_opt(const char *opt, char *data, int fl) { if (strncmp(opt, data, strlen(opt)) != 0) @@ -978,7 +948,6 @@ void ll_lli_init(struct ll_inode_info *lli) mutex_init(&lli->lli_readdir_mutex); lli->lli_opendir_key = NULL; lli->lli_sai = NULL; - lli->lli_def_acl = NULL; spin_lock_init(&lli->lli_sa_lock); lli->lli_opendir_pid = 0; } else { @@ -991,7 +960,6 @@ void ll_lli_init(struct ll_inode_info *lli) INIT_LIST_HEAD(&lli->lli_agl_list); lli->lli_agl_index = 0; lli->lli_async_rc = 0; - lli->lli_volatile = false; } mutex_init(&lli->lli_layout_mutex); } @@ -1190,28 +1158,6 @@ struct inode *ll_inode_from_resource_lock(struct ldlm_lock *lock) return inode; } -struct inode *ll_inode_from_lock(struct ldlm_lock *lock) -{ - struct inode *inode = NULL; - /* NOTE: we depend on atomic igrab() -bzzz */ - lock_res_and_lock(lock); - if (lock->l_ast_data) { - struct ll_inode_info *lli = ll_i2info(lock->l_ast_data); - if (lli->lli_inode_magic == LLI_INODE_MAGIC) { - inode = igrab(lock->l_ast_data); - } else { - inode = lock->l_ast_data; - LDLM_DEBUG_LIMIT(inode->i_state & I_FREEING ? D_INFO : - D_WARNING, lock, "l_ast_data %p is " - "bogus: magic %08x", lock->l_ast_data, - lli->lli_inode_magic); - inode = NULL; - } - } - unlock_res_and_lock(lock); - return inode; -} - void ll_clear_inode(struct inode *inode) { struct ll_inode_info *lli = ll_i2info(inode); diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c index 90b2c0d275f9..426c73961665 100644 --- a/drivers/staging/lustre/lustre/llite/llite_mmap.c +++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c @@ -51,10 +51,7 @@ #include "llite_internal.h" #include -struct page *ll_nopage(struct vm_area_struct *vma, unsigned long address, - int *type); - -static struct vm_operations_struct ll_file_vm_ops; +static const struct vm_operations_struct ll_file_vm_ops; void policy_from_vma(ldlm_policy_data_t *policy, struct vm_area_struct *vma, unsigned long addr, @@ -97,10 +94,10 @@ struct vm_area_struct *our_vma(struct mm_struct *mm, unsigned long addr, * \retval EINVAL if env can't allocated * \return other error codes from cl_io_init. */ -struct cl_io *ll_fault_io_init(struct vm_area_struct *vma, - struct lu_env **env_ret, - struct cl_env_nest *nest, - pgoff_t index, unsigned long *ra_flags) +static struct cl_io * +ll_fault_io_init(struct vm_area_struct *vma, struct lu_env **env_ret, + struct cl_env_nest *nest, pgoff_t index, + unsigned long *ra_flags) { struct file *file = vma->vm_file; struct inode *inode = file->f_dentry->d_inode; @@ -446,14 +443,6 @@ static void ll_vm_close(struct vm_area_struct *vma) LASSERT(atomic_read(&vob->cob_mmap_cnt) >= 0); } - -/* return the user space pointer that maps to a file offset via a vma */ -static inline unsigned long file_to_user(struct vm_area_struct *vma, __u64 byte) -{ - return vma->vm_start + (byte - ((__u64)vma->vm_pgoff << PAGE_CACHE_SHIFT)); - -} - /* XXX put nice comment here. talk about __free_pte -> dirty pages and * nopage's reference passing to the pte */ int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last) @@ -470,7 +459,7 @@ int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last) return rc; } -static struct vm_operations_struct ll_file_vm_ops = { +static const struct vm_operations_struct ll_file_vm_ops = { .fault = ll_fault, .page_mkwrite = ll_page_mkwrite, .open = ll_vm_open, diff --git a/drivers/staging/lustre/lustre/llite/lloop.c b/drivers/staging/lustre/lustre/llite/lloop.c index 437adaff0c0a..b9694b8cb5dd 100644 --- a/drivers/staging/lustre/lustre/llite/lloop.c +++ b/drivers/staging/lustre/lustre/llite/lloop.c @@ -122,9 +122,6 @@ struct lloop_device { loff_t lo_offset; loff_t lo_sizelimit; int lo_flags; - int (*ioctl)(struct lloop_device *, int cmd, - unsigned long arg); - struct file *lo_backing_file; struct block_device *lo_device; unsigned lo_blocksize; @@ -509,7 +506,6 @@ static int loop_set_fd(struct lloop_device *lo, struct file *unused, lo->lo_device = bdev; lo->lo_flags = lo_flags; lo->lo_backing_file = file; - lo->ioctl = NULL; lo->lo_sizelimit = 0; lo->old_gfp_mask = mapping_gfp_mask(mapping); mapping_set_gfp_mask(mapping, lo->old_gfp_mask & ~(__GFP_IO|__GFP_FS)); @@ -568,7 +564,6 @@ static int loop_clr_fd(struct lloop_device *lo, struct block_device *bdev, down(&lo->lo_sem); lo->lo_backing_file = NULL; - lo->ioctl = NULL; lo->lo_device = NULL; lo->lo_offset = 0; lo->lo_sizelimit = 0; diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index f291254d0c80..6d70c658294e 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -41,9 +41,9 @@ #include #include "llite_internal.h" +#include "vvp_internal.h" /* /proc/lustre/llite mount point registration */ -extern struct file_operations vvp_dump_pgcache_file_ops; static struct file_operations ll_rw_extents_stats_fops; static struct file_operations ll_rw_extents_stats_pp_fops; static struct file_operations ll_rw_offset_stats_fops; @@ -837,7 +837,7 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = { #define MAX_STRING_SIZE 128 -struct llite_file_opcode { +static const struct llite_file_opcode { __u32 opcode; __u32 type; const char *opname; diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index 25a6ea580f00..dfa1e745dfd6 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -75,14 +75,6 @@ static int ll_d_mountpoint(struct dentry *dparent, struct dentry *dchild, return mounted; } -int ll_unlock(__u32 mode, struct lustre_handle *lockh) -{ - ldlm_lock_decref(lockh, mode); - - return 0; -} - - /* called from iget5_locked->find_inode() under inode_hash_lock spinlock */ static int ll_test_inode(struct inode *inode, void *opaque) { @@ -433,12 +425,10 @@ struct dentry *ll_splice_alias(struct inode *inode, struct dentry *de) return de; } -int ll_lookup_it_finish(struct ptlrpc_request *request, - struct lookup_intent *it, void *data) +static int ll_lookup_it_finish(struct ptlrpc_request *request, + struct lookup_intent *it, + struct inode *parent, struct dentry **de) { - struct it_cb_data *icbd = data; - struct dentry **de = icbd->icbd_childp; - struct inode *parent = icbd->icbd_parent; struct inode *inode = NULL; __u64 bits = 0; int rc; @@ -513,7 +503,6 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, struct dentry *save = dentry, *retval; struct ptlrpc_request *req = NULL; struct md_op_data *op_data; - struct it_cb_data icbd; __u32 opc; int rc; @@ -527,7 +516,8 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, if (d_mountpoint(dentry)) CERROR("Tell Peter, lookup on mtpt, it %s\n", LL_IT2STR(it)); - ll_frob_intent(&it, &lookup_it); + if (it == NULL || it->it_op == IT_GETXATTR) + it = &lookup_it; if (it->it_op == IT_GETATTR) { rc = ll_statahead_enter(parent, &dentry, 0); @@ -538,9 +528,6 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, } } - icbd.icbd_childp = &dentry; - icbd.icbd_parent = parent; - if (it->it_op & IT_CREAT) opc = LUSTRE_OPC_CREATE; else @@ -562,7 +549,7 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, if (rc < 0) GOTO(out, retval = ERR_PTR(rc)); - rc = ll_lookup_it_finish(req, it, &icbd); + rc = ll_lookup_it_finish(req, it, parent, &dentry); if (rc != 0) { ll_intent_release(it); GOTO(out, retval = ERR_PTR(rc)); @@ -697,10 +684,7 @@ out_release: /* We depend on "mode" being set with the proper file type/umask by now */ -static struct inode *ll_create_node(struct inode *dir, const char *name, - int namelen, const void *data, int datalen, - int mode, __u64 extra, - struct lookup_intent *it) +static struct inode *ll_create_node(struct inode *dir, struct lookup_intent *it) { struct inode *inode = NULL; struct ptlrpc_request *request = NULL; @@ -757,14 +741,10 @@ static int ll_create_it(struct inode *dir, struct dentry *dentry, int mode, if (rc) return rc; - inode = ll_create_node(dir, dentry->d_name.name, dentry->d_name.len, - NULL, 0, mode, 0, it); + inode = ll_create_node(dir, it); if (IS_ERR(inode)) return PTR_ERR(inode); - if (filename_is_volatile(dentry->d_name.name, dentry->d_name.len, NULL)) - ll_i2info(inode)->lli_volatile = true; - d_instantiate(dentry, inode); return 0; } @@ -1238,7 +1218,7 @@ static int ll_rename(struct inode *old_dir, struct dentry *old_dentry, return err; } -struct inode_operations ll_dir_inode_operations = { +const struct inode_operations ll_dir_inode_operations = { .mknod = ll_mknod, .atomic_open = ll_atomic_open, .lookup = ll_lookup_nd, @@ -1260,7 +1240,7 @@ struct inode_operations ll_dir_inode_operations = { .get_acl = ll_get_acl, }; -struct inode_operations ll_special_inode_operations = { +const struct inode_operations ll_special_inode_operations = { .setattr = ll_setattr, .getattr = ll_getattr, .permission = ll_inode_permission, diff --git a/drivers/staging/lustre/lustre/llite/remote_perm.c b/drivers/staging/lustre/lustre/llite/remote_perm.c index dedd56ae1e6d..a8b1117b8f60 100644 --- a/drivers/staging/lustre/lustre/llite/remote_perm.c +++ b/drivers/staging/lustre/lustre/llite/remote_perm.c @@ -77,7 +77,7 @@ static inline void free_ll_remote_perm(struct ll_remote_perm *lrp) OBD_SLAB_FREE(lrp, ll_remote_perm_cachep, sizeof(*lrp)); } -struct hlist_head *alloc_rmtperm_hash(void) +static struct hlist_head *alloc_rmtperm_hash(void) { struct hlist_head *hash; int i; diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c index 416f7a094a6d..f0122c568a09 100644 --- a/drivers/staging/lustre/lustre/llite/rw.c +++ b/drivers/staging/lustre/lustre/llite/rw.c @@ -77,12 +77,6 @@ static void ll_cl_fini(struct ll_cl_context *lcc) cl_page_put(env, page); } - if (io && lcc->lcc_created) { - cl_io_end(env, io); - cl_io_unlock(env, io); - cl_io_iter_fini(env, io); - cl_io_fini(env, io); - } cl_env_put(env, &lcc->lcc_refcheck); } @@ -167,7 +161,6 @@ static struct ll_cl_context *ll_cl_init(struct file *file, } } else result = io->ci_result; - lcc->lcc_created = 1; } lcc->lcc_io = io; diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c index 7e3e0967993b..b401d36b5739 100644 --- a/drivers/staging/lustre/lustre/llite/rw26.c +++ b/drivers/staging/lustre/lustre/llite/rw26.c @@ -529,9 +529,9 @@ static int ll_write_end(struct file *file, struct address_space *mapping, } #ifdef CONFIG_MIGRATION -int ll_migratepage(struct address_space *mapping, - struct page *newpage, struct page *page - , enum migrate_mode mode +static int ll_migratepage(struct address_space *mapping, + struct page *newpage, struct page *page, + enum migrate_mode mode ) { /* Always fail page migration until we have a proper implementation */ @@ -540,9 +540,8 @@ int ll_migratepage(struct address_space *mapping, #endif #ifndef MS_HAS_NEW_AOPS -struct address_space_operations ll_aops = { - .readpage = ll_readpage, -// .readpages = ll_readpages, +const struct address_space_operations ll_aops = { + .readpage = ll_readpage, .direct_IO = ll_direct_IO_26, .writepage = ll_writepage, .writepages = ll_writepages, @@ -554,10 +553,9 @@ struct address_space_operations ll_aops = { #ifdef CONFIG_MIGRATION .migratepage = ll_migratepage, #endif - .bmap = NULL }; #else -struct address_space_operations_ext ll_aops = { +const struct address_space_operations_ext ll_aops = { .orig_aops.readpage = ll_readpage, // .orig_aops.readpages = ll_readpages, .orig_aops.direct_IO = ll_direct_IO_26, @@ -571,7 +569,6 @@ struct address_space_operations_ext ll_aops = { #ifdef CONFIG_MIGRATION .orig_aops.migratepage = ll_migratepage, #endif - .orig_aops.bmap = NULL, .write_begin = ll_write_begin, .write_end = ll_write_end }; diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index 51c532756a7c..1b47774d7447 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -1230,9 +1230,7 @@ do_it: */ ll_release_page(page, le32_to_cpu(dp->ldp_flags) & LDF_COLLIDE); - sai->sai_in_readpage = 1; page = ll_get_dir_page(dir, pos, &chain); - sai->sai_in_readpage = 0; } else { LASSERT(le32_to_cpu(dp->ldp_flags) & LDF_COLLIDE); ll_release_page(page, 1); @@ -1563,12 +1561,6 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, return entry ? 1 : -EAGAIN; } - /* if statahead is busy in readdir, help it do post-work */ - while (!ll_sa_entry_stated(entry) && - sai->sai_in_readpage && - !sa_received_empty(sai)) - ll_post_statahead(sai); - if (!ll_sa_entry_stated(entry)) { sai->sai_index_wait = entry->se_index; lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(30), NULL, diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c index 58bb8f21dbe5..951fdb1265b9 100644 --- a/drivers/staging/lustre/lustre/llite/super25.c +++ b/drivers/staging/lustre/lustre/llite/super25.c @@ -72,7 +72,7 @@ static void ll_destroy_inode(struct inode *inode) call_rcu(&inode->i_rcu, ll_inode_destroy_callback); } -int ll_init_inodecache(void) +static int ll_init_inodecache(void) { ll_inode_cachep = kmem_cache_create("lustre_inode_cache", sizeof(struct ll_inode_info), @@ -82,7 +82,7 @@ int ll_init_inodecache(void) return 0; } -void ll_destroy_inodecache(void) +static void ll_destroy_inodecache(void) { kmem_cache_destroy(ll_inode_cachep); } @@ -103,9 +103,6 @@ MODULE_ALIAS_FS("lustre"); void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg)); -int vvp_global_init(void); -void vvp_global_fini(void); - static int __init init_lustre_lite(void) { int i, rc, seed[2]; diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c index a9778b874e30..0f68c16abe30 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_dev.c +++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c @@ -43,7 +43,7 @@ #include #include - +#include "llite_internal.h" #include "vvp_internal.h" /***************************************************************************** @@ -57,7 +57,7 @@ * "llite_" (var. "ll_") prefix. */ -struct kmem_cache *vvp_thread_kmem; +static struct kmem_cache *vvp_thread_kmem; static struct kmem_cache *vvp_session_kmem; static struct lu_kmem_descr vvp_caches[] = { { @@ -536,7 +536,7 @@ static int vvp_dump_pgcache_seq_open(struct inode *inode, struct file *filp) return result; } -struct file_operations vvp_dump_pgcache_file_ops = { +const struct file_operations vvp_dump_pgcache_file_ops = { .owner = THIS_MODULE, .open = vvp_dump_pgcache_seq_open, .read = seq_read, diff --git a/drivers/staging/lustre/lustre/llite/vvp_internal.h b/drivers/staging/lustre/lustre/llite/vvp_internal.h index c82bf17f55a6..3c9a03d99559 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_internal.h +++ b/drivers/staging/lustre/lustre/llite/vvp_internal.h @@ -57,6 +57,6 @@ struct lu_object *vvp_object_alloc(const struct lu_env *env, struct ccc_object *cl_inode2ccc(struct inode *inode); -extern struct kmem_cache *vvp_thread_kmem; +extern const struct file_operations vvp_dump_pgcache_file_ops; #endif /* VVP_INTERNAL_H */ diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index 5156ab829090..7dd2b4723c5f 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c @@ -190,7 +190,7 @@ static void vvp_io_fault_fini(const struct lu_env *env, vvp_io_fini(env, ios); } -enum cl_lock_mode vvp_mode_from_vma(struct vm_area_struct *vma) +static enum cl_lock_mode vvp_mode_from_vma(struct vm_area_struct *vma) { /* * we only want to hold PW locks if the mmap() can generate diff --git a/drivers/staging/lustre/lustre/llite/vvp_object.c b/drivers/staging/lustre/lustre/llite/vvp_object.c index 554a5dd2155c..65b6db1b71b4 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_object.c +++ b/drivers/staging/lustre/lustre/llite/vvp_object.c @@ -120,8 +120,8 @@ static int vvp_attr_set(const struct lu_env *env, struct cl_object *obj, return 0; } -int vvp_conf_set(const struct lu_env *env, struct cl_object *obj, - const struct cl_object_conf *conf) +static int vvp_conf_set(const struct lu_env *env, struct cl_object *obj, + const struct cl_object_conf *conf) { struct ll_inode_info *lli = ll_i2info(conf->coc_inode); diff --git a/drivers/staging/lustre/lustre/llite/xattr_cache.c b/drivers/staging/lustre/lustre/llite/xattr_cache.c index dfd19f801013..4dd83fc03687 100644 --- a/drivers/staging/lustre/lustre/llite/xattr_cache.c +++ b/drivers/staging/lustre/lustre/llite/xattr_cache.c @@ -232,7 +232,7 @@ static int ll_xattr_cache_list(struct list_head *cache, * \retval 0 @cache is not initialized * \retval 1 @cache is initialized */ -int ll_xattr_cache_valid(struct ll_inode_info *lli) +static int ll_xattr_cache_valid(struct ll_inode_info *lli) { return !!(lli->lli_flags & LLIF_XATTR_CACHE); } -- cgit v1.2.3 From 5e42bc9deb5fb43ae44b7f8192c16612e6b1d6bc Mon Sep 17 00:00:00 2001 From: Li Xi Date: Sun, 27 Apr 2014 13:07:06 -0400 Subject: staging/lustre: remove assertion of spin_is_locked() spin_is_locked() is always false when the platform is uniprocessor and CONFIG_DEBUG_SPINLOCK is not enabled. This patch replaces its assertion by assert_spin_locked(). Signed-off-by: Li Xi Signed-off-by: James Simmons Reviewed-on: http://review.whamcloud.com/8144 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4199 Reviewed-by: Alexey Lyashkov Reviewed-by: Andreas Dilger Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/libcfs/linux/linux-lock.h | 2 +- drivers/staging/lustre/lustre/include/lustre_dlm.h | 2 +- drivers/staging/lustre/lustre/include/lustre_net.h | 2 +- drivers/staging/lustre/lustre/lov/lov_merge.c | 4 ++-- drivers/staging/lustre/lustre/obdclass/cl_lock.c | 2 +- drivers/staging/lustre/lustre/obdclass/cl_object.c | 4 ++-- drivers/staging/lustre/lustre/obdclass/cl_page.c | 2 +- drivers/staging/lustre/lustre/osc/osc_cache.c | 4 ++-- drivers/staging/lustre/lustre/osc/osc_cl_internal.h | 9 +++++++++ drivers/staging/lustre/lustre/ptlrpc/client.c | 8 +++----- drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c | 4 ++-- drivers/staging/lustre/lustre/ptlrpc/import.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/pinger.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/service.c | 4 ++-- 16 files changed, 31 insertions(+), 24 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-lock.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-lock.h index d6e00f92e4a0..b75e401d9a97 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-lock.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-lock.h @@ -66,7 +66,7 @@ * - spin_unlock(x) * - spin_unlock_bh(x) * - spin_trylock(x) - * - spin_is_locked(x) + * - assert_spin_locked(x) * * - spin_lock_irq(x) * - spin_lock_irqsave(x, f) diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index e28e31a26369..0c6b7841e56d 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -1445,7 +1445,7 @@ static inline void unlock_res(struct ldlm_resource *res) /** Check if resource is already locked, assert if not. */ static inline void check_res_locked(struct ldlm_resource *res) { - LASSERT(spin_is_locked(&res->lr_lock)); + assert_spin_locked(&res->lr_lock); } struct ldlm_resource * lock_res_and_lock(struct ldlm_lock *lock); diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index 7640e179e39d..f6b7d10cb78c 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -719,7 +719,7 @@ struct ptlrpc_nrs_pol_ops { * \a nrq * \param[in,out] nrq The request * - * \pre spin_is_locked(&svcpt->scp_req_lock) + * \pre assert_spin_locked(&svcpt->scp_req_lock) * * \see ptlrpc_nrs_req_stop_nolock() */ diff --git a/drivers/staging/lustre/lustre/lov/lov_merge.c b/drivers/staging/lustre/lustre/lov/lov_merge.c index 0a14cee67b88..da959e901371 100644 --- a/drivers/staging/lustre/lustre/lov/lov_merge.c +++ b/drivers/staging/lustre/lustre/lov/lov_merge.c @@ -58,7 +58,7 @@ int lov_merge_lvb_kms(struct lov_stripe_md *lsm, int i; int rc = 0; - LASSERT(spin_is_locked(&lsm->lsm_lock)); + assert_spin_locked(&lsm->lsm_lock); LASSERT(lsm->lsm_lock_owner == current_pid()); CDEBUG(D_INODE, "MDT ID "DOSTID" initial value: s="LPU64" m="LPU64 @@ -145,7 +145,7 @@ int lov_adjust_kms(struct obd_export *exp, struct lov_stripe_md *lsm, int stripe = 0; __u64 kms; - LASSERT(spin_is_locked(&lsm->lsm_lock)); + assert_spin_locked(&lsm->lsm_lock); LASSERT(lsm->lsm_lock_owner == current_pid()); if (shrink) { diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c index f8040a8923b2..df77c4fc0eac 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c @@ -478,7 +478,7 @@ static struct cl_lock *cl_lock_lookup(const struct lu_env *env, struct cl_object_header *head; head = cl_object_header(obj); - LINVRNT(spin_is_locked(&head->coh_lock_guard)); + assert_spin_locked(&head->coh_lock_guard); CS_LOCK_INC(obj, lookup); list_for_each_entry(lock, &head->coh_locks, cll_linkage) { int matched; diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c index 2837cbc8865d..41cbc95b916e 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c @@ -220,7 +220,7 @@ int cl_object_attr_get(const struct lu_env *env, struct cl_object *obj, struct lu_object_header *top; int result; - LASSERT(spin_is_locked(cl_object_attr_guard(obj))); + assert_spin_locked(cl_object_attr_guard(obj)); top = obj->co_lu.lo_header; result = 0; @@ -251,7 +251,7 @@ int cl_object_attr_set(const struct lu_env *env, struct cl_object *obj, struct lu_object_header *top; int result; - LASSERT(spin_is_locked(cl_object_attr_guard(obj))); + assert_spin_locked(cl_object_attr_guard(obj)); top = obj->co_lu.lo_header; result = 0; diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index a4b04cba0b24..1b616e4fe140 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -130,7 +130,7 @@ struct cl_page *cl_page_lookup(struct cl_object_header *hdr, pgoff_t index) { struct cl_page *page; - LASSERT(spin_is_locked(&hdr->coh_page_guard)); + assert_spin_locked(&hdr->coh_page_guard); page = radix_tree_lookup(&hdr->coh_tree, index); if (page != NULL) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index fe9989a49f81..00f38eeb5786 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -1311,7 +1311,7 @@ static int osc_completion(const struct lu_env *env, struct osc_async_page *oap, static void osc_consume_write_grant(struct client_obd *cli, struct brw_page *pga) { - LASSERT(spin_is_locked(&cli->cl_loi_list_lock.lock)); + assert_spin_locked(&cli->cl_loi_list_lock.lock); LASSERT(!(pga->flag & OBD_BRW_FROM_GRANT)); atomic_inc(&obd_dirty_pages); cli->cl_dirty += PAGE_CACHE_SIZE; @@ -1326,7 +1326,7 @@ static void osc_consume_write_grant(struct client_obd *cli, static void osc_release_write_grant(struct client_obd *cli, struct brw_page *pga) { - LASSERT(spin_is_locked(&cli->cl_loi_list_lock.lock)); + assert_spin_locked(&cli->cl_loi_list_lock.lock); if (!(pga->flag & OBD_BRW_FROM_GRANT)) { return; } diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h index 9e7899fa4cc4..e74b7bb9776c 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h @@ -176,7 +176,16 @@ static inline void osc_object_unlock(struct osc_object *obj) static inline int osc_object_is_locked(struct osc_object *obj) { +#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) return spin_is_locked(&obj->oo_lock); +#else + /* + * It is not perfect to return true all the time. + * But since this function is only used for assertion + * and checking, it seems OK. + */ + return 1; +#endif } /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 20987723bb56..7246e8ce9c19 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -2271,7 +2271,7 @@ static int __ptlrpc_req_finished(struct ptlrpc_request *request, int locked); */ void ptlrpc_req_finished_with_imp_lock(struct ptlrpc_request *request) { - LASSERT(spin_is_locked(&request->rq_import->imp_lock)); + assert_spin_locked(&request->rq_import->imp_lock); (void)__ptlrpc_req_finished(request, 1); } EXPORT_SYMBOL(ptlrpc_req_finished_with_imp_lock); @@ -2452,9 +2452,7 @@ void ptlrpc_free_committed(struct obd_import *imp) bool skip_committed_list = true; LASSERT(imp != NULL); - - LASSERT(spin_is_locked(&imp->imp_lock)); - + assert_spin_locked(&imp->imp_lock); if (imp->imp_peer_committed_transno == imp->imp_last_transno_checked && imp->imp_generation == imp->imp_last_generation_checked) { @@ -2585,7 +2583,7 @@ void ptlrpc_retain_replayable_request(struct ptlrpc_request *req, { struct list_head *tmp; - LASSERT(spin_is_locked(&imp->imp_lock)); + assert_spin_locked(&imp->imp_lock); if (req->rq_transno == 0) { DEBUG_REQ(D_EMERG, req, "saving request with zero transno"); diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c index 7a1ff4fecbe3..3be5bc14c4ed 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c @@ -137,7 +137,7 @@ void ctx_enhash_pf(struct ptlrpc_cli_ctx *ctx, struct hlist_head *hash) static void ctx_unhash_pf(struct ptlrpc_cli_ctx *ctx, struct hlist_head *freelist) { - LASSERT(spin_is_locked(&ctx->cc_sec->ps_lock)); + assert_spin_locked(&ctx->cc_sec->ps_lock); LASSERT(atomic_read(&ctx->cc_refcount) > 0); LASSERT(test_bit(PTLRPC_CTX_CACHED_BIT, &ctx->cc_flags)); LASSERT(!hlist_unhashed(&ctx->cc_cache)); @@ -719,7 +719,7 @@ void gss_unhash_msg_nolock(struct gss_upcall_msg *gmsg) __u32 idx = gmsg->gum_mechidx; LASSERT(idx < MECH_MAX); - LASSERT(spin_is_locked(&upcall_locks[idx])); + assert_spin_locked(&upcall_locks[idx]); if (list_empty(&gmsg->gum_list)) return; diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index b231452d6215..1c73194421a6 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -194,7 +194,7 @@ int ptlrpc_set_import_discon(struct obd_import *imp, __u32 conn_cnt) /* Must be called with imp_lock held! */ static void ptlrpc_deactivate_and_unlock_import(struct obd_import *imp) { - LASSERT(spin_is_locked(&imp->imp_lock)); + assert_spin_locked(&imp->imp_lock); CDEBUG(D_HA, "setting import %s INVALID\n", obd2cli_tgt(imp->imp_obd)); imp->imp_invalid = 1; diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 7a422ff759bf..6b9c6db1f2df 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -449,7 +449,7 @@ void nrs_policy_get_info_locked(struct ptlrpc_nrs_policy *policy, { LASSERT(policy != NULL); LASSERT(info != NULL); - LASSERT(spin_is_locked(&policy->pol_nrs->nrs_lock)); + assert_spin_locked(&policy->pol_nrs->nrs_lock); memcpy(info->pi_name, policy->pol_desc->pd_name, NRS_POL_NAME_MAX); diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c index 6dff502ce23e..38099d9dfdae 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c @@ -368,7 +368,7 @@ EXPORT_SYMBOL(ptlrpc_pinger_sending_on_import); void ptlrpc_pinger_commit_expected(struct obd_import *imp) { ptlrpc_update_next_ping(imp, 1); - LASSERT(spin_is_locked(&imp->imp_lock)); + assert_spin_locked(&imp->imp_lock); /* * Avoid reading stale imp_connect_data. When not sure if pings are * expected or not on next connection, we assume they are not and force diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c index 1d46b5e2b0bc..9d51badea73d 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c @@ -450,7 +450,7 @@ out: static inline void enc_pools_wakeup(void) { - LASSERT(spin_is_locked(&page_pools.epp_lock)); + assert_spin_locked(&page_pools.epp_lock); LASSERT(page_pools.epp_waitqlen >= 0); if (unlikely(page_pools.epp_waitqlen)) { diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 5d0eb6cb587c..d278f2e21803 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -384,8 +384,8 @@ void ptlrpc_dispatch_difficult_reply(struct ptlrpc_reply_state *rs) void ptlrpc_schedule_difficult_reply(struct ptlrpc_reply_state *rs) { - LASSERT(spin_is_locked(&rs->rs_svcpt->scp_rep_lock)); - LASSERT(spin_is_locked(&rs->rs_lock)); + assert_spin_locked(&rs->rs_svcpt->scp_rep_lock); + assert_spin_locked(&rs->rs_lock); LASSERT(rs->rs_difficult); rs->rs_scheduled_ever = 1; /* flag any notification attempt */ -- cgit v1.2.3 From beaa2647268496f94c387f146948118bd0abfde0 Mon Sep 17 00:00:00 2001 From: Swapnil Pimpale Date: Sun, 27 Apr 2014 13:07:07 -0400 Subject: staging/lustre/osc: Update inode timestamp for lockless IO as well Removed the checks for oi_lockless from osc_io_read_start() and osc_io_write_start(). This patch also removes the unnecessary call to cl_object_attr_get() in osc_io_write_start() before calling cl_object_attr_set() Signed-off-by: Swapnil Pimpale Reviewed-on: http://review.whamcloud.com/8797 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3868 Reviewed-by: John L. Hammond Reviewed-by: Andreas Dilger Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/osc/osc_io.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index 6744dc620840..09e06eb08530 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/drivers/staging/lustre/lustre/osc/osc_io.c @@ -509,12 +509,11 @@ static void osc_io_setattr_end(const struct lu_env *env, static int osc_io_read_start(const struct lu_env *env, const struct cl_io_slice *slice) { - struct osc_io *oio = cl2osc_io(env, slice); struct cl_object *obj = slice->cis_obj; struct cl_attr *attr = &osc_env_info(env)->oti_attr; int rc = 0; - if (oio->oi_lockless == 0 && !slice->cis_io->ci_noatime) { + if (!slice->cis_io->ci_noatime) { cl_object_attr_lock(obj); attr->cat_atime = LTIME_S(CURRENT_TIME); rc = cl_object_attr_set(env, obj, attr, CAT_ATIME); @@ -526,24 +525,17 @@ static int osc_io_read_start(const struct lu_env *env, static int osc_io_write_start(const struct lu_env *env, const struct cl_io_slice *slice) { - struct osc_io *oio = cl2osc_io(env, slice); struct cl_object *obj = slice->cis_obj; struct cl_attr *attr = &osc_env_info(env)->oti_attr; - int result = 0; + int rc = 0; - if (oio->oi_lockless == 0) { - OBD_FAIL_TIMEOUT(OBD_FAIL_OSC_DELAY_SETTIME, 1); - cl_object_attr_lock(obj); - result = cl_object_attr_get(env, obj, attr); - if (result == 0) { - attr->cat_mtime = attr->cat_ctime = - LTIME_S(CURRENT_TIME); - result = cl_object_attr_set(env, obj, attr, - CAT_MTIME | CAT_CTIME); - } - cl_object_attr_unlock(obj); - } - return result; + OBD_FAIL_TIMEOUT(OBD_FAIL_OSC_DELAY_SETTIME, 1); + cl_object_attr_lock(obj); + attr->cat_mtime = attr->cat_ctime = LTIME_S(CURRENT_TIME); + rc = cl_object_attr_set(env, obj, attr, CAT_MTIME | CAT_CTIME); + cl_object_attr_unlock(obj); + + return rc; } static int osc_fsync_ost(const struct lu_env *env, struct osc_object *obj, -- cgit v1.2.3 From b7d0254ce83019aebdc6bc3a7dcd4e720895ef1f Mon Sep 17 00:00:00 2001 From: Ryan Haasken Date: Sun, 27 Apr 2014 13:07:08 -0400 Subject: staging/lustre: Always clamp cdls_delay between min and max In libcfs_debug_vmsg2, cdls_delay is only clamped between the minimum and the maximum when it is increased by multiplying by the backoff factor. It is not clamped when it is decreased by dividing by the backoff factor. This allows it to achieve values less than the minimum, which allows a console message to be printed that should have been skipped. This patch moves the clamping outside of the else statement, ensuring that cdls_delay is always between the min and the max after the first time through libcfs_debug_vmsg2. Signed-off-by: Ryan Haasken Reviewed-on: http://review.whamcloud.com/9503 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4711 Reviewed-by: Chris Horn Reviewed-by: Ann Koehler Reviewed-by: Andreas Dilger Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/libcfs/tracefile.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/libcfs/tracefile.c b/drivers/staging/lustre/lustre/libcfs/tracefile.c index 50d421816c4c..07845e844243 100644 --- a/drivers/staging/lustre/lustre/libcfs/tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/tracefile.c @@ -416,13 +416,13 @@ console: cdls->cdls_delay /= libcfs_console_backoff * 4; } else { cdls->cdls_delay *= libcfs_console_backoff; - - if (cdls->cdls_delay < libcfs_console_min_delay) - cdls->cdls_delay = libcfs_console_min_delay; - else if (cdls->cdls_delay > libcfs_console_max_delay) - cdls->cdls_delay = libcfs_console_max_delay; } + if (cdls->cdls_delay < libcfs_console_min_delay) + cdls->cdls_delay = libcfs_console_min_delay; + else if (cdls->cdls_delay > libcfs_console_max_delay) + cdls->cdls_delay = libcfs_console_max_delay; + /* ensure cdls_next is never zero after it's been seen */ cdls->cdls_next = (cfs_time_current() + cdls->cdls_delay) | 1; } -- cgit v1.2.3 From 05289927d029ffed093424acac0b12f8ee06bfc2 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Sun, 27 Apr 2014 13:07:09 -0400 Subject: staging/lustre: pass fsync() range through RPC/IO stack The Linux VFS and Lustre OST_SYNC RPC are both capable of specifying fsync() on a sub-extent of the file {start, end} instead of the full file. This allows less than the full amount of data to be flushed, reducing or possibly eliminating the work needed before the syscall can return. However, the handling of sub-extent of the file for fsync was lost with the move to CLIO on the client and OSD API on the server. They were ignoring the passed {start, end} and using {0, OBD_OBJECT_EOF} instead. Return the ability to pass a sub-extent for fsync() from the client, to the specific stripes/OSTs that need the sync operation, and pass it down to the OSD. The ZFS OSD doesn't handle this yet, but there is room for improvement in a separate patch. Signed-off-by: Andreas Dilger Reviewed-on: http://review.whamcloud.com/8626 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4388 Reviewed-by: Bobi Jam Reviewed-by: Jinshan Xiong Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/dt_object.h | 9 +++++---- drivers/staging/lustre/lustre/llite/file.c | 5 ++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/dt_object.h b/drivers/staging/lustre/lustre/include/dt_object.h index 9304c269afa9..9b7921d1dea8 100644 --- a/drivers/staging/lustre/lustre/include/dt_object.h +++ b/drivers/staging/lustre/lustre/include/dt_object.h @@ -441,7 +441,8 @@ struct dt_object_operations { struct dt_object *dt, struct lustre_capa *old, __u64 opc); - int (*do_object_sync)(const struct lu_env *, struct dt_object *); + int (*do_object_sync)(const struct lu_env *env, struct dt_object *obj, + __u64 start, __u64 end); /** * Get object info of next level. Currently, only get inode from osd. * This is only used by quota b=16542 @@ -900,13 +901,13 @@ static inline int dt_object_lock(const struct lu_env *env, int dt_lookup_dir(const struct lu_env *env, struct dt_object *dir, const char *name, struct lu_fid *fid); -static inline int dt_object_sync(const struct lu_env *env, - struct dt_object *o) +static inline int dt_object_sync(const struct lu_env *env, struct dt_object *o, + __u64 start, __u64 end) { LASSERT(o); LASSERT(o->do_ops); LASSERT(o->do_ops->do_object_sync); - return o->do_ops->do_object_sync(env, o); + return o->do_ops->do_object_sync(env, o, start, end); } int dt_declare_version_set(const struct lu_env *env, struct dt_object *o, diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 4d8f6a0144bb..79accc5ac0bb 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -2570,7 +2570,7 @@ static int ll_flush(struct file *file, fl_owner_t id) /** * Called to make sure a portion of file has been written out. - * if @local_only is not true, it will send OST_SYNC RPCs to ost. + * if @mode is not CL_FSYNC_LOCAL, it will send OST_SYNC RPCs to OST. * * Return how many pages have been written. */ @@ -2667,8 +2667,7 @@ int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync) if (S_ISREG(inode->i_mode)) { struct ll_file_data *fd = LUSTRE_FPRIVATE(file); - err = cl_sync_file_range(inode, 0, OBD_OBJECT_EOF, - CL_FSYNC_ALL, 0); + err = cl_sync_file_range(inode, start, end, CL_FSYNC_ALL, 0); if (rc == 0 && err < 0) rc = err; if (rc < 0) -- cgit v1.2.3 From a1e7e2d4deab583593e427b3bf9dd62823d81fbc Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Sun, 27 Apr 2014 13:07:10 -0400 Subject: staging/lustre: Fix unsafe userspace access in many proc files Apparently we are pretty bad about verifying our buffers passed from userspace. Signed-off-by: Oleg Drokin Reviewed-on: http://review.whamcloud.com/9059 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4563 Reviewed-by: Dmitry Eremin Reviewed-by: James Simmons Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/fid/lproc_fid.c | 41 +++++++--- .../lustre/lustre/include/lustre/lustre_idl.h | 2 +- drivers/staging/lustre/lustre/llite/lproc_llite.c | 91 +++++++++++++++++----- .../lustre/lustre/obdclass/linux/linux-module.c | 9 ++- drivers/staging/lustre/lustre/osc/lproc_osc.c | 16 +++- 5 files changed, 124 insertions(+), 35 deletions(-) diff --git a/drivers/staging/lustre/lustre/fid/lproc_fid.c b/drivers/staging/lustre/lustre/fid/lproc_fid.c index ddd813cab501..6f5674d1aa72 100644 --- a/drivers/staging/lustre/lustre/fid/lproc_fid.c +++ b/drivers/staging/lustre/lustre/fid/lproc_fid.c @@ -54,32 +54,49 @@ #include #include "fid_internal.h" +/* Format: [0x64BIT_INT - 0x64BIT_INT] + 32 bytes just in case */ +#define MAX_FID_RANGE_STRLEN (32 + 2 * 2 * sizeof(__u64)) /* * Note: this function is only used for testing, it is no safe for production * use. */ -static int -lprocfs_fid_write_common(const char *buffer, unsigned long count, - struct lu_seq_range *range) +static int lprocfs_fid_write_common(const char __user *buffer, size_t count, + struct lu_seq_range *range) { struct lu_seq_range tmp; int rc; + char kernbuf[MAX_FID_RANGE_STRLEN]; LASSERT(range != NULL); - rc = sscanf(buffer, "[%llx - %llx]\n", + if (count >= sizeof(kernbuf)) + return -EINVAL; + + if (copy_from_user(kernbuf, buffer, count)) + return -EFAULT; + + kernbuf[count] = 0; + + if (count == 5 && strcmp(kernbuf, "clear") == 0) { + memset(range, 0, sizeof(*range)); + return count; + } + + /* of the form "[0x0000000240000400 - 0x000000028000400]" */ + rc = sscanf(kernbuf, "[%llx - %llx]\n", (long long unsigned *)&tmp.lsr_start, (long long unsigned *)&tmp.lsr_end); - if (rc != 2 || !range_is_sane(&tmp) || range_is_zero(&tmp)) + if (!range_is_sane(&tmp) || range_is_zero(&tmp) || + tmp.lsr_start < range->lsr_start || tmp.lsr_end > range->lsr_end) return -EINVAL; *range = tmp; - return 0; + return count; } /* Client side procfs stuff */ -static ssize_t -lprocfs_fid_space_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +static ssize_t lprocfs_fid_space_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct lu_client_seq *seq = ((struct seq_file *)file->private_data)->private; int rc; @@ -114,9 +131,9 @@ lprocfs_fid_space_seq_show(struct seq_file *m, void *unused) return rc; } -static ssize_t -lprocfs_fid_width_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +static ssize_t lprocfs_fid_width_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct lu_client_seq *seq = ((struct seq_file *)file->private_data)->private; __u64 max; diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index abd29bfa3713..83014c9fea65 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -265,7 +265,7 @@ static inline __u64 range_space(const struct lu_seq_range *range) static inline void range_init(struct lu_seq_range *range) { - range->lsr_start = range->lsr_end = range->lsr_index = 0; + memset(range, 0, sizeof(*range)); } /** diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 6d70c658294e..77ee9e58cf87 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -367,8 +367,9 @@ static int ll_max_cached_mb_seq_show(struct seq_file *m, void *v) cache->ccc_lru_shrinkers); } -static ssize_t ll_max_cached_mb_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +static ssize_t ll_max_cached_mb_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct super_block *sb = ((struct seq_file *)file->private_data)->private; struct ll_sb_info *sbi = ll_s2sbi(sb); @@ -376,9 +377,18 @@ static ssize_t ll_max_cached_mb_seq_write(struct file *file, const char *buffer, int mult, rc, pages_number; int diff = 0; int nrpages = 0; + char kernbuf[128]; + + if (count >= sizeof(kernbuf)) + return -EINVAL; + + if (copy_from_user(kernbuf, buffer, count)) + return -EFAULT; + kernbuf[count] = 0; mult = 1 << (20 - PAGE_CACHE_SHIFT); - buffer = lprocfs_find_named_value(buffer, "max_cached_mb:", &count); + buffer += lprocfs_find_named_value(kernbuf, "max_cached_mb:", &count) - + kernbuf; rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult); if (rc) return rc; @@ -1163,7 +1173,8 @@ static int ll_rw_extents_stats_pp_seq_show(struct seq_file *seq, void *v) } static ssize_t ll_rw_extents_stats_pp_seq_write(struct file *file, - const char *buf, size_t len, + const char __user *buf, + size_t len, loff_t *off) { struct seq_file *seq = file->private_data; @@ -1172,10 +1183,24 @@ static ssize_t ll_rw_extents_stats_pp_seq_write(struct file *file, int i; int value = 1, rc = 0; + if (len == 0) + return -EINVAL; + rc = lprocfs_write_helper(buf, len, &value); - if (rc < 0 && (strcmp(buf, "disabled") == 0 || - strcmp(buf, "Disabled") == 0)) - value = 0; + if (rc < 0 && len < 16) { + char kernbuf[16]; + + if (copy_from_user(kernbuf, buf, len)) + return -EFAULT; + kernbuf[len] = 0; + + if (kernbuf[len - 1] == '\n') + kernbuf[len - 1] = 0; + + if (strcmp(kernbuf, "disabled") == 0 || + strcmp(kernbuf, "Disabled") == 0) + value = 0; + } if (value == 0) sbi->ll_rw_stats_on = 0; @@ -1222,8 +1247,9 @@ static int ll_rw_extents_stats_seq_show(struct seq_file *seq, void *v) return 0; } -static ssize_t ll_rw_extents_stats_seq_write(struct file *file, const char *buf, - size_t len, loff_t *off) +static ssize_t ll_rw_extents_stats_seq_write(struct file *file, + const char __user *buf, + size_t len, loff_t *off) { struct seq_file *seq = file->private_data; struct ll_sb_info *sbi = seq->private; @@ -1231,15 +1257,30 @@ static ssize_t ll_rw_extents_stats_seq_write(struct file *file, const char *buf, int i; int value = 1, rc = 0; + if (len == 0) + return -EINVAL; + rc = lprocfs_write_helper(buf, len, &value); - if (rc < 0 && (strcmp(buf, "disabled") == 0 || - strcmp(buf, "Disabled") == 0)) - value = 0; + if (rc < 0 && len < 16) { + char kernbuf[16]; + + if (copy_from_user(kernbuf, buf, len)) + return -EFAULT; + kernbuf[len] = 0; + + if (kernbuf[len - 1] == '\n') + kernbuf[len - 1] = 0; + + if (strcmp(kernbuf, "disabled") == 0 || + strcmp(kernbuf, "Disabled") == 0) + value = 0; + } if (value == 0) sbi->ll_rw_stats_on = 0; else sbi->ll_rw_stats_on = 1; + spin_lock(&sbi->ll_pp_extent_lock); for (i = 0; i <= LL_PROCESS_HIST_MAX; i++) { io_extents->pp_extents[i].pid = 0; @@ -1250,7 +1291,6 @@ static ssize_t ll_rw_extents_stats_seq_write(struct file *file, const char *buf, return len; } - LPROC_SEQ_FOPS(ll_rw_extents_stats); void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, @@ -1410,8 +1450,9 @@ static int ll_rw_offset_stats_seq_show(struct seq_file *seq, void *v) return 0; } -static ssize_t ll_rw_offset_stats_seq_write(struct file *file, const char *buf, - size_t len, loff_t *off) +static ssize_t ll_rw_offset_stats_seq_write(struct file *file, + const char __user *buf, + size_t len, loff_t *off) { struct seq_file *seq = file->private_data; struct ll_sb_info *sbi = seq->private; @@ -1419,11 +1460,25 @@ static ssize_t ll_rw_offset_stats_seq_write(struct file *file, const char *buf, struct ll_rw_process_info *offset_info = sbi->ll_rw_offset_info; int value = 1, rc = 0; + if (len == 0) + return -EINVAL; + rc = lprocfs_write_helper(buf, len, &value); - if (rc < 0 && (strcmp(buf, "disabled") == 0 || - strcmp(buf, "Disabled") == 0)) - value = 0; + if (rc < 0 && len < 16) { + char kernbuf[16]; + + if (copy_from_user(kernbuf, buf, len)) + return -EFAULT; + kernbuf[len] = 0; + + if (kernbuf[len - 1] == '\n') + kernbuf[len - 1] = 0; + + if (strcmp(kernbuf, "disabled") == 0 || + strcmp(kernbuf, "Disabled") == 0) + value = 0; + } if (value == 0) sbi->ll_rw_stats_on = 0; diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c index dec10377f222..0334882070ef 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c @@ -279,8 +279,15 @@ static ssize_t obd_proc_jobid_var_seq_write(struct file *file, const char *buffe return -EINVAL; memset(obd_jobid_var, 0, JOBSTATS_JOBID_VAR_MAX_LEN + 1); + + /* This might leave the var invalid on error, which is probably fine.*/ + if (copy_from_user(obd_jobid_var, buffer, count)) + return -EFAULT; + /* Trim the trailing '\n' if any */ - memcpy(obd_jobid_var, buffer, count - (buffer[count - 1] == '\n')); + if (obd_jobid_var[count - 1] == '\n') + obd_jobid_var[count - 1] = 0; + return count; } LPROC_SEQ_FOPS(obd_proc_jobid_var); diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 0b59fc16c50c..358e32cd05d2 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -174,15 +174,25 @@ static int osc_cached_mb_seq_show(struct seq_file *m, void *v) } /* shrink the number of caching pages to a specific number */ -static ssize_t osc_cached_mb_seq_write(struct file *file, const char *buffer, - size_t count, loff_t *off) +static ssize_t osc_cached_mb_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) { struct obd_device *dev = ((struct seq_file *)file->private_data)->private; struct client_obd *cli = &dev->u.cli; int pages_number, mult, rc; + char kernbuf[128]; + + if (count >= sizeof(kernbuf)) + return -EINVAL; + + if (copy_from_user(kernbuf, buffer, count)) + return -EFAULT; + kernbuf[count] = 0; mult = 1 << (20 - PAGE_CACHE_SHIFT); - buffer = lprocfs_find_named_value(buffer, "used_mb:", &count); + buffer += lprocfs_find_named_value(kernbuf, "used_mb:", &count) - + kernbuf; rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult); if (rc) return rc; -- cgit v1.2.3 From ebdc4fc54d5defaa20417eabeb7a8d7b400fd53c Mon Sep 17 00:00:00 2001 From: Bobi Jam Date: Sun, 27 Apr 2014 13:07:11 -0400 Subject: staging/lustre/llite: prevent buffer overflow in fiemap lov_fiemap() does not take consider its @vallen parameter, which is the max buffer size the caller can hold for the fiemap extents. This patch fixes this and limits the max mapped fiemap extent count to fit in the preallocted buffer. This patch also fixes a memory out of bound write issue when the fiemap call is only for detecting the number of existing extent. Signed-off-by: Bobi Jam Reviewed-on: http://review.whamcloud.com/9834 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4619 Reviewed-by: Fan Yong Reviewed-by: Patrick Farrell Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/file.c | 15 +++++++++------ drivers/staging/lustre/lustre/lov/lov_obd.c | 3 ++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 79accc5ac0bb..562e33751197 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -1721,12 +1721,12 @@ out: * Make the FIEMAP get_info call and returns the result. */ static int ll_do_fiemap(struct inode *inode, struct ll_user_fiemap *fiemap, - int num_bytes) + size_t num_bytes) { struct obd_export *exp = ll_i2dtexp(inode); struct lov_stripe_md *lsm = NULL; struct ll_fiemap_info_key fm_key = { .name = KEY_FIEMAP, }; - int vallen = num_bytes; + __u32 vallen = num_bytes; int rc; /* Checks for fiemap flags */ @@ -3080,15 +3080,18 @@ static int ll_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, fiemap->fm_extent_count = fieinfo->fi_extents_max; fiemap->fm_start = start; fiemap->fm_length = len; - memcpy(&fiemap->fm_extents[0], fieinfo->fi_extents_start, - sizeof(struct ll_fiemap_extent)); + if (extent_count > 0) + memcpy(&fiemap->fm_extents[0], fieinfo->fi_extents_start, + sizeof(struct ll_fiemap_extent)); rc = ll_do_fiemap(inode, fiemap, num_bytes); fieinfo->fi_flags = fiemap->fm_flags; fieinfo->fi_extents_mapped = fiemap->fm_mapped_extents; - memcpy(fieinfo->fi_extents_start, &fiemap->fm_extents[0], - fiemap->fm_mapped_extents * sizeof(struct ll_fiemap_extent)); + if (extent_count > 0) + memcpy(fieinfo->fi_extents_start, &fiemap->fm_extents[0], + fiemap->fm_mapped_extents * + sizeof(struct ll_fiemap_extent)); OBD_FREE_LARGE(fiemap, num_bytes); return rc; diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index dbd971a1344f..12e778c42255 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -2248,11 +2248,12 @@ static int lov_fiemap(struct lov_obd *lov, __u32 keylen, void *key, if (fm_end_offset == -EINVAL) GOTO(out, rc = -EINVAL); + if (fiemap_count_to_size(fiemap->fm_extent_count) > *vallen) + fiemap->fm_extent_count = fiemap_size_to_count(*vallen); if (fiemap->fm_extent_count == 0) { get_num_extents = 1; count_local = 0; } - /* Check each stripe */ for (cur_stripe = start_stripe, i = 0; i < stripe_count; i++, cur_stripe = (cur_stripe + 1) % lsm->lsm_stripe_count) { -- cgit v1.2.3 From 1da4f83c0c43f25baf356c4cc719255877da6b1e Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Sun, 27 Apr 2014 14:42:29 -0400 Subject: staging/lustre/llite: Fix a compile warning. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Quiet the warning below in Lustre code. Actually the warning is invalid since we either always assign the symname in ll_readlink_internal or return an error there and then the following rc check would assign symlink variable explicitly. In file included from /home/green/bk/linux/drivers/staging/lustre/lustre/llite/../include/linux/lustre_compat25.h:41:0, from /home/green/bk/linux/drivers/staging/lustre/lustre/llite/../include/linux/lvfs.h:48, from /home/green/bk/linux/drivers/staging/lustre/lustre/llite/../include/lvfs.h:45, from /home/green/bk/linux/drivers/staging/lustre/lustre/llite/../include/obd_support.h:41, from /home/green/bk/linux/drivers/staging/lustre/lustre/llite/../include/obd_class.h:40, from /home/green/bk/linux/drivers/staging/lustre/lustre/llite/../include/linux/lustre_lite.h:49, from /home/green/bk/linux/drivers/staging/lustre/lustre/llite/../include/lustre_lite.h:45, from /home/green/bk/linux/drivers/staging/lustre/lustre/llite/symlink.c:42: /home/green/bk/linux/drivers/staging/lustre/lustre/llite/symlink.c: In function ‘ll_follow_link’: /home/green/bk/linux/include/linux/namei.h:88:29: warning: ‘symname’ may be used uninitialized in this function [-Wmaybe-uninitialized] nd->saved_names[nd->depth] = path; ^ /home/green/bk/linux/drivers/staging/lustre/lustre/llite/symlink.c:123:8: note: ‘symname’ was declared here char *symname; ^ Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/symlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/symlink.c b/drivers/staging/lustre/lustre/llite/symlink.c index 80d48b5ae247..129d3023dcea 100644 --- a/drivers/staging/lustre/lustre/llite/symlink.c +++ b/drivers/staging/lustre/lustre/llite/symlink.c @@ -120,7 +120,7 @@ static void *ll_follow_link(struct dentry *dentry, struct nameidata *nd) struct inode *inode = dentry->d_inode; struct ptlrpc_request *request = NULL; int rc; - char *symname; + char *symname = NULL; CDEBUG(D_VFSTRACE, "VFS Op\n"); /* Limit the recursive symlink depth to 5 instead of default -- cgit v1.2.3 From 3046365bb470f0ec2f7cf5cb07a8ee7e4b490103 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Tue, 29 Apr 2014 00:51:00 +0100 Subject: devres: introduce API "devm_kmemdup Introduce devm_kmemdup, which uses resource managed kmalloc. There are several request from maintainers to add this instead of using kmemdup. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- Documentation/driver-model/devres.txt | 1 + drivers/base/devres.c | 21 +++++++++++++++++++++ include/linux/device.h | 2 ++ 3 files changed, 24 insertions(+) diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt index 4f7897e99cba..499951873997 100644 --- a/Documentation/driver-model/devres.txt +++ b/Documentation/driver-model/devres.txt @@ -236,6 +236,7 @@ certainly invest a bit more effort into libata core layer). MEM devm_kzalloc() devm_kfree() + devm_kmemdup() IIO devm_iio_device_alloc() diff --git a/drivers/base/devres.c b/drivers/base/devres.c index db4e264eecb6..d0914cba2413 100644 --- a/drivers/base/devres.c +++ b/drivers/base/devres.c @@ -831,3 +831,24 @@ void devm_kfree(struct device *dev, void *p) WARN_ON(rc); } EXPORT_SYMBOL_GPL(devm_kfree); + +/** + * devm_kmemdup - Resource-managed kmemdup + * @dev: Device this memory belongs to + * @src: Memory region to duplicate + * @len: Memory region length + * @gfp: GFP mask to use + * + * Duplicate region of a memory using resource managed kmalloc + */ +void *devm_kmemdup(struct device *dev, const void *src, size_t len, gfp_t gfp) +{ + void *p; + + p = devm_kmalloc(dev, len, gfp); + if (p) + memcpy(p, src, len); + + return p; +} +EXPORT_SYMBOL_GPL(devm_kmemdup); diff --git a/include/linux/device.h b/include/linux/device.h index d1d1c055b48e..ab871588da89 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -623,6 +623,8 @@ static inline void *devm_kcalloc(struct device *dev, } extern void devm_kfree(struct device *dev, void *p); extern char *devm_kstrdup(struct device *dev, const char *s, gfp_t gfp); +extern void *devm_kmemdup(struct device *dev, const void *src, size_t len, + gfp_t gfp); void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res); void __iomem *devm_request_and_ioremap(struct device *dev, -- cgit v1.2.3 From 9fbfb4b37ed23f71aa9484484266381c6c6964cb Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Tue, 29 Apr 2014 00:51:00 +0100 Subject: IIO: core: Introduce read_raw_multi This callback is introduced to overcome some limitations of existing read_raw callback. The functionality of both existing read_raw and read_raw_multi is similar, both are used to request values from the device. The current read_raw callback allows only two return values. The new read_raw_multi allows returning multiple values. Instead of passing just address of val and val2, it passes length and pointer to values. Depending on the type and length of passed buffer, iio client drivers can return multiple values. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/iio_core.h | 2 +- drivers/iio/industrialio-core.c | 65 ++++++++++++++++++++++++++-------------- drivers/iio/industrialio-event.c | 6 ++-- drivers/iio/inkern.c | 16 ++++++++-- include/linux/iio/iio.h | 17 +++++++++++ include/linux/iio/types.h | 1 + 6 files changed, 80 insertions(+), 27 deletions(-) diff --git a/drivers/iio/iio_core.h b/drivers/iio/iio_core.h index f6db6af36ba6..5f0ea77fe717 100644 --- a/drivers/iio/iio_core.h +++ b/drivers/iio/iio_core.h @@ -35,7 +35,7 @@ int __iio_add_chan_devattr(const char *postfix, struct list_head *attr_list); void iio_free_chan_devattr_list(struct list_head *attr_list); -ssize_t iio_format_value(char *buf, unsigned int type, int val, int val2); +ssize_t iio_format_value(char *buf, unsigned int type, int size, int *vals); /* Event interface flags */ #define IIO_BUSY_BIT_POS 1 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 184444db62ac..59540859bfae 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -373,41 +373,53 @@ EXPORT_SYMBOL_GPL(iio_enum_write); * @buf: The buffer to which the formated value gets written * @type: One of the IIO_VAL_... constants. This decides how the val and val2 * parameters are formatted. - * @val: First part of the value, exact meaning depends on the type parameter. - * @val2: Second part of the value, exact meaning depends on the type parameter. + * @vals: pointer to the values, exact meaning depends on the type parameter. */ -ssize_t iio_format_value(char *buf, unsigned int type, int val, int val2) +ssize_t iio_format_value(char *buf, unsigned int type, int size, int *vals) { unsigned long long tmp; bool scale_db = false; switch (type) { case IIO_VAL_INT: - return sprintf(buf, "%d\n", val); + return sprintf(buf, "%d\n", vals[0]); case IIO_VAL_INT_PLUS_MICRO_DB: scale_db = true; case IIO_VAL_INT_PLUS_MICRO: - if (val2 < 0) - return sprintf(buf, "-%ld.%06u%s\n", abs(val), -val2, + if (vals[1] < 0) + return sprintf(buf, "-%ld.%06u%s\n", abs(vals[0]), + -vals[1], scale_db ? " dB" : ""); else - return sprintf(buf, "%d.%06u%s\n", val, val2, + return sprintf(buf, "%d.%06u%s\n", vals[0], vals[1], scale_db ? " dB" : ""); case IIO_VAL_INT_PLUS_NANO: - if (val2 < 0) - return sprintf(buf, "-%ld.%09u\n", abs(val), -val2); + if (vals[1] < 0) + return sprintf(buf, "-%ld.%09u\n", abs(vals[0]), + -vals[1]); else - return sprintf(buf, "%d.%09u\n", val, val2); + return sprintf(buf, "%d.%09u\n", vals[0], vals[1]); case IIO_VAL_FRACTIONAL: - tmp = div_s64((s64)val * 1000000000LL, val2); - val2 = do_div(tmp, 1000000000LL); - val = tmp; - return sprintf(buf, "%d.%09u\n", val, val2); + tmp = div_s64((s64)vals[0] * 1000000000LL, vals[1]); + vals[1] = do_div(tmp, 1000000000LL); + vals[0] = tmp; + return sprintf(buf, "%d.%09u\n", vals[0], vals[1]); case IIO_VAL_FRACTIONAL_LOG2: - tmp = (s64)val * 1000000000LL >> val2; - val2 = do_div(tmp, 1000000000LL); - val = tmp; - return sprintf(buf, "%d.%09u\n", val, val2); + tmp = (s64)vals[0] * 1000000000LL >> vals[1]; + vals[1] = do_div(tmp, 1000000000LL); + vals[0] = tmp; + return sprintf(buf, "%d.%09u\n", vals[0], vals[1]); + case IIO_VAL_INT_MULTIPLE: + { + int i; + int len = 0; + + for (i = 0; i < size; ++i) + len += snprintf(&buf[len], PAGE_SIZE - len, "%d ", + vals[i]); + len += snprintf(&buf[len], PAGE_SIZE - len, "\n"); + return len; + } default: return 0; } @@ -419,14 +431,23 @@ static ssize_t iio_read_channel_info(struct device *dev, { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); - int val, val2; - int ret = indio_dev->info->read_raw(indio_dev, this_attr->c, - &val, &val2, this_attr->address); + int vals[INDIO_MAX_RAW_ELEMENTS]; + int ret; + int val_len = 2; + + if (indio_dev->info->read_raw_multi) + ret = indio_dev->info->read_raw_multi(indio_dev, this_attr->c, + INDIO_MAX_RAW_ELEMENTS, + vals, &val_len, + this_attr->address); + else + ret = indio_dev->info->read_raw(indio_dev, this_attr->c, + &vals[0], &vals[1], this_attr->address); if (ret < 0) return ret; - return iio_format_value(buf, ret, val, val2); + return iio_format_value(buf, ret, val_len, vals); } /** diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c index dddfb0f90d34..258a973a1fb8 100644 --- a/drivers/iio/industrialio-event.c +++ b/drivers/iio/industrialio-event.c @@ -270,7 +270,7 @@ static ssize_t iio_ev_value_show(struct device *dev, { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); - int val, val2; + int val, val2, val_arr[2]; int ret; ret = indio_dev->info->read_event_value(indio_dev, @@ -279,7 +279,9 @@ static ssize_t iio_ev_value_show(struct device *dev, &val, &val2); if (ret < 0) return ret; - return iio_format_value(buf, ret, val, val2); + val_arr[0] = val; + val_arr[1] = val2; + return iio_format_value(buf, ret, 2, val_arr); } static ssize_t iio_ev_value_store(struct device *dev, diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index adeba5a0ecf7..d833d55052ea 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -417,12 +417,24 @@ static int iio_channel_read(struct iio_channel *chan, int *val, int *val2, enum iio_chan_info_enum info) { int unused; + int vals[INDIO_MAX_RAW_ELEMENTS]; + int ret; + int val_len = 2; if (val2 == NULL) val2 = &unused; - return chan->indio_dev->info->read_raw(chan->indio_dev, chan->channel, - val, val2, info); + if (chan->indio_dev->info->read_raw_multi) { + ret = chan->indio_dev->info->read_raw_multi(chan->indio_dev, + chan->channel, INDIO_MAX_RAW_ELEMENTS, + vals, &val_len, info); + *val = vals[0]; + *val2 = vals[1]; + } else + ret = chan->indio_dev->info->read_raw(chan->indio_dev, + chan->channel, val, val2, info); + + return ret; } int iio_read_channel_raw(struct iio_channel *chan, int *val) diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index 5f2d00e7e488..5629c92eeadf 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -288,6 +288,8 @@ static inline s64 iio_get_time_ns(void) #define INDIO_ALL_BUFFER_MODES \ (INDIO_BUFFER_TRIGGERED | INDIO_BUFFER_HARDWARE) +#define INDIO_MAX_RAW_ELEMENTS 4 + struct iio_trigger; /* forward declaration */ struct iio_dev; @@ -302,6 +304,14 @@ struct iio_dev; * the channel in question. Return value will specify the * type of value returned by the device. val and val2 will * contain the elements making up the returned value. + * @read_raw_multi: function to return values from the device. + * mask specifies which value. Note 0 means a reading of + * the channel in question. Return value will specify the + * type of value returned by the device. vals pointer + * contain the elements making up the returned value. + * max_len specifies maximum number of elements + * vals pointer can contain. val_len is used to return + * length of valid elements in vals. * @write_raw: function to write a value to the device. * Parameters are the same as for read_raw. * @write_raw_get_fmt: callback function to query the expected @@ -328,6 +338,13 @@ struct iio_info { int *val2, long mask); + int (*read_raw_multi)(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int max_len, + int *vals, + int *val_len, + long mask); + int (*write_raw)(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int val, diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h index 084d882fe01b..a13c2241abce 100644 --- a/include/linux/iio/types.h +++ b/include/linux/iio/types.h @@ -79,6 +79,7 @@ enum iio_event_direction { #define IIO_VAL_INT_PLUS_MICRO 2 #define IIO_VAL_INT_PLUS_NANO 3 #define IIO_VAL_INT_PLUS_MICRO_DB 4 +#define IIO_VAL_INT_MULTIPLE 5 #define IIO_VAL_FRACTIONAL 10 #define IIO_VAL_FRACTIONAL_LOG2 11 -- cgit v1.2.3 From 0ee8546ac01864b6e12e65199142e00db59c9809 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Tue, 29 Apr 2014 00:51:00 +0100 Subject: IIO: core: Modify scan element type The current scan element type uses the following format: [be|le]:[s|u]bits/storagebits[>>shift]. To specify multiple elements in this type, added a repeat value. So new format is: [be|le]:[s|u]bits/storagebitsXr[>>shift]. Here r is specifying how may times, real/storage bits are repeating. When X is value is 0 or 1, then repeat value is not used in the format, and it will be same as existing format. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-buffer.c | 41 +++++++++++++++++++++++++++++++++------ include/linux/iio/iio.h | 7 +++++++ 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index e472cff6eeae..36b1ae92e239 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -150,7 +150,16 @@ static ssize_t iio_show_fixed_type(struct device *dev, type = IIO_BE; #endif } - return sprintf(buf, "%s:%c%d/%d>>%u\n", + if (this_attr->c->scan_type.repeat > 1) + return sprintf(buf, "%s:%c%d/%dX%d>>%u\n", + iio_endian_prefix[type], + this_attr->c->scan_type.sign, + this_attr->c->scan_type.realbits, + this_attr->c->scan_type.storagebits, + this_attr->c->scan_type.repeat, + this_attr->c->scan_type.shift); + else + return sprintf(buf, "%s:%c%d/%d>>%u\n", iio_endian_prefix[type], this_attr->c->scan_type.sign, this_attr->c->scan_type.realbits, @@ -475,14 +484,22 @@ static int iio_compute_scan_bytes(struct iio_dev *indio_dev, for_each_set_bit(i, mask, indio_dev->masklength) { ch = iio_find_channel_from_si(indio_dev, i); - length = ch->scan_type.storagebits / 8; + if (ch->scan_type.repeat > 1) + length = ch->scan_type.storagebits / 8 * + ch->scan_type.repeat; + else + length = ch->scan_type.storagebits / 8; bytes = ALIGN(bytes, length); bytes += length; } if (timestamp) { ch = iio_find_channel_from_si(indio_dev, indio_dev->scan_index_timestamp); - length = ch->scan_type.storagebits / 8; + if (ch->scan_type.repeat > 1) + length = ch->scan_type.storagebits / 8 * + ch->scan_type.repeat; + else + length = ch->scan_type.storagebits / 8; bytes = ALIGN(bytes, length); bytes += length; } @@ -959,7 +976,11 @@ static int iio_buffer_update_demux(struct iio_dev *indio_dev, indio_dev->masklength, in_ind + 1); ch = iio_find_channel_from_si(indio_dev, in_ind); - length = ch->scan_type.storagebits/8; + if (ch->scan_type.repeat > 1) + length = ch->scan_type.storagebits / 8 * + ch->scan_type.repeat; + else + length = ch->scan_type.storagebits / 8; /* Make sure we are aligned */ in_loc += length; if (in_loc % length) @@ -971,7 +992,11 @@ static int iio_buffer_update_demux(struct iio_dev *indio_dev, goto error_clear_mux_table; } ch = iio_find_channel_from_si(indio_dev, in_ind); - length = ch->scan_type.storagebits/8; + if (ch->scan_type.repeat > 1) + length = ch->scan_type.storagebits / 8 * + ch->scan_type.repeat; + else + length = ch->scan_type.storagebits / 8; if (out_loc % length) out_loc += length - out_loc % length; if (in_loc % length) @@ -992,7 +1017,11 @@ static int iio_buffer_update_demux(struct iio_dev *indio_dev, } ch = iio_find_channel_from_si(indio_dev, indio_dev->scan_index_timestamp); - length = ch->scan_type.storagebits/8; + if (ch->scan_type.repeat > 1) + length = ch->scan_type.storagebits / 8 * + ch->scan_type.repeat; + else + length = ch->scan_type.storagebits / 8; if (out_loc % length) out_loc += length - out_loc % length; if (in_loc % length) diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index 5629c92eeadf..ccde91725f98 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -177,6 +177,12 @@ struct iio_event_spec { * shift: Shift right by this before masking out * realbits. * endianness: little or big endian + * repeat: Number of times real/storage bits + * repeats. When the repeat element is + * more than 1, then the type element in + * sysfs will show a repeat value. + * Otherwise, the number of repetitions is + * omitted. * @info_mask_separate: What information is to be exported that is specific to * this channel. * @info_mask_shared_by_type: What information is to be exported that is shared @@ -219,6 +225,7 @@ struct iio_chan_spec { u8 realbits; u8 storagebits; u8 shift; + u8 repeat; enum iio_endian endianness; } scan_type; long info_mask_separate; -- cgit v1.2.3 From 5082f405b74ad1b69aa9595555ce55b75b59b2ec Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Tue, 29 Apr 2014 00:51:00 +0100 Subject: IIO: core: Add quaternion modifier Added quaternion in the list of supported modifiers. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-core.c | 1 + include/linux/iio/types.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 59540859bfae..de8b1c2ed4b4 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -84,6 +84,7 @@ static const char * const iio_modifier_names[] = { [IIO_MOD_LIGHT_RED] = "red", [IIO_MOD_LIGHT_GREEN] = "green", [IIO_MOD_LIGHT_BLUE] = "blue", + [IIO_MOD_QUATERNION] = "quaternion", }; /* relies on pairs of these shared then separate */ diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h index a13c2241abce..4fdab2e843b4 100644 --- a/include/linux/iio/types.h +++ b/include/linux/iio/types.h @@ -53,6 +53,7 @@ enum iio_modifier { IIO_MOD_LIGHT_RED, IIO_MOD_LIGHT_GREEN, IIO_MOD_LIGHT_BLUE, + IIO_MOD_QUATERNION, }; enum iio_event_type { -- cgit v1.2.3 From fc18dddc0625cd1fdf6a823e85138ff05848a85f Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Tue, 29 Apr 2014 00:51:00 +0100 Subject: iio: hid-sensors: Added device rotation support Added usage id processing for device rotation. This uses IIO interfaces for triggered buffer to present data to user mode.This uses HID sensor framework for registering callback events from the sensor hub. Data is exported to user space in the form of quaternion rotation format. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/orientation/Kconfig | 12 + drivers/iio/orientation/Makefile | 1 + drivers/iio/orientation/hid-sensor-rotation.c | 348 ++++++++++++++++++++++++++ include/linux/hid-sensor-ids.h | 1 + 4 files changed, 362 insertions(+) create mode 100644 drivers/iio/orientation/hid-sensor-rotation.c diff --git a/drivers/iio/orientation/Kconfig b/drivers/iio/orientation/Kconfig index 58c62c837e12..e3aa1e58d920 100644 --- a/drivers/iio/orientation/Kconfig +++ b/drivers/iio/orientation/Kconfig @@ -16,4 +16,16 @@ config HID_SENSOR_INCLINOMETER_3D Say yes here to build support for the HID SENSOR Inclinometer 3D. +config HID_SENSOR_DEVICE_ROTATION + depends on HID_SENSOR_HUB + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER + select HID_SENSOR_IIO_COMMON + select HID_SENSOR_IIO_TRIGGER + tristate "HID Device Rotation" + help + Say yes here to build support for the HID SENSOR + device rotation. The output of a device rotation sensor + is presented using quaternion format. + endmenu diff --git a/drivers/iio/orientation/Makefile b/drivers/iio/orientation/Makefile index 2c97572ee919..4734dabbde13 100644 --- a/drivers/iio/orientation/Makefile +++ b/drivers/iio/orientation/Makefile @@ -4,3 +4,4 @@ # When adding new entries keep the list in alphabetical order obj-$(CONFIG_HID_SENSOR_INCLINOMETER_3D) += hid-sensor-incl-3d.o +obj-$(CONFIG_HID_SENSOR_DEVICE_ROTATION) += hid-sensor-rotation.o diff --git a/drivers/iio/orientation/hid-sensor-rotation.c b/drivers/iio/orientation/hid-sensor-rotation.c new file mode 100644 index 000000000000..51387bbc1ce1 --- /dev/null +++ b/drivers/iio/orientation/hid-sensor-rotation.c @@ -0,0 +1,348 @@ +/* + * HID Sensors Driver + * Copyright (c) 2014, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../common/hid-sensors/hid-sensor-trigger.h" + +struct dev_rot_state { + struct hid_sensor_hub_callbacks callbacks; + struct hid_sensor_common common_attributes; + struct hid_sensor_hub_attribute_info quaternion; + u32 sampled_vals[4]; +}; + +/* Channel definitions */ +static const struct iio_chan_spec dev_rot_channels[] = { + { + .type = IIO_ROT, + .modified = 1, + .channel2 = IIO_MOD_QUATERNION, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ) | + BIT(IIO_CHAN_INFO_HYSTERESIS) + } +}; + +/* Adjust channel real bits based on report descriptor */ +static void dev_rot_adjust_channel_bit_mask(struct iio_chan_spec *chan, + int size) +{ + chan->scan_type.sign = 's'; + /* Real storage bits will change based on the report desc. */ + chan->scan_type.realbits = size * 8; + /* Maximum size of a sample to capture is u32 */ + chan->scan_type.storagebits = sizeof(u32) * 8; + chan->scan_type.repeat = 4; +} + +/* Channel read_raw handler */ +static int dev_rot_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int size, int *vals, int *val_len, + long mask) +{ + struct dev_rot_state *rot_state = iio_priv(indio_dev); + int ret_type; + int i; + + vals[0] = 0; + vals[1] = 0; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + if (size >= 4) { + for (i = 0; i < 4; ++i) + vals[i] = rot_state->sampled_vals[i]; + ret_type = IIO_VAL_INT_MULTIPLE; + *val_len = 4; + } else + ret_type = -EINVAL; + break; + case IIO_CHAN_INFO_SAMP_FREQ: + ret_type = hid_sensor_read_samp_freq_value( + &rot_state->common_attributes, &vals[0], &vals[1]); + break; + case IIO_CHAN_INFO_HYSTERESIS: + ret_type = hid_sensor_read_raw_hyst_value( + &rot_state->common_attributes, &vals[0], &vals[1]); + break; + default: + ret_type = -EINVAL; + break; + } + + return ret_type; +} + +/* Channel write_raw handler */ +static int dev_rot_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, + int val2, + long mask) +{ + struct dev_rot_state *rot_state = iio_priv(indio_dev); + int ret; + + switch (mask) { + case IIO_CHAN_INFO_SAMP_FREQ: + ret = hid_sensor_write_samp_freq_value( + &rot_state->common_attributes, val, val2); + break; + case IIO_CHAN_INFO_HYSTERESIS: + ret = hid_sensor_write_raw_hyst_value( + &rot_state->common_attributes, val, val2); + break; + default: + ret = -EINVAL; + } + + return ret; +} + +static const struct iio_info dev_rot_info = { + .driver_module = THIS_MODULE, + .read_raw_multi = &dev_rot_read_raw, + .write_raw = &dev_rot_write_raw, +}; + +/* Function to push data to buffer */ +static void hid_sensor_push_data(struct iio_dev *indio_dev, u8 *data, int len) +{ + dev_dbg(&indio_dev->dev, "hid_sensor_push_data >>\n"); + iio_push_to_buffers(indio_dev, (u8 *)data); + dev_dbg(&indio_dev->dev, "hid_sensor_push_data <<\n"); + +} + +/* Callback handler to send event after all samples are received and captured */ +static int dev_rot_proc_event(struct hid_sensor_hub_device *hsdev, + unsigned usage_id, + void *priv) +{ + struct iio_dev *indio_dev = platform_get_drvdata(priv); + struct dev_rot_state *rot_state = iio_priv(indio_dev); + + dev_dbg(&indio_dev->dev, "dev_rot_proc_event [%d]\n", + rot_state->common_attributes.data_ready); + + if (rot_state->common_attributes.data_ready) + hid_sensor_push_data(indio_dev, + (u8 *)rot_state->sampled_vals, + sizeof(rot_state->sampled_vals)); + + return 0; +} + +/* Capture samples in local storage */ +static int dev_rot_capture_sample(struct hid_sensor_hub_device *hsdev, + unsigned usage_id, + size_t raw_len, char *raw_data, + void *priv) +{ + struct iio_dev *indio_dev = platform_get_drvdata(priv); + struct dev_rot_state *rot_state = iio_priv(indio_dev); + + if (usage_id == HID_USAGE_SENSOR_ORIENT_QUATERNION) { + memcpy(rot_state->sampled_vals, raw_data, + sizeof(rot_state->sampled_vals)); + dev_dbg(&indio_dev->dev, "Recd Quat len:%zu::%zu\n", raw_len, + sizeof(rot_state->sampled_vals)); + } + + return 0; +} + +/* Parse report which is specific to an usage id*/ +static int dev_rot_parse_report(struct platform_device *pdev, + struct hid_sensor_hub_device *hsdev, + struct iio_chan_spec *channels, + unsigned usage_id, + struct dev_rot_state *st) +{ + int ret; + + ret = sensor_hub_input_get_attribute_info(hsdev, + HID_INPUT_REPORT, + usage_id, + HID_USAGE_SENSOR_ORIENT_QUATERNION, + &st->quaternion); + if (ret) + return ret; + + dev_rot_adjust_channel_bit_mask(&channels[0], + st->quaternion.size / 4); + + dev_dbg(&pdev->dev, "dev_rot %x:%x\n", st->quaternion.index, + st->quaternion.report_id); + + dev_dbg(&pdev->dev, "dev_rot: attrib size %d\n", + st->quaternion.size); + + /* Set Sensitivity field ids, when there is no individual modifier */ + if (st->common_attributes.sensitivity.index < 0) { + sensor_hub_input_get_attribute_info(hsdev, + HID_FEATURE_REPORT, usage_id, + HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS | + HID_USAGE_SENSOR_DATA_ORIENTATION, + &st->common_attributes.sensitivity); + dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n", + st->common_attributes.sensitivity.index, + st->common_attributes.sensitivity.report_id); + } + + return 0; +} + +/* Function to initialize the processing for usage id */ +static int hid_dev_rot_probe(struct platform_device *pdev) +{ + int ret; + static char *name = "dev_rotation"; + struct iio_dev *indio_dev; + struct dev_rot_state *rot_state; + struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; + struct iio_chan_spec *channels; + + indio_dev = devm_iio_device_alloc(&pdev->dev, + sizeof(struct dev_rot_state)); + if (indio_dev == NULL) + return -ENOMEM; + + platform_set_drvdata(pdev, indio_dev); + + rot_state = iio_priv(indio_dev); + rot_state->common_attributes.hsdev = hsdev; + rot_state->common_attributes.pdev = pdev; + + ret = hid_sensor_parse_common_attributes(hsdev, + HID_USAGE_SENSOR_DEVICE_ORIENTATION, + &rot_state->common_attributes); + if (ret) { + dev_err(&pdev->dev, "failed to setup common attributes\n"); + return ret; + } + + channels = devm_kmemdup(&pdev->dev, dev_rot_channels, + sizeof(dev_rot_channels), GFP_KERNEL); + if (!channels) { + dev_err(&pdev->dev, "failed to duplicate channels\n"); + return -ENOMEM; + } + + ret = dev_rot_parse_report(pdev, hsdev, channels, + HID_USAGE_SENSOR_DEVICE_ORIENTATION, rot_state); + if (ret) { + dev_err(&pdev->dev, "failed to setup attributes\n"); + return ret; + } + + indio_dev->channels = channels; + indio_dev->num_channels = ARRAY_SIZE(dev_rot_channels); + indio_dev->dev.parent = &pdev->dev; + indio_dev->info = &dev_rot_info; + indio_dev->name = name; + indio_dev->modes = INDIO_DIRECT_MODE; + + ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time, + NULL, NULL); + if (ret) { + dev_err(&pdev->dev, "failed to initialize trigger buffer\n"); + return ret; + } + rot_state->common_attributes.data_ready = false; + ret = hid_sensor_setup_trigger(indio_dev, name, + &rot_state->common_attributes); + if (ret) { + dev_err(&pdev->dev, "trigger setup failed\n"); + goto error_unreg_buffer_funcs; + } + + ret = iio_device_register(indio_dev); + if (ret) { + dev_err(&pdev->dev, "device register failed\n"); + goto error_remove_trigger; + } + + rot_state->callbacks.send_event = dev_rot_proc_event; + rot_state->callbacks.capture_sample = dev_rot_capture_sample; + rot_state->callbacks.pdev = pdev; + ret = sensor_hub_register_callback(hsdev, + HID_USAGE_SENSOR_DEVICE_ORIENTATION, + &rot_state->callbacks); + if (ret) { + dev_err(&pdev->dev, "callback reg failed\n"); + goto error_iio_unreg; + } + + return 0; + +error_iio_unreg: + iio_device_unregister(indio_dev); +error_remove_trigger: + hid_sensor_remove_trigger(&rot_state->common_attributes); +error_unreg_buffer_funcs: + iio_triggered_buffer_cleanup(indio_dev); + return ret; +} + +/* Function to deinitialize the processing for usage id */ +static int hid_dev_rot_remove(struct platform_device *pdev) +{ + struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; + struct iio_dev *indio_dev = platform_get_drvdata(pdev); + struct dev_rot_state *rot_state = iio_priv(indio_dev); + + sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_DEVICE_ORIENTATION); + iio_device_unregister(indio_dev); + hid_sensor_remove_trigger(&rot_state->common_attributes); + iio_triggered_buffer_cleanup(indio_dev); + + return 0; +} + +static struct platform_device_id hid_dev_rot_ids[] = { + { + /* Format: HID-SENSOR-usage_id_in_hex_lowercase */ + .name = "HID-SENSOR-20008a", + }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(platform, hid_dev_rot_ids); + +static struct platform_driver hid_dev_rot_platform_driver = { + .id_table = hid_dev_rot_ids, + .driver = { + .name = KBUILD_MODNAME, + .owner = THIS_MODULE, + }, + .probe = hid_dev_rot_probe, + .remove = hid_dev_rot_remove, +}; +module_platform_driver(hid_dev_rot_platform_driver); + +MODULE_DESCRIPTION("HID Sensor Device Rotation"); +MODULE_AUTHOR("Srinivas Pandruvada "); +MODULE_LICENSE("GPL"); diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h index 14ead9e8eda8..109f0e633e01 100644 --- a/include/linux/hid-sensor-ids.h +++ b/include/linux/hid-sensor-ids.h @@ -76,6 +76,7 @@ #define HID_USAGE_SENSOR_ORIENT_TILT_Y 0x200480 #define HID_USAGE_SENSOR_ORIENT_TILT_Z 0x200481 +#define HID_USAGE_SENSOR_DEVICE_ORIENTATION 0x20008A #define HID_USAGE_SENSOR_ORIENT_ROTATION_MATRIX 0x200482 #define HID_USAGE_SENSOR_ORIENT_QUATERNION 0x200483 #define HID_USAGE_SENSOR_ORIENT_MAGN_FLUX 0x200484 -- cgit v1.2.3 From b4a2d475ae9baf8fcaa311ba62a404ba1efad147 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Tue, 29 Apr 2014 00:51:00 +0100 Subject: iio: Added ABI description for quaternion Added documentation for reading quaternion components for 3D rotations. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index 58ba33300305..6b74691dc281 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -792,6 +792,7 @@ What: /sys/.../iio:deviceX/scan_elements/in_incli_x_en What: /sys/.../iio:deviceX/scan_elements/in_incli_y_en What: /sys/.../iio:deviceX/scan_elements/in_pressureY_en What: /sys/.../iio:deviceX/scan_elements/in_pressure_en +What: /sys/.../iio:deviceX/scan_elements/in_rot_quaternion_en KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: @@ -807,6 +808,7 @@ What: /sys/.../iio:deviceX/scan_elements/in_voltageY_supply_type What: /sys/.../iio:deviceX/scan_elements/in_timestamp_type What: /sys/.../iio:deviceX/scan_elements/in_pressureY_type What: /sys/.../iio:deviceX/scan_elements/in_pressure_type +What: /sys/.../iio:deviceX/scan_elements/in_rot_quaternion_type KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: @@ -853,6 +855,7 @@ What: /sys/.../iio:deviceX/scan_elements/in_incli_y_index What: /sys/.../iio:deviceX/scan_elements/in_timestamp_index What: /sys/.../iio:deviceX/scan_elements/in_pressureY_index What: /sys/.../iio:deviceX/scan_elements/in_pressure_index +What: /sys/.../iio:deviceX/scan_elements/in_rot_quaternion_index KernelVersion: 2.6.37 Contact: linux-iio@vger.kernel.org Description: @@ -899,3 +902,12 @@ Contact: linux-iio@vger.kernel.org Description: This attribute is used to get/set the integration time in seconds. + +What: /sys/bus/iio/devices/iio:deviceX/in_rot_quaternion_raw +KernelVersion: 3.15 +Contact: linux-iio@vger.kernel.org +Description: + Raw value of quaternion components using a format + x y z w. Here x, y, and z component represents the axis about + which a rotation will occur and w component represents the + amount of rotation. -- cgit v1.2.3 From 2bbc7247259f0d27c84b0e0746bd5e9831e39c36 Mon Sep 17 00:00:00 2001 From: Naveen Krishna Ch Date: Wed, 30 Apr 2014 10:26:00 +0100 Subject: iio: exynos_adc: rearrange clk and regulator enable/disable calls This patch maintains the following order in probe(), remove(), resume() and suspend() calls regulator enable, clk prepare enable ... clk disable unprepare, regulator disable While at it, 1. enable the regulator before the iio_device_register() 2. handle the return values for enable/disable calls Signed-off-by: Naveen Krishna Ch Reviewed-by: Doug Anderson Signed-off-by: Jonathan Cameron --- drivers/iio/adc/exynos_adc.c | 62 +++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c index d25b262193a7..9d296094892d 100644 --- a/drivers/iio/adc/exynos_adc.c +++ b/drivers/iio/adc/exynos_adc.c @@ -290,32 +290,30 @@ static int exynos_adc_probe(struct platform_device *pdev) init_completion(&info->completion); - ret = request_irq(info->irq, exynos_adc_isr, - 0, dev_name(&pdev->dev), info); - if (ret < 0) { - dev_err(&pdev->dev, "failed requesting irq, irq = %d\n", - info->irq); - return ret; - } - - writel(1, info->enable_reg); - info->clk = devm_clk_get(&pdev->dev, "adc"); if (IS_ERR(info->clk)) { dev_err(&pdev->dev, "failed getting clock, err = %ld\n", PTR_ERR(info->clk)); - ret = PTR_ERR(info->clk); - goto err_irq; + return PTR_ERR(info->clk); } info->vdd = devm_regulator_get(&pdev->dev, "vdd"); if (IS_ERR(info->vdd)) { dev_err(&pdev->dev, "failed getting regulator, err = %ld\n", PTR_ERR(info->vdd)); - ret = PTR_ERR(info->vdd); - goto err_irq; + return PTR_ERR(info->vdd); } + ret = regulator_enable(info->vdd); + if (ret) + return ret; + + ret = clk_prepare_enable(info->clk); + if (ret) + goto err_disable_reg; + + writel(1, info->enable_reg); + info->version = exynos_adc_get_version(pdev); platform_set_drvdata(pdev, indio_dev); @@ -332,16 +330,18 @@ static int exynos_adc_probe(struct platform_device *pdev) else indio_dev->num_channels = MAX_ADC_V2_CHANNELS; + ret = request_irq(info->irq, exynos_adc_isr, + 0, dev_name(&pdev->dev), info); + if (ret < 0) { + dev_err(&pdev->dev, "failed requesting irq, irq = %d\n", + info->irq); + goto err_disable_clk; + } + ret = iio_device_register(indio_dev); if (ret) goto err_irq; - ret = regulator_enable(info->vdd); - if (ret) - goto err_iio_dev; - - clk_prepare_enable(info->clk); - exynos_adc_hw_init(info); ret = of_platform_populate(np, exynos_adc_match, NULL, &pdev->dev); @@ -355,12 +355,14 @@ static int exynos_adc_probe(struct platform_device *pdev) err_of_populate: device_for_each_child(&pdev->dev, NULL, exynos_adc_remove_devices); - regulator_disable(info->vdd); - clk_disable_unprepare(info->clk); -err_iio_dev: iio_device_unregister(indio_dev); err_irq: free_irq(info->irq, info); +err_disable_clk: + writel(0, info->enable_reg); + clk_disable_unprepare(info->clk); +err_disable_reg: + regulator_disable(info->vdd); return ret; } @@ -371,11 +373,11 @@ static int exynos_adc_remove(struct platform_device *pdev) device_for_each_child(&pdev->dev, NULL, exynos_adc_remove_devices); - regulator_disable(info->vdd); - clk_disable_unprepare(info->clk); - writel(0, info->enable_reg); iio_device_unregister(indio_dev); free_irq(info->irq, info); + writel(0, info->enable_reg); + clk_disable_unprepare(info->clk); + regulator_disable(info->vdd); return 0; } @@ -397,8 +399,8 @@ static int exynos_adc_suspend(struct device *dev) writel(con, ADC_V1_CON(info->regs)); } - clk_disable_unprepare(info->clk); writel(0, info->enable_reg); + clk_disable_unprepare(info->clk); regulator_disable(info->vdd); return 0; @@ -414,9 +416,11 @@ static int exynos_adc_resume(struct device *dev) if (ret) return ret; - writel(1, info->enable_reg); - clk_prepare_enable(info->clk); + ret = clk_prepare_enable(info->clk); + if (ret) + return ret; + writel(1, info->enable_reg); exynos_adc_hw_init(info); return 0; -- cgit v1.2.3 From c780a8c2415b21514b0a8b5398d7167c93627c64 Mon Sep 17 00:00:00 2001 From: Naveen Krishna Chatradhi Date: Wed, 30 Apr 2014 10:26:00 +0100 Subject: iio: exynos_adc: reduce timeout and use wait_for_completion_timeout ADC module on Exynos5 SoCs runs at 600KSPS. At this conversion rate, waiting for 1000 msecs is wasteful (incase of h/w failure). Hence, reduce the time out to 100msecs and use wait_for_completion_timeout() instead of wait_for_completion_interruptible_timeout() Signed-off-by: Naveen Krishna Chatradhi Reviewed-by: Doug Anderson Signed-off-by: Jonathan Cameron --- drivers/iio/adc/exynos_adc.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c index 9d296094892d..a1f6d90f3d26 100644 --- a/drivers/iio/adc/exynos_adc.c +++ b/drivers/iio/adc/exynos_adc.c @@ -82,7 +82,7 @@ enum adc_version { #define ADC_CON_EN_START (1u << 0) #define ADC_DATX_MASK 0xFFF -#define EXYNOS_ADC_TIMEOUT (msecs_to_jiffies(1000)) +#define EXYNOS_ADC_TIMEOUT (msecs_to_jiffies(100)) struct exynos_adc { void __iomem *regs; @@ -121,6 +121,7 @@ static int exynos_read_raw(struct iio_dev *indio_dev, struct exynos_adc *info = iio_priv(indio_dev); unsigned long timeout; u32 con1, con2; + int ret; if (mask != IIO_CHAN_INFO_RAW) return -EINVAL; @@ -145,16 +146,19 @@ static int exynos_read_raw(struct iio_dev *indio_dev, ADC_V1_CON(info->regs)); } - timeout = wait_for_completion_interruptible_timeout + timeout = wait_for_completion_timeout (&info->completion, EXYNOS_ADC_TIMEOUT); - *val = info->value; + if (timeout == 0) { + ret = -ETIMEDOUT; + } else { + *val = info->value; + *val2 = 0; + ret = IIO_VAL_INT; + } mutex_unlock(&indio_dev->mlock); - if (timeout == 0) - return -ETIMEDOUT; - - return IIO_VAL_INT; + return ret; } static irqreturn_t exynos_adc_isr(int irq, void *dev_id) -- cgit v1.2.3 From dd2723f57e3cd8f104884636e92492b884080d59 Mon Sep 17 00:00:00 2001 From: Naveen Krishna Chatradhi Date: Wed, 30 Apr 2014 10:26:00 +0100 Subject: iio: exynos_adc: do a soft reset in case of timeout Do a soft reset software if a timeout happens. This is applicable only for ADC_V2. Signed-off-by: Naveen Krishna Chatradhi Reviewed-by: Doug Anderson Signed-off-by: Jonathan Cameron --- drivers/iio/adc/exynos_adc.c | 50 +++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c index a1f6d90f3d26..a9946ec7a3b7 100644 --- a/drivers/iio/adc/exynos_adc.c +++ b/drivers/iio/adc/exynos_adc.c @@ -112,6 +112,30 @@ static inline unsigned int exynos_adc_get_version(struct platform_device *pdev) return (unsigned int)match->data; } +static void exynos_adc_hw_init(struct exynos_adc *info) +{ + u32 con1, con2; + + if (info->version == ADC_V2) { + con1 = ADC_V2_CON1_SOFT_RESET; + writel(con1, ADC_V2_CON1(info->regs)); + + con2 = ADC_V2_CON2_OSEL | ADC_V2_CON2_ESEL | + ADC_V2_CON2_HIGHF | ADC_V2_CON2_C_TIME(0); + writel(con2, ADC_V2_CON2(info->regs)); + + /* Enable interrupts */ + writel(1, ADC_V2_INT_EN(info->regs)); + } else { + /* set default prescaler values and Enable prescaler */ + con1 = ADC_V1_CON_PRSCLV(49) | ADC_V1_CON_PRSCEN; + + /* Enable 12-bit ADC resolution */ + con1 |= ADC_V1_CON_RES; + writel(con1, ADC_V1_CON(info->regs)); + } +} + static int exynos_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, @@ -149,6 +173,8 @@ static int exynos_read_raw(struct iio_dev *indio_dev, timeout = wait_for_completion_timeout (&info->completion, EXYNOS_ADC_TIMEOUT); if (timeout == 0) { + dev_warn(&indio_dev->dev, "Conversion timed out! Resetting\n"); + exynos_adc_hw_init(info); ret = -ETIMEDOUT; } else { *val = info->value; @@ -230,30 +256,6 @@ static int exynos_adc_remove_devices(struct device *dev, void *c) return 0; } -static void exynos_adc_hw_init(struct exynos_adc *info) -{ - u32 con1, con2; - - if (info->version == ADC_V2) { - con1 = ADC_V2_CON1_SOFT_RESET; - writel(con1, ADC_V2_CON1(info->regs)); - - con2 = ADC_V2_CON2_OSEL | ADC_V2_CON2_ESEL | - ADC_V2_CON2_HIGHF | ADC_V2_CON2_C_TIME(0); - writel(con2, ADC_V2_CON2(info->regs)); - - /* Enable interrupts */ - writel(1, ADC_V2_INT_EN(info->regs)); - } else { - /* set default prescaler values and Enable prescaler */ - con1 = ADC_V1_CON_PRSCLV(49) | ADC_V1_CON_PRSCEN; - - /* Enable 12-bit ADC resolution */ - con1 |= ADC_V1_CON_RES; - writel(con1, ADC_V1_CON(info->regs)); - } -} - static int exynos_adc_probe(struct platform_device *pdev) { struct exynos_adc *info = NULL; -- cgit v1.2.3 From 6442d94ba19da5424d670f4a4523be45e1ee78d9 Mon Sep 17 00:00:00 2001 From: Naveen Krishna Chatradhi Date: Wed, 30 Apr 2014 10:26:00 +0100 Subject: iio: exynos_adc: do a reinit_completion before the conversion Add reinit_completion() before the wait_for_completion_timeout in raw_read() call. Signed-off-by: Naveen Krishna Chatradhi Reviewed-by: Doug Anderson Signed-off-by: Jonathan Cameron --- drivers/iio/adc/exynos_adc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c index a9946ec7a3b7..d325aeafe5cb 100644 --- a/drivers/iio/adc/exynos_adc.c +++ b/drivers/iio/adc/exynos_adc.c @@ -151,6 +151,7 @@ static int exynos_read_raw(struct iio_dev *indio_dev, return -EINVAL; mutex_lock(&indio_dev->mlock); + reinit_completion(&info->completion); /* Select the channel to be used and Trigger conversion */ if (info->version == ADC_V2) { -- cgit v1.2.3 From fd8122d12858132aa9684f2b979107a1f4bba139 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Mon, 28 Apr 2014 17:00:00 +0100 Subject: staging: iio: Fix format string mismatch in ad7280a.c Fix two format string mismatch in ad7280a.c Signed-off-by: Masanari Iida Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/ad7280a.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index 1ac11f64827c..d215edf66af2 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -443,7 +443,7 @@ static ssize_t ad7280_show_balance_timer(struct device *dev, msecs = (ret >> 3) * 71500; - return sprintf(buf, "%d\n", msecs); + return sprintf(buf, "%u\n", msecs); } static ssize_t ad7280_store_balance_timer(struct device *dev, @@ -619,7 +619,7 @@ static ssize_t ad7280_read_channel_config(struct device *dev, return -EINVAL; } - return sprintf(buf, "%d\n", val); + return sprintf(buf, "%u\n", val); } static ssize_t ad7280_write_channel_config(struct device *dev, -- cgit v1.2.3 From 82a5803c782417754bdebb8dfa34edc62c0d8bbc Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 30 Apr 2014 22:05:00 +0100 Subject: staging: iio: ad799x: remove some unneeded IS_ERR() checks My static checker is upset that we check IS_ERR(t->reg) when we know it is not an ERR_PTR. Checking for IS_ERR() twice is often a sign of confusion and buggy code. In this case, if the call to "ret = regulator_enable(st->vref);" fails, then we call "regulator_disable(st->vref);" and that's a mistake because "st->vref" is not enabled. I fixed these problems and Hartmut Knaack pointed out a couple unneeded IS_ERR() checks in ad799x_remove() so I have removed those as well. Signed-off-by: Dan Carpenter Acked-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad799x.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c index 16a8b14b1921..39b4cb48d738 100644 --- a/drivers/iio/adc/ad799x.c +++ b/drivers/iio/adc/ad799x.c @@ -717,7 +717,7 @@ static int ad799x_probe(struct i2c_client *client, ret = iio_triggered_buffer_setup(indio_dev, NULL, &ad799x_trigger_handler, NULL); if (ret) - goto error_disable_reg; + goto error_disable_vref; if (client->irq > 0) { ret = devm_request_threaded_irq(&client->dev, @@ -739,11 +739,10 @@ static int ad799x_probe(struct i2c_client *client, error_cleanup_ring: iio_triggered_buffer_cleanup(indio_dev); +error_disable_vref: + regulator_disable(st->vref); error_disable_reg: - if (!IS_ERR(st->vref)) - regulator_disable(st->vref); - if (!IS_ERR(st->reg)) - regulator_disable(st->reg); + regulator_disable(st->reg); return ret; } @@ -756,10 +755,8 @@ static int ad799x_remove(struct i2c_client *client) iio_device_unregister(indio_dev); iio_triggered_buffer_cleanup(indio_dev); - if (!IS_ERR(st->vref)) - regulator_disable(st->vref); - if (!IS_ERR(st->reg)) - regulator_disable(st->reg); + regulator_disable(st->vref); + regulator_disable(st->reg); kfree(st->rx_buf); return 0; -- cgit v1.2.3 From 6584891bd0607ec7c67868b82d221bef67558962 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Wed, 5 Feb 2014 09:09:00 +0000 Subject: iio:magnetometer:mag3110: Fix initialization of ctrl_reg1 DR bits need to be shifted; since MAG3110_CTRL_DR_DEFAULT is zero, the change has no effect Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/mag3110.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/magnetometer/mag3110.c b/drivers/iio/magnetometer/mag3110.c index 8b77782474d7..1b2df75d07d0 100644 --- a/drivers/iio/magnetometer/mag3110.c +++ b/drivers/iio/magnetometer/mag3110.c @@ -338,7 +338,7 @@ static int mag3110_probe(struct i2c_client *client, indio_dev->num_channels = ARRAY_SIZE(mag3110_channels); indio_dev->available_scan_masks = mag3110_scan_masks; - data->ctrl_reg1 = MAG3110_CTRL_DR_DEFAULT; + data->ctrl_reg1 = MAG3110_CTRL_DR_DEFAULT << MAG3110_CTRL_DR_SHIFT; ret = i2c_smbus_write_byte_data(client, MAG3110_CTRL_REG1, data->ctrl_reg1); if (ret < 0) -- cgit v1.2.3 From 0828eddc56d38b70f9a9e5cf7a0050328a90e7a1 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Wed, 5 Feb 2014 09:09:00 +0000 Subject: iio:magnetometer:mag3110: Enable user offset calibration add IIO_CHAN_INFO_CALIBBIAS Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/mag3110.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/iio/magnetometer/mag3110.c b/drivers/iio/magnetometer/mag3110.c index 1b2df75d07d0..e3106b43ef48 100644 --- a/drivers/iio/magnetometer/mag3110.c +++ b/drivers/iio/magnetometer/mag3110.c @@ -199,6 +199,13 @@ static int mag3110_read_raw(struct iio_dev *indio_dev, *val = mag3110_samp_freq[i][0]; *val2 = mag3110_samp_freq[i][1]; return IIO_VAL_INT_PLUS_MICRO; + case IIO_CHAN_INFO_CALIBBIAS: + ret = i2c_smbus_read_word_swapped(data->client, + MAG3110_OFF_X + 2 * chan->scan_index); + if (ret < 0) + return ret; + *val = sign_extend32(ret >> 1, 14); + return IIO_VAL_INT; } return -EINVAL; } @@ -223,6 +230,11 @@ static int mag3110_write_raw(struct iio_dev *indio_dev, data->ctrl_reg1 |= rate << MAG3110_CTRL_DR_SHIFT; return i2c_smbus_write_byte_data(data->client, MAG3110_CTRL_REG1, data->ctrl_reg1); + case IIO_CHAN_INFO_CALIBBIAS: + if (val < -10000 || val > 10000) + return -EINVAL; + return i2c_smbus_write_word_swapped(data->client, + MAG3110_OFF_X + 2 * chan->scan_index, val << 1); default: return -EINVAL; } @@ -260,7 +272,8 @@ done: .type = IIO_MAGN, \ .modified = 1, \ .channel2 = IIO_MOD_##axis, \ - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ + BIT(IIO_CHAN_INFO_CALIBBIAS), \ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ) | \ BIT(IIO_CHAN_INFO_SCALE), \ .scan_index = idx, \ @@ -345,7 +358,7 @@ static int mag3110_probe(struct i2c_client *client, return ret; ret = i2c_smbus_write_byte_data(client, MAG3110_CTRL_REG2, - MAG3110_CTRL_AUTO_MRST_EN | MAG3110_CTRL_RAW); + MAG3110_CTRL_AUTO_MRST_EN); if (ret < 0) return ret; -- cgit v1.2.3 From 3017d90e8931fbd5dbde06b4e793aebb141e4977 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Wed, 5 Feb 2014 16:58:00 +0000 Subject: iio: Add Freescale MPL115A2 pressure / temperature sensor driver I2C-controlled sensor with 10-bit pressure and temperature measurement datasheet: http://cache.freescale.com/files/sensors/doc/data_sheet/MPL3115A2.pdf v2: * use devm_iio_device_register() Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/Kconfig | 10 ++ drivers/iio/pressure/Makefile | 1 + drivers/iio/pressure/mpl115.c | 211 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 222 insertions(+) create mode 100644 drivers/iio/pressure/mpl115.c diff --git a/drivers/iio/pressure/Kconfig b/drivers/iio/pressure/Kconfig index d88ff17fedb2..ffac8ac1efca 100644 --- a/drivers/iio/pressure/Kconfig +++ b/drivers/iio/pressure/Kconfig @@ -19,6 +19,16 @@ config HID_SENSOR_PRESS To compile this driver as a module, choose M here: the module will be called hid-sensor-press. +config MPL115 + tristate "Freescale MPL115A2 pressure sensor driver" + depends on I2C + help + Say yes here to build support for the Freescale MPL115A2 + pressure sensor connected via I2C. + + To compile this driver as a module, choose M here: the module + will be called mpl115. + config MPL3115 tristate "Freescale MPL3115A2 pressure sensor driver" depends on I2C diff --git a/drivers/iio/pressure/Makefile b/drivers/iio/pressure/Makefile index 4a57bf65b04b..c53d2500737a 100644 --- a/drivers/iio/pressure/Makefile +++ b/drivers/iio/pressure/Makefile @@ -4,6 +4,7 @@ # When adding new entries keep the list in alphabetical order obj-$(CONFIG_HID_SENSOR_PRESS) += hid-sensor-press.o +obj-$(CONFIG_MPL115) += mpl115.o obj-$(CONFIG_MPL3115) += mpl3115.o obj-$(CONFIG_IIO_ST_PRESS) += st_pressure.o st_pressure-y := st_pressure_core.o diff --git a/drivers/iio/pressure/mpl115.c b/drivers/iio/pressure/mpl115.c new file mode 100644 index 000000000000..f5ecd6e19f5d --- /dev/null +++ b/drivers/iio/pressure/mpl115.c @@ -0,0 +1,211 @@ +/* + * mpl115.c - Support for Freescale MPL115A2 pressure/temperature sensor + * + * Copyright (c) 2014 Peter Meerwald + * + * This file is subject to the terms and conditions of version 2 of + * the GNU General Public License. See the file COPYING in the main + * directory of this archive for more details. + * + * (7-bit I2C slave address 0x60) + * + * TODO: shutdown pin + * + */ + +#include +#include +#include +#include + +#define MPL115_PADC 0x00 /* pressure ADC output value, MSB first, 10 bit */ +#define MPL115_TADC 0x02 /* temperature ADC output value, MSB first, 10 bit */ +#define MPL115_A0 0x04 /* 12 bit integer, 3 bit fraction */ +#define MPL115_B1 0x06 /* 2 bit integer, 13 bit fraction */ +#define MPL115_B2 0x08 /* 1 bit integer, 14 bit fraction */ +#define MPL115_C12 0x0a /* 0 bit integer, 13 bit fraction */ +#define MPL115_CONVERT 0x12 /* convert temperature and pressure */ + +struct mpl115_data { + struct i2c_client *client; + struct mutex lock; + s16 a0; + s16 b1, b2; + s16 c12; +}; + +static int mpl115_request(struct mpl115_data *data) +{ + int ret = i2c_smbus_write_byte_data(data->client, MPL115_CONVERT, 0); + if (ret < 0) + return ret; + + usleep_range(3000, 4000); + + return 0; +} + +static int mpl115_comp_pressure(struct mpl115_data *data, int *val, int *val2) +{ + int ret; + u16 padc, tadc; + int a1, y1, pcomp; + unsigned kpa; + + mutex_lock(&data->lock); + ret = mpl115_request(data); + if (ret < 0) + goto done; + + ret = i2c_smbus_read_word_swapped(data->client, MPL115_PADC); + if (ret < 0) + goto done; + padc = ret >> 6; + + ret = i2c_smbus_read_word_swapped(data->client, MPL115_TADC); + if (ret < 0) + goto done; + tadc = ret >> 6; + + /* see Freescale AN3785 */ + a1 = data->b1 + ((data->c12 * tadc) >> 11); + y1 = (data->a0 << 10) + a1 * padc; + + /* compensated pressure with 4 fractional bits */ + pcomp = (y1 + ((data->b2 * (int) tadc) >> 1)) >> 9; + + kpa = pcomp * (115 - 50) / 1023 + (50 << 4); + *val = kpa >> 4; + *val2 = (kpa & 15) * (1000000 >> 4); +done: + mutex_unlock(&data->lock); + return ret; +} + +static int mpl115_read_temp(struct mpl115_data *data) +{ + int ret; + + mutex_lock(&data->lock); + ret = mpl115_request(data); + if (ret < 0) + goto done; + ret = i2c_smbus_read_word_swapped(data->client, MPL115_TADC); +done: + mutex_unlock(&data->lock); + return ret; +} + +static int mpl115_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + struct mpl115_data *data = iio_priv(indio_dev); + int ret; + + switch (mask) { + case IIO_CHAN_INFO_PROCESSED: + ret = mpl115_comp_pressure(data, val, val2); + if (ret < 0) + return ret; + return IIO_VAL_INT_PLUS_MICRO; + case IIO_CHAN_INFO_RAW: + /* temperature -5.35 C / LSB, 472 LSB is 25 C */ + ret = mpl115_read_temp(data); + if (ret < 0) + return ret; + *val = ret >> 6; + return IIO_VAL_INT; + case IIO_CHAN_INFO_OFFSET: + *val = 605; + *val2 = 750000; + return IIO_VAL_INT_PLUS_MICRO; + case IIO_CHAN_INFO_SCALE: + *val = -186; + *val2 = 915888; + return IIO_VAL_INT_PLUS_MICRO; + } + return -EINVAL; +} + +static const struct iio_chan_spec mpl115_channels[] = { + { + .type = IIO_PRESSURE, + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), + }, + { + .type = IIO_TEMP, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE), + }, +}; + +static const struct iio_info mpl115_info = { + .read_raw = &mpl115_read_raw, + .driver_module = THIS_MODULE, +}; + +static int mpl115_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct mpl115_data *data; + struct iio_dev *indio_dev; + int ret; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA)) + return -ENODEV; + + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); + if (!indio_dev) + return -ENOMEM; + + data = iio_priv(indio_dev); + data->client = client; + mutex_init(&data->lock); + + i2c_set_clientdata(client, indio_dev); + indio_dev->info = &mpl115_info; + indio_dev->name = id->name; + indio_dev->dev.parent = &client->dev; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = mpl115_channels; + indio_dev->num_channels = ARRAY_SIZE(mpl115_channels); + + ret = i2c_smbus_read_word_swapped(data->client, MPL115_A0); + if (ret < 0) + return ret; + data->a0 = ret; + ret = i2c_smbus_read_word_swapped(data->client, MPL115_B1); + if (ret < 0) + return ret; + data->b1 = ret; + ret = i2c_smbus_read_word_swapped(data->client, MPL115_B2); + if (ret < 0) + return ret; + data->b2 = ret; + ret = i2c_smbus_read_word_swapped(data->client, MPL115_C12); + if (ret < 0) + return ret; + data->c12 = ret; + + return devm_iio_device_register(&client->dev, indio_dev); +} + +static const struct i2c_device_id mpl115_id[] = { + { "mpl115", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, mpl115_id); + +static struct i2c_driver mpl115_driver = { + .driver = { + .name = "mpl115", + }, + .probe = mpl115_probe, + .id_table = mpl115_id, +}; +module_i2c_driver(mpl115_driver); + +MODULE_AUTHOR("Peter Meerwald "); +MODULE_DESCRIPTION("Freescale MPL115 pressure/temperature driver"); +MODULE_LICENSE("GPL"); -- cgit v1.2.3 From 638b43b347216bab1a989b036a92eb7d9d9ee421 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Wed, 5 Feb 2014 16:57:00 +0000 Subject: iio: Add TEMP_AMBIENT and TEMP_OBJECT channel modifiers useful for contactless temperature sensors to distinguish between the ambient temperature and the temperature of the object Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-core.c | 2 ++ include/linux/iio/types.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index de8b1c2ed4b4..4b1f375c5659 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -85,6 +85,8 @@ static const char * const iio_modifier_names[] = { [IIO_MOD_LIGHT_GREEN] = "green", [IIO_MOD_LIGHT_BLUE] = "blue", [IIO_MOD_QUATERNION] = "quaternion", + [IIO_MOD_TEMP_AMBIENT] = "ambient", + [IIO_MOD_TEMP_OBJECT] = "object", }; /* relies on pairs of these shared then separate */ diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h index 4fdab2e843b4..d480631eabc2 100644 --- a/include/linux/iio/types.h +++ b/include/linux/iio/types.h @@ -54,6 +54,8 @@ enum iio_modifier { IIO_MOD_LIGHT_GREEN, IIO_MOD_LIGHT_BLUE, IIO_MOD_QUATERNION, + IIO_MOD_TEMP_AMBIENT, + IIO_MOD_TEMP_OBJECT, }; enum iio_event_type { -- cgit v1.2.3 From 888c9c7366cef902531f27f6aa5fb787c86810d4 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Wed, 5 Feb 2014 16:57:00 +0000 Subject: iio: Add ABI documentation for object and ambient modifiers Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index 6b74691dc281..ca3d3b724efd 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -114,14 +114,17 @@ What: /sys/bus/iio/devices/iio:deviceX/in_temp_raw What: /sys/bus/iio/devices/iio:deviceX/in_tempX_raw What: /sys/bus/iio/devices/iio:deviceX/in_temp_x_raw What: /sys/bus/iio/devices/iio:deviceX/in_temp_y_raw -What: /sys/bus/iio/devices/iio:deviceX/in_temp_z_raw +What: /sys/bus/iio/devices/iio:deviceX/in_temp_ambient_raw +What: /sys/bus/iio/devices/iio:deviceX/in_temp_object_raw KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: Raw (unscaled no bias removal etc.) temperature measurement. If an axis is specified it generally means that the temperature sensor is associated with one part of a compound device (e.g. - a gyroscope axis). Units after application of scale and offset + a gyroscope axis). The ambient and object modifiers distinguish + between ambient (reference) and distant temperature for contact- + less measurements. Units after application of scale and offset are milli degrees Celsius. What: /sys/bus/iio/devices/iio:deviceX/in_tempX_input -- cgit v1.2.3 From 474fe212e669b6c1698982041028f7727c879970 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Wed, 5 Feb 2014 16:57:00 +0000 Subject: iio: Add Melexis mlx90614 contact-less infrared temperature sensor driver I2C-controlled sensor measures ambient and object temperatuer see http://www.melexis.com/Infrared-Thermometer-Sensors/Infrared-Thermometer-Sensors/MLX90614-615.aspx Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/iio/temperature/Kconfig | 10 +++ drivers/iio/temperature/Makefile | 1 + drivers/iio/temperature/mlx90614.c | 150 +++++++++++++++++++++++++++++++++++++ 3 files changed, 161 insertions(+) create mode 100644 drivers/iio/temperature/mlx90614.c diff --git a/drivers/iio/temperature/Kconfig b/drivers/iio/temperature/Kconfig index 372f8fb3085f..21feaa4661b4 100644 --- a/drivers/iio/temperature/Kconfig +++ b/drivers/iio/temperature/Kconfig @@ -3,6 +3,16 @@ # menu "Temperature sensors" +config MLX90614 + tristate "MLX90614 contact-less infrared sensor" + depends on I2C + help + If you say yes here you get support for the Melexis + MLX90614 contact-less infrared sensor connected with I2C. + + This driver can also be built as a module. If so, the module will + be called mlx90614. + config TMP006 tristate "TMP006 infrared thermopile sensor" depends on I2C diff --git a/drivers/iio/temperature/Makefile b/drivers/iio/temperature/Makefile index 24d7b602db3e..40710a81158e 100644 --- a/drivers/iio/temperature/Makefile +++ b/drivers/iio/temperature/Makefile @@ -2,4 +2,5 @@ # Makefile for industrial I/O temperature drivers # +obj-$(CONFIG_MLX90614) += mlx90614.o obj-$(CONFIG_TMP006) += tmp006.o diff --git a/drivers/iio/temperature/mlx90614.c b/drivers/iio/temperature/mlx90614.c new file mode 100644 index 000000000000..c8b6ac8b2d69 --- /dev/null +++ b/drivers/iio/temperature/mlx90614.c @@ -0,0 +1,150 @@ +/* + * mlx90614.c - Support for Melexis MLX90614 contactless IR temperature sensor + * + * Copyright (c) 2014 Peter Meerwald + * + * This file is subject to the terms and conditions of version 2 of + * the GNU General Public License. See the file COPYING in the main + * directory of this archive for more details. + * + * Driver for the Melexis MLX90614 I2C 16-bit IR thermopile sensor + * + * (7-bit I2C slave address 0x5a, 100KHz bus speed only!) + * + * TODO: sleep mode, configuration EEPROM + */ + +#include +#include +#include + +#include + +#define MLX90614_OP_RAM 0x00 + +/* RAM offsets with 16-bit data, MSB first */ +#define MLX90614_TA 0x06 /* ambient temperature */ +#define MLX90614_TOBJ1 0x07 /* object temperature */ + +struct mlx90614_data { + struct i2c_client *client; +}; + +static int mlx90614_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *channel, int *val, + int *val2, long mask) +{ + struct mlx90614_data *data = iio_priv(indio_dev); + s32 ret; + + switch (mask) { + case IIO_CHAN_INFO_RAW: /* 0.02K / LSB */ + switch (channel->channel2) { + case IIO_MOD_TEMP_AMBIENT: + ret = i2c_smbus_read_word_data(data->client, + MLX90614_OP_RAM | MLX90614_TA); + if (ret < 0) + return ret; + break; + case IIO_MOD_TEMP_OBJECT: + ret = i2c_smbus_read_word_data(data->client, + MLX90614_OP_RAM | MLX90614_TOBJ1); + if (ret < 0) + return ret; + break; + default: + return -EINVAL; + } + *val = ret; + return IIO_VAL_INT; + case IIO_CHAN_INFO_OFFSET: + *val = 13657; + *val2 = 500000; + return IIO_VAL_INT_PLUS_MICRO; + case IIO_CHAN_INFO_SCALE: + *val = 20; + return IIO_VAL_INT; + default: + return -EINVAL; + } +} + +static const struct iio_chan_spec mlx90614_channels[] = { + { + .type = IIO_TEMP, + .modified = 1, + .channel2 = IIO_MOD_TEMP_AMBIENT, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | + BIT(IIO_CHAN_INFO_SCALE), + }, + { + .type = IIO_TEMP, + .modified = 1, + .channel2 = IIO_MOD_TEMP_OBJECT, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | + BIT(IIO_CHAN_INFO_SCALE), + }, +}; + +static const struct iio_info mlx90614_info = { + .read_raw = mlx90614_read_raw, + .driver_module = THIS_MODULE, +}; + +static int mlx90614_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct iio_dev *indio_dev; + struct mlx90614_data *data; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA)) + return -ENODEV; + + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); + if (!indio_dev) + return -ENOMEM; + + data = iio_priv(indio_dev); + i2c_set_clientdata(client, indio_dev); + data->client = client; + + indio_dev->dev.parent = &client->dev; + indio_dev->name = id->name; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->info = &mlx90614_info; + + indio_dev->channels = mlx90614_channels; + indio_dev->num_channels = ARRAY_SIZE(mlx90614_channels); + + return iio_device_register(indio_dev); +} + +static int mlx90614_remove(struct i2c_client *client) +{ + iio_device_unregister(i2c_get_clientdata(client)); + + return 0; +} + +static const struct i2c_device_id mlx90614_id[] = { + { "mlx90614", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, mlx90614_id); + +static struct i2c_driver mlx90614_driver = { + .driver = { + .name = "mlx90614", + .owner = THIS_MODULE, + }, + .probe = mlx90614_probe, + .remove = mlx90614_remove, + .id_table = mlx90614_id, +}; +module_i2c_driver(mlx90614_driver); + +MODULE_AUTHOR("Peter Meerwald "); +MODULE_DESCRIPTION("Melexis MLX90614 contactless IR temperature sensor driver"); +MODULE_LICENSE("GPL"); -- cgit v1.2.3 From 065b055dce0cbc2c14fa602cf5ab9938b6a08793 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Wed, 5 Feb 2014 16:54:00 +0000 Subject: iio: Add intensity including ir and both modifiers to ABI documentation ex-post intensity has been in use for a long time but never documented it is beneficial to document what this is supposed to be Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index ca3d3b724efd..9669c1ff8491 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -895,6 +895,16 @@ Description: on-chip EEPROM. After power-up or chip reset the device will automatically load the saved configuration. +What: /sys/.../iio:deviceX/in_intensityY_raw +What: /sys/.../iio:deviceX/in_intensityY_ir_raw +What: /sys/.../iio:deviceX/in_intensityY_both_raw +KernelVersion: 3.4 +Contact: linux-iio@vger.kernel.org +Description: + Unit-less light intensity. Modifiers both and ir indicate + that measurements contains visible and infrared light + components or just infrared light, respectively. + What: /sys/.../iio:deviceX/in_intensity_red_integration_time What: /sys/.../iio:deviceX/in_intensity_green_integration_time What: /sys/.../iio:deviceX/in_intensity_blue_integration_time -- cgit v1.2.3 From 994265f180791b7502cebd10dcb550d941e182c7 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Wed, 5 Feb 2014 16:54:00 +0000 Subject: iio: Add ABI documentation for illuminance has been in use for a long time, but never documented; state that this measurement should be in lux (drivers may feel different about this) Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index 9669c1ff8491..a9757dcf2e81 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -895,6 +895,15 @@ Description: on-chip EEPROM. After power-up or chip reset the device will automatically load the saved configuration. +What: /sys/.../iio:deviceX/in_illuminanceY_input +What: /sys/.../iio:deviceX/in_illuminanceY_raw +What: /sys/.../iio:deviceX/in_illuminanceY_mean_raw +KernelVersion: 3.4 +Contact: linux-iio@vger.kernel.org +Description: + Illuminance measurement, units after application of scale + and offset are lux. + What: /sys/.../iio:deviceX/in_intensityY_raw What: /sys/.../iio:deviceX/in_intensityY_ir_raw What: /sys/.../iio:deviceX/in_intensityY_both_raw -- cgit v1.2.3 From 89a9430f1e65bc5b0eef78587d54306f813cd028 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Wed, 5 Feb 2014 16:54:00 +0000 Subject: iio: Fix spelling of illuminance in gp2ap020a00f driver Cc: Jacek Anaszewski Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/iio/light/gp2ap020a00f.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/iio/light/gp2ap020a00f.c b/drivers/iio/light/gp2ap020a00f.c index 5ea4a03c7e71..04bdb85d2d9f 100644 --- a/drivers/iio/light/gp2ap020a00f.c +++ b/drivers/iio/light/gp2ap020a00f.c @@ -5,13 +5,13 @@ * IIO features supported by the driver: * * Read-only raw channels: - * - illiminance_clear [lux] - * - illiminance_ir + * - illuminance_clear [lux] + * - illuminance_ir * - proximity * * Triggered buffer: - * - illiminance_clear - * - illiminance_ir + * - illuminance_clear + * - illuminance_ir * - proximity * * Events: -- cgit v1.2.3 From 88cece46acb88c4032d34b8b52796e08a99c34d2 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Tue, 29 Apr 2014 16:44:00 +0100 Subject: iio: ak8975: Fix issue with the name Fixing issue caused by clash of two patches, one adding a name with the acpi enumeration patch. 54ab3e24 Beomho Seo 2014-04-02 @572 indio_dev->name = id->name; d913971e Srinivas Pandruvada 2014-03-19 574 indio_dev->name = name; The name added by commit 54ab3e24 is not required as this is already added by taking care of case where id is NULL. Signed-off-by: Srinivas Pandruvada Reported-by: kbuild test robot Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/ak8975.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c index f5c1d41bf39f..09ea5c481f4c 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -569,7 +569,6 @@ static int ak8975_probe(struct i2c_client *client, indio_dev->channels = ak8975_channels; indio_dev->num_channels = ARRAY_SIZE(ak8975_channels); indio_dev->info = &ak8975_info; - indio_dev->name = id->name; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->name = name; err = iio_device_register(indio_dev); -- cgit v1.2.3 From c7eeea93ac60aba3c037af8933a7ffc96ccd495c Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Wed, 5 Feb 2014 09:51:00 +0000 Subject: iio: Add Freescale MMA8452Q 3-axis accelerometer driver 3-axis accelerometer sensor (2/4/8 g) with 12-bit resolution and I2C interface many extra features are unsupported (freefall detection, orientation change, autosleep) datasheet is here: http://cache.freescale.com/files/sensors/doc/data_sheet/MMA8452Q.pdf v2: (thanks to Jonathan Cameron) * use ARRAY_SIZE() Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/iio/accel/Kconfig | 12 ++ drivers/iio/accel/Makefile | 1 + drivers/iio/accel/mma8452.c | 439 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 452 insertions(+) create mode 100644 drivers/iio/accel/mma8452.c diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig index e23e50850655..1e120fa1e156 100644 --- a/drivers/iio/accel/Kconfig +++ b/drivers/iio/accel/Kconfig @@ -65,4 +65,16 @@ config KXSD9 Say yes here to build support for the Kionix KXSD9 accelerometer. Currently this only supports the device via an SPI interface. +config MMA8452 + tristate "Freescale MMA8452Q Accelerometer Driver" + depends on I2C + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER + help + Say yes here to build support for the Freescale MMA8452Q 3-axis + accelerometer. + + To compile this driver as a module, choose M here: the module + will be called mma8452. + endmenu diff --git a/drivers/iio/accel/Makefile b/drivers/iio/accel/Makefile index c48d15f25616..dc0e379c2592 100644 --- a/drivers/iio/accel/Makefile +++ b/drivers/iio/accel/Makefile @@ -6,6 +6,7 @@ obj-$(CONFIG_BMA180) += bma180.o obj-$(CONFIG_HID_SENSOR_ACCEL_3D) += hid-sensor-accel-3d.o obj-$(CONFIG_KXSD9) += kxsd9.o +obj-$(CONFIG_MMA8452) += mma8452.o obj-$(CONFIG_IIO_ST_ACCEL_3AXIS) += st_accel.o st_accel-y := st_accel_core.o diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c new file mode 100644 index 000000000000..17aeea170566 --- /dev/null +++ b/drivers/iio/accel/mma8452.c @@ -0,0 +1,439 @@ +/* + * mma8452.c - Support for Freescale MMA8452Q 3-axis 12-bit accelerometer + * + * Copyright 2014 Peter Meerwald + * + * This file is subject to the terms and conditions of version 2 of + * the GNU General Public License. See the file COPYING in the main + * directory of this archive for more details. + * + * 7-bit I2C slave address 0x1c/0x1d (pin selectable) + * + * TODO: interrupt, thresholding, orientation / freefall events, autosleep + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define MMA8452_STATUS 0x00 +#define MMA8452_OUT_X 0x01 /* MSB first, 12-bit */ +#define MMA8452_OUT_Y 0x03 +#define MMA8452_OUT_Z 0x05 +#define MMA8452_WHO_AM_I 0x0d +#define MMA8452_DATA_CFG 0x0e +#define MMA8452_OFF_X 0x2f +#define MMA8452_OFF_Y 0x30 +#define MMA8452_OFF_Z 0x31 +#define MMA8452_CTRL_REG1 0x2a +#define MMA8452_CTRL_REG2 0x2b + +#define MMA8452_STATUS_DRDY (BIT(2) | BIT(1) | BIT(0)) + +#define MMA8452_CTRL_DR_MASK (BIT(5) | BIT(4) | BIT(3)) +#define MMA8452_CTRL_DR_SHIFT 3 +#define MMA8452_CTRL_DR_DEFAULT 0x4 /* 50 Hz sample frequency */ +#define MMA8452_CTRL_ACTIVE BIT(0) + +#define MMA8452_DATA_CFG_FS_MASK (BIT(1) | BIT(0)) +#define MMA8452_DATA_CFG_FS_2G 0 +#define MMA8452_DATA_CFG_FS_4G 1 +#define MMA8452_DATA_CFG_FS_8G 2 + +#define MMA8452_DEVICE_ID 0x2a + +struct mma8452_data { + struct i2c_client *client; + struct mutex lock; + u8 ctrl_reg1; + u8 data_cfg; +}; + +static int mma8452_drdy(struct mma8452_data *data) +{ + int tries = 150; + + while (tries-- > 0) { + int ret = i2c_smbus_read_byte_data(data->client, + MMA8452_STATUS); + if (ret < 0) + return ret; + if ((ret & MMA8452_STATUS_DRDY) == MMA8452_STATUS_DRDY) + return 0; + msleep(20); + } + + dev_err(&data->client->dev, "data not ready\n"); + return -EIO; +} + +static int mma8452_read(struct mma8452_data *data, __be16 buf[3]) +{ + int ret = mma8452_drdy(data); + if (ret < 0) + return ret; + return i2c_smbus_read_i2c_block_data(data->client, + MMA8452_OUT_X, 3 * sizeof(__be16), (u8 *) buf); +} + +static ssize_t mma8452_show_int_plus_micros(char *buf, + const int (*vals)[2], int n) +{ + size_t len = 0; + + while (n-- > 0) + len += scnprintf(buf + len, PAGE_SIZE - len, + "%d.%06d ", vals[n][0], vals[n][1]); + + /* replace trailing space by newline */ + buf[len - 1] = '\n'; + + return len; +} + +static int mma8452_get_int_plus_micros_index(const int (*vals)[2], int n, + int val, int val2) +{ + while (n-- > 0) + if (val == vals[n][0] && val2 == vals[n][1]) + return n; + + return -EINVAL; +} + +static const int mma8452_samp_freq[8][2] = { + {800, 0}, {400, 0}, {200, 0}, {100, 0}, {50, 0}, {12, 500000}, + {6, 250000}, {1, 560000} +}; + +static const int mma8452_scales[3][2] = { + {0, 977}, {0, 1953}, {0, 3906} +}; + +static ssize_t mma8452_show_samp_freq_avail(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return mma8452_show_int_plus_micros(buf, mma8452_samp_freq, + ARRAY_SIZE(mma8452_samp_freq)); +} + +static ssize_t mma8452_show_scale_avail(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return mma8452_show_int_plus_micros(buf, mma8452_scales, + ARRAY_SIZE(mma8452_scales)); +} + +static IIO_DEV_ATTR_SAMP_FREQ_AVAIL(mma8452_show_samp_freq_avail); +static IIO_DEVICE_ATTR(in_accel_scale_available, S_IRUGO, + mma8452_show_scale_avail, NULL, 0); + +static int mma8452_get_samp_freq_index(struct mma8452_data *data, + int val, int val2) +{ + return mma8452_get_int_plus_micros_index(mma8452_samp_freq, + ARRAY_SIZE(mma8452_samp_freq), val, val2); +} + +static int mma8452_get_scale_index(struct mma8452_data *data, + int val, int val2) +{ + return mma8452_get_int_plus_micros_index(mma8452_scales, + ARRAY_SIZE(mma8452_scales), val, val2); +} + +static int mma8452_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + struct mma8452_data *data = iio_priv(indio_dev); + __be16 buffer[3]; + int i, ret; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + if (iio_buffer_enabled(indio_dev)) + return -EBUSY; + + mutex_lock(&data->lock); + ret = mma8452_read(data, buffer); + mutex_unlock(&data->lock); + if (ret < 0) + return ret; + *val = sign_extend32( + be16_to_cpu(buffer[chan->scan_index]) >> 4, 11); + return IIO_VAL_INT; + case IIO_CHAN_INFO_SCALE: + i = data->data_cfg & MMA8452_DATA_CFG_FS_MASK; + *val = mma8452_scales[i][0]; + *val2 = mma8452_scales[i][1]; + return IIO_VAL_INT_PLUS_MICRO; + case IIO_CHAN_INFO_SAMP_FREQ: + i = (data->ctrl_reg1 & MMA8452_CTRL_DR_MASK) >> + MMA8452_CTRL_DR_SHIFT; + *val = mma8452_samp_freq[i][0]; + *val2 = mma8452_samp_freq[i][1]; + return IIO_VAL_INT_PLUS_MICRO; + case IIO_CHAN_INFO_CALIBBIAS: + ret = i2c_smbus_read_byte_data(data->client, MMA8452_OFF_X + + chan->scan_index); + if (ret < 0) + return ret; + *val = sign_extend32(ret, 7); + return IIO_VAL_INT; + } + return -EINVAL; +} + +static int mma8452_standby(struct mma8452_data *data) +{ + return i2c_smbus_write_byte_data(data->client, MMA8452_CTRL_REG1, + data->ctrl_reg1 & ~MMA8452_CTRL_ACTIVE); +} + +static int mma8452_active(struct mma8452_data *data) +{ + return i2c_smbus_write_byte_data(data->client, MMA8452_CTRL_REG1, + data->ctrl_reg1); +} + +static int mma8452_change_config(struct mma8452_data *data, u8 reg, u8 val) +{ + int ret; + + mutex_lock(&data->lock); + + /* config can only be changed when in standby */ + ret = mma8452_standby(data); + if (ret < 0) + goto fail; + + ret = i2c_smbus_write_byte_data(data->client, reg, val); + if (ret < 0) + goto fail; + + ret = mma8452_active(data); + if (ret < 0) + goto fail; + + ret = 0; +fail: + mutex_unlock(&data->lock); + return ret; +} + +static int mma8452_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + struct mma8452_data *data = iio_priv(indio_dev); + int i; + + if (iio_buffer_enabled(indio_dev)) + return -EBUSY; + + switch (mask) { + case IIO_CHAN_INFO_SAMP_FREQ: + i = mma8452_get_samp_freq_index(data, val, val2); + if (i < 0) + return -EINVAL; + + data->ctrl_reg1 &= ~MMA8452_CTRL_DR_MASK; + data->ctrl_reg1 |= i << MMA8452_CTRL_DR_SHIFT; + return mma8452_change_config(data, MMA8452_CTRL_REG1, + data->ctrl_reg1); + case IIO_CHAN_INFO_SCALE: + i = mma8452_get_scale_index(data, val, val2); + if (i < 0) + return -EINVAL; + data->data_cfg &= ~MMA8452_DATA_CFG_FS_MASK; + data->data_cfg |= i; + return mma8452_change_config(data, MMA8452_DATA_CFG, + data->data_cfg); + case IIO_CHAN_INFO_CALIBBIAS: + if (val < -128 || val > 127) + return -EINVAL; + return mma8452_change_config(data, MMA8452_OFF_X + + chan->scan_index, val); + default: + return -EINVAL; + } +} + +static irqreturn_t mma8452_trigger_handler(int irq, void *p) +{ + struct iio_poll_func *pf = p; + struct iio_dev *indio_dev = pf->indio_dev; + struct mma8452_data *data = iio_priv(indio_dev); + u8 buffer[16]; /* 3 16-bit channels + padding + ts */ + int ret; + + ret = mma8452_read(data, (__be16 *) buffer); + if (ret < 0) + goto done; + + iio_push_to_buffers_with_timestamp(indio_dev, buffer, + iio_get_time_ns()); + +done: + iio_trigger_notify_done(indio_dev->trig); + return IRQ_HANDLED; +} + +#define MMA8452_CHANNEL(axis, idx) { \ + .type = IIO_ACCEL, \ + .modified = 1, \ + .channel2 = IIO_MOD_##axis, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ + BIT(IIO_CHAN_INFO_CALIBBIAS), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ) | \ + BIT(IIO_CHAN_INFO_SCALE), \ + .scan_index = idx, \ + .scan_type = { \ + .sign = 's', \ + .realbits = 12, \ + .storagebits = 16, \ + .shift = 4, \ + .endianness = IIO_BE, \ + }, \ +} + +static const struct iio_chan_spec mma8452_channels[] = { + MMA8452_CHANNEL(X, 0), + MMA8452_CHANNEL(Y, 1), + MMA8452_CHANNEL(Z, 2), + IIO_CHAN_SOFT_TIMESTAMP(3), +}; + +static struct attribute *mma8452_attributes[] = { + &iio_dev_attr_sampling_frequency_available.dev_attr.attr, + &iio_dev_attr_in_accel_scale_available.dev_attr.attr, + NULL +}; + +static const struct attribute_group mma8452_group = { + .attrs = mma8452_attributes, +}; + +static const struct iio_info mma8452_info = { + .attrs = &mma8452_group, + .read_raw = &mma8452_read_raw, + .write_raw = &mma8452_write_raw, + .driver_module = THIS_MODULE, +}; + +static const unsigned long mma8452_scan_masks[] = {0x7, 0}; + +static int mma8452_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct mma8452_data *data; + struct iio_dev *indio_dev; + int ret; + + ret = i2c_smbus_read_byte_data(client, MMA8452_WHO_AM_I); + if (ret < 0) + return ret; + if (ret != MMA8452_DEVICE_ID) + return -ENODEV; + + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); + if (!indio_dev) + return -ENOMEM; + + data = iio_priv(indio_dev); + data->client = client; + mutex_init(&data->lock); + + i2c_set_clientdata(client, indio_dev); + indio_dev->info = &mma8452_info; + indio_dev->name = id->name; + indio_dev->dev.parent = &client->dev; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = mma8452_channels; + indio_dev->num_channels = ARRAY_SIZE(mma8452_channels); + indio_dev->available_scan_masks = mma8452_scan_masks; + + data->ctrl_reg1 = MMA8452_CTRL_ACTIVE | + (MMA8452_CTRL_DR_DEFAULT << MMA8452_CTRL_DR_SHIFT); + ret = i2c_smbus_write_byte_data(client, MMA8452_CTRL_REG1, + data->ctrl_reg1); + if (ret < 0) + return ret; + + data->data_cfg = MMA8452_DATA_CFG_FS_2G; + ret = i2c_smbus_write_byte_data(client, MMA8452_DATA_CFG, + data->data_cfg); + if (ret < 0) + return ret; + + ret = iio_triggered_buffer_setup(indio_dev, NULL, + mma8452_trigger_handler, NULL); + if (ret < 0) + return ret; + + ret = iio_device_register(indio_dev); + if (ret < 0) + goto buffer_cleanup; + return 0; + +buffer_cleanup: + iio_triggered_buffer_cleanup(indio_dev); + return ret; +} + +static int mma8452_remove(struct i2c_client *client) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(client); + + iio_device_unregister(indio_dev); + iio_triggered_buffer_cleanup(indio_dev); + mma8452_standby(iio_priv(indio_dev)); + + return 0; +} + +#ifdef CONFIG_PM_SLEEP +static int mma8452_suspend(struct device *dev) +{ + return mma8452_standby(iio_priv(i2c_get_clientdata( + to_i2c_client(dev)))); +} + +static int mma8452_resume(struct device *dev) +{ + return mma8452_active(iio_priv(i2c_get_clientdata( + to_i2c_client(dev)))); +} + +static SIMPLE_DEV_PM_OPS(mma8452_pm_ops, mma8452_suspend, mma8452_resume); +#define MMA8452_PM_OPS (&mma8452_pm_ops) +#else +#define MMA8452_PM_OPS NULL +#endif + +static const struct i2c_device_id mma8452_id[] = { + { "mma8452", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, mma8452_id); + +static struct i2c_driver mma8452_driver = { + .driver = { + .name = "mma8452", + .pm = MMA8452_PM_OPS, + }, + .probe = mma8452_probe, + .remove = mma8452_remove, + .id_table = mma8452_id, +}; +module_i2c_driver(mma8452_driver); + +MODULE_AUTHOR("Peter Meerwald "); +MODULE_DESCRIPTION("Freescale MMA8452 accelerometer driver"); +MODULE_LICENSE("GPL"); -- cgit v1.2.3 From 7bc3dfa37ba6f6ea81c362eb1993bd20c0828eae Mon Sep 17 00:00:00 2001 From: Vitaly Osipov Date: Sun, 27 Apr 2014 01:08:21 +1000 Subject: staging: lustre: check for integer overflow In ll_ioctl_fiemap(), a user-supplied value is used to calculate a length of a buffer which is later allocated with user data. Signed-off-by: Vitaly Osipov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/file.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 562e33751197..d87f96d9e0fa 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -1829,6 +1829,10 @@ static int ll_ioctl_fiemap(struct inode *inode, unsigned long arg) if (get_user(extent_count, &((struct ll_user_fiemap __user *)arg)->fm_extent_count)) return -EFAULT; + + if (extent_count >= + (SIZE_MAX - sizeof(*fiemap_s)) / sizeof(struct ll_fiemap_extent)) + return -EINVAL; num_bytes = sizeof(*fiemap_s) + (extent_count * sizeof(struct ll_fiemap_extent)); -- cgit v1.2.3 From 76133e66b1417a73c0950d0716219d09ee21d595 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Sun, 27 Apr 2014 22:21:52 -0400 Subject: staging/lustre: Replace jobid acquiring with per node setting Insted of meddling directly in process environment variables (which is also not possible on certain platforms due to not exported symbols), create jobid_name proc file to represent this info (to be filled by job scheduler epilogue). Signed-off-by: Oleg Drokin CC: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/include/linux/libcfs/curproc.h | 1 - .../staging/lustre/lustre/include/lprocfs_status.h | 1 + drivers/staging/lustre/lustre/include/obd_class.h | 3 + .../lustre/lustre/libcfs/linux/linux-curproc.c | 152 --------------------- drivers/staging/lustre/lustre/obdclass/class_obd.c | 50 ++----- .../lustre/lustre/obdclass/linux/linux-module.c | 27 ++++ 6 files changed, 44 insertions(+), 190 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/curproc.h b/drivers/staging/lustre/include/linux/libcfs/curproc.h index 8fd47c98fd33..b314f34d2e68 100644 --- a/drivers/staging/lustre/include/linux/libcfs/curproc.h +++ b/drivers/staging/lustre/include/linux/libcfs/curproc.h @@ -56,7 +56,6 @@ /* check if task is running in compat mode.*/ #define current_pid() (current->pid) #define current_comm() (current->comm) -int cfs_get_environ(const char *key, char *value, int *val_len); typedef __u32 cfs_cap_t; diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 9ce12c78d47a..1b7f6a9bf62c 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -369,6 +369,7 @@ static inline void s2dhms(struct dhms *ts, time_t secs) #define JOBSTATS_JOBID_VAR_MAX_LEN 20 #define JOBSTATS_DISABLE "disable" #define JOBSTATS_PROCNAME_UID "procname_uid" +#define JOBSTATS_NODELOCAL "nodelocal" extern int lprocfs_write_frac_helper(const char *buffer, unsigned long count, int *val, int mult); diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 61ba370794f8..e265820c009f 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -2182,6 +2182,9 @@ void class_exit_uuidlist(void); int mea_name2idx(struct lmv_stripe_md *mea, const char *name, int namelen); int raw_name2idx(int hashtype, int count, const char *name, int namelen); +/* class_obd.c */ +extern char obd_jobid_node[]; + /* prng.c */ #define ll_generate_random_uuid(uuid_out) cfs_get_random_bytes(uuid_out, sizeof(class_uuid_t)) diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c index e74c3e28a972..bd301ce02255 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c @@ -100,158 +100,6 @@ cfs_cap_t cfs_curproc_cap_pack(void) return cap; } -static int cfs_access_process_vm(struct task_struct *tsk, unsigned long addr, - void *buf, int len, int write) -{ - /* Just copied from kernel for the kernels which doesn't - * have access_process_vm() exported */ - struct mm_struct *mm; - struct vm_area_struct *vma; - struct page *page; - void *old_buf = buf; - - mm = get_task_mm(tsk); - if (!mm) - return 0; - - down_read(&mm->mmap_sem); - /* ignore errors, just check how much was successfully transferred */ - while (len) { - int bytes, rc, offset; - void *maddr; - - rc = get_user_pages(tsk, mm, addr, 1, - write, 1, &page, &vma); - if (rc <= 0) - break; - - bytes = len; - offset = addr & (PAGE_SIZE-1); - if (bytes > PAGE_SIZE-offset) - bytes = PAGE_SIZE-offset; - - maddr = kmap(page); - if (write) { - copy_to_user_page(vma, page, addr, - maddr + offset, buf, bytes); - set_page_dirty_lock(page); - } else { - copy_from_user_page(vma, page, addr, - buf, maddr + offset, bytes); - } - kunmap(page); - page_cache_release(page); - len -= bytes; - buf += bytes; - addr += bytes; - } - up_read(&mm->mmap_sem); - mmput(mm); - - return buf - old_buf; -} - -/* Read the environment variable of current process specified by @key. */ -int cfs_get_environ(const char *key, char *value, int *val_len) -{ - struct mm_struct *mm; - char *buffer, *tmp_buf = NULL; - int buf_len = PAGE_CACHE_SIZE; - int key_len = strlen(key); - unsigned long addr; - int rc; - - buffer = kmalloc(buf_len, GFP_USER); - if (!buffer) - return -ENOMEM; - - mm = get_task_mm(current); - if (!mm) { - kfree(buffer); - return -EINVAL; - } - - /* Avoid deadlocks on mmap_sem if called from sys_mmap_pgoff(), - * which is already holding mmap_sem for writes. If some other - * thread gets the write lock in the meantime, this thread will - * block, but at least it won't deadlock on itself. LU-1735 */ - if (down_read_trylock(&mm->mmap_sem) == 0) { - kfree(buffer); - return -EDEADLK; - } - up_read(&mm->mmap_sem); - - addr = mm->env_start; - while (addr < mm->env_end) { - int this_len, retval, scan_len; - char *env_start, *env_end; - - memset(buffer, 0, buf_len); - - this_len = min_t(int, mm->env_end - addr, buf_len); - retval = cfs_access_process_vm(current, addr, buffer, - this_len, 0); - if (retval != this_len) - break; - - addr += retval; - - /* Parse the buffer to find out the specified key/value pair. - * The "key=value" entries are separated by '\0'. */ - env_start = buffer; - scan_len = this_len; - while (scan_len) { - char *entry; - int entry_len; - - env_end = memscan(env_start, '\0', scan_len); - LASSERT(env_end >= env_start && - env_end <= env_start + scan_len); - - /* The last entry of this buffer cross the buffer - * boundary, reread it in next cycle. */ - if (unlikely(env_end - env_start == scan_len)) { - /* This entry is too large to fit in buffer */ - if (unlikely(scan_len == this_len)) { - CERROR("Too long env variable.\n"); - GOTO(out, rc = -EINVAL); - } - addr -= scan_len; - break; - } - - entry = env_start; - entry_len = env_end - env_start; - - /* Key length + length of '=' */ - if (entry_len > key_len + 1 && - !memcmp(entry, key, key_len)) { - entry += key_len + 1; - entry_len -= key_len + 1; - /* The 'value' buffer passed in is too small.*/ - if (entry_len >= *val_len) - GOTO(out, rc = -EOVERFLOW); - - memcpy(value, entry, entry_len); - *val_len = entry_len; - GOTO(out, rc = 0); - } - - scan_len -= (env_end - env_start + 1); - env_start = env_end + 1; - } - } - GOTO(out, rc = -ENOENT); - -out: - mmput(mm); - kfree((void *)buffer); - if (tmp_buf) - kfree((void *)tmp_buf); - return rc; -} -EXPORT_SYMBOL(cfs_get_environ); - EXPORT_SYMBOL(cfs_cap_raise); EXPORT_SYMBOL(cfs_cap_lower); EXPORT_SYMBOL(cfs_cap_raised); diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index c93131e0d2da..dde04b767a6d 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -102,23 +102,17 @@ EXPORT_SYMBOL(obd_dirty_transit_pages); char obd_jobid_var[JOBSTATS_JOBID_VAR_MAX_LEN + 1] = JOBSTATS_DISABLE; EXPORT_SYMBOL(obd_jobid_var); -/* Get jobid of current process by reading the environment variable - * stored in between the "env_start" & "env_end" of task struct. - * - * TODO: - * It's better to cache the jobid for later use if there is any - * efficient way, the cl_env code probably could be reused for this - * purpose. +char obd_jobid_node[JOBSTATS_JOBID_SIZE + 1]; + +/* Get jobid of current process from stored variable or calculate + * it from pid and user_id. * - * If some job scheduler doesn't store jobid in the "env_start/end", - * then an upcall could be issued here to get the jobid by utilizing - * the userspace tools/api. Then, the jobid must be cached. + * Historically this was also done by reading the environment variable + * stored in between the "env_start" & "env_end" of task struct. + * This is now deprecated. */ int lustre_get_jobid(char *jobid) { - int jobid_len = JOBSTATS_JOBID_SIZE; - int rc = 0; - memset(jobid, 0, JOBSTATS_JOBID_SIZE); /* Jobstats isn't enabled */ if (strcmp(obd_jobid_var, JOBSTATS_DISABLE) == 0) @@ -132,31 +126,13 @@ int lustre_get_jobid(char *jobid) return 0; } - rc = cfs_get_environ(obd_jobid_var, jobid, &jobid_len); - if (rc) { - if (rc == -EOVERFLOW) { - /* For the PBS_JOBID and LOADL_STEP_ID keys (which are - * variable length strings instead of just numbers), it - * might make sense to keep the unique parts for JobID, - * instead of just returning an error. That means a - * larger temp buffer for cfs_get_environ(), then - * truncating the string at some separator to fit into - * the specified jobid_len. Fix later if needed. */ - static bool printed; - if (unlikely(!printed)) { - LCONSOLE_ERROR_MSG(0x16b, "%s value too large " - "for JobID buffer (%d)\n", - obd_jobid_var, jobid_len); - printed = true; - } - } else { - CDEBUG((rc == -ENOENT || rc == -EINVAL || - rc == -EDEADLK) ? D_INFO : D_ERROR, - "Get jobid for (%s) failed: rc = %d\n", - obd_jobid_var, rc); - } + /* Whole node dedicated to single job */ + if (strcmp(obd_jobid_var, JOBSTATS_NODELOCAL) == 0) { + strcpy(jobid, obd_jobid_node); + return 0; } - return rc; + + return -ENOENT; } EXPORT_SYMBOL(lustre_get_jobid); diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c index 0334882070ef..bdf2eed2952a 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c @@ -292,6 +292,31 @@ static ssize_t obd_proc_jobid_var_seq_write(struct file *file, const char *buffe } LPROC_SEQ_FOPS(obd_proc_jobid_var); +static int obd_proc_jobid_name_seq_show(struct seq_file *m, void *v) +{ + return seq_printf(m, "%s\n", obd_jobid_var); +} + +static ssize_t obd_proc_jobid_name_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) +{ + if (!count || count > JOBSTATS_JOBID_SIZE) + return -EINVAL; + + if (copy_from_user(obd_jobid_node, buffer, count)) + return -EFAULT; + + obd_jobid_node[count] = 0; + + /* Trim the trailing '\n' if any */ + if (obd_jobid_node[count - 1] == '\n') + obd_jobid_node[count - 1] = 0; + + return count; +} +LPROC_SEQ_FOPS(obd_proc_jobid_name); + /* Root for /proc/fs/lustre */ struct proc_dir_entry *proc_lustre_root = NULL; EXPORT_SYMBOL(proc_lustre_root); @@ -301,6 +326,8 @@ struct lprocfs_vars lprocfs_base[] = { { "pinger", &obd_proc_pinger_fops }, { "health_check", &obd_proc_health_fops }, { "jobid_var", &obd_proc_jobid_var_fops }, + { .name = "jobid_name", + .fops = &obd_proc_jobid_name_fops}, { 0 } }; -- cgit v1.2.3 From f39489e269caadd73896ee30456d6c14b122ad16 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Sun, 27 Apr 2014 22:25:55 -0400 Subject: staging/lustre/lnet: Drop useless LASSERT in ksocknal_select_ips It should never be NULL because our interface list is up to date, and even if it does, we'll just crash anyway so we are no better off. Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index 21d36ee5378a..a391d134787b 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -793,8 +793,6 @@ ksocknal_select_ips(ksock_peer_t *peer, __u32 *peerips, int n_peerips) ip = peer->ksnp_passive_ips[i]; best_iface = ksocknal_ip2iface(peer->ksnp_ni, ip); - /* peer passive ips are kept up to date */ - LASSERT(best_iface != NULL); } else { /* choose a new interface */ LASSERT (i == peer->ksnp_n_passive_ips); @@ -835,8 +833,6 @@ ksocknal_select_ips(ksock_peer_t *peer, __u32 *peerips, int n_peerips) peer->ksnp_n_passive_ips = i+1; } - LASSERT (best_iface != NULL); - /* mark the best matching peer IP used */ j = ksocknal_match_peerip(best_iface, peerips, n_peerips); peerips[j] = 0; -- cgit v1.2.3 From 1ae2bdb21e68744b726d2bdb06e9aef7295e44aa Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Sun, 27 Apr 2014 22:25:56 -0400 Subject: staging/lustre/lnet: remove unused variable in lnet_destroy_remote_nets_table Local variable 'hash' is never used found by Klocwork Insight tool Signed-off-by: Dmitry Eremin Reviewed-on: http://review.whamcloud.com/9386 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4629 Reviewed-by: John L. Hammond Reviewed-by: Isaac Huang Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/lnet/api-ni.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 85b8d815282d..3f1fdaa29891 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -127,8 +127,7 @@ lnet_create_remote_nets_table(void) static void lnet_destroy_remote_nets_table(void) { - int i; - struct list_head *hash; + int i; if (the_lnet.ln_remote_nets_hash == NULL) return; @@ -137,7 +136,8 @@ lnet_destroy_remote_nets_table(void) LASSERT(list_empty(&the_lnet.ln_remote_nets_hash[i])); LIBCFS_FREE(the_lnet.ln_remote_nets_hash, - LNET_REMOTE_NETS_HASH_SIZE * sizeof(*hash)); + LNET_REMOTE_NETS_HASH_SIZE * + sizeof(the_lnet.ln_remote_nets_hash[0])); the_lnet.ln_remote_nets_hash = NULL; } -- cgit v1.2.3 From 109dae8dab0f48ffbc88910084b3c795c647f6f4 Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Sun, 27 Apr 2014 22:25:57 -0400 Subject: staging/lustre/lnet: fix potential null pointer dereference in kiblnd_rejected Null pointer 'cp' that comes from line 2544 may be dereferenced at line 2618. found by Klocwork Insight tool Signed-off-by: Dmitry Eremin Reviewed-on: http://review.whamcloud.com/9386 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4629 Reviewed-by: John L. Hammond Reviewed-by: Isaac Huang Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c index 6173e74d7492..9bf6c949f5db 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -2609,13 +2609,17 @@ kiblnd_rejected (kib_conn_t *conn, int reason, void *priv, int priv_nob) case IBLND_REJECT_MSG_QUEUE_SIZE: CERROR("%s rejected: incompatible message queue depth %d, %d\n", - libcfs_nid2str(peer->ibp_nid), cp->ibcp_queue_depth, + libcfs_nid2str(peer->ibp_nid), + cp != NULL ? cp->ibcp_queue_depth : + IBLND_MSG_QUEUE_SIZE(rej->ibr_version), IBLND_MSG_QUEUE_SIZE(conn->ibc_version)); break; case IBLND_REJECT_RDMA_FRAGS: CERROR("%s rejected: incompatible # of RDMA fragments %d, %d\n", - libcfs_nid2str(peer->ibp_nid), cp->ibcp_max_frags, + libcfs_nid2str(peer->ibp_nid), + cp != NULL ? cp->ibcp_max_frags : + IBLND_RDMA_FRAGS(rej->ibr_version), IBLND_RDMA_FRAGS(conn->ibc_version)); break; -- cgit v1.2.3 From d36175e9d2c986ee653277928bfcbab6ddf6bb85 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Sun, 27 Apr 2014 22:25:58 -0400 Subject: staging/lustre/lnet: fix potential null pointer dereference Pointer 'ni' checked for NULL at line 1569 may be passed to function and may be dereferenced there by passing argument 1 to function 'lnet_ni_notify_locked' at line 1621. found by Klocwork Insight tool Signed-off-by: Oleg Drokin CC: Dmitry Eremin CC: Liang Zhen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/lnet/router.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c index 995f50976c42..926923a104c5 100644 --- a/drivers/staging/lustre/lnet/lnet/router.c +++ b/drivers/staging/lustre/lnet/lnet/router.c @@ -145,7 +145,7 @@ lnet_ni_notify_locked(lnet_ni_t *ni, lnet_peer_t *lp) * NB individual events can be missed; the only guarantee is that you * always get the most recent news */ - if (lp->lp_notifying) + if (lp->lp_notifying || ni == NULL) return; lp->lp_notifying = 1; -- cgit v1.2.3 From ee02eb4ae43b3b65cbf4c49c6915fe9d63aac970 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 28 Apr 2014 13:58:58 +0300 Subject: staging: lustre: integer overflow in obd_ioctl_is_invalid() The obd_ioctl_getdata() function caps "data->ioc_len" at OBD_MAX_IOCTL_BUFFER and then calls this obd_ioctl_is_invalid() to check that the other values inside data are valid. There are several lengths inside data but when they are added together they must not be larger than "data->ioc_len". The checks against "(data->ioc_inllen1 > (1<<30))" are supposed to ensure that the addition does not have an integer overflow. But "(1<<30) * 4" actually can overflow 32 bits, so the checks are insufficient. I have changed it to "> OBD_MAX_IOCTL_BUFFER" instead. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/lustre_lib.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_lib.h b/drivers/staging/lustre/lustre/include/lustre_lib.h index bdc981214805..3c26bbdc44b7 100644 --- a/drivers/staging/lustre/lustre/include/lustre_lib.h +++ b/drivers/staging/lustre/lustre/include/lustre_lib.h @@ -179,24 +179,25 @@ static inline int obd_ioctl_packlen(struct obd_ioctl_data *data) static inline int obd_ioctl_is_invalid(struct obd_ioctl_data *data) { - if (data->ioc_len > (1<<30)) { - CERROR("OBD ioctl: ioc_len larger than 1<<30\n"); + if (data->ioc_len > OBD_MAX_IOCTL_BUFFER) { + CERROR("OBD ioctl: ioc_len larger than %d\n", + OBD_MAX_IOCTL_BUFFER); return 1; } - if (data->ioc_inllen1 > (1<<30)) { - CERROR("OBD ioctl: ioc_inllen1 larger than 1<<30\n"); + if (data->ioc_inllen1 > OBD_MAX_IOCTL_BUFFER) { + CERROR("OBD ioctl: ioc_inllen1 larger than ioc_len\n"); return 1; } - if (data->ioc_inllen2 > (1<<30)) { - CERROR("OBD ioctl: ioc_inllen2 larger than 1<<30\n"); + if (data->ioc_inllen2 > OBD_MAX_IOCTL_BUFFER) { + CERROR("OBD ioctl: ioc_inllen2 larger than ioc_len\n"); return 1; } - if (data->ioc_inllen3 > (1<<30)) { - CERROR("OBD ioctl: ioc_inllen3 larger than 1<<30\n"); + if (data->ioc_inllen3 > OBD_MAX_IOCTL_BUFFER) { + CERROR("OBD ioctl: ioc_inllen3 larger than ioc_len\n"); return 1; } - if (data->ioc_inllen4 > (1<<30)) { - CERROR("OBD ioctl: ioc_inllen4 larger than 1<<30\n"); + if (data->ioc_inllen4 > OBD_MAX_IOCTL_BUFFER) { + CERROR("OBD ioctl: ioc_inllen4 larger than ioc_len\n"); return 1; } if (data->ioc_inlbuf1 && !data->ioc_inllen1) { -- cgit v1.2.3 From dab3aad3699d4951f60ec9e79009b62db63b1795 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Fri, 2 May 2014 18:28:33 +0200 Subject: staging/lustre/libcfs: Fix build errors for !CONFIG_SMP When CONFIG_SMP=n: drivers/staging/lustre/include/linux/libcfs/linux/linux-mem.h:58:31: fatal error: libcfs/libcfs_cpu.h: No such file or directory drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c:78:1: error: redefinition of 'cfs_cpt_table_print' drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h:109:1: note: previous definition of 'cfs_cpt_table_print' was here Signed-off-by: Geert Uytterhoeven Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/libcfs/linux/linux-mem.h | 2 +- drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-mem.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-mem.h index 72c76ad96ce9..ccee5c3e4142 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-mem.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-mem.h @@ -55,7 +55,7 @@ #ifndef HAVE_LIBCFS_CPT /* Need this for cfs_cpt_table */ -#include +#include #endif #define CFS_PAGE_MASK (~((__u64)PAGE_CACHE_SIZE-1)) diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c b/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c index d985e83ba2c3..a1a7bf44cccf 100644 --- a/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c +++ b/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c @@ -74,6 +74,7 @@ cfs_cpt_table_free(struct cfs_cpt_table *cptab) } EXPORT_SYMBOL(cfs_cpt_table_free); +#ifdef CONFIG_SMP int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len) { @@ -87,6 +88,7 @@ cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len) return rc; } EXPORT_SYMBOL(cfs_cpt_table_print); +#endif /* CONFIG_SMP */ int cfs_cpt_number(struct cfs_cpt_table *cptab) -- cgit v1.2.3 From b41a1fe067c34b40736860458b9d62b2139471d5 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Fri, 2 May 2014 18:28:34 +0200 Subject: staging: lustre: Use %zd to format ssize_t drivers/staging/lustre/lustre/llite/rw26.c: In function 'll_direct_IO_26': drivers/staging/lustre/lustre/llite/rw26.c:383:2: warning: format '%lu' expects argument of type 'long unsigned int', but argument 6 has type 'ssize_t' [-Wformat] drivers/staging/lustre/lustre/llite/rw26.c:383:2: warning: format '%lu' expects argument of type 'long unsigned int', but argument 10 has type 'ssize_t' [-Wformat] Join the quoted string split across lines to fix a checkpatch warning while we're at it. Signed-off-by: Geert Uytterhoeven Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/rw26.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c index b401d36b5739..55ca8d3c3e46 100644 --- a/drivers/staging/lustre/lustre/llite/rw26.c +++ b/drivers/staging/lustre/lustre/llite/rw26.c @@ -385,8 +385,8 @@ static ssize_t ll_direct_IO_26(int rw, struct kiocb *iocb, if ((file_offset & ~CFS_PAGE_MASK) || (count & ~CFS_PAGE_MASK)) return -EINVAL; - CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), size=%lu (max %lu), " - "offset=%lld=%llx, pages %lu (max %lu)\n", + CDEBUG(D_VFSTRACE, + "VFS Op:inode=%lu/%u(%p), size=%zd (max %lu), offset=%lld=%llx, pages %zd (max %lu)\n", inode->i_ino, inode->i_generation, inode, count, MAX_DIO_SIZE, file_offset, file_offset, count >> PAGE_CACHE_SHIFT, MAX_DIO_SIZE >> PAGE_CACHE_SHIFT); -- cgit v1.2.3 From 1d316792acd8bf70a5ad36ef0d3f84da509cab56 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Fri, 2 May 2014 18:28:35 +0200 Subject: staging/lustre/llite: Fix unused variable warning if !CONFIG_FS_POSIX_ACL If CONFIG_FS_POSIX_ACL=n: drivers/staging/lustre/lustre/llite/xattr.c: In function 'll_setxattr_common': drivers/staging/lustre/lustre/llite/xattr.c:115:27: warning: unused variable 'rce' [-Wunused-variable] Signed-off-by: Geert Uytterhoeven Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index 67a1de41c5b2..c6c27bbb43b4 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -112,8 +112,8 @@ int ll_setxattr_common(struct inode *inode, const char *name, struct ptlrpc_request *req = NULL; int xattr_type, rc; struct obd_capa *oc; - struct rmtacl_ctl_entry *rce = NULL; #ifdef CONFIG_FS_POSIX_ACL + struct rmtacl_ctl_entry *rce = NULL; posix_acl_xattr_header *new_value = NULL; ext_acl_xattr_header *acl = NULL; #endif -- cgit v1.2.3 From 80db2734acbc78db12798cfb611d6acc7fe389e6 Mon Sep 17 00:00:00 2001 From: Fredrick John Berchmans Date: Fri, 2 May 2014 19:50:15 -0700 Subject: staging: lustre use kernel socket sockopt apis Change old way of ops->setsockopt or ops->getsockopt in kernel to kernel_setsockopt or kernel_getsockopt. Signed-off-by: Fredrick John Berchmans Signed-off-by: Greg Kroah-Hartman --- .../lustre/lnet/klnds/socklnd/socklnd_lib-linux.c | 47 +++++----------------- .../lustre/lustre/libcfs/linux/linux-tcpip.c | 41 ++++--------------- 2 files changed, 17 insertions(+), 71 deletions(-) diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c index 37758d1c8a68..82b7d9f2862c 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c @@ -188,7 +188,6 @@ void ksocknal_lib_eager_ack (ksock_conn_t *conn) { int opt = 1; - mm_segment_t oldmm = get_fs(); struct socket *sock = conn->ksnc_sock; /* Remind the socket to ACK eagerly. If I don't, the socket might @@ -196,10 +195,8 @@ ksocknal_lib_eager_ack (ksock_conn_t *conn) * on, introducing delay in completing zero-copy sends in my * peer. */ - set_fs(KERNEL_DS); - sock->ops->setsockopt (sock, SOL_TCP, TCP_QUICKACK, + kernel_setsockopt(sock, SOL_TCP, TCP_QUICKACK, (char *)&opt, sizeof (opt)); - set_fs(oldmm); } int @@ -428,7 +425,6 @@ ksocknal_lib_csum_tx(ksock_tx_t *tx) int ksocknal_lib_get_conn_tunables (ksock_conn_t *conn, int *txmem, int *rxmem, int *nagle) { - mm_segment_t oldmm = get_fs (); struct socket *sock = conn->ksnc_sock; int len; int rc; @@ -443,10 +439,8 @@ ksocknal_lib_get_conn_tunables (ksock_conn_t *conn, int *txmem, int *rxmem, int rc = libcfs_sock_getbuf(sock, txmem, rxmem); if (rc == 0) { len = sizeof(*nagle); - set_fs(KERNEL_DS); - rc = sock->ops->getsockopt(sock, SOL_TCP, TCP_NODELAY, + rc = kernel_getsockopt(sock, SOL_TCP, TCP_NODELAY, (char *)nagle, &len); - set_fs(oldmm); } ksocknal_connsock_decref(conn); @@ -462,7 +456,6 @@ ksocknal_lib_get_conn_tunables (ksock_conn_t *conn, int *txmem, int *rxmem, int int ksocknal_lib_setup_sock (struct socket *sock) { - mm_segment_t oldmm = get_fs (); int rc; int option; int keep_idle; @@ -479,20 +472,16 @@ ksocknal_lib_setup_sock (struct socket *sock) linger.l_onoff = 0; linger.l_linger = 0; - set_fs (KERNEL_DS); - rc = sock_setsockopt (sock, SOL_SOCKET, SO_LINGER, + rc = kernel_setsockopt(sock, SOL_SOCKET, SO_LINGER, (char *)&linger, sizeof (linger)); - set_fs (oldmm); if (rc != 0) { CERROR ("Can't set SO_LINGER: %d\n", rc); return (rc); } option = -1; - set_fs (KERNEL_DS); - rc = sock->ops->setsockopt (sock, SOL_TCP, TCP_LINGER2, + rc = kernel_setsockopt(sock, SOL_TCP, TCP_LINGER2, (char *)&option, sizeof (option)); - set_fs (oldmm); if (rc != 0) { CERROR ("Can't set SO_LINGER2: %d\n", rc); return (rc); @@ -501,10 +490,8 @@ ksocknal_lib_setup_sock (struct socket *sock) if (!*ksocknal_tunables.ksnd_nagle) { option = 1; - set_fs (KERNEL_DS); - rc = sock->ops->setsockopt (sock, SOL_TCP, TCP_NODELAY, + rc = kernel_setsockopt(sock, SOL_TCP, TCP_NODELAY, (char *)&option, sizeof (option)); - set_fs (oldmm); if (rc != 0) { CERROR ("Can't disable nagle: %d\n", rc); return (rc); @@ -531,10 +518,8 @@ ksocknal_lib_setup_sock (struct socket *sock) do_keepalive = (keep_idle > 0 && keep_count > 0 && keep_intvl > 0); option = (do_keepalive ? 1 : 0); - set_fs (KERNEL_DS); - rc = sock_setsockopt (sock, SOL_SOCKET, SO_KEEPALIVE, + rc = kernel_setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (char *)&option, sizeof (option)); - set_fs (oldmm); if (rc != 0) { CERROR ("Can't set SO_KEEPALIVE: %d\n", rc); return (rc); @@ -543,28 +528,22 @@ ksocknal_lib_setup_sock (struct socket *sock) if (!do_keepalive) return (0); - set_fs (KERNEL_DS); - rc = sock->ops->setsockopt (sock, SOL_TCP, TCP_KEEPIDLE, + rc = kernel_setsockopt(sock, SOL_TCP, TCP_KEEPIDLE, (char *)&keep_idle, sizeof (keep_idle)); - set_fs (oldmm); if (rc != 0) { CERROR ("Can't set TCP_KEEPIDLE: %d\n", rc); return (rc); } - set_fs (KERNEL_DS); - rc = sock->ops->setsockopt (sock, SOL_TCP, TCP_KEEPINTVL, + rc = kernel_setsockopt(sock, SOL_TCP, TCP_KEEPINTVL, (char *)&keep_intvl, sizeof (keep_intvl)); - set_fs (oldmm); if (rc != 0) { CERROR ("Can't set TCP_KEEPINTVL: %d\n", rc); return (rc); } - set_fs (KERNEL_DS); - rc = sock->ops->setsockopt (sock, SOL_TCP, TCP_KEEPCNT, + rc = kernel_setsockopt(sock, SOL_TCP, TCP_KEEPCNT, (char *)&keep_count, sizeof (keep_count)); - set_fs (oldmm); if (rc != 0) { CERROR ("Can't set TCP_KEEPCNT: %d\n", rc); return (rc); @@ -581,7 +560,6 @@ ksocknal_lib_push_conn (ksock_conn_t *conn) int nonagle; int val = 1; int rc; - mm_segment_t oldmm; rc = ksocknal_connsock_addref(conn); if (rc != 0) /* being shut down */ @@ -595,15 +573,10 @@ ksocknal_lib_push_conn (ksock_conn_t *conn) tp->nonagle = 1; release_sock (sk); - oldmm = get_fs (); - set_fs (KERNEL_DS); - - rc = sk->sk_prot->setsockopt (sk, SOL_TCP, TCP_NODELAY, + rc = kernel_setsockopt(conn->ksnc_sock, SOL_TCP, TCP_NODELAY, (char *)&val, sizeof (val)); LASSERT (rc == 0); - set_fs (oldmm); - lock_sock (sk); tp->nonagle = nonagle; release_sock (sk); diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c index 7539fe16d76f..4153b4a61396 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c @@ -56,21 +56,8 @@ libcfs_sock_ioctl(int cmd, unsigned long arg) CERROR ("Can't create socket: %d\n", rc); return rc; } - - sock_filp = sock_alloc_file(sock, 0, NULL); - if (IS_ERR(sock_filp)) { - sock_release(sock); - rc = PTR_ERR(sock_filp); - goto out; - } - - set_fs(KERNEL_DS); - if (sock_filp->f_op->unlocked_ioctl) - rc = sock_filp->f_op->unlocked_ioctl(sock_filp, cmd, arg); - set_fs(oldmm); - - fput(sock_filp); -out: + rc = kernel_sock_ioctl(sock, cmd, arg); + sock_release(sock); return rc; } @@ -255,7 +242,6 @@ int libcfs_sock_write (struct socket *sock, void *buffer, int nob, int timeout) { int rc; - mm_segment_t oldmm = get_fs(); long ticks = timeout * HZ; unsigned long then; struct timeval tv; @@ -279,10 +265,8 @@ libcfs_sock_write (struct socket *sock, void *buffer, int nob, int timeout) .tv_sec = ticks / HZ, .tv_usec = ((ticks % HZ) * 1000000) / HZ }; - set_fs(KERNEL_DS); - rc = sock_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, + rc = kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, sizeof(tv)); - set_fs(oldmm); if (rc != 0) { CERROR("Can't set socket send timeout " "%ld.%06d: %d\n", @@ -321,7 +305,6 @@ int libcfs_sock_read (struct socket *sock, void *buffer, int nob, int timeout) { int rc; - mm_segment_t oldmm = get_fs(); long ticks = timeout * HZ; unsigned long then; struct timeval tv; @@ -343,10 +326,8 @@ libcfs_sock_read (struct socket *sock, void *buffer, int nob, int timeout) .tv_sec = ticks / HZ, .tv_usec = ((ticks % HZ) * 1000000) / HZ }; - set_fs(KERNEL_DS); - rc = sock_setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, + rc = kernel_setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv)); - set_fs(oldmm); if (rc != 0) { CERROR("Can't set socket recv timeout %ld.%06d: %d\n", (long)tv.tv_sec, (int)tv.tv_usec, rc); @@ -384,7 +365,6 @@ libcfs_sock_create (struct socket **sockp, int *fatal, struct socket *sock; int rc; int option; - mm_segment_t oldmm = get_fs(); /* All errors are fatal except bind failure if the port is in use */ *fatal = 1; @@ -396,11 +376,9 @@ libcfs_sock_create (struct socket **sockp, int *fatal, return (rc); } - set_fs (KERNEL_DS); option = 1; - rc = sock_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, + rc = kernel_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&option, sizeof (option)); - set_fs (oldmm); if (rc != 0) { CERROR("Can't set SO_REUSEADDR for socket: %d\n", rc); goto failed; @@ -437,16 +415,13 @@ libcfs_sock_create (struct socket **sockp, int *fatal, int libcfs_sock_setbuf (struct socket *sock, int txbufsize, int rxbufsize) { - mm_segment_t oldmm = get_fs(); int option; int rc; if (txbufsize != 0) { option = txbufsize; - set_fs (KERNEL_DS); - rc = sock_setsockopt(sock, SOL_SOCKET, SO_SNDBUF, + rc = kernel_setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (char *)&option, sizeof (option)); - set_fs (oldmm); if (rc != 0) { CERROR ("Can't set send buffer %d: %d\n", option, rc); @@ -456,10 +431,8 @@ libcfs_sock_setbuf (struct socket *sock, int txbufsize, int rxbufsize) if (rxbufsize != 0) { option = rxbufsize; - set_fs (KERNEL_DS); - rc = sock_setsockopt (sock, SOL_SOCKET, SO_RCVBUF, + rc = kernel_setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char *)&option, sizeof (option)); - set_fs (oldmm); if (rc != 0) { CERROR ("Can't set receive buffer %d: %d\n", option, rc); -- cgit v1.2.3 From 472603137a81918d2ef2b06d9dd557544810539b Mon Sep 17 00:00:00 2001 From: Sarath Lakshman Date: Thu, 3 Apr 2014 02:30:18 +0530 Subject: staging: nokia_h4p: Fix a coding style problem Fold a line to make it less than 80 characters Signed-off-by: Sarath Lakshman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nokia_h4p/nokia_fw-bcm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/nokia_h4p/nokia_fw-bcm.c b/drivers/staging/nokia_h4p/nokia_fw-bcm.c index 111ae94032d1..b55f5ba1134e 100644 --- a/drivers/staging/nokia_h4p/nokia_fw-bcm.c +++ b/drivers/staging/nokia_h4p/nokia_fw-bcm.c @@ -73,7 +73,8 @@ void hci_h4p_bcm_parse_fw_event(struct hci_h4p_info *info, struct sk_buff *skb) return; } - if (fw_skb->data[1] == 0x01 && fw_skb->data[2] == 0xfc && fw_skb->len >= 10) { + if (fw_skb->data[1] == 0x01 && fw_skb->data[2] == 0xfc && + fw_skb->len >= 10) { BT_DBG("Setting bluetooth address"); err = hci_h4p_bcm_set_bdaddr(info, fw_skb); if (err < 0) { -- cgit v1.2.3 From d985a5840dd3abe7297721d5169ee3889a10089a Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Sat, 5 Apr 2014 00:18:55 +0300 Subject: staging: r8188eu: cleanup by using "len" consistently "*(p + 1)" and "len" are the same thing. For reviewers who don't know that, then this code is worrying because we cap "len", but pass "*(p + 1)" to memcpy(). I have changed the code to use "len" throughout. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 3ed5941bedc3..55be52fb34a9 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -6600,13 +6600,13 @@ u8 collect_bss_info(struct adapter *padapter, struct recv_frame *precv_frame, st return _FAIL; } - if (*(p + 1)) { + if (len) { if (len > NDIS_802_11_LENGTH_SSID) { DBG_88E("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len); return _FAIL; } - memcpy(bssid->Ssid.Ssid, (p + 2), *(p + 1)); - bssid->Ssid.SsidLength = *(p + 1); + memcpy(bssid->Ssid.Ssid, (p + 2), len); + bssid->Ssid.SsidLength = len; } else { bssid->Ssid.SsidLength = 0; } -- cgit v1.2.3 From 50b14a9e1625f3f12f31a149feb146b4c6eea4b1 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 29 Apr 2014 15:41:01 +0300 Subject: staging: r8188eu: indent for loop body The for loop body wasn't indented so it upset my static checker. Also I removed an obsolete comment on the same line. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_security.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c index c4b16ea6348a..05335959b543 100644 --- a/drivers/staging/rtl8188eu/core/rtw_security.c +++ b/drivers/staging/rtl8188eu/core/rtw_security.c @@ -1153,7 +1153,7 @@ static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen) /* Insert MIC into payload */ for (j = 0; j < 8; j++) - pframe[payload_index+j] = mic[j]; /* message[payload_index+j] = mic[j]; */ + pframe[payload_index+j] = mic[j]; payload_index = hdrlen + 8; for (i = 0; i < num_blocks; i++) { -- cgit v1.2.3 From bc802a2742fc414d365a3c9cfd500019a7c7283f Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 29 Apr 2014 15:42:13 +0300 Subject: staging: frontier: fix some indenting There were a couple lines which were not indented far enough and it was confusing. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/frontier/tranzport.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/frontier/tranzport.c b/drivers/staging/frontier/tranzport.c index 0571988c58fc..334ba04ae44b 100644 --- a/drivers/staging/frontier/tranzport.c +++ b/drivers/staging/frontier/tranzport.c @@ -271,8 +271,8 @@ static void usb_tranzport_interrupt_in_callback(struct urb *urb) dev->interrupt_in_buffer[6], dev->interrupt_in_buffer[7]); #if SUPPRESS_EXTRA_OFFLINE_EVENTS - if (dev->offline == 2 && dev->interrupt_in_buffer[1] == 0xff) - goto resubmit; + if (dev->offline == 2 && dev->interrupt_in_buffer[1] == 0xff) + goto resubmit; if (dev->offline == 1 && dev->interrupt_in_buffer[1] == 0xff) { dev->offline = 2; goto resubmit; @@ -285,8 +285,8 @@ static void usb_tranzport_interrupt_in_callback(struct urb *urb) dev->offline = 1; #endif /* SUPPRESS_EXTRA_OFFLINE_EVENTS */ - dbg_info(&dev->intf->dev, "%s: head, tail are %x, %x\n", - __func__, dev->ring_head, dev->ring_tail); + dbg_info(&dev->intf->dev, "%s: head, tail are %x, %x\n", + __func__, dev->ring_head, dev->ring_tail); next_ring_head = (dev->ring_head + 1) % ring_buffer_size; -- cgit v1.2.3 From ab0fbdc2c2363c5a921807b43f9bc8980318f096 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 30 Apr 2014 13:06:03 +0300 Subject: staging: rtl8192u: cleanup a switch statement The white space was all wrong here. The case statements were indented too far. The if else blocks weren't indented at all. There was a break statement aligned with the else block and it confused my static checker because "were curly braces intended" so that the break statement was only on the else side? Also I removed some commented out code. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/ieee80211_softmac.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 2131912113d7..9caf6fdb8eed 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -1903,20 +1903,17 @@ static void ieee80211_process_action(struct ieee80211_device *ieee, } tmp = *act; act ++; - switch (tmp) - { - case ACT_CAT_BA: - if (*act == ACT_ADDBAREQ) + switch (tmp) { + case ACT_CAT_BA: + if (*act == ACT_ADDBAREQ) ieee80211_rx_ADDBAReq(ieee, skb); - else if (*act == ACT_ADDBARSP) + else if (*act == ACT_ADDBARSP) ieee80211_rx_ADDBARsp(ieee, skb); - else if (*act == ACT_DELBA) + else if (*act == ACT_DELBA) ieee80211_rx_DELBA(ieee, skb); - break; - default: -// if (net_ratelimit()) -// IEEE80211_DEBUG(IEEE80211_DL_BA, "unknown action frame(%d)\n", tmp); - break; + break; + default: + break; } return; -- cgit v1.2.3 From 10f62861b4a2f22cbd6412b3c42c76f0bdfbd648 Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Thu, 1 May 2014 01:30:23 +0900 Subject: staging: android: fix missing a blank line after declarations This patch fixes "Missing a blank line after declarations" warnings. Signed-off-by: Seunghun Lee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/alarm-dev.c | 1 + drivers/staging/android/binder.c | 34 +++++++++++++++++++++++++++ drivers/staging/android/ion/ion.c | 10 ++++++++ drivers/staging/android/ion/ion_heap.c | 2 ++ drivers/staging/android/ion/ion_priv.h | 1 + drivers/staging/android/ion/ion_system_heap.c | 5 ++++ drivers/staging/android/logger.c | 3 +++ drivers/staging/android/sw_sync.c | 2 ++ drivers/staging/android/sync.c | 8 +++++++ drivers/staging/android/timed_gpio.c | 1 + 10 files changed, 67 insertions(+) diff --git a/drivers/staging/android/alarm-dev.c b/drivers/staging/android/alarm-dev.c index 2fc7cdd4c4e3..f200e8a84325 100644 --- a/drivers/staging/android/alarm-dev.c +++ b/drivers/staging/android/alarm-dev.c @@ -329,6 +329,7 @@ static int alarm_release(struct inode *inode, struct file *file) if (file->private_data) { for (i = 0; i < ANDROID_ALARM_TYPE_COUNT; i++) { uint32_t alarm_type_mask = 1U << i; + if (alarm_enabled & alarm_type_mask) { alarm_dbg(INFO, "%s: clear alarm, pending %d\n", diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c index 1f5e2499ac1b..35c00abc3dd1 100644 --- a/drivers/staging/android/binder.c +++ b/drivers/staging/android/binder.c @@ -118,6 +118,7 @@ static int binder_set_stop_on_user_error(const char *val, struct kernel_param *kp) { int ret; + ret = param_set_int(val, kp); if (binder_stop_on_user_error < 2) wake_up(&binder_user_error_wait); @@ -194,6 +195,7 @@ static struct binder_transaction_log_entry *binder_transaction_log_add( struct binder_transaction_log *log) { struct binder_transaction_log_entry *e; + e = &log->entry[log->next]; memset(e, 0, sizeof(*e)); log->next++; @@ -432,6 +434,7 @@ static inline void binder_unlock(const char *tag) static void binder_set_nice(long nice) { long min_nice; + if (can_nice(current, nice)) { set_user_nice(current, nice); return; @@ -584,6 +587,7 @@ static int binder_update_page_range(struct binder_proc *proc, int allocate, for (page_addr = start; page_addr < end; page_addr += PAGE_SIZE) { int ret; struct page **page_array_ptr; + page = &proc->pages[(page_addr - proc->buffer) / PAGE_SIZE]; BUG_ON(*page); @@ -726,6 +730,7 @@ static struct binder_buffer *binder_alloc_buf(struct binder_proc *proc, binder_insert_allocated_buffer(proc, buffer); if (buffer_size != size) { struct binder_buffer *new_buffer = (void *)buffer->data + size; + list_add(&new_buffer->entry, &buffer->entry); new_buffer->free = 1; binder_insert_free_buffer(proc, new_buffer); @@ -838,6 +843,7 @@ static void binder_free_buf(struct binder_proc *proc, if (!list_is_last(&buffer->entry, &proc->buffers)) { struct binder_buffer *next = list_entry(buffer->entry.next, struct binder_buffer, entry); + if (next->free) { rb_erase(&next->rb_node, &proc->free_buffers); binder_delete_free_buffer(proc, next); @@ -846,6 +852,7 @@ static void binder_free_buf(struct binder_proc *proc, if (proc->buffers.next != &buffer->entry) { struct binder_buffer *prev = list_entry(buffer->entry.prev, struct binder_buffer, entry); + if (prev->free) { binder_delete_free_buffer(proc, buffer); rb_erase(&prev->rb_node, &proc->free_buffers); @@ -1107,6 +1114,7 @@ static int binder_inc_ref(struct binder_ref *ref, int strong, struct list_head *target_list) { int ret; + if (strong) { if (ref->strong == 0) { ret = binder_inc_node(ref->node, 1, 1, target_list); @@ -1138,6 +1146,7 @@ static int binder_dec_ref(struct binder_ref *ref, int strong) ref->strong--; if (ref->strong == 0) { int ret; + ret = binder_dec_node(ref->node, strong, 1); if (ret) return ret; @@ -1177,6 +1186,7 @@ static void binder_send_failed_reply(struct binder_transaction *t, uint32_t error_code) { struct binder_thread *target_thread; + BUG_ON(t->flags & TF_ONE_WAY); while (1) { target_thread = t->from; @@ -1247,6 +1257,7 @@ static void binder_transaction_buffer_release(struct binder_proc *proc, off_end = (void *)offp + buffer->offsets_size; for (; offp < off_end; offp++) { struct flat_binder_object *fp; + if (*offp > buffer->data_size - sizeof(*fp) || buffer->data_size < sizeof(*fp) || !IS_ALIGNED(*offp, sizeof(u32))) { @@ -1259,6 +1270,7 @@ static void binder_transaction_buffer_release(struct binder_proc *proc, case BINDER_TYPE_BINDER: case BINDER_TYPE_WEAK_BINDER: { struct binder_node *node = binder_get_node(proc, fp->binder); + if (node == NULL) { pr_err("transaction release %d bad node %016llx\n", debug_id, (u64)fp->binder); @@ -1272,6 +1284,7 @@ static void binder_transaction_buffer_release(struct binder_proc *proc, case BINDER_TYPE_HANDLE: case BINDER_TYPE_WEAK_HANDLE: { struct binder_ref *ref = binder_get_ref(proc, fp->handle); + if (ref == NULL) { pr_err("transaction release %d bad handle %d\n", debug_id, fp->handle); @@ -1363,6 +1376,7 @@ static void binder_transaction(struct binder_proc *proc, } else { if (tr->target.handle) { struct binder_ref *ref; + ref = binder_get_ref(proc, tr->target.handle); if (ref == NULL) { binder_user_error("%d:%d got transaction to invalid handle\n", @@ -1386,6 +1400,7 @@ static void binder_transaction(struct binder_proc *proc, } if (!(tr->flags & TF_ONE_WAY) && thread->transaction_stack) { struct binder_transaction *tmp; + tmp = thread->transaction_stack; if (tmp->to_thread != thread) { binder_user_error("%d:%d got new transaction with bad transaction stack, transaction %d has target %d:%d\n", @@ -1501,6 +1516,7 @@ static void binder_transaction(struct binder_proc *proc, off_end = (void *)offp + tr->offsets_size; for (; offp < off_end; offp++) { struct flat_binder_object *fp; + if (*offp > t->buffer->data_size - sizeof(*fp) || t->buffer->data_size < sizeof(*fp) || !IS_ALIGNED(*offp, sizeof(u32))) { @@ -1515,6 +1531,7 @@ static void binder_transaction(struct binder_proc *proc, case BINDER_TYPE_WEAK_BINDER: { struct binder_ref *ref; struct binder_node *node = binder_get_node(proc, fp->binder); + if (node == NULL) { node = binder_new_node(proc, fp->binder, fp->cookie); if (node == NULL) { @@ -1553,6 +1570,7 @@ static void binder_transaction(struct binder_proc *proc, case BINDER_TYPE_HANDLE: case BINDER_TYPE_WEAK_HANDLE: { struct binder_ref *ref = binder_get_ref(proc, fp->handle); + if (ref == NULL) { binder_user_error("%d:%d got transaction with invalid handle, %d\n", proc->pid, @@ -1575,6 +1593,7 @@ static void binder_transaction(struct binder_proc *proc, (u64)ref->node->ptr); } else { struct binder_ref *new_ref; + new_ref = binder_get_ref_for_node(target_proc, ref->node); if (new_ref == NULL) { return_error = BR_FAILED_REPLY; @@ -1694,6 +1713,7 @@ err_no_context_mgr_node: { struct binder_transaction_log_entry *fe; + fe = binder_transaction_log_add(&binder_transaction_log_failed); *fe = *e; } @@ -2024,12 +2044,14 @@ static int binder_thread_write(struct binder_proc *proc, struct binder_work *w; binder_uintptr_t cookie; struct binder_ref_death *death = NULL; + if (get_user(cookie, (binder_uintptr_t __user *)ptr)) return -EFAULT; ptr += sizeof(void *); list_for_each_entry(w, &proc->delivered_death, entry) { struct binder_ref_death *tmp_death = container_of(w, struct binder_ref_death, work); + if (tmp_death->cookie == cookie) { death = tmp_death; break; @@ -2216,6 +2238,7 @@ retry: const char *cmd_name; int strong = node->internal_strong_refs || node->local_strong_refs; int weak = !hlist_empty(&node->refs) || node->local_weak_refs || strong; + if (weak && !node->has_weak_ref) { cmd = BR_INCREFS; cmd_name = "BR_INCREFS"; @@ -2322,6 +2345,7 @@ retry: BUG_ON(t->buffer == NULL); if (t->buffer->target_node) { struct binder_node *target_node = t->buffer->target_node; + tr.target.ptr = target_node->ptr; tr.cookie = target_node->cookie; t->saved_priority = task_nice(current); @@ -2343,6 +2367,7 @@ retry: if (t->from) { struct task_struct *sender = t->from->proc->tsk; + tr.sender_pid = task_tgid_nr_ns(sender, task_active_pid_ns(current)); } else { @@ -2413,6 +2438,7 @@ done: static void binder_release_work(struct list_head *list) { struct binder_work *w; + while (!list_empty(list)) { w = list_first_entry(list, struct binder_work, entry); list_del_init(&w->entry); @@ -2593,6 +2619,7 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) switch (cmd) { case BINDER_WRITE_READ: { struct binder_write_read bwr; + if (size != sizeof(struct binder_write_read)) { ret = -EINVAL; goto err; @@ -2717,6 +2744,7 @@ err_unlocked: static void binder_vma_open(struct vm_area_struct *vma) { struct binder_proc *proc = vma->vm_private_data; + binder_debug(BINDER_DEBUG_OPEN_CLOSE, "%d open vm area %lx-%lx (%ld K) vma %lx pagep %lx\n", proc->pid, vma->vm_start, vma->vm_end, @@ -2727,6 +2755,7 @@ static void binder_vma_open(struct vm_area_struct *vma) static void binder_vma_close(struct vm_area_struct *vma) { struct binder_proc *proc = vma->vm_private_data; + binder_debug(BINDER_DEBUG_OPEN_CLOSE, "%d close vm area %lx-%lx (%ld K) vma %lx pagep %lx\n", proc->pid, vma->vm_start, vma->vm_end, @@ -2869,6 +2898,7 @@ static int binder_open(struct inode *nodp, struct file *filp) if (binder_debugfs_dir_entry_proc) { char strbuf[11]; + snprintf(strbuf, sizeof(strbuf), "%u", proc->pid); proc->debugfs_entry = debugfs_create_file(strbuf, S_IRUGO, binder_debugfs_dir_entry_proc, proc, &binder_proc_fops); @@ -2890,8 +2920,10 @@ static void binder_deferred_flush(struct binder_proc *proc) { struct rb_node *n; int wake_count = 0; + for (n = rb_first(&proc->threads); n != NULL; n = rb_next(n)) { struct binder_thread *thread = rb_entry(n, struct binder_thread, rb_node); + thread->looper |= BINDER_LOOPER_STATE_NEED_RETURN; if (thread->looper & BINDER_LOOPER_STATE_WAITING) { wake_up_interruptible(&thread->wait); @@ -2908,6 +2940,7 @@ static void binder_deferred_flush(struct binder_proc *proc) static int binder_release(struct inode *nodp, struct file *filp) { struct binder_proc *proc = filp->private_data; + debugfs_remove(proc->debugfs_entry); binder_defer_work(proc, BINDER_DEFERRED_RELEASE); @@ -3069,6 +3102,7 @@ static void binder_deferred_func(struct work_struct *work) struct files_struct *files; int defer; + do { binder_lock(__func__); mutex_lock(&binder_deferred_lock); diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 3d5bf1472236..ea2c8a9addb5 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -408,6 +408,7 @@ static struct ion_handle *ion_handle_lookup(struct ion_client *client, while (n) { struct ion_handle *entry = rb_entry(n, struct ion_handle, node); + if (buffer < entry->buffer) n = n->rb_left; else if (buffer > entry->buffer) @@ -720,9 +721,11 @@ static int ion_get_client_serial(const struct rb_root *root, { int serial = -1; struct rb_node *node; + for (node = rb_first(root); node; node = rb_next(node)) { struct ion_client *client = rb_entry(node, struct ion_client, node); + if (strcmp(client->name, name)) continue; serial = max(serial, client->display_serial); @@ -1035,12 +1038,14 @@ static int ion_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma) static void ion_dma_buf_release(struct dma_buf *dmabuf) { struct ion_buffer *buffer = dmabuf->priv; + ion_buffer_put(buffer); } static void *ion_dma_buf_kmap(struct dma_buf *dmabuf, unsigned long offset) { struct ion_buffer *buffer = dmabuf->priv; + return buffer->vaddr + offset * PAGE_SIZE; } @@ -1292,6 +1297,7 @@ static long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) case ION_IOC_IMPORT: { struct ion_handle *handle; + handle = ion_import_dma_buf(client, data.fd.fd); if (IS_ERR(handle)) ret = PTR_ERR(handle); @@ -1393,6 +1399,7 @@ static int ion_debug_heap_show(struct seq_file *s, void *unused) struct ion_client *client = rb_entry(n, struct ion_client, node); size_t size = ion_debug_heap_total(client, heap->id); + if (!size) continue; if (client->task) { @@ -1516,6 +1523,7 @@ void ion_device_add_heap(struct ion_device *dev, struct ion_heap *heap) if (!debug_file) { char buf[256], *path; + path = dentry_path(dev->heaps_debug_root, buf, 256); pr_err("Failed to create heap debugfs at %s/%s\n", path, heap->name); @@ -1531,6 +1539,7 @@ void ion_device_add_heap(struct ion_device *dev, struct ion_heap *heap) &debug_shrink_fops); if (!debug_file) { char buf[256], *path; + path = dentry_path(dev->heaps_debug_root, buf, 256); pr_err("Failed to create heap shrinker debugfs at %s/%s\n", path, debug_name); @@ -1606,6 +1615,7 @@ void __init ion_reserve(struct ion_platform_data *data) if (data->heaps[i].base == 0) { phys_addr_t paddr; + paddr = memblock_alloc_base(data->heaps[i].size, data->heaps[i].align, MEMBLOCK_ALLOC_ANYWHERE); diff --git a/drivers/staging/android/ion/ion_heap.c b/drivers/staging/android/ion/ion_heap.c index bdc6a28ba8c9..4605e04712aa 100644 --- a/drivers/staging/android/ion/ion_heap.c +++ b/drivers/staging/android/ion/ion_heap.c @@ -48,6 +48,7 @@ void *ion_heap_map_kernel(struct ion_heap *heap, for_each_sg(table->sgl, sg, table->nents, i) { int npages_this_entry = PAGE_ALIGN(sg->length) / PAGE_SIZE; struct page *page = sg_page(sg); + BUG_ON(i >= npages); for (j = 0; j < npages_this_entry; j++) *(tmp++) = page++; @@ -105,6 +106,7 @@ int ion_heap_map_user(struct ion_heap *heap, struct ion_buffer *buffer, static int ion_heap_clear_pages(struct page **pages, int num, pgprot_t pgprot) { void *addr = vm_map_ram(pages, num, -1, pgprot); + if (!addr) return -ENOMEM; memset(addr, 0, PAGE_SIZE * num); diff --git a/drivers/staging/android/ion/ion_priv.h b/drivers/staging/android/ion/ion_priv.h index 1eba3f2076a9..c2dc942418bf 100644 --- a/drivers/staging/android/ion/ion_priv.h +++ b/drivers/staging/android/ion/ion_priv.h @@ -178,6 +178,7 @@ struct ion_heap { spinlock_t free_lock; wait_queue_head_t waitqueue; struct task_struct *task; + int (*debug_show)(struct ion_heap *heap, struct seq_file *, void *); }; diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c index 0663a7fbfa60..a14499514eb6 100644 --- a/drivers/staging/android/ion/ion_system_heap.c +++ b/drivers/staging/android/ion/ion_system_heap.c @@ -34,6 +34,7 @@ static const int num_orders = ARRAY_SIZE(orders); static int order_to_index(unsigned int order) { int i; + for (i = 0; i < num_orders; i++) if (order == orders[i]) return i; @@ -92,6 +93,7 @@ static void free_buffer_page(struct ion_system_heap *heap, if (!cached && !(buffer->private_flags & ION_PRIV_FLAG_SHRINKER_FREE)) { struct ion_page_pool *pool = heap->pools[order_to_index(order)]; + ion_page_pool_free(pool, page); } else { __free_pages(page, order); @@ -242,6 +244,7 @@ static int ion_system_heap_shrink(struct ion_heap *heap, gfp_t gfp_mask, for (i = 0; i < num_orders; i++) { struct ion_page_pool *pool = sys_heap->pools[i]; + nr_total += ion_page_pool_shrink(pool, gfp_mask, nr_to_scan); } @@ -267,8 +270,10 @@ static int ion_system_heap_debug_show(struct ion_heap *heap, struct seq_file *s, struct ion_system_heap, heap); int i; + for (i = 0; i < num_orders; i++) { struct ion_page_pool *pool = sys_heap->pools[i]; + seq_printf(s, "%d order %u highmem pages in pool = %lu total\n", pool->high_count, pool->order, (1 << pool->order) * PAGE_SIZE * pool->high_count); diff --git a/drivers/staging/android/logger.c b/drivers/staging/android/logger.c index d42f5785f098..2772e01b37f5 100644 --- a/drivers/staging/android/logger.c +++ b/drivers/staging/android/logger.c @@ -108,6 +108,7 @@ static inline struct logger_log *file_get_log(struct file *file) { if (file->f_mode & FMODE_READ) { struct logger_reader *reader = file->private_data; + return reader->log; } else return file->private_data; @@ -124,6 +125,7 @@ static struct logger_entry *get_entry_header(struct logger_log *log, size_t off, struct logger_entry *scratch) { size_t len = min(sizeof(struct logger_entry), log->size - off); + if (len != sizeof(struct logger_entry)) { memcpy(((void *) scratch), log->buffer + off, len); memcpy(((void *) scratch) + len, log->buffer, @@ -642,6 +644,7 @@ static unsigned int logger_poll(struct file *file, poll_table *wait) static long logger_set_version(struct logger_reader *reader, void __user *arg) { int version; + if (copy_from_user(&version, arg, sizeof(int))) return -EFAULT; diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index f24493ac65e3..12a136ec1cec 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -97,6 +97,7 @@ static void sw_sync_pt_value_str(struct sync_pt *sync_pt, char *str, int size) { struct sw_sync_pt *pt = (struct sw_sync_pt *)sync_pt; + snprintf(str, size, "%d", pt->value); } @@ -156,6 +157,7 @@ static int sw_sync_open(struct inode *inode, struct file *file) static int sw_sync_release(struct inode *inode, struct file *file) { struct sw_sync_timeline *obj = file->private_data; + sync_timeline_destroy(&obj->obj); return 0; } diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index 3d05f662110b..1f88c5d0f0c7 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -384,6 +384,7 @@ static void sync_fence_detach_pts(struct sync_fence *fence) list_for_each_safe(pos, n, &fence->pt_list_head) { struct sync_pt *pt = container_of(pos, struct sync_pt, pt_list); + sync_timeline_remove_pt(pt); } } @@ -394,6 +395,7 @@ static void sync_fence_free_pts(struct sync_fence *fence) list_for_each_safe(pos, n, &fence->pt_list_head) { struct sync_pt *pt = container_of(pos, struct sync_pt, pt_list); + sync_pt_free(pt); } } @@ -827,6 +829,7 @@ static long sync_fence_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { struct sync_fence *fence = file->private_data; + switch (cmd) { case SYNC_IOC_WAIT: return sync_fence_ioctl_wait(fence, arg); @@ -856,18 +859,21 @@ static const char *sync_status_str(int status) static void sync_print_pt(struct seq_file *s, struct sync_pt *pt, bool fence) { int status = pt->status; + seq_printf(s, " %s%spt %s", fence ? pt->parent->name : "", fence ? "_" : "", sync_status_str(status)); if (pt->status) { struct timeval tv = ktime_to_timeval(pt->timestamp); + seq_printf(s, "@%ld.%06ld", tv.tv_sec, tv.tv_usec); } if (pt->parent->ops->timeline_value_str && pt->parent->ops->pt_value_str) { char value[64]; + pt->parent->ops->pt_value_str(pt, value, sizeof(value)); seq_printf(s, ": %s", value); if (fence) { @@ -892,6 +898,7 @@ static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj) if (obj->ops->timeline_value_str) { char value[64]; + obj->ops->timeline_value_str(obj, value, sizeof(value)); seq_printf(s, ": %s", value); } else if (obj->ops->print_obj) { @@ -1001,6 +1008,7 @@ static void sync_dump(void) for (i = 0; i < s.count; i += DUMP_CHUNK) { if ((s.count - i) > DUMP_CHUNK) { char c = s.buf[i + DUMP_CHUNK]; + s.buf[i + DUMP_CHUNK] = 0; pr_cont("%s", s.buf + i); s.buf[i + DUMP_CHUNK] = c; diff --git a/drivers/staging/android/timed_gpio.c b/drivers/staging/android/timed_gpio.c index 0c7fdc83b336..f7d124da5b70 100644 --- a/drivers/staging/android/timed_gpio.c +++ b/drivers/staging/android/timed_gpio.c @@ -51,6 +51,7 @@ static int gpio_get_time(struct timed_output_dev *dev) if (hrtimer_active(&data->timer)) { ktime_t r = hrtimer_get_remaining(&data->timer); struct timeval t = ktime_to_timeval(r); + return t.tv_sec * 1000 + t.tv_usec / 1000; } else return 0; -- cgit v1.2.3 From c3c1ba6640d6c8f87a7bca440841924b58df8fb8 Mon Sep 17 00:00:00 2001 From: Jun Tian Date: Mon, 28 Apr 2014 20:47:03 +0100 Subject: goldfish: 64-bit audio driver for goldfish platform Enable the 64-bit goldfish audio driver. Support 64-bit buffer address and data read/write. Signed-off-by: Jun Tian Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/goldfish/goldfish_audio.c | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/staging/goldfish/goldfish_audio.c b/drivers/staging/goldfish/goldfish_audio.c index 9243845418d6..383bee687151 100644 --- a/drivers/staging/goldfish/goldfish_audio.c +++ b/drivers/staging/goldfish/goldfish_audio.c @@ -78,11 +78,18 @@ enum { /* set number of bytes in buffer to write */ AUDIO_WRITE_BUFFER_1 = 0x10, AUDIO_WRITE_BUFFER_2 = 0x14, +#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT + AUDIO_SET_WRITE_BUFFER_1_HIGH = 0x28, + AUDIO_SET_WRITE_BUFFER_2_HIGH = 0x30, +#endif /* true if audio input is supported */ AUDIO_READ_SUPPORTED = 0x18, /* buffer to use for audio input */ AUDIO_SET_READ_BUFFER = 0x1C, +#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT + AUDIO_SET_READ_BUFFER_HIGH = 0x34, +#endif /* driver writes number of bytes to read */ AUDIO_START_READ = 0x20, @@ -267,6 +274,9 @@ static int goldfish_audio_probe(struct platform_device *pdev) struct resource *r; struct goldfish_audio *data; dma_addr_t buf_addr; +#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT + u32 buf_addr_high, buf_addr_low; +#endif data = kzalloc(sizeof(*data), GFP_KERNEL); if (data == NULL) { @@ -322,6 +332,28 @@ static int goldfish_audio_probe(struct platform_device *pdev) goto err_misc_register_failed; } +#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT + buf_addr_low = (u32)(buf_addr); + buf_addr_high = (u32)((buf_addr) >> 32); + + AUDIO_WRITE(data, AUDIO_SET_WRITE_BUFFER_1, buf_addr_low); + AUDIO_WRITE(data, AUDIO_SET_WRITE_BUFFER_1_HIGH, buf_addr_high); + + buf_addr_low = (u32)(buf_addr + WRITE_BUFFER_SIZE); + buf_addr_high = (u32)((buf_addr + WRITE_BUFFER_SIZE) >> 32); + + AUDIO_WRITE(data, AUDIO_SET_WRITE_BUFFER_2, buf_addr_low); + AUDIO_WRITE(data, AUDIO_SET_WRITE_BUFFER_2_HIGH, buf_addr_high); + + buf_addr_low = (u32)(buf_addr + 2 * WRITE_BUFFER_SIZE); + buf_addr_high = (u32)((buf_addr + 2 * WRITE_BUFFER_SIZE) >> 32); + + data->read_supported = AUDIO_READ(data, AUDIO_READ_SUPPORTED); + if (data->read_supported){ + AUDIO_WRITE(data, AUDIO_SET_READ_BUFFER, buf_addr_low); + AUDIO_WRITE(data, AUDIO_SET_READ_BUFFER_HIGH, buf_addr_high); + } +#else AUDIO_WRITE(data, AUDIO_SET_WRITE_BUFFER_1, buf_addr); AUDIO_WRITE(data, AUDIO_SET_WRITE_BUFFER_2, buf_addr + WRITE_BUFFER_SIZE); @@ -330,6 +362,7 @@ static int goldfish_audio_probe(struct platform_device *pdev) if (data->read_supported) AUDIO_WRITE(data, AUDIO_SET_READ_BUFFER, buf_addr + 2 * WRITE_BUFFER_SIZE); +#endif audio_data = data; return 0; -- cgit v1.2.3 From 7f09d4a00cc85ca43b2a7f491f9b3f8498413f1b Mon Sep 17 00:00:00 2001 From: Jun Tian Date: Mon, 28 Apr 2014 20:47:22 +0100 Subject: goldfish: 64-bit nand driver for goldfish platform Enable the 64-bit nand data support in the goldfish nand driver. Signed-off-by: Jun Tian Signed-off-by: Octavian Purdila Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/goldfish/goldfish_nand.c | 5 ++++- drivers/staging/goldfish/goldfish_nand_reg.h | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/staging/goldfish/goldfish_nand.c b/drivers/staging/goldfish/goldfish_nand.c index 2a292df71e7c..b8e3dd28096d 100644 --- a/drivers/staging/goldfish/goldfish_nand.c +++ b/drivers/staging/goldfish/goldfish_nand.c @@ -67,7 +67,7 @@ static u32 goldfish_nand_cmd_with_params(struct mtd_info *mtd, cps->addr_high = (u32)(addr >> 32); cps->addr_low = (u32)addr; cps->transfer_size = len; - cps->data = (u32)ptr; + cps->data = (unsigned long)ptr; writel(cmdp, base + NAND_COMMAND); *rv = cps->result; return 0; @@ -87,6 +87,9 @@ static u32 goldfish_nand_cmd(struct mtd_info *mtd, enum nand_cmd cmd, writel((u32)addr, base + NAND_ADDR_LOW); writel(len, base + NAND_TRANSFER_SIZE); writel((u32)ptr, base + NAND_DATA); +#ifdef CONFIG_64BIT + writel((u32)((u64)ptr >> 32), base + NAND_DATA_HIGH); +#endif writel(cmd, base + NAND_COMMAND); rv = readl(base + NAND_RESULT); } diff --git a/drivers/staging/goldfish/goldfish_nand_reg.h b/drivers/staging/goldfish/goldfish_nand_reg.h index ddfda71ab27a..60ab91f74be7 100644 --- a/drivers/staging/goldfish/goldfish_nand_reg.h +++ b/drivers/staging/goldfish/goldfish_nand_reg.h @@ -57,6 +57,9 @@ enum nand_reg { NAND_RESULT = 0x040, NAND_COMMAND = 0x044, NAND_DATA = 0x048, +#ifdef CONFIG_64BIT + NAND_DATA_HIGH = 0x100, +#endif NAND_TRANSFER_SIZE = 0x04c, NAND_ADDR_LOW = 0x050, NAND_ADDR_HIGH = 0x054, @@ -69,7 +72,7 @@ struct cmd_params { uint32_t addr_low; uint32_t addr_high; uint32_t transfer_size; - uint32_t data; + unsigned long data; uint32_t result; }; #endif -- cgit v1.2.3 From 425f3740cf8e93fac6318ed862bcc3081b818f0b Mon Sep 17 00:00:00 2001 From: Alan Date: Mon, 28 Apr 2014 20:47:36 +0100 Subject: goldfish: Add a 64bit write helper The base code imported from the Google tree is ifdef heaven. Prepare to fix this by adding a helper function. Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- include/linux/goldfish.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 include/linux/goldfish.h diff --git a/include/linux/goldfish.h b/include/linux/goldfish.h new file mode 100644 index 000000000000..9cc28902b54c --- /dev/null +++ b/include/linux/goldfish.h @@ -0,0 +1,15 @@ +#ifndef __LINUX_GOLDFISH_H +#define __LINUX_GOLDFISH_H + +/* Helpers for Goldfish virtual platform */ + +static inline void gf_write64(unsigned long data, + void __iomem *portl, void __iomem *porth) +{ + writel((u32)data, portl); +#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT + writel(data>>32, porth); +#endif +} + +#endif /* __LINUX_GOLDFISH_H */ -- cgit v1.2.3 From c1bc97f8f498a2bfab63ceef761fb0e88ef7c065 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 28 Apr 2014 20:50:56 +0100 Subject: goldfish bus: don't call request_mem_region This is a bug fix that has been lurking in the Google tree but not pushed upstream. From: Octavian Purdila The memory region is already reserved in goldfish_init() during platform init. Signed-off-by: Octavian Purdila Signed-off-by: Jun Tian Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/platform/goldfish/pdev_bus.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/platform/goldfish/pdev_bus.c b/drivers/platform/goldfish/pdev_bus.c index 92cc4cfafde5..4eb2bb34790d 100644 --- a/drivers/platform/goldfish/pdev_bus.c +++ b/drivers/platform/goldfish/pdev_bus.c @@ -184,11 +184,6 @@ static int goldfish_pdev_bus_probe(struct platform_device *pdev) pdev_bus_addr = r->start; pdev_bus_len = resource_size(r); - if (request_mem_region(pdev_bus_addr, pdev_bus_len, "goldfish")) { - dev_err(&pdev->dev, "unable to reserve Goldfish MMIO.\n"); - return -EBUSY; - } - pdev_bus_base = ioremap(pdev_bus_addr, pdev_bus_len); if (pdev_bus_base == NULL) { ret = -ENOMEM; -- cgit v1.2.3 From 1d57261c96cf37949b87d9d239afb3734846d78e Mon Sep 17 00:00:00 2001 From: Christian Engelmayer Date: Sat, 26 Apr 2014 16:04:29 +0200 Subject: staging: comedi: remove duplicate pointer assignments in attach functions Some board pointer are assigned twice via comedi_board() in the comedi low level driver attach functions. Remove the duplicate assignment from the variable definition where the pointer is not used anyway until assigned later in the function when dev->board_ptr, that comedi_board() relies on, is setup correctly. Signed-off-by: Christian Engelmayer Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 2 +- drivers/staging/comedi/drivers/das800.c | 2 +- drivers/staging/comedi/drivers/dt2801.c | 2 +- drivers/staging/comedi/drivers/ni_at_a2150.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index d581029146cb..0335a70a918b 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -1479,7 +1479,7 @@ static int das1800_probe(struct comedi_device *dev) static int das1800_attach(struct comedi_device *dev, struct comedi_devconfig *it) { - const struct das1800_board *thisboard = comedi_board(dev); + const struct das1800_board *thisboard; struct das1800_private *devpriv; struct comedi_subdevice *s; unsigned int irq = it->options[1]; diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c index b23a12ce7651..e2dc43dbdc5e 100644 --- a/drivers/staging/comedi/drivers/das800.c +++ b/drivers/staging/comedi/drivers/das800.c @@ -683,7 +683,7 @@ static int das800_probe(struct comedi_device *dev) static int das800_attach(struct comedi_device *dev, struct comedi_devconfig *it) { - const struct das800_board *thisboard = comedi_board(dev); + const struct das800_board *thisboard; struct das800_private *devpriv; struct comedi_subdevice *s; unsigned int irq = it->options[1]; diff --git a/drivers/staging/comedi/drivers/dt2801.c b/drivers/staging/comedi/drivers/dt2801.c index d4d4e4b497dc..4263014426f8 100644 --- a/drivers/staging/comedi/drivers/dt2801.c +++ b/drivers/staging/comedi/drivers/dt2801.c @@ -545,7 +545,7 @@ static int dt2801_dio_insn_config(struct comedi_device *dev, */ static int dt2801_attach(struct comedi_device *dev, struct comedi_devconfig *it) { - const struct dt2801_board *board = comedi_board(dev); + const struct dt2801_board *board; struct dt2801_private *devpriv; struct comedi_subdevice *s; int board_code, type; diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/staging/comedi/drivers/ni_at_a2150.c index afbf251ba270..fefd97e2344d 100644 --- a/drivers/staging/comedi/drivers/ni_at_a2150.c +++ b/drivers/staging/comedi/drivers/ni_at_a2150.c @@ -695,7 +695,7 @@ static int a2150_probe(struct comedi_device *dev) static int a2150_attach(struct comedi_device *dev, struct comedi_devconfig *it) { - const struct a2150_board *thisboard = comedi_board(dev); + const struct a2150_board *thisboard; struct a2150_private *devpriv; struct comedi_subdevice *s; unsigned int irq = it->options[1]; -- cgit v1.2.3 From 4ae63178637d03bca6b58336ad3e4b3af9e60339 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Sat, 26 Apr 2014 20:35:58 -0500 Subject: staging: comedi: addi_apci_1564: remove eeprom support code Reading the eeprom on this board is not necessary. All information required is in the boardinfo. Remove the eeprom support code which is not really useful here. Signed-off-by: Chase Southwood Cc: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1564.c | 46 +------------------------ 1 file changed, 1 insertion(+), 45 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 5f6d3b56fad2..df8833b741f5 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -7,7 +7,6 @@ #include "addi-data/addi_common.h" -#include "addi-data/addi_eeprom.c" #include "addi-data/hwdrv_apci1564.c" static const struct addi_board apci1564_boardtypes[] = { @@ -33,23 +32,6 @@ static const struct addi_board apci1564_boardtypes[] = { }, }; -static int i_ADDIDATA_InsnReadEeprom(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - const struct addi_board *this_board = comedi_board(dev); - struct addi_private *devpriv = dev->private; - unsigned short w_Address = CR_CHAN(insn->chanspec); - unsigned short w_Data; - - w_Data = addi_eeprom_readw(devpriv->i_IobaseAmcc, - this_board->pc_EepromChip, 2 * w_Address); - data[0] = w_Data; - - return insn->n; -} - static irqreturn_t v_ADDI_Interrupt(int irq, void *d) { struct comedi_device *dev = d; @@ -75,7 +57,6 @@ static int apci1564_auto_attach(struct comedi_device *dev, struct addi_private *devpriv; struct comedi_subdevice *s; int ret, n_subdevices; - unsigned int dw_Dummy; dev->board_name = this_board->pc_DriverName; @@ -120,23 +101,6 @@ static int apci1564_auto_attach(struct comedi_device *dev, dev->irq = pcidev->irq; } - /* Read eepeom and fill addi_board Structure */ - - if (this_board->i_PCIEeprom) { - if (!(strcmp(this_board->pc_EepromChip, "S5920"))) { - /* Set 3 wait stait */ - if (!(strcmp(dev->board_name, "apci035"))) - outl(0x80808082, devpriv->i_IobaseAmcc + 0x60); - else - outl(0x83838383, devpriv->i_IobaseAmcc + 0x60); - - /* Enable the interrupt for the controller */ - dw_Dummy = inl(devpriv->i_IobaseAmcc + 0x38); - outl(dw_Dummy | 0x2000, devpriv->i_IobaseAmcc + 0x38); - } - addi_eeprom_read_info(dev, pci_resource_start(pcidev, 0)); - } - n_subdevices = 7; ret = comedi_alloc_subdevices(dev, n_subdevices); if (ret) @@ -212,15 +176,7 @@ static int apci1564_auto_attach(struct comedi_device *dev, /* EEPROM */ s = &dev->subdevices[6]; - if (this_board->i_PCIEeprom) { - s->type = COMEDI_SUBD_MEMORY; - s->subdev_flags = SDF_READABLE | SDF_INTERNAL; - s->n_chan = 256; - s->maxdata = 0xffff; - s->insn_read = i_ADDIDATA_InsnReadEeprom; - } else { - s->type = COMEDI_SUBD_UNUSED; - } + s->type = COMEDI_SUBD_UNUSED; i_ADDI_Reset(dev); return 0; -- cgit v1.2.3 From 6aa4f14c1febf0f602c5516857303de9cc05d6e6 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Sat, 26 Apr 2014 20:36:44 -0500 Subject: staging: comedi: addi_apci_1564: remove unnecessary include This include is no longer needed. Signed-off-by: Chase Southwood Cc: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1564.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index df8833b741f5..c84e17c60cec 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -3,7 +3,6 @@ #include "../comedidev.h" #include "comedi_fc.h" -#include "amcc_s5933.h" #include "addi-data/addi_common.h" -- cgit v1.2.3 From cffd83b6d1e6e403a77c5babf1443cdfd1a080ef Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Tue, 29 Apr 2014 03:34:23 -0500 Subject: staging: comedi: addi_apci_1564: board has 32 digital inputs This board always has 32 digital inputs. Remove the test when initializing the subdevice. Also, since this board is the only one supported by this driver, remove the boardinfo about the digital inputs and just use the data directly in the subdevice init. Signed-off-by: Chase Southwood Reviewed-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1564.c | 26 +++++++++---------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index c84e17c60cec..fe42f9d8f1d1 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -20,8 +20,6 @@ static const struct addi_board apci1564_boardtypes[] = { .i_Timer = 1, .interrupt = apci1564_interrupt, .reset = apci1564_reset, - .di_config = apci1564_di_config, - .di_bits = apci1564_di_insn_bits, .do_config = apci1564_do_config, .do_bits = apci1564_do_insn_bits, .do_read = apci1564_do_read, @@ -115,21 +113,15 @@ static int apci1564_auto_attach(struct comedi_device *dev, /* Allocate and Initialise DI Subdevice Structures */ s = &dev->subdevices[2]; - if (devpriv->s_EeParameters.i_NbrDiChannel) { - s->type = COMEDI_SUBD_DI; - s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = devpriv->s_EeParameters.i_NbrDiChannel; - s->maxdata = 1; - s->len_chanlist = - devpriv->s_EeParameters.i_NbrDiChannel; - s->range_table = &range_digital; - s->insn_config = this_board->di_config; - s->insn_read = this_board->di_read; - s->insn_write = this_board->di_write; - s->insn_bits = this_board->di_bits; - } else { - s->type = COMEDI_SUBD_UNUSED; - } + s->type = COMEDI_SUBD_DI; + s->subdev_flags = SDF_READABLE; + s->n_chan = 32; + s->maxdata = 1; + s->len_chanlist = 32; + s->range_table = &range_digital; + s->insn_config = apci1564_di_config; + s->insn_bits = apci1564_di_insn_bits; + /* Allocate and Initialise DO Subdevice Structures */ s = &dev->subdevices[3]; if (devpriv->s_EeParameters.i_NbrDoChannel) { -- cgit v1.2.3 From 128f798918c398b5ae84e5734c3b5df8c35d5d94 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Wed, 30 Apr 2014 02:57:59 -0500 Subject: staging: comedi: addi_apci_1564: simplify the PCI bar reading and don't read the unused bars This driver only uses PCI bar 0 (devpriv->i_IobaseAmcc), and PCI bar 1 (dev->iobase), don't bother reading the unused PCI bars. Signed-off-by: Chase Southwood Reviewed-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1564.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index fe42f9d8f1d1..9962c28a0de0 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -65,15 +65,8 @@ static int apci1564_auto_attach(struct comedi_device *dev, if (ret) return ret; - if (this_board->i_IorangeBase1) - dev->iobase = pci_resource_start(pcidev, 1); - else - dev->iobase = pci_resource_start(pcidev, 0); - - devpriv->iobase = dev->iobase; + dev->iobase = pci_resource_start(pcidev, 1); devpriv->i_IobaseAmcc = pci_resource_start(pcidev, 0); - devpriv->i_IobaseAddon = pci_resource_start(pcidev, 2); - devpriv->i_IobaseReserved = pci_resource_start(pcidev, 3); /* Initialize parameters that can be overridden in EEPROM */ devpriv->s_EeParameters.i_NbrAiChannel = this_board->i_NbrAiChannel; -- cgit v1.2.3 From a7e04a080831087e1413e5651c0bf59f5dcfa409 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Tue, 29 Apr 2014 03:37:17 -0500 Subject: staging: comedi: addi_apci_1564: remove unnecessary info from boardinfo The i_IorangeBase1, i_PCIEeprom, and pc_EepromChip data in the boardinfo was only needed to work out the usage of the PCI bars. Now that that is squared away, this info is no longer needed and can be removed. Signed-off-by: Chase Southwood Reviewed-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1564.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 9962c28a0de0..4ac3afa87697 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -11,9 +11,6 @@ static const struct addi_board apci1564_boardtypes[] = { { .pc_DriverName = "apci1564", - .i_IorangeBase1 = APCI1564_ADDRESS_RANGE, - .i_PCIEeprom = ADDIDATA_EEPROM, - .pc_EepromChip = ADDIDATA_93C76, .i_NbrDiChannel = 32, .i_NbrDoChannel = 32, .i_DoMaxdata = 0xffffffff, -- cgit v1.2.3 From 66d76f19d6aa863ac5b3e38be345daf9b609f226 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Sat, 3 May 2014 02:49:15 -0500 Subject: staging: comedi: addi_apci_1564: remove use of devpriv->s_EeParameters This driver no longer reads the eeprom to find the board specific data, all the necessary data is in the boardinfo. Use the boardinfo directly instead of passing through devpriv->s_EeParameters. Signed-off-by: Chase Southwood Cc: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1564.c | 27 +++++-------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 4ac3afa87697..ea22530a5cbd 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -65,22 +65,6 @@ static int apci1564_auto_attach(struct comedi_device *dev, dev->iobase = pci_resource_start(pcidev, 1); devpriv->i_IobaseAmcc = pci_resource_start(pcidev, 0); - /* Initialize parameters that can be overridden in EEPROM */ - devpriv->s_EeParameters.i_NbrAiChannel = this_board->i_NbrAiChannel; - devpriv->s_EeParameters.i_NbrAoChannel = this_board->i_NbrAoChannel; - devpriv->s_EeParameters.i_AiMaxdata = this_board->i_AiMaxdata; - devpriv->s_EeParameters.i_AoMaxdata = this_board->i_AoMaxdata; - devpriv->s_EeParameters.i_NbrDiChannel = this_board->i_NbrDiChannel; - devpriv->s_EeParameters.i_NbrDoChannel = this_board->i_NbrDoChannel; - devpriv->s_EeParameters.i_DoMaxdata = this_board->i_DoMaxdata; - devpriv->s_EeParameters.i_Timer = this_board->i_Timer; - devpriv->s_EeParameters.ui_MinAcquisitiontimeNs = - this_board->ui_MinAcquisitiontimeNs; - devpriv->s_EeParameters.ui_MinDelaytimeNs = - this_board->ui_MinDelaytimeNs; - - /* ## */ - if (pcidev->irq > 0) { ret = request_irq(pcidev->irq, v_ADDI_Interrupt, IRQF_SHARED, dev->board_name, dev); @@ -114,14 +98,13 @@ static int apci1564_auto_attach(struct comedi_device *dev, /* Allocate and Initialise DO Subdevice Structures */ s = &dev->subdevices[3]; - if (devpriv->s_EeParameters.i_NbrDoChannel) { + if (this_board->i_NbrDoChannel) { s->type = COMEDI_SUBD_DO; s->subdev_flags = SDF_READABLE | SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = devpriv->s_EeParameters.i_NbrDoChannel; - s->maxdata = devpriv->s_EeParameters.i_DoMaxdata; - s->len_chanlist = - devpriv->s_EeParameters.i_NbrDoChannel; + s->n_chan = this_board->i_NbrDoChannel; + s->maxdata = this_board->i_DoMaxdata; + s->len_chanlist = this_board->i_NbrDoChannel; s->range_table = &range_digital; /* insn_config - for digital output memory */ @@ -135,7 +118,7 @@ static int apci1564_auto_attach(struct comedi_device *dev, /* Allocate and Initialise Timer Subdevice Structures */ s = &dev->subdevices[4]; - if (devpriv->s_EeParameters.i_Timer) { + if (this_board->i_Timer) { s->type = COMEDI_SUBD_TIMER; s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; s->n_chan = 1; -- cgit v1.2.3 From 4bac39f6c9b00c9cfc3e418ea1d0afcd1c113c2f Mon Sep 17 00:00:00 2001 From: Raghavendra Ganiga Date: Thu, 1 May 2014 13:53:12 +0530 Subject: staging: comedi: fix coding style issues in comedi_fops.c This is a patch to fix coding style warnings found by checkpatch.pl tool Signed-off-by: Raghavendra Chandra Ganiga Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 70545e670dd0..b24bf9bcbe2d 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -668,6 +668,7 @@ static int do_devconfig_ioctl(struct comedi_device *dev, return -EBUSY; if (dev->attached) { struct module *driver_module = dev->driver->module; + comedi_device_detach(dev); module_put(driver_module); } @@ -2653,6 +2654,7 @@ static int __init comedi_init(void) /* create devices files for legacy/manual use */ for (i = 0; i < comedi_num_legacy_minors; i++) { struct comedi_device *dev; + dev = comedi_alloc_board_minor(NULL); if (IS_ERR(dev)) { comedi_cleanup_board_minors(); -- cgit v1.2.3 From b5a7a466932e9d6da6221785b34854b1838a7061 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 11:08:32 -0700 Subject: staging: comedi: adv_pci1710: tidy up pci171x_ai_check_chanlist() Tidy up this function to clarify what the chanlist is being checked for. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 81 ++++++++++++++-------------- 1 file changed, 41 insertions(+), 40 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 765b1f00255b..da1309b80691 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -326,60 +326,61 @@ static const unsigned int muxonechan[] = { 0x1818, 0x1919, 0x1a1a, 0x1b1b, 0x1c1c, 0x1d1d, 0x1e1e, 0x1f1f }; -/* -============================================================================== - Check if channel list from user is built correctly - If it's ok, then program scan/gain logic. - This works for all cards. -*/ static int pci171x_ai_check_chanlist(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { + unsigned int chan0 = CR_CHAN(cmd->chanlist[0]); + unsigned int last_aref = CR_AREF(cmd->chanlist[0]); + unsigned int next_chan = (chan0 + 1) % s->n_chan; unsigned int chansegment[32]; - unsigned int i, nowmustbechan, seglen, segpos; - unsigned int *chanlist = cmd->chanlist; - unsigned int n_chan = cmd->chanlist_len; - - /* correct channel and range number check itself comedi/range.c */ - if (n_chan < 1) { - comedi_error(dev, "range/channel list is empty!"); - return 0; - } + unsigned int seglen; + int i; - if (n_chan == 1) + if (cmd->chanlist_len == 1) return 1; /* seglen=1 */ - chansegment[0] = chanlist[0]; /* first channel is every time ok */ - for (i = 1, seglen = 1; i < n_chan; i++, seglen++) { - if (chanlist[0] == chanlist[i]) + /* first channel is always ok */ + chansegment[0] = cmd->chanlist[0]; + + for (i = 1; i < cmd->chanlist_len; i++) { + unsigned int chan = CR_CHAN(cmd->chanlist[i]); + unsigned int aref = CR_AREF(cmd->chanlist[i]); + + if (cmd->chanlist[0] == cmd->chanlist[i]) break; /* we detected a loop, stop */ - if ((CR_CHAN(chanlist[i]) & 1) && - (CR_AREF(chanlist[i]) == AREF_DIFF)) { - comedi_error(dev, "Odd channel cannot be differential input!\n"); + + if (aref == AREF_DIFF && (chan & 1)) { + dev_err(dev->class_dev, + "Odd channel cannot be differential input!\n"); return 0; } - nowmustbechan = (CR_CHAN(chansegment[i - 1]) + 1) % s->n_chan; - if (CR_AREF(chansegment[i - 1]) == AREF_DIFF) - nowmustbechan = (nowmustbechan + 1) % s->n_chan; - if (nowmustbechan != CR_CHAN(chanlist[i])) { - printk("channel list must be continuous! chanlist[%i]=%d but must be %d or %d!\n", - i, CR_CHAN(chanlist[i]), nowmustbechan, - CR_CHAN(chanlist[0])); + + if (last_aref == AREF_DIFF) + next_chan = (next_chan + 1) % s->n_chan; + if (chan != next_chan) { + dev_err(dev->class_dev, + "channel list must be continuous! chanlist[%i]=%d but must be %d or %d!\n", + i, chan, next_chan, chan0); return 0; } - chansegment[i] = chanlist[i]; /* next correct channel in list */ - } - for (i = 0, segpos = 0; i < n_chan; i++) { - if (chanlist[i] != chansegment[i % seglen]) { - printk("bad channel, reference or range number! chanlist[%i]=%d,%d,%d and not %d,%d,%d!\n", - i, CR_CHAN(chansegment[i]), - CR_RANGE(chansegment[i]), - CR_AREF(chansegment[i]), - CR_CHAN(chanlist[i % seglen]), - CR_RANGE(chanlist[i % seglen]), - CR_AREF(chansegment[i % seglen])); + /* next correct channel in list */ + chansegment[i] = cmd->chanlist[i]; + last_aref = aref; + } + seglen = i; + + for (i = 0; i < cmd->chanlist_len; i++) { + if (cmd->chanlist[i] != chansegment[i % seglen]) { + dev_err(dev->class_dev, + "bad channel, reference or range number! chanlist[%i]=%d,%d,%d and not %d,%d,%d!\n", + i, CR_CHAN(chansegment[i]), + CR_RANGE(chansegment[i]), + CR_AREF(chansegment[i]), + CR_CHAN(cmd->chanlist[i % seglen]), + CR_RANGE(cmd->chanlist[i % seglen]), + CR_AREF(chansegment[i % seglen])); return 0; } } -- cgit v1.2.3 From 56556577d9c4b4528935ddfc5635953c956d7fc9 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 11:08:33 -0700 Subject: staging: comedi: adv_pci1710: don't check the chanlist twice The chanlist is checked in Step 5 of the (*do_cmdtest) there is no reason to check it again in the (*do_cmd). The only reason its done again is to get the actual 'seglen', the non-repeating length of the chanlist. Save the 'seglen' found by pci171x_ai_check_chanlist() in the private data and use that in the (*do_cmd). Rename the private data member to clarify it. Also, remove the unused 'act_chanlist_pos' member from the private data. Refactor the error handling in pci171x_ai_check_chanlist() so it returns and errno for failure and 0 for success. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 34 ++++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index da1309b80691..f83c382c1eaa 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -310,8 +310,7 @@ struct pci1710_private { unsigned int ai_et_MuxVal; unsigned int ai_et_div1, ai_et_div2; unsigned int act_chanlist[32]; /* list of scanned channel */ - unsigned char act_chanlist_len; /* len of scanlist */ - unsigned char act_chanlist_pos; /* actual position in MUX list */ + unsigned char saved_seglen; /* len of the non-repeating chanlist */ unsigned char da_ranges; /* copy of D/A outpit range register */ unsigned short ao_data[4]; /* data output buffer */ unsigned int cnt0_write_wait; /* after a write, wait for update of the @@ -330,6 +329,7 @@ static int pci171x_ai_check_chanlist(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { + struct pci1710_private *devpriv = dev->private; unsigned int chan0 = CR_CHAN(cmd->chanlist[0]); unsigned int last_aref = CR_AREF(cmd->chanlist[0]); unsigned int next_chan = (chan0 + 1) % s->n_chan; @@ -337,8 +337,10 @@ static int pci171x_ai_check_chanlist(struct comedi_device *dev, unsigned int seglen; int i; - if (cmd->chanlist_len == 1) - return 1; /* seglen=1 */ + if (cmd->chanlist_len == 1) { + devpriv->saved_seglen = cmd->chanlist_len; + return 0; + } /* first channel is always ok */ chansegment[0] = cmd->chanlist[0]; @@ -353,7 +355,7 @@ static int pci171x_ai_check_chanlist(struct comedi_device *dev, if (aref == AREF_DIFF && (chan & 1)) { dev_err(dev->class_dev, "Odd channel cannot be differential input!\n"); - return 0; + return -EINVAL; } if (last_aref == AREF_DIFF) @@ -362,7 +364,7 @@ static int pci171x_ai_check_chanlist(struct comedi_device *dev, dev_err(dev->class_dev, "channel list must be continuous! chanlist[%i]=%d but must be %d or %d!\n", i, chan, next_chan, chan0); - return 0; + return -EINVAL; } /* next correct channel in list */ @@ -381,10 +383,12 @@ static int pci171x_ai_check_chanlist(struct comedi_device *dev, CR_CHAN(cmd->chanlist[i % seglen]), CR_RANGE(cmd->chanlist[i % seglen]), CR_AREF(chansegment[i % seglen])); - return 0; + return -EINVAL; } } - return seglen; + devpriv->saved_seglen = seglen; + + return 0; } static void setup_channel_list(struct comedi_device *dev, @@ -396,9 +400,6 @@ static void setup_channel_list(struct comedi_device *dev, struct pci1710_private *devpriv = dev->private; unsigned int i, range, chanprog; - devpriv->act_chanlist_len = seglen; - devpriv->act_chanlist_pos = 0; - for (i = 0; i < seglen; i++) { /* store range list to card */ chanprog = muxonechan[CR_CHAN(chanlist[i])]; outw(chanprog, dev->iobase + PCI171x_MUX); /* select channel */ @@ -953,7 +954,6 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) struct pci1710_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; unsigned int divisor1 = 0, divisor2 = 0; - unsigned int seglen; int mode; if (cmd->convert_src == TRIG_TIMER) { @@ -967,10 +967,8 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) start_pacer(dev, -1, 0, 0); /* stop pacer */ - seglen = pci171x_ai_check_chanlist(dev, s, cmd); - if (seglen < 1) - return -EINVAL; - setup_channel_list(dev, s, cmd->chanlist, cmd->chanlist_len, seglen); + setup_channel_list(dev, s, cmd->chanlist, cmd->chanlist_len, + devpriv->saved_seglen); outb(0, dev->iobase + PCI171x_CLRFIFO); outb(0, dev->iobase + PCI171x_CLRINT); @@ -1104,7 +1102,9 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev, /* Step 5: check channel list */ - if (!pci171x_ai_check_chanlist(dev, s, cmd)) + err |= pci171x_ai_check_chanlist(dev, s, cmd); + + if (err) return 5; return 0; -- cgit v1.2.3 From b4720286248acb7b696d95c72641c80bced6b3d3 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 11:08:34 -0700 Subject: staging: comedi: adv_pci1710: remove 'neverending_ai' from private data This member of the private data is not necessary. We can determine if the analog input command is neverending by checking the cmd->stop_src: TRIG_COUNT -> !neverending_ai TRIG_NONE -> neverending_ai Do that instead and remove the unnecessary member. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index f83c382c1eaa..5a329d5d2019 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -298,7 +298,6 @@ static const struct boardtype boardtypes[] = { }; struct pci1710_private { - char neverending_ai; /* we do unlimited AI */ unsigned int CntrlReg; /* Control register */ unsigned int i8254_osc_base; /* frequence of onboard oscilator */ unsigned int ai_act_scan; /* how many scans we finished */ @@ -732,7 +731,6 @@ static int pci171x_ai_cancel(struct comedi_device *dev, devpriv->ai_act_scan = 0; s->async->cur_chan = 0; devpriv->ai_buf_ptr = 0; - devpriv->neverending_ai = 0; return 0; } @@ -800,8 +798,8 @@ static void interrupt_pci1710_every_sample(void *d) if (s->async->cur_chan == 0) { /* one scan done */ devpriv->ai_act_scan++; - if ((!devpriv->neverending_ai) && - (devpriv->ai_act_scan >= cmd->stop_arg)) { + if (cmd->stop_src == TRIG_COUNT && + devpriv->ai_act_scan >= cmd->stop_arg) { /* all data sampled */ s->async->events |= COMEDI_CB_EOA; cfc_handle_events(dev, s); @@ -901,13 +899,13 @@ static void interrupt_pci1710_half_fifo(void *d) return; } - if (!devpriv->neverending_ai) - if (devpriv->ai_act_scan >= cmd->stop_arg) { - /* all data sampled */ - s->async->events |= COMEDI_CB_EOA; - cfc_handle_events(dev, s); - return; - } + if (cmd->stop_src == TRIG_COUNT && + devpriv->ai_act_scan >= cmd->stop_arg) { + /* all data sampled */ + s->async->events |= COMEDI_CB_EOA; + cfc_handle_events(dev, s); + return; + } outb(0, dev->iobase + PCI171x_CLRINT); /* clear our INT request */ cfc_handle_events(dev, s); @@ -976,7 +974,6 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_act_scan = 0; s->async->cur_chan = 0; devpriv->ai_buf_ptr = 0; - devpriv->neverending_ai = 0; devpriv->CntrlReg &= Control_CNT0; /* don't we want wake up every scan? devpriv->ai_eos=1; */ @@ -987,12 +984,6 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_eos = 0; } - if (cmd->stop_arg == 0) - devpriv->neverending_ai = 1; - /* well, user want neverending */ - else - devpriv->neverending_ai = 0; - switch (mode) { case 1: case 2: -- cgit v1.2.3 From 17ac5ecf20e77833adbc01dcf82cb74c1e4c6896 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 11:08:35 -0700 Subject: staging: comedi: adv_pci1710: remove 'ai_buf_ptr' from private data This member of the private data is set to 0 but never used. Just remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 5a329d5d2019..4c9454e82b3a 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -302,7 +302,6 @@ struct pci1710_private { unsigned int i8254_osc_base; /* frequence of onboard oscilator */ unsigned int ai_act_scan; /* how many scans we finished */ unsigned int ai_act_chan; /* actual position in actual scan */ - unsigned int ai_buf_ptr; /* data buffer ptr in samples */ unsigned char ai_eos; /* 1=EOS wake up */ unsigned char ai_et; unsigned int ai_et_CntrlReg; @@ -730,7 +729,6 @@ static int pci171x_ai_cancel(struct comedi_device *dev, devpriv->ai_act_scan = 0; s->async->cur_chan = 0; - devpriv->ai_buf_ptr = 0; return 0; } @@ -973,7 +971,6 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_act_scan = 0; s->async->cur_chan = 0; - devpriv->ai_buf_ptr = 0; devpriv->CntrlReg &= Control_CNT0; /* don't we want wake up every scan? devpriv->ai_eos=1; */ -- cgit v1.2.3 From 5297a6ba0aba3d8c8238b53525a231a65fced0bf Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 11:08:36 -0700 Subject: staging: comedi: adv_pci1710: remove 'ai_eos' from private data This member of the private data is is not necessary. We can just check the cmd->flags for TRIG_WAKE_EOS when needed. Remvoe the member. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 4c9454e82b3a..6bdd915dc796 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -302,7 +302,6 @@ struct pci1710_private { unsigned int i8254_osc_base; /* frequence of onboard oscilator */ unsigned int ai_act_scan; /* how many scans we finished */ unsigned int ai_act_chan; /* actual position in actual scan */ - unsigned char ai_eos; /* 1=EOS wake up */ unsigned char ai_et; unsigned int ai_et_CntrlReg; unsigned int ai_et_MuxVal; @@ -916,9 +915,15 @@ static irqreturn_t interrupt_service_pci1710(int irq, void *d) { struct comedi_device *dev = d; struct pci1710_private *devpriv = dev->private; + struct comedi_subdevice *s; + struct comedi_cmd *cmd; if (!dev->attached) /* is device attached? */ return IRQ_NONE; /* no, exit */ + + s = dev->read_subdev; + cmd = &s->async->cmd; + /* is this interrupt from our board? */ if (!(inw(dev->iobase + PCI171x_STATUS) & Status_IRQ)) return IRQ_NONE; /* no, exit */ @@ -937,11 +942,12 @@ static irqreturn_t interrupt_service_pci1710(int irq, void *d) start_pacer(dev, 1, devpriv->ai_et_div1, devpriv->ai_et_div2); return IRQ_HANDLED; } - if (devpriv->ai_eos) { /* We use FIFO half full INT or not? */ + + if (cmd->flags & TRIG_WAKE_EOS) interrupt_pci1710_every_sample(d); - } else { + else interrupt_pci1710_half_fifo(d); - } + return IRQ_HANDLED; } @@ -973,13 +979,8 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) s->async->cur_chan = 0; devpriv->CntrlReg &= Control_CNT0; - /* don't we want wake up every scan? devpriv->ai_eos=1; */ - if (cmd->flags & TRIG_WAKE_EOS) { - devpriv->ai_eos = 1; - } else { + if ((cmd->flags & TRIG_WAKE_EOS) == 0) devpriv->CntrlReg |= Control_ONEFH; - devpriv->ai_eos = 0; - } switch (mode) { case 1: -- cgit v1.2.3 From 73bcf01cb8c57c699c2a194fef3bad9bd39d6e1a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 11:08:37 -0700 Subject: staging: comedi: adv_pci1710: only calc the pacer divisors once When the cmd->convert_src == TRIG_TIMER the divisors needed to generate the pacer time are calculated in the (*do_cmdtest) to validate the cmd->convert_arg. The core always does the (*do_cmdtest) before the (*do_cmd) so there is no reason to recalc the divisors. Save the calculated divisors in the private data as 'next_divisor[12]'. The (*do_cmd) then transfers them to the private data 'divisor[12]' so that they can be used to set the timer for the command immediately or later when the cmd->start_src is TRIG_EXT (mode 2 in this driver). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 6bdd915dc796..7941a3ef7bd4 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -305,7 +305,10 @@ struct pci1710_private { unsigned char ai_et; unsigned int ai_et_CntrlReg; unsigned int ai_et_MuxVal; - unsigned int ai_et_div1, ai_et_div2; + unsigned int next_divisor1; + unsigned int next_divisor2; + unsigned int divisor1; + unsigned int divisor2; unsigned int act_chanlist[32]; /* list of scanned channel */ unsigned char saved_seglen; /* len of the non-repeating chanlist */ unsigned char da_ranges; /* copy of D/A outpit range register */ @@ -939,7 +942,7 @@ static irqreturn_t interrupt_service_pci1710(int irq, void *d) outw(devpriv->ai_et_MuxVal, dev->iobase + PCI171x_MUX); outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL); /* start pacer */ - start_pacer(dev, 1, devpriv->ai_et_div1, devpriv->ai_et_div2); + start_pacer(dev, 1, devpriv->divisor1, devpriv->divisor2); return IRQ_HANDLED; } @@ -955,7 +958,6 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct pci1710_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - unsigned int divisor1 = 0, divisor2 = 0; int mode; if (cmd->convert_src == TRIG_TIMER) { @@ -982,6 +984,9 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if ((cmd->flags & TRIG_WAKE_EOS) == 0) devpriv->CntrlReg |= Control_ONEFH; + devpriv->divisor1 = devpriv->next_divisor1; + devpriv->divisor2 = devpriv->next_divisor2; + switch (mode) { case 1: case 2: @@ -995,17 +1000,11 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) } else { devpriv->ai_et = 0; } - i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, - &divisor1, &divisor2, - &cmd->convert_arg, - cmd->flags); outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL); if (mode != 2) { /* start pacer */ - start_pacer(dev, mode, divisor1, divisor2); - } else { - devpriv->ai_et_div1 = divisor1; - devpriv->ai_et_div2 = divisor2; + start_pacer(dev, mode, + devpriv->divisor1, devpriv->divisor2); } break; case 3: @@ -1028,7 +1027,6 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev, struct pci1710_private *devpriv = dev->private; int err = 0; int tmp; - unsigned int divisor1 = 0, divisor2 = 0; /* Step 1 : check if triggers are trivially valid */ @@ -1078,7 +1076,8 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev, if (cmd->convert_src == TRIG_TIMER) { tmp = cmd->convert_arg; i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, - &divisor1, &divisor2, + &devpriv->next_divisor1, + &devpriv->next_divisor2, &cmd->convert_arg, cmd->flags); if (cmd->convert_arg < this_board->ai_ns_min) cmd->convert_arg = this_board->ai_ns_min; -- cgit v1.2.3 From 335733438f703a4a54478360759b75ff1d24ebda Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 11:08:38 -0700 Subject: staging: comedi: adv_pci1710: remove local var in pci171x_ai_cmd() The local variable 'mode' is not necessary. We can determine the mode by checking the cmd->convert_src and cmd->start_src. Do this instead to clarify the code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 7941a3ef7bd4..6d0935a958d6 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -958,16 +958,6 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct pci1710_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - int mode; - - if (cmd->convert_src == TRIG_TIMER) { - if (cmd->start_src == TRIG_EXT) - mode = 2; - else - mode = 1; - } else { /* TRIG_EXT */ - mode = 3; - } start_pacer(dev, -1, 0, 0); /* stop pacer */ @@ -987,30 +977,27 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->divisor1 = devpriv->next_divisor1; devpriv->divisor2 = devpriv->next_divisor2; - switch (mode) { - case 1: - case 2: + if (cmd->convert_src == TRIG_TIMER) { devpriv->CntrlReg |= Control_PACER | Control_IRQEN; - if (mode == 2) { + if (cmd->start_src == TRIG_EXT) { devpriv->ai_et_CntrlReg = devpriv->CntrlReg; devpriv->CntrlReg &= ~(Control_PACER | Control_ONEFH | Control_GATE); devpriv->CntrlReg |= Control_EXT; devpriv->ai_et = 1; - } else { + } else { /* TRIG_NOW */ devpriv->ai_et = 0; } outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL); - if (mode != 2) { + + if (cmd->start_src == TRIG_NOW) { /* start pacer */ - start_pacer(dev, mode, + start_pacer(dev, 1, devpriv->divisor1, devpriv->divisor2); } - break; - case 3: + } else { /* TRIG_EXT */ devpriv->CntrlReg |= Control_EXT | Control_IRQEN; outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL); - break; } return 0; -- cgit v1.2.3 From 925ddefce0e9eec2412d03ceaa40f57323d09fec Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 11:08:39 -0700 Subject: staging: comedi: adv_pci1710: tidy up start_pacer() For aesthetics, rename this function so it has namespace associated with the driver. Change the parameters to the function. The 'mode' is really a flag to load the counters and the divisors can be found in the private data. To clarify the code and remove the magic numbers, use the 8253.h helpers to set the timer mode and load the counters. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 43 +++++++++++++--------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 6d0935a958d6..07999f072255 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -73,6 +73,9 @@ Configuration options: #define PCI171x_DAREF 14 /* W: D/A reference control */ #define PCI171x_DI 16 /* R: digi inputs */ #define PCI171x_DO 16 /* R: digi inputs */ + +#define PCI171X_TIMER_BASE 0x18 + #define PCI171x_CNT0 24 /* R/W: 8254 counter 0 */ #define PCI171x_CNT1 26 /* R/W: 8254 counter 1 */ #define PCI171x_CNT2 28 /* R/W: 8254 counter 2 */ @@ -567,20 +570,18 @@ static int pci171x_insn_bits_do(struct comedi_device *dev, return insn->n; } -/* -============================================================================== -*/ -static void start_pacer(struct comedi_device *dev, int mode, - unsigned int divisor1, unsigned int divisor2) +static void pci171x_start_pacer(struct comedi_device *dev, + bool load_counters) { - outw(0xb4, dev->iobase + PCI171x_CNTCTRL); - outw(0x74, dev->iobase + PCI171x_CNTCTRL); - - if (mode == 1) { - outw(divisor2 & 0xff, dev->iobase + PCI171x_CNT2); - outw((divisor2 >> 8) & 0xff, dev->iobase + PCI171x_CNT2); - outw(divisor1 & 0xff, dev->iobase + PCI171x_CNT1); - outw((divisor1 >> 8) & 0xff, dev->iobase + PCI171x_CNT1); + struct pci1710_private *devpriv = dev->private; + unsigned long timer_base = dev->iobase + PCI171X_TIMER_BASE; + + i8254_set_mode(timer_base, 1, 2, I8254_MODE2 | I8254_BINARY); + i8254_set_mode(timer_base, 1, 1, I8254_MODE2 | I8254_BINARY); + + if (load_counters) { + i8254_write(timer_base, 1, 2, devpriv->divisor2); + i8254_write(timer_base, 1, 1, devpriv->divisor1); } } @@ -723,7 +724,7 @@ static int pci171x_ai_cancel(struct comedi_device *dev, devpriv->CntrlReg |= Control_SW; outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL); /* reset any operations */ - start_pacer(dev, -1, 0, 0); + pci171x_start_pacer(dev, false); outb(0, dev->iobase + PCI171x_CLRFIFO); outb(0, dev->iobase + PCI171x_CLRINT); break; @@ -941,8 +942,7 @@ static irqreturn_t interrupt_service_pci1710(int irq, void *d) outb(0, dev->iobase + PCI171x_CLRINT); outw(devpriv->ai_et_MuxVal, dev->iobase + PCI171x_MUX); outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL); - /* start pacer */ - start_pacer(dev, 1, devpriv->divisor1, devpriv->divisor2); + pci171x_start_pacer(dev, true); return IRQ_HANDLED; } @@ -959,7 +959,7 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) struct pci1710_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - start_pacer(dev, -1, 0, 0); /* stop pacer */ + pci171x_start_pacer(dev, false); setup_channel_list(dev, s, cmd->chanlist, cmd->chanlist_len, devpriv->saved_seglen); @@ -990,11 +990,8 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) } outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL); - if (cmd->start_src == TRIG_NOW) { - /* start pacer */ - start_pacer(dev, 1, - devpriv->divisor1, devpriv->divisor2); - } + if (cmd->start_src == TRIG_NOW) + pci171x_start_pacer(dev, true); } else { /* TRIG_EXT */ devpriv->CntrlReg |= Control_EXT | Control_IRQEN; outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL); @@ -1098,7 +1095,7 @@ static int pci171x_reset(struct comedi_device *dev) outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL); /* reset any operations */ outb(0, dev->iobase + PCI171x_CLRFIFO); /* clear FIFO */ outb(0, dev->iobase + PCI171x_CLRINT); /* clear INT request */ - start_pacer(dev, -1, 0, 0); /* stop 8254 */ + pci171x_start_pacer(dev, false); devpriv->da_ranges = 0; if (this_board->n_aochan) { outb(devpriv->da_ranges, dev->iobase + PCI171x_DAREF); /* set DACs to 0..5V */ -- cgit v1.2.3 From e2d8c43b4eed79dee4248b040e6d66c447ccac3b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 11:08:40 -0700 Subject: staging: comedi: adv_pci1710: rename interrupt helper functions For aesthetics, rename the helper functions that are called by the interrupt function to handle reading the analog input samples. Also, change the parameters to the helpers to the comedi_device and comedi_subdevice pointers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 07999f072255..1ef75cb9e13b 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -736,14 +736,10 @@ static int pci171x_ai_cancel(struct comedi_device *dev, return 0; } -/* -============================================================================== -*/ -static void interrupt_pci1710_every_sample(void *d) +static void pci1710_handle_every_sample(struct comedi_device *dev, + struct comedi_subdevice *s) { - struct comedi_device *dev = d; struct pci1710_private *devpriv = dev->private; - struct comedi_subdevice *s = dev->read_subdev; struct comedi_cmd *cmd = &s->async->cmd; int m; #ifdef PCI171x_PARANOIDCHECK @@ -860,15 +856,11 @@ static int move_block_from_fifo(struct comedi_device *dev, return 0; } -/* -============================================================================== -*/ -static void interrupt_pci1710_half_fifo(void *d) +static void pci1710_handle_fifo(struct comedi_device *dev, + struct comedi_subdevice *s) { - struct comedi_device *dev = d; const struct boardtype *this_board = comedi_board(dev); struct pci1710_private *devpriv = dev->private; - struct comedi_subdevice *s = dev->read_subdev; struct comedi_cmd *cmd = &s->async->cmd; int m, samplesinbuf; @@ -947,9 +939,9 @@ static irqreturn_t interrupt_service_pci1710(int irq, void *d) } if (cmd->flags & TRIG_WAKE_EOS) - interrupt_pci1710_every_sample(d); + pci1710_handle_every_sample(dev, s); else - interrupt_pci1710_half_fifo(d); + pci1710_handle_fifo(dev, s); return IRQ_HANDLED; } -- cgit v1.2.3 From 16c7eb6047bb0261124dfc4b5e63873a9ca5c442 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 11:08:41 -0700 Subject: staging: comedi: adv_pci1710: always enable PCI171x_PARANOIDCHECK code This define enables code that checks for analog input channel dropout when reading samples. The define is enabled so we might as well always enable the code and remove the define. Factor out the common channel dropout detect code as a helper function and cleanup the code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 165 +++++++++++---------------- 1 file changed, 68 insertions(+), 97 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 1ef75cb9e13b..174f9de3b638 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -51,10 +51,6 @@ Configuration options: #include "8253.h" #include "amcc_s5933.h" -#define PCI171x_PARANOIDCHECK /* if defined, then is used code which control - * correct channel number on every 12 bit - * sample */ - /* hardware types of the cards */ #define TYPE_PCI171X 0 #define TYPE_PCI1713 2 @@ -328,6 +324,26 @@ static const unsigned int muxonechan[] = { 0x1818, 0x1919, 0x1a1a, 0x1b1b, 0x1c1c, 0x1d1d, 0x1e1e, 0x1f1f }; +static int pci171x_ai_dropout(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned int chan, + unsigned int val) +{ + const struct boardtype *board = comedi_board(dev); + struct pci1710_private *devpriv = dev->private; + + if (board->cardtype != TYPE_PCI1713) { + if ((val & 0xf000) != devpriv->act_chanlist[chan]) { + dev_err(dev->class_dev, + "A/D data droput: received from channel %d, expected %d\n", + (val >> 12) & 0xf, + (devpriv->act_chanlist[chan] >> 12) & 0xf); + return -ENODATA; + } + } + return 0; +} + static int pci171x_ai_check_chanlist(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) @@ -410,17 +426,13 @@ static void setup_channel_list(struct comedi_device *dev, if (CR_AREF(chanlist[i]) == AREF_DIFF) range |= 0x0020; outw(range, dev->iobase + PCI171x_RANGE); /* select gain */ -#ifdef PCI171x_PARANOIDCHECK devpriv->act_chanlist[i] = (CR_CHAN(chanlist[i]) << 12) & 0xf000; -#endif } -#ifdef PCI171x_PARANOIDCHECK for ( ; i < n_chan; i++) { /* store remainder of channel list */ devpriv->act_chanlist[i] = (CR_CHAN(chanlist[i]) << 12) & 0xf000; } -#endif devpriv->ai_et_MuxVal = CR_CHAN(chanlist[0]) | (CR_CHAN(chanlist[seglen - 1]) << 8); @@ -446,12 +458,9 @@ static int pci171x_insn_read_ai(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { struct pci1710_private *devpriv = dev->private; - int ret; - int n; -#ifdef PCI171x_PARANOIDCHECK - const struct boardtype *this_board = comedi_board(dev); - unsigned int idata; -#endif + unsigned int chan = CR_CHAN(insn->chanspec); + int ret = 0; + int i; devpriv->CntrlReg &= Control_CNT0; devpriv->CntrlReg |= Control_SW; /* set software trigger */ @@ -461,34 +470,27 @@ static int pci171x_insn_read_ai(struct comedi_device *dev, setup_channel_list(dev, s, &insn->chanspec, 1, 1); - for (n = 0; n < insn->n; n++) { + for (i = 0; i < insn->n; i++) { + unsigned int val; + outw(0, dev->iobase + PCI171x_SOFTTRG); /* start conversion */ ret = comedi_timeout(dev, s, insn, pci171x_ai_eoc, 0); - if (ret) { - outb(0, dev->iobase + PCI171x_CLRFIFO); - outb(0, dev->iobase + PCI171x_CLRINT); - return ret; - } + if (ret) + break; -#ifdef PCI171x_PARANOIDCHECK - idata = inw(dev->iobase + PCI171x_AD_DATA); - if (this_board->cardtype != TYPE_PCI1713) - if ((idata & 0xf000) != devpriv->act_chanlist[0]) { - comedi_error(dev, "A/D insn data droput!"); - return -ETIME; - } - data[n] = idata & 0x0fff; -#else - data[n] = inw(dev->iobase + PCI171x_AD_DATA) & 0x0fff; -#endif + val = inw(dev->iobase + PCI171x_AD_DATA); + ret = pci171x_ai_dropout(dev, s, chan, val); + if (ret) + break; + data[i] = val & s->maxdata; } outb(0, dev->iobase + PCI171x_CLRFIFO); outb(0, dev->iobase + PCI171x_CLRINT); - return n; + return ret ? ret : insn->n; } /* @@ -741,22 +743,20 @@ static void pci1710_handle_every_sample(struct comedi_device *dev, { struct pci1710_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - int m; -#ifdef PCI171x_PARANOIDCHECK - const struct boardtype *this_board = comedi_board(dev); - unsigned short sampl; -#endif + unsigned int status; + unsigned int val; + int ret; - m = inw(dev->iobase + PCI171x_STATUS); - if (m & Status_FE) { - dev_dbg(dev->class_dev, "A/D FIFO empty (%4x)\n", m); + status = inw(dev->iobase + PCI171x_STATUS); + if (status & Status_FE) { + dev_dbg(dev->class_dev, "A/D FIFO empty (%4x)\n", status); s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; cfc_handle_events(dev, s); return; } - if (m & Status_FF) { + if (status & Status_FF) { dev_dbg(dev->class_dev, - "A/D FIFO Full status (Fatal Error!) (%4x)\n", m); + "A/D FIFO Full status (Fatal Error!) (%4x)\n", status); s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; cfc_handle_events(dev, s); return; @@ -765,30 +765,16 @@ static void pci1710_handle_every_sample(struct comedi_device *dev, outb(0, dev->iobase + PCI171x_CLRINT); /* clear our INT request */ for (; !(inw(dev->iobase + PCI171x_STATUS) & Status_FE);) { -#ifdef PCI171x_PARANOIDCHECK - sampl = inw(dev->iobase + PCI171x_AD_DATA); - if (this_board->cardtype != TYPE_PCI1713) - if ((sampl & 0xf000) != - devpriv->act_chanlist[s->async->cur_chan]) { - printk - ("comedi: A/D data dropout: received data from channel %d, expected %d!\n", - (sampl & 0xf000) >> 12, - (devpriv-> - act_chanlist[s-> - async->cur_chan] & 0xf000) >> - 12); - s->async->events |= - COMEDI_CB_EOA | COMEDI_CB_ERROR; - cfc_handle_events(dev, s); - return; - } - comedi_buf_put(s->async, sampl & 0x0fff); -#else - comedi_buf_put(s->async, - inw(dev->iobase + PCI171x_AD_DATA) & 0x0fff); -#endif - ++s->async->cur_chan; + val = inw(dev->iobase + PCI171x_AD_DATA); + ret = pci171x_ai_dropout(dev, s, s->async->cur_chan, val); + if (ret) { + s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; + break; + } + + comedi_buf_put(s->async, val & s->maxdata); + s->async->cur_chan++; if (s->async->cur_chan >= cmd->chanlist_len) s->async->cur_chan = 0; @@ -799,8 +785,7 @@ static void pci1710_handle_every_sample(struct comedi_device *dev, devpriv->ai_act_scan >= cmd->stop_arg) { /* all data sampled */ s->async->events |= COMEDI_CB_EOA; - cfc_handle_events(dev, s); - return; + break; } } } @@ -818,41 +803,27 @@ static int move_block_from_fifo(struct comedi_device *dev, { struct pci1710_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - int i, j; -#ifdef PCI171x_PARANOIDCHECK - const struct boardtype *this_board = comedi_board(dev); - unsigned short sampl; -#endif + unsigned int val; + int ret; + int i; - j = s->async->cur_chan; for (i = 0; i < n; i++) { -#ifdef PCI171x_PARANOIDCHECK - sampl = inw(dev->iobase + PCI171x_AD_DATA); - if (this_board->cardtype != TYPE_PCI1713) - if ((sampl & 0xf000) != devpriv->act_chanlist[j]) { - dev_dbg(dev->class_dev, - "A/D FIFO data dropout: received data from channel %d, expected %d! (%d/%d/%d/%d/%d/%4x)\n", - (sampl & 0xf000) >> 12, - (devpriv->act_chanlist[j] & 0xf000) >> 12, - i, j, devpriv->ai_act_scan, n, turn, - sampl); - s->async->events |= - COMEDI_CB_EOA | COMEDI_CB_ERROR; - cfc_handle_events(dev, s); - return 1; - } - comedi_buf_put(s->async, sampl & 0x0fff); -#else - comedi_buf_put(s->async, - inw(dev->iobase + PCI171x_AD_DATA) & 0x0fff); -#endif - j++; - if (j >= cmd->chanlist_len) { - j = 0; + val = inw(dev->iobase + PCI171x_AD_DATA); + + ret = pci171x_ai_dropout(dev, s, s->async->cur_chan, val); + if (ret) { + s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; + return ret; + } + + comedi_buf_put(s->async, val & s->maxdata); + + s->async->cur_chan++; + if (s->async->cur_chan >= cmd->chanlist_len) { + s->async->cur_chan = 0; devpriv->ai_act_scan++; } } - s->async->cur_chan = j; return 0; } -- cgit v1.2.3 From 576a09f01bea680e46df033634541f33a70640cf Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 11:08:42 -0700 Subject: staging: comedi: adv_pci1710: remove 'i8254_osc_base' from private data This member of the private data is always set to I8254_OSC_BASE_10MHZ. Remove it from the private data and just open code the value. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 174f9de3b638..3060b951e9cd 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -298,7 +298,6 @@ static const struct boardtype boardtypes[] = { struct pci1710_private { unsigned int CntrlReg; /* Control register */ - unsigned int i8254_osc_base; /* frequence of onboard oscilator */ unsigned int ai_act_scan; /* how many scans we finished */ unsigned int ai_act_chan; /* actual position in actual scan */ unsigned char ai_et; @@ -1022,7 +1021,7 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev, if (cmd->convert_src == TRIG_TIMER) { tmp = cmd->convert_arg; - i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, + i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, &devpriv->next_divisor1, &devpriv->next_divisor2, &cmd->convert_arg, cmd->flags); @@ -1183,7 +1182,6 @@ static int pci1710_auto_attach(struct comedi_device *dev, s->do_cmd = pci171x_ai_cmd; s->cancel = pci171x_ai_cancel; } - devpriv->i8254_osc_base = I8254_OSC_BASE_10MHZ; subdev++; } -- cgit v1.2.3 From 8673804de08f047769d33858ad60a252b241bc76 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 11:08:43 -0700 Subject: staging: comedi: adv_pci1710: remove 'ai_act_chan' from private data This member of the private data is not ued by the driver. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 3060b951e9cd..0dc946eaa743 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -299,7 +299,6 @@ static const struct boardtype boardtypes[] = { struct pci1710_private { unsigned int CntrlReg; /* Control register */ unsigned int ai_act_scan; /* how many scans we finished */ - unsigned int ai_act_chan; /* actual position in actual scan */ unsigned char ai_et; unsigned int ai_et_CntrlReg; unsigned int ai_et_MuxVal; -- cgit v1.2.3 From f513b63f73e8bebc67a74dd46917788bfdf9c7cd Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:28 -0700 Subject: staging: comedi: cb_pcidas: don't calc ai pacer divisors twice The analog input async command can use the pacer for the scan_bagin_src or the convert_src. The (*do_cmdtest) validates that only one of these sources has the TRIG_TIMER selected and calculates the divisors when validating the cmd argument. There is no reason to recalc the divisors in the (*do_cmd). Just use the values from the private data. Also, refactor cb_pcidas_load_counters() to use the i8254_set_mode() and i8254_write() helpers instead of i8254_load(). This allows us to use the I8254_* defines when setting the mode to clarify the code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index 26fc00e552a8..48ac1f43a3d4 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -943,20 +943,16 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev, return 0; } -static void cb_pcidas_load_counters(struct comedi_device *dev, unsigned int *ns, - int rounding_flags) +static void cb_pcidas_load_counters(struct comedi_device *dev) { struct cb_pcidas_private *devpriv = dev->private; + unsigned long timer_base = devpriv->pacer_counter_dio + ADC8254; - i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, - &devpriv->divisor1, &devpriv->divisor2, - ns, rounding_flags); + i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY); + i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY); - /* Write the values of ctr1 and ctr2 into counters 1 and 2 */ - i8254_load(devpriv->pacer_counter_dio + ADC8254, 0, 1, - devpriv->divisor1, 2); - i8254_load(devpriv->pacer_counter_dio + ADC8254, 0, 2, - devpriv->divisor2, 2); + i8254_write(timer_base, 0, 1, devpriv->divisor1); + i8254_write(timer_base, 0, 2, devpriv->divisor2); } static int cb_pcidas_ai_cmd(struct comedi_device *dev, @@ -994,12 +990,8 @@ static int cb_pcidas_ai_cmd(struct comedi_device *dev, outw(bits, devpriv->control_status + ADCMUX_CONT); /* load counters */ - if (cmd->convert_src == TRIG_TIMER) - cb_pcidas_load_counters(dev, &cmd->convert_arg, - cmd->flags & TRIG_ROUND_MASK); - else if (cmd->scan_begin_src == TRIG_TIMER) - cb_pcidas_load_counters(dev, &cmd->scan_begin_arg, - cmd->flags & TRIG_ROUND_MASK); + if (cmd->scan_begin_src == TRIG_TIMER || cmd->convert_src == TRIG_TIMER) + cb_pcidas_load_counters(dev); /* set number of conversions */ if (cmd->stop_src == TRIG_COUNT) -- cgit v1.2.3 From 33eafb7761d244a3d41a25b56dd17ba05634907e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:29 -0700 Subject: staging: comedi: cb_pcidas: don't calc ao pacer divisors twice The analog output async command can use the pacer for the scan_begin_src. The (*do_cmdtest) calculates the divisors when validating the cmd argument. There is no reason to recalc the divisors in the (*do_cmd). Just use the values from the private data. For aesthetics, factor out the code that loads the counters to match the analog input. Refactor the code to use the i8254_set_mode() and i8254_write() helpers instead of i8254_load(). This allows us to use the I8254_* defines when setting the mode to clarify the code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index 48ac1f43a3d4..0df55dd0fb53 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -943,7 +943,7 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev, return 0; } -static void cb_pcidas_load_counters(struct comedi_device *dev) +static void cb_pcidas_ai_load_counters(struct comedi_device *dev) { struct cb_pcidas_private *devpriv = dev->private; unsigned long timer_base = devpriv->pacer_counter_dio + ADC8254; @@ -991,7 +991,7 @@ static int cb_pcidas_ai_cmd(struct comedi_device *dev, /* load counters */ if (cmd->scan_begin_src == TRIG_TIMER || cmd->convert_src == TRIG_TIMER) - cb_pcidas_load_counters(dev); + cb_pcidas_ai_load_counters(dev); /* set number of conversions */ if (cmd->stop_src == TRIG_COUNT) @@ -1196,6 +1196,18 @@ static int cb_pcidas_ao_inttrig(struct comedi_device *dev, return 0; } +static void cb_pcidas_ao_load_counters(struct comedi_device *dev) +{ + struct cb_pcidas_private *devpriv = dev->private; + unsigned long timer_base = devpriv->pacer_counter_dio + DAC8254; + + i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY); + i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY); + + i8254_write(timer_base, 0, 1, devpriv->ao_divisor1); + i8254_write(timer_base, 0, 2, devpriv->ao_divisor2); +} + static int cb_pcidas_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { @@ -1225,18 +1237,9 @@ static int cb_pcidas_ao_cmd(struct comedi_device *dev, outw(0, devpriv->ao_registers + DACFIFOCLR); /* load counters */ - if (cmd->scan_begin_src == TRIG_TIMER) { - i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, - &devpriv->ao_divisor1, - &devpriv->ao_divisor2, - &cmd->scan_begin_arg, cmd->flags); + if (cmd->scan_begin_src == TRIG_TIMER) + cb_pcidas_ao_load_counters(dev); - /* Write the values of ctr1 and ctr2 into counters 1 and 2 */ - i8254_load(devpriv->pacer_counter_dio + DAC8254, 0, 1, - devpriv->ao_divisor1, 2); - i8254_load(devpriv->pacer_counter_dio + DAC8254, 0, 2, - devpriv->ao_divisor2, 2); - } /* set number of conversions */ if (cmd->stop_src == TRIG_COUNT) devpriv->ao_count = cmd->chanlist_len * cmd->stop_arg; -- cgit v1.2.3 From 863e07c9f83c9674c0176771c40b56b48657e1e5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:30 -0700 Subject: staging: comedi: das16m1: don't calc pacer divisors twice The analog input async command can use the pacer for the convert_src. The (*do_cmdtest) calculates the divisors when validating the cmd argument. There is no reason to recalc the divisors in the (*do_cmd). Just use the values from the private data. Refactor das16m1_set_pacer() to use the i8254_set_mode() and i8254_write() helpers instead of i8254_load(). This allows us to use the I8254_* defines when setting the mode to clarify the code. Tidy up das16m1_cmd_exec() a bit. The pacer only needs to be set when the convert_src is TRIG_TIMER. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 41 +++++++++++--------------------- 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index a9cd21068ea8..4fe30cc254e3 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -254,26 +254,16 @@ static int das16m1_cmd_test(struct comedi_device *dev, return 0; } -/* This function takes a time in nanoseconds and sets the * - * 2 pacer clocks to the closest frequency possible. It also * - * returns the actual sampling period. */ -static unsigned int das16m1_set_pacer(struct comedi_device *dev, - unsigned int ns, int rounding_flags) +static void das16m1_set_pacer(struct comedi_device *dev) { struct das16m1_private_struct *devpriv = dev->private; + unsigned long timer_base = dev->iobase + DAS16M1_8254_SECOND; - i8253_cascade_ns_to_timer_2div(I8254_OSC_BASE_10MHZ, - &devpriv->divisor1, - &devpriv->divisor2, - &ns, rounding_flags); + i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY); + i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY); - /* Write the values of ctr1 and ctr2 into counters 1 and 2 */ - i8254_load(dev->iobase + DAS16M1_8254_SECOND, 0, 1, devpriv->divisor1, - 2); - i8254_load(dev->iobase + DAS16M1_8254_SECOND, 0, 2, devpriv->divisor2, - 2); - - return ns; + i8254_write(timer_base, 0, 1, devpriv->divisor1); + i8254_write(timer_base, 0, 2, devpriv->divisor2); } static int das16m1_cmd_exec(struct comedi_device *dev, @@ -307,10 +297,14 @@ static int das16m1_cmd_exec(struct comedi_device *dev, outb(byte, dev->iobase + DAS16M1_QUEUE_DATA); } - /* set counter mode and counts */ - cmd->convert_arg = - das16m1_set_pacer(dev, cmd->convert_arg, - cmd->flags & TRIG_ROUND_MASK); + /* enable interrupts and set internal pacer counter mode and counts */ + devpriv->control_state &= ~PACER_MASK; + if (cmd->convert_src == TRIG_TIMER) { + das16m1_set_pacer(dev); + devpriv->control_state |= INT_PACER; + } else { /* TRIG_EXT */ + devpriv->control_state |= EXT_PACER; + } /* set control & status register */ byte = 0; @@ -323,13 +317,6 @@ static int das16m1_cmd_exec(struct comedi_device *dev, /* clear interrupt bit */ outb(0, dev->iobase + DAS16M1_CLEAR_INTR); - /* enable interrupts and internal pacer */ - devpriv->control_state &= ~PACER_MASK; - if (cmd->convert_src == TRIG_TIMER) - devpriv->control_state |= INT_PACER; - else - devpriv->control_state |= EXT_PACER; - devpriv->control_state |= INTE; outb(devpriv->control_state, dev->iobase + DAS16M1_INTR_CONTROL); -- cgit v1.2.3 From 66fea98e6251e15d25965ef805786e8e0b1c5ee4 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:31 -0700 Subject: staging: comedi: das1800: refactor Step 4 of das1800_ai_do_cmdtest() Refactor this code to reduce the indent level and the > 80 char lines. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 71 ++++++++++++++------------------ 1 file changed, 31 insertions(+), 40 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 0335a70a918b..93fd58b60e5c 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -731,7 +731,7 @@ static irqreturn_t das1800_interrupt(int irq, void *d) /* converts requested conversion timing to timing compatible with * hardware, used only when card is in 'burst mode' */ -static unsigned int burst_convert_arg(unsigned int convert_arg, int round_mode) +static unsigned int burst_convert_arg(unsigned int convert_arg, int flags) { unsigned int micro_sec; @@ -740,7 +740,7 @@ static unsigned int burst_convert_arg(unsigned int convert_arg, int round_mode) convert_arg = 64000; /* the conversion time must be an integral number of microseconds */ - switch (round_mode) { + switch (flags & TRIG_ROUND_MASK) { case TRIG_ROUND_NEAREST: default: micro_sec = (convert_arg + 500) / 1000; @@ -785,7 +785,7 @@ static int das1800_ai_do_cmdtest(struct comedi_device *dev, const struct das1800_board *thisboard = comedi_board(dev); struct das1800_private *devpriv = dev->private; int err = 0; - unsigned int tmp_arg; + unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -843,48 +843,39 @@ static int das1800_ai_do_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ - if (cmd->convert_src == TRIG_TIMER) { - /* if we are not in burst mode */ - if (cmd->scan_begin_src == TRIG_FOLLOW) { - tmp_arg = cmd->convert_arg; - /* calculate counter values that give desired timing */ + if (cmd->scan_begin_src == TRIG_FOLLOW && + cmd->convert_src == TRIG_TIMER) { + /* we are not in burst mode */ + arg = cmd->convert_arg; + i8253_cascade_ns_to_timer(I8254_OSC_BASE_5MHZ, + &devpriv->divisor1, + &devpriv->divisor2, + &cmd->convert_arg, cmd->flags); + if (arg != cmd->convert_arg) + err++; + } else if (cmd->convert_src == TRIG_TIMER) { + /* we are in burst mode */ + arg = cmd->convert_arg; + cmd->convert_arg = burst_convert_arg(cmd->convert_arg, + cmd->flags); + if (arg != cmd->convert_arg) + err++; + + if (cmd->scan_begin_src == TRIG_TIMER) { + arg = cmd->convert_arg * cmd->chanlist_len; + if (arg > cmd->scan_begin_arg) { + cmd->scan_begin_arg = arg; + err++; + } + + arg = cmd->scan_begin_arg; i8253_cascade_ns_to_timer(I8254_OSC_BASE_5MHZ, &devpriv->divisor1, &devpriv->divisor2, - &cmd->convert_arg, + &cmd->scan_begin_arg, cmd->flags); - if (tmp_arg != cmd->convert_arg) - err++; - } - /* if we are in burst mode */ - else { - /* check that convert_arg is compatible */ - tmp_arg = cmd->convert_arg; - cmd->convert_arg = - burst_convert_arg(cmd->convert_arg, - cmd->flags & TRIG_ROUND_MASK); - if (tmp_arg != cmd->convert_arg) + if (arg != cmd->scan_begin_arg) err++; - - if (cmd->scan_begin_src == TRIG_TIMER) { - /* if scans are timed faster than conversion rate allows */ - if (cmd->convert_arg * cmd->chanlist_len > - cmd->scan_begin_arg) { - cmd->scan_begin_arg = - cmd->convert_arg * - cmd->chanlist_len; - err++; - } - tmp_arg = cmd->scan_begin_arg; - /* calculate counter values that give desired timing */ - i8253_cascade_ns_to_timer(I8254_OSC_BASE_5MHZ, - &devpriv->divisor1, - &devpriv->divisor2, - &cmd->scan_begin_arg, - cmd->flags); - if (tmp_arg != cmd->scan_begin_arg) - err++; - } } } -- cgit v1.2.3 From 1265c22fc8575e857f0a0573db263b507988f420 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:32 -0700 Subject: staging: comedi: das1800: don't calc pacer divisors twice The analog input async command can use the pacer for the scan_begin_src or the convert_src. The (*do_cmdtest) calculates the divisors when validating the cmd argument. There is no reason to recalc the divisors in the (*do_cmd). Just use the values from the private data. For aesthetics, rename the setup_counters() function so it has namespace associated with the driver. Refactor the function to use the values from the private data and absorb das1800_set_frequency() to clarify the code. Refactor the function to use the i8254_set_mode() and i8254_write() helpers instead of i8254_load(). This allows us to use the I8254_* defines when setting the mode to clarify the code. This function will not fail so change the return type to void to simplify the (*do_cmd) a bit. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 76 +++++++------------------------- 1 file changed, 16 insertions(+), 60 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 93fd58b60e5c..ba357b6ec127 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -962,68 +962,29 @@ static int control_c_bits(const struct comedi_cmd *cmd) return control_c; } -/* loads counters with divisor1, divisor2 from private structure */ -static int das1800_set_frequency(struct comedi_device *dev) +static void das1800_setup_counters(struct comedi_device *dev, + const struct comedi_cmd *cmd) { struct das1800_private *devpriv = dev->private; - int err = 0; - - /* counter 1, mode 2 */ - if (i8254_load(dev->iobase + DAS1800_COUNTER, 0, 1, devpriv->divisor1, - 2)) - err++; - /* counter 2, mode 2 */ - if (i8254_load(dev->iobase + DAS1800_COUNTER, 0, 2, devpriv->divisor2, - 2)) - err++; - if (err) - return -1; + unsigned long timer_base = dev->iobase + DAS1800_COUNTER; - return 0; -} - -/* sets up counters */ -static int setup_counters(struct comedi_device *dev, - const struct comedi_cmd *cmd) -{ - struct das1800_private *devpriv = dev->private; - unsigned int period; + /* setup cascaded counters for conversion/scan frequency */ + if ((cmd->scan_begin_src == TRIG_FOLLOW || + cmd->scan_begin_src == TRIG_TIMER) && + cmd->convert_src == TRIG_TIMER) { + i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY); + i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY); - /* setup cascaded counters for conversion/scan frequency */ - switch (cmd->scan_begin_src) { - case TRIG_FOLLOW: /* not in burst mode */ - if (cmd->convert_src == TRIG_TIMER) { - /* set conversion frequency */ - period = cmd->convert_arg; - i8253_cascade_ns_to_timer(I8254_OSC_BASE_5MHZ, - &devpriv->divisor1, - &devpriv->divisor2, - &period, cmd->flags); - if (das1800_set_frequency(dev) < 0) - return -1; - } - break; - case TRIG_TIMER: /* in burst mode */ - /* set scan frequency */ - period = cmd->scan_begin_arg; - i8253_cascade_ns_to_timer(I8254_OSC_BASE_5MHZ, - &devpriv->divisor1, - &devpriv->divisor2, - &period, cmd->flags); - if (das1800_set_frequency(dev) < 0) - return -1; - break; - default: - break; + i8254_write(timer_base, 0, 1, devpriv->divisor1); + i8254_write(timer_base, 0, 2, devpriv->divisor2); } - /* setup counter 0 for 'about triggering' */ + /* setup counter 0 for 'about triggering' */ if (cmd->stop_src == TRIG_EXT) { - /* load counter 0 in mode 0 */ - i8254_load(dev->iobase + DAS1800_COUNTER, 0, 0, 1, 0); - } + i8254_set_mode(timer_base, 0, 0, I8254_MODE0 | I8254_BINARY); - return 0; + i8254_write(timer_base, 0, 0, 1); + } } /* utility function that suggests a dma transfer size based on the conversion period 'ns' */ @@ -1136,7 +1097,6 @@ static int das1800_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct das1800_private *devpriv = dev->private; - int ret; int control_a, control_c; struct comedi_async *async = s->async; const struct comedi_cmd *cmd = &async->cmd; @@ -1167,11 +1127,7 @@ static int das1800_ai_do_cmd(struct comedi_device *dev, /* setup card and start */ program_chanlist(dev, cmd); - ret = setup_counters(dev, cmd); - if (ret < 0) { - comedi_error(dev, "Error setting up counters"); - return ret; - } + das1800_setup_counters(dev, cmd); setup_dma(dev, cmd); outb(control_c, dev->iobase + DAS1800_CONTROL_C); /* set conversion rate and length for burst mode */ -- cgit v1.2.3 From d33f88581d2bb06470cb12eb048d70ebdec6fee2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:33 -0700 Subject: staging: comedi: 8253.h: rename i8253_cascade_ns_to_timer_2div() All of the comedi drivers use the i8253_cascade_ns_to_timer macro when calculating the divisors for the cascaded timers. This macro just causes the i8253_cascade_ns_to_timer_2div() inline to be used. Rename i8253_cascade_ns_to_timer_2div() and remove the macro. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/8253.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/8253.h b/drivers/staging/comedi/drivers/8253.h index e3d737cf7302..88cd6f251dcc 100644 --- a/drivers/staging/comedi/drivers/8253.h +++ b/drivers/staging/comedi/drivers/8253.h @@ -30,8 +30,6 @@ #define I8254_OSC_BASE_2MHZ 500 #define I8254_OSC_BASE_1MHZ 1000 -#define i8253_cascade_ns_to_timer i8253_cascade_ns_to_timer_2div - static inline void i8253_cascade_ns_to_timer_2div_old(int i8253_osc_base, unsigned int *d1, unsigned int *d2, @@ -125,11 +123,11 @@ static inline void i8253_cascade_ns_to_timer_power(int i8253_osc_base, *d2 = div2 & 0xffff; } -static inline void i8253_cascade_ns_to_timer_2div(int i8253_osc_base, - unsigned int *d1, - unsigned int *d2, - unsigned int *nanosec, - int round_mode) +static inline void i8253_cascade_ns_to_timer(int i8253_osc_base, + unsigned int *d1, + unsigned int *d2, + unsigned int *nanosec, + int round_mode) { unsigned int divider; unsigned int div1, div2; -- cgit v1.2.3 From 8412a96127d2866a78dc8d73eeaedac688977f4f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:34 -0700 Subject: staging: comedi: 8253.h: remove the unused i8253_cascade_ns_to_timer_*() None of the comedi drivers use the i8253_cascade_ns_to_timer_2div_old() or i8253_cascade_ns_to_timer_power() helpers to calculate the cascaded divisors. Remove them to avoid any confusion. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/8253.h | 93 ----------------------------------- 1 file changed, 93 deletions(-) diff --git a/drivers/staging/comedi/drivers/8253.h b/drivers/staging/comedi/drivers/8253.h index 88cd6f251dcc..fb2c9d905723 100644 --- a/drivers/staging/comedi/drivers/8253.h +++ b/drivers/staging/comedi/drivers/8253.h @@ -30,99 +30,6 @@ #define I8254_OSC_BASE_2MHZ 500 #define I8254_OSC_BASE_1MHZ 1000 -static inline void i8253_cascade_ns_to_timer_2div_old(int i8253_osc_base, - unsigned int *d1, - unsigned int *d2, - unsigned int *nanosec, - int round_mode) -{ - int divider; - int div1, div2; - int div1_glb, div2_glb, ns_glb; - int div1_lub, div2_lub, ns_lub; - int ns; - - divider = (*nanosec + i8253_osc_base / 2) / i8253_osc_base; - - /* find 2 integers 1<={x,y}<=65536 such that x*y is - close to divider */ - - div1_lub = div2_lub = 0; - div1_glb = div2_glb = 0; - - ns_glb = 0; - ns_lub = 0xffffffff; - - div2 = 0x10000; - for (div1 = divider / 65536 + 1; div1 < div2; div1++) { - div2 = divider / div1; - - ns = i8253_osc_base * div1 * div2; - if (ns <= *nanosec && ns > ns_glb) { - ns_glb = ns; - div1_glb = div1; - div2_glb = div2; - } - - div2++; - if (div2 <= 65536) { - ns = i8253_osc_base * div1 * div2; - if (ns > *nanosec && ns < ns_lub) { - ns_lub = ns; - div1_lub = div1; - div2_lub = div2; - } - } - } - - *nanosec = div1_lub * div2_lub * i8253_osc_base; - *d1 = div1_lub & 0xffff; - *d2 = div2_lub & 0xffff; - return; -} - -static inline void i8253_cascade_ns_to_timer_power(int i8253_osc_base, - unsigned int *d1, - unsigned int *d2, - unsigned int *nanosec, - int round_mode) -{ - int div1, div2; - int base; - - for (div1 = 2; div1 <= (1 << 16); div1 <<= 1) { - base = i8253_osc_base * div1; - round_mode &= TRIG_ROUND_MASK; - switch (round_mode) { - case TRIG_ROUND_NEAREST: - default: - div2 = (*nanosec + base / 2) / base; - break; - case TRIG_ROUND_DOWN: - div2 = (*nanosec) / base; - break; - case TRIG_ROUND_UP: - div2 = (*nanosec + base - 1) / base; - break; - } - if (div2 < 2) - div2 = 2; - if (div2 <= 65536) { - *nanosec = div2 * base; - *d1 = div1 & 0xffff; - *d2 = div2 & 0xffff; - return; - } - } - - /* shouldn't get here */ - div1 = 0x10000; - div2 = 0x10000; - *nanosec = div1 * div2 * i8253_osc_base; - *d1 = div1 & 0xffff; - *d2 = div2 & 0xffff; -} - static inline void i8253_cascade_ns_to_timer(int i8253_osc_base, unsigned int *d1, unsigned int *d2, -- cgit v1.2.3 From f1c51faabc4d974cd118603e237aa5381437e634 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:35 -0700 Subject: staging: comedi: adl_pci9111: tidy up (*do_cmdtest) Step 4 This step in the (*do_cmdtest) fixes the comedi_cmd arguments, usually for TRIG_TIMER sources. Tidy up this step to clarify the code and remove the extra local variables. All the arguments are unsigned long so change the 'tmp' local variable type and rename it for aesthetics. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9111.c | 38 ++++++++++------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index 9225a382a2ae..96b1bf84d57b 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -355,7 +355,7 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev, { struct pci9111_private_data *dev_private = dev->private; int err = 0; - int tmp; + unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -413,41 +413,31 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev, if (err) return 3; - /* Step 4 : fix up any arguments */ + /* Step 4: fix up any arguments */ if (cmd->convert_src == TRIG_TIMER) { - tmp = cmd->convert_arg; + arg = cmd->convert_arg; i8253_cascade_ns_to_timer(I8254_OSC_BASE_2MHZ, &dev_private->div1, &dev_private->div2, &cmd->convert_arg, cmd->flags); - if (tmp != cmd->convert_arg) + if (cmd->convert_arg != arg) err |= -EINVAL; } - /* There's only one timer on this card, so the scan_begin timer must */ - /* be a multiple of chanlist_len*convert_arg */ + /* + * There's only one timer on this card, so the scan_begin timer + * must be a multiple of chanlist_len*convert_arg + */ if (cmd->scan_begin_src == TRIG_TIMER) { + arg = cmd->chanlist_len * cmd->convert_arg; - unsigned int scan_begin_min; - unsigned int scan_begin_arg; - unsigned int scan_factor; + if (arg < cmd->scan_begin_arg) + arg *= (cmd->scan_begin_arg / arg); - scan_begin_min = cmd->chanlist_len * cmd->convert_arg; - - if (cmd->scan_begin_arg != scan_begin_min) { - if (scan_begin_min < cmd->scan_begin_arg) { - scan_factor = - cmd->scan_begin_arg / scan_begin_min; - scan_begin_arg = scan_factor * scan_begin_min; - if (cmd->scan_begin_arg != scan_begin_arg) { - cmd->scan_begin_arg = scan_begin_arg; - err |= -EINVAL; - } - } else { - cmd->scan_begin_arg = scan_begin_min; - err |= -EINVAL; - } + if (cmd->scan_begin_arg != arg) { + cmd->scan_begin_arg = arg; + err |= -EINVAL; } } -- cgit v1.2.3 From 56e781203f055e93e2ff510d87a986e2b367c071 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:36 -0700 Subject: staging: comedi: addi_apci_2032: tidy up cmd use in apci2032_interrupt() Use a local variable for the comedi_cmd and tidy up this function a bit. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_2032.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_2032.c b/drivers/staging/comedi/drivers/addi_apci_2032.c index feefc7a5ca9a..2fd14553e57c 100644 --- a/drivers/staging/comedi/drivers/addi_apci_2032.c +++ b/drivers/staging/comedi/drivers/addi_apci_2032.c @@ -197,6 +197,7 @@ static irqreturn_t apci2032_interrupt(int irq, void *d) { struct comedi_device *dev = d; struct comedi_subdevice *s = dev->read_subdev; + struct comedi_cmd *cmd = &s->async->cmd; struct apci2032_int_private *subpriv; unsigned int val; bool do_event = false; @@ -222,21 +223,20 @@ static irqreturn_t apci2032_interrupt(int irq, void *d) */ if (subpriv->active && (val & subpriv->enabled_isns) != 0) { - unsigned short bits; - unsigned int n, len; - unsigned int *chanlist; + unsigned short bits = 0; + int i; /* Bits in scan data correspond to indices in channel list. */ - bits = 0; - len = s->async->cmd.chanlist_len; - chanlist = &s->async->cmd.chanlist[0]; - for (n = 0; n < len; n++) - if ((val & (1U << CR_CHAN(chanlist[n]))) != 0) - bits |= 1U << n; + for (i = 0; i < cmd->chanlist_len; i++) { + unsigned int chan = CR_CHAN(cmd->chanlist[i]); + + if (val & (1 << chan)) + bits |= (1 << i); + } if (comedi_buf_put(s->async, bits)) { s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS; - if (s->async->cmd.stop_src == TRIG_COUNT && + if (cmd->stop_src == TRIG_COUNT && subpriv->stop_count > 0) { subpriv->stop_count--; if (subpriv->stop_count == 0) { -- cgit v1.2.3 From 96410e7a3316a61ec509865ec76e7d033f8096eb Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:37 -0700 Subject: staging: comedi: amplc_pci224: remove 'ai_stop_continuous' from private data This member of the private data can be determined by checking the cmd->stop_src. Do that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci224.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index f0b04cac4a6e..3002156e7e79 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -377,7 +377,6 @@ struct pci224_private { unsigned int cached_div1; unsigned int cached_div2; unsigned int ao_stop_count; - short ao_stop_continuous; unsigned short ao_enab; /* max 16 channels so 'short' will do */ unsigned char intsce; }; @@ -521,7 +520,7 @@ static void pci224_ao_start(struct comedi_device *dev, unsigned long flags; set_bit(AO_CMD_STARTED, &devpriv->state); - if (!devpriv->ao_stop_continuous && devpriv->ao_stop_count == 0) { + if (cmd->stop_src == TRIG_COUNT && devpriv->ao_stop_count == 0) { /* An empty acquisition! */ s->async->events |= COMEDI_CB_EOA; cfc_handle_events(dev, s); @@ -560,7 +559,7 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, } /* Determine number of scans available in buffer. */ num_scans = comedi_buf_read_n_available(s->async) / bytes_per_scan; - if (!devpriv->ao_stop_continuous) { + if (cmd->stop_src == TRIG_COUNT) { /* Fixed number of scans. */ if (num_scans > devpriv->ao_stop_count) num_scans = devpriv->ao_stop_count; @@ -572,7 +571,7 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, switch (dacstat & PCI224_DACCON_FIFOFL_MASK) { case PCI224_DACCON_FIFOFL_EMPTY: room = PCI224_FIFO_ROOM_EMPTY; - if (!devpriv->ao_stop_continuous && devpriv->ao_stop_count == 0) { + if (cmd->stop_src == TRIG_COUNT && devpriv->ao_stop_count == 0) { /* FIFO empty at end of counted acquisition. */ s->async->events |= COMEDI_CB_EOA; cfc_handle_events(dev, s); @@ -614,7 +613,7 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, dev->iobase + PCI224_DACDATA); } } - if (!devpriv->ao_stop_continuous) { + if (cmd->stop_src == TRIG_COUNT) { devpriv->ao_stop_count -= num_scans; if (devpriv->ao_stop_count == 0) { /* @@ -952,18 +951,10 @@ static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) /* * Sort out end of acquisition. */ - switch (cmd->stop_src) { - case TRIG_COUNT: - /* Fixed number of scans. */ - devpriv->ao_stop_continuous = 0; + if (cmd->stop_src == TRIG_COUNT) devpriv->ao_stop_count = cmd->stop_arg; - break; - default: - /* Continuous scans. */ - devpriv->ao_stop_continuous = 1; + else /* TRIG_EXT | TRIG_NONE */ devpriv->ao_stop_count = 0; - break; - } spin_lock_irqsave(&devpriv->ao_spinlock, flags); if (cmd->start_src == TRIG_INT) { -- cgit v1.2.3 From bca4eac8fd36e8ab2990d513a9d6a34d2a5bd502 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:38 -0700 Subject: staging: comedi: amplc_pci230: remove 'ai_continuous' from private data This member of the private data can be determined by checking the cmd->stop_src. Do that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci230.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index d7ffd18206f9..c00bd7c46366 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -519,10 +519,6 @@ struct pci230_private { * level threshold (PCI230+/260+). */ unsigned short adcg; /* ADCG register value. */ unsigned char int_en; /* Interrupt enables bits. */ - unsigned char ai_continuous; /* Flag set when cmd->stop_src == - * TRIG_NONE - user chooses to stop - * continuous conversion by - * cancelation. */ unsigned char ao_continuous; /* Flag set when cmd->stop_src == * TRIG_NONE - user chooses to stop * continuous conversion by @@ -1862,9 +1858,9 @@ static void pci230_ai_update_fifo_trigger_level(struct comedi_device *dev, /* Wake at end of scan. */ wake = scanlen - devpriv->ai_scan_pos; } else { - if (devpriv->ai_continuous - || (devpriv->ai_scan_count >= PCI230_ADC_FIFOLEVEL_HALFFULL) - || (scanlen >= PCI230_ADC_FIFOLEVEL_HALFFULL)) { + if (cmd->stop_src != TRIG_COUNT || + devpriv->ai_scan_count >= PCI230_ADC_FIFOLEVEL_HALFFULL || + scanlen >= PCI230_ADC_FIFOLEVEL_HALFFULL) { wake = PCI230_ADC_FIFOLEVEL_HALFFULL; } else { wake = (devpriv->ai_scan_count * scanlen) @@ -2015,7 +2011,7 @@ static void pci230_ai_start(struct comedi_device *dev, struct comedi_cmd *cmd = &async->cmd; set_bit(AI_CMD_STARTED, &devpriv->state); - if (!devpriv->ai_continuous && (devpriv->ai_scan_count == 0)) { + if (cmd->stop_src == TRIG_COUNT && devpriv->ai_scan_count == 0) { /* An empty acquisition! */ async->events |= COMEDI_CB_EOA; pci230_ai_stop(dev, s); @@ -2163,6 +2159,7 @@ static void pci230_handle_ai(struct comedi_device *dev, struct comedi_subdevice *s) { struct pci230_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; unsigned int events = 0; unsigned int status_fifo; unsigned int i; @@ -2172,7 +2169,7 @@ static void pci230_handle_ai(struct comedi_device *dev, unsigned int scanlen = async->cmd.scan_end_arg; /* Determine number of samples to read. */ - if (devpriv->ai_continuous) { + if (cmd->stop_src != TRIG_COUNT) { todo = PCI230_ADC_FIFOLEVEL_HALFFULL; } else if (devpriv->ai_scan_count == 0) { todo = 0; @@ -2234,7 +2231,7 @@ static void pci230_handle_ai(struct comedi_device *dev, async->events |= COMEDI_CB_EOS; } } - if (!devpriv->ai_continuous && (devpriv->ai_scan_count == 0)) { + if (cmd->stop_src == TRIG_COUNT && devpriv->ai_scan_count == 0) { /* End of acquisition. */ events |= COMEDI_CB_EOA; } else { @@ -2285,14 +2282,10 @@ static int pci230_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) /* Get number of scans required. */ - if (cmd->stop_src == TRIG_COUNT) { + if (cmd->stop_src == TRIG_COUNT) devpriv->ai_scan_count = cmd->stop_arg; - devpriv->ai_continuous = 0; - } else { - /* TRIG_NONE, user calls cancel. */ + else /* TRIG_NONE, user calls cancel */ devpriv->ai_scan_count = 0; - devpriv->ai_continuous = 1; - } devpriv->ai_scan_pos = 0; /* Position within scan. */ /* Steps; -- cgit v1.2.3 From 7586fd6b3e2df042ce2b45cf4ab43a92af1a27ac Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:39 -0700 Subject: staging: comedi: amplc_pci230: remove 'ao_continuous' from private data This member of the private data can be determined by checking the cmd->stop_src. Do that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci230.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index c00bd7c46366..ff927c641748 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -519,10 +519,6 @@ struct pci230_private { * level threshold (PCI230+/260+). */ unsigned short adcg; /* ADCG register value. */ unsigned char int_en; /* Interrupt enables bits. */ - unsigned char ao_continuous; /* Flag set when cmd->stop_src == - * TRIG_NONE - user chooses to stop - * continuous conversion by - * cancelation. */ unsigned char ai_bipolar; /* Set if bipolar input range so we * know to mangle it. */ unsigned char ao_bipolar; /* Set if bipolar output range so we @@ -1164,7 +1160,7 @@ 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 (cmd->stop_src == TRIG_COUNT && devpriv->ao_scan_count == 0) return; for (i = 0; i < cmd->chanlist_len; i++) { /* Read sample from Comedi's circular buffer. */ @@ -1179,7 +1175,7 @@ static void pci230_handle_ao_nofifo(struct comedi_device *dev, pci230_ao_write_nofifo(dev, data, CR_CHAN(cmd->chanlist[i])); } async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS; - if (!devpriv->ao_continuous) { + if (cmd->stop_src == TRIG_COUNT) { devpriv->ao_scan_count--; if (devpriv->ao_scan_count == 0) { /* End of acquisition. */ @@ -1210,7 +1206,7 @@ static int pci230_handle_ao_fifo(struct comedi_device *dev, /* Determine number of scans available in buffer. */ bytes_per_scan = cmd->chanlist_len * sizeof(short); num_scans = comedi_buf_read_n_available(async) / bytes_per_scan; - if (!devpriv->ao_continuous) { + if (cmd->stop_src == TRIG_COUNT) { /* Fixed number of scans. */ if (num_scans > devpriv->ao_scan_count) num_scans = devpriv->ao_scan_count; @@ -1260,7 +1256,7 @@ static int pci230_handle_ao_fifo(struct comedi_device *dev, } } events |= COMEDI_CB_EOS | COMEDI_CB_BLOCK; - if (!devpriv->ao_continuous) { + if (cmd->stop_src == TRIG_COUNT) { devpriv->ao_scan_count -= num_scans; if (devpriv->ao_scan_count == 0) { /* All data for the command has been written @@ -1338,7 +1334,7 @@ static void pci230_ao_start(struct comedi_device *dev, unsigned long irqflags; set_bit(AO_CMD_STARTED, &devpriv->state); - if (!devpriv->ao_continuous && (devpriv->ao_scan_count == 0)) { + if (cmd->stop_src == TRIG_COUNT && devpriv->ao_scan_count == 0) { /* An empty acquisition! */ async->events |= COMEDI_CB_EOA; pci230_ao_stop(dev, s); @@ -1451,14 +1447,10 @@ static int pci230_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) } /* Get number of scans required. */ - if (cmd->stop_src == TRIG_COUNT) { + if (cmd->stop_src == TRIG_COUNT) devpriv->ao_scan_count = cmd->stop_arg; - devpriv->ao_continuous = 0; - } else { - /* TRIG_NONE, user calls cancel. */ + else /* TRIG_NONE, user calls cancel */ devpriv->ao_scan_count = 0; - devpriv->ao_continuous = 1; - } /* Set range - see analogue output range table; 0 => unipolar 10V, * 1 => bipolar +/-10V range scale */ -- cgit v1.2.3 From ffadead4e67899fd9ca0e33ce1a6bb1453e8b091 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:40 -0700 Subject: staging: comedi: addi_common.h: remove 'ui_AiFlags' from private data This member of the private data is a copy of the cmd->flags. Use that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/addi_common.h | 1 - drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 7 ++++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.h b/drivers/staging/comedi/drivers/addi-data/addi_common.h index 2ed2da3499f4..f4f0da5a26f8 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.h +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.h @@ -127,7 +127,6 @@ struct addi_private { unsigned int ui_AiReadData[32]; unsigned int ui_AiTimer0; /* Timer Constant for Timer0 */ unsigned int ui_AiTimer1; /* Timer constant for Timer1 */ - unsigned int ui_AiFlags; unsigned int ui_AiDataLength; unsigned int ui_AiNbrofScans; /* number of scans to do */ unsigned short us_UseDma; /* To use Dma or not */ diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 7ead23e34e8e..2bfccbbf5962 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -819,6 +819,7 @@ static int apci3120_cyclic_ai(int mode, { const struct addi_board *this_board = comedi_board(dev); struct addi_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; unsigned char b_Tmp; unsigned int ui_Tmp, ui_DelayTiming = 0, ui_TimerValue1 = 0, dmalen0 = 0, dmalen1 = 0, ui_TimerValue2 = @@ -1135,7 +1136,7 @@ static int apci3120_cyclic_ai(int mode, devpriv->ui_AiScanLength * 2 - dmalen0; } - if (devpriv->ui_AiFlags & TRIG_WAKE_EOS) { + if (cmd->flags & TRIG_WAKE_EOS) { /* don't we want wake up every scan? */ if (dmalen0 > (devpriv->ui_AiScanLength * 2)) { dmalen0 = devpriv->ui_AiScanLength * 2; @@ -1335,7 +1336,6 @@ static int apci3120_ai_cmd(struct comedi_device *dev, struct comedi_cmd *cmd = &s->async->cmd; /* loading private structure with cmd structure inputs */ - devpriv->ui_AiFlags = cmd->flags; devpriv->ui_AiNbrofChannels = cmd->chanlist_len; devpriv->ui_AiScanLength = cmd->scan_end_arg; devpriv->pui_AiChannelList = cmd->chanlist; @@ -1410,6 +1410,7 @@ static void apci3120_interrupt_dma(int irq, void *d) struct comedi_device *dev = d; struct addi_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; + struct comedi_cmd *cmd = &s->async->cmd; unsigned int next_dma_buf, samplesinbuf; unsigned long low_word, high_word, var; unsigned int ui_Tmp; @@ -1487,7 +1488,7 @@ static void apci3120_interrupt_dma(int irq, void *d) devpriv->ul_DmaBufferVirtual[devpriv-> ui_DmaActualBuffer], samplesinbuf); - if (!(devpriv->ui_AiFlags & TRIG_WAKE_EOS)) { + if (!(cmd->flags & TRIG_WAKE_EOS)) { s->async->events |= COMEDI_CB_EOS; comedi_event(dev, s); } -- cgit v1.2.3 From 72af0c4ed598419b908f12307cdac7151f622209 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:41 -0700 Subject: staging: comedi: addi_common.h: remove 'ui_AiScanLength' from private data This member of the private data is a copy of the cmd->scan_end_arg. Use that instead. Use a local variable in apci3120_cyclic_ai() for the DMA 'scan_bytes', which is the cmd->scan_end_arg * 2. Replace the open-coded '2' with sizeof(short). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/addi-data/addi_common.h | 1 - .../comedi/drivers/addi-data/hwdrv_apci3120.c | 37 +++++++++++----------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.h b/drivers/staging/comedi/drivers/addi-data/addi_common.h index f4f0da5a26f8..9e00410c5783 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.h +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.h @@ -121,7 +121,6 @@ struct addi_private { unsigned char b_AiContinuous; /* we do unlimited AI */ unsigned int ui_AiActualScan; /* how many scans we finished */ unsigned int ui_AiNbrofChannels; /* how many channels is measured */ - unsigned int ui_AiScanLength; /* Length of actual scanlist */ unsigned int *pui_AiChannelList; /* actual chanlist */ unsigned int ui_AiChannelList[32]; /* actual chanlist */ unsigned int ui_AiReadData[32]; diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 2bfccbbf5962..502121233d7f 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -1106,6 +1106,7 @@ static int apci3120_cyclic_ai(int mode, } } else { /* If DMA Enabled */ + unsigned int scan_bytes = cmd->scan_end_arg * sizeof(short); /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */ /* inw(dev->iobase+0); reset EOC bit */ @@ -1125,27 +1126,27 @@ static int apci3120_cyclic_ai(int mode, dmalen1 = devpriv->ui_DmaBufferSize[1]; if (!devpriv->b_AiContinuous) { - - if (dmalen0 > (devpriv->ui_AiNbrofScans * devpriv->ui_AiScanLength * 2)) { /* must we fill full first buffer? */ - dmalen0 = - devpriv->ui_AiNbrofScans * - devpriv->ui_AiScanLength * 2; - } else if (dmalen1 > (devpriv->ui_AiNbrofScans * devpriv->ui_AiScanLength * 2 - dmalen0)) /* and must we fill full second buffer when first is once filled? */ - dmalen1 = - devpriv->ui_AiNbrofScans * - devpriv->ui_AiScanLength * 2 - dmalen0; + /* + * Must we fill full first buffer? And must we fill + * full second buffer when first is once filled? + */ + if (dmalen0 > (devpriv->ui_AiNbrofScans * scan_bytes)) { + dmalen0 = devpriv->ui_AiNbrofScans * scan_bytes; + } else if (dmalen1 > (devpriv->ui_AiNbrofScans * scan_bytes - dmalen0)) + dmalen1 = devpriv->ui_AiNbrofScans * + scan_bytes - dmalen0; } if (cmd->flags & TRIG_WAKE_EOS) { /* don't we want wake up every scan? */ - if (dmalen0 > (devpriv->ui_AiScanLength * 2)) { - dmalen0 = devpriv->ui_AiScanLength * 2; - if (devpriv->ui_AiScanLength & 1) + if (dmalen0 > scan_bytes) { + dmalen0 = scan_bytes; + if (cmd->scan_end_arg & 1) dmalen0 += 2; } - if (dmalen1 > (devpriv->ui_AiScanLength * 2)) { - dmalen1 = devpriv->ui_AiScanLength * 2; - if (devpriv->ui_AiScanLength & 1) + if (dmalen1 > scan_bytes) { + dmalen1 = scan_bytes; + if (cmd->scan_end_arg & 1) dmalen1 -= 2; if (dmalen1 < 4) dmalen1 = 4; @@ -1337,7 +1338,6 @@ static int apci3120_ai_cmd(struct comedi_device *dev, /* loading private structure with cmd structure inputs */ devpriv->ui_AiNbrofChannels = cmd->chanlist_len; - devpriv->ui_AiScanLength = cmd->scan_end_arg; devpriv->pui_AiChannelList = cmd->chanlist; /* UPDATE-0.7.57->0.7.68devpriv->ui_AiDataLength=s->async->data_len; */ @@ -1390,11 +1390,12 @@ static void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev, unsigned int num_samples) { struct addi_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; devpriv->ui_AiActualScan += - (s->async->cur_chan + num_samples) / devpriv->ui_AiScanLength; + (s->async->cur_chan + num_samples) / cmd->scan_end_arg; s->async->cur_chan += num_samples; - s->async->cur_chan %= devpriv->ui_AiScanLength; + s->async->cur_chan %= cmd->scan_end_arg; cfc_write_array_to_buffer(s, dma_buffer, num_samples * sizeof(short)); } -- cgit v1.2.3 From bda88cd47559348d747dcf4741c6067e1348fa3c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:42 -0700 Subject: staging: comedi: addi_common.h: remove 'pui_AiChannelList' from private data This member of the private data is a copy of the cmd->chanlist. Use that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/addi_common.h | 1 - drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.h b/drivers/staging/comedi/drivers/addi-data/addi_common.h index 9e00410c5783..9978f135e141 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.h +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.h @@ -121,7 +121,6 @@ struct addi_private { unsigned char b_AiContinuous; /* we do unlimited AI */ unsigned int ui_AiActualScan; /* how many scans we finished */ unsigned int ui_AiNbrofChannels; /* how many channels is measured */ - unsigned int *pui_AiChannelList; /* actual chanlist */ unsigned int ui_AiChannelList[32]; /* actual chanlist */ unsigned int ui_AiReadData[32]; unsigned int ui_AiTimer0; /* Timer Constant for Timer0 */ diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 502121233d7f..e6de79c006de 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -901,7 +901,7 @@ static int apci3120_cyclic_ai(int mode, /* Initializes the sequence array */ /**********************************/ if (!apci3120_setup_chan_list(dev, s, devpriv->ui_AiNbrofChannels, - devpriv->pui_AiChannelList, 0)) + cmd->chanlist, 0)) return -EINVAL; us_TmpValue = (unsigned short) inw(dev->iobase + APCI3120_RD_STATUS); @@ -1338,7 +1338,6 @@ static int apci3120_ai_cmd(struct comedi_device *dev, /* loading private structure with cmd structure inputs */ devpriv->ui_AiNbrofChannels = cmd->chanlist_len; - devpriv->pui_AiChannelList = cmd->chanlist; /* UPDATE-0.7.57->0.7.68devpriv->ui_AiDataLength=s->async->data_len; */ devpriv->ui_AiDataLength = s->async->prealloc_bufsz; -- cgit v1.2.3 From 596c5a6e76eb1e24e049d85795050fd0ad20b947 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:43 -0700 Subject: staging: comedi: addi_common.h: remove 'ui_AiTimer0' from private data This member of the private data is a copy of the cmd->convert_arg. Use that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/addi_common.h | 1 - drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 5 +---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.h b/drivers/staging/comedi/drivers/addi-data/addi_common.h index 9978f135e141..097d67f430a2 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.h +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.h @@ -123,7 +123,6 @@ struct addi_private { unsigned int ui_AiNbrofChannels; /* how many channels is measured */ unsigned int ui_AiChannelList[32]; /* actual chanlist */ unsigned int ui_AiReadData[32]; - unsigned int ui_AiTimer0; /* Timer Constant for Timer0 */ unsigned int ui_AiTimer1; /* Timer constant for Timer1 */ unsigned int ui_AiDataLength; unsigned int ui_AiNbrofScans; /* number of scans to do */ diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index e6de79c006de..2975b94f40dd 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -892,7 +892,7 @@ static int apci3120_cyclic_ai(int mode, /* value for timer2 minus -2 has to be done .....dunno y?? */ ui_TimerValue2 = devpriv->ui_AiNbrofScans - 2; - ui_ConvertTiming = devpriv->ui_AiTimer0; + ui_ConvertTiming = cmd->convert_arg; if (mode == 2) ui_DelayTiming = devpriv->ui_AiTimer1; @@ -1347,7 +1347,6 @@ static int apci3120_ai_cmd(struct comedi_device *dev, else devpriv->ui_AiNbrofScans = 0; - devpriv->ui_AiTimer0 = 0; /* variables changed to timer0,timer1 */ devpriv->ui_AiTimer1 = 0; if ((devpriv->ui_AiNbrofScans == 0) || (devpriv->ui_AiNbrofScans == -1)) devpriv->b_AiContinuous = 1; /* user want neverending analog acquisition */ @@ -1363,7 +1362,6 @@ static int apci3120_ai_cmd(struct comedi_device *dev, if (cmd->convert_src == TRIG_TIMER) { /* mode 1 */ - devpriv->ui_AiTimer0 = cmd->convert_arg; /* timer constant in nano seconds */ /* return this_board->ai_cmd(1,dev,s); */ return apci3120_cyclic_ai(1, dev, s); } @@ -1373,7 +1371,6 @@ static int apci3120_ai_cmd(struct comedi_device *dev, && (cmd->convert_src == TRIG_TIMER)) { /* mode 2 */ devpriv->ui_AiTimer1 = cmd->scan_begin_arg; - devpriv->ui_AiTimer0 = cmd->convert_arg; /* variable changed timer2 to timer0 */ /* return this_board->ai_cmd(2,dev,s); */ return apci3120_cyclic_ai(2, dev, s); } -- cgit v1.2.3 From a1b986e88976e2ca566fa2726c2346b5fbd1903c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:44 -0700 Subject: staging: comedi: addi_common.h: remove 'ui_AiTimer1' from private data This member of the private data is a copy of the cmd->scan_begin_arg. Use that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/addi_common.h | 1 - drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.h b/drivers/staging/comedi/drivers/addi-data/addi_common.h index 097d67f430a2..b54819bbb10b 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.h +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.h @@ -123,7 +123,6 @@ struct addi_private { unsigned int ui_AiNbrofChannels; /* how many channels is measured */ unsigned int ui_AiChannelList[32]; /* actual chanlist */ unsigned int ui_AiReadData[32]; - unsigned int ui_AiTimer1; /* Timer constant for Timer1 */ unsigned int ui_AiDataLength; unsigned int ui_AiNbrofScans; /* number of scans to do */ unsigned short us_UseDma; /* To use Dma or not */ diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 2975b94f40dd..8f6f1522536e 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -895,7 +895,7 @@ static int apci3120_cyclic_ai(int mode, ui_ConvertTiming = cmd->convert_arg; if (mode == 2) - ui_DelayTiming = devpriv->ui_AiTimer1; + ui_DelayTiming = cmd->scan_begin_arg; /**********************************/ /* Initializes the sequence array */ @@ -1347,7 +1347,6 @@ static int apci3120_ai_cmd(struct comedi_device *dev, else devpriv->ui_AiNbrofScans = 0; - devpriv->ui_AiTimer1 = 0; if ((devpriv->ui_AiNbrofScans == 0) || (devpriv->ui_AiNbrofScans == -1)) devpriv->b_AiContinuous = 1; /* user want neverending analog acquisition */ /* stopped using cancel */ @@ -1370,7 +1369,6 @@ static int apci3120_ai_cmd(struct comedi_device *dev, if ((cmd->scan_begin_src == TRIG_TIMER) && (cmd->convert_src == TRIG_TIMER)) { /* mode 2 */ - devpriv->ui_AiTimer1 = cmd->scan_begin_arg; /* return this_board->ai_cmd(2,dev,s); */ return apci3120_cyclic_ai(2, dev, s); } -- cgit v1.2.3 From 5d6babe36ef3f2cc8cd3a2cef2fdb8bf4c144ed4 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:45 -0700 Subject: staging: comedi: addi_common.h: remove 'ui_AiDataLength' from private data This member of the private data is a copy of the s->async->prealloc_bufsz. Use that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/addi_common.h | 1 - drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 11 ++++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.h b/drivers/staging/comedi/drivers/addi-data/addi_common.h index b54819bbb10b..a2208e7a3605 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.h +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.h @@ -123,7 +123,6 @@ struct addi_private { unsigned int ui_AiNbrofChannels; /* how many channels is measured */ unsigned int ui_AiChannelList[32]; /* actual chanlist */ unsigned int ui_AiReadData[32]; - unsigned int ui_AiDataLength; unsigned int ui_AiNbrofScans; /* number of scans to do */ unsigned short us_UseDma; /* To use Dma or not */ unsigned char b_DmaDoubleBuffer; /* we can use double buffering */ diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 8f6f1522536e..cd8e9335aa6e 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -1152,10 +1152,10 @@ static int apci3120_cyclic_ai(int mode, dmalen1 = 4; } } else { /* isn't output buff smaller that our DMA buff? */ - if (dmalen0 > (devpriv->ui_AiDataLength)) - dmalen0 = devpriv->ui_AiDataLength; - if (dmalen1 > (devpriv->ui_AiDataLength)) - dmalen1 = devpriv->ui_AiDataLength; + if (dmalen0 > s->async->prealloc_bufsz) + dmalen0 = s->async->prealloc_bufsz; + if (dmalen1 > s->async->prealloc_bufsz) + dmalen1 = s->async->prealloc_bufsz; } devpriv->ui_DmaBufferUsesize[0] = dmalen0; devpriv->ui_DmaBufferUsesize[1] = dmalen1; @@ -1339,9 +1339,6 @@ static int apci3120_ai_cmd(struct comedi_device *dev, /* loading private structure with cmd structure inputs */ devpriv->ui_AiNbrofChannels = cmd->chanlist_len; - /* UPDATE-0.7.57->0.7.68devpriv->ui_AiDataLength=s->async->data_len; */ - devpriv->ui_AiDataLength = s->async->prealloc_bufsz; - if (cmd->stop_src == TRIG_COUNT) devpriv->ui_AiNbrofScans = cmd->stop_arg; else -- cgit v1.2.3 From eaca0032f1b5be78b0e8fe55934fd8db5d95d2d1 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:46 -0700 Subject: staging: comedi: addi_common.h: remove 'ui_AiNbrofScans' from private data This member of the private data is a copy of the cmd->stop_arg. Use that instead. Fix the b_AiContinuous check in apci3120_ai_cmd(). The (*do_cmdtest) validates that the cmd->stop_arg os >= 1 for TRIG_COUNT and 0 for TRIG_NONE. The correct test to set this flag is (cmd->stop_src == TRIG_NONE). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/addi-data/addi_common.h | 1 - .../comedi/drivers/addi-data/hwdrv_apci3120.c | 22 +++++++++------------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.h b/drivers/staging/comedi/drivers/addi-data/addi_common.h index a2208e7a3605..7471a0a9e13e 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.h +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.h @@ -123,7 +123,6 @@ struct addi_private { unsigned int ui_AiNbrofChannels; /* how many channels is measured */ unsigned int ui_AiChannelList[32]; /* actual chanlist */ unsigned int ui_AiReadData[32]; - unsigned int ui_AiNbrofScans; /* number of scans to do */ unsigned short us_UseDma; /* To use Dma or not */ unsigned char b_DmaDoubleBuffer; /* we can use double buffering */ unsigned int ui_DmaActualBuffer; /* which buffer is used now */ diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index cd8e9335aa6e..e4b92767b8ad 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -891,7 +891,7 @@ static int apci3120_cyclic_ai(int mode, devpriv->ui_DmaActualBuffer = 0; /* value for timer2 minus -2 has to be done .....dunno y?? */ - ui_TimerValue2 = devpriv->ui_AiNbrofScans - 2; + ui_TimerValue2 = cmd->stop_arg - 2; ui_ConvertTiming = cmd->convert_arg; if (mode == 2) @@ -1130,11 +1130,12 @@ static int apci3120_cyclic_ai(int mode, * Must we fill full first buffer? And must we fill * full second buffer when first is once filled? */ - if (dmalen0 > (devpriv->ui_AiNbrofScans * scan_bytes)) { - dmalen0 = devpriv->ui_AiNbrofScans * scan_bytes; - } else if (dmalen1 > (devpriv->ui_AiNbrofScans * scan_bytes - dmalen0)) - dmalen1 = devpriv->ui_AiNbrofScans * - scan_bytes - dmalen0; + if (dmalen0 > (cmd->stop_arg * scan_bytes)) { + dmalen0 = cmd->stop_arg * scan_bytes; + } else if (dmalen1 > (cmd->stop_arg * scan_bytes - + dmalen0)) + dmalen1 = cmd->stop_arg * scan_bytes - + dmalen0; } if (cmd->flags & TRIG_WAKE_EOS) { @@ -1339,12 +1340,7 @@ static int apci3120_ai_cmd(struct comedi_device *dev, /* loading private structure with cmd structure inputs */ devpriv->ui_AiNbrofChannels = cmd->chanlist_len; - if (cmd->stop_src == TRIG_COUNT) - devpriv->ui_AiNbrofScans = cmd->stop_arg; - else - devpriv->ui_AiNbrofScans = 0; - - if ((devpriv->ui_AiNbrofScans == 0) || (devpriv->ui_AiNbrofScans == -1)) + if (cmd->stop_src == TRIG_NONE) devpriv->b_AiContinuous = 1; /* user want neverending analog acquisition */ /* stopped using cancel */ @@ -1486,7 +1482,7 @@ static void apci3120_interrupt_dma(int irq, void *d) } } if (!devpriv->b_AiContinuous) - if (devpriv->ui_AiActualScan >= devpriv->ui_AiNbrofScans) { + if (devpriv->ui_AiActualScan >= cmd->stop_arg) { /* all data sampled */ apci3120_cancel(dev, s); devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE; -- cgit v1.2.3 From 2f673c5d10511e790de97ab885878cbad1678245 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:47 -0700 Subject: staging: comedi: addi_common.h: remove 'b_AiContinuous' from private data This member of the private data can be determined by checking the cmd->stop_src. Do that instead. Fix the b_AiContinuous check in apci3120_ai_cmd(). The (*do_cmdtest) validates that the cmd->stop_arg os >= 1 for TRIG_COUNT and 0 for TRIG_NONE. The correct test to set this flag is (cmd->stop_src == TRIG_NONE). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/addi_common.h | 1 - drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 15 +++++---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.h b/drivers/staging/comedi/drivers/addi-data/addi_common.h index 7471a0a9e13e..c55c5dae688e 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.h +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.h @@ -118,7 +118,6 @@ struct addi_private { int i_IobaseAmcc; /* base+size for AMCC chip */ int i_IobaseAddon; /* addon base address */ int i_IobaseReserved; - unsigned char b_AiContinuous; /* we do unlimited AI */ unsigned int ui_AiActualScan; /* how many scans we finished */ unsigned int ui_AiNbrofChannels; /* how many channels is measured */ unsigned int ui_AiChannelList[32]; /* actual chanlist */ diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index e4b92767b8ad..b9780768f88f 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -720,7 +720,6 @@ static int apci3120_cancel(struct comedi_device *dev, inw(dev->iobase + APCI3120_RD_STATUS); devpriv->ui_AiActualScan = 0; s->async->cur_chan = 0; - devpriv->b_AiContinuous = 0; devpriv->ui_DmaActualBuffer = 0; devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE; @@ -1038,7 +1037,7 @@ static int apci3120_cyclic_ai(int mode, outb(devpriv->b_ModeSelectRegister, dev->iobase + APCI3120_WRITE_MODE_SELECT); - if (!devpriv->b_AiContinuous) { + if (cmd->stop_src == TRIG_COUNT) { /* * configure Timer2 For counting EOS Reset gate 2 of Timer 2 to * disable it (Set Bit D14 to 0) @@ -1125,7 +1124,7 @@ static int apci3120_cyclic_ai(int mode, dmalen0 = devpriv->ui_DmaBufferSize[0]; dmalen1 = devpriv->ui_DmaBufferSize[1]; - if (!devpriv->b_AiContinuous) { + if (cmd->stop_src == TRIG_COUNT) { /* * Must we fill full first buffer? And must we fill * full second buffer when first is once filled? @@ -1294,8 +1293,8 @@ static int apci3120_cyclic_ai(int mode, /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ } - if ((devpriv->us_UseDma == APCI3120_DISABLE) - && !devpriv->b_AiContinuous) { + if (devpriv->us_UseDma == APCI3120_DISABLE && + cmd->stop_src == TRIG_COUNT) { /* set gate 2 to start conversion */ devpriv->us_OutputRegister = devpriv->us_OutputRegister | APCI3120_ENABLE_TIMER2; @@ -1340,10 +1339,6 @@ static int apci3120_ai_cmd(struct comedi_device *dev, /* loading private structure with cmd structure inputs */ devpriv->ui_AiNbrofChannels = cmd->chanlist_len; - if (cmd->stop_src == TRIG_NONE) - devpriv->b_AiContinuous = 1; /* user want neverending analog acquisition */ - /* stopped using cancel */ - if (cmd->start_src == TRIG_EXT) devpriv->b_ExttrigEnable = APCI3120_ENABLE; else @@ -1481,7 +1476,7 @@ static void apci3120_interrupt_dma(int irq, void *d) comedi_event(dev, s); } } - if (!devpriv->b_AiContinuous) + if (cmd->stop_src == TRIG_COUNT) if (devpriv->ui_AiActualScan >= cmd->stop_arg) { /* all data sampled */ apci3120_cancel(dev, s); -- cgit v1.2.3 From a19f71615875b207813fee32db983903a0ec5729 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:48 -0700 Subject: staging: comedi: hwdrv_apci3120: cmd->convert_src is always TRIG_TIMER The (*do_cmdtest) validates that the cmd->convert_src can only be TRIG_TIMER. Remove the unnecessay checks. THis also simplifies the (*do_cmd) a bit since "mode 3" (whatever that is) is never a valid mode. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 45 ++++++---------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index b9780768f88f..7bc6b8ff8157 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -765,15 +765,12 @@ static int apci3120_ai_cmdtest(struct comedi_device *dev, if (cmd->scan_begin_src == TRIG_TIMER) /* Test Delay timing */ err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, 100000); - if (cmd->convert_src == TRIG_TIMER) { /* Test Acquisition timing */ - if (cmd->scan_begin_src == TRIG_TIMER) { - if (cmd->convert_arg) - err |= cfc_check_trigger_arg_min( - &cmd->convert_arg, 10000); - } else { + if (cmd->scan_begin_src == TRIG_TIMER) { + if (cmd->convert_arg) err |= cfc_check_trigger_arg_min(&cmd->convert_arg, - 10000); - } + 10000); + } else { + err |= cfc_check_trigger_arg_min(&cmd->convert_arg, 10000); } err |= cfc_check_trigger_arg_min(&cmd->chanlist_len, 1); @@ -789,15 +786,10 @@ static int apci3120_ai_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ - if (cmd->convert_src == TRIG_TIMER) { - - if (cmd->scan_begin_src == TRIG_TIMER && - cmd->scan_begin_arg < - cmd->convert_arg * cmd->scan_end_arg) { - cmd->scan_begin_arg = - cmd->convert_arg * cmd->scan_end_arg; - err++; - } + if (cmd->scan_begin_src == TRIG_TIMER && + cmd->scan_begin_arg < cmd->convert_arg * cmd->scan_end_arg) { + cmd->scan_begin_arg = cmd->convert_arg * cmd->scan_end_arg; + err |= -EINVAL; } if (err) @@ -1344,23 +1336,10 @@ static int apci3120_ai_cmd(struct comedi_device *dev, else devpriv->b_ExttrigEnable = APCI3120_DISABLE; - if (cmd->scan_begin_src == TRIG_FOLLOW) { - /* mode 1 or 3 */ - if (cmd->convert_src == TRIG_TIMER) { - /* mode 1 */ - - /* return this_board->ai_cmd(1,dev,s); */ - return apci3120_cyclic_ai(1, dev, s); - } - - } - if ((cmd->scan_begin_src == TRIG_TIMER) - && (cmd->convert_src == TRIG_TIMER)) { - /* mode 2 */ - /* return this_board->ai_cmd(2,dev,s); */ + if (cmd->scan_begin_src == TRIG_FOLLOW) + return apci3120_cyclic_ai(1, dev, s); + else /* TRIG_TIMER */ return apci3120_cyclic_ai(2, dev, s); - } - return -1; } /* -- cgit v1.2.3 From 204563198e729cb9c12131a77a1bfdeaacd2a497 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:49 -0700 Subject: staging: comedi: hwdrv_apci3120: fix 'b_AiCyclicAcquisition' usage This private data member is set when an analog input async command is started by apci3120_cyclic_ai() and cleared when the command finishes or is canceled. Rename the CamelCase member to 'ai_running' and convert it to a bit-field flag. Remove the unnecessary clearing of the flag before or after calling apci3120_cancel(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/addi-data/addi_common.h | 2 +- .../comedi/drivers/addi-data/hwdrv_apci3120.c | 25 +++++----------------- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.h b/drivers/staging/comedi/drivers/addi-data/addi_common.h index c55c5dae688e..5c6a11c35ded 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.h +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.h @@ -137,7 +137,7 @@ struct addi_private { unsigned short us_OutputRegister; /* Contain data written at iobase + 0 */ unsigned char b_Timer2Mode; /* Specify the timer 2 mode */ unsigned char b_Timer2Interrupt; /* Timer2 interrupt enable or disable */ - unsigned char b_AiCyclicAcquisition; /* indicate cyclic acquisition */ + unsigned int ai_running:1; unsigned char b_InterruptMode; /* eoc eos or dma */ unsigned char b_EocEosInterrupt; /* Enable disable eoc eos interrupt */ unsigned int ui_EocEosConversionTime; diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 7bc6b8ff8157..8874b2ca4cd9 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -609,7 +609,7 @@ static int apci3120_reset(struct comedi_device *dev) unsigned int i; unsigned short us_TmpValue; - devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE; + devpriv->ai_running = 0; devpriv->b_EocEosInterrupt = APCI3120_DISABLE; devpriv->b_InterruptMode = APCI3120_EOC_MODE; devpriv->ui_EocEosConversionTime = 0; /* set eoc eos conv time to 0 */ @@ -722,7 +722,7 @@ static int apci3120_cancel(struct comedi_device *dev, s->async->cur_chan = 0; devpriv->ui_DmaActualBuffer = 0; - devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE; + devpriv->ai_running = 0; devpriv->b_InterruptMode = APCI3120_EOC_MODE; devpriv->b_EocEosInterrupt = APCI3120_DISABLE; apci3120_reset(dev); @@ -817,10 +817,6 @@ static int apci3120_cyclic_ai(int mode, 0, ui_TimerValue0, ui_ConvertTiming; unsigned short us_TmpValue; - /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */ - /* devpriv->b_AiCyclicAcquisition=APCI3120_ENABLE; */ - /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ - /*******************/ /* Resets the FIFO */ /*******************/ @@ -830,12 +826,7 @@ static int apci3120_cyclic_ai(int mode, /* inw(dev->iobase+APCI3120_RD_STATUS); */ /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ - /***************************/ - /* Acquisition initialized */ - /***************************/ - /* BEGIN JK 07.05.04: Comparison between WIN32 and Linux driver */ - devpriv->b_AiCyclicAcquisition = APCI3120_ENABLE; - /* END JK 07.05.04: Comparison between WIN32 and Linux driver */ + devpriv->ai_running = 1; /* clear software registers */ devpriv->b_TimerSelectMode = 0; @@ -1388,8 +1379,6 @@ static void apci3120_interrupt_dma(int irq, void *d) if (samplesinbuf & 1) { comedi_error(dev, "Odd count of bytes in DMA ring!"); apci3120_cancel(dev, s); - devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE; - return; } samplesinbuf = samplesinbuf >> 1; /* number of received samples */ @@ -1459,7 +1448,6 @@ static void apci3120_interrupt_dma(int irq, void *d) if (devpriv->ui_AiActualScan >= cmd->stop_arg) { /* all data sampled */ apci3120_cancel(dev, s); - devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE; s->async->events |= COMEDI_CB_EOA; comedi_event(dev, s); return; @@ -1609,7 +1597,7 @@ static void apci3120_interrupt(int irq, void *d) if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) { /* enable this in without DMA ??? */ - if (devpriv->b_AiCyclicAcquisition == APCI3120_ENABLE) { + if (devpriv->ai_running) { ui_Check = 0; apci3120_interrupt_handle_eos(dev); devpriv->ui_AiActualScan++; @@ -1651,8 +1639,6 @@ static void apci3120_interrupt(int irq, void *d) switch (devpriv->b_Timer2Mode) { case APCI3120_COUNTER: - - devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE; devpriv->b_ModeSelectRegister = devpriv-> b_ModeSelectRegister & APCI3120_DISABLE_EOS_INT; @@ -1668,7 +1654,6 @@ static void apci3120_interrupt(int irq, void *d) /* stop timer 0 and timer 1 */ apci3120_cancel(dev, s); - devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE; /* UPDATE-0.7.57->0.7.68comedi_done(dev,s); */ s->async->events |= COMEDI_CB_EOA; @@ -1707,7 +1692,7 @@ static void apci3120_interrupt(int irq, void *d) } if ((int_daq & 0x4) && (devpriv->b_InterruptMode == APCI3120_DMA_MODE)) { - if (devpriv->b_AiCyclicAcquisition == APCI3120_ENABLE) { + if (devpriv->ai_running) { /****************************/ /* Clear Timer Write TC int */ -- cgit v1.2.3 From 241f1c96441f7539459f159a099115a6d21e9f3e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:50 -0700 Subject: staging: comedi: hwdrv_apci3120: remove clearing of 'b_OutputMemoryStatus' This private data member is not used by this driver. Remove the unnecessary clearing of it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 8874b2ca4cd9..e3aa89780c2c 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -613,7 +613,6 @@ static int apci3120_reset(struct comedi_device *dev) devpriv->b_EocEosInterrupt = APCI3120_DISABLE; devpriv->b_InterruptMode = APCI3120_EOC_MODE; devpriv->ui_EocEosConversionTime = 0; /* set eoc eos conv time to 0 */ - devpriv->b_OutputMemoryStatus = 0; /* variables used in timer subdevice */ devpriv->b_Timer2Mode = 0; -- cgit v1.2.3 From d7c0dcb65abda2842a1bff678a5297ed68431421 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:51 -0700 Subject: staging: comedi: pcl711: fix 8254 timer programming As pointed out by Ian Abbott, the i8254_load() function does not use the I8254_MODE* values to specify the "mode". Refactor the 8254 timer programming to use the i8254_set_mode() and i8254_write() helpers instead of i8254_load(). This allows us to use the I8254_MODE* defines to clarify the code. For aesthetics, factor the timer programming out as a separate function. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl711.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c index 7c03a5d17b1b..2da6fec6ab4c 100644 --- a/drivers/staging/comedi/drivers/pcl711.c +++ b/drivers/staging/comedi/drivers/pcl711.c @@ -360,6 +360,18 @@ static int pcl711_ai_cmdtest(struct comedi_device *dev, return 0; } +static void pcl711_ai_load_counters(struct comedi_device *dev) +{ + struct pcl711_private *devpriv = dev->private; + unsigned long timer_base = dev->iobase + PCL711_TIMER_BASE; + + i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY); + i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY); + + i8254_write(timer_base, 0, 1, devpriv->divisor1); + i8254_write(timer_base, 0, 2, devpriv->divisor2); +} + static int pcl711_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct pcl711_private *devpriv = dev->private; @@ -378,13 +390,8 @@ static int pcl711_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) } if (cmd->scan_begin_src == TRIG_TIMER) { - i8254_load(dev->iobase + PCL711_TIMER_BASE, 0, - 1, devpriv->divisor1, I8254_MODE2 | I8254_BINARY); - i8254_load(dev->iobase + PCL711_TIMER_BASE, 0, - 2, devpriv->divisor2, I8254_MODE2 | I8254_BINARY); - + pcl711_ai_load_counters(dev); outb(PCL711_INT_STAT_CLR, dev->iobase + PCL711_INT_STAT_REG); - pcl711_ai_set_mode(dev, PCL711_MODE_PACER_IRQ); } else { pcl711_ai_set_mode(dev, PCL711_MODE_EXT_IRQ); -- cgit v1.2.3 From 4f161fc756a086f56b200a5a9e7ef60c28265a4c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:52 -0700 Subject: staging: comedi: ni_at_ao: fix 8254 timer programming As pointed out by Ian Abbott, the i8254_load() function does not use the I8254_MODE* values to specify the "mode". Refactor the 8254 timer programming to use the i8254_set_mode() and i8254_write() helpers instead of i8254_load(). This allows us to use the I8254_MODE* defines to clarify the code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_at_ao.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_at_ao.c b/drivers/staging/comedi/drivers/ni_at_ao.c index 10e3e9475ee2..c93b47bcca51 100644 --- a/drivers/staging/comedi/drivers/ni_at_ao.c +++ b/drivers/staging/comedi/drivers/ni_at_ao.c @@ -310,6 +310,7 @@ static int atao_calib_insn_read(struct comedi_device *dev, static void atao_reset(struct comedi_device *dev) { struct atao_private *devpriv = dev->private; + unsigned long timer_base = dev->iobase + ATAO_82C53_BASE; /* This is the reset sequence described in the manual */ @@ -317,10 +318,9 @@ static void atao_reset(struct comedi_device *dev) outw(devpriv->cfg1, dev->iobase + ATAO_CFG1_REG); /* Put outputs of counter 1 and counter 2 in a high state */ - i8254_load(dev->iobase + ATAO_82C53_BASE, 0, - 0, 0x0003, I8254_MODE4 | I8254_BINARY); - i8254_set_mode(dev->iobase + ATAO_82C53_BASE, 0, - 1, I8254_MODE4 | I8254_BINARY); + i8254_set_mode(timer_base, 0, 0, I8254_MODE4 | I8254_BINARY); + i8254_set_mode(timer_base, 0, 1, I8254_MODE4 | I8254_BINARY); + i8254_write(timer_base, 0, 0, 0x0003); outw(ATAO_CFG2_CALLD_NOP, dev->iobase + ATAO_CFG2_REG); -- cgit v1.2.3 From e72f7ad46e73b5cd372cdf6834d0dd0e0000d7ad Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:53 -0700 Subject: staging: comedi: me4000: fix 8254 timer programming As pointed out by Ian Abbott, the i8254_load() function does not use the I8254_MODE* values to specify the "mode". Refactor the 8254 timer programming to use the i8254_set_mode() and i8254_write() helpers instead of i8254_load(). This allows us to use the I8254_MODE* defines to clarify the code. Also, use the CR_CHAN() macro to make sure the only the channel is used in the insh->chanspec to specify the counter number. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/me4000.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c index 5fc4850afb74..a08bc6ffad30 100644 --- a/drivers/staging/comedi/drivers/me4000.c +++ b/drivers/staging/comedi/drivers/me4000.c @@ -1352,6 +1352,7 @@ static int me4000_cnt_insn_config(struct comedi_device *dev, unsigned int *data) { struct me4000_info *info = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); int err; switch (data[0]) { @@ -1359,16 +1360,17 @@ static int me4000_cnt_insn_config(struct comedi_device *dev, if (insn->n != 1) return -EINVAL; - err = i8254_load(info->timer_regbase, 0, insn->chanspec, 0, - I8254_MODE0 | I8254_BINARY); + err = i8254_set_mode(info->timer_regbase, 0, chan, + I8254_MODE0 | I8254_BINARY); if (err) return err; + i8254_write(info->timer_regbase, 0, chan, 0); break; case GPCT_SET_OPERATION: if (insn->n != 2) return -EINVAL; - err = i8254_set_mode(info->timer_regbase, 0, insn->chanspec, + err = i8254_set_mode(info->timer_regbase, 0, chan, (data[1] << 1) | I8254_BINARY); if (err) return err; -- cgit v1.2.3 From 90c32ce300fb79f45d55803bc021c4e49ed9b85f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:54 -0700 Subject: staging: comedi: amplc_pci244: clarify 8254 timer programming Refactor the 8254 timer programming to use the i8254_set_mode() and i8254_write() helpers instead of i8254_load(). This allows us to use the I8254_MODE* defines to clarify the code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci224.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index 3002156e7e79..c2b352c3c6a6 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -868,6 +868,7 @@ static void pci224_ao_start_pacer(struct comedi_device *dev, struct comedi_subdevice *s) { struct pci224_private *devpriv = dev->private; + unsigned long timer_base = devpriv->iobase1 + PCI224_Z2_CT0; /* * The output of timer Z2-0 will be used as the scan trigger @@ -881,13 +882,13 @@ static void pci224_ao_start_pacer(struct comedi_device *dev, /* Z2-2 needs 10 MHz clock. */ outb(CLK_CONFIG(2, CLK_10MHZ), devpriv->iobase1 + PCI224_ZCLK_SCE); /* Load Z2-2 mode (2) and counter (div1). */ - i8254_load(devpriv->iobase1 + PCI224_Z2_CT0, 0, - 2, devpriv->cached_div1, 2); + i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY); + i8254_write(timer_base, 0, 2, devpriv->cached_div1); /* Z2-0 is clocked from Z2-2's output. */ outb(CLK_CONFIG(0, CLK_OUTNM1), devpriv->iobase1 + PCI224_ZCLK_SCE); /* Load Z2-0 mode (2) and counter (div2). */ - i8254_load(devpriv->iobase1 + PCI224_Z2_CT0, 0, - 0, devpriv->cached_div2, 2); + i8254_set_mode(timer_base, 0, 0, I8254_MODE2 | I8254_BINARY); + i8254_write(timer_base, 0, 0, devpriv->cached_div2); } static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) -- cgit v1.2.3 From 52c9e62cf3247cb0599197e7a27356e6a2513a80 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:55 -0700 Subject: staging: comedi: das800: clarify 8254 timer programming Refactor the 8254 timer programming to use the i8254_set_mode() and i8254_write() helpers instead of i8254_load(). This allows us to use the I8254_MODE* defines to clarify the code. The das800_set_frequency() function will not fail. For aesthetics change the return to a void and remove the error handling. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das800.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c index e2dc43dbdc5e..615ae3f1c6cc 100644 --- a/drivers/staging/comedi/drivers/das800.c +++ b/drivers/staging/comedi/drivers/das800.c @@ -275,19 +275,15 @@ static void das800_disable(struct comedi_device *dev) spin_unlock_irqrestore(&dev->spinlock, irq_flags); } -static int das800_set_frequency(struct comedi_device *dev) +static void das800_set_frequency(struct comedi_device *dev) { struct das800_private *devpriv = dev->private; - int err = 0; - - if (i8254_load(dev->iobase + DAS800_8254, 0, 1, devpriv->divisor1, 2)) - err++; - if (i8254_load(dev->iobase + DAS800_8254, 0, 2, devpriv->divisor2, 2)) - err++; - if (err) - return -1; + unsigned long timer_base = dev->iobase + DAS800_8254; - return 0; + i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY); + i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY); + i8254_write(timer_base, 0, 1, devpriv->divisor1); + i8254_write(timer_base, 0, 2, devpriv->divisor2); } static int das800_cancel(struct comedi_device *dev, struct comedi_subdevice *s) @@ -448,10 +444,7 @@ static int das800_ai_do_cmd(struct comedi_device *dev, if (async->cmd.convert_src == TRIG_TIMER) { conv_bits |= CASC | ITE; /* set conversion frequency */ - if (das800_set_frequency(dev) < 0) { - comedi_error(dev, "Error setting up counters"); - return -1; - } + das800_set_frequency(dev); } spin_lock_irqsave(&dev->spinlock, irq_flags); -- cgit v1.2.3 From e74e98993da8dff62190c937d4371eda962e64b9 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:56 -0700 Subject: staging: comedi: ni_labpc: fix 8254 timer programming As pointed out by Ian Abbott, the i8254_load() function does not use the I8254_MODE* values to specify the "mode". The labpc_counter_load() function in this driver is passed an I8254_MODE* value so we need to use the i8254_set_mode() and i8254_write() helpers instead of i8254_load() to program the timers. The calls to labpc_counter_load() will not fail so change the return to void and remove all the unnecessary error handling. Similarly, change the return type of labpc_counter_set_mode() to void and remove the unnecessary error handling. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc.c | 92 +++++++++++++------------------ 1 file changed, 39 insertions(+), 53 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index fc9d31420956..c6e914dc70cf 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -171,32 +171,39 @@ static const struct labpc_boardinfo labpc_boards[] = { }; #endif -static int labpc_counter_load(struct comedi_device *dev, - unsigned long base_address, - unsigned int counter_number, - unsigned int count, unsigned int mode) +static void labpc_counter_load(struct comedi_device *dev, + unsigned long base_address, + unsigned int counter_number, + unsigned int count, + unsigned int mode) { const struct labpc_boardinfo *board = comedi_board(dev); - if (board->has_mmio) - return i8254_mm_load((void __iomem *)base_address, 0, - counter_number, count, mode); - else - return i8254_load(base_address, 0, counter_number, count, mode); + if (board->has_mmio) { + void __iomem *mmio_base = (void __iomem *)base_address; + + i8254_mm_set_mode(mmio_base, 0, counter_number, mode); + i8254_mm_write(mmio_base, 0, counter_number, count); + } else { + i8254_set_mode(base_address, 0, counter_number, mode); + i8254_write(base_address, 0, counter_number, count); + } } -static int labpc_counter_set_mode(struct comedi_device *dev, - unsigned long base_address, - unsigned int counter_number, - unsigned int mode) +static void labpc_counter_set_mode(struct comedi_device *dev, + unsigned long base_address, + unsigned int counter_number, + unsigned int mode) { const struct labpc_boardinfo *board = comedi_board(dev); - if (board->has_mmio) - return i8254_mm_set_mode((void __iomem *)base_address, 0, - counter_number, mode); - else - return i8254_set_mode(base_address, 0, counter_number, mode); + if (board->has_mmio) { + void __iomem *mmio_base = (void __iomem *)base_address; + + i8254_mm_set_mode(mmio_base, 0, counter_number, mode); + } else { + i8254_set_mode(base_address, 0, counter_number, mode); + } } static int labpc_cancel(struct comedi_device *dev, struct comedi_subdevice *s) @@ -349,10 +356,8 @@ static int labpc_ai_insn_read(struct comedi_device *dev, devpriv->write_byte(devpriv->cmd4, dev->iobase + CMD4_REG); /* initialize pacer counter to prevent any problems */ - ret = labpc_counter_set_mode(dev, dev->iobase + COUNTER_A_BASE_REG, - 0, I8254_MODE2); - if (ret) - return ret; + labpc_counter_set_mode(dev, dev->iobase + COUNTER_A_BASE_REG, + 0, I8254_MODE2); labpc_clear_adc_fifo(dev); @@ -730,7 +735,6 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) unsigned int aref = CR_AREF(chanspec); enum transfer_type xfer; unsigned long flags; - int ret; /* make sure board is disabled before setting up acquisition */ labpc_cancel(dev, s); @@ -745,17 +749,12 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) * load counter a1 with count of 3 * (pc+ manual says this is minimum allowed) using mode 0 */ - ret = labpc_counter_load(dev, dev->iobase + COUNTER_A_BASE_REG, - 1, 3, I8254_MODE0); + labpc_counter_load(dev, dev->iobase + COUNTER_A_BASE_REG, + 1, 3, I8254_MODE0); } else { /* just put counter a1 in mode 0 to set its output low */ - ret = labpc_counter_set_mode(dev, - dev->iobase + COUNTER_A_BASE_REG, - 1, I8254_MODE0); - } - if (ret) { - comedi_error(dev, "error loading counter a1"); - return ret; + labpc_counter_set_mode(dev, dev->iobase + COUNTER_A_BASE_REG, + 1, I8254_MODE0); } /* figure out what method we will use to transfer data */ @@ -800,38 +799,25 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) /* set up pacing */ labpc_adc_timing(dev, cmd, mode); /* load counter b0 in mode 3 */ - ret = labpc_counter_load(dev, dev->iobase + COUNTER_B_BASE_REG, - 0, devpriv->divisor_b0, I8254_MODE3); - if (ret < 0) { - comedi_error(dev, "error loading counter b0"); - return -1; - } + labpc_counter_load(dev, dev->iobase + COUNTER_B_BASE_REG, + 0, devpriv->divisor_b0, I8254_MODE3); } /* set up conversion pacing */ if (labpc_ai_convert_period(cmd, mode)) { /* load counter a0 in mode 2 */ - ret = labpc_counter_load(dev, dev->iobase + COUNTER_A_BASE_REG, - 0, devpriv->divisor_a0, I8254_MODE2); + labpc_counter_load(dev, dev->iobase + COUNTER_A_BASE_REG, + 0, devpriv->divisor_a0, I8254_MODE2); } else { /* initialize pacer counter to prevent any problems */ - ret = labpc_counter_set_mode(dev, - dev->iobase + COUNTER_A_BASE_REG, - 0, I8254_MODE2); - } - if (ret) { - comedi_error(dev, "error loading counter a0"); - return ret; + labpc_counter_set_mode(dev, dev->iobase + COUNTER_A_BASE_REG, + 0, I8254_MODE2); } /* set up scan pacing */ if (labpc_ai_scan_period(cmd, mode)) { /* load counter b1 in mode 2 */ - ret = labpc_counter_load(dev, dev->iobase + COUNTER_B_BASE_REG, - 1, devpriv->divisor_b1, I8254_MODE2); - if (ret < 0) { - comedi_error(dev, "error loading counter b1"); - return -1; - } + labpc_counter_load(dev, dev->iobase + COUNTER_B_BASE_REG, + 1, devpriv->divisor_b1, I8254_MODE2); } labpc_clear_adc_fifo(dev); -- cgit v1.2.3 From 22e09dff089fe93d6e3ef7cc0fb8f645a87153c6 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:57 -0700 Subject: staging: comedi: ni_at_a2150: clarify 8254 timer programming Refactor the 8254 timer programming to use the i8254_set_mode() and i8254_write() helpers instead of i8254_load(). This allows us to use the I8254_MODE* defines to clarify the code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_at_a2150.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/staging/comedi/drivers/ni_at_a2150.c index fefd97e2344d..f8d6bfce17e6 100644 --- a/drivers/staging/comedi/drivers/ni_at_a2150.c +++ b/drivers/staging/comedi/drivers/ni_at_a2150.c @@ -403,6 +403,7 @@ static int a2150_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) struct a2150_private *devpriv = dev->private; struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; + unsigned long timer_base = dev->iobase + I8253_BASE_REG; unsigned long lock_flags; unsigned int old_config_bits = devpriv->config_bits; unsigned int trigger_bits; @@ -470,7 +471,8 @@ static int a2150_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) outw(devpriv->irq_dma_bits, dev->iobase + IRQ_DMA_CNTRL_REG); /* may need to wait 72 sampling periods if timing was changed */ - i8254_load(dev->iobase + I8253_BASE_REG, 0, 2, 72, 0); + i8254_set_mode(timer_base, 0, 2, I8254_MODE0 | I8254_BINARY); + i8254_write(timer_base, 0, 2, 72); /* setup start triggering */ trigger_bits = 0; -- cgit v1.2.3 From bef74ba884be09144f13b7132c060c2e5b0ec415 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:58 -0700 Subject: staging: comedi: das16m1: clarify 8254 timer programming Refactor the 8254 timer programming to use the i8254_set_mode() and i8254_write() helpers instead of i8254_load(). This allows us to use the I8254_MODE* defines to clarify the code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index 4fe30cc254e3..c97444991d89 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -272,6 +272,7 @@ static int das16m1_cmd_exec(struct comedi_device *dev, struct das16m1_private_struct *devpriv = dev->private; struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; + unsigned long timer_base = dev->iobase + DAS16M1_8254_FIRST; unsigned int byte, i; /* disable interrupts and internal pacer */ @@ -283,11 +284,11 @@ static int das16m1_cmd_exec(struct comedi_device *dev, /* Initialize lower half of hardware counter, used to determine how * many samples are in fifo. Value doesn't actually load into counter * until counter's next clock (the next a/d conversion) */ - i8254_load(dev->iobase + DAS16M1_8254_FIRST, 0, 1, 0, 2); + i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY); + i8254_write(timer_base, 0, 1, 0); /* remember current reading of counter so we know when counter has * actually been loaded */ - devpriv->initial_hw_count = - i8254_read(dev->iobase + DAS16M1_8254_FIRST, 0, 1); + devpriv->initial_hw_count = i8254_read(timer_base, 0, 1); /* setup channel/gain queue */ for (i = 0; i < cmd->chanlist_len; i++) { outb(i, dev->iobase + DAS16M1_QUEUE_ADDR); -- cgit v1.2.3 From 8383b8c4a9b81ad5fa446a9b4c9bd5ac4b382c2a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Apr 2014 12:59:59 -0700 Subject: staging: comedi: das16: clarify 8254 timer programming Refactor the 8254 timer programming to use the i8254_set_mode() and i8254_write() helpers instead of i8254_load(). This allows us to use the I8254_MODE* defines to clarify the code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index eb774c3ef17f..a18c6b696ecf 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -740,9 +740,10 @@ static unsigned int das16_set_pacer(struct comedi_device *dev, unsigned int ns, &devpriv->divisor1, &devpriv->divisor2, &ns, rounding_flags); - /* Write the values of ctr1 and ctr2 into counters 1 and 2 */ - i8254_load(timer_base, 0, 1, devpriv->divisor1, 2); - i8254_load(timer_base, 0, 2, devpriv->divisor2, 2); + i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY); + i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY); + i8254_write(timer_base, 0, 1, devpriv->divisor1); + i8254_write(timer_base, 0, 2, devpriv->divisor2); return ns; } -- cgit v1.2.3 From a1f6c2afed3f4c96194f131373b1e914b285c76b Mon Sep 17 00:00:00 2001 From: Luca Ellero Date: Wed, 30 Apr 2014 11:22:07 +0200 Subject: staging: comedi: fix checkpatch warnings Signed-off-by: Luca Ellero Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/8255.h | 4 ++-- drivers/staging/comedi/drivers/addi_apci_3xxx.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/8255.h b/drivers/staging/comedi/drivers/8255.h index 4f16ea78f86a..795d232a6c02 100644 --- a/drivers/staging/comedi/drivers/8255.h +++ b/drivers/staging/comedi/drivers/8255.h @@ -22,10 +22,10 @@ #include "../comedidev.h" int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s, - int (*io) (int, int, int, unsigned long), + int (*io)(int, int, int, unsigned long), unsigned long iobase); int subdev_8255_init_irq(struct comedi_device *dev, struct comedi_subdevice *s, - int (*io) (int, int, int, unsigned long), + int (*io)(int, int, int, unsigned long), unsigned long iobase); void subdev_8255_interrupt(struct comedi_device *dev, struct comedi_subdevice *s); diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c index 64c37b65ba27..f290be818845 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c +++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c @@ -699,7 +699,8 @@ static int apci3xxx_dio_insn_config(struct comedi_device *dev, if (chan < 16) return -EINVAL; else - /* changing any channel in port 2 changes the entire port */ + /* changing any channel in port 2 */ + /* changes the entire port */ mask = 0xff0000; } -- cgit v1.2.3 From 7d52477ef5e66a43fe54e5737179e4e670db260d Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 1 May 2014 17:38:23 +0100 Subject: staging: comedi: drivers: correct mode check for i8254_set_mode() The upper bound check on the `mode` parameter of `i8254_set_mode()` and `i8254_mm_set_mode()` is incorrect. The `mode` parameter value consists of a mode number in the range 0 to 5 in bits 3..1 {represented by the constants `I8254_MODE0` (0 << 1) through to `I8254_MODE5` (2 << 1)} ORed with a BCD/binary flag in bit 0 {represented by the constants `I8254_BINARY` (0) and `I8254_BCD` (1)}. The maximum allowed value ought to be `I8254_MODE5 | I8254_BCD` ((5 << 1) | 1), but is currently `I8254_MODE5 | I8254_BINARY` ((5 << 1) | 0). Fix it. None of the comedi drivers use `I8254_BCD` but some of the low-level drivers allow user-space to configure the counter mode, so all legal values ought to be allowed. However, it's pretty unlikely anyone would want to set the counters to count in BCD (binary coded decimal) so the bug is not that significant. Reported-by: Hartley Sweeten Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/8253.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/8253.h b/drivers/staging/comedi/drivers/8253.h index fb2c9d905723..5829b46b757b 100644 --- a/drivers/staging/comedi/drivers/8253.h +++ b/drivers/staging/comedi/drivers/8253.h @@ -291,7 +291,7 @@ static inline int i8254_set_mode(unsigned long base_address, if (counter_number > 2) return -1; - if (mode > (I8254_MODE5 | I8254_BINARY)) + if (mode > (I8254_MODE5 | I8254_BCD)) return -1; byte = counter_number << 6; @@ -311,7 +311,7 @@ static inline int i8254_mm_set_mode(void __iomem *base_address, if (counter_number > 2) return -1; - if (mode > (I8254_MODE5 | I8254_BINARY)) + if (mode > (I8254_MODE5 | I8254_BCD)) return -1; byte = counter_number << 6; -- cgit v1.2.3 From 6e2954e801d7d93fe6f54eff988ddf25836fee0a Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 1 May 2014 17:38:24 +0100 Subject: staging: comedi: amplc_dio200_common: correct bound on counter mode For the mode configured by the `INSN_CONFIG_SET_COUNTER_MODE` comedi instruction for the counter subdevice channels supported by this module, the upper bound should be `I8254_MODE5 | I8254_BCD` ((5 << 1) | 1) rather than `I8254_MODE5 | I8254_BINARY` ((5 << 1) | 0). Fix it. Reported-by: Hartley Sweeten Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_dio200_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index 4ac320884ac6..ee18537b5a92 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -820,7 +820,7 @@ dio200_subdev_8254_config(struct comedi_device *dev, struct comedi_subdevice *s, spin_lock_irqsave(&subpriv->spinlock, flags); switch (data[0]) { case INSN_CONFIG_SET_COUNTER_MODE: - if (data[1] > (I8254_MODE5 | I8254_BINARY)) + if (data[1] > (I8254_MODE5 | I8254_BCD)) ret = -EINVAL; else dio200_subdev_8254_set_mode(dev, s, chan, data[1]); -- cgit v1.2.3 From 0ce016d0986ae618e0686489ad7b858fa13b885d Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 2 May 2014 13:50:13 +0100 Subject: staging: comedi: remove redundant pointer dereference in comedi_poll() `s->async->subdevice` in `comedi_poll()` points to the same `struct comedi_subdevice` as `s`, so the double pointer reference is redundant. Just use `s`. (`s->async->subdevice` is initialized by `__comedi_device_postconfig_async()` in "drivers/staging/comedi/drivers.c" and doesn't change.) Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index b24bf9bcbe2d..ecd27a6fc7f9 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -2035,7 +2035,7 @@ static unsigned int comedi_poll(struct file *file, poll_table *wait) s = comedi_write_subdevice(dev, minor); if (s && s->async) { - unsigned int bps = bytes_per_sample(s->async->subdevice); + unsigned int bps = bytes_per_sample(s); poll_wait(file, &s->async->wait_head, wait); comedi_buf_write_alloc(s->async, s->async->prealloc_bufsz); -- cgit v1.2.3 From 482f0a21904583923d5c37f84586839c026a734b Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 2 May 2014 13:50:14 +0100 Subject: staging: comedi: remove async parameter from resize_async_buffer() The `struct comedi_async *async` parameter of `resize_async_buffer()` is redundant as its value can be easily derived from the `struct comedi_subdevice *s` parameter as `s->async`. Remove the parameter. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index ecd27a6fc7f9..0affd1f96660 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -238,9 +238,9 @@ comedi_write_subdevice(const struct comedi_device *dev, unsigned int minor) } static int resize_async_buffer(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_async *async, unsigned new_size) + struct comedi_subdevice *s, unsigned new_size) { + struct comedi_async *async = s->async; int retval; if (new_size > async->max_bufsize) @@ -380,7 +380,7 @@ static ssize_t read_buffer_kb_store(struct device *csdev, mutex_lock(&dev->mutex); s = comedi_read_subdevice(dev, minor); if (s && (s->subdev_flags & SDF_CMD_READ) && s->async) - err = resize_async_buffer(dev, s, s->async, size); + err = resize_async_buffer(dev, s, size); else err = -EINVAL; mutex_unlock(&dev->mutex); @@ -493,7 +493,7 @@ static ssize_t write_buffer_kb_store(struct device *csdev, mutex_lock(&dev->mutex); s = comedi_write_subdevice(dev, minor); if (s && (s->subdev_flags & SDF_CMD_WRITE) && s->async) - err = resize_async_buffer(dev, s, s->async, size); + err = resize_async_buffer(dev, s, size); else err = -EINVAL; mutex_unlock(&dev->mutex); @@ -741,7 +741,7 @@ static int do_bufconfig_ioctl(struct comedi_device *dev, } if (bc.size) { - retval = resize_async_buffer(dev, s, async, bc.size); + retval = resize_async_buffer(dev, s, bc.size); if (retval < 0) return retval; } -- cgit v1.2.3 From c46e961e5ad19d5595dfe07d77c26eced8093ec9 Mon Sep 17 00:00:00 2001 From: Thomas Vegas Date: Tue, 1 Apr 2014 18:27:34 +0200 Subject: staging: serqt_usb2: Remove useless variable Use a more common kernel coding style. Signed-off-by: Thomas Vegas Signed-off-by: Greg Kroah-Hartman --- drivers/staging/serqt_usb2/serqt_usb2.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/serqt_usb2/serqt_usb2.c b/drivers/staging/serqt_usb2/serqt_usb2.c index 0267dd8b84b7..90cf2bd6728c 100644 --- a/drivers/staging/serqt_usb2/serqt_usb2.c +++ b/drivers/staging/serqt_usb2/serqt_usb2.c @@ -993,9 +993,7 @@ static void qt_close(struct usb_serial_port *port) struct quatech_port *qt_port; struct quatech_port *port0; struct tty_struct *tty; - int status; unsigned int index; - status = 0; tty = tty_port_tty_get(&port->port); index = port->port_number; @@ -1015,8 +1013,7 @@ static void qt_close(struct usb_serial_port *port) tty_kref_put(tty); /* Close uart channel */ - status = qt_close_channel(serial, index); - if (status < 0) + if (qt_close_channel(serial, index) < 0) dev_dbg(&port->dev, "%s - qt_close_channel failed.\n", __func__); -- cgit v1.2.3 From f5a7856ec94ce0c1aeeac841d3fa05853f5f53fb Mon Sep 17 00:00:00 2001 From: Thomas Vegas Date: Tue, 1 Apr 2014 18:28:33 +0200 Subject: staging: serqt_usb2: Add blank line after declaration Use a more common kernel coding style. Signed-off-by: Thomas Vegas Signed-off-by: Greg Kroah-Hartman --- drivers/staging/serqt_usb2/serqt_usb2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/serqt_usb2/serqt_usb2.c b/drivers/staging/serqt_usb2/serqt_usb2.c index 90cf2bd6728c..f329cb4d6323 100644 --- a/drivers/staging/serqt_usb2/serqt_usb2.c +++ b/drivers/staging/serqt_usb2/serqt_usb2.c @@ -1265,9 +1265,9 @@ static void qt_set_termios(struct tty_struct *tty, if (I_IXOFF(tty) || I_IXON(tty)) { unsigned char stop_char = STOP_CHAR(tty); unsigned char start_char = START_CHAR(tty); - status = - box_set_sw_flow_ctrl(port->serial, index, stop_char, - start_char); + + status = box_set_sw_flow_ctrl(port->serial, index, stop_char, + start_char); if (status < 0) dev_dbg(&port->dev, "box_set_sw_flow_ctrl (enabled) failed\n"); -- cgit v1.2.3 From 5f888cb7b1722412170728df2c9168d47596459c Mon Sep 17 00:00:00 2001 From: Thomas Vegas Date: Tue, 1 Apr 2014 18:29:37 +0200 Subject: staging: serqt_usb2: Clean up initializations of variables Use a more common kernel coding style. Signed-off-by: Thomas Vegas Signed-off-by: Greg Kroah-Hartman --- drivers/staging/serqt_usb2/serqt_usb2.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/staging/serqt_usb2/serqt_usb2.c b/drivers/staging/serqt_usb2/serqt_usb2.c index f329cb4d6323..998c3845421d 100644 --- a/drivers/staging/serqt_usb2/serqt_usb2.c +++ b/drivers/staging/serqt_usb2/serqt_usb2.c @@ -990,16 +990,10 @@ static void qt_block_until_empty(struct tty_struct *tty, static void qt_close(struct usb_serial_port *port) { struct usb_serial *serial = port->serial; - struct quatech_port *qt_port; - struct quatech_port *port0; - struct tty_struct *tty; - unsigned int index; - - tty = tty_port_tty_get(&port->port); - index = port->port_number; - - qt_port = qt_get_port_private(port); - port0 = qt_get_port_private(serial->port[0]); + struct tty_struct *tty = tty_port_tty_get(&port->port); + unsigned int index = port->port_number; + struct quatech_port *qt_port = qt_get_port_private(port); + struct quatech_port *port0 = qt_get_port_private(serial->port[0]); /* shutdown any bulk reads that might be going on */ if (serial->num_bulk_out) -- cgit v1.2.3 From 213351448f9dc5f43f155cb23ab9fafe8a9577ed Mon Sep 17 00:00:00 2001 From: navin patidar Date: Tue, 29 Apr 2014 06:55:12 +0530 Subject: staging: rtl8188eu: Remove debugging messages from usb_dvobj_init() Unnecessary debugging messages are removed from usb_dvobj_init(). Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 34 +++-------------------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index 49a4ce44ada6..8a528299e2fe 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -187,30 +187,13 @@ static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf) if (phost_endp) { pendp_desc = &phost_endp->desc; - DBG_88E("\nusb_endpoint_descriptor(%d):\n", i); - DBG_88E("bLength=%x\n", pendp_desc->bLength); - DBG_88E("bDescriptorType=%x\n", - pendp_desc->bDescriptorType); - DBG_88E("bEndpointAddress=%x\n", - pendp_desc->bEndpointAddress); - DBG_88E("wMaxPacketSize=%d\n", - le16_to_cpu(pendp_desc->wMaxPacketSize)); - DBG_88E("bInterval=%x\n", pendp_desc->bInterval); - if (RT_usb_endpoint_is_bulk_in(pendp_desc)) { - DBG_88E("RT_usb_endpoint_is_bulk_in = %x\n", - RT_usb_endpoint_num(pendp_desc)); pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = RT_usb_endpoint_num(pendp_desc); pdvobjpriv->RtNumInPipes++; } else if (usb_endpoint_is_int(pendp_desc)) { - DBG_88E("usb_endpoint_is_int = %x, Interval = %x\n", - RT_usb_endpoint_num(pendp_desc), - pendp_desc->bInterval); pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = RT_usb_endpoint_num(pendp_desc); pdvobjpriv->RtNumInPipes++; } else if (RT_usb_endpoint_is_bulk_out(pendp_desc)) { - DBG_88E("RT_usb_endpoint_is_bulk_out = %x\n", - RT_usb_endpoint_num(pendp_desc)); pdvobjpriv->RtOutPipe[pdvobjpriv->RtNumOutPipes] = RT_usb_endpoint_num(pendp_desc); pdvobjpriv->RtNumOutPipes++; } @@ -218,25 +201,14 @@ static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf) } } - DBG_88E("nr_endpoint=%d, in_num=%d, out_num=%d\n\n", - pdvobjpriv->nr_endpoint, pdvobjpriv->RtNumInPipes, - pdvobjpriv->RtNumOutPipes); - - if (pusbd->speed == USB_SPEED_HIGH) { + if (pusbd->speed == USB_SPEED_HIGH) pdvobjpriv->ishighspeed = true; - DBG_88E("USB_SPEED_HIGH\n"); - } else { + else pdvobjpriv->ishighspeed = false; - DBG_88E("NON USB_SPEED_HIGH\n"); - } - if (rtw_init_intf_priv(pdvobjpriv) == _FAIL) { - RT_TRACE(_module_os_intfs_c_, _drv_err_, - ("\n Can't INIT rtw_init_intf_priv\n")); + if (rtw_init_intf_priv(pdvobjpriv) == _FAIL) goto free_dvobj; - } - /* 3 misc */ sema_init(&(pdvobjpriv->usb_suspend_sema), 0); rtw_reset_continual_urb_error(pdvobjpriv); -- cgit v1.2.3 From 73fbfbfecbeb7c8642dd96a12ef991881492f051 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Tue, 29 Apr 2014 06:55:13 +0530 Subject: staging: rtl8188eu: Use USB subsystem functions to check endpoint type Use inline functions provided by USB subsystem to check endpoint type, instead of inline functions implemented by driver to do the same. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 57 +++++------------------------ 1 file changed, 10 insertions(+), 47 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index 8a528299e2fe..8ed2ac89f5c5 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -80,46 +80,6 @@ static struct rtw_usb_drv rtl8188e_usb_drv = { static struct rtw_usb_drv *usb_drv = &rtl8188e_usb_drv; -static inline int RT_usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd) -{ - return (epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN; -} - -static inline int RT_usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd) -{ - return (epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT; -} - -static inline int RT_usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd) -{ - return (epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT; -} - -static inline int RT_usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd) -{ - return (epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK; -} - -static inline int RT_usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd) -{ - return RT_usb_endpoint_xfer_bulk(epd) && RT_usb_endpoint_dir_in(epd); -} - -static inline int RT_usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd) -{ - return RT_usb_endpoint_xfer_bulk(epd) && RT_usb_endpoint_dir_out(epd); -} - -static inline int usb_endpoint_is_int(const struct usb_endpoint_descriptor *epd) -{ - return RT_usb_endpoint_xfer_int(epd) && RT_usb_endpoint_dir_in(epd); -} - -static inline int RT_usb_endpoint_num(const struct usb_endpoint_descriptor *epd) -{ - return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; -} - static u8 rtw_init_intf_priv(struct dvobj_priv *dvobj) { u8 rst = _SUCCESS; @@ -183,21 +143,24 @@ static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf) pdvobjpriv->nr_endpoint = piface_desc->bNumEndpoints; for (i = 0; i < pdvobjpriv->nr_endpoint; i++) { + int ep_num; phost_endp = phost_iface->endpoint + i; + if (phost_endp) { pendp_desc = &phost_endp->desc; + ep_num = usb_endpoint_num(pendp_desc); - if (RT_usb_endpoint_is_bulk_in(pendp_desc)) { - pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = RT_usb_endpoint_num(pendp_desc); + if (usb_endpoint_is_bulk_in(pendp_desc)) { + pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = ep_num; pdvobjpriv->RtNumInPipes++; - } else if (usb_endpoint_is_int(pendp_desc)) { - pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = RT_usb_endpoint_num(pendp_desc); + } else if (usb_endpoint_is_int_in(pendp_desc)) { + pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = ep_num; pdvobjpriv->RtNumInPipes++; - } else if (RT_usb_endpoint_is_bulk_out(pendp_desc)) { - pdvobjpriv->RtOutPipe[pdvobjpriv->RtNumOutPipes] = RT_usb_endpoint_num(pendp_desc); + } else if (usb_endpoint_is_bulk_out(pendp_desc)) { + pdvobjpriv->RtOutPipe[pdvobjpriv->RtNumOutPipes] = ep_num; pdvobjpriv->RtNumOutPipes++; } - pdvobjpriv->ep_num[i] = RT_usb_endpoint_num(pendp_desc); + pdvobjpriv->ep_num[i] = ep_num; } } -- cgit v1.2.3 From 7626e3d0d4731ccd3f556533b93c4cd3e8cbf5e6 Mon Sep 17 00:00:00 2001 From: Dominique van den Broeck Date: Sun, 27 Apr 2014 19:11:15 +0200 Subject: staging/rtl8192e: Erroneous return codes (types and values) This function returns a bool, that is supposed to be false when something goes wrong. It's assumed this way by its lone calling function (which is SetRFPowerState8190(), line 1445 of rtl8192e/rtl8192e/r8192E_phy.c) Despite of this, this procedure returns non-null enumerations values or negative codes instead. This patch fixes this. Signed-off-by: Dominique van den Broeck Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index fa087b654ebc..356d5217e9d4 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -3029,7 +3029,7 @@ bool NicIFEnableNIC(struct net_device *dev) RT_TRACE(COMP_ERR, "ERR!!! %s(): Driver is already down!\n", __func__); priv->bdisable_nic = false; - return RT_STATUS_FAILURE; + return false; } RT_TRACE(COMP_PS, "===========>%s()\n", __func__); @@ -3039,7 +3039,7 @@ bool NicIFEnableNIC(struct net_device *dev) RT_TRACE(COMP_ERR, "ERR!!! %s(): initialization is failed!\n", __func__); priv->bdisable_nic = false; - return -1; + return false; } RT_TRACE(COMP_INIT, "start adapter finished\n"); RT_CLEAR_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC); -- cgit v1.2.3 From 2930d0b977e6b9f66e8f090c685a18991944fca6 Mon Sep 17 00:00:00 2001 From: Rui Miguel Silva Date: Mon, 28 Apr 2014 12:12:54 +0100 Subject: staging: rtl8192u: fix checkpatch braces warning fix some code style related to the use of braces in a one statement block Signed-off-by: Rui Miguel Silva Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.c | 6 ++---- drivers/staging/rtl8192u/r8192U_wx.c | 3 +-- drivers/staging/rtl8192u/r819xU_firmware.c | 6 ++---- drivers/staging/rtl8192u/r819xU_phy.c | 3 +-- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index d97ad7b909bc..9fa12e4618b1 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -183,9 +183,8 @@ void dm_CheckRxAggregation(struct net_device *dev) { curTxOkCnt = priv->stats.txbytesunicast - lastTxOkCnt; curRxOkCnt = priv->stats.rxbytesunicast - lastRxOkCnt; - if((curTxOkCnt + curRxOkCnt) < 15000000) { + if ((curTxOkCnt + curRxOkCnt) < 15000000) return; - } if(curTxOkCnt > 4*curRxOkCnt) { if (priv->bCurrentRxAggrEnable) { @@ -1646,9 +1645,8 @@ void dm_restore_dynamic_mechanism_state(struct net_device *dev) write_nic_byte(dev, UFWP, 1); } //Restore TX Power Tracking Index - if(priv->btxpower_trackingInit && priv->btxpower_tracking){ + if (priv->btxpower_trackingInit && priv->btxpower_tracking) dm_txpower_reset_recovery(dev); - } // //Restore BB Initial Gain diff --git a/drivers/staging/rtl8192u/r8192U_wx.c b/drivers/staging/rtl8192u/r8192U_wx.c index c70af014a316..72db77317dec 100644 --- a/drivers/staging/rtl8192u/r8192U_wx.c +++ b/drivers/staging/rtl8192u/r8192U_wx.c @@ -275,9 +275,8 @@ static int rtl8180_wx_get_range(struct net_device *dev, range->num_bitrates = RATE_COUNT; - for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) { + for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) range->bitrate[i] = rtl8180_rates[i]; - } range->min_frag = MIN_FRAG_THRESHOLD; range->max_frag = MAX_FRAG_THRESHOLD; diff --git a/drivers/staging/rtl8192u/r819xU_firmware.c b/drivers/staging/rtl8192u/r819xU_firmware.c index ecfb66538eb3..98a113a6e439 100644 --- a/drivers/staging/rtl8192u/r819xU_firmware.c +++ b/drivers/staging/rtl8192u/r819xU_firmware.c @@ -277,13 +277,11 @@ bool init_firmware(struct net_device *dev) * and Tx descriptor info * */ rt_status = fw_download_code(dev,mapped_file,file_length); - if (rst_opt == OPT_SYSTEM_RESET) { + if (rst_opt == OPT_SYSTEM_RESET) release_firmware(fw_entry); - } - if (rt_status != TRUE) { + if (rt_status != TRUE) goto download_firmware_fail; - } switch (init_step) { case FW_INIT_STEP0_BOOT: diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index b9f35313c7ab..87e07ba49ecd 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -504,9 +504,8 @@ void rtl8192_phy_configmac(struct net_device *dev) pdwArray = rtl819XMACPHY_Array; } for (i = 0; i < dwArrayLen; i = i+3) { - if (pdwArray[i] == 0x318) { + if (pdwArray[i] == 0x318) pdwArray[i+2] = 0x00000800; - } RT_TRACE(COMP_DBG, "Rtl8190MACPHY_Array[0]=%x Rtl8190MACPHY_Array[1]=%x Rtl8190MACPHY_Array[2]=%x\n", -- cgit v1.2.3 From b9fb433072ebeffe9ae30c819f8032e8583d16fe Mon Sep 17 00:00:00 2001 From: Jan Moskyto Matejka Date: Wed, 30 Apr 2014 15:22:17 +0200 Subject: rtl8821ae: fixed defined-not-used warning by cleaning up BT_AUTO_REPORT_ONLY_8192E_2ANT (always set to 0, never used as constant) halbtc8192e2ant_iswifi_status_changed was called only from the unused code Signed-off-by: Jan Moskyto Matejka Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8821ae/btcoexist/halbtc8192e2ant.c | 43 ---------------------- .../staging/rtl8821ae/btcoexist/halbtc8192e2ant.h | 2 - 2 files changed, 45 deletions(-) diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c b/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c index 81706f4087f0..d2381794ecc9 100644 --- a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c +++ b/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.c @@ -503,38 +503,6 @@ static void halbtc8192e2ant_querybt_info(struct btc_coexist *btcoexist) btcoexist->btc_fill_h2c(btcoexist, 0x61, 1, h2c_parameter); } -static bool halbtc8192e2ant_iswifi_status_changed(struct btc_coexist *btcoexist) -{ - static bool pre_wifi_busy; - static bool pre_under_4way, pre_bt_hson; - bool wifi_busy = false, under_4way = false, bt_hson = false; - bool wifi_connected = false; - - btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, - &wifi_connected); - btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); - btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hson); - btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, - &under_4way); - - if (wifi_connected) { - if (wifi_busy != pre_wifi_busy) { - pre_wifi_busy = wifi_busy; - return true; - } - if (under_4way != pre_under_4way) { - pre_under_4way = under_4way; - return true; - } - if (bt_hson != pre_bt_hson) { - pre_bt_hson = bt_hson; - return true; - } - } - - return false; -} - static void halbtc8192e2ant_update_btlink_info(struct btc_coexist *btcoexist) { struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; @@ -3833,9 +3801,6 @@ void ex_halbtc8192e2ant_display_coex_info(struct btc_coexist *btcoexist) "0x774(lp rx[31:16]/tx[15:0])", coex_sta->low_priority_rx, coex_sta->low_priority_tx); CL_PRINTF(cli_buf); -#if (BT_AUTO_REPORT_ONLY_8192E_2ANT == 1) - halbtc8192e2ant_monitor_bt_ctr(btcoexist); -#endif btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_COEX_STATISTICS); } @@ -4011,14 +3976,12 @@ void ex_halbtc8192e2ant_bt_info_notify(struct btc_coexist *btcoexist, * do nothing here. */ } -#if (BT_AUTO_REPORT_ONLY_8192E_2ANT == 0) if ((coex_sta->bt_info_ext & BIT4)) { /* BT auto report already enabled, do nothing */ } else { halbtc8192e2ant_bt_autoreport(btcoexist, FORCE_EXEC, true); } -#endif } /* check BIT2 first ==> check if bt is under inquiry or page scan */ @@ -4148,14 +4111,8 @@ void ex_halbtc8192e2ant_periodical(struct btc_coexist *btcoexist) "************************************************\n"); } -#if (BT_AUTO_REPORT_ONLY_8192E_2ANT == 0) halbtc8192e2ant_querybt_info(btcoexist); halbtc8192e2ant_monitor_bt_ctr(btcoexist); halbtc8192e2ant_monitor_bt_enable_disable(btcoexist); -#else - if (halbtc8192e2ant_iswifi_status_changed(btcoexist) || - coex_dm->auto_tdma_adjust) - halbtc8192e2ant_run_coexist_mechanism(btcoexist); -#endif } diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.h b/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.h index 6d109edb8950..416d3ddaed33 100644 --- a/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.h +++ b/drivers/staging/rtl8821ae/btcoexist/halbtc8192e2ant.h @@ -1,8 +1,6 @@ /***************************************************************** * The following is for 8192E 2Ant BT Co-exist definition *****************************************************************/ -#define BT_AUTO_REPORT_ONLY_8192E_2ANT 0 - #define BT_INFO_8192E_2ANT_B_FTP BIT7 #define BT_INFO_8192E_2ANT_B_A2DP BIT6 #define BT_INFO_8192E_2ANT_B_HID BIT5 -- cgit v1.2.3 From d27ab0b9df6c2961da5d814e5f183318a1489c9c Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sat, 3 May 2014 17:15:18 +0530 Subject: staging: rtl8188eu: Remove function rtw_dequeue_recvbuf() rtw_dequeue_recvbuf() is not being used by driver. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_recv.c | 25 ------------------------- drivers/staging/rtl8188eu/include/rtw_recv.h | 1 - 2 files changed, 26 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index 5c1d2d28eb9d..eac526012d5f 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -313,31 +313,6 @@ int rtw_enqueue_recvbuf(struct recv_buf *precvbuf, struct __queue *queue) return _SUCCESS; } -struct recv_buf *rtw_dequeue_recvbuf (struct __queue *queue) -{ - unsigned long irqL; - struct recv_buf *precvbuf; - struct list_head *plist, *phead; - - spin_lock_irqsave(&queue->lock, irqL); - - if (_rtw_queue_empty(queue)) { - precvbuf = NULL; - } else { - phead = get_list_head(queue); - - plist = phead->next; - - precvbuf = container_of(plist, struct recv_buf, list); - - rtw_list_delete(&precvbuf->list); - } - - spin_unlock_irqrestore(&queue->lock, irqL); - - return precvbuf; -} - static int recvframe_chkmic(struct adapter *adapter, struct recv_frame *precvframe) { diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index bcbce46cec85..7b958606920f 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -304,7 +304,6 @@ void rtw_free_recvframe_queue(struct __queue *pframequeue, u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter); int rtw_enqueue_recvbuf_to_head(struct recv_buf *buf, struct __queue *queue); int rtw_enqueue_recvbuf(struct recv_buf *precvbuf, struct __queue *queue); -struct recv_buf *rtw_dequeue_recvbuf(struct __queue *queue); void rtw_reordering_ctrl_timeout_handler(void *pcontext); -- cgit v1.2.3 From 0521a2a6f9bceca23b38a8cad76ffa0e381600e2 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sat, 3 May 2014 17:15:19 +0530 Subject: staging: rtl8188eu: Remove function rtw_enqueue_recvbuf_to_head() rtw_enqueue_recvbuf_to_head() is not being used by driver. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_recv.c | 12 ------------ drivers/staging/rtl8188eu/include/rtw_recv.h | 1 - 2 files changed, 13 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index eac526012d5f..21aa89d19abd 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -289,18 +289,6 @@ u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter) return cnt; } -int rtw_enqueue_recvbuf_to_head(struct recv_buf *precvbuf, struct __queue *queue) -{ - spin_lock_bh(&queue->lock); - - rtw_list_delete(&precvbuf->list); - rtw_list_insert_head(&precvbuf->list, get_list_head(queue)); - - spin_unlock_bh(&queue->lock); - - return _SUCCESS; -} - int rtw_enqueue_recvbuf(struct recv_buf *precvbuf, struct __queue *queue) { unsigned long irqL; diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index 7b958606920f..21ce405c87e4 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -302,7 +302,6 @@ int rtw_enqueue_recvframe(struct recv_frame *precvframe, struct __queue *queue); void rtw_free_recvframe_queue(struct __queue *pframequeue, struct __queue *pfree_recv_queue); u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter); -int rtw_enqueue_recvbuf_to_head(struct recv_buf *buf, struct __queue *queue); int rtw_enqueue_recvbuf(struct recv_buf *precvbuf, struct __queue *queue); void rtw_reordering_ctrl_timeout_handler(void *pcontext); -- cgit v1.2.3 From 5fe2f910f44a49856245a79b7e4d711d4d9ce670 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sat, 3 May 2014 17:15:20 +0530 Subject: staging: rtl8188eu: Remove function rtw_enqueue_recvbuf() rtw_enqueue_recvbuf() is not being used by driver. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_recv.c | 12 ------------ drivers/staging/rtl8188eu/include/rtw_recv.h | 1 - 2 files changed, 13 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index 21aa89d19abd..da26fa5cb259 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -289,18 +289,6 @@ u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter) return cnt; } -int rtw_enqueue_recvbuf(struct recv_buf *precvbuf, struct __queue *queue) -{ - unsigned long irqL; - spin_lock_irqsave(&queue->lock, irqL); - - rtw_list_delete(&precvbuf->list); - - rtw_list_insert_tail(&precvbuf->list, get_list_head(queue)); - spin_unlock_irqrestore(&queue->lock, irqL); - return _SUCCESS; -} - static int recvframe_chkmic(struct adapter *adapter, struct recv_frame *precvframe) { diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index 21ce405c87e4..677859e33b13 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -302,7 +302,6 @@ int rtw_enqueue_recvframe(struct recv_frame *precvframe, struct __queue *queue); void rtw_free_recvframe_queue(struct __queue *pframequeue, struct __queue *pfree_recv_queue); u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter); -int rtw_enqueue_recvbuf(struct recv_buf *precvbuf, struct __queue *queue); void rtw_reordering_ctrl_timeout_handler(void *pcontext); -- cgit v1.2.3 From 9a4429ea62834d4e5e4e677b11b64a881da99b99 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sat, 3 May 2014 17:15:21 +0530 Subject: staging: rtl8188eu: Remove 'struct list_head list' from struct recv_buf Users of 'struct list_head list' variable e.g. rtw_enqueue_recvbuf(), rtw_enqueue_recvbuf_to_head() and rtw_dequeue_recvbuf() are already removed. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c | 1 - drivers/staging/rtl8188eu/include/rtw_recv.h | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c index b1b1584af1cd..98a79ba45d49 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c @@ -71,7 +71,6 @@ int rtl8188eu_init_recv_priv(struct adapter *padapter) precvbuf = (struct recv_buf *)precvpriv->precv_buf; for (i = 0; i < NR_RECVBUFF; i++) { - _rtw_init_listhead(&precvbuf->list); spin_lock_init(&precvbuf->recvbuf_lock); precvbuf->alloc_sz = MAX_RECVBUF_SZ; res = rtw_os_recvbuf_resource_alloc(padapter, precvbuf); diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index 677859e33b13..103849fdb6f8 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -235,7 +235,6 @@ struct sta_recv_priv { }; struct recv_buf { - struct list_head list; spinlock_t recvbuf_lock; u32 ref_cnt; struct adapter *adapter; -- cgit v1.2.3 From 4337ff2f8fed9230af7acb447f8c1e5a82087d97 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sat, 3 May 2014 17:15:22 +0530 Subject: staging: rtl8188eu: Remove 'spinlock_t recvbuf_lock' from struct recv_buf recvbuf_lock is initialized inside rtl8188eu_init_recv_priv() but never used. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c | 1 - drivers/staging/rtl8188eu/include/rtw_recv.h | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c index 98a79ba45d49..52d83a4afd35 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c @@ -71,7 +71,6 @@ int rtl8188eu_init_recv_priv(struct adapter *padapter) precvbuf = (struct recv_buf *)precvpriv->precv_buf; for (i = 0; i < NR_RECVBUFF; i++) { - spin_lock_init(&precvbuf->recvbuf_lock); precvbuf->alloc_sz = MAX_RECVBUF_SZ; res = rtw_os_recvbuf_resource_alloc(padapter, precvbuf); if (res == _FAIL) diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index 103849fdb6f8..4a19a0657f3a 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -235,7 +235,6 @@ struct sta_recv_priv { }; struct recv_buf { - spinlock_t recvbuf_lock; u32 ref_cnt; struct adapter *adapter; u8 *pbuf; -- cgit v1.2.3 From 498562560a351cd483bc5d6013a6a33c70e15043 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sat, 3 May 2014 17:15:23 +0530 Subject: staging: rtl8188eu: Remove 'dma_addr_t dma_transfer_addr' from struct recv_buf Remove unused variable dma_transfer_addr. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/rtw_recv.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index 4a19a0657f3a..bf9af773acf8 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -245,7 +245,6 @@ struct recv_buf { u8 *ptail; u8 *pend; struct urb *purb; - dma_addr_t dma_transfer_addr; /* (in) dma addr for transfer_buffer */ u32 alloc_sz; u8 irp_pending; int transfer_len; -- cgit v1.2.3 From afdd36ef9cb0392a701ee8940d1d9f7e01735643 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sat, 3 May 2014 17:15:24 +0530 Subject: staging: rtl8188eu: Remove 'int transfer_len' from struct recv_buf Driver is not making any use of value stored in this variable. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c | 2 -- drivers/staging/rtl8188eu/hal/usb_ops_linux.c | 1 - drivers/staging/rtl8188eu/include/rtw_recv.h | 1 - drivers/staging/rtl8188eu/os_dep/recv_linux.c | 1 - 4 files changed, 5 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c index 52d83a4afd35..ee7fa6408fe4 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c @@ -30,8 +30,6 @@ void rtl8188eu_init_recvbuf(struct adapter *padapter, struct recv_buf *precvbuf) { - precvbuf->transfer_len = 0; - precvbuf->len = 0; precvbuf->ref_cnt = 0; diff --git a/drivers/staging/rtl8188eu/hal/usb_ops_linux.c b/drivers/staging/rtl8188eu/hal/usb_ops_linux.c index 1fa5370f1da6..285cb5f3f727 100644 --- a/drivers/staging/rtl8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/hal/usb_ops_linux.c @@ -518,7 +518,6 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) } else { rtw_reset_continual_urb_error(adapter_to_dvobj(adapt)); - precvbuf->transfer_len = purb->actual_length; skb_put(precvbuf->pskb, purb->actual_length); skb_queue_tail(&precvpriv->rx_skb_queue, precvbuf->pskb); diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index bf9af773acf8..cac8acb10522 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -247,7 +247,6 @@ struct recv_buf { struct urb *purb; u32 alloc_sz; u8 irp_pending; - int transfer_len; struct sk_buff *pskb; u8 reuse; }; diff --git a/drivers/staging/rtl8188eu/os_dep/recv_linux.c b/drivers/staging/rtl8188eu/os_dep/recv_linux.c index da397e4c6773..083833908e93 100644 --- a/drivers/staging/rtl8188eu/os_dep/recv_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/recv_linux.c @@ -67,7 +67,6 @@ int rtw_os_recvbuf_resource_alloc(struct adapter *padapter, precvbuf->phead = NULL; precvbuf->ptail = NULL; precvbuf->pend = NULL; - precvbuf->transfer_len = 0; precvbuf->len = 0; return res; } -- cgit v1.2.3 From c11f3fff320540e7d84a3bbb2d7d3918465589b5 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sat, 3 May 2014 17:15:25 +0530 Subject: staging: rtl8188eu: Remove pdata, phead, ptail and pend from struct recv_buf Driver is not making use of value stored in removed variables. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c | 8 -------- drivers/staging/rtl8188eu/hal/usb_ops_linux.c | 9 --------- drivers/staging/rtl8188eu/include/rtw_recv.h | 4 ---- drivers/staging/rtl8188eu/os_dep/recv_linux.c | 4 ---- 4 files changed, 25 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c index ee7fa6408fe4..41a0c0dc521e 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c @@ -31,15 +31,7 @@ void rtl8188eu_init_recvbuf(struct adapter *padapter, struct recv_buf *precvbuf) { precvbuf->len = 0; - precvbuf->ref_cnt = 0; - - if (precvbuf->pbuf) { - precvbuf->pdata = precvbuf->pbuf; - precvbuf->phead = precvbuf->pbuf; - precvbuf->ptail = precvbuf->pbuf; - precvbuf->pend = precvbuf->pdata + MAX_RECVBUF_SZ; - } } int rtl8188eu_init_recv_priv(struct adapter *padapter) diff --git a/drivers/staging/rtl8188eu/hal/usb_ops_linux.c b/drivers/staging/rtl8188eu/hal/usb_ops_linux.c index 285cb5f3f727..654c5b38b1ac 100644 --- a/drivers/staging/rtl8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/hal/usb_ops_linux.c @@ -615,18 +615,9 @@ static u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1); skb_reserve(precvbuf->pskb, (RECVBUFF_ALIGN_SZ - alignment)); - precvbuf->phead = precvbuf->pskb->head; - precvbuf->pdata = precvbuf->pskb->data; - precvbuf->ptail = skb_tail_pointer(precvbuf->pskb); - precvbuf->pend = skb_end_pointer(precvbuf->pskb); precvbuf->pbuf = precvbuf->pskb->data; } else { /* reuse skb */ - precvbuf->phead = precvbuf->pskb->head; - precvbuf->pdata = precvbuf->pskb->data; - precvbuf->ptail = skb_tail_pointer(precvbuf->pskb); - precvbuf->pend = skb_end_pointer(precvbuf->pskb); precvbuf->pbuf = precvbuf->pskb->data; - precvbuf->reuse = false; } diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index cac8acb10522..8d3424b257e6 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -240,10 +240,6 @@ struct recv_buf { u8 *pbuf; u8 *pallocated_buf; u32 len; - u8 *phead; - u8 *pdata; - u8 *ptail; - u8 *pend; struct urb *purb; u32 alloc_sz; u8 irp_pending; diff --git a/drivers/staging/rtl8188eu/os_dep/recv_linux.c b/drivers/staging/rtl8188eu/os_dep/recv_linux.c index 083833908e93..99b5910e20f3 100644 --- a/drivers/staging/rtl8188eu/os_dep/recv_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/recv_linux.c @@ -63,10 +63,6 @@ int rtw_os_recvbuf_resource_alloc(struct adapter *padapter, precvbuf->reuse = false; precvbuf->pallocated_buf = NULL; precvbuf->pbuf = NULL; - precvbuf->pdata = NULL; - precvbuf->phead = NULL; - precvbuf->ptail = NULL; - precvbuf->pend = NULL; precvbuf->len = 0; return res; } -- cgit v1.2.3 From e205cae24d0845b39502dafc3c3abe4b265035d3 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sat, 3 May 2014 17:15:26 +0530 Subject: staging: rtl8188eu: Remove 'irp_pending' from struct recv_buf irp_pending is initialized to false inside rtw_os_recvbuf_resource_alloc() and value of irq_pending never changed after that, so 'if (!precvbuf->irp_pending)' inside rtw_os_read_port() function will be always true. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/rtw_recv.h | 1 - drivers/staging/rtl8188eu/os_dep/recv_linux.c | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index 8d3424b257e6..987445a0ab0a 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -242,7 +242,6 @@ struct recv_buf { u32 len; struct urb *purb; u32 alloc_sz; - u8 irp_pending; struct sk_buff *pskb; u8 reuse; }; diff --git a/drivers/staging/rtl8188eu/os_dep/recv_linux.c b/drivers/staging/rtl8188eu/os_dep/recv_linux.c index 99b5910e20f3..7f9b6545b625 100644 --- a/drivers/staging/rtl8188eu/os_dep/recv_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/recv_linux.c @@ -55,7 +55,6 @@ int rtw_os_recvbuf_resource_alloc(struct adapter *padapter, { int res = _SUCCESS; - precvbuf->irp_pending = false; precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL); if (precvbuf->purb == NULL) res = _FAIL; @@ -229,9 +228,8 @@ void rtw_os_read_port(struct adapter *padapter, struct recv_buf *precvbuf) dev_kfree_skb_any(precvbuf->pskb); precvbuf->pskb = NULL; precvbuf->reuse = false; - if (!precvbuf->irp_pending) - rtw_read_port(padapter, precvpriv->ff_hwaddr, 0, - (unsigned char *)precvbuf); + rtw_read_port(padapter, precvpriv->ff_hwaddr, 0, + (unsigned char *)precvbuf); } static void _rtw_reordering_ctrl_timeout_handler(void *func_context) -- cgit v1.2.3 From f0f4499d703d73c8c9dac77e3fff9cd71c04db9a Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sat, 3 May 2014 17:15:27 +0530 Subject: staging: rtl8188eu: Remove 'pallocated_buf' from struct recv_buf pallocated_buf is not being used by driver. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/rtw_recv.h | 1 - drivers/staging/rtl8188eu/os_dep/recv_linux.c | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index 987445a0ab0a..b955d73bb97c 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -238,7 +238,6 @@ struct recv_buf { u32 ref_cnt; struct adapter *adapter; u8 *pbuf; - u8 *pallocated_buf; u32 len; struct urb *purb; u32 alloc_sz; diff --git a/drivers/staging/rtl8188eu/os_dep/recv_linux.c b/drivers/staging/rtl8188eu/os_dep/recv_linux.c index 7f9b6545b625..25358fbeefeb 100644 --- a/drivers/staging/rtl8188eu/os_dep/recv_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/recv_linux.c @@ -60,7 +60,6 @@ int rtw_os_recvbuf_resource_alloc(struct adapter *padapter, res = _FAIL; precvbuf->pskb = NULL; precvbuf->reuse = false; - precvbuf->pallocated_buf = NULL; precvbuf->pbuf = NULL; precvbuf->len = 0; return res; -- cgit v1.2.3 From 1b2a4fc7a55415a7afc5baa21986dbd25345e782 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sat, 3 May 2014 17:15:28 +0530 Subject: staging: rtl8188eu: Remove 'alloc_sz' from struct recv_buf Driver isn't making any use of value stored in alloc_sz variable. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c | 1 - drivers/staging/rtl8188eu/include/rtw_recv.h | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c index 41a0c0dc521e..3edc2cd1ac7b 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c @@ -61,7 +61,6 @@ int rtl8188eu_init_recv_priv(struct adapter *padapter) precvbuf = (struct recv_buf *)precvpriv->precv_buf; for (i = 0; i < NR_RECVBUFF; i++) { - precvbuf->alloc_sz = MAX_RECVBUF_SZ; res = rtw_os_recvbuf_resource_alloc(padapter, precvbuf); if (res == _FAIL) break; diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index b955d73bb97c..519ed4e17a61 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -240,7 +240,6 @@ struct recv_buf { u8 *pbuf; u32 len; struct urb *purb; - u32 alloc_sz; struct sk_buff *pskb; u8 reuse; }; -- cgit v1.2.3 From 74e250e479cb79b0cd58a810ed1a6f630877b4ad Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sat, 3 May 2014 17:15:29 +0530 Subject: staging: rtl8188eu: Remove 'u32 len' from struct recv_buf Remove unused variable 'u32 len'. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c | 1 - drivers/staging/rtl8188eu/include/rtw_recv.h | 1 - drivers/staging/rtl8188eu/os_dep/recv_linux.c | 1 - 3 files changed, 3 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c index 3edc2cd1ac7b..740818a5a7cf 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c @@ -30,7 +30,6 @@ void rtl8188eu_init_recvbuf(struct adapter *padapter, struct recv_buf *precvbuf) { - precvbuf->len = 0; precvbuf->ref_cnt = 0; } diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index 519ed4e17a61..3f43f1179154 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -238,7 +238,6 @@ struct recv_buf { u32 ref_cnt; struct adapter *adapter; u8 *pbuf; - u32 len; struct urb *purb; struct sk_buff *pskb; u8 reuse; diff --git a/drivers/staging/rtl8188eu/os_dep/recv_linux.c b/drivers/staging/rtl8188eu/os_dep/recv_linux.c index 25358fbeefeb..2577ceb62dee 100644 --- a/drivers/staging/rtl8188eu/os_dep/recv_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/recv_linux.c @@ -61,7 +61,6 @@ int rtw_os_recvbuf_resource_alloc(struct adapter *padapter, precvbuf->pskb = NULL; precvbuf->reuse = false; precvbuf->pbuf = NULL; - precvbuf->len = 0; return res; } -- cgit v1.2.3 From a1f3b3fdba2ab124c1e8c2b6aa17cfcf5c99d756 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sat, 3 May 2014 17:15:30 +0530 Subject: staging: rtl8188eu: Remove 'u32 ref_cnt' from struct recv_buf Driver isn't making any use of value stored in variable ref_cnt. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c | 2 -- drivers/staging/rtl8188eu/include/rtw_recv.h | 1 - drivers/staging/rtl8188eu/os_dep/recv_linux.c | 1 - 3 files changed, 4 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c index 740818a5a7cf..fc06991ed784 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c @@ -30,7 +30,6 @@ void rtl8188eu_init_recvbuf(struct adapter *padapter, struct recv_buf *precvbuf) { - precvbuf->ref_cnt = 0; } int rtl8188eu_init_recv_priv(struct adapter *padapter) @@ -63,7 +62,6 @@ int rtl8188eu_init_recv_priv(struct adapter *padapter) res = rtw_os_recvbuf_resource_alloc(padapter, precvbuf); if (res == _FAIL) break; - precvbuf->ref_cnt = 0; precvbuf->adapter = padapter; precvbuf++; } diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index 3f43f1179154..8dadf30a818a 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -235,7 +235,6 @@ struct sta_recv_priv { }; struct recv_buf { - u32 ref_cnt; struct adapter *adapter; u8 *pbuf; struct urb *purb; diff --git a/drivers/staging/rtl8188eu/os_dep/recv_linux.c b/drivers/staging/rtl8188eu/os_dep/recv_linux.c index 2577ceb62dee..c1664b723bf5 100644 --- a/drivers/staging/rtl8188eu/os_dep/recv_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/recv_linux.c @@ -221,7 +221,6 @@ void rtw_os_read_port(struct adapter *padapter, struct recv_buf *precvbuf) { struct recv_priv *precvpriv = &padapter->recvpriv; - precvbuf->ref_cnt--; /* free skb in recv_buf */ dev_kfree_skb_any(precvbuf->pskb); precvbuf->pskb = NULL; -- cgit v1.2.3 From acfd19e70701dd1ba49653193eab88e379572e92 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sat, 3 May 2014 17:15:31 +0530 Subject: staging: rtl8188eu: Remove rtl8188eu_init_recvbuf() function rtl8188eu_init_recvbuf() function definition is empty now, so remove it. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c | 4 ---- drivers/staging/rtl8188eu/hal/usb_ops_linux.c | 2 -- drivers/staging/rtl8188eu/include/rtl8188e_recv.h | 1 - 3 files changed, 7 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c index fc06991ed784..2b4556414e8a 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c @@ -28,10 +28,6 @@ #include -void rtl8188eu_init_recvbuf(struct adapter *padapter, struct recv_buf *precvbuf) -{ -} - int rtl8188eu_init_recv_priv(struct adapter *padapter) { struct recv_priv *precvpriv = &padapter->recvpriv; diff --git a/drivers/staging/rtl8188eu/hal/usb_ops_linux.c b/drivers/staging/rtl8188eu/hal/usb_ops_linux.c index 654c5b38b1ac..d3c5ed335274 100644 --- a/drivers/staging/rtl8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/hal/usb_ops_linux.c @@ -600,8 +600,6 @@ static u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) precvbuf->reuse = true; } - rtl8188eu_init_recvbuf(adapter, precvbuf); - /* re-assign for linux based on skb */ if ((!precvbuf->reuse) || (precvbuf->pskb == NULL)) { precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev, MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ); diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_recv.h b/drivers/staging/rtl8188eu/include/rtl8188e_recv.h index 07e5f5227336..5fed30d389a2 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_recv.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_recv.h @@ -56,7 +56,6 @@ enum rx_packet_type { }; #define INTERRUPT_MSG_FORMAT_LEN 60 -void rtl8188eu_init_recvbuf(struct adapter *padapter, struct recv_buf *buf); s32 rtl8188eu_init_recv_priv(struct adapter *padapter); void rtl8188eu_free_recv_priv(struct adapter *padapter); void rtl8188eu_recv_hdl(struct adapter *padapter, struct recv_buf *precvbuf); -- cgit v1.2.3 From 09c3fbba88b444f5e46702cc90fd014d2df7b36d Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sat, 3 May 2014 17:15:32 +0530 Subject: staging: rtl8188eu: Remove 'u8 *pbuf' from struct recv_buf Instead of using pbuf to pass sbk data pointer to usb_fill_bulk_urb(), we can use precvbuf->pskb->data to do that. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/usb_ops_linux.c | 5 +---- drivers/staging/rtl8188eu/include/rtw_recv.h | 1 - drivers/staging/rtl8188eu/os_dep/recv_linux.c | 1 - 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/usb_ops_linux.c b/drivers/staging/rtl8188eu/hal/usb_ops_linux.c index d3c5ed335274..d8fc7472eb90 100644 --- a/drivers/staging/rtl8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/hal/usb_ops_linux.c @@ -612,10 +612,7 @@ static u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) tmpaddr = (size_t)precvbuf->pskb->data; alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1); skb_reserve(precvbuf->pskb, (RECVBUFF_ALIGN_SZ - alignment)); - - precvbuf->pbuf = precvbuf->pskb->data; } else { /* reuse skb */ - precvbuf->pbuf = precvbuf->pskb->data; precvbuf->reuse = false; } @@ -627,7 +624,7 @@ static u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) pipe = ffaddr2pipehdl(pdvobj, addr); usb_fill_bulk_urb(purb, pusbd, pipe, - precvbuf->pbuf, + precvbuf->pskb->data, MAX_RECVBUF_SZ, usb_read_port_complete, precvbuf);/* context is precvbuf */ diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index 8dadf30a818a..971dd16d4a27 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -236,7 +236,6 @@ struct sta_recv_priv { struct recv_buf { struct adapter *adapter; - u8 *pbuf; struct urb *purb; struct sk_buff *pskb; u8 reuse; diff --git a/drivers/staging/rtl8188eu/os_dep/recv_linux.c b/drivers/staging/rtl8188eu/os_dep/recv_linux.c index c1664b723bf5..29ec0148b573 100644 --- a/drivers/staging/rtl8188eu/os_dep/recv_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/recv_linux.c @@ -60,7 +60,6 @@ int rtw_os_recvbuf_resource_alloc(struct adapter *padapter, res = _FAIL; precvbuf->pskb = NULL; precvbuf->reuse = false; - precvbuf->pbuf = NULL; return res; } -- cgit v1.2.3 From 5d02edfc3957446fd625c0b018e14c6631a791f4 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Sat, 19 Apr 2014 00:22:00 +0100 Subject: iio: hid-sensors: Convert units and exponent HID sensor hub specify a default unit and alternative units. This along with unit exponent can be used adjust scale. This change change HID sensor data units to IIO defined units for each sensor type. So in this way user space can use a simply use: "(data + offset) * scale" to get final result. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- .../iio/common/hid-sensors/hid-sensor-attributes.c | 114 +++++++++++++++++++++ include/linux/hid-sensor-hub.h | 4 + 2 files changed, 118 insertions(+) diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c index 75b54730a963..e61b1faa1e06 100644 --- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c +++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c @@ -26,6 +26,40 @@ #include #include +struct { + u32 usage_id; + int unit; /* 0 for default others from HID sensor spec */ + int scale_val0; /* scale, whole number */ + int scale_val1; /* scale, fraction in micros */ +} static unit_conversion[] = { + {HID_USAGE_SENSOR_ACCEL_3D, 0, 9, 806650}, + {HID_USAGE_SENSOR_ACCEL_3D, + HID_USAGE_SENSOR_UNITS_METERS_PER_SEC_SQRD, 1, 0}, + {HID_USAGE_SENSOR_ACCEL_3D, + HID_USAGE_SENSOR_UNITS_G, 9, 806650}, + + {HID_USAGE_SENSOR_GYRO_3D, 0, 0, 17453}, + {HID_USAGE_SENSOR_GYRO_3D, + HID_USAGE_SENSOR_UNITS_RADIANS_PER_SECOND, 1, 0}, + {HID_USAGE_SENSOR_GYRO_3D, + HID_USAGE_SENSOR_UNITS_DEGREES_PER_SECOND, 0, 17453}, + + {HID_USAGE_SENSOR_COMPASS_3D, 0, 0, 1000}, + {HID_USAGE_SENSOR_COMPASS_3D, HID_USAGE_SENSOR_UNITS_GAUSS, 1, 0}, + + {HID_USAGE_SENSOR_INCLINOMETER_3D, 0, 0, 17453}, + {HID_USAGE_SENSOR_INCLINOMETER_3D, + HID_USAGE_SENSOR_UNITS_DEGREES, 0, 17453}, + {HID_USAGE_SENSOR_INCLINOMETER_3D, + HID_USAGE_SENSOR_UNITS_RADIANS, 1, 0}, + + {HID_USAGE_SENSOR_ALS, 0, 1, 0}, + {HID_USAGE_SENSOR_ALS, HID_USAGE_SENSOR_UNITS_LUX, 1, 0}, + + {HID_USAGE_SENSOR_PRESSURE, 0, 100000, 0}, + {HID_USAGE_SENSOR_PRESSURE, HID_USAGE_SENSOR_UNITS_PASCAL, 1, 0}, +}; + static int pow_10(unsigned power) { int i; @@ -209,6 +243,86 @@ int hid_sensor_write_raw_hyst_value(struct hid_sensor_common *st, } EXPORT_SYMBOL(hid_sensor_write_raw_hyst_value); +/* + * This fuction applies the unit exponent to the scale. + * For example: + * 9.806650 ->exp:2-> val0[980]val1[665000] + * 9.000806 ->exp:2-> val0[900]val1[80600] + * 0.174535 ->exp:2-> val0[17]val1[453500] + * 1.001745 ->exp:0-> val0[1]val1[1745] + * 1.001745 ->exp:2-> val0[100]val1[174500] + * 1.001745 ->exp:4-> val0[10017]val1[450000] + * 9.806650 ->exp:-2-> val0[0]val1[98066] + */ +static void adjust_exponent_micro(int *val0, int *val1, int scale0, + int scale1, int exp) +{ + int i; + int x; + int res; + int rem; + + if (exp > 0) { + *val0 = scale0 * pow_10(exp); + res = 0; + if (exp > 6) { + *val1 = 0; + return; + } + for (i = 0; i < exp; ++i) { + x = scale1 / pow_10(5 - i); + res += (pow_10(exp - 1 - i) * x); + scale1 = scale1 % pow_10(5 - i); + } + *val0 += res; + *val1 = scale1 * pow_10(exp); + } else if (exp < 0) { + exp = abs(exp); + if (exp > 6) { + *val0 = *val1 = 0; + return; + } + *val0 = scale0 / pow_10(exp); + rem = scale0 % pow_10(exp); + res = 0; + for (i = 0; i < (6 - exp); ++i) { + x = scale1 / pow_10(5 - i); + res += (pow_10(5 - exp - i) * x); + scale1 = scale1 % pow_10(5 - i); + } + *val1 = rem * pow_10(6 - exp) + res; + } else { + *val0 = scale0; + *val1 = scale1; + } +} + +int hid_sensor_format_scale(u32 usage_id, + struct hid_sensor_hub_attribute_info *attr_info, + int *val0, int *val1) +{ + int i; + int exp; + + *val0 = 1; + *val1 = 0; + + for (i = 0; ARRAY_SIZE(unit_conversion); ++i) { + if (unit_conversion[i].usage_id == usage_id && + unit_conversion[i].unit == attr_info->units) { + exp = hid_sensor_convert_exponent( + attr_info->unit_expo); + adjust_exponent_micro(val0, val1, + unit_conversion[i].scale_val0, + unit_conversion[i].scale_val1, exp); + break; + } + } + + return IIO_VAL_INT_PLUS_MICRO; +} +EXPORT_SYMBOL(hid_sensor_format_scale); + int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev, u32 usage_id, struct hid_sensor_common *st) diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h index b70cfd7ff29c..89626b23c246 100644 --- a/include/linux/hid-sensor-hub.h +++ b/include/linux/hid-sensor-hub.h @@ -223,4 +223,8 @@ int hid_sensor_read_samp_freq_value(struct hid_sensor_common *st, int hid_sensor_get_usage_index(struct hid_sensor_hub_device *hsdev, u32 report_id, int field_index, u32 usage_id); +int hid_sensor_format_scale(u32 usage_id, + struct hid_sensor_hub_attribute_info *attr_info, + int *val0, int *val1); + #endif -- cgit v1.2.3 From 9030924510a9e7d4b7d218749533840075879f2f Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Sat, 19 Apr 2014 00:22:00 +0100 Subject: iio: hid-sensors: Add api to get poll value Added interface to get poll value in milli-seconds. This value is changed by changing sampling frequency. This API allows clients to wait for at least some poll milli seconds before reading a new sample. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- .../iio/common/hid-sensors/hid-sensor-attributes.c | 20 ++++++++++++++++++++ include/linux/hid-sensor-hub.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c index e61b1faa1e06..372964635ccf 100644 --- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c +++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c @@ -147,6 +147,26 @@ static u32 convert_to_vtf_format(int size, int exp, int val1, int val2) return value; } +s32 hid_sensor_read_poll_value(struct hid_sensor_common *st) +{ + s32 value = 0; + int ret; + + ret = sensor_hub_get_feature(st->hsdev, + st->poll.report_id, + st->poll.index, &value); + + if (ret < 0 || value < 0) { + return -EINVAL; + } else { + if (st->poll.units == HID_USAGE_SENSOR_UNITS_SECOND) + value = value * 1000; + } + + return value; +} +EXPORT_SYMBOL(hid_sensor_read_poll_value); + int hid_sensor_read_samp_freq_value(struct hid_sensor_common *st, int *val1, int *val2) { diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h index 89626b23c246..88d8d636a68f 100644 --- a/include/linux/hid-sensor-hub.h +++ b/include/linux/hid-sensor-hub.h @@ -227,4 +227,6 @@ int hid_sensor_format_scale(u32 usage_id, struct hid_sensor_hub_attribute_info *attr_info, int *val0, int *val1); +s32 hid_sensor_read_poll_value(struct hid_sensor_common *st); + #endif -- cgit v1.2.3 From 73a24988201f1bc82143ad183c79206052ef2fe8 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Sat, 19 Apr 2014 00:22:00 +0100 Subject: iio: hid-sensors: Accelerometer 3D: adjust scale and offset Using units and unit exponent to calculate scale which is compliant to IIO ABI. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/accel/hid-sensor-accel-3d.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c index 3dcdbad65456..ca50a91752d8 100644 --- a/drivers/iio/accel/hid-sensor-accel-3d.c +++ b/drivers/iio/accel/hid-sensor-accel-3d.c @@ -42,6 +42,10 @@ struct accel_3d_state { struct hid_sensor_common common_attributes; struct hid_sensor_hub_attribute_info accel[ACCEL_3D_CHANNEL_MAX]; u32 accel_val[ACCEL_3D_CHANNEL_MAX]; + int scale_pre_decml; + int scale_post_decml; + int scale_precision; + int value_offset; }; static const u32 accel_3d_addresses[ACCEL_3D_CHANNEL_MAX] = { @@ -123,12 +127,12 @@ static int accel_3d_read_raw(struct iio_dev *indio_dev, ret_type = IIO_VAL_INT; break; case IIO_CHAN_INFO_SCALE: - *val = accel_state->accel[CHANNEL_SCAN_INDEX_X].units; - ret_type = IIO_VAL_INT; + *val = accel_state->scale_pre_decml; + *val2 = accel_state->scale_post_decml; + ret_type = accel_state->scale_precision; break; case IIO_CHAN_INFO_OFFSET: - *val = hid_sensor_convert_exponent( - accel_state->accel[CHANNEL_SCAN_INDEX_X].unit_expo); + *val = accel_state->value_offset; ret_type = IIO_VAL_INT; break; case IIO_CHAN_INFO_SAMP_FREQ: @@ -262,6 +266,11 @@ static int accel_3d_parse_report(struct platform_device *pdev, st->accel[1].index, st->accel[1].report_id, st->accel[2].index, st->accel[2].report_id); + st->scale_precision = hid_sensor_format_scale( + HID_USAGE_SENSOR_ACCEL_3D, + &st->accel[CHANNEL_SCAN_INDEX_X], + &st->scale_pre_decml, &st->scale_post_decml); + /* Set Sensitivity field ids, when there is no individual modifier */ if (st->common_attributes.sensitivity.index < 0) { sensor_hub_input_get_attribute_info(hsdev, -- cgit v1.2.3 From 6c7db77e406d61275e41268c1829e847a7237a27 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Sat, 19 Apr 2014 00:22:00 +0100 Subject: iio: hid-sensors: Gyro 3D : adjust scale and offset Using units and unit exponent to calculate scale which is compliant to IIO ABI. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/gyro/hid-sensor-gyro-3d.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c index 59d6bc3e04df..53ac06040fbe 100644 --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c @@ -42,6 +42,10 @@ struct gyro_3d_state { struct hid_sensor_common common_attributes; struct hid_sensor_hub_attribute_info gyro[GYRO_3D_CHANNEL_MAX]; u32 gyro_val[GYRO_3D_CHANNEL_MAX]; + int scale_pre_decml; + int scale_post_decml; + int scale_precision; + int value_offset; }; static const u32 gyro_3d_addresses[GYRO_3D_CHANNEL_MAX] = { @@ -123,12 +127,12 @@ static int gyro_3d_read_raw(struct iio_dev *indio_dev, ret_type = IIO_VAL_INT; break; case IIO_CHAN_INFO_SCALE: - *val = gyro_state->gyro[CHANNEL_SCAN_INDEX_X].units; - ret_type = IIO_VAL_INT; + *val = gyro_state->scale_pre_decml; + *val2 = gyro_state->scale_post_decml; + ret_type = gyro_state->scale_precision; break; case IIO_CHAN_INFO_OFFSET: - *val = hid_sensor_convert_exponent( - gyro_state->gyro[CHANNEL_SCAN_INDEX_X].unit_expo); + *val = gyro_state->value_offset; ret_type = IIO_VAL_INT; break; case IIO_CHAN_INFO_SAMP_FREQ: @@ -262,6 +266,11 @@ static int gyro_3d_parse_report(struct platform_device *pdev, st->gyro[1].index, st->gyro[1].report_id, st->gyro[2].index, st->gyro[2].report_id); + st->scale_precision = hid_sensor_format_scale( + HID_USAGE_SENSOR_GYRO_3D, + &st->gyro[CHANNEL_SCAN_INDEX_X], + &st->scale_pre_decml, &st->scale_post_decml); + /* Set Sensitivity field ids, when there is no individual modifier */ if (st->common_attributes.sensitivity.index < 0) { sensor_hub_input_get_attribute_info(hsdev, -- cgit v1.2.3 From 36783d09f1a5c0fdfe9c0d177b5491f0ed0509ce Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Sat, 19 Apr 2014 00:22:00 +0100 Subject: iio: hid-sensors: ALS: adjust scale and offset Using units and unit exponent to calculate scale which is compliant to IIO ABI. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/light/hid-sensor-als.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c index 621541fb10a9..39b50be9d456 100644 --- a/drivers/iio/light/hid-sensor-als.c +++ b/drivers/iio/light/hid-sensor-als.c @@ -37,6 +37,10 @@ struct als_state { struct hid_sensor_common common_attributes; struct hid_sensor_hub_attribute_info als_illum; u32 illum; + int scale_pre_decml; + int scale_post_decml; + int scale_precision; + int value_offset; }; /* Channel definitions */ @@ -102,12 +106,12 @@ static int als_read_raw(struct iio_dev *indio_dev, ret_type = IIO_VAL_INT; break; case IIO_CHAN_INFO_SCALE: - *val = als_state->als_illum.units; - ret_type = IIO_VAL_INT; + *val = als_state->scale_pre_decml; + *val2 = als_state->scale_post_decml; + ret_type = als_state->scale_precision; break; case IIO_CHAN_INFO_OFFSET: - *val = hid_sensor_convert_exponent( - als_state->als_illum.unit_expo); + *val = als_state->value_offset; ret_type = IIO_VAL_INT; break; case IIO_CHAN_INFO_SAMP_FREQ: @@ -229,6 +233,11 @@ static int als_parse_report(struct platform_device *pdev, dev_dbg(&pdev->dev, "als %x:%x\n", st->als_illum.index, st->als_illum.report_id); + st->scale_precision = hid_sensor_format_scale( + HID_USAGE_SENSOR_ALS, + &st->als_illum, + &st->scale_pre_decml, &st->scale_post_decml); + /* Set Sensitivity field ids, when there is no individual modifier */ if (st->common_attributes.sensitivity.index < 0) { sensor_hub_input_get_attribute_info(hsdev, -- cgit v1.2.3 From 92463fdab5d8e5f97d96478383c3d3e5385e867b Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Sat, 19 Apr 2014 00:22:00 +0100 Subject: iio: hid-sensors: Compass 3D: adjust scale and offset Using units and unit exponent to calculate scale which is compliant to IIO ABI. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/hid-sensor-magn-3d.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c index 6d162b7e7af5..131ced0dcb1c 100644 --- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c +++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c @@ -42,6 +42,10 @@ struct magn_3d_state { struct hid_sensor_common common_attributes; struct hid_sensor_hub_attribute_info magn[MAGN_3D_CHANNEL_MAX]; u32 magn_val[MAGN_3D_CHANNEL_MAX]; + int scale_pre_decml; + int scale_post_decml; + int scale_precision; + int value_offset; }; static const u32 magn_3d_addresses[MAGN_3D_CHANNEL_MAX] = { @@ -124,12 +128,12 @@ static int magn_3d_read_raw(struct iio_dev *indio_dev, ret_type = IIO_VAL_INT; break; case IIO_CHAN_INFO_SCALE: - *val = magn_state->magn[CHANNEL_SCAN_INDEX_X].units; - ret_type = IIO_VAL_INT; + *val = magn_state->scale_pre_decml; + *val2 = magn_state->scale_post_decml; + ret_type = magn_state->scale_precision; break; case IIO_CHAN_INFO_OFFSET: - *val = hid_sensor_convert_exponent( - magn_state->magn[CHANNEL_SCAN_INDEX_X].unit_expo); + *val = magn_state->value_offset; ret_type = IIO_VAL_INT; break; case IIO_CHAN_INFO_SAMP_FREQ: @@ -263,6 +267,11 @@ static int magn_3d_parse_report(struct platform_device *pdev, st->magn[1].index, st->magn[1].report_id, st->magn[2].index, st->magn[2].report_id); + st->scale_precision = hid_sensor_format_scale( + HID_USAGE_SENSOR_COMPASS_3D, + &st->magn[CHANNEL_SCAN_INDEX_X], + &st->scale_pre_decml, &st->scale_post_decml); + /* Set Sensitivity field ids, when there is no individual modifier */ if (st->common_attributes.sensitivity.index < 0) { sensor_hub_input_get_attribute_info(hsdev, -- cgit v1.2.3 From be8e48d67ecdb1cc1234ff4f32a6e5d0002e4672 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Sat, 19 Apr 2014 00:22:00 +0100 Subject: iio: hid-sensors: Inclinometer 3D: adjust scale and offset Using units and unit exponent to calculate scale which is compliant to IIO ABI. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/orientation/hid-sensor-incl-3d.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/iio/orientation/hid-sensor-incl-3d.c b/drivers/iio/orientation/hid-sensor-incl-3d.c index 070feab08faa..f0c465cc192a 100644 --- a/drivers/iio/orientation/hid-sensor-incl-3d.c +++ b/drivers/iio/orientation/hid-sensor-incl-3d.c @@ -42,6 +42,10 @@ struct incl_3d_state { struct hid_sensor_common common_attributes; struct hid_sensor_hub_attribute_info incl[INCLI_3D_CHANNEL_MAX]; u32 incl_val[INCLI_3D_CHANNEL_MAX]; + int scale_pre_decml; + int scale_post_decml; + int scale_precision; + int value_offset; }; static const u32 incl_3d_addresses[INCLI_3D_CHANNEL_MAX] = { @@ -125,12 +129,12 @@ static int incl_3d_read_raw(struct iio_dev *indio_dev, ret_type = IIO_VAL_INT; break; case IIO_CHAN_INFO_SCALE: - *val = incl_state->incl[CHANNEL_SCAN_INDEX_X].units; - ret_type = IIO_VAL_INT; + *val = incl_state->scale_pre_decml; + *val2 = incl_state->scale_post_decml; + ret_type = incl_state->scale_precision; break; case IIO_CHAN_INFO_OFFSET: - *val = hid_sensor_convert_exponent( - incl_state->incl[CHANNEL_SCAN_INDEX_X].unit_expo); + *val = incl_state->value_offset; ret_type = IIO_VAL_INT; break; case IIO_CHAN_INFO_SAMP_FREQ: @@ -279,6 +283,11 @@ static int incl_3d_parse_report(struct platform_device *pdev, st->incl[1].index, st->incl[1].report_id, st->incl[2].index, st->incl[2].report_id); + st->scale_precision = hid_sensor_format_scale( + HID_USAGE_SENSOR_INCLINOMETER_3D, + &st->incl[CHANNEL_SCAN_INDEX_X], + &st->scale_pre_decml, &st->scale_post_decml); + /* Set Sensitivity field ids, when there is no individual modifier */ if (st->common_attributes.sensitivity.index < 0) { sensor_hub_input_get_attribute_info(hsdev, -- cgit v1.2.3 From a269b9a0a27675c34c62c4e20c4ffb62054cd51a Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Sat, 19 Apr 2014 00:22:00 +0100 Subject: iio: hid-sensors: Pressure: adjust scale and offset Using units and unit exponent to calculate scale which is compliant to IIO ABI. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/hid-sensor-press.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c index e0e6409aa94e..ff69da4443b8 100644 --- a/drivers/iio/pressure/hid-sensor-press.c +++ b/drivers/iio/pressure/hid-sensor-press.c @@ -36,6 +36,10 @@ struct press_state { struct hid_sensor_common common_attributes; struct hid_sensor_hub_attribute_info press_attr; u32 press_data; + int scale_pre_decml; + int scale_post_decml; + int scale_precision; + int value_offset; }; /* Channel definitions */ @@ -102,12 +106,12 @@ static int press_read_raw(struct iio_dev *indio_dev, ret_type = IIO_VAL_INT; break; case IIO_CHAN_INFO_SCALE: - *val = press_state->press_attr.units; - ret_type = IIO_VAL_INT; + *val = press_state->scale_pre_decml; + *val2 = press_state->scale_post_decml; + ret_type = press_state->scale_precision; break; case IIO_CHAN_INFO_OFFSET: - *val = hid_sensor_convert_exponent( - press_state->press_attr.unit_expo); + *val = press_state->value_offset; ret_type = IIO_VAL_INT; break; case IIO_CHAN_INFO_SAMP_FREQ: @@ -229,6 +233,11 @@ static int press_parse_report(struct platform_device *pdev, dev_dbg(&pdev->dev, "press %x:%x\n", st->press_attr.index, st->press_attr.report_id); + st->scale_precision = hid_sensor_format_scale( + HID_USAGE_SENSOR_PRESSURE, + &st->press_attr, + &st->scale_pre_decml, &st->scale_post_decml); + /* Set Sensitivity field ids, when there is no individual modifier */ if (st->common_attributes.sensitivity.index < 0) { sensor_hub_input_get_attribute_info(hsdev, -- cgit v1.2.3 From 56ff6be608659ac06d4e3cc5827476efa29d610f Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Sat, 19 Apr 2014 00:22:00 +0100 Subject: iio: hid-sensors: Add API to power on/off Added an API to allow client drivers to turn ON and OFF sensors for quick read. Added data_read as counting varaible instead of boolean, so that sensor is powered off only when last user released it. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/accel/hid-sensor-accel-3d.c | 7 +++---- drivers/iio/common/hid-sensors/hid-sensor-trigger.c | 17 +++++++++++++---- drivers/iio/common/hid-sensors/hid-sensor-trigger.h | 1 + drivers/iio/gyro/hid-sensor-gyro-3d.c | 7 +++---- drivers/iio/light/hid-sensor-als.c | 7 +++---- drivers/iio/light/hid-sensor-prox.c | 7 +++---- drivers/iio/magnetometer/hid-sensor-magn-3d.c | 7 +++---- drivers/iio/orientation/hid-sensor-incl-3d.c | 7 +++---- drivers/iio/orientation/hid-sensor-rotation.c | 8 +++----- drivers/iio/pressure/hid-sensor-press.c | 7 +++---- include/linux/hid-sensor-hub.h | 2 +- 11 files changed, 39 insertions(+), 38 deletions(-) diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c index ca50a91752d8..cf61c87a47e9 100644 --- a/drivers/iio/accel/hid-sensor-accel-3d.c +++ b/drivers/iio/accel/hid-sensor-accel-3d.c @@ -201,9 +201,8 @@ static int accel_3d_proc_event(struct hid_sensor_hub_device *hsdev, struct iio_dev *indio_dev = platform_get_drvdata(priv); struct accel_3d_state *accel_state = iio_priv(indio_dev); - dev_dbg(&indio_dev->dev, "accel_3d_proc_event [%d]\n", - accel_state->common_attributes.data_ready); - if (accel_state->common_attributes.data_ready) + dev_dbg(&indio_dev->dev, "accel_3d_proc_event\n"); + if (atomic_read(&accel_state->common_attributes.data_ready)) hid_sensor_push_data(indio_dev, accel_state->accel_val, sizeof(accel_state->accel_val)); @@ -342,7 +341,7 @@ static int hid_accel_3d_probe(struct platform_device *pdev) dev_err(&pdev->dev, "failed to initialize trigger buffer\n"); goto error_free_dev_mem; } - accel_state->common_attributes.data_ready = false; + atomic_set(&accel_state->common_attributes.data_ready, 0); ret = hid_sensor_setup_trigger(indio_dev, name, &accel_state->common_attributes); if (ret < 0) { diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c index dbefbdaf7cd1..73282cee0c81 100644 --- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c +++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c @@ -28,16 +28,17 @@ #include #include "hid-sensor-trigger.h" -static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig, - bool state) +int hid_sensor_power_state(struct hid_sensor_common *st, bool state) { - struct hid_sensor_common *st = iio_trigger_get_drvdata(trig); int state_val; int report_val; if (state) { if (sensor_hub_device_open(st->hsdev)) return -EIO; + + atomic_inc(&st->data_ready); + state_val = hid_sensor_get_usage_index(st->hsdev, st->power_state.report_id, st->power_state.index, @@ -47,6 +48,8 @@ static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig, st->report_state.index, HID_USAGE_SENSOR_PROP_REPORTING_STATE_ALL_EVENTS_ENUM); } else { + if (!atomic_dec_and_test(&st->data_ready)) + return 0; sensor_hub_device_close(st->hsdev); state_val = hid_sensor_get_usage_index(st->hsdev, st->power_state.report_id, @@ -57,7 +60,6 @@ static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig, st->report_state.index, HID_USAGE_SENSOR_PROP_REPORTING_STATE_NO_EVENTS_ENUM); } - st->data_ready = state; if (state_val >= 0) { state_val += st->power_state.logical_minimum; @@ -75,6 +77,13 @@ static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig, return 0; } +EXPORT_SYMBOL(hid_sensor_power_state); + +static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig, + bool state) +{ + return hid_sensor_power_state(iio_trigger_get_drvdata(trig), state); +} void hid_sensor_remove_trigger(struct hid_sensor_common *attrb) { diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.h b/drivers/iio/common/hid-sensors/hid-sensor-trigger.h index ca02f7811aa8..0f8e78c249d3 100644 --- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.h +++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.h @@ -22,5 +22,6 @@ int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name, struct hid_sensor_common *attrb); void hid_sensor_remove_trigger(struct hid_sensor_common *attrb); +int hid_sensor_power_state(struct hid_sensor_common *st, bool state); #endif diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c index 53ac06040fbe..392c30b8cd74 100644 --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c @@ -201,9 +201,8 @@ static int gyro_3d_proc_event(struct hid_sensor_hub_device *hsdev, struct iio_dev *indio_dev = platform_get_drvdata(priv); struct gyro_3d_state *gyro_state = iio_priv(indio_dev); - dev_dbg(&indio_dev->dev, "gyro_3d_proc_event [%d]\n", - gyro_state->common_attributes.data_ready); - if (gyro_state->common_attributes.data_ready) + dev_dbg(&indio_dev->dev, "gyro_3d_proc_event\n"); + if (atomic_read(&gyro_state->common_attributes.data_ready)) hid_sensor_push_data(indio_dev, gyro_state->gyro_val, sizeof(gyro_state->gyro_val)); @@ -339,7 +338,7 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) dev_err(&pdev->dev, "failed to initialize trigger buffer\n"); goto error_free_dev_mem; } - gyro_state->common_attributes.data_ready = false; + atomic_set(&gyro_state->common_attributes.data_ready, 0); ret = hid_sensor_setup_trigger(indio_dev, name, &gyro_state->common_attributes); if (ret < 0) { diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c index 39b50be9d456..e124b395f320 100644 --- a/drivers/iio/light/hid-sensor-als.c +++ b/drivers/iio/light/hid-sensor-als.c @@ -180,9 +180,8 @@ static int als_proc_event(struct hid_sensor_hub_device *hsdev, struct iio_dev *indio_dev = platform_get_drvdata(priv); struct als_state *als_state = iio_priv(indio_dev); - dev_dbg(&indio_dev->dev, "als_proc_event [%d]\n", - als_state->common_attributes.data_ready); - if (als_state->common_attributes.data_ready) + dev_dbg(&indio_dev->dev, "als_proc_event\n"); + if (atomic_read(&als_state->common_attributes.data_ready)) hid_sensor_push_data(indio_dev, &als_state->illum, sizeof(als_state->illum)); @@ -305,7 +304,7 @@ static int hid_als_probe(struct platform_device *pdev) dev_err(&pdev->dev, "failed to initialize trigger buffer\n"); goto error_free_dev_mem; } - als_state->common_attributes.data_ready = false; + atomic_set(&als_state->common_attributes.data_ready, 0); ret = hid_sensor_setup_trigger(indio_dev, name, &als_state->common_attributes); if (ret < 0) { diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c index 1894ab196f97..07e98ec8e9f1 100644 --- a/drivers/iio/light/hid-sensor-prox.c +++ b/drivers/iio/light/hid-sensor-prox.c @@ -176,9 +176,8 @@ static int prox_proc_event(struct hid_sensor_hub_device *hsdev, struct iio_dev *indio_dev = platform_get_drvdata(priv); struct prox_state *prox_state = iio_priv(indio_dev); - dev_dbg(&indio_dev->dev, "prox_proc_event [%d]\n", - prox_state->common_attributes.data_ready); - if (prox_state->common_attributes.data_ready) + dev_dbg(&indio_dev->dev, "prox_proc_event\n"); + if (atomic_read(&prox_state->common_attributes.data_ready)) hid_sensor_push_data(indio_dev, &prox_state->human_presence, sizeof(prox_state->human_presence)); @@ -297,7 +296,7 @@ static int hid_prox_probe(struct platform_device *pdev) dev_err(&pdev->dev, "failed to initialize trigger buffer\n"); goto error_free_dev_mem; } - prox_state->common_attributes.data_ready = false; + atomic_set(&prox_state->common_attributes.data_ready, 0); ret = hid_sensor_setup_trigger(indio_dev, name, &prox_state->common_attributes); if (ret) { diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c index 131ced0dcb1c..54eea6a17061 100644 --- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c +++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c @@ -202,9 +202,8 @@ static int magn_3d_proc_event(struct hid_sensor_hub_device *hsdev, struct iio_dev *indio_dev = platform_get_drvdata(priv); struct magn_3d_state *magn_state = iio_priv(indio_dev); - dev_dbg(&indio_dev->dev, "magn_3d_proc_event [%d]\n", - magn_state->common_attributes.data_ready); - if (magn_state->common_attributes.data_ready) + dev_dbg(&indio_dev->dev, "magn_3d_proc_event\n"); + if (atomic_read(&magn_state->common_attributes.data_ready)) hid_sensor_push_data(indio_dev, magn_state->magn_val, sizeof(magn_state->magn_val)); @@ -343,7 +342,7 @@ static int hid_magn_3d_probe(struct platform_device *pdev) dev_err(&pdev->dev, "failed to initialize trigger buffer\n"); goto error_free_dev_mem; } - magn_state->common_attributes.data_ready = false; + atomic_set(&magn_state->common_attributes.data_ready, 0); ret = hid_sensor_setup_trigger(indio_dev, name, &magn_state->common_attributes); if (ret < 0) { diff --git a/drivers/iio/orientation/hid-sensor-incl-3d.c b/drivers/iio/orientation/hid-sensor-incl-3d.c index f0c465cc192a..bf11678dd04e 100644 --- a/drivers/iio/orientation/hid-sensor-incl-3d.c +++ b/drivers/iio/orientation/hid-sensor-incl-3d.c @@ -200,9 +200,8 @@ static int incl_3d_proc_event(struct hid_sensor_hub_device *hsdev, struct iio_dev *indio_dev = platform_get_drvdata(priv); struct incl_3d_state *incl_state = iio_priv(indio_dev); - dev_dbg(&indio_dev->dev, "incl_3d_proc_event [%d]\n", - incl_state->common_attributes.data_ready); - if (incl_state->common_attributes.data_ready) + dev_dbg(&indio_dev->dev, "incl_3d_proc_event\n"); + if (atomic_read(&incl_state->common_attributes.data_ready)) hid_sensor_push_data(indio_dev, (u8 *)incl_state->incl_val, sizeof(incl_state->incl_val)); @@ -358,7 +357,7 @@ static int hid_incl_3d_probe(struct platform_device *pdev) dev_err(&pdev->dev, "failed to initialize trigger buffer\n"); goto error_free_dev_mem; } - incl_state->common_attributes.data_ready = false; + atomic_set(&incl_state->common_attributes.data_ready, 0); ret = hid_sensor_setup_trigger(indio_dev, name, &incl_state->common_attributes); if (ret) { diff --git a/drivers/iio/orientation/hid-sensor-rotation.c b/drivers/iio/orientation/hid-sensor-rotation.c index 51387bbc1ce1..dccf848e8b0f 100644 --- a/drivers/iio/orientation/hid-sensor-rotation.c +++ b/drivers/iio/orientation/hid-sensor-rotation.c @@ -145,10 +145,8 @@ static int dev_rot_proc_event(struct hid_sensor_hub_device *hsdev, struct iio_dev *indio_dev = platform_get_drvdata(priv); struct dev_rot_state *rot_state = iio_priv(indio_dev); - dev_dbg(&indio_dev->dev, "dev_rot_proc_event [%d]\n", - rot_state->common_attributes.data_ready); - - if (rot_state->common_attributes.data_ready) + dev_dbg(&indio_dev->dev, "dev_rot_proc_event\n"); + if (atomic_read(&rot_state->common_attributes.data_ready)) hid_sensor_push_data(indio_dev, (u8 *)rot_state->sampled_vals, sizeof(rot_state->sampled_vals)); @@ -272,7 +270,7 @@ static int hid_dev_rot_probe(struct platform_device *pdev) dev_err(&pdev->dev, "failed to initialize trigger buffer\n"); return ret; } - rot_state->common_attributes.data_ready = false; + atomic_set(&rot_state->common_attributes.data_ready, 0); ret = hid_sensor_setup_trigger(indio_dev, name, &rot_state->common_attributes); if (ret) { diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c index ff69da4443b8..39df50c45dab 100644 --- a/drivers/iio/pressure/hid-sensor-press.c +++ b/drivers/iio/pressure/hid-sensor-press.c @@ -180,9 +180,8 @@ static int press_proc_event(struct hid_sensor_hub_device *hsdev, struct iio_dev *indio_dev = platform_get_drvdata(priv); struct press_state *press_state = iio_priv(indio_dev); - dev_dbg(&indio_dev->dev, "press_proc_event [%d]\n", - press_state->common_attributes.data_ready); - if (press_state->common_attributes.data_ready) + dev_dbg(&indio_dev->dev, "press_proc_event\n"); + if (atomic_read(&press_state->common_attributes.data_ready)) hid_sensor_push_data(indio_dev, &press_state->press_data, sizeof(press_state->press_data)); @@ -307,7 +306,7 @@ static int hid_press_probe(struct platform_device *pdev) dev_err(&pdev->dev, "failed to initialize trigger buffer\n"); goto error_free_dev_mem; } - press_state->common_attributes.data_ready = false; + atomic_set(&press_state->common_attributes.data_ready, 0); ret = hid_sensor_setup_trigger(indio_dev, name, &press_state->common_attributes); if (ret) { diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h index 88d8d636a68f..51f7ccadf923 100644 --- a/include/linux/hid-sensor-hub.h +++ b/include/linux/hid-sensor-hub.h @@ -189,7 +189,7 @@ struct hid_sensor_common { struct hid_sensor_hub_device *hsdev; struct platform_device *pdev; unsigned usage_id; - bool data_ready; + atomic_t data_ready; struct iio_trigger *trigger; struct hid_sensor_hub_attribute_info poll; struct hid_sensor_hub_attribute_info report_state; -- cgit v1.2.3 From c639945323253e962be6a56063273db1dbefc116 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Sat, 19 Apr 2014 00:22:00 +0100 Subject: iio: hid-sensors: Accelerometer 3D: Raw read support Added support for raw reading of channel. If the sensor is powered off, it will turn on for reading value. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/accel/hid-sensor-accel-3d.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c index cf61c87a47e9..69abf9163df7 100644 --- a/drivers/iio/accel/hid-sensor-accel-3d.c +++ b/drivers/iio/accel/hid-sensor-accel-3d.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -60,6 +61,7 @@ static const struct iio_chan_spec accel_3d_channels[] = { .type = IIO_ACCEL, .modified = 1, .channel2 = IIO_MOD_X, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_SAMP_FREQ) | @@ -69,6 +71,7 @@ static const struct iio_chan_spec accel_3d_channels[] = { .type = IIO_ACCEL, .modified = 1, .channel2 = IIO_MOD_Y, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_SAMP_FREQ) | @@ -78,6 +81,7 @@ static const struct iio_chan_spec accel_3d_channels[] = { .type = IIO_ACCEL, .modified = 1, .channel2 = IIO_MOD_Z, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_SAMP_FREQ) | @@ -108,22 +112,33 @@ static int accel_3d_read_raw(struct iio_dev *indio_dev, u32 address; int ret; int ret_type; + s32 poll_value; *val = 0; *val2 = 0; switch (mask) { case 0: + poll_value = hid_sensor_read_poll_value( + &accel_state->common_attributes); + if (poll_value < 0) + return -EINVAL; + + hid_sensor_power_state(&accel_state->common_attributes, true); + msleep_interruptible(poll_value * 2); report_id = accel_state->accel[chan->scan_index].report_id; address = accel_3d_addresses[chan->scan_index]; if (report_id >= 0) *val = sensor_hub_input_attr_get_raw_value( - accel_state->common_attributes.hsdev, - HID_USAGE_SENSOR_ACCEL_3D, address, - report_id); + accel_state->common_attributes.hsdev, + HID_USAGE_SENSOR_ACCEL_3D, address, + report_id); else { *val = 0; + hid_sensor_power_state(&accel_state->common_attributes, + false); return -EINVAL; } + hid_sensor_power_state(&accel_state->common_attributes, false); ret_type = IIO_VAL_INT; break; case IIO_CHAN_INFO_SCALE: -- cgit v1.2.3 From 0964f706dc7feed8b676cba2dc28937a88e5c4f8 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Sat, 19 Apr 2014 00:22:00 +0100 Subject: iio: hid-sensors: Gyro 3D: Raw read support Added support for raw reading of channel. If the sensor is powered off, it will turn on for reading value. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/gyro/hid-sensor-gyro-3d.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c index 392c30b8cd74..40f4e4935d0d 100644 --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -60,6 +61,7 @@ static const struct iio_chan_spec gyro_3d_channels[] = { .type = IIO_ANGL_VEL, .modified = 1, .channel2 = IIO_MOD_X, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_SAMP_FREQ) | @@ -69,6 +71,7 @@ static const struct iio_chan_spec gyro_3d_channels[] = { .type = IIO_ANGL_VEL, .modified = 1, .channel2 = IIO_MOD_Y, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_SAMP_FREQ) | @@ -78,6 +81,7 @@ static const struct iio_chan_spec gyro_3d_channels[] = { .type = IIO_ANGL_VEL, .modified = 1, .channel2 = IIO_MOD_Z, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_SAMP_FREQ) | @@ -108,22 +112,33 @@ static int gyro_3d_read_raw(struct iio_dev *indio_dev, u32 address; int ret; int ret_type; + s32 poll_value; *val = 0; *val2 = 0; switch (mask) { case 0: + poll_value = hid_sensor_read_poll_value( + &gyro_state->common_attributes); + if (poll_value < 0) + return -EINVAL; + + hid_sensor_power_state(&gyro_state->common_attributes, true); + msleep_interruptible(poll_value * 2); report_id = gyro_state->gyro[chan->scan_index].report_id; address = gyro_3d_addresses[chan->scan_index]; if (report_id >= 0) *val = sensor_hub_input_attr_get_raw_value( - gyro_state->common_attributes.hsdev, - HID_USAGE_SENSOR_GYRO_3D, address, - report_id); + gyro_state->common_attributes.hsdev, + HID_USAGE_SENSOR_GYRO_3D, address, + report_id); else { *val = 0; + hid_sensor_power_state(&gyro_state->common_attributes, + false); return -EINVAL; } + hid_sensor_power_state(&gyro_state->common_attributes, false); ret_type = IIO_VAL_INT; break; case IIO_CHAN_INFO_SCALE: -- cgit v1.2.3 From 371a12339a210561ca43f1ebcbc01fbdbcab9435 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Sat, 19 Apr 2014 00:22:00 +0100 Subject: iio: hid-sensors: ALS: Raw read support Added support for raw reading of channel. If the sensor is powered off, it will turn on for reading value. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/light/hid-sensor-als.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c index e124b395f320..f34c94380b41 100644 --- a/drivers/iio/light/hid-sensor-als.c +++ b/drivers/iio/light/hid-sensor-als.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -49,6 +50,7 @@ static const struct iio_chan_spec als_channels[] = { .type = IIO_INTENSITY, .modified = 1, .channel2 = IIO_MOD_LIGHT_BOTH, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_SAMP_FREQ) | @@ -79,6 +81,7 @@ static int als_read_raw(struct iio_dev *indio_dev, u32 address; int ret; int ret_type; + s32 poll_value; *val = 0; *val2 = 0; @@ -94,12 +97,23 @@ static int als_read_raw(struct iio_dev *indio_dev, report_id = -1; break; } - if (report_id >= 0) + if (report_id >= 0) { + poll_value = hid_sensor_read_poll_value( + &als_state->common_attributes); + if (poll_value < 0) + return -EINVAL; + + hid_sensor_power_state(&als_state->common_attributes, + true); + msleep_interruptible(poll_value * 2); + *val = sensor_hub_input_attr_get_raw_value( - als_state->common_attributes.hsdev, - HID_USAGE_SENSOR_ALS, address, - report_id); - else { + als_state->common_attributes.hsdev, + HID_USAGE_SENSOR_ALS, address, + report_id); + hid_sensor_power_state(&als_state->common_attributes, + false); + } else { *val = 0; return -EINVAL; } -- cgit v1.2.3 From 1eef062042751822e9f9de418b0f712c6f9b93e8 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Sat, 19 Apr 2014 00:22:00 +0100 Subject: iio: hid-sensors: Proximity: Raw read support Added support for raw reading of channel. If the sensor is powered off, it will turn on for reading value. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/light/hid-sensor-prox.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c index 07e98ec8e9f1..d203ef4d892f 100644 --- a/drivers/iio/light/hid-sensor-prox.c +++ b/drivers/iio/light/hid-sensor-prox.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -75,6 +76,7 @@ static int prox_read_raw(struct iio_dev *indio_dev, u32 address; int ret; int ret_type; + s32 poll_value; *val = 0; *val2 = 0; @@ -90,12 +92,24 @@ static int prox_read_raw(struct iio_dev *indio_dev, report_id = -1; break; } - if (report_id >= 0) + if (report_id >= 0) { + poll_value = hid_sensor_read_poll_value( + &prox_state->common_attributes); + if (poll_value < 0) + return -EINVAL; + + hid_sensor_power_state(&prox_state->common_attributes, + true); + + msleep_interruptible(poll_value * 2); + *val = sensor_hub_input_attr_get_raw_value( prox_state->common_attributes.hsdev, HID_USAGE_SENSOR_PROX, address, report_id); - else { + hid_sensor_power_state(&prox_state->common_attributes, + false); + } else { *val = 0; return -EINVAL; } -- cgit v1.2.3 From 8009c594a5b523444a18cfb65211d38a5e459a8a Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Sat, 19 Apr 2014 00:22:00 +0100 Subject: iio: hid-sensors: Compass 3D: Raw read support Added support for raw reading of channel. If the sensor is powered off, it will turn on for reading value Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/hid-sensor-magn-3d.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c index 54eea6a17061..41cf29e2a371 100644 --- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c +++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -60,6 +61,7 @@ static const struct iio_chan_spec magn_3d_channels[] = { .type = IIO_MAGN, .modified = 1, .channel2 = IIO_MOD_X, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_SAMP_FREQ) | @@ -69,6 +71,7 @@ static const struct iio_chan_spec magn_3d_channels[] = { .type = IIO_MAGN, .modified = 1, .channel2 = IIO_MOD_Y, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_SAMP_FREQ) | @@ -78,6 +81,7 @@ static const struct iio_chan_spec magn_3d_channels[] = { .type = IIO_MAGN, .modified = 1, .channel2 = IIO_MOD_Z, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_SAMP_FREQ) | @@ -108,11 +112,20 @@ static int magn_3d_read_raw(struct iio_dev *indio_dev, u32 address; int ret; int ret_type; + s32 poll_value; *val = 0; *val2 = 0; switch (mask) { case 0: + poll_value = hid_sensor_read_poll_value( + &magn_state->common_attributes); + if (poll_value < 0) + return -EINVAL; + + hid_sensor_power_state(&magn_state->common_attributes, true); + msleep_interruptible(poll_value * 2); + report_id = magn_state->magn[chan->scan_index].report_id; address = magn_3d_addresses[chan->scan_index]; @@ -123,8 +136,11 @@ static int magn_3d_read_raw(struct iio_dev *indio_dev, report_id); else { *val = 0; + hid_sensor_power_state(&magn_state->common_attributes, + false); return -EINVAL; } + hid_sensor_power_state(&magn_state->common_attributes, false); ret_type = IIO_VAL_INT; break; case IIO_CHAN_INFO_SCALE: -- cgit v1.2.3 From 6fe588e59935f3cb3a1e1cd3d49fa756f28cb2b3 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Sat, 19 Apr 2014 00:22:00 +0100 Subject: iio: hid-sensors: Inclinometer 3D: Raw read support Added support for raw reading of channel. If the sensor is powered off, it will turn on for reading value. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/orientation/hid-sensor-incl-3d.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/iio/orientation/hid-sensor-incl-3d.c b/drivers/iio/orientation/hid-sensor-incl-3d.c index bf11678dd04e..2478f6c2ef25 100644 --- a/drivers/iio/orientation/hid-sensor-incl-3d.c +++ b/drivers/iio/orientation/hid-sensor-incl-3d.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -110,11 +111,20 @@ static int incl_3d_read_raw(struct iio_dev *indio_dev, int report_id = -1; u32 address; int ret_type; + s32 poll_value; *val = 0; *val2 = 0; switch (mask) { case IIO_CHAN_INFO_RAW: + poll_value = hid_sensor_read_poll_value( + &incl_state->common_attributes); + if (poll_value < 0) + return -EINVAL; + + hid_sensor_power_state(&incl_state->common_attributes, true); + msleep_interruptible(poll_value * 2); + report_id = incl_state->incl[chan->scan_index].report_id; address = incl_3d_addresses[chan->scan_index]; @@ -124,8 +134,11 @@ static int incl_3d_read_raw(struct iio_dev *indio_dev, HID_USAGE_SENSOR_INCLINOMETER_3D, address, report_id); else { + hid_sensor_power_state(&incl_state->common_attributes, + false); return -EINVAL; } + hid_sensor_power_state(&incl_state->common_attributes, false); ret_type = IIO_VAL_INT; break; case IIO_CHAN_INFO_SCALE: -- cgit v1.2.3 From cd5b700f998d9e1d8e6dbc62aeb0351bb2216e22 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Sat, 19 Apr 2014 00:22:00 +0100 Subject: iio: hid-sensors: Pressure: Raw read support Added support for raw reading of channel. If the sensor is powered off, it will turn on for reading value. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/hid-sensor-press.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c index 39df50c45dab..1cd190c73788 100644 --- a/drivers/iio/pressure/hid-sensor-press.c +++ b/drivers/iio/pressure/hid-sensor-press.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -79,6 +80,7 @@ static int press_read_raw(struct iio_dev *indio_dev, u32 address; int ret; int ret_type; + s32 poll_value; *val = 0; *val2 = 0; @@ -94,12 +96,23 @@ static int press_read_raw(struct iio_dev *indio_dev, report_id = -1; break; } - if (report_id >= 0) + if (report_id >= 0) { + poll_value = hid_sensor_read_poll_value( + &press_state->common_attributes); + if (poll_value < 0) + return -EINVAL; + hid_sensor_power_state(&press_state->common_attributes, + true); + + msleep_interruptible(poll_value * 2); + *val = sensor_hub_input_attr_get_raw_value( press_state->common_attributes.hsdev, HID_USAGE_SENSOR_PRESSURE, address, report_id); - else { + hid_sensor_power_state(&press_state->common_attributes, + false); + } else { *val = 0; return -EINVAL; } -- cgit v1.2.3 From bf7f5204abdba94032ff7cae1c9c8c9e7671d246 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 5 Sep 2014 12:56:00 +0100 Subject: iio: hid-sensors: typo leads to potential forever loop The "i < " was missing in this condition. Fixes: 5d02edfc3957 ('iio: hid-sensors: Convert units and exponent') Signed-off-by: Dan Carpenter Signed-off-by: Jonathan Cameron --- drivers/iio/common/hid-sensors/hid-sensor-attributes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c index 372964635ccf..3052eb150099 100644 --- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c +++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c @@ -327,7 +327,7 @@ int hid_sensor_format_scale(u32 usage_id, *val0 = 1; *val1 = 0; - for (i = 0; ARRAY_SIZE(unit_conversion); ++i) { + for (i = 0; i < ARRAY_SIZE(unit_conversion); ++i) { if (unit_conversion[i].usage_id == usage_id && unit_conversion[i].unit == attr_info->units) { exp = hid_sensor_convert_exponent( -- cgit v1.2.3 From cc8b49fa26f57cc0096e702d3e7c3f7c3e263300 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 5 Aug 2014 15:56:00 +0100 Subject: iio: always select ANON_INODES Without ANON_INODES, we get this build error: drivers/built-in.o: In function `iio_event_getfd': :(.text+0x14bf18): undefined reference to `anon_inode_getfd' All other users explicitly select this symbol, so we should do the same thing here. Signed-off-by: Arnd Bergmann Cc: Jonathan Cameron Cc: linux-iio@vger.kernel.org Signed-off-by: Jonathan Cameron --- drivers/iio/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/Kconfig b/drivers/iio/Kconfig index 743485e4d6f8..345395e9dc6e 100644 --- a/drivers/iio/Kconfig +++ b/drivers/iio/Kconfig @@ -4,6 +4,7 @@ menuconfig IIO tristate "Industrial I/O support" + select ANON_INODES help The industrial I/O subsystem provides a unified framework for drivers for many different types of embedded sensors using a -- cgit v1.2.3 From 758ee467d37b6de6b3ca412d0cc90d2b9966b1af Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Wed, 9 Apr 2014 17:18:10 +0200 Subject: iio:adc: at91 requires the input subsystem Building the at91 adc driver with CONFIG_INPUT disabled results in this build error: ERROR: "input_event" [drivers/iio/adc/at91_adc.ko] undefined! ERROR: "input_unregister_device" [drivers/iio/adc/at91_adc.ko] undefined! ERROR: "input_free_device" [drivers/iio/adc/at91_adc.ko] undefined! ERROR: "input_register_device" [drivers/iio/adc/at91_adc.ko] undefined! ERROR: "input_set_abs_params" [drivers/iio/adc/at91_adc.ko] undefined! ERROR: "input_allocate_device" [drivers/iio/adc/at91_adc.ko] undefined! To make sure we can build random configurations, this adds a Kconfig dependency on CONFIG_INPUT, as we do for other similar drivers. Signed-off-by: Arnd Bergmann Cc: linux-iio@vger.kernel.org Cc: Josh Wu Cc: Maxime Ripard Acked-by: Nicolas Ferre Signed-off-by: Jonathan Cameron --- drivers/iio/adc/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 6cbf34a90c04..ee9d85e22c48 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -110,6 +110,7 @@ config AD799X config AT91_ADC tristate "Atmel AT91 ADC" depends on ARCH_AT91 + depends on INPUT select IIO_BUFFER select IIO_TRIGGERED_BUFFER select SYSFS -- cgit v1.2.3 From 3e729974d67608be773167677478781bc874d369 Mon Sep 17 00:00:00 2001 From: Archana Patni Date: Tue, 5 Aug 2014 14:36:00 +0100 Subject: iio: hid-sensors: Set default unit of measure for report interval For PROP_REPORT_INTERVAL, the spec does not mandate the presence of the report interval unit in the feature report and expects the default unit of measure to be used as milliseconds. Currently, when the unit is not present, it gets set as zero leading to issues in sampling frequency. This patch sets the unit of measure to the default unit if it is not defined by firmware. Signed-off-by: Archana Patni Signed-off-by: Subramony Sesha Reviewed-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/common/hid-sensors/hid-sensor-attributes.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c index 3052eb150099..403dd3d8986e 100644 --- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c +++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c @@ -343,15 +343,28 @@ int hid_sensor_format_scale(u32 usage_id, } EXPORT_SYMBOL(hid_sensor_format_scale); -int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev, +int hid_sensor_get_reporting_interval(struct hid_sensor_hub_device *hsdev, u32 usage_id, struct hid_sensor_common *st) { - sensor_hub_input_get_attribute_info(hsdev, HID_FEATURE_REPORT, usage_id, HID_USAGE_SENSOR_PROP_REPORT_INTERVAL, &st->poll); + /* Default unit of measure is milliseconds */ + if (st->poll.units == 0) + st->poll.units = HID_USAGE_SENSOR_UNITS_MILLISECOND; + return 0; + +} + +int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev, + u32 usage_id, + struct hid_sensor_common *st) +{ + + + hid_sensor_get_reporting_interval(hsdev, usage_id, st); sensor_hub_input_get_attribute_info(hsdev, HID_FEATURE_REPORT, usage_id, -- cgit v1.2.3 From b34a643e9baa21b377357b6ab572d2a0e03cf0e4 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:08 +0200 Subject: staging: rtl8723au: rtw_ieee80211.c mark a couple of function static Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 10 +++++----- drivers/staging/rtl8723au/include/ieee80211.h | 4 ---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index b56055eb433b..bffca4fe3b9c 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -76,7 +76,7 @@ int rtw_get_bit_value_from_ieee_value23a(u8 val) return 0; } -uint rtw_is_cckrates_included23a(u8 *rate) +static bool rtw_is_cckrates_included(u8 *rate) { u32 i = 0; @@ -90,7 +90,7 @@ uint rtw_is_cckrates_included23a(u8 *rate) return false; } -uint rtw_is_cckratesonly_included23a(u8 *rate) +static bool rtw_is_cckratesonly_included(u8 *rate) { u32 i = 0; @@ -108,14 +108,14 @@ uint rtw_is_cckratesonly_included23a(u8 *rate) int rtw_check_network_type23a(unsigned char *rate, int ratelen, int channel) { if (channel > 14) { - if ((rtw_is_cckrates_included23a(rate)) == true) + if (rtw_is_cckrates_included(rate)) return WIRELESS_INVALID; else return WIRELESS_11A; } else { /* could be pure B, pure G, or B/G */ - if ((rtw_is_cckratesonly_included23a(rate)) == true) + if (rtw_is_cckratesonly_included(rate)) return WIRELESS_11B; - else if ((rtw_is_cckrates_included23a(rate)) == true) + else if (rtw_is_cckrates_included(rate)) return WIRELESS_11BG; else return WIRELESS_11G; diff --git a/drivers/staging/rtl8723au/include/ieee80211.h b/drivers/staging/rtl8723au/include/ieee80211.h index 76875f651d82..4a4b08682925 100644 --- a/drivers/staging/rtl8723au/include/ieee80211.h +++ b/drivers/staging/rtl8723au/include/ieee80211.h @@ -447,10 +447,6 @@ int rtw_generate_ie23a(struct registry_priv *pregistrypriv); int rtw_get_bit_value_from_ieee_value23a(u8 val); -uint rtw_is_cckrates_included23a(u8 *rate); - -uint rtw_is_cckratesonly_included23a(u8 *rate); - int rtw_check_network_type23a(unsigned char *rate, int ratelen, int channel); void rtw_get_bcn_info23a(struct wlan_network *pnetwork); -- cgit v1.2.3 From ea0c927d01b1d9e21d478d2d2ff0f39f8f606c00 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:09 +0200 Subject: staging: rtl8723au: rtw_ieee80211.c: Reduce some excessive parenthesis usage Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 65 +++++++++++++------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index bffca4fe3b9c..bd35e8f320d0 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -46,21 +46,23 @@ u8 RSN_CIPHER_SUITE_WEP10423A[] = { 0x00, 0x0f, 0xac, 5 }; /* for adhoc-master to generate ie and provide supported-rate to fw */ /* */ -static u8 WIFI_CCKRATES[] = -{(IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK), - (IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK), - (IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK), - (IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK)}; - -static u8 WIFI_OFDMRATES[] = -{(IEEE80211_OFDM_RATE_6MB), - (IEEE80211_OFDM_RATE_9MB), - (IEEE80211_OFDM_RATE_12MB), - (IEEE80211_OFDM_RATE_18MB), - (IEEE80211_OFDM_RATE_24MB), - IEEE80211_OFDM_RATE_36MB, - IEEE80211_OFDM_RATE_48MB, - IEEE80211_OFDM_RATE_54MB}; +static u8 WIFI_CCKRATES[] = { + IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK +}; + +static u8 WIFI_OFDMRATES[] = { + IEEE80211_OFDM_RATE_6MB, + IEEE80211_OFDM_RATE_9MB, + IEEE80211_OFDM_RATE_12MB, + IEEE80211_OFDM_RATE_18MB, + IEEE80211_OFDM_RATE_24MB, + IEEE80211_OFDM_RATE_36MB, + IEEE80211_OFDM_RATE_48MB, + IEEE80211_OFDM_RATE_54MB +}; int rtw_get_bit_value_from_ieee_value23a(u8 val) { @@ -80,9 +82,9 @@ static bool rtw_is_cckrates_included(u8 *rate) { u32 i = 0; - while (rate[i] != 0) { - if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) || - (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22)) + while (rate[i]) { + if ((rate[i] & 0x7f) == 2 || (rate[i] & 0x7f) == 4 || + (rate[i] & 0x7f) == 11 || (rate[i] & 0x7f) == 22) return true; i++; } @@ -94,9 +96,9 @@ static bool rtw_is_cckratesonly_included(u8 *rate) { u32 i = 0; - while (rate[i] != 0) { - if ((((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) && - (((rate[i]) & 0x7f) != 11) && (((rate[i]) & 0x7f) != 22)) + while (rate[i]) { + if ((rate[i] & 0x7f) != 2 && (rate[i] & 0x7f) != 4 && + (rate[i] & 0x7f) != 11 && (rate[i] & 0x7f) != 22) return false; i++; @@ -143,7 +145,6 @@ u8 *rtw_set_ie23a(u8 *pbuf, int index, uint len, const u8 *source, uint *frlen) *frlen = *frlen + (len + 2); - return pbuf + len + 2; } @@ -367,7 +368,7 @@ uint rtw_get_rateset_len23a(u8 *rateset) uint i = 0; while(1) { - if ((rateset[i]) == 0) + if (rateset[i] == 0) break; if (i > 12) @@ -581,7 +582,7 @@ int rtw_parse_wpa2_ie23a(const u8* rsn_ie, int rsn_ie_len, int *group_cipher, return _FAIL; } - if ((*rsn_ie!= _WPA2_IE_ID_) || (*(rsn_ie+1) != (u8)(rsn_ie_len - 2))) { + if (*rsn_ie != _WPA2_IE_ID_ || *(rsn_ie+1) != (u8)(rsn_ie_len - 2)) { return _FAIL; } @@ -730,7 +731,7 @@ u8 rtw_is_wps_ie23a(u8 *ie_ptr, uint *wps_ielen) eid = ie_ptr[0]; - if ((eid == WLAN_EID_VENDOR_SPECIFIC) && + if (eid == WLAN_EID_VENDOR_SPECIFIC && !memcmp(&ie_ptr[2], wps_oui, 4)) { /* DBG_8723A("==> found WPS_IE.....\n"); */ *wps_ielen = ie_ptr[1] + 2; @@ -767,7 +768,7 @@ u8 *rtw_get_wps_ie23a(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen) while (cnt < in_len) { eid = in_ie[cnt]; - if ((eid == WLAN_EID_VENDOR_SPECIFIC) && + if (eid == WLAN_EID_VENDOR_SPECIFIC && !memcmp(&in_ie[cnt+2], wps_oui, 4)) { wpsie_ptr = &in_ie[cnt]; @@ -810,7 +811,7 @@ u8 *rtw_get_wps_attr23a(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, if (len_attr) *len_attr = 0; - if ((wps_ie[0] != WLAN_EID_VENDOR_SPECIFIC) || + if (wps_ie[0] != WLAN_EID_VENDOR_SPECIFIC || memcmp(wps_ie + 2, wps_oui, 4)) { return attr_ptr; } @@ -883,11 +884,11 @@ u8 *rtw_get_wps_attr_content23a(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, static u8 key_char2num(u8 ch) { - if ((ch >= '0') && (ch <= '9')) + if (ch >= '0' && ch <= '9') return ch - '0'; - else if ((ch >= 'a') && (ch <= 'f')) + else if (ch >= 'a' && ch <= 'f') return ch - 'a' + 10; - else if ((ch >= 'A') && (ch <= 'F')) + else if (ch >= 'A' && ch <= 'F') return ch - 'A' + 10; else return 0xff; @@ -895,12 +896,12 @@ static u8 key_char2num(u8 ch) u8 str_2char2num23a(u8 hch, u8 lch) { - return (key_char2num(hch) * 10) + key_char2num(lch); + return key_char2num(hch) * 10 + key_char2num(lch); } u8 key_2char2num23a(u8 hch, u8 lch) { - return (key_char2num(hch) << 4) | key_char2num(lch); + return key_char2num(hch) << 4 | key_char2num(lch); } void rtw_macaddr_cfg23a(u8 *mac_addr) -- cgit v1.2.3 From c347dc6207f81dfbb95f426c783cb95899f710ab Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:10 +0200 Subject: staging: rtl8723au: pass the cmd parm buffer directly to the cmd handler commit 0348dc74f6689825c16db40fbe0ce6ad2da5bab9 ensured that the parm buffer passed to the cmd handlers is not being over-written. Hence there is no need to make a copy of the parm buffer just to pass it into the cmd handler. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 22 ++-------------------- drivers/staging/rtl8723au/include/rtw_cmd.h | 2 -- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 5b3ac6901147..d139a32a405a 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -175,18 +175,6 @@ int rtw_init_cmd_priv23a(struct cmd_priv *pcmdpriv) { int res = _SUCCESS; - pcmdpriv->cmd_allocated_buf = kzalloc(MAX_CMDSZ + CMDBUFF_ALIGN_SZ, - GFP_KERNEL); - - if (pcmdpriv->cmd_allocated_buf == NULL) { - res = _FAIL; - goto exit; - } - - pcmdpriv->cmd_buf = pcmdpriv->cmd_allocated_buf + CMDBUFF_ALIGN_SZ - - ((unsigned long)(pcmdpriv->cmd_allocated_buf) & - (CMDBUFF_ALIGN_SZ - 1)); - pcmdpriv->rsp_allocated_buf = kzalloc(MAX_RSPSZ + 4, GFP_KERNEL); if (!pcmdpriv->rsp_allocated_buf) { @@ -248,10 +236,8 @@ void rtw_free_cmd_priv23a(struct cmd_priv *pcmdpriv) RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("rtw_free_cmd_priv23a\n")); - if (pcmdpriv) { - kfree(pcmdpriv->cmd_allocated_buf); + if (pcmdpriv) kfree(pcmdpriv->rsp_allocated_buf); - } } static int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) @@ -341,10 +327,8 @@ static void rtw_cmd_work(struct work_struct *work) void (*pcmd_callback)(struct rtw_adapter *dev, struct cmd_obj *pcmd); struct cmd_priv *pcmdpriv; struct cmd_obj *pcmd = container_of(work, struct cmd_obj, work); - u8 *pcmdbuf; pcmdpriv = &pcmd->padapter->cmdpriv; - pcmdbuf = pcmdpriv->cmd_buf; if (rtw_cmd_filter(pcmdpriv, pcmd) == _FAIL) { pcmd->res = H2C_DROPPED; @@ -355,13 +339,11 @@ static void rtw_cmd_work(struct work_struct *work) pcmd->cmdsz = ALIGN(pcmd->cmdsz, 4); - memcpy(pcmdbuf, pcmd->parmbuf, pcmd->cmdsz); - if (pcmd->cmdcode < (sizeof(wlancmds)/sizeof(struct cmd_hdl))) { cmd_hdl = wlancmds[pcmd->cmdcode].h2cfuns; if (cmd_hdl) - pcmd->res = cmd_hdl(pcmd->padapter, pcmdbuf); + pcmd->res = cmd_hdl(pcmd->padapter, pcmd->parmbuf); else pcmd->res = H2C_DROPPED; } else diff --git a/drivers/staging/rtl8723au/include/rtw_cmd.h b/drivers/staging/rtl8723au/include/rtw_cmd.h index 3ecb971c6e39..3e0698022184 100644 --- a/drivers/staging/rtl8723au/include/rtw_cmd.h +++ b/drivers/staging/rtl8723au/include/rtw_cmd.h @@ -44,8 +44,6 @@ struct cmd_obj { struct cmd_priv { struct workqueue_struct *wq; - u8 *cmd_buf; /* shall be non-paged, and 4 bytes aligned */ - u8 *cmd_allocated_buf; u8 *rsp_buf; /* shall be non-paged, and 4 bytes aligned */ u8 *rsp_allocated_buf; u32 cmd_issued_cnt; -- cgit v1.2.3 From fac7563a32d123a8386a8e921226af113898fb5e Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:11 +0200 Subject: staging: rtl8723au: rsp_buf wasn't used for anything - don't allocate it Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 19 ------------------- drivers/staging/rtl8723au/core/rtw_mlme.c | 2 -- drivers/staging/rtl8723au/include/rtw_cmd.h | 2 -- 3 files changed, 23 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index d139a32a405a..ec4533d155d3 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -175,27 +175,14 @@ int rtw_init_cmd_priv23a(struct cmd_priv *pcmdpriv) { int res = _SUCCESS; - pcmdpriv->rsp_allocated_buf = kzalloc(MAX_RSPSZ + 4, GFP_KERNEL); - - if (!pcmdpriv->rsp_allocated_buf) { - res = _FAIL; - goto exit; - } - - pcmdpriv->rsp_buf = pcmdpriv->rsp_allocated_buf + 4 - - ((unsigned long)(pcmdpriv->rsp_allocated_buf) & 3); - pcmdpriv->cmd_issued_cnt = 0; pcmdpriv->cmd_done_cnt = 0; pcmdpriv->rsp_cnt = 0; - pcmdpriv->wq = alloc_workqueue("rtl8723au", 0, 1); if (!pcmdpriv->wq) res = _FAIL; -exit: - return res; } @@ -205,7 +192,6 @@ static void c2h_wk_callback(struct work_struct *work); u32 rtw_init_evt_priv23a(struct evt_priv *pevtpriv) { - /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */ atomic_set(&pevtpriv->event_seq, 0); pevtpriv->evt_done_cnt = 0; @@ -235,9 +221,6 @@ void rtw_free_cmd_priv23a(struct cmd_priv *pcmdpriv) { RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("rtw_free_cmd_priv23a\n")); - - if (pcmdpriv) - kfree(pcmdpriv->rsp_allocated_buf); } static int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) @@ -361,8 +344,6 @@ post_process: pcmd_callback, pcmd->cmdcode)); rtw_free_cmd_obj23a(pcmd); } else { - /* todo: !!! fill rsp_buf to pcmd->rsp - if (pcmd->rsp!= NULL) */ /* need conider that free cmd_obj in rtw_cmd_callback */ pcmd_callback(pcmd->padapter, pcmd); diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 8d64cb02ee8e..d39f879790bb 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -64,8 +64,6 @@ int rtw_init_mlme_priv23a(struct rtw_adapter *padapter) memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct cfg80211_ssid)); - /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */ - rtw_clear_scan_deny(padapter); rtw_init_mlme_timer(padapter); diff --git a/drivers/staging/rtl8723au/include/rtw_cmd.h b/drivers/staging/rtl8723au/include/rtw_cmd.h index 3e0698022184..7c6858436e67 100644 --- a/drivers/staging/rtl8723au/include/rtw_cmd.h +++ b/drivers/staging/rtl8723au/include/rtw_cmd.h @@ -44,8 +44,6 @@ struct cmd_obj { struct cmd_priv { struct workqueue_struct *wq; - u8 *rsp_buf; /* shall be non-paged, and 4 bytes aligned */ - u8 *rsp_allocated_buf; u32 cmd_issued_cnt; u32 cmd_done_cnt; u32 rsp_cnt; -- cgit v1.2.3 From c3826753d39a5832905ed478fd6aa9ec0702e5c4 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:12 +0200 Subject: staging: rtl8723au: Remove rtw_free_cmd_priv23a() This function no longer does anything, so get rid of it. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 6 ------ drivers/staging/rtl8723au/include/rtw_cmd.h | 1 - drivers/staging/rtl8723au/os_dep/os_intfs.c | 2 -- 3 files changed, 9 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index ec4533d155d3..fb6d4b662ecc 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -217,12 +217,6 @@ void rtw_free_evt_priv23a(struct evt_priv *pevtpriv) } } -void rtw_free_cmd_priv23a(struct cmd_priv *pcmdpriv) -{ - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, - ("rtw_free_cmd_priv23a\n")); -} - static int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) { struct drvextra_cmd_parm *pdrvextra_cmd_parm; diff --git a/drivers/staging/rtl8723au/include/rtw_cmd.h b/drivers/staging/rtl8723au/include/rtw_cmd.h index 7c6858436e67..5c3b46b8e807 100644 --- a/drivers/staging/rtl8723au/include/rtw_cmd.h +++ b/drivers/staging/rtl8723au/include/rtw_cmd.h @@ -87,7 +87,6 @@ void rtw_free_cmd_obj23a(struct cmd_obj *pcmd); int rtw_cmd_thread23a(void *context); int rtw_init_cmd_priv23a(struct cmd_priv *pcmdpriv); -void rtw_free_cmd_priv23a (struct cmd_priv *pcmdpriv); u32 rtw_init_evt_priv23a (struct evt_priv *pevtpriv); void rtw_free_evt_priv23a (struct evt_priv *pevtpriv); diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index 7c4c0a54b238..f21128cd9ccf 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -570,8 +570,6 @@ u8 rtw_free_drv_sw23a(struct rtw_adapter *padapter) free_mlme_ext_priv23a(&padapter->mlmeextpriv); - rtw_free_cmd_priv23a(&padapter->cmdpriv); - rtw_free_evt_priv23a(&padapter->evtpriv); rtw_free_mlme_priv23a(&padapter->mlmepriv); -- cgit v1.2.3 From 8df06a3b80b344b6ce5291fb2ce5e346e317d230 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:13 +0200 Subject: staging: rtl8723au: Name cmd workqueue appropriately to allow for more workqueues Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index fb6d4b662ecc..81a35dd2416e 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -179,7 +179,7 @@ int rtw_init_cmd_priv23a(struct cmd_priv *pcmdpriv) pcmdpriv->cmd_done_cnt = 0; pcmdpriv->rsp_cnt = 0; - pcmdpriv->wq = alloc_workqueue("rtl8723au", 0, 1); + pcmdpriv->wq = alloc_workqueue("rtl8723au_cmd", 0, 1); if (!pcmdpriv->wq) res = _FAIL; -- cgit v1.2.3 From 980cf72afb0f6eac84d3ea63978db0993b76a3ec Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:14 +0200 Subject: staging: rtl8723au: Use workqueue to handle interrupt complete processing Split the old work handler into a workqueue for processing usb_read_interrupt_complete() events that require more than ust clearing the event, and leave the old handler to just handle event clearing. This means we can get rid of the hacks with magic pointers to determine what actions needs to be taken in the work handler, and as an extra bonus obsoletes the bizarre cbuf code. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 87 +++++++++++---------------- drivers/staging/rtl8723au/hal/usb_ops_linux.c | 51 +++++++++------- drivers/staging/rtl8723au/include/rtw_cmd.h | 21 ++++++- 3 files changed, 82 insertions(+), 77 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 81a35dd2416e..c39adc1974f9 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -188,33 +188,23 @@ int rtw_init_cmd_priv23a(struct cmd_priv *pcmdpriv) /* forward definition */ -static void c2h_wk_callback(struct work_struct *work); +static void rtw_irq_work(struct work_struct *work); u32 rtw_init_evt_priv23a(struct evt_priv *pevtpriv) { atomic_set(&pevtpriv->event_seq, 0); pevtpriv->evt_done_cnt = 0; - INIT_WORK(&pevtpriv->c2h_wk, c2h_wk_callback); - pevtpriv->c2h_wk_alive = false; - pevtpriv->c2h_queue = rtw_cbuf_alloc23a(C2H_QUEUE_MAX_LEN + 1); + pevtpriv->wq = alloc_workqueue("rtl8723au_evt", 0, 1); + + INIT_WORK(&pevtpriv->irq_wk, rtw_irq_work); return _SUCCESS; } void rtw_free_evt_priv23a(struct evt_priv *pevtpriv) { - cancel_work_sync(&pevtpriv->c2h_wk); - while (pevtpriv->c2h_wk_alive) - msleep(10); - - while (!rtw_cbuf_empty23a(pevtpriv->c2h_queue)) { - void *c2h; - if ((c2h = rtw_cbuf_pop23a(pevtpriv->c2h_queue)) != NULL && - c2h != (void *)pevtpriv) { - kfree(c2h); - } - } + cancel_work_sync(&pevtpriv->irq_wk); } static int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) @@ -1348,54 +1338,47 @@ exit: return ret; } -static void c2h_wk_callback(struct work_struct *work) +static void rtw_irq_work(struct work_struct *work) { struct evt_priv *evtpriv; struct rtw_adapter *adapter; - struct c2h_evt_hdr *c2h_evt; - c2h_id_filter ccx_id_filter; - evtpriv = container_of(work, struct evt_priv, c2h_wk); + evtpriv = container_of(work, struct evt_priv, irq_wk); adapter = container_of(evtpriv, struct rtw_adapter, evtpriv); - ccx_id_filter = rtw_hal_c2h_id_filter_ccx23a(adapter); - evtpriv->c2h_wk_alive = true; - - while (!rtw_cbuf_empty23a(evtpriv->c2h_queue)) { - c2h_evt = (struct c2h_evt_hdr *) - rtw_cbuf_pop23a(evtpriv->c2h_queue); - if (c2h_evt) { - /* This C2H event is read, clear it */ - c2h_evt_clear23a(adapter); - } else if ((c2h_evt = (struct c2h_evt_hdr *) - kmalloc(16, GFP_KERNEL))) { - if (!c2h_evt) - continue; - /* This C2H event is not read, read & clear now */ - if (c2h_evt_read23a(adapter, (u8*)c2h_evt) != _SUCCESS) - continue; - } + c2h_evt_clear23a(adapter); +} - /* Special pointer to trigger c2h_evt_clear23a only */ - if ((void *)c2h_evt == (void *)evtpriv) - continue; +void rtw_evt_work(struct work_struct *work) +{ + struct evt_work *ework; + struct rtw_adapter *adapter; + c2h_id_filter ccx_id_filter; - if (!c2h_evt_exist(c2h_evt)) { - kfree(c2h_evt); - continue; - } + ework = container_of(work, struct evt_work, work); + adapter = ework->adapter; - if (ccx_id_filter(c2h_evt->id) == true) { - /* Handle CCX report here */ - rtw_hal_c2h_handler23a(adapter, c2h_evt); - kfree(c2h_evt); - } else { - /* Enqueue into cmd_thread for others */ - rtw_c2h_wk_cmd23a(adapter, (u8 *)c2h_evt); - } + ccx_id_filter = rtw_hal_c2h_id_filter_ccx23a(adapter); + + c2h_evt_clear23a(adapter); + + if (!c2h_evt_exist(&ework->u.c2h_evt)) { + kfree(ework); + return; } - evtpriv->c2h_wk_alive = false; + if (ccx_id_filter(ework->u.c2h_evt.id) == true) { + /* Handle CCX report here */ + rtw_hal_c2h_handler23a(adapter, &ework->u.c2h_evt); + kfree(ework); + } else { + /* + * Enqueue into cmd_thread for others. + * ework will be turned into a c2h_evt and freed once it + * has been consumed. + */ + rtw_c2h_wk_cmd23a(adapter, (u8 *)&ework->u.c2h_evt); + } } u8 rtw_drvextra_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index 12997a5cd7a8..da0ef6b7e2a1 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -369,29 +369,36 @@ static void usb_read_interrupt_complete(struct urb *purb, struct pt_regs *regs) if (c2h_id_filter_ccx_8723a(c2h_evt->id)) { /* Handle CCX report here */ handle_txrpt_ccx_8723a(padapter, (void *)(c2h_evt->payload)); - /* Replace with special pointer to - trigger c2h_evt_clear23a */ - if (rtw_cbuf_push23a(padapter->evtpriv.c2h_queue, - (void *)&padapter->evtpriv) != - _SUCCESS) - DBG_8723A("%s rtw_cbuf_push23a fail\n", - __func__); - schedule_work(&padapter->evtpriv.c2h_wk); - } else if ((c2h_evt = (struct c2h_evt_hdr *) - kmalloc(16, GFP_ATOMIC))) { - memcpy(c2h_evt, purb->transfer_buffer, 16); - if (rtw_cbuf_push23a(padapter->evtpriv.c2h_queue, - (void *)c2h_evt) != _SUCCESS) - DBG_8723A("%s rtw_cbuf_push23a fail\n", - __func__); - schedule_work(&padapter->evtpriv.c2h_wk); + schedule_work(&padapter->evtpriv.irq_wk); } else { - /* Error handling for malloc fail */ - if (rtw_cbuf_push23a(padapter->evtpriv.c2h_queue, - (void *)NULL) != _SUCCESS) - DBG_8723A("%s rtw_cbuf_push23a fail\n", - __func__); - schedule_work(&padapter->evtpriv.c2h_wk); + struct evt_work *c2w; + int res; + + c2w = (struct evt_work *) + kmalloc(sizeof(struct evt_work), + GFP_ATOMIC); + + if (!c2w) { + printk(KERN_WARNING "%s: unable to " + "allocate work buffer\n", + __func__); + goto urb_submit; + } + + c2w->adapter = padapter; + INIT_WORK(&c2w->work, rtw_evt_work); + memcpy(c2w->u.buf, purb->transfer_buffer, 16); + + res = queue_work(padapter->evtpriv.wq, + &c2w->work); + + if (!res) { + printk(KERN_ERR "%s: Call to " + "queue_work() failed\n", + __func__); + kfree(c2w); + goto urb_submit; + } } } diff --git a/drivers/staging/rtl8723au/include/rtw_cmd.h b/drivers/staging/rtl8723au/include/rtw_cmd.h index 5c3b46b8e807..6ab3d0514ee5 100644 --- a/drivers/staging/rtl8723au/include/rtw_cmd.h +++ b/drivers/staging/rtl8723au/include/rtw_cmd.h @@ -53,9 +53,8 @@ struct cmd_priv { #define C2H_QUEUE_MAX_LEN 10 struct evt_priv { - struct work_struct c2h_wk; - bool c2h_wk_alive; - struct rtw_cbuf *c2h_queue; + struct workqueue_struct *wq; + struct work_struct irq_wk; atomic_t event_seq; u8 *evt_buf; /* shall be non-paged, and 4 bytes aligned */ @@ -79,8 +78,24 @@ struct c2h_evt_hdr { u8 payload[0]; }; +/* + * Do not reorder - this allows for struct evt_work to be passed on to + * rtw_c2h_wk_cmd23a() as a 'struct c2h_evt_hdr *' without making an + * additional copy. + */ +struct evt_work { + union { + struct c2h_evt_hdr c2h_evt; + u8 buf[16]; + } u; + struct work_struct work; + struct rtw_adapter *adapter; +}; + #define c2h_evt_exist(c2h_evt) ((c2h_evt)->id || (c2h_evt)->plen) +void rtw_evt_work(struct work_struct *work); + int rtw_enqueue_cmd23a(struct cmd_priv *pcmdpriv, struct cmd_obj *obj); void rtw_free_cmd_obj23a(struct cmd_obj *pcmd); -- cgit v1.2.3 From 593ac88e76afb0a738851714cbbdaf0b8e0a824e Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:15 +0200 Subject: staging: rtl8723au: Get rid of ugly cbuf interface Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/osdep_service.h | 14 ---- drivers/staging/rtl8723au/os_dep/osdep_service.c | 92 ----------------------- 2 files changed, 106 deletions(-) diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index 40445bbafe77..105e1c9713dc 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -166,20 +166,6 @@ void rtw_unlock_suspend(void); #define RTW_GET_BE24(a) ((((u32) (a)[0]) << 16) | (((u32) (a)[1]) << 8) | \ ((u32) (a)[2])) - -struct rtw_cbuf { - u32 write; - u32 read; - u32 size; - void *bufs[0]; -}; - -bool rtw_cbuf_full23a(struct rtw_cbuf *cbuf); -bool rtw_cbuf_empty23a(struct rtw_cbuf *cbuf); -bool rtw_cbuf_push23a(struct rtw_cbuf *cbuf, void *buf); -void *rtw_cbuf_pop23a(struct rtw_cbuf *cbuf); -struct rtw_cbuf *rtw_cbuf_alloc23a(u32 size); -void rtw_cbuf_free(struct rtw_cbuf *cbuf); s32 c2h_evt_hdl(struct rtw_adapter *adapter, struct c2h_evt_hdr *c2h_evt, c2h_id_filter filter); u8 rtw_do_join23a(struct rtw_adapter *padapter); diff --git a/drivers/staging/rtl8723au/os_dep/osdep_service.c b/drivers/staging/rtl8723au/os_dep/osdep_service.c index 4a937a7f1d11..9138a175ebd0 100644 --- a/drivers/staging/rtl8723au/os_dep/osdep_service.c +++ b/drivers/staging/rtl8723au/os_dep/osdep_service.c @@ -68,95 +68,3 @@ u32 _rtw_queue_empty23a(struct rtw_queue *pqueue) else return false; } - -/* rtw_cbuf_full23a - test if cbuf is full - * @cbuf: pointer of struct rtw_cbuf - * - * Returns: true if cbuf is full - */ -inline bool rtw_cbuf_full23a(struct rtw_cbuf *cbuf) -{ - return (cbuf->write == cbuf->read-1) ? true : false; -} - -/* rtw_cbuf_empty23a - test if cbuf is empty - * @cbuf: pointer of struct rtw_cbuf - * - * Returns: true if cbuf is empty - */ -inline bool rtw_cbuf_empty23a(struct rtw_cbuf *cbuf) -{ - return (cbuf->write == cbuf->read) ? true : false; -} - -/** - * rtw_cbuf_push23a - push a pointer into cbuf - * @cbuf: pointer of struct rtw_cbuf - * @buf: pointer to push in - * - * Lock free operation, be careful of the use scheme - * Returns: true push success - */ -bool rtw_cbuf_push23a(struct rtw_cbuf *cbuf, void *buf) -{ - if (rtw_cbuf_full23a(cbuf)) - return _FAIL; - - if (0) - DBG_8723A("%s on %u\n", __func__, cbuf->write); - cbuf->bufs[cbuf->write] = buf; - cbuf->write = (cbuf->write+1)%cbuf->size; - - return _SUCCESS; -} - -/** - * rtw_cbuf_pop23a - pop a pointer from cbuf - * @cbuf: pointer of struct rtw_cbuf - * - * Lock free operation, be careful of the use scheme - * Returns: pointer popped out - */ -void *rtw_cbuf_pop23a(struct rtw_cbuf *cbuf) -{ - void *buf; - if (rtw_cbuf_empty23a(cbuf)) - return NULL; - - if (0) - DBG_8723A("%s on %u\n", __func__, cbuf->read); - buf = cbuf->bufs[cbuf->read]; - cbuf->read = (cbuf->read+1)%cbuf->size; - - return buf; -} - -/** - * rtw_cbuf_alloc23a - allocte a rtw_cbuf with given size and do initialization - * @size: size of pointer - * - * Returns: pointer of srtuct rtw_cbuf, NULL for allocation failure - */ -struct rtw_cbuf *rtw_cbuf_alloc23a(u32 size) -{ - struct rtw_cbuf *cbuf; - - cbuf = kmalloc(sizeof(*cbuf) + sizeof(void *)*size, GFP_KERNEL); - - if (cbuf) { - cbuf->write = 0; - cbuf->read = 0; - cbuf->size = size; - } - - return cbuf; -} - -/** - * rtw_cbuf_free - free the given rtw_cbuf - * @cbuf: pointer of struct rtw_cbuf to free - */ -void rtw_cbuf_free(struct rtw_cbuf *cbuf) -{ - kfree(cbuf); -} -- cgit v1.2.3 From b35c0ff605d67018255d1b53e212a50289b2ab71 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:16 +0200 Subject: staging: rtl8723au: Remove unused + write-only entries from struct evt_priv Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 3 --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 5 ----- drivers/staging/rtl8723au/include/rtw_cmd.h | 5 ----- 3 files changed, 13 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index c39adc1974f9..272fb4f4a047 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -192,9 +192,6 @@ static void rtw_irq_work(struct work_struct *work); u32 rtw_init_evt_priv23a(struct evt_priv *pevtpriv) { - atomic_set(&pevtpriv->event_seq, 0); - pevtpriv->evt_done_cnt = 0; - pevtpriv->wq = alloc_workqueue("rtl8723au_evt", 0, 1); INIT_WORK(&pevtpriv->irq_wk, rtw_irq_work); diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index eb7b98e2e5be..8b39087d158d 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -6418,7 +6418,6 @@ u8 mlme_evt_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) u16 evt_sz; const uint *peventbuf; void (*event_callback)(struct rtw_adapter *dev, u8 *pbuf); - struct evt_priv *pevt_priv = &padapter->evtpriv; peventbuf = (uint*)pbuf; evt_sz = (u16)(*peventbuf&0xffff); @@ -6439,15 +6438,11 @@ u8 mlme_evt_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) goto _abort_event_; } - atomic_inc(&pevt_priv->event_seq); - peventbuf += 2; if (peventbuf) { event_callback = wlanevents[evt_code].event_callback; event_callback(padapter, (u8*)peventbuf); - - pevt_priv->evt_done_cnt++; } _abort_event_: diff --git a/drivers/staging/rtl8723au/include/rtw_cmd.h b/drivers/staging/rtl8723au/include/rtw_cmd.h index 6ab3d0514ee5..2cb9c085cc9d 100644 --- a/drivers/staging/rtl8723au/include/rtw_cmd.h +++ b/drivers/staging/rtl8723au/include/rtw_cmd.h @@ -55,11 +55,6 @@ struct cmd_priv { struct evt_priv { struct workqueue_struct *wq; struct work_struct irq_wk; - - atomic_t event_seq; - u8 *evt_buf; /* shall be non-paged, and 4 bytes aligned */ - u8 *evt_allocated_buf; - u32 evt_done_cnt; }; #define init_h2fwcmd_w_parm_no_rsp(pcmd, pparm, code) \ -- cgit v1.2.3 From d217e5dd224829a7d2a190c8119f16385f7d275a Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 9 May 2014 15:03:17 +0200 Subject: staging: rtl8723au: Move data byte-swap closer to register access This makes sparse happy Signed-off-by: Larry Finger Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_io.c | 12 ++---------- drivers/staging/rtl8723au/hal/usb_ops_linux.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_io.c b/drivers/staging/rtl8723au/core/rtw_io.c index 01022113950a..20680e0ce9e0 100644 --- a/drivers/staging/rtl8723au/core/rtw_io.c +++ b/drivers/staging/rtl8723au/core/rtw_io.c @@ -53,22 +53,16 @@ u8 _rtw_read823a(struct rtw_adapter *adapter, u32 addr) u16 _rtw_read1623a(struct rtw_adapter *adapter, u32 addr) { - u16 r_val; struct _io_ops *io_ops = &adapter->io_ops; - r_val = io_ops->_read16(adapter, addr); - - return le16_to_cpu(r_val); + return io_ops->_read16(adapter, addr); } u32 _rtw_read3223a(struct rtw_adapter *adapter, u32 addr) { - u32 r_val; struct _io_ops *io_ops = &adapter->io_ops; - r_val = io_ops->_read32(adapter, addr); - - return le32_to_cpu(r_val); + return io_ops->_read32(adapter, addr); } int _rtw_write823a(struct rtw_adapter *adapter, u32 addr, u8 val) @@ -86,7 +80,6 @@ int _rtw_write1623a(struct rtw_adapter *adapter, u32 addr, u16 val) struct _io_ops *io_ops = &adapter->io_ops; int ret; - val = cpu_to_le16(val); ret = io_ops->_write16(adapter, addr, val); return RTW_STATUS_CODE23a(ret); @@ -97,7 +90,6 @@ int _rtw_write3223a(struct rtw_adapter *adapter, u32 addr, u32 val) struct _io_ops *io_ops = &adapter->io_ops; int ret; - val = cpu_to_le32(val); ret = io_ops->_write32(adapter, addr, val); return RTW_STATUS_CODE23a(ret); diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index da0ef6b7e2a1..870fe5dabce4 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -154,7 +154,7 @@ static u16 usb_read16(struct rtw_adapter *padapter, u32 addr) u16 wvalue; u16 index; u16 len; - u16 data = 0; + __le16 data; request = 0x05; requesttype = 0x01;/* read_in */ @@ -166,7 +166,7 @@ static u16 usb_read16(struct rtw_adapter *padapter, u32 addr) usbctrl_vendorreq(padapter, request, wvalue, index, &data, len, requesttype); - return data; + return le16_to_cpu(data); } static u32 usb_read32(struct rtw_adapter *padapter, u32 addr) @@ -176,7 +176,7 @@ static u32 usb_read32(struct rtw_adapter *padapter, u32 addr) u16 wvalue; u16 index; u16 len; - u32 data = 0; + __le32 data; request = 0x05; requesttype = 0x01;/* read_in */ @@ -188,7 +188,7 @@ static u32 usb_read32(struct rtw_adapter *padapter, u32 addr) usbctrl_vendorreq(padapter, request, wvalue, index, &data, len, requesttype); - return data; + return le32_to_cpu(data); } static int usb_write8(struct rtw_adapter *padapter, u32 addr, u8 val) @@ -223,7 +223,7 @@ static int usb_write16(struct rtw_adapter *padapter, u32 addr, u16 val) u16 wvalue; u16 index; u16 len; - u16 data; + __le16 data; int ret; request = 0x05; @@ -233,7 +233,7 @@ static int usb_write16(struct rtw_adapter *padapter, u32 addr, u16 val) wvalue = (u16)(addr&0x0000ffff); len = 2; - data = val; + data = cpu_to_le16(val); ret = usbctrl_vendorreq(padapter, request, wvalue, index, &data, len, requesttype); @@ -247,7 +247,7 @@ static int usb_write32(struct rtw_adapter *padapter, u32 addr, u32 val) u16 wvalue; u16 index; u16 len; - u32 data; + __le32 data; int ret; request = 0x05; @@ -256,7 +256,7 @@ static int usb_write32(struct rtw_adapter *padapter, u32 addr, u32 val) wvalue = (u16)(addr&0x0000ffff); len = 4; - data = val; + data = cpu_to_le32(val); ret = usbctrl_vendorreq(padapter, request, wvalue, index, &data, len, requesttype); -- cgit v1.2.3 From 0f6df02ad85fa79e48468932a9d93605a4088ba2 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:18 +0200 Subject: staging: rtl8723au: Fix endian abnormality in mlme_evt_hdl23a() Every other place uses C2HEvent_Header() for events. Given the struct is endian dependant, use it here too to retrieve data from the parm buffer. Note the length field is not set/read in le order - question is whether it's simply an opaque field? Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 8b39087d158d..0372820538fd 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -6416,13 +6416,13 @@ u8 mlme_evt_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { u8 evt_code, evt_seq; u16 evt_sz; - const uint *peventbuf; + const struct C2HEvent_Header *c2h; void (*event_callback)(struct rtw_adapter *dev, u8 *pbuf); - peventbuf = (uint*)pbuf; - evt_sz = (u16)(*peventbuf&0xffff); - evt_seq = (u8)((*peventbuf>>24)&0x7f); - evt_code = (u8)((*peventbuf>>16)&0xff); + c2h = (struct C2HEvent_Header *)pbuf; + evt_sz = c2h->len; + evt_seq = c2h->seq; + evt_code = c2h->ID; /* checking if event code is valid */ if (evt_code >= MAX_C2HEVT) { @@ -6438,12 +6438,8 @@ u8 mlme_evt_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) goto _abort_event_; } - peventbuf += 2; - - if (peventbuf) { - event_callback = wlanevents[evt_code].event_callback; - event_callback(padapter, (u8*)peventbuf); - } + event_callback = wlanevents[evt_code].event_callback; + event_callback(padapter, (u8 *)pbuf + sizeof(struct C2HEvent_Header)); _abort_event_: -- cgit v1.2.3 From e2601960e9d5119f20fb3f5dca562378502ed7e6 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:19 +0200 Subject: staging: rtl8723au: Make event callbacks take a const u8 * This avoids an ugly cast in mlme_evt_hdl23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 19 ++++++++++--------- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 4 ++-- drivers/staging/rtl8723au/include/rtw_event.h | 2 +- drivers/staging/rtl8723au/include/rtw_mlme.h | 14 +++++++------- drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 4 ++-- 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index d39f879790bb..f02b314d25e0 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -626,14 +626,14 @@ static int rtw_is_desired_network(struct rtw_adapter *adapter, } /* TODO: Perry : For Power Management */ -void rtw_atimdone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) +void rtw_atimdone_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf) { RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("receive atimdone_evet\n")); return; } -void rtw_survey_event_cb23a(struct rtw_adapter *adapter, u8 *pbuf) +void rtw_survey_event_cb23a(struct rtw_adapter *adapter, const u8 *pbuf) { u32 len; struct wlan_bssid_ex *pnetwork; @@ -693,7 +693,8 @@ exit: return; } -void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) +void +rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf) { struct mlme_priv *pmlmepriv = &adapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; @@ -814,11 +815,11 @@ void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) rtw_cfg80211_surveydone_event_callback(adapter); } -void rtw_dummy_event_callback23a(struct rtw_adapter *adapter , u8 *pbuf) +void rtw_dummy_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf) { } -void rtw23a_fwdbg_event_callback(struct rtw_adapter *adapter , u8 *pbuf) +void rtw23a_fwdbg_event_callback(struct rtw_adapter *adapter, const u8 *pbuf) { } @@ -1335,7 +1336,7 @@ ignore_joinbss_callback: spin_unlock_bh(&pmlmepriv->lock); } -void rtw23a_joinbss_event_cb(struct rtw_adapter *adapter, u8 *pbuf) +void rtw23a_joinbss_event_cb(struct rtw_adapter *adapter, const u8 *pbuf) { struct wlan_network *pnetwork = (struct wlan_network *)pbuf; @@ -1344,7 +1345,7 @@ void rtw23a_joinbss_event_cb(struct rtw_adapter *adapter, u8 *pbuf) rtw_os_xmit_schedule23a(adapter); } -void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) +void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf) { struct sta_info *psta; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; @@ -1422,7 +1423,7 @@ void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) mlmeext_sta_add_event_callback23a(adapter, psta); } -void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) +void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf) { int mac_id; struct sta_info *psta; @@ -1531,7 +1532,7 @@ void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) spin_unlock_bh(&pmlmepriv->lock); } -void rtw_cpwm_event_callback23a(struct rtw_adapter *padapter, u8 *pbuf) +void rtw_cpwm_event_callback23a(struct rtw_adapter *padapter, const u8 *pbuf) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_cpwm_event_callback23a !!!\n")); diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 0372820538fd..3a0a4229e5ed 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -6417,7 +6417,7 @@ u8 mlme_evt_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) u8 evt_code, evt_seq; u16 evt_sz; const struct C2HEvent_Header *c2h; - void (*event_callback)(struct rtw_adapter *dev, u8 *pbuf); + void (*event_callback)(struct rtw_adapter *dev, const u8 *pbuf); c2h = (struct C2HEvent_Header *)pbuf; evt_sz = c2h->len; @@ -6439,7 +6439,7 @@ u8 mlme_evt_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) } event_callback = wlanevents[evt_code].event_callback; - event_callback(padapter, (u8 *)pbuf + sizeof(struct C2HEvent_Header)); + event_callback(padapter, pbuf + sizeof(struct C2HEvent_Header)); _abort_event_: diff --git a/drivers/staging/rtl8723au/include/rtw_event.h b/drivers/staging/rtl8723au/include/rtw_event.h index bb20640e6855..3520d383a8ef 100644 --- a/drivers/staging/rtl8723au/include/rtw_event.h +++ b/drivers/staging/rtl8723au/include/rtw_event.h @@ -81,7 +81,7 @@ struct addba_event struct fwevent { u32 parmsize; - void (*event_callback)(struct rtw_adapter *dev, u8 *pbuf); + void (*event_callback)(struct rtw_adapter *dev, const u8 *pbuf); }; diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index 38203f16aee8..50a2f9009526 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -333,13 +333,13 @@ void hostapd_mode_unload(struct rtw_adapter *padapter); #endif void rtw_joinbss_event_prehandle23a(struct rtw_adapter *adapter, u8 *pbuf); -void rtw_survey_event_cb23a(struct rtw_adapter *adapter, u8 *pbuf); -void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf); -void rtw23a_joinbss_event_cb(struct rtw_adapter *adapter, u8 *pbuf); -void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf); -void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf); -void rtw_atimdone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf); -void rtw_cpwm_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf); +void rtw_survey_event_cb23a(struct rtw_adapter *adapter, const u8 *pbuf); +void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf); +void rtw23a_joinbss_event_cb(struct rtw_adapter *adapter, const u8 *pbuf); +void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf); +void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf); +void rtw_atimdone_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf); +void rtw_cpwm_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf); int event_thread(void *context); diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 26d360178eac..6a4aa2b11808 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -699,8 +699,8 @@ struct C2HEvent_Header { unsigned int rsvd; }; -void rtw_dummy_event_callback23a(struct rtw_adapter *adapter , u8 *pbuf); -void rtw23a_fwdbg_event_callback(struct rtw_adapter *adapter , u8 *pbuf); +void rtw_dummy_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf); +void rtw23a_fwdbg_event_callback(struct rtw_adapter *adapter, const u8 *pbuf); enum rtw_c2h_event { GEN_EVT_CODE(_Read_MACREG) = 0, /*0*/ -- cgit v1.2.3 From 62dff10d207d8e9ac973a30f1e76230eea5feaa4 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:20 +0200 Subject: staging: rtl8723au: rtw_event.h remove some unused structs and random blank lines Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtw_event.h | 58 +++++---------------------- 1 file changed, 9 insertions(+), 49 deletions(-) diff --git a/drivers/staging/rtl8723au/include/rtw_event.h b/drivers/staging/rtl8723au/include/rtw_event.h index 3520d383a8ef..807cc83bc710 100644 --- a/drivers/staging/rtl8723au/include/rtw_event.h +++ b/drivers/staging/rtl8723au/include/rtw_event.h @@ -16,99 +16,59 @@ #define _RTW_EVENT_H_ #include - #include /* Used to report a bss has been scanned - */ -struct survey_event { +struct survey_event { struct wlan_bssid_ex bss; }; /* Used to report that the requested site survey has been done. - bss_cnt indicates the number of bss that has been reported. - - */ struct surveydone_event { - unsigned int bss_cnt; - + unsigned int bss_cnt; }; /* Used to report the link result of joinning the given bss - - join_res: -1: authentication fail -2: association fail > 0: TID - */ struct joinbss_event { - struct wlan_network network; + struct wlan_network network; }; /* Used to report a given STA has joinned the created BSS. It is used in AP/Ad-HoC(M) mode. - - */ struct stassoc_event { unsigned char macaddr[6]; unsigned char rsvd[2]; - int cam_id; - + int cam_id; }; struct stadel_event { - unsigned char macaddr[6]; - unsigned char rsvd[2]; /* for reason */ - int mac_id; + unsigned char macaddr[6]; + unsigned char rsvd[2]; /* for reason */ + int mac_id; }; -struct addba_event -{ +struct addba_event { unsigned int tid; }; #define GEN_EVT_CODE(event) event ## _EVT_ struct fwevent { - u32 parmsize; + u32 parmsize; void (*event_callback)(struct rtw_adapter *dev, const u8 *pbuf); }; - -#define C2HEVENT_SZ 32 - -struct event_node{ - unsigned char *node; - unsigned char evt_code; - unsigned short evt_sz; - volatile int *caller_ff_tail; - int caller_ff_sz; -}; - -struct c2hevent_queue { - volatile int head; - volatile int tail; - struct event_node nodes[C2HEVENT_SZ]; - unsigned char seq; -}; - -#define NETWORK_QUEUE_SZ 4 - -struct network_queue { - volatile int head; - volatile int tail; - struct wlan_bssid_ex networks[NETWORK_QUEUE_SZ]; -}; - - #endif /* _WLANEVENT_H_ */ -- cgit v1.2.3 From bd8ad4a510962fd8a43391dc8a22783f9f54398f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:21 +0200 Subject: staging: rtl8723au: Eliminate struct qos_priv Having struct qos_priv containing a single integer, and carrying a dedicated header file for it, is just plain silly. Move the integer into struct mlme_priv, which is the only place qos_priv was used anyway, and get rid of the header file. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 10 +++++----- drivers/staging/rtl8723au/core/rtw_cmd.c | 7 +++---- drivers/staging/rtl8723au/core/rtw_mlme.c | 5 ++--- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 6 +++--- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 2 +- drivers/staging/rtl8723au/core/rtw_xmit.c | 8 +++----- drivers/staging/rtl8723au/include/drv_types.h | 1 - drivers/staging/rtl8723au/include/rtw_mlme.h | 2 +- drivers/staging/rtl8723au/include/rtw_qos.h | 26 -------------------------- 9 files changed, 18 insertions(+), 49 deletions(-) delete mode 100644 drivers/staging/rtl8723au/include/rtw_qos.h diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 9b31412b7521..432f0a29892f 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -672,7 +672,7 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) /* todo: update wmm, ht cap */ /* pmlmeinfo->WMM_enable; */ /* pmlmeinfo->HT_enable; */ - if (pmlmepriv->qospriv.qos_option) + if (pmlmepriv->qos_option) pmlmeinfo->WMM_enable = true; if (pmlmepriv->htpriv.ht_option) { pmlmeinfo->WMM_enable = true; @@ -950,14 +950,14 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, /* wmm */ ie_len = 0; - pmlmepriv->qospriv.qos_option = 0; + pmlmepriv->qos_option = 0; if (pregistrypriv->wmm_enable) { for (p = ie + _BEACON_IE_OFFSET_; ;p += (ie_len + 2)) { p = rtw_get_ie23a(p, WLAN_EID_VENDOR_SPECIFIC, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); if ((p) && !memcmp(p+2, WMM_PARA_IE, 6)) { - pmlmepriv->qospriv.qos_option = 1; + pmlmepriv->qos_option = 1; *(p+8) |= BIT(7);/* QoS Info, support U-APSD */ @@ -1037,7 +1037,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, /* ht_cap */ if (pregistrypriv->ht_enable && ht_cap) { pmlmepriv->htpriv.ht_option = true; - pmlmepriv->qospriv.qos_option = 1; + pmlmepriv->qos_option = 1; if (pregistrypriv->ampdu_enable == 1) pmlmepriv->htpriv.ampdu_enable = true; @@ -1864,7 +1864,7 @@ void sta_info_update23a(struct rtw_adapter *padapter, struct sta_info *psta) else psta->qos_option = 0; - if (pmlmepriv->qospriv.qos_option == 0) + if (pmlmepriv->qos_option == 0) psta->qos_option = 0; /* update 802.11n ht cap. */ diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 272fb4f4a047..1ff945caa8f0 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -481,7 +481,6 @@ u8 rtw_joinbss_cmd23a(struct rtw_adapter *padapter, struct cmd_obj *pcmd; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct qos_priv *pqospriv = &pmlmepriv->qospriv; struct security_priv *psecuritypriv = &padapter->securitypriv; struct registry_priv *pregistrypriv = &padapter->registrypriv; struct ht_priv *phtpriv = &pmlmepriv->htpriv; @@ -573,7 +572,7 @@ u8 rtw_joinbss_cmd23a(struct rtw_adapter *padapter, &psecnetwork->IEs[0], pnetwork->network.IELength); - pqospriv->qos_option = 0; + pmlmepriv->qos_option = 0; if (pregistrypriv->wmm_enable) { u32 tmp_len; @@ -587,10 +586,10 @@ u8 rtw_joinbss_cmd23a(struct rtw_adapter *padapter, if (psecnetwork->IELength != tmp_len) { psecnetwork->IELength = tmp_len; /* There is WMM IE in this corresp. beacon */ - pqospriv->qos_option = 1; + pmlmepriv->qos_option = 1; } else { /* There is no WMM IE in this corresp. beacon */ - pqospriv->qos_option = 0; + pmlmepriv->qos_option = 0; } } diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index f02b314d25e0..ddbe6c648225 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -2239,7 +2239,6 @@ unsigned int rtw_restructure_ht_ie23a(struct rtw_adapter *padapter, u8 *in_ie, struct ieee80211_ht_cap ht_capie; unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00}; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct qos_priv *pqospriv = &pmlmepriv->qospriv; struct ht_priv *phtpriv = &pmlmepriv->htpriv; phtpriv->ht_option = false; @@ -2248,13 +2247,13 @@ unsigned int rtw_restructure_ht_ie23a(struct rtw_adapter *padapter, u8 *in_ie, if (p && p[1] > 0) { u32 rx_packet_offset, max_recvbuf_sz; - if (pqospriv->qos_option == 0) { + if (pmlmepriv->qos_option == 0) { out_len = *pout_len; pframe = rtw_set_ie23a(out_ie + out_len, WLAN_EID_VENDOR_SPECIFIC, _WMM_IE_Length_, WMM_IE, pout_len); - pqospriv->qos_option = 1; + pmlmepriv->qos_option = 1; } out_len = *pout_len; diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 3a0a4229e5ed..5ac41131a1a9 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1540,7 +1540,7 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) pstat->uapsd_vi = 0; pstat->uapsd_be = 0; pstat->uapsd_bk = 0; - if (pmlmepriv->qospriv.qos_option) { + if (pmlmepriv->qos_option) { const u8 *end = pos + left; p = pos; @@ -3225,7 +3225,7 @@ void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status, } /* FILL WMM IE */ - if (pstat->flags & WLAN_STA_WME && pmlmepriv->qospriv.qos_option) { + if (pstat->flags & WLAN_STA_WME && pmlmepriv->qos_option) { unsigned char WMM_PARA_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; int ie_len = 0; @@ -5369,7 +5369,7 @@ void update_sta_info23a(struct rtw_adapter *padapter, struct sta_info *psta) psta->htpriv.candidate_tid_bitmap = 0x0;/* reset */ /* QoS */ - if (pmlmepriv->qospriv.qos_option) + if (pmlmepriv->qos_option) psta->qos_option = true; psta->state = _FW_LINKED; diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 09f3a66010d9..0241a19d5f56 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -506,7 +506,7 @@ int WMM_param_handler23a(struct rtw_adapter *padapter, struct ndis_802_11_var_ie struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - if (pmlmepriv->qospriv.qos_option == 0) { + if (pmlmepriv->qos_option == 0) { pmlmeinfo->WMM_enable = 0; return _FAIL; } diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 31a44feaab1d..470d868f0f5c 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -473,7 +473,6 @@ static s32 update_attrib(struct rtw_adapter *padapter, struct sta_priv *pstapriv = &padapter->stapriv; struct security_priv *psecuritypriv = &padapter->securitypriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct qos_priv *pqospriv = &pmlmepriv->qospriv; int res = _SUCCESS; struct ethhdr *ehdr = (struct ethhdr *) skb->data; @@ -586,7 +585,7 @@ static s32 update_attrib(struct rtw_adapter *padapter, if (psta->qos_option) set_qos(skb, pattrib); } else { - if (pqospriv->qos_option) { + if (pmlmepriv->qos_option) { set_qos(skb, pattrib); if (pmlmepriv->acm_mask != 0) { @@ -767,7 +766,7 @@ static s32 xmitframe_addmic(struct rtw_adapter *padapter, &pframe[10], 6); } - /* if (pqospriv->qos_option == 1) */ + /* if (pmlmepriv->qos_option == 1) */ if (pattrib->qos_en) priority[0] = (u8)pxmitframe->attrib.priority; @@ -905,7 +904,6 @@ s32 rtw_make_wlanhdr23a(struct rtw_adapter *padapter, u8 *hdr, struct ieee80211_hdr *pwlanhdr = (struct ieee80211_hdr *)hdr; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct qos_priv *pqospriv = &pmlmepriv->qospriv; u8 qos_option = false; int res = _SUCCESS; __le16 *fctrl = &pwlanhdr->frame_control; @@ -948,7 +946,7 @@ s32 rtw_make_wlanhdr23a(struct rtw_adapter *padapter, u8 *hdr, memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN); memcpy(pwlanhdr->addr3, pattrib->dst, ETH_ALEN); - if (pqospriv->qos_option) + if (pmlmepriv->qos_option) qos_option = true; } diff --git a/drivers/staging/rtl8723au/include/drv_types.h b/drivers/staging/rtl8723au/include/drv_types.h index bec8fd7126d1..a61408cc7eb3 100644 --- a/drivers/staging/rtl8723au/include/drv_types.h +++ b/drivers/staging/rtl8723au/include/drv_types.h @@ -43,7 +43,6 @@ enum _NIC_VERSION { #include #include #include -#include #include #include #include diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index 50a2f9009526..6dd8fb476553 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -237,7 +237,7 @@ struct mlme_priv { struct timer_list set_scan_deny_timer; atomic_t set_scan_deny; /* 0: allowed, 1: deny */ - struct qos_priv qospriv; + unsigned int qos_option; /* Number of non-HT AP/stations */ int num_sta_no_ht; diff --git a/drivers/staging/rtl8723au/include/rtw_qos.h b/drivers/staging/rtl8723au/include/rtw_qos.h deleted file mode 100644 index 68fc5ba1844a..000000000000 --- a/drivers/staging/rtl8723au/include/rtw_qos.h +++ /dev/null @@ -1,26 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek 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. - * - ******************************************************************************/ - -#ifndef _RTW_QOS_H_ -#define _RTW_QOS_H_ - -#include - -struct qos_priv { - /* bit mask option: u-apsd, s-apsd, ts, block ack... */ - unsigned int qos_option; -}; - -#endif /* _RTL871X_QOS_H_ */ -- cgit v1.2.3 From 51e2726a341afa1ff9153e8482833475c92d721f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:22 +0200 Subject: staging: rtl8723au: Remove unused rtw_ioctl.h Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtw_ioctl.h | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 drivers/staging/rtl8723au/include/rtw_ioctl.h diff --git a/drivers/staging/rtl8723au/include/rtw_ioctl.h b/drivers/staging/rtl8723au/include/rtw_ioctl.h deleted file mode 100644 index 629eec8a7023..000000000000 --- a/drivers/staging/rtl8723au/include/rtw_ioctl.h +++ /dev/null @@ -1,26 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek 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. - * - ******************************************************************************/ -#ifndef _RTW_IOCTL_H_ -#define _RTW_IOCTL_H_ - -#include -#include - - -#if defined(CONFIG_WIRELESS_EXT) -extern struct iw_handler_def rtw_handlers_def; -#endif - -#endif /* #ifndef __INC_CEINFO_ */ -- cgit v1.2.3 From 45b09aa208922dc81f0d680f23547e3429f7a00a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:23 +0200 Subject: staging: rtl8723au: rtw_ioctl_set.h: Remove unused struct bssid_info Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtw_ioctl_set.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8723au/include/rtw_ioctl_set.h b/drivers/staging/rtl8723au/include/rtw_ioctl_set.h index 18ad2a873350..8e49be5fcdda 100644 --- a/drivers/staging/rtl8723au/include/rtw_ioctl_set.h +++ b/drivers/staging/rtl8723au/include/rtw_ioctl_set.h @@ -17,12 +17,6 @@ #include - -struct bssid_info { - unsigned char BSSID[6]; - u8 PMKID[16]; -}; - u8 rtw_set_802_11_authentication_mode23a(struct rtw_adapter *pdapter, enum ndis_802_11_auth_mode authmode); u8 rtw_set_802_11_add_wep23a(struct rtw_adapter * padapter, -- cgit v1.2.3 From 1509864ca70eafdfee169c6a4108960c04349f2d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:24 +0200 Subject: staging: rtl8723au: Remove a pile of unused firmware image file names Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c | 19 ------------------- drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c | 6 ------ drivers/staging/rtl8723au/include/rtl8723a_hal.h | 11 ----------- 3 files changed, 36 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c b/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c index 8400e6e2fca8..4860ba4e0188 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c @@ -417,12 +417,8 @@ s32 PHY_MACConfig8723A(struct rtw_adapter *Adapter) { int rtStatus = _SUCCESS; struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); - s8 *pszMACRegFile; - s8 sz8723MACRegFile[] = RTL8723_PHY_MACREG; bool is92C = IS_92C_SERIAL(pHalData->VersionID); - pszMACRegFile = sz8723MACRegFile; - /* */ /* Config MAC */ /* */ @@ -751,21 +747,6 @@ phy_BB8723a_Config_ParaFile(struct rtw_adapter *Adapter) struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); int rtStatus = _SUCCESS; - u8 sz8723BBRegFile[] = RTL8723_PHY_REG; - u8 sz8723AGCTableFile[] = RTL8723_AGC_TAB; - u8 sz8723BBRegPgFile[] = RTL8723_PHY_REG_PG; - u8 sz8723BBRegMpFile[] = RTL8723_PHY_REG_MP; - - u8 *pszBBRegFile = NULL, *pszAGCTableFile = NULL; - u8 *pszBBRegPgFile = NULL, *pszBBRegMpFile = NULL; - - /* RT_TRACE(COMP_INIT, DBG_TRACE, ("==>phy_BB8192S_Config_ParaFile\n")); */ - - pszBBRegFile = sz8723BBRegFile ; - pszAGCTableFile = sz8723AGCTableFile; - pszBBRegPgFile = sz8723BBRegPgFile; - pszBBRegMpFile = sz8723BBRegMpFile; - /* */ /* 1. Read PHY_REG.TXT BB INIT!! */ /* We will seperate as 88C / 92C according to chip version */ diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c b/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c index ed39c18c3f84..d4f922a0675e 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c @@ -417,12 +417,6 @@ static int phy_RF6052_Config_ParaFile(struct rtw_adapter *Adapter) struct bb_reg_define *pPhyReg; int rtStatus = _SUCCESS; struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); - static char sz8723RadioAFile[] = RTL8723_PHY_RADIO_A; - static char sz8723RadioBFile[] = RTL8723_PHY_RADIO_B; - char *pszRadioAFile, *pszRadioBFile; - - pszRadioAFile = sz8723RadioAFile; - pszRadioBFile = sz8723RadioBFile; /* 3----------------------------------------------------------------- */ /* 3 <2> Initialize RF */ diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index f6b4b7c7c22d..a6d4bc7bf04c 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -37,17 +37,6 @@ #define RTL819X_DEFAULT_RF_TYPE RF_1T2R #define RTL819X_TOTAL_RF_PATH 2 -/* TODO: The following need to check!! */ -#define RTL8723_FW_UMC_IMG "rtl8192CU\\rtl8723fw.bin" -#define RTL8723_FW_UMC_B_IMG "rtl8192CU\\rtl8723fw_B.bin" -#define RTL8723_PHY_REG "rtl8723S\\PHY_REG_1T.txt" -#define RTL8723_PHY_RADIO_A "rtl8723S\\radio_a_1T.txt" -#define RTL8723_PHY_RADIO_B "rtl8723S\\radio_b_1T.txt" -#define RTL8723_AGC_TAB "rtl8723S\\AGC_TAB_1T.txt" -#define RTL8723_PHY_MACREG "rtl8723S\\MAC_REG.txt" -#define RTL8723_PHY_REG_PG "rtl8723S\\PHY_REG_PG.txt" -#define RTL8723_PHY_REG_MP "rtl8723S\\PHY_REG_MP.txt" - /* */ /* RTL8723S From header */ /* */ -- cgit v1.2.3 From 9b6cd3e6ea12541c2783f9f96f21616648679eda Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:25 +0200 Subject: staging: rtl8723au: Remove a bunch of always true #ifdefs Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 26 ------------------ .../rtl8723au/include/rtl8723a_bt-coexist.h | 32 ---------------------- 2 files changed, 58 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index 0d1452757a09..32f8875f2a4f 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -100,7 +100,6 @@ enum { /* power saving */ -#ifdef __BT_C__ /* COMMOM/BT.c */ /* ===== Below this line is sync from SD7 driver COMMOM/BT.c ===== */ static u8 BT_Operation(struct rtw_adapter *padapter) @@ -177,15 +176,6 @@ void BT_LpsLeave(struct rtw_adapter *padapter) } /* ===== End of sync from SD7 driver COMMOM/BT.c ===== */ -#endif - -#ifdef __BT_HANDLEPACKET_C__ /* COMMOM/bt_handlepacket.c */ -/* ===== Below this line is sync from SD7 driver COMMOM/bt_handlepacket.c ===== */ - -/* ===== End of sync from SD7 driver COMMOM/bt_handlepacket.c ===== */ -#endif - -#ifdef __BT_HCI_C__ /* COMMOM/bt_hci.c */ #define i64fmt "ll" #define UINT64_C(v) (v) @@ -5213,9 +5203,6 @@ BTHCI_HandleHCICMD( } /* ===== End of sync from SD7 driver COMMOM/bt_hci.c ===== */ -#endif - -#ifdef __HALBTC87231ANT_C__ /* HAL/BTCoexist/HalBtc87231Ant.c */ static const char *const BtStateString[] = { "BT_DISABLED", @@ -6511,9 +6498,7 @@ void BTDM_1AntBtCoexist8723A(struct rtw_adapter *padapter) } /* ===== End of sync from SD7 driver HAL/BTCoexist/HalBtc87231Ant.c ===== */ -#endif -#ifdef __HALBTC87232ANT_C__ /* HAL/BTCoexist/HalBtc87232Ant.c */ /* ===== Below this line is sync from SD7 driver HAL/BTCoexist/HalBtc87232Ant.c ===== */ /* local function start with btdm_ */ @@ -8993,9 +8978,7 @@ void BTDM_2AntBtCoexist8723A(struct rtw_adapter *padapter) } /* ===== End of sync from SD7 driver HAL/BTCoexist/HalBtc87232Ant.c ===== */ -#endif -#ifdef __HALBTC8723_C__ /* HAL/BTCoexist/HalBtc8723.c */ /* ===== Below this line is sync from SD7 driver HAL/BTCoexist/HalBtc8723.c ===== */ static u8 btCoexDbgBuf[BT_TMP_BUF_SIZE]; @@ -9876,9 +9859,7 @@ static void BTDM_BTCoexist8723A(struct rtw_adapter *padapter) } /* ===== End of sync from SD7 driver HAL/BTCoexist/HalBtc8723.c ===== */ -#endif -#ifdef __HALBTCCSR1ANT_C__ /* HAL/BTCoexist/HalBtcCsr1Ant.c */ /* ===== Below this line is sync from SD7 driver HAL/BTCoexist/HalBtcCsr1Ant.c ===== */ /* local function start with btdm_ */ @@ -10065,9 +10046,7 @@ void BTDM_CheckBTIdleChange1Ant(struct rtw_adapter *padapter) } /* ===== End of sync from SD7 driver HAL/BTCoexist/HalBtcCsr1Ant.c ===== */ -#endif -#ifdef __HALBTCCSR2ANT_C__ /* HAL/BTCoexist/HalBtcCsr2Ant.c */ /* ===== Below this line is sync from SD7 driver HAL/BTCoexist/HalBtcCsr2Ant.c ===== */ /* local function start with btdm_ */ @@ -10122,9 +10101,7 @@ BTDM_DiminishWiFi( } /* ===== End of sync from SD7 driver HAL/BTCoexist/HalBtcCsr2Ant.c ===== */ -#endif -#ifdef __HALBTCOEXIST_C__ /* HAL/BTCoexist/HalBtCoexist.c */ /* ===== Below this line is sync from SD7 driver HAL/BTCoexist/HalBtCoexist.c ===== */ /* local function */ @@ -11260,9 +11237,7 @@ u8 BTDM_IsBtDisabled(struct rtw_adapter *padapter) } /* ===== End of sync from SD7 driver HAL/BTCoexist/HalBtCoexist.c ===== */ -#endif -#ifdef __HALBT_C__ /* HAL/HalBT.c */ /* ===== Below this line is sync from SD7 driver HAL/HalBT.c ===== */ /* */ @@ -11379,4 +11354,3 @@ void HALBT_SetRtsCtsNoLenLimit(struct rtw_adapter *padapter) } /* ===== End of sync from SD7 driver HAL/HalBT.c ===== */ -#endif diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h index 6d1edc6ef84d..1072f5eedfc8 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h @@ -19,19 +19,6 @@ #include "odm_precomp.h" -#define __BT_C__ 1 -#define __BT_HANDLEPACKET_C__ 1 -#define __BT_HCI_C__ 1 -#define __HALBTC87231ANT_C__ 1 -#define __HALBTC87232ANT_C__ 1 -#define __HALBTC8723_C__ 1 -#define __HALBTCCSR1ANT_C__ 1 -#define __HALBTCCSR2ANT_C__ 1 -#define __HALBTCOEXIST_C__ 1 -#define __HALBT_C__ 1 - -#ifdef __BT_C__ /* COMMON/BT.h */ - /* HEADER/PlatformDef.h */ enum rt_media_status { RT_MEDIA_DISCONNECT = 0, @@ -55,9 +42,6 @@ void BT_LpsLeave(struct rtw_adapter * padapter); #define BT_HsConnectionEstablished(Adapter) false /* ===== End of sync from SD7 driver COMMON/BT.h ===== */ -#endif /* __BT_C__ */ - -#ifdef __BT_HCI_C__ /* COMMON/bt_hci.h */ /* HEADER/SecurityType.h */ #define TKIP_ENC_KEY_POS 32 /* KEK_LEN+KEK_LEN) */ @@ -1132,9 +1116,7 @@ void BTHCI_DisconnectAll(struct rtw_adapter * padapter); enum hci_status BTHCI_HandleHCICMD(struct rtw_adapter * padapter, struct packet_irp_hcicmd_data *pHciCmd); /* ===== End of sync from SD7 driver COMMON/bt_hci.h ===== */ -#endif /* __BT_HCI_C__ */ -#ifdef __HALBTC87231ANT_C__ /* HAL/BTCoexist/HalBtc87231Ant.h */ /* ===== Below this line is sync from SD7 driver HAL/BTCoexist/HalBtc87231Ant.h ===== */ #define GET_BT_INFO(padapter) (&GET_HAL_DATA(padapter)->BtInfo) @@ -1191,9 +1173,7 @@ void BTDM_1AntForDhcp(struct rtw_adapter * padapter); void BTDM_1AntBtCoexist8723A(struct rtw_adapter * padapter); /* ===== End of sync from SD7 driver HAL/BTCoexist/HalBtc87231Ant.h ===== */ -#endif /* __HALBTC87231ANT_C__ */ -#ifdef __HALBTC87232ANT_C__ /* HAL/BTCoexist/HalBtc87232Ant.h */ /* ===== Below this line is sync from SD7 driver HAL/BTCoexist/HalBtc87232Ant.h ===== */ enum bt_2ant_bt_status { BT_2ANT_BT_STATUS_IDLE = 0x0, @@ -1274,9 +1254,7 @@ struct btdm_8723a_2ant { void BTDM_2AntBtCoexist8723A(struct rtw_adapter * padapter); /* ===== End of sync from SD7 driver HAL/BTCoexist/HalBtc87232Ant.h ===== */ -#endif /* __HALBTC87232ANT_C__ */ -#ifdef __HALBTC8723_C__ /* HAL/BTCoexist/HalBtc8723.h */ /* ===== Below this line is sync from SD7 driver HAL/BTCoexist/HalBtc8723.h ===== */ #define BT_Q_PKT_OFF 0 @@ -1356,9 +1334,7 @@ u8 BTDM_1Ant8723A(struct rtw_adapter * padapter); #define BT_1Ant BTDM_1Ant8723A /* ===== End of sync from SD7 driver HAL/BTCoexist/HalBtc8723.h ===== */ -#endif /* __HALBTC8723_C__ */ -#ifdef __HALBTCCSR1ANT_C__ /* HAL/BTCoexist/HalBtcCsr1Ant.h */ /* ===== Below this line is sync from SD7 driver HAL/BTCoexist/HalBtcCsr1Ant.h ===== */ enum BT_A2DP_INDEX{ @@ -1381,9 +1357,7 @@ void BTDM_SingleAnt(struct rtw_adapter * padapter, u8 bSingleAntOn, u8 bInterrup void BTDM_CheckBTIdleChange1Ant(struct rtw_adapter * padapter); /* ===== End of sync from SD7 driver HAL/BTCoexist/HalBtcCsr1Ant.h ===== */ -#endif /* __HALBTCCSR1ANT_C__ */ -#ifdef __HALBTCCSR2ANT_C__ /* HAL/BTCoexist/HalBtcCsr2Ant.h */ /* ===== Below this line is sync from SD7 driver HAL/BTCoexist/HalBtcCsr2Ant.h ===== */ /* */ @@ -1403,9 +1377,6 @@ void BTDM_CheckBTIdleChange1Ant(struct rtw_adapter * padapter); void BTDM_DiminishWiFi(struct rtw_adapter * Adapter, u8 bDACOn, u8 bInterruptOn, u8 DACSwingLevel, u8 bNAVOn); /* ===== End of sync from SD7 driver HAL/BTCoexist/HalBtcCsr2Ant.h ===== */ -#endif /* __HALBTCCSR2ANT_C__ */ - -#ifdef __HALBTCOEXIST_C__ /* HAL/BTCoexist/HalBtCoexist.h */ /* HEADER/TypeDef.h */ #define MAX_FW_SUPPORT_MACID_NUM 64 @@ -1638,9 +1609,7 @@ u32 BTDM_BtTxRxCounterH(struct rtw_adapter * padapter); u32 BTDM_BtTxRxCounterL(struct rtw_adapter * padapter); /* ===== End of sync from SD7 driver HAL/BTCoexist/HalBtCoexist.h ===== */ -#endif /* __HALBTCOEXIST_C__ */ -#ifdef __HALBT_C__ /* HAL/HalBT.h */ /* ===== Below this line is sync from SD7 driver HAL/HalBT.h ===== */ #define RTS_CTS_NO_LEN_LIMIT 0 @@ -1660,7 +1629,6 @@ void HALBT_InitHwConfig(struct rtw_adapter * padapter); void HALBT_SetRtsCtsNoLenLimit(struct rtw_adapter * padapter); /* ===== End of sync from SD7 driver HAL/HalBT.c ===== */ -#endif /* __HALBT_C__ */ #define _bt_dbg_off_ 0 #define _bt_dbg_on_ 1 -- cgit v1.2.3 From 7ae25994e02e7cc93cf5a17333cd962fbf48309d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:26 +0200 Subject: staging: rtl8723au: rtl8723a_recv.h: Don't put parenthesis around constants Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtl8723a_recv.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/include/rtl8723a_recv.h b/drivers/staging/rtl8723au/include/rtl8723a_recv.h index 6bf6904f4d48..4fbf73140621 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_recv.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_recv.h @@ -18,21 +18,21 @@ #include #include -#define NR_RECVBUFF (4) +#define NR_RECVBUFF 4 -#define NR_PREALLOC_RECV_SKB (8) +#define NR_PREALLOC_RECV_SKB 8 -#define RECV_BLK_SZ 512 -#define RECV_BLK_CNT 16 -#define RECV_BLK_TH RECV_BLK_CNT +#define RECV_BLK_SZ 512 +#define RECV_BLK_CNT 16 +#define RECV_BLK_TH RECV_BLK_CNT -#define MAX_RECVBUF_SZ (15360) /* 15k < 16k */ +#define MAX_RECVBUF_SZ 15360 /* 15k < 16k */ #define RECV_BULK_IN_ADDR 0x80 #define RECV_INT_IN_ADDR 0x81 -#define PHY_RSSI_SLID_WIN_MAX 100 -#define PHY_LINKQUALITY_SLID_WIN_MAX 20 +#define PHY_RSSI_SLID_WIN_MAX 100 +#define PHY_LINKQUALITY_SLID_WIN_MAX 20 struct phy_stat @@ -48,7 +48,7 @@ struct phy_stat }; /* Rx smooth factor */ -#define Rx_Smooth_Factor (20) +#define Rx_Smooth_Factor 20 struct interrupt_msg_format { unsigned int C2H_MSG0; @@ -61,7 +61,7 @@ struct interrupt_msg_format { }; void rtl8723au_init_recvbuf(struct rtw_adapter *padapter, struct recv_buf *precvbuf); -int rtl8723au_init_recv_priv(struct rtw_adapter * padapter); +int rtl8723au_init_recv_priv(struct rtw_adapter * padapter); void rtl8723au_free_recv_priv(struct rtw_adapter * padapter); void rtl8723a_process_phy_info(struct rtw_adapter *padapter, void *prframe); void update_recvframe_attrib(struct recv_frame *precvframe, struct recv_stat *prxstat); -- cgit v1.2.3 From c227ed0a692d0dff7be8c69ccad2e5032eee4a90 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:27 +0200 Subject: staging: rtl8723au: rtw_wlan_util.c: Clean up the code Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 385 ++++++++++++++----------- 1 file changed, 217 insertions(+), 168 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 0241a19d5f56..f8e10b1e192c 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -34,27 +34,33 @@ static unsigned char EPIGRAM_OUI[] = {0x00, 0x90, 0x4c}; unsigned char REALTEK_96B_IE23A[] = {0x00, 0xe0, 0x4c, 0x02, 0x01, 0x20}; -#define R2T_PHY_DELAY (0) +#define R2T_PHY_DELAY 0 -/* define WAIT_FOR_BCN_TO_MIN (3000) */ -#define WAIT_FOR_BCN_TO_MIN (6000) -#define WAIT_FOR_BCN_TO_MAX (20000) +/* define WAIT_FOR_BCN_TO_MIN 3000 */ +#define WAIT_FOR_BCN_TO_MIN 6000 +#define WAIT_FOR_BCN_TO_MAX 20000 static u8 rtw_basic_rate_cck[4] = { - IEEE80211_CCK_RATE_1MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_2MB|IEEE80211_BASIC_RATE_MASK, - IEEE80211_CCK_RATE_5MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_11MB|IEEE80211_BASIC_RATE_MASK + IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK }; static u8 rtw_basic_rate_ofdm[3] = { - IEEE80211_OFDM_RATE_6MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_OFDM_RATE_12MB|IEEE80211_BASIC_RATE_MASK, - IEEE80211_OFDM_RATE_24MB|IEEE80211_BASIC_RATE_MASK + IEEE80211_OFDM_RATE_6MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_OFDM_RATE_12MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_OFDM_RATE_24MB | IEEE80211_BASIC_RATE_MASK }; static u8 rtw_basic_rate_mix[7] = { - IEEE80211_CCK_RATE_1MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_2MB|IEEE80211_BASIC_RATE_MASK, - IEEE80211_CCK_RATE_5MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_11MB|IEEE80211_BASIC_RATE_MASK, - IEEE80211_OFDM_RATE_6MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_OFDM_RATE_12MB|IEEE80211_BASIC_RATE_MASK, - IEEE80211_OFDM_RATE_24MB|IEEE80211_BASIC_RATE_MASK + IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_OFDM_RATE_6MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_OFDM_RATE_12MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_OFDM_RATE_24MB | IEEE80211_BASIC_RATE_MASK }; int cckrates_included23a(unsigned char *rate, int ratelen) @@ -62,8 +68,8 @@ int cckrates_included23a(unsigned char *rate, int ratelen) int i; for (i = 0; i < ratelen; i++) { - if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) || - (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22)) + if (((rate[i]) & 0x7f) == 2 || ((rate[i]) & 0x7f) == 4 || + ((rate[i]) & 0x7f) == 11 || ((rate[i]) & 0x7f) == 22) return true; } @@ -75,8 +81,8 @@ int cckratesonly_included23a(unsigned char *rate, int ratelen) int i; for (i = 0; i < ratelen; i++) { - if ((((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) && - (((rate[i]) & 0x7f) != 11) && (((rate[i]) & 0x7f) != 22)) + if (((rate[i]) & 0x7f) != 2 && ((rate[i]) & 0x7f) != 4 && + ((rate[i]) & 0x7f) != 11 && ((rate[i]) & 0x7f) != 22) return false; } @@ -116,10 +122,11 @@ unsigned char networktype_to_raid23a(unsigned char network_type) return raid; } -u8 judge_network_type23a(struct rtw_adapter *padapter, unsigned char *rate, int ratelen) +u8 judge_network_type23a(struct rtw_adapter *padapter, + unsigned char *rate, int ratelen) { u8 network_type = 0; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (pmlmeext->cur_channel > 14) { @@ -194,7 +201,7 @@ static int is_basicrate(struct rtw_adapter *padapter, unsigned char rate) for (i = 0; i < NumRates; i++) { val = pmlmeext->basicrate[i]; - if ((val != 0xff) && (val != 0xfe)) { + if (val != 0xff && val != 0xfe) { if (rate == ratetbl_val_2wifirate(val)) return true; } @@ -208,7 +215,7 @@ static unsigned int ratetbl2rateset(struct rtw_adapter *padapter, { int i; unsigned char rate; - unsigned int len = 0; + unsigned int len = 0; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; for (i = 0; i < NumRates; i++) { @@ -233,7 +240,8 @@ static unsigned int ratetbl2rateset(struct rtw_adapter *padapter, return len; } -void get_rate_set23a(struct rtw_adapter *padapter, unsigned char *pbssrate, int *bssrate_len) +void get_rate_set23a(struct rtw_adapter *padapter, + unsigned char *pbssrate, int *bssrate_len) { unsigned char supportedrates[NumRates]; @@ -244,8 +252,8 @@ void get_rate_set23a(struct rtw_adapter *padapter, unsigned char *pbssrate, int void UpdateBrateTbl23a(struct rtw_adapter *Adapter, u8 *mBratesOS) { - u8 i; - u8 rate; + u8 i; + u8 rate; /* 1M, 2M, 5.5M, 11M, 6M, 12M, 24M are mandatory. */ for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) { @@ -268,8 +276,8 @@ void UpdateBrateTbl23a(struct rtw_adapter *Adapter, u8 *mBratesOS) void Update23aTblForSoftAP(u8 *bssrateset, u32 bssratelen) { - u8 i; - u8 rate; + u8 i; + u8 rate; for (i = 0; i < bssratelen; i++) { rate = bssrateset[i] & 0x7f; @@ -351,10 +359,11 @@ void set_channel_bwmode23a(struct rtw_adapter *padapter, unsigned char channel, u8 center_ch; if (padapter->bNotifyChannelChange) - DBG_8723A("[%s] ch = %d, offset = %d, bwmode = %d\n", __func__, channel, channel_offset, bwmode); + DBG_8723A("[%s] ch = %d, offset = %d, bwmode = %d\n", + __func__, channel, channel_offset, bwmode); - if ((bwmode == HT_CHANNEL_WIDTH_20) || - (channel_offset == HAL_PRIME_CHNL_OFFSET_DONT_CARE)) { + if (bwmode == HT_CHANNEL_WIDTH_20 || + channel_offset == HAL_PRIME_CHNL_OFFSET_DONT_CARE) { /* SelectChannel23a(padapter, channel); */ center_ch = channel; } else { @@ -400,15 +409,15 @@ inline u8 *get_my_bssid23a(struct wlan_bssid_ex *pnetwork) u16 get_beacon_interval23a(struct wlan_bssid_ex *bss) { unsigned short val; - memcpy((unsigned char *)&val, rtw_get_beacon_interval23a_from_ie(bss->IEs), 2); + memcpy(&val, rtw_get_beacon_interval23a_from_ie(bss->IEs), 2); return le16_to_cpu(val); } int is_client_associated_to_ap23a(struct rtw_adapter *padapter) { - struct mlme_ext_priv *pmlmeext; - struct mlme_ext_info *pmlmeinfo; + struct mlme_ext_priv *pmlmeext; + struct mlme_ext_info *pmlmeinfo; if (!padapter) return _FAIL; @@ -416,7 +425,8 @@ int is_client_associated_to_ap23a(struct rtw_adapter *padapter) pmlmeext = &padapter->mlmeextpriv; pmlmeinfo = &pmlmeext->mlmext_info; - if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE)) + if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS && + (pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) return true; else return _FAIL; @@ -424,11 +434,11 @@ int is_client_associated_to_ap23a(struct rtw_adapter *padapter) int is_client_associated_to_ibss23a(struct rtw_adapter *padapter) { - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && - ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE)) + if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS && + (pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) return true; else return _FAIL; @@ -437,7 +447,7 @@ int is_client_associated_to_ibss23a(struct rtw_adapter *padapter) int is_IBSS_empty23a(struct rtw_adapter *padapter) { unsigned int i; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; for (i = IBSS_START_MAC_ID; i < NUM_STA; i++) { @@ -467,7 +477,9 @@ void clear_cam_entry23a(struct rtw_adapter *padapter, u8 entry) { unsigned char null_sta[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - unsigned char null_key[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + unsigned char null_key[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00}; rtl8723a_cam_write(padapter, entry, 0, null_sta, null_key); } @@ -475,7 +487,7 @@ void clear_cam_entry23a(struct rtw_adapter *padapter, u8 entry) int allocate_fw_sta_entry23a(struct rtw_adapter *padapter) { unsigned int mac_id; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; for (mac_id = IBSS_START_MAC_ID; mac_id < NUM_STA; mac_id++) { @@ -491,19 +503,20 @@ int allocate_fw_sta_entry23a(struct rtw_adapter *padapter) void flush_all_cam_entry23a(struct rtw_adapter *padapter) { - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; rtl8723a_cam_invalid_all(padapter); - memset((u8 *)(pmlmeinfo->FW_sta_info), 0, sizeof(pmlmeinfo->FW_sta_info)); + memset(pmlmeinfo->FW_sta_info, 0, sizeof(pmlmeinfo->FW_sta_info)); } -int WMM_param_handler23a(struct rtw_adapter *padapter, struct ndis_802_11_var_ies * pIE) +int WMM_param_handler23a(struct rtw_adapter *padapter, + struct ndis_802_11_var_ies *pIE) { /* struct registry_priv *pregpriv = &padapter->registrypriv; */ struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (pmlmepriv->qos_option == 0) { @@ -519,15 +532,15 @@ int WMM_param_handler23a(struct rtw_adapter *padapter, struct ndis_802_11_var_ie void WMMOnAssocRsp23a(struct rtw_adapter *padapter) { - u8 ACI, ACM, AIFS, ECWMin, ECWMax, aSifsTime; - u8 acm_mask; - u16 TXOP; - u32 acParm, i; - u32 edca[4], inx[4]; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + u8 ACI, ACM, AIFS, ECWMin, ECWMax, aSifsTime; + u8 acm_mask; + u16 TXOP; + u32 acParm, i; + u32 edca[4], inx[4]; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct registry_priv *pregpriv = &padapter->registrypriv; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct registry_priv *pregpriv = &padapter->registrypriv; if (pmlmeinfo->WMM_enable == 0) { padapter->mlmepriv.acm_mask = 0; @@ -546,9 +559,10 @@ void WMMOnAssocRsp23a(struct rtw_adapter *padapter) ACM = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN >> 4) & 0x01; /* AIFS = AIFSN * slot time + SIFS - r2t phy delay */ - AIFS = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN & 0x0f) * pmlmeinfo->slotTime + aSifsTime; + AIFS = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN & 0x0f) * + pmlmeinfo->slotTime + aSifsTime; - ECWMin = (pmlmeinfo->WMM_param.ac_param[i].CW & 0x0f); + ECWMin = pmlmeinfo->WMM_param.ac_param[i].CW & 0x0f; ECWMax = (pmlmeinfo->WMM_param.ac_param[i].CW & 0xf0) >> 4; TXOP = le16_to_cpu(pmlmeinfo->WMM_param.ac_param[i].TXOP_limit); @@ -588,7 +602,7 @@ void WMMOnAssocRsp23a(struct rtw_adapter *padapter) inx[0] = 0; inx[1] = 1; inx[2] = 2; inx[3] = 3; if (pregpriv->wifi_spec == 1) { - u32 j, tmp, change_inx = false; + u32 j, tmp, change_inx = false; /* entry indx: 0->vo, 1->vi, 2->be, 3->bk. */ for (i = 0; i < 4; i++) { @@ -596,7 +610,8 @@ void WMMOnAssocRsp23a(struct rtw_adapter *padapter) /* compare CW and AIFS */ if ((edca[j] & 0xFFFF) < (edca[i] & 0xFFFF)) { change_inx = true; - } else if ((edca[j] & 0xFFFF) == (edca[i] & 0xFFFF)) { + } else if ((edca[j] & 0xFFFF) == + (edca[i] & 0xFFFF)) { /* compare TXOP */ if ((edca[j] >> 16) > (edca[i] >> 16)) change_inx = true; @@ -619,22 +634,24 @@ void WMMOnAssocRsp23a(struct rtw_adapter *padapter) for (i = 0; i<4; i++) { pxmitpriv->wmm_para_seq[i] = inx[i]; - DBG_8723A("wmm_para_seq(%d): %d\n", i, pxmitpriv->wmm_para_seq[i]); + DBG_8723A("wmm_para_seq(%d): %d\n", i, + pxmitpriv->wmm_para_seq[i]); } return; } -static void bwmode_update_check(struct rtw_adapter *padapter, struct ndis_802_11_var_ies * pIE) +static void bwmode_update_check(struct rtw_adapter *padapter, + struct ndis_802_11_var_ies *pIE) { - struct HT_info_element *pHT_info; + struct HT_info_element *pHT_info; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct registry_priv *pregistrypriv = &padapter->registrypriv; - struct ht_priv *phtpriv = &pmlmepriv->htpriv; - unsigned char new_bwmode; - unsigned char new_ch_offset; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; + unsigned char new_bwmode; + unsigned char new_ch_offset; if (!pIE) return; @@ -664,8 +681,8 @@ static void bwmode_update_check(struct rtw_adapter *padapter, struct ndis_802_11 new_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; } - if ((new_bwmode!= pmlmeext->cur_bwmode) || - (new_ch_offset!= pmlmeext->cur_ch_offset)) { + if (new_bwmode != pmlmeext->cur_bwmode || + new_ch_offset != pmlmeext->cur_ch_offset) { pmlmeinfo->bwmode_updated = true; pmlmeext->cur_bwmode = new_bwmode; @@ -673,52 +690,56 @@ static void bwmode_update_check(struct rtw_adapter *padapter, struct ndis_802_11 /* update HT info also */ HT_info_handler23a(padapter, pIE); - } else { + } else pmlmeinfo->bwmode_updated = false; - } if (pmlmeinfo->bwmode_updated) { struct sta_info *psta; struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; struct sta_priv *pstapriv = &padapter->stapriv; - /* set_channel_bwmode23a(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); */ + /* set_channel_bwmode23a(padapter, pmlmeext->cur_channel, + pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); */ /* update ap's stainfo */ psta = rtw_get_stainfo23a(pstapriv, cur_network->MacAddress); if (psta) { - struct ht_priv *phtpriv_sta = &psta->htpriv; + struct ht_priv *phtpriv_sta = &psta->htpriv; if (phtpriv_sta->ht_option) { /* bwmode */ phtpriv_sta->bwmode = pmlmeext->cur_bwmode; - phtpriv_sta->ch_offset = pmlmeext->cur_ch_offset; + phtpriv_sta->ch_offset = + pmlmeext->cur_ch_offset; } else { phtpriv_sta->bwmode = HT_CHANNEL_WIDTH_20; - phtpriv_sta->ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + phtpriv_sta->ch_offset = + HAL_PRIME_CHNL_OFFSET_DONT_CARE; } - } } } -void HT_caps_handler23a(struct rtw_adapter *padapter, struct ndis_802_11_var_ies * pIE) +void HT_caps_handler23a(struct rtw_adapter *padapter, + struct ndis_802_11_var_ies * pIE) { - unsigned int i; - u8 rf_type; - u8 max_AMPDU_len, min_MPDU_spacing; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + unsigned int i; + u8 rf_type; + u8 max_AMPDU_len, min_MPDU_spacing; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct ht_priv *phtpriv = &pmlmepriv->htpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; - if (pIE == NULL) return; + if (!pIE) + return; - if (phtpriv->ht_option == false) return; + if (phtpriv->ht_option == false) + return; pmlmeinfo->HT_caps_enable = 1; - for (i = 0; i < (pIE->Length); i++) { + for (i = 0; i < pIE->Length; i++) { if (i != 2) { /* Commented by Albert 2010/07/12 */ /* Got the endian issue here. */ @@ -726,12 +747,12 @@ void HT_caps_handler23a(struct rtw_adapter *padapter, struct ndis_802_11_var_ies } else { /* modify from fw by Thomas 2010/11/17 */ if ((pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x3) > (pIE->data[i] & 0x3)) - max_AMPDU_len = (pIE->data[i] & 0x3); + max_AMPDU_len = pIE->data[i] & 0x3; else - max_AMPDU_len = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x3); + max_AMPDU_len = pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x3; if ((pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) > (pIE->data[i] & 0x1c)) - min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c); + min_MPDU_spacing = pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c; else min_MPDU_spacing = (pIE->data[i] & 0x1c); @@ -742,31 +763,38 @@ void HT_caps_handler23a(struct rtw_adapter *padapter, struct ndis_802_11_var_ies /* Commented by Albert 2010/07/12 */ /* Have to handle the endian issue after copying. */ /* HT_ext_caps didn't be used yet. */ - pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info = le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info); - pmlmeinfo->HT_caps.u.HT_cap_element.HT_ext_caps = le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_ext_caps); + pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info = + le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info); + pmlmeinfo->HT_caps.u.HT_cap_element.HT_ext_caps = + le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_ext_caps); rf_type = rtl8723a_get_rf_type(padapter); /* update the MCS rates */ for (i = 0; i < 16; i++) { - if ((rf_type == RF_1T1R) || (rf_type == RF_1T2R)) - pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= MCS_rate_1R23A[i]; + if (rf_type == RF_1T1R || rf_type == RF_1T2R) + pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= + MCS_rate_1R23A[i]; else - pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= MCS_rate_2R23A[i]; + pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= + MCS_rate_2R23A[i]; } return; } -void HT_info_handler23a(struct rtw_adapter *padapter, struct ndis_802_11_var_ies * pIE) +void HT_info_handler23a(struct rtw_adapter *padapter, + struct ndis_802_11_var_ies *pIE) { - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct ht_priv *phtpriv = &pmlmepriv->htpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; - if (pIE == NULL) return; + if (!pIE) + return; - if (phtpriv->ht_option == false) return; + if (phtpriv->ht_option == false) + return; if (pIE->Length > sizeof(struct HT_info_element)) return; @@ -778,19 +806,20 @@ void HT_info_handler23a(struct rtw_adapter *padapter, struct ndis_802_11_var_ies void HTOnAssocRsp23a(struct rtw_adapter *padapter) { - unsigned char max_AMPDU_len; - unsigned char min_MPDU_spacing; + unsigned char max_AMPDU_len; + unsigned char min_MPDU_spacing; /* struct registry_priv *pregpriv = &padapter->registrypriv; */ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; DBG_8723A("%s\n", __func__); - if ((pmlmeinfo->HT_info_enable) && (pmlmeinfo->HT_caps_enable)) { + if (pmlmeinfo->HT_info_enable && pmlmeinfo->HT_caps_enable) pmlmeinfo->HT_enable = 1; - } else { + else { pmlmeinfo->HT_enable = 0; - /* set_channel_bwmode23a(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); */ + /* set_channel_bwmode23a(padapter, pmlmeext->cur_channel, + pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); */ return; } @@ -801,18 +830,20 @@ void HTOnAssocRsp23a(struct rtw_adapter *padapter) */ max_AMPDU_len = pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x03; - min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) >> 2; + min_MPDU_spacing = + (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) >> 2; rtl8723a_set_ampdu_min_space(padapter, min_MPDU_spacing); rtl8723a_set_ampdu_factor(padapter, max_AMPDU_len); } -void ERP_IE_handler23a(struct rtw_adapter *padapter, struct ndis_802_11_var_ies * pIE) +void ERP_IE_handler23a(struct rtw_adapter *padapter, + struct ndis_802_11_var_ies *pIE) { - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - if (pIE->Length>1) + if (pIE->Length > 1) return; pmlmeinfo->ERP_enable = 1; @@ -821,8 +852,8 @@ void ERP_IE_handler23a(struct rtw_adapter *padapter, struct ndis_802_11_var_ies void VCS_update23a(struct rtw_adapter *padapter, struct sta_info *psta) { - struct registry_priv *pregpriv = &padapter->registrypriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct registry_priv *pregpriv = &padapter->registrypriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; switch (pregpriv->vrtl_carrier_sense) { /* 0:off 1:on 2:auto */ @@ -841,7 +872,7 @@ void VCS_update23a(struct rtw_adapter *padapter, struct sta_info *psta) break; case 2: /* auto */ default: - if ((pmlmeinfo->ERP_enable) && (pmlmeinfo->ERP_IE & BIT(1))) { + if (pmlmeinfo->ERP_enable && pmlmeinfo->ERP_IE & BIT(1)) { if (pregpriv->vcs_type == 1) { psta->rtsen = 1; psta->cts2self = 0; @@ -1137,22 +1168,27 @@ void update_beacon23a_info(struct rtw_adapter *padapter, u8 *pframe, uint pkt_le unsigned int is_ap_in_tkip23a(struct rtw_adapter *padapter) { u32 i; - struct ndis_802_11_var_ies * pIE; + struct ndis_802_11_var_ies *pIE; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; if (rtw_get_capability23a(cur_network) & WLAN_CAPABILITY_PRIVACY) { - for (i = sizeof(struct ndis_802_11_fixed_ies); i < pmlmeinfo->network.IELength;) { - pIE = (struct ndis_802_11_var_ies *)(pmlmeinfo->network.IEs + i); + for (i = sizeof(struct ndis_802_11_fixed_ies); + i < pmlmeinfo->network.IELength;) { + pIE = (struct ndis_802_11_var_ies *) + (pmlmeinfo->network.IEs + i); switch (pIE->ElementID) { case WLAN_EID_VENDOR_SPECIFIC: - if ((!memcmp(pIE->data, RTW_WPA_OUI23A_TYPE, 4)) && (!memcmp((pIE->data + 12), WPA_TKIP_CIPHER23A, 4))) + if (!memcmp(pIE->data, RTW_WPA_OUI23A_TYPE, 4)&& + !memcmp((pIE->data + 12), + WPA_TKIP_CIPHER23A, 4)) return true; break; case WLAN_EID_RSN: - if (!memcmp((pIE->data + 8), RSN_TKIP_CIPHER23A, 4)) + if (!memcmp(pIE->data + 8, RSN_TKIP_CIPHER23A, + 4)) return true; break; default: @@ -1161,32 +1197,37 @@ unsigned int is_ap_in_tkip23a(struct rtw_adapter *padapter) i += (pIE->Length + 2); } return false; - } else { + } else return false; - } } unsigned int should_forbid_n_rate23a(struct rtw_adapter * padapter) { u32 i; - struct ndis_802_11_var_ies * pIE; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct ndis_802_11_var_ies *pIE; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_bssid_ex *cur_network = &pmlmepriv->cur_network.network; if (rtw_get_capability23a(cur_network) & WLAN_CAPABILITY_PRIVACY) { - for (i = sizeof(struct ndis_802_11_fixed_ies); i < cur_network->IELength;) { - pIE = (struct ndis_802_11_var_ies *)(cur_network->IEs + i); + for (i = sizeof(struct ndis_802_11_fixed_ies); + i < cur_network->IELength;) { + pIE = (struct ndis_802_11_var_ies *) + (cur_network->IEs + i); switch (pIE->ElementID) { case WLAN_EID_VENDOR_SPECIFIC: - if (!memcmp(pIE->data, RTW_WPA_OUI23A_TYPE, 4) && - ((!memcmp((pIE->data + 12), WPA_CIPHER_SUITE_CCMP23A, 4)) || - (!memcmp((pIE->data + 16), WPA_CIPHER_SUITE_CCMP23A, 4)))) + if (!memcmp(pIE->data, RTW_WPA_OUI23A_TYPE, 4)&& + (!memcmp(pIE->data + 12, + WPA_CIPHER_SUITE_CCMP23A, 4) || + !memcmp(pIE->data + 16, + WPA_CIPHER_SUITE_CCMP23A, 4))) return false; break; case WLAN_EID_RSN: - if ((!memcmp((pIE->data + 8), RSN_CIPHER_SUITE_CCMP23A, 4)) || - (!memcmp((pIE->data + 12), RSN_CIPHER_SUITE_CCMP23A, 4))) + if (!memcmp(pIE->data + 8, + RSN_CIPHER_SUITE_CCMP23A, 4) || + !memcmp(pIE->data + 12, + RSN_CIPHER_SUITE_CCMP23A, 4)) return false; default: break; @@ -1203,14 +1244,16 @@ unsigned int should_forbid_n_rate23a(struct rtw_adapter * padapter) unsigned int is_ap_in_wep23a(struct rtw_adapter *padapter) { u32 i; - struct ndis_802_11_var_ies * pIE; + struct ndis_802_11_var_ies *pIE; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; if (rtw_get_capability23a(cur_network) & WLAN_CAPABILITY_PRIVACY) { - for (i = sizeof(struct ndis_802_11_fixed_ies); i < pmlmeinfo->network.IELength;) { - pIE = (struct ndis_802_11_var_ies *)(pmlmeinfo->network.IEs + i); + for (i = sizeof(struct ndis_802_11_fixed_ies); + i < pmlmeinfo->network.IELength;) { + pIE = (struct ndis_802_11_var_ies *) + (pmlmeinfo->network.IEs + i); switch (pIE->ElementID) { case WLAN_EID_VENDOR_SPECIFIC: @@ -1228,14 +1271,13 @@ unsigned int is_ap_in_wep23a(struct rtw_adapter *padapter) } return true; - } else { + } else return false; - } } static int wifirate2_ratetbl_inx23a(unsigned char rate) { - int inx = 0; + int inx = 0; rate = rate & 0x7f; switch (rate) { @@ -1298,7 +1340,7 @@ unsigned int update_supported_rate23a(unsigned char *ptn, unsigned int ptn_sz) unsigned int i, num_of_rate; unsigned int mask = 0; - num_of_rate = (ptn_sz > NumRates)? NumRates: ptn_sz; + num_of_rate = (ptn_sz > NumRates) ? NumRates : ptn_sz; for (i = 0; i < num_of_rate; i++) mask |= 0x1 << wifirate2_ratetbl_inx23a(*(ptn + i)); @@ -1309,21 +1351,22 @@ unsigned int update_MSC_rate23a(struct HT_caps_element *pHT_caps) { unsigned int mask = 0; - mask = ((pHT_caps->u.HT_cap_element.MCS_rate[0] << 12) | (pHT_caps->u.HT_cap_element.MCS_rate[1] << 20)); + mask = pHT_caps->u.HT_cap_element.MCS_rate[0] << 12 | + pHT_caps->u.HT_cap_element.MCS_rate[1] << 20; return mask; } int support_short_GI23a(struct rtw_adapter *padapter, - struct HT_caps_element *pHT_caps) + struct HT_caps_element *pHT_caps) { - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; unsigned char bit_offset; - if (!(pmlmeinfo->HT_enable)) + if (!pmlmeinfo->HT_enable) return _FAIL; - if ((pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_RALINK)) + if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_RALINK) return _FAIL; bit_offset = (pmlmeext->cur_bwmode & HT_CHANNEL_WIDTH_40)? 6: 5; @@ -1389,10 +1432,10 @@ void update_tx_basic_rate23a(struct rtw_adapter *padapter, u8 wirelessmode) unsigned char check_assoc_AP23a(u8 *pframe, uint len) { - unsigned int i; - struct ndis_802_11_var_ies * pIE; - u8 epigram_vendor_flag; - u8 ralink_vendor_flag; + unsigned int i; + struct ndis_802_11_var_ies *pIE; + u8 epigram_vendor_flag; + u8 ralink_vendor_flag; epigram_vendor_flag = 0; ralink_vendor_flag = 0; @@ -1401,11 +1444,11 @@ unsigned char check_assoc_AP23a(u8 *pframe, uint len) switch (pIE->ElementID) { case WLAN_EID_VENDOR_SPECIFIC: - if ((!memcmp(pIE->data, ARTHEROS_OUI1, 3)) || - (!memcmp(pIE->data, ARTHEROS_OUI2, 3))) { + if (!memcmp(pIE->data, ARTHEROS_OUI1, 3) || + !memcmp(pIE->data, ARTHEROS_OUI2, 3)) { DBG_8723A("link to Artheros AP\n"); return HT_IOT_PEER_ATHEROS; - } else if ((!memcmp(pIE->data, BROADCOM_OUI1, 3)) || + } else if (!memcmp(pIE->data, BROADCOM_OUI1, 3) || !memcmp(pIE->data, BROADCOM_OUI2, 3) || !memcmp(pIE->data, BROADCOM_OUI2, 3)) { DBG_8723A("link to Broadcom AP\n"); @@ -1414,9 +1457,9 @@ unsigned char check_assoc_AP23a(u8 *pframe, uint len) DBG_8723A("link to Marvell AP\n"); return HT_IOT_PEER_MARVELL; } else if (!memcmp(pIE->data, RALINK_OUI, 3)) { - if (!ralink_vendor_flag) { + if (!ralink_vendor_flag) ralink_vendor_flag = 1; - } else { + else { DBG_8723A("link to Ralink AP\n"); return HT_IOT_PEER_RALINK; } @@ -1434,12 +1477,10 @@ unsigned char check_assoc_AP23a(u8 *pframe, uint len) if (ralink_vendor_flag) { DBG_8723A("link to Tenda W311R AP\n"); return HT_IOT_PEER_TENDA; - } else { + } else DBG_8723A("Capture EPIGRAM_OUI\n"); - } - } else { + } else break; - } default: break; } @@ -1461,7 +1502,7 @@ unsigned char check_assoc_AP23a(u8 *pframe, uint len) void update_IOT_info23a(struct rtw_adapter *padapter) { - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; switch (pmlmeinfo->assoc_AP_vendor) { @@ -1492,7 +1533,7 @@ void update_IOT_info23a(struct rtw_adapter *padapter) void update_capinfo23a(struct rtw_adapter *Adapter, u16 updateCap) { - struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (updateCap & cShortPreamble) { @@ -1514,15 +1555,18 @@ void update_capinfo23a(struct rtw_adapter *Adapter, u16 updateCap) pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME; } else { /* Filen: See 802.11-2007 p.90 */ - if (pmlmeext->cur_wireless_mode & (WIRELESS_11G | WIRELESS_11_24N)) { + if (pmlmeext->cur_wireless_mode & + (WIRELESS_11G | WIRELESS_11_24N)) { if (updateCap & cShortSlotTime) { /* Short Slot Time */ if (pmlmeinfo->slotTime != SHORT_SLOT_TIME) pmlmeinfo->slotTime = SHORT_SLOT_TIME; } else { /* Long Slot Time */ if (pmlmeinfo->slotTime != NON_SHORT_SLOT_TIME) - pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME; + pmlmeinfo->slotTime = + NON_SHORT_SLOT_TIME; } - } else if (pmlmeext->cur_wireless_mode & (WIRELESS_11A | WIRELESS_11_5N)) { + } else if (pmlmeext->cur_wireless_mode & + (WIRELESS_11A | WIRELESS_11_5N)) { pmlmeinfo->slotTime = SHORT_SLOT_TIME; } else { /* B Mode */ @@ -1535,10 +1579,10 @@ void update_capinfo23a(struct rtw_adapter *Adapter, u16 updateCap) void update_wireless_mode23a(struct rtw_adapter *padapter) { int ratelen, network_type = 0; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; - unsigned char *rate = cur_network->SupportedRates; + unsigned char *rate = cur_network->SupportedRates; ratelen = rtw_get_rateset_len23a(cur_network->SupportedRates); @@ -1553,15 +1597,16 @@ void update_wireless_mode23a(struct rtw_adapter *padapter) if (pmlmeinfo->HT_enable) network_type = WIRELESS_11_24N; - if ((cckratesonly_included23a(rate, ratelen)) == true) + if (cckratesonly_included23a(rate, ratelen) == true) network_type |= WIRELESS_11B; - else if ((cckrates_included23a(rate, ratelen)) == true) + else if (cckrates_included23a(rate, ratelen) == true) network_type |= WIRELESS_11BG; else network_type |= WIRELESS_11G; } - pmlmeext->cur_wireless_mode = network_type & padapter->registrypriv.wireless_mode; + pmlmeext->cur_wireless_mode = + network_type & padapter->registrypriv.wireless_mode; /* 0x0808 -> for CCK, 0x0a0a -> for OFDM */ /* change this value if having IOT issues. */ @@ -1583,7 +1628,7 @@ void update_bmc_sta_support_rate23a(struct rtw_adapter *padapter, u32 mac_id) memcpy((pmlmeinfo->FW_sta_info[mac_id].SupportedRates), rtw_basic_rate_cck, 4); } else { - memcpy((pmlmeinfo->FW_sta_info[mac_id].SupportedRates), + memcpy(pmlmeinfo->FW_sta_info[mac_id].SupportedRates, rtw_basic_rate_ofdm, 3); } } @@ -1610,14 +1655,15 @@ int update_sta_support_rate23a(struct rtw_adapter *padapter, u8 *pvar_ie, return _SUCCESS; } -void process_addba_req23a(struct rtw_adapter *padapter, u8 *paddba_req, u8 *addr) +void process_addba_req23a(struct rtw_adapter *padapter, + u8 *paddba_req, u8 *addr) { struct sta_info *psta; u16 tid, start_seq, param; struct recv_reorder_ctrl *preorder_ctrl; struct sta_priv *pstapriv = &padapter->stapriv; - struct ADDBA_request *preq = (struct ADDBA_request*)paddba_req; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct ADDBA_request *preq = (struct ADDBA_request*)paddba_req; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; psta = rtw_get_stainfo23a(pstapriv, addr); @@ -1626,13 +1672,14 @@ void process_addba_req23a(struct rtw_adapter *padapter, u8 *paddba_req, u8 *addr start_seq = le16_to_cpu(preq->BA_starting_seqctrl) >> 4; param = le16_to_cpu(preq->BA_para_set); - tid = (param>>2)&0x0f; + tid = (param >> 2) & 0x0f; preorder_ctrl = &psta->recvreorder_ctrl[tid]; preorder_ctrl->indicate_seq = 0xffff; - preorder_ctrl->enable = (pmlmeinfo->bAcceptAddbaReq == true)? true :false; + preorder_ctrl->enable = (pmlmeinfo->bAcceptAddbaReq == true) ? + true : false; } } @@ -1650,16 +1697,18 @@ int rtw_handle_dualmac23a(struct rtw_adapter *adapter, bool init) if (init) { if (pbuddy_padapter == NULL) { pbuddy_padapter = adapter; - DBG_8723A("%s(): pbuddy_padapter == NULL, Set pbuddy_padapter\n", __func__); + DBG_8723A("%s(): pbuddy_padapter == NULL, " + "Set pbuddy_padapter\n", __func__); } else { adapter->pbuddy_adapter = pbuddy_padapter; pbuddy_padapter->pbuddy_adapter = adapter; /* clear global value */ pbuddy_padapter = NULL; - DBG_8723A("%s(): pbuddy_padapter exist, Exchange Information\n", __func__); + DBG_8723A("%s(): pbuddy_padapter exist, " + "Exchange Information\n", __func__); } - } else { + } else pbuddy_padapter = NULL; - } + return status; } -- cgit v1.2.3 From ff516e707691c8d56585bcad47a987eabe115b44 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:28 +0200 Subject: staging: rtl8723au: Remove redundant check Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index f8e10b1e192c..161a2eb1363e 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -1414,7 +1414,7 @@ void update_tx_basic_rate23a(struct rtw_adapter *padapter, u8 wirelessmode) memset(supported_rates, 0, NDIS_802_11_LENGTH_RATES_EX); - if ((wirelessmode & WIRELESS_11B) && (wirelessmode == WIRELESS_11B)) { + if (wirelessmode == WIRELESS_11B) { memcpy(supported_rates, rtw_basic_rate_cck, 4); } else if (wirelessmode & WIRELESS_11B) { memcpy(supported_rates, rtw_basic_rate_mix, 7); -- cgit v1.2.3 From 222203206e8c86865fa1a714b1c5b2813ac5fbab Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:29 +0200 Subject: staging: rtl8723au: Declare validate_recv_*_frame() static Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_recv.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 3791bbbdc582..76873664d432 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -1111,10 +1111,8 @@ exit: return ret; } -int validate_recv_ctrl_frame(struct rtw_adapter *padapter, - struct recv_frame *precv_frame); -int validate_recv_ctrl_frame(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int validate_recv_ctrl_frame(struct rtw_adapter *padapter, + struct recv_frame *precv_frame) { #ifdef CONFIG_8723AU_AP_MODE struct rx_pkt_attrib *pattrib = &precv_frame->attrib; @@ -1259,10 +1257,8 @@ int validate_recv_ctrl_frame(struct rtw_adapter *padapter, struct recv_frame* recvframe_chk_defrag23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -int validate_recv_mgnt_frame(struct rtw_adapter *padapter, - struct recv_frame *precv_frame); -int validate_recv_mgnt_frame(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int validate_recv_mgnt_frame(struct rtw_adapter *padapter, + struct recv_frame *precv_frame) { struct sta_info *psta; struct sk_buff *skb; @@ -1308,10 +1304,8 @@ int validate_recv_mgnt_frame(struct rtw_adapter *padapter, return _SUCCESS; } -int validate_recv_data_frame(struct rtw_adapter *adapter, - struct recv_frame *precv_frame); -int validate_recv_data_frame(struct rtw_adapter *adapter, - struct recv_frame *precv_frame) +static int validate_recv_data_frame(struct rtw_adapter *adapter, + struct recv_frame *precv_frame) { u8 bretry; u8 *psa, *pda, *pbssid; -- cgit v1.2.3 From 5ca12b78995aeb9cbe5c127342e8ca27f1e6d038 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:30 +0200 Subject: staging: rtl8723au: Remove to_fr_ds packet attribute This is only used in one place - do the work there properly. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_recv.c | 18 ++++++------------ drivers/staging/rtl8723au/include/rtw_recv.h | 1 - drivers/staging/rtl8723au/include/wifi.h | 3 --- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 76873664d432..fd0958b675d5 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -1334,36 +1334,32 @@ static int validate_recv_data_frame(struct rtw_adapter *adapter, ether_addr_copy(pattrib->bssid, pbssid); - switch (pattrib->to_fr_ds) - { - case 0: + switch (hdr->frame_control & + cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) { + case cpu_to_le16(0): ether_addr_copy(pattrib->ra, pda); ether_addr_copy(pattrib->ta, psa); ret = sta2sta_data_frame(adapter, precv_frame, &psta); break; - case 1: + case cpu_to_le16(IEEE80211_FCTL_FROMDS): ether_addr_copy(pattrib->ra, pda); ether_addr_copy(pattrib->ta, pbssid); ret = ap2sta_data_frame(adapter, precv_frame, &psta); break; - case 2: + case cpu_to_le16(IEEE80211_FCTL_TODS): ether_addr_copy(pattrib->ra, pbssid); ether_addr_copy(pattrib->ta, psa); ret = sta2ap_data_frame(adapter, precv_frame, &psta); break; - case 3: + case cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS): ether_addr_copy(pattrib->ra, hdr->addr1); ether_addr_copy(pattrib->ta, hdr->addr2); ret = _FAIL; RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" case 3\n")); break; - - default: - ret = _FAIL; - break; } if ((ret == _FAIL) || (ret == RTW_RX_HANDLED)) @@ -1524,8 +1520,6 @@ static int validate_recv_frame(struct rtw_adapter *adapter, goto exit; } - pattrib->to_fr_ds = get_tofr_ds(hdr->frame_control); - seq_ctrl = le16_to_cpu(hdr->seq_ctrl); pattrib->frag_num = seq_ctrl & IEEE80211_SCTL_FRAG; pattrib->seq_num = seq_ctrl >> 4; diff --git a/drivers/staging/rtl8723au/include/rtw_recv.h b/drivers/staging/rtl8723au/include/rtw_recv.h index 1f18af8dcc04..0a88506ab859 100644 --- a/drivers/staging/rtl8723au/include/rtw_recv.h +++ b/drivers/staging/rtl8723au/include/rtw_recv.h @@ -99,7 +99,6 @@ struct rx_pkt_attrib { u8 drvinfo_sz; u8 shift_sz; u8 hdrlen; /* the WLAN Header Len */ - u8 to_fr_ds; u8 amsdu; u8 qos; u8 priority; diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index aebc05d8a123..e7c34b73ff1d 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -87,9 +87,6 @@ enum WIFI_REG_DOMAIN { #define SetFrDs(pbuf) \ (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_FROMDS)) -#define get_tofr_ds(pframe) ((ieee80211_has_tods(pframe) << 1) | \ - ieee80211_has_fromds(pframe)) - #define SetMFrag(pbuf) \ (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) -- cgit v1.2.3 From aa66fbb956d4b464d39176045c2b431da56f358f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:31 +0200 Subject: staging: rtl8723au: validate_recv_data_frame() use fctl knowledge to obtain bssid Use the knowledge we already have from parsing the TODS/FROMDS bits in hdr->frame_control to obtain the bssid. Note that get_hdr_bssid() would never return NULL as handling 4 combinations of a 2 bit word leaves little space for falling through to the 'default' value. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_recv.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index fd0958b675d5..3376a65d956a 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -1308,9 +1308,8 @@ static int validate_recv_data_frame(struct rtw_adapter *adapter, struct recv_frame *precv_frame) { u8 bretry; - u8 *psa, *pda, *pbssid; + u8 *psa, *pda; struct sta_info *psta = NULL; - u8 *ptr = precv_frame->pkt->data; struct rx_pkt_attrib *pattrib = & precv_frame->attrib; struct security_priv *psecuritypriv = &adapter->securitypriv; int ret = _SUCCESS; @@ -1322,39 +1321,39 @@ static int validate_recv_data_frame(struct rtw_adapter *adapter, bretry = ieee80211_has_retry(hdr->frame_control); pda = ieee80211_get_DA(hdr); psa = ieee80211_get_SA(hdr); - pbssid = get_hdr_bssid(ptr); - - if (pbssid == NULL) { - ret = _FAIL; - goto exit; - } ether_addr_copy(pattrib->dst, pda); ether_addr_copy(pattrib->src, psa); - ether_addr_copy(pattrib->bssid, pbssid); - switch (hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) { case cpu_to_le16(0): + ether_addr_copy(pattrib->bssid, hdr->addr3); ether_addr_copy(pattrib->ra, pda); ether_addr_copy(pattrib->ta, psa); ret = sta2sta_data_frame(adapter, precv_frame, &psta); break; case cpu_to_le16(IEEE80211_FCTL_FROMDS): + ether_addr_copy(pattrib->bssid, hdr->addr2); ether_addr_copy(pattrib->ra, pda); - ether_addr_copy(pattrib->ta, pbssid); + ether_addr_copy(pattrib->ta, hdr->addr2); ret = ap2sta_data_frame(adapter, precv_frame, &psta); break; case cpu_to_le16(IEEE80211_FCTL_TODS): - ether_addr_copy(pattrib->ra, pbssid); + ether_addr_copy(pattrib->bssid, hdr->addr1); + ether_addr_copy(pattrib->ra, hdr->addr1); ether_addr_copy(pattrib->ta, psa); ret = sta2ap_data_frame(adapter, precv_frame, &psta); break; case cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS): + /* + * There is no BSSID in this case, but the driver has been + * using addr1 so far, so keep it for now. + */ + ether_addr_copy(pattrib->bssid, hdr->addr1); ether_addr_copy(pattrib->ra, hdr->addr1); ether_addr_copy(pattrib->ta, hdr->addr2); ret = _FAIL; -- cgit v1.2.3 From b307108165cf98f70238900593719b15d7dd4075 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:32 +0200 Subject: staging: rtl8723au: update_recvframe_phyinfo(): Don't set variables twice Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723au_recv.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_recv.c b/drivers/staging/rtl8723au/hal/rtl8723au_recv.c index 1b5b83619c89..6857e5e7dfeb 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723au_recv.c +++ b/drivers/staging/rtl8723au/hal/rtl8723au_recv.c @@ -203,10 +203,6 @@ void update_recvframe_phyinfo(struct recv_frame *precvframe, struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; u8 *wlanhdr = skb->data; - pkt_info.bPacketMatchBSSID = false; - pkt_info.bPacketToSelf = false; - pkt_info.bPacketBeacon = false; - pkt_info.bPacketMatchBSSID = (!ieee80211_is_ctl(hdr->frame_control) && !pattrib->icv_err && -- cgit v1.2.3 From 9c4a961debe9ec8a6b87fa921396e170d7d5cf93 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:33 +0200 Subject: staging: rtl8723au: Fold get_hdr_bssid() into update_recvframe_phyinfo() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723au_recv.c | 38 ++++++++++++++++++++------ drivers/staging/rtl8723au/include/wifi.h | 29 -------------------- 2 files changed, 30 insertions(+), 37 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_recv.c b/drivers/staging/rtl8723au/hal/rtl8723au_recv.c index 6857e5e7dfeb..3a266abe9ad5 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723au_recv.c +++ b/drivers/staging/rtl8723au/hal/rtl8723au_recv.c @@ -201,14 +201,36 @@ void update_recvframe_phyinfo(struct recv_frame *precvframe, struct sta_info *psta; struct sk_buff *skb = precvframe->pkt; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - u8 *wlanhdr = skb->data; - - pkt_info.bPacketMatchBSSID = - (!ieee80211_is_ctl(hdr->frame_control) && - !pattrib->icv_err && - !pattrib->crc_err && - !memcmp(get_hdr_bssid(wlanhdr), - get_bssid(&padapter->mlmepriv), ETH_ALEN)); + bool matchbssid = false; + u8 *bssid; + + matchbssid = (!ieee80211_is_ctl(hdr->frame_control) && + !pattrib->icv_err && !pattrib->crc_err); + + if (matchbssid) { + switch (hdr->frame_control & + cpu_to_le16(IEEE80211_FCTL_TODS | + IEEE80211_FCTL_FROMDS)) { + case cpu_to_le16(IEEE80211_FCTL_TODS): + bssid = hdr->addr1; + break; + case cpu_to_le16(IEEE80211_FCTL_FROMDS): + bssid = hdr->addr2; + break; + case cpu_to_le16(0): + bssid = hdr->addr3; + break; + default: + bssid = NULL; + matchbssid = false; + } + + if (bssid) + matchbssid = ether_addr_equal( + get_bssid(&padapter->mlmepriv), bssid); + } + + pkt_info.bPacketMatchBSSID = matchbssid; da = ieee80211_get_DA(hdr); pkt_info.bPacketToSelf = pkt_info.bPacketMatchBSSID && diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index e7c34b73ff1d..1c1b2f6a2287 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -158,35 +158,6 @@ enum WIFI_REG_DOMAIN { (((ieee80211_has_tods(pbuf)<<1) | \ ieee80211_has_fromds(pbuf)) == 3 ? 30 : 24))) & 0x000f) -static inline unsigned char *get_hdr_bssid(unsigned char *pframe) -{ - unsigned char *sa; - unsigned int to_fr_ds; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) pframe; - - to_fr_ds = (ieee80211_has_tods(hdr->frame_control) << 1) | - ieee80211_has_fromds(hdr->frame_control); - - switch (to_fr_ds) { - case 0x00: /* ToDs=0, FromDs=0 */ - sa = hdr->addr3; - break; - case 0x01: /* ToDs=0, FromDs=1 */ - sa = hdr->addr2; - break; - case 0x02: /* ToDs=1, FromDs=0 */ - sa = hdr->addr1; - break; - case 0x03: /* ToDs=1, FromDs=1 */ - sa = hdr->addr1; - break; - default: - sa = NULL; /* */ - break; - } - return sa; -} - /*----------------------------------------------------------------------------- Below is for the security related definition ------------------------------------------------------------------------------*/ -- cgit v1.2.3 From c51e886fe17808d67ad05748d0c542c51f057283 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:34 +0200 Subject: staging: rtl8723au: Use struct ieee80211_pspoll to obtain 'aid' Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_recv.c | 6 +++--- drivers/staging/rtl8723au/include/wifi.h | 4 ---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 3376a65d956a..0999cf2311c7 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -1119,7 +1119,6 @@ static int validate_recv_ctrl_frame(struct rtw_adapter *padapter, struct sta_priv *pstapriv = &padapter->stapriv; struct sk_buff *skb = precv_frame->pkt; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - u8 *pframe = skb->data; if (!ieee80211_is_ctl(hdr->frame_control)) return _FAIL; @@ -1130,14 +1129,15 @@ static int validate_recv_ctrl_frame(struct rtw_adapter *padapter, /* only handle ps-poll */ if (ieee80211_is_pspoll(hdr->frame_control)) { + struct ieee80211_pspoll *psp = (struct ieee80211_pspoll *)hdr; u16 aid; u8 wmmps_ac = 0; struct sta_info *psta = NULL; - aid = GetAid(pframe); + aid = le16_to_cpu(psp->aid) & 0x3fff; psta = rtw_get_stainfo23a(pstapriv, hdr->addr2); - if ((!psta) || (psta->aid != aid)) + if (!psta || psta->aid != aid) return _FAIL; /* for rx pkt statistics */ diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index 1c1b2f6a2287..4657b2265672 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -149,10 +149,6 @@ enum WIFI_REG_DOMAIN { #define SetAMsdu(pbuf, amsdu) \ (*(__le16 *)(pbuf) |= cpu_to_le16((amsdu & 1) << 7)) -#define GetAid(pbuf) \ - (cpu_to_le16(*(unsigned short *)((unsigned long)(pbuf) + 2)) & \ - 0x3fff) - #define GetTid(pbuf) \ (cpu_to_le16(*(unsigned short *)((unsigned long)(pbuf) + \ (((ieee80211_has_tods(pbuf)<<1) | \ -- cgit v1.2.3 From be1bc0c9d6e2116f5c17564216345f75afba2ea1 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:35 +0200 Subject: staging: rtl8723au: wifi.h: remove more unused #defines Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/wifi.h | 53 -------------------------------- 1 file changed, 53 deletions(-) diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index 4657b2265672..4eb36336ca65 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -117,8 +117,6 @@ enum WIFI_REG_DOMAIN { *(__le16 *)(pbuf) |= cpu_to_le16(type); \ } while (0) -#define GetTupleCache(pbuf) (cpu_to_le16(*(unsigned short *)((unsigned long)(pbuf) + 22))) - #define SetFragNum(pbuf, num) \ do { \ *(unsigned short *)((unsigned long)(pbuf) + 22) = \ @@ -149,27 +147,6 @@ enum WIFI_REG_DOMAIN { #define SetAMsdu(pbuf, amsdu) \ (*(__le16 *)(pbuf) |= cpu_to_le16((amsdu & 1) << 7)) -#define GetTid(pbuf) \ - (cpu_to_le16(*(unsigned short *)((unsigned long)(pbuf) + \ - (((ieee80211_has_tods(pbuf)<<1) | \ - ieee80211_has_fromds(pbuf)) == 3 ? 30 : 24))) & 0x000f) - -/*----------------------------------------------------------------------------- - Below is for the security related definition -------------------------------------------------------------------------------*/ -#define _RESERVED_FRAME_TYPE_ 0 -#define _SKB_FRAME_TYPE_ 2 -#define _PRE_ALLOCMEM_ 1 -#define _PRE_ALLOCHDR_ 3 -#define _PRE_ALLOCLLCHDR_ 4 -#define _PRE_ALLOCICVHDR_ 5 -#define _PRE_ALLOCMICHDR_ 6 - -#define _SIFSTIME_ \ - ((priv->pmib->dot11BssType.net_work_type & WIRELESS_11A) ? 16 : 10) -#define _ACKCTSLNG_ 14 /* 14 bytes long, including crclng */ -#define _CRCLNG_ 4 - #define _ASOCREQ_IE_OFFSET_ 4 /* excluding wlan_hdr */ #define _ASOCRSP_IE_OFFSET_ 6 #define _REASOCREQ_IE_OFFSET_ 10 @@ -199,13 +176,6 @@ enum WIFI_REG_DOMAIN { #define _STATUS_CODE_ 2 #define _TIMESTAMP_ 8 -#define AUTH_ODD_TO 0 -#define AUTH_EVEN_TO 1 - -#define WLAN_ETHCONV_ENCAP 1 -#define WLAN_ETHCONV_RFC1042 2 -#define WLAN_ETHCONV_8021h 3 - #define cap_ESS BIT(0) #define cap_IBSS BIT(1) #define cap_CFPollable BIT(2) @@ -218,22 +188,6 @@ enum WIFI_REG_DOMAIN { #define cap_QoS BIT(9) #define cap_ShortSlot BIT(10) -/*----------------------------------------------------------------------------- - Below is the definition for 802.11i / 802.1x -------------------------------------------------------------------------------*/ -#define _IEEE8021X_MGT_ 1 /* WPA */ -#define _IEEE8021X_PSK_ 2 /* WPA with pre-shared key */ - -/* -#define _NO_PRIVACY_ 0 -#define _WEP_40_PRIVACY_ 1 -#define _TKIP_PRIVACY_ 2 -#define _WRAP_PRIVACY_ 3 -#define _CCMP_PRIVACY_ 4 -#define _WEP_104_PRIVACY_ 5 -#define _WEP_WPA_MIXED_PRIVACY_ 6 WEP + WPA -*/ - /*----------------------------------------------------------------------------- Below is the definition for WMM ------------------------------------------------------------------------------*/ @@ -245,13 +199,6 @@ enum WIFI_REG_DOMAIN { Below is the definition for 802.11n ------------------------------------------------------------------------------*/ -#define SetOrderBit(pbuf) \ - (*(unsigned short *)(pbuf) |= cpu_to_le16(_ORDER_)) - -#define GetOrderBit(pbuf) \ - (((*(unsigned short *)(pbuf)) & le16_to_cpu(_ORDER_)) != 0) - - /* struct rtw_ieee80211_ht_cap - HT additional information * * This structure refers to "HT information element" as -- cgit v1.2.3 From 9d85833d1956c88bd1b19d4df5e3cc5712519a63 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:36 +0200 Subject: staging: rtl8723au: Use random ethaddr if EEPROM address is corrupted Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 24 ------------------------ drivers/staging/rtl8723au/include/ieee80211.h | 2 -- drivers/staging/rtl8723au/os_dep/usb_intf.c | 6 ++++-- 3 files changed, 4 insertions(+), 28 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index bd35e8f320d0..98cd9905196e 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -904,30 +904,6 @@ u8 key_2char2num23a(u8 hch, u8 lch) return key_char2num(hch) << 4 | key_char2num(lch); } -void rtw_macaddr_cfg23a(u8 *mac_addr) -{ - u8 mac[ETH_ALEN]; - if (!mac_addr) - return; - - memcpy(mac, mac_addr, ETH_ALEN); - - if (is_broadcast_ether_addr(mac) || is_zero_ether_addr(mac)) { - mac[0] = 0x00; - mac[1] = 0xe0; - mac[2] = 0x4c; - mac[3] = 0x87; - mac[4] = 0x00; - mac[5] = 0x00; - /* use default mac addresss */ - memcpy(mac_addr, mac, ETH_ALEN); - DBG_8723A("MAC Address from efuse error, assign default " - "one !!!\n"); - } - DBG_8723A("rtw_macaddr_cfg23a MAC Address = "MAC_FMT"\n", - MAC_ARG(mac_addr)); -} - static int rtw_get_cipher_info(struct wlan_network *pnetwork) { const u8 *pbuf; diff --git a/drivers/staging/rtl8723au/include/ieee80211.h b/drivers/staging/rtl8723au/include/ieee80211.h index 4a4b08682925..e8072c4ee451 100644 --- a/drivers/staging/rtl8723au/include/ieee80211.h +++ b/drivers/staging/rtl8723au/include/ieee80211.h @@ -451,8 +451,6 @@ int rtw_check_network_type23a(unsigned char *rate, int ratelen, int channel); void rtw_get_bcn_info23a(struct wlan_network *pnetwork); -void rtw_macaddr_cfg23a(u8 *mac_addr); - u16 rtw_mcs_rate23a(u8 rf_type, u8 bw_40MHz, u8 short_GI_20, u8 short_GI_40, unsigned char * MCS_rate); int rtw_action_frame_parse23a(const u8 *frame, u32 frame_len, u8* category, u8 *action); diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index 7d5233b993f1..c6cc335a19bc 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -659,8 +659,10 @@ static struct rtw_adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, padapter->pwrctrlpriv.autopm_cnt = 1; #endif - /* set mac addr */ - rtw_macaddr_cfg23a(padapter->eeprompriv.mac_addr); + /* If the eeprom mac address is corrupted, assign a random address */ + if (is_broadcast_ether_addr(padapter->eeprompriv.mac_addr) || + is_zero_ether_addr(padapter->eeprompriv.mac_addr)) + eth_random_addr(padapter->eeprompriv.mac_addr); DBG_8723A("bDriverStopped:%d, bSurpriseRemoved:%d, bup:%d, hw_init_completed:%d\n", padapter->bDriverStopped, padapter->bSurpriseRemoved, -- cgit v1.2.3 From 613a774d9d992e42fda12414993266c77b7120fc Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:37 +0200 Subject: staging: rtl8723au: Remove unused ODM malloc/free functions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/odm_interface.c | 22 ---------------------- drivers/staging/rtl8723au/include/odm_interface.h | 3 --- 2 files changed, 25 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/odm_interface.c b/drivers/staging/rtl8723au/hal/odm_interface.c index bef1269749d0..13c790f51f5f 100644 --- a/drivers/staging/rtl8723au/hal/odm_interface.c +++ b/drivers/staging/rtl8723au/hal/odm_interface.c @@ -154,28 +154,6 @@ u32 ODM_GetRFReg( return PHY_QueryRFReg(Adapter, eRFPath, RegAddr, BitMask); } -/* */ -/* ODM Memory relative API. */ -/* */ -void ODM_AllocateMemory( - struct dm_odm_t *pDM_Odm, - void **pPtr, - u32 length - ) -{ - *pPtr = rtw_zvmalloc(length); -} - -/* length could be ignored, used to detect memory leakage. */ -void ODM_FreeMemory( - struct dm_odm_t *pDM_Odm, - void *pPtr, - u32 length - ) -{ - rtw_vmfree(pPtr, length); -} - /* */ /* ODM MISC relative API. */ /* */ diff --git a/drivers/staging/rtl8723au/include/odm_interface.h b/drivers/staging/rtl8723au/include/odm_interface.h index f216b5846f92..fe0d52764990 100644 --- a/drivers/staging/rtl8723au/include/odm_interface.h +++ b/drivers/staging/rtl8723au/include/odm_interface.h @@ -104,9 +104,6 @@ u32 ODM_GetRFReg(struct dm_odm_t *pDM_Odm, enum RF_RADIO_PATH eRFPath, u32 RegAddr, u32 BitMask); /* Memory Relative Function. */ -void ODM_AllocateMemory(struct dm_odm_t *pDM_Odm, void **pPtr, u32 length); -void ODM_FreeMemory(struct dm_odm_t *pDM_Odm, void *pPtr, u32 length); - s32 ODM_CompareMemory(struct dm_odm_t *pDM_Odm, void *pBuf1, void *pBuf2, u32 length); /* ODM MISC-spin lock relative API. */ -- cgit v1.2.3 From 5ead42ce719da100cd4c260bb7022d712c64e6ae Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:38 +0200 Subject: staging: rtl8723au: Remove unused ODM spin lock functions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/odm_interface.c | 18 ------------------ drivers/staging/rtl8723au/include/odm_interface.h | 5 ----- 2 files changed, 23 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/odm_interface.c b/drivers/staging/rtl8723au/hal/odm_interface.c index 13c790f51f5f..6ca12c418076 100644 --- a/drivers/staging/rtl8723au/hal/odm_interface.c +++ b/drivers/staging/rtl8723au/hal/odm_interface.c @@ -154,24 +154,6 @@ u32 ODM_GetRFReg( return PHY_QueryRFReg(Adapter, eRFPath, RegAddr, BitMask); } -/* */ -/* ODM MISC relative API. */ -/* */ -void -ODM_AcquireSpinLock( - struct dm_odm_t *pDM_Odm, - enum rt_spinlock_type type - ) -{ -} - -void ODM_ReleaseSpinLock( - struct dm_odm_t *pDM_Odm, - enum rt_spinlock_type type - ) -{ -} - /* */ /* Work item relative API. FOr MP driver only~! */ /* */ diff --git a/drivers/staging/rtl8723au/include/odm_interface.h b/drivers/staging/rtl8723au/include/odm_interface.h index fe0d52764990..2d51e0197b6a 100644 --- a/drivers/staging/rtl8723au/include/odm_interface.h +++ b/drivers/staging/rtl8723au/include/odm_interface.h @@ -106,11 +106,6 @@ u32 ODM_GetRFReg(struct dm_odm_t *pDM_Odm, enum RF_RADIO_PATH eRFPath, /* Memory Relative Function. */ s32 ODM_CompareMemory(struct dm_odm_t *pDM_Odm, void *pBuf1, void *pBuf2, u32 length); -/* ODM MISC-spin lock relative API. */ -void ODM_AcquireSpinLock(struct dm_odm_t *pDM_Odm, enum rt_spinlock_type type); - -void ODM_ReleaseSpinLock(struct dm_odm_t *pDM_Odm, enum rt_spinlock_type type); - /* ODM MISC-workitem relative API. */ void ODM_InitializeWorkItem(struct dm_odm_t *pDM_Odm, void *pRtWorkItem, RT_WORKITEM_CALL_BACK RtWorkItemCallback, void *pContext, const char *szID); -- cgit v1.2.3 From 59497030a27ef67a2c06fa362218aa4dcdfd4410 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:39 +0200 Subject: staging: rtl8723au: Remove a bunch of unused clutter from the ODM code Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/odm.c | 16 -------- drivers/staging/rtl8723au/hal/odm_interface.c | 41 ------------------- drivers/staging/rtl8723au/include/odm.h | 19 --------- drivers/staging/rtl8723au/include/odm_interface.h | 49 ----------------------- 4 files changed, 125 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/odm.c b/drivers/staging/rtl8723au/hal/odm.c index 584a74ed2943..d181cbc77f23 100644 --- a/drivers/staging/rtl8723au/hal/odm.c +++ b/drivers/staging/rtl8723au/hal/odm.c @@ -1576,22 +1576,6 @@ void odm_RSSIMonitorCheck23aAP(struct dm_odm_t *pDM_Odm) { } -void ODM_InitAllTimers(struct dm_odm_t *pDM_Odm) -{ - setup_timer(&pDM_Odm->DM_SWAT_Table.SwAntennaSwitchTimer, - odm_SwAntDivChkAntSwitchCallback23a, (unsigned long)pDM_Odm); -} - -void ODM_CancelAllTimers(struct dm_odm_t *pDM_Odm) -{ - del_timer_sync(&pDM_Odm->DM_SWAT_Table.SwAntennaSwitchTimer); -} - -void ODM_ReleaseAllTimers(struct dm_odm_t *pDM_Odm) -{ - ODM_ReleaseTimer(pDM_Odm, &pDM_Odm->DM_SWAT_Table.SwAntennaSwitchTimer); -} - /* endif */ /* 3 ============================================================ */ /* 3 Tx Power Tracking */ diff --git a/drivers/staging/rtl8723au/hal/odm_interface.c b/drivers/staging/rtl8723au/hal/odm_interface.c index 6ca12c418076..ce5d16641382 100644 --- a/drivers/staging/rtl8723au/hal/odm_interface.c +++ b/drivers/staging/rtl8723au/hal/odm_interface.c @@ -153,44 +153,3 @@ u32 ODM_GetRFReg( return PHY_QueryRFReg(Adapter, eRFPath, RegAddr, BitMask); } - -/* */ -/* Work item relative API. FOr MP driver only~! */ -/* */ -void ODM_InitializeWorkItem( - struct dm_odm_t *pDM_Odm, - void *pRtWorkItem, - RT_WORKITEM_CALL_BACK RtWorkItemCallback, - void *pContext, - const char *szID - ) -{ -} - -/* */ -/* ODM Timer relative API. */ -/* */ -void ODM_SetTimer(struct dm_odm_t *pDM_Odm, struct timer_list *pTimer, u32 msDelay) -{ - mod_timer(pTimer, jiffies + msecs_to_jiffies(msDelay)); /* ms */ -} - -void ODM_ReleaseTimer(struct dm_odm_t *pDM_Odm, struct timer_list *pTimer) -{ -} - -/* */ -/* ODM FW relative API. */ -/* */ -u32 ODM_FillH2CCmd( - u8 *pH2CBuffer, - u32 H2CBufferLen, - u32 CmdNum, - u32 *pElementID, - u32 *pCmdLen, - u8 **pCmbBuffer, - u8 *CmdStartSeq - ) -{ - return true; -} diff --git a/drivers/staging/rtl8723au/include/odm.h b/drivers/staging/rtl8723au/include/odm.h index dfedfbb48fc2..fb8b954d8b1c 100644 --- a/drivers/staging/rtl8723au/include/odm.h +++ b/drivers/staging/rtl8723au/include/odm.h @@ -187,7 +187,6 @@ struct rx_hp { bool First_time_enter; bool RXHP_enable; u8 TP_Mode; - struct timer_list PSDTimer; }; #define ASSOCIATE_ENTRY_NUM 32 /* Max size of AsocEntry[]. */ @@ -234,14 +233,12 @@ struct sw_ant_sw { u64 RXByteCnt_A; u64 RXByteCnt_B; u8 TrafficLoad; - struct timer_list SwAntennaSwitchTimer; }; struct edca_turbo { bool bCurrentTurboEDCA; bool bIsCurRDLState; u32 prv_traffic_idx; /* edca turbo */ - }; struct odm_rate_adapt { @@ -762,7 +759,6 @@ enum ant_dif_type { /* 2011/09/22 MH Copy from SD4 defined structure. We use to support PHY DM integration. */ struct dm_odm_t { - /* struct timer_list FastAntTrainingTimer; */ /* */ /* Add for different team use temporarily */ /* */ @@ -928,7 +924,6 @@ struct dm_odm_t { /* PSD */ bool bUserAssignLevel; - struct timer_list PSDTimer; u8 RSSI_BT; /* come from BT */ bool bPSDinProcess; bool bDMInitialGainEnable; @@ -955,14 +950,6 @@ struct dm_odm_t { /* */ /* ODM system resource. */ /* */ - - /* ODM relative time. */ - struct timer_list PathDivSwitchTimer; - /* 2011.09.27 add for Path Diversity */ - struct timer_list CCKPathDiversityTimer; - struct timer_list FastAntTrainingTimer; - - /* ODM relative workitem. */ }; /* DM_Dynamic_Mechanism_Structure */ enum odm_rf_content { @@ -1186,12 +1173,6 @@ void ODM_CmnInfoPtrArrayHook23a(struct dm_odm_t *pDM_Odm, enum odm_cmninfo CmnIn void ODM_CmnInfoUpdate23a(struct dm_odm_t *pDM_Odm, u32 CmnInfo, u64 Value); -void ODM_InitAllTimers(struct dm_odm_t *pDM_Odm); - -void ODM_CancelAllTimers(struct dm_odm_t *pDM_Odm); - -void ODM_ReleaseAllTimers(struct dm_odm_t *pDM_Odm); - void ODM_ResetIQKResult(struct dm_odm_t *pDM_Odm); void ODM_AntselStatistics_88C(struct dm_odm_t *pDM_Odm, u8 MacId, u32 PWDBAll, bool isCCKrate); diff --git a/drivers/staging/rtl8723au/include/odm_interface.h b/drivers/staging/rtl8723au/include/odm_interface.h index 2d51e0197b6a..c260d6bd8ff5 100644 --- a/drivers/staging/rtl8723au/include/odm_interface.h +++ b/drivers/staging/rtl8723au/include/odm_interface.h @@ -18,22 +18,6 @@ #define __ODM_INTERFACE_H__ - -/* */ -/* =========== Constant/Structure/Enum/... Define */ -/* */ - - - -/* */ -/* =========== Macro Define */ -/* */ - -#define _reg_all(_name) ODM_##_name -#define _reg_ic(_name, _ic) ODM_##_name##_ic -#define _bit_all(_name) BIT_##_name -#define _bit_ic(_name, _ic) BIT_##_name##_ic - /* _cat: implemented by Token-Pasting Operator. */ /*=================================== @@ -67,57 +51,24 @@ ODM_REG(DIG,_pDM_Odm) /* */ typedef void (*RT_WORKITEM_CALL_BACK)(struct work_struct *pContext); -/* */ -/* =========== Extern Variable ??? It should be forbidden. */ -/* */ - - /* */ /* =========== EXtern Function Prototype */ /* */ u8 ODM_Read1Byte(struct dm_odm_t *pDM_Odm, u32 RegAddr); - u16 ODM_Read2Byte(struct dm_odm_t *pDM_Odm, u32 RegAddr); - u32 ODM_Read4Byte(struct dm_odm_t *pDM_Odm, u32 RegAddr); - void ODM_Write1Byte(struct dm_odm_t *pDM_Odm, u32 RegAddr, u8 Data); - void ODM_Write2Byte(struct dm_odm_t *pDM_Odm, u32 RegAddr, u16 Data); - void ODM_Write4Byte(struct dm_odm_t *pDM_Odm, u32 RegAddr, u32 Data); - void ODM_SetMACReg(struct dm_odm_t *pDM_Odm, u32 RegAddr, u32 BitMask, u32 Data); - u32 ODM_GetMACReg(struct dm_odm_t *pDM_Odm, u32 RegAddr, u32 BitMask); - void ODM_SetBBReg(struct dm_odm_t *pDM_Odm, u32 RegAddr, u32 BitMask, u32 Data); - u32 ODM_GetBBReg(struct dm_odm_t *pDM_Odm, u32 RegAddr, u32 BitMask); - void ODM_SetRFReg(struct dm_odm_t *pDM_Odm, enum RF_RADIO_PATH eRFPath, u32 RegAddr, u32 BitMask, u32 Data); - u32 ODM_GetRFReg(struct dm_odm_t *pDM_Odm, enum RF_RADIO_PATH eRFPath, u32 RegAddr, u32 BitMask); -/* Memory Relative Function. */ -s32 ODM_CompareMemory(struct dm_odm_t *pDM_Odm, void *pBuf1, void *pBuf2, u32 length); - -/* ODM MISC-workitem relative API. */ -void ODM_InitializeWorkItem(struct dm_odm_t *pDM_Odm, void *pRtWorkItem, - RT_WORKITEM_CALL_BACK RtWorkItemCallback, void *pContext, const char *szID); - -/* ODM Timer relative API. */ -void ODM_SetTimer(struct dm_odm_t *pDM_Odm, struct timer_list *pTimer, u32 msDelay); - -void ODM_ReleaseTimer(struct dm_odm_t *pDM_Odm, struct timer_list *pTimer); - -/* ODM FW relative API. */ -u32 ODM_FillH2CCmd(u8 *pH2CBuffer, u32 H2CBufferLen, u32 CmdNum, - u32 *pElementID, u32 *pCmdLen, u8 **pCmbBuffer, - u8 *CmdStartSeq); - #endif /* __ODM_INTERFACE_H__ */ -- cgit v1.2.3 From 70e6b551c62fca644eed09b0a12f0e0bd6515164 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:40 +0200 Subject: staging: rtl8723au: Remove unused struct rtl8723a_priv Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/odm.h | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/drivers/staging/rtl8723au/include/odm.h b/drivers/staging/rtl8723au/include/odm.h index fb8b954d8b1c..e2b14f8b2d53 100644 --- a/drivers/staging/rtl8723au/include/odm.h +++ b/drivers/staging/rtl8723au/include/odm.h @@ -86,15 +86,6 @@ /* structure and define */ /* */ -/* */ -/* 2011/09/20 MH Add for AP/ADSLpseudo DM structuer requirement. */ -/* We need to remove to other position??? */ -/* */ -struct rtl8723a_priv { - u8 temp; -}; - - struct dig_t { u8 Dig_Enable_Flag; u8 Dig_Ext_Port_Stage; @@ -763,11 +754,6 @@ struct dm_odm_t { /* Add for different team use temporarily */ /* */ struct rtw_adapter *Adapter; /* For CE/NIC team */ - struct rtl8723a_priv *priv; /* For AP/ADSL team */ - /* WHen you use Adapter or priv pointer, you must make sure the pointer is ready. */ - bool odm_ready; - - struct rtl8723a_priv fake_priv; u64 DebugComponents; u32 DebugLevel; -- cgit v1.2.3 From 5cfab102fb62540b5d48eeb5e9ed6ba191fbf597 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:41 +0200 Subject: staging: rtl8723au: Remove some unused clutter from odm_types.h Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/odm_types.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/staging/rtl8723au/include/odm_types.h b/drivers/staging/rtl8723au/include/odm_types.h index a866769ea178..9f15f25476f5 100644 --- a/drivers/staging/rtl8723au/include/odm_types.h +++ b/drivers/staging/rtl8723au/include/odm_types.h @@ -22,15 +22,4 @@ enum hal_status { HAL_STATUS_FAILURE, }; -enum rt_spinlock_type { - RT_TEMP =1, -}; - -#define SET_TX_DESC_ANTSEL_A_88E(__pTxDesc, __Value) \ - SET_BITS_TO_LE_4BYTE(__pTxDesc+8, 24, 1, __Value) -#define SET_TX_DESC_ANTSEL_B_88E(__pTxDesc, __Value) \ - SET_BITS_TO_LE_4BYTE(__pTxDesc+8, 25, 1, __Value) -#define SET_TX_DESC_ANTSEL_C_88E(__pTxDesc, __Value) \ - SET_BITS_TO_LE_4BYTE(__pTxDesc+28, 29, 1, __Value) - #endif /* __ODM_TYPES_H__ */ -- cgit v1.2.3 From 1465967763933490aa8a31cbdd2c2205905c914f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:42 +0200 Subject: staging: rtl8723au: Get rid of second set of custom error codes One set of custom error codes for the driver should more than suffice. This allows us to get rid of odm_types.h as well. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/odm_HWConfig.c | 29 ++++++++---------------- drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c | 11 ++++----- drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c | 12 ++++++++-- drivers/staging/rtl8723au/include/odm_HWConfig.h | 14 +++++------- drivers/staging/rtl8723au/include/odm_precomp.h | 2 -- drivers/staging/rtl8723au/include/odm_types.h | 25 -------------------- 6 files changed, 30 insertions(+), 63 deletions(-) delete mode 100644 drivers/staging/rtl8723au/include/odm_types.h diff --git a/drivers/staging/rtl8723au/hal/odm_HWConfig.c b/drivers/staging/rtl8723au/hal/odm_HWConfig.c index 72441709697e..2d458bef922a 100644 --- a/drivers/staging/rtl8723au/hal/odm_HWConfig.c +++ b/drivers/staging/rtl8723au/hal/odm_HWConfig.c @@ -426,12 +426,9 @@ void ODM_MacStatusQuery23a(struct dm_odm_t *pDM_Odm, u8 *pMacStatus, u8 MacID, } -enum hal_status -ODM_ConfigRFWithHeaderFile23a( - struct dm_odm_t *pDM_Odm, - enum RF_RADIO_PATH Content, - enum RF_RADIO_PATH eRFPath - ) +int ODM_ConfigRFWithHeaderFile23a(struct dm_odm_t *pDM_Odm, + enum RF_RADIO_PATH Content, + enum RF_RADIO_PATH eRFPath) { ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("===>ODM_ConfigRFWithHeaderFile23a\n")); @@ -446,14 +443,11 @@ ODM_ConfigRFWithHeaderFile23a( } ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("ODM_ConfigRFWithHeaderFile23a: Radio No %x\n", eRFPath)); - return HAL_STATUS_SUCCESS; + return _SUCCESS; } -enum hal_status -ODM_ConfigBBWithHeaderFile23a( - struct dm_odm_t *pDM_Odm, - enum odm_bb_config_type ConfigType - ) +int ODM_ConfigBBWithHeaderFile23a(struct dm_odm_t *pDM_Odm, + enum odm_bb_config_type ConfigType) { if (pDM_Odm->SupportICType == ODM_RTL8723A) { if (ConfigType == CONFIG_BB_PHY_REG) @@ -465,17 +459,12 @@ ODM_ConfigBBWithHeaderFile23a( ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, (" ===> phy_ConfigBBWithHeaderFile() agc:Rtl8723PHY_REG_1TArray\n")); } - return HAL_STATUS_SUCCESS; + return _SUCCESS; } -enum hal_status -ODM_ConfigMACWithHeaderFile23a( - struct dm_odm_t *pDM_Odm - ) +int ODM_ConfigMACWithHeaderFile23a(struct dm_odm_t *pDM_Odm) { - u8 result = HAL_STATUS_SUCCESS; - if (pDM_Odm->SupportICType == ODM_RTL8723A) READ_AND_CONFIG_MP(8723A, _MAC_REG_); - return result; + return _SUCCESS; } diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c b/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c index 4860ba4e0188..5be4d83b8402 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c @@ -422,8 +422,7 @@ s32 PHY_MACConfig8723A(struct rtw_adapter *Adapter) /* */ /* Config MAC */ /* */ - if (HAL_STATUS_FAILURE == - ODM_ConfigMACWithHeaderFile23a(&pHalData->odmpriv)) + if (ODM_ConfigMACWithHeaderFile23a(&pHalData->odmpriv) == _FAIL) rtStatus = _FAIL; /* 2010.07.13 AMPDU aggregation number 9 */ @@ -751,8 +750,8 @@ phy_BB8723a_Config_ParaFile(struct rtw_adapter *Adapter) /* 1. Read PHY_REG.TXT BB INIT!! */ /* We will seperate as 88C / 92C according to chip version */ /* */ - if (HAL_STATUS_FAILURE == ODM_ConfigBBWithHeaderFile23a(&pHalData->odmpriv, - CONFIG_BB_PHY_REG)) + if (ODM_ConfigBBWithHeaderFile23a(&pHalData->odmpriv, + CONFIG_BB_PHY_REG) == _FAIL) rtStatus = _FAIL; if (rtStatus != _SUCCESS) goto phy_BB8190_Config_ParaFile_Fail; @@ -782,8 +781,8 @@ phy_BB8723a_Config_ParaFile(struct rtw_adapter *Adapter) /* */ /* 3. BB AGC table Initialization */ /* */ - if (HAL_STATUS_FAILURE == ODM_ConfigBBWithHeaderFile23a(&pHalData->odmpriv, - CONFIG_BB_AGC_TAB)) + if (ODM_ConfigBBWithHeaderFile23a(&pHalData->odmpriv, + CONFIG_BB_AGC_TAB) == _FAIL) rtStatus = _FAIL; phy_BB8190_Config_ParaFile_Fail: diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c b/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c index d4f922a0675e..7fbad8eb2a20 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c @@ -453,11 +453,19 @@ static int phy_RF6052_Config_ParaFile(struct rtw_adapter *Adapter) /*----Initialize RF fom connfiguration file----*/ switch (eRFPath) { case RF_PATH_A: - if (HAL_STATUS_FAILURE == ODM_ConfigRFWithHeaderFile23a(&pHalData->odmpriv, (enum RF_RADIO_PATH)eRFPath, (enum RF_RADIO_PATH)eRFPath)) + if (ODM_ConfigRFWithHeaderFile23a(&pHalData->odmpriv, + (enum RF_RADIO_PATH) + eRFPath, + (enum RF_RADIO_PATH) + eRFPath) == _FAIL) rtStatus = _FAIL; break; case RF_PATH_B: - if (HAL_STATUS_FAILURE == ODM_ConfigRFWithHeaderFile23a(&pHalData->odmpriv, (enum RF_RADIO_PATH)eRFPath, (enum RF_RADIO_PATH)eRFPath)) + if (ODM_ConfigRFWithHeaderFile23a(&pHalData->odmpriv, + (enum RF_RADIO_PATH) + eRFPath, + (enum RF_RADIO_PATH) + eRFPath) == _FAIL) rtStatus = _FAIL; break; } diff --git a/drivers/staging/rtl8723au/include/odm_HWConfig.h b/drivers/staging/rtl8723au/include/odm_HWConfig.h index 147855c96ad4..d2367ec95f17 100644 --- a/drivers/staging/rtl8723au/include/odm_HWConfig.h +++ b/drivers/staging/rtl8723au/include/odm_HWConfig.h @@ -160,15 +160,13 @@ void ODM_MacStatusQuery23a(struct dm_odm_t *pDM_Odm, bool bPacketBeacon ); -enum hal_status ODM_ConfigRFWithHeaderFile23a(struct dm_odm_t *pDM_Odm, - enum RF_RADIO_PATH Content, - enum RF_RADIO_PATH eRFPath -); +int ODM_ConfigRFWithHeaderFile23a(struct dm_odm_t *pDM_Odm, + enum RF_RADIO_PATH Content, + enum RF_RADIO_PATH eRFPath); -enum hal_status ODM_ConfigBBWithHeaderFile23a(struct dm_odm_t *pDM_Odm, - enum odm_bb_config_type ConfigType -); +int ODM_ConfigBBWithHeaderFile23a(struct dm_odm_t *pDM_Odm, + enum odm_bb_config_type ConfigType); -enum hal_status ODM_ConfigMACWithHeaderFile23a(struct dm_odm_t *pDM_Odm); +int ODM_ConfigMACWithHeaderFile23a(struct dm_odm_t *pDM_Odm); #endif diff --git a/drivers/staging/rtl8723au/include/odm_precomp.h b/drivers/staging/rtl8723au/include/odm_precomp.h index f3fc2fad9884..fe6df738c3ce 100644 --- a/drivers/staging/rtl8723au/include/odm_precomp.h +++ b/drivers/staging/rtl8723au/include/odm_precomp.h @@ -16,8 +16,6 @@ #ifndef __ODM_PRECOMP_H__ #define __ODM_PRECOMP_H__ -#include "odm_types.h" - #define TEST_FALG___ 1 /* 2 Config Flags and Structs - defined by each ODM Type */ diff --git a/drivers/staging/rtl8723au/include/odm_types.h b/drivers/staging/rtl8723au/include/odm_types.h deleted file mode 100644 index 9f15f25476f5..000000000000 --- a/drivers/staging/rtl8723au/include/odm_types.h +++ /dev/null @@ -1,25 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek 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. - * - ******************************************************************************/ -#ifndef __ODM_TYPES_H__ -#define __ODM_TYPES_H__ - -/* Define Different SW team support */ - -enum hal_status { - HAL_STATUS_SUCCESS, - HAL_STATUS_FAILURE, -}; - -#endif /* __ODM_TYPES_H__ */ -- cgit v1.2.3 From b06106d1053216406bc772c6a0760e1c6b92c214 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:43 +0200 Subject: staging: rtl8723au: rtw_sta_mgt.c: Fix some formatting badness Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_sta_mgt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c index 53dd3207ecef..656eb0f28dd3 100644 --- a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c @@ -384,9 +384,11 @@ void rtw_free_all_stainfo23a(struct rtw_adapter *padapter) { struct list_head *plist, *phead, *ptmp; struct sta_info *psta; - struct sta_priv *pstapriv = &padapter->stapriv; + struct sta_priv *pstapriv = &padapter->stapriv; struct sta_info* pbcmc_stainfo = rtw_get_bcmc_stainfo23a(padapter); - s32 index; if (pstapriv->asoc_sta_count == 1) + s32 index; + + if (pstapriv->asoc_sta_count == 1) return; spin_lock_bh(&pstapriv->sta_hash_lock); -- cgit v1.2.3 From 5d8b411b33ca7c5a08ce6617a168810da2d97ddb Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:44 +0200 Subject: staging: rtl8723au: rtw_alloc_stainfo23a(): Remove unused variable tmp_aid Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_sta_mgt.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c index 656eb0f28dd3..71addf6ec14e 100644 --- a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c @@ -169,7 +169,6 @@ struct sta_info *rtw_alloc_stainfo23a(struct sta_priv *pstapriv, u8 *hwaddr) struct sta_info *psta; struct rtw_queue *pfree_sta_queue; struct recv_reorder_ctrl *preorder_ctrl; - uint tmp_aid; s32 index; int i = 0; u16 wRxSeqInitialValue = 0xffff; @@ -186,8 +185,6 @@ struct sta_info *rtw_alloc_stainfo23a(struct sta_priv *pstapriv, u8 *hwaddr) list_del_init(&psta->list); - tmp_aid = psta->aid; - _rtw_init_stainfo(psta); psta->padapter = pstapriv->padapter; -- cgit v1.2.3 From 5290cd688e07fb492f3a049960f3b76ff776d218 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:45 +0200 Subject: staging: rtl8723au: rtw_createbss_cmd23a_callback(): Relax holding of pmlmepriv->lock We only really need to hold pmlmepriv->lock while calling rtw_indicate_connect23a(). rtw_get_stainfo23a() and rtw_alloc_stainfo23a() rely on pstapriv->sta_hash_lock and the non WIFI_AP_STATE path relies on pmlmepvi->scanned_queue.lock, except we need to used clr_fwstate() instead of _clr_fwstate_(). Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 1ff945caa8f0..dc61a816e39b 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -1505,8 +1505,6 @@ void rtw_createbss_cmd23a_callback(struct rtw_adapter *padapter, del_timer_sync(&pmlmepriv->assoc_timer); - spin_lock_bh(&pmlmepriv->lock); - if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { psta = rtw_get_stainfo23a(&padapter->stapriv, pnetwork->MacAddress); @@ -1521,7 +1519,9 @@ void rtw_createbss_cmd23a_callback(struct rtw_adapter *padapter, } } + spin_lock_bh(&pmlmepriv->lock); rtw_indicate_connect23a(padapter); + spin_unlock_bh(&pmlmepriv->lock); } else { pwlan = rtw_alloc_network(pmlmepriv); spin_lock_bh(&pmlmepriv->scanned_queue.lock); @@ -1554,7 +1554,7 @@ void rtw_createbss_cmd23a_callback(struct rtw_adapter *padapter, /* reset DSConfig */ - _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); + clr_fwstate(pmlmepriv, _FW_UNDER_LINKING); spin_unlock_bh(&pmlmepriv->scanned_queue.lock); /* we will set _FW_LINKED when there is one more sat to @@ -1563,8 +1563,6 @@ void rtw_createbss_cmd23a_callback(struct rtw_adapter *padapter, createbss_cmd_fail: - spin_unlock_bh(&pmlmepriv->lock); - rtw_free_cmd_obj23a(pcmd); } -- cgit v1.2.3 From ec838b0bc92630021eb32910b6ea3c3fc5da9e06 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:46 +0200 Subject: staging: rtl8723au: add GFP argument to rtw_alloc_network() This allows us to use GFP_KERNEL when calling from a work handler. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 2 +- drivers/staging/rtl8723au/core/rtw_mlme.c | 6 +++--- drivers/staging/rtl8723au/include/rtw_mlme.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index dc61a816e39b..b94049fa96d8 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -1523,7 +1523,7 @@ void rtw_createbss_cmd23a_callback(struct rtw_adapter *padapter, rtw_indicate_connect23a(padapter); spin_unlock_bh(&pmlmepriv->lock); } else { - pwlan = rtw_alloc_network(pmlmepriv); + pwlan = rtw_alloc_network(pmlmepriv, GFP_KERNEL); spin_lock_bh(&pmlmepriv->scanned_queue.lock); if (!pwlan) { pwlan = rtw_get_oldest_wlan_network23a(&pmlmepriv->scanned_queue); diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index ddbe6c648225..8983862d44f2 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -127,11 +127,11 @@ void rtw_free_mlme_priv23a(struct mlme_priv *pmlmepriv) rtw23a_free_mlme_priv_ie_data(pmlmepriv); } -struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv) +struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv, int gfp) { struct wlan_network *pnetwork; - pnetwork = kzalloc(sizeof(struct wlan_network), GFP_ATOMIC); + pnetwork = kzalloc(sizeof(struct wlan_network), gfp); if (pnetwork) { INIT_LIST_HEAD(&pnetwork->list); pnetwork->network_type = 0; @@ -514,7 +514,7 @@ void rtw_update_scanned_network23a(struct rtw_adapter *adapter, /* If we didn't find a match, then get a new network slot to initialize * with this beacon's information */ if (!found) { - pnetwork = rtw_alloc_network(pmlmepriv); + pnetwork = rtw_alloc_network(pmlmepriv, GFP_ATOMIC); if (!pnetwork) { if (!oldest) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index 6dd8fb476553..2b72d5bd4d28 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -454,7 +454,7 @@ void rtw23a_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv); void _rtw_free_mlme_priv23a(struct mlme_priv *pmlmepriv); -struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv); +struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv, int gfp); int rtw_if_up23a(struct rtw_adapter *padapter); -- cgit v1.2.3 From 6964213a949d73681b4abe7a7ad3570e49851d7b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:47 +0200 Subject: staging: rtl8723au: Eliminate stainfo_by_offset spaghetti Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 47 ++++++++-------------------- drivers/staging/rtl8723au/core/rtw_sta_mgt.c | 16 ---------- drivers/staging/rtl8723au/include/sta_info.h | 5 --- 3 files changed, 13 insertions(+), 55 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 432f0a29892f..9cf91a732405 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -186,7 +186,7 @@ void expire_timeout_chk23a(struct rtw_adapter *padapter) struct sta_info *psta; struct sta_priv *pstapriv = &padapter->stapriv; u8 chk_alive_num = 0; - char chk_alive_list[NUM_STA]; + struct sta_info *chk_alive_list[NUM_STA]; int i; spin_lock_bh(&pstapriv->auth_list_lock); @@ -260,13 +260,7 @@ void expire_timeout_chk23a(struct rtw_adapter *padapter) } if (pmlmeext->active_keep_alive_check) { - int stainfo_offset; - - stainfo_offset = rtw_stainfo_offset23a(pstapriv, psta); - if (stainfo_offset_valid(stainfo_offset)) { - chk_alive_list[chk_alive_num++] = stainfo_offset; - } - + chk_alive_list[chk_alive_num++] = psta; continue; } @@ -300,14 +294,14 @@ void expire_timeout_chk23a(struct rtw_adapter *padapter) if (rtw_get_oper_ch23a(padapter) != pmlmeext->cur_channel) { backup_oper_channel = rtw_get_oper_ch23a(padapter); SelectChannel23a(padapter, pmlmeext->cur_channel); - } + } /* issue null data to check sta alive*/ for (i = 0; i < chk_alive_num; i++) { int ret = _FAIL; - psta = rtw_get_stainfo23a_by_offset23a(pstapriv, chk_alive_list[i]); + psta = chk_alive_list[i]; if (!(psta->state &_FW_LINKED)) continue; @@ -1811,7 +1805,7 @@ int rtw_sta_flush23a(struct rtw_adapter *padapter) struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; u8 chk_alive_num = 0; - char chk_alive_list[NUM_STA]; + struct sta_info *chk_alive_list[NUM_STA]; int i; DBG_8723A(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(padapter->pnetdev)); @@ -1823,8 +1817,6 @@ int rtw_sta_flush23a(struct rtw_adapter *padapter) phead = &pstapriv->asoc_list; list_for_each_safe(plist, ptmp, phead) { - int stainfo_offset; - psta = container_of(plist, struct sta_info, asoc_list); /* Remove sta from asoc_list */ @@ -1832,18 +1824,14 @@ int rtw_sta_flush23a(struct rtw_adapter *padapter) pstapriv->asoc_list_cnt--; /* Keep sta for ap_free_sta23a() beyond this asoc_list loop */ - stainfo_offset = rtw_stainfo_offset23a(pstapriv, psta); - if (stainfo_offset_valid(stainfo_offset)) { - chk_alive_list[chk_alive_num++] = stainfo_offset; - } + chk_alive_list[chk_alive_num++] = psta; } spin_unlock_bh(&pstapriv->asoc_list_lock); /* For each sta in chk_alive_list, call ap_free_sta23a */ - for (i = 0; i < chk_alive_num; i++) { - psta = rtw_get_stainfo23a_by_offset23a(pstapriv, chk_alive_list[i]); - ap_free_sta23a(padapter, psta, true, WLAN_REASON_DEAUTH_LEAVING); - } + for (i = 0; i < chk_alive_num; i++) + ap_free_sta23a(padapter, chk_alive_list[i], true, + WLAN_REASON_DEAUTH_LEAVING); issue_deauth23a(padapter, bc_addr, WLAN_REASON_DEAUTH_LEAVING); @@ -1904,7 +1892,7 @@ void rtw_ap_restore_network(struct rtw_adapter *padapter) struct security_priv *psecuritypriv = &padapter->securitypriv; struct list_head *phead, *plist, *ptmp; u8 chk_alive_num = 0; - char chk_alive_list[NUM_STA]; + struct sta_info *chk_alive_list[NUM_STA]; int i; rtw_setopmode_cmd23a(padapter, Ndis802_11APMode); @@ -1931,26 +1919,17 @@ void rtw_ap_restore_network(struct rtw_adapter *padapter) phead = &pstapriv->asoc_list; list_for_each_safe(plist, ptmp, phead) { - int stainfo_offset; - psta = container_of(plist, struct sta_info, asoc_list); - stainfo_offset = rtw_stainfo_offset23a(pstapriv, psta); - if (stainfo_offset_valid(stainfo_offset)) { - chk_alive_list[chk_alive_num++] = stainfo_offset; - } + chk_alive_list[chk_alive_num++] = psta; } spin_unlock_bh(&pstapriv->asoc_list_lock); for (i = 0; i < chk_alive_num; i++) { - psta = rtw_get_stainfo23a_by_offset23a(pstapriv, chk_alive_list[i]); + psta = chk_alive_list[i]; - if (psta == NULL) { - DBG_8723A(FUNC_ADPT_FMT" sta_info is null\n", FUNC_ADPT_ARG(padapter)); - } - else if (psta->state &_FW_LINKED) - { + if (psta->state &_FW_LINKED) { Update_RA_Entry23a(padapter, psta); /* pairwise key */ rtw_setstakey_cmd23a(padapter, (unsigned char *)psta, true); diff --git a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c index 71addf6ec14e..e032d77d6e5d 100644 --- a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c @@ -92,22 +92,6 @@ u32 _rtw_init_sta_priv23a(struct sta_priv *pstapriv) return _SUCCESS; } -inline int rtw_stainfo_offset23a(struct sta_priv *stapriv, struct sta_info *sta) -{ - int offset = (((u8 *)sta) - stapriv->pstainfo_buf)/sizeof(struct sta_info); - - if (!stainfo_offset_valid(offset)) - DBG_8723A("%s invalid offset(%d), out of range!!!", __func__, offset); - return offset; -} - -inline struct sta_info *rtw_get_stainfo23a_by_offset23a(struct sta_priv *stapriv, int offset) -{ - if (!stainfo_offset_valid(offset)) - DBG_8723A("%s invalid offset(%d), out of range!!!", __func__, offset); - return (struct sta_info *)(stapriv->pstainfo_buf + offset * sizeof(struct sta_info)); -} - /* this function is used to free the memory of lock || sema for all stainfos */ static void rtw_mfree_all_stainfo(struct sta_priv *pstapriv) { diff --git a/drivers/staging/rtl8723au/include/sta_info.h b/drivers/staging/rtl8723au/include/sta_info.h index c02947f6bd9b..3a490d6dcbcc 100644 --- a/drivers/staging/rtl8723au/include/sta_info.h +++ b/drivers/staging/rtl8723au/include/sta_info.h @@ -369,11 +369,6 @@ static inline u32 wifi_mac_hash(const u8 *mac) u32 _rtw_init_sta_priv23a(struct sta_priv *pstapriv); u32 _rtw_free_sta_priv23a(struct sta_priv *pstapriv); -#define stainfo_offset_valid(offset) (offset < NUM_STA && offset >= 0) -int rtw_stainfo_offset23a(struct sta_priv *stapriv, struct sta_info *sta); -struct sta_info *rtw_get_stainfo23a_by_offset23a(struct sta_priv *stapriv, - int offset); - struct sta_info *rtw_alloc_stainfo23a(struct sta_priv *pstapriv, u8 *hwaddr); u32 rtw_free_stainfo23a(struct rtw_adapter *padapter, struct sta_info *psta); void rtw_free_all_stainfo23a(struct rtw_adapter *padapter); -- cgit v1.2.3 From 2ad7c3d940015ec00b9772ff1f1f4f9a24b1f682 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:48 +0200 Subject: staging: rtl8723au: Use kernel memory allocator for sta_priv allocations The kernel has a great memory allocator, use it instead of hacking up something in the driver. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_sta_mgt.c | 67 ++++------------------------ drivers/staging/rtl8723au/include/sta_info.h | 8 +--- 2 files changed, 11 insertions(+), 64 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c index e032d77d6e5d..317c10a74569 100644 --- a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c @@ -50,29 +50,15 @@ static void _rtw_init_stainfo(struct sta_info *psta) u32 _rtw_init_sta_priv23a(struct sta_priv *pstapriv) { - struct sta_info *psta; - s32 i; - - pstapriv->pallocated_stainfo_buf = rtw_zvmalloc(sizeof(struct sta_info) * NUM_STA+ 4); - - if (!pstapriv->pallocated_stainfo_buf) - return _FAIL; + int i; - pstapriv->pstainfo_buf = pstapriv->pallocated_stainfo_buf + 4 - - ((unsigned long)(pstapriv->pallocated_stainfo_buf) & 3); - _rtw_init_queue23a(&pstapriv->free_sta_queue); spin_lock_init(&pstapriv->sta_hash_lock); pstapriv->asoc_sta_count = 0; _rtw_init_queue23a(&pstapriv->sleep_q); _rtw_init_queue23a(&pstapriv->wakeup_q); - psta = (struct sta_info *)(pstapriv->pstainfo_buf); - - for (i = 0; i < NUM_STA; i++) { - _rtw_init_stainfo(psta); + for (i = 0; i < NUM_STA; i++) INIT_LIST_HEAD(&pstapriv->sta_hash[i]); - list_add_tail(&psta->list, get_list_head(&pstapriv->free_sta_queue)); - psta++; - } + #ifdef CONFIG_8723AU_AP_MODE pstapriv->sta_dz_bitmap = 0; pstapriv->tim_bitmap = 0; @@ -92,27 +78,6 @@ u32 _rtw_init_sta_priv23a(struct sta_priv *pstapriv) return _SUCCESS; } -/* this function is used to free the memory of lock || sema for all stainfos */ -static void rtw_mfree_all_stainfo(struct sta_priv *pstapriv) -{ - struct list_head *plist, *phead; - struct sta_info *psta; - - spin_lock_bh(&pstapriv->sta_hash_lock); - - phead = get_list_head(&pstapriv->free_sta_queue); - - /* we really achieve a lot in this loop .... */ - list_for_each(plist, phead) - psta = container_of(plist, struct sta_info, list); - spin_unlock_bh(&pstapriv->sta_hash_lock); -} - -static void rtw_mfree_sta_priv_lock(struct sta_priv *pstapriv) -{ - rtw_mfree_all_stainfo(pstapriv); /* be done before free sta_hash_lock */ -} - u32 _rtw_free_sta_priv23a(struct sta_priv *pstapriv) { struct list_head *phead, *plist, *ptmp; @@ -138,11 +103,6 @@ u32 _rtw_free_sta_priv23a(struct sta_priv *pstapriv) } spin_unlock_bh(&pstapriv->sta_hash_lock); /*===============================*/ - - rtw_mfree_sta_priv_lock(pstapriv); - - if (pstapriv->pallocated_stainfo_buf) - rtw_vmfree(pstapriv->pallocated_stainfo_buf, sizeof(struct sta_info)*NUM_STA+4); } return _SUCCESS; } @@ -151,23 +111,16 @@ struct sta_info *rtw_alloc_stainfo23a(struct sta_priv *pstapriv, u8 *hwaddr) { struct list_head *phash_list; struct sta_info *psta; - struct rtw_queue *pfree_sta_queue; struct recv_reorder_ctrl *preorder_ctrl; s32 index; int i = 0; u16 wRxSeqInitialValue = 0xffff; - pfree_sta_queue = &pstapriv->free_sta_queue; - - spin_lock_bh(&pstapriv->sta_hash_lock); - - if (_rtw_queue_empty23a(pfree_sta_queue)) { - spin_unlock_bh(&pstapriv->sta_hash_lock); + psta = (struct sta_info *)kmalloc(sizeof(struct sta_info), GFP_ATOMIC); + if (!psta) return NULL; - } - psta = container_of((&pfree_sta_queue->queue)->next, struct sta_info, list); - list_del_init(&psta->list); + spin_lock_bh(&pstapriv->sta_hash_lock); _rtw_init_stainfo(psta); @@ -233,9 +186,8 @@ exit: } /* using pstapriv->sta_hash_lock to protect */ -u32 rtw_free_stainfo23a(struct rtw_adapter *padapter, struct sta_info *psta) +u32 rtw_free_stainfo23a(struct rtw_adapter *padapter, struct sta_info *psta) { - struct rtw_queue *pfree_sta_queue; struct recv_reorder_ctrl *preorder_ctrl; struct sta_xmit_priv *pstaxmitpriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; @@ -250,8 +202,6 @@ u32 rtw_free_stainfo23a(struct rtw_adapter *padapter, struct sta_info *psta) psta->state &= ~_FW_LINKED; spin_unlock_bh(&psta->lock); - pfree_sta_queue = &pstapriv->free_sta_queue; - pstaxmitpriv = &psta->sta_xmitpriv; spin_lock_bh(&pxmitpriv->lock); @@ -355,7 +305,8 @@ u32 rtw_free_stainfo23a(struct rtw_adapter *padapter, struct sta_info *psta) psta->aid = 0; } #endif /* CONFIG_8723AU_AP_MODE */ - list_add_tail(&psta->list, get_list_head(pfree_sta_queue)); + + kfree(psta); exit: return _SUCCESS; } diff --git a/drivers/staging/rtl8723au/include/sta_info.h b/drivers/staging/rtl8723au/include/sta_info.h index 3a490d6dcbcc..27a604e7b5cb 100644 --- a/drivers/staging/rtl8723au/include/sta_info.h +++ b/drivers/staging/rtl8723au/include/sta_info.h @@ -310,13 +310,9 @@ struct sta_info { #define STA_PKTS_FMT "(m:%llu, c:%llu, d:%llu)" -struct sta_priv { - u8 *pallocated_stainfo_buf; - u8 *pstainfo_buf; - struct rtw_queue free_sta_queue; - +struct sta_priv { spinlock_t sta_hash_lock; - struct list_head sta_hash[NUM_STA]; + struct list_head sta_hash[NUM_STA]; int asoc_sta_count; struct rtw_queue sleep_q; struct rtw_queue wakeup_q; -- cgit v1.2.3 From 6e8bc71df6aeed8722256f5465b5857235c046a3 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:49 +0200 Subject: staging: rtl8723au: Add GFP argument to rtw_alloc_stainfo23a() No need to allocate GFP_ATOMIC when we don't need to. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 4 +++- drivers/staging/rtl8723au/core/rtw_cmd.c | 3 ++- drivers/staging/rtl8723au/core/rtw_mlme.c | 6 ++++-- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8723au/core/rtw_sta_mgt.c | 7 ++++--- drivers/staging/rtl8723au/include/sta_info.h | 2 +- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 9cf91a732405..01c6aeda63c5 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -1049,7 +1049,9 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, /* alloc sta_info for ap itself */ psta = rtw_get_stainfo23a(&padapter->stapriv, pbss_network->MacAddress); if (!psta) { - psta = rtw_alloc_stainfo23a(&padapter->stapriv, pbss_network->MacAddress); + psta = rtw_alloc_stainfo23a(&padapter->stapriv, + pbss_network->MacAddress, + GFP_KERNEL); if (!psta) return _FAIL; } diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index b94049fa96d8..a1f8ad98b742 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -1510,7 +1510,8 @@ void rtw_createbss_cmd23a_callback(struct rtw_adapter *padapter, pnetwork->MacAddress); if (!psta) { psta = rtw_alloc_stainfo23a(&padapter->stapriv, - pnetwork->MacAddress); + pnetwork->MacAddress, + GFP_KERNEL); if (!psta) { RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nCan't alloc sta_info when " diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 8983862d44f2..13bfc2fbc2fc 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -1014,7 +1014,8 @@ rtw_joinbss_update_stainfo(struct rtw_adapter *padapter, psta = rtw_get_stainfo23a(pstapriv, pnetwork->network.MacAddress); if (!psta) psta = rtw_alloc_stainfo23a(pstapriv, - pnetwork->network.MacAddress); + pnetwork->network.MacAddress, + GFP_ATOMIC); if (psta) { /* update ptarget_sta */ DBG_8723A("%s\n", __func__); @@ -1379,7 +1380,8 @@ void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf) return; } - psta = rtw_alloc_stainfo23a(&adapter->stapriv, pstassoc->macaddr); + psta = rtw_alloc_stainfo23a(&adapter->stapriv, pstassoc->macaddr, + GFP_KERNEL); if (!psta) { RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_, ("Can't alloc sta_info when " diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 5ac41131a1a9..7af99baa98ba 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -916,7 +916,7 @@ OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) /* allocate a new one */ DBG_8723A("going to alloc stainfo for sa ="MAC_FMT"\n", MAC_ARG(sa)); - pstat = rtw_alloc_stainfo23a(pstapriv, sa); + pstat = rtw_alloc_stainfo23a(pstapriv, sa, GFP_ATOMIC); if (!pstat) { DBG_8723A(" Exceed the upper limit of supported " "clients...\n"); diff --git a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c index 317c10a74569..068ad35e46df 100644 --- a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c @@ -107,7 +107,8 @@ u32 _rtw_free_sta_priv23a(struct sta_priv *pstapriv) return _SUCCESS; } -struct sta_info *rtw_alloc_stainfo23a(struct sta_priv *pstapriv, u8 *hwaddr) +struct sta_info * +rtw_alloc_stainfo23a(struct sta_priv *pstapriv, u8 *hwaddr, int gfp) { struct list_head *phash_list; struct sta_info *psta; @@ -116,7 +117,7 @@ struct sta_info *rtw_alloc_stainfo23a(struct sta_priv *pstapriv, u8 *hwaddr) int i = 0; u16 wRxSeqInitialValue = 0xffff; - psta = (struct sta_info *)kmalloc(sizeof(struct sta_info), GFP_ATOMIC); + psta = (struct sta_info *)kmalloc(sizeof(struct sta_info), gfp); if (!psta) return NULL; @@ -382,7 +383,7 @@ u32 rtw_init_bcmc_stainfo23a(struct rtw_adapter* padapter) u32 res = _SUCCESS; unsigned char bcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - psta = rtw_alloc_stainfo23a(pstapriv, bcast_addr); + psta = rtw_alloc_stainfo23a(pstapriv, bcast_addr, GFP_KERNEL); if (psta == NULL) { res = _FAIL; RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, diff --git a/drivers/staging/rtl8723au/include/sta_info.h b/drivers/staging/rtl8723au/include/sta_info.h index 27a604e7b5cb..195a3493395f 100644 --- a/drivers/staging/rtl8723au/include/sta_info.h +++ b/drivers/staging/rtl8723au/include/sta_info.h @@ -365,7 +365,7 @@ static inline u32 wifi_mac_hash(const u8 *mac) u32 _rtw_init_sta_priv23a(struct sta_priv *pstapriv); u32 _rtw_free_sta_priv23a(struct sta_priv *pstapriv); -struct sta_info *rtw_alloc_stainfo23a(struct sta_priv *pstapriv, u8 *hwaddr); +struct sta_info *rtw_alloc_stainfo23a(struct sta_priv *pstapriv, u8 *hwaddr, int gfp); u32 rtw_free_stainfo23a(struct rtw_adapter *padapter, struct sta_info *psta); void rtw_free_all_stainfo23a(struct rtw_adapter *padapter); struct sta_info *rtw_get_stainfo23a(struct sta_priv *pstapriv, const u8 *hwaddr); -- cgit v1.2.3 From 086f7a4d1758998c3692bb8d4fbd3a05eb27a7a1 Mon Sep 17 00:00:00 2001 From: Christian Engelmayer Date: Fri, 9 May 2014 15:03:50 +0200 Subject: staging: rtl8723au: fix potential leak in update_bcn_wps_ie() Fix a potential leak in the error path of function update_bcn_wps_ie(). Move the affected input verification to the beginning of the function so that it may return directly without leaking already allocated memory. Detected by Coverity - CID 1077718. Signed-off-by: Christian Engelmayer Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 01c6aeda63c5..da03196a3be2 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -1252,6 +1252,10 @@ static void update_bcn_wps_ie(struct rtw_adapter *padapter) DBG_8723A("%s\n", __func__); + pwps_ie_src = pmlmepriv->wps_beacon_ie; + if (pwps_ie_src == NULL) + return; + pwps_ie = rtw_get_wps_ie23a(ie+_FIXED_IE_LENGTH_, ielen-_FIXED_IE_LENGTH_, NULL, &wps_ielen); if (pwps_ie == NULL || wps_ielen == 0) @@ -1270,10 +1274,6 @@ static void update_bcn_wps_ie(struct rtw_adapter *padapter) remainder_ielen); } - pwps_ie_src = pmlmepriv->wps_beacon_ie; - if (pwps_ie_src == NULL) - return; - wps_ielen = (uint)pwps_ie_src[1];/* to get ie data len */ if ((wps_offset+wps_ielen+2+remainder_ielen)<= MAX_IE_SZ) { -- cgit v1.2.3 From 6042cbfddb1de718fad347b363fe9fadc8ceccd3 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:51 +0200 Subject: staging: rtl8723au: Declare rtw_alloc_xmitframe() static Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 18 ++++++++---------- drivers/staging/rtl8723au/include/rtw_xmit.h | 1 - 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 470d868f0f5c..c59f306a9efd 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -1515,14 +1515,8 @@ Otherwise, we must use _enter/_exit critical to protect free_xmit_queue... Must be very very cautious... */ -struct xmit_frame *rtw_alloc_xmitframe23a(struct xmit_priv *pxmitpriv)/* _queue *pfree_xmit_queue) */ +static struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv) { - /* - Please remember to use all the osdep_service api, - and lock/unlock or _enter/_exit critical to protect - pfree_xmit_queue - */ - struct xmit_frame *pxframe = NULL; struct list_head *plist, *phead; struct rtw_queue *pfree_xmit_queue = &pxmitpriv->free_xmit_queue; @@ -1530,7 +1524,9 @@ struct xmit_frame *rtw_alloc_xmitframe23a(struct xmit_priv *pxmitpriv)/* _queue spin_lock_bh(&pfree_xmit_queue->lock); if (_rtw_queue_empty23a(pfree_xmit_queue) == true) { - RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_alloc_xmitframe23a:%d\n", pxmitpriv->free_xmitframe_cnt)); + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, + ("rtw_alloc_xmitframe:%d\n", + pxmitpriv->free_xmitframe_cnt)); pxframe = NULL; } else { phead = get_list_head(pfree_xmit_queue); @@ -1541,7 +1537,9 @@ struct xmit_frame *rtw_alloc_xmitframe23a(struct xmit_priv *pxmitpriv)/* _queue list_del_init(&pxframe->list); pxmitpriv->free_xmitframe_cnt--; - RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_alloc_xmitframe23a():free_xmitframe_cnt =%d\n", pxmitpriv->free_xmitframe_cnt)); + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, + ("rtw_alloc_xmitframe():free_xmitframe_cnt =%d\n", + pxmitpriv->free_xmitframe_cnt)); } spin_unlock_bh(&pfree_xmit_queue->lock); @@ -1947,7 +1945,7 @@ int rtw_xmit23a(struct rtw_adapter *padapter, struct sk_buff *skb) struct xmit_frame *pxmitframe = NULL; s32 res; - pxmitframe = rtw_alloc_xmitframe23a(pxmitpriv); + pxmitframe = rtw_alloc_xmitframe(pxmitpriv); if (pxmitframe == NULL) { RT_TRACE(_module_xmit_osdep_c_, _drv_err_, diff --git a/drivers/staging/rtl8723au/include/rtw_xmit.h b/drivers/staging/rtl8723au/include/rtw_xmit.h index 5b879764518f..ca516623a2ba 100644 --- a/drivers/staging/rtl8723au/include/rtw_xmit.h +++ b/drivers/staging/rtl8723au/include/rtw_xmit.h @@ -357,7 +357,6 @@ void rtw_update_protection23a(struct rtw_adapter *padapter, u8 *ie, uint ie_len) s32 rtw_make_wlanhdr23a(struct rtw_adapter *padapter, u8 *hdr, struct pkt_attrib *pattrib); s32 rtw_put_snap23a(u8 *data, u16 h_proto); -struct xmit_frame *rtw_alloc_xmitframe23a(struct xmit_priv *pxmitpriv); struct xmit_frame *rtw_alloc_xmitframe23a_ext(struct xmit_priv *pxmitpriv); struct xmit_frame *rtw_alloc_xmitframe23a_once(struct xmit_priv *pxmitpriv); s32 rtw_free_xmitframe23a(struct xmit_priv *pxmitpriv, -- cgit v1.2.3 From 251ccc2d865be02f43d00000c48a1bc4fbd1016c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:52 +0200 Subject: staging: rtl8723au: Use kmalloc() rather than vmalloc() to allocate xmit_frames Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 53 ++++++++-------------------- drivers/staging/rtl8723au/include/rtw_xmit.h | 4 +-- 2 files changed, 15 insertions(+), 42 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index c59f306a9efd..f824b9ff2cd6 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -81,42 +81,21 @@ s32 _rtw_init_xmit_priv23a(struct xmit_priv *pxmitpriv, struct rtw_adapter *pada _rtw_init_queue23a(&pxmitpriv->free_xmit_queue); - /* - Please allocate memory with the sz = (struct xmit_frame) * NR_XMITFRAME, - and initialize free_xmit_frame below. - Please also apply free_txobj to link_up all the xmit_frames... - */ - - pxmitpriv->pallocated_frame_buf = rtw_zvmalloc(NR_XMITFRAME * sizeof(struct xmit_frame) + 4); - - if (pxmitpriv->pallocated_frame_buf == NULL) { - pxmitpriv->pxmit_frame_buf = NULL; - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_frame fail!\n")); - res = _FAIL; - goto exit; - } - pxmitpriv->pxmit_frame_buf = PTR_ALIGN(pxmitpriv->pallocated_frame_buf, 4); - - pxframe = (struct xmit_frame*) pxmitpriv->pxmit_frame_buf; - for (i = 0; i < NR_XMITFRAME; i++) { + pxframe = (struct xmit_frame *) + kzalloc(sizeof(struct xmit_frame), GFP_KERNEL); + if (!pxframe) + break; INIT_LIST_HEAD(&pxframe->list); pxframe->padapter = padapter; pxframe->frame_tag = NULL_FRAMETAG; - pxframe->pkt = NULL; - - pxframe->buf_addr = NULL; - pxframe->pxmitbuf = NULL; - list_add_tail(&pxframe->list, &pxmitpriv->free_xmit_queue.queue); - - pxframe++; } - pxmitpriv->free_xmitframe_cnt = NR_XMITFRAME; + pxmitpriv->free_xmitframe_cnt = i; pxmitpriv->frag_len = MAX_FRAG_THRESHOLD; @@ -242,7 +221,7 @@ fail: void _rtw_free_xmit_priv23a (struct xmit_priv *pxmitpriv) { struct rtw_adapter *padapter = pxmitpriv->adapter; - struct xmit_frame *pxmitframe = (struct xmit_frame*) pxmitpriv->pxmit_frame_buf; + struct xmit_frame *pxframe; struct xmit_buf *pxmitbuf; struct list_head *plist, *ptmp; u32 num_xmit_extbuf = NR_XMIT_EXTBUFF; @@ -250,11 +229,11 @@ void _rtw_free_xmit_priv23a (struct xmit_priv *pxmitpriv) rtw_hal_free_xmit_priv23a(padapter); - if (pxmitpriv->pxmit_frame_buf == NULL) - return; - for (i = 0; i < NR_XMITFRAME; i++) { - rtw_os_xmit_complete23a(padapter, pxmitframe); - pxmitframe++; + list_for_each_safe(plist, ptmp, &pxmitpriv->free_xmit_queue.queue) { + pxframe = container_of(plist, struct xmit_frame, list); + list_del_init(&pxframe->list); + rtw_os_xmit_complete23a(padapter, pxframe); + kfree(pxframe); } list_for_each_safe(plist, ptmp, &pxmitpriv->xmitbuf_list) { @@ -264,15 +243,11 @@ void _rtw_free_xmit_priv23a (struct xmit_priv *pxmitpriv) kfree(pxmitbuf); } - if (pxmitpriv->pallocated_frame_buf) { - rtw_vmfree(pxmitpriv->pallocated_frame_buf, NR_XMITFRAME * sizeof(struct xmit_frame) + 4); - } - /* free xframe_ext queue, the same count as extbuf */ - if ((pxmitframe = (struct xmit_frame*)pxmitpriv->xframe_ext)) { + if ((pxframe = (struct xmit_frame*)pxmitpriv->xframe_ext)) { for (i = 0; ixframe_ext_alloc_addr) diff --git a/drivers/staging/rtl8723au/include/rtw_xmit.h b/drivers/staging/rtl8723au/include/rtw_xmit.h index ca516623a2ba..e6d417c5e09a 100644 --- a/drivers/staging/rtl8723au/include/rtw_xmit.h +++ b/drivers/staging/rtl8723au/include/rtw_xmit.h @@ -286,9 +286,7 @@ struct xmit_priv { struct rtw_queue vo_pending; struct rtw_queue bm_pending; - u8 *pallocated_frame_buf; - u8 *pxmit_frame_buf; - uint free_xmitframe_cnt; + int free_xmitframe_cnt; struct rtw_queue free_xmit_queue; u8 *xframe_ext_alloc_addr; -- cgit v1.2.3 From 3a35058f2e4c6e2a6a8bb079d16fd6c632281097 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:53 +0200 Subject: stating: rtl8723au: Use kmalloc instead of vmalloc to allocate pool of xmit_frame_ext Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 34 +++++++++------------------- drivers/staging/rtl8723au/include/rtw_xmit.h | 4 +--- 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index f824b9ff2cd6..1ab7ded5679d 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -131,18 +131,11 @@ s32 _rtw_init_xmit_priv23a(struct xmit_priv *pxmitpriv, struct rtw_adapter *pada /* init xframe_ext queue, the same count as extbuf */ _rtw_init_queue23a(&pxmitpriv->free_xframe_ext_queue); - pxmitpriv->xframe_ext_alloc_addr = rtw_zvmalloc(num_xmit_extbuf * sizeof(struct xmit_frame) + 4); - - if (pxmitpriv->xframe_ext_alloc_addr == NULL) { - pxmitpriv->xframe_ext = NULL; - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xframe_ext fail!\n")); - res = _FAIL; - goto exit; - } - pxmitpriv->xframe_ext = PTR_ALIGN(pxmitpriv->xframe_ext_alloc_addr, 4); - pxframe = (struct xmit_frame*)pxmitpriv->xframe_ext; - for (i = 0; i < num_xmit_extbuf; i++) { + pxframe = (struct xmit_frame *) + kzalloc(sizeof(struct xmit_frame), GFP_KERNEL); + if (!pxframe) + break; INIT_LIST_HEAD(&pxframe->list); pxframe->padapter = padapter; @@ -157,10 +150,8 @@ s32 _rtw_init_xmit_priv23a(struct xmit_priv *pxmitpriv, struct rtw_adapter *pada list_add_tail(&pxframe->list, &pxmitpriv->free_xframe_ext_queue.queue); - - pxframe++; } - pxmitpriv->free_xframe_ext_cnt = num_xmit_extbuf; + pxmitpriv->free_xframe_ext_cnt = i; /* Init xmit extension buff */ _rtw_init_queue23a(&pxmitpriv->free_xmit_extbuf_queue); @@ -224,8 +215,6 @@ void _rtw_free_xmit_priv23a (struct xmit_priv *pxmitpriv) struct xmit_frame *pxframe; struct xmit_buf *pxmitbuf; struct list_head *plist, *ptmp; - u32 num_xmit_extbuf = NR_XMIT_EXTBUFF; - int i; rtw_hal_free_xmit_priv23a(padapter); @@ -244,14 +233,13 @@ void _rtw_free_xmit_priv23a (struct xmit_priv *pxmitpriv) } /* free xframe_ext queue, the same count as extbuf */ - if ((pxframe = (struct xmit_frame*)pxmitpriv->xframe_ext)) { - for (i = 0; ifree_xframe_ext_queue.queue) { + pxframe = container_of(plist, struct xmit_frame, list); + list_del_init(&pxframe->list); + rtw_os_xmit_complete23a(padapter, pxframe); + kfree(pxframe); } - if (pxmitpriv->xframe_ext_alloc_addr) - rtw_vmfree(pxmitpriv->xframe_ext_alloc_addr, num_xmit_extbuf * sizeof(struct xmit_frame) + 4); /* free xmit extension buff */ list_for_each_safe(plist, ptmp, &pxmitpriv->xmitextbuf_list) { diff --git a/drivers/staging/rtl8723au/include/rtw_xmit.h b/drivers/staging/rtl8723au/include/rtw_xmit.h index e6d417c5e09a..19c08d54c845 100644 --- a/drivers/staging/rtl8723au/include/rtw_xmit.h +++ b/drivers/staging/rtl8723au/include/rtw_xmit.h @@ -289,9 +289,7 @@ struct xmit_priv { int free_xmitframe_cnt; struct rtw_queue free_xmit_queue; - u8 *xframe_ext_alloc_addr; - u8 *xframe_ext; - uint free_xframe_ext_cnt; + int free_xframe_ext_cnt; struct rtw_queue free_xframe_ext_queue; uint frag_len; -- cgit v1.2.3 From 269746a4f3f6fab086b4eac5c912471f95232de3 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:54 +0200 Subject: staging: rtl723au: Remove some obsolete misleading comments Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 12 +++--------- drivers/staging/rtl8723au/include/rtw_xmit.h | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 1ab7ded5679d..18007cf1340e 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -50,27 +50,21 @@ void _rtw_init_sta_xmit_priv23a(struct sta_xmit_priv *psta_xmitpriv) } -s32 _rtw_init_xmit_priv23a(struct xmit_priv *pxmitpriv, struct rtw_adapter *padapter) +int _rtw_init_xmit_priv23a(struct xmit_priv *pxmitpriv, + struct rtw_adapter *padapter) { int i; struct xmit_buf *pxmitbuf; struct xmit_frame *pxframe; - int res = _SUCCESS; + int res = _SUCCESS; u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ; u32 num_xmit_extbuf = NR_XMIT_EXTBUFF; - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by rtw_zvmalloc(). */ - /* memset((unsigned char *)pxmitpriv, 0, sizeof(struct xmit_priv)); */ - spin_lock_init(&pxmitpriv->lock); spin_lock_init(&pxmitpriv->lock_sctx); sema_init(&pxmitpriv->xmit_sema, 0); sema_init(&pxmitpriv->terminate_xmitthread_sema, 0); - /* - Please insert all the queue initializaiton using _rtw_init_queue23a below - */ - pxmitpriv->adapter = padapter; _rtw_init_queue23a(&pxmitpriv->be_pending); diff --git a/drivers/staging/rtl8723au/include/rtw_xmit.h b/drivers/staging/rtl8723au/include/rtw_xmit.h index 19c08d54c845..155ac5d42b1d 100644 --- a/drivers/staging/rtl8723au/include/rtw_xmit.h +++ b/drivers/staging/rtl8723au/include/rtw_xmit.h @@ -377,7 +377,7 @@ s32 rtw_txframes_pending23a(struct rtw_adapter *padapter); s32 rtw_txframes_sta_ac_pending23a(struct rtw_adapter *padapter, struct pkt_attrib *pattrib); void rtw_init_hwxmits23a(struct hw_xmit *phwxmit, int entry); -s32 _rtw_init_xmit_priv23a(struct xmit_priv *pxmitpriv, +int _rtw_init_xmit_priv23a(struct xmit_priv *pxmitpriv, struct rtw_adapter *padapter); void _rtw_free_xmit_priv23a(struct xmit_priv *pxmitpriv); void rtw_alloc_hwxmits23a(struct rtw_adapter *padapter); -- cgit v1.2.3 From fd6d1c111b397454c8e16b447cd18a40c4bc68c5 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:55 +0200 Subject: staging: rtl8723au: Use kmalloc instead of vmalloc to allocate recv_frame pool Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_recv.c | 40 ++++++++-------------------- drivers/staging/rtl8723au/include/rtw_recv.h | 4 +-- 2 files changed, 12 insertions(+), 32 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 0999cf2311c7..3f134320cc23 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -47,12 +47,6 @@ int _rtw_init_recv_priv23a(struct recv_priv *precvpriv, int i; int res = _SUCCESS; - - - /* We don't need to memset padapter->XXX to zero, because - adapter is allocated by rtw_zvmalloc(). */ - /* memset((unsigned char *)precvpriv, 0, sizeof (struct recv_priv)); */ - spin_lock_init(&precvpriv->lock); _rtw_init_queue23a(&precvpriv->free_recv_queue); @@ -61,19 +55,11 @@ int _rtw_init_recv_priv23a(struct recv_priv *precvpriv, precvpriv->adapter = padapter; - precvpriv->free_recvframe_cnt = NR_RECVFRAME; - - precvpriv->pallocated_frame_buf = - rtw_zvmalloc(NR_RECVFRAME * sizeof(struct recv_frame)); - - if (precvpriv->pallocated_frame_buf == NULL) { - res = _FAIL; - goto exit; - } - - precvframe = precvpriv->pallocated_frame_buf; - for (i = 0; i < NR_RECVFRAME ; i++) { + precvframe = (struct recv_frame *) + kzalloc(sizeof(struct recv_frame), GFP_KERNEL); + if (!precvframe) + break; INIT_LIST_HEAD(&precvframe->list); list_add_tail(&precvframe->list, @@ -83,6 +69,7 @@ int _rtw_init_recv_priv23a(struct recv_priv *precvpriv, precvframe++; } + precvpriv->free_recvframe_cnt = i; precvpriv->rx_pending_cnt = 1; sema_init(&precvpriv->allrxreturnevt, 0); @@ -96,29 +83,24 @@ int _rtw_init_recv_priv23a(struct recv_priv *precvpriv, rtw_set_signal_stat_timer(precvpriv); -exit: - - - return res; } void _rtw_free_recv_priv23a (struct recv_priv *precvpriv) { struct rtw_adapter *padapter = precvpriv->adapter; - - + struct recv_frame *precvframe; + struct list_head *plist, *ptmp; rtw_free_uc_swdec_pending_queue23a(padapter); - if (precvpriv->pallocated_frame_buf) { - rtw_vmfree(precvpriv->pallocated_frame_buf, - NR_RECVFRAME * sizeof(struct recv_frame)); + list_for_each_safe(plist, ptmp, &precvpriv->free_recv_queue.queue) { + precvframe = container_of(plist, struct recv_frame, list); + list_del_init(&precvframe->list); + kfree(precvframe); } rtw_hal_free_recv_priv23a(padapter); - - } struct recv_frame *rtw_alloc_recvframe23a(struct rtw_queue *pfree_recv_queue) diff --git a/drivers/staging/rtl8723au/include/rtw_recv.h b/drivers/staging/rtl8723au/include/rtw_recv.h index 0a88506ab859..f47d159bfede 100644 --- a/drivers/staging/rtl8723au/include/rtw_recv.h +++ b/drivers/staging/rtl8723au/include/rtw_recv.h @@ -171,9 +171,7 @@ struct recv_priv { struct rtw_queue recv_pending_queue; struct rtw_queue uc_swdec_pending_queue; - void *pallocated_frame_buf; - - uint free_recvframe_cnt; + int free_recvframe_cnt; struct rtw_adapter *adapter; -- cgit v1.2.3 From 6f43d3bd9cd35a6d89333843ba4ca08ef0886604 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:56 +0200 Subject: staging: rtl8723au: Remove ugly vmalloc() wrappers Finally with the last user converted, get rid of ugly vmalloc wrappers Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/osdep_service.h | 7 ------- drivers/staging/rtl8723au/os_dep/osdep_service.c | 24 ----------------------- 2 files changed, 31 deletions(-) diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index 105e1c9713dc..3ec2469b3582 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -128,13 +128,6 @@ static inline u32 CHKBIT(u32 x) int RTW_STATUS_CODE23a(int error_code); -u8* _rtw_vmalloc(u32 sz); -u8* _rtw_zvmalloc(u32 sz); -void _rtw_vmfree(u8 *pbuf, u32 sz); -#define rtw_vmalloc(sz) _rtw_vmalloc((sz)) -#define rtw_zvmalloc(sz) _rtw_zvmalloc((sz)) -#define rtw_vmfree(pbuf, sz) _rtw_vmfree((pbuf), (sz)) - extern unsigned char REALTEK_96B_IE23A[]; extern unsigned char MCS_rate_2R23A[16]; extern unsigned char WPA_TKIP_CIPHER23A[4]; diff --git a/drivers/staging/rtl8723au/os_dep/osdep_service.c b/drivers/staging/rtl8723au/os_dep/osdep_service.c index 9138a175ebd0..68fa7a8fb7af 100644 --- a/drivers/staging/rtl8723au/os_dep/osdep_service.c +++ b/drivers/staging/rtl8723au/os_dep/osdep_service.c @@ -19,7 +19,6 @@ #include #include #include -#include /* * Translate the OS dependent @param error_code to OS independent RTW_STATUS_CODE23a @@ -32,29 +31,6 @@ inline int RTW_STATUS_CODE23a(int error_code) return _FAIL; } -inline u8 *_rtw_vmalloc(u32 sz) -{ - u8 *pbuf; - pbuf = vmalloc(sz); - - return pbuf; -} - -inline u8 *_rtw_zvmalloc(u32 sz) -{ - u8 *pbuf; - pbuf = _rtw_vmalloc(sz); - if (pbuf != NULL) - memset(pbuf, 0, sz); - - return pbuf; -} - -inline void _rtw_vmfree(u8 *pbuf, u32 sz) -{ - vfree(pbuf); -} - void _rtw_init_queue23a(struct rtw_queue *pqueue) { INIT_LIST_HEAD(&pqueue->queue); -- cgit v1.2.3 From a954a18f46d445c63ecb45dd369b4edb8aba3aed Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:57 +0200 Subject: staging: rtl8723au: Remove unused semaphore 'allrxreturnevt' Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_recv.c | 2 -- drivers/staging/rtl8723au/include/rtw_recv.h | 1 - 2 files changed, 3 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 3f134320cc23..756ad3f0ebd5 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -72,8 +72,6 @@ int _rtw_init_recv_priv23a(struct recv_priv *precvpriv, precvpriv->free_recvframe_cnt = i; precvpriv->rx_pending_cnt = 1; - sema_init(&precvpriv->allrxreturnevt, 0); - res = rtw_hal_init23a_recv_priv(padapter); setup_timer(&precvpriv->signal_stat_timer, rtw_signal_stat_timer_hdl23a, diff --git a/drivers/staging/rtl8723au/include/rtw_recv.h b/drivers/staging/rtl8723au/include/rtw_recv.h index f47d159bfede..35e47dac8615 100644 --- a/drivers/staging/rtl8723au/include/rtw_recv.h +++ b/drivers/staging/rtl8723au/include/rtw_recv.h @@ -187,7 +187,6 @@ struct recv_priv { uint rx_middlepacket_crcerr; /* u8 *pallocated_urb_buf; */ - struct semaphore allrxreturnevt; uint ff_hwaddr; u8 rx_pending_cnt; -- cgit v1.2.3 From c5779a0d1feff5d4e16f3bd4b1b17a41aac51d8a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:58 +0200 Subject: staging: rtl8723au: rtw_free_recvframe23a() is always passed precvpriv->free_recv_queue No point in passing in the pointer to free_recv_queue, when we always pass in the same value. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_recv.c | 56 +++++++++++---------------- drivers/staging/rtl8723au/core/rtw_sta_mgt.c | 3 +- drivers/staging/rtl8723au/hal/usb_ops_linux.c | 10 ++--- drivers/staging/rtl8723au/include/rtw_recv.h | 3 +- drivers/staging/rtl8723au/os_dep/recv_linux.c | 8 ++-- 5 files changed, 31 insertions(+), 49 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 756ad3f0ebd5..131b98c0582b 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -133,18 +133,18 @@ struct recv_frame *rtw_alloc_recvframe23a(struct rtw_queue *pfree_recv_queue) return pframe; } -int rtw_free_recvframe23a(struct recv_frame *precvframe, struct rtw_queue *pfree_recv_queue) +int rtw_free_recvframe23a(struct recv_frame *precvframe) { struct rtw_adapter *padapter = precvframe->adapter; struct recv_priv *precvpriv = &padapter->recvpriv; - - + struct rtw_queue *pfree_recv_queue; if (precvframe->pkt) { dev_kfree_skb_any(precvframe->pkt);/* free skb by driver */ precvframe->pkt = NULL; } + pfree_recv_queue = &precvpriv->free_recv_queue; spin_lock_bh(&pfree_recv_queue->lock); list_del_init(&precvframe->list); @@ -192,12 +192,11 @@ using spinlock to protect */ -void rtw_free_recvframe23a_queue(struct rtw_queue *pframequeue, struct rtw_queue *pfree_recv_queue) +static void rtw_free_recvframe23a_queue(struct rtw_queue *pframequeue) { struct recv_frame *hdr; struct list_head *plist, *phead, *ptmp; - spin_lock(&pframequeue->lock); phead = get_list_head(pframequeue); @@ -205,12 +204,10 @@ void rtw_free_recvframe23a_queue(struct rtw_queue *pframequeue, struct rtw_queu list_for_each_safe(plist, ptmp, phead) { hdr = container_of(plist, struct recv_frame, list); - rtw_free_recvframe23a(hdr, pfree_recv_queue); + rtw_free_recvframe23a(hdr); } spin_unlock(&pframequeue->lock); - - } u32 rtw_free_uc_swdec_pending_queue23a(struct rtw_adapter *adapter) @@ -218,8 +215,7 @@ u32 rtw_free_uc_swdec_pending_queue23a(struct rtw_adapter *adapter) u32 cnt = 0; struct recv_frame *pending_frame; while ((pending_frame = rtw_alloc_recvframe23a(&adapter->recvpriv.uc_swdec_pending_queue))) { - rtw_free_recvframe23a(pending_frame, - &adapter->recvpriv.free_recv_queue); + rtw_free_recvframe23a(pending_frame); DBG_8723A("%s: dequeue uc_swdec_pending_queue\n", __func__); cnt++; } @@ -532,8 +528,7 @@ struct recv_frame *decryptor(struct rtw_adapter *padapter, } if (res == _FAIL) { - rtw_free_recvframe23a(return_packet, - &padapter->recvpriv.free_recv_queue); + rtw_free_recvframe23a(return_packet); return_packet = NULL; } @@ -586,8 +581,7 @@ static struct recv_frame *portctrl(struct rtw_adapter *adapter, prtnframe = precv_frame; } else { /* free this frame */ - rtw_free_recvframe23a(precv_frame, - &adapter->recvpriv.free_recv_queue); + rtw_free_recvframe23a(precv_frame); prtnframe = NULL; } } else { @@ -1653,8 +1647,8 @@ struct recv_frame *recvframe_defrag(struct rtw_adapter *adapter, if (curfragnum != prframe->attrib.frag_num) { /* the first fragment number must be 0 */ /* free the whole queue */ - rtw_free_recvframe23a(prframe, pfree_recv_queue); - rtw_free_recvframe23a_queue(defrag_q, pfree_recv_queue); + rtw_free_recvframe23a(prframe); + rtw_free_recvframe23a_queue(defrag_q); return NULL; } @@ -1674,8 +1668,8 @@ struct recv_frame *recvframe_defrag(struct rtw_adapter *adapter, /* the fragment number must be increasing (after decache) */ /* release the defrag_q & prframe */ - rtw_free_recvframe23a(prframe, pfree_recv_queue); - rtw_free_recvframe23a_queue(defrag_q, pfree_recv_queue); + rtw_free_recvframe23a(prframe); + rtw_free_recvframe23a_queue(defrag_q); return NULL; } @@ -1703,7 +1697,7 @@ struct recv_frame *recvframe_defrag(struct rtw_adapter *adapter, }; /* free the defrag_q queue and return the prframe */ - rtw_free_recvframe23a_queue(defrag_q, pfree_recv_queue); + rtw_free_recvframe23a_queue(defrag_q); RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("Performance defrag!!!!!\n")); @@ -1764,7 +1758,7 @@ struct recv_frame* recvframe_chk_defrag23a(struct rtw_adapter *padapter, /* the first fragment */ if (_rtw_queue_empty23a(pdefrag_q) == false) { /* free current defrag_q */ - rtw_free_recvframe23a_queue(pdefrag_q, pfree_recv_queue); + rtw_free_recvframe23a_queue(pdefrag_q); } } @@ -1785,7 +1779,7 @@ struct recv_frame* recvframe_chk_defrag23a(struct rtw_adapter *padapter, } else { /* can't find this ta's defrag_queue, so free this recv_frame */ - rtw_free_recvframe23a(precv_frame, pfree_recv_queue); + rtw_free_recvframe23a(precv_frame); prtnframe = NULL; RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("Free because pdefrag_q == NULL: ismfrag = " @@ -1811,7 +1805,7 @@ struct recv_frame* recvframe_chk_defrag23a(struct rtw_adapter *padapter, } else { /* can't find this ta's defrag_queue, so free this recv_frame */ - rtw_free_recvframe23a(precv_frame, pfree_recv_queue); + rtw_free_recvframe23a(precv_frame); prtnframe = NULL; RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("Free because pdefrag_q == NULL: ismfrag = " @@ -1826,7 +1820,7 @@ struct recv_frame* recvframe_chk_defrag23a(struct rtw_adapter *padapter, RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvframe_chkmic(padapter, prtnframe) ==" "_FAIL\n")); - rtw_free_recvframe23a(prtnframe, pfree_recv_queue); + rtw_free_recvframe23a(prtnframe); prtnframe = NULL; } } @@ -1842,8 +1836,6 @@ int amsdu_to_msdu(struct rtw_adapter *padapter, struct recv_frame *prframe) struct rx_pkt_attrib *pattrib; struct sk_buff *skb, *sub_skb; struct sk_buff_head skb_list; - struct recv_priv *precvpriv = &padapter->recvpriv; - struct rtw_queue *pfree_recv_queue = &precvpriv->free_recv_queue; pattrib = &prframe->attrib; @@ -1865,7 +1857,7 @@ int amsdu_to_msdu(struct rtw_adapter *padapter, struct recv_frame *prframe) } prframe->pkt = NULL; - rtw_free_recvframe23a(prframe, pfree_recv_queue); + rtw_free_recvframe23a(prframe); return _SUCCESS; } @@ -2020,10 +2012,8 @@ int recv_indicatepkts_in_order(struct rtw_adapter *padapter, } } else { if (amsdu_to_msdu(padapter, prframe) != - _SUCCESS) { - rtw_free_recvframe23a(prframe, - &precvpriv->free_recv_queue); - } + _SUCCESS) + rtw_free_recvframe23a(prframe); } /* Update local variables. */ @@ -2228,7 +2218,6 @@ int process_recv_indicatepkts(struct rtw_adapter *padapter, static int recv_func_prehandle(struct rtw_adapter *padapter, struct recv_frame *rframe) { - struct rtw_queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue; int ret = _SUCCESS; /* check the frame crtl field and decache */ @@ -2236,7 +2225,7 @@ static int recv_func_prehandle(struct rtw_adapter *padapter, if (ret != _SUCCESS) { RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("recv_func: validate_recv_frame fail! drop pkt\n")); - rtw_free_recvframe23a(rframe, pfree_recv_queue); + rtw_free_recvframe23a(rframe); goto exit; } @@ -2250,7 +2239,6 @@ static int recv_func_posthandle(struct rtw_adapter *padapter, int ret = _SUCCESS; struct recv_frame *orig_prframe = prframe; struct recv_priv *precvpriv = &padapter->recvpriv; - struct rtw_queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue; /* DATA FRAME */ rtw_led_control(padapter, LED_CTL_RX); @@ -2296,7 +2284,7 @@ static int recv_func_posthandle(struct rtw_adapter *padapter, if (ret != _SUCCESS) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recv_func: process_recv_indicatepkts fail!\n")); - rtw_free_recvframe23a(orig_prframe, pfree_recv_queue);/* free this recv_frame */ + rtw_free_recvframe23a(orig_prframe);/* free this recv_frame */ goto _recv_data_drop; } return ret; diff --git a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c index 068ad35e46df..403dc8e07e73 100644 --- a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c @@ -255,7 +255,6 @@ u32 rtw_free_stainfo23a(struct rtw_adapter *padapter, struct sta_info *psta) struct list_head *phead, *plist; struct recv_frame *prframe; struct rtw_queue *ppending_recvframe_queue; - struct rtw_queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue; preorder_ctrl = &psta->recvreorder_ctrl[i]; @@ -271,7 +270,7 @@ u32 rtw_free_stainfo23a(struct rtw_adapter *padapter, struct sta_info *psta) prframe = container_of(plist, struct recv_frame, list); plist = plist->next; list_del_init(&prframe->list); - rtw_free_recvframe23a(prframe, pfree_recv_queue); + rtw_free_recvframe23a(prframe); } spin_unlock_bh(&ppending_recvframe_queue->lock); } diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index 870fe5dabce4..3aa0374cb60a 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -513,7 +513,7 @@ static int recvbuf2recvframe(struct rtw_adapter *padapter, struct sk_buff *pskb) if (pattrib->crc_err) { DBG_8723A("%s()-%d: RX Warning! rx CRC ERROR !!\n", __FUNCTION__, __LINE__); - rtw_free_recvframe23a(precvframe, pfree_recv_queue); + rtw_free_recvframe23a(precvframe); goto _exit_recvbuf2recvframe; } @@ -525,7 +525,7 @@ static int recvbuf2recvframe(struct rtw_adapter *padapter, struct sk_buff *pskb) ("recvbuf2recvframe: pkt_len<= 0\n")); DBG_8723A("%s()-%d: RX Warning!\n", __FUNCTION__, __LINE__); - rtw_free_recvframe23a(precvframe, pfree_recv_queue); + rtw_free_recvframe23a(precvframe); goto _exit_recvbuf2recvframe; } @@ -570,8 +570,7 @@ static int recvbuf2recvframe(struct rtw_adapter *padapter, struct sk_buff *pskb) if ((pattrib->mfrag == 1) && (pattrib->frag_num == 0)) { DBG_8723A("recvbuf2recvframe: alloc_skb fail, " "drop frag frame \n"); - rtw_free_recvframe23a(precvframe, - pfree_recv_queue); + rtw_free_recvframe23a(precvframe); goto _exit_recvbuf2recvframe; } @@ -579,8 +578,7 @@ static int recvbuf2recvframe(struct rtw_adapter *padapter, struct sk_buff *pskb) if (!precvframe->pkt) { DBG_8723A("recvbuf2recvframe: skb_clone " "fail\n"); - rtw_free_recvframe23a(precvframe, - pfree_recv_queue); + rtw_free_recvframe23a(precvframe); goto _exit_recvbuf2recvframe; } } diff --git a/drivers/staging/rtl8723au/include/rtw_recv.h b/drivers/staging/rtl8723au/include/rtw_recv.h index 35e47dac8615..3bd836fc74d8 100644 --- a/drivers/staging/rtl8723au/include/rtw_recv.h +++ b/drivers/staging/rtl8723au/include/rtw_recv.h @@ -279,11 +279,10 @@ struct recv_frame { /* get a free recv_frame from pfree_recv_queue */ struct recv_frame *rtw_alloc_recvframe23a(struct rtw_queue *pfree_recv_queue); -int rtw_free_recvframe23a(struct recv_frame *precvframe, struct rtw_queue *pfree_recv_queue); +int rtw_free_recvframe23a(struct recv_frame *precvframe); int rtw_enqueue_recvframe23a(struct recv_frame *precvframe, struct rtw_queue *queue); -void rtw_free_recvframe23a_queue(struct rtw_queue *pframequeue, struct rtw_queue *pfree_recv_queue); u32 rtw_free_uc_swdec_pending_queue23a(struct rtw_adapter *adapter); int rtw_enqueue_recvbuf23a_to_head(struct recv_buf *precvbuf, struct rtw_queue *queue); diff --git a/drivers/staging/rtl8723au/os_dep/recv_linux.c b/drivers/staging/rtl8723au/os_dep/recv_linux.c index 528ed9253b14..bcd970baf405 100644 --- a/drivers/staging/rtl8723au/os_dep/recv_linux.c +++ b/drivers/staging/rtl8723au/os_dep/recv_linux.c @@ -73,12 +73,10 @@ int rtw_recv_indicatepkt23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { struct recv_priv *precvpriv; - struct rtw_queue *pfree_recv_queue; struct sk_buff *skb; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - precvpriv = &(padapter->recvpriv); - pfree_recv_queue = &(precvpriv->free_recv_queue); + precvpriv = &padapter->recvpriv; skb = precv_frame->pkt; if (!skb) { @@ -147,7 +145,7 @@ _recv_indicatepkt_end: precv_frame->pkt = NULL; /* pointers to NULL before rtw_free_recvframe23a() */ - rtw_free_recvframe23a(precv_frame, pfree_recv_queue); + rtw_free_recvframe23a(precv_frame); RT_TRACE(_module_recv_osdep_c_, _drv_info_, ("\n rtw_recv_indicatepkt23a :after netif_rx!!!!\n")); @@ -155,7 +153,7 @@ _recv_indicatepkt_end: _recv_indicatepkt_drop: - rtw_free_recvframe23a(precv_frame, pfree_recv_queue); + rtw_free_recvframe23a(precv_frame); return _FAIL; } -- cgit v1.2.3 From 794ff0530e43d9a6d96cf0ece451225dd77e7b1c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:03:59 +0200 Subject: staging: rtl8723au: Eliminate _rtw_queue_empty23a() This was just a silly wrapper around list_empty() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ioctl_set.c | 2 +- drivers/staging/rtl8723au/core/rtw_recv.c | 6 +++--- drivers/staging/rtl8723au/core/rtw_xmit.c | 16 +++++++++------- drivers/staging/rtl8723au/include/osdep_service.h | 1 - drivers/staging/rtl8723au/os_dep/osdep_service.c | 8 -------- 5 files changed, 13 insertions(+), 20 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c index b03266bc1f3c..0024ff6f13e0 100644 --- a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c @@ -45,7 +45,7 @@ u8 rtw_do_join23a(struct rtw_adapter *padapter) pmlmepriv->to_join = true; - if (_rtw_queue_empty23a(queue) == true) { + if (list_empty(&queue->queue)) { spin_unlock_bh(&pmlmepriv->scanned_queue.lock); _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 131b98c0582b..014bb54c1a13 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -110,7 +110,7 @@ struct recv_frame *rtw_alloc_recvframe23a(struct rtw_queue *pfree_recv_queue) spin_lock_bh(&pfree_recv_queue->lock); - if (_rtw_queue_empty23a(pfree_recv_queue) == true) + if (list_empty(&pfree_recv_queue->queue)) pframe = NULL; else { phead = get_list_head(pfree_recv_queue); @@ -255,7 +255,7 @@ struct recv_buf *rtw_dequeue_recvbuf23a (struct rtw_queue *queue) spin_lock_irqsave(&queue->lock, irqL); - if (_rtw_queue_empty23a(queue) == true) { + if (list_empty(&queue->queue)) { precvbuf = NULL; } else { phead = get_list_head(queue); @@ -1756,7 +1756,7 @@ struct recv_frame* recvframe_chk_defrag23a(struct rtw_adapter *padapter, if (pdefrag_q != NULL) { if (fragnum == 0) { /* the first fragment */ - if (_rtw_queue_empty23a(pdefrag_q) == false) { + if (!list_empty(&pdefrag_q->queue)) { /* free current defrag_q */ rtw_free_recvframe23a_queue(pdefrag_q); } diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 18007cf1340e..829283f58a3b 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -984,10 +984,10 @@ s32 rtw_txframes_pending23a(struct rtw_adapter *padapter) { struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - return (!_rtw_queue_empty23a(&pxmitpriv->be_pending)) || - (!_rtw_queue_empty23a(&pxmitpriv->bk_pending)) || - (!_rtw_queue_empty23a(&pxmitpriv->vi_pending)) || - (!_rtw_queue_empty23a(&pxmitpriv->vo_pending)); + return (!list_empty(&pxmitpriv->be_pending.queue)) || + (!list_empty(&pxmitpriv->bk_pending.queue)) || + (!list_empty(&pxmitpriv->vi_pending.queue)) || + (!list_empty(&pxmitpriv->vo_pending.queue)); } s32 rtw_txframes_sta_ac_pending23a(struct rtw_adapter *padapter, @@ -1480,7 +1480,7 @@ static struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv) spin_lock_bh(&pfree_xmit_queue->lock); - if (_rtw_queue_empty23a(pfree_xmit_queue) == true) { + if (list_empty(&pfree_xmit_queue->queue)) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_alloc_xmitframe:%d\n", pxmitpriv->free_xmitframe_cnt)); @@ -1514,7 +1514,7 @@ struct xmit_frame *rtw_alloc_xmitframe23a_ext(struct xmit_priv *pxmitpriv) spin_lock_bh(&queue->lock); - if (_rtw_queue_empty23a(queue) == true) { + if (list_empty(&queue->queue)) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_alloc_xmitframe23a_ext:%d\n", pxmitpriv->free_xframe_ext_cnt)); pxframe = NULL; } else { @@ -1673,7 +1673,9 @@ rtw_dequeue_xframe23a(struct xmit_priv *pxmitpriv, struct hw_xmit *phwxmit_i, phwxmit->accnt--; /* Remove sta node when there is no pending packets. */ - if (_rtw_queue_empty23a(pframe_queue)) /* must be done after get_next and before break */ + /* must be done after get_next and + before break */ + if (list_empty(&pframe_queue->queue)) list_del_init(&ptxservq->tx_pending); goto exit; } diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index 3ec2469b3582..6992797044a8 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -137,7 +137,6 @@ extern unsigned char MCS_rate_2R23A[16]; extern unsigned char MCS_rate_1R23A[16]; void _rtw_init_queue23a(struct rtw_queue *pqueue); -u32 _rtw_queue_empty23a(struct rtw_queue *pqueue); void rtw_suspend_lock_init(void); void rtw_suspend_lock_uninit(void); diff --git a/drivers/staging/rtl8723au/os_dep/osdep_service.c b/drivers/staging/rtl8723au/os_dep/osdep_service.c index 68fa7a8fb7af..57c7bf8c314b 100644 --- a/drivers/staging/rtl8723au/os_dep/osdep_service.c +++ b/drivers/staging/rtl8723au/os_dep/osdep_service.c @@ -36,11 +36,3 @@ void _rtw_init_queue23a(struct rtw_queue *pqueue) INIT_LIST_HEAD(&pqueue->queue); spin_lock_init(&pqueue->lock); } - -u32 _rtw_queue_empty23a(struct rtw_queue *pqueue) -{ - if (list_empty(&pqueue->queue)) - return true; - else - return false; -} -- cgit v1.2.3 From be4c50604d22f0fd2c65853af18292f44d784b86 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:00 +0200 Subject: staging: rtl8723au: Eliminate RTW_STATUS_CODE23a() Inline the parsing of status codes. Long term we should pass back the proper status codes and get rid of the ugly _FAIL/_SUCCESS mess. This is one small step in that direction. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_io.c | 20 ++++++++++++++++---- drivers/staging/rtl8723au/include/osdep_service.h | 2 -- drivers/staging/rtl8723au/os_dep/osdep_service.c | 11 ----------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_io.c b/drivers/staging/rtl8723au/core/rtw_io.c index 20680e0ce9e0..cf6d30f005b6 100644 --- a/drivers/staging/rtl8723au/core/rtw_io.c +++ b/drivers/staging/rtl8723au/core/rtw_io.c @@ -72,7 +72,10 @@ int _rtw_write823a(struct rtw_adapter *adapter, u32 addr, u8 val) ret = io_ops->_write8(adapter, addr, val); - return RTW_STATUS_CODE23a(ret); + if (ret < 0) + return _FAIL; + else + return _SUCCESS; } int _rtw_write1623a(struct rtw_adapter *adapter, u32 addr, u16 val) @@ -82,7 +85,10 @@ int _rtw_write1623a(struct rtw_adapter *adapter, u32 addr, u16 val) ret = io_ops->_write16(adapter, addr, val); - return RTW_STATUS_CODE23a(ret); + if (ret < 0) + return _FAIL; + else + return _SUCCESS; } int _rtw_write3223a(struct rtw_adapter *adapter, u32 addr, u32 val) @@ -92,7 +98,10 @@ int _rtw_write3223a(struct rtw_adapter *adapter, u32 addr, u32 val) ret = io_ops->_write32(adapter, addr, val); - return RTW_STATUS_CODE23a(ret); + if (ret < 0) + return _FAIL; + else + return _SUCCESS; } int _rtw_writeN23a(struct rtw_adapter *adapter, u32 addr , u32 length , u8 *pdata) @@ -102,7 +111,10 @@ int _rtw_writeN23a(struct rtw_adapter *adapter, u32 addr , u32 length , u8 *pdat ret = io_ops->_writeN(adapter, addr, length, pdata); - return RTW_STATUS_CODE23a(ret); + if (ret < 0) + return _FAIL; + else + return _SUCCESS; } void _rtw_read_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem) { diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index 6992797044a8..c4711a6c0af0 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -126,8 +126,6 @@ static inline u32 CHKBIT(u32 x) #define BIT35 0x0800000000 #define BIT36 0x1000000000 -int RTW_STATUS_CODE23a(int error_code); - extern unsigned char REALTEK_96B_IE23A[]; extern unsigned char MCS_rate_2R23A[16]; extern unsigned char WPA_TKIP_CIPHER23A[4]; diff --git a/drivers/staging/rtl8723au/os_dep/osdep_service.c b/drivers/staging/rtl8723au/os_dep/osdep_service.c index 57c7bf8c314b..f5f385b7932f 100644 --- a/drivers/staging/rtl8723au/os_dep/osdep_service.c +++ b/drivers/staging/rtl8723au/os_dep/osdep_service.c @@ -20,17 +20,6 @@ #include #include -/* -* Translate the OS dependent @param error_code to OS independent RTW_STATUS_CODE23a -* @return: one of RTW_STATUS_CODE23a -*/ -inline int RTW_STATUS_CODE23a(int error_code) -{ - if (error_code >= 0) - return _SUCCESS; - return _FAIL; -} - void _rtw_init_queue23a(struct rtw_queue *pqueue) { INIT_LIST_HEAD(&pqueue->queue); -- cgit v1.2.3 From 5e3a829996e88a70efde2392e18883767c3e0142 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:01 +0200 Subject: staging: rtl8723au: Remove some unused prototypes Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/osdep_service.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index c4711a6c0af0..f514dd335881 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -136,11 +136,6 @@ extern unsigned char MCS_rate_1R23A[16]; void _rtw_init_queue23a(struct rtw_queue *pqueue); -void rtw_suspend_lock_init(void); -void rtw_suspend_lock_uninit(void); -void rtw_lock_suspend(void); -void rtw_unlock_suspend(void); - #define NDEV_FMT "%s" #define NDEV_ARG(ndev) ndev->name -- cgit v1.2.3 From dc24abd409275235425eb39104801c350ab48be1 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:02 +0200 Subject: staging: rtl8723au: Get rid of NDEV_FMT/NDEV_ARG macros Silly use-once macros that simply obfuscates the code. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/osdep_service.h | 2 -- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 5 ++--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index f514dd335881..67887bcdaec3 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -137,8 +137,6 @@ extern unsigned char MCS_rate_1R23A[16]; void _rtw_init_queue23a(struct rtw_queue *pqueue); -#define NDEV_FMT "%s" -#define NDEV_ARG(ndev) ndev->name #define ADPT_FMT "%s" #define ADPT_ARG(adapter) adapter->pnetdev->name #define FUNC_NDEV_FMT "%s(%s)" diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index ca100dcc2763..efdb48dfbb4d 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -2558,9 +2558,8 @@ static int rtw_cfg80211_add_monitor_if(struct rtw_adapter *padapter, char *name, } if (pwdev_priv->pmon_ndev) { - DBG_8723A(FUNC_ADPT_FMT " monitor interface exist: " NDEV_FMT - "\n", FUNC_ADPT_ARG(padapter), - NDEV_ARG(pwdev_priv->pmon_ndev)); + DBG_8723A(FUNC_ADPT_FMT " monitor interface exist: %s\n", + FUNC_ADPT_ARG(padapter), pwdev_priv->pmon_ndev->name); ret = -EBUSY; goto out; } -- cgit v1.2.3 From 9cd613c739ee436862e681acad8ded18ff85fd9a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:03 +0200 Subject: staging: rtl8723au: Remove FUNC_ADPT_{FMT,ARG} Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 9 --- drivers/staging/rtl8723au/core/rtw_ioctl_set.c | 4 +- drivers/staging/rtl8723au/core/rtw_mlme.c | 2 +- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 70 ++++++++++++----------- drivers/staging/rtl8723au/core/rtw_sreset.c | 19 ++++-- drivers/staging/rtl8723au/include/osdep_service.h | 2 - drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 69 +++++++++------------- 7 files changed, 79 insertions(+), 96 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index a1f8ad98b742..cd8af988cb4a 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -380,11 +380,6 @@ u8 rtw_sitesurvey_cmd23a(struct rtw_adapter *padapter, memcpy(&psurveyPara->ssid[i], &ssid[i], sizeof(struct cfg80211_ssid)); psurveyPara->ssid_num++; - if (0) - DBG_8723A(FUNC_ADPT_FMT" ssid:(%s, %d)\n", - FUNC_ADPT_ARG(padapter), - psurveyPara->ssid[i].ssid, - psurveyPara->ssid[i].ssid_len); } } } @@ -398,10 +393,6 @@ u8 rtw_sitesurvey_cmd23a(struct rtw_adapter *padapter, memcpy(&psurveyPara->ch[i], &ch[i], sizeof(struct rtw_ieee80211_channel)); psurveyPara->ch_num++; - if (0) - DBG_8723A(FUNC_ADPT_FMT" ch:%u\n", - FUNC_ADPT_ARG(padapter), - psurveyPara->ch[i].hw_value); } } } diff --git a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c index 0024ff6f13e0..abf30c5ce10a 100644 --- a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c @@ -406,8 +406,8 @@ u8 rtw_set_802_11_bssid23a_list_scan(struct rtw_adapter *padapter, } } else { if (rtw_is_scan_deny(padapter)) { - DBG_8723A(FUNC_ADPT_FMT": scan deny\n", - FUNC_ADPT_ARG(padapter)); + DBG_8723A("%s(%s): scan deny\n", + __func__, padapter->pnetdev->name); return _SUCCESS; } diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 13bfc2fbc2fc..e4656adfb051 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -1600,7 +1600,7 @@ void rtw_scan_timeout_handler23a(unsigned long data) struct rtw_adapter *adapter = (struct rtw_adapter *)data; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - DBG_8723A(FUNC_ADPT_FMT" fw_state =%x\n", FUNC_ADPT_ARG(adapter), + DBG_8723A("%s(%s): fw_state =%x\n", __func__, adapter->pnetdev->name, get_fwstate(pmlmepriv)); spin_lock_bh(&pmlmepriv->lock); diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 7af99baa98ba..839ced140da7 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -2086,17 +2086,17 @@ static s32 rtw_action_public_decache(struct recv_frame *recv_frame, s32 token) if (token >= 0) { if ((seq_ctrl == mlmeext->action_public_rxseq) && (token == mlmeext->action_public_dialog_token)) { - DBG_8723A(FUNC_ADPT_FMT" seq_ctrl = 0x%x, " - "rxseq = 0x%x, token:%d\n", - FUNC_ADPT_ARG(adapter), seq_ctrl, + DBG_8723A("%s(%s): seq_ctrl = 0x%x, " + "rxseq = 0x%x, token:%d\n", __func__, + adapter->pnetdev->name, seq_ctrl, mlmeext->action_public_rxseq, token); return _FAIL; } } else { if (seq_ctrl == mlmeext->action_public_rxseq) { - DBG_8723A(FUNC_ADPT_FMT" seq_ctrl = 0x%x, " - "rxseq = 0x%x\n", - FUNC_ADPT_ARG(adapter), seq_ctrl, + DBG_8723A("%s(%s): seq_ctrl = 0x%x, " + "rxseq = 0x%x\n", __func__, + adapter->pnetdev->name, seq_ctrl, mlmeext->action_public_rxseq); return _FAIL; } @@ -2257,15 +2257,15 @@ struct xmit_frame *alloc_mgtxmitframe23a(struct xmit_priv *pxmitpriv) pmgntframe = rtw_alloc_xmitframe23a_ext(pxmitpriv); if (!pmgntframe) { - DBG_8723A(FUNC_ADPT_FMT" alloc xmitframe fail\n", - FUNC_ADPT_ARG(pxmitpriv->adapter)); + DBG_8723A("%s(%s): alloc xmitframe fail\n", __func__, + pxmitpriv->adapter->pnetdev->name); goto exit; } pxmitbuf = rtw_alloc_xmitbuf23a_ext(pxmitpriv); if (!pxmitbuf) { - DBG_8723A(FUNC_ADPT_FMT" alloc xmitbuf fail\n", - FUNC_ADPT_ARG(pxmitpriv->adapter)); + DBG_8723A("%s(%s): alloc xmitbuf fail\n", __func__, + pxmitpriv->adapter->pnetdev->name); rtw_free_xmitframe23a(pxmitpriv, pmgntframe); pmgntframe = NULL; goto exit; @@ -2719,9 +2719,9 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, remainder_ie = ssid_ie + 2; remainder_ielen = pframe - remainder_ie; - DBG_8723A_LEVEL(_drv_warning_, FUNC_ADPT_FMT - " remainder_ielen > MAX_IE_SZ\n", - FUNC_ADPT_ARG(padapter)); + DBG_8723A_LEVEL(_drv_warning_, "%s(%s): " + "remainder_ielen > MAX_IE_SZ\n", + __func__, padapter->pnetdev->name); if (remainder_ielen > MAX_IE_SZ) remainder_ielen = MAX_IE_SZ; @@ -2947,14 +2947,15 @@ int issue_probereq23a_ex23a(struct rtw_adapter *padapter, if (try_cnt && wait_ms) { if (da) - DBG_8723A(FUNC_ADPT_FMT" to "MAC_FMT", ch:%u%s, %d/%d " - "in %u ms\n", FUNC_ADPT_ARG(padapter), + DBG_8723A("%s(%s): to "MAC_FMT", ch:%u%s, %d/%d " + "in %u ms\n", __func__, + padapter->pnetdev->name, MAC_ARG(da), rtw_get_oper_ch23a(padapter), ret == _SUCCESS?", acked":"", i, try_cnt, jiffies_to_msecs(jiffies - start)); else - DBG_8723A(FUNC_ADPT_FMT", ch:%u%s, %d/%d in %u ms\n", - FUNC_ADPT_ARG(padapter), + DBG_8723A("%s(%s):, ch:%u%s, %d/%d in %u ms\n", + __func__, padapter->pnetdev->name, rtw_get_oper_ch23a(padapter), ret == _SUCCESS?", acked":"", i, try_cnt, jiffies_to_msecs(jiffies - start)); @@ -3646,14 +3647,15 @@ int issue_nulldata23a(struct rtw_adapter *padapter, unsigned char *da, if (try_cnt && wait_ms) { if (da) - DBG_8723A(FUNC_ADPT_FMT" to "MAC_FMT", ch:%u%s, %d/%d " - "in %u ms\n", FUNC_ADPT_ARG(padapter), + DBG_8723A("%s(%s): to "MAC_FMT", ch:%u%s, %d/%d " + "in %u ms\n", __func__, + padapter->pnetdev->name, MAC_ARG(da), rtw_get_oper_ch23a(padapter), ret == _SUCCESS?", acked":"", i, try_cnt, jiffies_to_msecs(jiffies - start)); else - DBG_8723A(FUNC_ADPT_FMT", ch:%u%s, %d/%d in %u ms\n", - FUNC_ADPT_ARG(padapter), + DBG_8723A("%s(%s):, ch:%u%s, %d/%d in %u ms\n", + __func__, padapter->pnetdev->name, rtw_get_oper_ch23a(padapter), ret == _SUCCESS?", acked":"", i, try_cnt, jiffies_to_msecs(jiffies - start)); @@ -3775,14 +3777,15 @@ int issue_qos_nulldata23a(struct rtw_adapter *padapter, unsigned char *da, if (try_cnt && wait_ms) { if (da) - DBG_8723A(FUNC_ADPT_FMT" to "MAC_FMT", ch:%u%s, %d/%d " - "in %u ms\n", FUNC_ADPT_ARG(padapter), + DBG_8723A("%s(%s): to "MAC_FMT", ch:%u%s, %d/%d " + "in %u ms\n", __func__, + padapter->pnetdev->name, MAC_ARG(da), rtw_get_oper_ch23a(padapter), ret == _SUCCESS?", acked":"", i, try_cnt, jiffies_to_msecs(jiffies - start)); else - DBG_8723A(FUNC_ADPT_FMT", ch:%u%s, %d/%d in %u ms\n", - FUNC_ADPT_ARG(padapter), + DBG_8723A("%s(%s):, ch:%u%s, %d/%d in %u ms\n", + __func__, padapter->pnetdev->name, rtw_get_oper_ch23a(padapter), ret == _SUCCESS?", acked":"", i, try_cnt, jiffies_to_msecs(jiffies - start)); @@ -3886,14 +3889,15 @@ int issue_deauth23a_ex23a(struct rtw_adapter *padapter, u8 *da, if (try_cnt && wait_ms) { if (da) - DBG_8723A(FUNC_ADPT_FMT" to "MAC_FMT", ch:%u%s, %d/%d " - "in %u ms\n", FUNC_ADPT_ARG(padapter), + DBG_8723A("%s(%s): to "MAC_FMT", ch:%u%s, %d/%d " + "in %u ms\n", __func__, + padapter->pnetdev->name, MAC_ARG(da), rtw_get_oper_ch23a(padapter), ret == _SUCCESS?", acked":"", i, try_cnt, jiffies_to_msecs(jiffies - start)); else - DBG_8723A(FUNC_ADPT_FMT", ch:%u%s, %d/%d in %u ms\n", - FUNC_ADPT_ARG(padapter), + DBG_8723A("%s(%s):, ch:%u%s, %d/%d in %u ms\n", + __func__, padapter->pnetdev->name, rtw_get_oper_ch23a(padapter), ret == _SUCCESS?", acked":"", i, try_cnt, jiffies_to_msecs(jiffies - start)); @@ -5618,8 +5622,10 @@ void linked_status_chk23a(struct rtw_adapter *padapter) if (rx_chk == _FAIL) { pmlmeext->retry++; if (pmlmeext->retry > rx_chk_limit) { - DBG_8723A_LEVEL(_drv_always_, FUNC_ADPT_FMT" disconnect or roaming\n", - FUNC_ADPT_ARG(padapter)); + DBG_8723A_LEVEL(_drv_always_, + "%s(%s): disconnect or " + "roaming\n", __func__, + padapter->pnetdev->name); receive_disconnect23a(padapter, pmlmeinfo->network.MacAddress, WLAN_REASON_EXPIRATION_CHK); return; @@ -6083,8 +6089,6 @@ rtw_scan_ch_decision(struct rtw_adapter *padapter, /* acquire channels from in */ j = 0; for (i = 0;ichannel_set, in[i].hw_value)) >= 0 ) diff --git a/drivers/staging/rtl8723au/core/rtw_sreset.c b/drivers/staging/rtl8723au/core/rtw_sreset.c index 5bf7beb6d19c..0e1ea3142006 100644 --- a/drivers/staging/rtl8723au/core/rtw_sreset.c +++ b/drivers/staging/rtl8723au/core/rtw_sreset.c @@ -157,17 +157,24 @@ static void sreset_restore_network_status(struct rtw_adapter *padapter) struct mlme_priv *mlmepriv = &padapter->mlmepriv; if (check_fwstate(mlmepriv, WIFI_STATION_STATE)) { - DBG_8723A(FUNC_ADPT_FMT" fwstate:0x%08x - WIFI_STATION_STATE\n", FUNC_ADPT_ARG(padapter), get_fwstate(mlmepriv)); + DBG_8723A("%s(%s): fwstate:0x%08x - WIFI_STATION_STATE\n", + __func__, padapter->pnetdev->name, + get_fwstate(mlmepriv)); sreset_restore_network_station(padapter); #ifdef CONFIG_8723AU_AP_MODE } else if (check_fwstate(mlmepriv, WIFI_AP_STATE)) { - DBG_8723A(FUNC_ADPT_FMT" fwstate:0x%08x - WIFI_AP_STATE\n", FUNC_ADPT_ARG(padapter), get_fwstate(mlmepriv)); + DBG_8723A("%s(%s): fwstate:0x%08x - WIFI_AP_STATE\n", + __func__, padapter->pnetdev->name, + get_fwstate(mlmepriv)); rtw_ap_restore_network(padapter); #endif } else if (check_fwstate(mlmepriv, WIFI_ADHOC_STATE)) { - DBG_8723A(FUNC_ADPT_FMT" fwstate:0x%08x - WIFI_ADHOC_STATE\n", FUNC_ADPT_ARG(padapter), get_fwstate(mlmepriv)); + DBG_8723A("%s(%s): fwstate:0x%08x - WIFI_ADHOC_STATE\n", + __func__, padapter->pnetdev->name, + get_fwstate(mlmepriv)); } else { - DBG_8723A(FUNC_ADPT_FMT" fwstate:0x%08x - ???\n", FUNC_ADPT_ARG(padapter), get_fwstate(mlmepriv)); + DBG_8723A("%s(%s): fwstate:0x%08x - ???\n", __func__, + padapter->pnetdev->name, get_fwstate(mlmepriv)); } } @@ -179,7 +186,7 @@ static void sreset_stop_adapter(struct rtw_adapter *padapter) if (padapter == NULL) return; - DBG_8723A(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(padapter)); + DBG_8723A("%s(%s)\n", __func__, padapter->pnetdev->name); if (!rtw_netif_queue_stopped(padapter->pnetdev)) netif_tx_stop_all_queues(padapter->pnetdev); @@ -204,7 +211,7 @@ static void sreset_start_adapter(struct rtw_adapter *padapter) if (padapter == NULL) return; - DBG_8723A(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(padapter)); + DBG_8723A("%s(%s)\n", __func__, padapter->pnetdev->name); if (check_fwstate(pmlmepriv, _FW_LINKED)) { sreset_restore_network_status(padapter); diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index 67887bcdaec3..d7322ea6dc56 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -141,8 +141,6 @@ void _rtw_init_queue23a(struct rtw_queue *pqueue); #define ADPT_ARG(adapter) adapter->pnetdev->name #define FUNC_NDEV_FMT "%s(%s)" #define FUNC_NDEV_ARG(ndev) __func__, ndev->name -#define FUNC_ADPT_FMT "%s(%s)" -#define FUNC_ADPT_ARG(adapter) __func__, adapter->pnetdev->name /* Macros for handling unaligned memory accesses */ diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index efdb48dfbb4d..e0bd62bd554e 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -646,8 +646,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, if (!psta && check_fwstate(pmlmepriv, WIFI_AP_STATE)) { /* group key */ if (param->u.crypt.set_tx == 0) { /* group key */ if (strcmp(param->u.crypt.alg, "WEP") == 0) { - DBG_8723A("%s, set group_key, WEP\n", - __func__); + DBG_8723A("%s, set group_key, WEP\n", __func__); memcpy(psecuritypriv-> dot118021XGrpKey[param->u.crypt.idx]. @@ -1451,7 +1450,7 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy, struct cfg80211_ssid *ssids = request->ssids; bool need_indicate_scan_done = false; - DBG_8723A(FUNC_ADPT_FMT "\n", FUNC_ADPT_ARG(padapter)); + DBG_8723A("%s(%s):\n", __func__, padapter->pnetdev->name); spin_lock_bh(&pwdev_priv->scan_req_lock); pwdev_priv->scan_request = request; @@ -1480,8 +1479,8 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy, goto check_need_indicate_scan_done; } if (rtw_is_scan_deny(padapter)) { - DBG_8723A(FUNC_ADPT_FMT ": scan deny\n", - FUNC_ADPT_ARG(padapter)); + DBG_8723A("%s(%s): scan deny\n", __func__, + padapter->pnetdev->name); need_indicate_scan_done = true; goto check_need_indicate_scan_done; } @@ -1509,8 +1508,8 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy, if (request->n_channels == 1) { for (i = 0; i < request->n_channels && i < RTW_CHANNEL_SCAN_AMOUNT; i++) { - DBG_8723A(FUNC_ADPT_FMT CHAN_FMT "\n", - FUNC_ADPT_ARG(padapter), + DBG_8723A("%s:(%s):" CHAN_FMT "\n", + __func__, padapter->pnetdev->name, CHAN_ARG(request->channels[i])); ch[i].hw_value = request->channels[i]->hw_value; ch[i].flags = request->channels[i]->flags; @@ -2551,23 +2550,23 @@ static int rtw_cfg80211_add_monitor_if(struct rtw_adapter *padapter, char *name, struct rtw_wdev_priv *pwdev_priv = wdev_to_priv(padapter->rtw_wdev); if (!name) { - DBG_8723A(FUNC_ADPT_FMT " without specific name\n", - FUNC_ADPT_ARG(padapter)); + DBG_8723A("%s(%s): without specific name\n", + __func__, padapter->pnetdev->name); ret = -EINVAL; goto out; } if (pwdev_priv->pmon_ndev) { - DBG_8723A(FUNC_ADPT_FMT " monitor interface exist: %s\n", - FUNC_ADPT_ARG(padapter), pwdev_priv->pmon_ndev->name); + DBG_8723A("%s(%s): monitor interface exist: %s\n", __func__, + padapter->pnetdev->name, pwdev_priv->pmon_ndev->name); ret = -EBUSY; goto out; } mon_ndev = alloc_etherdev(sizeof(struct rtw_adapter)); if (!mon_ndev) { - DBG_8723A(FUNC_ADPT_FMT " allocate ndev fail\n", - FUNC_ADPT_ARG(padapter)); + DBG_8723A("%s(%s): allocate ndev fail\n", __func__, + padapter->pnetdev->name); ret = -ENOMEM; goto out; } @@ -2582,8 +2581,8 @@ static int rtw_cfg80211_add_monitor_if(struct rtw_adapter *padapter, char *name, /* wdev */ mon_wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL); if (!mon_wdev) { - DBG_8723A(FUNC_ADPT_FMT " allocate mon_wdev fail\n", - FUNC_ADPT_ARG(padapter)); + DBG_8723A("%s(%s): allocate mon_wdev fail\n", __func__, + padapter->pnetdev->name); ret = -ENOMEM; goto out; } @@ -2624,8 +2623,8 @@ cfg80211_rtw_add_virtual_intf(struct wiphy *wiphy, const char *name, struct net_device *ndev = NULL; struct rtw_adapter *padapter = wiphy_to_adapter(wiphy); - DBG_8723A(FUNC_ADPT_FMT " wiphy:%s, name:%s, type:%d\n", - FUNC_ADPT_ARG(padapter), wiphy_name(wiphy), name, type); + DBG_8723A("%s(%s): wiphy:%s, name:%s, type:%d\n", __func__, + padapter->pnetdev->name, wiphy_name(wiphy), name, type); switch (type) { case NL80211_IFTYPE_ADHOC: @@ -2654,7 +2653,8 @@ cfg80211_rtw_add_virtual_intf(struct wiphy *wiphy, const char *name, break; } - DBG_8723A(FUNC_ADPT_FMT " ndev:%p, ret:%d\n", FUNC_ADPT_ARG(padapter), + DBG_8723A("%s(%s): ndev:%p, ret:%d\n", __func__, + padapter->pnetdev->name, ndev, ret); return ndev ? ndev->ieee80211_ptr : ERR_PTR(ret); @@ -2757,29 +2757,12 @@ static int cfg80211_rtw_start_ap(struct wiphy *wiphy, struct net_device *ndev, struct wlan_bssid_ex *pbss_network_ext = &adapter->mlmeextpriv.mlmext_info.network; - if (0) - DBG_8723A(FUNC_ADPT_FMT - " ssid:(%s,%d), from ie:(%s,%d)\n", - FUNC_ADPT_ARG(adapter), settings->ssid, - (int)settings->ssid_len, - pbss_network->Ssid.ssid, - pbss_network->Ssid.ssid_len); - memcpy(pbss_network->Ssid.ssid, (void *)settings->ssid, settings->ssid_len); pbss_network->Ssid.ssid_len = settings->ssid_len; memcpy(pbss_network_ext->Ssid.ssid, (void *)settings->ssid, settings->ssid_len); pbss_network_ext->Ssid.ssid_len = settings->ssid_len; - - if (0) - DBG_8723A(FUNC_ADPT_FMT - " after ssid:(%s,%d), (%s,%d)\n", - FUNC_ADPT_ARG(adapter), - pbss_network->Ssid.ssid, - pbss_network->Ssid.ssid_len, - pbss_network_ext->Ssid.ssid, - pbss_network_ext->Ssid.ssid_len); } return ret; @@ -3102,16 +3085,16 @@ static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, /* cookie generation */ *cookie = (unsigned long)buf; - DBG_8723A(FUNC_ADPT_FMT " len =%zu, ch =%d" - "\n", FUNC_ADPT_ARG(padapter), len, tx_ch); + DBG_8723A("%s(%s): len =%zu, ch =%d\n", __func__, + padapter->pnetdev->name, len, tx_ch); /* indicate ack before issue frame to avoid racing with rsp frame */ rtw_cfg80211_mgmt_tx_status(padapter, *cookie, buf, len, ack, GFP_KERNEL); if (rtw_action_frame_parse23a(buf, len, &category, &action) == false) { - DBG_8723A(FUNC_ADPT_FMT " frame_control:0x%x\n", - FUNC_ADPT_ARG(padapter), + DBG_8723A("%s(%s): frame_control:0x%x\n", __func__, + padapter->pnetdev->name, le16_to_cpu(hdr->frame_control)); goto exit; } @@ -3130,8 +3113,8 @@ static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, } while (dump_cnt < dump_limit && tx_ret != _SUCCESS); if (tx_ret != _SUCCESS || dump_cnt > 1) { - DBG_8723A(FUNC_ADPT_FMT " %s (%d/%d) in %d ms\n", - FUNC_ADPT_ARG(padapter), + DBG_8723A("%s(%s): %s (%d/%d) in %d ms\n", + __func__, padapter->pnetdev->name, tx_ret == _SUCCESS ? "OK" : "FAIL", dump_cnt, dump_limit, jiffies_to_msecs(jiffies - start)); } @@ -3143,9 +3126,9 @@ static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, case P2P_INVIT_RESP: if (pwdev_priv->invit_info.flags & BIT(0) && pwdev_priv->invit_info.status == 0) { - DBG_8723A(FUNC_ADPT_FMT " agree with invitation of " + DBG_8723A("%s(%s): agree with invitation of " "persistent group\n", - FUNC_ADPT_ARG(padapter)); + __func__, padapter->pnetdev->name); rtw_set_scan_deny(padapter, 5000); rtw_pwr_wakeup_ex(padapter, 5000); rtw_clear_scan_deny(padapter); -- cgit v1.2.3 From a790d58e6832262692416d41af99670b7aa1dca4 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:04 +0200 Subject: staging: rtl8723au: Get rid of FUNC_NDEV_{FMT,ARG} Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 6 +- drivers/staging/rtl8723au/core/rtw_cmd.c | 7 +- drivers/staging/rtl8723au/core/rtw_mlme.c | 8 +- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 11 ++- drivers/staging/rtl8723au/include/osdep_service.h | 2 - drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 92 +++++++++++------------ drivers/staging/rtl8723au/os_dep/os_intfs.c | 4 +- 7 files changed, 61 insertions(+), 69 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index da03196a3be2..58b2359a990c 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -1778,8 +1778,8 @@ int rtw_ap_inform_ch_switch23a (struct rtw_adapter *padapter, u8 new_ch, u8 ch_o if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) return ret; - DBG_8723A(FUNC_NDEV_FMT" with ch:%u, offset:%u\n", - FUNC_NDEV_ARG(padapter->pnetdev), new_ch, ch_offset); + DBG_8723A("%s(%s): with ch:%u, offset:%u\n", __func__, + padapter->pnetdev->name, new_ch, ch_offset); spin_lock_bh(&pstapriv->asoc_list_lock); phead = &pstapriv->asoc_list; @@ -1810,7 +1810,7 @@ int rtw_sta_flush23a(struct rtw_adapter *padapter) struct sta_info *chk_alive_list[NUM_STA]; int i; - DBG_8723A(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(padapter->pnetdev)); + DBG_8723A("%s(%s)\n", __func__, padapter->pnetdev->name); if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) return ret; diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index cd8af988cb4a..8609dce66c46 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -893,8 +893,8 @@ u8 rtw_set_ch_cmd23a(struct rtw_adapter*padapter, u8 ch, u8 bw, u8 ch_offset, u8 res = _SUCCESS; - DBG_8723A(FUNC_NDEV_FMT" ch:%u, bw:%u, ch_offset:%u\n", - FUNC_NDEV_ARG(padapter->pnetdev), ch, bw, ch_offset); + DBG_8723A("%s(%s): ch:%u, bw:%u, ch_offset:%u\n", __func__, + padapter->pnetdev->name, ch, bw, ch_offset); /* check input parameter */ @@ -932,8 +932,7 @@ u8 rtw_set_ch_cmd23a(struct rtw_adapter*padapter, u8 ch, u8 bw, u8 ch_offset, /* do something based on res... */ exit: - DBG_8723A(FUNC_NDEV_FMT" res:%u\n", FUNC_NDEV_ARG(padapter->pnetdev), - res); + DBG_8723A("%s(%s): res:%u\n", __func__, padapter->pnetdev->name, res); return res; } diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index e4656adfb051..48b6d4ba3915 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -987,15 +987,15 @@ void rtw_scan_abort23a(struct rtw_adapter *adapter) if (adapter->bDriverStopped || adapter->bSurpriseRemoved) break; - DBG_8723A(FUNC_NDEV_FMT "fw_state = _FW_UNDER_SURVEY!\n", - FUNC_NDEV_ARG(adapter->pnetdev)); + DBG_8723A("%s(%s): fw_state = _FW_UNDER_SURVEY!\n", + __func__, adapter->pnetdev->name); msleep(20); } if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { if (!adapter->bDriverStopped && !adapter->bSurpriseRemoved) - DBG_8723A(FUNC_NDEV_FMT "waiting for scan_abort time " - "out!\n", FUNC_NDEV_ARG(adapter->pnetdev)); + DBG_8723A("%s(%s): waiting for scan_abort time out!\n", + __func__, adapter->pnetdev->name); rtw_cfg80211_indicate_scan_done(wdev_to_priv(adapter->rtw_wdev), true); } diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 839ced140da7..596d0f369858 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -3918,9 +3918,8 @@ void issue_action_spct_ch_switch23a(struct rtw_adapter *padapter, struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; u8 category, action; - DBG_8723A(FUNC_NDEV_FMT" ra ="MAC_FMT", ch:%u, offset:%u\n", - FUNC_NDEV_ARG(padapter->pnetdev), MAC_ARG(ra), - new_ch, ch_offset); + DBG_8723A("%s(%s): ra ="MAC_FMT", ch:%u, offset:%u\n", __func__, + padapter->pnetdev->name, MAC_ARG(ra), new_ch, ch_offset); if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) return; @@ -6527,9 +6526,9 @@ u8 set_ch_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) set_ch_parm = (struct set_ch_parm *)pbuf; - DBG_8723A(FUNC_NDEV_FMT" ch:%u, bw:%u, ch_offset:%u\n", - FUNC_NDEV_ARG(padapter->pnetdev), - set_ch_parm->ch, set_ch_parm->bw, set_ch_parm->ch_offset); + DBG_8723A("%s(%s): ch:%u, bw:%u, ch_offset:%u\n", __func__, + padapter->pnetdev->name, set_ch_parm->ch, + set_ch_parm->bw, set_ch_parm->ch_offset); pmlmeext->cur_channel = set_ch_parm->ch; pmlmeext->cur_ch_offset = set_ch_parm->ch_offset; diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index d7322ea6dc56..48fefa13ba04 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -139,8 +139,6 @@ void _rtw_init_queue23a(struct rtw_queue *pqueue); #define ADPT_FMT "%s" #define ADPT_ARG(adapter) adapter->pnetdev->name -#define FUNC_NDEV_FMT "%s(%s)" -#define FUNC_NDEV_ARG(ndev) __func__, ndev->name /* Macros for handling unaligned memory accesses */ diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index e0bd62bd554e..d79d690e3302 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -1080,7 +1080,7 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev, struct rtw_adapter *padapter = wiphy_to_adapter(wiphy); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - DBG_8723A(FUNC_NDEV_FMT " adding key for %pM\n", FUNC_NDEV_ARG(ndev), + DBG_8723A("%s(%s): adding key for %pM\n", __func__, ndev->name, mac_addr); DBG_8723A("cipher = 0x%x\n", params->cipher); DBG_8723A("key_len = 0x%x\n", params->key_len); @@ -1165,7 +1165,7 @@ cfg80211_rtw_get_key(struct wiphy *wiphy, struct net_device *ndev, void *cookie, void (*callback) (void *cookie, struct key_params *)) { - DBG_8723A(FUNC_NDEV_FMT "\n", FUNC_NDEV_ARG(ndev)); + DBG_8723A("%s(%s)\n", __func__, ndev->name); return 0; } @@ -1176,8 +1176,7 @@ static int cfg80211_rtw_del_key(struct wiphy *wiphy, struct net_device *ndev, struct rtw_adapter *padapter = netdev_priv(ndev); struct security_priv *psecuritypriv = &padapter->securitypriv; - DBG_8723A(FUNC_NDEV_FMT " key_index =%d\n", FUNC_NDEV_ARG(ndev), - key_index); + DBG_8723A("%s(%s): key_index =%d\n", __func__, ndev->name, key_index); if (key_index == psecuritypriv->dot11PrivacyKeyIndex) { /* clear the flag of wep default key set. */ @@ -1194,9 +1193,8 @@ static int cfg80211_rtw_set_default_key(struct wiphy *wiphy, struct rtw_adapter *padapter = netdev_priv(ndev); struct security_priv *psecuritypriv = &padapter->securitypriv; - DBG_8723A(FUNC_NDEV_FMT " key_index =%d" - ", unicast =%d, multicast =%d.\n", FUNC_NDEV_ARG(ndev), - key_index, unicast, multicast); + DBG_8723A("%s(%s): key_index =%d, unicast =%d, multicast =%d.\n", + __func__, ndev->name, key_index, unicast, multicast); if ((key_index < WEP_KEYS) && ((psecuritypriv->dot11PrivacyAlgrthm == _WEP40_) || @@ -1234,7 +1232,7 @@ static int cfg80211_rtw_get_station(struct wiphy *wiphy, sinfo->filled = 0; if (!mac) { - DBG_8723A(FUNC_NDEV_FMT " mac ==%p\n", FUNC_NDEV_ARG(ndev), mac); + DBG_8723A("%s(%s): mac ==%p\n", __func__, ndev->name, mac); ret = -ENOENT; goto exit; } @@ -1245,7 +1243,7 @@ static int cfg80211_rtw_get_station(struct wiphy *wiphy, ret = -ENOENT; goto exit; } - DBG_8723A(FUNC_NDEV_FMT " mac =" MAC_FMT "\n", FUNC_NDEV_ARG(ndev), + DBG_8723A("%s(%s): mac =" MAC_FMT "\n", __func__, ndev->name, MAC_ARG(mac)); /* for infra./P2PClient mode */ @@ -1300,7 +1298,7 @@ static int cfg80211_rtw_change_iface(struct wiphy *wiphy, int ret = 0; u8 change = false; - DBG_8723A(FUNC_NDEV_FMT " call netdev_open23a\n", FUNC_NDEV_ARG(ndev)); + DBG_8723A("%s(%s): call netdev_open23a\n", __func__, ndev->name); if (netdev_open23a(ndev) != 0) { ret = -EPERM; goto exit; @@ -1312,8 +1310,8 @@ static int cfg80211_rtw_change_iface(struct wiphy *wiphy, } old_type = rtw_wdev->iftype; - DBG_8723A(FUNC_NDEV_FMT " old_iftype =%d, new_iftype =%d\n", - FUNC_NDEV_ARG(ndev), old_type, type); + DBG_8723A("%s(%s): old_iftype =%d, new_iftype =%d\n", + __func__, ndev->name, old_type, type); if (old_type != type) { change = true; @@ -1450,7 +1448,7 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy, struct cfg80211_ssid *ssids = request->ssids; bool need_indicate_scan_done = false; - DBG_8723A("%s(%s):\n", __func__, padapter->pnetdev->name); + DBG_8723A("%s(%s)\n", __func__, padapter->pnetdev->name); spin_lock_bh(&pwdev_priv->scan_req_lock); pwdev_priv->scan_request = request; @@ -1546,13 +1544,13 @@ static int cfg80211_rtw_set_wiphy_params(struct wiphy *wiphy, u32 changed) static int cfg80211_rtw_join_ibss(struct wiphy *wiphy, struct net_device *ndev, struct cfg80211_ibss_params *params) { - DBG_8723A(FUNC_NDEV_FMT "\n", FUNC_NDEV_ARG(ndev)); + DBG_8723A("%s(%s)\n", __func__, ndev->name); return 0; } static int cfg80211_rtw_leave_ibss(struct wiphy *wiphy, struct net_device *ndev) { - DBG_8723A(FUNC_NDEV_FMT "\n", FUNC_NDEV_ARG(ndev)); + DBG_8723A("%s(%s)\n", __func__, ndev->name); return 0; } @@ -1868,7 +1866,7 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, struct security_priv *psecuritypriv = &padapter->securitypriv; struct rtw_queue *queue = &pmlmepriv->scanned_queue; - DBG_8723A("=>" FUNC_NDEV_FMT "\n", FUNC_NDEV_ARG(ndev)); + DBG_8723A("=>" "%s(%s)\n", __func__, ndev->name); DBG_8723A("privacy =%d, key =%p, key_len =%d, key_idx =%d\n", sme->privacy, sme->key, sme->key_len, sme->key_idx); @@ -2115,7 +2113,7 @@ static int cfg80211_rtw_disconnect(struct wiphy *wiphy, struct net_device *ndev, { struct rtw_adapter *padapter = wiphy_to_adapter(wiphy); - DBG_8723A(FUNC_NDEV_FMT "\n", FUNC_NDEV_ARG(ndev)); + DBG_8723A("%s(%s)\n", __func__, ndev->name); rtw_set_roaming(padapter, 0); @@ -2165,8 +2163,8 @@ static int cfg80211_rtw_set_power_mgmt(struct wiphy *wiphy, struct rtw_adapter *padapter = wiphy_to_adapter(wiphy); struct rtw_wdev_priv *rtw_wdev_priv = wdev_to_priv(padapter->rtw_wdev); - DBG_8723A(FUNC_NDEV_FMT " enabled:%u, timeout:%d\n", - FUNC_NDEV_ARG(ndev), enabled, timeout); + DBG_8723A("%s(%s): enabled:%u, timeout:%d\n", + __func__, ndev->name, enabled, timeout); rtw_wdev_priv->power_mgmt = enabled; @@ -2185,7 +2183,7 @@ static int cfg80211_rtw_set_pmksa(struct wiphy *wiphy, struct security_priv *psecuritypriv = &padapter->securitypriv; u8 strZeroMacAddress[ETH_ALEN] = { 0x00 }; - DBG_8723A(FUNC_NDEV_FMT "\n", FUNC_NDEV_ARG(netdev)); + DBG_8723A("%s(%s)\n", __func__, netdev->name); if (!memcmp(pmksa->bssid, strZeroMacAddress, ETH_ALEN)) { return -EINVAL; @@ -2199,9 +2197,8 @@ static int cfg80211_rtw_set_pmksa(struct wiphy *wiphy, pmksa->bssid, ETH_ALEN)) { /* BSSID is matched, the same AP => rewrite with new PMKID. */ - DBG_8723A(FUNC_NDEV_FMT - " BSSID exists in the PMKList.\n", - FUNC_NDEV_ARG(netdev)); + DBG_8723A("%s(%s): BSSID exists in the PMKList.\n", + __func__, netdev->name); memcpy(psecuritypriv->PMKIDList[index].PMKID, pmksa->pmkid, WLAN_PMKID_LEN); @@ -2214,9 +2211,8 @@ static int cfg80211_rtw_set_pmksa(struct wiphy *wiphy, if (!blInserted) { /* Find a new entry */ - DBG_8723A(FUNC_NDEV_FMT - " Use the new entry index = %d for this PMKID.\n", - FUNC_NDEV_ARG(netdev), psecuritypriv->PMKIDIndex); + DBG_8723A("%s(%s): Use new entry index = %d for this PMKID\n", + __func__, netdev->name, psecuritypriv->PMKIDIndex); memcpy(psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex]. Bssid, pmksa->bssid, ETH_ALEN); @@ -2242,7 +2238,7 @@ static int cfg80211_rtw_del_pmksa(struct wiphy *wiphy, struct rtw_adapter *padapter = wiphy_to_adapter(wiphy); struct security_priv *psecuritypriv = &padapter->securitypriv; - DBG_8723A(FUNC_NDEV_FMT "\n", FUNC_NDEV_ARG(netdev)); + DBG_8723A("%s(%s)\n", __func__, netdev->name); for (index = 0; index < NUM_PMKID_CACHE; index++) { if (!memcmp(psecuritypriv->PMKIDList[index].Bssid, @@ -2258,8 +2254,8 @@ static int cfg80211_rtw_del_pmksa(struct wiphy *wiphy, } if (false == bMatched) { - DBG_8723A(FUNC_NDEV_FMT " do not have matched BSSID\n", - FUNC_NDEV_ARG(netdev)); + DBG_8723A("%s(%s): do not have matched BSSID\n", __func__, + netdev->name); return -EINVAL; } @@ -2272,7 +2268,7 @@ static int cfg80211_rtw_flush_pmksa(struct wiphy *wiphy, struct rtw_adapter *padapter = wiphy_to_adapter(wiphy); struct security_priv *psecuritypriv = &padapter->securitypriv; - DBG_8723A(FUNC_NDEV_FMT "\n", FUNC_NDEV_ARG(netdev)); + DBG_8723A("%s(%s)\n", __func__, netdev->name); memset(&psecuritypriv->PMKIDList[0], 0x00, sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE); @@ -2410,7 +2406,7 @@ static int rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, struct ieee80211_radiotap_header *rtap_hdr; struct rtw_adapter *padapter = netdev_priv(ndev); - DBG_8723A(FUNC_NDEV_FMT "\n", FUNC_NDEV_ARG(ndev)); + DBG_8723A("%s(%s)\n", __func__, ndev->name); if (unlikely(skb->len < sizeof(struct ieee80211_radiotap_header))) goto fail; @@ -2476,14 +2472,14 @@ static int rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, if (rtw_action_frame_parse23a(skb->data, len, &category, &action) == false) { - DBG_8723A(FUNC_NDEV_FMT " frame_control:0x%x\n", - FUNC_NDEV_ARG(ndev), + DBG_8723A("%s(%s): frame_control:0x%x\n", + __func__, ndev->name, le16_to_cpu(dot11_hdr->frame_control)); goto fail; } - DBG_8723A("RTW_Tx:da =" MAC_FMT " via " FUNC_NDEV_FMT "\n", - MAC_ARG(dot11_hdr->addr1), FUNC_NDEV_ARG(ndev)); + DBG_8723A("RTW_Tx:da =" MAC_FMT " via %s(%s)\n", + MAC_ARG(dot11_hdr->addr1), __func__, ndev->name); if (category == WLAN_CATEGORY_PUBLIC) DBG_8723A("RTW_Tx:%s\n", action_public_str23a(action)); else @@ -2676,8 +2672,8 @@ static int cfg80211_rtw_del_virtual_intf(struct wiphy *wiphy, if (ndev == pwdev_priv->pmon_ndev) { pwdev_priv->pmon_ndev = NULL; pwdev_priv->ifname_mon[0] = '\0'; - DBG_8723A(FUNC_NDEV_FMT " remove monitor interface\n", - FUNC_NDEV_ARG(ndev)); + DBG_8723A("%s(%s): remove monitor interface\n", + __func__, ndev->name); } exit: @@ -2740,8 +2736,8 @@ static int cfg80211_rtw_start_ap(struct wiphy *wiphy, struct net_device *ndev, int ret = 0; struct rtw_adapter *adapter = wiphy_to_adapter(wiphy); - DBG_8723A(FUNC_NDEV_FMT " hidden_ssid:%d, auth_type:%d\n", - FUNC_NDEV_ARG(ndev), settings->hidden_ssid, + DBG_8723A("%s(%s): hidden_ssid:%d, auth_type:%d\n", + __func__, ndev->name, settings->hidden_ssid, settings->auth_type); ret = rtw_add_beacon(adapter, settings->beacon.head, @@ -2775,7 +2771,7 @@ static int cfg80211_rtw_change_beacon(struct wiphy *wiphy, int ret = 0; struct rtw_adapter *adapter = wiphy_to_adapter(wiphy); - DBG_8723A(FUNC_NDEV_FMT "\n", FUNC_NDEV_ARG(ndev)); + DBG_8723A("%s(%s)\n", __func__, ndev->name); ret = rtw_add_beacon(adapter, info->head, info->head_len, info->tail, info->tail_len); @@ -2785,7 +2781,7 @@ static int cfg80211_rtw_change_beacon(struct wiphy *wiphy, static int cfg80211_rtw_stop_ap(struct wiphy *wiphy, struct net_device *ndev) { - DBG_8723A(FUNC_NDEV_FMT "\n", FUNC_NDEV_ARG(ndev)); + DBG_8723A("%s(%s)\n", __func__, ndev->name); return 0; } @@ -2793,7 +2789,7 @@ static int cfg80211_rtw_add_station(struct wiphy *wiphy, struct net_device *ndev, u8 *mac, struct station_parameters *params) { - DBG_8723A(FUNC_NDEV_FMT "\n", FUNC_NDEV_ARG(ndev)); + DBG_8723A("%s(%s)\n", __func__, ndev->name); return 0; } @@ -2809,7 +2805,7 @@ static int cfg80211_rtw_del_station(struct wiphy *wiphy, struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct sta_priv *pstapriv = &padapter->stapriv; - DBG_8723A("+" FUNC_NDEV_FMT "\n", FUNC_NDEV_ARG(ndev)); + DBG_8723A("+%s(%s)\n", __func__, ndev->name); if (check_fwstate(pmlmepriv, (_FW_LINKED | WIFI_AP_STATE)) != true) { DBG_8723A("%s, fw_state != FW_LINKED|WIFI_AP_STATE\n", @@ -2869,7 +2865,7 @@ static int cfg80211_rtw_del_station(struct wiphy *wiphy, associated_clients_update23a(padapter, updated); - DBG_8723A("-" FUNC_NDEV_FMT "\n", FUNC_NDEV_ARG(ndev)); + DBG_8723A("-%s(%s)\n", __func__, ndev->name); return ret; } @@ -2878,7 +2874,7 @@ static int cfg80211_rtw_change_station(struct wiphy *wiphy, struct net_device *ndev, u8 *mac, struct station_parameters *params) { - DBG_8723A(FUNC_NDEV_FMT "\n", FUNC_NDEV_ARG(ndev)); + DBG_8723A("%s(%s)\n", __func__, ndev->name); return 0; } @@ -2886,7 +2882,7 @@ static int cfg80211_rtw_dump_station(struct wiphy *wiphy, struct net_device *ndev, int idx, u8 *mac, struct station_info *sinfo) { - DBG_8723A(FUNC_NDEV_FMT "\n", FUNC_NDEV_ARG(ndev)); + DBG_8723A("%s(%s)\n", __func__, ndev->name); /* TODO: dump scanned queue */ @@ -2896,7 +2892,7 @@ static int cfg80211_rtw_dump_station(struct wiphy *wiphy, static int cfg80211_rtw_change_bss(struct wiphy *wiphy, struct net_device *ndev, struct bss_parameters *params) { - DBG_8723A(FUNC_NDEV_FMT "\n", FUNC_NDEV_ARG(ndev)); + DBG_8723A("%s(%s)\n", __func__, ndev->name); return 0; } #endif /* CONFIG_8723AU_AP_MODE */ @@ -3163,7 +3159,7 @@ static int rtw_cfg80211_set_beacon_wpsp2pie(struct net_device *ndev, char *buf, struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - DBG_8723A(FUNC_NDEV_FMT " ielen =%d\n", FUNC_NDEV_ARG(ndev), len); + DBG_8723A("%s(%s): ielen =%d\n", __func__, ndev->name, len); if (len > 0) { wps_ie = rtw_get_wps_ie23a(buf, len, NULL, &wps_ielen); diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index f21128cd9ccf..ca95bd32c808 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -605,7 +605,7 @@ static int _rtw_drv_register_netdev(struct rtw_adapter *padapter, char *name) /* Tell the network stack we exist */ if (register_netdev(pnetdev)) { - DBG_8723A(FUNC_NDEV_FMT "Failed!\n", FUNC_NDEV_ARG(pnetdev)); + DBG_8723A("%s(%s): Failed!\n", __func__, pnetdev->name); ret = _FAIL; goto error_register_netdev; } @@ -876,7 +876,7 @@ static int netdev_close(struct net_device *pnetdev) void rtw_ndev_destructor(struct net_device *ndev) { - DBG_8723A(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev)); + DBG_8723A("%s(%s)\n", __func__, ndev->name); kfree(ndev->ieee80211_ptr); free_netdev(ndev); } -- cgit v1.2.3 From d39518a4b502d25b13b657b10d31499bcd1a535f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:05 +0200 Subject: staging: rtl8723au: Remove unused ADPT_{FMT,AGR} macros Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/osdep_service.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index 48fefa13ba04..fc6cad408c52 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -136,10 +136,6 @@ extern unsigned char MCS_rate_1R23A[16]; void _rtw_init_queue23a(struct rtw_queue *pqueue); - -#define ADPT_FMT "%s" -#define ADPT_ARG(adapter) adapter->pnetdev->name - /* Macros for handling unaligned memory accesses */ #define RTW_GET_BE24(a) ((((u32) (a)[0]) << 16) | (((u32) (a)[1]) << 8) | \ -- cgit v1.2.3 From f85bd052472e65d0cc2af11034b81910d84f3cad Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:06 +0200 Subject: staging: rtl8723au: Move REALTEK96B_IE23A to rtw_mlme_ext.c and mark it static Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 5 +++-- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 2 -- drivers/staging/rtl8723au/include/osdep_service.h | 1 - 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 596d0f369858..9e296fdb3f26 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -98,6 +98,7 @@ unsigned char WMM_PARA_OUI23A[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; unsigned char WPA_TKIP_CIPHER23A[4] = {0x00, 0x50, 0xf2, 0x02}; unsigned char RSN_TKIP_CIPHER23A[4] = {0x00, 0x0f, 0xac, 0x02}; +static unsigned char REALTEK_96B_IE[] = {0x00, 0xe0, 0x4c, 0x02, 0x01, 0x20}; /******************************************************** MCS rate definitions @@ -3254,7 +3255,7 @@ void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status, if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) { pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, 6, - REALTEK_96B_IE23A, &pattrib->pktlen); + REALTEK_96B_IE, &pattrib->pktlen); } /* add WPS IE ie for wps 2.0 */ @@ -3518,7 +3519,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, 6, - REALTEK_96B_IE23A, &pattrib->pktlen); + REALTEK_96B_IE, &pattrib->pktlen); pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe23a(padapter, pmgntframe); diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 161a2eb1363e..e6a905f054ed 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -32,8 +32,6 @@ static unsigned char REALTEK_OUI[] = {0x00, 0xe0, 0x4c}; static unsigned char AIRGOCAP_OUI[] = {0x00, 0x0a, 0xf5}; static unsigned char EPIGRAM_OUI[] = {0x00, 0x90, 0x4c}; -unsigned char REALTEK_96B_IE23A[] = {0x00, 0xe0, 0x4c, 0x02, 0x01, 0x20}; - #define R2T_PHY_DELAY 0 /* define WAIT_FOR_BCN_TO_MIN 3000 */ diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index fc6cad408c52..8ecf230c7c55 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -126,7 +126,6 @@ static inline u32 CHKBIT(u32 x) #define BIT35 0x0800000000 #define BIT36 0x1000000000 -extern unsigned char REALTEK_96B_IE23A[]; extern unsigned char MCS_rate_2R23A[16]; extern unsigned char WPA_TKIP_CIPHER23A[4]; extern unsigned char RSN_TKIP_CIPHER23A[4]; -- cgit v1.2.3 From 7871778259b1255738a0b5dd337e57144e06b5d2 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:07 +0200 Subject: staging: rtl8723au: Move {WPA,RSN}_TKIP_CIPHER23A to rtw_wlan_util.c and mark them static Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 3 --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 8 +++++--- drivers/staging/rtl8723au/include/osdep_service.h | 2 -- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 9e296fdb3f26..6106b6a9e87f 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -95,9 +95,6 @@ unsigned char WFD_OUI23A[] = {0x50, 0x6F, 0x9A, 0x0A}; unsigned char WMM_INFO_OUI23A[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01}; unsigned char WMM_PARA_OUI23A[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; -unsigned char WPA_TKIP_CIPHER23A[4] = {0x00, 0x50, 0xf2, 0x02}; -unsigned char RSN_TKIP_CIPHER23A[4] = {0x00, 0x0f, 0xac, 0x02}; - static unsigned char REALTEK_96B_IE[] = {0x00, 0xe0, 0x4c, 0x02, 0x01, 0x20}; /******************************************************** diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index e6a905f054ed..e7c67c396981 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -32,6 +32,9 @@ static unsigned char REALTEK_OUI[] = {0x00, 0xe0, 0x4c}; static unsigned char AIRGOCAP_OUI[] = {0x00, 0x0a, 0xf5}; static unsigned char EPIGRAM_OUI[] = {0x00, 0x90, 0x4c}; +static unsigned char WPA_TKIP_CIPHER[4] = {0x00, 0x50, 0xf2, 0x02}; +static unsigned char RSN_TKIP_CIPHER[4] = {0x00, 0x0f, 0xac, 0x02}; + #define R2T_PHY_DELAY 0 /* define WAIT_FOR_BCN_TO_MIN 3000 */ @@ -1181,12 +1184,11 @@ unsigned int is_ap_in_tkip23a(struct rtw_adapter *padapter) case WLAN_EID_VENDOR_SPECIFIC: if (!memcmp(pIE->data, RTW_WPA_OUI23A_TYPE, 4)&& !memcmp((pIE->data + 12), - WPA_TKIP_CIPHER23A, 4)) + WPA_TKIP_CIPHER, 4)) return true; break; case WLAN_EID_RSN: - if (!memcmp(pIE->data + 8, RSN_TKIP_CIPHER23A, - 4)) + if (!memcmp(pIE->data + 8, RSN_TKIP_CIPHER, 4)) return true; break; default: diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index 8ecf230c7c55..be9329f14f7a 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -127,8 +127,6 @@ static inline u32 CHKBIT(u32 x) #define BIT36 0x1000000000 extern unsigned char MCS_rate_2R23A[16]; -extern unsigned char WPA_TKIP_CIPHER23A[4]; -extern unsigned char RSN_TKIP_CIPHER23A[4]; extern unsigned char MCS_rate_2R23A[16]; extern unsigned char MCS_rate_1R23A[16]; -- cgit v1.2.3 From 95b0f200082e96aed935943450184fb288238618 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:08 +0200 Subject: staging: rtl8723au: Move rtw_do_join23a() prototype to rtw_ioctl_set.h rtw_do_join23a() is declared in rtw_ioctl_set.c so move the prototype to it's correct place, and remove duplicate protoype from rtw_mlme.c Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 2 -- drivers/staging/rtl8723au/include/osdep_service.h | 1 - drivers/staging/rtl8723au/include/rtw_ioctl_set.h | 1 + 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 48b6d4ba3915..b562bd6564a9 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -26,8 +26,6 @@ #include #include -extern u8 rtw_do_join23a(struct rtw_adapter * padapter); - static void rtw_init_mlme_timer(struct rtw_adapter *padapter) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index be9329f14f7a..f2a8d2acf789 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -139,6 +139,5 @@ void _rtw_init_queue23a(struct rtw_queue *pqueue); ((u32) (a)[2])) s32 c2h_evt_hdl(struct rtw_adapter *adapter, struct c2h_evt_hdr *c2h_evt, c2h_id_filter filter); -u8 rtw_do_join23a(struct rtw_adapter *padapter); #endif diff --git a/drivers/staging/rtl8723au/include/rtw_ioctl_set.h b/drivers/staging/rtl8723au/include/rtw_ioctl_set.h index 8e49be5fcdda..e18820012edc 100644 --- a/drivers/staging/rtl8723au/include/rtw_ioctl_set.h +++ b/drivers/staging/rtl8723au/include/rtw_ioctl_set.h @@ -29,5 +29,6 @@ u8 rtw_set_802_11_ssid23a(struct rtw_adapter * padapter, struct cfg80211_ssid * u16 rtw_get_cur_max_rate23a(struct rtw_adapter *adapter); s32 FillH2CCmd(struct rtw_adapter *padapter, u8 ElementID, u32 CmdLen, u8 *pCmdBuffer); +u8 rtw_do_join23a(struct rtw_adapter *padapter); #endif -- cgit v1.2.3 From ab281e3ba9ebf8b7b7e0bf4672256b145882c2b0 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:09 +0200 Subject: staging: rtl8723au: Declare c2h_evt_hdl static Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 6 +++--- drivers/staging/rtl8723au/include/osdep_service.h | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 8609dce66c46..9cb580e34a26 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -1297,10 +1297,10 @@ exit: return res; } -s32 c2h_evt_hdl(struct rtw_adapter *adapter, struct c2h_evt_hdr *c2h_evt, - c2h_id_filter filter) +static int c2h_evt_hdl(struct rtw_adapter *adapter, + struct c2h_evt_hdr *c2h_evt, c2h_id_filter filter) { - s32 ret = _FAIL; + int ret = _FAIL; u8 buf[16]; if (!c2h_evt) { diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index f2a8d2acf789..f595c85b5404 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -138,6 +138,4 @@ void _rtw_init_queue23a(struct rtw_queue *pqueue); #define RTW_GET_BE24(a) ((((u32) (a)[0]) << 16) | (((u32) (a)[1]) << 8) | \ ((u32) (a)[2])) -s32 c2h_evt_hdl(struct rtw_adapter *adapter, struct c2h_evt_hdr *c2h_evt, c2h_id_filter filter); - #endif -- cgit v1.2.3 From 849befad333c41633200ff36375d3d48739fbba3 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:10 +0200 Subject: staging: rtl8723au: c2h_evt_hdl() is always called with 3rd argument = NULL Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 9cb580e34a26..5276686a0a99 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -1297,8 +1297,7 @@ exit: return res; } -static int c2h_evt_hdl(struct rtw_adapter *adapter, - struct c2h_evt_hdr *c2h_evt, c2h_id_filter filter) +static int c2h_evt_hdl(struct rtw_adapter *adapter, struct c2h_evt_hdr *c2h_evt) { int ret = _FAIL; u8 buf[16]; @@ -1308,19 +1307,11 @@ static int c2h_evt_hdl(struct rtw_adapter *adapter, if (c2h_evt_read23a(adapter, buf) == _SUCCESS) { c2h_evt = (struct c2h_evt_hdr *)buf; - if (filter && filter(c2h_evt->id) == false) - goto exit; - ret = rtw_hal_c2h_handler23a(adapter, c2h_evt); } - } else { - - if (filter && filter(c2h_evt->id) == false) - goto exit; - + } else ret = rtw_hal_c2h_handler23a(adapter, c2h_evt); - } -exit: + return ret; } @@ -1396,7 +1387,7 @@ u8 rtw_drvextra_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) #endif /* CONFIG_8723AU_AP_MODE */ case C2H_WK_CID: c2h_evt_hdl(padapter, - (struct c2h_evt_hdr *)pdrvextra_cmd->pbuf, NULL); + (struct c2h_evt_hdr *)pdrvextra_cmd->pbuf); break; default: -- cgit v1.2.3 From 227ca8c4c40adf601e9cef25c45019e80429b204 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:11 +0200 Subject: staging: rtl8723au: The driver only has one c2h_id_filter Since we only have one function for this, there is no point in keeping the HAL silliness. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 5 +---- drivers/staging/rtl8723au/hal/hal_intf.c | 5 ----- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 1 - drivers/staging/rtl8723au/include/hal_intf.h | 2 -- drivers/staging/rtl8723au/include/osdep_service.h | 5 ----- 5 files changed, 1 insertion(+), 17 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 5276686a0a99..7bac18078367 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -1330,13 +1330,10 @@ void rtw_evt_work(struct work_struct *work) { struct evt_work *ework; struct rtw_adapter *adapter; - c2h_id_filter ccx_id_filter; ework = container_of(work, struct evt_work, work); adapter = ework->adapter; - ccx_id_filter = rtw_hal_c2h_id_filter_ccx23a(adapter); - c2h_evt_clear23a(adapter); if (!c2h_evt_exist(&ework->u.c2h_evt)) { @@ -1344,7 +1341,7 @@ void rtw_evt_work(struct work_struct *work) return; } - if (ccx_id_filter(ework->u.c2h_evt.id) == true) { + if (c2h_id_filter_ccx_8723a(ework->u.c2h_evt.id) == true) { /* Handle CCX report here */ rtw_hal_c2h_handler23a(adapter, &ework->u.c2h_evt); kfree(ework); diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index 1931f428722f..6b3edc044d4c 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -368,8 +368,3 @@ s32 rtw_hal_c2h_handler23a(struct rtw_adapter *adapter, struct c2h_evt_hdr *c2h_ ret = adapter->HalFunc.c2h_handler(adapter, c2h_evt); return ret; } - -c2h_id_filter rtw_hal_c2h_id_filter_ccx23a(struct rtw_adapter *adapter) -{ - return adapter->HalFunc.c2h_id_filter_ccx; -} diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index ee05bc00655a..a00dd7eb7d1c 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1766,7 +1766,6 @@ void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc) pHalFunc->hal_notch_filter = &hal_notch_filter_8723a; pHalFunc->c2h_handler = c2h_handler_8723a; - pHalFunc->c2h_id_filter_ccx = c2h_id_filter_ccx_8723a; } void rtl8723a_InitAntenna_Selection(struct rtw_adapter *padapter) diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 52b33fe61b3f..5a225e677daa 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -159,7 +159,6 @@ struct hal_ops { void (*hal_notch_filter)(struct rtw_adapter *adapter, bool enable); void (*hal_reset_security_engine)(struct rtw_adapter *adapter); s32 (*c2h_handler)(struct rtw_adapter *padapter, struct c2h_evt_hdr *c2h_evt); - c2h_id_filter c2h_id_filter_ccx; }; enum rt_eeprom_type { @@ -282,7 +281,6 @@ void rtw_hal_notch_filter23a(struct rtw_adapter *adapter, bool enable); void rtw_hal_reset_security_engine23a(struct rtw_adapter *adapter); s32 rtw_hal_c2h_handler23a(struct rtw_adapter *adapter, struct c2h_evt_hdr *c2h_evt); -c2h_id_filter rtw_hal_c2h_id_filter_ccx23a(struct rtw_adapter *adapter); void hw_var_set_correct_tsf(struct rtw_adapter *padapter); void hw_var_set_mlme_disconnect(struct rtw_adapter *padapter); void hw_var_set_opmode(struct rtw_adapter *padapter, u8 mode); diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index f595c85b5404..86f34523a369 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -54,11 +54,6 @@ #include #include -struct rtw_adapter; -struct c2h_evt_hdr; - -typedef s32 (*c2h_id_filter)(u8 id); - struct rtw_queue { struct list_head queue; spinlock_t lock; -- cgit v1.2.3 From 00cf86c9976e33092ea163c7d813d272a94664d3 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:12 +0200 Subject: staging: rtl8723au: Call c2h_handler_8723a() directly instead of via HAL interface Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 6 +++--- drivers/staging/rtl8723au/hal/hal_intf.c | 8 -------- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 5 +---- drivers/staging/rtl8723au/include/hal_intf.h | 2 -- drivers/staging/rtl8723au/include/rtl8723a_hal.h | 1 + 5 files changed, 5 insertions(+), 17 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 7bac18078367..6bb67f8d7f64 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -1307,10 +1307,10 @@ static int c2h_evt_hdl(struct rtw_adapter *adapter, struct c2h_evt_hdr *c2h_evt) if (c2h_evt_read23a(adapter, buf) == _SUCCESS) { c2h_evt = (struct c2h_evt_hdr *)buf; - ret = rtw_hal_c2h_handler23a(adapter, c2h_evt); + ret = c2h_handler_8723a(adapter, c2h_evt); } } else - ret = rtw_hal_c2h_handler23a(adapter, c2h_evt); + ret = c2h_handler_8723a(adapter, c2h_evt); return ret; } @@ -1343,7 +1343,7 @@ void rtw_evt_work(struct work_struct *work) if (c2h_id_filter_ccx_8723a(ework->u.c2h_evt.id) == true) { /* Handle CCX report here */ - rtw_hal_c2h_handler23a(adapter, &ework->u.c2h_evt); + c2h_handler_8723a(adapter, &ework->u.c2h_evt); kfree(ework); } else { /* diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index 6b3edc044d4c..d22c62c83cb1 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -360,11 +360,3 @@ void rtw_hal_reset_security_engine23a(struct rtw_adapter *adapter) if (adapter->HalFunc.hal_reset_security_engine) adapter->HalFunc.hal_reset_security_engine(adapter); } - -s32 rtw_hal_c2h_handler23a(struct rtw_adapter *adapter, struct c2h_evt_hdr *c2h_evt) -{ - s32 ret = _FAIL; - if (adapter->HalFunc.c2h_handler) - ret = adapter->HalFunc.c2h_handler(adapter, c2h_evt); - return ret; -} diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index a00dd7eb7d1c..5a0a368ec64e 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1661,8 +1661,7 @@ s32 c2h_id_filter_ccx_8723a(u8 id) return ret; } -static s32 c2h_handler_8723a(struct rtw_adapter *padapter, - struct c2h_evt_hdr *c2h_evt) +s32 c2h_handler_8723a(struct rtw_adapter *padapter, struct c2h_evt_hdr *c2h_evt) { s32 ret = _SUCCESS; u8 i = 0; @@ -1764,8 +1763,6 @@ void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc) pHalFunc->SetHalODMVarHandler = &rtl8723a_SetHalODMVar; pHalFunc->hal_notch_filter = &hal_notch_filter_8723a; - - pHalFunc->c2h_handler = c2h_handler_8723a; } void rtl8723a_InitAntenna_Selection(struct rtw_adapter *padapter) diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 5a225e677daa..bc29bf2c45e9 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -158,7 +158,6 @@ struct hal_ops { void (*hal_notch_filter)(struct rtw_adapter *adapter, bool enable); void (*hal_reset_security_engine)(struct rtw_adapter *adapter); - s32 (*c2h_handler)(struct rtw_adapter *padapter, struct c2h_evt_hdr *c2h_evt); }; enum rt_eeprom_type { @@ -280,7 +279,6 @@ bool rtw_hal_sreset_inprogress(struct rtw_adapter *padapter); void rtw_hal_notch_filter23a(struct rtw_adapter *adapter, bool enable); void rtw_hal_reset_security_engine23a(struct rtw_adapter *adapter); -s32 rtw_hal_c2h_handler23a(struct rtw_adapter *adapter, struct c2h_evt_hdr *c2h_evt); void hw_var_set_correct_tsf(struct rtw_adapter *padapter); void hw_var_set_mlme_disconnect(struct rtw_adapter *padapter); void hw_var_set_opmode(struct rtw_adapter *padapter, u8 mode); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index a6d4bc7bf04c..d4121a8c022d 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -545,5 +545,6 @@ void rtl8723a_start_thread(struct rtw_adapter *padapter); void rtl8723a_stop_thread(struct rtw_adapter *padapter); s32 c2h_id_filter_ccx_8723a(u8 id); +s32 c2h_handler_8723a(struct rtw_adapter *padapter, struct c2h_evt_hdr *c2h_evt); #endif -- cgit v1.2.3 From 405c9f5089444f0c07078ab56b5d00291d3ce8c8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:13 +0200 Subject: staging: rtl8723au: Remove local #define BIT() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/osdep_service.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index 86f34523a369..e6b14cc96f1f 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -72,9 +72,6 @@ static inline int rtw_netif_queue_stopped(struct net_device *pnetdev) netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 3)) ); } -#ifndef BIT -#define BIT(x) ( 1 << (x)) -#endif static inline u32 CHKBIT(u32 x) { WARN_ON(x >= 32); -- cgit v1.2.3 From 072fc84dce0620dcbb907a6881b46552c239bcf5 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:14 +0200 Subject: staging: rtl8723au: tid is 4 bits, so we need a 16 bit value to hold a bitmap Remove unused add_enable_bitmap and candidate_tid_bitmap from struct mlme_ext_info. In addition we don't need to use CHKBIT when we know we are dealing with a value in the range 0-15. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 18 +++++------------- drivers/staging/rtl8723au/core/rtw_xmit.c | 9 +++++++-- drivers/staging/rtl8723au/include/rtw_ht.h | 4 ++-- drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 2 -- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 6106b6a9e87f..475b0de0fe24 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -2034,11 +2034,10 @@ static int OnAction23a_back23a(struct rtw_adapter *padapter, tid = (capab & IEEE80211_ADDBA_PARAM_TID_MASK) >> 2; if (status == 0) { /* successful */ DBG_8723A("agg_enable for TID =%d\n", tid); - psta->htpriv.agg_enable_bitmap |= 1 << tid; - psta->htpriv.candidate_tid_bitmap &= - ~CHKBIT(tid); + psta->htpriv.agg_enable_bitmap |= BIT(tid); + psta->htpriv.candidate_tid_bitmap &= ~BIT(tid); } else - psta->htpriv.agg_enable_bitmap &= ~CHKBIT(tid); + psta->htpriv.agg_enable_bitmap &= ~BIT(tid); break; case WLAN_ACTION_DELBA: /* DELBA */ @@ -2051,14 +2050,11 @@ static int OnAction23a_back23a(struct rtw_adapter *padapter, preorder_ctrl->enable = false; preorder_ctrl->indicate_seq = 0xffff; } else { - psta->htpriv.agg_enable_bitmap &= ~(1 << tid); - psta->htpriv.candidate_tid_bitmap &= - ~(1 << tid); + psta->htpriv.agg_enable_bitmap &= ~BIT(tid); + psta->htpriv.candidate_tid_bitmap &= ~BIT(tid); } reason_code = get_unaligned_le16( &mgmt->u.action.u.delba.reason_code); - DBG_8723A("%s(): DELBA: %x(%x)\n", __func__, - pmlmeinfo->agg_enable_bitmap, reason_code); /* todo: how to notify the host while receiving DELETE BA */ break; @@ -5875,8 +5871,6 @@ u8 createbss_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) pmlmeinfo->HT_enable = 0; pmlmeinfo->HT_caps_enable = 0; pmlmeinfo->HT_info_enable = 0; - pmlmeinfo->agg_enable_bitmap = 0; - pmlmeinfo->candidate_tid_bitmap = 0; /* disable dynamic functions, such as high power, DIG */ rtl8723a_odm_support_ability_backup(padapter); @@ -5944,8 +5938,6 @@ u8 join_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) pmlmeinfo->HT_enable = 0; pmlmeinfo->HT_caps_enable = 0; pmlmeinfo->HT_info_enable = 0; - pmlmeinfo->agg_enable_bitmap = 0; - pmlmeinfo->candidate_tid_bitmap = 0; pmlmeinfo->bwmode_updated = false; /* pmlmeinfo->assoc_AP_vendor = HT_IOT_PEER_MAX; */ diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 829283f58a3b..2e508987009a 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -952,8 +952,13 @@ s32 rtw_make_wlanhdr23a(struct rtw_adapter *padapter, u8 *hdr, SetSeqNum(hdr, pattrib->seqnum); /* check if enable ampdu */ if (pattrib->ht_en && psta->htpriv.ampdu_enable) { - if (psta->htpriv.agg_enable_bitmap & CHKBIT(pattrib->priority)) - pattrib->ampdu_en = true; + if (pattrib->priority >= 16) + printk(KERN_WARNING "%s: Invalid " + "pattrib->priority %i\n", + __func__, pattrib->priority); + if (psta->htpriv.agg_enable_bitmap & + BIT(pattrib->priority)) + pattrib->ampdu_en = true; } /* re-check if enable ampdu by BA_starting_seqctrl */ if (pattrib->ampdu_en) { diff --git a/drivers/staging/rtl8723au/include/rtw_ht.h b/drivers/staging/rtl8723au/include/rtw_ht.h index 7fe0aa46f707..86ce86b6b69b 100644 --- a/drivers/staging/rtl8723au/include/rtw_ht.h +++ b/drivers/staging/rtl8723au/include/rtw_ht.h @@ -33,9 +33,9 @@ struct ht_priv u8 sgi;/* short GI */ /* for processing Tx A-MPDU */ - u8 agg_enable_bitmap; + u16 agg_enable_bitmap; /* u8 ADDBA_retry_count; */ - u8 candidate_tid_bitmap; + u16 candidate_tid_bitmap; struct ieee80211_ht_cap ht_cap; }; diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 6a4aa2b11808..d185748ecd09 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -357,9 +357,7 @@ struct mlme_ext_info u8 turboMode_cts2self; u8 turboMode_rtsen; u8 SM_PS; - u8 agg_enable_bitmap; u8 ADDBA_retry_count; - u8 candidate_tid_bitmap; u8 dialogToken; /* Accept ADDBA Request */ bool bAcceptAddbaReq; -- cgit v1.2.3 From 5a443893313811eebd4e9af0c1942873ace95c5f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:15 +0200 Subject: staging: rtl8723au: No need for CHKBIT since 16 + 12 is still < 32 Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 58b2359a990c..9e66c917ac59 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -380,9 +380,9 @@ void add_RATid23a(struct rtw_adapter *padapter, struct sta_info *psta, u8 rssi_l else limit = 8;/* 1R */ - for (i = 0; iht_cap.mcs.rx_mask[i/8] & BIT(i%8)) - tx_ra_bitmap |= CHKBIT(i+12); + for (i = 0; i < limit; i++) { + if (psta_ht->ht_cap.mcs.rx_mask[i / 8] & BIT(i % 8)) + tx_ra_bitmap |= BIT(i + 12); } /* max short GI rate */ -- cgit v1.2.3 From 4e489d91b4fe320b1260a504a61eb806f3044e61 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:16 +0200 Subject: staging: rtl8723au: 'keyid' is always 0-3, no need for CHKBIT() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 9 +++++++-- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 4 ++-- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 16 +++++++++++----- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index b562bd6564a9..900fc520d7ce 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -1867,6 +1867,11 @@ int rtw_set_key23a(struct rtw_adapter *adapter, struct mlme_priv *pmlmepriv = &adapter->mlmepriv; int res = _SUCCESS; + if (keyid >= 4) { + res = _FAIL; + goto exit; + } + pcmd = (struct cmd_obj *)kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (!pcmd) { res = _FAIL; /* try again */ @@ -1893,10 +1898,10 @@ int rtw_set_key23a(struct rtw_adapter *adapter, "psecuritypriv->dot11PrivacyAlgrthm =%d\n", psetkeyparm->algorithm)); } - psetkeyparm->keyid = (u8)keyid;/* 0~3 */ + psetkeyparm->keyid = keyid;/* 0~3 */ psetkeyparm->set_tx = set_tx; if (is_wep_enc(psetkeyparm->algorithm)) - pmlmepriv->key_mask |= CHKBIT(psetkeyparm->keyid); + pmlmepriv->key_mask |= BIT(psetkeyparm->keyid); DBG_8723A("==> rtw_set_key23a algorithm(%x), keyid(%x), key_mask(%x)\n", psetkeyparm->algorithm, psetkeyparm->keyid, diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index 8a95ae1d353c..8755d0a56025 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -81,8 +81,8 @@ int ips_leave23a(struct rtw_adapter * padapter) { DBG_8723A("==>%s, channel(%d), processing(%x)\n", __func__, padapter->mlmeextpriv.cur_channel, pwrpriv->bips_processing); set_channel_bwmode23a(padapter, padapter->mlmeextpriv.cur_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); - for (keyid = 0;keyid<4;keyid++) { - if (pmlmepriv->key_mask & CHKBIT(keyid)) { + for (keyid = 0; keyid < 4; keyid++) { + if (pmlmepriv->key_mask & BIT(keyid)) { if (keyid == psecuritypriv->dot11PrivacyKeyIndex) result = rtw_set_key23a(padapter, psecuritypriv, keyid, 1); else diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index d79d690e3302..1e3129f12f84 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -470,7 +470,7 @@ exit: } static int set_group_key(struct rtw_adapter *padapter, u8 *key, u8 alg, - int keyid) + u8 keyid) { u8 keylen; struct cmd_obj *pcmd; @@ -480,6 +480,11 @@ static int set_group_key(struct rtw_adapter *padapter, u8 *key, u8 alg, DBG_8723A("%s\n", __func__); + if (keyid >= 4) { + res = _FAIL; + goto exit; + } + pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (!pcmd) { res = _FAIL; @@ -492,9 +497,9 @@ static int set_group_key(struct rtw_adapter *padapter, u8 *key, u8 alg, goto exit; } - psetkeyparm->keyid = (u8) keyid; + psetkeyparm->keyid = keyid; if (is_wep_enc(alg)) - padapter->mlmepriv.key_mask |= CHKBIT(psetkeyparm->keyid); + padapter->mlmepriv.key_mask |= BIT(psetkeyparm->keyid); psetkeyparm->algorithm = alg; @@ -529,7 +534,7 @@ exit: } static int set_wep_key(struct rtw_adapter *padapter, u8 *key, u8 keylen, - int keyid) + u8 keyid) { u8 alg; @@ -552,7 +557,8 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, u32 param_len) { int ret = 0; - u32 wep_key_idx, wep_key_len; + u32 wep_key_len; + u8 wep_key_idx; struct sta_info *psta = NULL, *pbcmc_sta = NULL; struct rtw_adapter *padapter = netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -- cgit v1.2.3 From d7f2c23adf3b299680046041d87cbf900505e380 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:17 +0200 Subject: staging: rtl8723au: Another case of missing 'tid' bounds checking. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 5 +++++ drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 6bb67f8d7f64..3b9f8437c38a 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -823,6 +823,11 @@ u8 rtw_addbareq_cmd23a(struct rtw_adapter*padapter, u8 tid, u8 *addr) struct addBaReq_parm *paddbareq_parm; u8 res = _SUCCESS; + if (tid >= MAXTID) { + res = _FAIL; + goto exit; + } + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (!ph2c) { res = _FAIL; diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 475b0de0fe24..2bd74f0893a2 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -6354,7 +6354,7 @@ u8 add_ba_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) mod_timer(&psta->addba_retry_timer, jiffies + msecs_to_jiffies(ADDBA_TO)); } else { - psta->htpriv.candidate_tid_bitmap &= ~CHKBIT(pparm->tid); + psta->htpriv.candidate_tid_bitmap &= ~BIT(pparm->tid); } return H2C_SUCCESS; } -- cgit v1.2.3 From c06209d9489e43803bcb49c8f814e4799b1e128c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:18 +0200 Subject: staging: rtl8723au: set_qos() keep userpriority in a u8 Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 2e508987009a..36830be314d1 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -404,7 +404,7 @@ static void set_qos(struct sk_buff *skb, struct pkt_attrib *pattrib) { u8 *pframe = skb->data; struct iphdr *ip_hdr; - s32 UserPriority = 0; + u8 UserPriority = 0; /* get UserPriority from IP hdr */ if (pattrib->ether_type == ETH_P_IP) { -- cgit v1.2.3 From 7855848ecd33029b34674bf630c2478b8056b999 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:19 +0200 Subject: staging: rtl8723au: qos_asm23a(): Don't pass through an invalid priority Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 36830be314d1..5b1d35e71c93 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -394,6 +394,7 @@ u8 qos_acm23a(u8 acm_mask, u8 priority) default: DBG_8723A("qos_acm23a(): invalid pattrib->priority: %d!!!\n", priority); + change_priority = 0; break; } -- cgit v1.2.3 From 561fb403ba3393e7382faf5553eaefbd6c88bedb Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:20 +0200 Subject: staging: rtl8723au: pattrib->priority can't be > 15, no need for CHKBIT() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 900fc520d7ce..a5fca8141e32 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -2449,8 +2449,7 @@ void rtw_issue_addbareq_cmd23a(struct rtw_adapter *padapter, if (issued == 0) { DBG_8723A("rtw_issue_addbareq_cmd23a, p =%d\n", priority); - psta->htpriv.candidate_tid_bitmap |= - CHKBIT((u8)priority); + psta->htpriv.candidate_tid_bitmap |= BIT(priority); rtw_addbareq_cmd23a(padapter, (u8) priority, pattrib->ra); } -- cgit v1.2.3 From d8ab7e840dd36dfe5672d7dc94f428cb5f14c7cf Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:21 +0200 Subject: staging: rtl8723au: rtw_pwrctrl.c: Reduce spaghettification Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 215 ++++++++++++++------------- 1 file changed, 111 insertions(+), 104 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index 8755d0a56025..993504dd7eda 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -39,8 +39,7 @@ void ips_enter23a(struct rtw_adapter * padapter) #ifdef CONFIG_8723AU_BT_COEXIST BTDM_TurnOffBtCoexistBeforeEnterIPS(padapter); #endif - if (rf_off == pwrpriv->change_rfpwrstate) - { + if (pwrpriv->change_rfpwrstate == rf_off) { pwrpriv->bpower_saving = true; DBG_8723A_LEVEL(_drv_always_, "nolinked power save enter\n"); @@ -65,25 +64,32 @@ int ips_leave23a(struct rtw_adapter * padapter) down(&pwrpriv->lock); - if ((pwrpriv->rf_pwrstate == rf_off) &&!pwrpriv->bips_processing) - { + if (pwrpriv->rf_pwrstate == rf_off && !pwrpriv->bips_processing) { pwrpriv->bips_processing = true; pwrpriv->change_rfpwrstate = rf_on; pwrpriv->ips_leave23a_cnts++; - DBG_8723A("==>ips_leave23a cnts:%d\n", pwrpriv->ips_leave23a_cnts); + DBG_8723A("==>ips_leave23a cnts:%d\n", + pwrpriv->ips_leave23a_cnts); - if ((result = rtw_ips_pwr_up23a(padapter)) == _SUCCESS) { + result = rtw_ips_pwr_up23a(padapter); + if (result == _SUCCESS) pwrpriv->rf_pwrstate = rf_on; - } + DBG_8723A_LEVEL(_drv_always_, "nolinked power save leave\n"); - if ((_WEP40_ == psecuritypriv->dot11PrivacyAlgrthm) ||(_WEP104_ == psecuritypriv->dot11PrivacyAlgrthm)) - { - DBG_8723A("==>%s, channel(%d), processing(%x)\n", __func__, padapter->mlmeextpriv.cur_channel, pwrpriv->bips_processing); - set_channel_bwmode23a(padapter, padapter->mlmeextpriv.cur_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); + if (psecuritypriv->dot11PrivacyAlgrthm == _WEP40_ || + psecuritypriv->dot11PrivacyAlgrthm == _WEP104_) { + DBG_8723A("==>%s, channel(%d), processing(%x)\n", + __func__, padapter->mlmeextpriv.cur_channel, + pwrpriv->bips_processing); + set_channel_bwmode23a(padapter, + padapter->mlmeextpriv.cur_channel, + HAL_PRIME_CHNL_OFFSET_DONT_CARE, + HT_CHANNEL_WIDTH_20); for (keyid = 0; keyid < 4; keyid++) { if (pmlmepriv->key_mask & BIT(keyid)) { - if (keyid == psecuritypriv->dot11PrivacyKeyIndex) + if (keyid == + psecuritypriv->dot11PrivacyKeyIndex) result = rtw_set_key23a(padapter, psecuritypriv, keyid, 1); else result = rtw_set_key23a(padapter, psecuritypriv, keyid, 0); @@ -91,7 +97,8 @@ int ips_leave23a(struct rtw_adapter * padapter) } } - DBG_8723A("==> ips_leave23a.....LED(0x%08x)...\n", rtw_read32(padapter, 0x4c)); + DBG_8723A("==> ips_leave23a.....LED(0x%08x)...\n", + rtw_read32(padapter, 0x4c)); pwrpriv->bips_processing = false; pwrpriv->bkeepfwalive = false; @@ -139,9 +146,12 @@ static bool rtw_pwr_unassociated_idle(struct rtw_adapter *adapter) if (pxmit_priv->free_xmitbuf_cnt != NR_XMITBUFF || pxmit_priv->free_xmit_extbuf_cnt != NR_XMIT_EXTBUFF) { - DBG_8723A_LEVEL(_drv_always_, "There are some pkts to transmit\n"); - DBG_8723A_LEVEL(_drv_info_, "free_xmitbuf_cnt: %d, free_xmit_extbuf_cnt: %d\n", - pxmit_priv->free_xmitbuf_cnt, pxmit_priv->free_xmit_extbuf_cnt); + DBG_8723A_LEVEL(_drv_always_, + "There are some pkts to transmit\n"); + DBG_8723A_LEVEL(_drv_info_, "free_xmitbuf_cnt: %d, " + "free_xmit_extbuf_cnt: %d\n", + pxmit_priv->free_xmitbuf_cnt, + pxmit_priv->free_xmit_extbuf_cnt); goto exit; } @@ -164,7 +174,8 @@ void rtw_ps_processor23a(struct rtw_adapter*padapter) if (padapter->pwrctrlpriv.bHWPwrPindetect) { rfpwrstate = RfOnOffDetect23a(padapter); - DBG_8723A("@@@@- #2 %s ==> rfstate:%s\n", __func__, (rfpwrstate == rf_on)?"rf_on":"rf_off"); + DBG_8723A("@@@@- #2 %s ==> rfstate:%s\n", __func__, + (rfpwrstate == rf_on)?"rf_on":"rf_off"); if (rfpwrstate!= pwrpriv->rf_pwrstate) { if (rfpwrstate == rf_off) { @@ -176,7 +187,9 @@ void rtw_ps_processor23a(struct rtw_adapter*padapter) pwrpriv->change_rfpwrstate = rf_on; rtw_hw_resume23a(padapter); } - DBG_8723A("current rf_pwrstate(%s)\n", (pwrpriv->rf_pwrstate == rf_off)?"rf_off":"rf_on"); + DBG_8723A("current rf_pwrstate(%s)\n", + (pwrpriv->rf_pwrstate == rf_off) ? + "rf_off":"rf_on"); } pwrpriv->pwr_state_check_cnts ++; } @@ -187,9 +200,10 @@ void rtw_ps_processor23a(struct rtw_adapter*padapter) if (rtw_pwr_unassociated_idle(padapter) == false) goto exit; - if ((pwrpriv->rf_pwrstate == rf_on) && ((pwrpriv->pwr_state_check_cnts%4) == 0)) - { - DBG_8723A("==>%s .fw_state(%x)\n", __func__, get_fwstate(pmlmepriv)); + if (pwrpriv->rf_pwrstate == rf_on && + (pwrpriv->pwr_state_check_cnts % 4) == 0) { + DBG_8723A("==>%s .fw_state(%x)\n", __func__, + get_fwstate(pmlmepriv)); pwrpriv->change_rfpwrstate = rf_off; ips_enter23a(padapter); } @@ -208,36 +222,35 @@ static void pwr_state_check_handler(unsigned long data) /* * * Parameters - * padapter - * pslv power state level, only could be PS_STATE_S0 ~ PS_STATE_S4 + * padapter + * pslv power state level, only could be PS_STATE_S0 ~ PS_STATE_S4 * */ void rtw_set_rpwm23a(struct rtw_adapter *padapter, u8 pslv) { - u8 rpwm; + u8 rpwm; struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - - pslv = PS_STATE(pslv); - if (true == pwrpriv->btcoex_rfon) - { + if (pwrpriv->btcoex_rfon) { if (pslv < PS_STATE_S4) pslv = PS_STATE_S3; } if (pwrpriv->rpwm == pslv) { RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, - ("%s: Already set rpwm[0x%02X], new = 0x%02X!\n", __func__, pwrpriv->rpwm, pslv)); + ("%s: Already set rpwm[0x%02X], new = 0x%02X!\n", + __func__, pwrpriv->rpwm, pslv)); return; } - if ((padapter->bSurpriseRemoved == true) || - (padapter->hw_init_completed == false)) { + if (padapter->bSurpriseRemoved == true || + padapter->hw_init_completed == false) { RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, - ("%s: SurpriseRemoved(%d) hw_init_completed(%d)\n", - __func__, padapter->bSurpriseRemoved, padapter->hw_init_completed)); + ("%s: SurpriseRemoved(%d) hw_init_completed(%d)\n", + __func__, padapter->bSurpriseRemoved, + padapter->hw_init_completed)); pwrpriv->cpwm = PS_STATE_S4; @@ -246,18 +259,22 @@ void rtw_set_rpwm23a(struct rtw_adapter *padapter, u8 pslv) if (padapter->bDriverStopped == true) { RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, - ("%s: change power state(0x%02X) when DriverStopped\n", __func__, pslv)); + ("%s: change power state(0x%02X) when DriverStopped\n", + __func__, pslv)); if (pslv < PS_STATE_S2) { RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, - ("%s: Reject to enter PS_STATE(0x%02X) lower than S2 when DriverStopped!!\n", __func__, pslv)); + ("%s: Reject to enter PS_STATE(0x%02X) lower " + "than S2 when DriverStopped!!\n", + __func__, pslv)); return; } } rpwm = pslv | pwrpriv->tog; RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, - ("rtw_set_rpwm23a: rpwm = 0x%02x cpwm = 0x%02x\n", rpwm, pwrpriv->cpwm)); + ("rtw_set_rpwm23a: rpwm = 0x%02x cpwm = 0x%02x\n", + rpwm, pwrpriv->cpwm)); pwrpriv->rpwm = pslv; @@ -265,33 +282,29 @@ void rtw_set_rpwm23a(struct rtw_adapter *padapter, u8 pslv) pwrpriv->tog += 0x80; pwrpriv->cpwm = pslv; - - } static u8 PS_RDY_CHECK(struct rtw_adapter * padapter) { unsigned long delta_time; - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; delta_time = jiffies - pwrpriv->DelayLPSLastTimeStamp; if (delta_time < LPS_DELAY_TIME) - { return false; - } - if ((check_fwstate(pmlmepriv, _FW_LINKED) == false) || - (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) || - (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) + if (check_fwstate(pmlmepriv, _FW_LINKED) == false || + check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true || + check_fwstate(pmlmepriv, WIFI_AP_STATE) == true || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true || + check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) return false; - if (true == pwrpriv->bInSuspend) + if (pwrpriv->bInSuspend) return false; - if ((padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) && (padapter->securitypriv.binstallGrpkey == false)) - { + if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X && + padapter->securitypriv.binstallGrpkey == false) { DBG_8723A("Group handshake still in progress !!!\n"); return false; } @@ -301,7 +314,8 @@ static u8 PS_RDY_CHECK(struct rtw_adapter * padapter) return true; } -void rtw_set_ps_mode23a(struct rtw_adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_ant_mode) +void rtw_set_ps_mode23a(struct rtw_adapter *padapter, u8 ps_mode, + u8 smart_ps, u8 bcn_ant_mode) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; @@ -310,19 +324,18 @@ void rtw_set_ps_mode23a(struct rtw_adapter *padapter, u8 ps_mode, u8 smart_ps, u __func__, ps_mode, smart_ps)); if (ps_mode > PM_Card_Disable) { - RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, ("ps_mode:%d error\n", ps_mode)); + RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, + ("ps_mode:%d error\n", ps_mode)); return; } - if (pwrpriv->pwr_mode == ps_mode) - { - if (PS_MODE_ACTIVE == ps_mode) return; + if (pwrpriv->pwr_mode == ps_mode) { + if (PS_MODE_ACTIVE == ps_mode) + return; - if ((pwrpriv->smart_ps == smart_ps) && - (pwrpriv->bcn_ant_mode == bcn_ant_mode)) - { + if (pwrpriv->smart_ps == smart_ps && + pwrpriv->bcn_ant_mode == bcn_ant_mode) return; - } } if (ps_mode == PS_MODE_ACTIVE) { @@ -380,7 +393,8 @@ s32 LPS_RF_ON_check23a(struct rtw_adapter *padapter, u32 delay_ms) if (time_after(jiffies, end_time)) { err = -1; - DBG_8723A("%s: Wait for FW LPS leave more than %u ms!!!\n", __func__, delay_ms); + DBG_8723A("%s: Wait for FW LPS leave more than %u " + "ms!\n", __func__, delay_ms); break; } udelay(100); @@ -393,7 +407,7 @@ s32 LPS_RF_ON_check23a(struct rtw_adapter *padapter, u32 delay_ms) /* Enter the leisure power save mode. */ void LPS_Enter23a(struct rtw_adapter *padapter) { - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; if (!PS_RDY_CHECK(padapter)) return; @@ -403,13 +417,15 @@ void LPS_Enter23a(struct rtw_adapter *padapter) if (pwrpriv->LpsIdleCount >= 2) { /* 4 Sec */ if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) { pwrpriv->bpower_saving = true; - DBG_8723A("%s smart_ps:%d\n", __func__, pwrpriv->smart_ps); + DBG_8723A("%s smart_ps:%d\n", __func__, + pwrpriv->smart_ps); /* For Tenda W311R IOT issue */ - rtw_set_ps_mode23a(padapter, pwrpriv->power_mgnt, pwrpriv->smart_ps, 0); + rtw_set_ps_mode23a(padapter, + pwrpriv->power_mgnt, + pwrpriv->smart_ps, 0); } - } else { + } else pwrpriv->LpsIdleCount++; - } } } @@ -419,14 +435,15 @@ void LPS_Leave23a(struct rtw_adapter *padapter) { #define LPS_LEAVE_TIMEOUT_MS 100 - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; if (pwrpriv->bLeisurePs) { if (pwrpriv->pwr_mode != PS_MODE_ACTIVE) { rtw_set_ps_mode23a(padapter, PS_MODE_ACTIVE, 0, 0); if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) - LPS_RF_ON_check23a(padapter, LPS_LEAVE_TIMEOUT_MS); + LPS_RF_ON_check23a(padapter, + LPS_LEAVE_TIMEOUT_MS); } } @@ -438,17 +455,11 @@ void LPS_Leave23a(struct rtw_adapter *padapter) void LeaveAllPowerSaveMode23a(struct rtw_adapter *Adapter) { struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; - u8 enqueue = 0; - - + u8 enqueue = 0; /* DBG_8723A("%s.....\n", __func__); */ if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { /* connect */ rtw_lps_ctrl_wk_cmd23a(Adapter, LPS_CTRL_LEAVE, enqueue); - } - - } void rtw_init_pwrctrl_priv23a(struct rtw_adapter *padapter) @@ -471,8 +482,11 @@ void rtw_init_pwrctrl_priv23a(struct rtw_adapter *padapter) pwrctrlpriv->bkeepfwalive = false; pwrctrlpriv->LpsIdleCount = 0; - pwrctrlpriv->power_mgnt = padapter->registrypriv.power_mgnt;/* PS_MODE_MIN; */ - pwrctrlpriv->bLeisurePs = (PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt)?true:false; + + /* PS_MODE_MIN; */ + pwrctrlpriv->power_mgnt = padapter->registrypriv.power_mgnt; + pwrctrlpriv->bLeisurePs = + (PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt)?true:false; pwrctrlpriv->bFwCurrentInPSMode = false; @@ -489,8 +503,6 @@ void rtw_init_pwrctrl_priv23a(struct rtw_adapter *padapter) setup_timer(&pwrctrlpriv->pwr_state_check_timer, pwr_state_check_handler, (unsigned long)padapter); - - } void rtw_free_pwrctrl_priv(struct rtw_adapter *adapter) @@ -540,7 +552,8 @@ int _rtw_pwr_wakeup23a(struct rtw_adapter *padapter, u32 ips_deffer_ms, const ch jiffies_to_msecs(jiffies - start) <= 4000) msleep(10); if (rtw_hal_sreset_inprogress(padapter)) - DBG_8723A("%s wait sreset_inprogress timeout\n", __func__); + DBG_8723A("%s wait sreset_inprogress timeout\n", + __func__); else DBG_8723A("%s wait sreset_inprogress done\n", __func__); } @@ -558,27 +571,28 @@ int _rtw_pwr_wakeup23a(struct rtw_adapter *padapter, u32 ips_deffer_ms, const ch } /* System suspend is not allowed to wakeup */ - if ((pwrpriv->bInternalAutoSuspend == false) && (true == pwrpriv->bInSuspend)) { + if (pwrpriv->bInternalAutoSuspend == false && + pwrpriv->bInSuspend == true) { ret = _FAIL; goto exit; } /* block??? */ - if ((pwrpriv->bInternalAutoSuspend == true) && (padapter->net_closed == true)) { + if (pwrpriv->bInternalAutoSuspend == true && + padapter->net_closed == true) { ret = _FAIL; goto exit; } /* I think this should be check in IPS, LPS, autosuspend functions... */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { + if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { ret = _SUCCESS; goto exit; } if (rf_off == pwrpriv->rf_pwrstate) { DBG_8723A("%s call ips_leave23a....\n", __func__); - if (_FAIL == ips_leave23a(padapter)) { + if (ips_leave23a(padapter)== _FAIL) { DBG_8723A("======> ips_leave23a fail.............\n"); ret = _FAIL; goto exit; @@ -604,29 +618,22 @@ exit: int rtw_pm_set_lps23a(struct rtw_adapter *padapter, u8 mode) { - int ret = 0; + int ret = 0; struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; - if (mode < PS_MODE_NUM) - { - if (pwrctrlpriv->power_mgnt != mode) - { + if (mode < PS_MODE_NUM) { + if (pwrctrlpriv->power_mgnt != mode) { if (PS_MODE_ACTIVE == mode) - { LeaveAllPowerSaveMode23a(padapter); - } else - { pwrctrlpriv->LpsIdleCount = 2; - } pwrctrlpriv->power_mgnt = mode; - pwrctrlpriv->bLeisurePs = (PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt)?true:false; + pwrctrlpriv->bLeisurePs = + (PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt) ? + true:false; } - } - else - { + } else ret = -EINVAL; - } return ret; } @@ -637,17 +644,17 @@ int rtw_pm_set_ips23a(struct rtw_adapter *padapter, u8 mode) if (mode == IPS_NORMAL || mode == IPS_LEVEL_2) { rtw_ips_mode_req(pwrctrlpriv, mode); - DBG_8723A("%s %s\n", __func__, mode == IPS_NORMAL?"IPS_NORMAL":"IPS_LEVEL_2"); + DBG_8723A("%s %s\n", __func__, + mode == IPS_NORMAL?"IPS_NORMAL":"IPS_LEVEL_2"); return 0; - } - else if (mode == IPS_NONE) { + } else if (mode == IPS_NONE) { rtw_ips_mode_req(pwrctrlpriv, mode); DBG_8723A("%s %s\n", __func__, "IPS_NONE"); - if ((padapter->bSurpriseRemoved == 0)&&_FAIL == rtw_pwr_wakeup(padapter)) + if (padapter->bSurpriseRemoved == 0 && + rtw_pwr_wakeup(padapter) == _FAIL) return -EFAULT; - } - else { + } else return -EINVAL; - } + return 0; } -- cgit v1.2.3 From 208ceb8307a1832f427519d995a2e2d7e112d7d1 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:22 +0200 Subject: staging: rtl8723au: Remove some unused lists from struct sta_priv Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_sta_mgt.c | 2 -- drivers/staging/rtl8723au/include/sta_info.h | 2 -- 2 files changed, 4 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c index 403dc8e07e73..7f1f66c6709b 100644 --- a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c @@ -54,8 +54,6 @@ u32 _rtw_init_sta_priv23a(struct sta_priv *pstapriv) spin_lock_init(&pstapriv->sta_hash_lock); pstapriv->asoc_sta_count = 0; - _rtw_init_queue23a(&pstapriv->sleep_q); - _rtw_init_queue23a(&pstapriv->wakeup_q); for (i = 0; i < NUM_STA; i++) INIT_LIST_HEAD(&pstapriv->sta_hash[i]); diff --git a/drivers/staging/rtl8723au/include/sta_info.h b/drivers/staging/rtl8723au/include/sta_info.h index 195a3493395f..3bd8f44895c9 100644 --- a/drivers/staging/rtl8723au/include/sta_info.h +++ b/drivers/staging/rtl8723au/include/sta_info.h @@ -314,8 +314,6 @@ struct sta_priv { spinlock_t sta_hash_lock; struct list_head sta_hash[NUM_STA]; int asoc_sta_count; - struct rtw_queue sleep_q; - struct rtw_queue wakeup_q; struct rtw_adapter *padapter; struct list_head asoc_list; -- cgit v1.2.3 From a61b32289a16853fef477eec07ff210e735ab53a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:23 +0200 Subject: staging: rtl8723au: Remove another unused queue from struct recv_priv Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723au_recv.c | 5 ----- drivers/staging/rtl8723au/hal/usb_halinit.c | 1 - drivers/staging/rtl8723au/include/rtw_recv.h | 2 -- 3 files changed, 8 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_recv.c b/drivers/staging/rtl8723au/hal/rtl8723au_recv.c index 3a266abe9ad5..5e8cd0e59387 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723au_recv.c +++ b/drivers/staging/rtl8723au/hal/rtl8723au_recv.c @@ -48,9 +48,6 @@ int rtl8723au_init_recv_priv(struct rtw_adapter *padapter) if (!precvpriv->int_in_buf) DBG_8723A("alloc_mem for interrupt in endpoint fail !!!!\n"); - /* init recv_buf */ - _rtw_init_queue23a(&precvpriv->free_recv_buf_queue); - size = NR_RECVBUFF * sizeof(struct recv_buf); precvpriv->precv_buf = kzalloc(size, GFP_KERNEL); if (!precvpriv->precv_buf) { @@ -74,8 +71,6 @@ int rtl8723au_init_recv_priv(struct rtw_adapter *padapter) precvbuf++; } - precvpriv->free_recv_buf_queue_cnt = NR_RECVBUFF; - skb_queue_head_init(&precvpriv->rx_skb_queue); skb_queue_head_init(&precvpriv->free_recv_skb_queue); diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 20c11353a610..edddc20f24ee 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1253,7 +1253,6 @@ static unsigned int rtl8723au_inirp_init(struct rtw_adapter *Adapter) goto exit; } precvbuf++; - precvpriv->free_recv_buf_queue_cnt--; } _read_interrupt = io_ops->_read_interrupt; if (_read_interrupt(Adapter, RECV_INT_IN_ADDR) == false) { diff --git a/drivers/staging/rtl8723au/include/rtw_recv.h b/drivers/staging/rtl8723au/include/rtw_recv.h index 3bd836fc74d8..e22ce645667f 100644 --- a/drivers/staging/rtl8723au/include/rtw_recv.h +++ b/drivers/staging/rtl8723au/include/rtw_recv.h @@ -199,8 +199,6 @@ struct recv_priv { struct sk_buff_head free_recv_skb_queue; struct sk_buff_head rx_skb_queue; u8 *precv_buf; - struct rtw_queue free_recv_buf_queue; - u32 free_recv_buf_queue_cnt; /* For display the phy informatiom */ u8 is_signal_dbg; /* for debug */ -- cgit v1.2.3 From 099a845251999648b2b24435f48b7486751d1b1b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:24 +0200 Subject: staging: rtl8723au: Eliminate no-op function rtl8723au_init_recvbuf() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723au_recv.c | 5 ----- drivers/staging/rtl8723au/hal/usb_ops_linux.c | 2 -- drivers/staging/rtl8723au/include/rtl8723a_recv.h | 1 - 3 files changed, 8 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_recv.c b/drivers/staging/rtl8723au/hal/rtl8723au_recv.c index 5e8cd0e59387..6a25ad572b26 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723au_recv.c +++ b/drivers/staging/rtl8723au/hal/rtl8723au_recv.c @@ -23,11 +23,6 @@ #include #include -void rtl8723au_init_recvbuf(struct rtw_adapter *padapter, - struct recv_buf *precvbuf) -{ -} - int rtl8723au_init_recv_priv(struct rtw_adapter *padapter) { struct recv_priv *precvpriv = &padapter->recvpriv; diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index 3aa0374cb60a..484006a5f338 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -764,8 +764,6 @@ static u32 usb_read_port(struct rtw_adapter *adapter, u32 addr, u32 cnt, if (!precvbuf->pskb) precvbuf->pskb = skb_dequeue(&precvpriv->free_recv_skb_queue); - rtl8723au_init_recvbuf(adapter, precvbuf); - /* re-assign for linux based on skb */ if (!precvbuf->pskb) { precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev, MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_recv.h b/drivers/staging/rtl8723au/include/rtl8723a_recv.h index 4fbf73140621..885d4d3859f8 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_recv.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_recv.h @@ -60,7 +60,6 @@ struct interrupt_msg_format { unsigned int MSG_EX; }; -void rtl8723au_init_recvbuf(struct rtw_adapter *padapter, struct recv_buf *precvbuf); int rtl8723au_init_recv_priv(struct rtw_adapter * padapter); void rtl8723au_free_recv_priv(struct rtw_adapter * padapter); void rtl8723a_process_phy_info(struct rtw_adapter *padapter, void *prframe); -- cgit v1.2.3 From d095789ae66034c2991b398c5cf8e02ceff1bd88 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:25 +0200 Subject: staging: rtl8723au: Remove empty *_free_xmit_priv() and friends Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 2 -- drivers/staging/rtl8723au/hal/hal_intf.c | 5 ----- drivers/staging/rtl8723au/hal/rtl8723au_xmit.c | 4 ---- drivers/staging/rtl8723au/hal/usb_halinit.c | 1 - drivers/staging/rtl8723au/include/hal_intf.h | 2 -- drivers/staging/rtl8723au/include/rtl8723a_xmit.h | 1 - 6 files changed, 15 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 5b1d35e71c93..99589c467d8e 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -210,8 +210,6 @@ void _rtw_free_xmit_priv23a (struct xmit_priv *pxmitpriv) struct xmit_buf *pxmitbuf; struct list_head *plist, *ptmp; - rtw_hal_free_xmit_priv23a(padapter); - list_for_each_safe(plist, ptmp, &pxmitpriv->free_xmit_queue.queue) { pxframe = container_of(plist, struct xmit_frame, list); list_del_init(&pxframe->list); diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index d22c62c83cb1..afd4e1f9b079 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -208,11 +208,6 @@ s32 rtw_hal_init23a_xmit_priv(struct rtw_adapter *padapter) return padapter->HalFunc.init_xmit_priv(padapter); return _FAIL; } -void rtw_hal_free_xmit_priv23a(struct rtw_adapter *padapter) -{ - if (padapter->HalFunc.free_xmit_priv != NULL) - padapter->HalFunc.free_xmit_priv(padapter); -} s32 rtw_hal_init23a_recv_priv(struct rtw_adapter *padapter) { diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c b/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c index 2af2e3ee1abc..ed8aeb447be7 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c +++ b/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c @@ -31,10 +31,6 @@ s32 rtl8723au_init_xmit_priv(struct rtw_adapter *padapter) return _SUCCESS; } -void rtl8723au_free_xmit_priv(struct rtw_adapter *padapter) -{ -} - static void do_queue_select(struct rtw_adapter *padapter, struct pkt_attrib *pattrib) { u8 qsel; diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index edddc20f24ee..f34d5a40f349 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1756,7 +1756,6 @@ int rtl8723au_set_hal_ops(struct rtw_adapter *padapter) pHalFunc->inirp_deinit = &rtl8723au_inirp_deinit; pHalFunc->init_xmit_priv = &rtl8723au_init_xmit_priv; - pHalFunc->free_xmit_priv = &rtl8723au_free_xmit_priv; pHalFunc->init_recv_priv = &rtl8723au_init_recv_priv; pHalFunc->free_recv_priv = &rtl8723au_free_recv_priv; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index bc29bf2c45e9..2159f43ca286 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -71,7 +71,6 @@ struct hal_ops { u32 (*inirp_deinit)(struct rtw_adapter *padapter); s32 (*init_xmit_priv)(struct rtw_adapter *padapter); - void (*free_xmit_priv)(struct rtw_adapter *padapter); s32 (*init_recv_priv)(struct rtw_adapter *padapter); void (*free_recv_priv)(struct rtw_adapter *padapter); @@ -247,7 +246,6 @@ s32 rtw_hal_mgnt_xmit23a(struct rtw_adapter *padapter, struct xmit_frame *pmgntframe); s32 rtw_hal_init23a_xmit_priv(struct rtw_adapter *padapter); -void rtw_hal_free_xmit_priv23a(struct rtw_adapter *padapter); s32 rtw_hal_init23a_recv_priv(struct rtw_adapter *padapter); void rtw_hal_free_recv_priv23a(struct rtw_adapter *padapter); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_xmit.h b/drivers/staging/rtl8723au/include/rtl8723a_xmit.h index 3b6fdc3a9b7b..80e379c6b6fe 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_xmit.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_xmit.h @@ -220,7 +220,6 @@ s32 rtl8723au_hal_xmitframe_enqueue(struct rtw_adapter *padapter, struct xmit_fr s32 rtl8723au_xmit_buf_handler(struct rtw_adapter *padapter); #define hal_xmit_handler rtl8723au_xmit_buf_handler s32 rtl8723au_init_xmit_priv(struct rtw_adapter * padapter); -void rtl8723au_free_xmit_priv(struct rtw_adapter * padapter); s32 rtl8723au_hal_xmit(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe); s32 rtl8723au_mgnt_xmit(struct rtw_adapter *padapter, struct xmit_frame *pmgntframe); s32 rtl8723au_xmitframe_complete(struct rtw_adapter *padapter, struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf); -- cgit v1.2.3 From c7fff4e43ced0584bcbcef8a5f93bd9a813aac1b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:26 +0200 Subject: staging: rtl8723au: struct phy_info and struct odm_phy_info are identical We don't need two copies of the same struct, it just leads to pointless typecasts. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/odm.c | 3 ++- drivers/staging/rtl8723au/hal/odm_HWConfig.c | 8 ++++---- drivers/staging/rtl8723au/hal/rtl8723au_recv.c | 4 ++-- drivers/staging/rtl8723au/include/odm.h | 16 +--------------- drivers/staging/rtl8723au/include/odm_HWConfig.h | 2 +- 5 files changed, 10 insertions(+), 23 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/odm.c b/drivers/staging/rtl8723au/hal/odm.c index d181cbc77f23..5ef1fd35f5d5 100644 --- a/drivers/staging/rtl8723au/hal/odm.c +++ b/drivers/staging/rtl8723au/hal/odm.c @@ -1639,7 +1639,8 @@ void odm_SwAntDivInit(struct dm_odm_t *pDM_Odm) { } -void ODM_SwAntDivChkPerPktRssi(struct dm_odm_t *pDM_Odm, u8 StationID, struct odm_phy_info *pPhyInfo) +void ODM_SwAntDivChkPerPktRssi(struct dm_odm_t *pDM_Odm, u8 StationID, + struct phy_info *pPhyInfo) { } diff --git a/drivers/staging/rtl8723au/hal/odm_HWConfig.c b/drivers/staging/rtl8723au/hal/odm_HWConfig.c index 2d458bef922a..347c8e90fed6 100644 --- a/drivers/staging/rtl8723au/hal/odm_HWConfig.c +++ b/drivers/staging/rtl8723au/hal/odm_HWConfig.c @@ -91,7 +91,7 @@ odm_EVMdbToPercentage( } static void odm_RxPhyStatus92CSeries_Parsing(struct dm_odm_t *pDM_Odm, - struct odm_phy_info *pPhyInfo, + struct phy_info *pPhyInfo, u8 *pPhyStatus, struct odm_packet_info *pPktinfo) { @@ -281,7 +281,7 @@ void odm_Init_RSSIForDM23a(struct dm_odm_t *pDM_Odm) } static void odm_Process_RSSIForDM(struct dm_odm_t *pDM_Odm, - struct odm_phy_info *pPhyInfo, + struct phy_info *pPhyInfo, struct odm_packet_info *pPktinfo) { s32 UndecoratedSmoothedPWDB, UndecoratedSmoothedCCK; @@ -396,7 +396,7 @@ static void odm_Process_RSSIForDM(struct dm_odm_t *pDM_Odm, /* Endianness before calling this API */ static void ODM_PhyStatusQuery23a_92CSeries(struct dm_odm_t *pDM_Odm, - struct odm_phy_info *pPhyInfo, + struct phy_info *pPhyInfo, u8 *pPhyStatus, struct odm_packet_info *pPktinfo) { @@ -411,7 +411,7 @@ static void ODM_PhyStatusQuery23a_92CSeries(struct dm_odm_t *pDM_Odm, } } -void ODM_PhyStatusQuery23a(struct dm_odm_t *pDM_Odm, struct odm_phy_info *pPhyInfo, +void ODM_PhyStatusQuery23a(struct dm_odm_t *pDM_Odm, struct phy_info *pPhyInfo, u8 *pPhyStatus, struct odm_packet_info *pPktinfo) { ODM_PhyStatusQuery23a_92CSeries(pDM_Odm, pPhyInfo, pPhyStatus, pPktinfo); diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_recv.c b/drivers/staging/rtl8723au/hal/rtl8723au_recv.c index 6a25ad572b26..f0ce944dc4c4 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723au_recv.c +++ b/drivers/staging/rtl8723au/hal/rtl8723au_recv.c @@ -184,7 +184,7 @@ void update_recvframe_phyinfo(struct recv_frame *precvframe, struct rtw_adapter *padapter = precvframe->adapter; struct rx_pkt_attrib *pattrib = &precvframe->attrib; struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - struct odm_phy_info *pPHYInfo = (struct odm_phy_info *)(&pattrib->phy_info); + struct phy_info *pPHYInfo = &pattrib->phy_info; struct odm_packet_info pkt_info; u8 *sa = NULL, *da; struct sta_priv *pstapriv; @@ -247,7 +247,7 @@ void update_recvframe_phyinfo(struct recv_frame *precvframe, pkt_info.Rate = pattrib->mcs_rate; ODM_PhyStatusQuery23a(&pHalData->odmpriv, pPHYInfo, - (u8 *)pphy_status, &pkt_info); + (u8 *)pphy_status, &pkt_info); precvframe->psta = NULL; if (pkt_info.bPacketMatchBSSID && (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == true)) { diff --git a/drivers/staging/rtl8723au/include/odm.h b/drivers/staging/rtl8723au/include/odm.h index e2b14f8b2d53..aa46c6c56898 100644 --- a/drivers/staging/rtl8723au/include/odm.h +++ b/drivers/staging/rtl8723au/include/odm.h @@ -255,20 +255,6 @@ struct odm_rate_adapt { /* Declare for common info */ -struct odm_phy_info { - u8 RxPWDBAll; - u8 SignalQuality; /* in 0-100 index. */ - u8 RxMIMOSignalQuality[RF_PATH_MAX]; /* EVM */ - u8 RxMIMOSignalStrength[RF_PATH_MAX];/* in 0~100 index */ - s8 RxPower; /* in dBm Translate from PWdB */ - s8 RecvSignalPower;/* Real power in dBm for this packet, no beautification and aggregation. Keep this raw info to be used for the other procedures. */ - u8 BTRxRSSIPercentage; - u8 SignalStrength; /* in 0-100 index. */ - u8 RxPwr[RF_PATH_MAX];/* per-path's pwdb */ - u8 RxSNR[RF_PATH_MAX];/* per-path's SNR */ -}; - - struct odm_phy_dbg_info { /* ODM Write,debug info */ s8 RxSNRdB[RF_PATH_MAX]; @@ -1136,7 +1122,7 @@ bool ODM_RAStateCheck23a(struct dm_odm_t *pDM_Odm, s32 RSSI, bool bForceUpdate, #define dm_SWAW_RSSI_Check ODM_SwAntDivChkPerPktRssi void ODM_SwAntDivChkPerPktRssi(struct dm_odm_t *pDM_Odm, u8 StationID, - struct odm_phy_info *pPhyInfo); + struct phy_info *pPhyInfo); u32 ConvertTo_dB23a(u32 Value); diff --git a/drivers/staging/rtl8723au/include/odm_HWConfig.h b/drivers/staging/rtl8723au/include/odm_HWConfig.h index d2367ec95f17..6b98e05d0460 100644 --- a/drivers/staging/rtl8723au/include/odm_HWConfig.h +++ b/drivers/staging/rtl8723au/include/odm_HWConfig.h @@ -147,7 +147,7 @@ void odm_Init_RSSIForDM23a(struct dm_odm_t *pDM_Odm); void ODM_PhyStatusQuery23a( struct dm_odm_t *pDM_Odm, - struct odm_phy_info *pPhyInfo, + struct phy_info *pPhyInfo, u8 * pPhyStatus, struct odm_packet_info *pPktinfo ); -- cgit v1.2.3 From 299bcd779aefaca87401b6da7d676b66ee470b60 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:27 +0200 Subject: staging: rtl8723au: struct odm_mac_info isn't used Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/odm.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8723au/include/odm.h b/drivers/staging/rtl8723au/include/odm.h index aa46c6c56898..df1c86754566 100644 --- a/drivers/staging/rtl8723au/include/odm.h +++ b/drivers/staging/rtl8723au/include/odm.h @@ -274,11 +274,6 @@ struct odm_packet_info { bool bPacketBeacon; }; -struct odm_mac_info { - u8 test; - -}; - enum { /* BB Team */ @@ -859,7 +854,6 @@ struct dm_odm_t { /* PHY_INFO_88E PhyInfo; */ /* Latest packet phy info (ODM write) */ - struct odm_mac_info *pMacInfo; /* MAC_INFO_88E MacInfo; */ /* Different Team independt structure?? */ -- cgit v1.2.3 From 9f409937549b1018cb8fafcb8db22ea029498b20 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:28 +0200 Subject: staging: rtl8723au: Remove unused variable IOTPeer For bizarre reason we have unused variables IOTPeer both in struct sta_info and struct odm_sta_info. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/odm.h | 1 - drivers/staging/rtl8723au/include/sta_info.h | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/staging/rtl8723au/include/odm.h b/drivers/staging/rtl8723au/include/odm.h index df1c86754566..45c2ef50993a 100644 --- a/drivers/staging/rtl8723au/include/odm.h +++ b/drivers/staging/rtl8723au/include/odm.h @@ -298,7 +298,6 @@ enum { struct odm_sta_info { /* Driver Write */ bool bUsed; /* record the sta status link or not? */ - u8 IOTPeer; /* Enum value. HT_IOT_PEER_E */ /* ODM Write */ /* 1 PHY_STATUS_INFO */ diff --git a/drivers/staging/rtl8723au/include/sta_info.h b/drivers/staging/rtl8723au/include/sta_info.h index 3bd8f44895c9..10d933e0939b 100644 --- a/drivers/staging/rtl8723au/include/sta_info.h +++ b/drivers/staging/rtl8723au/include/sta_info.h @@ -211,7 +211,6 @@ struct sta_info { /* */ /* Driver Write */ u8 bValid; /* record the sta status link or not? */ - u8 IOTPeer; /* Enum value. HT_IOT_PEER_E */ u8 rssi_level; /* for Refresh RA mask */ /* ODM Write */ /* 1 PHY_STATUS_INFO */ -- cgit v1.2.3 From baa76831d1bb6a78bffbd639478f09e74c56a5b0 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:29 +0200 Subject: staging: rtl8723au: Since struct odm_sta_info isn't used, remove it completely Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/odm.h | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/drivers/staging/rtl8723au/include/odm.h b/drivers/staging/rtl8723au/include/odm.h index 45c2ef50993a..b3e726afc0f9 100644 --- a/drivers/staging/rtl8723au/include/odm.h +++ b/drivers/staging/rtl8723au/include/odm.h @@ -291,31 +291,6 @@ enum { ODM_PSD2AFH = 0x00000800 }; -/* */ -/* 2011/20/20 MH For MP driver RT_WLAN_STA = struct sta_info */ -/* Please declare below ODM relative info in your STA info structure. */ -/* */ -struct odm_sta_info { - /* Driver Write */ - bool bUsed; /* record the sta status link or not? */ - - /* ODM Write */ - /* 1 PHY_STATUS_INFO */ - u8 RSSI_Path[4]; /* */ - u8 RSSI_Ave; - u8 RXEVM[4]; - u8 RXSNR[4]; - - /* ODM Write */ - /* 1 TX_INFO (may changed by IC) */ - - /* */ - /* Please use compile flag to disable the structure for other IC except 88E. */ - /* Move To lower layer. */ - /* */ - /* ODM Write Wilson will handle this part(said by Luke.Lee) */ -}; - /* */ /* 2011/10/20 MH Define Common info enum for all team. */ /* */ -- cgit v1.2.3 From ef05499a75e53f53ea3c23ffa28b9ce1dad044c0 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 9 May 2014 15:04:30 +0200 Subject: staging: rtl8723au: Remove unused struct odm_ra_info Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/odm.h | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/drivers/staging/rtl8723au/include/odm.h b/drivers/staging/rtl8723au/include/odm.h index b3e726afc0f9..e809824c6a4c 100644 --- a/drivers/staging/rtl8723au/include/odm.h +++ b/drivers/staging/rtl8723au/include/odm.h @@ -556,38 +556,6 @@ enum odm_cca_path { ODM_CCA_1R_B = 2, }; -struct odm_ra_info { - u8 RateID; - u32 RateMask; - u32 RAUseRate; - u8 RateSGI; - u8 RssiStaRA; - u8 PreRssiStaRA; - u8 SGIEnable; - u8 DecisionRate; - u8 PreRate; - u8 HighestRate; - u8 LowestRate; - u32 NscUp; - u32 NscDown; - u16 RTY[5]; - u32 TOTAL; - u16 DROP; - u8 Active; - u16 RptTime; - u8 RAWaitingCounter; - u8 RAPendingCounter; - u8 PTActive; /* on or off */ - u8 PTTryState; /* 0 trying state, 1 for decision state */ - u8 PTStage; /* 0~6 */ - u8 PTStopCount; /* Stop PT counter */ - u8 PTPreRate; /* if rate change do PT */ - u8 PTPreRssi; /* if RSSI change 5% do PT */ - u8 PTModeSS; /* decide whitch rate should do PT */ - u8 RAstage; /* StageRA, decide how many times RA will be done between PT */ - u8 PTSmoothFactor; -}; - struct iqk_matrix_regs_set { bool bIQKDone; s32 Value[1][IQK_Matrix_REG_NUM]; -- cgit v1.2.3 From 1b3b9af1005e6207b82791bb0e86c6e8beab4b6c Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 9 May 2014 15:04:31 +0200 Subject: staging: rtl8723au: fix some confusing indenting The break and the "unknown++" are at the same indent level so my static checker complains. The if statement should be indented more. Signed-off-by: Dan Carpenter Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 2bd74f0893a2..1789822e785a 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1233,8 +1233,8 @@ static int rtw_validate_frame_ies(const u8 *start, uint len) case WLAN_EID_ERP_INFO: case WLAN_EID_EXT_SUPP_RATES: case WLAN_EID_VENDOR_SPECIFIC: - if (rtw_validate_vendor_specific_ies(pos, elen)) - unknown++; + if (rtw_validate_vendor_specific_ies(pos, elen)) + unknown++; break; case WLAN_EID_RSN: case WLAN_EID_PWR_CAPABILITY: -- cgit v1.2.3 From 0cc6c3ab3cdbcf8a4a103d27599a6d0b44a6c315 Mon Sep 17 00:00:00 2001 From: Christian Engelmayer Date: Wed, 7 May 2014 21:21:58 +0200 Subject: staging: rtl8723au: Remove unused pointer in rtw_wdev_free() Pointer 'pwdev_priv' in function rtw_wdev_free() is unused - thus remove it. Signed-off-by: Christian Engelmayer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 1e3129f12f84..53cec46763f0 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -3560,15 +3560,11 @@ exit: void rtw_wdev_free(struct wireless_dev *wdev) { - struct rtw_wdev_priv *pwdev_priv; - DBG_8723A("%s(wdev =%p)\n", __func__, wdev); if (!wdev) return; - pwdev_priv = wdev_to_priv(wdev); - kfree(wdev->wiphy->bands[IEEE80211_BAND_2GHZ]); kfree(wdev->wiphy->bands[IEEE80211_BAND_5GHZ]); -- cgit v1.2.3 From 49a75c444fcf07fdde2ec74428b6b1b9ff1c6b15 Mon Sep 17 00:00:00 2001 From: Jun Tian Date: Mon, 12 May 2014 16:54:46 +0100 Subject: goldfish: 64-bit pipe driver for goldfish platform Support 64-bit channel and address for the goldfish pipe driver. Signed-off-by: Jun Tian Signed-off-by: Octavian Purdila Signed-off-by: Brian Wood Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/platform/goldfish/goldfish_pipe.c | 35 +++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c index 4f5aa831f549..f33c6e0e7fb0 100644 --- a/drivers/platform/goldfish/goldfish_pipe.c +++ b/drivers/platform/goldfish/goldfish_pipe.c @@ -66,8 +66,14 @@ #define PIPE_REG_COMMAND 0x00 /* write: value = command */ #define PIPE_REG_STATUS 0x04 /* read */ #define PIPE_REG_CHANNEL 0x08 /* read/write: channel id */ +#ifdef CONFIG_64BIT +#define PIPE_REG_CHANNEL_HIGH 0x30 /* read/write: channel id */ +#endif #define PIPE_REG_SIZE 0x0c /* read/write: buffer size */ #define PIPE_REG_ADDRESS 0x10 /* write: physical address */ +#ifdef CONFIG_64BIT +#define PIPE_REG_ADDRESS_HIGH 0x34 /* write: physical address */ +#endif #define PIPE_REG_WAKES 0x14 /* read: wake flags */ #define PIPE_REG_PARAMS_ADDR_LOW 0x18 /* read/write: batch data address */ #define PIPE_REG_PARAMS_ADDR_HIGH 0x1c /* read/write: batch data address */ @@ -109,9 +115,9 @@ #define PIPE_WAKE_WRITE (1 << 2) /* pipe can now be written to */ struct access_params { - u32 channel; + unsigned long channel; u32 size; - u32 address; + unsigned long address; u32 cmd; u32 result; /* reserved for future extension */ @@ -155,7 +161,10 @@ static u32 goldfish_cmd_status(struct goldfish_pipe *pipe, u32 cmd) struct goldfish_pipe_dev *dev = pipe->dev; spin_lock_irqsave(&dev->lock, flags); - writel((u32)pipe, dev->base + PIPE_REG_CHANNEL); + writel((u32)(u64)pipe, dev->base + PIPE_REG_CHANNEL); +#ifdef CONFIG_64BIT + writel((u32)((u64)pipe >> 32), dev->base + PIPE_REG_CHANNEL_HIGH); +#endif writel(cmd, dev->base + PIPE_REG_COMMAND); status = readl(dev->base + PIPE_REG_STATUS); spin_unlock_irqrestore(&dev->lock, flags); @@ -168,7 +177,10 @@ static void goldfish_cmd(struct goldfish_pipe *pipe, u32 cmd) struct goldfish_pipe_dev *dev = pipe->dev; spin_lock_irqsave(&dev->lock, flags); - writel((u32)pipe, dev->base + PIPE_REG_CHANNEL); + writel((u32)(u64)pipe, dev->base + PIPE_REG_CHANNEL); +#ifdef CONFIG_64BIT + writel((u32)((u64)pipe >> 32), dev->base + PIPE_REG_CHANNEL_HIGH); +#endif writel(cmd, dev->base + PIPE_REG_COMMAND); spin_unlock_irqrestore(&dev->lock, flags); } @@ -322,9 +334,15 @@ static ssize_t goldfish_pipe_read_write(struct file *filp, char __user *buffer, spin_lock_irqsave(&dev->lock, irq_flags); if (access_with_param(dev, CMD_WRITE_BUFFER + cmd_offset, address, avail, pipe, &status)) { - writel((u32)pipe, dev->base + PIPE_REG_CHANNEL); + writel((u32)(u64)pipe, dev->base + PIPE_REG_CHANNEL); +#ifdef CONFIG_64BIT + writel((u32)((u64)pipe >> 32), dev->base + PIPE_REG_CHANNEL_HIGH); +#endif writel(avail, dev->base + PIPE_REG_SIZE); writel(address, dev->base + PIPE_REG_ADDRESS); +#ifdef CONFIG_64BIT + writel((u32)((u64)address >> 32), dev->base + PIPE_REG_ADDRESS_HIGH); +#endif writel(CMD_WRITE_BUFFER + cmd_offset, dev->base + PIPE_REG_COMMAND); status = readl(dev->base + PIPE_REG_STATUS); @@ -447,7 +465,12 @@ static irqreturn_t goldfish_pipe_interrupt(int irq, void *dev_id) /* First read the channel, 0 means the end of the list */ struct goldfish_pipe *pipe; unsigned long wakes; - unsigned long channel = readl(dev->base + PIPE_REG_CHANNEL); + unsigned long channel = 0; + +#ifdef CONFIG_64BIT + channel = (u64)readl(dev->base + PIPE_REG_CHANNEL_HIGH) << 32; +#endif + channel |= readl(dev->base + PIPE_REG_CHANNEL); if (channel == 0) break; -- cgit v1.2.3 From 25c72c786cb571cfdf39a31f9f64d143d8623a7a Mon Sep 17 00:00:00 2001 From: Jun Tian Date: Mon, 12 May 2014 16:54:57 +0100 Subject: goldfish: fix kernel panic when using multiple adb connection When using multiple adb on 64 bit kernel to transfer data, the goldfish pipe interrupt will crash the kernel. Signed-off-by: Jun Tian Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/platform/goldfish/goldfish_pipe.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c index f33c6e0e7fb0..670b9b94f74b 100644 --- a/drivers/platform/goldfish/goldfish_pipe.c +++ b/drivers/platform/goldfish/goldfish_pipe.c @@ -469,6 +469,9 @@ static irqreturn_t goldfish_pipe_interrupt(int irq, void *dev_id) #ifdef CONFIG_64BIT channel = (u64)readl(dev->base + PIPE_REG_CHANNEL_HIGH) << 32; + + if (channel == 0) + break; #endif channel |= readl(dev->base + PIPE_REG_CHANNEL); -- cgit v1.2.3 From f10d8434201859d5ad7f51032dcd2d0c09e85ee2 Mon Sep 17 00:00:00 2001 From: Octavian Purdila Date: Mon, 12 May 2014 16:55:05 +0100 Subject: goldfish: add support for 64bit to the virtual bus This patchs adds a new register to pass the upper 32bits for the device name address when running in 64bit mode. Signed-off-by: Octavian Purdila Signed-off-by: Jun Tian Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/platform/goldfish/pdev_bus.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/platform/goldfish/pdev_bus.c b/drivers/platform/goldfish/pdev_bus.c index 4eb2bb34790d..eb254400c44a 100644 --- a/drivers/platform/goldfish/pdev_bus.c +++ b/drivers/platform/goldfish/pdev_bus.c @@ -36,6 +36,7 @@ #define PDEV_BUS_IO_SIZE (0x14) #define PDEV_BUS_IRQ (0x18) #define PDEV_BUS_IRQ_COUNT (0x1c) +#define PDEV_BUS_GET_NAME_HIGH (0x20) struct pdev_bus_dev { struct list_head list; @@ -129,7 +130,10 @@ static int goldfish_new_pdev(void) dev->pdev.dev.dma_mask = (void *)(dev->pdev.name + name_len + 1); *dev->pdev.dev.dma_mask = ~0; - writel((unsigned long)name, pdev_bus_base + PDEV_BUS_GET_NAME); +#ifdef CONFIG_64BIT + writel((u32)((u64)name>>32), pdev_bus_base + PDEV_BUS_GET_NAME_HIGH); +#endif + writel((u32)(u64)name, pdev_bus_base + PDEV_BUS_GET_NAME); name[name_len] = '\0'; dev->pdev.id = readl(pdev_bus_base + PDEV_BUS_ID); dev->pdev.resource[0].start = base; -- cgit v1.2.3 From ec5e34c074793a1f80faaf75e9468dd2f39ec1dc Mon Sep 17 00:00:00 2001 From: Nick Kralevich Date: Mon, 12 May 2014 16:55:16 +0100 Subject: goldfish_nand.c: remove length restrictions Remove limitations on the size of a read / write request. AFAIK, there's no consequence to allowing the upper layers to specify different read / write sizes. This is needed to support running ext4 on goldfish. Bug: https://code.google.com/p/android/issues/detail?id=38561 Signed-off-by: Nick Kralevich Signed-off-by: Jun Tian Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/goldfish/goldfish_nand.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/goldfish/goldfish_nand.c b/drivers/staging/goldfish/goldfish_nand.c index b8e3dd28096d..b7ca553dfa29 100644 --- a/drivers/staging/goldfish/goldfish_nand.c +++ b/drivers/staging/goldfish/goldfish_nand.c @@ -202,8 +202,6 @@ static int goldfish_nand_read(struct mtd_info *mtd, loff_t from, size_t len, if (from + len > mtd->size) goto invalid_arg; - if (len != mtd->writesize) - goto invalid_arg; rem = do_div(from, mtd->writesize); if (rem) @@ -226,8 +224,6 @@ static int goldfish_nand_write(struct mtd_info *mtd, loff_t to, size_t len, if (to + len > mtd->size) goto invalid_arg; - if (len != mtd->writesize) - goto invalid_arg; rem = do_div(to, mtd->writesize); if (rem) -- cgit v1.2.3 From b8658bc81089d656fe54b12e21f0cae5116b6483 Mon Sep 17 00:00:00 2001 From: Jun Tian Date: Mon, 12 May 2014 16:55:26 +0100 Subject: goldfish: enable 64-bit tty driver Signed-off-by: Jun Tian Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/tty/goldfish.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c index 75dc9d25f326..08167aa093b2 100644 --- a/drivers/tty/goldfish.c +++ b/drivers/tty/goldfish.c @@ -29,6 +29,9 @@ enum { GOLDFISH_TTY_DATA_PTR = 0x10, GOLDFISH_TTY_DATA_LEN = 0x14, +#ifdef CONFIG_64BIT + GOLDFISH_TTY_DATA_PTR_HIGH = 0x18, +#endif GOLDFISH_TTY_CMD_INT_DISABLE = 0, GOLDFISH_TTY_CMD_INT_ENABLE = 1, @@ -58,6 +61,9 @@ static void goldfish_tty_do_write(int line, const char *buf, unsigned count) void __iomem *base = qtty->base; spin_lock_irqsave(&qtty->lock, irq_flags); writel((u32)buf, base + GOLDFISH_TTY_DATA_PTR); +#ifdef CONFIG_64BIT + writel((u32)((u64)buf >> 32), base + GOLDFISH_TTY_DATA_PTR_HIGH); +#endif writel(count, base + GOLDFISH_TTY_DATA_LEN); writel(GOLDFISH_TTY_CMD_WRITE_BUFFER, base + GOLDFISH_TTY_CMD); spin_unlock_irqrestore(&qtty->lock, irq_flags); @@ -79,6 +85,9 @@ static irqreturn_t goldfish_tty_interrupt(int irq, void *dev_id) count = tty_prepare_flip_string(&qtty->port, &buf, count); spin_lock_irqsave(&qtty->lock, irq_flags); writel((u32)buf, base + GOLDFISH_TTY_DATA_PTR); +#ifdef CONFIG_64BIT + writel((u32)((u64)buf >> 32), base + GOLDFISH_TTY_DATA_PTR_HIGH); +#endif writel(count, base + GOLDFISH_TTY_DATA_LEN); writel(GOLDFISH_TTY_CMD_READ_BUFFER, base + GOLDFISH_TTY_CMD); spin_unlock_irqrestore(&qtty->lock, irq_flags); -- cgit v1.2.3 From 9b17aeec232a5f0a61ce3952c2e728a0eeddda8b Mon Sep 17 00:00:00 2001 From: Alan Date: Mon, 12 May 2014 16:55:35 +0100 Subject: goldfish: Allow 64bit builds We can now enable the 64bit option for the Goldfish 64bit emulator. Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- arch/x86/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 25d2c6f7325e..9c43ea3cf510 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -415,7 +415,6 @@ config X86_UV config X86_GOLDFISH bool "Goldfish (Virtual Platform)" - depends on X86_32 depends on X86_EXTENDED_PLATFORM ---help--- Enable support for the Goldfish virtual platform used primarily -- cgit v1.2.3 From f6279717bbb20bf90ec414af17d2a31d843f5eb5 Mon Sep 17 00:00:00 2001 From: Alan Date: Mon, 12 May 2014 16:56:56 +0100 Subject: goldfish: clean up staging ifdefs Use the write helpers and add an audio helper Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/goldfish/goldfish_audio.c | 44 +++++++--------------------- drivers/staging/goldfish/goldfish_nand.c | 7 ++--- drivers/staging/goldfish/goldfish_nand_reg.h | 2 -- 3 files changed, 13 insertions(+), 40 deletions(-) diff --git a/drivers/staging/goldfish/goldfish_audio.c b/drivers/staging/goldfish/goldfish_audio.c index 383bee687151..cbd456770af0 100644 --- a/drivers/staging/goldfish/goldfish_audio.c +++ b/drivers/staging/goldfish/goldfish_audio.c @@ -26,6 +26,7 @@ #include #include #include +#include MODULE_AUTHOR("Google, Inc."); MODULE_DESCRIPTION("Android QEMU Audio Driver"); @@ -60,6 +61,8 @@ struct goldfish_audio { #define AUDIO_READ(data, addr) (readl(data->reg_base + addr)) #define AUDIO_WRITE(data, addr, x) (writel(x, data->reg_base + addr)) +#define AUDIO_WRITE64(data, addr, addr2, x) \ + (gf_write64((u64)(x), data->reg_base + addr, data->reg_base+addr2)) /* * temporary variable used between goldfish_audio_probe() and @@ -78,18 +81,14 @@ enum { /* set number of bytes in buffer to write */ AUDIO_WRITE_BUFFER_1 = 0x10, AUDIO_WRITE_BUFFER_2 = 0x14, -#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT AUDIO_SET_WRITE_BUFFER_1_HIGH = 0x28, AUDIO_SET_WRITE_BUFFER_2_HIGH = 0x30, -#endif /* true if audio input is supported */ AUDIO_READ_SUPPORTED = 0x18, /* buffer to use for audio input */ AUDIO_SET_READ_BUFFER = 0x1C, -#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT AUDIO_SET_READ_BUFFER_HIGH = 0x34, -#endif /* driver writes number of bytes to read */ AUDIO_START_READ = 0x20, @@ -274,9 +273,6 @@ static int goldfish_audio_probe(struct platform_device *pdev) struct resource *r; struct goldfish_audio *data; dma_addr_t buf_addr; -#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT - u32 buf_addr_high, buf_addr_low; -#endif data = kzalloc(sizeof(*data), GFP_KERNEL); if (data == NULL) { @@ -332,37 +328,19 @@ static int goldfish_audio_probe(struct platform_device *pdev) goto err_misc_register_failed; } -#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT - buf_addr_low = (u32)(buf_addr); - buf_addr_high = (u32)((buf_addr) >> 32); + AUDIO_WRITE64(data, AUDIO_SET_WRITE_BUFFER_1, + AUDIO_SET_WRITE_BUFFER_1_HIGH, buf_addr); + buf_addr += WRITE_BUFFER_SIZE; - AUDIO_WRITE(data, AUDIO_SET_WRITE_BUFFER_1, buf_addr_low); - AUDIO_WRITE(data, AUDIO_SET_WRITE_BUFFER_1_HIGH, buf_addr_high); + AUDIO_WRITE64(data, AUDIO_SET_WRITE_BUFFER_2, + AUDIO_SET_WRITE_BUFFER_2_HIGH, buf_addr); - buf_addr_low = (u32)(buf_addr + WRITE_BUFFER_SIZE); - buf_addr_high = (u32)((buf_addr + WRITE_BUFFER_SIZE) >> 32); - - AUDIO_WRITE(data, AUDIO_SET_WRITE_BUFFER_2, buf_addr_low); - AUDIO_WRITE(data, AUDIO_SET_WRITE_BUFFER_2_HIGH, buf_addr_high); - - buf_addr_low = (u32)(buf_addr + 2 * WRITE_BUFFER_SIZE); - buf_addr_high = (u32)((buf_addr + 2 * WRITE_BUFFER_SIZE) >> 32); - - data->read_supported = AUDIO_READ(data, AUDIO_READ_SUPPORTED); - if (data->read_supported){ - AUDIO_WRITE(data, AUDIO_SET_READ_BUFFER, buf_addr_low); - AUDIO_WRITE(data, AUDIO_SET_READ_BUFFER_HIGH, buf_addr_high); - } -#else - AUDIO_WRITE(data, AUDIO_SET_WRITE_BUFFER_1, buf_addr); - AUDIO_WRITE(data, AUDIO_SET_WRITE_BUFFER_2, - buf_addr + WRITE_BUFFER_SIZE); + buf_addr += WRITE_BUFFER_SIZE; data->read_supported = AUDIO_READ(data, AUDIO_READ_SUPPORTED); if (data->read_supported) - AUDIO_WRITE(data, AUDIO_SET_READ_BUFFER, - buf_addr + 2 * WRITE_BUFFER_SIZE); -#endif + AUDIO_WRITE64(data, AUDIO_SET_READ_BUFFER, + AUDIO_SET_READ_BUFFER_HIGH, buf_addr); audio_data = data; return 0; diff --git a/drivers/staging/goldfish/goldfish_nand.c b/drivers/staging/goldfish/goldfish_nand.c index b7ca553dfa29..092604c698b6 100644 --- a/drivers/staging/goldfish/goldfish_nand.c +++ b/drivers/staging/goldfish/goldfish_nand.c @@ -25,7 +25,7 @@ #include #include #include - +#include #include #include "goldfish_nand_reg.h" @@ -86,10 +86,7 @@ static u32 goldfish_nand_cmd(struct mtd_info *mtd, enum nand_cmd cmd, writel((u32)(addr >> 32), base + NAND_ADDR_HIGH); writel((u32)addr, base + NAND_ADDR_LOW); writel(len, base + NAND_TRANSFER_SIZE); - writel((u32)ptr, base + NAND_DATA); -#ifdef CONFIG_64BIT - writel((u32)((u64)ptr >> 32), base + NAND_DATA_HIGH); -#endif + gf_write64((u64)ptr, base + NAND_DATA, base + NAND_DATA_HIGH); writel(cmd, base + NAND_COMMAND); rv = readl(base + NAND_RESULT); } diff --git a/drivers/staging/goldfish/goldfish_nand_reg.h b/drivers/staging/goldfish/goldfish_nand_reg.h index 60ab91f74be7..fe7f47c7a5c8 100644 --- a/drivers/staging/goldfish/goldfish_nand_reg.h +++ b/drivers/staging/goldfish/goldfish_nand_reg.h @@ -57,9 +57,7 @@ enum nand_reg { NAND_RESULT = 0x040, NAND_COMMAND = 0x044, NAND_DATA = 0x048, -#ifdef CONFIG_64BIT NAND_DATA_HIGH = 0x100, -#endif NAND_TRANSFER_SIZE = 0x04c, NAND_ADDR_LOW = 0x050, NAND_ADDR_HIGH = 0x054, -- cgit v1.2.3 From e0f682e05f51c9eff68e61ce2350155895cd739e Mon Sep 17 00:00:00 2001 From: Alan Date: Mon, 12 May 2014 16:57:05 +0100 Subject: goldfish: clean up tty 64bit support Use the helper we now have available. Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/tty/goldfish.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c index 08167aa093b2..7eaafe3c80dc 100644 --- a/drivers/tty/goldfish.c +++ b/drivers/tty/goldfish.c @@ -21,6 +21,7 @@ #include #include #include +#include enum { GOLDFISH_TTY_PUT_CHAR = 0x00, @@ -29,9 +30,7 @@ enum { GOLDFISH_TTY_DATA_PTR = 0x10, GOLDFISH_TTY_DATA_LEN = 0x14, -#ifdef CONFIG_64BIT GOLDFISH_TTY_DATA_PTR_HIGH = 0x18, -#endif GOLDFISH_TTY_CMD_INT_DISABLE = 0, GOLDFISH_TTY_CMD_INT_ENABLE = 1, @@ -60,10 +59,8 @@ static void goldfish_tty_do_write(int line, const char *buf, unsigned count) struct goldfish_tty *qtty = &goldfish_ttys[line]; void __iomem *base = qtty->base; spin_lock_irqsave(&qtty->lock, irq_flags); - writel((u32)buf, base + GOLDFISH_TTY_DATA_PTR); -#ifdef CONFIG_64BIT - writel((u32)((u64)buf >> 32), base + GOLDFISH_TTY_DATA_PTR_HIGH); -#endif + gf_write64((u64)buf, base + GOLDFISH_TTY_DATA_PTR, + base + GOLDFISH_TTY_DATA_PTR_HIGH); writel(count, base + GOLDFISH_TTY_DATA_LEN); writel(GOLDFISH_TTY_CMD_WRITE_BUFFER, base + GOLDFISH_TTY_CMD); spin_unlock_irqrestore(&qtty->lock, irq_flags); @@ -84,10 +81,8 @@ static irqreturn_t goldfish_tty_interrupt(int irq, void *dev_id) count = tty_prepare_flip_string(&qtty->port, &buf, count); spin_lock_irqsave(&qtty->lock, irq_flags); - writel((u32)buf, base + GOLDFISH_TTY_DATA_PTR); -#ifdef CONFIG_64BIT - writel((u32)((u64)buf >> 32), base + GOLDFISH_TTY_DATA_PTR_HIGH); -#endif + gf_write64((u64)buf, base + GOLDFISH_TTY_DATA_PTR, + base + GOLDFISH_TTY_DATA_PTR_HIGH); writel(count, base + GOLDFISH_TTY_DATA_LEN); writel(GOLDFISH_TTY_CMD_READ_BUFFER, base + GOLDFISH_TTY_CMD); spin_unlock_irqrestore(&qtty->lock, irq_flags); -- cgit v1.2.3 From d78055dc9c786b392ce7b593c479bb9a3e1da61d Mon Sep 17 00:00:00 2001 From: Alan Date: Mon, 12 May 2014 16:57:14 +0100 Subject: goldfish: clean up the checkpatch warnings Mostly spacing changes, also making the operations structure const Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/tty/goldfish.c | 60 ++++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c index 7eaafe3c80dc..09495f515fa9 100644 --- a/drivers/tty/goldfish.c +++ b/drivers/tty/goldfish.c @@ -76,7 +76,7 @@ static irqreturn_t goldfish_tty_interrupt(int irq, void *dev_id) u32 count; count = readl(base + GOLDFISH_TTY_BYTES_READY); - if(count == 0) + if (count == 0) return IRQ_NONE; count = tty_prepare_flip_string(&qtty->port, &buf, count); @@ -92,24 +92,26 @@ static irqreturn_t goldfish_tty_interrupt(int irq, void *dev_id) static int goldfish_tty_activate(struct tty_port *port, struct tty_struct *tty) { - struct goldfish_tty *qtty = container_of(port, struct goldfish_tty, port); + struct goldfish_tty *qtty = container_of(port, struct goldfish_tty, + port); writel(GOLDFISH_TTY_CMD_INT_ENABLE, qtty->base + GOLDFISH_TTY_CMD); return 0; } static void goldfish_tty_shutdown(struct tty_port *port) { - struct goldfish_tty *qtty = container_of(port, struct goldfish_tty, port); + struct goldfish_tty *qtty = container_of(port, struct goldfish_tty, + port); writel(GOLDFISH_TTY_CMD_INT_DISABLE, qtty->base + GOLDFISH_TTY_CMD); } -static int goldfish_tty_open(struct tty_struct * tty, struct file * filp) +static int goldfish_tty_open(struct tty_struct *tty, struct file *filp) { struct goldfish_tty *qtty = &goldfish_ttys[tty->index]; return tty_port_open(&qtty->port, tty, filp); } -static void goldfish_tty_close(struct tty_struct * tty, struct file * filp) +static void goldfish_tty_close(struct tty_struct *tty, struct file *filp) { tty_port_close(tty->port, tty, filp); } @@ -119,7 +121,8 @@ static void goldfish_tty_hangup(struct tty_struct *tty) tty_port_hangup(tty->port); } -static int goldfish_tty_write(struct tty_struct * tty, const unsigned char *buf, int count) +static int goldfish_tty_write(struct tty_struct *tty, const unsigned char *buf, + int count) { goldfish_tty_do_write(tty->index, buf, count); return count; @@ -137,12 +140,14 @@ static int goldfish_tty_chars_in_buffer(struct tty_struct *tty) return readl(base + GOLDFISH_TTY_BYTES_READY); } -static void goldfish_tty_console_write(struct console *co, const char *b, unsigned count) +static void goldfish_tty_console_write(struct console *co, const char *b, + unsigned count) { goldfish_tty_do_write(co->index, b, count); } -static struct tty_driver *goldfish_tty_console_device(struct console *c, int *index) +static struct tty_driver *goldfish_tty_console_device(struct console *c, + int *index) { *index = c->index; return goldfish_tty_driver; @@ -150,9 +155,9 @@ static struct tty_driver *goldfish_tty_console_device(struct console *c, int *in static int goldfish_tty_console_setup(struct console *co, char *options) { - if((unsigned)co->index > goldfish_tty_line_count) + if ((unsigned)co->index > goldfish_tty_line_count) return -ENODEV; - if(goldfish_ttys[co->index].base == 0) + if (goldfish_ttys[co->index].base == 0) return -ENODEV; return 0; } @@ -162,7 +167,7 @@ static struct tty_port_operations goldfish_port_ops = { .shutdown = goldfish_tty_shutdown }; -static struct tty_operations goldfish_tty_ops = { +static const struct tty_operations goldfish_tty_ops = { .open = goldfish_tty_open, .close = goldfish_tty_close, .hangup = goldfish_tty_hangup, @@ -176,13 +181,14 @@ static int goldfish_tty_create_driver(void) int ret; struct tty_driver *tty; - goldfish_ttys = kzalloc(sizeof(*goldfish_ttys) * goldfish_tty_line_count, GFP_KERNEL); - if(goldfish_ttys == NULL) { + goldfish_ttys = kzalloc(sizeof(*goldfish_ttys) * + goldfish_tty_line_count, GFP_KERNEL); + if (goldfish_ttys == NULL) { ret = -ENOMEM; goto err_alloc_goldfish_ttys_failed; } tty = alloc_tty_driver(goldfish_tty_line_count); - if(tty == NULL) { + if (tty == NULL) { ret = -ENOMEM; goto err_alloc_tty_driver_failed; } @@ -191,10 +197,11 @@ static int goldfish_tty_create_driver(void) tty->type = TTY_DRIVER_TYPE_SERIAL; tty->subtype = SERIAL_TYPE_NORMAL; tty->init_termios = tty_std_termios; - tty->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; + tty->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW | + TTY_DRIVER_DYNAMIC_DEV; tty_set_operations(tty, &goldfish_tty_ops); ret = tty_register_driver(tty); - if(ret) + if (ret) goto err_tty_register_driver_failed; goldfish_tty_driver = tty; @@ -229,7 +236,7 @@ static int goldfish_tty_probe(struct platform_device *pdev) u32 irq; r = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if(r == NULL) + if (r == NULL) return -EINVAL; base = ioremap(r->start, 0x1000); @@ -237,18 +244,18 @@ static int goldfish_tty_probe(struct platform_device *pdev) pr_err("goldfish_tty: unable to remap base\n"); r = platform_get_resource(pdev, IORESOURCE_IRQ, 0); - if(r == NULL) + if (r == NULL) goto err_unmap; irq = r->start; - if(pdev->id >= goldfish_tty_line_count) + if (pdev->id >= goldfish_tty_line_count) goto err_unmap; mutex_lock(&goldfish_tty_lock); - if(goldfish_tty_current_line_count == 0) { + if (goldfish_tty_current_line_count == 0) { ret = goldfish_tty_create_driver(); - if(ret) + if (ret) goto err_create_driver_failed; } goldfish_tty_current_line_count++; @@ -262,14 +269,15 @@ static int goldfish_tty_probe(struct platform_device *pdev) writel(GOLDFISH_TTY_CMD_INT_DISABLE, base + GOLDFISH_TTY_CMD); - ret = request_irq(irq, goldfish_tty_interrupt, IRQF_SHARED, "goldfish_tty", pdev); - if(ret) + ret = request_irq(irq, goldfish_tty_interrupt, IRQF_SHARED, + "goldfish_tty", pdev); + if (ret) goto err_request_irq_failed; ttydev = tty_port_register_device(&qtty->port, goldfish_tty_driver, pdev->id, &pdev->dev); - if(IS_ERR(ttydev)) { + if (IS_ERR(ttydev)) { ret = PTR_ERR(ttydev); goto err_tty_register_device_failed; } @@ -290,7 +298,7 @@ err_tty_register_device_failed: free_irq(irq, pdev); err_request_irq_failed: goldfish_tty_current_line_count--; - if(goldfish_tty_current_line_count == 0) + if (goldfish_tty_current_line_count == 0) goldfish_tty_delete_driver(); err_create_driver_failed: mutex_unlock(&goldfish_tty_lock); @@ -312,7 +320,7 @@ static int goldfish_tty_remove(struct platform_device *pdev) qtty->base = 0; free_irq(qtty->irq, pdev); goldfish_tty_current_line_count--; - if(goldfish_tty_current_line_count == 0) + if (goldfish_tty_current_line_count == 0) goldfish_tty_delete_driver(); mutex_unlock(&goldfish_tty_lock); return 0; -- cgit v1.2.3 From a99698facdb92adebf4a4ed7691493b7e08ff5b6 Mon Sep 17 00:00:00 2001 From: Alan Date: Mon, 12 May 2014 16:57:22 +0100 Subject: goldfish: clean up the pipe driver 64bit ifdefs Use the 64bit helper method to scrub most of the ifdefs from the driver. The pipe reading has a funny case we can't scrub completely. Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/platform/goldfish/goldfish_pipe.c | 33 +++++++++++-------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c index 670b9b94f74b..c86180bba72e 100644 --- a/drivers/platform/goldfish/goldfish_pipe.c +++ b/drivers/platform/goldfish/goldfish_pipe.c @@ -56,6 +56,7 @@ #include #include #include +#include /* * IMPORTANT: The following constants must match the ones used and defined @@ -66,14 +67,10 @@ #define PIPE_REG_COMMAND 0x00 /* write: value = command */ #define PIPE_REG_STATUS 0x04 /* read */ #define PIPE_REG_CHANNEL 0x08 /* read/write: channel id */ -#ifdef CONFIG_64BIT #define PIPE_REG_CHANNEL_HIGH 0x30 /* read/write: channel id */ -#endif #define PIPE_REG_SIZE 0x0c /* read/write: buffer size */ #define PIPE_REG_ADDRESS 0x10 /* write: physical address */ -#ifdef CONFIG_64BIT #define PIPE_REG_ADDRESS_HIGH 0x34 /* write: physical address */ -#endif #define PIPE_REG_WAKES 0x14 /* read: wake flags */ #define PIPE_REG_PARAMS_ADDR_LOW 0x18 /* read/write: batch data address */ #define PIPE_REG_PARAMS_ADDR_HIGH 0x1c /* read/write: batch data address */ @@ -155,16 +152,14 @@ enum { static u32 goldfish_cmd_status(struct goldfish_pipe *pipe, u32 cmd) -{ +{ unsigned long flags; u32 status; struct goldfish_pipe_dev *dev = pipe->dev; spin_lock_irqsave(&dev->lock, flags); - writel((u32)(u64)pipe, dev->base + PIPE_REG_CHANNEL); -#ifdef CONFIG_64BIT - writel((u32)((u64)pipe >> 32), dev->base + PIPE_REG_CHANNEL_HIGH); -#endif + gf_write64((u64)pipe, dev->base + PIPE_REG_CHANNEL, + dev->base + PIPE_REG_CHANNEL_HIGH); writel(cmd, dev->base + PIPE_REG_COMMAND); status = readl(dev->base + PIPE_REG_STATUS); spin_unlock_irqrestore(&dev->lock, flags); @@ -172,15 +167,13 @@ static u32 goldfish_cmd_status(struct goldfish_pipe *pipe, u32 cmd) } static void goldfish_cmd(struct goldfish_pipe *pipe, u32 cmd) -{ +{ unsigned long flags; struct goldfish_pipe_dev *dev = pipe->dev; spin_lock_irqsave(&dev->lock, flags); - writel((u32)(u64)pipe, dev->base + PIPE_REG_CHANNEL); -#ifdef CONFIG_64BIT - writel((u32)((u64)pipe >> 32), dev->base + PIPE_REG_CHANNEL_HIGH); -#endif + gf_write64((u64)pipe, dev->base + PIPE_REG_CHANNEL, + dev->base + PIPE_REG_CHANNEL_HIGH); writel(cmd, dev->base + PIPE_REG_COMMAND); spin_unlock_irqrestore(&dev->lock, flags); } @@ -334,15 +327,11 @@ static ssize_t goldfish_pipe_read_write(struct file *filp, char __user *buffer, spin_lock_irqsave(&dev->lock, irq_flags); if (access_with_param(dev, CMD_WRITE_BUFFER + cmd_offset, address, avail, pipe, &status)) { - writel((u32)(u64)pipe, dev->base + PIPE_REG_CHANNEL); -#ifdef CONFIG_64BIT - writel((u32)((u64)pipe >> 32), dev->base + PIPE_REG_CHANNEL_HIGH); -#endif + gf_write64((u64)pipe, dev->base + PIPE_REG_CHANNEL, + dev->base + PIPE_REG_CHANNEL_HIGH); writel(avail, dev->base + PIPE_REG_SIZE); - writel(address, dev->base + PIPE_REG_ADDRESS); -#ifdef CONFIG_64BIT - writel((u32)((u64)address >> 32), dev->base + PIPE_REG_ADDRESS_HIGH); -#endif + gf_write64(address, dev->base + PIPE_REG_ADDRESS, + dev->base + PIPE_REG_ADDRESS_HIGH); writel(CMD_WRITE_BUFFER + cmd_offset, dev->base + PIPE_REG_COMMAND); status = readl(dev->base + PIPE_REG_STATUS); -- cgit v1.2.3 From 91ed9a7cddf1130af3a3aef0325d6e6d08eaffb2 Mon Sep 17 00:00:00 2001 From: Nicolas Del Piano Date: Fri, 25 Apr 2014 14:36:56 -0300 Subject: Staging: vt6655: tether: fixed a brace coding style issue Fixed a coding style issue. Signed-off-by: Nicolas Del Piano Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/tether.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vt6655/tether.c b/drivers/staging/vt6655/tether.c index a5dc3c09cfd7..1e7d3e2115a9 100644 --- a/drivers/staging/vt6655/tether.c +++ b/drivers/staging/vt6655/tether.c @@ -98,8 +98,8 @@ bool ETHbIsBufferCrc32Ok(unsigned char *pbyBuffer, unsigned int cbFrameLength) unsigned long dwCRC; dwCRC = CRCdwGetCrc32(pbyBuffer, cbFrameLength - 4); - if (cpu_to_le32(*((unsigned long *)(pbyBuffer + cbFrameLength - 4))) != dwCRC) { + if (cpu_to_le32(*((unsigned long *)(pbyBuffer + cbFrameLength - 4))) != dwCRC) return false; - } + return true; } -- cgit v1.2.3 From 34bdb981f7cb446259b0999d40f090c16f732eca Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Fri, 25 Apr 2014 15:39:12 +0200 Subject: staging: vt6656: Remove unnecesssary NULL check pFifoHead points to tx_buffer->fifo_head which can never be NULL. We also don't need to check for tx_buffer being NULL instead, since it always points to ->Data of struct vnt_usb_send_context - the pointer to which was checked before calling s_vGenerateTxParameter(). Silences a dereference before NULL check warning reported by the coverity scanner in CID 1127221. Cc: Dan Carpenter Signed-off-by: Tobias Klauser Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 1ff14469df99..abd1a26ce417 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -813,9 +813,6 @@ static u16 s_vGenerateTxParameter(struct vnt_private *pDevice, else if (wFifoCtl & FIFOCTL_AUTO_FB_1) byFBOption = AUTO_FB_1; - if (!pFifoHead) - return 0; - if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { if (need_rts) { struct vnt_rrv_time_rts *pBuf = -- cgit v1.2.3 From 838c2d6cfc0c2dc8ce136e01e681fc6cf4124c39 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Fri, 25 Apr 2014 11:53:58 +0200 Subject: staging: vt6656: Use proper target pointer in memcpy() The coverity scanner marked these two memcpy()'s as causing a buffer overflow in CIDs 142743 and 142744. This is due the h_dest member of struct ethhdr being used as a target (size ETH_ALEN) in memcpy, but the copy is of size ETH_HLEN. However, the intention here seems to be to copy the entire ethernet header. Make that clear by specifying the proper destination buffer. Also remove the unnecessary casts of the source argument. Signed-off-by: Tobias Klauser Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index abd1a26ce417..28f40e6bd262 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -2183,7 +2183,7 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, return STATUS_RESOURCES; } - memcpy(pDevice->sTxEthHeader.h_dest, (u8 *)(skb->data), ETH_HLEN); + memcpy(&pDevice->sTxEthHeader, skb->data, ETH_HLEN); //mike add:station mode check eapol-key challenge---> { @@ -2506,7 +2506,7 @@ int bRelayPacketSend(struct vnt_private *pDevice, u8 *pbySkbData, u32 uDataLen, return false; } - memcpy(pDevice->sTxEthHeader.h_dest, (u8 *)pbySkbData, ETH_HLEN); + memcpy(&pDevice->sTxEthHeader, pbySkbData, ETH_HLEN); if (pDevice->bEncryptionEnable == true) { bNeedEncryption = true; -- cgit v1.2.3 From 4e8a7e5fc29697f881f5c358f84df52914908703 Mon Sep 17 00:00:00 2001 From: Guido Martínez Date: Sat, 19 Apr 2014 16:44:59 -0300 Subject: staging: vt6655: remove dead code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove dead code in many places on this driver. Signed-off-by: Guido Martínez Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/IEEE11h.c | 6 - drivers/staging/vt6655/baseband.c | 17 --- drivers/staging/vt6655/bssdb.h | 2 - drivers/staging/vt6655/card.c | 38 +----- drivers/staging/vt6655/card.h | 1 - drivers/staging/vt6655/channel.c | 3 - drivers/staging/vt6655/datarate.c | 8 +- drivers/staging/vt6655/desc.h | 47 ------- drivers/staging/vt6655/device.h | 6 - drivers/staging/vt6655/device_main.c | 164 ++-------------------- drivers/staging/vt6655/dpc.c | 76 +---------- drivers/staging/vt6655/hostap.c | 47 ------- drivers/staging/vt6655/ioctl.c | 1 - drivers/staging/vt6655/ioctl.h | 9 -- drivers/staging/vt6655/iowpa.h | 7 - drivers/staging/vt6655/iwctl.c | 255 +---------------------------------- drivers/staging/vt6655/key.c | 6 - drivers/staging/vt6655/key.h | 2 - drivers/staging/vt6655/mac.c | 8 -- drivers/staging/vt6655/mac.h | 1 - drivers/staging/vt6655/mib.c | 3 - drivers/staging/vt6655/mib.h | 8 -- drivers/staging/vt6655/michael.c | 29 +--- drivers/staging/vt6655/power.c | 16 +-- drivers/staging/vt6655/power.h | 3 - drivers/staging/vt6655/rf.c | 18 +-- drivers/staging/vt6655/rxtx.c | 72 +--------- drivers/staging/vt6655/rxtx.h | 11 -- drivers/staging/vt6655/tkip.c | 1 - drivers/staging/vt6655/vntwifi.c | 47 +------ drivers/staging/vt6655/vntwifi.h | 14 -- drivers/staging/vt6655/wcmd.c | 29 +--- drivers/staging/vt6655/wctl.c | 6 +- drivers/staging/vt6655/wmgr.c | 103 +------------- drivers/staging/vt6655/wmgr.h | 30 ----- drivers/staging/vt6655/wpa.c | 8 +- drivers/staging/vt6655/wpa2.c | 1 - drivers/staging/vt6655/wpactl.c | 48 +------ drivers/staging/vt6655/wroute.c | 1 - 39 files changed, 51 insertions(+), 1101 deletions(-) diff --git a/drivers/staging/vt6655/IEEE11h.c b/drivers/staging/vt6655/IEEE11h.c index dfda3c82906c..6cfad1c04026 100644 --- a/drivers/staging/vt6655/IEEE11h.c +++ b/drivers/staging/vt6655/IEEE11h.c @@ -192,8 +192,6 @@ static bool s_bRxTPCReq(PSMgmtObject pMgmt, if (csMgmt_xmit(pMgmt->pAdapter, pTxPacket) != CMD_STATUS_PENDING) return false; return true; -/* return CARDbSendPacket(pMgmt->pAdapter, pFrame, PKT_TYPE_802_11_MNG, - sizeof(WLAN_FRAME_TPCREP)); */ } /*--------------------- Export Variables --------------------------*/ @@ -274,8 +272,6 @@ IEEE11hbMgrRxAction(void *pMgmtHandle, void *pRxPacket) pAction->byCategory); pAction->byCategory |= 0x80; - /*return CARDbSendPacket(pMgmt->pAdapter, pAction, PKT_TYPE_802_11_MNG, - uLength);*/ return true; } return true; @@ -317,6 +313,4 @@ bool IEEE11hbMSRRepTx(void *pMgmtHandle) if (csMgmt_xmit(pMgmt->pAdapter, pTxPacket) != CMD_STATUS_PENDING) return false; return true; -/* return CARDbSendPacket(pMgmt->pAdapter, pMSRRep, PKT_TYPE_802_11_MNG, - uLength); */ } diff --git a/drivers/staging/vt6655/baseband.c b/drivers/staging/vt6655/baseband.c index fa14659ba43c..9c0d8ee6084f 100644 --- a/drivers/staging/vt6655/baseband.c +++ b/drivers/staging/vt6655/baseband.c @@ -1095,7 +1095,6 @@ unsigned char byVT3253B0_AIROHA2230[CB_VT3253B0_INIT_FOR_AIROHA2230][2] = { {0x69, 0x00}, {0x6a, 0x00}, {0x6b, 0x00}, - //{0x6c, 0x80}, {0x6c, 0x00}, //RobertYu:20050125, request by JJSue {0x6d, 0x03}, {0x6e, 0x01}, @@ -1357,7 +1356,6 @@ unsigned char byVT3253B0_UW2451[CB_VT3253B0_INIT_FOR_UW2451][2] = { {0x69, 0x00}, {0x6a, 0x00}, {0x6b, 0x00}, - //{0x6c, 0x80}, {0x6c, 0x00}, //RobertYu:20050125, request by JJSue {0x6d, 0x03}, {0x6e, 0x01}, @@ -2208,8 +2206,6 @@ bool BBbVT3253Init(PSDevice pDevice) for (ii = 0; ii < CB_VT3253B0_AGC; ii++) { bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]); } - //VNSvOutPortB(dwIoBase + MAC_REG_ITRTMSET, 0x23); // RobertYu: 20050104, 20050131 disable PA_Delay - //MACvRegBitsOn(dwIoBase, MAC_REG_PAPEDELAY, BIT0); // RobertYu: 20050104, 20050131 disable PA_Delay pDevice->abyBBVGA[0] = 0x14; pDevice->abyBBVGA[1] = 0x0A; @@ -2613,13 +2609,11 @@ s_ulGetRatio(PSDevice pDevice) if (pDevice->uNumSQ3[RATE_54M] != 0) { ulPacketNum = pDevice->uNumSQ3[RATE_54M]; ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); - //ulRatio = (pDevice->uNumSQ3[RATE_54M] * 1000 / pDevice->uDiversityCnt); ulRatio += TOP_RATE_54M; } if (pDevice->uNumSQ3[RATE_48M] > ulMaxPacket) { ulPacketNum = pDevice->uNumSQ3[RATE_54M] + pDevice->uNumSQ3[RATE_48M]; ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); - //ulRatio = (pDevice->uNumSQ3[RATE_48M] * 1000 / pDevice->uDiversityCnt); ulRatio += TOP_RATE_48M; ulMaxPacket = pDevice->uNumSQ3[RATE_48M]; } @@ -2627,7 +2621,6 @@ s_ulGetRatio(PSDevice pDevice) ulPacketNum = pDevice->uNumSQ3[RATE_54M] + pDevice->uNumSQ3[RATE_48M] + pDevice->uNumSQ3[RATE_36M]; ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); - //ulRatio = (pDevice->uNumSQ3[RATE_36M] * 1000 / pDevice->uDiversityCnt); ulRatio += TOP_RATE_36M; ulMaxPacket = pDevice->uNumSQ3[RATE_36M]; } @@ -2635,7 +2628,6 @@ s_ulGetRatio(PSDevice pDevice) ulPacketNum = pDevice->uNumSQ3[RATE_54M] + pDevice->uNumSQ3[RATE_48M] + pDevice->uNumSQ3[RATE_36M] + pDevice->uNumSQ3[RATE_24M]; ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); - //ulRatio = (pDevice->uNumSQ3[RATE_24M] * 1000 / pDevice->uDiversityCnt); ulRatio += TOP_RATE_24M; ulMaxPacket = pDevice->uNumSQ3[RATE_24M]; } @@ -2644,7 +2636,6 @@ s_ulGetRatio(PSDevice pDevice) pDevice->uNumSQ3[RATE_36M] + pDevice->uNumSQ3[RATE_24M] + pDevice->uNumSQ3[RATE_18M]; ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); - //ulRatio = (pDevice->uNumSQ3[RATE_18M] * 1000 / pDevice->uDiversityCnt); ulRatio += TOP_RATE_18M; ulMaxPacket = pDevice->uNumSQ3[RATE_18M]; } @@ -2653,7 +2644,6 @@ s_ulGetRatio(PSDevice pDevice) pDevice->uNumSQ3[RATE_36M] + pDevice->uNumSQ3[RATE_24M] + pDevice->uNumSQ3[RATE_18M] + pDevice->uNumSQ3[RATE_12M]; ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); - //ulRatio = (pDevice->uNumSQ3[RATE_12M] * 1000 / pDevice->uDiversityCnt); ulRatio += TOP_RATE_12M; ulMaxPacket = pDevice->uNumSQ3[RATE_12M]; } @@ -2662,7 +2652,6 @@ s_ulGetRatio(PSDevice pDevice) pDevice->uNumSQ3[RATE_2M] - pDevice->uNumSQ3[RATE_5M] - pDevice->uNumSQ3[RATE_6M] - pDevice->uNumSQ3[RATE_9M]; ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); - //ulRatio = (pDevice->uNumSQ3[RATE_11M] * 1000 / pDevice->uDiversityCnt); ulRatio += TOP_RATE_11M; ulMaxPacket = pDevice->uNumSQ3[RATE_11M]; } @@ -2671,7 +2660,6 @@ s_ulGetRatio(PSDevice pDevice) pDevice->uNumSQ3[RATE_2M] - pDevice->uNumSQ3[RATE_5M] - pDevice->uNumSQ3[RATE_6M]; ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); - //ulRatio = (pDevice->uNumSQ3[RATE_9M] * 1000 / pDevice->uDiversityCnt); ulRatio += TOP_RATE_9M; ulMaxPacket = pDevice->uNumSQ3[RATE_9M]; } @@ -2679,7 +2667,6 @@ s_ulGetRatio(PSDevice pDevice) ulPacketNum = pDevice->uDiversityCnt - pDevice->uNumSQ3[RATE_1M] - pDevice->uNumSQ3[RATE_2M] - pDevice->uNumSQ3[RATE_5M]; ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); - //ulRatio = (pDevice->uNumSQ3[RATE_6M] * 1000 / pDevice->uDiversityCnt); ulRatio += TOP_RATE_6M; ulMaxPacket = pDevice->uNumSQ3[RATE_6M]; } @@ -2687,21 +2674,18 @@ s_ulGetRatio(PSDevice pDevice) ulPacketNum = pDevice->uDiversityCnt - pDevice->uNumSQ3[RATE_1M] - pDevice->uNumSQ3[RATE_2M]; ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); - //ulRatio = (pDevice->uNumSQ3[RATE_5M] * 1000 / pDevice->uDiversityCnt); ulRatio += TOP_RATE_55M; ulMaxPacket = pDevice->uNumSQ3[RATE_5M]; } if (pDevice->uNumSQ3[RATE_2M] > ulMaxPacket) { ulPacketNum = pDevice->uDiversityCnt - pDevice->uNumSQ3[RATE_1M]; ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); - //ulRatio = (pDevice->uNumSQ3[RATE_2M] * 1000 / pDevice->uDiversityCnt); ulRatio += TOP_RATE_2M; ulMaxPacket = pDevice->uNumSQ3[RATE_2M]; } if (pDevice->uNumSQ3[RATE_1M] > ulMaxPacket) { ulPacketNum = pDevice->uDiversityCnt; ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); - //ulRatio = (pDevice->uNumSQ3[RATE_1M] * 1000 / pDevice->uDiversityCnt); ulRatio += TOP_RATE_1M; } @@ -2741,7 +2725,6 @@ BBvAntennaDiversity(PSDevice pDevice, unsigned char byRxRate, unsigned char bySQ return; } pDevice->uDiversityCnt++; - // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->uDiversityCnt = %d\n", (int)pDevice->uDiversityCnt); pDevice->uNumSQ3[byRxRate]++; diff --git a/drivers/staging/vt6655/bssdb.h b/drivers/staging/vt6655/bssdb.h index 5c77677251ed..a0938b7dd082 100644 --- a/drivers/staging/vt6655/bssdb.h +++ b/drivers/staging/vt6655/bssdb.h @@ -112,7 +112,6 @@ typedef struct tagKnownBSS { unsigned char abySSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; unsigned char byRxRate; -// unsigned short wATIMWindow; unsigned char byRSSIStatCnt; long ldBmMAX; long ldBmAverage[RSSI_STAT_COUNT]; @@ -147,7 +146,6 @@ typedef struct tagKnownBSS { // Clear count unsigned int uClearCount; -// unsigned char abyIEs[WLAN_BEACON_FR_MAXLEN]; unsigned int uIELength; QWORD qwBSSTimestamp; QWORD qwLocalTSF; // local TSF timer diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index e7227954f2fe..702d4eb13583 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -59,7 +59,6 @@ /*--------------------- Static Definitions -------------------------*/ -//static int msglevel =MSG_LEVEL_DEBUG; static int msglevel = MSG_LEVEL_INFO; #define C_SIFS_A 16 // micro sec. @@ -337,36 +336,6 @@ s_vSetRSPINF(PSDevice pDevice, CARD_PHY_TYPE ePHYType, void *pvSupportRateIEs, v /*--------------------- Export Functions --------------------------*/ -/* - * Description: Card Send packet function - * - * Parameters: - * In: - * pDeviceHandler - The adapter to be set - * pPacket - Packet buffer pointer - * ePktType - Packet type - * uLength - Packet length - * Out: - * none - * - * Return Value: true if succeeded; false if failed. - * - */ -/* - bool CARDbSendPacket (void *pDeviceHandler, void *pPacket, CARD_PKT_TYPE ePktType, unsigned int uLength) { - PSDevice pDevice = (PSDevice) pDeviceHandler; - if (ePktType == PKT_TYPE_802_11_MNG) { - return TXbTD0Send(pDevice, pPacket, uLength); - } else if (ePktType == PKT_TYPE_802_11_BCN) { - return TXbBeaconSend(pDevice, pPacket, uLength); - } if (ePktType == PKT_TYPE_802_11_DATA) { - return TXbTD1Send(pDevice, pPacket, uLength); - } - - return true; - } -*/ - /* * Description: Get Card short preamble option value * @@ -426,7 +395,6 @@ bool CARDbSetPhyParameter(void *pDeviceHandler, CARD_PHY_TYPE ePHYType, unsigned unsigned char bySIFS = 0; unsigned char byDIFS = 0; unsigned char byData; -// PWLAN_IE_SUPP_RATES pRates = NULL; PWLAN_IE_SUPP_RATES pSupportRates = (PWLAN_IE_SUPP_RATES) pvSupportRateIEs; PWLAN_IE_SUPP_RATES pExtSupportRates = (PWLAN_IE_SUPP_RATES) pvExtSupportRateIEs; @@ -1301,8 +1269,6 @@ CARDbSetQuiet( if (pDevice->byQuietStartCount < byQuietCount) { pDevice->byQuietStartCount = byQuietCount; } - } else { - // we can not handle Quiet EID more } return true; } @@ -2060,8 +2026,6 @@ QWORD CARDqGetNextTBTT(QWORD qwTSF, unsigned short wBeaconInterval) uLowNextTBTT = (LODWORD(qwTSF) >> 10) << 10; // low dword (mod) bcn uLowRemain = (uLowNextTBTT) % uBeaconInterval; -// uHighRemain = ((0x80000000 % uBeaconInterval)* 2 * HIDWORD(qwTSF)) -// % uBeaconInterval; // high dword (mod) bcn uHighRemain = (((0xffffffff % uBeaconInterval) + 1) * HIDWORD(qwTSF)) % uBeaconInterval; @@ -2103,7 +2067,7 @@ void CARDvSetFirstNextTBTT(unsigned long dwIoBase, unsigned short wBeaconInterva VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT, LODWORD(qwNextTBTT)); VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT + 4, HIDWORD(qwNextTBTT)); MACvRegBitsOn(dwIoBase, MAC_REG_TFTCTL, TFTCTL_TBTTSYNCEN); - //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Card:First Next TBTT[%8xh:%8xh] \n", HIDWORD(qwNextTBTT), LODWORD(qwNextTBTT)); + return; } diff --git a/drivers/staging/vt6655/card.h b/drivers/staging/vt6655/card.h index ac6e2b4d0fd0..829be92838b0 100644 --- a/drivers/staging/vt6655/card.h +++ b/drivers/staging/vt6655/card.h @@ -104,7 +104,6 @@ void CARDvSafeResetRx(void *pDeviceHandler); //xxx bool CARDbRadioPowerOff(void *pDeviceHandler); bool CARDbRadioPowerOn(void *pDeviceHandler); -//bool CARDbSendPacket(void *pDeviceHandler, void *pPacket, CARD_PKT_TYPE ePktType, unsigned int uLength); bool CARDbIsShortPreamble(void *pDeviceHandler); bool CARDbIsShorSlotTime(void *pDeviceHandler); bool CARDbSetPhyParameter(void *pDeviceHandler, CARD_PHY_TYPE ePHYType, unsigned short wCapInfo, unsigned char byERPField, void *pvSupportRateIEs, void *pvExtSupportRateIEs); diff --git a/drivers/staging/vt6655/channel.c b/drivers/staging/vt6655/channel.c index 3198a31e2ed7..e69c312d1242 100644 --- a/drivers/staging/vt6655/channel.c +++ b/drivers/staging/vt6655/channel.c @@ -30,7 +30,6 @@ #define CARD_MAX_CHANNEL_TBL 56 -//static int msglevel = MSG_LEVEL_DEBUG; static int msglevel = MSG_LEVEL_INFO; /*--------------------- Static Variables --------------------------*/ @@ -509,7 +508,6 @@ unsigned char get_channel_mapping(void *pDeviceHandler, unsigned char byChannelN unsigned char get_channel_number(void *pDeviceHandler, unsigned char byChannelIndex) { - //PSDevice pDevice = (PSDevice) pDeviceHandler; return sChannelTbl[byChannelIndex].byChannelNumber; } @@ -560,7 +558,6 @@ bool set_channel(void *pDeviceHandler, unsigned int uConnectionChannel) if (pDevice->bEnablePSMode) RFvWriteWakeProgSyn(pDevice->PortOffset, pDevice->byRFType, uConnectionChannel); - //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "CARDbSetMediaChannel: %d\n", (unsigned char)uConnectionChannel); BBvSoftwareReset(pDevice->PortOffset); if (pDevice->byLocalID > REV_ID_VT3253_B1) { diff --git a/drivers/staging/vt6655/datarate.c b/drivers/staging/vt6655/datarate.c index 2d760da626bb..2db662471219 100644 --- a/drivers/staging/vt6655/datarate.c +++ b/drivers/staging/vt6655/datarate.c @@ -49,7 +49,6 @@ extern unsigned short TxRate_iwconfig; //2008-5-8 by chester /*--------------------- Static Variables --------------------------*/ -//static int msglevel =MSG_LEVEL_DEBUG; static int msglevel = MSG_LEVEL_INFO; static const unsigned char acbyIERate[MAX_RATE] = {0x02, 0x04, 0x0B, 0x16, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C}; @@ -251,9 +250,8 @@ RATEvParseMaxRate( if (byRate > byHighSuppRate) byHighSuppRate = byRate; *pwSuppRate |= (1<byPacketType == PK_TYPE_11GB) && CARDbIsOFDMinBasicRate((void *)pDevice)) { pDevice->byPacketType = PK_TYPE_11GA; @@ -299,7 +297,6 @@ RATEvTxRateFallBack( PSDevice pDevice = (PSDevice) pDeviceHandler; unsigned short wIdxDownRate = 0; unsigned int ii; -//unsigned long dwRateTable[MAX_RATE] = {1, 2, 5, 11, 6, 9, 12, 18, 24, 36, 48, 54}; bool bAutoRate[MAX_RATE] = {true, true, true, true, false, false, true, true, true, true, true, true}; unsigned long dwThroughputTbl[MAX_RATE] = {10, 20, 55, 110, 60, 90, 120, 180, 240, 360, 480, 540}; unsigned long dwThroughput = 0; @@ -345,8 +342,6 @@ RATEvTxRateFallBack( } dwThroughputTbl[ii] /= (psNodeDBTable->uTxOk[ii] + psNodeDBTable->uTxFail[ii]); } -// DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Rate %d,Ok: %d, Fail:%d, Throughput:%d\n", -// ii, psNodeDBTable->uTxOk[ii], psNodeDBTable->uTxFail[ii], dwThroughputTbl[ii]); } dwThroughput = dwThroughputTbl[psNodeDBTable->wTxDataRate]; @@ -371,7 +366,6 @@ RATEvTxRateFallBack( //2008-5-8 by chester TxRate_iwconfig = psNodeDBTable->wTxDataRate; s_vResetCounter(psNodeDBTable); -// DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Rate: %d, U:%d, D:%d\n", psNodeDBTable->wTxDataRate, wIdxUpRate, wIdxDownRate); return; } diff --git a/drivers/staging/vt6655/desc.h b/drivers/staging/vt6655/desc.h index f8e41487f856..c620cbfbaadf 100644 --- a/drivers/staging/vt6655/desc.h +++ b/drivers/staging/vt6655/desc.h @@ -213,29 +213,6 @@ typedef struct tagDEVICE_RD_INFO { dma_addr_t curr_desc; } DEVICE_RD_INFO, *PDEVICE_RD_INFO; -/* - static inline PDEVICE_RD_INFO alloc_rd_info(void) { - PDEVICE_RD_INFO ptr; - ptr = kmalloc(sizeof(DEVICE_RD_INFO), GFP_ATOMIC); - if (ptr == NULL) - return NULL; - else { - memset(ptr,0,sizeof(DEVICE_RD_INFO)); - return ptr; - } - } -*/ - -/* - typedef struct tagRDES0 { - unsigned short wResCount; - unsigned short wf1Owner; -// unsigned short f15Reserved : 15; -// unsigned short f1Owner : 1; -} __attribute__ ((__packed__)) -SRDES0; -*/ - #ifdef __BIG_ENDIAN typedef struct tagRDES0 { @@ -284,17 +261,6 @@ typedef const SRxDesc *PCSRxDesc; #ifdef __BIG_ENDIAN -/* - typedef struct tagTDES0 { - volatile unsigned char byTSR0; - volatile unsigned char byTSR1; - volatile unsigned short wOwner_Txtime; -// volatile unsigned short f15Txtime : 15; -// volatile unsigned short f1Owner:1; -} __attribute__ ((__packed__)) -STDES0; -*/ - typedef struct tagTDES0 { volatile unsigned char byTSR0; volatile unsigned char byTSR1; @@ -339,19 +305,6 @@ typedef struct tagDEVICE_TD_INFO { unsigned char byFlags; } DEVICE_TD_INFO, *PDEVICE_TD_INFO; -/* - static inline PDEVICE_TD_INFO alloc_td_info(void) { - PDEVICE_TD_INFO ptr; - ptr = kmalloc(sizeof(DEVICE_TD_INFO),GFP_ATOMIC); - if (ptr == NULL) - return NULL; - else { - memset(ptr,0,sizeof(DEVICE_TD_INFO)); - return ptr; - } - } -*/ - // // transmit descriptor // diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 985c3c19a4a7..45fc8a0b9b5c 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -750,12 +750,6 @@ typedef struct __device_info { bool bWPADEVUp; struct sk_buff *skb; #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT -/* - bool bwextstep0; - bool bwextstep1; - bool bwextstep2; - bool bwextstep3; -*/ unsigned int bwextcount; bool bWPASuppWextEnabled; #endif diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index a952df1bf9d6..024d84082d76 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -89,7 +89,6 @@ #include /*--------------------- Static Definitions -------------------------*/ -//static int msglevel =MSG_LEVEL_DEBUG; static int msglevel = MSG_LEVEL_INFO; // @@ -100,14 +99,8 @@ MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("VIA Networking Solomon-A/B/G Wireless LAN Adapter Driver"); static int mlme_kill; -//static struct task_struct * mlme_task; #define DEVICE_PARAM(N, D) -/* - static const int N[MAX_UINTS]=OPTION_DEFAULT;\ - MODULE_PARM(N, "1-" __MODULE_STRING(MAX_UINTS) "i");\ - MODULE_PARM_DESC(N, D); -*/ #define RX_DESC_MIN0 16 #define RX_DESC_MAX0 128 @@ -346,38 +339,6 @@ static void vt6655_remove(struct pci_dev *pcid) device_free_info(pDevice); } -/* - static void - device_set_int_opt(int *opt, int val, int min, int max, int def,char* name,char* devname) { - if (val==-1) - *opt=def; - else if (valmax) { - DBG_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: the value of parameter %s is invalid, the valid range is (%d-%d)\n" , - devname,name, min,max); - *opt=def; - } else { - DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "%s: set value of parameter %s to %d\n", - devname, name, val); - *opt=val; - } - } - - static void - device_set_bool_opt(unsigned int *opt, int val,bool def,u32 flag, char* name,char* devname) { - (*opt)&=(~flag); - if (val==-1) - *opt|=(def ? flag : 0); - else if (val<0 || val>1) { - DBG_PRT(MSG_LEVEL_INFO, KERN_NOTICE - "%s: the value of parameter %s is invalid, the valid range is (0-1)\n",devname,name); - *opt|=(def ? flag : 0); - } else { - DBG_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: set parameter %s to %s\n", - devname,name , val ? "true" : "false"); - *opt|=(val ? flag : 0); - } - } -*/ static void device_get_options(PSDevice pDevice, int index, char *devname) { POPTIONS pOpts = &(pDevice->sOpts); @@ -395,7 +356,6 @@ static void device_get_options(PSDevice pDevice, int index, char *devname) pOpts->flags |= DEVICE_FLAGS_PREAMBLE_TYPE; pOpts->flags |= DEVICE_FLAGS_OP_MODE; - //pOpts->flags|=DEVICE_FLAGS_PS_MODE; pOpts->short_retry = SHORT_RETRY_DEF; pOpts->long_retry = LONG_RETRY_DEF; pOpts->bbp_type = BBP_TYPE_DEF; @@ -431,7 +391,6 @@ device_set_options(PSDevice pDevice) { //PLICE_DEBUG-> pDevice->byAutoFBCtrl = AUTO_FB_0; - //pDevice->byAutoFBCtrl = AUTO_FB_1; //PLICE_DEBUG<- pDevice->bUpdateBBVGA = true; pDevice->byFOETuning = 0; @@ -549,12 +508,12 @@ static void device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) if (byValue == 0) // if not set default is All byValue = (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN); - pDevice->ulDiversityNValue = 100*260;//100*SROMbyReadEmbedded(pDevice->PortOffset, 0x51); - pDevice->ulDiversityMValue = 100*16;//SROMbyReadEmbedded(pDevice->PortOffset, 0x52); - pDevice->byTMax = 1;//SROMbyReadEmbedded(pDevice->PortOffset, 0x53); - pDevice->byTMax2 = 4;//SROMbyReadEmbedded(pDevice->PortOffset, 0x54); - pDevice->ulSQ3TH = 0;//(unsigned long) SROMbyReadEmbedded(pDevice->PortOffset, 0x55); - pDevice->byTMax3 = 64;//SROMbyReadEmbedded(pDevice->PortOffset, 0x56); + pDevice->ulDiversityNValue = 100*260; + pDevice->ulDiversityMValue = 100*16; + pDevice->byTMax = 1; + pDevice->byTMax2 = 4; + pDevice->ulSQ3TH = 0; + pDevice->byTMax3 = 64; if (byValue == (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN)) { pDevice->byAntennaCount = 2; @@ -568,7 +527,7 @@ static void device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) // chester for antenna byValue1 = SROMbyReadEmbedded(pDevice->PortOffset, EEP_OFS_ANTENNA); if ((byValue1 & 0x08) == 0) - pDevice->bDiversityEnable = false;//SROMbyReadEmbedded(pDevice->PortOffset, 0x50); + pDevice->bDiversityEnable = false; else pDevice->bDiversityEnable = true; } else { @@ -593,7 +552,6 @@ static void device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "bDiversityEnable=[%d],NValue=[%d],MValue=[%d],TMax=[%d],TMax2=[%d]\n", pDevice->bDiversityEnable, (int)pDevice->ulDiversityNValue, (int)pDevice->ulDiversityMValue, pDevice->byTMax, pDevice->byTMax2); -//#ifdef ZoneType_DefaultSetting //2008-8-4 by chester //zonetype initial pDevice->byOriginalZonetype = pDevice->abyEEPROM[EEP_OFS_ZONETYPE]; @@ -647,9 +605,6 @@ static void device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) pDevice->byCurPwr = 0xFF; pDevice->byCCKPwr = SROMbyReadEmbedded(pDevice->PortOffset, EEP_OFS_PWR_CCK); pDevice->byOFDMPwrG = SROMbyReadEmbedded(pDevice->PortOffset, EEP_OFS_PWR_OFDMG); - //byCCKPwrdBm = SROMbyReadEmbedded(pDevice->PortOffset, EEP_OFS_CCK_PWR_dBm); - - //byOFDMPwrdBm = SROMbyReadEmbedded(pDevice->PortOffset, EEP_OFS_OFDM_PWR_dBm); // Load power Table @@ -715,7 +670,6 @@ static void device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) pDevice->byCurrentCh = 0; - //pDevice->NetworkType = Ndis802_11Automode; // Set BB and packet type at the same time. // Set Short Slot Time, xIFS, and RSPINF. if (pDevice->uConnectionRate == RATE_AUTO) { @@ -807,7 +761,7 @@ static bool device_release_WPADEV(PSDevice pDevice) { viawget_wpa_header *wpahdr; int ii = 0; - // wait_queue_head_t Set_wait; + //send device close to wpa_supplicnat layer if (pDevice->bWPADEVUp) { wpahdr = (viawget_wpa_header *)pDevice->skb->data; @@ -823,9 +777,6 @@ static bool device_release_WPADEV(PSDevice pDevice) netif_rx(pDevice->skb); pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz); - //wait release WPADEV - // init_waitqueue_head(&Set_wait); - // wait_event_timeout(Set_wait, ((pDevice->wpadev==NULL)&&(pDevice->skb == NULL)),5*HZ); //1s wait while (pDevice->bWPADEVUp) { set_current_state(TASK_UNINTERRUPTIBLE); schedule_timeout(HZ / 20); //wait 50ms @@ -869,7 +820,6 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent) } // Chain it all together - // SET_MODULE_OWNER(dev); SET_NETDEV_DEV(dev, &pcid->dev); if (bFirst) { @@ -902,7 +852,6 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent) #ifdef DEBUG - //pci_read_config_byte(pcid, PCI_BASE_ADDRESS_0, &pDevice->byRevId); printk("after get pci_info memaddr is %x, io addr is %x,io_size is %d\n", pDevice->memaddr, pDevice->ioaddr, pDevice->io_size); { int i; @@ -916,7 +865,6 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent) PCI_BASE_ADDRESS_5, 0}; for (i = 0; address[i]; i++) { - //pci_write_config_dword(pcid,address[i], 0xFFFFFFFF); pci_read_config_dword(pcid, address[i], &bar); printk("bar %d is %x\n", i, bar); if (!bar) { @@ -942,11 +890,7 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent) #endif -#ifdef DEBUG - //return 0; -#endif pDevice->PortOffset = (unsigned long)ioremap(pDevice->memaddr & PCI_BASE_ADDRESS_MEM_MASK, pDevice->io_size); - //pDevice->PortOffset = (unsigned long)ioremap(pDevice->ioaddr & PCI_BASE_ADDRESS_IO_MASK, pDevice->io_size); if (pDevice->PortOffset == 0) { printk(KERN_ERR DEVICE_NAME ": Failed to IO remapping ..\n"); @@ -967,7 +911,6 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent) VNSvInPortB(pDevice->PortOffset+0x4F, &value); printk("Before write: value is %x\n", value); - //VNSvInPortB(pDevice->PortOffset+0x3F, 0x00); VNSvOutPortB(pDevice->PortOffset, value); VNSvInPortB(pDevice->PortOffset+0x4F, &value); printk("After write: value is %x\n", value); @@ -1075,11 +1018,6 @@ static bool device_get_pci_info(PSDevice pDevice, struct pci_dev *pcid) { pDevice->memaddr = pci_resource_start(pcid, 0); pDevice->ioaddr = pci_resource_start(pcid, 1); -#ifdef DEBUG -// pDevice->ioaddr = pci_resource_start(pcid, 0); -// pDevice->memaddr = pci_resource_start(pcid,1); -#endif - cis_addr = pci_resource_start(pcid, 2); pDevice->pcid = pcid; @@ -1088,13 +1026,6 @@ static bool device_get_pci_info(PSDevice pDevice, struct pci_dev *pcid) { pci_write_config_byte(pcid, PCI_COMMAND, (b|PCI_COMMAND_MASTER)); #ifdef PLICE_DEBUG - //pci_read_config_word(pcid,PCI_MAX_LAT,&max_lat); - //for (ii=0;ii<0xFF;ii++) - //pci_read_config_word(pcid,PCI_MAX_LAT,&max_lat); - //max_lat = 0x20; - //pci_write_config_word(pcid,PCI_MAX_LAT,max_lat); - //pci_read_config_word(pcid,PCI_MAX_LAT,&max_lat); - for (ii = 0; ii < 0xFF; ii++) { pci_read_config_byte(pcid, ii, &value); pci_config[ii] = value; @@ -1468,7 +1399,6 @@ static int device_rx_srv(PSDevice pDevice, unsigned int uIdx) { for (pRD = pDevice->pCurrRD[uIdx]; pRD->m_rd0RD0.f1Owner == OWNED_BY_HOST; pRD = pRD->next) { -// DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->pCurrRD = %x, works = %d\n", pRD, works); if (works++ > 15) break; if (device_receive_frame(pDevice, pRD)) { @@ -1584,7 +1514,6 @@ static int device_tx_srv(PSDevice pDevice, unsigned int uIdx) { skb->dev = pDevice->apdev; skb_reset_mac_header(skb); skb->pkt_type = PACKET_OTHERHOST; - //skb->protocol = htons(ETH_P_802_2); memset(skb->cb, 0, sizeof(skb->cb)); netif_rx(skb); } @@ -1596,8 +1525,6 @@ static int device_tx_srv(PSDevice pDevice, unsigned int uIdx) { (int)uIdx, byTsr1, byTsr0); } -// DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Tx[%d] fail has error. tsr1[%02X] tsr0[%02X].\n", -// (int)uIdx, byTsr1, byTsr0); if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pTD->pTDInfo->byFlags & TD_FLAGS_NETIF_SKB)) { @@ -1689,33 +1616,22 @@ int MlmeThread( { PSDevice pDevice = (PSDevice) Context; PSRxMgmtPacket pRxMgmtPacket; - // int i; - //complete(&pDevice->notify); - //i = 0; -#if 1 while (1) { - //down(&pDevice->mlme_semaphore); - // pRxMgmtPacket = DeQueue(pDevice); -#if 1 spin_lock_irq(&pDevice->lock); while (pDevice->rxManeQueue.packet_num != 0) { pRxMgmtPacket = DeQueue(pDevice); - //pDevice; - //DequeueManageObject(pDevice->FirstRecvMngList, pDevice->LastRecvMngList); vMgrRxManagePacket(pDevice, pDevice->pMgmt, pRxMgmtPacket); } spin_unlock_irq(&pDevice->lock); if (mlme_kill == 0) break; - //udelay(200); -#endif + schedule(); if (mlme_kill == 0) break; } -#endif return 0; } @@ -1749,7 +1665,6 @@ static int device_open(struct net_device *dev) { device_init_defrag_cb(pDevice); device_init_td0_ring(pDevice); device_init_td1_ring(pDevice); -// VNTWIFIvSet11h(pDevice->pMgmt, pDevice->b11hEnable); if (pDevice->bDiversityRegCtlON) { device_init_diversity_timer(pDevice); @@ -1773,8 +1688,6 @@ static int device_open(struct net_device *dev) { mlme_kill = 1; #endif - //wait_for_completion(&pDevice->notify); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "call device_init_registers\n"); device_init_registers(pDevice, DEVICE_INIT_COLD); MACvReadEtherAddress(pDevice->PortOffset, pDevice->abyCurrentNetAddr); @@ -1786,12 +1699,6 @@ static int device_open(struct net_device *dev) { add_timer(&(pDevice->pMgmt->sTimerSecondCallback)); #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT - /* - pDevice->bwextstep0 = false; - pDevice->bwextstep1 = false; - pDevice->bwextstep2 = false; - pDevice->bwextstep3 = false; - */ pDevice->bwextcount = 0; pDevice->bWPASuppWextEnabled = false; #endif @@ -1873,9 +1780,7 @@ static int device_close(struct net_device *dev) { pDevice->flags &= (~DEVICE_FLAGS_OPENED); //2008-0714-01by chester device_release_WPADEV(pDevice); -//PLICE_DEBUG-> - //tasklet_kill(&pDevice->RxMngWorkItem); -//PLICE_DEBUG<- + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_close.. \n"); return 0; } @@ -1922,7 +1827,6 @@ bool device_dma0_xmit(PSDevice pDevice, struct sk_buff *skb, unsigned int uNodeI unsigned int cbHeaderSize; unsigned int ii; SKeyItem STempKey; -// unsigned char byKeyIndex = 0; if (pDevice->bStopTx0Pkt) { dev_kfree_skb_irq(skb); @@ -2279,7 +2183,6 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev) { } } -// DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "acdma0: pDevice->wCurrentRate = %d \n", pDevice->wCurrentRate); if (pDevice->wCurrentRate <= RATE_11M) { byPktType = PK_TYPE_11B; @@ -2293,10 +2196,6 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev) { } } -//#ifdef PLICE_DEBUG -// printk("FIX RATE:CurrentRate is %d"); -//#endif - if (bNeedEncryption) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ntohs Pkt Type=%04x\n", ntohs(pDevice->sTxEthHeader.wType)); if ((pDevice->sTxEthHeader.wType) == TYPE_PKT_802_1x) { @@ -2374,12 +2273,10 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev) { } pDevice->apCurrTD[TYPE_AC0DMA] = pHeadTD; -//#ifdef PLICE_DEBUG + if (pDevice->bFixRate) { printk("FixRate:Rate is %d,TxPower is %d\n", pDevice->wCurrentRate, pDevice->byCurPwr); - } else { } -//#endif { unsigned char Protocol_Version; //802.1x Authentication @@ -2411,7 +2308,6 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev) { } MACvTransmitAC0(pDevice->PortOffset); -// DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "acdma0:pDevice->apCurrTD= %p\n", pHeadTD); dev->trans_start = jiffies; @@ -2430,7 +2326,6 @@ static irqreturn_t device_intr(int irq, void *dev_instance) { int handled = 0; unsigned char byData = 0; int ii = 0; -// unsigned char byRSSI; MACvReadISR(pDevice->PortOffset, &pDevice->dwIsr); @@ -2441,17 +2336,6 @@ static irqreturn_t device_intr(int irq, void *dev_instance) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dwIsr = 0xffff\n"); return IRQ_RETVAL(handled); } - /* - // 2008-05-21 by Richardtai, we can't read RSSI here, because no packet bound with RSSI - - if ((pDevice->dwIsr & ISR_RXDMA0) && - (pDevice->byLocalID != REV_ID_VT3253_B0) && - (pDevice->bBSSIDFilter == true)) { - // update RSSI - //BBbReadEmbedded(pDevice->PortOffset, 0x3E, &byRSSI); - //pDevice->uCurrRSSI = byRSSI; - } - */ handled = 1; MACvIntDisable(pDevice->PortOffset); @@ -2492,7 +2376,6 @@ static irqreturn_t device_intr(int irq, void *dev_instance) { VNSvInPortD(pDevice->PortOffset + MAC_REG_MAR4, &(pDevice->dwOrgMAR4)); MACvSelectPage0(pDevice->PortOffset); //xxxx - // WCMDbFlushCommandQueue(pDevice->pMgmt, true); if (set_channel(pDevice, pDevice->pCurrMeasureEID->sReq.byChannel)) { pDevice->bMeasureInProgress = true; MACvSelectPage1(pDevice->PortOffset); @@ -2505,7 +2388,6 @@ static irqreturn_t device_intr(int irq, void *dev_instance) { } } else { // can not measure because set channel fail - // WCMDbResetCommandQueue(pDevice->pMgmt); // clear measure control MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_EN); s_vCompleteCurrentMeasure(pDevice, MEASURE_MODE_INCAPABLE); @@ -2529,7 +2411,6 @@ static irqreturn_t device_intr(int irq, void *dev_instance) { MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, MSRCTL_EN); MACvSelectPage0(pDevice->PortOffset); set_channel(pDevice, pDevice->byOrgChannel); - // WCMDbResetCommandQueue(pDevice->pMgmt); MACvSelectPage1(pDevice->PortOffset); MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE); MACvSelectPage0(pDevice->PortOffset); @@ -2572,9 +2453,7 @@ static irqreturn_t device_intr(int irq, void *dev_instance) { } } - if (pDevice->eOPMode == OP_MODE_ADHOC) { - //pDevice->bBeaconSent = false; - } else { + if (pDevice->eOPMode != OP_MODE_ADHOC) { if ((pDevice->bUpdateBBVGA) && pDevice->bLinkPass && (pDevice->uCurrRSSI != 0)) { long ldBm; @@ -2615,9 +2494,7 @@ static irqreturn_t device_intr(int irq, void *dev_instance) { (pMgmt->wIBSSBeaconPeriod - MAKE_BEACON_RESERVED) << 10); } - if (pDevice->eOPMode == OP_MODE_ADHOC && pDevice->pMgmt->wCurrATIMWindow > 0) { - // todo adhoc PS mode - } + /* TODO: adhoc PS mode */ } @@ -2651,7 +2528,6 @@ static irqreturn_t device_intr(int irq, void *dev_instance) { MACvSelectPage1(pDevice->PortOffset); MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MSRCTL+1, MSRCTL1_TXPAUSE); MACvSelectPage0(pDevice->PortOffset); - //VNTWIFIbSendBeacon(pDevice->pMgmt); CARDbStartTxPacket(pDevice, PKT_TYPE_802_11_ALL); } } @@ -2670,8 +2546,6 @@ static irqreturn_t device_intr(int irq, void *dev_instance) { if (pDevice->dwIsr & ISR_AC0DMA) { max_count += device_tx_srv(pDevice, TYPE_AC0DMA); } - if (pDevice->dwIsr & ISR_SOFTTIMER) { - } if (pDevice->dwIsr & ISR_SOFTTIMER1) { if (pDevice->eOPMode == OP_MODE_AP) { if (pDevice->bShortSlotTime) @@ -3099,16 +2973,6 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { case SIOCGIWPRIV: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWPRIV \n"); rc = -EOPNOTSUPP; -/* - if (wrq->u.data.pointer) { - wrq->u.data.length = sizeof(iwctl_private_args) / sizeof(iwctl_private_args[0]); - - if (copy_to_user(wrq->u.data.pointer, - (u_char *) iwctl_private_args, - sizeof(iwctl_private_args))) - rc = -EFAULT; - } -*/ break; //2008-0409-07, by Einsn Liu @@ -3290,8 +3154,6 @@ static int __init vt6655_init_module(void) { int ret; -// ret=pci_module_init(&device_driver); - //ret = pcie_port_service_register(&device_driver); ret = pci_register_driver(&device_driver); #ifdef CONFIG_PM if (ret >= 0) diff --git a/drivers/staging/vt6655/dpc.c b/drivers/staging/vt6655/dpc.c index 771bf35ae044..37fa4af15927 100644 --- a/drivers/staging/vt6655/dpc.c +++ b/drivers/staging/vt6655/dpc.c @@ -60,7 +60,6 @@ /*--------------------- Static Classes ----------------------------*/ /*--------------------- Static Variables --------------------------*/ -//static int msglevel =MSG_LEVEL_DEBUG; static int msglevel = MSG_LEVEL_INFO; const unsigned char acbyRxRate[MAX_RATE] = @@ -327,15 +326,11 @@ device_receive_frame( PS802_11Header pMACHeader; bool bRxeapol_key = false; -// DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "---------- device_receive_frame---\n"); - skb = pRDInfo->skb; //PLICE_DEBUG-> -#if 1 pci_unmap_single(pDevice->pcid, pRDInfo->skb_dma, pDevice->rx_buf_sz, PCI_DMA_FROMDEVICE); -#endif //PLICE_DEBUG<- pwFrameSize = (unsigned short *)(skb->data + 2); FrameSize = cpu_to_le16(pCurrRD->m_rd1RD1.wReqCount) - cpu_to_le16(pCurrRD->m_rd0RD0.wResCount); @@ -366,7 +361,6 @@ device_receive_frame( return false; } //PLICE_DEBUG-> -#if 1 // update receive statistic counter STAvUpdateRDStatCounter(&pDevice->scStatistic, *pbyRsr, @@ -375,8 +369,6 @@ device_receive_frame( pbyFrame, FrameSize); -#endif - pMACHeader = (PS802_11Header)((unsigned char *)(skb->data) + 8); //PLICE_DEBUG<- if (pDevice->bMeasureInProgress) { @@ -492,8 +484,6 @@ device_receive_frame( pDevice->s802_11Counter.TKIPICVErrors++; } else if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_CCMP)) { pDevice->s802_11Counter.CCMPDecryptErrors++; - } else if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_WEP)) { -// pDevice->s802_11Counter.WEPICVErrorCount.QuadPart++; } } return false; @@ -557,13 +547,9 @@ device_receive_frame( pRxPacket->byRxRate = s_byGetRateIdx(*pbyRxRate); pRxPacket->byRxChannel = (*pbyRxSts) >> 2; //PLICE_DEBUG-> -//EnQueue(pDevice,pRxPacket); #ifdef THREAD EnQueue(pDevice, pRxPacket); - - //up(&pDevice->mlme_semaphore); - //Enque (pDevice->FirstRecvMngList,pDevice->LastRecvMngList,pMgmt); #else #ifdef TASK_LET @@ -571,12 +557,10 @@ device_receive_frame( tasklet_schedule(&pDevice->RxMngWorkItem); #else vMgrRxManagePacket((void *)pDevice, pDevice->pMgmt, pRxPacket); - //tasklet_schedule(&pDevice->RxMngWorkItem); #endif #endif //PLICE_DEBUG<- - //vMgrRxManagePacket((void *)pDevice, pDevice->pMgmt, pRxPacket); // hostap Deamon handle 802.11 management if (pDevice->bEnableHostapd) { skb->dev = pDevice->apdev; @@ -590,9 +574,8 @@ device_receive_frame( netif_rx(skb); return true; } - } else { - // Control Frame } + return false; } else { if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { @@ -643,14 +626,9 @@ device_receive_frame( // Data frame Handle if (pDevice->bEnablePSMode) { - if (IS_FC_MOREDATA((skb->data+4))) { - if (*pbyRsr & RSR_ADDROK) { - //PSbSendPSPOLL((PSDevice)pDevice); - } - } else { - if (pDevice->pMgmt->bInTIMWake == true) { + if (!IS_FC_MOREDATA((skb->data+4))) { + if (pDevice->pMgmt->bInTIMWake == true) pDevice->pMgmt->bInTIMWake = false; - } } } @@ -765,16 +743,12 @@ device_receive_frame( pdwMIC_L = (__le32 *)(skb->data + 4 + FrameSize); pdwMIC_R = (__le32 *)(skb->data + 4 + FrameSize + 4); - //DBG_PRN_GRP12(("RxL: %lx, RxR: %lx\n", *pdwMIC_L, *pdwMIC_R)); - //DBG_PRN_GRP12(("LocalL: %lx, LocalR: %lx\n", dwLocalMIC_L, dwLocalMIC_R)); - //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dwMICKey0= %lx,dwMICKey1= %lx \n", dwMICKey0, dwMICKey1); if ((le32_to_cpu(*pdwMIC_L) != dwLocalMIC_L) || (le32_to_cpu(*pdwMIC_R) != dwLocalMIC_R) || pDevice->bRxMICFail) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "MIC comparison is fail!\n"); pDevice->bRxMICFail = false; - //pDevice->s802_11Counter.TKIPLocalMICFailures.QuadPart++; pDevice->s802_11Counter.TKIPLocalMICFailures++; if (bDeFragRx) { if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) { @@ -813,10 +787,8 @@ device_receive_frame( if ((pDevice->pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (pDevice->pMgmt->eCurrState == WMAC_STATE_ASSOC) && (*pbyRsr & (RSR_ADDRBROAD | RSR_ADDRMULTI)) == 0) { - //s802_11_Status.Flags = NDIS_802_11_AUTH_REQUEST_PAIRWISE_ERROR; wpahdr->type = VIAWGET_PTK_MIC_MSG; } else { - //s802_11_Status.Flags = NDIS_802_11_AUTH_REQUEST_GROUP_ERROR; wpahdr->type = VIAWGET_GTK_MIC_MSG; } wpahdr->resp_ie_len = 0; @@ -863,10 +835,8 @@ device_receive_frame( !((dwRxTSC47_16 == 0) && (dwLocalTSC47_16 == 0xFFFFFFFF))) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "TSC is illegal~~!\n "); if (pKey->byCipherSuite == KEY_CTL_TKIP) - //pDevice->s802_11Counter.TKIPReplays.QuadPart++; pDevice->s802_11Counter.TKIPReplays++; else - //pDevice->s802_11Counter.CCMPReplays.QuadPart++; pDevice->s802_11Counter.CCMPReplays++; if (bDeFragRx) { @@ -881,10 +851,6 @@ device_receive_frame( } } // ----- End of Reply Counter Check -------------------------- - if ((pKey != NULL) && (bIsWEP)) { -// pDevice->s802_11Counter.DecryptSuccessCount.QuadPart++; - } - s_vProcessRxMACHeader(pDevice, (unsigned char *)(skb->data+4), FrameSize, bIsWEP, bExtIV, &cbHeaderOffset); FrameSize -= cbHeaderOffset; cbHeaderOffset += 4; // 4 is Rcv buffer header @@ -917,22 +883,6 @@ device_receive_frame( skb->protocol = eth_type_trans(skb, skb->dev); //drop frame not met IEEE 802.3 -/* - if (pDevice->flags & DEVICE_FLAGS_VAL_PKT_LEN) { - if ((skb->protocol==htons(ETH_P_802_3)) && - (skb->len!=htons(skb->mac.ethernet->h_proto))) { - pStats->rx_length_errors++; - pStats->rx_dropped++; - if (bDeFragRx) { - if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) { - DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc more frag bufs\n", - pDevice->dev->name); - } - } - return false; - } - } -*/ skb->ip_summed = CHECKSUM_NONE; pStats->rx_bytes += skb->len; @@ -1121,19 +1071,11 @@ static bool s_bHandleRxEncryption( if (pKey == NULL) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey == NULL\n"); - if (byDecMode == KEY_CTL_WEP) { -// pDevice->s802_11Counter.WEPUndecryptableCount.QuadPart++; - } else if (pDevice->bLinkPass) { -// pDevice->s802_11Counter.DecryptFailureCount.QuadPart++; - } + return false; } if (byDecMode != pKey->byCipherSuite) { - if (byDecMode == KEY_CTL_WEP) { -// pDevice->s802_11Counter.WEPUndecryptableCount.QuadPart++; - } else if (pDevice->bLinkPass) { -// pDevice->s802_11Counter.DecryptFailureCount.QuadPart++; - } + *pKeyOut = NULL; return false; } @@ -1231,14 +1173,8 @@ static bool s_bHostWepRxEncryption( DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "AES:%d %d %d\n", pDevice->pMgmt->byCSSPK, pDevice->pMgmt->byCSSGK, byDecMode); - if (byDecMode != pKey->byCipherSuite) { - if (byDecMode == KEY_CTL_WEP) { -// pDevice->s802_11Counter.WEPUndecryptableCount.QuadPart++; - } else if (pDevice->bLinkPass) { -// pDevice->s802_11Counter.DecryptFailureCount.QuadPart++; - } + if (byDecMode != pKey->byCipherSuite) return false; - } if (byDecMode == KEY_CTL_WEP) { // handle WEP diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c index 6eecd5358916..15c574529b21 100644 --- a/drivers/staging/vt6655/hostap.c +++ b/drivers/staging/vt6655/hostap.c @@ -48,7 +48,6 @@ /*--------------------- Static Classes ----------------------------*/ /*--------------------- Static Variables --------------------------*/ -//static int msglevel =MSG_LEVEL_DEBUG; static int msglevel = MSG_LEVEL_INFO; /*--------------------- Static Functions --------------------------*/ @@ -241,7 +240,6 @@ static int hostap_add_sta(PSDevice pDevice, pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_ASSOC; pMgmt->sNodeDBTable[uNodeIndex].wCapInfo = param->u.add_sta.capability; // TODO listenInterval -// pMgmt->sNodeDBTable[uNodeIndex].wListenInterval = 1; pMgmt->sNodeDBTable[uNodeIndex].bPSEnable = false; pMgmt->sNodeDBTable[uNodeIndex].bySuppRate = param->u.add_sta.tx_supp_rates; @@ -296,8 +294,6 @@ static int hostap_get_info_sta(PSDevice pDevice, if (BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &uNodeIndex)) { param->u.get_info_sta.inactive_sec = (jiffies - pMgmt->sNodeDBTable[uNodeIndex].ulLastRxJiffer) / HZ; - - //param->u.get_info_sta.txexc = pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts; } else { return -ENOENT; } @@ -305,37 +301,6 @@ static int hostap_get_info_sta(PSDevice pDevice, return 0; } -/* - * Description: - * reset txexec - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * true, false - * - * Return Value: - * - */ -/* - static int hostap_reset_txexc_sta(PSDevice pDevice, - struct viawget_hostapd_param *param) - { - PSMgmtObject pMgmt = pDevice->pMgmt; - unsigned int uNodeIndex; - - if (BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &uNodeIndex)) { - pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts = 0; - } else { - return -ENOENT; - } - - return 0; - } -*/ - /* * Description: * set station flag @@ -463,12 +428,6 @@ static int hostap_set_encryption(PSDevice pDevice, unsigned short wKeyCtl = 0; param->u.crypt.err = 0; -/* - if (param_len != - (int) ((char *) param->u.crypt.key - (char *) param) + - param->u.crypt.key_len) - return -EINVAL; -*/ if (param->u.crypt.alg > WPA_ALG_CCMP) return -EINVAL; @@ -780,12 +739,6 @@ int vt6655_hostap_ioctl(PSDevice pDevice, struct iw_point *p) ret = hostap_get_info_sta(pDevice, param); ap_ioctl = 1; break; -/* - case VIAWGET_HOSTAPD_RESET_TXEXC_STA: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_RESET_TXEXC_STA \n"); - ret = hostap_reset_txexc_sta(pDevice, param); - break; -*/ case VIAWGET_HOSTAPD_SET_FLAGS_STA: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SET_FLAGS_STA \n"); ret = hostap_set_flags_sta(pDevice, param); diff --git a/drivers/staging/vt6655/ioctl.c b/drivers/staging/vt6655/ioctl.c index 1de5d2c907d2..18d11d1f4fa6 100644 --- a/drivers/staging/vt6655/ioctl.c +++ b/drivers/staging/vt6655/ioctl.c @@ -319,7 +319,6 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) pList->sBSSIDList[ii].uChannel = pBSS->uChannel; pList->sBSSIDList[ii].wBeaconInterval = pBSS->wBeaconInterval; pList->sBSSIDList[ii].wCapInfo = pBSS->wCapInfo; - /* pList->sBSSIDList[ii].uRSSI = pBSS->uRSSI; */ RFvRSSITodBm(pDevice, (unsigned char)(pBSS->uRSSI), &ldBm); pList->sBSSIDList[ii].uRSSI = (unsigned int)ldBm; memcpy(pList->sBSSIDList[ii].abyBSSID, pBSS->abyBSSID, WLAN_BSSID_LEN); diff --git a/drivers/staging/vt6655/ioctl.h b/drivers/staging/vt6655/ioctl.h index ae240fd71a15..2f0db920e2cb 100644 --- a/drivers/staging/vt6655/ioctl.h +++ b/drivers/staging/vt6655/ioctl.h @@ -41,13 +41,4 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq); -/* - void vConfigWEPKey( - PSDevice pDevice, - unsigned long dwKeyIndex, - unsigned char *pbyKey, - unsigned long uKeyLength -); -*/ - #endif // __IOCTL_H__ diff --git a/drivers/staging/vt6655/iowpa.h b/drivers/staging/vt6655/iowpa.h index bfea01f5e00a..b7bd1909fa7c 100644 --- a/drivers/staging/vt6655/iowpa.h +++ b/drivers/staging/vt6655/iowpa.h @@ -34,13 +34,6 @@ #define WPA_IE_LEN 64 //WPA related -/* - typedef enum { WPA_ALG_NONE, WPA_ALG_WEP, WPA_ALG_TKIP, WPA_ALG_CCMP } wpa_alg; - typedef enum { CIPHER_NONE, CIPHER_WEP40, CIPHER_TKIP, CIPHER_CCMP, - CIPHER_WEP104 } wpa_cipher; - typedef enum { KEY_MGMT_802_1X, KEY_MGMT_PSK, KEY_MGMT_NONE, - KEY_MGMT_802_1X_NO_WPA, KEY_MGMT_WPA_NONE } wpa_key_mgmt; -*/ enum { VIAWGET_SET_WPA = 1, diff --git a/drivers/staging/vt6655/iwctl.c b/drivers/staging/vt6655/iwctl.c index a601c47a3803..9f88fb49f8ca 100644 --- a/drivers/staging/vt6655/iwctl.c +++ b/drivers/staging/vt6655/iwctl.c @@ -66,7 +66,6 @@ static const long frequency_list[] = { /*--------------------- Static Classes ----------------------------*/ -//static int msglevel =MSG_LEVEL_DEBUG; static int msglevel = MSG_LEVEL_INFO; /*--------------------- Static Variables --------------------------*/ @@ -89,7 +88,6 @@ struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev) #endif RFvRSSITodBm(pDevice, (unsigned char)(pDevice->uCurrRSSI), &ldBm); pDevice->wstats.qual.level = ldBm; - //pDevice->wstats.qual.level = 0x100 - pDevice->uCurrRSSI; pDevice->wstats.qual.noise = 0; pDevice->wstats.qual.updated = 1; pDevice->wstats.discard.nwid = 0; @@ -277,7 +275,6 @@ int iwctl_giwscan(struct net_device *dev, } iwe.u.qual.updated = 7; - // iwe.u.qual.qual = 0; current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN); memset(&iwe, 0, sizeof(iwe)); @@ -640,7 +637,6 @@ int iwctl_siwap(struct net_device *dev, if (pMgmt->eScanState == WMAC_IS_SCANNING) { // In scanning.. printk("SIOCSIWAP(??)-->In scanning...\n"); - // return -EAGAIN; } if (wrq->sa_family != ARPHRD_ETHER) rc = -EINVAL; @@ -778,7 +774,6 @@ int iwctl_siwessid(struct net_device *dev, if (pMgmt->eScanState == WMAC_IS_SCANNING) { // In scanning.. printk("SIOCSIWESSID(??)-->In scanning...\n"); - // return -EAGAIN; } // Check if we asked for `any' if (wrq->flags == 0) { @@ -889,7 +884,6 @@ int iwctl_giwessid(struct net_device *dev, // Get the current SSID pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; - //pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID; memcpy(extra, pItemSSID->abySSID , pItemSSID->len); extra[pItemSSID->len] = '\0'; wrq->length = pItemSSID->len + 1; @@ -1016,21 +1010,7 @@ int iwctl_giwrate(struct net_device *dev, brate = abySupportedRates[TxRate_iwconfig]; } } else brate = 0; -//2007-0118-05, by EinsnLiu -//Mark the unnecessary sentences. -/* - if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { - if (pDevice->byBBType == BB_TYPE_11B) - brate = 0x16; - if (pDevice->byBBType == BB_TYPE_11G) - brate = 0x6C; - if (pDevice->byBBType == BB_TYPE_11A) - brate = 0x6C; - } -*/ - -// if (pDevice->uConnectionRate == 13) -// brate = abySupportedRates[pDevice->wCurrentRate]; + wrq->value = brate * 500000; // If more than one rate, set auto if (pDevice->bFixRate == true) @@ -1319,82 +1299,6 @@ int iwctl_siwencode(struct net_device *dev, } //End Modify,Einsn -/* - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWENCODE \n"); - - // Check the size of the key - if (wrq->length > WLAN_WEP232_KEYLEN) { - rc = -EINVAL; - return rc; - } - - if (dwKeyIndex > WLAN_WEP_NKEYS) { - rc = -EINVAL; - return rc; - } - - if (dwKeyIndex > 0) - dwKeyIndex--; - - // Send the key to the card - if (wrq->length > 0) { - if (wrq->length == WLAN_WEP232_KEYLEN) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 232 bit wep key\n"); - } else if (wrq->length == WLAN_WEP104_KEYLEN) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 104 bit wep key\n"); - } else if (wrq->length == WLAN_WEP40_KEYLEN) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 40 bit wep key, index= %d\n", (int)dwKeyIndex); - } - memset(pDevice->abyKey, 0, WLAN_WEP232_KEYLEN); - memcpy(pDevice->abyKey, extra, wrq->length); - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "abyKey: "); - for (ii = 0; ii < wrq->length; ii++) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pDevice->abyKey[ii]); - } - - if (pDevice->flags & DEVICE_FLAGS_OPENED) { - spin_lock_irq(&pDevice->lock); - KeybSetDefaultKey(&(pDevice->sKey), - (unsigned long)(pDevice->byKeyIndex | (1 << 31)), - pDevice->uKeyLength, - NULL, - pDevice->abyKey, - KEY_CTL_WEP, - pDevice->PortOffset, - pDevice->byLocalID -); - spin_unlock_irq(&pDevice->lock); - } - pDevice->byKeyIndex = (unsigned char)dwKeyIndex; - pDevice->uKeyLength = wrq->length; - pDevice->bTransmitKey = true; - pDevice->bEncryptionEnable = true; - pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; - - // Do we want to just set the transmit key index ? - if (index < 4) { - pDevice->byKeyIndex = index; - } else if (!(wrq->flags & IW_ENCODE_MODE)) { - rc = -EINVAL; - return rc; - } - } - // Read the flags - if (wrq->flags & IW_ENCODE_DISABLED) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable WEP function\n"); - pMgmt->bShareKeyAlgorithm = false; - pDevice->bEncryptionEnable = false; - pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; - if (pDevice->flags & DEVICE_FLAGS_OPENED) { - spin_lock_irq(&pDevice->lock); - for (uu=0; uuPortOffset, uu); - spin_unlock_irq(&pDevice->lock); - } - } -*/ - if (wrq->flags & IW_ENCODE_RESTRICTED) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & ShareKey System\n"); pMgmt->bShareKeyAlgorithm = true; @@ -1406,77 +1310,6 @@ int iwctl_siwencode(struct net_device *dev, return rc; } -/* - * Wireless Handler : get encode mode - */ -/* - int iwctl_giwencode(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrq, - char *extra) { - PSDevice pDevice = (PSDevice)netdev_priv(dev); - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - int rc = 0; - char abyKey[WLAN_WEP232_KEYLEN]; - unsigned int index = (unsigned int)(wrq->flags & IW_ENCODE_INDEX); - PSKeyItem pKey = NULL; - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODE\n"); -//2007-0207-06, by EinsnLiu -//the key index in iwconfig is 1-4 when our driver is 0-3 -//so it can't be used directly. -//if the index is 0,we should used the index set by driver. -if (index > WLAN_WEP_NKEYS) { -rc = -EINVAL; -return rc; -} -if (index<1) {//set default key -if (pDevice->byKeyIndexbyKeyIndex; -} -else index=0; -} else index--; -//End Add,Einsn - -memset(abyKey, 0, sizeof(abyKey)); -// Check encryption mode -wrq->flags = IW_ENCODE_NOKEY; -// Is WEP enabled ??? -if (pDevice->bEncryptionEnable) -wrq->flags |= IW_ENCODE_ENABLED; -else -wrq->flags |= IW_ENCODE_DISABLED; - -if (pMgmt->bShareKeyAlgorithm) -wrq->flags |= IW_ENCODE_RESTRICTED; -else -wrq->flags |= IW_ENCODE_OPEN; - -if (KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, (unsigned char)index , &pKey)) { -wrq->length = pKey->uKeyLength; -memcpy(abyKey, pKey->abyKey, pKey->uKeyLength); -//2007-0207-06, by EinsnLiu -//only get key success need to copy data -//index should +1. -//there is not necessary to return -EINVAL when get key failed -//if return -EINVAL,the encryption item can't be display by the command "iwconfig". -wrq->flags |= index+1; -memcpy(extra, abyKey, WLAN_WEP232_KEYLEN); -} - -//else { -// rc = -EINVAL; -// return rc; -// } - -//End Modify,Einsn - -return 0; -} -*/ - -//2008-0409-06, by Einsn Liu - int iwctl_giwencode(struct net_device *dev, struct iw_request_info *info, struct iw_point *wrq, @@ -1659,13 +1492,12 @@ int iwctl_siwauth(struct net_device *dev, wpa_version = wrq->value; if (wrq->value == IW_AUTH_WPA_VERSION_DISABLED) { PRINT_K("iwctl_siwauth:set WPADEV to disable at 1??????\n"); - //pDevice->bWPADevEnable = false; } else if (wrq->value == IW_AUTH_WPA_VERSION_WPA) { PRINT_K("iwctl_siwauth:set WPADEV to WPA1******\n"); } else { PRINT_K("iwctl_siwauth:set WPADEV to WPA2******\n"); } - //pDevice->bWPASuppWextEnabled =true; + break; case IW_AUTH_CIPHER_PAIRWISE: pairwise = wrq->value; @@ -1718,7 +1550,6 @@ int iwctl_siwauth(struct net_device *dev, } break; case IW_AUTH_WPA_ENABLED: - //pDevice->bWPADevEnable = !! wrq->value; break; case IW_AUTH_RX_UNENCRYPTED_EAPOL: break; @@ -1733,7 +1564,6 @@ int iwctl_siwauth(struct net_device *dev, pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; pMgmt->bShareKeyAlgorithm = false; pMgmt->eAuthenMode = false; - //pDevice->bWPADevEnable = false; } break; @@ -1741,15 +1571,7 @@ int iwctl_siwauth(struct net_device *dev, ret = -EOPNOTSUPP; break; } -/* - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wpa_version = %d\n",wpa_version); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pairwise = %d\n",pairwise); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->eEncryptionStatus = %d\n",pDevice->eEncryptionStatus); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pMgmt->eAuthenMode = %d\n",pMgmt->eAuthenMode); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pMgmt->bShareKeyAlgorithm = %s\n",pMgmt->bShareKeyAlgorithm?"true":"false"); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->bEncryptionEnable = %s\n",pDevice->bEncryptionEnable?"true":"false"); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->bWPADevEnable = %s\n",pDevice->bWPADevEnable?"true":"false"); -*/ + return ret; } @@ -1833,8 +1655,7 @@ int iwctl_siwencodeext(struct net_device *dev, u8 seq[IW_ENCODE_SEQ_MAX_SIZE]; u8 key[64]; size_t seq_len = 0, key_len = 0; -// - // int ii; + u8 key_array[64]; int ret = 0; @@ -1949,7 +1770,6 @@ int iwctl_siwmlme(struct net_device *dev, PSDevice pDevice = (PSDevice)netdev_priv(dev); PSMgmtObject pMgmt = &(pDevice->sMgmtObj); struct iw_mlme *mlme = (struct iw_mlme *)extra; - //u16 reason = cpu_to_le16(mlme->reason_code); int ret = 0; if (memcmp(pMgmt->abyCurrBSSID, mlme->addr.sa_data, ETH_ALEN)) { @@ -1984,69 +1804,6 @@ int iwctl_siwmlme(struct net_device *dev, * Structures to export the Wireless Handlers */ -/* - static const iw_handler iwctl_handler[] = - { - (iw_handler) iwctl_commit, // SIOCSIWCOMMIT - (iw_handler) iwctl_giwname, // SIOCGIWNAME - (iw_handler) NULL, // SIOCSIWNWID - (iw_handler) NULL, // SIOCGIWNWID - (iw_handler) iwctl_siwfreq, // SIOCSIWFREQ - (iw_handler) iwctl_giwfreq, // SIOCGIWFREQ - (iw_handler) iwctl_siwmode, // SIOCSIWMODE - (iw_handler) iwctl_giwmode, // SIOCGIWMODE - (iw_handler) NULL, // SIOCSIWSENS - (iw_handler) iwctl_giwsens, // SIOCGIWSENS - (iw_handler) NULL, // SIOCSIWRANGE - (iw_handler) iwctl_giwrange, // SIOCGIWRANGE - (iw_handler) NULL, // SIOCSIWPRIV - (iw_handler) NULL, // SIOCGIWPRIV - (iw_handler) NULL, // SIOCSIWSTATS - (iw_handler) NULL, // SIOCGIWSTATS - (iw_handler) NULL, // SIOCSIWSPY - (iw_handler) NULL, // SIOCGIWSPY - (iw_handler) NULL, // -- hole -- - (iw_handler) NULL, // -- hole -- - (iw_handler) iwctl_siwap, // SIOCSIWAP - (iw_handler) iwctl_giwap, // SIOCGIWAP - (iw_handler) NULL, // -- hole -- 0x16 - (iw_handler) iwctl_giwaplist, // SIOCGIWAPLIST - (iw_handler) iwctl_siwscan, // SIOCSIWSCAN - (iw_handler) iwctl_giwscan, // SIOCGIWSCAN - (iw_handler) iwctl_siwessid, // SIOCSIWESSID - (iw_handler) iwctl_giwessid, // SIOCGIWESSID - (iw_handler) NULL, // SIOCSIWNICKN - (iw_handler) NULL, // SIOCGIWNICKN - (iw_handler) NULL, // -- hole -- - (iw_handler) NULL, // -- hole -- - (iw_handler) iwctl_siwrate, // SIOCSIWRATE 0x20 - (iw_handler) iwctl_giwrate, // SIOCGIWRATE - (iw_handler) iwctl_siwrts, // SIOCSIWRTS - (iw_handler) iwctl_giwrts, // SIOCGIWRTS - (iw_handler) iwctl_siwfrag, // SIOCSIWFRAG - (iw_handler) iwctl_giwfrag, // SIOCGIWFRAG - (iw_handler) NULL, // SIOCSIWTXPOW - (iw_handler) NULL, // SIOCGIWTXPOW - (iw_handler) iwctl_siwretry, // SIOCSIWRETRY - (iw_handler) iwctl_giwretry, // SIOCGIWRETRY - (iw_handler) iwctl_siwencode, // SIOCSIWENCODE - (iw_handler) iwctl_giwencode, // SIOCGIWENCODE - (iw_handler) iwctl_siwpower, // SIOCSIWPOWER - (iw_handler) iwctl_giwpower, // SIOCGIWPOWER - (iw_handler) NULL, // -- hole -- - (iw_handler) NULL, // -- hole -- - (iw_handler) iwctl_siwgenie, // SIOCSIWGENIE - (iw_handler) iwctl_giwgenie, // SIOCGIWGENIE - (iw_handler) iwctl_siwauth, // SIOCSIWAUTH - (iw_handler) iwctl_giwauth, // SIOCGIWAUTH - (iw_handler) iwctl_siwencodeext, // SIOCSIWENCODEEXT - (iw_handler) iwctl_giwencodeext, // SIOCGIWENCODEEXT - (iw_handler) NULL, // SIOCSIWPMKSA - (iw_handler) NULL, // -- hole -- - - }; -*/ - static const iw_handler iwctl_handler[] = { (iw_handler) iwctl_commit, // SIOCSIWCOMMIT @@ -2124,13 +1881,9 @@ const struct iw_handler_def iwctl_handler_def = { .get_wireless_stats = &iwctl_get_wireless_stats, .num_standard = sizeof(iwctl_handler)/sizeof(iw_handler), -// .num_private = sizeof(iwctl_private_handler)/sizeof(iw_handler), -// .num_private_args = sizeof(iwctl_private_args)/sizeof(struct iw_priv_args), .num_private = 0, .num_private_args = 0, .standard = (iw_handler *)iwctl_handler, -// .private = (iw_handler *) iwctl_private_handler, -// .private_args = (struct iw_priv_args *)iwctl_private_args, .private = NULL, .private_args = NULL, }; diff --git a/drivers/staging/vt6655/key.c b/drivers/staging/vt6655/key.c index 78b5809b8304..54de7d0fd37c 100644 --- a/drivers/staging/vt6655/key.c +++ b/drivers/staging/vt6655/key.c @@ -46,7 +46,6 @@ /*--------------------- Static Variables --------------------------*/ static int msglevel = MSG_LEVEL_INFO; -//static int msglevel =MSG_LEVEL_DEBUG; /*--------------------- Static Functions --------------------------*/ /*--------------------- Export Variables --------------------------*/ @@ -255,7 +254,6 @@ bool KeybSetKey( DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "KeybSetKey(R): \n"); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->bKeyValid: %d\n ", pKey->bKeyValid); - //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->uKeyLength: %d\n ", pKey->uKeyLength); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->abyKey: "); for (ii = 0; ii < pKey->uKeyLength; ii++) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pKey->abyKey[ii]); @@ -786,10 +784,6 @@ bool KeybSetAllGroupKey( } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "\n"); - //DBG_PRN_GRP12(("pKey->dwTSC47_16: %lX\n ", pKey->dwTSC47_16)); - //DBG_PRN_GRP12(("pKey->wTSC15_0: %X\n ", pKey->wTSC15_0)); - //DBG_PRN_GRP12(("pKey->dwKeyIndex: %lX\n ", pKey->dwKeyIndex)); - } // (pTable->KeyTable[i].bInUse == true) } return true; diff --git a/drivers/staging/vt6655/key.h b/drivers/staging/vt6655/key.h index 356e6de8f87f..4b8b4b6bd6cd 100644 --- a/drivers/staging/vt6655/key.h +++ b/drivers/staging/vt6655/key.h @@ -76,8 +76,6 @@ typedef struct tagSKeyTable unsigned long dwGTKeyIndex; // GroupTransmitKey Index bool bInUse; //2006-1116-01, by NomadZhao - //unsigned short wKeyCtl; - //bool bSoftWEP; bool bSoftWEP; unsigned short wKeyCtl; // for address of wKeyCtl at align 4 diff --git a/drivers/staging/vt6655/mac.c b/drivers/staging/vt6655/mac.c index 0ec079fa0398..db53e1a57bca 100644 --- a/drivers/staging/vt6655/mac.c +++ b/drivers/staging/vt6655/mac.c @@ -74,7 +74,6 @@ unsigned short TxRate_iwconfig;//2008-5-8 by chester /*--------------------- Static Definitions -------------------------*/ -//static int msglevel =MSG_LEVEL_DEBUG; static int msglevel = MSG_LEVEL_INFO; /*--------------------- Static Classes ----------------------------*/ @@ -770,7 +769,6 @@ bool MACbSoftwareReset(unsigned long dwIoBase) unsigned short ww; // turn on HOSTCR_SOFTRST, just write 0x01 to reset - //MACvRegBitsOn(dwIoBase, MAC_REG_HOSTCR, HOSTCR_SOFTRST); VNSvOutPortB(dwIoBase + MAC_REG_HOSTCR, 0x01); for (ww = 0; ww < W_MAX_TIMEOUT; ww++) { @@ -809,7 +807,6 @@ bool MACbSafeSoftwareReset(unsigned long dwIoBase) MACvSaveContext(dwIoBase, abyTmpRegData); // do reset bRetVal = MACbSoftwareReset(dwIoBase); - //BBvSoftwareReset(pDevice->PortOffset); // restore MAC context, except CR0 MACvRestoreContext(dwIoBase, abyTmpRegData); @@ -1022,11 +1019,6 @@ void MACvInitialize(unsigned long dwIoBase) // disable force PME-enable VNSvOutPortB(dwIoBase + MAC_REG_PMC1, PME_OVR); // only 3253 A - /* - MACvPwrEvntDisable(dwIoBase); - // clear power status - VNSvOutPortW(dwIoBase + MAC_REG_WAKEUPSR0, 0x0F0F); - */ // do reset MACbSoftwareReset(dwIoBase); diff --git a/drivers/staging/vt6655/mac.h b/drivers/staging/vt6655/mac.h index 4615db05549f..7333b8b526f4 100644 --- a/drivers/staging/vt6655/mac.h +++ b/drivers/staging/vt6655/mac.h @@ -1042,7 +1042,6 @@ void MACvSetKeyEntry(unsigned long dwIoBase, unsigned short wKeyCtl, unsigned in void MACvDisableKeyEntry(unsigned long dwIoBase, unsigned int uEntryIdx); void MACvSetDefaultKeyEntry(unsigned long dwIoBase, unsigned int uKeyLen, unsigned int uKeyIdx, unsigned long *pdwKey, unsigned char byLocalID); -//void MACvEnableDefaultKey(unsigned long dwIoBase, unsigned char byLocalID); void MACvDisableDefaultKey(unsigned long dwIoBase); void MACvSetDefaultTKIPKeyEntry(unsigned long dwIoBase, unsigned int uKeyLen, unsigned int uKeyIdx, unsigned long *pdwKey, unsigned char byLocalID); diff --git a/drivers/staging/vt6655/mib.c b/drivers/staging/vt6655/mib.c index 6a59652052b6..881c05413cb6 100644 --- a/drivers/staging/vt6655/mib.c +++ b/drivers/staging/vt6655/mib.c @@ -504,7 +504,6 @@ STAvUpdate802_11Counter( unsigned long dwCounter ) { - //p802_11Counter->TransmittedFragmentCount p802_11Counter->MulticastTransmittedFrameCount = (unsigned long long) (pStatistic->dwTsrBroadcast[TYPE_AC0DMA] + pStatistic->dwTsrBroadcast[TYPE_TXDMA0] + pStatistic->dwTsrMulticast[TYPE_AC0DMA] + @@ -513,12 +512,10 @@ STAvUpdate802_11Counter( p802_11Counter->RetryCount = (unsigned long long) (pStatistic->dwTsrRetry[TYPE_AC0DMA] + pStatistic->dwTsrRetry[TYPE_TXDMA0]); p802_11Counter->MultipleRetryCount = (unsigned long long) (pStatistic->dwTsrMoreThanOnceRetry[TYPE_AC0DMA] + pStatistic->dwTsrMoreThanOnceRetry[TYPE_TXDMA0]); - //p802_11Counter->FrameDuplicateCount p802_11Counter->RTSSuccessCount += (unsigned long long) (dwCounter & 0x000000ff); p802_11Counter->RTSFailureCount += (unsigned long long) ((dwCounter & 0x0000ff00) >> 8); p802_11Counter->ACKFailureCount += (unsigned long long) ((dwCounter & 0x00ff0000) >> 16); p802_11Counter->FCSErrorCount += (unsigned long long) ((dwCounter & 0xff000000) >> 24); - //p802_11Counter->ReceivedFragmentCount p802_11Counter->MulticastReceivedFrameCount = (unsigned long long) (pStatistic->dwRsrBroadcast + pStatistic->dwRsrMulticast); } diff --git a/drivers/staging/vt6655/mib.h b/drivers/staging/vt6655/mib.h index 6b99c119b78f..c0a59489184d 100644 --- a/drivers/staging/vt6655/mib.h +++ b/drivers/staging/vt6655/mib.h @@ -61,10 +61,6 @@ typedef struct tagSDot11Counters { unsigned long long CCMPReplays; unsigned long long CCMPDecryptErrors; unsigned long long FourWayHandshakeFailures; -// unsigned long long WEPUndecryptableCount; -// unsigned long long WEPICVErrorCount; -// unsigned long long DecryptSuccessCount; -// unsigned long long DecryptFailureCount; } SDot11Counters, *PSDot11Counters; // @@ -304,10 +300,6 @@ typedef struct tagSStatCounter { unsigned long long ullTxMulticastBytes[TYPE_MAXTD]; unsigned long long ullTxDirectedBytes[TYPE_MAXTD]; -// unsigned long dwTxRetryCount[8]; - // - // ISR status count - // SISRCounters ISRStat; SCustomCounters CustomStat; diff --git a/drivers/staging/vt6655/michael.c b/drivers/staging/vt6655/michael.c index ade4c855f20d..948658604b17 100644 --- a/drivers/staging/vt6655/michael.c +++ b/drivers/staging/vt6655/michael.c @@ -47,10 +47,7 @@ /*--------------------- Static Variables --------------------------*/ /*--------------------- Static Functions --------------------------*/ -/* - static unsigned long s_dwGetUINT32(unsigned char *p); // Get unsigned long from 4 bytes LSByte first - static void s_vPutUINT32(unsigned char *p, unsigned long val); // Put unsigned long 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(u32 dwK0, u32 dwK1); @@ -65,30 +62,6 @@ static unsigned int nBytesInM; // # bytes in M /*--------------------- Export Functions --------------------------*/ -/* - static unsigned long s_dwGetUINT32 (unsigned char *p) -// Convert from unsigned char [] to unsigned long in a portable way -{ -unsigned long res = 0; -unsigned int i; -for (i=0; i<4; i++) -{ - res |= (*p++) << (8 * i); -} -return res; -} - -static void s_vPutUINT32 (unsigned char *p, unsigned long val) -// Convert from unsigned long to unsigned char [] in a portable way -{ - unsigned int i; - for (i=0; i<4; i++) { - *p++ = (unsigned char) (val & 0xff); - val >>= 8; - } -} -*/ - static void s_vClear(void) { // Reset the state to the empty message. diff --git a/drivers/staging/vt6655/power.c b/drivers/staging/vt6655/power.c index 4bd1ccb79515..bc6186df5d30 100644 --- a/drivers/staging/vt6655/power.c +++ b/drivers/staging/vt6655/power.c @@ -95,14 +95,12 @@ PSvEnablePowerSaving( if (wListenInterval >= 2) { // clear always listen beacon MACvRegBitsOff(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_ALBCN); - //pDevice->wCFG &= ~CFG_ALB; // first time set listen next beacon MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_LNBCN); pMgmt->wCountToWakeUp = wListenInterval; } else { // always listen beacon MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_ALBCN); - //pDevice->wCFG |= CFG_ALB; pMgmt->wCountToWakeUp = 0; } @@ -110,13 +108,10 @@ PSvEnablePowerSaving( MACvRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PSEN); pDevice->bEnablePSMode = true; - if (pDevice->eOPMode == OP_MODE_ADHOC) { -// bMgrPrepareBeaconToSend((void *)pDevice, pMgmt); - } - // We don't send null pkt in ad hoc mode since beacon will handle this. - else if (pDevice->eOPMode == OP_MODE_INFRASTRUCTURE) { + /* We don't send null pkt in ad hoc mode since beacon will handle this. */ + if (pDevice->eOPMode != OP_MODE_ADHOC && pDevice->eOPMode == OP_MODE_INFRASTRUCTURE) PSbSendNullPacket(pDevice); - } + pDevice->bPWBitOn = true; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "PS:Power Saving Mode Enable... \n"); return; @@ -138,7 +133,6 @@ PSvDisablePowerSaving( ) { PSDevice pDevice = (PSDevice)hDeviceContext; -// PSMgmtObject pMgmt = pDevice->pMgmt; // disable power saving hw function MACbPSWakeup(pDevice->PortOffset); @@ -258,8 +252,6 @@ PSvSendPSPOLL( // send the frame if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Send PS-Poll packet failed..\n"); - } else { -// DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Send PS-Poll packet success..\n"); } return; @@ -336,8 +328,6 @@ PSbSendNullPacket( if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Send Null Packet failed !\n"); return false; - } else { -// DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Send Null Packet success....\n"); } return true; diff --git a/drivers/staging/vt6655/power.h b/drivers/staging/vt6655/power.h index 337dd659f12f..ce56124acf1b 100644 --- a/drivers/staging/vt6655/power.h +++ b/drivers/staging/vt6655/power.h @@ -42,9 +42,6 @@ /*--------------------- Export Functions --------------------------*/ -// PSDevice pDevice -// PSDevice hDeviceContext - bool PSbConsiderPowerDown( void *hDeviceContext, diff --git a/drivers/staging/vt6655/rf.c b/drivers/staging/vt6655/rf.c index edb1b2768b17..b379f4f8bb5f 100644 --- a/drivers/staging/vt6655/rf.c +++ b/drivers/staging/vt6655/rf.c @@ -39,8 +39,6 @@ /*--------------------- Static Definitions -------------------------*/ -//static int msglevel =MSG_LEVEL_INFO; - #define BY_AL2230_REG_LEN 23 //24bit #define CB_AL2230_INIT_SEQ 15 #define SWITCH_CHANNEL_DELAY_AL2230 200 //us @@ -183,7 +181,6 @@ static const unsigned long dwAL7230InitTable[CB_AL7230_INIT_SEQ] = { 0x841FF200+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11a: 451FE2 0x3FDFA300+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11a: 5FDFA3 0x7FD78400+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // 11b/g // Need modify for 11a - //0x802B4500+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11a: 8D1B45 // RoberYu:20050113, Rev0.47 Regsiter Setting Guide 0x802B5500+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11a: 8D1B55 0x56AF3600+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, @@ -192,7 +189,6 @@ static const unsigned long dwAL7230InitTable[CB_AL7230_INIT_SEQ] = { 0x221BB900+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, 0xE0000A00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11a: E0600A 0x08031B00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // init 0x080B1B00 => 0x080F1B00 for 3 wire control TxGain(D10) - //0x00093C00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11a: 00143C // RoberYu:20050113, Rev0.47 Regsiter Setting Guide 0x000A3C00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, // Need modify for 11a: 00143C 0xFFFFFD00+(BY_AL7230_REG_LEN<<3)+IFREGCTL_REGW, @@ -585,10 +581,9 @@ bool IFRFbWriteEmbedded(unsigned long dwIoBase, unsigned long dwData) break; } - if (ww == W_MAX_TIMEOUT) { -// DBG_PORT80_ALWAYS(0x32); + if (ww == W_MAX_TIMEOUT) return false; - } + return true; } @@ -930,9 +925,6 @@ bool RFbSetPower( case RATE_11M: byPwr = pDevice->abyCCKPwrTbl[uCH]; byPwrdBm = pDevice->abyCCKDefaultPwr[uCH]; -//PLICE_DEBUG-> - //byPwr+=5; -//PLICE_DEBUG <- break; case RATE_6M: case RATE_9M: @@ -955,9 +947,6 @@ bool RFbSetPower( } byPwrdBm += pDevice->abyOFDMDefaultPwr[uCH]; byPwr = byDec; -//PLICE_DEBUG-> - //byPwr+=5; -//PLICE_DEBUG<- break; case RATE_24M: case RATE_36M: @@ -965,9 +954,6 @@ bool RFbSetPower( case RATE_54M: byPwr = pDevice->abyOFDMPwrTbl[uCH]; byPwrdBm = pDevice->abyOFDMDefaultPwr[uCH]; -//PLICE_DEBUG-> - //byPwr+=5; -//PLICE_DEBUG<- break; } diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index c2653eb4f76c..e9642458f595 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -68,7 +68,6 @@ /*--------------------- Static Classes ----------------------------*/ /*--------------------- Static Variables --------------------------*/ -//static int msglevel =MSG_LEVEL_DEBUG; static int msglevel = MSG_LEVEL_INFO; #define PLICE_DEBUG @@ -1093,9 +1092,7 @@ s_vGenerateTxParameter( unsigned short wFifoCtl; bool bDisCRC = false; unsigned char byFBOption = AUTO_FB_NONE; -// unsigned short wCurrentRate = pDevice->wCurrentRate; - //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "s_vGenerateTxParameter...\n"); PSTxBufHead pFifoHead = (PSTxBufHead)pTxBufHead; pFifoHead->wReserved = wCurrentRate; wFifoCtl = pFifoHead->wFIFOCtl; @@ -1174,13 +1171,8 @@ s_vGenerateTxParameter( } } } - //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "s_vGenerateTxParameter END.\n"); } -/* - unsigned char *pbyBuffer,//point to pTxBufHead - unsigned short wFragType,//00:Non-Frag, 01:Start, 02:Mid, 03:Last - unsigned int cbFragmentSize,//Hdr+payoad+FCS -*/ + static void s_vFillFragParameter( @@ -1193,10 +1185,8 @@ s_vFillFragParameter( ) { PSTxBufHead pTxBufHead = (PSTxBufHead) pbyBuffer; - //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "s_vFillFragParameter...\n"); if (uTxType == TYPE_SYNCDMA) { - //PSTxSyncDesc ptdCurr = (PSTxSyncDesc)s_pvGetTxDescHead(pDevice, uTxType, uCurIdx); PSTxSyncDesc ptdCurr = (PSTxSyncDesc)pvtdCurr; //Set FIFOCtl & TimeStamp in TxSyncDesc @@ -1210,7 +1200,6 @@ s_vFillFragParameter( ptdCurr->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP); } } else { - //PSTxDesc ptdCurr = (PSTxDesc)s_pvGetTxDescHead(pDevice, uTxType, uCurIdx); PSTxDesc ptdCurr = (PSTxDesc)pvtdCurr; //Set TSR1 & ReqCount in TxDescHead ptdCurr->m_td1TD1.wReqCount = cpu_to_le16((unsigned short)(cbReqCount)); @@ -1222,8 +1211,6 @@ s_vFillFragParameter( } pTxBufHead->wFragCtl |= (unsigned short)wFragType;//0x0001; //0000 0000 0000 0001 - - //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "s_vFillFragParameter END\n"); } static unsigned int @@ -1245,8 +1232,6 @@ s_cbFillTxBufHead(PSDevice pDevice, unsigned char byPktType, unsigned char *pbyT unsigned short wFragType; //00:Non-Frag, 01:Start, 10:Mid, 11:Last unsigned int uDuration; unsigned char *pbyBuffer; -// unsigned int uKeyEntryIdx = NUM_KEY_ENTRY+1; -// unsigned char byKeySel = 0xFF; unsigned int cbIVlen = 0; unsigned int cbICVlen = 0; unsigned int cbMIClen = 0; @@ -1254,8 +1239,6 @@ s_cbFillTxBufHead(PSDevice pDevice, unsigned char byPktType, unsigned char *pbyT unsigned int cb802_1_H_len = 0; unsigned int uLength = 0; unsigned int uTmpLen = 0; -// unsigned char abyTmp[8]; -// unsigned long dwCRC; unsigned int cbMICHDR = 0; u32 dwMICKey0, dwMICKey1; u32 dwMIC_Priority; @@ -1274,7 +1257,6 @@ s_cbFillTxBufHead(PSDevice pDevice, unsigned char byPktType, unsigned char *pbyT unsigned char *pbyType; PSTxDesc ptdCurr; PSTxBufHead psTxBufHd = (PSTxBufHead) pbyTxBufferAddr; -// unsigned int tmpDescIdx; unsigned int cbHeaderLength = 0; void *pvRrvTime; PSMICHDRHead pMICHDR; @@ -1289,7 +1271,6 @@ s_cbFillTxBufHead(PSDevice pDevice, unsigned char byPktType, unsigned char *pbyT pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL; - //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "s_cbFillTxBufHead...\n"); if ((pDevice->eOPMode == OP_MODE_ADHOC) || (pDevice->eOPMode == OP_MODE_AP)) { if (is_multicast_ether_addr(&(psEthHeader->abyDstAddr[0]))) @@ -1567,7 +1548,6 @@ s_cbFillTxBufHead(PSDevice pDevice, unsigned char byPktType, unsigned char *pbyT // Last Fragmentation //========================= DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Last Fragmentation...\n"); - //tmpDescIdx = (uDescIdx + uFragIdx) % pDevice->cbTD[uDMAIdx]; wFragType = FRAGCTL_ENDFRAG; @@ -1600,7 +1580,6 @@ s_cbFillTxBufHead(PSDevice pDevice, unsigned char byPktType, unsigned char *pbyT //--------------------------- pbyBuffer = (unsigned char *)pHeadTD->pTDInfo->buf; - //pbyBuffer = (unsigned char *)pDevice->aamTxBuf[uDMAIdx][tmpDescIdx].pbyVAddr; uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen; @@ -1644,12 +1623,6 @@ s_cbFillTxBufHead(PSDevice pDevice, unsigned char byPktType, unsigned char *pbyT *(unsigned char *)((unsigned char *)&dwSafeMIC_R + uMICFragLen - 4), (cbMIClen - uMICFragLen)); } - /* - for (ii = 0; ii < cbLastFragPayloadSize + 8 + 24; ii++) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", *((unsigned char *)((pbyBuffer + uLength) + ii - 8 - 24))); - } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "\n\n"); - */ } MIC_vUnInit(); } else { @@ -1690,7 +1663,6 @@ s_cbFillTxBufHead(PSDevice pDevice, unsigned char byPktType, unsigned char *pbyT // Middle Fragmentation //========================= DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Middle Fragmentation...\n"); - //tmpDescIdx = (uDescIdx + uFragIdx) % pDevice->cbTD[uDMAIdx]; wFragType = FRAGCTL_MIDFRAG; @@ -1753,21 +1725,9 @@ s_cbFillTxBufHead(PSDevice pDevice, unsigned char byPktType, unsigned char *pbyT DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "MIDDLE: uMICFragLen:%d, cbFragPayloadSize:%d, uTmpLen:%d\n", uMICFragLen, cbFragPayloadSize, uTmpLen); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Fill MIC in Middle frag [%d]\n", uMICFragLen); - /* - for (ii = 0; ii < uMICFragLen; ii++) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", *((unsigned char *)((pbyBuffer + uLength + uTmpLen) + ii))); - } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "\n"); - */ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Get MIC:%X, %X\n", *pdwMIC_L, *pdwMIC_R); } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Middle frag len: %d\n", uTmpLen); - /* - for (ii = 0; ii < uTmpLen; ii++) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", *((unsigned char *)((pbyBuffer + uLength) + ii))); - } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "\n\n"); - */ } else { ASSERT(uTmpLen == (cbFragPayloadSize)); @@ -1804,8 +1764,6 @@ s_cbFillTxBufHead(PSDevice pDevice, unsigned char byPktType, unsigned char *pbyT //========================= // No Fragmentation //========================= - //DBG_PRTGRP03(("No Fragmentation...\n")); - //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "No Fragmentation...\n"); wFragType = FRAGCTL_NONFRAG; //Set FragCtl in TxBufferHead @@ -1864,12 +1822,6 @@ s_cbFillTxBufHead(PSDevice pDevice, unsigned char byPktType, unsigned char *pbyT if ((bNeedEncrypt == true) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Length:%d, %d\n", cbFrameBodySize - cb802_1_H_len, uLength); - /* - for (ii = 0; ii < (cbFrameBodySize - cb802_1_H_len); ii++) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", *((unsigned char *)((pbyBuffer + uLength) + ii))); - } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "\n"); - */ MIC_vAppend((pbyBuffer + uLength - cb802_1_H_len), cbFrameBodySize); @@ -1888,12 +1840,6 @@ s_cbFillTxBufHead(PSDevice pDevice, unsigned char byPktType, unsigned char *pbyT DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "uLength: %d, %d\n", uLength, cbFrameBodySize); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "cbReqCount:%d, %d, %d, %d\n", cbReqCount, cbHeaderLength, uPadding, cbIVlen); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "MIC:%x, %x\n", *pdwMIC_L, *pdwMIC_R); -/* - for (ii = 0; ii < 8; ii++) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", *(((unsigned char *)(pdwMIC_L) + ii))); - } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "\n"); -*/ } @@ -1917,12 +1863,9 @@ s_cbFillTxBufHead(PSDevice pDevice, unsigned char byPktType, unsigned char *pbyT pDevice->iTDUsed[uDMAIdx]++; -// DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " ptdCurr->m_dwReserved0[%d] ptdCurr->m_dwReserved1[%d].\n", ptdCurr->pTDInfo->dwReqCount, ptdCurr->pTDInfo->dwHeaderLength); -// DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " cbHeaderLength[%d]\n", cbHeaderLength); - } *puMACfragNum = uMACfragNum; - //DBG_PRTGRP03(("s_cbFillTxBufHead END\n")); + return cbHeaderLength; } @@ -2031,10 +1974,6 @@ vGenerateFIFOHeader(PSDevice pDevice, unsigned char byPktType, unsigned char *pb #endif pTxBufHead->byTxPower = pDevice->byCurPwr; -/* - if (pDevice->bEnableHostWEP) - pTxBufHead->wFragCtl &= ~(FRAGCTL_TKIP | FRAGCTL_LEGACY |FRAGCTL_AES); -*/ *pcbHeaderSize = s_cbFillTxBufHead(pDevice, byPktType, pbyTxBufferAddr, cbPayloadSize, uDMAIdx, pHeadTD, psEthHeader, pPacket, bNeedEncrypt, pTransmitKey, uNodeIndex, puMACfragNum); @@ -2075,7 +2014,7 @@ vGenerateMACHeader( { PS802_11Header pMACHeader = (PS802_11Header)pbyBufferAddr; - memset(pMACHeader, 0, (sizeof(S802_11Header))); //- sizeof(pMACHeader->dwIV))); + memset(pMACHeader, 0, (sizeof(S802_11Header))); if (uDMAIdx == TYPE_ATIMDMA) { pMACHeader->wFrameCtl = TYPE_802_11_ATIM; @@ -2247,8 +2186,6 @@ CMD_STATUS csMgmt_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket) { cbICVlen = 4; pTxBufHead->wFragCtl |= FRAGCTL_TKIP; //We need to get seed here for filling TxKey entry. - //TKIPvMixKey(pTransmitKey->abyKey, pDevice->abyCurrentNetAddr, - // pTransmitKey->wTSC15_0, pTransmitKey->dwTSC47_16, pDevice->abyPRNG); } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) { cbIVlen = 8;//RSN Header cbICVlen = 8;//MIC @@ -2613,7 +2550,6 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, unsigned char *pbMPDU, un unsigned char *pbyMacHdr; unsigned int cbExtSuppRate = 0; -// PWLAN_IE pItem; pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL; @@ -2736,8 +2672,6 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, unsigned char *pbMPDU, un cbICVlen = 4; pTxBufHead->wFragCtl |= FRAGCTL_TKIP; //We need to get seed here for filling TxKey entry. - //TKIPvMixKey(pTransmitKey->abyKey, pDevice->abyCurrentNetAddr, - // pTransmitKey->wTSC15_0, pTransmitKey->dwTSC47_16, pDevice->abyPRNG); } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) { cbIVlen = 8;//RSN Header cbICVlen = 8;//MIC diff --git a/drivers/staging/vt6655/rxtx.h b/drivers/staging/vt6655/rxtx.h index 4f2cf34dc39f..601bedb211d6 100644 --- a/drivers/staging/vt6655/rxtx.h +++ b/drivers/staging/vt6655/rxtx.h @@ -39,17 +39,6 @@ /*--------------------- Export Functions --------------------------*/ -/* - void - vGenerateMACHeader(PSDevice pDevice, unsigned long dwTxBufferAddr, unsigned char *pbySkbData, - unsigned int cbPacketSize, bool bDMA0Used, unsigned int *pcbHeadSize, - unsigned int *pcbAppendPayload); - - void - vProcessRxMACHeader(PSDevice pDevice, unsigned long dwRxBufferAddr, unsigned int cbPacketSize, - bool bIsWEP, unsigned int *pcbHeadSize); -*/ - void vGenerateMACHeader( PSDevice pDevice, diff --git a/drivers/staging/vt6655/tkip.c b/drivers/staging/vt6655/tkip.c index e7c17c6f7ea5..078b359a7d4b 100644 --- a/drivers/staging/vt6655/tkip.c +++ b/drivers/staging/vt6655/tkip.c @@ -189,7 +189,6 @@ void TKIPvMixKey( ) { unsigned int p1k[5]; -// unsigned int ttak0, ttak1, ttak2, ttak3, ttak4; unsigned int tsc0, tsc1, tsc2; unsigned int ppk0, ppk1, ppk2, ppk3, ppk4, ppk5; unsigned long int pnl, pnh; diff --git a/drivers/staging/vt6655/vntwifi.c b/drivers/staging/vt6655/vntwifi.c index e78aedf99077..2ccd0702388a 100644 --- a/drivers/staging/vt6655/vntwifi.c +++ b/drivers/staging/vt6655/vntwifi.c @@ -39,8 +39,6 @@ #include "datarate.h" /*--------------------- Static Definitions -------------------------*/ -//static int msglevel =MSG_LEVEL_DEBUG; -//static int msglevel =MSG_LEVEL_INFO; /*--------------------- Static Classes ----------------------------*/ @@ -591,46 +589,6 @@ VNTWIFIbyGetKeyCypher( } } -/* - bool - VNTWIFIbInit( - void *pAdapterHandler, - void **pMgmtHandler -) { - PSMgmtObject pMgmt = NULL; - unsigned int ii; - - pMgmt = (PSMgmtObject)kmalloc(sizeof(SMgmtObject), (int)GFP_ATOMIC); - if (pMgmt == NULL) { - *pMgmtHandler = NULL; - return false; - } - - memset(pMgmt, 0, sizeof(SMgmtObject)); - pMgmt->pAdapter = (void *) pAdapterHandler; - - // should initial MAC address abyMACAddr - for (ii=0; iiabyDesireBSSID[ii] = 0xFF; - } - pMgmt->pbyPSPacketPool = &pMgmt->byPSPacketPool[0]; - pMgmt->pbyMgmtPacketPool = &pMgmt->byMgmtPacketPool[0]; - pMgmt->byCSSPK = KEY_CTL_NONE; - pMgmt->byCSSGK = KEY_CTL_NONE; - pMgmt->wIBSSBeaconPeriod = DEFAULT_IBSS_BI; - - pMgmt->cbFreeCmdQueue = CMD_Q_SIZE; - pMgmt->uCmdDequeueIdx = 0; - pMgmt->uCmdEnqueueIdx = 0; - pMgmt->eCommandState = WLAN_CMD_STATE_IDLE; - pMgmt->bCmdStop = false; - pMgmt->bCmdRunning = false; - - *pMgmtHandler = pMgmt; - return true; - } -*/ - bool VNTWIFIbSetPMKIDCache( void *pMgmtObject, @@ -693,7 +651,6 @@ VNTWIFIbMeasureReport( PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject; unsigned char *pbyCurrentEID = (unsigned char *)(pMgmt->pCurrMeasureEIDRep); - //spin_lock_irq(&pDevice->lock); if ((pvMeasureEID != NULL) && (pMgmt->uLengthOfRepEIDs < (WLAN_A3FR_MAXLEN - sizeof(MEASEURE_REP) - sizeof(WLAN_80211HDR_A3) - 3)) ) { @@ -734,7 +691,7 @@ VNTWIFIbMeasureReport( if (bEndOfReport) { IEEE11hbMSRRepTx(pMgmt); } - //spin_unlock_irq(&pDevice->lock); + return true; } @@ -746,9 +703,7 @@ VNTWIFIbChannelSwitch( { PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject; - //spin_lock_irq(&pDevice->lock); pMgmt->uCurrChannel = byNewChannel; pMgmt->bSwitchChannel = false; - //spin_unlock_irq(&pDevice->lock); return true; } diff --git a/drivers/staging/vt6655/vntwifi.h b/drivers/staging/vt6655/vntwifi.h index 4b01ebd7299a..880b8ab109be 100644 --- a/drivers/staging/vt6655/vntwifi.h +++ b/drivers/staging/vt6655/vntwifi.h @@ -222,13 +222,6 @@ VNTWIFIvGetTxRate( unsigned char *pbyCCKBasicRate, unsigned char *pbyOFDMBasicRate ); -/* - bool - VNTWIFIbInit( - void *pAdapterHandler, - void **pMgmtHandler -); -*/ unsigned char VNTWIFIbyGetKeyCypher( @@ -276,12 +269,5 @@ VNTWIFIbChannelSwitch( void *pMgmtObject, unsigned char byNewChannel ); -/* - bool - VNTWIFIbRadarPresent( - void *pMgmtObject, - unsigned char byChannel -); -*/ #endif //__VNTWIFI_H__ diff --git a/drivers/staging/vt6655/wcmd.c b/drivers/staging/vt6655/wcmd.c index 72caaa203ddc..791b37e0db82 100644 --- a/drivers/staging/vt6655/wcmd.c +++ b/drivers/staging/vt6655/wcmd.c @@ -60,7 +60,6 @@ /*--------------------- Static Variables --------------------------*/ static int msglevel = MSG_LEVEL_INFO; -//static int msglevel =MSG_LEVEL_DEBUG; /*--------------------- Static Functions --------------------------*/ static @@ -377,7 +376,6 @@ vCommandTimer( return; } if (pMgmt->uScanChannel == pDevice->byMinChannel) { - //pMgmt->eScanType = WMAC_SCAN_ACTIVE; pMgmt->abyScanBSSID[0] = 0xFF; pMgmt->abyScanBSSID[1] = 0xFF; pMgmt->abyScanBSSID[2] = 0xFF; @@ -385,8 +383,6 @@ vCommandTimer( pMgmt->abyScanBSSID[4] = 0xFF; pMgmt->abyScanBSSID[5] = 0xFF; pItemSSID->byElementID = WLAN_EID_SSID; - // clear bssid list - // BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass); pMgmt->eScanState = WMAC_IS_SCANNING; } @@ -468,7 +464,6 @@ vCommandTimer( memset(pItemSSID->abySSID, 0, WLAN_SSID_MAXLEN); pMgmt->eCurrState = WMAC_STATE_IDLE; pMgmt->sNodeDBTable[0].bActive = false; -// pDevice->bBeaconBufReady = false; } netif_stop_queue(pDevice->dev); pDevice->eCommandState = WLAN_DISASSOCIATE_WAIT; @@ -480,7 +475,6 @@ vCommandTimer( } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " CARDbRadioPowerOff\n"); //2008-09-02 by chester - // CARDbRadioPowerOff(pDevice); s_bCommandComplete(pDevice); break; @@ -492,7 +486,6 @@ vCommandTimer( return; } //2008-09-02 by chester - // CARDbRadioPowerOff(pDevice); s_bCommandComplete(pDevice); break; @@ -504,8 +497,6 @@ vCommandTimer( return; } printk("chester-abyDesireSSID=%s\n", ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->abySSID); - //memcpy(pMgmt->abyAdHocSSID,pMgmt->abyDesireSSID, - //((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->len + WLAN_IEHDR_LEN); pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID; pItemSSIDCurr = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " cmd: desire ssid = %s\n", pItemSSID->abySSID); @@ -785,7 +776,6 @@ vCommandTimer( break; case WLAN_CMD_CHECK_BBSENSITIVITY_CHANGE: - //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "eCommandState == WLAN_CMD_CHECK_BBSENSITIVITY_START\n"); // wait all TD complete if (pDevice->iTDUsed[TYPE_AC0DMA] != 0) { vCommandTimerWait((void *)pDevice, 10); @@ -820,7 +810,6 @@ s_bCommandComplete( { PWLAN_IE_SSID pSSID; bool bRadioCmd = false; - //unsigned short wDeAuthenReason = 0; bool bForceSCAN = true; PSMgmtObject pMgmt = pDevice->pMgmt; @@ -847,14 +836,6 @@ s_bCommandComplete( } else { memset(pMgmt->abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); } -/* - if ((bForceSCAN == false) && (pDevice->bLinkPass == true)) { - if ((pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) && - (!memcmp(pSSID->abySSID, ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->abySSID, pSSID->len))) { - pDevice->eCommandState = WLAN_CMD_IDLE; - } - } -*/ break; case WLAN_CMD_SSID: pDevice->eCommandState = WLAN_CMD_SSID_START; @@ -923,11 +904,6 @@ bool bScheduleCommand( case WLAN_CMD_DISASSOCIATE: pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bNeedRadioOFF = *((int *)pbyItem0); break; -/* - case WLAN_CMD_DEAUTH: - pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].wDeAuthenReason = *((unsigned short *)pbyItem0); - break; -*/ case WLAN_CMD_RX_PSPOLL: break; @@ -948,10 +924,9 @@ bool bScheduleCommand( ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdEnqueueIdx, CMD_Q_SIZE); pDevice->cbFreeCmdQueue--; - if (!pDevice->bCmdRunning) { + if (!pDevice->bCmdRunning) s_bCommandComplete(pDevice); - } else { - } + return true; } diff --git a/drivers/staging/vt6655/wctl.c b/drivers/staging/vt6655/wctl.c index 950039f6d128..0ae57f1775c1 100644 --- a/drivers/staging/vt6655/wctl.c +++ b/drivers/staging/vt6655/wctl.c @@ -43,7 +43,7 @@ /*--------------------- Static Classes ----------------------------*/ /*--------------------- Static Variables --------------------------*/ -// static int msglevel =MSG_LEVEL_INFO; + /*--------------------- Static Functions --------------------------*/ /*--------------------- Export Variables --------------------------*/ @@ -113,7 +113,6 @@ unsigned int WCTLuSearchDFCB(PSDevice pDevice, PS802_11Header pMACHeader) if (pDevice->sRxDFCB[ii].bInUse && ether_addr_equal(pDevice->sRxDFCB[ii].abyAddr2, pMACHeader->abyAddr2)) { - // return ii; } } @@ -202,7 +201,6 @@ bool WCTLbHandleFragment(PSDevice pDevice, PS802_11Header pMACHeader, unsigned i pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].cbFrameLength = cbFrameLength; pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer += cbFrameLength; pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wFragNum++; - //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "First pDevice->uCurrentDFCBIdx= %d\n", pDevice->uCurrentDFCBIdx); return false; } else { pDevice->uCurrentDFCBIdx = WCTLuSearchDFCB(pDevice, pMACHeader); @@ -214,7 +212,6 @@ bool WCTLbHandleFragment(PSDevice pDevice, PS802_11Header pMACHeader, unsigned i pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].cbFrameLength += (cbFrameLength - uHeaderSize); pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer += (cbFrameLength - uHeaderSize); pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wFragNum++; - //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Second pDevice->uCurrentDFCBIdx= %d\n", pDevice->uCurrentDFCBIdx); } else { // seq error or frag # error flush DFCB pDevice->cbFreeDFCB++; @@ -228,7 +225,6 @@ bool WCTLbHandleFragment(PSDevice pDevice, PS802_11Header pMACHeader, unsigned i //enq defragcontrolblock pDevice->cbFreeDFCB++; pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].bInUse = false; - //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Last pDevice->uCurrentDFCBIdx= %d\n", pDevice->uCurrentDFCBIdx); return true; } return false; diff --git a/drivers/staging/vt6655/wmgr.c b/drivers/staging/vt6655/wmgr.c index b673bc9b2130..1d9de1fccd8c 100644 --- a/drivers/staging/vt6655/wmgr.c +++ b/drivers/staging/vt6655/wmgr.c @@ -88,7 +88,6 @@ /*--------------------- Static Variables --------------------------*/ static int msglevel = MSG_LEVEL_INFO; -//static int msglevel =MSG_LEVEL_DEBUG; /*--------------------- Static Functions --------------------------*/ //2008-8-4 by chester @@ -355,7 +354,6 @@ vMgrObjectInit( pMgmt->abyDesireBSSID[ii] = 0xFF; } pMgmt->sAssocInfo.AssocInfo.Length = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION); - //memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN +1); pMgmt->byCSSPK = KEY_CTL_NONE; pMgmt->byCSSGK = KEY_CTL_NONE; pMgmt->wIBSSBeaconPeriod = DEFAULT_IBSS_BI; @@ -1384,11 +1382,6 @@ s_vMgrRxAuthenSequence_2( s_vMgrLogStatus(pMgmt, cpu_to_le16((*(pFrame->pwStatus)))); pMgmt->eCurrState = WMAC_STATE_IDLE; } - if (pDevice->eCommandState == WLAN_AUTHENTICATE_WAIT) { -// spin_unlock_irq(&pDevice->lock); -// vCommandTimerWait((void *)pDevice, 0); -// spin_lock_irq(&pDevice->lock); - } break; @@ -1430,11 +1423,6 @@ s_vMgrRxAuthenSequence_2( DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Auth_reply sequence_2 tx ...\n"); } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:rx Auth_reply sequence_2 status error ...\n"); - if (pDevice->eCommandState == WLAN_AUTHENTICATE_WAIT) { -// spin_unlock_irq(&pDevice->lock); -// vCommandTimerWait((void *)pDevice, 0); -// spin_lock_irq(&pDevice->lock); - } s_vMgrLogStatus(pMgmt, cpu_to_le16((*(pFrame->pwStatus)))); } break; @@ -1559,12 +1547,6 @@ s_vMgrRxAuthenSequence_4( s_vMgrLogStatus(pMgmt, cpu_to_le16((*(pFrame->pwStatus)))); pMgmt->eCurrState = WMAC_STATE_IDLE; } - - if (pDevice->eCommandState == WLAN_AUTHENTICATE_WAIT) { -// spin_unlock_irq(&pDevice->lock); -// vCommandTimerWait((void *)pDevice, 0); -// spin_lock_irq(&pDevice->lock); - } } /*+ @@ -1588,7 +1570,6 @@ s_vMgrRxDisassociation( { WLAN_FR_DISASSOC sFrame; unsigned int uNodeIndex = 0; -// CMD_STATUS CmdStatus; viawget_wpa_header *wpahdr; if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { @@ -1871,7 +1852,6 @@ s_vMgrRxBeacon( (void *)pRxPacket ); } else { -// DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "update bcn: RxChannel = : %d\n", byCurrChannel); BSSbUpdateToBSSList((void *)pDevice, *sFrame.pqwTimestamp, *sFrame.pwBeaconInterval, @@ -1942,10 +1922,8 @@ s_vMgrRxBeacon( pDevice->uCurrRSSI = pRxPacket->uRSSI; pDevice->byCurrSQ = pRxPacket->bySQ; - if (pMgmt->sNodeDBTable[0].uInActiveCount != 0) { + if (pMgmt->sNodeDBTable[0].uInActiveCount != 0) pMgmt->sNodeDBTable[0].uInActiveCount = 0; - //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN:Wake Count= [%d]\n", pMgmt->wCountToWakeUp); - } } // check if SSID the same if (sFrame.pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) { @@ -2101,11 +2079,9 @@ s_vMgrRxBeacon( (pMgmt->bMulticastTIM && (pMgmt->byDTIMCount == 0))) { pMgmt->bInTIMWake = true; // send out ps-poll packet -// DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN:In TIM\n"); - if (pMgmt->bInTIM) { + + if (pMgmt->bInTIM) PSvSendPSPOLL((PSDevice)pDevice); -// DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN:PS-POLL sent..\n"); - } } else { pMgmt->bInTIMWake = false; @@ -2181,11 +2157,6 @@ s_vMgrRxBeacon( printk("s_vMgrRxBeacon:TxDataRate is %d,Index is %d\n", pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate, uNodeIndex); } #endif -/* - pMgmt->sNodeDBTable[uNodeIndex].bShortSlotTime = WLAN_GET_CAP_INFO_SHORTSLOTTIME(*sFrame.pwCapInfo); - if (pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate > RATE_11M) - pMgmt->sNodeDBTable[uNodeIndex].bERPExist = true; -*/ } // if other stations joined, indicate connection to upper layer.. @@ -2230,12 +2201,8 @@ s_vMgrRxBeacon( pMgmt->abyCurrSuppRates, pMgmt->abyCurrExtSuppRates); - // MACvRegBitsOff(pDevice->PortOffset, MAC_REG_RCR, RCR_BSSID); - // set highest basic rate - // s_vSetHighestBasicRate(pDevice, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates); // Prepare beacon frame bMgrPrepareBeaconToSend((void *)pDevice, pMgmt); - // } } } } @@ -2383,8 +2350,6 @@ vMgrCreateOwnIBSS( MACvWriteATIMW(pDevice->PortOffset, pMgmt->wCurrATIMWindow); pDevice->uCurrRSSI = 0; pDevice->byCurrSQ = 0; - //memcpy(pMgmt->abyDesireSSID,pMgmt->abyAdHocSSID, - // ((PWLAN_IE_SSID)pMgmt->abyAdHocSSID)->len + WLAN_IEHDR_LEN); memset(pMgmt->abyCurrSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); memcpy(pMgmt->abyCurrSSID, pMgmt->abyDesireSSID, @@ -2453,8 +2418,6 @@ vMgrCreateOwnIBSS( pMgmt->byERPContext = 0; -// memcpy(pDevice->abyBSSID, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); - if (pMgmt->eConfigMode == WMAC_CONFIG_AP) { CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, OP_MODE_AP); } else { @@ -2540,7 +2503,6 @@ vMgrJoinBSSBegin( return; } - // memset(pMgmt->abyDesireBSSID, 0, WLAN_BSSID_LEN); // Search known BSS list for prefer BSSID or SSID pCurr = BSSpSearchBSSList(pDevice, @@ -2560,23 +2522,6 @@ vMgrJoinBSSBegin( if (WLAN_GET_CAP_INFO_ESS(cpu_to_le16(pCurr->wCapInfo))) { if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA) || (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK)) { // patch for CISCO migration mode -/* - if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) { - if (WPA_SearchRSN(0, WPA_TKIP, pCurr) == false) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "No match RSN info. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); - // encryption mode error - pMgmt->eCurrState = WMAC_STATE_IDLE; - return; - } - } else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) { - if (WPA_SearchRSN(0, WPA_AESCCMP, pCurr) == false) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "No match RSN info. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); - // encryption mode error - pMgmt->eCurrState = WMAC_STATE_IDLE; - return; - } - } -*/ } #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT @@ -2647,9 +2592,6 @@ vMgrJoinBSSBegin( pMgmt->eCurrMode = WMAC_MODE_ESS_STA; pMgmt->eCurrState = WMAC_STATE_JOINTED; - // Adopt BSS state in Adapter Device Object - //pDevice->byOpMode = OP_MODE_INFRASTRUCTURE; -// memcpy(pDevice->abyBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN); // Add current BSS to Candidate list // This should only works for WPA2 BSS, and WPA2 BSS check must be done before. @@ -2721,15 +2663,10 @@ vMgrJoinBSSBegin( memset(pMgmt->abyCurrSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN); memcpy(pMgmt->abyCurrBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN); memcpy(pMgmt->abyCurrSSID, pCurr->abySSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN); -// pMgmt->wCurrATIMWindow = pCurr->wATIMWindow; MACvWriteATIMW(pDevice->PortOffset, pMgmt->wCurrATIMWindow); pMgmt->eCurrMode = WMAC_MODE_IBSS_STA; pMgmt->eCurrState = WMAC_STATE_STARTED; - // Adopt BSS state in Adapter Device Object - //pDevice->byOpMode = OP_MODE_ADHOC; -// pDevice->bLinkPass = true; -// memcpy(pDevice->abyBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Join IBSS ok:%pM\n", pMgmt->abyCurrBSSID); @@ -2766,7 +2703,7 @@ s_vMgrSynchBSS( { CARD_PHY_TYPE ePhyType = PHY_TYPE_11B; PSMgmtObject pMgmt = pDevice->pMgmt; -// int ii; + //1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M unsigned char abyCurrSuppRatesG[] = {WLAN_EID_SUPP_RATES, 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C}; unsigned char abyCurrExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES, 4, 0x0C, 0x12, 0x18, 0x60}; @@ -2884,24 +2821,6 @@ s_vMgrSynchBSS( return; } -/* - for (ii=0; iildBmMAX< pDevice->ldBmThreshold[ii]) { - pDevice->byBBVGANew = pDevice->abyBBVGA[ii]; - break; - } - } - - if (pDevice->byBBVGANew != pDevice->byBBVGACurrent) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "RSSI[%d] NewGain[%d] OldGain[%d] \n", - (int)pCurr->ldBmMAX, pDevice->byBBVGANew, pDevice->byBBVGACurrent); - printk("RSSI[%d] NewGain[%d] OldGain[%d] \n", - (int)pCurr->ldBmMAX, pDevice->byBBVGANew, pDevice->byBBVGACurrent); - BBvSetVGAGainOffset(pDevice, pDevice->byBBVGANew); - } - printk("ldBmMAX[%d] NewGain[%d] OldGain[%d] \n", - (int)pCurr->ldBmMAX, pDevice->byBBVGANew, pDevice->byBBVGACurrent); -*/ pMgmt->uCurrChannel = pCurr->uChannel; pMgmt->eCurrentPHYMode = ePhyType; pMgmt->byERPContext = pCurr->sERP.byERP; @@ -2943,7 +2862,7 @@ static void Encyption_Rebuild( } } } - // } + return; } @@ -4228,10 +4147,7 @@ s_vMgrRxProbeRequest( sFrame.len = pRxPacket->cbMPDULen; sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header; vMgrDecodeProbeRequest(&sFrame); -/* - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request rx:MAC addr:%pM\n", - sFrame.pHdr->sA3.abyAddr2); -*/ + if (sFrame.pSSID->len != 0) { if (sFrame.pSSID->len != ((PWLAN_IE_SSID)pMgmt->abyCurrSSID)->len) return; @@ -4267,8 +4183,6 @@ s_vMgrRxProbeRequest( Status = csMgmt_xmit(pDevice, pTxPacket); if (Status != CMD_STATUS_PENDING) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Probe response tx failed\n"); - } else { -// DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Probe response tx sending..\n"); } } } @@ -4361,7 +4275,6 @@ vMgrRxManagePacket( case WLAN_FSTYPE_PROBEREQ: // Frame Clase = 0 - //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx probereq\n"); s_vMgrRxProbeRequest(pDevice, pMgmt, pRxPacket); break; @@ -4374,7 +4287,6 @@ vMgrRxManagePacket( case WLAN_FSTYPE_BEACON: // Frame Clase = 0 - //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "rx beacon\n"); if (pMgmt->eScanState != WMAC_NO_SCANNING) { bInScan = true; } @@ -4442,7 +4354,6 @@ bMgrPrepareBeaconToSend( PSDevice pDevice = (PSDevice)hDeviceContext; PSTxMgmtPacket pTxPacket; -// pDevice->bBeaconBufReady = false; if (pDevice->bEncryptionEnable || pDevice->bEnable8021x) { pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1); } else { @@ -4455,7 +4366,7 @@ bMgrPrepareBeaconToSend( pMgmt->wCurrCapInfo, pMgmt->wCurrBeaconPeriod, pMgmt->uCurrChannel, - pMgmt->wCurrATIMWindow, //0, + pMgmt->wCurrATIMWindow, (PWLAN_IE_SSID)pMgmt->abyCurrSSID, (unsigned char *)pMgmt->abyCurrBSSID, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, diff --git a/drivers/staging/vt6655/wmgr.h b/drivers/staging/vt6655/wmgr.h index b91f1f89ed05..2312d71bac43 100644 --- a/drivers/staging/vt6655/wmgr.h +++ b/drivers/staging/vt6655/wmgr.h @@ -119,32 +119,6 @@ typedef struct tagSAssocInfo { } SAssocInfo, *PSAssocInfo; //--- -/* - typedef enum tagWMAC_AUTHENTICATION_MODE { - WMAC_AUTH_OPEN, - WMAC_AUTH_SHAREKEY, - WMAC_AUTH_AUTO, - WMAC_AUTH_WPA, - WMAC_AUTH_WPAPSK, - WMAC_AUTH_WPANONE, - WMAC_AUTH_WPA2, - WMAC_AUTH_WPA2PSK, - WMAC_AUTH_MAX // Not a real mode, defined as upper bound - - } WMAC_AUTHENTICATION_MODE, *PWMAC_AUTHENTICATION_MODE; -*/ - -// Pre-configured Mode (from XP) -/* - typedef enum tagWMAC_CONFIG_MODE { - WMAC_CONFIG_ESS_STA, - WMAC_CONFIG_IBSS_STA, - WMAC_CONFIG_AUTO, - WMAC_CONFIG_AP - - } WMAC_CONFIG_MODE, *PWMAC_CONFIG_MODE; -*/ - typedef enum tagWMAC_SCAN_TYPE { WMAC_SCAN_ACTIVE, WMAC_SCAN_PASSIVE, @@ -232,9 +206,6 @@ typedef struct tagSMgmtObject unsigned char byCSSGK; unsigned char byCSSPK; -// unsigned char abyNewSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN]; -// unsigned char abyNewExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN]; - // Current state vars unsigned int uCurrChannel; unsigned char abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; @@ -256,7 +227,6 @@ typedef struct tagSMgmtObject unsigned char abyDesireBSSID[WLAN_BSSID_LEN]; // Adhoc or AP configuration vars - //unsigned char abyAdHocSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; unsigned short wIBSSBeaconPeriod; unsigned short wIBSSATIMWindow; unsigned int uIBSSChannel; diff --git a/drivers/staging/vt6655/wpa.c b/drivers/staging/vt6655/wpa.c index 990ea0f9e9fb..9be59c23d7e6 100644 --- a/drivers/staging/vt6655/wpa.c +++ b/drivers/staging/vt6655/wpa.c @@ -160,8 +160,7 @@ WPA_ParseRSN( ; } else break; - //DBG_PRN_GRP14(("abyPKType[%d]: %X\n", j-1, pBSSList->abyPKType[j-1])); - } //for + } pBSSList->wPKCount = (unsigned short)j; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wPKCount: %d\n", pBSSList->wPKCount); } @@ -187,7 +186,7 @@ WPA_ParseRSN( ; } else break; - //DBG_PRN_GRP14(("abyAuthType[%d]: %X\n", j-1, pBSSList->abyAuthType[j-1])); + } if (j > 0) pBSSList->wAuthCount = (unsigned short)j; @@ -206,9 +205,6 @@ WPA_ParseRSN( pBSSList->byReplayIdx = 2 << ((*pbyCaps >> WPA_REPLAYBITSSHIFT) & WPA_REPLAYBITS); pBSSList->sRSNCapObj.bRSNCapExist = true; pBSSList->sRSNCapObj.wRSNCap = *(unsigned short *)pbyCaps; - //DBG_PRN_GRP14(("pbyCaps: %X\n", *pbyCaps)); - //DBG_PRN_GRP14(("byDefaultK_as_PK: %X\n", pBSSList->byDefaultK_as_PK)); - //DBG_PRN_GRP14(("byReplayIdx: %X\n", pBSSList->byReplayIdx)); } } pBSSList->bWPAValid = true; diff --git a/drivers/staging/vt6655/wpa2.c b/drivers/staging/vt6655/wpa2.c index 2013122e92b2..f5be587f78d2 100644 --- a/drivers/staging/vt6655/wpa2.c +++ b/drivers/staging/vt6655/wpa2.c @@ -37,7 +37,6 @@ /*--------------------- Static Definitions -------------------------*/ static int msglevel = MSG_LEVEL_INFO; -//static int msglevel =MSG_LEVEL_DEBUG; /*--------------------- Static Classes ----------------------------*/ /*--------------------- Static Variables --------------------------*/ diff --git a/drivers/staging/vt6655/wpactl.c b/drivers/staging/vt6655/wpactl.c index 1f72589cf718..5e0fae0743a5 100644 --- a/drivers/staging/vt6655/wpactl.c +++ b/drivers/staging/vt6655/wpactl.c @@ -51,7 +51,6 @@ static const int frequency_list[] = { /*--------------------- Static Classes ----------------------------*/ /*--------------------- Static Variables --------------------------*/ -//static int msglevel =MSG_LEVEL_DEBUG; static int msglevel = MSG_LEVEL_INFO; /*--------------------- Static Functions --------------------------*/ @@ -197,7 +196,6 @@ int wpa_set_keys(PSDevice pDevice, void *ctx, unsigned char abyKey[MAX_KEY_LEN]; unsigned char abySeq[MAX_KEY_LEN]; QWORD KeyRSC; -// NDIS_802_11_KEY_RSC KeyRSC; unsigned char byKeyDecMode = KEY_CTL_WEP; int ret = 0; int uu, ii; @@ -220,7 +218,6 @@ int wpa_set_keys(PSDevice pDevice, void *ctx, return ret; } - //spin_unlock_irq(&pDevice->lock); if (param->u.wpa_key.key && fcpfkernel) { memcpy(&abyKey[0], param->u.wpa_key.key, param->u.wpa_key.key_len); } else { @@ -259,7 +256,6 @@ int wpa_set_keys(PSDevice pDevice, void *ctx, return ret; } - //spin_unlock_irq(&pDevice->lock); if (param->u.wpa_key.seq && fcpfkernel) { memcpy(&abySeq[0], param->u.wpa_key.seq, param->u.wpa_key.seq_len); } else { @@ -278,7 +274,6 @@ int wpa_set_keys(PSDevice pDevice, void *ctx, LODWORD(KeyRSC) |= (abySeq[ii] << (ii * 8)); else HIDWORD(KeyRSC) |= (abySeq[ii] << ((ii-4) * 8)); - //KeyRSC |= (abySeq[ii] << (ii * 8)); } dwKeyIndex |= 1 << 29; } @@ -325,7 +320,6 @@ int wpa_set_keys(PSDevice pDevice, void *ctx, if ((byKeyDecMode == KEY_CTL_TKIP) && (param->u.wpa_key.key_len != MAX_KEY_LEN)) { // TKIP Key must be 256 bits - //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA - TKIP Key must be 256 bits\n")); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "return- TKIP Key must be 256 bits!\n"); return -EINVAL; } @@ -333,7 +327,6 @@ int wpa_set_keys(PSDevice pDevice, void *ctx, if ((byKeyDecMode == KEY_CTL_CCMP) && (param->u.wpa_key.key_len != AES_KEY_LEN)) { // AES Key must be 128 bits - //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA - AES Key must be 128 bits\n")); return -EINVAL; } @@ -361,8 +354,6 @@ int wpa_set_keys(PSDevice pDevice, void *ctx, DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "GROUP Key Assign.\n"); } else { - //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA -KeybSetDefaultKey Fail.0\n")); - // spin_unlock_irq(&pDevice->lock); return -EINVAL; } @@ -372,16 +363,13 @@ int wpa_set_keys(PSDevice pDevice, void *ctx, // Pairwise Key can't be WEP if (byKeyDecMode == KEY_CTL_WEP) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Pairwise Key can't be WEP\n"); - //spin_unlock_irq(&pDevice->lock); return -EINVAL; } dwKeyIndex |= (1 << 30); // set pairwise key - if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) { - //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA - WMAC_CONFIG_IBSS_STA\n")); - //spin_unlock_irq(&pDevice->lock); + if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) return -EINVAL; - } + if (KeybSetKey(&(pDevice->sKey), ¶m->addr[0], dwKeyIndex, @@ -395,17 +383,7 @@ int wpa_set_keys(PSDevice pDevice, void *ctx, } else { // Key Table Full - if (ether_addr_equal(param->addr, pDevice->abyBSSID)) { - //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA -Key Table Full.2\n")); - //spin_unlock_irq(&pDevice->lock); - return -EINVAL; - - } else { - // Save Key and configure just before associate/reassociate to BSSID - // we do not implement now - //spin_unlock_irq(&pDevice->lock); - return -EINVAL; - } + return -EINVAL; } } // BSSID not 0xffffffffffff if ((ret == 0) && ((param->u.wpa_key.set_tx) != 0)) { @@ -413,17 +391,6 @@ int wpa_set_keys(PSDevice pDevice, void *ctx, pDevice->bTransmitKey = true; } pDevice->bEncryptionEnable = true; - //spin_unlock_irq(&pDevice->lock); - -/* - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " key=%x-%x-%x-%x-%x-xxxxx\n", - pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][0], - pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][1], - pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][2], - pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][3], - pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[byKeyIndex][4] -); -*/ return ret; } @@ -655,11 +622,7 @@ static int wpa_get_scan(PSDevice pDevice, scan_buf->ssid_len = pItemSSID->len; scan_buf->freq = frequency_list[pBSS->uChannel-1]; scan_buf->caps = pBSS->wCapInfo; - //scan_buf->caps = pBSS->wCapInfo; - //scan_buf->qual = - //scan_buf->noise = - //scan_buf->level = - //scan_buf->maxrate = + if (pBSS->wWPALen != 0) { scan_buf->wpa_ie_len = pBSS->wWPALen; memcpy(scan_buf->wpa_ie, pBSS->byWPAIE, pBSS->wWPALen); @@ -789,13 +752,10 @@ static int wpa_set_associate(PSDevice pDevice, if (pMgmt->eAuthenMode == WMAC_AUTH_SHAREKEY) { pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; - //pMgmt->eAuthenMode = WMAC_AUTH_SHAREKEY; pMgmt->bShareKeyAlgorithm = true; } else if (pMgmt->eAuthenMode == WMAC_AUTH_OPEN) { if (!bWepEnabled) pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; else pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; - //pMgmt->eAuthenMode = WMAC_AUTH_OPEN; - //pMgmt->bShareKeyAlgorithm = false; //20080717-06, by chester//Fix Open mode, WEP encryption } //mike save old encryption status pDevice->eOldEncryptionStatus = pDevice->eEncryptionStatus; diff --git a/drivers/staging/vt6655/wroute.c b/drivers/staging/vt6655/wroute.c index c39d5ed59ded..4da3fef139dc 100644 --- a/drivers/staging/vt6655/wroute.c +++ b/drivers/staging/vt6655/wroute.c @@ -44,7 +44,6 @@ /*--------------------- Static Variables --------------------------*/ static int msglevel = MSG_LEVEL_INFO; -//static int msglevel =MSG_LEVEL_DEBUG; /*--------------------- Static Functions --------------------------*/ /*--------------------- Export Variables --------------------------*/ -- cgit v1.2.3 From bc5cf6563576bb36baa7e93417b9a2e29999a5c6 Mon Sep 17 00:00:00 2001 From: Guido Martínez Date: Sat, 19 Apr 2014 16:45:00 -0300 Subject: staging: vt6655: fix checkpatch bracing issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patchs fixes tons of warnings such as: WARNING: braces {} are not necessary for single statement blocks #354: FILE: drivers/staging/vt6655/wmgr.c:354: + for (ii = 0; ii < WLAN_BSSID_LEN; ii++) { + pMgmt->abyDesireBSSID[ii] = 0xFF; + } Please note: this patch only fixes bracing issues (and there is still a lot to do); so if you run checkpatch it _will_ throw a lot of errors. Use --test-only=braces Signed-off-by: Guido Martínez Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/baseband.c | 84 +++++----- drivers/staging/vt6655/bssdb.c | 6 +- drivers/staging/vt6655/card.c | 143 ++++++++-------- drivers/staging/vt6655/channel.c | 77 ++++----- drivers/staging/vt6655/datarate.c | 14 +- drivers/staging/vt6655/device_main.c | 134 +++++++-------- drivers/staging/vt6655/dpc.c | 66 ++++---- drivers/staging/vt6655/hostap.c | 16 +- drivers/staging/vt6655/iwctl.c | 138 ++++++++-------- drivers/staging/vt6655/key.c | 49 +++--- drivers/staging/vt6655/mac.c | 88 +++++----- drivers/staging/vt6655/mib.c | 78 +++++---- drivers/staging/vt6655/michael.c | 4 +- drivers/staging/vt6655/power.c | 20 +-- drivers/staging/vt6655/rf.c | 51 +++--- drivers/staging/vt6655/rxtx.c | 257 +++++++++++++---------------- drivers/staging/vt6655/tkip.c | 6 +- drivers/staging/vt6655/vntwifi.c | 68 ++++---- drivers/staging/vt6655/wcmd.c | 97 ++++++----- drivers/staging/vt6655/wctl.c | 3 +- drivers/staging/vt6655/wmgr.c | 307 ++++++++++++++++------------------- drivers/staging/vt6655/wpa2.c | 40 +++-- drivers/staging/vt6655/wpactl.c | 17 +- 23 files changed, 814 insertions(+), 949 deletions(-) diff --git a/drivers/staging/vt6655/baseband.c b/drivers/staging/vt6655/baseband.c index 9c0d8ee6084f..6f95fb618dc3 100644 --- a/drivers/staging/vt6655/baseband.c +++ b/drivers/staging/vt6655/baseband.c @@ -1784,29 +1784,27 @@ BBuGetFrameTime( uRate = (unsigned int)awcFrameTime[uRateIdx]; if (uRateIdx <= 3) { //CCK mode - - if (byPreambleType == 1) {//Short + if (byPreambleType == 1) //Short uPreamble = 96; - } else { + else uPreamble = 192; - } + uFrameTime = (cbFrameLength * 80) / uRate; //????? uTmp = (uFrameTime * uRate) / 80; - if (cbFrameLength != uTmp) { + if (cbFrameLength != uTmp) uFrameTime++; - } return uPreamble + uFrameTime; } else { uFrameTime = (cbFrameLength * 8 + 22) / uRate; //???????? uTmp = ((uFrameTime * uRate) - 22) / 8; - if (cbFrameLength != uTmp) { + if (cbFrameLength != uTmp) uFrameTime++; - } + uFrameTime = uFrameTime * 4; //??????? - if (byPktType != PK_TYPE_11A) { + if (byPktType != PK_TYPE_11A) uFrameTime += 6; //?????? - } + return 20 + uFrameTime; //?????? } } @@ -2127,16 +2125,16 @@ bool BBbVT3253Init(PSDevice pDevice) if (byRFType == RF_RFMD2959) { if (byLocalID <= REV_ID_VT3253_A1) { - for (ii = 0; ii < CB_VT3253_INIT_FOR_RFMD; ii++) { + for (ii = 0; ii < CB_VT3253_INIT_FOR_RFMD; ii++) bResult &= BBbWriteEmbedded(dwIoBase, byVT3253InitTab_RFMD[ii][0], byVT3253InitTab_RFMD[ii][1]); - } + } else { - for (ii = 0; ii < CB_VT3253B0_INIT_FOR_RFMD; ii++) { + for (ii = 0; ii < CB_VT3253B0_INIT_FOR_RFMD; ii++) bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_RFMD[ii][0], byVT3253B0_RFMD[ii][1]); - } - for (ii = 0; ii < CB_VT3253B0_AGC_FOR_RFMD2959; ii++) { + + for (ii = 0; ii < CB_VT3253B0_AGC_FOR_RFMD2959; ii++) bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AGC4_RFMD2959[ii][0], byVT3253B0_AGC4_RFMD2959[ii][1]); - } + VNSvOutPortD(dwIoBase + MAC_REG_ITRTMSET, 0x23); MACvRegBitsOn(dwIoBase, MAC_REG_PAPEDELAY, BIT0); } @@ -2149,12 +2147,12 @@ bool BBbVT3253Init(PSDevice pDevice) pDevice->ldBmThreshold[2] = 0; pDevice->ldBmThreshold[3] = 0; } else if ((byRFType == RF_AIROHA) || (byRFType == RF_AL2230S)) { - for (ii = 0; ii < CB_VT3253B0_INIT_FOR_AIROHA2230; ii++) { + for (ii = 0; ii < CB_VT3253B0_INIT_FOR_AIROHA2230; ii++) bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AIROHA2230[ii][0], byVT3253B0_AIROHA2230[ii][1]); - } - for (ii = 0; ii < CB_VT3253B0_AGC; ii++) { + + for (ii = 0; ii < CB_VT3253B0_AGC; ii++) bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]); - } + pDevice->abyBBVGA[0] = 0x1C; pDevice->abyBBVGA[1] = 0x10; pDevice->abyBBVGA[2] = 0x0; @@ -2164,12 +2162,12 @@ bool BBbVT3253Init(PSDevice pDevice) pDevice->ldBmThreshold[2] = 0; pDevice->ldBmThreshold[3] = 0; } else if (byRFType == RF_UW2451) { - for (ii = 0; ii < CB_VT3253B0_INIT_FOR_UW2451; ii++) { + for (ii = 0; ii < CB_VT3253B0_INIT_FOR_UW2451; ii++) bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_UW2451[ii][0], byVT3253B0_UW2451[ii][1]); - } - for (ii = 0; ii < CB_VT3253B0_AGC; ii++) { + + for (ii = 0; ii < CB_VT3253B0_AGC; ii++) bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]); - } + VNSvOutPortB(dwIoBase + MAC_REG_ITRTMSET, 0x23); MACvRegBitsOn(dwIoBase, MAC_REG_PAPEDELAY, BIT0); @@ -2182,9 +2180,9 @@ bool BBbVT3253Init(PSDevice pDevice) pDevice->ldBmThreshold[2] = 0; pDevice->ldBmThreshold[3] = 0; } else if (byRFType == RF_UW2452) { - for (ii = 0; ii < CB_VT3253B0_INIT_FOR_UW2451; ii++) { + for (ii = 0; ii < CB_VT3253B0_INIT_FOR_UW2451; ii++) bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_UW2451[ii][0], byVT3253B0_UW2451[ii][1]); - } + // Init ANT B select,TX Config CR09 = 0x61->0x45, 0x45->0x41(VC1/VC2 define, make the ANT_A, ANT_B inverted) //bResult &= BBbWriteEmbedded(dwIoBase,0x09,0x41); // Init ANT B select,RX Config CR10 = 0x28->0x2A, 0x2A->0x28(VC1/VC2 define, make the ANT_A, ANT_B inverted) @@ -2203,9 +2201,8 @@ bool BBbVT3253Init(PSDevice pDevice) //}} bResult &= BBbWriteEmbedded(dwIoBase, 0xb0, 0x58); - for (ii = 0; ii < CB_VT3253B0_AGC; ii++) { + for (ii = 0; ii < CB_VT3253B0_AGC; ii++) bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]); - } pDevice->abyBBVGA[0] = 0x14; pDevice->abyBBVGA[1] = 0x0A; @@ -2218,12 +2215,12 @@ bool BBbVT3253Init(PSDevice pDevice) //}} RobertYu } else if (byRFType == RF_VT3226) { - for (ii = 0; ii < CB_VT3253B0_INIT_FOR_AIROHA2230; ii++) { + for (ii = 0; ii < CB_VT3253B0_INIT_FOR_AIROHA2230; ii++) bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AIROHA2230[ii][0], byVT3253B0_AIROHA2230[ii][1]); - } - for (ii = 0; ii < CB_VT3253B0_AGC; ii++) { + + for (ii = 0; ii < CB_VT3253B0_AGC; ii++) bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]); - } + pDevice->abyBBVGA[0] = 0x1C; pDevice->abyBBVGA[1] = 0x10; pDevice->abyBBVGA[2] = 0x0; @@ -2236,9 +2233,9 @@ bool BBbVT3253Init(PSDevice pDevice) MACvSetRFLE_LatchBase(dwIoBase); //{{ RobertYu: 20050104 } else if (byRFType == RF_AIROHA7230) { - for (ii = 0; ii < CB_VT3253B0_INIT_FOR_AIROHA2230; ii++) { + for (ii = 0; ii < CB_VT3253B0_INIT_FOR_AIROHA2230; ii++) bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AIROHA2230[ii][0], byVT3253B0_AIROHA2230[ii][1]); - } + //{{ RobertYu:20050223, request by JerryChung // Init ANT B select,TX Config CR09 = 0x61->0x45, 0x45->0x41(VC1/VC2 define, make the ANT_A, ANT_B inverted) @@ -2249,9 +2246,9 @@ bool BBbVT3253Init(PSDevice pDevice) bResult &= BBbWriteEmbedded(dwIoBase, 0xd7, 0x06); //}} - for (ii = 0; ii < CB_VT3253B0_AGC; ii++) { + for (ii = 0; ii < CB_VT3253B0_AGC; ii++) bResult &= BBbWriteEmbedded(dwIoBase, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]); - } + pDevice->abyBBVGA[0] = 0x1C; pDevice->abyBBVGA[1] = 0x10; pDevice->abyBBVGA[2] = 0x0; @@ -2407,17 +2404,15 @@ BBvSetShortSlotTime(PSDevice pDevice) BBbReadEmbedded(pDevice->PortOffset, 0x0A, &byBBRxConf);//CR10 - if (pDevice->bShortSlotTime) { + if (pDevice->bShortSlotTime) byBBRxConf &= 0xDF;//1101 1111 - } else { + else byBBRxConf |= 0x20;//0010 0000 - } // patch for 3253B0 Baseband with Cardbus module BBbReadEmbedded(pDevice->PortOffset, 0xE7, &byBBVGA); - if (byBBVGA == pDevice->abyBBVGA[0]) { + if (byBBVGA == pDevice->abyBBVGA[0]) byBBRxConf |= 0x20;//0010 0000 - } BBbWriteEmbedded(pDevice->PortOffset, 0x0A, byBBRxConf);//CR10 } @@ -2698,9 +2693,8 @@ BBvClearAntDivSQ3Value(PSDevice pDevice) unsigned int ii; pDevice->uDiversityCnt = 0; - for (ii = 0; ii < MAX_RATE; ii++) { + for (ii = 0; ii < MAX_RATE; ii++) pDevice->uNumSQ3[ii] = 0; - } } /* @@ -2721,9 +2715,9 @@ BBvClearAntDivSQ3Value(PSDevice pDevice) void BBvAntennaDiversity(PSDevice pDevice, unsigned char byRxRate, unsigned char bySQ3) { - if ((byRxRate >= MAX_RATE) || (pDevice->wAntDiversityMaxRate >= MAX_RATE)) { + if ((byRxRate >= MAX_RATE) || (pDevice->wAntDiversityMaxRate >= MAX_RATE)) return; - } + pDevice->uDiversityCnt++; pDevice->uNumSQ3[byRxRate]++; diff --git a/drivers/staging/vt6655/bssdb.c b/drivers/staging/vt6655/bssdb.c index d7efd0173a9a..59679cd46816 100644 --- a/drivers/staging/vt6655/bssdb.c +++ b/drivers/staging/vt6655/bssdb.c @@ -497,9 +497,8 @@ BSSbInsertToBSSList( } } - if (bParsingQuiet && (pQuiet != NULL)) { + if (bParsingQuiet && (pQuiet != NULL)) CARDbStartQuiet(pMgmt->pAdapter); - } pBSSList->uIELength = uIELength; if (pBSSList->uIELength > WLAN_BEACON_FR_MAXLEN) @@ -662,9 +661,8 @@ BSSbUpdateToBSSList( } } - if (bParsingQuiet && (pQuiet != NULL)) { + if (bParsingQuiet && (pQuiet != NULL)) CARDbStartQuiet(pMgmt->pAdapter); - } pBSSList->uIELength = uIELength; if (pBSSList->uIELength > WLAN_BEACON_FR_MAXLEN) diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index 702d4eb13583..05bf48a24f45 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -351,9 +351,9 @@ s_vSetRSPINF(PSDevice pDevice, CARD_PHY_TYPE ePHYType, void *pvSupportRateIEs, v bool CARDbIsShortPreamble(void *pDeviceHandler) { PSDevice pDevice = (PSDevice) pDeviceHandler; - if (pDevice->byPreambleType == 0) { + if (pDevice->byPreambleType == 0) return false; - } + return true; } @@ -400,9 +400,9 @@ bool CARDbSetPhyParameter(void *pDeviceHandler, CARD_PHY_TYPE ePHYType, unsigned //Set SIFS, DIFS, EIFS, SlotTime, CwMin if (ePHYType == PHY_TYPE_11A) { - if (pSupportRates == NULL) { + if (pSupportRates == NULL) pSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultSuppRatesA; - } + if (pDevice->byRFType == RF_AIROHA7230) { // AL7230 use single PAPE and connect to PAPE_2.4G MACvSetBBType(pDevice->PortOffset, BB_TYPE_11G); @@ -410,9 +410,9 @@ bool CARDbSetPhyParameter(void *pDeviceHandler, CARD_PHY_TYPE ePHYType, unsigned pDevice->abyBBVGA[2] = 0x10; pDevice->abyBBVGA[3] = 0x10; BBbReadEmbedded(pDevice->PortOffset, 0xE7, &byData); - if (byData == 0x1C) { + if (byData == 0x1C) BBbWriteEmbedded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]); - } + } else if (pDevice->byRFType == RF_UW2452) { MACvSetBBType(pDevice->PortOffset, BB_TYPE_11A); pDevice->abyBBVGA[0] = 0x18; @@ -430,18 +430,18 @@ bool CARDbSetPhyParameter(void *pDeviceHandler, CARD_PHY_TYPE ePHYType, unsigned byDIFS = C_SIFS_A + 2*C_SLOT_SHORT; byCWMaxMin = 0xA4; } else if (ePHYType == PHY_TYPE_11B) { - if (pSupportRates == NULL) { + if (pSupportRates == NULL) pSupportRates = (PWLAN_IE_SUPP_RATES) abyDefaultSuppRatesB; - } + MACvSetBBType(pDevice->PortOffset, BB_TYPE_11B); if (pDevice->byRFType == RF_AIROHA7230) { pDevice->abyBBVGA[0] = 0x1C; pDevice->abyBBVGA[2] = 0x00; pDevice->abyBBVGA[3] = 0x00; BBbReadEmbedded(pDevice->PortOffset, 0xE7, &byData); - if (byData == 0x20) { + if (byData == 0x20) BBbWriteEmbedded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]); - } + } else if (pDevice->byRFType == RF_UW2452) { pDevice->abyBBVGA[0] = 0x14; BBbReadEmbedded(pDevice->PortOffset, 0xE7, &byData); @@ -466,9 +466,9 @@ bool CARDbSetPhyParameter(void *pDeviceHandler, CARD_PHY_TYPE ePHYType, unsigned pDevice->abyBBVGA[2] = 0x00; pDevice->abyBBVGA[3] = 0x00; BBbReadEmbedded(pDevice->PortOffset, 0xE7, &byData); - if (byData == 0x20) { + if (byData == 0x20) BBbWriteEmbedded(pDevice->PortOffset, 0xE7, pDevice->abyBBVGA[0]); - } + } else if (pDevice->byRFType == RF_UW2452) { pDevice->abyBBVGA[0] = 0x14; BBbReadEmbedded(pDevice->PortOffset, 0xE7, &byData); @@ -486,26 +486,25 @@ bool CARDbSetPhyParameter(void *pDeviceHandler, CARD_PHY_TYPE ePHYType, unsigned bySlot = C_SLOT_LONG; byDIFS = C_SIFS_BG + 2*C_SLOT_LONG; } - if (VNTWIFIbyGetMaxSupportRate(pSupportRates, pExtSupportRates) > RATE_11M) { + if (VNTWIFIbyGetMaxSupportRate(pSupportRates, pExtSupportRates) > RATE_11M) byCWMaxMin = 0xA4; - } else { + else byCWMaxMin = 0xA5; - } + if (pDevice->bProtectMode != VNTWIFIbIsProtectMode(byERPField)) { pDevice->bProtectMode = VNTWIFIbIsProtectMode(byERPField); - if (pDevice->bProtectMode) { + if (pDevice->bProtectMode) MACvEnableProtectMD(pDevice->PortOffset); - } else { + else MACvDisableProtectMD(pDevice->PortOffset); - } + } if (pDevice->bBarkerPreambleMd != VNTWIFIbIsBarkerMode(byERPField)) { pDevice->bBarkerPreambleMd = VNTWIFIbIsBarkerMode(byERPField); - if (pDevice->bBarkerPreambleMd) { + if (pDevice->bBarkerPreambleMd) MACvEnableBarkerPreambleMd(pDevice->PortOffset); - } else { + else MACvDisableBarkerPreambleMd(pDevice->PortOffset); - } } } @@ -534,22 +533,22 @@ bool CARDbSetPhyParameter(void *pDeviceHandler, CARD_PHY_TYPE ePHYType, unsigned if (pDevice->bySlot != bySlot) { pDevice->bySlot = bySlot; VNSvOutPortB(pDevice->PortOffset + MAC_REG_SLOT, pDevice->bySlot); - if (pDevice->bySlot == C_SLOT_SHORT) { + if (pDevice->bySlot == C_SLOT_SHORT) pDevice->bShortSlotTime = true; - } else { + else pDevice->bShortSlotTime = false; - } + BBvSetShortSlotTime(pDevice); } if (pDevice->byCWMaxMin != byCWMaxMin) { pDevice->byCWMaxMin = byCWMaxMin; VNSvOutPortB(pDevice->PortOffset + MAC_REG_CWMAXMIN0, pDevice->byCWMaxMin); } - if (VNTWIFIbIsShortPreamble(wCapInfo)) { + if (VNTWIFIbIsShortPreamble(wCapInfo)) pDevice->byPreambleType = pDevice->byShortPreamble; - } else { + else pDevice->byPreambleType = 0; - } + s_vSetRSPINF(pDevice, ePHYType, pSupportRates, pExtSupportRates); pDevice->eCurrentPHYType = ePHYType; // set for NDIS OID_802_11SUPPORTED_RATES @@ -629,9 +628,9 @@ bool CARDbSetBeaconPeriod(void *pDeviceHandler, unsigned short wBeaconInterval) uLowRemain = uBeaconInterval - uLowRemain; // check if carry when add one beacon interval - if ((~uLowNextTBTT) < uLowRemain) { + if ((~uLowNextTBTT) < uLowRemain) HIDWORD(qwNextTBTT)++; - } + LODWORD(qwNextTBTT) = uLowNextTBTT + uLowRemain; // set HW beacon interval @@ -687,15 +686,13 @@ bool CARDbStopTxPacket(void *pDeviceHandler, CARD_PKT_TYPE ePktType) } // wait all TD0 complete if (pDevice->bStopTx0Pkt == true) { - if (pDevice->iTDUsed[TYPE_TXDMA0] != 0) { + if (pDevice->iTDUsed[TYPE_TXDMA0] != 0) return false; - } } // wait all Data TD complete if (pDevice->bStopDataPkt == true) { - if (pDevice->iTDUsed[TYPE_AC0DMA] != 0) { + if (pDevice->iTDUsed[TYPE_AC0DMA] != 0) return false; - } } return true; @@ -759,16 +756,16 @@ bool CARDbSetBSSID(void *pDeviceHandler, unsigned char *pbyBSSID, CARD_OP_MODE e MACvWriteBSSIDAddress(pDevice->PortOffset, pbyBSSID); memcpy(pDevice->abyBSSID, pbyBSSID, WLAN_BSSID_LEN); - if (eOPMode == OP_MODE_ADHOC) { + if (eOPMode == OP_MODE_ADHOC) MACvRegBitsOn(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_ADHOC); - } else { + else MACvRegBitsOff(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_ADHOC); - } - if (eOPMode == OP_MODE_AP) { + + if (eOPMode == OP_MODE_AP) MACvRegBitsOn(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_AP); - } else { + else MACvRegBitsOff(pDevice->PortOffset, MAC_REG_HOSTCR, HOSTCR_AP); - } + if (eOPMode == OP_MODE_UNKNOWN) { MACvRegBitsOff(pDevice->PortOffset, MAC_REG_RCR, RCR_BSSID); pDevice->bBSSIDFilter = false; @@ -1011,31 +1008,31 @@ CARDbAdd_PMKID_Candidate( memset(&pDevice->gsPMKIDCandidate, 0, sizeof(SPMKIDCandidateEvent)); } - for (ii = 0; ii < 6; ii++) { + for (ii = 0; ii < 6; ii++) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02X ", *(pbyBSSID + ii)); - } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "\n"); // Update Old Candidate for (ii = 0; ii < pDevice->gsPMKIDCandidate.NumCandidates; ii++) { pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[ii]; if (!memcmp(pCandidateList->BSSID, pbyBSSID, ETH_ALEN)) { - if (bRSNCapExist && (wRSNCap & BIT0)) { + if (bRSNCapExist && (wRSNCap & BIT0)) pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED; - } else { + else pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED); - } + return true; } } // New Candidate pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[pDevice->gsPMKIDCandidate.NumCandidates]; - if (bRSNCapExist && (wRSNCap & BIT0)) { + if (bRSNCapExist && (wRSNCap & BIT0)) pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED; - } else { + else pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED); - } + memcpy(pCandidateList->BSSID, pbyBSSID, ETH_ALEN); pDevice->gsPMKIDCandidate.NumCandidates++; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "NumCandidates:%d\n", (int)pDevice->gsPMKIDCandidate.NumCandidates); @@ -1116,16 +1113,16 @@ CARDbStartMeasure( // start immediately by setting start TSF == current TSF + 2 TU LODWORD(qwStartTSF) = LODWORD(qwCurrTSF) + 2048; HIDWORD(qwStartTSF) = HIDWORD(qwCurrTSF); - if (LODWORD(qwCurrTSF) > LODWORD(qwStartTSF)) { + if (LODWORD(qwCurrTSF) > LODWORD(qwStartTSF)) HIDWORD(qwStartTSF)++; - } + bExpired = false; break; } else { // start at setting start TSF - 1TU(for channel switching) - if (LODWORD(qwStartTSF) < 1024) { + if (LODWORD(qwStartTSF) < 1024) HIDWORD(qwStartTSF)--; - } + LODWORD(qwStartTSF) -= 1024; } @@ -1214,9 +1211,9 @@ CARDbChannelSwitch( pDevice->byChannelSwitchCount = byCount; pDevice->byNewChannel = byNewChannel; pDevice->bChannelSwitch = true; - if (byMode == 1) { + if (byMode == 1) bResult = CARDbStopTxPacket(pDevice, PKT_TYPE_802_11_ALL); - } + return bResult; } @@ -1249,9 +1246,9 @@ CARDbSetQuiet( if (bResetQuiet) { MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, (MSRCTL_QUIETTXCHK | MSRCTL_QUIETEN)); - for (ii = 0; ii < MAX_QUIET_COUNT; ii++) { + for (ii = 0; ii < MAX_QUIET_COUNT; ii++) pDevice->sQuiet[ii].bEnable = false; - } + pDevice->uQuietEnqueue = 0; pDevice->bEnableFirstQuiet = false; pDevice->bQuietEnable = false; @@ -1266,9 +1263,8 @@ CARDbSetQuiet( pDevice->sQuiet[pDevice->uQuietEnqueue].dwStartTime += wQuietOffset; pDevice->uQuietEnqueue++; pDevice->uQuietEnqueue %= MAX_QUIET_COUNT; - if (pDevice->byQuietStartCount < byQuietCount) { + if (pDevice->byQuietStartCount < byQuietCount) pDevice->byQuietStartCount = byQuietCount; - } } return true; } @@ -1364,9 +1360,9 @@ CARDbStartQuiet( if (pDevice->dwCurrentQuietEndTime > 0x80010000) { // decreament all time to avoid wrap around for (ii = 0; ii < MAX_QUIET_COUNT; ii++) { - if (pDevice->sQuiet[ii].bEnable == true) { + if (pDevice->sQuiet[ii].bEnable == true) pDevice->sQuiet[ii].dwStartTime -= 0x80000000; - } + } pDevice->dwCurrentQuietEndTime -= 0x80000000; } @@ -1398,13 +1394,13 @@ CARDvSetPowerConstraint( PSDevice pDevice = (PSDevice) pDeviceHandler; if (byChannel > CB_MAX_CHANNEL_24G) { - if (pDevice->bCountryInfo5G == true) { + if (pDevice->bCountryInfo5G == true) pDevice->abyLocalPwr[byChannel] = pDevice->abyRegPwr[byChannel] - byPower; - } + } else { - if (pDevice->bCountryInfo24G == true) { + if (pDevice->bCountryInfo24G == true) pDevice->abyLocalPwr[byChannel] = pDevice->abyRegPwr[byChannel] - byPower; - } + } } @@ -1583,9 +1579,9 @@ unsigned short CARDwGetCCKControlRate(void *pDeviceHandler, unsigned short wRate unsigned int ui = (unsigned int) wRateIdx; while (ui > RATE_1M) { - if (pDevice->wBasicRate & ((unsigned short)1 << ui)) { + if (pDevice->wBasicRate & ((unsigned short)1 << ui)) return (unsigned short)ui; - } + ui--; } return (unsigned short)RATE_1M; @@ -1785,11 +1781,11 @@ void vUpdateIFS(void *pDeviceHandler) byMaxMin = 5; } else { // PK_TYPE_11GA & PK_TYPE_11GB pDevice->uSIFS = C_SIFS_BG; - if (pDevice->bShortSlotTime) { + if (pDevice->bShortSlotTime) pDevice->uSlot = C_SLOT_SHORT; - } else { + else pDevice->uSlot = C_SLOT_LONG; - } + pDevice->uDIFS = C_SIFS_BG + 2*pDevice->uSlot; if (pDevice->wBasicRate & 0x0150) { //0000 0001 0101 0000,24M,12M,6M pDevice->uCwMin = C_CWMIN_A; @@ -1871,13 +1867,12 @@ unsigned char CARDbyGetPktType(void *pDeviceHandler) { PSDevice pDevice = (PSDevice) pDeviceHandler; - if (pDevice->byBBType == BB_TYPE_11A || pDevice->byBBType == BB_TYPE_11B) { + if (pDevice->byBBType == BB_TYPE_11A || pDevice->byBBType == BB_TYPE_11B) return (unsigned char)pDevice->byBBType; - } else if (CARDbIsOFDMinBasicRate((void *)pDevice)) { + else if (CARDbIsOFDMinBasicRate((void *)pDevice)) return PK_TYPE_11GA; - } else { + else return PK_TYPE_11GB; - } } /* @@ -1956,9 +1951,9 @@ QWORD CARDqGetTSFOffset(unsigned char byRxRate, QWORD qwTSF1, QWORD qwTSF2) LODWORD(qwTSFOffset) = 0; wRxBcnTSFOffst = cwRXBCNTSFOff[byRxRate%MAX_RATE]; (qwTSF2).u.dwLowDword += (unsigned long)(wRxBcnTSFOffst); - if ((qwTSF2).u.dwLowDword < (unsigned long)(wRxBcnTSFOffst)) { + if ((qwTSF2).u.dwLowDword < (unsigned long)(wRxBcnTSFOffst)) (qwTSF2).u.dwHighDword++; - } + LODWORD(qwTSFOffset) = LODWORD(qwTSF1) - LODWORD(qwTSF2); if (LODWORD(qwTSF1) < LODWORD(qwTSF2)) { // if borrow needed diff --git a/drivers/staging/vt6655/channel.c b/drivers/staging/vt6655/channel.c index e69c312d1242..d5b89b7aaf23 100644 --- a/drivers/staging/vt6655/channel.c +++ b/drivers/staging/vt6655/channel.c @@ -420,9 +420,8 @@ void init_channel_table(void *pDeviceHandler) bool bMultiBand = false; unsigned int ii; - for (ii = 1; ii <= CARD_MAX_CHANNEL_TBL; ii++) { + for (ii = 1; ii <= CARD_MAX_CHANNEL_TBL; ii++) sChannelTbl[ii].bValid = false; - } switch (pDevice->byRFType) { case RF_RFMD2959: @@ -525,13 +524,11 @@ bool set_channel(void *pDeviceHandler, unsigned int uConnectionChannel) PSDevice pDevice = (PSDevice) pDeviceHandler; bool bResult = true; - if (pDevice->byCurrentCh == uConnectionChannel) { + if (pDevice->byCurrentCh == uConnectionChannel) return bResult; - } - if (!sChannelTbl[uConnectionChannel].bValid) { + if (!sChannelTbl[uConnectionChannel].bValid) return false; - } if ((uConnectionChannel > CB_MAX_CHANNEL_24G) && (pDevice->eCurrentPHYType != PHY_TYPE_11A)) { @@ -546,9 +543,8 @@ bool set_channel(void *pDeviceHandler, unsigned int uConnectionChannel) //{{ RobertYu: 20041202 //// TX_PE will reserve 3 us for MAX2829 A mode only, it is for better TX throughput - if (pDevice->byRFType == RF_AIROHA7230) { + if (pDevice->byRFType == RF_AIROHA7230) RFbAL7230SelectChannelPostProcess(pDevice->PortOffset, pDevice->byCurrentCh, (unsigned char)uConnectionChannel); - } //}} RobertYu pDevice->byCurrentCh = (unsigned char)uConnectionChannel; @@ -570,11 +566,10 @@ bool set_channel(void *pDeviceHandler, unsigned int uConnectionChannel) MACvSelectPage0(pDevice->PortOffset); } - if (pDevice->eCurrentPHYType == PHY_TYPE_11B) { + if (pDevice->eCurrentPHYType == PHY_TYPE_11B) RFbSetPower(pDevice, RATE_1M, pDevice->byCurrentCh); - } else { + else RFbSetPower(pDevice, RATE_6M, pDevice->byCurrentCh); - } return bResult; } @@ -601,15 +596,15 @@ void set_country_info(void *pDeviceHandler, CARD_PHY_TYPE ePHYType, void *pIE) if (ePHYType == PHY_TYPE_11A) { pDevice->bCountryInfo5G = true; - for (ii = CB_MAX_CHANNEL_24G + 1; ii <= CARD_MAX_CHANNEL_TBL; ii++) { + for (ii = CB_MAX_CHANNEL_24G + 1; ii <= CARD_MAX_CHANNEL_TBL; ii++) sChannelTbl[ii].bValid = false; - } + step = 4; } else { pDevice->bCountryInfo24G = true; - for (ii = 1; ii <= CB_MAX_CHANNEL_24G; ii++) { + for (ii = 1; ii <= CB_MAX_CHANNEL_24G; ii++) sChannelTbl[ii].bValid = false; - } + step = 1; } pDevice->abyCountryCode[0] = pIE_Country->abyCountryString[0]; @@ -652,19 +647,19 @@ unsigned char set_support_channels(void *pDeviceHandler, unsigned char *pbyIEs) byCount = 0; if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[28] == true) { for (ii = 28; ii < 36; ii += 2) { - if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == true) { + if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == true) byCount++; - } } + *pbyChTupple++ = 34; *pbyChTupple++ = byCount; byLen += 2; } else if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[29] == true) { for (ii = 29; ii < 36; ii += 2) { - if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == true) { + if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == true) byCount++; - } } + *pbyChTupple++ = 36; *pbyChTupple++ = byCount; byLen += 2; @@ -673,10 +668,10 @@ unsigned char set_support_channels(void *pDeviceHandler, unsigned char *pbyIEs) byCount = 0; if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[36] == true) { for (ii = 36; ii < 40; ii++) { - if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == true) { + if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == true) byCount++; - } } + *pbyChTupple++ = 52; *pbyChTupple++ = byCount; byLen += 2; @@ -685,19 +680,19 @@ unsigned char set_support_channels(void *pDeviceHandler, unsigned char *pbyIEs) byCount = 0; if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[40] == true) { for (ii = 40; ii < 51; ii++) { - if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == true) { + if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == true) byCount++; - } } + *pbyChTupple++ = 100; *pbyChTupple++ = byCount; byLen += 2; } else if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[51] == true) { for (ii = 51; ii < 56; ii++) { - if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == true) { + if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] == true) byCount++; - } } + *pbyChTupple++ = 149; *pbyChTupple++ = byCount; byLen += 2; @@ -764,14 +759,13 @@ unsigned char auto_channel_select(void *pDeviceHandler, CARD_PHY_TYPE ePHYType) if (ePHYType == PHY_TYPE_11A) { for (ii = CB_MAX_CHANNEL_24G + 1; ii <= CB_MAX_CHANNEL; ii++) { if (sChannelTbl[ii].bValid) { - if (byOptionChannel == 0) { + if (byOptionChannel == 0) byOptionChannel = (unsigned char) ii; - } - if (sChannelTbl[ii].byMAP == 0) { + + if (sChannelTbl[ii].byMAP == 0) return (unsigned char) ii; - } else if (!(sChannelTbl[ii].byMAP & 0x08)) { + else if (!(sChannelTbl[ii].byMAP & 0x08)) byOptionChannel = (unsigned char) ii; - } } } } else { @@ -781,25 +775,24 @@ unsigned char auto_channel_select(void *pDeviceHandler, CARD_PHY_TYPE ePHYType) if (sChannelTbl[ii].byMAP == 0) { aiWeight[ii] += 100; } else if (sChannelTbl[ii].byMAP & 0x01) { - if (ii > 3) { + if (ii > 3) aiWeight[ii - 3] -= 10; - } - if (ii > 2) { + + if (ii > 2) aiWeight[ii - 2] -= 20; - } - if (ii > 1) { + + if (ii > 1) aiWeight[ii - 1] -= 40; - } + aiWeight[ii] -= 80; - if (ii < CB_MAX_CHANNEL_24G) { + if (ii < CB_MAX_CHANNEL_24G) aiWeight[ii + 1] -= 40; - } - if (ii < (CB_MAX_CHANNEL_24G - 1)) { + + if (ii < (CB_MAX_CHANNEL_24G - 1)) aiWeight[ii+2] -= 20; - } - if (ii < (CB_MAX_CHANNEL_24G - 2)) { + + if (ii < (CB_MAX_CHANNEL_24G - 2)) aiWeight[ii+3] -= 10; - } } } } diff --git a/drivers/staging/vt6655/datarate.c b/drivers/staging/vt6655/datarate.c index 2db662471219..f8420d65cd94 100644 --- a/drivers/staging/vt6655/datarate.c +++ b/drivers/staging/vt6655/datarate.c @@ -253,9 +253,8 @@ RATEvParseMaxRate( } } - if ((pDevice->byPacketType == PK_TYPE_11GB) && CARDbIsOFDMinBasicRate((void *)pDevice)) { + if ((pDevice->byPacketType == PK_TYPE_11GB) && CARDbIsOFDMinBasicRate((void *)pDevice)) pDevice->byPacketType = PK_TYPE_11GA; - } *pbyTopCCKRate = pDevice->byTopCCKBasicRate; *pbyTopOFDMRate = pDevice->byTopOFDMBasicRate; @@ -319,15 +318,14 @@ RATEvTxRateFallBack( return; } - if (psNodeDBTable->uTimeCount >= AUTORATE_TIMEOUT) { + if (psNodeDBTable->uTimeCount >= AUTORATE_TIMEOUT) psNodeDBTable->uTimeCount = 0; - } for (ii = 0; ii < MAX_RATE; ii++) { if (psNodeDBTable->wSuppRate & (0x0001<uTxOk[ii] != 0) || (psNodeDBTable->uTxFail[ii] != 0)) { dwThroughputTbl[ii] *= psNodeDBTable->uTxOk[ii]; - if (ii < RATE_11M) { + if (ii < RATE_11M) psNodeDBTable->uTxFail[ii] *= 4; - } + dwThroughputTbl[ii] /= (psNodeDBTable->uTxOk[ii] + psNodeDBTable->uTxFail[ii]); } } diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 024d84082d76..1d3908d044d0 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -593,9 +593,9 @@ static void device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) pDevice->byRFType &= RF_MASK; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->byRFType = %x\n", pDevice->byRFType); - if (!pDevice->bZoneRegExist) { + if (!pDevice->bZoneRegExist) pDevice->byZoneType = pDevice->abyEEPROM[EEP_OFS_ZONETYPE]; - } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->byZoneType = %x\n", pDevice->byZoneType); //Init RF module @@ -610,13 +610,13 @@ static void device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) for (ii = 0; ii < CB_MAX_CHANNEL_24G; ii++) { pDevice->abyCCKPwrTbl[ii + 1] = SROMbyReadEmbedded(pDevice->PortOffset, (unsigned char)(ii + EEP_OFS_CCK_PWR_TBL)); - if (pDevice->abyCCKPwrTbl[ii + 1] == 0) { + if (pDevice->abyCCKPwrTbl[ii + 1] == 0) pDevice->abyCCKPwrTbl[ii+1] = pDevice->byCCKPwr; - } + pDevice->abyOFDMPwrTbl[ii + 1] = SROMbyReadEmbedded(pDevice->PortOffset, (unsigned char)(ii + EEP_OFS_OFDM_PWR_TBL)); - if (pDevice->abyOFDMPwrTbl[ii + 1] == 0) { + if (pDevice->abyOFDMPwrTbl[ii + 1] == 0) pDevice->abyOFDMPwrTbl[ii + 1] = pDevice->byOFDMPwrG; - } + pDevice->abyCCKDefaultPwr[ii + 1] = byCCKPwrdBm; pDevice->abyOFDMDefaultPwr[ii + 1] = byOFDMPwrdBm; } @@ -672,11 +672,10 @@ static void device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) // Set BB and packet type at the same time. // Set Short Slot Time, xIFS, and RSPINF. - if (pDevice->uConnectionRate == RATE_AUTO) { + if (pDevice->uConnectionRate == RATE_AUTO) pDevice->wCurrentRate = RATE_54M; - } else { + else pDevice->wCurrentRate = (unsigned short)pDevice->uConnectionRate; - } // default G Mode VNTWIFIbConfigPhyMode(pDevice->pMgmt, PHY_TYPE_11G); @@ -692,22 +691,25 @@ static void device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) MACvGPIOIn(pDevice->PortOffset, &pDevice->byGPIO); //2008-4-14 by chester for led issue #ifdef FOR_LED_ON_NOTEBOOK - if (pDevice->byGPIO & GPIO0_DATA) { pDevice->bHWRadioOff = true; } - if (!(pDevice->byGPIO & GPIO0_DATA)) { pDevice->bHWRadioOff = false; } + if (pDevice->byGPIO & GPIO0_DATA) + pDevice->bHWRadioOff = true; + if (!(pDevice->byGPIO & GPIO0_DATA)) + pDevice->bHWRadioOff = false; } - if (pDevice->bRadioControlOff) { + + if (pDevice->bRadioControlOff) CARDbRadioPowerOff(pDevice); - } else CARDbRadioPowerOn(pDevice); + else + CARDbRadioPowerOn(pDevice); #else if (((pDevice->byGPIO & GPIO0_DATA) && !(pDevice->byRadioCtl & EEP_RADIOCTL_INV)) || (!(pDevice->byGPIO & GPIO0_DATA) && (pDevice->byRadioCtl & EEP_RADIOCTL_INV))) { pDevice->bHWRadioOff = true; } } - if (pDevice->bHWRadioOff || pDevice->bRadioControlOff) { + if (pDevice->bHWRadioOff || pDevice->bRadioControlOff) CARDbRadioPowerOff(pDevice); - } #endif } @@ -722,9 +724,8 @@ CARDvSafeResetRx(pDevice); // reset Rx pointer CARDvSafeResetTx(pDevice); -if (pDevice->byLocalID <= REV_ID_VT3253_A1) { +if (pDevice->byLocalID <= REV_ID_VT3253_A1) MACvRegBitsOn(pDevice->PortOffset, MAC_REG_RCR, RCR_WPAERR); -} pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; @@ -1494,9 +1495,9 @@ static int device_tx_srv(PSDevice pDevice, unsigned int uIdx) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Tx[%d] OK but has error. tsr1[%02X] tsr0[%02X].\n", (int)uIdx, byTsr1, byTsr0); } - if ((pTxBufHead->wFragCtl & FRAGCTL_ENDFRAG) != FRAGCTL_NONFRAG) { + if ((pTxBufHead->wFragCtl & FRAGCTL_ENDFRAG) != FRAGCTL_NONFRAG) pDevice->s802_11Counter.TransmittedFragmentCount++; - } + pStats->tx_packets++; pStats->tx_bytes += pTD->pTDInfo->skb->len; } else { @@ -1560,9 +1561,9 @@ static int device_tx_srv(PSDevice pDevice, unsigned int uIdx) { bFull = true; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " AC0DMA is Full = %d\n", pDevice->iTDUsed[uIdx]); } - if (netif_queue_stopped(pDevice->dev) && !bFull) { + if (netif_queue_stopped(pDevice->dev) && !bFull) netif_wake_queue(pDevice->dev); - } + } pDevice->apTailTD[uIdx] = pTD; @@ -1643,9 +1644,9 @@ static int device_open(struct net_device *dev) { #endif pDevice->rx_buf_sz = PKT_BUF_SZ; - if (!device_init_rings(pDevice)) { + if (!device_init_rings(pDevice)) return -ENOMEM; - } + //2008-5-13 by chester i = request_irq(pDevice->pcid->irq, &device_intr, IRQF_SHARED, dev->name, dev); if (i) @@ -1666,9 +1667,9 @@ static int device_open(struct net_device *dev) { device_init_td0_ring(pDevice); device_init_td1_ring(pDevice); - if (pDevice->bDiversityRegCtlON) { + if (pDevice->bDiversityRegCtlON) device_init_diversity_timer(pDevice); - } + vMgrObjectInit(pDevice); vMgrTimerInit(pDevice); @@ -1855,9 +1856,9 @@ bool device_dma0_xmit(PSDevice pDevice, struct sk_buff *skb, unsigned int uNodeI cbFrameBodySize = skb->len - ETH_HLEN; // 802.1H - if (ntohs(pDevice->sTxEthHeader.wType) > ETH_DATA_LEN) { + if (ntohs(pDevice->sTxEthHeader.wType) > ETH_DATA_LEN) cbFrameBodySize += 8; - } + uMACfragNum = cbGetFragCount(pDevice, pTransmitKey, cbFrameBodySize, &pDevice->sTxEthHeader); if (uMACfragNum > AVAIL_TD(pDevice, TYPE_TXDMA0)) { @@ -1868,11 +1869,10 @@ bool device_dma0_xmit(PSDevice pDevice, struct sk_buff *skb, unsigned int uNodeI if (pDevice->bFixRate) { if (pDevice->eCurrentPHYType == PHY_TYPE_11B) { - if (pDevice->uConnectionRate >= RATE_11M) { + if (pDevice->uConnectionRate >= RATE_11M) pDevice->wCurrentRate = RATE_11M; - } else { + else pDevice->wCurrentRate = (unsigned short)pDevice->uConnectionRate; - } } else { if (pDevice->uConnectionRate >= RATE_54M) pDevice->wCurrentRate = RATE_54M; @@ -1884,11 +1884,10 @@ bool device_dma0_xmit(PSDevice pDevice, struct sk_buff *skb, unsigned int uNodeI } //preamble type - if (pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble) { + if (pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble) pDevice->byPreambleType = pDevice->byShortPreamble; - } else { + else pDevice->byPreambleType = PREAMBLE_LONG; - } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dma0: pDevice->wCurrentRate = %d \n", pDevice->wCurrentRate); @@ -1897,11 +1896,10 @@ bool device_dma0_xmit(PSDevice pDevice, struct sk_buff *skb, unsigned int uNodeI } else if (pDevice->eCurrentPHYType == PHY_TYPE_11A) { byPktType = PK_TYPE_11A; } else { - if (pDevice->bProtectMode) { + if (pDevice->bProtectMode) byPktType = PK_TYPE_11GB; - } else { + else byPktType = PK_TYPE_11GA; - } } if (pDevice->bEncryptionEnable) @@ -2023,12 +2021,11 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev) { return 0; } - if (pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble) { + if (pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble) pDevice->byPreambleType = pDevice->byShortPreamble; - - } else { + else pDevice->byPreambleType = PREAMBLE_LONG; - } + bNodeExist = true; } @@ -2049,9 +2046,8 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev) { memcpy(pDevice->sTxEthHeader.abyDstAddr, (unsigned char *)(skb->data), ETH_HLEN); cbFrameBodySize = skb->len - ETH_HLEN; // 802.1H - if (ntohs(pDevice->sTxEthHeader.wType) > ETH_DATA_LEN) { + if (ntohs(pDevice->sTxEthHeader.wType) > ETH_DATA_LEN) cbFrameBodySize += 8; - } if (pDevice->bEncryptionEnable) { bNeedEncryption = true; @@ -2087,9 +2083,9 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev) { pbyBSSID = pDevice->abyBroadcastAddr; if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == false) { pTransmitKey = NULL; - if (pDevice->pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { + if (pDevice->pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG "IBSS and KEY is NULL. [%d]\n", pDevice->pMgmt->eCurrMode); - } else + else DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG "NOT IBSS and KEY is NULL. [%d]\n", pDevice->pMgmt->eCurrMode); } else { bTKIP_UseGTK = true; @@ -2138,11 +2134,10 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev) { #endif if (pDevice->eCurrentPHYType == PHY_TYPE_11B) { - if (pDevice->uConnectionRate >= RATE_11M) { + if (pDevice->uConnectionRate >= RATE_11M) pDevice->wCurrentRate = RATE_11M; - } else { + else pDevice->wCurrentRate = (unsigned short)pDevice->uConnectionRate; - } } else { if ((pDevice->eCurrentPHYType == PHY_TYPE_11A) && (pDevice->uConnectionRate <= RATE_6M)) { @@ -2189,11 +2184,10 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev) { } else if (pDevice->eCurrentPHYType == PHY_TYPE_11A) { byPktType = PK_TYPE_11A; } else { - if (pDevice->bProtectMode) { + if (pDevice->bProtectMode) byPktType = PK_TYPE_11GB; - } else { + else byPktType = PK_TYPE_11GA; - } } if (bNeedEncryption) { @@ -2268,15 +2262,13 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev) { #ifdef TxInSleep pDevice->nTxDataTimeCout = 0; //2008-8-21 chester for send null packet #endif - if (AVAIL_TD(pDevice, TYPE_AC0DMA) <= 1) { + if (AVAIL_TD(pDevice, TYPE_AC0DMA) <= 1) netif_stop_queue(dev); - } pDevice->apCurrTD[TYPE_AC0DMA] = pHeadTD; - if (pDevice->bFixRate) { + if (pDevice->bFixRate) printk("FixRate:Rate is %d,TxPower is %d\n", pDevice->wCurrentRate, pDevice->byCurPwr); - } { unsigned char Protocol_Version; //802.1x Authentication @@ -2343,9 +2335,9 @@ static irqreturn_t device_intr(int irq, void *dev_instance) { //Make sure current page is 0 VNSvInPortB(pDevice->PortOffset + MAC_REG_PAGE1SEL, &byOrgPageSel); - if (byOrgPageSel == 1) { + if (byOrgPageSel == 1) MACvSelectPage0(pDevice->PortOffset); - } else + else byOrgPageSel = 0; MACvReadMIBCounter(pDevice->PortOffset, &dwMIBCounter); @@ -2383,9 +2375,9 @@ static irqreturn_t device_intr(int irq, void *dev_instance) { MACvSelectPage0(pDevice->PortOffset); pDevice->byBasicMap = 0; pDevice->byCCAFraction = 0; - for (ii = 0; ii < 8; ii++) { + for (ii = 0; ii < 8; ii++) pDevice->dwRPIs[ii] = 0; - } + } else { // can not measure because set channel fail // clear measure control @@ -2484,9 +2476,8 @@ static irqreturn_t device_intr(int irq, void *dev_instance) { } pDevice->bBeaconSent = false; - if (pDevice->bEnablePSMode) { + if (pDevice->bEnablePSMode) PSbIsNextTBTTWakeUp((void *)pDevice); - } if ((pDevice->eOPMode == OP_MODE_AP) || (pDevice->eOPMode == OP_MODE_ADHOC)) { @@ -2534,18 +2525,18 @@ static irqreturn_t device_intr(int irq, void *dev_instance) { } - if (pDevice->dwIsr & ISR_RXDMA0) { + if (pDevice->dwIsr & ISR_RXDMA0) max_count += device_rx_srv(pDevice, TYPE_RXDMA0); - } - if (pDevice->dwIsr & ISR_RXDMA1) { + + if (pDevice->dwIsr & ISR_RXDMA1) max_count += device_rx_srv(pDevice, TYPE_RXDMA1); - } - if (pDevice->dwIsr & ISR_TXDMA0) { + + if (pDevice->dwIsr & ISR_TXDMA0) max_count += device_tx_srv(pDevice, TYPE_TXDMA0); - } - if (pDevice->dwIsr & ISR_AC0DMA) { + + if (pDevice->dwIsr & ISR_AC0DMA) max_count += device_tx_srv(pDevice, TYPE_AC0DMA); - } + if (pDevice->dwIsr & ISR_SOFTTIMER1) { if (pDevice->eOPMode == OP_MODE_AP) { if (pDevice->bShortSlotTime) @@ -2566,9 +2557,8 @@ static irqreturn_t device_intr(int irq, void *dev_instance) { break; } - if (byOrgPageSel == 1) { + if (byOrgPageSel == 1) MACvSelectPage1(pDevice->PortOffset); - } spin_unlock_irq(&pDevice->lock); MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE); @@ -3059,9 +3049,9 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { rc = 0; } - if (test_and_set_bit(0, (void *)&(pMgmt->uCmdBusy))) { + if (test_and_set_bit(0, (void *)&(pMgmt->uCmdBusy))) return -EBUSY; - } + rc = private_ioctl(pDevice, rq); clear_bit(0, (void *)&(pMgmt->uCmdBusy)); break; diff --git a/drivers/staging/vt6655/dpc.c b/drivers/staging/vt6655/dpc.c index 37fa4af15927..7ddaf2603ba6 100644 --- a/drivers/staging/vt6655/dpc.c +++ b/drivers/staging/vt6655/dpc.c @@ -181,11 +181,11 @@ s_vProcessRxMACHeader(PSDevice pDevice, unsigned char *pbyRxBufferAddr, cbHeaderSize -= 8; pwType = (unsigned short *)(pbyRxBufferAddr + cbHeaderSize); if (bIsWEP) { - if (bExtIV) { + if (bExtIV) *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 8); // 8 is IV&ExtIV - } else { + else *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 4); // 4 is IV - } + } else { *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN); } @@ -194,11 +194,11 @@ s_vProcessRxMACHeader(PSDevice pDevice, unsigned char *pbyRxBufferAddr, cbHeaderSize -= 2; pwType = (unsigned short *)(pbyRxBufferAddr + cbHeaderSize); if (bIsWEP) { - if (bExtIV) { + if (bExtIV) *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 8); // 8 is IV&ExtIV - } else { + else *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 4); // 4 is IV - } + } else { *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN); } @@ -222,6 +222,7 @@ static unsigned char s_byGetRateIdx(unsigned char byRate) if (acbyRxRate[byRateIdx % MAX_RATE] == byRate) return byRateIdx; } + return 0; } @@ -372,9 +373,9 @@ device_receive_frame( pMACHeader = (PS802_11Header)((unsigned char *)(skb->data) + 8); //PLICE_DEBUG<- if (pDevice->bMeasureInProgress) { - if ((*pbyRsr & RSR_CRCOK) != 0) { + if ((*pbyRsr & RSR_CRCOK) != 0) pDevice->byBasicMap |= 0x01; - } + dwDuration = (FrameSize << 4); dwDuration /= acbyRxRate[*pbyRxRate%MAX_RATE]; if (*pbyRxRate <= RATE_11M) { @@ -391,9 +392,9 @@ device_receive_frame( RFvRSSITodBm(pDevice, *pbyRSSI, &ldBm); ldBmThreshold = -57; for (ii = 7; ii > 0;) { - if (ldBm > ldBmThreshold) { + if (ldBm > ldBmThreshold) break; - } + ldBmThreshold -= 5; ii--; } @@ -428,9 +429,8 @@ device_receive_frame( } if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { - if (s_bAPModeRxCtl(pDevice, pbyFrame, iSANodeIndex)) { + if (s_bAPModeRxCtl(pDevice, pbyFrame, iSANodeIndex)) return false; - } } if (IS_FC_WEP(pbyFrame)) { @@ -480,11 +480,10 @@ device_receive_frame( (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) || (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPA2) || (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) { - if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_TKIP)) { + if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_TKIP)) pDevice->s802_11Counter.TKIPICVErrors++; - } else if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_CCMP)) { + else if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_CCMP)) pDevice->s802_11Counter.CCMPDecryptErrors++; - } } return false; } @@ -639,9 +638,9 @@ device_receive_frame( BBvAntennaDiversity(pDevice, s_byGetRateIdx(*pbyRxRate), 0); } - if (pDevice->byLocalID != REV_ID_VT3253_B1) { + if (pDevice->byLocalID != REV_ID_VT3253_B1) pDevice->uCurrRSSI = *pbyRSSI; - } + pDevice->byCurrSQ = *pbySQ; if ((*pbyRSSI != 0) && @@ -651,11 +650,10 @@ device_receive_frame( pMgmt->pCurrBSS->byRSSIStatCnt++; pMgmt->pCurrBSS->byRSSIStatCnt %= RSSI_STAT_COUNT; pMgmt->pCurrBSS->ldBmAverage[pMgmt->pCurrBSS->byRSSIStatCnt] = ldBm; - for (ii = 0; ii < RSSI_STAT_COUNT; ii++) { - if (pMgmt->pCurrBSS->ldBmAverage[ii] != 0) { + for (ii = 0; ii < RSSI_STAT_COUNT; ii++) + if (pMgmt->pCurrBSS->ldBmAverage[ii] != 0) pMgmt->pCurrBSS->ldBmMAX = max(pMgmt->pCurrBSS->ldBmAverage[ii], ldBm); - } - } + } // ----------------------------------------------- @@ -698,9 +696,8 @@ device_receive_frame( } if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_TKIP)) { - if (bIsWEP) { + if (bIsWEP) FrameSize -= 8; //MIC - } } //-------------------------------------------------------------------------------- @@ -1093,9 +1090,9 @@ static bool s_bHandleRxEncryption( rc4_init(&pDevice->SBox, pDevice->abyPRNG, pKey->uKeyLength + 3); rc4_encrypt(&pDevice->SBox, pbyIV+4, pbyIV+4, PayloadLen); - if (ETHbIsBufferCrc32Ok(pbyIV+4, PayloadLen)) { + if (ETHbIsBufferCrc32Ok(pbyIV+4, PayloadLen)) *pbyNewRsr |= NEWRSR_DECRYPTOK; - } + } } else if ((byDecMode == KEY_CTL_TKIP) || (byDecMode == KEY_CTL_CCMP)) { @@ -1104,11 +1101,11 @@ static bool s_bHandleRxEncryption( PayloadLen -= (WLAN_HDR_ADDR3_LEN + 8 + 4); // 24 is 802.11 header, 8 is IV&ExtIV, 4 is crc *pdwRxTSC47_16 = cpu_to_le32(*(unsigned long *)(pbyIV + 4)); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ExtIV: %lx\n", *pdwRxTSC47_16); - if (byDecMode == KEY_CTL_TKIP) { + if (byDecMode == KEY_CTL_TKIP) *pwRxTSC15_0 = cpu_to_le16(MAKEWORD(*(pbyIV + 2), *pbyIV)); - } else { + else *pwRxTSC15_0 = cpu_to_le16(*(unsigned short *)pbyIV); - } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "TSC0_15: %x\n", *pwRxTSC15_0); if ((byDecMode == KEY_CTL_TKIP) && @@ -1193,9 +1190,9 @@ static bool s_bHostWepRxEncryption( rc4_init(&pDevice->SBox, pDevice->abyPRNG, pKey->uKeyLength + 3); rc4_encrypt(&pDevice->SBox, pbyIV+4, pbyIV+4, PayloadLen); - if (ETHbIsBufferCrc32Ok(pbyIV+4, PayloadLen)) { + if (ETHbIsBufferCrc32Ok(pbyIV+4, PayloadLen)) *pbyNewRsr |= NEWRSR_DECRYPTOK; - } + } } else if ((byDecMode == KEY_CTL_TKIP) || (byDecMode == KEY_CTL_CCMP)) { @@ -1205,11 +1202,11 @@ static bool s_bHostWepRxEncryption( *pdwRxTSC47_16 = cpu_to_le32(*(unsigned long *)(pbyIV + 4)); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ExtIV: %lx\n", *pdwRxTSC47_16); - if (byDecMode == KEY_CTL_TKIP) { + if (byDecMode == KEY_CTL_TKIP) *pwRxTSC15_0 = cpu_to_le16(MAKEWORD(*(pbyIV+2), *pbyIV)); - } else { + else *pwRxTSC15_0 = cpu_to_le16(*(unsigned short *)pbyIV); - } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "TSC0_15: %x\n", *pwRxTSC15_0); if (byDecMode == KEY_CTL_TKIP) { @@ -1322,9 +1319,8 @@ static bool s_bAPModeRxData( if (bRelayAndForward) iDANodeIndex = 0; - if ((pDevice->uAssocCount > 1) && (iDANodeIndex >= 0)) { + if ((pDevice->uAssocCount > 1) && (iDANodeIndex >= 0)) ROUTEbRelay(pDevice, (unsigned char *)(skb->data + cbHeaderOffset), FrameSize, (unsigned int)iDANodeIndex); - } if (bRelayOnly) return false; diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c index 15c574529b21..f55d0fbd842a 100644 --- a/drivers/staging/vt6655/hostap.c +++ b/drivers/staging/vt6655/hostap.c @@ -206,11 +206,11 @@ static int hostap_remove_sta(PSDevice pDevice, { unsigned int uNodeIndex; - if (BSSDBbIsSTAInNodeDB(pDevice->pMgmt, param->sta_addr, &uNodeIndex)) { + if (BSSDBbIsSTAInNodeDB(pDevice->pMgmt, param->sta_addr, &uNodeIndex)) BSSvRemoveOneNode(pDevice, uNodeIndex); - } else { + else return -ENOENT; - } + return 0; } @@ -233,9 +233,9 @@ static int hostap_add_sta(PSDevice pDevice, PSMgmtObject pMgmt = pDevice->pMgmt; unsigned int uNodeIndex; - if (!BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &uNodeIndex)) { + if (!BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &uNodeIndex)) BSSvCreateOneNode((PSDevice)pDevice, &uNodeIndex); - } + memcpy(pMgmt->sNodeDBTable[uNodeIndex].abyMACAddr, param->sta_addr, WLAN_ADDR_LEN); pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_ASSOC; pMgmt->sNodeDBTable[uNodeIndex].wCapInfo = param->u.add_sta.capability; @@ -660,9 +660,8 @@ static int hostap_get_encryption(PSDevice pDevice, } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "hostap_get_encryption: %d\n", iNodeIndex); memset(param->u.crypt.seq, 0, 8); - for (ii = 0; ii < 8; ii++) { + for (ii = 0; ii < 8; ii++) param->u.crypt.seq[ii] = (unsigned char)pMgmt->sNodeDBTable[iNodeIndex].KeyRSC >> (ii * 8); - } return ret; } @@ -767,9 +766,8 @@ int vt6655_hostap_ioctl(PSDevice pDevice, struct iw_point *p) } if ((ret == 0) && ap_ioctl) { - if (copy_to_user(p->pointer, param, p->length)) { + if (copy_to_user(p->pointer, param, p->length)) ret = -EFAULT; - } } out: diff --git a/drivers/staging/vt6655/iwctl.c b/drivers/staging/vt6655/iwctl.c index 9f88fb49f8ca..eb03e68cc04d 100644 --- a/drivers/staging/vt6655/iwctl.c +++ b/drivers/staging/vt6655/iwctl.c @@ -235,11 +235,11 @@ int iwctl_giwscan(struct net_device *dev, //ADD mode memset(&iwe, 0, sizeof(iwe)); iwe.cmd = SIOCGIWMODE; - if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) { + if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) iwe.u.mode = IW_MODE_INFRA; - } else { + else iwe.u.mode = IW_MODE_ADHOC; - } + iwe.len = IW_EV_UINT_LEN; current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN); //ADD frequency @@ -266,13 +266,13 @@ int iwctl_giwscan(struct net_device *dev, iwe.u.qual.level = ldBm; iwe.u.qual.noise = 0; //2008-0409-01, by Einsn Liu - if (-ldBm < 50) { + if (-ldBm < 50) iwe.u.qual.qual = 100; - } else if (-ldBm > 90) { + else if (-ldBm > 90) iwe.u.qual.qual = 0; - } else { + else iwe.u.qual.qual = (40 - (-ldBm - 50)) * 100 / 40; - } + iwe.u.qual.updated = 7; current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN); @@ -280,11 +280,11 @@ int iwctl_giwscan(struct net_device *dev, memset(&iwe, 0, sizeof(iwe)); iwe.cmd = SIOCGIWENCODE; iwe.u.data.length = 0; - if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) { + if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; - } else { + else iwe.u.data.flags = IW_ENCODE_DISABLED; - } + current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, pItemSSID->abySSID); memset(&iwe, 0, sizeof(iwe)); @@ -437,9 +437,9 @@ int iwctl_siwmode(struct net_device *dev, case IW_MODE_ADHOC: if (pMgmt->eConfigMode != WMAC_CONFIG_IBSS_STA) { pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA; - if (pDevice->flags & DEVICE_FLAGS_OPENED) { + if (pDevice->flags & DEVICE_FLAGS_OPENED) pDevice->bCommit = true; - } + } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to ad-hoc \n"); break; @@ -447,9 +447,9 @@ int iwctl_siwmode(struct net_device *dev, case IW_MODE_INFRA: if (pMgmt->eConfigMode != WMAC_CONFIG_ESS_STA) { pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA; - if (pDevice->flags & DEVICE_FLAGS_OPENED) { + if (pDevice->flags & DEVICE_FLAGS_OPENED) pDevice->bCommit = true; - } + } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to infrastructure \n"); break; @@ -461,9 +461,9 @@ int iwctl_siwmode(struct net_device *dev, if (pMgmt->eConfigMode != WMAC_CONFIG_AP) { pMgmt->eConfigMode = WMAC_CONFIG_AP; - if (pDevice->flags & DEVICE_FLAGS_OPENED) { + if (pDevice->flags & DEVICE_FLAGS_OPENED) pDevice->bCommit = true; - } + } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to Access Point \n"); break; @@ -670,9 +670,9 @@ int iwctl_siwap(struct net_device *dev, } } - if (pDevice->flags & DEVICE_FLAGS_OPENED) { + if (pDevice->flags & DEVICE_FLAGS_OPENED) pDevice->bCommit = true; - } + } return rc; } @@ -696,9 +696,8 @@ int iwctl_giwap(struct net_device *dev, if ((pDevice->bLinkPass == false) && (pMgmt->eCurrMode != WMAC_MODE_ESS_AP)) memset(wrq->sa_data, 0, 6); - if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { + if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6); - } wrq->sa_family = ARPHRD_ETHER; @@ -857,9 +856,8 @@ int iwctl_siwessid(struct net_device *dev, DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set essid = %s \n", pItemSSID->abySSID); } - if (pDevice->flags & DEVICE_FLAGS_OPENED) { + if (pDevice->flags & DEVICE_FLAGS_OPENED) pDevice->bCommit = true; - } return 0; } @@ -1038,11 +1036,11 @@ int iwctl_siwrts(struct net_device *dev, int rthr = wrq->value; if (wrq->disabled) rthr = 2312; - if ((rthr < 0) || (rthr > 2312)) { + + if ((rthr < 0) || (rthr > 2312)) rc = -EINVAL; - } else { + else pDevice->wRTSThreshold = rthr; - } } return 0; @@ -1142,9 +1140,8 @@ int iwctl_siwretry(struct net_device *dev, pDevice->byLongRetryLimit = wrq->value; } } - if (wrq->flags & IW_RETRY_LIFETIME) { + if (wrq->flags & IW_RETRY_LIFETIME) pDevice->wMaxTransmitMSDULifetime = wrq->value; - } return rc; } @@ -1214,10 +1211,13 @@ int iwctl_siwencode(struct net_device *dev, } if (dwKeyIndex < 1 && ((wrq->flags & IW_ENCODE_NOKEY) == 0)) {//set default key - if (pDevice->byKeyIndex < WLAN_WEP_NKEYS) { + if (pDevice->byKeyIndex < WLAN_WEP_NKEYS) dwKeyIndex = pDevice->byKeyIndex; - } else dwKeyIndex = 0; - } else dwKeyIndex--; + else + dwKeyIndex = 0; + } else { + dwKeyIndex--; + } // Check the size of the key if (wrq->length > WLAN_WEP232_KEYLEN) { @@ -1241,9 +1241,8 @@ int iwctl_siwencode(struct net_device *dev, memcpy(pDevice->abyKey, extra, wrq->length); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "abyKey: "); - for (ii = 0; ii < wrq->length; ii++) { + for (ii = 0; ii < wrq->length; ii++) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pDevice->abyKey[ii]); - } if (pDevice->flags & DEVICE_FLAGS_OPENED) { spin_lock_irq(&pDevice->lock); @@ -1324,16 +1323,17 @@ int iwctl_giwencode(struct net_device *dev, DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODE\n"); - if (index > WLAN_WEP_NKEYS) { + if (index > WLAN_WEP_NKEYS) return -EINVAL; - } + if (index < 1) {//get default key - if (pDevice->byKeyIndex < WLAN_WEP_NKEYS) { + if (pDevice->byKeyIndex < WLAN_WEP_NKEYS) index = pDevice->byKeyIndex; - } else + else index = 0; - } else + } else { index--; + } memset(abyKey, 0, WLAN_WEP232_KEYLEN); // Check encryption mode @@ -1490,37 +1490,36 @@ int iwctl_siwauth(struct net_device *dev, switch (wrq->flags & IW_AUTH_INDEX) { case IW_AUTH_WPA_VERSION: wpa_version = wrq->value; - if (wrq->value == IW_AUTH_WPA_VERSION_DISABLED) { + if (wrq->value == IW_AUTH_WPA_VERSION_DISABLED) PRINT_K("iwctl_siwauth:set WPADEV to disable at 1??????\n"); - } else if (wrq->value == IW_AUTH_WPA_VERSION_WPA) { + else if (wrq->value == IW_AUTH_WPA_VERSION_WPA) PRINT_K("iwctl_siwauth:set WPADEV to WPA1******\n"); - } else { + else PRINT_K("iwctl_siwauth:set WPADEV to WPA2******\n"); - } break; case IW_AUTH_CIPHER_PAIRWISE: pairwise = wrq->value; - if (pairwise == IW_AUTH_CIPHER_CCMP) { + if (pairwise == IW_AUTH_CIPHER_CCMP) pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled; - } else if (pairwise == IW_AUTH_CIPHER_TKIP) { + else if (pairwise == IW_AUTH_CIPHER_TKIP) pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled; - } else if (pairwise == IW_AUTH_CIPHER_WEP40 || pairwise == IW_AUTH_CIPHER_WEP104) { + else if (pairwise == IW_AUTH_CIPHER_WEP40 || pairwise == IW_AUTH_CIPHER_WEP104) pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; - } else if (pairwise == IW_AUTH_CIPHER_NONE) { - //do nothing,einsn liu - } else pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; + else if (pairwise == IW_AUTH_CIPHER_NONE) + ; /* do nothing,einsn liu */ + else + pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; break; case IW_AUTH_CIPHER_GROUP: if (wpa_version == IW_AUTH_WPA_VERSION_DISABLED) break; if (pairwise == IW_AUTH_CIPHER_NONE) { - if (wrq->value == IW_AUTH_CIPHER_CCMP) { + if (wrq->value == IW_AUTH_CIPHER_CCMP) pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled; - } else { + else pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled; - } } break; case IW_AUTH_KEY_MGMT: @@ -1528,13 +1527,15 @@ int iwctl_siwauth(struct net_device *dev, if (wpa_version == IW_AUTH_WPA_VERSION_WPA2) { if (wrq->value == IW_AUTH_KEY_MGMT_PSK) pMgmt->eAuthenMode = WMAC_AUTH_WPA2PSK; - else pMgmt->eAuthenMode = WMAC_AUTH_WPA2; + else + pMgmt->eAuthenMode = WMAC_AUTH_WPA2; } else if (wpa_version == IW_AUTH_WPA_VERSION_WPA) { - if (wrq->value == 0) { + if (wrq->value == 0) pMgmt->eAuthenMode = WMAC_AUTH_WPANONE; - } else if (wrq->value == IW_AUTH_KEY_MGMT_PSK) + else if (wrq->value == IW_AUTH_KEY_MGMT_PSK) pMgmt->eAuthenMode = WMAC_AUTH_WPAPSK; - else pMgmt->eAuthenMode = WMAC_AUTH_WPA; + else + pMgmt->eAuthenMode = WMAC_AUTH_WPA; } break; @@ -1543,11 +1544,11 @@ int iwctl_siwauth(struct net_device *dev, case IW_AUTH_DROP_UNENCRYPTED: break; case IW_AUTH_80211_AUTH_ALG: - if (wrq->value == IW_AUTH_ALG_OPEN_SYSTEM) { + if (wrq->value == IW_AUTH_ALG_OPEN_SYSTEM) pMgmt->bShareKeyAlgorithm = false; - } else if (wrq->value == IW_AUTH_ALG_SHARED_KEY) { + else if (wrq->value == IW_AUTH_ALG_SHARED_KEY) pMgmt->bShareKeyAlgorithm = true; - } + break; case IW_AUTH_WPA_ENABLED: break; @@ -1630,11 +1631,12 @@ int iwctl_giwgenie(struct net_device *dev, if (pMgmt->wWPAIELen > 0) { wrq->length = pMgmt->wWPAIELen; if (pMgmt->wWPAIELen <= space) { - if (copy_to_user(extra, pMgmt->abyWPAIE, pMgmt->wWPAIELen)) { + if (copy_to_user(extra, pMgmt->abyWPAIE, pMgmt->wWPAIELen)) ret = -EFAULT; - } - } else + + } else { ret = -E2BIG; + } } return ret; @@ -1725,18 +1727,18 @@ int iwctl_siwencodeext(struct net_device *dev, //****set if current action is Network Manager count?? //****this method is so foolish,but there is no other way??? if (param->u.wpa_key.alg_name == WPA_ALG_NONE) { - if (param->u.wpa_key.key_index == 0) { + if (param->u.wpa_key.key_index == 0) pDevice->bwextcount++; - } - if ((pDevice->bwextcount == 1) && (param->u.wpa_key.key_index == 1)) { + + if ((pDevice->bwextcount == 1) && (param->u.wpa_key.key_index == 1)) pDevice->bwextcount++; - } - if ((pDevice->bwextcount == 2) && (param->u.wpa_key.key_index == 2)) { + + if ((pDevice->bwextcount == 2) && (param->u.wpa_key.key_index == 2)) pDevice->bwextcount++; - } - if ((pDevice->bwextcount == 3) && (param->u.wpa_key.key_index == 3)) { + + if ((pDevice->bwextcount == 3) && (param->u.wpa_key.key_index == 3)) pDevice->bwextcount++; - } + } if (pDevice->bwextcount == 4) { printk("SIOCSIWENCODEEXT:Enable WPA WEXT SUPPORT!!!!!\n"); diff --git a/drivers/staging/vt6655/key.c b/drivers/staging/vt6655/key.c index 54de7d0fd37c..09a8bf50527b 100644 --- a/drivers/staging/vt6655/key.c +++ b/drivers/staging/vt6655/key.c @@ -255,9 +255,9 @@ bool KeybSetKey( DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "KeybSetKey(R): \n"); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->bKeyValid: %d\n ", pKey->bKeyValid); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->abyKey: "); - for (ii = 0; ii < pKey->uKeyLength; ii++) { + for (ii = 0; ii < pKey->uKeyLength; ii++) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pKey->abyKey[ii]); - } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "\n"); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->dwTSC47_16: %lx\n ", pKey->dwTSC47_16); @@ -319,9 +319,9 @@ bool KeybSetKey( DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->bKeyValid: %d\n ", pKey->bKeyValid); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->uKeyLength: %d\n ", (int)pKey->uKeyLength); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->abyKey: "); - for (ii = 0; ii < pKey->uKeyLength; ii++) { + for (ii = 0; ii < pKey->uKeyLength; ii++) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pKey->abyKey[ii]); - } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "\n"); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->dwTSC47_16: %lx\n ", pKey->dwTSC47_16); @@ -359,9 +359,9 @@ bool KeybRemoveKey( if (is_broadcast_ether_addr(pbyBSSID)) { // delete all keys if ((dwKeyIndex & PAIRWISE_KEY) != 0) { - for (i = 0; i < MAX_KEY_TABLE; i++) { + for (i = 0; i < MAX_KEY_TABLE; i++) pTable->KeyTable[i].PairwiseKey.bKeyValid = false; - } + s_vCheckKeyTableValid(pTable, dwIoBase); return true; } else if ((dwKeyIndex & 0x000000FF) < MAX_GROUP_KEY) { @@ -427,9 +427,9 @@ bool KeybRemoveAllKey( if (pTable->KeyTable[i].bInUse && ether_addr_equal(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { pTable->KeyTable[i].PairwiseKey.bKeyValid = false; - for (u = 0; u < MAX_GROUP_KEY; u++) { + for (u = 0; u < MAX_GROUP_KEY; u++) pTable->KeyTable[i].GroupKey[u].bKeyValid = false; - } + pTable->KeyTable[i].dwGTKeyIndex = 0; s_vCheckKeyTableValid(pTable, dwIoBase); return true; @@ -478,9 +478,8 @@ void KeyvRemoveAllWEPKey( { int i; - for (i = 0; i < MAX_GROUP_KEY; i++) { + for (i = 0; i < MAX_GROUP_KEY; i++) KeyvRemoveWEPKey(pTable, i, dwIoBase); - } } /* @@ -515,9 +514,9 @@ bool KeybGetTransmitKey( DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "KeybGetTransmitKey:"); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "PAIRWISE_KEY: KeyTable.abyBSSID: "); - for (ii = 0; ii < 6; ii++) { + for (ii = 0; ii < 6; ii++) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%x ", pTable->KeyTable[i].abyBSSID[ii]); - } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "\n"); return true; @@ -536,9 +535,9 @@ bool KeybGetTransmitKey( DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "KeybGetTransmitKey:"); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "GROUP_KEY: KeyTable.abyBSSID\n"); - for (ii = 0; ii < 6; ii++) { + for (ii = 0; ii < 6; ii++) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%x ", pTable->KeyTable[i].abyBSSID[ii]); - } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "\n"); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dwGTKeyIndex: %lX\n", pTable->KeyTable[i].dwGTKeyIndex); @@ -551,9 +550,9 @@ bool KeybGetTransmitKey( } // BSSID match } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ERROR: NO Match BSSID !!! "); - for (ii = 0; ii < 6; ii++) { + for (ii = 0; ii < 6; ii++) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", *(pbyBSSID+ii)); - } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "\n"); return false; } @@ -621,11 +620,10 @@ bool KeybSetDefaultKey( DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enter KeybSetDefaultKey: %1x, %d \n", (int)dwKeyIndex, (int)uKeyLength); - if ((dwKeyIndex & PAIRWISE_KEY) != 0) { // Pairwise key + if ((dwKeyIndex & PAIRWISE_KEY) != 0) // Pairwise key return false; - } else if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) { + else if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) return false; - } if (uKeyLength > MAX_KEY_LEN) return false; @@ -683,9 +681,9 @@ bool KeybSetDefaultKey( DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->bKeyValid: %d\n", pKey->bKeyValid); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->uKeyLength: %d\n", (int)pKey->uKeyLength); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->abyKey: \n"); - for (ii = 0; ii < pKey->uKeyLength; ii++) { + for (ii = 0; ii < pKey->uKeyLength; ii++) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%x", pKey->abyKey[ii]); - } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "\n"); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->dwTSC47_16: %lx\n", pKey->dwTSC47_16); @@ -729,11 +727,10 @@ bool KeybSetAllGroupKey( DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enter KeybSetAllGroupKey: %lX\n", dwKeyIndex); - if ((dwKeyIndex & PAIRWISE_KEY) != 0) { // Pairwise key + if ((dwKeyIndex & PAIRWISE_KEY) != 0) // Pairwise key return false; - } else if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) { + else if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) return false; - } for (i = 0; i < MAX_KEY_TABLE - 1; i++) { if (pTable->KeyTable[i].bInUse) { @@ -779,9 +776,9 @@ bool KeybSetAllGroupKey( DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->bKeyValid: %d\n ", pKey->bKeyValid); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->uKeyLength: %d\n ", (int)pKey->uKeyLength); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pKey->abyKey: "); - for (ii = 0; ii < pKey->uKeyLength; ii++) { + for (ii = 0; ii < pKey->uKeyLength; ii++) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pKey->abyKey[ii]); - } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "\n"); } // (pTable->KeyTable[i].bInUse == true) diff --git a/drivers/staging/vt6655/mac.c b/drivers/staging/vt6655/mac.c index db53e1a57bca..af6876a01ee8 100644 --- a/drivers/staging/vt6655/mac.c +++ b/drivers/staging/vt6655/mac.c @@ -641,16 +641,14 @@ void MACvSaveContext(unsigned long dwIoBase, unsigned char *pbyCxtBuf) int ii; // read page0 register - for (ii = 0; ii < MAC_MAX_CONTEXT_SIZE_PAGE0; ii++) { + for (ii = 0; ii < MAC_MAX_CONTEXT_SIZE_PAGE0; ii++) VNSvInPortB((dwIoBase + ii), (pbyCxtBuf + ii)); - } MACvSelectPage1(dwIoBase); // read page1 register - for (ii = 0; ii < MAC_MAX_CONTEXT_SIZE_PAGE1; ii++) { + for (ii = 0; ii < MAC_MAX_CONTEXT_SIZE_PAGE1; ii++) VNSvInPortB((dwIoBase + ii), (pbyCxtBuf + MAC_MAX_CONTEXT_SIZE_PAGE0 + ii)); - } MACvSelectPage0(dwIoBase); } @@ -675,25 +673,24 @@ void MACvRestoreContext(unsigned long dwIoBase, unsigned char *pbyCxtBuf) MACvSelectPage1(dwIoBase); // restore page1 - for (ii = 0; ii < MAC_MAX_CONTEXT_SIZE_PAGE1; ii++) { + for (ii = 0; ii < MAC_MAX_CONTEXT_SIZE_PAGE1; ii++) VNSvOutPortB((dwIoBase + ii), *(pbyCxtBuf + MAC_MAX_CONTEXT_SIZE_PAGE0 + ii)); - } + MACvSelectPage0(dwIoBase); // restore RCR,TCR,IMR... - for (ii = MAC_REG_RCR; ii < MAC_REG_ISR; ii++) { + for (ii = MAC_REG_RCR; ii < MAC_REG_ISR; ii++) VNSvOutPortB(dwIoBase + ii, *(pbyCxtBuf + ii)); - } + // restore MAC Config. - for (ii = MAC_REG_LRT; ii < MAC_REG_PAGE1SEL; ii++) { + for (ii = MAC_REG_LRT; ii < MAC_REG_PAGE1SEL; ii++) VNSvOutPortB(dwIoBase + ii, *(pbyCxtBuf + ii)); - } + VNSvOutPortB(dwIoBase + MAC_REG_CFG, *(pbyCxtBuf + MAC_REG_CFG)); // restore PS Config. - for (ii = MAC_REG_PSCFG; ii < MAC_REG_BBREGCTL; ii++) { + for (ii = MAC_REG_PSCFG; ii < MAC_REG_BBREGCTL; ii++) VNSvOutPortB(dwIoBase + ii, *(pbyCxtBuf + ii)); - } // restore CURR_RX_DESC_ADDR, CURR_TX_DESC_ADDR VNSvOutPortD(dwIoBase + MAC_REG_TXDMAPTR0, *(unsigned long *)(pbyCxtBuf + MAC_REG_TXDMAPTR0)); @@ -728,24 +725,20 @@ bool MACbCompareContext(unsigned long dwIoBase, unsigned char *pbyCxtBuf) // compare CURR_RX_DESC_ADDR, CURR_TX_DESC_ADDR VNSvInPortD(dwIoBase + MAC_REG_TXDMAPTR0, &dwData); - if (dwData != *(unsigned long *)(pbyCxtBuf + MAC_REG_TXDMAPTR0)) { + if (dwData != *(unsigned long *)(pbyCxtBuf + MAC_REG_TXDMAPTR0)) return false; - } VNSvInPortD(dwIoBase + MAC_REG_AC0DMAPTR, &dwData); - if (dwData != *(unsigned long *)(pbyCxtBuf + MAC_REG_AC0DMAPTR)) { + if (dwData != *(unsigned long *)(pbyCxtBuf + MAC_REG_AC0DMAPTR)) return false; - } VNSvInPortD(dwIoBase + MAC_REG_RXDMAPTR0, &dwData); - if (dwData != *(unsigned long *)(pbyCxtBuf + MAC_REG_RXDMAPTR0)) { + if (dwData != *(unsigned long *)(pbyCxtBuf + MAC_REG_RXDMAPTR0)) return false; - } VNSvInPortD(dwIoBase + MAC_REG_RXDMAPTR1, &dwData); - if (dwData != *(unsigned long *)(pbyCxtBuf + MAC_REG_RXDMAPTR1)) { + if (dwData != *(unsigned long *)(pbyCxtBuf + MAC_REG_RXDMAPTR1)) return false; - } return true; } @@ -1055,21 +1048,21 @@ void MACvSetCurrRx0DescAddr(unsigned long dwIoBase, unsigned long dwCurrDescAddr unsigned char byOrgDMACtl; VNSvInPortB(dwIoBase + MAC_REG_RXDMACTL0, &byOrgDMACtl); - if (byOrgDMACtl & DMACTL_RUN) { + if (byOrgDMACtl & DMACTL_RUN) VNSvOutPortB(dwIoBase + MAC_REG_RXDMACTL0+2, DMACTL_RUN); - } + for (ww = 0; ww < W_MAX_TIMEOUT; ww++) { VNSvInPortB(dwIoBase + MAC_REG_RXDMACTL0, &byData); if (!(byData & DMACTL_RUN)) break; } - if (ww == W_MAX_TIMEOUT) { + + if (ww == W_MAX_TIMEOUT) DBG_PORT80(0x13); - } + VNSvOutPortD(dwIoBase + MAC_REG_RXDMAPTR0, dwCurrDescAddr); - if (byOrgDMACtl & DMACTL_RUN) { + if (byOrgDMACtl & DMACTL_RUN) VNSvOutPortB(dwIoBase + MAC_REG_RXDMACTL0, DMACTL_RUN); - } } /* @@ -1093,21 +1086,21 @@ void MACvSetCurrRx1DescAddr(unsigned long dwIoBase, unsigned long dwCurrDescAddr unsigned char byOrgDMACtl; VNSvInPortB(dwIoBase + MAC_REG_RXDMACTL1, &byOrgDMACtl); - if (byOrgDMACtl & DMACTL_RUN) { + if (byOrgDMACtl & DMACTL_RUN) VNSvOutPortB(dwIoBase + MAC_REG_RXDMACTL1+2, DMACTL_RUN); - } + for (ww = 0; ww < W_MAX_TIMEOUT; ww++) { VNSvInPortB(dwIoBase + MAC_REG_RXDMACTL1, &byData); if (!(byData & DMACTL_RUN)) break; } - if (ww == W_MAX_TIMEOUT) { + if (ww == W_MAX_TIMEOUT) DBG_PORT80(0x14); - } + VNSvOutPortD(dwIoBase + MAC_REG_RXDMAPTR1, dwCurrDescAddr); - if (byOrgDMACtl & DMACTL_RUN) { + if (byOrgDMACtl & DMACTL_RUN) VNSvOutPortB(dwIoBase + MAC_REG_RXDMACTL1, DMACTL_RUN); - } + } /* @@ -1131,21 +1124,20 @@ void MACvSetCurrTx0DescAddrEx(unsigned long dwIoBase, unsigned long dwCurrDescAd unsigned char byOrgDMACtl; VNSvInPortB(dwIoBase + MAC_REG_TXDMACTL0, &byOrgDMACtl); - if (byOrgDMACtl & DMACTL_RUN) { + if (byOrgDMACtl & DMACTL_RUN) VNSvOutPortB(dwIoBase + MAC_REG_TXDMACTL0+2, DMACTL_RUN); - } + for (ww = 0; ww < W_MAX_TIMEOUT; ww++) { VNSvInPortB(dwIoBase + MAC_REG_TXDMACTL0, &byData); if (!(byData & DMACTL_RUN)) break; } - if (ww == W_MAX_TIMEOUT) { + if (ww == W_MAX_TIMEOUT) DBG_PORT80(0x25); - } + VNSvOutPortD(dwIoBase + MAC_REG_TXDMAPTR0, dwCurrDescAddr); - if (byOrgDMACtl & DMACTL_RUN) { + if (byOrgDMACtl & DMACTL_RUN) VNSvOutPortB(dwIoBase + MAC_REG_TXDMACTL0, DMACTL_RUN); - } } /* @@ -1170,9 +1162,9 @@ void MACvSetCurrAC0DescAddrEx(unsigned long dwIoBase, unsigned long dwCurrDescAd unsigned char byOrgDMACtl; VNSvInPortB(dwIoBase + MAC_REG_AC0DMACTL, &byOrgDMACtl); - if (byOrgDMACtl & DMACTL_RUN) { + if (byOrgDMACtl & DMACTL_RUN) VNSvOutPortB(dwIoBase + MAC_REG_AC0DMACTL+2, DMACTL_RUN); - } + for (ww = 0; ww < W_MAX_TIMEOUT; ww++) { VNSvInPortB(dwIoBase + MAC_REG_AC0DMACTL, &byData); if (!(byData & DMACTL_RUN)) @@ -1183,18 +1175,16 @@ void MACvSetCurrAC0DescAddrEx(unsigned long dwIoBase, unsigned long dwCurrDescAd DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " DBG_PORT80(0x26)\n"); } VNSvOutPortD(dwIoBase + MAC_REG_AC0DMAPTR, dwCurrDescAddr); - if (byOrgDMACtl & DMACTL_RUN) { + if (byOrgDMACtl & DMACTL_RUN) VNSvOutPortB(dwIoBase + MAC_REG_AC0DMACTL, DMACTL_RUN); - } } void MACvSetCurrTXDescAddr(int iTxType, unsigned long dwIoBase, unsigned long dwCurrDescAddr) { - if (iTxType == TYPE_AC0DMA) { + if (iTxType == TYPE_AC0DMA) MACvSetCurrAC0DescAddrEx(dwIoBase, dwCurrDescAddr); - } else if (iTxType == TYPE_TXDMA0) { + else if (iTxType == TYPE_TXDMA0) MACvSetCurrTx0DescAddrEx(dwIoBase, dwCurrDescAddr); - } } /* @@ -1384,9 +1374,9 @@ bool MACbPSWakeup(unsigned long dwIoBase) unsigned char byOrgValue; unsigned int ww; // Read PSCTL - if (MACbIsRegBitsOff(dwIoBase, MAC_REG_PSCTL, PSCTL_PS)) { + if (MACbIsRegBitsOff(dwIoBase, MAC_REG_PSCTL, PSCTL_PS)) return true; - } + // Disable PS MACvRegBitsOff(dwIoBase, MAC_REG_PSCTL, PSCTL_PSEN); @@ -1535,9 +1525,9 @@ void MACvSetDefaultKeyEntry(unsigned long dwIoBase, unsigned int uKeyLen, VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE); } dwData = *pdwKey; - if (uKeyLen == WLAN_WEP104_KEYLEN) { + if (uKeyLen == WLAN_WEP104_KEYLEN) dwData |= 0x80000000; - } + VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset+3); VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, dwData); VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE); diff --git a/drivers/staging/vt6655/mib.c b/drivers/staging/vt6655/mib.c index 881c05413cb6..36895970a892 100644 --- a/drivers/staging/vt6655/mib.c +++ b/drivers/staging/vt6655/mib.c @@ -187,75 +187,75 @@ void STAvUpdateRDStatCounter(PSStatCounter pStatistic, if (byRxRate == 22) { pStatistic->CustomStat.ullRsr11M++; - if (byRSR & RSR_CRCOK) { + if (byRSR & RSR_CRCOK) pStatistic->CustomStat.ullRsr11MCRCOk++; - } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "11M: ALL[%d], OK[%d]:[%02x]\n", (int)pStatistic->CustomStat.ullRsr11M, (int)pStatistic->CustomStat.ullRsr11MCRCOk, byRSR); } else if (byRxRate == 11) { pStatistic->CustomStat.ullRsr5M++; - if (byRSR & RSR_CRCOK) { + if (byRSR & RSR_CRCOK) pStatistic->CustomStat.ullRsr5MCRCOk++; - } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " 5M: ALL[%d], OK[%d]:[%02x]\n", (int)pStatistic->CustomStat.ullRsr5M, (int)pStatistic->CustomStat.ullRsr5MCRCOk, byRSR); } else if (byRxRate == 4) { pStatistic->CustomStat.ullRsr2M++; - if (byRSR & RSR_CRCOK) { + if (byRSR & RSR_CRCOK) pStatistic->CustomStat.ullRsr2MCRCOk++; - } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " 2M: ALL[%d], OK[%d]:[%02x]\n", (int)pStatistic->CustomStat.ullRsr2M, (int)pStatistic->CustomStat.ullRsr2MCRCOk, byRSR); } else if (byRxRate == 2) { pStatistic->CustomStat.ullRsr1M++; - if (byRSR & RSR_CRCOK) { + if (byRSR & RSR_CRCOK) pStatistic->CustomStat.ullRsr1MCRCOk++; - } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " 1M: ALL[%d], OK[%d]:[%02x]\n", (int)pStatistic->CustomStat.ullRsr1M, (int)pStatistic->CustomStat.ullRsr1MCRCOk, byRSR); } else if (byRxRate == 12) { pStatistic->CustomStat.ullRsr6M++; - if (byRSR & RSR_CRCOK) { + if (byRSR & RSR_CRCOK) pStatistic->CustomStat.ullRsr6MCRCOk++; - } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " 6M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr6M, (int)pStatistic->CustomStat.ullRsr6MCRCOk); } else if (byRxRate == 18) { pStatistic->CustomStat.ullRsr9M++; - if (byRSR & RSR_CRCOK) { + if (byRSR & RSR_CRCOK) pStatistic->CustomStat.ullRsr9MCRCOk++; - } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " 9M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr9M, (int)pStatistic->CustomStat.ullRsr9MCRCOk); } else if (byRxRate == 24) { pStatistic->CustomStat.ullRsr12M++; - if (byRSR & RSR_CRCOK) { + if (byRSR & RSR_CRCOK) pStatistic->CustomStat.ullRsr12MCRCOk++; - } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "12M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr12M, (int)pStatistic->CustomStat.ullRsr12MCRCOk); } else if (byRxRate == 36) { pStatistic->CustomStat.ullRsr18M++; - if (byRSR & RSR_CRCOK) { + if (byRSR & RSR_CRCOK) pStatistic->CustomStat.ullRsr18MCRCOk++; - } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "18M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr18M, (int)pStatistic->CustomStat.ullRsr18MCRCOk); } else if (byRxRate == 48) { pStatistic->CustomStat.ullRsr24M++; - if (byRSR & RSR_CRCOK) { + if (byRSR & RSR_CRCOK) pStatistic->CustomStat.ullRsr24MCRCOk++; - } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "24M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr24M, (int)pStatistic->CustomStat.ullRsr24MCRCOk); } else if (byRxRate == 72) { pStatistic->CustomStat.ullRsr36M++; - if (byRSR & RSR_CRCOK) { + if (byRSR & RSR_CRCOK) pStatistic->CustomStat.ullRsr36MCRCOk++; - } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "36M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr36M, (int)pStatistic->CustomStat.ullRsr36MCRCOk); } else if (byRxRate == 96) { pStatistic->CustomStat.ullRsr48M++; - if (byRSR & RSR_CRCOK) { + if (byRSR & RSR_CRCOK) pStatistic->CustomStat.ullRsr48MCRCOk++; - } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "48M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr48M, (int)pStatistic->CustomStat.ullRsr48MCRCOk); } else if (byRxRate == 108) { pStatistic->CustomStat.ullRsr54M++; - if (byRSR & RSR_CRCOK) { + if (byRSR & RSR_CRCOK) pStatistic->CustomStat.ullRsr54MCRCOk++; - } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "54M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr54M, (int)pStatistic->CustomStat.ullRsr54MCRCOk); } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unknown: Total[%d], CRCOK[%d]\n", (int)pStatistic->dwRsrRxPacket+1, (int)pStatistic->dwRsrCRCOk); @@ -288,13 +288,12 @@ void STAvUpdateRDStatCounter(PSStatCounter pStatistic, pStatistic->dwRsrRxPacket++; pStatistic->dwRsrRxOctet += cbFrameLength; - if (IS_TYPE_DATA(pbyBuffer)) { + if (IS_TYPE_DATA(pbyBuffer)) pStatistic->dwRsrRxData++; - } else if (IS_TYPE_MGMT(pbyBuffer)) { + else if (IS_TYPE_MGMT(pbyBuffer)) pStatistic->dwRsrRxManage++; - } else if (IS_TYPE_CONTROL(pbyBuffer)) { + else if (IS_TYPE_CONTROL(pbyBuffer)) pStatistic->dwRsrRxControl++; - } if (byRSR & RSR_ADDRBROAD) pStatistic->dwRsrBroadcast++; @@ -306,23 +305,22 @@ void STAvUpdateRDStatCounter(PSStatCounter pStatistic, if (WLAN_GET_FC_MOREFRAG(pHeader->wFrameCtl)) pStatistic->dwRsrRxFragment++; - if (cbFrameLength < ETH_ZLEN + 4) { + if (cbFrameLength < ETH_ZLEN + 4) pStatistic->dwRsrRunt++; - } else if (cbFrameLength == ETH_ZLEN + 4) { + else if (cbFrameLength == ETH_ZLEN + 4) pStatistic->dwRsrRxFrmLen64++; - } else if ((65 <= cbFrameLength) && (cbFrameLength <= 127)) { + else if ((65 <= cbFrameLength) && (cbFrameLength <= 127)) pStatistic->dwRsrRxFrmLen65_127++; - } else if ((128 <= cbFrameLength) && (cbFrameLength <= 255)) { + else if ((128 <= cbFrameLength) && (cbFrameLength <= 255)) pStatistic->dwRsrRxFrmLen128_255++; - } else if ((256 <= cbFrameLength) && (cbFrameLength <= 511)) { + else if ((256 <= cbFrameLength) && (cbFrameLength <= 511)) pStatistic->dwRsrRxFrmLen256_511++; - } else if ((512 <= cbFrameLength) && (cbFrameLength <= 1023)) { + else if ((512 <= cbFrameLength) && (cbFrameLength <= 1023)) pStatistic->dwRsrRxFrmLen512_1023++; - } else if ((1024 <= cbFrameLength) && (cbFrameLength <= ETH_FRAME_LEN + 4)) { + else if ((1024 <= cbFrameLength) && (cbFrameLength <= ETH_FRAME_LEN + 4)) pStatistic->dwRsrRxFrmLen1024_1518++; - } else if (cbFrameLength > ETH_FRAME_LEN + 4) { + else if (cbFrameLength > ETH_FRAME_LEN + 4) pStatistic->dwRsrLong++; - } } /* @@ -399,11 +397,11 @@ STAvUpdateTDStatCounter( unsigned char byTSR0_NCR = byTSR0 & TSR0_NCR; pHeader = (PWLAN_80211HDR_A4) pbyBuffer; - if (WLAN_GET_FC_TODS(pHeader->wFrameCtl) == 0) { + if (WLAN_GET_FC_TODS(pHeader->wFrameCtl) == 0) pbyDestAddr = &(pHeader->abyAddr1[0]); - } else { + else pbyDestAddr = &(pHeader->abyAddr3[0]); - } + // increase tx packet count pStatistic->dwTsrTxPacket[uIdx]++; pStatistic->dwTsrTxOctet[uIdx] += cbFrameLength; diff --git a/drivers/staging/vt6655/michael.c b/drivers/staging/vt6655/michael.c index 948658604b17..edee48777aac 100644 --- a/drivers/staging/vt6655/michael.c +++ b/drivers/staging/vt6655/michael.c @@ -137,9 +137,9 @@ void MIC_vGetMIC(u32 *pdwL, u32 *pdwR) s_vAppendByte(0); s_vAppendByte(0); // and then zeroes until the length is a multiple of 4 - while (nBytesInM != 0) { + while (nBytesInM != 0) s_vAppendByte(0); - } + // The s_vAppendByte function has already computed the result. *pdwL = L; *pdwR = R; diff --git a/drivers/staging/vt6655/power.c b/drivers/staging/vt6655/power.c index bc6186df5d30..5dfa911c6f49 100644 --- a/drivers/staging/vt6655/power.c +++ b/drivers/staging/vt6655/power.c @@ -145,9 +145,9 @@ PSvDisablePowerSaving( pDevice->bEnablePSMode = false; - if (pDevice->eOPMode == OP_MODE_INFRASTRUCTURE) { + if (pDevice->eOPMode == OP_MODE_INFRASTRUCTURE) PSbSendNullPacket(pDevice); - } + pDevice->bPWBitOn = false; return; } @@ -276,17 +276,15 @@ PSbSendNullPacket( PSMgmtObject pMgmt = pDevice->pMgmt; unsigned int uIdx; - if (!pDevice->bLinkPass) { + if (!pDevice->bLinkPass) return false; - } + #ifdef TxInSleep - if (!pDevice->bEnablePSMode && !pDevice->fTxDataInSleep) { + if (!pDevice->bEnablePSMode && !pDevice->fTxDataInSleep) return false; - } #else - if (!pDevice->bEnablePSMode) { + if (!pDevice->bEnablePSMode) return false; - } #endif if (pDevice->bEnablePSMode) { for (uIdx = 0; uIdx < TYPE_MAXTD; uIdx++) { @@ -315,9 +313,8 @@ PSbSendNullPacket( )); } - if (pMgmt->eCurrMode != WMAC_MODE_IBSS_STA) { + if (pMgmt->eCurrMode != WMAC_MODE_IBSS_STA) pTxPacket->p80211Header->sA3.wFrameCtl |= cpu_to_le16((unsigned short)WLAN_SET_FC_TODS(1)); - } memcpy(pTxPacket->p80211Header->sA3.abyAddr1, pMgmt->abyCurrBSSID, WLAN_ADDR_LEN); memcpy(pTxPacket->p80211Header->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); @@ -353,9 +350,8 @@ PSbIsNextTBTTWakeUp( bool bWakeUp = false; if (pMgmt->wListenInterval >= 2) { - if (pMgmt->wCountToWakeUp == 0) { + if (pMgmt->wCountToWakeUp == 0) pMgmt->wCountToWakeUp = pMgmt->wListenInterval; - } pMgmt->wCountToWakeUp--; diff --git a/drivers/staging/vt6655/rf.c b/drivers/staging/vt6655/rf.c index b379f4f8bb5f..99c89a14d89b 100644 --- a/drivers/staging/vt6655/rf.c +++ b/drivers/staging/vt6655/rf.c @@ -834,13 +834,12 @@ bool RFvWriteWakeProgSyn(unsigned long dwIoBase, unsigned char byRFType, unsigne byInitCount = CB_AL2230_INIT_SEQ + 2; // Init Reg + Channel Reg (2) bySleepCount = 0; - if (byInitCount > (MISCFIFO_SYNDATASIZE - bySleepCount)) { + if (byInitCount > (MISCFIFO_SYNDATASIZE - bySleepCount)) return false; - } - for (ii = 0; ii < CB_AL2230_INIT_SEQ; ii++) { + for (ii = 0; ii < CB_AL2230_INIT_SEQ; ii++) MACvSetMISCFifo(dwIoBase, (unsigned short)(MISCFIFO_SYNDATA_IDX + ii), dwAL2230InitTable[ii]); - } + MACvSetMISCFifo(dwIoBase, (unsigned short)(MISCFIFO_SYNDATA_IDX + ii), dwAL2230ChannelTable0[uChannel-1]); ii++; MACvSetMISCFifo(dwIoBase, (unsigned short)(MISCFIFO_SYNDATA_IDX + ii), dwAL2230ChannelTable1[uChannel-1]); @@ -851,18 +850,15 @@ bool RFvWriteWakeProgSyn(unsigned long dwIoBase, unsigned char byRFType, unsigne case RF_AIROHA7230: byInitCount = CB_AL7230_INIT_SEQ + 3; // Init Reg + Channel Reg (3) bySleepCount = 0; - if (byInitCount > (MISCFIFO_SYNDATASIZE - bySleepCount)) { + if (byInitCount > (MISCFIFO_SYNDATASIZE - bySleepCount)) return false; - } if (uChannel <= CB_MAX_CHANNEL_24G) { - for (ii = 0; ii < CB_AL7230_INIT_SEQ; ii++) { + for (ii = 0; ii < CB_AL7230_INIT_SEQ; ii++) MACvSetMISCFifo(dwIoBase, (unsigned short)(MISCFIFO_SYNDATA_IDX + ii), dwAL7230InitTable[ii]); - } } else { - for (ii = 0; ii < CB_AL7230_INIT_SEQ; ii++) { + for (ii = 0; ii < CB_AL7230_INIT_SEQ; ii++) MACvSetMISCFifo(dwIoBase, (unsigned short)(MISCFIFO_SYNDATA_IDX + ii), dwAL7230InitTableAMode[ii]); - } } MACvSetMISCFifo(dwIoBase, (unsigned short)(MISCFIFO_SYNDATA_IDX + ii), dwAL7230ChannelTable0[uChannel-1]); @@ -911,12 +907,11 @@ bool RFbSetPower( unsigned char byDec = 0; unsigned char byPwrdBm = 0; - if (pDevice->dwDiagRefCount != 0) { + if (pDevice->dwDiagRefCount != 0) return true; - } - if ((uCH < 1) || (uCH > CB_MAX_CHANNEL)) { + + if ((uCH < 1) || (uCH > CB_MAX_CHANNEL)) return false; - } switch (uRATE) { case RATE_1M: @@ -930,14 +925,14 @@ bool RFbSetPower( case RATE_9M: case RATE_18M: byPwr = pDevice->abyOFDMPwrTbl[uCH]; - if (pDevice->byRFType == RF_UW2452) { + if (pDevice->byRFType == RF_UW2452) byDec = byPwr + 14; - } else { + else byDec = byPwr + 10; - } - if (byDec >= pDevice->byMaxPwrLevel) { + + if (byDec >= pDevice->byMaxPwrLevel) byDec = pDevice->byMaxPwrLevel-1; - } + if (pDevice->byRFType == RF_UW2452) { byPwrdBm = byDec - byPwr; byPwrdBm /= 3; @@ -945,6 +940,7 @@ bool RFbSetPower( byPwrdBm = byDec - byPwr; byPwrdBm >>= 1; } + byPwrdBm += pDevice->abyOFDMDefaultPwr[uCH]; byPwr = byDec; break; @@ -957,14 +953,13 @@ bool RFbSetPower( break; } - if (pDevice->byCurPwr == byPwr) { + if (pDevice->byCurPwr == byPwr) return true; - } bResult = RFbRawSetPower(pDevice, byPwr, uRATE); - if (bResult) { + if (bResult) pDevice->byCurPwr = byPwr; - } + return bResult; } @@ -991,17 +986,17 @@ bool RFbRawSetPower( bool bResult = true; unsigned long dwMax7230Pwr = 0; - if (byPwr >= pDevice->byMaxPwrLevel) { + if (byPwr >= pDevice->byMaxPwrLevel) return false; - } + switch (pDevice->byRFType) { case RF_AIROHA: bResult &= IFRFbWriteEmbedded(pDevice->PortOffset, dwAL2230PowerTable[byPwr]); - if (uRATE <= RATE_11M) { + if (uRATE <= RATE_11M) bResult &= IFRFbWriteEmbedded(pDevice->PortOffset, 0x0001B400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); - } else { + else bResult &= IFRFbWriteEmbedded(pDevice->PortOffset, 0x0005A400+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW); - } + break; case RF_AL2230S: diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index e9642458f595..2219d71885a8 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -229,14 +229,14 @@ s_vFillTxKey( *pdwIV |= (unsigned long)byKeyIndex << 30; *pdwIV = cpu_to_le32(*pdwIV); pDevice->dwIVCounter++; - if (pDevice->dwIVCounter > WEP_IV_MASK) { + if (pDevice->dwIVCounter > WEP_IV_MASK) pDevice->dwIVCounter = 0; - } + } else if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) { pTransmitKey->wTSC15_0++; - if (pTransmitKey->wTSC15_0 == 0) { + if (pTransmitKey->wTSC15_0 == 0) pTransmitKey->dwTSC47_16++; - } + TKIPvMixKey(pTransmitKey->abyKey, pDevice->abyCurrentNetAddr, pTransmitKey->wTSC15_0, pTransmitKey->dwTSC47_16, pDevice->abyPRNG); memcpy(pbyBuf, pDevice->abyPRNG, 16); @@ -250,9 +250,9 @@ s_vFillTxKey( } else if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) { pTransmitKey->wTSC15_0++; - if (pTransmitKey->wTSC15_0 == 0) { + if (pTransmitKey->wTSC15_0 == 0) pTransmitKey->dwTSC47_16++; - } + memcpy(pbyBuf, pTransmitKey->abyKey, 16); // Make IV @@ -277,11 +277,11 @@ s_vFillTxKey( //Fill MICHDR1 *((unsigned char *)(pMICHDR+16)) = 0; // HLEN[15:8] - if (pDevice->bLongHeader) { + if (pDevice->bLongHeader) *((unsigned char *)(pMICHDR+17)) = 28; // HLEN[7:0] - } else { + else *((unsigned char *)(pMICHDR+17)) = 22; // HLEN[7:0] - } + wValue = cpu_to_le16(pMACHeader->wFrameCtl & 0xC78F); memcpy(pMICHDR+18, (unsigned char *)&wValue, 2); // MSKFRACTL memcpy(pMICHDR+20, &(pMACHeader->abyAddr1[0]), 6); @@ -293,9 +293,9 @@ s_vFillTxKey( wValue &= 0x000F; wValue = cpu_to_le16(wValue); memcpy(pMICHDR+38, (unsigned char *)&wValue, 2); // MSKSEQCTL - if (pDevice->bLongHeader) { + if (pDevice->bLongHeader) memcpy(pMICHDR+40, &(pMACHeader->abyAddr4[0]), 6); - } + } } @@ -358,17 +358,15 @@ s_uGetTxRsvTime( unsigned int uDataTime, uAckTime; uDataTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, cbFrameLength, wRate); - if (byPktType == PK_TYPE_11B) {//llb,CCK mode + if (byPktType == PK_TYPE_11B) //llb,CCK mode uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, (unsigned short)pDevice->byTopCCKBasicRate); - } else {//11g 2.4G OFDM mode & 11a 5G OFDM mode + else //11g 2.4G OFDM mode & 11a 5G OFDM mode uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, (unsigned short)pDevice->byTopOFDMBasicRate); - } - if (bNeedAck) { + if (bNeedAck) return uDataTime + pDevice->uSIFS + uAckTime; - } else { + else return uDataTime; - } } //byFreqType: 0=>5GHZ 1=>2.4GHZ @@ -428,9 +426,8 @@ s_uGetDataDuration( bool bLastFrag = 0; unsigned int uAckTime = 0, uNextPktTime = 0; - if (uFragIdx == (uMACfragNum-1)) { + if (uFragIdx == (uMACfragNum-1)) bLastFrag = 1; - } switch (byDurType) { case DATADUR_B: //DATADUR_B @@ -442,11 +439,11 @@ s_uGetDataDuration( return 0; } } else {//First Frag or Mid Frag - if (uFragIdx == (uMACfragNum-2)) { + if (uFragIdx == (uMACfragNum-2)) uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wRate, bNeedAck); - } else { + else uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck); - } + if (bNeedAck) { uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); return pDevice->uSIFS + uAckTime + uNextPktTime; @@ -465,11 +462,11 @@ s_uGetDataDuration( return 0; } } else {//First Frag or Mid Frag - if (uFragIdx == (uMACfragNum-2)) { + if (uFragIdx == (uMACfragNum-2)) uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wRate, bNeedAck); - } else { + else uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck); - } + if (bNeedAck) { uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); return pDevice->uSIFS + uAckTime + uNextPktTime; @@ -494,22 +491,22 @@ s_uGetDataDuration( else if (wRate > RATE_54M) wRate = RATE_54M; - if (uFragIdx == (uMACfragNum-2)) { + if (uFragIdx == (uMACfragNum-2)) uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck); - } else { + else uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck); - } + } else { // (byFBOption == AUTO_FB_1) if (wRate < RATE_18M) wRate = RATE_18M; else if (wRate > RATE_54M) wRate = RATE_54M; - if (uFragIdx == (uMACfragNum-2)) { + if (uFragIdx == (uMACfragNum-2)) uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck); - } else { + else uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck); - } + } if (bNeedAck) { @@ -536,11 +533,10 @@ s_uGetDataDuration( else if (wRate > RATE_54M) wRate = RATE_54M; - if (uFragIdx == (uMACfragNum-2)) { + if (uFragIdx == (uMACfragNum-2)) uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck); - } else { + else uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck); - } } else { // (byFBOption == AUTO_FB_1) if (wRate < RATE_18M) @@ -548,11 +544,10 @@ s_uGetDataDuration( else if (wRate > RATE_54M) wRate = RATE_54M; - if (uFragIdx == (uMACfragNum-2)) { + if (uFragIdx == (uMACfragNum-2)) uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck); - } else { + else uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck); - } } if (bNeedAck) { uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); @@ -608,54 +603,54 @@ s_uGetRTSCTSDuration( case RTSDUR_BA_F0: //RTSDuration_ba_f0 uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); - if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) { + if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) uDurTime = uCTSTime + 2 * pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck); - } else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) { + else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) uDurTime = uCTSTime + 2 * pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck); - } + break; case RTSDUR_AA_F0: //RTSDuration_aa_f0 uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); - if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) { + if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck); - } else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) { + else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck); - } + break; case RTSDUR_BA_F1: //RTSDuration_ba_f1 uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); - if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) { + if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck); - } else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) { + else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck); - } + break; case RTSDUR_AA_F1: //RTSDuration_aa_f1 uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); - if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) { + if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck); - } else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) { + else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck); - } + break; case CTSDUR_BA_F0: //CTSDuration_ba_f0 - if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) { + if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck); - } else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) { + else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck); - } + break; case CTSDUR_BA_F1: //CTSDuration_ba_f1 - if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) { + if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck); - } else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) { + else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <= RATE_54M)) uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck); - } + break; default: @@ -683,9 +678,9 @@ s_uFillDataHead( { unsigned short wLen = 0x0000; - if (pTxDataHead == NULL) { + if (pTxDataHead == NULL) return 0; - } + if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { if (byFBOption == AUTO_FB_NONE) { @@ -848,11 +843,11 @@ s_vFillRTSHead( } else { memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), ETH_ALEN); } - if (pDevice->eOPMode == OP_MODE_AP) { + if (pDevice->eOPMode == OP_MODE_AP) memcpy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), ETH_ALEN); - } else { + else memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), ETH_ALEN); - } + } else { PSRTS_g_FB pBuf = (PSRTS_g_FB)pvRTS; //Get SignalField,ServiceField,Length @@ -884,11 +879,10 @@ s_vFillRTSHead( memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), ETH_ALEN); } - if (pDevice->eOPMode == OP_MODE_AP) { + if (pDevice->eOPMode == OP_MODE_AP) memcpy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), ETH_ALEN); - } else { + else memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), ETH_ALEN); - } } // if (byFBOption == AUTO_FB_NONE) } else if (byPktType == PK_TYPE_11A) { @@ -912,11 +906,10 @@ s_vFillRTSHead( memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), ETH_ALEN); } - if (pDevice->eOPMode == OP_MODE_AP) { + if (pDevice->eOPMode == OP_MODE_AP) memcpy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), ETH_ALEN); - } else { + else memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), ETH_ALEN); - } } else { PSRTS_a_FB pBuf = (PSRTS_a_FB)pvRTS; @@ -939,11 +932,10 @@ s_vFillRTSHead( } else { memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), ETH_ALEN); } - if (pDevice->eOPMode == OP_MODE_AP) { + if (pDevice->eOPMode == OP_MODE_AP) memcpy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), ETH_ALEN); - } else { + else memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), ETH_ALEN); - } } } else if (byPktType == PK_TYPE_11B) { PSRTS_ab pBuf = (PSRTS_ab)pvRTS; @@ -965,11 +957,10 @@ s_vFillRTSHead( memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), ETH_ALEN); } - if (pDevice->eOPMode == OP_MODE_AP) { + if (pDevice->eOPMode == OP_MODE_AP) memcpy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), ETH_ALEN); - } else { + else memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), ETH_ALEN); - } } } @@ -990,9 +981,8 @@ s_vFillCTSHead( unsigned int uCTSFrameLen = 14; unsigned short wLen = 0x0000; - if (pvCTS == NULL) { + if (pvCTS == NULL) return; - } if (bDisCRC) { // When CRCDIS bit is on, H/W forgot to generate FCS for CTS frame, @@ -1097,15 +1087,13 @@ s_vGenerateTxParameter( pFifoHead->wReserved = wCurrentRate; wFifoCtl = pFifoHead->wFIFOCtl; - if (wFifoCtl & FIFOCTL_CRCDIS) { + if (wFifoCtl & FIFOCTL_CRCDIS) bDisCRC = true; - } - if (wFifoCtl & FIFOCTL_AUTO_FB_0) { + if (wFifoCtl & FIFOCTL_AUTO_FB_0) byFBOption = AUTO_FB_0; - } else if (wFifoCtl & FIFOCTL_AUTO_FB_1) { + else if (wFifoCtl & FIFOCTL_AUTO_FB_1) byFBOption = AUTO_FB_1; - } if (pDevice->bLongHeader) cbMACHdLen = WLAN_HDR_ADDR3_LEN + 6; @@ -1194,20 +1182,18 @@ s_vFillFragParameter( ptdCurr->m_wTimeStamp = pTxBufHead->wTimeStamp; //Set TSR1 & ReqCount in TxDescHead ptdCurr->m_td1TD1.wReqCount = cpu_to_le16((unsigned short)(cbReqCount)); - if (wFragType == FRAGCTL_ENDFRAG) { //Last Fragmentation + if (wFragType == FRAGCTL_ENDFRAG) //Last Fragmentation ptdCurr->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP | EDMSDU); - } else { + else ptdCurr->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP); - } } else { PSTxDesc ptdCurr = (PSTxDesc)pvtdCurr; //Set TSR1 & ReqCount in TxDescHead ptdCurr->m_td1TD1.wReqCount = cpu_to_le16((unsigned short)(cbReqCount)); - if (wFragType == FRAGCTL_ENDFRAG) { //Last Fragmentation + if (wFragType == FRAGCTL_ENDFRAG) //Last Fragmentation ptdCurr->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP | EDMSDU); - } else { + else ptdCurr->m_td1TD1.byTCR |= (TCR_STP | TCR_EDP); - } } pTxBufHead->wFragCtl |= (unsigned short)wFragType;//0x0001; //0000 0000 0000 0001 @@ -1293,9 +1279,8 @@ s_cbFillTxBufHead(PSDevice pDevice, unsigned char byPktType, unsigned char *pbyT if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { cbIVlen = 4; cbICVlen = 4; - if (pTransmitKey->uKeyLength == WLAN_WEP232_KEYLEN) { + if (pTransmitKey->uKeyLength == WLAN_WEP232_KEYLEN) bIsWEP256 = true; - } } if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) { cbIVlen = 8;//IV+ExtIV @@ -1328,11 +1313,10 @@ s_cbFillTxBufHead(PSDevice pDevice, unsigned char byPktType, unsigned char *pbyT // // Use for AUTO FALL BACK // - if (psTxBufHd->wFIFOCtl & FIFOCTL_AUTO_FB_0) { + if (psTxBufHd->wFIFOCtl & FIFOCTL_AUTO_FB_0) byFBOption = AUTO_FB_0; - } else if (psTxBufHd->wFIFOCtl & FIFOCTL_AUTO_FB_1) { + else if (psTxBufHd->wFIFOCtl & FIFOCTL_AUTO_FB_1) byFBOption = AUTO_FB_1; - } ////////////////////////////////////////////////////// //Set RrvTime/RTS/CTS Buffer @@ -1446,11 +1430,11 @@ s_cbFillTxBufHead(PSDevice pDevice, unsigned char byPktType, unsigned char *pbyT //FragNum = (FrameSize-(Hdr+FCS))/(Fragment Size -(Hrd+FCS))) uMACfragNum = (unsigned short) ((cbFrameBodySize + cbMIClen) / cbFragPayloadSize); cbLastFragPayloadSize = (cbFrameBodySize + cbMIClen) % cbFragPayloadSize; - if (cbLastFragPayloadSize == 0) { + if (cbLastFragPayloadSize == 0) cbLastFragPayloadSize = cbFragPayloadSize; - } else { + else uMACfragNum++; - } + //[Hdr+(IV)+last fragment payload+(MIC)+(ICV)+FCS] cbLastFragmentSize = cbMACHdLen + cbLastFragPayloadSize + cbIVlen + cbICVlen + cbFCSlen; @@ -1916,40 +1900,37 @@ vGenerateFIFOHeader(PSDevice pDevice, unsigned char byPktType, unsigned char *pb pTxBufHead->wFIFOCtl |= FIFOCTL_GENINT; //Set FIFOCTL_ISDMA0 - if (TYPE_TXDMA0 == uDMAIdx) { + if (TYPE_TXDMA0 == uDMAIdx) pTxBufHead->wFIFOCtl |= FIFOCTL_ISDMA0; - } //Set FRAGCTL_MACHDCNT - if (pDevice->bLongHeader) { + if (pDevice->bLongHeader) cbMacHdLen = WLAN_HDR_ADDR3_LEN + 6; - } else { + else cbMacHdLen = WLAN_HDR_ADDR3_LEN; - } + pTxBufHead->wFragCtl |= cpu_to_le16((unsigned short)(cbMacHdLen << 10)); //Set packet type - if (byPktType == PK_TYPE_11A) {//0000 0000 0000 0000 + if (byPktType == PK_TYPE_11A) //0000 0000 0000 0000 ; - } else if (byPktType == PK_TYPE_11B) {//0000 0001 0000 0000 + else if (byPktType == PK_TYPE_11B) //0000 0001 0000 0000 pTxBufHead->wFIFOCtl |= FIFOCTL_11B; - } else if (byPktType == PK_TYPE_11GB) {//0000 0010 0000 0000 + else if (byPktType == PK_TYPE_11GB) //0000 0010 0000 0000 pTxBufHead->wFIFOCtl |= FIFOCTL_11GB; - } else if (byPktType == PK_TYPE_11GA) {//0000 0011 0000 0000 + else if (byPktType == PK_TYPE_11GA) //0000 0011 0000 0000 pTxBufHead->wFIFOCtl |= FIFOCTL_11GA; - } + //Set FIFOCTL_GrpAckPolicy - if (pDevice->bGrpAckPolicy == true) {//0000 0100 0000 0000 + if (pDevice->bGrpAckPolicy == true) //0000 0100 0000 0000 pTxBufHead->wFIFOCtl |= FIFOCTL_GRPACK; - } //Set Auto Fallback Ctl if (pDevice->wCurrentRate >= RATE_18M) { - if (pDevice->byAutoFBCtrl == AUTO_FB_0) { + if (pDevice->byAutoFBCtrl == AUTO_FB_0) pTxBufHead->wFIFOCtl |= FIFOCTL_AUTO_FB_0; - } else if (pDevice->byAutoFBCtrl == AUTO_FB_1) { + else if (pDevice->byAutoFBCtrl == AUTO_FB_1) pTxBufHead->wFIFOCtl |= FIFOCTL_AUTO_FB_1; - } } //Set FRAGCTL_WEPTYP @@ -2016,11 +1997,10 @@ vGenerateMACHeader( memset(pMACHeader, 0, (sizeof(S802_11Header))); - if (uDMAIdx == TYPE_ATIMDMA) { + if (uDMAIdx == TYPE_ATIMDMA) pMACHeader->wFrameCtl = TYPE_802_11_ATIM; - } else { + else pMACHeader->wFrameCtl = TYPE_802_11_DATA; - } if (pDevice->eOPMode == OP_MODE_AP) { memcpy(&(pMACHeader->abyAddr1[0]), &(psEthHeader->abyDstAddr[0]), ETH_ALEN); @@ -2061,9 +2041,8 @@ vGenerateMACHeader( pDevice->wSeqCounter = 0; } - if ((wFragType == FRAGCTL_STAFRAG) || (wFragType == FRAGCTL_MIDFRAG)) { //StartFrag or MidFrag + if ((wFragType == FRAGCTL_STAFRAG) || (wFragType == FRAGCTL_MIDFRAG)) //StartFrag or MidFrag pMACHeader->wFrameCtl |= FC_MOREFRAG; - } } CMD_STATUS csMgmt_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket) { @@ -2095,9 +2074,8 @@ CMD_STATUS csMgmt_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket) { PSMgmtObject pMgmt = pDevice->pMgmt; unsigned short wCurrentRate = RATE_1M; - if (AVAIL_TD(pDevice, TYPE_TXDMA0) <= 0) { + if (AVAIL_TD(pDevice, TYPE_TXDMA0) <= 0) return CMD_STATUS_RESOURCES; - } pFrstTD = pDevice->apCurrTD[TYPE_TXDMA0]; pbyTxBufferAddr = (unsigned char *)pFrstTD->pTDInfo->buf; @@ -2118,11 +2096,11 @@ CMD_STATUS csMgmt_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket) { // 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability. // And cmd timer will wait data pkt TX finish before scanning so it's OK // to set power here. - if (pDevice->pMgmt->eScanState != WMAC_NO_SCANNING) { + if (pDevice->pMgmt->eScanState != WMAC_NO_SCANNING) RFbSetPower(pDevice, wCurrentRate, pDevice->byCurrentCh); - } else { + else RFbSetPower(pDevice, wCurrentRate, pMgmt->uCurrChannel); - } + pTxBufHead->byTxPower = pDevice->byCurPwr; //+++++++++++++++++++++ Patch VT3253 A1 performance +++++++++++++++++++++++++++ if (pDevice->byFOETuning) { @@ -2200,9 +2178,9 @@ CMD_STATUS csMgmt_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket) { cbFrameSize = cbMacHdLen + cbFrameBodySize + cbIVlen + cbMIClen + cbICVlen + cbFCSlen; //Set FIFOCTL_GrpAckPolicy - if (pDevice->bGrpAckPolicy == true) {//0000 0100 0000 0000 + if (pDevice->bGrpAckPolicy == true) //0000 0100 0000 0000 pTxBufHead->wFIFOCtl |= FIFOCTL_GRPACK; - } + //the rest of pTxBufHead->wFragCtl:FragTyp will be set later in s_vFillFragParameter() //Set RrvTime/RTS/CTS Buffer @@ -2338,9 +2316,8 @@ CMD_STATUS csMgmt_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket) { pDevice->iTDUsed[TYPE_TXDMA0]++; - if (AVAIL_TD(pDevice, TYPE_TXDMA0) <= 1) { + if (AVAIL_TD(pDevice, TYPE_TXDMA0) <= 1) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " available td0 <= 1\n"); - } pDevice->apCurrTD[TYPE_TXDMA0] = pFrstTD->next; @@ -2496,11 +2473,10 @@ cbGetFragCount( cbFragPayloadSize = cbFragmentSize - cbMACHdLen - cbIVlen - cbICVlen - cbFCSlen; uMACfragNum = (unsigned short) ((cbFrameBodySize + cbMIClen) / cbFragPayloadSize); cbLastFragPayloadSize = (cbFrameBodySize + cbMIClen) % cbFragPayloadSize; - if (cbLastFragPayloadSize == 0) { + if (cbLastFragPayloadSize == 0) cbLastFragPayloadSize = cbFragPayloadSize; - } else { + else uMACfragNum++; - } } return uMACfragNum; } @@ -2553,11 +2529,11 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, unsigned char *pbMPDU, un pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL; - if (cbMPDULen <= WLAN_HDR_ADDR3_LEN) { + if (cbMPDULen <= WLAN_HDR_ADDR3_LEN) cbFrameBodySize = 0; - } else { + else cbFrameBodySize = cbMPDULen - WLAN_HDR_ADDR3_LEN; - } + p80211Header = (PUWLAN_80211HDR)pbMPDU; pFrstTD = pDevice->apCurrTD[TYPE_TXDMA0]; @@ -2578,11 +2554,11 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, unsigned char *pbMPDU, un // 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability. // And cmd timer will wait data pkt TX to finish before scanning so it's OK // to set power here. - if (pDevice->pMgmt->eScanState != WMAC_NO_SCANNING) { + if (pDevice->pMgmt->eScanState != WMAC_NO_SCANNING) RFbSetPower(pDevice, wCurrentRate, pDevice->byCurrentCh); - } else { + else RFbSetPower(pDevice, wCurrentRate, pMgmt->uCurrChannel); - } + pTxBufHead->byTxPower = pDevice->byCurPwr; //+++++++++++++++++++++ Patch VT3253 A1 performance +++++++++++++++++++++++++++ @@ -2640,17 +2616,14 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, unsigned char *pbMPDU, un // hostapd deamon ext support rate patch if (WLAN_GET_FC_FSTYPE(p80211Header->sA4.wFrameCtl) == WLAN_FSTYPE_ASSOCRESP) { - if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len != 0) { + if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len != 0) cbExtSuppRate += ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len + WLAN_IEHDR_LEN; - } - if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len != 0) { + if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len != 0) cbExtSuppRate += ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len + WLAN_IEHDR_LEN; - } - if (cbExtSuppRate > 0) { + if (cbExtSuppRate > 0) cbFrameBodySize = WLAN_ASSOCRESP_OFF_SUPP_RATES; - } } //Set FRAGCTL_MACHDCNT @@ -2687,9 +2660,9 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, unsigned char *pbMPDU, un cbFrameSize = cbMacHdLen + cbFrameBodySize + cbIVlen + cbMIClen + cbICVlen + cbFCSlen + cbExtSuppRate; //Set FIFOCTL_GrpAckPolicy - if (pDevice->bGrpAckPolicy == true) {//0000 0100 0000 0000 + if (pDevice->bGrpAckPolicy == true) //0000 0100 0000 0000 pTxBufHead->wFIFOCtl |= FIFOCTL_GRPACK; - } + //the rest of pTxBufHead->wFragCtl:FragTyp will be set later in s_vFillFragParameter() if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {//802.11g packet @@ -2815,9 +2788,8 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, unsigned char *pbMPDU, un pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0; } - if ((pDevice->byLocalID <= REV_ID_VT3253_A1)) { + if ((pDevice->byLocalID <= REV_ID_VT3253_A1)) s_vSWencryption(pDevice, pTransmitKey, pbyPayloadHead, (unsigned short)(cbFrameBodySize + cbMIClen)); - } } pMACHeader->wSeqCtl = cpu_to_le16(pDevice->wSeqCounter << 4); @@ -2861,9 +2833,8 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, unsigned char *pbMPDU, un pDevice->iTDUsed[TYPE_TXDMA0]++; - if (AVAIL_TD(pDevice, TYPE_TXDMA0) <= 1) { + if (AVAIL_TD(pDevice, TYPE_TXDMA0) <= 1) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " available td0 <= 1\n"); - } pDevice->apCurrTD[TYPE_TXDMA0] = pFrstTD->next; diff --git a/drivers/staging/vt6655/tkip.c b/drivers/staging/vt6655/tkip.c index 078b359a7d4b..f758d021c60e 100644 --- a/drivers/staging/vt6655/tkip.c +++ b/drivers/staging/vt6655/tkip.c @@ -157,11 +157,11 @@ unsigned int rotr1(unsigned int a) { unsigned int b; - if ((a & 0x01) == 0x01) { + if ((a & 0x01) == 0x01) b = (a >> 1) | 0x8000; - } else { + else b = (a >> 1) & 0x7fff; - } + b = b % 65536; return b; } diff --git a/drivers/staging/vt6655/vntwifi.c b/drivers/staging/vt6655/vntwifi.c index 2ccd0702388a..7d61598563c7 100644 --- a/drivers/staging/vt6655/vntwifi.c +++ b/drivers/staging/vt6655/vntwifi.c @@ -151,9 +151,9 @@ VNTWIFIpGetCurrentChannel( ) { PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle; - if (pMgmtHandle != NULL) { + if (pMgmtHandle != NULL) return pMgmt->uCurrChannel; - } + return 0; } @@ -208,17 +208,17 @@ VNTWIFIbyGetMaxSupportRate( if (pSupportRateIEs) { for (ii = 0; ii < pSupportRateIEs->len; ii++) { bySupportRate = DATARATEbyGetRateIdx(pSupportRateIEs->abyRates[ii]); - if (bySupportRate > byMaxSupportRate) { + if (bySupportRate > byMaxSupportRate) byMaxSupportRate = bySupportRate; - } + } } if (pExtSupportRateIEs) { for (ii = 0; ii < pExtSupportRateIEs->len; ii++) { bySupportRate = DATARATEbyGetRateIdx(pExtSupportRateIEs->abyRates[ii]); - if (bySupportRate > byMaxSupportRate) { + if (bySupportRate > byMaxSupportRate) byMaxSupportRate = bySupportRate; - } + } } @@ -359,11 +359,10 @@ VNTWIFIbConfigPhyMode( if ((ePhyType != PHY_TYPE_AUTO) && (ePhyType != pMgmt->eCurrentPHYMode)) { - if (CARDbSetPhyParameter(pMgmt->pAdapter, ePhyType, 0, 0, NULL, NULL) == true) { + if (CARDbSetPhyParameter(pMgmt->pAdapter, ePhyType, 0, 0, NULL, NULL) == true) pMgmt->eCurrentPHYMode = ePhyType; - } else { + else return false; - } } pMgmt->eConfigPHYMode = ePhyType; return true; @@ -377,9 +376,8 @@ VNTWIFIbGetConfigPhyMode( { PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle; - if ((pMgmt != NULL) && (pePhyType != NULL)) { + if ((pMgmt != NULL) && (pePhyType != NULL)) *(PCARD_PHY_TYPE)pePhyType = pMgmt->eConfigPHYMode; - } } /*+ @@ -425,12 +423,12 @@ VNTWIFIvQueryBSSList(void *pMgmtHandle, unsigned int *puBSSCount, void **pvFirst for (ii = 0; ii < MAX_BSS_NUM; ii++) { pBSS = &(pMgmt->sBSSList[ii]); - if (!pBSS->bActive) { + if (!pBSS->bActive) continue; - } - if (*pvFirstBSS == NULL) { + + if (*pvFirstBSS == NULL) *pvFirstBSS = &(pMgmt->sBSSList[ii]); - } + uCount++; } *puBSSCount = uCount; @@ -450,9 +448,9 @@ VNTWIFIvGetNextBSS( while (*pvNextBSS == NULL) { pBSS++; - if (pBSS > &(pMgmt->sBSSList[MAX_BSS_NUM])) { + if (pBSS > &(pMgmt->sBSSList[MAX_BSS_NUM])) return; - } + if (pBSS->bActive == true) { *pvNextBSS = pBSS; return; @@ -487,10 +485,10 @@ VNTWIFIvUpdateNodeTxCounter( if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) || (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) { - if (BSSDBbIsSTAInNodeDB(pMgmt, pbyDestAddress, &uNodeIndex) == false) { + if (BSSDBbIsSTAInNodeDB(pMgmt, pbyDestAddress, &uNodeIndex) == false) return; - } } + pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts++; if (bTxOk) { // transmit success, TxAttempts at least plus one @@ -500,9 +498,9 @@ VNTWIFIvUpdateNodeTxCounter( pMgmt->sNodeDBTable[uNodeIndex].uTxFailures++; } pMgmt->sNodeDBTable[uNodeIndex].uTxRetry += pbyTxFailCount[MAX_RATE]; - for (ii = 0; ii < MAX_RATE; ii++) { + for (ii = 0; ii < MAX_RATE; ii++) pMgmt->sNodeDBTable[uNodeIndex].uTxFail[ii] += pbyTxFailCount[ii]; - } + return; } @@ -533,11 +531,11 @@ VNTWIFIvGetTxRate( pSupportRateIEs = (PWLAN_IE_SUPP_RATES) (pMgmt->sNodeDBTable[uNodeIndex].abyCurrSuppRates); pExtSupportRateIEs = (PWLAN_IE_SUPP_RATES) (pMgmt->sNodeDBTable[uNodeIndex].abyCurrExtSuppRates); } else { - if (pMgmt->eCurrentPHYMode != PHY_TYPE_11A) { + if (pMgmt->eCurrentPHYMode != PHY_TYPE_11A) wTxDataRate = RATE_2M; - } else { + else wTxDataRate = RATE_24M; - } + pSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrSuppRates; pExtSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrExtSuppRates; } @@ -556,9 +554,9 @@ VNTWIFIvGetTxRate( pSupportRateIEs, pExtSupportRateIEs ); - if (byACKRate > (unsigned char) wTxDataRate) { + if (byACKRate > (unsigned char) wTxDataRate) byACKRate = (unsigned char) wTxDataRate; - } + byCCKBasicRate = VNTWIFIbyGetACKTxRate(RATE_11M, pSupportRateIEs, pExtSupportRateIEs @@ -582,11 +580,10 @@ VNTWIFIbyGetKeyCypher( { PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle; - if (bGroupKey) { + if (bGroupKey) return pMgmt->byCSSGK; - } else { + else return pMgmt->byCSSPK; - } } bool @@ -598,9 +595,9 @@ VNTWIFIbSetPMKIDCache( { PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject; - if (ulCount > MAX_PMKID_CACHE) { + if (ulCount > MAX_PMKID_CACHE) return false; - } + pMgmt->gsPMKIDCache.BSSIDInfoCount = ulCount; memcpy(pMgmt->gsPMKIDCache.BSSIDInfo, pPMKIDInfo, (ulCount*sizeof(PMKIDInfo))); return true; @@ -615,15 +612,14 @@ VNTWIFIwGetMaxSupportRate( PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject; for (wRate = RATE_54M; wRate > RATE_1M; wRate--) { - if (pMgmt->sNodeDBTable[0].wSuppRate & (1<sNodeDBTable[0].wSuppRate & (1<eCurrentPHYMode == PHY_TYPE_11A) { + + if (pMgmt->eCurrentPHYMode == PHY_TYPE_11A) return RATE_6M; - } else { + else return RATE_1M; - } } void diff --git a/drivers/staging/vt6655/wcmd.c b/drivers/staging/vt6655/wcmd.c index 791b37e0db82..a689645fa012 100644 --- a/drivers/staging/vt6655/wcmd.c +++ b/drivers/staging/vt6655/wcmd.c @@ -127,14 +127,13 @@ vAdHocBeaconStop(PSDevice pDevice) (pMgmt->uScanChannel > CB_MAX_CHANNEL_24G)) { bStop = true; } - if (pMgmt->uIBSSChannel > CB_MAX_CHANNEL_24G) { + if (pMgmt->uIBSSChannel > CB_MAX_CHANNEL_24G) bStop = true; - } + } - if (bStop) { + if (bStop) MACvRegBitsOff(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX); - } } /* vAdHocBeaconStop */ /* @@ -196,13 +195,13 @@ s_vProbeChannel( PSMgmtObject pMgmt = pDevice->pMgmt; unsigned int ii; - if (pDevice->eCurrentPHYType == PHY_TYPE_11A) { + if (pDevice->eCurrentPHYType == PHY_TYPE_11A) pbyRate = &abyCurrSuppRatesA[0]; - } else if (pDevice->eCurrentPHYType == PHY_TYPE_11B) { + else if (pDevice->eCurrentPHYType == PHY_TYPE_11B) pbyRate = &abyCurrSuppRatesB[0]; - } else { + else pbyRate = &abyCurrSuppRatesG[0]; - } + // build an assocreq frame and send it pTxPacket = s_MgrMakeProbeRequest ( @@ -216,11 +215,10 @@ s_vProbeChannel( if (pTxPacket != NULL) { for (ii = 0; ii < 2; ii++) { - if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) { + if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request sending fail.. \n"); - } else { + else DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request is sending.. \n"); - } } } } @@ -359,11 +357,11 @@ vCommandTimer( // Set channel back set_channel(pMgmt->pAdapter, pMgmt->uCurrChannel); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning, set back to channel: [%d]\n", pMgmt->uCurrChannel); - if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { + if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, OP_MODE_ADHOC); - } else { + else CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, OP_MODE_INFRASTRUCTURE); - } + vAdHocBeaconRestart(pDevice); s_bCommandComplete(pDevice); @@ -389,11 +387,11 @@ vCommandTimer( vAdHocBeaconStop(pDevice); - if (set_channel(pMgmt->pAdapter, pMgmt->uScanChannel)) { + if (set_channel(pMgmt->pAdapter, pMgmt->uScanChannel)) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "SCAN Channel: %d\n", pMgmt->uScanChannel); - } else { + else DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "SET SCAN Channel Fail: %d\n", pMgmt->uScanChannel); - } + CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, OP_MODE_UNKNOWN); pMgmt->uScanChannel++; //2008-8-4 by chester @@ -426,11 +424,10 @@ vCommandTimer( // Set channel back set_channel(pMgmt->pAdapter, pMgmt->uCurrChannel); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning, set back to channel: [%d]\n", pMgmt->uCurrChannel); - if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { + if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, OP_MODE_ADHOC); - } else { + else CARDbSetBSSID(pMgmt->pAdapter, pMgmt->abyCurrBSSID, OP_MODE_INFRASTRUCTURE); - } pMgmt->eScanState = WMAC_NO_SCANNING; vAdHocBeaconRestart(pDevice); @@ -534,9 +531,9 @@ vCommandTimer( if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED)) { // Call mgr to begin the deauthentication // reason = (3) because sta has left ESS - if (pMgmt->eCurrState >= WMAC_STATE_AUTH) { + if (pMgmt->eCurrState >= WMAC_STATE_AUTH) vMgrDeAuthenBeginSta((void *)pDevice, pMgmt, pMgmt->abyCurrBSSID, (3), &Status); - } + // Call mgr to begin the authentication vMgrAuthenBeginSta((void *)pDevice, pMgmt, &Status); if (Status == CMD_STATUS_SUCCESS) { @@ -551,9 +548,9 @@ vCommandTimer( // if Adhoc mode else if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { if (pMgmt->eCurrState == WMAC_STATE_JOINTED) { - if (netif_queue_stopped(pDevice->dev)) { + if (netif_queue_stopped(pDevice->dev)) netif_wake_queue(pDevice->dev); - } + pDevice->bLinkPass = true; pMgmt->sNodeDBTable[0].bActive = true; @@ -562,9 +559,9 @@ vCommandTimer( } else { // start own IBSS vMgrCreateOwnIBSS((void *)pDevice, &Status); - if (Status != CMD_STATUS_SUCCESS) { + if (Status != CMD_STATUS_SUCCESS) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " WLAN_CMD_IBSS_CREATE fail ! \n"); - } + BSSvAddMulticastNode(pDevice); } } @@ -574,13 +571,13 @@ vCommandTimer( pMgmt->eConfigMode == WMAC_CONFIG_AUTO) { // start own IBSS vMgrCreateOwnIBSS((void *)pDevice, &Status); - if (Status != CMD_STATUS_SUCCESS) { + if (Status != CMD_STATUS_SUCCESS) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " WLAN_CMD_IBSS_CREATE fail ! \n"); - } + BSSvAddMulticastNode(pDevice); - if (netif_queue_stopped(pDevice->dev)) { + if (netif_queue_stopped(pDevice->dev)) netif_wake_queue(pDevice->dev); - } + pDevice->bLinkPass = true; } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disconnect SSID none\n"); @@ -632,12 +629,12 @@ vCommandTimer( case WLAN_ASSOCIATE_WAIT: if (pMgmt->eCurrState == WMAC_STATE_ASSOC) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "eCurrState == WMAC_STATE_ASSOC\n"); - if (pDevice->ePSMode != WMAC_POWER_CAM) { + if (pDevice->ePSMode != WMAC_POWER_CAM) PSvEnablePowerSaving((void *)pDevice, pMgmt->wListenInterval); - } - if (pMgmt->eAuthenMode >= WMAC_AUTH_WPA) { + + if (pMgmt->eAuthenMode >= WMAC_AUTH_WPA) KeybRemoveAllKey(&(pDevice->sKey), pDevice->abyBSSID, pDevice->PortOffset); - } + pDevice->bLinkPass = true; pDevice->byLinkWaitCount = 0; pDevice->byReAssocCount = 0; @@ -646,9 +643,9 @@ vCommandTimer( BBvSetFOE(pDevice->PortOffset); PSbSendNullPacket(pDevice); } - if (netif_queue_stopped(pDevice->dev)) { + if (netif_queue_stopped(pDevice->dev)) netif_wake_queue(pDevice->dev); - } + #ifdef TxInSleep if (pDevice->IsTxDataTrigger) { //TxDataTimer is not triggered at the first time del_timer(&pDevice->sTimerTxData); @@ -658,8 +655,8 @@ vCommandTimer( pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback pDevice->fTxDataInSleep = false; pDevice->nTxDataTimeCout = 0; - } else { } + pDevice->IsTxDataTrigger = true; add_timer(&pDevice->sTimerTxData); #endif @@ -694,17 +691,17 @@ vCommandTimer( pDevice->bFixRate = false; vMgrCreateOwnIBSS((void *)pDevice, &Status); - if (Status != CMD_STATUS_SUCCESS) { + if (Status != CMD_STATUS_SUCCESS) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " vMgrCreateOwnIBSS fail ! \n"); - } + // alway turn off unicast bit MACvRegBitsOff(pDevice->PortOffset, MAC_REG_RCR, RCR_UNICAST); pDevice->byRxMode &= ~RCR_UNICAST; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wcmd: rx_mode = %x\n", pDevice->byRxMode); BSSvAddMulticastNode(pDevice); - if (netif_queue_stopped(pDevice->dev)) { + if (netif_queue_stopped(pDevice->dev)) netif_wake_queue(pDevice->dev); - } + pDevice->bLinkPass = true; add_timer(&pMgmt->sTimerSecondCallback); } @@ -721,9 +718,9 @@ vCommandTimer( } else { pDevice->bMoreData = true; } - if (!device_dma0_xmit(pDevice, skb, 0)) { + if (!device_dma0_xmit(pDevice, skb, 0)) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Multicast ps tx fail \n"); - } + pMgmt->sNodeDBTable[0].wEnQueueCnt--; } } @@ -743,9 +740,9 @@ vCommandTimer( } else { pDevice->bMoreData = true; } - if (!device_dma0_xmit(pDevice, skb, ii)) { + if (!device_dma0_xmit(pDevice, skb, ii)) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "sta ps tx fail \n"); - } + pMgmt->sNodeDBTable[ii].wEnQueueCnt--; // check if sta ps enabled, and wait next pspoll. // if sta ps disable, then send all pending buffers. @@ -831,11 +828,11 @@ s_bCommandComplete( DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "eCommandState= WLAN_CMD_BSSID_SCAN\n"); pDevice->eCommandState = WLAN_CMD_SCAN_START; pMgmt->uScanChannel = 0; - if (pSSID->len != 0) { + if (pSSID->len != 0) memcpy(pMgmt->abyScanSSID, pSSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); - } else { + else memset(pMgmt->abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); - } + break; case WLAN_CMD_SSID: pDevice->eCommandState = WLAN_CMD_SSID_START; @@ -881,9 +878,9 @@ bool bScheduleCommand( { PSDevice pDevice = (PSDevice)hDeviceContext; - if (pDevice->cbFreeCmdQueue == 0) { + if (pDevice->cbFreeCmdQueue == 0) return false; - } + pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].eCmd = eCommand; pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = true; memset(pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].abyCmdDesireSSID, 0 , WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1); diff --git a/drivers/staging/vt6655/wctl.c b/drivers/staging/vt6655/wctl.c index 0ae57f1775c1..fddea9fc9cfe 100644 --- a/drivers/staging/vt6655/wctl.c +++ b/drivers/staging/vt6655/wctl.c @@ -191,9 +191,8 @@ bool WCTLbHandleFragment(PSDevice pDevice, PS802_11Header pMACHeader, unsigned i pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wFragNum = (pMACHeader->wSeqCtl & 0x000F); } else { pDevice->uCurrentDFCBIdx = WCTLuInsertDFCB(pDevice, pMACHeader); - if (pDevice->uCurrentDFCBIdx == pDevice->cbDFCB) { + if (pDevice->uCurrentDFCBIdx == pDevice->cbDFCB) return false; - } } // reserve 4 byte to match MAC RX Buffer pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer = (unsigned char *)(pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].skb->data + 4); diff --git a/drivers/staging/vt6655/wmgr.c b/drivers/staging/vt6655/wmgr.c index 1d9de1fccd8c..67384782b702 100644 --- a/drivers/staging/vt6655/wmgr.c +++ b/drivers/staging/vt6655/wmgr.c @@ -350,9 +350,9 @@ vMgrObjectInit( pMgmt->pbyPSPacketPool = &pMgmt->byPSPacketPool[0]; pMgmt->pbyMgmtPacketPool = &pMgmt->byMgmtPacketPool[0]; pMgmt->uCurrChannel = pDevice->uChannel; - for (ii = 0; ii < WLAN_BSSID_LEN; ii++) { + for (ii = 0; ii < WLAN_BSSID_LEN; ii++) pMgmt->abyDesireBSSID[ii] = 0xFF; - } + pMgmt->sAssocInfo.AssocInfo.Length = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION); pMgmt->byCSSPK = KEY_CTL_NONE; pMgmt->byCSSGK = KEY_CTL_NONE; @@ -456,9 +456,9 @@ vMgrAssocBeginSta( pMgmt->wCurrCapInfo = 0; pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_ESS(1); - if (pDevice->bEncryptionEnable) { + if (pDevice->bEncryptionEnable) pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1); - } + pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1); if (pMgmt->wListenInterval == 0) pMgmt->wListenInterval = 1; // at least one. @@ -466,13 +466,11 @@ vMgrAssocBeginSta( // ERP Phy (802.11g) should support short preamble. if (pMgmt->eCurrentPHYMode == PHY_TYPE_11G) { pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1); - if (CARDbIsShorSlotTime(pMgmt->pAdapter)) { + if (CARDbIsShorSlotTime(pMgmt->pAdapter)) pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1); - } } else if (pMgmt->eCurrentPHYMode == PHY_TYPE_11B) { - if (CARDbIsShortPreamble(pMgmt->pAdapter)) { + if (CARDbIsShortPreamble(pMgmt->pAdapter)) pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1); - } } if (pMgmt->b11hEnable) pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SPECTRUMMNG(1); @@ -497,8 +495,9 @@ vMgrAssocBeginSta( pMgmt->eCurrState = WMAC_STATE_ASSOCPENDING; *pStatus = CMD_STATUS_SUCCESS; } - } else + } else { *pStatus = CMD_STATUS_RESOURCES; + } return; } @@ -525,9 +524,8 @@ vMgrReAssocBeginSta( pMgmt->wCurrCapInfo = 0; pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_ESS(1); - if (pDevice->bEncryptionEnable) { + if (pDevice->bEncryptionEnable) pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1); - } pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1); @@ -537,14 +535,13 @@ vMgrReAssocBeginSta( // ERP Phy (802.11g) should support short preamble. if (pMgmt->eCurrentPHYMode == PHY_TYPE_11G) { pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1); - if (CARDbIsShorSlotTime(pMgmt->pAdapter)) { + if (CARDbIsShorSlotTime(pMgmt->pAdapter)) pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTSLOTTIME(1); - } } else if (pMgmt->eCurrentPHYMode == PHY_TYPE_11B) { - if (CARDbIsShortPreamble(pMgmt->pAdapter)) { + if (CARDbIsShortPreamble(pMgmt->pAdapter)) pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1); - } } + if (pMgmt->b11hEnable) pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SPECTRUMMNG(1); @@ -563,11 +560,10 @@ vMgrReAssocBeginSta( if (pTxPacket != NULL) { /* send the frame */ *pStatus = csMgmt_xmit(pDevice, pTxPacket); - if (*pStatus != CMD_STATUS_PENDING) { + if (*pStatus != CMD_STATUS_PENDING) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Reassociation tx failed.\n"); - } else { + else DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Reassociation tx sending.\n"); - } } return; @@ -684,21 +680,20 @@ s_vMgrRxAssocRequest( pMgmt->sNodeDBTable[uNodeIndex].bPSEnable = WLAN_GET_FC_PWRMGT(sFrame.pHdr->sA3.wFrameCtl) ? true : false; // Todo: check sta basic rate, if ap can't support, set status code - if (pDevice->eCurrentPHYType == PHY_TYPE_11B) { + if (pDevice->eCurrentPHYType == PHY_TYPE_11B) uRateLen = WLAN_RATES_MAXLEN_11B; - } + abyCurrSuppRates[0] = WLAN_EID_SUPP_RATES; abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates, (PWLAN_IE_SUPP_RATES)abyCurrSuppRates, uRateLen); abyCurrExtSuppRates[0] = WLAN_EID_EXTSUPP_RATES; - if (pDevice->eCurrentPHYType == PHY_TYPE_11G) { + if (pDevice->eCurrentPHYType == PHY_TYPE_11G) abyCurrExtSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pExtSuppRates, (PWLAN_IE_SUPP_RATES)abyCurrExtSuppRates, uRateLen); - } else { + else abyCurrExtSuppRates[1] = 0; - } RATEvParseMaxRate((void *)pDevice, (PWLAN_IE_SUPP_RATES)abyCurrSuppRates, @@ -734,9 +729,8 @@ s_vMgrRxAssocRequest( pDevice->bProtectMode = true; pDevice->bNonERPPresent = true; } - if (!pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble) { + if (!pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble) pDevice->bBarkerPreambleMd = true; - } DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Associate AID= %d \n", wAssocAID); DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "MAC=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X \n", @@ -749,8 +743,8 @@ s_vMgrRxAssocRequest( ); DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Max Support rate = %d \n", pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate); - }//else { TODO: received STA under state1 handle } - else { + } else { + /* TODO: received STA under state1 handle */ return; } @@ -767,17 +761,15 @@ s_vMgrRxAssocRequest( (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates ); if (pTxPacket != NULL) { - if (pDevice->bEnableHostapd) { + if (pDevice->bEnableHostapd) return; - } + /* send the frame */ Status = csMgmt_xmit(pDevice, pTxPacket); - if (Status != CMD_STATUS_PENDING) { + if (Status != CMD_STATUS_PENDING) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Assoc response tx failed\n"); - } else { + else DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Assoc response tx sending..\n"); - } - } return; @@ -837,9 +829,8 @@ s_vMgrRxReAssocRequest( WLAN_GET_FC_PWRMGT(sFrame.pHdr->sA3.wFrameCtl) ? true : false; // Todo: check sta basic rate, if ap can't support, set status code - if (pDevice->eCurrentPHYType == PHY_TYPE_11B) { + if (pDevice->eCurrentPHYType == PHY_TYPE_11B) uRateLen = WLAN_RATES_MAXLEN_11B; - } abyCurrSuppRates[0] = WLAN_EID_SUPP_RATES; abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates, @@ -889,9 +880,8 @@ s_vMgrRxReAssocRequest( pDevice->bProtectMode = true; pDevice->bNonERPPresent = true; } - if (!pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble) { + if (!pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble) pDevice->bBarkerPreambleMd = true; - } DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Rx ReAssociate AID= %d \n", wAssocAID); DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "MAC=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X \n", @@ -922,15 +912,14 @@ s_vMgrRxReAssocRequest( if (pTxPacket != NULL) { /* send the frame */ - if (pDevice->bEnableHostapd) { + if (pDevice->bEnableHostapd) return; - } + Status = csMgmt_xmit(pDevice, pTxPacket); - if (Status != CMD_STATUS_PENDING) { + if (Status != CMD_STATUS_PENDING) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:ReAssoc response tx failed\n"); - } else { + else DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:ReAssoc response tx sending..\n"); - } } return; } @@ -988,9 +977,9 @@ s_vMgrRxAssocResponse( if (cpu_to_le16((*(sFrame.pwStatus))) == WLAN_MGMT_STATUS_SUCCESS) { // set AID pMgmt->wCurrAID = cpu_to_le16((*(sFrame.pwAid))); - if ((pMgmt->wCurrAID >> 14) != (BIT0 | BIT1)) { + if ((pMgmt->wCurrAID >> 14) != (BIT0 | BIT1)) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "AID from AP, has two msb clear.\n"); - } + DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Association Successful, AID=%d.\n", pMgmt->wCurrAID & ~(BIT14 | BIT15)); pMgmt->eCurrState = WMAC_STATE_ASSOC; BSSvUpdateAPNode((void *)pDevice, sFrame.pwCapInfo, sFrame.pSuppRates, sFrame.pExtSuppRates); @@ -1187,9 +1176,8 @@ vMgrDeAuthenBeginSta( pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; *pStatus = csMgmt_xmit(pDevice, pTxPacket); - if (*pStatus == CMD_STATUS_PENDING) { + if (*pStatus == CMD_STATUS_PENDING) *pStatus = CMD_STATUS_SUCCESS; - } return; } @@ -1338,13 +1326,13 @@ s_vMgrRxAuthenSequence_1( pTxPacket->cbMPDULen = sFrame.len; pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; // send the frame - if (pDevice->bEnableHostapd) { + if (pDevice->bEnableHostapd) return; - } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Authreq_reply sequence_1 tx.. \n"); - if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) { + if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Authreq_reply sequence_1 tx failed.\n"); - } + return; } @@ -1417,9 +1405,9 @@ s_vMgrRxAuthenSequence_2( pTxPacket->cbMPDULen = sFrame.len; pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; // send the frame - if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) { + if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Auth_reply sequence_2 tx failed.\n"); - } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Auth_reply sequence_2 tx ...\n"); } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:rx Auth_reply sequence_2 status error ...\n"); @@ -1511,12 +1499,12 @@ reply: pTxPacket->cbMPDULen = sFrame.len; pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; // send the frame - if (pDevice->bEnableHostapd) { + if (pDevice->bEnableHostapd) return; - } - if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) { + + if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Authreq_reply sequence_4 tx failed.\n"); - } + return; } @@ -1577,11 +1565,11 @@ s_vMgrRxDisassociation( // a STA is leaving this BSS.. sFrame.len = pRxPacket->cbMPDULen; sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header; - if (BSSDBbIsSTAInNodeDB(pMgmt, pRxPacket->p80211Header->sA3.abyAddr2, &uNodeIndex)) { + if (BSSDBbIsSTAInNodeDB(pMgmt, pRxPacket->p80211Header->sA3.abyAddr2, &uNodeIndex)) BSSvRemoveOneNode(pDevice, uNodeIndex); - } else { + else DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Rx disassoc, sta not found\n"); - } + } else if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA) { sFrame.len = pRxPacket->cbMPDULen; sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header; @@ -1649,11 +1637,10 @@ s_vMgrRxDeauthentication( // a STA is leaving this BSS.. sFrame.len = pRxPacket->cbMPDULen; sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header; - if (BSSDBbIsSTAInNodeDB(pMgmt, pRxPacket->p80211Header->sA3.abyAddr2, &uNodeIndex)) { + if (BSSDBbIsSTAInNodeDB(pMgmt, pRxPacket->p80211Header->sA3.abyAddr2, &uNodeIndex)) BSSvRemoveOneNode(pDevice, uNodeIndex); - } else { + else DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Rx deauth, sta not found\n"); - } } else { if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA) { sFrame.len = pRxPacket->cbMPDULen; @@ -1874,9 +1861,8 @@ s_vMgrRxBeacon( } - if (bInScan) { + if (bInScan) return; - } if (byCurrChannel == (unsigned char)pMgmt->uCurrChannel) bIsChannelEqual = true; @@ -1960,9 +1946,9 @@ s_vMgrRxBeacon( // // Basic Rate Set may change dynamically // - if (pBSSList->eNetworkTypeInUse == PHY_TYPE_11B) { + if (pBSSList->eNetworkTypeInUse == PHY_TYPE_11B) uRateLen = WLAN_RATES_MAXLEN_11B; - } + pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pBSSList->abySuppRates, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, uRateLen); @@ -2022,22 +2008,20 @@ s_vMgrRxBeacon( // check if beacon TSF larger or small than our local TSF if (HIDWORD(qwTimestamp) == HIDWORD(qwLocalTSF)) { - if (LODWORD(qwTimestamp) >= LODWORD(qwLocalTSF)) { + if (LODWORD(qwTimestamp) >= LODWORD(qwLocalTSF)) bTSFOffsetPostive = true; - } else { + else bTSFOffsetPostive = false; - } } else if (HIDWORD(qwTimestamp) > HIDWORD(qwLocalTSF)) { bTSFOffsetPostive = true; } else if (HIDWORD(qwTimestamp) < HIDWORD(qwLocalTSF)) { bTSFOffsetPostive = false; } - if (bTSFOffsetPostive) { + if (bTSFOffsetPostive) qwTSFOffset = CARDqGetTSFOffset(pRxPacket->byRxRate, (qwTimestamp), (qwLocalTSF)); - } else { + else qwTSFOffset = CARDqGetTSFOffset(pRxPacket->byRxRate, (qwLocalTSF), (qwTimestamp)); - } if (HIDWORD(qwTSFOffset) != 0 || (LODWORD(qwTSFOffset) > TRIVIAL_SYNC_DIFFERENCE)) { @@ -2091,9 +2075,8 @@ s_vMgrRxBeacon( if (PSbSendNullPacket(pDevice)) pDevice->bPWBitOn = true; } - if (PSbConsiderPowerDown(pDevice, false, false)) { + if (PSbConsiderPowerDown(pDevice, false, false)) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN: Power down now...\n"); - } } } @@ -2164,9 +2147,9 @@ s_vMgrRxBeacon( DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Current IBSS State: [Started]........to: [Jointed] \n"); pMgmt->eCurrState = WMAC_STATE_JOINTED; pDevice->bLinkPass = true; - if (netif_queue_stopped(pDevice->dev)) { + if (netif_queue_stopped(pDevice->dev)) netif_wake_queue(pDevice->dev); - } + pMgmt->sNodeDBTable[0].bActive = true; pMgmt->sNodeDBTable[0].uInActiveCount = 0; @@ -2332,9 +2315,8 @@ vMgrCreateOwnIBSS( &wMaxBasicRate, &wMaxSuppRate, &wSuppRate, &byTopCCKBasicRate, &byTopOFDMBasicRate); - if (pMgmt->eConfigMode == WMAC_CONFIG_AP) { + if (pMgmt->eConfigMode == WMAC_CONFIG_AP) pMgmt->eCurrMode = WMAC_MODE_ESS_AP; - } if (pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) { memcpy(pMgmt->abyIBSSDFSOwner, pDevice->abyCurrentNetAddr, 6); @@ -2393,9 +2375,8 @@ vMgrCreateOwnIBSS( pMgmt->byDTIMCount = pMgmt->byDTIMPeriod - 1; } - if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) { + if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_IBSS(1); - } if (pDevice->bEncryptionEnable) { pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1); @@ -2437,11 +2418,10 @@ vMgrCreateOwnIBSS( set_channel(pMgmt->pAdapter, pMgmt->uIBSSChannel); pMgmt->uCurrChannel = pMgmt->uIBSSChannel; - if (CARDbIsShortPreamble(pMgmt->pAdapter)) { + if (CARDbIsShortPreamble(pMgmt->pAdapter)) pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_SHORTPREAMBLE(1); - } else { + else pMgmt->wCurrCapInfo &= (~WLAN_SET_CAP_INFO_SHORTPREAMBLE(1)); - } if (pMgmt->b11hEnable && (pMgmt->eCurrentPHYMode == PHY_TYPE_11A)) { @@ -2452,9 +2432,8 @@ vMgrCreateOwnIBSS( pMgmt->eCurrState = WMAC_STATE_STARTED; // Prepare beacon to send - if (bMgrPrepareBeaconToSend((void *)pDevice, pMgmt)) { + if (bMgrPrepareBeaconToSend((void *)pDevice, pMgmt)) *pStatus = CMD_STATUS_SUCCESS; - } return; } @@ -2541,9 +2520,8 @@ vMgrJoinBSSBegin( memset(pMgmt->abyCurrSuppRates, 0 , WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1); memset(pMgmt->abyCurrExtSuppRates, 0 , WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1); - if (pCurr->eNetworkTypeInUse == PHY_TYPE_11B) { + if (pCurr->eNetworkTypeInUse == PHY_TYPE_11B) uRateLen = WLAN_RATES_MAXLEN_11B; - } pItemRates = (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates; pItemExtRates = (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates; @@ -2570,9 +2548,8 @@ vMgrJoinBSSBegin( pItemRates->len += (unsigned char)ii; if (pItemExtRates->len - ii > 0) { pItemExtRates->len -= (unsigned char)ii; - for (uu = 0; uu < pItemExtRates->len; uu++) { + for (uu = 0; uu < pItemExtRates->len; uu++) pItemExtRates->abyRates[uu] = pItemExtRates->abyRates[uu + ii]; - } } else { pItemExtRates->len = 0; } @@ -2799,9 +2776,8 @@ s_vMgrSynchBSS( CARDbSetBSSID(pMgmt->pAdapter, pCurr->abyBSSID, OP_MODE_INFRASTRUCTURE); // Add current BSS to Candidate list // This should only works for WPA2 BSS, and WPA2 BSS check must be done before. - if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) { + if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) CARDbAdd_PMKID_Candidate(pMgmt->pAdapter, pMgmt->abyCurrBSSID, pCurr->sRSNCapObj.bRSNCapExist, pCurr->sRSNCapObj.wRSNCap); - } } else { CARDbSetBSSID(pMgmt->pAdapter, pCurr->abyBSSID, OP_MODE_ADHOC); } @@ -2898,9 +2874,9 @@ s_vMgrFormatTIM( if (!ii) { // Mask out the broadcast bit which is indicated separately. bMulticast = (byMap & byMask[0]) != 0; - if (bMulticast) { + if (bMulticast) pMgmt->sNodeDBTable[0].bRxPSPoll = true; - } + byMap = 0; } if (byMap) { @@ -2930,9 +2906,8 @@ s_vMgrFormatTIM( // Append variable part of TIM - for (ii = wStartIndex, jj = 0; ii <= wEndIndex; ii++, jj++) { + for (ii = wStartIndex, jj = 0; ii <= wEndIndex; ii++, jj++) pTIM->byVirtBitMap[jj] = pMgmt->abyPSTxMap[ii]; - } // Aid = 0 don't used. pTIM->byVirtBitMap[0] &= ~BIT0; @@ -2987,9 +2962,8 @@ s_MgrMakeBeacon( WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_BEACON) )); - if (pDevice->bEnablePSMode) { + if (pDevice->bEnablePSMode) sFrame.pHdr->sA3.wFrameCtl |= cpu_to_le16((unsigned short)WLAN_SET_FC_PWRMGT(1)); - } memcpy(sFrame.pHdr->sA3.abyAddr1, abyBroadcastAddr, WLAN_ADDR_LEN); memcpy(sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN); @@ -3212,9 +3186,8 @@ s_MgrMakeProbeResponse( *sFrame.pwBeaconInterval = cpu_to_le16(wCurrBeaconPeriod); *sFrame.pwCapInfo = cpu_to_le16(wCurrCapInfo); - if (byPHYType == BB_TYPE_11B) { + if (byPHYType == BB_TYPE_11B) *sFrame.pwCapInfo &= cpu_to_le16((unsigned short)~(WLAN_SET_CAP_INFO_SHORTSLOTTIME(1))); - } // Copy SSID sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len); @@ -3457,27 +3430,27 @@ s_MgrMakeAssocRequest( sFrame.pRSNWPA->abyMulticast[0] = 0x00; sFrame.pRSNWPA->abyMulticast[1] = 0x50; sFrame.pRSNWPA->abyMulticast[2] = 0xf2; - if (pMgmt->byCSSGK == KEY_CTL_WEP) { + if (pMgmt->byCSSGK == KEY_CTL_WEP) sFrame.pRSNWPA->abyMulticast[3] = pMgmt->pCurrBSS->byGKType; - } else if (pMgmt->byCSSGK == KEY_CTL_TKIP) { + else if (pMgmt->byCSSGK == KEY_CTL_TKIP) sFrame.pRSNWPA->abyMulticast[3] = WPA_TKIP; - } else if (pMgmt->byCSSGK == KEY_CTL_CCMP) { + else if (pMgmt->byCSSGK == KEY_CTL_CCMP) sFrame.pRSNWPA->abyMulticast[3] = WPA_AESCCMP; - } else { + else sFrame.pRSNWPA->abyMulticast[3] = WPA_NONE; - } + // Pairwise Key Cipher Suite sFrame.pRSNWPA->wPKCount = 1; sFrame.pRSNWPA->PKSList[0].abyOUI[0] = 0x00; sFrame.pRSNWPA->PKSList[0].abyOUI[1] = 0x50; sFrame.pRSNWPA->PKSList[0].abyOUI[2] = 0xf2; - if (pMgmt->byCSSPK == KEY_CTL_TKIP) { + if (pMgmt->byCSSPK == KEY_CTL_TKIP) sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_TKIP; - } else if (pMgmt->byCSSPK == KEY_CTL_CCMP) { + else if (pMgmt->byCSSPK == KEY_CTL_CCMP) sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_AESCCMP; - } else { + else sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_NONE; - } + // Auth Key Management Suite pbyRSN = (unsigned char *)(sFrame.pBuf + sFrame.len + 2 + sFrame.pRSNWPA->len); *pbyRSN++ = 0x01; @@ -3486,13 +3459,12 @@ s_MgrMakeAssocRequest( *pbyRSN++ = 0x50; *pbyRSN++ = 0xf2; - if (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) { + if (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) *pbyRSN++ = WPA_AUTH_PSK; - } else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA) { + else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA) *pbyRSN++ = WPA_AUTH_IEEE802_1X; - } else { + else *pbyRSN++ = WPA_NONE; - } sFrame.pRSNWPA->len += 6; @@ -3523,15 +3495,14 @@ s_MgrMakeAssocRequest( sFrame.pRSN->abyRSN[0] = 0x00; sFrame.pRSN->abyRSN[1] = 0x0F; sFrame.pRSN->abyRSN[2] = 0xAC; - if (pMgmt->byCSSGK == KEY_CTL_WEP) { + if (pMgmt->byCSSGK == KEY_CTL_WEP) sFrame.pRSN->abyRSN[3] = pMgmt->pCurrBSS->byCSSGK; - } else if (pMgmt->byCSSGK == KEY_CTL_TKIP) { + else if (pMgmt->byCSSGK == KEY_CTL_TKIP) sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_TKIP; - } else if (pMgmt->byCSSGK == KEY_CTL_CCMP) { + else if (pMgmt->byCSSGK == KEY_CTL_CCMP) sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_CCMP; - } else { + else sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_UNKNOWN; - } // Pairwise Key Cipher Suite sFrame.pRSN->abyRSN[4] = 1; @@ -3539,15 +3510,15 @@ s_MgrMakeAssocRequest( sFrame.pRSN->abyRSN[6] = 0x00; sFrame.pRSN->abyRSN[7] = 0x0F; sFrame.pRSN->abyRSN[8] = 0xAC; - if (pMgmt->byCSSPK == KEY_CTL_TKIP) { + if (pMgmt->byCSSPK == KEY_CTL_TKIP) sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_TKIP; - } else if (pMgmt->byCSSPK == KEY_CTL_CCMP) { + else if (pMgmt->byCSSPK == KEY_CTL_CCMP) sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_CCMP; - } else if (pMgmt->byCSSPK == KEY_CTL_NONE) { + else if (pMgmt->byCSSPK == KEY_CTL_NONE) sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_USE_GROUP; - } else { + else sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_UNKNOWN; - } + sFrame.pRSN->len += 6; // Auth Key Management Suite @@ -3556,13 +3527,13 @@ s_MgrMakeAssocRequest( sFrame.pRSN->abyRSN[12] = 0x00; sFrame.pRSN->abyRSN[13] = 0x0F; sFrame.pRSN->abyRSN[14] = 0xAC; - if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK) { + if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK) sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_PSK; - } else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) { + else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_802_1X; - } else { + else sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_UNKNOWN; - } + sFrame.pRSN->len += 6; // RSN Capabilities @@ -3587,9 +3558,8 @@ s_MgrMakeAssocRequest( pbyRSN += 16; } } - if (*pwPMKID != 0) { + if (*pwPMKID != 0) sFrame.pRSN->len += (2 + (*pwPMKID)*16); - } } sFrame.len += sFrame.pRSN->len + WLAN_IEHDR_LEN; @@ -3704,27 +3674,27 @@ s_MgrMakeReAssocRequest( sFrame.pRSNWPA->abyMulticast[0] = 0x00; sFrame.pRSNWPA->abyMulticast[1] = 0x50; sFrame.pRSNWPA->abyMulticast[2] = 0xf2; - if (pMgmt->byCSSGK == KEY_CTL_WEP) { + if (pMgmt->byCSSGK == KEY_CTL_WEP) sFrame.pRSNWPA->abyMulticast[3] = pMgmt->pCurrBSS->byGKType; - } else if (pMgmt->byCSSGK == KEY_CTL_TKIP) { + else if (pMgmt->byCSSGK == KEY_CTL_TKIP) sFrame.pRSNWPA->abyMulticast[3] = WPA_TKIP; - } else if (pMgmt->byCSSGK == KEY_CTL_CCMP) { + else if (pMgmt->byCSSGK == KEY_CTL_CCMP) sFrame.pRSNWPA->abyMulticast[3] = WPA_AESCCMP; - } else { + else sFrame.pRSNWPA->abyMulticast[3] = WPA_NONE; - } + // Pairwise Key Cipher Suite sFrame.pRSNWPA->wPKCount = 1; sFrame.pRSNWPA->PKSList[0].abyOUI[0] = 0x00; sFrame.pRSNWPA->PKSList[0].abyOUI[1] = 0x50; sFrame.pRSNWPA->PKSList[0].abyOUI[2] = 0xf2; - if (pMgmt->byCSSPK == KEY_CTL_TKIP) { + if (pMgmt->byCSSPK == KEY_CTL_TKIP) sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_TKIP; - } else if (pMgmt->byCSSPK == KEY_CTL_CCMP) { + else if (pMgmt->byCSSPK == KEY_CTL_CCMP) sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_AESCCMP; - } else { + else sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_NONE; - } + // Auth Key Management Suite pbyRSN = (unsigned char *)(sFrame.pBuf + sFrame.len + 2 + sFrame.pRSNWPA->len); *pbyRSN++ = 0x01; @@ -3733,13 +3703,12 @@ s_MgrMakeReAssocRequest( *pbyRSN++ = 0x50; *pbyRSN++ = 0xf2; - if (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) { + if (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) *pbyRSN++ = WPA_AUTH_PSK; - } else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA) { + else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA) *pbyRSN++ = WPA_AUTH_IEEE802_1X; - } else { + else *pbyRSN++ = WPA_NONE; - } sFrame.pRSNWPA->len += 6; @@ -3769,15 +3738,14 @@ s_MgrMakeReAssocRequest( sFrame.pRSN->abyRSN[0] = 0x00; sFrame.pRSN->abyRSN[1] = 0x0F; sFrame.pRSN->abyRSN[2] = 0xAC; - if (pMgmt->byCSSGK == KEY_CTL_WEP) { + if (pMgmt->byCSSGK == KEY_CTL_WEP) sFrame.pRSN->abyRSN[3] = pMgmt->pCurrBSS->byCSSGK; - } else if (pMgmt->byCSSGK == KEY_CTL_TKIP) { + else if (pMgmt->byCSSGK == KEY_CTL_TKIP) sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_TKIP; - } else if (pMgmt->byCSSGK == KEY_CTL_CCMP) { + else if (pMgmt->byCSSGK == KEY_CTL_CCMP) sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_CCMP; - } else { + else sFrame.pRSN->abyRSN[3] = WLAN_11i_CSS_UNKNOWN; - } // Pairwise Key Cipher Suite sFrame.pRSN->abyRSN[4] = 1; @@ -3785,15 +3753,15 @@ s_MgrMakeReAssocRequest( sFrame.pRSN->abyRSN[6] = 0x00; sFrame.pRSN->abyRSN[7] = 0x0F; sFrame.pRSN->abyRSN[8] = 0xAC; - if (pMgmt->byCSSPK == KEY_CTL_TKIP) { + if (pMgmt->byCSSPK == KEY_CTL_TKIP) sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_TKIP; - } else if (pMgmt->byCSSPK == KEY_CTL_CCMP) { + else if (pMgmt->byCSSPK == KEY_CTL_CCMP) sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_CCMP; - } else if (pMgmt->byCSSPK == KEY_CTL_NONE) { + else if (pMgmt->byCSSPK == KEY_CTL_NONE) sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_USE_GROUP; - } else { + else sFrame.pRSN->abyRSN[9] = WLAN_11i_CSS_UNKNOWN; - } + sFrame.pRSN->len += 6; // Auth Key Management Suite @@ -3802,13 +3770,13 @@ s_MgrMakeReAssocRequest( sFrame.pRSN->abyRSN[12] = 0x00; sFrame.pRSN->abyRSN[13] = 0x0F; sFrame.pRSN->abyRSN[14] = 0xAC; - if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK) { + if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK) sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_PSK; - } else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) { + else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_802_1X; - } else { + else sFrame.pRSN->abyRSN[15] = WLAN_11i_AKMSS_UNKNOWN; - } + sFrame.pRSN->len += 6; // RSN Capabilities @@ -3833,9 +3801,9 @@ s_MgrMakeReAssocRequest( pbyRSN += 16; } } - if (*pwPMKID != 0) { + + if (*pwPMKID != 0) sFrame.pRSN->len += (2 + (*pwPMKID) * 16); - } } sFrame.len += sFrame.pRSN->len + WLAN_IEHDR_LEN; @@ -4158,9 +4126,8 @@ s_vMgrRxProbeRequest( } } - if ((sFrame.pSuppRates->len > 4) || (sFrame.pExtSuppRates != NULL)) { + if ((sFrame.pSuppRates->len > 4) || (sFrame.pExtSuppRates != NULL)) byPHYType = BB_TYPE_11G; - } // Probe response reply.. pTxPacket = s_MgrMakeProbeResponse @@ -4287,9 +4254,9 @@ vMgrRxManagePacket( case WLAN_FSTYPE_BEACON: // Frame Clase = 0 - if (pMgmt->eScanState != WMAC_NO_SCANNING) { + if (pMgmt->eScanState != WMAC_NO_SCANNING) bInScan = true; - } + s_vMgrRxBeacon(pDevice, pMgmt, pRxPacket, bInScan); break; @@ -4354,11 +4321,11 @@ bMgrPrepareBeaconToSend( PSDevice pDevice = (PSDevice)hDeviceContext; PSTxMgmtPacket pTxPacket; - if (pDevice->bEncryptionEnable || pDevice->bEnable8021x) { + if (pDevice->bEncryptionEnable || pDevice->bEnable8021x) pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1); - } else { + else pMgmt->wCurrCapInfo &= ~WLAN_SET_CAP_INFO_PRIVACY(1); - } + pTxPacket = s_MgrMakeBeacon ( pDevice, @@ -4486,22 +4453,22 @@ bAdd_PMKID_Candidate( for (ii = 0; ii < pDevice->gsPMKIDCandidate.NumCandidates; ii++) { pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[ii]; if (!memcmp(pCandidateList->BSSID, pbyBSSID, ETH_ALEN)) { - if (psRSNCapObj->bRSNCapExist && (psRSNCapObj->wRSNCap & BIT0)) { + if (psRSNCapObj->bRSNCapExist && (psRSNCapObj->wRSNCap & BIT0)) pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED; - } else { + else pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED); - } + return true; } } // New Candidate pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[pDevice->gsPMKIDCandidate.NumCandidates]; - if (psRSNCapObj->bRSNCapExist && (psRSNCapObj->wRSNCap & BIT0)) { + if (psRSNCapObj->bRSNCapExist && (psRSNCapObj->wRSNCap & BIT0)) pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED; - } else { + else pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED); - } + memcpy(pCandidateList->BSSID, pbyBSSID, ETH_ALEN); pDevice->gsPMKIDCandidate.NumCandidates++; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "NumCandidates:%d\n", (int)pDevice->gsPMKIDCandidate.NumCandidates); diff --git a/drivers/staging/vt6655/wpa2.c b/drivers/staging/vt6655/wpa2.c index f5be587f78d2..4e1b63be380f 100644 --- a/drivers/staging/vt6655/wpa2.c +++ b/drivers/staging/vt6655/wpa2.c @@ -121,9 +121,9 @@ WPA2vParseRSN( WPA2_ClearRSN(pBSSNode); if (pRSN->len == 2) { // ver(2) - if ((pRSN->byElementID == WLAN_EID_RSN) && (pRSN->wVersion == 1)) { + if ((pRSN->byElementID == WLAN_EID_RSN) && (pRSN->wVersion == 1)) pBSSNode->bWPA2Valid = true; - } + return; } @@ -267,9 +267,9 @@ WPA2uSetIEs( unsigned int ii = 0; unsigned short *pwPMKID = NULL; - if (pRSNIEs == NULL) { + if (pRSNIEs == NULL) return 0; - } + if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) || (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) && (pMgmt->pCurrBSS != NULL)) { @@ -282,15 +282,14 @@ WPA2uSetIEs( pRSNIEs->abyRSN[0] = 0x00; pRSNIEs->abyRSN[1] = 0x0F; pRSNIEs->abyRSN[2] = 0xAC; - if (pMgmt->byCSSGK == KEY_CTL_WEP) { + if (pMgmt->byCSSGK == KEY_CTL_WEP) pRSNIEs->abyRSN[3] = pMgmt->pCurrBSS->byCSSGK; - } else if (pMgmt->byCSSGK == KEY_CTL_TKIP) { + else if (pMgmt->byCSSGK == KEY_CTL_TKIP) pRSNIEs->abyRSN[3] = WLAN_11i_CSS_TKIP; - } else if (pMgmt->byCSSGK == KEY_CTL_CCMP) { + else if (pMgmt->byCSSGK == KEY_CTL_CCMP) pRSNIEs->abyRSN[3] = WLAN_11i_CSS_CCMP; - } else { + else pRSNIEs->abyRSN[3] = WLAN_11i_CSS_UNKNOWN; - } // Pairwise Key Cipher Suite pRSNIEs->abyRSN[4] = 1; @@ -298,15 +297,15 @@ WPA2uSetIEs( pRSNIEs->abyRSN[6] = 0x00; pRSNIEs->abyRSN[7] = 0x0F; pRSNIEs->abyRSN[8] = 0xAC; - if (pMgmt->byCSSPK == KEY_CTL_TKIP) { + if (pMgmt->byCSSPK == KEY_CTL_TKIP) pRSNIEs->abyRSN[9] = WLAN_11i_CSS_TKIP; - } else if (pMgmt->byCSSPK == KEY_CTL_CCMP) { + else if (pMgmt->byCSSPK == KEY_CTL_CCMP) pRSNIEs->abyRSN[9] = WLAN_11i_CSS_CCMP; - } else if (pMgmt->byCSSPK == KEY_CTL_NONE) { + else if (pMgmt->byCSSPK == KEY_CTL_NONE) pRSNIEs->abyRSN[9] = WLAN_11i_CSS_USE_GROUP; - } else { + else pRSNIEs->abyRSN[9] = WLAN_11i_CSS_UNKNOWN; - } + pRSNIEs->len += 6; // Auth Key Management Suite @@ -315,13 +314,13 @@ WPA2uSetIEs( pRSNIEs->abyRSN[12] = 0x00; pRSNIEs->abyRSN[13] = 0x0F; pRSNIEs->abyRSN[14] = 0xAC; - if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK) { + if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK) pRSNIEs->abyRSN[15] = WLAN_11i_AKMSS_PSK; - } else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) { + else if (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) pRSNIEs->abyRSN[15] = WLAN_11i_AKMSS_802_1X; - } else { + else pRSNIEs->abyRSN[15] = WLAN_11i_AKMSS_UNKNOWN; - } + pRSNIEs->len += 6; // RSN Capabilities @@ -347,11 +346,10 @@ WPA2uSetIEs( pbyBuffer += 16; } } - if (*pwPMKID != 0) { + if (*pwPMKID != 0) pRSNIEs->len += (2 + (*pwPMKID)*16); - } else { + else pbyBuffer = &pRSNIEs->abyRSN[18]; - } } return pRSNIEs->len + WLAN_IEHDR_LEN; } diff --git a/drivers/staging/vt6655/wpactl.c b/drivers/staging/vt6655/wpactl.c index 5e0fae0743a5..089e8a7bcfbf 100644 --- a/drivers/staging/vt6655/wpactl.c +++ b/drivers/staging/vt6655/wpactl.c @@ -212,9 +212,9 @@ int wpa_set_keys(PSDevice pDevice, void *ctx, pDevice->byKeyIndex = 0; pDevice->bTransmitKey = false; KeyvRemoveAllWEPKey(&(pDevice->sKey), pDevice->PortOffset); - for (uu = 0; uu < MAX_KEY_TABLE; uu++) { + for (uu = 0; uu < MAX_KEY_TABLE; uu++) MACvDisableKeyEntry(pDevice->PortOffset, uu); - } + return ret; } @@ -283,13 +283,11 @@ int wpa_set_keys(PSDevice pDevice, void *ctx, return -EINVAL; } - if (param->u.wpa_key.alg_name == WPA_ALG_TKIP) { + if (param->u.wpa_key.alg_name == WPA_ALG_TKIP) pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled; - } - if (param->u.wpa_key.alg_name == WPA_ALG_CCMP) { + if (param->u.wpa_key.alg_name == WPA_ALG_CCMP) pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled; - } if (param->u.wpa_key.set_tx) dwKeyIndex |= (1 << 31); @@ -639,9 +637,9 @@ static int wpa_get_scan(PSDevice pDevice, if (jj < count) count = jj; - if (copy_to_user(param->u.scan_results.buf, pBuf, sizeof(struct viawget_scan_result) * count)) { + if (copy_to_user(param->u.scan_results.buf, pBuf, sizeof(struct viawget_scan_result) * count)) ret = -EFAULT; - } + param->u.scan_results.scan_count = count; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " param->u.scan_results.scan_count = %d\n", count); @@ -703,9 +701,8 @@ static int wpa_set_associate(PSDevice pDevice, // set bssid if (memcmp(param->u.wpa_associate.bssid, &abyNullAddr[0], 6) != 0) memcpy(pMgmt->abyDesireBSSID, param->u.wpa_associate.bssid, 6); - else { + else bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, pItemSSID->abySSID); - } if (param->u.wpa_associate.wpa_ie_len == 0) { if (param->u.wpa_associate.auth_alg & AUTH_ALG_SHARED_KEY) -- cgit v1.2.3 From ea9a8dae5acca2e2ac0421279de7818e92e4b251 Mon Sep 17 00:00:00 2001 From: Martin Kepplinger Date: Tue, 6 May 2014 07:58:39 +0200 Subject: staging: vt6656: make spin_lock_irq() human readable Don't require FIRMWAREbDownload() to, first off, unlock a held lock. Thus do all locking in main_usb.c and hold it for a insignificantly shorter period of time. This makes the affected area significantly more readable though. Signed-off-by: Martin Kepplinger Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/firmware.c | 2 -- drivers/staging/vt6656/main_usb.c | 5 ++++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vt6656/firmware.c b/drivers/staging/vt6656/firmware.c index 15c1e861c84b..afb79c66a933 100644 --- a/drivers/staging/vt6656/firmware.c +++ b/drivers/staging/vt6656/firmware.c @@ -55,7 +55,6 @@ int FIRMWAREbDownload(struct vnt_private *pDevice) __must_hold(&pDevice->lock) int ii, rc; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Download firmware\n"); - spin_unlock_irq(&pDevice->lock); rc = request_firmware(&fw, FIRMWARE_NAME, dev); if (rc) { @@ -92,7 +91,6 @@ free_fw: out: kfree(pBuffer); - spin_lock_irq(&pDevice->lock); return result; } MODULE_FIRMWARE(FIRMWARE_NAME); diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 3c9323069e01..1dc02c4abbed 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -319,7 +319,11 @@ static int device_init_registers(struct vnt_private *pDevice) memcpy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel, ETH_ALEN); if (!FIRMWAREbCheckVersion(pDevice)) { + + spin_unlock_irq(&pDevice->lock); if (FIRMWAREbDownload(pDevice) == true) { + + spin_lock_irq(&pDevice->lock); if (FIRMWAREbBrach2Sram(pDevice) == false) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " FIRMWAREbBrach2Sram fail\n"); @@ -329,7 +333,6 @@ static int device_init_registers(struct vnt_private *pDevice) } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " FIRMWAREbDownload fail\n"); - spin_unlock_irq(&pDevice->lock); return false; } } -- cgit v1.2.3 From 05cc617b5db8a6debac873e4dcfbd6d679406730 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 30 Apr 2014 21:31:12 +0100 Subject: staging: vt6656: rxtx: Remove unused uDMAIdx from driver. Remove from functions and callers. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/main_usb.c | 2 +- drivers/staging/vt6656/rxtx.c | 33 +++++++++++++++------------------ drivers/staging/vt6656/rxtx.h | 2 +- drivers/staging/vt6656/wcmd.c | 4 ++-- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 1dc02c4abbed..208640b1d775 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -1192,7 +1192,7 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev) goto out; } - if (nsDMA_tx_packet(pDevice, TYPE_AC0DMA, skb)) { + if (nsDMA_tx_packet(pDevice, skb)) { if (netif_queue_stopped(dev)) netif_wake_queue(dev); } diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 28f40e6bd262..03d5339191b6 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -101,11 +101,11 @@ static struct vnt_usb_send_context *s_vGetFreeContext(struct vnt_private *); static u16 s_vGenerateTxParameter(struct vnt_private *pDevice, u8 byPktType, u16 wCurrentRate, struct vnt_tx_buffer *tx_buffer, struct vnt_mic_hdr **mic_hdr, u32 need_mic, u32 cbFrameSize, - int bNeedACK, u32 uDMAIdx, struct ethhdr *psEthHeader, bool need_rts); + int bNeedACK, struct ethhdr *psEthHeader, bool need_rts); static void s_vGenerateMACHeader(struct vnt_private *pDevice, u8 *pbyBufferAddr, u16 wDuration, struct ethhdr *psEthHeader, - int bNeedEncrypt, u16 wFragType, u32 uDMAIdx, u32 uFragIdx); + int bNeedEncrypt, u16 wFragType, u32 uFragIdx); static void s_vFillTxKey(struct vnt_private *pDevice, struct vnt_tx_fifo_head *fifo_head, u8 *pbyIVHead, @@ -121,7 +121,7 @@ static unsigned int s_uGetTxRsvTime(struct vnt_private *pDevice, u8 byPktType, static __le16 s_uGetRTSCTSRsvTime(struct vnt_private *priv, u8 rsv_type, u8 pkt_type, u32 frame_lenght, u16 current_rate); -static u16 s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, +static u16 s_vFillCTSHead(struct vnt_private *pDevice, u8 byPktType, union vnt_tx_data_head *head, u32 cbFrameLength, int bNeedAck, u16 wCurrentRate, u8 byFBOption); @@ -714,7 +714,7 @@ static u16 s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, return 0; } -static u16 s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, +static u16 s_vFillCTSHead(struct vnt_private *pDevice, u8 byPktType, union vnt_tx_data_head *head, u32 cbFrameLength, int bNeedAck, u16 wCurrentRate, u8 byFBOption) { @@ -787,7 +787,6 @@ static u16 s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, * pCTS - CTS Buffer * cbFrameSize - Transmit Data Length (Hdr+Payload+FCS) * bNeedACK - If need ACK - * uDMAIdx - DMA Index * Out: * none * @@ -798,7 +797,7 @@ static u16 s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, static u16 s_vGenerateTxParameter(struct vnt_private *pDevice, u8 byPktType, u16 wCurrentRate, struct vnt_tx_buffer *tx_buffer, struct vnt_mic_hdr **mic_hdr, u32 need_mic, u32 cbFrameSize, - int bNeedACK, u32 uDMAIdx, struct ethhdr *psEthHeader, bool need_rts) + int bNeedACK, struct ethhdr *psEthHeader, bool need_rts) { struct vnt_tx_fifo_head *pFifoHead = &tx_buffer->fifo_head; union vnt_tx_data_head *head = NULL; @@ -866,7 +865,7 @@ static u16 s_vGenerateTxParameter(struct vnt_private *pDevice, } /* Fill CTS */ - return s_vFillCTSHead(pDevice, uDMAIdx, byPktType, + return s_vFillCTSHead(pDevice, byPktType, head, cbFrameSize, bNeedACK, wCurrentRate, byFBOption); } @@ -951,7 +950,7 @@ static u16 s_vGenerateTxParameter(struct vnt_private *pDevice, static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, struct vnt_tx_buffer *tx_buffer, int bNeedEncryption, - u32 uSkbPacketLen, u32 uDMAIdx, struct ethhdr *psEthHeader, + u32 uSkbPacketLen, struct ethhdr *psEthHeader, u8 *pPacket, PSKeyItem pTransmitKey, u32 uNodeIndex, u16 wCurrentRate, u32 *pcbHeaderLen, u32 *pcbTotalLen) { @@ -1147,17 +1146,16 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, //========================= DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No Fragmentation...\n"); byFragType = FRAGCTL_NONFRAG; - //uDMAIdx = TYPE_AC0DMA; //pTxBufHead = (PSTxBufHead) &(pTxBufHead->adwTxKey[0]); /* Fill FIFO, RrvTime, RTS and CTS */ uDuration = s_vGenerateTxParameter(pDevice, byPktType, wCurrentRate, tx_buffer, &pMICHDR, cbMICHDR, - cbFrameSize, bNeedACK, uDMAIdx, psEthHeader, bRTS); + cbFrameSize, bNeedACK, psEthHeader, bRTS); // Generate TX MAC Header s_vGenerateMACHeader(pDevice, pbyMacHdr, (u16)uDuration, psEthHeader, bNeedEncryption, - byFragType, uDMAIdx, 0); + byFragType, 0); if (bNeedEncryption == true) { //Fill TXKEY @@ -1289,7 +1287,7 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, static void s_vGenerateMACHeader(struct vnt_private *pDevice, u8 *pbyBufferAddr, u16 wDuration, struct ethhdr *psEthHeader, - int bNeedEncrypt, u16 wFragType, u32 uDMAIdx, u32 uFragIdx) + int bNeedEncrypt, u16 wFragType, u32 uFragIdx) { struct ieee80211_hdr *pMACHeader = (struct ieee80211_hdr *)pbyBufferAddr; @@ -1529,7 +1527,7 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, /* Fill FIFO,RrvTime,RTS,and CTS */ uDuration = s_vGenerateTxParameter(pDevice, byPktType, wCurrentRate, pTX_Buffer, &pMICHDR, 0, - cbFrameSize, bNeedACK, TYPE_TXDMA0, &sEthHeader, false); + cbFrameSize, bNeedACK, &sEthHeader, false); pMACHeader = (struct ieee80211_hdr *) (pbyTxBufferAddr + cbHeaderSize); @@ -1923,7 +1921,7 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) /* Fill FIFO,RrvTime,RTS,and CTS */ uDuration = s_vGenerateTxParameter(pDevice, byPktType, wCurrentRate, pTX_Buffer, &pMICHDR, cbMICHDR, - cbFrameSize, bNeedACK, TYPE_TXDMA0, &sEthHeader, false); + cbFrameSize, bNeedACK, &sEthHeader, false); pMACHeader = (struct ieee80211_hdr *) (pbyTxBufferAddr + cbHeaderSize); @@ -2085,8 +2083,7 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) * Return Value: NULL */ -int nsDMA_tx_packet(struct vnt_private *pDevice, - u32 uDMAIdx, struct sk_buff *skb) +int nsDMA_tx_packet(struct vnt_private *pDevice, struct sk_buff *skb) { struct net_device_stats *pStats = &pDevice->stats; struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; @@ -2417,7 +2414,7 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, fConvertedPacket = s_bPacketToWirelessUsb(pDevice, byPktType, pTX_Buffer, bNeedEncryption, - skb->len, uDMAIdx, &pDevice->sTxEthHeader, + skb->len, &pDevice->sTxEthHeader, (u8 *)skb->data, pTransmitKey, uNodeIndex, pDevice->wCurrentRate, &uHeaderLen, &BytesToWrite @@ -2581,7 +2578,7 @@ int bRelayPacketSend(struct vnt_private *pDevice, u8 *pbySkbData, u32 uDataLen, fConvertedPacket = s_bPacketToWirelessUsb(pDevice, byPktType, pTX_Buffer, bNeedEncryption, - uDataLen, TYPE_AC0DMA, &pDevice->sTxEthHeader, + uDataLen, &pDevice->sTxEthHeader, pbySkbData, pTransmitKey, uNodeIndex, pDevice->wCurrentRate, &uHeaderLen, &BytesToWrite diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h index 4dfb2e0c6ae7..982f1624efac 100644 --- a/drivers/staging/vt6656/rxtx.h +++ b/drivers/staging/vt6656/rxtx.h @@ -247,7 +247,7 @@ struct vnt_beacon_buffer { } __packed; void vDMA0_tx_80211(struct vnt_private *, struct sk_buff *skb); -int nsDMA_tx_packet(struct vnt_private *, u32 uDMAIdx, struct sk_buff *skb); +int nsDMA_tx_packet(struct vnt_private *, struct sk_buff *skb); CMD_STATUS csMgmt_xmit(struct vnt_private *, struct vnt_tx_mgmt *); CMD_STATUS csBeacon_xmit(struct vnt_private *, struct vnt_tx_mgmt *); int bRelayPacketSend(struct vnt_private *, u8 *pbySkbData, u32 uDataLen, diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c index 3cf3f24247a3..de7e80897abe 100644 --- a/drivers/staging/vt6656/wcmd.c +++ b/drivers/staging/vt6656/wcmd.c @@ -675,7 +675,7 @@ void vRunCommand(struct work_struct *work) pDevice->bMoreData = true; } - if (nsDMA_tx_packet(pDevice, TYPE_AC0DMA, skb) != 0) + if (nsDMA_tx_packet(pDevice, skb) != 0) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Multicast ps tx fail\n"); pMgmt->sNodeDBTable[0].wEnQueueCnt--; @@ -698,7 +698,7 @@ void vRunCommand(struct work_struct *work) pDevice->bMoreData = true; } - if (nsDMA_tx_packet(pDevice, TYPE_AC0DMA, skb) != 0) + if (nsDMA_tx_packet(pDevice, skb) != 0) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "sta ps tx fail\n"); pMgmt->sNodeDBTable[ii].wEnQueueCnt--; -- cgit v1.2.3 From 62a3f8a10d8dab8bae7565358bee3f923f02b8a0 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 30 Apr 2014 21:31:13 +0100 Subject: staging: vt6656: desh.h Remove unused macros and structures. All are dead and of no use. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/desc.h | 55 ------------------------------------------- 1 file changed, 55 deletions(-) diff --git a/drivers/staging/vt6656/desc.h b/drivers/staging/vt6656/desc.h index 7c6dd5f52295..171315ab864a 100644 --- a/drivers/staging/vt6656/desc.h +++ b/drivers/staging/vt6656/desc.h @@ -91,15 +91,6 @@ #define TSR_ACKDATA 0x02 #define TSR_VALID 0x01 -#define CB_PROTOCOL_RESERVED_SECTION 16 - -/* - * if retries exceed 15 times, TX will abort, and - * if TX fifo underflow, TX will fail - * we should try to resend it - */ -#define CB_MAX_TX_ABORT_RETRY 3 - #define FIFOCTL_AUTO_FB_1 0x1000 #define FIFOCTL_AUTO_FB_0 0x0800 #define FIFOCTL_GRPACK 0x0400 @@ -126,50 +117,4 @@ #define FRAGCTL_STAFRAG 0x0001 #define FRAGCTL_NONFRAG 0x0000 -#define TYPE_TXDMA0 0 -#define TYPE_AC0DMA 1 -#define TYPE_ATIMDMA 2 -#define TYPE_SYNCDMA 3 -#define TYPE_MAXTD 2 - -#define TYPE_BEACONDMA 4 - -#define TYPE_RXDMA0 0 -#define TYPE_RXDMA1 1 -#define TYPE_MAXRD 2 - -/* TD_INFO flags control bit */ -#define TD_FLAGS_NETIF_SKB 0x01 /* check if need release skb */ -#define TD_FLAGS_PRIV_SKB 0x02 /* check if called from private skb(hostap) */ -#define TD_FLAGS_PS_RETRY 0x04 /* check if PS STA frame re-transmit */ - -/* - * TX FIFO header - */ -typedef struct tagSBEACONCtl { - u32 BufReady:1; - u32 TSF:15; - u32 BufLen:11; - u32 Reserved:5; -} __attribute__ ((__packed__)) -SBEACONCtl; - -typedef struct tagSSecretKey { - u32 dwLowDword; - u8 byHighByte; -} __attribute__ ((__packed__)) -SSecretKey; - -typedef struct tagSKeyEntry { - u8 abyAddrHi[2]; - u16 wKCTL; - u8 abyAddrLo[4]; - u32 dwKey0[4]; - u32 dwKey1[4]; - u32 dwKey2[4]; - u32 dwKey3[4]; - u32 dwKey4[4]; -} __attribute__ ((__packed__)) -SKeyEntry; - #endif /* __DESC_H__ */ -- cgit v1.2.3 From 721b79d12fef7f13c0ac2cabb7cce39976769fcf Mon Sep 17 00:00:00 2001 From: Christian Engelmayer Date: Wed, 7 May 2014 21:43:37 +0200 Subject: staging: vt6656: fix potential leak in vt6656_hostap_ioctl() Commit fb841d67 (staging: vt6656: don't leak 'param' in vt6656_hostap_ioctl() when returning -EOPNOTSUPP) cleaned up direct returns in the ioctl switch statement that leaked already allocated memory. Fix the same issue for VIAWGET_HOSTAPD_SCAN_REQ and VIAWGET_HOSTAPD_MLME that are not supported by this driver. Detected by Coverity - CID 144381. Signed-off-by: Christian Engelmayer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/hostap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c index 67ba48b9a8d9..a0d9fffb3787 100644 --- a/drivers/staging/vt6656/hostap.c +++ b/drivers/staging/vt6656/hostap.c @@ -742,7 +742,8 @@ int vt6656_hostap_ioctl(struct vnt_private *pDevice, struct iw_point *p) case VIAWGET_HOSTAPD_MLME: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_MLME \n"); - return -EOPNOTSUPP; + ret = -EOPNOTSUPP; + goto out; case VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT \n"); @@ -751,7 +752,8 @@ int vt6656_hostap_ioctl(struct vnt_private *pDevice, struct iw_point *p) case VIAWGET_HOSTAPD_SCAN_REQ: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SCAN_REQ \n"); - return -EOPNOTSUPP; + ret = -EOPNOTSUPP; + goto out; case VIAWGET_HOSTAPD_STA_CLEAR_STATS: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_STA_CLEAR_STATS \n"); -- cgit v1.2.3 From 542f3d5af89c15d0b4e80bbf927d252efa0e48c3 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Fri, 25 Apr 2014 14:32:15 -0400 Subject: staging: dgap: Add Mark Hounschell to maintainers list for dgap Add Mark Hounschell to the MAINTAINERs list for the dgap driver Signed-off-by: Mark Hounschell Suggested-by: Dan Carpenter Cc: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index da6867988988..610c982af198 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2789,6 +2789,7 @@ F: sound/soc/codecs/da[79]*.[ch] DIGI NEO AND CLASSIC PCI PRODUCTS M: Lidza Louina +M: Mark Hounschell L: driverdev-devel@linuxdriverproject.org S: Maintained F: drivers/staging/dgnc/ -- cgit v1.2.3 From 2b46be68a1b67f40df4f288b90e79181c387eda6 Mon Sep 17 00:00:00 2001 From: Antoine Sirinelli Date: Thu, 27 Mar 2014 22:31:55 +0100 Subject: staging: dgnc: cleanup dgnc_finalize_board_init() Trivial cleanups: - Transform a printk() to a dev_err() call - Fix 2 lines over 80 characters Signed-off-by: Antoine Sirinelli Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_driver.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c index b1a39b25b419..900deb655dcf 100644 --- a/drivers/staging/dgnc/dgnc_driver.c +++ b/drivers/staging/dgnc/dgnc_driver.c @@ -730,15 +730,18 @@ static int dgnc_finalize_board_init(struct dgnc_board *brd) { DPR_INIT(("dgnc_finalize_board_init() - start #2\n")); if (brd->irq) { - rc = request_irq(brd->irq, brd->bd_ops->intr, IRQF_SHARED, "DGNC", brd); + rc = request_irq(brd->irq, brd->bd_ops->intr, + IRQF_SHARED, "DGNC", brd); if (rc) { - printk("Failed to hook IRQ %d\n",brd->irq); + dev_err(&brd->pdev->dev, + "Failed to hook IRQ %d\n", brd->irq); brd->state = BOARD_FAILED; brd->dpastatus = BD_NOFEP; rc = -ENODEV; } else { - DPR_INIT(("Requested and received usage of IRQ %d\n", brd->irq)); + DPR_INIT(("Requested and received usage of IRQ %d\n", + brd->irq)); } } return rc; -- cgit v1.2.3 From 3f2889621a6d47c3aa5e4284af808f8d79cc5d5d Mon Sep 17 00:00:00 2001 From: "Son P. Nguyen" Date: Sun, 20 Apr 2014 18:05:39 +0000 Subject: Staging: dgnc: dgnc_driver: fixed incorrect braces Fixed incorrect braces (coding style) Signed-off-by: Son P. Nguyen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_driver.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c index 900deb655dcf..031e13e1f51a 100644 --- a/drivers/staging/dgnc/dgnc_driver.c +++ b/drivers/staging/dgnc/dgnc_driver.c @@ -153,8 +153,7 @@ struct board_id { unsigned int is_pci_express; }; -static struct board_id dgnc_Ids[] = -{ +static struct board_id dgnc_Ids[] = { { PCI_DEVICE_CLASSIC_4_PCI_NAME, 4, 0 }, { PCI_DEVICE_CLASSIC_4_422_PCI_NAME, 4, 0 }, { PCI_DEVICE_CLASSIC_8_PCI_NAME, 8, 0 }, @@ -219,9 +218,8 @@ int dgnc_init_module(void) */ rc = dgnc_start(); - if (rc < 0) { + if (rc < 0) return rc; - } /* * Find and configure all the cards @@ -239,8 +237,7 @@ int dgnc_init_module(void) pr_warn("WARNING: dgnc driver load failed. No Digi Neo or Classic boards found.\n"); dgnc_cleanup_module(); - } - else { + } else { dgnc_create_driver_sysfiles(&dgnc_driver); } @@ -519,9 +516,8 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) brd->state = BOARD_FOUND; - for (i = 0; i < MAXPORTS; i++) { + for (i = 0; i < MAXPORTS; i++) brd->channels[i] = NULL; - } /* store which card & revision we have */ pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID, &brd->subvendor); @@ -802,9 +798,8 @@ static void dgnc_poll_handler(ulong dummy) * driver tells us its up and running, and has * everything it needs. */ - if (dgnc_driver_state != DRIVER_READY) { + if (dgnc_driver_state != DRIVER_READY) goto schedule_poller; - } /* Go thru each board, kicking off a tasklet for each if needed */ for (i = 0; i < dgnc_NumBoards; i++) { @@ -834,9 +829,8 @@ schedule_poller: new_time = dgnc_poll_time - jiffies; - if ((ulong) new_time >= 2 * dgnc_poll_tick) { + if ((ulong) new_time >= 2 * dgnc_poll_tick) dgnc_poll_time = jiffies + dgnc_jiffies_from_ms(dgnc_poll_tick); - } init_timer(&dgnc_poll_timer); dgnc_poll_timer.function = dgnc_poll_handler; @@ -863,9 +857,8 @@ static void dgnc_init_globals(void) dgnc_trcbuf_size = trcbuf_size; dgnc_debug = debug; - for (i = 0; i < MAXBOARDS; i++) { + for (i = 0; i < MAXBOARDS; i++) dgnc_Board[i] = NULL; - } init_timer(&dgnc_poll_timer); } -- cgit v1.2.3 From 36aa10aa018c2ed5571ffd145f39d3fcf993cee0 Mon Sep 17 00:00:00 2001 From: Vitaly Osipov Date: Sun, 27 Apr 2014 00:59:17 +1000 Subject: staging: dgnc: redundant NULL checks before kfree() Removed redundant NULL checks before calling kfree() Signed-off-by: Vitaly Osipov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_driver.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c index 031e13e1f51a..5af8300dfb0d 100644 --- a/drivers/staging/dgnc/dgnc_driver.c +++ b/drivers/staging/dgnc/dgnc_driver.c @@ -448,20 +448,15 @@ static void dgnc_cleanup_board(struct dgnc_board *brd) /* Free all allocated channels structs */ for (i = 0; i < MAXPORTS ; i++) { if (brd->channels[i]) { - if (brd->channels[i]->ch_rqueue) - kfree(brd->channels[i]->ch_rqueue); - if (brd->channels[i]->ch_equeue) - kfree(brd->channels[i]->ch_equeue); - if (brd->channels[i]->ch_wqueue) - kfree(brd->channels[i]->ch_wqueue); - + kfree(brd->channels[i]->ch_rqueue); + kfree(brd->channels[i]->ch_equeue); + kfree(brd->channels[i]->ch_wqueue); kfree(brd->channels[i]); brd->channels[i] = NULL; } } - if (brd->flipbuf) - kfree(brd->flipbuf); + kfree(brd->flipbuf); dgnc_Board[brd->boardnum] = NULL; -- cgit v1.2.3 From 0f33ae1ed6ac39da7b1f73972eb4791fe43d15d3 Mon Sep 17 00:00:00 2001 From: Martin Kepplinger Date: Tue, 29 Apr 2014 11:43:08 +0200 Subject: staging: dgnc: use dev_err() instead of printk() Use dev_err() insted of printk() in order to provice userspace with more useful information and use the common kernel coding style. Signed-off-by: Martin Kepplinger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/dgnc/dgnc_sysfs.c b/drivers/staging/dgnc/dgnc_sysfs.c index 946230c23487..0f0e8fcb663f 100644 --- a/drivers/staging/dgnc/dgnc_sysfs.c +++ b/drivers/staging/dgnc/dgnc_sysfs.c @@ -739,7 +739,7 @@ void dgnc_create_tty_sysfs(struct un_t *un, struct device *c) ret = sysfs_create_group(&c->kobj, &dgnc_tty_attribute_group); if (ret) { - printk(KERN_ERR "dgnc: failed to create sysfs tty device attributes.\n"); + dev_err(c, "dgnc: failed to create sysfs tty device attributes.\n"); sysfs_remove_group(&c->kobj, &dgnc_tty_attribute_group); return; } -- cgit v1.2.3 From c80561e96b81a01c3e4988fc08093479a1f0c914 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 14 May 2014 19:13:07 +0300 Subject: staging: dgnc: UART_IIR_XOFF code is buggy The UART_IIR_XOFF was supposed to be a no-op but, because there was a missing semi-colon, the if statement is not "Empty". I have just deleted this code because it was supposed to be a no-op anyway. UART_IIR_XOFF is a standard define and not something specific to this driver. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_cls.c | 4 ---- drivers/staging/dgnc/dgnc_cls.h | 1 - 2 files changed, 5 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_cls.c b/drivers/staging/dgnc/dgnc_cls.c index 60d9b62c6f1f..8e265c20db59 100644 --- a/drivers/staging/dgnc/dgnc_cls.c +++ b/drivers/staging/dgnc/dgnc_cls.c @@ -453,10 +453,6 @@ static inline void cls_parse_isr(struct dgnc_board *brd, uint port) cls_copy_data_from_queue_to_uart(ch); } - /* Received Xoff signal/Special character */ - if (isr & UART_IIR_XOFF) - /* Empty */ - /* CTS/RTS change of state */ if (isr & UART_IIR_CTSRTS) { brd->intr_modem++; diff --git a/drivers/staging/dgnc/dgnc_cls.h b/drivers/staging/dgnc/dgnc_cls.h index ffe8535a84a9..465d79a6f75f 100644 --- a/drivers/staging/dgnc/dgnc_cls.h +++ b/drivers/staging/dgnc/dgnc_cls.h @@ -61,7 +61,6 @@ struct cls_uart_struct { #define UART_16654_FCR_RXTRIGGER_56 0x80 #define UART_16654_FCR_RXTRIGGER_60 0xC0 -#define UART_IIR_XOFF 0x10 /* Received Xoff signal/Special character */ #define UART_IIR_CTSRTS 0x20 /* Received CTS/RTS change of state */ #define UART_IIR_RDI_TIMEOUT 0x0C /* Receiver data TIMEOUT */ -- cgit v1.2.3 From 87a76301091f8ff0c24e31c8befc6a4f699536f1 Mon Sep 17 00:00:00 2001 From: Anders Darander Date: Tue, 1 Apr 2014 08:29:39 +0200 Subject: Staging: ft1000-usb: wrap macros in do while Fix coding style issue by wrapping the macro in a do {} while (0). Signed-off-by: Anders Darander Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_proc.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c b/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c index 2575d0d6bff3..28f07a765098 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c @@ -32,17 +32,20 @@ #define seq_putx(m, message, size, var) \ - seq_printf(m, message); \ - for (i = 0; i < (size - 1); i++) \ - seq_printf(m, "%02x:", var[i]); \ - seq_printf(m, "%02x\n", var[i]) + do { \ + seq_printf(m, message); \ + for (i = 0; i < (size - 1); i++) \ + seq_printf(m, "%02x:", var[i]); \ + seq_printf(m, "%02x\n", var[i]); \ + } while (0) #define seq_putd(m, message, size, var) \ - seq_printf(m, message); \ - for (i = 0; i < (size - 1); i++) \ - seq_printf(m, "%d.", var[i]); \ - seq_printf(m, "%d\n", var[i]) - + do { \ + seq_printf(m, message); \ + for (i = 0; i < (size - 1); i++) \ + seq_printf(m, "%d.", var[i]); \ + seq_printf(m, "%d\n", var[i]); \ + } while (0) #define FTNET_PROC init_net.proc_net -- cgit v1.2.3 From a713cd594117c6841dbd56b608fa8629673f6617 Mon Sep 17 00:00:00 2001 From: Anders Darander Date: Tue, 1 Apr 2014 08:29:40 +0200 Subject: Staging: ft1000-usb: use netdev_warn Fix coding style issue by replacing printk with netdev_warn. Signed-off-by: Anders Darander Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_proc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c b/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c index 28f07a765098..e89b5d2c8e62 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c @@ -203,7 +203,7 @@ int ft1000_init_proc(struct net_device *dev) info->ft1000_proc_dir = proc_mkdir(FT1000_PROC_DIR, FTNET_PROC); if (info->ft1000_proc_dir == NULL) { - printk(KERN_WARNING "Unable to create %s dir.\n", + netdev_warn(dev, "Unable to create %s dir.\n", FT1000_PROC_DIR); goto fail; } @@ -213,7 +213,7 @@ int ft1000_init_proc(struct net_device *dev) &ft1000_proc_fops, dev); if (!ft1000_proc_file) { - printk(KERN_WARNING "Unable to create /proc entry.\n"); + netdev_warn(dev, "Unable to create /proc entry.\n"); goto fail_entry; } -- cgit v1.2.3 From 248b6a67567778123bf635945659e64cfe272e3b Mon Sep 17 00:00:00 2001 From: Paul McQuade Date: Thu, 3 Apr 2014 17:21:22 +0100 Subject: Staging:ft1000_debug.c:Renaming __FUNCTION__ __Function__ gets renamed with __func__ Signed-off-by: Paul McQuade Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c index ffdc7f597a96..dc7647f222f0 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c @@ -785,7 +785,7 @@ static int ft1000_release(struct inode *inode, struct file *file) /* initialize application information */ ft1000dev->appcnt--; - DEBUG("ft1000_chdev:%s:appcnt = %d\n", __FUNCTION__, ft1000dev->appcnt); + DEBUG("ft1000_chdev:%s:appcnt = %d\n", __func__, ft1000dev->appcnt); ft1000dev->app_info[i].fileobject = NULL; return 0; -- cgit v1.2.3 From 77a6f000a1a22d295b87a1a767ffe75b98f1775f Mon Sep 17 00:00:00 2001 From: Angus Gibson Date: Mon, 7 Apr 2014 12:29:30 +1000 Subject: staging: ft1000: remove explicit static initialisation Fix checkpatch.pl error where a static variable was explicitly initialised to false Signed-off-by: Angus Gibson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c index e40763e60dbd..0a2544c78292 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c @@ -35,7 +35,7 @@ static struct usb_device_id id_table[] = { MODULE_DEVICE_TABLE(usb, id_table); -static bool gPollingfailed = false; +static bool gPollingfailed; static int ft1000_poll_thread(void *arg) { int ret; -- cgit v1.2.3 From 5fd29b013b0df6bcb411c54f21a2661c142a118e Mon Sep 17 00:00:00 2001 From: Artem Fetishev Date: Sun, 11 May 2014 21:14:26 +0300 Subject: drivers: staging: ft1000: Fix indentation Fixes indentation in header files. Signed-off-by: Artem Fetishev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h | 92 ++++++++++++------------ 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h b/drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h index 419e534874f9..ad4bf8a886b4 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h @@ -23,62 +23,62 @@ * History: * 11/5/02 Whc Created. * -*---------------------------------------------------------------------------//--------------------------------------------------------------------------- +*--------------------------------------------------------------------------- */ #ifndef _FT1000IOCTLH_ #define _FT1000IOCTLH_ typedef struct _IOCTL_GET_VER { - unsigned long drv_ver; + unsigned long drv_ver; } __packed IOCTL_GET_VER, *PIOCTL_GET_VER; /* Data structure for Dsp statistics */ typedef struct _IOCTL_GET_DSP_STAT { - unsigned char DspVer[DSPVERSZ]; /* DSP version number */ - unsigned char HwSerNum[HWSERNUMSZ]; /* Hardware Serial Number */ - unsigned char Sku[SKUSZ]; /* SKU */ - unsigned char eui64[EUISZ]; /* EUI64 */ - unsigned short ConStat; /* Connection Status */ - /* Bits 0-3 = Connection Status Field */ - /* 0000=Idle (Disconnect) */ - /* 0001=Searching */ - /* 0010=Active (Connected) */ - /* 0011=Waiting for L2 down */ - /* 0100=Sleep */ - unsigned short LedStat; /* Led Status */ - /* Bits 0-3 = Signal Strength Field */ - /* 0000 = -105dBm to -92dBm */ - /* 0001 = -92dBm to -85dBm */ - /* 0011 = -85dBm to -75dBm */ - /* 0111 = -75dBm to -50dBm */ - /* 1111 = -50dBm to 0dBm */ - /* Bits 4-7 = Reserved */ - /* Bits 8-11 = SNR Field */ - /* 0000 = <2dB */ - /* 0001 = 2dB to 8dB */ - /* 0011 = 8dB to 15dB */ - /* 0111 = 15dB to 22dB */ - /* 1111 = >22dB */ - /* Bits 12-15 = Reserved */ - unsigned long nTxPkts; /* Number of packets transmitted from host to dsp */ - unsigned long nRxPkts; /* Number of packets received from dsp to host */ - unsigned long nTxBytes; /* Number of bytes transmitted from host to dsp */ - unsigned long nRxBytes; /* Number of bytes received from dsp to host */ - unsigned long ConTm; /* Current session connection time in seconds */ - unsigned char CalVer[CALVERSZ]; /* Proprietary Calibration Version */ - unsigned char CalDate[CALDATESZ]; /* Proprietary Calibration Date */ + unsigned char DspVer[DSPVERSZ]; /* DSP version number */ + unsigned char HwSerNum[HWSERNUMSZ]; /* Hardware Serial Number */ + unsigned char Sku[SKUSZ]; /* SKU */ + unsigned char eui64[EUISZ]; /* EUI64 */ + unsigned short ConStat; /* Connection Status */ + /* Bits 0-3 = Connection Status Field */ + /* 0000=Idle (Disconnect) */ + /* 0001=Searching */ + /* 0010=Active (Connected) */ + /* 0011=Waiting for L2 down */ + /* 0100=Sleep */ + unsigned short LedStat; /* Led Status */ + /* Bits 0-3 = Signal Strength Field */ + /* 0000 = -105dBm to -92dBm */ + /* 0001 = -92dBm to -85dBm */ + /* 0011 = -85dBm to -75dBm */ + /* 0111 = -75dBm to -50dBm */ + /* 1111 = -50dBm to 0dBm */ + /* Bits 4-7 = Reserved */ + /* Bits 8-11 = SNR Field */ + /* 0000 = <2dB */ + /* 0001 = 2dB to 8dB */ + /* 0011 = 8dB to 15dB */ + /* 0111 = 15dB to 22dB */ + /* 1111 = >22dB */ + /* Bits 12-15 = Reserved */ + unsigned long nTxPkts; /* Number of packets transmitted from host to dsp */ + unsigned long nRxPkts; /* Number of packets received from dsp to host */ + unsigned long nTxBytes; /* Number of bytes transmitted from host to dsp */ + unsigned long nRxBytes; /* Number of bytes received from dsp to host */ + unsigned long ConTm; /* Current session connection time in seconds */ + unsigned char CalVer[CALVERSZ]; /* Proprietary Calibration Version */ + unsigned char CalDate[CALDATESZ]; /* Proprietary Calibration Date */ } __packed IOCTL_GET_DSP_STAT, *PIOCTL_GET_DSP_STAT; /* Data structure for Dual Ported RAM messaging between Host and Dsp */ typedef struct _IOCTL_DPRAM_BLK { - unsigned short total_len; + unsigned short total_len; struct pseudo_hdr pseudohdr; - unsigned char buffer[1780]; + unsigned char buffer[1780]; } __packed IOCTL_DPRAM_BLK, *PIOCTL_DPRAM_BLK; typedef struct _IOCTL_DPRAM_COMMAND { - unsigned short extra; - IOCTL_DPRAM_BLK dpram_blk; + unsigned short extra; + IOCTL_DPRAM_BLK dpram_blk; } __packed IOCTL_DPRAM_COMMAND, *PIOCTL_DPRAM_COMMAND; /* @@ -86,13 +86,13 @@ typedef struct _IOCTL_DPRAM_COMMAND { */ #define FT1000_MAGIC_CODE 'F' -#define IOCTL_REGISTER_CMD 0 -#define IOCTL_SET_DPRAM_CMD 3 -#define IOCTL_GET_DPRAM_CMD 4 -#define IOCTL_GET_DSP_STAT_CMD 6 -#define IOCTL_GET_VER_CMD 7 -#define IOCTL_CONNECT 10 -#define IOCTL_DISCONNECT 11 +#define IOCTL_REGISTER_CMD 0 +#define IOCTL_SET_DPRAM_CMD 3 +#define IOCTL_GET_DPRAM_CMD 4 +#define IOCTL_GET_DSP_STAT_CMD 6 +#define IOCTL_GET_VER_CMD 7 +#define IOCTL_CONNECT 10 +#define IOCTL_DISCONNECT 11 #define IOCTL_FT1000_GET_DSP_STAT _IOR(FT1000_MAGIC_CODE, IOCTL_GET_DSP_STAT_CMD, sizeof(IOCTL_GET_DSP_STAT) #define IOCTL_FT1000_GET_VER _IOR(FT1000_MAGIC_CODE, IOCTL_GET_VER_CMD, sizeof(IOCTL_GET_VER) -- cgit v1.2.3 From b4da658ea91f8813f3eee8f40c82a7937449a741 Mon Sep 17 00:00:00 2001 From: Artem Fetishev Date: Sun, 11 May 2014 21:14:27 +0300 Subject: drivers: staging: ft1000: Fix IOCTL_FT1000_* marcos Fixes include: - Add closing brackets; - Remove sizeof (_IOR and _IOW macro can accept types); - Replace _IOW which size of 0 (the last arg) with _IO. - Actually these macros are not used anywhere and might be removed. Signed-off-by: Artem Fetishev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h b/drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h index ad4bf8a886b4..5c5e79fcff82 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h @@ -94,12 +94,12 @@ typedef struct _IOCTL_DPRAM_COMMAND { #define IOCTL_CONNECT 10 #define IOCTL_DISCONNECT 11 -#define IOCTL_FT1000_GET_DSP_STAT _IOR(FT1000_MAGIC_CODE, IOCTL_GET_DSP_STAT_CMD, sizeof(IOCTL_GET_DSP_STAT) -#define IOCTL_FT1000_GET_VER _IOR(FT1000_MAGIC_CODE, IOCTL_GET_VER_CMD, sizeof(IOCTL_GET_VER) -#define IOCTL_FT1000_CONNECT _IOW(FT1000_MAGIC_CODE, IOCTL_CONNECT, 0 -#define IOCTL_FT1000_DISCONNECT _IOW(FT1000_MAGIC_CODE, IOCTL_DISCONNECT, 0 -#define IOCTL_FT1000_SET_DPRAM _IOW(FT1000_MAGIC_CODE, IOCTL_SET_DPRAM_CMD, sizeof(IOCTL_DPRAM_BLK) -#define IOCTL_FT1000_GET_DPRAM _IOR(FT1000_MAGIC_CODE, IOCTL_GET_DPRAM_CMD, sizeof(IOCTL_DPRAM_BLK) -#define IOCTL_FT1000_REGISTER _IOW(FT1000_MAGIC_CODE, IOCTL_REGISTER_CMD, sizeof(unsigned short *) -#endif /* _FT1000IOCTLH_ */ +#define IOCTL_FT1000_GET_DSP_STAT _IOR(FT1000_MAGIC_CODE, IOCTL_GET_DSP_STAT_CMD, IOCTL_GET_DSP_STAT) +#define IOCTL_FT1000_GET_VER _IOR(FT1000_MAGIC_CODE, IOCTL_GET_VER_CMD, IOCTL_GET_VER) +#define IOCTL_FT1000_CONNECT _IO(FT1000_MAGIC_CODE, IOCTL_CONNECT) +#define IOCTL_FT1000_DISCONNECT _IO(FT1000_MAGIC_CODE, IOCTL_DISCONNECT) +#define IOCTL_FT1000_SET_DPRAM _IOW(FT1000_MAGIC_CODE, IOCTL_SET_DPRAM_CMD, IOCTL_DPRAM_BLK) +#define IOCTL_FT1000_GET_DPRAM _IOR(FT1000_MAGIC_CODE, IOCTL_GET_DPRAM_CMD, IOCTL_DPRAM_BLK) +#define IOCTL_FT1000_REGISTER _IOW(FT1000_MAGIC_CODE, IOCTL_REGISTER_CMD, unsigned short *) +#endif /* _FT1000IOCTLH_ */ -- cgit v1.2.3 From 5df466cd66159826276f7b807a7e729f6a40c09d Mon Sep 17 00:00:00 2001 From: Artem Fetishev Date: Sun, 11 May 2014 21:14:28 +0300 Subject: drivers: staging: ft1000: Use pr_info instead of printk Improve coding style by fixing this checkstyle warning: WARNING: Prefer [subsystem eg: netdev]_info([subsystem]dev, ... then dev_info(dev, ... then pr_info(... to printk(KERN_INFO ... Signed-off-by: Artem Fetishev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_usb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h index a6fdd524ee6f..fd3e1a97d6b9 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h @@ -24,7 +24,7 @@ struct app_info_block { struct list_head app_sqlist; /* link list of msgs for applicaton on slow queue */ } __packed; -#define DEBUG(args...) printk(KERN_INFO args) +#define DEBUG(args...) pr_info(args) #define FALSE 0 #define TRUE 1 -- cgit v1.2.3 From 48d1e475363638b58f76ee0bd3887082990ea0f9 Mon Sep 17 00:00:00 2001 From: Artem Fetishev Date: Sun, 11 May 2014 21:14:29 +0300 Subject: drivers: staging: ft1000: Remove typedefs Remove typedefs according to the "Chapter 5: Typedefs" from Documentation/CodingStyle. Signed-off-by: Artem Fetishev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_debug.c | 10 ++++----- drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h | 26 ++++++++++++------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c index dc7647f222f0..a8945b785967 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c @@ -417,8 +417,8 @@ static long ft1000_ioctl(struct file *file, unsigned int command, u16 tempword; unsigned long flags; struct timeval tv; - IOCTL_GET_VER get_ver_data; - IOCTL_GET_DSP_STAT get_stat_data; + struct IOCTL_GET_VER get_ver_data; + struct IOCTL_GET_DSP_STAT get_stat_data; u8 ConnectionMsg[] = {0x00,0x44,0x10,0x20,0x80,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x93,0x64, 0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x0a, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, @@ -527,8 +527,8 @@ static long ft1000_ioctl(struct file *file, unsigned int command, break; case IOCTL_SET_DPRAM_CMD: { - IOCTL_DPRAM_BLK *dpram_data = NULL; - /* IOCTL_DPRAM_COMMAND dpram_command; */ + struct IOCTL_DPRAM_BLK *dpram_data = NULL; + /* struct IOCTL_DPRAM_COMMAND dpram_command; */ u16 qtype; u16 msgsz; struct pseudo_hdr *ppseudo_hdr; @@ -672,7 +672,7 @@ static long ft1000_ioctl(struct file *file, unsigned int command, case IOCTL_GET_DPRAM_CMD: { struct dpram_blk *pdpram_blk; - IOCTL_DPRAM_BLK __user *pioctl_dpram; + struct IOCTL_DPRAM_BLK __user *pioctl_dpram; int msglen; /* DEBUG("FT1000:ft1000_ioctl: IOCTL_FT1000_GET_DPRAM called\n"); */ diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h b/drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h index 5c5e79fcff82..c10d5189d532 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h @@ -28,12 +28,12 @@ #ifndef _FT1000IOCTLH_ #define _FT1000IOCTLH_ -typedef struct _IOCTL_GET_VER { +struct IOCTL_GET_VER { unsigned long drv_ver; -} __packed IOCTL_GET_VER, *PIOCTL_GET_VER; +} __packed; /* Data structure for Dsp statistics */ -typedef struct _IOCTL_GET_DSP_STAT { +struct IOCTL_GET_DSP_STAT { unsigned char DspVer[DSPVERSZ]; /* DSP version number */ unsigned char HwSerNum[HWSERNUMSZ]; /* Hardware Serial Number */ unsigned char Sku[SKUSZ]; /* SKU */ @@ -67,19 +67,19 @@ typedef struct _IOCTL_GET_DSP_STAT { unsigned long ConTm; /* Current session connection time in seconds */ unsigned char CalVer[CALVERSZ]; /* Proprietary Calibration Version */ unsigned char CalDate[CALDATESZ]; /* Proprietary Calibration Date */ -} __packed IOCTL_GET_DSP_STAT, *PIOCTL_GET_DSP_STAT; +} __packed; /* Data structure for Dual Ported RAM messaging between Host and Dsp */ -typedef struct _IOCTL_DPRAM_BLK { +struct IOCTL_DPRAM_BLK { unsigned short total_len; struct pseudo_hdr pseudohdr; unsigned char buffer[1780]; -} __packed IOCTL_DPRAM_BLK, *PIOCTL_DPRAM_BLK; +} __packed; -typedef struct _IOCTL_DPRAM_COMMAND { +struct IOCTL_DPRAM_COMMAND { unsigned short extra; - IOCTL_DPRAM_BLK dpram_blk; -} __packed IOCTL_DPRAM_COMMAND, *PIOCTL_DPRAM_COMMAND; + struct IOCTL_DPRAM_BLK dpram_blk; +} __packed; /* * Custom IOCTL command codes @@ -94,12 +94,12 @@ typedef struct _IOCTL_DPRAM_COMMAND { #define IOCTL_CONNECT 10 #define IOCTL_DISCONNECT 11 -#define IOCTL_FT1000_GET_DSP_STAT _IOR(FT1000_MAGIC_CODE, IOCTL_GET_DSP_STAT_CMD, IOCTL_GET_DSP_STAT) -#define IOCTL_FT1000_GET_VER _IOR(FT1000_MAGIC_CODE, IOCTL_GET_VER_CMD, IOCTL_GET_VER) +#define IOCTL_FT1000_GET_DSP_STAT _IOR(FT1000_MAGIC_CODE, IOCTL_GET_DSP_STAT_CMD, struct IOCTL_GET_DSP_STAT) +#define IOCTL_FT1000_GET_VER _IOR(FT1000_MAGIC_CODE, IOCTL_GET_VER_CMD, struct IOCTL_GET_VER) #define IOCTL_FT1000_CONNECT _IO(FT1000_MAGIC_CODE, IOCTL_CONNECT) #define IOCTL_FT1000_DISCONNECT _IO(FT1000_MAGIC_CODE, IOCTL_DISCONNECT) -#define IOCTL_FT1000_SET_DPRAM _IOW(FT1000_MAGIC_CODE, IOCTL_SET_DPRAM_CMD, IOCTL_DPRAM_BLK) -#define IOCTL_FT1000_GET_DPRAM _IOR(FT1000_MAGIC_CODE, IOCTL_GET_DPRAM_CMD, IOCTL_DPRAM_BLK) +#define IOCTL_FT1000_SET_DPRAM _IOW(FT1000_MAGIC_CODE, IOCTL_SET_DPRAM_CMD, struct IOCTL_DPRAM_BLK) +#define IOCTL_FT1000_GET_DPRAM _IOR(FT1000_MAGIC_CODE, IOCTL_GET_DPRAM_CMD, struct IOCTL_DPRAM_BLK) #define IOCTL_FT1000_REGISTER _IOW(FT1000_MAGIC_CODE, IOCTL_REGISTER_CMD, unsigned short *) #endif /* _FT1000IOCTLH_ */ -- cgit v1.2.3 From 62ca89a1d014623b1a59aa60b6055d022f1f8836 Mon Sep 17 00:00:00 2001 From: Artem Fetishev Date: Sun, 11 May 2014 21:14:30 +0300 Subject: drivers: staging: ft1000: Fix lines over 80 characters ..plus some function arg indentation which I haven't noticed at first. Signed-off-by: Artem Fetishev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-pcmcia/ft1000.h | 15 ++++++--- drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h | 40 +++++++++++++++++------- drivers/staging/ft1000/ft1000-usb/ft1000_usb.h | 35 ++++++++++++--------- drivers/staging/ft1000/ft1000.h | 7 +++-- 4 files changed, 64 insertions(+), 33 deletions(-) diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000.h b/drivers/staging/ft1000/ft1000-pcmcia/ft1000.h index 65f7ab6cb467..0c21ac680038 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000.h +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000.h @@ -25,7 +25,10 @@ #define FT1000_DPRAM_BASE 0x0000 /* Dual Port RAM starting offset */ -/* Maximum number of occurrence of pseudo header errors before resetting PC Card. */ +/* + * Maximum number of occurrence of pseudo header errors before resetting PC + * Card. + */ #define MAX_PH_ERR 300 #define SUCCESS 0x00 @@ -40,16 +43,17 @@ struct ft1000_pcmcia { struct pcmcia_device; struct net_device; extern struct net_device *init_ft1000_card(struct pcmcia_device *link, - void *ft1000_reset); + void *ft1000_reset); extern void stop_ft1000_card(struct net_device *dev); extern int card_download(struct net_device *dev, const u8 *pFileStart, - size_t FileLength); + size_t FileLength); extern void ft1000InitProc(struct net_device *dev); extern void ft1000CleanupProc(struct net_device *dev); extern u16 ft1000_read_dpram(struct net_device *dev, int offset); extern void card_bootload(struct net_device *dev); -extern u16 ft1000_read_dpram_mag_16(struct net_device *dev, int offset, int Index); +extern u16 ft1000_read_dpram_mag_16(struct net_device *dev, int offset, + int Index); extern u32 ft1000_read_dpram_mag_32(struct net_device *dev, int offset); void ft1000_write_dpram_mag_32(struct net_device *dev, int offset, u32 value); @@ -60,7 +64,8 @@ static inline u16 ft1000_read_reg(struct net_device *dev, u16 offset) } /* Set the value of a given ASIC register. */ -static inline void ft1000_write_reg(struct net_device *dev, u16 offset, u16 value) +static inline void ft1000_write_reg(struct net_device *dev, u16 offset, + u16 value) { outw(value, dev->base_addr + offset); } diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h b/drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h index c10d5189d532..cb644a58d9f3 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_ioctl.h @@ -60,12 +60,24 @@ struct IOCTL_GET_DSP_STAT { /* 0111 = 15dB to 22dB */ /* 1111 = >22dB */ /* Bits 12-15 = Reserved */ - unsigned long nTxPkts; /* Number of packets transmitted from host to dsp */ - unsigned long nRxPkts; /* Number of packets received from dsp to host */ - unsigned long nTxBytes; /* Number of bytes transmitted from host to dsp */ - unsigned long nRxBytes; /* Number of bytes received from dsp to host */ - unsigned long ConTm; /* Current session connection time in seconds */ - unsigned char CalVer[CALVERSZ]; /* Proprietary Calibration Version */ + unsigned long nTxPkts; /* Number of packets transmitted + * from host to dsp + */ + unsigned long nRxPkts; /* Number of packets received from + * dsp to host + */ + unsigned long nTxBytes; /* Number of bytes transmitted + * from host to dsp + */ + unsigned long nRxBytes; /* Number of bytes received from + * dsp to host + */ + unsigned long ConTm; /* Current session connection time + * in seconds + */ + unsigned char CalVer[CALVERSZ]; /* Proprietary Calibration + * Version + */ unsigned char CalDate[CALDATESZ]; /* Proprietary Calibration Date */ } __packed; @@ -94,12 +106,18 @@ struct IOCTL_DPRAM_COMMAND { #define IOCTL_CONNECT 10 #define IOCTL_DISCONNECT 11 -#define IOCTL_FT1000_GET_DSP_STAT _IOR(FT1000_MAGIC_CODE, IOCTL_GET_DSP_STAT_CMD, struct IOCTL_GET_DSP_STAT) -#define IOCTL_FT1000_GET_VER _IOR(FT1000_MAGIC_CODE, IOCTL_GET_VER_CMD, struct IOCTL_GET_VER) +#define IOCTL_FT1000_GET_DSP_STAT _IOR(FT1000_MAGIC_CODE, \ + IOCTL_GET_DSP_STAT_CMD, \ + struct IOCTL_GET_DSP_STAT) +#define IOCTL_FT1000_GET_VER _IOR(FT1000_MAGIC_CODE, IOCTL_GET_VER_CMD, \ + struct IOCTL_GET_VER) #define IOCTL_FT1000_CONNECT _IO(FT1000_MAGIC_CODE, IOCTL_CONNECT) #define IOCTL_FT1000_DISCONNECT _IO(FT1000_MAGIC_CODE, IOCTL_DISCONNECT) -#define IOCTL_FT1000_SET_DPRAM _IOW(FT1000_MAGIC_CODE, IOCTL_SET_DPRAM_CMD, struct IOCTL_DPRAM_BLK) -#define IOCTL_FT1000_GET_DPRAM _IOR(FT1000_MAGIC_CODE, IOCTL_GET_DPRAM_CMD, struct IOCTL_DPRAM_BLK) -#define IOCTL_FT1000_REGISTER _IOW(FT1000_MAGIC_CODE, IOCTL_REGISTER_CMD, unsigned short *) +#define IOCTL_FT1000_SET_DPRAM _IOW(FT1000_MAGIC_CODE, IOCTL_SET_DPRAM_CMD, \ + struct IOCTL_DPRAM_BLK) +#define IOCTL_FT1000_GET_DPRAM _IOR(FT1000_MAGIC_CODE, IOCTL_GET_DPRAM_CMD, \ + struct IOCTL_DPRAM_BLK) +#define IOCTL_FT1000_REGISTER _IOW(FT1000_MAGIC_CODE, IOCTL_REGISTER_CMD, \ + unsigned short *) #endif /* _FT1000IOCTLH_ */ diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h index fd3e1a97d6b9..2d4b02e2382d 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h @@ -14,14 +14,18 @@ struct app_info_block { u32 nTxMsg; /* DPRAM msg sent to DSP with app_id */ u32 nRxMsg; /* DPRAM msg rcv from dsp with app_id */ - u32 nTxMsgReject; /* DPRAM msg rejected due to DSP doorbell set */ + u32 nTxMsgReject; /* DPRAM msg rejected due to DSP doorbell + * set + */ u32 nRxMsgMiss; /* DPRAM msg dropped due to overflow */ struct fown_struct *fileobject;/* Application's file object */ u16 app_id; /* Application id */ int DspBCMsgFlag; int NumOfMsg; /* number of messages queued up */ wait_queue_head_t wait_dpram_msg; - struct list_head app_sqlist; /* link list of msgs for applicaton on slow queue */ + struct list_head app_sqlist; /* link list of msgs for applicaton on + * slow queue + */ } __packed; #define DEBUG(args...) pr_info(args) @@ -41,7 +45,9 @@ struct app_info_block { /* MEMORY MAP FOR MAGNEMITE */ /* the indexes are swapped comparing to PCMCIA - is it OK or a bug? */ #undef FT1000_MAG_DSP_LED_INDX -#define FT1000_MAG_DSP_LED_INDX 0x1 /* dsp led status for PAD device */ +#define FT1000_MAG_DSP_LED_INDX 0x1 /* dsp led status for PAD + * device + */ #undef FT1000_MAG_DSP_CON_STATE_INDX #define FT1000_MAG_DSP_CON_STATE_INDX 0x0 /* DSP Connection Status Info */ @@ -99,21 +105,21 @@ struct dpram_blk { } __packed; int ft1000_read_register(struct ft1000_usb *ft1000dev, - u16 *Data, u16 nRegIndx); + u16 *Data, u16 nRegIndx); int ft1000_write_register(struct ft1000_usb *ft1000dev, - u16 value, u16 nRegIndx); + u16 value, u16 nRegIndx); int ft1000_read_dpram32(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer, u16 cnt); int ft1000_write_dpram32(struct ft1000_usb *ft1000dev, - u16 indx, u8 *buffer, u16 cnt); + u16 indx, u8 *buffer, u16 cnt); int ft1000_read_dpram16(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer, u8 highlow); int ft1000_write_dpram16(struct ft1000_usb *ft1000dev, - u16 indx, u16 value, u8 highlow); + u16 indx, u16 value, u8 highlow); int fix_ft1000_read_dpram32(struct ft1000_usb *ft1000dev, - u16 indx, u8 *buffer); + u16 indx, u8 *buffer); int fix_ft1000_write_dpram32(struct ft1000_usb *ft1000dev, - u16 indx, u8 *buffer); + u16 indx, u8 *buffer); extern void *pFileStart; extern size_t FileLength; @@ -125,12 +131,13 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, extern struct list_head freercvpool; -extern spinlock_t free_buff_lock; /* lock to arbitrate free buffer list for receive command data */ +/* lock to arbitrate free buffer list for receive command data */ +extern spinlock_t free_buff_lock; int ft1000_create_dev(struct ft1000_usb *dev); void ft1000_destroy_dev(struct net_device *dev); extern void card_send_command(struct ft1000_usb *ft1000dev, - void *ptempbuffer, int size); + void *ptempbuffer, int size); struct dpram_blk *ft1000_get_buffer(struct list_head *bufflist); void ft1000_free_buffer(struct dpram_blk *pdpram_blk, struct list_head *plist); @@ -139,12 +146,10 @@ int dsp_reload(struct ft1000_usb *ft1000dev); int init_ft1000_netdev(struct ft1000_usb *ft1000dev); struct usb_interface; int reg_ft1000_netdev(struct ft1000_usb *ft1000dev, - struct usb_interface *intf); + struct usb_interface *intf); int ft1000_poll(void *dev_id); int ft1000_init_proc(struct net_device *dev); void ft1000_cleanup_proc(struct ft1000_info *info); - - -#endif +#endif /* _FT1000_USB_H_ */ diff --git a/drivers/staging/ft1000/ft1000.h b/drivers/staging/ft1000/ft1000.h index ccb821a1f370..db57430f3b94 100644 --- a/drivers/staging/ft1000/ft1000.h +++ b/drivers/staging/ft1000/ft1000.h @@ -1,5 +1,6 @@ /* - * Common structures and definitions for FT1000 Flarion Flash OFDM PCMCIA and USB devices + * Common structures and definitions for FT1000 Flarion Flash OFDM PCMCIA and + * USB devices. * * Originally copyright (c) 2002 Flarion Technologies * @@ -17,7 +18,9 @@ #define MAGNEMITE_ID 0x1a01 /* ASIC ID for Magnemite */ /* MEMORY MAP common to both ELECTRABUZZ and MAGNEMITE */ -#define FT1000_REG_DPRAM_ADDR 0x000E /* DPADR - Dual Port Ram Indirect Address Register */ +#define FT1000_REG_DPRAM_ADDR 0x000E /* DPADR - Dual Port Ram Indirect + * Address Register + */ #define FT1000_REG_SUP_CTRL 0x0020 /* HCTR - Host Control Register */ #define FT1000_REG_SUP_STAT 0x0022 /* HSTAT - Host Status Register */ #define FT1000_REG_RESET 0x0024 /* HCTR - Host Control Register */ -- cgit v1.2.3 From f3c5261e04b9ace521e9392f7b6a28f62b28b9fc Mon Sep 17 00:00:00 2001 From: Jerry Snitselaar Date: Thu, 24 Apr 2014 00:31:48 -0700 Subject: staging/line6: blank line after declaration cleanup Fix coding style warnings reported by checkpath. Signed-off-by: Jerry Snitselaar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/line6/capture.c | 3 +++ drivers/staging/line6/midi.c | 2 ++ drivers/staging/line6/playback.c | 6 +++++- drivers/staging/line6/pod.c | 5 +++++ drivers/staging/line6/toneport.c | 2 ++ drivers/staging/line6/variax.c | 2 ++ 6 files changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/staging/line6/capture.c b/drivers/staging/line6/capture.c index 0eda51d2e9a2..e6ca631e3f79 100644 --- a/drivers/staging/line6/capture.c +++ b/drivers/staging/line6/capture.c @@ -97,6 +97,7 @@ void line6_unlink_audio_in_urbs(struct snd_line6_pcm *line6pcm) if (test_bit(i, &line6pcm->active_urb_in)) { if (!test_and_set_bit(i, &line6pcm->unlink_urb_in)) { struct urb *u = line6pcm->urb_audio_in[i]; + usb_unlink_urb(u); } } @@ -334,6 +335,7 @@ static int snd_line6_capture_hw_params(struct snd_pcm_substream *substream, static int snd_line6_capture_hw_free(struct snd_pcm_substream *substream) { struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); + line6_pcm_release(line6pcm, LINE6_BIT_PCM_ALSA_CAPTURE_BUFFER); return snd_pcm_lib_free_pages(substream); } @@ -380,6 +382,7 @@ static snd_pcm_uframes_t snd_line6_capture_pointer(struct snd_pcm_substream *substream) { struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); + return line6pcm->pos_in_done; } diff --git a/drivers/staging/line6/midi.c b/drivers/staging/line6/midi.c index 02345fb06e3d..1ac343b649c1 100644 --- a/drivers/staging/line6/midi.c +++ b/drivers/staging/line6/midi.c @@ -183,6 +183,7 @@ static void line6_midi_output_drain(struct snd_rawmidi_substream *substream) struct usb_line6 *line6 = line6_rawmidi_substream_midi(substream)->line6; struct snd_line6_midi *midi = line6->line6midi; + wait_event_interruptible(midi->send_wait, midi->num_active_send_urbs == 0); } @@ -260,6 +261,7 @@ static int snd_line6_new_midi(struct snd_line6_midi *line6midi) static int snd_line6_midi_free(struct snd_device *device) { struct snd_line6_midi *line6midi = device->device_data; + line6_midibuf_destroy(&line6midi->midibuf_in); line6_midibuf_destroy(&line6midi->midibuf_out); return 0; diff --git a/drivers/staging/line6/playback.c b/drivers/staging/line6/playback.c index 0f72db5665fe..2ca8900e68c3 100644 --- a/drivers/staging/line6/playback.c +++ b/drivers/staging/line6/playback.c @@ -44,6 +44,7 @@ static void change_volume(struct urb *urb_out, int volume[], } } else if (bytes_per_frame == 6) { unsigned char *p, *buf_end; + p = (unsigned char *)urb_out->transfer_buffer; buf_end = p + urb_out->transfer_buffer_length; @@ -310,6 +311,7 @@ void line6_unlink_audio_out_urbs(struct snd_line6_pcm *line6pcm) if (test_bit(i, &line6pcm->active_urb_out)) { if (!test_and_set_bit(i, &line6pcm->unlink_urb_out)) { struct urb *u = line6pcm->urb_audio_out[i]; + usb_unlink_urb(u); } } @@ -363,7 +365,6 @@ static void audio_out_callback(struct urb *urb) { int i, index, length = 0, shutdown = 0; unsigned long flags; - struct snd_line6_pcm *line6pcm = (struct snd_line6_pcm *)urb->context; struct snd_pcm_substream *substream = get_substream(line6pcm, SNDRV_PCM_STREAM_PLAYBACK); @@ -389,6 +390,7 @@ static void audio_out_callback(struct urb *urb) if (test_bit(LINE6_INDEX_PCM_ALSA_PLAYBACK_STREAM, &line6pcm->flags)) { struct snd_pcm_runtime *runtime = substream->runtime; + line6pcm->pos_out_done += length / line6pcm->properties->bytes_per_frame; @@ -485,6 +487,7 @@ static int snd_line6_playback_hw_params(struct snd_pcm_substream *substream, static int snd_line6_playback_hw_free(struct snd_pcm_substream *substream) { struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); + line6_pcm_release(line6pcm, LINE6_BIT_PCM_ALSA_PLAYBACK_BUFFER); return snd_pcm_lib_free_pages(substream); } @@ -539,6 +542,7 @@ static snd_pcm_uframes_t snd_line6_playback_pointer(struct snd_pcm_substream *substream) { struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream); + return line6pcm->pos_out_done; } diff --git a/drivers/staging/line6/pod.c b/drivers/staging/line6/pod.c index f4e95a614e3f..44f4b2f98570 100644 --- a/drivers/staging/line6/pod.c +++ b/drivers/staging/line6/pod.c @@ -197,6 +197,7 @@ static ssize_t serial_number_show(struct device *dev, { struct usb_interface *interface = to_usb_interface(dev); struct usb_line6_pod *pod = usb_get_intfdata(interface); + return sprintf(buf, "%d\n", pod->serial_number); } @@ -208,6 +209,7 @@ static ssize_t firmware_version_show(struct device *dev, { struct usb_interface *interface = to_usb_interface(dev); struct usb_line6_pod *pod = usb_get_intfdata(interface); + return sprintf(buf, "%d.%02d\n", pod->firmware_version / 100, pod->firmware_version % 100); } @@ -220,6 +222,7 @@ static ssize_t device_id_show(struct device *dev, { struct usb_interface *interface = to_usb_interface(dev); struct usb_line6_pod *pod = usb_get_intfdata(interface); + return sprintf(buf, "%d\n", pod->device_id); } @@ -243,6 +246,7 @@ static void pod_startup2(unsigned long data) { struct usb_line6_pod *pod = (struct usb_line6_pod *)data; struct usb_line6 *line6 = &pod->line6; + CHECK_STARTUP_PROGRESS(pod->startup_progress, POD_STARTUP_VERSIONREQ); /* request firmware version: */ @@ -294,6 +298,7 @@ static int snd_pod_control_monitor_get(struct snd_kcontrol *kcontrol, { struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); struct usb_line6_pod *pod = (struct usb_line6_pod *)line6pcm->line6; + ucontrol->value.integer.value[0] = pod->monitor_level; return 0; } diff --git a/drivers/staging/line6/toneport.c b/drivers/staging/line6/toneport.c index dcab6478a3b3..69437158d383 100644 --- a/drivers/staging/line6/toneport.c +++ b/drivers/staging/line6/toneport.c @@ -185,6 +185,7 @@ static int snd_toneport_monitor_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol); + ucontrol->value.integer.value[0] = line6pcm->volume_monitor; return 0; } @@ -263,6 +264,7 @@ static void toneport_start_pcm(unsigned long arg) { struct usb_line6_toneport *toneport = (struct usb_line6_toneport *)arg; struct usb_line6 *line6 = &toneport->line6; + line6_pcm_acquire(line6->line6pcm, LINE6_BITS_PCM_MONITOR); } diff --git a/drivers/staging/line6/variax.c b/drivers/staging/line6/variax.c index bd0f694fa8d8..ae2be99f9a92 100644 --- a/drivers/staging/line6/variax.c +++ b/drivers/staging/line6/variax.c @@ -95,6 +95,7 @@ static void variax_startup3(struct usb_line6_variax *variax) static void variax_startup4(unsigned long data) { struct usb_line6_variax *variax = (struct usb_line6_variax *)data; + CHECK_STARTUP_PROGRESS(variax->startup_progress, VARIAX_STARTUP_ACTIVATE); @@ -107,6 +108,7 @@ static void variax_startup4(unsigned long data) static void variax_startup5(unsigned long data) { struct usb_line6_variax *variax = (struct usb_line6_variax *)data; + CHECK_STARTUP_PROGRESS(variax->startup_progress, VARIAX_STARTUP_WORKQUEUE); -- cgit v1.2.3 From 5535c4dd475ff936d36ad4d3f85d8be74f30245f Mon Sep 17 00:00:00 2001 From: Rocco Folino Date: Thu, 3 Apr 2014 00:47:46 +0200 Subject: staging: gs_fpgaboot: Fixed code style issues Fixed missing a blank line after declarations warning Signed-off-by: Rocco Folino Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gs_fpgaboot/gs_fpgaboot.c | 2 +- drivers/staging/gs_fpgaboot/io.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c index 7506900c9b8d..6aa9d7c30139 100644 --- a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c +++ b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c @@ -214,8 +214,8 @@ static int gs_download_image(struct fpgaimage *fimage, enum wbus bus_bytes) { char *bitdata; int size, i, cnt; - cnt = 0; + cnt = 0; bitdata = (char *)fimage->fpgadata; size = fimage->lendata; diff --git a/drivers/staging/gs_fpgaboot/io.c b/drivers/staging/gs_fpgaboot/io.c index b7be8e37b8d1..23c12f47c8f1 100644 --- a/drivers/staging/gs_fpgaboot/io.c +++ b/drivers/staging/gs_fpgaboot/io.c @@ -44,6 +44,7 @@ static inline void xl_cclk_b(int32_t i); void xl_shift_cclk(int count) { int i; + for (i = 0; i < count; i++) { xl_cclk_b(1); xl_cclk_b(0); @@ -85,6 +86,7 @@ void xl_shift_bytes_out(enum wbus bus_byte, unsigned char *pdata) static inline unsigned char bitswap(unsigned char s) { unsigned char d; + d = (((s&0x80)>>7) | ((s&0x40)>>5) | ((s&0x20)>>3) | ((s&0x10)>>1) | ((s&0x08)<<1) | ((s&0x04)<<3) | ((s&0x02)<<5) | ((s&0x01)<<7)); return d; @@ -135,6 +137,7 @@ static inline void mpc85xx_gpio_set_high(int32_t port, uint32_t gpios) static inline void gpio_set_value(int32_t port, uint32_t gpio, uint32_t value) { int32_t g; + g = 31 - gpio; if (value) mpc85xx_gpio_set_high(port, 1U << g); @@ -145,6 +148,7 @@ static inline void gpio_set_value(int32_t port, uint32_t gpio, uint32_t value) static inline int gpio_get_value(int32_t port, uint32_t gpio) { int32_t g; + g = 31 - gpio; return !!mpc85xx_gpio_get(port, 1U << g); } @@ -184,6 +188,7 @@ int xl_get_done_b(void) static inline uint32_t bit_remap_byte0(uint32_t s) { uint32_t d; + d = (((s&0x80)>>7) | ((s&0x40)>>5) | ((s&0x20)>>3) | ((s&0x10)>>1) | ((s&0x08)<<1) | ((s&0x04)<<3) | ((s&0x02)<<6) | ((s&0x01)<<9)); return d; @@ -195,6 +200,7 @@ static inline uint32_t bit_remap_byte0(uint32_t s) static inline void byte0_out(unsigned char data) { uint32_t swap32; + swap32 = bit_remap_byte0((uint32_t) data) << 8; mpc85xx_gpio_set(0, 0x0002BF00, (uint32_t) swap32); -- cgit v1.2.3 From bf2ec0f9ada1db6778851fcc9f736b5ca00c97ec Mon Sep 17 00:00:00 2001 From: Micky Ching Date: Wed, 2 Apr 2014 17:58:52 +0800 Subject: staging: rts5208: fix static checker warnings The patch fa590c222fba: "staging: rts5208: add support for rts5208 and rts5288" from Nov 12, 2013, leads to the following static checker warning: drivers/staging/rts5208/rtsx_chip.c:107 rtsx_enable_bus_int() warn: add curly braces? This warning is produced because incorrect code indent. Signed-off-by: Micky Ching Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx_chip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rts5208/rtsx_chip.c b/drivers/staging/rts5208/rtsx_chip.c index 6426807a906f..7907e931a355 100644 --- a/drivers/staging/rts5208/rtsx_chip.c +++ b/drivers/staging/rts5208/rtsx_chip.c @@ -104,7 +104,7 @@ void rtsx_enable_bus_int(struct rtsx_chip *chip) if (chip->ic_version >= IC_VER_C) reg |= DELINK_INT_EN; #ifdef SUPPORT_OCP - reg |= OC_INT_EN; + reg |= OC_INT_EN; #endif if (!chip->adma_mode) reg |= DATA_DONE_INT_EN; -- cgit v1.2.3 From a21201369568a4e5bd23fb5cb9a966a1008637a6 Mon Sep 17 00:00:00 2001 From: Sherif Shehab Aldin Date: Sat, 5 Apr 2014 23:33:16 +0200 Subject: driver: staging: wlan-ng: Fixed Breaking long lines and strings style rule Fixed coding style rule "Breaking long lines and strings" for hfa384x_usb.c Signed-off-by: Sherif Shehab Aldin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/hfa384x_usb.c | 47 +++++++++++++++++------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c index 5b8b094c8726..646c29e7f4fd 100644 --- a/drivers/staging/wlan-ng/hfa384x_usb.c +++ b/drivers/staging/wlan-ng/hfa384x_usb.c @@ -642,8 +642,7 @@ usbctlx_get_status(const hfa384x_usb_cmdresp_t *cmdresp, result->resp1 = le16_to_cpu(cmdresp->resp1); result->resp2 = le16_to_cpu(cmdresp->resp2); - pr_debug("cmdresult:status=0x%04x " - "resp0=0x%04x resp1=0x%04x resp2=0x%04x\n", + pr_debug("cmdresult:status=0x%04x resp0=0x%04x resp1=0x%04x resp2=0x%04x\n", result->status, result->resp0, result->resp1, result->resp2); return result->status & HFA384x_STATUS_RESULT; @@ -991,9 +990,7 @@ int hfa384x_cmd_initialize(hfa384x_t *hw) result = hfa384x_docmd_wait(hw, &cmd); - pr_debug("cmdresp.init: " - "status=0x%04x, resp0=0x%04x, " - "resp1=0x%04x, resp2=0x%04x\n", + pr_debug("cmdresp.init: status=0x%04x, resp0=0x%04x, resp1=0x%04x, resp2=0x%04x\n", cmd.result.status, cmd.result.resp0, cmd.result.resp1, cmd.result.resp2); if (result == 0) { @@ -1381,8 +1378,7 @@ hfa384x_docmd(hfa384x_t *hw, ctlx->outbufsize = sizeof(ctlx->outbuf.cmdreq); - pr_debug("cmdreq: cmd=0x%04x " - "parm0=0x%04x parm1=0x%04x parm2=0x%04x\n", + pr_debug("cmdreq: cmd=0x%04x parm0=0x%04x parm1=0x%04x parm2=0x%04x\n", cmd->cmd, cmd->parm0, cmd->parm1, cmd->parm2); ctlx->reapable = mode; @@ -2018,7 +2014,8 @@ int hfa384x_drvr_flashdl_write(hfa384x_t *hw, u32 daddr, void *buf, u32 len) if (hw->dlstate != HFA384x_DLSTATE_FLASHENABLED) return -EINVAL; - netdev_info(hw->wlandev->netdev, "Download %d bytes to flash @0x%06x\n", len, daddr); + netdev_info(hw->wlandev->netdev, + "Download %d bytes to flash @0x%06x\n", len, daddr); /* Convert to flat address for arithmetic */ /* NOTE: dlbuffer RID stores the address in AUX format */ @@ -2028,8 +2025,9 @@ int hfa384x_drvr_flashdl_write(hfa384x_t *hw, u32 daddr, void *buf, u32 len) hw->bufinfo.page, hw->bufinfo.offset, dlbufaddr); #if 0 - netdev_warn(hw->wlandev->netdev, "dlbuf@0x%06lx len=%d to=%d\n", dlbufaddr, - hw->bufinfo.len, hw->dltimeout); + netdev_warn(hw->wlandev->netdev, + "dlbuf@0x%06lx len=%d to=%d\n", dlbufaddr, + hw->bufinfo.len, hw->dltimeout); #endif /* Calculations to determine how many fills of the dlbuffer to do * and how many USB wmemreq's to do for each fill. At this point @@ -2062,9 +2060,9 @@ int hfa384x_drvr_flashdl_write(hfa384x_t *hw, u32 daddr, void *buf, u32 len) result = hfa384x_cmd_download(hw, HFA384x_PROGMODE_NV, burnlo, burnhi, burnlen); if (result) { - netdev_err(hw->wlandev->netdev, "download(NV,lo=%x,hi=%x,len=%x) " - "cmd failed, result=%d. Aborting d/l\n", - burnlo, burnhi, burnlen, result); + netdev_err(hw->wlandev->netdev, + "download(NV,lo=%x,hi=%x,len=%x) cmd failed, result=%d. Aborting d/l\n", + burnlo, burnhi, burnlen, result); goto exit_proc; } @@ -2095,8 +2093,7 @@ int hfa384x_drvr_flashdl_write(hfa384x_t *hw, u32 daddr, void *buf, u32 len) 0, 0, 0); if (result) { netdev_err(hw->wlandev->netdev, - "download(NVWRITE,lo=%x,hi=%x,len=%x) " - "cmd failed, result=%d. Aborting d/l\n", + "download(NVWRITE,lo=%x,hi=%x,len=%x) cmd failed, result=%d. Aborting d/l\n", burnlo, burnhi, burnlen, result); goto exit_proc; } @@ -2352,7 +2349,8 @@ int hfa384x_drvr_ramdl_write(hfa384x_t *hw, u32 daddr, void *buf, u32 len) if (hw->dlstate != HFA384x_DLSTATE_RAMENABLED) return -EINVAL; - netdev_info(hw->wlandev->netdev, "Writing %d bytes to ram @0x%06x\n", len, daddr); + netdev_info(hw->wlandev->netdev, "Writing %d bytes to ram @0x%06x\n", + len, daddr); /* How many dowmem calls? */ nwrites = len / HFA384x_USB_RWMEM_MAXLEN; @@ -2462,7 +2460,8 @@ int hfa384x_drvr_readpda(hfa384x_t *hw, void *buf, unsigned int len) pdrcode = le16_to_cpu(pda[currpdr + 1]); /* Test the record length */ if (pdrlen > HFA384x_PDR_LEN_MAX || pdrlen == 0) { - netdev_err(hw->wlandev->netdev, "pdrlen invalid=%d\n", pdrlen); + netdev_err(hw->wlandev->netdev, + "pdrlen invalid=%d\n", pdrlen); pdaok = 0; break; } @@ -2784,7 +2783,8 @@ int hfa384x_drvr_txframe(hfa384x_t *hw, struct sk_buff *skb, result = 1; ret = submit_tx_urb(hw, &hw->tx_urb, GFP_ATOMIC); if (ret != 0) { - netdev_err(hw->wlandev->netdev, "submit_tx_urb() failed, error=%d\n", ret); + netdev_err(hw->wlandev->netdev, + "submit_tx_urb() failed, error=%d\n", ret); result = 3; } @@ -3397,8 +3397,7 @@ retry: * Throw this CTLX away ... */ netdev_err(hw->wlandev->netdev, - "Matched IN URB, CTLX[%d] in invalid state(%s)." - " Discarded.\n", + "Matched IN URB, CTLX[%d] in invalid state(%s). Discarded.\n", le16_to_cpu(ctlx->outbuf.type), ctlxstr(ctlx->state)); if (unlocked_usbctlx_cancel_async(hw, ctlx) == 0) @@ -4139,13 +4138,13 @@ static int hfa384x_isgood_pdrcode(u16 pdrcode) default: if (pdrcode < 0x1000) { /* code is OK, but we don't know exactly what it is */ - pr_debug("Encountered unknown PDR#=0x%04x, " - "assuming it's ok.\n", pdrcode); + pr_debug("Encountered unknown PDR#=0x%04x, assuming it's ok.\n", + pdrcode); return 1; } else { /* bad code */ - pr_debug("Encountered unknown PDR#=0x%04x, " - "(>=0x1000), assuming it's bad.\n", pdrcode); + pr_debug("Encountered unknown PDR#=0x%04x, (>=0x1000), assuming it's bad.\n", + pdrcode); return 0; } break; -- cgit v1.2.3 From a03742ac96fceac7b103aff7b9714605a21b8a3e Mon Sep 17 00:00:00 2001 From: Sherif Shehab Aldin Date: Sat, 5 Apr 2014 23:33:45 +0200 Subject: driver: staging: wlan-ng: Removed unnecessary typedefs from hfa384x_usb.c Removed unnecessary typedefs from hfa384x_usb.c Signed-off-by: Sherif Shehab Aldin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/hfa384x_usb.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c index 646c29e7f4fd..943de9c18634 100644 --- a/drivers/staging/wlan-ng/hfa384x_usb.c +++ b/drivers/staging/wlan-ng/hfa384x_usb.c @@ -744,14 +744,12 @@ static inline struct usbctlx_completor *init_rrid_completor( * Completor object: * Interprets the results of a synchronous RID-write ----------------------------------------------------------------*/ -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 struct usbctlx_cmd_completor usbctlx_wmem_completor_t; #define init_wmem_completor init_cmd_completor /*---------------------------------------------------------------- @@ -765,11 +763,11 @@ struct usbctlx_rmem_completor { void *data; unsigned int len; }; -typedef struct usbctlx_rmem_completor usbctlx_rmem_completor_t; static int usbctlx_rmem_completor_fn(struct usbctlx_completor *head) { - usbctlx_rmem_completor_t *complete = (usbctlx_rmem_completor_t *) head; + struct usbctlx_rmem_completor *complete = + (struct usbctlx_rmem_completor *)head; pr_debug("rmemresp:len=%d\n", complete->rmemresp->frmlen); memcpy(complete->data, complete->rmemresp->data, complete->len); @@ -777,7 +775,7 @@ static int usbctlx_rmem_completor_fn(struct usbctlx_completor *head) } static inline struct usbctlx_completor *init_rmem_completor( - usbctlx_rmem_completor_t + struct usbctlx_rmem_completor *completor, hfa384x_usb_rmemresp_t *rmemresp, @@ -1562,7 +1560,7 @@ hfa384x_dowrid(hfa384x_t *hw, if (result != 0) { kfree(ctlx); } else if (mode == DOWAIT) { - usbctlx_wrid_completor_t completor; + struct usbctlx_cmd_completor completor; hfa384x_cmdresult_t wridresult; result = hfa384x_usbctlx_complete_sync(hw, @@ -1654,7 +1652,7 @@ hfa384x_dormem(hfa384x_t *hw, if (result != 0) { kfree(ctlx); } else if (mode == DOWAIT) { - usbctlx_rmem_completor_t completor; + struct usbctlx_rmem_completor completor; result = hfa384x_usbctlx_complete_sync(hw, ctlx, @@ -1744,7 +1742,7 @@ hfa384x_dowmem(hfa384x_t *hw, if (result != 0) { kfree(ctlx); } else if (mode == DOWAIT) { - usbctlx_wmem_completor_t completor; + struct usbctlx_cmd_completor completor; hfa384x_cmdresult_t wmemresult; result = hfa384x_usbctlx_complete_sync(hw, -- cgit v1.2.3 From baa8a6c008329de5dd6909658c7f892340e4b5f0 Mon Sep 17 00:00:00 2001 From: Sherif Shehab Aldin Date: Sat, 5 Apr 2014 23:33:53 +0200 Subject: driver: staging: wlan-ng: switched to pr_warn changed printk(KERN_WARNING .. to pr_warn Signed-off-by: Sherif Shehab Aldin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/hfa384x_usb.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c index 943de9c18634..01284ea01cf9 100644 --- a/drivers/staging/wlan-ng/hfa384x_usb.c +++ b/drivers/staging/wlan-ng/hfa384x_usb.c @@ -714,10 +714,9 @@ static int usbctlx_rrid_completor_fn(struct usbctlx_completor *head) /* Validate the length, note body len calculation in bytes */ if (rridresult.riddata_len != complete->riddatalen) { - printk(KERN_WARNING - "RID len mismatch, rid=0x%04x hlen=%d fwlen=%d\n", - rridresult.rid, - complete->riddatalen, rridresult.riddata_len); + pr_warn("RID len mismatch, rid=0x%04x hlen=%d fwlen=%d\n", + rridresult.rid, + complete->riddatalen, rridresult.riddata_len); return -ENODATA; } -- cgit v1.2.3 From d6ae4a9995fa19ecde23f425a027f445074ba1ec Mon Sep 17 00:00:00 2001 From: Sherif Shehab Aldin Date: Sat, 5 Apr 2014 23:34:01 +0200 Subject: driver: staging: wlan-ng: Setting character pointers as const changed declaration of ctlx_str to: static const char * const ctlx_str[] Signed-off-by: Sherif Shehab Aldin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/hfa384x_usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c index 01284ea01cf9..74db234977a8 100644 --- a/drivers/staging/wlan-ng/hfa384x_usb.c +++ b/drivers/staging/wlan-ng/hfa384x_usb.c @@ -272,7 +272,7 @@ static int hfa384x_isgood_pdrcode(u16 pdrcode); static inline const char *ctlxstr(CTLX_STATE s) { - static const char *ctlx_str[] = { + static const char * const ctlx_str[] = { "Initial state", "Complete", "Request failed", -- cgit v1.2.3 From 83f91687b0922511eceddb9831e9f86c08bb3873 Mon Sep 17 00:00:00 2001 From: Sherif Shehab Aldin Date: Sat, 5 Apr 2014 23:34:12 +0200 Subject: driver: staging: wlan-ng: Removed Unnecessary space after function pointer name Removed Unnecessary space after function pointer name Signed-off-by: Sherif Shehab Aldin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/hfa384x_usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c index 74db234977a8..22f0f1da52fa 100644 --- a/drivers/staging/wlan-ng/hfa384x_usb.c +++ b/drivers/staging/wlan-ng/hfa384x_usb.c @@ -203,7 +203,7 @@ static int hfa384x_usbctlx_submit(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx); static void unlocked_usbctlx_complete(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx); struct usbctlx_completor { - int (*complete) (struct usbctlx_completor *); + int (*complete)(struct usbctlx_completor *); }; static int -- cgit v1.2.3 From 3f2d656481c64bad30f1f92b3834c6c2b5851916 Mon Sep 17 00:00:00 2001 From: Sherif Shehab Aldin Date: Sat, 5 Apr 2014 23:34:40 +0200 Subject: driver: staging: wlan-ng: Fixed Alignment to match open parenthesis Fixed Alignment to match open parenthesis in hfa384x_usb.c Signed-off-by: Sherif Shehab Aldin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/hfa384x_usb.c | 121 ++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 58 deletions(-) diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c index 22f0f1da52fa..a6684b67f8f4 100644 --- a/drivers/staging/wlan-ng/hfa384x_usb.c +++ b/drivers/staging/wlan-ng/hfa384x_usb.c @@ -350,14 +350,14 @@ static int submit_rx_urb(hfa384x_t *hw, gfp_t memflags) result = -ENOLINK; if (!hw->wlandev->hwremoved && - !test_bit(WORK_RX_HALT, &hw->usb_flags)) { + !test_bit(WORK_RX_HALT, &hw->usb_flags)) { result = SUBMIT_URB(&hw->rx_urb, memflags); /* Check whether we need to reset the RX pipe */ if (result == -EPIPE) { netdev_warn(hw->wlandev->netdev, - "%s rx pipe stalled: requesting reset\n", - hw->wlandev->netdev->name); + "%s rx pipe stalled: requesting reset\n", + hw->wlandev->netdev->name); if (!test_and_set_bit(WORK_RX_HALT, &hw->usb_flags)) schedule_work(&hw->usb_work); } @@ -406,8 +406,8 @@ static int submit_tx_urb(hfa384x_t *hw, struct urb *tx_urb, gfp_t memflags) /* Test whether we need to reset the TX pipe */ if (result == -EPIPE) { netdev_warn(hw->wlandev->netdev, - "%s tx pipe stalled: requesting reset\n", - netdev->name); + "%s tx pipe stalled: requesting reset\n", + netdev->name); set_bit(WORK_TX_HALT, &hw->usb_flags); schedule_work(&hw->usb_work); } else if (result == 0) { @@ -455,11 +455,11 @@ static void hfa384x_usb_defer(struct work_struct *data) ret = usb_clear_halt(hw->usb, hw->endp_in); if (ret != 0) { netdev_err(hw->wlandev->netdev, - "Failed to clear rx pipe for %s: err=%d\n", - netdev->name, ret); + "Failed to clear rx pipe for %s: err=%d\n", + netdev->name, ret); } else { netdev_info(hw->wlandev->netdev, "%s rx pipe reset complete.\n", - netdev->name); + netdev->name); clear_bit(WORK_RX_HALT, &hw->usb_flags); set_bit(WORK_RX_RESUME, &hw->usb_flags); } @@ -472,7 +472,8 @@ static void hfa384x_usb_defer(struct work_struct *data) ret = submit_rx_urb(hw, GFP_KERNEL); if (ret != 0) { netdev_err(hw->wlandev->netdev, - "Failed to resume %s rx pipe.\n", netdev->name); + "Failed to resume %s rx pipe.\n", + netdev->name); } else { clear_bit(WORK_RX_RESUME, &hw->usb_flags); } @@ -486,11 +487,11 @@ static void hfa384x_usb_defer(struct work_struct *data) ret = usb_clear_halt(hw->usb, hw->endp_out); if (ret != 0) { netdev_err(hw->wlandev->netdev, - "Failed to clear tx pipe for %s: err=%d\n", - netdev->name, ret); + "Failed to clear tx pipe for %s: err=%d\n", + netdev->name, ret); } else { netdev_info(hw->wlandev->netdev, "%s tx pipe reset complete.\n", - netdev->name); + netdev->name); clear_bit(WORK_TX_HALT, &hw->usb_flags); set_bit(WORK_TX_RESUME, &hw->usb_flags); @@ -1206,7 +1207,7 @@ int hfa384x_corereset(hfa384x_t *hw, int holdtime, int settletime, int genesis) result = usb_reset_device(hw->usb); if (result < 0) { netdev_err(hw->wlandev->netdev, "usb_reset_device() failed, result=%d.\n", - result); + result); } return result; @@ -1306,8 +1307,8 @@ cleanup: result = completor->complete(completor); } else { netdev_warn(hw->wlandev->netdev, "CTLX[%d] error: state(%s)\n", - le16_to_cpu(ctlx->outbuf.type), - ctlxstr(ctlx->state)); + le16_to_cpu(ctlx->outbuf.type), + ctlxstr(ctlx->state)); result = -EIO; } @@ -2051,7 +2052,7 @@ int hfa384x_drvr_flashdl_write(hfa384x_t *hw, u32 daddr, void *buf, u32 len) burnhi = HFA384x_ADDR_CMD_MKPAGE(burndaddr); netdev_info(hw->wlandev->netdev, "Writing %d bytes to flash @0x%06x\n", - burnlen, burndaddr); + burnlen, burndaddr); /* Set the download mode */ result = hfa384x_cmd_download(hw, HFA384x_PROGMODE_NV, @@ -2090,8 +2091,8 @@ int hfa384x_drvr_flashdl_write(hfa384x_t *hw, u32 daddr, void *buf, u32 len) 0, 0, 0); if (result) { netdev_err(hw->wlandev->netdev, - "download(NVWRITE,lo=%x,hi=%x,len=%x) cmd failed, result=%d. Aborting d/l\n", - burnlo, burnhi, burnlen, result); + "download(NVWRITE,lo=%x,hi=%x,len=%x) cmd failed, result=%d. Aborting d/l\n", + burnlo, burnhi, burnlen, result); goto exit_proc; } @@ -2274,7 +2275,7 @@ int hfa384x_drvr_ramdl_enable(hfa384x_t *hw, u32 exeaddr) for (i = 0; i < HFA384x_PORTID_MAX; i++) { if (hw->port_enabled[i]) { netdev_err(hw->wlandev->netdev, - "Can't download with a macport enabled.\n"); + "Can't download with a macport enabled.\n"); return -EINVAL; } } @@ -2445,7 +2446,8 @@ int hfa384x_drvr_readpda(hfa384x_t *hw, void *buf, unsigned int len) if (result) { netdev_warn(hw->wlandev->netdev, - "Read from index %zd failed, continuing\n", i); + "Read from index %zd failed, continuing\n", + i); continue; } @@ -2465,7 +2467,7 @@ int hfa384x_drvr_readpda(hfa384x_t *hw, void *buf, unsigned int len) /* Test the code */ if (!hfa384x_isgood_pdrcode(pdrcode)) { netdev_err(hw->wlandev->netdev, "pdrcode invalid=%d\n", - pdrcode); + pdrcode); pdaok = 0; break; } @@ -2481,13 +2483,13 @@ int hfa384x_drvr_readpda(hfa384x_t *hw, void *buf, unsigned int len) } if (pdaok) { netdev_info(hw->wlandev->netdev, - "PDA Read from 0x%08x in %s space.\n", - pdaloc[i].cardaddr, - pdaloc[i].auxctl == 0 ? "EXTDS" : - pdaloc[i].auxctl == 1 ? "NV" : - pdaloc[i].auxctl == 2 ? "PHY" : - pdaloc[i].auxctl == 3 ? "ICSRAM" : - ""); + "PDA Read from 0x%08x in %s space.\n", + pdaloc[i].cardaddr, + pdaloc[i].auxctl == 0 ? "EXTDS" : + pdaloc[i].auxctl == 1 ? "NV" : + pdaloc[i].auxctl == 2 ? "PHY" : + pdaloc[i].auxctl == 3 ? "ICSRAM" : + ""); break; } } @@ -2582,7 +2584,8 @@ int hfa384x_drvr_start(hfa384x_t *hw) result = submit_rx_urb(hw, GFP_KERNEL); if (result != 0) { netdev_err(hw->wlandev->netdev, - "Fatal, failed to submit RX URB, result=%d\n", result); + "Fatal, failed to submit RX URB, result=%d\n", + result); goto done; } @@ -2602,8 +2605,8 @@ int hfa384x_drvr_start(hfa384x_t *hw) if (result1 != 0) { if (result2 != 0) { netdev_err(hw->wlandev->netdev, - "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 { @@ -2613,9 +2616,9 @@ int hfa384x_drvr_start(hfa384x_t *hw) } } else if (result2 != 0) { netdev_warn(hw->wlandev->netdev, "First cmd_initialize() succeeded, but second attempt failed (result=%d)\n", - result2); + result2); netdev_warn(hw->wlandev->netdev, - "Most likely the card will be functional\n"); + "Most likely the card will be functional\n"); goto done; } @@ -3007,7 +3010,8 @@ static void unlocked_usbctlx_complete(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx) default: netdev_err(hw->wlandev->netdev, "CTLX[%d] not in a terminating state(%s)\n", - le16_to_cpu(ctlx->outbuf.type), ctlxstr(ctlx->state)); + le16_to_cpu(ctlx->outbuf.type), + ctlxstr(ctlx->state)); break; } /* switch */ } @@ -3089,8 +3093,8 @@ static void hfa384x_usbctlxq_run(hfa384x_t *hw) * and schedule a reset ... */ netdev_warn(hw->wlandev->netdev, - "%s tx pipe stalled: requesting reset\n", - hw->wlandev->netdev->name); + "%s tx pipe stalled: requesting reset\n", + hw->wlandev->netdev->name); list_move(&head->list, &hw->ctlxq.pending); set_bit(WORK_TX_HALT, &hw->usb_flags); schedule_work(&hw->usb_work); @@ -3099,12 +3103,12 @@ static void hfa384x_usbctlxq_run(hfa384x_t *hw) if (result == -ESHUTDOWN) { netdev_warn(hw->wlandev->netdev, "%s urb shutdown!\n", - hw->wlandev->netdev->name); + hw->wlandev->netdev->name); break; } netdev_err(hw->wlandev->netdev, "Failed to submit CTLX[%d]: error=%d\n", - le16_to_cpu(head->outbuf.type), result); + le16_to_cpu(head->outbuf.type), result); unlocked_usbctlx_complete(hw, head); } /* while */ @@ -3171,7 +3175,7 @@ static void hfa384x_usbin_callback(struct urb *urb) case -EPIPE: netdev_warn(hw->wlandev->netdev, "%s rx pipe stalled: requesting reset\n", - wlandev->netdev->name); + wlandev->netdev->name); if (!test_and_set_bit(WORK_RX_HALT, &hw->usb_flags)) schedule_work(&hw->usb_work); ++(wlandev->linux_stats.rx_errors); @@ -3222,8 +3226,8 @@ static void hfa384x_usbin_callback(struct urb *urb) if (result != 0) { netdev_err(hw->wlandev->netdev, - "Fatal, failed to resubmit rx_urb. error=%d\n", - result); + "Fatal, failed to resubmit rx_urb. error=%d\n", + result); } } @@ -3358,9 +3362,9 @@ retry: */ if (ctlx->outbuf.type != intype) { netdev_warn(hw->wlandev->netdev, - "Expected IN[%d], received IN[%d] - ignored.\n", - le16_to_cpu(ctlx->outbuf.type), - le16_to_cpu(intype)); + "Expected IN[%d], received IN[%d] - ignored.\n", + le16_to_cpu(ctlx->outbuf.type), + le16_to_cpu(intype)); goto unlock; } @@ -3394,9 +3398,9 @@ retry: * Throw this CTLX away ... */ netdev_err(hw->wlandev->netdev, - "Matched IN URB, CTLX[%d] in invalid state(%s). Discarded.\n", - le16_to_cpu(ctlx->outbuf.type), - ctlxstr(ctlx->state)); + "Matched IN URB, CTLX[%d] in invalid state(%s). Discarded.\n", + le16_to_cpu(ctlx->outbuf.type), + ctlxstr(ctlx->state)); if (unlocked_usbctlx_cancel_async(hw, ctlx) == 0) run_queue = 1; break; @@ -3531,7 +3535,8 @@ static void hfa384x_usbin_rx(wlandevice_t *wlandev, struct sk_buff *skb) default: netdev_warn(hw->wlandev->netdev, "Received frame on unsupported port=%d\n", - HFA384x_RXSTATUS_MACPORT_GET(usbin->rxfrm.desc.status)); + HFA384x_RXSTATUS_MACPORT_GET( + usbin->rxfrm.desc.status)); goto done; break; } @@ -3593,8 +3598,8 @@ static void hfa384x_int_rxmonitor(wlandevice_t *wlandev, skb = dev_alloc_skb(skblen); if (skb == NULL) { netdev_err(hw->wlandev->netdev, - "alloc_skb failed trying to allocate %d bytes\n", - skblen); + "alloc_skb failed trying to allocate %d bytes\n", + skblen); return; } @@ -3711,8 +3716,8 @@ static void hfa384x_usbout_callback(struct urb *urb) { hfa384x_t *hw = wlandev->priv; netdev_warn(hw->wlandev->netdev, - "%s tx pipe stalled: requesting reset\n", - wlandev->netdev->name); + "%s tx pipe stalled: requesting reset\n", + wlandev->netdev->name); if (!test_and_set_bit (WORK_TX_HALT, &hw->usb_flags)) schedule_work(&hw->usb_work); @@ -3744,7 +3749,7 @@ static void hfa384x_usbout_callback(struct urb *urb) default: netdev_info(wlandev->netdev, "unknown urb->status=%d\n", - urb->status); + urb->status); ++(wlandev->linux_stats.tx_errors); break; } /* switch */ @@ -3838,9 +3843,9 @@ retry: default: /* This is NOT a valid CTLX "success" state! */ netdev_err(hw->wlandev->netdev, - "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 { @@ -3848,8 +3853,8 @@ retry: if ((urb->status == -EPIPE) && !test_and_set_bit(WORK_TX_HALT, &hw->usb_flags)) { netdev_warn(hw->wlandev->netdev, - "%s tx pipe stalled: requesting reset\n", - hw->wlandev->netdev->name); + "%s tx pipe stalled: requesting reset\n", + hw->wlandev->netdev->name); schedule_work(&hw->usb_work); } -- cgit v1.2.3 From a3542e664bb10c10c52088efc460371225a939b0 Mon Sep 17 00:00:00 2001 From: Sherif Shehab Aldin Date: Sat, 5 Apr 2014 23:34:48 +0200 Subject: driver: staging: wlan-ng: Fixed white spaces issues In hfa384x_usb.c: Moved Logical continuations to the correct lines Removed unnecessary blank lines Signed-off-by: Sherif Shehab Aldin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/hfa384x_usb.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c index a6684b67f8f4..1a6116a5093c 100644 --- a/drivers/staging/wlan-ng/hfa384x_usb.c +++ b/drivers/staging/wlan-ng/hfa384x_usb.c @@ -398,9 +398,8 @@ static int submit_tx_urb(hfa384x_t *hw, struct urb *tx_urb, gfp_t memflags) result = -ENOLINK; if (netif_running(netdev)) { - - if (!hw->wlandev->hwremoved - && !test_bit(WORK_TX_HALT, &hw->usb_flags)) { + if (!hw->wlandev->hwremoved && + !test_bit(WORK_TX_HALT, &hw->usb_flags)) { result = SUBMIT_URB(tx_urb, memflags); /* Test whether we need to reset the TX pipe */ @@ -656,7 +655,6 @@ usbctlx_get_rridresult(const hfa384x_usb_rridresp_t *rridresp, result->rid = le16_to_cpu(rridresp->rid); result->riddata = rridresp->data; result->riddata_len = ((le16_to_cpu(rridresp->frmlen) - 1) * 2); - } /*---------------------------------------------------------------- @@ -2845,7 +2843,6 @@ static void hfa384x_usbctlx_reaper_task(unsigned long data) } spin_unlock_irqrestore(&hw->ctlxq.lock, flags); - } /*---------------------------------------------------------------- @@ -3706,7 +3703,6 @@ static void hfa384x_usbout_callback(struct urb *urb) #endif if (wlandev && wlandev->netdev) { - switch (urb->status) { case 0: hfa384x_usbout_tx(wlandev, usbout); @@ -3732,8 +3728,8 @@ static void hfa384x_usbout_callback(struct urb *urb) hfa384x_t *hw = wlandev->priv; if (!test_and_set_bit - (THROTTLE_TX, &hw->usb_flags) - && !timer_pending(&hw->throttle)) { + (THROTTLE_TX, &hw->usb_flags) && + !timer_pending(&hw->throttle)) { mod_timer(&hw->throttle, jiffies + THROTTLE_JIFFIES); } -- cgit v1.2.3 From 96b1971ace70c563048d341bfc1bd55754b95183 Mon Sep 17 00:00:00 2001 From: Sherif Shehab Aldin Date: Sat, 5 Apr 2014 23:34:56 +0200 Subject: driver: staging: wlan-ng: Removed multiple assignments Removed multiple assignments from hfa384x_usb.c Signed-off-by: Sherif Shehab Aldin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/hfa384x_usb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c index 1a6116a5093c..cf2703062e96 100644 --- a/drivers/staging/wlan-ng/hfa384x_usb.c +++ b/drivers/staging/wlan-ng/hfa384x_usb.c @@ -2599,7 +2599,8 @@ int hfa384x_drvr_start(hfa384x_t *hw) */ result1 = hfa384x_cmd_initialize(hw); msleep(1000); - result = result2 = hfa384x_cmd_initialize(hw); + result = hfa384x_cmd_initialize(hw); + result2 = result; if (result1 != 0) { if (result2 != 0) { netdev_err(hw->wlandev->netdev, -- cgit v1.2.3 From 638f81b849a306e4a897f99f51e22ba515338e21 Mon Sep 17 00:00:00 2001 From: Sherif Shehab Aldin Date: Sat, 5 Apr 2014 23:35:06 +0200 Subject: driver: staging: wlan-ng: Removed #if 0 lines from hfa384x_usb.c Removed lines that were ignored by #if 0 Signed-off-by: Sherif Shehab Aldin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/hfa384x_usb.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c index cf2703062e96..867edb4354d6 100644 --- a/drivers/staging/wlan-ng/hfa384x_usb.c +++ b/drivers/staging/wlan-ng/hfa384x_usb.c @@ -2019,12 +2019,6 @@ int hfa384x_drvr_flashdl_write(hfa384x_t *hw, u32 daddr, void *buf, u32 len) HFA384x_ADDR_AUX_MKFLAT(hw->bufinfo.page, hw->bufinfo.offset); pr_debug("dlbuf.page=0x%04x dlbuf.offset=0x%04x dlbufaddr=0x%08x\n", hw->bufinfo.page, hw->bufinfo.offset, dlbufaddr); - -#if 0 - netdev_warn(hw->wlandev->netdev, - "dlbuf@0x%06lx len=%d to=%d\n", dlbufaddr, - hw->bufinfo.len, hw->dltimeout); -#endif /* Calculations to determine how many fills of the dlbuffer to do * and how many USB wmemreq's to do for each fill. At this point * in time, the dlbuffer size and the wmemreq size are the same. -- cgit v1.2.3 From 5d85fe346fc34e1d5932974a95440297cd7a009f Mon Sep 17 00:00:00 2001 From: Sherif Shehab Aldin Date: Sat, 5 Apr 2014 23:35:15 +0200 Subject: driver: staging: wlan-ng: Removed unnecessary spaces after cast from hfa384x_usb.c Fixed: No space is necessary after a cast Signed-off-by: Sherif Shehab Aldin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/hfa384x_usb.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c index 867edb4354d6..f0ab5a27015e 100644 --- a/drivers/staging/wlan-ng/hfa384x_usb.c +++ b/drivers/staging/wlan-ng/hfa384x_usb.c @@ -673,7 +673,7 @@ static inline int usbctlx_cmd_completor_fn(struct usbctlx_completor *head) { struct usbctlx_cmd_completor *complete; - complete = (struct usbctlx_cmd_completor *) head; + complete = (struct usbctlx_cmd_completor *)head; return usbctlx_get_status(complete->cmdresp, complete->result); } @@ -708,7 +708,7 @@ static int usbctlx_rrid_completor_fn(struct usbctlx_completor *head) struct usbctlx_rrid_completor *complete; hfa384x_rridresult_t rridresult; - complete = (struct usbctlx_rrid_completor *) head; + complete = (struct usbctlx_rrid_completor *)head; usbctlx_get_rridresult(complete->rridresp, &rridresult); /* Validate the length, note body len calculation in bytes */ @@ -2819,7 +2819,7 @@ void hfa384x_tx_timeout(wlandevice_t *wlandev) ----------------------------------------------------------------*/ static void hfa384x_usbctlx_reaper_task(unsigned long data) { - hfa384x_t *hw = (hfa384x_t *) data; + hfa384x_t *hw = (hfa384x_t *)data; struct list_head *entry; struct list_head *temp; unsigned long flags; @@ -2856,7 +2856,7 @@ static void hfa384x_usbctlx_reaper_task(unsigned long data) ----------------------------------------------------------------*/ static void hfa384x_usbctlx_completion_task(unsigned long data) { - hfa384x_t *hw = (hfa384x_t *) data; + hfa384x_t *hw = (hfa384x_t *)data; struct list_head *entry; struct list_head *temp; unsigned long flags; @@ -3128,7 +3128,7 @@ static void hfa384x_usbin_callback(struct urb *urb) { wlandevice_t *wlandev = urb->context; hfa384x_t *hw; - hfa384x_usbin_t *usbin = (hfa384x_usbin_t *) urb->transfer_buffer; + hfa384x_usbin_t *usbin = (hfa384x_usbin_t *)urb->transfer_buffer; struct sk_buff *skb = NULL; int result; int urb_status; @@ -3456,7 +3456,7 @@ static void hfa384x_usbin_txcompl(wlandevice_t *wlandev, ----------------------------------------------------------------*/ static void hfa384x_usbin_rx(wlandevice_t *wlandev, struct sk_buff *skb) { - hfa384x_usbin_t *usbin = (hfa384x_usbin_t *) skb->data; + hfa384x_usbin_t *usbin = (hfa384x_usbin_t *)skb->data; hfa384x_t *hw = wlandev->priv; int hdrlen; struct p80211_rxmeta *rxmeta; @@ -3601,7 +3601,7 @@ static void hfa384x_int_rxmonitor(wlandevice_t *wlandev, struct p80211_caphdr *caphdr; /* The NEW header format! */ datap = skb_put(skb, sizeof(struct p80211_caphdr)); - caphdr = (struct p80211_caphdr *) datap; + caphdr = (struct p80211_caphdr *)datap; caphdr->version = htonl(P80211CAPTURE_VERSION); caphdr->length = htonl(sizeof(struct p80211_caphdr)); @@ -3896,7 +3896,7 @@ delresp: ----------------------------------------------------------------*/ static void hfa384x_usbctlx_reqtimerfn(unsigned long data) { - hfa384x_t *hw = (hfa384x_t *) data; + hfa384x_t *hw = (hfa384x_t *)data; unsigned long flags; spin_lock_irqsave(&hw->ctlxq.lock, flags); @@ -3954,7 +3954,7 @@ static void hfa384x_usbctlx_reqtimerfn(unsigned long data) ----------------------------------------------------------------*/ static void hfa384x_usbctlx_resptimerfn(unsigned long data) { - hfa384x_t *hw = (hfa384x_t *) data; + hfa384x_t *hw = (hfa384x_t *)data; unsigned long flags; spin_lock_irqsave(&hw->ctlxq.lock, flags); @@ -3993,7 +3993,7 @@ static void hfa384x_usbctlx_resptimerfn(unsigned long data) ----------------------------------------------------------------*/ static void hfa384x_usb_throttlefn(unsigned long data) { - hfa384x_t *hw = (hfa384x_t *) data; + hfa384x_t *hw = (hfa384x_t *)data; unsigned long flags; spin_lock_irqsave(&hw->ctlxq.lock, flags); -- cgit v1.2.3 From 8cf22fda6272e5240a118f003d9222da5489af38 Mon Sep 17 00:00:00 2001 From: Neil Armstrong Date: Fri, 11 Apr 2014 15:00:49 +0200 Subject: staging: wlan-ng: fix bad symbol declaration With sparse, the following error appears : CHECK drivers/staging/wlan-ng/p80211netdev.c drivers/staging/wlan-ng/cfg80211.c:710:6: warning: symbol 'prism2_connect_result' was not declared. Should it be static? drivers/staging/wlan-ng/cfg80211.c:719:6: warning: symbol 'prism2_disconnected' was not declared. Should it be static? drivers/staging/wlan-ng/cfg80211.c:725:6: warning: symbol 'prism2_roamed' was not declared. Should it be static? Move functions declaration to coherent internal header file. Signed-off-by: Neil 'Superna' Armstrong Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/prism2mgmt.h | 5 +++++ drivers/staging/wlan-ng/prism2sta.c | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wlan-ng/prism2mgmt.h b/drivers/staging/wlan-ng/prism2mgmt.h index 190d390c8490..b62fdcba94e6 100644 --- a/drivers/staging/wlan-ng/prism2mgmt.h +++ b/drivers/staging/wlan-ng/prism2mgmt.h @@ -109,4 +109,9 @@ void prism2sta_processing_defer(struct work_struct *data); void prism2sta_commsqual_defer(struct work_struct *data); void prism2sta_commsqual_timer(unsigned long data); +/* Interface callback functions, passing data back up to the cfg80211 layer */ +void prism2_connect_result(wlandevice_t *wlandev, u8 failed); +void prism2_disconnected(wlandevice_t *wlandev); +void prism2_roamed(wlandevice_t *wlandev); + #endif diff --git a/drivers/staging/wlan-ng/prism2sta.c b/drivers/staging/wlan-ng/prism2sta.c index f9ccf2371dba..3fd4538d9408 100644 --- a/drivers/staging/wlan-ng/prism2sta.c +++ b/drivers/staging/wlan-ng/prism2sta.c @@ -120,10 +120,6 @@ MODULE_PARM_DESC(prism2_reset_settletime, "reset settle time in ms"); MODULE_LICENSE("Dual MPL/GPL"); -void prism2_connect_result(wlandevice_t *wlandev, u8 failed); -void prism2_disconnected(wlandevice_t *wlandev); -void prism2_roamed(wlandevice_t *wlandev); - static int prism2sta_open(wlandevice_t *wlandev); static int prism2sta_close(wlandevice_t *wlandev); static void prism2sta_reset(wlandevice_t *wlandev); -- cgit v1.2.3 From 67c4ded5a3cfc666f149f2dee3ad5ae2f06f1736 Mon Sep 17 00:00:00 2001 From: Denis Pithon Date: Mon, 12 May 2014 17:22:44 +0200 Subject: staging/wlan-ng: update function header comment Header comment of p80211netdev_rx_bh() does not match function prototype. Fixed. Signed-off-by: Denis Pithon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/p80211netdev.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c index e3ae8024d3a4..e350e1ce475a 100644 --- a/drivers/staging/wlan-ng/p80211netdev.c +++ b/drivers/staging/wlan-ng/p80211netdev.c @@ -243,19 +243,11 @@ void p80211netdev_rx(wlandevice_t *wlandev, struct sk_buff *skb) tasklet_schedule(&wlandev->rx_bh); } -/*---------------------------------------------------------------- -* p80211netdev_rx_bh -* -* Deferred processing of all received frames. -* -* Arguments: -* wlandev WLAN network device structure -* skb skbuff containing a full 802.11 frame. -* Returns: -* nothing -* Side effects: -* -----------------------------------------------------------------*/ +/** + * p80211netdev_rx_bh - deferred processing of all received frames + * + * @arg: pointer to WLAN network device structure (cast to unsigned long) + */ static void p80211netdev_rx_bh(unsigned long arg) { wlandevice_t *wlandev = (wlandevice_t *) arg; -- cgit v1.2.3 From 05d39beeb865940852f469f1ce067cc7fa607a72 Mon Sep 17 00:00:00 2001 From: Denis Pithon Date: Mon, 12 May 2014 17:22:45 +0200 Subject: staging/wlan-ng: remove function declaration Removed useless function prototype: static function p80211netdev_rx_bh() is defined before being used. Signed-off-by: Denis Pithon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/p80211netdev.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c index e350e1ce475a..2da3cbb8f0fa 100644 --- a/drivers/staging/wlan-ng/p80211netdev.c +++ b/drivers/staging/wlan-ng/p80211netdev.c @@ -90,9 +90,6 @@ #include "cfg80211.c" -/* Support functions */ -static void p80211netdev_rx_bh(unsigned long arg); - /* netdevice method functions */ static int p80211knetdev_init(netdevice_t *netdev); static struct net_device_stats *p80211knetdev_get_stats(netdevice_t *netdev); -- cgit v1.2.3 From ccc3a5986daefdf0aef76f3664ac6848e3d9515e Mon Sep 17 00:00:00 2001 From: Denis Pithon Date: Mon, 12 May 2014 17:22:46 +0200 Subject: staging/wlan-ng: code refactoring Extract new static function from p80211netdev_rx_bh() to fix coding style issue (too many leading tabs). Signed-off-by: Denis Pithon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/p80211netdev.c | 74 ++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 31 deletions(-) diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c index 2da3cbb8f0fa..61a30928a9c1 100644 --- a/drivers/staging/wlan-ng/p80211netdev.c +++ b/drivers/staging/wlan-ng/p80211netdev.c @@ -240,6 +240,48 @@ void p80211netdev_rx(wlandevice_t *wlandev, struct sk_buff *skb) tasklet_schedule(&wlandev->rx_bh); } +#define CONV_TO_ETHER_SKIPPED 0x01 +#define CONV_TO_ETHER_FAILED 0x02 + +/** + * convert_frame_to_ether - conversion from 802.11 frame to ethernet frame + * @wlandev: pointer to WLAN device + * @skb: pointer to socket buffer + * + * Returns: 0 if conversion succeeded + * CONV_TO_ETHER_FAILED if conversion failed + * CONV_TO_ETHER_SKIPPED if frame is ignored + */ +static int convert_frame_to_ether(wlandevice_t *wlandev, struct sk_buff *skb) +{ + struct p80211_hdr_a3 *hdr; + + hdr = (struct p80211_hdr_a3 *) skb->data; + if (p80211_rx_typedrop(wlandev, hdr->fc)) + return CONV_TO_ETHER_SKIPPED; + + /* perform mcast filtering */ + if (wlandev->netdev->flags & IFF_ALLMULTI) { + /* allow my local address through */ + if (memcmp(hdr->a1, wlandev->netdev->dev_addr, ETH_ALEN) != 0) { + /* but reject anything else that isn't multicast */ + if (!(hdr->a1[0] & 0x01)) + return CONV_TO_ETHER_SKIPPED; + } + } + + if (skb_p80211_to_ether(wlandev, wlandev->ethconv, skb) == 0) { + skb->dev->last_rx = jiffies; + wlandev->linux_stats.rx_packets++; + wlandev->linux_stats.rx_bytes += skb->len; + netif_rx_ni(skb); + return 0; + } + + pr_debug("p80211_to_ether failed.\n"); + return CONV_TO_ETHER_FAILED; +} + /** * p80211netdev_rx_bh - deferred processing of all received frames * @@ -250,7 +292,6 @@ static void p80211netdev_rx_bh(unsigned long arg) wlandevice_t *wlandev = (wlandevice_t *) arg; struct sk_buff *skb = NULL; netdevice_t *dev = wlandev->netdev; - struct p80211_hdr_a3 *hdr; /* Let's empty our our queue */ while ((skb = skb_dequeue(&wlandev->nsd_rxq))) { @@ -273,37 +314,8 @@ static void p80211netdev_rx_bh(unsigned long arg) netif_rx_ni(skb); continue; } else { - hdr = (struct p80211_hdr_a3 *) skb->data; - if (p80211_rx_typedrop(wlandev, hdr->fc)) { - dev_kfree_skb(skb); - continue; - } - - /* perform mcast filtering */ - if (wlandev->netdev->flags & IFF_ALLMULTI) { - /* allow my local address through */ - if (memcmp - (hdr->a1, wlandev->netdev->dev_addr, - ETH_ALEN) != 0) { - /* but reject anything else that - isn't multicast */ - if (!(hdr->a1[0] & 0x01)) { - dev_kfree_skb(skb); - continue; - } - } - } - - if (skb_p80211_to_ether - (wlandev, wlandev->ethconv, skb) == 0) { - skb->dev->last_rx = jiffies; - wlandev->linux_stats.rx_packets++; - wlandev->linux_stats.rx_bytes += - skb->len; - netif_rx_ni(skb); + if (!convert_frame_to_ether(wlandev, skb)) continue; - } - pr_debug("p80211_to_ether failed.\n"); } } dev_kfree_skb(skb); -- cgit v1.2.3 From b674ee142296b84ea8514da52e9185dab4070b72 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Thu, 15 May 2014 22:49:10 +0100 Subject: staging: vt6656: nsDMA_tx_packet Move pContext later. call s_vGetFreeContext later in function skiping large chunk of code. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 03d5339191b6..57eb5025ae27 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -2172,14 +2172,6 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, struct sk_buff *skb) } } - pContext = s_vGetFreeContext(pDevice); - - if (pContext == NULL) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG" pContext == NULL\n"); - dev_kfree_skb_irq(skb); - return STATUS_RESOURCES; - } - memcpy(&pDevice->sTxEthHeader, skb->data, ETH_HLEN); //mike add:station mode check eapol-key challenge---> @@ -2402,7 +2394,6 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, struct sk_buff *skb) if (pTransmitKey == NULL) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"return no tx key\n"); - pContext->bBoolInUse = false; dev_kfree_skb_irq(skb); pStats->tx_dropped++; return STATUS_FAILURE; @@ -2410,6 +2401,13 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, struct sk_buff *skb) } } + pContext = s_vGetFreeContext(pDevice); + if (!pContext) { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG" pContext == NULL\n"); + dev_kfree_skb_irq(skb); + return STATUS_RESOURCES; + } + pTX_Buffer = (struct vnt_tx_buffer *)&pContext->Data[0]; fConvertedPacket = s_bPacketToWirelessUsb(pDevice, byPktType, -- cgit v1.2.3 From 30a05b397ce410685532120e97c6cc378dd31a1f Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Thu, 15 May 2014 22:49:11 +0100 Subject: staging: vt6656: struct vnt_usb_send_context remove camel case. Camel case changes pDevice -> priv pPacket -> skb pUrb -> urb uBufLen -> buf_len; bBoolInUse -> in_use Data -> data Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/device.h | 12 +++---- drivers/staging/vt6656/main_usb.c | 14 ++++---- drivers/staging/vt6656/rxtx.c | 74 +++++++++++++++++++-------------------- drivers/staging/vt6656/usbpipe.c | 26 +++++++------- 4 files changed, 63 insertions(+), 63 deletions(-) diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index e2abe3ddd244..f36a2eb826b7 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -176,13 +176,13 @@ struct vnt_rcb { /* used to track bulk out irps */ struct vnt_usb_send_context { - void *pDevice; - struct sk_buff *pPacket; - struct urb *pUrb; - unsigned int uBufLen; + void *priv; + struct sk_buff *skb; + struct urb *urb; + unsigned int buf_len; u8 type; - bool bBoolInUse; - unsigned char Data[MAX_TOTAL_SIZE_WITH_ALL_HEADERS]; + bool in_use; + unsigned char data[MAX_TOTAL_SIZE_WITH_ALL_HEADERS]; }; /* tx packet info for rxtx */ diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 208640b1d775..ea0d6b3361fd 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -760,9 +760,9 @@ static void device_free_tx_bufs(struct vnt_private *priv) for (ii = 0; ii < priv->cbTD; ii++) { tx_context = priv->apTD[ii]; /* deallocate URBs */ - if (tx_context->pUrb) { - usb_kill_urb(tx_context->pUrb); - usb_free_urb(tx_context->pUrb); + if (tx_context->urb) { + usb_kill_urb(tx_context->urb); + usb_free_urb(tx_context->urb); } kfree(tx_context); @@ -828,17 +828,17 @@ static bool device_alloc_bufs(struct vnt_private *priv) } priv->apTD[ii] = tx_context; - tx_context->pDevice = priv; + tx_context->priv = priv; /* allocate URBs */ - tx_context->pUrb = usb_alloc_urb(0, GFP_ATOMIC); - if (tx_context->pUrb == NULL) { + tx_context->urb = usb_alloc_urb(0, GFP_ATOMIC); + if (!tx_context->urb) { DBG_PRT(MSG_LEVEL_ERR, KERN_ERR "alloc tx urb failed\n"); goto free_tx; } - tx_context->bBoolInUse = false; + tx_context->in_use = false; } /* allocate RCB mem */ diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 57eb5025ae27..52be7b0d98bb 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -149,9 +149,9 @@ static struct vnt_usb_send_context return NULL; context = priv->apTD[ii]; - if (context->bBoolInUse == false) { - context->bBoolInUse = true; - memset(context->Data, 0, + if (context->in_use == false) { + context->in_use = true; + memset(context->data, 0, MAX_TOTAL_SIZE_WITH_ALL_HEADERS); return context; } @@ -1391,7 +1391,7 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, return CMD_STATUS_RESOURCES; } - pTX_Buffer = (struct vnt_tx_buffer *)&pContext->Data[0]; + pTX_Buffer = (struct vnt_tx_buffer *)&pContext->data[0]; cbFrameBodySize = pPacket->cbPayloadLen; pTxBufHead = &pTX_Buffer->fifo_head; pbyTxBufferAddr = (u8 *)&pTxBufHead->adwTxKey[0]; @@ -1609,9 +1609,9 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, pTX_Buffer->byPKTNO = (u8) (((wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); pTX_Buffer->byType = 0x00; - pContext->pPacket = NULL; - pContext->type = CONTEXT_MGMT_PACKET; - pContext->uBufLen = (u16)cbReqCount + 4; //USB header + pContext->skb = NULL; + pContext->type = CONTEXT_MGMT_PACKET; + pContext->buf_len = (u16)cbReqCount + 4; /* USB header */ if (WLAN_GET_FC_TODS(pMACHeader->frame_control) == 0) { s_vSaveTxPktInfo(pDevice, (u8)(pTX_Buffer->byPKTNO & 0x0F), @@ -1649,7 +1649,7 @@ CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, return status ; } - pTX_Buffer = (struct vnt_beacon_buffer *)&pContext->Data[0]; + pTX_Buffer = (struct vnt_beacon_buffer *)&pContext->data[0]; short_head = &pTX_Buffer->short_head; cbFrameBodySize = pPacket->cbPayloadLen; @@ -1701,9 +1701,9 @@ CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, pTX_Buffer->byPKTNO = (u8) (((wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); pTX_Buffer->byType = 0x01; - pContext->pPacket = NULL; - pContext->type = CONTEXT_MGMT_PACKET; - pContext->uBufLen = (u16)cbReqCount + 4; //USB header + pContext->skb = NULL; + pContext->type = CONTEXT_MGMT_PACKET; + pContext->buf_len = (u16)cbReqCount + 4; /* USB header */ PIPEnsSendBulkOut(pDevice,pContext); return CMD_STATUS_PENDING; @@ -1760,7 +1760,7 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) return ; } - pTX_Buffer = (struct vnt_tx_buffer *)&pContext->Data[0]; + pTX_Buffer = (struct vnt_tx_buffer *)&pContext->data[0]; pTxBufHead = &pTX_Buffer->fifo_head; pbyTxBufferAddr = (u8 *)&pTxBufHead->adwTxKey[0]; wTxBufSize = sizeof(struct vnt_tx_fifo_head); @@ -2049,9 +2049,9 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) pTX_Buffer->byPKTNO = (u8) (((wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); pTX_Buffer->byType = 0x00; - pContext->pPacket = skb; - pContext->type = CONTEXT_MGMT_PACKET; - pContext->uBufLen = (u16)cbReqCount + 4; //USB header + pContext->skb = skb; + pContext->type = CONTEXT_MGMT_PACKET; + pContext->buf_len = (u16)cbReqCount + 4; /* USB header */ if (WLAN_GET_FC_TODS(pMACHeader->frame_control) == 0) { s_vSaveTxPktInfo(pDevice, (u8)(pTX_Buffer->byPKTNO & 0x0F), @@ -2408,7 +2408,7 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, struct sk_buff *skb) return STATUS_RESOURCES; } - pTX_Buffer = (struct vnt_tx_buffer *)&pContext->Data[0]; + pTX_Buffer = (struct vnt_tx_buffer *)&pContext->data[0]; fConvertedPacket = s_bPacketToWirelessUsb(pDevice, byPktType, pTX_Buffer, bNeedEncryption, @@ -2418,11 +2418,11 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, struct sk_buff *skb) &uHeaderLen, &BytesToWrite ); - if (fConvertedPacket == false) { - pContext->bBoolInUse = false; - dev_kfree_skb_irq(skb); - return STATUS_FAILURE; - } + if (fConvertedPacket == false) { + pContext->in_use = false; + dev_kfree_skb_irq(skb); + return STATUS_FAILURE; + } if ( pDevice->bEnablePSMode == true ) { if ( !pDevice->bPSModeTxBurst ) { @@ -2436,9 +2436,9 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, struct sk_buff *skb) pTX_Buffer->byPKTNO = (u8) (((pDevice->wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); pTX_Buffer->tx_byte_count = cpu_to_le16((u16)BytesToWrite); - pContext->pPacket = skb; - pContext->type = CONTEXT_DATA_PACKET; - pContext->uBufLen = (u16)BytesToWrite + 4 ; //USB header + pContext->skb = skb; + pContext->type = CONTEXT_DATA_PACKET; + pContext->buf_len = (u16)BytesToWrite + 4 ; /* USB header */ s_vSaveTxPktInfo(pDevice, (u8)(pTX_Buffer->byPKTNO & 0x0F), &pDevice->sTxEthHeader.h_dest[0], @@ -2453,14 +2453,14 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, struct sk_buff *skb) bScheduleCommand((void *) pDevice, WLAN_CMD_DEAUTH, (u8 *) &wReason); } - if(status!=STATUS_PENDING) { - pContext->bBoolInUse = false; - dev_kfree_skb_irq(skb); - return STATUS_FAILURE; - } - else - return 0; + if (status != STATUS_PENDING) { + pContext->in_use = false; + dev_kfree_skb_irq(skb); + return STATUS_FAILURE; + } + + return 0; } /* @@ -2531,7 +2531,7 @@ int bRelayPacketSend(struct vnt_private *pDevice, u8 *pbySkbData, u32 uDataLen, } if ( bNeedEncryption && (pTransmitKey == NULL) ) { - pContext->bBoolInUse = false; + pContext->in_use = false; return false; } @@ -2572,7 +2572,7 @@ int bRelayPacketSend(struct vnt_private *pDevice, u8 *pbySkbData, u32 uDataLen, // Convert the packet to an usb frame and copy into our buffer // and send the irp. - pTX_Buffer = (struct vnt_tx_buffer *)&pContext->Data[0]; + pTX_Buffer = (struct vnt_tx_buffer *)&pContext->data[0]; fConvertedPacket = s_bPacketToWirelessUsb(pDevice, byPktType, pTX_Buffer, bNeedEncryption, @@ -2583,16 +2583,16 @@ int bRelayPacketSend(struct vnt_private *pDevice, u8 *pbySkbData, u32 uDataLen, ); if (fConvertedPacket == false) { - pContext->bBoolInUse = false; + pContext->in_use = false; return false; } pTX_Buffer->byPKTNO = (u8) (((pDevice->wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); pTX_Buffer->tx_byte_count = cpu_to_le16((u16)BytesToWrite); - pContext->pPacket = NULL; - pContext->type = CONTEXT_DATA_PACKET; - pContext->uBufLen = (u16)BytesToWrite + 4 ; //USB header + pContext->skb = NULL; + pContext->type = CONTEXT_DATA_PACKET; + pContext->buf_len = (u16)BytesToWrite + 4; /* USB header */ s_vSaveTxPktInfo(pDevice, (u8)(pTX_Buffer->byPKTNO & 0x0F), &pDevice->sTxEthHeader.h_dest[0], diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index c5838d99f89f..1a6f91144ca0 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -530,17 +530,17 @@ int PIPEnsSendBulkOut(struct vnt_private *priv, DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_nsSendBulkOut\n"); if (!(MP_IS_READY(priv) && priv->Flags & fMP_POST_WRITES)) { - context->bBoolInUse = false; + context->in_use = false; return STATUS_RESOURCES; } - urb = context->pUrb; + urb = context->urb; usb_fill_bulk_urb(urb, priv->usb, usb_sndbulkpipe(priv->usb, 3), - context->Data, - context->uBufLen, + context->data, + context->buf_len, s_nsBulkOutIoCompleteWrite, context); @@ -548,7 +548,7 @@ int PIPEnsSendBulkOut(struct vnt_private *priv, if (status != 0) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Submit Tx URB failed %d\n", status); - context->bBoolInUse = false; + context->in_use = false; return STATUS_FAILURE; } @@ -586,7 +586,7 @@ int PIPEnsSendBulkOut(struct vnt_private *priv, static void s_nsBulkOutIoCompleteWrite(struct urb *urb) { struct vnt_usb_send_context *context = urb->context; - struct vnt_private *priv = context->pDevice; + struct vnt_private *priv = context->priv; u8 context_type = context->type; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkOutIoCompleteWrite\n"); @@ -594,12 +594,12 @@ static void s_nsBulkOutIoCompleteWrite(struct urb *urb) switch (urb->status) { case 0: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "Write %d bytes\n", context->uBufLen); + "Write %d bytes\n", context->buf_len); break; case -ECONNRESET: case -ENOENT: case -ESHUTDOWN: - context->bBoolInUse = false; + context->in_use = false; return; case -ETIMEDOUT: default: @@ -612,11 +612,11 @@ static void s_nsBulkOutIoCompleteWrite(struct urb *urb) return; if (CONTEXT_DATA_PACKET == context_type) { - if (context->pPacket != NULL) { - dev_kfree_skb_irq(context->pPacket); - context->pPacket = NULL; + if (context->skb != NULL) { + dev_kfree_skb_irq(context->skb); + context->skb = NULL; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "tx %d bytes\n", context->uBufLen); + "tx %d bytes\n", context->buf_len); } priv->dev->trans_start = jiffies; @@ -627,7 +627,7 @@ static void s_nsBulkOutIoCompleteWrite(struct urb *urb) netif_wake_queue(priv->dev); } - context->bBoolInUse = false; + context->in_use = false; return; } -- cgit v1.2.3 From 7af94000fecf67ebea144a2a0427bdb6a795f890 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Thu, 15 May 2014 22:49:12 +0100 Subject: staging: vt6656: lock changes: Remove spin locks. Remove atomic paths to usbpipe.c PIPEnsControlOut and PIPEnsControlIn Remove from PIPEnsControlOut PIPEnsControlIn BSSvSecondCallBack vt6656_hostap_ioctl iwctl_siwmode iwctl_siwencode iwctl_siwpower iwctl_siwencodeext KeyvInitTable device_init_registers device_open device_close Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/bssdb.c | 4 ---- drivers/staging/vt6656/firmware.c | 2 +- drivers/staging/vt6656/hostap.c | 4 ++-- drivers/staging/vt6656/iwctl.c | 15 --------------- drivers/staging/vt6656/key.c | 3 --- drivers/staging/vt6656/main_usb.c | 27 ++++----------------------- drivers/staging/vt6656/usbpipe.c | 6 ------ 7 files changed, 7 insertions(+), 54 deletions(-) diff --git a/drivers/staging/vt6656/bssdb.c b/drivers/staging/vt6656/bssdb.c index 9c78dab95d35..b018955a2f9c 100644 --- a/drivers/staging/vt6656/bssdb.c +++ b/drivers/staging/vt6656/bssdb.c @@ -818,8 +818,6 @@ void BSSvSecondCallBack(struct work_struct *work) if (pDevice->Flags & fMP_DISCONNECTED) return; - spin_lock_irq(&pDevice->lock); - pDevice->uAssocCount = 0; /* Power Saving Mode Tx Burst */ @@ -1158,8 +1156,6 @@ void BSSvSecondCallBack(struct work_struct *work) netif_wake_queue(pDevice->dev); } - spin_unlock_irq(&pDevice->lock); - schedule_delayed_work(&pDevice->second_callback_work, HZ); } diff --git a/drivers/staging/vt6656/firmware.c b/drivers/staging/vt6656/firmware.c index afb79c66a933..7a4a97298a79 100644 --- a/drivers/staging/vt6656/firmware.c +++ b/drivers/staging/vt6656/firmware.c @@ -44,7 +44,7 @@ static int msglevel = MSG_LEVEL_INFO; #define FIRMWARE_CHUNK_SIZE 0x400 -int FIRMWAREbDownload(struct vnt_private *pDevice) __must_hold(&pDevice->lock) +int FIRMWAREbDownload(struct vnt_private *pDevice) { struct device *dev = &pDevice->usb->dev; const struct firmware *fw; diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c index a0d9fffb3787..2a5b7c82b245 100644 --- a/drivers/staging/vt6656/hostap.c +++ b/drivers/staging/vt6656/hostap.c @@ -698,9 +698,9 @@ int vt6656_hostap_ioctl(struct vnt_private *pDevice, struct iw_point *p) switch (param->cmd) { case VIAWGET_HOSTAPD_SET_ENCRYPTION: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SET_ENCRYPTION \n"); - spin_lock_irq(&pDevice->lock); + ret = hostap_set_encryption(pDevice, param, p->length); - spin_unlock_irq(&pDevice->lock); + break; case VIAWGET_HOSTAPD_GET_ENCRYPTION: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_GET_ENCRYPTION \n"); diff --git a/drivers/staging/vt6656/iwctl.c b/drivers/staging/vt6656/iwctl.c index cf4c06a42880..bfd5f371e4ad 100644 --- a/drivers/staging/vt6656/iwctl.c +++ b/drivers/staging/vt6656/iwctl.c @@ -441,8 +441,6 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info, DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Commit the settings\n"); - spin_lock_irq(&pDevice->lock); - if (pDevice->bLinkPass && memcmp(pMgmt->abyCurrSSID, pMgmt->abyDesireSSID, @@ -471,8 +469,6 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info, bScheduleCommand((void *) pDevice, WLAN_CMD_SSID, NULL); - - spin_unlock_irq(&pDevice->lock); } pDevice->bCommit = false; } @@ -1212,14 +1208,12 @@ int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info, DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pDevice->abyKey[ii]); if (pDevice->flags & DEVICE_FLAGS_OPENED) { - spin_lock_irq(&pDevice->lock); KeybSetDefaultKey(pDevice, &(pDevice->sKey), dwKeyIndex | (1 << 31), wrq->length, NULL, pDevice->abyKey, KEY_CTL_WEP); - spin_unlock_irq(&pDevice->lock); } pDevice->byKeyIndex = (u8)dwKeyIndex; pDevice->uKeyLength = wrq->length; @@ -1242,10 +1236,8 @@ int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info, pDevice->bEncryptionEnable = false; pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; if (pDevice->flags & DEVICE_FLAGS_OPENED) { - spin_lock_irq(&pDevice->lock); for (uu = 0; uu < MAX_KEY_TABLE; uu++) MACvDisableKeyEntry(pDevice, uu); - spin_unlock_irq(&pDevice->lock); } } if (wrq->flags & IW_ENCODE_RESTRICTED) { @@ -1342,12 +1334,9 @@ int iwctl_siwpower(struct net_device *dev, struct iw_request_info *info, return rc; } - spin_lock_irq(&pDevice->lock); - if (wrq->disabled) { pDevice->ePSMode = WMAC_POWER_CAM; PSvDisablePowerSaving(pDevice); - spin_unlock_irq(&pDevice->lock); return rc; } if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) { @@ -1359,8 +1348,6 @@ int iwctl_siwpower(struct net_device *dev, struct iw_request_info *info, PSvEnablePowerSaving((void *)pDevice, pMgmt->wListenInterval); } - spin_unlock_irq(&pDevice->lock); - switch (wrq->flags & IW_POWER_MODE) { case IW_POWER_UNICAST_R: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_UNICAST_R\n"); @@ -1723,9 +1710,7 @@ int iwctl_siwencodeext(struct net_device *dev, struct iw_request_info *info, KeyvInitTable(pDevice, &pDevice->sKey); } /*******/ - spin_lock_irq(&pDevice->lock); ret = wpa_set_keys(pDevice, param); - spin_unlock_irq(&pDevice->lock); error: kfree(buf); diff --git a/drivers/staging/vt6656/key.c b/drivers/staging/vt6656/key.c index be92c048a12e..b173ca154024 100644 --- a/drivers/staging/vt6656/key.c +++ b/drivers/staging/vt6656/key.c @@ -97,7 +97,6 @@ void KeyvInitTable(struct vnt_private *pDevice, PSKeyManagement pTable) int i, jj; u8 pbyData[MAX_KEY_TABLE+1]; - spin_lock_irq(&pDevice->lock); for (i=0;iKeyTable[i].bInUse = false; pTable->KeyTable[i].PairwiseKey.bKeyValid = false; @@ -122,8 +121,6 @@ void KeyvInitTable(struct vnt_private *pDevice, PSKeyManagement pTable) pbyData ); - spin_unlock_irq(&pDevice->lock); - return; } diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index ea0d6b3361fd..e99d2a9378a5 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -312,22 +312,15 @@ static int device_init_registers(struct vnt_private *pDevice) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "---->INIbInitAdapter. [%d][%d]\n", DEVICE_INIT_COLD, pDevice->byPacketType); - spin_lock_irq(&pDevice->lock); - 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)) { - - spin_unlock_irq(&pDevice->lock); if (FIRMWAREbDownload(pDevice) == true) { - - spin_lock_irq(&pDevice->lock); if (FIRMWAREbBrach2Sram(pDevice) == false) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " FIRMWAREbBrach2Sram fail\n"); - spin_unlock_irq(&pDevice->lock); return false; } } else { @@ -339,7 +332,6 @@ static int device_init_registers(struct vnt_private *pDevice) if (!BBbVT3184Init(pDevice)) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" BBbVT3184Init fail\n"); - spin_unlock_irq(&pDevice->lock); return false; } @@ -356,7 +348,6 @@ static int device_init_registers(struct vnt_private *pDevice) sizeof(struct vnt_cmd_card_init), (u8 *)init_cmd); if (ntStatus != STATUS_SUCCESS) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Issue Card init fail\n"); - spin_unlock_irq(&pDevice->lock); return false; } @@ -365,7 +356,6 @@ static int device_init_registers(struct vnt_private *pDevice) if (ntStatus != STATUS_SUCCESS) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Cardinit request in status fail!\n"); - spin_unlock_irq(&pDevice->lock); return false; } @@ -373,10 +363,8 @@ static int device_init_registers(struct vnt_private *pDevice) ntStatus = CONTROLnsRequestIn(pDevice, MESSAGE_TYPE_READ, MAC_REG_LOCALID, MESSAGE_REQUEST_MACREG, 1, &pDevice->byLocalID); - if (ntStatus != STATUS_SUCCESS) { - spin_unlock_irq(&pDevice->lock); + if (ntStatus != STATUS_SUCCESS) return false; - } /* do MACbSoftwareReset in MACvInitialize */ @@ -607,10 +595,8 @@ static int device_init_registers(struct vnt_private *pDevice) ntStatus = CONTROLnsRequestIn(pDevice, MESSAGE_TYPE_READ, MAC_REG_GPIOCTL1, MESSAGE_REQUEST_MACREG, 1, &byTmp); - if (ntStatus != STATUS_SUCCESS) { - spin_unlock_irq(&pDevice->lock); + if (ntStatus != STATUS_SUCCESS) return false; - } if ((byTmp & GPIO3_DATA) == 0) { pDevice->bHWRadioOff = true; @@ -637,9 +623,6 @@ static int device_init_registers(struct vnt_private *pDevice) CARDbRadioPowerOn(pDevice); } - - spin_unlock_irq(&pDevice->lock); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"<----INIbInitAdapter Exit\n"); return true; @@ -1028,7 +1011,6 @@ static int device_open(struct net_device *dev) /* if WEP key already set by iwconfig but device not yet open */ if ((pDevice->bEncryptionEnable == true) && (pDevice->bTransmitKey == true)) { - spin_lock_irq(&pDevice->lock); KeybSetDefaultKey( pDevice, &(pDevice->sKey), pDevice->byKeyIndex | (1 << 31), @@ -1037,7 +1019,7 @@ static int device_open(struct net_device *dev) pDevice->abyKey, KEY_CTL_WEP ); - spin_unlock_irq(&pDevice->lock); + pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; } @@ -1084,10 +1066,9 @@ static int device_close(struct net_device *dev) pMgmt->bShareKeyAlgorithm = false; pDevice->bEncryptionEnable = false; pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; - spin_lock_irq(&pDevice->lock); + for (uu = 0; uu < MAX_KEY_TABLE; uu++) MACvDisableKeyEntry(pDevice,uu); - spin_unlock_irq(&pDevice->lock); if ((pDevice->flags & DEVICE_FLAGS_UNPLUG) == false) { MACbShutdown(pDevice); diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 1a6f91144ca0..836da00bfaac 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -146,7 +146,6 @@ int PIPEnsControlOut(struct vnt_private *pDevice, u8 byRequest, u16 wValue, return STATUS_FAILURE; } - spin_unlock_irq(&pDevice->lock); for (ii = 0; ii <= USB_CTL_WAIT; ii ++) { if (pDevice->Flags & fMP_CONTROL_WRITES) @@ -157,12 +156,10 @@ int PIPEnsControlOut(struct vnt_private *pDevice, u8 byRequest, u16 wValue, if (ii >= USB_CTL_WAIT) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "control send request submission timeout\n"); - spin_lock_irq(&pDevice->lock); MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES); return STATUS_FAILURE; } } - spin_lock_irq(&pDevice->lock); return STATUS_SUCCESS; } @@ -208,7 +205,6 @@ int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue, return STATUS_FAILURE; } - spin_unlock_irq(&pDevice->lock); for (ii = 0; ii <= USB_CTL_WAIT; ii ++) { if (pDevice->Flags & fMP_CONTROL_READS) @@ -219,12 +215,10 @@ int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue, if (ii >= USB_CTL_WAIT) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "control rcv request submission timeout\n"); - spin_lock_irq(&pDevice->lock); MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS); return STATUS_FAILURE; } } - spin_lock_irq(&pDevice->lock); return ntStatus; } -- cgit v1.2.3 From d1d4120f7fab69b32d40780b766109d377d743a7 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Thu, 15 May 2014 22:49:13 +0100 Subject: staging: vt6656: lock changes: vRunCommand remove locks. Removing atomic locked paths to usbpipe.c PIPEnsControlOut and PIPEnsControlIn This function will nolonger need any locking. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/wcmd.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c index de7e80897abe..d51cc90047f6 100644 --- a/drivers/staging/vt6656/wcmd.c +++ b/drivers/staging/vt6656/wcmd.c @@ -286,8 +286,6 @@ void vRunCommand(struct work_struct *work) if (pDevice->bCmdRunning != true) return; - spin_lock_irq(&pDevice->lock); - switch (pDevice->eCommandState) { case WLAN_CMD_SCAN_START: @@ -365,11 +363,9 @@ void vRunCommand(struct work_struct *work) if ((pMgmt->b11hEnable == false) || (pMgmt->uScanChannel < CB_MAX_CHANNEL_24G)) { s_vProbeChannel(pDevice); - spin_unlock_irq(&pDevice->lock); vCommandTimerWait((void *) pDevice, 100); return; } else { - spin_unlock_irq(&pDevice->lock); vCommandTimerWait((void *) pDevice, WCMD_PASSIVE_SCAN_TIME); return; } @@ -504,7 +500,6 @@ void vRunCommand(struct work_struct *work) pDevice->byLinkWaitCount = 0; pDevice->eCommandState = WLAN_AUTHENTICATE_WAIT; vCommandTimerWait((void *) pDevice, AUTHENTICATE_TIMEOUT); - spin_unlock_irq(&pDevice->lock); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Set eCommandState = WLAN_AUTHENTICATE_WAIT\n"); return; } @@ -578,7 +573,6 @@ void vRunCommand(struct work_struct *work) pDevice->byLinkWaitCount = 0; pDevice->eCommandState = WLAN_ASSOCIATE_WAIT; vCommandTimerWait((void *) pDevice, ASSOCIATE_TIMEOUT); - spin_unlock_irq(&pDevice->lock); return; } } else if (pMgmt->eCurrState < WMAC_STATE_AUTHPENDING) { @@ -587,7 +581,6 @@ void vRunCommand(struct work_struct *work) //mike add:wait another 2 sec if authenticated_frame delay! pDevice->byLinkWaitCount++; printk("WLAN_AUTHENTICATE_WAIT:wait %d times!!\n", pDevice->byLinkWaitCount); - spin_unlock_irq(&pDevice->lock); vCommandTimerWait((void *) pDevice, AUTHENTICATE_TIMEOUT/2); return; } @@ -622,7 +615,6 @@ void vRunCommand(struct work_struct *work) //mike add:wait another 2 sec if associated_frame delay! pDevice->byLinkWaitCount++; printk("WLAN_ASSOCIATE_WAIT:wait %d times!!\n", pDevice->byLinkWaitCount); - spin_unlock_irq(&pDevice->lock); vCommandTimerWait((void *) pDevice, ASSOCIATE_TIMEOUT/2); return; } @@ -752,9 +744,9 @@ void vRunCommand(struct work_struct *work) pDevice->byKeyIndex = 0; pDevice->bTransmitKey = false; - spin_unlock_irq(&pDevice->lock); + KeyvInitTable(pDevice, &pDevice->sKey); - spin_lock_irq(&pDevice->lock); + pMgmt->byCSSPK = KEY_CTL_NONE; pMgmt->byCSSGK = KEY_CTL_NONE; @@ -882,7 +874,6 @@ void vRunCommand(struct work_struct *work) s_bCommandComplete(pDevice); - spin_unlock_irq(&pDevice->lock); return; } -- cgit v1.2.3 From e03ce8393e41ddff574c95ac72378ed1f02cef54 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Thu, 15 May 2014 22:49:14 +0100 Subject: staging: vt6656: lock changes: RXvMngWorkItem. Narrow atomic locks in RXvMngWorkItem. We must lock the DequeueRCB and RXvFreeRCB so that they are in sync. vMgrRxManagePacket can nolonger be atomically called. There is no need for an overall lock. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/dpc.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c index 4ccaa7e29a1c..156399d93540 100644 --- a/drivers/staging/vt6656/dpc.c +++ b/drivers/staging/vt6656/dpc.c @@ -1363,34 +1363,43 @@ void RXvMngWorkItem(struct work_struct *work) struct vnt_rcb *pRCB = NULL; struct vnt_rx_mgmt *pRxPacket; int bReAllocSkb = false; + unsigned long flags; if (pDevice->Flags & fMP_DISCONNECTED) return; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Rx Mng Thread\n"); - spin_lock_irq(&pDevice->lock); while (pDevice->NumRecvMngList!=0) { + spin_lock_irqsave(&pDevice->lock, flags); + pRCB = pDevice->FirstRecvMngList; pDevice->NumRecvMngList--; DequeueRCB(pDevice->FirstRecvMngList, pDevice->LastRecvMngList); + + spin_unlock_irqrestore(&pDevice->lock, flags); + if(!pRCB){ break; } pRxPacket = &(pRCB->sMngPacket); vMgrRxManagePacket(pDevice, &pDevice->vnt_mgmt, pRxPacket); pRCB->Ref--; - if(pRCB->Ref == 0) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RxvFreeMng %d %d\n",pDevice->NumRecvFreeList, pDevice->NumRecvMngList); - RXvFreeRCB(pRCB, bReAllocSkb); - } else { + if (pRCB->Ref == 0) { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RxvFreeMng %d %d\n", + pDevice->NumRecvFreeList, pDevice->NumRecvMngList); + + spin_lock_irqsave(&pDevice->lock, flags); + + RXvFreeRCB(pRCB, bReAllocSkb); + + spin_unlock_irqrestore(&pDevice->lock, flags); + } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Rx Mng Only we have the right to free RCB\n"); } } pDevice->bIsRxMngWorkItemQueued = false; - spin_unlock_irq(&pDevice->lock); - } -- cgit v1.2.3 From 931cb9ff6eefb5c0e92c1b170ba68f5453aab32f Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Thu, 15 May 2014 22:49:15 +0100 Subject: staging: vt6656: lock changes: csMgmt_xmit. csMgmt_xmit is nolonger atomically called but part of must be. Reorder the function so that RFbSetPower is called first. Add new lock spinlock for the remainder of the function. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 50 +++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 52be7b0d98bb..c6ac263a7cb9 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -1383,13 +1383,32 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, u16 wTxBufSize; u32 cbMacHdLen; u16 wCurrentRate = RATE_1M; + unsigned long flags; - pContext = s_vGetFreeContext(pDevice); + if (pDevice->byBBType == BB_TYPE_11A) { + wCurrentRate = RATE_6M; + byPktType = PK_TYPE_11A; + } else { + wCurrentRate = RATE_1M; + byPktType = PK_TYPE_11B; + } - if (NULL == pContext) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ManagementSend TX...NO CONTEXT!\n"); - return CMD_STATUS_RESOURCES; - } + if (pMgmt->eScanState != WMAC_NO_SCANNING) + RFbSetPower(pDevice, wCurrentRate, pDevice->byCurrentCh); + else + RFbSetPower(pDevice, wCurrentRate, pMgmt->uCurrChannel); + + pDevice->wCurrentRate = wCurrentRate; + + spin_lock_irqsave(&pDevice->lock, flags); + + pContext = s_vGetFreeContext(pDevice); + if (!pContext) { + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + "ManagementSend TX...NO CONTEXT!\n"); + spin_unlock_irqrestore(&pDevice->lock, flags); + return CMD_STATUS_RESOURCES; + } pTX_Buffer = (struct vnt_tx_buffer *)&pContext->data[0]; cbFrameBodySize = pPacket->cbPayloadLen; @@ -1397,24 +1416,6 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, pbyTxBufferAddr = (u8 *)&pTxBufHead->adwTxKey[0]; wTxBufSize = sizeof(struct vnt_tx_fifo_head); - if (pDevice->byBBType == BB_TYPE_11A) { - wCurrentRate = RATE_6M; - byPktType = PK_TYPE_11A; - } else { - wCurrentRate = RATE_1M; - byPktType = PK_TYPE_11B; - } - - // SetPower will cause error power TX state for OFDM Date packet in TX buffer. - // 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability. - // And cmd timer will wait data pkt TX finish before scanning so it's OK - // to set power here. - if (pMgmt->eScanState != WMAC_NO_SCANNING) { - RFbSetPower(pDevice, wCurrentRate, pDevice->byCurrentCh); - } else { - RFbSetPower(pDevice, wCurrentRate, pMgmt->uCurrChannel); - } - pDevice->wCurrentRate = wCurrentRate; //Set packet type if (byPktType == PK_TYPE_11A) {//0000 0000 0000 0000 @@ -1625,6 +1626,9 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, } PIPEnsSendBulkOut(pDevice,pContext); + + spin_unlock_irqrestore(&pDevice->lock, flags); + return CMD_STATUS_PENDING; } -- cgit v1.2.3 From 3bc552a1a0757d97cdbb04227536c101848b6a94 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Thu, 15 May 2014 22:49:16 +0100 Subject: staging: vt6656: lock changes: vDMA0_tx_80211 vDMA0_tx_80211 is atomically called. RFbSetPower can not be called atomically. If wCurrentRate is different to pDevice->wCurrentRate call bScheduleCommand WLAN_CMD_SETPOWER. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index c6ac263a7cb9..7287467c3aff 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -1781,11 +1781,11 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) // 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability. // And cmd timer will wait data pkt TX finish before scanning so it's OK // to set power here. - if (pMgmt->eScanState != WMAC_NO_SCANNING) { - RFbSetPower(pDevice, wCurrentRate, pDevice->byCurrentCh); - } else { - RFbSetPower(pDevice, wCurrentRate, pMgmt->uCurrChannel); - } + if (wCurrentRate != pDevice->wCurrentRate) { + pDevice->wCurrentRate = wCurrentRate; + + bScheduleCommand(pDevice, WLAN_CMD_SETPOWER, NULL); + } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"vDMA0_tx_80211: p80211Header->sA3.wFrameCtl = %x \n", p80211Header->sA3.wFrameCtl); -- cgit v1.2.3 From 8783a1a4afa4e14cf134afc7838b23fcd745b996 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Thu, 15 May 2014 22:49:17 +0100 Subject: staging: vt6656: lock changes: bMgrPrepareBeaconToSend add lock. bMgrPrepareBeaconToSend is nolonger atomic csBeacon_xmit must be locked add spin lock. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/wmgr.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vt6656/wmgr.c b/drivers/staging/vt6656/wmgr.c index 0d69719a7426..cce67cdad26a 100644 --- a/drivers/staging/vt6656/wmgr.c +++ b/drivers/staging/vt6656/wmgr.c @@ -4058,6 +4058,7 @@ int bMgrPrepareBeaconToSend(struct vnt_private *pDevice, struct vnt_manager *pMgmt) { struct vnt_tx_mgmt *pTxPacket; + unsigned long flags; // pDevice->bBeaconBufReady = false; if (pDevice->bEncryptionEnable || pDevice->bEnable8021x){ @@ -4084,8 +4085,13 @@ int bMgrPrepareBeaconToSend(struct vnt_private *pDevice, (pMgmt->abyCurrBSSID[0] == 0)) return false; - csBeacon_xmit(pDevice, pTxPacket); - MACvRegBitsOn(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX); + spin_lock_irqsave(&pDevice->lock, flags); + + csBeacon_xmit(pDevice, pTxPacket); + + spin_unlock_irqrestore(&pDevice->lock, flags); + + MACvRegBitsOn(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX); return true; } -- cgit v1.2.3 From 97641ca2b284ddc9870afdcfe22487702ee27b3e Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Thu, 15 May 2014 22:49:18 +0100 Subject: staging: vt6656: lock changes: vRunCommand nsDMA_tx_packet vRunCommand is nolonger atomic add lock for nsDMA_tx_packet. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/wcmd.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c index d51cc90047f6..66d59d51bf82 100644 --- a/drivers/staging/vt6656/wcmd.c +++ b/drivers/staging/vt6656/wcmd.c @@ -279,6 +279,7 @@ void vRunCommand(struct work_struct *work) int ii; u8 byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; u8 byData; + unsigned long flags; if (pDevice->Flags & fMP_DISCONNECTED) return; @@ -667,9 +668,13 @@ void vRunCommand(struct work_struct *work) pDevice->bMoreData = true; } + spin_lock_irqsave(&pDevice->lock, flags); + if (nsDMA_tx_packet(pDevice, skb) != 0) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Multicast ps tx fail\n"); + spin_unlock_irqrestore(&pDevice->lock, flags); + pMgmt->sNodeDBTable[0].wEnQueueCnt--; } } @@ -690,9 +695,13 @@ void vRunCommand(struct work_struct *work) pDevice->bMoreData = true; } + spin_lock_irqsave(&pDevice->lock, flags); + if (nsDMA_tx_packet(pDevice, skb) != 0) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "sta ps tx fail\n"); + spin_unlock_irqrestore(&pDevice->lock, flags); + pMgmt->sNodeDBTable[ii].wEnQueueCnt--; // check if sta ps enable, wait next pspoll // if sta ps disable, send all pending buffers. -- cgit v1.2.3 From c91b1869fb6f6d58f6321b8a88bd39577b0413a7 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Thu, 15 May 2014 22:49:19 +0100 Subject: staging: vt6656: lock changes: usbpipe.c add mutex lock. PIPEnsControlOut and PIPEnsControlIn are nolonger atomic but they do need a usb lock. Add new mutex lock for these functions and PIPEnsControlOutAsyn. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/device.h | 1 + drivers/staging/vt6656/main_usb.c | 2 ++ drivers/staging/vt6656/usbpipe.c | 16 ++++++++++++++++ 3 files changed, 19 insertions(+) diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index f36a2eb826b7..622cf02f5c8a 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -363,6 +363,7 @@ struct vnt_private { u8 byRxMode; spinlock_t lock; + struct mutex usb_lock; u32 rx_bytes; diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index e99d2a9378a5..14e649a66beb 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -695,6 +695,8 @@ vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id) device_set_options(pDevice); spin_lock_init(&pDevice->lock); + mutex_init(&pDevice->usb_lock); + INIT_DELAYED_WORK(&pDevice->run_command_work, vRunCommand); INIT_DELAYED_WORK(&pDevice->second_callback_work, BSSvSecondCallBack); INIT_WORK(&pDevice->read_work_item, RXvWorkItem); diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 836da00bfaac..934d0a92363b 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -82,6 +82,8 @@ int PIPEnsControlOutAsyn(struct vnt_private *pDevice, u8 byRequest, return STATUS_FAILURE; } + mutex_lock(&pDevice->usb_lock); + ntStatus = usb_control_msg( pDevice->usb, usb_sndctrlpipe(pDevice->usb , 0), @@ -100,6 +102,8 @@ int PIPEnsControlOutAsyn(struct vnt_private *pDevice, u8 byRequest, DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"usb_sndctrlpipe fail, ntStatus= %d\n", ntStatus); } + mutex_unlock(&pDevice->usb_lock); + return ntStatus; } @@ -123,6 +127,8 @@ int PIPEnsControlOut(struct vnt_private *pDevice, u8 byRequest, u16 wValue, if (pDevice->pControlURB->hcpriv) return STATUS_FAILURE; + mutex_lock(&pDevice->usb_lock); + MP_SET_FLAG(pDevice, fMP_CONTROL_WRITES); pDevice->sUsbCtlRequest.bRequestType = 0x40; @@ -143,6 +149,7 @@ int PIPEnsControlOut(struct vnt_private *pDevice, u8 byRequest, u16 wValue, "control send request submission failed: %d\n", ntStatus); MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES); + mutex_unlock(&pDevice->usb_lock); return STATUS_FAILURE; } @@ -157,10 +164,13 @@ int PIPEnsControlOut(struct vnt_private *pDevice, u8 byRequest, u16 wValue, DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "control send request submission timeout\n"); MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES); + mutex_unlock(&pDevice->usb_lock); return STATUS_FAILURE; } } + mutex_unlock(&pDevice->usb_lock); + return STATUS_SUCCESS; } @@ -184,6 +194,8 @@ int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue, if (pDevice->pControlURB->hcpriv) return STATUS_FAILURE; + mutex_lock(&pDevice->usb_lock); + MP_SET_FLAG(pDevice, fMP_CONTROL_READS); pDevice->sUsbCtlRequest.bRequestType = 0xC0; @@ -202,6 +214,7 @@ int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue, DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "control request submission failed: %d\n", ntStatus); MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS); + mutex_unlock(&pDevice->usb_lock); return STATUS_FAILURE; } @@ -216,10 +229,13 @@ int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue, DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "control rcv request submission timeout\n"); MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS); + mutex_unlock(&pDevice->usb_lock); return STATUS_FAILURE; } } + mutex_unlock(&pDevice->usb_lock); + return ntStatus; } -- cgit v1.2.3 From 29b02373f44d0d873a4f645b53c3cddce2f40f7b Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Thu, 15 May 2014 22:49:20 +0100 Subject: staging: vt6656: lock changes: s_nsBulkInUsbIoCompleteRead. Use spin_lock_irqsave/spin_unlock_irqrestore Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/usbpipe.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 934d0a92363b..b707470143af 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -474,6 +474,7 @@ static void s_nsBulkInUsbIoCompleteRead(struct urb *urb) { struct vnt_rcb *rcb = urb->context; struct vnt_private *priv = rcb->pDevice; + unsigned long flags; int re_alloc_skb = false; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkInUsbIoCompleteRead\n"); @@ -493,23 +494,23 @@ static void s_nsBulkInUsbIoCompleteRead(struct urb *urb) } if (urb->actual_length) { - spin_lock(&priv->lock); + spin_lock_irqsave(&priv->lock, flags); if (RXbBulkInProcessData(priv, rcb, urb->actual_length) == true) re_alloc_skb = true; - spin_unlock(&priv->lock); + spin_unlock_irqrestore(&priv->lock, flags); } rcb->Ref--; if (rcb->Ref == 0) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RxvFreeNormal %d\n", priv->NumRecvFreeList); - spin_lock(&priv->lock); + spin_lock_irqsave(&priv->lock, flags); RXvFreeRCB(rcb, re_alloc_skb); - spin_unlock(&priv->lock); + spin_unlock_irqrestore(&priv->lock, flags); } return; -- cgit v1.2.3 From 3c647642f6658c693d090b12c1b5bf901f3b7440 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Thu, 15 May 2014 22:49:21 +0100 Subject: staging: vt6656: lock changes device_xmit Replace locks with the spin_lock_irqsave and spin_unlock_irqrestore Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/main_usb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 14e649a66beb..462f95ddd979 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -1159,8 +1159,9 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev) { struct vnt_private *pDevice = netdev_priv(dev); struct net_device_stats *stats = &pDevice->stats; + unsigned long flags; - spin_lock_irq(&pDevice->lock); + spin_lock_irqsave(&pDevice->lock, flags); netif_stop_queue(dev); @@ -1181,7 +1182,7 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev) } out: - spin_unlock_irq(&pDevice->lock); + spin_unlock_irqrestore(&pDevice->lock, flags); return NETDEV_TX_OK; } -- cgit v1.2.3 From 7021b684eb1efa9a349785f919e177c1b63af313 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Thu, 15 May 2014 22:49:22 +0100 Subject: staging: vt6656: usbpipe.c PIPEnsControlOut use usb_control_msg Now that this fucntion is nolonger atomic change to usb_control_msg Return STATUS_FAILURE if ntStatus less than wLength. Remove fMP_CONTROL_WRITES flag Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/device.h | 1 - drivers/staging/vt6656/main_usb.c | 1 - drivers/staging/vt6656/usbpipe.c | 87 ++++----------------------------------- 3 files changed, 7 insertions(+), 82 deletions(-) diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index 622cf02f5c8a..da1b70d2795d 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -744,7 +744,6 @@ struct vnt_private { #define fMP_POST_READS 0x00000100 #define fMP_POST_WRITES 0x00000200 #define fMP_CONTROL_READS 0x00000400 -#define fMP_CONTROL_WRITES 0x00000800 #define MP_SET_FLAG(_M, _F) ((_M)->Flags |= (_F)) #define MP_CLEAR_FLAG(_M, _F) ((_M)->Flags &= ~(_F)) diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 462f95ddd979..6ca5d783fc34 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -965,7 +965,6 @@ static int device_open(struct net_device *dev) MP_CLEAR_FLAG(pDevice, fMP_DISCONNECTED); MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS); - MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES); MP_SET_FLAG(pDevice, fMP_POST_READS); MP_SET_FLAG(pDevice, fMP_POST_WRITES); diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index b707470143af..1ab39587ed87 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -64,7 +64,6 @@ static void s_nsInterruptUsbIoCompleteRead(struct urb *urb); static void s_nsBulkInUsbIoCompleteRead(struct urb *urb); static void s_nsBulkOutIoCompleteWrite(struct urb *urb); static void s_nsControlInUsbIoCompleteRead(struct urb *urb); -static void s_nsControlInUsbIoCompleteWrite(struct urb *urb); int PIPEnsControlOutAsyn(struct vnt_private *pDevice, u8 byRequest, u16 wValue, u16 wIndex, u16 wLength, u8 *pbyBuffer) @@ -74,9 +73,6 @@ int PIPEnsControlOutAsyn(struct vnt_private *pDevice, u8 byRequest, if (pDevice->Flags & fMP_DISCONNECTED) return STATUS_FAILURE; - if (pDevice->Flags & fMP_CONTROL_WRITES) - return STATUS_FAILURE; - if (in_interrupt()) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"in_interrupt return ..byRequest %x\n", byRequest); return STATUS_FAILURE; @@ -109,69 +105,24 @@ int PIPEnsControlOutAsyn(struct vnt_private *pDevice, u8 byRequest, int PIPEnsControlOut(struct vnt_private *pDevice, u8 byRequest, u16 wValue, u16 wIndex, u16 wLength, u8 *pbyBuffer) - __releases(&pDevice->lock) - __acquires(&pDevice->lock) { int ntStatus = 0; - int ii; - - if (pDevice->Flags & fMP_DISCONNECTED) - return STATUS_FAILURE; - - if (pDevice->Flags & fMP_CONTROL_WRITES) - return STATUS_FAILURE; - if (pDevice->Flags & fMP_CONTROL_READS) - return STATUS_FAILURE; - - if (pDevice->pControlURB->hcpriv) + if (pDevice->Flags & fMP_DISCONNECTED) return STATUS_FAILURE; mutex_lock(&pDevice->usb_lock); - MP_SET_FLAG(pDevice, fMP_CONTROL_WRITES); + ntStatus = usb_control_msg(pDevice->usb, + usb_sndctrlpipe(pDevice->usb, 0), byRequest, 0x40, wValue, + wIndex, pbyBuffer, wLength, USB_CTL_WAIT); - pDevice->sUsbCtlRequest.bRequestType = 0x40; - pDevice->sUsbCtlRequest.bRequest = byRequest; - pDevice->sUsbCtlRequest.wValue = cpu_to_le16p(&wValue); - pDevice->sUsbCtlRequest.wIndex = cpu_to_le16p(&wIndex); - pDevice->sUsbCtlRequest.wLength = cpu_to_le16p(&wLength); - pDevice->pControlURB->transfer_flags |= URB_ASYNC_UNLINK; - pDevice->pControlURB->actual_length = 0; - // Notice, pbyBuffer limited point to variable buffer, can't be constant. - usb_fill_control_urb(pDevice->pControlURB, pDevice->usb, - usb_sndctrlpipe(pDevice->usb , 0), (char *) &pDevice->sUsbCtlRequest, - pbyBuffer, wLength, s_nsControlInUsbIoCompleteWrite, pDevice); + mutex_unlock(&pDevice->usb_lock); - 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); - MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES); - mutex_unlock(&pDevice->usb_lock); + if (ntStatus < (int)wLength) return STATUS_FAILURE; - } - - for (ii = 0; ii <= USB_CTL_WAIT; ii ++) { - - if (pDevice->Flags & fMP_CONTROL_WRITES) - mdelay(1); - else - break; - - if (ii >= USB_CTL_WAIT) { - DBG_PRT(MSG_LEVEL_DEBUG, - KERN_INFO "control send request submission timeout\n"); - MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES); - mutex_unlock(&pDevice->usb_lock); - return STATUS_FAILURE; - } - } - - mutex_unlock(&pDevice->usb_lock); - return STATUS_SUCCESS; + return STATUS_SUCCESS; } int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue, @@ -188,9 +139,6 @@ int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue, if (pDevice->Flags & fMP_CONTROL_READS) return STATUS_FAILURE; - if (pDevice->Flags & fMP_CONTROL_WRITES) - return STATUS_FAILURE; - if (pDevice->pControlURB->hcpriv) return STATUS_FAILURE; @@ -239,27 +187,6 @@ int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue, return ntStatus; } -static void s_nsControlInUsbIoCompleteWrite(struct urb *urb) -{ - struct vnt_private *pDevice = (struct vnt_private *)urb->context; - - pDevice = urb->context; - switch (urb->status) { - case 0: - break; - case -EINPROGRESS: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl write urb status EINPROGRESS%d\n", urb->status); - break; - case -ENOENT: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl write urb status ENOENT %d\n", urb->status); - break; - default: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl write urb status %d\n", urb->status); - } - - MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES); -} - /* * Description: * Complete function of usb Control callback -- cgit v1.2.3 From 0fb2af353f11ea939b29c8cf07ce70a3882824cc Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Thu, 15 May 2014 22:49:23 +0100 Subject: staging: vt6656: PIPEnsControlIn use usb_control_msg Now that this function is nolonger atomic useusb_control_msg. Return STATUS_FAILURE if ntStatus less than wLength Remove the old struct urb and struct usb_ctrlrequest structures. Remove fMP_CONTROL_READS flag. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/device.h | 3 -- drivers/staging/vt6656/main_usb.c | 11 ----- drivers/staging/vt6656/usbpipe.c | 94 ++++----------------------------------- 3 files changed, 9 insertions(+), 99 deletions(-) diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index da1b70d2795d..410e0288f90d 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -380,9 +380,7 @@ struct vnt_private { u32 uCurrentDFCBIdx; /* USB */ - struct urb *pControlURB; struct urb *pInterruptURB; - struct usb_ctrlrequest sUsbCtlRequest; u32 int_interval; /* Variables to track resources for the BULK In Pipe */ @@ -743,7 +741,6 @@ struct vnt_private { #define fMP_RECV_SIDE_RESOURCE_ALLOCATED 0x00000080 #define fMP_POST_READS 0x00000100 #define fMP_POST_WRITES 0x00000200 -#define fMP_CONTROL_READS 0x00000400 #define MP_SET_FLAG(_M, _F) ((_M)->Flags |= (_F)) #define MP_CLEAR_FLAG(_M, _F) ((_M)->Flags &= ~(_F)) diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 6ca5d783fc34..1b58ccaac1f6 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -702,12 +702,6 @@ vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id) INIT_WORK(&pDevice->read_work_item, RXvWorkItem); INIT_WORK(&pDevice->rx_mng_work_item, RXvMngWorkItem); - pDevice->pControlURB = usb_alloc_urb(0, GFP_ATOMIC); - if (!pDevice->pControlURB) { - DBG_PRT(MSG_LEVEL_ERR, KERN_ERR"Failed to alloc control urb\n"); - goto err_netdev; - } - pDevice->tx_80211 = device_dma0_tx_80211; pDevice->vnt_mgmt.pAdapter = (void *) pDevice; @@ -964,7 +958,6 @@ static int device_open(struct net_device *dev) } MP_CLEAR_FLAG(pDevice, fMP_DISCONNECTED); - MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS); MP_SET_FLAG(pDevice, fMP_POST_READS); MP_SET_FLAG(pDevice, fMP_POST_WRITES); @@ -1130,10 +1123,6 @@ static void vt6656_disconnect(struct usb_interface *intf) if (device->dev) { unregister_netdev(device->dev); - - usb_kill_urb(device->pControlURB); - usb_free_urb(device->pControlURB); - free_netdev(device->dev); } } diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 1ab39587ed87..9946bfd57fe4 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -63,7 +63,6 @@ static int msglevel =MSG_LEVEL_INFO; static void s_nsInterruptUsbIoCompleteRead(struct urb *urb); static void s_nsBulkInUsbIoCompleteRead(struct urb *urb); static void s_nsBulkOutIoCompleteWrite(struct urb *urb); -static void s_nsControlInUsbIoCompleteRead(struct urb *urb); int PIPEnsControlOutAsyn(struct vnt_private *pDevice, u8 byRequest, u16 wValue, u16 wIndex, u16 wLength, u8 *pbyBuffer) @@ -126,100 +125,25 @@ int PIPEnsControlOut(struct vnt_private *pDevice, u8 byRequest, u16 wValue, } int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue, - u16 wIndex, u16 wLength, u8 *pbyBuffer) - __releases(&pDevice->lock) - __acquires(&pDevice->lock) + u16 wIndex, u16 wLength, u8 *pbyBuffer) { - int ntStatus = 0; - int ii; - - if (pDevice->Flags & fMP_DISCONNECTED) - return STATUS_FAILURE; - - if (pDevice->Flags & fMP_CONTROL_READS) - return STATUS_FAILURE; + int ntStatus; - if (pDevice->pControlURB->hcpriv) + if (pDevice->Flags & fMP_DISCONNECTED) return STATUS_FAILURE; mutex_lock(&pDevice->usb_lock); - MP_SET_FLAG(pDevice, fMP_CONTROL_READS); - - pDevice->sUsbCtlRequest.bRequestType = 0xC0; - pDevice->sUsbCtlRequest.bRequest = byRequest; - pDevice->sUsbCtlRequest.wValue = cpu_to_le16p(&wValue); - pDevice->sUsbCtlRequest.wIndex = cpu_to_le16p(&wIndex); - pDevice->sUsbCtlRequest.wLength = cpu_to_le16p(&wLength); - pDevice->pControlURB->transfer_flags |= URB_ASYNC_UNLINK; - pDevice->pControlURB->actual_length = 0; - usb_fill_control_urb(pDevice->pControlURB, pDevice->usb, - usb_rcvctrlpipe(pDevice->usb , 0), (char *) &pDevice->sUsbCtlRequest, - pbyBuffer, wLength, s_nsControlInUsbIoCompleteRead, pDevice); - - 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); - MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS); - mutex_unlock(&pDevice->usb_lock); - return STATUS_FAILURE; - } - - for (ii = 0; ii <= USB_CTL_WAIT; ii ++) { - - if (pDevice->Flags & fMP_CONTROL_READS) - mdelay(1); - else - break; - - if (ii >= USB_CTL_WAIT) { - DBG_PRT(MSG_LEVEL_DEBUG, - KERN_INFO "control rcv request submission timeout\n"); - MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS); - mutex_unlock(&pDevice->usb_lock); - return STATUS_FAILURE; - } - } + ntStatus = usb_control_msg(pDevice->usb, + usb_rcvctrlpipe(pDevice->usb, 0), byRequest, 0xc0, wValue, + wIndex, pbyBuffer, wLength, USB_CTL_WAIT); mutex_unlock(&pDevice->usb_lock); - return ntStatus; -} - -/* - * Description: - * Complete function of usb Control callback - * - * Parameters: - * In: - * pDevice - Pointer to the adapter - * - * Out: - * none - * - * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver - * - */ - -static void s_nsControlInUsbIoCompleteRead(struct urb *urb) -{ - struct vnt_private *pDevice = (struct vnt_private *)urb->context; - - switch (urb->status) { - case 0: - break; - case -EINPROGRESS: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl read urb status EINPROGRESS%d\n", urb->status); - break; - case -ENOENT: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl read urb status = ENOENT %d\n", urb->status); - break; - default: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl read urb status %d\n", urb->status); - } + if (ntStatus < (int)wLength) + return STATUS_FAILURE; - MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS); + return STATUS_SUCCESS; } /* -- cgit v1.2.3 From 3136b5fee2be0c177b381b62aa5da8dd8eb3ef94 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Thu, 15 May 2014 22:49:24 +0100 Subject: staging: vt6656: Remove PIPEnsControlOutAsyn/CONTROLnsRequestOutAsyn This now the same as PIPEnsControlOut. Replace with PIPEnsControlOut/CONTROLnsRequestOut. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/control.h | 3 --- drivers/staging/vt6656/firmware.c | 2 +- drivers/staging/vt6656/mac.c | 2 +- drivers/staging/vt6656/usbpipe.c | 38 -------------------------------------- drivers/staging/vt6656/usbpipe.h | 2 -- 5 files changed, 2 insertions(+), 45 deletions(-) diff --git a/drivers/staging/vt6656/control.h b/drivers/staging/vt6656/control.h index 9da9b96add70..4658910ca4c1 100644 --- a/drivers/staging/vt6656/control.h +++ b/drivers/staging/vt6656/control.h @@ -36,9 +36,6 @@ #define CONTROLnsRequestOut(Device, Request, Value, Index, Length, Buffer) \ PIPEnsControlOut(Device, Request, Value, Index, Length, Buffer) -#define CONTROLnsRequestOutAsyn(Device, Request, Value, Index, Length, Buffer) \ - PIPEnsControlOutAsyn(Device, Request, Value, Index, Length, Buffer) - #define CONTROLnsRequestIn(Device, Request, Value, Index, Length, Buffer) \ PIPEnsControlIn(Device, Request, Value, Index, Length, Buffer) diff --git a/drivers/staging/vt6656/firmware.c b/drivers/staging/vt6656/firmware.c index 7a4a97298a79..e03f1f97b284 100644 --- a/drivers/staging/vt6656/firmware.c +++ b/drivers/staging/vt6656/firmware.c @@ -71,7 +71,7 @@ int FIRMWAREbDownload(struct vnt_private *pDevice) wLength = min_t(int, fw->size - ii, FIRMWARE_CHUNK_SIZE); memcpy(pBuffer, fw->data + ii, wLength); - NdisStatus = CONTROLnsRequestOutAsyn(pDevice, + NdisStatus = CONTROLnsRequestOut(pDevice, 0, 0x1200+ii, 0x0000, diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index 3ce19ddbc569..8bd3ab0407bf 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -75,7 +75,7 @@ void MACvWriteMultiAddr(struct vnt_private *pDevice, u64 mc_filter) */ void MACbShutdown(struct vnt_private *pDevice) { - CONTROLnsRequestOutAsyn(pDevice, + CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_MACSHUTDOWN, 0, 0, diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 9946bfd57fe4..433edcab5081 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -64,44 +64,6 @@ static void s_nsInterruptUsbIoCompleteRead(struct urb *urb); static void s_nsBulkInUsbIoCompleteRead(struct urb *urb); static void s_nsBulkOutIoCompleteWrite(struct urb *urb); -int PIPEnsControlOutAsyn(struct vnt_private *pDevice, u8 byRequest, - u16 wValue, u16 wIndex, u16 wLength, u8 *pbyBuffer) -{ - int ntStatus; - - if (pDevice->Flags & fMP_DISCONNECTED) - return STATUS_FAILURE; - - if (in_interrupt()) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"in_interrupt return ..byRequest %x\n", byRequest); - return STATUS_FAILURE; - } - - mutex_lock(&pDevice->usb_lock); - - ntStatus = usb_control_msg( - pDevice->usb, - usb_sndctrlpipe(pDevice->usb , 0), - byRequest, - 0x40, // RequestType - wValue, - wIndex, - (void *) pbyBuffer, - wLength, - HZ - ); - if (ntStatus >= 0) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"usb_sndctrlpipe ntStatus= %d\n", ntStatus); - ntStatus = 0; - } else { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"usb_sndctrlpipe fail, ntStatus= %d\n", ntStatus); - } - - mutex_unlock(&pDevice->usb_lock); - - return ntStatus; -} - int PIPEnsControlOut(struct vnt_private *pDevice, u8 byRequest, u16 wValue, u16 wIndex, u16 wLength, u8 *pbyBuffer) { diff --git a/drivers/staging/vt6656/usbpipe.h b/drivers/staging/vt6656/usbpipe.h index f53770329e75..42ad4f73243c 100644 --- a/drivers/staging/vt6656/usbpipe.h +++ b/drivers/staging/vt6656/usbpipe.h @@ -34,8 +34,6 @@ int PIPEnsControlOut(struct vnt_private *, u8 byRequest, u16 wValue, u16 wIndex, u16 wLength, u8 *pbyBuffer); -int PIPEnsControlOutAsyn(struct vnt_private *, u8 byRequest, - u16 wValue, u16 wIndex, u16 wLength, u8 *pbyBuffer); int PIPEnsControlIn(struct vnt_private *, u8 byRequest, u16 wValue, u16 wIndex, u16 wLength, u8 *pbyBuffer); -- cgit v1.2.3 From 2787b99fd62f01af33bea5a076b665e128c67177 Mon Sep 17 00:00:00 2001 From: Camille Bordignon Date: Sun, 6 Apr 2014 18:21:27 +0200 Subject: staging: sep: Fix coding style Fix coding style warning "Missing a blank line after declarations" Signed-off-by: Camille Bordignon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sep/sep_crypto.c | 10 ++++++++++ drivers/staging/sep/sep_dev.h | 1 + 2 files changed, 11 insertions(+) diff --git a/drivers/staging/sep/sep_crypto.c b/drivers/staging/sep/sep_crypto.c index 965485f71fe9..415f8ec5276b 100644 --- a/drivers/staging/sep/sep_crypto.c +++ b/drivers/staging/sep/sep_crypto.c @@ -93,6 +93,7 @@ static void sep_do_callback(struct work_struct *work) { struct sep_work_struct *sep_work = container_of(work, struct sep_work_struct, work); + if (sep_work != NULL) { (sep_work->callback)(sep_work->data); kfree(sep_work); @@ -649,6 +650,7 @@ weak: static u32 sep_sg_nents(struct scatterlist *sg) { u32 ct1 = 0; + while (sg) { ct1 += 1; sg = sg_next(sg); @@ -666,6 +668,7 @@ static u32 sep_sg_nents(struct scatterlist *sg) static u32 sep_start_msg(struct this_task_ctx *ta_ctx) { u32 *word_ptr; + ta_ctx->msg_len_words = 2; ta_ctx->msgptr = ta_ctx->msg; memset(ta_ctx->msg, 0, SEP_DRIVER_MESSAGE_SHARED_AREA_SIZE_IN_BYTES); @@ -740,6 +743,7 @@ static void sep_write_msg(struct this_task_ctx *ta_ctx, void *in_addr, { u32 *word_ptr; void *void_ptr; + void_ptr = ta_ctx->msgptr + *msg_offset; word_ptr = (u32 *)void_ptr; memcpy(void_ptr, in_addr, size); @@ -748,6 +752,7 @@ static void sep_write_msg(struct this_task_ctx *ta_ctx, void *in_addr, /* Do we need to manipulate endian? */ if (byte_array) { u32 i; + for (i = 0; i < ((size + 3) / 4); i += 1) *(word_ptr + i) = CHG_ENDIAN(*(word_ptr + i)); } @@ -788,12 +793,14 @@ static void sep_read_msg(struct this_task_ctx *ta_ctx, void *in_addr, { u32 *word_ptr; void *void_ptr; + void_ptr = ta_ctx->msgptr + *msg_offset; word_ptr = (u32 *)void_ptr; /* Do we need to manipulate endian? */ if (byte_array) { u32 i; + for (i = 0; i < ((size + 3) / 4); i += 1) *(word_ptr + i) = CHG_ENDIAN(*(word_ptr + i)); } @@ -865,6 +872,7 @@ static void sep_read_context(struct this_task_ctx *ta_ctx, u32 *msg_offset, void *dst, u32 len) { u32 max_length = ((len + 3) / sizeof(u32)) * sizeof(u32); + sep_read_msg(ta_ctx, dst, len, max_length, msg_offset, 0); } @@ -884,6 +892,7 @@ static void sep_write_context(struct this_task_ctx *ta_ctx, u32 *msg_offset, void *src, u32 len) { u32 max_length = ((len + 3) / sizeof(u32)) * sizeof(u32); + sep_write_msg(ta_ctx, src, len, max_length, msg_offset, 0); } @@ -3893,6 +3902,7 @@ static struct crypto_alg crypto_algs[] = { int sep_crypto_setup(void) { int err, i, j, k; + tasklet_init(&sep_dev->finish_tasklet, sep_finish, (unsigned long)sep_dev); diff --git a/drivers/staging/sep/sep_dev.h b/drivers/staging/sep/sep_dev.h index 5f6a07f59dd7..bf56c06662fd 100644 --- a/drivers/staging/sep/sep_dev.h +++ b/drivers/staging/sep/sep_dev.h @@ -152,6 +152,7 @@ static inline u32 sep_read_reg(struct sep_device *dev, int reg) static inline void sep_wait_sram_write(struct sep_device *dev) { u32 reg_val; + do { reg_val = sep_read_reg(dev, HW_SRAM_DATA_READY_REG_ADDR); } while (!(reg_val & 1)); -- cgit v1.2.3 From fd09d1de70480e0534eb57b0c8eb19ffbdab1d95 Mon Sep 17 00:00:00 2001 From: Fabio Falzoi Date: Tue, 22 Apr 2014 23:22:59 +0200 Subject: Staging: rts5139: Camel case labels replaced Replace camel case labels with linux coding style compliant names. Signed-off-by: Fabio Falzoi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5139/rts51x.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rts5139/rts51x.c b/drivers/staging/rts5139/rts51x.c index c8d06d4fddd2..9d9c7067a500 100644 --- a/drivers/staging/rts5139/rts51x.c +++ b/drivers/staging/rts5139/rts51x.c @@ -273,7 +273,7 @@ static int rts51x_control_thread(void *__chip) /* has the command timed out *already* ? */ if (test_bit(FLIDX_TIMED_OUT, &chip->usb->dflags)) { chip->srb->result = DID_ABORT << 16; - goto SkipForAbort; + goto abort; } scsi_unlock(host); @@ -316,7 +316,7 @@ static int rts51x_control_thread(void *__chip) if (chip->srb->result != DID_ABORT << 16) chip->srb->scsi_done(chip->srb); else -SkipForAbort : +abort : RTS51X_DEBUGP("scsi command aborted\n"); /* If an abort request was received we need to signal that @@ -763,17 +763,17 @@ static int rts51x_probe(struct usb_interface *intf, /* Associate the us_data structure with the USB device */ result = associate_dev(chip, intf); if (result) - goto BadDevice; + goto bad_device; /* Find the endpoints and calculate pipe values */ result = get_pipes(chip); if (result) - goto BadDevice; + goto bad_device; /* Acquire all the other resources and add the host */ result = rts51x_acquire_resources(chip); if (result) - goto BadDevice; + goto bad_device; /* Start up our control thread */ th = kthread_run(rts51x_control_thread, chip, RTS51X_CTL_THREAD); @@ -781,14 +781,14 @@ static int rts51x_probe(struct usb_interface *intf, printk(KERN_WARNING RTS51X_TIP "Unable to start control thread\n"); result = PTR_ERR(th); - goto BadDevice; + goto bad_device; } rts51x->ctl_thread = th; result = scsi_add_host(rts51x_to_host(chip), &rts51x->pusb_intf->dev); if (result) { printk(KERN_WARNING RTS51X_TIP "Unable to add the scsi host\n"); - goto BadDevice; + goto bad_device; } scsi_scan_host(rts51x_to_host(chip)); @@ -798,7 +798,7 @@ static int rts51x_probe(struct usb_interface *intf, printk(KERN_WARNING RTS51X_TIP "Unable to start polling thread\n"); result = PTR_ERR(th); - goto BadDevice; + goto bad_device; } rts51x->polling_thread = th; @@ -813,7 +813,7 @@ static int rts51x_probe(struct usb_interface *intf, return 0; /* We come here if there are any problems */ -BadDevice: +bad_device: RTS51X_DEBUGP("rts51x_probe() failed\n"); release_everything(chip); return result; -- cgit v1.2.3 From 307a433e3d3072df727aba851595eac328d1ab4d Mon Sep 17 00:00:00 2001 From: Fabio Falzoi Date: Tue, 22 Apr 2014 23:23:00 +0200 Subject: Staging: rts5139: Fixed multi-line code alignment Multi-line code aligned with open parenthesis. Signed-off-by: Fabio Falzoi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5139/rts51x.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rts5139/rts51x.c b/drivers/staging/rts5139/rts51x.c index 9d9c7067a500..28f4631ec577 100644 --- a/drivers/staging/rts5139/rts51x.c +++ b/drivers/staging/rts5139/rts51x.c @@ -291,15 +291,15 @@ static int rts51x_control_thread(void *__chip) */ else if (chip->srb->device->id) { RTS51X_DEBUGP("Bad target number (%d:%d)\n", - chip->srb->device->id, - chip->srb->device->lun); + chip->srb->device->id, + chip->srb->device->lun); chip->srb->result = DID_BAD_TARGET << 16; } else if (chip->srb->device->lun > chip->max_lun) { RTS51X_DEBUGP("Bad LUN (%d:%d)\n", - chip->srb->device->id, - chip->srb->device->lun); + chip->srb->device->id, + chip->srb->device->lun); chip->srb->result = DID_BAD_TARGET << 16; } @@ -433,12 +433,12 @@ static int associate_dev(struct rts51x_chip *chip, struct usb_interface *intf) rts51x->pusb_intf = intf; rts51x->ifnum = intf->cur_altsetting->desc.bInterfaceNumber; RTS51X_DEBUGP("Vendor: 0x%04x, Product: 0x%04x, Revision: 0x%04x\n", - le16_to_cpu(rts51x->pusb_dev->descriptor.idVendor), - le16_to_cpu(rts51x->pusb_dev->descriptor.idProduct), - le16_to_cpu(rts51x->pusb_dev->descriptor.bcdDevice)); + le16_to_cpu(rts51x->pusb_dev->descriptor.idVendor), + le16_to_cpu(rts51x->pusb_dev->descriptor.idProduct), + le16_to_cpu(rts51x->pusb_dev->descriptor.bcdDevice)); RTS51X_DEBUGP("Interface Subclass: 0x%02x, Protocol: 0x%02x\n", - intf->cur_altsetting->desc.bInterfaceSubClass, - intf->cur_altsetting->desc.bInterfaceProtocol); + intf->cur_altsetting->desc.bInterfaceSubClass, + intf->cur_altsetting->desc.bInterfaceProtocol); /* Store our private data in the interface */ usb_set_intfdata(intf, chip); @@ -569,8 +569,7 @@ static int get_pipes(struct rts51x_chip *chip) } if (!ep_in || !ep_out) { - RTS51X_DEBUGP("Endpoint sanity check failed!" - "Rejecting dev.\n"); + RTS51X_DEBUGP("Endpoint sanity check failed! Rejecting dev.\n"); return -EIO; } -- cgit v1.2.3 From 7cb61930110358a62b6ef0564707ba9e201a535e Mon Sep 17 00:00:00 2001 From: Fabio Falzoi Date: Tue, 22 Apr 2014 23:23:01 +0200 Subject: Staging: rts5139: Splitted one-line multiple assignment Splitted a multiple assignment on two separate lines. Signed-off-by: Fabio Falzoi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5139/rts51x.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rts5139/rts51x.c b/drivers/staging/rts5139/rts51x.c index 28f4631ec577..2be6210ece59 100644 --- a/drivers/staging/rts5139/rts51x.c +++ b/drivers/staging/rts5139/rts51x.c @@ -607,7 +607,8 @@ static int rts51x_acquire_resources(struct rts51x_chip *chip) return -ENOMEM; } - chip->cmd_buf = chip->rsp_buf = rts51x->iobuf; + chip->cmd_buf = rts51x->iobuf; + chip->rsp_buf = rts51x->iobuf; rts51x_init_options(chip); -- cgit v1.2.3 From 4b3ef391c320b112d140f991dbde5da9c651a690 Mon Sep 17 00:00:00 2001 From: Fabio Falzoi Date: Tue, 22 Apr 2014 23:23:02 +0200 Subject: Staging: rts5139: Use standard pr_ prefixing Define pr_fmt macro to prefix every pr_ function in standard way. Signed-off-by: Fabio Falzoi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5139/rts51x.c | 100 +++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/drivers/staging/rts5139/rts51x.c b/drivers/staging/rts5139/rts51x.c index 2be6210ece59..8a0f9ae5592a 100644 --- a/drivers/staging/rts5139/rts51x.c +++ b/drivers/staging/rts5139/rts51x.c @@ -23,6 +23,8 @@ * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include @@ -109,13 +111,13 @@ static inline void usb_autopm_disable(struct usb_interface *intf) static void rts51x_try_to_enter_ss(struct rts51x_chip *chip) { - RTS51X_DEBUGP("Ready to enter SS state\n"); + pr_debug("Ready to enter SS state\n"); usb_autopm_enable(chip->usb->pusb_intf); } void rts51x_try_to_exit_ss(struct rts51x_chip *chip) { - RTS51X_DEBUGP("Exit from SS state\n"); + pr_debug("Exit from SS state\n"); usb_autopm_disable(chip->usb->pusb_intf); } @@ -123,7 +125,7 @@ int rts51x_suspend(struct usb_interface *iface, pm_message_t message) { struct rts51x_chip *chip = usb_get_intfdata(iface); - RTS51X_DEBUGP("%s, message.event = 0x%x\n", __func__, message.event); + pr_debug("%s, message.event = 0x%x\n", __func__, message.event); /* Wait until no command is running */ mutex_lock(&chip->usb->dev_mutex); @@ -132,11 +134,11 @@ int rts51x_suspend(struct usb_interface *iface, pm_message_t message) rts51x_do_before_power_down(chip); if (message.event == PM_EVENT_AUTO_SUSPEND) { - RTS51X_DEBUGP("Enter SS state"); + pr_debug("Enter SS state"); chip->resume_from_scsi = 0; RTS51X_SET_STAT(chip, STAT_SS); } else { - RTS51X_DEBUGP("Enter SUSPEND state"); + pr_debug("Enter SUSPEND state"); RTS51X_SET_STAT(chip, STAT_SUSPEND); } @@ -151,7 +153,7 @@ int rts51x_resume(struct usb_interface *iface) { struct rts51x_chip *chip = usb_get_intfdata(iface); - RTS51X_DEBUGP("%s\n", __func__); + pr_debug("%s\n", __func__); if (!RTS51X_CHK_STAT(chip, STAT_SS) || !chip->resume_from_scsi) { mutex_lock(&chip->usb->dev_mutex); @@ -159,7 +161,7 @@ int rts51x_resume(struct usb_interface *iface) if (chip->option.ss_en) { if (GET_PM_USAGE_CNT(chip) <= 0) { /* Remote wake up, increase pm_usage_cnt */ - RTS51X_DEBUGP("Incr pm_usage_cnt\n"); + pr_debug("Incr pm_usage_cnt\n"); SET_PM_USAGE_CNT(chip, 1); } } @@ -179,7 +181,7 @@ int rts51x_reset_resume(struct usb_interface *iface) { struct rts51x_chip *chip = usb_get_intfdata(iface); - RTS51X_DEBUGP("%s\n", __func__); + pr_debug("%s\n", __func__); mutex_lock(&chip->usb->dev_mutex); @@ -219,7 +221,7 @@ static int rts51x_pre_reset(struct usb_interface *iface) { struct rts51x_chip *chip = usb_get_intfdata(iface); - RTS51X_DEBUGP("%s\n", __func__); + pr_debug("%s\n", __func__); /* Make sure no command runs during the reset */ mutex_lock(&chip->usb->dev_mutex); @@ -230,7 +232,7 @@ static int rts51x_post_reset(struct usb_interface *iface) { struct rts51x_chip *chip = usb_get_intfdata(iface); - RTS51X_DEBUGP("%s\n", __func__); + pr_debug("%s\n", __func__); /* Report the reset to the SCSI core */ /* usb_stor_report_bus_reset(us); */ @@ -252,7 +254,7 @@ static int rts51x_control_thread(void *__chip) break; if (test_bit(FLIDX_DISCONNECTING, &chip->usb->dflags)) { - RTS51X_DEBUGP("-- exiting from rts51x-control\n"); + pr_debug("-- exiting from rts51x-control\n"); break; } @@ -266,7 +268,7 @@ static int rts51x_control_thread(void *__chip) if (chip->srb == NULL) { scsi_unlock(host); mutex_unlock(&chip->usb->dev_mutex); - RTS51X_DEBUGP("-- exiting from control thread\n"); + pr_debug("-- exiting from control thread\n"); break; } @@ -282,7 +284,7 @@ static int rts51x_control_thread(void *__chip) * is UNKNOWN */ if (chip->srb->sc_data_direction == DMA_BIDIRECTIONAL) { - RTS51X_DEBUGP("UNKNOWN data direction\n"); + pr_debug("UNKNOWN data direction\n"); chip->srb->result = DID_ERROR << 16; } @@ -290,16 +292,16 @@ static int rts51x_control_thread(void *__chip) * the maximum known LUN */ else if (chip->srb->device->id) { - RTS51X_DEBUGP("Bad target number (%d:%d)\n", - chip->srb->device->id, - chip->srb->device->lun); + pr_debug("Bad target number (%d:%d)\n", + chip->srb->device->id, + chip->srb->device->lun); chip->srb->result = DID_BAD_TARGET << 16; } else if (chip->srb->device->lun > chip->max_lun) { - RTS51X_DEBUGP("Bad LUN (%d:%d)\n", - chip->srb->device->id, - chip->srb->device->lun); + pr_debug("Bad LUN (%d:%d)\n", + chip->srb->device->id, + chip->srb->device->lun); chip->srb->result = DID_BAD_TARGET << 16; } @@ -317,7 +319,7 @@ static int rts51x_control_thread(void *__chip) chip->srb->scsi_done(chip->srb); else abort : - RTS51X_DEBUGP("scsi command aborted\n"); + pr_debug("scsi command aborted\n"); /* If an abort request was received we need to signal that * the abort has finished. The proper test for this is @@ -362,7 +364,7 @@ static int rts51x_polling_thread(void *__chip) /* if the device has disconnected, we are free to exit */ if (test_bit(FLIDX_DISCONNECTING, &chip->usb->dflags)) { - RTS51X_DEBUGP("-- exiting from rts51x-polling\n"); + pr_debug("-- exiting from rts51x-polling\n"); break; } @@ -432,13 +434,13 @@ static int associate_dev(struct rts51x_chip *chip, struct usb_interface *intf) rts51x->pusb_dev = interface_to_usbdev(intf); rts51x->pusb_intf = intf; rts51x->ifnum = intf->cur_altsetting->desc.bInterfaceNumber; - RTS51X_DEBUGP("Vendor: 0x%04x, Product: 0x%04x, Revision: 0x%04x\n", - le16_to_cpu(rts51x->pusb_dev->descriptor.idVendor), - le16_to_cpu(rts51x->pusb_dev->descriptor.idProduct), - le16_to_cpu(rts51x->pusb_dev->descriptor.bcdDevice)); - RTS51X_DEBUGP("Interface Subclass: 0x%02x, Protocol: 0x%02x\n", - intf->cur_altsetting->desc.bInterfaceSubClass, - intf->cur_altsetting->desc.bInterfaceProtocol); + pr_debug("Vendor: 0x%04x, Product: 0x%04x, Revision: 0x%04x\n", + le16_to_cpu(rts51x->pusb_dev->descriptor.idVendor), + le16_to_cpu(rts51x->pusb_dev->descriptor.idProduct), + le16_to_cpu(rts51x->pusb_dev->descriptor.bcdDevice)); + pr_debug("Interface Subclass: 0x%02x, Protocol: 0x%02x\n", + intf->cur_altsetting->desc.bInterfaceSubClass, + intf->cur_altsetting->desc.bInterfaceProtocol); /* Store our private data in the interface */ usb_set_intfdata(intf, chip); @@ -448,7 +450,7 @@ static int associate_dev(struct rts51x_chip *chip, struct usb_interface *intf) retval = usb_register_dev(intf, &rts51x_class); if (retval) { /* something prevented us from registering this driver */ - RTS51X_DEBUGP("Not able to get a minor for this device."); + pr_debug("Not able to get a minor for this device."); usb_set_intfdata(intf, NULL); return -ENOMEM; } @@ -458,7 +460,7 @@ static int associate_dev(struct rts51x_chip *chip, struct usb_interface *intf) rts51x->cr = usb_buffer_alloc(rts51x->pusb_dev, sizeof(*rts51x->cr), GFP_KERNEL, &rts51x->cr_dma); if (!rts51x->cr) { - RTS51X_DEBUGP("usb_ctrlrequest allocation failed\n"); + pr_debug("usb_ctrlrequest allocation failed\n"); usb_set_intfdata(intf, NULL); return -ENOMEM; } @@ -466,7 +468,7 @@ static int associate_dev(struct rts51x_chip *chip, struct usb_interface *intf) rts51x->iobuf = usb_buffer_alloc(rts51x->pusb_dev, RTS51X_IOBUF_SIZE, GFP_KERNEL, &rts51x->iobuf_dma); if (!rts51x->iobuf) { - RTS51X_DEBUGP("I/O buffer allocation failed\n"); + pr_debug("I/O buffer allocation failed\n"); usb_set_intfdata(intf, NULL); return -ENOMEM; } @@ -569,7 +571,7 @@ static int get_pipes(struct rts51x_chip *chip) } if (!ep_in || !ep_out) { - RTS51X_DEBUGP("Endpoint sanity check failed! Rejecting dev.\n"); + pr_debug("Endpoint sanity check failed! Rejecting dev.\n"); return -EIO; } @@ -597,13 +599,13 @@ static int rts51x_acquire_resources(struct rts51x_chip *chip) rts51x->current_urb = usb_alloc_urb(0, GFP_KERNEL); if (!rts51x->current_urb) { - RTS51X_DEBUGP("URB allocation failed\n"); + pr_debug("URB allocation failed\n"); return -ENOMEM; } rts51x->intr_urb = usb_alloc_urb(0, GFP_KERNEL); if (!rts51x->intr_urb) { - RTS51X_DEBUGP("URB allocation failed\n"); + pr_debug("URB allocation failed\n"); return -ENOMEM; } @@ -623,13 +625,13 @@ static int rts51x_acquire_resources(struct rts51x_chip *chip) /* Release all our dynamic resources */ static void rts51x_release_resources(struct rts51x_chip *chip) { - RTS51X_DEBUGP("-- %s\n", __func__); + pr_debug("-- %s\n", __func__); /* Tell the control thread to exit. The SCSI host must * already have been removed and the DISCONNECTING flag set * so that we won't accept any more commands. */ - RTS51X_DEBUGP("-- sending exit command to thread\n"); + pr_debug("-- sending exit command to thread\n"); complete(&chip->usb->cmnd_ready); if (chip->usb->ctl_thread) wait_for_completion(&chip->usb->control_exit); @@ -654,7 +656,7 @@ static void dissociate_dev(struct rts51x_chip *chip) { struct rts51x_usb *rts51x = chip->usb; - RTS51X_DEBUGP("-- %s\n", __func__); + pr_debug("-- %s\n", __func__); /* Free the device-related DMA-mapped buffers */ if (rts51x->cr) @@ -721,12 +723,12 @@ static int rts51x_probe(struct usb_interface *intf, int result; struct task_struct *th; - RTS51X_DEBUGP("%s detected\n", RTS51X_NAME); + pr_debug("%s detected\n", RTS51X_NAME); rts51x = kzalloc(sizeof(struct rts51x_usb), GFP_KERNEL); if (!rts51x) { - printk(KERN_WARNING RTS51X_TIP - "Unable to allocate rts51x_usb\n"); + pr_warn(RTS51X_TIP + "Unable to allocate rts51x_usb\n"); return -ENOMEM; } @@ -736,8 +738,8 @@ static int rts51x_probe(struct usb_interface *intf, */ host = scsi_host_alloc(&rts51x_host_template, sizeof(*chip)); if (!host) { - printk(KERN_WARNING RTS51X_TIP - "Unable to allocate the scsi host\n"); + pr_warn(RTS51X_TIP + "Unable to allocate the scsi host\n"); kfree(rts51x); return -ENOMEM; } @@ -778,8 +780,7 @@ static int rts51x_probe(struct usb_interface *intf, /* Start up our control thread */ th = kthread_run(rts51x_control_thread, chip, RTS51X_CTL_THREAD); if (IS_ERR(th)) { - printk(KERN_WARNING RTS51X_TIP - "Unable to start control thread\n"); + pr_warn("Unable to start control thread\n"); result = PTR_ERR(th); goto bad_device; } @@ -787,7 +788,7 @@ static int rts51x_probe(struct usb_interface *intf, result = scsi_add_host(rts51x_to_host(chip), &rts51x->pusb_intf->dev); if (result) { - printk(KERN_WARNING RTS51X_TIP "Unable to add the scsi host\n"); + pr_warn("Unable to add the scsi host\n"); goto bad_device; } scsi_scan_host(rts51x_to_host(chip)); @@ -795,8 +796,7 @@ static int rts51x_probe(struct usb_interface *intf, /* Start up our polling thread */ th = kthread_run(rts51x_polling_thread, chip, RTS51X_POLLING_THREAD); if (IS_ERR(th)) { - printk(KERN_WARNING RTS51X_TIP - "Unable to start polling thread\n"); + pr_warn("Unable to start polling thread\n"); result = PTR_ERR(th); goto bad_device; } @@ -806,7 +806,7 @@ static int rts51x_probe(struct usb_interface *intf, if (ss_en) { rts51x->pusb_intf->needs_remote_wakeup = needs_remote_wakeup; SET_PM_USAGE_CNT(chip, 1); - RTS51X_DEBUGP("pm_usage_cnt = %d\n", GET_PM_USAGE_CNT(chip)); + pr_debug("pm_usage_cnt = %d\n", GET_PM_USAGE_CNT(chip)); } #endif @@ -814,7 +814,7 @@ static int rts51x_probe(struct usb_interface *intf, /* We come here if there are any problems */ bad_device: - RTS51X_DEBUGP("rts51x_probe() failed\n"); + pr_debug("rts51x_probe() failed\n"); release_everything(chip); return result; } @@ -823,7 +823,7 @@ static void rts51x_disconnect(struct usb_interface *intf) { struct rts51x_chip *chip = (struct rts51x_chip *)usb_get_intfdata(intf); - RTS51X_DEBUGP("rts51x_disconnect() called\n"); + pr_debug("rts51x_disconnect() called\n"); quiesce_and_remove_host(chip); release_everything(chip); } -- cgit v1.2.3 From c606525d76d16702de1b40fcf017e63f31c270c1 Mon Sep 17 00:00:00 2001 From: Fabio Falzoi Date: Tue, 22 Apr 2014 23:23:03 +0200 Subject: Staging: rts5139: Removed OOM messages All allocation Out Of Memory messages removed. We rely on the generic OOM message in dump_stack(). Signed-off-by: Fabio Falzoi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5139/rts51x.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rts5139/rts51x.c b/drivers/staging/rts5139/rts51x.c index 8a0f9ae5592a..612041005b59 100644 --- a/drivers/staging/rts5139/rts51x.c +++ b/drivers/staging/rts5139/rts51x.c @@ -460,7 +460,6 @@ static int associate_dev(struct rts51x_chip *chip, struct usb_interface *intf) rts51x->cr = usb_buffer_alloc(rts51x->pusb_dev, sizeof(*rts51x->cr), GFP_KERNEL, &rts51x->cr_dma); if (!rts51x->cr) { - pr_debug("usb_ctrlrequest allocation failed\n"); usb_set_intfdata(intf, NULL); return -ENOMEM; } @@ -468,7 +467,6 @@ static int associate_dev(struct rts51x_chip *chip, struct usb_interface *intf) rts51x->iobuf = usb_buffer_alloc(rts51x->pusb_dev, RTS51X_IOBUF_SIZE, GFP_KERNEL, &rts51x->iobuf_dma); if (!rts51x->iobuf) { - pr_debug("I/O buffer allocation failed\n"); usb_set_intfdata(intf, NULL); return -ENOMEM; } @@ -598,16 +596,12 @@ static int rts51x_acquire_resources(struct rts51x_chip *chip) int retval; rts51x->current_urb = usb_alloc_urb(0, GFP_KERNEL); - if (!rts51x->current_urb) { - pr_debug("URB allocation failed\n"); + if (!rts51x->current_urb) return -ENOMEM; - } rts51x->intr_urb = usb_alloc_urb(0, GFP_KERNEL); - if (!rts51x->intr_urb) { - pr_debug("URB allocation failed\n"); + if (!rts51x->intr_urb) return -ENOMEM; - } chip->cmd_buf = rts51x->iobuf; chip->rsp_buf = rts51x->iobuf; @@ -726,11 +720,8 @@ static int rts51x_probe(struct usb_interface *intf, pr_debug("%s detected\n", RTS51X_NAME); rts51x = kzalloc(sizeof(struct rts51x_usb), GFP_KERNEL); - if (!rts51x) { - pr_warn(RTS51X_TIP - "Unable to allocate rts51x_usb\n"); + if (!rts51x) return -ENOMEM; - } /* * Ask the SCSI layer to allocate a host structure, with extra @@ -738,8 +729,6 @@ static int rts51x_probe(struct usb_interface *intf, */ host = scsi_host_alloc(&rts51x_host_template, sizeof(*chip)); if (!host) { - pr_warn(RTS51X_TIP - "Unable to allocate the scsi host\n"); kfree(rts51x); return -ENOMEM; } -- cgit v1.2.3 From ba8f073281fe0b6d50332bf005dd023ecf51efa9 Mon Sep 17 00:00:00 2001 From: Fabio Falzoi Date: Tue, 22 Apr 2014 23:23:04 +0200 Subject: Staging: rts5139: More appropriate use of sizeof operand Use the pointer rts51x to get the size of the struct. Signed-off-by: Fabio Falzoi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5139/rts51x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rts5139/rts51x.c b/drivers/staging/rts5139/rts51x.c index 612041005b59..8529cbabc554 100644 --- a/drivers/staging/rts5139/rts51x.c +++ b/drivers/staging/rts5139/rts51x.c @@ -719,7 +719,7 @@ static int rts51x_probe(struct usb_interface *intf, pr_debug("%s detected\n", RTS51X_NAME); - rts51x = kzalloc(sizeof(struct rts51x_usb), GFP_KERNEL); + rts51x = kzalloc(sizeof(*rts51x), GFP_KERNEL); if (!rts51x) return -ENOMEM; -- cgit v1.2.3 From 10f9f4aefa6f7aece31a0edff5ae2fdaaf55eca4 Mon Sep 17 00:00:00 2001 From: Thomas Tanaka Date: Wed, 16 Apr 2014 21:05:09 -0700 Subject: staging: rts5139: fixed coding style Fixed checkpatch warnings > 80 lines Signed-off-by: Thomas Tanaka Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5139/rts51x_fop.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rts5139/rts51x_fop.c b/drivers/staging/rts5139/rts51x_fop.c index 677d18b3dcd5..cf4e675aea69 100644 --- a/drivers/staging/rts5139/rts51x_fop.c +++ b/drivers/staging/rts5139/rts51x_fop.c @@ -70,7 +70,8 @@ static int rts51x_sd_direct_cmnd(struct rts51x_chip *chip, switch (dir) { case 0: /* No data */ - retval = ext_rts51x_sd_execute_no_data(chip, chip->card2lun[SD_CARD], + retval = ext_rts51x_sd_execute_no_data(chip, + chip->card2lun[SD_CARD], cmd_idx, standby, acmd, rsp_code, arg); if (retval != TRANSPORT_GOOD) @@ -83,10 +84,11 @@ static int rts51x_sd_direct_cmnd(struct rts51x_chip *chip, if (!buf) TRACE_RET(chip, STATUS_NOMEM); - retval = ext_rts51x_sd_execute_read_data(chip, chip->card2lun[SD_CARD], - cmd_idx, cmd12, standby, acmd, - rsp_code, arg, len, buf, - cmnd->buf_len, 0); + retval = ext_rts51x_sd_execute_read_data(chip, + chip->card2lun[SD_CARD], + cmd_idx, cmd12, standby, acmd, + rsp_code, arg, len, buf, + cmnd->buf_len, 0); if (retval != TRANSPORT_GOOD) { kfree(buf); TRACE_RET(chip, STATUS_FAIL); @@ -117,10 +119,11 @@ static int rts51x_sd_direct_cmnd(struct rts51x_chip *chip, } retval = - ext_rts51x_sd_execute_write_data(chip, chip->card2lun[SD_CARD], - cmd_idx, cmd12, standby, acmd, - rsp_code, arg, len, buf, - cmnd->buf_len, 0); + ext_rts51x_sd_execute_write_data(chip, + chip->card2lun[SD_CARD], + cmd_idx, cmd12, standby, acmd, + rsp_code, arg, len, buf, + cmnd->buf_len, 0); if (retval != TRANSPORT_GOOD) { kfree(buf); TRACE_RET(chip, STATUS_FAIL); -- cgit v1.2.3 From dbdb85221af150e8ef570c333cb4729a98cc82c8 Mon Sep 17 00:00:00 2001 From: Neil Armstrong Date: Fri, 11 Apr 2014 14:58:58 +0200 Subject: staging: rts5139: fix bad symbol declaration With sparse, the following error appears : CHECK drivers/staging/rts5139/ms_mg.c drivers/staging/rts5139/ms_mg.c:82:5: warning: symbol 'mg_set_tpc_para_sub' was not declared. Should it be static? Rename function with correct prefix and move declaration to coherent internal header file. Signed-off-by: Neil 'Superna' Armstrong Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5139/ms.c | 7 ++----- drivers/staging/rts5139/ms_mg.c | 2 +- drivers/staging/rts5139/ms_mg.h | 1 + 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rts5139/ms.c b/drivers/staging/rts5139/ms.c index 390292ad4566..a843a2f4392b 100644 --- a/drivers/staging/rts5139/ms.c +++ b/drivers/staging/rts5139/ms.c @@ -36,6 +36,7 @@ #include "rts51x_scsi.h" #include "rts51x_card.h" #include "ms.h" +#include "ms_mg.h" static inline void ms_set_err_code(struct rts51x_chip *chip, u8 err_code) { @@ -1183,10 +1184,6 @@ static int ms_read_attribute_info(struct rts51x_chip *chip) return STATUS_SUCCESS; } -#ifdef SUPPORT_MAGIC_GATE -int mg_set_tpc_para_sub(struct rts51x_chip *chip, int type, u8 mg_entry_num); -#endif - static int reset_ms_pro(struct rts51x_chip *chip) { struct ms_info *ms_card = &(chip->ms_card); @@ -1232,7 +1229,7 @@ Retry: #endif #ifdef SUPPORT_MAGIC_GATE - retval = mg_set_tpc_para_sub(chip, 0, 0); + retval = rts51x_mg_set_tpc_para_sub(chip, 0, 0); if (retval != STATUS_SUCCESS) TRACE_RET(chip, retval); #endif diff --git a/drivers/staging/rts5139/ms_mg.c b/drivers/staging/rts5139/ms_mg.c index 00862c1a36db..c8f26062c682 100644 --- a/drivers/staging/rts5139/ms_mg.c +++ b/drivers/staging/rts5139/ms_mg.c @@ -79,7 +79,7 @@ static int mg_send_ex_cmd(struct rts51x_chip *chip, u8 cmd, u8 entry_num) return STATUS_SUCCESS; } -int mg_set_tpc_para_sub(struct rts51x_chip *chip, int type, u8 mg_entry_num) +int rts51x_mg_set_tpc_para_sub(struct rts51x_chip *chip, int type, u8 mg_entry_num) { int retval; u8 buf[6]; diff --git a/drivers/staging/rts5139/ms_mg.h b/drivers/staging/rts5139/ms_mg.h index d15733a992ae..109c71290953 100644 --- a/drivers/staging/rts5139/ms_mg.h +++ b/drivers/staging/rts5139/ms_mg.h @@ -30,6 +30,7 @@ #include "rts51x_chip.h" #include "ms.h" +int rts51x_mg_set_tpc_para_sub(struct rts51x_chip *chip, int type, u8 mg_entry_num); int rts51x_mg_set_leaf_id(struct scsi_cmnd *srb, struct rts51x_chip *chip); int rts51x_mg_get_local_EKB(struct scsi_cmnd *srb, struct rts51x_chip *chip); int rts51x_mg_chg(struct scsi_cmnd *srb, struct rts51x_chip *chip); -- cgit v1.2.3 From 0f18a27787a340b26c4f64fae8f2bb103f50b546 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Sun, 6 Apr 2014 15:37:25 +0200 Subject: staging: rts5139: Make variables inside #ifdef CONFIG_PM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If CONFIG_PM=n: drivers/staging/rts5139/rts51x_transport.c:649: warning: ‘media_not_present’ defined but not used drivers/staging/rts5139/rts51x_transport.c:651: warning: ‘invalid_cmd_field’ defined but not used Move the variables inside the #ifdef CONFIG_PM, and make them const while we're at it. Signed-off-by: Geert Uytterhoeven Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5139/rts51x_transport.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rts5139/rts51x_transport.c b/drivers/staging/rts5139/rts51x_transport.c index 74588d249b32..0db1345df94e 100644 --- a/drivers/staging/rts5139/rts51x_transport.c +++ b/drivers/staging/rts5139/rts51x_transport.c @@ -646,16 +646,18 @@ int rts51x_get_epc_status(struct rts51x_chip *chip, u16 *status) chip->usb->intr_urb->actual_length); } -static u8 media_not_present[] = { - 0x70, 0, 0x02, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0x3A, 0, 0, 0, 0, 0 }; -static u8 invalid_cmd_field[] = { - 0x70, 0, 0x05, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0x24, 0, 0, 0, 0, 0 }; - void rts51x_invoke_transport(struct scsi_cmnd *srb, struct rts51x_chip *chip) { int result; #ifdef CONFIG_PM + static const u8 media_not_present[] = { + 0x70, 0, 0x02, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0x3A, 0, 0, 0, 0, 0 + }; + static const u8 invalid_cmd_field[] = { + 0x70, 0, 0x05, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0x24, 0, 0, 0, 0, 0 + }; + if (chip->option.ss_en) { if (srb->cmnd[0] == TEST_UNIT_READY) { if (RTS51X_CHK_STAT(chip, STAT_SS)) { -- cgit v1.2.3 From f2dbdf625ddc98fece71a79d78d0981204e933ee Mon Sep 17 00:00:00 2001 From: Octavian Purdila Date: Fri, 16 May 2014 08:24:58 +0300 Subject: goldfish: bus: fix warnings for 32bit builds drivers/platform/goldfish/pdev_bus.c: In function 'goldfish_new_pdev': drivers/platform/goldfish/pdev_bus.c:136:14: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] writel((u32)(u64)name, pdev_bus_base + PDEV_BUS_GET_NAME); Reported-by: Fengguang Wu Cc: Jun Tian Acked-by: Alan Cox Signed-off-by: Octavian Purdila Signed-off-by: Greg Kroah-Hartman --- drivers/platform/goldfish/pdev_bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/goldfish/pdev_bus.c b/drivers/platform/goldfish/pdev_bus.c index eb254400c44a..8c43589c3edb 100644 --- a/drivers/platform/goldfish/pdev_bus.c +++ b/drivers/platform/goldfish/pdev_bus.c @@ -133,7 +133,7 @@ static int goldfish_new_pdev(void) #ifdef CONFIG_64BIT writel((u32)((u64)name>>32), pdev_bus_base + PDEV_BUS_GET_NAME_HIGH); #endif - writel((u32)(u64)name, pdev_bus_base + PDEV_BUS_GET_NAME); + writel((u32)(unsigned long)name, pdev_bus_base + PDEV_BUS_GET_NAME); name[name_len] = '\0'; dev->pdev.id = readl(pdev_bus_base + PDEV_BUS_ID); dev->pdev.resource[0].start = base; -- cgit v1.2.3 From f4e131dc38d34469b9fee1840ad237324831bce3 Mon Sep 17 00:00:00 2001 From: Octavian Purdila Date: Fri, 16 May 2014 08:24:59 +0300 Subject: goldfish: pipe: fix warnings for 32bit builds drivers/platform/goldfish/goldfish_pipe.c: In function 'goldfish_cmd_status': drivers/platform/goldfish/goldfish_pipe.c:164:14: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] writel((u32)(u64)pipe, dev->base + PIPE_REG_CHANNEL); ^ drivers/platform/goldfish/goldfish_pipe.c: In function 'goldfish_cmd': drivers/platform/goldfish/goldfish_pipe.c:180:14: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] writel((u32)(u64)pipe, dev->base + PIPE_REG_CHANNEL); ^ drivers/platform/goldfish/goldfish_pipe.c: In function 'goldfish_pipe_read_write': drivers/platform/goldfish/goldfish_pipe.c:337:16: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] writel((u32)(u64)pipe, dev->base + PIPE_REG_CHANNEL); Reported-by: Fengguang Wu Cc: Jun Tian Acked-by: Alan Cox Signed-off-by: Octavian Purdila Signed-off-by: Greg Kroah-Hartman --- drivers/platform/goldfish/goldfish_pipe.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c index c86180bba72e..d9a09d9637d9 100644 --- a/drivers/platform/goldfish/goldfish_pipe.c +++ b/drivers/platform/goldfish/goldfish_pipe.c @@ -158,7 +158,7 @@ static u32 goldfish_cmd_status(struct goldfish_pipe *pipe, u32 cmd) struct goldfish_pipe_dev *dev = pipe->dev; spin_lock_irqsave(&dev->lock, flags); - gf_write64((u64)pipe, dev->base + PIPE_REG_CHANNEL, + gf_write64((u64)(unsigned long)pipe, dev->base + PIPE_REG_CHANNEL, dev->base + PIPE_REG_CHANNEL_HIGH); writel(cmd, dev->base + PIPE_REG_COMMAND); status = readl(dev->base + PIPE_REG_STATUS); @@ -172,7 +172,7 @@ static void goldfish_cmd(struct goldfish_pipe *pipe, u32 cmd) struct goldfish_pipe_dev *dev = pipe->dev; spin_lock_irqsave(&dev->lock, flags); - gf_write64((u64)pipe, dev->base + PIPE_REG_CHANNEL, + gf_write64((u64)(unsigned long)pipe, dev->base + PIPE_REG_CHANNEL, dev->base + PIPE_REG_CHANNEL_HIGH); writel(cmd, dev->base + PIPE_REG_COMMAND); spin_unlock_irqrestore(&dev->lock, flags); @@ -327,8 +327,9 @@ static ssize_t goldfish_pipe_read_write(struct file *filp, char __user *buffer, spin_lock_irqsave(&dev->lock, irq_flags); if (access_with_param(dev, CMD_WRITE_BUFFER + cmd_offset, address, avail, pipe, &status)) { - gf_write64((u64)pipe, dev->base + PIPE_REG_CHANNEL, - dev->base + PIPE_REG_CHANNEL_HIGH); + gf_write64((u64)(unsigned long)pipe, + dev->base + PIPE_REG_CHANNEL, + dev->base + PIPE_REG_CHANNEL_HIGH); writel(avail, dev->base + PIPE_REG_SIZE); gf_write64(address, dev->base + PIPE_REG_ADDRESS, dev->base + PIPE_REG_ADDRESS_HIGH); -- cgit v1.2.3 From 9c45c20da21d0de00444ef98c6ac824c906350af Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:03:34 +0200 Subject: staging: rtl8723au: rtl8723a_spec.h: Use BIT() instead of BITx macros Be consistent and stick to BIT() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtl8723a_spec.h | 314 +++++++++++----------- 1 file changed, 157 insertions(+), 157 deletions(-) diff --git a/drivers/staging/rtl8723au/include/rtl8723a_spec.h b/drivers/staging/rtl8723au/include/rtl8723a_spec.h index 3595c27907d0..b5d7123f7873 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_spec.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_spec.h @@ -481,11 +481,11 @@ /* 8192C Cmd9346CR bits (Offset 0xA, 16bit) */ /* */ /* EEPROM enable when set 1 */ -#define CmdEEPROM_En BIT5 +#define CmdEEPROM_En BIT(5) /* System EEPROM select, 0: boot from E-FUSE, 1: The EEPROM used is 9346 */ -#define CmdEERPOMSEL BIT4 -#define Cmd9346CR_9356SEL BIT4 +#define CmdEERPOMSEL BIT(4) +#define Cmd9346CR_9356SEL BIT(4) #define AutoLoadEEPROM (CmdEEPROM_En|CmdEERPOMSEL) #define AutoLoadEFUSE CmdEEPROM_En @@ -493,7 +493,7 @@ /* 8192C GPIO MUX Configuration Register (offset 0x40, 4 byte) */ /* */ #define GPIOSEL_GPIO 0 -#define GPIOSEL_ENBT BIT5 +#define GPIOSEL_ENBT BIT(5) /* */ /* 8192C GPIO PIN Control Register (offset 0x44, 4 byte) */ @@ -535,43 +535,43 @@ Default: 00b. #define RRSR_RSC_UPSUBCHNL 0x400000 #define RRSR_RSC_LOWSUBCHNL 0x200000 #define RRSR_SHORT 0x800000 -#define RRSR_1M BIT0 -#define RRSR_2M BIT1 -#define RRSR_5_5M BIT2 -#define RRSR_11M BIT3 -#define RRSR_6M BIT4 -#define RRSR_9M BIT5 -#define RRSR_12M BIT6 -#define RRSR_18M BIT7 -#define RRSR_24M BIT8 -#define RRSR_36M BIT9 -#define RRSR_48M BIT10 -#define RRSR_54M BIT11 -#define RRSR_MCS0 BIT12 -#define RRSR_MCS1 BIT13 -#define RRSR_MCS2 BIT14 -#define RRSR_MCS3 BIT15 -#define RRSR_MCS4 BIT16 -#define RRSR_MCS5 BIT17 -#define RRSR_MCS6 BIT18 -#define RRSR_MCS7 BIT19 -#define BRSR_AckShortPmb BIT23 +#define RRSR_1M BIT(0) +#define RRSR_2M BIT(1) +#define RRSR_5_5M BIT(2) +#define RRSR_11M BIT(3) +#define RRSR_6M BIT(4) +#define RRSR_9M BIT(5) +#define RRSR_12M BIT(6) +#define RRSR_18M BIT(7) +#define RRSR_24M BIT(8) +#define RRSR_36M BIT(9) +#define RRSR_48M BIT(10) +#define RRSR_54M BIT(11) +#define RRSR_MCS0 BIT(12) +#define RRSR_MCS1 BIT(13) +#define RRSR_MCS2 BIT(14) +#define RRSR_MCS3 BIT(15) +#define RRSR_MCS4 BIT(16) +#define RRSR_MCS5 BIT(17) +#define RRSR_MCS6 BIT(18) +#define RRSR_MCS7 BIT(19) +#define BRSR_AckShortPmb BIT(23) /* CCK ACK: use Short Preamble or not */ /* */ /* 8192C BW_OPMODE bits (Offset 0x203, 8bit) */ /* */ -#define BW_OPMODE_20MHZ BIT2 -#define BW_OPMODE_5G BIT1 -#define BW_OPMODE_11J BIT0 +#define BW_OPMODE_20MHZ BIT(2) +#define BW_OPMODE_5G BIT(1) +#define BW_OPMODE_11J BIT(0) /* */ /* 8192C CAM Config Setting (offset 0x250, 1 byte) */ /* */ -#define CAM_VALID BIT15 +#define CAM_VALID BIT(15) #define CAM_NOTVALID 0x0000 -#define CAM_USEDK BIT5 +#define CAM_USEDK BIT(5) #define CAM_CONTENT_COUNT 8 @@ -587,9 +587,9 @@ Default: 00b. #define CAM_CONFIG_USEDK true #define CAM_CONFIG_NO_USEDK false -#define CAM_WRITE BIT16 +#define CAM_WRITE BIT(16) #define CAM_READ 0x00000000 -#define CAM_POLLINIG BIT31 +#define CAM_POLLINIG BIT(31) #define SCR_UseDK 0x01 #define SCR_TxSecEnable 0x02 @@ -605,54 +605,54 @@ Default: 00b. #define IMR8190_DISABLED 0x0 /* IMR DW0 Bit 0-31 */ -#define IMR_BCNDMAINT6 BIT31 /* Beacon DMA Interrupt 6 */ -#define IMR_BCNDMAINT5 BIT30 /* Beacon DMA Interrupt 5 */ -#define IMR_BCNDMAINT4 BIT29 /* Beacon DMA Interrupt 4 */ -#define IMR_BCNDMAINT3 BIT28 /* Beacon DMA Interrupt 3 */ -#define IMR_BCNDMAINT2 BIT27 /* Beacon DMA Interrupt 2 */ -#define IMR_BCNDMAINT1 BIT26 /* Beacon DMA Interrupt 1 */ -#define IMR_BCNDOK8 BIT25 /* Beacon Queue DMA OK +#define IMR_BCNDMAINT6 BIT(31) /* Beacon DMA Interrupt 6 */ +#define IMR_BCNDMAINT5 BIT(30) /* Beacon DMA Interrupt 5 */ +#define IMR_BCNDMAINT4 BIT(29) /* Beacon DMA Interrupt 4 */ +#define IMR_BCNDMAINT3 BIT(28) /* Beacon DMA Interrupt 3 */ +#define IMR_BCNDMAINT2 BIT(27) /* Beacon DMA Interrupt 2 */ +#define IMR_BCNDMAINT1 BIT(26) /* Beacon DMA Interrupt 1 */ +#define IMR_BCNDOK8 BIT(25) /* Beacon Queue DMA OK Interrupt 8 */ -#define IMR_BCNDOK7 BIT24 /* Beacon Queue DMA OK +#define IMR_BCNDOK7 BIT(24) /* Beacon Queue DMA OK Interrupt 7 */ -#define IMR_BCNDOK6 BIT23 /* Beacon Queue DMA OK +#define IMR_BCNDOK6 BIT(23) /* Beacon Queue DMA OK Interrupt 6 */ -#define IMR_BCNDOK5 BIT22 /* Beacon Queue DMA OK +#define IMR_BCNDOK5 BIT(22) /* Beacon Queue DMA OK Interrupt 5 */ -#define IMR_BCNDOK4 BIT21 /* Beacon Queue DMA OK +#define IMR_BCNDOK4 BIT(21) /* Beacon Queue DMA OK Interrupt 4 */ -#define IMR_BCNDOK3 BIT20 /* Beacon Queue DMA OK +#define IMR_BCNDOK3 BIT(20) /* Beacon Queue DMA OK Interrupt 3 */ -#define IMR_BCNDOK2 BIT19 /* Beacon Queue DMA OK +#define IMR_BCNDOK2 BIT(19) /* Beacon Queue DMA OK Interrupt 2 */ -#define IMR_BCNDOK1 BIT18 /* Beacon Queue DMA OK +#define IMR_BCNDOK1 BIT(18) /* Beacon Queue DMA OK Interrupt 1 */ -#define IMR_TIMEOUT2 BIT17 /* Timeout interrupt 2 */ -#define IMR_TIMEOUT1 BIT16 /* Timeout interrupt 1 */ -#define IMR_TXFOVW BIT15 /* Transmit FIFO Overflow */ -#define IMR_PSTIMEOUT BIT14 /* Power save time out +#define IMR_TIMEOUT2 BIT(17) /* Timeout interrupt 2 */ +#define IMR_TIMEOUT1 BIT(16) /* Timeout interrupt 1 */ +#define IMR_TXFOVW BIT(15) /* Transmit FIFO Overflow */ +#define IMR_PSTIMEOUT BIT(14) /* Power save time out interrupt */ -#define IMR_BcnInt BIT13 /* Beacon DMA Interrupt 0 */ -#define IMR_RXFOVW BIT12 /* Receive FIFO Overflow */ -#define IMR_RDU BIT11 /* Receive Descriptor +#define IMR_BcnInt BIT(13) /* Beacon DMA Interrupt 0 */ +#define IMR_RXFOVW BIT(12) /* Receive FIFO Overflow */ +#define IMR_RDU BIT(11) /* Receive Descriptor Unavailable */ -#define IMR_ATIMEND BIT10 /* For 92C,ATIM Window +#define IMR_ATIMEND BIT(10) /* For 92C,ATIM Window End Interrupt */ -#define IMR_BDOK BIT9 /* Beacon Queue DMA OK +#define IMR_BDOK BIT(9) /* Beacon Queue DMA OK Interrup */ -#define IMR_HIGHDOK BIT8 /* High Queue DMA OK +#define IMR_HIGHDOK BIT(8) /* High Queue DMA OK Interrupt */ -#define IMR_TBDOK BIT7 /* Transmit Beacon OK +#define IMR_TBDOK BIT(7) /* Transmit Beacon OK interrup */ -#define IMR_MGNTDOK BIT6 /* Management Queue DMA OK +#define IMR_MGNTDOK BIT(6) /* Management Queue DMA OK Interrupt */ -#define IMR_TBDER BIT5 /* For 92C,Transmit Beacon +#define IMR_TBDER BIT(5) /* For 92C,Transmit Beacon Error Interrupt */ -#define IMR_BKDOK BIT4 /* AC_BK DMA OK Interrupt */ -#define IMR_BEDOK BIT3 /* AC_BE DMA OK Interrupt */ -#define IMR_VIDOK BIT2 /* AC_VI DMA OK Interrupt */ -#define IMR_VODOK BIT1 /* AC_VO DMA Interrupt */ -#define IMR_ROK BIT0 /* Receive DMA OK Interrupt */ +#define IMR_BKDOK BIT(4) /* AC_BK DMA OK Interrupt */ +#define IMR_BEDOK BIT(3) /* AC_BE DMA OK Interrupt */ +#define IMR_VIDOK BIT(2) /* AC_VI DMA OK Interrupt */ +#define IMR_VODOK BIT(1) /* AC_VO DMA Interrupt */ +#define IMR_ROK BIT(0) /* Receive DMA OK Interrupt */ #define IMR_RX_MASK (IMR_ROK|IMR_RDU|IMR_RXFOVW) #define IMR_TX_MASK (IMR_VODOK|IMR_VIDOK|IMR_BEDOK| \ @@ -660,14 +660,14 @@ Default: 00b. IMR_BDOK) /* 13. Host Interrupt Status Extension Register (Offset: 0x012C-012Eh) */ -#define IMR_BcnInt_E BIT12 -#define IMR_TXERR BIT11 -#define IMR_RXERR BIT10 -#define IMR_C2HCMD BIT9 -#define IMR_CPWM BIT8 +#define IMR_BcnInt_E BIT(12) +#define IMR_TXERR BIT(11) +#define IMR_RXERR BIT(10) +#define IMR_C2HCMD BIT(9) +#define IMR_CPWM BIT(8) /* RSVD [2-7] */ -#define IMR_OCPINT BIT1 -#define IMR_WLANOFF BIT0 +#define IMR_OCPINT BIT(1) +#define IMR_WLANOFF BIT(0) /* 8192C EEPROM/EFUSE share register definition. */ @@ -913,35 +913,35 @@ Current IOREG MAP /* */ /* 8192C (RCR) Receive Configuration Register (Offset 0x608, 32 bits) */ /* */ -#define RCR_APPFCS BIT31 /* WMAC append FCS after payload*/ -#define RCR_APP_MIC BIT30 -#define RCR_APP_PHYSTS BIT28 -#define RCR_APP_ICV BIT29 -#define RCR_APP_PHYST_RXFF BIT28 -#define RCR_APP_BA_SSN BIT27 /* Accept BA SSN */ -#define RCR_ENMBID BIT24 /* Enable Multiple BssId. */ -#define RCR_LSIGEN BIT23 -#define RCR_MFBEN BIT22 -#define RCR_HTC_LOC_CTRL BIT14 /* MFC<--HTC=1 MFC-->HTC=0 */ -#define RCR_AMF BIT13 /* Accept management type frame */ -#define RCR_ACF BIT12 /* Accept control type frame */ -#define RCR_ADF BIT11 /* Accept data type frame */ -#define RCR_AICV BIT9 /* Accept ICV error packet */ -#define RCR_ACRC32 BIT8 /* Accept CRC32 error packet */ -#define RCR_CBSSID_BCN BIT7 /* Accept BSSID match packet +#define RCR_APPFCS BIT(31) /* WMAC append FCS after payload*/ +#define RCR_APP_MIC BIT(30) +#define RCR_APP_PHYSTS BIT(28) +#define RCR_APP_ICV BIT(29) +#define RCR_APP_PHYST_RXFF BIT(28) +#define RCR_APP_BA_SSN BIT(27) /* Accept BA SSN */ +#define RCR_ENMBID BIT(24) /* Enable Multiple BssId. */ +#define RCR_LSIGEN BIT(23) +#define RCR_MFBEN BIT(22) +#define RCR_HTC_LOC_CTRL BIT(14) /* MFC<--HTC=1 MFC-->HTC=0 */ +#define RCR_AMF BIT(13) /* Accept management type frame */ +#define RCR_ACF BIT(12) /* Accept control type frame */ +#define RCR_ADF BIT(11) /* Accept data type frame */ +#define RCR_AICV BIT(9) /* Accept ICV error packet */ +#define RCR_ACRC32 BIT(8) /* Accept CRC32 error packet */ +#define RCR_CBSSID_BCN BIT(7) /* Accept BSSID match packet (Rx beacon, probe rsp) */ -#define RCR_CBSSID_DATA BIT6 /* Accept BSSID match packet +#define RCR_CBSSID_DATA BIT(6) /* Accept BSSID match packet (Data) */ #define RCR_CBSSID RCR_CBSSID_DATA /* Accept BSSID match packet */ -#define RCR_APWRMGT BIT5 /* Accept power management +#define RCR_APWRMGT BIT(5) /* Accept power management packet */ -#define RCR_ADD3 BIT4 /* Accept address 3 match +#define RCR_ADD3 BIT(4) /* Accept address 3 match packet */ -#define RCR_AB BIT3 /* Accept broadcast packet */ -#define RCR_AM BIT2 /* Accept multicast packet */ -#define RCR_APM BIT1 /* Accept physical match packet */ -#define RCR_AAP BIT0 /* Accept all unicast packet */ +#define RCR_AB BIT(3) /* Accept broadcast packet */ +#define RCR_AM BIT(2) /* Accept multicast packet */ +#define RCR_APM BIT(1) /* Accept physical match packet */ +#define RCR_AAP BIT(0) /* Accept all unicast packet */ #define RCR_MXDMA_OFFSET 8 #define RCR_FIFO_OFFSET 13 @@ -1714,33 +1714,33 @@ Current IOREG MAP /* 2REG_MULTI_FUNC_CTRL(For RTL8723 Only) */ /* Enable GPIO[9] as WiFi HW PDn source */ -#define WL_HWPDN_EN BIT0 +#define WL_HWPDN_EN BIT(0) /* WiFi HW PDn polarity control */ -#define WL_HWPDN_SL BIT1 +#define WL_HWPDN_SL BIT(1) /* WiFi function enable */ -#define WL_FUNC_EN BIT2 +#define WL_FUNC_EN BIT(2) /* Enable GPIO[9] as WiFi RF HW PDn source */ -#define WL_HWROF_EN BIT3 +#define WL_HWROF_EN BIT(3) /* Enable GPIO[11] as BT HW PDn source */ -#define BT_HWPDN_EN BIT16 +#define BT_HWPDN_EN BIT(16) /* BT HW PDn polarity control */ -#define BT_HWPDN_SL BIT17 +#define BT_HWPDN_SL BIT(17) /* BT function enable */ -#define BT_FUNC_EN BIT18 +#define BT_FUNC_EN BIT(18) /* Enable GPIO[11] as BT/GPS RF HW PDn source */ -#define BT_HWROF_EN BIT19 +#define BT_HWROF_EN BIT(19) /* Enable GPIO[10] as GPS HW PDn source */ -#define GPS_HWPDN_EN BIT20 +#define GPS_HWPDN_EN BIT(20) /* GPS HW PDn polarity control */ -#define GPS_HWPDN_SL BIT21 +#define GPS_HWPDN_SL BIT(21) /* GPS function enable */ -#define GPS_FUNC_EN BIT22 +#define GPS_FUNC_EN BIT(22) /* 3 REG_LIFECTRL_CTRL */ -#define HAL92C_EN_PKT_LIFE_TIME_BK BIT3 -#define HAL92C_EN_PKT_LIFE_TIME_BE BIT2 -#define HAL92C_EN_PKT_LIFE_TIME_VI BIT1 -#define HAL92C_EN_PKT_LIFE_TIME_VO BIT0 +#define HAL92C_EN_PKT_LIFE_TIME_BK BIT(3) +#define HAL92C_EN_PKT_LIFE_TIME_BE BIT(2) +#define HAL92C_EN_PKT_LIFE_TIME_VI BIT(1) +#define HAL92C_EN_PKT_LIFE_TIME_VO BIT(0) #define HAL92C_MSDU_LIFE_TIME_UNIT 128 /* in us, said by Tim. */ @@ -1933,7 +1933,7 @@ Current IOREG MAP HSISR_GPIO9_INT) /* 2 MCUFWDL */ -#define RAM_DL_SEL BIT7 /* 1:RAM, 0:ROM */ +#define RAM_DL_SEL BIT(7) /* 1:RAM, 0:ROM */ /* 2 HPON_FSM */ @@ -2083,60 +2083,60 @@ Current IOREG MAP /* USB interrupt */ -#define UHIMR_TIMEOUT2 BIT31 -#define UHIMR_TIMEOUT1 BIT30 -#define UHIMR_PSTIMEOUT BIT29 -#define UHIMR_GTINT4 BIT28 -#define UHIMR_GTINT3 BIT27 -#define UHIMR_TXBCNERR BIT26 -#define UHIMR_TXBCNOK BIT25 -#define UHIMR_TSF_BIT32_TOGGLE BIT24 -#define UHIMR_BCNDMAINT3 BIT23 -#define UHIMR_BCNDMAINT2 BIT22 -#define UHIMR_BCNDMAINT1 BIT21 -#define UHIMR_BCNDMAINT0 BIT20 -#define UHIMR_BCNDOK3 BIT19 -#define UHIMR_BCNDOK2 BIT18 -#define UHIMR_BCNDOK1 BIT17 -#define UHIMR_BCNDOK0 BIT16 -#define UHIMR_HSISR_IND BIT15 -#define UHIMR_BCNDMAINT_E BIT14 -/* RSVD BIT13 */ -#define UHIMR_CTW_END BIT12 -/* RSVD BIT11 */ -#define UHIMR_C2HCMD BIT10 -#define UHIMR_CPWM2 BIT9 -#define UHIMR_CPWM BIT8 -#define UHIMR_HIGHDOK BIT7 /* High Queue DMA OK +#define UHIMR_TIMEOUT2 BIT(31) +#define UHIMR_TIMEOUT1 BIT(30) +#define UHIMR_PSTIMEOUT BIT(29) +#define UHIMR_GTINT4 BIT(28) +#define UHIMR_GTINT3 BIT(27) +#define UHIMR_TXBCNERR BIT(26) +#define UHIMR_TXBCNOK BIT(25) +#define UHIMR_TSF_BIT32_TOGGLE BIT(24) +#define UHIMR_BCNDMAINT3 BIT(23) +#define UHIMR_BCNDMAINT2 BIT(22) +#define UHIMR_BCNDMAINT1 BIT(21) +#define UHIMR_BCNDMAINT0 BIT(20) +#define UHIMR_BCNDOK3 BIT(19) +#define UHIMR_BCNDOK2 BIT(18) +#define UHIMR_BCNDOK1 BIT(17) +#define UHIMR_BCNDOK0 BIT(16) +#define UHIMR_HSISR_IND BIT(15) +#define UHIMR_BCNDMAINT_E BIT(14) +/* RSVD BIT(13) */ +#define UHIMR_CTW_END BIT(12) +/* RSVD BIT(11) */ +#define UHIMR_C2HCMD BIT(10) +#define UHIMR_CPWM2 BIT(9) +#define UHIMR_CPWM BIT(8) +#define UHIMR_HIGHDOK BIT(7) /* High Queue DMA OK Interrupt */ -#define UHIMR_MGNTDOK BIT6 /* Management Queue DMA OK +#define UHIMR_MGNTDOK BIT(6) /* Management Queue DMA OK Interrupt */ -#define UHIMR_BKDOK BIT5 /* AC_BK DMA OK Interrupt */ -#define UHIMR_BEDOK BIT4 /* AC_BE DMA OK Interrupt */ -#define UHIMR_VIDOK BIT3 /* AC_VI DMA OK Interrupt */ -#define UHIMR_VODOK BIT2 /* AC_VO DMA Interrupt */ -#define UHIMR_RDU BIT1 /* Receive Descriptor +#define UHIMR_BKDOK BIT(5) /* AC_BK DMA OK Interrupt */ +#define UHIMR_BEDOK BIT(4) /* AC_BE DMA OK Interrupt */ +#define UHIMR_VIDOK BIT(3) /* AC_VI DMA OK Interrupt */ +#define UHIMR_VODOK BIT(2) /* AC_VO DMA Interrupt */ +#define UHIMR_RDU BIT(1) /* Receive Descriptor Unavailable */ -#define UHIMR_ROK BIT0 /* Receive DMA OK Interrupt */ +#define UHIMR_ROK BIT(0) /* Receive DMA OK Interrupt */ /* USB Host Interrupt Status Extension bit */ -#define UHIMR_BCNDMAINT7 BIT23 -#define UHIMR_BCNDMAINT6 BIT22 -#define UHIMR_BCNDMAINT5 BIT21 -#define UHIMR_BCNDMAINT4 BIT20 -#define UHIMR_BCNDOK7 BIT19 -#define UHIMR_BCNDOK6 BIT18 -#define UHIMR_BCNDOK5 BIT17 -#define UHIMR_BCNDOK4 BIT16 +#define UHIMR_BCNDMAINT7 BIT(23) +#define UHIMR_BCNDMAINT6 BIT(22) +#define UHIMR_BCNDMAINT5 BIT(21) +#define UHIMR_BCNDMAINT4 BIT(20) +#define UHIMR_BCNDOK7 BIT(19) +#define UHIMR_BCNDOK6 BIT(18) +#define UHIMR_BCNDOK5 BIT(17) +#define UHIMR_BCNDOK4 BIT(16) /* bit14-15: RSVD */ -#define UHIMR_ATIMEND_E BIT13 -#define UHIMR_ATIMEND BIT12 -#define UHIMR_TXERR BIT11 -#define UHIMR_RXERR BIT10 -#define UHIMR_TXFOVW BIT9 -#define UHIMR_RXFOVW BIT8 +#define UHIMR_ATIMEND_E BIT(13) +#define UHIMR_ATIMEND BIT(12) +#define UHIMR_TXERR BIT(11) +#define UHIMR_RXERR BIT(10) +#define UHIMR_TXFOVW BIT(9) +#define UHIMR_RXFOVW BIT(8) /* bit2-7: RSVD */ -#define UHIMR_OCPINT BIT1 +#define UHIMR_OCPINT BIT(1) /* bit0: RSVD */ #define REG_USB_HIMR 0xFE38 -- cgit v1.2.3 From 1c3b6e7d1ba2a4fc9171f206c932fc060556d0a4 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:03:35 +0200 Subject: staging: rtl8723au: rtl8723a_bt-coexist.h: Be consistent and use BIT() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- .../rtl8723au/include/rtl8723a_bt-coexist.h | 62 +++++++++++----------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h index 1072f5eedfc8..154bb4779953 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h @@ -1363,11 +1363,11 @@ void BTDM_CheckBTIdleChange1Ant(struct rtw_adapter * padapter); /* */ /* For old core stack before v251 */ /* */ -#define BT_RSSI_STATE_NORMAL_POWER BIT0 -#define BT_RSSI_STATE_AMDPU_OFF BIT1 -#define BT_RSSI_STATE_SPECIAL_LOW BIT2 -#define BT_RSSI_STATE_BG_EDCA_LOW BIT3 -#define BT_RSSI_STATE_TXPOWER_LOW BIT4 +#define BT_RSSI_STATE_NORMAL_POWER BIT(0) +#define BT_RSSI_STATE_AMDPU_OFF BIT(1) +#define BT_RSSI_STATE_SPECIAL_LOW BIT(2) +#define BT_RSSI_STATE_BG_EDCA_LOW BIT(3) +#define BT_RSSI_STATE_TXPOWER_LOW BIT(4) #define BT_DACSWING_OFF 0 #define BT_DACSWING_M4 1 @@ -1411,61 +1411,61 @@ void BTDM_DiminishWiFi(struct rtw_adapter * Adapter, u8 bDACOn, u8 bInterruptOn, #define BT_FW_COEX_THRESH_55 55 #define BT_FW_COEX_THRESH_65 65 -#define BT_COEX_STATE_BT30 BIT(0) +#define BT_COEX_STATE_BT30 BIT(0) #define BT_COEX_STATE_WIFI_HT20 BIT(1) #define BT_COEX_STATE_WIFI_HT40 BIT(2) -#define BT_COEX_STATE_WIFI_LEGACY BIT(3) +#define BT_COEX_STATE_WIFI_LEGACY BIT(3) #define BT_COEX_STATE_WIFI_RSSI_LOW BIT(4) -#define BT_COEX_STATE_WIFI_RSSI_MEDIUM BIT(5) +#define BT_COEX_STATE_WIFI_RSSI_MEDIUM BIT(5) #define BT_COEX_STATE_WIFI_RSSI_HIGH BIT(6) #define BT_COEX_STATE_DEC_BT_POWER BIT(7) #define BT_COEX_STATE_WIFI_IDLE BIT(8) -#define BT_COEX_STATE_WIFI_UPLINK BIT(9) +#define BT_COEX_STATE_WIFI_UPLINK BIT(9) #define BT_COEX_STATE_WIFI_DOWNLINK BIT(10) -#define BT_COEX_STATE_BT_INQ_PAGE BIT(11) -#define BT_COEX_STATE_BT_IDLE BIT(12) +#define BT_COEX_STATE_BT_INQ_PAGE BIT(11) +#define BT_COEX_STATE_BT_IDLE BIT(12) #define BT_COEX_STATE_BT_UPLINK BIT(13) #define BT_COEX_STATE_BT_DOWNLINK BIT(14) /* */ /* Todo: Remove these definitions */ -#define BT_COEX_STATE_BT_PAN_IDLE BIT(15) +#define BT_COEX_STATE_BT_PAN_IDLE BIT(15) #define BT_COEX_STATE_BT_PAN_UPLINK BIT(16) -#define BT_COEX_STATE_BT_PAN_DOWNLINK BIT(17) +#define BT_COEX_STATE_BT_PAN_DOWNLINK BIT(17) #define BT_COEX_STATE_BT_A2DP_IDLE BIT(18) /* */ -#define BT_COEX_STATE_BT_RSSI_LOW BIT(19) +#define BT_COEX_STATE_BT_RSSI_LOW BIT(19) -#define BT_COEX_STATE_PROFILE_HID BIT(20) +#define BT_COEX_STATE_PROFILE_HID BIT(20) #define BT_COEX_STATE_PROFILE_A2DP BIT(21) -#define BT_COEX_STATE_PROFILE_PAN BIT(22) -#define BT_COEX_STATE_PROFILE_SCO BIT(23) +#define BT_COEX_STATE_PROFILE_PAN BIT(22) +#define BT_COEX_STATE_PROFILE_SCO BIT(23) #define BT_COEX_STATE_WIFI_RSSI_1_LOW BIT(24) #define BT_COEX_STATE_WIFI_RSSI_1_MEDIUM BIT(25) #define BT_COEX_STATE_WIFI_RSSI_1_HIGH BIT(26) -#define BT_COEX_STATE_WIFI_RSSI_BEACON_LOW BIT(27) -#define BT_COEX_STATE_WIFI_RSSI_BEACON_MEDIUM BIT(28) -#define BT_COEX_STATE_WIFI_RSSI_BEACON_HIGH BIT(29) +#define BT_COEX_STATE_WIFI_RSSI_BEACON_LOW BIT(27) +#define BT_COEX_STATE_WIFI_RSSI_BEACON_MEDIUM BIT(28) +#define BT_COEX_STATE_WIFI_RSSI_BEACON_HIGH BIT(29) -#define BT_COEX_STATE_BTINFO_COMMON BIT30 -#define BT_COEX_STATE_BTINFO_B_HID_SCOESCO BIT31 -#define BT_COEX_STATE_BTINFO_B_FTP_A2DP BIT32 +#define BT_COEX_STATE_BTINFO_COMMON BIT(30) +#define BT_COEX_STATE_BTINFO_B_HID_SCOESCO BIT(31) +#define BT_COEX_STATE_BTINFO_B_FTP_A2DP BIT(32) -#define BT_COEX_STATE_BT_CNT_LEVEL_0 BIT33 -#define BT_COEX_STATE_BT_CNT_LEVEL_1 BIT34 -#define BT_COEX_STATE_BT_CNT_LEVEL_2 BIT35 -#define BT_COEX_STATE_BT_CNT_LEVEL_3 BIT36 +#define BT_COEX_STATE_BT_CNT_LEVEL_0 BIT(33) +#define BT_COEX_STATE_BT_CNT_LEVEL_1 BIT(34) +#define BT_COEX_STATE_BT_CNT_LEVEL_2 BIT(35) +#define BT_COEX_STATE_BT_CNT_LEVEL_3 BIT(36) -#define BT_RSSI_STATE_HIGH 0 -#define BT_RSSI_STATE_MEDIUM 1 -#define BT_RSSI_STATE_LOW 2 +#define BT_RSSI_STATE_HIGH 0 +#define BT_RSSI_STATE_MEDIUM 1 +#define BT_RSSI_STATE_LOW 2 #define BT_RSSI_STATE_STAY_HIGH 3 -#define BT_RSSI_STATE_STAY_MEDIUM 4 +#define BT_RSSI_STATE_STAY_MEDIUM 4 #define BT_RSSI_STATE_STAY_LOW 5 #define BT_AGCTABLE_OFF 0 -- cgit v1.2.3 From db6ec57ba0c434d4eb16917b2fe1ab1b96f4a334 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:03:36 +0200 Subject: staging: rtl8723au: Hal8723APhyCfg.h: Use BIT() instead of BITx Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/Hal8723APhyCfg.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723au/include/Hal8723APhyCfg.h b/drivers/staging/rtl8723au/include/Hal8723APhyCfg.h index 4b7f3479c0a9..299598b53876 100644 --- a/drivers/staging/rtl8723au/include/Hal8723APhyCfg.h +++ b/drivers/staging/rtl8723au/include/Hal8723APhyCfg.h @@ -68,13 +68,13 @@ enum RF_RADIO_PATH { enum WIRELESS_MODE { WIRELESS_MODE_UNKNOWN = 0x00, - WIRELESS_MODE_A = BIT2, - WIRELESS_MODE_B = BIT0, - WIRELESS_MODE_G = BIT1, - WIRELESS_MODE_AUTO = BIT5, - WIRELESS_MODE_N_24G = BIT3, - WIRELESS_MODE_N_5G = BIT4, - WIRELESS_MODE_AC = BIT6 + WIRELESS_MODE_A = BIT(2), + WIRELESS_MODE_B = BIT(0), + WIRELESS_MODE_G = BIT(1), + WIRELESS_MODE_AUTO = BIT(5), + WIRELESS_MODE_N_24G = BIT(3), + WIRELESS_MODE_N_5G = BIT(4), + WIRELESS_MODE_AC = BIT(6) }; enum baseband_config_type { -- cgit v1.2.3 From 750c8434fedb34f7de296a4af84ae0135c050aa3 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:03:37 +0200 Subject: staging: rtl8723au: Hal8723PwrSeq.h: Use BIT() instead of BITx Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/Hal8723PwrSeq.h | 104 +++++++++++----------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/drivers/staging/rtl8723au/include/Hal8723PwrSeq.h b/drivers/staging/rtl8723au/include/Hal8723PwrSeq.h index 7f3bdea6a55e..4a1f58f2982c 100644 --- a/drivers/staging/rtl8723au/include/Hal8723PwrSeq.h +++ b/drivers/staging/rtl8723au/include/Hal8723PwrSeq.h @@ -39,71 +39,71 @@ * { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here */ #define RTL8723A_TRANS_CARDEMU_TO_ACT \ - {0x0020, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT0, BIT0}, /*0x20[0] = 1b'1 enable LDOA12 MACRO block for all interface*/ \ - {0x0067, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, 0}, /*0x67[0] = 0 to disable BT_GPS_SEL pins*/ \ + {0x0020, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(0), BIT(0)}, /*0x20[0] = 1b'1 enable LDOA12 MACRO block for all interface*/ \ + {0x0067, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(4), 0}, /*0x67[0] = 0 to disable BT_GPS_SEL pins*/ \ {0x0001, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_DELAY, 1, PWRSEQ_DELAY_MS},/*Delay 1ms*/ \ - {0x0000, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT5, 0}, /*0x00[5] = 1b'0 release analog Ips to digital , 1:isolation*/ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT2, 0},/* disable SW LPS 0x04[10]= 0*/ \ - {0x0006, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT1, BIT1},/* wait till 0x04[17] = 1 power ready*/ \ - {0x0006, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT0, BIT0},/* release WLON reset 0x04[16]= 1*/ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT7, 0},/* disable HWPDN 0x04[15]= 0*/ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, (BIT4|BIT3), 0},/* disable WL suspend*/ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT0, BIT0},/* polling until return 0*/ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT0, 0},/**/ \ - {0x004E, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT7, 1},/*0x4C[23] = 0x4E[7] = 1, switch DPDT_SEL_P output from WL BB */\ + {0x0000, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(5), 0}, /*0x00[5] = 1b'0 release analog Ips to digital , 1:isolation*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(2), 0},/* disable SW LPS 0x04[10]= 0*/ \ + {0x0006, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT(1), BIT(1)},/* wait till 0x04[17] = 1 power ready*/ \ + {0x0006, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(0), BIT(0)},/* release WLON reset 0x04[16]= 1*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(7), 0},/* disable HWPDN 0x04[15]= 0*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, (BIT(4)|BIT(3)), 0},/* disable WL suspend*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(0), BIT(0)},/* polling until return 0*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT(0), 0},/**/ \ + {0x004E, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(7), 1},/*0x4C[23] = 0x4E[7] = 1, switch DPDT_SEL_P output from WL BB */\ #define RTL8723A_TRANS_ACT_TO_CARDEMU \ {0x001F, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0},/*0x1F[7:0] = 0 turn off RF*/ \ - {0x004E, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT7, 0},/*0x4C[23] = 0x4E[7] = 0, switch DPDT_SEL_P output from register 0x65[2] */\ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT1, BIT1}, /*0x04[9] = 1 turn off MAC by HW state machine*/ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT1, 0}, /*wait till 0x04[9] = 0 polling until return 0 to disable*/ \ - {0x0000, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT5, BIT5}, /*0x00[5] = 1b'1 analog Ips to digital , 1:isolation*/ \ - {0x0020, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT0, 0}, /*0x20[0] = 1b'0 disable LDOA12 MACRO block*/ \ + {0x004E, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(7), 0},/*0x4C[23] = 0x4E[7] = 0, switch DPDT_SEL_P output from register 0x65[2] */\ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(1), BIT(1)}, /*0x04[9] = 1 turn off MAC by HW state machine*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT(1), 0}, /*wait till 0x04[9] = 0 polling until return 0 to disable*/ \ + {0x0000, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(5), BIT(5)}, /*0x00[5] = 1b'1 analog Ips to digital , 1:isolation*/ \ + {0x0020, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(0), 0}, /*0x20[0] = 1b'0 disable LDOA12 MACRO block*/ \ #define RTL8723A_TRANS_CARDEMU_TO_SUS \ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4|BIT3, (BIT4|BIT3)}, /*0x04[12:11] = 2b'11 enable WL suspend for PCIe*/ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT3|BIT4, BIT3}, /*0x04[12:11] = 2b'01 enable WL suspend*/ \ - {0x0023, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, BIT4}, /*0x23[4] = 1b'1 12H LDO enter sleep mode*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(4)|BIT(3), (BIT(4)|BIT(3))}, /*0x04[12:11] = 2b'11 enable WL suspend for PCIe*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(3)|BIT(4), BIT(3)}, /*0x04[12:11] = 2b'01 enable WL suspend*/ \ + {0x0023, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(4), BIT(4)}, /*0x23[4] = 1b'1 12H LDO enter sleep mode*/ \ {0x0007, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x20}, /*0x07[7:0] = 0x20 SDIO SOP option to disable BG/MB/ACK/SWR*/ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT3|BIT4, BIT3|BIT4}, /*0x04[12:11] = 2b'11 enable WL suspend for PCIe*/ \ - {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT0, BIT0}, /*Set SDIO suspend local register*/ \ - {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT1, 0}, /*wait power state to suspend*/ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(3)|BIT(4), BIT(3)|BIT(4)}, /*0x04[12:11] = 2b'11 enable WL suspend for PCIe*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT(0), BIT(0)}, /*Set SDIO suspend local register*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT(1), 0}, /*wait power state to suspend*/ #define RTL8723A_TRANS_SUS_TO_CARDEMU \ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT3 | BIT7, 0}, /*clear suspend enable and power down enable*/ \ - {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT0, 0}, /*Set SDIO suspend local register*/ \ - {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT1, BIT1}, /*wait power state to suspend*/\ - {0x0023, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, 0}, /*0x23[4] = 1b'0 12H LDO enter normal mode*/ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT3|BIT4, 0}, /*0x04[12:11] = 2b'01enable WL suspend*/ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(3) | BIT(7), 0}, /*clear suspend enable and power down enable*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT(0), 0}, /*Set SDIO suspend local register*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT(1), BIT(1)}, /*wait power state to suspend*/\ + {0x0023, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(4), 0}, /*0x23[4] = 1b'0 12H LDO enter normal mode*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(3)|BIT(4), 0}, /*0x04[12:11] = 2b'01enable WL suspend*/ #define RTL8723A_TRANS_CARDEMU_TO_CARDDIS \ {0x0007, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x20}, /*0x07 = 0x20 , SOP option to disable BG/MB*/ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT3|BIT4, BIT3}, /*0x04[12:11] = 2b'01 enable WL suspend*/ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT2, BIT2}, /*0x04[10] = 1, enable SW LPS*/ \ - {0x004A, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT0, 1}, /*0x48[16] = 1 to enable GPIO9 as EXT WAKEUP*/ \ - {0x0023, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, BIT4}, /*0x23[4] = 1b'1 12H LDO enter sleep mode*/ \ - {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT0, BIT0}, /*Set SDIO suspend local register*/ \ - {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT1, 0}, /*wait power state to suspend*/ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(3)|BIT(4), BIT(3)}, /*0x04[12:11] = 2b'01 enable WL suspend*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(2), BIT(2)}, /*0x04[10] = 1, enable SW LPS*/ \ + {0x004A, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(0), 1}, /*0x48[16] = 1 to enable GPIO9 as EXT WAKEUP*/ \ + {0x0023, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(4), BIT(4)}, /*0x23[4] = 1b'1 12H LDO enter sleep mode*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT(0), BIT(0)}, /*Set SDIO suspend local register*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT(1), 0}, /*wait power state to suspend*/ #define RTL8723A_TRANS_CARDDIS_TO_CARDEMU \ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT3 | BIT7, 0}, /*clear suspend enable and power down enable*/ \ - {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT0, 0}, /*Set SDIO suspend local register*/ \ - {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT1, BIT1}, /*wait power state to suspend*/\ - {0x004A, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT0, 0}, /*0x48[16] = 0 to disable GPIO9 as EXT WAKEUP*/ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT3|BIT4, 0}, /*0x04[12:11] = 2b'01enable WL suspend*/\ - {0x0023, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, 0}, /*0x23[4] = 1b'0 12H LDO enter normal mode*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(3) | BIT(7), 0}, /*clear suspend enable and power down enable*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT(0), 0}, /*Set SDIO suspend local register*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT(1), BIT(1)}, /*wait power state to suspend*/\ + {0x004A, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(0), 0}, /*0x48[16] = 0 to disable GPIO9 as EXT WAKEUP*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(3)|BIT(4), 0}, /*0x04[12:11] = 2b'01enable WL suspend*/\ + {0x0023, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(4), 0}, /*0x23[4] = 1b'0 12H LDO enter normal mode*/ \ {0x0301, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0},/*PCIe DMA start*/ #define RTL8723A_TRANS_CARDEMU_TO_PDN \ - {0x0023, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, BIT4}, /*0x23[4] = 1b'1 12H LDO enter sleep mode*/ \ + {0x0023, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(4), BIT(4)}, /*0x23[4] = 1b'1 12H LDO enter sleep mode*/ \ {0x0007, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK|PWR_INTF_USB_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x20}, /*0x07[7:0] = 0x20 SOP option to disable BG/MB/ACK/SWR*/ \ - {0x0006, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT0, 0},/* 0x04[16] = 0*/\ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT7, BIT7},/* 0x04[15] = 1*/ + {0x0006, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(0), 0},/* 0x04[16] = 0*/\ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(7), BIT(7)},/* 0x04[15] = 1*/ #define RTL8723A_TRANS_PDN_TO_CARDEMU \ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT7, 0},/* 0x04[15] = 0*/ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(7), 0},/* 0x04[15] = 0*/ #define RTL8723A_TRANS_ACT_TO_LPS \ {0x0301, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0xFF},/*PCIe DMA stop*/ \ @@ -112,25 +112,25 @@ {0x05F9, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, 0xFF, 0},/*Should be zero if no packet is transmitting*/ \ {0x05FA, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, 0xFF, 0},/*Should be zero if no packet is transmitting*/ \ {0x05FB, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, 0xFF, 0},/*Should be zero if no packet is transmitting*/ \ - {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT0, 0},/*CCK and OFDM are disabled, and clock are gated*/ \ + {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(0), 0},/*CCK and OFDM are disabled, and clock are gated*/ \ {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_DELAY, 0, PWRSEQ_DELAY_US},/*Delay 1us*/ \ - {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT1, 0},/*Whole BB is reset*/ \ + {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(1), 0},/*Whole BB is reset*/ \ {0x0100, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x03},/*Reset MAC TRX*/ \ - {0x0101, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT1, 0},/*check if removed later*/ \ + {0x0101, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(1), 0},/*check if removed later*/ \ {0x0093, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x00},/*When driver enter Sus/ Disable, enable LOP for BT*/ \ - {0x0553, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT5, BIT5},/*Respond TxOK to scheduler*/ + {0x0553, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(5), BIT(5)},/*Respond TxOK to scheduler*/ #define RTL8723A_TRANS_LPS_TO_ACT \ {0x0080, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_WRITE, 0xFF, 0x84}, /*SDIO RPWM*/\ {0xFE58, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x84}, /*USB RPWM*/\ {0x0361, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x84}, /*PCIe RPWM*/\ {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_DELAY, 0, PWRSEQ_DELAY_MS}, /*Delay*/\ - {0x0008, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, 0}, /*. 0x08[4] = 0 switch TSF to 40M*/\ - {0x0109, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT7, 0}, /*Polling 0x109[7]= 0 TSF in 40M*/\ - {0x0029, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT6|BIT7, 0}, /*. 0x29[7:6] = 2b'00 enable BB clock*/\ - {0x0101, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT1, BIT1}, /*. 0x101[1] = 1*/\ + {0x0008, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(4), 0}, /*. 0x08[4] = 0 switch TSF to 40M*/\ + {0x0109, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT(7), 0}, /*Polling 0x109[7]= 0 TSF in 40M*/\ + {0x0029, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(6)|BIT(7), 0}, /*. 0x29[7:6] = 2b'00 enable BB clock*/\ + {0x0101, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(1), BIT(1)}, /*. 0x101[1] = 1*/\ {0x0100, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0xFF}, /*. 0x100[7:0] = 0xFF enable WMAC TRX*/\ - {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT1|BIT0, BIT1|BIT0}, /*. 0x02[1:0] = 2b'11 enable BB macro*/\ + {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(1)|BIT(0), BIT(1)|BIT(0)}, /*. 0x02[1:0] = 2b'11 enable BB macro*/\ {0x0522, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0}, /*. 0x522 = 0*/ #define RTL8723A_TRANS_END \ -- cgit v1.2.3 From f709b1824ecc7b005e58028cffe1a455fbcba7d4 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:03:38 +0200 Subject: staging: rtl8723au: hal_intf.h: Be consistent and use BIT() instead of BITx Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/hal_intf.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 2159f43ca286..bf13a6a7b556 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -19,10 +19,10 @@ #include enum RTL871X_HCI_TYPE { - RTW_PCIE = BIT0, - RTW_USB = BIT1, - RTW_SDIO = BIT2, - RTW_GSPI = BIT3, + RTW_PCIE = BIT(0), + RTW_USB = BIT(1), + RTW_SDIO = BIT(2), + RTW_GSPI = BIT(3), }; enum _CHIP_TYPE { @@ -168,10 +168,10 @@ enum rt_eeprom_type { #define RF_CHANGE_BY_INIT 0 -#define RF_CHANGE_BY_IPS BIT28 -#define RF_CHANGE_BY_PS BIT29 -#define RF_CHANGE_BY_HW BIT30 -#define RF_CHANGE_BY_SW BIT31 +#define RF_CHANGE_BY_IPS BIT(28) +#define RF_CHANGE_BY_PS BIT(29) +#define RF_CHANGE_BY_HW BIT(30) +#define RF_CHANGE_BY_SW BIT(31) enum hardware_type { HARDWARE_TYPE_RTL8180, -- cgit v1.2.3 From 93748447fefa0b739be533a894abf6cb2fef4528 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:03:39 +0200 Subject: staging: rtl8723au: odm.h: Use BIT() instead of BITx Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/odm.h | 102 ++++++++++++++++---------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/drivers/staging/rtl8723au/include/odm.h b/drivers/staging/rtl8723au/include/odm.h index e809824c6a4c..c851eda14a74 100644 --- a/drivers/staging/rtl8723au/include/odm.h +++ b/drivers/staging/rtl8723au/include/odm.h @@ -371,28 +371,28 @@ enum odm_cmninfo { /* Define ODM support ability. ODM_CMNINFO_ABILITY */ enum { /* BB ODM section BIT 0-15 */ - ODM_BB_DIG = BIT0, - ODM_BB_RA_MASK = BIT1, - ODM_BB_DYNAMIC_TXPWR = BIT2, - ODM_BB_FA_CNT = BIT3, - ODM_BB_RSSI_MONITOR = BIT4, - ODM_BB_CCK_PD = BIT5, - ODM_BB_ANT_DIV = BIT6, - ODM_BB_PWR_SAVE = BIT7, - ODM_BB_PWR_TRAIN = BIT8, - ODM_BB_RATE_ADAPTIVE = BIT9, - ODM_BB_PATH_DIV = BIT10, - ODM_BB_PSD = BIT11, - ODM_BB_RXHP = BIT12, + ODM_BB_DIG = BIT(0), + ODM_BB_RA_MASK = BIT(1), + ODM_BB_DYNAMIC_TXPWR = BIT(2), + ODM_BB_FA_CNT = BIT(3), + ODM_BB_RSSI_MONITOR = BIT(4), + ODM_BB_CCK_PD = BIT(5), + ODM_BB_ANT_DIV = BIT(6), + ODM_BB_PWR_SAVE = BIT(7), + ODM_BB_PWR_TRAIN = BIT(8), + ODM_BB_RATE_ADAPTIVE = BIT(9), + ODM_BB_PATH_DIV = BIT(10), + ODM_BB_PSD = BIT(11), + ODM_BB_RXHP = BIT(12), /* MAC DM section BIT 16-23 */ - ODM_MAC_EDCA_TURBO = BIT16, - ODM_MAC_EARLY_MODE = BIT17, + ODM_MAC_EDCA_TURBO = BIT(16), + ODM_MAC_EARLY_MODE = BIT(17), /* RF ODM section BIT 24-31 */ - ODM_RF_TX_PWR_TRACK = BIT24, - ODM_RF_RX_GAIN_TRACK = BIT25, - ODM_RF_CALIBRATION = BIT26, + ODM_RF_TX_PWR_TRACK = BIT(24), + ODM_RF_RX_GAIN_TRACK = BIT(25), + ODM_RF_CALIBRATION = BIT(26), }; @@ -406,13 +406,13 @@ enum odm_interface_def { /* ODM_CMNINFO_IC_TYPE */ enum odm_ic_type_def { - ODM_RTL8192S = BIT0, - ODM_RTL8192C = BIT1, - ODM_RTL8192D = BIT2, - ODM_RTL8723A = BIT3, - ODM_RTL8188E = BIT4, - ODM_RTL8812 = BIT5, - ODM_RTL8821 = BIT6, + ODM_RTL8192S = BIT(0), + ODM_RTL8192C = BIT(1), + ODM_RTL8192D = BIT(2), + ODM_RTL8723A = BIT(3), + ODM_RTL8188E = BIT(4), + ODM_RTL8812 = BIT(5), + ODM_RTL8821 = BIT(6), }; #define ODM_IC_11N_SERIES \ @@ -439,14 +439,14 @@ enum odm_fab_version { /* ODM_CMNINFO_RF_TYPE */ /* For example 1T2R (A+AB = BIT0|BIT4|BIT5) */ enum rf_path_def { - ODM_RF_TX_A = BIT0, - ODM_RF_TX_B = BIT1, - ODM_RF_TX_C = BIT2, - ODM_RF_TX_D = BIT3, - ODM_RF_RX_A = BIT4, - ODM_RF_RX_B = BIT5, - ODM_RF_RX_C = BIT6, - ODM_RF_RX_D = BIT7, + ODM_RF_TX_A = BIT(0), + ODM_RF_TX_B = BIT(1), + ODM_RF_TX_C = BIT(2), + ODM_RF_TX_D = BIT(3), + ODM_RF_RX_A = BIT(4), + ODM_RF_RX_B = BIT(5), + ODM_RF_RX_C = BIT(6), + ODM_RF_RX_D = BIT(7), }; @@ -479,33 +479,33 @@ enum odm_bt_coexist { /* ODM_CMNINFO_OP_MODE */ enum odm_operation_mode { - ODM_NO_LINK = BIT0, - ODM_LINK = BIT1, - ODM_SCAN = BIT2, - ODM_POWERSAVE = BIT3, - ODM_AP_MODE = BIT4, - ODM_CLIENT_MODE = BIT5, - ODM_AD_HOC = BIT6, - ODM_WIFI_DIRECT = BIT7, - ODM_WIFI_DISPLAY = BIT8, + ODM_NO_LINK = BIT(0), + ODM_LINK = BIT(1), + ODM_SCAN = BIT(2), + ODM_POWERSAVE = BIT(3), + ODM_AP_MODE = BIT(4), + ODM_CLIENT_MODE = BIT(5), + ODM_AD_HOC = BIT(6), + ODM_WIFI_DIRECT = BIT(7), + ODM_WIFI_DISPLAY = BIT(8), }; /* ODM_CMNINFO_WM_MODE */ enum odm_wireless_mode { ODM_WM_UNKNOW = 0x0, - ODM_WM_B = BIT0, - ODM_WM_G = BIT1, - ODM_WM_A = BIT2, - ODM_WM_N24G = BIT3, - ODM_WM_N5G = BIT4, - ODM_WM_AUTO = BIT5, - ODM_WM_AC = BIT6, + ODM_WM_B = BIT(0), + ODM_WM_G = BIT(1), + ODM_WM_A = BIT(2), + ODM_WM_N24G = BIT(3), + ODM_WM_N5G = BIT(4), + ODM_WM_AUTO = BIT(5), + ODM_WM_AC = BIT(6), }; /* ODM_CMNINFO_BAND */ enum odm_band_type { - ODM_BAND_2_4G = BIT0, - ODM_BAND_5G = BIT1, + ODM_BAND_2_4G = BIT(0), + ODM_BAND_5G = BIT(1), }; -- cgit v1.2.3 From c04d002ac22614c0d9789c8bd80cb2bf868a9eda Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:03:40 +0200 Subject: staging: rtl8723au: odm_debug.h: Use BIT() instead of BITx Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/odm_debug.h | 42 +++++++++++++-------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/staging/rtl8723au/include/odm_debug.h b/drivers/staging/rtl8723au/include/odm_debug.h index 5bc51d09e52f..4d935a33ccb3 100644 --- a/drivers/staging/rtl8723au/include/odm_debug.h +++ b/drivers/staging/rtl8723au/include/odm_debug.h @@ -65,30 +65,30 @@ /* */ /* */ /* BB Functions */ -#define ODM_COMP_DIG BIT0 -#define ODM_COMP_RA_MASK BIT1 -#define ODM_COMP_DYNAMIC_TXPWR BIT2 -#define ODM_COMP_FA_CNT BIT3 -#define ODM_COMP_RSSI_MONITOR BIT4 -#define ODM_COMP_CCK_PD BIT5 -#define ODM_COMP_ANT_DIV BIT6 -#define ODM_COMP_PWR_SAVE BIT7 -#define ODM_COMP_PWR_TRAIN BIT8 -#define ODM_COMP_RATE_ADAPTIVE BIT9 -#define ODM_COMP_PATH_DIV BIT10 -#define ODM_COMP_PSD BIT11 -#define ODM_COMP_DYNAMIC_PRICCA BIT12 -#define ODM_COMP_RXHP BIT13 +#define ODM_COMP_DIG BIT(0) +#define ODM_COMP_RA_MASK BIT(1) +#define ODM_COMP_DYNAMIC_TXPWR BIT(2) +#define ODM_COMP_FA_CNT BIT(3) +#define ODM_COMP_RSSI_MONITOR BIT(4) +#define ODM_COMP_CCK_PD BIT(5) +#define ODM_COMP_ANT_DIV BIT(6) +#define ODM_COMP_PWR_SAVE BIT(7) +#define ODM_COMP_PWR_TRAIN BIT(8) +#define ODM_COMP_RATE_ADAPTIVE BIT(9) +#define ODM_COMP_PATH_DIV BIT(10) +#define ODM_COMP_PSD BIT(11) +#define ODM_COMP_DYNAMIC_PRICCA BIT(12) +#define ODM_COMP_RXHP BIT(13) /* MAC Functions */ -#define ODM_COMP_EDCA_TURBO BIT16 -#define ODM_COMP_EARLY_MODE BIT17 +#define ODM_COMP_EDCA_TURBO BIT(16) +#define ODM_COMP_EARLY_MODE BIT(17) /* RF Functions */ -#define ODM_COMP_TX_PWR_TRACK BIT24 -#define ODM_COMP_RX_GAIN_TRACK BIT25 -#define ODM_COMP_CALIBRATION BIT26 +#define ODM_COMP_TX_PWR_TRACK BIT(24) +#define ODM_COMP_RX_GAIN_TRACK BIT(25) +#define ODM_COMP_CALIBRATION BIT(26) /* Common Functions */ -#define ODM_COMP_COMMON BIT30 -#define ODM_COMP_INIT BIT31 +#define ODM_COMP_COMMON BIT(30) +#define ODM_COMP_INIT BIT(31) /*------------------------Export Macro Definition---------------------------*/ #define DbgPrint printk -- cgit v1.2.3 From e478c1f52d9237a8895b54118b65df6e148ff8c5 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:03:41 +0200 Subject: staging: rtl8723au: odm_reg.h: Use BIT() instead of BITx Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/odm_reg.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723au/include/odm_reg.h b/drivers/staging/rtl8723au/include/odm_reg.h index 56191e9fdcdb..c18433120fe8 100644 --- a/drivers/staging/rtl8723au/include/odm_reg.h +++ b/drivers/staging/rtl8723au/include/odm_reg.h @@ -102,13 +102,10 @@ #define PATHDIV_REG 0xB30 #define PATHDIV_TRI 0xBA0 - /* */ /* Bitmap Definition */ /* */ -#define BIT_FA_RESET BIT0 - - +#define BIT_FA_RESET BIT(0) #endif -- cgit v1.2.3 From 68c9da90fe0de25b02db8111036d290376ce890a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:03:42 +0200 Subject: staging: rtl8723au: rtw_sreset.h: Use BIT() instead of BITx Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtw_sreset.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723au/include/rtw_sreset.h b/drivers/staging/rtl8723au/include/rtw_sreset.h index 4c523722dd14..91d57e2791d9 100644 --- a/drivers/staging/rtl8723au/include/rtw_sreset.h +++ b/drivers/staging/rtl8723au/include/rtw_sreset.h @@ -36,14 +36,14 @@ struct sreset_priv { #include -#define WIFI_STATUS_SUCCESS 0 -#define USB_VEN_REQ_CMD_FAIL BIT0 -#define USB_READ_PORT_FAIL BIT1 -#define USB_WRITE_PORT_FAIL BIT2 -#define WIFI_MAC_TXDMA_ERROR BIT3 -#define WIFI_TX_HANG BIT4 -#define WIFI_RX_HANG BIT5 -#define WIFI_IF_NOT_EXIST BIT6 +#define WIFI_STATUS_SUCCESS 0 +#define USB_VEN_REQ_CMD_FAIL BIT(0) +#define USB_READ_PORT_FAIL BIT(1) +#define USB_WRITE_PORT_FAIL BIT(2) +#define WIFI_MAC_TXDMA_ERROR BIT(3) +#define WIFI_TX_HANG BIT(4) +#define WIFI_RX_HANG BIT(5) +#define WIFI_IF_NOT_EXIST BIT(6) void sreset_init_value23a(struct rtw_adapter *padapter); void sreset_reset_value23a(struct rtw_adapter *padapter); -- cgit v1.2.3 From f8c41a92fb741e1592801223bd75b432dca7ae4b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:03:43 +0200 Subject: staging: rtl8723au: rtl8723au_led.c: Use BIT() instead of BITx Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723au_led.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_led.c b/drivers/staging/rtl8723au/hal/rtl8723au_led.c index 4d5c909487f8..b06905d019d3 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723au_led.c +++ b/drivers/staging/rtl8723au/hal/rtl8723au_led.c @@ -41,14 +41,17 @@ void SwLedOn23a(struct rtw_adapter *padapter, struct led_8723a *pLed) case LED_PIN_GPIO0: break; case LED_PIN_LED0: - rtw_write8(padapter, REG_LEDCFG0, (LedCfg&0xf0)|BIT5|BIT6); /* SW control led0 on. */ + /* SW control led0 on. */ + rtw_write8(padapter, REG_LEDCFG0, (LedCfg&0xf0)|BIT(5)|BIT(6)); break; case LED_PIN_LED1: - rtw_write8(padapter, REG_LEDCFG1, (LedCfg&0x00)|BIT6); /* SW control led1 on. */ + /* SW control led1 on. */ + rtw_write8(padapter, REG_LEDCFG1, (LedCfg&0x00)|BIT(6)); break; case LED_PIN_LED2: LedCfg = rtw_read8(padapter, REG_LEDCFG2); - rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0x80)|BIT5); /* SW control led1 on. */ + /* SW control led1 on. */ + rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0x80)|BIT(5)); break; default: break; @@ -70,14 +73,17 @@ void SwLedOff23a(struct rtw_adapter *padapter, struct led_8723a *pLed) case LED_PIN_GPIO0: break; case LED_PIN_LED0: - rtw_write8(padapter, REG_LEDCFG0, (LedCfg&0xf0)|BIT5|BIT6); /* SW control led0 on. */ + /* SW control led0 on. */ + rtw_write8(padapter, REG_LEDCFG0, (LedCfg&0xf0)|BIT(5)|BIT(6)); break; case LED_PIN_LED1: - rtw_write8(padapter, REG_LEDCFG1, (LedCfg&0x00)|BIT5|BIT6); /* SW control led1 on. */ + /* SW control led1 on. */ + rtw_write8(padapter, REG_LEDCFG1, (LedCfg&0x00)|BIT(5)|BIT(6)); break; case LED_PIN_LED2: LedCfg = rtw_read8(padapter, REG_LEDCFG2); - rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0x80)|BIT3|BIT5); /* SW control led1 on. */ + /* SW control led1 on. */ + rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0x80)|BIT(3)|BIT(5)); break; default: break; -- cgit v1.2.3 From 05f07e7d4d898b7211fd2d7ebedbd6fc4fd77a95 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:03:44 +0200 Subject: staging: rtl8723au: usb_halinit.c: Use BIT() instead of BITx Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_halinit.c | 36 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index f34d5a40f349..93b71d380841 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -119,7 +119,7 @@ static u8 _InitPowerOn(struct rtw_adapter *padapter) /* 0x04[19] = 1, suggest by Jackie 2011.05.09, reset 8051 */ value8 = rtw_read8(padapter, REG_APS_FSMCO+2); - rtw_write8(padapter, REG_APS_FSMCO + 2, (value8 | BIT3)); + rtw_write8(padapter, REG_APS_FSMCO + 2, value8 | BIT(3)); /* Enable MAC DMA/WMAC/SCHEDULE/SEC block */ /* Set CR bit10 to enable 32k calibration. Suggested by SD1 Gimmy. @@ -131,7 +131,7 @@ static u8 _InitPowerOn(struct rtw_adapter *padapter) rtw_write16(padapter, REG_CR, value16); /* for Efuse PG, suggest by Jackie 2011.11.23 */ - PHY_SetBBReg(padapter, REG_EFUSE_CTRL, BIT28|BIT29|BIT30, 0x06); + PHY_SetBBReg(padapter, REG_EFUSE_CTRL, BIT(28)|BIT(29)|BIT(30), 0x06); return status; } @@ -601,13 +601,13 @@ enum rt_rf_power_state RfOnOffDetect23a(struct rtw_adapter *pAdapter) if (pAdapter->pwrctrlpriv.bHWPowerdown) { val8 = rtw_read8(pAdapter, REG_HSISR); DBG_8723A("pwrdown, 0x5c(BIT7) =%02x\n", val8); - rfpowerstate = (val8 & BIT7) ? rf_off : rf_on; + rfpowerstate = (val8 & BIT(7)) ? rf_off : rf_on; } else { /* rf on/off */ rtw_write8(pAdapter, REG_MAC_PINMUX_CFG, - rtw_read8(pAdapter, REG_MAC_PINMUX_CFG) & ~BIT3); + rtw_read8(pAdapter, REG_MAC_PINMUX_CFG) & ~BIT(3)); val8 = rtw_read8(pAdapter, REG_GPIO_IO_SEL); DBG_8723A("GPIO_IN =%02x\n", val8); - rfpowerstate = (val8 & BIT3) ? rf_on : rf_off; + rfpowerstate = (val8 & BIT(3)) ? rf_on : rf_off; } return rfpowerstate; } /* HalDetectPwrDownMode */ @@ -924,7 +924,7 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, /* 2. Force PWM, Enable SPS18_LDO_Marco_Block */ rtw_write8(Adapter, REG_SPS0_CTRL, rtw_read8(Adapter, REG_SPS0_CTRL) | - (BIT0|BIT3)); + BIT(0) | BIT(3)); /* 3. restore BB, AFE control register. */ /* RF */ @@ -935,7 +935,7 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, PHY_SetBBReg(Adapter, rFPGA0_XAB_RFParameter, 0x38, 1); PHY_SetBBReg(Adapter, rOFDM0_TRxPathEnable, 0xf0, 1); - PHY_SetBBReg(Adapter, rFPGA0_RFMOD, BIT1, 0); + PHY_SetBBReg(Adapter, rFPGA0_RFMOD, BIT(1), 0); /* AFE */ if (pHalData->rf_type == RF_2T2R) @@ -968,7 +968,7 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, /* 2. Force PWM, Enable SPS18_LDO_Marco_Block */ rtw_write8(Adapter, REG_SPS0_CTRL, rtw_read8(Adapter, REG_SPS0_CTRL) | - (BIT0|BIT3)); + BIT(0) | BIT(3)); /* 3. restore BB, AFE control register. */ /* RF */ @@ -979,7 +979,7 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, PHY_SetBBReg(Adapter, rFPGA0_XAB_RFParameter, 0x38, 1); PHY_SetBBReg(Adapter, rOFDM0_TRxPathEnable, 0xf0, 1); - PHY_SetBBReg(Adapter, rFPGA0_RFMOD, BIT1, 0); + PHY_SetBBReg(Adapter, rFPGA0_RFMOD, BIT(1), 0); /* AFE */ if (pHalData->rf_type == RF_2T2R) @@ -1002,7 +1002,7 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, /* 5. gated MAC Clock */ bytetmp = rtw_read8(Adapter, REG_APSD_CTRL); - rtw_write8(Adapter, REG_APSD_CTRL, bytetmp & ~BIT6); + rtw_write8(Adapter, REG_APSD_CTRL, bytetmp & ~BIT(6)); mdelay(10); @@ -1017,9 +1017,9 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, case rf_off: value8 = rtw_read8(Adapter, REG_SPS0_CTRL) ; if (IS_81xxC_VENDOR_UMC_B_CUT(pHalData->VersionID)) - value8 &= ~(BIT0); + value8 &= ~BIT(0); else - value8 &= ~(BIT0|BIT3); + value8 &= ~(BIT(0) | BIT(3)); if (bRegSSPwrLvl == 1) { RT_TRACE(_module_hal_init_c_, _drv_err_, ("SS LVL1\n")); /* Disable RF and BB only for SelectSuspend. */ @@ -1049,7 +1049,7 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, 0x38, 0); } PHY_SetBBReg(Adapter, rOFDM0_TRxPathEnable, 0xf0, 0); - PHY_SetBBReg(Adapter, rFPGA0_RFMOD, BIT1, 1); + PHY_SetBBReg(Adapter, rFPGA0_RFMOD, BIT(1), 1); /* 2 .AFE control register to power down. bit[30:22] */ Adapter->pwrctrlpriv.PS_BBRegBackup[PSBBREG_AFE0] = @@ -1120,7 +1120,7 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, PHY_SetBBReg(Adapter, rFPGA0_XAB_RFParameter, 0x38, 0); PHY_SetBBReg(Adapter, rOFDM0_TRxPathEnable, 0xf0, 0); - PHY_SetBBReg(Adapter, rFPGA0_RFMOD, BIT1, 1); + PHY_SetBBReg(Adapter, rFPGA0_RFMOD, BIT(1), 1); /* 2 .AFE control register to power down. bit[30:22] */ Adapter->pwrctrlpriv.PS_BBRegBackup[PSBBREG_AFE0] = @@ -1179,13 +1179,13 @@ static void CardDisableRTL8723U(struct rtw_adapter *Adapter) rtw_write8(Adapter, REG_RF_CTRL, 0x00); /* ==== Reset digital sequence ====== */ - if ((rtw_read8(Adapter, REG_MCUFWDL)&BIT7) && + if ((rtw_read8(Adapter, REG_MCUFWDL) & BIT(7)) && Adapter->bFWReady) /* 8051 RAM code */ rtl8723a_FirmwareSelfReset(Adapter); /* Reset MCU. Suggested by Filen. 2011.01.26. by tynli. */ u1bTmp = rtw_read8(Adapter, REG_SYS_FUNC_EN+1); - rtw_write8(Adapter, REG_SYS_FUNC_EN+1, (u1bTmp & (~BIT2))); + rtw_write8(Adapter, REG_SYS_FUNC_EN+1, u1bTmp & ~BIT(2)); /* g. MCUFWDL 0x80[1:0]= 0 reset MCU ready status */ rtw_write8(Adapter, REG_MCUFWDL, 0x00); @@ -1198,9 +1198,9 @@ static void CardDisableRTL8723U(struct rtw_adapter *Adapter) /* Reset MCU IO Wrapper, added by Roger, 2011.08.30. */ u1bTmp = rtw_read8(Adapter, REG_RSV_CTRL + 1); - rtw_write8(Adapter, REG_RSV_CTRL+1, (u1bTmp & (~BIT0))); + rtw_write8(Adapter, REG_RSV_CTRL+1, u1bTmp & ~BIT(0)); u1bTmp = rtw_read8(Adapter, REG_RSV_CTRL + 1); - rtw_write8(Adapter, REG_RSV_CTRL+1, u1bTmp | BIT0); + rtw_write8(Adapter, REG_RSV_CTRL+1, u1bTmp | BIT(0)); /* 7. RSV_CTRL 0x1C[7:0] = 0x0E lock ISO/CLK/Power control register */ rtw_write8(Adapter, REG_RSV_CTRL, 0x0e); -- cgit v1.2.3 From 8952e08d4adbf0999f2ed9180752940bc0001ce8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:03:45 +0200 Subject: staging: rtl8723au: rtl8723a_bt-coexist.c: Be consistent in use of BIT() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index 32f8875f2a4f..8e1eb81284a9 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -9530,7 +9530,8 @@ static void BTDM_Display8723ABtCoexInfo(struct rtw_adapter *padapter) btInfoExt = pHalData->bt_coexist.halCoex8723.btInfoExt; rsprintf(btCoexDbgBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "A2DP rate", \ - (btInfoExt&BIT0) ? "Basic rate" : "EDR rate"); + (btInfoExt & BIT(0)) ? + "Basic rate" : "EDR rate"); DCMD_Printf(btCoexDbgBuf); } else { rsprintf(btCoexDbgBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s", "Bt link type/spec", \ -- cgit v1.2.3 From d66ecc271c42b4f3d618d76c98407812a2c6300e Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:03:46 +0200 Subject: staging: rtl8723au: hal_com.c: Use BIT() consistently instead of BITx Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_com.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index 8e08977e929b..bb948e595be3 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -760,14 +760,14 @@ void rtl8723a_bcn_valid(struct rtw_adapter *padapter) /* BCN_VALID, BIT16 of REG_TDECTRL = BIT0 of REG_TDECTRL+2, write 1 to clear, Clear by sw */ rtw_write8(padapter, REG_TDECTRL + 2, - rtw_read8(padapter, REG_TDECTRL + 2) | BIT0); + rtw_read8(padapter, REG_TDECTRL + 2) | BIT(0)); } bool rtl8723a_get_bcn_valid(struct rtw_adapter *padapter) { bool retval; - retval = (rtw_read8(padapter, REG_TDECTRL + 2) & BIT0) ? true : false; + retval = (rtw_read8(padapter, REG_TDECTRL + 2) & BIT(0)) ? true : false; return retval; } -- cgit v1.2.3 From a3f214622ddfa2b2a5b85a4959c3a17a2d3cc21c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:03:47 +0200 Subject: staging: rtl8723au: HalDMOutSrt8723A_CE.c: Use BIT() instead of BITx Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723au/hal/HalDMOutSrc8723A_CE.c | 63 ++++++++++++++-------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/HalDMOutSrc8723A_CE.c b/drivers/staging/rtl8723au/hal/HalDMOutSrc8723A_CE.c index 9796f2e5c68f..9007cd3c8333 100644 --- a/drivers/staging/rtl8723au/hal/HalDMOutSrc8723A_CE.c +++ b/drivers/staging/rtl8723au/hal/HalDMOutSrc8723A_CE.c @@ -252,14 +252,20 @@ odm_TXPowerTrackingCallback_ThermalMeter_92C( PHY_SetBBReg(Adapter, rOFDM0_XCTxAFE, bMaskH4Bits, value32); value32 = ((X * ele_D)>>7)&0x01; - PHY_SetBBReg(Adapter, rOFDM0_ECCAThreshold, BIT31, value32); + PHY_SetBBReg(Adapter, rOFDM0_ECCAThreshold, + BIT(31), value32); value32 = ((Y * ele_D)>>7)&0x01; - PHY_SetBBReg(Adapter, rOFDM0_ECCAThreshold, BIT29, value32); + PHY_SetBBReg(Adapter, rOFDM0_ECCAThreshold, + BIT(29), value32); } else { - PHY_SetBBReg(Adapter, rOFDM0_XATxIQImbalance, bMaskDWord, OFDMSwingTable23A[OFDM_index[0]]); - PHY_SetBBReg(Adapter, rOFDM0_XCTxAFE, bMaskH4Bits, 0x00); - PHY_SetBBReg(Adapter, rOFDM0_ECCAThreshold, BIT31|BIT29, 0x00); + PHY_SetBBReg(Adapter, rOFDM0_XATxIQImbalance, + bMaskDWord, + OFDMSwingTable23A[OFDM_index[0]]); + PHY_SetBBReg(Adapter, rOFDM0_XCTxAFE, + bMaskH4Bits, 0x00); + PHY_SetBBReg(Adapter, rOFDM0_ECCAThreshold, + BIT(31) | BIT(29), 0x00); } /* Adjust CCK according to IQK result */ @@ -308,14 +314,25 @@ odm_TXPowerTrackingCallback_ThermalMeter_92C( PHY_SetBBReg(Adapter, rOFDM0_XDTxAFE, bMaskH4Bits, value32); value32 = ((X * ele_D)>>7)&0x01; - PHY_SetBBReg(Adapter, rOFDM0_ECCAThreshold, BIT27, value32); + PHY_SetBBReg(Adapter, + rOFDM0_ECCAThreshold, + BIT(27), value32); value32 = ((Y * ele_D)>>7)&0x01; - PHY_SetBBReg(Adapter, rOFDM0_ECCAThreshold, BIT25, value32); + PHY_SetBBReg(Adapter, + rOFDM0_ECCAThreshold, + BIT(25), value32); } else { - PHY_SetBBReg(Adapter, rOFDM0_XBTxIQImbalance, bMaskDWord, OFDMSwingTable23A[OFDM_index[1]]); - PHY_SetBBReg(Adapter, rOFDM0_XDTxAFE, bMaskH4Bits, 0x00); - PHY_SetBBReg(Adapter, rOFDM0_ECCAThreshold, BIT27|BIT25, 0x00); + PHY_SetBBReg(Adapter, + rOFDM0_XBTxIQImbalance, + bMaskDWord, + OFDMSwingTable23A[OFDM_index[1]]); + PHY_SetBBReg(Adapter, + rOFDM0_XDTxAFE, + bMaskH4Bits, 0x00); + PHY_SetBBReg(Adapter, + rOFDM0_ECCAThreshold, + BIT(27) | BIT(25), 0x00); } } @@ -410,14 +427,14 @@ static u8 _PHY_PathA_IQK(struct rtw_adapter *pAdapter, bool configPathB) regE9C = PHY_QueryBBReg(pAdapter, rTx_Power_After_IQK_A, bMaskDWord); regEA4 = PHY_QueryBBReg(pAdapter, rRx_Power_Before_IQK_A_2, bMaskDWord); - if (!(regEAC & BIT28) && + if (!(regEAC & BIT(28)) && (((regE94 & 0x03FF0000)>>16) != 0x142) && (((regE9C & 0x03FF0000)>>16) != 0x42)) result |= 0x01; else /* if Tx not OK, ignore Rx */ return result; - if (!(regEAC & BIT27) && /* if Tx is OK, check whether Rx is OK */ + if (!(regEAC & BIT(27)) && /* if Tx is OK, check whether Rx is OK */ (((regEA4 & 0x03FF0000)>>16) != 0x132) && (((regEAC & 0x03FF0000)>>16) != 0x36)) result |= 0x02; @@ -445,14 +462,14 @@ static u8 _PHY_PathB_IQK(struct rtw_adapter *pAdapter) regEC4 = PHY_QueryBBReg(pAdapter, rRx_Power_Before_IQK_B_2, bMaskDWord); regECC = PHY_QueryBBReg(pAdapter, rRx_Power_After_IQK_B_2, bMaskDWord); - if (!(regEAC & BIT31) && + if (!(regEAC & BIT(31)) && (((regEB4 & 0x03FF0000)>>16) != 0x142) && (((regEBC & 0x03FF0000)>>16) != 0x42)) result |= 0x01; else return result; - if (!(regEAC & BIT30) && + if (!(regEAC & BIT(30)) && (((regEC4 & 0x03FF0000)>>16) != 0x132) && (((regECC & 0x03FF0000)>>16) != 0x36)) result |= 0x02; @@ -612,9 +629,9 @@ static void _PHY_MACSettingCalibration(struct rtw_adapter *pAdapter, u32 *MACReg rtw_write8(pAdapter, MACReg[i], 0x3F); for (i = 1 ; i < (IQK_MAC_REG_NUM - 1); i++) { - rtw_write8(pAdapter, MACReg[i], (u8)(MACBackup[i]&(~BIT3))); + rtw_write8(pAdapter, MACReg[i], (u8)(MACBackup[i] & ~BIT(3))); } - rtw_write8(pAdapter, MACReg[i], (u8)(MACBackup[i]&(~BIT5))); + rtw_write8(pAdapter, MACReg[i], (u8)(MACBackup[i] & ~BIT(5))); } static void _PHY_PathAStandBy(struct rtw_adapter *pAdapter) @@ -737,21 +754,23 @@ static void _PHY_IQCalibrate(struct rtw_adapter *pAdapter, int result[][8], u8 t _PHY_PathADDAOn(pAdapter, ADDA_REG, true, is2T); if (t == 0) - pdmpriv->bRfPiEnable = (u8)PHY_QueryBBReg(pAdapter, rFPGA0_XA_HSSIParameter1, BIT(8)); + pdmpriv->bRfPiEnable = (u8) + PHY_QueryBBReg(pAdapter, rFPGA0_XA_HSSIParameter1, + BIT(8)); if (!pdmpriv->bRfPiEnable) { /* Switch BB to PI mode to do IQ Calibration. */ _PHY_PIModeSwitch(pAdapter, true); } - PHY_SetBBReg(pAdapter, rFPGA0_RFMOD, BIT24, 0x00); + PHY_SetBBReg(pAdapter, rFPGA0_RFMOD, BIT(24), 0x00); PHY_SetBBReg(pAdapter, rOFDM0_TRxPathEnable, bMaskDWord, 0x03a05600); PHY_SetBBReg(pAdapter, rOFDM0_TRMuxPar, bMaskDWord, 0x000800e4); PHY_SetBBReg(pAdapter, rFPGA0_XCD_RFInterfaceSW, bMaskDWord, 0x22204000); - PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT10, 0x01); - PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT26, 0x01); - PHY_SetBBReg(pAdapter, rFPGA0_XA_RFInterfaceOE, BIT10, 0x00); - PHY_SetBBReg(pAdapter, rFPGA0_XB_RFInterfaceOE, BIT10, 0x00); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT(10), 0x01); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT(26), 0x01); + PHY_SetBBReg(pAdapter, rFPGA0_XA_RFInterfaceOE, BIT(10), 0x00); + PHY_SetBBReg(pAdapter, rFPGA0_XB_RFInterfaceOE, BIT(10), 0x00); if (is2T) { PHY_SetBBReg(pAdapter, rFPGA0_XA_LSSIParameter, bMaskDWord, 0x00010000); -- cgit v1.2.3 From 8f7654c18af7bc7a8f4e97630fd4090c5226ebf7 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:03:48 +0200 Subject: staging: rtl8723au: rtl8723a_phycfg.c: Use BIT() instead of BITx Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c b/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c index 5be4d83b8402..2ac780e9feae 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c @@ -212,10 +212,12 @@ phy_RFSerialRead(struct rtw_adapter *Adapter, enum RF_RADIO_PATH eRFPath, if (eRFPath == RF_PATH_A) RfPiEnable = (u8)PHY_QueryBBReg(Adapter, - rFPGA0_XA_HSSIParameter1, BIT8); + rFPGA0_XA_HSSIParameter1, + BIT(8)); else if (eRFPath == RF_PATH_B) RfPiEnable = (u8)PHY_QueryBBReg(Adapter, - rFPGA0_XB_HSSIParameter1, BIT8); + rFPGA0_XB_HSSIParameter1, + BIT(8)); if (RfPiEnable) { /* Read from BBreg8b8, 12 bits for 8190, 20bits for T65 RF */ @@ -804,7 +806,7 @@ PHY_BBConfig8723A(struct rtw_adapter *Adapter) /* 1. 0x28[1] = 1 */ TmpU1B = rtw_read8(Adapter, REG_AFE_PLL_CTRL); udelay(2); - rtw_write8(Adapter, REG_AFE_PLL_CTRL, (TmpU1B|BIT1)); + rtw_write8(Adapter, REG_AFE_PLL_CTRL, TmpU1B | BIT(1)); udelay(2); /* 2. 0x29[7:0] = 0xFF */ @@ -818,11 +820,11 @@ PHY_BBConfig8723A(struct rtw_adapter *Adapter) /* 4. 0x25[6] = 0 */ TmpU1B = rtw_read8(Adapter, REG_AFE_XTAL_CTRL + 1); - rtw_write8(Adapter, REG_AFE_XTAL_CTRL+1, (TmpU1B & (~BIT6))); + rtw_write8(Adapter, REG_AFE_XTAL_CTRL+1, TmpU1B & ~BIT(6)); /* 5. 0x24[20] = 0 Advised by SD3 Alex Wang. 2011.02.09. */ TmpU1B = rtw_read8(Adapter, REG_AFE_XTAL_CTRL+2); - rtw_write8(Adapter, REG_AFE_XTAL_CTRL+2, (TmpU1B & (~BIT4))); + rtw_write8(Adapter, REG_AFE_XTAL_CTRL+2, TmpU1B & ~BIT(4)); /* 6. 0x1f[7:0] = 0x07 */ rtw_write8(Adapter, REG_RF_CTRL, 0x07); @@ -982,7 +984,7 @@ _PHY_SetBWMode23a92C(struct rtw_adapter *Adapter) case HT_CHANNEL_WIDTH_20: PHY_SetBBReg(Adapter, rFPGA0_RFMOD, bRFMOD, 0x0); PHY_SetBBReg(Adapter, rFPGA1_RFMOD, bRFMOD, 0x0); - PHY_SetBBReg(Adapter, rFPGA0_AnalogParameter2, BIT10, 1); + PHY_SetBBReg(Adapter, rFPGA0_AnalogParameter2, BIT(10), 1); break; @@ -997,9 +999,9 @@ _PHY_SetBWMode23a92C(struct rtw_adapter *Adapter) (pHalData->nCur40MhzPrimeSC >> 1)); PHY_SetBBReg(Adapter, rOFDM1_LSTF, 0xC00, pHalData->nCur40MhzPrimeSC); - PHY_SetBBReg(Adapter, rFPGA0_AnalogParameter2, BIT10, 0); + PHY_SetBBReg(Adapter, rFPGA0_AnalogParameter2, BIT(10), 0); - PHY_SetBBReg(Adapter, 0x818, (BIT26 | BIT27), + PHY_SetBBReg(Adapter, 0x818, BIT(26) | BIT(27), (pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) ? 2:1); break; -- cgit v1.2.3 From bc0d10cb1e4ffd672bcb88281e0724eacf9ee206 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:03:49 +0200 Subject: staging: rtl8723au: rtl8723a_hal_init.c: Use BIT() consistently Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 5a0a368ec64e..55e3a6923910 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -251,7 +251,7 @@ void rtl8723a_FirmwareSelfReset(struct rtw_adapter *padapter) rtw_write8(padapter, REG_HMETFR + 3, 0x20); u1bTmp = rtw_read8(padapter, REG_SYS_FUNC_EN + 1); - while (u1bTmp & BIT2) { + while (u1bTmp & BIT(2)) { Delay--; if (Delay == 0) break; @@ -266,7 +266,7 @@ void rtl8723a_FirmwareSelfReset(struct rtw_adapter *padapter) /* force firmware reset */ u1bTmp = rtw_read8(padapter, REG_SYS_FUNC_EN + 1); rtw_write8(padapter, REG_SYS_FUNC_EN + 1, - u1bTmp & (~BIT2)); + u1bTmp & ~BIT(2)); } } } @@ -996,7 +996,7 @@ Hal_EfuseWordEnableDataWrite(struct rtw_adapter *padapter, efuse_OneByteRead23a(padapter, tmpaddr, &tmpdata[0]); efuse_OneByteRead23a(padapter, tmpaddr + 1, &tmpdata[1]); if ((data[0] != tmpdata[0]) || (data[1] != tmpdata[1])) { - badworden &= (~BIT(0)); + badworden &= ~BIT(0); } } if (!(word_en & BIT(1))) { @@ -1007,7 +1007,7 @@ Hal_EfuseWordEnableDataWrite(struct rtw_adapter *padapter, efuse_OneByteRead23a(padapter, tmpaddr, &tmpdata[2]); efuse_OneByteRead23a(padapter, tmpaddr + 1, &tmpdata[3]); if ((data[2] != tmpdata[2]) || (data[3] != tmpdata[3])) { - badworden &= (~BIT(1)); + badworden &= ~BIT(1); } } if (!(word_en & BIT(2))) { @@ -1018,7 +1018,7 @@ Hal_EfuseWordEnableDataWrite(struct rtw_adapter *padapter, efuse_OneByteRead23a(padapter, tmpaddr, &tmpdata[4]); efuse_OneByteRead23a(padapter, tmpaddr + 1, &tmpdata[5]); if ((data[4] != tmpdata[4]) || (data[5] != tmpdata[5])) { - badworden &= (~BIT(2)); + badworden &= ~BIT(2); } } if (!(word_en & BIT(3))) { @@ -1029,7 +1029,7 @@ Hal_EfuseWordEnableDataWrite(struct rtw_adapter *padapter, efuse_OneByteRead23a(padapter, tmpaddr, &tmpdata[6]); efuse_OneByteRead23a(padapter, tmpaddr + 1, &tmpdata[7]); if ((data[6] != tmpdata[6]) || (data[7] != tmpdata[7])) { - badworden &= (~BIT(3)); + badworden &= ~BIT(3); } } @@ -1644,11 +1644,11 @@ static void hal_notch_filter_8723a(struct rtw_adapter *adapter, bool enable) if (enable) { DBG_8723A("Enable notch filter\n"); rtw_write8(adapter, rOFDM0_RxDSP + 1, - rtw_read8(adapter, rOFDM0_RxDSP + 1) | BIT1); + rtw_read8(adapter, rOFDM0_RxDSP + 1) | BIT(1)); } else { DBG_8723A("Disable notch filter\n"); rtw_write8(adapter, rOFDM0_RxDSP + 1, - rtw_read8(adapter, rOFDM0_RxDSP + 1) & ~BIT1); + rtw_read8(adapter, rOFDM0_RxDSP + 1) & ~BIT(1)); } } @@ -2037,7 +2037,7 @@ static void _ResetDigitalProcedure1_92C(struct rtw_adapter *padapter, S3/S4/S5/Disable, we can stop 8051 because */ /* we will init FW when power on again. */ /* If we want to SS mode, we can not reset 8051. */ - if (rtw_read8(padapter, REG_MCUFWDL) & BIT1) { + if (rtw_read8(padapter, REG_MCUFWDL) & BIT(1)) { /* IF fw in RAM code, do reset */ if (padapter->bFWReady) { /* 2010/08/25 MH Accordign to RD alfred's @@ -2140,7 +2140,7 @@ static void _DisableAnalog(struct rtw_adapter *padapter, bool bWithoutHWSM) ******************************/ value8 = 0x23; if (IS_81xxC_VENDOR_UMC_B_CUT(pHalData->VersionID)) - value8 |= BIT3; + value8 |= BIT(3); rtw_write8(padapter, REG_SPS0_CTRL, value8); @@ -2340,7 +2340,7 @@ Hal_ReadPowerValueFromPROM_8723A(struct txpowerinfo *pwrInfo, [EEPROM_HT20_TX_PWR_INX_DIFF_8723A + group] >> (rfPath * 4)) & 0xF; /* 4bit sign number to 8 bit sign number */ - if (pwrInfo->HT20IndexDiff[rfPath][group] & BIT3) + if (pwrInfo->HT20IndexDiff[rfPath][group] & BIT(3)) pwrInfo->HT20IndexDiff[rfPath][group] |= 0xF0; pwrInfo->OFDMIndexDiff[rfPath][group] = -- cgit v1.2.3 From fc8b7c8cac39410896385b47cffd404f99b15496 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:03:50 +0200 Subject: staging: rtl8723au: odm.c: Use BIT() instead of BITx Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/odm.c | 67 ++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/odm.c b/drivers/staging/rtl8723au/hal/odm.c index 5ef1fd35f5d5..1eedd96b794e 100644 --- a/drivers/staging/rtl8723au/hal/odm.c +++ b/drivers/staging/rtl8723au/hal/odm.c @@ -563,7 +563,7 @@ void ODM_CmnInfoUpdate23a(struct dm_odm_t *pDM_Odm, u32 CmnInfo, u64 Value) void odm_CommonInfoSelfInit23a(struct dm_odm_t *pDM_Odm ) { - pDM_Odm->bCckHighPower = (bool) ODM_GetBBReg(pDM_Odm, 0x824, BIT9); + pDM_Odm->bCckHighPower = (bool) ODM_GetBBReg(pDM_Odm, 0x824, BIT(9)); pDM_Odm->RFPathRxEnable = (u8) ODM_GetBBReg(pDM_Odm, 0xc04, 0x0F); if (pDM_Odm->SupportICType & (ODM_RTL8723A)) pDM_Odm->AntDivType = CGCS_RX_SW_ANTDIV; @@ -941,8 +941,8 @@ void odm_FalseAlarmCounterStatistics23a(struct dm_odm_t *pDM_Odm) if (pDM_Odm->SupportICType & ODM_IC_11N_SERIES) { /* hold ofdm counter */ - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_HOLDC_11N, BIT31, 1); /* hold page C counter */ - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT31, 1); /* hold page D counter */ + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_HOLDC_11N, BIT(31), 1); /* hold page C counter */ + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT(31), 1); /* hold page D counter */ ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE1_11N, bMaskDWord); FalseAlmCnt->Cnt_Fast_Fsync = (ret_value&0xffff); @@ -962,9 +962,9 @@ void odm_FalseAlarmCounterStatistics23a(struct dm_odm_t *pDM_Odm) FalseAlmCnt->Cnt_Mcs_fail + FalseAlmCnt->Cnt_Fast_Fsync + FalseAlmCnt->Cnt_SB_Search_fail; - /* hold cck counter */ - ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT12, 1); - ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT14, 1); + /* hold cck counter */ + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT(12), 1); + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT(14), 1); ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_CCK_FA_LSB_11N, bMaskByte0); FalseAlmCnt->Cnt_Cck_fail = ret_value; @@ -986,20 +986,24 @@ void odm_FalseAlarmCounterStatistics23a(struct dm_odm_t *pDM_Odm) if (pDM_Odm->SupportICType >= ODM_RTL8723A) { /* reset false alarm counter registers */ - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTC_11N, BIT31, 1); - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTC_11N, BIT31, 0); - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT27, 1); - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT27, 0); + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTC_11N, BIT(31), 1); + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTC_11N, BIT(31), 0); + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT(27), 1); + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT(27), 0); /* update ofdm counter */ - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_HOLDC_11N, BIT31, 0); /* update page C counter */ - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT31, 0); /* update page D counter */ + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_HOLDC_11N, BIT(31), 0); /* update page C counter */ + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT(31), 0); /* update page D counter */ /* reset CCK CCA counter */ - ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT13|BIT12, 0); - ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT13|BIT12, 2); + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, + BIT(13) | BIT(12), 0); + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, + BIT(13) | BIT(12), 2); /* reset CCK FA counter */ - ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT15|BIT14, 0); - ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT15|BIT14, 2); + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, + BIT(15) | BIT(14), 0); + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, + BIT(15) | BIT(14), 2); } ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Enter odm_FalseAlarmCounterStatistics23a\n")); @@ -1016,11 +1020,11 @@ void odm_FalseAlarmCounterStatistics23a(struct dm_odm_t *pDM_Odm) FalseAlmCnt->Cnt_all = FalseAlmCnt->Cnt_Ofdm_fail + FalseAlmCnt->Cnt_Cck_fail; /* reset OFDM FA coutner */ - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RST_11AC, BIT17, 1); - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RST_11AC, BIT17, 0); + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RST_11AC, BIT(17), 1); + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RST_11AC, BIT(17), 0); /* reset CCK FA counter */ - ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11AC, BIT15, 0); - ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11AC, BIT15, 1); + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11AC, BIT(15), 0); + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11AC, BIT(15), 1); } ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_Cck_fail =%d\n", FalseAlmCnt->Cnt_Cck_fail)); ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_Ofdm_fail =%d\n", FalseAlmCnt->Cnt_Ofdm_fail)); @@ -1140,7 +1144,8 @@ void ODM_RF_Saving23a(struct dm_odm_t *pDM_Odm, u8 bForceInNormal) if (pDM_PSTable->initialize == 0) { pDM_PSTable->Reg874 = (ODM_GetBBReg(pDM_Odm, 0x874, bMaskDWord)&0x1CC000)>>14; - pDM_PSTable->RegC70 = (ODM_GetBBReg(pDM_Odm, 0xc70, bMaskDWord)&BIT3)>>3; + pDM_PSTable->RegC70 = + (ODM_GetBBReg(pDM_Odm, 0xc70, bMaskDWord) & BIT(3)) >>3; pDM_PSTable->Reg85C = (ODM_GetBBReg(pDM_Odm, 0x85c, bMaskDWord)&0xFF000000)>>24; pDM_PSTable->RegA74 = (ODM_GetBBReg(pDM_Odm, 0xa74, bMaskDWord)&0xF000)>>12; /* Reg818 = PHY_QueryBBReg(pAdapter, 0x818, bMaskDWord); */ @@ -1172,23 +1177,23 @@ void ODM_RF_Saving23a(struct dm_odm_t *pDM_Odm, u8 bForceInNormal) /* 8723 RSSI report will be wrong. Set 0x874[5]= 1 when enter BB power saving mode. */ /* Suggested by SD3 Yu-Nan. 2011.01.20. */ if (pDM_Odm->SupportICType == ODM_RTL8723A) - ODM_SetBBReg(pDM_Odm, 0x874, BIT5, 0x1); /* Reg874[5]= 1b'1 */ + ODM_SetBBReg(pDM_Odm, 0x874, BIT(5), 0x1); /* Reg874[5]= 1b'1 */ ODM_SetBBReg(pDM_Odm, 0x874, 0x1C0000, 0x2); /* Reg874[20:18]= 3'b010 */ - ODM_SetBBReg(pDM_Odm, 0xc70, BIT3, 0); /* RegC70[3]= 1'b0 */ + ODM_SetBBReg(pDM_Odm, 0xc70, BIT(3), 0); /* RegC70[3]= 1'b0 */ ODM_SetBBReg(pDM_Odm, 0x85c, 0xFF000000, 0x63); /* Reg85C[31:24]= 0x63 */ ODM_SetBBReg(pDM_Odm, 0x874, 0xC000, 0x2); /* Reg874[15:14]= 2'b10 */ ODM_SetBBReg(pDM_Odm, 0xa74, 0xF000, 0x3); /* RegA75[7:4]= 0x3 */ - ODM_SetBBReg(pDM_Odm, 0x818, BIT28, 0x0); /* Reg818[28]= 1'b0 */ - ODM_SetBBReg(pDM_Odm, 0x818, BIT28, 0x1); /* Reg818[28]= 1'b1 */ + ODM_SetBBReg(pDM_Odm, 0x818, BIT(28), 0x0); /* Reg818[28]= 1'b0 */ + ODM_SetBBReg(pDM_Odm, 0x818, BIT(28), 0x1); /* Reg818[28]= 1'b1 */ } else { ODM_SetBBReg(pDM_Odm, 0x874, 0x1CC000, pDM_PSTable->Reg874); - ODM_SetBBReg(pDM_Odm, 0xc70, BIT3, pDM_PSTable->RegC70); + ODM_SetBBReg(pDM_Odm, 0xc70, BIT(3), pDM_PSTable->RegC70); ODM_SetBBReg(pDM_Odm, 0x85c, 0xFF000000, pDM_PSTable->Reg85C); ODM_SetBBReg(pDM_Odm, 0xa74, 0xF000, pDM_PSTable->RegA74); - ODM_SetBBReg(pDM_Odm, 0x818, BIT28, 0x0); + ODM_SetBBReg(pDM_Odm, 0x818, BIT(28), 0x0); if (pDM_Odm->SupportICType == ODM_RTL8723A) - ODM_SetBBReg(pDM_Odm, 0x874, BIT5, 0x0); /* Reg874[5]= 1b'0 */ + ODM_SetBBReg(pDM_Odm, 0x874, BIT(5), 0x0); /* Reg874[5]= 1b'0 */ } pDM_PSTable->PreRFState = pDM_PSTable->CurRFState; } @@ -1789,10 +1794,10 @@ u32 GetPSDData(struct dm_odm_t *pDM_Odm, unsigned int point, u8 initial_gain_psd ODM_SetBBReg(pDM_Odm, 0x808, 0x3FF, point); /* Start PSD calculation, Reg808[22]= 0->1 */ - ODM_SetBBReg(pDM_Odm, 0x808, BIT22, 1); + ODM_SetBBReg(pDM_Odm, 0x808, BIT(22), 1); /* Need to wait for HW PSD report */ udelay(30); - ODM_SetBBReg(pDM_Odm, 0x808, BIT22, 0); + ODM_SetBBReg(pDM_Odm, 0x808, BIT(22), 0); /* Read PSD report, Reg8B4[15:0] */ psd_report = ODM_GetBBReg(pDM_Odm, 0x8B4, bMaskDWord) & 0x0000FFFF; @@ -1926,7 +1931,7 @@ bool ODM_SingleDualAntennaDetection(struct dm_odm_t *pDM_Odm, u8 mode) odm_PHY_SaveAFERegisters(pDM_Odm, AFE_REG_8723A, AFE_Backup, 16); /* Set PSD 128 pts */ - ODM_SetBBReg(pDM_Odm, rFPGA0_PSDFunction, BIT14|BIT15, 0x0); /* 128 pts */ + ODM_SetBBReg(pDM_Odm, rFPGA0_PSDFunction, BIT(14) | BIT(15), 0x0); /* To SET CH1 to do */ ODM_SetRFReg(pDM_Odm, RF_PATH_A, ODM_CHANNEL, bRFRegOffsetMask, 0x01); /* Channel 1 */ -- cgit v1.2.3 From f061c1b1e3c39790268249c50d593417472ff837 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:03:51 +0200 Subject: staging: rtl8723au: odm_HWConfig.c: Use BIT() consistently Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/odm_HWConfig.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/odm_HWConfig.c b/drivers/staging/rtl8723au/hal/odm_HWConfig.c index 347c8e90fed6..82b1b8348898 100644 --- a/drivers/staging/rtl8723au/hal/odm_HWConfig.c +++ b/drivers/staging/rtl8723au/hal/odm_HWConfig.c @@ -347,7 +347,8 @@ static void odm_Process_RSSIForDM(struct dm_odm_t *pDM_Odm, (RSSI_Ave)) / (Rx_Smooth_Factor); } } - pEntry->rssi_stat.PacketMap = (pEntry->rssi_stat.PacketMap<<1) | BIT0; + pEntry->rssi_stat.PacketMap = + (pEntry->rssi_stat.PacketMap<<1) | BIT(0); } else { RSSI_Ave = pPhyInfo->RxPWDBAll; @@ -377,7 +378,8 @@ static void odm_Process_RSSIForDM(struct dm_odm_t *pDM_Odm, pEntry->rssi_stat.ValidBit++; for (i = 0; i < pEntry->rssi_stat.ValidBit; i++) - OFDM_pkt += (u8)(pEntry->rssi_stat.PacketMap>>i)&BIT0; + OFDM_pkt += + (u8)(pEntry->rssi_stat.PacketMap>>i) & BIT(0); if (pEntry->rssi_stat.ValidBit == 64) { Weighting = ((OFDM_pkt<<4) > 64)?64:(OFDM_pkt<<4); -- cgit v1.2.3 From ebf2ccf69b656716bf63a412f90961e3b389288f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:03:52 +0200 Subject: staging: rtl8723au: Remove obsolete BITx #defines Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/osdep_service.h | 38 ----------------------- 1 file changed, 38 deletions(-) diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index e6b14cc96f1f..c2eea6ccb0af 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -80,44 +80,6 @@ static inline u32 CHKBIT(u32 x) return BIT(x); } -#define BIT0 0x00000001 -#define BIT1 0x00000002 -#define BIT2 0x00000004 -#define BIT3 0x00000008 -#define BIT4 0x00000010 -#define BIT5 0x00000020 -#define BIT6 0x00000040 -#define BIT7 0x00000080 -#define BIT8 0x00000100 -#define BIT9 0x00000200 -#define BIT10 0x00000400 -#define BIT11 0x00000800 -#define BIT12 0x00001000 -#define BIT13 0x00002000 -#define BIT14 0x00004000 -#define BIT15 0x00008000 -#define BIT16 0x00010000 -#define BIT17 0x00020000 -#define BIT18 0x00040000 -#define BIT19 0x00080000 -#define BIT20 0x00100000 -#define BIT21 0x00200000 -#define BIT22 0x00400000 -#define BIT23 0x00800000 -#define BIT24 0x01000000 -#define BIT25 0x02000000 -#define BIT26 0x04000000 -#define BIT27 0x08000000 -#define BIT28 0x10000000 -#define BIT29 0x20000000 -#define BIT30 0x40000000 -#define BIT31 0x80000000 -#define BIT32 0x0100000000 -#define BIT33 0x0200000000 -#define BIT34 0x0400000000 -#define BIT35 0x0800000000 -#define BIT36 0x1000000000 - extern unsigned char MCS_rate_2R23A[16]; extern unsigned char MCS_rate_2R23A[16]; -- cgit v1.2.3 From f7f332bd838119faf24bb4b6f3534f5a811fac70 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:03:53 +0200 Subject: staging: rtl8723au: osdep_service.h: Reduce excessive header inclusion Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/osdep_service.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index c2eea6ccb0af..d85f850b77b5 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -42,17 +42,11 @@ #include #include #include -#include /* Necessary because we use the proc fs */ #include /* for struct tasklet_struct */ #include -#include - -/* #include */ #include #include -#include -#include struct rtw_queue { struct list_head queue; -- cgit v1.2.3 From cf3d7b940ba56ad7c3547f0dab71e8e258e9e35a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:03:54 +0200 Subject: staging: rtl8723au: Remove unused bBTFWReady from struct rtw_adapter Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/drv_types.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8723au/include/drv_types.h b/drivers/staging/rtl8723au/include/drv_types.h index a61408cc7eb3..bf0fa90928e2 100644 --- a/drivers/staging/rtl8723au/include/drv_types.h +++ b/drivers/staging/rtl8723au/include/drv_types.h @@ -268,7 +268,6 @@ struct rtw_adapter { int net_closed; u8 bFWReady; - u8 bBTFWReady; u8 bReadPortCancel; u8 bWritePortCancel; /* The driver will show the desired chan nor when this flag is 1. */ -- cgit v1.2.3 From f207b02db8755807649861cc73c9927d2dc8a522 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:03:55 +0200 Subject: staging: rtl8723au: Remove unused rtl8723a_clone_haldata() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 7 ------- drivers/staging/rtl8723au/include/rtl8723a_hal.h | 1 - 2 files changed, 8 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 55e3a6923910..e23e5e38f01b 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3171,10 +3171,3 @@ void rtl8723a_SingleDualAntennaDetection(struct rtw_adapter *padapter) } } #endif /* CONFIG_8723AU_BT_COEXIST */ - -void rtl8723a_clone_haldata(struct rtw_adapter *dst_adapter, - struct rtw_adapter *src_adapter) -{ - memcpy(dst_adapter->HalData, src_adapter->HalData, - dst_adapter->hal_data_sz); -} diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index d4121a8c022d..9eff12abc670 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -540,7 +540,6 @@ void rtl8723a_SingleDualAntennaDetection(struct rtw_adapter *padapter); void SetBcnCtrlReg23a(struct rtw_adapter *padapter, u8 SetBits, u8 ClearBits); void rtl8723a_InitBeaconParameters(struct rtw_adapter *padapter); -void rtl8723a_clone_haldata(struct rtw_adapter *dst_adapter, struct rtw_adapter *src_adapter); void rtl8723a_start_thread(struct rtw_adapter *padapter); void rtl8723a_stop_thread(struct rtw_adapter *padapter); -- cgit v1.2.3 From d87283ff9b99b3e3225b8dd970e850ce6f3cc3bb Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:03:56 +0200 Subject: staging: rtl8723au: Remove unused hal_data_sz from struct rtw_adapter Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_halinit.c | 1 - drivers/staging/rtl8723au/include/drv_types.h | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 93b71d380841..ebdfcb7602d2 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1747,7 +1747,6 @@ int rtl8723au_set_hal_ops(struct rtw_adapter *padapter) DBG_8723A("cannot alloc memory for HAL DATA\n"); return -ENOMEM; } - padapter->hal_data_sz = sizeof(struct hal_data_8723a); pHalFunc->hal_init = &rtl8723au_hal_init; pHalFunc->hal_deinit = &rtl8723au_hal_deinit; diff --git a/drivers/staging/rtl8723au/include/drv_types.h b/drivers/staging/rtl8723au/include/drv_types.h index bf0fa90928e2..e31e6ea56f54 100644 --- a/drivers/staging/rtl8723au/include/drv_types.h +++ b/drivers/staging/rtl8723au/include/drv_types.h @@ -239,7 +239,6 @@ struct rtw_adapter { u32 setband; void *HalData; - u32 hal_data_sz; struct hal_ops HalFunc; s32 bDriverStopped; -- cgit v1.2.3 From 03722621d2d2313a068aa06b21bcc32fafa4b527 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:03:57 +0200 Subject: staging: rtl8723au: Call rtl8723a_init_default_value_directly() We really don't need two layers of silly indirection to call this function. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_intf.c | 5 ----- drivers/staging/rtl8723au/hal/usb_halinit.c | 6 ------ drivers/staging/rtl8723au/include/hal_intf.h | 2 -- drivers/staging/rtl8723au/os_dep/os_intfs.c | 6 ++++-- 4 files changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index afd4e1f9b079..dff5f02b537c 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -39,11 +39,6 @@ void rtw_hal_read_chip_version23a(struct rtw_adapter *padapter) padapter->HalFunc.read_chip_version(padapter); } -void rtw_hal_def_value_init23a(struct rtw_adapter *padapter) -{ - if (padapter->HalFunc.init_default_value) - padapter->HalFunc.init_default_value(padapter); -} void rtw_hal_free_data23a(struct rtw_adapter *padapter) { if (padapter->HalFunc.free_hal_data) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index ebdfcb7602d2..98abf549d3ab 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1733,11 +1733,6 @@ static void UpdateHalRAMask8192CUsb(struct rtw_adapter *padapter, pdmpriv->INIDATA_RATE[mac_id] = init_rate; } -static void rtl8723au_init_default_value(struct rtw_adapter *padapter) -{ - rtl8723a_init_default_value(padapter); -} - int rtl8723au_set_hal_ops(struct rtw_adapter *padapter) { struct hal_ops *pHalFunc = &padapter->HalFunc; @@ -1761,7 +1756,6 @@ int rtl8723au_set_hal_ops(struct rtw_adapter *padapter) pHalFunc->InitSwLeds = NULL; pHalFunc->DeInitSwLeds = NULL; - pHalFunc->init_default_value = &rtl8723au_init_default_value; pHalFunc->intf_chip_configure = &rtl8723au_interface_configure; pHalFunc->read_adapter_info = &ReadAdapterInfo8723AU; pHalFunc->GetHalDefVarHandler = &GetHalDefVar8192CUsb; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index bf13a6a7b556..8a8f7931b04e 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -82,8 +82,6 @@ struct hal_ops { void (*dm_deinit)(struct rtw_adapter *padapter); void (*read_chip_version)(struct rtw_adapter *padapter); - void (*init_default_value)(struct rtw_adapter *padapter); - void (*intf_chip_configure)(struct rtw_adapter *padapter); void (*read_adapter_info)(struct rtw_adapter *padapter); diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index ca95bd32c808..98c203dd3efd 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -22,6 +22,8 @@ #include #include +#include + #include MODULE_LICENSE("GPL"); @@ -419,7 +421,7 @@ static u8 rtw_init_default_value(struct rtw_adapter *padapter) rtw_update_registrypriv_dev_network23a(padapter); /* hal_priv */ - rtw_hal_def_value_init23a(padapter); + rtl8723a_init_default_value(padapter); /* misc. */ padapter->bReadPortCancel = false; @@ -435,7 +437,7 @@ u8 rtw_reset_drv_sw23a(struct rtw_adapter *padapter) u8 ret8 = _SUCCESS; /* hal_priv */ - rtw_hal_def_value_init23a(padapter); + rtl8723a_init_default_value(padapter); padapter->bReadPortCancel = false; padapter->bWritePortCancel = false; pmlmepriv->scan_interval = SCAN_INTERVAL;/* 30*2 sec = 60sec */ -- cgit v1.2.3 From 1f4746f1c51a42e4ad2f7316bdc89e67191a053e Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:03:58 +0200 Subject: staging: rtl8723au: Remove some more HAL clutter Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_intf.c | 6 ------ drivers/staging/rtl8723au/hal/usb_halinit.c | 17 ++++------------- drivers/staging/rtl8723au/include/hal_intf.h | 2 -- drivers/staging/rtl8723au/include/rtl8723a_hal.h | 2 ++ drivers/staging/rtl8723au/os_dep/usb_intf.c | 3 ++- 5 files changed, 8 insertions(+), 22 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index dff5f02b537c..77d38e863ee7 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -27,12 +27,6 @@ void rtw_hal_chip_configure23a(struct rtw_adapter *padapter) padapter->HalFunc.intf_chip_configure(padapter); } -void rtw_hal_read_chip_info23a(struct rtw_adapter *padapter) -{ - if (padapter->HalFunc.read_adapter_info) - padapter->HalFunc.read_adapter_info(padapter); -} - void rtw_hal_read_chip_version23a(struct rtw_adapter *padapter) { if (padapter->HalFunc.read_chip_version) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 98abf549d3ab..96be426d9f19 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1462,11 +1462,13 @@ static void hal_EfuseCellSel(struct rtw_adapter *Adapter) rtw_write32(Adapter, EFUSE_TEST, value32); } -static int _ReadAdapterInfo8723AU(struct rtw_adapter *Adapter) +void rtl8723a_read_adapter_info(struct rtw_adapter *Adapter) { - /* struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); */ unsigned long start = jiffies; + /* Read EEPROM size before call any EEPROM function */ + Adapter->EepromAddressSize = GetEEPROMSize8723A(Adapter); + MSG_8723A("====> _ReadAdapterInfo8723AU\n"); hal_EfuseCellSel(Adapter); @@ -1483,16 +1485,6 @@ static int _ReadAdapterInfo8723AU(struct rtw_adapter *Adapter) MSG_8723A("<==== _ReadAdapterInfo8723AU in %d ms\n", jiffies_to_msecs(jiffies - start)); - - return _SUCCESS; -} - -static void ReadAdapterInfo8723AU(struct rtw_adapter *Adapter) -{ - /* Read EEPROM size before call any EEPROM function */ - Adapter->EepromAddressSize = GetEEPROMSize8723A(Adapter); - - _ReadAdapterInfo8723AU(Adapter); } /* */ @@ -1757,7 +1749,6 @@ int rtl8723au_set_hal_ops(struct rtw_adapter *padapter) pHalFunc->DeInitSwLeds = NULL; pHalFunc->intf_chip_configure = &rtl8723au_interface_configure; - pHalFunc->read_adapter_info = &ReadAdapterInfo8723AU; pHalFunc->GetHalDefVarHandler = &GetHalDefVar8192CUsb; pHalFunc->SetHalDefVarHandler = &SetHalDefVar8192CUsb; pHalFunc->UpdateRAMaskHandler = &UpdateHalRAMask8192CUsb; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 8a8f7931b04e..681e8f7f4c65 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -84,8 +84,6 @@ struct hal_ops { void (*intf_chip_configure)(struct rtw_adapter *padapter); - void (*read_adapter_info)(struct rtw_adapter *padapter); - void (*enable_interrupt)(struct rtw_adapter *padapter); void (*disable_interrupt)(struct rtw_adapter *padapter); s32 (*interrupt_handler)(struct rtw_adapter *padapter); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index 9eff12abc670..14cc238882fa 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -546,4 +546,6 @@ void rtl8723a_stop_thread(struct rtw_adapter *padapter); s32 c2h_id_filter_ccx_8723a(u8 id); s32 c2h_handler_8723a(struct rtw_adapter *padapter, struct c2h_evt_hdr *c2h_evt); +void rtl8723a_read_adapter_info(struct rtw_adapter *Adapter); + #endif diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index c6cc335a19bc..09d0892b6bc5 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -25,6 +25,7 @@ #include #include #include +#include static int rtw_suspend(struct usb_interface *intf, pm_message_t message); static int rtw_resume(struct usb_interface *intf); @@ -631,7 +632,7 @@ static struct rtw_adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, rtw_hal_chip_configure23a(padapter); /* step read efuse/eeprom data and get mac_addr */ - rtw_hal_read_chip_info23a(padapter); + rtl8723a_read_adapter_info(padapter); /* step 5. */ if (rtw_init_drv_sw23a(padapter) == _FAIL) { -- cgit v1.2.3 From 8289d35730a8a5250cafb2c4922f9d3491e097b6 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:03:59 +0200 Subject: staging: rtl8723au: Get rid of rtw_hal_dm_* clutter Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 2 +- drivers/staging/rtl8723au/hal/hal_intf.c | 17 ----------------- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 5 ----- drivers/staging/rtl8723au/include/hal_intf.h | 7 ------- drivers/staging/rtl8723au/os_dep/os_intfs.c | 4 ++-- 5 files changed, 3 insertions(+), 32 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 3b9f8437c38a..32c5f72c9a44 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -1038,7 +1038,7 @@ static void dynamic_chk_wk_hdl(struct rtw_adapter *padapter, u8 *pbuf, int sz) linked_status_chk23a(padapter); traffic_status_watchdog(padapter); - rtw_hal_dm_watchdog23a(padapter); + rtl8723a_HalDmWatchDog(padapter); #ifdef CONFIG_8723AU_BT_COEXIST /* */ diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index 77d38e863ee7..1e42a33e6967 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -38,17 +38,6 @@ void rtw_hal_free_data23a(struct rtw_adapter *padapter) if (padapter->HalFunc.free_hal_data) padapter->HalFunc.free_hal_data(padapter); } -void rtw_hal_dm_init23a(struct rtw_adapter *padapter) -{ - if (padapter->HalFunc.dm_init) - padapter->HalFunc.dm_init(padapter); -} -void rtw_hal_dm_deinit23a(struct rtw_adapter *padapter) -{ - /* cancel dm timer */ - if (padapter->HalFunc.dm_deinit) - padapter->HalFunc.dm_deinit(padapter); -} void rtw_hal_sw_led_init23a(struct rtw_adapter *padapter) { if (padapter->HalFunc.InitSwLeds) @@ -273,12 +262,6 @@ void rtw_hal_set_chan23a(struct rtw_adapter *padapter, u8 channel) padapter->HalFunc.set_channel_handler(padapter, channel); } -void rtw_hal_dm_watchdog23a(struct rtw_adapter *padapter) -{ - if (padapter->HalFunc.hal_dm_watchdog) - padapter->HalFunc.hal_dm_watchdog(padapter); -} - void rtw_hal_bcn_related_reg_setting23a(struct rtw_adapter *padapter) { if (padapter->HalFunc.SetBeaconRelatedRegistersHandler) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index e23e5e38f01b..5e2726244576 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1723,16 +1723,11 @@ void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc) { pHalFunc->free_hal_data = &rtl8723a_free_hal_data; - pHalFunc->dm_init = &rtl8723a_init_dm_priv; - pHalFunc->dm_deinit = &rtl8723a_deinit_dm_priv; - pHalFunc->read_chip_version = &rtl8723a_read_chip_version; pHalFunc->set_bwmode_handler = &PHY_SetBWMode23a8723A; pHalFunc->set_channel_handler = &PHY_SwChnl8723A; - pHalFunc->hal_dm_watchdog = &rtl8723a_HalDmWatchDog; - pHalFunc->SetBeaconRelatedRegistersHandler = &rtl8723a_SetBeaconRelatedRegisters; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 681e8f7f4c65..959105e34a66 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -78,8 +78,6 @@ struct hal_ops { void (*InitSwLeds)(struct rtw_adapter *padapter); void (*DeInitSwLeds)(struct rtw_adapter *padapter); - void (*dm_init)(struct rtw_adapter *padapter); - void (*dm_deinit)(struct rtw_adapter *padapter); void (*read_chip_version)(struct rtw_adapter *padapter); void (*intf_chip_configure)(struct rtw_adapter *padapter); @@ -91,8 +89,6 @@ struct hal_ops { enum ht_channel_width Bandwidth, u8 Offset); void (*set_channel_handler)(struct rtw_adapter *padapter, u8 channel); - void (*hal_dm_watchdog)(struct rtw_adapter *padapter); - u8 (*GetHalDefVarHandler)(struct rtw_adapter *padapter, enum hal_def_variable eVariable, void *pValue); @@ -200,8 +196,6 @@ int rtw_resume_process23a(struct rtw_adapter *padapter); void rtw_hal_free_data23a(struct rtw_adapter *padapter); -void rtw_hal_dm_init23a(struct rtw_adapter *padapter); -void rtw_hal_dm_deinit23a(struct rtw_adapter *padapter); void rtw_hal_sw_led_init23a(struct rtw_adapter *padapter); void rtw_hal_sw_led_deinit23a(struct rtw_adapter *padapter); @@ -260,7 +254,6 @@ s32 rtw_hal_interrupt_handler23a(struct rtw_adapter *padapter); void rtw_hal_set_bwmode23a(struct rtw_adapter *padapter, enum ht_channel_width Bandwidth, u8 Offset); void rtw_hal_set_chan23a(struct rtw_adapter *padapter, u8 channel); -void rtw_hal_dm_watchdog23a(struct rtw_adapter *padapter); void rtw_hal_sreset_init23a(struct rtw_adapter *padapter); void rtw_hal_sreset_reset23a(struct rtw_adapter *padapter); diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index 98c203dd3efd..6273497aa61e 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -522,7 +522,7 @@ u8 rtw_init_drv_sw23a(struct rtw_adapter *padapter) ret8 = rtw_init_default_value(padapter); - rtw_hal_dm_init23a(padapter); + rtl8723a_init_dm_priv(padapter); rtw_hal_sw_led_init23a(padapter); rtw_hal_sreset_init23a(padapter); @@ -563,7 +563,7 @@ void rtw_cancel_all_timer23a(struct rtw_adapter *padapter) del_timer_sync(&padapter->recvpriv.signal_stat_timer); /* cancel dm timer */ - rtw_hal_dm_deinit23a(padapter); + rtl8723a_deinit_dm_priv(padapter); } u8 rtw_free_drv_sw23a(struct rtw_adapter *padapter) -- cgit v1.2.3 From b7c19c276a230aee012ba7adef036689633c4cd8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:00 +0200 Subject: staging: rtl8723au: Get rid of sreset related HAL clutter Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 2 +- drivers/staging/rtl8723au/core/rtw_mlme.c | 3 +- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 5 +-- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 6 +-- drivers/staging/rtl8723au/core/rtw_sreset.c | 25 ++++++------ drivers/staging/rtl8723au/hal/hal_intf.c | 48 ----------------------- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 8 ---- drivers/staging/rtl8723au/hal/rtl8723a_sreset.c | 8 ++-- drivers/staging/rtl8723au/include/hal_intf.h | 16 -------- drivers/staging/rtl8723au/include/rtw_sreset.h | 10 ++--- drivers/staging/rtl8723au/os_dep/os_intfs.c | 4 +- 11 files changed, 33 insertions(+), 102 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 32c5f72c9a44..356bfcc9744a 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -1033,7 +1033,7 @@ static void dynamic_chk_wk_hdl(struct rtw_adapter *padapter, u8 *pbuf, int sz) expire_timeout_chk23a(padapter); #endif - rtw_hal_sreset_xmit_status_check23a(padapter); + rtl8723a_sreset_xmit_status_check(padapter); linked_status_chk23a(padapter); traffic_status_watchdog(padapter); diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index a5fca8141e32..b1f1fd6e6c9f 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -25,6 +25,7 @@ #include #include #include +#include static void rtw_init_mlme_timer(struct rtw_adapter *padapter) { @@ -808,7 +809,7 @@ rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf) rtw_os_xmit_schedule23a(adapter); if (pmlmeext->sitesurvey_res.bss_cnt == 0) - rtw_hal_sreset_reset23a(adapter); + rtw_sreset_reset(adapter); rtw_cfg80211_surveydone_event_callback(adapter); } diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 1789822e785a..9d40b08dd19f 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -5555,10 +5555,9 @@ void linked_status_chk23a(struct rtw_adapter *padapter) struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct sta_priv *pstapriv = &padapter->stapriv; - rtw_hal_sreset_linked_status_check23a(padapter); + rtl8723a_sreset_linked_status_check(padapter); - if (is_client_associated_to_ap23a(padapter)) - { + if (is_client_associated_to_ap23a(padapter)) { /* linked infrastructure client mode */ int tx_chk = _SUCCESS, rx_chk = _SUCCESS; diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index 993504dd7eda..b36c12b842c0 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -546,12 +546,12 @@ int _rtw_pwr_wakeup23a(struct rtw_adapter *padapter, u32 ips_deffer_ms, const ch DBG_8723A("%s wait ps_processing done\n", __func__); } - if (rtw_hal_sreset_inprogress(padapter)) { + if (rtw_sreset_inprogress(padapter)) { DBG_8723A("%s wait sreset_inprogress...\n", __func__); - while (rtw_hal_sreset_inprogress(padapter) && + while (rtw_sreset_inprogress(padapter) && jiffies_to_msecs(jiffies - start) <= 4000) msleep(10); - if (rtw_hal_sreset_inprogress(padapter)) + if (rtw_sreset_inprogress(padapter)) DBG_8723A("%s wait sreset_inprogress timeout\n", __func__); else diff --git a/drivers/staging/rtl8723au/core/rtw_sreset.c b/drivers/staging/rtl8723au/core/rtw_sreset.c index 0e1ea3142006..4938af70cc02 100644 --- a/drivers/staging/rtl8723au/core/rtw_sreset.c +++ b/drivers/staging/rtl8723au/core/rtw_sreset.c @@ -13,11 +13,11 @@ * ******************************************************************************/ -#include +#include -void sreset_init_value23a(struct rtw_adapter *padapter) +void rtw_sreset_init(struct rtw_adapter *padapter) { - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); + struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); struct sreset_priv *psrtpriv = &pHalData->srestpriv; mutex_init(&psrtpriv->silentreset_mutex); @@ -26,9 +26,10 @@ void sreset_init_value23a(struct rtw_adapter *padapter) psrtpriv->last_tx_time = 0; psrtpriv->last_tx_complete_time = 0; } -void sreset_reset_value23a(struct rtw_adapter *padapter) + +void rtw_sreset_reset_value(struct rtw_adapter *padapter) { - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); + struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); struct sreset_priv *psrtpriv = &pHalData->srestpriv; psrtpriv->silent_reset_inprogress = false; @@ -37,9 +38,9 @@ void sreset_reset_value23a(struct rtw_adapter *padapter) psrtpriv->last_tx_complete_time = 0; } -u8 sreset_get_wifi_status23a(struct rtw_adapter *padapter) +u8 rtw_sreset_get_wifi_status(struct rtw_adapter *padapter) { - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); + struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); struct sreset_priv *psrtpriv = &pHalData->srestpriv; u8 status = WIFI_STATUS_SUCCESS; u32 val32 = 0; @@ -80,9 +81,10 @@ void sreset_set_trigger_point(struct rtw_adapter *padapter, s32 tgp) pHalData->srestpriv.dbg_trigger_point = tgp; } -bool sreset_inprogress(struct rtw_adapter *padapter) +bool rtw_sreset_inprogress(struct rtw_adapter *padapter) { - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); + struct rtw_adapter *primary_adapter = GET_PRIMARY_ADAPTER(padapter); + struct hal_data_8723a *pHalData = GET_HAL_DATA(primary_adapter); return pHalData->srestpriv.silent_reset_inprogress; } @@ -227,9 +229,10 @@ static void sreset_start_adapter(struct rtw_adapter *padapter) netif_tx_wake_all_queues(padapter->pnetdev); } -void sreset_reset(struct rtw_adapter *padapter) +void rtw_sreset_reset(struct rtw_adapter *active_adapter) { - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); + struct rtw_adapter *padapter = GET_PRIMARY_ADAPTER(active_adapter); + struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); struct sreset_priv *psrtpriv = &pHalData->srestpriv; struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; unsigned long start = jiffies; diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index 1e42a33e6967..d08e805bb023 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -268,54 +268,6 @@ void rtw_hal_bcn_related_reg_setting23a(struct rtw_adapter *padapter) padapter->HalFunc.SetBeaconRelatedRegistersHandler(padapter); } -void rtw_hal_sreset_init23a(struct rtw_adapter *padapter) -{ - if (padapter->HalFunc.sreset_init_value23a) - padapter->HalFunc.sreset_init_value23a(padapter); -} -void rtw_hal_sreset_reset23a(struct rtw_adapter *padapter) -{ - padapter = GET_PRIMARY_ADAPTER(padapter); - - if (padapter->HalFunc.silentreset) - padapter->HalFunc.silentreset(padapter); -} - -void rtw_hal_sreset_reset23a_value23a(struct rtw_adapter *padapter) -{ - if (padapter->HalFunc.sreset_reset_value23a) - padapter->HalFunc.sreset_reset_value23a(padapter); -} - -void rtw_hal_sreset_xmit_status_check23a(struct rtw_adapter *padapter) -{ - if (padapter->HalFunc.sreset_xmit_status_check) - padapter->HalFunc.sreset_xmit_status_check(padapter); -} -void rtw_hal_sreset_linked_status_check23a(struct rtw_adapter *padapter) -{ - if (padapter->HalFunc.sreset_linked_status_check) - padapter->HalFunc.sreset_linked_status_check(padapter); -} -u8 rtw_hal_sreset_get_wifi_status23a(struct rtw_adapter *padapter) -{ - u8 status = 0; - if (padapter->HalFunc.sreset_get_wifi_status23a) - status = padapter->HalFunc.sreset_get_wifi_status23a(padapter); - return status; -} - -bool rtw_hal_sreset_inprogress(struct rtw_adapter *padapter) -{ - bool inprogress = false; - - padapter = GET_PRIMARY_ADAPTER(padapter); - - if (padapter->HalFunc.sreset_inprogress) - inprogress = padapter->HalFunc.sreset_inprogress(padapter); - return inprogress; -} - void rtw_hal_notch_filter23a(struct rtw_adapter *adapter, bool enable) { if (adapter->HalFunc.hal_notch_filter) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 5e2726244576..71cf14320956 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1746,14 +1746,6 @@ void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc) pHalFunc->Efuse_WordEnableDataWrite23a = &Hal_EfuseWordEnableDataWrite; pHalFunc->Efuse_PgPacketWrite23a_BT = &Hal_EfusePgPacketWrite_BT; - pHalFunc->sreset_init_value23a = &sreset_init_value23a; - pHalFunc->sreset_reset_value23a = &sreset_reset_value23a; - pHalFunc->silentreset = &sreset_reset; - pHalFunc->sreset_xmit_status_check = &rtl8723a_sreset_xmit_status_check; - pHalFunc->sreset_linked_status_check = - &rtl8723a_sreset_linked_status_check; - pHalFunc->sreset_get_wifi_status23a = &sreset_get_wifi_status23a; - pHalFunc->sreset_inprogress = &sreset_inprogress; pHalFunc->GetHalODMVarHandler = &rtl8723a_GetHalODMVar; pHalFunc->SetHalODMVarHandler = &rtl8723a_SetHalODMVar; diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_sreset.c b/drivers/staging/rtl8723au/hal/rtl8723a_sreset.c index c0218e734b9e..54b0dfb6eebf 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_sreset.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_sreset.c @@ -30,7 +30,7 @@ void rtl8723a_sreset_xmit_status_check(struct rtw_adapter *padapter) txdma_status = rtw_read32(padapter, REG_TXDMA_STATUS); if (txdma_status != 0) { DBG_8723A("%s REG_TXDMA_STATUS:0x%08x\n", __func__, txdma_status); - rtw_hal_sreset_reset23a(padapter); + rtw_sreset_reset(padapter); } current_time = jiffies; @@ -47,7 +47,7 @@ void rtl8723a_sreset_xmit_status_check(struct rtw_adapter *padapter) if (diff_time > 4000) { /* padapter->Wifi_Error_Status = WIFI_TX_HANG; */ DBG_8723A("%s tx hang\n", __func__); - rtw_hal_sreset_reset23a(padapter); + rtw_sreset_reset(padapter); } } } @@ -55,7 +55,7 @@ void rtl8723a_sreset_xmit_status_check(struct rtw_adapter *padapter) if (psrtpriv->dbg_trigger_point == SRESET_TGP_XMIT_STATUS) { psrtpriv->dbg_trigger_point = SRESET_TGP_NULL; - rtw_hal_sreset_reset23a(padapter); + rtw_sreset_reset(padapter); return; } } @@ -67,7 +67,7 @@ void rtl8723a_sreset_linked_status_check(struct rtw_adapter *padapter) if (psrtpriv->dbg_trigger_point == SRESET_TGP_LINK_STATUS) { psrtpriv->dbg_trigger_point = SRESET_TGP_NULL; - rtw_hal_sreset_reset23a(padapter); + rtw_sreset_reset(padapter); return; } } diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 959105e34a66..2fdc02afb53d 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -139,14 +139,6 @@ struct hal_ops { bool (*Efuse_PgPacketWrite23a_BT)(struct rtw_adapter *padapter, u8 offset, u8 word_en, u8 *data); - void (*sreset_init_value23a)(struct rtw_adapter *padapter); - void (*sreset_reset_value23a)(struct rtw_adapter *padapter); - void (*silentreset)(struct rtw_adapter *padapter); - void (*sreset_xmit_status_check)(struct rtw_adapter *padapter); - void (*sreset_linked_status_check) (struct rtw_adapter *padapter); - u8 (*sreset_get_wifi_status23a)(struct rtw_adapter *padapter); - bool (*sreset_inprogress)(struct rtw_adapter *padapter); - void (*hal_notch_filter)(struct rtw_adapter *adapter, bool enable); void (*hal_reset_security_engine)(struct rtw_adapter *adapter); }; @@ -255,14 +247,6 @@ void rtw_hal_set_bwmode23a(struct rtw_adapter *padapter, enum ht_channel_width Bandwidth, u8 Offset); void rtw_hal_set_chan23a(struct rtw_adapter *padapter, u8 channel); -void rtw_hal_sreset_init23a(struct rtw_adapter *padapter); -void rtw_hal_sreset_reset23a(struct rtw_adapter *padapter); -void rtw_hal_sreset_reset23a_value23a(struct rtw_adapter *padapter); -void rtw_hal_sreset_xmit_status_check23a(struct rtw_adapter *padapter); -void rtw_hal_sreset_linked_status_check23a (struct rtw_adapter *padapter); -u8 rtw_hal_sreset_get_wifi_status23a(struct rtw_adapter *padapter); -bool rtw_hal_sreset_inprogress(struct rtw_adapter *padapter); - void rtw_hal_notch_filter23a(struct rtw_adapter *adapter, bool enable); void rtw_hal_reset_security_engine23a(struct rtw_adapter *adapter); diff --git a/drivers/staging/rtl8723au/include/rtw_sreset.h b/drivers/staging/rtl8723au/include/rtw_sreset.h index 91d57e2791d9..77cc7941b546 100644 --- a/drivers/staging/rtl8723au/include/rtw_sreset.h +++ b/drivers/staging/rtl8723au/include/rtw_sreset.h @@ -45,12 +45,12 @@ struct sreset_priv { #define WIFI_RX_HANG BIT(5) #define WIFI_IF_NOT_EXIST BIT(6) -void sreset_init_value23a(struct rtw_adapter *padapter); -void sreset_reset_value23a(struct rtw_adapter *padapter); -u8 sreset_get_wifi_status23a(struct rtw_adapter *padapter); +void rtw_sreset_init(struct rtw_adapter *padapter); +void rtw_sreset_reset_value(struct rtw_adapter *padapter); +u8 rtw_sreset_get_wifi_status(struct rtw_adapter *padapter); +bool rtw_sreset_inprogress(struct rtw_adapter *padapter); void sreset_set_wifi_error_status23a(struct rtw_adapter *padapter, u32 status); void sreset_set_trigger_point(struct rtw_adapter *padapter, s32 tgp); -bool sreset_inprogress(struct rtw_adapter *padapter); -void sreset_reset(struct rtw_adapter *padapter); +void rtw_sreset_reset(struct rtw_adapter *active_adapter); #endif diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index 6273497aa61e..38ad4ab45206 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -449,7 +449,7 @@ u8 rtw_reset_drv_sw23a(struct rtw_adapter *padapter) _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING); - rtw_hal_sreset_reset23a_value23a(padapter); + rtw_sreset_reset_value(padapter); pwrctrlpriv->pwr_state_check_cnts = 0; /* mlmeextpriv */ @@ -525,7 +525,7 @@ u8 rtw_init_drv_sw23a(struct rtw_adapter *padapter) rtl8723a_init_dm_priv(padapter); rtw_hal_sw_led_init23a(padapter); - rtw_hal_sreset_init23a(padapter); + rtw_sreset_init(padapter); exit: -- cgit v1.2.3 From a7a983ca20f15079bc5405c5ea587a61f94385ec Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:01 +0200 Subject: staging: rtl8723au: Remove unused hal_reset_security_engine code Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_intf.c | 8 -------- drivers/staging/rtl8723au/include/hal_intf.h | 2 -- 2 files changed, 10 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index d08e805bb023..24a39e6fbd1e 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -70,8 +70,6 @@ uint rtw_hal_init23a(struct rtw_adapter *padapter) if (padapter->registrypriv.notch_filter == 1) rtw_hal_notch_filter23a(padapter, 1); - - rtw_hal_reset_security_engine23a(padapter); } else { padapter->hw_init_completed = false; DBG_8723A("rtw_hal_init23a: hal__init fail\n"); @@ -273,9 +271,3 @@ void rtw_hal_notch_filter23a(struct rtw_adapter *adapter, bool enable) if (adapter->HalFunc.hal_notch_filter) adapter->HalFunc.hal_notch_filter(adapter, enable); } - -void rtw_hal_reset_security_engine23a(struct rtw_adapter *adapter) -{ - if (adapter->HalFunc.hal_reset_security_engine) - adapter->HalFunc.hal_reset_security_engine(adapter); -} diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 2fdc02afb53d..31d9a7515805 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -140,7 +140,6 @@ struct hal_ops { u8 offset, u8 word_en, u8 *data); void (*hal_notch_filter)(struct rtw_adapter *adapter, bool enable); - void (*hal_reset_security_engine)(struct rtw_adapter *adapter); }; enum rt_eeprom_type { @@ -248,7 +247,6 @@ void rtw_hal_set_bwmode23a(struct rtw_adapter *padapter, void rtw_hal_set_chan23a(struct rtw_adapter *padapter, u8 channel); void rtw_hal_notch_filter23a(struct rtw_adapter *adapter, bool enable); -void rtw_hal_reset_security_engine23a(struct rtw_adapter *adapter); void hw_var_set_correct_tsf(struct rtw_adapter *padapter); void hw_var_set_mlme_disconnect(struct rtw_adapter *padapter); -- cgit v1.2.3 From 369074f07163291e35252a7b8657b639acd9a8f9 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:02 +0200 Subject: staging: rtl8723au: Remove HAL notch_filter wrappers Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_intf.c | 9 ++------- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 4 +--- drivers/staging/rtl8723au/include/hal_intf.h | 4 ---- drivers/staging/rtl8723au/include/rtl8723a_hal.h | 1 + 4 files changed, 4 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index 24a39e6fbd1e..2b74fb7be6d9 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -20,6 +20,7 @@ #include #include +#include void rtw_hal_chip_configure23a(struct rtw_adapter *padapter) { @@ -69,7 +70,7 @@ uint rtw_hal_init23a(struct rtw_adapter *padapter) padapter->hw_init_completed = true; if (padapter->registrypriv.notch_filter == 1) - rtw_hal_notch_filter23a(padapter, 1); + rtl8723a_notch_filter(padapter, 1); } else { padapter->hw_init_completed = false; DBG_8723A("rtw_hal_init23a: hal__init fail\n"); @@ -265,9 +266,3 @@ void rtw_hal_bcn_related_reg_setting23a(struct rtw_adapter *padapter) if (padapter->HalFunc.SetBeaconRelatedRegistersHandler) padapter->HalFunc.SetBeaconRelatedRegistersHandler(padapter); } - -void rtw_hal_notch_filter23a(struct rtw_adapter *adapter, bool enable) -{ - if (adapter->HalFunc.hal_notch_filter) - adapter->HalFunc.hal_notch_filter(adapter, enable); -} diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 71cf14320956..758ee178c7e9 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1639,7 +1639,7 @@ static void rtl8723a_SetHalODMVar(struct rtw_adapter *Adapter, } } -static void hal_notch_filter_8723a(struct rtw_adapter *adapter, bool enable) +void rtl8723a_notch_filter(struct rtw_adapter *adapter, bool enable) { if (enable) { DBG_8723A("Enable notch filter\n"); @@ -1748,8 +1748,6 @@ void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc) pHalFunc->GetHalODMVarHandler = &rtl8723a_GetHalODMVar; pHalFunc->SetHalODMVarHandler = &rtl8723a_SetHalODMVar; - - pHalFunc->hal_notch_filter = &hal_notch_filter_8723a; } void rtl8723a_InitAntenna_Selection(struct rtw_adapter *padapter) diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 31d9a7515805..2645b649a9e0 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -138,8 +138,6 @@ struct hal_ops { u8 *data); bool (*Efuse_PgPacketWrite23a_BT)(struct rtw_adapter *padapter, u8 offset, u8 word_en, u8 *data); - - void (*hal_notch_filter)(struct rtw_adapter *adapter, bool enable); }; enum rt_eeprom_type { @@ -246,8 +244,6 @@ void rtw_hal_set_bwmode23a(struct rtw_adapter *padapter, enum ht_channel_width Bandwidth, u8 Offset); void rtw_hal_set_chan23a(struct rtw_adapter *padapter, u8 channel); -void rtw_hal_notch_filter23a(struct rtw_adapter *adapter, bool enable); - void hw_var_set_correct_tsf(struct rtw_adapter *padapter); void hw_var_set_mlme_disconnect(struct rtw_adapter *padapter); void hw_var_set_opmode(struct rtw_adapter *padapter, u8 mode); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index 14cc238882fa..88a79dfb87c5 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -547,5 +547,6 @@ s32 c2h_id_filter_ccx_8723a(u8 id); s32 c2h_handler_8723a(struct rtw_adapter *padapter, struct c2h_evt_hdr *c2h_evt); void rtl8723a_read_adapter_info(struct rtw_adapter *Adapter); +void rtl8723a_notch_filter(struct rtw_adapter *adapter, bool enable); #endif -- cgit v1.2.3 From 5d9edb5663653e7c5c682cd390796ab037d76700 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:03 +0200 Subject: staging: rtl8723au: Remove unused HAL wrappers around PHY register read/write calls Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_intf.c | 13 ------------- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 3 --- drivers/staging/rtl8723au/include/hal_intf.h | 8 -------- 3 files changed, 24 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index 2b74fb7be6d9..d9be03dfd28d 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -227,19 +227,6 @@ void rtw_hal_add_ra_tid23a(struct rtw_adapter *padapter, u32 bitmap, u8 arg, u8 padapter->HalFunc.Add_RateATid(padapter, bitmap, arg, rssi_level); } -u32 rtw_hal_read_rfreg23a(struct rtw_adapter *padapter, u32 eRFPath, u32 RegAddr, u32 BitMask) -{ - u32 data = 0; - if (padapter->HalFunc.read_rfreg) - data = padapter->HalFunc.read_rfreg(padapter, eRFPath, RegAddr, BitMask); - return data; -} -void rtw_hal_write_rfreg23a(struct rtw_adapter *padapter, u32 eRFPath, u32 RegAddr, u32 BitMask, u32 Data) -{ - if (padapter->HalFunc.write_rfreg) - padapter->HalFunc.write_rfreg(padapter, eRFPath, RegAddr, BitMask, Data); -} - s32 rtw_hal_interrupt_handler23a(struct rtw_adapter *padapter) { if (padapter->HalFunc.interrupt_handler) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 758ee178c7e9..681eee57c569 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1733,9 +1733,6 @@ void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc) pHalFunc->Add_RateATid = &rtl8723a_add_rateatid; - pHalFunc->read_rfreg = &PHY_QueryRFReg; - pHalFunc->write_rfreg = &PHY_SetRFReg; - /* Efuse related function */ pHalFunc->EfusePowerSwitch = &Hal_EfusePowerSwitch; pHalFunc->ReadEFuse = &Hal_ReadEFuse; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 2645b649a9e0..89cee4df1bc0 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -117,11 +117,6 @@ struct hal_ops { s32 (*hal_xmitframe_enqueue)(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe); - u32 (*read_rfreg)(struct rtw_adapter *padapter, u32 eRFPath, - u32 RegAddr, u32 BitMask); - void (*write_rfreg)(struct rtw_adapter *padapter, u32 eRFPath, - u32 RegAddr, u32 BitMask, u32 Data); - void (*EfusePowerSwitch)(struct rtw_adapter *padapter, u8 bWrite, u8 PwrState); void (*ReadEFuse)(struct rtw_adapter *padapter, u8 efuseType, @@ -235,9 +230,6 @@ void rtw_hal_clone_data(struct rtw_adapter *dst_padapter, struct rtw_adapter *sr void rtw_hal_bcn_related_reg_setting23a(struct rtw_adapter *padapter); -u32 rtw_hal_read_rfreg23a(struct rtw_adapter *padapter, u32 eRFPath, u32 RegAddr, u32 BitMask); -void rtw_hal_write_rfreg23a(struct rtw_adapter *padapter, u32 eRFPath, u32 RegAddr, u32 BitMask, u32 Data); - s32 rtw_hal_interrupt_handler23a(struct rtw_adapter *padapter); void rtw_hal_set_bwmode23a(struct rtw_adapter *padapter, -- cgit v1.2.3 From 44e621c7a6234f5913ba315866712585fe6bc3e4 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:04 +0200 Subject: staging: rtl8723au: Remove HAL wrappers around read_chip_version Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_intf.c | 6 ------ drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 11 +---------- drivers/staging/rtl8723au/include/hal_intf.h | 4 ---- drivers/staging/rtl8723au/include/rtl8723a_hal.h | 1 + drivers/staging/rtl8723au/os_dep/usb_intf.c | 2 +- 5 files changed, 3 insertions(+), 21 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index d9be03dfd28d..81faaa579e37 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -28,12 +28,6 @@ void rtw_hal_chip_configure23a(struct rtw_adapter *padapter) padapter->HalFunc.intf_chip_configure(padapter); } -void rtw_hal_read_chip_version23a(struct rtw_adapter *padapter) -{ - if (padapter->HalFunc.read_chip_version) - padapter->HalFunc.read_chip_version(padapter); -} - void rtw_hal_free_data23a(struct rtw_adapter *padapter) { if (padapter->HalFunc.free_hal_data) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 681eee57c569..b2e2734f26c4 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1387,7 +1387,7 @@ Hal_EfusePgPacketWrite_BT(struct rtw_adapter *pAdapter, return true; } -static struct hal_version ReadChipVersion8723A(struct rtw_adapter *padapter) +void rtl8723a_read_chip_version(struct rtw_adapter *padapter) { u32 value32; struct hal_version ChipVersion; @@ -1433,13 +1433,6 @@ static struct hal_version ReadChipVersion8723A(struct rtw_adapter *padapter) pHalData->rf_type = RF_1T1R; MSG_8723A("RF_Type is %x!!\n", pHalData->rf_type); - - return ChipVersion; -} - -static void rtl8723a_read_chip_version(struct rtw_adapter *padapter) -{ - ReadChipVersion8723A(padapter); } /* */ @@ -1723,8 +1716,6 @@ void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc) { pHalFunc->free_hal_data = &rtl8723a_free_hal_data; - pHalFunc->read_chip_version = &rtl8723a_read_chip_version; - pHalFunc->set_bwmode_handler = &PHY_SetBWMode23a8723A; pHalFunc->set_channel_handler = &PHY_SwChnl8723A; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 89cee4df1bc0..b25a8a07d2ee 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -78,8 +78,6 @@ struct hal_ops { void (*InitSwLeds)(struct rtw_adapter *padapter); void (*DeInitSwLeds)(struct rtw_adapter *padapter); - void (*read_chip_version)(struct rtw_adapter *padapter); - void (*intf_chip_configure)(struct rtw_adapter *padapter); void (*enable_interrupt)(struct rtw_adapter *padapter); @@ -189,8 +187,6 @@ uint rtw_hal_deinit23a(struct rtw_adapter *padapter); void rtw_hal_stop(struct rtw_adapter *padapter); void rtw_hal_chip_configure23a(struct rtw_adapter *padapter); -void rtw_hal_read_chip_info23a(struct rtw_adapter *padapter); -void rtw_hal_read_chip_version23a(struct rtw_adapter *padapter); u8 rtw_hal_set_def_var23a(struct rtw_adapter *padapter, enum hal_def_variable eVariable, diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index 88a79dfb87c5..a1045ab0e1b0 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -547,6 +547,7 @@ s32 c2h_id_filter_ccx_8723a(u8 id); s32 c2h_handler_8723a(struct rtw_adapter *padapter, struct c2h_evt_hdr *c2h_evt); void rtl8723a_read_adapter_info(struct rtw_adapter *Adapter); +void rtl8723a_read_chip_version(struct rtw_adapter *padapter); void rtl8723a_notch_filter(struct rtw_adapter *adapter, bool enable); #endif diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index 09d0892b6bc5..26f5523be719 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -626,7 +626,7 @@ static struct rtw_adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, rtl8723au_set_intf_ops(padapter); /* step read_chip_version */ - rtw_hal_read_chip_version23a(padapter); + rtl8723a_read_chip_version(padapter); /* step usb endpoint mapping */ rtw_hal_chip_configure23a(padapter); -- cgit v1.2.3 From 1aaa37613ff34f2a2828aee3d9dfb9e83c6b340f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:05 +0200 Subject: staging: rtl8723au: Remove HAL wrappers about USB init/deinit Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_intf.c | 20 -------------------- drivers/staging/rtl8723au/hal/usb_halinit.c | 9 +++------ drivers/staging/rtl8723au/include/hal_intf.h | 6 ------ drivers/staging/rtl8723au/include/usb_ops.h | 2 ++ drivers/staging/rtl8723au/os_dep/usb_intf.c | 4 ++-- 5 files changed, 7 insertions(+), 34 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index 81faaa579e37..b462fc53aa92 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -129,26 +129,6 @@ void rtw_hal_disable_interrupt23a(struct rtw_adapter *padapter) } -u32 rtw_hal_inirp_init23a(struct rtw_adapter *padapter) -{ - u32 rst = _FAIL; - if (padapter->HalFunc.inirp_init) - rst = padapter->HalFunc.inirp_init(padapter); - else - DBG_8723A(" %s HalFunc.inirp_init is NULL!!!\n", __FUNCTION__); - return rst; -} - -u32 rtw_hal_inirp_deinit23a(struct rtw_adapter *padapter) -{ - - if (padapter->HalFunc.inirp_deinit) - return padapter->HalFunc.inirp_deinit(padapter); - - return _FAIL; - -} - s32 rtw_hal_xmit23aframe_enqueue(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe) { if (padapter->HalFunc.hal_xmitframe_enqueue) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 96be426d9f19..f202ff39537a 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1222,11 +1222,11 @@ static u32 rtl8723au_hal_deinit(struct rtw_adapter *padapter) return _SUCCESS; } -static unsigned int rtl8723au_inirp_init(struct rtw_adapter *Adapter) +int rtl8723au_inirp_init(struct rtw_adapter *Adapter) { u8 i; struct recv_buf *precvbuf; - uint status; + int status; struct _io_ops *io_ops = &Adapter->io_ops; struct recv_priv *precvpriv = &Adapter->recvpriv; u32 (*_read_port)(struct rtw_adapter *padapter, u32 addr, u32 cnt, @@ -1270,7 +1270,7 @@ exit: return status; } -static unsigned int rtl8723au_inirp_deinit(struct rtw_adapter *Adapter) +int rtl8723au_inirp_deinit(struct rtw_adapter *Adapter) { struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); @@ -1738,9 +1738,6 @@ int rtl8723au_set_hal_ops(struct rtw_adapter *padapter) pHalFunc->hal_init = &rtl8723au_hal_init; pHalFunc->hal_deinit = &rtl8723au_hal_deinit; - pHalFunc->inirp_init = &rtl8723au_inirp_init; - pHalFunc->inirp_deinit = &rtl8723au_inirp_deinit; - pHalFunc->init_xmit_priv = &rtl8723au_init_xmit_priv; pHalFunc->init_recv_priv = &rtl8723au_init_recv_priv; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index b25a8a07d2ee..f56d7578b74e 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -67,9 +67,6 @@ struct hal_ops { void (*free_hal_data)(struct rtw_adapter *padapter); - u32 (*inirp_init)(struct rtw_adapter *padapter); - u32 (*inirp_deinit)(struct rtw_adapter *padapter); - s32 (*init_xmit_priv)(struct rtw_adapter *padapter); s32 (*init_recv_priv)(struct rtw_adapter *padapter); @@ -205,9 +202,6 @@ void rtw_hal_get_odm_var23a(struct rtw_adapter *padapter, void rtw_hal_enable_interrupt23a(struct rtw_adapter *padapter); void rtw_hal_disable_interrupt23a(struct rtw_adapter *padapter); -u32 rtw_hal_inirp_init23a(struct rtw_adapter *padapter); -u32 rtw_hal_inirp_deinit23a(struct rtw_adapter *padapter); - s32 rtw_hal_xmit23aframe_enqueue(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe); s32 rtw_hal_xmit23a(struct rtw_adapter *padapter, diff --git a/drivers/staging/rtl8723au/include/usb_ops.h b/drivers/staging/rtl8723au/include/usb_ops.h index 1013406c9c77..3afdbda179c0 100644 --- a/drivers/staging/rtl8723au/include/usb_ops.h +++ b/drivers/staging/rtl8723au/include/usb_ops.h @@ -92,5 +92,7 @@ static inline u8 rtw_usb_bulk_size_boundary(struct rtw_adapter *padapter, return rst; } +int rtl8723au_inirp_init(struct rtw_adapter *Adapter); +int rtl8723au_inirp_deinit(struct rtw_adapter *Adapter); #endif /* __USB_OPS_H_ */ diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index 26f5523be719..d80c35544d33 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -289,7 +289,7 @@ static void decide_chip_type_by_usb_device_id(struct rtw_adapter *padapter, static void usb_intf_start(struct rtw_adapter *padapter) { RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+usb_intf_start\n")); - rtw_hal_inirp_init23a(padapter); + rtl8723au_inirp_init(padapter); RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-usb_intf_start\n")); } @@ -307,7 +307,7 @@ static void usb_intf_stop(struct rtw_adapter *padapter) } /* cancel in irp */ - rtw_hal_inirp_deinit23a(padapter); + rtl8723au_inirp_deinit(padapter); /* cancel out irp */ rtw_write_port_cancel(padapter); -- cgit v1.2.3 From db20a02baf6bb95bdb6e0b048f4fb28e830edc8b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:06 +0200 Subject: staging: rtl8723au: We love wrappers! Get rid of pointless wrapper around a simple kfree() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_intf.c | 5 ----- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 10 ---------- drivers/staging/rtl8723au/include/hal_intf.h | 4 ---- drivers/staging/rtl8723au/os_dep/os_intfs.c | 3 ++- 4 files changed, 2 insertions(+), 20 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index b462fc53aa92..ad8c430657d1 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -28,11 +28,6 @@ void rtw_hal_chip_configure23a(struct rtw_adapter *padapter) padapter->HalFunc.intf_chip_configure(padapter); } -void rtw_hal_free_data23a(struct rtw_adapter *padapter) -{ - if (padapter->HalFunc.free_hal_data) - padapter->HalFunc.free_hal_data(padapter); -} void rtw_hal_sw_led_init23a(struct rtw_adapter *padapter) { if (padapter->HalFunc.InitSwLeds) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index b2e2734f26c4..8764172faaa4 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -427,14 +427,6 @@ void rtl8723a_InitializeFirmwareVars(struct rtw_adapter *padapter) pHalData->LastHMEBoxNum = 0; } -static void rtl8723a_free_hal_data(struct rtw_adapter *padapter) -{ - - kfree(padapter->HalData); - padapter->HalData = NULL; - -} - /* */ /* Efuse related code */ /* */ @@ -1714,8 +1706,6 @@ exit: void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc) { - pHalFunc->free_hal_data = &rtl8723a_free_hal_data; - pHalFunc->set_bwmode_handler = &PHY_SetBWMode23a8723A; pHalFunc->set_channel_handler = &PHY_SwChnl8723A; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index f56d7578b74e..5009c7d73b65 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -65,8 +65,6 @@ struct hal_ops { u32 (*hal_init)(struct rtw_adapter *padapter); u32 (*hal_deinit)(struct rtw_adapter *padapter); - void (*free_hal_data)(struct rtw_adapter *padapter); - s32 (*init_xmit_priv)(struct rtw_adapter *padapter); s32 (*init_recv_priv)(struct rtw_adapter *padapter); @@ -173,8 +171,6 @@ void rtw_hal_def_value_init23a(struct rtw_adapter *padapter); int pm_netdev_open23a(struct net_device *pnetdev, u8 bnormal); int rtw_resume_process23a(struct rtw_adapter *padapter); -void rtw_hal_free_data23a(struct rtw_adapter *padapter); - void rtw_hal_sw_led_init23a(struct rtw_adapter *padapter); void rtw_hal_sw_led_deinit23a(struct rtw_adapter *padapter); diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index 38ad4ab45206..3a455d111a33 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -584,7 +584,8 @@ u8 rtw_free_drv_sw23a(struct rtw_adapter *padapter) rtw_free_pwrctrl_priv(padapter); - rtw_hal_free_data23a(padapter); + kfree(padapter->HalData); + padapter->HalData = NULL; RT_TRACE(_module_os_intfs_c_, _drv_info_, ("<== rtw_free_drv_sw23a\n")); -- cgit v1.2.3 From 82ccb5972409fe838dd695ce45b79dc597428a4a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:07 +0200 Subject: staging: rtl8723au: Disentangle chip_configure from HAL wrappers Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_intf.c | 6 ------ drivers/staging/rtl8723au/hal/usb_halinit.c | 3 +-- drivers/staging/rtl8723au/include/hal_intf.h | 4 ---- drivers/staging/rtl8723au/include/usb_ops.h | 1 + drivers/staging/rtl8723au/os_dep/usb_intf.c | 2 +- 5 files changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index ad8c430657d1..76c8b1fec777 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -22,12 +22,6 @@ #include #include -void rtw_hal_chip_configure23a(struct rtw_adapter *padapter) -{ - if (padapter->HalFunc.intf_chip_configure) - padapter->HalFunc.intf_chip_configure(padapter); -} - void rtw_hal_sw_led_init23a(struct rtw_adapter *padapter) { if (padapter->HalFunc.InitSwLeds) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index f202ff39537a..96ee3107cb58 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -82,7 +82,7 @@ static bool rtl8723au_set_queue_pipe_mapping(struct rtw_adapter *pAdapter, return result; } -static void rtl8723au_interface_configure(struct rtw_adapter *padapter) +void rtl8723au_chip_configure(struct rtw_adapter *padapter) { struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter); @@ -1745,7 +1745,6 @@ int rtl8723au_set_hal_ops(struct rtw_adapter *padapter) pHalFunc->InitSwLeds = NULL; pHalFunc->DeInitSwLeds = NULL; - pHalFunc->intf_chip_configure = &rtl8723au_interface_configure; pHalFunc->GetHalDefVarHandler = &GetHalDefVar8192CUsb; pHalFunc->SetHalDefVarHandler = &SetHalDefVar8192CUsb; pHalFunc->UpdateRAMaskHandler = &UpdateHalRAMask8192CUsb; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 5009c7d73b65..464c29aa8843 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -73,8 +73,6 @@ struct hal_ops { void (*InitSwLeds)(struct rtw_adapter *padapter); void (*DeInitSwLeds)(struct rtw_adapter *padapter); - void (*intf_chip_configure)(struct rtw_adapter *padapter); - void (*enable_interrupt)(struct rtw_adapter *padapter); void (*disable_interrupt)(struct rtw_adapter *padapter); s32 (*interrupt_handler)(struct rtw_adapter *padapter); @@ -179,8 +177,6 @@ uint rtw_hal_init23a(struct rtw_adapter *padapter); uint rtw_hal_deinit23a(struct rtw_adapter *padapter); void rtw_hal_stop(struct rtw_adapter *padapter); -void rtw_hal_chip_configure23a(struct rtw_adapter *padapter); - u8 rtw_hal_set_def_var23a(struct rtw_adapter *padapter, enum hal_def_variable eVariable, void *pValue); diff --git a/drivers/staging/rtl8723au/include/usb_ops.h b/drivers/staging/rtl8723au/include/usb_ops.h index 3afdbda179c0..2836631dee83 100644 --- a/drivers/staging/rtl8723au/include/usb_ops.h +++ b/drivers/staging/rtl8723au/include/usb_ops.h @@ -94,5 +94,6 @@ static inline u8 rtw_usb_bulk_size_boundary(struct rtw_adapter *padapter, int rtl8723au_inirp_init(struct rtw_adapter *Adapter); int rtl8723au_inirp_deinit(struct rtw_adapter *Adapter); +void rtl8723au_chip_configure(struct rtw_adapter *padapter); #endif /* __USB_OPS_H_ */ diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index d80c35544d33..a3379b7fa178 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -629,7 +629,7 @@ static struct rtw_adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, rtl8723a_read_chip_version(padapter); /* step usb endpoint mapping */ - rtw_hal_chip_configure23a(padapter); + rtl8723au_chip_configure(padapter); /* step read efuse/eeprom data and get mac_addr */ rtl8723a_read_adapter_info(padapter); -- cgit v1.2.3 From 8a6f555fed20672bbf0dc9044162894fed5b398f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:08 +0200 Subject: staging: rtl8723au: Call bandwidth and channel setting handlers directly Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 8 ++++---- drivers/staging/rtl8723au/hal/hal_intf.c | 14 -------------- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 3 --- drivers/staging/rtl8723au/include/hal_intf.h | 7 ------- 4 files changed, 4 insertions(+), 28 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index e7c67c396981..affb06764252 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -335,7 +335,7 @@ void SelectChannel23a(struct rtw_adapter *padapter, unsigned char channel) /* saved channel info */ rtw_set_oper_ch23a(padapter, channel); - rtw_hal_set_chan23a(padapter, channel); + PHY_SwChnl8723A(padapter, channel); mutex_unlock(&adapter_to_dvobj(padapter)->setch_mutex); } @@ -348,8 +348,8 @@ void SetBWMode23a(struct rtw_adapter *padapter, unsigned short bwmode, unsigned rtw_set_oper_bw23a(padapter, bwmode); rtw_set_oper_ch23aoffset23a(padapter, channel_offset); - rtw_hal_set_bwmode23a(padapter, (enum ht_channel_width)bwmode, - channel_offset); + PHY_SetBWMode23a8723A(padapter, (enum ht_channel_width)bwmode, + channel_offset); mutex_unlock(&adapter_to_dvobj(padapter)->setbw_mutex); } @@ -386,7 +386,7 @@ void set_channel_bwmode23a(struct rtw_adapter *padapter, unsigned char channel, rtw_set_oper_bw23a(padapter, bwmode); rtw_set_oper_ch23aoffset23a(padapter, channel_offset); - rtw_hal_set_chan23a(padapter, center_ch); /* set center channel */ + PHY_SwChnl8723A(padapter, center_ch); /* set center channel */ mutex_unlock(&adapter_to_dvobj(padapter)->setch_mutex); diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index 76c8b1fec777..9ee4df640a64 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -197,20 +197,6 @@ s32 rtw_hal_interrupt_handler23a(struct rtw_adapter *padapter) return _FAIL; } -void rtw_hal_set_bwmode23a(struct rtw_adapter *padapter, - enum ht_channel_width Bandwidth, u8 offset) -{ - if (padapter->HalFunc.set_bwmode_handler) - padapter->HalFunc.set_bwmode_handler(padapter, Bandwidth, - offset); -} - -void rtw_hal_set_chan23a(struct rtw_adapter *padapter, u8 channel) -{ - if (padapter->HalFunc.set_channel_handler) - padapter->HalFunc.set_channel_handler(padapter, channel); -} - void rtw_hal_bcn_related_reg_setting23a(struct rtw_adapter *padapter) { if (padapter->HalFunc.SetBeaconRelatedRegistersHandler) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 8764172faaa4..8002063a601c 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1706,9 +1706,6 @@ exit: void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc) { - pHalFunc->set_bwmode_handler = &PHY_SetBWMode23a8723A; - pHalFunc->set_channel_handler = &PHY_SwChnl8723A; - pHalFunc->SetBeaconRelatedRegistersHandler = &rtl8723a_SetBeaconRelatedRegisters; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 464c29aa8843..7dfd42b0a1f0 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -76,9 +76,6 @@ struct hal_ops { void (*enable_interrupt)(struct rtw_adapter *padapter); void (*disable_interrupt)(struct rtw_adapter *padapter); s32 (*interrupt_handler)(struct rtw_adapter *padapter); - void (*set_bwmode_handler)(struct rtw_adapter *padapter, - enum ht_channel_width Bandwidth, u8 Offset); - void (*set_channel_handler)(struct rtw_adapter *padapter, u8 channel); u8 (*GetHalDefVarHandler)(struct rtw_adapter *padapter, enum hal_def_variable eVariable, @@ -214,10 +211,6 @@ void rtw_hal_bcn_related_reg_setting23a(struct rtw_adapter *padapter); s32 rtw_hal_interrupt_handler23a(struct rtw_adapter *padapter); -void rtw_hal_set_bwmode23a(struct rtw_adapter *padapter, - enum ht_channel_width Bandwidth, u8 Offset); -void rtw_hal_set_chan23a(struct rtw_adapter *padapter, u8 channel); - void hw_var_set_correct_tsf(struct rtw_adapter *padapter); void hw_var_set_mlme_disconnect(struct rtw_adapter *padapter); void hw_var_set_opmode(struct rtw_adapter *padapter, u8 mode); -- cgit v1.2.3 From daf1fe8053adc9534b5f8975cb492a011cb8257f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:09 +0200 Subject: staging: rtl8732au: Remove some unused hal data pointers Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 8002063a601c..7a40cb102575 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1727,11 +1727,8 @@ void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc) void rtl8723a_InitAntenna_Selection(struct rtw_adapter *padapter) { - struct hal_data_8723a *pHalData; u8 val; - pHalData = GET_HAL_DATA(padapter); - val = rtw_read8(padapter, REG_LEDCFG2); /* Let 8051 take control antenna settting */ val |= BIT(7); /* DPDT_SEL_EN, 0x4C[23] */ @@ -1740,11 +1737,8 @@ void rtl8723a_InitAntenna_Selection(struct rtw_adapter *padapter) void rtl8723a_CheckAntenna_Selection(struct rtw_adapter *padapter) { - struct hal_data_8723a *pHalData; u8 val; - pHalData = GET_HAL_DATA(padapter); - val = rtw_read8(padapter, REG_LEDCFG2); /* Let 8051 take control antenna settting */ if (!(val & BIT(7))) { @@ -1755,10 +1749,8 @@ void rtl8723a_CheckAntenna_Selection(struct rtw_adapter *padapter) void rtl8723a_DeinitAntenna_Selection(struct rtw_adapter *padapter) { - struct hal_data_8723a *pHalData; u8 val; - pHalData = GET_HAL_DATA(padapter); val = rtw_read8(padapter, REG_LEDCFG2); /* Let 8051 take control antenna settting */ val &= ~BIT(7); /* DPDT_SEL_EN, clear 0x4C[23] */ -- cgit v1.2.3 From 88715bcdb15d4d92b6bf85d05df7d01d166e5c94 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:10 +0200 Subject: staging: rtl8723au: Disentangle beacon register settings from the HAL wrappers Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 4 ++-- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 5 ----- drivers/staging/rtl8723au/hal/hal_intf.c | 6 ------ drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 5 +---- drivers/staging/rtl8723au/include/hal_intf.h | 3 --- drivers/staging/rtl8723au/include/rtl8723a_hal.h | 1 + drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 1 - 7 files changed, 4 insertions(+), 21 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 9d40b08dd19f..1172fe9362a8 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -4674,7 +4674,7 @@ void start_create_ibss23a(struct rtw_adapter* padapter) /* SelectChannel23a(padapter, pmlmeext->cur_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE); */ set_channel_bwmode23a(padapter, pmlmeext->cur_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); - beacon_timing_control23a(padapter); + rtl8723a_SetBeaconRelatedRegisters(padapter); /* set msr to WIFI_FW_ADHOC_STATE */ pmlmeinfo->state = WIFI_FW_ADHOC_STATE; @@ -4752,7 +4752,7 @@ void start_clnt_join23a(struct rtw_adapter* padapter) /* switch channel */ set_channel_bwmode23a(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); - beacon_timing_control23a(padapter); + rtl8723a_SetBeaconRelatedRegisters(padapter); pmlmeinfo->state = WIFI_FW_ADHOC_STATE; diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index affb06764252..6dc7d068b6bd 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -1683,11 +1683,6 @@ void process_addba_req23a(struct rtw_adapter *padapter, } } -void beacon_timing_control23a(struct rtw_adapter *padapter) -{ - rtw_hal_bcn_related_reg_setting23a(padapter); -} - static struct rtw_adapter *pbuddy_padapter; int rtw_handle_dualmac23a(struct rtw_adapter *adapter, bool init) diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index 9ee4df640a64..251722bfda89 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -196,9 +196,3 @@ s32 rtw_hal_interrupt_handler23a(struct rtw_adapter *padapter) return padapter->HalFunc.interrupt_handler(padapter); return _FAIL; } - -void rtw_hal_bcn_related_reg_setting23a(struct rtw_adapter *padapter) -{ - if (padapter->HalFunc.SetBeaconRelatedRegistersHandler) - padapter->HalFunc.SetBeaconRelatedRegistersHandler(padapter); -} diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 7a40cb102575..1991e765bfc1 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1522,7 +1522,7 @@ static void _BeaconFunctionEnable(struct rtw_adapter *padapter, u8 Enable, rtw_write8(padapter, REG_RD_CTRL + 1, 0x6F); } -static void rtl8723a_SetBeaconRelatedRegisters(struct rtw_adapter *padapter) +void rtl8723a_SetBeaconRelatedRegisters(struct rtw_adapter *padapter) { u32 value32; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -1706,9 +1706,6 @@ exit: void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc) { - pHalFunc->SetBeaconRelatedRegistersHandler = - &rtl8723a_SetBeaconRelatedRegisters; - pHalFunc->Add_RateATid = &rtl8723a_add_rateatid; /* Efuse related function */ diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 7dfd42b0a1f0..8e2ed156fc6f 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -93,7 +93,6 @@ struct hal_ops { void (*UpdateRAMaskHandler)(struct rtw_adapter *padapter, u32 mac_id, u8 rssi_level); - void (*SetBeaconRelatedRegistersHandler)(struct rtw_adapter *padapter); void (*Add_RateATid)(struct rtw_adapter *padapter, u32 bitmap, u8 arg, u8 rssi_level); @@ -207,8 +206,6 @@ void rtw_hal_update_ra_mask23a(struct sta_info *psta, u8 rssi_level); void rtw_hal_add_ra_tid23a(struct rtw_adapter *padapter, u32 bitmap, u8 arg, u8 rssi_level); void rtw_hal_clone_data(struct rtw_adapter *dst_padapter, struct rtw_adapter *src_padapter); -void rtw_hal_bcn_related_reg_setting23a(struct rtw_adapter *padapter); - s32 rtw_hal_interrupt_handler23a(struct rtw_adapter *padapter); void hw_var_set_correct_tsf(struct rtw_adapter *padapter); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index a1045ab0e1b0..5ee9fb711630 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -549,5 +549,6 @@ s32 c2h_handler_8723a(struct rtw_adapter *padapter, struct c2h_evt_hdr *c2h_evt) void rtl8723a_read_adapter_info(struct rtw_adapter *Adapter); void rtl8723a_read_chip_version(struct rtw_adapter *padapter); void rtl8723a_notch_filter(struct rtw_adapter *adapter, bool enable); +void rtl8723a_SetBeaconRelatedRegisters(struct rtw_adapter *padapter); #endif diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index d185748ecd09..b2036998b61e 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -567,7 +567,6 @@ void report_del_sta_event23a(struct rtw_adapter *padapter, void report_add_sta_event23a(struct rtw_adapter *padapter, unsigned char *MacAddr, int cam_idx); -void beacon_timing_control23a(struct rtw_adapter *padapter); u8 set_tx_beacon_cmd23a(struct rtw_adapter*padapter); unsigned int setup_beacon_frame(struct rtw_adapter *padapter, unsigned char *beacon_frame); -- cgit v1.2.3 From 1ec69343ee9af67e01491d3d6ffb8f2d432966ac Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:11 +0200 Subject: staging: rtl8723au: Disentangle rtl8723a_add_rateatid() from HAL Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 6 +++--- drivers/staging/rtl8723au/hal/hal_intf.c | 6 ------ drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 2 -- drivers/staging/rtl8723au/include/hal_intf.h | 4 ---- 4 files changed, 3 insertions(+), 15 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 9e66c917ac59..4b2394803504 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -18,6 +18,7 @@ #include #include #include +#include #ifdef CONFIG_8723AU_AP_MODE @@ -430,7 +431,7 @@ void add_RATid23a(struct rtw_adapter *padapter, struct sta_info *psta, u8 rssi_l /* bitmap[28:31]= Rate Adaptive id */ /* arg[0:4] = macid */ /* arg[5] = Short GI */ - rtw_hal_add_ra_tid23a(padapter, tx_ra_bitmap, arg, rssi_level); + rtl8723a_add_rateatid(padapter, tx_ra_bitmap, arg, rssi_level); if (shortGIrate == true) init_rate |= BIT(6); @@ -513,8 +514,7 @@ static void update_bmc_sta(struct rtw_adapter *padapter) /* bitmap[28:31]= Rate Adaptive id */ /* arg[0:4] = macid */ /* arg[5] = Short GI */ - rtw_hal_add_ra_tid23a(padapter, tx_ra_bitmap, arg, 0); - + rtl8723a_add_rateatid(padapter, tx_ra_bitmap, arg, 0); } /* set ra_id, init_rate */ diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index 251722bfda89..4ee539bb8c06 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -184,12 +184,6 @@ void rtw_hal_update_ra_mask23a(struct sta_info *psta, u8 rssi_level) } } -void rtw_hal_add_ra_tid23a(struct rtw_adapter *padapter, u32 bitmap, u8 arg, u8 rssi_level) -{ - if (padapter->HalFunc.Add_RateATid) - padapter->HalFunc.Add_RateATid(padapter, bitmap, arg, rssi_level); -} - s32 rtw_hal_interrupt_handler23a(struct rtw_adapter *padapter) { if (padapter->HalFunc.interrupt_handler) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 1991e765bfc1..44d26b71d375 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1706,8 +1706,6 @@ exit: void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc) { - pHalFunc->Add_RateATid = &rtl8723a_add_rateatid; - /* Efuse related function */ pHalFunc->EfusePowerSwitch = &Hal_EfusePowerSwitch; pHalFunc->ReadEFuse = &Hal_ReadEFuse; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 8e2ed156fc6f..4b9777d6dcaa 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -94,9 +94,6 @@ struct hal_ops { void (*UpdateRAMaskHandler)(struct rtw_adapter *padapter, u32 mac_id, u8 rssi_level); - void (*Add_RateATid)(struct rtw_adapter *padapter, u32 bitmap, - u8 arg, u8 rssi_level); - s32 (*hal_xmit)(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe); s32 (*mgnt_xmit)(struct rtw_adapter *padapter, @@ -203,7 +200,6 @@ s32 rtw_hal_init23a_recv_priv(struct rtw_adapter *padapter); void rtw_hal_free_recv_priv23a(struct rtw_adapter *padapter); void rtw_hal_update_ra_mask23a(struct sta_info *psta, u8 rssi_level); -void rtw_hal_add_ra_tid23a(struct rtw_adapter *padapter, u32 bitmap, u8 arg, u8 rssi_level); void rtw_hal_clone_data(struct rtw_adapter *dst_padapter, struct rtw_adapter *src_padapter); s32 rtw_hal_interrupt_handler23a(struct rtw_adapter *padapter); -- cgit v1.2.3 From de9a5f01b202811d2fcf319c57d1e216ba6b0885 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:12 +0200 Subject: staging: rtl8723au: Get rid of unused rtw_hal_get_odm_var23() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_intf.c | 5 ----- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 13 ------------- drivers/staging/rtl8723au/include/hal_intf.h | 6 ------ 3 files changed, 24 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index 4ee539bb8c06..1bdebefb18b3 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -95,11 +95,6 @@ void rtw_hal_set_odm_var23a(struct rtw_adapter *padapter, enum hal_odm_variable if (padapter->HalFunc.SetHalODMVarHandler) padapter->HalFunc.SetHalODMVarHandler(padapter, eVariable, pValue1, bSet); } -void rtw_hal_get_odm_var23a(struct rtw_adapter *padapter, enum hal_odm_variable eVariable, void *pValue1, bool bSet) -{ - if (padapter->HalFunc.GetHalODMVarHandler) - padapter->HalFunc.GetHalODMVarHandler(padapter, eVariable, pValue1, bSet); -} void rtw_hal_enable_interrupt23a(struct rtw_adapter *padapter) { diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 44d26b71d375..971826a12e0a 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1577,18 +1577,6 @@ void rtl8723a_SetBeaconRelatedRegisters(struct rtw_adapter *padapter) SetBcnCtrlReg23a(padapter, DIS_BCNQ_SUB, 0); } -static void rtl8723a_GetHalODMVar(struct rtw_adapter *Adapter, - enum hal_odm_variable eVariable, - void *pValue1, bool bSet) -{ - switch (eVariable) { - case HAL_ODM_STA_INFO: - break; - default: - break; - } -} - static void rtl8723a_SetHalODMVar(struct rtw_adapter *Adapter, enum hal_odm_variable eVariable, void *pValue1, bool bSet) @@ -1716,7 +1704,6 @@ void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc) pHalFunc->Efuse_WordEnableDataWrite23a = &Hal_EfuseWordEnableDataWrite; pHalFunc->Efuse_PgPacketWrite23a_BT = &Hal_EfusePgPacketWrite_BT; - pHalFunc->GetHalODMVarHandler = &rtl8723a_GetHalODMVar; pHalFunc->SetHalODMVarHandler = &rtl8723a_SetHalODMVar; } diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 4b9777d6dcaa..5186899f5b83 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -84,9 +84,6 @@ struct hal_ops { enum hal_def_variable eVariable, void *pValue); - void (*GetHalODMVarHandler)(struct rtw_adapter *padapter, - enum hal_odm_variable eVariable, - void *pValue1, bool bSet); void (*SetHalODMVarHandler)(struct rtw_adapter *padapter, enum hal_odm_variable eVariable, void *pValue1, bool bSet); @@ -180,9 +177,6 @@ u8 rtw_hal_get_def_var23a(struct rtw_adapter *padapter, void rtw_hal_set_odm_var23a(struct rtw_adapter *padapter, enum hal_odm_variable eVariable, void *pValue1, bool bSet); -void rtw_hal_get_odm_var23a(struct rtw_adapter *padapter, - enum hal_odm_variable eVariable, - void *pValue1, bool bSet); void rtw_hal_enable_interrupt23a(struct rtw_adapter *padapter); void rtw_hal_disable_interrupt23a(struct rtw_adapter *padapter); -- cgit v1.2.3 From dbe9849cd41dfc66921fb18e9334f78f440b9221 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:13 +0200 Subject: staging: rtl8723au: Disentangle set_odm_var() from the HAL wrappers Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 5 +++-- drivers/staging/rtl8723au/core/rtw_mlme.c | 6 +++--- drivers/staging/rtl8723au/core/rtw_sta_mgt.c | 3 ++- drivers/staging/rtl8723au/hal/hal_intf.c | 6 ------ drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 8 +++----- drivers/staging/rtl8723au/include/hal_intf.h | 8 -------- drivers/staging/rtl8723au/include/rtl8723a_hal.h | 3 +++ 7 files changed, 14 insertions(+), 25 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 4b2394803504..0b7a4a68b5f4 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -19,6 +19,7 @@ #include #include #include +#include #ifdef CONFIG_8723AU_AP_MODE @@ -497,7 +498,7 @@ static void update_bmc_sta(struct rtw_adapter *padapter) init_rate = get_highest_rate_idx23a(tx_ra_bitmap&0x0fffffff)&0x3f; /* ap mode */ - rtw_hal_set_odm_var23a(padapter, HAL_ODM_STA_INFO, psta, true); + rtl8723a_SetHalODMVar(padapter, HAL_ODM_STA_INFO, psta, true); { u8 arg = 0; @@ -552,7 +553,7 @@ void update_sta_info23a_apmode23a(struct rtw_adapter *padapter, struct sta_info DBG_8723A("%s\n", __func__); /* ap mode */ - rtw_hal_set_odm_var23a(padapter, HAL_ODM_STA_INFO, psta, true); + rtl8723a_SetHalODMVar(padapter, HAL_ODM_STA_INFO, psta, true); if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) psta->ieee8021x_blocked = true; diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index b1f1fd6e6c9f..b675673dd995 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -1020,10 +1020,10 @@ rtw_joinbss_update_stainfo(struct rtw_adapter *padapter, DBG_8723A("%s\n", __func__); psta->aid = pnetwork->join_res; - psta->mac_id = 0; + psta->mac_id = 0; /* sta mode */ - rtw_hal_set_odm_var23a(padapter, HAL_ODM_STA_INFO, psta, true); + rtl8723a_SetHalODMVar(padapter, HAL_ODM_STA_INFO, psta, true); /* security related */ if (padapter->securitypriv.dot11AuthAlgrthm == @@ -1394,7 +1394,7 @@ void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf) /* psta->aid = (uint)pstassoc->cam_id; */ DBG_8723A("%s\n",__func__); /* for ad-hoc mode */ - rtw_hal_set_odm_var23a(adapter, HAL_ODM_STA_INFO, psta, true); + rtl8723a_SetHalODMVar(adapter, HAL_ODM_STA_INFO, psta, true); if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) psta->dot118021XPrivacy = diff --git a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c index 7f1f66c6709b..148bb4a2de2f 100644 --- a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c @@ -20,6 +20,7 @@ #include #include #include +#include static void _rtw_init_stainfo(struct sta_info *psta) { @@ -273,7 +274,7 @@ u32 rtw_free_stainfo23a(struct rtw_adapter *padapter, struct sta_info *psta) spin_unlock_bh(&ppending_recvframe_queue->lock); } if (!(psta->state & WIFI_AP_STATE)) - rtw_hal_set_odm_var23a(padapter, HAL_ODM_STA_INFO, psta, false); + rtl8723a_SetHalODMVar(padapter, HAL_ODM_STA_INFO, psta, false); #ifdef CONFIG_8723AU_AP_MODE spin_lock_bh(&pstapriv->auth_list_lock); if (!list_empty(&psta->auth_list)) { diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index 1bdebefb18b3..2a5c9cc4f048 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -90,12 +90,6 @@ u8 rtw_hal_get_def_var23a(struct rtw_adapter *padapter, enum hal_def_variable eV return _FAIL; } -void rtw_hal_set_odm_var23a(struct rtw_adapter *padapter, enum hal_odm_variable eVariable, void *pValue1, bool bSet) -{ - if (padapter->HalFunc.SetHalODMVarHandler) - padapter->HalFunc.SetHalODMVarHandler(padapter, eVariable, pValue1, bSet); -} - void rtw_hal_enable_interrupt23a(struct rtw_adapter *padapter) { if (padapter->HalFunc.enable_interrupt) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 971826a12e0a..5ee4923ab06a 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1577,9 +1577,9 @@ void rtl8723a_SetBeaconRelatedRegisters(struct rtw_adapter *padapter) SetBcnCtrlReg23a(padapter, DIS_BCNQ_SUB, 0); } -static void rtl8723a_SetHalODMVar(struct rtw_adapter *Adapter, - enum hal_odm_variable eVariable, - void *pValue1, bool bSet) +void rtl8723a_SetHalODMVar(struct rtw_adapter *Adapter, + enum hal_odm_variable eVariable, + void *pValue1, bool bSet) { struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); struct dm_odm_t *podmpriv = &pHalData->odmpriv; @@ -1703,8 +1703,6 @@ void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc) pHalFunc->Efuse_PgPacketWrite23a = &Hal_EfusePgPacketWrite; pHalFunc->Efuse_WordEnableDataWrite23a = &Hal_EfuseWordEnableDataWrite; pHalFunc->Efuse_PgPacketWrite23a_BT = &Hal_EfusePgPacketWrite_BT; - - pHalFunc->SetHalODMVarHandler = &rtl8723a_SetHalODMVar; } void rtl8723a_InitAntenna_Selection(struct rtw_adapter *padapter) diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 5186899f5b83..9ffcbb806cdf 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -84,10 +84,6 @@ struct hal_ops { enum hal_def_variable eVariable, void *pValue); - void (*SetHalODMVarHandler)(struct rtw_adapter *padapter, - enum hal_odm_variable eVariable, - void *pValue1, bool bSet); - void (*UpdateRAMaskHandler)(struct rtw_adapter *padapter, u32 mac_id, u8 rssi_level); @@ -174,10 +170,6 @@ u8 rtw_hal_get_def_var23a(struct rtw_adapter *padapter, enum hal_def_variable eVariable, void *pValue); -void rtw_hal_set_odm_var23a(struct rtw_adapter *padapter, - enum hal_odm_variable eVariable, - void *pValue1, bool bSet); - void rtw_hal_enable_interrupt23a(struct rtw_adapter *padapter); void rtw_hal_disable_interrupt23a(struct rtw_adapter *padapter); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index 5ee9fb711630..da1a88220803 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -550,5 +550,8 @@ void rtl8723a_read_adapter_info(struct rtw_adapter *Adapter); void rtl8723a_read_chip_version(struct rtw_adapter *padapter); void rtl8723a_notch_filter(struct rtw_adapter *adapter, bool enable); void rtl8723a_SetBeaconRelatedRegisters(struct rtw_adapter *padapter); +void rtl8723a_SetHalODMVar(struct rtw_adapter *Adapter, + enum hal_odm_variable eVariable, + void *pValue1, bool bSet); #endif -- cgit v1.2.3 From b2e68046fe19c4198d80137303e1e54741cbe7c2 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:14 +0200 Subject: staging: rtl8723au: Remove first half of EFUSE functions from HAL wrappers Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_efuse.c | 199 ++++++++++++++++------ drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 164 +----------------- drivers/staging/rtl8723au/include/hal_intf.h | 4 - drivers/staging/rtl8723au/include/rtl8723a_hal.h | 5 + 4 files changed, 156 insertions(+), 216 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_efuse.c b/drivers/staging/rtl8723au/core/rtw_efuse.c index 35b177fd0510..1c8795620776 100644 --- a/drivers/staging/rtl8723au/core/rtw_efuse.c +++ b/drivers/staging/rtl8723au/core/rtw_efuse.c @@ -18,6 +18,7 @@ #include #include +#include /*------------------------Define local variable------------------------------*/ @@ -26,8 +27,11 @@ #define EFUSE_CTRL REG_EFUSE_CTRL /* E-Fuse Control. */ /* */ +#define VOLTAGE_V25 0x03 +#define LDOE25_SHIFT 28 + /*----------------------------------------------------------------------------- - * Function: Efuse_PowerSwitch23a + * Function: Efuse_PowerSwitch * * Overview: When we want to enable write operation, we should change to * pwr on state. When we stop write, we should switch to 500k mode @@ -44,13 +48,53 @@ * 11/17/2008 MHC Create Version 0. * *---------------------------------------------------------------------------*/ -void -Efuse_PowerSwitch23a( - struct rtw_adapter * pAdapter, - u8 bWrite, - u8 PwrState) +static void Efuse_PowerSwitch(struct rtw_adapter *padapter, + u8 bWrite, u8 PwrState) { - pAdapter->HalFunc.EfusePowerSwitch(pAdapter, bWrite, PwrState); + u8 tempval; + u16 tmpV16; + + if (PwrState == true) { + rtw_write8(padapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_ON); + + /* 1.2V Power: From VDDON with Power + Cut(0x0000h[15]), defualt valid */ + tmpV16 = rtw_read16(padapter, REG_SYS_ISO_CTRL); + if (!(tmpV16 & PWC_EV12V)) { + tmpV16 |= PWC_EV12V; + rtw_write16(padapter, REG_SYS_ISO_CTRL, tmpV16); + } + /* Reset: 0x0000h[28], default valid */ + tmpV16 = rtw_read16(padapter, REG_SYS_FUNC_EN); + if (!(tmpV16 & FEN_ELDR)) { + tmpV16 |= FEN_ELDR; + rtw_write16(padapter, REG_SYS_FUNC_EN, tmpV16); + } + + /* Clock: Gated(0x0008h[5]) 8M(0x0008h[1]) clock + from ANA, default valid */ + tmpV16 = rtw_read16(padapter, REG_SYS_CLKR); + if ((!(tmpV16 & LOADER_CLK_EN)) || (!(tmpV16 & ANA8M))) { + tmpV16 |= (LOADER_CLK_EN | ANA8M); + rtw_write16(padapter, REG_SYS_CLKR, tmpV16); + } + + if (bWrite == true) { + /* Enable LDO 2.5V before read/write action */ + tempval = rtw_read8(padapter, EFUSE_TEST + 3); + tempval &= 0x0F; + tempval |= (VOLTAGE_V25 << 4); + rtw_write8(padapter, EFUSE_TEST + 3, (tempval | 0x80)); + } + } else { + rtw_write8(padapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_OFF); + + if (bWrite == true) { + /* Disable LDO 2.5V after read/write action */ + tempval = rtw_read8(padapter, EFUSE_TEST + 3); + rtw_write8(padapter, EFUSE_TEST + 3, (tempval & 0x7F)); + } + } } /*----------------------------------------------------------------------------- @@ -74,7 +118,10 @@ Efuse_GetCurrentSize23a(struct rtw_adapter *pAdapter, u8 efuseType) { u16 ret = 0; - ret = pAdapter->HalFunc.EfuseGetCurrentSize(pAdapter, efuseType); + if (efuseType == EFUSE_WIFI) + ret = rtl8723a_EfuseGetCurrentSize_WiFi(pAdapter); + else + ret = rtl8723a_EfuseGetCurrentSize_BT(pAdapter); return ret; } @@ -138,41 +185,87 @@ ReadEFuseByte23a(struct rtw_adapter *Adapter, u16 _offset, u8 *pbuf) *pbuf = (u8)(value32 & 0xff); } -/* */ -/* Description: */ -/* 1. Execute E-Fuse read byte operation according as map offset and */ -/* save to E-Fuse table. */ -/* 2. Refered from SD1 Richard. */ -/* */ -/* Assumption: */ -/* 1. Boot from E-Fuse and successfully auto-load. */ -/* 2. PASSIVE_LEVEL (USB interface) */ -/* */ -/* Created by Roger, 2008.10.21. */ -/* */ -/* 2008/12/12 MH 1. Reorganize code flow and reserve bytes. and add description. */ -/* 2. Add efuse utilization collect. */ -/* 2008/12/22 MH Read Efuse must check if we write section 1 data again!!! Sec1 */ -/* write addr must be after sec5. */ -/* */ - -void -efuse_ReadEFuse(struct rtw_adapter *Adapter, u8 efuseType, - u16 _offset, u16 _size_byte, u8 *pbuf); -void -efuse_ReadEFuse(struct rtw_adapter *Adapter, u8 efuseType, - u16 _offset, u16 _size_byte, u8 *pbuf) -{ - Adapter->HalFunc.ReadEFuse(Adapter, efuseType, _offset, - _size_byte, pbuf); -} - void EFUSE_GetEfuseDefinition23a(struct rtw_adapter *pAdapter, u8 efuseType, - u8 type, void *pOut) + u8 type, void *pOut) { - pAdapter->HalFunc.EFUSEGetEfuseDefinition(pAdapter, efuseType, - type, pOut); + u8 *pu1Tmp; + u16 *pu2Tmp; + u8 *pMax_section; + + switch (type) { + case TYPE_EFUSE_MAX_SECTION: + pMax_section = (u8 *) pOut; + + if (efuseType == EFUSE_WIFI) + *pMax_section = EFUSE_MAX_SECTION_8723A; + else + *pMax_section = EFUSE_BT_MAX_SECTION; + break; + + case TYPE_EFUSE_REAL_CONTENT_LEN: + pu2Tmp = (u16 *) pOut; + + if (efuseType == EFUSE_WIFI) + *pu2Tmp = EFUSE_REAL_CONTENT_LEN_8723A; + else + *pu2Tmp = EFUSE_BT_REAL_CONTENT_LEN; + break; + + case TYPE_AVAILABLE_EFUSE_BYTES_BANK: + pu2Tmp = (u16 *) pOut; + + if (efuseType == EFUSE_WIFI) + *pu2Tmp = (EFUSE_REAL_CONTENT_LEN_8723A - + EFUSE_OOB_PROTECT_BYTES); + else + *pu2Tmp = (EFUSE_BT_REAL_BANK_CONTENT_LEN - + EFUSE_PROTECT_BYTES_BANK); + break; + + case TYPE_AVAILABLE_EFUSE_BYTES_TOTAL: + pu2Tmp = (u16 *) pOut; + + if (efuseType == EFUSE_WIFI) + *pu2Tmp = (EFUSE_REAL_CONTENT_LEN_8723A - + EFUSE_OOB_PROTECT_BYTES); + else + *pu2Tmp = (EFUSE_BT_REAL_CONTENT_LEN - + (EFUSE_PROTECT_BYTES_BANK * 3)); + break; + + case TYPE_EFUSE_MAP_LEN: + pu2Tmp = (u16 *) pOut; + + if (efuseType == EFUSE_WIFI) + *pu2Tmp = EFUSE_MAP_LEN_8723A; + else + *pu2Tmp = EFUSE_BT_MAP_LEN; + break; + + case TYPE_EFUSE_PROTECT_BYTES_BANK: + pu1Tmp = (u8 *) pOut; + + if (efuseType == EFUSE_WIFI) + *pu1Tmp = EFUSE_OOB_PROTECT_BYTES; + else + *pu1Tmp = EFUSE_PROTECT_BYTES_BANK; + break; + + case TYPE_EFUSE_CONTENT_LEN_BANK: + pu2Tmp = (u16 *) pOut; + + if (efuseType == EFUSE_WIFI) + *pu2Tmp = EFUSE_REAL_CONTENT_LEN_8723A; + else + *pu2Tmp = EFUSE_BT_REAL_BANK_CONTENT_LEN; + break; + + default: + pu1Tmp = (u8 *) pOut; + *pu1Tmp = 0; + break; + } } /*----------------------------------------------------------------------------- @@ -488,7 +581,7 @@ u8 rtw_efuse_access23a(struct rtw_adapter *padapter, u8 bWrite, u16 start_addr, } else rw8 = &efuse_read8; - Efuse_PowerSwitch23a(padapter, bWrite, true); + Efuse_PowerSwitch(padapter, bWrite, true); /* e-fuse one byte read / write */ for (i = 0; i < cnts; i++) { @@ -501,7 +594,7 @@ u8 rtw_efuse_access23a(struct rtw_adapter *padapter, u8 bWrite, u16 start_addr, if (_FAIL == res) break; } - Efuse_PowerSwitch23a(padapter, bWrite, false); + Efuse_PowerSwitch(padapter, bWrite, false); return res; } @@ -517,9 +610,9 @@ u16 efuse_GetMaxSize23a(struct rtw_adapter *padapter) /* */ u8 efuse_GetCurrentSize23a(struct rtw_adapter *padapter, u16 *size) { - Efuse_PowerSwitch23a(padapter, false, true); + Efuse_PowerSwitch(padapter, false, true); *size = Efuse_GetCurrentSize23a(padapter, EFUSE_WIFI); - Efuse_PowerSwitch23a(padapter, false, false); + Efuse_PowerSwitch(padapter, false, false); return _SUCCESS; } @@ -534,11 +627,11 @@ u8 rtw_efuse_map_read23a(struct rtw_adapter *padapter, u16 addr, u16 cnts, u8 *d if ((addr + cnts) > mapLen) return _FAIL; - Efuse_PowerSwitch23a(padapter, false, true); + Efuse_PowerSwitch(padapter, false, true); - efuse_ReadEFuse(padapter, EFUSE_WIFI, addr, cnts, data); + rtl8723a_readefuse(padapter, EFUSE_WIFI, addr, cnts, data); - Efuse_PowerSwitch23a(padapter, false, false); + Efuse_PowerSwitch(padapter, false, false); return _SUCCESS; } @@ -553,11 +646,11 @@ u8 rtw_BT_efuse_map_read23a(struct rtw_adapter *padapter, u16 addr, u16 cnts, u8 if ((addr + cnts) > mapLen) return _FAIL; - Efuse_PowerSwitch23a(padapter, false, true); + Efuse_PowerSwitch(padapter, false, true); - efuse_ReadEFuse(padapter, EFUSE_BT, addr, cnts, data); + rtl8723a_readefuse(padapter, EFUSE_BT, addr, cnts, data); - Efuse_PowerSwitch23a(padapter, false, false); + Efuse_PowerSwitch(padapter, false, false); return _SUCCESS; } @@ -585,14 +678,14 @@ Efuse_ReadAllMap(struct rtw_adapter *pAdapter, u8 efuseType, u8 *Efuse) { u16 mapLen = 0; - Efuse_PowerSwitch23a(pAdapter, false, true); + Efuse_PowerSwitch(pAdapter, false, true); EFUSE_GetEfuseDefinition23a(pAdapter, efuseType, TYPE_EFUSE_MAP_LEN, (void *)&mapLen); - efuse_ReadEFuse(pAdapter, efuseType, 0, mapLen, Efuse); + rtl8723a_readefuse(pAdapter, efuseType, 0, mapLen, Efuse); - Efuse_PowerSwitch23a(pAdapter, false, false); + Efuse_PowerSwitch(pAdapter, false, false); } /*----------------------------------------------------------------------------- diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 5ee4923ab06a..283f0f0f1a12 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -467,141 +467,6 @@ hal_EfuseSwitchToBank(struct rtw_adapter *padapter, u8 bank) return bRet; } -static void -Hal_GetEfuseDefinition(struct rtw_adapter *padapter, - u8 efuseType, u8 type, void *pOut) -{ - u8 *pu1Tmp; - u16 *pu2Tmp; - u8 *pMax_section; - - switch (type) { - case TYPE_EFUSE_MAX_SECTION: - pMax_section = (u8 *) pOut; - - if (efuseType == EFUSE_WIFI) - *pMax_section = EFUSE_MAX_SECTION_8723A; - else - *pMax_section = EFUSE_BT_MAX_SECTION; - break; - - case TYPE_EFUSE_REAL_CONTENT_LEN: - pu2Tmp = (u16 *) pOut; - - if (efuseType == EFUSE_WIFI) - *pu2Tmp = EFUSE_REAL_CONTENT_LEN_8723A; - else - *pu2Tmp = EFUSE_BT_REAL_CONTENT_LEN; - break; - - case TYPE_AVAILABLE_EFUSE_BYTES_BANK: - pu2Tmp = (u16 *) pOut; - - if (efuseType == EFUSE_WIFI) - *pu2Tmp = (EFUSE_REAL_CONTENT_LEN_8723A - - EFUSE_OOB_PROTECT_BYTES); - else - *pu2Tmp = (EFUSE_BT_REAL_BANK_CONTENT_LEN - - EFUSE_PROTECT_BYTES_BANK); - break; - - case TYPE_AVAILABLE_EFUSE_BYTES_TOTAL: - pu2Tmp = (u16 *) pOut; - - if (efuseType == EFUSE_WIFI) - *pu2Tmp = (EFUSE_REAL_CONTENT_LEN_8723A - - EFUSE_OOB_PROTECT_BYTES); - else - *pu2Tmp = (EFUSE_BT_REAL_CONTENT_LEN - - (EFUSE_PROTECT_BYTES_BANK * 3)); - break; - - case TYPE_EFUSE_MAP_LEN: - pu2Tmp = (u16 *) pOut; - - if (efuseType == EFUSE_WIFI) - *pu2Tmp = EFUSE_MAP_LEN_8723A; - else - *pu2Tmp = EFUSE_BT_MAP_LEN; - break; - - case TYPE_EFUSE_PROTECT_BYTES_BANK: - pu1Tmp = (u8 *) pOut; - - if (efuseType == EFUSE_WIFI) - *pu1Tmp = EFUSE_OOB_PROTECT_BYTES; - else - *pu1Tmp = EFUSE_PROTECT_BYTES_BANK; - break; - - case TYPE_EFUSE_CONTENT_LEN_BANK: - pu2Tmp = (u16 *) pOut; - - if (efuseType == EFUSE_WIFI) - *pu2Tmp = EFUSE_REAL_CONTENT_LEN_8723A; - else - *pu2Tmp = EFUSE_BT_REAL_BANK_CONTENT_LEN; - break; - - default: - pu1Tmp = (u8 *) pOut; - *pu1Tmp = 0; - break; - } -} - -#define VOLTAGE_V25 0x03 -#define LDOE25_SHIFT 28 - -static void -Hal_EfusePowerSwitch(struct rtw_adapter *padapter, u8 bWrite, u8 PwrState) -{ - u8 tempval; - u16 tmpV16; - - if (PwrState == true) { - rtw_write8(padapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_ON); - - /* 1.2V Power: From VDDON with Power - Cut(0x0000h[15]), defualt valid */ - tmpV16 = rtw_read16(padapter, REG_SYS_ISO_CTRL); - if (!(tmpV16 & PWC_EV12V)) { - tmpV16 |= PWC_EV12V; - rtw_write16(padapter, REG_SYS_ISO_CTRL, tmpV16); - } - /* Reset: 0x0000h[28], default valid */ - tmpV16 = rtw_read16(padapter, REG_SYS_FUNC_EN); - if (!(tmpV16 & FEN_ELDR)) { - tmpV16 |= FEN_ELDR; - rtw_write16(padapter, REG_SYS_FUNC_EN, tmpV16); - } - - /* Clock: Gated(0x0008h[5]) 8M(0x0008h[1]) clock - from ANA, default valid */ - tmpV16 = rtw_read16(padapter, REG_SYS_CLKR); - if ((!(tmpV16 & LOADER_CLK_EN)) || (!(tmpV16 & ANA8M))) { - tmpV16 |= (LOADER_CLK_EN | ANA8M); - rtw_write16(padapter, REG_SYS_CLKR, tmpV16); - } - - if (bWrite == true) { - /* Enable LDO 2.5V before read/write action */ - tempval = rtw_read8(padapter, EFUSE_TEST + 3); - tempval &= 0x0F; - tempval |= (VOLTAGE_V25 << 4); - rtw_write8(padapter, EFUSE_TEST + 3, (tempval | 0x80)); - } - } else { - rtw_write8(padapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_OFF); - - if (bWrite == true) { - /* Disable LDO 2.5V after read/write action */ - tempval = rtw_read8(padapter, EFUSE_TEST + 3); - rtw_write8(padapter, EFUSE_TEST + 3, (tempval & 0x7F)); - } - } -} - static void hal_ReadEFuse_WiFi(struct rtw_adapter *padapter, u16 _offset, u16 _size_byte, u8 *pbuf) @@ -812,9 +677,9 @@ exit: kfree(efuseTbl); } -static void -Hal_ReadEFuse(struct rtw_adapter *padapter, - u8 efuseType, u16 _offset, u16 _size_byte, u8 *pbuf) +void +rtl8723a_readefuse(struct rtw_adapter *padapter, + u8 efuseType, u16 _offset, u16 _size_byte, u8 *pbuf) { if (efuseType == EFUSE_WIFI) hal_ReadEFuse_WiFi(padapter, _offset, _size_byte, pbuf); @@ -822,8 +687,7 @@ Hal_ReadEFuse(struct rtw_adapter *padapter, hal_ReadEFuse_BT(padapter, _offset, _size_byte, pbuf); } -static u16 -hal_EfuseGetCurrentSize_WiFi(struct rtw_adapter *padapter) +u16 rtl8723a_EfuseGetCurrentSize_WiFi(struct rtw_adapter *padapter) { u16 efuse_addr = 0; u8 hoffset = 0, hworden = 0; @@ -874,8 +738,7 @@ hal_EfuseGetCurrentSize_WiFi(struct rtw_adapter *padapter) return efuse_addr; } -static u16 -hal_EfuseGetCurrentSize_BT(struct rtw_adapter *padapter) +u16 rtl8723a_EfuseGetCurrentSize_BT(struct rtw_adapter *padapter) { u16 btusedbytes; u16 efuse_addr; @@ -956,19 +819,6 @@ hal_EfuseGetCurrentSize_BT(struct rtw_adapter *padapter) return retU2; } -static u16 -Hal_EfuseGetCurrentSize(struct rtw_adapter *pAdapter, u8 efuseType) -{ - u16 ret = 0; - - if (efuseType == EFUSE_WIFI) - ret = hal_EfuseGetCurrentSize_WiFi(pAdapter); - else - ret = hal_EfuseGetCurrentSize_BT(pAdapter); - - return ret; -} - static u8 Hal_EfuseWordEnableDataWrite(struct rtw_adapter *padapter, u16 efuse_addr, u8 word_en, u8 *data) @@ -1695,10 +1545,6 @@ exit: void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc) { /* Efuse related function */ - pHalFunc->EfusePowerSwitch = &Hal_EfusePowerSwitch; - pHalFunc->ReadEFuse = &Hal_ReadEFuse; - pHalFunc->EFUSEGetEfuseDefinition = &Hal_GetEfuseDefinition; - pHalFunc->EfuseGetCurrentSize = &Hal_EfuseGetCurrentSize; pHalFunc->Efuse_PgPacketRead23a = &Hal_EfusePgPacketRead; pHalFunc->Efuse_PgPacketWrite23a = &Hal_EfusePgPacketWrite; pHalFunc->Efuse_WordEnableDataWrite23a = &Hal_EfuseWordEnableDataWrite; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 9ffcbb806cdf..b8fd4033e2bb 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -94,10 +94,6 @@ struct hal_ops { s32 (*hal_xmitframe_enqueue)(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe); - void (*EfusePowerSwitch)(struct rtw_adapter *padapter, u8 bWrite, - u8 PwrState); - void (*ReadEFuse)(struct rtw_adapter *padapter, u8 efuseType, - u16 _offset, u16 _size_byte, u8 *pbuf); void (*EFUSEGetEfuseDefinition)(struct rtw_adapter *padapter, u8 efuseType, u8 type, void *pOut); u16 (*EfuseGetCurrentSize)(struct rtw_adapter *padapter, u8 efuseType); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index da1a88220803..b61f37f7a308 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -553,5 +553,10 @@ void rtl8723a_SetBeaconRelatedRegisters(struct rtw_adapter *padapter); void rtl8723a_SetHalODMVar(struct rtw_adapter *Adapter, enum hal_odm_variable eVariable, void *pValue1, bool bSet); +void +rtl8723a_readefuse(struct rtw_adapter *padapter, + u8 efuseType, u16 _offset, u16 _size_byte, u8 *pbuf); +u16 rtl8723a_EfuseGetCurrentSize_WiFi(struct rtw_adapter *padapter); +u16 rtl8723a_EfuseGetCurrentSize_BT(struct rtw_adapter *padapter); #endif -- cgit v1.2.3 From a4f6eb1e8ea62d9bdb9a53f669066c0def35bcca Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:15 +0200 Subject: staging: rtl8723au: Remove a pile of unused EFUSE read/write functionality All this code was only pulled in since it was registered in the HAL wrapper interface, despite it never being called. It also removes the lasts pieces of code from rtl8723a_set_hal_ops(), so remove it as well. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_efuse.c | 34 --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 345 +--------------------- drivers/staging/rtl8723au/hal/usb_halinit.c | 1 - drivers/staging/rtl8723au/include/hal_intf.h | 13 - drivers/staging/rtl8723au/include/rtl8723a_hal.h | 1 - 5 files changed, 2 insertions(+), 392 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_efuse.c b/drivers/staging/rtl8723au/core/rtw_efuse.c index 1c8795620776..8ba5166a2559 100644 --- a/drivers/staging/rtl8723au/core/rtw_efuse.c +++ b/drivers/staging/rtl8723au/core/rtw_efuse.c @@ -465,28 +465,6 @@ efuse_OneByteWrite23a(struct rtw_adapter *pAdapter, u16 addr, u8 data) return bResult; } -int -Efuse_PgPacketRead23a(struct rtw_adapter *pAdapter, u8 offset, u8 *data) -{ - int ret = 0; - - ret = pAdapter->HalFunc.Efuse_PgPacketRead23a(pAdapter, offset, data); - - return ret; -} - -int -Efuse_PgPacketWrite23a(struct rtw_adapter *pAdapter, u8 offset, - u8 word_en, u8 *data) -{ - int ret; - - ret = pAdapter->HalFunc.Efuse_PgPacketWrite23a(pAdapter, offset, - word_en, data); - - return ret; -} - /*----------------------------------------------------------------------------- * Function: efuse_WordEnableDataRead23a * @@ -531,18 +509,6 @@ efuse_WordEnableDataRead23a(u8 word_en, } } -u8 -Efuse_WordEnableDataWrite23a(struct rtw_adapter *pAdapter, u16 efuse_addr, - u8 word_en, u8 *data) -{ - u8 ret = 0; - - ret = pAdapter->HalFunc.Efuse_WordEnableDataWrite23a(pAdapter, efuse_addr, - word_en, data); - - return ret; -} - static u8 efuse_read8(struct rtw_adapter *padapter, u16 address, u8 *value) { return efuse_OneByteRead23a(padapter, address, value); diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 283f0f0f1a12..ca122d0f80a6 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -819,67 +819,8 @@ u16 rtl8723a_EfuseGetCurrentSize_BT(struct rtw_adapter *padapter) return retU2; } -static u8 -Hal_EfuseWordEnableDataWrite(struct rtw_adapter *padapter, - u16 efuse_addr, u8 word_en, u8 *data) -{ - u16 tmpaddr = 0; - u16 start_addr = efuse_addr; - u8 badworden = 0x0F; - u8 tmpdata[PGPKT_DATA_SIZE]; - - memset(tmpdata, 0xFF, PGPKT_DATA_SIZE); - - if (!(word_en & BIT(0))) { - tmpaddr = start_addr; - efuse_OneByteWrite23a(padapter, start_addr++, data[0]); - efuse_OneByteWrite23a(padapter, start_addr++, data[1]); - - efuse_OneByteRead23a(padapter, tmpaddr, &tmpdata[0]); - efuse_OneByteRead23a(padapter, tmpaddr + 1, &tmpdata[1]); - if ((data[0] != tmpdata[0]) || (data[1] != tmpdata[1])) { - badworden &= ~BIT(0); - } - } - if (!(word_en & BIT(1))) { - tmpaddr = start_addr; - efuse_OneByteWrite23a(padapter, start_addr++, data[2]); - efuse_OneByteWrite23a(padapter, start_addr++, data[3]); - - efuse_OneByteRead23a(padapter, tmpaddr, &tmpdata[2]); - efuse_OneByteRead23a(padapter, tmpaddr + 1, &tmpdata[3]); - if ((data[2] != tmpdata[2]) || (data[3] != tmpdata[3])) { - badworden &= ~BIT(1); - } - } - if (!(word_en & BIT(2))) { - tmpaddr = start_addr; - efuse_OneByteWrite23a(padapter, start_addr++, data[4]); - efuse_OneByteWrite23a(padapter, start_addr++, data[5]); - - efuse_OneByteRead23a(padapter, tmpaddr, &tmpdata[4]); - efuse_OneByteRead23a(padapter, tmpaddr + 1, &tmpdata[5]); - if ((data[4] != tmpdata[4]) || (data[5] != tmpdata[5])) { - badworden &= ~BIT(2); - } - } - if (!(word_en & BIT(3))) { - tmpaddr = start_addr; - efuse_OneByteWrite23a(padapter, start_addr++, data[6]); - efuse_OneByteWrite23a(padapter, start_addr++, data[7]); - - efuse_OneByteRead23a(padapter, tmpaddr, &tmpdata[6]); - efuse_OneByteRead23a(padapter, tmpaddr + 1, &tmpdata[7]); - if ((data[6] != tmpdata[6]) || (data[7] != tmpdata[7])) { - badworden &= ~BIT(3); - } - } - - return badworden; -} - -static s32 -Hal_EfusePgPacketRead(struct rtw_adapter *padapter, u8 offset, u8 *data) +bool +rtl8723a_EfusePgPacketRead(struct rtw_adapter *padapter, u8 offset, u8 *data) { u8 efuse_data, word_cnts = 0; u16 efuse_addr = 0; @@ -956,279 +897,6 @@ Hal_EfusePgPacketRead(struct rtw_adapter *padapter, u8 offset, u8 *data) return ret; } -static u8 -hal_EfusePgCheckAvailableAddr(struct rtw_adapter *pAdapter, u8 efuseType) -{ - u16 max_available = 0; - u16 current_size; - - EFUSE_GetEfuseDefinition23a(pAdapter, efuseType, - TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, - &max_available); - - current_size = Efuse_GetCurrentSize23a(pAdapter, efuseType); - if (current_size >= max_available) { - DBG_8723A("%s: Error!! current_size(%d)>max_available(%d)\n", - __func__, current_size, max_available); - return false; - } - return true; -} - -static void -hal_EfuseConstructPGPkt(u8 offset, u8 word_en, u8 *pData, - struct pg_pkt_struct *pTargetPkt) -{ - memset(pTargetPkt->data, 0xFF, PGPKT_DATA_SIZE); - pTargetPkt->offset = offset; - pTargetPkt->word_en = word_en; - efuse_WordEnableDataRead23a(word_en, pData, pTargetPkt->data); - pTargetPkt->word_cnts = Efuse_CalculateWordCnts23a(pTargetPkt->word_en); -} - -static u8 -hal_EfusePartialWriteCheck(struct rtw_adapter *padapter, u8 efuseType, - u16 *pAddr, struct pg_pkt_struct *pTargetPkt) -{ - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - u8 bRet = false; - u16 startAddr = 0, efuse_max_available_len = 0, efuse_max = 0; - u8 efuse_data = 0; - - EFUSE_GetEfuseDefinition23a(padapter, efuseType, - TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, - &efuse_max_available_len); - EFUSE_GetEfuseDefinition23a(padapter, efuseType, - TYPE_EFUSE_CONTENT_LEN_BANK, &efuse_max); - - if (efuseType == EFUSE_WIFI) - startAddr = pHalData->EfuseUsedBytes; - else - startAddr = pHalData->BTEfuseUsedBytes; - - startAddr %= efuse_max; - - while (1) { - if (startAddr >= efuse_max_available_len) { - bRet = false; - DBG_8723A("%s: startAddr(%d) >= efuse_max_available_" - "len(%d)\n", __func__, startAddr, - efuse_max_available_len); - break; - } - - if (efuse_OneByteRead23a(padapter, startAddr, &efuse_data) && - (efuse_data != 0xFF)) { - bRet = false; - DBG_8723A("%s: Something Wrong! last bytes(%#X = 0x%02X) " - "is not 0xFF\n", __func__, - startAddr, efuse_data); - break; - } else { - /* not used header, 0xff */ - *pAddr = startAddr; - bRet = true; - break; - } - } - - return bRet; -} - -static u8 -hal_EfusePgPacketWrite1ByteHeader(struct rtw_adapter *pAdapter, u8 efuseType, - u16 *pAddr, struct pg_pkt_struct *pTargetPkt) -{ - u8 pg_header = 0, tmp_header = 0; - u16 efuse_addr = *pAddr; - u8 repeatcnt = 0; - - pg_header = ((pTargetPkt->offset << 4) & 0xf0) | pTargetPkt->word_en; - - do { - efuse_OneByteWrite23a(pAdapter, efuse_addr, pg_header); - efuse_OneByteRead23a(pAdapter, efuse_addr, &tmp_header); - if (tmp_header != 0xFF) - break; - if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) { - DBG_8723A("%s: Repeat over limit for pg_header!!\n", - __func__); - return false; - } - } while (1); - - if (tmp_header != pg_header) { - DBG_8723A(KERN_ERR "%s: PG Header Fail!!(pg = 0x%02X " - "read = 0x%02X)\n", __func__, - pg_header, tmp_header); - return false; - } - - *pAddr = efuse_addr; - - return true; -} - -static u8 -hal_EfusePgPacketWrite2ByteHeader(struct rtw_adapter *padapter, u8 efuseType, - u16 *pAddr, struct pg_pkt_struct *pTargetPkt) -{ - u16 efuse_addr, efuse_max_available_len = 0; - u8 pg_header = 0, tmp_header = 0; - u8 repeatcnt = 0; - - EFUSE_GetEfuseDefinition23a(padapter, efuseType, - TYPE_AVAILABLE_EFUSE_BYTES_BANK, - &efuse_max_available_len); - - efuse_addr = *pAddr; - if (efuse_addr >= efuse_max_available_len) { - DBG_8723A("%s: addr(%d) over avaliable(%d)!!\n", __func__, - efuse_addr, efuse_max_available_len); - return false; - } - - pg_header = ((pTargetPkt->offset & 0x07) << 5) | 0x0F; - - do { - efuse_OneByteWrite23a(padapter, efuse_addr, pg_header); - efuse_OneByteRead23a(padapter, efuse_addr, &tmp_header); - if (tmp_header != 0xFF) - break; - if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) { - DBG_8723A("%s: Repeat over limit for pg_header!!\n", - __func__); - return false; - } - } while (1); - - if (tmp_header != pg_header) { - DBG_8723A(KERN_ERR - "%s: PG Header Fail!!(pg = 0x%02X read = 0x%02X)\n", - __func__, pg_header, tmp_header); - return false; - } - - /* to write ext_header */ - efuse_addr++; - pg_header = ((pTargetPkt->offset & 0x78) << 1) | pTargetPkt->word_en; - - do { - efuse_OneByteWrite23a(padapter, efuse_addr, pg_header); - efuse_OneByteRead23a(padapter, efuse_addr, &tmp_header); - if (tmp_header != 0xFF) - break; - if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) { - DBG_8723A("%s: Repeat over limit for ext_header!!\n", - __func__); - return false; - } - } while (1); - - if (tmp_header != pg_header) { /* offset PG fail */ - DBG_8723A(KERN_ERR - "%s: PG EXT Header Fail!!(pg = 0x%02X read = 0x%02X)\n", - __func__, pg_header, tmp_header); - return false; - } - - *pAddr = efuse_addr; - - return true; -} - -static u8 -hal_EfusePgPacketWriteHeader(struct rtw_adapter *padapter, u8 efuseType, - u16 *pAddr, struct pg_pkt_struct *pTargetPkt) -{ - u8 bRet = false; - - if (pTargetPkt->offset >= EFUSE_MAX_SECTION_BASE) { - bRet = hal_EfusePgPacketWrite2ByteHeader(padapter, efuseType, - pAddr, pTargetPkt); - } else { - bRet = hal_EfusePgPacketWrite1ByteHeader(padapter, efuseType, - pAddr, pTargetPkt); - } - - return bRet; -} - -static u8 -hal_EfusePgPacketWriteData(struct rtw_adapter *pAdapter, u8 efuseType, - u16 *pAddr, struct pg_pkt_struct *pTargetPkt) -{ - u16 efuse_addr; - u8 badworden; - - efuse_addr = *pAddr; - badworden = - Efuse_WordEnableDataWrite23a(pAdapter, efuse_addr + 1, - pTargetPkt->word_en, pTargetPkt->data); - if (badworden != 0x0F) { - DBG_8723A("%s: Fail!!\n", __func__); - return false; - } - - return true; -} - -static s32 -Hal_EfusePgPacketWrite(struct rtw_adapter *padapter, - u8 offset, u8 word_en, u8 *pData) -{ - struct pg_pkt_struct targetPkt; - u16 startAddr = 0; - u8 efuseType = EFUSE_WIFI; - - if (!hal_EfusePgCheckAvailableAddr(padapter, efuseType)) - return false; - - hal_EfuseConstructPGPkt(offset, word_en, pData, &targetPkt); - - if (!hal_EfusePartialWriteCheck(padapter, efuseType, - &startAddr, &targetPkt)) - return false; - - if (!hal_EfusePgPacketWriteHeader(padapter, efuseType, - &startAddr, &targetPkt)) - return false; - - if (!hal_EfusePgPacketWriteData(padapter, efuseType, - &startAddr, &targetPkt)) - return false; - - return true; -} - -static bool -Hal_EfusePgPacketWrite_BT(struct rtw_adapter *pAdapter, - u8 offset, u8 word_en, u8 *pData) -{ - struct pg_pkt_struct targetPkt; - u16 startAddr = 0; - u8 efuseType = EFUSE_BT; - - if (!hal_EfusePgCheckAvailableAddr(pAdapter, efuseType)) - return false; - - hal_EfuseConstructPGPkt(offset, word_en, pData, &targetPkt); - - if (!hal_EfusePartialWriteCheck(pAdapter, efuseType, - &startAddr, &targetPkt)) - return false; - - if (!hal_EfusePgPacketWriteHeader(pAdapter, efuseType, - &startAddr, &targetPkt)) - return false; - - if (!hal_EfusePgPacketWriteData(pAdapter, efuseType, - &startAddr, &targetPkt)) - return false; - - return true; -} - void rtl8723a_read_chip_version(struct rtw_adapter *padapter) { u32 value32; @@ -1542,15 +1210,6 @@ exit: return ret; } -void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc) -{ - /* Efuse related function */ - pHalFunc->Efuse_PgPacketRead23a = &Hal_EfusePgPacketRead; - pHalFunc->Efuse_PgPacketWrite23a = &Hal_EfusePgPacketWrite; - pHalFunc->Efuse_WordEnableDataWrite23a = &Hal_EfuseWordEnableDataWrite; - pHalFunc->Efuse_PgPacketWrite23a_BT = &Hal_EfusePgPacketWrite_BT; -} - void rtl8723a_InitAntenna_Selection(struct rtw_adapter *padapter) { u8 val; diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 96ee3107cb58..a25b018bd905 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1751,6 +1751,5 @@ int rtl8723au_set_hal_ops(struct rtw_adapter *padapter) pHalFunc->hal_xmit = &rtl8723au_hal_xmit; pHalFunc->mgnt_xmit = &rtl8723au_mgnt_xmit; pHalFunc->hal_xmitframe_enqueue = &rtl8723au_hal_xmitframe_enqueue; - rtl8723a_set_hal_ops(pHalFunc); return 0; } diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index b8fd4033e2bb..dc4fca93c366 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -93,19 +93,6 @@ struct hal_ops { struct xmit_frame *pmgntframe); s32 (*hal_xmitframe_enqueue)(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe); - - void (*EFUSEGetEfuseDefinition)(struct rtw_adapter *padapter, - u8 efuseType, u8 type, void *pOut); - u16 (*EfuseGetCurrentSize)(struct rtw_adapter *padapter, u8 efuseType); - int (*Efuse_PgPacketRead23a)(struct rtw_adapter *padapter, - u8 offset, u8 *data); - int (*Efuse_PgPacketWrite23a)(struct rtw_adapter *padapter, - u8 offset, u8 word_en, u8 *data); - u8 (*Efuse_WordEnableDataWrite23a)(struct rtw_adapter *padapter, - u16 efuse_addr, u8 word_en, - u8 *data); - bool (*Efuse_PgPacketWrite23a_BT)(struct rtw_adapter *padapter, - u8 offset, u8 word_en, u8 *data); }; enum rt_eeprom_type { diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index b61f37f7a308..dd9558460d7b 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -531,7 +531,6 @@ void Hal_EfuseParseThermalMeter_8723A(struct rtw_adapter *padapter, u8 *hwinfo, void Hal_InitChannelPlan23a(struct rtw_adapter *padapter); -void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc); #ifdef CONFIG_8723AU_BT_COEXIST void rtl8723a_SingleDualAntennaDetection(struct rtw_adapter *padapter); #endif -- cgit v1.2.3 From c77726971ee29af46d2dabac2d4a821b84752a02 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:16 +0200 Subject: staging: rtl8723au: Pull hal_init/deinit out of HAL wrapper layer Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_intf.c | 36 -------------------- drivers/staging/rtl8723au/hal/usb_halinit.c | 49 ++++++++++++++++++++++++---- drivers/staging/rtl8723au/include/hal_intf.h | 6 ++-- 3 files changed, 44 insertions(+), 47 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index 2a5c9cc4f048..50d8ca3dfcd3 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -41,42 +41,6 @@ u32 rtw_hal_power_on23a(struct rtw_adapter *padapter) return _FAIL; } -uint rtw_hal_init23a(struct rtw_adapter *padapter) -{ - uint status = _SUCCESS; - - padapter->hw_init_completed = false; - - status = padapter->HalFunc.hal_init(padapter); - - if (status == _SUCCESS) { - padapter->hw_init_completed = true; - - if (padapter->registrypriv.notch_filter == 1) - rtl8723a_notch_filter(padapter, 1); - } else { - padapter->hw_init_completed = false; - DBG_8723A("rtw_hal_init23a: hal__init fail\n"); - } - - RT_TRACE(_module_hal_init_c_, _drv_err_, ("-rtl871x_hal_init:status = 0x%x\n", status)); - - return status; -} - -uint rtw_hal_deinit23a(struct rtw_adapter *padapter) -{ - uint status = _SUCCESS; - - status = padapter->HalFunc.hal_deinit(padapter); - - if (status == _SUCCESS) - padapter->hw_init_completed = false; - else - DBG_8723A("\n rtw_hal_deinit23a: hal_init fail\n"); - return status; -} - u8 rtw_hal_set_def_var23a(struct rtw_adapter *padapter, enum hal_def_variable eVariable, void *pValue) { if (padapter->HalFunc.SetHalDefVarHandler) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index a25b018bd905..e3e7153205f8 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -614,10 +614,11 @@ enum rt_rf_power_state RfOnOffDetect23a(struct rtw_adapter *pAdapter) void _ps_open_RF23a(struct rtw_adapter *padapter); -static u32 rtl8723au_hal_init(struct rtw_adapter *Adapter) +static int rtl8723au_hal_init(struct rtw_adapter *Adapter) { - u8 val8 = 0; - u32 boundary, status = _SUCCESS; + u8 val8 = 0; + u32 boundary; + int status = _SUCCESS; struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); struct pwrctrl_priv *pwrctrlpriv = &Adapter->pwrctrlpriv; struct registry_priv *pregistrypriv = &Adapter->registrypriv; @@ -1206,7 +1207,7 @@ static void CardDisableRTL8723U(struct rtw_adapter *Adapter) rtw_write8(Adapter, REG_RSV_CTRL, 0x0e); } -static u32 rtl8723au_hal_deinit(struct rtw_adapter *padapter) +static int rtl8723au_hal_deinit(struct rtw_adapter *padapter) { DBG_8723A("==> %s\n", __func__); @@ -1725,6 +1726,43 @@ static void UpdateHalRAMask8192CUsb(struct rtw_adapter *padapter, pdmpriv->INIDATA_RATE[mac_id] = init_rate; } +int rtw_hal_init23a(struct rtw_adapter *padapter) +{ + int status; + + padapter->hw_init_completed = false; + + status = rtl8723au_hal_init(padapter); + + if (status == _SUCCESS) { + padapter->hw_init_completed = true; + + if (padapter->registrypriv.notch_filter == 1) + rtl8723a_notch_filter(padapter, 1); + } else { + padapter->hw_init_completed = false; + DBG_8723A("rtw_hal_init23a: hal__init fail\n"); + } + + RT_TRACE(_module_hal_init_c_, _drv_err_, + ("-rtl871x_hal_init:status = 0x%x\n", status)); + + return status; +} + +int rtw_hal_deinit23a(struct rtw_adapter *padapter) +{ + int status; + + status = rtl8723au_hal_deinit(padapter); + + if (status == _SUCCESS) + padapter->hw_init_completed = false; + else + DBG_8723A("\n rtw_hal_deinit23a: hal_init fail\n"); + return status; +} + int rtl8723au_set_hal_ops(struct rtw_adapter *padapter) { struct hal_ops *pHalFunc = &padapter->HalFunc; @@ -1735,9 +1773,6 @@ int rtl8723au_set_hal_ops(struct rtw_adapter *padapter) return -ENOMEM; } - pHalFunc->hal_init = &rtl8723au_hal_init; - pHalFunc->hal_deinit = &rtl8723au_hal_deinit; - pHalFunc->init_xmit_priv = &rtl8723au_init_xmit_priv; pHalFunc->init_recv_priv = &rtl8723au_init_recv_priv; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index dc4fca93c366..fb5b8a72b1b7 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -62,8 +62,6 @@ enum hal_odm_variable { struct hal_ops { u32 (*hal_power_on)(struct rtw_adapter *padapter); - u32 (*hal_init)(struct rtw_adapter *padapter); - u32 (*hal_deinit)(struct rtw_adapter *padapter); s32 (*init_xmit_priv)(struct rtw_adapter *padapter); @@ -142,8 +140,8 @@ void rtw_hal_sw_led_init23a(struct rtw_adapter *padapter); void rtw_hal_sw_led_deinit23a(struct rtw_adapter *padapter); u32 rtw_hal_power_on23a(struct rtw_adapter *padapter); -uint rtw_hal_init23a(struct rtw_adapter *padapter); -uint rtw_hal_deinit23a(struct rtw_adapter *padapter); +int rtw_hal_init23a(struct rtw_adapter *padapter); +int rtw_hal_deinit23a(struct rtw_adapter *padapter); void rtw_hal_stop(struct rtw_adapter *padapter); u8 rtw_hal_set_def_var23a(struct rtw_adapter *padapter, -- cgit v1.2.3 From b3d139a6468047b87667c65d7ebc7c0c6b55ada6 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:17 +0200 Subject: staging: rtl8723au: Disentangle recv/xmit_priv init/free from HAL wrappers Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_recv.c | 5 +++-- drivers/staging/rtl8723au/core/rtw_xmit.c | 4 +++- drivers/staging/rtl8723au/hal/hal_intf.c | 20 -------------------- drivers/staging/rtl8723au/hal/rtl8723au_xmit.c | 10 ---------- drivers/staging/rtl8723au/hal/usb_halinit.c | 4 ---- drivers/staging/rtl8723au/include/hal_intf.h | 10 ---------- drivers/staging/rtl8723au/include/rtl8723a_xmit.h | 1 - 7 files changed, 6 insertions(+), 48 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 014bb54c1a13..6d98531a9c31 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -22,6 +22,7 @@ #include #include #include +#include void rtw_signal_stat_timer_hdl23a(unsigned long data); @@ -72,7 +73,7 @@ int _rtw_init_recv_priv23a(struct recv_priv *precvpriv, precvpriv->free_recvframe_cnt = i; precvpriv->rx_pending_cnt = 1; - res = rtw_hal_init23a_recv_priv(padapter); + res = rtl8723au_init_recv_priv(padapter); setup_timer(&precvpriv->signal_stat_timer, rtw_signal_stat_timer_hdl23a, (unsigned long)padapter); @@ -98,7 +99,7 @@ void _rtw_free_recv_priv23a (struct recv_priv *precvpriv) kfree(precvframe); } - rtw_hal_free_recv_priv23a(padapter); + rtl8723au_free_recv_priv(padapter); } struct recv_frame *rtw_alloc_recvframe23a(struct rtw_queue *pfree_recv_queue) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 99589c467d8e..c6a6567ba6f2 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -194,7 +194,9 @@ int _rtw_init_xmit_priv23a(struct xmit_priv *pxmitpriv, pxmitpriv->ack_tx = false; mutex_init(&pxmitpriv->ack_tx_mutex); rtw_sctx_init23a(&pxmitpriv->ack_tx_ops, 0); - rtw_hal_init23a_xmit_priv(padapter); + tasklet_init(&padapter->xmitpriv.xmit_tasklet, + (void(*)(unsigned long))rtl8723au_xmit_tasklet, + (unsigned long)padapter); exit: diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index 50d8ca3dfcd3..7346f300574c 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -95,26 +95,6 @@ s32 rtw_hal_mgnt_xmit23a(struct rtw_adapter *padapter, struct xmit_frame *pmgntf return ret; } -s32 rtw_hal_init23a_xmit_priv(struct rtw_adapter *padapter) -{ - if (padapter->HalFunc.init_xmit_priv != NULL) - return padapter->HalFunc.init_xmit_priv(padapter); - return _FAIL; -} - -s32 rtw_hal_init23a_recv_priv(struct rtw_adapter *padapter) -{ - if (padapter->HalFunc.init_recv_priv) - return padapter->HalFunc.init_recv_priv(padapter); - - return _FAIL; -} -void rtw_hal_free_recv_priv23a(struct rtw_adapter *padapter) -{ - if (padapter->HalFunc.free_recv_priv) - padapter->HalFunc.free_recv_priv(padapter); -} - void rtw_hal_update_ra_mask23a(struct sta_info *psta, u8 rssi_level) { struct rtw_adapter *padapter; diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c b/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c index ed8aeb447be7..da6bda049567 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c +++ b/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c @@ -21,16 +21,6 @@ /* include */ #include -s32 rtl8723au_init_xmit_priv(struct rtw_adapter *padapter) -{ - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - - tasklet_init(&pxmitpriv->xmit_tasklet, - (void(*)(unsigned long))rtl8723au_xmit_tasklet, - (unsigned long)padapter); - return _SUCCESS; -} - static void do_queue_select(struct rtw_adapter *padapter, struct pkt_attrib *pattrib) { u8 qsel; diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index e3e7153205f8..3ed766bea5cd 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1773,10 +1773,6 @@ int rtl8723au_set_hal_ops(struct rtw_adapter *padapter) return -ENOMEM; } - pHalFunc->init_xmit_priv = &rtl8723au_init_xmit_priv; - - pHalFunc->init_recv_priv = &rtl8723au_init_recv_priv; - pHalFunc->free_recv_priv = &rtl8723au_free_recv_priv; pHalFunc->InitSwLeds = NULL; pHalFunc->DeInitSwLeds = NULL; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index fb5b8a72b1b7..114063adc17e 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -63,11 +63,6 @@ enum hal_odm_variable { struct hal_ops { u32 (*hal_power_on)(struct rtw_adapter *padapter); - s32 (*init_xmit_priv)(struct rtw_adapter *padapter); - - s32 (*init_recv_priv)(struct rtw_adapter *padapter); - void (*free_recv_priv)(struct rtw_adapter *padapter); - void (*InitSwLeds)(struct rtw_adapter *padapter); void (*DeInitSwLeds)(struct rtw_adapter *padapter); @@ -161,11 +156,6 @@ s32 rtw_hal_xmit23a(struct rtw_adapter *padapter, s32 rtw_hal_mgnt_xmit23a(struct rtw_adapter *padapter, struct xmit_frame *pmgntframe); -s32 rtw_hal_init23a_xmit_priv(struct rtw_adapter *padapter); - -s32 rtw_hal_init23a_recv_priv(struct rtw_adapter *padapter); -void rtw_hal_free_recv_priv23a(struct rtw_adapter *padapter); - void rtw_hal_update_ra_mask23a(struct sta_info *psta, u8 rssi_level); void rtw_hal_clone_data(struct rtw_adapter *dst_padapter, struct rtw_adapter *src_padapter); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_xmit.h b/drivers/staging/rtl8723au/include/rtl8723a_xmit.h index 80e379c6b6fe..9b8438736b48 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_xmit.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_xmit.h @@ -219,7 +219,6 @@ void rtl8723a_fill_fake_txdesc(struct rtw_adapter *padapter, u8 *pDesc, u32 Buff s32 rtl8723au_hal_xmitframe_enqueue(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe); s32 rtl8723au_xmit_buf_handler(struct rtw_adapter *padapter); #define hal_xmit_handler rtl8723au_xmit_buf_handler -s32 rtl8723au_init_xmit_priv(struct rtw_adapter * padapter); s32 rtl8723au_hal_xmit(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe); s32 rtl8723au_mgnt_xmit(struct rtw_adapter *padapter, struct xmit_frame *pmgntframe); s32 rtl8723au_xmitframe_complete(struct rtw_adapter *padapter, struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf); -- cgit v1.2.3 From 638443dcf4fdacad614d9bc198dcfe921a5ca08c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:18 +0200 Subject: staging: rtl8723au: Call xmit/recv handlers directly instead of via HAL wrappers Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 10 +++++----- drivers/staging/rtl8723au/core/rtw_recv.c | 4 +++- drivers/staging/rtl8723au/core/rtw_xmit.c | 9 +++++---- drivers/staging/rtl8723au/hal/hal_intf.c | 24 ----------------------- drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 4 ++-- drivers/staging/rtl8723au/hal/rtl8723au_xmit.c | 15 +++----------- drivers/staging/rtl8723au/hal/usb_halinit.c | 3 --- drivers/staging/rtl8723au/include/hal_intf.h | 14 ------------- drivers/staging/rtl8723au/include/rtl8723a_xmit.h | 4 ++-- 9 files changed, 20 insertions(+), 67 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 1172fe9362a8..3a9e1354b214 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -2329,7 +2329,7 @@ void dump_mgntframe23a(struct rtw_adapter *padapter, padapter->bDriverStopped == true) return; - rtw_hal_mgnt_xmit23a(padapter, pmgntframe); + rtl8723au_mgnt_xmit(padapter, pmgntframe); } s32 dump_mgntframe23a_and_wait(struct rtw_adapter *padapter, @@ -2348,7 +2348,7 @@ s32 dump_mgntframe23a_and_wait(struct rtw_adapter *padapter, rtw_sctx_init23a(&sctx, timeout_ms); pxmitbuf->sctx = &sctx; - ret = rtw_hal_mgnt_xmit23a(padapter, pmgntframe); + ret = rtl8723au_mgnt_xmit(padapter, pmgntframe); if (ret == _SUCCESS) ret = rtw_sctx_wait23a(&sctx); @@ -2375,9 +2375,8 @@ s32 dump_mgntframe23a_and_wait_ack23a(struct rtw_adapter *padapter, pxmitpriv->ack_tx = true; pmgntframe->ack_report = 1; - if (rtw_hal_mgnt_xmit23a(padapter, pmgntframe) == _SUCCESS) { + if (rtl8723au_mgnt_xmit(padapter, pmgntframe) == _SUCCESS) ret = rtw_ack_tx_wait23a(pxmitpriv, timeout_ms); - } pxmitpriv->ack_tx = false; mutex_unlock(&pxmitpriv->ack_tx_mutex); @@ -6492,7 +6491,8 @@ u8 tx_beacon_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) pxmitframe->attrib.qsel = 0x11;/* HIQ */ - rtw_hal_xmit23aframe_enqueue(padapter, pxmitframe); + rtl8723au_hal_xmitframe_enqueue(padapter, + pxmitframe); } /* spin_unlock_bh(&psta_bmc->sleep_q.lock); */ diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 6d98531a9c31..79a76d692df3 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -23,6 +23,7 @@ #include #include #include +#include void rtw_signal_stat_timer_hdl23a(unsigned long data); @@ -1178,7 +1179,8 @@ static int validate_recv_ctrl_frame(struct rtw_adapter *padapter, /* DBG_8723A("handling ps-poll, q_len =%d, tim =%x\n", psta->sleepq_len, pstapriv->tim_bitmap); */ - rtw_hal_xmit23aframe_enqueue(padapter, pxmitframe); + rtl8723au_hal_xmitframe_enqueue(padapter, + pxmitframe); if (psta->sleepq_len == 0) { pstapriv->tim_bitmap &= ~CHKBIT(psta->aid); diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index c6a6567ba6f2..05803c6c71fb 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -20,6 +20,7 @@ #include #include #include +#include static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; @@ -1940,7 +1941,7 @@ int rtw_xmit23a(struct rtw_adapter *padapter, struct sk_buff *skb) spin_unlock_bh(&pxmitpriv->lock); #endif - if (rtw_hal_xmit23a(padapter, pxmitframe) == false) + if (rtl8723au_hal_xmit(padapter, pxmitframe) == false) return 1; return 0; @@ -2212,7 +2213,7 @@ void wakeup_sta_to_xmit23a(struct rtw_adapter *padapter, struct sta_info *psta) } pxmitframe->attrib.triggered = 1; - rtw_hal_xmit23aframe_enqueue(padapter, pxmitframe); + rtl8723au_hal_xmitframe_enqueue(padapter, pxmitframe); } if (psta->sleepq_len == 0) { @@ -2259,7 +2260,7 @@ void wakeup_sta_to_xmit23a(struct rtw_adapter *padapter, struct sta_info *psta) pxmitframe->attrib.mdata = 0; pxmitframe->attrib.triggered = 1; - rtw_hal_xmit23aframe_enqueue(padapter, pxmitframe); + rtl8723au_hal_xmitframe_enqueue(padapter, pxmitframe); } if (psta_bmc->sleepq_len == 0) { pstapriv->tim_bitmap &= ~BIT(0); @@ -2333,7 +2334,7 @@ void xmit_delivery_enabled_frames23a(struct rtw_adapter *padapter, pxmitframe->attrib.triggered = 1; - rtw_hal_xmit23aframe_enqueue(padapter, pxmitframe); + rtl8723au_hal_xmitframe_enqueue(padapter, pxmitframe); if ((psta->sleepq_ac_len == 0) && (!psta->has_legacy_ac) && (wmmps_ac)) { diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index 7346f300574c..86d934afeb5a 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -71,30 +71,6 @@ void rtw_hal_disable_interrupt23a(struct rtw_adapter *padapter) } -s32 rtw_hal_xmit23aframe_enqueue(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe) -{ - if (padapter->HalFunc.hal_xmitframe_enqueue) - return padapter->HalFunc.hal_xmitframe_enqueue(padapter, pxmitframe); - - return false; -} - -s32 rtw_hal_xmit23a(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe) -{ - if (padapter->HalFunc.hal_xmit) - return padapter->HalFunc.hal_xmit(padapter, pxmitframe); - - return false; -} - -s32 rtw_hal_mgnt_xmit23a(struct rtw_adapter *padapter, struct xmit_frame *pmgntframe) -{ - s32 ret = _FAIL; - if (padapter->HalFunc.mgnt_xmit) - ret = padapter->HalFunc.mgnt_xmit(padapter, pmgntframe); - return ret; -} - void rtw_hal_update_ra_mask23a(struct sta_info *psta, u8 rssi_level) { struct rtw_adapter *padapter; diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c index ffd6b73eb6a8..e94557fc12cb 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c @@ -578,7 +578,7 @@ static void SetFwRsvdPagePkt(struct rtw_adapter *padapter, bool bDLFinished) pattrib->pktlen = pattrib->last_txcmdsz = TotalPacketLen - TXDESC_OFFSET; memcpy(pmgntframe->buf_addr, ReservedPagePacket, TotalPacketLen); - rtw_hal_mgnt_xmit23a(padapter, pmgntframe); + rtl8723au_mgnt_xmit(padapter, pmgntframe); DBG_8723A("%s: Set RSVD page location to Fw\n", __FUNCTION__); FillH2CCmd(padapter, RSVD_PAGE_EID, sizeof(RsvdPageLoc), (u8 *)&RsvdPageLoc); @@ -737,7 +737,7 @@ static void SetFwRsvdPagePkt_BTCoex(struct rtw_adapter *padapter) pattrib->pktlen = pattrib->last_txcmdsz = TotalPacketLen - TXDESC_OFFSET; memcpy(pmgntframe->buf_addr, ReservedPagePacket, TotalPacketLen); - rtw_hal_mgnt_xmit23a(padapter, pmgntframe); + rtl8723au_mgnt_xmit(padapter, pmgntframe); DBG_8723A("%s: Set RSVD page location to Fw\n", __FUNCTION__); FillH2CCmd(padapter, RSVD_PAGE_EID, sizeof(RsvdPageLoc), (u8 *)&RsvdPageLoc); diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c b/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c index da6bda049567..3926ad1c353d 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c +++ b/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c @@ -428,9 +428,10 @@ static s32 xmitframe_direct(struct rtw_adapter *padapter, struct xmit_frame *pxm * true dump packet directly * false enqueue packet */ -static s32 pre_xmitframe(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe) +bool rtl8723au_hal_xmit(struct rtw_adapter *padapter, + struct xmit_frame *pxmitframe) { - s32 res; + int res; struct xmit_buf *pxmitbuf = NULL; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct pkt_attrib *pattrib = &pxmitframe->attrib; @@ -504,16 +505,6 @@ s32 rtl8723au_mgnt_xmit(struct rtw_adapter *padapter, struct xmit_frame *pmgntfr return rtw_dump_xframe(padapter, pmgntframe); } -/* - * Return - * true dump packet directly ok - * false temporary can't transmit packets to hardware - */ -s32 rtl8723au_hal_xmit(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe) -{ - return pre_xmitframe(padapter, pxmitframe); -} - s32 rtl8723au_hal_xmitframe_enqueue(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe) { diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 3ed766bea5cd..60eed82445d7 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1779,8 +1779,5 @@ int rtl8723au_set_hal_ops(struct rtw_adapter *padapter) pHalFunc->GetHalDefVarHandler = &GetHalDefVar8192CUsb; pHalFunc->SetHalDefVarHandler = &SetHalDefVar8192CUsb; pHalFunc->UpdateRAMaskHandler = &UpdateHalRAMask8192CUsb; - pHalFunc->hal_xmit = &rtl8723au_hal_xmit; - pHalFunc->mgnt_xmit = &rtl8723au_mgnt_xmit; - pHalFunc->hal_xmitframe_enqueue = &rtl8723au_hal_xmitframe_enqueue; return 0; } diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 114063adc17e..8e44b88a3fc4 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -79,13 +79,6 @@ struct hal_ops { void (*UpdateRAMaskHandler)(struct rtw_adapter *padapter, u32 mac_id, u8 rssi_level); - - s32 (*hal_xmit)(struct rtw_adapter *padapter, - struct xmit_frame *pxmitframe); - s32 (*mgnt_xmit)(struct rtw_adapter *padapter, - struct xmit_frame *pmgntframe); - s32 (*hal_xmitframe_enqueue)(struct rtw_adapter *padapter, - struct xmit_frame *pxmitframe); }; enum rt_eeprom_type { @@ -149,13 +142,6 @@ u8 rtw_hal_get_def_var23a(struct rtw_adapter *padapter, void rtw_hal_enable_interrupt23a(struct rtw_adapter *padapter); void rtw_hal_disable_interrupt23a(struct rtw_adapter *padapter); -s32 rtw_hal_xmit23aframe_enqueue(struct rtw_adapter *padapter, - struct xmit_frame *pxmitframe); -s32 rtw_hal_xmit23a(struct rtw_adapter *padapter, - struct xmit_frame *pxmitframe); -s32 rtw_hal_mgnt_xmit23a(struct rtw_adapter *padapter, - struct xmit_frame *pmgntframe); - void rtw_hal_update_ra_mask23a(struct sta_info *psta, u8 rssi_level); void rtw_hal_clone_data(struct rtw_adapter *dst_padapter, struct rtw_adapter *src_padapter); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_xmit.h b/drivers/staging/rtl8723au/include/rtl8723a_xmit.h index 9b8438736b48..ab9ca349b6f4 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_xmit.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_xmit.h @@ -216,10 +216,10 @@ void handle_txrpt_ccx_8723a(struct rtw_adapter *adapter, void *buf); void rtl8723a_update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem); void rtl8723a_fill_fake_txdesc(struct rtw_adapter *padapter, u8 *pDesc, u32 BufferLen, u8 IsPsPoll, u8 IsBTQosNull); -s32 rtl8723au_hal_xmitframe_enqueue(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe); +int rtl8723au_hal_xmitframe_enqueue(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe); s32 rtl8723au_xmit_buf_handler(struct rtw_adapter *padapter); #define hal_xmit_handler rtl8723au_xmit_buf_handler -s32 rtl8723au_hal_xmit(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe); +bool rtl8723au_hal_xmit(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe); s32 rtl8723au_mgnt_xmit(struct rtw_adapter *padapter, struct xmit_frame *pmgntframe); s32 rtl8723au_xmitframe_complete(struct rtw_adapter *padapter, struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf); -- cgit v1.2.3 From ac4cbc68dc0243c4e9be9da403e80c8b5cfaf740 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:19 +0200 Subject: staging: rtl8723au: Pull update_ramask call out of HAL wrapper layer Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_intf.c | 6 ++---- drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 4 ++-- drivers/staging/rtl8723au/hal/usb_halinit.c | 5 ++--- drivers/staging/rtl8723au/include/hal_intf.h | 3 --- drivers/staging/rtl8723au/include/rtl8723a_hal.h | 2 ++ 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index 86d934afeb5a..75ddf5d5f809 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -87,10 +87,8 @@ void rtw_hal_update_ra_mask23a(struct sta_info *psta, u8 rssi_level) #ifdef CONFIG_8723AU_AP_MODE add_RATid23a(padapter, psta, rssi_level); #endif - } else { - if (padapter->HalFunc.UpdateRAMaskHandler) - padapter->HalFunc.UpdateRAMaskHandler(padapter, psta->mac_id, rssi_level); - } + } else + rtl8723a_update_ramask(padapter, psta->mac_id, rssi_level); } s32 rtw_hal_interrupt_handler23a(struct rtw_adapter *padapter) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index 8e1eb81284a9..37b6b79fe220 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -4662,8 +4662,8 @@ bthci_StateConnected(struct rtw_adapter *padapter, /* for rate adaptive */ - if (padapter->HalFunc.UpdateRAMaskHandler) - padapter->HalFunc.UpdateRAMaskHandler(padapter, MAX_FW_SUPPORT_MACID_NUM-1-EntryNum, 0); + rtl8723a_update_ramask(padapter, + MAX_FW_SUPPORT_MACID_NUM-1-EntryNum, 0); HalSetBrateCfg23a(padapter, padapter->mlmepriv.cur_network.network.SupportedRates); BTDM_SetFwChnlInfo(padapter, RT_MEDIA_CONNECT); diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 60eed82445d7..db94b0c3d973 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1612,8 +1612,8 @@ static u8 SetHalDefVar8192CUsb(struct rtw_adapter *Adapter, return bResult; } -static void UpdateHalRAMask8192CUsb(struct rtw_adapter *padapter, - u32 mac_id, u8 rssi_level) +void rtl8723a_update_ramask(struct rtw_adapter *padapter, + u32 mac_id, u8 rssi_level) { u8 init_rate = 0; u8 networkType, raid; @@ -1778,6 +1778,5 @@ int rtl8723au_set_hal_ops(struct rtw_adapter *padapter) pHalFunc->GetHalDefVarHandler = &GetHalDefVar8192CUsb; pHalFunc->SetHalDefVarHandler = &SetHalDefVar8192CUsb; - pHalFunc->UpdateRAMaskHandler = &UpdateHalRAMask8192CUsb; return 0; } diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 8e44b88a3fc4..56629f5dd57e 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -76,9 +76,6 @@ struct hal_ops { u8 (*SetHalDefVarHandler)(struct rtw_adapter *padapter, enum hal_def_variable eVariable, void *pValue); - - void (*UpdateRAMaskHandler)(struct rtw_adapter *padapter, - u32 mac_id, u8 rssi_level); }; enum rt_eeprom_type { diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index dd9558460d7b..efa78778ba23 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -557,5 +557,7 @@ rtl8723a_readefuse(struct rtw_adapter *padapter, u8 efuseType, u16 _offset, u16 _size_byte, u8 *pbuf); u16 rtl8723a_EfuseGetCurrentSize_WiFi(struct rtw_adapter *padapter); u16 rtl8723a_EfuseGetCurrentSize_BT(struct rtw_adapter *padapter); +void rtl8723a_update_ramask(struct rtw_adapter *padapter, + u32 mac_id, u8 rssi_level); #endif -- cgit v1.2.3 From 39f1a8ebbacfee86c53f7b6b1dda8e9c14e9772b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:20 +0200 Subject: staging: rtl8723au: Make direct calls to GetHalDefVar8192CUsb() Remove another round of HAL wrapping, and remove unused SetHalDefVar8192CUsb(). Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 12 ++-- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 4 +- drivers/staging/rtl8723au/core/rtw_recv.c | 2 +- drivers/staging/rtl8723au/hal/hal_intf.c | 13 ----- drivers/staging/rtl8723au/hal/usb_halinit.c | 81 ++------------------------- drivers/staging/rtl8723au/include/hal_intf.h | 17 +----- 6 files changed, 16 insertions(+), 113 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index b675673dd995..a7371a874573 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -2270,13 +2270,13 @@ unsigned int rtw_restructure_ht_ie23a(struct rtw_adapter *padapter, u8 *in_ie, IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_TX_STBC | IEEE80211_HT_CAP_DSSSCCK40; - rtw_hal_get_def_var23a(padapter, HAL_DEF_RX_PACKET_OFFSET, - &rx_packet_offset); - rtw_hal_get_def_var23a(padapter, HAL_DEF_MAX_RECVBUF_SZ, - &max_recvbuf_sz); + GetHalDefVar8192CUsb(padapter, HAL_DEF_RX_PACKET_OFFSET, + &rx_packet_offset); + GetHalDefVar8192CUsb(padapter, HAL_DEF_MAX_RECVBUF_SZ, + &max_recvbuf_sz); - rtw_hal_get_def_var23a(padapter, HW_VAR_MAX_RX_AMPDU_FACTOR, - &max_rx_ampdu_factor); + GetHalDefVar8192CUsb(padapter, HW_VAR_MAX_RX_AMPDU_FACTOR, + &max_rx_ampdu_factor); ht_capie.ampdu_params_info = max_rx_ampdu_factor & 0x03; if (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 3a9e1354b214..a769d92e4f00 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -4084,8 +4084,8 @@ void issue_action_BA23a(struct rtw_adapter *padapter, pframe = rtw_set_fixed_ie23a(pframe, 2, (unsigned char *)&status, &pattrib->pktlen); - rtw_hal_get_def_var23a(padapter, HW_VAR_MAX_RX_AMPDU_FACTOR, - &max_rx_ampdu_factor); + GetHalDefVar8192CUsb(padapter, HW_VAR_MAX_RX_AMPDU_FACTOR, + &max_rx_ampdu_factor); if (max_rx_ampdu_factor == IEEE80211_HT_MAX_AMPDU_64K) BA_para_set = ((le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x1000); /* 64 buffer size */ else if (max_rx_ampdu_factor == IEEE80211_HT_MAX_AMPDU_32K) diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 79a76d692df3..19b58cae8c42 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -1506,7 +1506,7 @@ static int validate_recv_frame(struct rtw_adapter *adapter, pattrib->privacy = ieee80211_has_protected(hdr->frame_control); pattrib->order = ieee80211_has_order(hdr->frame_control); - rtw_hal_get_def_var23a(adapter, HAL_DEF_DBG_DUMP_RXPKT, &bDumpRxPkt); + GetHalDefVar8192CUsb(adapter, HAL_DEF_DBG_DUMP_RXPKT, &bDumpRxPkt); if (unlikely(bDumpRxPkt == 1)) dump_rx_pkt(skb, type, bDumpRxPkt); diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index 75ddf5d5f809..1904582d3ec0 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -41,19 +41,6 @@ u32 rtw_hal_power_on23a(struct rtw_adapter *padapter) return _FAIL; } -u8 rtw_hal_set_def_var23a(struct rtw_adapter *padapter, enum hal_def_variable eVariable, void *pValue) -{ - if (padapter->HalFunc.SetHalDefVarHandler) - return padapter->HalFunc.SetHalDefVarHandler(padapter, eVariable, pValue); - return _FAIL; -} -u8 rtw_hal_get_def_var23a(struct rtw_adapter *padapter, enum hal_def_variable eVariable, void *pValue) -{ - if (padapter->HalFunc.GetHalDefVarHandler) - return padapter->HalFunc.GetHalDefVarHandler(padapter, eVariable, pValue); - return _FAIL; -} - void rtw_hal_enable_interrupt23a(struct rtw_adapter *padapter) { if (padapter->HalFunc.enable_interrupt) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index db94b0c3d973..be98560f1e4f 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1492,11 +1492,11 @@ void rtl8723a_read_adapter_info(struct rtw_adapter *Adapter) /* Description: */ /* Query setting of specified variable. */ /* */ -static u8 GetHalDefVar8192CUsb(struct rtw_adapter *Adapter, - enum hal_def_variable eVariable, void *pValue) +int GetHalDefVar8192CUsb(struct rtw_adapter *Adapter, + enum hal_def_variable eVariable, void *pValue) { - struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); - u8 bResult = _SUCCESS; + struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); + int bResult = _SUCCESS; switch (eVariable) { case HAL_DEF_UNDERCORATEDSMOOTHEDPWDB: @@ -1541,77 +1541,6 @@ static u8 GetHalDefVar8192CUsb(struct rtw_adapter *Adapter, return bResult; } -/* Change default setting of specified variable. */ -static u8 SetHalDefVar8192CUsb(struct rtw_adapter *Adapter, - enum hal_def_variable eVariable, void *pValue) -{ - struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); - u8 bResult = _SUCCESS; - - switch (eVariable) { - case HAL_DEF_DBG_DUMP_RXPKT: - pHalData->bDumpRxPkt = *((u8 *)pValue); - break; - case HAL_DEF_DBG_DM_FUNC: - { - u8 dm_func = *((u8 *)pValue); - struct dm_priv *pdmpriv = &pHalData->dmpriv; - struct dm_odm_t *podmpriv = &pHalData->odmpriv; - - if (dm_func == 0) { /* disable all dynamic func */ - podmpriv->SupportAbility = DYNAMIC_FUNC_DISABLE; - DBG_8723A("==> Disable all dynamic function...\n"); - } else if (dm_func == 1) {/* disable DIG */ - podmpriv->SupportAbility &= (~DYNAMIC_BB_DIG); - DBG_8723A("==> Disable DIG...\n"); - } else if (dm_func == 2) {/* disable High power */ - podmpriv->SupportAbility &= (~DYNAMIC_BB_DYNAMIC_TXPWR); - } else if (dm_func == 3) {/* disable tx power tracking */ - podmpriv->SupportAbility &= (~DYNAMIC_RF_CALIBRATION); - DBG_8723A("==> Disable tx power tracking...\n"); - } else if (dm_func == 4) {/* disable BT coexistence */ - pdmpriv->DMFlag &= (~DYNAMIC_FUNC_BT); - } else if (dm_func == 5) {/* disable antenna diversity */ - podmpriv->SupportAbility &= (~DYNAMIC_BB_ANT_DIV); - } else if (dm_func == 6) {/* turn on all dynamic func */ - if (!(podmpriv->SupportAbility & DYNAMIC_BB_DIG)) { - struct dig_t *pDigTable = - &podmpriv->DM_DigTable; - pDigTable->CurIGValue = rtw_read8(Adapter, 0xc50); - } - pdmpriv->DMFlag |= DYNAMIC_FUNC_BT; - podmpriv->SupportAbility = DYNAMIC_ALL_FUNC_ENABLE; - DBG_8723A("==> Turn on all dynamic function...\n"); - } - } - break; - case HW_DEF_FA_CNT_DUMP: - { - u8 bRSSIDump = *((u8 *)pValue); - struct dm_odm_t *pDM_Odm = &pHalData->odmpriv; - if (bRSSIDump) - pDM_Odm->DebugComponents = ODM_COMP_DIG|ODM_COMP_FA_CNT; - else - pDM_Odm->DebugComponents = 0; - } - break; - case HW_DEF_ODM_DBG_FLAG: - { - u64 DebugComponents = *((u64 *)pValue); - struct dm_odm_t *pDM_Odm = &pHalData->odmpriv; - pDM_Odm->DebugComponents = DebugComponents; - } - break; - default: - /* RT_TRACE(COMP_INIT, DBG_TRACE, ("SetHalDefVar819xUsb(): " - "Unkown variable: %d!\n", eVariable)); */ - bResult = _FAIL; - break; - } - - return bResult; -} - void rtl8723a_update_ramask(struct rtw_adapter *padapter, u32 mac_id, u8 rssi_level) { @@ -1776,7 +1705,5 @@ int rtl8723au_set_hal_ops(struct rtw_adapter *padapter) pHalFunc->InitSwLeds = NULL; pHalFunc->DeInitSwLeds = NULL; - pHalFunc->GetHalDefVarHandler = &GetHalDefVar8192CUsb; - pHalFunc->SetHalDefVarHandler = &SetHalDefVar8192CUsb; return 0; } diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 56629f5dd57e..f69e9339fac3 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -69,13 +69,6 @@ struct hal_ops { void (*enable_interrupt)(struct rtw_adapter *padapter); void (*disable_interrupt)(struct rtw_adapter *padapter); s32 (*interrupt_handler)(struct rtw_adapter *padapter); - - u8 (*GetHalDefVarHandler)(struct rtw_adapter *padapter, - enum hal_def_variable eVariable, - void *pValue); - u8 (*SetHalDefVarHandler)(struct rtw_adapter *padapter, - enum hal_def_variable eVariable, - void *pValue); }; enum rt_eeprom_type { @@ -129,13 +122,6 @@ int rtw_hal_init23a(struct rtw_adapter *padapter); int rtw_hal_deinit23a(struct rtw_adapter *padapter); void rtw_hal_stop(struct rtw_adapter *padapter); -u8 rtw_hal_set_def_var23a(struct rtw_adapter *padapter, - enum hal_def_variable eVariable, - void *pValue); -u8 rtw_hal_get_def_var23a(struct rtw_adapter *padapter, - enum hal_def_variable eVariable, - void *pValue); - void rtw_hal_enable_interrupt23a(struct rtw_adapter *padapter); void rtw_hal_disable_interrupt23a(struct rtw_adapter *padapter); @@ -151,4 +137,7 @@ void hw_var_set_macaddr(struct rtw_adapter *padapter, u8 *val); void hw_var_set_bssid(struct rtw_adapter *padapter, u8 *val); void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type); +int GetHalDefVar8192CUsb(struct rtw_adapter *Adapter, + enum hal_def_variable eVariable, void *pValue); + #endif /* __HAL_INTF_H__ */ -- cgit v1.2.3 From d9edcafbdc3e8b073f775aa206da8ce7cf045e43 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:21 +0200 Subject: staging: rtl8723au: Remove unused hal_power_on() wrapper Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_intf.c | 7 ------- drivers/staging/rtl8723au/include/hal_intf.h | 3 --- 2 files changed, 10 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index 1904582d3ec0..dba428ac21ed 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -34,13 +34,6 @@ void rtw_hal_sw_led_deinit23a(struct rtw_adapter *padapter) padapter->HalFunc.DeInitSwLeds(padapter); } -u32 rtw_hal_power_on23a(struct rtw_adapter *padapter) -{ - if (padapter->HalFunc.hal_power_on) - return padapter->HalFunc.hal_power_on(padapter); - return _FAIL; -} - void rtw_hal_enable_interrupt23a(struct rtw_adapter *padapter) { if (padapter->HalFunc.enable_interrupt) diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index f69e9339fac3..6e32215a0b04 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -61,8 +61,6 @@ enum hal_odm_variable { }; struct hal_ops { - u32 (*hal_power_on)(struct rtw_adapter *padapter); - void (*InitSwLeds)(struct rtw_adapter *padapter); void (*DeInitSwLeds)(struct rtw_adapter *padapter); @@ -117,7 +115,6 @@ int rtw_resume_process23a(struct rtw_adapter *padapter); void rtw_hal_sw_led_init23a(struct rtw_adapter *padapter); void rtw_hal_sw_led_deinit23a(struct rtw_adapter *padapter); -u32 rtw_hal_power_on23a(struct rtw_adapter *padapter); int rtw_hal_init23a(struct rtw_adapter *padapter); int rtw_hal_deinit23a(struct rtw_adapter *padapter); void rtw_hal_stop(struct rtw_adapter *padapter); -- cgit v1.2.3 From 10ce2646494f7e2d92f7ace9865524dd2448d5a6 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:22 +0200 Subject: staging: rtl8723au: Remove unused HAL interrupt function wrappers Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_intf.c | 24 ------------------------ drivers/staging/rtl8723au/include/hal_intf.h | 9 --------- 2 files changed, 33 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index dba428ac21ed..1d47539c220e 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -34,23 +34,6 @@ void rtw_hal_sw_led_deinit23a(struct rtw_adapter *padapter) padapter->HalFunc.DeInitSwLeds(padapter); } -void rtw_hal_enable_interrupt23a(struct rtw_adapter *padapter) -{ - if (padapter->HalFunc.enable_interrupt) - padapter->HalFunc.enable_interrupt(padapter); - else - DBG_8723A("%s: HalFunc.enable_interrupt is NULL!\n", __FUNCTION__); - -} -void rtw_hal_disable_interrupt23a(struct rtw_adapter *padapter) -{ - if (padapter->HalFunc.disable_interrupt) - padapter->HalFunc.disable_interrupt(padapter); - else - DBG_8723A("%s: HalFunc.disable_interrupt is NULL!\n", __FUNCTION__); - -} - void rtw_hal_update_ra_mask23a(struct sta_info *psta, u8 rssi_level) { struct rtw_adapter *padapter; @@ -70,10 +53,3 @@ void rtw_hal_update_ra_mask23a(struct sta_info *psta, u8 rssi_level) } else rtl8723a_update_ramask(padapter, psta->mac_id, rssi_level); } - -s32 rtw_hal_interrupt_handler23a(struct rtw_adapter *padapter) -{ - if (padapter->HalFunc.interrupt_handler) - return padapter->HalFunc.interrupt_handler(padapter); - return _FAIL; -} diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 6e32215a0b04..b2dcd1da9713 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -63,10 +63,6 @@ enum hal_odm_variable { struct hal_ops { void (*InitSwLeds)(struct rtw_adapter *padapter); void (*DeInitSwLeds)(struct rtw_adapter *padapter); - - void (*enable_interrupt)(struct rtw_adapter *padapter); - void (*disable_interrupt)(struct rtw_adapter *padapter); - s32 (*interrupt_handler)(struct rtw_adapter *padapter); }; enum rt_eeprom_type { @@ -119,14 +115,9 @@ int rtw_hal_init23a(struct rtw_adapter *padapter); int rtw_hal_deinit23a(struct rtw_adapter *padapter); void rtw_hal_stop(struct rtw_adapter *padapter); -void rtw_hal_enable_interrupt23a(struct rtw_adapter *padapter); -void rtw_hal_disable_interrupt23a(struct rtw_adapter *padapter); - void rtw_hal_update_ra_mask23a(struct sta_info *psta, u8 rssi_level); void rtw_hal_clone_data(struct rtw_adapter *dst_padapter, struct rtw_adapter *src_padapter); -s32 rtw_hal_interrupt_handler23a(struct rtw_adapter *padapter); - void hw_var_set_correct_tsf(struct rtw_adapter *padapter); void hw_var_set_mlme_disconnect(struct rtw_adapter *padapter); void hw_var_set_opmode(struct rtw_adapter *padapter, u8 mode); -- cgit v1.2.3 From 02d50c22bdedec15998ca1a83141aae9b79b1022 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:23 +0200 Subject: staging: rtl8723au: Remove sw led hal ops Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_intf.c | 12 ------------ drivers/staging/rtl8723au/hal/usb_halinit.c | 5 ----- drivers/staging/rtl8723au/include/drv_types.h | 1 - drivers/staging/rtl8723au/include/hal_intf.h | 8 -------- drivers/staging/rtl8723au/os_dep/os_intfs.c | 3 --- 5 files changed, 29 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index 1d47539c220e..cc1b1eac5b89 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -22,18 +22,6 @@ #include #include -void rtw_hal_sw_led_init23a(struct rtw_adapter *padapter) -{ - if (padapter->HalFunc.InitSwLeds) - padapter->HalFunc.InitSwLeds(padapter); -} - -void rtw_hal_sw_led_deinit23a(struct rtw_adapter *padapter) -{ - if (padapter->HalFunc.DeInitSwLeds) - padapter->HalFunc.DeInitSwLeds(padapter); -} - void rtw_hal_update_ra_mask23a(struct sta_info *psta, u8 rssi_level) { struct rtw_adapter *padapter; diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index be98560f1e4f..5ecd7f339f82 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1694,16 +1694,11 @@ int rtw_hal_deinit23a(struct rtw_adapter *padapter) int rtl8723au_set_hal_ops(struct rtw_adapter *padapter) { - struct hal_ops *pHalFunc = &padapter->HalFunc; - padapter->HalData = kzalloc(sizeof(struct hal_data_8723a), GFP_KERNEL); if (!padapter->HalData) { DBG_8723A("cannot alloc memory for HAL DATA\n"); return -ENOMEM; } - pHalFunc->InitSwLeds = NULL; - pHalFunc->DeInitSwLeds = NULL; - return 0; } diff --git a/drivers/staging/rtl8723au/include/drv_types.h b/drivers/staging/rtl8723au/include/drv_types.h index e31e6ea56f54..3f2252301139 100644 --- a/drivers/staging/rtl8723au/include/drv_types.h +++ b/drivers/staging/rtl8723au/include/drv_types.h @@ -239,7 +239,6 @@ struct rtw_adapter { u32 setband; void *HalData; - struct hal_ops HalFunc; s32 bDriverStopped; s32 bSurpriseRemoved; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index b2dcd1da9713..04223b5c047d 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -60,11 +60,6 @@ enum hal_odm_variable { HAL_ODM_WIFI_DISPLAY_STATE, }; -struct hal_ops { - void (*InitSwLeds)(struct rtw_adapter *padapter); - void (*DeInitSwLeds)(struct rtw_adapter *padapter); -}; - enum rt_eeprom_type { EEPROM_93C46, EEPROM_93C56, @@ -108,9 +103,6 @@ void rtw_hal_def_value_init23a(struct rtw_adapter *padapter); int pm_netdev_open23a(struct net_device *pnetdev, u8 bnormal); int rtw_resume_process23a(struct rtw_adapter *padapter); -void rtw_hal_sw_led_init23a(struct rtw_adapter *padapter); -void rtw_hal_sw_led_deinit23a(struct rtw_adapter *padapter); - int rtw_hal_init23a(struct rtw_adapter *padapter); int rtw_hal_deinit23a(struct rtw_adapter *padapter); void rtw_hal_stop(struct rtw_adapter *padapter); diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index 3a455d111a33..1a253a0a372e 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -523,7 +523,6 @@ u8 rtw_init_drv_sw23a(struct rtw_adapter *padapter) ret8 = rtw_init_default_value(padapter); rtl8723a_init_dm_priv(padapter); - rtw_hal_sw_led_init23a(padapter); rtw_sreset_init(padapter); @@ -549,8 +548,6 @@ void rtw_cancel_all_timer23a(struct rtw_adapter *padapter) RT_TRACE(_module_os_intfs_c_, _drv_info_, ("rtw_cancel_all_timer23a:cancel dynamic_chk_timer!\n")); - /* cancel sw led timer */ - rtw_hal_sw_led_deinit23a(padapter); RT_TRACE(_module_os_intfs_c_, _drv_info_, ("rtw_cancel_all_timer23a:cancel DeInitSwLeds!\n")); -- cgit v1.2.3 From 9385d861bddfb451145500ed1375304fa6ccec41 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:24 +0200 Subject: staging: rtl8723au: Get rid of rtl8723au_set_hal_ops() and get rid of hal_ops.h Since rtl8723au_set_hal_ops() is just a kmalloc(), move it to rtw_usb_if1_init() and fix the error handling to not leak memory. This also allows us to get rid of hal_ops.h Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_intf.c | 1 - drivers/staging/rtl8723au/hal/usb_halinit.c | 12 ------------ drivers/staging/rtl8723au/include/usb_hal.h | 20 -------------------- drivers/staging/rtl8723au/os_dep/usb_intf.c | 9 +++++---- 4 files changed, 5 insertions(+), 37 deletions(-) delete mode 100644 drivers/staging/rtl8723au/include/usb_hal.h diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index cc1b1eac5b89..5383e692546f 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -19,7 +19,6 @@ #include -#include #include void rtw_hal_update_ra_mask23a(struct sta_info *psta, u8 rssi_level) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 5ecd7f339f82..538eacc51ed2 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -25,7 +25,6 @@ #include #include -#include #include static void @@ -1691,14 +1690,3 @@ int rtw_hal_deinit23a(struct rtw_adapter *padapter) DBG_8723A("\n rtw_hal_deinit23a: hal_init fail\n"); return status; } - -int rtl8723au_set_hal_ops(struct rtw_adapter *padapter) -{ - padapter->HalData = kzalloc(sizeof(struct hal_data_8723a), GFP_KERNEL); - if (!padapter->HalData) { - DBG_8723A("cannot alloc memory for HAL DATA\n"); - return -ENOMEM; - } - - return 0; -} diff --git a/drivers/staging/rtl8723au/include/usb_hal.h b/drivers/staging/rtl8723au/include/usb_hal.h deleted file mode 100644 index 4edec3b539b7..000000000000 --- a/drivers/staging/rtl8723au/include/usb_hal.h +++ /dev/null @@ -1,20 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek 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. - * - ******************************************************************************/ -#ifndef __USB_HAL_H__ -#define __USB_HAL_H__ - -int rtl8723au_set_hal_ops(struct rtw_adapter *padapter); - -#endif /* __USB_HAL_H__ */ diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index a3379b7fa178..1e87c681c7bd 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -24,7 +24,6 @@ #include #include #include -#include #include static int rtw_suspend(struct usb_interface *intf, pm_message_t message); @@ -616,9 +615,10 @@ static struct rtw_adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, if (rtw_wdev_alloc(padapter, dvobj_to_dev(dvobj))) goto handle_dualmac; - /* step 2. hook HalFunc, allocate HalData */ - if (rtl8723au_set_hal_ops(padapter)) - return NULL; + /* step 2. allocate HalData */ + padapter->HalData = kzalloc(sizeof(struct hal_data_8723a), GFP_KERNEL); + if (!padapter->HalData) + goto free_wdev; padapter->intf_start = &usb_intf_start; padapter->intf_stop = &usb_intf_stop; @@ -674,6 +674,7 @@ static struct rtw_adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, free_hal_data: if (status != _SUCCESS) kfree(padapter->HalData); +free_wdev: if (status != _SUCCESS) { rtw_wdev_unregister(padapter->rtw_wdev); rtw_wdev_free(padapter->rtw_wdev); -- cgit v1.2.3 From 25a931106fab088f5c50b4b998c0100127c3d262 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:25 +0200 Subject: staging: rtl8723au: usb_osintf.h isn't used for anything - get rid of it Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ioctl_set.c | 1 - drivers/staging/rtl8723au/hal/usb_halinit.c | 1 - drivers/staging/rtl8723au/include/usb_osintf.h | 24 ------------------------ drivers/staging/rtl8723au/os_dep/os_intfs.c | 1 - drivers/staging/rtl8723au/os_dep/usb_intf.c | 1 - 5 files changed, 28 deletions(-) delete mode 100644 drivers/staging/rtl8723au/include/usb_osintf.h diff --git a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c index abf30c5ce10a..eb4aa925287a 100644 --- a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c @@ -19,7 +19,6 @@ #include #include -#include #include #include diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 538eacc51ed2..e345634ecb25 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -25,7 +25,6 @@ #include #include -#include static void _ConfigChipOutEP(struct rtw_adapter *pAdapter, u8 NumOutPipe) diff --git a/drivers/staging/rtl8723au/include/usb_osintf.h b/drivers/staging/rtl8723au/include/usb_osintf.h deleted file mode 100644 index 46087662834e..000000000000 --- a/drivers/staging/rtl8723au/include/usb_osintf.h +++ /dev/null @@ -1,24 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek 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. - * - ******************************************************************************/ -#ifndef __USB_OSINTF_H -#define __USB_OSINTF_H - -#include -#include -#include - -#define USBD_HALTED(_status) ((u32)(_status) >> 30 == 3) - -#endif diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index 1a253a0a372e..afab4625b041 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -21,7 +21,6 @@ #include #include -#include #include #include diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index 1e87c681c7bd..6077e37850a9 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -23,7 +23,6 @@ #include #include #include -#include #include static int rtw_suspend(struct usb_interface *intf, pm_message_t message); -- cgit v1.2.3 From 60a2d48551341ec597579ad52b64de18553bfe14 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:26 +0200 Subject: staging: rtl8723au: usb_vendor_req.h isn't used - remove it Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/usb_vendor_req.h | 31 ---------------------- drivers/staging/rtl8723au/os_dep/usb_intf.c | 1 - 2 files changed, 32 deletions(-) delete mode 100644 drivers/staging/rtl8723au/include/usb_vendor_req.h diff --git a/drivers/staging/rtl8723au/include/usb_vendor_req.h b/drivers/staging/rtl8723au/include/usb_vendor_req.h deleted file mode 100644 index eb4508ef191e..000000000000 --- a/drivers/staging/rtl8723au/include/usb_vendor_req.h +++ /dev/null @@ -1,31 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek 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. - * - ******************************************************************************/ -#ifndef _USB_VENDOR_REQUEST_H_ -#define _USB_VENDOR_REQUEST_H_ - -/* 4 Set/Get Register related wIndex/Data */ -#define RT_USB_RESET_MASK_OFF 0 -#define RT_USB_RESET_MASK_ON 1 -#define RT_USB_SLEEP_MASK_OFF 0 -#define RT_USB_SLEEP_MASK_ON 1 -#define RT_USB_LDO_ON 1 -#define RT_USB_LDO_OFF 0 - -/* 4 Set/Get SYSCLK related wValue or Data */ -#define RT_USB_SYSCLK_32KHZ 0 -#define RT_USB_SYSCLK_40MHZ 1 -#define RT_USB_SYSCLK_60MHZ 2 - -#endif diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index 6077e37850a9..6479c5fbf9a1 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include -- cgit v1.2.3 From 7271496bd187bb0a3b8a9adea36bfdfd6292ccd0 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:27 +0200 Subject: staging: rtl8723au: Remove unused mp_custom_oid.h Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/mp_custom_oid.h | 342 ---------------------- 1 file changed, 342 deletions(-) delete mode 100644 drivers/staging/rtl8723au/include/mp_custom_oid.h diff --git a/drivers/staging/rtl8723au/include/mp_custom_oid.h b/drivers/staging/rtl8723au/include/mp_custom_oid.h deleted file mode 100644 index da197cf678a1..000000000000 --- a/drivers/staging/rtl8723au/include/mp_custom_oid.h +++ /dev/null @@ -1,342 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek 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. - * - ******************************************************************************/ -#ifndef __CUSTOM_OID_H -#define __CUSTOM_OID_H - -/* 0xFF818000 - 0xFF81802F RTL8180 Mass Production Kit */ -/* 0xFF818500 - 0xFF81850F RTL8185 Setup Utility */ -/* 0xFF818580 - 0xFF81858F RTL8185 Phy Status Utility */ - -/* For Production Kit with Agilent Equipments */ -/* in order to make our custom oids hopefully somewhat unique */ -/* we will use 0xFF (indicating implementation specific OID) */ -/* 81(first byte of non zero Realtek unique identifier) */ -/* 80 (second byte of non zero Realtek unique identifier) */ -/* XX (the custom OID number - providing 255 possible custom oids) */ - -#define OID_RT_PRO_RESET_DUT 0xFF818000 -#define OID_RT_PRO_SET_DATA_RATE 0xFF818001 -#define OID_RT_PRO_START_TEST 0xFF818002 -#define OID_RT_PRO_STOP_TEST 0xFF818003 -#define OID_RT_PRO_SET_PREAMBLE 0xFF818004 -#define OID_RT_PRO_SET_SCRAMBLER 0xFF818005 -#define OID_RT_PRO_SET_FILTER_BB 0xFF818006 -#define OID_RT_PRO_SET_MANUAL_DIVERSITY_BB 0xFF818007 -#define OID_RT_PRO_SET_CHANNEL_DIRECT_CALL 0xFF818008 -#define OID_RT_PRO_SET_SLEEP_MODE_DIRECT_CALL 0xFF818009 -#define OID_RT_PRO_SET_WAKE_MODE_DIRECT_CALL 0xFF81800A - -#define OID_RT_PRO_SET_TX_ANTENNA_BB 0xFF81800D -#define OID_RT_PRO_SET_ANTENNA_BB 0xFF81800E -#define OID_RT_PRO_SET_CR_SCRAMBLER 0xFF81800F -#define OID_RT_PRO_SET_CR_NEW_FILTER 0xFF818010 -#define OID_RT_PRO_SET_TX_POWER_CONTROL 0xFF818011 -#define OID_RT_PRO_SET_CR_TX_CONFIG 0xFF818012 -#define OID_RT_PRO_GET_TX_POWER_CONTROL 0xFF818013 -#define OID_RT_PRO_GET_CR_SIGNAL_QUALITY 0xFF818014 -#define OID_RT_PRO_SET_CR_SETPOINT 0xFF818015 -#define OID_RT_PRO_SET_INTEGRATOR 0xFF818016 -#define OID_RT_PRO_SET_SIGNAL_QUALITY 0xFF818017 -#define OID_RT_PRO_GET_INTEGRATOR 0xFF818018 -#define OID_RT_PRO_GET_SIGNAL_QUALITY 0xFF818019 -#define OID_RT_PRO_QUERY_EEPROM_TYPE 0xFF81801A -#define OID_RT_PRO_WRITE_MAC_ADDRESS 0xFF81801B -#define OID_RT_PRO_READ_MAC_ADDRESS 0xFF81801C -#define OID_RT_PRO_WRITE_CIS_DATA 0xFF81801D -#define OID_RT_PRO_READ_CIS_DATA 0xFF81801E -#define OID_RT_PRO_WRITE_POWER_CONTROL 0xFF81801F -#define OID_RT_PRO_READ_POWER_CONTROL 0xFF818020 -#define OID_RT_PRO_WRITE_EEPROM 0xFF818021 -#define OID_RT_PRO_READ_EEPROM 0xFF818022 -#define OID_RT_PRO_RESET_TX_PACKET_SENT 0xFF818023 -#define OID_RT_PRO_QUERY_TX_PACKET_SENT 0xFF818024 -#define OID_RT_PRO_RESET_RX_PACKET_RECEIVED 0xFF818025 -#define OID_RT_PRO_QUERY_RX_PACKET_RECEIVED 0xFF818026 -#define OID_RT_PRO_QUERY_RX_PACKET_CRC32_ERROR 0xFF818027 -#define OID_RT_PRO_QUERY_CURRENT_ADDRESS 0xFF818028 -#define OID_RT_PRO_QUERY_PERMANENT_ADDRESS 0xFF818029 -#define OID_RT_PRO_SET_PHILIPS_RF_PARAMETERS 0xFF81802A -#define OID_RT_PRO_RECEIVE_PACKET 0xFF81802C -/* added by Owen on 04/08/03 for Cameo's request */ -#define OID_RT_PRO_WRITE_EEPROM_BYTE 0xFF81802D -#define OID_RT_PRO_READ_EEPROM_BYTE 0xFF81802E -#define OID_RT_PRO_SET_MODULATION 0xFF81802F -/* */ - -#define OID_RT_DRIVER_OPTION 0xFF818080 -#define OID_RT_RF_OFF 0xFF818081 -#define OID_RT_AUTH_STATUS 0xFF818082 - -/* */ -#define OID_RT_PRO_SET_CONTINUOUS_TX 0xFF81800B -#define OID_RT_PRO_SET_SINGLE_CARRIER_TX 0xFF81800C -#define OID_RT_PRO_SET_CARRIER_SUPPRESSION_TX 0xFF81802B -#define OID_RT_PRO_SET_SINGLE_TONE_TX 0xFF818043 -/* */ - - -/* by Owen for RTL8185 Phy Status Report Utility */ -#define OID_RT_UTILITYfalse_ALARM_COUNTERS 0xFF818580 -#define OID_RT_UTILITY_SELECT_DEBUG_MODE 0xFF818581 -#define OID_RT_UTILITY_SELECT_SUBCARRIER_NUMBER 0xFF818582 -#define OID_RT_UTILITY_GET_RSSI_STATUS 0xFF818583 -#define OID_RT_UTILITY_GET_FRAME_DETECTION_STATUS 0xFF818584 -#define OID_RT_UTILITY_GET_AGC_AND_FREQUENCY_OFFSET_ESTIMATION_STATUS 0xFF818585 -#define OID_RT_UTILITY_GET_CHANNEL_ESTIMATION_STATUS 0xFF818586 - -/* by Owen on 03/09/19-03/09/22 for RTL8185 */ -#define OID_RT_WIRELESS_MODE 0xFF818500 -#define OID_RT_SUPPORTED_RATES 0xFF818501 -#define OID_RT_DESIRED_RATES 0xFF818502 -#define OID_RT_WIRELESS_MODE_STARTING_ADHOC 0xFF818503 -/* */ - -#define OID_RT_GET_CONNECT_STATE 0xFF030001 -#define OID_RT_RESCAN 0xFF030002 -#define OID_RT_SET_KEY_LENGTH 0xFF030003 -#define OID_RT_SET_DEFAULT_KEY_ID 0xFF030004 - -#define OID_RT_SET_CHANNEL 0xFF010182 -#define OID_RT_SET_SNIFFER_MODE 0xFF010183 -#define OID_RT_GET_SIGNAL_QUALITY 0xFF010184 -#define OID_RT_GET_SMALL_PACKET_CRC 0xFF010185 -#define OID_RT_GET_MIDDLE_PACKET_CRC 0xFF010186 -#define OID_RT_GET_LARGE_PACKET_CRC 0xFF010187 -#define OID_RT_GET_TX_RETRY 0xFF010188 -#define OID_RT_GET_RX_RETRY 0xFF010189 -#define OID_RT_PRO_SET_FW_DIG_STATE 0xFF01018A/* S */ -#define OID_RT_PRO_SET_FW_RA_STATE 0xFF01018B/* S */ - -#define OID_RT_GET_RX_TOTAL_PACKET 0xFF010190 -#define OID_RT_GET_TX_BEACON_OK 0xFF010191 -#define OID_RT_GET_TX_BEACON_ERR 0xFF010192 -#define OID_RT_GET_RX_ICV_ERR 0xFF010193 -#define OID_RT_SET_ENCRYPTION_ALGORITHM 0xFF010194 -#define OID_RT_SET_NO_AUTO_RESCAN 0xFF010195 -#define OID_RT_GET_PREAMBLE_MODE 0xFF010196 -#define OID_RT_GET_DRIVER_UP_DELTA_TIME 0xFF010197 -#define OID_RT_GET_AP_IP 0xFF010198 -#define OID_RT_GET_CHANNELPLAN 0xFF010199 -#define OID_RT_SET_PREAMBLE_MODE 0xFF01019A -#define OID_RT_SET_BCN_INTVL 0xFF01019B -#define OID_RT_GET_RF_VENDER 0xFF01019C -#define OID_RT_DEDICATE_PROBE 0xFF01019D -#define OID_RT_PRO_RX_FILTER_PATTERN 0xFF01019E - -#define OID_RT_GET_DCST_CURRENT_THRESHOLD 0xFF01019F - -#define OID_RT_GET_CCA_ERR 0xFF0101A0 -#define OID_RT_GET_CCA_UPGRADE_THRESHOLD 0xFF0101A1 -#define OID_RT_GET_CCA_FALLBACK_THRESHOLD 0xFF0101A2 - -#define OID_RT_GET_CCA_UPGRADE_EVALUATE_TIMES 0xFF0101A3 -#define OID_RT_GET_CCA_FALLBACK_EVALUATE_TIMES 0xFF0101A4 - -/* by Owen on 03/31/03 for Cameo's request */ -#define OID_RT_SET_RATE_ADAPTIVE 0xFF0101A5 -/* */ -#define OID_RT_GET_DCST_EVALUATE_PERIOD 0xFF0101A5 -#define OID_RT_GET_DCST_TIME_UNIT_INDEX 0xFF0101A6 -#define OID_RT_GET_TOTAL_TX_BYTES 0xFF0101A7 -#define OID_RT_GET_TOTAL_RX_BYTES 0xFF0101A8 -#define OID_RT_CURRENT_TX_POWER_LEVEL 0xFF0101A9 -#define OID_RT_GET_ENC_KEY_MISMATCH_COUNT 0xFF0101AA -#define OID_RT_GET_ENC_KEY_MATCH_COUNT 0xFF0101AB -#define OID_RT_GET_CHANNEL 0xFF0101AC - -#define OID_RT_SET_CHANNELPLAN 0xFF0101AD -#define OID_RT_GET_HARDWARE_RADIO_OFF 0xFF0101AE -#define OID_RT_CHANNELPLAN_BY_COUNTRY 0xFF0101AF -#define OID_RT_SCAN_AVAILABLE_BSSID 0xFF0101B0 -#define OID_RT_GET_HARDWARE_VERSION 0xFF0101B1 -#define OID_RT_GET_IS_ROAMING 0xFF0101B2 -#define OID_RT_GET_IS_PRIVACY 0xFF0101B3 -#define OID_RT_GET_KEY_MISMATCH 0xFF0101B4 -#define OID_RT_SET_RSSI_ROAM_TRAFFIC_TH 0xFF0101B5 -#define OID_RT_SET_RSSI_ROAM_SIGNAL_TH 0xFF0101B6 -#define OID_RT_RESET_LOG 0xFF0101B7 -#define OID_RT_GET_LOG 0xFF0101B8 -#define OID_RT_SET_INDICATE_HIDDEN_AP 0xFF0101B9 -#define OID_RT_GET_HEADER_FAIL 0xFF0101BA -#define OID_RT_SUPPORTED_WIRELESS_MODE 0xFF0101BB -#define OID_RT_GET_CHANNEL_LIST 0xFF0101BC -#define OID_RT_GET_SCAN_IN_PROGRESS 0xFF0101BD -#define OID_RT_GET_TX_INFO 0xFF0101BE -#define OID_RT_RF_READ_WRITE_OFFSET 0xFF0101BF -#define OID_RT_RF_READ_WRITE 0xFF0101C0 - -/* For Netgear request. 2005.01.13, by rcnjko. */ -#define OID_RT_FORCED_DATA_RATE 0xFF0101C1 -#define OID_RT_WIRELESS_MODE_FOR_SCAN_LIST 0xFF0101C2 -/* For Netgear request. 2005.02.17, by rcnjko. */ -#define OID_RT_GET_BSS_WIRELESS_MODE 0xFF0101C3 -/* For AZ project. 2005.06.27, by rcnjko. */ -#define OID_RT_SCAN_WITH_MAGIC_PACKET 0xFF0101C4 - -/* Vincent 8185MP */ -#define OID_RT_PRO_RX_FILTER 0xFF0111C0 - -/* Andy TEST */ -/* define OID_RT_PRO_WRITE_REGISTRY 0xFF0111C1 */ -/* define OID_RT_PRO_READ_REGISTRY 0xFF0111C2 */ -#define OID_CE_USB_WRITE_REGISTRY 0xFF0111C1 -#define OID_CE_USB_READ_REGISTRY 0xFF0111C2 - - -#define OID_RT_PRO_SET_INITIAL_GAIN 0xFF0111C3 -#define OID_RT_PRO_SET_BB_RF_STANDBY_MODE 0xFF0111C4 -#define OID_RT_PRO_SET_BB_RF_SHUTDOWN_MODE 0xFF0111C5 -#define OID_RT_PRO_SET_TX_CHARGE_PUMP 0xFF0111C6 -#define OID_RT_PRO_SET_RX_CHARGE_PUMP 0xFF0111C7 -#define OID_RT_PRO_RF_WRITE_REGISTRY 0xFF0111C8 -#define OID_RT_PRO_RF_READ_REGISTRY 0xFF0111C9 -#define OID_RT_PRO_QUERY_RF_TYPE 0xFF0111CA - -/* AP OID */ -#define OID_RT_AP_GET_ASSOCIATED_STATION_LIST 0xFF010300 -#define OID_RT_AP_GET_CURRENT_TIME_STAMP 0xFF010301 -#define OID_RT_AP_SWITCH_INTO_AP_MODE 0xFF010302 -#define OID_RT_AP_SET_DTIM_PERIOD 0xFF010303 -#define OID_RT_AP_SUPPORTED 0xFF010304 /* Determine if driver supports AP mode. 2004.08.27, by rcnjko. */ -#define OID_RT_AP_SET_PASSPHRASE 0xFF010305 /* Set WPA-PSK passphrase into authenticator. 2005.07.08, byrcnjko. */ - -/* 8187MP. 2004.09.06, by rcnjko. */ -#define OID_RT_PRO8187_WI_POLL 0xFF818780 -#define OID_RT_PRO_WRITE_BB_REG 0xFF818781 -#define OID_RT_PRO_READ_BB_REG 0xFF818782 -#define OID_RT_PRO_WRITE_RF_REG 0xFF818783 -#define OID_RT_PRO_READ_RF_REG 0xFF818784 - -/* Meeting House. added by Annie, 2005-07-20. */ -#define OID_RT_MH_VENDER_ID 0xFFEDC100 - -/* 8711 MP OID added 20051230. */ -#define OID_RT_PRO8711_JOIN_BSS 0xFF871100/* S */ - -#define OID_RT_PRO_READ_REGISTER 0xFF871101 /* Q */ -#define OID_RT_PRO_WRITE_REGISTER 0xFF871102 /* S */ - -#define OID_RT_PRO_BURST_READ_REGISTER 0xFF871103 /* Q */ -#define OID_RT_PRO_BURST_WRITE_REGISTER 0xFF871104 /* S */ - -#define OID_RT_PRO_WRITE_TXCMD 0xFF871105 /* S */ - -#define OID_RT_PRO_READ16_EEPROM 0xFF871106 /* Q */ -#define OID_RT_PRO_WRITE16_EEPROM 0xFF871107 /* S */ - -#define OID_RT_PRO_H2C_SET_COMMAND 0xFF871108 /* S */ -#define OID_RT_PRO_H2C_QUERY_RESULT 0xFF871109 /* Q */ - -#define OID_RT_PRO8711_WI_POLL 0xFF87110A /* Q */ -#define OID_RT_PRO8711_PKT_LOSS 0xFF87110B /* Q */ -#define OID_RT_RD_ATTRIB_MEM 0xFF87110C/* Q */ -#define OID_RT_WR_ATTRIB_MEM 0xFF87110D/* S */ - - -/* Method 2 for H2C/C2H */ -#define OID_RT_PRO_H2C_CMD_MODE 0xFF871110 /* S */ -#define OID_RT_PRO_H2C_CMD_RSP_MODE 0xFF871111 /* Q */ -#define OID_RT_PRO_H2C_CMD_EVENT_MODE 0xFF871112 /* S */ -#define OID_RT_PRO_WAIT_C2H_EVENT 0xFF871113 /* Q */ -#define OID_RT_PRO_RW_ACCESS_PROTOCOL_TEST 0xFF871114/* Q */ - -#define OID_RT_PRO_SCSI_ACCESS_TEST 0xFF871115 /* Q, S */ - -#define OID_RT_PRO_SCSI_TCPIPOFFLOAD_OUT 0xFF871116 /* S */ -#define OID_RT_PRO_SCSI_TCPIPOFFLOAD_IN 0xFF871117 /* Q,S */ -#define OID_RT_RRO_RX_PKT_VIA_IOCTRL 0xFF871118 /* Q */ -#define OID_RT_RRO_RX_PKTARRAY_VIA_IOCTRL 0xFF871119 /* Q */ - -#define OID_RT_RPO_SET_PWRMGT_TEST 0xFF87111A /* S */ -#define OID_RT_PRO_QRY_PWRMGT_TEST 0XFF87111B /* Q */ -#define OID_RT_RPO_ASYNC_RWIO_TEST 0xFF87111C /* S */ -#define OID_RT_RPO_ASYNC_RWIO_POLL 0xFF87111D /* Q */ -#define OID_RT_PRO_SET_RF_INTFS 0xFF87111E /* S */ -#define OID_RT_POLL_RX_STATUS 0xFF87111F /* Q */ - -#define OID_RT_PRO_CFG_DEBUG_MESSAGE 0xFF871120 /* Q,S */ -#define OID_RT_PRO_SET_DATA_RATE_EX 0xFF871121/* S */ -#define OID_RT_PRO_SET_BASIC_RATE 0xFF871122/* S */ -#define OID_RT_PRO_READ_TSSI 0xFF871123/* S */ -#define OID_RT_PRO_SET_POWER_TRACKING 0xFF871124/* S */ - - -#define OID_RT_PRO_QRY_PWRSTATE 0xFF871150 /* Q */ -#define OID_RT_PRO_SET_PWRSTATE 0xFF871151 /* S */ - -/* Method 2 , using workitem */ -#define OID_RT_SET_READ_REG 0xFF871181 /* S */ -#define OID_RT_SET_WRITE_REG 0xFF871182 /* S */ -#define OID_RT_SET_BURST_READ_REG 0xFF871183 /* S */ -#define OID_RT_SET_BURST_WRITE_REG 0xFF871184 /* S */ -#define OID_RT_SET_WRITE_TXCMD 0xFF871185 /* S */ -#define OID_RT_SET_READ16_EEPROM 0xFF871186 /* S */ -#define OID_RT_SET_WRITE16_EEPROM 0xFF871187 /* S */ -#define OID_RT_QRY_POLL_WKITEM 0xFF871188 /* Q */ - -/* For SDIO INTERFACE only */ -#define OID_RT_PRO_SYNCPAGERW_SRAM 0xFF8711A0 /* Q, S */ -#define OID_RT_PRO_871X_DRV_EXT 0xFF8711A1 - -/* For USB INTERFACE only */ -#define OID_RT_PRO_USB_VENDOR_REQ 0xFF8711B0 /* Q, S */ -#define OID_RT_PRO_SCSI_AUTO_TEST 0xFF8711B1 /* S */ -#define OID_RT_PRO_USB_MAC_AC_FIFO_WRITE 0xFF8711B2 /* S */ -#define OID_RT_PRO_USB_MAC_RX_FIFO_READ 0xFF8711B3 /* Q */ -#define OID_RT_PRO_USB_MAC_RX_FIFO_POLLING 0xFF8711B4 /* Q */ - -#define OID_RT_PRO_H2C_SET_RATE_TABLE 0xFF8711FB /* S */ -#define OID_RT_PRO_H2C_GET_RATE_TABLE 0xFF8711FC /* S */ -#define OID_RT_PRO_H2C_C2H_LBK_TEST 0xFF8711FE - -#define OID_RT_PRO_ENCRYPTION_CTRL 0xFF871200 /* Q, S */ -#define OID_RT_PRO_ADD_STA_INFO 0xFF871201 /* S */ -#define OID_RT_PRO_DELE_STA_INFO 0xFF871202 /* S */ -#define OID_RT_PRO_QUERY_DR_VARIABLE 0xFF871203 /* Q */ - -#define OID_RT_PRO_RX_PACKET_TYPE 0xFF871204 /* Q, S */ - -#define OID_RT_PRO_READ_EFUSE 0xFF871205 /* Q */ -#define OID_RT_PRO_WRITE_EFUSE 0xFF871206 /* S */ -#define OID_RT_PRO_RW_EFUSE_PGPKT 0xFF871207 /* Q, S */ -#define OID_RT_GET_EFUSE_CURRENT_SIZE 0xFF871208 /* Q */ - -#define OID_RT_SET_BANDWIDTH 0xFF871209 /* S */ -#define OID_RT_SET_CRYSTAL_CAP 0xFF87120A /* S */ - -#define OID_RT_SET_RX_PACKET_TYPE 0xFF87120B /* S */ - -#define OID_RT_GET_EFUSE_MAX_SIZE 0xFF87120C /* Q */ - -#define OID_RT_PRO_SET_TX_AGC_OFFSET 0xFF87120D /* S */ - -#define OID_RT_PRO_SET_PKT_TEST_MODE 0xFF87120E /* S */ - -#define OID_RT_PRO_FOR_EVM_TEST_SETTING 0xFF87120F /* S */ - -#define OID_RT_PRO_GET_THERMAL_METER 0xFF871210 /* Q */ - -#define OID_RT_RESET_PHY_RX_PACKET_COUNT 0xFF871211 /* S */ -#define OID_RT_GET_PHY_RX_PACKET_RECEIVED 0xFF871212 /* Q */ -#define OID_RT_GET_PHY_RX_PACKET_CRC32_ERROR 0xFF871213 /* Q */ - -#define OID_RT_SET_POWER_DOWN 0xFF871214 /* S */ - -#define OID_RT_GET_POWER_MODE 0xFF871215 /* Q */ - -#define OID_RT_PRO_EFUSE 0xFF871216 /* Q, S */ -#define OID_RT_PRO_EFUSE_MAP 0xFF871217 /* Q, S */ - -#endif /* ifndef __CUSTOM_OID_H */ -- cgit v1.2.3 From 1ec8911b6d7d12757be89d6d8f0cbbd8aa4ba350 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:28 +0200 Subject: staging: rtl8723au: Make cmd and event handlers return int instead of u8 This is needed so we can eventually start passing around proper error codes instead of the custom RTW ones. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 79 +++++++++++----------- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 38 +++++------ drivers/staging/rtl8723au/include/rtw_cmd.h | 84 ++++++++++++------------ drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 62 ++++++++--------- 4 files changed, 131 insertions(+), 132 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 356bfcc9744a..2f3fbb3d1bbb 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -287,7 +287,7 @@ void rtw_free_cmd_obj23a(struct cmd_obj *pcmd) static void rtw_cmd_work(struct work_struct *work) { - u8 (*cmd_hdl)(struct rtw_adapter *padapter, const u8 *pbuf); + int (*cmd_hdl)(struct rtw_adapter *padapter, const u8 *pbuf); void (*pcmd_callback)(struct rtw_adapter *dev, struct cmd_obj *pcmd); struct cmd_priv *pcmdpriv; struct cmd_obj *pcmd = container_of(work, struct cmd_obj, work); @@ -338,11 +338,11 @@ post_process: } -u8 rtw_sitesurvey_cmd23a(struct rtw_adapter *padapter, - struct cfg80211_ssid *ssid, int ssid_num, - struct rtw_ieee80211_channel *ch, int ch_num) +int rtw_sitesurvey_cmd23a(struct rtw_adapter *padapter, + struct cfg80211_ssid *ssid, int ssid_num, + struct rtw_ieee80211_channel *ch, int ch_num) { - u8 res = _FAIL; + int res = _FAIL; struct cmd_obj *ph2c; struct sitesurvey_parm *psurveyPara; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; @@ -421,7 +421,7 @@ void rtw_getbbrfreg_cmdrsp_callback23a(struct rtw_adapter *padapter, kfree(pcmd); } -u8 rtw_createbss_cmd23a(struct rtw_adapter *padapter) +int rtw_createbss_cmd23a(struct rtw_adapter *padapter) { struct cmd_obj *pcmd; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; @@ -464,10 +464,11 @@ exit: return res; } -u8 rtw_joinbss_cmd23a(struct rtw_adapter *padapter, - struct wlan_network *pnetwork) +int rtw_joinbss_cmd23a(struct rtw_adapter *padapter, + struct wlan_network *pnetwork) { - u8 *auth, res = _SUCCESS; + u8 *auth; + int res = _SUCCESS; struct wlan_bssid_ex *psecnetwork; struct cmd_obj *pcmd; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; @@ -629,13 +630,13 @@ exit: return res; } -u8 rtw_disassoc_cmd23a(struct rtw_adapter*padapter, u32 deauth_timeout_ms, - bool enqueue) +int rtw_disassoc_cmd23a(struct rtw_adapter*padapter, u32 deauth_timeout_ms, + bool enqueue) { struct cmd_obj *cmdobj = NULL; struct disconnect_parm *param = NULL; struct cmd_priv *cmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; + int res = _SUCCESS; RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_disassoc_cmd23a\n")); @@ -670,13 +671,13 @@ exit: return res; } -u8 rtw_setopmode_cmd23a(struct rtw_adapter *padapter, - enum ndis_802_11_net_infra networktype) +int rtw_setopmode_cmd23a(struct rtw_adapter *padapter, + enum ndis_802_11_net_infra networktype) { struct cmd_obj *ph2c; struct setopmode_parm *psetop; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; + int res = _SUCCESS; ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (!ph2c) { @@ -699,7 +700,7 @@ exit: return res; } -u8 rtw_setstakey_cmd23a(struct rtw_adapter *padapter, u8 *psta, u8 unicast_key) +int rtw_setstakey_cmd23a(struct rtw_adapter *padapter, u8 *psta, u8 unicast_key) { struct cmd_obj *ph2c; struct set_stakey_parm *psetstakey_para; @@ -708,7 +709,7 @@ u8 rtw_setstakey_cmd23a(struct rtw_adapter *padapter, u8 *psta, u8 unicast_key) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv *psecuritypriv = &padapter->securitypriv; struct sta_info *sta = (struct sta_info*)psta; - u8 res = _SUCCESS; + int res = _SUCCESS; ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (!ph2c) { @@ -763,15 +764,15 @@ exit: return res; } -u8 rtw_clearstakey_cmd23a(struct rtw_adapter *padapter, u8 *psta, u8 entry, - u8 enqueue) +int rtw_clearstakey_cmd23a(struct rtw_adapter *padapter, u8 *psta, u8 entry, + u8 enqueue) { struct cmd_obj *ph2c; struct set_stakey_parm *psetstakey_para; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct set_stakey_rsp *psetstakey_rsp = NULL; struct sta_info *sta = (struct sta_info *)psta; - u8 res = _SUCCESS; + int res = _SUCCESS; if (!enqueue) { clear_cam_entry23a(padapter, entry); @@ -816,12 +817,12 @@ exit: return res; } -u8 rtw_addbareq_cmd23a(struct rtw_adapter*padapter, u8 tid, u8 *addr) +int rtw_addbareq_cmd23a(struct rtw_adapter*padapter, u8 tid, u8 *addr) { struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct cmd_obj *ph2c; struct addBaReq_parm *paddbareq_parm; - u8 res = _SUCCESS; + int res = _SUCCESS; if (tid >= MAXTID) { res = _FAIL; @@ -852,12 +853,12 @@ exit: return res; } -u8 rtw_dynamic_chk_wk_cmd23a(struct rtw_adapter*padapter) +int rtw_dynamic_chk_wk_cmd23a(struct rtw_adapter*padapter) { struct cmd_obj *ph2c; struct drvextra_cmd_parm *pdrvextra_cmd_parm; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; + int res = _SUCCESS; ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (!ph2c) { @@ -889,14 +890,13 @@ exit: * This is only ever called from on_action_spct23a_ch_switch () which isn't * called from anywhere itself */ -u8 rtw_set_ch_cmd23a(struct rtw_adapter*padapter, u8 ch, u8 bw, u8 ch_offset, - u8 enqueue) +int rtw_set_ch_cmd23a(struct rtw_adapter*padapter, u8 ch, u8 bw, u8 ch_offset, + u8 enqueue) { struct cmd_obj *pcmdobj; struct set_ch_parm *set_ch_parm; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - - u8 res = _SUCCESS; + int res = _SUCCESS; DBG_8723A("%s(%s): ch:%u, bw:%u, ch_offset:%u\n", __func__, padapter->pnetdev->name, ch, bw, ch_offset); @@ -1118,13 +1118,13 @@ static void lps_ctrl_wk_hdl(struct rtw_adapter *padapter, u8 lps_ctrl_type) } } -u8 rtw_lps_ctrl_wk_cmd23a(struct rtw_adapter *padapter, - u8 lps_ctrl_type, u8 enqueue) +int rtw_lps_ctrl_wk_cmd23a(struct rtw_adapter *padapter, + u8 lps_ctrl_type, u8 enqueue) { struct cmd_obj *ph2c; struct drvextra_cmd_parm *pdrvextra_cmd_parm; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; + int res = _SUCCESS; if (enqueue) { ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); @@ -1161,13 +1161,12 @@ static void power_saving_wk_hdl(struct rtw_adapter *padapter, u8 *pbuf, int sz) rtw_ps_processor23a(padapter); } -u8 rtw_ps_cmd23a(struct rtw_adapter*padapter) +int rtw_ps_cmd23a(struct rtw_adapter*padapter) { struct cmd_obj *ppscmd; struct drvextra_cmd_parm *pdrvextra_cmd_parm; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - - u8 res = _SUCCESS; + int res = _SUCCESS; ppscmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (!ppscmd) { @@ -1232,12 +1231,12 @@ static void rtw_chk_hi_queue_hdl(struct rtw_adapter *padapter) } } -u8 rtw_chk_hi_queue_cmd23a(struct rtw_adapter*padapter) +int rtw_chk_hi_queue_cmd23a(struct rtw_adapter*padapter) { struct cmd_obj *ph2c; struct drvextra_cmd_parm *pdrvextra_cmd_parm; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; + int res = _SUCCESS; ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (!ph2c) { @@ -1267,12 +1266,12 @@ exit: } #endif -u8 rtw_c2h_wk_cmd23a(struct rtw_adapter *padapter, u8 *c2h_evt) +int rtw_c2h_wk_cmd23a(struct rtw_adapter *padapter, u8 *c2h_evt) { struct cmd_obj *ph2c; struct drvextra_cmd_parm *pdrvextra_cmd_parm; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; + int res = _SUCCESS; ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (!ph2c) { @@ -1360,7 +1359,7 @@ void rtw_evt_work(struct work_struct *work) } } -u8 rtw_drvextra_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) +int rtw_drvextra_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { const struct drvextra_cmd_parm *pdrvextra_cmd; @@ -1409,7 +1408,7 @@ u8 rtw_drvextra_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) } void rtw_survey_cmd_callback23a(struct rtw_adapter *padapter, - struct cmd_obj *pcmd) + struct cmd_obj *pcmd) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index a769d92e4f00..91164036da73 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -5809,12 +5809,12 @@ void init_mlme_ext_timer23a(struct rtw_adapter *padapter) (unsigned long)padapter); } -u8 NULL_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) +int NULL_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { return H2C_SUCCESS; } -u8 setopmode_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) +int setopmode_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { u8 type; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -5839,7 +5839,7 @@ u8 setopmode_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) return H2C_SUCCESS; } -u8 createbss_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) +int createbss_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -5893,7 +5893,7 @@ u8 createbss_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) return H2C_SUCCESS; } -u8 join_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) +int join_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { struct ndis_802_11_var_ies * pIE; struct registry_priv *pregpriv = &padapter->registrypriv; @@ -6014,7 +6014,7 @@ u8 join_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) return H2C_SUCCESS; } -u8 disconnect_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) +int disconnect_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { const struct disconnect_parm *param = (struct disconnect_parm *)pbuf; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -6125,7 +6125,7 @@ rtw_scan_ch_decision(struct rtw_adapter *padapter, return j; } -u8 sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) +int sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; const struct sitesurvey_parm *pparm = (struct sitesurvey_parm *)pbuf; @@ -6207,7 +6207,7 @@ u8 sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) return H2C_SUCCESS; } -u8 setauth_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) +int setauth_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { const struct setauth_parm *pparm = (struct setauth_parm *)pbuf; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -6221,7 +6221,7 @@ u8 setauth_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) return H2C_SUCCESS; } -u8 setkey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) +int setkey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { unsigned short ctrl; const struct setkey_parm *pparm = (struct setkey_parm *)pbuf; @@ -6246,7 +6246,7 @@ u8 setkey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) return H2C_SUCCESS; } -u8 set_stakey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) +int set_stakey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { u16 ctrl = 0; u8 cam_id;/* cam_entry */ @@ -6333,7 +6333,7 @@ u8 set_stakey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) return H2C_SUCCESS; } -u8 add_ba_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) +int add_ba_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { const struct addBaReq_parm *pparm = (struct addBaReq_parm *)pbuf; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -6357,7 +6357,7 @@ u8 add_ba_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) return H2C_SUCCESS; } -u8 set_tx_beacon_cmd23a(struct rtw_adapter* padapter) +int set_tx_beacon_cmd23a(struct rtw_adapter* padapter) { struct cmd_obj *ph2c; struct Tx_Beacon_param *ptxBeacon_parm; @@ -6403,7 +6403,7 @@ exit: return res; } -u8 mlme_evt_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) +int mlme_evt_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { u8 evt_code, evt_seq; u16 evt_sz; @@ -6437,7 +6437,7 @@ _abort_event_: return H2C_SUCCESS; } -u8 h2c_msg_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) +int h2c_msg_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { if (!pbuf) return H2C_PARAMETERS_ERROR; @@ -6445,7 +6445,7 @@ u8 h2c_msg_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) return H2C_SUCCESS; } -u8 tx_beacon_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) +int tx_beacon_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { if (send_beacon23a(padapter) == _FAIL) { @@ -6505,7 +6505,7 @@ u8 tx_beacon_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) return H2C_SUCCESS; } -u8 set_ch_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) +int set_ch_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { const struct set_ch_parm *set_ch_parm; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -6528,7 +6528,7 @@ u8 set_ch_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) return H2C_SUCCESS; } -u8 set_chplan_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) +int set_chplan_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { const struct SetChannelPlan_param *setChannelPlan_param; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -6544,7 +6544,7 @@ u8 set_chplan_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) return H2C_SUCCESS; } -u8 led_blink_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) +int led_blink_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { struct LedBlink_param *ledBlink_param; @@ -6556,7 +6556,7 @@ u8 led_blink_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) return H2C_SUCCESS; } -u8 set_csa_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) +int set_csa_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { return H2C_REJECTED; } @@ -6574,7 +6574,7 @@ u8 set_csa_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) /* TDLS_CKALV_PH1 : check alive timer phase1 */ /* TDLS_CKALV_PH2 : check alive timer phase2 */ /* TDLS_FREE_STA : free tdls sta */ -u8 tdls_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) +int tdls_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { return H2C_REJECTED; } diff --git a/drivers/staging/rtl8723au/include/rtw_cmd.h b/drivers/staging/rtl8723au/include/rtw_cmd.h index 2cb9c085cc9d..427596e123d9 100644 --- a/drivers/staging/rtl8723au/include/rtw_cmd.h +++ b/drivers/staging/rtl8723au/include/rtw_cmd.h @@ -35,9 +35,9 @@ struct cmd_obj { struct work_struct work; struct rtw_adapter *padapter; u16 cmdcode; - u8 res; - u8 *parmbuf; + int res; u32 cmdsz; + u8 *parmbuf; u8 *rsp; u32 rspsz; }; @@ -679,52 +679,52 @@ Result: #define H2C_CMD_OVERFLOW 0x06 #define H2C_RESERVED 0x07 -u8 rtw_setassocsta_cmd(struct rtw_adapter *padapter, u8 *mac_addr); -u8 rtw_setstandby_cmd(struct rtw_adapter *padapter, uint action); -u8 rtw_sitesurvey_cmd23a(struct rtw_adapter *padapter, struct cfg80211_ssid *ssid, int ssid_num, struct rtw_ieee80211_channel *ch, int ch_num); -u8 rtw_createbss_cmd23a(struct rtw_adapter *padapter); -u8 rtw_createbss_cmd23a_ex(struct rtw_adapter *padapter, unsigned char *pbss, unsigned int sz); -u8 rtw_setphy_cmd(struct rtw_adapter *padapter, u8 modem, u8 ch); -u8 rtw_setstakey_cmd23a(struct rtw_adapter *padapter, u8 *psta, u8 unicast_key); -u8 rtw_clearstakey_cmd23a(struct rtw_adapter *padapter, u8 *psta, u8 entry, u8 enqueue); -u8 rtw_joinbss_cmd23a(struct rtw_adapter *padapter, struct wlan_network* pnetwork); -u8 rtw_disassoc_cmd23a(struct rtw_adapter *padapter, u32 deauth_timeout_ms, bool enqueue); -u8 rtw_setopmode_cmd23a(struct rtw_adapter *padapter, enum ndis_802_11_net_infra networktype); -u8 rtw_setdatarate_cmd(struct rtw_adapter *padapter, u8 *rateset); -u8 rtw_setbasicrate_cmd(struct rtw_adapter *padapter, u8 *rateset); -u8 rtw_setbbreg_cmd(struct rtw_adapter * padapter, u8 offset, u8 val); -u8 rtw_setrfreg_cmd(struct rtw_adapter * padapter, u8 offset, u32 val); -u8 rtw_getbbreg_cmd(struct rtw_adapter * padapter, u8 offset, u8 * pval); -u8 rtw_getrfreg_cmd(struct rtw_adapter * padapter, u8 offset, u8 * pval); -u8 rtw_setrfintfs_cmd(struct rtw_adapter *padapter, u8 mode); -u8 rtw_setrttbl_cmd(struct rtw_adapter *padapter, struct setratable_parm *prate_table); -u8 rtw_getrttbl_cmd(struct rtw_adapter *padapter, struct getratable_rsp *pval); - -u8 rtw_gettssi_cmd(struct rtw_adapter *padapter, u8 offset,u8 *pval); -u8 rtw_setfwdig_cmd(struct rtw_adapter*padapter, u8 type); -u8 rtw_setfwra_cmd(struct rtw_adapter*padapter, u8 type); - -u8 rtw_addbareq_cmd23a(struct rtw_adapter*padapter, u8 tid, u8 *addr); - -u8 rtw_dynamic_chk_wk_cmd23a(struct rtw_adapter *adapter); - -u8 rtw_lps_ctrl_wk_cmd23a(struct rtw_adapter*padapter, u8 lps_ctrl_type, u8 enqueue); - -u8 rtw_ps_cmd23a(struct rtw_adapter*padapter); +int rtw_setassocsta_cmd(struct rtw_adapter *padapter, u8 *mac_addr); +int rtw_setstandby_cmd(struct rtw_adapter *padapter, uint action); +int rtw_sitesurvey_cmd23a(struct rtw_adapter *padapter, struct cfg80211_ssid *ssid, int ssid_num, struct rtw_ieee80211_channel *ch, int ch_num); +int rtw_createbss_cmd23a(struct rtw_adapter *padapter); +int rtw_createbss_cmd23a_ex(struct rtw_adapter *padapter, unsigned char *pbss, unsigned int sz); +int rtw_setphy_cmd(struct rtw_adapter *padapter, u8 modem, u8 ch); +int rtw_setstakey_cmd23a(struct rtw_adapter *padapter, u8 *psta, u8 unicast_key); +int rtw_clearstakey_cmd23a(struct rtw_adapter *padapter, u8 *psta, u8 entry, u8 enqueue); +int rtw_joinbss_cmd23a(struct rtw_adapter *padapter, struct wlan_network* pnetwork); +int rtw_disassoc_cmd23a(struct rtw_adapter *padapter, u32 deauth_timeout_ms, bool enqueue); +int rtw_setopmode_cmd23a(struct rtw_adapter *padapter, enum ndis_802_11_net_infra networktype); +int rtw_setdatarate_cmd(struct rtw_adapter *padapter, u8 *rateset); +int rtw_setbasicrate_cmd(struct rtw_adapter *padapter, u8 *rateset); +int rtw_setbbreg_cmd(struct rtw_adapter * padapter, u8 offset, u8 val); +int rtw_setrfreg_cmd(struct rtw_adapter * padapter, u8 offset, u32 val); +int rtw_getbbreg_cmd(struct rtw_adapter * padapter, u8 offset, u8 * pval); +int rtw_getrfreg_cmd(struct rtw_adapter * padapter, u8 offset, u8 * pval); +int rtw_setrfintfs_cmd(struct rtw_adapter *padapter, u8 mode); +int rtw_setrttbl_cmd(struct rtw_adapter *padapter, struct setratable_parm *prate_table); +int rtw_getrttbl_cmd(struct rtw_adapter *padapter, struct getratable_rsp *pval); + +int rtw_gettssi_cmd(struct rtw_adapter *padapter, u8 offset,u8 *pval); +int rtw_setfwdig_cmd(struct rtw_adapter*padapter, u8 type); +int rtw_setfwra_cmd(struct rtw_adapter*padapter, u8 type); + +int rtw_addbareq_cmd23a(struct rtw_adapter*padapter, u8 tid, u8 *addr); + +int rtw_dynamic_chk_wk_cmd23a(struct rtw_adapter *adapter); + +int rtw_lps_ctrl_wk_cmd23a(struct rtw_adapter*padapter, u8 lps_ctrl_type, u8 enqueue); + +int rtw_ps_cmd23a(struct rtw_adapter*padapter); #ifdef CONFIG_8723AU_AP_MODE -u8 rtw_chk_hi_queue_cmd23a(struct rtw_adapter*padapter); +int rtw_chk_hi_queue_cmd23a(struct rtw_adapter*padapter); #endif -u8 rtw_set_ch_cmd23a(struct rtw_adapter*padapter, u8 ch, u8 bw, u8 ch_offset, u8 enqueue); -u8 rtw_set_chplan_cmd(struct rtw_adapter*padapter, u8 chplan, u8 enqueue); -u8 rtw_led_blink_cmd(struct rtw_adapter*padapter, struct led_8723a *pLed); -u8 rtw_set_csa_cmd(struct rtw_adapter*padapter, u8 new_ch_no); -u8 rtw_tdls_cmd(struct rtw_adapter*padapter, u8 *addr, u8 option); +int rtw_set_ch_cmd23a(struct rtw_adapter*padapter, u8 ch, u8 bw, u8 ch_offset, u8 enqueue); +int rtw_set_chplan_cmd(struct rtw_adapter*padapter, u8 chplan, u8 enqueue); +int rtw_led_blink_cmd(struct rtw_adapter*padapter, struct led_8723a *pLed); +int rtw_set_csa_cmd(struct rtw_adapter*padapter, u8 new_ch_no); +int rtw_tdls_cmd(struct rtw_adapter*padapter, u8 *addr, u8 option); -u8 rtw_c2h_wk_cmd23a(struct rtw_adapter *padapter, u8 *c2h_evt); +int rtw_c2h_wk_cmd23a(struct rtw_adapter *padapter, u8 *c2h_evt); -u8 rtw_drvextra_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +int rtw_drvextra_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); void rtw_survey_cmd_callback23a(struct rtw_adapter *padapter, struct cmd_obj *pcmd); void rtw_disassoc_cmd23a_callback(struct rtw_adapter *padapter, struct cmd_obj *pcmd); diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index b2036998b61e..0148311fb69d 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -567,7 +567,7 @@ void report_del_sta_event23a(struct rtw_adapter *padapter, void report_add_sta_event23a(struct rtw_adapter *padapter, unsigned char *MacAddr, int cam_idx); -u8 set_tx_beacon_cmd23a(struct rtw_adapter*padapter); +int set_tx_beacon_cmd23a(struct rtw_adapter*padapter); unsigned int setup_beacon_frame(struct rtw_adapter *padapter, unsigned char *beacon_frame); void update_mgnt_tx_rate23a(struct rtw_adapter *padapter, u8 rate); @@ -637,39 +637,39 @@ void correct_TSF23a(struct rtw_adapter *padapter, struct mlme_ext_priv *pmlmeext struct cmd_hdl { uint parmsize; - u8 (*h2cfuns)(struct rtw_adapter *padapter, const u8 *pbuf); + int (*h2cfuns)(struct rtw_adapter *padapter, const u8 *pbuf); }; -u8 read_macreg_hdl(struct rtw_adapter *padapter, u8 *pbuf); -u8 write_macreg_hdl(struct rtw_adapter *padapter, u8 *pbuf); -u8 read_bbreg_hdl(struct rtw_adapter *padapter, u8 *pbuf); -u8 write_bbreg_hdl(struct rtw_adapter *padapter, u8 *pbuf); -u8 read_rfreg_hdl(struct rtw_adapter *padapter, u8 *pbuf); -u8 write_rfreg_hdl(struct rtw_adapter *padapter, u8 *pbuf); - - -u8 NULL_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); -u8 join_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); -u8 disconnect_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); -u8 createbss_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); -u8 setopmode_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); -u8 sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); -u8 setauth_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); -u8 setkey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); -u8 set_stakey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); -u8 set_assocsta_hdl(struct rtw_adapter *padapter, const u8 *pbuf); -u8 del_assocsta_hdl(struct rtw_adapter *padapter, const u8 *pbuf); -u8 add_ba_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); - -u8 mlme_evt_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); -u8 h2c_msg_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); -u8 tx_beacon_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); -u8 set_ch_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); -u8 set_chplan_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); -u8 led_blink_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); -u8 set_csa_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); /* Kurt: Handling DFS channel switch announcement ie. */ -u8 tdls_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +int read_macreg_hdl(struct rtw_adapter *padapter, u8 *pbuf); +int write_macreg_hdl(struct rtw_adapter *padapter, u8 *pbuf); +int read_bbreg_hdl(struct rtw_adapter *padapter, u8 *pbuf); +int write_bbreg_hdl(struct rtw_adapter *padapter, u8 *pbuf); +int read_rfreg_hdl(struct rtw_adapter *padapter, u8 *pbuf); +int write_rfreg_hdl(struct rtw_adapter *padapter, u8 *pbuf); + + +int NULL_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +int join_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +int disconnect_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +int createbss_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +int setopmode_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +int sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +int setauth_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +int setkey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +int set_stakey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +int set_assocsta_hdl(struct rtw_adapter *padapter, const u8 *pbuf); +int del_assocsta_hdl(struct rtw_adapter *padapter, const u8 *pbuf); +int add_ba_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); + +int mlme_evt_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +int h2c_msg_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +int tx_beacon_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +int set_ch_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +int set_chplan_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +int led_blink_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); +int set_csa_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); /* Kurt: Handling DFS channel switch announcement ie. */ +int tdls_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf); #define GEN_DRV_CMD_HANDLER(size, cmd) {size, &cmd ## _hdl23a}, #define GEN_MLME_EXT_HANDLER(size, cmd) {size, cmd}, -- cgit v1.2.3 From 44f3f16d8ba0d36c6fdc1ce5a3fe5ff288ff990b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:29 +0200 Subject: staging: rtl8723au: Clean up error code mess in rtw_efuse.c Use int to return error codes, and avoid mixing and matching true/false with _FAIL/_SUCCESS at random. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_efuse.c | 53 +++++++++++------------ drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 6 +-- drivers/staging/rtl8723au/include/rtw_efuse.h | 11 +++-- 3 files changed, 34 insertions(+), 36 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_efuse.c b/drivers/staging/rtl8723au/core/rtw_efuse.c index 8ba5166a2559..61fef36ab35a 100644 --- a/drivers/staging/rtl8723au/core/rtw_efuse.c +++ b/drivers/staging/rtl8723au/core/rtw_efuse.c @@ -403,11 +403,11 @@ EFUSE_Write1Byte( }/* EFUSE_Write1Byte */ /* 11/16/2008 MH Read one byte from real Efuse. */ -u8 +int efuse_OneByteRead23a(struct rtw_adapter *pAdapter, u16 addr, u8 *data) { u8 tmpidx = 0; - u8 bResult; + int bResult; /* -----------------e-fuse reg ctrl --------------------------------- */ /* address */ @@ -421,20 +421,20 @@ efuse_OneByteRead23a(struct rtw_adapter *pAdapter, u16 addr, u8 *data) tmpidx++; if (tmpidx < 100) { *data = rtw_read8(pAdapter, EFUSE_CTRL); - bResult = true; + bResult = _SUCCESS; } else { *data = 0xff; - bResult = false; + bResult = _FAIL; } return bResult; } /* 11/16/2008 MH Write one byte to reald Efuse. */ -u8 +int efuse_OneByteWrite23a(struct rtw_adapter *pAdapter, u16 addr, u8 data) { u8 tmpidx = 0; - u8 bResult; + int bResult; /* RT_TRACE(COMP_EFUSE, DBG_LOUD, ("Addr = %x Data =%x\n", addr, data)); */ @@ -453,14 +453,10 @@ efuse_OneByteWrite23a(struct rtw_adapter *pAdapter, u16 addr, u8 data) tmpidx++; } - if (tmpidx<100) - { - bResult = true; - } + if (tmpidx < 100) + bResult = _SUCCESS; else - { - bResult = false; - } + bResult = _FAIL; return bResult; } @@ -509,12 +505,12 @@ efuse_WordEnableDataRead23a(u8 word_en, } } -static u8 efuse_read8(struct rtw_adapter *padapter, u16 address, u8 *value) +static int efuse_read8(struct rtw_adapter *padapter, u16 address, u8 *value) { return efuse_OneByteRead23a(padapter, address, value); } -static u8 efuse_write8(struct rtw_adapter *padapter, u16 address, u8 *value) +static int efuse_write8(struct rtw_adapter *padapter, u16 address, u8 *value) { return efuse_OneByteWrite23a(padapter, address, *value); } @@ -522,13 +518,13 @@ static u8 efuse_write8(struct rtw_adapter *padapter, u16 address, u8 *value) /* * read/wirte raw efuse data */ -u8 rtw_efuse_access23a(struct rtw_adapter *padapter, u8 bWrite, u16 start_addr, - u16 cnts, u8 *data) +int rtw_efuse_access23a(struct rtw_adapter *padapter, u8 bWrite, u16 start_addr, + u16 cnts, u8 *data) { int i = 0; - u16 real_content_len = 0, max_available_size = 0; - u8 res = _FAIL ; - u8 (*rw8)(struct rtw_adapter *, u16, u8*); + u16 real_content_len = 0, max_available_size = 0; + int res = _FAIL ; + int (*rw8)(struct rtw_adapter *, u16, u8*); EFUSE_GetEfuseDefinition23a(padapter, EFUSE_WIFI, TYPE_EFUSE_REAL_CONTENT_LEN, @@ -557,7 +553,8 @@ u8 rtw_efuse_access23a(struct rtw_adapter *padapter, u8 bWrite, u16 start_addr, } res = rw8(padapter, start_addr++, data++); - if (_FAIL == res) break; + if (res == _FAIL) + break; } Efuse_PowerSwitch(padapter, bWrite, false); @@ -567,14 +564,14 @@ u8 rtw_efuse_access23a(struct rtw_adapter *padapter, u8 bWrite, u16 start_addr, /* */ u16 efuse_GetMaxSize23a(struct rtw_adapter *padapter) { - u16 max_size; + u16 max_size; EFUSE_GetEfuseDefinition23a(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_size); return max_size; } /* */ -u8 efuse_GetCurrentSize23a(struct rtw_adapter *padapter, u16 *size) +int efuse_GetCurrentSize23a(struct rtw_adapter *padapter, u16 *size) { Efuse_PowerSwitch(padapter, false, true); *size = Efuse_GetCurrentSize23a(padapter, EFUSE_WIFI); @@ -583,9 +580,10 @@ u8 efuse_GetCurrentSize23a(struct rtw_adapter *padapter, u16 *size) return _SUCCESS; } /* */ -u8 rtw_efuse_map_read23a(struct rtw_adapter *padapter, u16 addr, u16 cnts, u8 *data) +int rtw_efuse_map_read23a(struct rtw_adapter *padapter, + u16 addr, u16 cnts, u8 *data) { - u16 mapLen = 0; + u16 mapLen = 0; EFUSE_GetEfuseDefinition23a(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&mapLen); @@ -602,9 +600,10 @@ u8 rtw_efuse_map_read23a(struct rtw_adapter *padapter, u16 addr, u16 cnts, u8 *d return _SUCCESS; } -u8 rtw_BT_efuse_map_read23a(struct rtw_adapter *padapter, u16 addr, u16 cnts, u8 *data) +int rtw_BT_efuse_map_read23a(struct rtw_adapter *padapter, + u16 addr, u16 cnts, u8 *data) { - u16 mapLen = 0; + u16 mapLen = 0; EFUSE_GetEfuseDefinition23a(padapter, EFUSE_BT, TYPE_EFUSE_MAP_LEN, (void *)&mapLen); diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index ca122d0f80a6..3a9a96a2a5ea 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -703,7 +703,7 @@ u16 rtl8723a_EfuseGetCurrentSize_WiFi(struct rtw_adapter *padapter) while (AVAILABLE_EFUSE_ADDR(efuse_addr)) { if (efuse_OneByteRead23a(padapter, efuse_addr, &efuse_data) == - false) { + _FAIL) { DBG_8723A(KERN_ERR "%s: efuse_OneByteRead23a Fail! " "addr = 0x%X !!\n", __func__, efuse_addr); break; @@ -774,7 +774,7 @@ u16 rtl8723a_EfuseGetCurrentSize_BT(struct rtw_adapter *padapter) while (AVAILABLE_EFUSE_ADDR(efuse_addr)) { if (efuse_OneByteRead23a(padapter, efuse_addr, - &efuse_data) == false) { + &efuse_data) == _FAIL) { DBG_8723A(KERN_ERR "%s: efuse_OneByteRead23a Fail!" " addr = 0x%X !!\n", __func__, efuse_addr); @@ -851,7 +851,7 @@ rtl8723a_EfusePgPacketRead(struct rtw_adapter *padapter, u8 offset, u8 *data) /* */ while (AVAILABLE_EFUSE_ADDR(efuse_addr)) { if (efuse_OneByteRead23a(padapter, efuse_addr++, &efuse_data) == - false) { + _FAIL) { ret = false; break; } diff --git a/drivers/staging/rtl8723au/include/rtw_efuse.h b/drivers/staging/rtl8723au/include/rtw_efuse.h index a7755056163f..07bdc3464443 100644 --- a/drivers/staging/rtl8723au/include/rtw_efuse.h +++ b/drivers/staging/rtl8723au/include/rtw_efuse.h @@ -81,20 +81,19 @@ struct pg_pkt_struct { /*------------------------Export global variable----------------------------*/ -u8 efuse_GetCurrentSize23a(struct rtw_adapter *padapter, u16 *size); u16 efuse_GetMaxSize23a(struct rtw_adapter *padapter); -u8 rtw_efuse_access23a(struct rtw_adapter *padapter, u8 bRead, u16 start_addr, u16 cnts, u8 *data); -u8 rtw_efuse_map_read23a(struct rtw_adapter *padapter, u16 addr, u16 cnts, u8 *data); +int rtw_efuse_access23a(struct rtw_adapter *padapter, u8 bRead, u16 start_addr, u16 cnts, u8 *data); +int rtw_efuse_map_read23a(struct rtw_adapter *padapter, u16 addr, u16 cnts, u8 *data); u8 rtw_efuse_map_write(struct rtw_adapter *padapter, u16 addr, u16 cnts, u8 *data); -u8 rtw_BT_efuse_map_read23a(struct rtw_adapter *padapter, u16 addr, u16 cnts, u8 *data); +int rtw_BT_efuse_map_read23a(struct rtw_adapter *padapter, u16 addr, u16 cnts, u8 *data); u8 rtw_BT_efuse_map_write(struct rtw_adapter *padapter, u16 addr, u16 cnts, u8 *data); u16 Efuse_GetCurrentSize23a(struct rtw_adapter *pAdapter, u8 efuseType); u8 Efuse_CalculateWordCnts23a(u8 word_en); void ReadEFuseByte23a(struct rtw_adapter *Adapter, u16 _offset, u8 *pbuf); void EFUSE_GetEfuseDefinition23a(struct rtw_adapter *pAdapter, u8 efuseType, u8 type, void *pOut); -u8 efuse_OneByteRead23a(struct rtw_adapter *pAdapter, u16 addr, u8 *data); -u8 efuse_OneByteWrite23a(struct rtw_adapter *pAdapter, u16 addr, u8 data); +int efuse_OneByteRead23a(struct rtw_adapter *pAdapter, u16 addr, u8 *data); +int efuse_OneByteWrite23a(struct rtw_adapter *pAdapter, u16 addr, u8 data); void Efuse_PowerSwitch23a(struct rtw_adapter *pAdapter,u8 bWrite,u8 PwrState); int Efuse_PgPacketRead23a(struct rtw_adapter *pAdapter, u8 offset, u8 *data); -- cgit v1.2.3 From 828373f9968c650362ab1b48b5e7b5ddbb216b64 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:30 +0200 Subject: staging: rtl8723au: Remove unused rtw_is_wps_ie23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 19 ------------------- drivers/staging/rtl8723au/include/ieee80211.h | 1 - 2 files changed, 20 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index 98cd9905196e..78607fc5c862 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -721,25 +721,6 @@ int rtw_get_sec_ie23a(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, return *rsn_len + *wpa_len; } -u8 rtw_is_wps_ie23a(u8 *ie_ptr, uint *wps_ielen) -{ - u8 match = false; - u8 eid, wps_oui[4]= {0x0, 0x50, 0xf2, 0x04}; - - if (!ie_ptr) - return match; - - eid = ie_ptr[0]; - - if (eid == WLAN_EID_VENDOR_SPECIFIC && - !memcmp(&ie_ptr[2], wps_oui, 4)) { - /* DBG_8723A("==> found WPS_IE.....\n"); */ - *wps_ielen = ie_ptr[1] + 2; - match = true; - } - return match; -} - /** * rtw_get_wps_ie23a - Search WPS IE from a series of IEs * @in_ie: Address of IEs to search diff --git a/drivers/staging/rtl8723au/include/ieee80211.h b/drivers/staging/rtl8723au/include/ieee80211.h index e8072c4ee451..ef788b54b0b5 100644 --- a/drivers/staging/rtl8723au/include/ieee80211.h +++ b/drivers/staging/rtl8723au/include/ieee80211.h @@ -434,7 +434,6 @@ int rtw_parse_wpa2_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, in int rtw_get_sec_ie23a(u8 *in_ie,uint in_len,u8 *rsn_ie,u16 *rsn_len,u8 *wpa_ie,u16 *wpa_len); -u8 rtw_is_wps_ie23a(u8 *ie_ptr, uint *wps_ielen); u8 *rtw_get_wps_ie23a(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen); u8 *rtw_get_wps_attr23a(u8 *wps_ie, uint wps_ielen, u16 target_attr_id ,u8 *buf_attr, u32 *len_attr); u8 *rtw_get_wps_attr_content23a(u8 *wps_ie, uint wps_ielen, u16 target_attr_id ,u8 *buf_content, uint *len_content); -- cgit v1.2.3 From ad899b12192ef2fa0cf81a88a320d5a0de4d5151 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:31 +0200 Subject: staging: rtl8723au: Clean up error codes in IO functions This also fixes up another messy case assuming _FAIL == false and true == _SUCCESS Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_io.c | 10 +++++----- drivers/staging/rtl8723au/hal/usb_halinit.c | 10 +++++----- drivers/staging/rtl8723au/hal/usb_ops_linux.c | 8 ++++---- drivers/staging/rtl8723au/include/rtw_io.h | 21 +++++++++++++-------- drivers/staging/rtl8723au/include/usb_ops_linux.h | 2 +- drivers/staging/rtl8723au/os_dep/usb_ops_linux.c | 4 ++-- 6 files changed, 30 insertions(+), 25 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_io.c b/drivers/staging/rtl8723au/core/rtw_io.c index cf6d30f005b6..0dc0cf753462 100644 --- a/drivers/staging/rtl8723au/core/rtw_io.c +++ b/drivers/staging/rtl8723au/core/rtw_io.c @@ -139,7 +139,7 @@ void _rtw_write_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem) io_ops->_write_mem(adapter, addr, cnt, pmem); } -void _rtw_read_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, +int _rtw_read_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct recv_buf *rbuf) { struct _io_ops *io_ops = &adapter->io_ops; @@ -150,10 +150,10 @@ void _rtw_read_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, ("rtw_read_port:bDriverStopped(%d) OR " "bSurpriseRemoved(%d)", adapter->bDriverStopped, adapter->bSurpriseRemoved)); - return; + return _FAIL; } - io_ops->_read_port(adapter, addr, cnt, rbuf); + return io_ops->_read_port(adapter, addr, cnt, rbuf); } void _rtw_read_port23a_cancel(struct rtw_adapter *adapter) @@ -167,11 +167,11 @@ void _rtw_read_port23a_cancel(struct rtw_adapter *adapter) _read_port_cancel(adapter); } -u32 _rtw_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, +int _rtw_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct xmit_buf *xbuf) { struct _io_ops *io_ops = &adapter->io_ops; - u32 ret = _SUCCESS; + int ret = _SUCCESS; ret = io_ops->_write_port(adapter, addr, cnt, xbuf); diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index e345634ecb25..df2650712191 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1228,10 +1228,10 @@ int rtl8723au_inirp_init(struct rtw_adapter *Adapter) int status; struct _io_ops *io_ops = &Adapter->io_ops; struct recv_priv *precvpriv = &Adapter->recvpriv; - u32 (*_read_port)(struct rtw_adapter *padapter, u32 addr, u32 cnt, + int (*_read_port)(struct rtw_adapter *padapter, u32 addr, u32 cnt, struct recv_buf *rbuf); - u32 (*_read_interrupt)(struct rtw_adapter *padapter, u32 addr); - struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); + int (*_read_interrupt)(struct rtw_adapter *padapter, u32 addr); + struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); _read_port = io_ops->_read_port; @@ -1245,7 +1245,7 @@ int rtl8723au_inirp_init(struct rtw_adapter *Adapter) precvbuf = (struct recv_buf *)precvpriv->precv_buf; for (i = 0; i < NR_RECVBUFF; i++) { if (_read_port(Adapter, precvpriv->ff_hwaddr, 0, precvbuf) == - false) { + _FAIL) { RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("usb_rx_init: usb_read_port error\n")); status = _FAIL; @@ -1254,7 +1254,7 @@ int rtl8723au_inirp_init(struct rtw_adapter *Adapter) precvbuf++; } _read_interrupt = io_ops->_read_interrupt; - if (_read_interrupt(Adapter, RECV_INT_IN_ADDR) == false) { + if (_read_interrupt(Adapter, RECV_INT_IN_ADDR) == _FAIL) { RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("usb_rx_init: usb_read_interrupt error\n")); status = _FAIL; diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index 484006a5f338..4a83b138a8f5 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -439,11 +439,11 @@ urb_submit: } } -static u32 usb_read_interrupt(struct rtw_adapter *adapter, u32 addr) +static int usb_read_interrupt(struct rtw_adapter *adapter, u32 addr) { int err; unsigned int pipe; - u32 ret = _SUCCESS; + int ret = _SUCCESS; struct dvobj_priv *pdvobj = adapter_to_dvobj(adapter); struct recv_priv *precvpriv = &adapter->recvpriv; struct usb_device *pusbd = pdvobj->pusbdev; @@ -733,14 +733,14 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) } } -static u32 usb_read_port(struct rtw_adapter *adapter, u32 addr, u32 cnt, +static int usb_read_port(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct recv_buf *precvbuf) { int err; unsigned int pipe; unsigned long tmpaddr = 0; unsigned long alignment = 0; - u32 ret = _SUCCESS; + int ret = _SUCCESS; struct urb *purb = NULL; struct dvobj_priv *pdvobj = adapter_to_dvobj(adapter); struct recv_priv *precvpriv = &adapter->recvpriv; diff --git a/drivers/staging/rtl8723au/include/rtw_io.h b/drivers/staging/rtl8723au/include/rtw_io.h index fffe028750c2..2919dcca3882 100644 --- a/drivers/staging/rtl8723au/include/rtw_io.h +++ b/drivers/staging/rtl8723au/include/rtw_io.h @@ -107,15 +107,20 @@ struct _io_ops int (*_write8)(struct rtw_adapter *adapter, u32 addr, u8 val); int (*_write16)(struct rtw_adapter *adapter, u32 addr, u16 val); int (*_write32)(struct rtw_adapter *adapter, u32 addr, u32 val); - int (*_writeN)(struct rtw_adapter *adapter, u32 addr, u32 length, u8 *pdata); + int (*_writeN)(struct rtw_adapter *adapter, u32 addr, u32 length, + u8 *pdata); - void (*_read_mem)(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem); - void (*_write_mem)(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem); + void (*_read_mem)(struct rtw_adapter *adapter, u32 addr, u32 cnt, + u8 *pmem); + void (*_write_mem)(struct rtw_adapter *adapter, u32 addr, u32 cnt, + u8 *pmem); - u32 (*_read_interrupt)(struct rtw_adapter *adapter, u32 addr); + int (*_read_interrupt)(struct rtw_adapter *adapter, u32 addr); - u32 (*_read_port)(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct recv_buf *rbuf); - u32 (*_write_port)(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct xmit_buf *pmem); + int (*_read_port)(struct rtw_adapter *adapter, u32 addr, u32 cnt, + struct recv_buf *rbuf); + int (*_write_port)(struct rtw_adapter *adapter, u32 addr, u32 cnt, + struct xmit_buf *pmem); void (*_read_port_cancel)(struct rtw_adapter *adapter); void (*_write_port_cancel)(struct rtw_adapter *adapter); @@ -254,7 +259,7 @@ u8 _rtw_read823a(struct rtw_adapter *adapter, u32 addr); u16 _rtw_read1623a(struct rtw_adapter *adapter, u32 addr); u32 _rtw_read3223a(struct rtw_adapter *adapter, u32 addr); void _rtw_read_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem); -void _rtw_read_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct recv_buf *rbuf); +int _rtw_read_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct recv_buf *rbuf); void _rtw_read_port23a_cancel(struct rtw_adapter *adapter); int _rtw_write823a(struct rtw_adapter *adapter, u32 addr, u8 val); @@ -263,7 +268,7 @@ int _rtw_write3223a(struct rtw_adapter *adapter, u32 addr, u32 val); int _rtw_writeN23a(struct rtw_adapter *adapter, u32 addr, u32 length, u8 *pdata); void _rtw_write_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem); -u32 _rtw_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct xmit_buf *pmem); +int _rtw_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct xmit_buf *pmem); void _rtw_write_port23a_cancel(struct rtw_adapter *adapter); #ifdef DBG_IO diff --git a/drivers/staging/rtl8723au/include/usb_ops_linux.h b/drivers/staging/rtl8723au/include/usb_ops_linux.h index 0eb33e01c78c..92d5eb550c63 100644 --- a/drivers/staging/rtl8723au/include/usb_ops_linux.h +++ b/drivers/staging/rtl8723au/include/usb_ops_linux.h @@ -39,7 +39,7 @@ void usb_write_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *wmem); void usb_read_port_cancel23a(struct rtw_adapter *adapter); -u32 usb_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, +int usb_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct xmit_buf *wmem); void usb_write_port23a_cancel(struct rtw_adapter *adapter); diff --git a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c index b88f72f0f06b..b82dd89de886 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c @@ -160,7 +160,7 @@ check_completion: tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); } -u32 usb_write_port23a(struct rtw_adapter *padapter, u32 addr, u32 cnt, +int usb_write_port23a(struct rtw_adapter *padapter, u32 addr, u32 cnt, struct xmit_buf *pxmitbuf) { struct urb *purb = NULL; @@ -171,7 +171,7 @@ u32 usb_write_port23a(struct rtw_adapter *padapter, u32 addr, u32 cnt, unsigned long irqL; unsigned int pipe; int status; - u32 ret = _FAIL; + int ret = _FAIL; RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("+usb_write_port23a\n")); -- cgit v1.2.3 From 43eeb8ee53a22b7cc6a4139ce7173c6fc0794d73 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:32 +0200 Subject: staging: rtl8723au: Remove unused usb_read_mem/usb_write_mem stubs Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_io.c | 24 ----------------------- drivers/staging/rtl8723au/hal/usb_ops_linux.c | 2 -- drivers/staging/rtl8723au/include/rtw_io.h | 11 ----------- drivers/staging/rtl8723au/include/usb_ops_linux.h | 4 ---- drivers/staging/rtl8723au/os_dep/usb_ops_linux.c | 8 -------- 5 files changed, 49 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_io.c b/drivers/staging/rtl8723au/core/rtw_io.c index 0dc0cf753462..0f26ea8de216 100644 --- a/drivers/staging/rtl8723au/core/rtw_io.c +++ b/drivers/staging/rtl8723au/core/rtw_io.c @@ -27,8 +27,6 @@ Compiler Flag Option: 1. For USB: a. USE_ASYNC_IRP: Both sync/async operations are provided. -Only sync read/rtw_write_mem operations are provided. - jackson@realtek.com.tw */ @@ -116,28 +114,6 @@ int _rtw_writeN23a(struct rtw_adapter *adapter, u32 addr , u32 length , u8 *pdat else return _SUCCESS; } -void _rtw_read_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem) -{ - struct _io_ops *io_ops = &adapter->io_ops; - - if ((adapter->bDriverStopped == true) || - (adapter->bSurpriseRemoved == true)) { - RT_TRACE(_module_rtl871x_io_c_, _drv_info_, - ("rtw_read_mem:bDriverStopped(%d) OR " - "bSurpriseRemoved(%d)", adapter->bDriverStopped, - adapter->bSurpriseRemoved)); - return; - } - - io_ops->_read_mem(adapter, addr, cnt, pmem); -} - -void _rtw_write_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem) -{ - struct _io_ops *io_ops = &adapter->io_ops; - - io_ops->_write_mem(adapter, addr, cnt, pmem); -} int _rtw_read_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct recv_buf *rbuf) diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index 4a83b138a8f5..0a7fa0a9c9af 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -834,7 +834,6 @@ void rtl8723au_set_intf_ops(struct rtw_adapter *padapter) pops->_read8 = &usb_read8; pops->_read16 = &usb_read16; pops->_read32 = &usb_read32; - pops->_read_mem = &usb_read_mem23a; pops->_read_port = &usb_read_port; pops->_write8 = &usb_write8; @@ -842,7 +841,6 @@ void rtl8723au_set_intf_ops(struct rtw_adapter *padapter) pops->_write32 = &usb_write32; pops->_writeN = &usb_writeN; - pops->_write_mem = &usb_write_mem23a; pops->_write_port = &usb_write_port23a; pops->_read_port_cancel = &usb_read_port_cancel23a; diff --git a/drivers/staging/rtl8723au/include/rtw_io.h b/drivers/staging/rtl8723au/include/rtw_io.h index 2919dcca3882..f303213b42a7 100644 --- a/drivers/staging/rtl8723au/include/rtw_io.h +++ b/drivers/staging/rtl8723au/include/rtw_io.h @@ -110,11 +110,6 @@ struct _io_ops int (*_writeN)(struct rtw_adapter *adapter, u32 addr, u32 length, u8 *pdata); - void (*_read_mem)(struct rtw_adapter *adapter, u32 addr, u32 cnt, - u8 *pmem); - void (*_write_mem)(struct rtw_adapter *adapter, u32 addr, u32 cnt, - u8 *pmem); - int (*_read_interrupt)(struct rtw_adapter *adapter, u32 addr); int (*_read_port)(struct rtw_adapter *adapter, u32 addr, u32 cnt, @@ -258,7 +253,6 @@ void _rtw_attrib_write(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem) u8 _rtw_read823a(struct rtw_adapter *adapter, u32 addr); u16 _rtw_read1623a(struct rtw_adapter *adapter, u32 addr); u32 _rtw_read3223a(struct rtw_adapter *adapter, u32 addr); -void _rtw_read_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem); int _rtw_read_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct recv_buf *rbuf); void _rtw_read_port23a_cancel(struct rtw_adapter *adapter); @@ -267,7 +261,6 @@ int _rtw_write1623a(struct rtw_adapter *adapter, u32 addr, u16 val); int _rtw_write3223a(struct rtw_adapter *adapter, u32 addr, u32 val); int _rtw_writeN23a(struct rtw_adapter *adapter, u32 addr, u32 length, u8 *pdata); -void _rtw_write_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem); int _rtw_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct xmit_buf *pmem); void _rtw_write_port23a_cancel(struct rtw_adapter *adapter); @@ -287,7 +280,6 @@ int dbg_rtw_writeN23a(struct rtw_adapter *adapter, u32 addr ,u32 length , u8 *da #define rtw_read8(adapter, addr) dbg_rtw_read823a((adapter), (addr), __FUNCTION__, __LINE__) #define rtw_read16(adapter, addr) dbg_rtw_read1623a((adapter), (addr), __FUNCTION__, __LINE__) #define rtw_read32(adapter, addr) dbg_rtw_read3223a((adapter), (addr), __FUNCTION__, __LINE__) -#define rtw_read_mem(adapter, addr, cnt, mem) _rtw_read_mem23a((adapter), (addr), (cnt), (mem)) #define rtw_read_port(adapter, addr, cnt, mem) _rtw_read_port23a((adapter), (addr), (cnt), (mem)) #define rtw_read_port_cancel(adapter) _rtw_read_port23a_cancel((adapter)) @@ -296,14 +288,12 @@ int dbg_rtw_writeN23a(struct rtw_adapter *adapter, u32 addr ,u32 length , u8 *da #define rtw_write32(adapter, addr, val) dbg_rtw_write3223a((adapter), (addr), (val), __FUNCTION__, __LINE__) #define rtw_writeN(adapter, addr, length, data) dbg_rtw_writeN23a((adapter), (addr), (length), (data), __FUNCTION__, __LINE__) -#define rtw_write_mem(adapter, addr, cnt, mem) _rtw_write_mem23a((adapter), addr, cnt, mem) #define rtw_write_port(adapter, addr, cnt, mem) _rtw_write_port23a(adapter, addr, cnt, mem) #define rtw_write_port_cancel(adapter) _rtw_write_port23a_cancel(adapter) #else /* DBG_IO */ #define rtw_read8(adapter, addr) _rtw_read823a((adapter), (addr)) #define rtw_read16(adapter, addr) _rtw_read1623a((adapter), (addr)) #define rtw_read32(adapter, addr) _rtw_read3223a((adapter), (addr)) -#define rtw_read_mem(adapter, addr, cnt, mem) _rtw_read_mem23a((adapter), (addr), (cnt), (mem)) #define rtw_read_port(adapter, addr, cnt, mem) _rtw_read_port23a((adapter), (addr), (cnt), (mem)) #define rtw_read_port_cancel(adapter) _rtw_read_port23a_cancel((adapter)) @@ -312,7 +302,6 @@ int dbg_rtw_writeN23a(struct rtw_adapter *adapter, u32 addr ,u32 length , u8 *da #define rtw_write32(adapter, addr, val) _rtw_write3223a((adapter), (addr), (val)) #define rtw_writeN(adapter, addr, length, data) _rtw_writeN23a((adapter), (addr), (length), (data)) -#define rtw_write_mem(adapter, addr, cnt, mem) _rtw_write_mem23a((adapter), (addr), (cnt), (mem)) #define rtw_write_port(adapter, addr, cnt, mem) _rtw_write_port23a((adapter), (addr), (cnt), (mem)) #define rtw_write_port_cancel(adapter) _rtw_write_port23a_cancel((adapter)) #endif /* DBG_IO */ diff --git a/drivers/staging/rtl8723au/include/usb_ops_linux.h b/drivers/staging/rtl8723au/include/usb_ops_linux.h index 92d5eb550c63..814bc2005c05 100644 --- a/drivers/staging/rtl8723au/include/usb_ops_linux.h +++ b/drivers/staging/rtl8723au/include/usb_ops_linux.h @@ -26,7 +26,6 @@ #define _usbctrl_vendorreq_async_callback(urb, regs) \ _usbctrl_vendorreq_async_callback(urb) -#define usb_write_mem23a_complete(purb, regs) usb_write_mem23a_complete(purb) #define usb_write_port23a_complete(purb, regs) usb_write_port23a_complete(purb) #define usb_read_port_complete(purb, regs) usb_read_port_complete(purb) #define usb_read_interrupt_complete(purb, regs) \ @@ -34,9 +33,6 @@ unsigned int ffaddr2pipehdl23a(struct dvobj_priv *pdvobj, u32 addr); -void usb_read_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *rmem); -void usb_write_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *wmem); - void usb_read_port_cancel23a(struct rtw_adapter *adapter); int usb_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, diff --git a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c index b82dd89de886..cd38c78e2868 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c @@ -41,14 +41,6 @@ struct zero_bulkout_context { void *padapter; }; -void usb_read_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *rmem) -{ -} - -void usb_write_mem23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *wmem) -{ -} - void usb_read_port_cancel23a(struct rtw_adapter *padapter) { struct recv_buf *precvbuf; -- cgit v1.2.3 From 7e761c5a2ad625f3f73fa458ed2fac26611ffdfa Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:33 +0200 Subject: staging: rtl8723au: rtw_ioctl_set.c: Fix up messy error code handling Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ioctl_set.c | 46 ++++++++++------------- drivers/staging/rtl8723au/include/rtw_ioctl_set.h | 22 ++++++----- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 8 ++-- 3 files changed, 35 insertions(+), 41 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c index eb4aa925287a..a2dfb93b04eb 100644 --- a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c @@ -22,13 +22,13 @@ #include #include -u8 rtw_do_join23a(struct rtw_adapter *padapter) +int rtw_do_join23a(struct rtw_adapter *padapter) { struct list_head *plist, *phead; u8* pibss = NULL; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct rtw_queue *queue = &pmlmepriv->scanned_queue; - u8 ret = _SUCCESS; + int ret = _SUCCESS; spin_lock_bh(&pmlmepriv->scanned_queue.lock); phead = get_list_head(queue); @@ -151,9 +151,10 @@ exit: return ret; } -u8 rtw_set_802_11_ssid23a(struct rtw_adapter* padapter, struct cfg80211_ssid *ssid) +int rtw_set_802_11_ssid23a(struct rtw_adapter* padapter, + struct cfg80211_ssid *ssid) { - u8 status = _SUCCESS; + int status = _SUCCESS; u32 cur_time = 0; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -278,7 +279,7 @@ exit: return status; } -u8 rtw_set_802_11_infrastructure_mode23a(struct rtw_adapter* padapter, +int rtw_set_802_11_infrastructure_mode23a(struct rtw_adapter* padapter, enum ndis_802_11_net_infra networktype) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -361,25 +362,26 @@ u8 rtw_set_802_11_infrastructure_mode23a(struct rtw_adapter* padapter, spin_unlock_bh(&pmlmepriv->lock); } - return true; + return _SUCCESS; } -u8 rtw_set_802_11_bssid23a_list_scan(struct rtw_adapter *padapter, - struct cfg80211_ssid *pssid, int ssid_max_num) +int rtw_set_802_11_bssid23a_list_scan(struct rtw_adapter *padapter, + struct cfg80211_ssid *pssid, + int ssid_max_num) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - u8 res = true; + int res = _SUCCESS; RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("+rtw_set_802_11_bssid23a_list_scan(), fw_state =%x\n", get_fwstate(pmlmepriv))); if (!padapter) { - res = false; + res = _FAIL; goto exit; } if (padapter->hw_init_completed == false) { - res = false; + res = _FAIL; RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n === rtw_set_802_11_bssid23a_list_scan:" "hw_init_completed == false ===\n")); @@ -392,7 +394,6 @@ u8 rtw_set_802_11_bssid23a_list_scan(struct rtw_adapter *padapter, RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("rtw_set_802_11_bssid23a_list_scan fail since fw_state " "= %x\n", get_fwstate(pmlmepriv))); - res = true; if (check_fwstate(pmlmepriv, (_FW_UNDER_SURVEY|_FW_UNDER_LINKING))) { @@ -421,12 +422,11 @@ exit: return res; } -u8 rtw_set_802_11_authentication_mode23a(struct rtw_adapter* padapter, - enum ndis_802_11_auth_mode authmode) +int rtw_set_802_11_authentication_mode23a(struct rtw_adapter* padapter, + enum ndis_802_11_auth_mode authmode) { struct security_priv *psecuritypriv = &padapter->securitypriv; int res; - u8 ret; RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_802_11_auth.mode(): mode =%x\n", authmode)); @@ -443,22 +443,16 @@ u8 rtw_set_802_11_authentication_mode23a(struct rtw_adapter* padapter, res = rtw_set_auth23a(padapter, psecuritypriv); - if (res == _SUCCESS) - ret = true; - else - ret = false; - - return ret; + return res; } -u8 rtw_set_802_11_add_wep23a(struct rtw_adapter* padapter, +int rtw_set_802_11_add_wep23a(struct rtw_adapter* padapter, struct ndis_802_11_wep *wep) { u8 bdefaultkey; u8 btransmitkey; int keyid, res; struct security_priv *psecuritypriv = &padapter->securitypriv; - u8 ret = _SUCCESS; bdefaultkey = (wep->KeyIndex & 0x40000000) > 0 ? false : true; btransmitkey = (wep->KeyIndex & 0x80000000) > 0 ? true : false; @@ -467,7 +461,7 @@ u8 rtw_set_802_11_add_wep23a(struct rtw_adapter* padapter, if (keyid >= 4) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("MgntActrtw_set_802_11_add_wep23a:keyid>4 =>fail\n")); - ret = false; + res = _FAIL; goto exit; } @@ -522,11 +516,9 @@ u8 rtw_set_802_11_add_wep23a(struct rtw_adapter* padapter, res = rtw_set_key23a(padapter, psecuritypriv, keyid, 1); - if (res == _FAIL) - ret = false; exit: - return ret; + return res; } /* diff --git a/drivers/staging/rtl8723au/include/rtw_ioctl_set.h b/drivers/staging/rtl8723au/include/rtw_ioctl_set.h index e18820012edc..13f7fcb2a73a 100644 --- a/drivers/staging/rtl8723au/include/rtw_ioctl_set.h +++ b/drivers/staging/rtl8723au/include/rtw_ioctl_set.h @@ -17,18 +17,20 @@ #include -u8 rtw_set_802_11_authentication_mode23a(struct rtw_adapter *pdapter, - enum ndis_802_11_auth_mode authmode); -u8 rtw_set_802_11_add_wep23a(struct rtw_adapter * padapter, - struct ndis_802_11_wep *wep); -u8 rtw_set_802_11_bssid23a_list_scan(struct rtw_adapter *padapter, - struct cfg80211_ssid *pssid, int ssid_max_num); -u8 rtw_set_802_11_infrastructure_mode23a(struct rtw_adapter *padapter, - enum ndis_802_11_net_infra networktype); -u8 rtw_set_802_11_ssid23a(struct rtw_adapter * padapter, struct cfg80211_ssid * ssid); +int rtw_set_802_11_authentication_mode23a(struct rtw_adapter *pdapter, + enum ndis_802_11_auth_mode authmode); +int rtw_set_802_11_add_wep23a(struct rtw_adapter * padapter, + struct ndis_802_11_wep *wep); +int rtw_set_802_11_bssid23a_list_scan(struct rtw_adapter *padapter, + struct cfg80211_ssid *pssid, + int ssid_max_num); +int rtw_set_802_11_infrastructure_mode23a(struct rtw_adapter *padapter, + enum ndis_802_11_net_infra networktype); +int rtw_set_802_11_ssid23a(struct rtw_adapter * padapter, + struct cfg80211_ssid * ssid); u16 rtw_get_cur_max_rate23a(struct rtw_adapter *adapter); s32 FillH2CCmd(struct rtw_adapter *padapter, u8 ElementID, u32 CmdLen, u8 *pCmdBuffer); -u8 rtw_do_join23a(struct rtw_adapter *padapter); +int rtw_do_join23a(struct rtw_adapter *padapter); #endif diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 53cec46763f0..627d75c1b329 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -1343,7 +1343,8 @@ static int cfg80211_rtw_change_iface(struct wiphy *wiphy, rtw_wdev->iftype = type; - if (rtw_set_802_11_infrastructure_mode23a(padapter, networkType) == false) { + if (rtw_set_802_11_infrastructure_mode23a + (padapter, networkType) != _SUCCESS) { rtw_wdev->iftype = old_type; ret = -EPERM; goto exit; @@ -1982,7 +1983,7 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, } if (rtw_set_802_11_infrastructure_mode23a - (padapter, pnetwork->network.InfrastructureMode) == false) { + (padapter, pnetwork->network.InfrastructureMode) != _SUCCESS) { ret = -EPERM; goto exit; } @@ -2069,9 +2070,8 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, memcpy(pwep->KeyMaterial, (void *)sme->key, pwep->KeyLength); - if (rtw_set_802_11_add_wep23a(padapter, pwep) == (u8) _FAIL) { + if (rtw_set_802_11_add_wep23a(padapter, pwep) != _SUCCESS) ret = -EOPNOTSUPP; - } kfree(pwep); -- cgit v1.2.3 From f66e05d8fc10c939180df08eafe969675dc72a11 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:34 +0200 Subject: staging: rtl8723au: rtw_mlme_ext.c: Use int to return error codes Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 31 ++++++++++++------------ drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 14 +++++------ 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 91164036da73..9f9facd4a28a 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -2065,7 +2065,7 @@ static int OnAction23a_back23a(struct rtw_adapter *padapter, return _SUCCESS; } -static s32 rtw_action_public_decache(struct recv_frame *recv_frame, s32 token) +static int rtw_action_public_decache(struct recv_frame *recv_frame, s32 token) { struct rtw_adapter *adapter = recv_frame->adapter; struct mlme_ext_priv *mlmeext = &adapter->mlmeextpriv; @@ -2105,7 +2105,7 @@ static s32 rtw_action_public_decache(struct recv_frame *recv_frame, s32 token) return _SUCCESS; } -static unsigned int on_action_public23a_p2p(struct recv_frame *precv_frame) +static int on_action_public23a_p2p(struct recv_frame *precv_frame) { struct sk_buff *skb = precv_frame->pkt; u8 *pframe = skb->data; @@ -2123,7 +2123,7 @@ static unsigned int on_action_public23a_p2p(struct recv_frame *precv_frame) return _SUCCESS; } -static unsigned int on_action_public23a_vendor(struct recv_frame *precv_frame) +static int on_action_public23a_vendor(struct recv_frame *precv_frame) { unsigned int ret = _FAIL; struct sk_buff *skb = precv_frame->pkt; @@ -2168,7 +2168,7 @@ exit: static int on_action_public23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { - unsigned int ret = _FAIL; + int ret = _FAIL; struct sk_buff *skb = precv_frame->pkt; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; u8 *pframe = skb->data; @@ -2332,10 +2332,10 @@ void dump_mgntframe23a(struct rtw_adapter *padapter, rtl8723au_mgnt_xmit(padapter, pmgntframe); } -s32 dump_mgntframe23a_and_wait(struct rtw_adapter *padapter, +int dump_mgntframe23a_and_wait(struct rtw_adapter *padapter, struct xmit_frame *pmgntframe, int timeout_ms) { - s32 ret = _FAIL; + int ret = _FAIL; unsigned long irqL; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct xmit_buf *pxmitbuf = pmgntframe->pxmitbuf; @@ -2360,16 +2360,16 @@ s32 dump_mgntframe23a_and_wait(struct rtw_adapter *padapter, return ret; } -s32 dump_mgntframe23a_and_wait_ack23a(struct rtw_adapter *padapter, +int dump_mgntframe23a_and_wait_ack23a(struct rtw_adapter *padapter, struct xmit_frame *pmgntframe) { - s32 ret = _FAIL; + int ret = _FAIL; u32 timeout_ms = 500;/* 500ms */ struct xmit_priv *pxmitpriv = &padapter->xmitpriv; if (padapter->bSurpriseRemoved == true || padapter->bDriverStopped == true) - return -1; + return _FAIL; mutex_lock(&pxmitpriv->ack_tx_mutex); pxmitpriv->ack_tx = true; @@ -4278,7 +4278,7 @@ out: dump_mgntframe23a(padapter, pmgntframe); } -unsigned int send_delba23a(struct rtw_adapter *padapter, u8 initiator, u8 *addr) +int send_delba23a(struct rtw_adapter *padapter, u8 initiator, u8 *addr) { struct sta_priv *pstapriv = &padapter->stapriv; struct sta_info *psta = NULL; @@ -4318,7 +4318,7 @@ unsigned int send_delba23a(struct rtw_adapter *padapter, u8 initiator, u8 *addr) return _SUCCESS; } -unsigned int send_beacon23a(struct rtw_adapter *padapter) +int send_beacon23a(struct rtw_adapter *padapter) { bool bxmitok; int issue = 0; @@ -4464,9 +4464,9 @@ void site_survey23a(struct rtw_adapter *padapter) } /* collect bss info from Beacon and Probe request/response frames. */ -u8 collect_bss_info23a(struct rtw_adapter *padapter, - struct recv_frame *precv_frame, - struct wlan_bssid_ex *bssid) +int collect_bss_info23a(struct rtw_adapter *padapter, + struct recv_frame *precv_frame, + struct wlan_bssid_ex *bssid) { int i; const u8 *p; @@ -4808,7 +4808,8 @@ void start_clnt_assoc23a(struct rtw_adapter* padapter) set_link_timer(pmlmeext, REASSOC_TO); } -unsigned int receive_disconnect23a(struct rtw_adapter *padapter, unsigned char *MacAddr, unsigned short reason) +int receive_disconnect23a(struct rtw_adapter *padapter, + unsigned char *MacAddr, unsigned short reason) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 0148311fb69d..2d56c34c6cfe 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -498,9 +498,9 @@ void flush_all_cam_entry23a(struct rtw_adapter *padapter); bool IsLegal5GChannel(struct rtw_adapter *Adapter, u8 channel); void site_survey23a(struct rtw_adapter *padapter); -u8 collect_bss_info23a(struct rtw_adapter *padapter, - struct recv_frame *precv_frame, - struct wlan_bssid_ex *bssid); +int collect_bss_info23a(struct rtw_adapter *padapter, + struct recv_frame *precv_frame, + struct wlan_bssid_ex *bssid); void update_network23a(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, struct rtw_adapter *padapter, bool update_ie); @@ -548,8 +548,8 @@ unsigned int update_MSC_rate23a(struct HT_caps_element *pHT_caps); void Update_RA_Entry23a(struct rtw_adapter *padapter, struct sta_info *psta); void set_sta_rate23a(struct rtw_adapter *padapter, struct sta_info *psta); -unsigned int receive_disconnect23a(struct rtw_adapter *padapter, - unsigned char *MacAddr, unsigned short reason); +int receive_disconnect23a(struct rtw_adapter *padapter, + unsigned char *MacAddr, unsigned short reason); unsigned char get_highest_rate_idx23a(u32 mask); int support_short_GI23a(struct rtw_adapter *padapter, @@ -605,8 +605,8 @@ void issue_action_spct_ch_switch23a(struct rtw_adapter *padapter, u8 *ra, void issue_action_BA23a(struct rtw_adapter *padapter, const unsigned char *raddr, unsigned char action, unsigned short status); -unsigned int send_delba23a(struct rtw_adapter *padapter, u8 initiator, u8 *addr); -unsigned int send_beacon23a(struct rtw_adapter *padapter); +int send_delba23a(struct rtw_adapter *padapter, u8 initiator, u8 *addr); +int send_beacon23a(struct rtw_adapter *padapter); void start_clnt_assoc23a(struct rtw_adapter *padapter); void start_clnt_auth23a(struct rtw_adapter *padapter); -- cgit v1.2.3 From d5789247bb65d00d35d10f2bc604341cd7080bab Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:35 +0200 Subject: staging: rtl8723au: Don't return true/false in unsigned int Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 6 +++--- drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 6dc7d068b6bd..efdd0dd18036 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -1166,7 +1166,7 @@ void update_beacon23a_info(struct rtw_adapter *padapter, u8 *pframe, uint pkt_le } } -unsigned int is_ap_in_tkip23a(struct rtw_adapter *padapter) +bool is_ap_in_tkip23a(struct rtw_adapter *padapter) { u32 i; struct ndis_802_11_var_ies *pIE; @@ -1201,7 +1201,7 @@ unsigned int is_ap_in_tkip23a(struct rtw_adapter *padapter) return false; } -unsigned int should_forbid_n_rate23a(struct rtw_adapter * padapter) +bool should_forbid_n_rate23a(struct rtw_adapter * padapter) { u32 i; struct ndis_802_11_var_ies *pIE; @@ -1241,7 +1241,7 @@ unsigned int should_forbid_n_rate23a(struct rtw_adapter * padapter) } } -unsigned int is_ap_in_wep23a(struct rtw_adapter *padapter) +bool is_ap_in_wep23a(struct rtw_adapter *padapter) { u32 i; struct ndis_802_11_var_ies *pIE; diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 2d56c34c6cfe..80e093fea272 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -554,9 +554,9 @@ int receive_disconnect23a(struct rtw_adapter *padapter, unsigned char get_highest_rate_idx23a(u32 mask); int support_short_GI23a(struct rtw_adapter *padapter, struct HT_caps_element *pHT_caps); -unsigned int is_ap_in_tkip23a(struct rtw_adapter *padapter); -unsigned int is_ap_in_wep23a(struct rtw_adapter *padapter); -unsigned int should_forbid_n_rate23a(struct rtw_adapter *padapter); +bool is_ap_in_tkip23a(struct rtw_adapter *padapter); +bool is_ap_in_wep23a(struct rtw_adapter *padapter); +bool should_forbid_n_rate23a(struct rtw_adapter *padapter); void report_join_res23a(struct rtw_adapter *padapter, int res); void report_survey_event23a(struct rtw_adapter *padapter, -- cgit v1.2.3 From 696324803396e6cc3f4b849d48fc3d4a9c20b289 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:36 +0200 Subject: staging: rtl8723au: decryptor() use int to store error codes Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_recv.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 19b58cae8c42..eda495a1d5d8 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -476,8 +476,7 @@ struct recv_frame *decryptor(struct rtw_adapter *padapter, struct rx_pkt_attrib *prxattrib = &precv_frame->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; struct recv_frame *return_packet = precv_frame; - u32 res = _SUCCESS; - + int res = _SUCCESS; RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("prxstat->decrypted =%x prxattrib->encrypt = 0x%03x\n", -- cgit v1.2.3 From 75f3f039563c85e6dc89e937e253051a07336348 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:37 +0200 Subject: staging: rtl8723au: rtw_security.c: Clean up mess of error return code types Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_security.c | 26 ++++++++++++------------ drivers/staging/rtl8723au/include/rtw_security.h | 8 ++++---- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_security.c b/drivers/staging/rtl8723au/core/rtw_security.c index fd43e71bf6d6..77709fea856c 100644 --- a/drivers/staging/rtl8723au/core/rtw_security.c +++ b/drivers/staging/rtl8723au/core/rtw_security.c @@ -610,9 +610,9 @@ static void phase2(u8 *rc4key, const u8 *tk, const u16 *p1k, u16 iv16) } /* The hlen isn't include the IV */ -u32 rtw_tkip_encrypt23a(struct rtw_adapter *padapter, - struct xmit_frame *pxmitframe) -{ /* exclude ICV */ +int rtw_tkip_encrypt23a(struct rtw_adapter *padapter, + struct xmit_frame *pxmitframe) +{ u16 pnl; u32 pnh; u8 rc4key[16]; @@ -622,14 +622,13 @@ u32 rtw_tkip_encrypt23a(struct rtw_adapter *padapter, struct arc4context mycontext; int curfragnum, length; u32 prwskeylen; - u8 *pframe, *payload,*iv,*prwskey; union pn48 dot11txpn; struct sta_info *stainfo; struct pkt_attrib *pattrib = &pxmitframe->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - u32 res = _SUCCESS; + int res = _SUCCESS; if (!pxmitframe->buf_addr) return _FAIL; @@ -716,10 +715,9 @@ u32 rtw_tkip_encrypt23a(struct rtw_adapter *padapter, } /* The hlen isn't include the IV */ -u32 rtw_tkip_decrypt23a(struct rtw_adapter *padapter, - struct recv_frame *precvframe) +int rtw_tkip_decrypt23a(struct rtw_adapter *padapter, + struct recv_frame *precvframe) { - /* exclude ICV */ u16 pnl; u32 pnh; u8 rc4key[16]; @@ -734,7 +732,7 @@ u32 rtw_tkip_decrypt23a(struct rtw_adapter *padapter, struct rx_pkt_attrib *prxattrib = &precvframe->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; struct sk_buff * skb = precvframe->pkt; - u32 res = _SUCCESS; + int res = _SUCCESS; pframe = skb->data; @@ -1303,7 +1301,8 @@ static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen) return _SUCCESS; } -u32 rtw_aes_encrypt23a(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe) +int rtw_aes_encrypt23a(struct rtw_adapter *padapter, + struct xmit_frame *pxmitframe) { /* exclude ICV */ /* Intermediate Buffers */ int curfragnum, length; @@ -1314,7 +1313,7 @@ u32 rtw_aes_encrypt23a(struct rtw_adapter *padapter, struct xmit_frame *pxmitfra struct pkt_attrib *pattrib = &pxmitframe->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - u32 res = _SUCCESS; + int res = _SUCCESS; if (!pxmitframe->buf_addr) return _FAIL; @@ -1586,7 +1585,8 @@ static int aes_decipher(u8 *key, uint hdrlen, return res; } -u32 rtw_aes_decrypt23a(struct rtw_adapter *padapter, struct recv_frame *precvframe) +int rtw_aes_decrypt23a(struct rtw_adapter *padapter, + struct recv_frame *precvframe) { /* exclude ICV */ struct sta_info *stainfo; struct rx_pkt_attrib *prxattrib = &precvframe->attrib; @@ -1594,7 +1594,7 @@ u32 rtw_aes_decrypt23a(struct rtw_adapter *padapter, struct recv_frame *precvfra struct sk_buff *skb = precvframe->pkt; int length; u8 *pframe, *prwskey; /* *payload,*iv */ - u32 res = _SUCCESS; + int res = _SUCCESS; pframe = skb->data; /* 4 start to encrypt each fragment */ diff --git a/drivers/staging/rtl8723au/include/rtw_security.h b/drivers/staging/rtl8723au/include/rtw_security.h index 702dd845a3ff..e9e850616359 100644 --- a/drivers/staging/rtl8723au/include/rtw_security.h +++ b/drivers/staging/rtl8723au/include/rtw_security.h @@ -323,15 +323,15 @@ void rtw_secgetmic23a(struct mic_data *pmicdata, u8 *dst); void rtw_seccalctkipmic23a(u8 *key, u8 *header, u8 *data, u32 data_len, u8 *Miccode, u8 priorityi); -u32 rtw_aes_encrypt23a(struct rtw_adapter *padapter, +int rtw_aes_encrypt23a(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe); -u32 rtw_tkip_encrypt23a(struct rtw_adapter *padapter, +int rtw_tkip_encrypt23a(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe); void rtw_wep_encrypt23a(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe); -u32 rtw_aes_decrypt23a(struct rtw_adapter *padapter, +int rtw_aes_decrypt23a(struct rtw_adapter *padapter, struct recv_frame *precvframe); -u32 rtw_tkip_decrypt23a(struct rtw_adapter *padapter, +int rtw_tkip_decrypt23a(struct rtw_adapter *padapter, struct recv_frame *precvframe); void rtw_wep_decrypt23a(struct rtw_adapter *padapter, struct recv_frame *precvframe); -- cgit v1.2.3 From 95ddd22553b82be0f92f277744c33c88897afabc Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:38 +0200 Subject: staging: rtl8723au: rtw_sta_mgt.c: Clean up messy usage of return types Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_sta_mgt.c | 18 +++++++++--------- drivers/staging/rtl8723au/include/sta_info.h | 10 +++++----- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c index 148bb4a2de2f..f65d6d72624b 100644 --- a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c @@ -49,7 +49,7 @@ static void _rtw_init_stainfo(struct sta_info *psta) #endif /* CONFIG_8723AU_AP_MODE */ } -u32 _rtw_init_sta_priv23a(struct sta_priv *pstapriv) +int _rtw_init_sta_priv23a(struct sta_priv *pstapriv) { int i; @@ -77,12 +77,12 @@ u32 _rtw_init_sta_priv23a(struct sta_priv *pstapriv) return _SUCCESS; } -u32 _rtw_free_sta_priv23a(struct sta_priv *pstapriv) +int _rtw_free_sta_priv23a(struct sta_priv *pstapriv) { struct list_head *phead, *plist, *ptmp; struct sta_info *psta; struct recv_reorder_ctrl *preorder_ctrl; - int index; + int index; if (pstapriv) { /* delete all reordering_ctrl_timer */ @@ -186,7 +186,7 @@ exit: } /* using pstapriv->sta_hash_lock to protect */ -u32 rtw_free_stainfo23a(struct rtw_adapter *padapter, struct sta_info *psta) +int rtw_free_stainfo23a(struct rtw_adapter *padapter, struct sta_info *psta) { struct recv_reorder_ctrl *preorder_ctrl; struct sta_xmit_priv *pstaxmitpriv; @@ -373,12 +373,12 @@ struct sta_info *rtw_get_stainfo23a(struct sta_priv *pstapriv, const u8 *hwaddr) return psta; } -u32 rtw_init_bcmc_stainfo23a(struct rtw_adapter* padapter) +int rtw_init_bcmc_stainfo23a(struct rtw_adapter* padapter) { struct sta_priv *pstapriv = &padapter->stapriv; struct sta_info *psta; struct tx_servq *ptxservq; - u32 res = _SUCCESS; + int res = _SUCCESS; unsigned char bcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; psta = rtw_alloc_stainfo23a(pstapriv, bcast_addr, GFP_KERNEL); @@ -405,13 +405,13 @@ struct sta_info *rtw_get_bcmc_stainfo23a(struct rtw_adapter *padapter) return psta; } -u8 rtw_access_ctrl23a(struct rtw_adapter *padapter, u8 *mac_addr) +bool rtw_access_ctrl23a(struct rtw_adapter *padapter, u8 *mac_addr) { - u8 res = true; + bool res = true; #ifdef CONFIG_8723AU_AP_MODE struct list_head *plist, *phead; struct rtw_wlan_acl_node *paclnode; - u8 match = false; + bool match = false; struct sta_priv *pstapriv = &padapter->stapriv; struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; struct rtw_queue *pacl_node_q = &pacl_list->acl_node_q; diff --git a/drivers/staging/rtl8723au/include/sta_info.h b/drivers/staging/rtl8723au/include/sta_info.h index 10d933e0939b..747e7db2113e 100644 --- a/drivers/staging/rtl8723au/include/sta_info.h +++ b/drivers/staging/rtl8723au/include/sta_info.h @@ -359,15 +359,15 @@ static inline u32 wifi_mac_hash(const u8 *mac) return x; } -u32 _rtw_init_sta_priv23a(struct sta_priv *pstapriv); -u32 _rtw_free_sta_priv23a(struct sta_priv *pstapriv); +int _rtw_init_sta_priv23a(struct sta_priv *pstapriv); +int _rtw_free_sta_priv23a(struct sta_priv *pstapriv); struct sta_info *rtw_alloc_stainfo23a(struct sta_priv *pstapriv, u8 *hwaddr, int gfp); -u32 rtw_free_stainfo23a(struct rtw_adapter *padapter, struct sta_info *psta); +int rtw_free_stainfo23a(struct rtw_adapter *padapter, struct sta_info *psta); void rtw_free_all_stainfo23a(struct rtw_adapter *padapter); struct sta_info *rtw_get_stainfo23a(struct sta_priv *pstapriv, const u8 *hwaddr); -u32 rtw_init_bcmc_stainfo23a(struct rtw_adapter *padapter); +int rtw_init_bcmc_stainfo23a(struct rtw_adapter *padapter); struct sta_info *rtw_get_bcmc_stainfo23a(struct rtw_adapter *padapter); -u8 rtw_access_ctrl23a(struct rtw_adapter *padapter, u8 *mac_addr); +bool rtw_access_ctrl23a(struct rtw_adapter *padapter, u8 *mac_addr); #endif /* _STA_INFO_H_ */ -- cgit v1.2.3 From f6fe0a414b40a5d9413be81d7084cff69dd97193 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:39 +0200 Subject: staging: rtl8723au: rtw_wlan_util.c: Fix up random mixing of bool vs int Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 14 +++++++------- drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index efdd0dd18036..c4c47164b990 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -415,13 +415,13 @@ u16 get_beacon_interval23a(struct wlan_bssid_ex *bss) return le16_to_cpu(val); } -int is_client_associated_to_ap23a(struct rtw_adapter *padapter) +bool is_client_associated_to_ap23a(struct rtw_adapter *padapter) { struct mlme_ext_priv *pmlmeext; struct mlme_ext_info *pmlmeinfo; if (!padapter) - return _FAIL; + return false; pmlmeext = &padapter->mlmeextpriv; pmlmeinfo = &pmlmeext->mlmext_info; @@ -430,10 +430,10 @@ int is_client_associated_to_ap23a(struct rtw_adapter *padapter) (pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) return true; else - return _FAIL; + return false; } -int is_client_associated_to_ibss23a(struct rtw_adapter *padapter) +bool is_client_associated_to_ibss23a(struct rtw_adapter *padapter) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -442,10 +442,10 @@ int is_client_associated_to_ibss23a(struct rtw_adapter *padapter) (pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) return true; else - return _FAIL; + return false; } -int is_IBSS_empty23a(struct rtw_adapter *padapter) +bool is_IBSS_empty23a(struct rtw_adapter *padapter) { unsigned int i; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -453,7 +453,7 @@ int is_IBSS_empty23a(struct rtw_adapter *padapter) for (i = IBSS_START_MAC_ID; i < NUM_STA; i++) { if (pmlmeinfo->FW_sta_info[i].status == 1) - return _FAIL; + return false; } return true; diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 80e093fea272..346ee16ca248 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -508,9 +508,9 @@ int get_bsstype23a(unsigned short capability); u8 *get_my_bssid23a(struct wlan_bssid_ex *pnetwork); u16 get_beacon_interval23a(struct wlan_bssid_ex *bss); -int is_client_associated_to_ap23a(struct rtw_adapter *padapter); -int is_client_associated_to_ibss23a(struct rtw_adapter *padapter); -int is_IBSS_empty23a(struct rtw_adapter *padapter); +bool is_client_associated_to_ap23a(struct rtw_adapter *padapter); +bool is_client_associated_to_ibss23a(struct rtw_adapter *padapter); +bool is_IBSS_empty23a(struct rtw_adapter *padapter); unsigned char check_assoc_AP23a(u8 *pframe, uint len); -- cgit v1.2.3 From 8fd873d93d3f6d2331a96531a3211eb8d7133280 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:40 +0200 Subject: staging: rtl8723au: rtw_xmit.c: Be consistent in using int for error return type Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 05803c6c71fb..65e7de8de916 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -424,7 +424,7 @@ static void set_qos(struct sk_buff *skb, struct pkt_attrib *pattrib) pattrib->subtype = WIFI_QOS_DATA_TYPE; } -static s32 update_attrib(struct rtw_adapter *padapter, +static int update_attrib(struct rtw_adapter *padapter, struct sk_buff *skb, struct pkt_attrib *pattrib) { struct sta_info *psta = NULL; @@ -647,7 +647,7 @@ exit: return res; } -static s32 xmitframe_addmic(struct rtw_adapter *padapter, +static int xmitframe_addmic(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe) { struct mic_data micdata; struct sta_info *stainfo; @@ -823,7 +823,7 @@ static s32 xmitframe_addmic(struct rtw_adapter *padapter, return _SUCCESS; } -static s32 xmitframe_swencrypt(struct rtw_adapter *padapter, +static int xmitframe_swencrypt(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe) { struct pkt_attrib *pattrib = &pxmitframe->attrib; @@ -856,7 +856,7 @@ static s32 xmitframe_swencrypt(struct rtw_adapter *padapter, return _SUCCESS; } -s32 rtw_make_wlanhdr23a(struct rtw_adapter *padapter, u8 *hdr, +int rtw_make_wlanhdr23a(struct rtw_adapter *padapter, u8 *hdr, struct pkt_attrib *pattrib) { u16 *qc; @@ -1070,7 +1070,7 @@ This sub-routine will perform all the following: 6. apply sw-encrypt, if necessary. */ -s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *skb, +int rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *skb, struct xmit_frame *pxmitframe) { struct sta_info *psta; @@ -1083,7 +1083,7 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *skb, u8 *pdata = skb->data; int data_len = skb->len; s32 bmcst = is_multicast_ether_addr(pattrib->ra); - s32 res = _SUCCESS; + int res = _SUCCESS; if (pattrib->psta) psta = pattrib->psta; @@ -1363,7 +1363,8 @@ struct xmit_buf *rtw_alloc_xmitbuf23a_ext(struct xmit_priv *pxmitpriv) return pxmitbuf; } -s32 rtw_free_xmitbuf_ext23a(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) +int rtw_free_xmitbuf_ext23a(struct xmit_priv *pxmitpriv, + struct xmit_buf *pxmitbuf) { unsigned long irqL; struct rtw_queue *pfree_queue = &pxmitpriv->free_xmit_extbuf_queue; @@ -1417,7 +1418,7 @@ struct xmit_buf *rtw_alloc_xmitbuf23a(struct xmit_priv *pxmitpriv) return pxmitbuf; } -s32 rtw_free_xmitbuf23a(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) +int rtw_free_xmitbuf23a(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) { unsigned long irqL; struct rtw_queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue; @@ -1607,7 +1608,7 @@ void rtw_free_xmitframe_queue23a(struct xmit_priv *pxmitpriv, } -s32 rtw_xmitframe_enqueue23a(struct rtw_adapter *padapter, +int rtw_xmitframe_enqueue23a(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe) { if (rtw_xmit23a_classifier(padapter, pxmitframe) == _FAIL) { @@ -1731,8 +1732,8 @@ struct tx_servq *rtw_get_sta_pending23a(struct rtw_adapter *padapter, struct sta * Will enqueue pxmitframe to the proper queue, * and indicate it to xx_pending list..... */ -s32 rtw_xmit23a_classifier(struct rtw_adapter *padapter, - struct xmit_frame *pxmitframe) +int rtw_xmit23a_classifier(struct rtw_adapter *padapter, + struct xmit_frame *pxmitframe) { struct sta_info *psta; struct tx_servq *ptxservq; @@ -1909,7 +1910,7 @@ int rtw_xmit23a(struct rtw_adapter *padapter, struct sk_buff *skb) { struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct xmit_frame *pxmitframe = NULL; - s32 res; + int res; pxmitframe = rtw_alloc_xmitframe(pxmitpriv); @@ -1959,7 +1960,7 @@ int xmitframe_enqueue_for_sleeping_sta23a(struct rtw_adapter *padapter, struct x int bmcst = is_multicast_ether_addr(pattrib->ra); if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == false) - return ret; + return ret; if (pattrib->psta) { psta = pattrib->psta; -- cgit v1.2.3 From 16b9632da2c071d74934447e266717787bec449b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:41 +0200 Subject: staging: rtl8732au: ioctl_cfg80211.c: Fix another case of u8 abuse for error return Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 627d75c1b329..182f57c2d86b 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -435,12 +435,12 @@ void rtw_cfg80211_indicate_disconnect(struct rtw_adapter *padapter) } #ifdef CONFIG_8723AU_AP_MODE -static u8 set_pairwise_key(struct rtw_adapter *padapter, struct sta_info *psta) +static int set_pairwise_key(struct rtw_adapter *padapter, struct sta_info *psta) { struct cmd_obj *ph2c; struct set_stakey_parm *psetstakey_para; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; + int res = _SUCCESS; ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (ph2c == NULL) { -- cgit v1.2.3 From 9e2d06661a55ac8486cdb8e2bd9358755d2f703c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:42 +0200 Subject: staging: rtl8723au: os_intfs.c: Fixup more u8/uint abuse for error return codes Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/osdep_intf.h | 6 +++--- drivers/staging/rtl8723au/os_dep/os_intfs.c | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8723au/include/osdep_intf.h b/drivers/staging/rtl8723au/include/osdep_intf.h index d3e22635e9ea..9e77156d51d2 100644 --- a/drivers/staging/rtl8723au/include/osdep_intf.h +++ b/drivers/staging/rtl8723au/include/osdep_intf.h @@ -22,9 +22,9 @@ int rtw_hw_suspend23a(struct rtw_adapter *padapter); int rtw_hw_resume23a(struct rtw_adapter *padapter); -u8 rtw_init_drv_sw23a(struct rtw_adapter *padapter); -u8 rtw_free_drv_sw23a(struct rtw_adapter *padapter); -u8 rtw_reset_drv_sw23a(struct rtw_adapter *padapter); +int rtw_init_drv_sw23a(struct rtw_adapter *padapter); +int rtw_free_drv_sw23a(struct rtw_adapter *padapter); +int rtw_reset_drv_sw23a(struct rtw_adapter *padapter); void rtw_cancel_all_timer23a(struct rtw_adapter *padapter); diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index afab4625b041..9f3df9e45e34 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -172,10 +172,10 @@ MODULE_PARM_DESC(debug, "Set debug level (1-9) (default 1)"); static int netdev_close(struct net_device *pnetdev); -static uint loadparam(struct rtw_adapter *padapter, struct net_device *pnetdev) +static int loadparam(struct rtw_adapter *padapter, struct net_device *pnetdev) { struct registry_priv *registry_par = &padapter->registrypriv; - uint status = _SUCCESS; + int status = _SUCCESS; GlobalDebugLevel23A = rtw_debug; registry_par->chip_version = (u8)rtw_chip_version; @@ -378,13 +378,13 @@ struct net_device *rtw_init_netdev23a(struct rtw_adapter *old_padapter) return pnetdev; } -static u8 rtw_init_default_value(struct rtw_adapter *padapter) +static int rtw_init_default_value(struct rtw_adapter *padapter) { struct registry_priv *pregistrypriv = &padapter->registrypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv *psecuritypriv = &padapter->securitypriv; - u8 ret = _SUCCESS; + int ret = _SUCCESS; /* xmit_priv */ pxmitpriv->vcs_setting = pregistrypriv->vrtl_carrier_sense; @@ -429,11 +429,11 @@ static u8 rtw_init_default_value(struct rtw_adapter *padapter) return ret; } -u8 rtw_reset_drv_sw23a(struct rtw_adapter *padapter) +int rtw_reset_drv_sw23a(struct rtw_adapter *padapter) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; - u8 ret8 = _SUCCESS; + int ret8 = _SUCCESS; /* hal_priv */ rtl8723a_init_default_value(padapter); @@ -458,9 +458,9 @@ u8 rtw_reset_drv_sw23a(struct rtw_adapter *padapter) return ret8; } -u8 rtw_init_drv_sw23a(struct rtw_adapter *padapter) +int rtw_init_drv_sw23a(struct rtw_adapter *padapter) { - u8 ret8 = _SUCCESS; + int ret8 = _SUCCESS; RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_init_drv_sw23a\n")); @@ -562,7 +562,7 @@ void rtw_cancel_all_timer23a(struct rtw_adapter *padapter) rtl8723a_deinit_dm_priv(padapter); } -u8 rtw_free_drv_sw23a(struct rtw_adapter *padapter) +int rtw_free_drv_sw23a(struct rtw_adapter *padapter) { RT_TRACE(_module_os_intfs_c_, _drv_info_, ("==>rtw_free_drv_sw23a")); @@ -655,7 +655,7 @@ int netdev_open23a(struct net_device *pnetdev) struct rtw_adapter *padapter = netdev_priv(pnetdev); struct pwrctrl_priv *pwrctrlpriv; int ret = 0; - uint status; + int status; RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+871x_drv - dev_open\n")); DBG_8723A("+871x_drv - drv_open, bup =%d\n", padapter->bup); -- cgit v1.2.3 From 86c3e3f11e83af86ad3876ecb1f9e98e35851d1b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:43 +0200 Subject: staging: rtl8723au: usb_intf.c: Fixup yet another round of u8 abuse for error type Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/usb_intf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index 6479c5fbf9a1..97a2bc6102b5 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -99,9 +99,9 @@ static inline int RT_usb_endpoint_num(const struct usb_endpoint_descriptor *epd) return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; } -static u8 rtw_init_intf_priv(struct dvobj_priv *dvobj) +static int rtw_init_intf_priv(struct dvobj_priv *dvobj) { - u8 rst = _SUCCESS; + int rst = _SUCCESS; mutex_init(&dvobj->usb_vendor_req_mutex); dvobj->usb_alloc_vendor_req_buf = kzalloc(MAX_USB_IO_CTL_SIZE, @@ -117,9 +117,9 @@ exit: return rst; } -static u8 rtw_deinit_intf_priv(struct dvobj_priv *dvobj) +static int rtw_deinit_intf_priv(struct dvobj_priv *dvobj) { - u8 rst = _SUCCESS; + int rst = _SUCCESS; kfree(dvobj->usb_alloc_vendor_req_buf); -- cgit v1.2.3 From e04cd3f5edf700912a29c14aa4b663689ee4ca07 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:44 +0200 Subject: staging: rtl8723au: usb_halinit.c: Another u8 error code case Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_halinit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index df2650712191..ccc57fddd780 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -100,9 +100,9 @@ void rtl8723au_chip_configure(struct rtw_adapter *padapter) pdvobjpriv->RtNumOutPipes); } -static u8 _InitPowerOn(struct rtw_adapter *padapter) +static int _InitPowerOn(struct rtw_adapter *padapter) { - u8 status = _SUCCESS; + int status = _SUCCESS; u16 value16 = 0; u8 value8 = 0; -- cgit v1.2.3 From 24ed8e4575cdd9bf59750755fadbef67af427c88 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:45 +0200 Subject: staging: rtl8723au: rtl8723au_xmit_tasklet(): Remove unnecessary variable init Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_ops_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index 0a7fa0a9c9af..c7df5212fc57 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -802,7 +802,7 @@ static int usb_read_port(struct rtw_adapter *adapter, u32 addr, u32 cnt, void rtl8723au_xmit_tasklet(void *priv) { - int ret = false; + int ret; struct rtw_adapter *padapter = (struct rtw_adapter *)priv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; -- cgit v1.2.3 From 5c195cc27bb73264d9b3193153095b3b090d2deb Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:46 +0200 Subject: staging: rtl8723au: rtl8723au_xmit.c: Fixup messy return type usage Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723au_xmit.c | 26 +++++++++++++---------- drivers/staging/rtl8723au/include/rtl8723a_xmit.h | 4 ++-- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c b/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c index 3926ad1c353d..113144c3c02f 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c +++ b/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c @@ -295,10 +295,11 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bag return pull; } -static s32 rtw_dump_xframe(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe) +static int rtw_dump_xframe(struct rtw_adapter *padapter, + struct xmit_frame *pxmitframe) { - s32 ret = _SUCCESS; - s32 inner_ret = _SUCCESS; + int ret = _SUCCESS; + int inner_ret = _SUCCESS; int t, sz, w_sz, pull = 0; u8 *mem_addr; u32 ff_hwaddr; @@ -363,8 +364,9 @@ static s32 rtw_dump_xframe(struct rtw_adapter *padapter, struct xmit_frame *pxmi return ret; } -s32 rtl8723au_xmitframe_complete(struct rtw_adapter *padapter, - struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) +bool rtl8723au_xmitframe_complete(struct rtw_adapter *padapter, + struct xmit_priv *pxmitpriv, + struct xmit_buf *pxmitbuf) { struct hw_xmit *phwxmits; struct xmit_frame *pxmitframe; @@ -413,9 +415,10 @@ s32 rtl8723au_xmitframe_complete(struct rtw_adapter *padapter, return true; } -static s32 xmitframe_direct(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe) +static int xmitframe_direct(struct rtw_adapter *padapter, + struct xmit_frame *pxmitframe) { - s32 res = _SUCCESS; + int res; res = rtw_xmitframe_coalesce23a(padapter, pxmitframe->pkt, pxmitframe); if (res == _SUCCESS) @@ -500,16 +503,17 @@ enqueue: return false; } -s32 rtl8723au_mgnt_xmit(struct rtw_adapter *padapter, struct xmit_frame *pmgntframe) +int rtl8723au_mgnt_xmit(struct rtw_adapter *padapter, + struct xmit_frame *pmgntframe) { return rtw_dump_xframe(padapter, pmgntframe); } -s32 rtl8723au_hal_xmitframe_enqueue(struct rtw_adapter *padapter, - struct xmit_frame *pxmitframe) +int rtl8723au_hal_xmitframe_enqueue(struct rtw_adapter *padapter, + struct xmit_frame *pxmitframe) { struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - s32 err; + int err; err = rtw_xmitframe_enqueue23a(padapter, pxmitframe); if (err != _SUCCESS) { diff --git a/drivers/staging/rtl8723au/include/rtl8723a_xmit.h b/drivers/staging/rtl8723au/include/rtl8723a_xmit.h index ab9ca349b6f4..79883d7b867d 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_xmit.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_xmit.h @@ -220,8 +220,8 @@ int rtl8723au_hal_xmitframe_enqueue(struct rtw_adapter *padapter, struct xmit_fr s32 rtl8723au_xmit_buf_handler(struct rtw_adapter *padapter); #define hal_xmit_handler rtl8723au_xmit_buf_handler bool rtl8723au_hal_xmit(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe); -s32 rtl8723au_mgnt_xmit(struct rtw_adapter *padapter, struct xmit_frame *pmgntframe); -s32 rtl8723au_xmitframe_complete(struct rtw_adapter *padapter, struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf); +int rtl8723au_mgnt_xmit(struct rtw_adapter *padapter, struct xmit_frame *pmgntframe); +bool rtl8723au_xmitframe_complete(struct rtw_adapter *padapter, struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf); #endif -- cgit v1.2.3 From c691ec33734d2bbaf2d63f9d4db94b5fa2314201 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:47 +0200 Subject: staging: rtl8723au: rtl8723a_phycfg.c: Use int for error return codes Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c b/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c index 2ac780e9feae..c48cf04e60e0 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c @@ -415,7 +415,7 @@ PHY_SetRFReg(struct rtw_adapter *Adapter, enum RF_RADIO_PATH eRFPath, * 08/12/2008 MHC Create Version 0. * *---------------------------------------------------------------------------*/ -s32 PHY_MACConfig8723A(struct rtw_adapter *Adapter) +int PHY_MACConfig8723A(struct rtw_adapter *Adapter) { int rtStatus = _SUCCESS; struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); -- cgit v1.2.3 From a5681f99b4caa996e3d51ddaf6d11e7a9bdd33ae Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:48 +0200 Subject: staging: rtl8723au: rtl8723a_hal_init.c: Fix more messy return type abuse Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 40 +++++++++++------------ drivers/staging/rtl8723au/include/rtl8723a_hal.h | 6 ++-- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 3a9a96a2a5ea..df90c662e6a9 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -187,7 +187,7 @@ exit: return ret; } -static s32 _FWFreeToGo(struct rtw_adapter *padapter) +static int _FWFreeToGo(struct rtw_adapter *padapter) { u32 counter = 0; u32 value32; @@ -276,9 +276,9 @@ void rtl8723a_FirmwareSelfReset(struct rtw_adapter *padapter) /* Download 8192C firmware code. */ /* */ /* */ -s32 rtl8723a_FirmwareDownload(struct rtw_adapter *padapter) +int rtl8723a_FirmwareDownload(struct rtw_adapter *padapter) { - s32 rtStatus = _SUCCESS; + int rtStatus = _SUCCESS; u8 writeFW_retry = 0; unsigned long fwdl_start_time; struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); @@ -1143,18 +1143,18 @@ void rtl8723a_notch_filter(struct rtw_adapter *adapter, bool enable) } } -s32 c2h_id_filter_ccx_8723a(u8 id) +bool c2h_id_filter_ccx_8723a(u8 id) { - s32 ret = false; + bool ret = false; if (id == C2H_CCX_TX_RPT) ret = true; return ret; } -s32 c2h_handler_8723a(struct rtw_adapter *padapter, struct c2h_evt_hdr *c2h_evt) +int c2h_handler_8723a(struct rtw_adapter *padapter, struct c2h_evt_hdr *c2h_evt) { - s32 ret = _SUCCESS; + int ret = _SUCCESS; u8 i = 0; if (c2h_evt == NULL) { @@ -1293,9 +1293,9 @@ u8 GetEEPROMSize8723A(struct rtw_adapter *padapter) /* LLT R/W/Init function */ /* */ /* */ -static s32 _LLTWrite(struct rtw_adapter *padapter, u32 address, u32 data) +static int _LLTWrite(struct rtw_adapter *padapter, u32 address, u32 data) { - s32 status = _SUCCESS; + int status = _SUCCESS; s32 count = 0; u32 value = _LLT_INIT_ADDR(address) | _LLT_INIT_DATA(data) | _LLT_OP(_LLT_WRITE_ACCESS); @@ -1322,23 +1322,23 @@ static s32 _LLTWrite(struct rtw_adapter *padapter, u32 address, u32 data) return status; } -s32 InitLLTTable23a(struct rtw_adapter *padapter, u32 boundary) +int InitLLTTable23a(struct rtw_adapter *padapter, u32 boundary) { - s32 status = _SUCCESS; + int status = _SUCCESS; u32 i; u32 txpktbuf_bndy = boundary; u32 Last_Entry_Of_TxPktBuf = LAST_ENTRY_OF_TX_PKT_BUFFER; for (i = 0; i < (txpktbuf_bndy - 1); i++) { status = _LLTWrite(padapter, i, i + 1); - if (_SUCCESS != status) { + if (status != _SUCCESS) { return status; } } /* end of list */ status = _LLTWrite(padapter, (txpktbuf_bndy - 1), 0xFF); - if (_SUCCESS != status) { + if (status != _SUCCESS) { return status; } @@ -1355,7 +1355,7 @@ s32 InitLLTTable23a(struct rtw_adapter *padapter, u32 boundary) /* Let last entry point to the start entry of ring buffer */ status = _LLTWrite(padapter, Last_Entry_Of_TxPktBuf, txpktbuf_bndy); - if (_SUCCESS != status) { + if (status != _SUCCESS) { return status; } @@ -1598,7 +1598,7 @@ static void _DisableAnalog(struct rtw_adapter *padapter, bool bWithoutHWSM) } /* HW Auto state machine */ -s32 CardDisableHWSM(struct rtw_adapter *padapter, u8 resetMCU) +int CardDisableHWSM(struct rtw_adapter *padapter, u8 resetMCU) { int rtStatus = _SUCCESS; @@ -1624,9 +1624,9 @@ s32 CardDisableHWSM(struct rtw_adapter *padapter, u8 resetMCU) } /* without HW Auto state machine */ -s32 CardDisableWithoutHWSM(struct rtw_adapter *padapter) +int CardDisableWithoutHWSM(struct rtw_adapter *padapter) { - s32 rtStatus = _SUCCESS; + int rtStatus = _SUCCESS; /* RT_TRACE(COMP_INIT, DBG_LOUD, ("======> Card Disable Without HWSM .\n")); */ @@ -2017,20 +2017,20 @@ Hal_EfuseParseXtal_8723A(struct rtw_adapter *pAdapter, void Hal_EfuseParseThermalMeter_8723A(struct rtw_adapter *padapter, - u8 *PROMContent, u8 AutoloadFail) + u8 *PROMContent, bool AutoloadFail) { struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); /* */ /* ThermalMeter from EEPROM */ /* */ - if (false == AutoloadFail) + if (AutoloadFail == false) pHalData->EEPROMThermalMeter = PROMContent[EEPROM_THERMAL_METER_8723A]; else pHalData->EEPROMThermalMeter = EEPROM_Default_ThermalMeter; - if ((pHalData->EEPROMThermalMeter == 0xff) || (true == AutoloadFail)) { + if ((pHalData->EEPROMThermalMeter == 0xff) || (AutoloadFail == true)) { pHalData->bAPKThermalMeterIgnore = true; pHalData->EEPROMThermalMeter = EEPROM_Default_ThermalMeter; } diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index efa78778ba23..c22bb811aa01 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -527,7 +527,7 @@ void Hal_EfuseParseCustomerID(struct rtw_adapter *padapter, u8 *hwinfo, bool Aut void Hal_EfuseParseAntennaDiversity(struct rtw_adapter *padapter, u8 *hwinfo, bool AutoLoadFail); void Hal_EfuseParseRateIndicationOption(struct rtw_adapter *padapter, u8 *hwinfo, bool AutoLoadFail); void Hal_EfuseParseXtal_8723A(struct rtw_adapter *pAdapter, u8 *hwinfo, u8 AutoLoadFail); -void Hal_EfuseParseThermalMeter_8723A(struct rtw_adapter *padapter, u8 *hwinfo, u8 AutoLoadFail); +void Hal_EfuseParseThermalMeter_8723A(struct rtw_adapter *padapter, u8 *hwinfo, bool AutoLoadFail); void Hal_InitChannelPlan23a(struct rtw_adapter *padapter); @@ -542,8 +542,8 @@ void rtl8723a_InitBeaconParameters(struct rtw_adapter *padapter); void rtl8723a_start_thread(struct rtw_adapter *padapter); void rtl8723a_stop_thread(struct rtw_adapter *padapter); -s32 c2h_id_filter_ccx_8723a(u8 id); -s32 c2h_handler_8723a(struct rtw_adapter *padapter, struct c2h_evt_hdr *c2h_evt); +bool c2h_id_filter_ccx_8723a(u8 id); +int c2h_handler_8723a(struct rtw_adapter *padapter, struct c2h_evt_hdr *c2h_evt); void rtl8723a_read_adapter_info(struct rtw_adapter *Adapter); void rtl8723a_read_chip_version(struct rtw_adapter *padapter); -- cgit v1.2.3 From 95d412d830f453c021dc6000a8180d18deae7985 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:49 +0200 Subject: staging: rtl8723au: rtl8723a_cmd.c: Fix up bad return types Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 14 +++++++------- drivers/staging/rtl8723au/include/rtl8723a_cmd.h | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c index e94557fc12cb..9bbb09f09ff7 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c @@ -47,7 +47,8 @@ static u8 _is_fw_read_cmd_down(struct rtw_adapter *padapter, u8 msgbox_num) *| h2c_msg |Ext_bit |CMD_ID | * ******************************************/ -s32 FillH2CCmd(struct rtw_adapter *padapter, u8 ElementID, u32 CmdLen, u8 *pCmdBuffer) +int FillH2CCmd(struct rtw_adapter *padapter, u8 ElementID, u32 CmdLen, + u8 *pCmdBuffer) { u8 bcmd_down = false; s32 retry_cnts = 100; @@ -57,7 +58,7 @@ s32 FillH2CCmd(struct rtw_adapter *padapter, u8 ElementID, u32 CmdLen, u8 *pCmdB struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); u32 h2c_cmd = 0; u16 h2c_cmd_ex = 0; - s32 ret = _FAIL; + int ret = _FAIL; padapter = GET_PRIMARY_ADAPTER(padapter); pHalData = GET_HAL_DATA(padapter); @@ -112,9 +113,9 @@ exit: return ret; } -u8 rtl8723a_set_rssi_cmd(struct rtw_adapter *padapter, u8 *param) +int rtl8723a_set_rssi_cmd(struct rtw_adapter *padapter, u8 *param) { - u8 res = _SUCCESS; + int res = _SUCCESS; *((u32 *)param) = cpu_to_le32(*((u32 *)param)); @@ -123,10 +124,10 @@ u8 rtl8723a_set_rssi_cmd(struct rtw_adapter *padapter, u8 *param) return res; } -u8 rtl8723a_set_raid_cmd(struct rtw_adapter *padapter, u32 mask, u8 arg) +int rtl8723a_set_raid_cmd(struct rtw_adapter *padapter, u32 mask, u8 arg) { u8 buf[5]; - u8 res = _SUCCESS; + int res = _SUCCESS; memset(buf, 0, 5); mask = cpu_to_le32(mask); @@ -136,7 +137,6 @@ u8 rtl8723a_set_raid_cmd(struct rtw_adapter *padapter, u32 mask, u8 arg) FillH2CCmd(padapter, MACID_CONFIG_EID, 5, buf); return res; - } /* bitmap[0:27] = tx_rate_bitmap */ diff --git a/drivers/staging/rtl8723au/include/rtl8723a_cmd.h b/drivers/staging/rtl8723au/include/rtl8723a_cmd.h index 09fa72340302..3a15c9e8628b 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_cmd.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_cmd.h @@ -142,14 +142,14 @@ struct lowpwr_lps_parm{ /* host message to firmware cmd */ -void rtl8723a_set_FwPwrMode_cmd(struct rtw_adapter * padapter, u8 Mode); -void rtl8723a_set_FwJoinBssReport_cmd(struct rtw_adapter * padapter, u8 mstatus); +void rtl8723a_set_FwPwrMode_cmd(struct rtw_adapter *padapter, u8 Mode); +void rtl8723a_set_FwJoinBssReport_cmd(struct rtw_adapter *padapter, u8 mstatus); #ifdef CONFIG_8723AU_BT_COEXIST -void rtl8723a_set_BTCoex_AP_mode_FwRsvdPkt_cmd(struct rtw_adapter * padapter); +void rtl8723a_set_BTCoex_AP_mode_FwRsvdPkt_cmd(struct rtw_adapter *padapter); #endif -u8 rtl8723a_set_rssi_cmd(struct rtw_adapter * padapter, u8 *param); -u8 rtl8723a_set_raid_cmd(struct rtw_adapter * padapter, u32 mask, u8 arg); -void rtl8723a_add_rateatid(struct rtw_adapter * padapter, u32 bitmap, u8 arg, u8 rssi_level); +int rtl8723a_set_rssi_cmd(struct rtw_adapter *padapter, u8 *param); +int rtl8723a_set_raid_cmd(struct rtw_adapter *padapter, u32 mask, u8 arg); +void rtl8723a_add_rateatid(struct rtw_adapter *padapter, u32 bitmap, u8 arg, u8 rssi_level); void CheckFwRsvdPageContent23a(struct rtw_adapter *padapter); -- cgit v1.2.3 From 18bd6df23dd5d8560d9d5993a3257d0bb2c31e66 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:50 +0200 Subject: staging: rtl8723au: hal_com.c: Fix one case of returning status in an s32 Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_com.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index bb948e595be3..29e0ec9acb65 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -355,9 +355,9 @@ void c2h_evt_clear23a(struct rtw_adapter *adapter) rtw_write8(adapter, REG_C2HEVT_CLEAR, C2H_EVT_HOST_CLOSE); } -s32 c2h_evt_read23a(struct rtw_adapter *adapter, u8 *buf) +int c2h_evt_read23a(struct rtw_adapter *adapter, u8 *buf) { - s32 ret = _FAIL; + int ret = _FAIL; struct c2h_evt_hdr *c2h_evt; int i; u8 trigger; -- cgit v1.2.3 From 9b00959fca12f140b06e475f395da265a2b95ef8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:51 +0200 Subject: staging: rtl8723au: odm_precomp.h: Remove unused #define TEST_FALG__ Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/odm_precomp.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8723au/include/odm_precomp.h b/drivers/staging/rtl8723au/include/odm_precomp.h index fe6df738c3ce..69de888d884c 100644 --- a/drivers/staging/rtl8723au/include/odm_precomp.h +++ b/drivers/staging/rtl8723au/include/odm_precomp.h @@ -16,8 +16,6 @@ #ifndef __ODM_PRECOMP_H__ #define __ODM_PRECOMP_H__ -#define TEST_FALG___ 1 - /* 2 Config Flags and Structs - defined by each ODM Type */ #include -- cgit v1.2.3 From 7438ccb93689845d31f5ced3ff6b22eada280d94 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:52 +0200 Subject: staging: rtl8723au: hal/usb_ops_linux.c: Various cleanups Reduce excessive parenthesis usage, remove unnecessary null initialization of variables, and some bad formatting. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_ops_linux.c | 106 ++++++++++++++------------ 1 file changed, 57 insertions(+), 49 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index c7df5212fc57..be43863d1c2d 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -35,15 +35,17 @@ static int usbctrl_vendorreq(struct rtw_adapter *padapter, u8 request, u8 *pIo_buf; int vendorreq_times = 0; - if ((padapter->bSurpriseRemoved) || (padapter->pwrctrlpriv.pnp_bstop_trx)) { + if (padapter->bSurpriseRemoved || padapter->pwrctrlpriv.pnp_bstop_trx) { RT_TRACE(_module_hci_ops_os_c_, _drv_err_, - ("usbctrl_vendorreq:(padapter->bSurpriseRemoved||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n")); + ("usbctrl_vendorreq:(padapter->bSurpriseRemoved||" + "adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n")); status = -EPERM; goto exit; } if (len > MAX_VENDOR_REQ_CMD_SIZE) { - DBG_8723A("[%s] Buffer len error , vendor request failed\n", __FUNCTION__); + DBG_8723A("[%s] Buffer len error , vendor request failed\n", + __FUNCTION__); status = -EINVAL; goto exit; } @@ -86,21 +88,26 @@ static int usbctrl_vendorreq(struct rtw_adapter *padapter, u8 request, } else { /* error cases */ DBG_8723A("reg 0x%x, usb %s %u fail, status:%d value =" " 0x%x, vendorreq_times:%d\n", - value, (requesttype == 0x01) ? "read" : "write", + value, (requesttype == 0x01) ? + "read" : "write", len, status, *(u32 *)pdata, vendorreq_times); if (status < 0) { - if (status == (-ESHUTDOWN) || status == -ENODEV) { + if (status == -ESHUTDOWN || status == -ENODEV) padapter->bSurpriseRemoved = true; - } else { - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - pHalData->srestpriv.Wifi_Error_Status = USB_VEN_REQ_CMD_FAIL; + else { + struct hal_data_8723a *pHalData; + pHalData = GET_HAL_DATA(padapter); + pHalData->srestpriv.Wifi_Error_Status = + USB_VEN_REQ_CMD_FAIL; } } else { /* status != len && status >= 0 */ if (status > 0) { if (requesttype == 0x01) { - /* For Control read transfer, we have to copy - * the read data from pIo_buf to pdata. + /* + * For Control read transfer, + * we have to copy the read + * data from pIo_buf to pdata. */ memcpy(pdata, pIo_buf, len); } @@ -111,11 +118,11 @@ static int usbctrl_vendorreq(struct rtw_adapter *padapter, u8 request, padapter->bSurpriseRemoved = true; break; } - } /* firmware download is checksumed, don't retry */ - if ((value >= FW_8723A_START_ADDRESS && value <= FW_8723A_END_ADDRESS) || status == len) + if ((value >= FW_8723A_START_ADDRESS && + value <= FW_8723A_END_ADDRESS) || status == len) break; } @@ -332,8 +339,8 @@ InterruptRecognized8723AU(struct rtw_adapter *Adapter, void *pContent, memcpy(&report.state, &buffer[USB_INTR_CPWM_OFFSET], 1); - return ((pHalData->IntArray[0])&pHalData->IntrMask[0]) != 0 || - ((pHalData->IntArray[1])&pHalData->IntrMask[1]) != 0; + return (pHalData->IntArray[0] & pHalData->IntrMask[0]) != 0 || + (pHalData->IntArray[1] & pHalData->IntrMask[1]) != 0; } static void usb_read_interrupt_complete(struct urb *purb, struct pt_regs *regs) @@ -368,7 +375,8 @@ static void usb_read_interrupt_complete(struct urb *purb, struct pt_regs *regs) if (c2h_evt_exist(c2h_evt)) { if (c2h_id_filter_ccx_8723a(c2h_evt->id)) { /* Handle CCX report here */ - handle_txrpt_ccx_8723a(padapter, (void *)(c2h_evt->payload)); + handle_txrpt_ccx_8723a(padapter, (void *) + c2h_evt->payload); schedule_work(&padapter->evtpriv.irq_wk); } else { struct evt_work *c2w; @@ -472,16 +480,16 @@ static int recvbuf2recvframe(struct rtw_adapter *padapter, struct sk_buff *pskb) u8 shift_sz = 0; u16 pkt_cnt; u32 pkt_offset, skb_len, alloc_sz; - s32 transfer_len; - struct recv_stat *prxstat; - struct phy_stat *pphy_info = NULL; - struct sk_buff *pkt_copy = NULL; - struct recv_frame *precvframe = NULL; - struct rx_pkt_attrib *pattrib = NULL; - struct recv_priv *precvpriv = &padapter->recvpriv; - struct rtw_queue *pfree_recv_queue = &precvpriv->free_recv_queue; - - transfer_len = (s32)pskb->len; + int transfer_len; + struct recv_stat *prxstat; + struct phy_stat *pphy_info; + struct sk_buff *pkt_copy; + struct recv_frame *precvframe; + struct rx_pkt_attrib *pattrib; + struct recv_priv *precvpriv = &padapter->recvpriv; + struct rtw_queue *pfree_recv_queue = &precvpriv->free_recv_queue; + + transfer_len = (int)pskb->len; pbuf = pskb->data; prxstat = (struct recv_stat *)pbuf; @@ -520,7 +528,7 @@ static int recvbuf2recvframe(struct rtw_adapter *padapter, struct sk_buff *pskb) pkt_offset = RXDESC_SIZE + pattrib->drvinfo_sz + pattrib->shift_sz + pattrib->pkt_len; - if ((pattrib->pkt_len <= 0) || (pkt_offset > transfer_len)) { + if (pattrib->pkt_len <= 0 || pkt_offset > transfer_len) { RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("recvbuf2recvframe: pkt_len<= 0\n")); DBG_8723A("%s()-%d: RX Warning!\n", @@ -532,11 +540,10 @@ static int recvbuf2recvframe(struct rtw_adapter *padapter, struct sk_buff *pskb) /* Modified by Albert 20101213 */ /* For 8 bytes IP header alignment. */ /* Qos data, wireless lan header length is 26 */ - if (pattrib->qos) { + if (pattrib->qos) shift_sz = 6; - } else { + else shift_sz = 0; - } skb_len = pattrib->pkt_len; @@ -544,7 +551,7 @@ static int recvbuf2recvframe(struct rtw_adapter *padapter, struct sk_buff *pskb) * 1536+drvinfo_sz+RXDESC_SIZE to defrag packet. * modify alloc_sz for recvive crc error packet * by thomas 2011-06-02 */ - if ((pattrib->mfrag == 1) && (pattrib->frag_num == 0)) { + if (pattrib->mfrag == 1 && pattrib->frag_num == 0) { /* alloc_sz = 1664; 1664 is 128 alignment. */ if (skb_len <= 1650) alloc_sz = 1664; @@ -561,13 +568,17 @@ static int recvbuf2recvframe(struct rtw_adapter *padapter, struct sk_buff *pskb) if (pkt_copy) { pkt_copy->dev = padapter->pnetdev; precvframe->pkt = pkt_copy; - skb_reserve(pkt_copy, 8 - ((unsigned long)(pkt_copy->data) & 7));/* force pkt_copy->data at 8-byte alignment address */ - /*force ip_hdr at 8-byte alignment address according to shift_sz. */ + /* force pkt_copy->data at 8-byte alignment address */ + skb_reserve(pkt_copy, 8 - + ((unsigned long)(pkt_copy->data) & 7)); + /*force ip_hdr at 8-byte alignment address + according to shift_sz. */ skb_reserve(pkt_copy, shift_sz); - memcpy(pkt_copy->data, (pbuf + pattrib->shift_sz + pattrib->drvinfo_sz + RXDESC_SIZE), skb_len); + memcpy(pkt_copy->data, pbuf + pattrib->shift_sz + + pattrib->drvinfo_sz + RXDESC_SIZE, skb_len); skb_put(pkt_copy, skb_len); } else { - if ((pattrib->mfrag == 1) && (pattrib->frag_num == 0)) { + if (pattrib->mfrag == 1 && pattrib->frag_num == 0) { DBG_8723A("recvbuf2recvframe: alloc_skb fail, " "drop frag frame \n"); rtw_free_recvframe23a(precvframe); @@ -602,7 +613,7 @@ static int recvbuf2recvframe(struct rtw_adapter *padapter, struct sk_buff *pskb) if (transfer_len > 0 && pkt_cnt == 0) pkt_cnt = (le32_to_cpu(prxstat->rxdw2)>>16) & 0xff; - } while ((transfer_len > 0) && (pkt_cnt > 0)); + } while (transfer_len > 0 && pkt_cnt > 0); _exit_recvbuf2recvframe: @@ -616,8 +627,7 @@ void rtl8723au_recv_tasklet(void *priv) struct recv_priv *precvpriv = &padapter->recvpriv; while (NULL != (pskb = skb_dequeue(&precvpriv->rx_skb_queue))) { - if ((padapter->bDriverStopped) || - (padapter->bSurpriseRemoved)) { + if (padapter->bDriverStopped || padapter->bSurpriseRemoved) { DBG_8723A("recv_tasklet => bDriverStopped or " "bSurpriseRemoved \n"); dev_kfree_skb_any(pskb); @@ -660,8 +670,8 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) } if (purb->status == 0) { - if ((purb->actual_length > MAX_RECVBUF_SZ) || - (purb->actual_length < RXDESC_SIZE)) { + if (purb->actual_length > MAX_RECVBUF_SZ || + purb->actual_length < RXDESC_SIZE) { RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete: (purb->actual_" "length > MAX_RECVBUF_SZ) || (purb->actual_" @@ -729,7 +739,6 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) default: break; } - } } @@ -738,13 +747,13 @@ static int usb_read_port(struct rtw_adapter *adapter, u32 addr, u32 cnt, { int err; unsigned int pipe; - unsigned long tmpaddr = 0; - unsigned long alignment = 0; + unsigned long tmpaddr; + unsigned long alignment; int ret = _SUCCESS; - struct urb *purb = NULL; - struct dvobj_priv *pdvobj = adapter_to_dvobj(adapter); - struct recv_priv *precvpriv = &adapter->recvpriv; - struct usb_device *pusbd = pdvobj->pusbdev; + struct urb *purb; + struct dvobj_priv *pdvobj = adapter_to_dvobj(adapter); + struct recv_priv *precvpriv = &adapter->recvpriv; + struct usb_device *pusbd = pdvobj->pusbdev; if (adapter->bDriverStopped || adapter->bSurpriseRemoved || adapter->pwrctrlpriv.pnp_bstop_trx) { @@ -810,9 +819,8 @@ void rtl8723au_xmit_tasklet(void *priv) return; while (1) { - if ((padapter->bDriverStopped) || - (padapter->bSurpriseRemoved) || - (padapter->bWritePortCancel)) { + if (padapter->bDriverStopped || padapter->bSurpriseRemoved || + padapter->bWritePortCancel) { DBG_8723A("xmit_tasklet => bDriverStopped or " "bSurpriseRemoved or bWritePortCancel\n"); break; -- cgit v1.2.3 From eb269884cffe61edce56300a56092969d98b4d50 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:53 +0200 Subject: staging: rtl8723au: os_dep/usb_ops_linux.c: More bad parenthesis cleanup Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/usb_ops_linux.c | 45 ++++++++++++++---------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c index cd38c78e2868..6af475707bb8 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c @@ -93,23 +93,25 @@ static void usb_write_port23a_complete(struct urb *purb, struct pt_regs *regs) if (padapter->bSurpriseRemoved || padapter->bDriverStopped || padapter->bWritePortCancel) { RT_TRACE(_module_hci_ops_os_c_, _drv_err_, - ("usb_write_port23a_complete:bDriverStopped(%d) OR bSurpriseRemoved(%d)", - padapter->bDriverStopped, padapter->bSurpriseRemoved)); - DBG_8723A("%s(): TX Warning! bDriverStopped(%d) OR bSurpriseRemoved(%d) bWritePortCancel(%d) pxmitbuf->ext_tag(%x)\n", - __func__, padapter->bDriverStopped, - padapter->bSurpriseRemoved, padapter->bReadPortCancel, - pxmitbuf->ext_tag); + ("usb_write_port23a_complete:bDriverStopped(%d) OR " + "bSurpriseRemoved(%d)", padapter->bDriverStopped, + padapter->bSurpriseRemoved)); + DBG_8723A("%s(): TX Warning! bDriverStopped(%d) OR " + "bSurpriseRemoved(%d) bWritePortCancel(%d) " + "pxmitbuf->ext_tag(%x)\n", __func__, + padapter->bDriverStopped, padapter->bSurpriseRemoved, + padapter->bReadPortCancel, pxmitbuf->ext_tag); goto check_completion; } if (purb->status) { RT_TRACE(_module_hci_ops_os_c_, _drv_err_, - ("usb_write_port23a_complete : purb->status(%d) != 0\n", - purb->status)); + ("usb_write_port23a_complete : purb->status(%d) " + "!= 0\n", purb->status)); DBG_8723A("###=> urb_write_port_complete status(%d)\n", purb->status); - if ((purb->status == -EPIPE) || (purb->status == -EPROTO)) { + if (purb->status == -EPIPE || purb->status == -EPROTO) { sreset_set_wifi_error_status23a(padapter, USB_WRITE_PORT_FAIL); } else if (purb->status == -EINPROGRESS) { @@ -127,13 +129,15 @@ static void usb_write_port23a_complete(struct urb *purb, struct pt_regs *regs) ("usb_write_port23a_complete: ESHUTDOWN\n")); padapter->bDriverStopped = true; RT_TRACE(_module_hci_ops_os_c_, _drv_err_, - ("usb_write_port23a_complete:bDriverStopped = true\n")); + ("usb_write_port23a_complete:bDriverStopped " + "= true\n")); goto check_completion; } else { padapter->bSurpriseRemoved = true; DBG_8723A("bSurpriseRemoved = true\n"); RT_TRACE(_module_hci_ops_os_c_, _drv_err_, - ("usb_write_port23a_complete:bSurpriseRemoved = true\n")); + ("usb_write_port23a_complete:bSurpriseRemoved " + "= true\n")); goto check_completion; } } @@ -143,8 +147,8 @@ static void usb_write_port23a_complete(struct urb *purb, struct pt_regs *regs) check_completion: spin_lock_irqsave(&pxmitpriv->lock_sctx, irqL); rtw23a_sctx_done_err(&pxmitbuf->sctx, - purb->status ? RTW_SCTX_DONE_WRITE_PORT_ERR : - RTW_SCTX_DONE_SUCCESS); + purb->status ? RTW_SCTX_DONE_WRITE_PORT_ERR : + RTW_SCTX_DONE_SUCCESS); spin_unlock_irqrestore(&pxmitpriv->lock_sctx, irqL); rtw_free_xmitbuf23a(pxmitpriv, pxmitbuf); @@ -158,7 +162,7 @@ int usb_write_port23a(struct rtw_adapter *padapter, u32 addr, u32 cnt, struct urb *purb = NULL; struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter); struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct xmit_frame *pxmitframe = (struct xmit_frame *)pxmitbuf->priv_data; + struct xmit_frame *pxmitframe; struct usb_device *pusbd = pdvobj->pusbdev; unsigned long irqL; unsigned int pipe; @@ -167,14 +171,17 @@ int usb_write_port23a(struct rtw_adapter *padapter, u32 addr, u32 cnt, RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("+usb_write_port23a\n")); - if ((padapter->bDriverStopped) || (padapter->bSurpriseRemoved) || - (padapter->pwrctrlpriv.pnp_bstop_trx)) { + if (padapter->bDriverStopped || padapter->bSurpriseRemoved || + padapter->pwrctrlpriv.pnp_bstop_trx) { RT_TRACE(_module_hci_ops_os_c_, _drv_err_, - ("usb_write_port23a:( padapter->bDriverStopped ||padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n")); + ("usb_write_port23a:( padapter->bDriverStopped || " + "padapter->bSurpriseRemoved || " + "adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n")); rtw23a_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_TX_DENY); goto exit; } + pxmitframe = (struct xmit_frame *)pxmitbuf->priv_data; spin_lock_irqsave(&pxmitpriv->lock, irqL); switch (addr) { @@ -204,7 +211,7 @@ int usb_write_port23a(struct rtw_adapter *padapter, u32 addr, u32 cnt, spin_unlock_irqrestore(&pxmitpriv->lock, irqL); - purb = pxmitbuf->pxmit_urb[0]; + purb = pxmitbuf->pxmit_urb[0]; /* translate DMA FIFO addr to pipehandle */ pipe = ffaddr2pipehdl23a(pdvobj, addr); @@ -220,7 +227,7 @@ int usb_write_port23a(struct rtw_adapter *padapter, u32 addr, u32 cnt, phaldata->srestpriv.last_tx_time = jiffies; } else { rtw23a_sctx_done_err(&pxmitbuf->sctx, - RTW_SCTX_DONE_WRITE_PORT_ERR); + RTW_SCTX_DONE_WRITE_PORT_ERR); DBG_8723A("usb_write_port23a, status =%d\n", status); RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port23a(): usb_submit_urb, status =%x\n", -- cgit v1.2.3 From e6ac6eb2aef4a78f21e433d5ce657334d0f77ec5 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:54 +0200 Subject: staging: rtl8723au: os_intfs.c: Various cosmetic cleanups In addition skb->priorty is a u32, so make rtw_classify8021d return a u32 to match. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/os_intfs.c | 71 +++++++++++++----------- drivers/staging/rtl8723au/os_dep/osdep_service.c | 27 --------- 2 files changed, 38 insertions(+), 60 deletions(-) delete mode 100644 drivers/staging/rtl8723au/os_dep/osdep_service.c diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index 9f3df9e45e34..f8cc876fb8e6 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -274,9 +274,9 @@ static struct net_device_stats *rtw_net_get_stats(struct net_device *pnetdev) static const u16 rtw_1d_to_queue[8] = { 2, 3, 3, 2, 1, 1, 0, 0 }; /* Given a data frame determine the 802.1p/1d tag to use. */ -static unsigned int rtw_classify8021d(struct sk_buff *skb) +static u32 rtw_classify8021d(struct sk_buff *skb) { - unsigned int dscp; + u32 dscp; /* skb->priority values from 256->263 are magic values to * directly indicate a specific 802.1d priority. This is used @@ -433,7 +433,6 @@ int rtw_reset_drv_sw23a(struct rtw_adapter *padapter) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; - int ret8 = _SUCCESS; /* hal_priv */ rtl8723a_init_default_value(padapter); @@ -455,7 +454,7 @@ int rtw_reset_drv_sw23a(struct rtw_adapter *padapter) padapter->mlmeextpriv.sitesurvey_res.state = SCAN_DISABLE; rtw_set_signal_stat_timer(&padapter->recvpriv); - return ret8; + return _SUCCESS; } int rtw_init_drv_sw23a(struct rtw_adapter *padapter) @@ -464,7 +463,7 @@ int rtw_init_drv_sw23a(struct rtw_adapter *padapter) RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_init_drv_sw23a\n")); - if ((rtw_init_cmd_priv23a(&padapter->cmdpriv)) == _FAIL) { + if (rtw_init_cmd_priv23a(&padapter->cmdpriv) == _FAIL) { RT_TRACE(_module_os_intfs_c_, _drv_err_, ("\n Can't init cmd_priv\n")); ret8 = _FAIL; @@ -533,29 +532,30 @@ exit: void rtw_cancel_all_timer23a(struct rtw_adapter *padapter) { - RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_cancel_all_timer23a\n")); + RT_TRACE(_module_os_intfs_c_, _drv_info_, + ("+rtw_cancel_all_timer23a\n")); del_timer_sync(&padapter->mlmepriv.assoc_timer); RT_TRACE(_module_os_intfs_c_, _drv_info_, - ("rtw_cancel_all_timer23a:cancel association timer complete!\n")); + ("%s:cancel association timer complete!\n", __func__)); del_timer_sync(&padapter->mlmepriv.scan_to_timer); RT_TRACE(_module_os_intfs_c_, _drv_info_, - ("rtw_cancel_all_timer23a:cancel scan_to_timer!\n")); + ("%s:cancel scan_to_timer!\n", __func__)); del_timer_sync(&padapter->mlmepriv.dynamic_chk_timer); RT_TRACE(_module_os_intfs_c_, _drv_info_, - ("rtw_cancel_all_timer23a:cancel dynamic_chk_timer!\n")); + ("%s:cancel dynamic_chk_timer!\n", __func__)); RT_TRACE(_module_os_intfs_c_, _drv_info_, - ("rtw_cancel_all_timer23a:cancel DeInitSwLeds!\n")); + ("%s:cancel DeInitSwLeds!\n", __func__)); del_timer_sync(&padapter->pwrctrlpriv.pwr_state_check_timer); del_timer_sync(&padapter->mlmepriv.set_scan_deny_timer); rtw_clear_scan_deny(padapter); RT_TRACE(_module_os_intfs_c_, _drv_info_, - ("rtw_cancel_all_timer23a:cancel set_scan_deny_timer!\n")); + ("%s:cancel set_scan_deny_timer!\n", __func__)); del_timer_sync(&padapter->recvpriv.signal_stat_timer); /* cancel dm timer */ @@ -574,7 +574,8 @@ int rtw_free_drv_sw23a(struct rtw_adapter *padapter) _rtw_free_xmit_priv23a(&padapter->xmitpriv); - _rtw_free_sta_priv23a(&padapter->stapriv);/* will free bcmc_stainfo here */ + /* will free bcmc_stainfo here */ + _rtw_free_sta_priv23a(&padapter->stapriv); _rtw_free_recv_priv23a(&padapter->recvpriv); @@ -627,26 +628,30 @@ int rtw_drv_register_netdev(struct rtw_adapter *if1) struct dvobj_priv *dvobj = if1->dvobj; int i, status = _SUCCESS; - if (dvobj->iface_nums < IFACE_ID_MAX) { - for (i = 0; i < dvobj->iface_nums; i++) { - struct rtw_adapter *padapter = dvobj->padapters[i]; - - if (padapter) { - char *name; - - if (padapter->iface_id == IFACE_ID0) - name = if1->registrypriv.ifname; - else if (padapter->iface_id == IFACE_ID1) - name = if1->registrypriv.if2name; - else - name = "wlan%d"; - status = _rtw_drv_register_netdev(padapter, - name); - if (status != _SUCCESS) - break; - } + if (dvobj->iface_nums >= IFACE_ID_MAX) { + status = _FAIL; /* -EINVAL */ + goto exit; + } + + for (i = 0; i < dvobj->iface_nums; i++) { + struct rtw_adapter *padapter = dvobj->padapters[i]; + + if (padapter) { + char *name; + + if (padapter->iface_id == IFACE_ID0) + name = if1->registrypriv.ifname; + else if (padapter->iface_id == IFACE_ID1) + name = if1->registrypriv.if2name; + else + name = "wlan%d"; + status = _rtw_drv_register_netdev(padapter, name); + if (status != _SUCCESS) + break; } } + +exit: return status; } @@ -733,7 +738,7 @@ netdev_open23a_error: goto exit; } -static int ips_netdrv_open(struct rtw_adapter *padapter) +static int ips_netdrv_open(struct rtw_adapter *padapter) { int status = _SUCCESS; @@ -840,8 +845,8 @@ static int netdev_close(struct net_device *pnetdev) padapter->net_closed = true; if (padapter->pwrctrlpriv.rf_pwrstate == rf_on) { - DBG_8723A("(2)871x_drv - drv_close, bup =%d, hw_init_completed =%d\n", - padapter->bup, + DBG_8723A("(2)871x_drv - drv_close, bup =%d, " + "hw_init_completed =%d\n", padapter->bup, padapter->hw_init_completed); /* s1. */ diff --git a/drivers/staging/rtl8723au/os_dep/osdep_service.c b/drivers/staging/rtl8723au/os_dep/osdep_service.c deleted file mode 100644 index f5f385b7932f..000000000000 --- a/drivers/staging/rtl8723au/os_dep/osdep_service.c +++ /dev/null @@ -1,27 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek 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. - * - ******************************************************************************/ - - -#define _OSDEP_SERVICE_C_ - -#include -#include -#include - -void _rtw_init_queue23a(struct rtw_queue *pqueue) -{ - INIT_LIST_HEAD(&pqueue->queue); - spin_lock_init(&pqueue->lock); -} -- cgit v1.2.3 From 633dd914ca2b94e91e453d033724d805d286394a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:55 +0200 Subject: staging: rtl8723au: Move last utility function from osdep_service.c to os_intfs.c No point carrying a dedicated file just for this small helper, so move it to os_intfs.c and get rid of osdep_service.c Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/Makefile | 1 - drivers/staging/rtl8723au/os_dep/os_intfs.c | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/Makefile b/drivers/staging/rtl8723au/Makefile index bbf503dd437a..5146b709efb4 100644 --- a/drivers/staging/rtl8723au/Makefile +++ b/drivers/staging/rtl8723au/Makefile @@ -45,7 +45,6 @@ r8723au-y := \ hal/usb_ops_linux.o \ os_dep/ioctl_cfg80211.o \ os_dep/mlme_linux.o \ - os_dep/osdep_service.o \ os_dep/os_intfs.o \ os_dep/recv_linux.o \ os_dep/usb_intf.o \ diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index f8cc876fb8e6..590028322c44 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -884,3 +884,9 @@ void rtw_ndev_destructor(struct net_device *ndev) kfree(ndev->ieee80211_ptr); free_netdev(ndev); } + +void _rtw_init_queue23a(struct rtw_queue *pqueue) +{ + INIT_LIST_HEAD(&pqueue->queue); + spin_lock_init(&pqueue->lock); +} -- cgit v1.2.3 From 43aeefd925e246a70dd4be8e03a76701ded4918f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:56 +0200 Subject: staging: rtl8723au: Remove unused usb_suspend_sema Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/drv_types.h | 2 -- drivers/staging/rtl8723au/os_dep/usb_intf.c | 1 - 2 files changed, 3 deletions(-) diff --git a/drivers/staging/rtl8723au/include/drv_types.h b/drivers/staging/rtl8723au/include/drv_types.h index 3f2252301139..b652754efb24 100644 --- a/drivers/staging/rtl8723au/include/drv_types.h +++ b/drivers/staging/rtl8723au/include/drv_types.h @@ -178,8 +178,6 @@ struct dvobj_priv { u8 RtNumOutPipes; int ep_num[5]; /* endpoint number */ - struct semaphore usb_suspend_sema; - struct mutex usb_vendor_req_mutex; u8 *usb_alloc_vendor_req_buf; diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index 97a2bc6102b5..b3965920b87c 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -227,7 +227,6 @@ static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf) goto free_dvobj; } /* 3 misc */ - sema_init(&(pdvobjpriv->usb_suspend_sema), 0); rtw_reset_continual_urb_error(pdvobjpriv); usb_get_dev(pusbd); status = _SUCCESS; -- cgit v1.2.3 From c174eae6f71bf3da736460e7872cdfc23c854fbc Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:57 +0200 Subject: staging: rtl8723au: Call rtl8723au_set_hw_type() directly Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/usb_ops.h | 1 - drivers/staging/rtl8723au/os_dep/usb_intf.c | 10 +--------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/include/usb_ops.h b/drivers/staging/rtl8723au/include/usb_ops.h index 2836631dee83..58878dc36e76 100644 --- a/drivers/staging/rtl8723au/include/usb_ops.h +++ b/drivers/staging/rtl8723au/include/usb_ops.h @@ -43,7 +43,6 @@ enum { (timeout_ms)) void rtl8723au_set_hw_type(struct rtw_adapter *padapter); -#define hal_set_hw_type rtl8723au_set_hw_type void rtl8723au_set_intf_ops(struct rtw_adapter *padapter); diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index b3965920b87c..556b97659f7d 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -275,13 +275,6 @@ static void usb_dvobj_deinit(struct usb_interface *usb_intf) usb_put_dev(interface_to_usbdev(usb_intf)); } -static void decide_chip_type_by_usb_device_id(struct rtw_adapter *padapter, - const struct usb_device_id *pdid) -{ - padapter->chip_type = NULL_CHIP_TYPE; - hal_set_hw_type(padapter); -} - static void usb_intf_start(struct rtw_adapter *padapter) { RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+usb_intf_start\n")); @@ -601,8 +594,7 @@ static struct rtw_adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, dvobj->padapters[dvobj->iface_nums++] = padapter; padapter->iface_id = IFACE_ID0; - /* step 1-1., decide the chip_type via vid/pid */ - decide_chip_type_by_usb_device_id(padapter, pdid); + rtl8723au_set_hw_type(padapter); if (rtw_handle_dualmac23a(padapter, 1) != _SUCCESS) goto free_adapter; -- cgit v1.2.3 From 596f85adaac5259b2019d41a0e34292efe8df511 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:58 +0200 Subject: staging: rtl8723au: Call usb_intf_{start,stop} directly Rip out multiple layer of useless wrappers Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/drv_types.h | 3 --- drivers/staging/rtl8723au/include/osdep_intf.h | 4 ++++ drivers/staging/rtl8723au/include/usb_ops.h | 2 -- drivers/staging/rtl8723au/os_dep/os_intfs.c | 9 +++------ drivers/staging/rtl8723au/os_dep/usb_intf.c | 15 ++------------- 5 files changed, 9 insertions(+), 24 deletions(-) diff --git a/drivers/staging/rtl8723au/include/drv_types.h b/drivers/staging/rtl8723au/include/drv_types.h index b652754efb24..6724c58b1ed6 100644 --- a/drivers/staging/rtl8723au/include/drv_types.h +++ b/drivers/staging/rtl8723au/include/drv_types.h @@ -251,9 +251,6 @@ struct rtw_adapter { u8 init_adpt_in_progress; u8 bHaltInProgress; - void (*intf_start)(struct rtw_adapter *adapter); - void (*intf_stop)(struct rtw_adapter *adapter); - struct net_device *pnetdev; /* used by rtw_rereg_nd_name related function */ diff --git a/drivers/staging/rtl8723au/include/osdep_intf.h b/drivers/staging/rtl8723au/include/osdep_intf.h index 9e77156d51d2..33afa62f31b1 100644 --- a/drivers/staging/rtl8723au/include/osdep_intf.h +++ b/drivers/staging/rtl8723au/include/osdep_intf.h @@ -41,4 +41,8 @@ void rtw_ips_pwr_down23a(struct rtw_adapter *padapter); int rtw_drv_register_netdev(struct rtw_adapter *padapter); void rtw_ndev_destructor(struct net_device *ndev); +int rtl8723au_inirp_init(struct rtw_adapter *Adapter); +int rtl8723au_inirp_deinit(struct rtw_adapter *Adapter); +void rtl8723a_usb_intf_stop(struct rtw_adapter *padapter); + #endif /* _OSDEP_INTF_H_ */ diff --git a/drivers/staging/rtl8723au/include/usb_ops.h b/drivers/staging/rtl8723au/include/usb_ops.h index 58878dc36e76..a5fd432be918 100644 --- a/drivers/staging/rtl8723au/include/usb_ops.h +++ b/drivers/staging/rtl8723au/include/usb_ops.h @@ -91,8 +91,6 @@ static inline u8 rtw_usb_bulk_size_boundary(struct rtw_adapter *padapter, return rst; } -int rtl8723au_inirp_init(struct rtw_adapter *Adapter); -int rtl8723au_inirp_deinit(struct rtw_adapter *Adapter); void rtl8723au_chip_configure(struct rtw_adapter *padapter); #endif /* __USB_OPS_H_ */ diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index 590028322c44..9161e5cda9a5 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -693,8 +693,7 @@ int netdev_open23a(struct net_device *pnetdev) goto netdev_open23a_error; } - if (padapter->intf_start) - padapter->intf_start(padapter); + rtl8723au_inirp_init(padapter); rtw_cfg80211_init_wiphy(padapter); @@ -756,8 +755,7 @@ static int ips_netdrv_open(struct rtw_adapter *padapter) goto netdev_open23a_error; } - if (padapter->intf_start) - padapter->intf_start(padapter); + rtl8723au_inirp_init(padapter); rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv); mod_timer(&padapter->mlmepriv.dynamic_chk_timer, @@ -811,8 +809,7 @@ void rtw_ips_dev_unload23a(struct rtw_adapter *padapter) { rtl8723a_fifo_cleanup(padapter); - if (padapter->intf_stop) - padapter->intf_stop(padapter); + rtl8723a_usb_intf_stop(padapter); /* s5. */ if (!padapter->bSurpriseRemoved) diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index 556b97659f7d..38f2af3badbf 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -275,14 +275,7 @@ static void usb_dvobj_deinit(struct usb_interface *usb_intf) usb_put_dev(interface_to_usbdev(usb_intf)); } -static void usb_intf_start(struct rtw_adapter *padapter) -{ - RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+usb_intf_start\n")); - rtl8723au_inirp_init(padapter); - RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-usb_intf_start\n")); -} - -static void usb_intf_stop(struct rtw_adapter *padapter) +void rtl8723a_usb_intf_stop(struct rtw_adapter *padapter) { RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+usb_intf_stop\n")); @@ -318,8 +311,7 @@ static void rtw_dev_unload(struct rtw_adapter *padapter) RTW_SCTX_DONE_DRV_STOP); /* s3. */ - if (padapter->intf_stop) - padapter->intf_stop(padapter); + rtl8723a_usb_intf_stop(padapter); /* s4. */ if (!padapter->pwrctrlpriv.bInternalAutoSuspend) @@ -609,9 +601,6 @@ static struct rtw_adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, if (!padapter->HalData) goto free_wdev; - padapter->intf_start = &usb_intf_start; - padapter->intf_stop = &usb_intf_stop; - rtl8723au_set_intf_ops(padapter); /* step read_chip_version */ -- cgit v1.2.3 From 4631e5055eda1e52fdfe952b9e56f9f5743f3910 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:59 +0200 Subject: staging: rtl8723au: Don't wrap calls to usb_control_msg() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_ops_linux.c | 6 +++--- drivers/staging/rtl8723au/include/usb_ops.h | 4 ---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index be43863d1c2d..e156377b681e 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -73,9 +73,9 @@ static int usbctrl_vendorreq(struct rtw_adapter *padapter, u8 request, memcpy(pIo_buf, pdata, len); } - status = rtw_usb_control_msg(udev, pipe, request, reqtype, - value, index, pIo_buf, len, - RTW_USB_CONTROL_MSG_TIMEOUT); + status = usb_control_msg(udev, pipe, request, reqtype, + value, index, pIo_buf, len, + RTW_USB_CONTROL_MSG_TIMEOUT); if (status == len) { /* Success this control transfer. */ rtw_reset_continual_urb_error(pdvobjpriv); diff --git a/drivers/staging/rtl8723au/include/usb_ops.h b/drivers/staging/rtl8723au/include/usb_ops.h index a5fd432be918..be75c9f16444 100644 --- a/drivers/staging/rtl8723au/include/usb_ops.h +++ b/drivers/staging/rtl8723au/include/usb_ops.h @@ -34,10 +34,6 @@ enum { #define MAX_VENDOR_REQ_CMD_SIZE 254 /* 8188cu SIE Support */ #define MAX_USB_IO_CTL_SIZE (MAX_VENDOR_REQ_CMD_SIZE +ALIGNMENT_UNIT) -#define rtw_usb_control_msg(dev, pipe, request, requesttype, value, \ - index, data, size, timeout_ms) \ - usb_control_msg((dev), (pipe), (request), (requesttype), \ - (value), (index), (data), (size), (timeout_ms)) #define rtw_usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout_ms) \ usb_bulk_msg((usb_dev), (pipe), (data), (len), (actual_length), \ (timeout_ms)) -- cgit v1.2.3 From a64ddc8d4e0fffd7f1c433fc7f31c5803735a5a5 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:05:00 +0200 Subject: staging: rtl8723au: Remove unused USB bulk related macros and variables Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_halinit.c | 8 -------- drivers/staging/rtl8723au/include/rtl8723a_hal.h | 5 ----- drivers/staging/rtl8723au/include/usb_ops.h | 22 ---------------------- 3 files changed, 35 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index ccc57fddd780..9ef333c031e2 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -85,14 +85,6 @@ void rtl8723au_chip_configure(struct rtw_adapter *padapter) struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter); - if (pdvobjpriv->ishighspeed == true) { - /* 512 bytes */ - pHalData->UsbBulkOutSize = USB_HIGH_SPEED_BULK_SIZE; - } else { - /* 64 bytes */ - pHalData->UsbBulkOutSize = USB_FULL_SPEED_BULK_SIZE; - } - pHalData->interfaceIndex = pdvobjpriv->InterfaceNumber; rtl8723au_set_queue_pipe_mapping(padapter, diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index c22bb811aa01..1aa65e067209 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -413,11 +413,6 @@ struct hal_data_8723a { bool bMACFuncEnable; - /* */ - /* For USB Interface HAL related */ - /* */ - u32 UsbBulkOutSize; - /* Interrupt related register information. */ u32 IntArray[2]; u32 IntrMask[2]; diff --git a/drivers/staging/rtl8723au/include/usb_ops.h b/drivers/staging/rtl8723au/include/usb_ops.h index be75c9f16444..977805d97b34 100644 --- a/drivers/staging/rtl8723au/include/usb_ops.h +++ b/drivers/staging/rtl8723au/include/usb_ops.h @@ -34,10 +34,6 @@ enum { #define MAX_VENDOR_REQ_CMD_SIZE 254 /* 8188cu SIE Support */ #define MAX_USB_IO_CTL_SIZE (MAX_VENDOR_REQ_CMD_SIZE +ALIGNMENT_UNIT) -#define rtw_usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout_ms) \ - usb_bulk_msg((usb_dev), (pipe), (data), (len), (actual_length), \ - (timeout_ms)) - void rtl8723au_set_hw_type(struct rtw_adapter *padapter); void rtl8723au_set_intf_ops(struct rtw_adapter *padapter); @@ -69,24 +65,6 @@ static inline void rtw_reset_continual_urb_error(struct dvobj_priv *dvobj) atomic_set(&dvobj->continual_urb_error, 0); } -#define USB_HIGH_SPEED_BULK_SIZE 512 -#define USB_FULL_SPEED_BULK_SIZE 64 - -static inline u8 rtw_usb_bulk_size_boundary(struct rtw_adapter *padapter, - int buf_len) -{ - u8 rst = true; - struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter); - - if (pdvobjpriv->ishighspeed) - rst = (0 == (buf_len) % USB_HIGH_SPEED_BULK_SIZE) ? - true : false; - else - rst = (0 == (buf_len) % USB_FULL_SPEED_BULK_SIZE) ? - true : false; - return rst; -} - void rtl8723au_chip_configure(struct rtw_adapter *padapter); #endif /* __USB_OPS_H_ */ -- cgit v1.2.3 From 2296fd2d928c2cb9d601cdeef5e41eea4c120b88 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:05:01 +0200 Subject: staging: rtl8723au: Remove nasty wrappers used to hide wrong function types Do not use #defines to hack around pre-history functions not matching current APIs Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_ops_linux.c | 4 ++-- drivers/staging/rtl8723au/include/usb_ops_linux.h | 7 ------- drivers/staging/rtl8723au/os_dep/usb_ops_linux.c | 2 +- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index e156377b681e..2eba530a1c6c 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -343,7 +343,7 @@ InterruptRecognized8723AU(struct rtw_adapter *Adapter, void *pContent, (pHalData->IntArray[1] & pHalData->IntrMask[1]) != 0; } -static void usb_read_interrupt_complete(struct urb *purb, struct pt_regs *regs) +static void usb_read_interrupt_complete(struct urb *purb) { int err; struct rtw_adapter *padapter = (struct rtw_adapter *)purb->context; @@ -643,7 +643,7 @@ void rtl8723au_recv_tasklet(void *priv) } } -static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) +static void usb_read_port_complete(struct urb *purb) { struct recv_buf *precvbuf = (struct recv_buf *)purb->context; struct rtw_adapter *padapter = (struct rtw_adapter *)precvbuf->adapter; diff --git a/drivers/staging/rtl8723au/include/usb_ops_linux.h b/drivers/staging/rtl8723au/include/usb_ops_linux.h index 814bc2005c05..fb75ff3582ae 100644 --- a/drivers/staging/rtl8723au/include/usb_ops_linux.h +++ b/drivers/staging/rtl8723au/include/usb_ops_linux.h @@ -24,13 +24,6 @@ #define RTW_USB_BULKOUT_TIMEOUT 5000/* ms */ -#define _usbctrl_vendorreq_async_callback(urb, regs) \ - _usbctrl_vendorreq_async_callback(urb) -#define usb_write_port23a_complete(purb, regs) usb_write_port23a_complete(purb) -#define usb_read_port_complete(purb, regs) usb_read_port_complete(purb) -#define usb_read_interrupt_complete(purb, regs) \ - usb_read_interrupt_complete(purb) - unsigned int ffaddr2pipehdl23a(struct dvobj_priv *pdvobj, u32 addr); void usb_read_port_cancel23a(struct rtw_adapter *adapter); diff --git a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c index 6af475707bb8..3bcb781a9d50 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c @@ -60,7 +60,7 @@ void usb_read_port_cancel23a(struct rtw_adapter *padapter) usb_kill_urb(padapter->recvpriv.int_in_urb); } -static void usb_write_port23a_complete(struct urb *purb, struct pt_regs *regs) +static void usb_write_port23a_complete(struct urb *purb) { struct xmit_buf *pxmitbuf = (struct xmit_buf *)purb->context; struct rtw_adapter *padapter = pxmitbuf->padapter; -- cgit v1.2.3 From 428891a3cb566dac159351d86e3619320f0fb6c3 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:05:02 +0200 Subject: staging: rtl8723au: usb_ops_linux.h: Remove some unused #defines Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/usb_ops_linux.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/rtl8723au/include/usb_ops_linux.h b/drivers/staging/rtl8723au/include/usb_ops_linux.h index fb75ff3582ae..f46b81b7d259 100644 --- a/drivers/staging/rtl8723au/include/usb_ops_linux.h +++ b/drivers/staging/rtl8723au/include/usb_ops_linux.h @@ -17,13 +17,10 @@ #define VENDOR_CMD_MAX_DATA_LEN 254 -#define RTW_USB_CONTROL_MSG_TIMEOUT_TEST 10/* ms */ #define RTW_USB_CONTROL_MSG_TIMEOUT 500/* ms */ #define MAX_USBCTRL_VENDORREQ_TIMES 10 -#define RTW_USB_BULKOUT_TIMEOUT 5000/* ms */ - unsigned int ffaddr2pipehdl23a(struct dvobj_priv *pdvobj, u32 addr); void usb_read_port_cancel23a(struct rtw_adapter *adapter); -- cgit v1.2.3 From af1853da17137a9577792affd4c6df4b8d32dccf Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:05:03 +0200 Subject: staging: rtl8723au: Clean up mess of parenthesis abuse Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/ieee80211.h | 88 +++++++++++++++------------ 1 file changed, 49 insertions(+), 39 deletions(-) diff --git a/drivers/staging/rtl8723au/include/ieee80211.h b/drivers/staging/rtl8723au/include/ieee80211.h index ef788b54b0b5..ee600ab7d1c7 100644 --- a/drivers/staging/rtl8723au/include/ieee80211.h +++ b/drivers/staging/rtl8723au/include/ieee80211.h @@ -58,7 +58,7 @@ #define WPA_CIPHER_NONE BIT(0) #define WPA_CIPHER_WEP40 BIT(1) -#define WPA_CIPHER_WEP104 BIT(2) +#define WPA_CIPHER_WEP104 BIT(2) #define WPA_CIPHER_TKIP BIT(3) #define WPA_CIPHER_CCMP BIT(4) @@ -105,41 +105,53 @@ enum ratr_table_mode { enum NETWORK_TYPE { - WIRELESS_INVALID = 0, - /* Sub-Element */ - WIRELESS_11B = BIT(0), /* tx: cck only , rx: cck only, hw: cck */ - WIRELESS_11G = BIT(1), /* tx: ofdm only, rx: ofdm & cck, hw: cck & ofdm */ - WIRELESS_11A = BIT(2), /* tx: ofdm only, rx: ofdm only, hw: ofdm only */ - WIRELESS_11_24N = BIT(3), /* tx: MCS only, rx: MCS & cck, hw: MCS & cck */ - WIRELESS_11_5N = BIT(4), /* tx: MCS only, rx: MCS & ofdm, hw: ofdm only */ + WIRELESS_INVALID = 0, + /* Sub-Element */ + /* tx: cck only , rx: cck only, hw: cck */ + WIRELESS_11B = BIT(0), + /* tx: ofdm only, rx: ofdm & cck, hw: cck & ofdm */ + WIRELESS_11G = BIT(1), + /* tx: ofdm only, rx: ofdm only, hw: ofdm only */ + WIRELESS_11A = BIT(2), + /* tx: MCS only, rx: MCS & cck, hw: MCS & cck */ + WIRELESS_11_24N = BIT(3), + /* tx: MCS only, rx: MCS & ofdm, hw: ofdm only */ + WIRELESS_11_5N = BIT(4), /* WIRELESS_AUTO = BIT(5), */ - WIRELESS_AC = BIT(6), - - /* Combination */ - WIRELESS_11BG = (WIRELESS_11B|WIRELESS_11G), /* tx: cck & ofdm, rx: cck & ofdm & MCS, hw: cck & ofdm */ - WIRELESS_11G_24N = (WIRELESS_11G|WIRELESS_11_24N), /* tx: ofdm & MCS, rx: ofdm & cck & MCS, hw: cck & ofdm */ - WIRELESS_11A_5N = (WIRELESS_11A|WIRELESS_11_5N), /* tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */ - WIRELESS_11BG_24N = (WIRELESS_11B|WIRELESS_11G|WIRELESS_11_24N), /* tx: ofdm & cck & MCS, rx: ofdm & cck & MCS, hw: ofdm & cck */ - WIRELESS_11AGN = (WIRELESS_11A|WIRELESS_11G|WIRELESS_11_24N|WIRELESS_11_5N), /* tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */ - WIRELESS_11ABGN = (WIRELESS_11A|WIRELESS_11B|WIRELESS_11G|WIRELESS_11_24N|WIRELESS_11_5N), + WIRELESS_AC = BIT(6), + + /* Combination */ + /* tx: cck & ofdm, rx: cck & ofdm & MCS, hw: cck & ofdm */ + WIRELESS_11BG = WIRELESS_11B|WIRELESS_11G, + /* tx: ofdm & MCS, rx: ofdm & cck & MCS, hw: cck & ofdm */ + WIRELESS_11G_24N = WIRELESS_11G | WIRELESS_11_24N, + /* tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */ + WIRELESS_11A_5N = WIRELESS_11A | WIRELESS_11_5N, + /* tx: ofdm & cck & MCS, rx: ofdm & cck & MCS, hw: ofdm & cck */ + WIRELESS_11BG_24N = WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N, + /* tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */ + WIRELESS_11AGN = WIRELESS_11A | WIRELESS_11G | WIRELESS_11_24N | + WIRELESS_11_5N, + WIRELESS_11ABGN = WIRELESS_11A | WIRELESS_11B | WIRELESS_11G | + WIRELESS_11_24N | WIRELESS_11_5N, }; #define SUPPORTED_24G_NETTYPE_MSK (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N) #define SUPPORTED_5G_NETTYPE_MSK (WIRELESS_11A | WIRELESS_11_5N) -#define IsSupported24G(NetType) ((NetType) & SUPPORTED_24G_NETTYPE_MSK ? true : false) -#define IsSupported5G(NetType) ((NetType) & SUPPORTED_5G_NETTYPE_MSK ? true : false) +#define IsSupported24G(NetType) (NetType & SUPPORTED_24G_NETTYPE_MSK ? true : false) +#define IsSupported5G(NetType) (NetType & SUPPORTED_5G_NETTYPE_MSK ? true : false) #define IsEnableHWCCK(NetType) IsSupported24G(NetType) -#define IsEnableHWOFDM(NetType) ((NetType) & (WIRELESS_11G|WIRELESS_11_24N|SUPPORTED_5G_NETTYPE_MSK) ? true : false) +#define IsEnableHWOFDM(NetType) (NetType & (WIRELESS_11G|WIRELESS_11_24N|SUPPORTED_5G_NETTYPE_MSK) ? true : false) #define IsSupportedRxCCK(NetType) IsEnableHWCCK(NetType) #define IsSupportedRxOFDM(NetType) IsEnableHWOFDM(NetType) #define IsSupportedRxMCS(NetType) IsEnableHWOFDM(NetType) -#define IsSupportedTxCCK(NetType) ((NetType) & (WIRELESS_11B) ? true : false) -#define IsSupportedTxOFDM(NetType) ((NetType) & (WIRELESS_11G|WIRELESS_11A) ? true : false) -#define IsSupportedTxMCS(NetType) ((NetType) & (WIRELESS_11_24N|WIRELESS_11_5N) ? true : false) +#define IsSupportedTxCCK(NetType) (NetType & (WIRELESS_11B) ? true : false) +#define IsSupportedTxOFDM(NetType) (NetType & (WIRELESS_11G|WIRELESS_11A) ? true : false) +#define IsSupportedTxMCS(NetType) (NetType & (WIRELESS_11_24N|WIRELESS_11_5N) ? true : false) struct ieee_param { @@ -192,7 +204,7 @@ struct ieee_param { /* QoS,QOS */ #define NORMAL_ACK 0 #define NO_ACK 1 -#define NON_EXPLICIT_ACK 2 +#define NON_EXPLICIT_ACK 2 #define BLOCK_ACK 3 /* IEEE 802.11 defines */ @@ -200,24 +212,22 @@ struct ieee_param { #define P80211_OUI_LEN 3 struct ieee80211_snap_hdr { - u8 dsap; /* always 0xAA */ u8 ssap; /* always 0xAA */ u8 ctrl; /* always 0x03 */ u8 oui[P80211_OUI_LEN]; /* organizational universal id */ - } __attribute__ ((packed)); #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr) -#define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE) -#define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE) +#define WLAN_FC_GET_TYPE(fc) (fc & IEEE80211_FCTL_FTYPE) +#define WLAN_FC_GET_STYPE(fc) (fc & IEEE80211_FCTL_STYPE) -#define WLAN_QC_GET_TID(qc) ((qc) & 0x0f) +#define WLAN_QC_GET_TID(qc) (qc & 0x0f) -#define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTW_IEEE80211_SCTL_FRAG) -#define WLAN_GET_SEQ_SEQ(seq) ((seq) & RTW_IEEE80211_SCTL_SEQ) +#define WLAN_GET_SEQ_FRAG(seq) (seq & RTW_IEEE80211_SCTL_FRAG) +#define WLAN_GET_SEQ_SEQ(seq) (seq & RTW_IEEE80211_SCTL_SEQ) #define WLAN_REASON_JOIN_WRONG_CHANNEL 65534 @@ -302,16 +312,16 @@ struct ieee80211_snap_hdr { * only use 8, and then use extended rates for the remaining supported * rates. Other APs, however, stick all of their supported rates on the * main rates information element... */ -#define MAX_RATES_LENGTH ((u8)12) -#define MAX_RATES_EX_LENGTH ((u8)16) -#define MAX_CHANNEL_NUMBER 161 +#define MAX_RATES_LENGTH 12 +#define MAX_RATES_EX_LENGTH 16 +#define MAX_CHANNEL_NUMBER 161 -#define MAX_WPA_IE_LEN (256) -#define MAX_WPS_IE_LEN (512) -#define MAX_P2P_IE_LEN (256) -#define MAX_WFD_IE_LEN (128) +#define MAX_WPA_IE_LEN 256 +#define MAX_WPS_IE_LEN 512 +#define MAX_P2P_IE_LEN 256 +#define MAX_WFD_IE_LEN 128 -#define IW_ESSID_MAX_SIZE 32 +#define IW_ESSID_MAX_SIZE 32 /* join_res: -- cgit v1.2.3 From 4810ce070e3348120e900f8ac8f53f39397d8cd8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:05:04 +0200 Subject: staging: rtl8723au: Use correct pipe type for USB interrupts Use a correct pipe type when filling un interrupt urbs. This should finally take care of the WARN() messages on the console when USB urbs are submitted. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/usb_ops_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c index 3bcb781a9d50..3ef38706a21d 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c @@ -26,7 +26,7 @@ unsigned int ffaddr2pipehdl23a(struct dvobj_priv *pdvobj, u32 addr) if (addr == RECV_BULK_IN_ADDR) { pipe = usb_rcvbulkpipe(pusbd, pdvobj->RtInPipe[0]); } else if (addr == RECV_INT_IN_ADDR) { - pipe = usb_rcvbulkpipe(pusbd, pdvobj->RtInPipe[1]); + pipe = usb_rcvintpipe(pusbd, pdvobj->RtInPipe[1]); } else if (addr < HW_QUEUE_ENTRY) { ep_num = pdvobj->Queue2Pipe[addr]; pipe = usb_sndbulkpipe(pusbd, ep_num); -- cgit v1.2.3 From 97ccc3a6bead88e637c0150b19aaea27387ba6f7 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:05:05 +0200 Subject: staging: rtl8723au: Clean up usb_{read,write}_port() usage Get rid of silly HAL convolution for calling usb_{read,write}_port() functions. Benefit from fact we just have one input address for read_port, so no point storing this and carrying it around. Pick pipe in the local function instead of based on dst/src address. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_io.c | 28 ----------------------- drivers/staging/rtl8723au/hal/rtl8723au_xmit.c | 3 ++- drivers/staging/rtl8723au/hal/usb_halinit.c | 10 ++------ drivers/staging/rtl8723au/hal/usb_ops_linux.c | 23 ++++++++----------- drivers/staging/rtl8723au/include/rtw_io.h | 11 --------- drivers/staging/rtl8723au/include/rtw_recv.h | 1 - drivers/staging/rtl8723au/include/usb_ops_linux.h | 4 ++++ drivers/staging/rtl8723au/os_dep/usb_ops_linux.c | 25 ++++---------------- 8 files changed, 23 insertions(+), 82 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_io.c b/drivers/staging/rtl8723au/core/rtw_io.c index 0f26ea8de216..532ad758372f 100644 --- a/drivers/staging/rtl8723au/core/rtw_io.c +++ b/drivers/staging/rtl8723au/core/rtw_io.c @@ -115,23 +115,6 @@ int _rtw_writeN23a(struct rtw_adapter *adapter, u32 addr , u32 length , u8 *pdat return _SUCCESS; } -int _rtw_read_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, - struct recv_buf *rbuf) -{ - struct _io_ops *io_ops = &adapter->io_ops; - - if ((adapter->bDriverStopped == true) || - (adapter->bSurpriseRemoved == true)) { - RT_TRACE(_module_rtl871x_io_c_, _drv_info_, - ("rtw_read_port:bDriverStopped(%d) OR " - "bSurpriseRemoved(%d)", adapter->bDriverStopped, - adapter->bSurpriseRemoved)); - return _FAIL; - } - - return io_ops->_read_port(adapter, addr, cnt, rbuf); -} - void _rtw_read_port23a_cancel(struct rtw_adapter *adapter) { void (*_read_port_cancel)(struct rtw_adapter *adapter); @@ -143,17 +126,6 @@ void _rtw_read_port23a_cancel(struct rtw_adapter *adapter) _read_port_cancel(adapter); } -int _rtw_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, - struct xmit_buf *xbuf) -{ - struct _io_ops *io_ops = &adapter->io_ops; - int ret = _SUCCESS; - - ret = io_ops->_write_port(adapter, addr, cnt, xbuf); - - return ret; -} - void _rtw_write_port23a_cancel(struct rtw_adapter *adapter) { void (*_write_port_cancel)(struct rtw_adapter *adapter); diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c b/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c index 113144c3c02f..45bd67e88e0e 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c +++ b/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c @@ -345,7 +345,8 @@ static int rtw_dump_xframe(struct rtw_adapter *padapter, } ff_hwaddr = rtw_get_ff_hwaddr23a(pxmitframe); - inner_ret = rtw_write_port(padapter, ff_hwaddr, w_sz, pxmitbuf); + inner_ret = rtl8723a_usb_write_port(padapter, ff_hwaddr, + w_sz, pxmitbuf); rtw_count_tx_stats23a(padapter, pxmitframe, sz); RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 9ef333c031e2..11b33e6fd709 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1220,24 +1220,18 @@ int rtl8723au_inirp_init(struct rtw_adapter *Adapter) int status; struct _io_ops *io_ops = &Adapter->io_ops; struct recv_priv *precvpriv = &Adapter->recvpriv; - int (*_read_port)(struct rtw_adapter *padapter, u32 addr, u32 cnt, - struct recv_buf *rbuf); int (*_read_interrupt)(struct rtw_adapter *padapter, u32 addr); struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); - _read_port = io_ops->_read_port; - status = _SUCCESS; RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("===> usb_inirp_init\n")); - precvpriv->ff_hwaddr = RECV_BULK_IN_ADDR; - /* issue Rx irp to receive data */ precvbuf = (struct recv_buf *)precvpriv->precv_buf; for (i = 0; i < NR_RECVBUFF; i++) { - if (_read_port(Adapter, precvpriv->ff_hwaddr, 0, precvbuf) == - _FAIL) { + if (rtl8723a_usb_read_port(Adapter, RECV_BULK_IN_ADDR, 0, + precvbuf) == _FAIL) { RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("usb_rx_init: usb_read_port error\n")); status = _FAIL; diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index 2eba530a1c6c..cb83758393b3 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -457,7 +457,7 @@ static int usb_read_interrupt(struct rtw_adapter *adapter, u32 addr) struct usb_device *pusbd = pdvobj->pusbdev; /* translate DMA FIFO addr to pipehandle */ - pipe = ffaddr2pipehdl23a(pdvobj, addr); + pipe = usb_rcvintpipe(pusbd, pdvobj->RtInPipe[1]); usb_fill_int_urb(precvpriv->int_in_urb, pusbd, pipe, precvpriv->int_in_buf, USB_INTR_CONTENT_LENGTH, @@ -676,8 +676,8 @@ static void usb_read_port_complete(struct urb *purb) ("usb_read_port_complete: (purb->actual_" "length > MAX_RECVBUF_SZ) || (purb->actual_" "length < RXDESC_SIZE)\n")); - rtw_read_port(padapter, precvpriv->ff_hwaddr, 0, - precvbuf); + rtl8723a_usb_read_port(padapter, RECV_BULK_IN_ADDR, 0, + precvbuf); DBG_8723A("%s()-%d: RX Warning!\n", __FUNCTION__, __LINE__); } else { @@ -692,8 +692,8 @@ static void usb_read_port_complete(struct urb *purb) tasklet_schedule(&precvpriv->recv_tasklet); precvbuf->pskb = NULL; - rtw_read_port(padapter, precvpriv->ff_hwaddr, 0, - precvbuf); + rtl8723a_usb_read_port(padapter, RECV_BULK_IN_ADDR, 0, + precvbuf); } } else { RT_TRACE(_module_hci_ops_os_c_, _drv_err_, @@ -730,8 +730,8 @@ static void usb_read_port_complete(struct urb *purb) pHalData = GET_HAL_DATA(padapter); pHalData->srestpriv.Wifi_Error_Status = USB_READ_PORT_FAIL; - rtw_read_port(padapter, precvpriv->ff_hwaddr, - 0, precvbuf); + rtl8723a_usb_read_port(padapter, RECV_BULK_IN_ADDR, 0, + precvbuf); break; case -EINPROGRESS: DBG_8723A("ERROR: URB IS IN PROGRESS!/n"); @@ -742,8 +742,8 @@ static void usb_read_port_complete(struct urb *purb) } } -static int usb_read_port(struct rtw_adapter *adapter, u32 addr, u32 cnt, - struct recv_buf *precvbuf) +int rtl8723a_usb_read_port(struct rtw_adapter *adapter, u32 addr, u32 cnt, + struct recv_buf *precvbuf) { int err; unsigned int pipe; @@ -791,7 +791,7 @@ static int usb_read_port(struct rtw_adapter *adapter, u32 addr, u32 cnt, purb = precvbuf->purb; /* translate DMA FIFO addr to pipehandle */ - pipe = ffaddr2pipehdl23a(pdvobj, addr); + pipe = usb_rcvbulkpipe(pusbd, pdvobj->RtInPipe[0]); usb_fill_bulk_urb(purb, pusbd, pipe, precvbuf->pskb->data, MAX_RECVBUF_SZ, usb_read_port_complete, @@ -842,15 +842,12 @@ void rtl8723au_set_intf_ops(struct rtw_adapter *padapter) pops->_read8 = &usb_read8; pops->_read16 = &usb_read16; pops->_read32 = &usb_read32; - pops->_read_port = &usb_read_port; pops->_write8 = &usb_write8; pops->_write16 = &usb_write16; pops->_write32 = &usb_write32; pops->_writeN = &usb_writeN; - pops->_write_port = &usb_write_port23a; - pops->_read_port_cancel = &usb_read_port_cancel23a; pops->_write_port_cancel = &usb_write_port23a_cancel; diff --git a/drivers/staging/rtl8723au/include/rtw_io.h b/drivers/staging/rtl8723au/include/rtw_io.h index f303213b42a7..192e16764d9a 100644 --- a/drivers/staging/rtl8723au/include/rtw_io.h +++ b/drivers/staging/rtl8723au/include/rtw_io.h @@ -112,11 +112,6 @@ struct _io_ops int (*_read_interrupt)(struct rtw_adapter *adapter, u32 addr); - int (*_read_port)(struct rtw_adapter *adapter, u32 addr, u32 cnt, - struct recv_buf *rbuf); - int (*_write_port)(struct rtw_adapter *adapter, u32 addr, u32 cnt, - struct xmit_buf *pmem); - void (*_read_port_cancel)(struct rtw_adapter *adapter); void (*_write_port_cancel)(struct rtw_adapter *adapter); }; @@ -253,7 +248,6 @@ void _rtw_attrib_write(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem) u8 _rtw_read823a(struct rtw_adapter *adapter, u32 addr); u16 _rtw_read1623a(struct rtw_adapter *adapter, u32 addr); u32 _rtw_read3223a(struct rtw_adapter *adapter, u32 addr); -int _rtw_read_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct recv_buf *rbuf); void _rtw_read_port23a_cancel(struct rtw_adapter *adapter); int _rtw_write823a(struct rtw_adapter *adapter, u32 addr, u8 val); @@ -261,7 +255,6 @@ int _rtw_write1623a(struct rtw_adapter *adapter, u32 addr, u16 val); int _rtw_write3223a(struct rtw_adapter *adapter, u32 addr, u32 val); int _rtw_writeN23a(struct rtw_adapter *adapter, u32 addr, u32 length, u8 *pdata); -int _rtw_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct xmit_buf *pmem); void _rtw_write_port23a_cancel(struct rtw_adapter *adapter); #ifdef DBG_IO @@ -280,7 +273,6 @@ int dbg_rtw_writeN23a(struct rtw_adapter *adapter, u32 addr ,u32 length , u8 *da #define rtw_read8(adapter, addr) dbg_rtw_read823a((adapter), (addr), __FUNCTION__, __LINE__) #define rtw_read16(adapter, addr) dbg_rtw_read1623a((adapter), (addr), __FUNCTION__, __LINE__) #define rtw_read32(adapter, addr) dbg_rtw_read3223a((adapter), (addr), __FUNCTION__, __LINE__) -#define rtw_read_port(adapter, addr, cnt, mem) _rtw_read_port23a((adapter), (addr), (cnt), (mem)) #define rtw_read_port_cancel(adapter) _rtw_read_port23a_cancel((adapter)) #define rtw_write8(adapter, addr, val) dbg_rtw_write823a((adapter), (addr), (val), __FUNCTION__, __LINE__) @@ -288,13 +280,11 @@ int dbg_rtw_writeN23a(struct rtw_adapter *adapter, u32 addr ,u32 length , u8 *da #define rtw_write32(adapter, addr, val) dbg_rtw_write3223a((adapter), (addr), (val), __FUNCTION__, __LINE__) #define rtw_writeN(adapter, addr, length, data) dbg_rtw_writeN23a((adapter), (addr), (length), (data), __FUNCTION__, __LINE__) -#define rtw_write_port(adapter, addr, cnt, mem) _rtw_write_port23a(adapter, addr, cnt, mem) #define rtw_write_port_cancel(adapter) _rtw_write_port23a_cancel(adapter) #else /* DBG_IO */ #define rtw_read8(adapter, addr) _rtw_read823a((adapter), (addr)) #define rtw_read16(adapter, addr) _rtw_read1623a((adapter), (addr)) #define rtw_read32(adapter, addr) _rtw_read3223a((adapter), (addr)) -#define rtw_read_port(adapter, addr, cnt, mem) _rtw_read_port23a((adapter), (addr), (cnt), (mem)) #define rtw_read_port_cancel(adapter) _rtw_read_port23a_cancel((adapter)) #define rtw_write8(adapter, addr, val) _rtw_write823a((adapter), (addr), (val)) @@ -302,7 +292,6 @@ int dbg_rtw_writeN23a(struct rtw_adapter *adapter, u32 addr ,u32 length , u8 *da #define rtw_write32(adapter, addr, val) _rtw_write3223a((adapter), (addr), (val)) #define rtw_writeN(adapter, addr, length, data) _rtw_writeN23a((adapter), (addr), (length), (data)) -#define rtw_write_port(adapter, addr, cnt, mem) _rtw_write_port23a((adapter), (addr), (cnt), (mem)) #define rtw_write_port_cancel(adapter) _rtw_write_port23a_cancel((adapter)) #endif /* DBG_IO */ diff --git a/drivers/staging/rtl8723au/include/rtw_recv.h b/drivers/staging/rtl8723au/include/rtw_recv.h index e22ce645667f..fd381c594b14 100644 --- a/drivers/staging/rtl8723au/include/rtw_recv.h +++ b/drivers/staging/rtl8723au/include/rtw_recv.h @@ -187,7 +187,6 @@ struct recv_priv { uint rx_middlepacket_crcerr; /* u8 *pallocated_urb_buf; */ - uint ff_hwaddr; u8 rx_pending_cnt; struct urb *int_in_urb; diff --git a/drivers/staging/rtl8723au/include/usb_ops_linux.h b/drivers/staging/rtl8723au/include/usb_ops_linux.h index f46b81b7d259..ed4d8a82db14 100644 --- a/drivers/staging/rtl8723au/include/usb_ops_linux.h +++ b/drivers/staging/rtl8723au/include/usb_ops_linux.h @@ -28,5 +28,9 @@ void usb_read_port_cancel23a(struct rtw_adapter *adapter); int usb_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct xmit_buf *wmem); void usb_write_port23a_cancel(struct rtw_adapter *adapter); +int rtl8723a_usb_read_port(struct rtw_adapter *adapter, u32 addr, u32 cnt, + struct recv_buf *precvbuf); +int rtl8723a_usb_write_port(struct rtw_adapter *padapter, u32 addr, u32 cnt, + struct xmit_buf *pxmitbuf); #endif diff --git a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c index 3ef38706a21d..2eb76bdba029 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c @@ -18,22 +18,6 @@ #include #include -unsigned int ffaddr2pipehdl23a(struct dvobj_priv *pdvobj, u32 addr) -{ - struct usb_device *pusbd = pdvobj->pusbdev; - unsigned int pipe = 0, ep_num = 0; - - if (addr == RECV_BULK_IN_ADDR) { - pipe = usb_rcvbulkpipe(pusbd, pdvobj->RtInPipe[0]); - } else if (addr == RECV_INT_IN_ADDR) { - pipe = usb_rcvintpipe(pusbd, pdvobj->RtInPipe[1]); - } else if (addr < HW_QUEUE_ENTRY) { - ep_num = pdvobj->Queue2Pipe[addr]; - pipe = usb_sndbulkpipe(pusbd, ep_num); - } - return pipe; -} - struct zero_bulkout_context { void *pbuf; void *purb; @@ -156,8 +140,8 @@ check_completion: tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); } -int usb_write_port23a(struct rtw_adapter *padapter, u32 addr, u32 cnt, - struct xmit_buf *pxmitbuf) +int rtl8723a_usb_write_port(struct rtw_adapter *padapter, u32 addr, u32 cnt, + struct xmit_buf *pxmitbuf) { struct urb *purb = NULL; struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter); @@ -165,7 +149,7 @@ int usb_write_port23a(struct rtw_adapter *padapter, u32 addr, u32 cnt, struct xmit_frame *pxmitframe; struct usb_device *pusbd = pdvobj->pusbdev; unsigned long irqL; - unsigned int pipe; + unsigned int pipe, ep_num; int status; int ret = _FAIL; @@ -214,7 +198,8 @@ int usb_write_port23a(struct rtw_adapter *padapter, u32 addr, u32 cnt, purb = pxmitbuf->pxmit_urb[0]; /* translate DMA FIFO addr to pipehandle */ - pipe = ffaddr2pipehdl23a(pdvobj, addr); + ep_num = pdvobj->Queue2Pipe[addr]; + pipe = usb_sndbulkpipe(pusbd, ep_num); usb_fill_bulk_urb(purb, pusbd, pipe, pxmitframe->buf_addr, /* pxmitbuf->pbuf */ -- cgit v1.2.3 From 633475cf5e6bfca434c7feb06653b0a187274c1d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:05:06 +0200 Subject: staging: rtl8723au: Call usb_{read,write}_port() functions directly Get rid of more HAL layer obfuscations Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_io.c | 22 ---------------------- drivers/staging/rtl8723au/hal/usb_halinit.c | 2 +- drivers/staging/rtl8723au/hal/usb_ops_linux.c | 3 --- drivers/staging/rtl8723au/include/rtw_io.h | 9 --------- drivers/staging/rtl8723au/include/usb_ops_linux.h | 9 ++------- drivers/staging/rtl8723au/os_dep/usb_intf.c | 2 +- drivers/staging/rtl8723au/os_dep/usb_ops_linux.c | 4 ++-- 7 files changed, 6 insertions(+), 45 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_io.c b/drivers/staging/rtl8723au/core/rtw_io.c index 532ad758372f..45866d78f7ec 100644 --- a/drivers/staging/rtl8723au/core/rtw_io.c +++ b/drivers/staging/rtl8723au/core/rtw_io.c @@ -114,25 +114,3 @@ int _rtw_writeN23a(struct rtw_adapter *adapter, u32 addr , u32 length , u8 *pdat else return _SUCCESS; } - -void _rtw_read_port23a_cancel(struct rtw_adapter *adapter) -{ - void (*_read_port_cancel)(struct rtw_adapter *adapter); - struct _io_ops *io_ops = &adapter->io_ops; - - _read_port_cancel = io_ops->_read_port_cancel; - - if (_read_port_cancel) - _read_port_cancel(adapter); -} - -void _rtw_write_port23a_cancel(struct rtw_adapter *adapter) -{ - void (*_write_port_cancel)(struct rtw_adapter *adapter); - struct _io_ops *io_ops = &adapter->io_ops; - - _write_port_cancel = io_ops->_write_port_cancel; - - if (_write_port_cancel) - _write_port_cancel(adapter); -} diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 11b33e6fd709..fc1d407f2648 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1261,7 +1261,7 @@ int rtl8723au_inirp_deinit(struct rtw_adapter *Adapter) RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("\n ===> usb_rx_deinit\n")); - rtw_read_port_cancel(Adapter); + rtl8723a_usb_read_port_cancel(Adapter); pHalData->IntrMask[0] = rtw_read32(Adapter, REG_USB_HIMR); MSG_8723A("%s pHalData->IntrMask = 0x%04x\n", __func__, pHalData->IntrMask[0]); diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index cb83758393b3..3b8a1996b3f1 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -848,9 +848,6 @@ void rtl8723au_set_intf_ops(struct rtw_adapter *padapter) pops->_write32 = &usb_write32; pops->_writeN = &usb_writeN; - pops->_read_port_cancel = &usb_read_port_cancel23a; - pops->_write_port_cancel = &usb_write_port23a_cancel; - pops->_read_interrupt = &usb_read_interrupt; } diff --git a/drivers/staging/rtl8723au/include/rtw_io.h b/drivers/staging/rtl8723au/include/rtw_io.h index 192e16764d9a..50a1783859a8 100644 --- a/drivers/staging/rtl8723au/include/rtw_io.h +++ b/drivers/staging/rtl8723au/include/rtw_io.h @@ -111,9 +111,6 @@ struct _io_ops u8 *pdata); int (*_read_interrupt)(struct rtw_adapter *adapter, u32 addr); - - void (*_read_port_cancel)(struct rtw_adapter *adapter); - void (*_write_port_cancel)(struct rtw_adapter *adapter); }; struct io_req { @@ -273,26 +270,20 @@ int dbg_rtw_writeN23a(struct rtw_adapter *adapter, u32 addr ,u32 length , u8 *da #define rtw_read8(adapter, addr) dbg_rtw_read823a((adapter), (addr), __FUNCTION__, __LINE__) #define rtw_read16(adapter, addr) dbg_rtw_read1623a((adapter), (addr), __FUNCTION__, __LINE__) #define rtw_read32(adapter, addr) dbg_rtw_read3223a((adapter), (addr), __FUNCTION__, __LINE__) -#define rtw_read_port_cancel(adapter) _rtw_read_port23a_cancel((adapter)) #define rtw_write8(adapter, addr, val) dbg_rtw_write823a((adapter), (addr), (val), __FUNCTION__, __LINE__) #define rtw_write16(adapter, addr, val) dbg_rtw_write1623a((adapter), (addr), (val), __FUNCTION__, __LINE__) #define rtw_write32(adapter, addr, val) dbg_rtw_write3223a((adapter), (addr), (val), __FUNCTION__, __LINE__) #define rtw_writeN(adapter, addr, length, data) dbg_rtw_writeN23a((adapter), (addr), (length), (data), __FUNCTION__, __LINE__) - -#define rtw_write_port_cancel(adapter) _rtw_write_port23a_cancel(adapter) #else /* DBG_IO */ #define rtw_read8(adapter, addr) _rtw_read823a((adapter), (addr)) #define rtw_read16(adapter, addr) _rtw_read1623a((adapter), (addr)) #define rtw_read32(adapter, addr) _rtw_read3223a((adapter), (addr)) -#define rtw_read_port_cancel(adapter) _rtw_read_port23a_cancel((adapter)) #define rtw_write8(adapter, addr, val) _rtw_write823a((adapter), (addr), (val)) #define rtw_write16(adapter, addr, val) _rtw_write1623a((adapter), (addr), (val)) #define rtw_write32(adapter, addr, val) _rtw_write3223a((adapter), (addr), (val)) #define rtw_writeN(adapter, addr, length, data) _rtw_writeN23a((adapter), (addr), (length), (data)) - -#define rtw_write_port_cancel(adapter) _rtw_write_port23a_cancel((adapter)) #endif /* DBG_IO */ #define PlatformEFIOWrite1Byte(_a,_b,_c) \ diff --git a/drivers/staging/rtl8723au/include/usb_ops_linux.h b/drivers/staging/rtl8723au/include/usb_ops_linux.h index ed4d8a82db14..f851becf863f 100644 --- a/drivers/staging/rtl8723au/include/usb_ops_linux.h +++ b/drivers/staging/rtl8723au/include/usb_ops_linux.h @@ -21,16 +21,11 @@ #define MAX_USBCTRL_VENDORREQ_TIMES 10 -unsigned int ffaddr2pipehdl23a(struct dvobj_priv *pdvobj, u32 addr); - -void usb_read_port_cancel23a(struct rtw_adapter *adapter); - -int usb_write_port23a(struct rtw_adapter *adapter, u32 addr, u32 cnt, - struct xmit_buf *wmem); -void usb_write_port23a_cancel(struct rtw_adapter *adapter); int rtl8723a_usb_read_port(struct rtw_adapter *adapter, u32 addr, u32 cnt, struct recv_buf *precvbuf); +void rtl8723a_usb_read_port_cancel(struct rtw_adapter *padapter); int rtl8723a_usb_write_port(struct rtw_adapter *padapter, u32 addr, u32 cnt, struct xmit_buf *pxmitbuf); +void rtl8723a_usb_write_port_cancel(struct rtw_adapter *padapter); #endif diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index 38f2af3badbf..34522d290048 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -292,7 +292,7 @@ void rtl8723a_usb_intf_stop(struct rtw_adapter *padapter) rtl8723au_inirp_deinit(padapter); /* cancel out irp */ - rtw_write_port_cancel(padapter); + rtl8723a_usb_write_port_cancel(padapter); /* todo:cancel other irps */ RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-usb_intf_stop\n")); diff --git a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c index 2eb76bdba029..a41d824ab325 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c @@ -25,7 +25,7 @@ struct zero_bulkout_context { void *padapter; }; -void usb_read_port_cancel23a(struct rtw_adapter *padapter) +void rtl8723a_usb_read_port_cancel(struct rtw_adapter *padapter) { struct recv_buf *precvbuf; int i; @@ -237,7 +237,7 @@ exit: return ret; } -void usb_write_port23a_cancel(struct rtw_adapter *padapter) +void rtl8723a_usb_write_port_cancel(struct rtw_adapter *padapter) { struct xmit_buf *pxmitbuf; struct list_head *plist; -- cgit v1.2.3 From 1c1bc5f1dd86237c65f571ca72c75b285b0dceeb Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:05:07 +0200 Subject: staging: rtl8723au: Call usb_read_interrupt() directly instead of via HAL layer Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_halinit.c | 5 +---- drivers/staging/rtl8723au/hal/usb_ops_linux.c | 4 +--- drivers/staging/rtl8723au/include/rtw_io.h | 2 -- drivers/staging/rtl8723au/include/usb_ops_linux.h | 1 + 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index fc1d407f2648..46dcc567aa2d 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1218,9 +1218,7 @@ int rtl8723au_inirp_init(struct rtw_adapter *Adapter) u8 i; struct recv_buf *precvbuf; int status; - struct _io_ops *io_ops = &Adapter->io_ops; struct recv_priv *precvpriv = &Adapter->recvpriv; - int (*_read_interrupt)(struct rtw_adapter *padapter, u32 addr); struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); status = _SUCCESS; @@ -1239,8 +1237,7 @@ int rtl8723au_inirp_init(struct rtw_adapter *Adapter) } precvbuf++; } - _read_interrupt = io_ops->_read_interrupt; - if (_read_interrupt(Adapter, RECV_INT_IN_ADDR) == _FAIL) { + if (rtl8723a_usb_read_interrupt(Adapter, RECV_INT_IN_ADDR) == _FAIL) { RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("usb_rx_init: usb_read_interrupt error\n")); status = _FAIL; diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index 3b8a1996b3f1..bb85131c30e0 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -447,7 +447,7 @@ urb_submit: } } -static int usb_read_interrupt(struct rtw_adapter *adapter, u32 addr) +int rtl8723a_usb_read_interrupt(struct rtw_adapter *adapter, u32 addr) { int err; unsigned int pipe; @@ -847,8 +847,6 @@ void rtl8723au_set_intf_ops(struct rtw_adapter *padapter) pops->_write16 = &usb_write16; pops->_write32 = &usb_write32; pops->_writeN = &usb_writeN; - - pops->_read_interrupt = &usb_read_interrupt; } void rtl8723au_set_hw_type(struct rtw_adapter *padapter) diff --git a/drivers/staging/rtl8723au/include/rtw_io.h b/drivers/staging/rtl8723au/include/rtw_io.h index 50a1783859a8..82939f5225db 100644 --- a/drivers/staging/rtl8723au/include/rtw_io.h +++ b/drivers/staging/rtl8723au/include/rtw_io.h @@ -109,8 +109,6 @@ struct _io_ops int (*_write32)(struct rtw_adapter *adapter, u32 addr, u32 val); int (*_writeN)(struct rtw_adapter *adapter, u32 addr, u32 length, u8 *pdata); - - int (*_read_interrupt)(struct rtw_adapter *adapter, u32 addr); }; struct io_req { diff --git a/drivers/staging/rtl8723au/include/usb_ops_linux.h b/drivers/staging/rtl8723au/include/usb_ops_linux.h index f851becf863f..acd98f7fc63c 100644 --- a/drivers/staging/rtl8723au/include/usb_ops_linux.h +++ b/drivers/staging/rtl8723au/include/usb_ops_linux.h @@ -27,5 +27,6 @@ void rtl8723a_usb_read_port_cancel(struct rtw_adapter *padapter); int rtl8723a_usb_write_port(struct rtw_adapter *padapter, u32 addr, u32 cnt, struct xmit_buf *pxmitbuf); void rtl8723a_usb_write_port_cancel(struct rtw_adapter *padapter); +int rtl8723a_usb_read_interrupt(struct rtw_adapter *adapter, u32 addr); #endif -- cgit v1.2.3 From 050abc45833c6a66501cb3f938ef6e93ac18da8d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:05:08 +0200 Subject: staging: rtl8723au: Call usb_read*() functions directly Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_efuse.c | 50 +++++++------- drivers/staging/rtl8723au/core/rtw_io.c | 24 ------- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 3 +- drivers/staging/rtl8723au/core/rtw_sreset.c | 3 +- .../staging/rtl8723au/hal/HalDMOutSrc8723A_CE.c | 7 +- drivers/staging/rtl8723au/hal/HalPwrSeqCmd.c | 6 +- drivers/staging/rtl8723au/hal/hal_com.c | 47 +++++++------ drivers/staging/rtl8723au/hal/odm.c | 4 +- drivers/staging/rtl8723au/hal/odm_interface.c | 15 ++-- .../staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 59 ++++++++-------- drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 9 +-- drivers/staging/rtl8723au/hal/rtl8723a_dm.c | 13 ++-- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 80 +++++++++++----------- drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c | 17 ++--- drivers/staging/rtl8723au/hal/rtl8723a_sreset.c | 3 +- drivers/staging/rtl8723au/hal/rtl8723au_led.c | 5 +- drivers/staging/rtl8723au/hal/usb_halinit.c | 57 +++++++-------- drivers/staging/rtl8723au/hal/usb_ops_linux.c | 10 +-- drivers/staging/rtl8723au/include/rtw_io.h | 28 +------- drivers/staging/rtl8723au/include/usb_ops_linux.h | 4 ++ 20 files changed, 209 insertions(+), 235 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_efuse.c b/drivers/staging/rtl8723au/core/rtw_efuse.c index 61fef36ab35a..427937a21c08 100644 --- a/drivers/staging/rtl8723au/core/rtw_efuse.c +++ b/drivers/staging/rtl8723au/core/rtw_efuse.c @@ -19,6 +19,7 @@ #include #include +#include /*------------------------Define local variable------------------------------*/ @@ -59,13 +60,13 @@ static void Efuse_PowerSwitch(struct rtw_adapter *padapter, /* 1.2V Power: From VDDON with Power Cut(0x0000h[15]), defualt valid */ - tmpV16 = rtw_read16(padapter, REG_SYS_ISO_CTRL); + tmpV16 = rtl8723au_read16(padapter, REG_SYS_ISO_CTRL); if (!(tmpV16 & PWC_EV12V)) { tmpV16 |= PWC_EV12V; rtw_write16(padapter, REG_SYS_ISO_CTRL, tmpV16); } /* Reset: 0x0000h[28], default valid */ - tmpV16 = rtw_read16(padapter, REG_SYS_FUNC_EN); + tmpV16 = rtl8723au_read16(padapter, REG_SYS_FUNC_EN); if (!(tmpV16 & FEN_ELDR)) { tmpV16 |= FEN_ELDR; rtw_write16(padapter, REG_SYS_FUNC_EN, tmpV16); @@ -73,7 +74,7 @@ static void Efuse_PowerSwitch(struct rtw_adapter *padapter, /* Clock: Gated(0x0008h[5]) 8M(0x0008h[1]) clock from ANA, default valid */ - tmpV16 = rtw_read16(padapter, REG_SYS_CLKR); + tmpV16 = rtl8723au_read16(padapter, REG_SYS_CLKR); if ((!(tmpV16 & LOADER_CLK_EN)) || (!(tmpV16 & ANA8M))) { tmpV16 |= (LOADER_CLK_EN | ANA8M); rtw_write16(padapter, REG_SYS_CLKR, tmpV16); @@ -81,7 +82,7 @@ static void Efuse_PowerSwitch(struct rtw_adapter *padapter, if (bWrite == true) { /* Enable LDO 2.5V before read/write action */ - tempval = rtw_read8(padapter, EFUSE_TEST + 3); + tempval = rtl8723au_read8(padapter, EFUSE_TEST + 3); tempval &= 0x0F; tempval |= (VOLTAGE_V25 << 4); rtw_write8(padapter, EFUSE_TEST + 3, (tempval | 0x80)); @@ -91,7 +92,7 @@ static void Efuse_PowerSwitch(struct rtw_adapter *padapter, if (bWrite == true) { /* Disable LDO 2.5V after read/write action */ - tempval = rtw_read8(padapter, EFUSE_TEST + 3); + tempval = rtl8723au_read8(padapter, EFUSE_TEST + 3); rtw_write8(padapter, EFUSE_TEST + 3, (tempval & 0x7F)); } } @@ -158,20 +159,20 @@ ReadEFuseByte23a(struct rtw_adapter *Adapter, u16 _offset, u8 *pbuf) /* Write Address */ rtw_write8(Adapter, EFUSE_CTRL+1, (_offset & 0xff)); - readbyte = rtw_read8(Adapter, EFUSE_CTRL+2); + readbyte = rtl8723au_read8(Adapter, EFUSE_CTRL+2); rtw_write8(Adapter, EFUSE_CTRL+2, ((_offset >> 8) & 0x03) | (readbyte & 0xfc)); /* Write bit 32 0 */ - readbyte = rtw_read8(Adapter, EFUSE_CTRL+3); + readbyte = rtl8723au_read8(Adapter, EFUSE_CTRL+3); rtw_write8(Adapter, EFUSE_CTRL+3, (readbyte & 0x7f)); /* Check bit 32 read-ready */ retry = 0; - value32 = rtw_read32(Adapter, EFUSE_CTRL); + value32 = rtl8723au_read32(Adapter, EFUSE_CTRL); /* while(!(((value32 >> 24) & 0xff) & 0x80) && (retry<10)) */ while(!(((value32 >> 24) & 0xff) & 0x80) && (retry<10000)) { - value32 = rtw_read32(Adapter, EFUSE_CTRL); + value32 = rtl8723au_read32(Adapter, EFUSE_CTRL); retry++; } @@ -180,7 +181,7 @@ ReadEFuseByte23a(struct rtw_adapter *Adapter, u16 _offset, u8 *pbuf) /* Designer says that there shall be some delay after ready bit is set, or the */ /* result will always stay on last data we read. */ udelay(50); - value32 = rtw_read32(Adapter, EFUSE_CTRL); + value32 = rtl8723au_read32(Adapter, EFUSE_CTRL); *pbuf = (u8)(value32 & 0xff); } @@ -302,21 +303,21 @@ EFUSE_Read1Byte23a(struct rtw_adapter *Adapter, u16 Address) /* Write E-fuse Register address bit0~7 */ temp = Address & 0xFF; rtw_write8(Adapter, EFUSE_CTRL+1, temp); - Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+2); + Bytetemp = rtl8723au_read8(Adapter, EFUSE_CTRL+2); /* Write E-fuse Register address bit8~9 */ temp = ((Address >> 8) & 0x03) | (Bytetemp & 0xFC); rtw_write8(Adapter, EFUSE_CTRL+2, temp); /* Write 0x30[31]= 0 */ - Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3); + Bytetemp = rtl8723au_read8(Adapter, EFUSE_CTRL+3); temp = Bytetemp & 0x7F; rtw_write8(Adapter, EFUSE_CTRL+3, temp); /* Wait Write-ready (0x30[31]= 1) */ - Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3); + Bytetemp = rtl8723au_read8(Adapter, EFUSE_CTRL+3); while(!(Bytetemp & 0x80)) { - Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3); + Bytetemp = rtl8723au_read8(Adapter, EFUSE_CTRL+3); k++; if (k == 1000) { @@ -324,7 +325,7 @@ EFUSE_Read1Byte23a(struct rtw_adapter *Adapter, u16 Address) break; } } - data = rtw_read8(Adapter, EFUSE_CTRL); + data = rtl8723au_read8(Adapter, EFUSE_CTRL); return data; } else @@ -376,22 +377,22 @@ EFUSE_Write1Byte( /* Write E-fuse Register address bit0~7 */ temp = Address & 0xFF; rtw_write8(Adapter, EFUSE_CTRL+1, temp); - Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+2); + Bytetemp = rtl8723au_read8(Adapter, EFUSE_CTRL+2); /* Write E-fuse Register address bit8~9 */ temp = ((Address >> 8) & 0x03) | (Bytetemp & 0xFC); rtw_write8(Adapter, EFUSE_CTRL+2, temp); /* Write 0x30[31]= 1 */ - Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3); + Bytetemp = rtl8723au_read8(Adapter, EFUSE_CTRL+3); temp = Bytetemp | 0x80; rtw_write8(Adapter, EFUSE_CTRL+3, temp); /* Wait Write-ready (0x30[31]= 0) */ - Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3); + Bytetemp = rtl8723au_read8(Adapter, EFUSE_CTRL+3); while(Bytetemp & 0x80) { - Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3); + Bytetemp = rtl8723au_read8(Adapter, EFUSE_CTRL+3); k++; if (k == 100) { @@ -413,14 +414,14 @@ efuse_OneByteRead23a(struct rtw_adapter *pAdapter, u16 addr, u8 *data) /* address */ rtw_write8(pAdapter, EFUSE_CTRL+1, (u8)(addr&0xff)); rtw_write8(pAdapter, EFUSE_CTRL+2, ((u8)((addr>>8) &0x03)) | - (rtw_read8(pAdapter, EFUSE_CTRL+2)&0xFC)); + (rtl8723au_read8(pAdapter, EFUSE_CTRL+2)&0xFC)); rtw_write8(pAdapter, EFUSE_CTRL+3, 0x72);/* read cmd */ - while(!(0x80 &rtw_read8(pAdapter, EFUSE_CTRL+3)) && (tmpidx<100)) + while(!(0x80 &rtl8723au_read8(pAdapter, EFUSE_CTRL+3)) && (tmpidx<100)) tmpidx++; if (tmpidx < 100) { - *data = rtw_read8(pAdapter, EFUSE_CTRL); + *data = rtl8723au_read8(pAdapter, EFUSE_CTRL); bResult = _SUCCESS; } else { *data = 0xff; @@ -444,12 +445,13 @@ efuse_OneByteWrite23a(struct rtw_adapter *pAdapter, u16 addr, u8 data) /* address */ rtw_write8(pAdapter, EFUSE_CTRL+1, (u8)(addr&0xff)); rtw_write8(pAdapter, EFUSE_CTRL+2, - (rtw_read8(pAdapter, EFUSE_CTRL+2)&0xFC)|(u8)((addr>>8)&0x03)); + (rtl8723au_read8(pAdapter, EFUSE_CTRL+2)&0xFC)|(u8)((addr>>8)&0x03)); rtw_write8(pAdapter, EFUSE_CTRL, data);/* data */ rtw_write8(pAdapter, EFUSE_CTRL+3, 0xF2);/* write cmd */ - while((0x80 & rtw_read8(pAdapter, EFUSE_CTRL+3)) && (tmpidx<100)) { + while((0x80 & rtl8723au_read8(pAdapter, EFUSE_CTRL+3)) && + (tmpidx<100)) { tmpidx++; } diff --git a/drivers/staging/rtl8723au/core/rtw_io.c b/drivers/staging/rtl8723au/core/rtw_io.c index 45866d78f7ec..a7901d724ebd 100644 --- a/drivers/staging/rtl8723au/core/rtw_io.c +++ b/drivers/staging/rtl8723au/core/rtw_io.c @@ -39,30 +39,6 @@ jackson@realtek.com.tw #include -u8 _rtw_read823a(struct rtw_adapter *adapter, u32 addr) -{ - u8 r_val; - struct _io_ops *io_ops = &adapter->io_ops; - - r_val = io_ops->_read8(adapter, addr); - - return r_val; -} - -u16 _rtw_read1623a(struct rtw_adapter *adapter, u32 addr) -{ - struct _io_ops *io_ops = &adapter->io_ops; - - return io_ops->_read16(adapter, addr); -} - -u32 _rtw_read3223a(struct rtw_adapter *adapter, u32 addr) -{ - struct _io_ops *io_ops = &adapter->io_ops; - - return io_ops->_read32(adapter, addr); -} - int _rtw_write823a(struct rtw_adapter *adapter, u32 addr, u8 val) { struct _io_ops *io_ops = &adapter->io_ops; diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index b36c12b842c0..7ae9748dcd7b 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -22,6 +22,7 @@ #ifdef CONFIG_8723AU_BT_COEXIST #include #endif +#include void ips_enter23a(struct rtw_adapter * padapter) { @@ -98,7 +99,7 @@ int ips_leave23a(struct rtw_adapter * padapter) } DBG_8723A("==> ips_leave23a.....LED(0x%08x)...\n", - rtw_read32(padapter, 0x4c)); + rtl8723au_read32(padapter, 0x4c)); pwrpriv->bips_processing = false; pwrpriv->bkeepfwalive = false; diff --git a/drivers/staging/rtl8723au/core/rtw_sreset.c b/drivers/staging/rtl8723au/core/rtw_sreset.c index 4938af70cc02..ec6754befab6 100644 --- a/drivers/staging/rtl8723au/core/rtw_sreset.c +++ b/drivers/staging/rtl8723au/core/rtw_sreset.c @@ -14,6 +14,7 @@ ******************************************************************************/ #include +#include void rtw_sreset_init(struct rtw_adapter *padapter) { @@ -47,7 +48,7 @@ u8 rtw_sreset_get_wifi_status(struct rtw_adapter *padapter) if (psrtpriv->silent_reset_inprogress) return status; - val32 = rtw_read32(padapter, REG_TXDMA_STATUS); + val32 = rtl8723au_read32(padapter, REG_TXDMA_STATUS); if (val32 == 0xeaeaeaea) { psrtpriv->Wifi_Error_Status = WIFI_IF_NOT_EXIST; } else if (val32 != 0) { diff --git a/drivers/staging/rtl8723au/hal/HalDMOutSrc8723A_CE.c b/drivers/staging/rtl8723au/hal/HalDMOutSrc8723A_CE.c index 9007cd3c8333..b92e13e66aae 100644 --- a/drivers/staging/rtl8723au/hal/HalDMOutSrc8723A_CE.c +++ b/drivers/staging/rtl8723au/hal/HalDMOutSrc8723A_CE.c @@ -18,6 +18,7 @@ /* include files */ #include "odm_precomp.h" +#include #define DPK_DELTA_MAPPING_NUM 13 #define index_mapping_HP_NUM 15 @@ -581,9 +582,9 @@ static void _PHY_SaveMACRegisters(struct rtw_adapter *pAdapter, u32 *MACReg, u32 u32 i; for (i = 0 ; i < (IQK_MAC_REG_NUM - 1); i++) { - MACBackup[i] = rtw_read8(pAdapter, MACReg[i]); + MACBackup[i] = rtl8723au_read8(pAdapter, MACReg[i]); } - MACBackup[i] = rtw_read32(pAdapter, MACReg[i]); + MACBackup[i] = rtl8723au_read32(pAdapter, MACReg[i]); } static void _PHY_ReloadADDARegisters(struct rtw_adapter *pAdapter, u32 *ADDAReg, u32 *ADDABackup, u32 RegiesterNum) @@ -878,7 +879,7 @@ static void _PHY_LCCalibrate(struct rtw_adapter *pAdapter, bool is2T) u32 RF_Amode = 0, RF_Bmode = 0, LC_Cal; /* Check continuous TX and Packet TX */ - tmpReg = rtw_read8(pAdapter, 0xd03); + tmpReg = rtl8723au_read8(pAdapter, 0xd03); if ((tmpReg&0x70) != 0) /* Deal with contisuous TX case */ rtw_write8(pAdapter, 0xd03, tmpReg&0x8F); /* disable all continuous TX */ diff --git a/drivers/staging/rtl8723au/hal/HalPwrSeqCmd.c b/drivers/staging/rtl8723au/hal/HalPwrSeqCmd.c index 4f6b4b72f922..8234ce851975 100644 --- a/drivers/staging/rtl8723au/hal/HalPwrSeqCmd.c +++ b/drivers/staging/rtl8723au/hal/HalPwrSeqCmd.c @@ -30,6 +30,7 @@ Major Change History: --*/ #include +#include /* */ /* Description: */ @@ -89,7 +90,7 @@ u8 HalPwrSeqCmdParsing23a(struct rtw_adapter *padapter, u8 CutVersion, offset = GET_PWR_CFG_OFFSET(PwrCfgCmd); /* Read the value from system register */ - value = rtw_read8(padapter, offset); + value = rtl8723au_read8(padapter, offset); value &= ~(GET_PWR_CFG_MASK(PwrCfgCmd)); value |= (GET_PWR_CFG_VALUE(PwrCfgCmd) & @@ -107,7 +108,8 @@ u8 HalPwrSeqCmdParsing23a(struct rtw_adapter *padapter, u8 CutVersion, bPollingBit = false; offset = GET_PWR_CFG_OFFSET(PwrCfgCmd); do { - value = rtw_read8(padapter, offset); + value = rtl8723au_read8(padapter, + offset); value &= GET_PWR_CFG_MASK(PwrCfgCmd); if (value == diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index 29e0ec9acb65..c5f46f6e51d2 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -18,6 +18,7 @@ #include #include #include +#include #define _HAL_INIT_C_ @@ -225,7 +226,7 @@ void HalSetBrateCfg23a(struct rtw_adapter *padapter, u8 *mBratesOS) rtw_write8(padapter, REG_RRSR, brate_cfg & 0xff); rtw_write8(padapter, REG_RRSR + 1, (brate_cfg >> 8) & 0xff); rtw_write8(padapter, REG_RRSR + 2, - rtw_read8(padapter, REG_RRSR + 2) & 0xf0); + rtl8723au_read8(padapter, REG_RRSR + 2) & 0xf0); rate_index = 0; /* Set RTS initial rate */ @@ -365,7 +366,7 @@ int c2h_evt_read23a(struct rtw_adapter *adapter, u8 *buf) if (buf == NULL) goto exit; - trigger = rtw_read8(adapter, REG_C2HEVT_CLEAR); + trigger = rtl8723au_read8(adapter, REG_C2HEVT_CLEAR); if (trigger == C2H_EVT_HOST_CLOSE) goto exit; /* Not ready */ @@ -376,8 +377,8 @@ int c2h_evt_read23a(struct rtw_adapter *adapter, u8 *buf) memset(c2h_evt, 0, 16); - *buf = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL); - *(buf + 1) = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL + 1); + *buf = rtl8723au_read8(adapter, REG_C2HEVT_MSG_NORMAL); + *(buf + 1) = rtl8723au_read8(adapter, REG_C2HEVT_MSG_NORMAL + 1); RT_PRINT_DATA(_module_hal_init_c_, _drv_info_, "c2h_evt_read23a(): ", &c2h_evt, sizeof(c2h_evt)); @@ -390,7 +391,7 @@ int c2h_evt_read23a(struct rtw_adapter *adapter, u8 *buf) /* Read the content */ for (i = 0; i < c2h_evt->plen; i++) - c2h_evt->payload[i] = rtw_read8(adapter, + c2h_evt->payload[i] = rtl8723au_read8(adapter, REG_C2HEVT_MSG_NORMAL + sizeof(*c2h_evt) + i); @@ -441,7 +442,7 @@ rtl8723a_set_ampdu_min_space(struct rtw_adapter *padapter, u8 MinSpacingToSet) ("Set HW_VAR_AMPDU_MIN_SPACE: %#x\n", padapter->MgntInfo.MinSpaceCfg)); */ MinSpacingToSet |= - rtw_read8(padapter, REG_AMPDU_MIN_SPACE) & 0xf8; + rtl8723au_read8(padapter, REG_AMPDU_MIN_SPACE) & 0xf8; rtw_write8(padapter, REG_AMPDU_MIN_SPACE, MinSpacingToSet); } @@ -513,7 +514,7 @@ void rtl8723a_set_media_status(struct rtw_adapter *padapter, u8 status) { u8 val8; - val8 = rtw_read8(padapter, MSR) & 0x0c; + val8 = rtl8723au_read8(padapter, MSR) & 0x0c; val8 |= status; rtw_write8(padapter, MSR, val8); } @@ -522,7 +523,7 @@ void rtl8723a_set_media_status1(struct rtw_adapter *padapter, u8 status) { u8 val8; - val8 = rtw_read8(padapter, MSR) & 0x03; + val8 = rtl8723au_read8(padapter, MSR) & 0x03; val8 |= status << 2; rtw_write8(padapter, MSR, val8); } @@ -538,7 +539,7 @@ void rtl8723a_set_bcn_func(struct rtw_adapter *padapter, u8 val) void rtl8723a_check_bssid(struct rtw_adapter *padapter, u8 val) { u32 val32; - val32 = rtw_read32(padapter, REG_RCR); + val32 = rtl8723au_read32(padapter, REG_RCR); if (val) val32 |= RCR_CBSSID_DATA | RCR_CBSSID_BCN; else @@ -553,7 +554,7 @@ void rtl8723a_mlme_sitesurvey(struct rtw_adapter *padapter, u8 flag) /* config RCR to receive different BSSID & not to receive data frame */ - v32 = rtw_read32(padapter, REG_RCR); + v32 = rtl8723au_read32(padapter, REG_RCR); v32 &= ~(RCR_CBSSID_BCN); rtw_write32(padapter, REG_RCR, v32); /* reject all data frame */ @@ -579,7 +580,7 @@ void rtl8723a_mlme_sitesurvey(struct rtw_adapter *padapter, u8 flag) SetBcnCtrlReg23a(padapter, 0, DIS_TSF_UDT); } - v32 = rtw_read32(padapter, REG_RCR); + v32 = rtl8723au_read32(padapter, REG_RCR); v32 |= RCR_CBSSID_BCN; rtw_write32(padapter, REG_RCR, v32); } @@ -591,17 +592,18 @@ void rtl8723a_mlme_sitesurvey(struct rtw_adapter *padapter, u8 flag) void rtl8723a_on_rcr_am(struct rtw_adapter *padapter) { - rtw_write32(padapter, REG_RCR, rtw_read32(padapter, REG_RCR) | RCR_AM); + rtw_write32(padapter, REG_RCR, + rtl8723au_read32(padapter, REG_RCR) | RCR_AM); DBG_8723A("%s, %d, RCR = %x \n", __FUNCTION__, __LINE__, - rtw_read32(padapter, REG_RCR)); + rtl8723au_read32(padapter, REG_RCR)); } void rtl8723a_off_rcr_am(struct rtw_adapter *padapter) { rtw_write32(padapter, REG_RCR, - rtw_read32(padapter, REG_RCR) & (~RCR_AM)); + rtl8723au_read32(padapter, REG_RCR) & (~RCR_AM)); DBG_8723A("%s, %d, RCR = %x \n", __FUNCTION__, __LINE__, - rtw_read32(padapter, REG_RCR)); + rtl8723au_read32(padapter, REG_RCR)); } void rtl8723a_set_slot_time(struct rtw_adapter *padapter, u8 slottime) @@ -730,17 +732,18 @@ void rtl8723a_fifo_cleanup(struct rtw_adapter *padapter) rtw_write8(padapter, REG_TXPAUSE, 0xff); /* keep sn */ - padapter->xmitpriv.nqos_ssn = rtw_read16(padapter, REG_NQOS_SEQ); + padapter->xmitpriv.nqos_ssn = rtl8723au_read16(padapter, REG_NQOS_SEQ); if (pwrpriv->bkeepfwalive != true) { u32 v32; /* RX DMA stop */ - v32 = rtw_read32(padapter, REG_RXPKT_NUM); + v32 = rtl8723au_read32(padapter, REG_RXPKT_NUM); v32 |= RW_RELEASE_EN; rtw_write32(padapter, REG_RXPKT_NUM, v32); do { - v32 = rtw_read32(padapter, REG_RXPKT_NUM) & RXDMA_IDLE; + v32 = rtl8723au_read32(padapter, + REG_RXPKT_NUM) & RXDMA_IDLE; if (!v32) break; } while (trycnt--); @@ -760,14 +763,14 @@ void rtl8723a_bcn_valid(struct rtw_adapter *padapter) /* BCN_VALID, BIT16 of REG_TDECTRL = BIT0 of REG_TDECTRL+2, write 1 to clear, Clear by sw */ rtw_write8(padapter, REG_TDECTRL + 2, - rtw_read8(padapter, REG_TDECTRL + 2) | BIT(0)); + rtl8723au_read8(padapter, REG_TDECTRL + 2) | BIT(0)); } bool rtl8723a_get_bcn_valid(struct rtw_adapter *padapter) { bool retval; - retval = (rtw_read8(padapter, REG_TDECTRL + 2) & BIT(0)) ? true : false; + retval = (rtl8723au_read8(padapter, REG_TDECTRL + 2) & BIT(0)) ? true : false; return retval; } @@ -910,7 +913,7 @@ bool rtl8723a_get_fwlps_rf_on(struct rtw_adapter *padapter) not check Fw LPS Leave, because Fw is unload. */ retval = true; } else { - valRCR = rtw_read32(padapter, REG_RCR); + valRCR = rtl8723au_read32(padapter, REG_RCR); if (valRCR & 0x00070000) retval = false; else @@ -924,7 +927,7 @@ bool rtl8723a_chk_hi_queue_empty(struct rtw_adapter *padapter) { u32 hgq; - hgq = rtw_read32(padapter, REG_HGQ_INFORMATION); + hgq = rtl8723au_read32(padapter, REG_HGQ_INFORMATION); return ((hgq & 0x0000ff00) == 0) ? true : false; } diff --git a/drivers/staging/rtl8723au/hal/odm.c b/drivers/staging/rtl8723au/hal/odm.c index 1eedd96b794e..af6c54c84e42 100644 --- a/drivers/staging/rtl8723au/hal/odm.c +++ b/drivers/staging/rtl8723au/hal/odm.c @@ -14,6 +14,7 @@ ******************************************************************************/ #include "odm_precomp.h" +#include "usb_ops_linux.h" static const u16 dB_Invert_Table[8][12] = { {1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4}, @@ -1444,7 +1445,8 @@ void odm_DynamicTxPower23aSavePowerIndex(struct dm_odm_t *pDM_Odm) struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); struct dm_priv *pdmpriv = &pHalData->dmpriv; for (index = 0; index < 6; index++) - pdmpriv->PowerIndex_backup[index] = rtw_read8(Adapter, Power_Index_REG[index]); + pdmpriv->PowerIndex_backup[index] = + rtl8723au_read8(Adapter, Power_Index_REG[index]); } void odm_DynamicTxPower23aRestorePowerIndex(struct dm_odm_t *pDM_Odm) diff --git a/drivers/staging/rtl8723au/hal/odm_interface.c b/drivers/staging/rtl8723au/hal/odm_interface.c index ce5d16641382..e5873e08f4cb 100644 --- a/drivers/staging/rtl8723au/hal/odm_interface.c +++ b/drivers/staging/rtl8723au/hal/odm_interface.c @@ -21,6 +21,7 @@ /* */ /* ODM IO Relative API. */ /* */ +#include u8 ODM_Read1Byte(struct dm_odm_t *pDM_Odm, u32 RegAddr @@ -28,25 +29,21 @@ u8 ODM_Read1Byte(struct dm_odm_t *pDM_Odm, { struct rtw_adapter *Adapter = pDM_Odm->Adapter; - return rtw_read8(Adapter, RegAddr); + return rtl8723au_read8(Adapter, RegAddr); } -u16 ODM_Read2Byte(struct dm_odm_t *pDM_Odm, - u32 RegAddr - ) +u16 ODM_Read2Byte(struct dm_odm_t *pDM_Odm, u32 RegAddr) { struct rtw_adapter *Adapter = pDM_Odm->Adapter; - return rtw_read16(Adapter, RegAddr); + return rtl8723au_read16(Adapter, RegAddr); } -u32 ODM_Read4Byte(struct dm_odm_t *pDM_Odm, - u32 RegAddr - ) +u32 ODM_Read4Byte(struct dm_odm_t *pDM_Odm, u32 RegAddr) { struct rtw_adapter *Adapter = pDM_Odm->Adapter; - return rtw_read32(Adapter, RegAddr); + return rtl8723au_read32(Adapter, RegAddr); } void ODM_Write1Byte( diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index 37b6b79fe220..13ca1f66a7c5 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -15,6 +15,7 @@ #include #include #include +#include #define DIS_PS_RX_BCN @@ -5271,7 +5272,7 @@ static void btdm_1AntTSFSwitch(struct rtw_adapter *padapter, u8 enable) { u8 oldVal, newVal; - oldVal = rtw_read8(padapter, 0x550); + oldVal = rtl8723au_read8(padapter, 0x550); if (enable) newVal = oldVal | EN_BCN_FUNCTION; @@ -9031,11 +9032,11 @@ static void btdm_BtHwCountersMonitor(struct rtw_adapter *padapter) regHPTxRx = REG_HIGH_PRIORITY_TXRX; regLPTxRx = REG_LOW_PRIORITY_TXRX; - u4Tmp = rtw_read32(padapter, regHPTxRx); + u4Tmp = rtl8723au_read32(padapter, regHPTxRx); regHPTx = u4Tmp & bMaskLWord; regHPRx = (u4Tmp & bMaskHWord)>>16; - u4Tmp = rtw_read32(padapter, regLPTxRx); + u4Tmp = rtl8723au_read32(padapter, regLPTxRx); regLPTx = u4Tmp & bMaskLWord; regLPRx = (u4Tmp & bMaskHWord)>>16; @@ -9061,7 +9062,7 @@ static void btdm_BtEnableDisableCheck8723A(struct rtw_adapter *padapter) u8 val8; /* ox68[28]= 1 => BT enable; otherwise disable */ - val8 = rtw_read8(padapter, 0x6B); + val8 = rtl8723au_read8(padapter, 0x6B); if (!(val8 & BIT(4))) btAlife = false; @@ -9345,7 +9346,7 @@ BTDM_SetSwPenaltyTxRateAdaptive( struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); u8 tmpU1; - tmpU1 = rtw_read8(padapter, 0x4fd); + tmpU1 = rtl8723au_read8(padapter, 0x4fd); tmpU1 |= BIT(0); if (BT_TX_RATE_ADAPTIVE_LOW_PENALTY == raType) { tmpU1 &= ~BIT(2); @@ -9585,9 +9586,9 @@ static void BTDM_Display8723ABtCoexInfo(struct rtw_adapter *padapter) pBtCoex->btdm2Ant.bCurDecBtPwr); DCMD_Printf(btCoexDbgBuf); } - u1Tmp = rtw_read8(padapter, 0x778); - u1Tmp1 = rtw_read8(padapter, 0x783); - u1Tmp2 = rtw_read8(padapter, 0x796); + u1Tmp = rtl8723au_read8(padapter, 0x778); + u1Tmp1 = rtl8723au_read8(padapter, 0x783); + u1Tmp2 = rtl8723au_read8(padapter, 0x796); rsprintf(btCoexDbgBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x778/ 0x783/ 0x796", \ u1Tmp, u1Tmp1, u1Tmp2); DCMD_Printf(btCoexDbgBuf); @@ -9597,7 +9598,7 @@ static void BTDM_Display8723ABtCoexInfo(struct rtw_adapter *padapter) pBtCoex->btdm2Ant.bCurDacSwingOn, pBtCoex->btdm2Ant.curDacSwingLvl); DCMD_Printf(btCoexDbgBuf); } - u4Tmp[0] = rtw_read32(padapter, 0x880); + u4Tmp[0] = rtl8723au_read32(padapter, 0x880); rsprintf(btCoexDbgBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x880", \ u4Tmp[0]); DCMD_Printf(btCoexDbgBuf); @@ -9608,56 +9609,56 @@ static void BTDM_Display8723ABtCoexInfo(struct rtw_adapter *padapter) DCMD_Printf(btCoexDbgBuf); } - u1Tmp = rtw_read8(padapter, 0x40); + u1Tmp = rtl8723au_read8(padapter, 0x40); rsprintf(btCoexDbgBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x40", \ u1Tmp); DCMD_Printf(btCoexDbgBuf); - u4Tmp[0] = rtw_read32(padapter, 0x550); - u1Tmp = rtw_read8(padapter, 0x522); + u4Tmp[0] = rtl8723au_read32(padapter, 0x550); + u1Tmp = rtl8723au_read8(padapter, 0x522); rsprintf(btCoexDbgBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x", "0x550(bcn contrl)/0x522", \ u4Tmp[0], u1Tmp); DCMD_Printf(btCoexDbgBuf); - u4Tmp[0] = rtw_read32(padapter, 0x484); + u4Tmp[0] = rtl8723au_read32(padapter, 0x484); rsprintf(btCoexDbgBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x484(rate adaptive)", \ u4Tmp[0]); DCMD_Printf(btCoexDbgBuf); - u4Tmp[0] = rtw_read32(padapter, 0x50); + u4Tmp[0] = rtl8723au_read32(padapter, 0x50); rsprintf(btCoexDbgBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0xc50(dig)", \ u4Tmp[0]); DCMD_Printf(btCoexDbgBuf); - u4Tmp[0] = rtw_read32(padapter, 0xda0); - u4Tmp[1] = rtw_read32(padapter, 0xda4); - u4Tmp[2] = rtw_read32(padapter, 0xda8); - u4Tmp[3] = rtw_read32(padapter, 0xdac); + u4Tmp[0] = rtl8723au_read32(padapter, 0xda0); + u4Tmp[1] = rtl8723au_read32(padapter, 0xda4); + u4Tmp[2] = rtl8723au_read32(padapter, 0xda8); + u4Tmp[3] = rtl8723au_read32(padapter, 0xdac); rsprintf(btCoexDbgBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0xda0/0xda4/0xda8/0xdac(FA cnt)", \ u4Tmp[0], u4Tmp[1], u4Tmp[2], u4Tmp[3]); DCMD_Printf(btCoexDbgBuf); - u4Tmp[0] = rtw_read32(padapter, 0x6c0); - u4Tmp[1] = rtw_read32(padapter, 0x6c4); - u4Tmp[2] = rtw_read32(padapter, 0x6c8); - u1Tmp = rtw_read8(padapter, 0x6cc); + u4Tmp[0] = rtl8723au_read32(padapter, 0x6c0); + u4Tmp[1] = rtl8723au_read32(padapter, 0x6c4); + u4Tmp[2] = rtl8723au_read32(padapter, 0x6c8); + u1Tmp = rtl8723au_read8(padapter, 0x6cc); rsprintf(btCoexDbgBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \ u4Tmp[0], u4Tmp[1], u4Tmp[2], u1Tmp); DCMD_Printf(btCoexDbgBuf); - /* u4Tmp = rtw_read32(padapter, 0x770); */ + /* u4Tmp = rtl8723au_read32(padapter, 0x770); */ rsprintf(btCoexDbgBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d", "0x770(Hi pri Rx[31:16]/Tx[15:0])", \ pHalData->bt_coexist.halCoex8723.highPriorityRx, pHalData->bt_coexist.halCoex8723.highPriorityTx); DCMD_Printf(btCoexDbgBuf); - /* u4Tmp = rtw_read32(padapter, 0x774); */ + /* u4Tmp = rtl8723au_read32(padapter, 0x774); */ rsprintf(btCoexDbgBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d", "0x774(Lo pri Rx[31:16]/Tx[15:0])", \ pHalData->bt_coexist.halCoex8723.lowPriorityRx, pHalData->bt_coexist.halCoex8723.lowPriorityTx); DCMD_Printf(btCoexDbgBuf); /* Tx mgnt queue hang or not, 0x41b should = 0xf, ex: 0xd ==>hang */ - u1Tmp = rtw_read8(padapter, 0x41b); + u1Tmp = rtl8723au_read8(padapter, 0x41b); rsprintf(btCoexDbgBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x41b (hang chk == 0xf)", \ u1Tmp); DCMD_Printf(btCoexDbgBuf); @@ -9941,15 +9942,15 @@ void BTDM_CheckBTIdleChange1Ant(struct rtw_adapter *padapter) else regBTPolling = REG_BT_POLLING; - BT_Active = rtw_read32(padapter, regBTActive); + BT_Active = rtl8723au_read32(padapter, regBTActive); RTPRINT(FBT, BT_TRACE, ("[DM][BT], BT_Active(0x%x) =%x\n", regBTActive, BT_Active)); BT_Active = BT_Active & 0x00ffffff; - BT_State = rtw_read32(padapter, regBTState); + BT_State = rtl8723au_read32(padapter, regBTState); RTPRINT(FBT, BT_TRACE, ("[DM][BT], BT_State(0x%x) =%x\n", regBTState, BT_State)); BT_State = BT_State & 0x00ffffff; - BT_Polling = rtw_read32(padapter, regBTPolling); + BT_Polling = rtl8723au_read32(padapter, regBTPolling); RTPRINT(FBT, BT_TRACE, ("[DM][BT], BT_Polling(0x%x) =%x\n", regBTPolling, BT_Polling)); if (BT_Active == 0xffffffff && BT_State == 0xffffffff && BT_Polling == 0xffffffff) @@ -10585,7 +10586,7 @@ u8 BTDM_DisableEDCATurbo(struct rtw_adapter *padapter) pHalData->odmpriv.DM_EDCA_Table.bCurrentTurboEDCA = false; pHalData->dmpriv.prv_traffic_idx = 3; } - cur_EDCA_reg = rtw_read32(padapter, REG_EDCA_BE_PARAM); + cur_EDCA_reg = rtl8723au_read32(padapter, REG_EDCA_BE_PARAM); if (cur_EDCA_reg != EDCA_BT_BE) bBtChangeEDCA = true; diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c index 9bbb09f09ff7..06973d541a4a 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c @@ -20,6 +20,7 @@ #include #include #include +#include #define RTL92C_MAX_H2C_BOX_NUMS 4 #define RTL92C_MAX_CMD_LEN 5 @@ -33,7 +34,7 @@ static u8 _is_fw_read_cmd_down(struct rtw_adapter *padapter, u8 msgbox_num) u8 valid; do { - valid = rtw_read8(padapter, REG_HMETFR) & BIT(msgbox_num); + valid = rtl8723au_read8(padapter, REG_HMETFR) & BIT(msgbox_num); if (0 == valid) read_down = true; } while ((!read_down) && (retry_cnts--)); @@ -610,7 +611,7 @@ void rtl8723a_set_FwJoinBssReport_cmd(struct rtw_adapter *padapter, u8 mstatus) /* rtw_write8(padapter, REG_HWSEQ_CTRL, 0xFF); */ /* set REG_CR bit 8 */ - v8 = rtw_read8(padapter, REG_CR+1); + v8 = rtl8723au_read8(padapter, REG_CR+1); v8 |= BIT(0); /* ENSWBCN */ rtw_write8(padapter, REG_CR+1, v8); @@ -626,7 +627,7 @@ void rtl8723a_set_FwJoinBssReport_cmd(struct rtw_adapter *padapter, u8 mstatus) bRecover = true; /* To tell Hw the packet is not a real beacon frame. */ - /* U1bTmp = rtw_read8(padapter, REG_FWHW_TXQ_CTRL+2); */ + /* U1bTmp = rtl8723au_read8(padapter, REG_FWHW_TXQ_CTRL+2); */ rtw_write8(padapter, REG_FWHW_TXQ_CTRL+2, pHalData->RegFwHwTxQCtrl & ~BIT(6)); pHalData->RegFwHwTxQCtrl &= ~BIT(6); SetFwRsvdPagePkt(padapter, 0); @@ -645,7 +646,7 @@ void rtl8723a_set_FwJoinBssReport_cmd(struct rtw_adapter *padapter, u8 mstatus) } /* Clear CR[8] or beacon packet will not be send to TxBuf anymore. */ - v8 = rtw_read8(padapter, REG_CR+1); + v8 = rtl8723au_read8(padapter, REG_CR+1); v8 &= ~BIT(0); /* ~ENSWBCN */ rtw_write8(padapter, REG_CR+1, v8); } diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_dm.c b/drivers/staging/rtl8723au/hal/rtl8723a_dm.c index 4ca7b8ec7b38..1ec73e7e2f06 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_dm.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_dm.c @@ -28,6 +28,7 @@ #include #include +#include /* */ /* Global var */ @@ -45,18 +46,18 @@ static void dm_CheckPbcGPIO(struct rtw_adapter *padapter) if (!padapter->registrypriv.hw_wps_pbc) return; - tmp1byte = rtw_read8(padapter, GPIO_IO_SEL); + tmp1byte = rtl8723au_read8(padapter, GPIO_IO_SEL); tmp1byte |= (HAL_8192C_HW_GPIO_WPS_BIT); rtw_write8(padapter, GPIO_IO_SEL, tmp1byte); /* enable GPIO[2] as output mode */ tmp1byte &= ~(HAL_8192C_HW_GPIO_WPS_BIT); rtw_write8(padapter, GPIO_IN, tmp1byte); /* reset the floating voltage level */ - tmp1byte = rtw_read8(padapter, GPIO_IO_SEL); + tmp1byte = rtl8723au_read8(padapter, GPIO_IO_SEL); tmp1byte &= ~(HAL_8192C_HW_GPIO_WPS_BIT); rtw_write8(padapter, GPIO_IO_SEL, tmp1byte); /* enable GPIO[2] as input mode */ - tmp1byte = rtw_read8(padapter, GPIO_IN); + tmp1byte = rtl8723au_read8(padapter, GPIO_IN); if (tmp1byte == 0xff) return; @@ -197,7 +198,7 @@ void rtl8723a_InitHalDm(struct rtw_adapter *Adapter) ODM23a_DMInit(pDM_Odm); /* Save REG_INIDATA_RATE_SEL value for TXDESC. */ for (i = 0; i < 32; i++) - pdmpriv->INIDATA_RATE[i] = rtw_read8(Adapter, REG_INIDATA_RATE_SEL+i) & 0x3f; + pdmpriv->INIDATA_RATE[i] = rtl8723au_read8(Adapter, REG_INIDATA_RATE_SEL+i) & 0x3f; } void @@ -225,11 +226,11 @@ rtl8723a_HalDmWatchDog( /* Read REG_INIDATA_RATE_SEL value for TXDESC. */ if (check_fwstate(&Adapter->mlmepriv, WIFI_STATION_STATE)) { - pdmpriv->INIDATA_RATE[0] = rtw_read8(Adapter, REG_INIDATA_RATE_SEL) & 0x3f; + pdmpriv->INIDATA_RATE[0] = rtl8723au_read8(Adapter, REG_INIDATA_RATE_SEL) & 0x3f; } else { u8 i; for (i = 1 ; i < (Adapter->stapriv.asoc_sta_count + 1); i++) - pdmpriv->INIDATA_RATE[i] = rtw_read8(Adapter, (REG_INIDATA_RATE_SEL+i)) & 0x3f; + pdmpriv->INIDATA_RATE[i] = rtl8723au_read8(Adapter, (REG_INIDATA_RATE_SEL+i)) & 0x3f; } } diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index df90c662e6a9..ea8def5de7d7 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -19,6 +19,7 @@ #include #include +#include static void _FWDownloadEnable(struct rtw_adapter *padapter, bool enable) { @@ -26,19 +27,19 @@ static void _FWDownloadEnable(struct rtw_adapter *padapter, bool enable) if (enable) { /* 8051 enable */ - tmp = rtw_read8(padapter, REG_SYS_FUNC_EN + 1); + tmp = rtl8723au_read8(padapter, REG_SYS_FUNC_EN + 1); rtw_write8(padapter, REG_SYS_FUNC_EN + 1, tmp | 0x04); /* MCU firmware download enable. */ - tmp = rtw_read8(padapter, REG_MCUFWDL); + tmp = rtl8723au_read8(padapter, REG_MCUFWDL); rtw_write8(padapter, REG_MCUFWDL, tmp | 0x01); /* 8051 reset */ - tmp = rtw_read8(padapter, REG_MCUFWDL + 2); + tmp = rtl8723au_read8(padapter, REG_MCUFWDL + 2); rtw_write8(padapter, REG_MCUFWDL + 2, tmp & 0xf7); } else { /* MCU firmware download disable. */ - tmp = rtw_read8(padapter, REG_MCUFWDL); + tmp = rtl8723au_read8(padapter, REG_MCUFWDL); rtw_write8(padapter, REG_MCUFWDL, tmp & 0xfe); /* Reserved for fw extension. */ @@ -142,7 +143,7 @@ _PageWrite(struct rtw_adapter *padapter, u32 page, void *buffer, u32 size) u8 value8; u8 u8Page = (u8) (page & 0x07); - value8 = (rtw_read8(padapter, REG_MCUFWDL + 2) & 0xF8) | u8Page; + value8 = (rtl8723au_read8(padapter, REG_MCUFWDL + 2) & 0xF8) | u8Page; rtw_write8(padapter, REG_MCUFWDL + 2, value8); return _BlockWrite(padapter, buffer, size); @@ -194,7 +195,7 @@ static int _FWFreeToGo(struct rtw_adapter *padapter) /* polling CheckSum report */ do { - value32 = rtw_read32(padapter, REG_MCUFWDL); + value32 = rtl8723au_read32(padapter, REG_MCUFWDL); if (value32 & FWDL_ChkSum_rpt) break; } while (counter++ < POLLING_READY_TIMEOUT_COUNT); @@ -209,7 +210,7 @@ static int _FWFreeToGo(struct rtw_adapter *padapter) ("%s: Checksum report OK! REG_MCUFWDL:0x%08x\n", __func__, value32)); - value32 = rtw_read32(padapter, REG_MCUFWDL); + value32 = rtl8723au_read32(padapter, REG_MCUFWDL); value32 |= MCUFWDL_RDY; value32 &= ~WINTINI_RDY; rtw_write32(padapter, REG_MCUFWDL, value32); @@ -217,7 +218,7 @@ static int _FWFreeToGo(struct rtw_adapter *padapter) /* polling for FW ready */ counter = 0; do { - value32 = rtw_read32(padapter, REG_MCUFWDL); + value32 = rtl8723au_read32(padapter, REG_MCUFWDL); if (value32 & WINTINI_RDY) { RT_TRACE(_module_hal_init_c_, _drv_info_, ("%s: Polling FW ready success!! " @@ -250,13 +251,13 @@ void rtl8723a_FirmwareSelfReset(struct rtw_adapter *padapter) /* 0x1cf = 0x20. Inform 8051 to reset. 2009.12.25. tynli_test */ rtw_write8(padapter, REG_HMETFR + 3, 0x20); - u1bTmp = rtw_read8(padapter, REG_SYS_FUNC_EN + 1); + u1bTmp = rtl8723au_read8(padapter, REG_SYS_FUNC_EN + 1); while (u1bTmp & BIT(2)) { Delay--; if (Delay == 0) break; udelay(50); - u1bTmp = rtw_read8(padapter, REG_SYS_FUNC_EN + 1); + u1bTmp = rtl8723au_read8(padapter, REG_SYS_FUNC_EN + 1); } RT_TRACE(_module_hal_init_c_, _drv_info_, ("-%s: 8051 reset success (%d)\n", __func__, @@ -264,7 +265,7 @@ void rtl8723a_FirmwareSelfReset(struct rtw_adapter *padapter) if ((Delay == 0)) { /* force firmware reset */ - u1bTmp = rtw_read8(padapter, REG_SYS_FUNC_EN + 1); + u1bTmp = rtl8723au_read8(padapter, REG_SYS_FUNC_EN + 1); rtw_write8(padapter, REG_SYS_FUNC_EN + 1, u1bTmp & ~BIT(2)); } @@ -372,7 +373,7 @@ int rtl8723a_FirmwareDownload(struct rtw_adapter *padapter) /* Suggested by Filen. If 8051 is running in RAM code, driver should inform Fw to reset by itself, */ /* or it will cause download Fw fail. 2010.02.01. by tynli. */ - if (rtw_read8(padapter, REG_MCUFWDL) & RAM_DL_SEL) { + if (rtl8723au_read8(padapter, REG_MCUFWDL) & RAM_DL_SEL) { /* 8051 RAM code */ rtl8723a_FirmwareSelfReset(padapter); rtw_write8(padapter, REG_MCUFWDL, 0x00); @@ -383,7 +384,7 @@ int rtl8723a_FirmwareDownload(struct rtw_adapter *padapter) while (1) { /* reset the FWDL chksum */ rtw_write8(padapter, REG_MCUFWDL, - rtw_read8(padapter, REG_MCUFWDL) | FWDL_ChkSum_rpt); + rtl8723au_read8(padapter, REG_MCUFWDL) | FWDL_ChkSum_rpt); rtStatus = _WriteFW(padapter, buf, fw_size); @@ -437,7 +438,7 @@ hal_EfuseSwitchToBank(struct rtw_adapter *padapter, u8 bank) u32 value32 = 0; DBG_8723A("%s: Efuse switch bank to %d\n", __func__, bank); - value32 = rtw_read32(padapter, EFUSE_TEST); + value32 = rtl8723au_read32(padapter, EFUSE_TEST); bRet = true; switch (bank) { case 0: @@ -905,7 +906,7 @@ void rtl8723a_read_chip_version(struct rtw_adapter *padapter) pHalData = GET_HAL_DATA(padapter); - value32 = rtw_read32(padapter, REG_SYS_CFG); + value32 = rtl8723au_read32(padapter, REG_SYS_CFG); ChipVersion.ICType = CHIP_8723A; ChipVersion.ChipType = ((value32 & RTL_ID) ? TEST_CHIP : NORMAL_CHIP); ChipVersion.RFType = RF_TYPE_1T1R; @@ -917,13 +918,13 @@ void rtl8723a_read_chip_version(struct rtw_adapter *padapter) pHalData->RegulatorMode = ((value32 & SPS_SEL) ? RT_LDO_REGULATOR : RT_SWITCHING_REGULATOR); - value32 = rtw_read32(padapter, REG_GPIO_OUTSTS); + value32 = rtl8723au_read32(padapter, REG_GPIO_OUTSTS); /* ROM code version. */ ChipVersion.ROMVer = ((value32 & RF_RL_ID) >> 20); /* For multi-function consideration. Added by Roger, 2010.10.06. */ pHalData->MultiFunc = RT_MULTI_FUNC_NONE; - value32 = rtw_read32(padapter, REG_MULTI_FUNC_CTRL); + value32 = rtl8723au_read32(padapter, REG_MULTI_FUNC_CTRL); pHalData->MultiFunc |= ((value32 & WL_FUNC_EN) ? RT_MULTI_FUNC_WIFI : 0); pHalData->MultiFunc |= ((value32 & BT_FUNC_EN) ? RT_MULTI_FUNC_BT : 0); @@ -967,7 +968,7 @@ void SetBcnCtrlReg23a(struct rtw_adapter *padapter, u8 SetBits, u8 ClearBits) addr = REG_BCN_CTRL; - *pRegBcnCtrlVal = rtw_read8(padapter, addr); + *pRegBcnCtrlVal = rtl8723au_read8(padapter, addr); *pRegBcnCtrlVal |= SetBits; *pRegBcnCtrlVal &= ~ClearBits; @@ -1075,7 +1076,7 @@ void rtl8723a_SetBeaconRelatedRegisters(struct rtw_adapter *padapter) /* */ /* Reset TSF Timer to zero, added by Roger. 2008.06.24 */ /* */ - value32 = rtw_read32(padapter, REG_TCR); + value32 = rtl8723au_read32(padapter, REG_TCR); value32 &= ~TSFRST; rtw_write32(padapter, REG_TCR, value32); @@ -1135,11 +1136,11 @@ void rtl8723a_notch_filter(struct rtw_adapter *adapter, bool enable) if (enable) { DBG_8723A("Enable notch filter\n"); rtw_write8(adapter, rOFDM0_RxDSP + 1, - rtw_read8(adapter, rOFDM0_RxDSP + 1) | BIT(1)); + rtl8723au_read8(adapter, rOFDM0_RxDSP + 1) | BIT(1)); } else { DBG_8723A("Disable notch filter\n"); rtw_write8(adapter, rOFDM0_RxDSP + 1, - rtw_read8(adapter, rOFDM0_RxDSP + 1) & ~BIT(1)); + rtl8723au_read8(adapter, rOFDM0_RxDSP + 1) & ~BIT(1)); } } @@ -1214,7 +1215,7 @@ void rtl8723a_InitAntenna_Selection(struct rtw_adapter *padapter) { u8 val; - val = rtw_read8(padapter, REG_LEDCFG2); + val = rtl8723au_read8(padapter, REG_LEDCFG2); /* Let 8051 take control antenna settting */ val |= BIT(7); /* DPDT_SEL_EN, 0x4C[23] */ rtw_write8(padapter, REG_LEDCFG2, val); @@ -1224,7 +1225,7 @@ void rtl8723a_CheckAntenna_Selection(struct rtw_adapter *padapter) { u8 val; - val = rtw_read8(padapter, REG_LEDCFG2); + val = rtl8723au_read8(padapter, REG_LEDCFG2); /* Let 8051 take control antenna settting */ if (!(val & BIT(7))) { val |= BIT(7); /* DPDT_SEL_EN, 0x4C[23] */ @@ -1236,7 +1237,7 @@ void rtl8723a_DeinitAntenna_Selection(struct rtw_adapter *padapter) { u8 val; - val = rtw_read8(padapter, REG_LEDCFG2); + val = rtl8723au_read8(padapter, REG_LEDCFG2); /* Let 8051 take control antenna settting */ val &= ~BIT(7); /* DPDT_SEL_EN, clear 0x4C[23] */ rtw_write8(padapter, REG_LEDCFG2, val); @@ -1279,7 +1280,7 @@ u8 GetEEPROMSize8723A(struct rtw_adapter *padapter) u8 size = 0; u32 cr; - cr = rtw_read16(padapter, REG_9346CR); + cr = rtl8723au_read16(padapter, REG_9346CR); /* 6: EEPROM used is 93C46, 4: boot from E-Fuse. */ size = (cr & BOOT_FROM_EEPROM) ? 6 : 4; @@ -1305,7 +1306,7 @@ static int _LLTWrite(struct rtw_adapter *padapter, u32 address, u32 data) /* polling */ do { - value = rtw_read32(padapter, LLTReg); + value = rtl8723au_read32(padapter, LLTReg); if (_LLT_NO_ACTIVE == _LLT_OP_VALUE(value)) { break; } @@ -1376,7 +1377,7 @@ n. LEDCFG 0x4C[15:0] = 0x8080 /* 1. Disable GPIO[7:0] */ rtw_write16(padapter, REG_GPIO_PIN_CTRL + 2, 0x0000); - value32 = rtw_read32(padapter, REG_GPIO_PIN_CTRL) & 0xFFFF00FF; + value32 = rtl8723au_read32(padapter, REG_GPIO_PIN_CTRL) & 0xFFFF00FF; u4bTmp = value32 & 0x000000FF; value32 |= ((u4bTmp << 8) | 0x00FF0000); rtw_write32(padapter, REG_GPIO_PIN_CTRL, value32); @@ -1391,7 +1392,7 @@ n. LEDCFG 0x4C[15:0] = 0x8080 /* Configure all pins as input mode. */ rtw_write16(padapter, REG_GPIO_IO_SEL_2, 0x0000); - value32 = rtw_read32(padapter, REG_GPIO_PIN_CTRL_2) & 0xFFFF001F; + value32 = rtl8723au_read32(padapter, REG_GPIO_PIN_CTRL_2) & 0xFFFF001F; u4bTmp = value32 & 0x0000001F; /* Set pin 8, 10, 11 and pin 12 to output mode. */ value32 |= ((u4bTmp << 8) | 0x001D0000); @@ -1455,15 +1456,15 @@ static void _ResetDigitalProcedure1_92C(struct rtw_adapter *padapter, u16 valu16 = 0; rtw_write8(padapter, REG_MCUFWDL, 0); - valu16 = rtw_read16(padapter, REG_SYS_FUNC_EN); + valu16 = rtl8723au_read16(padapter, REG_SYS_FUNC_EN); /* reset MCU , 8051 */ rtw_write16(padapter, REG_SYS_FUNC_EN, (valu16 & (~FEN_CPUEN))); - valu16 = rtw_read16(padapter, REG_SYS_FUNC_EN) & 0x0FFF; + valu16 = rtl8723au_read16(padapter, REG_SYS_FUNC_EN) & 0x0FFF; rtw_write16(padapter, REG_SYS_FUNC_EN, (valu16 | (FEN_HWPDN | FEN_ELDR))); /* reset MAC */ - valu16 = rtw_read16(padapter, REG_SYS_FUNC_EN); + valu16 = rtl8723au_read16(padapter, REG_SYS_FUNC_EN); /* enable MCU , 8051 */ rtw_write16(padapter, REG_SYS_FUNC_EN, (valu16 | FEN_CPUEN)); } else { @@ -1474,7 +1475,7 @@ static void _ResetDigitalProcedure1_92C(struct rtw_adapter *padapter, S3/S4/S5/Disable, we can stop 8051 because */ /* we will init FW when power on again. */ /* If we want to SS mode, we can not reset 8051. */ - if (rtw_read8(padapter, REG_MCUFWDL) & BIT(1)) { + if (rtl8723au_read8(padapter, REG_MCUFWDL) & BIT(1)) { /* IF fw in RAM code, do reset */ if (padapter->bFWReady) { /* 2010/08/25 MH Accordign to RD alfred's @@ -1492,7 +1493,8 @@ static void _ResetDigitalProcedure1_92C(struct rtw_adapter *padapter, while ((retry_cnts++ < 100) && (FEN_CPUEN & - rtw_read16(padapter, REG_SYS_FUNC_EN))) { + rtl8723au_read16(padapter, + REG_SYS_FUNC_EN))) { udelay(50); /* us */ } @@ -1564,7 +1566,7 @@ static void _DisableAnalog(struct rtw_adapter *padapter, bool bWithoutHWSM) rtw_write8(padapter, REG_LDOA15_CTRL, 0x04); /* rtw_write8(padapter, REG_LDOV12D_CTRL, 0x54); */ - value8 = rtw_read8(padapter, REG_LDOV12D_CTRL); + value8 = rtl8723au_read8(padapter, REG_LDOV12D_CTRL); value8 &= (~LDV12_EN); rtw_write8(padapter, REG_LDOV12D_CTRL, value8); /* RT_TRACE(COMP_INIT, DBG_LOUD, @@ -1909,7 +1911,7 @@ Hal_EfuseParseBTCoexistInfo_8723A(struct rtw_adapter *padapter, u32 tmpu4; if (!AutoLoadFail) { - tmpu4 = rtw_read32(padapter, REG_MULTI_FUNC_CTRL); + tmpu4 = rtl8723au_read32(padapter, REG_MULTI_FUNC_CTRL); if (tmpu4 & BT_FUNC_EN) pHalData->EEPROMBluetoothCoexist = 1; else @@ -2422,7 +2424,7 @@ void hw_var_set_opmode(struct rtw_adapter *padapter, u8 mode) SetBcnCtrlReg23a(padapter, val8, ~val8); } - val8 = rtw_read8(padapter, MSR); + val8 = rtl8723au_read8(padapter, MSR); val8 = (val8 & 0xC) | mode; rtw_write8(padapter, MSR, val8); } @@ -2466,7 +2468,7 @@ void hw_var_set_correct_tsf(struct rtw_adapter *padapter) ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)) { /* pHalData->RegTxPause |= STOP_BCNQ;BIT(6) */ /* rtw_write8(padapter, REG_TXPAUSE, - (rtw_read8(Adapter, REG_TXPAUSE)|BIT(6))); */ + (rtl8723au_read8(Adapter, REG_TXPAUSE)|BIT(6))); */ StopTxBeacon(padapter); } @@ -2510,10 +2512,10 @@ void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type) /* enable to rx data frame.Accept all data frame */ /* rtw_write32(padapter, REG_RCR, - rtw_read32(padapter, REG_RCR)|RCR_ADF); */ + rtl8723au_read32(padapter, REG_RCR)|RCR_ADF); */ rtw_write16(padapter, REG_RXFLTMAP2, 0xFFFF); - v32 = rtw_read32(padapter, REG_RCR); + v32 = rtl8723au_read32(padapter, REG_RCR); v32 |= RCR_CBSSID_DATA | RCR_CBSSID_BCN; rtw_write32(padapter, REG_RCR, v32); diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c b/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c index c48cf04e60e0..ad999ffd4050 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c @@ -18,6 +18,7 @@ #include #include +#include /*---------------------------Define Local Constant---------------------------*/ /* Channel switch:The size of command tables for switch channel*/ @@ -87,7 +88,7 @@ PHY_QueryBBReg(struct rtw_adapter *Adapter, u32 RegAddr, u32 BitMask) { u32 ReturnValue = 0, OriginalValue, BitShift; - OriginalValue = rtw_read32(Adapter, RegAddr); + OriginalValue = rtl8723au_read32(Adapter, RegAddr); BitShift = phy_CalculateBitShift(BitMask); ReturnValue = (OriginalValue & BitMask) >> BitShift; return ReturnValue; @@ -123,7 +124,7 @@ PHY_SetBBReg(struct rtw_adapter *Adapter, u32 RegAddr, u32 BitMask, u32 Data) /* RT_TRACE(COMP_RF, DBG_TRACE, ("--->PHY_SetBBReg(): RegAddr(%#lx), BitMask(%#lx), Data(%#lx)\n", RegAddr, BitMask, Data)); */ if (BitMask != bMaskDWord) {/* if not "double word" write */ - OriginalValue = rtw_read32(Adapter, RegAddr); + OriginalValue = rtl8723au_read32(Adapter, RegAddr); BitShift = phy_CalculateBitShift(BitMask); Data = ((OriginalValue & (~BitMask)) | (Data << BitShift)); } @@ -804,7 +805,7 @@ PHY_BBConfig8723A(struct rtw_adapter *Adapter) /* Suggested by Scott. tynli_test. 2010.12.30. */ /* 1. 0x28[1] = 1 */ - TmpU1B = rtw_read8(Adapter, REG_AFE_PLL_CTRL); + TmpU1B = rtl8723au_read8(Adapter, REG_AFE_PLL_CTRL); udelay(2); rtw_write8(Adapter, REG_AFE_PLL_CTRL, TmpU1B | BIT(1)); udelay(2); @@ -814,16 +815,16 @@ PHY_BBConfig8723A(struct rtw_adapter *Adapter) udelay(2); /* 3. 0x02[1:0] = 2b'11 */ - TmpU1B = rtw_read8(Adapter, REG_SYS_FUNC_EN); + TmpU1B = rtl8723au_read8(Adapter, REG_SYS_FUNC_EN); rtw_write8(Adapter, REG_SYS_FUNC_EN, (TmpU1B | FEN_BB_GLB_RSTn | FEN_BBRSTB)); /* 4. 0x25[6] = 0 */ - TmpU1B = rtw_read8(Adapter, REG_AFE_XTAL_CTRL + 1); + TmpU1B = rtl8723au_read8(Adapter, REG_AFE_XTAL_CTRL + 1); rtw_write8(Adapter, REG_AFE_XTAL_CTRL+1, TmpU1B & ~BIT(6)); /* 5. 0x24[20] = 0 Advised by SD3 Alex Wang. 2011.02.09. */ - TmpU1B = rtw_read8(Adapter, REG_AFE_XTAL_CTRL+2); + TmpU1B = rtl8723au_read8(Adapter, REG_AFE_XTAL_CTRL+2); rtw_write8(Adapter, REG_AFE_XTAL_CTRL+2, TmpU1B & ~BIT(4)); /* 6. 0x1f[7:0] = 0x07 */ @@ -956,8 +957,8 @@ _PHY_SetBWMode23a92C(struct rtw_adapter *Adapter) /* 3<1>Set MAC register */ /* 3 */ - regBwOpMode = rtw_read8(Adapter, REG_BWOPMODE); - regRRSR_RSC = rtw_read8(Adapter, REG_RRSR+2); + regBwOpMode = rtl8723au_read8(Adapter, REG_BWOPMODE); + regRRSR_RSC = rtl8723au_read8(Adapter, REG_RRSR+2); switch (pHalData->CurrentChannelBW) { case HT_CHANNEL_WIDTH_20: diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_sreset.c b/drivers/staging/rtl8723au/hal/rtl8723a_sreset.c index 54b0dfb6eebf..0680e29a5528 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_sreset.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_sreset.c @@ -16,6 +16,7 @@ #include #include +#include void rtl8723a_sreset_xmit_status_check(struct rtw_adapter *padapter) { @@ -27,7 +28,7 @@ void rtl8723a_sreset_xmit_status_check(struct rtw_adapter *padapter) unsigned int diff_time; u32 txdma_status; - txdma_status = rtw_read32(padapter, REG_TXDMA_STATUS); + txdma_status = rtl8723au_read32(padapter, REG_TXDMA_STATUS); if (txdma_status != 0) { DBG_8723A("%s REG_TXDMA_STATUS:0x%08x\n", __func__, txdma_status); rtw_sreset_reset(padapter); diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_led.c b/drivers/staging/rtl8723au/hal/rtl8723au_led.c index b06905d019d3..4c9318f4ac85 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723au_led.c +++ b/drivers/staging/rtl8723au/hal/rtl8723au_led.c @@ -16,6 +16,7 @@ #include "drv_types.h" #include "rtl8723a_hal.h" #include "rtl8723a_led.h" +#include "usb_ops_linux.h" /* */ /* LED object. */ @@ -49,7 +50,7 @@ void SwLedOn23a(struct rtw_adapter *padapter, struct led_8723a *pLed) rtw_write8(padapter, REG_LEDCFG1, (LedCfg&0x00)|BIT(6)); break; case LED_PIN_LED2: - LedCfg = rtw_read8(padapter, REG_LEDCFG2); + LedCfg = rtl8723au_read8(padapter, REG_LEDCFG2); /* SW control led1 on. */ rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0x80)|BIT(5)); break; @@ -81,7 +82,7 @@ void SwLedOff23a(struct rtw_adapter *padapter, struct led_8723a *pLed) rtw_write8(padapter, REG_LEDCFG1, (LedCfg&0x00)|BIT(5)|BIT(6)); break; case LED_PIN_LED2: - LedCfg = rtw_read8(padapter, REG_LEDCFG2); + LedCfg = rtl8723au_read8(padapter, REG_LEDCFG2); /* SW control led1 on. */ rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0x80)|BIT(3)|BIT(5)); break; diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 46dcc567aa2d..750f1ca4d515 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -36,7 +36,7 @@ _ConfigChipOutEP(struct rtw_adapter *pAdapter, u8 NumOutPipe) pHalData->OutEpNumber = 0; /* Normal and High queue */ - value8 = rtw_read8(pAdapter, (REG_NORMAL_SIE_EP + 1)); + value8 = rtl8723au_read8(pAdapter, (REG_NORMAL_SIE_EP + 1)); if (value8 & USB_NORMAL_SIE_EP_MASK) { pHalData->OutEpQueueSel |= TX_SELE_HQ; @@ -49,7 +49,7 @@ _ConfigChipOutEP(struct rtw_adapter *pAdapter, u8 NumOutPipe) } /* Low queue */ - value8 = rtw_read8(pAdapter, (REG_NORMAL_SIE_EP + 2)); + value8 = rtl8723au_read8(pAdapter, (REG_NORMAL_SIE_EP + 2)); if (value8 & USB_NORMAL_SIE_EP_MASK) { pHalData->OutEpQueueSel |= TX_SELE_LQ; pHalData->OutEpNumber++; @@ -108,13 +108,13 @@ static int _InitPowerOn(struct rtw_adapter *padapter) return _FAIL; /* 0x04[19] = 1, suggest by Jackie 2011.05.09, reset 8051 */ - value8 = rtw_read8(padapter, REG_APS_FSMCO+2); + value8 = rtl8723au_read8(padapter, REG_APS_FSMCO+2); rtw_write8(padapter, REG_APS_FSMCO + 2, value8 | BIT(3)); /* Enable MAC DMA/WMAC/SCHEDULE/SEC block */ /* Set CR bit10 to enable 32k calibration. Suggested by SD1 Gimmy. Added by tynli. 2011.08.31. */ - value16 = rtw_read16(padapter, REG_CR); + value16 = rtl8723au_read16(padapter, REG_CR); value16 |= (HCI_TXDMA_EN | HCI_RXDMA_EN | TXDMA_EN | RXDMA_EN | PROTOCOL_EN | SCHEDULE_EN | MACTXEN | MACRXEN | ENSEC | CALTMR_EN); @@ -216,7 +216,7 @@ static void _InitNormalChipRegPriority(struct rtw_adapter *Adapter, u16 beQ, u16 bkQ, u16 viQ, u16 voQ, u16 mgtQ, u16 hiQ) { - u16 value16 = rtw_read16(Adapter, REG_TRXDMA_CTRL) & 0x7; + u16 value16 = rtl8723au_read16(Adapter, REG_TRXDMA_CTRL) & 0x7; value16 |= _TXDMA_BEQ_MAP(beQ) | _TXDMA_BKQ_MAP(bkQ) | _TXDMA_VIQ_MAP(viQ) | _TXDMA_VOQ_MAP(voQ) | @@ -346,7 +346,7 @@ static void _InitNetworkType(struct rtw_adapter *Adapter) { u32 value32; - value32 = rtw_read32(Adapter, REG_CR); + value32 = rtl8723au_read32(Adapter, REG_CR); /* TODO: use the other function to set network type */ value32 = (value32 & ~MASK_NETTYPE) | _NETTYPE(NT_LINK_AP); @@ -402,7 +402,7 @@ static void _InitWMACSetting(struct rtw_adapter *Adapter) /* rtw_write16(Adapter, REG_RXFLTMAP0, value16); */ /* enable RX_SHIFT bits */ - /* rtw_write8(Adapter, REG_TRXDMA_CTRL, rtw_read8(Adapter, + /* rtw_write8(Adapter, REG_TRXDMA_CTRL, rtl8723au_read8(Adapter, REG_TRXDMA_CTRL)|BIT(1)); */ } @@ -412,7 +412,7 @@ static void _InitAdaptiveCtrl(struct rtw_adapter *Adapter) u32 value32; /* Response Rate Set */ - value32 = rtw_read32(Adapter, REG_RRSR); + value32 = rtl8723au_read32(Adapter, REG_RRSR); value32 &= ~RATE_BITMAP_ALL; value32 |= RATE_RRSR_CCK_ONLY_1M; rtw_write32(Adapter, REG_RRSR, value32); @@ -480,7 +480,7 @@ static void _InitRetryFunction(struct rtw_adapter *Adapter) { u8 value8; - value8 = rtw_read8(Adapter, REG_FWHW_TXQ_CTRL); + value8 = rtl8723au_read8(Adapter, REG_FWHW_TXQ_CTRL); value8 |= EN_AMPDU_RTY_NEW; rtw_write8(Adapter, REG_FWHW_TXQ_CTRL, value8); @@ -589,13 +589,14 @@ enum rt_rf_power_state RfOnOffDetect23a(struct rtw_adapter *pAdapter) enum rt_rf_power_state rfpowerstate = rf_off; if (pAdapter->pwrctrlpriv.bHWPowerdown) { - val8 = rtw_read8(pAdapter, REG_HSISR); + val8 = rtl8723au_read8(pAdapter, REG_HSISR); DBG_8723A("pwrdown, 0x5c(BIT7) =%02x\n", val8); rfpowerstate = (val8 & BIT(7)) ? rf_off : rf_on; } else { /* rf on/off */ rtw_write8(pAdapter, REG_MAC_PINMUX_CFG, - rtw_read8(pAdapter, REG_MAC_PINMUX_CFG) & ~BIT(3)); - val8 = rtw_read8(pAdapter, REG_GPIO_IO_SEL); + rtl8723au_read8(pAdapter, REG_MAC_PINMUX_CFG) & + ~BIT(3)); + val8 = rtl8723au_read8(pAdapter, REG_GPIO_IO_SEL); DBG_8723A("GPIO_IN =%02x\n", val8); rfpowerstate = (val8 & BIT(3)) ? rf_on : rf_off; } @@ -634,7 +635,7 @@ static int rtl8723au_hal_init(struct rtw_adapter *Adapter) } /* Check if MAC has already power on. by tynli. 2011.05.27. */ - val8 = rtw_read8(Adapter, REG_CR); + val8 = rtl8723au_read8(Adapter, REG_CR); RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("%s: REG_CR 0x100 = 0x%02x\n", __func__, val8)); /* Fix 92DU-VC S3 hang with the reason is that secondary mac is not @@ -881,13 +882,15 @@ static int rtl8723au_hal_init(struct rtw_adapter *Adapter) rtl8723a_set_nav_upper(Adapter, WiFiNavUpperUs); /* 2011/03/09 MH debug only, UMC-B cut pass 2500 S5 test, but we need to fin root cause. */ - if (((rtw_read32(Adapter, rFPGA0_RFMOD) & 0xFF000000) != 0x83000000)) { + if (((rtl8723au_read32(Adapter, rFPGA0_RFMOD) & 0xFF000000) != + 0x83000000)) { PHY_SetBBReg(Adapter, rFPGA0_RFMOD, BIT(24), 1); RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("%s: IQK fail recorver\n", __func__)); } /* ack for xmit mgmt frames. */ - rtw_write32(Adapter, REG_FWHW_TXQ_CTRL, rtw_read32(Adapter, REG_FWHW_TXQ_CTRL)|BIT(12)); + rtw_write32(Adapter, REG_FWHW_TXQ_CTRL, + rtl8723au_read32(Adapter, REG_FWHW_TXQ_CTRL)|BIT(12)); exit: HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_END); @@ -914,7 +917,7 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, /* 2. Force PWM, Enable SPS18_LDO_Marco_Block */ rtw_write8(Adapter, REG_SPS0_CTRL, - rtw_read8(Adapter, REG_SPS0_CTRL) | + rtl8723au_read8(Adapter, REG_SPS0_CTRL) | BIT(0) | BIT(3)); /* 3. restore BB, AFE control register. */ @@ -958,7 +961,7 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, /* 2. Force PWM, Enable SPS18_LDO_Marco_Block */ rtw_write8(Adapter, REG_SPS0_CTRL, - rtw_read8(Adapter, REG_SPS0_CTRL) | + rtl8723au_read8(Adapter, REG_SPS0_CTRL) | BIT(0) | BIT(3)); /* 3. restore BB, AFE control register. */ @@ -992,7 +995,7 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, } /* 5. gated MAC Clock */ - bytetmp = rtw_read8(Adapter, REG_APSD_CTRL); + bytetmp = rtl8723au_read8(Adapter, REG_APSD_CTRL); rtw_write8(Adapter, REG_APSD_CTRL, bytetmp & ~BIT(6)); mdelay(10); @@ -1006,7 +1009,7 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, break; case rf_sleep: case rf_off: - value8 = rtw_read8(Adapter, REG_SPS0_CTRL) ; + value8 = rtl8723au_read8(Adapter, REG_SPS0_CTRL) ; if (IS_81xxC_VENDOR_UMC_B_CUT(pHalData->VersionID)) value8 &= ~BIT(0); else @@ -1170,12 +1173,12 @@ static void CardDisableRTL8723U(struct rtw_adapter *Adapter) rtw_write8(Adapter, REG_RF_CTRL, 0x00); /* ==== Reset digital sequence ====== */ - if ((rtw_read8(Adapter, REG_MCUFWDL) & BIT(7)) && + if ((rtl8723au_read8(Adapter, REG_MCUFWDL) & BIT(7)) && Adapter->bFWReady) /* 8051 RAM code */ rtl8723a_FirmwareSelfReset(Adapter); /* Reset MCU. Suggested by Filen. 2011.01.26. by tynli. */ - u1bTmp = rtw_read8(Adapter, REG_SYS_FUNC_EN+1); + u1bTmp = rtl8723au_read8(Adapter, REG_SYS_FUNC_EN+1); rtw_write8(Adapter, REG_SYS_FUNC_EN+1, u1bTmp & ~BIT(2)); /* g. MCUFWDL 0x80[1:0]= 0 reset MCU ready status */ @@ -1188,9 +1191,9 @@ static void CardDisableRTL8723U(struct rtw_adapter *Adapter) rtl8723AU_card_disable_flow); /* Reset MCU IO Wrapper, added by Roger, 2011.08.30. */ - u1bTmp = rtw_read8(Adapter, REG_RSV_CTRL + 1); + u1bTmp = rtl8723au_read8(Adapter, REG_RSV_CTRL + 1); rtw_write8(Adapter, REG_RSV_CTRL+1, u1bTmp & ~BIT(0)); - u1bTmp = rtw_read8(Adapter, REG_RSV_CTRL + 1); + u1bTmp = rtl8723au_read8(Adapter, REG_RSV_CTRL + 1); rtw_write8(Adapter, REG_RSV_CTRL+1, u1bTmp | BIT(0)); /* 7. RSV_CTRL 0x1C[7:0] = 0x0E lock ISO/CLK/Power control register */ @@ -1242,7 +1245,7 @@ int rtl8723au_inirp_init(struct rtw_adapter *Adapter) ("usb_rx_init: usb_read_interrupt error\n")); status = _FAIL; } - pHalData->IntrMask[0] = rtw_read32(Adapter, REG_USB_HIMR); + pHalData->IntrMask[0] = rtl8723au_read32(Adapter, REG_USB_HIMR); MSG_8723A("pHalData->IntrMask = 0x%04x\n", pHalData->IntrMask[0]); pHalData->IntrMask[0] |= UHIMR_C2HCMD|UHIMR_CPWM; rtw_write32(Adapter, REG_USB_HIMR, pHalData->IntrMask[0]); @@ -1259,7 +1262,7 @@ int rtl8723au_inirp_deinit(struct rtw_adapter *Adapter) RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("\n ===> usb_rx_deinit\n")); rtl8723a_usb_read_port_cancel(Adapter); - pHalData->IntrMask[0] = rtw_read32(Adapter, REG_USB_HIMR); + pHalData->IntrMask[0] = rtl8723au_read32(Adapter, REG_USB_HIMR); MSG_8723A("%s pHalData->IntrMask = 0x%04x\n", __func__, pHalData->IntrMask[0]); pHalData->IntrMask[0] = 0x0; @@ -1400,7 +1403,7 @@ static void _ReadPROMContent(struct rtw_adapter *Adapter) struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(Adapter); u8 eeValue; - eeValue = rtw_read8(Adapter, REG_9346CR); + eeValue = rtl8723au_read8(Adapter, REG_9346CR); /* To check system boot selection. */ pEEPROM->EepromOrEfuse = (eeValue & BOOT_FROM_EEPROM) ? true : false; pEEPROM->bautoload_fail_flag = (eeValue & EEPROM_EN) ? false : true; @@ -1439,7 +1442,7 @@ static void hal_EfuseCellSel(struct rtw_adapter *Adapter) { u32 value32; - value32 = rtw_read32(Adapter, EFUSE_TEST); + value32 = rtl8723au_read32(Adapter, EFUSE_TEST); value32 = (value32 & ~EFUSE_SEL_MASK) | EFUSE_SEL(EFUSE_WIFI_SEL_0); rtw_write32(Adapter, EFUSE_TEST, value32); } diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index bb85131c30e0..d5e74e97a872 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -132,7 +132,7 @@ exit: return status; } -static u8 usb_read8(struct rtw_adapter *padapter, u32 addr) +u8 rtl8723au_read8(struct rtw_adapter *padapter, u32 addr) { u8 request; u8 requesttype; @@ -154,7 +154,7 @@ static u8 usb_read8(struct rtw_adapter *padapter, u32 addr) return data; } -static u16 usb_read16(struct rtw_adapter *padapter, u32 addr) +u16 rtl8723au_read16(struct rtw_adapter *padapter, u32 addr) { u8 request; u8 requesttype; @@ -176,7 +176,7 @@ static u16 usb_read16(struct rtw_adapter *padapter, u32 addr) return le16_to_cpu(data); } -static u32 usb_read32(struct rtw_adapter *padapter, u32 addr) +u32 rtl8723au_read32(struct rtw_adapter *padapter, u32 addr) { u8 request; u8 requesttype; @@ -839,10 +839,6 @@ void rtl8723au_set_intf_ops(struct rtw_adapter *padapter) memset((u8 *)pops, 0, sizeof(struct _io_ops)); - pops->_read8 = &usb_read8; - pops->_read16 = &usb_read16; - pops->_read32 = &usb_read32; - pops->_write8 = &usb_write8; pops->_write16 = &usb_write16; pops->_write32 = &usb_write32; diff --git a/drivers/staging/rtl8723au/include/rtw_io.h b/drivers/staging/rtl8723au/include/rtw_io.h index 82939f5225db..b9263dadc50f 100644 --- a/drivers/staging/rtl8723au/include/rtw_io.h +++ b/drivers/staging/rtl8723au/include/rtw_io.h @@ -100,10 +100,6 @@ struct intf_priv; struct _io_ops { - u8 (*_read8)(struct rtw_adapter *adapter, u32 addr); - u16 (*_read16)(struct rtw_adapter *adapter, u32 addr); - u32 (*_read32)(struct rtw_adapter *adapter, u32 addr); - int (*_write8)(struct rtw_adapter *adapter, u32 addr, u8 val); int (*_write16)(struct rtw_adapter *adapter, u32 addr, u16 val); int (*_write32)(struct rtw_adapter *adapter, u32 addr, u32 val); @@ -240,9 +236,6 @@ struct reg_protocol_wt { void _rtw_attrib_read(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem); void _rtw_attrib_write(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem); -u8 _rtw_read823a(struct rtw_adapter *adapter, u32 addr); -u16 _rtw_read1623a(struct rtw_adapter *adapter, u32 addr); -u32 _rtw_read3223a(struct rtw_adapter *adapter, u32 addr); void _rtw_read_port23a_cancel(struct rtw_adapter *adapter); int _rtw_write823a(struct rtw_adapter *adapter, u32 addr, u8 val); @@ -256,28 +249,16 @@ void _rtw_write_port23a_cancel(struct rtw_adapter *adapter); bool match_read_sniff_ranges(u16 addr, u16 len); bool match_write_sniff_ranges(u16 addr, u16 len); -u8 dbg_rtw_read823a(struct rtw_adapter *adapter, u32 addr, const char *caller, const int line); -u16 dbg_rtw_read1623a(struct rtw_adapter *adapter, u32 addr, const char *caller, const int line); -u32 dbg_rtw_read3223a(struct rtw_adapter *adapter, u32 addr, const char *caller, const int line); - int dbg_rtw_write823a(struct rtw_adapter *adapter, u32 addr, u8 val, const char *caller, const int line); int dbg_rtw_write1623a(struct rtw_adapter *adapter, u32 addr, u16 val, const char *caller, const int line); int dbg_rtw_write3223a(struct rtw_adapter *adapter, u32 addr, u32 val, const char *caller, const int line); int dbg_rtw_writeN23a(struct rtw_adapter *adapter, u32 addr ,u32 length , u8 *data, const char *caller, const int line); -#define rtw_read8(adapter, addr) dbg_rtw_read823a((adapter), (addr), __FUNCTION__, __LINE__) -#define rtw_read16(adapter, addr) dbg_rtw_read1623a((adapter), (addr), __FUNCTION__, __LINE__) -#define rtw_read32(adapter, addr) dbg_rtw_read3223a((adapter), (addr), __FUNCTION__, __LINE__) - #define rtw_write8(adapter, addr, val) dbg_rtw_write823a((adapter), (addr), (val), __FUNCTION__, __LINE__) #define rtw_write16(adapter, addr, val) dbg_rtw_write1623a((adapter), (addr), (val), __FUNCTION__, __LINE__) #define rtw_write32(adapter, addr, val) dbg_rtw_write3223a((adapter), (addr), (val), __FUNCTION__, __LINE__) #define rtw_writeN(adapter, addr, length, data) dbg_rtw_writeN23a((adapter), (addr), (length), (data), __FUNCTION__, __LINE__) #else /* DBG_IO */ -#define rtw_read8(adapter, addr) _rtw_read823a((adapter), (addr)) -#define rtw_read16(adapter, addr) _rtw_read1623a((adapter), (addr)) -#define rtw_read32(adapter, addr) _rtw_read3223a((adapter), (addr)) - #define rtw_write8(adapter, addr, val) _rtw_write823a((adapter), (addr), (val)) #define rtw_write16(adapter, addr, val) _rtw_write1623a((adapter), (addr), (val)) #define rtw_write32(adapter, addr, val) _rtw_write3223a((adapter), (addr), (val)) @@ -291,11 +272,8 @@ int dbg_rtw_writeN23a(struct rtw_adapter *adapter, u32 addr ,u32 length , u8 *da #define PlatformEFIOWrite4Byte(_a,_b,_c) \ rtw_write32(_a,_b,_c) -#define PlatformEFIORead1Byte(_a,_b) \ - rtw_read8(_a,_b) -#define PlatformEFIORead2Byte(_a,_b) \ - rtw_read16(_a,_b) -#define PlatformEFIORead4Byte(_a,_b) \ - rtw_read32(_a,_b) +#define PlatformEFIORead1Byte(_a,_b) rtl8723au_read8(_a,_b) +#define PlatformEFIORead2Byte(_a,_b) rtl8723au_read16(_a,_b) +#define PlatformEFIORead4Byte(_a,_b) rtl8723au_read32(_a,_b) #endif /* _RTL8711_IO_H_ */ diff --git a/drivers/staging/rtl8723au/include/usb_ops_linux.h b/drivers/staging/rtl8723au/include/usb_ops_linux.h index acd98f7fc63c..29509544ab6f 100644 --- a/drivers/staging/rtl8723au/include/usb_ops_linux.h +++ b/drivers/staging/rtl8723au/include/usb_ops_linux.h @@ -29,4 +29,8 @@ int rtl8723a_usb_write_port(struct rtw_adapter *padapter, u32 addr, u32 cnt, void rtl8723a_usb_write_port_cancel(struct rtw_adapter *padapter); int rtl8723a_usb_read_interrupt(struct rtw_adapter *adapter, u32 addr); +u8 rtl8723au_read8(struct rtw_adapter *padapter, u32 addr); +u16 rtl8723au_read16(struct rtw_adapter *padapter, u32 addr); +u32 rtl8723au_read32(struct rtw_adapter *padapter, u32 addr); + #endif -- cgit v1.2.3 From edbfd672cacb0d417096a1ed75e0070f1672c861 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:05:09 +0200 Subject: staging: rtl8723au: Call usb_write*() functions directly This allows us to finally remove the ugly HAL interface for accessing registers, and remove rtw_io.c Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/Makefile | 1 - drivers/staging/rtl8723au/core/rtw_efuse.c | 51 +++-- drivers/staging/rtl8723au/core/rtw_io.c | 92 -------- drivers/staging/rtl8723au/core/rtw_sreset.c | 2 +- .../staging/rtl8723au/hal/HalDMOutSrc8723A_CE.c | 67 +++--- drivers/staging/rtl8723au/hal/HalPwrSeqCmd.c | 2 +- drivers/staging/rtl8723au/hal/hal_com.c | 100 ++++----- drivers/staging/rtl8723au/hal/odm.c | 9 +- drivers/staging/rtl8723au/hal/odm_interface.c | 25 +-- .../staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 98 ++++---- drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 30 ++- drivers/staging/rtl8723au/hal/rtl8723a_dm.c | 9 +- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 246 +++++++++++---------- drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c | 26 +-- drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c | 4 +- drivers/staging/rtl8723au/hal/rtl8723au_led.c | 16 +- drivers/staging/rtl8723au/hal/usb_halinit.c | 199 +++++++++-------- drivers/staging/rtl8723au/hal/usb_ops_linux.c | 22 +- drivers/staging/rtl8723au/include/drv_types.h | 1 - drivers/staging/rtl8723au/include/rtw_io.h | 35 +-- drivers/staging/rtl8723au/include/usb_ops.h | 2 - drivers/staging/rtl8723au/include/usb_ops_linux.h | 5 + drivers/staging/rtl8723au/os_dep/usb_intf.c | 2 - 23 files changed, 476 insertions(+), 568 deletions(-) delete mode 100644 drivers/staging/rtl8723au/core/rtw_io.c diff --git a/drivers/staging/rtl8723au/Makefile b/drivers/staging/rtl8723au/Makefile index 5146b709efb4..950446e4ee1b 100644 --- a/drivers/staging/rtl8723au/Makefile +++ b/drivers/staging/rtl8723au/Makefile @@ -2,7 +2,6 @@ r8723au-y := \ core/rtw_ap.o \ core/rtw_cmd.o \ core/rtw_efuse.o \ - core/rtw_io.o \ core/rtw_ioctl_set.o \ core/rtw_ieee80211.o \ core/rtw_led.o \ diff --git a/drivers/staging/rtl8723au/core/rtw_efuse.c b/drivers/staging/rtl8723au/core/rtw_efuse.c index 427937a21c08..cc063cbc49bb 100644 --- a/drivers/staging/rtl8723au/core/rtw_efuse.c +++ b/drivers/staging/rtl8723au/core/rtw_efuse.c @@ -56,20 +56,20 @@ static void Efuse_PowerSwitch(struct rtw_adapter *padapter, u16 tmpV16; if (PwrState == true) { - rtw_write8(padapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_ON); + rtl8723au_write8(padapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_ON); /* 1.2V Power: From VDDON with Power Cut(0x0000h[15]), defualt valid */ tmpV16 = rtl8723au_read16(padapter, REG_SYS_ISO_CTRL); if (!(tmpV16 & PWC_EV12V)) { tmpV16 |= PWC_EV12V; - rtw_write16(padapter, REG_SYS_ISO_CTRL, tmpV16); + rtl8723au_write16(padapter, REG_SYS_ISO_CTRL, tmpV16); } /* Reset: 0x0000h[28], default valid */ tmpV16 = rtl8723au_read16(padapter, REG_SYS_FUNC_EN); if (!(tmpV16 & FEN_ELDR)) { tmpV16 |= FEN_ELDR; - rtw_write16(padapter, REG_SYS_FUNC_EN, tmpV16); + rtl8723au_write16(padapter, REG_SYS_FUNC_EN, tmpV16); } /* Clock: Gated(0x0008h[5]) 8M(0x0008h[1]) clock @@ -77,7 +77,7 @@ static void Efuse_PowerSwitch(struct rtw_adapter *padapter, tmpV16 = rtl8723au_read16(padapter, REG_SYS_CLKR); if ((!(tmpV16 & LOADER_CLK_EN)) || (!(tmpV16 & ANA8M))) { tmpV16 |= (LOADER_CLK_EN | ANA8M); - rtw_write16(padapter, REG_SYS_CLKR, tmpV16); + rtl8723au_write16(padapter, REG_SYS_CLKR, tmpV16); } if (bWrite == true) { @@ -85,15 +85,17 @@ static void Efuse_PowerSwitch(struct rtw_adapter *padapter, tempval = rtl8723au_read8(padapter, EFUSE_TEST + 3); tempval &= 0x0F; tempval |= (VOLTAGE_V25 << 4); - rtw_write8(padapter, EFUSE_TEST + 3, (tempval | 0x80)); + rtl8723au_write8(padapter, EFUSE_TEST + 3, + tempval | 0x80); } } else { - rtw_write8(padapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_OFF); + rtl8723au_write8(padapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_OFF); if (bWrite == true) { /* Disable LDO 2.5V after read/write action */ tempval = rtl8723au_read8(padapter, EFUSE_TEST + 3); - rtw_write8(padapter, EFUSE_TEST + 3, (tempval & 0x7F)); + rtl8723au_write8(padapter, EFUSE_TEST + 3, + tempval & 0x7F); } } } @@ -158,13 +160,14 @@ ReadEFuseByte23a(struct rtw_adapter *Adapter, u16 _offset, u8 *pbuf) u16 retry; /* Write Address */ - rtw_write8(Adapter, EFUSE_CTRL+1, (_offset & 0xff)); + rtl8723au_write8(Adapter, EFUSE_CTRL+1, (_offset & 0xff)); readbyte = rtl8723au_read8(Adapter, EFUSE_CTRL+2); - rtw_write8(Adapter, EFUSE_CTRL+2, ((_offset >> 8) & 0x03) | (readbyte & 0xfc)); + rtl8723au_write8(Adapter, EFUSE_CTRL+2, + ((_offset >> 8) & 0x03) | (readbyte & 0xfc)); /* Write bit 32 0 */ readbyte = rtl8723au_read8(Adapter, EFUSE_CTRL+3); - rtw_write8(Adapter, EFUSE_CTRL+3, (readbyte & 0x7f)); + rtl8723au_write8(Adapter, EFUSE_CTRL+3, readbyte & 0x7f); /* Check bit 32 read-ready */ retry = 0; @@ -302,16 +305,16 @@ EFUSE_Read1Byte23a(struct rtw_adapter *Adapter, u16 Address) { /* Write E-fuse Register address bit0~7 */ temp = Address & 0xFF; - rtw_write8(Adapter, EFUSE_CTRL+1, temp); + rtl8723au_write8(Adapter, EFUSE_CTRL+1, temp); Bytetemp = rtl8723au_read8(Adapter, EFUSE_CTRL+2); /* Write E-fuse Register address bit8~9 */ temp = ((Address >> 8) & 0x03) | (Bytetemp & 0xFC); - rtw_write8(Adapter, EFUSE_CTRL+2, temp); + rtl8723au_write8(Adapter, EFUSE_CTRL+2, temp); /* Write 0x30[31]= 0 */ Bytetemp = rtl8723au_read8(Adapter, EFUSE_CTRL+3); temp = Bytetemp & 0x7F; - rtw_write8(Adapter, EFUSE_CTRL+3, temp); + rtl8723au_write8(Adapter, EFUSE_CTRL+3, temp); /* Wait Write-ready (0x30[31]= 1) */ Bytetemp = rtl8723au_read8(Adapter, EFUSE_CTRL+3); @@ -372,21 +375,21 @@ EFUSE_Write1Byte( if (Address < contentLen) /* E-fuse 512Byte */ { - rtw_write8(Adapter, EFUSE_CTRL, Value); + rtl8723au_write8(Adapter, EFUSE_CTRL, Value); /* Write E-fuse Register address bit0~7 */ temp = Address & 0xFF; - rtw_write8(Adapter, EFUSE_CTRL+1, temp); + rtl8723au_write8(Adapter, EFUSE_CTRL+1, temp); Bytetemp = rtl8723au_read8(Adapter, EFUSE_CTRL+2); /* Write E-fuse Register address bit8~9 */ temp = ((Address >> 8) & 0x03) | (Bytetemp & 0xFC); - rtw_write8(Adapter, EFUSE_CTRL+2, temp); + rtl8723au_write8(Adapter, EFUSE_CTRL+2, temp); /* Write 0x30[31]= 1 */ Bytetemp = rtl8723au_read8(Adapter, EFUSE_CTRL+3); temp = Bytetemp | 0x80; - rtw_write8(Adapter, EFUSE_CTRL+3, temp); + rtl8723au_write8(Adapter, EFUSE_CTRL+3, temp); /* Wait Write-ready (0x30[31]= 0) */ Bytetemp = rtl8723au_read8(Adapter, EFUSE_CTRL+3); @@ -412,11 +415,11 @@ efuse_OneByteRead23a(struct rtw_adapter *pAdapter, u16 addr, u8 *data) /* -----------------e-fuse reg ctrl --------------------------------- */ /* address */ - rtw_write8(pAdapter, EFUSE_CTRL+1, (u8)(addr&0xff)); - rtw_write8(pAdapter, EFUSE_CTRL+2, ((u8)((addr>>8) &0x03)) | + rtl8723au_write8(pAdapter, EFUSE_CTRL+1, (u8)(addr&0xff)); + rtl8723au_write8(pAdapter, EFUSE_CTRL+2, ((u8)((addr>>8) &0x03)) | (rtl8723au_read8(pAdapter, EFUSE_CTRL+2)&0xFC)); - rtw_write8(pAdapter, EFUSE_CTRL+3, 0x72);/* read cmd */ + rtl8723au_write8(pAdapter, EFUSE_CTRL+3, 0x72);/* read cmd */ while(!(0x80 &rtl8723au_read8(pAdapter, EFUSE_CTRL+3)) && (tmpidx<100)) tmpidx++; @@ -443,12 +446,12 @@ efuse_OneByteWrite23a(struct rtw_adapter *pAdapter, u16 addr, u8 data) /* -----------------e-fuse reg ctrl --------------------------------- */ /* address */ - rtw_write8(pAdapter, EFUSE_CTRL+1, (u8)(addr&0xff)); - rtw_write8(pAdapter, EFUSE_CTRL+2, + rtl8723au_write8(pAdapter, EFUSE_CTRL+1, (u8)(addr&0xff)); + rtl8723au_write8(pAdapter, EFUSE_CTRL+2, (rtl8723au_read8(pAdapter, EFUSE_CTRL+2)&0xFC)|(u8)((addr>>8)&0x03)); - rtw_write8(pAdapter, EFUSE_CTRL, data);/* data */ + rtl8723au_write8(pAdapter, EFUSE_CTRL, data);/* data */ - rtw_write8(pAdapter, EFUSE_CTRL+3, 0xF2);/* write cmd */ + rtl8723au_write8(pAdapter, EFUSE_CTRL+3, 0xF2);/* write cmd */ while((0x80 & rtl8723au_read8(pAdapter, EFUSE_CTRL+3)) && (tmpidx<100)) { diff --git a/drivers/staging/rtl8723au/core/rtw_io.c b/drivers/staging/rtl8723au/core/rtw_io.c deleted file mode 100644 index a7901d724ebd..000000000000 --- a/drivers/staging/rtl8723au/core/rtw_io.c +++ /dev/null @@ -1,92 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek 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. - * - ******************************************************************************/ -/* - -The purpose of rtw_io.c - -a. provides the API - -b. provides the protocol engine - -c. provides the software interface between caller and the hardware interface - -Compiler Flag Option: - -1. For USB: - a. USE_ASYNC_IRP: Both sync/async operations are provided. - -jackson@realtek.com.tw - -*/ - -#define _RTW_IO_C_ -#include -#include -#include -#include - -#include - -int _rtw_write823a(struct rtw_adapter *adapter, u32 addr, u8 val) -{ - struct _io_ops *io_ops = &adapter->io_ops; - int ret; - - ret = io_ops->_write8(adapter, addr, val); - - if (ret < 0) - return _FAIL; - else - return _SUCCESS; -} - -int _rtw_write1623a(struct rtw_adapter *adapter, u32 addr, u16 val) -{ - struct _io_ops *io_ops = &adapter->io_ops; - int ret; - - ret = io_ops->_write16(adapter, addr, val); - - if (ret < 0) - return _FAIL; - else - return _SUCCESS; -} - -int _rtw_write3223a(struct rtw_adapter *adapter, u32 addr, u32 val) -{ - struct _io_ops *io_ops = &adapter->io_ops; - int ret; - - ret = io_ops->_write32(adapter, addr, val); - - if (ret < 0) - return _FAIL; - else - return _SUCCESS; -} - -int _rtw_writeN23a(struct rtw_adapter *adapter, u32 addr , u32 length , u8 *pdata) -{ - struct _io_ops *io_ops = &adapter->io_ops; - int ret; - - ret = io_ops->_writeN(adapter, addr, length, pdata); - - if (ret < 0) - return _FAIL; - else - return _SUCCESS; -} diff --git a/drivers/staging/rtl8723au/core/rtw_sreset.c b/drivers/staging/rtl8723au/core/rtw_sreset.c index ec6754befab6..5e6d5fc9166b 100644 --- a/drivers/staging/rtl8723au/core/rtw_sreset.c +++ b/drivers/staging/rtl8723au/core/rtw_sreset.c @@ -150,7 +150,7 @@ static void sreset_restore_network_station(struct rtw_adapter *padapter) mlmeext_joinbss_event_callback23a(padapter, 1); /* restore Sequence No. */ - rtw_write8(padapter, 0x4dc, padapter->xmitpriv.nqos_ssn); + rtl8723au_write8(padapter, 0x4dc, padapter->xmitpriv.nqos_ssn); sreset_restore_security_station(padapter); } diff --git a/drivers/staging/rtl8723au/hal/HalDMOutSrc8723A_CE.c b/drivers/staging/rtl8723au/hal/HalDMOutSrc8723A_CE.c index b92e13e66aae..4b41bc4ce1e6 100644 --- a/drivers/staging/rtl8723au/hal/HalDMOutSrc8723A_CE.c +++ b/drivers/staging/rtl8723au/hal/HalDMOutSrc8723A_CE.c @@ -271,23 +271,23 @@ odm_TXPowerTrackingCallback_ThermalMeter_92C( /* Adjust CCK according to IQK result */ if (!pdmpriv->bCCKinCH14) { - rtw_write8(Adapter, 0xa22, CCKSwingTable_Ch1_Ch1323A[CCK_index][0]); - rtw_write8(Adapter, 0xa23, CCKSwingTable_Ch1_Ch1323A[CCK_index][1]); - rtw_write8(Adapter, 0xa24, CCKSwingTable_Ch1_Ch1323A[CCK_index][2]); - rtw_write8(Adapter, 0xa25, CCKSwingTable_Ch1_Ch1323A[CCK_index][3]); - rtw_write8(Adapter, 0xa26, CCKSwingTable_Ch1_Ch1323A[CCK_index][4]); - rtw_write8(Adapter, 0xa27, CCKSwingTable_Ch1_Ch1323A[CCK_index][5]); - rtw_write8(Adapter, 0xa28, CCKSwingTable_Ch1_Ch1323A[CCK_index][6]); - rtw_write8(Adapter, 0xa29, CCKSwingTable_Ch1_Ch1323A[CCK_index][7]); + rtl8723au_write8(Adapter, 0xa22, CCKSwingTable_Ch1_Ch1323A[CCK_index][0]); + rtl8723au_write8(Adapter, 0xa23, CCKSwingTable_Ch1_Ch1323A[CCK_index][1]); + rtl8723au_write8(Adapter, 0xa24, CCKSwingTable_Ch1_Ch1323A[CCK_index][2]); + rtl8723au_write8(Adapter, 0xa25, CCKSwingTable_Ch1_Ch1323A[CCK_index][3]); + rtl8723au_write8(Adapter, 0xa26, CCKSwingTable_Ch1_Ch1323A[CCK_index][4]); + rtl8723au_write8(Adapter, 0xa27, CCKSwingTable_Ch1_Ch1323A[CCK_index][5]); + rtl8723au_write8(Adapter, 0xa28, CCKSwingTable_Ch1_Ch1323A[CCK_index][6]); + rtl8723au_write8(Adapter, 0xa29, CCKSwingTable_Ch1_Ch1323A[CCK_index][7]); } else { - rtw_write8(Adapter, 0xa22, CCKSwingTable_Ch1423A[CCK_index][0]); - rtw_write8(Adapter, 0xa23, CCKSwingTable_Ch1423A[CCK_index][1]); - rtw_write8(Adapter, 0xa24, CCKSwingTable_Ch1423A[CCK_index][2]); - rtw_write8(Adapter, 0xa25, CCKSwingTable_Ch1423A[CCK_index][3]); - rtw_write8(Adapter, 0xa26, CCKSwingTable_Ch1423A[CCK_index][4]); - rtw_write8(Adapter, 0xa27, CCKSwingTable_Ch1423A[CCK_index][5]); - rtw_write8(Adapter, 0xa28, CCKSwingTable_Ch1423A[CCK_index][6]); - rtw_write8(Adapter, 0xa29, CCKSwingTable_Ch1423A[CCK_index][7]); + rtl8723au_write8(Adapter, 0xa22, CCKSwingTable_Ch1423A[CCK_index][0]); + rtl8723au_write8(Adapter, 0xa23, CCKSwingTable_Ch1423A[CCK_index][1]); + rtl8723au_write8(Adapter, 0xa24, CCKSwingTable_Ch1423A[CCK_index][2]); + rtl8723au_write8(Adapter, 0xa25, CCKSwingTable_Ch1423A[CCK_index][3]); + rtl8723au_write8(Adapter, 0xa26, CCKSwingTable_Ch1423A[CCK_index][4]); + rtl8723au_write8(Adapter, 0xa27, CCKSwingTable_Ch1423A[CCK_index][5]); + rtl8723au_write8(Adapter, 0xa28, CCKSwingTable_Ch1423A[CCK_index][6]); + rtl8723au_write8(Adapter, 0xa29, CCKSwingTable_Ch1423A[CCK_index][7]); } if (is2T) { @@ -600,10 +600,10 @@ static void _PHY_ReloadMACRegisters(struct rtw_adapter *pAdapter, u32 *MACReg, u { u32 i; - for (i = 0 ; i < (IQK_MAC_REG_NUM - 1); i++) { - rtw_write8(pAdapter, MACReg[i], (u8)MACBackup[i]); - } - rtw_write32(pAdapter, MACReg[i], MACBackup[i]); + for (i = 0 ; i < (IQK_MAC_REG_NUM - 1); i++) + rtl8723au_write8(pAdapter, MACReg[i], (u8)MACBackup[i]); + + rtl8723au_write32(pAdapter, MACReg[i], MACBackup[i]); } static void _PHY_PathADDAOn(struct rtw_adapter *pAdapter, u32 *ADDAReg, bool isPathAOn, bool is2T) @@ -627,12 +627,13 @@ static void _PHY_MACSettingCalibration(struct rtw_adapter *pAdapter, u32 *MACReg { u32 i = 0; - rtw_write8(pAdapter, MACReg[i], 0x3F); + rtl8723au_write8(pAdapter, MACReg[i], 0x3F); for (i = 1 ; i < (IQK_MAC_REG_NUM - 1); i++) { - rtw_write8(pAdapter, MACReg[i], (u8)(MACBackup[i] & ~BIT(3))); + rtl8723au_write8(pAdapter, MACReg[i], + (u8)(MACBackup[i] & ~BIT(3))); } - rtw_write8(pAdapter, MACReg[i], (u8)(MACBackup[i] & ~BIT(5))); + rtl8723au_write8(pAdapter, MACReg[i], (u8)(MACBackup[i] & ~BIT(5))); } static void _PHY_PathAStandBy(struct rtw_adapter *pAdapter) @@ -881,10 +882,15 @@ static void _PHY_LCCalibrate(struct rtw_adapter *pAdapter, bool is2T) /* Check continuous TX and Packet TX */ tmpReg = rtl8723au_read8(pAdapter, 0xd03); - if ((tmpReg&0x70) != 0) /* Deal with contisuous TX case */ - rtw_write8(pAdapter, 0xd03, tmpReg&0x8F); /* disable all continuous TX */ - else /* Deal with Packet TX case */ - rtw_write8(pAdapter, REG_TXPAUSE, 0xFF); /* block all queues */ + if ((tmpReg&0x70) != 0) { + /* Deal with contisuous TX case */ + /* disable all continuous TX */ + rtl8723au_write8(pAdapter, 0xd03, tmpReg&0x8F); + } else { + /* Deal with Packet TX case */ + /* block all queues */ + rtl8723au_write8(pAdapter, REG_TXPAUSE, 0xFF); + } if ((tmpReg&0x70) != 0) { /* 1. Read original RF mode */ @@ -915,15 +921,14 @@ static void _PHY_LCCalibrate(struct rtw_adapter *pAdapter, bool is2T) /* Restore original situation */ if ((tmpReg&0x70) != 0) { /* Deal with contuous TX case */ /* Path-A */ - rtw_write8(pAdapter, 0xd03, tmpReg); + rtl8723au_write8(pAdapter, 0xd03, tmpReg); PHY_SetRFReg(pAdapter, RF_PATH_A, RF_AC, bMask12Bits, RF_Amode); /* Path-B */ if (is2T) PHY_SetRFReg(pAdapter, RF_PATH_B, RF_AC, bMask12Bits, RF_Bmode); - } else { /* Deal with Packet TX case */ - rtw_write8(pAdapter, REG_TXPAUSE, 0x00); - } + } else /* Deal with Packet TX case */ + rtl8723au_write8(pAdapter, REG_TXPAUSE, 0x00); } /* Analog Pre-distortion calibration */ diff --git a/drivers/staging/rtl8723au/hal/HalPwrSeqCmd.c b/drivers/staging/rtl8723au/hal/HalPwrSeqCmd.c index 8234ce851975..1da4eece6f9a 100644 --- a/drivers/staging/rtl8723au/hal/HalPwrSeqCmd.c +++ b/drivers/staging/rtl8723au/hal/HalPwrSeqCmd.c @@ -97,7 +97,7 @@ u8 HalPwrSeqCmdParsing23a(struct rtw_adapter *padapter, u8 CutVersion, GET_PWR_CFG_MASK(PwrCfgCmd)); /* Write the value back to sytem register */ - rtw_write8(padapter, offset, value); + rtl8723au_write8(padapter, offset, value); break; case PWR_CMD_POLLING: diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index c5f46f6e51d2..1ec214594774 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -223,10 +223,10 @@ void HalSetBrateCfg23a(struct rtw_adapter *padapter, u8 *mBratesOS) DBG_8723A("HW_VAR_BASIC_RATE: BrateCfg(%#x)\n", brate_cfg); /* Set RRSR rate table. */ - rtw_write8(padapter, REG_RRSR, brate_cfg & 0xff); - rtw_write8(padapter, REG_RRSR + 1, (brate_cfg >> 8) & 0xff); - rtw_write8(padapter, REG_RRSR + 2, - rtl8723au_read8(padapter, REG_RRSR + 2) & 0xf0); + rtl8723au_write8(padapter, REG_RRSR, brate_cfg & 0xff); + rtl8723au_write8(padapter, REG_RRSR + 1, (brate_cfg >> 8) & 0xff); + rtl8723au_write8(padapter, REG_RRSR + 2, + rtl8723au_read8(padapter, REG_RRSR + 2) & 0xf0); rate_index = 0; /* Set RTS initial rate */ @@ -235,7 +235,7 @@ void HalSetBrateCfg23a(struct rtw_adapter *padapter, u8 *mBratesOS) rate_index++; } /* Ziv - Check */ - rtw_write8(padapter, REG_INIRTS_RATE_SEL, rate_index); + rtl8723au_write8(padapter, REG_INIRTS_RATE_SEL, rate_index); return; } @@ -353,7 +353,7 @@ bool Hal_MappingOutPipe23a(struct rtw_adapter *pAdapter, u8 NumOutPipe) void c2h_evt_clear23a(struct rtw_adapter *adapter) { - rtw_write8(adapter, REG_C2HEVT_CLEAR, C2H_EVT_HOST_CLOSE); + rtl8723au_write8(adapter, REG_C2HEVT_CLEAR, C2H_EVT_HOST_CLOSE); } int c2h_evt_read23a(struct rtw_adapter *adapter, u8 *buf) @@ -443,8 +443,8 @@ rtl8723a_set_ampdu_min_space(struct rtw_adapter *padapter, u8 MinSpacingToSet) padapter->MgntInfo.MinSpaceCfg)); */ MinSpacingToSet |= rtl8723au_read8(padapter, REG_AMPDU_MIN_SPACE) & 0xf8; - rtw_write8(padapter, REG_AMPDU_MIN_SPACE, - MinSpacingToSet); + rtl8723au_write8(padapter, REG_AMPDU_MIN_SPACE, + MinSpacingToSet); } } @@ -480,8 +480,8 @@ void rtl8723a_set_ampdu_factor(struct rtw_adapter *padapter, u8 FactorToSet) pRegToSet[index] = (pRegToSet[index] & 0xf0) | FactorToSet; - rtw_write8(padapter, REG_AGGLEN_LMT + index, - pRegToSet[index]); + rtl8723au_write8(padapter, REG_AGGLEN_LMT + index, + pRegToSet[index]); } /* RT_TRACE(COMP_MLME, DBG_LOUD, @@ -507,7 +507,7 @@ void rtl8723a_set_acm_ctrl(struct rtw_adapter *padapter, u8 ctrl) } DBG_8723A("[HW_VAR_ACM_CTRL] Write 0x%02X\n", hwctrl); - rtw_write8(padapter, REG_ACMHWCTRL, hwctrl); + rtl8723au_write8(padapter, REG_ACMHWCTRL, hwctrl); } void rtl8723a_set_media_status(struct rtw_adapter *padapter, u8 status) @@ -516,7 +516,7 @@ void rtl8723a_set_media_status(struct rtw_adapter *padapter, u8 status) val8 = rtl8723au_read8(padapter, MSR) & 0x0c; val8 |= status; - rtw_write8(padapter, MSR, val8); + rtl8723au_write8(padapter, MSR, val8); } void rtl8723a_set_media_status1(struct rtw_adapter *padapter, u8 status) @@ -525,7 +525,7 @@ void rtl8723a_set_media_status1(struct rtw_adapter *padapter, u8 status) val8 = rtl8723au_read8(padapter, MSR) & 0x03; val8 |= status << 2; - rtw_write8(padapter, MSR, val8); + rtl8723au_write8(padapter, MSR, val8); } void rtl8723a_set_bcn_func(struct rtw_adapter *padapter, u8 val) @@ -544,7 +544,7 @@ void rtl8723a_check_bssid(struct rtw_adapter *padapter, u8 val) val32 |= RCR_CBSSID_DATA | RCR_CBSSID_BCN; else val32 &= ~(RCR_CBSSID_DATA | RCR_CBSSID_BCN); - rtw_write32(padapter, REG_RCR, val32); + rtl8723au_write32(padapter, REG_RCR, val32); } void rtl8723a_mlme_sitesurvey(struct rtw_adapter *padapter, u8 flag) @@ -556,9 +556,9 @@ void rtl8723a_mlme_sitesurvey(struct rtw_adapter *padapter, u8 flag) to receive data frame */ v32 = rtl8723au_read32(padapter, REG_RCR); v32 &= ~(RCR_CBSSID_BCN); - rtw_write32(padapter, REG_RCR, v32); + rtl8723au_write32(padapter, REG_RCR, v32); /* reject all data frame */ - rtw_write16(padapter, REG_RXFLTMAP2, 0); + rtl8723au_write16(padapter, REG_RXFLTMAP2, 0); /* disable update TSF */ SetBcnCtrlReg23a(padapter, DIS_TSF_UDT, 0); @@ -574,7 +574,7 @@ void rtl8723a_mlme_sitesurvey(struct rtw_adapter *padapter, u8 flag) ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)) { /* enable to rx data frame */ - rtw_write16(padapter, REG_RXFLTMAP2, 0xFFFF); + rtl8723au_write16(padapter, REG_RXFLTMAP2, 0xFFFF); /* enable update TSF */ SetBcnCtrlReg23a(padapter, 0, DIS_TSF_UDT); @@ -582,7 +582,7 @@ void rtl8723a_mlme_sitesurvey(struct rtw_adapter *padapter, u8 flag) v32 = rtl8723au_read32(padapter, REG_RCR); v32 |= RCR_CBSSID_BCN; - rtw_write32(padapter, REG_RCR, v32); + rtl8723au_write32(padapter, REG_RCR, v32); } #ifdef CONFIG_8723AU_BT_COEXIST @@ -592,7 +592,7 @@ void rtl8723a_mlme_sitesurvey(struct rtw_adapter *padapter, u8 flag) void rtl8723a_on_rcr_am(struct rtw_adapter *padapter) { - rtw_write32(padapter, REG_RCR, + rtl8723au_write32(padapter, REG_RCR, rtl8723au_read32(padapter, REG_RCR) | RCR_AM); DBG_8723A("%s, %d, RCR = %x \n", __FUNCTION__, __LINE__, rtl8723au_read32(padapter, REG_RCR)); @@ -600,7 +600,7 @@ void rtl8723a_on_rcr_am(struct rtw_adapter *padapter) void rtl8723a_off_rcr_am(struct rtw_adapter *padapter) { - rtw_write32(padapter, REG_RCR, + rtl8723au_write32(padapter, REG_RCR, rtl8723au_read32(padapter, REG_RCR) & (~RCR_AM)); DBG_8723A("%s, %d, RCR = %x \n", __FUNCTION__, __LINE__, rtl8723au_read32(padapter, REG_RCR)); @@ -612,7 +612,7 @@ void rtl8723a_set_slot_time(struct rtw_adapter *padapter, u8 slottime) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - rtw_write8(padapter, REG_SLOT, slottime); + rtl8723au_write8(padapter, REG_SLOT, slottime); if (pmlmeinfo->WMM_enable == 0) { if (pmlmeext->cur_wireless_mode == WIRELESS_11B) @@ -623,10 +623,10 @@ void rtl8723a_set_slot_time(struct rtw_adapter *padapter, u8 slottime) u1bAIFS = aSifsTime + (2 * pmlmeinfo->slotTime); /* Temporary removed, 2008.06.20. */ - rtw_write8(padapter, REG_EDCA_VO_PARAM, u1bAIFS); - rtw_write8(padapter, REG_EDCA_VI_PARAM, u1bAIFS); - rtw_write8(padapter, REG_EDCA_BE_PARAM, u1bAIFS); - rtw_write8(padapter, REG_EDCA_BK_PARAM, u1bAIFS); + rtl8723au_write8(padapter, REG_EDCA_VO_PARAM, u1bAIFS); + rtl8723au_write8(padapter, REG_EDCA_VI_PARAM, u1bAIFS); + rtl8723au_write8(padapter, REG_EDCA_BE_PARAM, u1bAIFS); + rtl8723au_write8(padapter, REG_EDCA_BK_PARAM, u1bAIFS); } } @@ -641,12 +641,12 @@ void rtl8723a_ack_preamble(struct rtw_adapter *padapter, u8 bShortPreamble) /* regTmp = 0; */ if (bShortPreamble) regTmp |= 0x80; - rtw_write8(padapter, REG_RRSR + 2, regTmp); + rtl8723au_write8(padapter, REG_RRSR + 2, regTmp); } void rtl8723a_set_sec_cfg(struct rtw_adapter *padapter, u8 sec) { - rtw_write8(padapter, REG_SECCFG, sec); + rtl8723au_write8(padapter, REG_SECCFG, sec); } void rtl8723a_cam_empty_entry(struct rtw_adapter *padapter, u8 ucIndex) @@ -670,12 +670,12 @@ void rtl8723a_cam_empty_entry(struct rtw_adapter *padapter, u8 ucIndex) ulCommand = ulCommand | CAM_POLLINIG | CAM_WRITE; /* write content 0 is equall to mark invalid */ /* delay_ms(40); */ - rtw_write32(padapter, WCAMI, ulContent); + rtl8723au_write32(padapter, WCAMI, ulContent); /* RT_TRACE(COMP_SEC, DBG_LOUD, ("rtl8723a_cam_empty_entry(): WRITE A4: %lx \n", ulContent));*/ /* delay_ms(40); */ - rtw_write32(padapter, RWCAM, ulCommand); + rtl8723au_write32(padapter, RWCAM, ulCommand); /* RT_TRACE(COMP_SEC, DBG_LOUD, ("rtl8723a_cam_empty_entry(): WRITE A0: %lx \n", ulCommand));*/ @@ -684,7 +684,7 @@ void rtl8723a_cam_empty_entry(struct rtw_adapter *padapter, u8 ucIndex) void rtl8723a_cam_invalid_all(struct rtw_adapter *padapter) { - rtw_write32(padapter, RWCAM, BIT(31) | BIT(30)); + rtl8723au_write32(padapter, RWCAM, BIT(31) | BIT(30)); } void rtl8723a_cam_write(struct rtw_adapter *padapter, @@ -712,9 +712,9 @@ void rtl8723a_cam_write(struct rtw_adapter *padapter, break; } - rtw_write32(padapter, WCAMI, val); + rtl8723au_write32(padapter, WCAMI, val); cmd = CAM_POLLINIG | CAM_WRITE | (addr + j); - rtw_write32(padapter, RWCAM, cmd); + rtl8723au_write32(padapter, RWCAM, cmd); /* DBG_8723A("%s => cam write: %x, %x\n", __func__, cmd, val);*/ } @@ -729,7 +729,7 @@ void rtl8723a_fifo_cleanup(struct rtw_adapter *padapter) u8 trycnt = 100; /* pause tx */ - rtw_write8(padapter, REG_TXPAUSE, 0xff); + rtl8723au_write8(padapter, REG_TXPAUSE, 0xff); /* keep sn */ padapter->xmitpriv.nqos_ssn = rtl8723au_read16(padapter, REG_NQOS_SEQ); @@ -740,7 +740,7 @@ void rtl8723a_fifo_cleanup(struct rtw_adapter *padapter) /* RX DMA stop */ v32 = rtl8723au_read32(padapter, REG_RXPKT_NUM); v32 |= RW_RELEASE_EN; - rtw_write32(padapter, REG_RXPKT_NUM, v32); + rtl8723au_write32(padapter, REG_RXPKT_NUM, v32); do { v32 = rtl8723au_read32(padapter, REG_RXPKT_NUM) & RXDMA_IDLE; @@ -752,8 +752,8 @@ void rtl8723a_fifo_cleanup(struct rtw_adapter *padapter) } /* RQPN Load 0 */ - rtw_write16(padapter, REG_RQPN_NPQ, 0); - rtw_write32(padapter, REG_RQPN, 0x80000000); + rtl8723au_write16(padapter, REG_RQPN_NPQ, 0); + rtl8723au_write32(padapter, REG_RQPN, 0x80000000); mdelay(10); } } @@ -762,8 +762,8 @@ void rtl8723a_bcn_valid(struct rtw_adapter *padapter) { /* BCN_VALID, BIT16 of REG_TDECTRL = BIT0 of REG_TDECTRL+2, write 1 to clear, Clear by sw */ - rtw_write8(padapter, REG_TDECTRL + 2, - rtl8723au_read8(padapter, REG_TDECTRL + 2) | BIT(0)); + rtl8723au_write8(padapter, REG_TDECTRL + 2, + rtl8723au_read8(padapter, REG_TDECTRL + 2) | BIT(0)); } bool rtl8723a_get_bcn_valid(struct rtw_adapter *padapter) @@ -777,7 +777,7 @@ bool rtl8723a_get_bcn_valid(struct rtw_adapter *padapter) void rtl8723a_set_beacon_interval(struct rtw_adapter *padapter, u16 interval) { - rtw_write16(padapter, REG_BCN_INTERVAL, interval); + rtl8723au_write16(padapter, REG_BCN_INTERVAL, interval); } void rtl8723a_set_resp_sifs(struct rtw_adapter *padapter, @@ -786,24 +786,24 @@ void rtl8723a_set_resp_sifs(struct rtw_adapter *padapter, /* SIFS_Timer = 0x0a0a0808; */ /* RESP_SIFS for CCK */ /* SIFS_T2T_CCK (0x08) */ - rtw_write8(padapter, REG_R2T_SIFS, r2t1); + rtl8723au_write8(padapter, REG_R2T_SIFS, r2t1); /* SIFS_R2T_CCK(0x08) */ - rtw_write8(padapter, REG_R2T_SIFS + 1, r2t2); + rtl8723au_write8(padapter, REG_R2T_SIFS + 1, r2t2); /* RESP_SIFS for OFDM */ /* SIFS_T2T_OFDM (0x0a) */ - rtw_write8(padapter, REG_T2T_SIFS, t2t1); + rtl8723au_write8(padapter, REG_T2T_SIFS, t2t1); /* SIFS_R2T_OFDM(0x0a) */ - rtw_write8(padapter, REG_T2T_SIFS + 1, t2t2); + rtl8723au_write8(padapter, REG_T2T_SIFS + 1, t2t2); } void rtl8723a_set_ac_param_vo(struct rtw_adapter *padapter, u32 vo) { - rtw_write32(padapter, REG_EDCA_VO_PARAM, vo); + rtl8723au_write32(padapter, REG_EDCA_VO_PARAM, vo); } void rtl8723a_set_ac_param_vi(struct rtw_adapter *padapter, u32 vi) { - rtw_write32(padapter, REG_EDCA_VI_PARAM, vi); + rtl8723au_write32(padapter, REG_EDCA_VI_PARAM, vi); } void rtl8723a_set_ac_param_be(struct rtw_adapter *padapter, u32 be) @@ -811,17 +811,17 @@ void rtl8723a_set_ac_param_be(struct rtw_adapter *padapter, u32 be) struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); pHalData->AcParam_BE = be; - rtw_write32(padapter, REG_EDCA_BE_PARAM, be); + rtl8723au_write32(padapter, REG_EDCA_BE_PARAM, be); } void rtl8723a_set_ac_param_bk(struct rtw_adapter *padapter, u32 bk) { - rtw_write32(padapter, REG_EDCA_BK_PARAM, bk); + rtl8723au_write32(padapter, REG_EDCA_BK_PARAM, bk); } void rtl8723a_set_rxdma_agg_pg_th(struct rtw_adapter *padapter, u8 val) { - rtw_write8(padapter, REG_RXDMA_AGG_PG_TH, val); + rtl8723au_write8(padapter, REG_RXDMA_AGG_PG_TH, val); } void rtl8723a_set_nav_upper(struct rtw_adapter *padapter, u32 usNavUpper) @@ -839,7 +839,7 @@ void rtl8723a_set_nav_upper(struct rtw_adapter *padapter, u32 usNavUpper) /* is getting the upper integer. */ usNavUpper = (usNavUpper + HAL_8723A_NAV_UPPER_UNIT - 1) / HAL_8723A_NAV_UPPER_UNIT; - rtw_write8(padapter, REG_NAV_UPPER, (u8) usNavUpper); + rtl8723au_write8(padapter, REG_NAV_UPPER, (u8) usNavUpper); } void rtl8723a_set_initial_gain(struct rtw_adapter *padapter, u32 rx_gain) @@ -890,7 +890,7 @@ void rtl8723a_odm_support_ability_clr(struct rtw_adapter *padapter, u32 val) void rtl8723a_set_rpwm(struct rtw_adapter *padapter, u8 val) { - rtw_write8(padapter, REG_USB_HRPWM, val); + rtl8723au_write8(padapter, REG_USB_HRPWM, val); } u8 rtl8723a_get_rf_type(struct rtw_adapter *padapter) diff --git a/drivers/staging/rtl8723au/hal/odm.c b/drivers/staging/rtl8723au/hal/odm.c index af6c54c84e42..b709f7bf3a9f 100644 --- a/drivers/staging/rtl8723au/hal/odm.c +++ b/drivers/staging/rtl8723au/hal/odm.c @@ -1458,7 +1458,8 @@ void odm_DynamicTxPower23aRestorePowerIndex(struct dm_odm_t *pDM_Odm) u32 Power_Index_REG[6] = {0xc90, 0xc91, 0xc92, 0xc98, 0xc99, 0xc9a}; struct dm_priv *pdmpriv = &pHalData->dmpriv; for (index = 0; index < 6; index++) - rtw_write8(Adapter, Power_Index_REG[index], pdmpriv->PowerIndex_backup[index]); + rtl8723au_write8(Adapter, Power_Index_REG[index], + pdmpriv->PowerIndex_backup[index]); } void odm_DynamicTxPower23aWritePowerIndex(struct dm_odm_t *pDM_Odm, @@ -1766,7 +1767,8 @@ void odm_EdcaTurboCheck23aCE23a(struct dm_odm_t *pDM_Odm) edca_param = EDCAParam[pmlmeinfo->assoc_AP_vendor][trafficIndex]; else edca_param = EDCAParam[HT_IOT_PEER_UNKNOWN][trafficIndex]; - rtw_write32(Adapter, REG_EDCA_BE_PARAM, edca_param); + rtl8723au_write32(Adapter, REG_EDCA_BE_PARAM, + edca_param); pDM_Odm->DM_EDCA_Table.prv_traffic_idx = trafficIndex; } @@ -1776,7 +1778,8 @@ void odm_EdcaTurboCheck23aCE23a(struct dm_odm_t *pDM_Odm) /* Turn Off EDCA turbo here. */ /* Restore original EDCA according to the declaration of AP. */ if (pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA) { - rtw_write32(Adapter, REG_EDCA_BE_PARAM, pHalData->AcParam_BE); + rtl8723au_write32(Adapter, REG_EDCA_BE_PARAM, + pHalData->AcParam_BE); pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA = false; } } diff --git a/drivers/staging/rtl8723au/hal/odm_interface.c b/drivers/staging/rtl8723au/hal/odm_interface.c index e5873e08f4cb..f03f6d4a3888 100644 --- a/drivers/staging/rtl8723au/hal/odm_interface.c +++ b/drivers/staging/rtl8723au/hal/odm_interface.c @@ -46,38 +46,25 @@ u32 ODM_Read4Byte(struct dm_odm_t *pDM_Odm, u32 RegAddr) return rtl8723au_read32(Adapter, RegAddr); } -void ODM_Write1Byte( - struct dm_odm_t *pDM_Odm, - u32 RegAddr, - u8 Data - ) +void ODM_Write1Byte(struct dm_odm_t *pDM_Odm, u32 RegAddr, u8 Data) { struct rtw_adapter *Adapter = pDM_Odm->Adapter; - rtw_write8(Adapter, RegAddr, Data); + rtl8723au_write8(Adapter, RegAddr, Data); } -void ODM_Write2Byte( - struct dm_odm_t *pDM_Odm, - u32 RegAddr, - u16 Data - ) +void ODM_Write2Byte(struct dm_odm_t *pDM_Odm, u32 RegAddr, u16 Data) { struct rtw_adapter *Adapter = pDM_Odm->Adapter; - rtw_write16(Adapter, RegAddr, Data); + rtl8723au_write16(Adapter, RegAddr, Data); } -void ODM_Write4Byte( - struct dm_odm_t *pDM_Odm, - u32 RegAddr, - u32 Data - ) +void ODM_Write4Byte(struct dm_odm_t *pDM_Odm, u32 RegAddr, u32 Data) { struct rtw_adapter *Adapter = pDM_Odm->Adapter; - rtw_write32(Adapter, RegAddr, Data); - + rtl8723au_write32(Adapter, RegAddr, Data); } void ODM_SetMACReg( diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index 13ca1f66a7c5..a0ab7abf67c8 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -5280,7 +5280,7 @@ static void btdm_1AntTSFSwitch(struct rtw_adapter *padapter, u8 enable) newVal = oldVal & ~EN_BCN_FUNCTION; if (oldVal != newVal) - rtw_write8(padapter, 0x550, newVal); + rtl8723au_write8(padapter, 0x550, newVal); } static u8 btdm_Is1AntPsTdmaStateChange(struct rtw_adapter *padapter) @@ -5379,8 +5379,8 @@ btdm_1AntPsTdma( case 29: /* WiFi DHCP/Site Survey & BT ACL busy */ if (btdm_Is1AntPsTdmaStateChange(padapter)) { BTDM_SetFw3a(padapter, 0xeb, 0x1a, 0x1a, 0x01, 0x18); - rtw_write32(padapter, 0x6c0, 0x5afa5afa); - rtw_write32(padapter, 0x6c4, 0x5afa5afa); + rtl8723au_write32(padapter, 0x6c0, 0x5afa5afa); + rtl8723au_write32(padapter, 0x6c4, 0x5afa5afa); } break; case 30: /* WiFi idle & BT Inquiry */ @@ -5423,7 +5423,8 @@ btdm_1AntPsTdma( /* Antenna control by PTA, 0x870 = 0x310 */ BTDM_SetFw3a(padapter, 0x0, 0x0, 0x0, 0x8, 0x0); } - rtw_write16(padapter, 0x860, 0x210); /* Switch Antenna to BT */ + /* Switch Antenna to BT */ + rtl8723au_write16(padapter, 0x860, 0x210); RTPRINT(FBT, BT_TRACE, ("[BTCoex], 0x860 = 0x210, Switch Antenna to BT\n")); break; case 9: @@ -5431,7 +5432,8 @@ btdm_1AntPsTdma( /* Antenna control by PTA, 0x870 = 0x310 */ BTDM_SetFw3a(padapter, 0x0, 0x0, 0x0, 0x8, 0x0); } - rtw_write16(padapter, 0x860, 0x110); /* Switch Antenna to WiFi */ + /* Switch Antenna to WiFi */ + rtl8723au_write16(padapter, 0x860, 0x110); RTPRINT(FBT, BT_TRACE, ("[BTCoex], 0x860 = 0x110, Switch Antenna to WiFi\n")); break; } @@ -5561,24 +5563,28 @@ static void btdm_1AntWifiParaAdjust(struct rtw_adapter *padapter, u8 bEnable) static void btdm_1AntPtaParaReload(struct rtw_adapter *padapter) { /* PTA parameter */ - rtw_write8(padapter, 0x6cc, 0x0); /* 1-Ant coex */ - rtw_write32(padapter, 0x6c8, 0xffff); /* wifi break table */ - rtw_write32(padapter, 0x6c4, 0x55555555); /* coex table */ + rtl8723au_write8(padapter, 0x6cc, 0x0); /* 1-Ant coex */ + rtl8723au_write32(padapter, 0x6c8, 0xffff); /* wifi break table */ + rtl8723au_write32(padapter, 0x6c4, 0x55555555); /* coex table */ /* Antenna switch control parameter */ - rtw_write32(padapter, 0x858, 0xaaaaaaaa); + rtl8723au_write32(padapter, 0x858, 0xaaaaaaaa); if (IS_8723A_A_CUT(GET_HAL_DATA(padapter)->VersionID)) { - rtw_write32(padapter, 0x870, 0x0); /* SPDT(connected with TRSW) control by hardware PTA */ - rtw_write8(padapter, 0x40, 0x24); + /* SPDT(connected with TRSW) control by hardware PTA */ + rtl8723au_write32(padapter, 0x870, 0x0); + rtl8723au_write8(padapter, 0x40, 0x24); } else { - rtw_write8(padapter, 0x40, 0x20); - rtw_write16(padapter, 0x860, 0x210); /* set antenna at bt side if ANTSW is software control */ - rtw_write32(padapter, 0x870, 0x300); /* SPDT(connected with TRSW) control by hardware PTA */ - rtw_write32(padapter, 0x874, 0x22804000); /* ANTSW keep by GNT_BT */ + rtl8723au_write8(padapter, 0x40, 0x20); + /* set antenna at bt side if ANTSW is software control */ + rtl8723au_write16(padapter, 0x860, 0x210); + /* SPDT(connected with TRSW) control by hardware PTA */ + rtl8723au_write32(padapter, 0x870, 0x300); + /* ANTSW keep by GNT_BT */ + rtl8723au_write32(padapter, 0x874, 0x22804000); } /* coexistence parameters */ - rtw_write8(padapter, 0x778, 0x1); /* enable RTK mode PTA */ + rtl8723au_write8(padapter, 0x778, 0x1); /* enable RTK mode PTA */ /* BT don't ignore WLAN_Act */ btdm_SetFwIgnoreWlanAct(padapter, false); @@ -5775,8 +5781,8 @@ static void btdm_1AntCoexProcessForWifiConnect(struct rtw_adapter *padapter) case BT_INFO_STATE_CONNECT_IDLE: /* WiFi is Busy */ btdm_1AntSetPSTDMA(padapter, false, 0, true, 5); - rtw_write32(padapter, 0x6c0, 0x5a5a5a5a); - rtw_write32(padapter, 0x6c4, 0x5a5a5a5a); + rtl8723au_write32(padapter, 0x6c0, 0x5a5a5a5a); + rtl8723au_write32(padapter, 0x6c4, 0x5a5a5a5a); break; case BT_INFO_STATE_ACL_INQ_OR_PAG: RTPRINT(FBT, BT_TRACE, @@ -5798,8 +5804,8 @@ static void btdm_1AntCoexProcessForWifiConnect(struct rtw_adapter *padapter) #else /* !BTCOEX_CMCC_TEST */ btdm_1AntSetPSTDMA(padapter, false, 0, false, 8); - rtw_write32(padapter, 0x6c0, 0x5a5a5a5a); - rtw_write32(padapter, 0x6c4, 0x5a5a5a5a); + rtl8723au_write32(padapter, 0x6c0, 0x5a5a5a5a); + rtl8723au_write32(padapter, 0x6c4, 0x5a5a5a5a); #endif /* !BTCOEX_CMCC_TEST */ } break; @@ -5922,7 +5928,8 @@ btdm_1AntUpdateHalRAMask(struct rtw_adapter *padapter, u32 mac_id, u32 filter) if (shortGIrate) init_rate |= BIT(6); - rtw_write8(padapter, (REG_INIDATA_RATE_SEL+mac_id), init_rate); + rtl8723au_write8(padapter, REG_INIDATA_RATE_SEL + mac_id, + init_rate); } psta->init_rate = init_rate; @@ -6181,7 +6188,7 @@ static void BTDM_1AntParaInit(struct rtw_adapter *padapter) pBtdm8723 = &pBtCoex->btdm1Ant; /* Enable counter statistics */ - rtw_write8(padapter, 0x76e, 0x4); + rtl8723au_write8(padapter, 0x76e, 0x4); btdm_1AntPtaParaReload(padapter); pBtdm8723->wifiRssiThresh = 48; @@ -6255,8 +6262,8 @@ static void BTDM_1AntWifiAssociateNotify(struct rtw_adapter *padapter, u8 type) BtState == BT_INFO_STATE_ACL_SCO_BUSY) { btdm_1AntSetPSTDMA(padapter, false, 0, false, 8); - rtw_write32(padapter, 0x6c0, 0x5a5a5a5a); - rtw_write32(padapter, 0x6c4, 0x5a5a5a5a); + rtl8723au_write32(padapter, 0x6c0, 0x5a5a5a5a); + rtl8723au_write32(padapter, 0x6c4, 0x5a5a5a5a); } else if (BtState == BT_INFO_STATE_ACL_ONLY_BUSY || BtState == BT_INFO_STATE_ACL_INQ_OR_PAG) { if (pBtCoex->c2hBtProfile == BT_INFO_HID) @@ -6751,13 +6758,13 @@ btdm_SetCoexTable(struct rtw_adapter *padapter, u32 val0x6c0, u32 val0x6c8, u8 val0x6cc) { RTPRINT(FBT, BT_TRACE, ("set coex table, set 0x6c0 = 0x%x\n", val0x6c0)); - rtw_write32(padapter, 0x6c0, val0x6c0); + rtl8723au_write32(padapter, 0x6c0, val0x6c0); RTPRINT(FBT, BT_TRACE, ("set coex table, set 0x6c8 = 0x%x\n", val0x6c8)); - rtw_write32(padapter, 0x6c8, val0x6c8); + rtl8723au_write32(padapter, 0x6c8, val0x6c8); RTPRINT(FBT, BT_TRACE, ("set coex table, set 0x6cc = 0x%x\n", val0x6cc)); - rtw_write8(padapter, 0x6cc, val0x6cc); + rtl8723au_write8(padapter, 0x6cc, val0x6cc); } static void @@ -8580,9 +8587,9 @@ static void BTDM_2AntParaInit(struct rtw_adapter *padapter) RTPRINT(FBT, BT_TRACE, ("[BTCoex], 2Ant Parameter Init!!\n")); /* Enable counter statistics */ - rtw_write8(padapter, 0x76e, 0x4); - rtw_write8(padapter, 0x778, 0x3); - rtw_write8(padapter, 0x40, 0x20); + rtl8723au_write8(padapter, 0x76e, 0x4); + rtl8723au_write8(padapter, 0x778, 0x3); + rtl8723au_write8(padapter, 0x40, 0x20); /* force to reset coex mechanism */ pBtdm8723->preVal0x6c0 = 0x0; @@ -9049,7 +9056,7 @@ static void btdm_BtHwCountersMonitor(struct rtw_adapter *padapter) RTPRINT(FBT, BT_TRACE, ("Low Priority Tx/Rx = %d / %d\n", regLPTx, regLPRx)); /* reset counter */ - rtw_write8(padapter, 0x76e, 0xc); + rtl8723au_write8(padapter, 0x76e, 0xc); } /* This function check if 8723 bt is disabled */ @@ -9355,7 +9362,7 @@ BTDM_SetSwPenaltyTxRateAdaptive( tmpU1 |= BIT(2); } - rtw_write8(padapter, 0x4fd, tmpU1); + rtl8723au_write8(padapter, 0x4fd, tmpU1); } void BTDM_SetFwDecBtPwr(struct rtw_adapter *padapter, u8 bDecBtPwr) @@ -10591,7 +10598,8 @@ u8 BTDM_DisableEDCATurbo(struct rtw_adapter *padapter) if (cur_EDCA_reg != EDCA_BT_BE) bBtChangeEDCA = true; if (bBtChangeEDCA || !pHalData->bt_coexist.bEDCAInitialized) { - rtw_write32(padapter, REG_EDCA_BE_PARAM, EDCA_BT_BE); + rtl8723au_write32(padapter, REG_EDCA_BE_PARAM, + EDCA_BT_BE); pHalData->bt_coexist.lastBtEdca = EDCA_BT_BE; } bRet = true; @@ -10638,11 +10646,11 @@ void BTDM_AGCTable(struct rtw_adapter *padapter, u8 type) struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); if (type == BT_AGCTABLE_OFF) { RTPRINT(FBT, BT_TRACE, ("[BT]AGCTable Off!\n")); - rtw_write32(padapter, 0xc78, 0x641c0001); - rtw_write32(padapter, 0xc78, 0x631d0001); - rtw_write32(padapter, 0xc78, 0x621e0001); - rtw_write32(padapter, 0xc78, 0x611f0001); - rtw_write32(padapter, 0xc78, 0x60200001); + rtl8723au_write32(padapter, 0xc78, 0x641c0001); + rtl8723au_write32(padapter, 0xc78, 0x631d0001); + rtl8723au_write32(padapter, 0xc78, 0x621e0001); + rtl8723au_write32(padapter, 0xc78, 0x611f0001); + rtl8723au_write32(padapter, 0xc78, 0x60200001); PHY_SetRFReg(padapter, PathA, RF_RX_AGC_HP, bRFRegOffsetMask, 0x32000); PHY_SetRFReg(padapter, PathA, RF_RX_AGC_HP, bRFRegOffsetMask, 0x71000); @@ -10653,11 +10661,11 @@ void BTDM_AGCTable(struct rtw_adapter *padapter, u8 type) pHalData->bt_coexist.b8723aAgcTableOn = false; } else if (type == BT_AGCTABLE_ON) { RTPRINT(FBT, BT_TRACE, ("[BT]AGCTable On!\n")); - rtw_write32(padapter, 0xc78, 0x4e1c0001); - rtw_write32(padapter, 0xc78, 0x4d1d0001); - rtw_write32(padapter, 0xc78, 0x4c1e0001); - rtw_write32(padapter, 0xc78, 0x4b1f0001); - rtw_write32(padapter, 0xc78, 0x4a200001); + rtl8723au_write32(padapter, 0xc78, 0x4e1c0001); + rtl8723au_write32(padapter, 0xc78, 0x4d1d0001); + rtl8723au_write32(padapter, 0xc78, 0x4c1e0001); + rtl8723au_write32(padapter, 0xc78, 0x4b1f0001); + rtl8723au_write32(padapter, 0xc78, 0x4a200001); PHY_SetRFReg(padapter, PathA, RF_RX_AGC_HP, bRFRegOffsetMask, 0xdc000); PHY_SetRFReg(padapter, PathA, RF_RX_AGC_HP, bRFRegOffsetMask, 0x90000); @@ -10677,10 +10685,10 @@ void BTDM_BBBackOffLevel(struct rtw_adapter *padapter, u8 type) if (type == BT_BB_BACKOFF_OFF) { RTPRINT(FBT, BT_TRACE, ("[BT]BBBackOffLevel Off!\n")); - rtw_write32(padapter, 0xc04, 0x3a05611); + rtl8723au_write32(padapter, 0xc04, 0x3a05611); } else if (type == BT_BB_BACKOFF_ON) { RTPRINT(FBT, BT_TRACE, ("[BT]BBBackOffLevel On!\n")); - rtw_write32(padapter, 0xc04, 0x3a07611); + rtl8723au_write32(padapter, 0xc04, 0x3a07611); pHalData->bt_coexist.bSWCoexistAllOff = false; } } diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c index 06973d541a4a..ea344214357d 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c @@ -95,11 +95,11 @@ int FillH2CCmd(struct rtw_adapter *padapter, u8 ElementID, u32 CmdLen, if (h2c_cmd & BIT(7)) { msgbox_ex_addr = REG_HMEBOX_EXT_0 + (h2c_box_num * EX_MESSAGE_BOX_SIZE); h2c_cmd_ex = le16_to_cpu(h2c_cmd_ex); - rtw_write16(padapter, msgbox_ex_addr, h2c_cmd_ex); + rtl8723au_write16(padapter, msgbox_ex_addr, h2c_cmd_ex); } msgbox_addr = REG_HMEBOX_0 + (h2c_box_num * MESSAGE_BOX_SIZE); h2c_cmd = le32_to_cpu(h2c_cmd); - rtw_write32(padapter, msgbox_addr, h2c_cmd); + rtl8723au_write32(padapter, msgbox_addr, h2c_cmd); bcmd_down = true; @@ -168,7 +168,8 @@ void rtl8723a_add_rateatid(struct rtw_adapter *pAdapter, u32 bitmap, u8 arg, u8 if (shortGIrate == true) init_rate |= BIT(6); - rtw_write8(pAdapter, (REG_INIDATA_RATE_SEL+macid), (u8)init_rate); + rtl8723au_write8(pAdapter, REG_INIDATA_RATE_SEL + macid, + init_rate); } } @@ -603,17 +604,18 @@ void rtl8723a_set_FwJoinBssReport_cmd(struct rtw_adapter *padapter, u8 mstatus) /* We should set AID, correct TSF, HW seq enable before set JoinBssReport to Fw in 88/92C. */ /* Suggested by filen. Added by tynli. */ - rtw_write16(padapter, REG_BCN_PSR_RPT, (0xC000|pmlmeinfo->aid)); + rtl8723au_write16(padapter, REG_BCN_PSR_RPT, + 0xC000|pmlmeinfo->aid); /* Do not set TSF again here or vWiFi beacon DMA INT will not work. */ /* correct_TSF23a(padapter, pmlmeext); */ /* Hw sequende enable by dedault. 2010.06.23. by tynli. */ - /* rtw_write16(padapter, REG_NQOS_SEQ, ((pmlmeext->mgnt_seq+100)&0xFFF)); */ - /* rtw_write8(padapter, REG_HWSEQ_CTRL, 0xFF); */ + /* rtl8723au_write16(padapter, REG_NQOS_SEQ, ((pmlmeext->mgnt_seq+100)&0xFFF)); */ + /* rtl8723au_write8(padapter, REG_HWSEQ_CTRL, 0xFF); */ /* set REG_CR bit 8 */ v8 = rtl8723au_read8(padapter, REG_CR+1); v8 |= BIT(0); /* ENSWBCN */ - rtw_write8(padapter, REG_CR+1, v8); + rtl8723au_write8(padapter, REG_CR+1, v8); /* Disable Hw protection for a time which revserd for Hw sending beacon. */ /* Fix download reserved page packet fail that access collision with the protection time. */ @@ -628,7 +630,8 @@ void rtl8723a_set_FwJoinBssReport_cmd(struct rtw_adapter *padapter, u8 mstatus) /* To tell Hw the packet is not a real beacon frame. */ /* U1bTmp = rtl8723au_read8(padapter, REG_FWHW_TXQ_CTRL+2); */ - rtw_write8(padapter, REG_FWHW_TXQ_CTRL+2, pHalData->RegFwHwTxQCtrl & ~BIT(6)); + rtl8723au_write8(padapter, REG_FWHW_TXQ_CTRL + 2, + pHalData->RegFwHwTxQCtrl & ~BIT(6)); pHalData->RegFwHwTxQCtrl &= ~BIT(6); SetFwRsvdPagePkt(padapter, 0); @@ -641,14 +644,15 @@ void rtl8723a_set_FwJoinBssReport_cmd(struct rtw_adapter *padapter, u8 mstatus) /* the beacon cannot be sent by HW. */ /* 2010.06.23. Added by tynli. */ if (bRecover) { - rtw_write8(padapter, REG_FWHW_TXQ_CTRL+2, pHalData->RegFwHwTxQCtrl | BIT(6)); + rtl8723au_write8(padapter, REG_FWHW_TXQ_CTRL + 2, + pHalData->RegFwHwTxQCtrl | BIT(6)); pHalData->RegFwHwTxQCtrl |= BIT(6); } /* Clear CR[8] or beacon packet will not be send to TxBuf anymore. */ v8 = rtl8723au_read8(padapter, REG_CR+1); v8 &= ~BIT(0); /* ~ENSWBCN */ - rtw_write8(padapter, REG_CR+1, v8); + rtl8723au_write8(padapter, REG_CR+1, v8); } JoinBssRptParm.OpMode = mstatus; @@ -762,7 +766,8 @@ void rtl8723a_set_BTCoex_AP_mode_FwRsvdPkt_cmd(struct rtw_adapter *padapter) /* To tell Hw the packet is not a real beacon frame. */ pHalData->RegFwHwTxQCtrl &= ~BIT(6); - rtw_write8(padapter, REG_FWHW_TXQ_CTRL+2, pHalData->RegFwHwTxQCtrl); + rtl8723au_write8(padapter, REG_FWHW_TXQ_CTRL + 2, + pHalData->RegFwHwTxQCtrl); SetFwRsvdPagePkt_BTCoex(padapter); /* To make sure that if there exists an adapter which would like to send beacon. */ @@ -772,7 +777,8 @@ void rtl8723a_set_BTCoex_AP_mode_FwRsvdPkt_cmd(struct rtw_adapter *padapter) /* 2010.06.23. Added by tynli. */ if (bRecover) { pHalData->RegFwHwTxQCtrl |= BIT(6); - rtw_write8(padapter, REG_FWHW_TXQ_CTRL+2, pHalData->RegFwHwTxQCtrl); + rtl8723au_write8(padapter, REG_FWHW_TXQ_CTRL + 2, + pHalData->RegFwHwTxQCtrl); } } #endif diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_dm.c b/drivers/staging/rtl8723au/hal/rtl8723a_dm.c index 1ec73e7e2f06..ac47a9711086 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_dm.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_dm.c @@ -48,14 +48,17 @@ static void dm_CheckPbcGPIO(struct rtw_adapter *padapter) tmp1byte = rtl8723au_read8(padapter, GPIO_IO_SEL); tmp1byte |= (HAL_8192C_HW_GPIO_WPS_BIT); - rtw_write8(padapter, GPIO_IO_SEL, tmp1byte); /* enable GPIO[2] as output mode */ + /* enable GPIO[2] as output mode */ + rtl8723au_write8(padapter, GPIO_IO_SEL, tmp1byte); tmp1byte &= ~(HAL_8192C_HW_GPIO_WPS_BIT); - rtw_write8(padapter, GPIO_IN, tmp1byte); /* reset the floating voltage level */ + /* reset the floating voltage level */ + rtl8723au_write8(padapter, GPIO_IN, tmp1byte); tmp1byte = rtl8723au_read8(padapter, GPIO_IO_SEL); tmp1byte &= ~(HAL_8192C_HW_GPIO_WPS_BIT); - rtw_write8(padapter, GPIO_IO_SEL, tmp1byte); /* enable GPIO[2] as input mode */ + /* enable GPIO[2] as input mode */ + rtl8723au_write8(padapter, GPIO_IO_SEL, tmp1byte); tmp1byte = rtl8723au_read8(padapter, GPIO_IN); diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index ea8def5de7d7..e2d426ae0671 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -28,22 +28,22 @@ static void _FWDownloadEnable(struct rtw_adapter *padapter, bool enable) if (enable) { /* 8051 enable */ tmp = rtl8723au_read8(padapter, REG_SYS_FUNC_EN + 1); - rtw_write8(padapter, REG_SYS_FUNC_EN + 1, tmp | 0x04); + rtl8723au_write8(padapter, REG_SYS_FUNC_EN + 1, tmp | 0x04); /* MCU firmware download enable. */ tmp = rtl8723au_read8(padapter, REG_MCUFWDL); - rtw_write8(padapter, REG_MCUFWDL, tmp | 0x01); + rtl8723au_write8(padapter, REG_MCUFWDL, tmp | 0x01); /* 8051 reset */ tmp = rtl8723au_read8(padapter, REG_MCUFWDL + 2); - rtw_write8(padapter, REG_MCUFWDL + 2, tmp & 0xf7); + rtl8723au_write8(padapter, REG_MCUFWDL + 2, tmp & 0xf7); } else { /* MCU firmware download disable. */ tmp = rtl8723au_read8(padapter, REG_MCUFWDL); - rtw_write8(padapter, REG_MCUFWDL, tmp & 0xfe); + rtl8723au_write8(padapter, REG_MCUFWDL, tmp & 0xfe); /* Reserved for fw extension. */ - rtw_write8(padapter, REG_MCUFWDL + 1, 0x00); + rtl8723au_write8(padapter, REG_MCUFWDL + 1, 0x00); } } @@ -76,9 +76,10 @@ static int _BlockWrite(struct rtw_adapter *padapter, void *buffer, u32 buffSize) } for (i = 0; i < blockCount_p1; i++) { - ret = rtw_writeN(padapter, - (FW_8723A_START_ADDRESS + i * blockSize_p1), - blockSize_p1, (bufferPtr + i * blockSize_p1)); + ret = rtl8723au_writeN(padapter, (FW_8723A_START_ADDRESS + + i * blockSize_p1), + blockSize_p1, + (bufferPtr + i * blockSize_p1)); if (ret == _FAIL) goto exit; } @@ -100,11 +101,12 @@ static int _BlockWrite(struct rtw_adapter *padapter, void *buffer, u32 buffSize) } for (i = 0; i < blockCount_p2; i++) { - ret = rtw_writeN(padapter, - (FW_8723A_START_ADDRESS + offset + - i * blockSize_p2), blockSize_p2, - (bufferPtr + offset + - i * blockSize_p2)); + ret = rtl8723au_writeN(padapter, + (FW_8723A_START_ADDRESS + + offset + i * blockSize_p2), + blockSize_p2, + (bufferPtr + offset + + i * blockSize_p2)); if (ret == _FAIL) goto exit; @@ -124,9 +126,9 @@ static int _BlockWrite(struct rtw_adapter *padapter, void *buffer, u32 buffSize) (buffSize - offset), blockSize_p3, blockCount_p3)); for (i = 0; i < blockCount_p3; i++) { - ret = rtw_write8(padapter, - (FW_8723A_START_ADDRESS + offset + i), - *(bufferPtr + offset + i)); + ret = rtl8723au_write8(padapter, + (FW_8723A_START_ADDRESS + offset + i), + *(bufferPtr + offset + i)); if (ret == _FAIL) goto exit; @@ -144,7 +146,7 @@ _PageWrite(struct rtw_adapter *padapter, u32 page, void *buffer, u32 size) u8 u8Page = (u8) (page & 0x07); value8 = (rtl8723au_read8(padapter, REG_MCUFWDL + 2) & 0xF8) | u8Page; - rtw_write8(padapter, REG_MCUFWDL + 2, value8); + rtl8723au_write8(padapter, REG_MCUFWDL + 2, value8); return _BlockWrite(padapter, buffer, size); } @@ -213,7 +215,7 @@ static int _FWFreeToGo(struct rtw_adapter *padapter) value32 = rtl8723au_read32(padapter, REG_MCUFWDL); value32 |= MCUFWDL_RDY; value32 &= ~WINTINI_RDY; - rtw_write32(padapter, REG_MCUFWDL, value32); + rtl8723au_write32(padapter, REG_MCUFWDL, value32); /* polling for FW ready */ counter = 0; @@ -249,7 +251,7 @@ void rtl8723a_FirmwareSelfReset(struct rtw_adapter *padapter) pHalData->FirmwareSubVersion < 0x01)))) { /* after 88C Fw v33.1 */ /* 0x1cf = 0x20. Inform 8051 to reset. 2009.12.25. tynli_test */ - rtw_write8(padapter, REG_HMETFR + 3, 0x20); + rtl8723au_write8(padapter, REG_HMETFR + 3, 0x20); u1bTmp = rtl8723au_read8(padapter, REG_SYS_FUNC_EN + 1); while (u1bTmp & BIT(2)) { @@ -266,8 +268,8 @@ void rtl8723a_FirmwareSelfReset(struct rtw_adapter *padapter) if ((Delay == 0)) { /* force firmware reset */ u1bTmp = rtl8723au_read8(padapter, REG_SYS_FUNC_EN + 1); - rtw_write8(padapter, REG_SYS_FUNC_EN + 1, - u1bTmp & ~BIT(2)); + rtl8723au_write8(padapter, REG_SYS_FUNC_EN + 1, + u1bTmp & ~BIT(2)); } } } @@ -376,15 +378,16 @@ int rtl8723a_FirmwareDownload(struct rtw_adapter *padapter) if (rtl8723au_read8(padapter, REG_MCUFWDL) & RAM_DL_SEL) { /* 8051 RAM code */ rtl8723a_FirmwareSelfReset(padapter); - rtw_write8(padapter, REG_MCUFWDL, 0x00); + rtl8723au_write8(padapter, REG_MCUFWDL, 0x00); } _FWDownloadEnable(padapter, true); fwdl_start_time = jiffies; while (1) { /* reset the FWDL chksum */ - rtw_write8(padapter, REG_MCUFWDL, - rtl8723au_read8(padapter, REG_MCUFWDL) | FWDL_ChkSum_rpt); + rtl8723au_write8(padapter, REG_MCUFWDL, + rtl8723au_read8(padapter, REG_MCUFWDL) | + FWDL_ChkSum_rpt); rtStatus = _WriteFW(padapter, buf, fw_size); @@ -463,7 +466,7 @@ hal_EfuseSwitchToBank(struct rtw_adapter *padapter, u8 bank) bRet = false; break; } - rtw_write32(padapter, EFUSE_TEST, value32); + rtl8723au_write32(padapter, EFUSE_TEST, value32); return bRet; } @@ -972,29 +975,30 @@ void SetBcnCtrlReg23a(struct rtw_adapter *padapter, u8 SetBits, u8 ClearBits) *pRegBcnCtrlVal |= SetBits; *pRegBcnCtrlVal &= ~ClearBits; - rtw_write8(padapter, addr, *pRegBcnCtrlVal); + rtl8723au_write8(padapter, addr, *pRegBcnCtrlVal); } void rtl8723a_InitBeaconParameters(struct rtw_adapter *padapter) { struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - rtw_write16(padapter, REG_BCN_CTRL, 0x1010); + rtl8723au_write16(padapter, REG_BCN_CTRL, 0x1010); pHalData->RegBcnCtrlVal = 0x1010; /* TODO: Remove these magic number */ - rtw_write16(padapter, REG_TBTT_PROHIBIT, 0x6404); /* ms */ + rtl8723au_write16(padapter, REG_TBTT_PROHIBIT, 0x6404); /* ms */ /* Firmware will control REG_DRVERLYINT when power saving is enable, */ /* so don't set this register on STA mode. */ if (check_fwstate(&padapter->mlmepriv, WIFI_STATION_STATE) == false) - rtw_write8(padapter, REG_DRVERLYINT, DRIVER_EARLY_INT_TIME); + rtl8723au_write8(padapter, REG_DRVERLYINT, + DRIVER_EARLY_INT_TIME); /* 2ms */ - rtw_write8(padapter, REG_BCNDMATIM, BCN_DMA_ATIME_INT_TIME); + rtl8723au_write8(padapter, REG_BCNDMATIM, BCN_DMA_ATIME_INT_TIME); /* Suggested by designer timchen. Change beacon AIFS to the largest number beacause test chip does not contension before sending beacon. by tynli. 2009.11.03 */ - rtw_write16(padapter, REG_BCNTCFG, 0x660F); + rtl8723au_write16(padapter, REG_BCNTCFG, 0x660F); } static void ResumeTxBeacon(struct rtw_adapter *padapter) @@ -1008,10 +1012,11 @@ static void ResumeTxBeacon(struct rtw_adapter *padapter) RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("+ResumeTxBeacon\n")); pHalData->RegFwHwTxQCtrl |= BIT(6); - rtw_write8(padapter, REG_FWHW_TXQ_CTRL + 2, pHalData->RegFwHwTxQCtrl); - rtw_write8(padapter, REG_TBTT_PROHIBIT + 1, 0xff); + rtl8723au_write8(padapter, REG_FWHW_TXQ_CTRL + 2, + pHalData->RegFwHwTxQCtrl); + rtl8723au_write8(padapter, REG_TBTT_PROHIBIT + 1, 0xff); pHalData->RegReg542 |= BIT(0); - rtw_write8(padapter, REG_TBTT_PROHIBIT + 2, pHalData->RegReg542); + rtl8723au_write8(padapter, REG_TBTT_PROHIBIT + 2, pHalData->RegReg542); } static void StopTxBeacon(struct rtw_adapter *padapter) @@ -1025,10 +1030,11 @@ static void StopTxBeacon(struct rtw_adapter *padapter) RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("+StopTxBeacon\n")); pHalData->RegFwHwTxQCtrl &= ~BIT(6); - rtw_write8(padapter, REG_FWHW_TXQ_CTRL + 2, pHalData->RegFwHwTxQCtrl); - rtw_write8(padapter, REG_TBTT_PROHIBIT + 1, 0x64); + rtl8723au_write8(padapter, REG_FWHW_TXQ_CTRL + 2, + pHalData->RegFwHwTxQCtrl); + rtl8723au_write8(padapter, REG_TBTT_PROHIBIT + 1, 0x64); pHalData->RegReg542 &= ~BIT(0); - rtw_write8(padapter, REG_TBTT_PROHIBIT + 2, pHalData->RegReg542); + rtl8723au_write8(padapter, REG_TBTT_PROHIBIT + 2, pHalData->RegReg542); CheckFwRsvdPageContent23a(padapter); /* 2010.06.23. Added by tynli. */ } @@ -1038,7 +1044,7 @@ static void _BeaconFunctionEnable(struct rtw_adapter *padapter, u8 Enable, { SetBcnCtrlReg23a(padapter, DIS_TSF_UDT | EN_BCN_FUNCTION | DIS_BCNQ_SUB, 0); - rtw_write8(padapter, REG_RD_CTRL + 1, 0x6F); + rtl8723au_write8(padapter, REG_RD_CTRL + 1, 0x6F); } void rtl8723a_SetBeaconRelatedRegisters(struct rtw_adapter *padapter) @@ -1062,32 +1068,32 @@ void rtl8723a_SetBeaconRelatedRegisters(struct rtw_adapter *padapter) /* */ /* ATIM window */ /* */ - rtw_write16(padapter, REG_ATIMWND, 2); + rtl8723au_write16(padapter, REG_ATIMWND, 2); /* */ /* Beacon interval (in unit of TU). */ /* */ - rtw_write16(padapter, REG_BCN_INTERVAL, pmlmeinfo->bcn_interval); + rtl8723au_write16(padapter, REG_BCN_INTERVAL, pmlmeinfo->bcn_interval); rtl8723a_InitBeaconParameters(padapter); - rtw_write8(padapter, REG_SLOT, 0x09); + rtl8723au_write8(padapter, REG_SLOT, 0x09); /* */ /* Reset TSF Timer to zero, added by Roger. 2008.06.24 */ /* */ value32 = rtl8723au_read32(padapter, REG_TCR); value32 &= ~TSFRST; - rtw_write32(padapter, REG_TCR, value32); + rtl8723au_write32(padapter, REG_TCR, value32); value32 |= TSFRST; - rtw_write32(padapter, REG_TCR, value32); + rtl8723au_write32(padapter, REG_TCR, value32); /* NOTE: Fix test chip's bug (about contention windows's randomness) */ if (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE | WIFI_AP_STATE) == true) { - rtw_write8(padapter, REG_RXTSF_OFFSET_CCK, 0x50); - rtw_write8(padapter, REG_RXTSF_OFFSET_OFDM, 0x50); + rtl8723au_write8(padapter, REG_RXTSF_OFFSET_CCK, 0x50); + rtl8723au_write8(padapter, REG_RXTSF_OFFSET_OFDM, 0x50); } _BeaconFunctionEnable(padapter, true, true); @@ -1135,12 +1141,14 @@ void rtl8723a_notch_filter(struct rtw_adapter *adapter, bool enable) { if (enable) { DBG_8723A("Enable notch filter\n"); - rtw_write8(adapter, rOFDM0_RxDSP + 1, - rtl8723au_read8(adapter, rOFDM0_RxDSP + 1) | BIT(1)); + rtl8723au_write8(adapter, rOFDM0_RxDSP + 1, + rtl8723au_read8(adapter, rOFDM0_RxDSP + 1) | + BIT(1)); } else { DBG_8723A("Disable notch filter\n"); - rtw_write8(adapter, rOFDM0_RxDSP + 1, - rtl8723au_read8(adapter, rOFDM0_RxDSP + 1) & ~BIT(1)); + rtl8723au_write8(adapter, rOFDM0_RxDSP + 1, + rtl8723au_read8(adapter, rOFDM0_RxDSP + 1) & + ~BIT(1)); } } @@ -1218,7 +1226,7 @@ void rtl8723a_InitAntenna_Selection(struct rtw_adapter *padapter) val = rtl8723au_read8(padapter, REG_LEDCFG2); /* Let 8051 take control antenna settting */ val |= BIT(7); /* DPDT_SEL_EN, 0x4C[23] */ - rtw_write8(padapter, REG_LEDCFG2, val); + rtl8723au_write8(padapter, REG_LEDCFG2, val); } void rtl8723a_CheckAntenna_Selection(struct rtw_adapter *padapter) @@ -1229,7 +1237,7 @@ void rtl8723a_CheckAntenna_Selection(struct rtw_adapter *padapter) /* Let 8051 take control antenna settting */ if (!(val & BIT(7))) { val |= BIT(7); /* DPDT_SEL_EN, 0x4C[23] */ - rtw_write8(padapter, REG_LEDCFG2, val); + rtl8723au_write8(padapter, REG_LEDCFG2, val); } } @@ -1240,7 +1248,7 @@ void rtl8723a_DeinitAntenna_Selection(struct rtw_adapter *padapter) val = rtl8723au_read8(padapter, REG_LEDCFG2); /* Let 8051 take control antenna settting */ val &= ~BIT(7); /* DPDT_SEL_EN, clear 0x4C[23] */ - rtw_write8(padapter, REG_LEDCFG2, val); + rtl8723au_write8(padapter, REG_LEDCFG2, val); } void rtl8723a_init_default_value(struct rtw_adapter *padapter) @@ -1302,7 +1310,7 @@ static int _LLTWrite(struct rtw_adapter *padapter, u32 address, u32 data) _LLT_OP(_LLT_WRITE_ACCESS); u16 LLTReg = REG_LLT_INIT; - rtw_write32(padapter, LLTReg, value); + rtl8723au_write32(padapter, LLTReg, value); /* polling */ do { @@ -1376,11 +1384,11 @@ n. LEDCFG 0x4C[15:0] = 0x8080 u32 u4bTmp; /* 1. Disable GPIO[7:0] */ - rtw_write16(padapter, REG_GPIO_PIN_CTRL + 2, 0x0000); + rtl8723au_write16(padapter, REG_GPIO_PIN_CTRL + 2, 0x0000); value32 = rtl8723au_read32(padapter, REG_GPIO_PIN_CTRL) & 0xFFFF00FF; u4bTmp = value32 & 0x000000FF; value32 |= ((u4bTmp << 8) | 0x00FF0000); - rtw_write32(padapter, REG_GPIO_PIN_CTRL, value32); + rtl8723au_write32(padapter, REG_GPIO_PIN_CTRL, value32); /* */ /* For RTL8723u multi-function configuration which @@ -1391,15 +1399,15 @@ n. LEDCFG 0x4C[15:0] = 0x8080 /* 2. Disable GPIO[8] and GPIO[12] */ /* Configure all pins as input mode. */ - rtw_write16(padapter, REG_GPIO_IO_SEL_2, 0x0000); + rtl8723au_write16(padapter, REG_GPIO_IO_SEL_2, 0x0000); value32 = rtl8723au_read32(padapter, REG_GPIO_PIN_CTRL_2) & 0xFFFF001F; u4bTmp = value32 & 0x0000001F; /* Set pin 8, 10, 11 and pin 12 to output mode. */ value32 |= ((u4bTmp << 8) | 0x001D0000); - rtw_write32(padapter, REG_GPIO_PIN_CTRL_2, value32); + rtl8723au_write32(padapter, REG_GPIO_PIN_CTRL_2, value32); /* 3. Disable LED0 & 1 */ - rtw_write16(padapter, REG_LEDCFG0, 0x8080); + rtl8723au_write16(padapter, REG_LEDCFG0, 0x8080); } /* end of _DisableGPIO() */ static void _DisableRFAFEAndResetBB8192C(struct rtw_adapter *padapter) @@ -1413,21 +1421,21 @@ e. SYS_FUNC_EN 0x02[7:0] = 0x14 reset BB state machine ***************************************/ u8 eRFPath = 0, value8 = 0; - rtw_write8(padapter, REG_TXPAUSE, 0xFF); + rtl8723au_write8(padapter, REG_TXPAUSE, 0xFF); PHY_SetRFReg(padapter, (enum RF_RADIO_PATH) eRFPath, 0x0, bMaskByte0, 0x0); value8 |= APSDOFF; - rtw_write8(padapter, REG_APSD_CTRL, value8); /* 0x40 */ + rtl8723au_write8(padapter, REG_APSD_CTRL, value8); /* 0x40 */ /* Set BB reset at first */ value8 = 0; value8 |= (FEN_USBD | FEN_USBA | FEN_BB_GLB_RSTn); - rtw_write8(padapter, REG_SYS_FUNC_EN, value8); /* 0x16 */ + rtl8723au_write8(padapter, REG_SYS_FUNC_EN, value8); /* 0x16 */ /* Set global reset. */ value8 &= ~FEN_BB_GLB_RSTn; - rtw_write8(padapter, REG_SYS_FUNC_EN, value8); /* 0x14 */ + rtl8723au_write8(padapter, REG_SYS_FUNC_EN, value8); /* 0x14 */ /* 2010/08/12 MH We need to set BB/GLBAL reset to save power for SS mode. */ @@ -1454,19 +1462,22 @@ static void _ResetDigitalProcedure1_92C(struct rtw_adapter *padapter, (8051 enable) ******************************/ u16 valu16 = 0; - rtw_write8(padapter, REG_MCUFWDL, 0); + rtl8723au_write8(padapter, REG_MCUFWDL, 0); valu16 = rtl8723au_read16(padapter, REG_SYS_FUNC_EN); /* reset MCU , 8051 */ - rtw_write16(padapter, REG_SYS_FUNC_EN, (valu16 & (~FEN_CPUEN))); + rtl8723au_write16(padapter, REG_SYS_FUNC_EN, + valu16 & (~FEN_CPUEN)); valu16 = rtl8723au_read16(padapter, REG_SYS_FUNC_EN) & 0x0FFF; - rtw_write16(padapter, REG_SYS_FUNC_EN, - (valu16 | (FEN_HWPDN | FEN_ELDR))); /* reset MAC */ + /* reset MAC */ + rtl8723au_write16(padapter, REG_SYS_FUNC_EN, + valu16 | (FEN_HWPDN | FEN_ELDR)); valu16 = rtl8723au_read16(padapter, REG_SYS_FUNC_EN); /* enable MCU , 8051 */ - rtw_write16(padapter, REG_SYS_FUNC_EN, (valu16 | FEN_CPUEN)); + rtl8723au_write16(padapter, REG_SYS_FUNC_EN, + valu16 | FEN_CPUEN); } else { u8 retry_cnts = 0; @@ -1481,15 +1492,16 @@ static void _ResetDigitalProcedure1_92C(struct rtw_adapter *padapter, /* 2010/08/25 MH Accordign to RD alfred's suggestion, we need to disable other */ /* HRCV INT to influence 8051 reset. */ - rtw_write8(padapter, REG_FWIMR, 0x20); + rtl8723au_write8(padapter, REG_FWIMR, 0x20); /* 2011/02/15 MH According to Alex's suggestion, close mask to prevent incorrect FW write operation. */ - rtw_write8(padapter, REG_FTIMR, 0x00); - rtw_write8(padapter, REG_FSIMR, 0x00); + rtl8723au_write8(padapter, REG_FTIMR, 0x00); + rtl8723au_write8(padapter, REG_FSIMR, 0x00); /* 8051 reset by self */ - rtw_write8(padapter, REG_HMETFR + 3, 0x20); + rtl8723au_write8(padapter, REG_HMETFR + 3, + 0x20); while ((retry_cnts++ < 100) && (FEN_CPUEN & @@ -1500,15 +1512,16 @@ static void _ResetDigitalProcedure1_92C(struct rtw_adapter *padapter, if (retry_cnts >= 100) { /* Reset MAC and Enable 8051 */ - rtw_write8(padapter, - REG_SYS_FUNC_EN + 1, 0x50); + rtl8723au_write8(padapter, + REG_SYS_FUNC_EN + 1, + 0x50); mdelay(10); } } } /* Reset MAC and Enable 8051 */ - rtw_write8(padapter, REG_SYS_FUNC_EN + 1, 0x54); - rtw_write8(padapter, REG_MCUFWDL, 0); + rtl8723au_write8(padapter, REG_SYS_FUNC_EN + 1, 0x54); + rtl8723au_write8(padapter, REG_MCUFWDL, 0); } if (bWithoutHWSM) { @@ -1520,13 +1533,13 @@ static void _ResetDigitalProcedure1_92C(struct rtw_adapter *padapter, j. SYS_ISO_CTRL 0x00[7:0] = 0xF9 isolated digital to PON ******************************/ /* modify to 0x70A3 by Scott. */ - rtw_write16(padapter, REG_SYS_CLKR, 0x70A3); - rtw_write8(padapter, REG_AFE_PLL_CTRL, 0x80); - rtw_write16(padapter, REG_AFE_XTAL_CTRL, 0x880F); - rtw_write8(padapter, REG_SYS_ISO_CTRL, 0xF9); + rtl8723au_write16(padapter, REG_SYS_CLKR, 0x70A3); + rtl8723au_write8(padapter, REG_AFE_PLL_CTRL, 0x80); + rtl8723au_write16(padapter, REG_AFE_XTAL_CTRL, 0x880F); + rtl8723au_write8(padapter, REG_SYS_ISO_CTRL, 0xF9); } else { /* Disable all RF/BB power */ - rtw_write8(padapter, REG_RF_CTRL, 0x00); + rtl8723au_write8(padapter, REG_RF_CTRL, 0x00); } } @@ -1544,9 +1557,9 @@ l. SYS_CLKR 0x08[15:0] = 0x3083 disable ELDR clock m. SYS_ISO_CTRL 0x01[7:0] = 0x83 isolated ELDR to PON ******************************/ /* modify to 0x70a3 by Scott. */ - rtw_write16(padapter, REG_SYS_CLKR, 0x70a3); + rtl8723au_write16(padapter, REG_SYS_CLKR, 0x70a3); /* modify to 0x82 by Scott. */ - rtw_write8(padapter, REG_SYS_ISO_CTRL + 1, 0x82); + rtl8723au_write8(padapter, REG_SYS_ISO_CTRL + 1, 0x82); } static void _DisableAnalog(struct rtw_adapter *padapter, bool bWithoutHWSM) @@ -1563,12 +1576,12 @@ static void _DisableAnalog(struct rtw_adapter *padapter, bool bWithoutHWSM) clock automatically ******************************/ - rtw_write8(padapter, REG_LDOA15_CTRL, 0x04); - /* rtw_write8(padapter, REG_LDOV12D_CTRL, 0x54); */ + rtl8723au_write8(padapter, REG_LDOA15_CTRL, 0x04); + /* rtl8723au_write8(padapter, REG_LDOV12D_CTRL, 0x54); */ value8 = rtl8723au_read8(padapter, REG_LDOV12D_CTRL); value8 &= (~LDV12_EN); - rtw_write8(padapter, REG_LDOV12D_CTRL, value8); + rtl8723au_write8(padapter, REG_LDOV12D_CTRL, value8); /* RT_TRACE(COMP_INIT, DBG_LOUD, (" REG_LDOV12D_CTRL Reg0x21:0x%02x.\n", value8)); */ } @@ -1581,7 +1594,7 @@ static void _DisableAnalog(struct rtw_adapter *padapter, bool bWithoutHWSM) if (IS_81xxC_VENDOR_UMC_B_CUT(pHalData->VersionID)) value8 |= BIT(3); - rtw_write8(padapter, REG_SPS0_CTRL, value8); + rtl8723au_write8(padapter, REG_SPS0_CTRL, value8); if (bWithoutHWSM) { /* value16 |= (APDM_HOST | FSM_HSUS |/PFM_ALDN); */ @@ -1594,9 +1607,9 @@ static void _DisableAnalog(struct rtw_adapter *padapter, bool bWithoutHWSM) value16 |= (APDM_HOST | AFSM_HSUS | PFM_ALDN); } - rtw_write16(padapter, REG_APS_FSMCO, value16); /* 0x4802 */ + rtl8723au_write16(padapter, REG_APS_FSMCO, value16); /* 0x4802 */ - rtw_write8(padapter, REG_RSV_CTRL, 0x0e); + rtl8723au_write8(padapter, REG_RSV_CTRL, 0x0e); } /* HW Auto state machine */ @@ -2395,26 +2408,29 @@ void hw_var_set_opmode(struct rtw_adapter *padapter, u8 mode) SetBcnCtrlReg23a(padapter, val8, ~val8); /* Set RCR */ - /* rtw_write32(padapter, REG_RCR, 0x70002a8e); + /* rtl8723au_write32(padapter, REG_RCR, 0x70002a8e); CBSSID_DATA must set to 0 */ /* CBSSID_DATA must set to 0 */ - rtw_write32(padapter, REG_RCR, 0x7000228e); + rtl8723au_write32(padapter, REG_RCR, 0x7000228e); /* enable to rx data frame */ - rtw_write16(padapter, REG_RXFLTMAP2, 0xFFFF); + rtl8723au_write16(padapter, REG_RXFLTMAP2, 0xFFFF); /* enable to rx ps-poll */ - rtw_write16(padapter, REG_RXFLTMAP1, 0x0400); + rtl8723au_write16(padapter, REG_RXFLTMAP1, 0x0400); /* Beacon Control related register for first time */ - rtw_write8(padapter, REG_BCNDMATIM, 0x02); /* 2ms */ - rtw_write8(padapter, REG_DRVERLYINT, 0x05); /* 5ms */ - rtw_write8(padapter, REG_ATIMWND, 0x0a); /* 10ms for port0 */ - rtw_write16(padapter, REG_BCNTCFG, 0x00); - rtw_write16(padapter, REG_TBTT_PROHIBIT, 0xff04); + /* 2ms */ + rtl8723au_write8(padapter, REG_BCNDMATIM, 0x02); + /* 5ms */ + rtl8723au_write8(padapter, REG_DRVERLYINT, 0x05); + /* 10ms for port0 */ + rtl8723au_write8(padapter, REG_ATIMWND, 0x0a); + rtl8723au_write16(padapter, REG_BCNTCFG, 0x00); + rtl8723au_write16(padapter, REG_TBTT_PROHIBIT, 0xff04); /* +32767 (~32ms) */ - rtw_write16(padapter, REG_TSFTR_SYN_OFFSET, 0x7fff); + rtl8723au_write16(padapter, REG_TSFTR_SYN_OFFSET, 0x7fff); /* reset TSF */ - rtw_write8(padapter, REG_DUAL_TSF_RST, BIT(0)); + rtl8723au_write8(padapter, REG_DUAL_TSF_RST, BIT(0)); /* enable BCN Function */ /* don't enable update TSF (due to TSF update when @@ -2426,7 +2442,7 @@ void hw_var_set_opmode(struct rtw_adapter *padapter, u8 mode) val8 = rtl8723au_read8(padapter, MSR); val8 = (val8 & 0xC) | mode; - rtw_write8(padapter, MSR, val8); + rtl8723au_write8(padapter, MSR, val8); } void hw_var_set_macaddr(struct rtw_adapter *padapter, u8 *val) @@ -2437,7 +2453,7 @@ void hw_var_set_macaddr(struct rtw_adapter *padapter, u8 *val) reg_macid = REG_MACID; for (idx = 0; idx < 6; idx++) - rtw_write8(padapter, (reg_macid + idx), val[idx]); + rtl8723au_write8(padapter, (reg_macid + idx), val[idx]); } void hw_var_set_bssid(struct rtw_adapter *padapter, u8 *val) @@ -2448,7 +2464,7 @@ void hw_var_set_bssid(struct rtw_adapter *padapter, u8 *val) reg_bssid = REG_BSSID; for (idx = 0; idx < 6; idx++) - rtw_write8(padapter, (reg_bssid + idx), val[idx]); + rtl8723au_write8(padapter, (reg_bssid + idx), val[idx]); } void hw_var_set_correct_tsf(struct rtw_adapter *padapter) @@ -2467,7 +2483,7 @@ void hw_var_set_correct_tsf(struct rtw_adapter *padapter) if (((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)) { /* pHalData->RegTxPause |= STOP_BCNQ;BIT(6) */ - /* rtw_write8(padapter, REG_TXPAUSE, + /* rtl8723au_write8(padapter, REG_TXPAUSE, (rtl8723au_read8(Adapter, REG_TXPAUSE)|BIT(6))); */ StopTxBeacon(padapter); } @@ -2477,8 +2493,8 @@ void hw_var_set_correct_tsf(struct rtw_adapter *padapter) /* disable related TSF function */ SetBcnCtrlReg23a(padapter, 0, EN_BCN_FUNCTION); - rtw_write32(padapter, reg_tsftr, tsf); - rtw_write32(padapter, reg_tsftr + 4, tsf >> 32); + rtl8723au_write32(padapter, reg_tsftr, tsf); + rtl8723au_write32(padapter, reg_tsftr + 4, tsf >> 32); /* enable related TSF function */ SetBcnCtrlReg23a(padapter, EN_BCN_FUNCTION, 0); @@ -2491,10 +2507,10 @@ void hw_var_set_correct_tsf(struct rtw_adapter *padapter) void hw_var_set_mlme_disconnect(struct rtw_adapter *padapter) { /* reject all data frames */ - rtw_write16(padapter, REG_RXFLTMAP2, 0); + rtl8723au_write16(padapter, REG_RXFLTMAP2, 0); /* reset TSF */ - rtw_write8(padapter, REG_DUAL_TSF_RST, BIT(0)); + rtl8723au_write8(padapter, REG_DUAL_TSF_RST, BIT(0)); /* disable update TSF */ SetBcnCtrlReg23a(padapter, DIS_TSF_UDT, 0); @@ -2511,13 +2527,13 @@ void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type) u32 v32; /* enable to rx data frame.Accept all data frame */ - /* rtw_write32(padapter, REG_RCR, + /* rtl8723au_write32(padapter, REG_RCR, rtl8723au_read32(padapter, REG_RCR)|RCR_ADF); */ - rtw_write16(padapter, REG_RXFLTMAP2, 0xFFFF); + rtl8723au_write16(padapter, REG_RXFLTMAP2, 0xFFFF); v32 = rtl8723au_read32(padapter, REG_RCR); v32 |= RCR_CBSSID_DATA | RCR_CBSSID_BCN; - rtw_write32(padapter, REG_RCR, v32); + rtl8723au_write32(padapter, REG_RCR, v32); if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) RetryLimit = @@ -2527,7 +2543,7 @@ void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type) } else if (type == 1) { /* joinbss_event callback when join res < 0 */ /* config RCR to receive different BSSID & not to receive data frame during linking */ - rtw_write16(padapter, REG_RXFLTMAP2, 0); + rtl8723au_write16(padapter, REG_RXFLTMAP2, 0); } else if (type == 2) { /* sta add event callback */ /* enable update TSF */ SetBcnCtrlReg23a(padapter, 0, DIS_TSF_UDT); @@ -2535,14 +2551,14 @@ void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type) if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE)) { /* fixed beacon issue for 8191su........... */ - rtw_write8(padapter, 0x542, 0x02); + rtl8723au_write8(padapter, 0x542, 0x02); RetryLimit = 0x7; } } - rtw_write16(padapter, REG_RL, - RetryLimit << RETRY_LIMIT_SHORT_SHIFT | RetryLimit << - RETRY_LIMIT_LONG_SHIFT); + rtl8723au_write16(padapter, REG_RL, + RetryLimit << RETRY_LIMIT_SHORT_SHIFT | RetryLimit << + RETRY_LIMIT_LONG_SHIFT); #ifdef CONFIG_8723AU_BT_COEXIST switch (type) { diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c b/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c index ad999ffd4050..97da41409bc3 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c @@ -129,7 +129,7 @@ PHY_SetBBReg(struct rtw_adapter *Adapter, u32 RegAddr, u32 BitMask, u32 Data) Data = ((OriginalValue & (~BitMask)) | (Data << BitShift)); } - rtw_write32(Adapter, RegAddr, Data); + rtl8723au_write32(Adapter, RegAddr, Data); /* RTPRINT(FPHY, PHY_BBW, ("BBW MASK = 0x%lx Addr[0x%lx]= 0x%lx\n", BitMask, RegAddr, Data)); */ /* RT_TRACE(COMP_RF, DBG_TRACE, ("<---PHY_SetBBReg(): RegAddr(%#lx), BitMask(%#lx), Data(%#lx)\n", RegAddr, BitMask, Data)); */ @@ -430,9 +430,9 @@ int PHY_MACConfig8723A(struct rtw_adapter *Adapter) /* 2010.07.13 AMPDU aggregation number 9 */ /* rtw_write16(Adapter, REG_MAX_AGGR_NUM, MAX_AGGR_NUM); */ - rtw_write8(Adapter, REG_MAX_AGGR_NUM, 0x0A); /* By tynli. 2010.11.18. */ + rtl8723au_write8(Adapter, REG_MAX_AGGR_NUM, 0x0A); if (is92C && (BOARD_USB_DONGLE == pHalData->BoardType)) - rtw_write8(Adapter, 0x40, 0x04); + rtl8723au_write8(Adapter, 0x40, 0x04); return rtStatus; } @@ -807,28 +807,28 @@ PHY_BBConfig8723A(struct rtw_adapter *Adapter) /* 1. 0x28[1] = 1 */ TmpU1B = rtl8723au_read8(Adapter, REG_AFE_PLL_CTRL); udelay(2); - rtw_write8(Adapter, REG_AFE_PLL_CTRL, TmpU1B | BIT(1)); + rtl8723au_write8(Adapter, REG_AFE_PLL_CTRL, TmpU1B | BIT(1)); udelay(2); /* 2. 0x29[7:0] = 0xFF */ - rtw_write8(Adapter, REG_AFE_PLL_CTRL+1, 0xff); + rtl8723au_write8(Adapter, REG_AFE_PLL_CTRL+1, 0xff); udelay(2); /* 3. 0x02[1:0] = 2b'11 */ TmpU1B = rtl8723au_read8(Adapter, REG_SYS_FUNC_EN); - rtw_write8(Adapter, REG_SYS_FUNC_EN, - (TmpU1B | FEN_BB_GLB_RSTn | FEN_BBRSTB)); + rtl8723au_write8(Adapter, REG_SYS_FUNC_EN, + (TmpU1B | FEN_BB_GLB_RSTn | FEN_BBRSTB)); /* 4. 0x25[6] = 0 */ TmpU1B = rtl8723au_read8(Adapter, REG_AFE_XTAL_CTRL + 1); - rtw_write8(Adapter, REG_AFE_XTAL_CTRL+1, TmpU1B & ~BIT(6)); + rtl8723au_write8(Adapter, REG_AFE_XTAL_CTRL+1, TmpU1B & ~BIT(6)); /* 5. 0x24[20] = 0 Advised by SD3 Alex Wang. 2011.02.09. */ TmpU1B = rtl8723au_read8(Adapter, REG_AFE_XTAL_CTRL+2); - rtw_write8(Adapter, REG_AFE_XTAL_CTRL+2, TmpU1B & ~BIT(4)); + rtl8723au_write8(Adapter, REG_AFE_XTAL_CTRL+2, TmpU1B & ~BIT(4)); /* 6. 0x1f[7:0] = 0x07 */ - rtw_write8(Adapter, REG_RF_CTRL, 0x07); + rtl8723au_write8(Adapter, REG_RF_CTRL, 0x07); /* */ /* Config BB and AGC */ @@ -963,14 +963,14 @@ _PHY_SetBWMode23a92C(struct rtw_adapter *Adapter) switch (pHalData->CurrentChannelBW) { case HT_CHANNEL_WIDTH_20: regBwOpMode |= BW_OPMODE_20MHZ; - rtw_write8(Adapter, REG_BWOPMODE, regBwOpMode); + rtl8723au_write8(Adapter, REG_BWOPMODE, regBwOpMode); break; case HT_CHANNEL_WIDTH_40: regBwOpMode &= ~BW_OPMODE_20MHZ; - rtw_write8(Adapter, REG_BWOPMODE, regBwOpMode); + rtl8723au_write8(Adapter, REG_BWOPMODE, regBwOpMode); regRRSR_RSC = (regRRSR_RSC & 0x90) | (pHalData->nCur40MhzPrimeSC << 5); - rtw_write8(Adapter, REG_RRSR+2, regRRSR_RSC); + rtl8723au_write8(Adapter, REG_RRSR+2, regRRSR_RSC); break; default: diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c b/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c index 7fbad8eb2a20..c30bd232bf62 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c @@ -40,6 +40,7 @@ #include #include +#include /*---------------------------Define Local Constant---------------------------*/ /* Define local structure for debug!!!!! */ @@ -368,7 +369,8 @@ static void writeOFDMPowerReg(struct rtw_adapter *Adapter, u8 index, u32 *pValue writeVal = (writeVal > 8) ? (writeVal-8) : 0; else writeVal = (writeVal > 6) ? (writeVal-6) : 0; - rtw_write8(Adapter, (u32)(RegOffset+i), (u8)writeVal); + rtl8723au_write8(Adapter, RegOffset + i, + (u8)writeVal); } } } diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_led.c b/drivers/staging/rtl8723au/hal/rtl8723au_led.c index 4c9318f4ac85..b946636af9b3 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723au_led.c +++ b/drivers/staging/rtl8723au/hal/rtl8723au_led.c @@ -43,16 +43,17 @@ void SwLedOn23a(struct rtw_adapter *padapter, struct led_8723a *pLed) break; case LED_PIN_LED0: /* SW control led0 on. */ - rtw_write8(padapter, REG_LEDCFG0, (LedCfg&0xf0)|BIT(5)|BIT(6)); + rtl8723au_write8(padapter, REG_LEDCFG0, + (LedCfg&0xf0)|BIT(5)|BIT(6)); break; case LED_PIN_LED1: /* SW control led1 on. */ - rtw_write8(padapter, REG_LEDCFG1, (LedCfg&0x00)|BIT(6)); + rtl8723au_write8(padapter, REG_LEDCFG1, (LedCfg&0x00)|BIT(6)); break; case LED_PIN_LED2: LedCfg = rtl8723au_read8(padapter, REG_LEDCFG2); /* SW control led1 on. */ - rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0x80)|BIT(5)); + rtl8723au_write8(padapter, REG_LEDCFG2, (LedCfg&0x80)|BIT(5)); break; default: break; @@ -75,16 +76,19 @@ void SwLedOff23a(struct rtw_adapter *padapter, struct led_8723a *pLed) break; case LED_PIN_LED0: /* SW control led0 on. */ - rtw_write8(padapter, REG_LEDCFG0, (LedCfg&0xf0)|BIT(5)|BIT(6)); + rtl8723au_write8(padapter, REG_LEDCFG0, + (LedCfg&0xf0)|BIT(5)|BIT(6)); break; case LED_PIN_LED1: /* SW control led1 on. */ - rtw_write8(padapter, REG_LEDCFG1, (LedCfg&0x00)|BIT(5)|BIT(6)); + rtl8723au_write8(padapter, REG_LEDCFG1, + (LedCfg&0x00)|BIT(5)|BIT(6)); break; case LED_PIN_LED2: LedCfg = rtl8723au_read8(padapter, REG_LEDCFG2); /* SW control led1 on. */ - rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0x80)|BIT(3)|BIT(5)); + rtl8723au_write8(padapter, REG_LEDCFG2, + (LedCfg&0x80)|BIT(3)|BIT(5)); break; default: break; diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 750f1ca4d515..95906d46d748 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -100,7 +100,7 @@ static int _InitPowerOn(struct rtw_adapter *padapter) /* RSV_CTRL 0x1C[7:0] = 0x00 unlock ISO/CLK/Power control register */ - rtw_write8(padapter, REG_RSV_CTRL, 0x0); + rtl8723au_write8(padapter, REG_RSV_CTRL, 0x0); /* HW Power on sequence */ if (!HalPwrSeqCmdParsing23a(padapter, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, @@ -109,7 +109,7 @@ static int _InitPowerOn(struct rtw_adapter *padapter) /* 0x04[19] = 1, suggest by Jackie 2011.05.09, reset 8051 */ value8 = rtl8723au_read8(padapter, REG_APS_FSMCO+2); - rtw_write8(padapter, REG_APS_FSMCO + 2, value8 | BIT(3)); + rtl8723au_write8(padapter, REG_APS_FSMCO + 2, value8 | BIT(3)); /* Enable MAC DMA/WMAC/SCHEDULE/SEC block */ /* Set CR bit10 to enable 32k calibration. Suggested by SD1 Gimmy. @@ -118,7 +118,7 @@ static int _InitPowerOn(struct rtw_adapter *padapter) value16 |= (HCI_TXDMA_EN | HCI_RXDMA_EN | TXDMA_EN | RXDMA_EN | PROTOCOL_EN | SCHEDULE_EN | MACTXEN | MACRXEN | ENSEC | CALTMR_EN); - rtw_write16(padapter, REG_CR, value16); + rtl8723au_write16(padapter, REG_CR, value16); /* for Efuse PG, suggest by Jackie 2011.11.23 */ PHY_SetBBReg(padapter, REG_EFUSE_CTRL, BIT(28)|BIT(29)|BIT(30), 0x06); @@ -133,10 +133,10 @@ static void _InitInterrupt(struct rtw_adapter *Adapter) /* HISR - turn all on */ value32 = 0xFFFFFFFF; - rtw_write32(Adapter, REG_HISR, value32); + rtl8723au_write32(Adapter, REG_HISR, value32); /* HIMR - turn all on */ - rtw_write32(Adapter, REG_HIMR, value32); + rtl8723au_write32(Adapter, REG_HIMR, value32); } static void _InitQueueReservedPage(struct rtw_adapter *Adapter) @@ -175,12 +175,12 @@ static void _InitQueueReservedPage(struct rtw_adapter *Adapter) WMM_NORMAL_PAGE_NUM_NPQ : NORMAL_PAGE_NUM_NPQ; } value8 = (u8)_NPQ(numNQ); - rtw_write8(Adapter, REG_RQPN_NPQ, value8); + rtl8723au_write8(Adapter, REG_RQPN_NPQ, value8); } /* TX DMA */ value32 = _HPQ(numHQ) | _LPQ(numLQ) | _PUBQ(numPubQ) | LD_RQPN; - rtw_write32(Adapter, REG_RQPN, value32); + rtl8723au_write32(Adapter, REG_RQPN, value32); } static void _InitTxBufferBoundary(struct rtw_adapter *Adapter) @@ -194,11 +194,11 @@ static void _InitTxBufferBoundary(struct rtw_adapter *Adapter) else /* for WMM */ txpktbuf_bndy = WMM_NORMAL_TX_PAGE_BOUNDARY; - rtw_write8(Adapter, REG_TXPKTBUF_BCNQ_BDNY, txpktbuf_bndy); - rtw_write8(Adapter, REG_TXPKTBUF_MGQ_BDNY, txpktbuf_bndy); - rtw_write8(Adapter, REG_TXPKTBUF_WMAC_LBK_BF_HD, txpktbuf_bndy); - rtw_write8(Adapter, REG_TRXFF_BNDY, txpktbuf_bndy); - rtw_write8(Adapter, REG_TDECTRL+1, txpktbuf_bndy); + rtl8723au_write8(Adapter, REG_TXPKTBUF_BCNQ_BDNY, txpktbuf_bndy); + rtl8723au_write8(Adapter, REG_TXPKTBUF_MGQ_BDNY, txpktbuf_bndy); + rtl8723au_write8(Adapter, REG_TXPKTBUF_WMAC_LBK_BF_HD, txpktbuf_bndy); + rtl8723au_write8(Adapter, REG_TRXFF_BNDY, txpktbuf_bndy); + rtl8723au_write8(Adapter, REG_TDECTRL+1, txpktbuf_bndy); } static void _InitPageBoundary(struct rtw_adapter *Adapter) @@ -207,7 +207,7 @@ static void _InitPageBoundary(struct rtw_adapter *Adapter) /* srand(static_cast(time(NULL))); */ u16 rxff_bndy = 0x27FF;/* rand() % 1) ? 0x27FF : 0x23FF; */ - rtw_write16(Adapter, (REG_TRXFF_BNDY + 2), rxff_bndy); + rtl8723au_write16(Adapter, (REG_TRXFF_BNDY + 2), rxff_bndy); /* TODO: ?? shall we set tx boundary? */ } @@ -222,7 +222,7 @@ _InitNormalChipRegPriority(struct rtw_adapter *Adapter, u16 beQ, u16 bkQ, _TXDMA_VIQ_MAP(viQ) | _TXDMA_VOQ_MAP(voQ) | _TXDMA_MGQ_MAP(mgtQ) | _TXDMA_HIQ_MAP(hiQ); - rtw_write16(Adapter, REG_TRXDMA_CTRL, value16); + rtl8723au_write16(Adapter, REG_TRXDMA_CTRL, value16); } static void _InitNormalChipOneOutEpPriority(struct rtw_adapter *Adapter) @@ -350,7 +350,7 @@ static void _InitNetworkType(struct rtw_adapter *Adapter) /* TODO: use the other function to set network type */ value32 = (value32 & ~MASK_NETTYPE) | _NETTYPE(NT_LINK_AP); - rtw_write32(Adapter, REG_CR, value32); + rtl8723au_write32(Adapter, REG_CR, value32); } static void _InitTransferPageSize(struct rtw_adapter *Adapter) @@ -359,12 +359,12 @@ static void _InitTransferPageSize(struct rtw_adapter *Adapter) u8 value8; value8 = _PSRX(PBP_128) | _PSTX(PBP_128); - rtw_write8(Adapter, REG_PBP, value8); + rtl8723au_write8(Adapter, REG_PBP, value8); } static void _InitDriverInfoSize(struct rtw_adapter *Adapter, u8 drvInfoSize) { - rtw_write8(Adapter, REG_RX_DRVINFO_SZ, drvInfoSize); + rtl8723au_write8(Adapter, REG_RX_DRVINFO_SZ, drvInfoSize); } static void _InitWMACSetting(struct rtw_adapter *Adapter) @@ -379,15 +379,15 @@ static void _InitWMACSetting(struct rtw_adapter *Adapter) /* some REG_RCR will be modified later by phy_ConfigMACWithHeaderFile() */ - rtw_write32(Adapter, REG_RCR, pHalData->ReceiveConfig); + rtl8723au_write32(Adapter, REG_RCR, pHalData->ReceiveConfig); /* Accept all multicast address */ - rtw_write32(Adapter, REG_MAR, 0xFFFFFFFF); - rtw_write32(Adapter, REG_MAR + 4, 0xFFFFFFFF); + rtl8723au_write32(Adapter, REG_MAR, 0xFFFFFFFF); + rtl8723au_write32(Adapter, REG_MAR + 4, 0xFFFFFFFF); /* Accept all data frames */ /* value16 = 0xFFFF; */ - /* rtw_write16(Adapter, REG_RXFLTMAP2, value16); */ + /* rtl8723au_write16(Adapter, REG_RXFLTMAP2, value16); */ /* 2010.09.08 hpfan */ /* Since ADF is removed from RCR, ps-poll will not be indicate @@ -395,14 +395,14 @@ static void _InitWMACSetting(struct rtw_adapter *Adapter) /* RxFilterMap should mask ps-poll to gurantee AP mode can rx ps-poll. */ /* value16 = 0x400; */ - /* rtw_write16(Adapter, REG_RXFLTMAP1, value16); */ + /* rtl8723au_write16(Adapter, REG_RXFLTMAP1, value16); */ /* Accept all management frames */ /* value16 = 0xFFFF; */ - /* rtw_write16(Adapter, REG_RXFLTMAP0, value16); */ + /* rtl8723au_write16(Adapter, REG_RXFLTMAP0, value16); */ /* enable RX_SHIFT bits */ - /* rtw_write8(Adapter, REG_TRXDMA_CTRL, rtl8723au_read8(Adapter, + /* rtl8723au_write8(Adapter, REG_TRXDMA_CTRL, rtl8723au_read8(Adapter, REG_TRXDMA_CTRL)|BIT(1)); */ } @@ -415,46 +415,46 @@ static void _InitAdaptiveCtrl(struct rtw_adapter *Adapter) value32 = rtl8723au_read32(Adapter, REG_RRSR); value32 &= ~RATE_BITMAP_ALL; value32 |= RATE_RRSR_CCK_ONLY_1M; - rtw_write32(Adapter, REG_RRSR, value32); + rtl8723au_write32(Adapter, REG_RRSR, value32); /* CF-END Threshold */ - /* m_spIoBase->rtw_write8(REG_CFEND_TH, 0x1); */ + /* m_spIoBase->rtl8723au_write8(REG_CFEND_TH, 0x1); */ /* SIFS (used in NAV) */ value16 = _SPEC_SIFS_CCK(0x10) | _SPEC_SIFS_OFDM(0x10); - rtw_write16(Adapter, REG_SPEC_SIFS, value16); + rtl8723au_write16(Adapter, REG_SPEC_SIFS, value16); /* Retry Limit */ value16 = _LRL(0x30) | _SRL(0x30); - rtw_write16(Adapter, REG_RL, value16); + rtl8723au_write16(Adapter, REG_RL, value16); } static void _InitRateFallback(struct rtw_adapter *Adapter) { /* Set Data Auto Rate Fallback Retry Count register. */ - rtw_write32(Adapter, REG_DARFRC, 0x00000000); - rtw_write32(Adapter, REG_DARFRC+4, 0x10080404); - rtw_write32(Adapter, REG_RARFRC, 0x04030201); - rtw_write32(Adapter, REG_RARFRC+4, 0x08070605); + rtl8723au_write32(Adapter, REG_DARFRC, 0x00000000); + rtl8723au_write32(Adapter, REG_DARFRC+4, 0x10080404); + rtl8723au_write32(Adapter, REG_RARFRC, 0x04030201); + rtl8723au_write32(Adapter, REG_RARFRC+4, 0x08070605); } static void _InitEDCA(struct rtw_adapter *Adapter) { /* Set Spec SIFS (used in NAV) */ - rtw_write16(Adapter, REG_SPEC_SIFS, 0x100a); - rtw_write16(Adapter, REG_MAC_SPEC_SIFS, 0x100a); + rtl8723au_write16(Adapter, REG_SPEC_SIFS, 0x100a); + rtl8723au_write16(Adapter, REG_MAC_SPEC_SIFS, 0x100a); /* Set SIFS for CCK */ - rtw_write16(Adapter, REG_SIFS_CTX, 0x100a); + rtl8723au_write16(Adapter, REG_SIFS_CTX, 0x100a); /* Set SIFS for OFDM */ - rtw_write16(Adapter, REG_SIFS_TRX, 0x100a); + rtl8723au_write16(Adapter, REG_SIFS_TRX, 0x100a); /* TXOP */ - rtw_write32(Adapter, REG_EDCA_BE_PARAM, 0x005EA42B); - rtw_write32(Adapter, REG_EDCA_BK_PARAM, 0x0000A44F); - rtw_write32(Adapter, REG_EDCA_VI_PARAM, 0x005EA324); - rtw_write32(Adapter, REG_EDCA_VO_PARAM, 0x002FA226); + rtl8723au_write32(Adapter, REG_EDCA_BE_PARAM, 0x005EA42B); + rtl8723au_write32(Adapter, REG_EDCA_BK_PARAM, 0x0000A44F); + rtl8723au_write32(Adapter, REG_EDCA_VI_PARAM, 0x005EA324); + rtl8723au_write32(Adapter, REG_EDCA_VO_PARAM, 0x002FA226); } static void _InitHWLed(struct rtw_adapter *Adapter) @@ -471,9 +471,9 @@ static void _InitHWLed(struct rtw_adapter *Adapter) static void _InitRDGSetting(struct rtw_adapter *Adapter) { - rtw_write8(Adapter, REG_RD_CTRL, 0xFF); - rtw_write16(Adapter, REG_RD_NAV_NXT, 0x200); - rtw_write8(Adapter, REG_RD_RESP_PKT_TH, 0x05); + rtl8723au_write8(Adapter, REG_RD_CTRL, 0xFF); + rtl8723au_write16(Adapter, REG_RD_NAV_NXT, 0x200); + rtl8723au_write8(Adapter, REG_RD_RESP_PKT_TH, 0x05); } static void _InitRetryFunction(struct rtw_adapter *Adapter) @@ -482,10 +482,10 @@ static void _InitRetryFunction(struct rtw_adapter *Adapter) value8 = rtl8723au_read8(Adapter, REG_FWHW_TXQ_CTRL); value8 |= EN_AMPDU_RTY_NEW; - rtw_write8(Adapter, REG_FWHW_TXQ_CTRL, value8); + rtl8723au_write8(Adapter, REG_FWHW_TXQ_CTRL, value8); /* Set ACK timeout */ - rtw_write8(Adapter, REG_ACKTO, 0x40); + rtl8723au_write8(Adapter, REG_ACKTO, 0x40); } /*----------------------------------------------------------------------------- @@ -593,9 +593,9 @@ enum rt_rf_power_state RfOnOffDetect23a(struct rtw_adapter *pAdapter) DBG_8723A("pwrdown, 0x5c(BIT7) =%02x\n", val8); rfpowerstate = (val8 & BIT(7)) ? rf_off : rf_on; } else { /* rf on/off */ - rtw_write8(pAdapter, REG_MAC_PINMUX_CFG, - rtl8723au_read8(pAdapter, REG_MAC_PINMUX_CFG) & - ~BIT(3)); + rtl8723au_write8(pAdapter, REG_MAC_PINMUX_CFG, + rtl8723au_read8(pAdapter, REG_MAC_PINMUX_CFG) & + ~BIT(3)); val8 = rtl8723au_read8(pAdapter, REG_GPIO_IO_SEL); DBG_8723A("GPIO_IN =%02x\n", val8); rfpowerstate = (val8 & BIT(3)) ? rf_on : rf_off; @@ -798,16 +798,16 @@ static int rtl8723au_hal_init(struct rtw_adapter *Adapter) /* HW SEQ CTRL */ /* set 0x0 to 0xFF by tynli. Default enable HW SEQ NUM. */ - rtw_write8(Adapter, REG_HWSEQ_CTRL, 0xFF); + rtl8723au_write8(Adapter, REG_HWSEQ_CTRL, 0xFF); /* */ /* Disable BAR, suggested by Scott */ /* 2010.04.09 add by hpfan */ /* */ - rtw_write32(Adapter, REG_BAR_MODE_CTRL, 0x0201ffff); + rtl8723au_write32(Adapter, REG_BAR_MODE_CTRL, 0x0201ffff); if (pregistrypriv->wifi_spec) - rtw_write16(Adapter, REG_FAST_EDCA_CTRL, 0); + rtl8723au_write16(Adapter, REG_FAST_EDCA_CTRL, 0); /* Move by Neo for USB SS from above setp */ _RfPowerSave(Adapter); @@ -838,31 +838,31 @@ static int rtl8723au_hal_init(struct rtw_adapter *Adapter) HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MISC21); /* fixed USB interface interference issue */ - rtw_write8(Adapter, 0xfe40, 0xe0); - rtw_write8(Adapter, 0xfe41, 0x8d); - rtw_write8(Adapter, 0xfe42, 0x80); - rtw_write32(Adapter, 0x20c, 0xfd0320); + rtl8723au_write8(Adapter, 0xfe40, 0xe0); + rtl8723au_write8(Adapter, 0xfe41, 0x8d); + rtl8723au_write8(Adapter, 0xfe42, 0x80); + rtl8723au_write32(Adapter, 0x20c, 0xfd0320); /* Solve too many protocol error on USB bus */ if (!IS_81xxC_VENDOR_UMC_A_CUT(pHalData->VersionID)) { /* 0xE6 = 0x94 */ - rtw_write8(Adapter, 0xFE40, 0xE6); - rtw_write8(Adapter, 0xFE41, 0x94); - rtw_write8(Adapter, 0xFE42, 0x80); + rtl8723au_write8(Adapter, 0xFE40, 0xE6); + rtl8723au_write8(Adapter, 0xFE41, 0x94); + rtl8723au_write8(Adapter, 0xFE42, 0x80); /* 0xE0 = 0x19 */ - rtw_write8(Adapter, 0xFE40, 0xE0); - rtw_write8(Adapter, 0xFE41, 0x19); - rtw_write8(Adapter, 0xFE42, 0x80); + rtl8723au_write8(Adapter, 0xFE40, 0xE0); + rtl8723au_write8(Adapter, 0xFE41, 0x19); + rtl8723au_write8(Adapter, 0xFE42, 0x80); /* 0xE5 = 0x91 */ - rtw_write8(Adapter, 0xFE40, 0xE5); - rtw_write8(Adapter, 0xFE41, 0x91); - rtw_write8(Adapter, 0xFE42, 0x80); + rtl8723au_write8(Adapter, 0xFE40, 0xE5); + rtl8723au_write8(Adapter, 0xFE41, 0x91); + rtl8723au_write8(Adapter, 0xFE42, 0x80); /* 0xE2 = 0x81 */ - rtw_write8(Adapter, 0xFE40, 0xE2); - rtw_write8(Adapter, 0xFE41, 0x81); - rtw_write8(Adapter, 0xFE42, 0x80); + rtl8723au_write8(Adapter, 0xFE40, 0xE2); + rtl8723au_write8(Adapter, 0xFE41, 0x81); + rtl8723au_write8(Adapter, 0xFE42, 0x80); } @@ -889,8 +889,8 @@ static int rtl8723au_hal_init(struct rtw_adapter *Adapter) } /* ack for xmit mgmt frames. */ - rtw_write32(Adapter, REG_FWHW_TXQ_CTRL, - rtl8723au_read32(Adapter, REG_FWHW_TXQ_CTRL)|BIT(12)); + rtl8723au_write32(Adapter, REG_FWHW_TXQ_CTRL, + rtl8723au_read32(Adapter, REG_FWHW_TXQ_CTRL)|BIT(12)); exit: HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_END); @@ -916,9 +916,9 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, ReadXBYTE(REG_SYS_CLKR+1) | BIT(3)); */ /* 2. Force PWM, Enable SPS18_LDO_Marco_Block */ - rtw_write8(Adapter, REG_SPS0_CTRL, - rtl8723au_read8(Adapter, REG_SPS0_CTRL) | - BIT(0) | BIT(3)); + rtl8723au_write8(Adapter, REG_SPS0_CTRL, + rtl8723au_read8(Adapter, REG_SPS0_CTRL) | + BIT(0) | BIT(3)); /* 3. restore BB, AFE control register. */ /* RF */ @@ -952,17 +952,17 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, } else { /* Level 2 or others. */ /* h. AFE_PLL_CTRL 0x28[7:0] = 0x80 disable AFE PLL */ - rtw_write8(Adapter, REG_AFE_PLL_CTRL, 0x81); + rtl8723au_write8(Adapter, REG_AFE_PLL_CTRL, 0x81); /* i. AFE_XTAL_CTRL 0x24[15:0] = 0x880F gated AFE DIG_CLOCK */ - rtw_write16(Adapter, REG_AFE_XTAL_CTRL, 0x800F); + rtl8723au_write16(Adapter, REG_AFE_XTAL_CTRL, 0x800F); mdelay(1); /* 2. Force PWM, Enable SPS18_LDO_Marco_Block */ - rtw_write8(Adapter, REG_SPS0_CTRL, - rtl8723au_read8(Adapter, REG_SPS0_CTRL) | - BIT(0) | BIT(3)); + rtl8723au_write8(Adapter, REG_SPS0_CTRL, + rtl8723au_read8(Adapter, REG_SPS0_CTRL) | + BIT(0) | BIT(3)); /* 3. restore BB, AFE control register. */ /* RF */ @@ -996,15 +996,17 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, /* 5. gated MAC Clock */ bytetmp = rtl8723au_read8(Adapter, REG_APSD_CTRL); - rtw_write8(Adapter, REG_APSD_CTRL, bytetmp & ~BIT(6)); + rtl8723au_write8(Adapter, REG_APSD_CTRL, + bytetmp & ~BIT(6)); mdelay(10); /* Set BB reset at first */ - rtw_write8(Adapter, REG_SYS_FUNC_EN, 0x17); /* 0x16 */ + /* 0x16 */ + rtl8723au_write8(Adapter, REG_SYS_FUNC_EN, 0x17); /* Enable TX */ - rtw_write8(Adapter, REG_TXPAUSE, 0x0); + rtl8723au_write8(Adapter, REG_TXPAUSE, 0x0); } break; case rf_sleep: @@ -1063,18 +1065,19 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, bRFRegOffsetMask, 0); /* 4. Force PFM , disable SPS18_LDO_Marco_Block */ - rtw_write8(Adapter, REG_SPS0_CTRL, value8); + rtl8723au_write8(Adapter, REG_SPS0_CTRL, value8); } else { /* Level 2 or others. */ RT_TRACE(_module_hal_init_c_, _drv_err_, ("SS LVL2\n")); { u8 eRFPath = RF_PATH_A, value8 = 0; - rtw_write8(Adapter, REG_TXPAUSE, 0xFF); + rtl8723au_write8(Adapter, REG_TXPAUSE, 0xFF); PHY_SetRFReg(Adapter, (enum RF_RADIO_PATH)eRFPath, 0x0, bMaskByte0, 0x0); value8 |= APSDOFF; /* 0x40 */ - rtw_write8(Adapter, REG_APSD_CTRL, value8); + rtl8723au_write8(Adapter, REG_APSD_CTRL, + value8); /* After switch APSD, we need to delay for stability */ @@ -1085,7 +1088,8 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, value8 |= (FEN_USBD | FEN_USBA | FEN_BB_GLB_RSTn); /* 0x16 */ - rtw_write8(Adapter, REG_SYS_FUNC_EN, value8); + rtl8723au_write8(Adapter, REG_SYS_FUNC_EN, + value8); } /* Disable RF and BB only for SelectSuspend. */ @@ -1134,17 +1138,17 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter, bRFRegOffsetMask, 0); /* 4. Force PFM , disable SPS18_LDO_Marco_Block */ - rtw_write8(Adapter, REG_SPS0_CTRL, value8); + rtl8723au_write8(Adapter, REG_SPS0_CTRL, value8); /* 2010/10/13 MH/Isaachsu exchange sequence. */ /* h. AFE_PLL_CTRL 0x28[7:0] = 0x80 disable AFE PLL */ - rtw_write8(Adapter, REG_AFE_PLL_CTRL, 0x80); + rtl8723au_write8(Adapter, REG_AFE_PLL_CTRL, 0x80); mdelay(1); /* i. AFE_XTAL_CTRL 0x24[15:0] = 0x880F gated AFE DIG_CLOCK */ - rtw_write16(Adapter, REG_AFE_XTAL_CTRL, 0xA80F); + rtl8723au_write16(Adapter, REG_AFE_XTAL_CTRL, 0xA80F); } break; default: @@ -1170,7 +1174,7 @@ static void CardDisableRTL8723U(struct rtw_adapter *Adapter) PWR_INTF_USB_MSK, rtl8723AU_enter_lps_flow); /* 2. 0x1F[7:0] = 0 turn off RF */ - rtw_write8(Adapter, REG_RF_CTRL, 0x00); + rtl8723au_write8(Adapter, REG_RF_CTRL, 0x00); /* ==== Reset digital sequence ====== */ if ((rtl8723au_read8(Adapter, REG_MCUFWDL) & BIT(7)) && @@ -1179,10 +1183,10 @@ static void CardDisableRTL8723U(struct rtw_adapter *Adapter) /* Reset MCU. Suggested by Filen. 2011.01.26. by tynli. */ u1bTmp = rtl8723au_read8(Adapter, REG_SYS_FUNC_EN+1); - rtw_write8(Adapter, REG_SYS_FUNC_EN+1, u1bTmp & ~BIT(2)); + rtl8723au_write8(Adapter, REG_SYS_FUNC_EN+1, u1bTmp & ~BIT(2)); /* g. MCUFWDL 0x80[1:0]= 0 reset MCU ready status */ - rtw_write8(Adapter, REG_MCUFWDL, 0x00); + rtl8723au_write8(Adapter, REG_MCUFWDL, 0x00); /* ==== Reset digital sequence end ====== */ /* Card disable power action flow */ @@ -1192,12 +1196,12 @@ static void CardDisableRTL8723U(struct rtw_adapter *Adapter) /* Reset MCU IO Wrapper, added by Roger, 2011.08.30. */ u1bTmp = rtl8723au_read8(Adapter, REG_RSV_CTRL + 1); - rtw_write8(Adapter, REG_RSV_CTRL+1, u1bTmp & ~BIT(0)); + rtl8723au_write8(Adapter, REG_RSV_CTRL+1, u1bTmp & ~BIT(0)); u1bTmp = rtl8723au_read8(Adapter, REG_RSV_CTRL + 1); - rtw_write8(Adapter, REG_RSV_CTRL+1, u1bTmp | BIT(0)); + rtl8723au_write8(Adapter, REG_RSV_CTRL+1, u1bTmp | BIT(0)); /* 7. RSV_CTRL 0x1C[7:0] = 0x0E lock ISO/CLK/Power control register */ - rtw_write8(Adapter, REG_RSV_CTRL, 0x0e); + rtl8723au_write8(Adapter, REG_RSV_CTRL, 0x0e); } static int rtl8723au_hal_deinit(struct rtw_adapter *padapter) @@ -1248,7 +1252,7 @@ int rtl8723au_inirp_init(struct rtw_adapter *Adapter) pHalData->IntrMask[0] = rtl8723au_read32(Adapter, REG_USB_HIMR); MSG_8723A("pHalData->IntrMask = 0x%04x\n", pHalData->IntrMask[0]); pHalData->IntrMask[0] |= UHIMR_C2HCMD|UHIMR_CPWM; - rtw_write32(Adapter, REG_USB_HIMR, pHalData->IntrMask[0]); + rtl8723au_write32(Adapter, REG_USB_HIMR, pHalData->IntrMask[0]); exit: RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("<=== usb_inirp_init\n")); @@ -1266,7 +1270,7 @@ int rtl8723au_inirp_deinit(struct rtw_adapter *Adapter) MSG_8723A("%s pHalData->IntrMask = 0x%04x\n", __func__, pHalData->IntrMask[0]); pHalData->IntrMask[0] = 0x0; - rtw_write32(Adapter, REG_USB_HIMR, pHalData->IntrMask[0]); + rtl8723au_write32(Adapter, REG_USB_HIMR, pHalData->IntrMask[0]); RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("\n <=== usb_rx_deinit\n")); return _SUCCESS; @@ -1444,7 +1448,7 @@ static void hal_EfuseCellSel(struct rtw_adapter *Adapter) value32 = rtl8723au_read32(Adapter, EFUSE_TEST); value32 = (value32 & ~EFUSE_SEL_MASK) | EFUSE_SEL(EFUSE_WIFI_SEL_0); - rtw_write32(Adapter, EFUSE_TEST, value32); + rtl8723au_write32(Adapter, EFUSE_TEST, value32); } void rtl8723a_read_adapter_info(struct rtw_adapter *Adapter) @@ -1628,7 +1632,8 @@ void rtl8723a_update_ramask(struct rtw_adapter *padapter, if (shortGIrate == true) init_rate |= BIT(6); - rtw_write8(padapter, (REG_INIDATA_RATE_SEL+mac_id), init_rate); + rtl8723au_write8(padapter, (REG_INIDATA_RATE_SEL+mac_id), + init_rate); } /* set ra_id */ diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index d5e74e97a872..52792e027a4f 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -198,7 +198,7 @@ u32 rtl8723au_read32(struct rtw_adapter *padapter, u32 addr) return le32_to_cpu(data); } -static int usb_write8(struct rtw_adapter *padapter, u32 addr, u8 val) +int rtl8723au_write8(struct rtw_adapter *padapter, u32 addr, u8 val) { u8 request; u8 requesttype; @@ -223,7 +223,7 @@ static int usb_write8(struct rtw_adapter *padapter, u32 addr, u8 val) return ret; } -static int usb_write16(struct rtw_adapter *padapter, u32 addr, u16 val) +int rtl8723au_write16(struct rtw_adapter *padapter, u32 addr, u16 val) { u8 request; u8 requesttype; @@ -247,7 +247,7 @@ static int usb_write16(struct rtw_adapter *padapter, u32 addr, u16 val) return ret; } -static int usb_write32(struct rtw_adapter *padapter, u32 addr, u32 val) +int rtl8723au_write32(struct rtw_adapter *padapter, u32 addr, u32 val) { u8 request; u8 requesttype; @@ -271,8 +271,8 @@ static int usb_write32(struct rtw_adapter *padapter, u32 addr, u32 val) return ret; } -static int usb_writeN(struct rtw_adapter *padapter, - u32 addr, u32 length, u8 *pdata) +int rtl8723au_writeN(struct rtw_adapter *padapter, + u32 addr, u32 length, u8 *pdata) { u8 request; u8 requesttype; @@ -833,18 +833,6 @@ void rtl8723au_xmit_tasklet(void *priv) } } -void rtl8723au_set_intf_ops(struct rtw_adapter *padapter) -{ - struct _io_ops *pops = &padapter->io_ops; - - memset((u8 *)pops, 0, sizeof(struct _io_ops)); - - pops->_write8 = &usb_write8; - pops->_write16 = &usb_write16; - pops->_write32 = &usb_write32; - pops->_writeN = &usb_writeN; -} - void rtl8723au_set_hw_type(struct rtw_adapter *padapter) { padapter->chip_type = RTL8723A; diff --git a/drivers/staging/rtl8723au/include/drv_types.h b/drivers/staging/rtl8723au/include/drv_types.h index 6724c58b1ed6..c3d633c4ec1e 100644 --- a/drivers/staging/rtl8723au/include/drv_types.h +++ b/drivers/staging/rtl8723au/include/drv_types.h @@ -220,7 +220,6 @@ struct rtw_adapter { struct mlme_ext_priv mlmeextpriv; struct cmd_priv cmdpriv; struct evt_priv evtpriv; - struct _io_ops io_ops; struct xmit_priv xmitpriv; struct recv_priv recvpriv; struct sta_priv stapriv; diff --git a/drivers/staging/rtl8723au/include/rtw_io.h b/drivers/staging/rtl8723au/include/rtw_io.h index b9263dadc50f..0938e4a8df44 100644 --- a/drivers/staging/rtl8723au/include/rtw_io.h +++ b/drivers/staging/rtl8723au/include/rtw_io.h @@ -98,15 +98,6 @@ struct intf_priv; -struct _io_ops -{ - int (*_write8)(struct rtw_adapter *adapter, u32 addr, u8 val); - int (*_write16)(struct rtw_adapter *adapter, u32 addr, u16 val); - int (*_write32)(struct rtw_adapter *adapter, u32 addr, u32 val); - int (*_writeN)(struct rtw_adapter *adapter, u32 addr, u32 length, - u8 *pdata); -}; - struct io_req { struct list_head list; u32 addr; @@ -238,39 +229,19 @@ void _rtw_attrib_write(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem) void _rtw_read_port23a_cancel(struct rtw_adapter *adapter); -int _rtw_write823a(struct rtw_adapter *adapter, u32 addr, u8 val); -int _rtw_write1623a(struct rtw_adapter *adapter, u32 addr, u16 val); -int _rtw_write3223a(struct rtw_adapter *adapter, u32 addr, u32 val); -int _rtw_writeN23a(struct rtw_adapter *adapter, u32 addr, u32 length, u8 *pdata); - void _rtw_write_port23a_cancel(struct rtw_adapter *adapter); #ifdef DBG_IO bool match_read_sniff_ranges(u16 addr, u16 len); bool match_write_sniff_ranges(u16 addr, u16 len); - -int dbg_rtw_write823a(struct rtw_adapter *adapter, u32 addr, u8 val, const char *caller, const int line); -int dbg_rtw_write1623a(struct rtw_adapter *adapter, u32 addr, u16 val, const char *caller, const int line); -int dbg_rtw_write3223a(struct rtw_adapter *adapter, u32 addr, u32 val, const char *caller, const int line); -int dbg_rtw_writeN23a(struct rtw_adapter *adapter, u32 addr ,u32 length , u8 *data, const char *caller, const int line); - -#define rtw_write8(adapter, addr, val) dbg_rtw_write823a((adapter), (addr), (val), __FUNCTION__, __LINE__) -#define rtw_write16(adapter, addr, val) dbg_rtw_write1623a((adapter), (addr), (val), __FUNCTION__, __LINE__) -#define rtw_write32(adapter, addr, val) dbg_rtw_write3223a((adapter), (addr), (val), __FUNCTION__, __LINE__) -#define rtw_writeN(adapter, addr, length, data) dbg_rtw_writeN23a((adapter), (addr), (length), (data), __FUNCTION__, __LINE__) -#else /* DBG_IO */ -#define rtw_write8(adapter, addr, val) _rtw_write823a((adapter), (addr), (val)) -#define rtw_write16(adapter, addr, val) _rtw_write1623a((adapter), (addr), (val)) -#define rtw_write32(adapter, addr, val) _rtw_write3223a((adapter), (addr), (val)) -#define rtw_writeN(adapter, addr, length, data) _rtw_writeN23a((adapter), (addr), (length), (data)) #endif /* DBG_IO */ #define PlatformEFIOWrite1Byte(_a,_b,_c) \ - rtw_write8(_a,_b,_c) + rtl8723au_write8(_a,_b,_c) #define PlatformEFIOWrite2Byte(_a,_b,_c) \ - rtw_write16(_a,_b,_c) + rtl8723au_write16(_a,_b,_c) #define PlatformEFIOWrite4Byte(_a,_b,_c) \ - rtw_write32(_a,_b,_c) + rtl8723au_write32(_a,_b,_c) #define PlatformEFIORead1Byte(_a,_b) rtl8723au_read8(_a,_b) #define PlatformEFIORead2Byte(_a,_b) rtl8723au_read16(_a,_b) diff --git a/drivers/staging/rtl8723au/include/usb_ops.h b/drivers/staging/rtl8723au/include/usb_ops.h index 977805d97b34..ade8bc71572a 100644 --- a/drivers/staging/rtl8723au/include/usb_ops.h +++ b/drivers/staging/rtl8723au/include/usb_ops.h @@ -36,8 +36,6 @@ enum { void rtl8723au_set_hw_type(struct rtw_adapter *padapter); -void rtl8723au_set_intf_ops(struct rtw_adapter *padapter); - void rtl8723au_recv_tasklet(void *priv); void rtl8723au_xmit_tasklet(void *priv); diff --git a/drivers/staging/rtl8723au/include/usb_ops_linux.h b/drivers/staging/rtl8723au/include/usb_ops_linux.h index 29509544ab6f..4b5b10ca1e47 100644 --- a/drivers/staging/rtl8723au/include/usb_ops_linux.h +++ b/drivers/staging/rtl8723au/include/usb_ops_linux.h @@ -32,5 +32,10 @@ int rtl8723a_usb_read_interrupt(struct rtw_adapter *adapter, u32 addr); u8 rtl8723au_read8(struct rtw_adapter *padapter, u32 addr); u16 rtl8723au_read16(struct rtw_adapter *padapter, u32 addr); u32 rtl8723au_read32(struct rtw_adapter *padapter, u32 addr); +int rtl8723au_write8(struct rtw_adapter *padapter, u32 addr, u8 val); +int rtl8723au_write16(struct rtw_adapter *padapter, u32 addr, u16 val); +int rtl8723au_write32(struct rtw_adapter *padapter, u32 addr, u32 val); +int rtl8723au_writeN(struct rtw_adapter *padapter, + u32 addr, u32 length, u8 *pdata); #endif diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index 34522d290048..cc5188bf49fb 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -601,8 +601,6 @@ static struct rtw_adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, if (!padapter->HalData) goto free_wdev; - rtl8723au_set_intf_ops(padapter); - /* step read_chip_version */ rtl8723a_read_chip_version(padapter); -- cgit v1.2.3 From 68552a904c86e3e49d53305933371a1225d8aaf2 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:05:10 +0200 Subject: staging: rtl8723au: Name port vs register access functions consistently Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723au_xmit.c | 4 ++-- drivers/staging/rtl8723au/hal/usb_halinit.c | 8 ++++---- drivers/staging/rtl8723au/hal/usb_ops_linux.c | 18 +++++++++--------- drivers/staging/rtl8723au/include/usb_ops_linux.h | 14 +++++++------- drivers/staging/rtl8723au/os_dep/usb_intf.c | 2 +- drivers/staging/rtl8723au/os_dep/usb_ops_linux.c | 8 ++++---- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c b/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c index 45bd67e88e0e..d2caafa6b026 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c +++ b/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c @@ -345,8 +345,8 @@ static int rtw_dump_xframe(struct rtw_adapter *padapter, } ff_hwaddr = rtw_get_ff_hwaddr23a(pxmitframe); - inner_ret = rtl8723a_usb_write_port(padapter, ff_hwaddr, - w_sz, pxmitbuf); + inner_ret = rtl8723au_write_port(padapter, ff_hwaddr, + w_sz, pxmitbuf); rtw_count_tx_stats23a(padapter, pxmitframe, sz); RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 95906d46d748..e0d2d6e205c3 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1235,8 +1235,8 @@ int rtl8723au_inirp_init(struct rtw_adapter *Adapter) /* issue Rx irp to receive data */ precvbuf = (struct recv_buf *)precvpriv->precv_buf; for (i = 0; i < NR_RECVBUFF; i++) { - if (rtl8723a_usb_read_port(Adapter, RECV_BULK_IN_ADDR, 0, - precvbuf) == _FAIL) { + if (rtl8723au_read_port(Adapter, RECV_BULK_IN_ADDR, 0, + precvbuf) == _FAIL) { RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("usb_rx_init: usb_read_port error\n")); status = _FAIL; @@ -1244,7 +1244,7 @@ int rtl8723au_inirp_init(struct rtw_adapter *Adapter) } precvbuf++; } - if (rtl8723a_usb_read_interrupt(Adapter, RECV_INT_IN_ADDR) == _FAIL) { + if (rtl8723au_read_interrupt(Adapter, RECV_INT_IN_ADDR) == _FAIL) { RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("usb_rx_init: usb_read_interrupt error\n")); status = _FAIL; @@ -1265,7 +1265,7 @@ int rtl8723au_inirp_deinit(struct rtw_adapter *Adapter) RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("\n ===> usb_rx_deinit\n")); - rtl8723a_usb_read_port_cancel(Adapter); + rtl8723au_read_port_cancel(Adapter); pHalData->IntrMask[0] = rtl8723au_read32(Adapter, REG_USB_HIMR); MSG_8723A("%s pHalData->IntrMask = 0x%04x\n", __func__, pHalData->IntrMask[0]); diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index 52792e027a4f..73b49aca95e1 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -447,7 +447,7 @@ urb_submit: } } -int rtl8723a_usb_read_interrupt(struct rtw_adapter *adapter, u32 addr) +int rtl8723au_read_interrupt(struct rtw_adapter *adapter, u32 addr) { int err; unsigned int pipe; @@ -676,8 +676,8 @@ static void usb_read_port_complete(struct urb *purb) ("usb_read_port_complete: (purb->actual_" "length > MAX_RECVBUF_SZ) || (purb->actual_" "length < RXDESC_SIZE)\n")); - rtl8723a_usb_read_port(padapter, RECV_BULK_IN_ADDR, 0, - precvbuf); + rtl8723au_read_port(padapter, RECV_BULK_IN_ADDR, 0, + precvbuf); DBG_8723A("%s()-%d: RX Warning!\n", __FUNCTION__, __LINE__); } else { @@ -692,8 +692,8 @@ static void usb_read_port_complete(struct urb *purb) tasklet_schedule(&precvpriv->recv_tasklet); precvbuf->pskb = NULL; - rtl8723a_usb_read_port(padapter, RECV_BULK_IN_ADDR, 0, - precvbuf); + rtl8723au_read_port(padapter, RECV_BULK_IN_ADDR, 0, + precvbuf); } } else { RT_TRACE(_module_hci_ops_os_c_, _drv_err_, @@ -730,8 +730,8 @@ static void usb_read_port_complete(struct urb *purb) pHalData = GET_HAL_DATA(padapter); pHalData->srestpriv.Wifi_Error_Status = USB_READ_PORT_FAIL; - rtl8723a_usb_read_port(padapter, RECV_BULK_IN_ADDR, 0, - precvbuf); + rtl8723au_read_port(padapter, RECV_BULK_IN_ADDR, 0, + precvbuf); break; case -EINPROGRESS: DBG_8723A("ERROR: URB IS IN PROGRESS!/n"); @@ -742,8 +742,8 @@ static void usb_read_port_complete(struct urb *purb) } } -int rtl8723a_usb_read_port(struct rtw_adapter *adapter, u32 addr, u32 cnt, - struct recv_buf *precvbuf) +int rtl8723au_read_port(struct rtw_adapter *adapter, u32 addr, u32 cnt, + struct recv_buf *precvbuf) { int err; unsigned int pipe; diff --git a/drivers/staging/rtl8723au/include/usb_ops_linux.h b/drivers/staging/rtl8723au/include/usb_ops_linux.h index 4b5b10ca1e47..e540a4bad087 100644 --- a/drivers/staging/rtl8723au/include/usb_ops_linux.h +++ b/drivers/staging/rtl8723au/include/usb_ops_linux.h @@ -21,13 +21,13 @@ #define MAX_USBCTRL_VENDORREQ_TIMES 10 -int rtl8723a_usb_read_port(struct rtw_adapter *adapter, u32 addr, u32 cnt, - struct recv_buf *precvbuf); -void rtl8723a_usb_read_port_cancel(struct rtw_adapter *padapter); -int rtl8723a_usb_write_port(struct rtw_adapter *padapter, u32 addr, u32 cnt, - struct xmit_buf *pxmitbuf); -void rtl8723a_usb_write_port_cancel(struct rtw_adapter *padapter); -int rtl8723a_usb_read_interrupt(struct rtw_adapter *adapter, u32 addr); +int rtl8723au_read_port(struct rtw_adapter *adapter, u32 addr, u32 cnt, + struct recv_buf *precvbuf); +void rtl8723au_read_port_cancel(struct rtw_adapter *padapter); +int rtl8723au_write_port(struct rtw_adapter *padapter, u32 addr, u32 cnt, + struct xmit_buf *pxmitbuf); +void rtl8723au_write_port_cancel(struct rtw_adapter *padapter); +int rtl8723au_read_interrupt(struct rtw_adapter *adapter, u32 addr); u8 rtl8723au_read8(struct rtw_adapter *padapter, u32 addr); u16 rtl8723au_read16(struct rtw_adapter *padapter, u32 addr); diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index cc5188bf49fb..d00ccdcaacc5 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -292,7 +292,7 @@ void rtl8723a_usb_intf_stop(struct rtw_adapter *padapter) rtl8723au_inirp_deinit(padapter); /* cancel out irp */ - rtl8723a_usb_write_port_cancel(padapter); + rtl8723au_write_port_cancel(padapter); /* todo:cancel other irps */ RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-usb_intf_stop\n")); diff --git a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c index a41d824ab325..d081449318c2 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/os_dep/usb_ops_linux.c @@ -25,7 +25,7 @@ struct zero_bulkout_context { void *padapter; }; -void rtl8723a_usb_read_port_cancel(struct rtw_adapter *padapter) +void rtl8723au_read_port_cancel(struct rtw_adapter *padapter) { struct recv_buf *precvbuf; int i; @@ -140,8 +140,8 @@ check_completion: tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); } -int rtl8723a_usb_write_port(struct rtw_adapter *padapter, u32 addr, u32 cnt, - struct xmit_buf *pxmitbuf) +int rtl8723au_write_port(struct rtw_adapter *padapter, u32 addr, u32 cnt, + struct xmit_buf *pxmitbuf) { struct urb *purb = NULL; struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter); @@ -237,7 +237,7 @@ exit: return ret; } -void rtl8723a_usb_write_port_cancel(struct rtw_adapter *padapter) +void rtl8723au_write_port_cancel(struct rtw_adapter *padapter) { struct xmit_buf *pxmitbuf; struct list_head *plist; -- cgit v1.2.3 From a5daa10c385adaccc81c23c5ad5686c495cf3bba Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:05:11 +0200 Subject: staging: rtl8723au: Remove some leftover obsolete prototypes Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtw_io.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/rtl8723au/include/rtw_io.h b/drivers/staging/rtl8723au/include/rtw_io.h index 0938e4a8df44..0bd03718fe7d 100644 --- a/drivers/staging/rtl8723au/include/rtw_io.h +++ b/drivers/staging/rtl8723au/include/rtw_io.h @@ -224,13 +224,6 @@ struct reg_protocol_wt { }; -void _rtw_attrib_read(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem); -void _rtw_attrib_write(struct rtw_adapter *adapter, u32 addr, u32 cnt, u8 *pmem); - -void _rtw_read_port23a_cancel(struct rtw_adapter *adapter); - -void _rtw_write_port23a_cancel(struct rtw_adapter *adapter); - #ifdef DBG_IO bool match_read_sniff_ranges(u16 addr, u16 len); bool match_write_sniff_ranges(u16 addr, u16 len); -- cgit v1.2.3 From a74aef217097b05aecbceed456d30e5dcd20e0c9 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:05:12 +0200 Subject: staging: rtl8723au: The DBG_IO code is all gone Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtw_io.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8723au/include/rtw_io.h b/drivers/staging/rtl8723au/include/rtw_io.h index 0bd03718fe7d..cc151b08d312 100644 --- a/drivers/staging/rtl8723au/include/rtw_io.h +++ b/drivers/staging/rtl8723au/include/rtw_io.h @@ -223,12 +223,6 @@ struct reg_protocol_wt { }; - -#ifdef DBG_IO -bool match_read_sniff_ranges(u16 addr, u16 len); -bool match_write_sniff_ranges(u16 addr, u16 len); -#endif /* DBG_IO */ - #define PlatformEFIOWrite1Byte(_a,_b,_c) \ rtl8723au_write8(_a,_b,_c) #define PlatformEFIOWrite2Byte(_a,_b,_c) \ -- cgit v1.2.3 From 13b2beb3420af1d6ca60cb018e36793a03fe6d4e Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:05:13 +0200 Subject: staging: rtl8723au: Remove some unused ODM dynamic TX power functionality Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/odm.c | 82 ++----------------------- drivers/staging/rtl8723au/include/rtl8723a_dm.h | 2 - 2 files changed, 4 insertions(+), 80 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/odm.c b/drivers/staging/rtl8723au/hal/odm.c index b709f7bf3a9f..05ddd724e1be 100644 --- a/drivers/staging/rtl8723au/hal/odm.c +++ b/drivers/staging/rtl8723au/hal/odm.c @@ -200,17 +200,6 @@ void odm_RefreshRateAdaptiveMask23aAPADSL23a(struct dm_odm_t *pDM_Odm); void odm_DynamicTxPower23aInit(struct dm_odm_t *pDM_Odm); -void odm_DynamicTxPower23aRestorePowerIndex(struct dm_odm_t *pDM_Odm); - -void odm_DynamicTxPower23aSavePowerIndex(struct dm_odm_t *pDM_Odm); - -void odm_DynamicTxPower23aWritePowerIndex(struct dm_odm_t *pDM_Odm, - u8 Value); - -void odm_DynamicTxPower23a_92C(struct dm_odm_t *pDM_Odm); - -void odm_DynamicTxPower23a_92D(struct dm_odm_t *pDM_Odm); - void odm_RSSIMonitorInit(struct dm_odm_t *pDM_Odm); void odm_RSSIMonitorCheck23aMP(struct dm_odm_t *pDM_Odm); @@ -233,8 +222,6 @@ void odm_SwAntDivChkAntSwitchNIC(struct dm_odm_t *pDM_Odm, void odm_SwAntDivChkAntSwitchCallback23a(unsigned long data); -void odm_GlobalAdapterCheck(void); - void odm_RefreshRateAdaptiveMask23a(struct dm_odm_t *pDM_Odm); void ODM_TXPowerTrackingCheck23a(struct dm_odm_t *pDM_Odm); @@ -307,7 +294,6 @@ void ODM23a_DMInit(struct dm_odm_t *pDM_Odm) void ODM_DMWatchdog23a(struct dm_odm_t *pDM_Odm) { /* 2012.05.03 Luke: For all IC series */ - odm_GlobalAdapterCheck(); odm_CmnInfoHook_Debug23a(pDM_Odm); odm_CmnInfoUpdate_Debug23a(pDM_Odm); odm_CommonInfoSelfUpdate23a(pDM_Odm); @@ -344,7 +330,6 @@ void ODM_DMWatchdog23a(struct dm_odm_t *pDM_Odm) if (pDM_Odm->SupportICType & ODM_IC_11N_SERIES) { ODM_TXPowerTrackingCheck23a(pDM_Odm); odm_EdcaTurboCheck23a(pDM_Odm); - odm_DynamicTxPower23a(pDM_Odm); } odm_dtc(pDM_Odm); @@ -1430,62 +1415,13 @@ void odm_DynamicTxPower23aInit(struct dm_odm_t *pDM_Odm) struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); struct dm_priv *pdmpriv = &pHalData->dmpriv; - pdmpriv->bDynamicTxPowerEnable = false; - - pdmpriv->LastDTPLvl = TxHighPwrLevel_Normal; + /* + * This is never changed, so we should be able to clean up the + * code checking for different values in rtl8723a_rf6052.c + */ pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal; } -void odm_DynamicTxPower23aSavePowerIndex(struct dm_odm_t *pDM_Odm) -{ - u8 index; - u32 Power_Index_REG[6] = {0xc90, 0xc91, 0xc92, 0xc98, 0xc99, 0xc9a}; - - struct rtw_adapter *Adapter = pDM_Odm->Adapter; - struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); - struct dm_priv *pdmpriv = &pHalData->dmpriv; - for (index = 0; index < 6; index++) - pdmpriv->PowerIndex_backup[index] = - rtl8723au_read8(Adapter, Power_Index_REG[index]); -} - -void odm_DynamicTxPower23aRestorePowerIndex(struct dm_odm_t *pDM_Odm) -{ - u8 index; - struct rtw_adapter *Adapter = pDM_Odm->Adapter; - - struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); - u32 Power_Index_REG[6] = {0xc90, 0xc91, 0xc92, 0xc98, 0xc99, 0xc9a}; - struct dm_priv *pdmpriv = &pHalData->dmpriv; - for (index = 0; index < 6; index++) - rtl8723au_write8(Adapter, Power_Index_REG[index], - pdmpriv->PowerIndex_backup[index]); -} - -void odm_DynamicTxPower23aWritePowerIndex(struct dm_odm_t *pDM_Odm, - u8 Value) -{ - - u8 index; - u32 Power_Index_REG[6] = {0xc90, 0xc91, 0xc92, 0xc98, 0xc99, 0xc9a}; - - for (index = 0; index < 6; index++) - ODM_Write1Byte(pDM_Odm, Power_Index_REG[index], Value); - -} - -void odm_DynamicTxPower23a(struct dm_odm_t *pDM_Odm) -{ -} - -void odm_DynamicTxPower23a_92C(struct dm_odm_t *pDM_Odm) -{ -} - -void odm_DynamicTxPower23a_92D(struct dm_odm_t *pDM_Odm) -{ -} - /* 3 ============================================================ */ /* 3 RSSI Monitor */ /* 3 ============================================================ */ @@ -1839,16 +1775,6 @@ ConvertTo_dB23a( return dB; } -/* */ -/* 2011/09/22 MH Add for 92D global spin lock utilization. */ -/* */ -void -odm_GlobalAdapterCheck( - void - ) -{ -} /* odm_GlobalAdapterCheck */ - /* */ /* Description: */ /*Set Single/Dual Antenna default setting for products that do not do detection in advance. */ diff --git a/drivers/staging/rtl8723au/include/rtl8723a_dm.h b/drivers/staging/rtl8723au/include/rtl8723a_dm.h index 47e887f5bb26..ccac672c9c04 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_dm.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_dm.h @@ -59,8 +59,6 @@ struct dm_priv #endif /* for High Power */ - u8 bDynamicTxPowerEnable; - u8 LastDTPLvl; u8 DynamicTxHighPowerLvl;/* Add by Jacken Tx Power Control for Near/Far Range 2008/03/06 */ /* for tx power tracking */ -- cgit v1.2.3 From d0a3956fefcb8aec21845a8ae8b927415a3edf41 Mon Sep 17 00:00:00 2001 From: Michalis Pappas Date: Fri, 9 May 2014 18:08:20 +0800 Subject: staging: gdm72xx: Remove unnecessary extern declarations from header files Fixes the following checkpatch.pl issue: CHECK: extern prototypes should be avoided in .h files Signed-off-by: Michalis Pappas Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm72xx/gdm_wimax.h | 6 +++--- drivers/staging/gdm72xx/sdio_boot.h | 2 +- drivers/staging/gdm72xx/usb_boot.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/gdm72xx/gdm_wimax.h b/drivers/staging/gdm72xx/gdm_wimax.h index 1fcfc8555417..3013bdbff8fd 100644 --- a/drivers/staging/gdm72xx/gdm_wimax.h +++ b/drivers/staging/gdm72xx/gdm_wimax.h @@ -64,8 +64,8 @@ struct nic { /*#define LOOPBACK_TEST */ -extern int register_wimax_device(struct phy_dev *phy_dev, struct device *pdev); -extern int gdm_wimax_send_tx(struct sk_buff *skb, struct net_device *dev); -extern void unregister_wimax_device(struct phy_dev *phy_dev); +int register_wimax_device(struct phy_dev *phy_dev, struct device *pdev); +int gdm_wimax_send_tx(struct sk_buff *skb, struct net_device *dev); +void unregister_wimax_device(struct phy_dev *phy_dev); #endif diff --git a/drivers/staging/gdm72xx/sdio_boot.h b/drivers/staging/gdm72xx/sdio_boot.h index 373ac28063c6..045c1f450539 100644 --- a/drivers/staging/gdm72xx/sdio_boot.h +++ b/drivers/staging/gdm72xx/sdio_boot.h @@ -16,6 +16,6 @@ struct sdio_func; -extern int sdio_boot(struct sdio_func *func); +int sdio_boot(struct sdio_func *func); #endif /* __SDIO_BOOT_H__ */ diff --git a/drivers/staging/gdm72xx/usb_boot.h b/drivers/staging/gdm72xx/usb_boot.h index c715cd3cd300..05308e253050 100644 --- a/drivers/staging/gdm72xx/usb_boot.h +++ b/drivers/staging/gdm72xx/usb_boot.h @@ -16,7 +16,7 @@ struct usb_device; -extern int usb_boot(struct usb_device *usbdev, u16 pid); -extern int usb_emergency(struct usb_device *usbdev); +int usb_boot(struct usb_device *usbdev, u16 pid); +int usb_emergency(struct usb_device *usbdev); #endif /* __USB_BOOT_H__ */ -- cgit v1.2.3 From 917ab47f5a25d636a88a06cdc0ca0432a59b6968 Mon Sep 17 00:00:00 2001 From: Michalis Pappas Date: Fri, 9 May 2014 18:08:21 +0800 Subject: staging: gdm72xx: Replace comparisons on jiffies values with wrap-safe functions Fixes the following checkpatch.pl issue: WARNING: Comparing jiffies is almost always wrong; prefer time_after, time_before and friends Signed-off-by: Michalis Pappas Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm72xx/gdm_usb.c | 2 +- drivers/staging/gdm72xx/sdio_boot.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/gdm72xx/gdm_usb.c b/drivers/staging/gdm72xx/gdm_usb.c index 20539d809397..9ddf8f58d87b 100644 --- a/drivers/staging/gdm72xx/gdm_usb.c +++ b/drivers/staging/gdm72xx/gdm_usb.c @@ -730,7 +730,7 @@ static int k_mode_thread(void *arg) spin_unlock_irqrestore(&k_lock, flags2); expire = jiffies + K_WAIT_TIME; - while (jiffies < expire) + while (time_before(jiffies, expire)) schedule_timeout(K_WAIT_TIME); spin_lock_irqsave(&rx->lock, flags); diff --git a/drivers/staging/gdm72xx/sdio_boot.c b/drivers/staging/gdm72xx/sdio_boot.c index cbe5dcfc2ac9..2c02842ac5da 100644 --- a/drivers/staging/gdm72xx/sdio_boot.c +++ b/drivers/staging/gdm72xx/sdio_boot.c @@ -41,11 +41,11 @@ static u8 *tx_buf; static int ack_ready(struct sdio_func *func) { - unsigned long start = jiffies; + unsigned long wait = jiffies + HZ; u8 val; int ret; - while ((jiffies - start) < HZ) { + while (time_before(jiffies, wait)) { val = sdio_readb(func, 0x13, &ret); if (val & 0x01) return 1; -- cgit v1.2.3 From baad5ee108bf8a4fdfdc6a381ffb5554dfdeaaa7 Mon Sep 17 00:00:00 2001 From: Michalis Pappas Date: Fri, 9 May 2014 18:08:22 +0800 Subject: staging: gdm72xx: Modify a struct allocation to match coding standards Fixes the following checkpatch.pl issue: CHECK: Prefer kmalloc(sizeof(*entry)...) over kmalloc(sizeof(struct qos_entry_s)...) Signed-off-by: Michalis Pappas Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm72xx/gdm_qos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/gdm72xx/gdm_qos.c b/drivers/staging/gdm72xx/gdm_qos.c index 50d43ada0936..519db48a14e1 100644 --- a/drivers/staging/gdm72xx/gdm_qos.c +++ b/drivers/staging/gdm72xx/gdm_qos.c @@ -56,7 +56,7 @@ static void *alloc_qos_entry(void) } spin_unlock_irqrestore(&qos_free_list.lock, flags); - entry = kmalloc(sizeof(struct qos_entry_s), GFP_ATOMIC); + entry = kmalloc(sizeof(*entry), GFP_ATOMIC); return entry; } -- cgit v1.2.3 From 522c6ff211473d5da0c221e18be70e88a760d48f Mon Sep 17 00:00:00 2001 From: Michalis Pappas Date: Fri, 9 May 2014 18:08:23 +0800 Subject: staging: gdm72xx: Move logical continuation to previous line to conform to coding style Fixes the following checkpatch.pl issue: CHECK: Logical continuations should be on the previous line Signed-off-by: Michalis Pappas Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm72xx/gdm_usb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/gdm72xx/gdm_usb.c b/drivers/staging/gdm72xx/gdm_usb.c index 9ddf8f58d87b..b9d764395fb9 100644 --- a/drivers/staging/gdm72xx/gdm_usb.c +++ b/drivers/staging/gdm72xx/gdm_usb.c @@ -518,8 +518,8 @@ static void do_pm_control(struct work_struct *work) usb_autopm_put_interface(udev->intf); spin_lock_irqsave(&tx->lock, flags); - if (!(udev->usbdev->state & USB_STATE_SUSPENDED) - && (!list_empty(&tx->hci_list) || !list_empty(&tx->sdu_list))) { + if (!(udev->usbdev->state & USB_STATE_SUSPENDED) && + (!list_empty(&tx->hci_list) || !list_empty(&tx->sdu_list))) { struct usb_tx *t, *temp; list_for_each_entry_safe(t, temp, &tx->pending_list, p_list) { -- cgit v1.2.3 From 633c8a2fc91aa2c2f0402dc1225a91acd58804c8 Mon Sep 17 00:00:00 2001 From: Michalis Pappas Date: Fri, 9 May 2014 18:08:24 +0800 Subject: staging: gdm72xx: Fix some camel-case variables Fixes the following checkpatch.pl issue: CHECK: Avoid CamelCase: Signed-off-by: Michalis Pappas Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm72xx/gdm_qos.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/staging/gdm72xx/gdm_qos.c b/drivers/staging/gdm72xx/gdm_qos.c index 519db48a14e1..465f69543d2b 100644 --- a/drivers/staging/gdm72xx/gdm_qos.c +++ b/drivers/staging/gdm72xx/gdm_qos.c @@ -142,24 +142,24 @@ void gdm_qos_release_list(void *nic_ptr) free_qos_entry_list(&free_list); } -static u32 chk_ipv4_rule(struct gdm_wimax_csr_s *csr, u8 *Stream, u8 *port) +static u32 chk_ipv4_rule(struct gdm_wimax_csr_s *csr, u8 *stream, u8 *port) { int i; if (csr->classifier_rule_en&IPTYPEOFSERVICE) { - if (((Stream[1] & csr->ip2s_mask) < csr->ip2s_lo) || - ((Stream[1] & csr->ip2s_mask) > csr->ip2s_hi)) + if (((stream[1] & csr->ip2s_mask) < csr->ip2s_lo) || + ((stream[1] & csr->ip2s_mask) > csr->ip2s_hi)) return 1; } if (csr->classifier_rule_en&PROTOCOL) { - if (Stream[9] != csr->protocol) + if (stream[9] != csr->protocol) return 1; } if (csr->classifier_rule_en&IPMASKEDSRCADDRESS) { for (i = 0; i < 4; i++) { - if ((Stream[12 + i] & csr->ipsrc_addrmask[i]) != + if ((stream[12 + i] & csr->ipsrc_addrmask[i]) != (csr->ipsrc_addr[i] & csr->ipsrc_addrmask[i])) return 1; } @@ -167,7 +167,7 @@ static u32 chk_ipv4_rule(struct gdm_wimax_csr_s *csr, u8 *Stream, u8 *port) if (csr->classifier_rule_en&IPMASKEDDSTADDRESS) { for (i = 0; i < 4; i++) { - if ((Stream[16 + i] & csr->ipdst_addrmask[i]) != + if ((stream[16 + i] & csr->ipdst_addrmask[i]) != (csr->ipdst_addr[i] & csr->ipdst_addrmask[i])) return 1; } @@ -190,16 +190,15 @@ static u32 chk_ipv4_rule(struct gdm_wimax_csr_s *csr, u8 *Stream, u8 *port) static u32 get_qos_index(struct nic *nic, u8 *iph, u8 *tcpudph) { - u32 IP_Ver, Header_Len, i; + u32 IP_ver, i; struct qos_cb_s *qcb = &nic->qos; if (iph == NULL || tcpudph == NULL) return -1; - IP_Ver = (iph[0]>>4)&0xf; - Header_Len = iph[0]&0xf; + IP_ver = (iph[0]>>4)&0xf; - if (IP_Ver == 4) { + if (IP_ver == 4) { for (i = 0; i < QOS_MAX; i++) { if (qcb->csr[i].enabled) { if (qcb->csr[i].classifier_rule_en) { @@ -336,16 +335,16 @@ void gdm_recv_qos_hci_packet(void *nic_ptr, u8 *buf, int size) { struct nic *nic = nic_ptr; u32 i, SFID, index, pos; - u8 subCmdEvt; + u8 sub_cmd_evt; struct qos_cb_s *qcb = &nic->qos; struct qos_entry_s *entry, *n; struct list_head send_list; struct list_head free_list; unsigned long flags; - subCmdEvt = (u8)buf[4]; + sub_cmd_evt = (u8)buf[4]; - if (subCmdEvt == QOS_REPORT) { + if (sub_cmd_evt == QOS_REPORT) { spin_lock_irqsave(&qcb->qos_lock, flags); for (i = 0; i < qcb->qos_list_cnt; i++) { SFID = ((buf[(i*5)+6]<<24)&0xff000000); @@ -367,7 +366,7 @@ void gdm_recv_qos_hci_packet(void *nic_ptr, u8 *buf, int size) return; } - /* subCmdEvt == QOS_ADD || subCmdEvt == QOS_CHANG_DEL */ + /* sub_cmd_evt == QOS_ADD || sub_cmd_evt == QOS_CHANG_DEL */ pos = 6; SFID = ((buf[pos++]<<24)&0xff000000); SFID += ((buf[pos++]<<16)&0xff0000); @@ -382,7 +381,7 @@ void gdm_recv_qos_hci_packet(void *nic_ptr, u8 *buf, int size) return; } - if (subCmdEvt == QOS_ADD) { + if (sub_cmd_evt == QOS_ADD) { netdev_dbg(nic->netdev, "QOS_ADD SFID = 0x%x, index=%d\n", SFID, index); @@ -423,7 +422,7 @@ void gdm_recv_qos_hci_packet(void *nic_ptr, u8 *buf, int size) qcb->qos_limit_size = 254/qcb->qos_list_cnt; spin_unlock_irqrestore(&qcb->qos_lock, flags); - } else if (subCmdEvt == QOS_CHANGE_DEL) { + } else if (sub_cmd_evt == QOS_CHANGE_DEL) { netdev_dbg(nic->netdev, "QOS_CHANGE_DEL SFID = 0x%x, index=%d\n", SFID, index); -- cgit v1.2.3 From 71fd11e1a0b585934b1b7af8114971979b0142c8 Mon Sep 17 00:00:00 2001 From: Michalis Pappas Date: Fri, 9 May 2014 18:08:25 +0800 Subject: staging: gdm72xx: Fix braces to conform with coding style Fixes the following checkpatch.pl issue: CHECK: braces {} should be used on all arms of this statement Signed-off-by: Michalis Pappas Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm72xx/gdm_wimax.c | 16 ++++++++-------- drivers/staging/gdm72xx/netlink_k.c | 7 ++++--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/staging/gdm72xx/gdm_wimax.c b/drivers/staging/gdm72xx/gdm_wimax.c index 05ce2a22c220..814d2e4d6db2 100644 --- a/drivers/staging/gdm72xx/gdm_wimax.c +++ b/drivers/staging/gdm72xx/gdm_wimax.c @@ -263,9 +263,9 @@ static struct evt_entry *get_event_entry(void) { struct evt_entry *e; - if (list_empty(&wm_event.freeq)) + if (list_empty(&wm_event.freeq)) { e = alloc_event_entry(); - else { + } else { e = list_entry(wm_event.freeq.next, struct evt_entry, list); list_del(&e->list); } @@ -379,9 +379,9 @@ static int gdm_wimax_tx(struct sk_buff *skb, struct net_device *dev) } #if !defined(LOOPBACK_TEST) - if (!fsm) + if (!fsm) { netdev_err(dev, "ASSERTION ERROR: fsm is NULL!!\n"); - else if (fsm->m_status != M_CONNECTED) { + } else if (fsm->m_status != M_CONNECTED) { netdev_emerg(dev, "ASSERTION ERROR: Device is NOT ready. status=%d\n", fsm->m_status); kfree_skb(skb); @@ -544,9 +544,9 @@ static void gdm_update_fsm(struct net_device *dev, struct fsm_s *new_fsm) if (cur_fsm->m_status != new_fsm->m_status || cur_fsm->c_status != new_fsm->c_status) { - if (new_fsm->m_status == M_CONNECTED) + if (new_fsm->m_status == M_CONNECTED) { netif_carrier_on(dev); - else if (cur_fsm->m_status == M_CONNECTED) { + } else if (cur_fsm->m_status == M_CONNECTED) { netif_carrier_off(dev); #if defined(CONFIG_WIMAX_GDM72XX_QOS) gdm_qos_release_list(nic); @@ -855,9 +855,9 @@ static void prepare_rx_complete(void *arg, void *data, int len) int ret; ret = gdm_wimax_get_prepared_info(nic->netdev, data, len); - if (ret == 1) + if (ret == 1) { gdm_wimax_rcv_with_cb(nic, rx_complete, nic); - else { + } else { if (ret < 0) netdev_err(nic->netdev, "get_prepared_info failed(%d)\n", ret); diff --git a/drivers/staging/gdm72xx/netlink_k.c b/drivers/staging/gdm72xx/netlink_k.c index af7f1c1d0b5c..52317c724969 100644 --- a/drivers/staging/gdm72xx/netlink_k.c +++ b/drivers/staging/gdm72xx/netlink_k.c @@ -75,8 +75,9 @@ static void netlink_rcv_cb(struct sk_buff *skb) netdev_err(skb->dev, "dev_get_by_index(%d) is not found.\n", ifindex); - } else + } else { netdev_err(skb->dev, "Unregistered Callback\n"); + } } } @@ -144,9 +145,9 @@ int netlink_send(struct sock *sock, int group, u16 type, void *msg, int len) ret = netlink_broadcast(sock, skb, 0, group+1, GFP_ATOMIC); - if (!ret) + if (!ret) { return len; - else { + } else { if (ret != -ESRCH) { pr_err("netlink_broadcast g=%d, t=%d, l=%d, r=%d\n", group, type, len, ret); -- cgit v1.2.3 From b268666f6b25e4b09a612d69f4cb9a2089d7adb5 Mon Sep 17 00:00:00 2001 From: Michalis Pappas Date: Fri, 9 May 2014 18:08:26 +0800 Subject: staging: gdm72xx: Removed commented-out code Signed-off-by: Michalis Pappas Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm72xx/gdm_qos.h | 17 ----------------- drivers/staging/gdm72xx/gdm_wimax.c | 4 ---- drivers/staging/gdm72xx/gdm_wimax.h | 6 ------ drivers/staging/gdm72xx/usb_boot.c | 17 +---------------- 4 files changed, 1 insertion(+), 43 deletions(-) diff --git a/drivers/staging/gdm72xx/gdm_qos.h b/drivers/staging/gdm72xx/gdm_qos.h index 8f18119d22a9..6543cff2a876 100644 --- a/drivers/staging/gdm72xx/gdm_qos.h +++ b/drivers/staging/gdm72xx/gdm_qos.h @@ -34,23 +34,6 @@ #define IEEE802_1QVLANID 0x10 struct gdm_wimax_csr_s { - /* union{ - U16 all; - struct _CS_CLASSIFIER_RULE_ENABLE{ - IPTypeOfService:1, - Protocol:1, - IPMaskedSrcAddress:1, - IPMaskedDstAddress:1, - ProtocolSrcPortRange:1, - ProtocolDstPortRange:1, - DstMacAddr:1, - SrcMacAddr:1, - Ethertype:1, - IEEE802_1DUserPriority:1, - IEEE802_1QVLANID:1, - Reserved:5; - } fields; - } */ BOOLEAN enabled; u32 SFID; u8 qos_buf_count; diff --git a/drivers/staging/gdm72xx/gdm_wimax.c b/drivers/staging/gdm72xx/gdm_wimax.c index 814d2e4d6db2..3ccb0838a391 100644 --- a/drivers/staging/gdm72xx/gdm_wimax.c +++ b/drivers/staging/gdm72xx/gdm_wimax.c @@ -862,10 +862,6 @@ static void prepare_rx_complete(void *arg, void *data, int len) netdev_err(nic->netdev, "get_prepared_info failed(%d)\n", ret); gdm_wimax_rcv_with_cb(nic, prepare_rx_complete, nic); - #if 0 - /* Re-prepare WiMax device */ - gdm_wimax_prepare_device(nic->netdev); - #endif } } diff --git a/drivers/staging/gdm72xx/gdm_wimax.h b/drivers/staging/gdm72xx/gdm_wimax.h index 3013bdbff8fd..55212f55efd7 100644 --- a/drivers/staging/gdm72xx/gdm_wimax.h +++ b/drivers/staging/gdm72xx/gdm_wimax.h @@ -23,10 +23,6 @@ #define DRIVER_VERSION "3.2.3" -/*#define ETH_P_IP 0x0800 */ -/*#define ETH_P_ARP 0x0806 */ -/*#define ETH_P_IPV6 0x86DD */ - #define H2L(x) __cpu_to_le16(x) #define L2H(x) __le16_to_cpu(x) #define DH2L(x) __cpu_to_le32(x) @@ -62,8 +58,6 @@ struct nic { }; -/*#define LOOPBACK_TEST */ - int register_wimax_device(struct phy_dev *phy_dev, struct device *pdev); int gdm_wimax_send_tx(struct sk_buff *skb, struct net_device *dev); void unregister_wimax_device(struct phy_dev *phy_dev); diff --git a/drivers/staging/gdm72xx/usb_boot.c b/drivers/staging/gdm72xx/usb_boot.c index 0d45eb680be5..8518a5a67872 100644 --- a/drivers/staging/gdm72xx/usb_boot.c +++ b/drivers/staging/gdm72xx/usb_boot.c @@ -169,14 +169,7 @@ int usb_boot(struct usb_device *usbdev, u16 pid) memcpy(&hdr, firm->data, sizeof(hdr)); array_le32_to_cpu((u32 *)&hdr, 19); -#if 0 - if (hdr.magic_code != 0x10767fff) { - dev_err(&usbdev->dev, "Invalid magic code 0x%08x\n", - hdr.magic_code); - ret = -EINVAL; - goto out; - } -#endif + if (hdr.count > MAX_IMG_CNT) { dev_err(&usbdev->dev, "Too many images. %d\n", hdr.count); ret = -EINVAL; @@ -201,14 +194,6 @@ int usb_boot(struct usb_device *usbdev, u16 pid) memcpy(&fw_info, firm->data + pos, sizeof(fw_info)); array_le32_to_cpu((u32 *)&fw_info, 8); -#if 0 - if ((fw_info.id & 0xfffff000) != 0x10767000) { - dev_err(&usbdev->dev, "Invalid FW id. 0x%08x\n", - fw_info.id); - ret = -EIO; - goto out; - } -#endif if ((fw_info.id & 0xffff) != pid) continue; -- cgit v1.2.3 From 39c511f8cb90be18f12575e5bdaf566a5e9a56b5 Mon Sep 17 00:00:00 2001 From: Michalis Pappas Date: Fri, 9 May 2014 18:08:27 +0800 Subject: staging: gdm72xx: Whitespace fixes to conform to coding standards Fixes the following checkpatch.pl issues: WARNING: unnecessary whitespace before a quoted newline CHECK: Alignment should match open parenthesis CHECK: No space is necessary after a cast Also some additional, whitespace related, readability issues. Signed-off-by: Michalis Pappas Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm72xx/gdm_qos.c | 72 ++++++++++++++++++------------------- drivers/staging/gdm72xx/gdm_sdio.c | 15 ++++---- drivers/staging/gdm72xx/gdm_usb.c | 43 ++++++++-------------- drivers/staging/gdm72xx/gdm_wimax.c | 61 +++++++++++++++---------------- drivers/staging/gdm72xx/gdm_wimax.h | 6 ++-- drivers/staging/gdm72xx/netlink_k.c | 5 ++- drivers/staging/gdm72xx/netlink_k.h | 4 +-- drivers/staging/gdm72xx/usb_boot.c | 18 +++++----- 8 files changed, 101 insertions(+), 123 deletions(-) diff --git a/drivers/staging/gdm72xx/gdm_qos.c b/drivers/staging/gdm72xx/gdm_qos.c index 465f69543d2b..33df46a62380 100644 --- a/drivers/staging/gdm72xx/gdm_qos.c +++ b/drivers/staging/gdm72xx/gdm_qos.c @@ -47,8 +47,7 @@ static void *alloc_qos_entry(void) spin_lock_irqsave(&qos_free_list.lock, flags); if (qos_free_list.cnt) { - entry = list_entry(qos_free_list.head.prev, struct qos_entry_s, - list); + entry = list_entry(qos_free_list.head.prev, struct qos_entry_s, list); list_del(&entry->list); qos_free_list.cnt--; spin_unlock_irqrestore(&qos_free_list.lock, flags); @@ -62,7 +61,7 @@ static void *alloc_qos_entry(void) static void free_qos_entry(void *entry) { - struct qos_entry_s *qentry = (struct qos_entry_s *) entry; + struct qos_entry_s *qentry = (struct qos_entry_s *)entry; unsigned long flags; spin_lock_irqsave(&qos_free_list.lock, flags); @@ -148,7 +147,7 @@ static u32 chk_ipv4_rule(struct gdm_wimax_csr_s *csr, u8 *stream, u8 *port) if (csr->classifier_rule_en&IPTYPEOFSERVICE) { if (((stream[1] & csr->ip2s_mask) < csr->ip2s_lo) || - ((stream[1] & csr->ip2s_mask) > csr->ip2s_hi)) + ((stream[1] & csr->ip2s_mask) > csr->ip2s_hi)) return 1; } @@ -190,7 +189,7 @@ static u32 chk_ipv4_rule(struct gdm_wimax_csr_s *csr, u8 *stream, u8 *port) static u32 get_qos_index(struct nic *nic, u8 *iph, u8 *tcpudph) { - u32 IP_ver, i; + u32 IP_ver, i; struct qos_cb_s *qcb = &nic->qos; if (iph == NULL || tcpudph == NULL) @@ -198,16 +197,16 @@ static u32 get_qos_index(struct nic *nic, u8 *iph, u8 *tcpudph) IP_ver = (iph[0]>>4)&0xf; - if (IP_ver == 4) { - for (i = 0; i < QOS_MAX; i++) { - if (qcb->csr[i].enabled) { - if (qcb->csr[i].classifier_rule_en) { - if (chk_ipv4_rule(&qcb->csr[i], iph, - tcpudph) == 0) - return i; - } - } - } + if (IP_ver != 4) + return -1; + + for (i = 0; i < QOS_MAX; i++) { + if (!qcb->csr[i].enabled) + continue; + if (!qcb->csr[i].classifier_rule_en) + continue; + if (chk_ipv4_rule(&qcb->csr[i], iph, tcpudph) == 0) + return i; } return -1; @@ -222,22 +221,20 @@ static u32 extract_qos_list(struct nic *nic, struct list_head *head) INIT_LIST_HEAD(head); for (i = 0; i < QOS_MAX; i++) { - if (qcb->csr[i].enabled) { - if (qcb->csr[i].qos_buf_count < qcb->qos_limit_size) { - if (!list_empty(&qcb->qos_list[i])) { - entry = list_entry( - qcb->qos_list[i].prev, - struct qos_entry_s, list); - list_move_tail(&entry->list, head); - qcb->csr[i].qos_buf_count++; - - if (!list_empty(&qcb->qos_list[i])) - netdev_warn(nic->netdev, - "Index(%d) is piled!!\n", - i); - } - } - } + if (!qcb->csr[i].enabled) + continue; + if (qcb->csr[i].qos_buf_count >= qcb->qos_limit_size) + continue; + if (list_empty(&qcb->qos_list[i])) + continue; + + entry = list_entry(qcb->qos_list[i].prev, struct qos_entry_s, list); + + list_move_tail(&entry->list, head); + qcb->csr[i].qos_buf_count++; + + if (!list_empty(&qcb->qos_list[i])) + netdev_warn(nic->netdev, "Index(%d) is piled!!\n", i); } return 0; @@ -260,14 +257,14 @@ int gdm_qos_send_hci_pkt(struct sk_buff *skb, struct net_device *dev) int index; struct qos_cb_s *qcb = &nic->qos; unsigned long flags; - struct ethhdr *ethh = (struct ethhdr *) (skb->data + HCI_HEADER_SIZE); - struct iphdr *iph = (struct iphdr *) ((char *) ethh + ETH_HLEN); + struct ethhdr *ethh = (struct ethhdr *)(skb->data + HCI_HEADER_SIZE); + struct iphdr *iph = (struct iphdr *)((char *)ethh + ETH_HLEN); struct tcphdr *tcph; struct qos_entry_s *entry = NULL; struct list_head send_list; int ret = 0; - tcph = (struct tcphdr *) iph + iph->ihl*4; + tcph = (struct tcphdr *)iph + iph->ihl*4; if (B2H(ethh->h_proto) == ETH_P_IP) { if (qcb->qos_list_cnt && !qos_free_list.cnt) { @@ -280,7 +277,7 @@ int gdm_qos_send_hci_pkt(struct sk_buff *skb, struct net_device *dev) spin_lock_irqsave(&qcb->qos_lock, flags); if (qcb->qos_list_cnt) { - index = get_qos_index(nic, (u8 *)iph, (u8 *) tcph); + index = get_qos_index(nic, (u8 *)iph, (u8 *)tcph); if (index == -1) index = qcb->qos_null_idx; @@ -376,7 +373,7 @@ void gdm_recv_qos_hci_packet(void *nic_ptr, u8 *buf, int size) index = get_csr(qcb, SFID, 1); if (index == -1) { netdev_err(nic->netdev, - "QoS ERROR: csr Update Error / Wrong index (%d) \n", + "QoS ERROR: csr Update Error / Wrong index (%d)\n", index); return; } @@ -433,8 +430,7 @@ void gdm_recv_qos_hci_packet(void *nic_ptr, u8 *buf, int size) qcb->qos_list_cnt--; qcb->qos_limit_size = 254/qcb->qos_list_cnt; - list_for_each_entry_safe(entry, n, &qcb->qos_list[index], - list) { + list_for_each_entry_safe(entry, n, &qcb->qos_list[index], list) { list_move_tail(&entry->list, &free_list); } spin_unlock_irqrestore(&qcb->qos_lock, flags); diff --git a/drivers/staging/gdm72xx/gdm_sdio.c b/drivers/staging/gdm72xx/gdm_sdio.c index c24653739e13..07be325ba1b6 100644 --- a/drivers/staging/gdm72xx/gdm_sdio.c +++ b/drivers/staging/gdm72xx/gdm_sdio.c @@ -312,8 +312,7 @@ static void send_sdu(struct sdio_func *func, struct tx_cxt *tx) spin_unlock_irqrestore(&tx->lock, flags); } -static void send_hci(struct sdio_func *func, struct tx_cxt *tx, - struct sdio_tx *t) +static void send_hci(struct sdio_func *func, struct tx_cxt *tx, struct sdio_tx *t) { unsigned long flags; @@ -380,7 +379,7 @@ static void do_tx(struct work_struct *work) } static int gdm_sdio_send(void *priv_dev, void *data, int len, - void (*cb)(void *data), void *cb_data) + void (*cb)(void *data), void *cb_data) { struct sdiowm_dev *sdev = priv_dev; struct tx_cxt *tx = &sdev->tx; @@ -510,6 +509,7 @@ static void gdm_sdio_irq(struct sdio_func *func) if (hdr[3] == 1) { /* Ack */ u32 *ack_seq = (u32 *)&hdr[4]; + spin_lock_irqsave(&tx->lock, flags); tx->can_send = 1; @@ -521,7 +521,7 @@ static void gdm_sdio_irq(struct sdio_func *func) } memcpy(rx->rx_buf, hdr + TYPE_A_HEADER_SIZE, - TYPE_A_LOOKAHEAD_SIZE - TYPE_A_HEADER_SIZE); + TYPE_A_LOOKAHEAD_SIZE - TYPE_A_HEADER_SIZE); buf = rx->rx_buf + TYPE_A_LOOKAHEAD_SIZE - TYPE_A_HEADER_SIZE; remain = len - TYPE_A_LOOKAHEAD_SIZE + TYPE_A_HEADER_SIZE; @@ -577,8 +577,8 @@ done: } static int gdm_sdio_receive(void *priv_dev, - void (*cb)(void *cb_data, void *data, int len), - void *cb_data) + void (*cb)(void *cb_data, void *data, int len), + void *cb_data) { struct sdiowm_dev *sdev = priv_dev; struct rx_cxt *rx = &sdev->rx; @@ -601,8 +601,7 @@ static int gdm_sdio_receive(void *priv_dev, return 0; } -static int sdio_wimax_probe(struct sdio_func *func, - const struct sdio_device_id *id) +static int sdio_wimax_probe(struct sdio_func *func, const struct sdio_device_id *id) { int ret; struct phy_dev *phy_dev = NULL; diff --git a/drivers/staging/gdm72xx/gdm_usb.c b/drivers/staging/gdm72xx/gdm_usb.c index b9d764395fb9..c7298d084611 100644 --- a/drivers/staging/gdm72xx/gdm_usb.c +++ b/drivers/staging/gdm72xx/gdm_usb.c @@ -344,16 +344,11 @@ static int gdm_usb_send(void *priv_dev, void *data, int len, if ((len % 512) == 0) len++; - usb_fill_bulk_urb(t->urb, - usbdev, - usb_sndbulkpipe(usbdev, 1), - t->buf, - len + padding, - gdm_usb_send_complete, - t); - - print_hex_dump_debug("usb_send: ", DUMP_PREFIX_NONE, 16, 1, - t->buf, len + padding, false); + usb_fill_bulk_urb(t->urb, usbdev, usb_sndbulkpipe(usbdev, 1), t->buf, + len + padding, gdm_usb_send_complete, t); + + print_hex_dump_debug("usb_send: ", DUMP_PREFIX_NONE, 16, 1, t->buf, + len + padding, false); #ifdef CONFIG_WIMAX_GDM72XX_USB_PM if (usbdev->state & USB_STATE_SUSPENDED) { list_add_tail(&t->p_list, &tx->pending_list); @@ -470,8 +465,8 @@ static void gdm_usb_rcv_complete(struct urb *urb) } static int gdm_usb_receive(void *priv_dev, - void (*cb)(void *cb_data, void *data, int len), - void *cb_data) + void (*cb)(void *cb_data, void *data, int len), + void *cb_data) { struct usbwm_dev *udev = priv_dev; struct usb_device *usbdev = udev->usbdev; @@ -494,13 +489,8 @@ static int gdm_usb_receive(void *priv_dev, r->callback = cb; r->cb_data = cb_data; - usb_fill_bulk_urb(r->urb, - usbdev, - usb_rcvbulkpipe(usbdev, 0x82), - r->buf, - RX_BUF_SIZE, - gdm_usb_rcv_complete, - r); + usb_fill_bulk_urb(r->urb, usbdev, usb_rcvbulkpipe(usbdev, 0x82), r->buf, + RX_BUF_SIZE, gdm_usb_rcv_complete, r); return usb_submit_urb(r->urb, GFP_ATOMIC); } @@ -519,7 +509,7 @@ static void do_pm_control(struct work_struct *work) spin_lock_irqsave(&tx->lock, flags); if (!(udev->usbdev->state & USB_STATE_SUSPENDED) && - (!list_empty(&tx->hci_list) || !list_empty(&tx->sdu_list))) { + (!list_empty(&tx->hci_list) || !list_empty(&tx->sdu_list))) { struct usb_tx *t, *temp; list_for_each_entry_safe(t, temp, &tx->pending_list, p_list) { @@ -536,8 +526,7 @@ static void do_pm_control(struct work_struct *work) } #endif /* CONFIG_WIMAX_GDM72XX_USB_PM */ -static int gdm_usb_probe(struct usb_interface *intf, - const struct usb_device_id *id) +static int gdm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) { int ret = 0; u8 bConfigurationValue; @@ -566,8 +555,7 @@ static int gdm_usb_probe(struct usb_interface *intf, } /* Support for EEPROM bootloader */ - if (bConfigurationValue == DOWNLOAD_CONF_VALUE || - idProduct & B_DOWNLOAD) { + if (bConfigurationValue == DOWNLOAD_CONF_VALUE || idProduct & B_DOWNLOAD) { ret = usb_boot(usbdev, bcdDevice); goto out; } @@ -639,8 +627,8 @@ static void gdm_usb_disconnect(struct usb_interface *intf) idProduct = L2H(usbdev->descriptor.idProduct); if (idProduct != EMERGENCY_PID && - bConfigurationValue != DOWNLOAD_CONF_VALUE && - (idProduct & B_DOWNLOAD) == 0) { + bConfigurationValue != DOWNLOAD_CONF_VALUE && (idProduct & B_DOWNLOAD) == 0) { + udev = phy_dev->priv_dev; udev->usbdev = NULL; @@ -742,8 +730,7 @@ static int k_mode_thread(void *arg) spin_lock_irqsave(&tx->lock, flags); - list_for_each_entry_safe(t, temp, &tx->pending_list, - p_list) { + list_for_each_entry_safe(t, temp, &tx->pending_list, p_list) { list_del(&t->p_list); ret = usb_submit_urb(t->urb, GFP_ATOMIC); diff --git a/drivers/staging/gdm72xx/gdm_wimax.c b/drivers/staging/gdm72xx/gdm_wimax.c index 3ccb0838a391..094e9c9ee860 100644 --- a/drivers/staging/gdm72xx/gdm_wimax.c +++ b/drivers/staging/gdm72xx/gdm_wimax.c @@ -135,24 +135,24 @@ static void dump_eth_packet(struct net_device *dev, const char *title, u16 port = 0; protocol = (data[12]<<8) | data[13]; - ih = (struct iphdr *) (data+ETH_HLEN); + ih = (struct iphdr *)(data+ETH_HLEN); if (protocol == ETH_P_IP) { - uh = (struct udphdr *) ((char *)ih + sizeof(struct iphdr)); + uh = (struct udphdr *)((char *)ih + sizeof(struct iphdr)); ip_protocol = ih->protocol; port = ntohs(uh->dest); } else if (protocol == ETH_P_IPV6) { - struct ipv6hdr *i6h = (struct ipv6hdr *) data; - uh = (struct udphdr *) ((char *)i6h + sizeof(struct ipv6hdr)); + struct ipv6hdr *i6h = (struct ipv6hdr *)data; + + uh = (struct udphdr *)((char *)i6h + sizeof(struct ipv6hdr)); ip_protocol = i6h->nexthdr; port = ntohs(uh->dest); } - netdev_dbg(dev, "[%s] len=%d, %s, %s, %s\n", - title, len, - get_protocol_name(protocol), - get_ip_protocol_name(ip_protocol), - get_port_name(port)); + netdev_dbg(dev, "[%s] len=%d, %s, %s, %s\n", title, len, + get_protocol_name(protocol), + get_ip_protocol_name(ip_protocol), + get_port_name(port)); if (!(data[0] == 0xff && data[1] == 0xff)) { if (protocol == ETH_P_IP) @@ -196,9 +196,10 @@ static void gdm_wimax_event_rcv(struct net_device *dev, u16 type, void *msg, { struct nic *nic = netdev_priv(dev); - u8 *buf = (u8 *) msg; + u8 *buf = (u8 *)msg; u16 hci_cmd = (buf[0]<<8) | buf[1]; u16 hci_len = (buf[2]<<8) | buf[3]; + netdev_dbg(dev, "H=>D: 0x%04x(%d)\n", hci_cmd, hci_len); gdm_wimax_send(nic, msg, len); @@ -310,6 +311,7 @@ static int gdm_wimax_event_send(struct net_device *dev, char *buf, int size) u16 hci_cmd = ((u8)buf[0]<<8) | (u8)buf[1]; u16 hci_len = ((u8)buf[2]<<8) | (u8)buf[3]; + netdev_dbg(dev, "D=>H: 0x%04x(%d)\n", hci_cmd, hci_len); spin_lock_irqsave(&wm_event.evt_lock, flags); @@ -346,8 +348,7 @@ int gdm_wimax_send_tx(struct sk_buff *skb, struct net_device *dev) int ret = 0; struct nic *nic = netdev_priv(dev); - ret = gdm_wimax_send_with_cb(nic, skb->data, skb->len, tx_complete, - nic); + ret = gdm_wimax_send_with_cb(nic, skb->data, skb->len, tx_complete, nic); if (ret == -ENOSPC) { netif_stop_queue(dev); ret = 0; @@ -368,7 +369,7 @@ static int gdm_wimax_tx(struct sk_buff *skb, struct net_device *dev) { int ret = 0; struct nic *nic = netdev_priv(dev); - struct fsm_s *fsm = (struct fsm_s *) nic->sdk_data[SIOC_DATA_FSM].buf; + struct fsm_s *fsm = (struct fsm_s *)nic->sdk_data[SIOC_DATA_FSM].buf; dump_eth_packet(dev, "TX", skb->data, skb->len); @@ -408,7 +409,7 @@ static int gdm_wimax_set_config(struct net_device *dev, struct ifmap *map) static void __gdm_wimax_set_mac_addr(struct net_device *dev, char *mac_addr) { u16 hci_pkt_buf[32 / sizeof(u16)]; - u8 *pkt = (u8 *) &hci_pkt_buf[0]; + u8 *pkt = (u8 *)&hci_pkt_buf[0]; struct nic *nic = netdev_priv(dev); /* Since dev is registered as a ethernet device, @@ -454,7 +455,7 @@ static struct net_device_stats *gdm_wimax_stats(struct net_device *dev) static int gdm_wimax_open(struct net_device *dev) { struct nic *nic = netdev_priv(dev); - struct fsm_s *fsm = (struct fsm_s *) nic->sdk_data[SIOC_DATA_FSM].buf; + struct fsm_s *fsm = (struct fsm_s *)nic->sdk_data[SIOC_DATA_FSM].buf; netif_start_queue(dev); @@ -466,7 +467,7 @@ static int gdm_wimax_open(struct net_device *dev) static int gdm_wimax_close(struct net_device *dev) { struct nic *nic = netdev_priv(dev); - struct fsm_s *fsm = (struct fsm_s *) nic->sdk_data[SIOC_DATA_FSM].buf; + struct fsm_s *fsm = (struct fsm_s *)nic->sdk_data[SIOC_DATA_FSM].buf; netif_stop_queue(dev); @@ -536,14 +537,13 @@ static void gdm_wimax_cleanup_ioctl(struct net_device *dev) static void gdm_update_fsm(struct net_device *dev, struct fsm_s *new_fsm) { struct nic *nic = netdev_priv(dev); - struct fsm_s *cur_fsm = - (struct fsm_s *) nic->sdk_data[SIOC_DATA_FSM].buf; + struct fsm_s *cur_fsm = (struct fsm_s *)nic->sdk_data[SIOC_DATA_FSM].buf; if (!cur_fsm) return; if (cur_fsm->m_status != new_fsm->m_status || - cur_fsm->c_status != new_fsm->c_status) { + cur_fsm->c_status != new_fsm->c_status) { if (new_fsm->m_status == M_CONNECTED) { netif_carrier_on(dev); } else if (cur_fsm->m_status == M_CONNECTED) { @@ -558,7 +558,7 @@ static void gdm_update_fsm(struct net_device *dev, struct fsm_s *new_fsm) static int gdm_wimax_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) { - struct wm_req_s *req = (struct wm_req_s *) ifr; + struct wm_req_s *req = (struct wm_req_s *)ifr; struct nic *nic = netdev_priv(dev); int ret; @@ -575,15 +575,14 @@ static int gdm_wimax_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) } if (req->cmd == SIOCG_DATA) { ret = gdm_wimax_ioctl_get_data(&req->data, - &nic->sdk_data[req->data_id]); + &nic->sdk_data[req->data_id]); if (ret < 0) return ret; } else if (req->cmd == SIOCS_DATA) { if (req->data_id == SIOC_DATA_FSM) { /*NOTE: gdm_update_fsm should be called before gdm_wimax_ioctl_set_data is called*/ - gdm_update_fsm(dev, - (struct fsm_s *) req->data.buf); + gdm_update_fsm(dev, (struct fsm_s *)req->data.buf); } ret = gdm_wimax_ioctl_set_data( &nic->sdk_data[req->data_id], &req->data); @@ -603,7 +602,7 @@ static void gdm_wimax_prepare_device(struct net_device *dev) { struct nic *nic = netdev_priv(dev); u16 buf[32 / sizeof(u16)]; - struct hci_s *hci = (struct hci_s *) buf; + struct hci_s *hci = (struct hci_s *)buf; u16 len = 0; u32 val = 0; @@ -660,8 +659,7 @@ static int gdm_wimax_hci_get_tlv(u8 *buf, u8 *T, u16 *L, u8 **V) return next_pos; } -static int gdm_wimax_get_prepared_info(struct net_device *dev, char *buf, - int len) +static int gdm_wimax_get_prepared_info(struct net_device *dev, char *buf, int len) { u8 T, *V; u16 L; @@ -740,7 +738,7 @@ static void gdm_wimax_transmit_aggr_pkt(struct net_device *dev, char *buf, int length; while (len > 0) { - hci = (struct hci_s *) buf; + hci = (struct hci_s *)buf; if (B2H(hci->cmd_evt) != WIMAX_RX_SDU) { netdev_err(dev, "Wrong cmd_evt(0x%04X)\n", @@ -785,8 +783,7 @@ static void gdm_wimax_transmit_pkt(struct net_device *dev, char *buf, int len) switch (cmd_evt) { case WIMAX_RX_SDU_AGGR: - gdm_wimax_transmit_aggr_pkt(dev, &buf[HCI_HEADER_SIZE], - cmd_len); + gdm_wimax_transmit_aggr_pkt(dev, &buf[HCI_HEADER_SIZE], cmd_len); break; case WIMAX_RX_SDU: gdm_wimax_netif_rx(dev, &buf[HCI_HEADER_SIZE], cmd_len); @@ -822,13 +819,13 @@ static void gdm_wimax_ind_fsm_update(struct net_device *dev, struct fsm_s *fsm) memcpy(&hci_pkt_buf[HCI_HEADER_SIZE], fsm, sizeof(struct fsm_s)); gdm_wimax_event_send(dev, hci_pkt_buf, - HCI_HEADER_SIZE + sizeof(struct fsm_s)); + HCI_HEADER_SIZE + sizeof(struct fsm_s)); } static void gdm_wimax_ind_if_updown(struct net_device *dev, int if_up) { u16 buf[32 / sizeof(u16)]; - struct hci_s *hci = (struct hci_s *) buf; + struct hci_s *hci = (struct hci_s *)buf; unsigned char up_down; up_down = if_up ? WIMAX_IF_UP : WIMAX_IF_DOWN; @@ -944,7 +941,7 @@ cleanup: void unregister_wimax_device(struct phy_dev *phy_dev) { struct nic *nic = netdev_priv(phy_dev->netdev); - struct fsm_s *fsm = (struct fsm_s *) nic->sdk_data[SIOC_DATA_FSM].buf; + struct fsm_s *fsm = (struct fsm_s *)nic->sdk_data[SIOC_DATA_FSM].buf; if (fsm) fsm->m_status = M_INIT; diff --git a/drivers/staging/gdm72xx/gdm_wimax.h b/drivers/staging/gdm72xx/gdm_wimax.h index 55212f55efd7..21087c03ce3b 100644 --- a/drivers/staging/gdm72xx/gdm_wimax.h +++ b/drivers/staging/gdm72xx/gdm_wimax.h @@ -38,10 +38,10 @@ struct phy_dev { struct net_device *netdev; int (*send_func)(void *priv_dev, void *data, int len, - void (*cb)(void *cb_data), void *cb_data); + void (*cb)(void *cb_data), void *cb_data); int (*rcv_func)(void *priv_dev, - void (*cb)(void *cb_data, void *data, int len), - void *cb_data); + void (*cb)(void *cb_data, void *data, int len), + void *cb_data); }; struct nic { diff --git a/drivers/staging/gdm72xx/netlink_k.c b/drivers/staging/gdm72xx/netlink_k.c index 52317c724969..06f7b13b3196 100644 --- a/drivers/staging/gdm72xx/netlink_k.c +++ b/drivers/staging/gdm72xx/netlink_k.c @@ -55,8 +55,7 @@ static void netlink_rcv_cb(struct sk_buff *skb) if (skb->len >= NLMSG_HDRLEN) { nlh = (struct nlmsghdr *)skb->data; - if (skb->len < nlh->nlmsg_len || - nlh->nlmsg_len > ND_MAX_MSG_LEN) { + if (skb->len < nlh->nlmsg_len || nlh->nlmsg_len > ND_MAX_MSG_LEN) { netdev_err(skb->dev, "Invalid length (%d,%d)\n", skb->len, nlh->nlmsg_len); return; @@ -89,7 +88,7 @@ static void netlink_rcv(struct sk_buff *skb) } struct sock *netlink_init(int unit, void (*cb)(struct net_device *dev, u16 type, - void *msg, int len)) + void *msg, int len)) { struct sock *sock; struct netlink_kernel_cfg cfg = { diff --git a/drivers/staging/gdm72xx/netlink_k.h b/drivers/staging/gdm72xx/netlink_k.h index 1dffaa6156e4..b6caac16b3d3 100644 --- a/drivers/staging/gdm72xx/netlink_k.h +++ b/drivers/staging/gdm72xx/netlink_k.h @@ -16,8 +16,8 @@ #include #include -struct sock *netlink_init(int unit, - void (*cb)(struct net_device *dev, u16 type, void *msg, int len)); +struct sock *netlink_init(int unit, void (*cb)(struct net_device *dev, u16 type, + void *msg, int len)); void netlink_exit(struct sock *sock); int netlink_send(struct sock *sock, int group, u16 type, void *msg, int len); diff --git a/drivers/staging/gdm72xx/usb_boot.c b/drivers/staging/gdm72xx/usb_boot.c index 8518a5a67872..75149d7027db 100644 --- a/drivers/staging/gdm72xx/usb_boot.c +++ b/drivers/staging/gdm72xx/usb_boot.c @@ -67,6 +67,7 @@ struct fw_info { static void array_le32_to_cpu(u32 *arr, int num) { int i; + for (i = 0; i < num; i++, arr++) *arr = __le32_to_cpu(*arr); } @@ -79,7 +80,7 @@ static int gdm_wibro_send(struct usb_device *usbdev, void *data, int len) int actual; ret = usb_bulk_msg(usbdev, usb_sndbulkpipe(usbdev, 1), data, len, - &actual, 1000); + &actual, 1000); if (ret < 0) { dev_err(&usbdev->dev, "Error : usb_bulk_msg ( result = %d )\n", @@ -95,7 +96,7 @@ static int gdm_wibro_recv(struct usb_device *usbdev, void *data, int len) int actual; ret = usb_bulk_msg(usbdev, usb_rcvbulkpipe(usbdev, 2), data, len, - &actual, 5000); + &actual, 5000); if (ret < 0) { dev_err(&usbdev->dev, @@ -105,9 +106,8 @@ static int gdm_wibro_recv(struct usb_device *usbdev, void *data, int len) return 0; } -static int download_image(struct usb_device *usbdev, - const struct firmware *firm, - loff_t pos, u32 img_len, u32 magic_num) +static int download_image(struct usb_device *usbdev, const struct firmware *firm, + loff_t pos, u32 img_len, u32 magic_num) { struct dn_header h; int ret = 0; @@ -204,8 +204,8 @@ int usb_boot(struct usb_device *usbdev, u16 pid) goto out; } - ret = download_image(usbdev, firm, pos, - fw_info.kernel_len, DN_KERNEL_MAGIC_NUMBER); + ret = download_image(usbdev, firm, pos, fw_info.kernel_len, + DN_KERNEL_MAGIC_NUMBER); if (ret < 0) goto out; dev_info(&usbdev->dev, "GCT: Kernel download success.\n"); @@ -216,7 +216,7 @@ int usb_boot(struct usb_device *usbdev, u16 pid) goto out; } ret = download_image(usbdev, firm, pos, fw_info.rootfs_len, - DN_ROOTFS_MAGIC_NUMBER); + DN_ROOTFS_MAGIC_NUMBER); if (ret < 0) goto out; dev_info(&usbdev->dev, "GCT: Filesystem download success.\n"); @@ -261,7 +261,7 @@ out: } static int em_download_image(struct usb_device *usbdev, const char *img_name, - char *type_string) + char *type_string) { char *buf = NULL; loff_t pos = 0; -- cgit v1.2.3 From ac1a3bfafb66d51be061c341f05f283d38d2e22f Mon Sep 17 00:00:00 2001 From: Michalis Pappas Date: Fri, 9 May 2014 18:08:28 +0800 Subject: staging: gdm72xx: Indentation and other whitespace fixes Signed-off-by: Michalis Pappas Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm72xx/gdm_qos.c | 2 +- drivers/staging/gdm72xx/gdm_sdio.c | 14 +++--- drivers/staging/gdm72xx/gdm_sdio.h | 29 +++++-------- drivers/staging/gdm72xx/gdm_usb.c | 17 ++++---- drivers/staging/gdm72xx/gdm_usb.h | 11 +---- drivers/staging/gdm72xx/gdm_wimax.c | 21 +++++---- drivers/staging/gdm72xx/gdm_wimax.h | 21 ++++----- drivers/staging/gdm72xx/hci.h | 87 +++++++++++++++++-------------------- drivers/staging/gdm72xx/usb_ids.h | 2 +- drivers/staging/gdm72xx/wm_ioctl.h | 22 +++++----- 10 files changed, 97 insertions(+), 129 deletions(-) diff --git a/drivers/staging/gdm72xx/gdm_qos.c b/drivers/staging/gdm72xx/gdm_qos.c index 33df46a62380..eba3bfaebacd 100644 --- a/drivers/staging/gdm72xx/gdm_qos.c +++ b/drivers/staging/gdm72xx/gdm_qos.c @@ -24,7 +24,7 @@ #include "hci.h" #include "gdm_qos.h" -#define B2H(x) __be16_to_cpu(x) +#define B2H(x) __be16_to_cpu(x) #define MAX_FREE_LIST_CNT 32 static struct { diff --git a/drivers/staging/gdm72xx/gdm_sdio.c b/drivers/staging/gdm72xx/gdm_sdio.c index 07be325ba1b6..6d1de33e2e90 100644 --- a/drivers/staging/gdm72xx/gdm_sdio.c +++ b/drivers/staging/gdm72xx/gdm_sdio.c @@ -31,11 +31,11 @@ #define MAX_NR_RX_BUF 4 #define SDU_TX_BUF_SIZE 2048 -#define TX_BUF_SIZE 2048 +#define TX_BUF_SIZE 2048 #define TX_CHUNK_SIZE (2048 - TYPE_A_HEADER_SIZE) -#define RX_BUF_SIZE (25*1024) +#define RX_BUF_SIZE (25*1024) -#define TX_HZ 2000 +#define TX_HZ 2000 #define TX_INTERVAL (1000000/TX_HZ) static int init_sdio(struct sdiowm_dev *sdev); @@ -127,10 +127,10 @@ static void put_rx_struct(struct rx_cxt *rx, struct sdio_rx *r) static int init_sdio(struct sdiowm_dev *sdev) { int ret = 0, i; - struct tx_cxt *tx = &sdev->tx; - struct rx_cxt *rx = &sdev->rx; - struct sdio_tx *t; - struct sdio_rx *r; + struct tx_cxt *tx = &sdev->tx; + struct rx_cxt *rx = &sdev->rx; + struct sdio_tx *t; + struct sdio_rx *r; INIT_LIST_HEAD(&tx->free_list); INIT_LIST_HEAD(&tx->sdu_list); diff --git a/drivers/staging/gdm72xx/gdm_sdio.h b/drivers/staging/gdm72xx/gdm_sdio.h index 216e98f31bae..0c0e2cbb727e 100644 --- a/drivers/staging/gdm72xx/gdm_sdio.h +++ b/drivers/staging/gdm72xx/gdm_sdio.h @@ -22,10 +22,8 @@ struct sdio_tx { struct list_head list; struct tx_cxt *tx_cxt; - - u8 *buf; - int len; - + u8 *buf; + int len; void (*callback)(void *cb_data); void *cb_data; }; @@ -35,18 +33,15 @@ struct tx_cxt { struct list_head sdu_list; struct list_head hci_list; struct timeval sdu_stamp; - - u8 *sdu_buf; - - spinlock_t lock; - int can_send; - int stop_sdu_tx; + u8 *sdu_buf; + spinlock_t lock; + int can_send; + int stop_sdu_tx; }; struct sdio_rx { struct list_head list; struct rx_cxt *rx_cxt; - void (*callback)(void *cb_data, void *data, int len); void *cb_data; }; @@ -54,18 +49,14 @@ struct sdio_rx { struct rx_cxt { struct list_head free_list; struct list_head req_list; - - u8 *rx_buf; - - spinlock_t lock; + u8 *rx_buf; + spinlock_t lock; }; struct sdiowm_dev { struct sdio_func *func; - - struct tx_cxt tx; - struct rx_cxt rx; - + struct tx_cxt tx; + struct rx_cxt rx; struct work_struct ws; }; diff --git a/drivers/staging/gdm72xx/gdm_usb.c b/drivers/staging/gdm72xx/gdm_usb.c index c7298d084611..c59a7a4be82f 100644 --- a/drivers/staging/gdm72xx/gdm_usb.c +++ b/drivers/staging/gdm72xx/gdm_usb.c @@ -27,6 +27,7 @@ MODULE_DEVICE_TABLE(usb, id_table); #define TX_BUF_SIZE 2048 + #if defined(CONFIG_WIMAX_GDM72XX_WIMAX2) #define RX_BUF_SIZE (128*1024) /* For packet aggregation */ #else @@ -166,10 +167,10 @@ static void put_rx_struct(struct rx_cxt *rx, struct usb_rx *r) static int init_usb(struct usbwm_dev *udev) { int ret = 0, i; - struct tx_cxt *tx = &udev->tx; - struct rx_cxt *rx = &udev->rx; - struct usb_tx *t; - struct usb_rx *r; + struct tx_cxt *tx = &udev->tx; + struct rx_cxt *rx = &udev->rx; + struct usb_tx *t; + struct usb_rx *r; unsigned long flags; INIT_LIST_HEAD(&tx->free_list); @@ -215,10 +216,10 @@ fail: static void release_usb(struct usbwm_dev *udev) { - struct tx_cxt *tx = &udev->tx; - struct rx_cxt *rx = &udev->rx; - struct usb_tx *t, *t_next; - struct usb_rx *r, *r_next; + struct tx_cxt *tx = &udev->tx; + struct rx_cxt *rx = &udev->rx; + struct usb_tx *t, *t_next; + struct usb_rx *r, *r_next; unsigned long flags; spin_lock_irqsave(&tx->lock, flags); diff --git a/drivers/staging/gdm72xx/gdm_usb.h b/drivers/staging/gdm72xx/gdm_usb.h index f2c54511bb96..30506529a8cc 100644 --- a/drivers/staging/gdm72xx/gdm_usb.h +++ b/drivers/staging/gdm72xx/gdm_usb.h @@ -28,12 +28,10 @@ struct usb_tx { struct list_head p_list; #endif struct tx_cxt *tx_cxt; - struct urb *urb; u8 *buf; - void (*callback)(void *cb_data); - void *cb_data; + void *cb_data; }; struct tx_cxt { @@ -43,17 +41,14 @@ struct tx_cxt { #if defined(CONFIG_WIMAX_GDM72XX_USB_PM) || defined(CONFIG_WIMAX_GDM72XX_K_MODE) struct list_head pending_list; #endif - spinlock_t lock; }; struct usb_rx { struct list_head list; struct rx_cxt *rx_cxt; - struct urb *urb; u8 *buf; - void (*callback)(void *cb_data, void *data, int len); void *cb_data; }; @@ -75,11 +70,9 @@ struct usbwm_dev { int bw_switch; struct list_head list; #endif - struct tx_cxt tx; struct rx_cxt rx; - - int padding; + int padding; }; #endif /* __GDM_USB_H__ */ diff --git a/drivers/staging/gdm72xx/gdm_wimax.c b/drivers/staging/gdm72xx/gdm_wimax.c index 094e9c9ee860..492bc78c250d 100644 --- a/drivers/staging/gdm72xx/gdm_wimax.c +++ b/drivers/staging/gdm72xx/gdm_wimax.c @@ -35,10 +35,10 @@ #define EVT_MAX_SIZE 2048 struct evt_entry { - struct list_head list; - struct net_device *dev; - char evt_data[EVT_MAX_SIZE]; - int size; + struct list_head list; + struct net_device *dev; + char evt_data[EVT_MAX_SIZE]; + int size; }; static void __gdm_wimax_event_send(struct work_struct *work); @@ -52,7 +52,6 @@ static struct { struct sock *sock; struct list_head evtq; spinlock_t evt_lock; - struct list_head freeq; struct work_struct ws; } wm_event; @@ -868,13 +867,13 @@ static void start_rx_proc(struct nic *nic) } static struct net_device_ops gdm_netdev_ops = { - .ndo_open = gdm_wimax_open, - .ndo_stop = gdm_wimax_close, - .ndo_set_config = gdm_wimax_set_config, - .ndo_start_xmit = gdm_wimax_tx, - .ndo_get_stats = gdm_wimax_stats, + .ndo_open = gdm_wimax_open, + .ndo_stop = gdm_wimax_close, + .ndo_set_config = gdm_wimax_set_config, + .ndo_start_xmit = gdm_wimax_tx, + .ndo_get_stats = gdm_wimax_stats, .ndo_set_mac_address = gdm_wimax_set_mac_addr, - .ndo_do_ioctl = gdm_wimax_ioctl, + .ndo_do_ioctl = gdm_wimax_ioctl, }; int register_wimax_device(struct phy_dev *phy_dev, struct device *pdev) diff --git a/drivers/staging/gdm72xx/gdm_wimax.h b/drivers/staging/gdm72xx/gdm_wimax.h index 21087c03ce3b..7e2c88877ed0 100644 --- a/drivers/staging/gdm72xx/gdm_wimax.h +++ b/drivers/staging/gdm72xx/gdm_wimax.h @@ -34,28 +34,23 @@ #define DB2H(x) __be32_to_cpu(x) struct phy_dev { - void *priv_dev; + void *priv_dev; struct net_device *netdev; - - int (*send_func)(void *priv_dev, void *data, int len, - void (*cb)(void *cb_data), void *cb_data); - int (*rcv_func)(void *priv_dev, - void (*cb)(void *cb_data, void *data, int len), - void *cb_data); + int (*send_func)(void *priv_dev, void *data, int len, + void (*cb)(void *cb_data), void *cb_data); + int (*rcv_func)(void *priv_dev, + void (*cb)(void *cb_data, void *data, int len), + void *cb_data); }; struct nic { struct net_device *netdev; struct phy_dev *phy_dev; - struct net_device_stats stats; - - struct data_s sdk_data[SIOC_DATA_MAX]; - + struct data_s sdk_data[SIOC_DATA_MAX]; #if defined(CONFIG_WIMAX_GDM72XX_QOS) - struct qos_cb_s qos; + struct qos_cb_s qos; #endif - }; int register_wimax_device(struct phy_dev *phy_dev, struct device *pdev); diff --git a/drivers/staging/gdm72xx/hci.h b/drivers/staging/gdm72xx/hci.h index 0e0676622f1d..2485a3799123 100644 --- a/drivers/staging/gdm72xx/hci.h +++ b/drivers/staging/gdm72xx/hci.h @@ -18,18 +18,18 @@ #define HCI_VALUE_OFFS (HCI_HEADER_SIZE) #define HCI_MAX_PACKET 2048 #define HCI_MAX_PARAM (HCI_MAX_PACKET-HCI_HEADER_SIZE) -#define HCI_MAX_TLV 32 +#define HCI_MAX_TLV 32 /* CMD-EVT */ /* Category 0 */ -#define WIMAX_RESET 0x0000 -#define WIMAX_SET_INFO 0x0001 -#define WIMAX_GET_INFO 0x0002 +#define WIMAX_RESET 0x0000 +#define WIMAX_SET_INFO 0x0001 +#define WIMAX_GET_INFO 0x0002 #define WIMAX_GET_INFO_RESULT 0x8003 -#define WIMAX_RADIO_OFF 0x0004 -#define WIMAX_RADIO_ON 0x0006 -#define WIMAX_WIMAX_RESET 0x0007 /* Is this still here */ +#define WIMAX_RADIO_OFF 0x0004 +#define WIMAX_RADIO_ON 0x0006 +#define WIMAX_WIMAX_RESET 0x0007 /* Is this still here */ /* Category 1 */ #define WIMAX_NET_ENTRY 0x0100 @@ -40,26 +40,22 @@ #define WIMAX_EXIT_IDLE 0x0106 #define WIMAX_MODE_CHANGE 0x8108 #define WIMAX_HANDOVER 0x8109 /* obsolete */ - -#define WIMAX_SCAN 0x010d +#define WIMAX_SCAN 0x010d #define WIMAX_SCAN_COMPLETE 0x810e #define WIMAX_SCAN_RESULT 0x810f - #define WIMAX_CONNECT 0x0110 #define WIMAX_CONNECT_START 0x8111 -#define WIMAX_CONNECT_COMPLETE 0x8112 +#define WIMAX_CONNECT_COMPLETE 0x8112 #define WIMAX_ASSOC_START 0x8113 -#define WIMAX_ASSOC_COMPLETE 0x8114 +#define WIMAX_ASSOC_COMPLETE 0x8114 #define WIMAX_DISCONN_IND 0x8115 #define WIMAX_ENTRY_IND 0x8116 #define WIMAX_HO_START 0x8117 #define WIMAX_HO_COMPLETE 0x8118 -#define WIMAX_RADIO_STATE_IND 0x8119 +#define WIMAX_RADIO_STATE_IND 0x8119 #define WIMAX_IP_RENEW_IND 0x811a - -#define WIMAX_DISCOVER_NSP 0x011d +#define WIMAX_DISCOVER_NSP 0x011d #define WIMAX_DISCOVER_NSP_RESULT 0x811e - #define WIMAX_SDU_TX_FLOW 0x8125 /* Category 2 */ @@ -71,34 +67,33 @@ #define WIMAX_TX_SDU_AGGR 0x0205 /* Category 3 */ -#define WIMAX_DM_CMD 0x030a -#define WIMAX_DM_RSP 0x830b - -#define WIMAX_CLI_CMD 0x030c -#define WIMAX_CLI_RSP 0x830d +#define WIMAX_DM_CMD 0x030a +#define WIMAX_DM_RSP 0x830b -#define WIMAX_DL_IMAGE 0x0310 -#define WIMAX_DL_IMAGE_STATUS 0x8311 -#define WIMAX_UL_IMAGE 0x0312 -#define WIMAX_UL_IMAGE_RESULT 0x8313 -#define WIMAX_UL_IMAGE_STATUS 0x0314 +#define WIMAX_CLI_CMD 0x030c +#define WIMAX_CLI_RSP 0x830d -#define WIMAX_EVT_MODEM_REPORT 0x8325 +#define WIMAX_DL_IMAGE 0x0310 +#define WIMAX_DL_IMAGE_STATUS 0x8311 +#define WIMAX_UL_IMAGE 0x0312 +#define WIMAX_UL_IMAGE_RESULT 0x8313 +#define WIMAX_UL_IMAGE_STATUS 0x0314 +#define WIMAX_EVT_MODEM_REPORT 0x8325 /* Category 0xF */ -#define WIMAX_FSM_UPDATE 0x8F01 -#define WIMAX_IF_UPDOWN 0x8F02 - #define WIMAX_IF_UP 1 - #define WIMAX_IF_DOWN 2 +#define WIMAX_FSM_UPDATE 0x8F01 +#define WIMAX_IF_UPDOWN 0x8F02 +#define WIMAX_IF_UP 1 +#define WIMAX_IF_DOWN 2 /* WIMAX mode */ -#define W_NULL 0 -#define W_STANDBY 1 -#define W_OOZ 2 -#define W_AWAKE 3 -#define W_IDLE 4 -#define W_SLEEP 5 -#define W_WAIT 6 +#define W_NULL 0 +#define W_STANDBY 1 +#define W_OOZ 2 +#define W_AWAKE 3 +#define W_IDLE 4 +#define W_SLEEP 5 +#define W_WAIT 6 #define W_NET_ENTRY_RNG 0x80 #define W_NET_ENTRY_SBC 0x81 @@ -113,8 +108,8 @@ #define W_NET_ENTRY_DSX_FAIL 0x1104000 /* Scan Type */ -#define W_SCAN_ALL_CHANNEL 0 -#define W_SCAN_ALL_SUBSCRIPTION 1 +#define W_SCAN_ALL_CHANNEL 0 +#define W_SCAN_ALL_SUBSCRIPTION 1 #define W_SCAN_SPECIFIED_SUBSCRIPTION 2 /* @@ -126,7 +121,7 @@ * */ #define TLV_L(x) (((x) >> 16) & 0xff) -#define TLV_T(x) ((x) & 0xff) +#define TLV_T(x) ((x) & 0xff) #define TLV_COMPOSITE(x) ((x) >> 31) /* GENERAL */ @@ -141,7 +136,6 @@ #define T_OOZ_SCAN_INTERVAL (0x08 | (4 << 16)) #define T_IMEI (0x09 | (8 << 16)) #define T_PID (0x0a | (12 << 16)) - #define T_CAPABILITY (0x1a | (4 << 16)) #define T_RELEASE_NUMBER (0x1b | (4 << 16)) #define T_DRIVER_REVISION (0x1c | (4 << 16)) @@ -150,19 +144,16 @@ #define T_PHY_HW_REVISION (0x1f | (4 << 16)) /* HANDOVER */ -#define T_SCAN_INTERVAL (0x20 | (1 << 16)) - +#define T_SCAN_INTERVAL (0x20 | (1 << 16)) #define T_RSC_RETAIN_TIME (0x2f | (2 << 16)) /* SLEEP */ #define T_TYPE1_ISW (0x40 | (1 << 16)) - #define T_SLP_START_TO (0x4a | (2 << 16)) /* IDLE */ #define T_IDLE_MODE_TO (0x50 | (2 << 16)) - -#define T_IDLE_START_TO (0x54 | (2 << 16)) +#define T_IDLE_START_TO (0x54 | (2 << 16)) /* MONITOR */ #define T_RSSI (0x60 | (1 << 16)) @@ -180,7 +171,7 @@ #define T_CS_TYPE (0xa6 | (2 << 16)) #define T_VENDOR_NAME (0xa7 | (0 << 16)) #define T_MOD_NAME (0xa8 | (0 << 16)) -#define T_PACKET_FILTER (0xa9 | (1 << 16)) +#define T_PACKET_FILTER (0xa9 | (1 << 16)) #define T_NSP_CHANGE_COUNT (0xaa | (4 << 16)) #define T_RADIO_STATE (0xab | (1 << 16)) #define T_URI_CONTACT_TYPE (0xac | (1 << 16)) diff --git a/drivers/staging/gdm72xx/usb_ids.h b/drivers/staging/gdm72xx/usb_ids.h index b34616b7203f..1a61b3599765 100644 --- a/drivers/staging/gdm72xx/usb_ids.h +++ b/drivers/staging/gdm72xx/usb_ids.h @@ -29,7 +29,7 @@ .idVendor = (vend), .idProduct = (prod), .bInterfaceClass = (intf) #define EMERGENCY_PID 0x720f -#define BL_PID_MASK 0xffc0 +#define BL_PID_MASK 0xffc0 #define USB_DEVICE_BOOTLOADER(vid, pid) \ {USB_DEVICE((vid), ((pid)&BL_PID_MASK)|B_DOWNLOAD)}, \ diff --git a/drivers/staging/gdm72xx/wm_ioctl.h b/drivers/staging/gdm72xx/wm_ioctl.h index 9f46e06f2303..d022c6ca0e23 100644 --- a/drivers/staging/gdm72xx/wm_ioctl.h +++ b/drivers/staging/gdm72xx/wm_ioctl.h @@ -19,10 +19,10 @@ #define NETLINK_WIMAX 31 -#define SIOCWMIOCTL SIOCDEVPRIVATE +#define SIOCWMIOCTL SIOCDEVPRIVATE -#define SIOCG_DATA 0x8D10 -#define SIOCS_DATA 0x8D11 +#define SIOCG_DATA 0x8D10 +#define SIOCS_DATA 0x8D11 enum { SIOC_DATA_FSM, @@ -34,7 +34,7 @@ enum { SIOC_DATA_END }; -#define SIOC_DATA_MAX 16 +#define SIOC_DATA_MAX 16 /* FSM */ enum { @@ -67,23 +67,21 @@ enum { }; struct fsm_s { - int m_status; /*main status*/ - int c_status; /*connection status*/ - int d_status; /*oma-dm status*/ + int m_status; /*main status*/ + int c_status; /*connection status*/ + int d_status; /*oma-dm status*/ }; struct data_s { - int size; + int size; void *buf; }; struct wm_req_s { union { - char ifrn_name[IFNAMSIZ]; + char ifrn_name[IFNAMSIZ]; } ifr_ifrn; - unsigned short cmd; - unsigned short data_id; struct data_s data; @@ -91,7 +89,7 @@ struct wm_req_s { }; #ifndef ifr_name -#define ifr_name ifr_ifrn.ifrn_name +#define ifr_name ifr_ifrn.ifrn_name #endif #endif -- cgit v1.2.3 From 8a637aa5503327e24cac792c4195c1fb9e02c196 Mon Sep 17 00:00:00 2001 From: Michalis Pappas Date: Fri, 9 May 2014 18:08:29 +0800 Subject: staging: gdm72xx: Remove task from TODO list Removed line related to replacement of kernel_thread with kthread, as issue was fixed on ff5e4a1d2702 ('Staging: gdm72xx: gdm_usb: fix deprecated function kernel_thread') Signed-off-by: Michalis Pappas Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm72xx/TODO | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/gdm72xx/TODO b/drivers/staging/gdm72xx/TODO index 5ab27fb29594..62d0cd6225c8 100644 --- a/drivers/staging/gdm72xx/TODO +++ b/drivers/staging/gdm72xx/TODO @@ -1,3 +1,2 @@ TODO: -- Replace kernel_thread with kthread in gdm_usb.c - Clean up coding style to meet kernel standard. -- cgit v1.2.3 From abeb935f11e1b5c891456e5f567b65422ea87952 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Fri, 16 May 2014 08:08:53 -0400 Subject: staging: dgap: Add Mark Hounschell to maintainers list for dgap Add Mark Hounschell to the MAINTAINERs list for the dgap driver Signed-off-by: Mark Hounschell Suggested-by: Dan Carpenter Cc: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 610c982af198..0de64a5fff58 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2796,6 +2796,7 @@ F: drivers/staging/dgnc/ DIGI EPCA PCI PRODUCTS M: Lidza Louina +M: Mark Hounschell L: driverdev-devel@linuxdriverproject.org S: Maintained F: drivers/staging/dgap/ -- cgit v1.2.3 From 077c28f8c2f6d375bb7927c1f909df810776647b Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 23 Apr 2014 10:33:44 -0400 Subject: staging: dgap: Fix how we insure config data is a string This patch changes the way we insure the config data is a string. Clearly this was just wrong. After a certain number of loads/unloads various OOPs were generated indicating something other than this driver had a problem. It was this driver. Signed-off-by: Mark Hounschell Tested-by: Mark Hounschell Reported-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 3c9278a224e2..e0b8d0f051cc 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -834,7 +834,7 @@ static int dgap_firmware_load(struct pci_dev *pdev, int card_type) return ret; } - dgap_config_buf = kmalloc(fw->size + 1, GFP_KERNEL); + dgap_config_buf = kzalloc(fw->size + 1, GFP_KERNEL); if (!dgap_config_buf) { release_firmware(fw); return -ENOMEM; @@ -842,7 +842,6 @@ static int dgap_firmware_load(struct pci_dev *pdev, int card_type) memcpy(dgap_config_buf, fw->data, fw->size); release_firmware(fw); - dgap_config_buf[fw->size + 1] = '\0'; if (dgap_parsefile(&dgap_config_buf, TRUE) != 0) { kfree(dgap_config_buf); -- cgit v1.2.3 From 23aa2ad4a6281a43a3836bfeac006d03a4a361a0 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 23 Apr 2014 10:33:45 -0400 Subject: staging: dgap: Fix BUG in processing config file This patch fixes an OOPS caused by a pointer being changed between the malloc and free. Signed-off-by: Mark Hounschell Tested-by: Mark Hounschell Reported-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index e0b8d0f051cc..55a23b051e86 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -820,6 +820,7 @@ static int dgap_firmware_load(struct pci_dev *pdev, int card_type) { struct board_t *brd = dgap_Board[dgap_NumBoards - 1]; const struct firmware *fw; + char *tmp_ptr; int ret; dgap_get_vpd(brd); @@ -843,7 +844,14 @@ static int dgap_firmware_load(struct pci_dev *pdev, int card_type) memcpy(dgap_config_buf, fw->data, fw->size); release_firmware(fw); - if (dgap_parsefile(&dgap_config_buf, TRUE) != 0) { + /* + * preserve dgap_config_buf + * as dgap_parsefile would + * otherwise alter it. + */ + tmp_ptr = dgap_config_buf; + + if (dgap_parsefile(&tmp_ptr, TRUE) != 0) { kfree(dgap_config_buf); return -EINVAL; } -- cgit v1.2.3 From b6339d023025cb94cf5e39f3edb0d7db3b21077f Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 23 Apr 2014 15:43:07 -0400 Subject: staging: dgap: fix sparse warnings for re_map_membase and re_map_port This patch fixes sparse warnings for the re_map_membase and re_map_port variables. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 24 ++++++++++++------------ drivers/staging/dgap/dgap.h | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 55a23b051e86..38db01a75c14 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -1300,7 +1300,7 @@ static int dgap_tty_init(struct board_t *brd) int i; int tlw; uint true_count = 0; - u8 *vaddr; + u8 __iomem *vaddr; u8 modem = 0; struct channel_t *ch; struct bs_t *bs; @@ -4310,7 +4310,7 @@ static int dgap_tty_register_ports(struct board_t *brd) */ static void dgap_do_bios_load(struct board_t *brd, const u8 *ubios, int len) { - u8 *addr; + u8 __iomem *addr; uint offset; int i; @@ -4343,7 +4343,7 @@ static void dgap_do_bios_load(struct board_t *brd, const u8 *ubios, int len) */ static int dgap_test_bios(struct board_t *brd) { - u8 *addr; + u8 __iomem *addr; u16 word; u16 err1; u16 err2; @@ -4386,7 +4386,7 @@ static int dgap_test_bios(struct board_t *brd) */ static void dgap_do_fep_load(struct board_t *brd, const u8 *ufep, int len) { - u8 *addr; + u8 __iomem *addr; uint offset; if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) @@ -4430,7 +4430,7 @@ static void dgap_do_fep_load(struct board_t *brd, const u8 *ufep, int len) */ static int dgap_test_fep(struct board_t *brd) { - u8 *addr; + u8 __iomem *addr; u16 word; u16 err1; u16 err2; @@ -4529,7 +4529,7 @@ static void dgap_do_reset_board(struct board_t *brd) */ static void dgap_do_conc_load(struct board_t *brd, u8 *uaddr, int len) { - char *vaddr; + char __iomem *vaddr; u16 offset = 0; struct downld_t *to_dp; @@ -4667,7 +4667,7 @@ static void dgap_poll_tasklet(unsigned long data) { struct board_t *bd = (struct board_t *) data; ulong lock_flags; - char *vaddr; + char __iomem *vaddr; u16 head, tail; if (!bd || (bd->magic != DGAP_BOARD_MAGIC)) @@ -4743,7 +4743,7 @@ out: static void dgap_cmdb(struct channel_t *ch, u8 cmd, u8 byte1, u8 byte2, uint ncmds) { - char *vaddr = NULL; + char __iomem *vaddr; struct cm_t *cm_addr = NULL; uint count; uint n; @@ -4828,7 +4828,7 @@ static void dgap_cmdb(struct channel_t *ch, u8 cmd, u8 byte1, *=======================================================================*/ static void dgap_cmdw(struct channel_t *ch, u8 cmd, u16 word, uint ncmds) { - char *vaddr = NULL; + char __iomem *vaddr; struct cm_t *cm_addr = NULL; uint count; uint n; @@ -4911,7 +4911,7 @@ static void dgap_cmdw(struct channel_t *ch, u8 cmd, u16 word, uint ncmds) *=======================================================================*/ static void dgap_cmdw_ext(struct channel_t *ch, u16 cmd, u16 word, uint ncmds) { - char *vaddr = NULL; + char __iomem *vaddr; struct cm_t *cm_addr = NULL; uint count; uint n; @@ -5058,7 +5058,7 @@ static void dgap_wmove(struct channel_t *ch, char *buf, uint cnt) */ static uint dgap_get_custom_baud(struct channel_t *ch) { - u8 *vaddr; + u8 __iomem *vaddr; ulong offset = 0; uint value = 0; @@ -5580,7 +5580,7 @@ static int dgap_event(struct board_t *bd) ulong lock_flags2; struct bs_t *bs; u8 *event; - u8 *vaddr = NULL; + u8 __iomem *vaddr; struct ev_t *eaddr = NULL; uint head; uint tail; diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h index b23570bd183d..72b3d0c29e1e 100644 --- a/drivers/staging/dgap/dgap.h +++ b/drivers/staging/dgap/dgap.h @@ -571,8 +571,8 @@ struct board_t { ulong membase; /* Start of base memory of the card */ ulong membase_end; /* End of base memory of the card */ - u8 *re_map_port; /* Remapped io port of the card */ - u8 *re_map_membase;/* Remapped memory of the card */ + u8 __iomem *re_map_port; /* Remapped io port of the card */ + u8 __iomem *re_map_membase;/* Remapped memory of the card */ u8 runwait; /* # Processes waiting for FEP */ u8 inhibit_poller; /* Tells the poller to leave us alone */ -- cgit v1.2.3 From 405b26d92d085154ba9f68d160d21e9d35a5e0f2 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 23 Apr 2014 16:25:27 -0400 Subject: staging: dgap: fix sparse warnings for the entire bs_t structure This patch fixes sparse warnings for the entire bs_t structure This entire structure defines a hardware segment Signed-off-by: Mark Hounschell Tested-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 22 +++++++++++----------- drivers/staging/dgap/dgap.h | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 38db01a75c14..0bf22f7b3c74 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -1303,7 +1303,7 @@ static int dgap_tty_init(struct board_t *brd) u8 __iomem *vaddr; u8 modem = 0; struct channel_t *ch; - struct bs_t *bs; + struct bs_t __iomem *bs; struct cm_t *cm; if (!brd) @@ -1635,7 +1635,7 @@ static void dgap_sniff_nowait_nolock(struct channel_t *ch, u8 *text, static void dgap_input(struct channel_t *ch) { struct board_t *bd; - struct bs_t *bs; + struct bs_t __iomem *bs; struct tty_struct *tp; struct tty_ldisc *ld; uint rmask; @@ -1962,7 +1962,7 @@ static int dgap_tty_open(struct tty_struct *tty, struct file *file) struct board_t *brd; struct channel_t *ch; struct un_t *un; - struct bs_t *bs; + struct bs_t __iomem *bs; uint major = 0; uint minor = 0; int rc = 0; @@ -2416,7 +2416,7 @@ static int dgap_tty_chars_in_buffer(struct tty_struct *tty) struct board_t *bd = NULL; struct channel_t *ch = NULL; struct un_t *un = NULL; - struct bs_t *bs = NULL; + struct bs_t __iomem *bs; u8 tbusy; uint chars = 0; u16 thead, ttail, tmask, chead, ctail; @@ -2507,7 +2507,7 @@ static int dgap_wait_for_drain(struct tty_struct *tty) { struct channel_t *ch; struct un_t *un; - struct bs_t *bs; + struct bs_t __iomem *bs; int ret = -EIO; uint count = 1; ulong lock_flags = 0; @@ -2618,7 +2618,7 @@ static int dgap_maxcps_room(struct tty_struct *tty, int bytes_available) static inline void dgap_set_firmware_event(struct un_t *un, unsigned int event) { struct channel_t *ch = NULL; - struct bs_t *bs = NULL; + struct bs_t __iomem *bs = NULL; if (!un || un->magic != DGAP_UNIT_MAGIC) return; @@ -2652,7 +2652,7 @@ static int dgap_tty_write_room(struct tty_struct *tty) { struct channel_t *ch = NULL; struct un_t *un = NULL; - struct bs_t *bs = NULL; + struct bs_t __iomem *bs; u16 head, tail, tmask; int ret = 0; ulong lock_flags = 0; @@ -2741,7 +2741,7 @@ static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, { struct channel_t *ch = NULL; struct un_t *un = NULL; - struct bs_t *bs = NULL; + struct bs_t __iomem *bs; char *vaddr = NULL; u16 head, tail, tmask, remain; int bufcount = 0, n = 0; @@ -5006,7 +5006,7 @@ static void dgap_wmove(struct channel_t *ch, char *buf, uint cnt) { int n; char *taddr; - struct bs_t *bs; + struct bs_t __iomem *bs; u16 head; if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) @@ -5125,7 +5125,7 @@ static int dgap_param(struct tty_struct *tty) struct ktermios *ts; struct board_t *bd; struct channel_t *ch; - struct bs_t *bs; + struct bs_t __iomem *bs; struct un_t *un; u16 head; u16 cflag; @@ -5578,7 +5578,7 @@ static int dgap_event(struct board_t *bd) struct channel_t *ch; ulong lock_flags; ulong lock_flags2; - struct bs_t *bs; + struct bs_t __iomem *bs; u8 *event; u8 __iomem *vaddr; struct ev_t *eaddr = NULL; diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h index 72b3d0c29e1e..8d75d32faa1b 100644 --- a/drivers/staging/dgap/dgap.h +++ b/drivers/staging/dgap/dgap.h @@ -593,7 +593,7 @@ struct board_t { u32 dgap_Serial_Major; u32 dgap_TransparentPrint_Major; - struct bs_t *bd_bs; /* Base structure pointer */ + struct bs_t __iomem *bd_bs; /* Base structure pointer */ char *flipbuf; /* Our flip buffer, alloced if */ /* board is found */ @@ -968,7 +968,7 @@ struct digi_cmd { ************************************************************************/ struct channel_t { int magic; /* Channel Magic Number */ - struct bs_t *ch_bs; /* Base structure pointer */ + struct bs_t __iomem *ch_bs; /* Base structure pointer */ struct cm_t *ch_cm; /* Command queue pointer */ struct board_t *ch_bd; /* Board structure pointer */ unsigned char *ch_vaddr; /* FEP memory origin */ -- cgit v1.2.3 From 6a30cddba4d2415cc41cd7db30d79122490a224d Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 23 Apr 2014 16:43:21 -0400 Subject: staging: dgap: fix sparse warnings for the entire cm_t structure This patch fixes sparse warnings for the entire cm_t structure This entire structure defines a hardware segment Signed-off-by: Mark Hounschell Tested-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 8 ++++---- drivers/staging/dgap/dgap.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 0bf22f7b3c74..1e7f40eff90b 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -1304,7 +1304,7 @@ static int dgap_tty_init(struct board_t *brd) u8 modem = 0; struct channel_t *ch; struct bs_t __iomem *bs; - struct cm_t *cm; + struct cm_t __iomem *cm; if (!brd) return -ENXIO; @@ -4744,7 +4744,7 @@ static void dgap_cmdb(struct channel_t *ch, u8 cmd, u8 byte1, u8 byte2, uint ncmds) { char __iomem *vaddr; - struct cm_t *cm_addr = NULL; + struct __iomem cm_t *cm_addr; uint count; uint n; u16 head; @@ -4829,7 +4829,7 @@ static void dgap_cmdb(struct channel_t *ch, u8 cmd, u8 byte1, static void dgap_cmdw(struct channel_t *ch, u8 cmd, u16 word, uint ncmds) { char __iomem *vaddr; - struct cm_t *cm_addr = NULL; + struct __iomem cm_t *cm_addr; uint count; uint n; u16 head; @@ -4912,7 +4912,7 @@ static void dgap_cmdw(struct channel_t *ch, u8 cmd, u16 word, uint ncmds) static void dgap_cmdw_ext(struct channel_t *ch, u16 cmd, u16 word, uint ncmds) { char __iomem *vaddr; - struct cm_t *cm_addr = NULL; + struct __iomem cm_t *cm_addr; uint count; uint n; u16 head; diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h index 8d75d32faa1b..e8bb8c630cc8 100644 --- a/drivers/staging/dgap/dgap.h +++ b/drivers/staging/dgap/dgap.h @@ -969,7 +969,7 @@ struct digi_cmd { struct channel_t { int magic; /* Channel Magic Number */ struct bs_t __iomem *ch_bs; /* Base structure pointer */ - struct cm_t *ch_cm; /* Command queue pointer */ + struct cm_t __iomem *ch_cm; /* Command queue pointer */ struct board_t *ch_bd; /* Board structure pointer */ unsigned char *ch_vaddr; /* FEP memory origin */ unsigned char *ch_taddr; /* Write buffer origin */ -- cgit v1.2.3 From 630b2abf9cee48d5db766a4241caa0132b92de09 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Thu, 24 Apr 2014 09:22:12 -0400 Subject: staging: dgap: fix a few misc sparse warnings This patch fixes a few misc sparse warnings related to __iomem Signed-off-by: Mark Hounschell Tested-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 20 ++++++++++---------- drivers/staging/dgap/dgap.h | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 1e7f40eff90b..67e4adf1dbab 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -1365,8 +1365,8 @@ static int dgap_tty_init(struct board_t *brd) ch = brd->channels[0]; vaddr = brd->re_map_membase; - bs = (struct bs_t *) ((ulong) vaddr + CHANBUF); - cm = (struct cm_t *) ((ulong) vaddr + CMDBUF); + bs = (struct bs_t __iomem *) ((ulong) vaddr + CHANBUF); + cm = (struct cm_t __iomem *) ((ulong) vaddr + CMDBUF); brd->bd_bs = bs; @@ -1786,7 +1786,7 @@ static void dgap_input(struct channel_t *ch) if (s <= 0) break; - memcpy_fromio(buf, (char *) ch->ch_raddr + tail, s); + memcpy_fromio(buf, ch->ch_raddr + tail, s); dgap_sniff_nowait_nolock(ch, "USER READ", buf, s); tail += s; @@ -2742,7 +2742,7 @@ static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, struct channel_t *ch = NULL; struct un_t *un = NULL; struct bs_t __iomem *bs; - char *vaddr = NULL; + char __iomem *vaddr; u16 head, tail, tmask, remain; int bufcount = 0, n = 0; int orig_count = 0; @@ -4935,7 +4935,7 @@ static void dgap_cmdw_ext(struct channel_t *ch, u16 cmd, u16 word, uint ncmds) if (!vaddr) return; - cm_addr = (struct cm_t *) (vaddr + CMDBUF); + cm_addr = (struct cm_t __iomem *) (vaddr + CMDBUF); head = readw(&(cm_addr->cm_head)); /* @@ -4951,19 +4951,19 @@ static void dgap_cmdw_ext(struct channel_t *ch, u16 cmd, u16 word, uint ncmds) */ /* Write an FF to tell the FEP that we want an extended command */ - writeb((u8) 0xff, (char *) (vaddr + head + CMDSTART + 0)); + writeb((u8) 0xff, (vaddr + head + CMDSTART + 0)); - writeb((u8) ch->ch_portnum, (u8 *) (vaddr + head + CMDSTART + 1)); - writew((u16) cmd, (char *) (vaddr + head + CMDSTART + 2)); + writeb((u8) ch->ch_portnum, (vaddr + head + CMDSTART + 1)); + writew((u16) cmd, (vaddr + head + CMDSTART + 2)); /* * If the second part of the command won't fit, * put it at the beginning of the circular buffer. */ if (((head + 4) >= ((CMDMAX - CMDSTART)) || (head & 03))) - writew((u16) word, (char *) (vaddr + CMDSTART)); + writew((u16) word, (vaddr + CMDSTART)); else - writew((u16) word, (char *) (vaddr + head + CMDSTART + 4)); + writew((u16) word, (vaddr + head + CMDSTART + 4)); head = (head + 8) & (CMDMAX - CMDSTART - 4); diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h index e8bb8c630cc8..2bbb51ff12f4 100644 --- a/drivers/staging/dgap/dgap.h +++ b/drivers/staging/dgap/dgap.h @@ -971,9 +971,9 @@ struct channel_t { struct bs_t __iomem *ch_bs; /* Base structure pointer */ struct cm_t __iomem *ch_cm; /* Command queue pointer */ struct board_t *ch_bd; /* Board structure pointer */ - unsigned char *ch_vaddr; /* FEP memory origin */ - unsigned char *ch_taddr; /* Write buffer origin */ - unsigned char *ch_raddr; /* Read buffer origin */ + u8 __iomem *ch_vaddr; /* FEP memory origin */ + u8 __iomem *ch_taddr; /* Write buffer origin */ + u8 __iomem *ch_raddr; /* Read buffer origin */ struct digi_t ch_digi; /* Transparent Print structure */ struct un_t ch_tun; /* Terminal unit info */ struct un_t ch_pun; /* Printer unit info */ -- cgit v1.2.3 From 45c44ddd0158ba2219c48ce48fe60f3a33b933bd Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Thu, 24 Apr 2014 10:33:58 -0400 Subject: staging: dgap: fix sparse warning about dgap_poll_lock This patch fixes a sparse warning: warning: symbol 'dgap_poll_lock' was not declared. Should it be static? Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 67e4adf1dbab..54ce657d6f37 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -226,7 +226,7 @@ static uint dgap_count = 500; /* * Poller stuff */ -DEFINE_SPINLOCK(dgap_poll_lock); /* Poll scheduling lock */ +static DEFINE_SPINLOCK(dgap_poll_lock); /* Poll scheduling lock */ static ulong dgap_poll_time; /* Time of next poll */ static uint dgap_poll_stop; /* Used to tell poller to stop */ static struct timer_list dgap_poll_timer; -- cgit v1.2.3 From 8f5879c4953673070a72ed88d9189b7c8ccc30d5 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Thu, 24 Apr 2014 10:41:44 -0400 Subject: staging: dgap: fix sparse warnings Using plain integer as NULL pointer This patch fixes sparse warnings: warning: Using plain integer as NULL pointer Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 54ce657d6f37..390a3359f39c 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -318,22 +318,22 @@ struct firmware_info { * Firmware - BIOS, FEP, and CONC filenames */ static struct firmware_info fw_info[] = { - { "dgap/dgap.conf", "dgap/sxbios.bin", "dgap/sxfep.bin", 0, 0 }, - { "dgap/dgap.conf", "dgap/cxpbios.bin", "dgap/cxpfep.bin", 0, 1 }, - { "dgap/dgap.conf", "dgap/cxpbios.bin", "dgap/cxpfep.bin", 0, 2 }, - { "dgap/dgap.conf", "dgap/pcibios.bin", "dgap/pcifep.bin", 0, 3 }, - { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", 0, 4 }, - { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", 0, 5 }, - { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", 0, 6 }, - { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", 0, 7 }, - { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", 0, 8 }, - { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", 0, 9 }, - { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", 0, 10 }, - { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", 0, 11 }, - { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", 0, 12 }, - { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", 0, 13 }, - { "dgap/dgap.conf", "dgap/sxbios.bin", "dgap/sxfep.bin", 0, 14 }, - {0,} + { "dgap/dgap.conf", "dgap/sxbios.bin", "dgap/sxfep.bin", NULL, 0 }, + { "dgap/dgap.conf", "dgap/cxpbios.bin", "dgap/cxpfep.bin", NULL, 1 }, + { "dgap/dgap.conf", "dgap/cxpbios.bin", "dgap/cxpfep.bin", NULL, 2 }, + { "dgap/dgap.conf", "dgap/pcibios.bin", "dgap/pcifep.bin", NULL, 3 }, + { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", NULL, 4 }, + { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", NULL, 5 }, + { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", NULL, 6 }, + { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", NULL, 7 }, + { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", NULL, 8 }, + { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", NULL, 9 }, + { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", NULL, 10 }, + { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", NULL, 11 }, + { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", NULL, 12 }, + { "dgap/dgap.conf", "dgap/xrbios.bin", "dgap/xrfep.bin", NULL, 13 }, + { "dgap/dgap.conf", "dgap/sxbios.bin", "dgap/sxfep.bin", NULL, 14 }, + {NULL,} }; /* -- cgit v1.2.3 From cacaf1045cc45648cb7b19542b3d8a0a7057c37a Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Fri, 25 Apr 2014 10:00:42 -0400 Subject: staging: dgap: fix a few more sparse warnings This patch fixes a few more sparse warnings related to __iomem version 2 excludes a change that actually caused a new sparse warning. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 390a3359f39c..3b732380f9e6 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -4406,7 +4406,8 @@ static void dgap_do_fep_load(struct board_t *brd, const u8 *ufep, int len) */ if ((brd->type == PCX) || (brd->type == PEPC)) { u8 string[100]; - u8 *config, *xconfig; + u8 __iomem *config; + u8 *xconfig; int i = 0; xconfig = dgap_create_config_string(brd, string); @@ -4685,7 +4686,7 @@ static void dgap_poll_tasklet(unsigned long data) */ if (bd->state == BOARD_READY) { - struct ev_t *eaddr = NULL; + struct ev_t __iomem *eaddr; if (!bd->re_map_membase) { spin_unlock_irqrestore(&bd->bd_lock, lock_flags); @@ -4699,7 +4700,7 @@ static void dgap_poll_tasklet(unsigned long data) if (!bd->nasync) goto out; - eaddr = (struct ev_t *) (vaddr + EVBUF); + eaddr = (struct ev_t __iomem *) (vaddr + EVBUF); /* Get our head and tail */ head = readw(&(eaddr->ev_head)); @@ -4768,7 +4769,7 @@ static void dgap_cmdb(struct channel_t *ch, u8 cmd, u8 byte1, if (!vaddr) return; - cm_addr = (struct cm_t *) (vaddr + CMDBUF); + cm_addr = (struct cm_t __iomem *) (vaddr + CMDBUF); head = readw(&(cm_addr->cm_head)); /* @@ -4782,10 +4783,10 @@ static void dgap_cmdb(struct channel_t *ch, u8 cmd, u8 byte1, /* * Put the data in the circular command buffer. */ - writeb(cmd, (char *) (vaddr + head + CMDSTART + 0)); - writeb((u8) ch->ch_portnum, (char *) (vaddr + head + CMDSTART + 1)); - writeb(byte1, (char *) (vaddr + head + CMDSTART + 2)); - writeb(byte2, (char *) (vaddr + head + CMDSTART + 3)); + writeb(cmd, (vaddr + head + CMDSTART + 0)); + writeb((u8) ch->ch_portnum, (vaddr + head + CMDSTART + 1)); + writeb(byte1, (vaddr + head + CMDSTART + 2)); + writeb(byte2, (vaddr + head + CMDSTART + 3)); head = (head + 4) & (CMDMAX - CMDSTART - 4); @@ -4852,7 +4853,7 @@ static void dgap_cmdw(struct channel_t *ch, u8 cmd, u16 word, uint ncmds) if (!vaddr) return; - cm_addr = (struct cm_t *) (vaddr + CMDBUF); + cm_addr = (struct cm_t __iomem *) (vaddr + CMDBUF); head = readw(&(cm_addr->cm_head)); /* @@ -4866,9 +4867,9 @@ static void dgap_cmdw(struct channel_t *ch, u8 cmd, u16 word, uint ncmds) /* * Put the data in the circular command buffer. */ - writeb(cmd, (char *) (vaddr + head + CMDSTART + 0)); - writeb((u8) ch->ch_portnum, (char *) (vaddr + head + CMDSTART + 1)); - writew((u16) word, (char *) (vaddr + head + CMDSTART + 2)); + writeb(cmd, (vaddr + head + CMDSTART + 0)); + writeb((u8) ch->ch_portnum, (vaddr + head + CMDSTART + 1)); + writew((u16) word, (vaddr + head + CMDSTART + 2)); head = (head + 4) & (CMDMAX - CMDSTART - 4); @@ -5005,7 +5006,7 @@ static void dgap_cmdw_ext(struct channel_t *ch, u16 cmd, u16 word, uint ncmds) static void dgap_wmove(struct channel_t *ch, char *buf, uint cnt) { int n; - char *taddr; + char __iomem *taddr; struct bs_t __iomem *bs; u16 head; @@ -5059,7 +5060,7 @@ static void dgap_wmove(struct channel_t *ch, char *buf, uint cnt) static uint dgap_get_custom_baud(struct channel_t *ch) { u8 __iomem *vaddr; - ulong offset = 0; + ulong offset; uint value = 0; if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) @@ -5080,7 +5081,7 @@ static uint dgap_get_custom_baud(struct channel_t *ch) * Go get from fep mem, what the fep * believes the custom baud rate is. */ - offset = ((((*(unsigned short *)(vaddr + ECS_SEG)) << 4) + + offset = ((((*(unsigned short __iomem *)(vaddr + ECS_SEG)) << 4) + (ch->ch_portnum * 0x28) + LINE_SPEED)); value = readw(vaddr + offset); @@ -5579,9 +5580,9 @@ static int dgap_event(struct board_t *bd) ulong lock_flags; ulong lock_flags2; struct bs_t __iomem *bs; - u8 *event; + u8 __iomem *event; u8 __iomem *vaddr; - struct ev_t *eaddr = NULL; + struct ev_t __iomem *eaddr; uint head; uint tail; int port; @@ -5601,7 +5602,7 @@ static int dgap_event(struct board_t *bd) return -ENXIO; } - eaddr = (struct ev_t *) (vaddr + EVBUF); + eaddr = (struct ev_t __iomem *) (vaddr + EVBUF); /* Get our head and tail */ head = readw(&(eaddr->ev_head)); -- cgit v1.2.3 From 7496e0538666012b89d2280f3f6681345002a454 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Fri, 25 Apr 2014 13:10:18 -0400 Subject: staging: dgap: check unchecked return values Check the return values of dgap_tty_register and dgap_finalize_board_init. If they fail for a particular board we should not be able to try to use that board. IE. no device entries shall be created for that board. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 3b732380f9e6..2c7acee6c926 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -882,8 +882,13 @@ static int dgap_firmware_load(struct pci_dev *pdev, int card_type) return -EINVAL; } - dgap_tty_register(brd); - dgap_finalize_board_init(brd); + ret = dgap_tty_register(brd); + if (ret) + return ret; + + ret = dgap_finalize_board_init(brd); + if (ret) + return ret; if (fw_info[card_type].bios_name) { ret = request_firmware(&fw, fw_info[card_type].bios_name, -- cgit v1.2.3 From 5c3b48d9b99c4a135f27b08cf3d51dfae4cf7e59 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Fri, 25 Apr 2014 13:10:19 -0400 Subject: staging: dgap: remove two unnecessary conditionals Remove 2 unnessessary conditionals. They are always false in this code path. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 2c7acee6c926..b834c83da930 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -1271,25 +1271,21 @@ static int dgap_tty_register(struct board_t *brd) */ tty_set_operations(brd->PrintDriver, &dgap_tty_ops); - if (!brd->dgap_Major_Serial_Registered) { - /* Register tty devices */ - rc = tty_register_driver(brd->SerialDriver); - if (rc < 0) - return rc; - brd->dgap_Major_Serial_Registered = TRUE; - dgap_BoardsByMajor[brd->SerialDriver->major] = brd; - brd->dgap_Serial_Major = brd->SerialDriver->major; - } + /* Register tty devices */ + rc = tty_register_driver(brd->SerialDriver); + if (rc < 0) + return rc; + brd->dgap_Major_Serial_Registered = TRUE; + dgap_BoardsByMajor[brd->SerialDriver->major] = brd; + brd->dgap_Serial_Major = brd->SerialDriver->major; - if (!brd->dgap_Major_TransparentPrint_Registered) { - /* Register Transparent Print devices */ - rc = tty_register_driver(brd->PrintDriver); - if (rc < 0) - return rc; - brd->dgap_Major_TransparentPrint_Registered = TRUE; - dgap_BoardsByMajor[brd->PrintDriver->major] = brd; - brd->dgap_TransparentPrint_Major = brd->PrintDriver->major; - } + /* Register Transparent Print devices */ + rc = tty_register_driver(brd->PrintDriver); + if (rc < 0) + return rc; + brd->dgap_Major_TransparentPrint_Registered = TRUE; + dgap_BoardsByMajor[brd->PrintDriver->major] = brd; + brd->dgap_TransparentPrint_Major = brd->PrintDriver->major; return rc; } -- cgit v1.2.3 From acfd4aae9e782bb5b1dde844247cda01e3256cd2 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Fri, 25 Apr 2014 13:10:20 -0400 Subject: staging: dgap: Add check for MAXBOARDS in .probe (dgap_init_one) Insure we don't allow configuring more than MAXBOARDS (32). Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index b834c83da930..f597432ede8c 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -572,6 +572,9 @@ static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) { int rc; + if (dgap_NumBoards >= MAXBOARDS) + return -EPERM; + /* wake up and enable device */ rc = pci_enable_device(pdev); -- cgit v1.2.3 From f34475f5badfe8a9ad5836c94ca32f16ef07e9a8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 22:59:18 +0200 Subject: staging: rtl8723au: Do not reset wdev->iftype in netdev_close() wdev->ifdev should be set by .change_virtual_intf(). This solves the problem of WARN() messages on module unload. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/os_intfs.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index 9161e5cda9a5..5be8dd9e1fea 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -866,8 +866,6 @@ static int netdev_close(struct net_device *pnetdev) } rtw_scan_abort23a(padapter); - /* set this at the end */ - padapter->rtw_wdev->iftype = NL80211_IFTYPE_MONITOR; RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-871x_drv - drv_close\n")); DBG_8723A("-871x_drv - drv_close, bup =%d\n", padapter->bup); -- cgit v1.2.3 From 6a82524167abda7dc92b76a4ba85ff2ceca6f8d8 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Fri, 25 Apr 2014 14:19:42 -0400 Subject: staging: dgap: refactor ugly dgap_init_one function This patch just cleans up the ugly dgap_init_one function Signed-off-by: Mark Hounschell Suggested-by: Dan Carpenter Tested-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index f597432ede8c..f2ad7ae8036e 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -575,19 +575,16 @@ static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) if (dgap_NumBoards >= MAXBOARDS) return -EPERM; - /* wake up and enable device */ rc = pci_enable_device(pdev); + if (rc) + return -EIO; - if (rc < 0) { - rc = -EIO; - } else { - rc = dgap_probe1(pdev, ent->driver_data); - if (rc == 0) { - dgap_NumBoards++; - rc = dgap_firmware_load(pdev, ent->driver_data); - } - } - return rc; + rc = dgap_probe1(pdev, ent->driver_data); + if (rc) + return rc; + + dgap_NumBoards++; + return dgap_firmware_load(pdev, ent->driver_data); } static int dgap_probe1(struct pci_dev *pdev, int card_type) -- cgit v1.2.3 From fea0683ebe7f642528c186109f928f9467e0c37e Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Fri, 25 Apr 2014 16:49:29 -0400 Subject: staging: dgap: Get rid of CamelCase This patch gets rid of the obvious CamelCases from both dgap.c and dgap.h Signed-off-by: Mark Hounschell Tested-by: Mark Hounschell Suggested-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 228 ++++++++++++++++++++++---------------------- drivers/staging/dgap/dgap.h | 24 ++--- 2 files changed, 127 insertions(+), 125 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index f2ad7ae8036e..d7cfc453e4f5 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -176,7 +176,7 @@ static void dgap_remove_tty_sysfs(struct device *c); /* * Function prototypes from dgap_parse.h */ -static int dgap_parsefile(char **in, int Remove); +static int dgap_parsefile(char **in, int remove); static struct cnode *dgap_find_config(int type, int bus, int slot); static uint dgap_config_get_num_prts(struct board_t *bd); static char *dgap_create_config_string(struct board_t *bd, char *string); @@ -206,12 +206,12 @@ module_exit(dgap_cleanup_module); /* * File operations permitted on Control/Management major. */ -static const struct file_operations DgapBoardFops = { +static const struct file_operations dgap_board_fops = { .owner = THIS_MODULE, }; -static uint dgap_NumBoards; -static struct board_t *dgap_Board[MAXBOARDS]; +static uint dgap_numboards; +static struct board_t *dgap_board[MAXBOARDS]; static ulong dgap_poll_counter; static char *dgap_config_buf; static int dgap_driver_state = DRIVER_INITIALIZED; @@ -220,7 +220,7 @@ static int dgap_poll_tick = 20; /* Poll interval - 20 ms */ static struct class *dgap_class; -static struct board_t *dgap_BoardsByMajor[256]; +static struct board_t *dgap_boards_by_major[256]; static uint dgap_count = 500; /* @@ -280,7 +280,7 @@ struct board_id { uint dpatype; }; -static struct board_id dgap_Ids[] = { +static struct board_id dgap_ids[] = { { PPCM, PCI_DEV_XEM_NAME, 64, (T_PCXM|T_PCLITE|T_PCIBUS) }, { PCX, PCI_DEV_CX_NAME, 128, (T_CX|T_PCIBUS) }, { PCX, PCI_DEV_CX_IBM_NAME, 128, (T_CX|T_PCIBUS) }, @@ -359,7 +359,7 @@ static struct digi_t dgap_digi_init = { * 1 stop bit. */ -static struct ktermios DgapDefaultTermios = { +static struct ktermios dgap_default_termios = { .c_iflag = (DEFAULT_IFLAGS), /* iflags */ .c_oflag = (DEFAULT_OFLAGS), /* oflags */ .c_cflag = (DEFAULT_CFLAGS), /* cflags */ @@ -510,7 +510,7 @@ static int dgap_start(void) */ dgap_init_globals(); - dgap_NumBoards = 0; + dgap_numboards = 0; pr_info("For the tools package please visit http://www.digi.com\n"); @@ -521,7 +521,7 @@ static int dgap_start(void) /* * Register management/dpa devices */ - rc = register_chrdev(DIGI_DGAP_MAJOR, "dgap", &DgapBoardFops); + rc = register_chrdev(DIGI_DGAP_MAJOR, "dgap", &dgap_board_fops); if (rc < 0) return rc; @@ -572,7 +572,7 @@ static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) { int rc; - if (dgap_NumBoards >= MAXBOARDS) + if (dgap_numboards >= MAXBOARDS) return -EPERM; rc = pci_enable_device(pdev); @@ -583,7 +583,7 @@ static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) if (rc) return rc; - dgap_NumBoards++; + dgap_numboards++; return dgap_firmware_load(pdev, ent->driver_data); } @@ -620,13 +620,13 @@ static void dgap_cleanup_module(void) class_destroy(dgap_class); unregister_chrdev(DIGI_DGAP_MAJOR, "dgap"); - for (i = 0; i < dgap_NumBoards; ++i) { - dgap_remove_ports_sysfiles(dgap_Board[i]); - dgap_tty_uninit(dgap_Board[i]); - dgap_cleanup_board(dgap_Board[i]); + for (i = 0; i < dgap_numboards; ++i) { + dgap_remove_ports_sysfiles(dgap_board[i]); + dgap_tty_uninit(dgap_board[i]); + dgap_cleanup_board(dgap_board[i]); } - if (dgap_NumBoards) + if (dgap_numboards) pci_unregister_driver(&dgap_driver); } @@ -666,7 +666,7 @@ static void dgap_cleanup_board(struct board_t *brd) kfree(brd->flipbuf); kfree(brd->flipflagbuf); - dgap_Board[brd->boardnum] = NULL; + dgap_board[brd->boardnum] = NULL; kfree(brd); } @@ -687,21 +687,21 @@ static int dgap_found_board(struct pci_dev *pdev, int id) if (!brd) return -ENOMEM; - dgap_Board[dgap_NumBoards] = brd; + dgap_board[dgap_numboards] = brd; /* store the info for the board we've found */ brd->magic = DGAP_BOARD_MAGIC; - brd->boardnum = dgap_NumBoards; + brd->boardnum = dgap_numboards; brd->firstminor = 0; brd->vendor = dgap_pci_tbl[id].vendor; brd->device = dgap_pci_tbl[id].device; brd->pdev = pdev; brd->pci_bus = pdev->bus->number; brd->pci_slot = PCI_SLOT(pdev->devfn); - brd->name = dgap_Ids[id].name; - brd->maxports = dgap_Ids[id].maxports; - brd->type = dgap_Ids[id].config_type; - brd->dpatype = dgap_Ids[id].dpatype; + brd->name = dgap_ids[id].name; + brd->maxports = dgap_ids[id].maxports; + brd->type = dgap_ids[id].config_type; + brd->dpatype = dgap_ids[id].dpatype; brd->dpastatus = BD_NOFEP; init_waitqueue_head(&brd->state_wait); @@ -783,7 +783,7 @@ static int dgap_found_board(struct pci_dev *pdev, int id) brd->state = BOARD_FAILED; pr_info("dgap: board %d: %s (rev %d), irq %ld\n", - dgap_NumBoards, brd->name, brd->rev, brd->irq); + dgap_numboards, brd->name, brd->rev, brd->irq); return 0; } @@ -818,7 +818,7 @@ static int dgap_finalize_board_init(struct board_t *brd) static int dgap_firmware_load(struct pci_dev *pdev, int card_type) { - struct board_t *brd = dgap_Board[dgap_NumBoards - 1]; + struct board_t *brd = dgap_board[dgap_numboards - 1]; const struct firmware *fw; char *tmp_ptr; int ret; @@ -1055,10 +1055,10 @@ static void dgap_poll_handler(ulong dummy) * Otherwise, use our new tasklet based poller, which should * speed things up for multiple boards. */ - if ((dgap_NumBoards == 1) || (num_online_cpus() <= 1)) { - for (i = 0; i < dgap_NumBoards; i++) { + if ((dgap_numboards == 1) || (num_online_cpus() <= 1)) { + for (i = 0; i < dgap_numboards; i++) { - brd = dgap_Board[i]; + brd = dgap_board[i]; if (brd->state == BOARD_FAILED) continue; @@ -1071,8 +1071,8 @@ static void dgap_poll_handler(ulong dummy) * Go thru each board, kicking off a * tasklet for each if needed */ - for (i = 0; i < dgap_NumBoards; i++) { - brd = dgap_Board[i]; + for (i = 0; i < dgap_numboards; i++) { + brd = dgap_board[i]; /* * Attempt to grab the board lock. @@ -1170,7 +1170,7 @@ static void dgap_init_globals(void) int i = 0; for (i = 0; i < MAXBOARDS; i++) - dgap_Board[i] = NULL; + dgap_board[i] = NULL; init_timer(&dgap_poll_timer); @@ -1212,80 +1212,82 @@ static int dgap_tty_register(struct board_t *brd) { int rc = 0; - brd->SerialDriver = alloc_tty_driver(MAXPORTS); - - snprintf(brd->SerialName, MAXTTYNAMELEN, "tty_dgap_%d_", brd->boardnum); - brd->SerialDriver->name = brd->SerialName; - brd->SerialDriver->name_base = 0; - brd->SerialDriver->major = 0; - brd->SerialDriver->minor_start = 0; - brd->SerialDriver->type = TTY_DRIVER_TYPE_SERIAL; - brd->SerialDriver->subtype = SERIAL_TYPE_NORMAL; - brd->SerialDriver->init_termios = DgapDefaultTermios; - brd->SerialDriver->driver_name = DRVSTR; - brd->SerialDriver->flags = (TTY_DRIVER_REAL_RAW | + brd->serial_driver = alloc_tty_driver(MAXPORTS); + + snprintf(brd->serial_name, MAXTTYNAMELEN, "tty_dgap_%d_", + brd->boardnum); + brd->serial_driver->name = brd->serial_name; + brd->serial_driver->name_base = 0; + brd->serial_driver->major = 0; + brd->serial_driver->minor_start = 0; + brd->serial_driver->type = TTY_DRIVER_TYPE_SERIAL; + brd->serial_driver->subtype = SERIAL_TYPE_NORMAL; + brd->serial_driver->init_termios = dgap_default_termios; + brd->serial_driver->driver_name = DRVSTR; + brd->serial_driver->flags = (TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK); /* The kernel wants space to store pointers to tty_structs */ - brd->SerialDriver->ttys = + brd->serial_driver->ttys = kzalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL); - if (!brd->SerialDriver->ttys) + if (!brd->serial_driver->ttys) return -ENOMEM; /* * Entry points for driver. Called by the kernel from * tty_io.c and n_tty.c. */ - tty_set_operations(brd->SerialDriver, &dgap_tty_ops); + tty_set_operations(brd->serial_driver, &dgap_tty_ops); /* * If we're doing transparent print, we have to do all of the above * again, separately so we don't get the LD confused about what major * we are when we get into the dgap_tty_open() routine. */ - brd->PrintDriver = alloc_tty_driver(MAXPORTS); - - snprintf(brd->PrintName, MAXTTYNAMELEN, "pr_dgap_%d_", brd->boardnum); - brd->PrintDriver->name = brd->PrintName; - brd->PrintDriver->name_base = 0; - brd->PrintDriver->major = 0; - brd->PrintDriver->minor_start = 0; - brd->PrintDriver->type = TTY_DRIVER_TYPE_SERIAL; - brd->PrintDriver->subtype = SERIAL_TYPE_NORMAL; - brd->PrintDriver->init_termios = DgapDefaultTermios; - brd->PrintDriver->driver_name = DRVSTR; - brd->PrintDriver->flags = (TTY_DRIVER_REAL_RAW | + brd->print_driver = alloc_tty_driver(MAXPORTS); + + snprintf(brd->print_name, MAXTTYNAMELEN, "pr_dgap_%d_", + brd->boardnum); + brd->print_driver->name = brd->print_name; + brd->print_driver->name_base = 0; + brd->print_driver->major = 0; + brd->print_driver->minor_start = 0; + brd->print_driver->type = TTY_DRIVER_TYPE_SERIAL; + brd->print_driver->subtype = SERIAL_TYPE_NORMAL; + brd->print_driver->init_termios = dgap_default_termios; + brd->print_driver->driver_name = DRVSTR; + brd->print_driver->flags = (TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK); /* The kernel wants space to store pointers to tty_structs */ - brd->PrintDriver->ttys = + brd->print_driver->ttys = kzalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL); - if (!brd->PrintDriver->ttys) + if (!brd->print_driver->ttys) return -ENOMEM; /* * Entry points for driver. Called by the kernel from * tty_io.c and n_tty.c. */ - tty_set_operations(brd->PrintDriver, &dgap_tty_ops); + tty_set_operations(brd->print_driver, &dgap_tty_ops); /* Register tty devices */ - rc = tty_register_driver(brd->SerialDriver); + rc = tty_register_driver(brd->serial_driver); if (rc < 0) return rc; - brd->dgap_Major_Serial_Registered = TRUE; - dgap_BoardsByMajor[brd->SerialDriver->major] = brd; - brd->dgap_Serial_Major = brd->SerialDriver->major; + brd->dgap_major_serial_registered = TRUE; + dgap_boards_by_major[brd->serial_driver->major] = brd; + brd->dgap_serial_major = brd->serial_driver->major; /* Register Transparent Print devices */ - rc = tty_register_driver(brd->PrintDriver); + rc = tty_register_driver(brd->print_driver); if (rc < 0) return rc; - brd->dgap_Major_TransparentPrint_Registered = TRUE; - dgap_BoardsByMajor[brd->PrintDriver->major] = brd; - brd->dgap_TransparentPrint_Major = brd->PrintDriver->major; + brd->dgap_major_transparent_print_registered = TRUE; + dgap_boards_by_major[brd->print_driver->major] = brd; + brd->dgap_transparent_print_major = brd->print_driver->major; return rc; } @@ -1473,38 +1475,38 @@ static void dgap_tty_uninit(struct board_t *brd) struct device *dev; int i = 0; - if (brd->dgap_Major_Serial_Registered) { - dgap_BoardsByMajor[brd->SerialDriver->major] = NULL; - brd->dgap_Serial_Major = 0; + if (brd->dgap_major_serial_registered) { + dgap_boards_by_major[brd->serial_driver->major] = NULL; + brd->dgap_serial_major = 0; for (i = 0; i < brd->nasync; i++) { - tty_port_destroy(&brd->SerialPorts[i]); + tty_port_destroy(&brd->serial_ports[i]); dev = brd->channels[i]->ch_tun.un_sysfs; dgap_remove_tty_sysfs(dev); - tty_unregister_device(brd->SerialDriver, i); + tty_unregister_device(brd->serial_driver, i); } - tty_unregister_driver(brd->SerialDriver); - kfree(brd->SerialDriver->ttys); - brd->SerialDriver->ttys = NULL; - put_tty_driver(brd->SerialDriver); - kfree(brd->SerialPorts); - brd->dgap_Major_Serial_Registered = FALSE; + tty_unregister_driver(brd->serial_driver); + kfree(brd->serial_driver->ttys); + brd->serial_driver->ttys = NULL; + put_tty_driver(brd->serial_driver); + kfree(brd->serial_ports); + brd->dgap_major_serial_registered = FALSE; } - if (brd->dgap_Major_TransparentPrint_Registered) { - dgap_BoardsByMajor[brd->PrintDriver->major] = NULL; - brd->dgap_TransparentPrint_Major = 0; + if (brd->dgap_major_transparent_print_registered) { + dgap_boards_by_major[brd->print_driver->major] = NULL; + brd->dgap_transparent_print_major = 0; for (i = 0; i < brd->nasync; i++) { - tty_port_destroy(&brd->PrinterPorts[i]); + tty_port_destroy(&brd->printer_ports[i]); dev = brd->channels[i]->ch_pun.un_sysfs; dgap_remove_tty_sysfs(dev); - tty_unregister_device(brd->PrintDriver, i); + tty_unregister_device(brd->print_driver, i); } - tty_unregister_driver(brd->PrintDriver); - kfree(brd->PrintDriver->ttys); - brd->PrintDriver->ttys = NULL; - put_tty_driver(brd->PrintDriver); - kfree(brd->PrinterPorts); - brd->dgap_Major_TransparentPrint_Registered = FALSE; + tty_unregister_driver(brd->print_driver); + kfree(brd->print_driver->ttys); + brd->print_driver->ttys = NULL; + put_tty_driver(brd->print_driver); + kfree(brd->printer_ports); + brd->dgap_major_transparent_print_registered = FALSE; } } @@ -1980,7 +1982,7 @@ static int dgap_tty_open(struct tty_struct *tty, struct file *file) return -ENXIO; /* Get board pointer from our array of majors we have allocated */ - brd = dgap_BoardsByMajor[major]; + brd = dgap_boards_by_major[major]; if (!brd) return -ENXIO; @@ -2018,10 +2020,10 @@ static int dgap_tty_open(struct tty_struct *tty, struct file *file) spin_lock_irqsave(&ch->ch_lock, lock_flags2); /* Figure out our type */ - if (major == brd->dgap_Serial_Major) { + if (major == brd->dgap_serial_major) { un = &brd->channels[minor]->ch_tun; un->un_type = DGAP_SERIAL; - } else if (major == brd->dgap_TransparentPrint_Major) { + } else if (major == brd->dgap_transparent_print_major) { un = &brd->channels[minor]->ch_pun; un->un_type = DGAP_PRINT; } else { @@ -4239,18 +4241,18 @@ static int dgap_after_config_loaded(int board) /* * Initialize KME waitqueues... */ - init_waitqueue_head(&(dgap_Board[board]->kme_wait)); + init_waitqueue_head(&(dgap_board[board]->kme_wait)); /* * allocate flip buffer for board. */ - dgap_Board[board]->flipbuf = kmalloc(MYFLIPLEN, GFP_ATOMIC); - if (!dgap_Board[board]->flipbuf) + dgap_board[board]->flipbuf = kmalloc(MYFLIPLEN, GFP_ATOMIC); + if (!dgap_board[board]->flipbuf) return -ENOMEM; - dgap_Board[board]->flipflagbuf = kmalloc(MYFLIPLEN, GFP_ATOMIC); - if (!dgap_Board[board]->flipflagbuf) { - kfree(dgap_Board[board]->flipbuf); + dgap_board[board]->flipflagbuf = kmalloc(MYFLIPLEN, GFP_ATOMIC); + if (!dgap_board[board]->flipflagbuf) { + kfree(dgap_board[board]->flipbuf); return -ENOMEM; } @@ -4265,36 +4267,36 @@ static int dgap_tty_register_ports(struct board_t *brd) struct channel_t *ch; int i; - brd->SerialPorts = kcalloc(brd->nasync, sizeof(*brd->SerialPorts), + brd->serial_ports = kcalloc(brd->nasync, sizeof(*brd->serial_ports), GFP_KERNEL); - if (brd->SerialPorts == NULL) + if (brd->serial_ports == NULL) return -ENOMEM; for (i = 0; i < brd->nasync; i++) - tty_port_init(&brd->SerialPorts[i]); + tty_port_init(&brd->serial_ports[i]); - brd->PrinterPorts = kcalloc(brd->nasync, sizeof(*brd->PrinterPorts), + brd->printer_ports = kcalloc(brd->nasync, sizeof(*brd->printer_ports), GFP_KERNEL); - if (brd->PrinterPorts == NULL) { - kfree(brd->SerialPorts); + if (brd->printer_ports == NULL) { + kfree(brd->serial_ports); return -ENOMEM; } for (i = 0; i < brd->nasync; i++) - tty_port_init(&brd->PrinterPorts[i]); + tty_port_init(&brd->printer_ports[i]); ch = brd->channels[0]; for (i = 0; i < brd->nasync; i++, ch = brd->channels[i]) { struct device *classp; - classp = tty_port_register_device(&brd->SerialPorts[i], - brd->SerialDriver, + classp = tty_port_register_device(&brd->serial_ports[i], + brd->serial_driver, brd->firstminor + i, NULL); dgap_create_tty_sysfs(&ch->ch_tun, classp); ch->ch_tun.un_sysfs = classp; - classp = tty_port_register_device(&brd->PrinterPorts[i], - brd->PrintDriver, + classp = tty_port_register_device(&brd->printer_ports[i], + brd->print_driver, brd->firstminor + i, NULL); dgap_create_tty_sysfs(&ch->ch_pun, classp); @@ -5767,7 +5769,7 @@ static DRIVER_ATTR(version, S_IRUSR, dgap_driver_version_show, NULL); static ssize_t dgap_driver_boards_show(struct device_driver *ddp, char *buf) { - return snprintf(buf, PAGE_SIZE, "%d\n", dgap_NumBoards); + return snprintf(buf, PAGE_SIZE, "%d\n", dgap_numboards); } static DRIVER_ATTR(boards, S_IRUSR, dgap_driver_boards_show, NULL); @@ -6510,7 +6512,7 @@ static void dgap_remove_tty_sysfs(struct device *c) /* * Parse a configuration file read into memory as a string. */ -static int dgap_parsefile(char **in, int Remove) +static int dgap_parsefile(char **in, int remove) { struct cnode *p, *brd, *line, *conc; int rc; diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h index 2bbb51ff12f4..cd2150bf88f1 100644 --- a/drivers/staging/dgap/dgap.h +++ b/drivers/staging/dgap/dgap.h @@ -580,18 +580,18 @@ struct board_t { struct channel_t *channels[MAXPORTS]; /* array of pointers to our */ /* channels. */ - struct tty_driver *SerialDriver; - struct tty_port *SerialPorts; - char SerialName[200]; - struct tty_driver *PrintDriver; - struct tty_port *PrinterPorts; - char PrintName[200]; - - u32 dgap_Major_Serial_Registered; - u32 dgap_Major_TransparentPrint_Registered; - - u32 dgap_Serial_Major; - u32 dgap_TransparentPrint_Major; + struct tty_driver *serial_driver; + struct tty_port *serial_ports; + char serial_name[200]; + struct tty_driver *print_driver; + struct tty_port *printer_ports; + char print_name[200]; + + u32 dgap_major_serial_registered; + u32 dgap_major_transparent_print_registered; + + u32 dgap_serial_major; + u32 dgap_transparent_print_major; struct bs_t __iomem *bd_bs; /* Base structure pointer */ -- cgit v1.2.3 From 751a624adbe47145d3667c4b504858ffd3e8f175 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Sat, 3 May 2014 23:23:29 +0300 Subject: staging: lustre: info leak in lnet_ping() On 64 bit systems there is a 4 byte hole after the last member of the struct. We should clear it to avoid disclosing stack information. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/lnet/api-ni.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 3f1fdaa29891..3f878dee2e42 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -1927,6 +1927,7 @@ lnet_ping (lnet_process_id_t id, int timeout_ms, lnet_process_id_t *ids, int n_i rc = -EFAULT; /* If I SEGV... */ + memset(&tmpid, 0, sizeof(tmpid)); for (i = 0; i < n_ids; i++) { tmpid.pid = info->pi_pid; tmpid.nid = info->pi_ni[i].ns_nid; -- cgit v1.2.3 From a9c08b0ac1c4f022bda7e2c7aa11869da33a8058 Mon Sep 17 00:00:00 2001 From: Vitaly Osipov Date: Sun, 4 May 2014 14:14:26 +1000 Subject: staging: lustre: return -EFAULT instead of bytes remaining return -EFAULT instead of the value returned by copy_from_user() Signed-off-by: Vitaly Osipov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/libcfs/linux/linux-module.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c index 9a3b07bd2fac..581b4728c6ca 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c @@ -45,14 +45,12 @@ int libcfs_ioctl_getdata(char *buf, char *end, void *arg) struct libcfs_ioctl_hdr *hdr; struct libcfs_ioctl_data *data; int orig_len; - int err; hdr = (struct libcfs_ioctl_hdr *)buf; data = (struct libcfs_ioctl_data *)buf; - err = copy_from_user(buf, (void *)arg, sizeof(*hdr)); - if (err) - return err; + if (copy_from_user(buf, (void *)arg, sizeof(*hdr))) + return -EFAULT; if (hdr->ioc_version != LIBCFS_IOCTL_VERSION) { CERROR("PORTALS: version mismatch kernel vs application\n"); @@ -71,9 +69,8 @@ int libcfs_ioctl_getdata(char *buf, char *end, void *arg) } orig_len = hdr->ioc_len; - err = copy_from_user(buf, (void *)arg, hdr->ioc_len); - if (err) - return err; + if (copy_from_user(buf, (void *)arg, hdr->ioc_len)) + return -EFAULT; if (orig_len != data->ioc_len) return -EINVAL; -- cgit v1.2.3 From 7f03de97b6f14e6548593425a5d9adc09260f32b Mon Sep 17 00:00:00 2001 From: Fredrick John Berchmans Date: Sat, 3 May 2014 21:42:14 -0700 Subject: staging: lustre: fix unused variable warnings Reported-by: kbuild test robot Signed-off-by: Fredrick John Berchmans Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c index 4153b4a61396..ac3a444a918d 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c @@ -46,10 +46,8 @@ int libcfs_sock_ioctl(int cmd, unsigned long arg) { - mm_segment_t oldmm = get_fs(); struct socket *sock; int rc; - struct file *sock_filp; rc = sock_create (PF_INET, SOCK_STREAM, 0, &sock); if (rc != 0) { -- cgit v1.2.3 From fcd0157ece8a1bf36b877a9c8078ea721678a38b Mon Sep 17 00:00:00 2001 From: Ken Cox Date: Mon, 28 Apr 2014 12:23:13 -0500 Subject: Staging: unisys: detect s-Par firmware This patch adds support for detection of s-Par firmware by checking for the hypervisor bit in the CPU capabilities, and then querying the hypervisor ID cpuid leaf. This functionality will be used by the unisys drivers to determine if they are being loaded on an s-Par platform and refuse to load if no s-Par firmware is present. This fixes a problem reported from upstream where a panic occurs if the unisys drivers are loaded on a non s-Par system. Reported-by: Fengguang Wu Signed-off-by: Ken Cox Tested by: Ken Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/channels/chanstub.c | 3 ++ drivers/staging/unisys/include/timskmodutils.h | 2 + drivers/staging/unisys/uislib/uislib.c | 3 ++ drivers/staging/unisys/virthba/virthba.c | 3 ++ drivers/staging/unisys/virtpci/virtpci.c | 4 ++ .../unisys/visorchannel/visorchannel_main.c | 3 ++ .../unisys/visorchipset/visorchipset_main.c | 3 ++ drivers/staging/unisys/visorutil/visorkmodutils.c | 54 ++++++++++++++++++++++ 8 files changed, 75 insertions(+) diff --git a/drivers/staging/unisys/channels/chanstub.c b/drivers/staging/unisys/channels/chanstub.c index 45ac55d3fe1c..1e7d6a78602d 100644 --- a/drivers/staging/unisys/channels/chanstub.c +++ b/drivers/staging/unisys/channels/chanstub.c @@ -25,11 +25,14 @@ #include "channel.h" #include "chanstub.h" +#include "timskmodutils.h" #include "version.h" static __init int channel_mod_init(void) { + if (!unisys_spar_platform) + return -ENODEV; return 0; } diff --git a/drivers/staging/unisys/include/timskmodutils.h b/drivers/staging/unisys/include/timskmodutils.h index 0045d559d1b9..c316c94ea194 100644 --- a/drivers/staging/unisys/include/timskmodutils.h +++ b/drivers/staging/unisys/include/timskmodutils.h @@ -72,4 +72,6 @@ char *cyclesToSomethingsPerSecond(u64 cycles, u64 cyclesPerSecond, struct seq_file *visor_seq_file_new_buffer(void *buf, size_t buf_size); void visor_seq_file_done_buffer(struct seq_file *m); +extern int unisys_spar_platform; + #endif diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 0e1a58ab28b1..fbdb19fc7891 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -2277,6 +2277,9 @@ static int __init uislib_mod_init(void) { + if (!unisys_spar_platform) + return -ENODEV; + LOGINF("MONITORAPIS"); LOGINF("sizeof(struct uiscmdrsp):%lu bytes\n", diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c index a13e79e287f4..d528388d596f 100644 --- a/drivers/staging/unisys/virthba/virthba.c +++ b/drivers/staging/unisys/virthba/virthba.c @@ -1699,6 +1699,9 @@ virthba_mod_init(void) int error; int i; + if (!unisys_spar_platform) + return -ENODEV; + LOGINF("Entering virthba_mod_init...\n"); POSTCODE_LINUX_2(VHBA_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO); diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index 21f8bd5fdff9..9a35dd2cd472 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -39,6 +39,7 @@ #include #include "version.h" #include "guestlinuxdebug.h" +#include "timskmodutils.h" struct driver_private { struct kobject kobj; @@ -1687,6 +1688,9 @@ static int __init virtpci_mod_init(void) int ret; + if (!unisys_spar_platform) + return -ENODEV; + LOGINF("Module build: Date:%s Time:%s...\n", __DATE__, __TIME__); POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO); diff --git a/drivers/staging/unisys/visorchannel/visorchannel_main.c b/drivers/staging/unisys/visorchannel/visorchannel_main.c index 1a092570602e..c8f89bd75e0c 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel_main.c +++ b/drivers/staging/unisys/visorchannel/visorchannel_main.c @@ -29,6 +29,9 @@ static int __init visorchannel_init(void) { + if (!unisys_spar_platform) + return -ENODEV; + INFODRV("driver version %s loaded", VERSION); return 0; } diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 1895dc459643..5b955926f42d 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -2699,6 +2699,9 @@ visorchipset_init(void) struct proc_dir_entry *toolaction_file; struct proc_dir_entry *bootToTool_file; + if (!unisys_spar_platform) + return -ENODEV; + LOGINF("chipset driver version %s loaded", VERSION); /* process module options */ POSTCODE_LINUX_2(DRIVER_ENTRY_PC, POSTCODE_SEVERITY_INFO); diff --git a/drivers/staging/unisys/visorutil/visorkmodutils.c b/drivers/staging/unisys/visorutil/visorkmodutils.c index e802e75a4696..7521027c9368 100644 --- a/drivers/staging/unisys/visorutil/visorkmodutils.c +++ b/drivers/staging/unisys/visorutil/visorkmodutils.c @@ -20,6 +20,22 @@ #define MYDRVNAME "timskmodutils" +/* s-Par uses the Intel processor's VT-X features to separate groups of + * processors into partitions. The firmware sets the hypervisor bit and + * reports an ID in the HV capabilities leaf so that the partition's OS + * knows s-Par is present and managing the processors. + */ + +#define UNISYS_SPAR_LEAF_ID 0x40000000 + +/* The s-Par leaf ID returns "UnisysSpar64" encoded across ebx, ecx, edx */ +#define UNISYS_SPAR_ID_EBX 0x73696e55 +#define UNISYS_SPAR_ID_ECX 0x70537379 +#define UNISYS_SPAR_ID_EDX 0x34367261 + +int unisys_spar_platform; +EXPORT_SYMBOL_GPL(unisys_spar_platform); + /** Callers to interfaces that set __GFP_NORETRY flag below * must check for a NULL (error) result as we are telling the * kernel interface that it is okay to fail. @@ -69,3 +85,41 @@ void visor_seq_file_done_buffer(struct seq_file *m) kfree(m); } EXPORT_SYMBOL_GPL(visor_seq_file_done_buffer); + +static __init uint32_t +visorutil_spar_detect(void) +{ + unsigned int eax, ebx, ecx, edx; + + if (cpu_has_hypervisor) { + /* check the ID */ + cpuid(UNISYS_SPAR_LEAF_ID, &eax, &ebx, &ecx, &edx); + return (ebx == UNISYS_SPAR_ID_EBX) && + (ecx == UNISYS_SPAR_ID_ECX) && + (edx == UNISYS_SPAR_ID_EDX); + } else + return 0; + +} + + + + +static __init int +visorutil_mod_init(void) +{ + if (visorutil_spar_detect()) { + unisys_spar_platform = TRUE; + return 0; + } else + return -ENODEV; +} + +static __exit void +visorutil_mod_exit(void) +{ +} + +module_init(visorutil_mod_init); +module_exit(visorutil_mod_exit); + -- cgit v1.2.3 From 37b7e990ff0ac58f8b09b5e8beee7777edbff739 Mon Sep 17 00:00:00 2001 From: Ken Cox Date: Mon, 28 Apr 2014 12:23:14 -0500 Subject: Staging: unisys: visorutil: Add MODULE_LICENSE("GPL") The visorutil module was lacking license info. Signed-off-by: Ken Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorutil/visorkmodutils.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/unisys/visorutil/visorkmodutils.c b/drivers/staging/unisys/visorutil/visorkmodutils.c index 7521027c9368..10d77cb6ee97 100644 --- a/drivers/staging/unisys/visorutil/visorkmodutils.c +++ b/drivers/staging/unisys/visorutil/visorkmodutils.c @@ -123,3 +123,4 @@ visorutil_mod_exit(void) module_init(visorutil_mod_init); module_exit(visorutil_mod_exit); +MODULE_LICENSE("GPL"); -- cgit v1.2.3 From 90addb0218d47a886c846a22d75979fe5bf3471b Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Tue, 6 May 2014 09:58:23 -0400 Subject: staging: unisys: Replace GUID with uuid_le This patch replaces the GUID type with uuid_le. It removes the header file guidutils.h, updates all uses of the GUID type to uuid_le, and replaces all function calls that used the GUID type with their uuid_le equivalents. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/channel.h | 27 +-- .../common-spar/include/channels/channel_guid.h | 28 +-- .../include/channels/controlvmchannel.h | 19 +- .../common-spar/include/channels/diagchannel.h | 10 +- .../common-spar/include/channels/iochannel.h | 10 +- .../common-spar/include/channels/vbuschannel.h | 10 +- drivers/staging/unisys/include/commontypes.h | 47 ++--- drivers/staging/unisys/include/guidutils.h | 203 --------------------- drivers/staging/unisys/include/uisqueue.h | 13 +- drivers/staging/unisys/include/uisutils.h | 21 ++- drivers/staging/unisys/uislib/uislib.c | 53 ++---- drivers/staging/unisys/uislib/uisutils.c | 53 +++--- drivers/staging/unisys/virtpci/virtpci.c | 13 +- drivers/staging/unisys/virtpci/virtpci.h | 3 +- drivers/staging/unisys/visorchannel/visorchannel.h | 14 +- .../unisys/visorchannel/visorchannel_funcs.c | 39 ++-- .../unisys/visorchannel/visorchannel_main.c | 2 +- drivers/staging/unisys/visorchipset/parser.c | 5 +- drivers/staging/unisys/visorchipset/parser.h | 4 +- drivers/staging/unisys/visorchipset/testing.h | 5 +- drivers/staging/unisys/visorchipset/visorchipset.h | 16 +- .../unisys/visorchipset/visorchipset_main.c | 15 +- 22 files changed, 182 insertions(+), 428 deletions(-) delete mode 100644 drivers/staging/unisys/include/guidutils.h diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index baa0e501e6b4..237a852c2fc0 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -16,6 +16,8 @@ #ifndef __CHANNEL_H__ #define __CHANNEL_H__ +#include + /* * Whenever this file is changed a corresponding change must be made in * the Console/ServicePart/visordiag_early/supervisor_channel.h file @@ -46,19 +48,6 @@ #define COVER(v, d) ((d)*COVERQ(v, d)) #endif -#ifndef GUID0 -#define GUID0 {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0} } -#endif - -/* The C language is inconsistent with respect to where it allows literal - * constants, especially literal constant structs. Literal constant structs - * are allowed for initialization only, whereas other types of literal - * constants are allowed anywhere. We get around this inconsistency by - * declaring a "static const" variable for each GUID. This variable can be - * used in expressions where the literal constant would not be allowed. - */ -static const GUID Guid0 = GUID0; - #define ULTRA_CHANNEL_PROTOCOL_SIGNATURE SIGNATURE_32('E', 'C', 'N', 'L') typedef enum { @@ -226,13 +215,13 @@ typedef struct _CHANNEL_HEADER { U32 HeaderSize; /* sizeof(CHANNEL_HEADER) */ U64 Size; /* Total size of this channel in bytes */ U64 Features; /* Flags to modify behavior */ - GUID Type; /* Channel type: data, bus, control, etc. */ + uuid_le Type; /* Channel type: data, bus, control, etc. */ U64 PartitionHandle; /* ID of guest partition */ U64 Handle; /* Device number of this channel in client */ U64 oChannelSpace; /* Offset in bytes to channel specific area */ U32 VersionId; /* CHANNEL_HEADER Version ID */ U32 PartitionIndex; /* Index of guest partition */ - GUID ZoneGuid; /* Guid of Channel's zone */ + uuid_le ZoneGuid; /* Guid of Channel's zone */ U32 oClientString; /* offset from channel header to * nul-terminated ClientString (0 if * ClientString not present) */ @@ -320,17 +309,17 @@ typedef struct _SIGNAL_QUEUE_HEADER { */ static inline int ULTRA_check_channel_client(void __iomem *pChannel, - GUID expectedTypeGuid, + uuid_le expectedTypeGuid, char *channelName, U64 expectedMinBytes, U32 expectedVersionId, U64 expectedSignature, char *fileName, int lineNumber, void *logCtx) { - if (MEMCMP(&expectedTypeGuid, &Guid0, sizeof(GUID)) != 0) + if (uuid_le_cmp(expectedTypeGuid, NULL_UUID_LE) != 0) /* caller wants us to verify type GUID */ if (MEMCMP_IO(&(((CHANNEL_HEADER __iomem *) (pChannel))->Type), - &expectedTypeGuid, sizeof(GUID)) != 0) { + &expectedTypeGuid, sizeof(uuid_le)) != 0) { CHANNEL_GUID_MISMATCH(expectedTypeGuid, channelName, "type", expectedTypeGuid, ((CHANNEL_HEADER __iomem *) @@ -380,7 +369,7 @@ ULTRA_check_channel_client(void __iomem *pChannel, * is used to pass the EFI_DIAG_CAPTURE_PROTOCOL needed to log messages. */ static inline int -ULTRA_check_channel_server(GUID typeGuid, +ULTRA_check_channel_server(uuid_le typeGuid, char *channelName, U64 expectedMinBytes, U64 actualBytes, diff --git a/drivers/staging/unisys/common-spar/include/channels/channel_guid.h b/drivers/staging/unisys/common-spar/include/channels/channel_guid.h index 1f1f48e8f1c9..63c67ca4c9ec 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel_guid.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel_guid.h @@ -21,44 +21,44 @@ * {414815ed-c58c-11da-95a9-00e08161165f} */ #define ULTRA_VHBA_CHANNEL_PROTOCOL_GUID \ - { 0x414815ed, 0xc58c, 0x11da, \ - { 0x95, 0xa9, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f } } -static const GUID UltraVhbaChannelProtocolGuid = + UUID_LE(0x414815ed, 0xc58c, 0x11da, \ + 0x95, 0xa9, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f) +static const uuid_le UltraVhbaChannelProtocolGuid = ULTRA_VHBA_CHANNEL_PROTOCOL_GUID; /* Used in IOChannel * {8cd5994d-c58e-11da-95a9-00e08161165f} */ #define ULTRA_VNIC_CHANNEL_PROTOCOL_GUID \ - { 0x8cd5994d, 0xc58e, 0x11da, \ - { 0x95, 0xa9, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f } } -static const GUID UltraVnicChannelProtocolGuid = + UUID_LE(0x8cd5994d, 0xc58e, 0x11da, \ + 0x95, 0xa9, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f) +static const uuid_le UltraVnicChannelProtocolGuid = ULTRA_VNIC_CHANNEL_PROTOCOL_GUID; /* Used in IOChannel * {72120008-4AAB-11DC-8530-444553544200} */ #define ULTRA_SIOVM_GUID \ - { 0x72120008, 0x4AAB, 0x11DC, \ - { 0x85, 0x30, 0x44, 0x45, 0x53, 0x54, 0x42, 0x00 } } -static const GUID UltraSIOVMGuid = ULTRA_SIOVM_GUID; + UUID_LE(0x72120008, 0x4AAB, 0x11DC, \ + 0x85, 0x30, 0x44, 0x45, 0x53, 0x54, 0x42, 0x00) +static const uuid_le UltraSIOVMGuid = ULTRA_SIOVM_GUID; /* Used in visornoop/visornoop_main.c * {5b52c5ac-e5f5-4d42-8dff-429eaecd221f} */ #define ULTRA_CONTROLDIRECTOR_CHANNEL_PROTOCOL_GUID \ - { 0x5b52c5ac, 0xe5f5, 0x4d42, \ - { 0x8d, 0xff, 0x42, 0x9e, 0xae, 0xcd, 0x22, 0x1f } } + UUID_LE(0x5b52c5ac, 0xe5f5, 0x4d42, \ + 0x8d, 0xff, 0x42, 0x9e, 0xae, 0xcd, 0x22, 0x1f) -static const GUID UltraControlDirectorChannelProtocolGuid = +static const uuid_le UltraControlDirectorChannelProtocolGuid = ULTRA_CONTROLDIRECTOR_CHANNEL_PROTOCOL_GUID; /* Used in visorchipset/visorchipset_main.c * {B4E79625-AEDE-4EAA-9E11-D3EDDCD4504C} */ #define ULTRA_DIAG_POOL_CHANNEL_PROTOCOL_GUID \ - {0xb4e79625, 0xaede, 0x4eaa, \ - { 0x9e, 0x11, 0xd3, 0xed, 0xdc, 0xd4, 0x50, 0x4c } } + UUID_LE(0xb4e79625, 0xaede, 0x4eaa, \ + 0x9e, 0x11, 0xd3, 0xed, 0xdc, 0xd4, 0x50, 0x4c) diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h index 17beec231d70..d8b12a733488 100644 --- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h @@ -16,6 +16,7 @@ #ifndef __CONTROLVMCHANNEL_H__ #define __CONTROLVMCHANNEL_H__ +#include #include "commontypes.h" #include "channel.h" #include "controlframework.h" @@ -25,10 +26,10 @@ enum { INVALID_GUEST_FIRMWARE, SAMPLE_GUEST_FIRMWARE, /* {2B3C2D10-7EF5-4ad8-B966-3448B7386B3D} */ #define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_GUID \ - {0x2b3c2d10, 0x7ef5, 0x4ad8, \ - {0xb9, 0x66, 0x34, 0x48, 0xb7, 0x38, 0x6b, 0x3d} } + UUID_LE(0x2b3c2d10, 0x7ef5, 0x4ad8, \ + 0xb9, 0x66, 0x34, 0x48, 0xb7, 0x38, 0x6b, 0x3d) -static const GUID UltraControlvmChannelProtocolGuid = +static const uuid_le UltraControlvmChannelProtocolGuid = ULTRA_CONTROLVM_CHANNEL_PROTOCOL_GUID; #define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE \ @@ -293,8 +294,8 @@ typedef struct _CONTROLVM_PACKET_DEVICE_CREATE { * can be dereferenced by the receiver * of this ControlVm command */ U64 channelBytes; /**< specifies size of the channel in bytes */ - GUID dataTypeGuid;/**< specifies format of data in channel */ - GUID devInstGuid; /**< instance guid for the device */ + uuid_le dataTypeGuid;/**< specifies format of data in channel */ + uuid_le devInstGuid; /**< instance guid for the device */ struct InterruptInfo intr; /**< specifies interrupt information */ } CONTROLVM_PACKET_DEVICE_CREATE; /* for CONTROLVM_DEVICE_CREATE */ @@ -333,9 +334,9 @@ typedef struct _CONTROLVM_MESSAGE_PACKET { * dereferenced by the receiver * of this ControlVm command */ U64 channelBytes; /*< size of the channel in bytes */ - GUID busDataTypeGuid;/*< indicates format of data in bus - * channel */ - GUID busInstGuid; /*< instance guid for the bus */ + uuid_le busDataTypeGuid;/*< indicates format of data in + bus channel */ + uuid_le busInstGuid; /*< instance guid for the bus */ } createBus; /* for CONTROLVM_BUS_CREATE */ struct { U32 busNo; /*< bus # (0..n-1) from the msg @@ -611,7 +612,7 @@ typedef struct _ULTRA_CONTROLVM_PARAMETERS_HEADER { U32 ClientLength; U32 NameOffset; U32 NameLength; - GUID Id; + uuid_le Id; U32 Revision; U32 Reserved; /* Natural alignment */ } ULTRA_CONTROLVM_PARAMETERS_HEADER; diff --git a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h index 83f1cc7b443f..1bea2f720e48 100644 --- a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/diagchannel.h @@ -38,16 +38,16 @@ /* {EEA7A573-DB82-447c-8716-EFBEAAAE4858} */ #define ULTRA_DIAG_CHANNEL_PROTOCOL_GUID \ - {0xeea7a573, 0xdb82, 0x447c, \ - {0x87, 0x16, 0xef, 0xbe, 0xaa, 0xae, 0x48, 0x58} } + UUID_LE(0xeea7a573, 0xdb82, 0x447c, \ + 0x87, 0x16, 0xef, 0xbe, 0xaa, 0xae, 0x48, 0x58) -static const GUID UltraDiagChannelProtocolGuid = +static const uuid_le UltraDiagChannelProtocolGuid = ULTRA_DIAG_CHANNEL_PROTOCOL_GUID; /* {E850F968-3263-4484-8CA5-2A35D087A5A8} */ #define ULTRA_DIAG_ROOT_CHANNEL_PROTOCOL_GUID \ - {0xe850f968, 0x3263, 0x4484, \ - {0x8c, 0xa5, 0x2a, 0x35, 0xd0, 0x87, 0xa5, 0xa8} } + UUID_LE(0xe850f968, 0x3263, 0x4484, \ + 0x8c, 0xa5, 0x2a, 0x35, 0xd0, 0x87, 0xa5, 0xa8) #define ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE ULTRA_CHANNEL_PROTOCOL_SIGNATURE diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/common-spar/include/channels/iochannel.h index 8cbf04d40f78..6dcfa6e78375 100644 --- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/iochannel.h @@ -29,6 +29,8 @@ * CHANNEL_ATTACHED -> CHANNEL_OPENED (performed only by GuestPart) */ +#include + #include "commontypes.h" #include "vmcallinterface.h" @@ -696,7 +698,7 @@ typedef struct _ULTRA_IO_CHANNEL_PROTOCOL { U8 macaddr[MAX_MACADDR_LEN]; /* 6 bytes */ U32 num_rcv_bufs; /* 4 */ U32 mtu; /* 4 */ - GUID zoneGuid; /* 16 */ + uuid_le zoneGuid; /* 16 */ } vnic; /* total 30 */ }; @@ -807,7 +809,7 @@ static inline int ULTRA_VHBA_init_channel(ULTRA_IO_CHANNEL_PROTOCOL *x, x->ChannelHeader.HeaderSize = sizeof(x->ChannelHeader); x->ChannelHeader.Size = COVER(bytes, 4096); x->ChannelHeader.Type = UltraVhbaChannelProtocolGuid; - x->ChannelHeader.ZoneGuid = Guid0; + x->ChannelHeader.ZoneGuid = NULL_UUID_LE; x->vhba.wwnn = *wwnn; x->vhba.max = *max; INIT_CLIENTSTRING(x, ULTRA_IO_CHANNEL_PROTOCOL, clientStr, @@ -832,7 +834,7 @@ static inline void ULTRA_VHBA_set_max(ULTRA_IO_CHANNEL_PROTOCOL *x, static inline int ULTRA_VNIC_init_channel(ULTRA_IO_CHANNEL_PROTOCOL *x, unsigned char *macaddr, U32 num_rcv_bufs, U32 mtu, - GUID zoneGuid, + uuid_le zoneGuid, unsigned char *clientStr, U32 clientStrLen, U64 bytes) { @@ -843,7 +845,7 @@ static inline int ULTRA_VNIC_init_channel(ULTRA_IO_CHANNEL_PROTOCOL *x, x->ChannelHeader.HeaderSize = sizeof(x->ChannelHeader); x->ChannelHeader.Size = COVER(bytes, 4096); x->ChannelHeader.Type = UltraVnicChannelProtocolGuid; - x->ChannelHeader.ZoneGuid = Guid0; + x->ChannelHeader.ZoneGuid = NULL_UUID_LE; MEMCPY(x->vnic.macaddr, macaddr, MAX_MACADDR_LEN); x->vnic.num_rcv_bufs = num_rcv_bufs; x->vnic.mtu = mtu; diff --git a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h index 7643042c0ce2..0dd3e2dd0e1d 100644 --- a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h +++ b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h @@ -23,15 +23,16 @@ * We currently use this for the client to provide various information about * the client devices and client drivers for the server end to see. */ +#include #include "commontypes.h" #include "vbusdeviceinfo.h" #include "channel.h" /* {193b331b-c58f-11da-95a9-00e08161165f} */ #define ULTRA_VBUS_CHANNEL_PROTOCOL_GUID \ - {0x193b331b, 0xc58f, 0x11da, \ - {0x95, 0xa9, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f} } -static const GUID UltraVbusChannelProtocolGuid = + UUID_LE(0x193b331b, 0xc58f, 0x11da, \ + 0x95, 0xa9, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f) +static const uuid_le UltraVbusChannelProtocolGuid = ULTRA_VBUS_CHANNEL_PROTOCOL_GUID; #define ULTRA_VBUS_CHANNEL_PROTOCOL_SIGNATURE ULTRA_CHANNEL_PROTOCOL_SIGNATURE @@ -112,8 +113,7 @@ ULTRA_VBUS_init_channel(ULTRA_VBUS_CHANNEL_PROTOCOL __iomem *x, writeq(bytesAllocated, &x->ChannelHeader.Size); memcpy_toio(&x->ChannelHeader.Type, &UltraVbusChannelProtocolGuid, sizeof(x->ChannelHeader.Type)); - memcpy_toio(&x->ChannelHeader.ZoneGuid, &Guid0, - sizeof(x->ChannelHeader.ZoneGuid)); + memcpy_toio(&x->ChannelHeader.ZoneGuid, &NULL_UUID_LE, sizeof(uuid_le)); writel(sizeof(ULTRA_VBUS_HEADERINFO), &x->HdrInfo.structBytes); writel(sizeof(ULTRA_VBUS_HEADERINFO), &x->HdrInfo.chpInfoByteOffset); writel(readl(&x->HdrInfo.chpInfoByteOffset) + diff --git a/drivers/staging/unisys/include/commontypes.h b/drivers/staging/unisys/include/commontypes.h index 3a8f302c87db..9de6f9dc5fbf 100644 --- a/drivers/staging/unisys/include/commontypes.h +++ b/drivers/staging/unisys/include/commontypes.h @@ -24,6 +24,7 @@ #include #include #include +#include #else #include #include @@ -59,16 +60,6 @@ #endif -typedef struct { - U32 data1; - U16 data2; - U16 data3; - U8 data4[8]; -} __attribute__ ((__packed__)) GUID; - -#ifndef GUID0 -#define GUID0 {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0} } -#endif typedef U64 GUEST_PHYSICAL_ADDRESS; #define MEMSET(ptr, val, len) memset(ptr, val, len) @@ -89,18 +80,16 @@ typedef U64 GUEST_PHYSICAL_ADDRESS; #define CHANNEL_GUID_MISMATCH(chType, chName, field, expected, actual, fil, \ lin, logCtx) \ do { \ - char s1[50], s2[50], s3[50]; \ - pr_err("Channel mismatch on channel=%s(%s) field=%s expected=%s actual=%s @%s:%d\n", \ - chName, GUID_format2(&chType, s1), field, \ - GUID_format2(&expected, s2), GUID_format2(&actual, s3), \ + pr_err("Channel mismatch on channel=%s(%pUL) field=%s expected=%pUL actual=%pUL @%s:%d\n", \ + chName, &chType, field, \ + &expected, &actual, \ fil, lin); \ } while (0) #define CHANNEL_U32_MISMATCH(chType, chName, field, expected, actual, fil, \ lin, logCtx) \ do { \ - char s1[50]; \ - pr_err("Channel mismatch on channel=%s(%s) field=%s expected=0x%-8.8lx actual=0x%-8.8lx @%s:%d\n", \ - chName, GUID_format2(&chType, s1), field, \ + pr_err("Channel mismatch on channel=%s(%pUL) field=%s expected=0x%-8.8lx actual=0x%-8.8lx @%s:%d\n", \ + chName, &chType, field, \ (unsigned long)expected, (unsigned long)actual, \ fil, lin); \ } while (0) @@ -108,9 +97,8 @@ typedef U64 GUEST_PHYSICAL_ADDRESS; #define CHANNEL_U64_MISMATCH(chType, chName, field, expected, actual, fil, \ lin, logCtx) \ do { \ - char s1[50]; \ - pr_err("Channel mismatch on channel=%s(%s) field=%s expected=0x%-8.8Lx actual=0x%-8.8Lx @%s:%d\n", \ - chName, GUID_format2(&chType, s1), field, \ + pr_err("Channel mismatch on channel=%s(%pUL) field=%s expected=0x%-8.8Lx actual=0x%-8.8Lx @%s:%d\n", \ + chName, &chType, field, \ (unsigned long long)expected, \ (unsigned long long)actual, \ fil, lin); \ @@ -128,21 +116,19 @@ typedef U64 GUEST_PHYSICAL_ADDRESS; #define CHANNEL_GUID_MISMATCH(chType, chName, field, expected, actual, fil, \ lin, logCtx) \ do { \ - char s1[50], s2[50], s3[50]; \ syslog(LOG_USER | LOG_ERR, \ - "Channel mismatch on channel=%s(%s) field=%s expected=%s actual=%s @%s:%d", \ - chName, GUID_format2(&chType, s1), field, \ - GUID_format2(&expected, s2), GUID_format2(&actual, s3), \ + "Channel mismatch on channel=%s(%pUL) field=%s expected=%pUL actual=%pUL @%s:%d", \ + chName, &chType, field, \ + &expected, &actual, \ fil, lin); \ } while (0) #define CHANNEL_U32_MISMATCH(chType, chName, field, expected, actual, fil, \ lin, logCtx) \ do { \ - char s1[50]; \ syslog(LOG_USER | LOG_ERR, \ - "Channel mismatch on channel=%s(%s) field=%s expected=0x%-8.8lx actual=0x%-8.8lx @%s:%d", \ - chName, GUID_format2(&chType, s1), field, \ + "Channel mismatch on channel=%s(%pUL) field=%s expected=0x%-8.8lx actual=0x%-8.8lx @%s:%d", \ + chName, chType, field, \ (unsigned long)expected, (unsigned long)actual, \ fil, lin); \ } while (0) @@ -150,10 +136,9 @@ typedef U64 GUEST_PHYSICAL_ADDRESS; #define CHANNEL_U64_MISMATCH(chType, chName, field, expected, actual, fil, \ lin, logCtx) \ do { \ - char s1[50]; \ syslog(LOG_USER | LOG_ERR, \ - "Channel mismatch on channel=%s(%s) field=%s expected=0x%-8.8Lx actual=0x%-8.8Lx @%s:%d", \ - chName, GUID_format2(&chType, s1), field, \ + "Channel mismatch on channel=%s(%pUL) field=%s expected=0x%-8.8Lx actual=0x%-8.8Lx @%s:%d", \ + chName, chType, field, \ (unsigned long long)expected, \ (unsigned long long)actual, \ fil, lin); \ @@ -167,4 +152,4 @@ typedef U64 GUEST_PHYSICAL_ADDRESS; #define VolatileBarrier() MEMORYBARRIER #endif -#include "guidutils.h" + diff --git a/drivers/staging/unisys/include/guidutils.h b/drivers/staging/unisys/include/guidutils.h deleted file mode 100644 index adeb92d8dd4d..000000000000 --- a/drivers/staging/unisys/include/guidutils.h +++ /dev/null @@ -1,203 +0,0 @@ -/* Copyright (C) 2010 - 2013 UNISYS CORPORATION - * All rights reserved. - * - * 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, GOOD TITLE or - * NON INFRINGEMENT. See the GNU General Public License for more - * details. - */ - -/* guidutils.h - * - * These are GUID manipulation inlines that can be used from either - * kernel-mode or user-mode. - * - */ -#ifndef __GUIDUTILS_H__ -#define __GUIDUTILS_H__ - -#ifdef __KERNEL__ -#include -#include -#include -#define GUID_STRTOUL kstrtoul -#else -#include -#include -#include -#include - -#define GUID_STRTOUL strtoul -#endif - -static inline char * -GUID_format1(const GUID *guid, char *s) -{ - sprintf(s, "{%-8.8lx-%-4.4x-%-4.4x-%-2.2x%-2.2x%-2.2x%-2.2x%-2.2x%-2.2x%-2.2x%-2.2x}", - (ulong) guid->data1, - guid->data2, - guid->data3, - guid->data4[0], - guid->data4[1], - guid->data4[2], - guid->data4[3], - guid->data4[4], guid->data4[5], guid->data4[6], guid->data4[7]); - return s; -} - -/** Format a GUID in Microsoft's 'what in the world were they thinking' - * format. - */ -static inline char * -GUID_format2(const GUID *guid, char *s) -{ - sprintf(s, "{%-8.8lx-%-4.4x-%-4.4x-%-2.2x%-2.2x-%-2.2x%-2.2x%-2.2x%-2.2x%-2.2x%-2.2x}", - (ulong) guid->data1, - guid->data2, - guid->data3, - guid->data4[0], - guid->data4[1], - guid->data4[2], - guid->data4[3], - guid->data4[4], guid->data4[5], guid->data4[6], guid->data4[7]); - return s; -} - -/** - * Like GUID_format2 but without the curly braces and the - * hex digits in upper case - */ -static inline char * -GUID_format3(const GUID *guid, char *s) -{ - sprintf(s, "%-8.8lX-%-4.4X-%-4.4X-%-2.2X%-2.2X-%-2.2X%-2.2X%-2.2X%-2.2X%-2.2X%-2.2X", - (ulong) guid->data1, - guid->data2, - guid->data3, - guid->data4[0], - guid->data4[1], - guid->data4[2], - guid->data4[3], - guid->data4[4], guid->data4[5], guid->data4[6], guid->data4[7]); - return s; -} - -/** Parse a guid string in any of these forms: - * {11111111-2222-3333-4455-66778899aabb} - * {11111111-2222-3333-445566778899aabb} - * 11111111-2222-3333-4455-66778899aabb - * 11111111-2222-3333-445566778899aabb - */ -static inline GUID -GUID_scan(U8 *p) -{ - GUID guid = GUID0; - U8 x[33]; - int count = 0; - int c, i = 0; - U8 cdata1[9]; - U8 cdata2[5]; - U8 cdata3[5]; - U8 cdata4[3]; - int dashcount = 0; - int brace = 0; - unsigned long uldata; - - if (!p) - return guid; - if (*p == '{') { - p++; - brace = 1; - } - while (count < 32) { - if (*p == '}') - return guid; - if (*p == '\0') - return guid; - c = toupper(*p); - p++; - if (c == '-') { - switch (dashcount) { - case 0: - if (i != 8) - return guid; - break; - case 1: - if (i != 4) - return guid; - break; - case 2: - if (i != 4) - return guid; - break; - case 3: - if (i != 4) - return guid; - break; - default: - return guid; - } - dashcount++; - i = 0; - continue; - } - if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F')) - i++; - else - return guid; - x[count++] = c; - } - x[count] = '\0'; - if (brace) { - if (*p == '}') - p++; - else - return guid; - } - if (dashcount == 3 || dashcount == 4) - ; - else - return guid; - memset(cdata1, 0, sizeof(cdata1)); - memset(cdata2, 0, sizeof(cdata2)); - memset(cdata3, 0, sizeof(cdata3)); - memset(cdata4, 0, sizeof(cdata4)); - memcpy(cdata1, x + 0, 8); - memcpy(cdata2, x + 8, 4); - memcpy(cdata3, x + 12, 4); - - if (GUID_STRTOUL((char *) cdata1, 16, &uldata) == 0) - guid.data1 = (U32)uldata; - if (GUID_STRTOUL((char *) cdata2, 16, &uldata) == 0) - guid.data2 = (U16)uldata; - if (GUID_STRTOUL((char *) cdata3, 16, &uldata) == 0) - guid.data3 = (U16)uldata; - - for (i = 0; i < 8; i++) { - memcpy(cdata4, x + 16 + (i * 2), 2); - if (GUID_STRTOUL((char *) cdata4, 16, &uldata) == 0) - guid.data4[i] = (U8) uldata; - } - - return guid; -} - -static inline char * -GUID_sanitize(char *inputGuidStr, char *outputGuidStr) -{ - GUID g; - GUID guid0 = GUID0; - *outputGuidStr = '\0'; - g = GUID_scan((U8 *) inputGuidStr); - if (memcmp(&g, &guid0, sizeof(GUID)) == 0) - return outputGuidStr; /* bad GUID format */ - return GUID_format1(&g, outputGuidStr); -} - -#endif diff --git a/drivers/staging/unisys/include/uisqueue.h b/drivers/staging/unisys/include/uisqueue.h index d7793a84903e..2a5bea3b3325 100644 --- a/drivers/staging/unisys/include/uisqueue.h +++ b/drivers/staging/unisys/include/uisqueue.h @@ -28,6 +28,7 @@ #include "uniklog.h" #include #include +#include #include "controlvmchannel.h" #include "controlvmcompletionstatus.h" @@ -136,8 +137,8 @@ struct device_info { void __iomem *chanptr; U64 channelAddr; U64 channelBytes; - GUID channelTypeGuid; - GUID devInstGuid; + uuid_le channelTypeGuid; + uuid_le devInstGuid; struct InterruptInfo intr; struct switch_info *swtch; char devid[30]; /* "vbus:dev" */ @@ -163,7 +164,7 @@ struct bus_info { U32 busNo, deviceCount; struct device_info **device; U64 guestHandle, recvBusInterruptHandle; - GUID busInstGuid; + uuid_le busInstGuid; ULTRA_VBUS_CHANNEL_PROTOCOL __iomem *pBusChannel; int busChannelBytes; struct proc_dir_entry *proc_dir; /* proc/uislib/vbus/ */ @@ -356,8 +357,8 @@ struct add_vbus_guestpart { * NOT YET USED */ U32 busNo; /* bus number to be created/deleted */ U32 deviceCount; /* max num of devices on bus */ - GUID busTypeGuid; /* indicates type of bus */ - GUID busInstGuid; /* instance guid for device */ + uuid_le busTypeGuid; /* indicates type of bus */ + uuid_le busInstGuid; /* instance guid for device */ }; struct del_vbus_guestpart { @@ -371,7 +372,7 @@ struct add_virt_guestpart { void __iomem *chanptr; /* pointer to data channel */ U32 busNo; /* bus number for the operation */ U32 deviceNo; /* number of device on the bus */ - GUID devInstGuid; /* instance guid for device */ + uuid_le devInstGuid; /* instance guid for device */ struct InterruptInfo intr; /* recv/send interrupt info */ /* recvInterruptHandle contains info needed in order to * register to receive interrupts on the data channel. diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index f4774c05f909..f4845f2ffa06 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -25,6 +25,7 @@ #include #include #include +#include #include "vmcallinterface.h" #include "channel.h" @@ -54,7 +55,7 @@ extern atomic_t UisUtils_Registered_Services; typedef unsigned int MACARRAY[MAX_MACADDR_LEN]; typedef struct ReqHandlerInfo_struct { - GUID switchTypeGuid; + uuid_le switchTypeGuid; int (*controlfunc)(struct io_msgs *); unsigned long min_channel_bytes; int (*Server_Channel_Ok)(unsigned long channelBytes); @@ -64,7 +65,7 @@ typedef struct ReqHandlerInfo_struct { struct list_head list_link; /* links into ReqHandlerInfo_list */ } ReqHandlerInfo_t; -ReqHandlerInfo_t *ReqHandlerAdd(GUID switchTypeGuid, +ReqHandlerInfo_t *ReqHandlerAdd(uuid_le switchTypeGuid, const char *switch_type_name, int (*controlfunc)(struct io_msgs *), unsigned long min_channel_bytes, @@ -73,8 +74,8 @@ ReqHandlerInfo_t *ReqHandlerAdd(GUID switchTypeGuid, int (*Server_Channel_Init) (void *x, unsigned char *clientStr, U32 clientStrLen, U64 bytes)); -ReqHandlerInfo_t *ReqHandlerFind(GUID switchTypeGuid); -int ReqHandlerDel(GUID switchTypeGuid); +ReqHandlerInfo_t *ReqHandlerFind(uuid_le switchTypeGuid); +int ReqHandlerDel(uuid_le switchTypeGuid); #define uislib_ioremap_cache(addr, size) \ dbg_ioremap_cache(addr, size, __FILE__, __LINE__) @@ -112,7 +113,7 @@ int uisutil_add_proc_line_ex(int *total, char **buffer, int *buffer_remaining, int uisctrl_register_req_handler(int type, void *fptr, ULTRA_VBUS_DEVICEINFO *chipset_DriverInfo); -int uisctrl_register_req_handler_ex(GUID switchTypeGuid, +int uisctrl_register_req_handler_ex(uuid_le switchTypeGuid, const char *switch_type_name, int (*fptr)(struct io_msgs *), unsigned long min_channel_bytes, @@ -123,7 +124,7 @@ int uisctrl_register_req_handler_ex(GUID switchTypeGuid, U32 clientStrLen, U64 bytes), ULTRA_VBUS_DEVICEINFO *chipset_DriverInfo); -int uisctrl_unregister_req_handler_ex(GUID switchTypeGuid); +int uisctrl_unregister_req_handler_ex(uuid_le switchTypeGuid); unsigned char *util_map_virt(struct phys_info *sg); void util_unmap_virt(struct phys_info *sg); unsigned char *util_map_virt_atomic(struct phys_info *sg); @@ -133,20 +134,20 @@ int uislib_server_inject_add_vnic(U32 switchNo, U32 BusNo, U32 numIntPorts, pCHANNEL_HEADER **chan); void uislib_server_inject_del_vnic(U32 switchNo, U32 busNo, U32 numIntPorts, U32 numExtPorts); -int uislib_client_inject_add_bus(U32 busNo, GUID instGuid, +int uislib_client_inject_add_bus(U32 busNo, uuid_le instGuid, U64 channelAddr, ulong nChannelBytes); int uislib_client_inject_del_bus(U32 busNo); int uislib_client_inject_add_vhba(U32 busNo, U32 devNo, U64 phys_chan_addr, U32 chan_bytes, - int is_test_addr, GUID instGuid, + int is_test_addr, uuid_le instGuid, struct InterruptInfo *intr); int uislib_client_inject_pause_vhba(U32 busNo, U32 devNo); int uislib_client_inject_resume_vhba(U32 busNo, U32 devNo); int uislib_client_inject_del_vhba(U32 busNo, U32 devNo); int uislib_client_inject_add_vnic(U32 busNo, U32 devNo, U64 phys_chan_addr, U32 chan_bytes, - int is_test_addr, GUID instGuid, + int is_test_addr, uuid_le instGuid, struct InterruptInfo *intr); int uislib_client_inject_pause_vnic(U32 busNo, U32 devNo); int uislib_client_inject_resume_vnic(U32 busNo, U32 devNo); @@ -195,7 +196,7 @@ struct chaninfo { */ #define WAIT_FOR_VALID_GUID(guid) \ do { \ - while (MEMCMP_IO(&guid, &Guid0, sizeof(Guid0)) == 0) { \ + while (uuid_le_cmp(guid, NULL_UUID_LE) == 0) { \ LOGERR("Waiting for non-0 GUID (why???)...\n"); \ UIS_THREAD_WAIT_SEC(5); \ } \ diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index fbdb19fc7891..41fa3607c4ac 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -587,10 +587,8 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) */ if (!msg->hdr.Flags.server) { struct guest_msgs cmd; - if (!memcmp - (&dev->channelTypeGuid, - &UltraVhbaChannelProtocolGuid, - sizeof(GUID))) { + if (!uuid_le_cmp(dev->channelTypeGuid, + UltraVhbaChannelProtocolGuid)) { WAIT_FOR_VALID_GUID(((CHANNEL_HEADER __iomem *) (dev-> chanptr))-> @@ -614,10 +612,8 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) dev->devInstGuid; cmd.add_vhba.intr = dev->intr; } else - if (!memcmp - (&dev->channelTypeGuid, - &UltraVnicChannelProtocolGuid, - sizeof(GUID))) { + if (!uuid_le_cmp(dev->channelTypeGuid, + UltraVnicChannelProtocolGuid)) { WAIT_FOR_VALID_GUID(((CHANNEL_HEADER __iomem *) (dev-> chanptr))-> @@ -723,16 +719,13 @@ pause_device(CONTROLVM_MESSAGE *msg) /* the msg is bound for virtpci; send * guest_msgs struct to callback */ - if (!memcmp - (&dev->channelTypeGuid, - &UltraVhbaChannelProtocolGuid, sizeof(GUID))) { + if (!uuid_le_cmp(dev->channelTypeGuid, + UltraVhbaChannelProtocolGuid)) { cmd.msgtype = GUEST_PAUSE_VHBA; cmd.pause_vhba.chanptr = dev->chanptr; } else - if (!memcmp - (&dev->channelTypeGuid, - &UltraVnicChannelProtocolGuid, - sizeof(GUID))) { + if (!uuid_le_cmp(dev->channelTypeGuid, + UltraVnicChannelProtocolGuid)) { cmd.msgtype = GUEST_PAUSE_VNIC; cmd.pause_vnic.chanptr = dev->chanptr; } else { @@ -798,15 +791,13 @@ resume_device(CONTROLVM_MESSAGE *msg) /* the msg is bound for virtpci; send * guest_msgs struct to callback */ - if (!memcmp(&dev->channelTypeGuid, - &UltraVhbaChannelProtocolGuid, - sizeof(GUID))) { + if (!uuid_le_cmp(dev->channelTypeGuid, + UltraVhbaChannelProtocolGuid)) { cmd.msgtype = GUEST_RESUME_VHBA; cmd.resume_vhba.chanptr = dev->chanptr; } else - if (!memcmp(&dev->channelTypeGuid, - &UltraVnicChannelProtocolGuid, - sizeof(GUID))) { + if (!uuid_le_cmp(dev->channelTypeGuid, + UltraVnicChannelProtocolGuid)) { cmd.msgtype = GUEST_RESUME_VNIC; cmd.resume_vnic.chanptr = dev->chanptr; } else { @@ -873,16 +864,13 @@ destroy_device(CONTROLVM_MESSAGE *msg, char *buf) /* the msg is bound for virtpci; send * guest_msgs struct to callback */ - if (!memcmp - (&dev->channelTypeGuid, - &UltraVhbaChannelProtocolGuid, sizeof(GUID))) { + if (!uuid_le_cmp(dev->channelTypeGuid, + UltraVhbaChannelProtocolGuid)) { cmd.msgtype = GUEST_DEL_VHBA; cmd.del_vhba.chanptr = dev->chanptr; } else - if (!memcmp - (&dev->channelTypeGuid, - &UltraVnicChannelProtocolGuid, - sizeof(GUID))) { + if (!uuid_le_cmp(dev->channelTypeGuid, + UltraVnicChannelProtocolGuid)) { cmd.msgtype = GUEST_DEL_VNIC; cmd.del_vnic.chanptr = dev->chanptr; } else { @@ -1008,7 +996,7 @@ delete_device_glue(U32 busNo, U32 devNo) } int -uislib_client_inject_add_bus(U32 busNo, GUID instGuid, +uislib_client_inject_add_bus(U32 busNo, uuid_le instGuid, U64 channelAddr, ulong nChannelBytes) { CONTROLVM_MESSAGE msg; @@ -1109,7 +1097,7 @@ EXPORT_SYMBOL_GPL(uislib_client_inject_resume_vhba); int uislib_client_inject_add_vhba(U32 busNo, U32 devNo, U64 phys_chan_addr, U32 chan_bytes, - int is_test_addr, GUID instGuid, + int is_test_addr, uuid_le instGuid, struct InterruptInfo *intr) { CONTROLVM_MESSAGE msg; @@ -1168,7 +1156,7 @@ EXPORT_SYMBOL_GPL(uislib_client_inject_del_vhba); int uislib_client_inject_add_vnic(U32 busNo, U32 devNo, U64 phys_chan_addr, U32 chan_bytes, - int is_test_addr, GUID instGuid, + int is_test_addr, uuid_le instGuid, struct InterruptInfo *intr) { CONTROLVM_MESSAGE msg; @@ -1272,7 +1260,6 @@ uislib_client_add_vnic(U32 busNo) BOOL busCreated = FALSE; int devNo = 0; /* Default to 0, since only one device * will be created for this bus... */ - GUID dummyGuid = GUID0; CONTROLVM_MESSAGE msg; init_msg_header(&msg, CONTROLVM_BUS_CREATE, 0, 0); @@ -1291,7 +1278,7 @@ uislib_client_add_vnic(U32 busNo) msg.hdr.Flags.testMessage = 1; msg.cmd.createDevice.busNo = busNo; msg.cmd.createDevice.devNo = devNo; - msg.cmd.createDevice.devInstGuid = dummyGuid; + msg.cmd.createDevice.devInstGuid = NULL_UUID_LE; memset(&msg.cmd.createDevice.intr, 0, sizeof(struct InterruptInfo)); msg.cmd.createDevice.channelAddr = PhysicalDataChan; msg.cmd.createDevice.channelBytes = MIN_IO_CHANNEL_SIZE; diff --git a/drivers/staging/unisys/uislib/uisutils.c b/drivers/staging/unisys/uislib/uisutils.c index b49647ccc9d0..0f1bb739975e 100644 --- a/drivers/staging/unisys/uislib/uisutils.c +++ b/drivers/staging/unisys/uislib/uisutils.c @@ -24,8 +24,9 @@ #include "uisutils.h" #include "version.h" #include "vbushelper.h" -#include "guidutils.h" +#include #include +#include #ifdef CONFIG_HIGHMEM #include #endif @@ -104,7 +105,7 @@ uisctrl_register_req_handler(int type, void *fptr, EXPORT_SYMBOL_GPL(uisctrl_register_req_handler); int -uisctrl_register_req_handler_ex(GUID switchTypeGuid, +uisctrl_register_req_handler_ex(uuid_le switchTypeGuid, const char *switch_type_name, int (*controlfunc)(struct io_msgs *), unsigned long min_channel_bytes, @@ -115,24 +116,22 @@ uisctrl_register_req_handler_ex(GUID switchTypeGuid, U32 clientStrLen, U64 bytes), ULTRA_VBUS_DEVICEINFO *chipset_DriverInfo) { - char s[99]; ReqHandlerInfo_t *pReqHandlerInfo; int rc = 0; /* assume failure */ - LOGINF("type=%s, controlfunc=0x%p.\n", - GUID_format1(&switchTypeGuid, s), controlfunc); + LOGINF("type=%pUL, controlfunc=0x%p.\n", + &switchTypeGuid, controlfunc); if (!controlfunc) { - LOGERR("%s: controlfunc must be supplied\n", - GUID_format1(&switchTypeGuid, s)); + LOGERR("%pUL: controlfunc must be supplied\n", &switchTypeGuid); goto Away; } if (!Server_Channel_Ok) { - LOGERR("%s: Server_Channel_Ok must be supplied\n", - GUID_format1(&switchTypeGuid, s)); + LOGERR("%pUL: Server_Channel_Ok must be supplied\n", + &switchTypeGuid); goto Away; } if (!Server_Channel_Init) { - LOGERR("%s: Server_Channel_Init must be supplied\n", - GUID_format1(&switchTypeGuid, s)); + LOGERR("%pUL: Server_Channel_Init must be supplied\n", + &switchTypeGuid); goto Away; } pReqHandlerInfo = ReqHandlerAdd(switchTypeGuid, @@ -141,8 +140,7 @@ uisctrl_register_req_handler_ex(GUID switchTypeGuid, min_channel_bytes, Server_Channel_Ok, Server_Channel_Init); if (!pReqHandlerInfo) { - LOGERR("failed to add %s to server list\n", - GUID_format1(&switchTypeGuid, s)); + LOGERR("failed to add %pUL to server list\n", &switchTypeGuid); goto Away; } @@ -156,30 +154,27 @@ Away: VERSION, NULL, __DATE__, __TIME__); } else - LOGERR("failed to register type %s.\n", - GUID_format1(&switchTypeGuid, s)); + LOGERR("failed to register type %pUL.\n", &switchTypeGuid); return rc; } EXPORT_SYMBOL_GPL(uisctrl_register_req_handler_ex); int -uisctrl_unregister_req_handler_ex(GUID switchTypeGuid) +uisctrl_unregister_req_handler_ex(uuid_le switchTypeGuid) { - char s[99]; int rc = 0; /* assume failure */ - LOGINF("type=%s.\n", GUID_format1(&switchTypeGuid, s)); + LOGINF("type=%pUL.\n", &switchTypeGuid); if (ReqHandlerDel(switchTypeGuid) < 0) { - LOGERR("failed to remove %s from server list\n", - GUID_format1(&switchTypeGuid, s)); + LOGERR("failed to remove %pUL from server list\n", + &switchTypeGuid); goto Away; } atomic_dec(&UisUtils_Registered_Services); rc = 1; /* success */ Away: if (!rc) - LOGERR("failed to unregister type %s.\n", - GUID_format1(&switchTypeGuid, s)); + LOGERR("failed to unregister type %pUL.\n", &switchTypeGuid); return rc; } EXPORT_SYMBOL_GPL(uisctrl_unregister_req_handler_ex); @@ -281,7 +276,7 @@ static LIST_HEAD(ReqHandlerInfo_list); /* list of ReqHandlerInfo_t */ static DEFINE_SPINLOCK(ReqHandlerInfo_list_lock); ReqHandlerInfo_t * -ReqHandlerAdd(GUID switchTypeGuid, +ReqHandlerAdd(uuid_le switchTypeGuid, const char *switch_type_name, int (*controlfunc)(struct io_msgs *), unsigned long min_channel_bytes, @@ -310,16 +305,14 @@ ReqHandlerAdd(GUID switchTypeGuid, } ReqHandlerInfo_t * -ReqHandlerFind(GUID switchTypeGuid) +ReqHandlerFind(uuid_le switchTypeGuid) { struct list_head *lelt, *tmp; ReqHandlerInfo_t *entry = NULL; spin_lock(&ReqHandlerInfo_list_lock); list_for_each_safe(lelt, tmp, &ReqHandlerInfo_list) { entry = list_entry(lelt, ReqHandlerInfo_t, list_link); - if (memcmp - (&entry->switchTypeGuid, &switchTypeGuid, - sizeof(GUID)) == 0) { + if (uuid_le_cmp(entry->switchTypeGuid, switchTypeGuid) == 0) { spin_unlock(&ReqHandlerInfo_list_lock); return entry; } @@ -329,7 +322,7 @@ ReqHandlerFind(GUID switchTypeGuid) } int -ReqHandlerDel(GUID switchTypeGuid) +ReqHandlerDel(uuid_le switchTypeGuid) { struct list_head *lelt, *tmp; ReqHandlerInfo_t *entry = NULL; @@ -337,9 +330,7 @@ ReqHandlerDel(GUID switchTypeGuid) spin_lock(&ReqHandlerInfo_list_lock); list_for_each_safe(lelt, tmp, &ReqHandlerInfo_list) { entry = list_entry(lelt, ReqHandlerInfo_t, list_link); - if (memcmp - (&entry->switchTypeGuid, &switchTypeGuid, - sizeof(GUID)) == 0) { + if (uuid_le_cmp(entry->switchTypeGuid, switchTypeGuid) == 0) { list_del(lelt); kfree(entry); rc++; diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c index 9a35dd2cd472..71246feb154f 100644 --- a/drivers/staging/unisys/virtpci/virtpci.c +++ b/drivers/staging/unisys/virtpci/virtpci.c @@ -365,7 +365,7 @@ static int add_vhba(struct add_virt_guestpart *addparams) memcpy_fromio(&net.zoneGuid, \ &((ULTRA_IO_CHANNEL_PROTOCOL __iomem *) \ chanptr)->vnic.zoneGuid, \ - sizeof(GUID)); \ + sizeof(uuid_le)); \ } /* adds a vnic @@ -391,14 +391,10 @@ add_vnic(struct add_virt_guestpart *addparams) GET_BUS_DEV(addparams->busNo); - LOGINF("Adding vnic macaddr:%02x:%02x:%02x:%02x:%02x:%02x rcvbufs:%d mtu:%d chanptr:%p{%-8.8lx-%-4.4x-%-4.4x-%-2.2x%-2.2x%-2.2x%-2.2x%-2.2x%-2.2x%-2.2x%-2.2x}\n", + LOGINF("Adding vnic macaddr:%02x:%02x:%02x:%02x:%02x:%02x rcvbufs:%d mtu:%d chanptr:%p%pUL\n", net.mac_addr[0], net.mac_addr[1], net.mac_addr[2], net.mac_addr[3], net.mac_addr[4], net.mac_addr[5], net.num_rcv_bufs, net.mtu, - addparams->chanptr, (ulong) net.zoneGuid.data1, net.zoneGuid.data2, - net.zoneGuid.data3, net.zoneGuid.data4[0], net.zoneGuid.data4[1], - net.zoneGuid.data4[2], net.zoneGuid.data4[3], - net.zoneGuid.data4[4], net.zoneGuid.data4[5], - net.zoneGuid.data4[6], net.zoneGuid.data4[7]); + addparams->chanptr, &net.zoneGuid); i = virtpci_device_add(vbus, VIRTNIC_TYPE, addparams, NULL, &net); if (i) { LOGINF("Added vnic macaddr:%02x:%02x:%02x:%02x:%02x:%02x\n", @@ -1510,7 +1506,6 @@ static ssize_t virt_proc_write(struct file *file, const char __user *buffer, struct add_virt_guestpart addparams; struct del_vbus_guestpart busdelparams; struct del_virt_guestpart delparams; - GUID dummyGuid = GUID0; #ifdef STORAGE_CHANNEL U64 storagechannel; #endif @@ -1561,7 +1556,7 @@ static ssize_t virt_proc_write(struct file *file, const char __user *buffer, __pa(chanptr), MIN_IO_CHANNEL_SIZE, 1, /* test msg */ - dummyGuid, /* inst guid */ + NULL_UUID_LE, /* inst guid */ NULL)) { /*interrupt info */ LOGERR("FAILED to inject add vnic\n"); return -EFAULT; diff --git a/drivers/staging/unisys/virtpci/virtpci.h b/drivers/staging/unisys/virtpci/virtpci.h index b695c4b8e8bd..f7be17b669c4 100644 --- a/drivers/staging/unisys/virtpci/virtpci.h +++ b/drivers/staging/unisys/virtpci/virtpci.h @@ -24,6 +24,7 @@ #include "uisqueue.h" #include +#include #define PCI_DEVICE_ID_VIRTHBA 0xAA00 #define PCI_DEVICE_ID_VIRTNIC 0xAB00 @@ -41,7 +42,7 @@ struct net_adap_info { u8 mac_addr[MAX_MACADDR_LEN]; int num_rcv_bufs; unsigned mtu; - GUID zoneGuid; + uuid_le zoneGuid; }; typedef enum { diff --git a/drivers/staging/unisys/visorchannel/visorchannel.h b/drivers/staging/unisys/visorchannel/visorchannel.h index a8c2ebd0c99a..a00dfb55c8d2 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel.h +++ b/drivers/staging/unisys/visorchannel/visorchannel.h @@ -18,6 +18,8 @@ #ifndef __VISORCHANNEL_H__ #define __VISORCHANNEL_H__ +#include + #include "commontypes.h" #include "memregion.h" #include "channel.h" @@ -38,15 +40,15 @@ typedef struct VISORCHANNEL_Tag VISORCHANNEL; * In this case, the values can simply be read from the channel header. */ VISORCHANNEL *visorchannel_create(HOSTADDRESS physaddr, - ulong channelBytes, GUID guid); + ulong channelBytes, uuid_le guid); VISORCHANNEL *visorchannel_create_overlapped(ulong channelBytes, VISORCHANNEL *parent, ulong off, - GUID guid); + uuid_le guid); VISORCHANNEL *visorchannel_create_with_lock(HOSTADDRESS physaddr, - ulong channelBytes, GUID guid); + ulong channelBytes, uuid_le guid); VISORCHANNEL *visorchannel_create_overlapped_with_lock(ulong channelBytes, VISORCHANNEL *parent, - ulong off, GUID guid); + ulong off, uuid_le guid); void visorchannel_destroy(VISORCHANNEL *channel); int visorchannel_read(VISORCHANNEL *channel, ulong offset, void *local, ulong nbytes); @@ -64,9 +66,9 @@ ulong visorchannel_get_nbytes(VISORCHANNEL *channel); char *visorchannel_id(VISORCHANNEL *channel, char *s); char *visorchannel_zoneid(VISORCHANNEL *channel, char *s); U64 visorchannel_get_clientpartition(VISORCHANNEL *channel); -GUID visorchannel_get_GUID(VISORCHANNEL *channel); +uuid_le visorchannel_get_uuid(VISORCHANNEL *channel); MEMREGION *visorchannel_get_memregion(VISORCHANNEL *channel); -char *visorchannel_GUID_id(GUID *guid, char *s); +char *visorchannel_uuid_id(uuid_le *guid, char *s); void visorchannel_debug(VISORCHANNEL *channel, int nQueues, struct seq_file *seq, U32 off); void visorchannel_dump_section(VISORCHANNEL *chan, char *s, diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c index 4427d01b1126..bc4fc671a0b9 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c +++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c @@ -24,14 +24,14 @@ #include "globals.h" #include "visorchannel.h" -#include "guidutils.h" +#include #define MYDRVNAME "visorchannel" struct VISORCHANNEL_Tag { MEMREGION *memregion; /* from visor_memregion_create() */ CHANNEL_HEADER chan_hdr; - GUID guid; + uuid_le guid; ulong size; BOOL needs_lock; spinlock_t insert_lock; @@ -50,7 +50,7 @@ struct VISORCHANNEL_Tag { */ static VISORCHANNEL * visorchannel_create_guts(HOSTADDRESS physaddr, ulong channelBytes, - VISORCHANNEL *parent, ulong off, GUID guid, + VISORCHANNEL *parent, ulong off, uuid_le guid, BOOL needs_lock) { VISORCHANNEL *p = NULL; @@ -90,7 +90,7 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channelBytes, if (channelBytes == 0) /* we had better be a CLIENT of this channel */ channelBytes = (ulong) p->chan_hdr.Size; - if (STRUCTSEQUAL(guid, Guid0)) + if (uuid_le_cmp(guid, NULL_UUID_LE) == 0) /* we had better be a CLIENT of this channel */ guid = p->chan_hdr.Type; if (visor_memregion_resize(p->memregion, channelBytes) < 0) { @@ -114,7 +114,7 @@ Away: } VISORCHANNEL * -visorchannel_create(HOSTADDRESS physaddr, ulong channelBytes, GUID guid) +visorchannel_create(HOSTADDRESS physaddr, ulong channelBytes, uuid_le guid) { return visorchannel_create_guts(physaddr, channelBytes, NULL, 0, guid, FALSE); @@ -123,7 +123,7 @@ EXPORT_SYMBOL_GPL(visorchannel_create); VISORCHANNEL * visorchannel_create_with_lock(HOSTADDRESS physaddr, ulong channelBytes, - GUID guid) + uuid_le guid) { return visorchannel_create_guts(physaddr, channelBytes, NULL, 0, guid, TRUE); @@ -132,7 +132,7 @@ EXPORT_SYMBOL_GPL(visorchannel_create_with_lock); VISORCHANNEL * visorchannel_create_overlapped(ulong channelBytes, - VISORCHANNEL *parent, ulong off, GUID guid) + VISORCHANNEL *parent, ulong off, uuid_le guid) { return visorchannel_create_guts(0, channelBytes, parent, off, guid, FALSE); @@ -142,7 +142,7 @@ EXPORT_SYMBOL_GPL(visorchannel_create_overlapped); VISORCHANNEL * visorchannel_create_overlapped_with_lock(ulong channelBytes, VISORCHANNEL *parent, ulong off, - GUID guid) + uuid_le guid) { return visorchannel_create_guts(0, channelBytes, parent, off, guid, TRUE); @@ -177,23 +177,24 @@ visorchannel_get_nbytes(VISORCHANNEL *channel) EXPORT_SYMBOL_GPL(visorchannel_get_nbytes); char * -visorchannel_GUID_id(GUID *guid, char *s) +visorchannel_uuid_id(uuid_le *guid, char *s) { - return GUID_format1(guid, s); + sprintf(s, "%pUL", guid); + return s; } -EXPORT_SYMBOL_GPL(visorchannel_GUID_id); +EXPORT_SYMBOL_GPL(visorchannel_uuid_id); char * visorchannel_id(VISORCHANNEL *channel, char *s) { - return visorchannel_GUID_id(&channel->guid, s); + return visorchannel_uuid_id(&channel->guid, s); } EXPORT_SYMBOL_GPL(visorchannel_id); char * visorchannel_zoneid(VISORCHANNEL *channel, char *s) { - return visorchannel_GUID_id(&channel->chan_hdr.ZoneGuid, s); + return visorchannel_uuid_id(&channel->chan_hdr.ZoneGuid, s); } EXPORT_SYMBOL_GPL(visorchannel_zoneid); @@ -204,12 +205,12 @@ visorchannel_get_clientpartition(VISORCHANNEL *channel) } EXPORT_SYMBOL_GPL(visorchannel_get_clientpartition); -GUID -visorchannel_get_GUID(VISORCHANNEL *channel) +uuid_le +visorchannel_get_uuid(VISORCHANNEL *channel) { return channel->guid; } -EXPORT_SYMBOL_GPL(visorchannel_get_GUID); +EXPORT_SYMBOL_GPL(visorchannel_get_uuid); MEMREGION * visorchannel_get_memregion(VISORCHANNEL *channel) @@ -558,7 +559,6 @@ visorchannel_debug(VISORCHANNEL *channel, int nQueues, MEMREGION *memregion = NULL; CHANNEL_HEADER hdr; CHANNEL_HEADER *phdr = &hdr; - char s[99]; int i = 0; int errcode = 0; @@ -588,9 +588,8 @@ visorchannel_debug(VISORCHANNEL *channel, int nQueues, nbytes = (ulong) (phdr->Size); seq_printf(seq, "--- Begin channel @0x%-16.16Lx for 0x%lx bytes (region=0x%lx bytes) ---\n", addr + off, nbytes, nbytes_region); - seq_printf(seq, "Type = %s\n", GUID_format2(&phdr->Type, s)); - seq_printf(seq, "ZoneGuid = %s\n", - GUID_format2(&phdr->ZoneGuid, s)); + seq_printf(seq, "Type = %pUL\n", &phdr->Type); + seq_printf(seq, "ZoneGuid = %pUL\n", &phdr->ZoneGuid); seq_printf(seq, "Signature = 0x%-16.16Lx\n", (long long) phdr->Signature); seq_printf(seq, "LegacyState = %lu\n", (ulong) phdr->LegacyState); diff --git a/drivers/staging/unisys/visorchannel/visorchannel_main.c b/drivers/staging/unisys/visorchannel/visorchannel_main.c index c8f89bd75e0c..f4be2e62c97d 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel_main.c +++ b/drivers/staging/unisys/visorchannel/visorchannel_main.c @@ -22,7 +22,7 @@ #include "globals.h" #include "channel.h" #include "visorchannel.h" -#include "guidutils.h" +#include #define MYDRVNAME "visorchannel" diff --git a/drivers/staging/unisys/visorchipset/parser.c b/drivers/staging/unisys/visorchipset/parser.c index 948fbb8ed09c..4274dd2dbbd1 100644 --- a/drivers/staging/unisys/visorchipset/parser.c +++ b/drivers/staging/unisys/visorchipset/parser.c @@ -20,6 +20,7 @@ #include "controlvmchannel.h" #include #include +#include #define MYDRVNAME "visorchipset_parser" #define CURRENT_FILE_PC VISOR_CHIPSET_PC_parser_c @@ -191,7 +192,7 @@ parser_byteStream_get(PARSER_CONTEXT *ctx, ulong *nbytes) return (void *) ctx->data; } -GUID +uuid_le parser_id_get(PARSER_CONTEXT *ctx) { ULTRA_CONTROLVM_PARAMETERS_HEADER *phdr = NULL; @@ -199,7 +200,7 @@ parser_id_get(PARSER_CONTEXT *ctx) if (ctx == NULL) { ERRDRV("%s (%s:%d) - no context", __func__, __FILE__, __LINE__); - return Guid0; + return NULL_UUID_LE; } phdr = (ULTRA_CONTROLVM_PARAMETERS_HEADER *) (ctx->data); return phdr->Id; diff --git a/drivers/staging/unisys/visorchipset/parser.h b/drivers/staging/unisys/visorchipset/parser.h index 3e4aedc580ce..be85fd68c0c4 100644 --- a/drivers/staging/unisys/visorchipset/parser.h +++ b/drivers/staging/unisys/visorchipset/parser.h @@ -18,6 +18,8 @@ #ifndef __PARSER_H__ #define __PARSER_H__ +#include + #include "uniklog.h" #include "timskmod.h" #include "channel.h" @@ -37,7 +39,7 @@ PARSER_CONTEXT *parser_init_byteStream(U64 addr, U32 bytes, BOOL isLocal, void parser_param_start(PARSER_CONTEXT *ctx, PARSER_WHICH_STRING which_string); void *parser_param_get(PARSER_CONTEXT *ctx, char *nam, int namesize); void *parser_string_get(PARSER_CONTEXT *ctx); -GUID parser_id_get(PARSER_CONTEXT *ctx); +uuid_le parser_id_get(PARSER_CONTEXT *ctx); char *parser_simpleString_get(PARSER_CONTEXT *ctx); void *parser_byteStream_get(PARSER_CONTEXT *ctx, ulong *nbytes); void parser_done(PARSER_CONTEXT *ctx); diff --git a/drivers/staging/unisys/visorchipset/testing.h b/drivers/staging/unisys/visorchipset/testing.h index ad378b82cf99..015d502cbb16 100644 --- a/drivers/staging/unisys/visorchipset/testing.h +++ b/drivers/staging/unisys/visorchipset/testing.h @@ -19,6 +19,7 @@ #define __VISORCHIPSET_TESTING_H__ #define VISORCHIPSET_TEST_PROC +#include #include "globals.h" #include "controlvmchannel.h" @@ -28,10 +29,10 @@ void test_manufacture_vnic_client_add(void *p); void test_manufacture_vnic_client_add_phys(HOSTADDRESS addr); void test_manufacture_preamble_messages(void); void test_manufacture_device_attach(ulong busNo, ulong devNo); -void test_manufacture_device_add(ulong busNo, ulong devNo, GUID dataTypeGuid, +void test_manufacture_device_add(ulong busNo, ulong devNo, uuid_le dataTypeGuid, void *pChannel); void test_manufacture_add_bus(ulong busNo, ulong maxDevices, - GUID id, u8 *name, BOOL isServer); + uuid_le id, u8 *name, BOOL isServer); void test_manufacture_device_destroy(ulong busNo, ulong devNo); void test_manufacture_bus_destroy(ulong busNo); void test_manufacture_detach_externalPort(ulong switchNo, ulong externalPortNo); diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h index 06646e4e3f1e..e01cc7207bae 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset.h +++ b/drivers/staging/unisys/visorchipset/visorchipset.h @@ -18,6 +18,8 @@ #ifndef __VISORCHIPSET_H__ #define __VISORCHIPSET_H__ +#include + #include "timskmod.h" #include "channel.h" #include "controlvmchannel.h" @@ -63,8 +65,8 @@ typedef struct { HOSTADDRESS channelAddr; struct InterruptInfo intr; U64 nChannelBytes; - GUID channelTypeGuid; - GUID channelInstGuid; + uuid_le channelTypeGuid; + uuid_le channelInstGuid; } VISORCHIPSET_CHANNEL_INFO; @@ -77,7 +79,7 @@ typedef struct { struct list_head entry; U32 busNo; U32 devNo; - GUID devInstGuid; + uuid_le devInstGuid; VISORCHIPSET_STATE state; VISORCHIPSET_CHANNEL_INFO chanInfo; U32 Reserved1; /* CONTROLVM_ID */ @@ -125,7 +127,7 @@ typedef struct { U32 busNo; VISORCHIPSET_STATE state; VISORCHIPSET_CHANNEL_INFO chanInfo; - GUID partitionGuid; + uuid_le partitionGuid; U64 partitionHandle; U8 *name; /* UTF8 */ U8 *description; /* UTF8 */ @@ -161,7 +163,7 @@ findbus(struct list_head *list, U32 busNo) typedef struct { U32 switchNo; VISORCHIPSET_STATE state; - GUID switchTypeGuid; + uuid_le switchTypeGuid; U8 *authService1; U8 *authService2; U8 *authService3; @@ -181,7 +183,7 @@ typedef struct { U32 switchNo; U32 externalPortNo; VISORCHIPSET_STATE state; - GUID networkZoneGuid; + uuid_le networkZoneGuid; int pdPort; U8 *ip; U8 *ipNetmask; @@ -224,7 +226,7 @@ typedef struct { void (*device_destroy)(ulong busNo, ulong devNo); void (*device_pause)(ulong busNo, ulong devNo); void (*device_resume)(ulong busNo, ulong devNo); - int (*get_channel_info)(GUID typeGuid, ulong *minSize, + int (*get_channel_info)(uuid_le typeGuid, ulong *minSize, ulong *maxSize); } VISORCHIPSET_BUSDEV_NOTIFIERS; diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 5b955926f42d..02874e69c4fc 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -26,7 +26,6 @@ #include "parser.h" #include "uniklog.h" #include "uisutils.h" -#include "guidutils.h" #include "controlvmcompletionstatus.h" #include "guestlinuxdebug.h" #include "filexfer.h" @@ -34,6 +33,7 @@ #include #include #include +#include #define CURRENT_FILE_PC VISOR_CHIPSET_PC_visorchipset_main_c #define TEST_VNIC_PHYSITF "eth0" /* physical network itf for @@ -82,7 +82,7 @@ typedef struct { static CONTROLVM_MESSAGE_HEADER g_DiagMsgHdr; static CONTROLVM_MESSAGE_HEADER g_ChipSetMsgHdr; static CONTROLVM_MESSAGE_HEADER g_DelDumpMsgHdr; -static const GUID UltraDiagPoolChannelProtocolGuid = +static const uuid_le UltraDiagPoolChannelProtocolGuid = ULTRA_DIAG_POOL_CHANNEL_PROTOCOL_GUID; /* 0xffffff is an invalid Bus/Device number */ static ulong g_diagpoolBusNo = 0xffffff; @@ -93,15 +93,12 @@ static CONTROLVM_MESSAGE_PACKET g_DeviceChangeStatePacket; * "visorhackbus") */ #define FOR_VISORHACKBUS(channel_type_guid) \ - ((memcmp(&channel_type_guid, &UltraVnicChannelProtocolGuid, \ - sizeof(GUID)) == 0) || \ - (memcmp(&channel_type_guid, &UltraVhbaChannelProtocolGuid, \ - sizeof(GUID)) == 0)) + (((uuid_le_cmp(channel_type_guid, UltraVnicChannelProtocolGuid) == 0)\ + || (uuid_le_cmp(channel_type_guid, UltraVhbaChannelProtocolGuid) == 0))) #define FOR_VISORBUS(channel_type_guid) (!(FOR_VISORHACKBUS(channel_type_guid))) #define is_diagpool_channel(channel_type_guid) \ - (memcmp(&channel_type_guid, \ - &UltraDiagPoolChannelProtocolGuid, sizeof(GUID)) == 0) + (uuid_le_cmp(channel_type_guid, UltraDiagPoolChannelProtocolGuid) == 0) typedef enum { PARTPROP_invalid, @@ -1189,7 +1186,7 @@ bus_configure(CONTROLVM_MESSAGE *inmsg, PARSER_CONTEXT *parser_ctx) parser_param_start(parser_ctx, PARSERSTRING_NAME); pBusInfo->name = parser_string_get(parser_ctx); - visorchannel_GUID_id(&pBusInfo->partitionGuid, s); + visorchannel_uuid_id(&pBusInfo->partitionGuid, s); pBusInfo->procObject = visor_proc_CreateObject(PartitionType, s, (void *) (pBusInfo)); if (pBusInfo->procObject == NULL) { -- cgit v1.2.3 From b27a00de27cd2ba7ad86959b41f38c987816f4ff Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Mon, 12 May 2014 12:38:29 -0400 Subject: staging: unisys: remove testing proc interfaces from uislib Several proc interfaces in the uislib module were intended for debug and testing during initial driver development. They are no longer needed, so we should remove them from the module. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/uislib/uislib.c | 534 +-------------------------------- 1 file changed, 1 insertion(+), 533 deletions(-) diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 41fa3607c4ac..843a94b70052 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -45,7 +45,6 @@ #define SET_PROC_OWNER(x, y) -#define UISLIB_TEST_PROC #define POLLJIFFIES_NORMAL 1 /* Choose whether or not you want to wakeup the request-polling thread * after an IO termination: @@ -91,44 +90,20 @@ static int Go_Polling_Device_Channels; static struct proc_dir_entry *uislib_proc_dir; static struct proc_dir_entry *uislib_proc_vbus_dir; -static struct proc_dir_entry *vnic_proc_entry; /* Used to be "datachan" */ -static struct proc_dir_entry *ctrlchan_proc_entry; -static struct proc_dir_entry *pmem_proc_entry; static struct proc_dir_entry *info_proc_entry; -static struct proc_dir_entry *switch_proc_entry; -static struct proc_dir_entry *extport_proc_entry; static struct proc_dir_entry *platformnumber_proc_entry; -static struct proc_dir_entry *bus_proc_entry; -static struct proc_dir_entry *dev_proc_entry; -static struct proc_dir_entry *chipset_proc_entry; static struct proc_dir_entry *cycles_before_wait_proc_entry; -static struct proc_dir_entry *reset_counts_proc_entry; static struct proc_dir_entry *smart_wakeup_proc_entry; -static struct proc_dir_entry *disable_proc_entry; #define DIR_PROC_ENTRY "uislib" #define DIR_VBUS_PROC_ENTRY "vbus" -#define VNIC_PROC_ENTRY_FN "vnic" /* Used to be "datachan" */ -#define CTRLCHAN_PROC_ENTRY_FN "ctrlchan" -#define PMEM_PROC_ENTRY_FN "phys_to_virt" #define INFO_PROC_ENTRY_FN "info" -#define SWITCH_PROC_ENTRY_FN "switch" -#define SWITCH_COUNT_PROC_ENTRY_FN "switch_count" -#define EXTPORT_PROC_ENTRY_FN "extport" #define PLATFORMNUMBER_PROC_ENTRY_FN "platform" -#define BUS_PROC_ENTRY_FN "bus" -#define DEV_PROC_ENTRY_FN "device" -#define CHIPSET_PROC_ENTRY_FN "chipset" #define CYCLES_BEFORE_WAIT_PROC_ENTRY_FN "cycles_before_wait" -#define RESET_COUNTS_PROC_ENTRY_FN "reset_counts" #define SMART_WAKEUP_PROC_ENTRY_FN "smart_wakeup" #define CALLHOME_PROC_ENTRY_FN "callhome" #define CALLHOME_THROTTLED_PROC_ENTRY_FN "callhome_throttled" -#define DISABLE_PROC_ENTRY_FN "switch_state" -#ifdef UISLIB_TEST_PROC -static struct proc_dir_entry *test_proc_entry; -#define TEST_PROC_ENTRY_FN "test" -#endif + static unsigned long long cycles_before_wait, wait_cycles; /*****************************************************/ @@ -155,21 +130,6 @@ static ssize_t uislib_proc_read_writeonly(struct file *file, char __user *buffer, size_t count, loff_t *ppos); -static ssize_t vnic_proc_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos); - -static const struct file_operations proc_vnic_fops = { - .read = uislib_proc_read_writeonly, - .write = vnic_proc_write, -}; - -static ssize_t chipset_proc_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos); - -static const struct file_operations proc_chipset_fops = { - .read = uislib_proc_read_writeonly, - .write = chipset_proc_write, -}; static ssize_t info_proc_read(struct file *file, char __user *buf, size_t len, loff_t *offset); @@ -191,14 +151,6 @@ static const struct file_operations proc_cycles_before_wait_fops = { .write = cycles_before_wait_proc_write, }; -static ssize_t reset_counts_proc_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *ppos); -static const struct file_operations proc_reset_counts_fops = { - .read = uislib_proc_read_writeonly, - .write = reset_counts_proc_write, -}; - static ssize_t smart_wakeup_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos); @@ -207,30 +159,6 @@ static const struct file_operations proc_smart_wakeup_fops = { .write = smart_wakeup_proc_write, }; -static ssize_t test_proc_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *ppos); -static const struct file_operations proc_test_fops = { - .read = uislib_proc_read_writeonly, - .write = test_proc_write, -}; - -static ssize_t bus_proc_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *ppos); -static const struct file_operations proc_bus_fops = { - .read = uislib_proc_read_writeonly, - .write = bus_proc_write, -}; - -static ssize_t dev_proc_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *ppos); -static const struct file_operations proc_dev_fops = { - .read = uislib_proc_read_writeonly, - .write = dev_proc_write, -}; - static void init_msg_header(CONTROLVM_MESSAGE *msg, U32 id, uint rsp, uint svr) { @@ -1363,130 +1291,6 @@ EXPORT_SYMBOL_GPL(uislib_cache_free); /* proc filesystem callback functions */ /*****************************************************/ -static ssize_t -vnic_proc_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos) -{ - int action = 0xffff, busNo = 0, i, result = 0; - char buf[4]; - char direction; -/* GUID guid; */ - if (count >= ARRAY_SIZE(buf)) - return -EINVAL; - - if (copy_from_user(buf, buffer, count)) { - LOGERR("echo > /proc/uislib/vnic copy_from_user ****FAILED.\n"); - return -EFAULT; - } - - i = sscanf(buf, "%d%c", &action, &direction); - if (i != 2) { - LOGERR("unable to parse vnic proc parameters.\n"); - return -EFAULT; - } - - if ((direction != '-') && (direction != '+')) { - LOGERR("unable to determine whether to add or delete vnic\n"); - return -EFAULT; - } - - /* if (i < 1), i.e., if we didn't even read the action field, - * then action will default to 0xffff and the code below will - * fall through the switch and print usage. - */ - switch (action) { - case 0: - /* call client method... */ - busNo = 0; /* All client drivers use bus value of 0... */ - if (direction == '+') - result = uislib_client_add_vnic(busNo); - else - result = uislib_client_delete_vnic(busNo); - if (!result) { - LOGERR("echo 0%c > /proc/uislib/vnic failed (client end)", - direction); - return -EFAULT; - } - return count; - - default: - break; - } - - LOGERR("USAGE: echo > /proc/uislib/vnic"); - LOGERR(" "); - LOGERR("Client Syntax"); - LOGERR("-------------"); - LOGERR("0+ ==> add vnic"); - LOGERR("0- ==> delete vnic"); - LOGERR(" "); - return count; -} /* end vnic_proc_write */ - -static ssize_t -chipset_proc_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos) -{ - int i, action = 0xffff; - char buf[4]; - CONTROLVM_MESSAGE msg; - - if (count >= ARRAY_SIZE(buf)) - return -EINVAL; - - memset(&msg, 0, sizeof(CONTROLVM_MESSAGE)); - - if (copy_from_user(buf, buffer, count)) { - LOGERR("copy_from_user ****FAILED.\n"); - return -EFAULT; - } - - if (chipset_inited) { - LOGINF("Chipset already initialized\n"); - return -EFAULT; - } - i = sscanf(buf, "%x", &action); - - /* if (i < 1), i.e., if we didn't even read the action field, - * then action will default to 0xffff and the code below will - * fall through the switch and print usage. - */ - switch (action) { - case 1: - /* GUEST */ - /* step: initialize the chipset */ - init_msg_header(&msg, CONTROLVM_CHIPSET_INIT, 0, 0); - msg.hdr.Flags.testMessage = 0; - msg.cmd.initChipset.busCount = 23; - msg.cmd.initChipset.switchCount = 23; - - if (init_chipset(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { - LOGERR("init_chipset failed.\n"); - return 0; - } - return 1; - case 2: - /* BOTH */ - init_msg_header(&msg, CONTROLVM_CHIPSET_INIT, 0, 0); - msg.hdr.Flags.testMessage = 1; - msg.cmd.initChipset.busCount = 23; - msg.cmd.initChipset.switchCount = 23; - - if (init_chipset(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { - LOGERR("init_chipset failed.\n"); - return 0; - } - return 1; - - default: - break; - } - - LOGERR("usage: 1 ==> init_chipset client\n"); - LOGERR("usage: 2 ==> init_chipset test\n"); - return -EFAULT; -} - #define PLINE(...) uisutil_add_proc_line_ex(&tot, buff, \ buff_len, __VA_ARGS__) @@ -1612,8 +1416,6 @@ platformnumber_proc_read(struct file *file, char __user *buf, return length; } -#ifdef UISLIB_TEST_PROC - /* proc/uislib/vbus//info */ static int proc_info_vbus_show(struct seq_file *m, void *v) @@ -1652,82 +1454,6 @@ proc_info_vbus_show(struct seq_file *m, void *v) return 0; } -static ssize_t -bus_proc_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos) -{ - int server_flag = 0; - int i, action = 0xffff, result; - char buf[16]; - CONTROLVM_MESSAGE msg; - U32 busNo, deviceCount; - - if (count >= ARRAY_SIZE(buf)) - return -EINVAL; - - memset(&msg, 0, sizeof(CONTROLVM_MESSAGE)); - - if (copy_from_user(buf, buffer, count)) { - LOGERR("echo > /proc/uislib/bus: copy_from_user ****FAILED."); - return -EFAULT; - } - - i = sscanf(buf, "%x-%d-%d", &action, &busNo, &deviceCount); - - /* if (i < 1), i.e., if we didn't even read the action field, - * then action will default to 0xffff and the code below will - * fall through the switch and print usage. - */ - switch (action) { - case 0: - /* destroy a bus */ - if (i != 2) - break; - init_msg_header(&msg, CONTROLVM_BUS_DESTROY, 0, server_flag); - msg.cmd.destroyBus.busNo = busNo; - - result = destroy_bus(&msg, NULL); - - if (result != CONTROLVM_RESP_SUCCESS) { - LOGERR("echo 0-%d > /proc/uislib/bus {CONTROLVM_BUS_DESTROY Failed} Result(%d)", - busNo, result); - return -EFAULT; - } - return count; - case 1: - /* create a bus */ - if (i != 3) - break; - init_msg_header(&msg, CONTROLVM_BUS_CREATE, 0, server_flag); - msg.cmd.createBus.busNo = busNo; - msg.cmd.createBus.deviceCount = deviceCount; - - result = create_bus(&msg, NULL); - - if (result != CONTROLVM_RESP_SUCCESS) { - LOGERR("echo 1-%d-%d > /proc/uislib/bus {CONTROLVM_BUS_CREATE Failed} Result(%d)", - busNo, deviceCount, result); - return -EFAULT; - } - - return count; - default: - break; - } - - LOGERR("USAGE: echo -... > /proc/uislib/bus"); - LOGERR(" "); - LOGERR("Destruct Syntax ControlVM Message Id"); - LOGERR("--------------- ---------------------"); - LOGERR("0- ==> CONTROLVM_BUS_DESTROY"); - LOGERR(" "); - LOGERR("Construct Syntax ControlVM Message Id"); - LOGERR("----------------------- -------------------- "); - LOGERR("1-- ==> CONTROLVM_BUS_CREATE"); - - return -EFAULT; -} - static ssize_t uislib_proc_read_writeonly(struct file *file, char __user *buffer, size_t count, loff_t *ppos) @@ -1735,105 +1461,6 @@ uislib_proc_read_writeonly(struct file *file, char __user *buffer, return 0; } -static ssize_t -dev_proc_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos) -{ - int server_flag = 0; - CONTROLVM_MESSAGE msg; - U32 busNo, devNo; - char buf[32]; - unsigned int chanptr; - int type, i, action = 0xffff, result; - - if (count >= ARRAY_SIZE(buf)) - return -EINVAL; - - if (copy_from_user(buf, buffer, count)) { - LOGERR("echo > /proc/uislib/device: copy_from_user ****FAILED."); - return -EFAULT; - } - - i = sscanf(buf, "%x-%d-%d-%x-%d", - &action, &busNo, &devNo, &chanptr, &type); - - switch (action) { - case 0: - if (i != 3) - break; - - /* destroy a device */ - init_msg_header(&msg, CONTROLVM_DEVICE_DESTROY, 0, server_flag); - msg.cmd.destroyDevice.busNo = busNo; - msg.cmd.destroyDevice.devNo = devNo; - - result = destroy_device(&msg, NULL); - - if (result != CONTROLVM_RESP_SUCCESS) { - LOGERR("echo 0-%d-%d > /proc/uislib/device {CONTROLVM_DEVICE_DESTROY Failed} Result(%d)", - busNo, devNo, result); - return -EFAULT; - } - - return count; - - case 1: - if (i != 5) - break; - - /* create a device */ - init_msg_header(&msg, CONTROLVM_DEVICE_CREATE, 0, server_flag); - msg.cmd.createDevice.busNo = busNo; - msg.cmd.createDevice.devNo = devNo; - msg.cmd.createDevice.channelAddr = __pa(chanptr); - msg.cmd.createDevice.channelBytes = MIN_IO_CHANNEL_SIZE; - - if (type == 0) - msg.cmd.createDevice.dataTypeGuid = - UltraVhbaChannelProtocolGuid; - else if (type == 1) - msg.cmd.createDevice.dataTypeGuid = - UltraVnicChannelProtocolGuid; - else { - LOGERR("echo 1-%d-%d-%x- > /proc/uislib/devce failed: invalid device type %d.", - busNo, devNo, chanptr, type); - return -EFAULT; - } - - result = create_device(&msg, NULL); - - if (result != CONTROLVM_RESP_SUCCESS) { - if (type == 0) - LOGERR("echo 1-%d-%d-%x-0 > /proc/uislib/device {CONTROLVM_DEVICE_CREATE[vHBA] Failed} Result(%d)", - busNo, devNo, chanptr, result); - else - LOGERR("echo 1-%d-%d-%x-1 > /proc/uislib/device {CONTROLVM_DEVICE_CREATE[vNIC] Failed} Result(%d)", - busNo, devNo, chanptr, result); - return -EFAULT; - } - - default: - break; - } - - LOGERR("USAGE: echo --... > /proc/uislib/device"); - LOGERR(" "); - LOGERR("Destruct Syntax ControlVM Message Id"); - LOGERR("----------------- ------------------------"); - LOGERR("0-- ==> CONTROLVM_DEVICE_DESTROY"); - LOGERR(" "); - LOGERR("Construct Syntax ControlVM Message Id"); - LOGERR - ("---------------------------------- ----------------------- "); - LOGERR - ("1---- ==> CONTROLVM_DEVICE_CREATE"); - LOGERR(" : vHBA"); - LOGERR(" : vNIC"); - LOGERR(" "); - - return -EFAULT; -} - static ssize_t cycles_before_wait_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) @@ -1865,56 +1492,6 @@ cycles_before_wait_proc_write(struct file *file, const char __user *buffer, return count; } -static ssize_t -reset_counts_proc_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos) -{ - char buf[16]; - unsigned long long new_value; - struct bus_info *bus; - int i; - -#define RESET_COUNTS_USE_ERROR { \ - LOGERR("Incorrect reset_counts Input.\n"); \ - pr_info("Please pass the new value for the counters:\n"); \ - pr_info("e.g. echo 0 > reset_counts\n"); \ - return -EFAULT; \ - } - - if (count >= ARRAY_SIZE(buf)) - return -EINVAL; - - if (count == 0) - RESET_COUNTS_USE_ERROR; - - if (copy_from_user(buf, buffer, count)) { - LOGERR("copy_from_user failed.\n"); - return -EFAULT; - } - buf[count - 1] = '\0'; /* Replace the LF at the end of the - * input with a NULL */ - /* Pull out the reset_counts must be decimal integer */ - if (sscanf(buf, "%llu", &new_value) != 1) - RESET_COUNTS_USE_ERROR; - read_lock(&BusListLock); - for (bus = BusListHead; bus; bus = bus->next) { - - for (i = 0; i < bus->deviceCount; i++) { - if (bus->device[i]) { - bus->device[i]->first_busy_cnt = new_value; - bus->device[i]->moved_to_tail_cnt = new_value; - bus->device[i]->last_on_list_cnt = new_value; - } - } - } - read_unlock(&BusListLock); - tot_moved_to_tail_cnt = new_value; - tot_wait_cnt = new_value; - tot_wakeup_cnt = new_value; - tot_schedule_cnt = new_value; - return count; -} - static ssize_t smart_wakeup_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) @@ -1948,66 +1525,6 @@ smart_wakeup_proc_write(struct file *file, const char __user *buffer, return count; } -static ssize_t -test_proc_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos) -{ - int i, action = 0xffff; - char buf[16]; - CONTROLVM_MESSAGE msg; - S64 vrtc_offset; - - if (count >= ARRAY_SIZE(buf)) - return -EINVAL; - - memset(&msg, 0, sizeof(CONTROLVM_MESSAGE)); - - if (copy_from_user(buf, buffer, count)) { - LOGERR("copy_from_user ****FAILED.\n"); - return -EFAULT; - } - - i = sscanf(buf, "%x", &action); - - /* if (i < 1), i.e., if we didn't even read the action field, - * then action will default to 0xffff and the code below will - * fall through the switch and print usage. */ - switch (action) { - case 6: - msg.hdr.Id = CONTROLVM_CHIPSET_STOP; - msg.hdr.Flags.responseExpected = 1; - stop_chipset(&msg, NULL); - break; - case 7: - vrtc_offset = 0; - LOGERR("about to issue QUERY vrtc_offset=%LX", vrtc_offset); - vrtc_offset = Issue_VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET(); - LOGERR("result is vrtc_offset=%LX", vrtc_offset); - break; - case 8: - vrtc_offset = 60; - LOGERR("about to increase physical time by 0x%LX seconds", - vrtc_offset); - vrtc_offset = Issue_VMCALL_UPDATE_PHYSICAL_TIME(vrtc_offset); - break; - case 9: - vrtc_offset = -60; - LOGERR("about to decrease physical time by 0x%LX seconds", - vrtc_offset); - vrtc_offset = Issue_VMCALL_UPDATE_PHYSICAL_TIME(vrtc_offset); - break; - default: - LOGERR("usage: 6 for CHIPSET_STOP\n"); - LOGERR(" 7 for VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET()\n"); - LOGERR(" 8 for VMCALL_UPDATE_PHYSICAL_TIME(60)\n"); - LOGERR(" 9 for VMCALL_UPDATE_PHYSICAL_TIME(-60)\n"); - return -EFAULT; - break; - } - return count; -} - -#endif /* UISLIB_TEST_PROC */ static struct device_info * find_dev(U32 busNo, U32 devNo) { @@ -2303,17 +1820,6 @@ uislib_mod_init(void) /* (e.g., for /proc/uislib/vbus//info) */ uislib_proc_vbus_dir = proc_mkdir(DIR_VBUS_PROC_ENTRY, uislib_proc_dir); - vnic_proc_entry = proc_create(VNIC_PROC_ENTRY_FN, 0, uislib_proc_dir, - &proc_vnic_fops); - SET_PROC_OWNER(vnic_proc_entry, THIS_MODULE); - - /* for testing purposes only, create the proc entries for - * enqueuing Control Channel messages */ - chipset_proc_entry = - proc_create(CHIPSET_PROC_ENTRY_FN, 0, uislib_proc_dir, - &proc_chipset_fops); - SET_PROC_OWNER(chipset_proc_entry, THIS_MODULE); - info_proc_entry = proc_create(INFO_PROC_ENTRY_FN, 0, uislib_proc_dir, &proc_info_fops); SET_PROC_OWNER(info_proc_entry, THIS_MODULE); @@ -2328,29 +1834,11 @@ uislib_mod_init(void) &proc_cycles_before_wait_fops); SET_PROC_OWNER(cycles_before_wait_proc_entry, THIS_MODULE); - reset_counts_proc_entry = - proc_create(RESET_COUNTS_PROC_ENTRY_FN, 0, uislib_proc_dir, - &proc_reset_counts_fops); - SET_PROC_OWNER(reset_counts_proc_entry, THIS_MODULE); - smart_wakeup_proc_entry = proc_create(SMART_WAKEUP_PROC_ENTRY_FN, 0, uislib_proc_dir, &proc_smart_wakeup_fops); SET_PROC_OWNER(smart_wakeup_proc_entry, THIS_MODULE); -#ifdef UISLIB_TEST_PROC - test_proc_entry = proc_create(TEST_PROC_ENTRY_FN, 0, uislib_proc_dir, - &proc_test_fops); - SET_PROC_OWNER(test_proc_entry, THIS_MODULE); - - bus_proc_entry = proc_create(BUS_PROC_ENTRY_FN, 0, uislib_proc_dir, - &proc_bus_fops); - SET_PROC_OWNER(bus_proc_entry, THIS_MODULE); - - dev_proc_entry = proc_create(DEV_PROC_ENTRY_FN, 0, uislib_proc_dir, - &proc_dev_fops); - SET_PROC_OWNER(dev_proc_entry, THIS_MODULE); -#endif /* UISLIB_TEST_PROC */ POSTCODE_LINUX_3(DRIVER_EXIT_PC, 0, POSTCODE_SEVERITY_INFO); return 0; } @@ -2358,36 +1846,16 @@ uislib_mod_init(void) static void __exit uislib_mod_exit(void) { - if (disable_proc_entry) - remove_proc_entry(DISABLE_PROC_ENTRY_FN, uislib_proc_dir); if (cycles_before_wait_proc_entry) remove_proc_entry(CYCLES_BEFORE_WAIT_PROC_ENTRY_FN, uislib_proc_dir); - if (reset_counts_proc_entry) - remove_proc_entry(RESET_COUNTS_PROC_ENTRY_FN, uislib_proc_dir); if (smart_wakeup_proc_entry) remove_proc_entry(SMART_WAKEUP_PROC_ENTRY_FN, uislib_proc_dir); - if (ctrlchan_proc_entry) - remove_proc_entry(CTRLCHAN_PROC_ENTRY_FN, uislib_proc_dir); - if (pmem_proc_entry) - remove_proc_entry(PMEM_PROC_ENTRY_FN, uislib_proc_dir); if (info_proc_entry) remove_proc_entry(INFO_PROC_ENTRY_FN, uislib_proc_dir); - if (switch_proc_entry) - remove_proc_entry(SWITCH_PROC_ENTRY_FN, uislib_proc_dir); - if (extport_proc_entry) - remove_proc_entry(EXTPORT_PROC_ENTRY_FN, uislib_proc_dir); if (platformnumber_proc_entry) remove_proc_entry(PLATFORMNUMBER_PROC_ENTRY_FN, uislib_proc_dir); - if (bus_proc_entry) - remove_proc_entry(BUS_PROC_ENTRY_FN, uislib_proc_dir); - if (dev_proc_entry) - remove_proc_entry(DEV_PROC_ENTRY_FN, uislib_proc_dir); - if (vnic_proc_entry) - remove_proc_entry(VNIC_PROC_ENTRY_FN, uislib_proc_dir); - if (chipset_proc_entry) - remove_proc_entry(CHIPSET_PROC_ENTRY_FN, uislib_proc_dir); if (uislib_proc_vbus_dir) remove_proc_entry(DIR_VBUS_PROC_ENTRY, uislib_proc_dir); if (uislib_proc_dir) -- cgit v1.2.3 From 28fa597f43374b163abf6dc0d41d35ae5cd29b0f Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Mon, 12 May 2014 12:38:30 -0400 Subject: staging: unisys: move uislib/platform proc entry to debugfs Convert /proc/uislib/platform to an equivalent entry in debugfs. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/uislib/uislib.c | 62 ++++++++++------------------------ 1 file changed, 17 insertions(+), 45 deletions(-) diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 843a94b70052..3d4cf49dbb80 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -23,6 +23,7 @@ #include #endif #include +#include #include "commontypes.h" @@ -91,19 +92,23 @@ static int Go_Polling_Device_Channels; static struct proc_dir_entry *uislib_proc_dir; static struct proc_dir_entry *uislib_proc_vbus_dir; static struct proc_dir_entry *info_proc_entry; -static struct proc_dir_entry *platformnumber_proc_entry; static struct proc_dir_entry *cycles_before_wait_proc_entry; static struct proc_dir_entry *smart_wakeup_proc_entry; #define DIR_PROC_ENTRY "uislib" #define DIR_VBUS_PROC_ENTRY "vbus" #define INFO_PROC_ENTRY_FN "info" -#define PLATFORMNUMBER_PROC_ENTRY_FN "platform" #define CYCLES_BEFORE_WAIT_PROC_ENTRY_FN "cycles_before_wait" #define SMART_WAKEUP_PROC_ENTRY_FN "smart_wakeup" #define CALLHOME_PROC_ENTRY_FN "callhome" #define CALLHOME_THROTTLED_PROC_ENTRY_FN "callhome_throttled" +#define DIR_DEBUGFS_ENTRY "uislib" +static struct dentry *dir_debugfs; + +#define PLATFORMNUMBER_DEBUGFS_ENTRY_FN "platform" +static struct dentry *platformnumber_debugfs_read; + static unsigned long long cycles_before_wait, wait_cycles; /*****************************************************/ @@ -137,12 +142,6 @@ static const struct file_operations proc_info_fops = { .read = info_proc_read, }; -static ssize_t platformnumber_proc_read(struct file *file, char __user *buf, - size_t len, loff_t *offset); -static const struct file_operations proc_platformnumber_fops = { - .read = platformnumber_proc_read, -}; - static ssize_t cycles_before_wait_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos); @@ -1386,36 +1385,6 @@ info_proc_read(struct file *file, char __user *buf, size_t len, loff_t *offset) ProcReadBuffer, totalBytes); } -static ssize_t -platformnumber_proc_read(struct file *file, char __user *buf, - size_t len, loff_t *offset) -{ - int length = 0; - char *vbuf; - loff_t pos = *offset; - - if (pos < 0) - return -EINVAL; - - if (pos > 0 || !len) - return 0; - - vbuf = kzalloc(len, GFP_KERNEL); - if (!vbuf) - return -ENOMEM; - - length = sprintf(vbuf, "%d\n", PlatformNumber); - - if (copy_to_user(buf, vbuf, length)) { - kfree(vbuf); - return -EFAULT; - } - - kfree(vbuf); - *offset += length; - return length; -} - /* proc/uislib/vbus//info */ static int proc_info_vbus_show(struct seq_file *m, void *v) @@ -1824,10 +1793,13 @@ uislib_mod_init(void) &proc_info_fops); SET_PROC_OWNER(info_proc_entry, THIS_MODULE); - platformnumber_proc_entry = - proc_create(PLATFORMNUMBER_PROC_ENTRY_FN, 0, uislib_proc_dir, - &proc_platformnumber_fops); - SET_PROC_OWNER(platformnumberinfo_proc_entry, THIS_MODULE); + dir_debugfs = debugfs_create_dir(DIR_DEBUGFS_ENTRY, NULL); + + if (dir_debugfs) { + platformnumber_debugfs_read = debugfs_create_u32( + PLATFORMNUMBER_DEBUGFS_ENTRY_FN, 0444, dir_debugfs, + &PlatformNumber); + } cycles_before_wait_proc_entry = proc_create(CYCLES_BEFORE_WAIT_PROC_ENTRY_FN, 0, uislib_proc_dir, @@ -1853,9 +1825,6 @@ uislib_mod_exit(void) remove_proc_entry(SMART_WAKEUP_PROC_ENTRY_FN, uislib_proc_dir); if (info_proc_entry) remove_proc_entry(INFO_PROC_ENTRY_FN, uislib_proc_dir); - if (platformnumber_proc_entry) - remove_proc_entry(PLATFORMNUMBER_PROC_ENTRY_FN, - uislib_proc_dir); if (uislib_proc_vbus_dir) remove_proc_entry(DIR_VBUS_PROC_ENTRY, uislib_proc_dir); if (uislib_proc_dir) @@ -1866,6 +1835,9 @@ uislib_mod_exit(void) ProcReadBuffer = NULL; } + debugfs_remove(platformnumber_debugfs_read); + debugfs_remove(dir_debugfs); + DBGINF("goodbye.\n"); return; } -- cgit v1.2.3 From b913a2ef771198dda1ec4f710d553d2f8b318e1b Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Mon, 12 May 2014 12:38:31 -0400 Subject: staging: unisys: move uislib/cycles_before_wait proc entry to debugfs Convert /proc/uislib/cycles_before_wait to an equivalent entry in debugfs. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/uislib/uislib.c | 57 +++++----------------------------- 1 file changed, 8 insertions(+), 49 deletions(-) diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 3d4cf49dbb80..5f2f9e7495d8 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -92,13 +92,11 @@ static int Go_Polling_Device_Channels; static struct proc_dir_entry *uislib_proc_dir; static struct proc_dir_entry *uislib_proc_vbus_dir; static struct proc_dir_entry *info_proc_entry; -static struct proc_dir_entry *cycles_before_wait_proc_entry; static struct proc_dir_entry *smart_wakeup_proc_entry; #define DIR_PROC_ENTRY "uislib" #define DIR_VBUS_PROC_ENTRY "vbus" #define INFO_PROC_ENTRY_FN "info" -#define CYCLES_BEFORE_WAIT_PROC_ENTRY_FN "cycles_before_wait" #define SMART_WAKEUP_PROC_ENTRY_FN "smart_wakeup" #define CALLHOME_PROC_ENTRY_FN "callhome" #define CALLHOME_THROTTLED_PROC_ENTRY_FN "callhome_throttled" @@ -109,6 +107,9 @@ static struct dentry *dir_debugfs; #define PLATFORMNUMBER_DEBUGFS_ENTRY_FN "platform" static struct dentry *platformnumber_debugfs_read; +#define CYCLES_BEFORE_WAIT_DEBUGFS_ENTRY_FN "cycles_before_wait" +static struct dentry *cycles_before_wait_debugfs_read; + static unsigned long long cycles_before_wait, wait_cycles; /*****************************************************/ @@ -142,14 +143,6 @@ static const struct file_operations proc_info_fops = { .read = info_proc_read, }; -static ssize_t cycles_before_wait_proc_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *ppos); -static const struct file_operations proc_cycles_before_wait_fops = { - .read = uislib_proc_read_writeonly, - .write = cycles_before_wait_proc_write, -}; - static ssize_t smart_wakeup_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos); @@ -1430,37 +1423,6 @@ uislib_proc_read_writeonly(struct file *file, char __user *buffer, return 0; } -static ssize_t -cycles_before_wait_proc_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos) -{ - char buf[16]; - -#define CYCLES_BEFORE_WAIT_USE_ERROR { \ - LOGERR("Incorrect Call Home Input.\n"); \ - pr_info("Please pass Call Home Event Parameters in the form:\n"); \ - pr_info("EventID Category Type[parameter1][parameter2][parameter3][parameter4][parameter5][parameter6]\n"); \ - return -EFAULT; \ -} - if (count >= ARRAY_SIZE(buf)) - return -EINVAL; - - if (count == 0) - CYCLES_BEFORE_WAIT_USE_ERROR; - - if (copy_from_user(buf, buffer, count)) { - LOGERR("copy_from_user failed.\n"); - return -EFAULT; - } - buf[count - 1] = '\0'; /* Replace the LF at the end of the - * input with a NULL */ - /* Pull out the cycles_before_wait must be decimal integer */ - if (sscanf(buf, "%lld", &cycles_before_wait) != 1) - CYCLES_BEFORE_WAIT_USE_ERROR; - - return count; -} - static ssize_t smart_wakeup_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) @@ -1799,12 +1761,11 @@ uislib_mod_init(void) platformnumber_debugfs_read = debugfs_create_u32( PLATFORMNUMBER_DEBUGFS_ENTRY_FN, 0444, dir_debugfs, &PlatformNumber); - } - cycles_before_wait_proc_entry = - proc_create(CYCLES_BEFORE_WAIT_PROC_ENTRY_FN, 0, uislib_proc_dir, - &proc_cycles_before_wait_fops); - SET_PROC_OWNER(cycles_before_wait_proc_entry, THIS_MODULE); + cycles_before_wait_debugfs_read = debugfs_create_u64( + CYCLES_BEFORE_WAIT_DEBUGFS_ENTRY_FN, 0666, dir_debugfs, + &cycles_before_wait); + } smart_wakeup_proc_entry = proc_create(SMART_WAKEUP_PROC_ENTRY_FN, 0, uislib_proc_dir, @@ -1818,9 +1779,6 @@ uislib_mod_init(void) static void __exit uislib_mod_exit(void) { - if (cycles_before_wait_proc_entry) - remove_proc_entry(CYCLES_BEFORE_WAIT_PROC_ENTRY_FN, - uislib_proc_dir); if (smart_wakeup_proc_entry) remove_proc_entry(SMART_WAKEUP_PROC_ENTRY_FN, uislib_proc_dir); if (info_proc_entry) @@ -1835,6 +1793,7 @@ uislib_mod_exit(void) ProcReadBuffer = NULL; } + debugfs_remove(cycles_before_wait_debugfs_read); debugfs_remove(platformnumber_debugfs_read); debugfs_remove(dir_debugfs); -- cgit v1.2.3 From 81d2d7de0b5533c9ca1fa7c43f760458de21654c Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Mon, 12 May 2014 12:38:32 -0400 Subject: staging: unisys: move uislib/smart_wakeup proc entry to debugfs Convert /proc/uislib/smart_wakeup to an equivalent entry in debugfs. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/uislib/uislib.c | 59 ++++++---------------------------- 1 file changed, 9 insertions(+), 50 deletions(-) diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 5f2f9e7495d8..35430ead9f55 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -92,12 +92,11 @@ static int Go_Polling_Device_Channels; static struct proc_dir_entry *uislib_proc_dir; static struct proc_dir_entry *uislib_proc_vbus_dir; static struct proc_dir_entry *info_proc_entry; -static struct proc_dir_entry *smart_wakeup_proc_entry; #define DIR_PROC_ENTRY "uislib" #define DIR_VBUS_PROC_ENTRY "vbus" #define INFO_PROC_ENTRY_FN "info" -#define SMART_WAKEUP_PROC_ENTRY_FN "smart_wakeup" + #define CALLHOME_PROC_ENTRY_FN "callhome" #define CALLHOME_THROTTLED_PROC_ENTRY_FN "callhome_throttled" @@ -110,6 +109,9 @@ static struct dentry *platformnumber_debugfs_read; #define CYCLES_BEFORE_WAIT_DEBUGFS_ENTRY_FN "cycles_before_wait" static struct dentry *cycles_before_wait_debugfs_read; +#define SMART_WAKEUP_DEBUGFS_ENTRY_FN "smart_wakeup" +static struct dentry *smart_wakeup_debugfs_entry; + static unsigned long long cycles_before_wait, wait_cycles; /*****************************************************/ @@ -143,14 +145,6 @@ static const struct file_operations proc_info_fops = { .read = info_proc_read, }; -static ssize_t smart_wakeup_proc_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *ppos); -static const struct file_operations proc_smart_wakeup_fops = { - .read = uislib_proc_read_writeonly, - .write = smart_wakeup_proc_write, -}; - static void init_msg_header(CONTROLVM_MESSAGE *msg, U32 id, uint rsp, uint svr) { @@ -1423,39 +1417,6 @@ uislib_proc_read_writeonly(struct file *file, char __user *buffer, return 0; } -static ssize_t -smart_wakeup_proc_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos) -{ - char buf[16]; - int new_value; - -#define SMART_WAKEUP_USE_ERROR { \ - LOGERR("Incorrect smart_wakeup Input 0 disables smart_wakeup, and 1 enables smart_wakeup.\n"); \ - pr_info("echo 0 > smart_wakeup\n"); \ - pr_info("echo 1 > smart_wakeup\n"); \ - return -EFAULT; \ - } - - if (count >= ARRAY_SIZE(buf)) - return -EINVAL; - - if (count == 0) - SMART_WAKEUP_USE_ERROR; - - if (copy_from_user(buf, buffer, count)) { - LOGERR("copy_from_user failed.\n"); - return -EFAULT; - } - buf[count - 1] = '\0'; /* Replace the LF at the end of the - * input with a NULL */ - /* Pull out the smart_wakeup must be decimal integer */ - if (sscanf(buf, "%d", &new_value) != 1) - SMART_WAKEUP_USE_ERROR; - en_smart_wakeup = new_value; - return count; -} - static struct device_info * find_dev(U32 busNo, U32 devNo) { @@ -1765,12 +1726,11 @@ uislib_mod_init(void) cycles_before_wait_debugfs_read = debugfs_create_u64( CYCLES_BEFORE_WAIT_DEBUGFS_ENTRY_FN, 0666, dir_debugfs, &cycles_before_wait); - } - smart_wakeup_proc_entry = - proc_create(SMART_WAKEUP_PROC_ENTRY_FN, 0, uislib_proc_dir, - &proc_smart_wakeup_fops); - SET_PROC_OWNER(smart_wakeup_proc_entry, THIS_MODULE); + smart_wakeup_debugfs_entry = debugfs_create_bool( + SMART_WAKEUP_DEBUGFS_ENTRY_FN, 0666, dir_debugfs, + &en_smart_wakeup); + } POSTCODE_LINUX_3(DRIVER_EXIT_PC, 0, POSTCODE_SEVERITY_INFO); return 0; @@ -1779,8 +1739,6 @@ uislib_mod_init(void) static void __exit uislib_mod_exit(void) { - if (smart_wakeup_proc_entry) - remove_proc_entry(SMART_WAKEUP_PROC_ENTRY_FN, uislib_proc_dir); if (info_proc_entry) remove_proc_entry(INFO_PROC_ENTRY_FN, uislib_proc_dir); if (uislib_proc_vbus_dir) @@ -1793,6 +1751,7 @@ uislib_mod_exit(void) ProcReadBuffer = NULL; } + debugfs_remove(smart_wakeup_debugfs_entry); debugfs_remove(cycles_before_wait_debugfs_read); debugfs_remove(platformnumber_debugfs_read); debugfs_remove(dir_debugfs); -- cgit v1.2.3 From e564f3a07c8e74d302d0edbfde0c50d4900aa03b Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Mon, 12 May 2014 12:38:33 -0400 Subject: staging: unisys: remove functions made redundant in uislib.c The patches to move proc files have made the functions uislib_proc_read_writeonly() and stop_chipset() redundant. Remove them. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/uislib/uislib.c | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 35430ead9f55..35f28579ea47 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -134,11 +134,6 @@ static const struct file_operations proc_info_vbus_fops = { .release = single_release, }; -static ssize_t uislib_proc_read_writeonly(struct file *file, - char __user *buffer, - size_t count, loff_t *ppos); - - static ssize_t info_proc_read(struct file *file, char __user *buf, size_t len, loff_t *offset); static const struct file_operations proc_info_fops = { @@ -858,27 +853,6 @@ init_chipset(CONTROLVM_MESSAGE *msg, char *buf) return CONTROLVM_RESP_SUCCESS; } -static int -stop_chipset(CONTROLVM_MESSAGE *msg, char *buf) -{ - /* Check that all buses and switches have been torn down and - * destroyed. - */ - if (BusListHead) { - /* Buses still exist. */ - LOGERR("CONTROLVM_CHIPSET_STOP: BusListHead is not NULL"); - return CONTROLVM_RESP_ERROR_CHIPSET_STOP_FAILED_BUS; - } - if (BusListCount) { - /* BusListHead is NULL, but BusListCount != 0 */ - LOGERR("CONTROLVM_CHIPSET_STOP: BusListCount != 0"); - return CONTROLVM_RESP_ERROR_CHIPSET_STOP_FAILED_BUS; - } - - /* Buses are shut down. */ - return visorchipset_chipset_notready(); -} - static int delete_bus_glue(U32 busNo) { @@ -1410,13 +1384,6 @@ proc_info_vbus_show(struct seq_file *m, void *v) return 0; } -static ssize_t -uislib_proc_read_writeonly(struct file *file, char __user *buffer, - size_t count, loff_t *ppos) -{ - return 0; -} - static struct device_info * find_dev(U32 busNo, U32 devNo) { -- cgit v1.2.3 From 7ec967208dceaa534a619f09c6e6fac10a91fa50 Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Mon, 12 May 2014 12:38:34 -0400 Subject: staging: unisys: move uislib/info proc entry to debugfs Convert /proc/uislib/info to an equivalent entry under debugfs. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/uislib/uislib.c | 40 ++++++++++++++-------------------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 35f28579ea47..4e1b0fdc8e16 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -91,11 +91,9 @@ static int Go_Polling_Device_Channels; static struct proc_dir_entry *uislib_proc_dir; static struct proc_dir_entry *uislib_proc_vbus_dir; -static struct proc_dir_entry *info_proc_entry; #define DIR_PROC_ENTRY "uislib" #define DIR_VBUS_PROC_ENTRY "vbus" -#define INFO_PROC_ENTRY_FN "info" #define CALLHOME_PROC_ENTRY_FN "callhome" #define CALLHOME_THROTTLED_PROC_ENTRY_FN "callhome_throttled" @@ -112,6 +110,9 @@ static struct dentry *cycles_before_wait_debugfs_read; #define SMART_WAKEUP_DEBUGFS_ENTRY_FN "smart_wakeup" static struct dentry *smart_wakeup_debugfs_entry; +#define INFO_DEBUGFS_ENTRY_FN "info" +static struct dentry *info_debugfs_entry; + static unsigned long long cycles_before_wait, wait_cycles; /*****************************************************/ @@ -134,10 +135,10 @@ static const struct file_operations proc_info_vbus_fops = { .release = single_release, }; -static ssize_t info_proc_read(struct file *file, char __user *buf, +static ssize_t info_debugfs_read(struct file *file, char __user *buf, size_t len, loff_t *offset); -static const struct file_operations proc_info_fops = { - .read = info_proc_read, +static const struct file_operations debugfs_info_fops = { + .read = info_debugfs_read, }; static void @@ -158,16 +159,6 @@ create_bus_proc_entries(struct bus_info *bus) bus->name); return; } - bus->proc_info = proc_create_data("info", 0, bus->proc_dir, - &proc_info_vbus_fops, bus); - if (!bus->proc_info) { - LOGERR("failed to create /proc/uislib/vbus/%s/info", bus->name); - remove_proc_entry(bus->name, uislib_proc_vbus_dir); - bus->proc_dir = NULL; - return; - } - SET_PROC_OWNER(bus->proc_info, THIS_MODULE); - } static __iomem void * @@ -1255,7 +1246,7 @@ EXPORT_SYMBOL_GPL(uislib_cache_free); buff_len, __VA_ARGS__) static int -info_proc_read_helper(char **buff, int *buff_len) +info_debugfs_read_helper(char **buff, int *buff_len) { int i, tot = 0; struct bus_info *bus; @@ -1315,7 +1306,8 @@ err_done: } static ssize_t -info_proc_read(struct file *file, char __user *buf, size_t len, loff_t *offset) +info_debugfs_read(struct file *file, char __user *buf, + size_t len, loff_t *offset) { char *temp; int totalBytes = 0; @@ -1335,9 +1327,9 @@ info_proc_read(struct file *file, char __user *buf, size_t len, loff_t *offset) temp = ProcReadBuffer; if ((*offset == 0) || (!ProcReadBufferValid)) { - DBGINF("calling info_proc_read_helper.\n"); + DBGINF("calling info_debugfs_read_helper.\n"); /* if the read fails, then -1 will be returned */ - totalBytes = info_proc_read_helper(&temp, &remaining_bytes); + totalBytes = info_debugfs_read_helper(&temp, &remaining_bytes); ProcReadBufferValid = 1; } else totalBytes = strlen(ProcReadBuffer); @@ -1679,13 +1671,14 @@ uislib_mod_init(void) /* (e.g., for /proc/uislib/vbus//info) */ uislib_proc_vbus_dir = proc_mkdir(DIR_VBUS_PROC_ENTRY, uislib_proc_dir); - info_proc_entry = proc_create(INFO_PROC_ENTRY_FN, 0, uislib_proc_dir, - &proc_info_fops); - SET_PROC_OWNER(info_proc_entry, THIS_MODULE); dir_debugfs = debugfs_create_dir(DIR_DEBUGFS_ENTRY, NULL); if (dir_debugfs) { + info_debugfs_entry = debugfs_create_file( + INFO_DEBUGFS_ENTRY_FN, 0444, dir_debugfs, NULL, + &debugfs_info_fops); + platformnumber_debugfs_read = debugfs_create_u32( PLATFORMNUMBER_DEBUGFS_ENTRY_FN, 0444, dir_debugfs, &PlatformNumber); @@ -1706,8 +1699,6 @@ uislib_mod_init(void) static void __exit uislib_mod_exit(void) { - if (info_proc_entry) - remove_proc_entry(INFO_PROC_ENTRY_FN, uislib_proc_dir); if (uislib_proc_vbus_dir) remove_proc_entry(DIR_VBUS_PROC_ENTRY, uislib_proc_dir); if (uislib_proc_dir) @@ -1718,6 +1709,7 @@ uislib_mod_exit(void) ProcReadBuffer = NULL; } + debugfs_remove(info_debugfs_entry); debugfs_remove(smart_wakeup_debugfs_entry); debugfs_remove(cycles_before_wait_debugfs_read); debugfs_remove(platformnumber_debugfs_read); -- cgit v1.2.3 From c79d84517ce86e1388a43060f8d86a593fa706bd Mon Sep 17 00:00:00 2001 From: Benjamin Romer Date: Mon, 12 May 2014 12:38:35 -0400 Subject: staging: unisys: remove remaining proc directory entries Finally, remove /proc/uislib and all remaining, redundant entries created under /proc/uislib/vbus. Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/uislib/uislib.c | 92 ---------------------------------- 1 file changed, 92 deletions(-) diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 4e1b0fdc8e16..166a518a04f6 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -89,12 +89,6 @@ static DEFINE_SEMAPHORE(Lock_Polling_Device_Channels); /* unlocked */ static DECLARE_WAIT_QUEUE_HEAD(Wakeup_Polling_Device_Channels); static int Go_Polling_Device_Channels; -static struct proc_dir_entry *uislib_proc_dir; -static struct proc_dir_entry *uislib_proc_vbus_dir; - -#define DIR_PROC_ENTRY "uislib" -#define DIR_VBUS_PROC_ENTRY "vbus" - #define CALLHOME_PROC_ENTRY_FN "callhome" #define CALLHOME_THROTTLED_PROC_ENTRY_FN "callhome_throttled" @@ -119,22 +113,6 @@ static unsigned long long cycles_before_wait, wait_cycles; /* local functions */ /*****************************************************/ -static int proc_info_vbus_show(struct seq_file *m, void *v); -static int -proc_info_vbus_open(struct inode *inode, struct file *filp) -{ - /* proc_info_vbus_show will grab this from seq_file.private: */ - struct bus_info *bus = PDE_DATA(inode); - return single_open(filp, proc_info_vbus_show, bus); -} - -static const struct file_operations proc_info_vbus_fops = { - .open = proc_info_vbus_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - static ssize_t info_debugfs_read(struct file *file, char __user *buf, size_t len, loff_t *offset); static const struct file_operations debugfs_info_fops = { @@ -150,17 +128,6 @@ init_msg_header(CONTROLVM_MESSAGE *msg, U32 id, uint rsp, uint svr) msg->hdr.Flags.server = svr; } -static void -create_bus_proc_entries(struct bus_info *bus) -{ - bus->proc_dir = proc_mkdir(bus->name, uislib_proc_vbus_dir); - if (!bus->proc_dir) { - LOGERR("failed to create /proc/uislib/vbus/%s directory", - bus->name); - return; - } -} - static __iomem void * init_vbus_channel(U64 channelAddr, U32 channelBytes, int isServer) { @@ -296,7 +263,6 @@ create_bus(CONTROLVM_MESSAGE *msg, char *buf) CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR; } } - create_bus_proc_entries(bus); /* add bus at the head of our list */ write_lock(&BusListLock); @@ -373,14 +339,6 @@ destroy_bus(CONTROLVM_MESSAGE *msg, char *buf) read_unlock(&BusListLock); return CONTROLVM_RESP_ERROR_ALREADY_DONE; } - if (bus->proc_info) { - remove_proc_entry("info", bus->proc_dir); - bus->proc_info = NULL; - } - if (bus->proc_dir) { - remove_proc_entry(bus->name, uislib_proc_vbus_dir); - bus->proc_dir = NULL; - } if (bus->pBusChannel) { uislib_iounmap(bus->pBusChannel); bus->pBusChannel = NULL; @@ -1338,44 +1296,6 @@ info_debugfs_read(struct file *file, char __user *buf, ProcReadBuffer, totalBytes); } -/* proc/uislib/vbus//info */ -static int -proc_info_vbus_show(struct seq_file *m, void *v) -{ - struct bus_info *bus = m->private; - int i, devInfoCount, x; - char buf[999]; - - if (bus == NULL) - return 0; - seq_printf(m, "Client device / client driver info for %s partition (vbus #%d):\n", - bus->partitionName, bus->busNo); - if ((bus->busChannelBytes == 0) || (bus->pBusChannel == NULL)) - return 0; - devInfoCount = - (bus->busChannelBytes - - sizeof(ULTRA_VBUS_CHANNEL_PROTOCOL)) / - sizeof(ULTRA_VBUS_DEVICEINFO); - x = VBUSCHANNEL_devInfoToStringBuffer(&bus->pBusChannel->ChpInfo, buf, - sizeof(buf) - 1, -1); - buf[x] = '\0'; - seq_printf(m, "%s", buf); - x = VBUSCHANNEL_devInfoToStringBuffer(&bus->pBusChannel->BusInfo, - buf, sizeof(buf) - 1, -1); - buf[x] = '\0'; - seq_printf(m, "%s", buf); - for (i = 0; i < devInfoCount; i++) { - x = VBUSCHANNEL_devInfoToStringBuffer(&bus->pBusChannel-> - DevInfo[i], buf, - sizeof(buf) - 1, i); - if (x > 0) { - buf[x] = '\0'; - seq_printf(m, "%s", buf); - } - } - return 0; -} - static struct device_info * find_dev(U32 busNo, U32 devNo) { @@ -1666,14 +1586,7 @@ uislib_mod_init(void) * then map this physical address to a virtual address. */ POSTCODE_LINUX_2(DRIVER_ENTRY_PC, POSTCODE_SEVERITY_INFO); - /* create the proc entries for the channels */ - uislib_proc_dir = proc_mkdir(DIR_PROC_ENTRY, NULL); - /* (e.g., for /proc/uislib/vbus//info) */ - uislib_proc_vbus_dir = proc_mkdir(DIR_VBUS_PROC_ENTRY, uislib_proc_dir); - - dir_debugfs = debugfs_create_dir(DIR_DEBUGFS_ENTRY, NULL); - if (dir_debugfs) { info_debugfs_entry = debugfs_create_file( INFO_DEBUGFS_ENTRY_FN, 0444, dir_debugfs, NULL, @@ -1699,11 +1612,6 @@ uislib_mod_init(void) static void __exit uislib_mod_exit(void) { - if (uislib_proc_vbus_dir) - remove_proc_entry(DIR_VBUS_PROC_ENTRY, uislib_proc_dir); - if (uislib_proc_dir) - remove_proc_entry(DIR_PROC_ENTRY, NULL); - if (ProcReadBuffer) { vfree(ProcReadBuffer); ProcReadBuffer = NULL; -- cgit v1.2.3 From e03e1e39b6d66c11d71c91a080b479fb432e3674 Mon Sep 17 00:00:00 2001 From: Masaru Nomura Date: Sat, 17 May 2014 21:32:53 +0100 Subject: staging: unisys: visorutil: Add a blank line Add a blank line after declarations to meet kernel coding style. Signed-off-by: Masaru Nomura Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorutil/charqueue.c | 2 ++ drivers/staging/unisys/visorutil/easyproc.c | 6 ++++++ drivers/staging/unisys/visorutil/periodic_work.c | 1 + drivers/staging/unisys/visorutil/procobjecttree.c | 6 ++++++ 4 files changed, 15 insertions(+) diff --git a/drivers/staging/unisys/visorutil/charqueue.c b/drivers/staging/unisys/visorutil/charqueue.c index 61600e1955b3..22241c7b4f7f 100644 --- a/drivers/staging/unisys/visorutil/charqueue.c +++ b/drivers/staging/unisys/visorutil/charqueue.c @@ -41,6 +41,7 @@ CHARQUEUE *visor_charqueue_create(ulong nslots) { int alloc_size = sizeof(CHARQUEUE) + nslots + 1; CHARQUEUE *cq = kmalloc(alloc_size, GFP_KERNEL|__GFP_NORETRY); + if (cq == NULL) { ERRDRV("visor_charqueue_create allocation failed (alloc_size=%d)", alloc_size); @@ -75,6 +76,7 @@ EXPORT_SYMBOL_GPL(visor_charqueue_enqueue); BOOL visor_charqueue_is_empty(CHARQUEUE *charqueue) { BOOL b; + spin_lock(&charqueue->lock); b = IS_EMPTY(charqueue); spin_unlock(&charqueue->lock); diff --git a/drivers/staging/unisys/visorutil/easyproc.c b/drivers/staging/unisys/visorutil/easyproc.c index 43df5988f0b8..3b388494e2af 100644 --- a/drivers/staging/unisys/visorutil/easyproc.c +++ b/drivers/staging/unisys/visorutil/easyproc.c @@ -61,6 +61,7 @@ static struct proc_dir_entry * createProcDir(char *name, struct proc_dir_entry *parent) { struct proc_dir_entry *p = proc_mkdir_mode(name, S_IFDIR, parent); + if (p == NULL) ERRDRV("failed to create /proc directory %s", name); return p; @@ -196,6 +197,7 @@ void visor_easyproc_InitDevice(struct easyproc_driver_info *pdriver, { if ((pdriver->ProcDeviceDir != NULL) && (p->procDevicexDir == NULL)) { char s[29]; + sprintf(s, "%d", devno); p->procDevicexDir = createProcDir(s, pdriver->ProcDeviceDir); p->devno = devno; @@ -267,6 +269,7 @@ void visor_easyproc_DeInitDevice(struct easyproc_driver_info *pdriver, struct easyproc_device_info *p, int devno) { size_t i; + for (i = 0; i < ARRAY_SIZE(p->device_property_info); i++) { if (p->device_property_info[i].procEntry != NULL) { struct easyproc_device_property_info *px = @@ -281,6 +284,7 @@ void visor_easyproc_DeInitDevice(struct easyproc_driver_info *pdriver, } if (p->procDevicexDir != NULL) { char s[29]; + sprintf(s, "%d", devno); remove_proc_entry(s, pdriver->ProcDeviceDir); p->procDevicexDir = NULL; @@ -334,6 +338,7 @@ static ssize_t proc_write_driver(struct file *file, const char __user *buffer, struct seq_file *seq = (struct seq_file *)file->private_data; struct easyproc_driver_info *p = NULL; char local_buf[256]; + if (seq == NULL) return 0; p = (struct easyproc_driver_info *)(seq->private); @@ -356,6 +361,7 @@ static ssize_t proc_write_device(struct file *file, const char __user *buffer, struct seq_file *seq = (struct seq_file *)file->private_data; struct easyproc_device_info *p = NULL; char local_buf[256]; + if (seq == NULL) return 0; p = (struct easyproc_device_info *)(seq->private); diff --git a/drivers/staging/unisys/visorutil/periodic_work.c b/drivers/staging/unisys/visorutil/periodic_work.c index 0251b83aa55c..38a60ce8c27c 100644 --- a/drivers/staging/unisys/visorutil/periodic_work.c +++ b/drivers/staging/unisys/visorutil/periodic_work.c @@ -92,6 +92,7 @@ EXPORT_SYMBOL_GPL(visor_periodic_work_destroy); BOOL visor_periodic_work_nextperiod(PERIODIC_WORK *periodic_work) { BOOL rc = FALSE; + write_lock(&periodic_work->lock); if (periodic_work->want_to_stop) { periodic_work->is_scheduled = FALSE; diff --git a/drivers/staging/unisys/visorutil/procobjecttree.c b/drivers/staging/unisys/visorutil/procobjecttree.c index 2f874e0ab339..5c8c95c51519 100644 --- a/drivers/staging/unisys/visorutil/procobjecttree.c +++ b/drivers/staging/unisys/visorutil/procobjecttree.c @@ -95,6 +95,7 @@ static struct proc_dir_entry * createProcDir(const char *name, struct proc_dir_entry *parent) { struct proc_dir_entry *p = proc_mkdir_mode(name, S_IFDIR, parent); + if (p == NULL) ERRDRV("failed to create /proc directory %s", name); return p; @@ -197,9 +198,11 @@ void visor_proc_DestroyType(MYPROCTYPE *type) return; if (type->procDirs != NULL) { int i = type->nNames-1; + while (i >= 0) { if (type->procDirs[i] != NULL) { struct proc_dir_entry *parent = NULL; + if (i == 0) parent = type->procDirRoot; else @@ -299,6 +302,7 @@ EXPORT_SYMBOL_GPL(visor_proc_CreateObject); void visor_proc_DestroyObject(MYPROCOBJECT *obj) { MYPROCTYPE *type = NULL; + if (obj == NULL) return; type = obj->type; @@ -306,6 +310,7 @@ void visor_proc_DestroyObject(MYPROCOBJECT *obj) return; if (obj->procDirProperties != NULL) { int i = 0; + for (i = 0; i < type->nProperties; i++) { if (obj->procDirProperties[i] != NULL) { remove_proc_entry(type->propertyNames[i], @@ -338,6 +343,7 @@ EXPORT_SYMBOL_GPL(visor_proc_DestroyObject); static int seq_show(struct seq_file *seq, void *offset) { PROCDIRENTRYCONTEXT *ctx = (PROCDIRENTRYCONTEXT *)(seq->private); + if (ctx == NULL) { ERRDRV("I don't have a freakin' clue..."); return 0; -- cgit v1.2.3 From f53d9f12c51ace9956d6c3ee7aa447f09e6cbfa4 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 17 May 2014 09:50:18 +0100 Subject: staging: vt6656: rf.c additional power. Provides extra power on weak RSSI. The values orginate from the vendors driver. It is applied later in RFbRawSetPower to simplify and check that it doesn't exceed the max power. Vendor driver VT6656_Linux_src_v1.21.03_x86_11.04.zip http://www.viaembedded.com/servlet/downloadSvl?id=1890&download_file_id=14704 This is GPL-licensed code. vendors code ... if (pDevice->byRFType == RF_VT3226D0) { if (lRSSI == 0){ lAdditionalPower = 7; } else if ((lRSSI < -60) && (lRSSI >= -65)){ lAdditionalPower = 5; //lAdditionalPower = 9; } else if ((lRSSI < -65) && (lRSSI >= -70)){ lAdditionalPower = 7; //lAdditionalPower = 9; } else if ((lRSSI < -70) && (lRSSI >= -80)){ lAdditionalPower = 9; } else if (lRSSI < -80) { lAdditionalPower = 9; } } else { if (lRSSI == 0){ lAdditionalPower = 7; } else if ((lRSSI < -70) && (lRSSI >= -75)){ lAdditionalPower = 5; } else if ((lRSSI < -75) && (lRSSI >= -80)){ lAdditionalPower = 7; } else if (lRSSI < -80) { lAdditionalPower = 9; } } ... Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rf.c | 30 ++++++++++++++++++++++++++++++ drivers/staging/vt6656/rf.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c index 1e8f64bff03c..64632e9fff63 100644 --- a/drivers/staging/vt6656/rf.c +++ b/drivers/staging/vt6656/rf.c @@ -769,6 +769,32 @@ int RFbSetPower(struct vnt_private *priv, u32 rate, u32 channel) return ret; } +static u8 vnt_rf_addpower(struct vnt_private *priv) +{ + s32 rssi = -priv->uCurrRSSI; + + if (!rssi) + return 7; + + if (priv->byRFType == RF_VT3226D0) { + if (rssi < -70) + return 9; + else if (rssi < -65) + return 7; + else if (rssi < -60) + return 5; + } else { + if (rssi < -80) + return 9; + else if (rssi < -75) + return 7; + else if (rssi < -70) + return 5; + } + + return 0; +} + /* * Description: Set Tx power * @@ -788,6 +814,10 @@ int RFbRawSetPower(struct vnt_private *priv, u8 power, u32 rate) u32 power_setting = 0; int ret = true; + power += vnt_rf_addpower(priv); + if (power > VNT_RF_MAX_POWER) + power = VNT_RF_MAX_POWER; + if (priv->byCurPwr == power) return true; diff --git a/drivers/staging/vt6656/rf.h b/drivers/staging/vt6656/rf.h index de5c613b4ef9..e9a01fee4127 100644 --- a/drivers/staging/vt6656/rf.h +++ b/drivers/staging/vt6656/rf.h @@ -53,6 +53,8 @@ #define RF_EMU 0x80 #define RF_MASK 0x7F +#define VNT_RF_MAX_POWER 0x3f + extern const u8 RFaby11aChannelIndex[200]; int IFRFbWriteEmbedded(struct vnt_private *, u32 dwData); -- cgit v1.2.3 From f347d8cbd0e3cb580266b07110d02470c18700b0 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 17 May 2014 09:50:19 +0100 Subject: staging: vt6656: usbpipe: get rid of in/out debug messages. Remove all in/out debug messages. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/usbpipe.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 433edcab5081..8d0705db84a8 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -126,9 +126,6 @@ int PIPEnsInterruptRead(struct vnt_private *priv) { int status = STATUS_FAILURE; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "---->s_nsStartInterruptUsbRead()\n"); - if (priv->int_buf.in_use == true) return STATUS_FAILURE; @@ -150,9 +147,6 @@ int PIPEnsInterruptRead(struct vnt_private *priv) priv->int_buf.in_use = false; } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "<----s_nsStartInterruptUsbRead Return(%x)\n", status); - return status; } @@ -176,9 +170,6 @@ static void s_nsInterruptUsbIoCompleteRead(struct urb *urb) struct vnt_private *priv = urb->context; int status; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "---->s_nsInterruptUsbIoCompleteRead\n"); - switch (urb->status) { case 0: case -ETIMEDOUT: @@ -194,9 +185,6 @@ static void s_nsInterruptUsbIoCompleteRead(struct urb *urb) status = urb->status; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "s_nsInterruptUsbIoCompleteRead Status %d\n", status); - if (status != STATUS_SUCCESS) { priv->int_buf.in_use = false; @@ -236,8 +224,6 @@ int PIPEnsBulkInUsbRead(struct vnt_private *priv, struct vnt_rcb *rcb) int status = 0; struct urb *urb; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsStartBulkInUsbRead\n"); - if (priv->Flags & fMP_DISCONNECTED) return STATUS_FAILURE; @@ -290,8 +276,6 @@ static void s_nsBulkInUsbIoCompleteRead(struct urb *urb) unsigned long flags; int re_alloc_skb = false; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkInUsbIoCompleteRead\n"); - switch (urb->status) { case 0: break; @@ -351,8 +335,6 @@ int PIPEnsSendBulkOut(struct vnt_private *priv, priv->bPWBitOn = false; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_nsSendBulkOut\n"); - if (!(MP_IS_READY(priv) && priv->Flags & fMP_POST_WRITES)) { context->in_use = false; return STATUS_RESOURCES; @@ -413,8 +395,6 @@ static void s_nsBulkOutIoCompleteWrite(struct urb *urb) struct vnt_private *priv = context->priv; u8 context_type = context->type; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkOutIoCompleteWrite\n"); - switch (urb->status) { case 0: DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO -- cgit v1.2.3 From 8a6602614a470a9a12bee60773bbee8c882a6b38 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 17 May 2014 09:50:20 +0100 Subject: staging: vt6656: usbpipe: replace debug messsages. Replace all DBG_PRT wiht dev_dbg Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/usbpipe.c | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 8d0705db84a8..5a4666533e9c 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -51,9 +51,6 @@ //endpoint 2: read bulk //endpoint 3: write bulk -//static int msglevel =MSG_LEVEL_DEBUG; -static int msglevel =MSG_LEVEL_INFO; - #define USB_CTL_WAIT 500 //ms #ifndef URB_ASYNC_UNLINK @@ -142,8 +139,7 @@ int PIPEnsInterruptRead(struct vnt_private *priv) status = usb_submit_urb(priv->pInterruptURB, GFP_ATOMIC); if (status) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "Submit int URB failed %d\n", status); + dev_dbg(&priv->usb->dev, "Submit int URB failed %d\n", status); priv->int_buf.in_use = false; } @@ -188,16 +184,14 @@ static void s_nsInterruptUsbIoCompleteRead(struct urb *urb) if (status != STATUS_SUCCESS) { priv->int_buf.in_use = false; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "IntUSBIoCompleteControl STATUS = %d\n", status); + dev_dbg(&priv->usb->dev, "%s status = %d\n", __func__, status); } else { INTnsProcessData(priv); } status = usb_submit_urb(priv->pInterruptURB, GFP_ATOMIC); if (status) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "Submit int URB failed %d\n", status); + dev_dbg(&priv->usb->dev, "Submit int URB failed %d\n", status); } else { priv->int_buf.in_use = true; } @@ -229,7 +223,7 @@ int PIPEnsBulkInUsbRead(struct vnt_private *priv, struct vnt_rcb *rcb) urb = rcb->pUrb; if (rcb->skb == NULL) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"rcb->skb is null\n"); + dev_dbg(&priv->usb->dev, "rcb->skb is null\n"); return status; } @@ -243,8 +237,7 @@ int PIPEnsBulkInUsbRead(struct vnt_private *priv, struct vnt_rcb *rcb) status = usb_submit_urb(urb, GFP_ATOMIC); if (status != 0) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "Submit Rx URB failed %d\n", status); + dev_dbg(&priv->usb->dev, "Submit Rx URB failed %d\n", status); return STATUS_FAILURE ; } @@ -285,8 +278,7 @@ static void s_nsBulkInUsbIoCompleteRead(struct urb *urb) return; case -ETIMEDOUT: default: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "BULK In failed %d\n", urb->status); + dev_dbg(&priv->usb->dev, "BULK In failed %d\n", urb->status); break; } @@ -301,8 +293,9 @@ static void s_nsBulkInUsbIoCompleteRead(struct urb *urb) rcb->Ref--; if (rcb->Ref == 0) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RxvFreeNormal %d\n", - priv->NumRecvFreeList); + dev_dbg(&priv->usb->dev, + "RxvFreeNormal %d\n", priv->NumRecvFreeList); + spin_lock_irqsave(&priv->lock, flags); RXvFreeRCB(rcb, re_alloc_skb); @@ -352,8 +345,8 @@ int PIPEnsSendBulkOut(struct vnt_private *priv, status = usb_submit_urb(urb, GFP_ATOMIC); if (status != 0) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "Submit Tx URB failed %d\n", status); + dev_dbg(&priv->usb->dev, "Submit Tx URB failed %d\n", status); + context->in_use = false; return STATUS_FAILURE; } @@ -397,8 +390,7 @@ static void s_nsBulkOutIoCompleteWrite(struct urb *urb) switch (urb->status) { case 0: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "Write %d bytes\n", context->buf_len); + dev_dbg(&priv->usb->dev, "Write %d bytes\n", context->buf_len); break; case -ECONNRESET: case -ENOENT: @@ -407,8 +399,7 @@ static void s_nsBulkOutIoCompleteWrite(struct urb *urb) return; case -ETIMEDOUT: default: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "BULK Out failed %d\n", urb->status); + dev_dbg(&priv->usb->dev, "BULK Out failed %d\n", urb->status); break; } @@ -419,8 +410,8 @@ static void s_nsBulkOutIoCompleteWrite(struct urb *urb) if (context->skb != NULL) { dev_kfree_skb_irq(context->skb); context->skb = NULL; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "tx %d bytes\n", context->buf_len); + dev_dbg(&priv->usb->dev, + "tx %d bytes\n", context->buf_len); } priv->dev->trans_start = jiffies; -- cgit v1.2.3 From 0f06a73949f97b7043fd5cbe2768617637666b84 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 17 May 2014 09:50:21 +0100 Subject: staging: vt6656: PIPEnsControlOut remove camel case. Camel case changes pDevice, byRequest, wValue, wIndex, wLength, pbyBuffer, ntStatus -> priv, request, value, index, length, buffer, status Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/usbpipe.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 5a4666533e9c..76fa19e5bcd9 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -61,23 +61,23 @@ static void s_nsInterruptUsbIoCompleteRead(struct urb *urb); static void s_nsBulkInUsbIoCompleteRead(struct urb *urb); static void s_nsBulkOutIoCompleteWrite(struct urb *urb); -int PIPEnsControlOut(struct vnt_private *pDevice, u8 byRequest, u16 wValue, - u16 wIndex, u16 wLength, u8 *pbyBuffer) +int PIPEnsControlOut(struct vnt_private *priv, u8 request, u16 value, + u16 index, u16 length, u8 *buffer) { - int ntStatus = 0; + int status = 0; - if (pDevice->Flags & fMP_DISCONNECTED) + if (priv->Flags & fMP_DISCONNECTED) return STATUS_FAILURE; - mutex_lock(&pDevice->usb_lock); + mutex_lock(&priv->usb_lock); - ntStatus = usb_control_msg(pDevice->usb, - usb_sndctrlpipe(pDevice->usb, 0), byRequest, 0x40, wValue, - wIndex, pbyBuffer, wLength, USB_CTL_WAIT); + status = usb_control_msg(priv->usb, + usb_sndctrlpipe(priv->usb, 0), request, 0x40, value, + index, buffer, length, USB_CTL_WAIT); - mutex_unlock(&pDevice->usb_lock); + mutex_unlock(&priv->usb_lock); - if (ntStatus < (int)wLength) + if (status < (int)length) return STATUS_FAILURE; return STATUS_SUCCESS; -- cgit v1.2.3 From 9af49fdbdde5a8cedfcc64f223d5291114db3a90 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 17 May 2014 09:50:22 +0100 Subject: staging: vt6656: PIPEnsControlIn remove camel case. Camel case changes pDevice, byRequest, wValue, wIndex, wLength, pbyBuffer, ntStatus -> priv, request, value, index, length, buffer, status Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/usbpipe.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 76fa19e5bcd9..2dfa16e3ad01 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -83,23 +83,23 @@ int PIPEnsControlOut(struct vnt_private *priv, u8 request, u16 value, return STATUS_SUCCESS; } -int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue, - u16 wIndex, u16 wLength, u8 *pbyBuffer) +int PIPEnsControlIn(struct vnt_private *priv, u8 request, u16 value, + u16 index, u16 length, u8 *buffer) { - int ntStatus; + int status; - if (pDevice->Flags & fMP_DISCONNECTED) + if (priv->Flags & fMP_DISCONNECTED) return STATUS_FAILURE; - mutex_lock(&pDevice->usb_lock); + mutex_lock(&priv->usb_lock); - ntStatus = usb_control_msg(pDevice->usb, - usb_rcvctrlpipe(pDevice->usb, 0), byRequest, 0xc0, wValue, - wIndex, pbyBuffer, wLength, USB_CTL_WAIT); + status = usb_control_msg(priv->usb, + usb_rcvctrlpipe(priv->usb, 0), request, 0xc0, value, + index, buffer, length, USB_CTL_WAIT); - mutex_unlock(&pDevice->usb_lock); + mutex_unlock(&priv->usb_lock); - if (ntStatus < (int)wLength) + if (status < (int)length) return STATUS_FAILURE; return STATUS_SUCCESS; -- cgit v1.2.3 From fe7111aa936eb5226ba9aa519a636371a6f5aa61 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 17 May 2014 09:50:23 +0100 Subject: staging: vt6656: device_cfg.h remove dead code. Also unneeded #ifndef Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/device_cfg.h | 45 ------------------------------------- 1 file changed, 45 deletions(-) diff --git a/drivers/staging/vt6656/device_cfg.h b/drivers/staging/vt6656/device_cfg.h index 0b9d8349c2e4..b01833936352 100644 --- a/drivers/staging/vt6656/device_cfg.h +++ b/drivers/staging/vt6656/device_cfg.h @@ -27,61 +27,16 @@ #ifndef __DEVICE_CONFIG_H #define __DEVICE_CONFIG_H -#include - -typedef -struct _version { - unsigned char major; - unsigned char minor; - unsigned char build; -} version_t, *pversion_t; - -#ifndef false -#define false (0) -#endif - -#ifndef true -#define true (!(false)) -#endif - -#define VID_TABLE_SIZE 64 -#define MCAST_TABLE_SIZE 64 -#define MCAM_SIZE 32 -#define VCAM_SIZE 32 -#define TX_QUEUE_NO 8 - #define DEVICE_NAME "vt6656" #define DEVICE_FULL_DRV_NAM "VIA Networking Wireless LAN USB Driver" -#ifndef MAJOR_VERSION -#define MAJOR_VERSION 1 -#endif - -#ifndef MINOR_VERSION -#define MINOR_VERSION 13 -#endif - -#ifndef DEVICE_VERSION #define DEVICE_VERSION "1.19_12" -#endif #define MAX_RATE 12 -/* config file */ -#include -#include -#ifndef CONFIG_PATH #define CONFIG_PATH "/etc/vntconfiguration.dat" -#endif - -/* Max: 2378 = 2312 Payload + 30HD + 4CRC + 2Padding + 4Len + 8TSF + 4RSR */ -#define PKT_BUF_SZ 2390 #define MAX_UINTS 8 #define OPTION_DEFAULT { [0 ... MAX_UINTS-1] = -1} -typedef enum _chip_type { - VT3184 = 1 -} CHIP_TYPE, *PCHIP_TYPE; - #endif -- cgit v1.2.3 From 4aeaf1538f7179edefcc6e35203828c7cc4f85a5 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 17 May 2014 09:50:24 +0100 Subject: staging: vt6656: device_cfg.h Move macros to device.h Remove device_cfg.h Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/device.h | 13 +++++++++++- drivers/staging/vt6656/device_cfg.h | 42 ------------------------------------- 2 files changed, 12 insertions(+), 43 deletions(-) delete mode 100644 drivers/staging/vt6656/device_cfg.h diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index 410e0288f90d..3c2c4ce0753c 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -60,11 +60,12 @@ #define RT_DOWNDEV_EVENT_FLAG 0x0105 #define RT_RMMOD_EVENT_FLAG 0x0106 +#define MAX_RATE 12 + /* * device specific */ -#include "device_cfg.h" #include "80211hdr.h" #include "tether.h" #include "wmgr.h" @@ -79,6 +80,16 @@ #define VNT_USB_VENDOR_ID 0x160a #define VNT_USB_PRODUCT_ID 0x3184 +#define DEVICE_NAME "vt6656" +#define DEVICE_FULL_DRV_NAM "VIA Networking Wireless LAN USB Driver" + +#define DEVICE_VERSION "1.19_12" + +#define CONFIG_PATH "/etc/vntconfiguration.dat" + +#define MAX_UINTS 8 +#define OPTION_DEFAULT { [0 ... MAX_UINTS-1] = -1} + #define MAC_MAX_CONTEXT_REG (256+128) #define MAX_MULTICAST_ADDRESS_NUM 32 diff --git a/drivers/staging/vt6656/device_cfg.h b/drivers/staging/vt6656/device_cfg.h deleted file mode 100644 index b01833936352..000000000000 --- a/drivers/staging/vt6656/device_cfg.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: device_cfg.h - * - * Purpose: Driver configuration header - * Author: Lyndon Chen - * - * Date: Dec 9, 2005 - * - */ -#ifndef __DEVICE_CONFIG_H -#define __DEVICE_CONFIG_H - -#define DEVICE_NAME "vt6656" -#define DEVICE_FULL_DRV_NAM "VIA Networking Wireless LAN USB Driver" - -#define DEVICE_VERSION "1.19_12" - -#define MAX_RATE 12 - -#define CONFIG_PATH "/etc/vntconfiguration.dat" - -#define MAX_UINTS 8 -#define OPTION_DEFAULT { [0 ... MAX_UINTS-1] = -1} - -#endif -- cgit v1.2.3 From d4f376ddbecf8d2927bd5326f39659ba570cac7e Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 17 May 2014 09:50:25 +0100 Subject: staging: vt6656: device.h remove dead macros Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/device.h | 67 +---------------------------------------- 1 file changed, 1 insertion(+), 66 deletions(-) diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index 3c2c4ce0753c..f8591a283f93 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -52,14 +52,6 @@ #undef DEVICE_ETHTOOL_IOCTL_SUPPORT #endif -/* please copy below macro to driver_event.c for API */ -#define RT_INSMOD_EVENT_FLAG 0x0101 -#define RT_UPDEV_EVENT_FLAG 0x0102 -#define RT_DISCONNECTED_EVENT_FLAG 0x0103 -#define RT_WPACONNECTED_EVENT_FLAG 0x0104 -#define RT_DOWNDEV_EVENT_FLAG 0x0105 -#define RT_RMMOD_EVENT_FLAG 0x0106 - #define MAX_RATE 12 /* @@ -90,27 +82,8 @@ #define MAX_UINTS 8 #define OPTION_DEFAULT { [0 ... MAX_UINTS-1] = -1} -#define MAC_MAX_CONTEXT_REG (256+128) - -#define MAX_MULTICAST_ADDRESS_NUM 32 -#define MULTICAST_ADDRESS_LIST_SIZE (MAX_MULTICAST_ADDRESS_NUM * ETH_ALEN) - #define DUPLICATE_RX_CACHE_LENGTH 5 -#define NUM_KEY_ENTRY 11 - -#define TX_WEP_NONE 0 -#define TX_WEP_OTF 1 -#define TX_WEP_SW 2 -#define TX_WEP_SWOTP 3 -#define TX_WEP_OTPSW 4 -#define TX_WEP_SW232 5 - -#define KEYSEL_WEP40 0 -#define KEYSEL_WEP104 1 -#define KEYSEL_TKIP 2 -#define KEYSEL_CCMP 3 - #define AUTO_FB_NONE 0 #define AUTO_FB_0 1 #define AUTO_FB_1 2 @@ -130,13 +103,6 @@ #define ANT_RXA 2 #define ANT_RXB 3 -#define MAXCHECKHANGCNT 4 - -/* Packet type */ -#define TX_PKT_UNI 0x00 -#define TX_PKT_MULTI 0x01 -#define TX_PKT_BROAD 0x02 - #define BB_VGA_LEVEL 4 #define BB_VGA_CHANGE_THRESHOLD 3 @@ -144,9 +110,6 @@ #define RUN_AT(x) (jiffies+(x)) #endif -/* DMA related */ -#define RESERV_AC0DMA 4 - #define PRIVATE_Message 0 #define DBG_PRT(l, p, args...) { if (l <= msglevel) printk(p, ##args); } @@ -320,29 +283,9 @@ typedef struct tagSDeFragControlBlock /* flags for options */ #define DEVICE_FLAGS_UNPLUG 0x00000001UL -#define DEVICE_FLAGS_PREAMBLE_TYPE 0x00000002UL -#define DEVICE_FLAGS_OP_MODE 0x00000004UL -#define DEVICE_FLAGS_PS_MODE 0x00000008UL -#define DEVICE_FLAGS_80211h_MODE 0x00000010UL /* flags for driver status */ #define DEVICE_FLAGS_OPENED 0x00010000UL -#define DEVICE_FLAGS_WOL_ENABLED 0x00080000UL -/* flags for capabilities */ -#define DEVICE_FLAGS_TX_ALIGN 0x01000000UL -#define DEVICE_FLAGS_HAVE_CAM 0x02000000UL -#define DEVICE_FLAGS_FLOW_CTRL 0x04000000UL - -/* flags for MII status */ -#define DEVICE_LINK_FAIL 0x00000001UL -#define DEVICE_SPEED_10 0x00000002UL -#define DEVICE_SPEED_100 0x00000004UL -#define DEVICE_SPEED_1000 0x00000008UL -#define DEVICE_DUPLEX_FULL 0x00000010UL -#define DEVICE_AUTONEG_ENABLE 0x00000020UL -#define DEVICE_FORCED_BY_EEPROM 0x00000040UL -/* for device_set_media_duplex */ -#define DEVICE_LINK_CHANGE 0x00000001UL typedef struct __device_opt { int nRxDescs0; /* number of RX descriptors 0 */ @@ -742,14 +685,7 @@ struct vnt_private { (uVar)++; \ } -#define fMP_RESET_IN_PROGRESS 0x00000001 #define fMP_DISCONNECTED 0x00000002 -#define fMP_HALT_IN_PROGRESS 0x00000004 -#define fMP_SURPRISE_REMOVED 0x00000008 -#define fMP_RECV_LOOKASIDE 0x00000010 -#define fMP_INIT_IN_PROGRESS 0x00000020 -#define fMP_SEND_SIDE_RESOURCE_ALLOCATED 0x00000040 -#define fMP_RECV_SIDE_RESOURCE_ALLOCATED 0x00000080 #define fMP_POST_READS 0x00000100 #define fMP_POST_WRITES 0x00000200 @@ -757,8 +693,7 @@ struct vnt_private { #define MP_CLEAR_FLAG(_M, _F) ((_M)->Flags &= ~(_F)) #define MP_TEST_FLAGS(_M, _F) (((_M)->Flags & (_F)) == (_F)) -#define MP_IS_READY(_M) (((_M)->Flags & \ - (fMP_DISCONNECTED | fMP_RESET_IN_PROGRESS | fMP_HALT_IN_PROGRESS | fMP_INIT_IN_PROGRESS | fMP_SURPRISE_REMOVED)) == 0) +#define MP_IS_READY(_M) (((_M)->Flags & fMP_DISCONNECTED) == 0) int device_alloc_frag_buf(struct vnt_private *, PSDeFragControlBlock pDeF); void vnt_configure_filter(struct vnt_private *); -- cgit v1.2.3 From bffa42e1515e6cc8c4b14e8e86d772391476848b Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 17 May 2014 09:50:26 +0100 Subject: staging: vt6656: desc.h Remove unused macros Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/desc.h | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/staging/vt6656/desc.h b/drivers/staging/vt6656/desc.h index 171315ab864a..617d479b85cc 100644 --- a/drivers/staging/vt6656/desc.h +++ b/drivers/staging/vt6656/desc.h @@ -39,28 +39,15 @@ /* max transmit or receive buffer size */ #define CB_MAX_BUF_SIZE 2900U /* NOTE: must be multiple of 4 */ -/* max TX buffer size */ -#define CB_MAX_TX_BUF_SIZE CB_MAX_BUF_SIZE -/* max RX buffer size when not use Multi-RD */ -#define CB_MAX_RX_BUF_SIZE_NORMAL CB_MAX_BUF_SIZE - -#define CB_BEACON_BUF_SIZE 512U /* default beacon buffer size */ - #define MAX_TOTAL_SIZE_WITH_ALL_HEADERS CB_MAX_BUF_SIZE #define MAX_INTERRUPT_SIZE 32 -#define RX_BLOCKS 64 /* from 0x60 to 0xA0 */ -#define TX_BLOCKS 32 /* from 0xA0 to 0xC0 */ - #define CB_MAX_RX_DESC 128 /* max # of descriptors */ #define CB_MIN_RX_DESC 16 /* min # of RX descriptors */ #define CB_MAX_TX_DESC 128 /* max # of descriptors */ #define CB_MIN_TX_DESC 16 /* min # of TX descriptors */ -#define CB_RD_NUM 64 /* default # of RD */ -#define CB_TD_NUM 64 /* default # of TD */ - /* * bits in the RSR register */ -- cgit v1.2.3 From 399db90dd75930770e82cf240f0afc38d98f5020 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 17 May 2014 09:50:27 +0100 Subject: staging: vt6656: srom.h : Remove dead code. Remove macros and unused strutures. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/srom.h | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/drivers/staging/vt6656/srom.h b/drivers/staging/vt6656/srom.h index 488192d79ac9..ce61ab423e24 100644 --- a/drivers/staging/vt6656/srom.h +++ b/drivers/staging/vt6656/srom.h @@ -32,10 +32,6 @@ #define EEP_MAX_CONTEXT_SIZE 256 -#define CB_EEPROM_READBYTE_WAIT 900 //us - -#define W_MAX_I2CRETRY 0x0fff - // // Contents in the EEPROM // @@ -75,38 +71,4 @@ // #define EEP_RADIOCTL_ENABLE 0x80 -// AT24C02 eeprom contents -// 2048 bits = 256 bytes = 128 words -// -typedef struct tagSSromReg { - u8 abyPAR[6]; // 0x00 (u16) - - u16 wSUB_VID; // 0x03 (u16) - u16 wSUB_SID; - - u8 byBCFG0; // 0x05 (u16) - u8 byBCFG1; - - u8 byFCR0; // 0x06 (u16) - u8 byFCR1; - u8 byPMC0; // 0x07 (u16) - u8 byPMC1; - u8 byMAXLAT; // 0x08 (u16) - u8 byMINGNT; - u8 byCFG0; // 0x09 (u16) - u8 byCFG1; - u16 wCISPTR; // 0x0A (u16) - u16 wRsv0; // 0x0B (u16) - u16 wRsv1; // 0x0C (u16) - u8 byBBPAIR; // 0x0D (u16) - u8 byRFTYPE; - u8 byMinChannel; // 0x0E (u16) - u8 byMaxChannel; - u8 bySignature; // 0x0F (u16) - u8 byCheckSum; - - u8 abyReserved0[96]; // 0x10 (u16) - u8 abyCIS[128]; // 0x80 (u16) -} SSromReg, *PSSromReg; - #endif /* __EEPROM_H__ */ -- cgit v1.2.3 From 15baf4ff626c2f89104f93197e1495b87618189f Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 17 May 2014 09:50:28 +0100 Subject: staging: vt6656: srom.h move all macros to device.h Remove srom.h Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 1 - drivers/staging/vt6656/datarate.c | 1 - drivers/staging/vt6656/device.h | 36 ++++++++++++++++++- drivers/staging/vt6656/srom.h | 74 --------------------------------------- 4 files changed, 35 insertions(+), 77 deletions(-) delete mode 100644 drivers/staging/vt6656/srom.h diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index 3d4610e25fca..9f3b2fbd9060 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -40,7 +40,6 @@ #include "mac.h" #include "baseband.h" #include "rf.h" -#include "srom.h" #include "control.h" #include "datarate.h" #include "rndis.h" diff --git a/drivers/staging/vt6656/datarate.c b/drivers/staging/vt6656/datarate.c index 547db6f0c53f..8032d6b5b383 100644 --- a/drivers/staging/vt6656/datarate.c +++ b/drivers/staging/vt6656/datarate.c @@ -40,7 +40,6 @@ #include "datarate.h" #include "card.h" #include "baseband.h" -#include "srom.h" #include "rf.h" /* static int msglevel = MSG_LEVEL_DEBUG; */ diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index f8591a283f93..990b3450614b 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -62,7 +62,6 @@ #include "tether.h" #include "wmgr.h" #include "wcmd.h" -#include "srom.h" #include "rc4.h" #include "desc.h" #include "key.h" @@ -106,6 +105,41 @@ #define BB_VGA_LEVEL 4 #define BB_VGA_CHANGE_THRESHOLD 3 +#define EEP_MAX_CONTEXT_SIZE 256 + +/* Contents in the EEPROM */ +#define EEP_OFS_PAR 0x0 +#define EEP_OFS_ANTENNA 0x17 +#define EEP_OFS_RADIOCTL 0x18 +#define EEP_OFS_RFTYPE 0x1b +#define EEP_OFS_MINCHANNEL 0x1c +#define EEP_OFS_MAXCHANNEL 0x1d +#define EEP_OFS_SIGNATURE 0x1e +#define EEP_OFS_ZONETYPE 0x1f +#define EEP_OFS_RFTABLE 0x20 +#define EEP_OFS_PWR_CCK 0x20 +#define EEP_OFS_SETPT_CCK 0x21 +#define EEP_OFS_PWR_OFDMG 0x23 + +#define EEP_OFS_CALIB_TX_IQ 0x24 +#define EEP_OFS_CALIB_TX_DC 0x25 +#define EEP_OFS_CALIB_RX_IQ 0x26 + +#define EEP_OFS_MAJOR_VER 0x2e +#define EEP_OFS_MINOR_VER 0x2f + +#define EEP_OFS_CCK_PWR_TBL 0x30 +#define EEP_OFS_OFDM_PWR_TBL 0x40 +#define EEP_OFS_OFDMA_PWR_TBL 0x50 + +/* Bits in EEP_OFS_ANTENNA */ +#define EEP_ANTENNA_MAIN 0x1 +#define EEP_ANTENNA_AUX 0x2 +#define EEP_ANTINV 0x4 + +/* Bits in EEP_OFS_RADIOCTL */ +#define EEP_RADIOCTL_ENABLE 0x80 + #ifndef RUN_AT #define RUN_AT(x) (jiffies+(x)) #endif diff --git a/drivers/staging/vt6656/srom.h b/drivers/staging/vt6656/srom.h deleted file mode 100644 index ce61ab423e24..000000000000 --- a/drivers/staging/vt6656/srom.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: srom.h - * - * Purpose: Implement functions to access eeprom - * - * Author: Jerry Chen - * - * Date: Jan 29, 2003 - * - */ - -#ifndef __SROM_H__ -#define __SROM_H__ - -#define EEP_MAX_CONTEXT_SIZE 256 - -// -// Contents in the EEPROM -// -#define EEP_OFS_PAR 0x00 // physical address -#define EEP_OFS_ANTENNA 0x17 -#define EEP_OFS_RADIOCTL 0x18 -#define EEP_OFS_RFTYPE 0x1B // for select RF -#define EEP_OFS_MINCHANNEL 0x1C // Min Channel # -#define EEP_OFS_MAXCHANNEL 0x1D // Max Channel # -#define EEP_OFS_SIGNATURE 0x1E // -#define EEP_OFS_ZONETYPE 0x1F // -#define EEP_OFS_RFTABLE 0x20 // RF POWER TABLE -#define EEP_OFS_PWR_CCK 0x20 -#define EEP_OFS_SETPT_CCK 0x21 -#define EEP_OFS_PWR_OFDMG 0x23 - -#define EEP_OFS_CALIB_TX_IQ 0x24 -#define EEP_OFS_CALIB_TX_DC 0x25 -#define EEP_OFS_CALIB_RX_IQ 0x26 - -#define EEP_OFS_MAJOR_VER 0x2E -#define EEP_OFS_MINOR_VER 0x2F - -#define EEP_OFS_CCK_PWR_TBL 0x30 -#define EEP_OFS_OFDM_PWR_TBL 0x40 -#define EEP_OFS_OFDMA_PWR_TBL 0x50 - -// -// Bits in EEP_OFS_ANTENNA -// -#define EEP_ANTENNA_MAIN 0x01 -#define EEP_ANTENNA_AUX 0x02 -#define EEP_ANTINV 0x04 - -// -// Bits in EEP_OFS_RADIOCTL -// -#define EEP_RADIOCTL_ENABLE 0x80 - -#endif /* __EEPROM_H__ */ -- cgit v1.2.3 From 887651e00e2745c3ae571f68fb3be0669a6cc896 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 17 May 2014 09:50:29 +0100 Subject: staging: vt6656: rndis.h remove dead code. Remove dead structures and macros. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rndis.h | 64 ------------------------------------------ 1 file changed, 64 deletions(-) diff --git a/drivers/staging/vt6656/rndis.h b/drivers/staging/vt6656/rndis.h index 3661f82766e0..cf4e0e087bca 100644 --- a/drivers/staging/vt6656/rndis.h +++ b/drivers/staging/vt6656/rndis.h @@ -64,21 +64,8 @@ #define MESSAGE_REQUEST_RF_CH1 0x0C #define MESSAGE_REQUEST_RF_CH2 0x0D -#define VIAUSB20_PACKET_HEADER 0x04 - #define USB_REG4 0x604 -typedef struct _CMD_MESSAGE -{ - u8 byData[256]; -} CMD_MESSAGE, *PCMD_MESSAGE; - -typedef struct _CMD_WRITE_MASK -{ - u8 byData; - u8 byMask; -} CMD_WRITE_MASK, *PCMD_WRITE_MASK; - struct vnt_cmd_card_init { u8 init_class; @@ -97,55 +84,4 @@ struct vnt_rsp_card_init u8 max_channel; }; -typedef struct _CMD_SET_KEY -{ - u16 wKCTL; - u8 abyMacAddr[6]; - u8 abyKey[16]; -} CMD_SET_KEY, *PCMD_SET_KEY; - -typedef struct _CMD_CLRKEY_ENTRY -{ - u8 abyKeyEntry[11]; -} CMD_CLRKEY_ENTRY, *PCMD_CLRKEY_ENTRY; - -typedef struct _CMD_WRITE_MISCFF -{ - u32 adwMiscFFData[22][4]; //a key entry has only 22 dwords -} CMD_WRITE_MISCFF, *PCMD_WRITE_MISCFF; - -typedef struct _CMD_SET_TSFTBTT -{ - u8 abyTSF_TBTT[8]; -} CMD_SET_TSFTBTT, *PCMD_SET_TSFTBTT; - -typedef struct _CMD_SET_SSTIFS -{ - u8 bySIFS; - u8 byDIFS; - u8 byEIFS; - u8 bySlotTime; - u8 byCwMax_Min; - u8 byBBCR10; -} CMD_SET_SSTIFS, *PCMD_SET_SSTIFS; - -typedef struct _CMD_CHANGE_BBTYPE -{ - u8 bySIFS; - u8 byDIFS; - u8 byEIFS; - u8 bySlotTime; - u8 byCwMax_Min; - u8 byBBCR10; - u8 byBB_BBType; //CR88 - u8 byMAC_BBType; - u32 dwRSPINF_b_1; - u32 dwRSPINF_b_2; - u32 dwRSPINF_b_55; - u32 dwRSPINF_b_11; - u16 wRSPINF_a[9]; -} CMD_CHANGE_BBTYPE, *PCMD_CHANGE_BBTYPE; - -#define EXCH_WORD(w) ((u16)((u16)(w)<<8) | (u16)((u16)(w)>>8)) - #endif /* _RNDIS_H_ */ -- cgit v1.2.3 From 60f8ce8dd6feb2d921a5513e79eaf9d6884abc09 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 17 May 2014 09:50:30 +0100 Subject: staging: vt6656: rndis.h move all to device.h Commands macros are common to all source files. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 1 - drivers/staging/vt6656/bssdb.c | 1 - drivers/staging/vt6656/card.c | 1 - drivers/staging/vt6656/control.c | 1 - drivers/staging/vt6656/device.h | 56 ++++++++++++++++++++++++- drivers/staging/vt6656/firmware.c | 1 - drivers/staging/vt6656/iwctl.c | 1 - drivers/staging/vt6656/key.c | 1 - drivers/staging/vt6656/mac.c | 1 - drivers/staging/vt6656/power.c | 1 - drivers/staging/vt6656/rf.c | 1 - drivers/staging/vt6656/rndis.h | 87 --------------------------------------- drivers/staging/vt6656/wcmd.c | 1 - drivers/staging/vt6656/wmgr.c | 1 - drivers/staging/vt6656/wpactl.c | 1 - 15 files changed, 55 insertions(+), 101 deletions(-) delete mode 100644 drivers/staging/vt6656/rndis.h diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index 9f3b2fbd9060..b4489d6c6c26 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -42,7 +42,6 @@ #include "rf.h" #include "control.h" #include "datarate.h" -#include "rndis.h" static int msglevel =MSG_LEVEL_INFO; //static int msglevel =MSG_LEVEL_DEBUG; diff --git a/drivers/staging/vt6656/bssdb.c b/drivers/staging/vt6656/bssdb.c index b018955a2f9c..7e8e67a460ca 100644 --- a/drivers/staging/vt6656/bssdb.c +++ b/drivers/staging/vt6656/bssdb.c @@ -54,7 +54,6 @@ #include "mac.h" #include "wpa2.h" #include "control.h" -#include "rndis.h" #include "iowpa.h" #include "power.h" diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index 0d8772858f09..b8f35e7a25ee 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -57,7 +57,6 @@ #include "rc4.h" #include "country.h" #include "datarate.h" -#include "rndis.h" #include "control.h" //static int msglevel =MSG_LEVEL_DEBUG; diff --git a/drivers/staging/vt6656/control.c b/drivers/staging/vt6656/control.c index 026784fcde82..fc19166e2f8b 100644 --- a/drivers/staging/vt6656/control.c +++ b/drivers/staging/vt6656/control.c @@ -41,7 +41,6 @@ */ #include "control.h" -#include "rndis.h" /* static int msglevel =MSG_LEVEL_INFO; */ /* static int msglevel =MSG_LEVEL_DEBUG; */ diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index 990b3450614b..59d3828bf7c2 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -66,7 +66,6 @@ #include "desc.h" #include "key.h" #include "card.h" -#include "rndis.h" #define VNT_USB_VENDOR_ID 0x160a #define VNT_USB_PRODUCT_ID 0x3184 @@ -140,6 +139,44 @@ /* Bits in EEP_OFS_RADIOCTL */ #define EEP_RADIOCTL_ENABLE 0x80 +/* control commands */ +#define MESSAGE_TYPE_READ 0x1 +#define MESSAGE_TYPE_WRITE 0x0 +#define MESSAGE_TYPE_LOCK_OR 0x2 +#define MESSAGE_TYPE_LOCK_AND 0x3 +#define MESSAGE_TYPE_WRITE_MASK 0x4 +#define MESSAGE_TYPE_CARDINIT 0x5 +#define MESSAGE_TYPE_INIT_RSP 0x6 +#define MESSAGE_TYPE_MACSHUTDOWN 0x7 +#define MESSAGE_TYPE_SETKEY 0x8 +#define MESSAGE_TYPE_CLRKEYENTRY 0x9 +#define MESSAGE_TYPE_WRITE_MISCFF 0xa +#define MESSAGE_TYPE_SET_ANTMD 0xb +#define MESSAGE_TYPE_SELECT_CHANNLE 0xc +#define MESSAGE_TYPE_SET_TSFTBTT 0xd +#define MESSAGE_TYPE_SET_SSTIFS 0xe +#define MESSAGE_TYPE_CHANGE_BBTYPE 0xf +#define MESSAGE_TYPE_DISABLE_PS 0x10 +#define MESSAGE_TYPE_WRITE_IFRF 0x11 + +/* command read/write(index) */ +#define MESSAGE_REQUEST_MEM 0x1 +#define MESSAGE_REQUEST_BBREG 0x2 +#define MESSAGE_REQUEST_MACREG 0x3 +#define MESSAGE_REQUEST_EEPROM 0x4 +#define MESSAGE_REQUEST_TSF 0x5 +#define MESSAGE_REQUEST_TBTT 0x6 +#define MESSAGE_REQUEST_BBAGC 0x7 +#define MESSAGE_REQUEST_VERSION 0x8 +#define MESSAGE_REQUEST_RF_INIT 0x9 +#define MESSAGE_REQUEST_RF_INIT2 0xa +#define MESSAGE_REQUEST_RF_CH0 0xb +#define MESSAGE_REQUEST_RF_CH1 0xc +#define MESSAGE_REQUEST_RF_CH2 0xd + +/* USB registers */ +#define USB_REG4 0x604 + #ifndef RUN_AT #define RUN_AT(x) (jiffies+(x)) #endif @@ -161,6 +198,23 @@ typedef enum __device_msg_level { #define DEVICE_INIT_RESET 0x1 /* reset init or Dx to D0 power remain */ #define DEVICE_INIT_DXPL 0x2 /* Dx to D0 power lost init */ +/* Device init */ +struct vnt_cmd_card_init { + u8 init_class; + u8 exist_sw_net_addr; + u8 sw_net_addr[6]; + u8 short_retry_limit; + u8 long_retry_limit; +}; + +struct vnt_rsp_card_init { + u8 status; + u8 net_addr[6]; + u8 rf_type; + u8 min_channel; + u8 max_channel; +}; + /* USB */ /* diff --git a/drivers/staging/vt6656/firmware.c b/drivers/staging/vt6656/firmware.c index e03f1f97b284..1d3d268ef772 100644 --- a/drivers/staging/vt6656/firmware.c +++ b/drivers/staging/vt6656/firmware.c @@ -34,7 +34,6 @@ #include #include "firmware.h" #include "control.h" -#include "rndis.h" static int msglevel = MSG_LEVEL_INFO; /* static int msglevel = MSG_LEVEL_DEBUG; */ diff --git a/drivers/staging/vt6656/iwctl.c b/drivers/staging/vt6656/iwctl.c index bfd5f371e4ad..38739fa32461 100644 --- a/drivers/staging/vt6656/iwctl.c +++ b/drivers/staging/vt6656/iwctl.c @@ -40,7 +40,6 @@ #include "iowpa.h" #include "wpactl.h" #include "control.h" -#include "rndis.h" #include "baseband.h" static const long frequency_list[] = { diff --git a/drivers/staging/vt6656/key.c b/drivers/staging/vt6656/key.c index b173ca154024..a88c6b1886dc 100644 --- a/drivers/staging/vt6656/key.c +++ b/drivers/staging/vt6656/key.c @@ -39,7 +39,6 @@ #include "mac.h" #include "tmacro.h" #include "key.h" -#include "rndis.h" #include "control.h" static int msglevel =MSG_LEVEL_INFO; diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index 8bd3ab0407bf..8298a9e25ee2 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -35,7 +35,6 @@ #include "desc.h" #include "mac.h" #include "80211hdr.h" -#include "rndis.h" #include "control.h" //static int msglevel =MSG_LEVEL_DEBUG; diff --git a/drivers/staging/vt6656/power.c b/drivers/staging/vt6656/power.c index 43da58927cd2..c4bea74f86f9 100644 --- a/drivers/staging/vt6656/power.c +++ b/drivers/staging/vt6656/power.c @@ -45,7 +45,6 @@ #include "rxtx.h" #include "card.h" #include "control.h" -#include "rndis.h" static int msglevel = MSG_LEVEL_INFO; diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c index 64632e9fff63..7217f2c8bb04 100644 --- a/drivers/staging/vt6656/rf.c +++ b/drivers/staging/vt6656/rf.c @@ -39,7 +39,6 @@ #include "rf.h" #include "baseband.h" #include "control.h" -#include "rndis.h" #include "datarate.h" static int msglevel =MSG_LEVEL_INFO; diff --git a/drivers/staging/vt6656/rndis.h b/drivers/staging/vt6656/rndis.h deleted file mode 100644 index cf4e0e087bca..000000000000 --- a/drivers/staging/vt6656/rndis.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: rndis.h - * - * Purpose: Interface between firmware and driver - * - * Author: Warren Hsu - * - * Date: Nov 24, 2004 - * - */ - -#ifndef __RNDIS_H__ -#define __RNDIS_H__ - -#define MESSAGE_TYPE_READ 0x01 -#define MESSAGE_TYPE_WRITE 0x00 -#define MESSAGE_TYPE_LOCK_OR 0x02 -#define MESSAGE_TYPE_LOCK_AND 0x03 -#define MESSAGE_TYPE_WRITE_MASK 0x04 -#define MESSAGE_TYPE_CARDINIT 0x05 -#define MESSAGE_TYPE_INIT_RSP 0x06 -#define MESSAGE_TYPE_MACSHUTDOWN 0x07 -#define MESSAGE_TYPE_SETKEY 0x08 -#define MESSAGE_TYPE_CLRKEYENTRY 0x09 -#define MESSAGE_TYPE_WRITE_MISCFF 0x0A -#define MESSAGE_TYPE_SET_ANTMD 0x0B -#define MESSAGE_TYPE_SELECT_CHANNLE 0x0C -#define MESSAGE_TYPE_SET_TSFTBTT 0x0D -#define MESSAGE_TYPE_SET_SSTIFS 0x0E -#define MESSAGE_TYPE_CHANGE_BBTYPE 0x0F -#define MESSAGE_TYPE_DISABLE_PS 0x10 -#define MESSAGE_TYPE_WRITE_IFRF 0x11 - -//used for read/write(index) -#define MESSAGE_REQUEST_MEM 0x01 -#define MESSAGE_REQUEST_BBREG 0x02 -#define MESSAGE_REQUEST_MACREG 0x03 -#define MESSAGE_REQUEST_EEPROM 0x04 -#define MESSAGE_REQUEST_TSF 0x05 -#define MESSAGE_REQUEST_TBTT 0x06 -#define MESSAGE_REQUEST_BBAGC 0x07 -#define MESSAGE_REQUEST_VERSION 0x08 -#define MESSAGE_REQUEST_RF_INIT 0x09 -#define MESSAGE_REQUEST_RF_INIT2 0x0A -#define MESSAGE_REQUEST_RF_CH0 0x0B -#define MESSAGE_REQUEST_RF_CH1 0x0C -#define MESSAGE_REQUEST_RF_CH2 0x0D - -#define USB_REG4 0x604 - -struct vnt_cmd_card_init -{ - u8 init_class; - u8 exist_sw_net_addr; - u8 sw_net_addr[6]; - u8 short_retry_limit; - u8 long_retry_limit; -}; - -struct vnt_rsp_card_init -{ - u8 status; - u8 net_addr[6]; - u8 rf_type; - u8 min_channel; - u8 max_channel; -}; - -#endif /* _RNDIS_H_ */ diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c index 66d59d51bf82..8fecb34297af 100644 --- a/drivers/staging/vt6656/wcmd.c +++ b/drivers/staging/vt6656/wcmd.c @@ -51,7 +51,6 @@ #include "control.h" #include "rxtx.h" #include "rf.h" -#include "rndis.h" #include "channel.h" #include "iowpa.h" diff --git a/drivers/staging/vt6656/wmgr.c b/drivers/staging/vt6656/wmgr.c index cce67cdad26a..64edc16da7ce 100644 --- a/drivers/staging/vt6656/wmgr.c +++ b/drivers/staging/vt6656/wmgr.c @@ -79,7 +79,6 @@ #include "rf.h" #include "iowpa.h" #include "control.h" -#include "rndis.h" static int msglevel = MSG_LEVEL_INFO; //static int msglevel =MSG_LEVEL_DEBUG; diff --git a/drivers/staging/vt6656/wpactl.c b/drivers/staging/vt6656/wpactl.c index f4a8a5cb9feb..b6885a91d1a4 100644 --- a/drivers/staging/vt6656/wpactl.c +++ b/drivers/staging/vt6656/wpactl.c @@ -39,7 +39,6 @@ #include "iocmd.h" #include "iowpa.h" #include "control.h" -#include "rndis.h" #include "rf.h" static int msglevel = MSG_LEVEL_INFO; -- cgit v1.2.3 From 2486890a932a8e6b3172dba3732604504ab8b885 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 17 May 2014 09:50:31 +0100 Subject: staging: vt6656: Remove unused variable byRevId. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/device.h | 2 -- drivers/staging/vt6656/main_usb.c | 7 +------ 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index 59d3828bf7c2..aefbe9382ff7 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -409,8 +409,6 @@ struct vnt_private { u32 rx_bytes; - u8 byRevId; - u32 flags; unsigned long Flags; diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 1b58ccaac1f6..68ae97c5617b 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -387,7 +387,7 @@ static int device_init_registers(struct vnt_private *pDevice) pDevice->byTopOFDMBasicRate = RATE_24M; pDevice->byTopCCKBasicRate = RATE_1M; - pDevice->byRevId = 0; + /* target to IF pin while programming to RF chip */ pDevice->byCurPwr = 0xFF; @@ -508,11 +508,6 @@ static int device_init_registers(struct vnt_private *pDevice) /* get RFType */ pDevice->byRFType = init_rsp->rf_type; - if ((pDevice->byRFType & RF_EMU) != 0) { - /* force change RevID for VT3253 emu */ - pDevice->byRevId = 0x80; - } - /* load vt3266 calibration parameters in EEPROM */ if (pDevice->byRFType == RF_VT3226D0) { if ((pDevice->abyEEPROM[EEP_OFS_MAJOR_VER] == 0x1) && -- cgit v1.2.3 From a0522e88c057519a6ac38cc1269286950e84ccc3 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 17 May 2014 09:50:32 +0100 Subject: staging: vt6656: Remove unused variable ulTxPower. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/device.h | 1 - drivers/staging/vt6656/main_usb.c | 3 --- 2 files changed, 4 deletions(-) diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index aefbe9382ff7..7e7ac8034581 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -639,7 +639,6 @@ struct vnt_private { u8 bSameBSSCurNum; int bRoaming; int b11hEable; - unsigned long ulTxPower; /* Encryption */ NDIS_802_11_WEP_STATUS eEncryptionStatus; diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 68ae97c5617b..3832bcb3d798 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -498,9 +498,6 @@ static int device_init_registers(struct vnt_private *pDevice) pDevice->eConfigPHYMode = PHY_TYPE_AUTO; pDevice->byBBType = BB_TYPE_11G; - /* initialize BBP registers */ - pDevice->ulTxPower = 25; - /* get channel range */ pDevice->byMinChannel = 1; pDevice->byMaxChannel = CB_MAX_CHANNEL; -- cgit v1.2.3 From f576abc8fc807f8faaff516d511e974cb959a527 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 17 May 2014 09:50:33 +0100 Subject: staging: vt6656: Remove dead variable bCCK. bCCK is always true remove all false conditions and local variable. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 6 ------ drivers/staging/vt6656/device.h | 1 - drivers/staging/vt6656/main_usb.c | 2 -- drivers/staging/vt6656/wmgr.c | 1 - 4 files changed, 10 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index b4489d6c6c26..a70b27890a09 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -737,7 +737,6 @@ void BBvCalculateParameter(struct vnt_private *pDevice, u32 cbFrameLength, u32 cbTmp; int bExtBit; u8 byPreambleType = pDevice->byPreambleType; - int bCCK = pDevice->bCCK; cbBitCount = cbFrameLength * 8; bExtBit = false; @@ -757,8 +756,6 @@ void BBvCalculateParameter(struct vnt_private *pDevice, u32 cbFrameLength, break; case RATE_5M : - if (bCCK == false) - cbBitCount ++; cbUsCount = (cbBitCount * 10) / 55; cbTmp = (cbUsCount * 55) / 10; if (cbTmp != cbBitCount) @@ -770,9 +767,6 @@ void BBvCalculateParameter(struct vnt_private *pDevice, u32 cbFrameLength, break; case RATE_11M : - - if (bCCK == false) - cbBitCount ++; cbUsCount = cbBitCount / 11; cbTmp = cbUsCount * 11; if (cbTmp != cbBitCount) { diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index 7e7ac8034581..824882487724 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -581,7 +581,6 @@ struct vnt_private { u32 dwMaxReceiveLifetime; /* dot11MaxReceiveLifetime */ - int bCCK; int bEncryptionEnable; int bShortSlotTime; int bProtectMode; diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 3832bcb3d798..ea0c9e7c331e 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -368,8 +368,6 @@ static int device_init_registers(struct vnt_private *pDevice) /* do MACbSoftwareReset in MACvInitialize */ - /* force CCK */ - pDevice->bCCK = true; pDevice->bProtectMode = false; /* only used in 11g type, sync with ERP IE */ pDevice->bNonERPPresent = false; diff --git a/drivers/staging/vt6656/wmgr.c b/drivers/staging/vt6656/wmgr.c index 64edc16da7ce..d08f29086818 100644 --- a/drivers/staging/vt6656/wmgr.c +++ b/drivers/staging/vt6656/wmgr.c @@ -2571,7 +2571,6 @@ static void s_vMgrSynchBSS(struct vnt_private *pDevice, u32 uBSSMode, } // Init the BSS informations - pDevice->bCCK = true; pDevice->bProtectMode = false; MACvDisableProtectMD(pDevice); pDevice->bBarkerPreambleMd = false; -- cgit v1.2.3 From 6983df6fbceb9978d024f6455cfbb9d25022627c Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 17 May 2014 09:50:34 +0100 Subject: staging: vt6656: Remove unused variable uScanTime. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/device.h | 1 - drivers/staging/vt6656/main_usb.c | 3 --- 2 files changed, 4 deletions(-) diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index 824882487724..eff50c8a7f6c 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -607,7 +607,6 @@ struct vnt_private { int bBeaconSent; int bFixRate; u8 byCurrentCh; - u32 uScanTime; CMD_STATE eCommandState; diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index ea0c9e7c331e..c00a16c610ea 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -488,9 +488,6 @@ static int device_init_registers(struct vnt_private *pDevice) /* get Auto Fall Back type */ pDevice->byAutoFBCtrl = AUTO_FB_0; - /* set SCAN Time */ - pDevice->uScanTime = WLAN_SCAN_MINITIME; - /* default Auto Mode */ /* pDevice->NetworkType = Ndis802_11Automode; */ pDevice->eConfigPHYMode = PHY_TYPE_AUTO; -- cgit v1.2.3 From e7cb8e25eb906b6d86cb7028b7daf8bb4687ca1a Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 17 May 2014 09:50:35 +0100 Subject: staging: vt6656: Remove unused variable byACKRate. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/device.h | 1 - drivers/staging/vt6656/rxtx.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index eff50c8a7f6c..73bce9e80c33 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -535,7 +535,6 @@ struct vnt_private { u8 byBBType; /* 0: 11A, 1:11B, 2:11G */ u8 byPacketType; /* 0:11a 1:11b 2:11gb 3:11ga */ u16 wBasicRate; - u8 byACKRate; u8 byTopOFDMBasicRate; u8 byTopCCKBasicRate; diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 7287467c3aff..4ec79c461d45 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -2341,12 +2341,10 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, struct sk_buff *skb) if (pDevice->sTxEthHeader.h_proto == cpu_to_be16(ETH_P_PAE)) { if (pDevice->byBBType != BB_TYPE_11A) { pDevice->wCurrentRate = RATE_1M; - pDevice->byACKRate = RATE_1M; pDevice->byTopCCKBasicRate = RATE_1M; pDevice->byTopOFDMBasicRate = RATE_6M; } else { pDevice->wCurrentRate = RATE_6M; - pDevice->byACKRate = RATE_6M; pDevice->byTopCCKBasicRate = RATE_1M; pDevice->byTopOFDMBasicRate = RATE_6M; } -- cgit v1.2.3 From 085f7c437f5304fdab43caee1814213358f4feb9 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 17 May 2014 09:50:36 +0100 Subject: staging: vt6656: vnt_private remove dead variables. dwAotoRateTxOkCnt dwAotoRateTxFailCnt dwErrorRateThreshold dwTPTable Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/device.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index 73bce9e80c33..f3072dd07784 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -538,10 +538,6 @@ struct vnt_private { u8 byTopOFDMBasicRate; u8 byTopCCKBasicRate; - u32 dwAotoRateTxOkCnt; - u32 dwAotoRateTxFailCnt; - u32 dwErrorRateThreshold[13]; - u32 dwTPTable[MAX_RATE]; u8 abyEEPROM[EEP_MAX_CONTEXT_SIZE]; /*u32 alignment */ u8 byMinChannel; -- cgit v1.2.3 From 0fc64c1579448cda6b94723a705020723957ce7b Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 17 May 2014 09:50:37 +0100 Subject: staging: vt6656: vnt_private remove dead variables byFOETuning byAutoPwrTunning Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/device.h | 6 ------ drivers/staging/vt6656/main_usb.c | 2 -- 2 files changed, 8 deletions(-) diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index f3072dd07784..a8637ec51c2f 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -672,12 +672,6 @@ struct vnt_private { int bRadioCmd; - /* For FOE Tuning */ - u8 byFOETuning; - - /* For Auto Power Tunning */ - u8 byAutoPwrTunning; - /* BaseBand Loopback Use */ u8 byBBCR4d; u8 byBBCRc9; diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index c00a16c610ea..a9d9cc89fc87 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -263,8 +263,6 @@ device_set_options(struct vnt_private *pDevice) { pDevice->byPacketType = pDevice->byBBType; pDevice->byAutoFBCtrl = AUTO_FB_0; pDevice->bUpdateBBVGA = true; - pDevice->byFOETuning = 0; - pDevice->byAutoPwrTunning = 0; pDevice->byPreambleType = 0; pDevice->bExistSWNetAddr = false; /* pDevice->bDiversityRegCtlON = true; */ -- cgit v1.2.3 From c729b0a4dea5b13fdfdc196299489a4cd08cfb16 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 17 May 2014 09:50:38 +0100 Subject: staging: vt6656: vnt_private remove dead variables. byBBCR4d byBBCRc9 byBBCR88 byBBCR09 Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/device.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index a8637ec51c2f..ee3fb0b6fb77 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -672,12 +672,6 @@ struct vnt_private { int bRadioCmd; - /* BaseBand Loopback Use */ - u8 byBBCR4d; - u8 byBBCRc9; - u8 byBBCR88; - u8 byBBCR09; - /* command timer */ struct delayed_work run_command_work; /* One second callback */ -- cgit v1.2.3 From 9cade5aceb9c78b96260f78249cadc579ab4118c Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 17 May 2014 09:50:39 +0100 Subject: staging: vt6656: Remove always true bUpdateBBVGA Remove true if statements. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/bssdb.c | 29 ++++++++++++----------------- drivers/staging/vt6656/device.h | 1 - drivers/staging/vt6656/main_usb.c | 9 +++------ drivers/staging/vt6656/wcmd.c | 17 +++++++---------- drivers/staging/vt6656/wmgr.c | 3 +-- 5 files changed, 23 insertions(+), 36 deletions(-) diff --git a/drivers/staging/vt6656/bssdb.c b/drivers/staging/vt6656/bssdb.c index 7e8e67a460ca..de60c99601d4 100644 --- a/drivers/staging/vt6656/bssdb.c +++ b/drivers/staging/vt6656/bssdb.c @@ -455,16 +455,14 @@ int BSSbInsertToBSSList(struct vnt_private *pDevice, } } - if (pDevice->bUpdateBBVGA) { - /* Monitor if RSSI is too strong. */ - pBSSList->byRSSIStatCnt = 0; - RFvRSSITodBm(pDevice, (u8) (pRxPacket->uRSSI), + /* Monitor if RSSI is too strong. */ + pBSSList->byRSSIStatCnt = 0; + RFvRSSITodBm(pDevice, (u8) (pRxPacket->uRSSI), &pBSSList->ldBmMAX); - pBSSList->ldBmAverage[0] = pBSSList->ldBmMAX; - pBSSList->ldBmAverRange = pBSSList->ldBmMAX; - for (ii = 1; ii < RSSI_STAT_COUNT; ii++) - pBSSList->ldBmAverage[ii] = 0; - } + pBSSList->ldBmAverage[0] = pBSSList->ldBmMAX; + pBSSList->ldBmAverRange = pBSSList->ldBmMAX; + for (ii = 1; ii < RSSI_STAT_COUNT; ii++) + pBSSList->ldBmAverage[ii] = 0; pBSSList->uIELength = uIELength; if (pBSSList->uIELength > WLAN_BEACON_FR_MAXLEN) @@ -998,10 +996,8 @@ void BSSvSecondCallBack(struct work_struct *work) if (pMgmt->sNodeDBTable[0].bActive) { /* Assoc with BSS */ - if (pDevice->bUpdateBBVGA) { - s_vCheckSensitivity(pDevice); - s_vCheckPreEDThreshold(pDevice); - } + s_vCheckSensitivity(pDevice); + s_vCheckPreEDThreshold(pDevice); if (pMgmt->sNodeDBTable[0].uInActiveCount >= (LOST_BEACON_COUNT/2) && @@ -1118,10 +1114,9 @@ void BSSvSecondCallBack(struct work_struct *work) } if (pMgmt->eCurrState == WMAC_STATE_JOINTED) { - if (pDevice->bUpdateBBVGA) { - s_vCheckSensitivity(pDevice); - s_vCheckPreEDThreshold(pDevice); - } + s_vCheckSensitivity(pDevice); + s_vCheckPreEDThreshold(pDevice); + if (pMgmt->sNodeDBTable[0].uInActiveCount >= ADHOC_LOST_BEACON_COUNT) { DBG_PRT(MSG_LEVEL_NOTICE, diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index ee3fb0b6fb77..606ca9fcd3d2 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -660,7 +660,6 @@ struct vnt_private { int bRxMICFail; /* For Update BaseBand VGA Gain Offset */ - int bUpdateBBVGA; u32 uBBVGADiffCount; u8 byBBVGANew; u8 byBBVGACurrent; diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index a9d9cc89fc87..3a576fa87dbc 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -262,7 +262,6 @@ device_set_options(struct vnt_private *pDevice) { pDevice->byBBType = BBP_TYPE_DEF; pDevice->byPacketType = pDevice->byBBType; pDevice->byAutoFBCtrl = AUTO_FB_0; - pDevice->bUpdateBBVGA = true; pDevice->byPreambleType = 0; pDevice->bExistSWNetAddr = false; /* pDevice->bDiversityRegCtlON = true; */ @@ -566,12 +565,10 @@ static int device_init_registers(struct vnt_private *pDevice) BBvSetShortSlotTime(pDevice); CARDvSetBSSMode(pDevice); - if (pDevice->bUpdateBBVGA) { - pDevice->byBBVGACurrent = pDevice->abyBBVGA[0]; - pDevice->byBBVGANew = pDevice->byBBVGACurrent; + pDevice->byBBVGACurrent = pDevice->abyBBVGA[0]; + pDevice->byBBVGANew = pDevice->byBBVGACurrent; - BBvSetVGAGainOffset(pDevice, pDevice->abyBBVGA[0]); - } + BBvSetVGAGainOffset(pDevice, pDevice->abyBBVGA[0]); pDevice->byRadioCtl = pDevice->abyEEPROM[EEP_OFS_RADIOCTL]; pDevice->bHWRadioOff = false; diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c index 8fecb34297af..b742460670d3 100644 --- a/drivers/staging/vt6656/wcmd.c +++ b/drivers/staging/vt6656/wcmd.c @@ -344,11 +344,10 @@ void vRunCommand(struct work_struct *work) CARDbSetMediaChannel(pDevice, pMgmt->uScanChannel); // Set Baseband to be more sensitive. - if (pDevice->bUpdateBBVGA) { - BBvSetShortSlotTime(pDevice); - BBvSetVGAGainOffset(pDevice, pDevice->abyBBVGA[0]); - BBvUpdatePreEDThreshold(pDevice, true); - } + BBvSetShortSlotTime(pDevice); + BBvSetVGAGainOffset(pDevice, pDevice->abyBBVGA[0]); + BBvUpdatePreEDThreshold(pDevice, true); + pMgmt->uScanChannel++; while (!ChannelValid(pDevice->byZoneType, pMgmt->uScanChannel) && @@ -381,11 +380,9 @@ void vRunCommand(struct work_struct *work) CARDvSetBSSMode(pDevice); } - if (pDevice->bUpdateBBVGA) { - BBvSetShortSlotTime(pDevice); - BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent); - BBvUpdatePreEDThreshold(pDevice, false); - } + BBvSetShortSlotTime(pDevice); + BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent); + BBvUpdatePreEDThreshold(pDevice, false); // Set channel back vAdHocBeaconRestart(pDevice); diff --git a/drivers/staging/vt6656/wmgr.c b/drivers/staging/vt6656/wmgr.c index d08f29086818..e6eec7fc2701 100644 --- a/drivers/staging/vt6656/wmgr.c +++ b/drivers/staging/vt6656/wmgr.c @@ -2653,8 +2653,7 @@ static void s_vMgrSynchBSS(struct vnt_private *pDevice, u32 uBSSMode, pMgmt->uCurrChannel = pCurr->uChannel; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "<----s_bSynchBSS Set Channel [%d]\n", pCurr->uChannel); - if ((pDevice->bUpdateBBVGA) && - (pDevice->byBBVGACurrent != pDevice->abyBBVGA[0])) { + if (pDevice->byBBVGACurrent != pDevice->abyBBVGA[0]) { pDevice->byBBVGACurrent = pDevice->abyBBVGA[0]; BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent); BBvSetShortSlotTime(pDevice); -- cgit v1.2.3 From bb7e5ed497f8fdf399d582f0fd4af4ef7d752d77 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Sun, 18 May 2014 12:55:12 +0200 Subject: staging: xgifb: Eliminate useless ifndefs XGI_VB_CHIP_TYPE, PCI_DEVICE_ID_XGI_42 and PCI_DEVICE_ID_XGI_27 are never defined. Signed-off-by: Lubomir Rintel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main.h | 4 ---- drivers/staging/xgifb/vgatypes.h | 2 -- 2 files changed, 6 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h index 95ce9708cec9..85079fea7152 100644 --- a/drivers/staging/xgifb/XGI_main.h +++ b/drivers/staging/xgifb/XGI_main.h @@ -4,12 +4,8 @@ #include "XGIfb.h" #include "vb_def.h" -#ifndef PCI_DEVICE_ID_XGI_42 #define PCI_DEVICE_ID_XGI_42 0x042 -#endif -#ifndef PCI_DEVICE_ID_XGI_27 #define PCI_DEVICE_ID_XGI_27 0x027 -#endif static const struct pci_device_id xgifb_pci_table[] = { {PCI_DEVICE(PCI_VENDOR_ID_XGI, PCI_DEVICE_ID_XGI_20)}, diff --git a/drivers/staging/xgifb/vgatypes.h b/drivers/staging/xgifb/vgatypes.h index 264351441f99..61fa10fd470f 100644 --- a/drivers/staging/xgifb/vgatypes.h +++ b/drivers/staging/xgifb/vgatypes.h @@ -5,7 +5,6 @@ #include "../../video/fbdev/sis/vgatypes.h" #include "../../video/fbdev/sis/sis.h" /* for LCD_TYPE */ -#ifndef XGI_VB_CHIP_TYPE enum XGI_VB_CHIP_TYPE { VB_CHIP_Legacy = 0, VB_CHIP_301, @@ -19,7 +18,6 @@ enum XGI_VB_CHIP_TYPE { VB_CHIP_UNKNOWN, /* other video bridge or no video bridge */ MAX_VB_CHIP }; -#endif struct xgi_hw_device_info { unsigned long ulExternalChip; /* NO VB or other video bridge*/ -- cgit v1.2.3 From a5c79d610f08484238729c07778398dd72c8c7e6 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Sun, 18 May 2014 12:55:14 +0200 Subject: staging: xgifb: Initialize Part0Port It was left uninitialized, likely overseen, in this commit: 56810a92c689c6 ("staging: xgifb: use XGIRegInit() Avoid copy-paste and use XGIRegInit() to initialize registers addresses.") Signed-off-by: Lubomir Rintel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index a62d4dd4ce82..f82f0574bbdc 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -218,6 +218,7 @@ void XGIRegInit(struct vb_device_info *XGI_Pr, unsigned long BaseAddr) XGI_Pr->P3c8 = BaseAddr + 0x18; XGI_Pr->P3c9 = BaseAddr + 0x19; XGI_Pr->P3da = BaseAddr + 0x2A; + XGI_Pr->Part0Port = BaseAddr + XGI_CRT2_PORT_00; /* Digital video interface registers (LCD) */ XGI_Pr->Part1Port = BaseAddr + SIS_CRT2_PORT_04; /* 301 TV Encoder registers */ -- cgit v1.2.3 From 51c4491457e996200db64fda51fe456c124b738a Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Sun, 18 May 2014 12:55:15 +0200 Subject: staging: xgifb: Drop some more useless defines SetLCDStdMode is not supported as of 34c13ee2b690 ("staging: xgifb: drop code for legacy VGA modes"). DisableLCD24bpp defined to zero was never realy useful and went away with aa56b2790a8b ("staging: xgifb: vb_table: delete XGI21_LCDCapList"). Signed-off-by: Lubomir Rintel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_def.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/xgifb/vb_def.h b/drivers/staging/xgifb/vb_def.h index 949f0e5eed8d..481eb174fdf0 100644 --- a/drivers/staging/xgifb/vb_def.h +++ b/drivers/staging/xgifb/vb_def.h @@ -44,12 +44,10 @@ #define SetLCDtoNonExpanding 0x0010 #define SetLCDDualLink 0x0100 #define SetLCDLowResolution 0x0200 -#define SetLCDStdMode 0x0400 /* LCD Capability shampoo */ #define DefaultLCDCap 0x80ea #define EnableLCD24bpp 0x0004 /* default */ -#define DisableLCD24bpp 0x0000 #define LCDPolarity 0x00c0 /* default: SyncNN */ #define XGI_LCDDualLink 0x0100 #define EnableSpectrum 0x0200 -- cgit v1.2.3 From 5a0ba45727a457e7a5db232a4742dd43795021cf Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Sun, 18 May 2014 12:55:16 +0200 Subject: staging: xgifb: Update TODO There's no more printk abuse, it's been sorted out in 448810662ac3 ("Staging: xgifb: Remove printk usage.") Extra ifdefs have been fixed too, mostly in 800d67cf9f77 ("staging: xgifb: eliminate #ifdef Tap4"), c39aada6926c ("staging: xgifb: eliminate #ifdef XGIFB_PAN"), fa4c212f2b81 ("staging: xgifb: delete unused definitions"), 5c167b30c1b4 ("staging: xgifb: eliminate #ifdef NewScratch"), f059077388b0 ("Staging: xgifb: Remove #ifdef MODULE") and more. Signed-off-by: Lubomir Rintel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/TODO | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/xgifb/TODO b/drivers/staging/xgifb/TODO index 392b29d8f134..7eb99140a399 100644 --- a/drivers/staging/xgifb/TODO +++ b/drivers/staging/xgifb/TODO @@ -6,8 +6,7 @@ Arnaud TODO: - clean ups - sort out dup ids with SiS driver -- remove useless/wrong/unused #ifdef/code/... -- fix printk usages +- remove useless/wrong/unused code... - get rid of non-linux related stuff Please send patches to: -- cgit v1.2.3 From 2000c581d8372b6dfad397cdf8a68fe3832c8755 Mon Sep 17 00:00:00 2001 From: Masaru Nomura Date: Sun, 18 May 2014 00:54:29 +0100 Subject: staging: dgnc: Put else statements on the right line Fix indenting of if-else statement in dgnc_neo.c and dgnc_tty.c so that following else-if or else statement meets coding style. Signed-off-by: Masaru Nomura Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_neo.c | 48 ++++++++++++++--------------------------- drivers/staging/dgnc/dgnc_tty.c | 36 +++++++++++-------------------- 2 files changed, 28 insertions(+), 56 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c index cf22c7b725f9..e87cf49be175 100644 --- a/drivers/staging/dgnc/dgnc_neo.c +++ b/drivers/staging/dgnc/dgnc_neo.c @@ -485,8 +485,7 @@ static inline void neo_parse_isr(struct dgnc_board *brd, uint port) DGNC_UNLOCK(ch->ch_lock, lock_flags); } DPR_INTR(("Port %d. XON detected in incoming data\n", port)); - } - else if (cause == UART_17158_XOFF_DETECT) { + } else if (cause == UART_17158_XOFF_DETECT) { if (!(brd->channels[port]->ch_flags & CH_STOP)) { DGNC_LOCK(ch->ch_lock, lock_flags); ch->ch_flags |= CH_STOP; @@ -511,8 +510,7 @@ static inline void neo_parse_isr(struct dgnc_board *brd, uint port) DGNC_LOCK(ch->ch_lock, lock_flags); ch->ch_mostat |= UART_MCR_RTS; DGNC_UNLOCK(ch->ch_lock, lock_flags); - } - else { + } else { DGNC_LOCK(ch->ch_lock, lock_flags); ch->ch_mostat &= ~(UART_MCR_RTS); DGNC_UNLOCK(ch->ch_lock, lock_flags); @@ -522,8 +520,7 @@ static inline void neo_parse_isr(struct dgnc_board *brd, uint port) DGNC_LOCK(ch->ch_lock, lock_flags); ch->ch_mostat |= UART_MCR_DTR; DGNC_UNLOCK(ch->ch_lock, lock_flags); - } - else { + } else { DGNC_LOCK(ch->ch_lock, lock_flags); ch->ch_mostat &= ~(UART_MCR_DTR); DGNC_UNLOCK(ch->ch_lock, lock_flags); @@ -624,8 +621,7 @@ static inline void neo_parse_lsr(struct dgnc_board *brd, uint port) /* Transfer data (if any) from Write Queue -> UART. */ neo_copy_data_from_queue_to_uart(ch); - } - else if (linestatus & UART_17158_TX_AND_FIFO_CLR) { + } else if (linestatus & UART_17158_TX_AND_FIFO_CLR) { brd->intr_tx++; ch->ch_intr_tx++; DGNC_LOCK(ch->ch_lock, lock_flags); @@ -834,8 +830,7 @@ static void neo_param(struct tty_struct *tty) if (ch->ch_c_cflag & CREAD) { ier |= (UART_IER_RDI | UART_IER_RLSI); - } - else { + } else { ier &= ~(UART_IER_RDI | UART_IER_RLSI); } @@ -848,8 +843,7 @@ static void neo_param(struct tty_struct *tty) !(ch->ch_c_cflag & CLOCAL)) { ier |= UART_IER_MSI; - } - else { + } else { ier &= ~UART_IER_MSI; } @@ -863,29 +857,25 @@ static void neo_param(struct tty_struct *tty) if (ch->ch_digi.digi_flags & CTSPACE || ch->ch_c_cflag & CRTSCTS) { neo_set_cts_flow_control(ch); - } - else if (ch->ch_c_iflag & IXON) { + } else if (ch->ch_c_iflag & IXON) { /* If start/stop is set to disable, then we should disable flow control */ if ((ch->ch_startc == _POSIX_VDISABLE) || (ch->ch_stopc == _POSIX_VDISABLE)) neo_set_no_output_flow_control(ch); else neo_set_ixon_flow_control(ch); - } - else { + } else { neo_set_no_output_flow_control(ch); } if (ch->ch_digi.digi_flags & RTSPACE || ch->ch_c_cflag & CRTSCTS) { neo_set_rts_flow_control(ch); - } - else if (ch->ch_c_iflag & IXOFF) { + } else if (ch->ch_c_iflag & IXOFF) { /* If start/stop is set to disable, then we should disable flow control */ if ((ch->ch_startc == _POSIX_VDISABLE) || (ch->ch_stopc == _POSIX_VDISABLE)) neo_set_no_input_flow_control(ch); else neo_set_ixoff_flow_control(ch); - } - else { + } else { neo_set_no_input_flow_control(ch); } @@ -1227,8 +1217,7 @@ static void neo_copy_data_from_uart_to_queue(struct channel_t *ch) */ if ((ch->ch_bd->dvid & 0xf0) >= UART_XR17E158_DVID) { total -= 1; - } - else { + } else { total -= 3; } } @@ -1435,8 +1424,7 @@ static int neo_drain(struct tty_struct *tty, uint seconds) /* If ret is non-zero, user ctrl-c'ed us */ if (rc) { DPR_IOCTL(("%d Drain - User ctrl c'ed\n", __LINE__)); - } - else { + } else { DPR_IOCTL(("%d Drain wait finished.\n", __LINE__)); } @@ -1468,8 +1456,7 @@ static void neo_flush_uart_write(struct channel_t *ch) if (tmp & 4) { DPR_IOCTL(("Still flushing TX UART... i: %d\n", i)); udelay(10); - } - else + } else break; } @@ -1501,8 +1488,7 @@ static void neo_flush_uart_read(struct channel_t *ch) if (tmp & 2) { DPR_IOCTL(("Still flushing RX UART... i: %d\n", i)); udelay(10); - } - else + } else break; } } @@ -1598,8 +1584,7 @@ static void neo_copy_data_from_queue_to_uart(struct channel_t *ch) } n = UART_17158_TX_FIFOSIZE - ch->ch_t_tlevel; - } - else { + } else { n = UART_17158_TX_FIFOSIZE - readb(&ch->ch_neo_uart->tfifo); } @@ -1963,8 +1948,7 @@ static void neo_vpd(struct dgnc_board *brd) || (brd->vpd[0x7F] != 0x78)) /* small resource end tag */ { memset(brd->vpd, '\0', NEO_VPD_IMAGESIZE); - } - else { + } else { /* Search for the serial number */ for (i = 0; i < NEO_VPD_IMAGEBYTES - 3; i++) { if (brd->vpd[i] == 'S' && brd->vpd[i + 1] == 'N') { diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index f0b17c36edd8..e432c04f9943 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -803,8 +803,7 @@ void dgnc_input(struct channel_t *ch) else tty_insert_flip_char(tp->port, *(ch->ch_rqueue + tail + i), TTY_NORMAL); } - } - else { + } else { tty_insert_flip_string(tp->port, ch->ch_rqueue + tail, s); } @@ -1267,12 +1266,10 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) if (!IS_PRINT(minor)) { un = &brd->channels[PORT_NUM(minor)]->ch_tun; un->un_type = DGNC_SERIAL; - } - else if (IS_PRINT(minor)) { + } else if (IS_PRINT(minor)) { un = &brd->channels[PORT_NUM(minor)]->ch_pun; un->un_type = DGNC_PRINT; - } - else { + } else { DGNC_UNLOCK(ch->ch_lock, lock_flags); DPR_OPEN(("%d Unknown TYPE!\n", __LINE__)); return -ENXIO; @@ -1507,8 +1504,7 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc DPR_OPEN(("%d: ch_flags: %x\n", __LINE__, ch->ch_flags)); break; } - } - else { + } else { sleep_on_un_flags = 1; } @@ -1550,8 +1546,7 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc if (sleep_on_un_flags) { retval = wait_event_interruptible(un->un_flags_wait, (old_flags != (ch->ch_tun.un_flags | ch->ch_pun.un_flags))); - } - else { + } else { retval = wait_event_interruptible(ch->ch_flags_wait, (old_flags != ch->ch_flags)); } @@ -1748,8 +1743,7 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) /* Turn off UART interrupts for this port */ ch->ch_bd->bd_ops->uart_off(ch); - } - else { + } else { /* * turn off print device when closing print device. */ @@ -1867,12 +1861,10 @@ static int dgnc_maxcps_room(struct tty_struct *tty, int bytes_available) /* buffer is empty */ ch->ch_cpstime = current_time; /* reset ch_cpstime */ cps_limit = ch->ch_digi.digi_bufsize; - } - else if (ch->ch_cpstime < buffer_time) { + } else if (ch->ch_cpstime < buffer_time) { /* still room in the buffer */ cps_limit = ((buffer_time - ch->ch_cpstime) * ch->ch_digi.digi_maxcps) / HZ; - } - else { + } else { /* no room in the buffer */ cps_limit = 0; } @@ -1931,8 +1923,7 @@ static int dgnc_tty_write_room(struct tty_struct *tty) if (!(ch->ch_flags & CH_PRON)) ret -= ch->ch_digi.digi_onlen; ret -= ch->ch_digi.digi_offlen; - } - else { + } else { if (ch->ch_flags & CH_PRON) ret -= ch->ch_digi.digi_offlen; } @@ -2560,15 +2551,13 @@ static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, uns if (arg & TIOCM_RTS) { ch->ch_mostat |= UART_MCR_RTS; - } - else { + } else { ch->ch_mostat &= ~(UART_MCR_RTS); } if (arg & TIOCM_DTR) { ch->ch_mostat |= UART_MCR_DTR; - } - else { + } else { ch->ch_mostat &= ~(UART_MCR_DTR); } @@ -3279,8 +3268,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, return -EINTR; } DGNC_LOCK(ch->ch_lock, lock_flags); - } - else { + } else { tty_ldisc_flush(tty); } /* fall thru */ -- cgit v1.2.3 From 33cfbaf5d065bb166893a1adb20bdfc70b909516 Mon Sep 17 00:00:00 2001 From: Masaru Nomura Date: Sun, 18 May 2014 00:54:30 +0100 Subject: staging: dgnc: dgnc_neo: Clean up if statement Fix line over 80 characters and indenting of condition part. Also, remove unnecessary braces to meet coding style. Signed-off-by: Masaru Nomura Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_neo.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c index e87cf49be175..10b60167c784 100644 --- a/drivers/staging/dgnc/dgnc_neo.c +++ b/drivers/staging/dgnc/dgnc_neo.c @@ -838,14 +838,14 @@ static void neo_param(struct tty_struct *tty) * Have the UART interrupt on modem signal changes ONLY when * we are in hardware flow control mode, or CLOCAL/FORCEDCD is not set. */ - if ((ch->ch_digi.digi_flags & CTSPACE) || (ch->ch_digi.digi_flags & RTSPACE) || - (ch->ch_c_cflag & CRTSCTS) || !(ch->ch_digi.digi_flags & DIGI_FORCEDCD) || - !(ch->ch_c_cflag & CLOCAL)) - { + if ((ch->ch_digi.digi_flags & CTSPACE) || + (ch->ch_digi.digi_flags & RTSPACE) || + (ch->ch_c_cflag & CRTSCTS) || + !(ch->ch_digi.digi_flags & DIGI_FORCEDCD) || + !(ch->ch_c_cflag & CLOCAL)) ier |= UART_IER_MSI; - } else { + else ier &= ~UART_IER_MSI; - } ier |= UART_IER_THRI; -- cgit v1.2.3 From 50667c67dbefea289460dc3e2b4ebc307fd88000 Mon Sep 17 00:00:00 2001 From: Masaru Nomura Date: Sun, 18 May 2014 00:54:31 +0100 Subject: staging: dgnc: Remove extra curly braces Remove unnecessary curly braces of if statements in dgnc_neo.c and dgnc_tty.c to meet kernel coding style. Signed-off-by: Masaru Nomura Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_neo.c | 60 ++++++++-------------- drivers/staging/dgnc/dgnc_tty.c | 110 +++++++++++++++------------------------- 2 files changed, 61 insertions(+), 109 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c index 10b60167c784..2d472e643b01 100644 --- a/drivers/staging/dgnc/dgnc_neo.c +++ b/drivers/staging/dgnc/dgnc_neo.c @@ -434,9 +434,8 @@ static inline void neo_parse_isr(struct dgnc_board *brd, uint port) isr = readb(&ch->ch_neo_uart->isr_fcr); /* Bail if no pending interrupt */ - if (isr & UART_IIR_NO_INT) { + if (isr & UART_IIR_NO_INT) break; - } /* * Yank off the upper 2 bits, which just show that the FIFO's are enabled. @@ -650,24 +649,20 @@ static void neo_param(struct tty_struct *tty) struct channel_t *ch; struct un_t *un; - if (!tty || tty->magic != TTY_MAGIC) { + if (!tty || tty->magic != TTY_MAGIC) return; - } un = (struct un_t *) tty->driver_data; - if (!un || un->magic != DGNC_UNIT_MAGIC) { + if (!un || un->magic != DGNC_UNIT_MAGIC) return; - } ch = un->un_ch; - if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) { + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) return; - } bd = ch->ch_bd; - if (!bd || bd->magic != DGNC_BOARD_MAGIC) { + if (!bd || bd->magic != DGNC_BOARD_MAGIC) return; - } DPR_PARAM(("param start: tdev: %x cflags: %x oflags: %x iflags: %x\n", ch->ch_tun.un_dev, ch->ch_c_cflag, ch->ch_c_oflag, ch->ch_c_iflag)); @@ -773,13 +768,11 @@ static void neo_param(struct tty_struct *tty) } } - if (ch->ch_c_cflag & PARENB) { + if (ch->ch_c_cflag & PARENB) lcr |= UART_LCR_PARITY; - } - if (!(ch->ch_c_cflag & PARODD)) { + if (!(ch->ch_c_cflag & PARODD)) lcr |= UART_LCR_EPAR; - } /* * Not all platforms support mark/space parity, @@ -828,11 +821,10 @@ static void neo_param(struct tty_struct *tty) if (uart_lcr != lcr) writeb(lcr, &ch->ch_neo_uart->lcr); - if (ch->ch_c_cflag & CREAD) { + if (ch->ch_c_cflag & CREAD) ier |= (UART_IER_RDI | UART_IER_RLSI); - } else { + else ier &= ~(UART_IER_RDI | UART_IER_RLSI); - } /* * Have the UART interrupt on modem signal changes ONLY when @@ -1215,11 +1207,10 @@ static void neo_copy_data_from_uart_to_queue(struct channel_t *ch) * The count can be any where from 0-3 bytes "off". * Bizarre, but true. */ - if ((ch->ch_bd->dvid & 0xf0) >= UART_XR17E158_DVID) { + if ((ch->ch_bd->dvid & 0xf0) >= UART_XR17E158_DVID) total -= 1; - } else { + else total -= 3; - } } @@ -1263,9 +1254,8 @@ static void neo_copy_data_from_uart_to_queue(struct channel_t *ch) * will reset some bits after our read, we need to ensure * we don't miss our TX FIFO emptys. */ - if (linestatus & (UART_LSR_THRE | UART_17158_TX_AND_FIFO_CLR)) { + if (linestatus & (UART_LSR_THRE | UART_17158_TX_AND_FIFO_CLR)) ch->ch_flags |= (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM); - } linestatus = 0; @@ -1393,19 +1383,16 @@ static int neo_drain(struct tty_struct *tty, uint seconds) struct un_t *un; int rc = 0; - if (!tty || tty->magic != TTY_MAGIC) { + if (!tty || tty->magic != TTY_MAGIC) return -ENXIO; - } un = (struct un_t *) tty->driver_data; - if (!un || un->magic != DGNC_UNIT_MAGIC) { + if (!un || un->magic != DGNC_UNIT_MAGIC) return -ENXIO; - } ch = un->un_ch; - if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) { + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) return -ENXIO; - } DPR_IOCTL(("%d Drain wait started.\n", __LINE__)); @@ -1422,11 +1409,10 @@ static int neo_drain(struct tty_struct *tty, uint seconds) rc = wait_event_interruptible(un->un_flags_wait, ((un->un_flags & UN_EMPTY) == 0)); /* If ret is non-zero, user ctrl-c'ed us */ - if (rc) { + if (rc) DPR_IOCTL(("%d Drain - User ctrl c'ed\n", __LINE__)); - } else { + else DPR_IOCTL(("%d Drain wait finished.\n", __LINE__)); - } return rc; } @@ -1442,9 +1428,8 @@ static void neo_flush_uart_write(struct channel_t *ch) uchar tmp = 0; int i = 0; - if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) { + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) return; - } writeb((UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_XMIT), &ch->ch_neo_uart->isr_fcr); neo_pci_posting_flush(ch->ch_bd); @@ -1474,9 +1459,8 @@ static void neo_flush_uart_read(struct channel_t *ch) uchar tmp = 0; int i = 0; - if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) { + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) return; - } writeb((UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR), &ch->ch_neo_uart->isr_fcr); neo_pci_posting_flush(ch->ch_bd); @@ -1950,10 +1934,8 @@ static void neo_vpd(struct dgnc_board *brd) memset(brd->vpd, '\0', NEO_VPD_IMAGESIZE); } else { /* Search for the serial number */ - for (i = 0; i < NEO_VPD_IMAGEBYTES - 3; i++) { - if (brd->vpd[i] == 'S' && brd->vpd[i + 1] == 'N') { + for (i = 0; i < NEO_VPD_IMAGEBYTES - 3; i++) + if (brd->vpd[i] == 'S' && brd->vpd[i + 1] == 'N') strncpy(brd->serial_num, &(brd->vpd[i + 3]), 9); - } - } } } diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index e432c04f9943..e3001b52146c 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -533,9 +533,8 @@ void dgnc_sniff_nowait_nolock(struct channel_t *ch, uchar *text, uchar *buf, int * We *cannot* sleep here waiting for space, because this * function was probably called by the interrupt/timer routines! */ - if (n == 0) { + if (n == 0) return; - } /* * Copy as much data as will fit. @@ -856,14 +855,11 @@ void dgnc_carrier(struct channel_t *ch) phys_carrier = 1; } - if (ch->ch_digi.digi_flags & DIGI_FORCEDCD) { + if (ch->ch_digi.digi_flags & DIGI_FORCEDCD) virt_carrier = 1; - } - if (ch->ch_c_cflag & CLOCAL) { + if (ch->ch_c_cflag & CLOCAL) virt_carrier = 1; - } - DPR_CARR(("DCD: physical: %d virt: %d\n", phys_carrier, virt_carrier)); @@ -1004,11 +1000,10 @@ static void dgnc_set_custom_speed(struct channel_t *ch, uint newrate) deltahigh = testrate_high - newrate; deltalow = newrate - testrate_low; - if (deltahigh < deltalow) { + if (deltahigh < deltalow) newrate = testrate_high; - } else { + else newrate = testrate_low; - } } } @@ -1221,15 +1216,13 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) major = MAJOR(tty_devnum(tty)); minor = MINOR(tty_devnum(tty)); - if (major > 255) { + if (major > 255) return -ENXIO; - } /* Get board pointer from our array of majors we have allocated */ brd = dgnc_BoardsByMajor[major]; - if (!brd) { + if (!brd) return -ENXIO; - } /* * If board is not yet up to a state of READY, go to @@ -1238,9 +1231,8 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) rc = wait_event_interruptible(brd->state_wait, (brd->state & BOARD_READY)); - if (rc) { + if (rc) return rc; - } DGNC_LOCK(brd->bd_lock, lock_flags); @@ -1406,10 +1398,9 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) rc = dgnc_block_til_ready(tty, file, ch); - if (rc) { + if (rc) DPR_OPEN(("dgnc_tty_open returning after dgnc_block_til_ready " "with %d\n", rc)); - } /* No going back now, increment our unit and channel counters */ DGNC_LOCK(ch->ch_lock, lock_flags); @@ -1441,9 +1432,8 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc } un = tty->driver_data; - if (!un || un->magic != DGNC_UNIT_MAGIC) { + if (!un || un->magic != DGNC_UNIT_MAGIC) return -ENXIO; - } DPR_OPEN(("dgnc_block_til_ready - before block.\n")); @@ -1486,9 +1476,8 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc * 3) DCD (fake or real) is active. */ - if (file->f_flags & O_NONBLOCK) { + if (file->f_flags & O_NONBLOCK) break; - } if (tty->flags & (1 << TTY_IO_ERROR)) { retval = -EIO; @@ -1543,13 +1532,12 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc /* * Wait for something in the flags to change from the current value. */ - if (sleep_on_un_flags) { + if (sleep_on_un_flags) retval = wait_event_interruptible(un->un_flags_wait, (old_flags != (ch->ch_tun.un_flags | ch->ch_pun.un_flags))); - } else { + else retval = wait_event_interruptible(ch->ch_flags_wait, (old_flags != ch->ch_flags)); - } DPR_OPEN(("After sleep... retval: %x\n", retval)); @@ -1703,9 +1691,8 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) DPR_CLOSE(("After calling wait_for_drain\n")); - if (rc) { + if (rc) DPR_BASIC(("dgnc_tty_close - bad return: %d ", rc)); - } dgnc_tty_flush_buffer(tty); tty_ldisc_flush(tty); @@ -2077,9 +2064,8 @@ static int dgnc_tty_write(struct tty_struct *tty, * the board. */ /* we're allowed to block if it's from_user */ - if (down_interruptible(&dgnc_TmpWriteSem)) { + if (down_interruptible(&dgnc_TmpWriteSem)) return -EINTR; - } /* * copy_from_user() returns the number @@ -2262,21 +2248,17 @@ static int dgnc_tty_tiocmset(struct tty_struct *tty, DGNC_LOCK(ch->ch_lock, lock_flags); - if (set & TIOCM_RTS) { + if (set & TIOCM_RTS) ch->ch_mostat |= UART_MCR_RTS; - } - if (set & TIOCM_DTR) { + if (set & TIOCM_DTR) ch->ch_mostat |= UART_MCR_DTR; - } - if (clear & TIOCM_RTS) { + if (clear & TIOCM_RTS) ch->ch_mostat &= ~(UART_MCR_RTS); - } - if (clear & TIOCM_DTR) { + if (clear & TIOCM_DTR) ch->ch_mostat &= ~(UART_MCR_DTR); - } ch->ch_bd->bd_ops->assert_modem_signals(ch); @@ -2526,40 +2508,34 @@ static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, uns switch (command) { case TIOCMBIS: - if (arg & TIOCM_RTS) { + if (arg & TIOCM_RTS) ch->ch_mostat |= UART_MCR_RTS; - } - if (arg & TIOCM_DTR) { + if (arg & TIOCM_DTR) ch->ch_mostat |= UART_MCR_DTR; - } break; case TIOCMBIC: - if (arg & TIOCM_RTS) { + if (arg & TIOCM_RTS) ch->ch_mostat &= ~(UART_MCR_RTS); - } - if (arg & TIOCM_DTR) { + if (arg & TIOCM_DTR) ch->ch_mostat &= ~(UART_MCR_DTR); - } break; case TIOCMSET: - if (arg & TIOCM_RTS) { + if (arg & TIOCM_RTS) ch->ch_mostat |= UART_MCR_RTS; - } else { + else ch->ch_mostat &= ~(UART_MCR_RTS); - } - if (arg & TIOCM_DTR) { + if (arg & TIOCM_DTR) ch->ch_mostat |= UART_MCR_DTR; - } else { + else ch->ch_mostat &= ~(UART_MCR_DTR); - } break; @@ -3037,9 +3013,8 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, */ rc = tty_check_change(tty); DGNC_UNLOCK(ch->ch_lock, lock_flags); - if (rc) { + if (rc) return rc; - } rc = ch->ch_bd->bd_ops->drain(tty, 0); @@ -3070,9 +3045,8 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, */ rc = tty_check_change(tty); DGNC_UNLOCK(ch->ch_lock, lock_flags); - if (rc) { + if (rc) return rc; - } rc = ch->ch_bd->bd_ops->drain(tty, 0); if (rc) { @@ -3094,9 +3068,8 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, case TIOCSBRK: rc = tty_check_change(tty); DGNC_UNLOCK(ch->ch_lock, lock_flags); - if (rc) { + if (rc) return rc; - } rc = ch->ch_bd->bd_ops->drain(tty, 0); if (rc) { @@ -3358,9 +3331,9 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, DGNC_UNLOCK(ch->ch_lock, lock_flags); - if (copy_to_user(uarg, &buf, sizeof(buf))) { + if (copy_to_user(uarg, &buf, sizeof(buf))) return -EFAULT; - } + return 0; } @@ -3377,9 +3350,9 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, /* NOTE: MORE EVENTS NEEDS TO BE ADDED HERE */ if (ch->ch_flags & CH_BREAK_SENDING) events |= EV_TXB; - if ((ch->ch_flags & CH_STOP) || (ch->ch_flags & CH_FORCED_STOP)) { + if ((ch->ch_flags & CH_STOP) || (ch->ch_flags & CH_FORCED_STOP)) events |= (EV_OPU | EV_OPS); - } + if ((ch->ch_flags & CH_STOPI) || (ch->ch_flags & CH_FORCED_STOPI)) { events |= (EV_IPU | EV_IPS); } @@ -3406,9 +3379,8 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, /* * Get data from user first. */ - if (copy_from_user(&buf, uarg, sizeof(buf))) { + if (copy_from_user(&buf, uarg, sizeof(buf))) return -EFAULT; - } DGNC_LOCK(ch->ch_lock, lock_flags); @@ -3437,24 +3409,22 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, * insert more characters into our queue for OPOST processing * that the RealPort Server doesn't know about. */ - if (buf.txbuf > tdist) { + if (buf.txbuf > tdist) buf.txbuf = tdist; - } /* * Report whether our queue and UART TX are completely empty. */ - if (count) { + if (count) buf.txdone = 0; - } else { + else buf.txdone = 1; - } DGNC_UNLOCK(ch->ch_lock, lock_flags); - if (copy_to_user(uarg, &buf, sizeof(buf))) { + if (copy_to_user(uarg, &buf, sizeof(buf))) return -EFAULT; - } + return 0; } default: -- cgit v1.2.3 From 6559e221a187f657b710eb7c8f56bc0870ec1186 Mon Sep 17 00:00:00 2001 From: Jason Cooper Date: Fri, 25 Apr 2014 16:45:09 +0000 Subject: staging: crypto: skein: depend upon CRYPTO Fengguang's randconfig kernel build tester discovered the following warnings: warning: (CRYPTO_THREEFISH) selects CRYPTO_ALGAPI which has unmet direct dependencies (CRYPTO) warning: (DM_VERITY && CRYPTO_SKEIN) selects CRYPTO_HASH which has unmet direct dependencies (CRYPTO) Fix this in the Kconfig by depending on CRYPTO. Reported-by: Fengguang Wu Signed-off-by: Jason Cooper Reviewed-by: Marek Vasut Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig index 8f5a72a90ced..b9172bfcdc1b 100644 --- a/drivers/staging/skein/Kconfig +++ b/drivers/staging/skein/Kconfig @@ -1,6 +1,6 @@ config CRYPTO_SKEIN bool "Skein digest algorithm" - depends on (X86 || UML_X86) && 64BIT + depends on (X86 || UML_X86) && 64BIT && CRYPTO select CRYPTO_THREEFISH select CRYPTO_HASH help @@ -17,7 +17,7 @@ config CRYPTO_SKEIN config CRYPTO_THREEFISH bool "Threefish tweakable block cipher" - depends on (X86 || UML_X86) && 64BIT + depends on (X86 || UML_X86) && 64BIT && CRYPTO select CRYPTO_ALGAPI help Threefish cipher algorithm is the tweakable block cipher underneath -- cgit v1.2.3 From 68ace624a6cd39880638311cda21efe8d507d613 Mon Sep 17 00:00:00 2001 From: Anton Saraev Date: Mon, 19 May 2014 12:09:54 +0400 Subject: staging: crypto: skein: rename camelcase functions camelCase is not accepted in the Linux Kernel. To prepare skein driver for mainline inclusion, we rename all functions to non-camelCase equivalents. Signed-off-by: Anton Saraev Reviewed-by: Jake Edge Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/TODO | 1 - drivers/staging/skein/include/skein.h | 66 ++++++++-------- drivers/staging/skein/include/skeinApi.h | 38 ++++----- drivers/staging/skein/include/skein_block.h | 12 +-- drivers/staging/skein/include/threefishApi.h | 44 ++++++----- drivers/staging/skein/skein.c | 114 +++++++++++++-------------- drivers/staging/skein/skeinApi.c | 72 ++++++++--------- drivers/staging/skein/skeinBlockNo3F.c | 24 +++--- drivers/staging/skein/skein_block.c | 40 +++++----- drivers/staging/skein/threefish1024Block.c | 6 +- drivers/staging/skein/threefish256Block.c | 6 +- drivers/staging/skein/threefish512Block.c | 6 +- drivers/staging/skein/threefishApi.c | 38 ++++----- 13 files changed, 239 insertions(+), 228 deletions(-) diff --git a/drivers/staging/skein/TODO b/drivers/staging/skein/TODO index f5c167a305ae..bc42fb8c1a0b 100644 --- a/drivers/staging/skein/TODO +++ b/drivers/staging/skein/TODO @@ -1,7 +1,6 @@ skein/threefish TODO - rename camelcase vars - - rename camelcase functions - rename files - move macros into appropriate header files - add / pass test vectors diff --git a/drivers/staging/skein/include/skein.h b/drivers/staging/skein/include/skein.h index 0a2abcecd2f7..15ff60f63d07 100644 --- a/drivers/staging/skein/include/skein.h +++ b/drivers/staging/skein/include/skein.h @@ -86,59 +86,59 @@ struct skein1024_ctx { /* 1024-bit Skein hash context structure */ u8 b[SKEIN1024_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ }; -/* Skein APIs for (incremental) "straight hashing" */ -int Skein_256_Init(struct skein_256_ctx *ctx, size_t hashBitLen); -int Skein_512_Init(struct skein_512_ctx *ctx, size_t hashBitLen); -int Skein1024_Init(struct skein1024_ctx *ctx, size_t hashBitLen); - -int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg, - size_t msgByteCnt); -int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg, - size_t msgByteCnt); -int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg, - size_t msgByteCnt); - -int Skein_256_Final(struct skein_256_ctx *ctx, u8 *hashVal); -int Skein_512_Final(struct skein_512_ctx *ctx, u8 *hashVal); -int Skein1024_Final(struct skein1024_ctx *ctx, u8 *hashVal); +/* Skein APIs for (incremental) "straight hashing" */ +int skein_256_init(struct skein_256_ctx *ctx, size_t hashBitLen); +int skein_512_init(struct skein_512_ctx *ctx, size_t hashBitLen); +int skein_1024_init(struct skein1024_ctx *ctx, size_t hashBitLen); + +int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg, + size_t msgByteCnt); +int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg, + size_t msgByteCnt); +int skein_1024_update(struct skein1024_ctx *ctx, const u8 *msg, + size_t msgByteCnt); + +int skein_256_final(struct skein_256_ctx *ctx, u8 *hashVal); +int skein_512_final(struct skein_512_ctx *ctx, u8 *hashVal); +int skein_1024_final(struct skein1024_ctx *ctx, u8 *hashVal); /* ** Skein APIs for "extended" initialization: MAC keys, tree hashing. -** After an InitExt() call, just use Update/Final calls as with Init(). +** After an init_ext() call, just use update/final calls as with init(). ** -** Notes: Same parameters as _Init() calls, plus treeInfo/key/keyBytes. +** Notes: Same parameters as _init() calls, plus treeInfo/key/keyBytes. ** When keyBytes == 0 and treeInfo == SKEIN_SEQUENTIAL, -** the results of InitExt() are identical to calling Init(). -** The function Init() may be called once to "precompute" the IV for +** the results of init_ext() are identical to calling init(). +** The function init() may be called once to "precompute" the IV for ** a given hashBitLen value, then by saving a copy of the context ** the IV computation may be avoided in later calls. -** Similarly, the function InitExt() may be called once per MAC key +** Similarly, the function init_ext() may be called once per MAC key ** to precompute the MAC IV, then a copy of the context saved and ** reused for each new MAC computation. **/ -int Skein_256_InitExt(struct skein_256_ctx *ctx, size_t hashBitLen, - u64 treeInfo, const u8 *key, size_t keyBytes); -int Skein_512_InitExt(struct skein_512_ctx *ctx, size_t hashBitLen, - u64 treeInfo, const u8 *key, size_t keyBytes); -int Skein1024_InitExt(struct skein1024_ctx *ctx, size_t hashBitLen, +int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hashBitLen, + u64 treeInfo, const u8 *key, size_t keyBytes); +int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hashBitLen, + u64 treeInfo, const u8 *key, size_t keyBytes); +int skein_1024_init_ext(struct skein1024_ctx *ctx, size_t hashBitLen, u64 treeInfo, const u8 *key, size_t keyBytes); /* ** Skein APIs for MAC and tree hash: -** Final_Pad: pad, do final block, but no OUTPUT type -** Output: do just the output stage +** final_pad: pad, do final block, but no OUTPUT type +** output: do just the output stage */ -int Skein_256_Final_Pad(struct skein_256_ctx *ctx, u8 *hashVal); -int Skein_512_Final_Pad(struct skein_512_ctx *ctx, u8 *hashVal); -int Skein1024_Final_Pad(struct skein1024_ctx *ctx, u8 *hashVal); +int skein_256_final_pad(struct skein_256_ctx *ctx, u8 *hashVal); +int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hashVal); +int skein_1024_final_pad(struct skein1024_ctx *ctx, u8 *hashVal); #ifndef SKEIN_TREE_HASH #define SKEIN_TREE_HASH (1) #endif #if SKEIN_TREE_HASH -int Skein_256_Output(struct skein_256_ctx *ctx, u8 *hashVal); -int Skein_512_Output(struct skein_512_ctx *ctx, u8 *hashVal); -int Skein1024_Output(struct skein1024_ctx *ctx, u8 *hashVal); +int skein_256_output(struct skein_256_ctx *ctx, u8 *hashVal); +int skein_512_output(struct skein_512_ctx *ctx, u8 *hashVal); +int skein_1024_output(struct skein1024_ctx *ctx, u8 *hashVal); #endif /***************************************************************** diff --git a/drivers/staging/skein/include/skeinApi.h b/drivers/staging/skein/include/skeinApi.h index ace931a67c23..ea54546bf030 100644 --- a/drivers/staging/skein/include/skeinApi.h +++ b/drivers/staging/skein/include/skeinApi.h @@ -50,31 +50,31 @@ OTHER DEALINGS IN THE SOFTWARE. * struct skein_ctx ctx; // a Skein hash or MAC context * * // prepare context, here for a Skein with a state size of 512 bits. - * skeinCtxPrepare(&ctx, Skein512); + * skein_ctx_prepare(&ctx, Skein512); * * // Initialize the context to set the requested hash length in bits * // here request a output hash size of 31 bits (Skein supports variable * // output sizes even very strange sizes) - * skeinInit(&ctx, 31); + * skein_init(&ctx, 31); * * // Now update Skein with any number of message bits. A function that * // takes a number of bytes is also available. - * skeinUpdateBits(&ctx, message, msgLength); + * skein_update_bits(&ctx, message, msgLength); * * // Now get the result of the Skein hash. The output buffer must be * // large enough to hold the request number of output bits. The application * // may now extract the bits. - * skeinFinal(&ctx, result); + * skein_final(&ctx, result); * ... * @endcode * - * An application may use @c skeinReset to reset a Skein context and use + * An application may use @c skein_reset to reset a Skein context and use * it for creation of another hash with the same Skein state size and output * bit length. In this case the API implementation restores some internal * internal state data and saves a full Skein initialization round. * - * To create a MAC the application just uses @c skeinMacInit instead of - * @c skeinInit. All other functions calls remain the same. + * To create a MAC the application just uses @c skein_mac_init instead of + * @c skein_init. All other functions calls remain the same. * */ @@ -123,7 +123,7 @@ struct skein_ctx { * @return * SKEIN_SUCESS of SKEIN_FAIL */ -int skeinCtxPrepare(struct skein_ctx *ctx, enum skein_size size); +int skein_ctx_prepare(struct skein_ctx *ctx, enum skein_size size); /** * Initialize a Skein context. @@ -137,9 +137,9 @@ int skeinCtxPrepare(struct skein_ctx *ctx, enum skein_size size); * Number of MAC hash bits to compute * @return * SKEIN_SUCESS of SKEIN_FAIL - * @see skeinReset + * @see skein_reset */ -int skeinInit(struct skein_ctx *ctx, size_t hashBitLen); +int skein_init(struct skein_ctx *ctx, size_t hashBitLen); /** * Resets a Skein context for further use. @@ -151,7 +151,7 @@ int skeinInit(struct skein_ctx *ctx, size_t hashBitLen); * @param ctx * Pointer to a pre-initialized Skein MAC context */ -void skeinReset(struct skein_ctx *ctx); +void skein_reset(struct skein_ctx *ctx); /** * Initializes a Skein context for MAC usage. @@ -173,8 +173,8 @@ void skeinReset(struct skein_ctx *ctx); * @return * SKEIN_SUCESS of SKEIN_FAIL */ -int skeinMacInit(struct skein_ctx *ctx, const u8 *key, size_t keyLen, - size_t hashBitLen); +int skein_mac_init(struct skein_ctx *ctx, const u8 *key, size_t keyLen, + size_t hashBitLen); /** * Update Skein with the next part of the message. @@ -188,8 +188,8 @@ int skeinMacInit(struct skein_ctx *ctx, const u8 *key, size_t keyLen, * @return * Success or error code. */ -int skeinUpdate(struct skein_ctx *ctx, const u8 *msg, - size_t msgByteCnt); +int skein_update(struct skein_ctx *ctx, const u8 *msg, + size_t msgByteCnt); /** * Update the hash with a message bit string. @@ -204,8 +204,8 @@ int skeinUpdate(struct skein_ctx *ctx, const u8 *msg, * @param msgBitCnt * Length of the message in @b bits. */ -int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg, - size_t msgBitCnt); +int skein_update_bits(struct skein_ctx *ctx, const u8 *msg, + size_t msgBitCnt); /** * Finalize Skein and return the hash. @@ -220,9 +220,9 @@ int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg, * enough to store @c hashBitLen bits. * @return * Success or error code. - * @see skeinReset + * @see skein_reset */ -int skeinFinal(struct skein_ctx *ctx, u8 *hash); +int skein_final(struct skein_ctx *ctx, u8 *hash); /** * @} diff --git a/drivers/staging/skein/include/skein_block.h b/drivers/staging/skein/include/skein_block.h index b15c079b5bd4..41cae89ff4cc 100644 --- a/drivers/staging/skein/include/skein_block.h +++ b/drivers/staging/skein/include/skein_block.h @@ -12,11 +12,11 @@ #include /* get the Skein API definitions */ -void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, - size_t blkCnt, size_t byteCntAdd); -void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, - size_t blkCnt, size_t byteCntAdd); -void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, - size_t blkCnt, size_t byteCntAdd); +void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blkPtr, + size_t blkCnt, size_t byteCntAdd); +void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blkPtr, + size_t blkCnt, size_t byteCntAdd); +void skein_1024_process_block(struct skein1024_ctx *ctx, const u8 *blkPtr, + size_t blkCnt, size_t byteCntAdd); #endif diff --git a/drivers/staging/skein/include/threefishApi.h b/drivers/staging/skein/include/threefishApi.h index e81675d7eac9..6cdad46f19c8 100644 --- a/drivers/staging/skein/include/threefishApi.h +++ b/drivers/staging/skein/include/threefishApi.h @@ -21,10 +21,10 @@ struct threefish_key keyCtx; // Initialize the context - threefishSetKey(&keyCtx, Threefish512, key, tweak); + threefish_set_key(&keyCtx, Threefish512, key, tweak); // Encrypt - threefishEncryptBlockBytes(&keyCtx, input, cipher); + threefish_encrypt_block_bytes(&keyCtx, input, cipher); @endcode */ @@ -72,9 +72,9 @@ struct threefish_key { * @param tweak * Pointer to the two tweak words (word has 64 bits). */ -void threefishSetKey(struct threefish_key *keyCtx, - enum threefish_size stateSize, - u64 *keyData, u64 *tweak); +void threefish_set_key(struct threefish_key *keyCtx, + enum threefish_size stateSize, + u64 *keyData, u64 *tweak); /** * Encrypt Threefisch block (bytes). @@ -91,7 +91,8 @@ void threefishSetKey(struct threefish_key *keyCtx, * @param out * Pointer to cipher buffer. */ -void threefishEncryptBlockBytes(struct threefish_key *keyCtx, u8 *in, u8 *out); +void threefish_encrypt_block_bytes(struct threefish_key *keyCtx, u8 *in, + u8 *out); /** * Encrypt Threefisch block (words). @@ -110,8 +111,8 @@ void threefishEncryptBlockBytes(struct threefish_key *keyCtx, u8 *in, u8 *out); * @param out * Pointer to cipher buffer. */ -void threefishEncryptBlockWords(struct threefish_key *keyCtx, u64 *in, - u64 *out); +void threefish_encrypt_block_words(struct threefish_key *keyCtx, u64 *in, + u64 *out); /** * Decrypt Threefisch block (bytes). @@ -128,7 +129,8 @@ void threefishEncryptBlockWords(struct threefish_key *keyCtx, u64 *in, * @param out * Pointer to plaintext buffer. */ -void threefishDecryptBlockBytes(struct threefish_key *keyCtx, u8 *in, u8 *out); +void threefish_decrypt_block_bytes(struct threefish_key *keyCtx, u8 *in, + u8 *out); /** * Decrypt Threefisch block (words). @@ -147,17 +149,21 @@ void threefishDecryptBlockBytes(struct threefish_key *keyCtx, u8 *in, u8 *out); * @param out * Pointer to plaintext buffer. */ -void threefishDecryptBlockWords(struct threefish_key *keyCtx, u64 *in, - u64 *out); +void threefish_decrypt_block_words(struct threefish_key *keyCtx, u64 *in, + u64 *out); -void threefishEncrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output); -void threefishEncrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output); -void threefishEncrypt1024(struct threefish_key *keyCtx, u64 *input, - u64 *output); -void threefishDecrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output); -void threefishDecrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output); -void threefishDecrypt1024(struct threefish_key *keyCtx, u64 *input, - u64 *output); +void threefish_encrypt_256(struct threefish_key *keyCtx, u64 *input, + u64 *output); +void threefish_encrypt_512(struct threefish_key *keyCtx, u64 *input, + u64 *output); +void threefish_encrypt_1024(struct threefish_key *keyCtx, u64 *input, + u64 *output); +void threefish_decrypt_256(struct threefish_key *keyCtx, u64 *input, + u64 *output); +void threefish_decrypt_512(struct threefish_key *keyCtx, u64 *input, + u64 *output); +void threefish_decrypt_1024(struct threefish_key *keyCtx, u64 *input, + u64 *output); /** * @} */ diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c index 096b86bf9430..ac64d9f096f0 100644 --- a/drivers/staging/skein/skein.c +++ b/drivers/staging/skein/skein.c @@ -21,7 +21,7 @@ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a straight hashing operation */ -int Skein_256_Init(struct skein_256_ctx *ctx, size_t hashBitLen) +int skein_256_init(struct skein_256_ctx *ctx, size_t hashBitLen) { union { u8 b[SKEIN_256_STATE_BYTES]; @@ -64,7 +64,7 @@ int Skein_256_Init(struct skein_256_ctx *ctx, size_t hashBitLen) /* compute the initial chaining values from config block */ /* zero the chaining variables */ memset(ctx->X, 0, sizeof(ctx->X)); - Skein_256_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); + skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); break; } /* The chaining vars ctx->X are now initialized for hashBitLen. */ @@ -76,9 +76,9 @@ int Skein_256_Init(struct skein_256_ctx *ctx, size_t hashBitLen) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a MAC and/or tree hash operation */ -/* [identical to Skein_256_Init() when keyBytes == 0 && \ +/* [identical to skein_256_init() when keyBytes == 0 && \ * treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ -int Skein_256_InitExt(struct skein_256_ctx *ctx, size_t hashBitLen, +int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hashBitLen, u64 treeInfo, const u8 *key, size_t keyBytes) { union { @@ -103,9 +103,9 @@ int Skein_256_InitExt(struct skein_256_ctx *ctx, size_t hashBitLen, /* zero the initial chaining variables */ memset(ctx->X, 0, sizeof(ctx->X)); /* hash the key */ - Skein_256_Update(ctx, key, keyBytes); + skein_256_update(ctx, key, keyBytes); /* put result into cfg.b[] */ - Skein_256_Final_Pad(ctx, cfg.b); + skein_256_final_pad(ctx, cfg.b); /* copy over into ctx->X[] */ memcpy(ctx->X, cfg.b, sizeof(cfg.b)); } @@ -128,7 +128,7 @@ int Skein_256_InitExt(struct skein_256_ctx *ctx, size_t hashBitLen, Skein_Show_Key(256, &ctx->h, key, keyBytes); /* compute the initial chaining values from config block */ - Skein_256_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); + skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); /* The chaining vars ctx->X are now initialized */ /* Set up to process the data message portion of the hash (default) */ @@ -139,8 +139,8 @@ int Skein_256_InitExt(struct skein_256_ctx *ctx, size_t hashBitLen, /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* process the input bytes */ -int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg, - size_t msgByteCnt) +int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg, + size_t msgByteCnt) { size_t n; @@ -162,7 +162,7 @@ int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg, ctx->h.bCnt += n; } Skein_assert(ctx->h.bCnt == SKEIN_256_BLOCK_BYTES); - Skein_256_Process_Block(ctx, ctx->b, 1, + skein_256_process_block(ctx, ctx->b, 1, SKEIN_256_BLOCK_BYTES); ctx->h.bCnt = 0; } @@ -173,7 +173,7 @@ int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg, if (msgByteCnt > SKEIN_256_BLOCK_BYTES) { /* number of full blocks to process */ n = (msgByteCnt-1) / SKEIN_256_BLOCK_BYTES; - Skein_256_Process_Block(ctx, msg, n, + skein_256_process_block(ctx, msg, n, SKEIN_256_BLOCK_BYTES); msgByteCnt -= n * SKEIN_256_BLOCK_BYTES; msg += n * SKEIN_256_BLOCK_BYTES; @@ -193,7 +193,7 @@ int Skein_256_Update(struct skein_256_ctx *ctx, const u8 *msg, /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the result */ -int Skein_256_Final(struct skein_256_ctx *ctx, u8 *hashVal) +int skein_256_final(struct skein_256_ctx *ctx, u8 *hashVal) { size_t i, n, byteCnt; u64 X[SKEIN_256_STATE_WORDS]; @@ -208,7 +208,7 @@ int Skein_256_Final(struct skein_256_ctx *ctx, u8 *hashVal) SKEIN_256_BLOCK_BYTES - ctx->h.bCnt); /* process the final block */ - Skein_256_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); + skein_256_process_block(ctx, ctx->b, 1, ctx->h.bCnt); /* now output the result */ /* total number of output bytes */ @@ -224,7 +224,7 @@ int Skein_256_Final(struct skein_256_ctx *ctx, u8 *hashVal) ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); Skein_Start_New_Type(ctx, OUT_FINAL); /* run "counter mode" */ - Skein_256_Process_Block(ctx, ctx->b, 1, sizeof(u64)); + skein_256_process_block(ctx, ctx->b, 1, sizeof(u64)); /* number of output bytes left to go */ n = byteCnt - i*SKEIN_256_BLOCK_BYTES; if (n >= SKEIN_256_BLOCK_BYTES) @@ -246,7 +246,7 @@ int Skein_256_Final(struct skein_256_ctx *ctx, u8 *hashVal) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a straight hashing operation */ -int Skein_512_Init(struct skein_512_ctx *ctx, size_t hashBitLen) +int skein_512_init(struct skein_512_ctx *ctx, size_t hashBitLen) { union { u8 b[SKEIN_512_STATE_BYTES]; @@ -289,7 +289,7 @@ int Skein_512_Init(struct skein_512_ctx *ctx, size_t hashBitLen) /* compute the initial chaining values from config block */ /* zero the chaining variables */ memset(ctx->X, 0, sizeof(ctx->X)); - Skein_512_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); + skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); break; } @@ -305,10 +305,10 @@ int Skein_512_Init(struct skein_512_ctx *ctx, size_t hashBitLen) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a MAC and/or tree hash operation */ -/* [identical to Skein_512_Init() when keyBytes == 0 && \ +/* [identical to skein_512_init() when keyBytes == 0 && \ * treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ -int Skein_512_InitExt(struct skein_512_ctx *ctx, size_t hashBitLen, - u64 treeInfo, const u8 *key, size_t keyBytes) +int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hashBitLen, + u64 treeInfo, const u8 *key, size_t keyBytes) { union { u8 b[SKEIN_512_STATE_BYTES]; @@ -332,9 +332,9 @@ int Skein_512_InitExt(struct skein_512_ctx *ctx, size_t hashBitLen, /* zero the initial chaining variables */ memset(ctx->X, 0, sizeof(ctx->X)); /* hash the key */ - Skein_512_Update(ctx, key, keyBytes); + skein_512_update(ctx, key, keyBytes); /* put result into cfg.b[] */ - Skein_512_Final_Pad(ctx, cfg.b); + skein_512_final_pad(ctx, cfg.b); /* copy over into ctx->X[] */ memcpy(ctx->X, cfg.b, sizeof(cfg.b)); } @@ -356,7 +356,7 @@ int Skein_512_InitExt(struct skein_512_ctx *ctx, size_t hashBitLen, Skein_Show_Key(512, &ctx->h, key, keyBytes); /* compute the initial chaining values from config block */ - Skein_512_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); + skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); /* The chaining vars ctx->X are now initialized */ /* Set up to process the data message portion of the hash (default) */ @@ -367,8 +367,8 @@ int Skein_512_InitExt(struct skein_512_ctx *ctx, size_t hashBitLen, /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* process the input bytes */ -int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg, - size_t msgByteCnt) +int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg, + size_t msgByteCnt) { size_t n; @@ -390,7 +390,7 @@ int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg, ctx->h.bCnt += n; } Skein_assert(ctx->h.bCnt == SKEIN_512_BLOCK_BYTES); - Skein_512_Process_Block(ctx, ctx->b, 1, + skein_512_process_block(ctx, ctx->b, 1, SKEIN_512_BLOCK_BYTES); ctx->h.bCnt = 0; } @@ -401,7 +401,7 @@ int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg, if (msgByteCnt > SKEIN_512_BLOCK_BYTES) { /* number of full blocks to process */ n = (msgByteCnt-1) / SKEIN_512_BLOCK_BYTES; - Skein_512_Process_Block(ctx, msg, n, + skein_512_process_block(ctx, msg, n, SKEIN_512_BLOCK_BYTES); msgByteCnt -= n * SKEIN_512_BLOCK_BYTES; msg += n * SKEIN_512_BLOCK_BYTES; @@ -421,7 +421,7 @@ int Skein_512_Update(struct skein_512_ctx *ctx, const u8 *msg, /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the result */ -int Skein_512_Final(struct skein_512_ctx *ctx, u8 *hashVal) +int skein_512_final(struct skein_512_ctx *ctx, u8 *hashVal) { size_t i, n, byteCnt; u64 X[SKEIN_512_STATE_WORDS]; @@ -436,7 +436,7 @@ int Skein_512_Final(struct skein_512_ctx *ctx, u8 *hashVal) SKEIN_512_BLOCK_BYTES - ctx->h.bCnt); /* process the final block */ - Skein_512_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); + skein_512_process_block(ctx, ctx->b, 1, ctx->h.bCnt); /* now output the result */ /* total number of output bytes */ @@ -452,7 +452,7 @@ int Skein_512_Final(struct skein_512_ctx *ctx, u8 *hashVal) ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); Skein_Start_New_Type(ctx, OUT_FINAL); /* run "counter mode" */ - Skein_512_Process_Block(ctx, ctx->b, 1, sizeof(u64)); + skein_512_process_block(ctx, ctx->b, 1, sizeof(u64)); /* number of output bytes left to go */ n = byteCnt - i*SKEIN_512_BLOCK_BYTES; if (n >= SKEIN_512_BLOCK_BYTES) @@ -474,7 +474,7 @@ int Skein_512_Final(struct skein_512_ctx *ctx, u8 *hashVal) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a straight hashing operation */ -int Skein1024_Init(struct skein1024_ctx *ctx, size_t hashBitLen) +int skein_1024_init(struct skein1024_ctx *ctx, size_t hashBitLen) { union { u8 b[SKEIN1024_STATE_BYTES]; @@ -514,7 +514,7 @@ int Skein1024_Init(struct skein1024_ctx *ctx, size_t hashBitLen) /* compute the initial chaining values from config block */ /* zero the chaining variables */ memset(ctx->X, 0, sizeof(ctx->X)); - Skein1024_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); + skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); break; } @@ -527,9 +527,9 @@ int Skein1024_Init(struct skein1024_ctx *ctx, size_t hashBitLen) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a MAC and/or tree hash operation */ -/* [identical to Skein1024_Init() when keyBytes == 0 && \ +/* [identical to skein_1024_init() when keyBytes == 0 && \ * treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ -int Skein1024_InitExt(struct skein1024_ctx *ctx, size_t hashBitLen, +int skein_1024_init_ext(struct skein1024_ctx *ctx, size_t hashBitLen, u64 treeInfo, const u8 *key, size_t keyBytes) { union { @@ -554,9 +554,9 @@ int Skein1024_InitExt(struct skein1024_ctx *ctx, size_t hashBitLen, /* zero the initial chaining variables */ memset(ctx->X, 0, sizeof(ctx->X)); /* hash the key */ - Skein1024_Update(ctx, key, keyBytes); + skein_1024_update(ctx, key, keyBytes); /* put result into cfg.b[] */ - Skein1024_Final_Pad(ctx, cfg.b); + skein_1024_final_pad(ctx, cfg.b); /* copy over into ctx->X[] */ memcpy(ctx->X, cfg.b, sizeof(cfg.b)); } @@ -579,7 +579,7 @@ int Skein1024_InitExt(struct skein1024_ctx *ctx, size_t hashBitLen, Skein_Show_Key(1024, &ctx->h, key, keyBytes); /* compute the initial chaining values from config block */ - Skein1024_Process_Block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); + skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); /* The chaining vars ctx->X are now initialized */ /* Set up to process the data message portion of the hash (default) */ @@ -590,8 +590,8 @@ int Skein1024_InitExt(struct skein1024_ctx *ctx, size_t hashBitLen, /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* process the input bytes */ -int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg, - size_t msgByteCnt) +int skein_1024_update(struct skein1024_ctx *ctx, const u8 *msg, + size_t msgByteCnt) { size_t n; @@ -613,8 +613,8 @@ int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg, ctx->h.bCnt += n; } Skein_assert(ctx->h.bCnt == SKEIN1024_BLOCK_BYTES); - Skein1024_Process_Block(ctx, ctx->b, 1, - SKEIN1024_BLOCK_BYTES); + skein_1024_process_block(ctx, ctx->b, 1, + SKEIN1024_BLOCK_BYTES); ctx->h.bCnt = 0; } /* @@ -624,8 +624,8 @@ int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg, if (msgByteCnt > SKEIN1024_BLOCK_BYTES) { /* number of full blocks to process */ n = (msgByteCnt-1) / SKEIN1024_BLOCK_BYTES; - Skein1024_Process_Block(ctx, msg, n, - SKEIN1024_BLOCK_BYTES); + skein_1024_process_block(ctx, msg, n, + SKEIN1024_BLOCK_BYTES); msgByteCnt -= n * SKEIN1024_BLOCK_BYTES; msg += n * SKEIN1024_BLOCK_BYTES; } @@ -644,7 +644,7 @@ int Skein1024_Update(struct skein1024_ctx *ctx, const u8 *msg, /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the result */ -int Skein1024_Final(struct skein1024_ctx *ctx, u8 *hashVal) +int skein_1024_final(struct skein1024_ctx *ctx, u8 *hashVal) { size_t i, n, byteCnt; u64 X[SKEIN1024_STATE_WORDS]; @@ -659,7 +659,7 @@ int Skein1024_Final(struct skein1024_ctx *ctx, u8 *hashVal) SKEIN1024_BLOCK_BYTES - ctx->h.bCnt); /* process the final block */ - Skein1024_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); + skein_1024_process_block(ctx, ctx->b, 1, ctx->h.bCnt); /* now output the result */ /* total number of output bytes */ @@ -675,7 +675,7 @@ int Skein1024_Final(struct skein1024_ctx *ctx, u8 *hashVal) ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); Skein_Start_New_Type(ctx, OUT_FINAL); /* run "counter mode" */ - Skein1024_Process_Block(ctx, ctx->b, 1, sizeof(u64)); + skein_1024_process_block(ctx, ctx->b, 1, sizeof(u64)); /* number of output bytes left to go */ n = byteCnt - i*SKEIN1024_BLOCK_BYTES; if (n >= SKEIN1024_BLOCK_BYTES) @@ -696,7 +696,7 @@ int Skein1024_Final(struct skein1024_ctx *ctx, u8 *hashVal) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the block, no OUTPUT stage */ -int Skein_256_Final_Pad(struct skein_256_ctx *ctx, u8 *hashVal) +int skein_256_final_pad(struct skein_256_ctx *ctx, u8 *hashVal) { /* catch uninitialized context */ Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); @@ -708,7 +708,7 @@ int Skein_256_Final_Pad(struct skein_256_ctx *ctx, u8 *hashVal) memset(&ctx->b[ctx->h.bCnt], 0, SKEIN_256_BLOCK_BYTES - ctx->h.bCnt); /* process the final block */ - Skein_256_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); + skein_256_process_block(ctx, ctx->b, 1, ctx->h.bCnt); /* "output" the state bytes */ Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN_256_BLOCK_BYTES); @@ -718,7 +718,7 @@ int Skein_256_Final_Pad(struct skein_256_ctx *ctx, u8 *hashVal) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the block, no OUTPUT stage */ -int Skein_512_Final_Pad(struct skein_512_ctx *ctx, u8 *hashVal) +int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hashVal) { /* catch uninitialized context */ Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); @@ -730,7 +730,7 @@ int Skein_512_Final_Pad(struct skein_512_ctx *ctx, u8 *hashVal) memset(&ctx->b[ctx->h.bCnt], 0, SKEIN_512_BLOCK_BYTES - ctx->h.bCnt); /* process the final block */ - Skein_512_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); + skein_512_process_block(ctx, ctx->b, 1, ctx->h.bCnt); /* "output" the state bytes */ Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN_512_BLOCK_BYTES); @@ -740,7 +740,7 @@ int Skein_512_Final_Pad(struct skein_512_ctx *ctx, u8 *hashVal) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the block, no OUTPUT stage */ -int Skein1024_Final_Pad(struct skein1024_ctx *ctx, u8 *hashVal) +int skein_1024_final_pad(struct skein1024_ctx *ctx, u8 *hashVal) { /* catch uninitialized context */ Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); @@ -752,7 +752,7 @@ int Skein1024_Final_Pad(struct skein1024_ctx *ctx, u8 *hashVal) memset(&ctx->b[ctx->h.bCnt], 0, SKEIN1024_BLOCK_BYTES - ctx->h.bCnt); /* process the final block */ - Skein1024_Process_Block(ctx, ctx->b, 1, ctx->h.bCnt); + skein_1024_process_block(ctx, ctx->b, 1, ctx->h.bCnt); /* "output" the state bytes */ Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN1024_BLOCK_BYTES); @@ -763,7 +763,7 @@ int Skein1024_Final_Pad(struct skein1024_ctx *ctx, u8 *hashVal) #if SKEIN_TREE_HASH /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* just do the OUTPUT stage */ -int Skein_256_Output(struct skein_256_ctx *ctx, u8 *hashVal) +int skein_256_output(struct skein_256_ctx *ctx, u8 *hashVal) { size_t i, n, byteCnt; u64 X[SKEIN_256_STATE_WORDS]; @@ -784,7 +784,7 @@ int Skein_256_Output(struct skein_256_ctx *ctx, u8 *hashVal) ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); Skein_Start_New_Type(ctx, OUT_FINAL); /* run "counter mode" */ - Skein_256_Process_Block(ctx, ctx->b, 1, sizeof(u64)); + skein_256_process_block(ctx, ctx->b, 1, sizeof(u64)); /* number of output bytes left to go */ n = byteCnt - i*SKEIN_256_BLOCK_BYTES; if (n >= SKEIN_256_BLOCK_BYTES) @@ -802,7 +802,7 @@ int Skein_256_Output(struct skein_256_ctx *ctx, u8 *hashVal) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* just do the OUTPUT stage */ -int Skein_512_Output(struct skein_512_ctx *ctx, u8 *hashVal) +int skein_512_output(struct skein_512_ctx *ctx, u8 *hashVal) { size_t i, n, byteCnt; u64 X[SKEIN_512_STATE_WORDS]; @@ -823,7 +823,7 @@ int Skein_512_Output(struct skein_512_ctx *ctx, u8 *hashVal) ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); Skein_Start_New_Type(ctx, OUT_FINAL); /* run "counter mode" */ - Skein_512_Process_Block(ctx, ctx->b, 1, sizeof(u64)); + skein_512_process_block(ctx, ctx->b, 1, sizeof(u64)); /* number of output bytes left to go */ n = byteCnt - i*SKEIN_512_BLOCK_BYTES; if (n >= SKEIN_512_BLOCK_BYTES) @@ -841,7 +841,7 @@ int Skein_512_Output(struct skein_512_ctx *ctx, u8 *hashVal) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* just do the OUTPUT stage */ -int Skein1024_Output(struct skein1024_ctx *ctx, u8 *hashVal) +int skein_1024_output(struct skein1024_ctx *ctx, u8 *hashVal) { size_t i, n, byteCnt; u64 X[SKEIN1024_STATE_WORDS]; @@ -862,7 +862,7 @@ int Skein1024_Output(struct skein1024_ctx *ctx, u8 *hashVal) ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); Skein_Start_New_Type(ctx, OUT_FINAL); /* run "counter mode" */ - Skein1024_Process_Block(ctx, ctx->b, 1, sizeof(u64)); + skein_1024_process_block(ctx, ctx->b, 1, sizeof(u64)); /* number of output bytes left to go */ n = byteCnt - i*SKEIN1024_BLOCK_BYTES; if (n >= SKEIN1024_BLOCK_BYTES) diff --git a/drivers/staging/skein/skeinApi.c b/drivers/staging/skein/skeinApi.c index dd109bf6f7b9..c4f5333e1cce 100644 --- a/drivers/staging/skein/skeinApi.c +++ b/drivers/staging/skein/skeinApi.c @@ -27,7 +27,7 @@ OTHER DEALINGS IN THE SOFTWARE. #include #include -int skeinCtxPrepare(struct skein_ctx *ctx, enum skein_size size) +int skein_ctx_prepare(struct skein_ctx *ctx, enum skein_size size) { Skein_Assert(ctx && size, SKEIN_FAIL); @@ -37,7 +37,7 @@ int skeinCtxPrepare(struct skein_ctx *ctx, enum skein_size size) return SKEIN_SUCCESS; } -int skeinInit(struct skein_ctx *ctx, size_t hashBitLen) +int skein_init(struct skein_ctx *ctx, size_t hashBitLen) { int ret = SKEIN_FAIL; size_t Xlen = 0; @@ -58,16 +58,16 @@ int skeinInit(struct skein_ctx *ctx, size_t hashBitLen) */ switch (ctx->skeinSize) { case Skein256: - ret = Skein_256_InitExt(&ctx->m.s256, hashBitLen, - treeInfo, NULL, 0); + ret = skein_256_init_ext(&ctx->m.s256, hashBitLen, + treeInfo, NULL, 0); break; case Skein512: - ret = Skein_512_InitExt(&ctx->m.s512, hashBitLen, - treeInfo, NULL, 0); + ret = skein_512_init_ext(&ctx->m.s512, hashBitLen, + treeInfo, NULL, 0); break; case Skein1024: - ret = Skein1024_InitExt(&ctx->m.s1024, hashBitLen, - treeInfo, NULL, 0); + ret = skein_1024_init_ext(&ctx->m.s1024, hashBitLen, + treeInfo, NULL, 0); break; } @@ -81,8 +81,8 @@ int skeinInit(struct skein_ctx *ctx, size_t hashBitLen) return ret; } -int skeinMacInit(struct skein_ctx *ctx, const u8 *key, size_t keyLen, - size_t hashBitLen) +int skein_mac_init(struct skein_ctx *ctx, const u8 *key, size_t keyLen, + size_t hashBitLen) { int ret = SKEIN_FAIL; u64 *X = NULL; @@ -98,20 +98,20 @@ int skeinMacInit(struct skein_ctx *ctx, const u8 *key, size_t keyLen, switch (ctx->skeinSize) { case Skein256: - ret = Skein_256_InitExt(&ctx->m.s256, hashBitLen, - treeInfo, - (const u8 *)key, keyLen); + ret = skein_256_init_ext(&ctx->m.s256, hashBitLen, + treeInfo, + (const u8 *)key, keyLen); break; case Skein512: - ret = Skein_512_InitExt(&ctx->m.s512, hashBitLen, - treeInfo, - (const u8 *)key, keyLen); + ret = skein_512_init_ext(&ctx->m.s512, hashBitLen, + treeInfo, + (const u8 *)key, keyLen); break; case Skein1024: - ret = Skein1024_InitExt(&ctx->m.s1024, hashBitLen, - treeInfo, - (const u8 *)key, keyLen); + ret = skein_1024_init_ext(&ctx->m.s1024, hashBitLen, + treeInfo, + (const u8 *)key, keyLen); break; } @@ -125,7 +125,7 @@ int skeinMacInit(struct skein_ctx *ctx, const u8 *key, size_t keyLen, return ret; } -void skeinReset(struct skein_ctx *ctx) +void skein_reset(struct skein_ctx *ctx) { size_t Xlen = 0; u64 *X = NULL; @@ -144,23 +144,23 @@ void skeinReset(struct skein_ctx *ctx) Skein_Start_New_Type(&ctx->m, MSG); } -int skeinUpdate(struct skein_ctx *ctx, const u8 *msg, - size_t msgByteCnt) +int skein_update(struct skein_ctx *ctx, const u8 *msg, + size_t msgByteCnt) { int ret = SKEIN_FAIL; Skein_Assert(ctx, SKEIN_FAIL); switch (ctx->skeinSize) { case Skein256: - ret = Skein_256_Update(&ctx->m.s256, (const u8 *)msg, - msgByteCnt); + ret = skein_256_update(&ctx->m.s256, (const u8 *)msg, + msgByteCnt); break; case Skein512: - ret = Skein_512_Update(&ctx->m.s512, (const u8 *)msg, - msgByteCnt); + ret = skein_512_update(&ctx->m.s512, (const u8 *)msg, + msgByteCnt); break; case Skein1024: - ret = Skein1024_Update(&ctx->m.s1024, (const u8 *)msg, + ret = skein_1024_update(&ctx->m.s1024, (const u8 *)msg, msgByteCnt); break; } @@ -168,8 +168,8 @@ int skeinUpdate(struct skein_ctx *ctx, const u8 *msg, } -int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg, - size_t msgBitCnt) +int skein_update_bits(struct skein_ctx *ctx, const u8 *msg, + size_t msgBitCnt) { /* * I've used the bit pad implementation from skein_test.c (see NIST CD) @@ -189,9 +189,9 @@ int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg, /* if number of bits is a multiple of bytes - that's easy */ if ((msgBitCnt & 0x7) == 0) - return skeinUpdate(ctx, msg, msgBitCnt >> 3); + return skein_update(ctx, msg, msgBitCnt >> 3); - skeinUpdate(ctx, msg, (msgBitCnt >> 3) + 1); + skein_update(ctx, msg, (msgBitCnt >> 3) + 1); /* * The next line rely on the fact that the real Skein contexts @@ -201,7 +201,7 @@ int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg, */ up = (u8 *)ctx->m.s256.X + ctx->skeinSize / 8; - /* set tweak flag for the skeinFinal call */ + /* set tweak flag for the skein_final call */ Skein_Set_Bit_Pad_Flag(ctx->m.h); /* now "pad" the final partial byte the way NIST likes */ @@ -217,20 +217,20 @@ int skeinUpdateBits(struct skein_ctx *ctx, const u8 *msg, return SKEIN_SUCCESS; } -int skeinFinal(struct skein_ctx *ctx, u8 *hash) +int skein_final(struct skein_ctx *ctx, u8 *hash) { int ret = SKEIN_FAIL; Skein_Assert(ctx, SKEIN_FAIL); switch (ctx->skeinSize) { case Skein256: - ret = Skein_256_Final(&ctx->m.s256, (u8 *)hash); + ret = skein_256_final(&ctx->m.s256, (u8 *)hash); break; case Skein512: - ret = Skein_512_Final(&ctx->m.s512, (u8 *)hash); + ret = skein_512_final(&ctx->m.s512, (u8 *)hash); break; case Skein1024: - ret = Skein1024_Final(&ctx->m.s1024, (u8 *)hash); + ret = skein_1024_final(&ctx->m.s1024, (u8 *)hash); break; } return ret; diff --git a/drivers/staging/skein/skeinBlockNo3F.c b/drivers/staging/skein/skeinBlockNo3F.c index 69176389fef9..0acb617d168d 100644 --- a/drivers/staging/skein/skeinBlockNo3F.c +++ b/drivers/staging/skein/skeinBlockNo3F.c @@ -5,8 +5,8 @@ /***************************** Skein_256 ******************************/ -void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, - size_t blkCnt, size_t byteCntAdd) +void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blkPtr, + size_t blkCnt, size_t byteCntAdd) { struct threefish_key key; u64 tweak[2]; @@ -34,12 +34,12 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, tweak[0] |= (words[1] & 0xffffffffL) << 32; tweak[1] |= words[2] & 0xffffffffL; - threefishSetKey(&key, Threefish256, ctx->X, tweak); + threefish_set_key(&key, Threefish256, ctx->X, tweak); /* get input block in little-endian format */ Skein_Get64_LSB_First(w, blkPtr, SKEIN_256_STATE_WORDS); - threefishEncryptBlockWords(&key, w, ctx->X); + threefish_encrypt_block_words(&key, w, ctx->X); blkPtr += SKEIN_256_BLOCK_BYTES; @@ -56,8 +56,8 @@ void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, ctx->h.T[1] = tweak[1]; } -void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, - size_t blkCnt, size_t byteCntAdd) +void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blkPtr, + size_t blkCnt, size_t byteCntAdd) { struct threefish_key key; u64 tweak[2]; @@ -85,12 +85,12 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, tweak[0] |= (words[1] & 0xffffffffL) << 32; tweak[1] |= words[2] & 0xffffffffL; - threefishSetKey(&key, Threefish512, ctx->X, tweak); + threefish_set_key(&key, Threefish512, ctx->X, tweak); /* get input block in little-endian format */ Skein_Get64_LSB_First(w, blkPtr, SKEIN_512_STATE_WORDS); - threefishEncryptBlockWords(&key, w, ctx->X); + threefish_encrypt_block_words(&key, w, ctx->X); blkPtr += SKEIN_512_BLOCK_BYTES; @@ -111,8 +111,8 @@ void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, ctx->h.T[1] = tweak[1]; } -void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, - size_t blkCnt, size_t byteCntAdd) +void skein_1024_process_block(struct skein1024_ctx *ctx, const u8 *blkPtr, + size_t blkCnt, size_t byteCntAdd) { struct threefish_key key; u64 tweak[2]; @@ -140,12 +140,12 @@ void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, tweak[0] |= (words[1] & 0xffffffffL) << 32; tweak[1] |= words[2] & 0xffffffffL; - threefishSetKey(&key, Threefish1024, ctx->X, tweak); + threefish_set_key(&key, Threefish1024, ctx->X, tweak); /* get input block in little-endian format */ Skein_Get64_LSB_First(w, blkPtr, SKEIN1024_STATE_WORDS); - threefishEncryptBlockWords(&key, w, ctx->X); + threefish_encrypt_block_words(&key, w, ctx->X); blkPtr += SKEIN1024_BLOCK_BYTES; diff --git a/drivers/staging/skein/skein_block.c b/drivers/staging/skein/skein_block.c index fd96ca0ad0ed..1195aec4de89 100644 --- a/drivers/staging/skein/skein_block.c +++ b/drivers/staging/skein/skein_block.c @@ -39,8 +39,8 @@ /***************************** Skein_256 ******************************/ #if !(SKEIN_USE_ASM & 256) -void Skein_256_Process_Block(struct skein_256_ctx *ctx, const u8 *blkPtr, - size_t blkCnt, size_t byteCntAdd) +void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blkPtr, + size_t blkCnt, size_t byteCntAdd) { /* do it in C */ enum { WCNT = SKEIN_256_STATE_WORDS @@ -215,7 +215,7 @@ do { \ R256_8_rounds(14); #endif #if (SKEIN_UNROLL_256 > 14) -#error "need more unrolling in Skein_256_Process_Block" +#error "need more unrolling in skein_256_process_block" #endif } /* do the final "feedforward" xor, update context chaining */ @@ -233,12 +233,12 @@ do { \ } #if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF) -size_t Skein_256_Process_Block_CodeSize(void) +size_t skein_256_process_block_code_size(void) { - return ((u8 *) Skein_256_Process_Block_CodeSize) - - ((u8 *) Skein_256_Process_Block); + return ((u8 *) skein_256_process_block_code_size) - + ((u8 *) skein_256_process_block); } -unsigned int Skein_256_Unroll_Cnt(void) +unsigned int skein_256_unroll_cnt(void) { return SKEIN_UNROLL_256; } @@ -247,8 +247,8 @@ unsigned int Skein_256_Unroll_Cnt(void) /***************************** Skein_512 ******************************/ #if !(SKEIN_USE_ASM & 512) -void Skein_512_Process_Block(struct skein_512_ctx *ctx, const u8 *blkPtr, - size_t blkCnt, size_t byteCntAdd) +void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blkPtr, + size_t blkCnt, size_t byteCntAdd) { /* do it in C */ enum { WCNT = SKEIN_512_STATE_WORDS @@ -441,7 +441,7 @@ do { \ R512_8_rounds(14); #endif #if (SKEIN_UNROLL_512 > 14) -#error "need more unrolling in Skein_512_Process_Block" +#error "need more unrolling in skein_512_process_block" #endif } @@ -463,12 +463,12 @@ do { \ } #if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF) -size_t Skein_512_Process_Block_CodeSize(void) +size_t skein_512_process_block_code_size(void) { - return ((u8 *) Skein_512_Process_Block_CodeSize) - - ((u8 *) Skein_512_Process_Block); + return ((u8 *) skein_512_process_block_code_size) - + ((u8 *) skein_512_process_block); } -unsigned int Skein_512_Unroll_Cnt(void) +unsigned int skein_512_unroll_cnt(void) { return SKEIN_UNROLL_512; } @@ -477,8 +477,8 @@ unsigned int Skein_512_Unroll_Cnt(void) /***************************** Skein1024 ******************************/ #if !(SKEIN_USE_ASM & 1024) -void Skein1024_Process_Block(struct skein1024_ctx *ctx, const u8 *blkPtr, - size_t blkCnt, size_t byteCntAdd) +void skein_1024_process_block(struct skein1024_ctx *ctx, const u8 *blkPtr, + size_t blkCnt, size_t byteCntAdd) { /* do it in C, always looping (unrolled is bigger AND slower!) */ enum { WCNT = SKEIN1024_STATE_WORDS @@ -757,12 +757,12 @@ do { \ } #if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF) -size_t Skein1024_Process_Block_CodeSize(void) +size_t skein_1024_process_block_code_size(void) { - return ((u8 *) Skein1024_Process_Block_CodeSize) - - ((u8 *) Skein1024_Process_Block); + return ((u8 *) skein_1024_process_block_code_size) - + ((u8 *) skein_1024_process_block); } -unsigned int Skein1024_Unroll_Cnt(void) +unsigned int skein_1024_unroll_cnt(void) { return SKEIN_UNROLL_1024; } diff --git a/drivers/staging/skein/threefish1024Block.c b/drivers/staging/skein/threefish1024Block.c index fe7517b2008c..113019f4c619 100644 --- a/drivers/staging/skein/threefish1024Block.c +++ b/drivers/staging/skein/threefish1024Block.c @@ -2,7 +2,8 @@ #include -void threefishEncrypt1024(struct threefish_key *keyCtx, u64 *input, u64 *output) +void threefish_encrypt_1024(struct threefish_key *keyCtx, u64 *input, + u64 *output) { u64 b0 = input[0], b1 = input[1], b2 = input[2], b3 = input[3], @@ -2122,7 +2123,8 @@ void threefishEncrypt1024(struct threefish_key *keyCtx, u64 *input, u64 *output) output[15] = b15 + k1 + 20; } -void threefishDecrypt1024(struct threefish_key *keyCtx, u64 *input, u64 *output) +void threefish_decrypt_1024(struct threefish_key *keyCtx, u64 *input, + u64 *output) { u64 b0 = input[0], b1 = input[1], b2 = input[2], b3 = input[3], diff --git a/drivers/staging/skein/threefish256Block.c b/drivers/staging/skein/threefish256Block.c index 2ae746a641ae..ee21aef24573 100644 --- a/drivers/staging/skein/threefish256Block.c +++ b/drivers/staging/skein/threefish256Block.c @@ -2,7 +2,8 @@ #include -void threefishEncrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output) +void threefish_encrypt_256(struct threefish_key *keyCtx, u64 *input, + u64 *output) { u64 b0 = input[0], b1 = input[1], b2 = input[2], b3 = input[3]; @@ -494,7 +495,8 @@ void threefishEncrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output) output[3] = b3 + k1 + 18; } -void threefishDecrypt256(struct threefish_key *keyCtx, u64 *input, u64 *output) +void threefish_decrypt_256(struct threefish_key *keyCtx, u64 *input, + u64 *output) { u64 b0 = input[0], b1 = input[1], b2 = input[2], b3 = input[3]; diff --git a/drivers/staging/skein/threefish512Block.c b/drivers/staging/skein/threefish512Block.c index f428fd6e1719..c4ad1b458a36 100644 --- a/drivers/staging/skein/threefish512Block.c +++ b/drivers/staging/skein/threefish512Block.c @@ -2,7 +2,8 @@ #include -void threefishEncrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output) +void threefish_encrypt_512(struct threefish_key *keyCtx, u64 *input, + u64 *output) { u64 b0 = input[0], b1 = input[1], b2 = input[2], b3 = input[3], @@ -962,7 +963,8 @@ void threefishEncrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output) output[7] = b7 + k7 + 18; } -void threefishDecrypt512(struct threefish_key *keyCtx, u64 *input, u64 *output) +void threefish_decrypt_512(struct threefish_key *keyCtx, u64 *input, + u64 *output) { u64 b0 = input[0], b1 = input[1], b2 = input[2], b3 = input[3], diff --git a/drivers/staging/skein/threefishApi.c b/drivers/staging/skein/threefishApi.c index 1e70f66b7032..fce613b5404c 100644 --- a/drivers/staging/skein/threefishApi.c +++ b/drivers/staging/skein/threefishApi.c @@ -3,9 +3,9 @@ #include #include -void threefishSetKey(struct threefish_key *keyCtx, - enum threefish_size stateSize, - u64 *keyData, u64 *tweak) +void threefish_set_key(struct threefish_key *keyCtx, + enum threefish_size stateSize, + u64 *keyData, u64 *tweak) { int keyWords = stateSize / 64; int i; @@ -23,56 +23,56 @@ void threefishSetKey(struct threefish_key *keyCtx, keyCtx->stateSize = stateSize; } -void threefishEncryptBlockBytes(struct threefish_key *keyCtx, u8 *in, - u8 *out) +void threefish_encrypt_block_bytes(struct threefish_key *keyCtx, u8 *in, + u8 *out) { u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ u64 cipher[SKEIN_MAX_STATE_WORDS]; Skein_Get64_LSB_First(plain, in, keyCtx->stateSize / 64); - threefishEncryptBlockWords(keyCtx, plain, cipher); + threefish_encrypt_block_words(keyCtx, plain, cipher); Skein_Put64_LSB_First(out, cipher, keyCtx->stateSize / 8); } -void threefishEncryptBlockWords(struct threefish_key *keyCtx, u64 *in, - u64 *out) +void threefish_encrypt_block_words(struct threefish_key *keyCtx, u64 *in, + u64 *out) { switch (keyCtx->stateSize) { case Threefish256: - threefishEncrypt256(keyCtx, in, out); + threefish_encrypt_256(keyCtx, in, out); break; case Threefish512: - threefishEncrypt512(keyCtx, in, out); + threefish_encrypt_512(keyCtx, in, out); break; case Threefish1024: - threefishEncrypt1024(keyCtx, in, out); + threefish_encrypt_1024(keyCtx, in, out); break; } } -void threefishDecryptBlockBytes(struct threefish_key *keyCtx, u8 *in, - u8 *out) +void threefish_decrypt_block_bytes(struct threefish_key *keyCtx, u8 *in, + u8 *out) { u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ u64 cipher[SKEIN_MAX_STATE_WORDS]; Skein_Get64_LSB_First(cipher, in, keyCtx->stateSize / 64); - threefishDecryptBlockWords(keyCtx, cipher, plain); + threefish_decrypt_block_words(keyCtx, cipher, plain); Skein_Put64_LSB_First(out, plain, keyCtx->stateSize / 8); } -void threefishDecryptBlockWords(struct threefish_key *keyCtx, u64 *in, - u64 *out) +void threefish_decrypt_block_words(struct threefish_key *keyCtx, u64 *in, + u64 *out) { switch (keyCtx->stateSize) { case Threefish256: - threefishDecrypt256(keyCtx, in, out); + threefish_decrypt_256(keyCtx, in, out); break; case Threefish512: - threefishDecrypt512(keyCtx, in, out); + threefish_decrypt_512(keyCtx, in, out); break; case Threefish1024: - threefishDecrypt1024(keyCtx, in, out); + threefish_decrypt_1024(keyCtx, in, out); break; } } -- cgit v1.2.3 From 95f1840a7e761a86931f08c6e84f6df33333c217 Mon Sep 17 00:00:00 2001 From: Anton Saraev Date: Mon, 19 May 2014 12:09:55 +0400 Subject: staging: crypto: skein: rename camelcase vars camelCase is not accepted in the Linux Kernel. To prepare skein driver for mainline inclusion, we rename all vars to non-camelCase equivalents. Signed-off-by: Anton Saraev Reviewed-by: Jake Edge Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/TODO | 1 - drivers/staging/skein/include/skein.h | 119 ++++---- drivers/staging/skein/include/skeinApi.h | 28 +- drivers/staging/skein/include/skein_block.h | 12 +- drivers/staging/skein/include/threefishApi.h | 54 ++-- drivers/staging/skein/skein.c | 415 ++++++++++++++------------- drivers/staging/skein/skeinApi.c | 102 +++---- drivers/staging/skein/skeinBlockNo3F.c | 42 +-- drivers/staging/skein/skein_block.c | 125 ++++---- drivers/staging/skein/threefish1024Block.c | 76 ++--- drivers/staging/skein/threefish256Block.c | 28 +- drivers/staging/skein/threefish512Block.c | 44 +-- drivers/staging/skein/threefishApi.c | 60 ++-- 13 files changed, 558 insertions(+), 548 deletions(-) diff --git a/drivers/staging/skein/TODO b/drivers/staging/skein/TODO index bc42fb8c1a0b..88a6e81145e1 100644 --- a/drivers/staging/skein/TODO +++ b/drivers/staging/skein/TODO @@ -1,6 +1,5 @@ skein/threefish TODO - - rename camelcase vars - rename files - move macros into appropriate header files - add / pass test vectors diff --git a/drivers/staging/skein/include/skein.h b/drivers/staging/skein/include/skein.h index 15ff60f63d07..deaa9c867343 100644 --- a/drivers/staging/skein/include/skein.h +++ b/drivers/staging/skein/include/skein.h @@ -33,8 +33,9 @@ #endif /* below two prototype assume we are handed aligned data */ -#define Skein_Put64_LSB_First(dst08, src64, bCnt) memcpy(dst08, src64, bCnt) -#define Skein_Get64_LSB_First(dst64, src08, wCnt) memcpy(dst64, src08, 8*(wCnt)) +#define Skein_Put64_LSB_First(dst08, src64, b_cnt) memcpy(dst08, src64, b_cnt) +#define Skein_Get64_LSB_First(dst64, src08, w_cnt) \ + memcpy(dst64, src08, 8*(w_cnt)) #define Skein_Swap64(w64) (w64) enum { @@ -63,82 +64,82 @@ enum { #define SKEIN1024_BLOCK_BYTES (8*SKEIN1024_STATE_WORDS) struct skein_ctx_hdr { - size_t hashBitLen; /* size of hash result, in bits */ - size_t bCnt; /* current byte count in buffer b[] */ - u64 T[SKEIN_MODIFIER_WORDS]; /* tweak: T[0]=byte cnt, T[1]=flags */ + size_t hash_bit_len; /* size of hash result, in bits */ + size_t b_cnt; /* current byte count in buffer b[] */ + u64 T[SKEIN_MODIFIER_WORDS]; /* tweak: T[0]=byte cnt, T[1]=flags */ }; struct skein_256_ctx { /* 256-bit Skein hash context structure */ struct skein_ctx_hdr h; /* common header context variables */ - u64 X[SKEIN_256_STATE_WORDS]; /* chaining variables */ - u8 b[SKEIN_256_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ + u64 X[SKEIN_256_STATE_WORDS]; /* chaining variables */ + u8 b[SKEIN_256_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ }; struct skein_512_ctx { /* 512-bit Skein hash context structure */ struct skein_ctx_hdr h; /* common header context variables */ - u64 X[SKEIN_512_STATE_WORDS]; /* chaining variables */ - u8 b[SKEIN_512_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ + u64 X[SKEIN_512_STATE_WORDS]; /* chaining variables */ + u8 b[SKEIN_512_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ }; struct skein1024_ctx { /* 1024-bit Skein hash context structure */ struct skein_ctx_hdr h; /* common header context variables */ - u64 X[SKEIN1024_STATE_WORDS]; /* chaining variables */ - u8 b[SKEIN1024_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ + u64 X[SKEIN1024_STATE_WORDS]; /* chaining variables */ + u8 b[SKEIN1024_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ }; /* Skein APIs for (incremental) "straight hashing" */ -int skein_256_init(struct skein_256_ctx *ctx, size_t hashBitLen); -int skein_512_init(struct skein_512_ctx *ctx, size_t hashBitLen); -int skein_1024_init(struct skein1024_ctx *ctx, size_t hashBitLen); +int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len); +int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len); +int skein_1024_init(struct skein1024_ctx *ctx, size_t hash_bit_len); int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg, - size_t msgByteCnt); + size_t msg_byte_cnt); int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg, - size_t msgByteCnt); + size_t msg_byte_cnt); int skein_1024_update(struct skein1024_ctx *ctx, const u8 *msg, - size_t msgByteCnt); + size_t msg_byte_cnt); -int skein_256_final(struct skein_256_ctx *ctx, u8 *hashVal); -int skein_512_final(struct skein_512_ctx *ctx, u8 *hashVal); -int skein_1024_final(struct skein1024_ctx *ctx, u8 *hashVal); +int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val); +int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val); +int skein_1024_final(struct skein1024_ctx *ctx, u8 *hash_val); /* ** Skein APIs for "extended" initialization: MAC keys, tree hashing. ** After an init_ext() call, just use update/final calls as with init(). ** -** Notes: Same parameters as _init() calls, plus treeInfo/key/keyBytes. -** When keyBytes == 0 and treeInfo == SKEIN_SEQUENTIAL, +** Notes: Same parameters as _init() calls, plus tree_info/key/key_bytes. +** When key_bytes == 0 and tree_info == SKEIN_SEQUENTIAL, ** the results of init_ext() are identical to calling init(). ** The function init() may be called once to "precompute" the IV for -** a given hashBitLen value, then by saving a copy of the context +** a given hash_bit_len value, then by saving a copy of the context ** the IV computation may be avoided in later calls. ** Similarly, the function init_ext() may be called once per MAC key ** to precompute the MAC IV, then a copy of the context saved and ** reused for each new MAC computation. **/ -int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hashBitLen, - u64 treeInfo, const u8 *key, size_t keyBytes); -int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hashBitLen, - u64 treeInfo, const u8 *key, size_t keyBytes); -int skein_1024_init_ext(struct skein1024_ctx *ctx, size_t hashBitLen, - u64 treeInfo, const u8 *key, size_t keyBytes); +int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hash_bit_len, + u64 tree_info, const u8 *key, size_t key_bytes); +int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hash_bit_len, + u64 tree_info, const u8 *key, size_t key_bytes); +int skein_1024_init_ext(struct skein1024_ctx *ctx, size_t hash_bit_len, + u64 tree_info, const u8 *key, size_t key_bytes); /* ** Skein APIs for MAC and tree hash: ** final_pad: pad, do final block, but no OUTPUT type ** output: do just the output stage */ -int skein_256_final_pad(struct skein_256_ctx *ctx, u8 *hashVal); -int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hashVal); -int skein_1024_final_pad(struct skein1024_ctx *ctx, u8 *hashVal); +int skein_256_final_pad(struct skein_256_ctx *ctx, u8 *hash_val); +int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hash_val); +int skein_1024_final_pad(struct skein1024_ctx *ctx, u8 *hash_val); #ifndef SKEIN_TREE_HASH #define SKEIN_TREE_HASH (1) #endif #if SKEIN_TREE_HASH -int skein_256_output(struct skein_256_ctx *ctx, u8 *hashVal); -int skein_512_output(struct skein_512_ctx *ctx, u8 *hashVal); -int skein_1024_output(struct skein1024_ctx *ctx, u8 *hashVal); +int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val); +int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val); +int skein_1024_output(struct skein1024_ctx *ctx, u8 *hash_val); #endif /***************************************************************** @@ -207,7 +208,7 @@ int skein_1024_output(struct skein1024_ctx *ctx, u8 *hashVal); #define SKEIN_CFG_STR_LEN (4*8) -/* bit field definitions in config block treeInfo word */ +/* bit field definitions in config block tree_info word */ #define SKEIN_CFG_TREE_LEAF_SIZE_POS (0) #define SKEIN_CFG_TREE_NODE_SIZE_POS (8) #define SKEIN_CFG_TREE_MAX_LEVEL_POS (16) @@ -219,46 +220,46 @@ int skein_1024_output(struct skein1024_ctx *ctx, u8 *hashVal); #define SKEIN_CFG_TREE_MAX_LEVEL_MSK (((u64)0xFF) << \ SKEIN_CFG_TREE_MAX_LEVEL_POS) -#define SKEIN_CFG_TREE_INFO(leaf, node, maxLvl) \ +#define SKEIN_CFG_TREE_INFO(leaf, node, max_lvl) \ ((((u64)(leaf)) << SKEIN_CFG_TREE_LEAF_SIZE_POS) | \ (((u64)(node)) << SKEIN_CFG_TREE_NODE_SIZE_POS) | \ - (((u64)(maxLvl)) << SKEIN_CFG_TREE_MAX_LEVEL_POS)) + (((u64)(max_lvl)) << SKEIN_CFG_TREE_MAX_LEVEL_POS)) -/* use as treeInfo in InitExt() call for sequential processing */ +/* use as tree_info in InitExt() call for sequential processing */ #define SKEIN_CFG_TREE_INFO_SEQUENTIAL SKEIN_CFG_TREE_INFO(0, 0, 0) /* ** Skein macros for getting/setting tweak words, etc. ** These are useful for partial input bytes, hash tree init/update, etc. **/ -#define Skein_Get_Tweak(ctxPtr, TWK_NUM) ((ctxPtr)->h.T[TWK_NUM]) -#define Skein_Set_Tweak(ctxPtr, TWK_NUM, tVal) { \ - (ctxPtr)->h.T[TWK_NUM] = (tVal); \ +#define Skein_Get_Tweak(ctx_ptr, TWK_NUM) ((ctx_ptr)->h.T[TWK_NUM]) +#define Skein_Set_Tweak(ctx_ptr, TWK_NUM, t_val) { \ + (ctx_ptr)->h.T[TWK_NUM] = (t_val); \ } -#define Skein_Get_T0(ctxPtr) Skein_Get_Tweak(ctxPtr, 0) -#define Skein_Get_T1(ctxPtr) Skein_Get_Tweak(ctxPtr, 1) -#define Skein_Set_T0(ctxPtr, T0) Skein_Set_Tweak(ctxPtr, 0, T0) -#define Skein_Set_T1(ctxPtr, T1) Skein_Set_Tweak(ctxPtr, 1, T1) +#define Skein_Get_T0(ctx_ptr) Skein_Get_Tweak(ctx_ptr, 0) +#define Skein_Get_T1(ctx_ptr) Skein_Get_Tweak(ctx_ptr, 1) +#define Skein_Set_T0(ctx_ptr, T0) Skein_Set_Tweak(ctx_ptr, 0, T0) +#define Skein_Set_T1(ctx_ptr, T1) Skein_Set_Tweak(ctx_ptr, 1, T1) /* set both tweak words at once */ -#define Skein_Set_T0_T1(ctxPtr, T0, T1) \ +#define Skein_Set_T0_T1(ctx_ptr, T0, T1) \ { \ - Skein_Set_T0(ctxPtr, (T0)); \ - Skein_Set_T1(ctxPtr, (T1)); \ + Skein_Set_T0(ctx_ptr, (T0)); \ + Skein_Set_T1(ctx_ptr, (T1)); \ } -#define Skein_Set_Type(ctxPtr, BLK_TYPE) \ - Skein_Set_T1(ctxPtr, SKEIN_T1_BLK_TYPE_##BLK_TYPE) +#define Skein_Set_Type(ctx_ptr, BLK_TYPE) \ + Skein_Set_T1(ctx_ptr, SKEIN_T1_BLK_TYPE_##BLK_TYPE) /* * setup for starting with a new type: - * h.T[0]=0; h.T[1] = NEW_TYPE; h.bCnt=0; + * h.T[0]=0; h.T[1] = NEW_TYPE; h.b_cnt=0; */ -#define Skein_Start_New_Type(ctxPtr, BLK_TYPE) { \ - Skein_Set_T0_T1(ctxPtr, 0, SKEIN_T1_FLAG_FIRST | \ +#define Skein_Start_New_Type(ctx_ptr, BLK_TYPE) { \ + Skein_Set_T0_T1(ctx_ptr, 0, SKEIN_T1_FLAG_FIRST | \ SKEIN_T1_BLK_TYPE_##BLK_TYPE); \ - (ctxPtr)->h.bCnt = 0; \ + (ctx_ptr)->h.b_cnt = 0; \ } #define Skein_Clear_First_Flag(hdr) { \ @@ -278,14 +279,14 @@ int skein_1024_output(struct skein1024_ctx *ctx, u8 *hashVal); #ifdef SKEIN_DEBUG /* examine/display intermediate values? */ #include "skein_debug.h" #else /* default is no callouts */ -#define Skein_Show_Block(bits, ctx, X, blkPtr, wPtr, ksEvenPtr, ksOddPtr) +#define Skein_Show_Block(bits, ctx, X, blk_ptr, w_ptr, ks_event_ptr, ks_odd_ptr) #define Skein_Show_Round(bits, ctx, r, X) #define Skein_Show_R_Ptr(bits, ctx, r, X_ptr) -#define Skein_Show_Final(bits, ctx, cnt, outPtr) -#define Skein_Show_Key(bits, ctx, key, keyBytes) +#define Skein_Show_Final(bits, ctx, cnt, out_ptr) +#define Skein_Show_Key(bits, ctx, key, key_bytes) #endif -#define Skein_Assert(x, retCode)/* ignore all Asserts, for performance */ +#define Skein_Assert(x, ret_code)/* ignore all Asserts, for performance */ #define Skein_assert(x) /***************************************************************** diff --git a/drivers/staging/skein/include/skeinApi.h b/drivers/staging/skein/include/skeinApi.h index ea54546bf030..11ecab83fea6 100644 --- a/drivers/staging/skein/include/skeinApi.h +++ b/drivers/staging/skein/include/skeinApi.h @@ -59,7 +59,7 @@ OTHER DEALINGS IN THE SOFTWARE. * * // Now update Skein with any number of message bits. A function that * // takes a number of bytes is also available. - * skein_update_bits(&ctx, message, msgLength); + * skein_update_bits(&ctx, message, msg_length); * * // Now get the result of the Skein hash. The output buffer must be * // large enough to hold the request number of output bits. The application @@ -99,8 +99,8 @@ enum skein_size { * structures as well. */ struct skein_ctx { - u64 skeinSize; - u64 XSave[SKEIN_MAX_STATE_WORDS]; /* save area for state variables */ + u64 skein_size; + u64 X_save[SKEIN_MAX_STATE_WORDS]; /* save area for state variables */ union { struct skein_ctx_hdr h; struct skein_256_ctx s256; @@ -133,13 +133,13 @@ int skein_ctx_prepare(struct skein_ctx *ctx, enum skein_size size); * * @param ctx * Pointer to a Skein context. - * @param hashBitLen + * @param hash_bit_len * Number of MAC hash bits to compute * @return * SKEIN_SUCESS of SKEIN_FAIL * @see skein_reset */ -int skein_init(struct skein_ctx *ctx, size_t hashBitLen); +int skein_init(struct skein_ctx *ctx, size_t hash_bit_len); /** * Resets a Skein context for further use. @@ -166,15 +166,15 @@ void skein_reset(struct skein_ctx *ctx); * Pointer to an empty or preinitialized Skein MAC context * @param key * Pointer to key bytes or NULL - * @param keyLen + * @param key_len * Length of the key in bytes or zero - * @param hashBitLen + * @param hash_bit_len * Number of MAC hash bits to compute * @return * SKEIN_SUCESS of SKEIN_FAIL */ -int skein_mac_init(struct skein_ctx *ctx, const u8 *key, size_t keyLen, - size_t hashBitLen); +int skein_mac_init(struct skein_ctx *ctx, const u8 *key, size_t key_len, + size_t hash_bit_len); /** * Update Skein with the next part of the message. @@ -183,13 +183,13 @@ int skein_mac_init(struct skein_ctx *ctx, const u8 *key, size_t keyLen, * Pointer to initialized Skein context * @param msg * Pointer to the message. - * @param msgByteCnt + * @param msg_byte_cnt * Length of the message in @b bytes * @return * Success or error code. */ int skein_update(struct skein_ctx *ctx, const u8 *msg, - size_t msgByteCnt); + size_t msg_byte_cnt); /** * Update the hash with a message bit string. @@ -201,11 +201,11 @@ int skein_update(struct skein_ctx *ctx, const u8 *msg, * Pointer to initialized Skein context * @param msg * Pointer to the message. - * @param msgBitCnt + * @param msg_bit_cnt * Length of the message in @b bits. */ int skein_update_bits(struct skein_ctx *ctx, const u8 *msg, - size_t msgBitCnt); + size_t msg_bit_cnt); /** * Finalize Skein and return the hash. @@ -217,7 +217,7 @@ int skein_update_bits(struct skein_ctx *ctx, const u8 *msg, * Pointer to initialized Skein context * @param hash * Pointer to buffer that receives the hash. The buffer must be large - * enough to store @c hashBitLen bits. + * enough to store @c hash_bit_len bits. * @return * Success or error code. * @see skein_reset diff --git a/drivers/staging/skein/include/skein_block.h b/drivers/staging/skein/include/skein_block.h index 41cae89ff4cc..ec787a3fbebd 100644 --- a/drivers/staging/skein/include/skein_block.h +++ b/drivers/staging/skein/include/skein_block.h @@ -12,11 +12,11 @@ #include /* get the Skein API definitions */ -void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blkPtr, - size_t blkCnt, size_t byteCntAdd); -void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blkPtr, - size_t blkCnt, size_t byteCntAdd); -void skein_1024_process_block(struct skein1024_ctx *ctx, const u8 *blkPtr, - size_t blkCnt, size_t byteCntAdd); +void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, + size_t blk_cnt, size_t byte_cnt_add); +void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, + size_t blk_cnt, size_t byte_cnt_add); +void skein_1024_process_block(struct skein1024_ctx *ctx, const u8 *blk_ptr, + size_t blk_cnt, size_t byte_cnt_add); #endif diff --git a/drivers/staging/skein/include/threefishApi.h b/drivers/staging/skein/include/threefishApi.h index 6cdad46f19c8..37f6e63b2c30 100644 --- a/drivers/staging/skein/include/threefishApi.h +++ b/drivers/staging/skein/include/threefishApi.h @@ -18,13 +18,13 @@ * @code // Threefish cipher context data - struct threefish_key keyCtx; + struct threefish_key key_ctx; // Initialize the context - threefish_set_key(&keyCtx, Threefish512, key, tweak); + threefish_set_key(&key_ctx, Threefish512, key, tweak); // Encrypt - threefish_encrypt_block_bytes(&keyCtx, input, cipher); + threefish_encrypt_block_bytes(&key_ctx, input, cipher); @endcode */ @@ -51,7 +51,7 @@ enum threefish_size { * structures as well. */ struct threefish_key { - u64 stateSize; + u64 state_size; u64 key[SKEIN_MAX_STATE_WORDS+1]; /* max number of key words*/ u64 tweak[3]; }; @@ -63,106 +63,106 @@ struct threefish_key { * the given size. The key data must have the same length (number of bits) * as the state size * - * @param keyCtx + * @param key_ctx * Pointer to a Threefish key structure. * @param size * Which Skein size to use. - * @param keyData + * @param key_data * Pointer to the key words (word has 64 bits). * @param tweak * Pointer to the two tweak words (word has 64 bits). */ -void threefish_set_key(struct threefish_key *keyCtx, - enum threefish_size stateSize, - u64 *keyData, u64 *tweak); +void threefish_set_key(struct threefish_key *key_ctx, + enum threefish_size state_size, + u64 *key_data, u64 *tweak); /** * Encrypt Threefisch block (bytes). * * The buffer must have at least the same length (number of bits) aas the - * state size for this key. The function uses the first @c stateSize bits + * state size for this key. The function uses the first @c state_size bits * of the input buffer, encrypts them and stores the result in the output * buffer. * - * @param keyCtx + * @param key_ctx * Pointer to a Threefish key structure. * @param in * Poionter to plaintext data buffer. * @param out * Pointer to cipher buffer. */ -void threefish_encrypt_block_bytes(struct threefish_key *keyCtx, u8 *in, +void threefish_encrypt_block_bytes(struct threefish_key *key_ctx, u8 *in, u8 *out); /** * Encrypt Threefisch block (words). * * The buffer must have at least the same length (number of bits) aas the - * state size for this key. The function uses the first @c stateSize bits + * state size for this key. The function uses the first @c state_size bits * of the input buffer, encrypts them and stores the result in the output * buffer. * * The wordsize ist set to 64 bits. * - * @param keyCtx + * @param key_ctx * Pointer to a Threefish key structure. * @param in * Poionter to plaintext data buffer. * @param out * Pointer to cipher buffer. */ -void threefish_encrypt_block_words(struct threefish_key *keyCtx, u64 *in, +void threefish_encrypt_block_words(struct threefish_key *key_ctx, u64 *in, u64 *out); /** * Decrypt Threefisch block (bytes). * * The buffer must have at least the same length (number of bits) aas the - * state size for this key. The function uses the first @c stateSize bits + * state size for this key. The function uses the first @c state_size bits * of the input buffer, decrypts them and stores the result in the output * buffer * - * @param keyCtx + * @param key_ctx * Pointer to a Threefish key structure. * @param in * Poionter to cipher data buffer. * @param out * Pointer to plaintext buffer. */ -void threefish_decrypt_block_bytes(struct threefish_key *keyCtx, u8 *in, +void threefish_decrypt_block_bytes(struct threefish_key *key_ctx, u8 *in, u8 *out); /** * Decrypt Threefisch block (words). * * The buffer must have at least the same length (number of bits) aas the - * state size for this key. The function uses the first @c stateSize bits + * state size for this key. The function uses the first @c state_size bits * of the input buffer, encrypts them and stores the result in the output * buffer. * * The wordsize ist set to 64 bits. * - * @param keyCtx + * @param key_ctx * Pointer to a Threefish key structure. * @param in * Poionter to cipher data buffer. * @param out * Pointer to plaintext buffer. */ -void threefish_decrypt_block_words(struct threefish_key *keyCtx, u64 *in, +void threefish_decrypt_block_words(struct threefish_key *key_ctx, u64 *in, u64 *out); -void threefish_encrypt_256(struct threefish_key *keyCtx, u64 *input, +void threefish_encrypt_256(struct threefish_key *key_ctx, u64 *input, u64 *output); -void threefish_encrypt_512(struct threefish_key *keyCtx, u64 *input, +void threefish_encrypt_512(struct threefish_key *key_ctx, u64 *input, u64 *output); -void threefish_encrypt_1024(struct threefish_key *keyCtx, u64 *input, +void threefish_encrypt_1024(struct threefish_key *key_ctx, u64 *input, u64 *output); -void threefish_decrypt_256(struct threefish_key *keyCtx, u64 *input, +void threefish_decrypt_256(struct threefish_key *key_ctx, u64 *input, u64 *output); -void threefish_decrypt_512(struct threefish_key *keyCtx, u64 *input, +void threefish_decrypt_512(struct threefish_key *key_ctx, u64 *input, u64 *output); -void threefish_decrypt_1024(struct threefish_key *keyCtx, u64 *input, +void threefish_decrypt_1024(struct threefish_key *key_ctx, u64 *input, u64 *output); /** * @} diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c index ac64d9f096f0..d4f3534feae0 100644 --- a/drivers/staging/skein/skein.c +++ b/drivers/staging/skein/skein.c @@ -21,17 +21,17 @@ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a straight hashing operation */ -int skein_256_init(struct skein_256_ctx *ctx, size_t hashBitLen) +int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len) { union { - u8 b[SKEIN_256_STATE_BYTES]; - u64 w[SKEIN_256_STATE_WORDS]; + u8 b[SKEIN_256_STATE_BYTES]; + u64 w[SKEIN_256_STATE_WORDS]; } cfg; /* config block */ - Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN); - ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ + Skein_Assert(hash_bit_len > 0, SKEIN_BAD_HASHLEN); + ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */ - switch (hashBitLen) { /* use pre-computed values, where available */ + switch (hash_bit_len) { /* use pre-computed values, where available */ case 256: memcpy(ctx->X, SKEIN_256_IV_256, sizeof(ctx->X)); break; @@ -56,7 +56,7 @@ int skein_256_init(struct skein_256_ctx *ctx, size_t hashBitLen) /* set the schema, version */ cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); /* hash result length in bits */ - cfg.w[1] = Skein_Swap64(hashBitLen); + cfg.w[1] = Skein_Swap64(hash_bit_len); cfg.w[2] = Skein_Swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); /* zero pad config block */ memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); @@ -67,7 +67,7 @@ int skein_256_init(struct skein_256_ctx *ctx, size_t hashBitLen) skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); break; } - /* The chaining vars ctx->X are now initialized for hashBitLen. */ + /* The chaining vars ctx->X are now initialized for hash_bit_len. */ /* Set up to process the data message portion of the hash (default) */ Skein_Start_New_Type(ctx, MSG); /* T0=0, T1= MSG type */ @@ -76,34 +76,34 @@ int skein_256_init(struct skein_256_ctx *ctx, size_t hashBitLen) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a MAC and/or tree hash operation */ -/* [identical to skein_256_init() when keyBytes == 0 && \ - * treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ -int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hashBitLen, - u64 treeInfo, const u8 *key, size_t keyBytes) +/* [identical to skein_256_init() when key_bytes == 0 && \ + * tree_info == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ +int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hash_bit_len, + u64 tree_info, const u8 *key, size_t key_bytes) { union { u8 b[SKEIN_256_STATE_BYTES]; - u64 w[SKEIN_256_STATE_WORDS]; + u64 w[SKEIN_256_STATE_WORDS]; } cfg; /* config block */ - Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN); - Skein_Assert(keyBytes == 0 || key != NULL, SKEIN_FAIL); + Skein_Assert(hash_bit_len > 0, SKEIN_BAD_HASHLEN); + Skein_Assert(key_bytes == 0 || key != NULL, SKEIN_FAIL); /* compute the initial chaining values ctx->X[], based on key */ - if (keyBytes == 0) { /* is there a key? */ + if (key_bytes == 0) { /* is there a key? */ /* no key: use all zeroes as key for config block */ memset(ctx->X, 0, sizeof(ctx->X)); } else { /* here to pre-process a key */ Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); /* do a mini-Init right here */ /* set output hash bit count = state size */ - ctx->h.hashBitLen = 8*sizeof(ctx->X); + ctx->h.hash_bit_len = 8*sizeof(ctx->X); /* set tweaks: T0 = 0; T1 = KEY type */ Skein_Start_New_Type(ctx, KEY); /* zero the initial chaining variables */ memset(ctx->X, 0, sizeof(ctx->X)); /* hash the key */ - skein_256_update(ctx, key, keyBytes); + skein_256_update(ctx, key, key_bytes); /* put result into cfg.b[] */ skein_256_final_pad(ctx, cfg.b); /* copy over into ctx->X[] */ @@ -114,18 +114,18 @@ int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hashBitLen, * precomputed for each key) */ /* output hash bit count */ - ctx->h.hashBitLen = hashBitLen; + ctx->h.hash_bit_len = hash_bit_len; Skein_Start_New_Type(ctx, CFG_FINAL); /* pre-pad cfg.w[] with zeroes */ memset(&cfg.w, 0, sizeof(cfg.w)); cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); /* hash result length in bits */ - cfg.w[1] = Skein_Swap64(hashBitLen); + cfg.w[1] = Skein_Swap64(hash_bit_len); /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ - cfg.w[2] = Skein_Swap64(treeInfo); + cfg.w[2] = Skein_Swap64(tree_info); - Skein_Show_Key(256, &ctx->h, key, keyBytes); + Skein_Show_Key(256, &ctx->h, key, key_bytes); /* compute the initial chaining values from config block */ skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); @@ -140,52 +140,53 @@ int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hashBitLen, /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* process the input bytes */ int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg, - size_t msgByteCnt) + size_t msg_byte_cnt) { size_t n; /* catch uninitialized context */ - Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); + Skein_Assert(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* process full blocks, if any */ - if (msgByteCnt + ctx->h.bCnt > SKEIN_256_BLOCK_BYTES) { + if (msg_byte_cnt + ctx->h.b_cnt > SKEIN_256_BLOCK_BYTES) { /* finish up any buffered message data */ - if (ctx->h.bCnt) { + if (ctx->h.b_cnt) { /* # bytes free in buffer b[] */ - n = SKEIN_256_BLOCK_BYTES - ctx->h.bCnt; + n = SKEIN_256_BLOCK_BYTES - ctx->h.b_cnt; if (n) { /* check on our logic here */ - Skein_assert(n < msgByteCnt); - memcpy(&ctx->b[ctx->h.bCnt], msg, n); - msgByteCnt -= n; + Skein_assert(n < msg_byte_cnt); + memcpy(&ctx->b[ctx->h.b_cnt], msg, n); + msg_byte_cnt -= n; msg += n; - ctx->h.bCnt += n; + ctx->h.b_cnt += n; } - Skein_assert(ctx->h.bCnt == SKEIN_256_BLOCK_BYTES); + Skein_assert(ctx->h.b_cnt == SKEIN_256_BLOCK_BYTES); skein_256_process_block(ctx, ctx->b, 1, SKEIN_256_BLOCK_BYTES); - ctx->h.bCnt = 0; + ctx->h.b_cnt = 0; } /* * now process any remaining full blocks, directly from input * message data */ - if (msgByteCnt > SKEIN_256_BLOCK_BYTES) { + if (msg_byte_cnt > SKEIN_256_BLOCK_BYTES) { /* number of full blocks to process */ - n = (msgByteCnt-1) / SKEIN_256_BLOCK_BYTES; + n = (msg_byte_cnt-1) / SKEIN_256_BLOCK_BYTES; skein_256_process_block(ctx, msg, n, SKEIN_256_BLOCK_BYTES); - msgByteCnt -= n * SKEIN_256_BLOCK_BYTES; + msg_byte_cnt -= n * SKEIN_256_BLOCK_BYTES; msg += n * SKEIN_256_BLOCK_BYTES; } - Skein_assert(ctx->h.bCnt == 0); + Skein_assert(ctx->h.b_cnt == 0); } /* copy any remaining source message data bytes into b[] */ - if (msgByteCnt) { - Skein_assert(msgByteCnt + ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES); - memcpy(&ctx->b[ctx->h.bCnt], msg, msgByteCnt); - ctx->h.bCnt += msgByteCnt; + if (msg_byte_cnt) { + Skein_assert(msg_byte_cnt + ctx->h.b_cnt <= + SKEIN_256_BLOCK_BYTES); + memcpy(&ctx->b[ctx->h.b_cnt], msg, msg_byte_cnt); + ctx->h.b_cnt += msg_byte_cnt; } return SKEIN_SUCCESS; @@ -193,47 +194,47 @@ int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg, /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the result */ -int skein_256_final(struct skein_256_ctx *ctx, u8 *hashVal) +int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val) { - size_t i, n, byteCnt; + size_t i, n, byte_cnt; u64 X[SKEIN_256_STATE_WORDS]; /* catch uninitialized context */ - Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); + Skein_Assert(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* tag as the final block */ ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* zero pad b[] if necessary */ - if (ctx->h.bCnt < SKEIN_256_BLOCK_BYTES) - memset(&ctx->b[ctx->h.bCnt], 0, - SKEIN_256_BLOCK_BYTES - ctx->h.bCnt); + if (ctx->h.b_cnt < SKEIN_256_BLOCK_BYTES) + memset(&ctx->b[ctx->h.b_cnt], 0, + SKEIN_256_BLOCK_BYTES - ctx->h.b_cnt); /* process the final block */ - skein_256_process_block(ctx, ctx->b, 1, ctx->h.bCnt); + skein_256_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); /* now output the result */ /* total number of output bytes */ - byteCnt = (ctx->h.hashBitLen + 7) >> 3; + byte_cnt = (ctx->h.hash_bit_len + 7) >> 3; /* run Threefish in "counter mode" to generate output */ /* zero out b[], so it can hold the counter */ memset(ctx->b, 0, sizeof(ctx->b)); /* keep a local copy of counter mode "key" */ memcpy(X, ctx->X, sizeof(X)); - for (i = 0; i*SKEIN_256_BLOCK_BYTES < byteCnt; i++) { + for (i = 0; i*SKEIN_256_BLOCK_BYTES < byte_cnt; i++) { /* build the counter block */ ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); Skein_Start_New_Type(ctx, OUT_FINAL); /* run "counter mode" */ skein_256_process_block(ctx, ctx->b, 1, sizeof(u64)); /* number of output bytes left to go */ - n = byteCnt - i*SKEIN_256_BLOCK_BYTES; + n = byte_cnt - i*SKEIN_256_BLOCK_BYTES; if (n >= SKEIN_256_BLOCK_BYTES) n = SKEIN_256_BLOCK_BYTES; /* "output" the ctr mode bytes */ - Skein_Put64_LSB_First(hashVal+i*SKEIN_256_BLOCK_BYTES, ctx->X, + Skein_Put64_LSB_First(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->X, n); Skein_Show_Final(256, &ctx->h, n, - hashVal+i*SKEIN_256_BLOCK_BYTES); + hash_val+i*SKEIN_256_BLOCK_BYTES); /* restore the counter mode key for next time */ memcpy(ctx->X, X, sizeof(X)); } @@ -246,17 +247,17 @@ int skein_256_final(struct skein_256_ctx *ctx, u8 *hashVal) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a straight hashing operation */ -int skein_512_init(struct skein_512_ctx *ctx, size_t hashBitLen) +int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len) { union { - u8 b[SKEIN_512_STATE_BYTES]; - u64 w[SKEIN_512_STATE_WORDS]; + u8 b[SKEIN_512_STATE_BYTES]; + u64 w[SKEIN_512_STATE_WORDS]; } cfg; /* config block */ - Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN); - ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ + Skein_Assert(hash_bit_len > 0, SKEIN_BAD_HASHLEN); + ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */ - switch (hashBitLen) { /* use pre-computed values, where available */ + switch (hash_bit_len) { /* use pre-computed values, where available */ case 512: memcpy(ctx->X, SKEIN_512_IV_512, sizeof(ctx->X)); break; @@ -281,7 +282,7 @@ int skein_512_init(struct skein_512_ctx *ctx, size_t hashBitLen) /* set the schema, version */ cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); /* hash result length in bits */ - cfg.w[1] = Skein_Swap64(hashBitLen); + cfg.w[1] = Skein_Swap64(hash_bit_len); cfg.w[2] = Skein_Swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); /* zero pad config block */ memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); @@ -295,7 +296,7 @@ int skein_512_init(struct skein_512_ctx *ctx, size_t hashBitLen) /* * The chaining vars ctx->X are now initialized for the given - * hashBitLen. + * hash_bit_len. */ /* Set up to process the data message portion of the hash (default) */ Skein_Start_New_Type(ctx, MSG); /* T0=0, T1= MSG type */ @@ -305,34 +306,34 @@ int skein_512_init(struct skein_512_ctx *ctx, size_t hashBitLen) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a MAC and/or tree hash operation */ -/* [identical to skein_512_init() when keyBytes == 0 && \ - * treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ -int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hashBitLen, - u64 treeInfo, const u8 *key, size_t keyBytes) +/* [identical to skein_512_init() when key_bytes == 0 && \ + * tree_info == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ +int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hash_bit_len, + u64 tree_info, const u8 *key, size_t key_bytes) { union { - u8 b[SKEIN_512_STATE_BYTES]; - u64 w[SKEIN_512_STATE_WORDS]; + u8 b[SKEIN_512_STATE_BYTES]; + u64 w[SKEIN_512_STATE_WORDS]; } cfg; /* config block */ - Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN); - Skein_Assert(keyBytes == 0 || key != NULL, SKEIN_FAIL); + Skein_Assert(hash_bit_len > 0, SKEIN_BAD_HASHLEN); + Skein_Assert(key_bytes == 0 || key != NULL, SKEIN_FAIL); /* compute the initial chaining values ctx->X[], based on key */ - if (keyBytes == 0) { /* is there a key? */ + if (key_bytes == 0) { /* is there a key? */ /* no key: use all zeroes as key for config block */ memset(ctx->X, 0, sizeof(ctx->X)); } else { /* here to pre-process a key */ Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); /* do a mini-Init right here */ /* set output hash bit count = state size */ - ctx->h.hashBitLen = 8*sizeof(ctx->X); + ctx->h.hash_bit_len = 8*sizeof(ctx->X); /* set tweaks: T0 = 0; T1 = KEY type */ Skein_Start_New_Type(ctx, KEY); /* zero the initial chaining variables */ memset(ctx->X, 0, sizeof(ctx->X)); /* hash the key */ - skein_512_update(ctx, key, keyBytes); + skein_512_update(ctx, key, key_bytes); /* put result into cfg.b[] */ skein_512_final_pad(ctx, cfg.b); /* copy over into ctx->X[] */ @@ -342,18 +343,18 @@ int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hashBitLen, * build/process the config block, type == CONFIG (could be * precomputed for each key) */ - ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ + ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */ Skein_Start_New_Type(ctx, CFG_FINAL); /* pre-pad cfg.w[] with zeroes */ memset(&cfg.w, 0, sizeof(cfg.w)); cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); /* hash result length in bits */ - cfg.w[1] = Skein_Swap64(hashBitLen); + cfg.w[1] = Skein_Swap64(hash_bit_len); /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ - cfg.w[2] = Skein_Swap64(treeInfo); + cfg.w[2] = Skein_Swap64(tree_info); - Skein_Show_Key(512, &ctx->h, key, keyBytes); + Skein_Show_Key(512, &ctx->h, key, key_bytes); /* compute the initial chaining values from config block */ skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); @@ -368,52 +369,53 @@ int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hashBitLen, /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* process the input bytes */ int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg, - size_t msgByteCnt) + size_t msg_byte_cnt) { size_t n; /* catch uninitialized context */ - Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); + Skein_Assert(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* process full blocks, if any */ - if (msgByteCnt + ctx->h.bCnt > SKEIN_512_BLOCK_BYTES) { + if (msg_byte_cnt + ctx->h.b_cnt > SKEIN_512_BLOCK_BYTES) { /* finish up any buffered message data */ - if (ctx->h.bCnt) { + if (ctx->h.b_cnt) { /* # bytes free in buffer b[] */ - n = SKEIN_512_BLOCK_BYTES - ctx->h.bCnt; + n = SKEIN_512_BLOCK_BYTES - ctx->h.b_cnt; if (n) { /* check on our logic here */ - Skein_assert(n < msgByteCnt); - memcpy(&ctx->b[ctx->h.bCnt], msg, n); - msgByteCnt -= n; + Skein_assert(n < msg_byte_cnt); + memcpy(&ctx->b[ctx->h.b_cnt], msg, n); + msg_byte_cnt -= n; msg += n; - ctx->h.bCnt += n; + ctx->h.b_cnt += n; } - Skein_assert(ctx->h.bCnt == SKEIN_512_BLOCK_BYTES); + Skein_assert(ctx->h.b_cnt == SKEIN_512_BLOCK_BYTES); skein_512_process_block(ctx, ctx->b, 1, SKEIN_512_BLOCK_BYTES); - ctx->h.bCnt = 0; + ctx->h.b_cnt = 0; } /* * now process any remaining full blocks, directly from input * message data */ - if (msgByteCnt > SKEIN_512_BLOCK_BYTES) { + if (msg_byte_cnt > SKEIN_512_BLOCK_BYTES) { /* number of full blocks to process */ - n = (msgByteCnt-1) / SKEIN_512_BLOCK_BYTES; + n = (msg_byte_cnt-1) / SKEIN_512_BLOCK_BYTES; skein_512_process_block(ctx, msg, n, SKEIN_512_BLOCK_BYTES); - msgByteCnt -= n * SKEIN_512_BLOCK_BYTES; + msg_byte_cnt -= n * SKEIN_512_BLOCK_BYTES; msg += n * SKEIN_512_BLOCK_BYTES; } - Skein_assert(ctx->h.bCnt == 0); + Skein_assert(ctx->h.b_cnt == 0); } /* copy any remaining source message data bytes into b[] */ - if (msgByteCnt) { - Skein_assert(msgByteCnt + ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES); - memcpy(&ctx->b[ctx->h.bCnt], msg, msgByteCnt); - ctx->h.bCnt += msgByteCnt; + if (msg_byte_cnt) { + Skein_assert(msg_byte_cnt + ctx->h.b_cnt <= + SKEIN_512_BLOCK_BYTES); + memcpy(&ctx->b[ctx->h.b_cnt], msg, msg_byte_cnt); + ctx->h.b_cnt += msg_byte_cnt; } return SKEIN_SUCCESS; @@ -421,47 +423,47 @@ int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg, /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the result */ -int skein_512_final(struct skein_512_ctx *ctx, u8 *hashVal) +int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val) { - size_t i, n, byteCnt; + size_t i, n, byte_cnt; u64 X[SKEIN_512_STATE_WORDS]; /* catch uninitialized context */ - Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); + Skein_Assert(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* tag as the final block */ ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* zero pad b[] if necessary */ - if (ctx->h.bCnt < SKEIN_512_BLOCK_BYTES) - memset(&ctx->b[ctx->h.bCnt], 0, - SKEIN_512_BLOCK_BYTES - ctx->h.bCnt); + if (ctx->h.b_cnt < SKEIN_512_BLOCK_BYTES) + memset(&ctx->b[ctx->h.b_cnt], 0, + SKEIN_512_BLOCK_BYTES - ctx->h.b_cnt); /* process the final block */ - skein_512_process_block(ctx, ctx->b, 1, ctx->h.bCnt); + skein_512_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); /* now output the result */ /* total number of output bytes */ - byteCnt = (ctx->h.hashBitLen + 7) >> 3; + byte_cnt = (ctx->h.hash_bit_len + 7) >> 3; /* run Threefish in "counter mode" to generate output */ /* zero out b[], so it can hold the counter */ memset(ctx->b, 0, sizeof(ctx->b)); /* keep a local copy of counter mode "key" */ memcpy(X, ctx->X, sizeof(X)); - for (i = 0; i*SKEIN_512_BLOCK_BYTES < byteCnt; i++) { + for (i = 0; i*SKEIN_512_BLOCK_BYTES < byte_cnt; i++) { /* build the counter block */ ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); Skein_Start_New_Type(ctx, OUT_FINAL); /* run "counter mode" */ skein_512_process_block(ctx, ctx->b, 1, sizeof(u64)); /* number of output bytes left to go */ - n = byteCnt - i*SKEIN_512_BLOCK_BYTES; + n = byte_cnt - i*SKEIN_512_BLOCK_BYTES; if (n >= SKEIN_512_BLOCK_BYTES) n = SKEIN_512_BLOCK_BYTES; /* "output" the ctr mode bytes */ - Skein_Put64_LSB_First(hashVal+i*SKEIN_512_BLOCK_BYTES, ctx->X, + Skein_Put64_LSB_First(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->X, n); Skein_Show_Final(512, &ctx->h, n, - hashVal+i*SKEIN_512_BLOCK_BYTES); + hash_val+i*SKEIN_512_BLOCK_BYTES); /* restore the counter mode key for next time */ memcpy(ctx->X, X, sizeof(X)); } @@ -474,17 +476,17 @@ int skein_512_final(struct skein_512_ctx *ctx, u8 *hashVal) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a straight hashing operation */ -int skein_1024_init(struct skein1024_ctx *ctx, size_t hashBitLen) +int skein_1024_init(struct skein1024_ctx *ctx, size_t hash_bit_len) { union { - u8 b[SKEIN1024_STATE_BYTES]; - u64 w[SKEIN1024_STATE_WORDS]; + u8 b[SKEIN1024_STATE_BYTES]; + u64 w[SKEIN1024_STATE_WORDS]; } cfg; /* config block */ - Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN); - ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ + Skein_Assert(hash_bit_len > 0, SKEIN_BAD_HASHLEN); + ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */ - switch (hashBitLen) { /* use pre-computed values, where available */ + switch (hash_bit_len) { /* use pre-computed values, where available */ case 512: memcpy(ctx->X, SKEIN1024_IV_512, sizeof(ctx->X)); break; @@ -506,7 +508,7 @@ int skein_1024_init(struct skein1024_ctx *ctx, size_t hashBitLen) /* set the schema, version */ cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); /* hash result length in bits */ - cfg.w[1] = Skein_Swap64(hashBitLen); + cfg.w[1] = Skein_Swap64(hash_bit_len); cfg.w[2] = Skein_Swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); /* zero pad config block */ memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); @@ -518,7 +520,7 @@ int skein_1024_init(struct skein1024_ctx *ctx, size_t hashBitLen) break; } - /* The chaining vars ctx->X are now initialized for the hashBitLen. */ + /* The chaining vars ctx->X are now initialized for the hash_bit_len. */ /* Set up to process the data message portion of the hash (default) */ Skein_Start_New_Type(ctx, MSG); /* T0=0, T1= MSG type */ @@ -527,34 +529,34 @@ int skein_1024_init(struct skein1024_ctx *ctx, size_t hashBitLen) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a MAC and/or tree hash operation */ -/* [identical to skein_1024_init() when keyBytes == 0 && \ - * treeInfo == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ -int skein_1024_init_ext(struct skein1024_ctx *ctx, size_t hashBitLen, - u64 treeInfo, const u8 *key, size_t keyBytes) +/* [identical to skein_1024_init() when key_bytes == 0 && \ + * tree_info == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ +int skein_1024_init_ext(struct skein1024_ctx *ctx, size_t hash_bit_len, + u64 tree_info, const u8 *key, size_t key_bytes) { union { - u8 b[SKEIN1024_STATE_BYTES]; - u64 w[SKEIN1024_STATE_WORDS]; + u8 b[SKEIN1024_STATE_BYTES]; + u64 w[SKEIN1024_STATE_WORDS]; } cfg; /* config block */ - Skein_Assert(hashBitLen > 0, SKEIN_BAD_HASHLEN); - Skein_Assert(keyBytes == 0 || key != NULL, SKEIN_FAIL); + Skein_Assert(hash_bit_len > 0, SKEIN_BAD_HASHLEN); + Skein_Assert(key_bytes == 0 || key != NULL, SKEIN_FAIL); /* compute the initial chaining values ctx->X[], based on key */ - if (keyBytes == 0) { /* is there a key? */ + if (key_bytes == 0) { /* is there a key? */ /* no key: use all zeroes as key for config block */ memset(ctx->X, 0, sizeof(ctx->X)); } else { /* here to pre-process a key */ Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); /* do a mini-Init right here */ /* set output hash bit count = state size */ - ctx->h.hashBitLen = 8*sizeof(ctx->X); + ctx->h.hash_bit_len = 8*sizeof(ctx->X); /* set tweaks: T0 = 0; T1 = KEY type */ Skein_Start_New_Type(ctx, KEY); /* zero the initial chaining variables */ memset(ctx->X, 0, sizeof(ctx->X)); /* hash the key */ - skein_1024_update(ctx, key, keyBytes); + skein_1024_update(ctx, key, key_bytes); /* put result into cfg.b[] */ skein_1024_final_pad(ctx, cfg.b); /* copy over into ctx->X[] */ @@ -565,18 +567,18 @@ int skein_1024_init_ext(struct skein1024_ctx *ctx, size_t hashBitLen, * precomputed for each key) */ /* output hash bit count */ - ctx->h.hashBitLen = hashBitLen; + ctx->h.hash_bit_len = hash_bit_len; Skein_Start_New_Type(ctx, CFG_FINAL); /* pre-pad cfg.w[] with zeroes */ memset(&cfg.w, 0, sizeof(cfg.w)); cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); /* hash result length in bits */ - cfg.w[1] = Skein_Swap64(hashBitLen); + cfg.w[1] = Skein_Swap64(hash_bit_len); /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ - cfg.w[2] = Skein_Swap64(treeInfo); + cfg.w[2] = Skein_Swap64(tree_info); - Skein_Show_Key(1024, &ctx->h, key, keyBytes); + Skein_Show_Key(1024, &ctx->h, key, key_bytes); /* compute the initial chaining values from config block */ skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); @@ -591,52 +593,53 @@ int skein_1024_init_ext(struct skein1024_ctx *ctx, size_t hashBitLen, /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* process the input bytes */ int skein_1024_update(struct skein1024_ctx *ctx, const u8 *msg, - size_t msgByteCnt) + size_t msg_byte_cnt) { size_t n; /* catch uninitialized context */ - Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); + Skein_Assert(ctx->h.b_cnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); /* process full blocks, if any */ - if (msgByteCnt + ctx->h.bCnt > SKEIN1024_BLOCK_BYTES) { + if (msg_byte_cnt + ctx->h.b_cnt > SKEIN1024_BLOCK_BYTES) { /* finish up any buffered message data */ - if (ctx->h.bCnt) { + if (ctx->h.b_cnt) { /* # bytes free in buffer b[] */ - n = SKEIN1024_BLOCK_BYTES - ctx->h.bCnt; + n = SKEIN1024_BLOCK_BYTES - ctx->h.b_cnt; if (n) { /* check on our logic here */ - Skein_assert(n < msgByteCnt); - memcpy(&ctx->b[ctx->h.bCnt], msg, n); - msgByteCnt -= n; + Skein_assert(n < msg_byte_cnt); + memcpy(&ctx->b[ctx->h.b_cnt], msg, n); + msg_byte_cnt -= n; msg += n; - ctx->h.bCnt += n; + ctx->h.b_cnt += n; } - Skein_assert(ctx->h.bCnt == SKEIN1024_BLOCK_BYTES); + Skein_assert(ctx->h.b_cnt == SKEIN1024_BLOCK_BYTES); skein_1024_process_block(ctx, ctx->b, 1, SKEIN1024_BLOCK_BYTES); - ctx->h.bCnt = 0; + ctx->h.b_cnt = 0; } /* * now process any remaining full blocks, directly from input * message data */ - if (msgByteCnt > SKEIN1024_BLOCK_BYTES) { + if (msg_byte_cnt > SKEIN1024_BLOCK_BYTES) { /* number of full blocks to process */ - n = (msgByteCnt-1) / SKEIN1024_BLOCK_BYTES; + n = (msg_byte_cnt-1) / SKEIN1024_BLOCK_BYTES; skein_1024_process_block(ctx, msg, n, SKEIN1024_BLOCK_BYTES); - msgByteCnt -= n * SKEIN1024_BLOCK_BYTES; + msg_byte_cnt -= n * SKEIN1024_BLOCK_BYTES; msg += n * SKEIN1024_BLOCK_BYTES; } - Skein_assert(ctx->h.bCnt == 0); + Skein_assert(ctx->h.b_cnt == 0); } /* copy any remaining source message data bytes into b[] */ - if (msgByteCnt) { - Skein_assert(msgByteCnt + ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES); - memcpy(&ctx->b[ctx->h.bCnt], msg, msgByteCnt); - ctx->h.bCnt += msgByteCnt; + if (msg_byte_cnt) { + Skein_assert(msg_byte_cnt + ctx->h.b_cnt <= + SKEIN1024_BLOCK_BYTES); + memcpy(&ctx->b[ctx->h.b_cnt], msg, msg_byte_cnt); + ctx->h.b_cnt += msg_byte_cnt; } return SKEIN_SUCCESS; @@ -644,47 +647,47 @@ int skein_1024_update(struct skein1024_ctx *ctx, const u8 *msg, /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the result */ -int skein_1024_final(struct skein1024_ctx *ctx, u8 *hashVal) +int skein_1024_final(struct skein1024_ctx *ctx, u8 *hash_val) { - size_t i, n, byteCnt; + size_t i, n, byte_cnt; u64 X[SKEIN1024_STATE_WORDS]; /* catch uninitialized context */ - Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); + Skein_Assert(ctx->h.b_cnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); /* tag as the final block */ ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* zero pad b[] if necessary */ - if (ctx->h.bCnt < SKEIN1024_BLOCK_BYTES) - memset(&ctx->b[ctx->h.bCnt], 0, - SKEIN1024_BLOCK_BYTES - ctx->h.bCnt); + if (ctx->h.b_cnt < SKEIN1024_BLOCK_BYTES) + memset(&ctx->b[ctx->h.b_cnt], 0, + SKEIN1024_BLOCK_BYTES - ctx->h.b_cnt); /* process the final block */ - skein_1024_process_block(ctx, ctx->b, 1, ctx->h.bCnt); + skein_1024_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); /* now output the result */ /* total number of output bytes */ - byteCnt = (ctx->h.hashBitLen + 7) >> 3; + byte_cnt = (ctx->h.hash_bit_len + 7) >> 3; /* run Threefish in "counter mode" to generate output */ /* zero out b[], so it can hold the counter */ memset(ctx->b, 0, sizeof(ctx->b)); /* keep a local copy of counter mode "key" */ memcpy(X, ctx->X, sizeof(X)); - for (i = 0; i*SKEIN1024_BLOCK_BYTES < byteCnt; i++) { + for (i = 0; i*SKEIN1024_BLOCK_BYTES < byte_cnt; i++) { /* build the counter block */ ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); Skein_Start_New_Type(ctx, OUT_FINAL); /* run "counter mode" */ skein_1024_process_block(ctx, ctx->b, 1, sizeof(u64)); /* number of output bytes left to go */ - n = byteCnt - i*SKEIN1024_BLOCK_BYTES; + n = byte_cnt - i*SKEIN1024_BLOCK_BYTES; if (n >= SKEIN1024_BLOCK_BYTES) n = SKEIN1024_BLOCK_BYTES; /* "output" the ctr mode bytes */ - Skein_Put64_LSB_First(hashVal+i*SKEIN1024_BLOCK_BYTES, ctx->X, + Skein_Put64_LSB_First(hash_val+i*SKEIN1024_BLOCK_BYTES, ctx->X, n); Skein_Show_Final(1024, &ctx->h, n, - hashVal+i*SKEIN1024_BLOCK_BYTES); + hash_val+i*SKEIN1024_BLOCK_BYTES); /* restore the counter mode key for next time */ memcpy(ctx->X, X, sizeof(X)); } @@ -696,66 +699,66 @@ int skein_1024_final(struct skein1024_ctx *ctx, u8 *hashVal) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the block, no OUTPUT stage */ -int skein_256_final_pad(struct skein_256_ctx *ctx, u8 *hashVal) +int skein_256_final_pad(struct skein_256_ctx *ctx, u8 *hash_val) { /* catch uninitialized context */ - Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); + Skein_Assert(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* tag as the final block */ ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* zero pad b[] if necessary */ - if (ctx->h.bCnt < SKEIN_256_BLOCK_BYTES) - memset(&ctx->b[ctx->h.bCnt], 0, - SKEIN_256_BLOCK_BYTES - ctx->h.bCnt); + if (ctx->h.b_cnt < SKEIN_256_BLOCK_BYTES) + memset(&ctx->b[ctx->h.b_cnt], 0, + SKEIN_256_BLOCK_BYTES - ctx->h.b_cnt); /* process the final block */ - skein_256_process_block(ctx, ctx->b, 1, ctx->h.bCnt); + skein_256_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); /* "output" the state bytes */ - Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN_256_BLOCK_BYTES); + Skein_Put64_LSB_First(hash_val, ctx->X, SKEIN_256_BLOCK_BYTES); return SKEIN_SUCCESS; } /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the block, no OUTPUT stage */ -int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hashVal) +int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hash_val) { /* catch uninitialized context */ - Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); + Skein_Assert(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* tag as the final block */ ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* zero pad b[] if necessary */ - if (ctx->h.bCnt < SKEIN_512_BLOCK_BYTES) - memset(&ctx->b[ctx->h.bCnt], 0, - SKEIN_512_BLOCK_BYTES - ctx->h.bCnt); + if (ctx->h.b_cnt < SKEIN_512_BLOCK_BYTES) + memset(&ctx->b[ctx->h.b_cnt], 0, + SKEIN_512_BLOCK_BYTES - ctx->h.b_cnt); /* process the final block */ - skein_512_process_block(ctx, ctx->b, 1, ctx->h.bCnt); + skein_512_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); /* "output" the state bytes */ - Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN_512_BLOCK_BYTES); + Skein_Put64_LSB_First(hash_val, ctx->X, SKEIN_512_BLOCK_BYTES); return SKEIN_SUCCESS; } /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the block, no OUTPUT stage */ -int skein_1024_final_pad(struct skein1024_ctx *ctx, u8 *hashVal) +int skein_1024_final_pad(struct skein1024_ctx *ctx, u8 *hash_val) { /* catch uninitialized context */ - Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); + Skein_Assert(ctx->h.b_cnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); /* tag as the final block */ ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* zero pad b[] if necessary */ - if (ctx->h.bCnt < SKEIN1024_BLOCK_BYTES) - memset(&ctx->b[ctx->h.bCnt], 0, - SKEIN1024_BLOCK_BYTES - ctx->h.bCnt); + if (ctx->h.b_cnt < SKEIN1024_BLOCK_BYTES) + memset(&ctx->b[ctx->h.b_cnt], 0, + SKEIN1024_BLOCK_BYTES - ctx->h.b_cnt); /* process the final block */ - skein_1024_process_block(ctx, ctx->b, 1, ctx->h.bCnt); + skein_1024_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); /* "output" the state bytes */ - Skein_Put64_LSB_First(hashVal, ctx->X, SKEIN1024_BLOCK_BYTES); + Skein_Put64_LSB_First(hash_val, ctx->X, SKEIN1024_BLOCK_BYTES); return SKEIN_SUCCESS; } @@ -763,37 +766,37 @@ int skein_1024_final_pad(struct skein1024_ctx *ctx, u8 *hashVal) #if SKEIN_TREE_HASH /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* just do the OUTPUT stage */ -int skein_256_output(struct skein_256_ctx *ctx, u8 *hashVal) +int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val) { - size_t i, n, byteCnt; + size_t i, n, byte_cnt; u64 X[SKEIN_256_STATE_WORDS]; /* catch uninitialized context */ - Skein_Assert(ctx->h.bCnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); + Skein_Assert(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* now output the result */ /* total number of output bytes */ - byteCnt = (ctx->h.hashBitLen + 7) >> 3; + byte_cnt = (ctx->h.hash_bit_len + 7) >> 3; /* run Threefish in "counter mode" to generate output */ /* zero out b[], so it can hold the counter */ memset(ctx->b, 0, sizeof(ctx->b)); /* keep a local copy of counter mode "key" */ memcpy(X, ctx->X, sizeof(X)); - for (i = 0; i*SKEIN_256_BLOCK_BYTES < byteCnt; i++) { + for (i = 0; i*SKEIN_256_BLOCK_BYTES < byte_cnt; i++) { /* build the counter block */ ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); Skein_Start_New_Type(ctx, OUT_FINAL); /* run "counter mode" */ skein_256_process_block(ctx, ctx->b, 1, sizeof(u64)); /* number of output bytes left to go */ - n = byteCnt - i*SKEIN_256_BLOCK_BYTES; + n = byte_cnt - i*SKEIN_256_BLOCK_BYTES; if (n >= SKEIN_256_BLOCK_BYTES) n = SKEIN_256_BLOCK_BYTES; /* "output" the ctr mode bytes */ - Skein_Put64_LSB_First(hashVal+i*SKEIN_256_BLOCK_BYTES, ctx->X, + Skein_Put64_LSB_First(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->X, n); Skein_Show_Final(256, &ctx->h, n, - hashVal+i*SKEIN_256_BLOCK_BYTES); + hash_val+i*SKEIN_256_BLOCK_BYTES); /* restore the counter mode key for next time */ memcpy(ctx->X, X, sizeof(X)); } @@ -802,37 +805,37 @@ int skein_256_output(struct skein_256_ctx *ctx, u8 *hashVal) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* just do the OUTPUT stage */ -int skein_512_output(struct skein_512_ctx *ctx, u8 *hashVal) +int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val) { - size_t i, n, byteCnt; + size_t i, n, byte_cnt; u64 X[SKEIN_512_STATE_WORDS]; /* catch uninitialized context */ - Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); + Skein_Assert(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* now output the result */ /* total number of output bytes */ - byteCnt = (ctx->h.hashBitLen + 7) >> 3; + byte_cnt = (ctx->h.hash_bit_len + 7) >> 3; /* run Threefish in "counter mode" to generate output */ /* zero out b[], so it can hold the counter */ memset(ctx->b, 0, sizeof(ctx->b)); /* keep a local copy of counter mode "key" */ memcpy(X, ctx->X, sizeof(X)); - for (i = 0; i*SKEIN_512_BLOCK_BYTES < byteCnt; i++) { + for (i = 0; i*SKEIN_512_BLOCK_BYTES < byte_cnt; i++) { /* build the counter block */ ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); Skein_Start_New_Type(ctx, OUT_FINAL); /* run "counter mode" */ skein_512_process_block(ctx, ctx->b, 1, sizeof(u64)); /* number of output bytes left to go */ - n = byteCnt - i*SKEIN_512_BLOCK_BYTES; + n = byte_cnt - i*SKEIN_512_BLOCK_BYTES; if (n >= SKEIN_512_BLOCK_BYTES) n = SKEIN_512_BLOCK_BYTES; /* "output" the ctr mode bytes */ - Skein_Put64_LSB_First(hashVal+i*SKEIN_512_BLOCK_BYTES, ctx->X, + Skein_Put64_LSB_First(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->X, n); Skein_Show_Final(256, &ctx->h, n, - hashVal+i*SKEIN_512_BLOCK_BYTES); + hash_val+i*SKEIN_512_BLOCK_BYTES); /* restore the counter mode key for next time */ memcpy(ctx->X, X, sizeof(X)); } @@ -841,37 +844,37 @@ int skein_512_output(struct skein_512_ctx *ctx, u8 *hashVal) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* just do the OUTPUT stage */ -int skein_1024_output(struct skein1024_ctx *ctx, u8 *hashVal) +int skein_1024_output(struct skein1024_ctx *ctx, u8 *hash_val) { - size_t i, n, byteCnt; + size_t i, n, byte_cnt; u64 X[SKEIN1024_STATE_WORDS]; /* catch uninitialized context */ - Skein_Assert(ctx->h.bCnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); + Skein_Assert(ctx->h.b_cnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); /* now output the result */ /* total number of output bytes */ - byteCnt = (ctx->h.hashBitLen + 7) >> 3; + byte_cnt = (ctx->h.hash_bit_len + 7) >> 3; /* run Threefish in "counter mode" to generate output */ /* zero out b[], so it can hold the counter */ memset(ctx->b, 0, sizeof(ctx->b)); /* keep a local copy of counter mode "key" */ memcpy(X, ctx->X, sizeof(X)); - for (i = 0; i*SKEIN1024_BLOCK_BYTES < byteCnt; i++) { + for (i = 0; i*SKEIN1024_BLOCK_BYTES < byte_cnt; i++) { /* build the counter block */ ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); Skein_Start_New_Type(ctx, OUT_FINAL); /* run "counter mode" */ skein_1024_process_block(ctx, ctx->b, 1, sizeof(u64)); /* number of output bytes left to go */ - n = byteCnt - i*SKEIN1024_BLOCK_BYTES; + n = byte_cnt - i*SKEIN1024_BLOCK_BYTES; if (n >= SKEIN1024_BLOCK_BYTES) n = SKEIN1024_BLOCK_BYTES; /* "output" the ctr mode bytes */ - Skein_Put64_LSB_First(hashVal+i*SKEIN1024_BLOCK_BYTES, ctx->X, + Skein_Put64_LSB_First(hash_val+i*SKEIN1024_BLOCK_BYTES, ctx->X, n); Skein_Show_Final(256, &ctx->h, n, - hashVal+i*SKEIN1024_BLOCK_BYTES); + hash_val+i*SKEIN1024_BLOCK_BYTES); /* restore the counter mode key for next time */ memcpy(ctx->X, X, sizeof(X)); } diff --git a/drivers/staging/skein/skeinApi.c b/drivers/staging/skein/skeinApi.c index c4f5333e1cce..3426392888e2 100644 --- a/drivers/staging/skein/skeinApi.c +++ b/drivers/staging/skein/skeinApi.c @@ -32,17 +32,17 @@ int skein_ctx_prepare(struct skein_ctx *ctx, enum skein_size size) Skein_Assert(ctx && size, SKEIN_FAIL); memset(ctx , 0, sizeof(struct skein_ctx)); - ctx->skeinSize = size; + ctx->skein_size = size; return SKEIN_SUCCESS; } -int skein_init(struct skein_ctx *ctx, size_t hashBitLen) +int skein_init(struct skein_ctx *ctx, size_t hash_bit_len) { int ret = SKEIN_FAIL; - size_t Xlen = 0; + size_t X_len = 0; u64 *X = NULL; - u64 treeInfo = SKEIN_CFG_TREE_INFO_SEQUENTIAL; + u64 tree_info = SKEIN_CFG_TREE_INFO_SEQUENTIAL; Skein_Assert(ctx, SKEIN_FAIL); /* @@ -51,83 +51,83 @@ int skein_init(struct skein_ctx *ctx, size_t hashBitLen) * memory available. The beauty of C :-) . */ X = ctx->m.s256.X; - Xlen = ctx->skeinSize/8; + X_len = ctx->skein_size/8; /* * If size is the same and hash bit length is zero then reuse * the save chaining variables. */ - switch (ctx->skeinSize) { + switch (ctx->skein_size) { case Skein256: - ret = skein_256_init_ext(&ctx->m.s256, hashBitLen, - treeInfo, NULL, 0); + ret = skein_256_init_ext(&ctx->m.s256, hash_bit_len, + tree_info, NULL, 0); break; case Skein512: - ret = skein_512_init_ext(&ctx->m.s512, hashBitLen, - treeInfo, NULL, 0); + ret = skein_512_init_ext(&ctx->m.s512, hash_bit_len, + tree_info, NULL, 0); break; case Skein1024: - ret = skein_1024_init_ext(&ctx->m.s1024, hashBitLen, - treeInfo, NULL, 0); + ret = skein_1024_init_ext(&ctx->m.s1024, hash_bit_len, + tree_info, NULL, 0); break; } if (ret == SKEIN_SUCCESS) { /* * Save chaining variables for this combination of size and - * hashBitLen + * hash_bit_len */ - memcpy(ctx->XSave, X, Xlen); + memcpy(ctx->X_save, X, X_len); } return ret; } -int skein_mac_init(struct skein_ctx *ctx, const u8 *key, size_t keyLen, - size_t hashBitLen) +int skein_mac_init(struct skein_ctx *ctx, const u8 *key, size_t key_len, + size_t hash_bit_len) { int ret = SKEIN_FAIL; u64 *X = NULL; - size_t Xlen = 0; - u64 treeInfo = SKEIN_CFG_TREE_INFO_SEQUENTIAL; + size_t X_len = 0; + u64 tree_info = SKEIN_CFG_TREE_INFO_SEQUENTIAL; Skein_Assert(ctx, SKEIN_FAIL); X = ctx->m.s256.X; - Xlen = ctx->skeinSize/8; + X_len = ctx->skein_size/8; - Skein_Assert(hashBitLen, SKEIN_BAD_HASHLEN); + Skein_Assert(hash_bit_len, SKEIN_BAD_HASHLEN); - switch (ctx->skeinSize) { + switch (ctx->skein_size) { case Skein256: - ret = skein_256_init_ext(&ctx->m.s256, hashBitLen, - treeInfo, - (const u8 *)key, keyLen); + ret = skein_256_init_ext(&ctx->m.s256, hash_bit_len, + tree_info, + (const u8 *)key, key_len); break; case Skein512: - ret = skein_512_init_ext(&ctx->m.s512, hashBitLen, - treeInfo, - (const u8 *)key, keyLen); + ret = skein_512_init_ext(&ctx->m.s512, hash_bit_len, + tree_info, + (const u8 *)key, key_len); break; case Skein1024: - ret = skein_1024_init_ext(&ctx->m.s1024, hashBitLen, - treeInfo, - (const u8 *)key, keyLen); + ret = skein_1024_init_ext(&ctx->m.s1024, hash_bit_len, + tree_info, + (const u8 *)key, key_len); break; } if (ret == SKEIN_SUCCESS) { /* * Save chaining variables for this combination of key, - * keyLen, hashBitLen + * key_len, hash_bit_len */ - memcpy(ctx->XSave, X, Xlen); + memcpy(ctx->X_save, X, X_len); } return ret; } void skein_reset(struct skein_ctx *ctx) { - size_t Xlen = 0; + size_t X_len = 0; u64 *X = NULL; /* @@ -136,32 +136,33 @@ void skein_reset(struct skein_ctx *ctx) * memory available. The beautiy of C :-) . */ X = ctx->m.s256.X; - Xlen = ctx->skeinSize/8; + X_len = ctx->skein_size/8; /* Restore the chaing variable, reset byte counter */ - memcpy(X, ctx->XSave, Xlen); + memcpy(X, ctx->X_save, X_len); /* Setup context to process the message */ Skein_Start_New_Type(&ctx->m, MSG); } int skein_update(struct skein_ctx *ctx, const u8 *msg, - size_t msgByteCnt) + size_t msg_byte_cnt) { int ret = SKEIN_FAIL; + Skein_Assert(ctx, SKEIN_FAIL); - switch (ctx->skeinSize) { + switch (ctx->skein_size) { case Skein256: ret = skein_256_update(&ctx->m.s256, (const u8 *)msg, - msgByteCnt); + msg_byte_cnt); break; case Skein512: ret = skein_512_update(&ctx->m.s512, (const u8 *)msg, - msgByteCnt); + msg_byte_cnt); break; case Skein1024: ret = skein_1024_update(&ctx->m.s1024, (const u8 *)msg, - msgByteCnt); + msg_byte_cnt); break; } return ret; @@ -169,7 +170,7 @@ int skein_update(struct skein_ctx *ctx, const u8 *msg, } int skein_update_bits(struct skein_ctx *ctx, const u8 *msg, - size_t msgBitCnt) + size_t msg_bit_cnt) { /* * I've used the bit pad implementation from skein_test.c (see NIST CD) @@ -185,13 +186,13 @@ int skein_update_bits(struct skein_ctx *ctx, const u8 *msg, * assert an error */ Skein_Assert((ctx->m.h.T[1] & SKEIN_T1_FLAG_BIT_PAD) == 0 || - msgBitCnt == 0, SKEIN_FAIL); + msg_bit_cnt == 0, SKEIN_FAIL); /* if number of bits is a multiple of bytes - that's easy */ - if ((msgBitCnt & 0x7) == 0) - return skein_update(ctx, msg, msgBitCnt >> 3); + if ((msg_bit_cnt & 0x7) == 0) + return skein_update(ctx, msg, msg_bit_cnt >> 3); - skein_update(ctx, msg, (msgBitCnt >> 3) + 1); + skein_update(ctx, msg, (msg_bit_cnt >> 3) + 1); /* * The next line rely on the fact that the real Skein contexts @@ -199,18 +200,18 @@ int skein_update_bits(struct skein_ctx *ctx, const u8 *msg, * Skein's real partial block buffer. * If this layout ever changes we have to adapt this as well. */ - up = (u8 *)ctx->m.s256.X + ctx->skeinSize / 8; + up = (u8 *)ctx->m.s256.X + ctx->skein_size / 8; /* set tweak flag for the skein_final call */ Skein_Set_Bit_Pad_Flag(ctx->m.h); /* now "pad" the final partial byte the way NIST likes */ - /* get the bCnt value (same location for all block sizes) */ - length = ctx->m.h.bCnt; + /* get the b_cnt value (same location for all block sizes) */ + length = ctx->m.h.b_cnt; /* internal sanity check: there IS a partial byte in the buffer! */ Skein_assert(length != 0); /* partial byte bit mask */ - mask = (u8) (1u << (7 - (msgBitCnt & 7))); + mask = (u8) (1u << (7 - (msg_bit_cnt & 7))); /* apply bit padding on final byte (in the buffer) */ up[length-1] = (u8)((up[length-1] & (0-mask))|mask); @@ -220,9 +221,10 @@ int skein_update_bits(struct skein_ctx *ctx, const u8 *msg, int skein_final(struct skein_ctx *ctx, u8 *hash) { int ret = SKEIN_FAIL; + Skein_Assert(ctx, SKEIN_FAIL); - switch (ctx->skeinSize) { + switch (ctx->skein_size) { case Skein256: ret = skein_256_final(&ctx->m.s256, (u8 *)hash); break; diff --git a/drivers/staging/skein/skeinBlockNo3F.c b/drivers/staging/skein/skeinBlockNo3F.c index 0acb617d168d..041e5ae20b78 100644 --- a/drivers/staging/skein/skeinBlockNo3F.c +++ b/drivers/staging/skein/skeinBlockNo3F.c @@ -5,8 +5,8 @@ /***************************** Skein_256 ******************************/ -void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blkPtr, - size_t blkCnt, size_t byteCntAdd) +void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, + size_t blk_cnt, size_t byte_cnt_add) { struct threefish_key key; u64 tweak[2]; @@ -14,12 +14,12 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blkPtr, u64 w[SKEIN_256_STATE_WORDS]; /* local copy of input block */ u64 words[3]; - Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ + Skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ tweak[0] = ctx->h.T[0]; tweak[1] = ctx->h.T[1]; do { - u64 carry = byteCntAdd; + u64 carry = byte_cnt_add; words[0] = tweak[0] & 0xffffffffL; words[1] = ((tweak[0] >> 32) & 0xffffffffL); @@ -37,11 +37,11 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blkPtr, threefish_set_key(&key, Threefish256, ctx->X, tweak); /* get input block in little-endian format */ - Skein_Get64_LSB_First(w, blkPtr, SKEIN_256_STATE_WORDS); + Skein_Get64_LSB_First(w, blk_ptr, SKEIN_256_STATE_WORDS); threefish_encrypt_block_words(&key, w, ctx->X); - blkPtr += SKEIN_256_BLOCK_BYTES; + blk_ptr += SKEIN_256_BLOCK_BYTES; /* do the final "feedforward" xor, update ctx chaining vars */ ctx->X[0] = ctx->X[0] ^ w[0]; @@ -50,14 +50,14 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blkPtr, ctx->X[3] = ctx->X[3] ^ w[3]; tweak[1] &= ~SKEIN_T1_FLAG_FIRST; - } while (--blkCnt); + } while (--blk_cnt); ctx->h.T[0] = tweak[0]; ctx->h.T[1] = tweak[1]; } -void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blkPtr, - size_t blkCnt, size_t byteCntAdd) +void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, + size_t blk_cnt, size_t byte_cnt_add) { struct threefish_key key; u64 tweak[2]; @@ -65,12 +65,12 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blkPtr, u64 words[3]; u64 w[SKEIN_512_STATE_WORDS]; /* local copy of input block */ - Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ + Skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ tweak[0] = ctx->h.T[0]; tweak[1] = ctx->h.T[1]; do { - u64 carry = byteCntAdd; + u64 carry = byte_cnt_add; words[0] = tweak[0] & 0xffffffffL; words[1] = ((tweak[0] >> 32) & 0xffffffffL); @@ -88,11 +88,11 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blkPtr, threefish_set_key(&key, Threefish512, ctx->X, tweak); /* get input block in little-endian format */ - Skein_Get64_LSB_First(w, blkPtr, SKEIN_512_STATE_WORDS); + Skein_Get64_LSB_First(w, blk_ptr, SKEIN_512_STATE_WORDS); threefish_encrypt_block_words(&key, w, ctx->X); - blkPtr += SKEIN_512_BLOCK_BYTES; + blk_ptr += SKEIN_512_BLOCK_BYTES; /* do the final "feedforward" xor, update ctx chaining vars */ ctx->X[0] = ctx->X[0] ^ w[0]; @@ -105,14 +105,14 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blkPtr, ctx->X[7] = ctx->X[7] ^ w[7]; tweak[1] &= ~SKEIN_T1_FLAG_FIRST; - } while (--blkCnt); + } while (--blk_cnt); ctx->h.T[0] = tweak[0]; ctx->h.T[1] = tweak[1]; } -void skein_1024_process_block(struct skein1024_ctx *ctx, const u8 *blkPtr, - size_t blkCnt, size_t byteCntAdd) +void skein_1024_process_block(struct skein1024_ctx *ctx, const u8 *blk_ptr, + size_t blk_cnt, size_t byte_cnt_add) { struct threefish_key key; u64 tweak[2]; @@ -120,12 +120,12 @@ void skein_1024_process_block(struct skein1024_ctx *ctx, const u8 *blkPtr, u64 words[3]; u64 w[SKEIN1024_STATE_WORDS]; /* local copy of input block */ - Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ + Skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ tweak[0] = ctx->h.T[0]; tweak[1] = ctx->h.T[1]; do { - u64 carry = byteCntAdd; + u64 carry = byte_cnt_add; words[0] = tweak[0] & 0xffffffffL; words[1] = ((tweak[0] >> 32) & 0xffffffffL); @@ -143,11 +143,11 @@ void skein_1024_process_block(struct skein1024_ctx *ctx, const u8 *blkPtr, threefish_set_key(&key, Threefish1024, ctx->X, tweak); /* get input block in little-endian format */ - Skein_Get64_LSB_First(w, blkPtr, SKEIN1024_STATE_WORDS); + Skein_Get64_LSB_First(w, blk_ptr, SKEIN1024_STATE_WORDS); threefish_encrypt_block_words(&key, w, ctx->X); - blkPtr += SKEIN1024_BLOCK_BYTES; + blk_ptr += SKEIN1024_BLOCK_BYTES; /* do the final "feedforward" xor, update ctx chaining vars */ ctx->X[0] = ctx->X[0] ^ w[0]; @@ -168,7 +168,7 @@ void skein_1024_process_block(struct skein1024_ctx *ctx, const u8 *blkPtr, ctx->X[15] = ctx->X[15] ^ w[15]; tweak[1] &= ~SKEIN_T1_FLAG_FIRST; - } while (--blkCnt); + } while (--blk_cnt); ctx->h.T[0] = tweak[0]; ctx->h.T[1] = tweak[1]; diff --git a/drivers/staging/skein/skein_block.c b/drivers/staging/skein/skein_block.c index 1195aec4de89..a51aa57b473d 100644 --- a/drivers/staging/skein/skein_block.c +++ b/drivers/staging/skein/skein_block.c @@ -39,8 +39,8 @@ /***************************** Skein_256 ******************************/ #if !(SKEIN_USE_ASM & 256) -void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blkPtr, - size_t blkCnt, size_t byteCntAdd) +void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, + size_t blk_cnt, size_t byte_cnt_add) { /* do it in C */ enum { WCNT = SKEIN_256_STATE_WORDS @@ -66,10 +66,11 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blkPtr, u64 X0, X1, X2, X3; /* local copy of context vars, for speed */ u64 w[WCNT]; /* local copy of input block */ #ifdef SKEIN_DEBUG - const u64 *Xptr[4]; /* use for debugging (help cc put Xn in regs) */ - Xptr[0] = &X0; Xptr[1] = &X1; Xptr[2] = &X2; Xptr[3] = &X3; + const u64 *X_ptr[4]; /* use for debugging (help cc put Xn in regs) */ + + X_ptr[0] = &X0; X_ptr[1] = &X1; X_ptr[2] = &X2; X_ptr[3] = &X3; #endif - Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ + Skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ ts[0] = ctx->h.T[0]; ts[1] = ctx->h.T[1]; do { @@ -77,7 +78,7 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blkPtr, * this implementation only supports 2**64 input bytes * (no carry out here) */ - ts[0] += byteCntAdd; /* update processed length */ + ts[0] += byte_cnt_add; /* update processed length */ /* precompute the key schedule for this block */ ks[0] = ctx->X[0]; @@ -89,9 +90,9 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blkPtr, ts[2] = ts[0] ^ ts[1]; /* get input block in little-endian format */ - Skein_Get64_LSB_First(w, blkPtr, WCNT); + Skein_Get64_LSB_First(w, blk_ptr, WCNT); DebugSaveTweak(ctx); - Skein_Show_Block(BLK_BITS, &ctx->h, ctx->X, blkPtr, w, ks, ts); + Skein_Show_Block(BLK_BITS, &ctx->h, ctx->X, blk_ptr, w, ks, ts); X0 = w[0] + ks[0]; /* do the first full key injection */ X1 = w[1] + ks[1] + ts[0]; @@ -100,23 +101,23 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blkPtr, /* show starting state values */ Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, - Xptr); + X_ptr); - blkPtr += SKEIN_256_BLOCK_BYTES; + blk_ptr += SKEIN_256_BLOCK_BYTES; /* run the rounds */ -#define Round256(p0, p1, p2, p3, ROT, rNum) \ +#define Round256(p0, p1, p2, p3, ROT, r_num) \ do { \ X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ } while (0) #if SKEIN_UNROLL_256 == 0 -#define R256(p0, p1, p2, p3, ROT, rNum) /* fully unrolled */ \ +#define R256(p0, p1, p2, p3, ROT, r_num) /* fully unrolled */ \ do { \ - Round256(p0, p1, p2, p3, ROT, rNum) \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rNum, Xptr); \ + Round256(p0, p1, p2, p3, ROT, r_num); \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, r_num, X_ptr); \ } while (0) #define I256(R) \ @@ -126,13 +127,13 @@ do { \ X1 += ks[((R)+2) % 5] + ts[((R)+1) % 3]; \ X2 += ks[((R)+3) % 5] + ts[((R)+2) % 3]; \ X3 += ks[((R)+4) % 5] + (R)+1; \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ } while (0) #else /* looping version */ -#define R256(p0, p1, p2, p3, ROT, rNum) \ +#define R256(p0, p1, p2, p3, ROT, r_num) \ do { \ - Round256(p0, p1, p2, p3, ROT, rNum) \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rNum, Xptr); \ + Round256(p0, p1, p2, p3, ROT, r_num); \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + r_num, X_ptr); \ } while (0) #define I256(R) \ @@ -145,7 +146,7 @@ do { \ /* rotate key schedule */ \ ks[r + (R) + 4] = ks[r + (R) - 1]; \ ts[r + (R) + 2] = ts[r + (R) - 1]; \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ } while (0) for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_256) @@ -227,7 +228,7 @@ do { \ Skein_Show_Round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X); ts[1] &= ~SKEIN_T1_FLAG_FIRST; - } while (--blkCnt); + } while (--blk_cnt); ctx->h.T[0] = ts[0]; ctx->h.T[1] = ts[1]; } @@ -247,8 +248,8 @@ unsigned int skein_256_unroll_cnt(void) /***************************** Skein_512 ******************************/ #if !(SKEIN_USE_ASM & 512) -void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blkPtr, - size_t blkCnt, size_t byteCntAdd) +void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, + size_t blk_cnt, size_t byte_cnt_add) { /* do it in C */ enum { WCNT = SKEIN_512_STATE_WORDS @@ -274,12 +275,13 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blkPtr, u64 X0, X1, X2, X3, X4, X5, X6, X7; /* local copies, for speed */ u64 w[WCNT]; /* local copy of input block */ #ifdef SKEIN_DEBUG - const u64 *Xptr[8]; /* use for debugging (help cc put Xn in regs) */ - Xptr[0] = &X0; Xptr[1] = &X1; Xptr[2] = &X2; Xptr[3] = &X3; - Xptr[4] = &X4; Xptr[5] = &X5; Xptr[6] = &X6; Xptr[7] = &X7; + const u64 *X_ptr[8]; /* use for debugging (help cc put Xn in regs) */ + + X_ptr[0] = &X0; X_ptr[1] = &X1; X_ptr[2] = &X2; X_ptr[3] = &X3; + X_ptr[4] = &X4; X_ptr[5] = &X5; X_ptr[6] = &X6; X_ptr[7] = &X7; #endif - Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ + Skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ ts[0] = ctx->h.T[0]; ts[1] = ctx->h.T[1]; do { @@ -287,7 +289,7 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blkPtr, * this implementation only supports 2**64 input bytes * (no carry out here) */ - ts[0] += byteCntAdd; /* update processed length */ + ts[0] += byte_cnt_add; /* update processed length */ /* precompute the key schedule for this block */ ks[0] = ctx->X[0]; @@ -304,9 +306,9 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blkPtr, ts[2] = ts[0] ^ ts[1]; /* get input block in little-endian format */ - Skein_Get64_LSB_First(w, blkPtr, WCNT); + Skein_Get64_LSB_First(w, blk_ptr, WCNT); DebugSaveTweak(ctx); - Skein_Show_Block(BLK_BITS, &ctx->h, ctx->X, blkPtr, w, ks, ts); + Skein_Show_Block(BLK_BITS, &ctx->h, ctx->X, blk_ptr, w, ks, ts); X0 = w[0] + ks[0]; /* do the first full key injection */ X1 = w[1] + ks[1]; @@ -317,12 +319,12 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blkPtr, X6 = w[6] + ks[6] + ts[1]; X7 = w[7] + ks[7]; - blkPtr += SKEIN_512_BLOCK_BYTES; + blk_ptr += SKEIN_512_BLOCK_BYTES; Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, - Xptr); + X_ptr); /* run the rounds */ -#define Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \ +#define Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \ do { \ X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ @@ -331,10 +333,10 @@ do { \ } while (0) #if SKEIN_UNROLL_512 == 0 -#define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) /* unrolled */ \ +#define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) /* unrolled */ \ do { \ - Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rNum, Xptr); \ + Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, r_num, X_ptr); \ } while (0) #define I512(R) \ @@ -348,13 +350,13 @@ do { \ X5 += ks[((R) + 6) % 9] + ts[((R) + 1) % 3]; \ X6 += ks[((R) + 7) % 9] + ts[((R) + 2) % 3]; \ X7 += ks[((R) + 8) % 9] + (R) + 1; \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ } while (0) #else /* looping version */ -#define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \ +#define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \ do { \ - Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, rNum) \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rNum, Xptr); \ + Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num); \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + r_num, X_ptr); \ } while (0) #define I512(R) \ @@ -371,7 +373,7 @@ do { \ /* rotate key schedule */ \ ks[r + (R) + 8] = ks[r + (R) - 1]; \ ts[r + (R) + 2] = ts[r + (R) - 1]; \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ } while (0) for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_512) @@ -457,7 +459,7 @@ do { \ Skein_Show_Round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X); ts[1] &= ~SKEIN_T1_FLAG_FIRST; - } while (--blkCnt); + } while (--blk_cnt); ctx->h.T[0] = ts[0]; ctx->h.T[1] = ts[1]; } @@ -477,8 +479,8 @@ unsigned int skein_512_unroll_cnt(void) /***************************** Skein1024 ******************************/ #if !(SKEIN_USE_ASM & 1024) -void skein_1024_process_block(struct skein1024_ctx *ctx, const u8 *blkPtr, - size_t blkCnt, size_t byteCntAdd) +void skein_1024_process_block(struct skein1024_ctx *ctx, const u8 *blk_ptr, + size_t blk_cnt, size_t byte_cnt_add) { /* do it in C, always looping (unrolled is bigger AND slower!) */ enum { WCNT = SKEIN1024_STATE_WORDS @@ -507,14 +509,17 @@ void skein_1024_process_block(struct skein1024_ctx *ctx, const u8 *blkPtr, X08, X09, X10, X11, X12, X13, X14, X15; u64 w[WCNT]; /* local copy of input block */ #ifdef SKEIN_DEBUG - const u64 *Xptr[16]; /* use for debugging (help cc put Xn in regs) */ - Xptr[0] = &X00; Xptr[1] = &X01; Xptr[2] = &X02; Xptr[3] = &X03; - Xptr[4] = &X04; Xptr[5] = &X05; Xptr[6] = &X06; Xptr[7] = &X07; - Xptr[8] = &X08; Xptr[9] = &X09; Xptr[10] = &X10; Xptr[11] = &X11; - Xptr[12] = &X12; Xptr[13] = &X13; Xptr[14] = &X14; Xptr[15] = &X15; + const u64 *X_ptr[16]; /* use for debugging (help cc put Xn in regs) */ + + X_ptr[0] = &X00; X_ptr[1] = &X01; X_ptr[2] = &X02; + X_ptr[3] = &X03; X_ptr[4] = &X04; X_ptr[5] = &X05; + X_ptr[6] = &X06; X_ptr[7] = &X07; X_ptr[8] = &X08; + X_ptr[9] = &X09; X_ptr[10] = &X10; X_ptr[11] = &X11; + X_ptr[12] = &X12; X_ptr[13] = &X13; X_ptr[14] = &X14; + X_ptr[15] = &X15; #endif - Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ + Skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ ts[0] = ctx->h.T[0]; ts[1] = ctx->h.T[1]; do { @@ -522,7 +527,7 @@ void skein_1024_process_block(struct skein1024_ctx *ctx, const u8 *blkPtr, * this implementation only supports 2**64 input bytes * (no carry out here) */ - ts[0] += byteCntAdd; /* update processed length */ + ts[0] += byte_cnt_add; /* update processed length */ /* precompute the key schedule for this block */ ks[0] = ctx->X[0]; @@ -549,9 +554,9 @@ void skein_1024_process_block(struct skein1024_ctx *ctx, const u8 *blkPtr, ts[2] = ts[0] ^ ts[1]; /* get input block in little-endian format */ - Skein_Get64_LSB_First(w, blkPtr, WCNT); + Skein_Get64_LSB_First(w, blk_ptr, WCNT); DebugSaveTweak(ctx); - Skein_Show_Block(BLK_BITS, &ctx->h, ctx->X, blkPtr, w, ks, ts); + Skein_Show_Block(BLK_BITS, &ctx->h, ctx->X, blk_ptr, w, ks, ts); X00 = w[0] + ks[0]; /* do the first full key injection */ X01 = w[1] + ks[1]; @@ -571,10 +576,10 @@ void skein_1024_process_block(struct skein1024_ctx *ctx, const u8 *blkPtr, X15 = w[15] + ks[15]; Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, - Xptr); + X_ptr); #define Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ - pF, ROT, rNum) \ + pF, ROT, r_num) \ do { \ X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ @@ -592,7 +597,7 @@ do { \ do { \ Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ pF, ROT, rn) \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rn, Xptr); \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rn, X_ptr); \ } while (0) #define I1024(R) \ @@ -614,7 +619,7 @@ do { \ X13 += ks[((R) + 14) % 17] + ts[((R) + 1) % 3]; \ X14 += ks[((R) + 15) % 17] + ts[((R) + 2) % 3]; \ X15 += ks[((R) + 16) % 17] + (R) + 1; \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ } while (0) #else /* looping version */ #define R1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, \ @@ -622,7 +627,7 @@ do { \ do { \ Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ pF, ROT, rn) \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rn, Xptr); \ + Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rn, X_ptr); \ } while (0) #define I1024(R) \ @@ -647,7 +652,7 @@ do { \ /* rotate key schedule */ \ ks[r + (R) + 16] = ks[r + (R) - 1]; \ ts[r + (R) + 2] = ts[r + (R) - 1]; \ - Skein_Show_R_Ptr(BLK_BITSi, &ctx->h, SKEIN_RND_KEY_INJECT, Xptr); \ + Skein_Show_R_Ptr(BLK_BITSi, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ } while (0) for (r = 1; r <= 2 * RCNT; r += 2 * SKEIN_UNROLL_1024) @@ -750,8 +755,8 @@ do { \ Skein_Show_Round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X); ts[1] &= ~SKEIN_T1_FLAG_FIRST; - blkPtr += SKEIN1024_BLOCK_BYTES; - } while (--blkCnt); + blk_ptr += SKEIN1024_BLOCK_BYTES; + } while (--blk_cnt); ctx->h.T[0] = ts[0]; ctx->h.T[1] = ts[1]; } diff --git a/drivers/staging/skein/threefish1024Block.c b/drivers/staging/skein/threefish1024Block.c index 113019f4c619..827ce1a7b33a 100644 --- a/drivers/staging/skein/threefish1024Block.c +++ b/drivers/staging/skein/threefish1024Block.c @@ -2,28 +2,28 @@ #include -void threefish_encrypt_1024(struct threefish_key *keyCtx, u64 *input, +void threefish_encrypt_1024(struct threefish_key *key_ctx, u64 *input, u64 *output) { u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3], - b4 = input[4], b5 = input[5], - b6 = input[6], b7 = input[7], - b8 = input[8], b9 = input[9], - b10 = input[10], b11 = input[11], - b12 = input[12], b13 = input[13], - b14 = input[14], b15 = input[15]; - u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1], - k2 = keyCtx->key[2], k3 = keyCtx->key[3], - k4 = keyCtx->key[4], k5 = keyCtx->key[5], - k6 = keyCtx->key[6], k7 = keyCtx->key[7], - k8 = keyCtx->key[8], k9 = keyCtx->key[9], - k10 = keyCtx->key[10], k11 = keyCtx->key[11], - k12 = keyCtx->key[12], k13 = keyCtx->key[13], - k14 = keyCtx->key[14], k15 = keyCtx->key[15], - k16 = keyCtx->key[16]; - u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], - t2 = keyCtx->tweak[2]; + b2 = input[2], b3 = input[3], + b4 = input[4], b5 = input[5], + b6 = input[6], b7 = input[7], + b8 = input[8], b9 = input[9], + b10 = input[10], b11 = input[11], + b12 = input[12], b13 = input[13], + b14 = input[14], b15 = input[15]; + u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], + k2 = key_ctx->key[2], k3 = key_ctx->key[3], + k4 = key_ctx->key[4], k5 = key_ctx->key[5], + k6 = key_ctx->key[6], k7 = key_ctx->key[7], + k8 = key_ctx->key[8], k9 = key_ctx->key[9], + k10 = key_ctx->key[10], k11 = key_ctx->key[11], + k12 = key_ctx->key[12], k13 = key_ctx->key[13], + k14 = key_ctx->key[14], k15 = key_ctx->key[15], + k16 = key_ctx->key[16]; + u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], + t2 = key_ctx->tweak[2]; b1 += k1; b0 += b1 + k0; @@ -2123,28 +2123,28 @@ void threefish_encrypt_1024(struct threefish_key *keyCtx, u64 *input, output[15] = b15 + k1 + 20; } -void threefish_decrypt_1024(struct threefish_key *keyCtx, u64 *input, +void threefish_decrypt_1024(struct threefish_key *key_ctx, u64 *input, u64 *output) { u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3], - b4 = input[4], b5 = input[5], - b6 = input[6], b7 = input[7], - b8 = input[8], b9 = input[9], - b10 = input[10], b11 = input[11], - b12 = input[12], b13 = input[13], - b14 = input[14], b15 = input[15]; - u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1], - k2 = keyCtx->key[2], k3 = keyCtx->key[3], - k4 = keyCtx->key[4], k5 = keyCtx->key[5], - k6 = keyCtx->key[6], k7 = keyCtx->key[7], - k8 = keyCtx->key[8], k9 = keyCtx->key[9], - k10 = keyCtx->key[10], k11 = keyCtx->key[11], - k12 = keyCtx->key[12], k13 = keyCtx->key[13], - k14 = keyCtx->key[14], k15 = keyCtx->key[15], - k16 = keyCtx->key[16]; - u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], - t2 = keyCtx->tweak[2]; + b2 = input[2], b3 = input[3], + b4 = input[4], b5 = input[5], + b6 = input[6], b7 = input[7], + b8 = input[8], b9 = input[9], + b10 = input[10], b11 = input[11], + b12 = input[12], b13 = input[13], + b14 = input[14], b15 = input[15]; + u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], + k2 = key_ctx->key[2], k3 = key_ctx->key[3], + k4 = key_ctx->key[4], k5 = key_ctx->key[5], + k6 = key_ctx->key[6], k7 = key_ctx->key[7], + k8 = key_ctx->key[8], k9 = key_ctx->key[9], + k10 = key_ctx->key[10], k11 = key_ctx->key[11], + k12 = key_ctx->key[12], k13 = key_ctx->key[13], + k14 = key_ctx->key[14], k15 = key_ctx->key[15], + k16 = key_ctx->key[16]; + u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], + t2 = key_ctx->tweak[2]; u64 tmp; b0 -= k3; diff --git a/drivers/staging/skein/threefish256Block.c b/drivers/staging/skein/threefish256Block.c index ee21aef24573..1329c71697ed 100644 --- a/drivers/staging/skein/threefish256Block.c +++ b/drivers/staging/skein/threefish256Block.c @@ -2,16 +2,16 @@ #include -void threefish_encrypt_256(struct threefish_key *keyCtx, u64 *input, +void threefish_encrypt_256(struct threefish_key *key_ctx, u64 *input, u64 *output) { u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3]; - u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1], - k2 = keyCtx->key[2], k3 = keyCtx->key[3], - k4 = keyCtx->key[4]; - u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], - t2 = keyCtx->tweak[2]; + b2 = input[2], b3 = input[3]; + u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], + k2 = key_ctx->key[2], k3 = key_ctx->key[3], + k4 = key_ctx->key[4]; + u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], + t2 = key_ctx->tweak[2]; b1 += k1 + t0; b0 += b1 + k0; @@ -495,16 +495,16 @@ void threefish_encrypt_256(struct threefish_key *keyCtx, u64 *input, output[3] = b3 + k1 + 18; } -void threefish_decrypt_256(struct threefish_key *keyCtx, u64 *input, +void threefish_decrypt_256(struct threefish_key *key_ctx, u64 *input, u64 *output) { u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3]; - u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1], - k2 = keyCtx->key[2], k3 = keyCtx->key[3], - k4 = keyCtx->key[4]; - u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], - t2 = keyCtx->tweak[2]; + b2 = input[2], b3 = input[3]; + u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], + k2 = key_ctx->key[2], k3 = key_ctx->key[3], + k4 = key_ctx->key[4]; + u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], + t2 = key_ctx->tweak[2]; u64 tmp; diff --git a/drivers/staging/skein/threefish512Block.c b/drivers/staging/skein/threefish512Block.c index c4ad1b458a36..db50d83933dc 100644 --- a/drivers/staging/skein/threefish512Block.c +++ b/drivers/staging/skein/threefish512Block.c @@ -2,20 +2,20 @@ #include -void threefish_encrypt_512(struct threefish_key *keyCtx, u64 *input, +void threefish_encrypt_512(struct threefish_key *key_ctx, u64 *input, u64 *output) { u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3], - b4 = input[4], b5 = input[5], - b6 = input[6], b7 = input[7]; - u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1], - k2 = keyCtx->key[2], k3 = keyCtx->key[3], - k4 = keyCtx->key[4], k5 = keyCtx->key[5], - k6 = keyCtx->key[6], k7 = keyCtx->key[7], - k8 = keyCtx->key[8]; - u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], - t2 = keyCtx->tweak[2]; + b2 = input[2], b3 = input[3], + b4 = input[4], b5 = input[5], + b6 = input[6], b7 = input[7]; + u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], + k2 = key_ctx->key[2], k3 = key_ctx->key[3], + k4 = key_ctx->key[4], k5 = key_ctx->key[5], + k6 = key_ctx->key[6], k7 = key_ctx->key[7], + k8 = key_ctx->key[8]; + u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], + t2 = key_ctx->tweak[2]; b1 += k1; b0 += b1 + k0; @@ -963,20 +963,20 @@ void threefish_encrypt_512(struct threefish_key *keyCtx, u64 *input, output[7] = b7 + k7 + 18; } -void threefish_decrypt_512(struct threefish_key *keyCtx, u64 *input, +void threefish_decrypt_512(struct threefish_key *key_ctx, u64 *input, u64 *output) { u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3], - b4 = input[4], b5 = input[5], - b6 = input[6], b7 = input[7]; - u64 k0 = keyCtx->key[0], k1 = keyCtx->key[1], - k2 = keyCtx->key[2], k3 = keyCtx->key[3], - k4 = keyCtx->key[4], k5 = keyCtx->key[5], - k6 = keyCtx->key[6], k7 = keyCtx->key[7], - k8 = keyCtx->key[8]; - u64 t0 = keyCtx->tweak[0], t1 = keyCtx->tweak[1], - t2 = keyCtx->tweak[2]; + b2 = input[2], b3 = input[3], + b4 = input[4], b5 = input[5], + b6 = input[6], b7 = input[7]; + u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], + k2 = key_ctx->key[2], k3 = key_ctx->key[3], + k4 = key_ctx->key[4], k5 = key_ctx->key[5], + k6 = key_ctx->key[6], k7 = key_ctx->key[7], + k8 = key_ctx->key[8]; + u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], + t2 = key_ctx->tweak[2]; u64 tmp; diff --git a/drivers/staging/skein/threefishApi.c b/drivers/staging/skein/threefishApi.c index fce613b5404c..67ba9a6e4b12 100644 --- a/drivers/staging/skein/threefishApi.c +++ b/drivers/staging/skein/threefishApi.c @@ -3,76 +3,76 @@ #include #include -void threefish_set_key(struct threefish_key *keyCtx, - enum threefish_size stateSize, - u64 *keyData, u64 *tweak) +void threefish_set_key(struct threefish_key *key_ctx, + enum threefish_size state_size, + u64 *key_data, u64 *tweak) { - int keyWords = stateSize / 64; + int key_words = state_size / 64; int i; u64 parity = KeyScheduleConst; - keyCtx->tweak[0] = tweak[0]; - keyCtx->tweak[1] = tweak[1]; - keyCtx->tweak[2] = tweak[0] ^ tweak[1]; + key_ctx->tweak[0] = tweak[0]; + key_ctx->tweak[1] = tweak[1]; + key_ctx->tweak[2] = tweak[0] ^ tweak[1]; - for (i = 0; i < keyWords; i++) { - keyCtx->key[i] = keyData[i]; - parity ^= keyData[i]; + for (i = 0; i < key_words; i++) { + key_ctx->key[i] = key_data[i]; + parity ^= key_data[i]; } - keyCtx->key[i] = parity; - keyCtx->stateSize = stateSize; + key_ctx->key[i] = parity; + key_ctx->state_size = state_size; } -void threefish_encrypt_block_bytes(struct threefish_key *keyCtx, u8 *in, +void threefish_encrypt_block_bytes(struct threefish_key *key_ctx, u8 *in, u8 *out) { u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ u64 cipher[SKEIN_MAX_STATE_WORDS]; - Skein_Get64_LSB_First(plain, in, keyCtx->stateSize / 64); - threefish_encrypt_block_words(keyCtx, plain, cipher); - Skein_Put64_LSB_First(out, cipher, keyCtx->stateSize / 8); + Skein_Get64_LSB_First(plain, in, key_ctx->state_size / 64); + threefish_encrypt_block_words(key_ctx, plain, cipher); + Skein_Put64_LSB_First(out, cipher, key_ctx->state_size / 8); } -void threefish_encrypt_block_words(struct threefish_key *keyCtx, u64 *in, +void threefish_encrypt_block_words(struct threefish_key *key_ctx, u64 *in, u64 *out) { - switch (keyCtx->stateSize) { + switch (key_ctx->state_size) { case Threefish256: - threefish_encrypt_256(keyCtx, in, out); + threefish_encrypt_256(key_ctx, in, out); break; case Threefish512: - threefish_encrypt_512(keyCtx, in, out); + threefish_encrypt_512(key_ctx, in, out); break; case Threefish1024: - threefish_encrypt_1024(keyCtx, in, out); + threefish_encrypt_1024(key_ctx, in, out); break; } } -void threefish_decrypt_block_bytes(struct threefish_key *keyCtx, u8 *in, +void threefish_decrypt_block_bytes(struct threefish_key *key_ctx, u8 *in, u8 *out) { u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ u64 cipher[SKEIN_MAX_STATE_WORDS]; - Skein_Get64_LSB_First(cipher, in, keyCtx->stateSize / 64); - threefish_decrypt_block_words(keyCtx, cipher, plain); - Skein_Put64_LSB_First(out, plain, keyCtx->stateSize / 8); + Skein_Get64_LSB_First(cipher, in, key_ctx->state_size / 64); + threefish_decrypt_block_words(key_ctx, cipher, plain); + Skein_Put64_LSB_First(out, plain, key_ctx->state_size / 8); } -void threefish_decrypt_block_words(struct threefish_key *keyCtx, u64 *in, +void threefish_decrypt_block_words(struct threefish_key *key_ctx, u64 *in, u64 *out) { - switch (keyCtx->stateSize) { + switch (key_ctx->state_size) { case Threefish256: - threefish_decrypt_256(keyCtx, in, out); + threefish_decrypt_256(key_ctx, in, out); break; case Threefish512: - threefish_decrypt_512(keyCtx, in, out); + threefish_decrypt_512(key_ctx, in, out); break; case Threefish1024: - threefish_decrypt_1024(keyCtx, in, out); + threefish_decrypt_1024(key_ctx, in, out); break; } } -- cgit v1.2.3 From 3201b7f25e3b9843a4f475f7d61f0fbe8de3d208 Mon Sep 17 00:00:00 2001 From: Anton Saraev Date: Mon, 19 May 2014 12:09:56 +0400 Subject: staging: crypto: skein: rename skein1024_ctx to skein_1024_ctx Code have skein_512_ctx and skein_256_ctx but skein1024_ctx. It would be logical to convert these names to a single form. Signed-off-by: Anton Saraev Reviewed-by: Jake Edge Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/include/skein.h | 14 +++++++------- drivers/staging/skein/include/skeinApi.h | 2 +- drivers/staging/skein/include/skein_block.h | 2 +- drivers/staging/skein/skein.c | 12 ++++++------ drivers/staging/skein/skeinBlockNo3F.c | 2 +- drivers/staging/skein/skein_block.c | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/staging/skein/include/skein.h b/drivers/staging/skein/include/skein.h index deaa9c867343..09e96d6f8d56 100644 --- a/drivers/staging/skein/include/skein.h +++ b/drivers/staging/skein/include/skein.h @@ -81,7 +81,7 @@ struct skein_512_ctx { /* 512-bit Skein hash context structure */ u8 b[SKEIN_512_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ }; -struct skein1024_ctx { /* 1024-bit Skein hash context structure */ +struct skein_1024_ctx { /* 1024-bit Skein hash context structure */ struct skein_ctx_hdr h; /* common header context variables */ u64 X[SKEIN1024_STATE_WORDS]; /* chaining variables */ u8 b[SKEIN1024_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ @@ -90,18 +90,18 @@ struct skein1024_ctx { /* 1024-bit Skein hash context structure */ /* Skein APIs for (incremental) "straight hashing" */ int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len); int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len); -int skein_1024_init(struct skein1024_ctx *ctx, size_t hash_bit_len); +int skein_1024_init(struct skein_1024_ctx *ctx, size_t hash_bit_len); int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg, size_t msg_byte_cnt); int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg, size_t msg_byte_cnt); -int skein_1024_update(struct skein1024_ctx *ctx, const u8 *msg, +int skein_1024_update(struct skein_1024_ctx *ctx, const u8 *msg, size_t msg_byte_cnt); int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val); int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val); -int skein_1024_final(struct skein1024_ctx *ctx, u8 *hash_val); +int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val); /* ** Skein APIs for "extended" initialization: MAC keys, tree hashing. @@ -121,7 +121,7 @@ int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hash_bit_len, u64 tree_info, const u8 *key, size_t key_bytes); int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hash_bit_len, u64 tree_info, const u8 *key, size_t key_bytes); -int skein_1024_init_ext(struct skein1024_ctx *ctx, size_t hash_bit_len, +int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t hash_bit_len, u64 tree_info, const u8 *key, size_t key_bytes); /* @@ -131,7 +131,7 @@ int skein_1024_init_ext(struct skein1024_ctx *ctx, size_t hash_bit_len, */ int skein_256_final_pad(struct skein_256_ctx *ctx, u8 *hash_val); int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hash_val); -int skein_1024_final_pad(struct skein1024_ctx *ctx, u8 *hash_val); +int skein_1024_final_pad(struct skein_1024_ctx *ctx, u8 *hash_val); #ifndef SKEIN_TREE_HASH #define SKEIN_TREE_HASH (1) @@ -139,7 +139,7 @@ int skein_1024_final_pad(struct skein1024_ctx *ctx, u8 *hash_val); #if SKEIN_TREE_HASH int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val); int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val); -int skein_1024_output(struct skein1024_ctx *ctx, u8 *hash_val); +int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); #endif /***************************************************************** diff --git a/drivers/staging/skein/include/skeinApi.h b/drivers/staging/skein/include/skeinApi.h index 11ecab83fea6..850d5c9bc4a9 100644 --- a/drivers/staging/skein/include/skeinApi.h +++ b/drivers/staging/skein/include/skeinApi.h @@ -105,7 +105,7 @@ struct skein_ctx { struct skein_ctx_hdr h; struct skein_256_ctx s256; struct skein_512_ctx s512; - struct skein1024_ctx s1024; + struct skein_1024_ctx s1024; } m; }; diff --git a/drivers/staging/skein/include/skein_block.h b/drivers/staging/skein/include/skein_block.h index ec787a3fbebd..a8dd083940b4 100644 --- a/drivers/staging/skein/include/skein_block.h +++ b/drivers/staging/skein/include/skein_block.h @@ -16,7 +16,7 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, size_t blk_cnt, size_t byte_cnt_add); void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, size_t blk_cnt, size_t byte_cnt_add); -void skein_1024_process_block(struct skein1024_ctx *ctx, const u8 *blk_ptr, +void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, size_t blk_cnt, size_t byte_cnt_add); #endif diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c index d4f3534feae0..43e7757872fa 100644 --- a/drivers/staging/skein/skein.c +++ b/drivers/staging/skein/skein.c @@ -476,7 +476,7 @@ int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* init the context for a straight hashing operation */ -int skein_1024_init(struct skein1024_ctx *ctx, size_t hash_bit_len) +int skein_1024_init(struct skein_1024_ctx *ctx, size_t hash_bit_len) { union { u8 b[SKEIN1024_STATE_BYTES]; @@ -531,7 +531,7 @@ int skein_1024_init(struct skein1024_ctx *ctx, size_t hash_bit_len) /* init the context for a MAC and/or tree hash operation */ /* [identical to skein_1024_init() when key_bytes == 0 && \ * tree_info == SKEIN_CFG_TREE_INFO_SEQUENTIAL] */ -int skein_1024_init_ext(struct skein1024_ctx *ctx, size_t hash_bit_len, +int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t hash_bit_len, u64 tree_info, const u8 *key, size_t key_bytes) { union { @@ -592,7 +592,7 @@ int skein_1024_init_ext(struct skein1024_ctx *ctx, size_t hash_bit_len, /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* process the input bytes */ -int skein_1024_update(struct skein1024_ctx *ctx, const u8 *msg, +int skein_1024_update(struct skein_1024_ctx *ctx, const u8 *msg, size_t msg_byte_cnt) { size_t n; @@ -647,7 +647,7 @@ int skein_1024_update(struct skein1024_ctx *ctx, const u8 *msg, /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the result */ -int skein_1024_final(struct skein1024_ctx *ctx, u8 *hash_val) +int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val) { size_t i, n, byte_cnt; u64 X[SKEIN1024_STATE_WORDS]; @@ -743,7 +743,7 @@ int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hash_val) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* finalize the hash computation and output the block, no OUTPUT stage */ -int skein_1024_final_pad(struct skein1024_ctx *ctx, u8 *hash_val) +int skein_1024_final_pad(struct skein_1024_ctx *ctx, u8 *hash_val) { /* catch uninitialized context */ Skein_Assert(ctx->h.b_cnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); @@ -844,7 +844,7 @@ int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val) /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* just do the OUTPUT stage */ -int skein_1024_output(struct skein1024_ctx *ctx, u8 *hash_val) +int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val) { size_t i, n, byte_cnt; u64 X[SKEIN1024_STATE_WORDS]; diff --git a/drivers/staging/skein/skeinBlockNo3F.c b/drivers/staging/skein/skeinBlockNo3F.c index 041e5ae20b78..55c6831093d6 100644 --- a/drivers/staging/skein/skeinBlockNo3F.c +++ b/drivers/staging/skein/skeinBlockNo3F.c @@ -111,7 +111,7 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, ctx->h.T[1] = tweak[1]; } -void skein_1024_process_block(struct skein1024_ctx *ctx, const u8 *blk_ptr, +void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, size_t blk_cnt, size_t byte_cnt_add) { struct threefish_key key; diff --git a/drivers/staging/skein/skein_block.c b/drivers/staging/skein/skein_block.c index a51aa57b473d..c9db6d664cb1 100644 --- a/drivers/staging/skein/skein_block.c +++ b/drivers/staging/skein/skein_block.c @@ -479,7 +479,7 @@ unsigned int skein_512_unroll_cnt(void) /***************************** Skein1024 ******************************/ #if !(SKEIN_USE_ASM & 1024) -void skein_1024_process_block(struct skein1024_ctx *ctx, const u8 *blk_ptr, +void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, size_t blk_cnt, size_t byte_cnt_add) { /* do it in C, always looping (unrolled is bigger AND slower!) */ enum { -- cgit v1.2.3 From 9435d3ace68afea0533954e69cf0f8569fb7dc42 Mon Sep 17 00:00:00 2001 From: Anton Saraev Date: Mon, 19 May 2014 12:09:57 +0400 Subject: staging: crypto: skein: rename enums Linux Kernel use capitalized names for enum. To prepare skein driver to mainline inclusion, we rename all enums to capitalized names. Signed-off-by: Anton Saraev Reviewed-by: Jake Edge Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/include/skein.h | 6 +++--- drivers/staging/skein/include/skeinApi.h | 8 ++++---- drivers/staging/skein/include/threefishApi.h | 18 +++++++++--------- drivers/staging/skein/skeinApi.c | 24 ++++++++++++------------ drivers/staging/skein/skeinBlockNo3F.c | 6 +++--- drivers/staging/skein/skein_block.c | 6 +++--- drivers/staging/skein/threefishApi.c | 12 ++++++------ 7 files changed, 40 insertions(+), 40 deletions(-) diff --git a/drivers/staging/skein/include/skein.h b/drivers/staging/skein/include/skein.h index 09e96d6f8d56..8ecd720f981c 100644 --- a/drivers/staging/skein/include/skein.h +++ b/drivers/staging/skein/include/skein.h @@ -293,7 +293,7 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); ** Skein block function constants (shared across Ref and Opt code) ******************************************************************/ enum { - /* Skein_256 round rotation constants */ + /* SKEIN_256 round rotation constants */ R_256_0_0 = 14, R_256_0_1 = 16, R_256_1_0 = 52, R_256_1_1 = 57, R_256_2_0 = 23, R_256_2_1 = 40, @@ -303,7 +303,7 @@ enum { R_256_6_0 = 58, R_256_6_1 = 22, R_256_7_0 = 32, R_256_7_1 = 32, - /* Skein_512 round rotation constants */ + /* SKEIN_512 round rotation constants */ R_512_0_0 = 46, R_512_0_1 = 36, R_512_0_2 = 19, R_512_0_3 = 37, R_512_1_0 = 33, R_512_1_1 = 27, R_512_1_2 = 14, R_512_1_3 = 42, R_512_2_0 = 17, R_512_2_1 = 49, R_512_2_2 = 36, R_512_2_3 = 39, @@ -313,7 +313,7 @@ enum { R_512_6_0 = 25, R_512_6_1 = 29, R_512_6_2 = 39, R_512_6_3 = 43, R_512_7_0 = 8, R_512_7_1 = 35, R_512_7_2 = 56, R_512_7_3 = 22, - /* Skein1024 round rotation constants */ + /* SKEIN_1024 round rotation constants */ R1024_0_0 = 24, R1024_0_1 = 13, R1024_0_2 = 8, R1024_0_3 = 47, R1024_0_4 = 8, R1024_0_5 = 17, R1024_0_6 = 22, R1024_0_7 = 37, R1024_1_0 = 38, R1024_1_1 = 19, R1024_1_2 = 10, R1024_1_3 = 55, diff --git a/drivers/staging/skein/include/skeinApi.h b/drivers/staging/skein/include/skeinApi.h index 850d5c9bc4a9..b4e879d43d8a 100644 --- a/drivers/staging/skein/include/skeinApi.h +++ b/drivers/staging/skein/include/skeinApi.h @@ -50,7 +50,7 @@ OTHER DEALINGS IN THE SOFTWARE. * struct skein_ctx ctx; // a Skein hash or MAC context * * // prepare context, here for a Skein with a state size of 512 bits. - * skein_ctx_prepare(&ctx, Skein512); + * skein_ctx_prepare(&ctx, SKEIN_512); * * // Initialize the context to set the requested hash length in bits * // here request a output hash size of 31 bits (Skein supports variable @@ -85,9 +85,9 @@ OTHER DEALINGS IN THE SOFTWARE. * Which Skein size to use */ enum skein_size { - Skein256 = 256, /*!< Skein with 256 bit state */ - Skein512 = 512, /*!< Skein with 512 bit state */ - Skein1024 = 1024 /*!< Skein with 1024 bit state */ + SKEIN_256 = 256, /*!< Skein with 256 bit state */ + SKEIN_512 = 512, /*!< Skein with 512 bit state */ + SKEIN_1024 = 1024 /*!< Skein with 1024 bit state */ }; /** diff --git a/drivers/staging/skein/include/threefishApi.h b/drivers/staging/skein/include/threefishApi.h index 37f6e63b2c30..63030e52b9a0 100644 --- a/drivers/staging/skein/include/threefishApi.h +++ b/drivers/staging/skein/include/threefishApi.h @@ -17,14 +17,14 @@ * functions. * @code - // Threefish cipher context data - struct threefish_key key_ctx; + // Threefish cipher context data + struct threefish_key key_ctx; - // Initialize the context - threefish_set_key(&key_ctx, Threefish512, key, tweak); + // Initialize the context + threefish_set_key(&key_ctx, THREEFISH_512, key, tweak); - // Encrypt - threefish_encrypt_block_bytes(&key_ctx, input, cipher); + // Encrypt + threefish_encrypt_block_bytes(&key_ctx, input, cipher); @endcode */ @@ -37,9 +37,9 @@ * Which Threefish size to use */ enum threefish_size { - Threefish256 = 256, /*!< Skein with 256 bit state */ - Threefish512 = 512, /*!< Skein with 512 bit state */ - Threefish1024 = 1024 /*!< Skein with 1024 bit state */ + THREEFISH_256 = 256, /*!< Skein with 256 bit state */ + THREEFISH_512 = 512, /*!< Skein with 512 bit state */ + THREEFISH_1024 = 1024 /*!< Skein with 1024 bit state */ }; /** diff --git a/drivers/staging/skein/skeinApi.c b/drivers/staging/skein/skeinApi.c index 3426392888e2..87b3ff23b49c 100644 --- a/drivers/staging/skein/skeinApi.c +++ b/drivers/staging/skein/skeinApi.c @@ -57,15 +57,15 @@ int skein_init(struct skein_ctx *ctx, size_t hash_bit_len) * the save chaining variables. */ switch (ctx->skein_size) { - case Skein256: + case SKEIN_256: ret = skein_256_init_ext(&ctx->m.s256, hash_bit_len, tree_info, NULL, 0); break; - case Skein512: + case SKEIN_512: ret = skein_512_init_ext(&ctx->m.s512, hash_bit_len, tree_info, NULL, 0); break; - case Skein1024: + case SKEIN_1024: ret = skein_1024_init_ext(&ctx->m.s1024, hash_bit_len, tree_info, NULL, 0); break; @@ -97,18 +97,18 @@ int skein_mac_init(struct skein_ctx *ctx, const u8 *key, size_t key_len, Skein_Assert(hash_bit_len, SKEIN_BAD_HASHLEN); switch (ctx->skein_size) { - case Skein256: + case SKEIN_256: ret = skein_256_init_ext(&ctx->m.s256, hash_bit_len, tree_info, (const u8 *)key, key_len); break; - case Skein512: + case SKEIN_512: ret = skein_512_init_ext(&ctx->m.s512, hash_bit_len, tree_info, (const u8 *)key, key_len); break; - case Skein1024: + case SKEIN_1024: ret = skein_1024_init_ext(&ctx->m.s1024, hash_bit_len, tree_info, (const u8 *)key, key_len); @@ -152,15 +152,15 @@ int skein_update(struct skein_ctx *ctx, const u8 *msg, Skein_Assert(ctx, SKEIN_FAIL); switch (ctx->skein_size) { - case Skein256: + case SKEIN_256: ret = skein_256_update(&ctx->m.s256, (const u8 *)msg, msg_byte_cnt); break; - case Skein512: + case SKEIN_512: ret = skein_512_update(&ctx->m.s512, (const u8 *)msg, msg_byte_cnt); break; - case Skein1024: + case SKEIN_1024: ret = skein_1024_update(&ctx->m.s1024, (const u8 *)msg, msg_byte_cnt); break; @@ -225,13 +225,13 @@ int skein_final(struct skein_ctx *ctx, u8 *hash) Skein_Assert(ctx, SKEIN_FAIL); switch (ctx->skein_size) { - case Skein256: + case SKEIN_256: ret = skein_256_final(&ctx->m.s256, (u8 *)hash); break; - case Skein512: + case SKEIN_512: ret = skein_512_final(&ctx->m.s512, (u8 *)hash); break; - case Skein1024: + case SKEIN_1024: ret = skein_1024_final(&ctx->m.s1024, (u8 *)hash); break; } diff --git a/drivers/staging/skein/skeinBlockNo3F.c b/drivers/staging/skein/skeinBlockNo3F.c index 55c6831093d6..716b78e6f83f 100644 --- a/drivers/staging/skein/skeinBlockNo3F.c +++ b/drivers/staging/skein/skeinBlockNo3F.c @@ -34,7 +34,7 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, tweak[0] |= (words[1] & 0xffffffffL) << 32; tweak[1] |= words[2] & 0xffffffffL; - threefish_set_key(&key, Threefish256, ctx->X, tweak); + threefish_set_key(&key, THREEFISH_256, ctx->X, tweak); /* get input block in little-endian format */ Skein_Get64_LSB_First(w, blk_ptr, SKEIN_256_STATE_WORDS); @@ -85,7 +85,7 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, tweak[0] |= (words[1] & 0xffffffffL) << 32; tweak[1] |= words[2] & 0xffffffffL; - threefish_set_key(&key, Threefish512, ctx->X, tweak); + threefish_set_key(&key, THREEFISH_512, ctx->X, tweak); /* get input block in little-endian format */ Skein_Get64_LSB_First(w, blk_ptr, SKEIN_512_STATE_WORDS); @@ -140,7 +140,7 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, tweak[0] |= (words[1] & 0xffffffffL) << 32; tweak[1] |= words[2] & 0xffffffffL; - threefish_set_key(&key, Threefish1024, ctx->X, tweak); + threefish_set_key(&key, THREEFISH_1024, ctx->X, tweak); /* get input block in little-endian format */ Skein_Get64_LSB_First(w, blk_ptr, SKEIN1024_STATE_WORDS); diff --git a/drivers/staging/skein/skein_block.c b/drivers/staging/skein/skein_block.c index c9db6d664cb1..ebd4af1aaae5 100644 --- a/drivers/staging/skein/skein_block.c +++ b/drivers/staging/skein/skein_block.c @@ -37,7 +37,7 @@ #define DebugSaveTweak(ctx) #endif -/***************************** Skein_256 ******************************/ +/***************************** SKEIN_256 ******************************/ #if !(SKEIN_USE_ASM & 256) void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, size_t blk_cnt, size_t byte_cnt_add) @@ -246,7 +246,7 @@ unsigned int skein_256_unroll_cnt(void) #endif #endif -/***************************** Skein_512 ******************************/ +/***************************** SKEIN_512 ******************************/ #if !(SKEIN_USE_ASM & 512) void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, size_t blk_cnt, size_t byte_cnt_add) @@ -477,7 +477,7 @@ unsigned int skein_512_unroll_cnt(void) #endif #endif -/***************************** Skein1024 ******************************/ +/***************************** SKEIN_1024 ******************************/ #if !(SKEIN_USE_ASM & 1024) void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, size_t blk_cnt, size_t byte_cnt_add) diff --git a/drivers/staging/skein/threefishApi.c b/drivers/staging/skein/threefishApi.c index 67ba9a6e4b12..17a314b8d65a 100644 --- a/drivers/staging/skein/threefishApi.c +++ b/drivers/staging/skein/threefishApi.c @@ -38,13 +38,13 @@ void threefish_encrypt_block_words(struct threefish_key *key_ctx, u64 *in, u64 *out) { switch (key_ctx->state_size) { - case Threefish256: + case THREEFISH_256: threefish_encrypt_256(key_ctx, in, out); break; - case Threefish512: + case THREEFISH_512: threefish_encrypt_512(key_ctx, in, out); break; - case Threefish1024: + case THREEFISH_1024: threefish_encrypt_1024(key_ctx, in, out); break; } @@ -65,13 +65,13 @@ void threefish_decrypt_block_words(struct threefish_key *key_ctx, u64 *in, u64 *out) { switch (key_ctx->state_size) { - case Threefish256: + case THREEFISH_256: threefish_decrypt_256(key_ctx, in, out); break; - case Threefish512: + case THREEFISH_512: threefish_decrypt_512(key_ctx, in, out); break; - case Threefish1024: + case THREEFISH_1024: threefish_decrypt_1024(key_ctx, in, out); break; } -- cgit v1.2.3 From 0264b7b7fb44e78414d16fa5142cea4b9799609a Mon Sep 17 00:00:00 2001 From: Anton Saraev Date: Mon, 19 May 2014 12:09:58 +0400 Subject: staging: crypto: skein: rename macros Mixing upper and lower case in names of macros like It_Is_Macro is not accepted in the Linux Kernel. To prepare skein driver for mainline inclusion, we rename all macros to uppercase or lowercase names. Signed-off-by: Anton Saraev Reviewed-by: Jake Edge Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/include/skein.h | 75 +++---- drivers/staging/skein/include/skein_iv.h | 6 +- drivers/staging/skein/include/threefishApi.h | 2 +- drivers/staging/skein/skein.c | 262 +++++++++++------------ drivers/staging/skein/skeinApi.c | 22 +- drivers/staging/skein/skeinBlockNo3F.c | 20 +- drivers/staging/skein/skein_block.c | 308 +++++++++++++-------------- drivers/staging/skein/threefishApi.c | 10 +- 8 files changed, 353 insertions(+), 352 deletions(-) diff --git a/drivers/staging/skein/include/skein.h b/drivers/staging/skein/include/skein.h index 8ecd720f981c..2c87ff74aaea 100644 --- a/drivers/staging/skein/include/skein.h +++ b/drivers/staging/skein/include/skein.h @@ -28,15 +28,15 @@ ** ***************************************************************************/ -#ifndef RotL_64 -#define RotL_64(x, N) (((x) << (N)) | ((x) >> (64-(N)))) +#ifndef rotl_64 +#define rotl_64(x, N) (((x) << (N)) | ((x) >> (64-(N)))) #endif /* below two prototype assume we are handed aligned data */ -#define Skein_Put64_LSB_First(dst08, src64, b_cnt) memcpy(dst08, src64, b_cnt) -#define Skein_Get64_LSB_First(dst64, src08, w_cnt) \ +#define skein_put64_lsb_first(dst08, src64, b_cnt) memcpy(dst08, src64, b_cnt) +#define skein_get64_lsb_first(dst64, src08, w_cnt) \ memcpy(dst64, src08, 8*(w_cnt)) -#define Skein_Swap64(w64) (w64) +#define skein_swap64(w64) (w64) enum { SKEIN_SUCCESS = 0, /* return codes from Skein calls */ @@ -48,20 +48,20 @@ enum { #define SKEIN_256_STATE_WORDS (4) #define SKEIN_512_STATE_WORDS (8) -#define SKEIN1024_STATE_WORDS (16) +#define SKEIN_1024_STATE_WORDS (16) #define SKEIN_MAX_STATE_WORDS (16) #define SKEIN_256_STATE_BYTES (8*SKEIN_256_STATE_WORDS) #define SKEIN_512_STATE_BYTES (8*SKEIN_512_STATE_WORDS) -#define SKEIN1024_STATE_BYTES (8*SKEIN1024_STATE_WORDS) +#define SKEIN_1024_STATE_BYTES (8*SKEIN_1024_STATE_WORDS) #define SKEIN_256_STATE_BITS (64*SKEIN_256_STATE_WORDS) #define SKEIN_512_STATE_BITS (64*SKEIN_512_STATE_WORDS) -#define SKEIN1024_STATE_BITS (64*SKEIN1024_STATE_WORDS) +#define SKEIN_1024_STATE_BITS (64*SKEIN_1024_STATE_WORDS) #define SKEIN_256_BLOCK_BYTES (8*SKEIN_256_STATE_WORDS) #define SKEIN_512_BLOCK_BYTES (8*SKEIN_512_STATE_WORDS) -#define SKEIN1024_BLOCK_BYTES (8*SKEIN1024_STATE_WORDS) +#define SKEIN_1024_BLOCK_BYTES (8*SKEIN_1024_STATE_WORDS) struct skein_ctx_hdr { size_t hash_bit_len; /* size of hash result, in bits */ @@ -83,8 +83,8 @@ struct skein_512_ctx { /* 512-bit Skein hash context structure */ struct skein_1024_ctx { /* 1024-bit Skein hash context structure */ struct skein_ctx_hdr h; /* common header context variables */ - u64 X[SKEIN1024_STATE_WORDS]; /* chaining variables */ - u8 b[SKEIN1024_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ + u64 X[SKEIN_1024_STATE_WORDS]; /* chaining variables */ + u8 b[SKEIN_1024_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ }; /* Skein APIs for (incremental) "straight hashing" */ @@ -232,44 +232,44 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); ** Skein macros for getting/setting tweak words, etc. ** These are useful for partial input bytes, hash tree init/update, etc. **/ -#define Skein_Get_Tweak(ctx_ptr, TWK_NUM) ((ctx_ptr)->h.T[TWK_NUM]) -#define Skein_Set_Tweak(ctx_ptr, TWK_NUM, t_val) { \ +#define skein_get_tweak(ctx_ptr, TWK_NUM) ((ctx_ptr)->h.T[TWK_NUM]) +#define skein_set_tweak(ctx_ptr, TWK_NUM, t_val) { \ (ctx_ptr)->h.T[TWK_NUM] = (t_val); \ } -#define Skein_Get_T0(ctx_ptr) Skein_Get_Tweak(ctx_ptr, 0) -#define Skein_Get_T1(ctx_ptr) Skein_Get_Tweak(ctx_ptr, 1) -#define Skein_Set_T0(ctx_ptr, T0) Skein_Set_Tweak(ctx_ptr, 0, T0) -#define Skein_Set_T1(ctx_ptr, T1) Skein_Set_Tweak(ctx_ptr, 1, T1) +#define skein_get_T0(ctx_ptr) skein_get_tweak(ctx_ptr, 0) +#define skein_get_T1(ctx_ptr) skein_get_tweak(ctx_ptr, 1) +#define skein_set_T0(ctx_ptr, T0) skein_set_tweak(ctx_ptr, 0, T0) +#define skein_set_T1(ctx_ptr, T1) skein_set_tweak(ctx_ptr, 1, T1) /* set both tweak words at once */ -#define Skein_Set_T0_T1(ctx_ptr, T0, T1) \ - { \ - Skein_Set_T0(ctx_ptr, (T0)); \ - Skein_Set_T1(ctx_ptr, (T1)); \ +#define skein_set_T0_T1(ctx_ptr, T0, T1) \ + { \ + skein_set_T0(ctx_ptr, (T0)); \ + skein_set_T1(ctx_ptr, (T1)); \ } -#define Skein_Set_Type(ctx_ptr, BLK_TYPE) \ - Skein_Set_T1(ctx_ptr, SKEIN_T1_BLK_TYPE_##BLK_TYPE) +#define skein_set_type(ctx_ptr, BLK_TYPE) \ + skein_set_T1(ctx_ptr, SKEIN_T1_BLK_TYPE_##BLK_TYPE) /* * setup for starting with a new type: * h.T[0]=0; h.T[1] = NEW_TYPE; h.b_cnt=0; */ -#define Skein_Start_New_Type(ctx_ptr, BLK_TYPE) { \ - Skein_Set_T0_T1(ctx_ptr, 0, SKEIN_T1_FLAG_FIRST | \ +#define skein_start_new_type(ctx_ptr, BLK_TYPE) { \ + skein_set_T0_T1(ctx_ptr, 0, SKEIN_T1_FLAG_FIRST | \ SKEIN_T1_BLK_TYPE_##BLK_TYPE); \ (ctx_ptr)->h.b_cnt = 0; \ } -#define Skein_Clear_First_Flag(hdr) { \ +#define skein_clear_first_flag(hdr) { \ (hdr).T[1] &= ~SKEIN_T1_FLAG_FIRST; \ } -#define Skein_Set_Bit_Pad_Flag(hdr) { \ +#define skein_set_bit_pad_flag(hdr) { \ (hdr).T[1] |= SKEIN_T1_FLAG_BIT_PAD; \ } -#define Skein_Set_Tree_Level(hdr, height) { \ +#define skein_set_tree_level(hdr, height) { \ (hdr).T[1] |= SKEIN_T1_TREE_LEVEL(height); \ } @@ -279,15 +279,16 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); #ifdef SKEIN_DEBUG /* examine/display intermediate values? */ #include "skein_debug.h" #else /* default is no callouts */ -#define Skein_Show_Block(bits, ctx, X, blk_ptr, w_ptr, ks_event_ptr, ks_odd_ptr) -#define Skein_Show_Round(bits, ctx, r, X) -#define Skein_Show_R_Ptr(bits, ctx, r, X_ptr) -#define Skein_Show_Final(bits, ctx, cnt, out_ptr) -#define Skein_Show_Key(bits, ctx, key, key_bytes) +#define skein_show_block(bits, ctx, X, blk_ptr, w_ptr, ks_event_ptr, ks_odd_ptr) +#define skein_show_round(bits, ctx, r, X) +#define skein_show_r_ptr(bits, ctx, r, X_ptr) +#define skein_show_final(bits, ctx, cnt, out_ptr) +#define skein_show_key(bits, ctx, key, key_bytes) #endif -#define Skein_Assert(x, ret_code)/* ignore all Asserts, for performance */ -#define Skein_assert(x) +/* ignore all asserts, for performance */ +#define skein_assert_ret(x, ret_code) +#define skein_assert(x) /***************************************************************** ** Skein block function constants (shared across Ref and Opt code) @@ -335,11 +336,11 @@ enum { #ifndef SKEIN_ROUNDS #define SKEIN_256_ROUNDS_TOTAL (72) /* # rounds for diff block sizes */ #define SKEIN_512_ROUNDS_TOTAL (72) -#define SKEIN1024_ROUNDS_TOTAL (80) +#define SKEIN_1024_ROUNDS_TOTAL (80) #else /* allow command-line define in range 8*(5..14) */ #define SKEIN_256_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS/100) + 5) % 10) + 5)) #define SKEIN_512_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS/10) + 5) % 10) + 5)) -#define SKEIN1024_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS) + 5) % 10) + 5)) +#define SKEIN_1024_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS) + 5) % 10) + 5)) #endif #endif /* ifndef _SKEIN_H_ */ diff --git a/drivers/staging/skein/include/skein_iv.h b/drivers/staging/skein/include/skein_iv.h index 8dd5e4d88a1d..7ff93dfd912f 100644 --- a/drivers/staging/skein/include/skein_iv.h +++ b/drivers/staging/skein/include/skein_iv.h @@ -124,7 +124,7 @@ const u64 SKEIN_512_IV_512[] = { }; /* blkSize = 1024 bits. hashSize = 384 bits */ -const u64 SKEIN1024_IV_384[] = { +const u64 SKEIN_1024_IV_384[] = { MK_64(0x5102B6B8, 0xC1894A35), MK_64(0xFEEBC9E3, 0xFE8AF11A), MK_64(0x0C807F06, 0xE32BED71), @@ -144,7 +144,7 @@ const u64 SKEIN1024_IV_384[] = { }; /* blkSize = 1024 bits. hashSize = 512 bits */ -const u64 SKEIN1024_IV_512[] = { +const u64 SKEIN_1024_IV_512[] = { MK_64(0xCAEC0E5D, 0x7C1B1B18), MK_64(0xA01B0E04, 0x5F03E802), MK_64(0x33840451, 0xED912885), @@ -164,7 +164,7 @@ const u64 SKEIN1024_IV_512[] = { }; /* blkSize = 1024 bits. hashSize = 1024 bits */ -const u64 SKEIN1024_IV_1024[] = { +const u64 SKEIN_1024_IV_1024[] = { MK_64(0xD593DA07, 0x41E72355), MK_64(0x15B5E511, 0xAC73E00C), MK_64(0x5180E5AE, 0xBAF2C4F0), diff --git a/drivers/staging/skein/include/threefishApi.h b/drivers/staging/skein/include/threefishApi.h index 63030e52b9a0..96cc0e868f43 100644 --- a/drivers/staging/skein/include/threefishApi.h +++ b/drivers/staging/skein/include/threefishApi.h @@ -31,7 +31,7 @@ #include #include -#define KeyScheduleConst 0x1BD11BDAA9FC1A22L +#define KEY_SCHEDULE_CONST 0x1BD11BDAA9FC1A22L /** * Which Threefish size to use diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c index 43e7757872fa..2a2da983a1cc 100644 --- a/drivers/staging/skein/skein.c +++ b/drivers/staging/skein/skein.c @@ -28,7 +28,7 @@ int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len) u64 w[SKEIN_256_STATE_WORDS]; } cfg; /* config block */ - Skein_Assert(hash_bit_len > 0, SKEIN_BAD_HASHLEN); + skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */ switch (hash_bit_len) { /* use pre-computed values, where available */ @@ -51,13 +51,13 @@ int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len) * precomputed) */ /* set tweaks: T0=0; T1=CFG | FINAL */ - Skein_Start_New_Type(ctx, CFG_FINAL); + skein_start_new_type(ctx, CFG_FINAL); /* set the schema, version */ - cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); + cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER); /* hash result length in bits */ - cfg.w[1] = Skein_Swap64(hash_bit_len); - cfg.w[2] = Skein_Swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); + cfg.w[1] = skein_swap64(hash_bit_len); + cfg.w[2] = skein_swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); /* zero pad config block */ memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); @@ -69,7 +69,7 @@ int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len) } /* The chaining vars ctx->X are now initialized for hash_bit_len. */ /* Set up to process the data message portion of the hash (default) */ - Skein_Start_New_Type(ctx, MSG); /* T0=0, T1= MSG type */ + skein_start_new_type(ctx, MSG); /* T0=0, T1= MSG type */ return SKEIN_SUCCESS; } @@ -86,20 +86,20 @@ int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hash_bit_len, u64 w[SKEIN_256_STATE_WORDS]; } cfg; /* config block */ - Skein_Assert(hash_bit_len > 0, SKEIN_BAD_HASHLEN); - Skein_Assert(key_bytes == 0 || key != NULL, SKEIN_FAIL); + skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); + skein_assert_ret(key_bytes == 0 || key != NULL, SKEIN_FAIL); /* compute the initial chaining values ctx->X[], based on key */ if (key_bytes == 0) { /* is there a key? */ /* no key: use all zeroes as key for config block */ memset(ctx->X, 0, sizeof(ctx->X)); } else { /* here to pre-process a key */ - Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); + skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); /* do a mini-Init right here */ /* set output hash bit count = state size */ ctx->h.hash_bit_len = 8*sizeof(ctx->X); /* set tweaks: T0 = 0; T1 = KEY type */ - Skein_Start_New_Type(ctx, KEY); + skein_start_new_type(ctx, KEY); /* zero the initial chaining variables */ memset(ctx->X, 0, sizeof(ctx->X)); /* hash the key */ @@ -115,24 +115,24 @@ int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hash_bit_len, */ /* output hash bit count */ ctx->h.hash_bit_len = hash_bit_len; - Skein_Start_New_Type(ctx, CFG_FINAL); + skein_start_new_type(ctx, CFG_FINAL); /* pre-pad cfg.w[] with zeroes */ memset(&cfg.w, 0, sizeof(cfg.w)); - cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); + cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER); /* hash result length in bits */ - cfg.w[1] = Skein_Swap64(hash_bit_len); + cfg.w[1] = skein_swap64(hash_bit_len); /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ - cfg.w[2] = Skein_Swap64(tree_info); + cfg.w[2] = skein_swap64(tree_info); - Skein_Show_Key(256, &ctx->h, key, key_bytes); + skein_show_key(256, &ctx->h, key, key_bytes); /* compute the initial chaining values from config block */ skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); /* The chaining vars ctx->X are now initialized */ /* Set up to process the data message portion of the hash (default) */ - Skein_Start_New_Type(ctx, MSG); + skein_start_new_type(ctx, MSG); return SKEIN_SUCCESS; } @@ -145,7 +145,7 @@ int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg, size_t n; /* catch uninitialized context */ - Skein_Assert(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); + skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* process full blocks, if any */ if (msg_byte_cnt + ctx->h.b_cnt > SKEIN_256_BLOCK_BYTES) { @@ -155,13 +155,13 @@ int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg, n = SKEIN_256_BLOCK_BYTES - ctx->h.b_cnt; if (n) { /* check on our logic here */ - Skein_assert(n < msg_byte_cnt); + skein_assert(n < msg_byte_cnt); memcpy(&ctx->b[ctx->h.b_cnt], msg, n); msg_byte_cnt -= n; msg += n; ctx->h.b_cnt += n; } - Skein_assert(ctx->h.b_cnt == SKEIN_256_BLOCK_BYTES); + skein_assert(ctx->h.b_cnt == SKEIN_256_BLOCK_BYTES); skein_256_process_block(ctx, ctx->b, 1, SKEIN_256_BLOCK_BYTES); ctx->h.b_cnt = 0; @@ -178,12 +178,12 @@ int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg, msg_byte_cnt -= n * SKEIN_256_BLOCK_BYTES; msg += n * SKEIN_256_BLOCK_BYTES; } - Skein_assert(ctx->h.b_cnt == 0); + skein_assert(ctx->h.b_cnt == 0); } /* copy any remaining source message data bytes into b[] */ if (msg_byte_cnt) { - Skein_assert(msg_byte_cnt + ctx->h.b_cnt <= + skein_assert(msg_byte_cnt + ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES); memcpy(&ctx->b[ctx->h.b_cnt], msg, msg_byte_cnt); ctx->h.b_cnt += msg_byte_cnt; @@ -199,7 +199,7 @@ int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val) size_t i, n, byte_cnt; u64 X[SKEIN_256_STATE_WORDS]; /* catch uninitialized context */ - Skein_Assert(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); + skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* tag as the final block */ ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; @@ -222,8 +222,8 @@ int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val) memcpy(X, ctx->X, sizeof(X)); for (i = 0; i*SKEIN_256_BLOCK_BYTES < byte_cnt; i++) { /* build the counter block */ - ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); - Skein_Start_New_Type(ctx, OUT_FINAL); + ((u64 *)ctx->b)[0] = skein_swap64((u64) i); + skein_start_new_type(ctx, OUT_FINAL); /* run "counter mode" */ skein_256_process_block(ctx, ctx->b, 1, sizeof(u64)); /* number of output bytes left to go */ @@ -231,9 +231,9 @@ int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val) if (n >= SKEIN_256_BLOCK_BYTES) n = SKEIN_256_BLOCK_BYTES; /* "output" the ctr mode bytes */ - Skein_Put64_LSB_First(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->X, + skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->X, n); - Skein_Show_Final(256, &ctx->h, n, + skein_show_final(256, &ctx->h, n, hash_val+i*SKEIN_256_BLOCK_BYTES); /* restore the counter mode key for next time */ memcpy(ctx->X, X, sizeof(X)); @@ -254,7 +254,7 @@ int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len) u64 w[SKEIN_512_STATE_WORDS]; } cfg; /* config block */ - Skein_Assert(hash_bit_len > 0, SKEIN_BAD_HASHLEN); + skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */ switch (hash_bit_len) { /* use pre-computed values, where available */ @@ -277,13 +277,13 @@ int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len) * precomputed) */ /* set tweaks: T0=0; T1=CFG | FINAL */ - Skein_Start_New_Type(ctx, CFG_FINAL); + skein_start_new_type(ctx, CFG_FINAL); /* set the schema, version */ - cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); + cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER); /* hash result length in bits */ - cfg.w[1] = Skein_Swap64(hash_bit_len); - cfg.w[2] = Skein_Swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); + cfg.w[1] = skein_swap64(hash_bit_len); + cfg.w[2] = skein_swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); /* zero pad config block */ memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); @@ -299,7 +299,7 @@ int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len) * hash_bit_len. */ /* Set up to process the data message portion of the hash (default) */ - Skein_Start_New_Type(ctx, MSG); /* T0=0, T1= MSG type */ + skein_start_new_type(ctx, MSG); /* T0=0, T1= MSG type */ return SKEIN_SUCCESS; } @@ -316,20 +316,20 @@ int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hash_bit_len, u64 w[SKEIN_512_STATE_WORDS]; } cfg; /* config block */ - Skein_Assert(hash_bit_len > 0, SKEIN_BAD_HASHLEN); - Skein_Assert(key_bytes == 0 || key != NULL, SKEIN_FAIL); + skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); + skein_assert_ret(key_bytes == 0 || key != NULL, SKEIN_FAIL); /* compute the initial chaining values ctx->X[], based on key */ if (key_bytes == 0) { /* is there a key? */ /* no key: use all zeroes as key for config block */ memset(ctx->X, 0, sizeof(ctx->X)); } else { /* here to pre-process a key */ - Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); + skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); /* do a mini-Init right here */ /* set output hash bit count = state size */ ctx->h.hash_bit_len = 8*sizeof(ctx->X); /* set tweaks: T0 = 0; T1 = KEY type */ - Skein_Start_New_Type(ctx, KEY); + skein_start_new_type(ctx, KEY); /* zero the initial chaining variables */ memset(ctx->X, 0, sizeof(ctx->X)); /* hash the key */ @@ -344,24 +344,24 @@ int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hash_bit_len, * precomputed for each key) */ ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */ - Skein_Start_New_Type(ctx, CFG_FINAL); + skein_start_new_type(ctx, CFG_FINAL); /* pre-pad cfg.w[] with zeroes */ memset(&cfg.w, 0, sizeof(cfg.w)); - cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); + cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER); /* hash result length in bits */ - cfg.w[1] = Skein_Swap64(hash_bit_len); + cfg.w[1] = skein_swap64(hash_bit_len); /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ - cfg.w[2] = Skein_Swap64(tree_info); + cfg.w[2] = skein_swap64(tree_info); - Skein_Show_Key(512, &ctx->h, key, key_bytes); + skein_show_key(512, &ctx->h, key, key_bytes); /* compute the initial chaining values from config block */ skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); /* The chaining vars ctx->X are now initialized */ /* Set up to process the data message portion of the hash (default) */ - Skein_Start_New_Type(ctx, MSG); + skein_start_new_type(ctx, MSG); return SKEIN_SUCCESS; } @@ -374,7 +374,7 @@ int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg, size_t n; /* catch uninitialized context */ - Skein_Assert(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); + skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* process full blocks, if any */ if (msg_byte_cnt + ctx->h.b_cnt > SKEIN_512_BLOCK_BYTES) { @@ -384,13 +384,13 @@ int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg, n = SKEIN_512_BLOCK_BYTES - ctx->h.b_cnt; if (n) { /* check on our logic here */ - Skein_assert(n < msg_byte_cnt); + skein_assert(n < msg_byte_cnt); memcpy(&ctx->b[ctx->h.b_cnt], msg, n); msg_byte_cnt -= n; msg += n; ctx->h.b_cnt += n; } - Skein_assert(ctx->h.b_cnt == SKEIN_512_BLOCK_BYTES); + skein_assert(ctx->h.b_cnt == SKEIN_512_BLOCK_BYTES); skein_512_process_block(ctx, ctx->b, 1, SKEIN_512_BLOCK_BYTES); ctx->h.b_cnt = 0; @@ -407,12 +407,12 @@ int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg, msg_byte_cnt -= n * SKEIN_512_BLOCK_BYTES; msg += n * SKEIN_512_BLOCK_BYTES; } - Skein_assert(ctx->h.b_cnt == 0); + skein_assert(ctx->h.b_cnt == 0); } /* copy any remaining source message data bytes into b[] */ if (msg_byte_cnt) { - Skein_assert(msg_byte_cnt + ctx->h.b_cnt <= + skein_assert(msg_byte_cnt + ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES); memcpy(&ctx->b[ctx->h.b_cnt], msg, msg_byte_cnt); ctx->h.b_cnt += msg_byte_cnt; @@ -428,7 +428,7 @@ int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val) size_t i, n, byte_cnt; u64 X[SKEIN_512_STATE_WORDS]; /* catch uninitialized context */ - Skein_Assert(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); + skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* tag as the final block */ ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; @@ -451,8 +451,8 @@ int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val) memcpy(X, ctx->X, sizeof(X)); for (i = 0; i*SKEIN_512_BLOCK_BYTES < byte_cnt; i++) { /* build the counter block */ - ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); - Skein_Start_New_Type(ctx, OUT_FINAL); + ((u64 *)ctx->b)[0] = skein_swap64((u64) i); + skein_start_new_type(ctx, OUT_FINAL); /* run "counter mode" */ skein_512_process_block(ctx, ctx->b, 1, sizeof(u64)); /* number of output bytes left to go */ @@ -460,9 +460,9 @@ int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val) if (n >= SKEIN_512_BLOCK_BYTES) n = SKEIN_512_BLOCK_BYTES; /* "output" the ctr mode bytes */ - Skein_Put64_LSB_First(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->X, + skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->X, n); - Skein_Show_Final(512, &ctx->h, n, + skein_show_final(512, &ctx->h, n, hash_val+i*SKEIN_512_BLOCK_BYTES); /* restore the counter mode key for next time */ memcpy(ctx->X, X, sizeof(X)); @@ -479,22 +479,22 @@ int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val) int skein_1024_init(struct skein_1024_ctx *ctx, size_t hash_bit_len) { union { - u8 b[SKEIN1024_STATE_BYTES]; - u64 w[SKEIN1024_STATE_WORDS]; + u8 b[SKEIN_1024_STATE_BYTES]; + u64 w[SKEIN_1024_STATE_WORDS]; } cfg; /* config block */ - Skein_Assert(hash_bit_len > 0, SKEIN_BAD_HASHLEN); + skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); ctx->h.hash_bit_len = hash_bit_len; /* output hash bit count */ switch (hash_bit_len) { /* use pre-computed values, where available */ case 512: - memcpy(ctx->X, SKEIN1024_IV_512, sizeof(ctx->X)); + memcpy(ctx->X, SKEIN_1024_IV_512, sizeof(ctx->X)); break; case 384: - memcpy(ctx->X, SKEIN1024_IV_384, sizeof(ctx->X)); + memcpy(ctx->X, SKEIN_1024_IV_384, sizeof(ctx->X)); break; case 1024: - memcpy(ctx->X, SKEIN1024_IV_1024, sizeof(ctx->X)); + memcpy(ctx->X, SKEIN_1024_IV_1024, sizeof(ctx->X)); break; default: /* here if there is no precomputed IV value available */ @@ -503,13 +503,13 @@ int skein_1024_init(struct skein_1024_ctx *ctx, size_t hash_bit_len) * (could be precomputed) */ /* set tweaks: T0=0; T1=CFG | FINAL */ - Skein_Start_New_Type(ctx, CFG_FINAL); + skein_start_new_type(ctx, CFG_FINAL); /* set the schema, version */ - cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); + cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER); /* hash result length in bits */ - cfg.w[1] = Skein_Swap64(hash_bit_len); - cfg.w[2] = Skein_Swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); + cfg.w[1] = skein_swap64(hash_bit_len); + cfg.w[2] = skein_swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); /* zero pad config block */ memset(&cfg.w[3], 0, sizeof(cfg) - 3*sizeof(cfg.w[0])); @@ -522,7 +522,7 @@ int skein_1024_init(struct skein_1024_ctx *ctx, size_t hash_bit_len) /* The chaining vars ctx->X are now initialized for the hash_bit_len. */ /* Set up to process the data message portion of the hash (default) */ - Skein_Start_New_Type(ctx, MSG); /* T0=0, T1= MSG type */ + skein_start_new_type(ctx, MSG); /* T0=0, T1= MSG type */ return SKEIN_SUCCESS; } @@ -535,24 +535,24 @@ int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t hash_bit_len, u64 tree_info, const u8 *key, size_t key_bytes) { union { - u8 b[SKEIN1024_STATE_BYTES]; - u64 w[SKEIN1024_STATE_WORDS]; + u8 b[SKEIN_1024_STATE_BYTES]; + u64 w[SKEIN_1024_STATE_WORDS]; } cfg; /* config block */ - Skein_Assert(hash_bit_len > 0, SKEIN_BAD_HASHLEN); - Skein_Assert(key_bytes == 0 || key != NULL, SKEIN_FAIL); + skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); + skein_assert_ret(key_bytes == 0 || key != NULL, SKEIN_FAIL); /* compute the initial chaining values ctx->X[], based on key */ if (key_bytes == 0) { /* is there a key? */ /* no key: use all zeroes as key for config block */ memset(ctx->X, 0, sizeof(ctx->X)); } else { /* here to pre-process a key */ - Skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); + skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); /* do a mini-Init right here */ /* set output hash bit count = state size */ ctx->h.hash_bit_len = 8*sizeof(ctx->X); /* set tweaks: T0 = 0; T1 = KEY type */ - Skein_Start_New_Type(ctx, KEY); + skein_start_new_type(ctx, KEY); /* zero the initial chaining variables */ memset(ctx->X, 0, sizeof(ctx->X)); /* hash the key */ @@ -568,24 +568,24 @@ int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t hash_bit_len, */ /* output hash bit count */ ctx->h.hash_bit_len = hash_bit_len; - Skein_Start_New_Type(ctx, CFG_FINAL); + skein_start_new_type(ctx, CFG_FINAL); /* pre-pad cfg.w[] with zeroes */ memset(&cfg.w, 0, sizeof(cfg.w)); - cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); + cfg.w[0] = skein_swap64(SKEIN_SCHEMA_VER); /* hash result length in bits */ - cfg.w[1] = Skein_Swap64(hash_bit_len); + cfg.w[1] = skein_swap64(hash_bit_len); /* tree hash config info (or SKEIN_CFG_TREE_INFO_SEQUENTIAL) */ - cfg.w[2] = Skein_Swap64(tree_info); + cfg.w[2] = skein_swap64(tree_info); - Skein_Show_Key(1024, &ctx->h, key, key_bytes); + skein_show_key(1024, &ctx->h, key, key_bytes); /* compute the initial chaining values from config block */ skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); /* The chaining vars ctx->X are now initialized */ /* Set up to process the data message portion of the hash (default) */ - Skein_Start_New_Type(ctx, MSG); + skein_start_new_type(ctx, MSG); return SKEIN_SUCCESS; } @@ -598,46 +598,46 @@ int skein_1024_update(struct skein_1024_ctx *ctx, const u8 *msg, size_t n; /* catch uninitialized context */ - Skein_Assert(ctx->h.b_cnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); + skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL); /* process full blocks, if any */ - if (msg_byte_cnt + ctx->h.b_cnt > SKEIN1024_BLOCK_BYTES) { + if (msg_byte_cnt + ctx->h.b_cnt > SKEIN_1024_BLOCK_BYTES) { /* finish up any buffered message data */ if (ctx->h.b_cnt) { /* # bytes free in buffer b[] */ - n = SKEIN1024_BLOCK_BYTES - ctx->h.b_cnt; + n = SKEIN_1024_BLOCK_BYTES - ctx->h.b_cnt; if (n) { /* check on our logic here */ - Skein_assert(n < msg_byte_cnt); + skein_assert(n < msg_byte_cnt); memcpy(&ctx->b[ctx->h.b_cnt], msg, n); msg_byte_cnt -= n; msg += n; ctx->h.b_cnt += n; } - Skein_assert(ctx->h.b_cnt == SKEIN1024_BLOCK_BYTES); + skein_assert(ctx->h.b_cnt == SKEIN_1024_BLOCK_BYTES); skein_1024_process_block(ctx, ctx->b, 1, - SKEIN1024_BLOCK_BYTES); + SKEIN_1024_BLOCK_BYTES); ctx->h.b_cnt = 0; } /* * now process any remaining full blocks, directly from input * message data */ - if (msg_byte_cnt > SKEIN1024_BLOCK_BYTES) { + if (msg_byte_cnt > SKEIN_1024_BLOCK_BYTES) { /* number of full blocks to process */ - n = (msg_byte_cnt-1) / SKEIN1024_BLOCK_BYTES; + n = (msg_byte_cnt-1) / SKEIN_1024_BLOCK_BYTES; skein_1024_process_block(ctx, msg, n, - SKEIN1024_BLOCK_BYTES); - msg_byte_cnt -= n * SKEIN1024_BLOCK_BYTES; - msg += n * SKEIN1024_BLOCK_BYTES; + SKEIN_1024_BLOCK_BYTES); + msg_byte_cnt -= n * SKEIN_1024_BLOCK_BYTES; + msg += n * SKEIN_1024_BLOCK_BYTES; } - Skein_assert(ctx->h.b_cnt == 0); + skein_assert(ctx->h.b_cnt == 0); } /* copy any remaining source message data bytes into b[] */ if (msg_byte_cnt) { - Skein_assert(msg_byte_cnt + ctx->h.b_cnt <= - SKEIN1024_BLOCK_BYTES); + skein_assert(msg_byte_cnt + ctx->h.b_cnt <= + SKEIN_1024_BLOCK_BYTES); memcpy(&ctx->b[ctx->h.b_cnt], msg, msg_byte_cnt); ctx->h.b_cnt += msg_byte_cnt; } @@ -650,16 +650,16 @@ int skein_1024_update(struct skein_1024_ctx *ctx, const u8 *msg, int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val) { size_t i, n, byte_cnt; - u64 X[SKEIN1024_STATE_WORDS]; + u64 X[SKEIN_1024_STATE_WORDS]; /* catch uninitialized context */ - Skein_Assert(ctx->h.b_cnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); + skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL); /* tag as the final block */ ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* zero pad b[] if necessary */ - if (ctx->h.b_cnt < SKEIN1024_BLOCK_BYTES) + if (ctx->h.b_cnt < SKEIN_1024_BLOCK_BYTES) memset(&ctx->b[ctx->h.b_cnt], 0, - SKEIN1024_BLOCK_BYTES - ctx->h.b_cnt); + SKEIN_1024_BLOCK_BYTES - ctx->h.b_cnt); /* process the final block */ skein_1024_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); @@ -673,21 +673,21 @@ int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val) memset(ctx->b, 0, sizeof(ctx->b)); /* keep a local copy of counter mode "key" */ memcpy(X, ctx->X, sizeof(X)); - for (i = 0; i*SKEIN1024_BLOCK_BYTES < byte_cnt; i++) { + for (i = 0; i*SKEIN_1024_BLOCK_BYTES < byte_cnt; i++) { /* build the counter block */ - ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); - Skein_Start_New_Type(ctx, OUT_FINAL); + ((u64 *)ctx->b)[0] = skein_swap64((u64) i); + skein_start_new_type(ctx, OUT_FINAL); /* run "counter mode" */ skein_1024_process_block(ctx, ctx->b, 1, sizeof(u64)); /* number of output bytes left to go */ - n = byte_cnt - i*SKEIN1024_BLOCK_BYTES; - if (n >= SKEIN1024_BLOCK_BYTES) - n = SKEIN1024_BLOCK_BYTES; + n = byte_cnt - i*SKEIN_1024_BLOCK_BYTES; + if (n >= SKEIN_1024_BLOCK_BYTES) + n = SKEIN_1024_BLOCK_BYTES; /* "output" the ctr mode bytes */ - Skein_Put64_LSB_First(hash_val+i*SKEIN1024_BLOCK_BYTES, ctx->X, + skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx->X, n); - Skein_Show_Final(1024, &ctx->h, n, - hash_val+i*SKEIN1024_BLOCK_BYTES); + skein_show_final(1024, &ctx->h, n, + hash_val+i*SKEIN_1024_BLOCK_BYTES); /* restore the counter mode key for next time */ memcpy(ctx->X, X, sizeof(X)); } @@ -702,7 +702,7 @@ int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val) int skein_256_final_pad(struct skein_256_ctx *ctx, u8 *hash_val) { /* catch uninitialized context */ - Skein_Assert(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); + skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* tag as the final block */ ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; @@ -714,7 +714,7 @@ int skein_256_final_pad(struct skein_256_ctx *ctx, u8 *hash_val) skein_256_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); /* "output" the state bytes */ - Skein_Put64_LSB_First(hash_val, ctx->X, SKEIN_256_BLOCK_BYTES); + skein_put64_lsb_first(hash_val, ctx->X, SKEIN_256_BLOCK_BYTES); return SKEIN_SUCCESS; } @@ -724,7 +724,7 @@ int skein_256_final_pad(struct skein_256_ctx *ctx, u8 *hash_val) int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hash_val) { /* catch uninitialized context */ - Skein_Assert(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); + skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* tag as the final block */ ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; @@ -736,7 +736,7 @@ int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hash_val) skein_512_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); /* "output" the state bytes */ - Skein_Put64_LSB_First(hash_val, ctx->X, SKEIN_512_BLOCK_BYTES); + skein_put64_lsb_first(hash_val, ctx->X, SKEIN_512_BLOCK_BYTES); return SKEIN_SUCCESS; } @@ -746,19 +746,19 @@ int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hash_val) int skein_1024_final_pad(struct skein_1024_ctx *ctx, u8 *hash_val) { /* catch uninitialized context */ - Skein_Assert(ctx->h.b_cnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); + skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL); /* tag as the final block */ ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* zero pad b[] if necessary */ - if (ctx->h.b_cnt < SKEIN1024_BLOCK_BYTES) + if (ctx->h.b_cnt < SKEIN_1024_BLOCK_BYTES) memset(&ctx->b[ctx->h.b_cnt], 0, - SKEIN1024_BLOCK_BYTES - ctx->h.b_cnt); + SKEIN_1024_BLOCK_BYTES - ctx->h.b_cnt); /* process the final block */ skein_1024_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); /* "output" the state bytes */ - Skein_Put64_LSB_First(hash_val, ctx->X, SKEIN1024_BLOCK_BYTES); + skein_put64_lsb_first(hash_val, ctx->X, SKEIN_1024_BLOCK_BYTES); return SKEIN_SUCCESS; } @@ -771,7 +771,7 @@ int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val) size_t i, n, byte_cnt; u64 X[SKEIN_256_STATE_WORDS]; /* catch uninitialized context */ - Skein_Assert(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); + skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* now output the result */ /* total number of output bytes */ @@ -784,8 +784,8 @@ int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val) memcpy(X, ctx->X, sizeof(X)); for (i = 0; i*SKEIN_256_BLOCK_BYTES < byte_cnt; i++) { /* build the counter block */ - ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); - Skein_Start_New_Type(ctx, OUT_FINAL); + ((u64 *)ctx->b)[0] = skein_swap64((u64) i); + skein_start_new_type(ctx, OUT_FINAL); /* run "counter mode" */ skein_256_process_block(ctx, ctx->b, 1, sizeof(u64)); /* number of output bytes left to go */ @@ -793,9 +793,9 @@ int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val) if (n >= SKEIN_256_BLOCK_BYTES) n = SKEIN_256_BLOCK_BYTES; /* "output" the ctr mode bytes */ - Skein_Put64_LSB_First(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->X, + skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->X, n); - Skein_Show_Final(256, &ctx->h, n, + skein_show_final(256, &ctx->h, n, hash_val+i*SKEIN_256_BLOCK_BYTES); /* restore the counter mode key for next time */ memcpy(ctx->X, X, sizeof(X)); @@ -810,7 +810,7 @@ int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val) size_t i, n, byte_cnt; u64 X[SKEIN_512_STATE_WORDS]; /* catch uninitialized context */ - Skein_Assert(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); + skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* now output the result */ /* total number of output bytes */ @@ -823,8 +823,8 @@ int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val) memcpy(X, ctx->X, sizeof(X)); for (i = 0; i*SKEIN_512_BLOCK_BYTES < byte_cnt; i++) { /* build the counter block */ - ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); - Skein_Start_New_Type(ctx, OUT_FINAL); + ((u64 *)ctx->b)[0] = skein_swap64((u64) i); + skein_start_new_type(ctx, OUT_FINAL); /* run "counter mode" */ skein_512_process_block(ctx, ctx->b, 1, sizeof(u64)); /* number of output bytes left to go */ @@ -832,9 +832,9 @@ int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val) if (n >= SKEIN_512_BLOCK_BYTES) n = SKEIN_512_BLOCK_BYTES; /* "output" the ctr mode bytes */ - Skein_Put64_LSB_First(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->X, + skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->X, n); - Skein_Show_Final(256, &ctx->h, n, + skein_show_final(256, &ctx->h, n, hash_val+i*SKEIN_512_BLOCK_BYTES); /* restore the counter mode key for next time */ memcpy(ctx->X, X, sizeof(X)); @@ -847,9 +847,9 @@ int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val) int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val) { size_t i, n, byte_cnt; - u64 X[SKEIN1024_STATE_WORDS]; + u64 X[SKEIN_1024_STATE_WORDS]; /* catch uninitialized context */ - Skein_Assert(ctx->h.b_cnt <= SKEIN1024_BLOCK_BYTES, SKEIN_FAIL); + skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL); /* now output the result */ /* total number of output bytes */ @@ -860,21 +860,21 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val) memset(ctx->b, 0, sizeof(ctx->b)); /* keep a local copy of counter mode "key" */ memcpy(X, ctx->X, sizeof(X)); - for (i = 0; i*SKEIN1024_BLOCK_BYTES < byte_cnt; i++) { + for (i = 0; i*SKEIN_1024_BLOCK_BYTES < byte_cnt; i++) { /* build the counter block */ - ((u64 *)ctx->b)[0] = Skein_Swap64((u64) i); - Skein_Start_New_Type(ctx, OUT_FINAL); + ((u64 *)ctx->b)[0] = skein_swap64((u64) i); + skein_start_new_type(ctx, OUT_FINAL); /* run "counter mode" */ skein_1024_process_block(ctx, ctx->b, 1, sizeof(u64)); /* number of output bytes left to go */ - n = byte_cnt - i*SKEIN1024_BLOCK_BYTES; - if (n >= SKEIN1024_BLOCK_BYTES) - n = SKEIN1024_BLOCK_BYTES; + n = byte_cnt - i*SKEIN_1024_BLOCK_BYTES; + if (n >= SKEIN_1024_BLOCK_BYTES) + n = SKEIN_1024_BLOCK_BYTES; /* "output" the ctr mode bytes */ - Skein_Put64_LSB_First(hash_val+i*SKEIN1024_BLOCK_BYTES, ctx->X, + skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx->X, n); - Skein_Show_Final(256, &ctx->h, n, - hash_val+i*SKEIN1024_BLOCK_BYTES); + skein_show_final(256, &ctx->h, n, + hash_val+i*SKEIN_1024_BLOCK_BYTES); /* restore the counter mode key for next time */ memcpy(ctx->X, X, sizeof(X)); } diff --git a/drivers/staging/skein/skeinApi.c b/drivers/staging/skein/skeinApi.c index 87b3ff23b49c..16d596b45317 100644 --- a/drivers/staging/skein/skeinApi.c +++ b/drivers/staging/skein/skeinApi.c @@ -29,7 +29,7 @@ OTHER DEALINGS IN THE SOFTWARE. int skein_ctx_prepare(struct skein_ctx *ctx, enum skein_size size) { - Skein_Assert(ctx && size, SKEIN_FAIL); + skein_assert_ret(ctx && size, SKEIN_FAIL); memset(ctx , 0, sizeof(struct skein_ctx)); ctx->skein_size = size; @@ -44,7 +44,7 @@ int skein_init(struct skein_ctx *ctx, size_t hash_bit_len) u64 *X = NULL; u64 tree_info = SKEIN_CFG_TREE_INFO_SEQUENTIAL; - Skein_Assert(ctx, SKEIN_FAIL); + skein_assert_ret(ctx, SKEIN_FAIL); /* * The following two lines rely of the fact that the real Skein * contexts are a union in out context and thus have tha maximum @@ -89,12 +89,12 @@ int skein_mac_init(struct skein_ctx *ctx, const u8 *key, size_t key_len, size_t X_len = 0; u64 tree_info = SKEIN_CFG_TREE_INFO_SEQUENTIAL; - Skein_Assert(ctx, SKEIN_FAIL); + skein_assert_ret(ctx, SKEIN_FAIL); X = ctx->m.s256.X; X_len = ctx->skein_size/8; - Skein_Assert(hash_bit_len, SKEIN_BAD_HASHLEN); + skein_assert_ret(hash_bit_len, SKEIN_BAD_HASHLEN); switch (ctx->skein_size) { case SKEIN_256: @@ -141,7 +141,7 @@ void skein_reset(struct skein_ctx *ctx) memcpy(X, ctx->X_save, X_len); /* Setup context to process the message */ - Skein_Start_New_Type(&ctx->m, MSG); + skein_start_new_type(&ctx->m, MSG); } int skein_update(struct skein_ctx *ctx, const u8 *msg, @@ -149,7 +149,7 @@ int skein_update(struct skein_ctx *ctx, const u8 *msg, { int ret = SKEIN_FAIL; - Skein_Assert(ctx, SKEIN_FAIL); + skein_assert_ret(ctx, SKEIN_FAIL); switch (ctx->skein_size) { case SKEIN_256: @@ -185,8 +185,8 @@ int skein_update_bits(struct skein_ctx *ctx, const u8 *msg, * only the final Update() call is allowed do partial bytes, else * assert an error */ - Skein_Assert((ctx->m.h.T[1] & SKEIN_T1_FLAG_BIT_PAD) == 0 || - msg_bit_cnt == 0, SKEIN_FAIL); + skein_assert_ret((ctx->m.h.T[1] & SKEIN_T1_FLAG_BIT_PAD) == 0 || + msg_bit_cnt == 0, SKEIN_FAIL); /* if number of bits is a multiple of bytes - that's easy */ if ((msg_bit_cnt & 0x7) == 0) @@ -203,13 +203,13 @@ int skein_update_bits(struct skein_ctx *ctx, const u8 *msg, up = (u8 *)ctx->m.s256.X + ctx->skein_size / 8; /* set tweak flag for the skein_final call */ - Skein_Set_Bit_Pad_Flag(ctx->m.h); + skein_set_bit_pad_flag(ctx->m.h); /* now "pad" the final partial byte the way NIST likes */ /* get the b_cnt value (same location for all block sizes) */ length = ctx->m.h.b_cnt; /* internal sanity check: there IS a partial byte in the buffer! */ - Skein_assert(length != 0); + skein_assert(length != 0); /* partial byte bit mask */ mask = (u8) (1u << (7 - (msg_bit_cnt & 7))); /* apply bit padding on final byte (in the buffer) */ @@ -222,7 +222,7 @@ int skein_final(struct skein_ctx *ctx, u8 *hash) { int ret = SKEIN_FAIL; - Skein_Assert(ctx, SKEIN_FAIL); + skein_assert_ret(ctx, SKEIN_FAIL); switch (ctx->skein_size) { case SKEIN_256: diff --git a/drivers/staging/skein/skeinBlockNo3F.c b/drivers/staging/skein/skeinBlockNo3F.c index 716b78e6f83f..4ee7f9fb4365 100644 --- a/drivers/staging/skein/skeinBlockNo3F.c +++ b/drivers/staging/skein/skeinBlockNo3F.c @@ -11,10 +11,10 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, struct threefish_key key; u64 tweak[2]; int i; - u64 w[SKEIN_256_STATE_WORDS]; /* local copy of input block */ + u64 w[SKEIN_256_STATE_WORDS]; /* local copy of input block */ u64 words[3]; - Skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ + skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ tweak[0] = ctx->h.T[0]; tweak[1] = ctx->h.T[1]; @@ -37,7 +37,7 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, threefish_set_key(&key, THREEFISH_256, ctx->X, tweak); /* get input block in little-endian format */ - Skein_Get64_LSB_First(w, blk_ptr, SKEIN_256_STATE_WORDS); + skein_get64_lsb_first(w, blk_ptr, SKEIN_256_STATE_WORDS); threefish_encrypt_block_words(&key, w, ctx->X); @@ -63,9 +63,9 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, u64 tweak[2]; int i; u64 words[3]; - u64 w[SKEIN_512_STATE_WORDS]; /* local copy of input block */ + u64 w[SKEIN_512_STATE_WORDS]; /* local copy of input block */ - Skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ + skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ tweak[0] = ctx->h.T[0]; tweak[1] = ctx->h.T[1]; @@ -88,7 +88,7 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, threefish_set_key(&key, THREEFISH_512, ctx->X, tweak); /* get input block in little-endian format */ - Skein_Get64_LSB_First(w, blk_ptr, SKEIN_512_STATE_WORDS); + skein_get64_lsb_first(w, blk_ptr, SKEIN_512_STATE_WORDS); threefish_encrypt_block_words(&key, w, ctx->X); @@ -118,9 +118,9 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, u64 tweak[2]; int i; u64 words[3]; - u64 w[SKEIN1024_STATE_WORDS]; /* local copy of input block */ + u64 w[SKEIN_1024_STATE_WORDS]; /* local copy of input block */ - Skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ + skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ tweak[0] = ctx->h.T[0]; tweak[1] = ctx->h.T[1]; @@ -143,11 +143,11 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, threefish_set_key(&key, THREEFISH_1024, ctx->X, tweak); /* get input block in little-endian format */ - Skein_Get64_LSB_First(w, blk_ptr, SKEIN1024_STATE_WORDS); + skein_get64_lsb_first(w, blk_ptr, SKEIN_1024_STATE_WORDS); threefish_encrypt_block_words(&key, w, ctx->X); - blk_ptr += SKEIN1024_BLOCK_BYTES; + blk_ptr += SKEIN_1024_BLOCK_BYTES; /* do the final "feedforward" xor, update ctx chaining vars */ ctx->X[0] = ctx->X[0] ^ w[0]; diff --git a/drivers/staging/skein/skein_block.c b/drivers/staging/skein/skein_block.c index ebd4af1aaae5..7b66ec529422 100644 --- a/drivers/staging/skein/skein_block.c +++ b/drivers/staging/skein/skein_block.c @@ -32,9 +32,9 @@ #define ts (kw + KW_TWK_BASE) #ifdef SKEIN_DEBUG -#define DebugSaveTweak(ctx) { ctx->h.T[0] = ts[0]; ctx->h.T[1] = ts[1]; } +#define debug_save_tweak(ctx) { ctx->h.T[0] = ts[0]; ctx->h.T[1] = ts[1]; } #else -#define DebugSaveTweak(ctx) +#define debug_save_tweak(ctx) #endif /***************************** SKEIN_256 ******************************/ @@ -70,7 +70,7 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, X_ptr[0] = &X0; X_ptr[1] = &X1; X_ptr[2] = &X2; X_ptr[3] = &X3; #endif - Skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ + skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ ts[0] = ctx->h.T[0]; ts[1] = ctx->h.T[1]; do { @@ -90,9 +90,9 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, ts[2] = ts[0] ^ ts[1]; /* get input block in little-endian format */ - Skein_Get64_LSB_First(w, blk_ptr, WCNT); - DebugSaveTweak(ctx); - Skein_Show_Block(BLK_BITS, &ctx->h, ctx->X, blk_ptr, w, ks, ts); + skein_get64_lsb_first(w, blk_ptr, WCNT); + debug_save_tweak(ctx); + skein_show_block(BLK_BITS, &ctx->h, ctx->X, blk_ptr, w, ks, ts); X0 = w[0] + ks[0]; /* do the first full key injection */ X1 = w[1] + ks[1] + ts[0]; @@ -100,24 +100,24 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, X3 = w[3] + ks[3]; /* show starting state values */ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, + skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, X_ptr); blk_ptr += SKEIN_256_BLOCK_BYTES; /* run the rounds */ -#define Round256(p0, p1, p2, p3, ROT, r_num) \ +#define ROUND256(p0, p1, p2, p3, ROT, r_num) \ do { \ - X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ - X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ + X##p0 += X##p1; X##p1 = rotl_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ + X##p2 += X##p3; X##p3 = rotl_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ } while (0) #if SKEIN_UNROLL_256 == 0 #define R256(p0, p1, p2, p3, ROT, r_num) /* fully unrolled */ \ do { \ - Round256(p0, p1, p2, p3, ROT, r_num); \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, r_num, X_ptr); \ + ROUND256(p0, p1, p2, p3, ROT, r_num); \ + skein_show_r_ptr(BLK_BITS, &ctx->h, r_num, X_ptr); \ } while (0) #define I256(R) \ @@ -127,13 +127,13 @@ do { \ X1 += ks[((R)+2) % 5] + ts[((R)+1) % 3]; \ X2 += ks[((R)+3) % 5] + ts[((R)+2) % 3]; \ X3 += ks[((R)+4) % 5] + (R)+1; \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ + skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ } while (0) #else /* looping version */ #define R256(p0, p1, p2, p3, ROT, r_num) \ do { \ - Round256(p0, p1, p2, p3, ROT, r_num); \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + r_num, X_ptr); \ + ROUND256(p0, p1, p2, p3, ROT, r_num); \ + skein_show_r_ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + r_num, X_ptr); \ } while (0) #define I256(R) \ @@ -146,13 +146,13 @@ do { \ /* rotate key schedule */ \ ks[r + (R) + 4] = ks[r + (R) - 1]; \ ts[r + (R) + 2] = ts[r + (R) - 1]; \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ + skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ } while (0) for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_256) #endif { -#define R256_8_rounds(R) \ +#define R256_8_ROUNDS(R) \ do { \ R256(0, 1, 2, 3, R_256_0, 8 * (R) + 1); \ R256(0, 3, 2, 1, R_256_1, 8 * (R) + 2); \ @@ -166,54 +166,54 @@ do { \ I256(2 * (R) + 1); \ } while (0) - R256_8_rounds(0); + R256_8_ROUNDS(0); -#define R256_Unroll_R(NN) \ +#define R256_UNROLL_R(NN) \ ((SKEIN_UNROLL_256 == 0 && \ SKEIN_256_ROUNDS_TOTAL/8 > (NN)) || \ (SKEIN_UNROLL_256 > (NN))) - #if R256_Unroll_R(1) - R256_8_rounds(1); + #if R256_UNROLL_R(1) + R256_8_ROUNDS(1); #endif - #if R256_Unroll_R(2) - R256_8_rounds(2); + #if R256_UNROLL_R(2) + R256_8_ROUNDS(2); #endif - #if R256_Unroll_R(3) - R256_8_rounds(3); + #if R256_UNROLL_R(3) + R256_8_ROUNDS(3); #endif - #if R256_Unroll_R(4) - R256_8_rounds(4); + #if R256_UNROLL_R(4) + R256_8_ROUNDS(4); #endif - #if R256_Unroll_R(5) - R256_8_rounds(5); + #if R256_UNROLL_R(5) + R256_8_ROUNDS(5); #endif - #if R256_Unroll_R(6) - R256_8_rounds(6); + #if R256_UNROLL_R(6) + R256_8_ROUNDS(6); #endif - #if R256_Unroll_R(7) - R256_8_rounds(7); + #if R256_UNROLL_R(7) + R256_8_ROUNDS(7); #endif - #if R256_Unroll_R(8) - R256_8_rounds(8); + #if R256_UNROLL_R(8) + R256_8_ROUNDS(8); #endif - #if R256_Unroll_R(9) - R256_8_rounds(9); + #if R256_UNROLL_R(9) + R256_8_ROUNDS(9); #endif - #if R256_Unroll_R(10) - R256_8_rounds(10); + #if R256_UNROLL_R(10) + R256_8_ROUNDS(10); #endif - #if R256_Unroll_R(11) - R256_8_rounds(11); + #if R256_UNROLL_R(11) + R256_8_ROUNDS(11); #endif - #if R256_Unroll_R(12) - R256_8_rounds(12); + #if R256_UNROLL_R(12) + R256_8_ROUNDS(12); #endif - #if R256_Unroll_R(13) - R256_8_rounds(13); + #if R256_UNROLL_R(13) + R256_8_ROUNDS(13); #endif - #if R256_Unroll_R(14) - R256_8_rounds(14); + #if R256_UNROLL_R(14) + R256_8_ROUNDS(14); #endif #if (SKEIN_UNROLL_256 > 14) #error "need more unrolling in skein_256_process_block" @@ -225,7 +225,7 @@ do { \ ctx->X[2] = X2 ^ w[2]; ctx->X[3] = X3 ^ w[3]; - Skein_Show_Round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X); + skein_show_round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X); ts[1] &= ~SKEIN_T1_FLAG_FIRST; } while (--blk_cnt); @@ -281,7 +281,7 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, X_ptr[4] = &X4; X_ptr[5] = &X5; X_ptr[6] = &X6; X_ptr[7] = &X7; #endif - Skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ + skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ ts[0] = ctx->h.T[0]; ts[1] = ctx->h.T[1]; do { @@ -306,9 +306,9 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, ts[2] = ts[0] ^ ts[1]; /* get input block in little-endian format */ - Skein_Get64_LSB_First(w, blk_ptr, WCNT); - DebugSaveTweak(ctx); - Skein_Show_Block(BLK_BITS, &ctx->h, ctx->X, blk_ptr, w, ks, ts); + skein_get64_lsb_first(w, blk_ptr, WCNT); + debug_save_tweak(ctx); + skein_show_block(BLK_BITS, &ctx->h, ctx->X, blk_ptr, w, ks, ts); X0 = w[0] + ks[0]; /* do the first full key injection */ X1 = w[1] + ks[1]; @@ -321,22 +321,22 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, blk_ptr += SKEIN_512_BLOCK_BYTES; - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, + skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, X_ptr); /* run the rounds */ -#define Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \ +#define ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \ do { \ - X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ - X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ - X##p4 += X##p5; X##p5 = RotL_64(X##p5, ROT##_2); X##p5 ^= X##p4; \ - X##p6 += X##p7; X##p7 = RotL_64(X##p7, ROT##_3); X##p7 ^= X##p6; \ + X##p0 += X##p1; X##p1 = rotl_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ + X##p2 += X##p3; X##p3 = rotl_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ + X##p4 += X##p5; X##p5 = rotl_64(X##p5, ROT##_2); X##p5 ^= X##p4; \ + X##p6 += X##p7; X##p7 = rotl_64(X##p7, ROT##_3); X##p7 ^= X##p6; \ } while (0) #if SKEIN_UNROLL_512 == 0 #define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) /* unrolled */ \ do { \ - Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, r_num, X_ptr); \ + ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \ + skein_show_r_ptr(BLK_BITS, &ctx->h, r_num, X_ptr); \ } while (0) #define I512(R) \ @@ -350,13 +350,13 @@ do { \ X5 += ks[((R) + 6) % 9] + ts[((R) + 1) % 3]; \ X6 += ks[((R) + 7) % 9] + ts[((R) + 2) % 3]; \ X7 += ks[((R) + 8) % 9] + (R) + 1; \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ + skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ } while (0) #else /* looping version */ #define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) \ do { \ - Round512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num); \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + r_num, X_ptr); \ + ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num); \ + skein_show_r_ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + r_num, X_ptr); \ } while (0) #define I512(R) \ @@ -373,13 +373,13 @@ do { \ /* rotate key schedule */ \ ks[r + (R) + 8] = ks[r + (R) - 1]; \ ts[r + (R) + 2] = ts[r + (R) - 1]; \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ + skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ } while (0) for (r = 1; r < 2 * RCNT; r += 2 * SKEIN_UNROLL_512) #endif /* end of looped code definitions */ { -#define R512_8_rounds(R) /* do 8 full rounds */ \ +#define R512_8_ROUNDS(R) /* do 8 full rounds */ \ do { \ R512(0, 1, 2, 3, 4, 5, 6, 7, R_512_0, 8 * (R) + 1); \ R512(2, 1, 4, 7, 6, 5, 0, 3, R_512_1, 8 * (R) + 2); \ @@ -393,54 +393,54 @@ do { \ I512(2 * (R) + 1); /* and key injection */ \ } while (0) - R512_8_rounds(0); + R512_8_ROUNDS(0); -#define R512_Unroll_R(NN) \ +#define R512_UNROLL_R(NN) \ ((SKEIN_UNROLL_512 == 0 && \ SKEIN_512_ROUNDS_TOTAL/8 > (NN)) || \ (SKEIN_UNROLL_512 > (NN))) - #if R512_Unroll_R(1) - R512_8_rounds(1); + #if R512_UNROLL_R(1) + R512_8_ROUNDS(1); #endif - #if R512_Unroll_R(2) - R512_8_rounds(2); + #if R512_UNROLL_R(2) + R512_8_ROUNDS(2); #endif - #if R512_Unroll_R(3) - R512_8_rounds(3); + #if R512_UNROLL_R(3) + R512_8_ROUNDS(3); #endif - #if R512_Unroll_R(4) - R512_8_rounds(4); + #if R512_UNROLL_R(4) + R512_8_ROUNDS(4); #endif - #if R512_Unroll_R(5) - R512_8_rounds(5); + #if R512_UNROLL_R(5) + R512_8_ROUNDS(5); #endif - #if R512_Unroll_R(6) - R512_8_rounds(6); + #if R512_UNROLL_R(6) + R512_8_ROUNDS(6); #endif - #if R512_Unroll_R(7) - R512_8_rounds(7); + #if R512_UNROLL_R(7) + R512_8_ROUNDS(7); #endif - #if R512_Unroll_R(8) - R512_8_rounds(8); + #if R512_UNROLL_R(8) + R512_8_ROUNDS(8); #endif - #if R512_Unroll_R(9) - R512_8_rounds(9); + #if R512_UNROLL_R(9) + R512_8_ROUNDS(9); #endif - #if R512_Unroll_R(10) - R512_8_rounds(10); + #if R512_UNROLL_R(10) + R512_8_ROUNDS(10); #endif - #if R512_Unroll_R(11) - R512_8_rounds(11); + #if R512_UNROLL_R(11) + R512_8_ROUNDS(11); #endif - #if R512_Unroll_R(12) - R512_8_rounds(12); + #if R512_UNROLL_R(12) + R512_8_ROUNDS(12); #endif - #if R512_Unroll_R(13) - R512_8_rounds(13); + #if R512_UNROLL_R(13) + R512_8_ROUNDS(13); #endif - #if R512_Unroll_R(14) - R512_8_rounds(14); + #if R512_UNROLL_R(14) + R512_8_ROUNDS(14); #endif #if (SKEIN_UNROLL_512 > 14) #error "need more unrolling in skein_512_process_block" @@ -456,7 +456,7 @@ do { \ ctx->X[5] = X5 ^ w[5]; ctx->X[6] = X6 ^ w[6]; ctx->X[7] = X7 ^ w[7]; - Skein_Show_Round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X); + skein_show_round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X); ts[1] &= ~SKEIN_T1_FLAG_FIRST; } while (--blk_cnt); @@ -483,10 +483,10 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, size_t blk_cnt, size_t byte_cnt_add) { /* do it in C, always looping (unrolled is bigger AND slower!) */ enum { - WCNT = SKEIN1024_STATE_WORDS + WCNT = SKEIN_1024_STATE_WORDS }; #undef RCNT -#define RCNT (SKEIN1024_ROUNDS_TOTAL/8) +#define RCNT (SKEIN_1024_ROUNDS_TOTAL/8) #ifdef SKEIN_LOOP /* configure how much to unroll the loop */ #define SKEIN_UNROLL_1024 ((SKEIN_LOOP)%10) @@ -519,7 +519,7 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, X_ptr[15] = &X15; #endif - Skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ + skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ ts[0] = ctx->h.T[0]; ts[1] = ctx->h.T[1]; do { @@ -554,9 +554,9 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, ts[2] = ts[0] ^ ts[1]; /* get input block in little-endian format */ - Skein_Get64_LSB_First(w, blk_ptr, WCNT); - DebugSaveTweak(ctx); - Skein_Show_Block(BLK_BITS, &ctx->h, ctx->X, blk_ptr, w, ks, ts); + skein_get64_lsb_first(w, blk_ptr, WCNT); + debug_save_tweak(ctx); + skein_show_block(BLK_BITS, &ctx->h, ctx->X, blk_ptr, w, ks, ts); X00 = w[0] + ks[0]; /* do the first full key injection */ X01 = w[1] + ks[1]; @@ -575,29 +575,29 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, X14 = w[14] + ks[14] + ts[1]; X15 = w[15] + ks[15]; - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, + skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, X_ptr); -#define Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ +#define ROUND1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ pF, ROT, r_num) \ do { \ - X##p0 += X##p1; X##p1 = RotL_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ - X##p2 += X##p3; X##p3 = RotL_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ - X##p4 += X##p5; X##p5 = RotL_64(X##p5, ROT##_2); X##p5 ^= X##p4; \ - X##p6 += X##p7; X##p7 = RotL_64(X##p7, ROT##_3); X##p7 ^= X##p6; \ - X##p8 += X##p9; X##p9 = RotL_64(X##p9, ROT##_4); X##p9 ^= X##p8; \ - X##pA += X##pB; X##pB = RotL_64(X##pB, ROT##_5); X##pB ^= X##pA; \ - X##pC += X##pD; X##pD = RotL_64(X##pD, ROT##_6); X##pD ^= X##pC; \ - X##pE += X##pF; X##pF = RotL_64(X##pF, ROT##_7); X##pF ^= X##pE; \ + X##p0 += X##p1; X##p1 = rotl_64(X##p1, ROT##_0); X##p1 ^= X##p0; \ + X##p2 += X##p3; X##p3 = rotl_64(X##p3, ROT##_1); X##p3 ^= X##p2; \ + X##p4 += X##p5; X##p5 = rotl_64(X##p5, ROT##_2); X##p5 ^= X##p4; \ + X##p6 += X##p7; X##p7 = rotl_64(X##p7, ROT##_3); X##p7 ^= X##p6; \ + X##p8 += X##p9; X##p9 = rotl_64(X##p9, ROT##_4); X##p9 ^= X##p8; \ + X##pA += X##pB; X##pB = rotl_64(X##pB, ROT##_5); X##pB ^= X##pA; \ + X##pC += X##pD; X##pD = rotl_64(X##pD, ROT##_6); X##pD ^= X##pC; \ + X##pE += X##pF; X##pF = rotl_64(X##pF, ROT##_7); X##pF ^= X##pE; \ } while (0) #if SKEIN_UNROLL_1024 == 0 #define R1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, \ ROT, rn) \ do { \ - Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ - pF, ROT, rn) \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, rn, X_ptr); \ + ROUND1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ + pF, ROT, rn); \ + skein_show_r_ptr(BLK_BITS, &ctx->h, rn, X_ptr); \ } while (0) #define I1024(R) \ @@ -619,15 +619,15 @@ do { \ X13 += ks[((R) + 14) % 17] + ts[((R) + 1) % 3]; \ X14 += ks[((R) + 15) % 17] + ts[((R) + 2) % 3]; \ X15 += ks[((R) + 16) % 17] + (R) + 1; \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ + skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ } while (0) #else /* looping version */ #define R1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, pF, \ ROT, rn) \ do { \ - Round1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ - pF, ROT, rn) \ - Skein_Show_R_Ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rn, X_ptr); \ + ROUND1024(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pA, pB, pC, pD, pE, \ + pF, ROT, rn); \ + skein_show_r_ptr(BLK_BITS, &ctx->h, 4 * (r - 1) + rn, X_ptr); \ } while (0) #define I1024(R) \ @@ -652,13 +652,13 @@ do { \ /* rotate key schedule */ \ ks[r + (R) + 16] = ks[r + (R) - 1]; \ ts[r + (R) + 2] = ts[r + (R) - 1]; \ - Skein_Show_R_Ptr(BLK_BITSi, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ + skein_show_r_ptr(BLK_BITSi, &ctx->h, SKEIN_RND_KEY_INJECT, X_ptr); \ } while (0) for (r = 1; r <= 2 * RCNT; r += 2 * SKEIN_UNROLL_1024) #endif { -#define R1024_8_rounds(R) \ +#define R1024_8_ROUNDS(R) \ do { \ R1024(00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, \ R1024_0, 8*(R) + 1); \ @@ -680,54 +680,54 @@ do { \ I1024(2*(R)+1); \ } while (0) - R1024_8_rounds(0); + R1024_8_ROUNDS(0); -#define R1024_Unroll_R(NN) \ +#define R1024_UNROLL_R(NN) \ ((SKEIN_UNROLL_1024 == 0 && \ - SKEIN1024_ROUNDS_TOTAL/8 > (NN)) || \ + SKEIN_1024_ROUNDS_TOTAL/8 > (NN)) || \ (SKEIN_UNROLL_1024 > (NN))) - #if R1024_Unroll_R(1) - R1024_8_rounds(1); + #if R1024_UNROLL_R(1) + R1024_8_ROUNDS(1); #endif - #if R1024_Unroll_R(2) - R1024_8_rounds(2); + #if R1024_UNROLL_R(2) + R1024_8_ROUNDS(2); #endif - #if R1024_Unroll_R(3) - R1024_8_rounds(3); + #if R1024_UNROLL_R(3) + R1024_8_ROUNDS(3); #endif - #if R1024_Unroll_R(4) - R1024_8_rounds(4); + #if R1024_UNROLL_R(4) + R1024_8_ROUNDS(4); #endif - #if R1024_Unroll_R(5) - R1024_8_rounds(5); + #if R1024_UNROLL_R(5) + R1024_8_ROUNDS(5); #endif - #if R1024_Unroll_R(6) - R1024_8_rounds(6); + #if R1024_UNROLL_R(6) + R1024_8_ROUNDS(6); #endif - #if R1024_Unroll_R(7) - R1024_8_rounds(7); + #if R1024_UNROLL_R(7) + R1024_8_ROUNDS(7); #endif - #if R1024_Unroll_R(8) - R1024_8_rounds(8); + #if R1024_UNROLL_R(8) + R1024_8_ROUNDS(8); #endif - #if R1024_Unroll_R(9) - R1024_8_rounds(9); + #if R1024_UNROLL_R(9) + R1024_8_ROUNDS(9); #endif - #if R1024_Unroll_R(10) - R1024_8_rounds(10); + #if R1024_UNROLL_R(10) + R1024_8_ROUNDS(10); #endif - #if R1024_Unroll_R(11) - R1024_8_rounds(11); + #if R1024_UNROLL_R(11) + R1024_8_ROUNDS(11); #endif - #if R1024_Unroll_R(12) - R1024_8_rounds(12); + #if R1024_UNROLL_R(12) + R1024_8_ROUNDS(12); #endif - #if R1024_Unroll_R(13) - R1024_8_rounds(13); + #if R1024_UNROLL_R(13) + R1024_8_ROUNDS(13); #endif - #if R1024_Unroll_R(14) - R1024_8_rounds(14); + #if R1024_UNROLL_R(14) + R1024_8_ROUNDS(14); #endif #if (SKEIN_UNROLL_1024 > 14) #error "need more unrolling in Skein_1024_Process_Block" @@ -752,10 +752,10 @@ do { \ ctx->X[14] = X14 ^ w[14]; ctx->X[15] = X15 ^ w[15]; - Skein_Show_Round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X); + skein_show_round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X); ts[1] &= ~SKEIN_T1_FLAG_FIRST; - blk_ptr += SKEIN1024_BLOCK_BYTES; + blk_ptr += SKEIN_1024_BLOCK_BYTES; } while (--blk_cnt); ctx->h.T[0] = ts[0]; ctx->h.T[1] = ts[1]; diff --git a/drivers/staging/skein/threefishApi.c b/drivers/staging/skein/threefishApi.c index 17a314b8d65a..0ba42fac2f88 100644 --- a/drivers/staging/skein/threefishApi.c +++ b/drivers/staging/skein/threefishApi.c @@ -9,7 +9,7 @@ void threefish_set_key(struct threefish_key *key_ctx, { int key_words = state_size / 64; int i; - u64 parity = KeyScheduleConst; + u64 parity = KEY_SCHEDULE_CONST; key_ctx->tweak[0] = tweak[0]; key_ctx->tweak[1] = tweak[1]; @@ -29,9 +29,9 @@ void threefish_encrypt_block_bytes(struct threefish_key *key_ctx, u8 *in, u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ u64 cipher[SKEIN_MAX_STATE_WORDS]; - Skein_Get64_LSB_First(plain, in, key_ctx->state_size / 64); + skein_get64_lsb_first(plain, in, key_ctx->state_size / 64); threefish_encrypt_block_words(key_ctx, plain, cipher); - Skein_Put64_LSB_First(out, cipher, key_ctx->state_size / 8); + skein_put64_lsb_first(out, cipher, key_ctx->state_size / 8); } void threefish_encrypt_block_words(struct threefish_key *key_ctx, u64 *in, @@ -56,9 +56,9 @@ void threefish_decrypt_block_bytes(struct threefish_key *key_ctx, u8 *in, u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ u64 cipher[SKEIN_MAX_STATE_WORDS]; - Skein_Get64_LSB_First(cipher, in, key_ctx->state_size / 64); + skein_get64_lsb_first(cipher, in, key_ctx->state_size / 64); threefish_decrypt_block_words(key_ctx, cipher, plain); - Skein_Put64_LSB_First(out, plain, key_ctx->state_size / 8); + skein_put64_lsb_first(out, plain, key_ctx->state_size / 8); } void threefish_decrypt_block_words(struct threefish_key *key_ctx, u64 *in, -- cgit v1.2.3 From a30d534bdab1bec46cca2a58bafdbadd7a64f081 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 19 May 2014 20:32:53 +0100 Subject: staging: vt6656: Remove dead code hostap. It is based on viawget, proprietary version of wpa supplicant. The code is not compatible with the current version of hostapd. It may be possible to implement when the driver is fully converted to mac80211. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/Makefile | 1 - drivers/staging/vt6656/dpc.c | 1 - drivers/staging/vt6656/hostap.c | 781 -------------------------------------- drivers/staging/vt6656/hostap.h | 58 --- drivers/staging/vt6656/iwctl.c | 1 - drivers/staging/vt6656/main_usb.c | 12 - drivers/staging/vt6656/rxtx.c | 1 - 7 files changed, 855 deletions(-) delete mode 100644 drivers/staging/vt6656/hostap.c delete mode 100644 drivers/staging/vt6656/hostap.h diff --git a/drivers/staging/vt6656/Makefile b/drivers/staging/vt6656/Makefile index 1d829b46c2e7..47b60753bb23 100644 --- a/drivers/staging/vt6656/Makefile +++ b/drivers/staging/vt6656/Makefile @@ -19,7 +19,6 @@ vt6656_stage-y += main_usb.o \ rc4.o \ tether.o \ tcrc.o \ - hostap.o \ wpa.o \ key.o \ tkip.o \ diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c index 156399d93540..2596fcecc4b7 100644 --- a/drivers/staging/vt6656/dpc.c +++ b/drivers/staging/vt6656/dpc.c @@ -50,7 +50,6 @@ #include "tkip.h" #include "tcrc.h" #include "wctl.h" -#include "hostap.h" #include "rf.h" #include "iowpa.h" #include "aes_ccmp.h" diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c deleted file mode 100644 index 2a5b7c82b245..000000000000 --- a/drivers/staging/vt6656/hostap.c +++ /dev/null @@ -1,781 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: hostap.c - * - * Purpose: handle hostap daemon ioctl input/out functions - * - * Author: Lyndon Chen - * - * Date: Oct. 20, 2003 - * - * Functions: - * - * Revision History: - * - */ - -#include "hostap.h" -#include "iocmd.h" -#include "mac.h" -#include "card.h" -#include "baseband.h" -#include "wpactl.h" -#include "key.h" -#include "datarate.h" - -#define VIAWGET_HOSTAPD_MAX_BUF_SIZE 1024 -#define HOSTAP_CRYPT_FLAG_SET_TX_KEY BIT0 -#define HOSTAP_CRYPT_ERR_UNKNOWN_ADDR 3 -#define HOSTAP_CRYPT_ERR_KEY_SET_FAILED 5 - -static int msglevel =MSG_LEVEL_INFO; - -/* - * Description: - * register net_device (AP) for hostap daemon - * - * Parameters: - * In: - * pDevice - - * rtnl_locked - - * Out: - * - * Return Value: - * - */ - -static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked) -{ - struct vnt_private *apdev_priv; - struct net_device *dev = pDevice->dev; - int ret; - const struct net_device_ops apdev_netdev_ops = { - .ndo_start_xmit = pDevice->tx_80211, - }; - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name); - - pDevice->apdev = kzalloc(sizeof(struct net_device), GFP_KERNEL); - if (pDevice->apdev == NULL) - return -ENOMEM; - - apdev_priv = netdev_priv(pDevice->apdev); - *apdev_priv = *pDevice; - memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN); - - pDevice->apdev->netdev_ops = &apdev_netdev_ops; - - pDevice->apdev->type = ARPHRD_IEEE80211; - - pDevice->apdev->base_addr = dev->base_addr; - pDevice->apdev->irq = dev->irq; - pDevice->apdev->mem_start = dev->mem_start; - pDevice->apdev->mem_end = dev->mem_end; - sprintf(pDevice->apdev->name, "%sap", dev->name); - if (rtnl_locked) - ret = register_netdevice(pDevice->apdev); - else - ret = register_netdev(pDevice->apdev); - if (ret) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: register_netdevice(AP) failed!\n", - dev->name); - return -1; - } - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Registered netdevice %s for AP management\n", - dev->name, pDevice->apdev->name); - - KeyvInitTable(pDevice,&pDevice->sKey); - - return 0; -} - -/* - * Description: - * unregister net_device(AP) - * - * Parameters: - * In: - * pDevice - - * rtnl_locked - - * Out: - * - * Return Value: - * - */ - -static int hostap_disable_hostapd(struct vnt_private *pDevice, int rtnl_locked) -{ - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: disabling hostapd mode\n", pDevice->dev->name); - - if (pDevice->apdev && pDevice->apdev->name && pDevice->apdev->name[0]) { - if (rtnl_locked) - unregister_netdevice(pDevice->apdev); - else - unregister_netdev(pDevice->apdev); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Netdevice %s unregistered\n", - pDevice->dev->name, pDevice->apdev->name); - } - if (pDevice->apdev) - free_netdev(pDevice->apdev); - pDevice->apdev = NULL; - pDevice->bEnable8021x = false; - pDevice->bEnableHostWEP = false; - pDevice->bEncryptionEnable = false; - - return 0; -} - -/* - * Description: - * Set enable/disable hostapd mode - * - * Parameters: - * In: - * pDevice - - * rtnl_locked - - * Out: - * - * Return Value: - * - */ - -int vt6656_hostap_set_hostapd(struct vnt_private *pDevice, - int val, int rtnl_locked) -{ - if (val < 0 || val > 1) - return -EINVAL; - - if (pDevice->bEnableHostapd == val) - return 0; - - pDevice->bEnableHostapd = val; - - if (val) - return hostap_enable_hostapd(pDevice, rtnl_locked); - else - return hostap_disable_hostapd(pDevice, rtnl_locked); -} - -/* - * Description: - * remove station function supported for hostap daemon - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ -static int hostap_remove_sta(struct vnt_private *pDevice, - struct viawget_hostapd_param *param) -{ - unsigned int uNodeIndex; - - if (BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &uNodeIndex)) { - BSSvRemoveOneNode(pDevice, uNodeIndex); - } - else { - return -ENOENT; - } - return 0; -} - -/* - * Description: - * add a station from hostap daemon - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ -static int hostap_add_sta(struct vnt_private *pDevice, - struct viawget_hostapd_param *param) -{ - struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - unsigned int uNodeIndex; - - if (!BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &uNodeIndex)) - BSSvCreateOneNode(pDevice, &uNodeIndex); - - memcpy(pMgmt->sNodeDBTable[uNodeIndex].abyMACAddr, param->sta_addr, WLAN_ADDR_LEN); - pMgmt->sNodeDBTable[uNodeIndex].eNodeState = NODE_ASSOC; - pMgmt->sNodeDBTable[uNodeIndex].wCapInfo = param->u.add_sta.capability; -// TODO listenInterval -// pMgmt->sNodeDBTable[uNodeIndex].wListenInterval = 1; - pMgmt->sNodeDBTable[uNodeIndex].bPSEnable = false; - pMgmt->sNodeDBTable[uNodeIndex].bySuppRate = param->u.add_sta.tx_supp_rates; - - // set max tx rate - pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate = - pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate; - // set max basic rate - pMgmt->sNodeDBTable[uNodeIndex].wMaxBasicRate = RATE_2M; - // Todo: check sta preamble, if ap can't support, set status code - pMgmt->sNodeDBTable[uNodeIndex].bShortPreamble = - WLAN_GET_CAP_INFO_SHORTPREAMBLE(pMgmt->sNodeDBTable[uNodeIndex].wCapInfo); - - pMgmt->sNodeDBTable[uNodeIndex].wAID = (u16)param->u.add_sta.aid; - - pMgmt->sNodeDBTable[uNodeIndex].ulLastRxJiffer = jiffies; - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Add STA AID= %d \n", pMgmt->sNodeDBTable[uNodeIndex].wAID); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "MAC=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X \n", - param->sta_addr[0], - param->sta_addr[1], - param->sta_addr[2], - param->sta_addr[3], - param->sta_addr[4], - param->sta_addr[5] - ) ; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Max Support rate = %d \n", - pMgmt->sNodeDBTable[uNodeIndex].wMaxSuppRate); - - return 0; -} - -/* - * Description: - * get station info - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ - -static int hostap_get_info_sta(struct vnt_private *pDevice, - struct viawget_hostapd_param *param) -{ - struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - unsigned int uNodeIndex; - - if (BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &uNodeIndex)) { - param->u.get_info_sta.inactive_sec = - (jiffies - pMgmt->sNodeDBTable[uNodeIndex].ulLastRxJiffer) / HZ; - - //param->u.get_info_sta.txexc = pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts; - } - else { - return -ENOENT; - } - - return 0; -} - -/* - * Description: - * set station flag - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ -static int hostap_set_flags_sta(struct vnt_private *pDevice, - struct viawget_hostapd_param *param) -{ - struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - unsigned int uNodeIndex; - - if (BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &uNodeIndex)) { - pMgmt->sNodeDBTable[uNodeIndex].dwFlags |= param->u.set_flags_sta.flags_or; - pMgmt->sNodeDBTable[uNodeIndex].dwFlags &= param->u.set_flags_sta.flags_and; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " dwFlags = %x\n", - (unsigned int) pMgmt->sNodeDBTable[uNodeIndex].dwFlags); - } - else { - return -ENOENT; - } - - return 0; -} - -/* - * Description: - * set generic element (wpa ie) - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ -static int hostap_set_generic_element(struct vnt_private *pDevice, - struct viawget_hostapd_param *param) -{ - struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - - memcpy( pMgmt->abyWPAIE, - param->u.generic_elem.data, - param->u.generic_elem.len - ); - - pMgmt->wWPAIELen = param->u.generic_elem.len; - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pMgmt->wWPAIELen = %d\n", pMgmt->wWPAIELen); - - // disable wpa - if (pMgmt->wWPAIELen == 0) { - pMgmt->eAuthenMode = WMAC_AUTH_OPEN; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " No WPAIE, Disable WPA \n"); - } else { - // enable wpa - if ((pMgmt->abyWPAIE[0] == WLAN_EID_RSN_WPA) || - (pMgmt->abyWPAIE[0] == WLAN_EID_RSN)) { - pMgmt->eAuthenMode = WMAC_AUTH_WPANONE; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set WPAIE enable WPA\n"); - } else - return -EINVAL; - } - - return 0; -} - -/* - * Description: - * flush station nodes table. - * - * Parameters: - * In: - * pDevice - - * Out: - * - * Return Value: - * - */ - -static void hostap_flush_sta(struct vnt_private *pDevice) -{ - // reserved node index =0 for multicast node. - BSSvClearNodeDBTable(pDevice, 1); - pDevice->uAssocCount = 0; - - return; -} - -/* - * Description: - * set each stations encryption key - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ -static int hostap_set_encryption(struct vnt_private *pDevice, - struct viawget_hostapd_param *param, int param_len) -{ - struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - u32 dwKeyIndex = 0; - u8 abyKey[MAX_KEY_LEN]; - u8 abySeq[MAX_KEY_LEN]; - NDIS_802_11_KEY_RSC KeyRSC; - u8 byKeyDecMode = KEY_CTL_WEP; - int ret = 0; - s32 iNodeIndex = -1; - int ii; - bool bKeyTableFull = false; - u16 wKeyCtl = 0; - - param->u.crypt.err = 0; - - if (param->u.crypt.alg > WPA_ALG_CCMP) - return -EINVAL; - - if ((param->u.crypt.idx > 3) || (param->u.crypt.key_len > MAX_KEY_LEN)) { - param->u.crypt.err = HOSTAP_CRYPT_ERR_KEY_SET_FAILED; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " HOSTAP_CRYPT_ERR_KEY_SET_FAILED\n"); - return -EINVAL; - } - - if (is_broadcast_ether_addr(param->sta_addr)) { - if (param->u.crypt.idx >= MAX_GROUP_KEY) - return -EINVAL; - iNodeIndex = 0; - - } else { - if (BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &iNodeIndex) == false) { - param->u.crypt.err = HOSTAP_CRYPT_ERR_UNKNOWN_ADDR; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " HOSTAP_CRYPT_ERR_UNKNOWN_ADDR\n"); - return -EINVAL; - } - } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " hostap_set_encryption: sta_index %d \n", iNodeIndex); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " hostap_set_encryption: alg %d \n", param->u.crypt.alg); - - if (param->u.crypt.alg == WPA_ALG_NONE) { - - if (pMgmt->sNodeDBTable[iNodeIndex].bOnFly == true) { - if (KeybRemoveKey( pDevice, - &(pDevice->sKey), - param->sta_addr, - pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex - ) == false) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "KeybRemoveKey fail \n"); - } - pMgmt->sNodeDBTable[iNodeIndex].bOnFly = false; - } - pMgmt->sNodeDBTable[iNodeIndex].byKeyIndex = 0; - pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex = 0; - pMgmt->sNodeDBTable[iNodeIndex].uWepKeyLength = 0; - pMgmt->sNodeDBTable[iNodeIndex].KeyRSC = 0; - pMgmt->sNodeDBTable[iNodeIndex].dwTSC47_16 = 0; - pMgmt->sNodeDBTable[iNodeIndex].wTSC15_0 = 0; - pMgmt->sNodeDBTable[iNodeIndex].byCipherSuite = 0; - memset(&pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[0], - 0, - MAX_KEY_LEN - ); - - return ret; - } - - memcpy(abyKey, param->u.crypt.key, param->u.crypt.key_len); - // copy to node key tbl - pMgmt->sNodeDBTable[iNodeIndex].byKeyIndex = param->u.crypt.idx; - pMgmt->sNodeDBTable[iNodeIndex].uWepKeyLength = param->u.crypt.key_len; - memcpy(&pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[0], - param->u.crypt.key, - param->u.crypt.key_len - ); - - dwKeyIndex = (u32)(param->u.crypt.idx); - if (param->u.crypt.flags & HOSTAP_CRYPT_FLAG_SET_TX_KEY) { - pDevice->byKeyIndex = (u8)dwKeyIndex; - pDevice->bTransmitKey = true; - dwKeyIndex |= (1 << 31); - } - - if (param->u.crypt.alg == WPA_ALG_WEP) { - - if ((pDevice->bEnable8021x == false) || (iNodeIndex == 0)) { - KeybSetDefaultKey( pDevice, - &(pDevice->sKey), - dwKeyIndex & ~(BIT30 | USE_KEYRSC), - param->u.crypt.key_len, - NULL, - abyKey, - KEY_CTL_WEP - ); - - } else { - // 8021x enable, individual key - dwKeyIndex |= (1 << 30); // set pairwise key - if (KeybSetKey(pDevice, &(pDevice->sKey), - ¶m->sta_addr[0], - dwKeyIndex & ~(USE_KEYRSC), - param->u.crypt.key_len, - &KeyRSC, (u8 *)abyKey, - KEY_CTL_WEP - ) == true) { - - pMgmt->sNodeDBTable[iNodeIndex].bOnFly = true; - - } else { - // Key Table Full - pMgmt->sNodeDBTable[iNodeIndex].bOnFly = false; - bKeyTableFull = true; - } - } - pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled; - pDevice->bEncryptionEnable = true; - pMgmt->byCSSPK = KEY_CTL_WEP; - pMgmt->byCSSGK = KEY_CTL_WEP; - pMgmt->sNodeDBTable[iNodeIndex].byCipherSuite = KEY_CTL_WEP; - pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex = dwKeyIndex; - return ret; - } - - if (param->u.crypt.seq) { - memcpy(&abySeq, param->u.crypt.seq, 8); - for (ii = 0 ; ii < 8 ; ii++) - KeyRSC |= (unsigned long)abySeq[ii] << (ii * 8); - - dwKeyIndex |= 1 << 29; - pMgmt->sNodeDBTable[iNodeIndex].KeyRSC = KeyRSC; - } - - if (param->u.crypt.alg == WPA_ALG_TKIP) { - if (param->u.crypt.key_len != MAX_KEY_LEN) - return -EINVAL; - pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled; - byKeyDecMode = KEY_CTL_TKIP; - pMgmt->byCSSPK = KEY_CTL_TKIP; - pMgmt->byCSSGK = KEY_CTL_TKIP; - } - - if (param->u.crypt.alg == WPA_ALG_CCMP) { - if ((param->u.crypt.key_len != AES_KEY_LEN) || - (pDevice->byLocalID <= REV_ID_VT3253_A1)) - return -EINVAL; - pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled; - byKeyDecMode = KEY_CTL_CCMP; - pMgmt->byCSSPK = KEY_CTL_CCMP; - pMgmt->byCSSGK = KEY_CTL_CCMP; - } - - if (iNodeIndex == 0) { - KeybSetDefaultKey( pDevice, - &(pDevice->sKey), - dwKeyIndex, - param->u.crypt.key_len, - &KeyRSC, - abyKey, - byKeyDecMode - ); - pMgmt->sNodeDBTable[iNodeIndex].bOnFly = true; - - } else { - dwKeyIndex |= (1 << 30); // set pairwise key - if (KeybSetKey(pDevice, - &(pDevice->sKey), - ¶m->sta_addr[0], - dwKeyIndex, - param->u.crypt.key_len, - &KeyRSC, - (u8 *)abyKey, - byKeyDecMode - ) == true) { - - pMgmt->sNodeDBTable[iNodeIndex].bOnFly = true; - - } else { - // Key Table Full - pMgmt->sNodeDBTable[iNodeIndex].bOnFly = false; - bKeyTableFull = true; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Key Table Full\n"); - } - - } - - if (bKeyTableFull == true) { - wKeyCtl &= 0x7F00; // clear all key control filed - wKeyCtl |= (byKeyDecMode << 4); - wKeyCtl |= (byKeyDecMode); - wKeyCtl |= 0x0044; // use group key for all address - wKeyCtl |= 0x4000; // disable KeyTable[MAX_KEY_TABLE-1] on-fly to genernate rx int -// Todo.. xxxxxx - //MACvSetDefaultKeyCtl(pDevice->PortOffset, wKeyCtl, MAX_KEY_TABLE-1, pDevice->byLocalID); - } - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Set key sta_index= %d \n", iNodeIndex); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " tx_index=%d len=%d \n", param->u.crypt.idx, - param->u.crypt.key_len ); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " key=%x-%x-%x-%x-%x-xxxxx \n", - pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[0], - pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[1], - pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[2], - pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[3], - pMgmt->sNodeDBTable[iNodeIndex].abyWepKey[4] - ); - - // set wep key - pDevice->bEncryptionEnable = true; - pMgmt->sNodeDBTable[iNodeIndex].byCipherSuite = byKeyDecMode; - pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex = dwKeyIndex; - pMgmt->sNodeDBTable[iNodeIndex].dwTSC47_16 = 0; - pMgmt->sNodeDBTable[iNodeIndex].wTSC15_0 = 0; - - return ret; -} - -/* - * Description: - * get each stations encryption key - * - * Parameters: - * In: - * pDevice - - * param - - * Out: - * - * Return Value: - * - */ -static int hostap_get_encryption(struct vnt_private *pDevice, - struct viawget_hostapd_param *param, - int param_len) -{ - struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - int ret = 0; - int ii; - s32 iNodeIndex = 0; - - param->u.crypt.err = 0; - - if (is_broadcast_ether_addr(param->sta_addr)) { - iNodeIndex = 0; - } else { - if (BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &iNodeIndex) == false) { - param->u.crypt.err = HOSTAP_CRYPT_ERR_UNKNOWN_ADDR; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "hostap_get_encryption: HOSTAP_CRYPT_ERR_UNKNOWN_ADDR\n"); - return -EINVAL; - } - } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "hostap_get_encryption: %d\n", iNodeIndex); - memset(param->u.crypt.seq, 0, 8); - for (ii = 0 ; ii < 8 ; ii++) { - param->u.crypt.seq[ii] = (u8)pMgmt->sNodeDBTable[iNodeIndex].KeyRSC >> (ii * 8); - } - - return ret; -} - -/* - * Description: - * vt6656_hostap_ioctl main function supported for hostap daemon. - * - * Parameters: - * In: - * pDevice - - * iw_point - - * Out: - * - * Return Value: - * - */ - -int vt6656_hostap_ioctl(struct vnt_private *pDevice, struct iw_point *p) -{ - struct viawget_hostapd_param *param; - int ret = 0; - int ap_ioctl = 0; - - if (p->length < sizeof(struct viawget_hostapd_param) || - p->length > VIAWGET_HOSTAPD_MAX_BUF_SIZE || !p->pointer) - return -EINVAL; - - param = kmalloc((int)p->length, GFP_KERNEL); - if (param == NULL) - return -ENOMEM; - - if (copy_from_user(param, p->pointer, p->length)) { - ret = -EFAULT; - goto out; - } - - switch (param->cmd) { - case VIAWGET_HOSTAPD_SET_ENCRYPTION: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SET_ENCRYPTION \n"); - - ret = hostap_set_encryption(pDevice, param, p->length); - - break; - case VIAWGET_HOSTAPD_GET_ENCRYPTION: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_GET_ENCRYPTION \n"); - spin_lock_irq(&pDevice->lock); - ret = hostap_get_encryption(pDevice, param, p->length); - spin_unlock_irq(&pDevice->lock); - break; - case VIAWGET_HOSTAPD_SET_ASSOC_AP_ADDR: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SET_ASSOC_AP_ADDR \n"); - ret = -EOPNOTSUPP; - goto out; - case VIAWGET_HOSTAPD_FLUSH: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_FLUSH \n"); - spin_lock_irq(&pDevice->lock); - hostap_flush_sta(pDevice); - spin_unlock_irq(&pDevice->lock); - break; - case VIAWGET_HOSTAPD_ADD_STA: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_ADD_STA \n"); - spin_lock_irq(&pDevice->lock); - ret = hostap_add_sta(pDevice, param); - spin_unlock_irq(&pDevice->lock); - break; - case VIAWGET_HOSTAPD_REMOVE_STA: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_REMOVE_STA \n"); - spin_lock_irq(&pDevice->lock); - ret = hostap_remove_sta(pDevice, param); - spin_unlock_irq(&pDevice->lock); - break; - case VIAWGET_HOSTAPD_GET_INFO_STA: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_GET_INFO_STA \n"); - ret = hostap_get_info_sta(pDevice, param); - ap_ioctl = 1; - break; - case VIAWGET_HOSTAPD_SET_FLAGS_STA: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SET_FLAGS_STA \n"); - ret = hostap_set_flags_sta(pDevice, param); - break; - - case VIAWGET_HOSTAPD_MLME: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_MLME \n"); - ret = -EOPNOTSUPP; - goto out; - - case VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT \n"); - ret = hostap_set_generic_element(pDevice, param); - break; - - case VIAWGET_HOSTAPD_SCAN_REQ: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SCAN_REQ \n"); - ret = -EOPNOTSUPP; - goto out; - - case VIAWGET_HOSTAPD_STA_CLEAR_STATS: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_STA_CLEAR_STATS \n"); - ret = -EOPNOTSUPP; - goto out; - default: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "vt6656_hostap_ioctl: unknown cmd=%d\n", - (int)param->cmd); - ret = -EOPNOTSUPP; - goto out; - } - - if ((ret == 0) && ap_ioctl) { - if (copy_to_user(p->pointer, param, p->length)) { - ret = -EFAULT; - goto out; - } - } - - out: - kfree(param); - - return ret; -} - diff --git a/drivers/staging/vt6656/hostap.h b/drivers/staging/vt6656/hostap.h deleted file mode 100644 index 6a68f7e69cff..000000000000 --- a/drivers/staging/vt6656/hostap.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: hostap.h - * - * Purpose: - * - * Author: Lyndon Chen - * - * Date: May 21, 2003 - * - */ - -#ifndef __HOSTAP_H__ -#define __HOSTAP_H__ - -#include "device.h" - -#define WLAN_RATE_1M BIT0 -#define WLAN_RATE_2M BIT1 -#define WLAN_RATE_5M5 BIT2 -#define WLAN_RATE_11M BIT3 -#define WLAN_RATE_6M BIT4 -#define WLAN_RATE_9M BIT5 -#define WLAN_RATE_12M BIT6 -#define WLAN_RATE_18M BIT7 -#define WLAN_RATE_24M BIT8 -#define WLAN_RATE_36M BIT9 -#define WLAN_RATE_48M BIT10 -#define WLAN_RATE_54M BIT11 - -#ifndef ETH_P_PAE -#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ -#endif /* ETH_P_PAE */ - -#ifndef ARPHRD_IEEE80211 -#define ARPHRD_IEEE80211 801 -#endif - -int vt6656_hostap_set_hostapd(struct vnt_private *, int val, int rtnl_locked); -int vt6656_hostap_ioctl(struct vnt_private *, struct iw_point *p); - -#endif /* __HOSTAP_H__ */ diff --git a/drivers/staging/vt6656/iwctl.c b/drivers/staging/vt6656/iwctl.c index 38739fa32461..a148cede48ca 100644 --- a/drivers/staging/vt6656/iwctl.c +++ b/drivers/staging/vt6656/iwctl.c @@ -34,7 +34,6 @@ #include "iwctl.h" #include "mac.h" #include "card.h" -#include "hostap.h" #include "power.h" #include "rf.h" #include "iowpa.h" diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 3a576fa87dbc..b38be8df86c5 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -60,7 +60,6 @@ #include "tcrc.h" #include "rxtx.h" #include "bssdb.h" -#include "hostap.h" #include "wpactl.h" #include "iwctl.h" #include "dpc.h" @@ -1391,20 +1390,9 @@ static struct net_device_stats *device_get_stats(struct net_device *dev) static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { - struct vnt_private *pDevice = netdev_priv(dev); - struct iwreq *wrq = (struct iwreq *) rq; int rc = 0; switch (cmd) { - - case IOCTL_CMD_HOSTAPD: - - if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) - rc = -EFAULT; - - rc = vt6656_hostap_ioctl(pDevice, &wrq->u.data); - break; - case SIOCETHTOOL: return ethtool_ioctl(dev, rq); diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 4ec79c461d45..8e0045aeb582 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -56,7 +56,6 @@ #include "tkip.h" #include "tcrc.h" #include "wctl.h" -#include "hostap.h" #include "rf.h" #include "datarate.h" #include "usbpipe.h" -- cgit v1.2.3 From 90f96acd1b6ea7c16e43303f74bc97f8250010ac Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 19 May 2014 20:32:54 +0100 Subject: staging: vt6656: Remove hostapd functions. Remove throughout driver bEnableHostapd bEnable8021x bEnableHostWEP struct net_device *apdev tx_80211 Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/bssdb.c | 4 +- drivers/staging/vt6656/device.h | 7 - drivers/staging/vt6656/dpc.c | 210 +------------------- drivers/staging/vt6656/iocmd.h | 301 ---------------------------- drivers/staging/vt6656/iwctl.c | 16 -- drivers/staging/vt6656/main_usb.c | 18 -- drivers/staging/vt6656/rxtx.c | 406 -------------------------------------- drivers/staging/vt6656/wcmd.c | 7 +- drivers/staging/vt6656/wmgr.c | 45 +---- 9 files changed, 13 insertions(+), 1001 deletions(-) diff --git a/drivers/staging/vt6656/bssdb.c b/drivers/staging/vt6656/bssdb.c index de60c99601d4..5f631c8f522b 100644 --- a/drivers/staging/vt6656/bssdb.c +++ b/drivers/staging/vt6656/bssdb.c @@ -771,8 +771,8 @@ void BSSvAddMulticastNode(struct vnt_private *pDevice) { struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - if (!pDevice->bEnableHostWEP) - memset(&pMgmt->sNodeDBTable[0], 0, sizeof(KnownNodeDB)); + memset(&pMgmt->sNodeDBTable[0], 0, sizeof(KnownNodeDB)); + memset(pMgmt->sNodeDBTable[0].abyMACAddr, 0xff, WLAN_ADDR_LEN); pMgmt->sNodeDBTable[0].bActive = true; pMgmt->sNodeDBTable[0].bPSEnable = false; diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index 606ca9fcd3d2..d55f81c8ec61 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -707,13 +707,6 @@ struct vnt_private { int bwextstep3; int bWPASuppWextEnabled; - /* user space daemon: hostapd, is used for HOSTAP */ - int bEnableHostapd; - int bEnable8021x; - int bEnableHostWEP; - struct net_device *apdev; - int (*tx_80211)(struct sk_buff *skb, struct net_device *dev); - u32 uChannel; struct iw_statistics wstats; /* wireless stats */ diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c index 2596fcecc4b7..a1ae21355076 100644 --- a/drivers/staging/vt6656/dpc.c +++ b/drivers/staging/vt6656/dpc.c @@ -29,7 +29,6 @@ * s_bAPModeRxCtl- AP Rcv frame filer Ctl. * s_bAPModeRxData- AP Rcv data frame handle * s_bHandleRxEncryption- Rcv decrypted data via on-fly - * s_bHostWepRxEncryption- Rcv encrypted data via host * s_byGetRateIdx- get rate index * s_vGetDASA- get data offset * s_vProcessRxMACHeader- Rcv 802.11 and translate to 802.3 @@ -86,10 +85,6 @@ static int s_bHandleRxEncryption(struct vnt_private *pDevice, u8 *pbyFrame, u32 FrameSize, u8 *pbyRsr, u8 *pbyNewRsr, PSKeyItem *pKeyOut, s32 *pbExtIV, u16 *pwRxTSC15_0, u32 *pdwRxTSC47_16); -static int s_bHostWepRxEncryption(struct vnt_private *pDevice, u8 *pbyFrame, - u32 FrameSize, u8 *pbyRsr, int bOnFly, PSKeyItem pKey, u8 *pbyNewRsr, - s32 *pbExtIV, u16 *pwRxTSC15_0, u32 *pdwRxTSC47_16); - /*+ * * Description: @@ -267,7 +262,6 @@ int RXbBulkInProcessData(struct vnt_private *pDevice, struct vnt_rcb *pRCB, PSKeyItem pKey = NULL; u16 wRxTSC15_0 = 0; u32 dwRxTSC47_16 = 0; - SKeyItem STempKey; /* signed long ldBm = 0; */ int bIsWEP = false; int bExtIV = false; u32 dwWbkStatus; @@ -400,39 +394,9 @@ int RXbBulkInProcessData(struct vnt_private *pDevice, struct vnt_rcb *pRCB, DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"rx WEP pkt\n"); bIsWEP = true; - if ((pDevice->bEnableHostWEP) && (iSANodeIndex >= 0)) { - pKey = &STempKey; - pKey->byCipherSuite = pMgmt->sNodeDBTable[iSANodeIndex].byCipherSuite; - pKey->dwKeyIndex = pMgmt->sNodeDBTable[iSANodeIndex].dwKeyIndex; - pKey->uKeyLength = pMgmt->sNodeDBTable[iSANodeIndex].uWepKeyLength; - pKey->dwTSC47_16 = pMgmt->sNodeDBTable[iSANodeIndex].dwTSC47_16; - pKey->wTSC15_0 = pMgmt->sNodeDBTable[iSANodeIndex].wTSC15_0; - memcpy(pKey->abyKey, - &pMgmt->sNodeDBTable[iSANodeIndex].abyWepKey[0], - pKey->uKeyLength - ); - - bRxDecryOK = s_bHostWepRxEncryption(pDevice, - pbyFrame, - FrameSize, - pbyRsr, - pMgmt->sNodeDBTable[iSANodeIndex].bOnFly, - pKey, - pbyNewRsr, - &bExtIV, - &wRxTSC15_0, - &dwRxTSC47_16); - } else { - bRxDecryOK = s_bHandleRxEncryption(pDevice, - pbyFrame, - FrameSize, - pbyRsr, - pbyNewRsr, - &pKey, - &bExtIV, - &wRxTSC15_0, - &dwRxTSC47_16); - } + + bRxDecryOK = s_bHandleRxEncryption(pDevice, pbyFrame, FrameSize, + pbyRsr, pbyNewRsr, &pKey, &bExtIV, &wRxTSC15_0, &dwRxTSC47_16); if (bRxDecryOK) { if ((*pbyNewRsr & NEWRSR_DECRYPTOK) == 0) { @@ -516,22 +480,6 @@ int RXbBulkInProcessData(struct vnt_private *pDevice, struct vnt_rcb *pRCB, } pRxPacket->byRxChannel = (*pbyRxSts) >> 2; - // hostap Deamon handle 802.11 management - if (pDevice->bEnableHostapd) { - skb->dev = pDevice->apdev; - //skb->data += 4; - //skb->tail += 4; - skb->data += 8; - skb->tail += 8; - skb_put(skb, FrameSize); - skb_reset_mac_header(skb); - skb->pkt_type = PACKET_OTHERHOST; - skb->protocol = htons(ETH_P_802_2); - memset(skb->cb, 0, sizeof(skb->cb)); - netif_rx(skb); - return true; - } - // // Insert the RCB in the Recv Mng list // @@ -653,45 +601,6 @@ int RXbBulkInProcessData(struct vnt_private *pDevice, struct vnt_rcb *pRCB, } */ - // ----------------------------------------------- - - if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pDevice->bEnable8021x == true)){ - u8 abyMacHdr[24]; - - // Only 802.1x packet incoming allowed - if (bIsWEP) - cbIVOffset = 8; - else - cbIVOffset = 0; - wEtherType = (skb->data[cbIVOffset + 8 + 24 + 6] << 8) | - skb->data[cbIVOffset + 8 + 24 + 6 + 1]; - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wEtherType = %04x \n", wEtherType); - if (wEtherType == ETH_P_PAE) { - skb->dev = pDevice->apdev; - - if (bIsWEP == true) { - // strip IV header(8) - memcpy(&abyMacHdr[0], (skb->data + 8), 24); - memcpy((skb->data + 8 + cbIVOffset), &abyMacHdr[0], 24); - } - - skb->data += (cbIVOffset + 8); - skb->tail += (cbIVOffset + 8); - skb_put(skb, FrameSize); - skb_reset_mac_header(skb); - skb->pkt_type = PACKET_OTHERHOST; - skb->protocol = htons(ETH_P_802_2); - memset(skb->cb, 0, sizeof(skb->cb)); - netif_rx(skb); - return true; - - } - // check if 802.1x authorized - if (!(pMgmt->sNodeDBTable[iSANodeIndex].dwFlags & WLAN_STA_AUTHORIZED)) - return false; - } - if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_TKIP)) { if (bIsWEP) { FrameSize -= 8; //MIC @@ -1097,119 +1006,6 @@ static int s_bHandleRxEncryption(struct vnt_private *pDevice, u8 *pbyFrame, return true; } -static int s_bHostWepRxEncryption(struct vnt_private *pDevice, u8 *pbyFrame, - u32 FrameSize, u8 *pbyRsr, int bOnFly, PSKeyItem pKey, u8 *pbyNewRsr, - s32 *pbExtIV, u16 *pwRxTSC15_0, u32 *pdwRxTSC47_16) -{ - struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - struct ieee80211_hdr *pMACHeader; - u32 PayloadLen = FrameSize; - u8 *pbyIV; - u8 byKeyIdx; - u8 byDecMode = KEY_CTL_WEP; - - *pwRxTSC15_0 = 0; - *pdwRxTSC47_16 = 0; - - pbyIV = pbyFrame + WLAN_HDR_ADDR3_LEN; - if ( WLAN_GET_FC_TODS(*(u16 *)pbyFrame) && - WLAN_GET_FC_FROMDS(*(u16 *)pbyFrame) ) { - pbyIV += 6; // 6 is 802.11 address4 - PayloadLen -= 6; - } - byKeyIdx = (*(pbyIV+3) & 0xc0); - byKeyIdx >>= 6; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\nKeyIdx: %d\n", byKeyIdx); - - if (pMgmt->byCSSGK == KEY_CTL_TKIP) - byDecMode = KEY_CTL_TKIP; - else if (pMgmt->byCSSGK == KEY_CTL_CCMP) - byDecMode = KEY_CTL_CCMP; - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"AES:%d %d %d\n", pMgmt->byCSSPK, pMgmt->byCSSGK, byDecMode); - - if (byDecMode != pKey->byCipherSuite) { - return false; - } - - if (byDecMode == KEY_CTL_WEP) { - // handle WEP - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"byDecMode == KEY_CTL_WEP\n"); - if ((pDevice->byLocalID <= REV_ID_VT3253_A1) || - (((PSKeyTable)(pKey->pvKeyTable))->bSoftWEP == true) || - (bOnFly == false)) { - // Software WEP - // 1. 3253A - // 2. WEP 256 - // 3. NotOnFly - - PayloadLen -= (WLAN_HDR_ADDR3_LEN + 4 + 4); // 24 is 802.11 header,4 is IV, 4 is crc - memcpy(pDevice->abyPRNG, pbyIV, 3); - memcpy(pDevice->abyPRNG + 3, pKey->abyKey, pKey->uKeyLength); - rc4_init(&pDevice->SBox, pDevice->abyPRNG, pKey->uKeyLength + 3); - rc4_encrypt(&pDevice->SBox, pbyIV+4, pbyIV+4, PayloadLen); - - if (ETHbIsBufferCrc32Ok(pbyIV+4, PayloadLen)) { - *pbyNewRsr |= NEWRSR_DECRYPTOK; - } - } - } else if ((byDecMode == KEY_CTL_TKIP) || - (byDecMode == KEY_CTL_CCMP)) { - // TKIP/AES - - PayloadLen -= (WLAN_HDR_ADDR3_LEN + 8 + 4); // 24 is 802.11 header, 8 is IV&ExtIV, 4 is crc - *pdwRxTSC47_16 = cpu_to_le32(*(u32 *)(pbyIV + 4)); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ExtIV: %x\n", *pdwRxTSC47_16); - - if (byDecMode == KEY_CTL_TKIP) { - *pwRxTSC15_0 = cpu_to_le16(MAKEWORD(*(pbyIV+2), *pbyIV)); - } else { - *pwRxTSC15_0 = cpu_to_le16(*(u16 *)pbyIV); - } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TSC0_15: %x\n", *pwRxTSC15_0); - - if (byDecMode == KEY_CTL_TKIP) { - - if ((pDevice->byLocalID <= REV_ID_VT3253_A1) || (bOnFly == false)) { - // Software TKIP - // 1. 3253 A - // 2. NotOnFly - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"soft KEY_CTL_TKIP \n"); - pMACHeader = (struct ieee80211_hdr *) (pbyFrame); - TKIPvMixKey(pKey->abyKey, pMACHeader->addr2, *pwRxTSC15_0, *pdwRxTSC47_16, pDevice->abyPRNG); - rc4_init(&pDevice->SBox, pDevice->abyPRNG, TKIP_KEY_LEN); - rc4_encrypt(&pDevice->SBox, pbyIV+8, pbyIV+8, PayloadLen); - if (ETHbIsBufferCrc32Ok(pbyIV+8, PayloadLen)) { - *pbyNewRsr |= NEWRSR_DECRYPTOK; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ICV OK!\n"); - } else { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ICV FAIL!!!\n"); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"PayloadLen = %d\n", PayloadLen); - } - } - } - - if (byDecMode == KEY_CTL_CCMP) { - if (bOnFly == false) { - // Software CCMP - // NotOnFly - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"soft KEY_CTL_CCMP\n"); - if (AESbGenCCMP(pKey->abyKey, pbyFrame, FrameSize)) { - *pbyNewRsr |= NEWRSR_DECRYPTOK; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"CCMP MIC compare OK!\n"); - } else { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"CCMP MIC fail!\n"); - } - } - } - - }// end of TKIP/AES - - if ((*(pbyIV+3) & 0x20) != 0) - *pbExtIV = true; - return true; -} - static int s_bAPModeRxData(struct vnt_private *pDevice, struct sk_buff *skb, u32 FrameSize, u32 cbHeaderOffset, s32 iSANodeIndex, s32 iDANodeIndex) { diff --git a/drivers/staging/vt6656/iocmd.h b/drivers/staging/vt6656/iocmd.h index f3406da7336e..abf1f86ef0af 100644 --- a/drivers/staging/vt6656/iocmd.h +++ b/drivers/staging/vt6656/iocmd.h @@ -29,57 +29,12 @@ #ifndef __IOCMD_H__ #define __IOCMD_H__ -// ioctl Command code -#define MAGIC_CODE 0x3142 -#define IOCTL_CMD_TEST (SIOCDEVPRIVATE + 0) -#define IOCTL_CMD_SET (SIOCDEVPRIVATE + 1) -#define IOCTL_CMD_HOSTAPD (SIOCDEVPRIVATE + 2) -#define IOCTL_CMD_WPA (SIOCDEVPRIVATE + 3) - -typedef enum tagWMAC_CMD { - - WLAN_CMD_BSS_SCAN, - WLAN_CMD_BSS_JOIN, - WLAN_CMD_DISASSOC, - WLAN_CMD_SET_WEP, - WLAN_CMD_GET_LINK, - WLAN_CMD_GET_LISTLEN, - WLAN_CMD_GET_LIST, - WLAN_CMD_GET_MIB, - WLAN_CMD_GET_STAT, - WLAN_CMD_STOP_MAC, - WLAN_CMD_START_MAC, - WLAN_CMD_AP_START, - WLAN_CMD_SET_HOSTAPD, - WLAN_CMD_SET_HOSTAPD_STA, - WLAN_CMD_SET_802_1X, - WLAN_CMD_SET_HOST_WEP, - WLAN_CMD_SET_WPA, - WLAN_CMD_GET_NODE_CNT, - WLAN_CMD_ZONETYPE_SET, - WLAN_CMD_GET_NODE_LIST - -} WMAC_CMD, *PWMAC_CMD; - typedef enum tagWZONETYPE { ZoneType_USA = 0, ZoneType_Japan = 1, ZoneType_Europe = 2 } WZONETYPE; -#define ADHOC 0 -#define INFRA 1 -#define BOTH 2 -#define AP 3 - -#define ADHOC_STARTED 1 -#define ADHOC_JOINTED 2 - -#define PHY80211a 0 -#define PHY80211b 1 -#define PHY80211g 2 - -#define SSID_ID 0 #define SSID_MAXLEN 32 #define BSSID_LEN 6 #define WEP_NKEYS 4 @@ -88,82 +43,6 @@ typedef enum tagWZONETYPE { #define WEP_104BIT_LEN 13 #define WEP_232BIT_LEN 16 -// Ioctl interface structure -// Command structure -// -typedef struct tagSCmdRequest { - u8 name[16]; - void *data; - u16 wResult; - u16 wCmdCode; -} __packed SCmdRequest, *PSCmdRequest; - -// -// Scan -// - -typedef struct tagSCmdScan { - - u8 ssid[SSID_MAXLEN + 2]; - -} __packed SCmdScan, *PSCmdScan; - -// -// BSS Join -// - -typedef struct tagSCmdBSSJoin { - - u16 wBSSType; - u16 wBBPType; - u8 ssid[SSID_MAXLEN + 2]; - u32 uChannel; - bool bPSEnable; - bool bShareKeyAuth; - -} __packed SCmdBSSJoin, *PSCmdBSSJoin; - -// -// Zonetype Setting -// - -typedef struct tagSCmdZoneTypeSet { - - bool bWrite; - WZONETYPE ZoneType; - -} __packed SCmdZoneTypeSet, *PSCmdZoneTypeSet; - -typedef struct tagSWPAResult { - char ifname[100]; - u8 proto; - u8 key_mgmt; - u8 eap_type; - bool authenticated; -} __packed SWPAResult, *PSWPAResult; - -typedef struct tagSCmdStartAP { - - u16 wBSSType; - u16 wBBPType; - u8 ssid[SSID_MAXLEN + 2]; - u32 uChannel; - u32 uBeaconInt; - bool bShareKeyAuth; - u8 byBasicRate; - -} __packed SCmdStartAP, *PSCmdStartAP; - -typedef struct tagSCmdSetWEP { - - bool bEnableWep; - u8 byKeyIndex; - u8 abyWepKey[WEP_NKEYS][WEP_KEYMAXLEN]; - bool bWepKeyAvailable[WEP_NKEYS]; - u32 auWepKeyLength[WEP_NKEYS]; - -} __packed SCmdSetWEP, *PSCmdSetWEP; - typedef struct tagSBSSIDItem { u32 uChannel; @@ -177,12 +56,6 @@ typedef struct tagSBSSIDItem { } __packed SBSSIDItem; -typedef struct tagSBSSIDList { - - u32 uItem; - SBSSIDItem sBSSIDList[0]; -} __packed SBSSIDList, *PSBSSIDList; - typedef struct tagSNodeItem { // STA info u16 wAID; @@ -203,180 +76,6 @@ typedef struct tagSNodeItem { } __packed SNodeItem; -typedef struct tagSNodeList { - - u32 uItem; - SNodeItem sNodeList[0]; - -} __packed SNodeList, *PSNodeList; - -typedef struct tagSCmdLinkStatus { - - bool bLink; - u16 wBSSType; - u8 byState; - u8 abyBSSID[BSSID_LEN]; - u8 abySSID[SSID_MAXLEN + 2]; - u32 uChannel; - u32 uLinkRate; - -} __packed SCmdLinkStatus, *PSCmdLinkStatus; - -// -// 802.11 counter -// -typedef struct tagSDot11MIBCount { - u32 TransmittedFragmentCount; - u32 MulticastTransmittedFrameCount; - u32 FailedCount; - u32 RetryCount; - u32 MultipleRetryCount; - u32 RTSSuccessCount; - u32 RTSFailureCount; - u32 ACKFailureCount; - u32 FrameDuplicateCount; - u32 ReceivedFragmentCount; - u32 MulticastReceivedFrameCount; - u32 FCSErrorCount; -} __packed SDot11MIBCount, *PSDot11MIBCount; - -// -// statistic counter -// -typedef struct tagSStatMIBCount { - // - // ISR status count - // - u32 dwIsrTx0OK; - u32 dwIsrTx1OK; - u32 dwIsrBeaconTxOK; - u32 dwIsrRxOK; - u32 dwIsrTBTTInt; - u32 dwIsrSTIMERInt; - u32 dwIsrUnrecoverableError; - u32 dwIsrSoftInterrupt; - u32 dwIsrRxNoBuf; - ///////////////////////////////////// - - u32 dwIsrUnknown; /* unknown interrupt count */ - - // RSR status count - // - u32 dwRsrFrmAlgnErr; - u32 dwRsrErr; - u32 dwRsrCRCErr; - u32 dwRsrCRCOk; - u32 dwRsrBSSIDOk; - u32 dwRsrADDROk; - u32 dwRsrICVOk; - u32 dwNewRsrShortPreamble; - u32 dwRsrLong; - u32 dwRsrRunt; - - u32 dwRsrRxControl; - u32 dwRsrRxData; - u32 dwRsrRxManage; - - u32 dwRsrRxPacket; - u32 dwRsrRxOctet; - u32 dwRsrBroadcast; - u32 dwRsrMulticast; - u32 dwRsrDirected; - // 64-bit OID - u32 ullRsrOK; - - // for some optional OIDs (64 bits) and DMI support - u32 ullRxBroadcastBytes; - u32 ullRxMulticastBytes; - u32 ullRxDirectedBytes; - u32 ullRxBroadcastFrames; - u32 ullRxMulticastFrames; - u32 ullRxDirectedFrames; - - u32 dwRsrRxFragment; - u32 dwRsrRxFrmLen64; - u32 dwRsrRxFrmLen65_127; - u32 dwRsrRxFrmLen128_255; - u32 dwRsrRxFrmLen256_511; - u32 dwRsrRxFrmLen512_1023; - u32 dwRsrRxFrmLen1024_1518; - - // TSR0,1 status count - // - u32 dwTsrTotalRetry[2]; /* total collision retry count */ - u32 dwTsrOnceRetry[2]; /* this packet had one collision */ - u32 dwTsrMoreThanOnceRetry[2]; /* this packet had many collisions */ - u32 dwTsrRetry[2]; /* this packet has ever occur collision, - * that is (dwTsrOnceCollision0 plus - * dwTsrMoreThanOnceCollision0) */ - u32 dwTsrACKData[2]; - u32 dwTsrErr[2]; - u32 dwAllTsrOK[2]; - u32 dwTsrRetryTimeout[2]; - u32 dwTsrTransmitTimeout[2]; - - u32 dwTsrTxPacket[2]; - u32 dwTsrTxOctet[2]; - u32 dwTsrBroadcast[2]; - u32 dwTsrMulticast[2]; - u32 dwTsrDirected[2]; - - // RD/TD count - u32 dwCntRxFrmLength; - u32 dwCntTxBufLength; - - u8 abyCntRxPattern[16]; - u8 abyCntTxPattern[16]; - - /* Software check.... */ - u32 dwCntRxDataErr; /* rx buffer data CRC err count */ - u32 dwCntDecryptErr; /* rx buffer data CRC err count */ - u32 dwCntRxICVErr; /* rx buffer data CRC err count */ - u32 idxRxErrorDesc; /* index for rx data error RD */ - - /* 64-bit OID */ - u32 ullTsrOK[2]; - - // for some optional OIDs (64 bits) and DMI support - u32 ullTxBroadcastFrames[2]; - u32 ullTxMulticastFrames[2]; - u32 ullTxDirectedFrames[2]; - u32 ullTxBroadcastBytes[2]; - u32 ullTxMulticastBytes[2]; - u32 ullTxDirectedBytes[2]; -} __packed SStatMIBCount, *PSStatMIBCount; - -typedef struct tagSCmdValue { - - u32 dwValue; - -} __packed SCmdValue, *PSCmdValue; - -// -// hostapd & viawget ioctl related -// - -// VIAGWET_IOCTL_HOSTAPD ioctl() cmd: -enum { - VIAWGET_HOSTAPD_FLUSH = 1, - VIAWGET_HOSTAPD_ADD_STA = 2, - VIAWGET_HOSTAPD_REMOVE_STA = 3, - VIAWGET_HOSTAPD_GET_INFO_STA = 4, - VIAWGET_HOSTAPD_SET_ENCRYPTION = 5, - VIAWGET_HOSTAPD_GET_ENCRYPTION = 6, - VIAWGET_HOSTAPD_SET_FLAGS_STA = 7, - VIAWGET_HOSTAPD_SET_ASSOC_AP_ADDR = 8, - VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT = 9, - VIAWGET_HOSTAPD_MLME = 10, - VIAWGET_HOSTAPD_SCAN_REQ = 11, - VIAWGET_HOSTAPD_STA_CLEAR_STATS = 12, -}; - -#define VIAWGET_HOSTAPD_GENERIC_ELEMENT_HDR_LEN \ -((int) (&((struct viawget_hostapd_param *) 0)->u.generic_elem.data)) - -// Maximum length for algorithm names (-1 for nul termination) used in ioctl() - struct viawget_hostapd_param { u32 cmd; u8 sta_addr[6]; diff --git a/drivers/staging/vt6656/iwctl.c b/drivers/staging/vt6656/iwctl.c index a148cede48ca..de2ae1d46434 100644 --- a/drivers/staging/vt6656/iwctl.c +++ b/drivers/staging/vt6656/iwctl.c @@ -382,12 +382,6 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info, if (pMgmt == NULL) return -EFAULT; - if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP && pDevice->bEnableHostapd) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "Can't set operation mode, hostapd is running\n"); - return rc; - } - switch (*wmode) { case IW_MODE_ADHOC: if (pMgmt->eConfigMode != WMAC_CONFIG_IBSS_STA) { @@ -407,19 +401,9 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info, DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to infrastructure\n"); break; case IW_MODE_MASTER: - - pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA; rc = -EOPNOTSUPP; break; - if (pMgmt->eConfigMode != WMAC_CONFIG_AP) { - pMgmt->eConfigMode = WMAC_CONFIG_AP; - if (pDevice->flags & DEVICE_FLAGS_OPENED) - pDevice->bCommit = true; - } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to Access Point\n"); - break; - case IW_MODE_REPEAT: pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA; rc = -EOPNOTSUPP; diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index b38be8df86c5..9f888d511d75 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -216,7 +216,6 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); static int device_init_registers(struct vnt_private *pDevice); static bool device_init_defrag_cb(struct vnt_private *pDevice); static void device_init_diversity_timer(struct vnt_private *pDevice); -static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev); static int ethtool_ioctl(struct net_device *dev, struct ifreq *); static void device_free_tx_bufs(struct vnt_private *pDevice); @@ -683,7 +682,6 @@ vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id) INIT_WORK(&pDevice->read_work_item, RXvWorkItem); INIT_WORK(&pDevice->rx_mng_work_item, RXvMngWorkItem); - pDevice->tx_80211 = device_dma0_tx_80211; pDevice->vnt_mgmt.pAdapter = (void *) pDevice; netdev->netdev_ops = &device_netdev_ops; @@ -1108,22 +1106,6 @@ static void vt6656_disconnect(struct usb_interface *intf) } } -static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev) -{ - struct vnt_private *pDevice = netdev_priv(dev); - - spin_lock_irq(&pDevice->lock); - - if (unlikely(pDevice->bStopTx0Pkt)) - dev_kfree_skb_irq(skb); - else - vDMA0_tx_80211(pDevice, skb); - - spin_unlock_irq(&pDevice->lock); - - return NETDEV_TX_OK; -} - static int device_xmit(struct sk_buff *skb, struct net_device *dev) { struct vnt_private *pDevice = netdev_priv(dev); diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 8e0045aeb582..771318170a0c 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -954,7 +954,6 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, u32 *pcbHeaderLen, u32 *pcbTotalLen) { struct vnt_tx_fifo_head *pTxBufHead = &tx_buffer->fifo_head; - struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; u32 cbFrameSize, cbFrameBodySize; u32 cb802_1_H_len; u32 cbIVlen = 0, cbICVlen = 0, cbMIClen = 0, cbMACHdLen = 0; @@ -1160,11 +1159,6 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, //Fill TXKEY s_vFillTxKey(pDevice, pTxBufHead, pbyIVHead, pTransmitKey, pbyMacHdr, (u16)cbFrameBodySize, pMICHDR); - - if (pDevice->bEnableHostWEP) { - pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16; - pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0; - } } /* 802.1H */ @@ -1713,364 +1707,6 @@ CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, } -void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) -{ - struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - struct vnt_tx_buffer *pTX_Buffer; - struct vnt_tx_fifo_head *pTxBufHead; - u8 byPktType; - u8 *pbyTxBufferAddr; - u32 uDuration, cbReqCount; - struct ieee80211_hdr *pMACHeader; - u32 cbHeaderSize, cbFrameBodySize; - int bNeedACK, bIsPSPOLL = false; - u32 cbFrameSize; - u32 cbIVlen = 0, cbICVlen = 0, cbMIClen = 0, cbFCSlen = 4; - u32 uPadding = 0; - u32 cbMICHDR = 0, uLength = 0; - u32 dwMICKey0, dwMICKey1; - u32 dwMIC_Priority; - u32 *pdwMIC_L, *pdwMIC_R; - u16 wTxBufSize; - u32 cbMacHdLen; - struct ethhdr sEthHeader; - struct vnt_mic_hdr *pMICHDR; - u32 wCurrentRate = RATE_1M; - PUWLAN_80211HDR p80211Header; - u32 uNodeIndex = 0; - int bNodeExist = false; - SKeyItem STempKey; - PSKeyItem pTransmitKey = NULL; - u8 *pbyIVHead, *pbyPayloadHead, *pbyMacHdr; - u32 cbExtSuppRate = 0; - struct vnt_usb_send_context *pContext; - - pMICHDR = NULL; - - if(skb->len <= WLAN_HDR_ADDR3_LEN) { - cbFrameBodySize = 0; - } - else { - cbFrameBodySize = skb->len - WLAN_HDR_ADDR3_LEN; - } - p80211Header = (PUWLAN_80211HDR)skb->data; - - pContext = s_vGetFreeContext(pDevice); - - if (NULL == pContext) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"DMA0 TX...NO CONTEXT!\n"); - dev_kfree_skb_irq(skb); - return ; - } - - pTX_Buffer = (struct vnt_tx_buffer *)&pContext->data[0]; - pTxBufHead = &pTX_Buffer->fifo_head; - pbyTxBufferAddr = (u8 *)&pTxBufHead->adwTxKey[0]; - wTxBufSize = sizeof(struct vnt_tx_fifo_head); - - if (pDevice->byBBType == BB_TYPE_11A) { - wCurrentRate = RATE_6M; - byPktType = PK_TYPE_11A; - } else { - wCurrentRate = RATE_1M; - byPktType = PK_TYPE_11B; - } - - // SetPower will cause error power TX state for OFDM Date packet in TX buffer. - // 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability. - // And cmd timer will wait data pkt TX finish before scanning so it's OK - // to set power here. - if (wCurrentRate != pDevice->wCurrentRate) { - pDevice->wCurrentRate = wCurrentRate; - - bScheduleCommand(pDevice, WLAN_CMD_SETPOWER, NULL); - } - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"vDMA0_tx_80211: p80211Header->sA3.wFrameCtl = %x \n", p80211Header->sA3.wFrameCtl); - - //Set packet type - if (byPktType == PK_TYPE_11A) {//0000 0000 0000 0000 - pTxBufHead->wFIFOCtl = 0; - } - else if (byPktType == PK_TYPE_11B) {//0000 0001 0000 0000 - pTxBufHead->wFIFOCtl |= FIFOCTL_11B; - } - else if (byPktType == PK_TYPE_11GB) {//0000 0010 0000 0000 - pTxBufHead->wFIFOCtl |= FIFOCTL_11GB; - } - else if (byPktType == PK_TYPE_11GA) {//0000 0011 0000 0000 - pTxBufHead->wFIFOCtl |= FIFOCTL_11GA; - } - - pTxBufHead->wFIFOCtl |= FIFOCTL_TMOEN; - pTxBufHead->time_stamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us); - - if (is_multicast_ether_addr(p80211Header->sA3.abyAddr1)) { - bNeedACK = false; - if (pDevice->bEnableHostWEP) { - uNodeIndex = 0; - bNodeExist = true; - } - } - else { - if (pDevice->bEnableHostWEP) { - if (BSSbIsSTAInNodeDB(pDevice, (u8 *)(p80211Header->sA3.abyAddr1), &uNodeIndex)) - bNodeExist = true; - } - bNeedACK = true; - pTxBufHead->wFIFOCtl |= FIFOCTL_NEEDACK; - }; - - if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) || - (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ) { - - pTxBufHead->wFIFOCtl |= FIFOCTL_LRETRY; - //Set Preamble type always long - //pDevice->byPreambleType = PREAMBLE_LONG; - - // probe-response don't retry - //if ((p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_MGMT_PROBE_RSP) { - // bNeedACK = false; - // pTxBufHead->wFIFOCtl &= (~FIFOCTL_NEEDACK); - //} - } - - pTxBufHead->wFIFOCtl |= (FIFOCTL_GENINT | FIFOCTL_ISDMA0); - - if ((p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_CTL_PSPOLL) { - bIsPSPOLL = true; - cbMacHdLen = WLAN_HDR_ADDR2_LEN; - } else { - cbMacHdLen = WLAN_HDR_ADDR3_LEN; - } - - // hostapd daemon ext support rate patch - if (WLAN_GET_FC_FSTYPE(p80211Header->sA4.wFrameCtl) == WLAN_FSTYPE_ASSOCRESP) { - - if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len != 0) { - cbExtSuppRate += ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len + WLAN_IEHDR_LEN; - } - - if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len != 0) { - cbExtSuppRate += ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len + WLAN_IEHDR_LEN; - } - - if (cbExtSuppRate >0) { - cbFrameBodySize = WLAN_ASSOCRESP_OFF_SUPP_RATES; - } - } - - //Set FRAGCTL_MACHDCNT - pTxBufHead->wFragCtl |= cpu_to_le16((u16)cbMacHdLen << 10); - - // Notes: - // Although spec says MMPDU can be fragmented; In most case, - // no one will send a MMPDU under fragmentation. With RTS may occur. - - if (WLAN_GET_FC_ISWEP(p80211Header->sA4.wFrameCtl) != 0) { - if (pDevice->eEncryptionStatus == Ndis802_11Encryption1Enabled) { - cbIVlen = 4; - cbICVlen = 4; - pTxBufHead->wFragCtl |= FRAGCTL_LEGACY; - } - else if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) { - cbIVlen = 8;//IV+ExtIV - cbMIClen = 8; - cbICVlen = 4; - pTxBufHead->wFragCtl |= FRAGCTL_TKIP; - //We need to get seed here for filling TxKey entry. - //TKIPvMixKey(pTransmitKey->abyKey, pDevice->abyCurrentNetAddr, - // pTransmitKey->wTSC15_0, pTransmitKey->dwTSC47_16, pDevice->abyPRNG); - } - else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) { - cbIVlen = 8;//RSN Header - cbICVlen = 8;//MIC - cbMICHDR = sizeof(struct vnt_mic_hdr); - pTxBufHead->wFragCtl |= FRAGCTL_AES; - } - //MAC Header should be padding 0 to DW alignment. - uPadding = 4 - (cbMacHdLen%4); - uPadding %= 4; - } - - cbFrameSize = cbMacHdLen + cbFrameBodySize + cbIVlen + cbMIClen + cbICVlen + cbFCSlen + cbExtSuppRate; - - //Set FIFOCTL_GrpAckPolicy - if (pDevice->bGrpAckPolicy == true) {//0000 0100 0000 0000 - pTxBufHead->wFIFOCtl |= FIFOCTL_GRPACK; - } - //the rest of pTxBufHead->wFragCtl:FragTyp will be set later in s_vFillFragParameter() - - if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {//802.11g packet - cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_cts) + cbMICHDR + - sizeof(struct vnt_cts); - - } - else {//802.11a/b packet - cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR + - sizeof(struct vnt_tx_datahead_ab); - } - memcpy(&(sEthHeader.h_dest[0]), - &(p80211Header->sA3.abyAddr1[0]), - ETH_ALEN); - memcpy(&(sEthHeader.h_source[0]), - &(p80211Header->sA3.abyAddr2[0]), - ETH_ALEN); - //========================= - // No Fragmentation - //========================= - pTxBufHead->wFragCtl |= (u16)FRAGCTL_NONFRAG; - - /* Fill FIFO,RrvTime,RTS,and CTS */ - uDuration = s_vGenerateTxParameter(pDevice, byPktType, wCurrentRate, - pTX_Buffer, &pMICHDR, cbMICHDR, - cbFrameSize, bNeedACK, &sEthHeader, false); - - pMACHeader = (struct ieee80211_hdr *) (pbyTxBufferAddr + cbHeaderSize); - - cbReqCount = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen + (cbFrameBodySize + cbMIClen) + cbExtSuppRate; - - pbyMacHdr = (u8 *)(pbyTxBufferAddr + cbHeaderSize); - pbyPayloadHead = (u8 *)(pbyMacHdr + cbMacHdLen + uPadding + cbIVlen); - pbyIVHead = (u8 *)(pbyMacHdr + cbMacHdLen + uPadding); - - // Copy the Packet into a tx Buffer - memcpy(pbyMacHdr, skb->data, cbMacHdLen); - - // version set to 0, patch for hostapd deamon - pMACHeader->frame_control &= cpu_to_le16(0xfffc); - memcpy(pbyPayloadHead, (skb->data + cbMacHdLen), cbFrameBodySize); - - // replace support rate, patch for hostapd daemon( only support 11M) - if (WLAN_GET_FC_FSTYPE(p80211Header->sA4.wFrameCtl) == WLAN_FSTYPE_ASSOCRESP) { - if (cbExtSuppRate != 0) { - if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len != 0) - memcpy((pbyPayloadHead + cbFrameBodySize), - pMgmt->abyCurrSuppRates, - ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len + WLAN_IEHDR_LEN - ); - if (((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len != 0) - memcpy((pbyPayloadHead + cbFrameBodySize) + ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates)->len + WLAN_IEHDR_LEN, - pMgmt->abyCurrExtSuppRates, - ((PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates)->len + WLAN_IEHDR_LEN - ); - } - } - - // Set wep - if (WLAN_GET_FC_ISWEP(p80211Header->sA4.wFrameCtl) != 0) { - - if (pDevice->bEnableHostWEP) { - pTransmitKey = &STempKey; - pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite; - pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex; - pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength; - pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16; - pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0; - memcpy(pTransmitKey->abyKey, - &pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0], - pTransmitKey->uKeyLength - ); - } - - if ((pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) { - - dwMICKey0 = *(u32 *)(&pTransmitKey->abyKey[16]); - dwMICKey1 = *(u32 *)(&pTransmitKey->abyKey[20]); - - // DO Software Michael - MIC_vInit(dwMICKey0, dwMICKey1); - MIC_vAppend((u8 *)&(sEthHeader.h_dest[0]), 12); - dwMIC_Priority = 0; - MIC_vAppend((u8 *)&dwMIC_Priority, 4); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"DMA0_tx_8021:MIC KEY:"\ - " %X, %X\n", dwMICKey0, dwMICKey1); - - uLength = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen; - - MIC_vAppend((pbyTxBufferAddr + uLength), cbFrameBodySize); - - pdwMIC_L = (u32 *)(pbyTxBufferAddr + uLength + cbFrameBodySize); - pdwMIC_R = (u32 *)(pbyTxBufferAddr + uLength + cbFrameBodySize + 4); - - MIC_vGetMIC(pdwMIC_L, pdwMIC_R); - MIC_vUnInit(); - - if (pDevice->bTxMICFail == true) { - *pdwMIC_L = 0; - *pdwMIC_R = 0; - pDevice->bTxMICFail = false; - } - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"uLength: %d, %d\n", uLength, cbFrameBodySize); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"cbReqCount:%d, %d, %d, %d\n", cbReqCount, cbHeaderSize, uPadding, cbIVlen); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MIC:%x, %x\n", - *pdwMIC_L, *pdwMIC_R); - - } - - s_vFillTxKey(pDevice, pTxBufHead, pbyIVHead, pTransmitKey, - pbyMacHdr, (u16)cbFrameBodySize, pMICHDR); - - if (pDevice->bEnableHostWEP) { - pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16; - pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0 = pTransmitKey->wTSC15_0; - } - - if ((pDevice->byLocalID <= REV_ID_VT3253_A1)) { - s_vSWencryption(pDevice, pTransmitKey, pbyPayloadHead, (u16)(cbFrameBodySize + cbMIClen)); - } - } - - pMACHeader->seq_ctrl = cpu_to_le16(pDevice->wSeqCounter << 4); - pDevice->wSeqCounter++ ; - if (pDevice->wSeqCounter > 0x0fff) - pDevice->wSeqCounter = 0; - - if (bIsPSPOLL) { - // The MAC will automatically replace the Duration-field of MAC header by Duration-field - // of FIFO control header. - // This will cause AID-field of PS-POLL packet be incorrect (Because PS-POLL's AID field is - // in the same place of other packet's Duration-field). - // And it will cause Cisco-AP to issue Disassociation-packet - if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { - struct vnt_tx_datahead_g *data_head = &pTX_Buffer->tx_head. - tx_cts.tx.head.cts_g.data_head; - data_head->duration_a = - cpu_to_le16(p80211Header->sA2.wDurationID); - data_head->duration_b = - cpu_to_le16(p80211Header->sA2.wDurationID); - } else { - struct vnt_tx_datahead_ab *data_head = &pTX_Buffer->tx_head. - tx_ab.tx.head.data_head_ab; - data_head->duration = - cpu_to_le16(p80211Header->sA2.wDurationID); - } - } - - pTX_Buffer->tx_byte_count = cpu_to_le16((u16)(cbReqCount)); - pTX_Buffer->byPKTNO = (u8) (((wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); - pTX_Buffer->byType = 0x00; - - pContext->skb = skb; - pContext->type = CONTEXT_MGMT_PACKET; - pContext->buf_len = (u16)cbReqCount + 4; /* USB header */ - - if (WLAN_GET_FC_TODS(pMACHeader->frame_control) == 0) { - s_vSaveTxPktInfo(pDevice, (u8)(pTX_Buffer->byPKTNO & 0x0F), - &pMACHeader->addr1[0], (u16)cbFrameSize, - pTxBufHead->wFIFOCtl); - } - else { - s_vSaveTxPktInfo(pDevice, (u8)(pTX_Buffer->byPKTNO & 0x0F), - &pMACHeader->addr3[0], (u16)cbFrameSize, - pTxBufHead->wFIFOCtl); - } - PIPEnsSendBulkOut(pDevice,pContext); - return ; - -} - //TYPE_AC0DMA data tx /* * Description: @@ -2098,7 +1734,6 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, struct sk_buff *skb) u8 byPktType; int bNeedEncryption = false; PSKeyItem pTransmitKey = NULL; - SKeyItem STempKey; int ii; int bTKIP_UseGTK = false; int bNeedDeAuth = false; @@ -2262,22 +1897,6 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, struct sk_buff *skb) } while(false); } - if (pDevice->bEnableHostWEP) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"acdma0: STA index %d\n", uNodeIndex); - if (pDevice->bEncryptionEnable == true) { - pTransmitKey = &STempKey; - pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite; - pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex; - pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength; - pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16; - pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0; - memcpy(pTransmitKey->abyKey, - &pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0], - pTransmitKey->uKeyLength - ); - } - } - byPktType = (u8)pDevice->byPacketType; if (pDevice->bFixRate) { @@ -2381,15 +2000,6 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, struct sk_buff *skb) } } } - - if (pDevice->bEnableHostWEP) { - if ((uNodeIndex != 0) && - (pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex & PAIRWISE_KEY)) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Find PTK [%X]\n", - pTransmitKey->dwKeyIndex); - bNeedEncryption = true; - } - } } else { @@ -2487,7 +2097,6 @@ int bRelayPacketSend(struct vnt_private *pDevice, u8 *pbySkbData, u32 uDataLen, u32 BytesToWrite = 0, uHeaderLen = 0; u8 byPktType = PK_TYPE_11B; int bNeedEncryption = false; - SKeyItem STempKey; PSKeyItem pTransmitKey = NULL; u8 *pbyBSSID; struct vnt_usb_send_context *pContext; @@ -2516,21 +2125,6 @@ int bRelayPacketSend(struct vnt_private *pDevice, u8 *pbySkbData, u32 uDataLen, } } - if (pDevice->bEnableHostWEP) { - if (uNodeIndex < MAX_NODE_NUM + 1) { - pTransmitKey = &STempKey; - pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite; - pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex; - pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength; - pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16; - pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0; - memcpy(pTransmitKey->abyKey, - &pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0], - pTransmitKey->uKeyLength - ); - } - } - if ( bNeedEncryption && (pTransmitKey == NULL) ) { pContext->in_use = false; return false; diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c index b742460670d3..ff4e4ae0485d 100644 --- a/drivers/staging/vt6656/wcmd.c +++ b/drivers/staging/vt6656/wcmd.c @@ -627,10 +627,9 @@ void vRunCommand(struct work_struct *work) pMgmt->eCurrMode = WMAC_MODE_STANDBY; pDevice->bLinkPass = false; ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_SLOW); - if (pDevice->bEnableHostWEP == true) - BSSvClearNodeDBTable(pDevice, 1); - else - BSSvClearNodeDBTable(pDevice, 0); + + BSSvClearNodeDBTable(pDevice, 0); + pDevice->uAssocCount = 0; pMgmt->eCurrState = WMAC_STATE_IDLE; pDevice->bFixRate = false; diff --git a/drivers/staging/vt6656/wmgr.c b/drivers/staging/vt6656/wmgr.c index e6eec7fc2701..4f46aa6e25f5 100644 --- a/drivers/staging/vt6656/wmgr.c +++ b/drivers/staging/vt6656/wmgr.c @@ -540,10 +540,6 @@ static void s_vMgrRxAssocRequest(struct vnt_private *pDevice, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates ); if (pTxPacket != NULL ){ - - if (pDevice->bEnableHostapd) { - return; - } /* send the frame */ Status = csMgmt_xmit(pDevice, pTxPacket); if (Status != CMD_STATUS_PENDING) { @@ -689,9 +685,6 @@ static void s_vMgrRxReAssocRequest(struct vnt_private *pDevice, if (pTxPacket != NULL ){ /* send the frame */ - if (pDevice->bEnableHostapd) { - return; - } Status = csMgmt_xmit(pDevice, pTxPacket); if (Status != CMD_STATUS_PENDING) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:ReAssoc response tx failed\n"); @@ -1074,9 +1067,6 @@ static void s_vMgrRxAuthenSequence_1(struct vnt_private *pDevice, pTxPacket->cbMPDULen = sFrame.len; pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; // send the frame - if (pDevice->bEnableHostapd) { - return; - } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Authreq_reply sequence_1 tx.. \n"); if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Authreq_reply sequence_1 tx failed.\n"); @@ -1256,9 +1246,6 @@ reply: pTxPacket->cbMPDULen = sFrame.len; pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; // send the frame - if (pDevice->bEnableHostapd) { - return; - } if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Mgt:Authreq_reply sequence_4 tx failed.\n"); } @@ -2929,16 +2916,6 @@ static struct vnt_tx_mgmt *s_MgrMakeBeacon(struct vnt_private *pDevice, ((PWLAN_IE_SUPP_RATES)pCurrExtSuppRates)->len + WLAN_IEHDR_LEN ); } - // hostapd wpa/wpa2 IE - if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pDevice->bEnableHostapd == true)) { - if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) { - if (pMgmt->wWPAIELen != 0) { - sFrame.pRSN = (PWLAN_IE_RSN)(sFrame.pBuf + sFrame.len); - memcpy(sFrame.pRSN, pMgmt->abyWPAIE, pMgmt->wWPAIELen); - sFrame.len += pMgmt->wWPAIELen; - } - } - } /* Adjust the length fields */ pTxPacket->cbMPDULen = sFrame.len; @@ -3049,17 +3026,6 @@ static struct vnt_tx_mgmt *s_MgrMakeProbeResponse(struct vnt_private *pDevice, ); } - // hostapd wpa/wpa2 IE - if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pDevice->bEnableHostapd == true)) { - if (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) { - if (pMgmt->wWPAIELen != 0) { - sFrame.pRSN = (PWLAN_IE_RSN)(sFrame.pBuf + sFrame.len); - memcpy(sFrame.pRSN, pMgmt->abyWPAIE, pMgmt->wWPAIELen); - sFrame.len += pMgmt->wWPAIELen; - } - } - } - // Adjust the length fields pTxPacket->cbMPDULen = sFrame.len; pTxPacket->cbPayloadLen = sFrame.len - WLAN_HDR_ADDR3_LEN; @@ -4058,12 +4024,11 @@ int bMgrPrepareBeaconToSend(struct vnt_private *pDevice, unsigned long flags; // pDevice->bBeaconBufReady = false; - if (pDevice->bEncryptionEnable || pDevice->bEnable8021x){ - pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1); - } - else { - pMgmt->wCurrCapInfo &= ~WLAN_SET_CAP_INFO_PRIVACY(1); - } + if (pDevice->bEncryptionEnable) + pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_PRIVACY(1); + else + pMgmt->wCurrCapInfo &= ~WLAN_SET_CAP_INFO_PRIVACY(1); + pTxPacket = s_MgrMakeBeacon ( pDevice, -- cgit v1.2.3 From c0fcac91f36903d9ef2daa5418d270d88a146db1 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 19 May 2014 20:32:55 +0100 Subject: staging: vt6656: dpc.c remove hostapd Remove dead functions s_bAPModeRxCtl s_bAPModeRxData Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/dpc.c | 223 +------------------------------------------ 1 file changed, 1 insertion(+), 222 deletions(-) diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c index a1ae21355076..88808ba5eedc 100644 --- a/drivers/staging/vt6656/dpc.c +++ b/drivers/staging/vt6656/dpc.c @@ -26,8 +26,6 @@ * * Functions: * device_receive_frame - Rcv 802.11 frame function - * s_bAPModeRxCtl- AP Rcv frame filer Ctl. - * s_bAPModeRxData- AP Rcv data frame handle * s_bHandleRxEncryption- Rcv decrypted data via on-fly * s_byGetRateIdx- get rate index * s_vGetDASA- get data offset @@ -75,12 +73,6 @@ static void s_vProcessRxMACHeader(struct vnt_private *pDevice, u8 *pbyRxBufferAddr, u32 cbPacketSize, int bIsWEP, int bExtIV, u32 *pcbHeadSize); -static int s_bAPModeRxCtl(struct vnt_private *pDevice, u8 *pbyFrame, - s32 iSANodeIndex); - -static int s_bAPModeRxData(struct vnt_private *pDevice, struct sk_buff *skb, - u32 FrameSize, u32 cbHeaderOffset, s32 iSANodeIndex, s32 iDANodeIndex); - static int s_bHandleRxEncryption(struct vnt_private *pDevice, u8 *pbyFrame, u32 FrameSize, u8 *pbyRsr, u8 *pbyNewRsr, PSKeyItem *pKeyOut, s32 *pbExtIV, u16 *pwRxTSC15_0, u32 *pdwRxTSC47_16); @@ -255,7 +247,7 @@ int RXbBulkInProcessData(struct vnt_private *pDevice, struct vnt_rcb *pRCB, u32 cbHeaderOffset, cbIVOffset; u32 FrameSize; u16 wEtherType = 0; - s32 iSANodeIndex = -1, iDANodeIndex = -1; + s32 iSANodeIndex = -1; int ii; u8 *pbyRxSts, *pbyRxRate, *pbySQ, *pby3SQ; u32 cbHeaderSize; @@ -383,12 +375,6 @@ int RXbBulkInProcessData(struct vnt_private *pDevice, struct vnt_rcb *pRCB, } } - if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { - if (s_bAPModeRxCtl(pDevice, pbyFrame, iSANodeIndex) == true) { - return false; - } - } - if (IS_FC_WEP(pbyFrame)) { bool bRxDecryOK = false; @@ -735,26 +721,6 @@ int RXbBulkInProcessData(struct vnt_private *pDevice, struct vnt_rcb *pRCB, if (FrameSize < 12) return false; - if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { - if (s_bAPModeRxData(pDevice, - skb, - FrameSize, - cbHeaderOffset, - iSANodeIndex, - iDANodeIndex - ) == false) { - - if (bDeFragRx) { - if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) { - DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc more frag bufs\n", - pDevice->dev->name); - } - } - return false; - } - - } - skb->data += cbHeaderOffset; skb->tail += cbHeaderOffset; skb_put(skb, FrameSize); @@ -774,112 +740,6 @@ int RXbBulkInProcessData(struct vnt_private *pDevice, struct vnt_rcb *pRCB, return true; } -static int s_bAPModeRxCtl(struct vnt_private *pDevice, u8 *pbyFrame, - s32 iSANodeIndex) -{ - struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - struct ieee80211_hdr *p802_11Header; - CMD_STATUS Status; - - if (IS_CTL_PSPOLL(pbyFrame) || !IS_TYPE_CONTROL(pbyFrame)) { - - p802_11Header = (struct ieee80211_hdr *) (pbyFrame); - if (!IS_TYPE_MGMT(pbyFrame)) { - - // Data & PS-Poll packet - // check frame class - if (iSANodeIndex > 0) { - // frame class 3 fliter & checking - if (pMgmt->sNodeDBTable[iSANodeIndex].eNodeState < NODE_AUTH) { - // send deauth notification - // reason = (6) class 2 received from nonauth sta - vMgrDeAuthenBeginSta(pDevice, - pMgmt, - (u8 *)(p802_11Header->addr2), - (WLAN_MGMT_REASON_CLASS2_NONAUTH), - &Status - ); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: send vMgrDeAuthenBeginSta 1\n"); - return true; - } - if (pMgmt->sNodeDBTable[iSANodeIndex].eNodeState < NODE_ASSOC) { - // send deassoc notification - // reason = (7) class 3 received from nonassoc sta - vMgrDisassocBeginSta(pDevice, - pMgmt, - (u8 *)(p802_11Header->addr2), - (WLAN_MGMT_REASON_CLASS3_NONASSOC), - &Status - ); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: send vMgrDisassocBeginSta 2\n"); - return true; - } - - if (pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable) { - // delcare received ps-poll event - if (IS_CTL_PSPOLL(pbyFrame)) { - pMgmt->sNodeDBTable[iSANodeIndex].bRxPSPoll = true; - bScheduleCommand((void *) pDevice, - WLAN_CMD_RX_PSPOLL, - NULL); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: WLAN_CMD_RX_PSPOLL 1\n"); - } - else { - // check Data PS state - // if PW bit off, send out all PS bufferring packets. - if (!IS_FC_POWERMGT(pbyFrame)) { - pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable = false; - pMgmt->sNodeDBTable[iSANodeIndex].bRxPSPoll = true; - bScheduleCommand((void *) pDevice, - WLAN_CMD_RX_PSPOLL, - NULL); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: WLAN_CMD_RX_PSPOLL 2\n"); - } - } - } - else { - if (IS_FC_POWERMGT(pbyFrame)) { - pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable = true; - // Once if STA in PS state, enable multicast bufferring - pMgmt->sNodeDBTable[0].bPSEnable = true; - } - else { - // clear all pending PS frame. - if (pMgmt->sNodeDBTable[iSANodeIndex].wEnQueueCnt > 0) { - pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable = false; - pMgmt->sNodeDBTable[iSANodeIndex].bRxPSPoll = true; - bScheduleCommand((void *) pDevice, - WLAN_CMD_RX_PSPOLL, - NULL); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: WLAN_CMD_RX_PSPOLL 3\n"); - - } - } - } - } - else { - vMgrDeAuthenBeginSta(pDevice, - pMgmt, - (u8 *)(p802_11Header->addr2), - (WLAN_MGMT_REASON_CLASS2_NONAUTH), - &Status - ); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: send vMgrDeAuthenBeginSta 3\n"); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BSSID:%pM\n", - p802_11Header->addr3); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ADDR2:%pM\n", - p802_11Header->addr2); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ADDR1:%pM\n", - p802_11Header->addr1); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: frame_control= %x\n", p802_11Header->frame_control); - return true; - } - } - } - return false; - -} - static int s_bHandleRxEncryption(struct vnt_private *pDevice, u8 *pbyFrame, u32 FrameSize, u8 *pbyRsr, u8 *pbyNewRsr, PSKeyItem *pKeyOut, s32 *pbExtIV, u16 *pwRxTSC15_0, u32 *pdwRxTSC47_16) @@ -1006,87 +866,6 @@ static int s_bHandleRxEncryption(struct vnt_private *pDevice, u8 *pbyFrame, return true; } -static int s_bAPModeRxData(struct vnt_private *pDevice, struct sk_buff *skb, - u32 FrameSize, u32 cbHeaderOffset, s32 iSANodeIndex, s32 iDANodeIndex) -{ - struct sk_buff *skbcpy; - struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - int bRelayAndForward = false; - int bRelayOnly = false; - u8 byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; - u16 wAID; - - if (FrameSize > CB_MAX_BUF_SIZE) - return false; - // check DA - if (is_multicast_ether_addr((u8 *)(skb->data+cbHeaderOffset))) { - if (pMgmt->sNodeDBTable[0].bPSEnable) { - - skbcpy = netdev_alloc_skb(pDevice->dev, pDevice->rx_buf_sz); - - // if any node in PS mode, buffer packet until DTIM. - if (skbcpy == NULL) { - DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "relay multicast no skb available \n"); - } - else { - skbcpy->len = FrameSize; - memcpy(skbcpy->data, skb->data+cbHeaderOffset, FrameSize); - skb_queue_tail(&(pMgmt->sNodeDBTable[0].sTxPSQueue), skbcpy); - pMgmt->sNodeDBTable[0].wEnQueueCnt++; - // set tx map - pMgmt->abyPSTxMap[0] |= byMask[0]; - } - } - else { - bRelayAndForward = true; - } - } - else { - // check if relay - if (BSSbIsSTAInNodeDB(pDevice, (u8 *)(skb->data+cbHeaderOffset), &iDANodeIndex)) { - if (pMgmt->sNodeDBTable[iDANodeIndex].eNodeState >= NODE_ASSOC) { - if (pMgmt->sNodeDBTable[iDANodeIndex].bPSEnable) { - // queue this skb until next PS tx, and then release. - - skb->data += cbHeaderOffset; - skb->tail += cbHeaderOffset; - skb_put(skb, FrameSize); - skb_queue_tail(&pMgmt->sNodeDBTable[iDANodeIndex].sTxPSQueue, skb); - - pMgmt->sNodeDBTable[iDANodeIndex].wEnQueueCnt++; - wAID = pMgmt->sNodeDBTable[iDANodeIndex].wAID; - pMgmt->abyPSTxMap[wAID >> 3] |= byMask[wAID & 7]; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "relay: index= %d, pMgmt->abyPSTxMap[%d]= %d\n", - iDANodeIndex, (wAID >> 3), pMgmt->abyPSTxMap[wAID >> 3]); - return true; - } - else { - bRelayOnly = true; - } - } - } - } - - if (bRelayOnly || bRelayAndForward) { - // relay this packet right now - if (bRelayAndForward) - iDANodeIndex = 0; - - if ((pDevice->uAssocCount > 1) && (iDANodeIndex >= 0)) { - bRelayPacketSend(pDevice, (u8 *) (skb->data + cbHeaderOffset), - FrameSize, (unsigned int) iDANodeIndex); - } - - if (bRelayOnly) - return false; - } - // none associate, don't forward - if (pDevice->uAssocCount == 0) - return false; - - return true; -} - void RXvWorkItem(struct work_struct *work) { struct vnt_private *priv = -- cgit v1.2.3 From 7a24390d0f122f7c4a83dc2d0ffe85d22544cd3a Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 19 May 2014 20:32:56 +0100 Subject: staging: vt6656: dead code bRelayPacketSend After dead code hostapd remove bRelayPacketSend Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 126 ------------------------------------------ drivers/staging/vt6656/rxtx.h | 2 - 2 files changed, 128 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 771318170a0c..2b0ae062e43b 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -2073,129 +2073,3 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, struct sk_buff *skb) return 0; } - -/* - * Description: - * Relay packet send (AC1DMA) from rx dpc. - * - * Parameters: - * In: - * pDevice - Pointer to the adapter - * pPacket - Pointer to rx packet - * cbPacketSize - rx ethernet frame size - * Out: - * TURE, false - * - * Return Value: Return true if packet is copy to dma1; otherwise false - */ - -int bRelayPacketSend(struct vnt_private *pDevice, u8 *pbySkbData, u32 uDataLen, - u32 uNodeIndex) -{ - struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - struct vnt_tx_buffer *pTX_Buffer; - u32 BytesToWrite = 0, uHeaderLen = 0; - u8 byPktType = PK_TYPE_11B; - int bNeedEncryption = false; - PSKeyItem pTransmitKey = NULL; - u8 *pbyBSSID; - struct vnt_usb_send_context *pContext; - u8 byPktTyp; - int fConvertedPacket; - u32 status; - u16 wKeepRate = pDevice->wCurrentRate; - - pContext = s_vGetFreeContext(pDevice); - - if (NULL == pContext) { - return false; - } - - memcpy(&pDevice->sTxEthHeader, pbySkbData, ETH_HLEN); - - if (pDevice->bEncryptionEnable == true) { - bNeedEncryption = true; - // get group key - pbyBSSID = pDevice->abyBroadcastAddr; - if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == false) { - pTransmitKey = NULL; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"KEY is NULL. [%d]\n", pMgmt->eCurrMode); - } else { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"Get GTK.\n"); - } - } - - if ( bNeedEncryption && (pTransmitKey == NULL) ) { - pContext->in_use = false; - return false; - } - - byPktTyp = (u8)pDevice->byPacketType; - - if (pDevice->bFixRate) { - if (pDevice->byBBType == BB_TYPE_11B) { - if (pDevice->uConnectionRate >= RATE_11M) { - pDevice->wCurrentRate = RATE_11M; - } else { - pDevice->wCurrentRate = (u16)pDevice->uConnectionRate; - } - } else { - if ((pDevice->byBBType == BB_TYPE_11A) && - (pDevice->uConnectionRate <= RATE_6M)) { - pDevice->wCurrentRate = RATE_6M; - } else { - if (pDevice->uConnectionRate >= RATE_54M) - pDevice->wCurrentRate = RATE_54M; - else - pDevice->wCurrentRate = (u16)pDevice->uConnectionRate; - } - } - } - else { - pDevice->wCurrentRate = pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate; - } - - if (wKeepRate != pDevice->wCurrentRate) { - bScheduleCommand((void *) pDevice, WLAN_CMD_SETPOWER, NULL); - } - - if (pDevice->wCurrentRate <= RATE_11M) - byPktType = PK_TYPE_11B; - - BytesToWrite = uDataLen + ETH_FCS_LEN; - - // Convert the packet to an usb frame and copy into our buffer - // and send the irp. - - pTX_Buffer = (struct vnt_tx_buffer *)&pContext->data[0]; - - fConvertedPacket = s_bPacketToWirelessUsb(pDevice, byPktType, - pTX_Buffer, bNeedEncryption, - uDataLen, &pDevice->sTxEthHeader, - pbySkbData, pTransmitKey, uNodeIndex, - pDevice->wCurrentRate, - &uHeaderLen, &BytesToWrite - ); - - if (fConvertedPacket == false) { - pContext->in_use = false; - return false; - } - - pTX_Buffer->byPKTNO = (u8) (((pDevice->wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); - pTX_Buffer->tx_byte_count = cpu_to_le16((u16)BytesToWrite); - - pContext->skb = NULL; - pContext->type = CONTEXT_DATA_PACKET; - pContext->buf_len = (u16)BytesToWrite + 4; /* USB header */ - - s_vSaveTxPktInfo(pDevice, (u8)(pTX_Buffer->byPKTNO & 0x0F), - &pDevice->sTxEthHeader.h_dest[0], - (u16)(BytesToWrite - uHeaderLen), - pTX_Buffer->fifo_head.wFIFOCtl); - - status = PIPEnsSendBulkOut(pDevice,pContext); - - return true; -} - diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h index 982f1624efac..6db3337f1d1d 100644 --- a/drivers/staging/vt6656/rxtx.h +++ b/drivers/staging/vt6656/rxtx.h @@ -250,7 +250,5 @@ void vDMA0_tx_80211(struct vnt_private *, struct sk_buff *skb); int nsDMA_tx_packet(struct vnt_private *, struct sk_buff *skb); CMD_STATUS csMgmt_xmit(struct vnt_private *, struct vnt_tx_mgmt *); CMD_STATUS csBeacon_xmit(struct vnt_private *, struct vnt_tx_mgmt *); -int bRelayPacketSend(struct vnt_private *, u8 *pbySkbData, u32 uDataLen, - u32 uNodeIndex); #endif /* __RXTX_H__ */ -- cgit v1.2.3 From 2a4ee86f044ca0c39e9633d9f40e36a1a7df1180 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 19 May 2014 20:32:57 +0100 Subject: staging; vt6656: dead code aes_ccmp. After dead code dpc hostapd remove aes.c/h Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/Makefile | 1 - drivers/staging/vt6656/aes_ccmp.c | 374 -------------------------------------- drivers/staging/vt6656/aes_ccmp.h | 35 ---- drivers/staging/vt6656/dpc.c | 1 - 4 files changed, 411 deletions(-) delete mode 100644 drivers/staging/vt6656/aes_ccmp.c delete mode 100644 drivers/staging/vt6656/aes_ccmp.h diff --git a/drivers/staging/vt6656/Makefile b/drivers/staging/vt6656/Makefile index 47b60753bb23..846db132f5d5 100644 --- a/drivers/staging/vt6656/Makefile +++ b/drivers/staging/vt6656/Makefile @@ -26,7 +26,6 @@ vt6656_stage-y += main_usb.o \ rf.o \ iwctl.o \ wpactl.o \ - aes_ccmp.o \ usbpipe.o \ channel.o \ control.o \ diff --git a/drivers/staging/vt6656/aes_ccmp.c b/drivers/staging/vt6656/aes_ccmp.c deleted file mode 100644 index a9d51687db7f..000000000000 --- a/drivers/staging/vt6656/aes_ccmp.c +++ /dev/null @@ -1,374 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * File: aes_ccmp.c - * - * Purpose: AES_CCMP decryption - * - * Author: Warren Hsu - * - * Date: Feb 15, 2005 - * - * Functions: - * AESbGenCCMP - Parsing RX-packet - * - * Revision History: - */ - -#include "device.h" -#include "80211hdr.h" -#include "aes_ccmp.h" - -/* - * SBOX Table - */ - -static u8 sbox_table[256] = { - 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, - 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, - 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, - 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, - 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, - 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, - 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, - 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, - 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, - 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, - 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, - 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, - 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, - 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, - 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, - 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 -}; - -static u8 dot2_table[256] = { - 0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e, - 0x20, 0x22, 0x24, 0x26, 0x28, 0x2a, 0x2c, 0x2e, 0x30, 0x32, 0x34, 0x36, 0x38, 0x3a, 0x3c, 0x3e, - 0x40, 0x42, 0x44, 0x46, 0x48, 0x4a, 0x4c, 0x4e, 0x50, 0x52, 0x54, 0x56, 0x58, 0x5a, 0x5c, 0x5e, - 0x60, 0x62, 0x64, 0x66, 0x68, 0x6a, 0x6c, 0x6e, 0x70, 0x72, 0x74, 0x76, 0x78, 0x7a, 0x7c, 0x7e, - 0x80, 0x82, 0x84, 0x86, 0x88, 0x8a, 0x8c, 0x8e, 0x90, 0x92, 0x94, 0x96, 0x98, 0x9a, 0x9c, 0x9e, - 0xa0, 0xa2, 0xa4, 0xa6, 0xa8, 0xaa, 0xac, 0xae, 0xb0, 0xb2, 0xb4, 0xb6, 0xb8, 0xba, 0xbc, 0xbe, - 0xc0, 0xc2, 0xc4, 0xc6, 0xc8, 0xca, 0xcc, 0xce, 0xd0, 0xd2, 0xd4, 0xd6, 0xd8, 0xda, 0xdc, 0xde, - 0xe0, 0xe2, 0xe4, 0xe6, 0xe8, 0xea, 0xec, 0xee, 0xf0, 0xf2, 0xf4, 0xf6, 0xf8, 0xfa, 0xfc, 0xfe, - 0x1b, 0x19, 0x1f, 0x1d, 0x13, 0x11, 0x17, 0x15, 0x0b, 0x09, 0x0f, 0x0d, 0x03, 0x01, 0x07, 0x05, - 0x3b, 0x39, 0x3f, 0x3d, 0x33, 0x31, 0x37, 0x35, 0x2b, 0x29, 0x2f, 0x2d, 0x23, 0x21, 0x27, 0x25, - 0x5b, 0x59, 0x5f, 0x5d, 0x53, 0x51, 0x57, 0x55, 0x4b, 0x49, 0x4f, 0x4d, 0x43, 0x41, 0x47, 0x45, - 0x7b, 0x79, 0x7f, 0x7d, 0x73, 0x71, 0x77, 0x75, 0x6b, 0x69, 0x6f, 0x6d, 0x63, 0x61, 0x67, 0x65, - 0x9b, 0x99, 0x9f, 0x9d, 0x93, 0x91, 0x97, 0x95, 0x8b, 0x89, 0x8f, 0x8d, 0x83, 0x81, 0x87, 0x85, - 0xbb, 0xb9, 0xbf, 0xbd, 0xb3, 0xb1, 0xb7, 0xb5, 0xab, 0xa9, 0xaf, 0xad, 0xa3, 0xa1, 0xa7, 0xa5, - 0xdb, 0xd9, 0xdf, 0xdd, 0xd3, 0xd1, 0xd7, 0xd5, 0xcb, 0xc9, 0xcf, 0xcd, 0xc3, 0xc1, 0xc7, 0xc5, - 0xfb, 0xf9, 0xff, 0xfd, 0xf3, 0xf1, 0xf7, 0xf5, 0xeb, 0xe9, 0xef, 0xed, 0xe3, 0xe1, 0xe7, 0xe5 -}; - -static u8 dot3_table[256] = { - 0x00, 0x03, 0x06, 0x05, 0x0c, 0x0f, 0x0a, 0x09, 0x18, 0x1b, 0x1e, 0x1d, 0x14, 0x17, 0x12, 0x11, - 0x30, 0x33, 0x36, 0x35, 0x3c, 0x3f, 0x3a, 0x39, 0x28, 0x2b, 0x2e, 0x2d, 0x24, 0x27, 0x22, 0x21, - 0x60, 0x63, 0x66, 0x65, 0x6c, 0x6f, 0x6a, 0x69, 0x78, 0x7b, 0x7e, 0x7d, 0x74, 0x77, 0x72, 0x71, - 0x50, 0x53, 0x56, 0x55, 0x5c, 0x5f, 0x5a, 0x59, 0x48, 0x4b, 0x4e, 0x4d, 0x44, 0x47, 0x42, 0x41, - 0xc0, 0xc3, 0xc6, 0xc5, 0xcc, 0xcf, 0xca, 0xc9, 0xd8, 0xdb, 0xde, 0xdd, 0xd4, 0xd7, 0xd2, 0xd1, - 0xf0, 0xf3, 0xf6, 0xf5, 0xfc, 0xff, 0xfa, 0xf9, 0xe8, 0xeb, 0xee, 0xed, 0xe4, 0xe7, 0xe2, 0xe1, - 0xa0, 0xa3, 0xa6, 0xa5, 0xac, 0xaf, 0xaa, 0xa9, 0xb8, 0xbb, 0xbe, 0xbd, 0xb4, 0xb7, 0xb2, 0xb1, - 0x90, 0x93, 0x96, 0x95, 0x9c, 0x9f, 0x9a, 0x99, 0x88, 0x8b, 0x8e, 0x8d, 0x84, 0x87, 0x82, 0x81, - 0x9b, 0x98, 0x9d, 0x9e, 0x97, 0x94, 0x91, 0x92, 0x83, 0x80, 0x85, 0x86, 0x8f, 0x8c, 0x89, 0x8a, - 0xab, 0xa8, 0xad, 0xae, 0xa7, 0xa4, 0xa1, 0xa2, 0xb3, 0xb0, 0xb5, 0xb6, 0xbf, 0xbc, 0xb9, 0xba, - 0xfb, 0xf8, 0xfd, 0xfe, 0xf7, 0xf4, 0xf1, 0xf2, 0xe3, 0xe0, 0xe5, 0xe6, 0xef, 0xec, 0xe9, 0xea, - 0xcb, 0xc8, 0xcd, 0xce, 0xc7, 0xc4, 0xc1, 0xc2, 0xd3, 0xd0, 0xd5, 0xd6, 0xdf, 0xdc, 0xd9, 0xda, - 0x5b, 0x58, 0x5d, 0x5e, 0x57, 0x54, 0x51, 0x52, 0x43, 0x40, 0x45, 0x46, 0x4f, 0x4c, 0x49, 0x4a, - 0x6b, 0x68, 0x6d, 0x6e, 0x67, 0x64, 0x61, 0x62, 0x73, 0x70, 0x75, 0x76, 0x7f, 0x7c, 0x79, 0x7a, - 0x3b, 0x38, 0x3d, 0x3e, 0x37, 0x34, 0x31, 0x32, 0x23, 0x20, 0x25, 0x26, 0x2f, 0x2c, 0x29, 0x2a, - 0x0b, 0x08, 0x0d, 0x0e, 0x07, 0x04, 0x01, 0x02, 0x13, 0x10, 0x15, 0x16, 0x1f, 0x1c, 0x19, 0x1a -}; - -static void xor_128(u8 *a, u8 *b, u8 *out) -{ - u32 *dwPtrA = (u32 *) a; - u32 *dwPtrB = (u32 *) b; - u32 *dwPtrOut = (u32 *) out; - - (*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++); - (*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++); - (*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++); - (*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++); -} - -static void xor_32(u8 *a, u8 *b, u8 *out) -{ - u32 *dwPtrA = (u32 *) a; - u32 *dwPtrB = (u32 *) b; - u32 *dwPtrOut = (u32 *) out; - - (*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++); -} - -static void AddRoundKey(u8 *key, int round) -{ - u8 sbox_key[4]; - u8 rcon_table[10] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36}; - - sbox_key[0] = sbox_table[key[13]]; - sbox_key[1] = sbox_table[key[14]]; - sbox_key[2] = sbox_table[key[15]]; - sbox_key[3] = sbox_table[key[12]]; - - key[0] = key[0] ^ rcon_table[round]; - xor_32(&key[0], sbox_key, &key[0]); - - xor_32(&key[4], &key[0], &key[4]); - xor_32(&key[8], &key[4], &key[8]); - xor_32(&key[12], &key[8], &key[12]); -} - -static void SubBytes(u8 *in, u8 *out) -{ - int i; - - for (i = 0; i < 16; i++) - out[i] = sbox_table[in[i]]; -} - -static void ShiftRows(u8 *in, u8 *out) -{ - out[0] = in[0]; - out[1] = in[5]; - out[2] = in[10]; - out[3] = in[15]; - out[4] = in[4]; - out[5] = in[9]; - out[6] = in[14]; - out[7] = in[3]; - out[8] = in[8]; - out[9] = in[13]; - out[10] = in[2]; - out[11] = in[7]; - out[12] = in[12]; - out[13] = in[1]; - out[14] = in[6]; - out[15] = in[11]; -} - -static void MixColumns(u8 *in, u8 *out) -{ - - out[0] = dot2_table[in[0]] ^ dot3_table[in[1]] ^ in[2] ^ in[3]; - out[1] = in[0] ^ dot2_table[in[1]] ^ dot3_table[in[2]] ^ in[3]; - out[2] = in[0] ^ in[1] ^ dot2_table[in[2]] ^ dot3_table[in[3]]; - out[3] = dot3_table[in[0]] ^ in[1] ^ in[2] ^ dot2_table[in[3]]; -} - -static void AESv128(u8 *key, u8 *data, u8 *ciphertext) -{ - int i; - int round; - u8 TmpdataA[16]; - u8 TmpdataB[16]; - u8 abyRoundKey[16]; - - for (i = 0; i < 16; i++) - abyRoundKey[i] = key[i]; - - for (round = 0; round < 11; round++) { - if (round == 0) { - xor_128(abyRoundKey, data, ciphertext); - AddRoundKey(abyRoundKey, round); - } else if (round == 10) { - SubBytes(ciphertext, TmpdataA); - ShiftRows(TmpdataA, TmpdataB); - xor_128(TmpdataB, abyRoundKey, ciphertext); - } else { /* round 1 ~ 9 */ - SubBytes(ciphertext, TmpdataA); - ShiftRows(TmpdataA, TmpdataB); - MixColumns(&TmpdataB[0], &TmpdataA[0]); - MixColumns(&TmpdataB[4], &TmpdataA[4]); - MixColumns(&TmpdataB[8], &TmpdataA[8]); - MixColumns(&TmpdataB[12], &TmpdataA[12]); - xor_128(TmpdataA, abyRoundKey, ciphertext); - AddRoundKey(abyRoundKey, round); - } - } - -} - -/* - * Description: AES decryption - * - * Parameters: - * In: - * pbyRxKey - The key used to decrypt - * pbyFrame - Starting address of packet header - * wFrameSize - Total packet size including CRC - * Out: - * none - * - * Return Value: MIC compare result - * - */ - -bool AESbGenCCMP(u8 *pbyRxKey, u8 *pbyFrame, u16 wFrameSize) -{ - u8 abyNonce[13]; - u8 MIC_IV[16]; - u8 MIC_HDR1[16]; - u8 MIC_HDR2[16]; - u8 abyMIC[16]; - u8 abyCTRPLD[16]; - u8 abyTmp[16]; - u8 abyPlainText[16]; - u8 abyLastCipher[16]; - - struct ieee80211_hdr *pMACHeader = (struct ieee80211_hdr *) pbyFrame; - u8 *pbyIV; - u8 *pbyPayload; - u16 wHLen = 22; - /* 8 is IV, 8 is MIC, 4 is CRC */ - u16 wPayloadSize = wFrameSize - 8 - 8 - 4 - WLAN_HDR_ADDR3_LEN; - bool bA4 = false; - u8 byTmp; - u16 wCnt; - int ii, jj, kk; - - pbyIV = pbyFrame + WLAN_HDR_ADDR3_LEN; - if (WLAN_GET_FC_TODS(*(u16 *) pbyFrame) && - WLAN_GET_FC_FROMDS(*(u16 *) pbyFrame)) { - bA4 = true; - pbyIV += 6; /* 6 is 802.11 address4 */ - wHLen += 6; - wPayloadSize -= 6; - } - pbyPayload = pbyIV + 8; /* IV-length */ - - abyNonce[0] = 0x00; /* now is 0, if Qos here will be priority */ - memcpy(&(abyNonce[1]), pMACHeader->addr2, ETH_ALEN); - abyNonce[7] = pbyIV[7]; - abyNonce[8] = pbyIV[6]; - abyNonce[9] = pbyIV[5]; - abyNonce[10] = pbyIV[4]; - abyNonce[11] = pbyIV[1]; - abyNonce[12] = pbyIV[0]; - - /* MIC_IV */ - MIC_IV[0] = 0x59; - memcpy(&(MIC_IV[1]), &(abyNonce[0]), 13); - MIC_IV[14] = (u8)(wPayloadSize >> 8); - MIC_IV[15] = (u8)(wPayloadSize & 0xff); - - /* MIC_HDR1 */ - MIC_HDR1[0] = (u8)(wHLen >> 8); - MIC_HDR1[1] = (u8)(wHLen & 0xff); - byTmp = (u8)(le16_to_cpu(pMACHeader->frame_control) >> 8); - MIC_HDR1[2] = byTmp & 0x8f; - byTmp = (u8)(le16_to_cpu(pMACHeader->frame_control) & 0xff); - byTmp &= 0x87; - MIC_HDR1[3] = byTmp | 0x40; - memcpy(&(MIC_HDR1[4]), pMACHeader->addr1, ETH_ALEN); - memcpy(&(MIC_HDR1[10]), pMACHeader->addr2, ETH_ALEN); - - /* MIC_HDR2 */ - memcpy(&(MIC_HDR2[0]), pMACHeader->addr3, ETH_ALEN); - byTmp = (u8)(le16_to_cpu(pMACHeader->seq_ctrl) >> 8); - MIC_HDR2[6] = byTmp & 0x0f; - MIC_HDR2[7] = 0; - - if (bA4) { - memcpy(&(MIC_HDR2[8]), pMACHeader->addr4, ETH_ALEN); - } else { - MIC_HDR2[8] = 0x00; - MIC_HDR2[9] = 0x00; - MIC_HDR2[10] = 0x00; - MIC_HDR2[11] = 0x00; - MIC_HDR2[12] = 0x00; - MIC_HDR2[13] = 0x00; - } - MIC_HDR2[14] = 0x00; - MIC_HDR2[15] = 0x00; - - /* CCMP */ - AESv128(pbyRxKey, MIC_IV, abyMIC); - for (kk = 0; kk < 16; kk++) - abyTmp[kk] = MIC_HDR1[kk] ^ abyMIC[kk]; - - AESv128(pbyRxKey, abyTmp, abyMIC); - for (kk = 0; kk < 16; kk++) - abyTmp[kk] = MIC_HDR2[kk] ^ abyMIC[kk]; - - AESv128(pbyRxKey, abyTmp, abyMIC); - - wCnt = 1; - abyCTRPLD[0] = 0x01; - memcpy(&(abyCTRPLD[1]), &(abyNonce[0]), 13); - - for (jj = wPayloadSize; jj > 16; jj = jj-16) { - - abyCTRPLD[14] = (u8) (wCnt >> 8); - abyCTRPLD[15] = (u8) (wCnt & 0xff); - - AESv128(pbyRxKey, abyCTRPLD, abyTmp); - - for (kk = 0; kk < 16; kk++) - abyPlainText[kk] = abyTmp[kk] ^ pbyPayload[kk]; - - for (kk = 0; kk < 16; kk++) - abyTmp[kk] = abyMIC[kk] ^ abyPlainText[kk]; - - AESv128(pbyRxKey, abyTmp, abyMIC); - - memcpy(pbyPayload, abyPlainText, 16); - wCnt++; - pbyPayload += 16; - } /* for wPayloadSize */ - - /* last payload */ - memcpy(&(abyLastCipher[0]), pbyPayload, jj); - for (ii = jj; ii < 16; ii++) - abyLastCipher[ii] = 0x00; - - abyCTRPLD[14] = (u8) (wCnt >> 8); - abyCTRPLD[15] = (u8) (wCnt & 0xff); - - AESv128(pbyRxKey, abyCTRPLD, abyTmp); - for (kk = 0; kk < 16; kk++) - abyPlainText[kk] = abyTmp[kk] ^ abyLastCipher[kk]; - - memcpy(pbyPayload, abyPlainText, jj); - pbyPayload += jj; - - /* for MIC calculation */ - for (ii = jj; ii < 16; ii++) - abyPlainText[ii] = 0x00; - for (kk = 0; kk < 16; kk++) - abyTmp[kk] = abyMIC[kk] ^ abyPlainText[kk]; - - AESv128(pbyRxKey, abyTmp, abyMIC); - - /* => above is the calculated MIC */ - - wCnt = 0; - abyCTRPLD[14] = (u8) (wCnt >> 8); - abyCTRPLD[15] = (u8) (wCnt & 0xff); - AESv128(pbyRxKey, abyCTRPLD, abyTmp); - - for (kk = 0; kk < 8; kk++) - abyTmp[kk] = abyTmp[kk] ^ pbyPayload[kk]; - - /* => above is the packet dec-MIC */ - - if (!memcmp(abyMIC, abyTmp, 8)) - return true; - else - return false; -} diff --git a/drivers/staging/vt6656/aes_ccmp.h b/drivers/staging/vt6656/aes_ccmp.h deleted file mode 100644 index ed6a9ae315de..000000000000 --- a/drivers/staging/vt6656/aes_ccmp.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: aes_ccmp.h - * - * Purpose: AES_CCMP Decryption - * - * Author: Warren Hsu - * - * Date: Feb 15, 2005 - * - */ - -#ifndef __AES_H__ -#define __AES_H__ - -bool AESbGenCCMP(u8 * pbyRxKey, u8 * pbyFrame, u16 wFrameSize); - -#endif /* __AES_CCMP_H__ */ diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c index 88808ba5eedc..c05a96f2a97a 100644 --- a/drivers/staging/vt6656/dpc.c +++ b/drivers/staging/vt6656/dpc.c @@ -49,7 +49,6 @@ #include "wctl.h" #include "rf.h" #include "iowpa.h" -#include "aes_ccmp.h" #include "datarate.h" #include "usbpipe.h" -- cgit v1.2.3 From 4d99952df1d6a4ef14013fe315a44fcd6bdd9f59 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 19 May 2014 20:32:58 +0100 Subject: staging: vt6656: checkpatch cleanup BBuGetFrameTime. clean up white space. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 78 ++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 42 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index a70b27890a09..dbe06f9ec4c8 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -663,53 +663,47 @@ s_vClearSQ3Value(PSDevice pDevice); * Return Value: FrameTime * */ -unsigned int -BBuGetFrameTime( - u8 byPreambleType, - u8 byPktType, - unsigned int cbFrameLength, - u16 wRate - ) +unsigned int BBuGetFrameTime(u8 byPreambleType, u8 byPktType, + unsigned int cbFrameLength, u16 wRate) { - unsigned int uFrameTime; - unsigned int uPreamble; - unsigned int uTmp; - unsigned int uRateIdx = (unsigned int)wRate; - unsigned int uRate = 0; - - if (uRateIdx > RATE_54M) { - return 0; - } + unsigned int uFrameTime; + unsigned int uPreamble; + unsigned int uTmp; + unsigned int uRateIdx = (unsigned int)wRate; + unsigned int uRate = 0; - uRate = (unsigned int)awcFrameTime[uRateIdx]; + if (uRateIdx > RATE_54M) + return 0; - if (uRateIdx <= 3) { //CCK mode + uRate = (unsigned int)awcFrameTime[uRateIdx]; - if (byPreambleType == 1) {//Short - uPreamble = 96; - } else { - uPreamble = 192; - } - uFrameTime = (cbFrameLength * 80) / uRate; //????? - uTmp = (uFrameTime * uRate) / 80; - if (cbFrameLength != uTmp) { - uFrameTime ++; - } + if (uRateIdx <= 3) { + if (byPreambleType == 1) + uPreamble = 96; + else + uPreamble = 192; - return (uPreamble + uFrameTime); - } - else { - uFrameTime = (cbFrameLength * 8 + 22) / uRate; //???????? - uTmp = ((uFrameTime * uRate) - 22) / 8; - if(cbFrameLength != uTmp) { - uFrameTime ++; - } - uFrameTime = uFrameTime * 4; //??????? - if(byPktType != PK_TYPE_11A) { - uFrameTime += 6; - } - return (20 + uFrameTime); //?????? - } + uFrameTime = (cbFrameLength * 80) / uRate; + uTmp = (uFrameTime * uRate) / 80; + + if (cbFrameLength != uTmp) + uFrameTime++; + + return uPreamble + uFrameTime; + } else { + uFrameTime = (cbFrameLength * 8 + 22) / uRate; + uTmp = ((uFrameTime * uRate) - 22) / 8; + + if (cbFrameLength != uTmp) + uFrameTime++; + + uFrameTime = uFrameTime * 4; + + if (byPktType != PK_TYPE_11A) + uFrameTime += 6; + + return 20 + uFrameTime; + } } /* -- cgit v1.2.3 From 3b5a89ca3db0f8c816aa0590d3b2955df63d3d01 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 19 May 2014 20:32:59 +0100 Subject: staging: vt6656: BBuGetFrameTime remove uRateIdx Remove uRateIdx and rename wRate tx_rate Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 13 ++++++------- drivers/staging/vt6656/baseband.h | 9 ++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index dbe06f9ec4c8..baa3858fee66 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -657,27 +657,26 @@ s_vClearSQ3Value(PSDevice pDevice); * byPreambleType - Preamble Type * byPktType - PK_TYPE_11A, PK_TYPE_11B, PK_TYPE_11GB, PK_TYPE_11GA * cbFrameLength - Baseband Type - * wRate - Tx Rate + * tx_rate - Tx Rate * Out: * * Return Value: FrameTime * */ -unsigned int BBuGetFrameTime(u8 byPreambleType, u8 byPktType, - unsigned int cbFrameLength, u16 wRate) +unsigned int BBuGetFrameTime(u8 byPreambleType, u8 byPktType, + unsigned int cbFrameLength, u16 tx_rate) { unsigned int uFrameTime; unsigned int uPreamble; unsigned int uTmp; - unsigned int uRateIdx = (unsigned int)wRate; unsigned int uRate = 0; - if (uRateIdx > RATE_54M) + if (tx_rate > RATE_54M) return 0; - uRate = (unsigned int)awcFrameTime[uRateIdx]; + uRate = (unsigned int)awcFrameTime[tx_rate]; - if (uRateIdx <= 3) { + if (tx_rate <= 3) { if (byPreambleType == 1) uPreamble = 96; else diff --git a/drivers/staging/vt6656/baseband.h b/drivers/staging/vt6656/baseband.h index 79faedf4a5e9..08c24a3b3189 100644 --- a/drivers/staging/vt6656/baseband.h +++ b/drivers/staging/vt6656/baseband.h @@ -88,13 +88,8 @@ struct vnt_phy_field { __le16 len; } __packed; -unsigned int -BBuGetFrameTime( - u8 byPreambleType, - u8 byFreqType, - unsigned int cbFrameLength, - u16 wRate - ); +unsigned int BBuGetFrameTime(u8 byPreambleType, u8 byPktType, + unsigned int cbFrameLength, u16 tx_rate); void BBvCalculateParameter(struct vnt_private *, u32 cbFrameLength, u16 wRate, u8 byPacketType, struct vnt_phy_field *); -- cgit v1.2.3 From 030ede1e0ed4b112f774e3bef82e93a188ac8969 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 19 May 2014 20:33:00 +0100 Subject: staging: vt6656: BBuGetFrameTime remove camel case. Camel case changes. byPreambleType, byPktType, cbFrameLength, uFrameTime, uPreamble, uTmp, uRate -> preamble_type, pkt_type, frame_length, frame_time, preamble, tmp, rate Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 52 +++++++++++++++++++-------------------- drivers/staging/vt6656/baseband.h | 4 +-- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index baa3858fee66..36977f09a6e8 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -654,54 +654,54 @@ s_vClearSQ3Value(PSDevice pDevice); * * Parameters: * In: - * byPreambleType - Preamble Type - * byPktType - PK_TYPE_11A, PK_TYPE_11B, PK_TYPE_11GB, PK_TYPE_11GA - * cbFrameLength - Baseband Type + * preamble_type - Preamble Type + * pkt_type - PK_TYPE_11A, PK_TYPE_11B, PK_TYPE_11GB, PK_TYPE_11GA + * frame_length - Baseband Type * tx_rate - Tx Rate * Out: * * Return Value: FrameTime * */ -unsigned int BBuGetFrameTime(u8 byPreambleType, u8 byPktType, - unsigned int cbFrameLength, u16 tx_rate) +unsigned int BBuGetFrameTime(u8 preamble_type, u8 pkt_type, + unsigned int frame_length, u16 tx_rate) { - unsigned int uFrameTime; - unsigned int uPreamble; - unsigned int uTmp; - unsigned int uRate = 0; + unsigned int frame_time; + unsigned int preamble; + unsigned int tmp; + unsigned int rate = 0; if (tx_rate > RATE_54M) return 0; - uRate = (unsigned int)awcFrameTime[tx_rate]; + rate = (unsigned int)awcFrameTime[tx_rate]; if (tx_rate <= 3) { - if (byPreambleType == 1) - uPreamble = 96; + if (preamble_type == 1) + preamble = 96; else - uPreamble = 192; + preamble = 192; - uFrameTime = (cbFrameLength * 80) / uRate; - uTmp = (uFrameTime * uRate) / 80; + frame_time = (frame_length * 80) / rate; + tmp = (frame_time * rate) / 80; - if (cbFrameLength != uTmp) - uFrameTime++; + if (frame_length != tmp) + frame_time++; - return uPreamble + uFrameTime; + return preamble + frame_time; } else { - uFrameTime = (cbFrameLength * 8 + 22) / uRate; - uTmp = ((uFrameTime * uRate) - 22) / 8; + frame_time = (frame_length * 8 + 22) / rate; + tmp = ((frame_time * rate) - 22) / 8; - if (cbFrameLength != uTmp) - uFrameTime++; + if (frame_length != tmp) + frame_time++; - uFrameTime = uFrameTime * 4; + frame_time = frame_time * 4; - if (byPktType != PK_TYPE_11A) - uFrameTime += 6; + if (pkt_type != PK_TYPE_11A) + frame_time += 6; - return 20 + uFrameTime; + return 20 + frame_time; } } diff --git a/drivers/staging/vt6656/baseband.h b/drivers/staging/vt6656/baseband.h index 08c24a3b3189..da5520c888a5 100644 --- a/drivers/staging/vt6656/baseband.h +++ b/drivers/staging/vt6656/baseband.h @@ -88,8 +88,8 @@ struct vnt_phy_field { __le16 len; } __packed; -unsigned int BBuGetFrameTime(u8 byPreambleType, u8 byPktType, - unsigned int cbFrameLength, u16 tx_rate); +unsigned int BBuGetFrameTime(u8 preamble_type, u8 pkt_type, + unsigned int frame_length, u16 tx_rate); void BBvCalculateParameter(struct vnt_private *, u32 cbFrameLength, u16 wRate, u8 byPacketType, struct vnt_phy_field *); -- cgit v1.2.3 From a4fb3e78b7c8b03602563538d0fd60a4203eacc4 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 19 May 2014 20:33:01 +0100 Subject: staging: vt6656: checkpatch cleanup BBvCalculateParameter. White space clean up. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 218 ++++++++++++++++++-------------------- 1 file changed, 103 insertions(+), 115 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index 36977f09a6e8..9f435c5aaad4 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -731,129 +731,117 @@ void BBvCalculateParameter(struct vnt_private *pDevice, u32 cbFrameLength, int bExtBit; u8 byPreambleType = pDevice->byPreambleType; - cbBitCount = cbFrameLength * 8; - bExtBit = false; - - switch (wRate) { - case RATE_1M : - cbUsCount = cbBitCount; - phy->signal = 0x00; - break; - - case RATE_2M : - cbUsCount = cbBitCount / 2; - if (byPreambleType == 1) - phy->signal = 0x09; - else // long preamble - phy->signal = 0x01; - break; - - case RATE_5M : - cbUsCount = (cbBitCount * 10) / 55; - cbTmp = (cbUsCount * 55) / 10; - if (cbTmp != cbBitCount) - cbUsCount ++; - if (byPreambleType == 1) - phy->signal = 0x0a; - else // long preamble - phy->signal = 0x02; - break; - - case RATE_11M : - cbUsCount = cbBitCount / 11; - cbTmp = cbUsCount * 11; - if (cbTmp != cbBitCount) { - cbUsCount ++; - if ((cbBitCount - cbTmp) <= 3) - bExtBit = true; - } - if (byPreambleType == 1) - phy->signal = 0x0b; - else // long preamble - phy->signal = 0x03; - break; - - case RATE_6M : - if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ - phy->signal = 0x9b; - } - else {//11g, 2.4GHZ - phy->signal = 0x8b; - } - break; + cbBitCount = cbFrameLength * 8; + bExtBit = false; - case RATE_9M : - if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ - phy->signal = 0x9f; - } - else {//11g, 2.4GHZ - phy->signal = 0x8f; - } - break; + switch (wRate) { + case RATE_1M: + cbUsCount = cbBitCount; - case RATE_12M : - if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ - phy->signal = 0x9a; - } - else {//11g, 2.4GHZ - phy->signal = 0x8a; - } - break; + phy->signal = 0x00; - case RATE_18M : - if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ - phy->signal = 0x9e; - } - else {//11g, 2.4GHZ - phy->signal = 0x8e; - } - break; + break; + case RATE_2M: + cbUsCount = cbBitCount / 2; - case RATE_24M : - if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ - phy->signal = 0x99; - } - else {//11g, 2.4GHZ - phy->signal = 0x89; - } - break; + if (byPreambleType == 1) + phy->signal = 0x09; + else + phy->signal = 0x01; - case RATE_36M : - if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ - phy->signal = 0x9d; - } - else {//11g, 2.4GHZ - phy->signal = 0x8d; - } - break; + break; + case RATE_5M: + cbUsCount = (cbBitCount * 10) / 55; + cbTmp = (cbUsCount * 55) / 10; - case RATE_48M : - if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ - phy->signal = 0x98; - } - else {//11g, 2.4GHZ - phy->signal = 0x88; - } - break; + if (cbTmp != cbBitCount) + cbUsCount++; - case RATE_54M : - if (byPacketType == PK_TYPE_11A) {//11a, 5GHZ - phy->signal = 0x9c; - } - else {//11g, 2.4GHZ - phy->signal = 0x8c; - } - break; + if (byPreambleType == 1) + phy->signal = 0x0a; + else + phy->signal = 0x02; - default : - if (byPacketType == PK_TYPE_11A) {//11a, 5GHZ - phy->signal = 0x9c; - } - else {//11g, 2.4GHZ - phy->signal = 0x8c; - } - break; - } + break; + case RATE_11M: + cbUsCount = cbBitCount / 11; + cbTmp = cbUsCount * 11; + + if (cbTmp != cbBitCount) { + cbUsCount++; + + if ((cbBitCount - cbTmp) <= 3) + bExtBit = true; + } + + if (byPreambleType == 1) + phy->signal = 0x0b; + else + phy->signal = 0x03; + + break; + case RATE_6M: + if (byPacketType == PK_TYPE_11A) + phy->signal = 0x9b; + else + phy->signal = 0x8b; + + break; + case RATE_9M: + if (byPacketType == PK_TYPE_11A) + phy->signal = 0x9f; + else + phy->signal = 0x8f; + + break; + case RATE_12M: + if (byPacketType == PK_TYPE_11A) + phy->signal = 0x9a; + else + phy->signal = 0x8a; + + break; + case RATE_18M: + if (byPacketType == PK_TYPE_11A) + phy->signal = 0x9e; + else + phy->signal = 0x8e; + + break; + case RATE_24M: + if (byPacketType == PK_TYPE_11A) + phy->signal = 0x99; + else + phy->signal = 0x89; + + break; + case RATE_36M: + if (byPacketType == PK_TYPE_11A) + phy->signal = 0x9d; + else + phy->signal = 0x8d; + + break; + case RATE_48M: + if (byPacketType == PK_TYPE_11A) + phy->signal = 0x98; + else + phy->signal = 0x88; + + break; + case RATE_54M: + if (byPacketType == PK_TYPE_11A) + phy->signal = 0x9c; + else + phy->signal = 0x8c; + break; + default: + if (byPacketType == PK_TYPE_11A) + phy->signal = 0x9c; + else + phy->signal = 0x8c; + break; + } if (byPacketType == PK_TYPE_11B) { phy->service = 0x00; -- cgit v1.2.3 From a1ff5435145a06900fb4673db4974934a3ea3015 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 19 May 2014 20:33:02 +0100 Subject: staging: vt6656: BBvCalculateParameter remove camel case Camel case changes pDevice, cbFrameLength, wRate, byPacketType, cbBitCount, cbUsCount cbTmp, bExtBit, byPreambleType -> priv, frame_length, tx_rate, pkt_type, bit_count, count, tmp, ext_bit, preamble_type Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 82 +++++++++++++++++++-------------------- drivers/staging/vt6656/baseband.h | 4 +- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index 9f435c5aaad4..0bdc81495760 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -710,9 +710,9 @@ unsigned int BBuGetFrameTime(u8 preamble_type, u8 pkt_type, * * Parameters: * In: - * pDevice - Device Structure - * cbFrameLength - Tx Frame Length - * wRate - Tx Rate + * priv - Device Structure + * frame_length - Tx Frame Length + * tx_rate - Tx Rate * Out: * struct vnt_phy_field *phy * - pointer to Phy Length field @@ -722,135 +722,135 @@ unsigned int BBuGetFrameTime(u8 preamble_type, u8 pkt_type, * Return Value: none * */ -void BBvCalculateParameter(struct vnt_private *pDevice, u32 cbFrameLength, - u16 wRate, u8 byPacketType, struct vnt_phy_field *phy) +void BBvCalculateParameter(struct vnt_private *priv, u32 frame_length, + u16 tx_rate, u8 pkt_type, struct vnt_phy_field *phy) { - u32 cbBitCount; - u32 cbUsCount = 0; - u32 cbTmp; - int bExtBit; - u8 byPreambleType = pDevice->byPreambleType; + u32 bit_count; + u32 count = 0; + u32 tmp; + int ext_bit; + u8 preamble_type = priv->byPreambleType; - cbBitCount = cbFrameLength * 8; - bExtBit = false; + bit_count = frame_length * 8; + ext_bit = false; - switch (wRate) { + switch (tx_rate) { case RATE_1M: - cbUsCount = cbBitCount; + count = bit_count; phy->signal = 0x00; break; case RATE_2M: - cbUsCount = cbBitCount / 2; + count = bit_count / 2; - if (byPreambleType == 1) + if (preamble_type == 1) phy->signal = 0x09; else phy->signal = 0x01; break; case RATE_5M: - cbUsCount = (cbBitCount * 10) / 55; - cbTmp = (cbUsCount * 55) / 10; + count = (bit_count * 10) / 55; + tmp = (count * 55) / 10; - if (cbTmp != cbBitCount) - cbUsCount++; + if (tmp != bit_count) + count++; - if (byPreambleType == 1) + if (preamble_type == 1) phy->signal = 0x0a; else phy->signal = 0x02; break; case RATE_11M: - cbUsCount = cbBitCount / 11; - cbTmp = cbUsCount * 11; + count = bit_count / 11; + tmp = count * 11; - if (cbTmp != cbBitCount) { - cbUsCount++; + if (tmp != bit_count) { + count++; - if ((cbBitCount - cbTmp) <= 3) - bExtBit = true; + if ((bit_count - tmp) <= 3) + ext_bit = true; } - if (byPreambleType == 1) + if (preamble_type == 1) phy->signal = 0x0b; else phy->signal = 0x03; break; case RATE_6M: - if (byPacketType == PK_TYPE_11A) + if (pkt_type == PK_TYPE_11A) phy->signal = 0x9b; else phy->signal = 0x8b; break; case RATE_9M: - if (byPacketType == PK_TYPE_11A) + if (pkt_type == PK_TYPE_11A) phy->signal = 0x9f; else phy->signal = 0x8f; break; case RATE_12M: - if (byPacketType == PK_TYPE_11A) + if (pkt_type == PK_TYPE_11A) phy->signal = 0x9a; else phy->signal = 0x8a; break; case RATE_18M: - if (byPacketType == PK_TYPE_11A) + if (pkt_type == PK_TYPE_11A) phy->signal = 0x9e; else phy->signal = 0x8e; break; case RATE_24M: - if (byPacketType == PK_TYPE_11A) + if (pkt_type == PK_TYPE_11A) phy->signal = 0x99; else phy->signal = 0x89; break; case RATE_36M: - if (byPacketType == PK_TYPE_11A) + if (pkt_type == PK_TYPE_11A) phy->signal = 0x9d; else phy->signal = 0x8d; break; case RATE_48M: - if (byPacketType == PK_TYPE_11A) + if (pkt_type == PK_TYPE_11A) phy->signal = 0x98; else phy->signal = 0x88; break; case RATE_54M: - if (byPacketType == PK_TYPE_11A) + if (pkt_type == PK_TYPE_11A) phy->signal = 0x9c; else phy->signal = 0x8c; break; default: - if (byPacketType == PK_TYPE_11A) + if (pkt_type == PK_TYPE_11A) phy->signal = 0x9c; else phy->signal = 0x8c; break; } - if (byPacketType == PK_TYPE_11B) { + if (pkt_type == PK_TYPE_11B) { phy->service = 0x00; - if (bExtBit) + if (ext_bit) phy->service |= 0x80; - phy->len = cpu_to_le16((u16)cbUsCount); + phy->len = cpu_to_le16((u16)count); } else { phy->service = 0x00; - phy->len = cpu_to_le16((u16)cbFrameLength); + phy->len = cpu_to_le16((u16)frame_length); } } diff --git a/drivers/staging/vt6656/baseband.h b/drivers/staging/vt6656/baseband.h index da5520c888a5..005b94c9af24 100644 --- a/drivers/staging/vt6656/baseband.h +++ b/drivers/staging/vt6656/baseband.h @@ -91,8 +91,8 @@ struct vnt_phy_field { unsigned int BBuGetFrameTime(u8 preamble_type, u8 pkt_type, unsigned int frame_length, u16 tx_rate); -void BBvCalculateParameter(struct vnt_private *, u32 cbFrameLength, - u16 wRate, u8 byPacketType, struct vnt_phy_field *); +void BBvCalculateParameter(struct vnt_private *, u32 frame_length, + u16 tx_rate, u8 pkt_type, struct vnt_phy_field *); /* timer for antenna diversity */ -- cgit v1.2.3 From efe40c09b82c80f75b546443e187fdebf2308681 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 19 May 2014 20:33:03 +0100 Subject: staging: vt6656: clean up BBvSetAntennaMode. white space clean up. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index 0bdc81495760..5e2ffab42e56 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -869,25 +869,21 @@ void BBvCalculateParameter(struct vnt_private *priv, u32 frame_length, */ void BBvSetAntennaMode(struct vnt_private *pDevice, u8 byAntennaMode) { - switch (byAntennaMode) { - case ANT_TXA: - case ANT_TXB: - break; - case ANT_RXA: - pDevice->byBBRxConf &= 0xFC; - break; - case ANT_RXB: - pDevice->byBBRxConf &= 0xFE; - pDevice->byBBRxConf |= 0x02; - break; - } + switch (byAntennaMode) { + case ANT_TXA: + case ANT_TXB: + break; + case ANT_RXA: + pDevice->byBBRxConf &= 0xFC; + break; + case ANT_RXB: + pDevice->byBBRxConf &= 0xFE; + pDevice->byBBRxConf |= 0x02; + break; + } - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_SET_ANTMD, - (u16) byAntennaMode, - 0, - 0, - NULL); + CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_SET_ANTMD, + (u16)byAntennaMode, 0, 0, NULL); } /* -- cgit v1.2.3 From 53dab3280b972c1383ee0ef5eccb040f911cd131 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 19 May 2014 20:33:04 +0100 Subject: staging: vt6656: BBvSetAntennaMode remove camel case. changes pDevice -> priv byAntennaMode -> antenna_mode Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index 5e2ffab42e56..03ecde8f9eca 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -859,31 +859,31 @@ void BBvCalculateParameter(struct vnt_private *priv, u32 frame_length, * * Parameters: * In: - * pDevice - Device Structure - * byAntennaMode - Antenna Mode + * priv - Device Structure + * antenna_mode - Antenna Mode * Out: * none * * Return Value: none * */ -void BBvSetAntennaMode(struct vnt_private *pDevice, u8 byAntennaMode) +void BBvSetAntennaMode(struct vnt_private *priv, u8 antenna_mode) { - switch (byAntennaMode) { + switch (antenna_mode) { case ANT_TXA: case ANT_TXB: break; case ANT_RXA: - pDevice->byBBRxConf &= 0xFC; + priv->byBBRxConf &= 0xFC; break; case ANT_RXB: - pDevice->byBBRxConf &= 0xFE; - pDevice->byBBRxConf |= 0x02; + priv->byBBRxConf &= 0xFE; + priv->byBBRxConf |= 0x02; break; } - CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_SET_ANTMD, - (u16)byAntennaMode, 0, 0, NULL); + CONTROLnsRequestOut(priv, MESSAGE_TYPE_SET_ANTMD, + (u16)antenna_mode, 0, 0, NULL); } /* -- cgit v1.2.3 From 4bdb31202899caf056d4e423f3f00b966215c572 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 19 May 2014 20:33:05 +0100 Subject: staging: vt6656: BBvSetShortSlotTime remove camel case. pDevice -> priv byBBVGA -> bb_vga Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index 03ecde8f9eca..e440823ea13b 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -1078,27 +1078,28 @@ int BBbVT3184Init(struct vnt_private *priv) * * Parameters: * In: - * pDevice - Device Structure + * priv - Device Structure * Out: * none * * Return Value: none * */ -void BBvSetShortSlotTime(struct vnt_private *pDevice) +void BBvSetShortSlotTime(struct vnt_private *priv) { - u8 byBBVGA=0; + u8 bb_vga = 0; - if (pDevice->bShortSlotTime) - pDevice->byBBRxConf &= 0xDF;//1101 1111 + if (priv->bShortSlotTime) + priv->byBBRxConf &= 0xdf; else - pDevice->byBBRxConf |= 0x20;//0010 0000 + priv->byBBRxConf |= 0x20; + + ControlvReadByte(priv, MESSAGE_REQUEST_BBREG, 0xe7, &bb_vga); - ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0xE7, &byBBVGA); - if (byBBVGA == pDevice->abyBBVGA[0]) - pDevice->byBBRxConf |= 0x20;//0010 0000 + if (bb_vga == priv->abyBBVGA[0]) + priv->byBBRxConf |= 0x20; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0A, pDevice->byBBRxConf); + ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0x0a, priv->byBBRxConf); } void BBvSetVGAGainOffset(struct vnt_private *pDevice, u8 byData) -- cgit v1.2.3 From 15897f6724f3e48b73f52db28b5a8a4107ebf723 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 19 May 2014 20:33:06 +0100 Subject: staging: vt6656: BBvSetVGAGainOffset remove camel case pDevice -> priv byData -> data Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index e440823ea13b..466abd98f4a1 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -1102,18 +1102,18 @@ void BBvSetShortSlotTime(struct vnt_private *priv) ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0x0a, priv->byBBRxConf); } -void BBvSetVGAGainOffset(struct vnt_private *pDevice, u8 byData) +void BBvSetVGAGainOffset(struct vnt_private *priv, u8 data) { - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xE7, byData); + ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0xE7, data); - // patch for 3253B0 Baseband with Cardbus module - if (pDevice->bShortSlotTime) - pDevice->byBBRxConf &= 0xDF; /* 1101 1111 */ + /* patch for 3253B0 Baseband with Cardbus module */ + if (priv->bShortSlotTime) + priv->byBBRxConf &= 0xdf; /* 1101 1111 */ else - pDevice->byBBRxConf |= 0x20; /* 0010 0000 */ + priv->byBBRxConf |= 0x20; /* 0010 0000 */ - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0A, pDevice->byBBRxConf);//CR10 + ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0x0a, priv->byBBRxConf); } /* -- cgit v1.2.3 From 07c116f29c4825f591b9428510d18cb128b08e99 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 19 May 2014 20:33:07 +0100 Subject: staging: vt6656: BBvSetDeepSleep remove camel case pDevice -> priv Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index 466abd98f4a1..9956f5afc3ad 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -1121,17 +1121,17 @@ void BBvSetVGAGainOffset(struct vnt_private *priv, u8 data) * * Parameters: * In: - * pDevice - Device Structure + * priv - Device Structure * Out: * none * * Return Value: none * */ -void BBvSetDeepSleep(struct vnt_private *pDevice) +void BBvSetDeepSleep(struct vnt_private *priv) { - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0c, 0x17);//CR12 - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0D, 0xB9);//CR13 + ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0x0c, 0x17);/* CR12 */ + ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0xB9);/* CR13 */ } void BBvExitDeepSleep(struct vnt_private *pDevice) -- cgit v1.2.3 From 36c69f3ce5fc1218308fb9ce3ecf1f4119e40586 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 19 May 2014 20:33:08 +0100 Subject: staging: vt6656: BBvExitDeepSleep remove camel case. pDevice -> priv Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index 9956f5afc3ad..0cde6b5bf7d0 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -1134,10 +1134,10 @@ void BBvSetDeepSleep(struct vnt_private *priv) ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0xB9);/* CR13 */ } -void BBvExitDeepSleep(struct vnt_private *pDevice) +void BBvExitDeepSleep(struct vnt_private *priv) { - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0C, 0x00);//CR12 - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0D, 0x01);//CR13 + ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0x0c, 0x00);/* CR12 */ + ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0x01);/* CR13 */ } static unsigned long s_ulGetLowSQ3(struct vnt_private *pDevice) -- cgit v1.2.3 From 0b7021f57b7b8d44989bd399a1034cb98bfe358a Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 19 May 2014 20:33:09 +0100 Subject: staging: vt6656: BBvUpdatePreEDThreshold replace debug messages. Replace DBG_PRT with single dev_dbg with calling function and byBBPreEDRSSI value. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 71 ++------------------------------------- 1 file changed, 3 insertions(+), 68 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index 0cde6b5bf7d0..087b84d9173f 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -1423,7 +1423,6 @@ void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning) pDevice->byBBPreEDIndex = 0; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70, -71,...\n"); break; } @@ -1432,127 +1431,106 @@ void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning) pDevice->byBBPreEDIndex = 20; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI 0, -1,-2,..-45\n"); } else if(pDevice->byBBPreEDRSSI <= 46) { //RSSI -46 if(pDevice->byBBPreEDIndex == 19) break; pDevice->byBBPreEDIndex = 19; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x1A); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -46\n"); } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -47 if(pDevice->byBBPreEDIndex == 18) break; pDevice->byBBPreEDIndex = 18; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x15); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -47\n"); } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49 if(pDevice->byBBPreEDIndex == 17) break; pDevice->byBBPreEDIndex = 17; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0E); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -48,-49\n"); } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51 if(pDevice->byBBPreEDIndex == 16) break; pDevice->byBBPreEDIndex = 16; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x09); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -50,-51\n"); } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53 if(pDevice->byBBPreEDIndex == 15) break; pDevice->byBBPreEDIndex = 15; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x06); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -52,-53\n"); } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55 if(pDevice->byBBPreEDIndex == 14) break; pDevice->byBBPreEDIndex = 14; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x03); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -54,-55\n"); } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56 if(pDevice->byBBPreEDIndex == 13) break; pDevice->byBBPreEDIndex = 13; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xA0); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -56\n"); } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57 if(pDevice->byBBPreEDIndex == 12) break; pDevice->byBBPreEDIndex = 12; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x20); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -57\n"); } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58 if(pDevice->byBBPreEDIndex == 11) break; pDevice->byBBPreEDIndex = 11; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xA0); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -58\n"); } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59 if(pDevice->byBBPreEDIndex == 10) break; pDevice->byBBPreEDIndex = 10; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x54); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -59\n"); } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60 if(pDevice->byBBPreEDIndex == 9) break; pDevice->byBBPreEDIndex = 9; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x18); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -60\n"); } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61 if(pDevice->byBBPreEDIndex == 8) break; pDevice->byBBPreEDIndex = 8; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xE3); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -61\n"); } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62 if(pDevice->byBBPreEDIndex == 7) break; pDevice->byBBPreEDIndex = 7; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB9); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -62\n"); } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63 if(pDevice->byBBPreEDIndex == 6) break; pDevice->byBBPreEDIndex = 6; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x93); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -63\n"); } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64 if(pDevice->byBBPreEDIndex == 5) break; pDevice->byBBPreEDIndex = 5; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x79); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -64\n"); } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65 if(pDevice->byBBPreEDIndex == 4) break; pDevice->byBBPreEDIndex = 4; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x62); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -65\n"); } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66 if(pDevice->byBBPreEDIndex == 3) break; pDevice->byBBPreEDIndex = 3; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x51); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -66\n"); } else if(pDevice->byBBPreEDRSSI <= 67) { //RSSI -67 if(pDevice->byBBPreEDIndex == 2) break; pDevice->byBBPreEDIndex = 2; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67\n"); } else if(pDevice->byBBPreEDRSSI <= 68) { //RSSI -68 if(pDevice->byBBPreEDIndex == 1) break; pDevice->byBBPreEDIndex = 1; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x36); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -68\n"); } else { //RSSI -69, -70,.... if(pDevice->byBBPreEDIndex == 0) break; pDevice->byBBPreEDIndex = 0; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70,...\n"); } break; @@ -1565,7 +1543,6 @@ void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning) pDevice->byBBPreEDIndex = 0; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x24); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70,..\n"); break; } @@ -1574,139 +1551,116 @@ void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning) pDevice->byBBPreEDIndex = 22; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI 0, -1,-2,..-41\n"); } else if(pDevice->byBBPreEDRSSI <= 42) { //RSSI -42 if(pDevice->byBBPreEDIndex == 21) break; pDevice->byBBPreEDIndex = 21; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x36); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -42\n"); } else if(pDevice->byBBPreEDRSSI <= 43) { //RSSI -43 if(pDevice->byBBPreEDIndex == 20) break; pDevice->byBBPreEDIndex = 20; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x26); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -43\n"); } else if(pDevice->byBBPreEDRSSI <= 45) { //RSSI -44, -45 if(pDevice->byBBPreEDIndex == 19) break; pDevice->byBBPreEDIndex = 19; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x18); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -44,-45\n"); } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -46, -47 if(pDevice->byBBPreEDIndex == 18) break; pDevice->byBBPreEDIndex = 18; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x11); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -46,-47\n"); } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49 if(pDevice->byBBPreEDIndex == 17) break; pDevice->byBBPreEDIndex = 17; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0a); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -48,-49\n"); } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51 if(pDevice->byBBPreEDIndex == 16) break; pDevice->byBBPreEDIndex = 16; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x07); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -50,-51\n"); } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53 if(pDevice->byBBPreEDIndex == 15) break; pDevice->byBBPreEDIndex = 15; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x04); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -52,-53\n"); } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55 if(pDevice->byBBPreEDIndex == 14) break; pDevice->byBBPreEDIndex = 14; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -54,-55\n"); } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56 if(pDevice->byBBPreEDIndex == 13) break; pDevice->byBBPreEDIndex = 13; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -56\n"); } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57 if(pDevice->byBBPreEDIndex == 12) break; pDevice->byBBPreEDIndex = 12; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB0); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -57\n"); } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58 if(pDevice->byBBPreEDIndex == 11) break; pDevice->byBBPreEDIndex = 11; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x70); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -58\n"); } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59 if(pDevice->byBBPreEDIndex == 10) break; pDevice->byBBPreEDIndex = 10; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -59\n"); } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60 if(pDevice->byBBPreEDIndex == 9) break; pDevice->byBBPreEDIndex = 9; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xEA); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -60\n"); } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61 if(pDevice->byBBPreEDIndex == 8) break; pDevice->byBBPreEDIndex = 8; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -61\n"); } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62 if(pDevice->byBBPreEDIndex == 7) break; pDevice->byBBPreEDIndex = 7; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x9C); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -62\n"); } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63 if(pDevice->byBBPreEDIndex == 6) break; pDevice->byBBPreEDIndex = 6; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x80); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -63\n"); } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64 if(pDevice->byBBPreEDIndex == 5) break; pDevice->byBBPreEDIndex = 5; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x68); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -64\n"); } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65 if(pDevice->byBBPreEDIndex == 4) break; pDevice->byBBPreEDIndex = 4; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x52); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -65\n"); } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66 if(pDevice->byBBPreEDIndex == 3) break; pDevice->byBBPreEDIndex = 3; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -66\n"); } else if(pDevice->byBBPreEDRSSI <= 67) { //RSSI -67 if(pDevice->byBBPreEDIndex == 2) break; pDevice->byBBPreEDIndex = 2; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x36); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67\n"); } else if(pDevice->byBBPreEDRSSI <= 68) { //RSSI -68 if(pDevice->byBBPreEDIndex == 1) break; pDevice->byBBPreEDIndex = 1; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x2D); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -68\n"); } else { //RSSI -69, -70, ... if(pDevice->byBBPreEDIndex == 0) break; pDevice->byBBPreEDIndex = 0; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x24); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70,..\n"); } break; @@ -1716,7 +1670,6 @@ void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning) pDevice->byBBPreEDIndex = 0; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x38); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67, -68,..\n"); break; } @@ -1725,131 +1678,113 @@ void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning) pDevice->byBBPreEDIndex = 20; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI 0, -1,-2,..-41\n"); } else if(pDevice->byBBPreEDRSSI <= 42) { //RSSI -42 if(pDevice->byBBPreEDIndex == 19) break; pDevice->byBBPreEDIndex = 19; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x36); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -42\n"); } else if(pDevice->byBBPreEDRSSI <= 43) { //RSSI -43 if(pDevice->byBBPreEDIndex == 18) break; pDevice->byBBPreEDIndex = 18; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x26); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -43\n"); } else if(pDevice->byBBPreEDRSSI <= 45) { //RSSI -44, -45 if(pDevice->byBBPreEDIndex == 17) break; pDevice->byBBPreEDIndex = 17; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x18); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -44,-45\n"); } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -46, -47 if(pDevice->byBBPreEDIndex == 16) break; pDevice->byBBPreEDIndex = 16; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x11); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -46,-47\n"); } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49 if(pDevice->byBBPreEDIndex == 15) break; pDevice->byBBPreEDIndex = 15; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0a); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -48,-49\n"); } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51 if(pDevice->byBBPreEDIndex == 14) break; pDevice->byBBPreEDIndex = 14; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x07); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -50,-51\n"); } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53 if(pDevice->byBBPreEDIndex == 13) break; pDevice->byBBPreEDIndex = 13; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x04); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -52,-53\n"); } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55 if(pDevice->byBBPreEDIndex == 12) break; pDevice->byBBPreEDIndex = 12; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -54,-55\n"); } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56 if(pDevice->byBBPreEDIndex == 11) break; pDevice->byBBPreEDIndex = 11; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -56\n"); } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57 if(pDevice->byBBPreEDIndex == 10) break; pDevice->byBBPreEDIndex = 10; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB0); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -57\n"); } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58 if(pDevice->byBBPreEDIndex == 9) break; pDevice->byBBPreEDIndex = 9; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x70); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -58\n"); } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59 if(pDevice->byBBPreEDIndex == 8) break; pDevice->byBBPreEDIndex = 8; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -59\n"); } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60 if(pDevice->byBBPreEDIndex == 7) break; pDevice->byBBPreEDIndex = 7; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xEA); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -60\n"); } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61 if(pDevice->byBBPreEDIndex == 6) break; pDevice->byBBPreEDIndex = 6; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -61\n"); } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62 if(pDevice->byBBPreEDIndex == 5) break; pDevice->byBBPreEDIndex = 5; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x9C); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -62\n"); } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63 if(pDevice->byBBPreEDIndex == 4) break; pDevice->byBBPreEDIndex = 4; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x80); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -63\n"); } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64 if(pDevice->byBBPreEDIndex == 3) break; pDevice->byBBPreEDIndex = 3; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x68); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -64\n"); } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65 if(pDevice->byBBPreEDIndex == 2) break; pDevice->byBBPreEDIndex = 2; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x52); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -65\n"); } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66 if(pDevice->byBBPreEDIndex == 1) break; pDevice->byBBPreEDIndex = 1; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -66\n"); } else { //RSSI -67, -68, ... if(pDevice->byBBPreEDIndex == 0) break; pDevice->byBBPreEDIndex = 0; ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x38); //CR206(0xCE) - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67, -68,..\n"); } break; } + dev_dbg(&pDevice->usb->dev, "%s byBBPreEDRSSI %d\n", + __func__, pDevice->byBBPreEDRSSI); + } -- cgit v1.2.3 From 7794dad6721d8c202fcdc360e0d2d62f4090449e Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 19 May 2014 20:33:10 +0100 Subject: staging: vt6656: BBvUpdatePreEDThreshold reorganize ControlvWriteByte. Create variables cr_201 and cr 206 with values for registers 0xc9 and 0xce. Set both to zero . If cr201 and cr206 are zero drop out. write both out with ControlvWriteByte. pDevice->byBBPreEDIndex breaks will be dealt with in next patch Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 225 +++++++++++++++----------------------- 1 file changed, 89 insertions(+), 136 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index 087b84d9173f..39bdd4b496e1 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -1410,6 +1410,7 @@ void TimerSQ3Tmax3CallBack(struct vnt_private *pDevice) void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning) { + u8 cr_201 = 0x0, cr_206 = 0x0; switch(pDevice->byRFType) { @@ -1421,116 +1422,99 @@ void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning) if( bScanning ) { // need Max sensitivity //RSSI -69, -70,.... pDevice->byBBPreEDIndex = 0; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE) + cr_206 = 0x30; break; } if(pDevice->byBBPreEDRSSI <= 45) { // RSSI 0, -1,-2,....-45 if(pDevice->byBBPreEDIndex == 20) break; pDevice->byBBPreEDIndex = 20; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) + cr_201 = 0xff; } else if(pDevice->byBBPreEDRSSI <= 46) { //RSSI -46 if(pDevice->byBBPreEDIndex == 19) break; pDevice->byBBPreEDIndex = 19; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x1A); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) + cr_201 = 0x1a; } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -47 if(pDevice->byBBPreEDIndex == 18) break; pDevice->byBBPreEDIndex = 18; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x15); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) + cr_201 = 0x15; } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49 if(pDevice->byBBPreEDIndex == 17) break; pDevice->byBBPreEDIndex = 17; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0E); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) + cr_201 = 0xe; } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51 if(pDevice->byBBPreEDIndex == 16) break; pDevice->byBBPreEDIndex = 16; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x09); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) + cr_201 = 0x9; } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53 if(pDevice->byBBPreEDIndex == 15) break; pDevice->byBBPreEDIndex = 15; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x06); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) + cr_201 = 0x6; } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55 if(pDevice->byBBPreEDIndex == 14) break; pDevice->byBBPreEDIndex = 14; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x03); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) + cr_201 = 0x3; } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56 if(pDevice->byBBPreEDIndex == 13) break; pDevice->byBBPreEDIndex = 13; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xA0); //CR206(0xCE) + cr_201 = 0x2; + cr_206 = 0xa0; } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57 if(pDevice->byBBPreEDIndex == 12) break; pDevice->byBBPreEDIndex = 12; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x20); //CR206(0xCE) + cr_201 = 0x2; + cr_206 = 0x20; } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58 if(pDevice->byBBPreEDIndex == 11) break; pDevice->byBBPreEDIndex = 11; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xA0); //CR206(0xCE) + cr_201 = 0x1; + cr_206 = 0xa0; } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59 if(pDevice->byBBPreEDIndex == 10) break; pDevice->byBBPreEDIndex = 10; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x54); //CR206(0xCE) + cr_201 = 0x1; + cr_206 = 0x54; } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60 if(pDevice->byBBPreEDIndex == 9) break; pDevice->byBBPreEDIndex = 9; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x18); //CR206(0xCE) + cr_201 = 0x1; + cr_206 = 0x18; } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61 if(pDevice->byBBPreEDIndex == 8) break; pDevice->byBBPreEDIndex = 8; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xE3); //CR206(0xCE) + cr_206 = 0xe3; } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62 if(pDevice->byBBPreEDIndex == 7) break; pDevice->byBBPreEDIndex = 7; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB9); //CR206(0xCE) + cr_206 = 0xb9; } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63 if(pDevice->byBBPreEDIndex == 6) break; pDevice->byBBPreEDIndex = 6; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x93); //CR206(0xCE) + cr_206 = 0x93; } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64 if(pDevice->byBBPreEDIndex == 5) break; pDevice->byBBPreEDIndex = 5; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x79); //CR206(0xCE) + cr_206 = 0x79; } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65 if(pDevice->byBBPreEDIndex == 4) break; pDevice->byBBPreEDIndex = 4; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x62); //CR206(0xCE) + cr_206 = 0x62; } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66 if(pDevice->byBBPreEDIndex == 3) break; pDevice->byBBPreEDIndex = 3; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x51); //CR206(0xCE) + cr_206 = 0x51; } else if(pDevice->byBBPreEDRSSI <= 67) { //RSSI -67 if(pDevice->byBBPreEDIndex == 2) break; pDevice->byBBPreEDIndex = 2; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE) + cr_206 = 0x43; } else if(pDevice->byBBPreEDRSSI <= 68) { //RSSI -68 if(pDevice->byBBPreEDIndex == 1) break; pDevice->byBBPreEDIndex = 1; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x36); //CR206(0xCE) + cr_206 = 0x36; } else { //RSSI -69, -70,.... if(pDevice->byBBPreEDIndex == 0) break; pDevice->byBBPreEDIndex = 0; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE) + cr_206 = 0x30; } break; @@ -1541,126 +1525,107 @@ void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning) if( bScanning ) { // need Max sensitivity //RSSI -69, -70, ... pDevice->byBBPreEDIndex = 0; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x24); //CR206(0xCE) + cr_206 = 0x24; break; } if(pDevice->byBBPreEDRSSI <= 41) { // RSSI 0, -1,-2,....-41 if(pDevice->byBBPreEDIndex == 22) break; pDevice->byBBPreEDIndex = 22; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) + cr_201 = 0xff; } else if(pDevice->byBBPreEDRSSI <= 42) { //RSSI -42 if(pDevice->byBBPreEDIndex == 21) break; pDevice->byBBPreEDIndex = 21; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x36); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) + cr_201 = 0x36; } else if(pDevice->byBBPreEDRSSI <= 43) { //RSSI -43 if(pDevice->byBBPreEDIndex == 20) break; pDevice->byBBPreEDIndex = 20; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x26); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) + cr_201 = 0x26; } else if(pDevice->byBBPreEDRSSI <= 45) { //RSSI -44, -45 if(pDevice->byBBPreEDIndex == 19) break; pDevice->byBBPreEDIndex = 19; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x18); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) + cr_201 = 0x18; } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -46, -47 if(pDevice->byBBPreEDIndex == 18) break; pDevice->byBBPreEDIndex = 18; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x11); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) + cr_201 = 0x11; } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49 if(pDevice->byBBPreEDIndex == 17) break; pDevice->byBBPreEDIndex = 17; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0a); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) + cr_201 = 0xa; } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51 if(pDevice->byBBPreEDIndex == 16) break; pDevice->byBBPreEDIndex = 16; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x07); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) + cr_201 = 0x7; } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53 if(pDevice->byBBPreEDIndex == 15) break; pDevice->byBBPreEDIndex = 15; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x04); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) + cr_201 = 0x4; } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55 if(pDevice->byBBPreEDIndex == 14) break; pDevice->byBBPreEDIndex = 14; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE) + cr_201 = 0x2; + cr_206 = 0xc0; } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56 if(pDevice->byBBPreEDIndex == 13) break; pDevice->byBBPreEDIndex = 13; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE) + cr_201 = 0x2; + cr_206 = 0x30; } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57 if(pDevice->byBBPreEDIndex == 12) break; pDevice->byBBPreEDIndex = 12; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB0); //CR206(0xCE) + cr_201 = 0x1; + cr_206 = 0xb0; } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58 if(pDevice->byBBPreEDIndex == 11) break; pDevice->byBBPreEDIndex = 11; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x70); //CR206(0xCE) + cr_201 = 0x1; + cr_206 = 0x70; } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59 if(pDevice->byBBPreEDIndex == 10) break; pDevice->byBBPreEDIndex = 10; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE) + cr_201 = 0x1; + cr_206 = 0x30; } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60 if(pDevice->byBBPreEDIndex == 9) break; pDevice->byBBPreEDIndex = 9; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xEA); //CR206(0xCE) + cr_206 = 0xea; } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61 if(pDevice->byBBPreEDIndex == 8) break; pDevice->byBBPreEDIndex = 8; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE) + cr_206 = 0xc0; } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62 if(pDevice->byBBPreEDIndex == 7) break; pDevice->byBBPreEDIndex = 7; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x9C); //CR206(0xCE) + cr_206 = 0x9c; } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63 if(pDevice->byBBPreEDIndex == 6) break; pDevice->byBBPreEDIndex = 6; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x80); //CR206(0xCE) + cr_206 = 0x80; } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64 if(pDevice->byBBPreEDIndex == 5) break; pDevice->byBBPreEDIndex = 5; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x68); //CR206(0xCE) + cr_206 = 0x68; } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65 if(pDevice->byBBPreEDIndex == 4) break; pDevice->byBBPreEDIndex = 4; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x52); //CR206(0xCE) + cr_206 = 0x52; } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66 if(pDevice->byBBPreEDIndex == 3) break; pDevice->byBBPreEDIndex = 3; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE) + cr_206 = 0x43; } else if(pDevice->byBBPreEDRSSI <= 67) { //RSSI -67 if(pDevice->byBBPreEDIndex == 2) break; pDevice->byBBPreEDIndex = 2; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x36); //CR206(0xCE) + cr_206 = 0x36; } else if(pDevice->byBBPreEDRSSI <= 68) { //RSSI -68 if(pDevice->byBBPreEDIndex == 1) break; pDevice->byBBPreEDIndex = 1; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x2D); //CR206(0xCE) + cr_206 = 0x2d; } else { //RSSI -69, -70, ... if(pDevice->byBBPreEDIndex == 0) break; pDevice->byBBPreEDIndex = 0; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x24); //CR206(0xCE) + cr_206 = 0x24; } break; @@ -1668,116 +1633,99 @@ void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning) if( bScanning ) { // need Max sensitivity //RSSI -67, -68, ... pDevice->byBBPreEDIndex = 0; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x38); //CR206(0xCE) + cr_206 = 0x38; break; } if(pDevice->byBBPreEDRSSI <= 41) { // RSSI 0, -1,-2,....-41 if(pDevice->byBBPreEDIndex == 20) break; pDevice->byBBPreEDIndex = 20; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) + cr_201 = 0xff; } else if(pDevice->byBBPreEDRSSI <= 42) { //RSSI -42 if(pDevice->byBBPreEDIndex == 19) break; pDevice->byBBPreEDIndex = 19; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x36); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) + cr_201 = 0x36; } else if(pDevice->byBBPreEDRSSI <= 43) { //RSSI -43 if(pDevice->byBBPreEDIndex == 18) break; pDevice->byBBPreEDIndex = 18; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x26); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) + cr_201 = 0x26; } else if(pDevice->byBBPreEDRSSI <= 45) { //RSSI -44, -45 if(pDevice->byBBPreEDIndex == 17) break; pDevice->byBBPreEDIndex = 17; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x18); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) + cr_201 = 0x18; } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -46, -47 if(pDevice->byBBPreEDIndex == 16) break; pDevice->byBBPreEDIndex = 16; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x11); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) + cr_201 = 0x11; } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49 if(pDevice->byBBPreEDIndex == 15) break; pDevice->byBBPreEDIndex = 15; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0a); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) + cr_201 = 0xa; } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51 if(pDevice->byBBPreEDIndex == 14) break; pDevice->byBBPreEDIndex = 14; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x07); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) + cr_201 = 0x7; } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53 if(pDevice->byBBPreEDIndex == 13) break; pDevice->byBBPreEDIndex = 13; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x04); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) + cr_201 = 0x4; } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55 if(pDevice->byBBPreEDIndex == 12) break; pDevice->byBBPreEDIndex = 12; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE) + cr_201 = 0x2; + cr_206 = 0xc0; } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56 if(pDevice->byBBPreEDIndex == 11) break; pDevice->byBBPreEDIndex = 11; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE) + cr_201 = 0x2; + cr_206 = 0x30; } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57 if(pDevice->byBBPreEDIndex == 10) break; pDevice->byBBPreEDIndex = 10; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB0); //CR206(0xCE) + cr_201 = 0x1; + cr_206 = 0xb0; } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58 if(pDevice->byBBPreEDIndex == 9) break; pDevice->byBBPreEDIndex = 9; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x70); //CR206(0xCE) + cr_201 = 0x1; + cr_206 = 0x70; } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59 if(pDevice->byBBPreEDIndex == 8) break; pDevice->byBBPreEDIndex = 8; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE) + cr_201 = 0x1; + cr_206 = 0x30; } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60 if(pDevice->byBBPreEDIndex == 7) break; pDevice->byBBPreEDIndex = 7; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xEA); //CR206(0xCE) + cr_206 = 0xea; } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61 if(pDevice->byBBPreEDIndex == 6) break; pDevice->byBBPreEDIndex = 6; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE) + cr_206 = 0xc0; } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62 if(pDevice->byBBPreEDIndex == 5) break; pDevice->byBBPreEDIndex = 5; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x9C); //CR206(0xCE) + cr_206 = 0x9c; } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63 if(pDevice->byBBPreEDIndex == 4) break; pDevice->byBBPreEDIndex = 4; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x80); //CR206(0xCE) + cr_206 = 0x80; } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64 if(pDevice->byBBPreEDIndex == 3) break; pDevice->byBBPreEDIndex = 3; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x68); //CR206(0xCE) + cr_206 = 0x68; } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65 if(pDevice->byBBPreEDIndex == 2) break; pDevice->byBBPreEDIndex = 2; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x52); //CR206(0xCE) + cr_206 = 0x52; } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66 if(pDevice->byBBPreEDIndex == 1) break; pDevice->byBBPreEDIndex = 1; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE) + cr_206 = 0x43; } else { //RSSI -67, -68, ... if(pDevice->byBBPreEDIndex == 0) break; pDevice->byBBPreEDIndex = 0; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x38); //CR206(0xCE) + cr_206 = 0x38; } break; @@ -1786,5 +1734,10 @@ void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning) dev_dbg(&pDevice->usb->dev, "%s byBBPreEDRSSI %d\n", __func__, pDevice->byBBPreEDRSSI); + if (!cr_201 && !cr_206) + return; + + ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xc9, cr_201); + ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xce, cr_206); } -- cgit v1.2.3 From 6d5485af95e62ad82b8e9db8e250126e13f3e1bc Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 19 May 2014 20:33:11 +0100 Subject: staging: vt6656: BBvUpdatePreEDThreshold change byBBPreEDIndex assign pDevice->byBBPreEDIndex to ed_idx and change ed_inx value in switch. If ed_inx == byBBPreEDIndex and not bScanning return out. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 207 ++++++++++++++------------------------ 1 file changed, 74 insertions(+), 133 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index 39bdd4b496e1..b308a7d4ddbd 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -1411,6 +1411,7 @@ void TimerSQ3Tmax3CallBack(struct vnt_private *pDevice) void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning) { u8 cr_201 = 0x0, cr_206 = 0x0; + u8 ed_inx = pDevice->byBBPreEDIndex; switch(pDevice->byRFType) { @@ -1421,99 +1422,78 @@ void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning) if( bScanning ) { // need Max sensitivity //RSSI -69, -70,.... - pDevice->byBBPreEDIndex = 0; + ed_inx = 0; cr_206 = 0x30; break; } if(pDevice->byBBPreEDRSSI <= 45) { // RSSI 0, -1,-2,....-45 - if(pDevice->byBBPreEDIndex == 20) break; - pDevice->byBBPreEDIndex = 20; + ed_inx = 20; cr_201 = 0xff; } else if(pDevice->byBBPreEDRSSI <= 46) { //RSSI -46 - if(pDevice->byBBPreEDIndex == 19) break; - pDevice->byBBPreEDIndex = 19; + ed_inx = 19; cr_201 = 0x1a; } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -47 - if(pDevice->byBBPreEDIndex == 18) break; - pDevice->byBBPreEDIndex = 18; + ed_inx = 18; cr_201 = 0x15; } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49 - if(pDevice->byBBPreEDIndex == 17) break; - pDevice->byBBPreEDIndex = 17; + ed_inx = 17; cr_201 = 0xe; } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51 - if(pDevice->byBBPreEDIndex == 16) break; - pDevice->byBBPreEDIndex = 16; + ed_inx = 16; cr_201 = 0x9; } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53 - if(pDevice->byBBPreEDIndex == 15) break; - pDevice->byBBPreEDIndex = 15; + ed_inx = 15; cr_201 = 0x6; } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55 - if(pDevice->byBBPreEDIndex == 14) break; - pDevice->byBBPreEDIndex = 14; + ed_inx = 14; cr_201 = 0x3; } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56 - if(pDevice->byBBPreEDIndex == 13) break; - pDevice->byBBPreEDIndex = 13; + ed_inx = 13; cr_201 = 0x2; cr_206 = 0xa0; } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57 - if(pDevice->byBBPreEDIndex == 12) break; - pDevice->byBBPreEDIndex = 12; + ed_inx = 12; cr_201 = 0x2; cr_206 = 0x20; } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58 - if(pDevice->byBBPreEDIndex == 11) break; - pDevice->byBBPreEDIndex = 11; + ed_inx = 11; cr_201 = 0x1; cr_206 = 0xa0; } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59 - if(pDevice->byBBPreEDIndex == 10) break; - pDevice->byBBPreEDIndex = 10; + ed_inx = 10; cr_201 = 0x1; cr_206 = 0x54; } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60 - if(pDevice->byBBPreEDIndex == 9) break; - pDevice->byBBPreEDIndex = 9; + ed_inx = 9; cr_201 = 0x1; cr_206 = 0x18; } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61 - if(pDevice->byBBPreEDIndex == 8) break; - pDevice->byBBPreEDIndex = 8; + ed_inx = 8; cr_206 = 0xe3; } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62 - if(pDevice->byBBPreEDIndex == 7) break; - pDevice->byBBPreEDIndex = 7; + ed_inx = 7; cr_206 = 0xb9; } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63 - if(pDevice->byBBPreEDIndex == 6) break; - pDevice->byBBPreEDIndex = 6; + ed_inx = 6; cr_206 = 0x93; } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64 - if(pDevice->byBBPreEDIndex == 5) break; - pDevice->byBBPreEDIndex = 5; + ed_inx = 5; cr_206 = 0x79; } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65 - if(pDevice->byBBPreEDIndex == 4) break; - pDevice->byBBPreEDIndex = 4; + ed_inx = 4; cr_206 = 0x62; } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66 - if(pDevice->byBBPreEDIndex == 3) break; - pDevice->byBBPreEDIndex = 3; + ed_inx = 3; cr_206 = 0x51; } else if(pDevice->byBBPreEDRSSI <= 67) { //RSSI -67 - if(pDevice->byBBPreEDIndex == 2) break; - pDevice->byBBPreEDIndex = 2; + ed_inx = 2; cr_206 = 0x43; } else if(pDevice->byBBPreEDRSSI <= 68) { //RSSI -68 - if(pDevice->byBBPreEDIndex == 1) break; - pDevice->byBBPreEDIndex = 1; + ed_inx = 1; cr_206 = 0x36; } else { //RSSI -69, -70,.... - if(pDevice->byBBPreEDIndex == 0) break; - pDevice->byBBPreEDIndex = 0; + ed_inx = 0; cr_206 = 0x30; } break; @@ -1524,107 +1504,84 @@ void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning) if( bScanning ) { // need Max sensitivity //RSSI -69, -70, ... - pDevice->byBBPreEDIndex = 0; + ed_inx = 0; cr_206 = 0x24; break; } if(pDevice->byBBPreEDRSSI <= 41) { // RSSI 0, -1,-2,....-41 - if(pDevice->byBBPreEDIndex == 22) break; - pDevice->byBBPreEDIndex = 22; + ed_inx = 22; cr_201 = 0xff; } else if(pDevice->byBBPreEDRSSI <= 42) { //RSSI -42 - if(pDevice->byBBPreEDIndex == 21) break; - pDevice->byBBPreEDIndex = 21; + ed_inx = 21; cr_201 = 0x36; } else if(pDevice->byBBPreEDRSSI <= 43) { //RSSI -43 - if(pDevice->byBBPreEDIndex == 20) break; - pDevice->byBBPreEDIndex = 20; + ed_inx = 20; cr_201 = 0x26; } else if(pDevice->byBBPreEDRSSI <= 45) { //RSSI -44, -45 - if(pDevice->byBBPreEDIndex == 19) break; - pDevice->byBBPreEDIndex = 19; + ed_inx = 19; cr_201 = 0x18; } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -46, -47 - if(pDevice->byBBPreEDIndex == 18) break; - pDevice->byBBPreEDIndex = 18; + ed_inx = 18; cr_201 = 0x11; } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49 - if(pDevice->byBBPreEDIndex == 17) break; - pDevice->byBBPreEDIndex = 17; + ed_inx = 17; cr_201 = 0xa; } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51 - if(pDevice->byBBPreEDIndex == 16) break; - pDevice->byBBPreEDIndex = 16; + ed_inx = 16; cr_201 = 0x7; } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53 - if(pDevice->byBBPreEDIndex == 15) break; - pDevice->byBBPreEDIndex = 15; + ed_inx = 15; cr_201 = 0x4; } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55 - if(pDevice->byBBPreEDIndex == 14) break; - pDevice->byBBPreEDIndex = 14; + ed_inx = 14; cr_201 = 0x2; cr_206 = 0xc0; } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56 - if(pDevice->byBBPreEDIndex == 13) break; - pDevice->byBBPreEDIndex = 13; + ed_inx = 13; cr_201 = 0x2; cr_206 = 0x30; } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57 - if(pDevice->byBBPreEDIndex == 12) break; - pDevice->byBBPreEDIndex = 12; + ed_inx = 12; cr_201 = 0x1; cr_206 = 0xb0; } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58 - if(pDevice->byBBPreEDIndex == 11) break; - pDevice->byBBPreEDIndex = 11; + ed_inx = 11; cr_201 = 0x1; cr_206 = 0x70; } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59 - if(pDevice->byBBPreEDIndex == 10) break; - pDevice->byBBPreEDIndex = 10; + ed_inx = 10; cr_201 = 0x1; cr_206 = 0x30; } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60 - if(pDevice->byBBPreEDIndex == 9) break; - pDevice->byBBPreEDIndex = 9; + ed_inx = 9; cr_206 = 0xea; } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61 - if(pDevice->byBBPreEDIndex == 8) break; - pDevice->byBBPreEDIndex = 8; + ed_inx = 8; cr_206 = 0xc0; } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62 - if(pDevice->byBBPreEDIndex == 7) break; - pDevice->byBBPreEDIndex = 7; + ed_inx = 7; cr_206 = 0x9c; } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63 - if(pDevice->byBBPreEDIndex == 6) break; - pDevice->byBBPreEDIndex = 6; + ed_inx = 6; cr_206 = 0x80; } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64 - if(pDevice->byBBPreEDIndex == 5) break; - pDevice->byBBPreEDIndex = 5; + ed_inx = 5; cr_206 = 0x68; } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65 - if(pDevice->byBBPreEDIndex == 4) break; - pDevice->byBBPreEDIndex = 4; + ed_inx = 4; cr_206 = 0x52; } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66 - if(pDevice->byBBPreEDIndex == 3) break; - pDevice->byBBPreEDIndex = 3; + ed_inx = 3; cr_206 = 0x43; } else if(pDevice->byBBPreEDRSSI <= 67) { //RSSI -67 - if(pDevice->byBBPreEDIndex == 2) break; - pDevice->byBBPreEDIndex = 2; + ed_inx = 2; cr_206 = 0x36; } else if(pDevice->byBBPreEDRSSI <= 68) { //RSSI -68 - if(pDevice->byBBPreEDIndex == 1) break; - pDevice->byBBPreEDIndex = 1; + ed_inx = 1; cr_206 = 0x2d; } else { //RSSI -69, -70, ... - if(pDevice->byBBPreEDIndex == 0) break; - pDevice->byBBPreEDIndex = 0; + ed_inx = 0; cr_206 = 0x24; } break; @@ -1632,105 +1589,89 @@ void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning) case RF_VT3342A0: //RobertYu:20060627, testing table if( bScanning ) { // need Max sensitivity //RSSI -67, -68, ... - pDevice->byBBPreEDIndex = 0; + ed_inx = 0; cr_206 = 0x38; break; } if(pDevice->byBBPreEDRSSI <= 41) { // RSSI 0, -1,-2,....-41 - if(pDevice->byBBPreEDIndex == 20) break; - pDevice->byBBPreEDIndex = 20; + ed_inx = 20; cr_201 = 0xff; } else if(pDevice->byBBPreEDRSSI <= 42) { //RSSI -42 - if(pDevice->byBBPreEDIndex == 19) break; - pDevice->byBBPreEDIndex = 19; + ed_inx = 19; cr_201 = 0x36; } else if(pDevice->byBBPreEDRSSI <= 43) { //RSSI -43 - if(pDevice->byBBPreEDIndex == 18) break; - pDevice->byBBPreEDIndex = 18; + ed_inx = 18; cr_201 = 0x26; } else if(pDevice->byBBPreEDRSSI <= 45) { //RSSI -44, -45 - if(pDevice->byBBPreEDIndex == 17) break; - pDevice->byBBPreEDIndex = 17; + ed_inx = 17; cr_201 = 0x18; } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -46, -47 - if(pDevice->byBBPreEDIndex == 16) break; - pDevice->byBBPreEDIndex = 16; + ed_inx = 16; cr_201 = 0x11; } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49 - if(pDevice->byBBPreEDIndex == 15) break; - pDevice->byBBPreEDIndex = 15; + ed_inx = 15; cr_201 = 0xa; } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51 - if(pDevice->byBBPreEDIndex == 14) break; - pDevice->byBBPreEDIndex = 14; + ed_inx = 14; cr_201 = 0x7; } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53 - if(pDevice->byBBPreEDIndex == 13) break; - pDevice->byBBPreEDIndex = 13; + ed_inx = 13; cr_201 = 0x4; } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55 - if(pDevice->byBBPreEDIndex == 12) break; - pDevice->byBBPreEDIndex = 12; + ed_inx = 12; cr_201 = 0x2; cr_206 = 0xc0; } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56 - if(pDevice->byBBPreEDIndex == 11) break; - pDevice->byBBPreEDIndex = 11; + ed_inx = 11; cr_201 = 0x2; cr_206 = 0x30; } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57 - if(pDevice->byBBPreEDIndex == 10) break; - pDevice->byBBPreEDIndex = 10; + ed_inx = 10; cr_201 = 0x1; cr_206 = 0xb0; } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58 - if(pDevice->byBBPreEDIndex == 9) break; - pDevice->byBBPreEDIndex = 9; + ed_inx = 9; cr_201 = 0x1; cr_206 = 0x70; } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59 - if(pDevice->byBBPreEDIndex == 8) break; - pDevice->byBBPreEDIndex = 8; + ed_inx = 8; cr_201 = 0x1; cr_206 = 0x30; } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60 - if(pDevice->byBBPreEDIndex == 7) break; - pDevice->byBBPreEDIndex = 7; + ed_inx = 7; cr_206 = 0xea; } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61 - if(pDevice->byBBPreEDIndex == 6) break; - pDevice->byBBPreEDIndex = 6; + ed_inx = 6; cr_206 = 0xc0; } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62 - if(pDevice->byBBPreEDIndex == 5) break; - pDevice->byBBPreEDIndex = 5; + ed_inx = 5; cr_206 = 0x9c; } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63 - if(pDevice->byBBPreEDIndex == 4) break; - pDevice->byBBPreEDIndex = 4; + ed_inx = 4; cr_206 = 0x80; } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64 - if(pDevice->byBBPreEDIndex == 3) break; - pDevice->byBBPreEDIndex = 3; + ed_inx = 3; cr_206 = 0x68; } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65 - if(pDevice->byBBPreEDIndex == 2) break; - pDevice->byBBPreEDIndex = 2; + ed_inx = 2; cr_206 = 0x52; } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66 - if(pDevice->byBBPreEDIndex == 1) break; - pDevice->byBBPreEDIndex = 1; + ed_inx = 1; cr_206 = 0x43; } else { //RSSI -67, -68, ... - if(pDevice->byBBPreEDIndex == 0) break; - pDevice->byBBPreEDIndex = 0; + ed_inx = 0; cr_206 = 0x38; } break; } + if (ed_inx == pDevice->byBBPreEDIndex && !bScanning) + return; + + pDevice->byBBPreEDIndex = ed_inx; + dev_dbg(&pDevice->usb->dev, "%s byBBPreEDRSSI %d\n", __func__, pDevice->byBBPreEDRSSI); -- cgit v1.2.3 From 19440266b8876b5b6674162a43063192f12e3518 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 19 May 2014 20:33:12 +0100 Subject: staging: vt6656: clean up BBvUpdatePreEDThreshold Camel case changes pDevice -> priv bScanning -> scanning White space cleanup Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 504 +++++++++++++++++++------------------- drivers/staging/vt6656/baseband.h | 2 +- 2 files changed, 249 insertions(+), 257 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index b308a7d4ddbd..88682c07479a 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -1408,277 +1408,269 @@ void TimerSQ3Tmax3CallBack(struct vnt_private *pDevice) spin_unlock_irq(&pDevice->lock); } -void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning) +void BBvUpdatePreEDThreshold(struct vnt_private *priv, int scanning) { u8 cr_201 = 0x0, cr_206 = 0x0; - u8 ed_inx = pDevice->byBBPreEDIndex; - - switch(pDevice->byRFType) - { - case RF_AL2230: - case RF_AL2230S: - case RF_AIROHA7230: - //RobertYu:20060627, update new table - - if( bScanning ) - { // need Max sensitivity //RSSI -69, -70,.... - ed_inx = 0; - cr_206 = 0x30; - break; - } + u8 ed_inx = priv->byBBPreEDIndex; + + switch (priv->byRFType) { + case RF_AL2230: + case RF_AL2230S: + case RF_AIROHA7230: + if (scanning) { /* Max sensitivity */ + ed_inx = 0; + cr_206 = 0x30; + break; + } - if(pDevice->byBBPreEDRSSI <= 45) { // RSSI 0, -1,-2,....-45 - ed_inx = 20; - cr_201 = 0xff; - } else if(pDevice->byBBPreEDRSSI <= 46) { //RSSI -46 - ed_inx = 19; - cr_201 = 0x1a; - } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -47 - ed_inx = 18; - cr_201 = 0x15; - } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49 - ed_inx = 17; - cr_201 = 0xe; - } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51 - ed_inx = 16; - cr_201 = 0x9; - } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53 - ed_inx = 15; - cr_201 = 0x6; - } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55 - ed_inx = 14; - cr_201 = 0x3; - } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56 - ed_inx = 13; - cr_201 = 0x2; - cr_206 = 0xa0; - } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57 - ed_inx = 12; - cr_201 = 0x2; - cr_206 = 0x20; - } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58 - ed_inx = 11; - cr_201 = 0x1; - cr_206 = 0xa0; - } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59 - ed_inx = 10; - cr_201 = 0x1; - cr_206 = 0x54; - } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60 - ed_inx = 9; - cr_201 = 0x1; - cr_206 = 0x18; - } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61 - ed_inx = 8; - cr_206 = 0xe3; - } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62 - ed_inx = 7; - cr_206 = 0xb9; - } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63 - ed_inx = 6; - cr_206 = 0x93; - } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64 - ed_inx = 5; - cr_206 = 0x79; - } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65 - ed_inx = 4; - cr_206 = 0x62; - } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66 - ed_inx = 3; - cr_206 = 0x51; - } else if(pDevice->byBBPreEDRSSI <= 67) { //RSSI -67 - ed_inx = 2; - cr_206 = 0x43; - } else if(pDevice->byBBPreEDRSSI <= 68) { //RSSI -68 - ed_inx = 1; - cr_206 = 0x36; - } else { //RSSI -69, -70,.... - ed_inx = 0; - cr_206 = 0x30; - } - break; + if (priv->byBBPreEDRSSI <= 45) { + ed_inx = 20; + cr_201 = 0xff; + } else if (priv->byBBPreEDRSSI <= 46) { + ed_inx = 19; + cr_201 = 0x1a; + } else if (priv->byBBPreEDRSSI <= 47) { + ed_inx = 18; + cr_201 = 0x15; + } else if (priv->byBBPreEDRSSI <= 49) { + ed_inx = 17; + cr_201 = 0xe; + } else if (priv->byBBPreEDRSSI <= 51) { + ed_inx = 16; + cr_201 = 0x9; + } else if (priv->byBBPreEDRSSI <= 53) { + ed_inx = 15; + cr_201 = 0x6; + } else if (priv->byBBPreEDRSSI <= 55) { + ed_inx = 14; + cr_201 = 0x3; + } else if (priv->byBBPreEDRSSI <= 56) { + ed_inx = 13; + cr_201 = 0x2; + cr_206 = 0xa0; + } else if (priv->byBBPreEDRSSI <= 57) { + ed_inx = 12; + cr_201 = 0x2; + cr_206 = 0x20; + } else if (priv->byBBPreEDRSSI <= 58) { + ed_inx = 11; + cr_201 = 0x1; + cr_206 = 0xa0; + } else if (priv->byBBPreEDRSSI <= 59) { + ed_inx = 10; + cr_201 = 0x1; + cr_206 = 0x54; + } else if (priv->byBBPreEDRSSI <= 60) { + ed_inx = 9; + cr_201 = 0x1; + cr_206 = 0x18; + } else if (priv->byBBPreEDRSSI <= 61) { + ed_inx = 8; + cr_206 = 0xe3; + } else if (priv->byBBPreEDRSSI <= 62) { + ed_inx = 7; + cr_206 = 0xb9; + } else if (priv->byBBPreEDRSSI <= 63) { + ed_inx = 6; + cr_206 = 0x93; + } else if (priv->byBBPreEDRSSI <= 64) { + ed_inx = 5; + cr_206 = 0x79; + } else if (priv->byBBPreEDRSSI <= 65) { + ed_inx = 4; + cr_206 = 0x62; + } else if (priv->byBBPreEDRSSI <= 66) { + ed_inx = 3; + cr_206 = 0x51; + } else if (priv->byBBPreEDRSSI <= 67) { + ed_inx = 2; + cr_206 = 0x43; + } else if (priv->byBBPreEDRSSI <= 68) { + ed_inx = 1; + cr_206 = 0x36; + } else { + ed_inx = 0; + cr_206 = 0x30; + } + break; - case RF_VT3226: - case RF_VT3226D0: - //RobertYu:20060627, update new table + case RF_VT3226: + case RF_VT3226D0: + if (scanning) { /* Max sensitivity */ + ed_inx = 0; + cr_206 = 0x24; + break; + } - if( bScanning ) - { // need Max sensitivity //RSSI -69, -70, ... - ed_inx = 0; - cr_206 = 0x24; - break; - } + if (priv->byBBPreEDRSSI <= 41) { + ed_inx = 22; + cr_201 = 0xff; + } else if (priv->byBBPreEDRSSI <= 42) { + ed_inx = 21; + cr_201 = 0x36; + } else if (priv->byBBPreEDRSSI <= 43) { + ed_inx = 20; + cr_201 = 0x26; + } else if (priv->byBBPreEDRSSI <= 45) { + ed_inx = 19; + cr_201 = 0x18; + } else if (priv->byBBPreEDRSSI <= 47) { + ed_inx = 18; + cr_201 = 0x11; + } else if (priv->byBBPreEDRSSI <= 49) { + ed_inx = 17; + cr_201 = 0xa; + } else if (priv->byBBPreEDRSSI <= 51) { + ed_inx = 16; + cr_201 = 0x7; + } else if (priv->byBBPreEDRSSI <= 53) { + ed_inx = 15; + cr_201 = 0x4; + } else if (priv->byBBPreEDRSSI <= 55) { + ed_inx = 14; + cr_201 = 0x2; + cr_206 = 0xc0; + } else if (priv->byBBPreEDRSSI <= 56) { + ed_inx = 13; + cr_201 = 0x2; + cr_206 = 0x30; + } else if (priv->byBBPreEDRSSI <= 57) { + ed_inx = 12; + cr_201 = 0x1; + cr_206 = 0xb0; + } else if (priv->byBBPreEDRSSI <= 58) { + ed_inx = 11; + cr_201 = 0x1; + cr_206 = 0x70; + } else if (priv->byBBPreEDRSSI <= 59) { + ed_inx = 10; + cr_201 = 0x1; + cr_206 = 0x30; + } else if (priv->byBBPreEDRSSI <= 60) { + ed_inx = 9; + cr_206 = 0xea; + } else if (priv->byBBPreEDRSSI <= 61) { + ed_inx = 8; + cr_206 = 0xc0; + } else if (priv->byBBPreEDRSSI <= 62) { + ed_inx = 7; + cr_206 = 0x9c; + } else if (priv->byBBPreEDRSSI <= 63) { + ed_inx = 6; + cr_206 = 0x80; + } else if (priv->byBBPreEDRSSI <= 64) { + ed_inx = 5; + cr_206 = 0x68; + } else if (priv->byBBPreEDRSSI <= 65) { + ed_inx = 4; + cr_206 = 0x52; + } else if (priv->byBBPreEDRSSI <= 66) { + ed_inx = 3; + cr_206 = 0x43; + } else if (priv->byBBPreEDRSSI <= 67) { + ed_inx = 2; + cr_206 = 0x36; + } else if (priv->byBBPreEDRSSI <= 68) { + ed_inx = 1; + cr_206 = 0x2d; + } else { + ed_inx = 0; + cr_206 = 0x24; + } + break; - if(pDevice->byBBPreEDRSSI <= 41) { // RSSI 0, -1,-2,....-41 - ed_inx = 22; - cr_201 = 0xff; - } else if(pDevice->byBBPreEDRSSI <= 42) { //RSSI -42 - ed_inx = 21; - cr_201 = 0x36; - } else if(pDevice->byBBPreEDRSSI <= 43) { //RSSI -43 - ed_inx = 20; - cr_201 = 0x26; - } else if(pDevice->byBBPreEDRSSI <= 45) { //RSSI -44, -45 - ed_inx = 19; - cr_201 = 0x18; - } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -46, -47 - ed_inx = 18; - cr_201 = 0x11; - } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49 - ed_inx = 17; - cr_201 = 0xa; - } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51 - ed_inx = 16; - cr_201 = 0x7; - } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53 - ed_inx = 15; - cr_201 = 0x4; - } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55 - ed_inx = 14; - cr_201 = 0x2; - cr_206 = 0xc0; - } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56 - ed_inx = 13; - cr_201 = 0x2; - cr_206 = 0x30; - } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57 - ed_inx = 12; - cr_201 = 0x1; - cr_206 = 0xb0; - } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58 - ed_inx = 11; - cr_201 = 0x1; - cr_206 = 0x70; - } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59 - ed_inx = 10; - cr_201 = 0x1; - cr_206 = 0x30; - } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60 - ed_inx = 9; - cr_206 = 0xea; - } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61 - ed_inx = 8; - cr_206 = 0xc0; - } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62 - ed_inx = 7; - cr_206 = 0x9c; - } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63 - ed_inx = 6; - cr_206 = 0x80; - } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64 - ed_inx = 5; - cr_206 = 0x68; - } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65 - ed_inx = 4; - cr_206 = 0x52; - } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66 - ed_inx = 3; - cr_206 = 0x43; - } else if(pDevice->byBBPreEDRSSI <= 67) { //RSSI -67 - ed_inx = 2; - cr_206 = 0x36; - } else if(pDevice->byBBPreEDRSSI <= 68) { //RSSI -68 - ed_inx = 1; - cr_206 = 0x2d; - } else { //RSSI -69, -70, ... - ed_inx = 0; - cr_206 = 0x24; - } - break; - - case RF_VT3342A0: //RobertYu:20060627, testing table - if( bScanning ) - { // need Max sensitivity //RSSI -67, -68, ... - ed_inx = 0; - cr_206 = 0x38; - break; - } + case RF_VT3342A0: + if (scanning) { /* need Max sensitivity */ + ed_inx = 0; + cr_206 = 0x38; + break; + } - if(pDevice->byBBPreEDRSSI <= 41) { // RSSI 0, -1,-2,....-41 - ed_inx = 20; - cr_201 = 0xff; - } else if(pDevice->byBBPreEDRSSI <= 42) { //RSSI -42 - ed_inx = 19; - cr_201 = 0x36; - } else if(pDevice->byBBPreEDRSSI <= 43) { //RSSI -43 - ed_inx = 18; - cr_201 = 0x26; - } else if(pDevice->byBBPreEDRSSI <= 45) { //RSSI -44, -45 - ed_inx = 17; - cr_201 = 0x18; - } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -46, -47 - ed_inx = 16; - cr_201 = 0x11; - } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49 - ed_inx = 15; - cr_201 = 0xa; - } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51 - ed_inx = 14; - cr_201 = 0x7; - } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53 - ed_inx = 13; - cr_201 = 0x4; - } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55 - ed_inx = 12; - cr_201 = 0x2; - cr_206 = 0xc0; - } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56 - ed_inx = 11; - cr_201 = 0x2; - cr_206 = 0x30; - } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57 - ed_inx = 10; - cr_201 = 0x1; - cr_206 = 0xb0; - } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58 - ed_inx = 9; - cr_201 = 0x1; - cr_206 = 0x70; - } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59 - ed_inx = 8; - cr_201 = 0x1; - cr_206 = 0x30; - } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60 - ed_inx = 7; - cr_206 = 0xea; - } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61 - ed_inx = 6; - cr_206 = 0xc0; - } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62 - ed_inx = 5; - cr_206 = 0x9c; - } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63 - ed_inx = 4; - cr_206 = 0x80; - } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64 - ed_inx = 3; - cr_206 = 0x68; - } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65 - ed_inx = 2; - cr_206 = 0x52; - } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66 - ed_inx = 1; - cr_206 = 0x43; - } else { //RSSI -67, -68, ... - ed_inx = 0; - cr_206 = 0x38; - } - break; + if (priv->byBBPreEDRSSI <= 41) { + ed_inx = 20; + cr_201 = 0xff; + } else if (priv->byBBPreEDRSSI <= 42) { + ed_inx = 19; + cr_201 = 0x36; + } else if (priv->byBBPreEDRSSI <= 43) { + ed_inx = 18; + cr_201 = 0x26; + } else if (priv->byBBPreEDRSSI <= 45) { + ed_inx = 17; + cr_201 = 0x18; + } else if (priv->byBBPreEDRSSI <= 47) { + ed_inx = 16; + cr_201 = 0x11; + } else if (priv->byBBPreEDRSSI <= 49) { + ed_inx = 15; + cr_201 = 0xa; + } else if (priv->byBBPreEDRSSI <= 51) { + ed_inx = 14; + cr_201 = 0x7; + } else if (priv->byBBPreEDRSSI <= 53) { + ed_inx = 13; + cr_201 = 0x4; + } else if (priv->byBBPreEDRSSI <= 55) { + ed_inx = 12; + cr_201 = 0x2; + cr_206 = 0xc0; + } else if (priv->byBBPreEDRSSI <= 56) { + ed_inx = 11; + cr_201 = 0x2; + cr_206 = 0x30; + } else if (priv->byBBPreEDRSSI <= 57) { + ed_inx = 10; + cr_201 = 0x1; + cr_206 = 0xb0; + } else if (priv->byBBPreEDRSSI <= 58) { + ed_inx = 9; + cr_201 = 0x1; + cr_206 = 0x70; + } else if (priv->byBBPreEDRSSI <= 59) { + ed_inx = 8; + cr_201 = 0x1; + cr_206 = 0x30; + } else if (priv->byBBPreEDRSSI <= 60) { + ed_inx = 7; + cr_206 = 0xea; + } else if (priv->byBBPreEDRSSI <= 61) { + ed_inx = 6; + cr_206 = 0xc0; + } else if (priv->byBBPreEDRSSI <= 62) { + ed_inx = 5; + cr_206 = 0x9c; + } else if (priv->byBBPreEDRSSI <= 63) { + ed_inx = 4; + cr_206 = 0x80; + } else if (priv->byBBPreEDRSSI <= 64) { + ed_inx = 3; + cr_206 = 0x68; + } else if (priv->byBBPreEDRSSI <= 65) { + ed_inx = 2; + cr_206 = 0x52; + } else if (priv->byBBPreEDRSSI <= 66) { + ed_inx = 1; + cr_206 = 0x43; + } else { + ed_inx = 0; + cr_206 = 0x38; + } + break; - } + } - if (ed_inx == pDevice->byBBPreEDIndex && !bScanning) + if (ed_inx == priv->byBBPreEDIndex && !scanning) return; - pDevice->byBBPreEDIndex = ed_inx; + priv->byBBPreEDIndex = ed_inx; - dev_dbg(&pDevice->usb->dev, "%s byBBPreEDRSSI %d\n", - __func__, pDevice->byBBPreEDRSSI); + dev_dbg(&priv->usb->dev, "%s byBBPreEDRSSI %d\n", + __func__, priv->byBBPreEDRSSI); if (!cr_201 && !cr_206) return; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xc9, cr_201); - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xce, cr_206); + ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0xc9, cr_201); + ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0xce, cr_206); } diff --git a/drivers/staging/vt6656/baseband.h b/drivers/staging/vt6656/baseband.h index 005b94c9af24..eda0d8aa6c74 100644 --- a/drivers/staging/vt6656/baseband.h +++ b/drivers/staging/vt6656/baseband.h @@ -107,6 +107,6 @@ void BBvSetAntennaMode(struct vnt_private *, u8 byAntennaMode); int BBbVT3184Init(struct vnt_private *); void BBvSetDeepSleep(struct vnt_private *); void BBvExitDeepSleep(struct vnt_private *); -void BBvUpdatePreEDThreshold(struct vnt_private *, int bScanning); +void BBvUpdatePreEDThreshold(struct vnt_private *, int scanning); #endif /* __BASEBAND_H__ */ -- cgit v1.2.3 From 85dfd522f885ee4ec0b0b4efa1fdd9c650e243be Mon Sep 17 00:00:00 2001 From: Jake Edge Date: Mon, 19 May 2014 17:48:24 -0600 Subject: staging/skein: rename files and clean up directory structure Clean up file names and locations. Get rid of include/ directory and move those up to the top-level. Rename files to get rid of upper case. Remove skeinBlockNo3F.c as it was unused (temporary file or something?). Signed-off-by: Jake Edge Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/Makefile | 12 +- drivers/staging/skein/TODO | 1 - drivers/staging/skein/include/skein.h | 346 -- drivers/staging/skein/include/skeinApi.h | 230 -- drivers/staging/skein/include/skein_block.h | 22 - drivers/staging/skein/include/skein_iv.h | 186 - drivers/staging/skein/include/threefishApi.h | 170 - drivers/staging/skein/skein.c | 6 +- drivers/staging/skein/skein.h | 346 ++ drivers/staging/skein/skeinApi.c | 239 -- drivers/staging/skein/skeinBlockNo3F.c | 175 - drivers/staging/skein/skein_api.c | 239 ++ drivers/staging/skein/skein_api.h | 230 ++ drivers/staging/skein/skein_block.c | 2 +- drivers/staging/skein/skein_block.h | 22 + drivers/staging/skein/skein_iv.h | 186 + drivers/staging/skein/threefish1024Block.c | 4902 -------------------------- drivers/staging/skein/threefish256Block.c | 1139 ------ drivers/staging/skein/threefish512Block.c | 2225 ------------ drivers/staging/skein/threefishApi.c | 79 - drivers/staging/skein/threefish_1024_block.c | 4902 ++++++++++++++++++++++++++ drivers/staging/skein/threefish_256_block.c | 1139 ++++++ drivers/staging/skein/threefish_512_block.c | 2225 ++++++++++++ drivers/staging/skein/threefish_api.c | 77 + drivers/staging/skein/threefish_api.h | 170 + 25 files changed, 9545 insertions(+), 9725 deletions(-) delete mode 100644 drivers/staging/skein/include/skein.h delete mode 100644 drivers/staging/skein/include/skeinApi.h delete mode 100644 drivers/staging/skein/include/skein_block.h delete mode 100644 drivers/staging/skein/include/skein_iv.h delete mode 100644 drivers/staging/skein/include/threefishApi.h create mode 100644 drivers/staging/skein/skein.h delete mode 100644 drivers/staging/skein/skeinApi.c delete mode 100644 drivers/staging/skein/skeinBlockNo3F.c create mode 100644 drivers/staging/skein/skein_api.c create mode 100644 drivers/staging/skein/skein_api.h create mode 100644 drivers/staging/skein/skein_block.h create mode 100644 drivers/staging/skein/skein_iv.h delete mode 100644 drivers/staging/skein/threefish1024Block.c delete mode 100644 drivers/staging/skein/threefish256Block.c delete mode 100644 drivers/staging/skein/threefish512Block.c delete mode 100644 drivers/staging/skein/threefishApi.c create mode 100644 drivers/staging/skein/threefish_1024_block.c create mode 100644 drivers/staging/skein/threefish_256_block.c create mode 100644 drivers/staging/skein/threefish_512_block.c create mode 100644 drivers/staging/skein/threefish_api.c create mode 100644 drivers/staging/skein/threefish_api.h diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile index 2bb386e1e58c..395454cea433 100644 --- a/drivers/staging/skein/Makefile +++ b/drivers/staging/skein/Makefile @@ -1,13 +1,11 @@ # # Makefile for the skein secure hash algorithm # -subdir-ccflags-y := -I$(src)/include/ - obj-$(CONFIG_CRYPTO_SKEIN) += skein.o \ - skeinApi.o \ + skein_api.o \ skein_block.o -obj-$(CONFIG_CRYPTO_THREEFISH) += threefish1024Block.o \ - threefish256Block.o \ - threefish512Block.o \ - threefishApi.o +obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_1024_block.o \ + threefish_256_block.o \ + threefish_512_block.o \ + threefish_api.o diff --git a/drivers/staging/skein/TODO b/drivers/staging/skein/TODO index 88a6e81145e1..cd3508dd9089 100644 --- a/drivers/staging/skein/TODO +++ b/drivers/staging/skein/TODO @@ -1,6 +1,5 @@ skein/threefish TODO - - rename files - move macros into appropriate header files - add / pass test vectors - module support diff --git a/drivers/staging/skein/include/skein.h b/drivers/staging/skein/include/skein.h deleted file mode 100644 index 2c87ff74aaea..000000000000 --- a/drivers/staging/skein/include/skein.h +++ /dev/null @@ -1,346 +0,0 @@ -#ifndef _SKEIN_H_ -#define _SKEIN_H_ 1 -/************************************************************************** -** -** Interface declarations and internal definitions for Skein hashing. -** -** Source code author: Doug Whiting, 2008. -** -** This algorithm and source code is released to the public domain. -** -*************************************************************************** -** -** The following compile-time switches may be defined to control some -** tradeoffs between speed, code size, error checking, and security. -** -** The "default" note explains what happens when the switch is not defined. -** -** SKEIN_DEBUG -- make callouts from inside Skein code -** to examine/display intermediate values. -** [default: no callouts (no overhead)] -** -** SKEIN_ERR_CHECK -- how error checking is handled inside Skein -** code. If not defined, most error checking -** is disabled (for performance). Otherwise, -** the switch value is interpreted as: -** 0: use assert() to flag errors -** 1: return SKEIN_FAIL to flag errors -** -***************************************************************************/ - -#ifndef rotl_64 -#define rotl_64(x, N) (((x) << (N)) | ((x) >> (64-(N)))) -#endif - -/* below two prototype assume we are handed aligned data */ -#define skein_put64_lsb_first(dst08, src64, b_cnt) memcpy(dst08, src64, b_cnt) -#define skein_get64_lsb_first(dst64, src08, w_cnt) \ - memcpy(dst64, src08, 8*(w_cnt)) -#define skein_swap64(w64) (w64) - -enum { - SKEIN_SUCCESS = 0, /* return codes from Skein calls */ - SKEIN_FAIL = 1, - SKEIN_BAD_HASHLEN = 2 -}; - -#define SKEIN_MODIFIER_WORDS (2) /* number of modifier (tweak) words */ - -#define SKEIN_256_STATE_WORDS (4) -#define SKEIN_512_STATE_WORDS (8) -#define SKEIN_1024_STATE_WORDS (16) -#define SKEIN_MAX_STATE_WORDS (16) - -#define SKEIN_256_STATE_BYTES (8*SKEIN_256_STATE_WORDS) -#define SKEIN_512_STATE_BYTES (8*SKEIN_512_STATE_WORDS) -#define SKEIN_1024_STATE_BYTES (8*SKEIN_1024_STATE_WORDS) - -#define SKEIN_256_STATE_BITS (64*SKEIN_256_STATE_WORDS) -#define SKEIN_512_STATE_BITS (64*SKEIN_512_STATE_WORDS) -#define SKEIN_1024_STATE_BITS (64*SKEIN_1024_STATE_WORDS) - -#define SKEIN_256_BLOCK_BYTES (8*SKEIN_256_STATE_WORDS) -#define SKEIN_512_BLOCK_BYTES (8*SKEIN_512_STATE_WORDS) -#define SKEIN_1024_BLOCK_BYTES (8*SKEIN_1024_STATE_WORDS) - -struct skein_ctx_hdr { - size_t hash_bit_len; /* size of hash result, in bits */ - size_t b_cnt; /* current byte count in buffer b[] */ - u64 T[SKEIN_MODIFIER_WORDS]; /* tweak: T[0]=byte cnt, T[1]=flags */ -}; - -struct skein_256_ctx { /* 256-bit Skein hash context structure */ - struct skein_ctx_hdr h; /* common header context variables */ - u64 X[SKEIN_256_STATE_WORDS]; /* chaining variables */ - u8 b[SKEIN_256_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ -}; - -struct skein_512_ctx { /* 512-bit Skein hash context structure */ - struct skein_ctx_hdr h; /* common header context variables */ - u64 X[SKEIN_512_STATE_WORDS]; /* chaining variables */ - u8 b[SKEIN_512_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ -}; - -struct skein_1024_ctx { /* 1024-bit Skein hash context structure */ - struct skein_ctx_hdr h; /* common header context variables */ - u64 X[SKEIN_1024_STATE_WORDS]; /* chaining variables */ - u8 b[SKEIN_1024_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ -}; - -/* Skein APIs for (incremental) "straight hashing" */ -int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len); -int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len); -int skein_1024_init(struct skein_1024_ctx *ctx, size_t hash_bit_len); - -int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg, - size_t msg_byte_cnt); -int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg, - size_t msg_byte_cnt); -int skein_1024_update(struct skein_1024_ctx *ctx, const u8 *msg, - size_t msg_byte_cnt); - -int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val); -int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val); -int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val); - -/* -** Skein APIs for "extended" initialization: MAC keys, tree hashing. -** After an init_ext() call, just use update/final calls as with init(). -** -** Notes: Same parameters as _init() calls, plus tree_info/key/key_bytes. -** When key_bytes == 0 and tree_info == SKEIN_SEQUENTIAL, -** the results of init_ext() are identical to calling init(). -** The function init() may be called once to "precompute" the IV for -** a given hash_bit_len value, then by saving a copy of the context -** the IV computation may be avoided in later calls. -** Similarly, the function init_ext() may be called once per MAC key -** to precompute the MAC IV, then a copy of the context saved and -** reused for each new MAC computation. -**/ -int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hash_bit_len, - u64 tree_info, const u8 *key, size_t key_bytes); -int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hash_bit_len, - u64 tree_info, const u8 *key, size_t key_bytes); -int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t hash_bit_len, - u64 tree_info, const u8 *key, size_t key_bytes); - -/* -** Skein APIs for MAC and tree hash: -** final_pad: pad, do final block, but no OUTPUT type -** output: do just the output stage -*/ -int skein_256_final_pad(struct skein_256_ctx *ctx, u8 *hash_val); -int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hash_val); -int skein_1024_final_pad(struct skein_1024_ctx *ctx, u8 *hash_val); - -#ifndef SKEIN_TREE_HASH -#define SKEIN_TREE_HASH (1) -#endif -#if SKEIN_TREE_HASH -int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val); -int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val); -int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); -#endif - -/***************************************************************** -** "Internal" Skein definitions -** -- not needed for sequential hashing API, but will be -** helpful for other uses of Skein (e.g., tree hash mode). -** -- included here so that they can be shared between -** reference and optimized code. -******************************************************************/ - -/* tweak word T[1]: bit field starting positions */ -#define SKEIN_T1_BIT(BIT) ((BIT) - 64) /* second word */ - -#define SKEIN_T1_POS_TREE_LVL SKEIN_T1_BIT(112) /* 112..118 hash tree level */ -#define SKEIN_T1_POS_BIT_PAD SKEIN_T1_BIT(119) /* 119 part. final in byte */ -#define SKEIN_T1_POS_BLK_TYPE SKEIN_T1_BIT(120) /* 120..125 type field `*/ -#define SKEIN_T1_POS_FIRST SKEIN_T1_BIT(126) /* 126 first blk flag */ -#define SKEIN_T1_POS_FINAL SKEIN_T1_BIT(127) /* 127 final blk flag */ - -/* tweak word T[1]: flag bit definition(s) */ -#define SKEIN_T1_FLAG_FIRST (((u64) 1) << SKEIN_T1_POS_FIRST) -#define SKEIN_T1_FLAG_FINAL (((u64) 1) << SKEIN_T1_POS_FINAL) -#define SKEIN_T1_FLAG_BIT_PAD (((u64) 1) << SKEIN_T1_POS_BIT_PAD) - -/* tweak word T[1]: tree level bit field mask */ -#define SKEIN_T1_TREE_LVL_MASK (((u64)0x7F) << SKEIN_T1_POS_TREE_LVL) -#define SKEIN_T1_TREE_LEVEL(n) (((u64) (n)) << SKEIN_T1_POS_TREE_LVL) - -/* tweak word T[1]: block type field */ -#define SKEIN_BLK_TYPE_KEY (0) /* key, for MAC and KDF */ -#define SKEIN_BLK_TYPE_CFG (4) /* configuration block */ -#define SKEIN_BLK_TYPE_PERS (8) /* personalization string */ -#define SKEIN_BLK_TYPE_PK (12) /* pubkey (for digital sigs) */ -#define SKEIN_BLK_TYPE_KDF (16) /* key identifier for KDF */ -#define SKEIN_BLK_TYPE_NONCE (20) /* nonce for PRNG */ -#define SKEIN_BLK_TYPE_MSG (48) /* message processing */ -#define SKEIN_BLK_TYPE_OUT (63) /* output stage */ -#define SKEIN_BLK_TYPE_MASK (63) /* bit field mask */ - -#define SKEIN_T1_BLK_TYPE(T) (((u64) (SKEIN_BLK_TYPE_##T)) << \ - SKEIN_T1_POS_BLK_TYPE) -#define SKEIN_T1_BLK_TYPE_KEY SKEIN_T1_BLK_TYPE(KEY) /* for MAC and KDF */ -#define SKEIN_T1_BLK_TYPE_CFG SKEIN_T1_BLK_TYPE(CFG) /* config block */ -#define SKEIN_T1_BLK_TYPE_PERS SKEIN_T1_BLK_TYPE(PERS) /* personalization */ -#define SKEIN_T1_BLK_TYPE_PK SKEIN_T1_BLK_TYPE(PK) /* pubkey (for sigs) */ -#define SKEIN_T1_BLK_TYPE_KDF SKEIN_T1_BLK_TYPE(KDF) /* key ident for KDF */ -#define SKEIN_T1_BLK_TYPE_NONCE SKEIN_T1_BLK_TYPE(NONCE)/* nonce for PRNG */ -#define SKEIN_T1_BLK_TYPE_MSG SKEIN_T1_BLK_TYPE(MSG) /* message processing */ -#define SKEIN_T1_BLK_TYPE_OUT SKEIN_T1_BLK_TYPE(OUT) /* output stage */ -#define SKEIN_T1_BLK_TYPE_MASK SKEIN_T1_BLK_TYPE(MASK) /* field bit mask */ - -#define SKEIN_T1_BLK_TYPE_CFG_FINAL (SKEIN_T1_BLK_TYPE_CFG | \ - SKEIN_T1_FLAG_FINAL) -#define SKEIN_T1_BLK_TYPE_OUT_FINAL (SKEIN_T1_BLK_TYPE_OUT | \ - SKEIN_T1_FLAG_FINAL) - -#define SKEIN_VERSION (1) - -#ifndef SKEIN_ID_STRING_LE /* allow compile-time personalization */ -#define SKEIN_ID_STRING_LE (0x33414853) /* "SHA3" (little-endian)*/ -#endif - -#define SKEIN_MK_64(hi32, lo32) ((lo32) + (((u64) (hi32)) << 32)) -#define SKEIN_SCHEMA_VER SKEIN_MK_64(SKEIN_VERSION, SKEIN_ID_STRING_LE) -#define SKEIN_KS_PARITY SKEIN_MK_64(0x1BD11BDA, 0xA9FC1A22) - -#define SKEIN_CFG_STR_LEN (4*8) - -/* bit field definitions in config block tree_info word */ -#define SKEIN_CFG_TREE_LEAF_SIZE_POS (0) -#define SKEIN_CFG_TREE_NODE_SIZE_POS (8) -#define SKEIN_CFG_TREE_MAX_LEVEL_POS (16) - -#define SKEIN_CFG_TREE_LEAF_SIZE_MSK (((u64)0xFF) << \ - SKEIN_CFG_TREE_LEAF_SIZE_POS) -#define SKEIN_CFG_TREE_NODE_SIZE_MSK (((u64)0xFF) << \ - SKEIN_CFG_TREE_NODE_SIZE_POS) -#define SKEIN_CFG_TREE_MAX_LEVEL_MSK (((u64)0xFF) << \ - SKEIN_CFG_TREE_MAX_LEVEL_POS) - -#define SKEIN_CFG_TREE_INFO(leaf, node, max_lvl) \ - ((((u64)(leaf)) << SKEIN_CFG_TREE_LEAF_SIZE_POS) | \ - (((u64)(node)) << SKEIN_CFG_TREE_NODE_SIZE_POS) | \ - (((u64)(max_lvl)) << SKEIN_CFG_TREE_MAX_LEVEL_POS)) - -/* use as tree_info in InitExt() call for sequential processing */ -#define SKEIN_CFG_TREE_INFO_SEQUENTIAL SKEIN_CFG_TREE_INFO(0, 0, 0) - -/* -** Skein macros for getting/setting tweak words, etc. -** These are useful for partial input bytes, hash tree init/update, etc. -**/ -#define skein_get_tweak(ctx_ptr, TWK_NUM) ((ctx_ptr)->h.T[TWK_NUM]) -#define skein_set_tweak(ctx_ptr, TWK_NUM, t_val) { \ - (ctx_ptr)->h.T[TWK_NUM] = (t_val); \ - } - -#define skein_get_T0(ctx_ptr) skein_get_tweak(ctx_ptr, 0) -#define skein_get_T1(ctx_ptr) skein_get_tweak(ctx_ptr, 1) -#define skein_set_T0(ctx_ptr, T0) skein_set_tweak(ctx_ptr, 0, T0) -#define skein_set_T1(ctx_ptr, T1) skein_set_tweak(ctx_ptr, 1, T1) - -/* set both tweak words at once */ -#define skein_set_T0_T1(ctx_ptr, T0, T1) \ - { \ - skein_set_T0(ctx_ptr, (T0)); \ - skein_set_T1(ctx_ptr, (T1)); \ - } - -#define skein_set_type(ctx_ptr, BLK_TYPE) \ - skein_set_T1(ctx_ptr, SKEIN_T1_BLK_TYPE_##BLK_TYPE) - -/* - * setup for starting with a new type: - * h.T[0]=0; h.T[1] = NEW_TYPE; h.b_cnt=0; - */ -#define skein_start_new_type(ctx_ptr, BLK_TYPE) { \ - skein_set_T0_T1(ctx_ptr, 0, SKEIN_T1_FLAG_FIRST | \ - SKEIN_T1_BLK_TYPE_##BLK_TYPE); \ - (ctx_ptr)->h.b_cnt = 0; \ - } - -#define skein_clear_first_flag(hdr) { \ - (hdr).T[1] &= ~SKEIN_T1_FLAG_FIRST; \ - } -#define skein_set_bit_pad_flag(hdr) { \ - (hdr).T[1] |= SKEIN_T1_FLAG_BIT_PAD; \ - } - -#define skein_set_tree_level(hdr, height) { \ - (hdr).T[1] |= SKEIN_T1_TREE_LEVEL(height); \ - } - -/***************************************************************** -** "Internal" Skein definitions for debugging and error checking -******************************************************************/ -#ifdef SKEIN_DEBUG /* examine/display intermediate values? */ -#include "skein_debug.h" -#else /* default is no callouts */ -#define skein_show_block(bits, ctx, X, blk_ptr, w_ptr, ks_event_ptr, ks_odd_ptr) -#define skein_show_round(bits, ctx, r, X) -#define skein_show_r_ptr(bits, ctx, r, X_ptr) -#define skein_show_final(bits, ctx, cnt, out_ptr) -#define skein_show_key(bits, ctx, key, key_bytes) -#endif - -/* ignore all asserts, for performance */ -#define skein_assert_ret(x, ret_code) -#define skein_assert(x) - -/***************************************************************** -** Skein block function constants (shared across Ref and Opt code) -******************************************************************/ -enum { - /* SKEIN_256 round rotation constants */ - R_256_0_0 = 14, R_256_0_1 = 16, - R_256_1_0 = 52, R_256_1_1 = 57, - R_256_2_0 = 23, R_256_2_1 = 40, - R_256_3_0 = 5, R_256_3_1 = 37, - R_256_4_0 = 25, R_256_4_1 = 33, - R_256_5_0 = 46, R_256_5_1 = 12, - R_256_6_0 = 58, R_256_6_1 = 22, - R_256_7_0 = 32, R_256_7_1 = 32, - - /* SKEIN_512 round rotation constants */ - R_512_0_0 = 46, R_512_0_1 = 36, R_512_0_2 = 19, R_512_0_3 = 37, - R_512_1_0 = 33, R_512_1_1 = 27, R_512_1_2 = 14, R_512_1_3 = 42, - R_512_2_0 = 17, R_512_2_1 = 49, R_512_2_2 = 36, R_512_2_3 = 39, - R_512_3_0 = 44, R_512_3_1 = 9, R_512_3_2 = 54, R_512_3_3 = 56, - R_512_4_0 = 39, R_512_4_1 = 30, R_512_4_2 = 34, R_512_4_3 = 24, - R_512_5_0 = 13, R_512_5_1 = 50, R_512_5_2 = 10, R_512_5_3 = 17, - R_512_6_0 = 25, R_512_6_1 = 29, R_512_6_2 = 39, R_512_6_3 = 43, - R_512_7_0 = 8, R_512_7_1 = 35, R_512_7_2 = 56, R_512_7_3 = 22, - - /* SKEIN_1024 round rotation constants */ - R1024_0_0 = 24, R1024_0_1 = 13, R1024_0_2 = 8, R1024_0_3 = 47, - R1024_0_4 = 8, R1024_0_5 = 17, R1024_0_6 = 22, R1024_0_7 = 37, - R1024_1_0 = 38, R1024_1_1 = 19, R1024_1_2 = 10, R1024_1_3 = 55, - R1024_1_4 = 49, R1024_1_5 = 18, R1024_1_6 = 23, R1024_1_7 = 52, - R1024_2_0 = 33, R1024_2_1 = 4, R1024_2_2 = 51, R1024_2_3 = 13, - R1024_2_4 = 34, R1024_2_5 = 41, R1024_2_6 = 59, R1024_2_7 = 17, - R1024_3_0 = 5, R1024_3_1 = 20, R1024_3_2 = 48, R1024_3_3 = 41, - R1024_3_4 = 47, R1024_3_5 = 28, R1024_3_6 = 16, R1024_3_7 = 25, - R1024_4_0 = 41, R1024_4_1 = 9, R1024_4_2 = 37, R1024_4_3 = 31, - R1024_4_4 = 12, R1024_4_5 = 47, R1024_4_6 = 44, R1024_4_7 = 30, - R1024_5_0 = 16, R1024_5_1 = 34, R1024_5_2 = 56, R1024_5_3 = 51, - R1024_5_4 = 4, R1024_5_5 = 53, R1024_5_6 = 42, R1024_5_7 = 41, - R1024_6_0 = 31, R1024_6_1 = 44, R1024_6_2 = 47, R1024_6_3 = 46, - R1024_6_4 = 19, R1024_6_5 = 42, R1024_6_6 = 44, R1024_6_7 = 25, - R1024_7_0 = 9, R1024_7_1 = 48, R1024_7_2 = 35, R1024_7_3 = 52, - R1024_7_4 = 23, R1024_7_5 = 31, R1024_7_6 = 37, R1024_7_7 = 20 -}; - -#ifndef SKEIN_ROUNDS -#define SKEIN_256_ROUNDS_TOTAL (72) /* # rounds for diff block sizes */ -#define SKEIN_512_ROUNDS_TOTAL (72) -#define SKEIN_1024_ROUNDS_TOTAL (80) -#else /* allow command-line define in range 8*(5..14) */ -#define SKEIN_256_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS/100) + 5) % 10) + 5)) -#define SKEIN_512_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS/10) + 5) % 10) + 5)) -#define SKEIN_1024_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS) + 5) % 10) + 5)) -#endif - -#endif /* ifndef _SKEIN_H_ */ diff --git a/drivers/staging/skein/include/skeinApi.h b/drivers/staging/skein/include/skeinApi.h deleted file mode 100644 index b4e879d43d8a..000000000000 --- a/drivers/staging/skein/include/skeinApi.h +++ /dev/null @@ -1,230 +0,0 @@ -/* -Copyright (c) 2010 Werner Dittmann - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -*/ - -#ifndef SKEINAPI_H -#define SKEINAPI_H - -/** - * @file skeinApi.h - * @brief A Skein API and its functions. - * @{ - * - * This API and the functions that implement this API simplify the usage - * of Skein. The design and the way to use the functions follow the openSSL - * design but at the same time take care of some Skein specific behaviour - * and possibilities. - * - * The functions enable applications to create a normal Skein hashes and - * message authentication codes (MAC). - * - * Using these functions is simple and straight forward: - * - * @code - * - * #include - * - * ... - * struct skein_ctx ctx; // a Skein hash or MAC context - * - * // prepare context, here for a Skein with a state size of 512 bits. - * skein_ctx_prepare(&ctx, SKEIN_512); - * - * // Initialize the context to set the requested hash length in bits - * // here request a output hash size of 31 bits (Skein supports variable - * // output sizes even very strange sizes) - * skein_init(&ctx, 31); - * - * // Now update Skein with any number of message bits. A function that - * // takes a number of bytes is also available. - * skein_update_bits(&ctx, message, msg_length); - * - * // Now get the result of the Skein hash. The output buffer must be - * // large enough to hold the request number of output bits. The application - * // may now extract the bits. - * skein_final(&ctx, result); - * ... - * @endcode - * - * An application may use @c skein_reset to reset a Skein context and use - * it for creation of another hash with the same Skein state size and output - * bit length. In this case the API implementation restores some internal - * internal state data and saves a full Skein initialization round. - * - * To create a MAC the application just uses @c skein_mac_init instead of - * @c skein_init. All other functions calls remain the same. - * - */ - -#include -#include - -/** - * Which Skein size to use - */ -enum skein_size { - SKEIN_256 = 256, /*!< Skein with 256 bit state */ - SKEIN_512 = 512, /*!< Skein with 512 bit state */ - SKEIN_1024 = 1024 /*!< Skein with 1024 bit state */ -}; - -/** - * Context for Skein. - * - * This structure was setup with some know-how of the internal - * Skein structures, in particular ordering of header and size dependent - * variables. If Skein implementation changes this, then adapt these - * structures as well. - */ -struct skein_ctx { - u64 skein_size; - u64 X_save[SKEIN_MAX_STATE_WORDS]; /* save area for state variables */ - union { - struct skein_ctx_hdr h; - struct skein_256_ctx s256; - struct skein_512_ctx s512; - struct skein_1024_ctx s1024; - } m; -}; - -/** - * Prepare a Skein context. - * - * An application must call this function before it can use the Skein - * context. The functions clears memory and initializes size dependent - * variables. - * - * @param ctx - * Pointer to a Skein context. - * @param size - * Which Skein size to use. - * @return - * SKEIN_SUCESS of SKEIN_FAIL - */ -int skein_ctx_prepare(struct skein_ctx *ctx, enum skein_size size); - -/** - * Initialize a Skein context. - * - * Initializes the context with this data and saves the resulting Skein - * state variables for further use. - * - * @param ctx - * Pointer to a Skein context. - * @param hash_bit_len - * Number of MAC hash bits to compute - * @return - * SKEIN_SUCESS of SKEIN_FAIL - * @see skein_reset - */ -int skein_init(struct skein_ctx *ctx, size_t hash_bit_len); - -/** - * Resets a Skein context for further use. - * - * Restores the saved chaining variables to reset the Skein context. - * Thus applications can reuse the same setup to process several - * messages. This saves a complete Skein initialization cycle. - * - * @param ctx - * Pointer to a pre-initialized Skein MAC context - */ -void skein_reset(struct skein_ctx *ctx); - -/** - * Initializes a Skein context for MAC usage. - * - * Initializes the context with this data and saves the resulting Skein - * state variables for further use. - * - * Applications call the normal Skein functions to update the MAC and - * get the final result. - * - * @param ctx - * Pointer to an empty or preinitialized Skein MAC context - * @param key - * Pointer to key bytes or NULL - * @param key_len - * Length of the key in bytes or zero - * @param hash_bit_len - * Number of MAC hash bits to compute - * @return - * SKEIN_SUCESS of SKEIN_FAIL - */ -int skein_mac_init(struct skein_ctx *ctx, const u8 *key, size_t key_len, - size_t hash_bit_len); - -/** - * Update Skein with the next part of the message. - * - * @param ctx - * Pointer to initialized Skein context - * @param msg - * Pointer to the message. - * @param msg_byte_cnt - * Length of the message in @b bytes - * @return - * Success or error code. - */ -int skein_update(struct skein_ctx *ctx, const u8 *msg, - size_t msg_byte_cnt); - -/** - * Update the hash with a message bit string. - * - * Skein can handle data not only as bytes but also as bit strings of - * arbitrary length (up to its maximum design size). - * - * @param ctx - * Pointer to initialized Skein context - * @param msg - * Pointer to the message. - * @param msg_bit_cnt - * Length of the message in @b bits. - */ -int skein_update_bits(struct skein_ctx *ctx, const u8 *msg, - size_t msg_bit_cnt); - -/** - * Finalize Skein and return the hash. - * - * Before an application can reuse a Skein setup the application must - * reset the Skein context. - * - * @param ctx - * Pointer to initialized Skein context - * @param hash - * Pointer to buffer that receives the hash. The buffer must be large - * enough to store @c hash_bit_len bits. - * @return - * Success or error code. - * @see skein_reset - */ -int skein_final(struct skein_ctx *ctx, u8 *hash); - -/** - * @} - */ -#endif diff --git a/drivers/staging/skein/include/skein_block.h b/drivers/staging/skein/include/skein_block.h deleted file mode 100644 index a8dd083940b4..000000000000 --- a/drivers/staging/skein/include/skein_block.h +++ /dev/null @@ -1,22 +0,0 @@ -/*********************************************************************** -** -** Implementation of the Skein hash function. -** -** Source code author: Doug Whiting, 2008. -** -** This algorithm and source code is released to the public domain. -** -************************************************************************/ -#ifndef _SKEIN_BLOCK_H_ -#define _SKEIN_BLOCK_H_ - -#include /* get the Skein API definitions */ - -void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, - size_t blk_cnt, size_t byte_cnt_add); -void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, - size_t blk_cnt, size_t byte_cnt_add); -void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, - size_t blk_cnt, size_t byte_cnt_add); - -#endif diff --git a/drivers/staging/skein/include/skein_iv.h b/drivers/staging/skein/include/skein_iv.h deleted file mode 100644 index 7ff93dfd912f..000000000000 --- a/drivers/staging/skein/include/skein_iv.h +++ /dev/null @@ -1,186 +0,0 @@ -#ifndef _SKEIN_IV_H_ -#define _SKEIN_IV_H_ - -#include /* get Skein macros and types */ - -/* -***************** Pre-computed Skein IVs ******************* -** -** NOTE: these values are not "magic" constants, but -** are generated using the Threefish block function. -** They are pre-computed here only for speed; i.e., to -** avoid the need for a Threefish call during Init(). -** -** The IV for any fixed hash length may be pre-computed. -** Only the most common values are included here. -** -************************************************************ -**/ - -#define MK_64 SKEIN_MK_64 - -/* blkSize = 256 bits. hashSize = 128 bits */ -const u64 SKEIN_256_IV_128[] = { - MK_64(0xE1111906, 0x964D7260), - MK_64(0x883DAAA7, 0x7C8D811C), - MK_64(0x10080DF4, 0x91960F7A), - MK_64(0xCCF7DDE5, 0xB45BC1C2) -}; - -/* blkSize = 256 bits. hashSize = 160 bits */ -const u64 SKEIN_256_IV_160[] = { - MK_64(0x14202314, 0x72825E98), - MK_64(0x2AC4E9A2, 0x5A77E590), - MK_64(0xD47A5856, 0x8838D63E), - MK_64(0x2DD2E496, 0x8586AB7D) -}; - -/* blkSize = 256 bits. hashSize = 224 bits */ -const u64 SKEIN_256_IV_224[] = { - MK_64(0xC6098A8C, 0x9AE5EA0B), - MK_64(0x876D5686, 0x08C5191C), - MK_64(0x99CB88D7, 0xD7F53884), - MK_64(0x384BDDB1, 0xAEDDB5DE) -}; - -/* blkSize = 256 bits. hashSize = 256 bits */ -const u64 SKEIN_256_IV_256[] = { - MK_64(0xFC9DA860, 0xD048B449), - MK_64(0x2FCA6647, 0x9FA7D833), - MK_64(0xB33BC389, 0x6656840F), - MK_64(0x6A54E920, 0xFDE8DA69) -}; - -/* blkSize = 512 bits. hashSize = 128 bits */ -const u64 SKEIN_512_IV_128[] = { - MK_64(0xA8BC7BF3, 0x6FBF9F52), - MK_64(0x1E9872CE, 0xBD1AF0AA), - MK_64(0x309B1790, 0xB32190D3), - MK_64(0xBCFBB854, 0x3F94805C), - MK_64(0x0DA61BCD, 0x6E31B11B), - MK_64(0x1A18EBEA, 0xD46A32E3), - MK_64(0xA2CC5B18, 0xCE84AA82), - MK_64(0x6982AB28, 0x9D46982D) -}; - -/* blkSize = 512 bits. hashSize = 160 bits */ -const u64 SKEIN_512_IV_160[] = { - MK_64(0x28B81A2A, 0xE013BD91), - MK_64(0xC2F11668, 0xB5BDF78F), - MK_64(0x1760D8F3, 0xF6A56F12), - MK_64(0x4FB74758, 0x8239904F), - MK_64(0x21EDE07F, 0x7EAF5056), - MK_64(0xD908922E, 0x63ED70B8), - MK_64(0xB8EC76FF, 0xECCB52FA), - MK_64(0x01A47BB8, 0xA3F27A6E) -}; - -/* blkSize = 512 bits. hashSize = 224 bits */ -const u64 SKEIN_512_IV_224[] = { - MK_64(0xCCD06162, 0x48677224), - MK_64(0xCBA65CF3, 0xA92339EF), - MK_64(0x8CCD69D6, 0x52FF4B64), - MK_64(0x398AED7B, 0x3AB890B4), - MK_64(0x0F59D1B1, 0x457D2BD0), - MK_64(0x6776FE65, 0x75D4EB3D), - MK_64(0x99FBC70E, 0x997413E9), - MK_64(0x9E2CFCCF, 0xE1C41EF7) -}; - -/* blkSize = 512 bits. hashSize = 256 bits */ -const u64 SKEIN_512_IV_256[] = { - MK_64(0xCCD044A1, 0x2FDB3E13), - MK_64(0xE8359030, 0x1A79A9EB), - MK_64(0x55AEA061, 0x4F816E6F), - MK_64(0x2A2767A4, 0xAE9B94DB), - MK_64(0xEC06025E, 0x74DD7683), - MK_64(0xE7A436CD, 0xC4746251), - MK_64(0xC36FBAF9, 0x393AD185), - MK_64(0x3EEDBA18, 0x33EDFC13) -}; - -/* blkSize = 512 bits. hashSize = 384 bits */ -const u64 SKEIN_512_IV_384[] = { - MK_64(0xA3F6C6BF, 0x3A75EF5F), - MK_64(0xB0FEF9CC, 0xFD84FAA4), - MK_64(0x9D77DD66, 0x3D770CFE), - MK_64(0xD798CBF3, 0xB468FDDA), - MK_64(0x1BC4A666, 0x8A0E4465), - MK_64(0x7ED7D434, 0xE5807407), - MK_64(0x548FC1AC, 0xD4EC44D6), - MK_64(0x266E1754, 0x6AA18FF8) -}; - -/* blkSize = 512 bits. hashSize = 512 bits */ -const u64 SKEIN_512_IV_512[] = { - MK_64(0x4903ADFF, 0x749C51CE), - MK_64(0x0D95DE39, 0x9746DF03), - MK_64(0x8FD19341, 0x27C79BCE), - MK_64(0x9A255629, 0xFF352CB1), - MK_64(0x5DB62599, 0xDF6CA7B0), - MK_64(0xEABE394C, 0xA9D5C3F4), - MK_64(0x991112C7, 0x1A75B523), - MK_64(0xAE18A40B, 0x660FCC33) -}; - -/* blkSize = 1024 bits. hashSize = 384 bits */ -const u64 SKEIN_1024_IV_384[] = { - MK_64(0x5102B6B8, 0xC1894A35), - MK_64(0xFEEBC9E3, 0xFE8AF11A), - MK_64(0x0C807F06, 0xE32BED71), - MK_64(0x60C13A52, 0xB41A91F6), - MK_64(0x9716D35D, 0xD4917C38), - MK_64(0xE780DF12, 0x6FD31D3A), - MK_64(0x797846B6, 0xC898303A), - MK_64(0xB172C2A8, 0xB3572A3B), - MK_64(0xC9BC8203, 0xA6104A6C), - MK_64(0x65909338, 0xD75624F4), - MK_64(0x94BCC568, 0x4B3F81A0), - MK_64(0x3EBBF51E, 0x10ECFD46), - MK_64(0x2DF50F0B, 0xEEB08542), - MK_64(0x3B5A6530, 0x0DBC6516), - MK_64(0x484B9CD2, 0x167BBCE1), - MK_64(0x2D136947, 0xD4CBAFEA) -}; - -/* blkSize = 1024 bits. hashSize = 512 bits */ -const u64 SKEIN_1024_IV_512[] = { - MK_64(0xCAEC0E5D, 0x7C1B1B18), - MK_64(0xA01B0E04, 0x5F03E802), - MK_64(0x33840451, 0xED912885), - MK_64(0x374AFB04, 0xEAEC2E1C), - MK_64(0xDF25A0E2, 0x813581F7), - MK_64(0xE4004093, 0x8B12F9D2), - MK_64(0xA662D539, 0xC2ED39B6), - MK_64(0xFA8B85CF, 0x45D8C75A), - MK_64(0x8316ED8E, 0x29EDE796), - MK_64(0x053289C0, 0x2E9F91B8), - MK_64(0xC3F8EF1D, 0x6D518B73), - MK_64(0xBDCEC3C4, 0xD5EF332E), - MK_64(0x549A7E52, 0x22974487), - MK_64(0x67070872, 0x5B749816), - MK_64(0xB9CD28FB, 0xF0581BD1), - MK_64(0x0E2940B8, 0x15804974) -}; - -/* blkSize = 1024 bits. hashSize = 1024 bits */ -const u64 SKEIN_1024_IV_1024[] = { - MK_64(0xD593DA07, 0x41E72355), - MK_64(0x15B5E511, 0xAC73E00C), - MK_64(0x5180E5AE, 0xBAF2C4F0), - MK_64(0x03BD41D3, 0xFCBCAFAF), - MK_64(0x1CAEC6FD, 0x1983A898), - MK_64(0x6E510B8B, 0xCDD0589F), - MK_64(0x77E2BDFD, 0xC6394ADA), - MK_64(0xC11E1DB5, 0x24DCB0A3), - MK_64(0xD6D14AF9, 0xC6329AB5), - MK_64(0x6A9B0BFC, 0x6EB67E0D), - MK_64(0x9243C60D, 0xCCFF1332), - MK_64(0x1A1F1DDE, 0x743F02D4), - MK_64(0x0996753C, 0x10ED0BB8), - MK_64(0x6572DD22, 0xF2B4969A), - MK_64(0x61FD3062, 0xD00A579A), - MK_64(0x1DE0536E, 0x8682E539) -}; - -#endif /* _SKEIN_IV_H_ */ diff --git a/drivers/staging/skein/include/threefishApi.h b/drivers/staging/skein/include/threefishApi.h deleted file mode 100644 index 96cc0e868f43..000000000000 --- a/drivers/staging/skein/include/threefishApi.h +++ /dev/null @@ -1,170 +0,0 @@ - -#ifndef THREEFISHAPI_H -#define THREEFISHAPI_H - -/** - * @file threefishApi.h - * @brief A Threefish cipher API and its functions. - * @{ - * - * This API and the functions that implement this API simplify the usage - * of the Threefish cipher. The design and the way to use the functions - * follow the openSSL design but at the same time take care of some Threefish - * specific behaviour and possibilities. - * - * These are the low level functions that deal with Threefisch blocks only. - * Implementations for cipher modes such as ECB, CFB, or CBC may use these - * functions. - * -@code - // Threefish cipher context data - struct threefish_key key_ctx; - - // Initialize the context - threefish_set_key(&key_ctx, THREEFISH_512, key, tweak); - - // Encrypt - threefish_encrypt_block_bytes(&key_ctx, input, cipher); -@endcode - */ - -#include -#include - -#define KEY_SCHEDULE_CONST 0x1BD11BDAA9FC1A22L - -/** - * Which Threefish size to use - */ -enum threefish_size { - THREEFISH_256 = 256, /*!< Skein with 256 bit state */ - THREEFISH_512 = 512, /*!< Skein with 512 bit state */ - THREEFISH_1024 = 1024 /*!< Skein with 1024 bit state */ -}; - -/** - * Context for Threefish key and tweak words. - * - * This structure was setup with some know-how of the internal - * Skein structures, in particular ordering of header and size dependent - * variables. If Skein implementation changes this, the adapt these - * structures as well. - */ -struct threefish_key { - u64 state_size; - u64 key[SKEIN_MAX_STATE_WORDS+1]; /* max number of key words*/ - u64 tweak[3]; -}; - -/** - * Set Threefish key and tweak data. - * - * This function sets the key and tweak data for the Threefish cipher of - * the given size. The key data must have the same length (number of bits) - * as the state size - * - * @param key_ctx - * Pointer to a Threefish key structure. - * @param size - * Which Skein size to use. - * @param key_data - * Pointer to the key words (word has 64 bits). - * @param tweak - * Pointer to the two tweak words (word has 64 bits). - */ -void threefish_set_key(struct threefish_key *key_ctx, - enum threefish_size state_size, - u64 *key_data, u64 *tweak); - -/** - * Encrypt Threefisch block (bytes). - * - * The buffer must have at least the same length (number of bits) aas the - * state size for this key. The function uses the first @c state_size bits - * of the input buffer, encrypts them and stores the result in the output - * buffer. - * - * @param key_ctx - * Pointer to a Threefish key structure. - * @param in - * Poionter to plaintext data buffer. - * @param out - * Pointer to cipher buffer. - */ -void threefish_encrypt_block_bytes(struct threefish_key *key_ctx, u8 *in, - u8 *out); - -/** - * Encrypt Threefisch block (words). - * - * The buffer must have at least the same length (number of bits) aas the - * state size for this key. The function uses the first @c state_size bits - * of the input buffer, encrypts them and stores the result in the output - * buffer. - * - * The wordsize ist set to 64 bits. - * - * @param key_ctx - * Pointer to a Threefish key structure. - * @param in - * Poionter to plaintext data buffer. - * @param out - * Pointer to cipher buffer. - */ -void threefish_encrypt_block_words(struct threefish_key *key_ctx, u64 *in, - u64 *out); - -/** - * Decrypt Threefisch block (bytes). - * - * The buffer must have at least the same length (number of bits) aas the - * state size for this key. The function uses the first @c state_size bits - * of the input buffer, decrypts them and stores the result in the output - * buffer - * - * @param key_ctx - * Pointer to a Threefish key structure. - * @param in - * Poionter to cipher data buffer. - * @param out - * Pointer to plaintext buffer. - */ -void threefish_decrypt_block_bytes(struct threefish_key *key_ctx, u8 *in, - u8 *out); - -/** - * Decrypt Threefisch block (words). - * - * The buffer must have at least the same length (number of bits) aas the - * state size for this key. The function uses the first @c state_size bits - * of the input buffer, encrypts them and stores the result in the output - * buffer. - * - * The wordsize ist set to 64 bits. - * - * @param key_ctx - * Pointer to a Threefish key structure. - * @param in - * Poionter to cipher data buffer. - * @param out - * Pointer to plaintext buffer. - */ -void threefish_decrypt_block_words(struct threefish_key *key_ctx, u64 *in, - u64 *out); - -void threefish_encrypt_256(struct threefish_key *key_ctx, u64 *input, - u64 *output); -void threefish_encrypt_512(struct threefish_key *key_ctx, u64 *input, - u64 *output); -void threefish_encrypt_1024(struct threefish_key *key_ctx, u64 *input, - u64 *output); -void threefish_decrypt_256(struct threefish_key *key_ctx, u64 *input, - u64 *output); -void threefish_decrypt_512(struct threefish_key *key_ctx, u64 *input, - u64 *output); -void threefish_decrypt_1024(struct threefish_key *key_ctx, u64 *input, - u64 *output); -/** - * @} - */ -#endif diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c index 2a2da983a1cc..f76d5850c7dd 100644 --- a/drivers/staging/skein/skein.c +++ b/drivers/staging/skein/skein.c @@ -11,9 +11,9 @@ #define SKEIN_PORT_CODE /* instantiate any code in skein_port.h */ #include /* get the memcpy/memset functions */ -#include /* get the Skein API definitions */ -#include /* get precomputed IVs */ -#include +#include "skein.h" /* get the Skein API definitions */ +#include "skein_iv.h" /* get precomputed IVs */ +#include "skein_block.h" /*****************************************************************/ /* 256-bit Skein */ diff --git a/drivers/staging/skein/skein.h b/drivers/staging/skein/skein.h new file mode 100644 index 000000000000..2c87ff74aaea --- /dev/null +++ b/drivers/staging/skein/skein.h @@ -0,0 +1,346 @@ +#ifndef _SKEIN_H_ +#define _SKEIN_H_ 1 +/************************************************************************** +** +** Interface declarations and internal definitions for Skein hashing. +** +** Source code author: Doug Whiting, 2008. +** +** This algorithm and source code is released to the public domain. +** +*************************************************************************** +** +** The following compile-time switches may be defined to control some +** tradeoffs between speed, code size, error checking, and security. +** +** The "default" note explains what happens when the switch is not defined. +** +** SKEIN_DEBUG -- make callouts from inside Skein code +** to examine/display intermediate values. +** [default: no callouts (no overhead)] +** +** SKEIN_ERR_CHECK -- how error checking is handled inside Skein +** code. If not defined, most error checking +** is disabled (for performance). Otherwise, +** the switch value is interpreted as: +** 0: use assert() to flag errors +** 1: return SKEIN_FAIL to flag errors +** +***************************************************************************/ + +#ifndef rotl_64 +#define rotl_64(x, N) (((x) << (N)) | ((x) >> (64-(N)))) +#endif + +/* below two prototype assume we are handed aligned data */ +#define skein_put64_lsb_first(dst08, src64, b_cnt) memcpy(dst08, src64, b_cnt) +#define skein_get64_lsb_first(dst64, src08, w_cnt) \ + memcpy(dst64, src08, 8*(w_cnt)) +#define skein_swap64(w64) (w64) + +enum { + SKEIN_SUCCESS = 0, /* return codes from Skein calls */ + SKEIN_FAIL = 1, + SKEIN_BAD_HASHLEN = 2 +}; + +#define SKEIN_MODIFIER_WORDS (2) /* number of modifier (tweak) words */ + +#define SKEIN_256_STATE_WORDS (4) +#define SKEIN_512_STATE_WORDS (8) +#define SKEIN_1024_STATE_WORDS (16) +#define SKEIN_MAX_STATE_WORDS (16) + +#define SKEIN_256_STATE_BYTES (8*SKEIN_256_STATE_WORDS) +#define SKEIN_512_STATE_BYTES (8*SKEIN_512_STATE_WORDS) +#define SKEIN_1024_STATE_BYTES (8*SKEIN_1024_STATE_WORDS) + +#define SKEIN_256_STATE_BITS (64*SKEIN_256_STATE_WORDS) +#define SKEIN_512_STATE_BITS (64*SKEIN_512_STATE_WORDS) +#define SKEIN_1024_STATE_BITS (64*SKEIN_1024_STATE_WORDS) + +#define SKEIN_256_BLOCK_BYTES (8*SKEIN_256_STATE_WORDS) +#define SKEIN_512_BLOCK_BYTES (8*SKEIN_512_STATE_WORDS) +#define SKEIN_1024_BLOCK_BYTES (8*SKEIN_1024_STATE_WORDS) + +struct skein_ctx_hdr { + size_t hash_bit_len; /* size of hash result, in bits */ + size_t b_cnt; /* current byte count in buffer b[] */ + u64 T[SKEIN_MODIFIER_WORDS]; /* tweak: T[0]=byte cnt, T[1]=flags */ +}; + +struct skein_256_ctx { /* 256-bit Skein hash context structure */ + struct skein_ctx_hdr h; /* common header context variables */ + u64 X[SKEIN_256_STATE_WORDS]; /* chaining variables */ + u8 b[SKEIN_256_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ +}; + +struct skein_512_ctx { /* 512-bit Skein hash context structure */ + struct skein_ctx_hdr h; /* common header context variables */ + u64 X[SKEIN_512_STATE_WORDS]; /* chaining variables */ + u8 b[SKEIN_512_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ +}; + +struct skein_1024_ctx { /* 1024-bit Skein hash context structure */ + struct skein_ctx_hdr h; /* common header context variables */ + u64 X[SKEIN_1024_STATE_WORDS]; /* chaining variables */ + u8 b[SKEIN_1024_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ +}; + +/* Skein APIs for (incremental) "straight hashing" */ +int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len); +int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len); +int skein_1024_init(struct skein_1024_ctx *ctx, size_t hash_bit_len); + +int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg, + size_t msg_byte_cnt); +int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg, + size_t msg_byte_cnt); +int skein_1024_update(struct skein_1024_ctx *ctx, const u8 *msg, + size_t msg_byte_cnt); + +int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val); +int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val); +int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val); + +/* +** Skein APIs for "extended" initialization: MAC keys, tree hashing. +** After an init_ext() call, just use update/final calls as with init(). +** +** Notes: Same parameters as _init() calls, plus tree_info/key/key_bytes. +** When key_bytes == 0 and tree_info == SKEIN_SEQUENTIAL, +** the results of init_ext() are identical to calling init(). +** The function init() may be called once to "precompute" the IV for +** a given hash_bit_len value, then by saving a copy of the context +** the IV computation may be avoided in later calls. +** Similarly, the function init_ext() may be called once per MAC key +** to precompute the MAC IV, then a copy of the context saved and +** reused for each new MAC computation. +**/ +int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hash_bit_len, + u64 tree_info, const u8 *key, size_t key_bytes); +int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hash_bit_len, + u64 tree_info, const u8 *key, size_t key_bytes); +int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t hash_bit_len, + u64 tree_info, const u8 *key, size_t key_bytes); + +/* +** Skein APIs for MAC and tree hash: +** final_pad: pad, do final block, but no OUTPUT type +** output: do just the output stage +*/ +int skein_256_final_pad(struct skein_256_ctx *ctx, u8 *hash_val); +int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hash_val); +int skein_1024_final_pad(struct skein_1024_ctx *ctx, u8 *hash_val); + +#ifndef SKEIN_TREE_HASH +#define SKEIN_TREE_HASH (1) +#endif +#if SKEIN_TREE_HASH +int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val); +int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val); +int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); +#endif + +/***************************************************************** +** "Internal" Skein definitions +** -- not needed for sequential hashing API, but will be +** helpful for other uses of Skein (e.g., tree hash mode). +** -- included here so that they can be shared between +** reference and optimized code. +******************************************************************/ + +/* tweak word T[1]: bit field starting positions */ +#define SKEIN_T1_BIT(BIT) ((BIT) - 64) /* second word */ + +#define SKEIN_T1_POS_TREE_LVL SKEIN_T1_BIT(112) /* 112..118 hash tree level */ +#define SKEIN_T1_POS_BIT_PAD SKEIN_T1_BIT(119) /* 119 part. final in byte */ +#define SKEIN_T1_POS_BLK_TYPE SKEIN_T1_BIT(120) /* 120..125 type field `*/ +#define SKEIN_T1_POS_FIRST SKEIN_T1_BIT(126) /* 126 first blk flag */ +#define SKEIN_T1_POS_FINAL SKEIN_T1_BIT(127) /* 127 final blk flag */ + +/* tweak word T[1]: flag bit definition(s) */ +#define SKEIN_T1_FLAG_FIRST (((u64) 1) << SKEIN_T1_POS_FIRST) +#define SKEIN_T1_FLAG_FINAL (((u64) 1) << SKEIN_T1_POS_FINAL) +#define SKEIN_T1_FLAG_BIT_PAD (((u64) 1) << SKEIN_T1_POS_BIT_PAD) + +/* tweak word T[1]: tree level bit field mask */ +#define SKEIN_T1_TREE_LVL_MASK (((u64)0x7F) << SKEIN_T1_POS_TREE_LVL) +#define SKEIN_T1_TREE_LEVEL(n) (((u64) (n)) << SKEIN_T1_POS_TREE_LVL) + +/* tweak word T[1]: block type field */ +#define SKEIN_BLK_TYPE_KEY (0) /* key, for MAC and KDF */ +#define SKEIN_BLK_TYPE_CFG (4) /* configuration block */ +#define SKEIN_BLK_TYPE_PERS (8) /* personalization string */ +#define SKEIN_BLK_TYPE_PK (12) /* pubkey (for digital sigs) */ +#define SKEIN_BLK_TYPE_KDF (16) /* key identifier for KDF */ +#define SKEIN_BLK_TYPE_NONCE (20) /* nonce for PRNG */ +#define SKEIN_BLK_TYPE_MSG (48) /* message processing */ +#define SKEIN_BLK_TYPE_OUT (63) /* output stage */ +#define SKEIN_BLK_TYPE_MASK (63) /* bit field mask */ + +#define SKEIN_T1_BLK_TYPE(T) (((u64) (SKEIN_BLK_TYPE_##T)) << \ + SKEIN_T1_POS_BLK_TYPE) +#define SKEIN_T1_BLK_TYPE_KEY SKEIN_T1_BLK_TYPE(KEY) /* for MAC and KDF */ +#define SKEIN_T1_BLK_TYPE_CFG SKEIN_T1_BLK_TYPE(CFG) /* config block */ +#define SKEIN_T1_BLK_TYPE_PERS SKEIN_T1_BLK_TYPE(PERS) /* personalization */ +#define SKEIN_T1_BLK_TYPE_PK SKEIN_T1_BLK_TYPE(PK) /* pubkey (for sigs) */ +#define SKEIN_T1_BLK_TYPE_KDF SKEIN_T1_BLK_TYPE(KDF) /* key ident for KDF */ +#define SKEIN_T1_BLK_TYPE_NONCE SKEIN_T1_BLK_TYPE(NONCE)/* nonce for PRNG */ +#define SKEIN_T1_BLK_TYPE_MSG SKEIN_T1_BLK_TYPE(MSG) /* message processing */ +#define SKEIN_T1_BLK_TYPE_OUT SKEIN_T1_BLK_TYPE(OUT) /* output stage */ +#define SKEIN_T1_BLK_TYPE_MASK SKEIN_T1_BLK_TYPE(MASK) /* field bit mask */ + +#define SKEIN_T1_BLK_TYPE_CFG_FINAL (SKEIN_T1_BLK_TYPE_CFG | \ + SKEIN_T1_FLAG_FINAL) +#define SKEIN_T1_BLK_TYPE_OUT_FINAL (SKEIN_T1_BLK_TYPE_OUT | \ + SKEIN_T1_FLAG_FINAL) + +#define SKEIN_VERSION (1) + +#ifndef SKEIN_ID_STRING_LE /* allow compile-time personalization */ +#define SKEIN_ID_STRING_LE (0x33414853) /* "SHA3" (little-endian)*/ +#endif + +#define SKEIN_MK_64(hi32, lo32) ((lo32) + (((u64) (hi32)) << 32)) +#define SKEIN_SCHEMA_VER SKEIN_MK_64(SKEIN_VERSION, SKEIN_ID_STRING_LE) +#define SKEIN_KS_PARITY SKEIN_MK_64(0x1BD11BDA, 0xA9FC1A22) + +#define SKEIN_CFG_STR_LEN (4*8) + +/* bit field definitions in config block tree_info word */ +#define SKEIN_CFG_TREE_LEAF_SIZE_POS (0) +#define SKEIN_CFG_TREE_NODE_SIZE_POS (8) +#define SKEIN_CFG_TREE_MAX_LEVEL_POS (16) + +#define SKEIN_CFG_TREE_LEAF_SIZE_MSK (((u64)0xFF) << \ + SKEIN_CFG_TREE_LEAF_SIZE_POS) +#define SKEIN_CFG_TREE_NODE_SIZE_MSK (((u64)0xFF) << \ + SKEIN_CFG_TREE_NODE_SIZE_POS) +#define SKEIN_CFG_TREE_MAX_LEVEL_MSK (((u64)0xFF) << \ + SKEIN_CFG_TREE_MAX_LEVEL_POS) + +#define SKEIN_CFG_TREE_INFO(leaf, node, max_lvl) \ + ((((u64)(leaf)) << SKEIN_CFG_TREE_LEAF_SIZE_POS) | \ + (((u64)(node)) << SKEIN_CFG_TREE_NODE_SIZE_POS) | \ + (((u64)(max_lvl)) << SKEIN_CFG_TREE_MAX_LEVEL_POS)) + +/* use as tree_info in InitExt() call for sequential processing */ +#define SKEIN_CFG_TREE_INFO_SEQUENTIAL SKEIN_CFG_TREE_INFO(0, 0, 0) + +/* +** Skein macros for getting/setting tweak words, etc. +** These are useful for partial input bytes, hash tree init/update, etc. +**/ +#define skein_get_tweak(ctx_ptr, TWK_NUM) ((ctx_ptr)->h.T[TWK_NUM]) +#define skein_set_tweak(ctx_ptr, TWK_NUM, t_val) { \ + (ctx_ptr)->h.T[TWK_NUM] = (t_val); \ + } + +#define skein_get_T0(ctx_ptr) skein_get_tweak(ctx_ptr, 0) +#define skein_get_T1(ctx_ptr) skein_get_tweak(ctx_ptr, 1) +#define skein_set_T0(ctx_ptr, T0) skein_set_tweak(ctx_ptr, 0, T0) +#define skein_set_T1(ctx_ptr, T1) skein_set_tweak(ctx_ptr, 1, T1) + +/* set both tweak words at once */ +#define skein_set_T0_T1(ctx_ptr, T0, T1) \ + { \ + skein_set_T0(ctx_ptr, (T0)); \ + skein_set_T1(ctx_ptr, (T1)); \ + } + +#define skein_set_type(ctx_ptr, BLK_TYPE) \ + skein_set_T1(ctx_ptr, SKEIN_T1_BLK_TYPE_##BLK_TYPE) + +/* + * setup for starting with a new type: + * h.T[0]=0; h.T[1] = NEW_TYPE; h.b_cnt=0; + */ +#define skein_start_new_type(ctx_ptr, BLK_TYPE) { \ + skein_set_T0_T1(ctx_ptr, 0, SKEIN_T1_FLAG_FIRST | \ + SKEIN_T1_BLK_TYPE_##BLK_TYPE); \ + (ctx_ptr)->h.b_cnt = 0; \ + } + +#define skein_clear_first_flag(hdr) { \ + (hdr).T[1] &= ~SKEIN_T1_FLAG_FIRST; \ + } +#define skein_set_bit_pad_flag(hdr) { \ + (hdr).T[1] |= SKEIN_T1_FLAG_BIT_PAD; \ + } + +#define skein_set_tree_level(hdr, height) { \ + (hdr).T[1] |= SKEIN_T1_TREE_LEVEL(height); \ + } + +/***************************************************************** +** "Internal" Skein definitions for debugging and error checking +******************************************************************/ +#ifdef SKEIN_DEBUG /* examine/display intermediate values? */ +#include "skein_debug.h" +#else /* default is no callouts */ +#define skein_show_block(bits, ctx, X, blk_ptr, w_ptr, ks_event_ptr, ks_odd_ptr) +#define skein_show_round(bits, ctx, r, X) +#define skein_show_r_ptr(bits, ctx, r, X_ptr) +#define skein_show_final(bits, ctx, cnt, out_ptr) +#define skein_show_key(bits, ctx, key, key_bytes) +#endif + +/* ignore all asserts, for performance */ +#define skein_assert_ret(x, ret_code) +#define skein_assert(x) + +/***************************************************************** +** Skein block function constants (shared across Ref and Opt code) +******************************************************************/ +enum { + /* SKEIN_256 round rotation constants */ + R_256_0_0 = 14, R_256_0_1 = 16, + R_256_1_0 = 52, R_256_1_1 = 57, + R_256_2_0 = 23, R_256_2_1 = 40, + R_256_3_0 = 5, R_256_3_1 = 37, + R_256_4_0 = 25, R_256_4_1 = 33, + R_256_5_0 = 46, R_256_5_1 = 12, + R_256_6_0 = 58, R_256_6_1 = 22, + R_256_7_0 = 32, R_256_7_1 = 32, + + /* SKEIN_512 round rotation constants */ + R_512_0_0 = 46, R_512_0_1 = 36, R_512_0_2 = 19, R_512_0_3 = 37, + R_512_1_0 = 33, R_512_1_1 = 27, R_512_1_2 = 14, R_512_1_3 = 42, + R_512_2_0 = 17, R_512_2_1 = 49, R_512_2_2 = 36, R_512_2_3 = 39, + R_512_3_0 = 44, R_512_3_1 = 9, R_512_3_2 = 54, R_512_3_3 = 56, + R_512_4_0 = 39, R_512_4_1 = 30, R_512_4_2 = 34, R_512_4_3 = 24, + R_512_5_0 = 13, R_512_5_1 = 50, R_512_5_2 = 10, R_512_5_3 = 17, + R_512_6_0 = 25, R_512_6_1 = 29, R_512_6_2 = 39, R_512_6_3 = 43, + R_512_7_0 = 8, R_512_7_1 = 35, R_512_7_2 = 56, R_512_7_3 = 22, + + /* SKEIN_1024 round rotation constants */ + R1024_0_0 = 24, R1024_0_1 = 13, R1024_0_2 = 8, R1024_0_3 = 47, + R1024_0_4 = 8, R1024_0_5 = 17, R1024_0_6 = 22, R1024_0_7 = 37, + R1024_1_0 = 38, R1024_1_1 = 19, R1024_1_2 = 10, R1024_1_3 = 55, + R1024_1_4 = 49, R1024_1_5 = 18, R1024_1_6 = 23, R1024_1_7 = 52, + R1024_2_0 = 33, R1024_2_1 = 4, R1024_2_2 = 51, R1024_2_3 = 13, + R1024_2_4 = 34, R1024_2_5 = 41, R1024_2_6 = 59, R1024_2_7 = 17, + R1024_3_0 = 5, R1024_3_1 = 20, R1024_3_2 = 48, R1024_3_3 = 41, + R1024_3_4 = 47, R1024_3_5 = 28, R1024_3_6 = 16, R1024_3_7 = 25, + R1024_4_0 = 41, R1024_4_1 = 9, R1024_4_2 = 37, R1024_4_3 = 31, + R1024_4_4 = 12, R1024_4_5 = 47, R1024_4_6 = 44, R1024_4_7 = 30, + R1024_5_0 = 16, R1024_5_1 = 34, R1024_5_2 = 56, R1024_5_3 = 51, + R1024_5_4 = 4, R1024_5_5 = 53, R1024_5_6 = 42, R1024_5_7 = 41, + R1024_6_0 = 31, R1024_6_1 = 44, R1024_6_2 = 47, R1024_6_3 = 46, + R1024_6_4 = 19, R1024_6_5 = 42, R1024_6_6 = 44, R1024_6_7 = 25, + R1024_7_0 = 9, R1024_7_1 = 48, R1024_7_2 = 35, R1024_7_3 = 52, + R1024_7_4 = 23, R1024_7_5 = 31, R1024_7_6 = 37, R1024_7_7 = 20 +}; + +#ifndef SKEIN_ROUNDS +#define SKEIN_256_ROUNDS_TOTAL (72) /* # rounds for diff block sizes */ +#define SKEIN_512_ROUNDS_TOTAL (72) +#define SKEIN_1024_ROUNDS_TOTAL (80) +#else /* allow command-line define in range 8*(5..14) */ +#define SKEIN_256_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS/100) + 5) % 10) + 5)) +#define SKEIN_512_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS/10) + 5) % 10) + 5)) +#define SKEIN_1024_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS) + 5) % 10) + 5)) +#endif + +#endif /* ifndef _SKEIN_H_ */ diff --git a/drivers/staging/skein/skeinApi.c b/drivers/staging/skein/skeinApi.c deleted file mode 100644 index 16d596b45317..000000000000 --- a/drivers/staging/skein/skeinApi.c +++ /dev/null @@ -1,239 +0,0 @@ -/* -Copyright (c) 2010 Werner Dittmann - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -*/ - -#include -#include - -int skein_ctx_prepare(struct skein_ctx *ctx, enum skein_size size) -{ - skein_assert_ret(ctx && size, SKEIN_FAIL); - - memset(ctx , 0, sizeof(struct skein_ctx)); - ctx->skein_size = size; - - return SKEIN_SUCCESS; -} - -int skein_init(struct skein_ctx *ctx, size_t hash_bit_len) -{ - int ret = SKEIN_FAIL; - size_t X_len = 0; - u64 *X = NULL; - u64 tree_info = SKEIN_CFG_TREE_INFO_SEQUENTIAL; - - skein_assert_ret(ctx, SKEIN_FAIL); - /* - * The following two lines rely of the fact that the real Skein - * contexts are a union in out context and thus have tha maximum - * memory available. The beauty of C :-) . - */ - X = ctx->m.s256.X; - X_len = ctx->skein_size/8; - /* - * If size is the same and hash bit length is zero then reuse - * the save chaining variables. - */ - switch (ctx->skein_size) { - case SKEIN_256: - ret = skein_256_init_ext(&ctx->m.s256, hash_bit_len, - tree_info, NULL, 0); - break; - case SKEIN_512: - ret = skein_512_init_ext(&ctx->m.s512, hash_bit_len, - tree_info, NULL, 0); - break; - case SKEIN_1024: - ret = skein_1024_init_ext(&ctx->m.s1024, hash_bit_len, - tree_info, NULL, 0); - break; - } - - if (ret == SKEIN_SUCCESS) { - /* - * Save chaining variables for this combination of size and - * hash_bit_len - */ - memcpy(ctx->X_save, X, X_len); - } - return ret; -} - -int skein_mac_init(struct skein_ctx *ctx, const u8 *key, size_t key_len, - size_t hash_bit_len) -{ - int ret = SKEIN_FAIL; - u64 *X = NULL; - size_t X_len = 0; - u64 tree_info = SKEIN_CFG_TREE_INFO_SEQUENTIAL; - - skein_assert_ret(ctx, SKEIN_FAIL); - - X = ctx->m.s256.X; - X_len = ctx->skein_size/8; - - skein_assert_ret(hash_bit_len, SKEIN_BAD_HASHLEN); - - switch (ctx->skein_size) { - case SKEIN_256: - ret = skein_256_init_ext(&ctx->m.s256, hash_bit_len, - tree_info, - (const u8 *)key, key_len); - - break; - case SKEIN_512: - ret = skein_512_init_ext(&ctx->m.s512, hash_bit_len, - tree_info, - (const u8 *)key, key_len); - break; - case SKEIN_1024: - ret = skein_1024_init_ext(&ctx->m.s1024, hash_bit_len, - tree_info, - (const u8 *)key, key_len); - - break; - } - if (ret == SKEIN_SUCCESS) { - /* - * Save chaining variables for this combination of key, - * key_len, hash_bit_len - */ - memcpy(ctx->X_save, X, X_len); - } - return ret; -} - -void skein_reset(struct skein_ctx *ctx) -{ - size_t X_len = 0; - u64 *X = NULL; - - /* - * The following two lines rely of the fact that the real Skein - * contexts are a union in out context and thus have tha maximum - * memory available. The beautiy of C :-) . - */ - X = ctx->m.s256.X; - X_len = ctx->skein_size/8; - /* Restore the chaing variable, reset byte counter */ - memcpy(X, ctx->X_save, X_len); - - /* Setup context to process the message */ - skein_start_new_type(&ctx->m, MSG); -} - -int skein_update(struct skein_ctx *ctx, const u8 *msg, - size_t msg_byte_cnt) -{ - int ret = SKEIN_FAIL; - - skein_assert_ret(ctx, SKEIN_FAIL); - - switch (ctx->skein_size) { - case SKEIN_256: - ret = skein_256_update(&ctx->m.s256, (const u8 *)msg, - msg_byte_cnt); - break; - case SKEIN_512: - ret = skein_512_update(&ctx->m.s512, (const u8 *)msg, - msg_byte_cnt); - break; - case SKEIN_1024: - ret = skein_1024_update(&ctx->m.s1024, (const u8 *)msg, - msg_byte_cnt); - break; - } - return ret; - -} - -int skein_update_bits(struct skein_ctx *ctx, const u8 *msg, - size_t msg_bit_cnt) -{ - /* - * I've used the bit pad implementation from skein_test.c (see NIST CD) - * and modified it to use the convenience functions and added some - * pointer arithmetic. - */ - size_t length; - u8 mask; - u8 *up; - - /* - * only the final Update() call is allowed do partial bytes, else - * assert an error - */ - skein_assert_ret((ctx->m.h.T[1] & SKEIN_T1_FLAG_BIT_PAD) == 0 || - msg_bit_cnt == 0, SKEIN_FAIL); - - /* if number of bits is a multiple of bytes - that's easy */ - if ((msg_bit_cnt & 0x7) == 0) - return skein_update(ctx, msg, msg_bit_cnt >> 3); - - skein_update(ctx, msg, (msg_bit_cnt >> 3) + 1); - - /* - * The next line rely on the fact that the real Skein contexts - * are a union in our context. After the addition the pointer points to - * Skein's real partial block buffer. - * If this layout ever changes we have to adapt this as well. - */ - up = (u8 *)ctx->m.s256.X + ctx->skein_size / 8; - - /* set tweak flag for the skein_final call */ - skein_set_bit_pad_flag(ctx->m.h); - - /* now "pad" the final partial byte the way NIST likes */ - /* get the b_cnt value (same location for all block sizes) */ - length = ctx->m.h.b_cnt; - /* internal sanity check: there IS a partial byte in the buffer! */ - skein_assert(length != 0); - /* partial byte bit mask */ - mask = (u8) (1u << (7 - (msg_bit_cnt & 7))); - /* apply bit padding on final byte (in the buffer) */ - up[length-1] = (u8)((up[length-1] & (0-mask))|mask); - - return SKEIN_SUCCESS; -} - -int skein_final(struct skein_ctx *ctx, u8 *hash) -{ - int ret = SKEIN_FAIL; - - skein_assert_ret(ctx, SKEIN_FAIL); - - switch (ctx->skein_size) { - case SKEIN_256: - ret = skein_256_final(&ctx->m.s256, (u8 *)hash); - break; - case SKEIN_512: - ret = skein_512_final(&ctx->m.s512, (u8 *)hash); - break; - case SKEIN_1024: - ret = skein_1024_final(&ctx->m.s1024, (u8 *)hash); - break; - } - return ret; -} diff --git a/drivers/staging/skein/skeinBlockNo3F.c b/drivers/staging/skein/skeinBlockNo3F.c deleted file mode 100644 index 4ee7f9fb4365..000000000000 --- a/drivers/staging/skein/skeinBlockNo3F.c +++ /dev/null @@ -1,175 +0,0 @@ - -#include -#include -#include - - -/***************************** Skein_256 ******************************/ -void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, - size_t blk_cnt, size_t byte_cnt_add) -{ - struct threefish_key key; - u64 tweak[2]; - int i; - u64 w[SKEIN_256_STATE_WORDS]; /* local copy of input block */ - u64 words[3]; - - skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ - tweak[0] = ctx->h.T[0]; - tweak[1] = ctx->h.T[1]; - - do { - u64 carry = byte_cnt_add; - - words[0] = tweak[0] & 0xffffffffL; - words[1] = ((tweak[0] >> 32) & 0xffffffffL); - words[2] = (tweak[1] & 0xffffffffL); - - for (i = 0; i < 3; i++) { - carry += words[i]; - words[i] = carry; - carry >>= 32; - } - tweak[0] = words[0] & 0xffffffffL; - tweak[0] |= (words[1] & 0xffffffffL) << 32; - tweak[1] |= words[2] & 0xffffffffL; - - threefish_set_key(&key, THREEFISH_256, ctx->X, tweak); - - /* get input block in little-endian format */ - skein_get64_lsb_first(w, blk_ptr, SKEIN_256_STATE_WORDS); - - threefish_encrypt_block_words(&key, w, ctx->X); - - blk_ptr += SKEIN_256_BLOCK_BYTES; - - /* do the final "feedforward" xor, update ctx chaining vars */ - ctx->X[0] = ctx->X[0] ^ w[0]; - ctx->X[1] = ctx->X[1] ^ w[1]; - ctx->X[2] = ctx->X[2] ^ w[2]; - ctx->X[3] = ctx->X[3] ^ w[3]; - - tweak[1] &= ~SKEIN_T1_FLAG_FIRST; - } while (--blk_cnt); - - ctx->h.T[0] = tweak[0]; - ctx->h.T[1] = tweak[1]; -} - -void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, - size_t blk_cnt, size_t byte_cnt_add) -{ - struct threefish_key key; - u64 tweak[2]; - int i; - u64 words[3]; - u64 w[SKEIN_512_STATE_WORDS]; /* local copy of input block */ - - skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ - tweak[0] = ctx->h.T[0]; - tweak[1] = ctx->h.T[1]; - - do { - u64 carry = byte_cnt_add; - - words[0] = tweak[0] & 0xffffffffL; - words[1] = ((tweak[0] >> 32) & 0xffffffffL); - words[2] = (tweak[1] & 0xffffffffL); - - for (i = 0; i < 3; i++) { - carry += words[i]; - words[i] = carry; - carry >>= 32; - } - tweak[0] = words[0] & 0xffffffffL; - tweak[0] |= (words[1] & 0xffffffffL) << 32; - tweak[1] |= words[2] & 0xffffffffL; - - threefish_set_key(&key, THREEFISH_512, ctx->X, tweak); - - /* get input block in little-endian format */ - skein_get64_lsb_first(w, blk_ptr, SKEIN_512_STATE_WORDS); - - threefish_encrypt_block_words(&key, w, ctx->X); - - blk_ptr += SKEIN_512_BLOCK_BYTES; - - /* do the final "feedforward" xor, update ctx chaining vars */ - ctx->X[0] = ctx->X[0] ^ w[0]; - ctx->X[1] = ctx->X[1] ^ w[1]; - ctx->X[2] = ctx->X[2] ^ w[2]; - ctx->X[3] = ctx->X[3] ^ w[3]; - ctx->X[4] = ctx->X[4] ^ w[4]; - ctx->X[5] = ctx->X[5] ^ w[5]; - ctx->X[6] = ctx->X[6] ^ w[6]; - ctx->X[7] = ctx->X[7] ^ w[7]; - - tweak[1] &= ~SKEIN_T1_FLAG_FIRST; - } while (--blk_cnt); - - ctx->h.T[0] = tweak[0]; - ctx->h.T[1] = tweak[1]; -} - -void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, - size_t blk_cnt, size_t byte_cnt_add) -{ - struct threefish_key key; - u64 tweak[2]; - int i; - u64 words[3]; - u64 w[SKEIN_1024_STATE_WORDS]; /* local copy of input block */ - - skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ - tweak[0] = ctx->h.T[0]; - tweak[1] = ctx->h.T[1]; - - do { - u64 carry = byte_cnt_add; - - words[0] = tweak[0] & 0xffffffffL; - words[1] = ((tweak[0] >> 32) & 0xffffffffL); - words[2] = (tweak[1] & 0xffffffffL); - - for (i = 0; i < 3; i++) { - carry += words[i]; - words[i] = carry; - carry >>= 32; - } - tweak[0] = words[0] & 0xffffffffL; - tweak[0] |= (words[1] & 0xffffffffL) << 32; - tweak[1] |= words[2] & 0xffffffffL; - - threefish_set_key(&key, THREEFISH_1024, ctx->X, tweak); - - /* get input block in little-endian format */ - skein_get64_lsb_first(w, blk_ptr, SKEIN_1024_STATE_WORDS); - - threefish_encrypt_block_words(&key, w, ctx->X); - - blk_ptr += SKEIN_1024_BLOCK_BYTES; - - /* do the final "feedforward" xor, update ctx chaining vars */ - ctx->X[0] = ctx->X[0] ^ w[0]; - ctx->X[1] = ctx->X[1] ^ w[1]; - ctx->X[2] = ctx->X[2] ^ w[2]; - ctx->X[3] = ctx->X[3] ^ w[3]; - ctx->X[4] = ctx->X[4] ^ w[4]; - ctx->X[5] = ctx->X[5] ^ w[5]; - ctx->X[6] = ctx->X[6] ^ w[6]; - ctx->X[7] = ctx->X[7] ^ w[7]; - ctx->X[8] = ctx->X[8] ^ w[8]; - ctx->X[9] = ctx->X[9] ^ w[9]; - ctx->X[10] = ctx->X[10] ^ w[10]; - ctx->X[11] = ctx->X[11] ^ w[11]; - ctx->X[12] = ctx->X[12] ^ w[12]; - ctx->X[13] = ctx->X[13] ^ w[13]; - ctx->X[14] = ctx->X[14] ^ w[14]; - ctx->X[15] = ctx->X[15] ^ w[15]; - - tweak[1] &= ~SKEIN_T1_FLAG_FIRST; - } while (--blk_cnt); - - ctx->h.T[0] = tweak[0]; - ctx->h.T[1] = tweak[1]; -} diff --git a/drivers/staging/skein/skein_api.c b/drivers/staging/skein/skein_api.c new file mode 100644 index 000000000000..eaf7af4c8007 --- /dev/null +++ b/drivers/staging/skein/skein_api.c @@ -0,0 +1,239 @@ +/* +Copyright (c) 2010 Werner Dittmann + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include +#include "skein_api.h" + +int skein_ctx_prepare(struct skein_ctx *ctx, enum skein_size size) +{ + skein_assert_ret(ctx && size, SKEIN_FAIL); + + memset(ctx , 0, sizeof(struct skein_ctx)); + ctx->skein_size = size; + + return SKEIN_SUCCESS; +} + +int skein_init(struct skein_ctx *ctx, size_t hash_bit_len) +{ + int ret = SKEIN_FAIL; + size_t X_len = 0; + u64 *X = NULL; + u64 tree_info = SKEIN_CFG_TREE_INFO_SEQUENTIAL; + + skein_assert_ret(ctx, SKEIN_FAIL); + /* + * The following two lines rely of the fact that the real Skein + * contexts are a union in out context and thus have tha maximum + * memory available. The beauty of C :-) . + */ + X = ctx->m.s256.X; + X_len = ctx->skein_size/8; + /* + * If size is the same and hash bit length is zero then reuse + * the save chaining variables. + */ + switch (ctx->skein_size) { + case SKEIN_256: + ret = skein_256_init_ext(&ctx->m.s256, hash_bit_len, + tree_info, NULL, 0); + break; + case SKEIN_512: + ret = skein_512_init_ext(&ctx->m.s512, hash_bit_len, + tree_info, NULL, 0); + break; + case SKEIN_1024: + ret = skein_1024_init_ext(&ctx->m.s1024, hash_bit_len, + tree_info, NULL, 0); + break; + } + + if (ret == SKEIN_SUCCESS) { + /* + * Save chaining variables for this combination of size and + * hash_bit_len + */ + memcpy(ctx->X_save, X, X_len); + } + return ret; +} + +int skein_mac_init(struct skein_ctx *ctx, const u8 *key, size_t key_len, + size_t hash_bit_len) +{ + int ret = SKEIN_FAIL; + u64 *X = NULL; + size_t X_len = 0; + u64 tree_info = SKEIN_CFG_TREE_INFO_SEQUENTIAL; + + skein_assert_ret(ctx, SKEIN_FAIL); + + X = ctx->m.s256.X; + X_len = ctx->skein_size/8; + + skein_assert_ret(hash_bit_len, SKEIN_BAD_HASHLEN); + + switch (ctx->skein_size) { + case SKEIN_256: + ret = skein_256_init_ext(&ctx->m.s256, hash_bit_len, + tree_info, + (const u8 *)key, key_len); + + break; + case SKEIN_512: + ret = skein_512_init_ext(&ctx->m.s512, hash_bit_len, + tree_info, + (const u8 *)key, key_len); + break; + case SKEIN_1024: + ret = skein_1024_init_ext(&ctx->m.s1024, hash_bit_len, + tree_info, + (const u8 *)key, key_len); + + break; + } + if (ret == SKEIN_SUCCESS) { + /* + * Save chaining variables for this combination of key, + * key_len, hash_bit_len + */ + memcpy(ctx->X_save, X, X_len); + } + return ret; +} + +void skein_reset(struct skein_ctx *ctx) +{ + size_t X_len = 0; + u64 *X = NULL; + + /* + * The following two lines rely of the fact that the real Skein + * contexts are a union in out context and thus have tha maximum + * memory available. The beautiy of C :-) . + */ + X = ctx->m.s256.X; + X_len = ctx->skein_size/8; + /* Restore the chaing variable, reset byte counter */ + memcpy(X, ctx->X_save, X_len); + + /* Setup context to process the message */ + skein_start_new_type(&ctx->m, MSG); +} + +int skein_update(struct skein_ctx *ctx, const u8 *msg, + size_t msg_byte_cnt) +{ + int ret = SKEIN_FAIL; + + skein_assert_ret(ctx, SKEIN_FAIL); + + switch (ctx->skein_size) { + case SKEIN_256: + ret = skein_256_update(&ctx->m.s256, (const u8 *)msg, + msg_byte_cnt); + break; + case SKEIN_512: + ret = skein_512_update(&ctx->m.s512, (const u8 *)msg, + msg_byte_cnt); + break; + case SKEIN_1024: + ret = skein_1024_update(&ctx->m.s1024, (const u8 *)msg, + msg_byte_cnt); + break; + } + return ret; + +} + +int skein_update_bits(struct skein_ctx *ctx, const u8 *msg, + size_t msg_bit_cnt) +{ + /* + * I've used the bit pad implementation from skein_test.c (see NIST CD) + * and modified it to use the convenience functions and added some + * pointer arithmetic. + */ + size_t length; + u8 mask; + u8 *up; + + /* + * only the final Update() call is allowed do partial bytes, else + * assert an error + */ + skein_assert_ret((ctx->m.h.T[1] & SKEIN_T1_FLAG_BIT_PAD) == 0 || + msg_bit_cnt == 0, SKEIN_FAIL); + + /* if number of bits is a multiple of bytes - that's easy */ + if ((msg_bit_cnt & 0x7) == 0) + return skein_update(ctx, msg, msg_bit_cnt >> 3); + + skein_update(ctx, msg, (msg_bit_cnt >> 3) + 1); + + /* + * The next line rely on the fact that the real Skein contexts + * are a union in our context. After the addition the pointer points to + * Skein's real partial block buffer. + * If this layout ever changes we have to adapt this as well. + */ + up = (u8 *)ctx->m.s256.X + ctx->skein_size / 8; + + /* set tweak flag for the skein_final call */ + skein_set_bit_pad_flag(ctx->m.h); + + /* now "pad" the final partial byte the way NIST likes */ + /* get the b_cnt value (same location for all block sizes) */ + length = ctx->m.h.b_cnt; + /* internal sanity check: there IS a partial byte in the buffer! */ + skein_assert(length != 0); + /* partial byte bit mask */ + mask = (u8) (1u << (7 - (msg_bit_cnt & 7))); + /* apply bit padding on final byte (in the buffer) */ + up[length-1] = (u8)((up[length-1] & (0-mask))|mask); + + return SKEIN_SUCCESS; +} + +int skein_final(struct skein_ctx *ctx, u8 *hash) +{ + int ret = SKEIN_FAIL; + + skein_assert_ret(ctx, SKEIN_FAIL); + + switch (ctx->skein_size) { + case SKEIN_256: + ret = skein_256_final(&ctx->m.s256, (u8 *)hash); + break; + case SKEIN_512: + ret = skein_512_final(&ctx->m.s512, (u8 *)hash); + break; + case SKEIN_1024: + ret = skein_1024_final(&ctx->m.s1024, (u8 *)hash); + break; + } + return ret; +} diff --git a/drivers/staging/skein/skein_api.h b/drivers/staging/skein/skein_api.h new file mode 100644 index 000000000000..db808ae434ff --- /dev/null +++ b/drivers/staging/skein/skein_api.h @@ -0,0 +1,230 @@ +/* +Copyright (c) 2010 Werner Dittmann + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef SKEINAPI_H +#define SKEINAPI_H + +/** + * @file skein_api.h + * @brief A Skein API and its functions. + * @{ + * + * This API and the functions that implement this API simplify the usage + * of Skein. The design and the way to use the functions follow the openSSL + * design but at the same time take care of some Skein specific behaviour + * and possibilities. + * + * The functions enable applications to create a normal Skein hashes and + * message authentication codes (MAC). + * + * Using these functions is simple and straight forward: + * + * @code + * + * #include "skein_api.h" + * + * ... + * struct skein_ctx ctx; // a Skein hash or MAC context + * + * // prepare context, here for a Skein with a state size of 512 bits. + * skein_ctx_prepare(&ctx, SKEIN_512); + * + * // Initialize the context to set the requested hash length in bits + * // here request a output hash size of 31 bits (Skein supports variable + * // output sizes even very strange sizes) + * skein_init(&ctx, 31); + * + * // Now update Skein with any number of message bits. A function that + * // takes a number of bytes is also available. + * skein_update_bits(&ctx, message, msg_length); + * + * // Now get the result of the Skein hash. The output buffer must be + * // large enough to hold the request number of output bits. The application + * // may now extract the bits. + * skein_final(&ctx, result); + * ... + * @endcode + * + * An application may use @c skein_reset to reset a Skein context and use + * it for creation of another hash with the same Skein state size and output + * bit length. In this case the API implementation restores some internal + * internal state data and saves a full Skein initialization round. + * + * To create a MAC the application just uses @c skein_mac_init instead of + * @c skein_init. All other functions calls remain the same. + * + */ + +#include +#include "skein.h" + +/** + * Which Skein size to use + */ +enum skein_size { + SKEIN_256 = 256, /*!< Skein with 256 bit state */ + SKEIN_512 = 512, /*!< Skein with 512 bit state */ + SKEIN_1024 = 1024 /*!< Skein with 1024 bit state */ +}; + +/** + * Context for Skein. + * + * This structure was setup with some know-how of the internal + * Skein structures, in particular ordering of header and size dependent + * variables. If Skein implementation changes this, then adapt these + * structures as well. + */ +struct skein_ctx { + u64 skein_size; + u64 X_save[SKEIN_MAX_STATE_WORDS]; /* save area for state variables */ + union { + struct skein_ctx_hdr h; + struct skein_256_ctx s256; + struct skein_512_ctx s512; + struct skein_1024_ctx s1024; + } m; +}; + +/** + * Prepare a Skein context. + * + * An application must call this function before it can use the Skein + * context. The functions clears memory and initializes size dependent + * variables. + * + * @param ctx + * Pointer to a Skein context. + * @param size + * Which Skein size to use. + * @return + * SKEIN_SUCESS of SKEIN_FAIL + */ +int skein_ctx_prepare(struct skein_ctx *ctx, enum skein_size size); + +/** + * Initialize a Skein context. + * + * Initializes the context with this data and saves the resulting Skein + * state variables for further use. + * + * @param ctx + * Pointer to a Skein context. + * @param hash_bit_len + * Number of MAC hash bits to compute + * @return + * SKEIN_SUCESS of SKEIN_FAIL + * @see skein_reset + */ +int skein_init(struct skein_ctx *ctx, size_t hash_bit_len); + +/** + * Resets a Skein context for further use. + * + * Restores the saved chaining variables to reset the Skein context. + * Thus applications can reuse the same setup to process several + * messages. This saves a complete Skein initialization cycle. + * + * @param ctx + * Pointer to a pre-initialized Skein MAC context + */ +void skein_reset(struct skein_ctx *ctx); + +/** + * Initializes a Skein context for MAC usage. + * + * Initializes the context with this data and saves the resulting Skein + * state variables for further use. + * + * Applications call the normal Skein functions to update the MAC and + * get the final result. + * + * @param ctx + * Pointer to an empty or preinitialized Skein MAC context + * @param key + * Pointer to key bytes or NULL + * @param key_len + * Length of the key in bytes or zero + * @param hash_bit_len + * Number of MAC hash bits to compute + * @return + * SKEIN_SUCESS of SKEIN_FAIL + */ +int skein_mac_init(struct skein_ctx *ctx, const u8 *key, size_t key_len, + size_t hash_bit_len); + +/** + * Update Skein with the next part of the message. + * + * @param ctx + * Pointer to initialized Skein context + * @param msg + * Pointer to the message. + * @param msg_byte_cnt + * Length of the message in @b bytes + * @return + * Success or error code. + */ +int skein_update(struct skein_ctx *ctx, const u8 *msg, + size_t msg_byte_cnt); + +/** + * Update the hash with a message bit string. + * + * Skein can handle data not only as bytes but also as bit strings of + * arbitrary length (up to its maximum design size). + * + * @param ctx + * Pointer to initialized Skein context + * @param msg + * Pointer to the message. + * @param msg_bit_cnt + * Length of the message in @b bits. + */ +int skein_update_bits(struct skein_ctx *ctx, const u8 *msg, + size_t msg_bit_cnt); + +/** + * Finalize Skein and return the hash. + * + * Before an application can reuse a Skein setup the application must + * reset the Skein context. + * + * @param ctx + * Pointer to initialized Skein context + * @param hash + * Pointer to buffer that receives the hash. The buffer must be large + * enough to store @c hash_bit_len bits. + * @return + * Success or error code. + * @see skein_reset + */ +int skein_final(struct skein_ctx *ctx, u8 *hash); + +/** + * @} + */ +#endif diff --git a/drivers/staging/skein/skein_block.c b/drivers/staging/skein/skein_block.c index 7b66ec529422..76c4113ea5c8 100644 --- a/drivers/staging/skein/skein_block.c +++ b/drivers/staging/skein/skein_block.c @@ -15,7 +15,7 @@ ************************************************************************/ #include -#include +#include "skein.h" #ifndef SKEIN_USE_ASM #define SKEIN_USE_ASM (0) /* default is all C code (no ASM) */ diff --git a/drivers/staging/skein/skein_block.h b/drivers/staging/skein/skein_block.h new file mode 100644 index 000000000000..bd7bdc35df29 --- /dev/null +++ b/drivers/staging/skein/skein_block.h @@ -0,0 +1,22 @@ +/*********************************************************************** +** +** Implementation of the Skein hash function. +** +** Source code author: Doug Whiting, 2008. +** +** This algorithm and source code is released to the public domain. +** +************************************************************************/ +#ifndef _SKEIN_BLOCK_H_ +#define _SKEIN_BLOCK_H_ + +#include "skein.h" /* get the Skein API definitions */ + +void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, + size_t blk_cnt, size_t byte_cnt_add); +void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, + size_t blk_cnt, size_t byte_cnt_add); +void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, + size_t blk_cnt, size_t byte_cnt_add); + +#endif diff --git a/drivers/staging/skein/skein_iv.h b/drivers/staging/skein/skein_iv.h new file mode 100644 index 000000000000..a03703deeaf8 --- /dev/null +++ b/drivers/staging/skein/skein_iv.h @@ -0,0 +1,186 @@ +#ifndef _SKEIN_IV_H_ +#define _SKEIN_IV_H_ + +#include "skein.h" /* get Skein macros and types */ + +/* +***************** Pre-computed Skein IVs ******************* +** +** NOTE: these values are not "magic" constants, but +** are generated using the Threefish block function. +** They are pre-computed here only for speed; i.e., to +** avoid the need for a Threefish call during Init(). +** +** The IV for any fixed hash length may be pre-computed. +** Only the most common values are included here. +** +************************************************************ +**/ + +#define MK_64 SKEIN_MK_64 + +/* blkSize = 256 bits. hashSize = 128 bits */ +const u64 SKEIN_256_IV_128[] = { + MK_64(0xE1111906, 0x964D7260), + MK_64(0x883DAAA7, 0x7C8D811C), + MK_64(0x10080DF4, 0x91960F7A), + MK_64(0xCCF7DDE5, 0xB45BC1C2) +}; + +/* blkSize = 256 bits. hashSize = 160 bits */ +const u64 SKEIN_256_IV_160[] = { + MK_64(0x14202314, 0x72825E98), + MK_64(0x2AC4E9A2, 0x5A77E590), + MK_64(0xD47A5856, 0x8838D63E), + MK_64(0x2DD2E496, 0x8586AB7D) +}; + +/* blkSize = 256 bits. hashSize = 224 bits */ +const u64 SKEIN_256_IV_224[] = { + MK_64(0xC6098A8C, 0x9AE5EA0B), + MK_64(0x876D5686, 0x08C5191C), + MK_64(0x99CB88D7, 0xD7F53884), + MK_64(0x384BDDB1, 0xAEDDB5DE) +}; + +/* blkSize = 256 bits. hashSize = 256 bits */ +const u64 SKEIN_256_IV_256[] = { + MK_64(0xFC9DA860, 0xD048B449), + MK_64(0x2FCA6647, 0x9FA7D833), + MK_64(0xB33BC389, 0x6656840F), + MK_64(0x6A54E920, 0xFDE8DA69) +}; + +/* blkSize = 512 bits. hashSize = 128 bits */ +const u64 SKEIN_512_IV_128[] = { + MK_64(0xA8BC7BF3, 0x6FBF9F52), + MK_64(0x1E9872CE, 0xBD1AF0AA), + MK_64(0x309B1790, 0xB32190D3), + MK_64(0xBCFBB854, 0x3F94805C), + MK_64(0x0DA61BCD, 0x6E31B11B), + MK_64(0x1A18EBEA, 0xD46A32E3), + MK_64(0xA2CC5B18, 0xCE84AA82), + MK_64(0x6982AB28, 0x9D46982D) +}; + +/* blkSize = 512 bits. hashSize = 160 bits */ +const u64 SKEIN_512_IV_160[] = { + MK_64(0x28B81A2A, 0xE013BD91), + MK_64(0xC2F11668, 0xB5BDF78F), + MK_64(0x1760D8F3, 0xF6A56F12), + MK_64(0x4FB74758, 0x8239904F), + MK_64(0x21EDE07F, 0x7EAF5056), + MK_64(0xD908922E, 0x63ED70B8), + MK_64(0xB8EC76FF, 0xECCB52FA), + MK_64(0x01A47BB8, 0xA3F27A6E) +}; + +/* blkSize = 512 bits. hashSize = 224 bits */ +const u64 SKEIN_512_IV_224[] = { + MK_64(0xCCD06162, 0x48677224), + MK_64(0xCBA65CF3, 0xA92339EF), + MK_64(0x8CCD69D6, 0x52FF4B64), + MK_64(0x398AED7B, 0x3AB890B4), + MK_64(0x0F59D1B1, 0x457D2BD0), + MK_64(0x6776FE65, 0x75D4EB3D), + MK_64(0x99FBC70E, 0x997413E9), + MK_64(0x9E2CFCCF, 0xE1C41EF7) +}; + +/* blkSize = 512 bits. hashSize = 256 bits */ +const u64 SKEIN_512_IV_256[] = { + MK_64(0xCCD044A1, 0x2FDB3E13), + MK_64(0xE8359030, 0x1A79A9EB), + MK_64(0x55AEA061, 0x4F816E6F), + MK_64(0x2A2767A4, 0xAE9B94DB), + MK_64(0xEC06025E, 0x74DD7683), + MK_64(0xE7A436CD, 0xC4746251), + MK_64(0xC36FBAF9, 0x393AD185), + MK_64(0x3EEDBA18, 0x33EDFC13) +}; + +/* blkSize = 512 bits. hashSize = 384 bits */ +const u64 SKEIN_512_IV_384[] = { + MK_64(0xA3F6C6BF, 0x3A75EF5F), + MK_64(0xB0FEF9CC, 0xFD84FAA4), + MK_64(0x9D77DD66, 0x3D770CFE), + MK_64(0xD798CBF3, 0xB468FDDA), + MK_64(0x1BC4A666, 0x8A0E4465), + MK_64(0x7ED7D434, 0xE5807407), + MK_64(0x548FC1AC, 0xD4EC44D6), + MK_64(0x266E1754, 0x6AA18FF8) +}; + +/* blkSize = 512 bits. hashSize = 512 bits */ +const u64 SKEIN_512_IV_512[] = { + MK_64(0x4903ADFF, 0x749C51CE), + MK_64(0x0D95DE39, 0x9746DF03), + MK_64(0x8FD19341, 0x27C79BCE), + MK_64(0x9A255629, 0xFF352CB1), + MK_64(0x5DB62599, 0xDF6CA7B0), + MK_64(0xEABE394C, 0xA9D5C3F4), + MK_64(0x991112C7, 0x1A75B523), + MK_64(0xAE18A40B, 0x660FCC33) +}; + +/* blkSize = 1024 bits. hashSize = 384 bits */ +const u64 SKEIN_1024_IV_384[] = { + MK_64(0x5102B6B8, 0xC1894A35), + MK_64(0xFEEBC9E3, 0xFE8AF11A), + MK_64(0x0C807F06, 0xE32BED71), + MK_64(0x60C13A52, 0xB41A91F6), + MK_64(0x9716D35D, 0xD4917C38), + MK_64(0xE780DF12, 0x6FD31D3A), + MK_64(0x797846B6, 0xC898303A), + MK_64(0xB172C2A8, 0xB3572A3B), + MK_64(0xC9BC8203, 0xA6104A6C), + MK_64(0x65909338, 0xD75624F4), + MK_64(0x94BCC568, 0x4B3F81A0), + MK_64(0x3EBBF51E, 0x10ECFD46), + MK_64(0x2DF50F0B, 0xEEB08542), + MK_64(0x3B5A6530, 0x0DBC6516), + MK_64(0x484B9CD2, 0x167BBCE1), + MK_64(0x2D136947, 0xD4CBAFEA) +}; + +/* blkSize = 1024 bits. hashSize = 512 bits */ +const u64 SKEIN_1024_IV_512[] = { + MK_64(0xCAEC0E5D, 0x7C1B1B18), + MK_64(0xA01B0E04, 0x5F03E802), + MK_64(0x33840451, 0xED912885), + MK_64(0x374AFB04, 0xEAEC2E1C), + MK_64(0xDF25A0E2, 0x813581F7), + MK_64(0xE4004093, 0x8B12F9D2), + MK_64(0xA662D539, 0xC2ED39B6), + MK_64(0xFA8B85CF, 0x45D8C75A), + MK_64(0x8316ED8E, 0x29EDE796), + MK_64(0x053289C0, 0x2E9F91B8), + MK_64(0xC3F8EF1D, 0x6D518B73), + MK_64(0xBDCEC3C4, 0xD5EF332E), + MK_64(0x549A7E52, 0x22974487), + MK_64(0x67070872, 0x5B749816), + MK_64(0xB9CD28FB, 0xF0581BD1), + MK_64(0x0E2940B8, 0x15804974) +}; + +/* blkSize = 1024 bits. hashSize = 1024 bits */ +const u64 SKEIN_1024_IV_1024[] = { + MK_64(0xD593DA07, 0x41E72355), + MK_64(0x15B5E511, 0xAC73E00C), + MK_64(0x5180E5AE, 0xBAF2C4F0), + MK_64(0x03BD41D3, 0xFCBCAFAF), + MK_64(0x1CAEC6FD, 0x1983A898), + MK_64(0x6E510B8B, 0xCDD0589F), + MK_64(0x77E2BDFD, 0xC6394ADA), + MK_64(0xC11E1DB5, 0x24DCB0A3), + MK_64(0xD6D14AF9, 0xC6329AB5), + MK_64(0x6A9B0BFC, 0x6EB67E0D), + MK_64(0x9243C60D, 0xCCFF1332), + MK_64(0x1A1F1DDE, 0x743F02D4), + MK_64(0x0996753C, 0x10ED0BB8), + MK_64(0x6572DD22, 0xF2B4969A), + MK_64(0x61FD3062, 0xD00A579A), + MK_64(0x1DE0536E, 0x8682E539) +}; + +#endif /* _SKEIN_IV_H_ */ diff --git a/drivers/staging/skein/threefish1024Block.c b/drivers/staging/skein/threefish1024Block.c deleted file mode 100644 index 827ce1a7b33a..000000000000 --- a/drivers/staging/skein/threefish1024Block.c +++ /dev/null @@ -1,4902 +0,0 @@ -#include -#include - - -void threefish_encrypt_1024(struct threefish_key *key_ctx, u64 *input, - u64 *output) -{ - u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3], - b4 = input[4], b5 = input[5], - b6 = input[6], b7 = input[7], - b8 = input[8], b9 = input[9], - b10 = input[10], b11 = input[11], - b12 = input[12], b13 = input[13], - b14 = input[14], b15 = input[15]; - u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], - k2 = key_ctx->key[2], k3 = key_ctx->key[3], - k4 = key_ctx->key[4], k5 = key_ctx->key[5], - k6 = key_ctx->key[6], k7 = key_ctx->key[7], - k8 = key_ctx->key[8], k9 = key_ctx->key[9], - k10 = key_ctx->key[10], k11 = key_ctx->key[11], - k12 = key_ctx->key[12], k13 = key_ctx->key[13], - k14 = key_ctx->key[14], k15 = key_ctx->key[15], - k16 = key_ctx->key[16]; - u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], - t2 = key_ctx->tweak[2]; - - b1 += k1; - b0 += b1 + k0; - b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - - b3 += k3; - b2 += b3 + k2; - b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - - b5 += k5; - b4 += b5 + k4; - b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - - b7 += k7; - b6 += b7 + k6; - b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - - b9 += k9; - b8 += b9 + k8; - b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - - b11 += k11; - b10 += b11 + k10; - b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - - b13 += k13 + t0; - b12 += b13 + k12; - b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - - b15 += k15; - b14 += b15 + k14 + t1; - b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - - b0 += b9; - b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - - b2 += b13; - b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - - b6 += b11; - b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - - b4 += b15; - b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - - b10 += b7; - b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - - b12 += b3; - b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - - b14 += b5; - b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - - b8 += b1; - b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - - b0 += b7; - b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - - b2 += b5; - b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - - b4 += b3; - b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - - b6 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - - b12 += b15; - b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - - b14 += b13; - b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - - b8 += b11; - b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - - b10 += b9; - b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - - b0 += b15; - b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - - b2 += b11; - b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - - b6 += b13; - b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - - b4 += b9; - b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - - b14 += b1; - b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - - b8 += b5; - b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - - b10 += b3; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - - b12 += b7; - b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - - b1 += k2; - b0 += b1 + k1; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - - b3 += k4; - b2 += b3 + k3; - b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - - b5 += k6; - b4 += b5 + k5; - b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - - b7 += k8; - b6 += b7 + k7; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - - b9 += k10; - b8 += b9 + k9; - b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - - b11 += k12; - b10 += b11 + k11; - b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - - b13 += k14 + t1; - b12 += b13 + k13; - b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - - b15 += k16 + 1; - b14 += b15 + k15 + t2; - b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - - b0 += b9; - b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - - b2 += b13; - b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - - b6 += b11; - b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - - b4 += b15; - b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - - b10 += b7; - b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - - b12 += b3; - b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - - b14 += b5; - b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - - b8 += b1; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - - b0 += b7; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - - b2 += b5; - b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - - b4 += b3; - b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - - b6 += b1; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - - b12 += b15; - b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - - b14 += b13; - b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - - b8 += b11; - b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - - b10 += b9; - b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - - b0 += b15; - b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - - b2 += b11; - b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - - b6 += b13; - b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - - b4 += b9; - b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - - b14 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - - b8 += b5; - b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - - b10 += b3; - b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - - b12 += b7; - b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - - b1 += k3; - b0 += b1 + k2; - b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - - b3 += k5; - b2 += b3 + k4; - b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - - b5 += k7; - b4 += b5 + k6; - b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - - b7 += k9; - b6 += b7 + k8; - b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - - b9 += k11; - b8 += b9 + k10; - b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - - b11 += k13; - b10 += b11 + k12; - b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - - b13 += k15 + t2; - b12 += b13 + k14; - b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - - b15 += k0 + 2; - b14 += b15 + k16 + t0; - b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - - b0 += b9; - b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - - b2 += b13; - b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - - b6 += b11; - b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - - b4 += b15; - b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - - b10 += b7; - b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - - b12 += b3; - b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - - b14 += b5; - b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - - b8 += b1; - b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - - b0 += b7; - b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - - b2 += b5; - b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - - b4 += b3; - b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - - b6 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - - b12 += b15; - b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - - b14 += b13; - b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - - b8 += b11; - b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - - b10 += b9; - b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - - b0 += b15; - b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - - b2 += b11; - b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - - b6 += b13; - b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - - b4 += b9; - b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - - b14 += b1; - b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - - b8 += b5; - b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - - b10 += b3; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - - b12 += b7; - b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - - b1 += k4; - b0 += b1 + k3; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - - b3 += k6; - b2 += b3 + k5; - b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - - b5 += k8; - b4 += b5 + k7; - b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - - b7 += k10; - b6 += b7 + k9; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - - b9 += k12; - b8 += b9 + k11; - b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - - b11 += k14; - b10 += b11 + k13; - b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - - b13 += k16 + t0; - b12 += b13 + k15; - b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - - b15 += k1 + 3; - b14 += b15 + k0 + t1; - b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - - b0 += b9; - b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - - b2 += b13; - b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - - b6 += b11; - b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - - b4 += b15; - b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - - b10 += b7; - b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - - b12 += b3; - b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - - b14 += b5; - b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - - b8 += b1; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - - b0 += b7; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - - b2 += b5; - b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - - b4 += b3; - b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - - b6 += b1; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - - b12 += b15; - b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - - b14 += b13; - b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - - b8 += b11; - b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - - b10 += b9; - b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - - b0 += b15; - b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - - b2 += b11; - b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - - b6 += b13; - b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - - b4 += b9; - b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - - b14 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - - b8 += b5; - b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - - b10 += b3; - b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - - b12 += b7; - b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - - b1 += k5; - b0 += b1 + k4; - b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - - b3 += k7; - b2 += b3 + k6; - b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - - b5 += k9; - b4 += b5 + k8; - b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - - b7 += k11; - b6 += b7 + k10; - b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - - b9 += k13; - b8 += b9 + k12; - b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - - b11 += k15; - b10 += b11 + k14; - b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - - b13 += k0 + t1; - b12 += b13 + k16; - b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - - b15 += k2 + 4; - b14 += b15 + k1 + t2; - b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - - b0 += b9; - b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - - b2 += b13; - b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - - b6 += b11; - b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - - b4 += b15; - b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - - b10 += b7; - b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - - b12 += b3; - b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - - b14 += b5; - b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - - b8 += b1; - b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - - b0 += b7; - b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - - b2 += b5; - b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - - b4 += b3; - b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - - b6 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - - b12 += b15; - b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - - b14 += b13; - b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - - b8 += b11; - b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - - b10 += b9; - b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - - b0 += b15; - b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - - b2 += b11; - b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - - b6 += b13; - b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - - b4 += b9; - b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - - b14 += b1; - b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - - b8 += b5; - b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - - b10 += b3; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - - b12 += b7; - b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - - b1 += k6; - b0 += b1 + k5; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - - b3 += k8; - b2 += b3 + k7; - b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - - b5 += k10; - b4 += b5 + k9; - b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - - b7 += k12; - b6 += b7 + k11; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - - b9 += k14; - b8 += b9 + k13; - b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - - b11 += k16; - b10 += b11 + k15; - b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - - b13 += k1 + t2; - b12 += b13 + k0; - b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - - b15 += k3 + 5; - b14 += b15 + k2 + t0; - b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - - b0 += b9; - b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - - b2 += b13; - b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - - b6 += b11; - b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - - b4 += b15; - b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - - b10 += b7; - b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - - b12 += b3; - b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - - b14 += b5; - b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - - b8 += b1; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - - b0 += b7; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - - b2 += b5; - b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - - b4 += b3; - b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - - b6 += b1; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - - b12 += b15; - b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - - b14 += b13; - b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - - b8 += b11; - b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - - b10 += b9; - b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - - b0 += b15; - b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - - b2 += b11; - b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - - b6 += b13; - b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - - b4 += b9; - b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - - b14 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - - b8 += b5; - b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - - b10 += b3; - b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - - b12 += b7; - b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - - b1 += k7; - b0 += b1 + k6; - b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - - b3 += k9; - b2 += b3 + k8; - b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - - b5 += k11; - b4 += b5 + k10; - b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - - b7 += k13; - b6 += b7 + k12; - b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - - b9 += k15; - b8 += b9 + k14; - b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - - b11 += k0; - b10 += b11 + k16; - b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - - b13 += k2 + t0; - b12 += b13 + k1; - b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - - b15 += k4 + 6; - b14 += b15 + k3 + t1; - b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - - b0 += b9; - b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - - b2 += b13; - b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - - b6 += b11; - b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - - b4 += b15; - b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - - b10 += b7; - b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - - b12 += b3; - b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - - b14 += b5; - b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - - b8 += b1; - b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - - b0 += b7; - b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - - b2 += b5; - b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - - b4 += b3; - b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - - b6 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - - b12 += b15; - b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - - b14 += b13; - b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - - b8 += b11; - b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - - b10 += b9; - b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - - b0 += b15; - b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - - b2 += b11; - b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - - b6 += b13; - b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - - b4 += b9; - b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - - b14 += b1; - b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - - b8 += b5; - b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - - b10 += b3; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - - b12 += b7; - b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - - b1 += k8; - b0 += b1 + k7; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - - b3 += k10; - b2 += b3 + k9; - b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - - b5 += k12; - b4 += b5 + k11; - b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - - b7 += k14; - b6 += b7 + k13; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - - b9 += k16; - b8 += b9 + k15; - b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - - b11 += k1; - b10 += b11 + k0; - b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - - b13 += k3 + t1; - b12 += b13 + k2; - b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - - b15 += k5 + 7; - b14 += b15 + k4 + t2; - b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - - b0 += b9; - b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - - b2 += b13; - b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - - b6 += b11; - b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - - b4 += b15; - b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - - b10 += b7; - b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - - b12 += b3; - b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - - b14 += b5; - b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - - b8 += b1; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - - b0 += b7; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - - b2 += b5; - b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - - b4 += b3; - b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - - b6 += b1; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - - b12 += b15; - b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - - b14 += b13; - b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - - b8 += b11; - b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - - b10 += b9; - b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - - b0 += b15; - b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - - b2 += b11; - b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - - b6 += b13; - b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - - b4 += b9; - b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - - b14 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - - b8 += b5; - b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - - b10 += b3; - b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - - b12 += b7; - b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - - b1 += k9; - b0 += b1 + k8; - b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - - b3 += k11; - b2 += b3 + k10; - b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - - b5 += k13; - b4 += b5 + k12; - b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - - b7 += k15; - b6 += b7 + k14; - b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - - b9 += k0; - b8 += b9 + k16; - b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - - b11 += k2; - b10 += b11 + k1; - b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - - b13 += k4 + t2; - b12 += b13 + k3; - b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - - b15 += k6 + 8; - b14 += b15 + k5 + t0; - b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - - b0 += b9; - b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - - b2 += b13; - b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - - b6 += b11; - b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - - b4 += b15; - b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - - b10 += b7; - b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - - b12 += b3; - b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - - b14 += b5; - b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - - b8 += b1; - b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - - b0 += b7; - b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - - b2 += b5; - b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - - b4 += b3; - b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - - b6 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - - b12 += b15; - b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - - b14 += b13; - b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - - b8 += b11; - b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - - b10 += b9; - b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - - b0 += b15; - b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - - b2 += b11; - b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - - b6 += b13; - b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - - b4 += b9; - b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - - b14 += b1; - b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - - b8 += b5; - b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - - b10 += b3; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - - b12 += b7; - b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - - b1 += k10; - b0 += b1 + k9; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - - b3 += k12; - b2 += b3 + k11; - b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - - b5 += k14; - b4 += b5 + k13; - b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - - b7 += k16; - b6 += b7 + k15; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - - b9 += k1; - b8 += b9 + k0; - b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - - b11 += k3; - b10 += b11 + k2; - b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - - b13 += k5 + t0; - b12 += b13 + k4; - b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - - b15 += k7 + 9; - b14 += b15 + k6 + t1; - b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - - b0 += b9; - b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - - b2 += b13; - b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - - b6 += b11; - b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - - b4 += b15; - b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - - b10 += b7; - b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - - b12 += b3; - b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - - b14 += b5; - b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - - b8 += b1; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - - b0 += b7; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - - b2 += b5; - b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - - b4 += b3; - b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - - b6 += b1; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - - b12 += b15; - b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - - b14 += b13; - b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - - b8 += b11; - b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - - b10 += b9; - b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - - b0 += b15; - b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - - b2 += b11; - b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - - b6 += b13; - b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - - b4 += b9; - b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - - b14 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - - b8 += b5; - b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - - b10 += b3; - b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - - b12 += b7; - b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - - b1 += k11; - b0 += b1 + k10; - b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - - b3 += k13; - b2 += b3 + k12; - b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - - b5 += k15; - b4 += b5 + k14; - b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - - b7 += k0; - b6 += b7 + k16; - b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - - b9 += k2; - b8 += b9 + k1; - b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - - b11 += k4; - b10 += b11 + k3; - b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - - b13 += k6 + t1; - b12 += b13 + k5; - b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - - b15 += k8 + 10; - b14 += b15 + k7 + t2; - b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - - b0 += b9; - b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - - b2 += b13; - b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - - b6 += b11; - b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - - b4 += b15; - b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - - b10 += b7; - b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - - b12 += b3; - b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - - b14 += b5; - b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - - b8 += b1; - b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - - b0 += b7; - b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - - b2 += b5; - b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - - b4 += b3; - b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - - b6 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - - b12 += b15; - b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - - b14 += b13; - b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - - b8 += b11; - b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - - b10 += b9; - b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - - b0 += b15; - b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - - b2 += b11; - b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - - b6 += b13; - b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - - b4 += b9; - b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - - b14 += b1; - b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - - b8 += b5; - b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - - b10 += b3; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - - b12 += b7; - b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - - b1 += k12; - b0 += b1 + k11; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - - b3 += k14; - b2 += b3 + k13; - b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - - b5 += k16; - b4 += b5 + k15; - b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - - b7 += k1; - b6 += b7 + k0; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - - b9 += k3; - b8 += b9 + k2; - b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - - b11 += k5; - b10 += b11 + k4; - b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - - b13 += k7 + t2; - b12 += b13 + k6; - b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - - b15 += k9 + 11; - b14 += b15 + k8 + t0; - b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - - b0 += b9; - b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - - b2 += b13; - b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - - b6 += b11; - b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - - b4 += b15; - b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - - b10 += b7; - b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - - b12 += b3; - b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - - b14 += b5; - b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - - b8 += b1; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - - b0 += b7; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - - b2 += b5; - b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - - b4 += b3; - b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - - b6 += b1; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - - b12 += b15; - b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - - b14 += b13; - b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - - b8 += b11; - b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - - b10 += b9; - b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - - b0 += b15; - b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - - b2 += b11; - b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - - b6 += b13; - b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - - b4 += b9; - b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - - b14 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - - b8 += b5; - b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - - b10 += b3; - b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - - b12 += b7; - b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - - b1 += k13; - b0 += b1 + k12; - b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - - b3 += k15; - b2 += b3 + k14; - b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - - b5 += k0; - b4 += b5 + k16; - b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - - b7 += k2; - b6 += b7 + k1; - b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - - b9 += k4; - b8 += b9 + k3; - b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - - b11 += k6; - b10 += b11 + k5; - b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - - b13 += k8 + t0; - b12 += b13 + k7; - b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - - b15 += k10 + 12; - b14 += b15 + k9 + t1; - b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - - b0 += b9; - b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - - b2 += b13; - b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - - b6 += b11; - b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - - b4 += b15; - b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - - b10 += b7; - b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - - b12 += b3; - b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - - b14 += b5; - b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - - b8 += b1; - b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - - b0 += b7; - b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - - b2 += b5; - b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - - b4 += b3; - b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - - b6 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - - b12 += b15; - b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - - b14 += b13; - b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - - b8 += b11; - b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - - b10 += b9; - b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - - b0 += b15; - b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - - b2 += b11; - b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - - b6 += b13; - b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - - b4 += b9; - b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - - b14 += b1; - b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - - b8 += b5; - b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - - b10 += b3; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - - b12 += b7; - b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - - b1 += k14; - b0 += b1 + k13; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - - b3 += k16; - b2 += b3 + k15; - b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - - b5 += k1; - b4 += b5 + k0; - b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - - b7 += k3; - b6 += b7 + k2; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - - b9 += k5; - b8 += b9 + k4; - b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - - b11 += k7; - b10 += b11 + k6; - b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - - b13 += k9 + t1; - b12 += b13 + k8; - b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - - b15 += k11 + 13; - b14 += b15 + k10 + t2; - b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - - b0 += b9; - b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - - b2 += b13; - b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - - b6 += b11; - b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - - b4 += b15; - b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - - b10 += b7; - b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - - b12 += b3; - b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - - b14 += b5; - b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - - b8 += b1; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - - b0 += b7; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - - b2 += b5; - b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - - b4 += b3; - b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - - b6 += b1; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - - b12 += b15; - b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - - b14 += b13; - b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - - b8 += b11; - b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - - b10 += b9; - b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - - b0 += b15; - b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - - b2 += b11; - b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - - b6 += b13; - b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - - b4 += b9; - b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - - b14 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - - b8 += b5; - b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - - b10 += b3; - b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - - b12 += b7; - b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - - b1 += k15; - b0 += b1 + k14; - b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - - b3 += k0; - b2 += b3 + k16; - b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - - b5 += k2; - b4 += b5 + k1; - b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - - b7 += k4; - b6 += b7 + k3; - b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - - b9 += k6; - b8 += b9 + k5; - b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - - b11 += k8; - b10 += b11 + k7; - b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - - b13 += k10 + t2; - b12 += b13 + k9; - b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - - b15 += k12 + 14; - b14 += b15 + k11 + t0; - b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - - b0 += b9; - b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - - b2 += b13; - b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - - b6 += b11; - b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - - b4 += b15; - b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - - b10 += b7; - b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - - b12 += b3; - b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - - b14 += b5; - b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - - b8 += b1; - b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - - b0 += b7; - b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - - b2 += b5; - b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - - b4 += b3; - b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - - b6 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - - b12 += b15; - b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - - b14 += b13; - b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - - b8 += b11; - b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - - b10 += b9; - b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - - b0 += b15; - b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - - b2 += b11; - b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - - b6 += b13; - b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - - b4 += b9; - b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - - b14 += b1; - b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - - b8 += b5; - b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - - b10 += b3; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - - b12 += b7; - b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - - b1 += k16; - b0 += b1 + k15; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - - b3 += k1; - b2 += b3 + k0; - b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - - b5 += k3; - b4 += b5 + k2; - b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - - b7 += k5; - b6 += b7 + k4; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - - b9 += k7; - b8 += b9 + k6; - b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - - b11 += k9; - b10 += b11 + k8; - b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - - b13 += k11 + t0; - b12 += b13 + k10; - b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - - b15 += k13 + 15; - b14 += b15 + k12 + t1; - b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - - b0 += b9; - b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - - b2 += b13; - b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - - b6 += b11; - b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - - b4 += b15; - b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - - b10 += b7; - b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - - b12 += b3; - b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - - b14 += b5; - b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - - b8 += b1; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - - b0 += b7; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - - b2 += b5; - b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - - b4 += b3; - b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - - b6 += b1; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - - b12 += b15; - b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - - b14 += b13; - b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - - b8 += b11; - b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - - b10 += b9; - b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - - b0 += b15; - b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - - b2 += b11; - b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - - b6 += b13; - b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - - b4 += b9; - b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - - b14 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - - b8 += b5; - b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - - b10 += b3; - b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - - b12 += b7; - b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - - b1 += k0; - b0 += b1 + k16; - b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - - b3 += k2; - b2 += b3 + k1; - b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - - b5 += k4; - b4 += b5 + k3; - b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - - b7 += k6; - b6 += b7 + k5; - b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - - b9 += k8; - b8 += b9 + k7; - b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - - b11 += k10; - b10 += b11 + k9; - b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - - b13 += k12 + t1; - b12 += b13 + k11; - b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - - b15 += k14 + 16; - b14 += b15 + k13 + t2; - b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - - b0 += b9; - b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - - b2 += b13; - b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - - b6 += b11; - b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - - b4 += b15; - b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - - b10 += b7; - b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - - b12 += b3; - b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - - b14 += b5; - b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - - b8 += b1; - b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - - b0 += b7; - b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - - b2 += b5; - b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - - b4 += b3; - b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - - b6 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - - b12 += b15; - b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - - b14 += b13; - b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - - b8 += b11; - b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - - b10 += b9; - b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - - b0 += b15; - b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - - b2 += b11; - b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - - b6 += b13; - b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - - b4 += b9; - b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - - b14 += b1; - b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - - b8 += b5; - b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - - b10 += b3; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - - b12 += b7; - b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - - b1 += k1; - b0 += b1 + k0; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - - b3 += k3; - b2 += b3 + k2; - b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - - b5 += k5; - b4 += b5 + k4; - b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - - b7 += k7; - b6 += b7 + k6; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - - b9 += k9; - b8 += b9 + k8; - b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - - b11 += k11; - b10 += b11 + k10; - b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - - b13 += k13 + t2; - b12 += b13 + k12; - b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - - b15 += k15 + 17; - b14 += b15 + k14 + t0; - b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - - b0 += b9; - b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - - b2 += b13; - b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - - b6 += b11; - b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - - b4 += b15; - b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - - b10 += b7; - b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - - b12 += b3; - b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - - b14 += b5; - b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - - b8 += b1; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - - b0 += b7; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - - b2 += b5; - b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - - b4 += b3; - b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - - b6 += b1; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - - b12 += b15; - b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - - b14 += b13; - b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - - b8 += b11; - b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - - b10 += b9; - b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - - b0 += b15; - b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - - b2 += b11; - b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - - b6 += b13; - b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - - b4 += b9; - b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - - b14 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - - b8 += b5; - b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - - b10 += b3; - b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - - b12 += b7; - b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - - b1 += k2; - b0 += b1 + k1; - b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - - b3 += k4; - b2 += b3 + k3; - b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - - b5 += k6; - b4 += b5 + k5; - b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - - b7 += k8; - b6 += b7 + k7; - b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - - b9 += k10; - b8 += b9 + k9; - b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - - b11 += k12; - b10 += b11 + k11; - b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - - b13 += k14 + t0; - b12 += b13 + k13; - b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - - b15 += k16 + 18; - b14 += b15 + k15 + t1; - b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - - b0 += b9; - b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - - b2 += b13; - b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - - b6 += b11; - b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - - b4 += b15; - b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - - b10 += b7; - b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - - b12 += b3; - b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - - b14 += b5; - b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - - b8 += b1; - b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - - b0 += b7; - b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - - b2 += b5; - b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - - b4 += b3; - b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - - b6 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - - b12 += b15; - b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - - b14 += b13; - b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - - b8 += b11; - b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - - b10 += b9; - b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - - b0 += b15; - b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - - b2 += b11; - b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - - b6 += b13; - b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - - b4 += b9; - b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - - b14 += b1; - b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - - b8 += b5; - b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - - b10 += b3; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - - b12 += b7; - b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - - b1 += k3; - b0 += b1 + k2; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - - b3 += k5; - b2 += b3 + k4; - b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - - b5 += k7; - b4 += b5 + k6; - b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - - b7 += k9; - b6 += b7 + k8; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - - b9 += k11; - b8 += b9 + k10; - b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - - b11 += k13; - b10 += b11 + k12; - b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - - b13 += k15 + t1; - b12 += b13 + k14; - b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - - b15 += k0 + 19; - b14 += b15 + k16 + t2; - b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - - b0 += b9; - b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - - b2 += b13; - b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - - b6 += b11; - b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - - b4 += b15; - b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - - b10 += b7; - b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - - b12 += b3; - b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - - b14 += b5; - b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - - b8 += b1; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - - b0 += b7; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - - b2 += b5; - b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - - b4 += b3; - b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - - b6 += b1; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - - b12 += b15; - b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - - b14 += b13; - b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - - b8 += b11; - b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - - b10 += b9; - b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - - b0 += b15; - b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - - b2 += b11; - b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - - b6 += b13; - b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - - b4 += b9; - b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - - b14 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - - b8 += b5; - b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - - b10 += b3; - b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - - b12 += b7; - b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - - output[0] = b0 + k3; - output[1] = b1 + k4; - output[2] = b2 + k5; - output[3] = b3 + k6; - output[4] = b4 + k7; - output[5] = b5 + k8; - output[6] = b6 + k9; - output[7] = b7 + k10; - output[8] = b8 + k11; - output[9] = b9 + k12; - output[10] = b10 + k13; - output[11] = b11 + k14; - output[12] = b12 + k15; - output[13] = b13 + k16 + t2; - output[14] = b14 + k0 + t0; - output[15] = b15 + k1 + 20; -} - -void threefish_decrypt_1024(struct threefish_key *key_ctx, u64 *input, - u64 *output) -{ - u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3], - b4 = input[4], b5 = input[5], - b6 = input[6], b7 = input[7], - b8 = input[8], b9 = input[9], - b10 = input[10], b11 = input[11], - b12 = input[12], b13 = input[13], - b14 = input[14], b15 = input[15]; - u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], - k2 = key_ctx->key[2], k3 = key_ctx->key[3], - k4 = key_ctx->key[4], k5 = key_ctx->key[5], - k6 = key_ctx->key[6], k7 = key_ctx->key[7], - k8 = key_ctx->key[8], k9 = key_ctx->key[9], - k10 = key_ctx->key[10], k11 = key_ctx->key[11], - k12 = key_ctx->key[12], k13 = key_ctx->key[13], - k14 = key_ctx->key[14], k15 = key_ctx->key[15], - k16 = key_ctx->key[16]; - u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], - t2 = key_ctx->tweak[2]; - u64 tmp; - - b0 -= k3; - b1 -= k4; - b2 -= k5; - b3 -= k6; - b4 -= k7; - b5 -= k8; - b6 -= k9; - b7 -= k10; - b8 -= k11; - b9 -= k12; - b10 -= k13; - b11 -= k14; - b12 -= k15; - b13 -= k16 + t2; - b14 -= k0 + t0; - b15 -= k1 + 20; - tmp = b7 ^ b12; - b7 = (tmp >> 20) | (tmp << (64 - 20)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 37) | (tmp << (64 - 37)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 31) | (tmp << (64 - 31)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 52) | (tmp << (64 - 52)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 35) | (tmp << (64 - 35)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 48) | (tmp << (64 - 48)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 25) | (tmp << (64 - 25)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 44) | (tmp << (64 - 44)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 19) | (tmp << (64 - 19)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 47) | (tmp << (64 - 47)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 44) | (tmp << (64 - 44)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 53) | (tmp << (64 - 53)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 4) | (tmp << (64 - 4)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 56) | (tmp << (64 - 56)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 34) | (tmp << (64 - 34)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 16) | (tmp << (64 - 16)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 30) | (tmp << (64 - 30)); - b14 -= b15 + k16 + t2; - b15 -= k0 + 19; - - tmp = b13 ^ b12; - b13 = (tmp >> 44) | (tmp << (64 - 44)); - b12 -= b13 + k14; - b13 -= k15 + t1; - - tmp = b11 ^ b10; - b11 = (tmp >> 47) | (tmp << (64 - 47)); - b10 -= b11 + k12; - b11 -= k13; - - tmp = b9 ^ b8; - b9 = (tmp >> 12) | (tmp << (64 - 12)); - b8 -= b9 + k10; - b9 -= k11; - - tmp = b7 ^ b6; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b6 -= b7 + k8; - b7 -= k9; - - tmp = b5 ^ b4; - b5 = (tmp >> 37) | (tmp << (64 - 37)); - b4 -= b5 + k6; - b5 -= k7; - - tmp = b3 ^ b2; - b3 = (tmp >> 9) | (tmp << (64 - 9)); - b2 -= b3 + k4; - b3 -= k5; - - tmp = b1 ^ b0; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b0 -= b1 + k2; - b1 -= k3; - - tmp = b7 ^ b12; - b7 = (tmp >> 25) | (tmp << (64 - 25)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 28) | (tmp << (64 - 28)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 47) | (tmp << (64 - 47)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 41) | (tmp << (64 - 41)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 48) | (tmp << (64 - 48)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 20) | (tmp << (64 - 20)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 59) | (tmp << (64 - 59)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 41) | (tmp << (64 - 41)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 34) | (tmp << (64 - 34)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 4) | (tmp << (64 - 4)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 33) | (tmp << (64 - 33)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 52) | (tmp << (64 - 52)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 18) | (tmp << (64 - 18)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 49) | (tmp << (64 - 49)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 55) | (tmp << (64 - 55)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 19) | (tmp << (64 - 19)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 38) | (tmp << (64 - 38)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 37) | (tmp << (64 - 37)); - b14 -= b15 + k15 + t1; - b15 -= k16 + 18; - - tmp = b13 ^ b12; - b13 = (tmp >> 22) | (tmp << (64 - 22)); - b12 -= b13 + k13; - b13 -= k14 + t0; - - tmp = b11 ^ b10; - b11 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b11 + k11; - b11 -= k12; - - tmp = b9 ^ b8; - b9 = (tmp >> 8) | (tmp << (64 - 8)); - b8 -= b9 + k9; - b9 -= k10; - - tmp = b7 ^ b6; - b7 = (tmp >> 47) | (tmp << (64 - 47)); - b6 -= b7 + k7; - b7 -= k8; - - tmp = b5 ^ b4; - b5 = (tmp >> 8) | (tmp << (64 - 8)); - b4 -= b5 + k5; - b5 -= k6; - - tmp = b3 ^ b2; - b3 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b3 + k3; - b3 -= k4; - - tmp = b1 ^ b0; - b1 = (tmp >> 24) | (tmp << (64 - 24)); - b0 -= b1 + k1; - b1 -= k2; - - tmp = b7 ^ b12; - b7 = (tmp >> 20) | (tmp << (64 - 20)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 37) | (tmp << (64 - 37)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 31) | (tmp << (64 - 31)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 52) | (tmp << (64 - 52)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 35) | (tmp << (64 - 35)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 48) | (tmp << (64 - 48)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 25) | (tmp << (64 - 25)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 44) | (tmp << (64 - 44)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 19) | (tmp << (64 - 19)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 47) | (tmp << (64 - 47)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 44) | (tmp << (64 - 44)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 53) | (tmp << (64 - 53)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 4) | (tmp << (64 - 4)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 56) | (tmp << (64 - 56)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 34) | (tmp << (64 - 34)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 16) | (tmp << (64 - 16)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 30) | (tmp << (64 - 30)); - b14 -= b15 + k14 + t0; - b15 -= k15 + 17; - - tmp = b13 ^ b12; - b13 = (tmp >> 44) | (tmp << (64 - 44)); - b12 -= b13 + k12; - b13 -= k13 + t2; - - tmp = b11 ^ b10; - b11 = (tmp >> 47) | (tmp << (64 - 47)); - b10 -= b11 + k10; - b11 -= k11; - - tmp = b9 ^ b8; - b9 = (tmp >> 12) | (tmp << (64 - 12)); - b8 -= b9 + k8; - b9 -= k9; - - tmp = b7 ^ b6; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b6 -= b7 + k6; - b7 -= k7; - - tmp = b5 ^ b4; - b5 = (tmp >> 37) | (tmp << (64 - 37)); - b4 -= b5 + k4; - b5 -= k5; - - tmp = b3 ^ b2; - b3 = (tmp >> 9) | (tmp << (64 - 9)); - b2 -= b3 + k2; - b3 -= k3; - - tmp = b1 ^ b0; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b0 -= b1 + k0; - b1 -= k1; - - tmp = b7 ^ b12; - b7 = (tmp >> 25) | (tmp << (64 - 25)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 28) | (tmp << (64 - 28)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 47) | (tmp << (64 - 47)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 41) | (tmp << (64 - 41)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 48) | (tmp << (64 - 48)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 20) | (tmp << (64 - 20)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 59) | (tmp << (64 - 59)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 41) | (tmp << (64 - 41)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 34) | (tmp << (64 - 34)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 4) | (tmp << (64 - 4)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 33) | (tmp << (64 - 33)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 52) | (tmp << (64 - 52)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 18) | (tmp << (64 - 18)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 49) | (tmp << (64 - 49)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 55) | (tmp << (64 - 55)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 19) | (tmp << (64 - 19)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 38) | (tmp << (64 - 38)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 37) | (tmp << (64 - 37)); - b14 -= b15 + k13 + t2; - b15 -= k14 + 16; - - tmp = b13 ^ b12; - b13 = (tmp >> 22) | (tmp << (64 - 22)); - b12 -= b13 + k11; - b13 -= k12 + t1; - - tmp = b11 ^ b10; - b11 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b11 + k9; - b11 -= k10; - - tmp = b9 ^ b8; - b9 = (tmp >> 8) | (tmp << (64 - 8)); - b8 -= b9 + k7; - b9 -= k8; - - tmp = b7 ^ b6; - b7 = (tmp >> 47) | (tmp << (64 - 47)); - b6 -= b7 + k5; - b7 -= k6; - - tmp = b5 ^ b4; - b5 = (tmp >> 8) | (tmp << (64 - 8)); - b4 -= b5 + k3; - b5 -= k4; - - tmp = b3 ^ b2; - b3 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b3 + k1; - b3 -= k2; - - tmp = b1 ^ b0; - b1 = (tmp >> 24) | (tmp << (64 - 24)); - b0 -= b1 + k16; - b1 -= k0; - - tmp = b7 ^ b12; - b7 = (tmp >> 20) | (tmp << (64 - 20)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 37) | (tmp << (64 - 37)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 31) | (tmp << (64 - 31)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 52) | (tmp << (64 - 52)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 35) | (tmp << (64 - 35)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 48) | (tmp << (64 - 48)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 25) | (tmp << (64 - 25)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 44) | (tmp << (64 - 44)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 19) | (tmp << (64 - 19)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 47) | (tmp << (64 - 47)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 44) | (tmp << (64 - 44)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 53) | (tmp << (64 - 53)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 4) | (tmp << (64 - 4)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 56) | (tmp << (64 - 56)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 34) | (tmp << (64 - 34)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 16) | (tmp << (64 - 16)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 30) | (tmp << (64 - 30)); - b14 -= b15 + k12 + t1; - b15 -= k13 + 15; - - tmp = b13 ^ b12; - b13 = (tmp >> 44) | (tmp << (64 - 44)); - b12 -= b13 + k10; - b13 -= k11 + t0; - - tmp = b11 ^ b10; - b11 = (tmp >> 47) | (tmp << (64 - 47)); - b10 -= b11 + k8; - b11 -= k9; - - tmp = b9 ^ b8; - b9 = (tmp >> 12) | (tmp << (64 - 12)); - b8 -= b9 + k6; - b9 -= k7; - - tmp = b7 ^ b6; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b6 -= b7 + k4; - b7 -= k5; - - tmp = b5 ^ b4; - b5 = (tmp >> 37) | (tmp << (64 - 37)); - b4 -= b5 + k2; - b5 -= k3; - - tmp = b3 ^ b2; - b3 = (tmp >> 9) | (tmp << (64 - 9)); - b2 -= b3 + k0; - b3 -= k1; - - tmp = b1 ^ b0; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b0 -= b1 + k15; - b1 -= k16; - - tmp = b7 ^ b12; - b7 = (tmp >> 25) | (tmp << (64 - 25)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 28) | (tmp << (64 - 28)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 47) | (tmp << (64 - 47)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 41) | (tmp << (64 - 41)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 48) | (tmp << (64 - 48)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 20) | (tmp << (64 - 20)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 59) | (tmp << (64 - 59)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 41) | (tmp << (64 - 41)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 34) | (tmp << (64 - 34)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 4) | (tmp << (64 - 4)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 33) | (tmp << (64 - 33)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 52) | (tmp << (64 - 52)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 18) | (tmp << (64 - 18)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 49) | (tmp << (64 - 49)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 55) | (tmp << (64 - 55)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 19) | (tmp << (64 - 19)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 38) | (tmp << (64 - 38)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 37) | (tmp << (64 - 37)); - b14 -= b15 + k11 + t0; - b15 -= k12 + 14; - - tmp = b13 ^ b12; - b13 = (tmp >> 22) | (tmp << (64 - 22)); - b12 -= b13 + k9; - b13 -= k10 + t2; - - tmp = b11 ^ b10; - b11 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b11 + k7; - b11 -= k8; - - tmp = b9 ^ b8; - b9 = (tmp >> 8) | (tmp << (64 - 8)); - b8 -= b9 + k5; - b9 -= k6; - - tmp = b7 ^ b6; - b7 = (tmp >> 47) | (tmp << (64 - 47)); - b6 -= b7 + k3; - b7 -= k4; - - tmp = b5 ^ b4; - b5 = (tmp >> 8) | (tmp << (64 - 8)); - b4 -= b5 + k1; - b5 -= k2; - - tmp = b3 ^ b2; - b3 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b3 + k16; - b3 -= k0; - - tmp = b1 ^ b0; - b1 = (tmp >> 24) | (tmp << (64 - 24)); - b0 -= b1 + k14; - b1 -= k15; - - tmp = b7 ^ b12; - b7 = (tmp >> 20) | (tmp << (64 - 20)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 37) | (tmp << (64 - 37)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 31) | (tmp << (64 - 31)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 52) | (tmp << (64 - 52)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 35) | (tmp << (64 - 35)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 48) | (tmp << (64 - 48)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 25) | (tmp << (64 - 25)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 44) | (tmp << (64 - 44)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 19) | (tmp << (64 - 19)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 47) | (tmp << (64 - 47)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 44) | (tmp << (64 - 44)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 53) | (tmp << (64 - 53)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 4) | (tmp << (64 - 4)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 56) | (tmp << (64 - 56)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 34) | (tmp << (64 - 34)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 16) | (tmp << (64 - 16)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 30) | (tmp << (64 - 30)); - b14 -= b15 + k10 + t2; - b15 -= k11 + 13; - - tmp = b13 ^ b12; - b13 = (tmp >> 44) | (tmp << (64 - 44)); - b12 -= b13 + k8; - b13 -= k9 + t1; - - tmp = b11 ^ b10; - b11 = (tmp >> 47) | (tmp << (64 - 47)); - b10 -= b11 + k6; - b11 -= k7; - - tmp = b9 ^ b8; - b9 = (tmp >> 12) | (tmp << (64 - 12)); - b8 -= b9 + k4; - b9 -= k5; - - tmp = b7 ^ b6; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b6 -= b7 + k2; - b7 -= k3; - - tmp = b5 ^ b4; - b5 = (tmp >> 37) | (tmp << (64 - 37)); - b4 -= b5 + k0; - b5 -= k1; - - tmp = b3 ^ b2; - b3 = (tmp >> 9) | (tmp << (64 - 9)); - b2 -= b3 + k15; - b3 -= k16; - - tmp = b1 ^ b0; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b0 -= b1 + k13; - b1 -= k14; - - tmp = b7 ^ b12; - b7 = (tmp >> 25) | (tmp << (64 - 25)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 28) | (tmp << (64 - 28)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 47) | (tmp << (64 - 47)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 41) | (tmp << (64 - 41)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 48) | (tmp << (64 - 48)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 20) | (tmp << (64 - 20)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 59) | (tmp << (64 - 59)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 41) | (tmp << (64 - 41)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 34) | (tmp << (64 - 34)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 4) | (tmp << (64 - 4)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 33) | (tmp << (64 - 33)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 52) | (tmp << (64 - 52)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 18) | (tmp << (64 - 18)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 49) | (tmp << (64 - 49)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 55) | (tmp << (64 - 55)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 19) | (tmp << (64 - 19)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 38) | (tmp << (64 - 38)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 37) | (tmp << (64 - 37)); - b14 -= b15 + k9 + t1; - b15 -= k10 + 12; - - tmp = b13 ^ b12; - b13 = (tmp >> 22) | (tmp << (64 - 22)); - b12 -= b13 + k7; - b13 -= k8 + t0; - - tmp = b11 ^ b10; - b11 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b11 + k5; - b11 -= k6; - - tmp = b9 ^ b8; - b9 = (tmp >> 8) | (tmp << (64 - 8)); - b8 -= b9 + k3; - b9 -= k4; - - tmp = b7 ^ b6; - b7 = (tmp >> 47) | (tmp << (64 - 47)); - b6 -= b7 + k1; - b7 -= k2; - - tmp = b5 ^ b4; - b5 = (tmp >> 8) | (tmp << (64 - 8)); - b4 -= b5 + k16; - b5 -= k0; - - tmp = b3 ^ b2; - b3 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b3 + k14; - b3 -= k15; - - tmp = b1 ^ b0; - b1 = (tmp >> 24) | (tmp << (64 - 24)); - b0 -= b1 + k12; - b1 -= k13; - - tmp = b7 ^ b12; - b7 = (tmp >> 20) | (tmp << (64 - 20)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 37) | (tmp << (64 - 37)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 31) | (tmp << (64 - 31)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 52) | (tmp << (64 - 52)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 35) | (tmp << (64 - 35)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 48) | (tmp << (64 - 48)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 25) | (tmp << (64 - 25)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 44) | (tmp << (64 - 44)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 19) | (tmp << (64 - 19)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 47) | (tmp << (64 - 47)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 44) | (tmp << (64 - 44)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 53) | (tmp << (64 - 53)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 4) | (tmp << (64 - 4)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 56) | (tmp << (64 - 56)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 34) | (tmp << (64 - 34)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 16) | (tmp << (64 - 16)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 30) | (tmp << (64 - 30)); - b14 -= b15 + k8 + t0; - b15 -= k9 + 11; - - tmp = b13 ^ b12; - b13 = (tmp >> 44) | (tmp << (64 - 44)); - b12 -= b13 + k6; - b13 -= k7 + t2; - - tmp = b11 ^ b10; - b11 = (tmp >> 47) | (tmp << (64 - 47)); - b10 -= b11 + k4; - b11 -= k5; - - tmp = b9 ^ b8; - b9 = (tmp >> 12) | (tmp << (64 - 12)); - b8 -= b9 + k2; - b9 -= k3; - - tmp = b7 ^ b6; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b6 -= b7 + k0; - b7 -= k1; - - tmp = b5 ^ b4; - b5 = (tmp >> 37) | (tmp << (64 - 37)); - b4 -= b5 + k15; - b5 -= k16; - - tmp = b3 ^ b2; - b3 = (tmp >> 9) | (tmp << (64 - 9)); - b2 -= b3 + k13; - b3 -= k14; - - tmp = b1 ^ b0; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b0 -= b1 + k11; - b1 -= k12; - - tmp = b7 ^ b12; - b7 = (tmp >> 25) | (tmp << (64 - 25)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 28) | (tmp << (64 - 28)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 47) | (tmp << (64 - 47)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 41) | (tmp << (64 - 41)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 48) | (tmp << (64 - 48)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 20) | (tmp << (64 - 20)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 59) | (tmp << (64 - 59)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 41) | (tmp << (64 - 41)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 34) | (tmp << (64 - 34)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 4) | (tmp << (64 - 4)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 33) | (tmp << (64 - 33)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 52) | (tmp << (64 - 52)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 18) | (tmp << (64 - 18)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 49) | (tmp << (64 - 49)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 55) | (tmp << (64 - 55)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 19) | (tmp << (64 - 19)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 38) | (tmp << (64 - 38)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 37) | (tmp << (64 - 37)); - b14 -= b15 + k7 + t2; - b15 -= k8 + 10; - - tmp = b13 ^ b12; - b13 = (tmp >> 22) | (tmp << (64 - 22)); - b12 -= b13 + k5; - b13 -= k6 + t1; - - tmp = b11 ^ b10; - b11 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b11 + k3; - b11 -= k4; - - tmp = b9 ^ b8; - b9 = (tmp >> 8) | (tmp << (64 - 8)); - b8 -= b9 + k1; - b9 -= k2; - - tmp = b7 ^ b6; - b7 = (tmp >> 47) | (tmp << (64 - 47)); - b6 -= b7 + k16; - b7 -= k0; - - tmp = b5 ^ b4; - b5 = (tmp >> 8) | (tmp << (64 - 8)); - b4 -= b5 + k14; - b5 -= k15; - - tmp = b3 ^ b2; - b3 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b3 + k12; - b3 -= k13; - - tmp = b1 ^ b0; - b1 = (tmp >> 24) | (tmp << (64 - 24)); - b0 -= b1 + k10; - b1 -= k11; - - tmp = b7 ^ b12; - b7 = (tmp >> 20) | (tmp << (64 - 20)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 37) | (tmp << (64 - 37)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 31) | (tmp << (64 - 31)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 52) | (tmp << (64 - 52)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 35) | (tmp << (64 - 35)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 48) | (tmp << (64 - 48)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 25) | (tmp << (64 - 25)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 44) | (tmp << (64 - 44)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 19) | (tmp << (64 - 19)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 47) | (tmp << (64 - 47)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 44) | (tmp << (64 - 44)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 53) | (tmp << (64 - 53)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 4) | (tmp << (64 - 4)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 56) | (tmp << (64 - 56)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 34) | (tmp << (64 - 34)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 16) | (tmp << (64 - 16)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 30) | (tmp << (64 - 30)); - b14 -= b15 + k6 + t1; - b15 -= k7 + 9; - - tmp = b13 ^ b12; - b13 = (tmp >> 44) | (tmp << (64 - 44)); - b12 -= b13 + k4; - b13 -= k5 + t0; - - tmp = b11 ^ b10; - b11 = (tmp >> 47) | (tmp << (64 - 47)); - b10 -= b11 + k2; - b11 -= k3; - - tmp = b9 ^ b8; - b9 = (tmp >> 12) | (tmp << (64 - 12)); - b8 -= b9 + k0; - b9 -= k1; - - tmp = b7 ^ b6; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b6 -= b7 + k15; - b7 -= k16; - - tmp = b5 ^ b4; - b5 = (tmp >> 37) | (tmp << (64 - 37)); - b4 -= b5 + k13; - b5 -= k14; - - tmp = b3 ^ b2; - b3 = (tmp >> 9) | (tmp << (64 - 9)); - b2 -= b3 + k11; - b3 -= k12; - - tmp = b1 ^ b0; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b0 -= b1 + k9; - b1 -= k10; - - tmp = b7 ^ b12; - b7 = (tmp >> 25) | (tmp << (64 - 25)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 28) | (tmp << (64 - 28)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 47) | (tmp << (64 - 47)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 41) | (tmp << (64 - 41)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 48) | (tmp << (64 - 48)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 20) | (tmp << (64 - 20)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 59) | (tmp << (64 - 59)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 41) | (tmp << (64 - 41)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 34) | (tmp << (64 - 34)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 4) | (tmp << (64 - 4)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 33) | (tmp << (64 - 33)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 52) | (tmp << (64 - 52)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 18) | (tmp << (64 - 18)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 49) | (tmp << (64 - 49)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 55) | (tmp << (64 - 55)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 19) | (tmp << (64 - 19)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 38) | (tmp << (64 - 38)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 37) | (tmp << (64 - 37)); - b14 -= b15 + k5 + t0; - b15 -= k6 + 8; - - tmp = b13 ^ b12; - b13 = (tmp >> 22) | (tmp << (64 - 22)); - b12 -= b13 + k3; - b13 -= k4 + t2; - - tmp = b11 ^ b10; - b11 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b11 + k1; - b11 -= k2; - - tmp = b9 ^ b8; - b9 = (tmp >> 8) | (tmp << (64 - 8)); - b8 -= b9 + k16; - b9 -= k0; - - tmp = b7 ^ b6; - b7 = (tmp >> 47) | (tmp << (64 - 47)); - b6 -= b7 + k14; - b7 -= k15; - - tmp = b5 ^ b4; - b5 = (tmp >> 8) | (tmp << (64 - 8)); - b4 -= b5 + k12; - b5 -= k13; - - tmp = b3 ^ b2; - b3 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b3 + k10; - b3 -= k11; - - tmp = b1 ^ b0; - b1 = (tmp >> 24) | (tmp << (64 - 24)); - b0 -= b1 + k8; - b1 -= k9; - - tmp = b7 ^ b12; - b7 = (tmp >> 20) | (tmp << (64 - 20)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 37) | (tmp << (64 - 37)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 31) | (tmp << (64 - 31)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 52) | (tmp << (64 - 52)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 35) | (tmp << (64 - 35)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 48) | (tmp << (64 - 48)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 25) | (tmp << (64 - 25)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 44) | (tmp << (64 - 44)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 19) | (tmp << (64 - 19)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 47) | (tmp << (64 - 47)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 44) | (tmp << (64 - 44)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 53) | (tmp << (64 - 53)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 4) | (tmp << (64 - 4)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 56) | (tmp << (64 - 56)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 34) | (tmp << (64 - 34)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 16) | (tmp << (64 - 16)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 30) | (tmp << (64 - 30)); - b14 -= b15 + k4 + t2; - b15 -= k5 + 7; - - tmp = b13 ^ b12; - b13 = (tmp >> 44) | (tmp << (64 - 44)); - b12 -= b13 + k2; - b13 -= k3 + t1; - - tmp = b11 ^ b10; - b11 = (tmp >> 47) | (tmp << (64 - 47)); - b10 -= b11 + k0; - b11 -= k1; - - tmp = b9 ^ b8; - b9 = (tmp >> 12) | (tmp << (64 - 12)); - b8 -= b9 + k15; - b9 -= k16; - - tmp = b7 ^ b6; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b6 -= b7 + k13; - b7 -= k14; - - tmp = b5 ^ b4; - b5 = (tmp >> 37) | (tmp << (64 - 37)); - b4 -= b5 + k11; - b5 -= k12; - - tmp = b3 ^ b2; - b3 = (tmp >> 9) | (tmp << (64 - 9)); - b2 -= b3 + k9; - b3 -= k10; - - tmp = b1 ^ b0; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b0 -= b1 + k7; - b1 -= k8; - - tmp = b7 ^ b12; - b7 = (tmp >> 25) | (tmp << (64 - 25)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 28) | (tmp << (64 - 28)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 47) | (tmp << (64 - 47)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 41) | (tmp << (64 - 41)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 48) | (tmp << (64 - 48)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 20) | (tmp << (64 - 20)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 59) | (tmp << (64 - 59)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 41) | (tmp << (64 - 41)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 34) | (tmp << (64 - 34)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 4) | (tmp << (64 - 4)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 33) | (tmp << (64 - 33)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 52) | (tmp << (64 - 52)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 18) | (tmp << (64 - 18)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 49) | (tmp << (64 - 49)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 55) | (tmp << (64 - 55)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 19) | (tmp << (64 - 19)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 38) | (tmp << (64 - 38)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 37) | (tmp << (64 - 37)); - b14 -= b15 + k3 + t1; - b15 -= k4 + 6; - - tmp = b13 ^ b12; - b13 = (tmp >> 22) | (tmp << (64 - 22)); - b12 -= b13 + k1; - b13 -= k2 + t0; - - tmp = b11 ^ b10; - b11 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b11 + k16; - b11 -= k0; - - tmp = b9 ^ b8; - b9 = (tmp >> 8) | (tmp << (64 - 8)); - b8 -= b9 + k14; - b9 -= k15; - - tmp = b7 ^ b6; - b7 = (tmp >> 47) | (tmp << (64 - 47)); - b6 -= b7 + k12; - b7 -= k13; - - tmp = b5 ^ b4; - b5 = (tmp >> 8) | (tmp << (64 - 8)); - b4 -= b5 + k10; - b5 -= k11; - - tmp = b3 ^ b2; - b3 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b3 + k8; - b3 -= k9; - - tmp = b1 ^ b0; - b1 = (tmp >> 24) | (tmp << (64 - 24)); - b0 -= b1 + k6; - b1 -= k7; - - tmp = b7 ^ b12; - b7 = (tmp >> 20) | (tmp << (64 - 20)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 37) | (tmp << (64 - 37)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 31) | (tmp << (64 - 31)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 52) | (tmp << (64 - 52)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 35) | (tmp << (64 - 35)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 48) | (tmp << (64 - 48)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 25) | (tmp << (64 - 25)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 44) | (tmp << (64 - 44)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 19) | (tmp << (64 - 19)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 47) | (tmp << (64 - 47)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 44) | (tmp << (64 - 44)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 53) | (tmp << (64 - 53)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 4) | (tmp << (64 - 4)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 56) | (tmp << (64 - 56)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 34) | (tmp << (64 - 34)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 16) | (tmp << (64 - 16)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 30) | (tmp << (64 - 30)); - b14 -= b15 + k2 + t0; - b15 -= k3 + 5; - - tmp = b13 ^ b12; - b13 = (tmp >> 44) | (tmp << (64 - 44)); - b12 -= b13 + k0; - b13 -= k1 + t2; - - tmp = b11 ^ b10; - b11 = (tmp >> 47) | (tmp << (64 - 47)); - b10 -= b11 + k15; - b11 -= k16; - - tmp = b9 ^ b8; - b9 = (tmp >> 12) | (tmp << (64 - 12)); - b8 -= b9 + k13; - b9 -= k14; - - tmp = b7 ^ b6; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b6 -= b7 + k11; - b7 -= k12; - - tmp = b5 ^ b4; - b5 = (tmp >> 37) | (tmp << (64 - 37)); - b4 -= b5 + k9; - b5 -= k10; - - tmp = b3 ^ b2; - b3 = (tmp >> 9) | (tmp << (64 - 9)); - b2 -= b3 + k7; - b3 -= k8; - - tmp = b1 ^ b0; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b0 -= b1 + k5; - b1 -= k6; - - tmp = b7 ^ b12; - b7 = (tmp >> 25) | (tmp << (64 - 25)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 28) | (tmp << (64 - 28)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 47) | (tmp << (64 - 47)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 41) | (tmp << (64 - 41)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 48) | (tmp << (64 - 48)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 20) | (tmp << (64 - 20)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 59) | (tmp << (64 - 59)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 41) | (tmp << (64 - 41)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 34) | (tmp << (64 - 34)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 4) | (tmp << (64 - 4)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 33) | (tmp << (64 - 33)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 52) | (tmp << (64 - 52)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 18) | (tmp << (64 - 18)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 49) | (tmp << (64 - 49)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 55) | (tmp << (64 - 55)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 19) | (tmp << (64 - 19)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 38) | (tmp << (64 - 38)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 37) | (tmp << (64 - 37)); - b14 -= b15 + k1 + t2; - b15 -= k2 + 4; - - tmp = b13 ^ b12; - b13 = (tmp >> 22) | (tmp << (64 - 22)); - b12 -= b13 + k16; - b13 -= k0 + t1; - - tmp = b11 ^ b10; - b11 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b11 + k14; - b11 -= k15; - - tmp = b9 ^ b8; - b9 = (tmp >> 8) | (tmp << (64 - 8)); - b8 -= b9 + k12; - b9 -= k13; - - tmp = b7 ^ b6; - b7 = (tmp >> 47) | (tmp << (64 - 47)); - b6 -= b7 + k10; - b7 -= k11; - - tmp = b5 ^ b4; - b5 = (tmp >> 8) | (tmp << (64 - 8)); - b4 -= b5 + k8; - b5 -= k9; - - tmp = b3 ^ b2; - b3 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b3 + k6; - b3 -= k7; - - tmp = b1 ^ b0; - b1 = (tmp >> 24) | (tmp << (64 - 24)); - b0 -= b1 + k4; - b1 -= k5; - - tmp = b7 ^ b12; - b7 = (tmp >> 20) | (tmp << (64 - 20)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 37) | (tmp << (64 - 37)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 31) | (tmp << (64 - 31)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 52) | (tmp << (64 - 52)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 35) | (tmp << (64 - 35)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 48) | (tmp << (64 - 48)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 25) | (tmp << (64 - 25)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 44) | (tmp << (64 - 44)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 19) | (tmp << (64 - 19)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 47) | (tmp << (64 - 47)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 44) | (tmp << (64 - 44)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 53) | (tmp << (64 - 53)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 4) | (tmp << (64 - 4)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 56) | (tmp << (64 - 56)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 34) | (tmp << (64 - 34)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 16) | (tmp << (64 - 16)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 30) | (tmp << (64 - 30)); - b14 -= b15 + k0 + t1; - b15 -= k1 + 3; - - tmp = b13 ^ b12; - b13 = (tmp >> 44) | (tmp << (64 - 44)); - b12 -= b13 + k15; - b13 -= k16 + t0; - - tmp = b11 ^ b10; - b11 = (tmp >> 47) | (tmp << (64 - 47)); - b10 -= b11 + k13; - b11 -= k14; - - tmp = b9 ^ b8; - b9 = (tmp >> 12) | (tmp << (64 - 12)); - b8 -= b9 + k11; - b9 -= k12; - - tmp = b7 ^ b6; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b6 -= b7 + k9; - b7 -= k10; - - tmp = b5 ^ b4; - b5 = (tmp >> 37) | (tmp << (64 - 37)); - b4 -= b5 + k7; - b5 -= k8; - - tmp = b3 ^ b2; - b3 = (tmp >> 9) | (tmp << (64 - 9)); - b2 -= b3 + k5; - b3 -= k6; - - tmp = b1 ^ b0; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b0 -= b1 + k3; - b1 -= k4; - - tmp = b7 ^ b12; - b7 = (tmp >> 25) | (tmp << (64 - 25)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 28) | (tmp << (64 - 28)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 47) | (tmp << (64 - 47)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 41) | (tmp << (64 - 41)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 48) | (tmp << (64 - 48)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 20) | (tmp << (64 - 20)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 59) | (tmp << (64 - 59)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 41) | (tmp << (64 - 41)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 34) | (tmp << (64 - 34)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 4) | (tmp << (64 - 4)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 33) | (tmp << (64 - 33)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 52) | (tmp << (64 - 52)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 18) | (tmp << (64 - 18)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 49) | (tmp << (64 - 49)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 55) | (tmp << (64 - 55)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 19) | (tmp << (64 - 19)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 38) | (tmp << (64 - 38)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 37) | (tmp << (64 - 37)); - b14 -= b15 + k16 + t0; - b15 -= k0 + 2; - - tmp = b13 ^ b12; - b13 = (tmp >> 22) | (tmp << (64 - 22)); - b12 -= b13 + k14; - b13 -= k15 + t2; - - tmp = b11 ^ b10; - b11 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b11 + k12; - b11 -= k13; - - tmp = b9 ^ b8; - b9 = (tmp >> 8) | (tmp << (64 - 8)); - b8 -= b9 + k10; - b9 -= k11; - - tmp = b7 ^ b6; - b7 = (tmp >> 47) | (tmp << (64 - 47)); - b6 -= b7 + k8; - b7 -= k9; - - tmp = b5 ^ b4; - b5 = (tmp >> 8) | (tmp << (64 - 8)); - b4 -= b5 + k6; - b5 -= k7; - - tmp = b3 ^ b2; - b3 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b3 + k4; - b3 -= k5; - - tmp = b1 ^ b0; - b1 = (tmp >> 24) | (tmp << (64 - 24)); - b0 -= b1 + k2; - b1 -= k3; - - tmp = b7 ^ b12; - b7 = (tmp >> 20) | (tmp << (64 - 20)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 37) | (tmp << (64 - 37)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 31) | (tmp << (64 - 31)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 52) | (tmp << (64 - 52)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 35) | (tmp << (64 - 35)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 48) | (tmp << (64 - 48)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 25) | (tmp << (64 - 25)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 44) | (tmp << (64 - 44)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 19) | (tmp << (64 - 19)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 47) | (tmp << (64 - 47)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 44) | (tmp << (64 - 44)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 53) | (tmp << (64 - 53)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 4) | (tmp << (64 - 4)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 56) | (tmp << (64 - 56)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 34) | (tmp << (64 - 34)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 16) | (tmp << (64 - 16)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 30) | (tmp << (64 - 30)); - b14 -= b15 + k15 + t2; - b15 -= k16 + 1; - - tmp = b13 ^ b12; - b13 = (tmp >> 44) | (tmp << (64 - 44)); - b12 -= b13 + k13; - b13 -= k14 + t1; - - tmp = b11 ^ b10; - b11 = (tmp >> 47) | (tmp << (64 - 47)); - b10 -= b11 + k11; - b11 -= k12; - - tmp = b9 ^ b8; - b9 = (tmp >> 12) | (tmp << (64 - 12)); - b8 -= b9 + k9; - b9 -= k10; - - tmp = b7 ^ b6; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b6 -= b7 + k7; - b7 -= k8; - - tmp = b5 ^ b4; - b5 = (tmp >> 37) | (tmp << (64 - 37)); - b4 -= b5 + k5; - b5 -= k6; - - tmp = b3 ^ b2; - b3 = (tmp >> 9) | (tmp << (64 - 9)); - b2 -= b3 + k3; - b3 -= k4; - - tmp = b1 ^ b0; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b0 -= b1 + k1; - b1 -= k2; - - tmp = b7 ^ b12; - b7 = (tmp >> 25) | (tmp << (64 - 25)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 28) | (tmp << (64 - 28)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 47) | (tmp << (64 - 47)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 41) | (tmp << (64 - 41)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 48) | (tmp << (64 - 48)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 20) | (tmp << (64 - 20)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 59) | (tmp << (64 - 59)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 41) | (tmp << (64 - 41)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 34) | (tmp << (64 - 34)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 4) | (tmp << (64 - 4)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 33) | (tmp << (64 - 33)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 52) | (tmp << (64 - 52)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 18) | (tmp << (64 - 18)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 49) | (tmp << (64 - 49)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 55) | (tmp << (64 - 55)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 19) | (tmp << (64 - 19)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 38) | (tmp << (64 - 38)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 37) | (tmp << (64 - 37)); - b14 -= b15 + k14 + t1; - b15 -= k15; - - tmp = b13 ^ b12; - b13 = (tmp >> 22) | (tmp << (64 - 22)); - b12 -= b13 + k12; - b13 -= k13 + t0; - - tmp = b11 ^ b10; - b11 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b11 + k10; - b11 -= k11; - - tmp = b9 ^ b8; - b9 = (tmp >> 8) | (tmp << (64 - 8)); - b8 -= b9 + k8; - b9 -= k9; - - tmp = b7 ^ b6; - b7 = (tmp >> 47) | (tmp << (64 - 47)); - b6 -= b7 + k6; - b7 -= k7; - - tmp = b5 ^ b4; - b5 = (tmp >> 8) | (tmp << (64 - 8)); - b4 -= b5 + k4; - b5 -= k5; - - tmp = b3 ^ b2; - b3 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b3 + k2; - b3 -= k3; - - tmp = b1 ^ b0; - b1 = (tmp >> 24) | (tmp << (64 - 24)); - b0 -= b1 + k0; - b1 -= k1; - - output[15] = b15; - output[14] = b14; - output[13] = b13; - output[12] = b12; - output[11] = b11; - output[10] = b10; - output[9] = b9; - output[8] = b8; - output[7] = b7; - output[6] = b6; - output[5] = b5; - output[4] = b4; - output[3] = b3; - output[2] = b2; - output[1] = b1; - output[0] = b0; -} diff --git a/drivers/staging/skein/threefish256Block.c b/drivers/staging/skein/threefish256Block.c deleted file mode 100644 index 1329c71697ed..000000000000 --- a/drivers/staging/skein/threefish256Block.c +++ /dev/null @@ -1,1139 +0,0 @@ -#include -#include - - -void threefish_encrypt_256(struct threefish_key *key_ctx, u64 *input, - u64 *output) -{ - u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3]; - u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], - k2 = key_ctx->key[2], k3 = key_ctx->key[3], - k4 = key_ctx->key[4]; - u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], - t2 = key_ctx->tweak[2]; - - b1 += k1 + t0; - b0 += b1 + k0; - b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - - b3 += k3; - b2 += b3 + k2 + t1; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - - b0 += b3; - b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - - b2 += b1; - b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - - b0 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - - b2 += b3; - b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - - b0 += b3; - b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - - b2 += b1; - b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - - b1 += k2 + t1; - b0 += b1 + k1; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - - b3 += k4 + 1; - b2 += b3 + k3 + t2; - b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - - b0 += b3; - b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - - b2 += b1; - b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - - b0 += b1; - b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - - b2 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - - b0 += b3; - b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - - b2 += b1; - b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - - - b1 += k3 + t2; - b0 += b1 + k2; - b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - - b3 += k0 + 2; - b2 += b3 + k4 + t0; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - - b0 += b3; - b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - - b2 += b1; - b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - - b0 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - - b2 += b3; - b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - - b0 += b3; - b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - - b2 += b1; - b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - - b1 += k4 + t0; - b0 += b1 + k3; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - - b3 += k1 + 3; - b2 += b3 + k0 + t1; - b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - - b0 += b3; - b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - - b2 += b1; - b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - - b0 += b1; - b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - - b2 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - - b0 += b3; - b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - - b2 += b1; - b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - - - b1 += k0 + t1; - b0 += b1 + k4; - b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - - b3 += k2 + 4; - b2 += b3 + k1 + t2; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - - b0 += b3; - b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - - b2 += b1; - b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - - b0 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - - b2 += b3; - b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - - b0 += b3; - b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - - b2 += b1; - b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - - b1 += k1 + t2; - b0 += b1 + k0; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - - b3 += k3 + 5; - b2 += b3 + k2 + t0; - b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - - b0 += b3; - b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - - b2 += b1; - b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - - b0 += b1; - b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - - b2 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - - b0 += b3; - b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - - b2 += b1; - b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - - - b1 += k2 + t0; - b0 += b1 + k1; - b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - - b3 += k4 + 6; - b2 += b3 + k3 + t1; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - - b0 += b3; - b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - - b2 += b1; - b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - - b0 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - - b2 += b3; - b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - - b0 += b3; - b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - - b2 += b1; - b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - - b1 += k3 + t1; - b0 += b1 + k2; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - - b3 += k0 + 7; - b2 += b3 + k4 + t2; - b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - - b0 += b3; - b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - - b2 += b1; - b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - - b0 += b1; - b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - - b2 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - - b0 += b3; - b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - - b2 += b1; - b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - - - b1 += k4 + t2; - b0 += b1 + k3; - b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - - b3 += k1 + 8; - b2 += b3 + k0 + t0; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - - b0 += b3; - b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - - b2 += b1; - b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - - b0 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - - b2 += b3; - b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - - b0 += b3; - b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - - b2 += b1; - b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - - b1 += k0 + t0; - b0 += b1 + k4; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - - b3 += k2 + 9; - b2 += b3 + k1 + t1; - b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - - b0 += b3; - b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - - b2 += b1; - b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - - b0 += b1; - b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - - b2 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - - b0 += b3; - b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - - b2 += b1; - b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - - - b1 += k1 + t1; - b0 += b1 + k0; - b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - - b3 += k3 + 10; - b2 += b3 + k2 + t2; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - - b0 += b3; - b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - - b2 += b1; - b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - - b0 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - - b2 += b3; - b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - - b0 += b3; - b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - - b2 += b1; - b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - - b1 += k2 + t2; - b0 += b1 + k1; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - - b3 += k4 + 11; - b2 += b3 + k3 + t0; - b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - - b0 += b3; - b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - - b2 += b1; - b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - - b0 += b1; - b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - - b2 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - - b0 += b3; - b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - - b2 += b1; - b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - - - b1 += k3 + t0; - b0 += b1 + k2; - b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - - b3 += k0 + 12; - b2 += b3 + k4 + t1; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - - b0 += b3; - b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - - b2 += b1; - b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - - b0 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - - b2 += b3; - b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - - b0 += b3; - b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - - b2 += b1; - b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - - b1 += k4 + t1; - b0 += b1 + k3; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - - b3 += k1 + 13; - b2 += b3 + k0 + t2; - b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - - b0 += b3; - b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - - b2 += b1; - b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - - b0 += b1; - b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - - b2 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - - b0 += b3; - b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - - b2 += b1; - b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - - - b1 += k0 + t2; - b0 += b1 + k4; - b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - - b3 += k2 + 14; - b2 += b3 + k1 + t0; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - - b0 += b3; - b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - - b2 += b1; - b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - - b0 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - - b2 += b3; - b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - - b0 += b3; - b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - - b2 += b1; - b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - - b1 += k1 + t0; - b0 += b1 + k0; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - - b3 += k3 + 15; - b2 += b3 + k2 + t1; - b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - - b0 += b3; - b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - - b2 += b1; - b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - - b0 += b1; - b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - - b2 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - - b0 += b3; - b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - - b2 += b1; - b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - - - b1 += k2 + t1; - b0 += b1 + k1; - b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - - b3 += k4 + 16; - b2 += b3 + k3 + t2; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - - b0 += b3; - b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - - b2 += b1; - b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - - b0 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - - b2 += b3; - b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - - b0 += b3; - b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - - b2 += b1; - b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - - b1 += k3 + t2; - b0 += b1 + k2; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - - b3 += k0 + 17; - b2 += b3 + k4 + t0; - b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - - b0 += b3; - b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - - b2 += b1; - b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - - b0 += b1; - b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - - b2 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - - b0 += b3; - b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - - b2 += b1; - b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - - output[0] = b0 + k3; - output[1] = b1 + k4 + t0; - output[2] = b2 + k0 + t1; - output[3] = b3 + k1 + 18; -} - -void threefish_decrypt_256(struct threefish_key *key_ctx, u64 *input, - u64 *output) -{ - u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3]; - u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], - k2 = key_ctx->key[2], k3 = key_ctx->key[3], - k4 = key_ctx->key[4]; - u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], - t2 = key_ctx->tweak[2]; - - u64 tmp; - - b0 -= k3; - b1 -= k4 + t0; - b2 -= k0 + t1; - b3 -= k1 + 18; - tmp = b3 ^ b0; - b3 = (tmp >> 32) | (tmp << (64 - 32)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 32) | (tmp << (64 - 32)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 58) | (tmp << (64 - 58)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 12) | (tmp << (64 - 12)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b0 -= b1 + k2; - b1 -= k3 + t2; - - tmp = b3 ^ b2; - b3 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b3 + k4 + t0; - b3 -= k0 + 17; - - tmp = b3 ^ b0; - b3 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 37) | (tmp << (64 - 37)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 40) | (tmp << (64 - 40)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 52) | (tmp << (64 - 52)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 57) | (tmp << (64 - 57)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 14) | (tmp << (64 - 14)); - b0 -= b1 + k1; - b1 -= k2 + t1; - - tmp = b3 ^ b2; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b2 -= b3 + k3 + t2; - b3 -= k4 + 16; - - - tmp = b3 ^ b0; - b3 = (tmp >> 32) | (tmp << (64 - 32)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 32) | (tmp << (64 - 32)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 58) | (tmp << (64 - 58)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 12) | (tmp << (64 - 12)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b0 -= b1 + k0; - b1 -= k1 + t0; - - tmp = b3 ^ b2; - b3 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b3 + k2 + t1; - b3 -= k3 + 15; - - tmp = b3 ^ b0; - b3 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 37) | (tmp << (64 - 37)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 40) | (tmp << (64 - 40)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 52) | (tmp << (64 - 52)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 57) | (tmp << (64 - 57)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 14) | (tmp << (64 - 14)); - b0 -= b1 + k4; - b1 -= k0 + t2; - - tmp = b3 ^ b2; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b2 -= b3 + k1 + t0; - b3 -= k2 + 14; - - - tmp = b3 ^ b0; - b3 = (tmp >> 32) | (tmp << (64 - 32)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 32) | (tmp << (64 - 32)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 58) | (tmp << (64 - 58)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 12) | (tmp << (64 - 12)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b0 -= b1 + k3; - b1 -= k4 + t1; - - tmp = b3 ^ b2; - b3 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b3 + k0 + t2; - b3 -= k1 + 13; - - tmp = b3 ^ b0; - b3 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 37) | (tmp << (64 - 37)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 40) | (tmp << (64 - 40)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 52) | (tmp << (64 - 52)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 57) | (tmp << (64 - 57)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 14) | (tmp << (64 - 14)); - b0 -= b1 + k2; - b1 -= k3 + t0; - - tmp = b3 ^ b2; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b2 -= b3 + k4 + t1; - b3 -= k0 + 12; - - - tmp = b3 ^ b0; - b3 = (tmp >> 32) | (tmp << (64 - 32)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 32) | (tmp << (64 - 32)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 58) | (tmp << (64 - 58)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 12) | (tmp << (64 - 12)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b0 -= b1 + k1; - b1 -= k2 + t2; - - tmp = b3 ^ b2; - b3 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b3 + k3 + t0; - b3 -= k4 + 11; - - tmp = b3 ^ b0; - b3 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 37) | (tmp << (64 - 37)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 40) | (tmp << (64 - 40)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 52) | (tmp << (64 - 52)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 57) | (tmp << (64 - 57)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 14) | (tmp << (64 - 14)); - b0 -= b1 + k0; - b1 -= k1 + t1; - - tmp = b3 ^ b2; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b2 -= b3 + k2 + t2; - b3 -= k3 + 10; - - - tmp = b3 ^ b0; - b3 = (tmp >> 32) | (tmp << (64 - 32)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 32) | (tmp << (64 - 32)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 58) | (tmp << (64 - 58)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 12) | (tmp << (64 - 12)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b0 -= b1 + k4; - b1 -= k0 + t0; - - tmp = b3 ^ b2; - b3 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b3 + k1 + t1; - b3 -= k2 + 9; - - tmp = b3 ^ b0; - b3 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 37) | (tmp << (64 - 37)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 40) | (tmp << (64 - 40)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 52) | (tmp << (64 - 52)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 57) | (tmp << (64 - 57)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 14) | (tmp << (64 - 14)); - b0 -= b1 + k3; - b1 -= k4 + t2; - - tmp = b3 ^ b2; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b2 -= b3 + k0 + t0; - b3 -= k1 + 8; - - - tmp = b3 ^ b0; - b3 = (tmp >> 32) | (tmp << (64 - 32)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 32) | (tmp << (64 - 32)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 58) | (tmp << (64 - 58)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 12) | (tmp << (64 - 12)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b0 -= b1 + k2; - b1 -= k3 + t1; - - tmp = b3 ^ b2; - b3 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b3 + k4 + t2; - b3 -= k0 + 7; - - tmp = b3 ^ b0; - b3 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 37) | (tmp << (64 - 37)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 40) | (tmp << (64 - 40)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 52) | (tmp << (64 - 52)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 57) | (tmp << (64 - 57)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 14) | (tmp << (64 - 14)); - b0 -= b1 + k1; - b1 -= k2 + t0; - - tmp = b3 ^ b2; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b2 -= b3 + k3 + t1; - b3 -= k4 + 6; - - - tmp = b3 ^ b0; - b3 = (tmp >> 32) | (tmp << (64 - 32)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 32) | (tmp << (64 - 32)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 58) | (tmp << (64 - 58)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 12) | (tmp << (64 - 12)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b0 -= b1 + k0; - b1 -= k1 + t2; - - tmp = b3 ^ b2; - b3 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b3 + k2 + t0; - b3 -= k3 + 5; - - tmp = b3 ^ b0; - b3 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 37) | (tmp << (64 - 37)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 40) | (tmp << (64 - 40)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 52) | (tmp << (64 - 52)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 57) | (tmp << (64 - 57)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 14) | (tmp << (64 - 14)); - b0 -= b1 + k4; - b1 -= k0 + t1; - - tmp = b3 ^ b2; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b2 -= b3 + k1 + t2; - b3 -= k2 + 4; - - - tmp = b3 ^ b0; - b3 = (tmp >> 32) | (tmp << (64 - 32)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 32) | (tmp << (64 - 32)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 58) | (tmp << (64 - 58)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 12) | (tmp << (64 - 12)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b0 -= b1 + k3; - b1 -= k4 + t0; - - tmp = b3 ^ b2; - b3 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b3 + k0 + t1; - b3 -= k1 + 3; - - tmp = b3 ^ b0; - b3 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 37) | (tmp << (64 - 37)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 40) | (tmp << (64 - 40)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 52) | (tmp << (64 - 52)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 57) | (tmp << (64 - 57)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 14) | (tmp << (64 - 14)); - b0 -= b1 + k2; - b1 -= k3 + t2; - - tmp = b3 ^ b2; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b2 -= b3 + k4 + t0; - b3 -= k0 + 2; - - - tmp = b3 ^ b0; - b3 = (tmp >> 32) | (tmp << (64 - 32)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 32) | (tmp << (64 - 32)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 58) | (tmp << (64 - 58)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 12) | (tmp << (64 - 12)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b0 -= b1 + k1; - b1 -= k2 + t1; - - tmp = b3 ^ b2; - b3 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b3 + k3 + t2; - b3 -= k4 + 1; - - tmp = b3 ^ b0; - b3 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 37) | (tmp << (64 - 37)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 40) | (tmp << (64 - 40)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 52) | (tmp << (64 - 52)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 57) | (tmp << (64 - 57)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 14) | (tmp << (64 - 14)); - b0 -= b1 + k0; - b1 -= k1 + t0; - - tmp = b3 ^ b2; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b2 -= b3 + k2 + t1; - b3 -= k3; - - output[0] = b0; - output[1] = b1; - output[2] = b2; - output[3] = b3; -} diff --git a/drivers/staging/skein/threefish512Block.c b/drivers/staging/skein/threefish512Block.c deleted file mode 100644 index db50d83933dc..000000000000 --- a/drivers/staging/skein/threefish512Block.c +++ /dev/null @@ -1,2225 +0,0 @@ -#include -#include - - -void threefish_encrypt_512(struct threefish_key *key_ctx, u64 *input, - u64 *output) -{ - u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3], - b4 = input[4], b5 = input[5], - b6 = input[6], b7 = input[7]; - u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], - k2 = key_ctx->key[2], k3 = key_ctx->key[3], - k4 = key_ctx->key[4], k5 = key_ctx->key[5], - k6 = key_ctx->key[6], k7 = key_ctx->key[7], - k8 = key_ctx->key[8]; - u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], - t2 = key_ctx->tweak[2]; - - b1 += k1; - b0 += b1 + k0; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - - b3 += k3; - b2 += b3 + k2; - b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - - b5 += k5 + t0; - b4 += b5 + k4; - b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - - b7 += k7; - b6 += b7 + k6 + t1; - b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - - b2 += b1; - b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - - b4 += b7; - b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - - b6 += b5; - b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - - b0 += b3; - b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - - b4 += b1; - b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - - b6 += b3; - b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - - b0 += b5; - b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - - b2 += b7; - b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - - b6 += b1; - b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - - b0 += b7; - b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - - b2 += b5; - b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - - b4 += b3; - b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - - b1 += k2; - b0 += b1 + k1; - b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - - b3 += k4; - b2 += b3 + k3; - b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - - b5 += k6 + t1; - b4 += b5 + k5; - b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - - b7 += k8 + 1; - b6 += b7 + k7 + t2; - b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - - b2 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - - b4 += b7; - b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - - b6 += b5; - b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - - b0 += b3; - b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - - b4 += b1; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - - b6 += b3; - b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - - b0 += b5; - b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - - b2 += b7; - b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - - b6 += b1; - b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - - b0 += b7; - b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - - b2 += b5; - b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - - b4 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - - b1 += k3; - b0 += b1 + k2; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - - b3 += k5; - b2 += b3 + k4; - b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - - b5 += k7 + t2; - b4 += b5 + k6; - b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - - b7 += k0 + 2; - b6 += b7 + k8 + t0; - b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - - b2 += b1; - b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - - b4 += b7; - b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - - b6 += b5; - b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - - b0 += b3; - b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - - b4 += b1; - b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - - b6 += b3; - b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - - b0 += b5; - b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - - b2 += b7; - b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - - b6 += b1; - b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - - b0 += b7; - b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - - b2 += b5; - b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - - b4 += b3; - b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - - b1 += k4; - b0 += b1 + k3; - b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - - b3 += k6; - b2 += b3 + k5; - b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - - b5 += k8 + t0; - b4 += b5 + k7; - b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - - b7 += k1 + 3; - b6 += b7 + k0 + t1; - b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - - b2 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - - b4 += b7; - b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - - b6 += b5; - b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - - b0 += b3; - b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - - b4 += b1; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - - b6 += b3; - b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - - b0 += b5; - b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - - b2 += b7; - b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - - b6 += b1; - b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - - b0 += b7; - b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - - b2 += b5; - b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - - b4 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - - b1 += k5; - b0 += b1 + k4; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - - b3 += k7; - b2 += b3 + k6; - b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - - b5 += k0 + t1; - b4 += b5 + k8; - b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - - b7 += k2 + 4; - b6 += b7 + k1 + t2; - b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - - b2 += b1; - b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - - b4 += b7; - b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - - b6 += b5; - b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - - b0 += b3; - b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - - b4 += b1; - b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - - b6 += b3; - b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - - b0 += b5; - b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - - b2 += b7; - b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - - b6 += b1; - b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - - b0 += b7; - b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - - b2 += b5; - b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - - b4 += b3; - b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - - b1 += k6; - b0 += b1 + k5; - b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - - b3 += k8; - b2 += b3 + k7; - b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - - b5 += k1 + t2; - b4 += b5 + k0; - b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - - b7 += k3 + 5; - b6 += b7 + k2 + t0; - b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - - b2 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - - b4 += b7; - b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - - b6 += b5; - b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - - b0 += b3; - b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - - b4 += b1; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - - b6 += b3; - b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - - b0 += b5; - b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - - b2 += b7; - b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - - b6 += b1; - b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - - b0 += b7; - b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - - b2 += b5; - b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - - b4 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - - b1 += k7; - b0 += b1 + k6; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - - b3 += k0; - b2 += b3 + k8; - b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - - b5 += k2 + t0; - b4 += b5 + k1; - b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - - b7 += k4 + 6; - b6 += b7 + k3 + t1; - b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - - b2 += b1; - b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - - b4 += b7; - b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - - b6 += b5; - b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - - b0 += b3; - b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - - b4 += b1; - b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - - b6 += b3; - b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - - b0 += b5; - b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - - b2 += b7; - b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - - b6 += b1; - b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - - b0 += b7; - b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - - b2 += b5; - b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - - b4 += b3; - b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - - b1 += k8; - b0 += b1 + k7; - b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - - b3 += k1; - b2 += b3 + k0; - b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - - b5 += k3 + t1; - b4 += b5 + k2; - b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - - b7 += k5 + 7; - b6 += b7 + k4 + t2; - b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - - b2 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - - b4 += b7; - b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - - b6 += b5; - b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - - b0 += b3; - b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - - b4 += b1; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - - b6 += b3; - b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - - b0 += b5; - b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - - b2 += b7; - b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - - b6 += b1; - b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - - b0 += b7; - b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - - b2 += b5; - b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - - b4 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - - b1 += k0; - b0 += b1 + k8; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - - b3 += k2; - b2 += b3 + k1; - b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - - b5 += k4 + t2; - b4 += b5 + k3; - b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - - b7 += k6 + 8; - b6 += b7 + k5 + t0; - b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - - b2 += b1; - b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - - b4 += b7; - b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - - b6 += b5; - b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - - b0 += b3; - b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - - b4 += b1; - b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - - b6 += b3; - b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - - b0 += b5; - b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - - b2 += b7; - b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - - b6 += b1; - b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - - b0 += b7; - b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - - b2 += b5; - b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - - b4 += b3; - b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - - b1 += k1; - b0 += b1 + k0; - b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - - b3 += k3; - b2 += b3 + k2; - b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - - b5 += k5 + t0; - b4 += b5 + k4; - b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - - b7 += k7 + 9; - b6 += b7 + k6 + t1; - b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - - b2 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - - b4 += b7; - b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - - b6 += b5; - b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - - b0 += b3; - b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - - b4 += b1; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - - b6 += b3; - b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - - b0 += b5; - b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - - b2 += b7; - b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - - b6 += b1; - b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - - b0 += b7; - b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - - b2 += b5; - b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - - b4 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - - b1 += k2; - b0 += b1 + k1; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - - b3 += k4; - b2 += b3 + k3; - b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - - b5 += k6 + t1; - b4 += b5 + k5; - b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - - b7 += k8 + 10; - b6 += b7 + k7 + t2; - b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - - b2 += b1; - b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - - b4 += b7; - b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - - b6 += b5; - b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - - b0 += b3; - b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - - b4 += b1; - b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - - b6 += b3; - b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - - b0 += b5; - b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - - b2 += b7; - b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - - b6 += b1; - b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - - b0 += b7; - b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - - b2 += b5; - b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - - b4 += b3; - b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - - b1 += k3; - b0 += b1 + k2; - b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - - b3 += k5; - b2 += b3 + k4; - b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - - b5 += k7 + t2; - b4 += b5 + k6; - b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - - b7 += k0 + 11; - b6 += b7 + k8 + t0; - b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - - b2 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - - b4 += b7; - b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - - b6 += b5; - b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - - b0 += b3; - b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - - b4 += b1; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - - b6 += b3; - b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - - b0 += b5; - b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - - b2 += b7; - b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - - b6 += b1; - b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - - b0 += b7; - b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - - b2 += b5; - b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - - b4 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - - b1 += k4; - b0 += b1 + k3; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - - b3 += k6; - b2 += b3 + k5; - b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - - b5 += k8 + t0; - b4 += b5 + k7; - b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - - b7 += k1 + 12; - b6 += b7 + k0 + t1; - b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - - b2 += b1; - b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - - b4 += b7; - b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - - b6 += b5; - b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - - b0 += b3; - b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - - b4 += b1; - b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - - b6 += b3; - b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - - b0 += b5; - b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - - b2 += b7; - b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - - b6 += b1; - b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - - b0 += b7; - b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - - b2 += b5; - b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - - b4 += b3; - b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - - b1 += k5; - b0 += b1 + k4; - b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - - b3 += k7; - b2 += b3 + k6; - b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - - b5 += k0 + t1; - b4 += b5 + k8; - b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - - b7 += k2 + 13; - b6 += b7 + k1 + t2; - b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - - b2 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - - b4 += b7; - b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - - b6 += b5; - b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - - b0 += b3; - b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - - b4 += b1; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - - b6 += b3; - b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - - b0 += b5; - b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - - b2 += b7; - b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - - b6 += b1; - b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - - b0 += b7; - b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - - b2 += b5; - b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - - b4 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - - b1 += k6; - b0 += b1 + k5; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - - b3 += k8; - b2 += b3 + k7; - b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - - b5 += k1 + t2; - b4 += b5 + k0; - b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - - b7 += k3 + 14; - b6 += b7 + k2 + t0; - b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - - b2 += b1; - b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - - b4 += b7; - b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - - b6 += b5; - b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - - b0 += b3; - b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - - b4 += b1; - b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - - b6 += b3; - b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - - b0 += b5; - b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - - b2 += b7; - b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - - b6 += b1; - b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - - b0 += b7; - b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - - b2 += b5; - b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - - b4 += b3; - b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - - b1 += k7; - b0 += b1 + k6; - b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - - b3 += k0; - b2 += b3 + k8; - b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - - b5 += k2 + t0; - b4 += b5 + k1; - b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - - b7 += k4 + 15; - b6 += b7 + k3 + t1; - b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - - b2 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - - b4 += b7; - b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - - b6 += b5; - b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - - b0 += b3; - b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - - b4 += b1; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - - b6 += b3; - b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - - b0 += b5; - b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - - b2 += b7; - b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - - b6 += b1; - b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - - b0 += b7; - b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - - b2 += b5; - b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - - b4 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - - b1 += k8; - b0 += b1 + k7; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - - b3 += k1; - b2 += b3 + k0; - b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - - b5 += k3 + t1; - b4 += b5 + k2; - b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - - b7 += k5 + 16; - b6 += b7 + k4 + t2; - b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - - b2 += b1; - b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - - b4 += b7; - b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - - b6 += b5; - b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - - b0 += b3; - b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - - b4 += b1; - b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - - b6 += b3; - b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - - b0 += b5; - b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - - b2 += b7; - b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - - b6 += b1; - b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - - b0 += b7; - b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - - b2 += b5; - b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - - b4 += b3; - b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - - b1 += k0; - b0 += b1 + k8; - b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - - b3 += k2; - b2 += b3 + k1; - b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - - b5 += k4 + t2; - b4 += b5 + k3; - b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - - b7 += k6 + 17; - b6 += b7 + k5 + t0; - b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - - b2 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - - b4 += b7; - b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - - b6 += b5; - b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - - b0 += b3; - b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - - b4 += b1; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - - b6 += b3; - b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - - b0 += b5; - b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - - b2 += b7; - b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - - b6 += b1; - b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - - b0 += b7; - b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - - b2 += b5; - b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - - b4 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - - output[0] = b0 + k0; - output[1] = b1 + k1; - output[2] = b2 + k2; - output[3] = b3 + k3; - output[4] = b4 + k4; - output[5] = b5 + k5 + t0; - output[6] = b6 + k6 + t1; - output[7] = b7 + k7 + 18; -} - -void threefish_decrypt_512(struct threefish_key *key_ctx, u64 *input, - u64 *output) -{ - u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3], - b4 = input[4], b5 = input[5], - b6 = input[6], b7 = input[7]; - u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], - k2 = key_ctx->key[2], k3 = key_ctx->key[3], - k4 = key_ctx->key[4], k5 = key_ctx->key[5], - k6 = key_ctx->key[6], k7 = key_ctx->key[7], - k8 = key_ctx->key[8]; - u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], - t2 = key_ctx->tweak[2]; - - u64 tmp; - - b0 -= k0; - b1 -= k1; - b2 -= k2; - b3 -= k3; - b4 -= k4; - b5 -= k5 + t0; - b6 -= k6 + t1; - b7 -= k7 + 18; - - tmp = b3 ^ b4; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 56) | (tmp << (64 - 56)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 35) | (tmp << (64 - 35)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 8) | (tmp << (64 - 8)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 43) | (tmp << (64 - 43)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 29) | (tmp << (64 - 29)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 17) | (tmp << (64 - 17)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 50) | (tmp << (64 - 50)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 24) | (tmp << (64 - 24)); - b6 -= b7 + k5 + t0; - b7 -= k6 + 17; - - tmp = b5 ^ b4; - b5 = (tmp >> 34) | (tmp << (64 - 34)); - b4 -= b5 + k3; - b5 -= k4 + t2; - - tmp = b3 ^ b2; - b3 = (tmp >> 30) | (tmp << (64 - 30)); - b2 -= b3 + k1; - b3 -= k2; - - tmp = b1 ^ b0; - b1 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b1 + k8; - b1 -= k0; - - tmp = b3 ^ b4; - b3 = (tmp >> 56) | (tmp << (64 - 56)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 54) | (tmp << (64 - 54)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 44) | (tmp << (64 - 44)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 39) | (tmp << (64 - 39)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 36) | (tmp << (64 - 36)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 49) | (tmp << (64 - 49)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 17) | (tmp << (64 - 17)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 42) | (tmp << (64 - 42)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 14) | (tmp << (64 - 14)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 27) | (tmp << (64 - 27)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 37) | (tmp << (64 - 37)); - b6 -= b7 + k4 + t2; - b7 -= k5 + 16; - - tmp = b5 ^ b4; - b5 = (tmp >> 19) | (tmp << (64 - 19)); - b4 -= b5 + k2; - b5 -= k3 + t1; - - tmp = b3 ^ b2; - b3 = (tmp >> 36) | (tmp << (64 - 36)); - b2 -= b3 + k0; - b3 -= k1; - - tmp = b1 ^ b0; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b1 + k7; - b1 -= k8; - - tmp = b3 ^ b4; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 56) | (tmp << (64 - 56)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 35) | (tmp << (64 - 35)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 8) | (tmp << (64 - 8)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 43) | (tmp << (64 - 43)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 29) | (tmp << (64 - 29)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 17) | (tmp << (64 - 17)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 50) | (tmp << (64 - 50)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 24) | (tmp << (64 - 24)); - b6 -= b7 + k3 + t1; - b7 -= k4 + 15; - - tmp = b5 ^ b4; - b5 = (tmp >> 34) | (tmp << (64 - 34)); - b4 -= b5 + k1; - b5 -= k2 + t0; - - tmp = b3 ^ b2; - b3 = (tmp >> 30) | (tmp << (64 - 30)); - b2 -= b3 + k8; - b3 -= k0; - - tmp = b1 ^ b0; - b1 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b1 + k6; - b1 -= k7; - - tmp = b3 ^ b4; - b3 = (tmp >> 56) | (tmp << (64 - 56)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 54) | (tmp << (64 - 54)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 44) | (tmp << (64 - 44)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 39) | (tmp << (64 - 39)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 36) | (tmp << (64 - 36)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 49) | (tmp << (64 - 49)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 17) | (tmp << (64 - 17)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 42) | (tmp << (64 - 42)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 14) | (tmp << (64 - 14)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 27) | (tmp << (64 - 27)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 37) | (tmp << (64 - 37)); - b6 -= b7 + k2 + t0; - b7 -= k3 + 14; - - tmp = b5 ^ b4; - b5 = (tmp >> 19) | (tmp << (64 - 19)); - b4 -= b5 + k0; - b5 -= k1 + t2; - - tmp = b3 ^ b2; - b3 = (tmp >> 36) | (tmp << (64 - 36)); - b2 -= b3 + k7; - b3 -= k8; - - tmp = b1 ^ b0; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b1 + k5; - b1 -= k6; - - tmp = b3 ^ b4; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 56) | (tmp << (64 - 56)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 35) | (tmp << (64 - 35)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 8) | (tmp << (64 - 8)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 43) | (tmp << (64 - 43)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 29) | (tmp << (64 - 29)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 17) | (tmp << (64 - 17)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 50) | (tmp << (64 - 50)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 24) | (tmp << (64 - 24)); - b6 -= b7 + k1 + t2; - b7 -= k2 + 13; - - tmp = b5 ^ b4; - b5 = (tmp >> 34) | (tmp << (64 - 34)); - b4 -= b5 + k8; - b5 -= k0 + t1; - - tmp = b3 ^ b2; - b3 = (tmp >> 30) | (tmp << (64 - 30)); - b2 -= b3 + k6; - b3 -= k7; - - tmp = b1 ^ b0; - b1 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b1 + k4; - b1 -= k5; - - tmp = b3 ^ b4; - b3 = (tmp >> 56) | (tmp << (64 - 56)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 54) | (tmp << (64 - 54)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 44) | (tmp << (64 - 44)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 39) | (tmp << (64 - 39)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 36) | (tmp << (64 - 36)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 49) | (tmp << (64 - 49)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 17) | (tmp << (64 - 17)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 42) | (tmp << (64 - 42)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 14) | (tmp << (64 - 14)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 27) | (tmp << (64 - 27)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 37) | (tmp << (64 - 37)); - b6 -= b7 + k0 + t1; - b7 -= k1 + 12; - - tmp = b5 ^ b4; - b5 = (tmp >> 19) | (tmp << (64 - 19)); - b4 -= b5 + k7; - b5 -= k8 + t0; - - tmp = b3 ^ b2; - b3 = (tmp >> 36) | (tmp << (64 - 36)); - b2 -= b3 + k5; - b3 -= k6; - - tmp = b1 ^ b0; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b1 + k3; - b1 -= k4; - - tmp = b3 ^ b4; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 56) | (tmp << (64 - 56)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 35) | (tmp << (64 - 35)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 8) | (tmp << (64 - 8)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 43) | (tmp << (64 - 43)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 29) | (tmp << (64 - 29)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 17) | (tmp << (64 - 17)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 50) | (tmp << (64 - 50)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 24) | (tmp << (64 - 24)); - b6 -= b7 + k8 + t0; - b7 -= k0 + 11; - - tmp = b5 ^ b4; - b5 = (tmp >> 34) | (tmp << (64 - 34)); - b4 -= b5 + k6; - b5 -= k7 + t2; - - tmp = b3 ^ b2; - b3 = (tmp >> 30) | (tmp << (64 - 30)); - b2 -= b3 + k4; - b3 -= k5; - - tmp = b1 ^ b0; - b1 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b1 + k2; - b1 -= k3; - - tmp = b3 ^ b4; - b3 = (tmp >> 56) | (tmp << (64 - 56)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 54) | (tmp << (64 - 54)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 44) | (tmp << (64 - 44)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 39) | (tmp << (64 - 39)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 36) | (tmp << (64 - 36)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 49) | (tmp << (64 - 49)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 17) | (tmp << (64 - 17)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 42) | (tmp << (64 - 42)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 14) | (tmp << (64 - 14)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 27) | (tmp << (64 - 27)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 37) | (tmp << (64 - 37)); - b6 -= b7 + k7 + t2; - b7 -= k8 + 10; - - tmp = b5 ^ b4; - b5 = (tmp >> 19) | (tmp << (64 - 19)); - b4 -= b5 + k5; - b5 -= k6 + t1; - - tmp = b3 ^ b2; - b3 = (tmp >> 36) | (tmp << (64 - 36)); - b2 -= b3 + k3; - b3 -= k4; - - tmp = b1 ^ b0; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b1 + k1; - b1 -= k2; - - tmp = b3 ^ b4; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 56) | (tmp << (64 - 56)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 35) | (tmp << (64 - 35)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 8) | (tmp << (64 - 8)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 43) | (tmp << (64 - 43)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 29) | (tmp << (64 - 29)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 17) | (tmp << (64 - 17)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 50) | (tmp << (64 - 50)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 24) | (tmp << (64 - 24)); - b6 -= b7 + k6 + t1; - b7 -= k7 + 9; - - tmp = b5 ^ b4; - b5 = (tmp >> 34) | (tmp << (64 - 34)); - b4 -= b5 + k4; - b5 -= k5 + t0; - - tmp = b3 ^ b2; - b3 = (tmp >> 30) | (tmp << (64 - 30)); - b2 -= b3 + k2; - b3 -= k3; - - tmp = b1 ^ b0; - b1 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b1 + k0; - b1 -= k1; - - tmp = b3 ^ b4; - b3 = (tmp >> 56) | (tmp << (64 - 56)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 54) | (tmp << (64 - 54)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 44) | (tmp << (64 - 44)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 39) | (tmp << (64 - 39)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 36) | (tmp << (64 - 36)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 49) | (tmp << (64 - 49)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 17) | (tmp << (64 - 17)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 42) | (tmp << (64 - 42)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 14) | (tmp << (64 - 14)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 27) | (tmp << (64 - 27)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 37) | (tmp << (64 - 37)); - b6 -= b7 + k5 + t0; - b7 -= k6 + 8; - - tmp = b5 ^ b4; - b5 = (tmp >> 19) | (tmp << (64 - 19)); - b4 -= b5 + k3; - b5 -= k4 + t2; - - tmp = b3 ^ b2; - b3 = (tmp >> 36) | (tmp << (64 - 36)); - b2 -= b3 + k1; - b3 -= k2; - - tmp = b1 ^ b0; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b1 + k8; - b1 -= k0; - - tmp = b3 ^ b4; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 56) | (tmp << (64 - 56)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 35) | (tmp << (64 - 35)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 8) | (tmp << (64 - 8)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 43) | (tmp << (64 - 43)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 29) | (tmp << (64 - 29)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 17) | (tmp << (64 - 17)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 50) | (tmp << (64 - 50)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 24) | (tmp << (64 - 24)); - b6 -= b7 + k4 + t2; - b7 -= k5 + 7; - - tmp = b5 ^ b4; - b5 = (tmp >> 34) | (tmp << (64 - 34)); - b4 -= b5 + k2; - b5 -= k3 + t1; - - tmp = b3 ^ b2; - b3 = (tmp >> 30) | (tmp << (64 - 30)); - b2 -= b3 + k0; - b3 -= k1; - - tmp = b1 ^ b0; - b1 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b1 + k7; - b1 -= k8; - - tmp = b3 ^ b4; - b3 = (tmp >> 56) | (tmp << (64 - 56)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 54) | (tmp << (64 - 54)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 44) | (tmp << (64 - 44)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 39) | (tmp << (64 - 39)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 36) | (tmp << (64 - 36)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 49) | (tmp << (64 - 49)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 17) | (tmp << (64 - 17)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 42) | (tmp << (64 - 42)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 14) | (tmp << (64 - 14)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 27) | (tmp << (64 - 27)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 37) | (tmp << (64 - 37)); - b6 -= b7 + k3 + t1; - b7 -= k4 + 6; - - tmp = b5 ^ b4; - b5 = (tmp >> 19) | (tmp << (64 - 19)); - b4 -= b5 + k1; - b5 -= k2 + t0; - - tmp = b3 ^ b2; - b3 = (tmp >> 36) | (tmp << (64 - 36)); - b2 -= b3 + k8; - b3 -= k0; - - tmp = b1 ^ b0; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b1 + k6; - b1 -= k7; - - tmp = b3 ^ b4; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 56) | (tmp << (64 - 56)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 35) | (tmp << (64 - 35)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 8) | (tmp << (64 - 8)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 43) | (tmp << (64 - 43)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 29) | (tmp << (64 - 29)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 17) | (tmp << (64 - 17)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 50) | (tmp << (64 - 50)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 24) | (tmp << (64 - 24)); - b6 -= b7 + k2 + t0; - b7 -= k3 + 5; - - tmp = b5 ^ b4; - b5 = (tmp >> 34) | (tmp << (64 - 34)); - b4 -= b5 + k0; - b5 -= k1 + t2; - - tmp = b3 ^ b2; - b3 = (tmp >> 30) | (tmp << (64 - 30)); - b2 -= b3 + k7; - b3 -= k8; - - tmp = b1 ^ b0; - b1 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b1 + k5; - b1 -= k6; - - tmp = b3 ^ b4; - b3 = (tmp >> 56) | (tmp << (64 - 56)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 54) | (tmp << (64 - 54)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 44) | (tmp << (64 - 44)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 39) | (tmp << (64 - 39)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 36) | (tmp << (64 - 36)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 49) | (tmp << (64 - 49)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 17) | (tmp << (64 - 17)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 42) | (tmp << (64 - 42)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 14) | (tmp << (64 - 14)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 27) | (tmp << (64 - 27)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 37) | (tmp << (64 - 37)); - b6 -= b7 + k1 + t2; - b7 -= k2 + 4; - - tmp = b5 ^ b4; - b5 = (tmp >> 19) | (tmp << (64 - 19)); - b4 -= b5 + k8; - b5 -= k0 + t1; - - tmp = b3 ^ b2; - b3 = (tmp >> 36) | (tmp << (64 - 36)); - b2 -= b3 + k6; - b3 -= k7; - - tmp = b1 ^ b0; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b1 + k4; - b1 -= k5; - - tmp = b3 ^ b4; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 56) | (tmp << (64 - 56)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 35) | (tmp << (64 - 35)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 8) | (tmp << (64 - 8)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 43) | (tmp << (64 - 43)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 29) | (tmp << (64 - 29)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 17) | (tmp << (64 - 17)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 50) | (tmp << (64 - 50)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 24) | (tmp << (64 - 24)); - b6 -= b7 + k0 + t1; - b7 -= k1 + 3; - - tmp = b5 ^ b4; - b5 = (tmp >> 34) | (tmp << (64 - 34)); - b4 -= b5 + k7; - b5 -= k8 + t0; - - tmp = b3 ^ b2; - b3 = (tmp >> 30) | (tmp << (64 - 30)); - b2 -= b3 + k5; - b3 -= k6; - - tmp = b1 ^ b0; - b1 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b1 + k3; - b1 -= k4; - - tmp = b3 ^ b4; - b3 = (tmp >> 56) | (tmp << (64 - 56)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 54) | (tmp << (64 - 54)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 44) | (tmp << (64 - 44)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 39) | (tmp << (64 - 39)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 36) | (tmp << (64 - 36)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 49) | (tmp << (64 - 49)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 17) | (tmp << (64 - 17)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 42) | (tmp << (64 - 42)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 14) | (tmp << (64 - 14)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 27) | (tmp << (64 - 27)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 37) | (tmp << (64 - 37)); - b6 -= b7 + k8 + t0; - b7 -= k0 + 2; - - tmp = b5 ^ b4; - b5 = (tmp >> 19) | (tmp << (64 - 19)); - b4 -= b5 + k6; - b5 -= k7 + t2; - - tmp = b3 ^ b2; - b3 = (tmp >> 36) | (tmp << (64 - 36)); - b2 -= b3 + k4; - b3 -= k5; - - tmp = b1 ^ b0; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b1 + k2; - b1 -= k3; - - tmp = b3 ^ b4; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 56) | (tmp << (64 - 56)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 35) | (tmp << (64 - 35)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 8) | (tmp << (64 - 8)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 43) | (tmp << (64 - 43)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 29) | (tmp << (64 - 29)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 17) | (tmp << (64 - 17)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 50) | (tmp << (64 - 50)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 24) | (tmp << (64 - 24)); - b6 -= b7 + k7 + t2; - b7 -= k8 + 1; - - tmp = b5 ^ b4; - b5 = (tmp >> 34) | (tmp << (64 - 34)); - b4 -= b5 + k5; - b5 -= k6 + t1; - - tmp = b3 ^ b2; - b3 = (tmp >> 30) | (tmp << (64 - 30)); - b2 -= b3 + k3; - b3 -= k4; - - tmp = b1 ^ b0; - b1 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b1 + k1; - b1 -= k2; - - tmp = b3 ^ b4; - b3 = (tmp >> 56) | (tmp << (64 - 56)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 54) | (tmp << (64 - 54)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 44) | (tmp << (64 - 44)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 39) | (tmp << (64 - 39)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 36) | (tmp << (64 - 36)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 49) | (tmp << (64 - 49)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 17) | (tmp << (64 - 17)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 42) | (tmp << (64 - 42)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 14) | (tmp << (64 - 14)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 27) | (tmp << (64 - 27)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 37) | (tmp << (64 - 37)); - b6 -= b7 + k6 + t1; - b7 -= k7; - - tmp = b5 ^ b4; - b5 = (tmp >> 19) | (tmp << (64 - 19)); - b4 -= b5 + k4; - b5 -= k5 + t0; - - tmp = b3 ^ b2; - b3 = (tmp >> 36) | (tmp << (64 - 36)); - b2 -= b3 + k2; - b3 -= k3; - - tmp = b1 ^ b0; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b1 + k0; - b1 -= k1; - - output[0] = b0; - output[1] = b1; - output[2] = b2; - output[3] = b3; - - output[7] = b7; - output[6] = b6; - output[5] = b5; - output[4] = b4; -} diff --git a/drivers/staging/skein/threefishApi.c b/drivers/staging/skein/threefishApi.c deleted file mode 100644 index 0ba42fac2f88..000000000000 --- a/drivers/staging/skein/threefishApi.c +++ /dev/null @@ -1,79 +0,0 @@ - - -#include -#include - -void threefish_set_key(struct threefish_key *key_ctx, - enum threefish_size state_size, - u64 *key_data, u64 *tweak) -{ - int key_words = state_size / 64; - int i; - u64 parity = KEY_SCHEDULE_CONST; - - key_ctx->tweak[0] = tweak[0]; - key_ctx->tweak[1] = tweak[1]; - key_ctx->tweak[2] = tweak[0] ^ tweak[1]; - - for (i = 0; i < key_words; i++) { - key_ctx->key[i] = key_data[i]; - parity ^= key_data[i]; - } - key_ctx->key[i] = parity; - key_ctx->state_size = state_size; -} - -void threefish_encrypt_block_bytes(struct threefish_key *key_ctx, u8 *in, - u8 *out) -{ - u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ - u64 cipher[SKEIN_MAX_STATE_WORDS]; - - skein_get64_lsb_first(plain, in, key_ctx->state_size / 64); - threefish_encrypt_block_words(key_ctx, plain, cipher); - skein_put64_lsb_first(out, cipher, key_ctx->state_size / 8); -} - -void threefish_encrypt_block_words(struct threefish_key *key_ctx, u64 *in, - u64 *out) -{ - switch (key_ctx->state_size) { - case THREEFISH_256: - threefish_encrypt_256(key_ctx, in, out); - break; - case THREEFISH_512: - threefish_encrypt_512(key_ctx, in, out); - break; - case THREEFISH_1024: - threefish_encrypt_1024(key_ctx, in, out); - break; - } -} - -void threefish_decrypt_block_bytes(struct threefish_key *key_ctx, u8 *in, - u8 *out) -{ - u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ - u64 cipher[SKEIN_MAX_STATE_WORDS]; - - skein_get64_lsb_first(cipher, in, key_ctx->state_size / 64); - threefish_decrypt_block_words(key_ctx, cipher, plain); - skein_put64_lsb_first(out, plain, key_ctx->state_size / 8); -} - -void threefish_decrypt_block_words(struct threefish_key *key_ctx, u64 *in, - u64 *out) -{ - switch (key_ctx->state_size) { - case THREEFISH_256: - threefish_decrypt_256(key_ctx, in, out); - break; - case THREEFISH_512: - threefish_decrypt_512(key_ctx, in, out); - break; - case THREEFISH_1024: - threefish_decrypt_1024(key_ctx, in, out); - break; - } -} - diff --git a/drivers/staging/skein/threefish_1024_block.c b/drivers/staging/skein/threefish_1024_block.c new file mode 100644 index 000000000000..dac74e10d6e4 --- /dev/null +++ b/drivers/staging/skein/threefish_1024_block.c @@ -0,0 +1,4902 @@ +#include +#include "threefish_api.h" + + +void threefish_encrypt_1024(struct threefish_key *key_ctx, u64 *input, + u64 *output) +{ + u64 b0 = input[0], b1 = input[1], + b2 = input[2], b3 = input[3], + b4 = input[4], b5 = input[5], + b6 = input[6], b7 = input[7], + b8 = input[8], b9 = input[9], + b10 = input[10], b11 = input[11], + b12 = input[12], b13 = input[13], + b14 = input[14], b15 = input[15]; + u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], + k2 = key_ctx->key[2], k3 = key_ctx->key[3], + k4 = key_ctx->key[4], k5 = key_ctx->key[5], + k6 = key_ctx->key[6], k7 = key_ctx->key[7], + k8 = key_ctx->key[8], k9 = key_ctx->key[9], + k10 = key_ctx->key[10], k11 = key_ctx->key[11], + k12 = key_ctx->key[12], k13 = key_ctx->key[13], + k14 = key_ctx->key[14], k15 = key_ctx->key[15], + k16 = key_ctx->key[16]; + u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], + t2 = key_ctx->tweak[2]; + + b1 += k1; + b0 += b1 + k0; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k3; + b2 += b3 + k2; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k5; + b4 += b5 + k4; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k7; + b6 += b7 + k6; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k9; + b8 += b9 + k8; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k11; + b10 += b11 + k10; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k13 + t0; + b12 += b13 + k12; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k15; + b14 += b15 + k14 + t1; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k2; + b0 += b1 + k1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k4; + b2 += b3 + k3; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k6; + b4 += b5 + k5; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k8; + b6 += b7 + k7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k10; + b8 += b9 + k9; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k12; + b10 += b11 + k11; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k14 + t1; + b12 += b13 + k13; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k16 + 1; + b14 += b15 + k15 + t2; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + b1 += k3; + b0 += b1 + k2; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k5; + b2 += b3 + k4; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k7; + b4 += b5 + k6; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k9; + b6 += b7 + k8; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k11; + b8 += b9 + k10; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k13; + b10 += b11 + k12; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k15 + t2; + b12 += b13 + k14; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k0 + 2; + b14 += b15 + k16 + t0; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k4; + b0 += b1 + k3; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k6; + b2 += b3 + k5; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k8; + b4 += b5 + k7; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k10; + b6 += b7 + k9; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k12; + b8 += b9 + k11; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k14; + b10 += b11 + k13; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k16 + t0; + b12 += b13 + k15; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k1 + 3; + b14 += b15 + k0 + t1; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + b1 += k5; + b0 += b1 + k4; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k7; + b2 += b3 + k6; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k9; + b4 += b5 + k8; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k11; + b6 += b7 + k10; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k13; + b8 += b9 + k12; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k15; + b10 += b11 + k14; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k0 + t1; + b12 += b13 + k16; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k2 + 4; + b14 += b15 + k1 + t2; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k6; + b0 += b1 + k5; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k8; + b2 += b3 + k7; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k10; + b4 += b5 + k9; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k12; + b6 += b7 + k11; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k14; + b8 += b9 + k13; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k16; + b10 += b11 + k15; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k1 + t2; + b12 += b13 + k0; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k3 + 5; + b14 += b15 + k2 + t0; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + b1 += k7; + b0 += b1 + k6; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k9; + b2 += b3 + k8; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k11; + b4 += b5 + k10; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k13; + b6 += b7 + k12; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k15; + b8 += b9 + k14; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k0; + b10 += b11 + k16; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k2 + t0; + b12 += b13 + k1; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k4 + 6; + b14 += b15 + k3 + t1; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k8; + b0 += b1 + k7; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k10; + b2 += b3 + k9; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k12; + b4 += b5 + k11; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k14; + b6 += b7 + k13; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k16; + b8 += b9 + k15; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k1; + b10 += b11 + k0; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k3 + t1; + b12 += b13 + k2; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k5 + 7; + b14 += b15 + k4 + t2; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + b1 += k9; + b0 += b1 + k8; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k11; + b2 += b3 + k10; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k13; + b4 += b5 + k12; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k15; + b6 += b7 + k14; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k0; + b8 += b9 + k16; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k2; + b10 += b11 + k1; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k4 + t2; + b12 += b13 + k3; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k6 + 8; + b14 += b15 + k5 + t0; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k10; + b0 += b1 + k9; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k12; + b2 += b3 + k11; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k14; + b4 += b5 + k13; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k16; + b6 += b7 + k15; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k1; + b8 += b9 + k0; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k3; + b10 += b11 + k2; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k5 + t0; + b12 += b13 + k4; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k7 + 9; + b14 += b15 + k6 + t1; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + b1 += k11; + b0 += b1 + k10; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k13; + b2 += b3 + k12; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k15; + b4 += b5 + k14; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k0; + b6 += b7 + k16; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k2; + b8 += b9 + k1; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k4; + b10 += b11 + k3; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k6 + t1; + b12 += b13 + k5; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k8 + 10; + b14 += b15 + k7 + t2; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k12; + b0 += b1 + k11; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k14; + b2 += b3 + k13; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k16; + b4 += b5 + k15; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k1; + b6 += b7 + k0; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k3; + b8 += b9 + k2; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k5; + b10 += b11 + k4; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k7 + t2; + b12 += b13 + k6; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k9 + 11; + b14 += b15 + k8 + t0; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + b1 += k13; + b0 += b1 + k12; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k15; + b2 += b3 + k14; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k0; + b4 += b5 + k16; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k2; + b6 += b7 + k1; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k4; + b8 += b9 + k3; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k6; + b10 += b11 + k5; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k8 + t0; + b12 += b13 + k7; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k10 + 12; + b14 += b15 + k9 + t1; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k14; + b0 += b1 + k13; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k16; + b2 += b3 + k15; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k1; + b4 += b5 + k0; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k3; + b6 += b7 + k2; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k5; + b8 += b9 + k4; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k7; + b10 += b11 + k6; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k9 + t1; + b12 += b13 + k8; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k11 + 13; + b14 += b15 + k10 + t2; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + b1 += k15; + b0 += b1 + k14; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k0; + b2 += b3 + k16; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k2; + b4 += b5 + k1; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k4; + b6 += b7 + k3; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k6; + b8 += b9 + k5; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k8; + b10 += b11 + k7; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k10 + t2; + b12 += b13 + k9; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k12 + 14; + b14 += b15 + k11 + t0; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k16; + b0 += b1 + k15; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k1; + b2 += b3 + k0; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k3; + b4 += b5 + k2; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k5; + b6 += b7 + k4; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k7; + b8 += b9 + k6; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k9; + b10 += b11 + k8; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k11 + t0; + b12 += b13 + k10; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k13 + 15; + b14 += b15 + k12 + t1; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + b1 += k0; + b0 += b1 + k16; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k2; + b2 += b3 + k1; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k4; + b4 += b5 + k3; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k6; + b6 += b7 + k5; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k8; + b8 += b9 + k7; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k10; + b10 += b11 + k9; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k12 + t1; + b12 += b13 + k11; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k14 + 16; + b14 += b15 + k13 + t2; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k1; + b0 += b1 + k0; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k3; + b2 += b3 + k2; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k5; + b4 += b5 + k4; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k7; + b6 += b7 + k6; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k9; + b8 += b9 + k8; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k11; + b10 += b11 + k10; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k13 + t2; + b12 += b13 + k12; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k15 + 17; + b14 += b15 + k14 + t0; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + b1 += k2; + b0 += b1 + k1; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k4; + b2 += b3 + k3; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k6; + b4 += b5 + k5; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k8; + b6 += b7 + k7; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k10; + b8 += b9 + k9; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k12; + b10 += b11 + k11; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k14 + t0; + b12 += b13 + k13; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k16 + 18; + b14 += b15 + k15 + t1; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k3; + b0 += b1 + k2; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k5; + b2 += b3 + k4; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k7; + b4 += b5 + k6; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k9; + b6 += b7 + k8; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k11; + b8 += b9 + k10; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k13; + b10 += b11 + k12; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k15 + t1; + b12 += b13 + k14; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k0 + 19; + b14 += b15 + k16 + t2; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + output[0] = b0 + k3; + output[1] = b1 + k4; + output[2] = b2 + k5; + output[3] = b3 + k6; + output[4] = b4 + k7; + output[5] = b5 + k8; + output[6] = b6 + k9; + output[7] = b7 + k10; + output[8] = b8 + k11; + output[9] = b9 + k12; + output[10] = b10 + k13; + output[11] = b11 + k14; + output[12] = b12 + k15; + output[13] = b13 + k16 + t2; + output[14] = b14 + k0 + t0; + output[15] = b15 + k1 + 20; +} + +void threefish_decrypt_1024(struct threefish_key *key_ctx, u64 *input, + u64 *output) +{ + u64 b0 = input[0], b1 = input[1], + b2 = input[2], b3 = input[3], + b4 = input[4], b5 = input[5], + b6 = input[6], b7 = input[7], + b8 = input[8], b9 = input[9], + b10 = input[10], b11 = input[11], + b12 = input[12], b13 = input[13], + b14 = input[14], b15 = input[15]; + u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], + k2 = key_ctx->key[2], k3 = key_ctx->key[3], + k4 = key_ctx->key[4], k5 = key_ctx->key[5], + k6 = key_ctx->key[6], k7 = key_ctx->key[7], + k8 = key_ctx->key[8], k9 = key_ctx->key[9], + k10 = key_ctx->key[10], k11 = key_ctx->key[11], + k12 = key_ctx->key[12], k13 = key_ctx->key[13], + k14 = key_ctx->key[14], k15 = key_ctx->key[15], + k16 = key_ctx->key[16]; + u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], + t2 = key_ctx->tweak[2]; + u64 tmp; + + b0 -= k3; + b1 -= k4; + b2 -= k5; + b3 -= k6; + b4 -= k7; + b5 -= k8; + b6 -= k9; + b7 -= k10; + b8 -= k11; + b9 -= k12; + b10 -= k13; + b11 -= k14; + b12 -= k15; + b13 -= k16 + t2; + b14 -= k0 + t0; + b15 -= k1 + 20; + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k16 + t2; + b15 -= k0 + 19; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k14; + b13 -= k15 + t1; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k12; + b11 -= k13; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k10; + b9 -= k11; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k8; + b7 -= k9; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k6; + b5 -= k7; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k4; + b3 -= k5; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k2; + b1 -= k3; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k15 + t1; + b15 -= k16 + 18; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k13; + b13 -= k14 + t0; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k11; + b11 -= k12; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k9; + b9 -= k10; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k7; + b7 -= k8; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k5; + b5 -= k6; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k3; + b3 -= k4; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k1; + b1 -= k2; + + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k14 + t0; + b15 -= k15 + 17; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k12; + b13 -= k13 + t2; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k10; + b11 -= k11; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k8; + b9 -= k9; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k6; + b7 -= k7; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k4; + b5 -= k5; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k2; + b3 -= k3; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k0; + b1 -= k1; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k13 + t2; + b15 -= k14 + 16; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k11; + b13 -= k12 + t1; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k9; + b11 -= k10; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k7; + b9 -= k8; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k5; + b7 -= k6; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k3; + b5 -= k4; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k1; + b3 -= k2; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k16; + b1 -= k0; + + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k12 + t1; + b15 -= k13 + 15; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k10; + b13 -= k11 + t0; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k8; + b11 -= k9; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k6; + b9 -= k7; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k4; + b7 -= k5; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k2; + b5 -= k3; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k0; + b3 -= k1; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k15; + b1 -= k16; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k11 + t0; + b15 -= k12 + 14; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k9; + b13 -= k10 + t2; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k7; + b11 -= k8; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k5; + b9 -= k6; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k3; + b7 -= k4; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k1; + b5 -= k2; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k16; + b3 -= k0; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k14; + b1 -= k15; + + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k10 + t2; + b15 -= k11 + 13; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k8; + b13 -= k9 + t1; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k6; + b11 -= k7; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k4; + b9 -= k5; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k2; + b7 -= k3; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k0; + b5 -= k1; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k15; + b3 -= k16; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k13; + b1 -= k14; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k9 + t1; + b15 -= k10 + 12; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k7; + b13 -= k8 + t0; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k5; + b11 -= k6; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k3; + b9 -= k4; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k1; + b7 -= k2; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k16; + b5 -= k0; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k14; + b3 -= k15; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k12; + b1 -= k13; + + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k8 + t0; + b15 -= k9 + 11; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k6; + b13 -= k7 + t2; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k4; + b11 -= k5; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k2; + b9 -= k3; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k0; + b7 -= k1; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k15; + b5 -= k16; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k13; + b3 -= k14; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k11; + b1 -= k12; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k7 + t2; + b15 -= k8 + 10; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k5; + b13 -= k6 + t1; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k3; + b11 -= k4; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k1; + b9 -= k2; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k16; + b7 -= k0; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k14; + b5 -= k15; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k12; + b3 -= k13; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k10; + b1 -= k11; + + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k6 + t1; + b15 -= k7 + 9; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k4; + b13 -= k5 + t0; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k2; + b11 -= k3; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k0; + b9 -= k1; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k15; + b7 -= k16; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k13; + b5 -= k14; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k11; + b3 -= k12; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k9; + b1 -= k10; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k5 + t0; + b15 -= k6 + 8; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k3; + b13 -= k4 + t2; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k1; + b11 -= k2; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k16; + b9 -= k0; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k14; + b7 -= k15; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k12; + b5 -= k13; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k10; + b3 -= k11; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k8; + b1 -= k9; + + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k4 + t2; + b15 -= k5 + 7; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k2; + b13 -= k3 + t1; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k0; + b11 -= k1; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k15; + b9 -= k16; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k13; + b7 -= k14; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k11; + b5 -= k12; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k9; + b3 -= k10; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k7; + b1 -= k8; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k3 + t1; + b15 -= k4 + 6; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k1; + b13 -= k2 + t0; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k16; + b11 -= k0; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k14; + b9 -= k15; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k12; + b7 -= k13; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k10; + b5 -= k11; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k8; + b3 -= k9; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k6; + b1 -= k7; + + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k2 + t0; + b15 -= k3 + 5; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k0; + b13 -= k1 + t2; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k15; + b11 -= k16; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k13; + b9 -= k14; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k11; + b7 -= k12; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k9; + b5 -= k10; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k7; + b3 -= k8; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k5; + b1 -= k6; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k1 + t2; + b15 -= k2 + 4; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k16; + b13 -= k0 + t1; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k14; + b11 -= k15; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k12; + b9 -= k13; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k10; + b7 -= k11; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k8; + b5 -= k9; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k6; + b3 -= k7; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k4; + b1 -= k5; + + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k0 + t1; + b15 -= k1 + 3; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k15; + b13 -= k16 + t0; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k13; + b11 -= k14; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k11; + b9 -= k12; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k9; + b7 -= k10; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k7; + b5 -= k8; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k5; + b3 -= k6; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k3; + b1 -= k4; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k16 + t0; + b15 -= k0 + 2; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k14; + b13 -= k15 + t2; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k12; + b11 -= k13; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k10; + b9 -= k11; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k8; + b7 -= k9; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k6; + b5 -= k7; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k4; + b3 -= k5; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k2; + b1 -= k3; + + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k15 + t2; + b15 -= k16 + 1; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k13; + b13 -= k14 + t1; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k11; + b11 -= k12; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k9; + b9 -= k10; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k7; + b7 -= k8; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k5; + b5 -= k6; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k3; + b3 -= k4; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k1; + b1 -= k2; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k14 + t1; + b15 -= k15; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k12; + b13 -= k13 + t0; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k10; + b11 -= k11; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k8; + b9 -= k9; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k6; + b7 -= k7; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k4; + b5 -= k5; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k2; + b3 -= k3; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k0; + b1 -= k1; + + output[15] = b15; + output[14] = b14; + output[13] = b13; + output[12] = b12; + output[11] = b11; + output[10] = b10; + output[9] = b9; + output[8] = b8; + output[7] = b7; + output[6] = b6; + output[5] = b5; + output[4] = b4; + output[3] = b3; + output[2] = b2; + output[1] = b1; + output[0] = b0; +} diff --git a/drivers/staging/skein/threefish_256_block.c b/drivers/staging/skein/threefish_256_block.c new file mode 100644 index 000000000000..0b33b3fb899e --- /dev/null +++ b/drivers/staging/skein/threefish_256_block.c @@ -0,0 +1,1139 @@ +#include +#include "threefish_api.h" + + +void threefish_encrypt_256(struct threefish_key *key_ctx, u64 *input, + u64 *output) +{ + u64 b0 = input[0], b1 = input[1], + b2 = input[2], b3 = input[3]; + u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], + k2 = key_ctx->key[2], k3 = key_ctx->key[3], + k4 = key_ctx->key[4]; + u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], + t2 = key_ctx->tweak[2]; + + b1 += k1 + t0; + b0 += b1 + k0; + b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + + b3 += k3; + b2 += b3 + k2 + t1; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + + b0 += b3; + b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + + b2 += b1; + b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + + b0 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + + b2 += b3; + b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + + b0 += b3; + b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + + b2 += b1; + b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + + b1 += k2 + t1; + b0 += b1 + k1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + + b3 += k4 + 1; + b2 += b3 + k3 + t2; + b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + + b0 += b3; + b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + + b2 += b1; + b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + + b0 += b1; + b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + + b2 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + + b0 += b3; + b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + + b2 += b1; + b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + + b1 += k3 + t2; + b0 += b1 + k2; + b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + + b3 += k0 + 2; + b2 += b3 + k4 + t0; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + + b0 += b3; + b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + + b2 += b1; + b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + + b0 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + + b2 += b3; + b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + + b0 += b3; + b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + + b2 += b1; + b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + + b1 += k4 + t0; + b0 += b1 + k3; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + + b3 += k1 + 3; + b2 += b3 + k0 + t1; + b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + + b0 += b3; + b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + + b2 += b1; + b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + + b0 += b1; + b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + + b2 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + + b0 += b3; + b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + + b2 += b1; + b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + + b1 += k0 + t1; + b0 += b1 + k4; + b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + + b3 += k2 + 4; + b2 += b3 + k1 + t2; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + + b0 += b3; + b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + + b2 += b1; + b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + + b0 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + + b2 += b3; + b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + + b0 += b3; + b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + + b2 += b1; + b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + + b1 += k1 + t2; + b0 += b1 + k0; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + + b3 += k3 + 5; + b2 += b3 + k2 + t0; + b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + + b0 += b3; + b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + + b2 += b1; + b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + + b0 += b1; + b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + + b2 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + + b0 += b3; + b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + + b2 += b1; + b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + + b1 += k2 + t0; + b0 += b1 + k1; + b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + + b3 += k4 + 6; + b2 += b3 + k3 + t1; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + + b0 += b3; + b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + + b2 += b1; + b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + + b0 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + + b2 += b3; + b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + + b0 += b3; + b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + + b2 += b1; + b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + + b1 += k3 + t1; + b0 += b1 + k2; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + + b3 += k0 + 7; + b2 += b3 + k4 + t2; + b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + + b0 += b3; + b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + + b2 += b1; + b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + + b0 += b1; + b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + + b2 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + + b0 += b3; + b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + + b2 += b1; + b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + + b1 += k4 + t2; + b0 += b1 + k3; + b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + + b3 += k1 + 8; + b2 += b3 + k0 + t0; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + + b0 += b3; + b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + + b2 += b1; + b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + + b0 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + + b2 += b3; + b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + + b0 += b3; + b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + + b2 += b1; + b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + + b1 += k0 + t0; + b0 += b1 + k4; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + + b3 += k2 + 9; + b2 += b3 + k1 + t1; + b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + + b0 += b3; + b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + + b2 += b1; + b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + + b0 += b1; + b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + + b2 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + + b0 += b3; + b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + + b2 += b1; + b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + + b1 += k1 + t1; + b0 += b1 + k0; + b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + + b3 += k3 + 10; + b2 += b3 + k2 + t2; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + + b0 += b3; + b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + + b2 += b1; + b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + + b0 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + + b2 += b3; + b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + + b0 += b3; + b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + + b2 += b1; + b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + + b1 += k2 + t2; + b0 += b1 + k1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + + b3 += k4 + 11; + b2 += b3 + k3 + t0; + b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + + b0 += b3; + b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + + b2 += b1; + b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + + b0 += b1; + b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + + b2 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + + b0 += b3; + b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + + b2 += b1; + b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + + b1 += k3 + t0; + b0 += b1 + k2; + b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + + b3 += k0 + 12; + b2 += b3 + k4 + t1; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + + b0 += b3; + b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + + b2 += b1; + b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + + b0 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + + b2 += b3; + b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + + b0 += b3; + b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + + b2 += b1; + b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + + b1 += k4 + t1; + b0 += b1 + k3; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + + b3 += k1 + 13; + b2 += b3 + k0 + t2; + b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + + b0 += b3; + b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + + b2 += b1; + b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + + b0 += b1; + b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + + b2 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + + b0 += b3; + b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + + b2 += b1; + b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + + b1 += k0 + t2; + b0 += b1 + k4; + b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + + b3 += k2 + 14; + b2 += b3 + k1 + t0; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + + b0 += b3; + b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + + b2 += b1; + b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + + b0 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + + b2 += b3; + b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + + b0 += b3; + b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + + b2 += b1; + b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + + b1 += k1 + t0; + b0 += b1 + k0; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + + b3 += k3 + 15; + b2 += b3 + k2 + t1; + b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + + b0 += b3; + b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + + b2 += b1; + b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + + b0 += b1; + b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + + b2 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + + b0 += b3; + b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + + b2 += b1; + b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + + b1 += k2 + t1; + b0 += b1 + k1; + b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + + b3 += k4 + 16; + b2 += b3 + k3 + t2; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + + b0 += b3; + b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + + b2 += b1; + b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + + b0 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + + b2 += b3; + b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + + b0 += b3; + b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + + b2 += b1; + b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + + b1 += k3 + t2; + b0 += b1 + k2; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + + b3 += k0 + 17; + b2 += b3 + k4 + t0; + b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + + b0 += b3; + b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + + b2 += b1; + b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + + b0 += b1; + b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + + b2 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + + b0 += b3; + b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + + b2 += b1; + b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + output[0] = b0 + k3; + output[1] = b1 + k4 + t0; + output[2] = b2 + k0 + t1; + output[3] = b3 + k1 + 18; +} + +void threefish_decrypt_256(struct threefish_key *key_ctx, u64 *input, + u64 *output) +{ + u64 b0 = input[0], b1 = input[1], + b2 = input[2], b3 = input[3]; + u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], + k2 = key_ctx->key[2], k3 = key_ctx->key[3], + k4 = key_ctx->key[4]; + u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], + t2 = key_ctx->tweak[2]; + + u64 tmp; + + b0 -= k3; + b1 -= k4 + t0; + b2 -= k0 + t1; + b3 -= k1 + 18; + tmp = b3 ^ b0; + b3 = (tmp >> 32) | (tmp << (64 - 32)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 32) | (tmp << (64 - 32)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 58) | (tmp << (64 - 58)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 12) | (tmp << (64 - 12)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b0 -= b1 + k2; + b1 -= k3 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b3 + k4 + t0; + b3 -= k0 + 17; + + tmp = b3 ^ b0; + b3 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 37) | (tmp << (64 - 37)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 40) | (tmp << (64 - 40)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 52) | (tmp << (64 - 52)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 57) | (tmp << (64 - 57)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 14) | (tmp << (64 - 14)); + b0 -= b1 + k1; + b1 -= k2 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b2 -= b3 + k3 + t2; + b3 -= k4 + 16; + + + tmp = b3 ^ b0; + b3 = (tmp >> 32) | (tmp << (64 - 32)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 32) | (tmp << (64 - 32)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 58) | (tmp << (64 - 58)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 12) | (tmp << (64 - 12)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b0 -= b1 + k0; + b1 -= k1 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b3 + k2 + t1; + b3 -= k3 + 15; + + tmp = b3 ^ b0; + b3 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 37) | (tmp << (64 - 37)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 40) | (tmp << (64 - 40)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 52) | (tmp << (64 - 52)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 57) | (tmp << (64 - 57)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 14) | (tmp << (64 - 14)); + b0 -= b1 + k4; + b1 -= k0 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b2 -= b3 + k1 + t0; + b3 -= k2 + 14; + + + tmp = b3 ^ b0; + b3 = (tmp >> 32) | (tmp << (64 - 32)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 32) | (tmp << (64 - 32)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 58) | (tmp << (64 - 58)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 12) | (tmp << (64 - 12)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b0 -= b1 + k3; + b1 -= k4 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b3 + k0 + t2; + b3 -= k1 + 13; + + tmp = b3 ^ b0; + b3 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 37) | (tmp << (64 - 37)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 40) | (tmp << (64 - 40)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 52) | (tmp << (64 - 52)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 57) | (tmp << (64 - 57)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 14) | (tmp << (64 - 14)); + b0 -= b1 + k2; + b1 -= k3 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b2 -= b3 + k4 + t1; + b3 -= k0 + 12; + + + tmp = b3 ^ b0; + b3 = (tmp >> 32) | (tmp << (64 - 32)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 32) | (tmp << (64 - 32)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 58) | (tmp << (64 - 58)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 12) | (tmp << (64 - 12)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b0 -= b1 + k1; + b1 -= k2 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b3 + k3 + t0; + b3 -= k4 + 11; + + tmp = b3 ^ b0; + b3 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 37) | (tmp << (64 - 37)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 40) | (tmp << (64 - 40)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 52) | (tmp << (64 - 52)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 57) | (tmp << (64 - 57)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 14) | (tmp << (64 - 14)); + b0 -= b1 + k0; + b1 -= k1 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b2 -= b3 + k2 + t2; + b3 -= k3 + 10; + + + tmp = b3 ^ b0; + b3 = (tmp >> 32) | (tmp << (64 - 32)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 32) | (tmp << (64 - 32)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 58) | (tmp << (64 - 58)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 12) | (tmp << (64 - 12)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b0 -= b1 + k4; + b1 -= k0 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b3 + k1 + t1; + b3 -= k2 + 9; + + tmp = b3 ^ b0; + b3 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 37) | (tmp << (64 - 37)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 40) | (tmp << (64 - 40)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 52) | (tmp << (64 - 52)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 57) | (tmp << (64 - 57)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 14) | (tmp << (64 - 14)); + b0 -= b1 + k3; + b1 -= k4 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b2 -= b3 + k0 + t0; + b3 -= k1 + 8; + + + tmp = b3 ^ b0; + b3 = (tmp >> 32) | (tmp << (64 - 32)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 32) | (tmp << (64 - 32)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 58) | (tmp << (64 - 58)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 12) | (tmp << (64 - 12)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b0 -= b1 + k2; + b1 -= k3 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b3 + k4 + t2; + b3 -= k0 + 7; + + tmp = b3 ^ b0; + b3 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 37) | (tmp << (64 - 37)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 40) | (tmp << (64 - 40)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 52) | (tmp << (64 - 52)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 57) | (tmp << (64 - 57)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 14) | (tmp << (64 - 14)); + b0 -= b1 + k1; + b1 -= k2 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b2 -= b3 + k3 + t1; + b3 -= k4 + 6; + + + tmp = b3 ^ b0; + b3 = (tmp >> 32) | (tmp << (64 - 32)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 32) | (tmp << (64 - 32)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 58) | (tmp << (64 - 58)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 12) | (tmp << (64 - 12)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b0 -= b1 + k0; + b1 -= k1 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b3 + k2 + t0; + b3 -= k3 + 5; + + tmp = b3 ^ b0; + b3 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 37) | (tmp << (64 - 37)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 40) | (tmp << (64 - 40)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 52) | (tmp << (64 - 52)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 57) | (tmp << (64 - 57)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 14) | (tmp << (64 - 14)); + b0 -= b1 + k4; + b1 -= k0 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b2 -= b3 + k1 + t2; + b3 -= k2 + 4; + + + tmp = b3 ^ b0; + b3 = (tmp >> 32) | (tmp << (64 - 32)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 32) | (tmp << (64 - 32)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 58) | (tmp << (64 - 58)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 12) | (tmp << (64 - 12)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b0 -= b1 + k3; + b1 -= k4 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b3 + k0 + t1; + b3 -= k1 + 3; + + tmp = b3 ^ b0; + b3 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 37) | (tmp << (64 - 37)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 40) | (tmp << (64 - 40)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 52) | (tmp << (64 - 52)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 57) | (tmp << (64 - 57)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 14) | (tmp << (64 - 14)); + b0 -= b1 + k2; + b1 -= k3 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b2 -= b3 + k4 + t0; + b3 -= k0 + 2; + + + tmp = b3 ^ b0; + b3 = (tmp >> 32) | (tmp << (64 - 32)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 32) | (tmp << (64 - 32)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 58) | (tmp << (64 - 58)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 12) | (tmp << (64 - 12)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b0 -= b1 + k1; + b1 -= k2 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b3 + k3 + t2; + b3 -= k4 + 1; + + tmp = b3 ^ b0; + b3 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 37) | (tmp << (64 - 37)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 40) | (tmp << (64 - 40)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 52) | (tmp << (64 - 52)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 57) | (tmp << (64 - 57)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 14) | (tmp << (64 - 14)); + b0 -= b1 + k0; + b1 -= k1 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b2 -= b3 + k2 + t1; + b3 -= k3; + + output[0] = b0; + output[1] = b1; + output[2] = b2; + output[3] = b3; +} diff --git a/drivers/staging/skein/threefish_512_block.c b/drivers/staging/skein/threefish_512_block.c new file mode 100644 index 000000000000..1c62bf6a7da3 --- /dev/null +++ b/drivers/staging/skein/threefish_512_block.c @@ -0,0 +1,2225 @@ +#include +#include "threefish_api.h" + + +void threefish_encrypt_512(struct threefish_key *key_ctx, u64 *input, + u64 *output) +{ + u64 b0 = input[0], b1 = input[1], + b2 = input[2], b3 = input[3], + b4 = input[4], b5 = input[5], + b6 = input[6], b7 = input[7]; + u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], + k2 = key_ctx->key[2], k3 = key_ctx->key[3], + k4 = key_ctx->key[4], k5 = key_ctx->key[5], + k6 = key_ctx->key[6], k7 = key_ctx->key[7], + k8 = key_ctx->key[8]; + u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], + t2 = key_ctx->tweak[2]; + + b1 += k1; + b0 += b1 + k0; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + + b3 += k3; + b2 += b3 + k2; + b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + + b5 += k5 + t0; + b4 += b5 + k4; + b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + + b7 += k7; + b6 += b7 + k6 + t1; + b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + + b2 += b1; + b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + + b4 += b7; + b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + + b6 += b5; + b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + + b0 += b3; + b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + + b4 += b1; + b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + + b6 += b3; + b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + + b0 += b5; + b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + + b2 += b7; + b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + + b6 += b1; + b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + + b0 += b7; + b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + + b2 += b5; + b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + + b4 += b3; + b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + + b1 += k2; + b0 += b1 + k1; + b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + + b3 += k4; + b2 += b3 + k3; + b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + + b5 += k6 + t1; + b4 += b5 + k5; + b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + + b7 += k8 + 1; + b6 += b7 + k7 + t2; + b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + + b2 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + + b4 += b7; + b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + + b6 += b5; + b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + + b0 += b3; + b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + + b4 += b1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + + b6 += b3; + b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + + b0 += b5; + b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + + b2 += b7; + b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + + b6 += b1; + b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + + b0 += b7; + b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + + b2 += b5; + b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + + b4 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + + b1 += k3; + b0 += b1 + k2; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + + b3 += k5; + b2 += b3 + k4; + b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + + b5 += k7 + t2; + b4 += b5 + k6; + b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + + b7 += k0 + 2; + b6 += b7 + k8 + t0; + b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + + b2 += b1; + b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + + b4 += b7; + b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + + b6 += b5; + b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + + b0 += b3; + b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + + b4 += b1; + b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + + b6 += b3; + b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + + b0 += b5; + b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + + b2 += b7; + b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + + b6 += b1; + b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + + b0 += b7; + b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + + b2 += b5; + b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + + b4 += b3; + b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + + b1 += k4; + b0 += b1 + k3; + b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + + b3 += k6; + b2 += b3 + k5; + b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + + b5 += k8 + t0; + b4 += b5 + k7; + b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + + b7 += k1 + 3; + b6 += b7 + k0 + t1; + b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + + b2 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + + b4 += b7; + b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + + b6 += b5; + b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + + b0 += b3; + b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + + b4 += b1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + + b6 += b3; + b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + + b0 += b5; + b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + + b2 += b7; + b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + + b6 += b1; + b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + + b0 += b7; + b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + + b2 += b5; + b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + + b4 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + + b1 += k5; + b0 += b1 + k4; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + + b3 += k7; + b2 += b3 + k6; + b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + + b5 += k0 + t1; + b4 += b5 + k8; + b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + + b7 += k2 + 4; + b6 += b7 + k1 + t2; + b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + + b2 += b1; + b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + + b4 += b7; + b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + + b6 += b5; + b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + + b0 += b3; + b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + + b4 += b1; + b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + + b6 += b3; + b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + + b0 += b5; + b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + + b2 += b7; + b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + + b6 += b1; + b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + + b0 += b7; + b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + + b2 += b5; + b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + + b4 += b3; + b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + + b1 += k6; + b0 += b1 + k5; + b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + + b3 += k8; + b2 += b3 + k7; + b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + + b5 += k1 + t2; + b4 += b5 + k0; + b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + + b7 += k3 + 5; + b6 += b7 + k2 + t0; + b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + + b2 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + + b4 += b7; + b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + + b6 += b5; + b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + + b0 += b3; + b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + + b4 += b1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + + b6 += b3; + b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + + b0 += b5; + b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + + b2 += b7; + b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + + b6 += b1; + b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + + b0 += b7; + b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + + b2 += b5; + b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + + b4 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + + b1 += k7; + b0 += b1 + k6; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + + b3 += k0; + b2 += b3 + k8; + b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + + b5 += k2 + t0; + b4 += b5 + k1; + b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + + b7 += k4 + 6; + b6 += b7 + k3 + t1; + b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + + b2 += b1; + b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + + b4 += b7; + b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + + b6 += b5; + b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + + b0 += b3; + b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + + b4 += b1; + b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + + b6 += b3; + b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + + b0 += b5; + b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + + b2 += b7; + b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + + b6 += b1; + b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + + b0 += b7; + b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + + b2 += b5; + b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + + b4 += b3; + b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + + b1 += k8; + b0 += b1 + k7; + b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + + b3 += k1; + b2 += b3 + k0; + b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + + b5 += k3 + t1; + b4 += b5 + k2; + b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + + b7 += k5 + 7; + b6 += b7 + k4 + t2; + b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + + b2 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + + b4 += b7; + b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + + b6 += b5; + b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + + b0 += b3; + b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + + b4 += b1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + + b6 += b3; + b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + + b0 += b5; + b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + + b2 += b7; + b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + + b6 += b1; + b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + + b0 += b7; + b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + + b2 += b5; + b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + + b4 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + + b1 += k0; + b0 += b1 + k8; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + + b3 += k2; + b2 += b3 + k1; + b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + + b5 += k4 + t2; + b4 += b5 + k3; + b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + + b7 += k6 + 8; + b6 += b7 + k5 + t0; + b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + + b2 += b1; + b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + + b4 += b7; + b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + + b6 += b5; + b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + + b0 += b3; + b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + + b4 += b1; + b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + + b6 += b3; + b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + + b0 += b5; + b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + + b2 += b7; + b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + + b6 += b1; + b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + + b0 += b7; + b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + + b2 += b5; + b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + + b4 += b3; + b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + + b1 += k1; + b0 += b1 + k0; + b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + + b3 += k3; + b2 += b3 + k2; + b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + + b5 += k5 + t0; + b4 += b5 + k4; + b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + + b7 += k7 + 9; + b6 += b7 + k6 + t1; + b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + + b2 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + + b4 += b7; + b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + + b6 += b5; + b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + + b0 += b3; + b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + + b4 += b1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + + b6 += b3; + b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + + b0 += b5; + b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + + b2 += b7; + b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + + b6 += b1; + b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + + b0 += b7; + b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + + b2 += b5; + b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + + b4 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + + b1 += k2; + b0 += b1 + k1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + + b3 += k4; + b2 += b3 + k3; + b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + + b5 += k6 + t1; + b4 += b5 + k5; + b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + + b7 += k8 + 10; + b6 += b7 + k7 + t2; + b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + + b2 += b1; + b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + + b4 += b7; + b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + + b6 += b5; + b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + + b0 += b3; + b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + + b4 += b1; + b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + + b6 += b3; + b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + + b0 += b5; + b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + + b2 += b7; + b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + + b6 += b1; + b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + + b0 += b7; + b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + + b2 += b5; + b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + + b4 += b3; + b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + + b1 += k3; + b0 += b1 + k2; + b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + + b3 += k5; + b2 += b3 + k4; + b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + + b5 += k7 + t2; + b4 += b5 + k6; + b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + + b7 += k0 + 11; + b6 += b7 + k8 + t0; + b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + + b2 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + + b4 += b7; + b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + + b6 += b5; + b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + + b0 += b3; + b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + + b4 += b1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + + b6 += b3; + b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + + b0 += b5; + b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + + b2 += b7; + b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + + b6 += b1; + b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + + b0 += b7; + b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + + b2 += b5; + b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + + b4 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + + b1 += k4; + b0 += b1 + k3; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + + b3 += k6; + b2 += b3 + k5; + b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + + b5 += k8 + t0; + b4 += b5 + k7; + b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + + b7 += k1 + 12; + b6 += b7 + k0 + t1; + b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + + b2 += b1; + b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + + b4 += b7; + b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + + b6 += b5; + b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + + b0 += b3; + b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + + b4 += b1; + b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + + b6 += b3; + b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + + b0 += b5; + b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + + b2 += b7; + b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + + b6 += b1; + b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + + b0 += b7; + b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + + b2 += b5; + b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + + b4 += b3; + b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + + b1 += k5; + b0 += b1 + k4; + b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + + b3 += k7; + b2 += b3 + k6; + b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + + b5 += k0 + t1; + b4 += b5 + k8; + b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + + b7 += k2 + 13; + b6 += b7 + k1 + t2; + b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + + b2 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + + b4 += b7; + b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + + b6 += b5; + b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + + b0 += b3; + b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + + b4 += b1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + + b6 += b3; + b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + + b0 += b5; + b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + + b2 += b7; + b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + + b6 += b1; + b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + + b0 += b7; + b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + + b2 += b5; + b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + + b4 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + + b1 += k6; + b0 += b1 + k5; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + + b3 += k8; + b2 += b3 + k7; + b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + + b5 += k1 + t2; + b4 += b5 + k0; + b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + + b7 += k3 + 14; + b6 += b7 + k2 + t0; + b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + + b2 += b1; + b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + + b4 += b7; + b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + + b6 += b5; + b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + + b0 += b3; + b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + + b4 += b1; + b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + + b6 += b3; + b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + + b0 += b5; + b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + + b2 += b7; + b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + + b6 += b1; + b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + + b0 += b7; + b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + + b2 += b5; + b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + + b4 += b3; + b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + + b1 += k7; + b0 += b1 + k6; + b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + + b3 += k0; + b2 += b3 + k8; + b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + + b5 += k2 + t0; + b4 += b5 + k1; + b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + + b7 += k4 + 15; + b6 += b7 + k3 + t1; + b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + + b2 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + + b4 += b7; + b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + + b6 += b5; + b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + + b0 += b3; + b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + + b4 += b1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + + b6 += b3; + b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + + b0 += b5; + b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + + b2 += b7; + b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + + b6 += b1; + b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + + b0 += b7; + b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + + b2 += b5; + b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + + b4 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + + b1 += k8; + b0 += b1 + k7; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + + b3 += k1; + b2 += b3 + k0; + b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + + b5 += k3 + t1; + b4 += b5 + k2; + b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + + b7 += k5 + 16; + b6 += b7 + k4 + t2; + b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + + b2 += b1; + b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + + b4 += b7; + b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + + b6 += b5; + b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + + b0 += b3; + b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + + b4 += b1; + b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + + b6 += b3; + b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + + b0 += b5; + b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + + b2 += b7; + b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + + b6 += b1; + b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + + b0 += b7; + b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + + b2 += b5; + b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + + b4 += b3; + b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + + b1 += k0; + b0 += b1 + k8; + b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + + b3 += k2; + b2 += b3 + k1; + b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + + b5 += k4 + t2; + b4 += b5 + k3; + b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + + b7 += k6 + 17; + b6 += b7 + k5 + t0; + b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + + b2 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + + b4 += b7; + b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + + b6 += b5; + b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + + b0 += b3; + b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + + b4 += b1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + + b6 += b3; + b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + + b0 += b5; + b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + + b2 += b7; + b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + + b6 += b1; + b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + + b0 += b7; + b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + + b2 += b5; + b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + + b4 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + + output[0] = b0 + k0; + output[1] = b1 + k1; + output[2] = b2 + k2; + output[3] = b3 + k3; + output[4] = b4 + k4; + output[5] = b5 + k5 + t0; + output[6] = b6 + k6 + t1; + output[7] = b7 + k7 + 18; +} + +void threefish_decrypt_512(struct threefish_key *key_ctx, u64 *input, + u64 *output) +{ + u64 b0 = input[0], b1 = input[1], + b2 = input[2], b3 = input[3], + b4 = input[4], b5 = input[5], + b6 = input[6], b7 = input[7]; + u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], + k2 = key_ctx->key[2], k3 = key_ctx->key[3], + k4 = key_ctx->key[4], k5 = key_ctx->key[5], + k6 = key_ctx->key[6], k7 = key_ctx->key[7], + k8 = key_ctx->key[8]; + u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], + t2 = key_ctx->tweak[2]; + + u64 tmp; + + b0 -= k0; + b1 -= k1; + b2 -= k2; + b3 -= k3; + b4 -= k4; + b5 -= k5 + t0; + b6 -= k6 + t1; + b7 -= k7 + 18; + + tmp = b3 ^ b4; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 56) | (tmp << (64 - 56)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 35) | (tmp << (64 - 35)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 8) | (tmp << (64 - 8)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 43) | (tmp << (64 - 43)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 29) | (tmp << (64 - 29)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 17) | (tmp << (64 - 17)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 50) | (tmp << (64 - 50)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 24) | (tmp << (64 - 24)); + b6 -= b7 + k5 + t0; + b7 -= k6 + 17; + + tmp = b5 ^ b4; + b5 = (tmp >> 34) | (tmp << (64 - 34)); + b4 -= b5 + k3; + b5 -= k4 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 30) | (tmp << (64 - 30)); + b2 -= b3 + k1; + b3 -= k2; + + tmp = b1 ^ b0; + b1 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b1 + k8; + b1 -= k0; + + tmp = b3 ^ b4; + b3 = (tmp >> 56) | (tmp << (64 - 56)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 54) | (tmp << (64 - 54)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 44) | (tmp << (64 - 44)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 39) | (tmp << (64 - 39)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 36) | (tmp << (64 - 36)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 49) | (tmp << (64 - 49)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 17) | (tmp << (64 - 17)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 42) | (tmp << (64 - 42)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 14) | (tmp << (64 - 14)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 27) | (tmp << (64 - 27)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 37) | (tmp << (64 - 37)); + b6 -= b7 + k4 + t2; + b7 -= k5 + 16; + + tmp = b5 ^ b4; + b5 = (tmp >> 19) | (tmp << (64 - 19)); + b4 -= b5 + k2; + b5 -= k3 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 36) | (tmp << (64 - 36)); + b2 -= b3 + k0; + b3 -= k1; + + tmp = b1 ^ b0; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b1 + k7; + b1 -= k8; + + tmp = b3 ^ b4; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 56) | (tmp << (64 - 56)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 35) | (tmp << (64 - 35)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 8) | (tmp << (64 - 8)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 43) | (tmp << (64 - 43)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 29) | (tmp << (64 - 29)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 17) | (tmp << (64 - 17)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 50) | (tmp << (64 - 50)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 24) | (tmp << (64 - 24)); + b6 -= b7 + k3 + t1; + b7 -= k4 + 15; + + tmp = b5 ^ b4; + b5 = (tmp >> 34) | (tmp << (64 - 34)); + b4 -= b5 + k1; + b5 -= k2 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 30) | (tmp << (64 - 30)); + b2 -= b3 + k8; + b3 -= k0; + + tmp = b1 ^ b0; + b1 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b1 + k6; + b1 -= k7; + + tmp = b3 ^ b4; + b3 = (tmp >> 56) | (tmp << (64 - 56)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 54) | (tmp << (64 - 54)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 44) | (tmp << (64 - 44)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 39) | (tmp << (64 - 39)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 36) | (tmp << (64 - 36)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 49) | (tmp << (64 - 49)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 17) | (tmp << (64 - 17)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 42) | (tmp << (64 - 42)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 14) | (tmp << (64 - 14)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 27) | (tmp << (64 - 27)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 37) | (tmp << (64 - 37)); + b6 -= b7 + k2 + t0; + b7 -= k3 + 14; + + tmp = b5 ^ b4; + b5 = (tmp >> 19) | (tmp << (64 - 19)); + b4 -= b5 + k0; + b5 -= k1 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 36) | (tmp << (64 - 36)); + b2 -= b3 + k7; + b3 -= k8; + + tmp = b1 ^ b0; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b1 + k5; + b1 -= k6; + + tmp = b3 ^ b4; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 56) | (tmp << (64 - 56)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 35) | (tmp << (64 - 35)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 8) | (tmp << (64 - 8)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 43) | (tmp << (64 - 43)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 29) | (tmp << (64 - 29)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 17) | (tmp << (64 - 17)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 50) | (tmp << (64 - 50)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 24) | (tmp << (64 - 24)); + b6 -= b7 + k1 + t2; + b7 -= k2 + 13; + + tmp = b5 ^ b4; + b5 = (tmp >> 34) | (tmp << (64 - 34)); + b4 -= b5 + k8; + b5 -= k0 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 30) | (tmp << (64 - 30)); + b2 -= b3 + k6; + b3 -= k7; + + tmp = b1 ^ b0; + b1 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b1 + k4; + b1 -= k5; + + tmp = b3 ^ b4; + b3 = (tmp >> 56) | (tmp << (64 - 56)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 54) | (tmp << (64 - 54)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 44) | (tmp << (64 - 44)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 39) | (tmp << (64 - 39)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 36) | (tmp << (64 - 36)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 49) | (tmp << (64 - 49)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 17) | (tmp << (64 - 17)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 42) | (tmp << (64 - 42)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 14) | (tmp << (64 - 14)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 27) | (tmp << (64 - 27)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 37) | (tmp << (64 - 37)); + b6 -= b7 + k0 + t1; + b7 -= k1 + 12; + + tmp = b5 ^ b4; + b5 = (tmp >> 19) | (tmp << (64 - 19)); + b4 -= b5 + k7; + b5 -= k8 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 36) | (tmp << (64 - 36)); + b2 -= b3 + k5; + b3 -= k6; + + tmp = b1 ^ b0; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b1 + k3; + b1 -= k4; + + tmp = b3 ^ b4; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 56) | (tmp << (64 - 56)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 35) | (tmp << (64 - 35)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 8) | (tmp << (64 - 8)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 43) | (tmp << (64 - 43)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 29) | (tmp << (64 - 29)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 17) | (tmp << (64 - 17)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 50) | (tmp << (64 - 50)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 24) | (tmp << (64 - 24)); + b6 -= b7 + k8 + t0; + b7 -= k0 + 11; + + tmp = b5 ^ b4; + b5 = (tmp >> 34) | (tmp << (64 - 34)); + b4 -= b5 + k6; + b5 -= k7 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 30) | (tmp << (64 - 30)); + b2 -= b3 + k4; + b3 -= k5; + + tmp = b1 ^ b0; + b1 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b1 + k2; + b1 -= k3; + + tmp = b3 ^ b4; + b3 = (tmp >> 56) | (tmp << (64 - 56)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 54) | (tmp << (64 - 54)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 44) | (tmp << (64 - 44)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 39) | (tmp << (64 - 39)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 36) | (tmp << (64 - 36)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 49) | (tmp << (64 - 49)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 17) | (tmp << (64 - 17)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 42) | (tmp << (64 - 42)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 14) | (tmp << (64 - 14)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 27) | (tmp << (64 - 27)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 37) | (tmp << (64 - 37)); + b6 -= b7 + k7 + t2; + b7 -= k8 + 10; + + tmp = b5 ^ b4; + b5 = (tmp >> 19) | (tmp << (64 - 19)); + b4 -= b5 + k5; + b5 -= k6 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 36) | (tmp << (64 - 36)); + b2 -= b3 + k3; + b3 -= k4; + + tmp = b1 ^ b0; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b1 + k1; + b1 -= k2; + + tmp = b3 ^ b4; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 56) | (tmp << (64 - 56)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 35) | (tmp << (64 - 35)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 8) | (tmp << (64 - 8)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 43) | (tmp << (64 - 43)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 29) | (tmp << (64 - 29)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 17) | (tmp << (64 - 17)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 50) | (tmp << (64 - 50)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 24) | (tmp << (64 - 24)); + b6 -= b7 + k6 + t1; + b7 -= k7 + 9; + + tmp = b5 ^ b4; + b5 = (tmp >> 34) | (tmp << (64 - 34)); + b4 -= b5 + k4; + b5 -= k5 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 30) | (tmp << (64 - 30)); + b2 -= b3 + k2; + b3 -= k3; + + tmp = b1 ^ b0; + b1 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b1 + k0; + b1 -= k1; + + tmp = b3 ^ b4; + b3 = (tmp >> 56) | (tmp << (64 - 56)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 54) | (tmp << (64 - 54)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 44) | (tmp << (64 - 44)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 39) | (tmp << (64 - 39)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 36) | (tmp << (64 - 36)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 49) | (tmp << (64 - 49)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 17) | (tmp << (64 - 17)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 42) | (tmp << (64 - 42)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 14) | (tmp << (64 - 14)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 27) | (tmp << (64 - 27)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 37) | (tmp << (64 - 37)); + b6 -= b7 + k5 + t0; + b7 -= k6 + 8; + + tmp = b5 ^ b4; + b5 = (tmp >> 19) | (tmp << (64 - 19)); + b4 -= b5 + k3; + b5 -= k4 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 36) | (tmp << (64 - 36)); + b2 -= b3 + k1; + b3 -= k2; + + tmp = b1 ^ b0; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b1 + k8; + b1 -= k0; + + tmp = b3 ^ b4; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 56) | (tmp << (64 - 56)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 35) | (tmp << (64 - 35)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 8) | (tmp << (64 - 8)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 43) | (tmp << (64 - 43)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 29) | (tmp << (64 - 29)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 17) | (tmp << (64 - 17)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 50) | (tmp << (64 - 50)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 24) | (tmp << (64 - 24)); + b6 -= b7 + k4 + t2; + b7 -= k5 + 7; + + tmp = b5 ^ b4; + b5 = (tmp >> 34) | (tmp << (64 - 34)); + b4 -= b5 + k2; + b5 -= k3 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 30) | (tmp << (64 - 30)); + b2 -= b3 + k0; + b3 -= k1; + + tmp = b1 ^ b0; + b1 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b1 + k7; + b1 -= k8; + + tmp = b3 ^ b4; + b3 = (tmp >> 56) | (tmp << (64 - 56)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 54) | (tmp << (64 - 54)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 44) | (tmp << (64 - 44)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 39) | (tmp << (64 - 39)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 36) | (tmp << (64 - 36)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 49) | (tmp << (64 - 49)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 17) | (tmp << (64 - 17)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 42) | (tmp << (64 - 42)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 14) | (tmp << (64 - 14)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 27) | (tmp << (64 - 27)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 37) | (tmp << (64 - 37)); + b6 -= b7 + k3 + t1; + b7 -= k4 + 6; + + tmp = b5 ^ b4; + b5 = (tmp >> 19) | (tmp << (64 - 19)); + b4 -= b5 + k1; + b5 -= k2 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 36) | (tmp << (64 - 36)); + b2 -= b3 + k8; + b3 -= k0; + + tmp = b1 ^ b0; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b1 + k6; + b1 -= k7; + + tmp = b3 ^ b4; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 56) | (tmp << (64 - 56)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 35) | (tmp << (64 - 35)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 8) | (tmp << (64 - 8)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 43) | (tmp << (64 - 43)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 29) | (tmp << (64 - 29)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 17) | (tmp << (64 - 17)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 50) | (tmp << (64 - 50)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 24) | (tmp << (64 - 24)); + b6 -= b7 + k2 + t0; + b7 -= k3 + 5; + + tmp = b5 ^ b4; + b5 = (tmp >> 34) | (tmp << (64 - 34)); + b4 -= b5 + k0; + b5 -= k1 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 30) | (tmp << (64 - 30)); + b2 -= b3 + k7; + b3 -= k8; + + tmp = b1 ^ b0; + b1 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b1 + k5; + b1 -= k6; + + tmp = b3 ^ b4; + b3 = (tmp >> 56) | (tmp << (64 - 56)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 54) | (tmp << (64 - 54)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 44) | (tmp << (64 - 44)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 39) | (tmp << (64 - 39)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 36) | (tmp << (64 - 36)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 49) | (tmp << (64 - 49)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 17) | (tmp << (64 - 17)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 42) | (tmp << (64 - 42)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 14) | (tmp << (64 - 14)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 27) | (tmp << (64 - 27)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 37) | (tmp << (64 - 37)); + b6 -= b7 + k1 + t2; + b7 -= k2 + 4; + + tmp = b5 ^ b4; + b5 = (tmp >> 19) | (tmp << (64 - 19)); + b4 -= b5 + k8; + b5 -= k0 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 36) | (tmp << (64 - 36)); + b2 -= b3 + k6; + b3 -= k7; + + tmp = b1 ^ b0; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b1 + k4; + b1 -= k5; + + tmp = b3 ^ b4; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 56) | (tmp << (64 - 56)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 35) | (tmp << (64 - 35)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 8) | (tmp << (64 - 8)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 43) | (tmp << (64 - 43)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 29) | (tmp << (64 - 29)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 17) | (tmp << (64 - 17)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 50) | (tmp << (64 - 50)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 24) | (tmp << (64 - 24)); + b6 -= b7 + k0 + t1; + b7 -= k1 + 3; + + tmp = b5 ^ b4; + b5 = (tmp >> 34) | (tmp << (64 - 34)); + b4 -= b5 + k7; + b5 -= k8 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 30) | (tmp << (64 - 30)); + b2 -= b3 + k5; + b3 -= k6; + + tmp = b1 ^ b0; + b1 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b1 + k3; + b1 -= k4; + + tmp = b3 ^ b4; + b3 = (tmp >> 56) | (tmp << (64 - 56)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 54) | (tmp << (64 - 54)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 44) | (tmp << (64 - 44)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 39) | (tmp << (64 - 39)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 36) | (tmp << (64 - 36)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 49) | (tmp << (64 - 49)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 17) | (tmp << (64 - 17)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 42) | (tmp << (64 - 42)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 14) | (tmp << (64 - 14)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 27) | (tmp << (64 - 27)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 37) | (tmp << (64 - 37)); + b6 -= b7 + k8 + t0; + b7 -= k0 + 2; + + tmp = b5 ^ b4; + b5 = (tmp >> 19) | (tmp << (64 - 19)); + b4 -= b5 + k6; + b5 -= k7 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 36) | (tmp << (64 - 36)); + b2 -= b3 + k4; + b3 -= k5; + + tmp = b1 ^ b0; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b1 + k2; + b1 -= k3; + + tmp = b3 ^ b4; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 56) | (tmp << (64 - 56)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 35) | (tmp << (64 - 35)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 8) | (tmp << (64 - 8)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 43) | (tmp << (64 - 43)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 29) | (tmp << (64 - 29)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 17) | (tmp << (64 - 17)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 50) | (tmp << (64 - 50)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 24) | (tmp << (64 - 24)); + b6 -= b7 + k7 + t2; + b7 -= k8 + 1; + + tmp = b5 ^ b4; + b5 = (tmp >> 34) | (tmp << (64 - 34)); + b4 -= b5 + k5; + b5 -= k6 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 30) | (tmp << (64 - 30)); + b2 -= b3 + k3; + b3 -= k4; + + tmp = b1 ^ b0; + b1 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b1 + k1; + b1 -= k2; + + tmp = b3 ^ b4; + b3 = (tmp >> 56) | (tmp << (64 - 56)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 54) | (tmp << (64 - 54)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 44) | (tmp << (64 - 44)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 39) | (tmp << (64 - 39)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 36) | (tmp << (64 - 36)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 49) | (tmp << (64 - 49)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 17) | (tmp << (64 - 17)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 42) | (tmp << (64 - 42)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 14) | (tmp << (64 - 14)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 27) | (tmp << (64 - 27)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 37) | (tmp << (64 - 37)); + b6 -= b7 + k6 + t1; + b7 -= k7; + + tmp = b5 ^ b4; + b5 = (tmp >> 19) | (tmp << (64 - 19)); + b4 -= b5 + k4; + b5 -= k5 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 36) | (tmp << (64 - 36)); + b2 -= b3 + k2; + b3 -= k3; + + tmp = b1 ^ b0; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b1 + k0; + b1 -= k1; + + output[0] = b0; + output[1] = b1; + output[2] = b2; + output[3] = b3; + + output[7] = b7; + output[6] = b6; + output[5] = b5; + output[4] = b4; +} diff --git a/drivers/staging/skein/threefish_api.c b/drivers/staging/skein/threefish_api.c new file mode 100644 index 000000000000..2b649abb78c7 --- /dev/null +++ b/drivers/staging/skein/threefish_api.c @@ -0,0 +1,77 @@ +#include +#include "threefish_api.h" + +void threefish_set_key(struct threefish_key *key_ctx, + enum threefish_size state_size, + u64 *key_data, u64 *tweak) +{ + int key_words = state_size / 64; + int i; + u64 parity = KEY_SCHEDULE_CONST; + + key_ctx->tweak[0] = tweak[0]; + key_ctx->tweak[1] = tweak[1]; + key_ctx->tweak[2] = tweak[0] ^ tweak[1]; + + for (i = 0; i < key_words; i++) { + key_ctx->key[i] = key_data[i]; + parity ^= key_data[i]; + } + key_ctx->key[i] = parity; + key_ctx->state_size = state_size; +} + +void threefish_encrypt_block_bytes(struct threefish_key *key_ctx, u8 *in, + u8 *out) +{ + u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ + u64 cipher[SKEIN_MAX_STATE_WORDS]; + + skein_get64_lsb_first(plain, in, key_ctx->state_size / 64); + threefish_encrypt_block_words(key_ctx, plain, cipher); + skein_put64_lsb_first(out, cipher, key_ctx->state_size / 8); +} + +void threefish_encrypt_block_words(struct threefish_key *key_ctx, u64 *in, + u64 *out) +{ + switch (key_ctx->state_size) { + case THREEFISH_256: + threefish_encrypt_256(key_ctx, in, out); + break; + case THREEFISH_512: + threefish_encrypt_512(key_ctx, in, out); + break; + case THREEFISH_1024: + threefish_encrypt_1024(key_ctx, in, out); + break; + } +} + +void threefish_decrypt_block_bytes(struct threefish_key *key_ctx, u8 *in, + u8 *out) +{ + u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ + u64 cipher[SKEIN_MAX_STATE_WORDS]; + + skein_get64_lsb_first(cipher, in, key_ctx->state_size / 64); + threefish_decrypt_block_words(key_ctx, cipher, plain); + skein_put64_lsb_first(out, plain, key_ctx->state_size / 8); +} + +void threefish_decrypt_block_words(struct threefish_key *key_ctx, u64 *in, + u64 *out) +{ + switch (key_ctx->state_size) { + case THREEFISH_256: + threefish_decrypt_256(key_ctx, in, out); + break; + case THREEFISH_512: + threefish_decrypt_512(key_ctx, in, out); + break; + case THREEFISH_1024: + threefish_decrypt_1024(key_ctx, in, out); + break; + } +} + diff --git a/drivers/staging/skein/threefish_api.h b/drivers/staging/skein/threefish_api.h new file mode 100644 index 000000000000..2fce154b59e5 --- /dev/null +++ b/drivers/staging/skein/threefish_api.h @@ -0,0 +1,170 @@ + +#ifndef THREEFISHAPI_H +#define THREEFISHAPI_H + +/** + * @file threefish_api.h + * @brief A Threefish cipher API and its functions. + * @{ + * + * This API and the functions that implement this API simplify the usage + * of the Threefish cipher. The design and the way to use the functions + * follow the openSSL design but at the same time take care of some Threefish + * specific behaviour and possibilities. + * + * These are the low level functions that deal with Threefisch blocks only. + * Implementations for cipher modes such as ECB, CFB, or CBC may use these + * functions. + * +@code + // Threefish cipher context data + struct threefish_key key_ctx; + + // Initialize the context + threefish_set_key(&key_ctx, THREEFISH_512, key, tweak); + + // Encrypt + threefish_encrypt_block_bytes(&key_ctx, input, cipher); +@endcode + */ + +#include +#include "skein.h" + +#define KEY_SCHEDULE_CONST 0x1BD11BDAA9FC1A22L + +/** + * Which Threefish size to use + */ +enum threefish_size { + THREEFISH_256 = 256, /*!< Skein with 256 bit state */ + THREEFISH_512 = 512, /*!< Skein with 512 bit state */ + THREEFISH_1024 = 1024 /*!< Skein with 1024 bit state */ +}; + +/** + * Context for Threefish key and tweak words. + * + * This structure was setup with some know-how of the internal + * Skein structures, in particular ordering of header and size dependent + * variables. If Skein implementation changes this, the adapt these + * structures as well. + */ +struct threefish_key { + u64 state_size; + u64 key[SKEIN_MAX_STATE_WORDS+1]; /* max number of key words*/ + u64 tweak[3]; +}; + +/** + * Set Threefish key and tweak data. + * + * This function sets the key and tweak data for the Threefish cipher of + * the given size. The key data must have the same length (number of bits) + * as the state size + * + * @param key_ctx + * Pointer to a Threefish key structure. + * @param size + * Which Skein size to use. + * @param key_data + * Pointer to the key words (word has 64 bits). + * @param tweak + * Pointer to the two tweak words (word has 64 bits). + */ +void threefish_set_key(struct threefish_key *key_ctx, + enum threefish_size state_size, + u64 *key_data, u64 *tweak); + +/** + * Encrypt Threefisch block (bytes). + * + * The buffer must have at least the same length (number of bits) aas the + * state size for this key. The function uses the first @c state_size bits + * of the input buffer, encrypts them and stores the result in the output + * buffer. + * + * @param key_ctx + * Pointer to a Threefish key structure. + * @param in + * Poionter to plaintext data buffer. + * @param out + * Pointer to cipher buffer. + */ +void threefish_encrypt_block_bytes(struct threefish_key *key_ctx, u8 *in, + u8 *out); + +/** + * Encrypt Threefisch block (words). + * + * The buffer must have at least the same length (number of bits) aas the + * state size for this key. The function uses the first @c state_size bits + * of the input buffer, encrypts them and stores the result in the output + * buffer. + * + * The wordsize ist set to 64 bits. + * + * @param key_ctx + * Pointer to a Threefish key structure. + * @param in + * Poionter to plaintext data buffer. + * @param out + * Pointer to cipher buffer. + */ +void threefish_encrypt_block_words(struct threefish_key *key_ctx, u64 *in, + u64 *out); + +/** + * Decrypt Threefisch block (bytes). + * + * The buffer must have at least the same length (number of bits) aas the + * state size for this key. The function uses the first @c state_size bits + * of the input buffer, decrypts them and stores the result in the output + * buffer + * + * @param key_ctx + * Pointer to a Threefish key structure. + * @param in + * Poionter to cipher data buffer. + * @param out + * Pointer to plaintext buffer. + */ +void threefish_decrypt_block_bytes(struct threefish_key *key_ctx, u8 *in, + u8 *out); + +/** + * Decrypt Threefisch block (words). + * + * The buffer must have at least the same length (number of bits) aas the + * state size for this key. The function uses the first @c state_size bits + * of the input buffer, encrypts them and stores the result in the output + * buffer. + * + * The wordsize ist set to 64 bits. + * + * @param key_ctx + * Pointer to a Threefish key structure. + * @param in + * Poionter to cipher data buffer. + * @param out + * Pointer to plaintext buffer. + */ +void threefish_decrypt_block_words(struct threefish_key *key_ctx, u64 *in, + u64 *out); + +void threefish_encrypt_256(struct threefish_key *key_ctx, u64 *input, + u64 *output); +void threefish_encrypt_512(struct threefish_key *key_ctx, u64 *input, + u64 *output); +void threefish_encrypt_1024(struct threefish_key *key_ctx, u64 *input, + u64 *output); +void threefish_decrypt_256(struct threefish_key *key_ctx, u64 *input, + u64 *output); +void threefish_decrypt_512(struct threefish_key *key_ctx, u64 *input, + u64 *output); +void threefish_decrypt_1024(struct threefish_key *key_ctx, u64 *input, + u64 *output); +/** + * @} + */ +#endif -- cgit v1.2.3 From 8d9e9857c576d8d710ae6a6152a6ddcd29772bb1 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 19 May 2014 14:34:09 +0100 Subject: goldfish: fix >> 32 warning We should be checking for a 64bit platform not 64bit DMA address types in the case of Goldfish. The Goldfish virtual platform is either 32/32 or 64/64. Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- include/linux/goldfish.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/goldfish.h b/include/linux/goldfish.h index 9cc28902b54c..569236e6b2bc 100644 --- a/include/linux/goldfish.h +++ b/include/linux/goldfish.h @@ -7,7 +7,7 @@ static inline void gf_write64(unsigned long data, void __iomem *portl, void __iomem *porth) { writel((u32)data, portl); -#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT +#ifdef CONFIG_64BIT writel(data>>32, porth); #endif } -- cgit v1.2.3 From 0109ce7304afb58102ea1545f609f4cf876b0949 Mon Sep 17 00:00:00 2001 From: Jake Edge Date: Tue, 20 May 2014 07:58:40 -0600 Subject: staging/skein: move all threefish block functions to one file move all threefish block functions to one file, remove unneeded include Signed-off-by: Jake Edge Acked-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/Makefile | 4 +- drivers/staging/skein/threefish_1024_block.c | 4902 --------------- drivers/staging/skein/threefish_256_block.c | 1139 ---- drivers/staging/skein/threefish_512_block.c | 2225 ------- drivers/staging/skein/threefish_block.c | 8258 ++++++++++++++++++++++++++ 5 files changed, 8259 insertions(+), 8269 deletions(-) delete mode 100644 drivers/staging/skein/threefish_1024_block.c delete mode 100644 drivers/staging/skein/threefish_256_block.c delete mode 100644 drivers/staging/skein/threefish_512_block.c create mode 100644 drivers/staging/skein/threefish_block.c diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile index 395454cea433..a14aaddd829c 100644 --- a/drivers/staging/skein/Makefile +++ b/drivers/staging/skein/Makefile @@ -5,7 +5,5 @@ obj-$(CONFIG_CRYPTO_SKEIN) += skein.o \ skein_api.o \ skein_block.o -obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_1024_block.o \ - threefish_256_block.o \ - threefish_512_block.o \ +obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_block.o \ threefish_api.o diff --git a/drivers/staging/skein/threefish_1024_block.c b/drivers/staging/skein/threefish_1024_block.c deleted file mode 100644 index dac74e10d6e4..000000000000 --- a/drivers/staging/skein/threefish_1024_block.c +++ /dev/null @@ -1,4902 +0,0 @@ -#include -#include "threefish_api.h" - - -void threefish_encrypt_1024(struct threefish_key *key_ctx, u64 *input, - u64 *output) -{ - u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3], - b4 = input[4], b5 = input[5], - b6 = input[6], b7 = input[7], - b8 = input[8], b9 = input[9], - b10 = input[10], b11 = input[11], - b12 = input[12], b13 = input[13], - b14 = input[14], b15 = input[15]; - u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], - k2 = key_ctx->key[2], k3 = key_ctx->key[3], - k4 = key_ctx->key[4], k5 = key_ctx->key[5], - k6 = key_ctx->key[6], k7 = key_ctx->key[7], - k8 = key_ctx->key[8], k9 = key_ctx->key[9], - k10 = key_ctx->key[10], k11 = key_ctx->key[11], - k12 = key_ctx->key[12], k13 = key_ctx->key[13], - k14 = key_ctx->key[14], k15 = key_ctx->key[15], - k16 = key_ctx->key[16]; - u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], - t2 = key_ctx->tweak[2]; - - b1 += k1; - b0 += b1 + k0; - b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - - b3 += k3; - b2 += b3 + k2; - b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - - b5 += k5; - b4 += b5 + k4; - b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - - b7 += k7; - b6 += b7 + k6; - b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - - b9 += k9; - b8 += b9 + k8; - b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - - b11 += k11; - b10 += b11 + k10; - b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - - b13 += k13 + t0; - b12 += b13 + k12; - b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - - b15 += k15; - b14 += b15 + k14 + t1; - b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - - b0 += b9; - b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - - b2 += b13; - b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - - b6 += b11; - b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - - b4 += b15; - b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - - b10 += b7; - b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - - b12 += b3; - b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - - b14 += b5; - b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - - b8 += b1; - b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - - b0 += b7; - b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - - b2 += b5; - b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - - b4 += b3; - b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - - b6 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - - b12 += b15; - b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - - b14 += b13; - b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - - b8 += b11; - b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - - b10 += b9; - b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - - b0 += b15; - b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - - b2 += b11; - b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - - b6 += b13; - b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - - b4 += b9; - b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - - b14 += b1; - b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - - b8 += b5; - b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - - b10 += b3; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - - b12 += b7; - b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - - b1 += k2; - b0 += b1 + k1; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - - b3 += k4; - b2 += b3 + k3; - b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - - b5 += k6; - b4 += b5 + k5; - b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - - b7 += k8; - b6 += b7 + k7; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - - b9 += k10; - b8 += b9 + k9; - b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - - b11 += k12; - b10 += b11 + k11; - b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - - b13 += k14 + t1; - b12 += b13 + k13; - b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - - b15 += k16 + 1; - b14 += b15 + k15 + t2; - b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - - b0 += b9; - b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - - b2 += b13; - b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - - b6 += b11; - b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - - b4 += b15; - b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - - b10 += b7; - b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - - b12 += b3; - b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - - b14 += b5; - b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - - b8 += b1; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - - b0 += b7; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - - b2 += b5; - b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - - b4 += b3; - b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - - b6 += b1; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - - b12 += b15; - b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - - b14 += b13; - b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - - b8 += b11; - b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - - b10 += b9; - b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - - b0 += b15; - b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - - b2 += b11; - b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - - b6 += b13; - b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - - b4 += b9; - b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - - b14 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - - b8 += b5; - b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - - b10 += b3; - b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - - b12 += b7; - b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - - b1 += k3; - b0 += b1 + k2; - b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - - b3 += k5; - b2 += b3 + k4; - b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - - b5 += k7; - b4 += b5 + k6; - b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - - b7 += k9; - b6 += b7 + k8; - b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - - b9 += k11; - b8 += b9 + k10; - b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - - b11 += k13; - b10 += b11 + k12; - b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - - b13 += k15 + t2; - b12 += b13 + k14; - b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - - b15 += k0 + 2; - b14 += b15 + k16 + t0; - b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - - b0 += b9; - b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - - b2 += b13; - b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - - b6 += b11; - b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - - b4 += b15; - b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - - b10 += b7; - b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - - b12 += b3; - b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - - b14 += b5; - b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - - b8 += b1; - b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - - b0 += b7; - b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - - b2 += b5; - b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - - b4 += b3; - b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - - b6 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - - b12 += b15; - b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - - b14 += b13; - b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - - b8 += b11; - b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - - b10 += b9; - b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - - b0 += b15; - b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - - b2 += b11; - b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - - b6 += b13; - b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - - b4 += b9; - b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - - b14 += b1; - b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - - b8 += b5; - b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - - b10 += b3; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - - b12 += b7; - b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - - b1 += k4; - b0 += b1 + k3; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - - b3 += k6; - b2 += b3 + k5; - b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - - b5 += k8; - b4 += b5 + k7; - b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - - b7 += k10; - b6 += b7 + k9; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - - b9 += k12; - b8 += b9 + k11; - b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - - b11 += k14; - b10 += b11 + k13; - b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - - b13 += k16 + t0; - b12 += b13 + k15; - b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - - b15 += k1 + 3; - b14 += b15 + k0 + t1; - b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - - b0 += b9; - b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - - b2 += b13; - b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - - b6 += b11; - b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - - b4 += b15; - b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - - b10 += b7; - b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - - b12 += b3; - b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - - b14 += b5; - b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - - b8 += b1; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - - b0 += b7; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - - b2 += b5; - b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - - b4 += b3; - b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - - b6 += b1; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - - b12 += b15; - b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - - b14 += b13; - b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - - b8 += b11; - b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - - b10 += b9; - b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - - b0 += b15; - b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - - b2 += b11; - b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - - b6 += b13; - b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - - b4 += b9; - b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - - b14 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - - b8 += b5; - b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - - b10 += b3; - b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - - b12 += b7; - b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - - b1 += k5; - b0 += b1 + k4; - b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - - b3 += k7; - b2 += b3 + k6; - b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - - b5 += k9; - b4 += b5 + k8; - b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - - b7 += k11; - b6 += b7 + k10; - b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - - b9 += k13; - b8 += b9 + k12; - b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - - b11 += k15; - b10 += b11 + k14; - b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - - b13 += k0 + t1; - b12 += b13 + k16; - b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - - b15 += k2 + 4; - b14 += b15 + k1 + t2; - b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - - b0 += b9; - b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - - b2 += b13; - b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - - b6 += b11; - b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - - b4 += b15; - b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - - b10 += b7; - b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - - b12 += b3; - b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - - b14 += b5; - b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - - b8 += b1; - b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - - b0 += b7; - b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - - b2 += b5; - b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - - b4 += b3; - b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - - b6 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - - b12 += b15; - b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - - b14 += b13; - b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - - b8 += b11; - b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - - b10 += b9; - b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - - b0 += b15; - b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - - b2 += b11; - b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - - b6 += b13; - b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - - b4 += b9; - b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - - b14 += b1; - b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - - b8 += b5; - b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - - b10 += b3; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - - b12 += b7; - b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - - b1 += k6; - b0 += b1 + k5; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - - b3 += k8; - b2 += b3 + k7; - b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - - b5 += k10; - b4 += b5 + k9; - b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - - b7 += k12; - b6 += b7 + k11; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - - b9 += k14; - b8 += b9 + k13; - b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - - b11 += k16; - b10 += b11 + k15; - b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - - b13 += k1 + t2; - b12 += b13 + k0; - b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - - b15 += k3 + 5; - b14 += b15 + k2 + t0; - b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - - b0 += b9; - b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - - b2 += b13; - b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - - b6 += b11; - b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - - b4 += b15; - b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - - b10 += b7; - b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - - b12 += b3; - b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - - b14 += b5; - b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - - b8 += b1; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - - b0 += b7; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - - b2 += b5; - b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - - b4 += b3; - b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - - b6 += b1; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - - b12 += b15; - b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - - b14 += b13; - b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - - b8 += b11; - b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - - b10 += b9; - b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - - b0 += b15; - b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - - b2 += b11; - b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - - b6 += b13; - b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - - b4 += b9; - b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - - b14 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - - b8 += b5; - b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - - b10 += b3; - b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - - b12 += b7; - b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - - b1 += k7; - b0 += b1 + k6; - b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - - b3 += k9; - b2 += b3 + k8; - b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - - b5 += k11; - b4 += b5 + k10; - b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - - b7 += k13; - b6 += b7 + k12; - b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - - b9 += k15; - b8 += b9 + k14; - b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - - b11 += k0; - b10 += b11 + k16; - b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - - b13 += k2 + t0; - b12 += b13 + k1; - b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - - b15 += k4 + 6; - b14 += b15 + k3 + t1; - b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - - b0 += b9; - b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - - b2 += b13; - b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - - b6 += b11; - b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - - b4 += b15; - b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - - b10 += b7; - b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - - b12 += b3; - b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - - b14 += b5; - b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - - b8 += b1; - b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - - b0 += b7; - b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - - b2 += b5; - b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - - b4 += b3; - b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - - b6 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - - b12 += b15; - b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - - b14 += b13; - b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - - b8 += b11; - b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - - b10 += b9; - b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - - b0 += b15; - b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - - b2 += b11; - b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - - b6 += b13; - b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - - b4 += b9; - b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - - b14 += b1; - b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - - b8 += b5; - b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - - b10 += b3; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - - b12 += b7; - b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - - b1 += k8; - b0 += b1 + k7; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - - b3 += k10; - b2 += b3 + k9; - b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - - b5 += k12; - b4 += b5 + k11; - b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - - b7 += k14; - b6 += b7 + k13; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - - b9 += k16; - b8 += b9 + k15; - b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - - b11 += k1; - b10 += b11 + k0; - b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - - b13 += k3 + t1; - b12 += b13 + k2; - b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - - b15 += k5 + 7; - b14 += b15 + k4 + t2; - b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - - b0 += b9; - b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - - b2 += b13; - b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - - b6 += b11; - b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - - b4 += b15; - b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - - b10 += b7; - b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - - b12 += b3; - b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - - b14 += b5; - b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - - b8 += b1; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - - b0 += b7; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - - b2 += b5; - b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - - b4 += b3; - b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - - b6 += b1; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - - b12 += b15; - b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - - b14 += b13; - b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - - b8 += b11; - b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - - b10 += b9; - b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - - b0 += b15; - b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - - b2 += b11; - b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - - b6 += b13; - b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - - b4 += b9; - b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - - b14 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - - b8 += b5; - b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - - b10 += b3; - b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - - b12 += b7; - b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - - b1 += k9; - b0 += b1 + k8; - b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - - b3 += k11; - b2 += b3 + k10; - b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - - b5 += k13; - b4 += b5 + k12; - b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - - b7 += k15; - b6 += b7 + k14; - b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - - b9 += k0; - b8 += b9 + k16; - b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - - b11 += k2; - b10 += b11 + k1; - b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - - b13 += k4 + t2; - b12 += b13 + k3; - b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - - b15 += k6 + 8; - b14 += b15 + k5 + t0; - b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - - b0 += b9; - b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - - b2 += b13; - b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - - b6 += b11; - b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - - b4 += b15; - b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - - b10 += b7; - b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - - b12 += b3; - b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - - b14 += b5; - b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - - b8 += b1; - b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - - b0 += b7; - b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - - b2 += b5; - b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - - b4 += b3; - b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - - b6 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - - b12 += b15; - b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - - b14 += b13; - b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - - b8 += b11; - b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - - b10 += b9; - b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - - b0 += b15; - b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - - b2 += b11; - b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - - b6 += b13; - b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - - b4 += b9; - b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - - b14 += b1; - b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - - b8 += b5; - b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - - b10 += b3; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - - b12 += b7; - b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - - b1 += k10; - b0 += b1 + k9; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - - b3 += k12; - b2 += b3 + k11; - b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - - b5 += k14; - b4 += b5 + k13; - b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - - b7 += k16; - b6 += b7 + k15; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - - b9 += k1; - b8 += b9 + k0; - b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - - b11 += k3; - b10 += b11 + k2; - b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - - b13 += k5 + t0; - b12 += b13 + k4; - b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - - b15 += k7 + 9; - b14 += b15 + k6 + t1; - b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - - b0 += b9; - b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - - b2 += b13; - b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - - b6 += b11; - b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - - b4 += b15; - b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - - b10 += b7; - b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - - b12 += b3; - b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - - b14 += b5; - b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - - b8 += b1; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - - b0 += b7; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - - b2 += b5; - b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - - b4 += b3; - b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - - b6 += b1; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - - b12 += b15; - b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - - b14 += b13; - b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - - b8 += b11; - b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - - b10 += b9; - b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - - b0 += b15; - b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - - b2 += b11; - b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - - b6 += b13; - b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - - b4 += b9; - b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - - b14 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - - b8 += b5; - b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - - b10 += b3; - b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - - b12 += b7; - b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - - b1 += k11; - b0 += b1 + k10; - b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - - b3 += k13; - b2 += b3 + k12; - b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - - b5 += k15; - b4 += b5 + k14; - b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - - b7 += k0; - b6 += b7 + k16; - b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - - b9 += k2; - b8 += b9 + k1; - b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - - b11 += k4; - b10 += b11 + k3; - b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - - b13 += k6 + t1; - b12 += b13 + k5; - b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - - b15 += k8 + 10; - b14 += b15 + k7 + t2; - b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - - b0 += b9; - b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - - b2 += b13; - b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - - b6 += b11; - b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - - b4 += b15; - b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - - b10 += b7; - b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - - b12 += b3; - b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - - b14 += b5; - b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - - b8 += b1; - b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - - b0 += b7; - b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - - b2 += b5; - b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - - b4 += b3; - b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - - b6 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - - b12 += b15; - b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - - b14 += b13; - b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - - b8 += b11; - b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - - b10 += b9; - b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - - b0 += b15; - b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - - b2 += b11; - b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - - b6 += b13; - b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - - b4 += b9; - b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - - b14 += b1; - b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - - b8 += b5; - b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - - b10 += b3; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - - b12 += b7; - b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - - b1 += k12; - b0 += b1 + k11; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - - b3 += k14; - b2 += b3 + k13; - b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - - b5 += k16; - b4 += b5 + k15; - b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - - b7 += k1; - b6 += b7 + k0; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - - b9 += k3; - b8 += b9 + k2; - b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - - b11 += k5; - b10 += b11 + k4; - b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - - b13 += k7 + t2; - b12 += b13 + k6; - b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - - b15 += k9 + 11; - b14 += b15 + k8 + t0; - b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - - b0 += b9; - b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - - b2 += b13; - b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - - b6 += b11; - b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - - b4 += b15; - b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - - b10 += b7; - b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - - b12 += b3; - b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - - b14 += b5; - b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - - b8 += b1; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - - b0 += b7; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - - b2 += b5; - b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - - b4 += b3; - b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - - b6 += b1; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - - b12 += b15; - b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - - b14 += b13; - b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - - b8 += b11; - b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - - b10 += b9; - b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - - b0 += b15; - b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - - b2 += b11; - b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - - b6 += b13; - b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - - b4 += b9; - b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - - b14 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - - b8 += b5; - b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - - b10 += b3; - b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - - b12 += b7; - b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - - b1 += k13; - b0 += b1 + k12; - b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - - b3 += k15; - b2 += b3 + k14; - b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - - b5 += k0; - b4 += b5 + k16; - b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - - b7 += k2; - b6 += b7 + k1; - b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - - b9 += k4; - b8 += b9 + k3; - b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - - b11 += k6; - b10 += b11 + k5; - b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - - b13 += k8 + t0; - b12 += b13 + k7; - b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - - b15 += k10 + 12; - b14 += b15 + k9 + t1; - b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - - b0 += b9; - b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - - b2 += b13; - b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - - b6 += b11; - b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - - b4 += b15; - b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - - b10 += b7; - b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - - b12 += b3; - b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - - b14 += b5; - b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - - b8 += b1; - b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - - b0 += b7; - b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - - b2 += b5; - b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - - b4 += b3; - b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - - b6 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - - b12 += b15; - b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - - b14 += b13; - b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - - b8 += b11; - b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - - b10 += b9; - b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - - b0 += b15; - b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - - b2 += b11; - b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - - b6 += b13; - b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - - b4 += b9; - b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - - b14 += b1; - b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - - b8 += b5; - b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - - b10 += b3; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - - b12 += b7; - b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - - b1 += k14; - b0 += b1 + k13; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - - b3 += k16; - b2 += b3 + k15; - b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - - b5 += k1; - b4 += b5 + k0; - b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - - b7 += k3; - b6 += b7 + k2; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - - b9 += k5; - b8 += b9 + k4; - b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - - b11 += k7; - b10 += b11 + k6; - b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - - b13 += k9 + t1; - b12 += b13 + k8; - b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - - b15 += k11 + 13; - b14 += b15 + k10 + t2; - b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - - b0 += b9; - b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - - b2 += b13; - b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - - b6 += b11; - b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - - b4 += b15; - b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - - b10 += b7; - b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - - b12 += b3; - b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - - b14 += b5; - b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - - b8 += b1; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - - b0 += b7; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - - b2 += b5; - b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - - b4 += b3; - b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - - b6 += b1; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - - b12 += b15; - b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - - b14 += b13; - b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - - b8 += b11; - b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - - b10 += b9; - b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - - b0 += b15; - b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - - b2 += b11; - b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - - b6 += b13; - b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - - b4 += b9; - b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - - b14 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - - b8 += b5; - b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - - b10 += b3; - b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - - b12 += b7; - b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - - b1 += k15; - b0 += b1 + k14; - b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - - b3 += k0; - b2 += b3 + k16; - b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - - b5 += k2; - b4 += b5 + k1; - b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - - b7 += k4; - b6 += b7 + k3; - b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - - b9 += k6; - b8 += b9 + k5; - b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - - b11 += k8; - b10 += b11 + k7; - b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - - b13 += k10 + t2; - b12 += b13 + k9; - b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - - b15 += k12 + 14; - b14 += b15 + k11 + t0; - b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - - b0 += b9; - b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - - b2 += b13; - b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - - b6 += b11; - b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - - b4 += b15; - b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - - b10 += b7; - b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - - b12 += b3; - b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - - b14 += b5; - b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - - b8 += b1; - b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - - b0 += b7; - b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - - b2 += b5; - b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - - b4 += b3; - b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - - b6 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - - b12 += b15; - b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - - b14 += b13; - b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - - b8 += b11; - b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - - b10 += b9; - b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - - b0 += b15; - b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - - b2 += b11; - b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - - b6 += b13; - b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - - b4 += b9; - b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - - b14 += b1; - b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - - b8 += b5; - b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - - b10 += b3; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - - b12 += b7; - b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - - b1 += k16; - b0 += b1 + k15; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - - b3 += k1; - b2 += b3 + k0; - b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - - b5 += k3; - b4 += b5 + k2; - b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - - b7 += k5; - b6 += b7 + k4; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - - b9 += k7; - b8 += b9 + k6; - b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - - b11 += k9; - b10 += b11 + k8; - b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - - b13 += k11 + t0; - b12 += b13 + k10; - b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - - b15 += k13 + 15; - b14 += b15 + k12 + t1; - b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - - b0 += b9; - b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - - b2 += b13; - b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - - b6 += b11; - b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - - b4 += b15; - b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - - b10 += b7; - b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - - b12 += b3; - b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - - b14 += b5; - b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - - b8 += b1; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - - b0 += b7; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - - b2 += b5; - b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - - b4 += b3; - b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - - b6 += b1; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - - b12 += b15; - b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - - b14 += b13; - b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - - b8 += b11; - b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - - b10 += b9; - b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - - b0 += b15; - b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - - b2 += b11; - b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - - b6 += b13; - b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - - b4 += b9; - b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - - b14 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - - b8 += b5; - b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - - b10 += b3; - b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - - b12 += b7; - b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - - b1 += k0; - b0 += b1 + k16; - b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - - b3 += k2; - b2 += b3 + k1; - b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - - b5 += k4; - b4 += b5 + k3; - b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - - b7 += k6; - b6 += b7 + k5; - b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - - b9 += k8; - b8 += b9 + k7; - b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - - b11 += k10; - b10 += b11 + k9; - b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - - b13 += k12 + t1; - b12 += b13 + k11; - b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - - b15 += k14 + 16; - b14 += b15 + k13 + t2; - b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - - b0 += b9; - b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - - b2 += b13; - b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - - b6 += b11; - b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - - b4 += b15; - b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - - b10 += b7; - b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - - b12 += b3; - b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - - b14 += b5; - b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - - b8 += b1; - b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - - b0 += b7; - b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - - b2 += b5; - b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - - b4 += b3; - b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - - b6 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - - b12 += b15; - b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - - b14 += b13; - b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - - b8 += b11; - b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - - b10 += b9; - b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - - b0 += b15; - b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - - b2 += b11; - b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - - b6 += b13; - b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - - b4 += b9; - b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - - b14 += b1; - b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - - b8 += b5; - b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - - b10 += b3; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - - b12 += b7; - b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - - b1 += k1; - b0 += b1 + k0; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - - b3 += k3; - b2 += b3 + k2; - b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - - b5 += k5; - b4 += b5 + k4; - b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - - b7 += k7; - b6 += b7 + k6; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - - b9 += k9; - b8 += b9 + k8; - b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - - b11 += k11; - b10 += b11 + k10; - b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - - b13 += k13 + t2; - b12 += b13 + k12; - b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - - b15 += k15 + 17; - b14 += b15 + k14 + t0; - b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - - b0 += b9; - b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - - b2 += b13; - b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - - b6 += b11; - b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - - b4 += b15; - b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - - b10 += b7; - b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - - b12 += b3; - b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - - b14 += b5; - b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - - b8 += b1; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - - b0 += b7; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - - b2 += b5; - b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - - b4 += b3; - b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - - b6 += b1; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - - b12 += b15; - b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - - b14 += b13; - b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - - b8 += b11; - b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - - b10 += b9; - b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - - b0 += b15; - b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - - b2 += b11; - b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - - b6 += b13; - b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - - b4 += b9; - b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - - b14 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - - b8 += b5; - b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - - b10 += b3; - b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - - b12 += b7; - b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - - b1 += k2; - b0 += b1 + k1; - b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; - - b3 += k4; - b2 += b3 + k3; - b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; - - b5 += k6; - b4 += b5 + k5; - b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; - - b7 += k8; - b6 += b7 + k7; - b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; - - b9 += k10; - b8 += b9 + k9; - b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; - - b11 += k12; - b10 += b11 + k11; - b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; - - b13 += k14 + t0; - b12 += b13 + k13; - b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; - - b15 += k16 + 18; - b14 += b15 + k15 + t1; - b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; - - b0 += b9; - b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; - - b2 += b13; - b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; - - b6 += b11; - b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; - - b4 += b15; - b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; - - b10 += b7; - b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; - - b12 += b3; - b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; - - b14 += b5; - b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; - - b8 += b1; - b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; - - b0 += b7; - b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; - - b2 += b5; - b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; - - b4 += b3; - b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; - - b6 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; - - b12 += b15; - b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; - - b14 += b13; - b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; - - b8 += b11; - b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; - - b10 += b9; - b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; - - b0 += b15; - b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; - - b2 += b11; - b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; - - b6 += b13; - b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; - - b4 += b9; - b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; - - b14 += b1; - b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; - - b8 += b5; - b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; - - b10 += b3; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; - - b12 += b7; - b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; - - b1 += k3; - b0 += b1 + k2; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; - - b3 += k5; - b2 += b3 + k4; - b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; - - b5 += k7; - b4 += b5 + k6; - b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; - - b7 += k9; - b6 += b7 + k8; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; - - b9 += k11; - b8 += b9 + k10; - b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; - - b11 += k13; - b10 += b11 + k12; - b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; - - b13 += k15 + t1; - b12 += b13 + k14; - b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; - - b15 += k0 + 19; - b14 += b15 + k16 + t2; - b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; - - b0 += b9; - b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; - - b2 += b13; - b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; - - b6 += b11; - b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; - - b4 += b15; - b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; - - b10 += b7; - b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; - - b12 += b3; - b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; - - b14 += b5; - b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; - - b8 += b1; - b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; - - b0 += b7; - b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; - - b2 += b5; - b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; - - b4 += b3; - b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; - - b6 += b1; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; - - b12 += b15; - b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; - - b14 += b13; - b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; - - b8 += b11; - b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; - - b10 += b9; - b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; - - b0 += b15; - b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; - - b2 += b11; - b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; - - b6 += b13; - b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; - - b4 += b9; - b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; - - b14 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; - - b8 += b5; - b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; - - b10 += b3; - b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; - - b12 += b7; - b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; - - output[0] = b0 + k3; - output[1] = b1 + k4; - output[2] = b2 + k5; - output[3] = b3 + k6; - output[4] = b4 + k7; - output[5] = b5 + k8; - output[6] = b6 + k9; - output[7] = b7 + k10; - output[8] = b8 + k11; - output[9] = b9 + k12; - output[10] = b10 + k13; - output[11] = b11 + k14; - output[12] = b12 + k15; - output[13] = b13 + k16 + t2; - output[14] = b14 + k0 + t0; - output[15] = b15 + k1 + 20; -} - -void threefish_decrypt_1024(struct threefish_key *key_ctx, u64 *input, - u64 *output) -{ - u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3], - b4 = input[4], b5 = input[5], - b6 = input[6], b7 = input[7], - b8 = input[8], b9 = input[9], - b10 = input[10], b11 = input[11], - b12 = input[12], b13 = input[13], - b14 = input[14], b15 = input[15]; - u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], - k2 = key_ctx->key[2], k3 = key_ctx->key[3], - k4 = key_ctx->key[4], k5 = key_ctx->key[5], - k6 = key_ctx->key[6], k7 = key_ctx->key[7], - k8 = key_ctx->key[8], k9 = key_ctx->key[9], - k10 = key_ctx->key[10], k11 = key_ctx->key[11], - k12 = key_ctx->key[12], k13 = key_ctx->key[13], - k14 = key_ctx->key[14], k15 = key_ctx->key[15], - k16 = key_ctx->key[16]; - u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], - t2 = key_ctx->tweak[2]; - u64 tmp; - - b0 -= k3; - b1 -= k4; - b2 -= k5; - b3 -= k6; - b4 -= k7; - b5 -= k8; - b6 -= k9; - b7 -= k10; - b8 -= k11; - b9 -= k12; - b10 -= k13; - b11 -= k14; - b12 -= k15; - b13 -= k16 + t2; - b14 -= k0 + t0; - b15 -= k1 + 20; - tmp = b7 ^ b12; - b7 = (tmp >> 20) | (tmp << (64 - 20)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 37) | (tmp << (64 - 37)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 31) | (tmp << (64 - 31)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 52) | (tmp << (64 - 52)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 35) | (tmp << (64 - 35)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 48) | (tmp << (64 - 48)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 25) | (tmp << (64 - 25)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 44) | (tmp << (64 - 44)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 19) | (tmp << (64 - 19)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 47) | (tmp << (64 - 47)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 44) | (tmp << (64 - 44)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 53) | (tmp << (64 - 53)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 4) | (tmp << (64 - 4)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 56) | (tmp << (64 - 56)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 34) | (tmp << (64 - 34)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 16) | (tmp << (64 - 16)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 30) | (tmp << (64 - 30)); - b14 -= b15 + k16 + t2; - b15 -= k0 + 19; - - tmp = b13 ^ b12; - b13 = (tmp >> 44) | (tmp << (64 - 44)); - b12 -= b13 + k14; - b13 -= k15 + t1; - - tmp = b11 ^ b10; - b11 = (tmp >> 47) | (tmp << (64 - 47)); - b10 -= b11 + k12; - b11 -= k13; - - tmp = b9 ^ b8; - b9 = (tmp >> 12) | (tmp << (64 - 12)); - b8 -= b9 + k10; - b9 -= k11; - - tmp = b7 ^ b6; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b6 -= b7 + k8; - b7 -= k9; - - tmp = b5 ^ b4; - b5 = (tmp >> 37) | (tmp << (64 - 37)); - b4 -= b5 + k6; - b5 -= k7; - - tmp = b3 ^ b2; - b3 = (tmp >> 9) | (tmp << (64 - 9)); - b2 -= b3 + k4; - b3 -= k5; - - tmp = b1 ^ b0; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b0 -= b1 + k2; - b1 -= k3; - - tmp = b7 ^ b12; - b7 = (tmp >> 25) | (tmp << (64 - 25)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 28) | (tmp << (64 - 28)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 47) | (tmp << (64 - 47)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 41) | (tmp << (64 - 41)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 48) | (tmp << (64 - 48)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 20) | (tmp << (64 - 20)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 59) | (tmp << (64 - 59)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 41) | (tmp << (64 - 41)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 34) | (tmp << (64 - 34)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 4) | (tmp << (64 - 4)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 33) | (tmp << (64 - 33)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 52) | (tmp << (64 - 52)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 18) | (tmp << (64 - 18)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 49) | (tmp << (64 - 49)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 55) | (tmp << (64 - 55)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 19) | (tmp << (64 - 19)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 38) | (tmp << (64 - 38)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 37) | (tmp << (64 - 37)); - b14 -= b15 + k15 + t1; - b15 -= k16 + 18; - - tmp = b13 ^ b12; - b13 = (tmp >> 22) | (tmp << (64 - 22)); - b12 -= b13 + k13; - b13 -= k14 + t0; - - tmp = b11 ^ b10; - b11 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b11 + k11; - b11 -= k12; - - tmp = b9 ^ b8; - b9 = (tmp >> 8) | (tmp << (64 - 8)); - b8 -= b9 + k9; - b9 -= k10; - - tmp = b7 ^ b6; - b7 = (tmp >> 47) | (tmp << (64 - 47)); - b6 -= b7 + k7; - b7 -= k8; - - tmp = b5 ^ b4; - b5 = (tmp >> 8) | (tmp << (64 - 8)); - b4 -= b5 + k5; - b5 -= k6; - - tmp = b3 ^ b2; - b3 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b3 + k3; - b3 -= k4; - - tmp = b1 ^ b0; - b1 = (tmp >> 24) | (tmp << (64 - 24)); - b0 -= b1 + k1; - b1 -= k2; - - tmp = b7 ^ b12; - b7 = (tmp >> 20) | (tmp << (64 - 20)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 37) | (tmp << (64 - 37)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 31) | (tmp << (64 - 31)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 52) | (tmp << (64 - 52)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 35) | (tmp << (64 - 35)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 48) | (tmp << (64 - 48)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 25) | (tmp << (64 - 25)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 44) | (tmp << (64 - 44)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 19) | (tmp << (64 - 19)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 47) | (tmp << (64 - 47)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 44) | (tmp << (64 - 44)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 53) | (tmp << (64 - 53)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 4) | (tmp << (64 - 4)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 56) | (tmp << (64 - 56)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 34) | (tmp << (64 - 34)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 16) | (tmp << (64 - 16)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 30) | (tmp << (64 - 30)); - b14 -= b15 + k14 + t0; - b15 -= k15 + 17; - - tmp = b13 ^ b12; - b13 = (tmp >> 44) | (tmp << (64 - 44)); - b12 -= b13 + k12; - b13 -= k13 + t2; - - tmp = b11 ^ b10; - b11 = (tmp >> 47) | (tmp << (64 - 47)); - b10 -= b11 + k10; - b11 -= k11; - - tmp = b9 ^ b8; - b9 = (tmp >> 12) | (tmp << (64 - 12)); - b8 -= b9 + k8; - b9 -= k9; - - tmp = b7 ^ b6; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b6 -= b7 + k6; - b7 -= k7; - - tmp = b5 ^ b4; - b5 = (tmp >> 37) | (tmp << (64 - 37)); - b4 -= b5 + k4; - b5 -= k5; - - tmp = b3 ^ b2; - b3 = (tmp >> 9) | (tmp << (64 - 9)); - b2 -= b3 + k2; - b3 -= k3; - - tmp = b1 ^ b0; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b0 -= b1 + k0; - b1 -= k1; - - tmp = b7 ^ b12; - b7 = (tmp >> 25) | (tmp << (64 - 25)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 28) | (tmp << (64 - 28)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 47) | (tmp << (64 - 47)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 41) | (tmp << (64 - 41)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 48) | (tmp << (64 - 48)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 20) | (tmp << (64 - 20)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 59) | (tmp << (64 - 59)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 41) | (tmp << (64 - 41)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 34) | (tmp << (64 - 34)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 4) | (tmp << (64 - 4)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 33) | (tmp << (64 - 33)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 52) | (tmp << (64 - 52)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 18) | (tmp << (64 - 18)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 49) | (tmp << (64 - 49)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 55) | (tmp << (64 - 55)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 19) | (tmp << (64 - 19)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 38) | (tmp << (64 - 38)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 37) | (tmp << (64 - 37)); - b14 -= b15 + k13 + t2; - b15 -= k14 + 16; - - tmp = b13 ^ b12; - b13 = (tmp >> 22) | (tmp << (64 - 22)); - b12 -= b13 + k11; - b13 -= k12 + t1; - - tmp = b11 ^ b10; - b11 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b11 + k9; - b11 -= k10; - - tmp = b9 ^ b8; - b9 = (tmp >> 8) | (tmp << (64 - 8)); - b8 -= b9 + k7; - b9 -= k8; - - tmp = b7 ^ b6; - b7 = (tmp >> 47) | (tmp << (64 - 47)); - b6 -= b7 + k5; - b7 -= k6; - - tmp = b5 ^ b4; - b5 = (tmp >> 8) | (tmp << (64 - 8)); - b4 -= b5 + k3; - b5 -= k4; - - tmp = b3 ^ b2; - b3 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b3 + k1; - b3 -= k2; - - tmp = b1 ^ b0; - b1 = (tmp >> 24) | (tmp << (64 - 24)); - b0 -= b1 + k16; - b1 -= k0; - - tmp = b7 ^ b12; - b7 = (tmp >> 20) | (tmp << (64 - 20)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 37) | (tmp << (64 - 37)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 31) | (tmp << (64 - 31)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 52) | (tmp << (64 - 52)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 35) | (tmp << (64 - 35)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 48) | (tmp << (64 - 48)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 25) | (tmp << (64 - 25)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 44) | (tmp << (64 - 44)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 19) | (tmp << (64 - 19)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 47) | (tmp << (64 - 47)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 44) | (tmp << (64 - 44)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 53) | (tmp << (64 - 53)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 4) | (tmp << (64 - 4)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 56) | (tmp << (64 - 56)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 34) | (tmp << (64 - 34)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 16) | (tmp << (64 - 16)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 30) | (tmp << (64 - 30)); - b14 -= b15 + k12 + t1; - b15 -= k13 + 15; - - tmp = b13 ^ b12; - b13 = (tmp >> 44) | (tmp << (64 - 44)); - b12 -= b13 + k10; - b13 -= k11 + t0; - - tmp = b11 ^ b10; - b11 = (tmp >> 47) | (tmp << (64 - 47)); - b10 -= b11 + k8; - b11 -= k9; - - tmp = b9 ^ b8; - b9 = (tmp >> 12) | (tmp << (64 - 12)); - b8 -= b9 + k6; - b9 -= k7; - - tmp = b7 ^ b6; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b6 -= b7 + k4; - b7 -= k5; - - tmp = b5 ^ b4; - b5 = (tmp >> 37) | (tmp << (64 - 37)); - b4 -= b5 + k2; - b5 -= k3; - - tmp = b3 ^ b2; - b3 = (tmp >> 9) | (tmp << (64 - 9)); - b2 -= b3 + k0; - b3 -= k1; - - tmp = b1 ^ b0; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b0 -= b1 + k15; - b1 -= k16; - - tmp = b7 ^ b12; - b7 = (tmp >> 25) | (tmp << (64 - 25)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 28) | (tmp << (64 - 28)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 47) | (tmp << (64 - 47)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 41) | (tmp << (64 - 41)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 48) | (tmp << (64 - 48)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 20) | (tmp << (64 - 20)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 59) | (tmp << (64 - 59)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 41) | (tmp << (64 - 41)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 34) | (tmp << (64 - 34)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 4) | (tmp << (64 - 4)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 33) | (tmp << (64 - 33)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 52) | (tmp << (64 - 52)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 18) | (tmp << (64 - 18)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 49) | (tmp << (64 - 49)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 55) | (tmp << (64 - 55)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 19) | (tmp << (64 - 19)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 38) | (tmp << (64 - 38)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 37) | (tmp << (64 - 37)); - b14 -= b15 + k11 + t0; - b15 -= k12 + 14; - - tmp = b13 ^ b12; - b13 = (tmp >> 22) | (tmp << (64 - 22)); - b12 -= b13 + k9; - b13 -= k10 + t2; - - tmp = b11 ^ b10; - b11 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b11 + k7; - b11 -= k8; - - tmp = b9 ^ b8; - b9 = (tmp >> 8) | (tmp << (64 - 8)); - b8 -= b9 + k5; - b9 -= k6; - - tmp = b7 ^ b6; - b7 = (tmp >> 47) | (tmp << (64 - 47)); - b6 -= b7 + k3; - b7 -= k4; - - tmp = b5 ^ b4; - b5 = (tmp >> 8) | (tmp << (64 - 8)); - b4 -= b5 + k1; - b5 -= k2; - - tmp = b3 ^ b2; - b3 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b3 + k16; - b3 -= k0; - - tmp = b1 ^ b0; - b1 = (tmp >> 24) | (tmp << (64 - 24)); - b0 -= b1 + k14; - b1 -= k15; - - tmp = b7 ^ b12; - b7 = (tmp >> 20) | (tmp << (64 - 20)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 37) | (tmp << (64 - 37)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 31) | (tmp << (64 - 31)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 52) | (tmp << (64 - 52)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 35) | (tmp << (64 - 35)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 48) | (tmp << (64 - 48)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 25) | (tmp << (64 - 25)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 44) | (tmp << (64 - 44)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 19) | (tmp << (64 - 19)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 47) | (tmp << (64 - 47)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 44) | (tmp << (64 - 44)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 53) | (tmp << (64 - 53)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 4) | (tmp << (64 - 4)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 56) | (tmp << (64 - 56)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 34) | (tmp << (64 - 34)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 16) | (tmp << (64 - 16)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 30) | (tmp << (64 - 30)); - b14 -= b15 + k10 + t2; - b15 -= k11 + 13; - - tmp = b13 ^ b12; - b13 = (tmp >> 44) | (tmp << (64 - 44)); - b12 -= b13 + k8; - b13 -= k9 + t1; - - tmp = b11 ^ b10; - b11 = (tmp >> 47) | (tmp << (64 - 47)); - b10 -= b11 + k6; - b11 -= k7; - - tmp = b9 ^ b8; - b9 = (tmp >> 12) | (tmp << (64 - 12)); - b8 -= b9 + k4; - b9 -= k5; - - tmp = b7 ^ b6; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b6 -= b7 + k2; - b7 -= k3; - - tmp = b5 ^ b4; - b5 = (tmp >> 37) | (tmp << (64 - 37)); - b4 -= b5 + k0; - b5 -= k1; - - tmp = b3 ^ b2; - b3 = (tmp >> 9) | (tmp << (64 - 9)); - b2 -= b3 + k15; - b3 -= k16; - - tmp = b1 ^ b0; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b0 -= b1 + k13; - b1 -= k14; - - tmp = b7 ^ b12; - b7 = (tmp >> 25) | (tmp << (64 - 25)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 28) | (tmp << (64 - 28)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 47) | (tmp << (64 - 47)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 41) | (tmp << (64 - 41)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 48) | (tmp << (64 - 48)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 20) | (tmp << (64 - 20)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 59) | (tmp << (64 - 59)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 41) | (tmp << (64 - 41)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 34) | (tmp << (64 - 34)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 4) | (tmp << (64 - 4)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 33) | (tmp << (64 - 33)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 52) | (tmp << (64 - 52)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 18) | (tmp << (64 - 18)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 49) | (tmp << (64 - 49)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 55) | (tmp << (64 - 55)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 19) | (tmp << (64 - 19)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 38) | (tmp << (64 - 38)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 37) | (tmp << (64 - 37)); - b14 -= b15 + k9 + t1; - b15 -= k10 + 12; - - tmp = b13 ^ b12; - b13 = (tmp >> 22) | (tmp << (64 - 22)); - b12 -= b13 + k7; - b13 -= k8 + t0; - - tmp = b11 ^ b10; - b11 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b11 + k5; - b11 -= k6; - - tmp = b9 ^ b8; - b9 = (tmp >> 8) | (tmp << (64 - 8)); - b8 -= b9 + k3; - b9 -= k4; - - tmp = b7 ^ b6; - b7 = (tmp >> 47) | (tmp << (64 - 47)); - b6 -= b7 + k1; - b7 -= k2; - - tmp = b5 ^ b4; - b5 = (tmp >> 8) | (tmp << (64 - 8)); - b4 -= b5 + k16; - b5 -= k0; - - tmp = b3 ^ b2; - b3 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b3 + k14; - b3 -= k15; - - tmp = b1 ^ b0; - b1 = (tmp >> 24) | (tmp << (64 - 24)); - b0 -= b1 + k12; - b1 -= k13; - - tmp = b7 ^ b12; - b7 = (tmp >> 20) | (tmp << (64 - 20)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 37) | (tmp << (64 - 37)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 31) | (tmp << (64 - 31)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 52) | (tmp << (64 - 52)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 35) | (tmp << (64 - 35)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 48) | (tmp << (64 - 48)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 25) | (tmp << (64 - 25)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 44) | (tmp << (64 - 44)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 19) | (tmp << (64 - 19)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 47) | (tmp << (64 - 47)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 44) | (tmp << (64 - 44)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 53) | (tmp << (64 - 53)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 4) | (tmp << (64 - 4)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 56) | (tmp << (64 - 56)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 34) | (tmp << (64 - 34)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 16) | (tmp << (64 - 16)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 30) | (tmp << (64 - 30)); - b14 -= b15 + k8 + t0; - b15 -= k9 + 11; - - tmp = b13 ^ b12; - b13 = (tmp >> 44) | (tmp << (64 - 44)); - b12 -= b13 + k6; - b13 -= k7 + t2; - - tmp = b11 ^ b10; - b11 = (tmp >> 47) | (tmp << (64 - 47)); - b10 -= b11 + k4; - b11 -= k5; - - tmp = b9 ^ b8; - b9 = (tmp >> 12) | (tmp << (64 - 12)); - b8 -= b9 + k2; - b9 -= k3; - - tmp = b7 ^ b6; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b6 -= b7 + k0; - b7 -= k1; - - tmp = b5 ^ b4; - b5 = (tmp >> 37) | (tmp << (64 - 37)); - b4 -= b5 + k15; - b5 -= k16; - - tmp = b3 ^ b2; - b3 = (tmp >> 9) | (tmp << (64 - 9)); - b2 -= b3 + k13; - b3 -= k14; - - tmp = b1 ^ b0; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b0 -= b1 + k11; - b1 -= k12; - - tmp = b7 ^ b12; - b7 = (tmp >> 25) | (tmp << (64 - 25)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 28) | (tmp << (64 - 28)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 47) | (tmp << (64 - 47)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 41) | (tmp << (64 - 41)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 48) | (tmp << (64 - 48)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 20) | (tmp << (64 - 20)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 59) | (tmp << (64 - 59)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 41) | (tmp << (64 - 41)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 34) | (tmp << (64 - 34)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 4) | (tmp << (64 - 4)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 33) | (tmp << (64 - 33)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 52) | (tmp << (64 - 52)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 18) | (tmp << (64 - 18)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 49) | (tmp << (64 - 49)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 55) | (tmp << (64 - 55)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 19) | (tmp << (64 - 19)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 38) | (tmp << (64 - 38)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 37) | (tmp << (64 - 37)); - b14 -= b15 + k7 + t2; - b15 -= k8 + 10; - - tmp = b13 ^ b12; - b13 = (tmp >> 22) | (tmp << (64 - 22)); - b12 -= b13 + k5; - b13 -= k6 + t1; - - tmp = b11 ^ b10; - b11 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b11 + k3; - b11 -= k4; - - tmp = b9 ^ b8; - b9 = (tmp >> 8) | (tmp << (64 - 8)); - b8 -= b9 + k1; - b9 -= k2; - - tmp = b7 ^ b6; - b7 = (tmp >> 47) | (tmp << (64 - 47)); - b6 -= b7 + k16; - b7 -= k0; - - tmp = b5 ^ b4; - b5 = (tmp >> 8) | (tmp << (64 - 8)); - b4 -= b5 + k14; - b5 -= k15; - - tmp = b3 ^ b2; - b3 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b3 + k12; - b3 -= k13; - - tmp = b1 ^ b0; - b1 = (tmp >> 24) | (tmp << (64 - 24)); - b0 -= b1 + k10; - b1 -= k11; - - tmp = b7 ^ b12; - b7 = (tmp >> 20) | (tmp << (64 - 20)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 37) | (tmp << (64 - 37)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 31) | (tmp << (64 - 31)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 52) | (tmp << (64 - 52)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 35) | (tmp << (64 - 35)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 48) | (tmp << (64 - 48)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 25) | (tmp << (64 - 25)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 44) | (tmp << (64 - 44)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 19) | (tmp << (64 - 19)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 47) | (tmp << (64 - 47)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 44) | (tmp << (64 - 44)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 53) | (tmp << (64 - 53)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 4) | (tmp << (64 - 4)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 56) | (tmp << (64 - 56)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 34) | (tmp << (64 - 34)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 16) | (tmp << (64 - 16)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 30) | (tmp << (64 - 30)); - b14 -= b15 + k6 + t1; - b15 -= k7 + 9; - - tmp = b13 ^ b12; - b13 = (tmp >> 44) | (tmp << (64 - 44)); - b12 -= b13 + k4; - b13 -= k5 + t0; - - tmp = b11 ^ b10; - b11 = (tmp >> 47) | (tmp << (64 - 47)); - b10 -= b11 + k2; - b11 -= k3; - - tmp = b9 ^ b8; - b9 = (tmp >> 12) | (tmp << (64 - 12)); - b8 -= b9 + k0; - b9 -= k1; - - tmp = b7 ^ b6; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b6 -= b7 + k15; - b7 -= k16; - - tmp = b5 ^ b4; - b5 = (tmp >> 37) | (tmp << (64 - 37)); - b4 -= b5 + k13; - b5 -= k14; - - tmp = b3 ^ b2; - b3 = (tmp >> 9) | (tmp << (64 - 9)); - b2 -= b3 + k11; - b3 -= k12; - - tmp = b1 ^ b0; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b0 -= b1 + k9; - b1 -= k10; - - tmp = b7 ^ b12; - b7 = (tmp >> 25) | (tmp << (64 - 25)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 28) | (tmp << (64 - 28)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 47) | (tmp << (64 - 47)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 41) | (tmp << (64 - 41)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 48) | (tmp << (64 - 48)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 20) | (tmp << (64 - 20)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 59) | (tmp << (64 - 59)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 41) | (tmp << (64 - 41)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 34) | (tmp << (64 - 34)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 4) | (tmp << (64 - 4)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 33) | (tmp << (64 - 33)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 52) | (tmp << (64 - 52)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 18) | (tmp << (64 - 18)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 49) | (tmp << (64 - 49)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 55) | (tmp << (64 - 55)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 19) | (tmp << (64 - 19)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 38) | (tmp << (64 - 38)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 37) | (tmp << (64 - 37)); - b14 -= b15 + k5 + t0; - b15 -= k6 + 8; - - tmp = b13 ^ b12; - b13 = (tmp >> 22) | (tmp << (64 - 22)); - b12 -= b13 + k3; - b13 -= k4 + t2; - - tmp = b11 ^ b10; - b11 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b11 + k1; - b11 -= k2; - - tmp = b9 ^ b8; - b9 = (tmp >> 8) | (tmp << (64 - 8)); - b8 -= b9 + k16; - b9 -= k0; - - tmp = b7 ^ b6; - b7 = (tmp >> 47) | (tmp << (64 - 47)); - b6 -= b7 + k14; - b7 -= k15; - - tmp = b5 ^ b4; - b5 = (tmp >> 8) | (tmp << (64 - 8)); - b4 -= b5 + k12; - b5 -= k13; - - tmp = b3 ^ b2; - b3 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b3 + k10; - b3 -= k11; - - tmp = b1 ^ b0; - b1 = (tmp >> 24) | (tmp << (64 - 24)); - b0 -= b1 + k8; - b1 -= k9; - - tmp = b7 ^ b12; - b7 = (tmp >> 20) | (tmp << (64 - 20)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 37) | (tmp << (64 - 37)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 31) | (tmp << (64 - 31)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 52) | (tmp << (64 - 52)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 35) | (tmp << (64 - 35)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 48) | (tmp << (64 - 48)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 25) | (tmp << (64 - 25)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 44) | (tmp << (64 - 44)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 19) | (tmp << (64 - 19)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 47) | (tmp << (64 - 47)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 44) | (tmp << (64 - 44)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 53) | (tmp << (64 - 53)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 4) | (tmp << (64 - 4)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 56) | (tmp << (64 - 56)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 34) | (tmp << (64 - 34)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 16) | (tmp << (64 - 16)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 30) | (tmp << (64 - 30)); - b14 -= b15 + k4 + t2; - b15 -= k5 + 7; - - tmp = b13 ^ b12; - b13 = (tmp >> 44) | (tmp << (64 - 44)); - b12 -= b13 + k2; - b13 -= k3 + t1; - - tmp = b11 ^ b10; - b11 = (tmp >> 47) | (tmp << (64 - 47)); - b10 -= b11 + k0; - b11 -= k1; - - tmp = b9 ^ b8; - b9 = (tmp >> 12) | (tmp << (64 - 12)); - b8 -= b9 + k15; - b9 -= k16; - - tmp = b7 ^ b6; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b6 -= b7 + k13; - b7 -= k14; - - tmp = b5 ^ b4; - b5 = (tmp >> 37) | (tmp << (64 - 37)); - b4 -= b5 + k11; - b5 -= k12; - - tmp = b3 ^ b2; - b3 = (tmp >> 9) | (tmp << (64 - 9)); - b2 -= b3 + k9; - b3 -= k10; - - tmp = b1 ^ b0; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b0 -= b1 + k7; - b1 -= k8; - - tmp = b7 ^ b12; - b7 = (tmp >> 25) | (tmp << (64 - 25)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 28) | (tmp << (64 - 28)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 47) | (tmp << (64 - 47)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 41) | (tmp << (64 - 41)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 48) | (tmp << (64 - 48)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 20) | (tmp << (64 - 20)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 59) | (tmp << (64 - 59)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 41) | (tmp << (64 - 41)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 34) | (tmp << (64 - 34)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 4) | (tmp << (64 - 4)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 33) | (tmp << (64 - 33)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 52) | (tmp << (64 - 52)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 18) | (tmp << (64 - 18)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 49) | (tmp << (64 - 49)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 55) | (tmp << (64 - 55)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 19) | (tmp << (64 - 19)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 38) | (tmp << (64 - 38)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 37) | (tmp << (64 - 37)); - b14 -= b15 + k3 + t1; - b15 -= k4 + 6; - - tmp = b13 ^ b12; - b13 = (tmp >> 22) | (tmp << (64 - 22)); - b12 -= b13 + k1; - b13 -= k2 + t0; - - tmp = b11 ^ b10; - b11 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b11 + k16; - b11 -= k0; - - tmp = b9 ^ b8; - b9 = (tmp >> 8) | (tmp << (64 - 8)); - b8 -= b9 + k14; - b9 -= k15; - - tmp = b7 ^ b6; - b7 = (tmp >> 47) | (tmp << (64 - 47)); - b6 -= b7 + k12; - b7 -= k13; - - tmp = b5 ^ b4; - b5 = (tmp >> 8) | (tmp << (64 - 8)); - b4 -= b5 + k10; - b5 -= k11; - - tmp = b3 ^ b2; - b3 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b3 + k8; - b3 -= k9; - - tmp = b1 ^ b0; - b1 = (tmp >> 24) | (tmp << (64 - 24)); - b0 -= b1 + k6; - b1 -= k7; - - tmp = b7 ^ b12; - b7 = (tmp >> 20) | (tmp << (64 - 20)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 37) | (tmp << (64 - 37)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 31) | (tmp << (64 - 31)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 52) | (tmp << (64 - 52)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 35) | (tmp << (64 - 35)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 48) | (tmp << (64 - 48)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 25) | (tmp << (64 - 25)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 44) | (tmp << (64 - 44)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 19) | (tmp << (64 - 19)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 47) | (tmp << (64 - 47)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 44) | (tmp << (64 - 44)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 53) | (tmp << (64 - 53)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 4) | (tmp << (64 - 4)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 56) | (tmp << (64 - 56)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 34) | (tmp << (64 - 34)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 16) | (tmp << (64 - 16)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 30) | (tmp << (64 - 30)); - b14 -= b15 + k2 + t0; - b15 -= k3 + 5; - - tmp = b13 ^ b12; - b13 = (tmp >> 44) | (tmp << (64 - 44)); - b12 -= b13 + k0; - b13 -= k1 + t2; - - tmp = b11 ^ b10; - b11 = (tmp >> 47) | (tmp << (64 - 47)); - b10 -= b11 + k15; - b11 -= k16; - - tmp = b9 ^ b8; - b9 = (tmp >> 12) | (tmp << (64 - 12)); - b8 -= b9 + k13; - b9 -= k14; - - tmp = b7 ^ b6; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b6 -= b7 + k11; - b7 -= k12; - - tmp = b5 ^ b4; - b5 = (tmp >> 37) | (tmp << (64 - 37)); - b4 -= b5 + k9; - b5 -= k10; - - tmp = b3 ^ b2; - b3 = (tmp >> 9) | (tmp << (64 - 9)); - b2 -= b3 + k7; - b3 -= k8; - - tmp = b1 ^ b0; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b0 -= b1 + k5; - b1 -= k6; - - tmp = b7 ^ b12; - b7 = (tmp >> 25) | (tmp << (64 - 25)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 28) | (tmp << (64 - 28)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 47) | (tmp << (64 - 47)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 41) | (tmp << (64 - 41)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 48) | (tmp << (64 - 48)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 20) | (tmp << (64 - 20)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 59) | (tmp << (64 - 59)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 41) | (tmp << (64 - 41)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 34) | (tmp << (64 - 34)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 4) | (tmp << (64 - 4)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 33) | (tmp << (64 - 33)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 52) | (tmp << (64 - 52)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 18) | (tmp << (64 - 18)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 49) | (tmp << (64 - 49)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 55) | (tmp << (64 - 55)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 19) | (tmp << (64 - 19)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 38) | (tmp << (64 - 38)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 37) | (tmp << (64 - 37)); - b14 -= b15 + k1 + t2; - b15 -= k2 + 4; - - tmp = b13 ^ b12; - b13 = (tmp >> 22) | (tmp << (64 - 22)); - b12 -= b13 + k16; - b13 -= k0 + t1; - - tmp = b11 ^ b10; - b11 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b11 + k14; - b11 -= k15; - - tmp = b9 ^ b8; - b9 = (tmp >> 8) | (tmp << (64 - 8)); - b8 -= b9 + k12; - b9 -= k13; - - tmp = b7 ^ b6; - b7 = (tmp >> 47) | (tmp << (64 - 47)); - b6 -= b7 + k10; - b7 -= k11; - - tmp = b5 ^ b4; - b5 = (tmp >> 8) | (tmp << (64 - 8)); - b4 -= b5 + k8; - b5 -= k9; - - tmp = b3 ^ b2; - b3 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b3 + k6; - b3 -= k7; - - tmp = b1 ^ b0; - b1 = (tmp >> 24) | (tmp << (64 - 24)); - b0 -= b1 + k4; - b1 -= k5; - - tmp = b7 ^ b12; - b7 = (tmp >> 20) | (tmp << (64 - 20)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 37) | (tmp << (64 - 37)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 31) | (tmp << (64 - 31)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 52) | (tmp << (64 - 52)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 35) | (tmp << (64 - 35)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 48) | (tmp << (64 - 48)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 25) | (tmp << (64 - 25)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 44) | (tmp << (64 - 44)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 19) | (tmp << (64 - 19)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 47) | (tmp << (64 - 47)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 44) | (tmp << (64 - 44)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 53) | (tmp << (64 - 53)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 4) | (tmp << (64 - 4)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 56) | (tmp << (64 - 56)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 34) | (tmp << (64 - 34)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 16) | (tmp << (64 - 16)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 30) | (tmp << (64 - 30)); - b14 -= b15 + k0 + t1; - b15 -= k1 + 3; - - tmp = b13 ^ b12; - b13 = (tmp >> 44) | (tmp << (64 - 44)); - b12 -= b13 + k15; - b13 -= k16 + t0; - - tmp = b11 ^ b10; - b11 = (tmp >> 47) | (tmp << (64 - 47)); - b10 -= b11 + k13; - b11 -= k14; - - tmp = b9 ^ b8; - b9 = (tmp >> 12) | (tmp << (64 - 12)); - b8 -= b9 + k11; - b9 -= k12; - - tmp = b7 ^ b6; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b6 -= b7 + k9; - b7 -= k10; - - tmp = b5 ^ b4; - b5 = (tmp >> 37) | (tmp << (64 - 37)); - b4 -= b5 + k7; - b5 -= k8; - - tmp = b3 ^ b2; - b3 = (tmp >> 9) | (tmp << (64 - 9)); - b2 -= b3 + k5; - b3 -= k6; - - tmp = b1 ^ b0; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b0 -= b1 + k3; - b1 -= k4; - - tmp = b7 ^ b12; - b7 = (tmp >> 25) | (tmp << (64 - 25)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 28) | (tmp << (64 - 28)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 47) | (tmp << (64 - 47)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 41) | (tmp << (64 - 41)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 48) | (tmp << (64 - 48)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 20) | (tmp << (64 - 20)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 59) | (tmp << (64 - 59)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 41) | (tmp << (64 - 41)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 34) | (tmp << (64 - 34)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 4) | (tmp << (64 - 4)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 33) | (tmp << (64 - 33)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 52) | (tmp << (64 - 52)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 18) | (tmp << (64 - 18)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 49) | (tmp << (64 - 49)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 55) | (tmp << (64 - 55)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 19) | (tmp << (64 - 19)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 38) | (tmp << (64 - 38)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 37) | (tmp << (64 - 37)); - b14 -= b15 + k16 + t0; - b15 -= k0 + 2; - - tmp = b13 ^ b12; - b13 = (tmp >> 22) | (tmp << (64 - 22)); - b12 -= b13 + k14; - b13 -= k15 + t2; - - tmp = b11 ^ b10; - b11 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b11 + k12; - b11 -= k13; - - tmp = b9 ^ b8; - b9 = (tmp >> 8) | (tmp << (64 - 8)); - b8 -= b9 + k10; - b9 -= k11; - - tmp = b7 ^ b6; - b7 = (tmp >> 47) | (tmp << (64 - 47)); - b6 -= b7 + k8; - b7 -= k9; - - tmp = b5 ^ b4; - b5 = (tmp >> 8) | (tmp << (64 - 8)); - b4 -= b5 + k6; - b5 -= k7; - - tmp = b3 ^ b2; - b3 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b3 + k4; - b3 -= k5; - - tmp = b1 ^ b0; - b1 = (tmp >> 24) | (tmp << (64 - 24)); - b0 -= b1 + k2; - b1 -= k3; - - tmp = b7 ^ b12; - b7 = (tmp >> 20) | (tmp << (64 - 20)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 37) | (tmp << (64 - 37)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 31) | (tmp << (64 - 31)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 52) | (tmp << (64 - 52)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 35) | (tmp << (64 - 35)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 48) | (tmp << (64 - 48)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 25) | (tmp << (64 - 25)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 44) | (tmp << (64 - 44)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 19) | (tmp << (64 - 19)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 47) | (tmp << (64 - 47)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 44) | (tmp << (64 - 44)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 42) | (tmp << (64 - 42)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 53) | (tmp << (64 - 53)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 4) | (tmp << (64 - 4)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 56) | (tmp << (64 - 56)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 34) | (tmp << (64 - 34)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 16) | (tmp << (64 - 16)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 30) | (tmp << (64 - 30)); - b14 -= b15 + k15 + t2; - b15 -= k16 + 1; - - tmp = b13 ^ b12; - b13 = (tmp >> 44) | (tmp << (64 - 44)); - b12 -= b13 + k13; - b13 -= k14 + t1; - - tmp = b11 ^ b10; - b11 = (tmp >> 47) | (tmp << (64 - 47)); - b10 -= b11 + k11; - b11 -= k12; - - tmp = b9 ^ b8; - b9 = (tmp >> 12) | (tmp << (64 - 12)); - b8 -= b9 + k9; - b9 -= k10; - - tmp = b7 ^ b6; - b7 = (tmp >> 31) | (tmp << (64 - 31)); - b6 -= b7 + k7; - b7 -= k8; - - tmp = b5 ^ b4; - b5 = (tmp >> 37) | (tmp << (64 - 37)); - b4 -= b5 + k5; - b5 -= k6; - - tmp = b3 ^ b2; - b3 = (tmp >> 9) | (tmp << (64 - 9)); - b2 -= b3 + k3; - b3 -= k4; - - tmp = b1 ^ b0; - b1 = (tmp >> 41) | (tmp << (64 - 41)); - b0 -= b1 + k1; - b1 -= k2; - - tmp = b7 ^ b12; - b7 = (tmp >> 25) | (tmp << (64 - 25)); - b12 -= b7; - - tmp = b3 ^ b10; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b10 -= b3; - - tmp = b5 ^ b8; - b5 = (tmp >> 28) | (tmp << (64 - 28)); - b8 -= b5; - - tmp = b1 ^ b14; - b1 = (tmp >> 47) | (tmp << (64 - 47)); - b14 -= b1; - - tmp = b9 ^ b4; - b9 = (tmp >> 41) | (tmp << (64 - 41)); - b4 -= b9; - - tmp = b13 ^ b6; - b13 = (tmp >> 48) | (tmp << (64 - 48)); - b6 -= b13; - - tmp = b11 ^ b2; - b11 = (tmp >> 20) | (tmp << (64 - 20)); - b2 -= b11; - - tmp = b15 ^ b0; - b15 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b15; - - tmp = b9 ^ b10; - b9 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b9; - - tmp = b11 ^ b8; - b11 = (tmp >> 59) | (tmp << (64 - 59)); - b8 -= b11; - - tmp = b13 ^ b14; - b13 = (tmp >> 41) | (tmp << (64 - 41)); - b14 -= b13; - - tmp = b15 ^ b12; - b15 = (tmp >> 34) | (tmp << (64 - 34)); - b12 -= b15; - - tmp = b1 ^ b6; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b6 -= b1; - - tmp = b3 ^ b4; - b3 = (tmp >> 51) | (tmp << (64 - 51)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 4) | (tmp << (64 - 4)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 33) | (tmp << (64 - 33)); - b0 -= b7; - - tmp = b1 ^ b8; - b1 = (tmp >> 52) | (tmp << (64 - 52)); - b8 -= b1; - - tmp = b5 ^ b14; - b5 = (tmp >> 23) | (tmp << (64 - 23)); - b14 -= b5; - - tmp = b3 ^ b12; - b3 = (tmp >> 18) | (tmp << (64 - 18)); - b12 -= b3; - - tmp = b7 ^ b10; - b7 = (tmp >> 49) | (tmp << (64 - 49)); - b10 -= b7; - - tmp = b15 ^ b4; - b15 = (tmp >> 55) | (tmp << (64 - 55)); - b4 -= b15; - - tmp = b11 ^ b6; - b11 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b11; - - tmp = b13 ^ b2; - b13 = (tmp >> 19) | (tmp << (64 - 19)); - b2 -= b13; - - tmp = b9 ^ b0; - b9 = (tmp >> 38) | (tmp << (64 - 38)); - b0 -= b9; - - tmp = b15 ^ b14; - b15 = (tmp >> 37) | (tmp << (64 - 37)); - b14 -= b15 + k14 + t1; - b15 -= k15; - - tmp = b13 ^ b12; - b13 = (tmp >> 22) | (tmp << (64 - 22)); - b12 -= b13 + k12; - b13 -= k13 + t0; - - tmp = b11 ^ b10; - b11 = (tmp >> 17) | (tmp << (64 - 17)); - b10 -= b11 + k10; - b11 -= k11; - - tmp = b9 ^ b8; - b9 = (tmp >> 8) | (tmp << (64 - 8)); - b8 -= b9 + k8; - b9 -= k9; - - tmp = b7 ^ b6; - b7 = (tmp >> 47) | (tmp << (64 - 47)); - b6 -= b7 + k6; - b7 -= k7; - - tmp = b5 ^ b4; - b5 = (tmp >> 8) | (tmp << (64 - 8)); - b4 -= b5 + k4; - b5 -= k5; - - tmp = b3 ^ b2; - b3 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b3 + k2; - b3 -= k3; - - tmp = b1 ^ b0; - b1 = (tmp >> 24) | (tmp << (64 - 24)); - b0 -= b1 + k0; - b1 -= k1; - - output[15] = b15; - output[14] = b14; - output[13] = b13; - output[12] = b12; - output[11] = b11; - output[10] = b10; - output[9] = b9; - output[8] = b8; - output[7] = b7; - output[6] = b6; - output[5] = b5; - output[4] = b4; - output[3] = b3; - output[2] = b2; - output[1] = b1; - output[0] = b0; -} diff --git a/drivers/staging/skein/threefish_256_block.c b/drivers/staging/skein/threefish_256_block.c deleted file mode 100644 index 0b33b3fb899e..000000000000 --- a/drivers/staging/skein/threefish_256_block.c +++ /dev/null @@ -1,1139 +0,0 @@ -#include -#include "threefish_api.h" - - -void threefish_encrypt_256(struct threefish_key *key_ctx, u64 *input, - u64 *output) -{ - u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3]; - u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], - k2 = key_ctx->key[2], k3 = key_ctx->key[3], - k4 = key_ctx->key[4]; - u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], - t2 = key_ctx->tweak[2]; - - b1 += k1 + t0; - b0 += b1 + k0; - b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - - b3 += k3; - b2 += b3 + k2 + t1; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - - b0 += b3; - b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - - b2 += b1; - b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - - b0 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - - b2 += b3; - b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - - b0 += b3; - b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - - b2 += b1; - b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - - b1 += k2 + t1; - b0 += b1 + k1; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - - b3 += k4 + 1; - b2 += b3 + k3 + t2; - b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - - b0 += b3; - b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - - b2 += b1; - b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - - b0 += b1; - b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - - b2 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - - b0 += b3; - b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - - b2 += b1; - b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - - - b1 += k3 + t2; - b0 += b1 + k2; - b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - - b3 += k0 + 2; - b2 += b3 + k4 + t0; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - - b0 += b3; - b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - - b2 += b1; - b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - - b0 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - - b2 += b3; - b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - - b0 += b3; - b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - - b2 += b1; - b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - - b1 += k4 + t0; - b0 += b1 + k3; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - - b3 += k1 + 3; - b2 += b3 + k0 + t1; - b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - - b0 += b3; - b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - - b2 += b1; - b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - - b0 += b1; - b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - - b2 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - - b0 += b3; - b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - - b2 += b1; - b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - - - b1 += k0 + t1; - b0 += b1 + k4; - b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - - b3 += k2 + 4; - b2 += b3 + k1 + t2; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - - b0 += b3; - b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - - b2 += b1; - b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - - b0 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - - b2 += b3; - b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - - b0 += b3; - b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - - b2 += b1; - b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - - b1 += k1 + t2; - b0 += b1 + k0; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - - b3 += k3 + 5; - b2 += b3 + k2 + t0; - b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - - b0 += b3; - b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - - b2 += b1; - b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - - b0 += b1; - b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - - b2 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - - b0 += b3; - b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - - b2 += b1; - b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - - - b1 += k2 + t0; - b0 += b1 + k1; - b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - - b3 += k4 + 6; - b2 += b3 + k3 + t1; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - - b0 += b3; - b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - - b2 += b1; - b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - - b0 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - - b2 += b3; - b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - - b0 += b3; - b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - - b2 += b1; - b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - - b1 += k3 + t1; - b0 += b1 + k2; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - - b3 += k0 + 7; - b2 += b3 + k4 + t2; - b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - - b0 += b3; - b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - - b2 += b1; - b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - - b0 += b1; - b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - - b2 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - - b0 += b3; - b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - - b2 += b1; - b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - - - b1 += k4 + t2; - b0 += b1 + k3; - b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - - b3 += k1 + 8; - b2 += b3 + k0 + t0; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - - b0 += b3; - b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - - b2 += b1; - b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - - b0 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - - b2 += b3; - b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - - b0 += b3; - b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - - b2 += b1; - b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - - b1 += k0 + t0; - b0 += b1 + k4; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - - b3 += k2 + 9; - b2 += b3 + k1 + t1; - b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - - b0 += b3; - b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - - b2 += b1; - b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - - b0 += b1; - b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - - b2 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - - b0 += b3; - b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - - b2 += b1; - b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - - - b1 += k1 + t1; - b0 += b1 + k0; - b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - - b3 += k3 + 10; - b2 += b3 + k2 + t2; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - - b0 += b3; - b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - - b2 += b1; - b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - - b0 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - - b2 += b3; - b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - - b0 += b3; - b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - - b2 += b1; - b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - - b1 += k2 + t2; - b0 += b1 + k1; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - - b3 += k4 + 11; - b2 += b3 + k3 + t0; - b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - - b0 += b3; - b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - - b2 += b1; - b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - - b0 += b1; - b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - - b2 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - - b0 += b3; - b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - - b2 += b1; - b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - - - b1 += k3 + t0; - b0 += b1 + k2; - b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - - b3 += k0 + 12; - b2 += b3 + k4 + t1; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - - b0 += b3; - b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - - b2 += b1; - b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - - b0 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - - b2 += b3; - b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - - b0 += b3; - b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - - b2 += b1; - b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - - b1 += k4 + t1; - b0 += b1 + k3; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - - b3 += k1 + 13; - b2 += b3 + k0 + t2; - b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - - b0 += b3; - b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - - b2 += b1; - b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - - b0 += b1; - b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - - b2 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - - b0 += b3; - b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - - b2 += b1; - b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - - - b1 += k0 + t2; - b0 += b1 + k4; - b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - - b3 += k2 + 14; - b2 += b3 + k1 + t0; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - - b0 += b3; - b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - - b2 += b1; - b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - - b0 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - - b2 += b3; - b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - - b0 += b3; - b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - - b2 += b1; - b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - - b1 += k1 + t0; - b0 += b1 + k0; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - - b3 += k3 + 15; - b2 += b3 + k2 + t1; - b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - - b0 += b3; - b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - - b2 += b1; - b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - - b0 += b1; - b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - - b2 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - - b0 += b3; - b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - - b2 += b1; - b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - - - b1 += k2 + t1; - b0 += b1 + k1; - b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; - - b3 += k4 + 16; - b2 += b3 + k3 + t2; - b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; - - b0 += b3; - b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; - - b2 += b1; - b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; - - b0 += b1; - b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; - - b2 += b3; - b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; - - b0 += b3; - b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; - - b2 += b1; - b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; - - b1 += k3 + t2; - b0 += b1 + k2; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; - - b3 += k0 + 17; - b2 += b3 + k4 + t0; - b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; - - b0 += b3; - b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; - - b2 += b1; - b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; - - b0 += b1; - b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; - - b2 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; - - b0 += b3; - b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; - - b2 += b1; - b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; - - output[0] = b0 + k3; - output[1] = b1 + k4 + t0; - output[2] = b2 + k0 + t1; - output[3] = b3 + k1 + 18; -} - -void threefish_decrypt_256(struct threefish_key *key_ctx, u64 *input, - u64 *output) -{ - u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3]; - u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], - k2 = key_ctx->key[2], k3 = key_ctx->key[3], - k4 = key_ctx->key[4]; - u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], - t2 = key_ctx->tweak[2]; - - u64 tmp; - - b0 -= k3; - b1 -= k4 + t0; - b2 -= k0 + t1; - b3 -= k1 + 18; - tmp = b3 ^ b0; - b3 = (tmp >> 32) | (tmp << (64 - 32)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 32) | (tmp << (64 - 32)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 58) | (tmp << (64 - 58)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 12) | (tmp << (64 - 12)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b0 -= b1 + k2; - b1 -= k3 + t2; - - tmp = b3 ^ b2; - b3 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b3 + k4 + t0; - b3 -= k0 + 17; - - tmp = b3 ^ b0; - b3 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 37) | (tmp << (64 - 37)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 40) | (tmp << (64 - 40)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 52) | (tmp << (64 - 52)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 57) | (tmp << (64 - 57)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 14) | (tmp << (64 - 14)); - b0 -= b1 + k1; - b1 -= k2 + t1; - - tmp = b3 ^ b2; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b2 -= b3 + k3 + t2; - b3 -= k4 + 16; - - - tmp = b3 ^ b0; - b3 = (tmp >> 32) | (tmp << (64 - 32)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 32) | (tmp << (64 - 32)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 58) | (tmp << (64 - 58)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 12) | (tmp << (64 - 12)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b0 -= b1 + k0; - b1 -= k1 + t0; - - tmp = b3 ^ b2; - b3 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b3 + k2 + t1; - b3 -= k3 + 15; - - tmp = b3 ^ b0; - b3 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 37) | (tmp << (64 - 37)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 40) | (tmp << (64 - 40)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 52) | (tmp << (64 - 52)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 57) | (tmp << (64 - 57)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 14) | (tmp << (64 - 14)); - b0 -= b1 + k4; - b1 -= k0 + t2; - - tmp = b3 ^ b2; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b2 -= b3 + k1 + t0; - b3 -= k2 + 14; - - - tmp = b3 ^ b0; - b3 = (tmp >> 32) | (tmp << (64 - 32)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 32) | (tmp << (64 - 32)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 58) | (tmp << (64 - 58)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 12) | (tmp << (64 - 12)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b0 -= b1 + k3; - b1 -= k4 + t1; - - tmp = b3 ^ b2; - b3 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b3 + k0 + t2; - b3 -= k1 + 13; - - tmp = b3 ^ b0; - b3 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 37) | (tmp << (64 - 37)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 40) | (tmp << (64 - 40)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 52) | (tmp << (64 - 52)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 57) | (tmp << (64 - 57)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 14) | (tmp << (64 - 14)); - b0 -= b1 + k2; - b1 -= k3 + t0; - - tmp = b3 ^ b2; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b2 -= b3 + k4 + t1; - b3 -= k0 + 12; - - - tmp = b3 ^ b0; - b3 = (tmp >> 32) | (tmp << (64 - 32)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 32) | (tmp << (64 - 32)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 58) | (tmp << (64 - 58)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 12) | (tmp << (64 - 12)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b0 -= b1 + k1; - b1 -= k2 + t2; - - tmp = b3 ^ b2; - b3 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b3 + k3 + t0; - b3 -= k4 + 11; - - tmp = b3 ^ b0; - b3 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 37) | (tmp << (64 - 37)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 40) | (tmp << (64 - 40)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 52) | (tmp << (64 - 52)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 57) | (tmp << (64 - 57)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 14) | (tmp << (64 - 14)); - b0 -= b1 + k0; - b1 -= k1 + t1; - - tmp = b3 ^ b2; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b2 -= b3 + k2 + t2; - b3 -= k3 + 10; - - - tmp = b3 ^ b0; - b3 = (tmp >> 32) | (tmp << (64 - 32)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 32) | (tmp << (64 - 32)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 58) | (tmp << (64 - 58)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 12) | (tmp << (64 - 12)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b0 -= b1 + k4; - b1 -= k0 + t0; - - tmp = b3 ^ b2; - b3 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b3 + k1 + t1; - b3 -= k2 + 9; - - tmp = b3 ^ b0; - b3 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 37) | (tmp << (64 - 37)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 40) | (tmp << (64 - 40)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 52) | (tmp << (64 - 52)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 57) | (tmp << (64 - 57)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 14) | (tmp << (64 - 14)); - b0 -= b1 + k3; - b1 -= k4 + t2; - - tmp = b3 ^ b2; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b2 -= b3 + k0 + t0; - b3 -= k1 + 8; - - - tmp = b3 ^ b0; - b3 = (tmp >> 32) | (tmp << (64 - 32)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 32) | (tmp << (64 - 32)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 58) | (tmp << (64 - 58)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 12) | (tmp << (64 - 12)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b0 -= b1 + k2; - b1 -= k3 + t1; - - tmp = b3 ^ b2; - b3 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b3 + k4 + t2; - b3 -= k0 + 7; - - tmp = b3 ^ b0; - b3 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 37) | (tmp << (64 - 37)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 40) | (tmp << (64 - 40)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 52) | (tmp << (64 - 52)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 57) | (tmp << (64 - 57)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 14) | (tmp << (64 - 14)); - b0 -= b1 + k1; - b1 -= k2 + t0; - - tmp = b3 ^ b2; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b2 -= b3 + k3 + t1; - b3 -= k4 + 6; - - - tmp = b3 ^ b0; - b3 = (tmp >> 32) | (tmp << (64 - 32)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 32) | (tmp << (64 - 32)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 58) | (tmp << (64 - 58)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 12) | (tmp << (64 - 12)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b0 -= b1 + k0; - b1 -= k1 + t2; - - tmp = b3 ^ b2; - b3 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b3 + k2 + t0; - b3 -= k3 + 5; - - tmp = b3 ^ b0; - b3 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 37) | (tmp << (64 - 37)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 40) | (tmp << (64 - 40)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 52) | (tmp << (64 - 52)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 57) | (tmp << (64 - 57)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 14) | (tmp << (64 - 14)); - b0 -= b1 + k4; - b1 -= k0 + t1; - - tmp = b3 ^ b2; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b2 -= b3 + k1 + t2; - b3 -= k2 + 4; - - - tmp = b3 ^ b0; - b3 = (tmp >> 32) | (tmp << (64 - 32)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 32) | (tmp << (64 - 32)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 58) | (tmp << (64 - 58)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 12) | (tmp << (64 - 12)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b0 -= b1 + k3; - b1 -= k4 + t0; - - tmp = b3 ^ b2; - b3 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b3 + k0 + t1; - b3 -= k1 + 3; - - tmp = b3 ^ b0; - b3 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 37) | (tmp << (64 - 37)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 40) | (tmp << (64 - 40)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 52) | (tmp << (64 - 52)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 57) | (tmp << (64 - 57)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 14) | (tmp << (64 - 14)); - b0 -= b1 + k2; - b1 -= k3 + t2; - - tmp = b3 ^ b2; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b2 -= b3 + k4 + t0; - b3 -= k0 + 2; - - - tmp = b3 ^ b0; - b3 = (tmp >> 32) | (tmp << (64 - 32)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 32) | (tmp << (64 - 32)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 58) | (tmp << (64 - 58)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 12) | (tmp << (64 - 12)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b0 -= b1 + k1; - b1 -= k2 + t1; - - tmp = b3 ^ b2; - b3 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b3 + k3 + t2; - b3 -= k4 + 1; - - tmp = b3 ^ b0; - b3 = (tmp >> 5) | (tmp << (64 - 5)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 37) | (tmp << (64 - 37)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 23) | (tmp << (64 - 23)); - b0 -= b1; - - tmp = b3 ^ b2; - b3 = (tmp >> 40) | (tmp << (64 - 40)); - b2 -= b3; - - tmp = b3 ^ b0; - b3 = (tmp >> 52) | (tmp << (64 - 52)); - b0 -= b3; - - tmp = b1 ^ b2; - b1 = (tmp >> 57) | (tmp << (64 - 57)); - b2 -= b1; - - tmp = b1 ^ b0; - b1 = (tmp >> 14) | (tmp << (64 - 14)); - b0 -= b1 + k0; - b1 -= k1 + t0; - - tmp = b3 ^ b2; - b3 = (tmp >> 16) | (tmp << (64 - 16)); - b2 -= b3 + k2 + t1; - b3 -= k3; - - output[0] = b0; - output[1] = b1; - output[2] = b2; - output[3] = b3; -} diff --git a/drivers/staging/skein/threefish_512_block.c b/drivers/staging/skein/threefish_512_block.c deleted file mode 100644 index 1c62bf6a7da3..000000000000 --- a/drivers/staging/skein/threefish_512_block.c +++ /dev/null @@ -1,2225 +0,0 @@ -#include -#include "threefish_api.h" - - -void threefish_encrypt_512(struct threefish_key *key_ctx, u64 *input, - u64 *output) -{ - u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3], - b4 = input[4], b5 = input[5], - b6 = input[6], b7 = input[7]; - u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], - k2 = key_ctx->key[2], k3 = key_ctx->key[3], - k4 = key_ctx->key[4], k5 = key_ctx->key[5], - k6 = key_ctx->key[6], k7 = key_ctx->key[7], - k8 = key_ctx->key[8]; - u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], - t2 = key_ctx->tweak[2]; - - b1 += k1; - b0 += b1 + k0; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - - b3 += k3; - b2 += b3 + k2; - b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - - b5 += k5 + t0; - b4 += b5 + k4; - b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - - b7 += k7; - b6 += b7 + k6 + t1; - b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - - b2 += b1; - b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - - b4 += b7; - b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - - b6 += b5; - b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - - b0 += b3; - b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - - b4 += b1; - b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - - b6 += b3; - b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - - b0 += b5; - b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - - b2 += b7; - b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - - b6 += b1; - b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - - b0 += b7; - b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - - b2 += b5; - b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - - b4 += b3; - b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - - b1 += k2; - b0 += b1 + k1; - b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - - b3 += k4; - b2 += b3 + k3; - b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - - b5 += k6 + t1; - b4 += b5 + k5; - b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - - b7 += k8 + 1; - b6 += b7 + k7 + t2; - b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - - b2 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - - b4 += b7; - b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - - b6 += b5; - b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - - b0 += b3; - b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - - b4 += b1; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - - b6 += b3; - b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - - b0 += b5; - b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - - b2 += b7; - b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - - b6 += b1; - b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - - b0 += b7; - b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - - b2 += b5; - b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - - b4 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - - b1 += k3; - b0 += b1 + k2; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - - b3 += k5; - b2 += b3 + k4; - b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - - b5 += k7 + t2; - b4 += b5 + k6; - b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - - b7 += k0 + 2; - b6 += b7 + k8 + t0; - b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - - b2 += b1; - b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - - b4 += b7; - b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - - b6 += b5; - b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - - b0 += b3; - b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - - b4 += b1; - b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - - b6 += b3; - b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - - b0 += b5; - b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - - b2 += b7; - b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - - b6 += b1; - b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - - b0 += b7; - b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - - b2 += b5; - b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - - b4 += b3; - b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - - b1 += k4; - b0 += b1 + k3; - b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - - b3 += k6; - b2 += b3 + k5; - b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - - b5 += k8 + t0; - b4 += b5 + k7; - b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - - b7 += k1 + 3; - b6 += b7 + k0 + t1; - b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - - b2 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - - b4 += b7; - b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - - b6 += b5; - b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - - b0 += b3; - b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - - b4 += b1; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - - b6 += b3; - b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - - b0 += b5; - b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - - b2 += b7; - b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - - b6 += b1; - b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - - b0 += b7; - b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - - b2 += b5; - b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - - b4 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - - b1 += k5; - b0 += b1 + k4; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - - b3 += k7; - b2 += b3 + k6; - b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - - b5 += k0 + t1; - b4 += b5 + k8; - b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - - b7 += k2 + 4; - b6 += b7 + k1 + t2; - b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - - b2 += b1; - b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - - b4 += b7; - b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - - b6 += b5; - b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - - b0 += b3; - b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - - b4 += b1; - b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - - b6 += b3; - b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - - b0 += b5; - b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - - b2 += b7; - b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - - b6 += b1; - b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - - b0 += b7; - b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - - b2 += b5; - b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - - b4 += b3; - b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - - b1 += k6; - b0 += b1 + k5; - b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - - b3 += k8; - b2 += b3 + k7; - b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - - b5 += k1 + t2; - b4 += b5 + k0; - b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - - b7 += k3 + 5; - b6 += b7 + k2 + t0; - b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - - b2 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - - b4 += b7; - b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - - b6 += b5; - b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - - b0 += b3; - b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - - b4 += b1; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - - b6 += b3; - b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - - b0 += b5; - b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - - b2 += b7; - b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - - b6 += b1; - b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - - b0 += b7; - b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - - b2 += b5; - b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - - b4 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - - b1 += k7; - b0 += b1 + k6; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - - b3 += k0; - b2 += b3 + k8; - b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - - b5 += k2 + t0; - b4 += b5 + k1; - b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - - b7 += k4 + 6; - b6 += b7 + k3 + t1; - b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - - b2 += b1; - b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - - b4 += b7; - b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - - b6 += b5; - b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - - b0 += b3; - b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - - b4 += b1; - b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - - b6 += b3; - b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - - b0 += b5; - b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - - b2 += b7; - b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - - b6 += b1; - b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - - b0 += b7; - b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - - b2 += b5; - b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - - b4 += b3; - b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - - b1 += k8; - b0 += b1 + k7; - b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - - b3 += k1; - b2 += b3 + k0; - b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - - b5 += k3 + t1; - b4 += b5 + k2; - b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - - b7 += k5 + 7; - b6 += b7 + k4 + t2; - b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - - b2 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - - b4 += b7; - b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - - b6 += b5; - b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - - b0 += b3; - b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - - b4 += b1; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - - b6 += b3; - b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - - b0 += b5; - b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - - b2 += b7; - b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - - b6 += b1; - b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - - b0 += b7; - b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - - b2 += b5; - b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - - b4 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - - b1 += k0; - b0 += b1 + k8; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - - b3 += k2; - b2 += b3 + k1; - b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - - b5 += k4 + t2; - b4 += b5 + k3; - b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - - b7 += k6 + 8; - b6 += b7 + k5 + t0; - b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - - b2 += b1; - b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - - b4 += b7; - b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - - b6 += b5; - b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - - b0 += b3; - b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - - b4 += b1; - b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - - b6 += b3; - b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - - b0 += b5; - b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - - b2 += b7; - b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - - b6 += b1; - b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - - b0 += b7; - b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - - b2 += b5; - b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - - b4 += b3; - b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - - b1 += k1; - b0 += b1 + k0; - b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - - b3 += k3; - b2 += b3 + k2; - b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - - b5 += k5 + t0; - b4 += b5 + k4; - b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - - b7 += k7 + 9; - b6 += b7 + k6 + t1; - b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - - b2 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - - b4 += b7; - b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - - b6 += b5; - b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - - b0 += b3; - b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - - b4 += b1; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - - b6 += b3; - b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - - b0 += b5; - b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - - b2 += b7; - b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - - b6 += b1; - b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - - b0 += b7; - b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - - b2 += b5; - b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - - b4 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - - b1 += k2; - b0 += b1 + k1; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - - b3 += k4; - b2 += b3 + k3; - b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - - b5 += k6 + t1; - b4 += b5 + k5; - b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - - b7 += k8 + 10; - b6 += b7 + k7 + t2; - b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - - b2 += b1; - b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - - b4 += b7; - b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - - b6 += b5; - b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - - b0 += b3; - b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - - b4 += b1; - b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - - b6 += b3; - b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - - b0 += b5; - b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - - b2 += b7; - b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - - b6 += b1; - b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - - b0 += b7; - b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - - b2 += b5; - b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - - b4 += b3; - b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - - b1 += k3; - b0 += b1 + k2; - b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - - b3 += k5; - b2 += b3 + k4; - b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - - b5 += k7 + t2; - b4 += b5 + k6; - b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - - b7 += k0 + 11; - b6 += b7 + k8 + t0; - b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - - b2 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - - b4 += b7; - b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - - b6 += b5; - b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - - b0 += b3; - b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - - b4 += b1; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - - b6 += b3; - b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - - b0 += b5; - b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - - b2 += b7; - b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - - b6 += b1; - b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - - b0 += b7; - b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - - b2 += b5; - b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - - b4 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - - b1 += k4; - b0 += b1 + k3; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - - b3 += k6; - b2 += b3 + k5; - b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - - b5 += k8 + t0; - b4 += b5 + k7; - b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - - b7 += k1 + 12; - b6 += b7 + k0 + t1; - b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - - b2 += b1; - b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - - b4 += b7; - b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - - b6 += b5; - b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - - b0 += b3; - b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - - b4 += b1; - b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - - b6 += b3; - b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - - b0 += b5; - b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - - b2 += b7; - b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - - b6 += b1; - b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - - b0 += b7; - b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - - b2 += b5; - b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - - b4 += b3; - b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - - b1 += k5; - b0 += b1 + k4; - b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - - b3 += k7; - b2 += b3 + k6; - b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - - b5 += k0 + t1; - b4 += b5 + k8; - b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - - b7 += k2 + 13; - b6 += b7 + k1 + t2; - b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - - b2 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - - b4 += b7; - b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - - b6 += b5; - b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - - b0 += b3; - b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - - b4 += b1; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - - b6 += b3; - b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - - b0 += b5; - b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - - b2 += b7; - b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - - b6 += b1; - b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - - b0 += b7; - b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - - b2 += b5; - b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - - b4 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - - b1 += k6; - b0 += b1 + k5; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - - b3 += k8; - b2 += b3 + k7; - b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - - b5 += k1 + t2; - b4 += b5 + k0; - b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - - b7 += k3 + 14; - b6 += b7 + k2 + t0; - b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - - b2 += b1; - b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - - b4 += b7; - b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - - b6 += b5; - b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - - b0 += b3; - b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - - b4 += b1; - b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - - b6 += b3; - b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - - b0 += b5; - b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - - b2 += b7; - b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - - b6 += b1; - b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - - b0 += b7; - b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - - b2 += b5; - b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - - b4 += b3; - b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - - b1 += k7; - b0 += b1 + k6; - b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - - b3 += k0; - b2 += b3 + k8; - b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - - b5 += k2 + t0; - b4 += b5 + k1; - b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - - b7 += k4 + 15; - b6 += b7 + k3 + t1; - b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - - b2 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - - b4 += b7; - b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - - b6 += b5; - b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - - b0 += b3; - b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - - b4 += b1; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - - b6 += b3; - b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - - b0 += b5; - b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - - b2 += b7; - b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - - b6 += b1; - b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - - b0 += b7; - b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - - b2 += b5; - b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - - b4 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - - b1 += k8; - b0 += b1 + k7; - b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; - - b3 += k1; - b2 += b3 + k0; - b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; - - b5 += k3 + t1; - b4 += b5 + k2; - b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; - - b7 += k5 + 16; - b6 += b7 + k4 + t2; - b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; - - b2 += b1; - b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; - - b4 += b7; - b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; - - b6 += b5; - b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; - - b0 += b3; - b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; - - b4 += b1; - b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; - - b6 += b3; - b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; - - b0 += b5; - b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; - - b2 += b7; - b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; - - b6 += b1; - b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; - - b0 += b7; - b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; - - b2 += b5; - b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; - - b4 += b3; - b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; - - b1 += k0; - b0 += b1 + k8; - b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; - - b3 += k2; - b2 += b3 + k1; - b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; - - b5 += k4 + t2; - b4 += b5 + k3; - b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; - - b7 += k6 + 17; - b6 += b7 + k5 + t0; - b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; - - b2 += b1; - b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; - - b4 += b7; - b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; - - b6 += b5; - b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; - - b0 += b3; - b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; - - b4 += b1; - b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; - - b6 += b3; - b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; - - b0 += b5; - b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; - - b2 += b7; - b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; - - b6 += b1; - b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; - - b0 += b7; - b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; - - b2 += b5; - b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; - - b4 += b3; - b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; - - output[0] = b0 + k0; - output[1] = b1 + k1; - output[2] = b2 + k2; - output[3] = b3 + k3; - output[4] = b4 + k4; - output[5] = b5 + k5 + t0; - output[6] = b6 + k6 + t1; - output[7] = b7 + k7 + 18; -} - -void threefish_decrypt_512(struct threefish_key *key_ctx, u64 *input, - u64 *output) -{ - u64 b0 = input[0], b1 = input[1], - b2 = input[2], b3 = input[3], - b4 = input[4], b5 = input[5], - b6 = input[6], b7 = input[7]; - u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], - k2 = key_ctx->key[2], k3 = key_ctx->key[3], - k4 = key_ctx->key[4], k5 = key_ctx->key[5], - k6 = key_ctx->key[6], k7 = key_ctx->key[7], - k8 = key_ctx->key[8]; - u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], - t2 = key_ctx->tweak[2]; - - u64 tmp; - - b0 -= k0; - b1 -= k1; - b2 -= k2; - b3 -= k3; - b4 -= k4; - b5 -= k5 + t0; - b6 -= k6 + t1; - b7 -= k7 + 18; - - tmp = b3 ^ b4; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 56) | (tmp << (64 - 56)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 35) | (tmp << (64 - 35)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 8) | (tmp << (64 - 8)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 43) | (tmp << (64 - 43)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 29) | (tmp << (64 - 29)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 17) | (tmp << (64 - 17)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 50) | (tmp << (64 - 50)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 24) | (tmp << (64 - 24)); - b6 -= b7 + k5 + t0; - b7 -= k6 + 17; - - tmp = b5 ^ b4; - b5 = (tmp >> 34) | (tmp << (64 - 34)); - b4 -= b5 + k3; - b5 -= k4 + t2; - - tmp = b3 ^ b2; - b3 = (tmp >> 30) | (tmp << (64 - 30)); - b2 -= b3 + k1; - b3 -= k2; - - tmp = b1 ^ b0; - b1 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b1 + k8; - b1 -= k0; - - tmp = b3 ^ b4; - b3 = (tmp >> 56) | (tmp << (64 - 56)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 54) | (tmp << (64 - 54)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 44) | (tmp << (64 - 44)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 39) | (tmp << (64 - 39)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 36) | (tmp << (64 - 36)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 49) | (tmp << (64 - 49)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 17) | (tmp << (64 - 17)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 42) | (tmp << (64 - 42)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 14) | (tmp << (64 - 14)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 27) | (tmp << (64 - 27)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 37) | (tmp << (64 - 37)); - b6 -= b7 + k4 + t2; - b7 -= k5 + 16; - - tmp = b5 ^ b4; - b5 = (tmp >> 19) | (tmp << (64 - 19)); - b4 -= b5 + k2; - b5 -= k3 + t1; - - tmp = b3 ^ b2; - b3 = (tmp >> 36) | (tmp << (64 - 36)); - b2 -= b3 + k0; - b3 -= k1; - - tmp = b1 ^ b0; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b1 + k7; - b1 -= k8; - - tmp = b3 ^ b4; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 56) | (tmp << (64 - 56)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 35) | (tmp << (64 - 35)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 8) | (tmp << (64 - 8)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 43) | (tmp << (64 - 43)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 29) | (tmp << (64 - 29)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 17) | (tmp << (64 - 17)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 50) | (tmp << (64 - 50)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 24) | (tmp << (64 - 24)); - b6 -= b7 + k3 + t1; - b7 -= k4 + 15; - - tmp = b5 ^ b4; - b5 = (tmp >> 34) | (tmp << (64 - 34)); - b4 -= b5 + k1; - b5 -= k2 + t0; - - tmp = b3 ^ b2; - b3 = (tmp >> 30) | (tmp << (64 - 30)); - b2 -= b3 + k8; - b3 -= k0; - - tmp = b1 ^ b0; - b1 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b1 + k6; - b1 -= k7; - - tmp = b3 ^ b4; - b3 = (tmp >> 56) | (tmp << (64 - 56)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 54) | (tmp << (64 - 54)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 44) | (tmp << (64 - 44)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 39) | (tmp << (64 - 39)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 36) | (tmp << (64 - 36)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 49) | (tmp << (64 - 49)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 17) | (tmp << (64 - 17)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 42) | (tmp << (64 - 42)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 14) | (tmp << (64 - 14)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 27) | (tmp << (64 - 27)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 37) | (tmp << (64 - 37)); - b6 -= b7 + k2 + t0; - b7 -= k3 + 14; - - tmp = b5 ^ b4; - b5 = (tmp >> 19) | (tmp << (64 - 19)); - b4 -= b5 + k0; - b5 -= k1 + t2; - - tmp = b3 ^ b2; - b3 = (tmp >> 36) | (tmp << (64 - 36)); - b2 -= b3 + k7; - b3 -= k8; - - tmp = b1 ^ b0; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b1 + k5; - b1 -= k6; - - tmp = b3 ^ b4; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 56) | (tmp << (64 - 56)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 35) | (tmp << (64 - 35)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 8) | (tmp << (64 - 8)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 43) | (tmp << (64 - 43)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 29) | (tmp << (64 - 29)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 17) | (tmp << (64 - 17)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 50) | (tmp << (64 - 50)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 24) | (tmp << (64 - 24)); - b6 -= b7 + k1 + t2; - b7 -= k2 + 13; - - tmp = b5 ^ b4; - b5 = (tmp >> 34) | (tmp << (64 - 34)); - b4 -= b5 + k8; - b5 -= k0 + t1; - - tmp = b3 ^ b2; - b3 = (tmp >> 30) | (tmp << (64 - 30)); - b2 -= b3 + k6; - b3 -= k7; - - tmp = b1 ^ b0; - b1 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b1 + k4; - b1 -= k5; - - tmp = b3 ^ b4; - b3 = (tmp >> 56) | (tmp << (64 - 56)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 54) | (tmp << (64 - 54)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 44) | (tmp << (64 - 44)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 39) | (tmp << (64 - 39)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 36) | (tmp << (64 - 36)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 49) | (tmp << (64 - 49)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 17) | (tmp << (64 - 17)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 42) | (tmp << (64 - 42)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 14) | (tmp << (64 - 14)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 27) | (tmp << (64 - 27)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 37) | (tmp << (64 - 37)); - b6 -= b7 + k0 + t1; - b7 -= k1 + 12; - - tmp = b5 ^ b4; - b5 = (tmp >> 19) | (tmp << (64 - 19)); - b4 -= b5 + k7; - b5 -= k8 + t0; - - tmp = b3 ^ b2; - b3 = (tmp >> 36) | (tmp << (64 - 36)); - b2 -= b3 + k5; - b3 -= k6; - - tmp = b1 ^ b0; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b1 + k3; - b1 -= k4; - - tmp = b3 ^ b4; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 56) | (tmp << (64 - 56)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 35) | (tmp << (64 - 35)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 8) | (tmp << (64 - 8)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 43) | (tmp << (64 - 43)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 29) | (tmp << (64 - 29)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 17) | (tmp << (64 - 17)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 50) | (tmp << (64 - 50)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 24) | (tmp << (64 - 24)); - b6 -= b7 + k8 + t0; - b7 -= k0 + 11; - - tmp = b5 ^ b4; - b5 = (tmp >> 34) | (tmp << (64 - 34)); - b4 -= b5 + k6; - b5 -= k7 + t2; - - tmp = b3 ^ b2; - b3 = (tmp >> 30) | (tmp << (64 - 30)); - b2 -= b3 + k4; - b3 -= k5; - - tmp = b1 ^ b0; - b1 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b1 + k2; - b1 -= k3; - - tmp = b3 ^ b4; - b3 = (tmp >> 56) | (tmp << (64 - 56)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 54) | (tmp << (64 - 54)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 44) | (tmp << (64 - 44)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 39) | (tmp << (64 - 39)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 36) | (tmp << (64 - 36)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 49) | (tmp << (64 - 49)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 17) | (tmp << (64 - 17)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 42) | (tmp << (64 - 42)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 14) | (tmp << (64 - 14)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 27) | (tmp << (64 - 27)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 37) | (tmp << (64 - 37)); - b6 -= b7 + k7 + t2; - b7 -= k8 + 10; - - tmp = b5 ^ b4; - b5 = (tmp >> 19) | (tmp << (64 - 19)); - b4 -= b5 + k5; - b5 -= k6 + t1; - - tmp = b3 ^ b2; - b3 = (tmp >> 36) | (tmp << (64 - 36)); - b2 -= b3 + k3; - b3 -= k4; - - tmp = b1 ^ b0; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b1 + k1; - b1 -= k2; - - tmp = b3 ^ b4; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 56) | (tmp << (64 - 56)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 35) | (tmp << (64 - 35)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 8) | (tmp << (64 - 8)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 43) | (tmp << (64 - 43)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 29) | (tmp << (64 - 29)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 17) | (tmp << (64 - 17)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 50) | (tmp << (64 - 50)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 24) | (tmp << (64 - 24)); - b6 -= b7 + k6 + t1; - b7 -= k7 + 9; - - tmp = b5 ^ b4; - b5 = (tmp >> 34) | (tmp << (64 - 34)); - b4 -= b5 + k4; - b5 -= k5 + t0; - - tmp = b3 ^ b2; - b3 = (tmp >> 30) | (tmp << (64 - 30)); - b2 -= b3 + k2; - b3 -= k3; - - tmp = b1 ^ b0; - b1 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b1 + k0; - b1 -= k1; - - tmp = b3 ^ b4; - b3 = (tmp >> 56) | (tmp << (64 - 56)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 54) | (tmp << (64 - 54)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 44) | (tmp << (64 - 44)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 39) | (tmp << (64 - 39)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 36) | (tmp << (64 - 36)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 49) | (tmp << (64 - 49)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 17) | (tmp << (64 - 17)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 42) | (tmp << (64 - 42)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 14) | (tmp << (64 - 14)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 27) | (tmp << (64 - 27)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 37) | (tmp << (64 - 37)); - b6 -= b7 + k5 + t0; - b7 -= k6 + 8; - - tmp = b5 ^ b4; - b5 = (tmp >> 19) | (tmp << (64 - 19)); - b4 -= b5 + k3; - b5 -= k4 + t2; - - tmp = b3 ^ b2; - b3 = (tmp >> 36) | (tmp << (64 - 36)); - b2 -= b3 + k1; - b3 -= k2; - - tmp = b1 ^ b0; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b1 + k8; - b1 -= k0; - - tmp = b3 ^ b4; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 56) | (tmp << (64 - 56)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 35) | (tmp << (64 - 35)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 8) | (tmp << (64 - 8)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 43) | (tmp << (64 - 43)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 29) | (tmp << (64 - 29)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 17) | (tmp << (64 - 17)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 50) | (tmp << (64 - 50)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 24) | (tmp << (64 - 24)); - b6 -= b7 + k4 + t2; - b7 -= k5 + 7; - - tmp = b5 ^ b4; - b5 = (tmp >> 34) | (tmp << (64 - 34)); - b4 -= b5 + k2; - b5 -= k3 + t1; - - tmp = b3 ^ b2; - b3 = (tmp >> 30) | (tmp << (64 - 30)); - b2 -= b3 + k0; - b3 -= k1; - - tmp = b1 ^ b0; - b1 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b1 + k7; - b1 -= k8; - - tmp = b3 ^ b4; - b3 = (tmp >> 56) | (tmp << (64 - 56)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 54) | (tmp << (64 - 54)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 44) | (tmp << (64 - 44)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 39) | (tmp << (64 - 39)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 36) | (tmp << (64 - 36)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 49) | (tmp << (64 - 49)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 17) | (tmp << (64 - 17)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 42) | (tmp << (64 - 42)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 14) | (tmp << (64 - 14)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 27) | (tmp << (64 - 27)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 37) | (tmp << (64 - 37)); - b6 -= b7 + k3 + t1; - b7 -= k4 + 6; - - tmp = b5 ^ b4; - b5 = (tmp >> 19) | (tmp << (64 - 19)); - b4 -= b5 + k1; - b5 -= k2 + t0; - - tmp = b3 ^ b2; - b3 = (tmp >> 36) | (tmp << (64 - 36)); - b2 -= b3 + k8; - b3 -= k0; - - tmp = b1 ^ b0; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b1 + k6; - b1 -= k7; - - tmp = b3 ^ b4; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 56) | (tmp << (64 - 56)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 35) | (tmp << (64 - 35)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 8) | (tmp << (64 - 8)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 43) | (tmp << (64 - 43)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 29) | (tmp << (64 - 29)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 17) | (tmp << (64 - 17)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 50) | (tmp << (64 - 50)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 24) | (tmp << (64 - 24)); - b6 -= b7 + k2 + t0; - b7 -= k3 + 5; - - tmp = b5 ^ b4; - b5 = (tmp >> 34) | (tmp << (64 - 34)); - b4 -= b5 + k0; - b5 -= k1 + t2; - - tmp = b3 ^ b2; - b3 = (tmp >> 30) | (tmp << (64 - 30)); - b2 -= b3 + k7; - b3 -= k8; - - tmp = b1 ^ b0; - b1 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b1 + k5; - b1 -= k6; - - tmp = b3 ^ b4; - b3 = (tmp >> 56) | (tmp << (64 - 56)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 54) | (tmp << (64 - 54)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 44) | (tmp << (64 - 44)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 39) | (tmp << (64 - 39)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 36) | (tmp << (64 - 36)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 49) | (tmp << (64 - 49)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 17) | (tmp << (64 - 17)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 42) | (tmp << (64 - 42)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 14) | (tmp << (64 - 14)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 27) | (tmp << (64 - 27)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 37) | (tmp << (64 - 37)); - b6 -= b7 + k1 + t2; - b7 -= k2 + 4; - - tmp = b5 ^ b4; - b5 = (tmp >> 19) | (tmp << (64 - 19)); - b4 -= b5 + k8; - b5 -= k0 + t1; - - tmp = b3 ^ b2; - b3 = (tmp >> 36) | (tmp << (64 - 36)); - b2 -= b3 + k6; - b3 -= k7; - - tmp = b1 ^ b0; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b1 + k4; - b1 -= k5; - - tmp = b3 ^ b4; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 56) | (tmp << (64 - 56)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 35) | (tmp << (64 - 35)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 8) | (tmp << (64 - 8)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 43) | (tmp << (64 - 43)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 29) | (tmp << (64 - 29)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 17) | (tmp << (64 - 17)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 50) | (tmp << (64 - 50)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 24) | (tmp << (64 - 24)); - b6 -= b7 + k0 + t1; - b7 -= k1 + 3; - - tmp = b5 ^ b4; - b5 = (tmp >> 34) | (tmp << (64 - 34)); - b4 -= b5 + k7; - b5 -= k8 + t0; - - tmp = b3 ^ b2; - b3 = (tmp >> 30) | (tmp << (64 - 30)); - b2 -= b3 + k5; - b3 -= k6; - - tmp = b1 ^ b0; - b1 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b1 + k3; - b1 -= k4; - - tmp = b3 ^ b4; - b3 = (tmp >> 56) | (tmp << (64 - 56)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 54) | (tmp << (64 - 54)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 44) | (tmp << (64 - 44)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 39) | (tmp << (64 - 39)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 36) | (tmp << (64 - 36)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 49) | (tmp << (64 - 49)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 17) | (tmp << (64 - 17)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 42) | (tmp << (64 - 42)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 14) | (tmp << (64 - 14)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 27) | (tmp << (64 - 27)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 37) | (tmp << (64 - 37)); - b6 -= b7 + k8 + t0; - b7 -= k0 + 2; - - tmp = b5 ^ b4; - b5 = (tmp >> 19) | (tmp << (64 - 19)); - b4 -= b5 + k6; - b5 -= k7 + t2; - - tmp = b3 ^ b2; - b3 = (tmp >> 36) | (tmp << (64 - 36)); - b2 -= b3 + k4; - b3 -= k5; - - tmp = b1 ^ b0; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b1 + k2; - b1 -= k3; - - tmp = b3 ^ b4; - b3 = (tmp >> 22) | (tmp << (64 - 22)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 56) | (tmp << (64 - 56)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 35) | (tmp << (64 - 35)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 8) | (tmp << (64 - 8)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 43) | (tmp << (64 - 43)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 29) | (tmp << (64 - 29)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 25) | (tmp << (64 - 25)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 17) | (tmp << (64 - 17)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 10) | (tmp << (64 - 10)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 50) | (tmp << (64 - 50)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 13) | (tmp << (64 - 13)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 24) | (tmp << (64 - 24)); - b6 -= b7 + k7 + t2; - b7 -= k8 + 1; - - tmp = b5 ^ b4; - b5 = (tmp >> 34) | (tmp << (64 - 34)); - b4 -= b5 + k5; - b5 -= k6 + t1; - - tmp = b3 ^ b2; - b3 = (tmp >> 30) | (tmp << (64 - 30)); - b2 -= b3 + k3; - b3 -= k4; - - tmp = b1 ^ b0; - b1 = (tmp >> 39) | (tmp << (64 - 39)); - b0 -= b1 + k1; - b1 -= k2; - - tmp = b3 ^ b4; - b3 = (tmp >> 56) | (tmp << (64 - 56)); - b4 -= b3; - - tmp = b5 ^ b2; - b5 = (tmp >> 54) | (tmp << (64 - 54)); - b2 -= b5; - - tmp = b7 ^ b0; - b7 = (tmp >> 9) | (tmp << (64 - 9)); - b0 -= b7; - - tmp = b1 ^ b6; - b1 = (tmp >> 44) | (tmp << (64 - 44)); - b6 -= b1; - - tmp = b7 ^ b2; - b7 = (tmp >> 39) | (tmp << (64 - 39)); - b2 -= b7; - - tmp = b5 ^ b0; - b5 = (tmp >> 36) | (tmp << (64 - 36)); - b0 -= b5; - - tmp = b3 ^ b6; - b3 = (tmp >> 49) | (tmp << (64 - 49)); - b6 -= b3; - - tmp = b1 ^ b4; - b1 = (tmp >> 17) | (tmp << (64 - 17)); - b4 -= b1; - - tmp = b3 ^ b0; - b3 = (tmp >> 42) | (tmp << (64 - 42)); - b0 -= b3; - - tmp = b5 ^ b6; - b5 = (tmp >> 14) | (tmp << (64 - 14)); - b6 -= b5; - - tmp = b7 ^ b4; - b7 = (tmp >> 27) | (tmp << (64 - 27)); - b4 -= b7; - - tmp = b1 ^ b2; - b1 = (tmp >> 33) | (tmp << (64 - 33)); - b2 -= b1; - - tmp = b7 ^ b6; - b7 = (tmp >> 37) | (tmp << (64 - 37)); - b6 -= b7 + k6 + t1; - b7 -= k7; - - tmp = b5 ^ b4; - b5 = (tmp >> 19) | (tmp << (64 - 19)); - b4 -= b5 + k4; - b5 -= k5 + t0; - - tmp = b3 ^ b2; - b3 = (tmp >> 36) | (tmp << (64 - 36)); - b2 -= b3 + k2; - b3 -= k3; - - tmp = b1 ^ b0; - b1 = (tmp >> 46) | (tmp << (64 - 46)); - b0 -= b1 + k0; - b1 -= k1; - - output[0] = b0; - output[1] = b1; - output[2] = b2; - output[3] = b3; - - output[7] = b7; - output[6] = b6; - output[5] = b5; - output[4] = b4; -} diff --git a/drivers/staging/skein/threefish_block.c b/drivers/staging/skein/threefish_block.c new file mode 100644 index 000000000000..bd1e15caae4e --- /dev/null +++ b/drivers/staging/skein/threefish_block.c @@ -0,0 +1,8258 @@ +#include "threefish_api.h" + +void threefish_encrypt_256(struct threefish_key *key_ctx, u64 *input, + u64 *output) +{ + u64 b0 = input[0], b1 = input[1], + b2 = input[2], b3 = input[3]; + u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], + k2 = key_ctx->key[2], k3 = key_ctx->key[3], + k4 = key_ctx->key[4]; + u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], + t2 = key_ctx->tweak[2]; + + b1 += k1 + t0; + b0 += b1 + k0; + b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + + b3 += k3; + b2 += b3 + k2 + t1; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + + b0 += b3; + b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + + b2 += b1; + b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + + b0 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + + b2 += b3; + b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + + b0 += b3; + b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + + b2 += b1; + b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + + b1 += k2 + t1; + b0 += b1 + k1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + + b3 += k4 + 1; + b2 += b3 + k3 + t2; + b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + + b0 += b3; + b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + + b2 += b1; + b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + + b0 += b1; + b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + + b2 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + + b0 += b3; + b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + + b2 += b1; + b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + + b1 += k3 + t2; + b0 += b1 + k2; + b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + + b3 += k0 + 2; + b2 += b3 + k4 + t0; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + + b0 += b3; + b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + + b2 += b1; + b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + + b0 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + + b2 += b3; + b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + + b0 += b3; + b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + + b2 += b1; + b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + + b1 += k4 + t0; + b0 += b1 + k3; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + + b3 += k1 + 3; + b2 += b3 + k0 + t1; + b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + + b0 += b3; + b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + + b2 += b1; + b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + + b0 += b1; + b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + + b2 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + + b0 += b3; + b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + + b2 += b1; + b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + + b1 += k0 + t1; + b0 += b1 + k4; + b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + + b3 += k2 + 4; + b2 += b3 + k1 + t2; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + + b0 += b3; + b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + + b2 += b1; + b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + + b0 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + + b2 += b3; + b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + + b0 += b3; + b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + + b2 += b1; + b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + + b1 += k1 + t2; + b0 += b1 + k0; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + + b3 += k3 + 5; + b2 += b3 + k2 + t0; + b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + + b0 += b3; + b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + + b2 += b1; + b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + + b0 += b1; + b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + + b2 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + + b0 += b3; + b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + + b2 += b1; + b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + + b1 += k2 + t0; + b0 += b1 + k1; + b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + + b3 += k4 + 6; + b2 += b3 + k3 + t1; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + + b0 += b3; + b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + + b2 += b1; + b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + + b0 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + + b2 += b3; + b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + + b0 += b3; + b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + + b2 += b1; + b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + + b1 += k3 + t1; + b0 += b1 + k2; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + + b3 += k0 + 7; + b2 += b3 + k4 + t2; + b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + + b0 += b3; + b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + + b2 += b1; + b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + + b0 += b1; + b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + + b2 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + + b0 += b3; + b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + + b2 += b1; + b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + + b1 += k4 + t2; + b0 += b1 + k3; + b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + + b3 += k1 + 8; + b2 += b3 + k0 + t0; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + + b0 += b3; + b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + + b2 += b1; + b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + + b0 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + + b2 += b3; + b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + + b0 += b3; + b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + + b2 += b1; + b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + + b1 += k0 + t0; + b0 += b1 + k4; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + + b3 += k2 + 9; + b2 += b3 + k1 + t1; + b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + + b0 += b3; + b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + + b2 += b1; + b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + + b0 += b1; + b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + + b2 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + + b0 += b3; + b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + + b2 += b1; + b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + + b1 += k1 + t1; + b0 += b1 + k0; + b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + + b3 += k3 + 10; + b2 += b3 + k2 + t2; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + + b0 += b3; + b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + + b2 += b1; + b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + + b0 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + + b2 += b3; + b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + + b0 += b3; + b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + + b2 += b1; + b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + + b1 += k2 + t2; + b0 += b1 + k1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + + b3 += k4 + 11; + b2 += b3 + k3 + t0; + b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + + b0 += b3; + b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + + b2 += b1; + b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + + b0 += b1; + b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + + b2 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + + b0 += b3; + b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + + b2 += b1; + b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + + b1 += k3 + t0; + b0 += b1 + k2; + b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + + b3 += k0 + 12; + b2 += b3 + k4 + t1; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + + b0 += b3; + b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + + b2 += b1; + b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + + b0 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + + b2 += b3; + b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + + b0 += b3; + b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + + b2 += b1; + b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + + b1 += k4 + t1; + b0 += b1 + k3; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + + b3 += k1 + 13; + b2 += b3 + k0 + t2; + b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + + b0 += b3; + b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + + b2 += b1; + b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + + b0 += b1; + b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + + b2 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + + b0 += b3; + b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + + b2 += b1; + b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + + b1 += k0 + t2; + b0 += b1 + k4; + b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + + b3 += k2 + 14; + b2 += b3 + k1 + t0; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + + b0 += b3; + b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + + b2 += b1; + b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + + b0 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + + b2 += b3; + b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + + b0 += b3; + b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + + b2 += b1; + b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + + b1 += k1 + t0; + b0 += b1 + k0; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + + b3 += k3 + 15; + b2 += b3 + k2 + t1; + b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + + b0 += b3; + b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + + b2 += b1; + b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + + b0 += b1; + b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + + b2 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + + b0 += b3; + b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + + b2 += b1; + b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + + b1 += k2 + t1; + b0 += b1 + k1; + b1 = ((b1 << 14) | (b1 >> (64 - 14))) ^ b0; + + b3 += k4 + 16; + b2 += b3 + k3 + t2; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b2; + + b0 += b3; + b3 = ((b3 << 52) | (b3 >> (64 - 52))) ^ b0; + + b2 += b1; + b1 = ((b1 << 57) | (b1 >> (64 - 57))) ^ b2; + + b0 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b0; + + b2 += b3; + b3 = ((b3 << 40) | (b3 >> (64 - 40))) ^ b2; + + b0 += b3; + b3 = ((b3 << 5) | (b3 >> (64 - 5))) ^ b0; + + b2 += b1; + b1 = ((b1 << 37) | (b1 >> (64 - 37))) ^ b2; + + b1 += k3 + t2; + b0 += b1 + k2; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b0; + + b3 += k0 + 17; + b2 += b3 + k4 + t0; + b3 = ((b3 << 33) | (b3 >> (64 - 33))) ^ b2; + + b0 += b3; + b3 = ((b3 << 46) | (b3 >> (64 - 46))) ^ b0; + + b2 += b1; + b1 = ((b1 << 12) | (b1 >> (64 - 12))) ^ b2; + + b0 += b1; + b1 = ((b1 << 58) | (b1 >> (64 - 58))) ^ b0; + + b2 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b2; + + b0 += b3; + b3 = ((b3 << 32) | (b3 >> (64 - 32))) ^ b0; + + b2 += b1; + b1 = ((b1 << 32) | (b1 >> (64 - 32))) ^ b2; + + output[0] = b0 + k3; + output[1] = b1 + k4 + t0; + output[2] = b2 + k0 + t1; + output[3] = b3 + k1 + 18; +} + +void threefish_decrypt_256(struct threefish_key *key_ctx, u64 *input, + u64 *output) +{ + u64 b0 = input[0], b1 = input[1], + b2 = input[2], b3 = input[3]; + u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], + k2 = key_ctx->key[2], k3 = key_ctx->key[3], + k4 = key_ctx->key[4]; + u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], + t2 = key_ctx->tweak[2]; + + u64 tmp; + + b0 -= k3; + b1 -= k4 + t0; + b2 -= k0 + t1; + b3 -= k1 + 18; + tmp = b3 ^ b0; + b3 = (tmp >> 32) | (tmp << (64 - 32)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 32) | (tmp << (64 - 32)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 58) | (tmp << (64 - 58)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 12) | (tmp << (64 - 12)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b0 -= b1 + k2; + b1 -= k3 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b3 + k4 + t0; + b3 -= k0 + 17; + + tmp = b3 ^ b0; + b3 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 37) | (tmp << (64 - 37)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 40) | (tmp << (64 - 40)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 52) | (tmp << (64 - 52)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 57) | (tmp << (64 - 57)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 14) | (tmp << (64 - 14)); + b0 -= b1 + k1; + b1 -= k2 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b2 -= b3 + k3 + t2; + b3 -= k4 + 16; + + + tmp = b3 ^ b0; + b3 = (tmp >> 32) | (tmp << (64 - 32)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 32) | (tmp << (64 - 32)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 58) | (tmp << (64 - 58)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 12) | (tmp << (64 - 12)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b0 -= b1 + k0; + b1 -= k1 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b3 + k2 + t1; + b3 -= k3 + 15; + + tmp = b3 ^ b0; + b3 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 37) | (tmp << (64 - 37)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 40) | (tmp << (64 - 40)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 52) | (tmp << (64 - 52)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 57) | (tmp << (64 - 57)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 14) | (tmp << (64 - 14)); + b0 -= b1 + k4; + b1 -= k0 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b2 -= b3 + k1 + t0; + b3 -= k2 + 14; + + + tmp = b3 ^ b0; + b3 = (tmp >> 32) | (tmp << (64 - 32)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 32) | (tmp << (64 - 32)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 58) | (tmp << (64 - 58)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 12) | (tmp << (64 - 12)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b0 -= b1 + k3; + b1 -= k4 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b3 + k0 + t2; + b3 -= k1 + 13; + + tmp = b3 ^ b0; + b3 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 37) | (tmp << (64 - 37)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 40) | (tmp << (64 - 40)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 52) | (tmp << (64 - 52)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 57) | (tmp << (64 - 57)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 14) | (tmp << (64 - 14)); + b0 -= b1 + k2; + b1 -= k3 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b2 -= b3 + k4 + t1; + b3 -= k0 + 12; + + + tmp = b3 ^ b0; + b3 = (tmp >> 32) | (tmp << (64 - 32)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 32) | (tmp << (64 - 32)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 58) | (tmp << (64 - 58)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 12) | (tmp << (64 - 12)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b0 -= b1 + k1; + b1 -= k2 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b3 + k3 + t0; + b3 -= k4 + 11; + + tmp = b3 ^ b0; + b3 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 37) | (tmp << (64 - 37)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 40) | (tmp << (64 - 40)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 52) | (tmp << (64 - 52)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 57) | (tmp << (64 - 57)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 14) | (tmp << (64 - 14)); + b0 -= b1 + k0; + b1 -= k1 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b2 -= b3 + k2 + t2; + b3 -= k3 + 10; + + + tmp = b3 ^ b0; + b3 = (tmp >> 32) | (tmp << (64 - 32)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 32) | (tmp << (64 - 32)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 58) | (tmp << (64 - 58)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 12) | (tmp << (64 - 12)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b0 -= b1 + k4; + b1 -= k0 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b3 + k1 + t1; + b3 -= k2 + 9; + + tmp = b3 ^ b0; + b3 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 37) | (tmp << (64 - 37)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 40) | (tmp << (64 - 40)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 52) | (tmp << (64 - 52)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 57) | (tmp << (64 - 57)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 14) | (tmp << (64 - 14)); + b0 -= b1 + k3; + b1 -= k4 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b2 -= b3 + k0 + t0; + b3 -= k1 + 8; + + + tmp = b3 ^ b0; + b3 = (tmp >> 32) | (tmp << (64 - 32)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 32) | (tmp << (64 - 32)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 58) | (tmp << (64 - 58)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 12) | (tmp << (64 - 12)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b0 -= b1 + k2; + b1 -= k3 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b3 + k4 + t2; + b3 -= k0 + 7; + + tmp = b3 ^ b0; + b3 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 37) | (tmp << (64 - 37)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 40) | (tmp << (64 - 40)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 52) | (tmp << (64 - 52)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 57) | (tmp << (64 - 57)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 14) | (tmp << (64 - 14)); + b0 -= b1 + k1; + b1 -= k2 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b2 -= b3 + k3 + t1; + b3 -= k4 + 6; + + + tmp = b3 ^ b0; + b3 = (tmp >> 32) | (tmp << (64 - 32)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 32) | (tmp << (64 - 32)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 58) | (tmp << (64 - 58)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 12) | (tmp << (64 - 12)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b0 -= b1 + k0; + b1 -= k1 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b3 + k2 + t0; + b3 -= k3 + 5; + + tmp = b3 ^ b0; + b3 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 37) | (tmp << (64 - 37)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 40) | (tmp << (64 - 40)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 52) | (tmp << (64 - 52)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 57) | (tmp << (64 - 57)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 14) | (tmp << (64 - 14)); + b0 -= b1 + k4; + b1 -= k0 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b2 -= b3 + k1 + t2; + b3 -= k2 + 4; + + + tmp = b3 ^ b0; + b3 = (tmp >> 32) | (tmp << (64 - 32)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 32) | (tmp << (64 - 32)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 58) | (tmp << (64 - 58)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 12) | (tmp << (64 - 12)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b0 -= b1 + k3; + b1 -= k4 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b3 + k0 + t1; + b3 -= k1 + 3; + + tmp = b3 ^ b0; + b3 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 37) | (tmp << (64 - 37)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 40) | (tmp << (64 - 40)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 52) | (tmp << (64 - 52)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 57) | (tmp << (64 - 57)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 14) | (tmp << (64 - 14)); + b0 -= b1 + k2; + b1 -= k3 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b2 -= b3 + k4 + t0; + b3 -= k0 + 2; + + + tmp = b3 ^ b0; + b3 = (tmp >> 32) | (tmp << (64 - 32)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 32) | (tmp << (64 - 32)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 58) | (tmp << (64 - 58)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 12) | (tmp << (64 - 12)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b0 -= b1 + k1; + b1 -= k2 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b3 + k3 + t2; + b3 -= k4 + 1; + + tmp = b3 ^ b0; + b3 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 37) | (tmp << (64 - 37)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b0 -= b1; + + tmp = b3 ^ b2; + b3 = (tmp >> 40) | (tmp << (64 - 40)); + b2 -= b3; + + tmp = b3 ^ b0; + b3 = (tmp >> 52) | (tmp << (64 - 52)); + b0 -= b3; + + tmp = b1 ^ b2; + b1 = (tmp >> 57) | (tmp << (64 - 57)); + b2 -= b1; + + tmp = b1 ^ b0; + b1 = (tmp >> 14) | (tmp << (64 - 14)); + b0 -= b1 + k0; + b1 -= k1 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b2 -= b3 + k2 + t1; + b3 -= k3; + + output[0] = b0; + output[1] = b1; + output[2] = b2; + output[3] = b3; +} + +void threefish_encrypt_512(struct threefish_key *key_ctx, u64 *input, + u64 *output) +{ + u64 b0 = input[0], b1 = input[1], + b2 = input[2], b3 = input[3], + b4 = input[4], b5 = input[5], + b6 = input[6], b7 = input[7]; + u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], + k2 = key_ctx->key[2], k3 = key_ctx->key[3], + k4 = key_ctx->key[4], k5 = key_ctx->key[5], + k6 = key_ctx->key[6], k7 = key_ctx->key[7], + k8 = key_ctx->key[8]; + u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], + t2 = key_ctx->tweak[2]; + + b1 += k1; + b0 += b1 + k0; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + + b3 += k3; + b2 += b3 + k2; + b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + + b5 += k5 + t0; + b4 += b5 + k4; + b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + + b7 += k7; + b6 += b7 + k6 + t1; + b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + + b2 += b1; + b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + + b4 += b7; + b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + + b6 += b5; + b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + + b0 += b3; + b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + + b4 += b1; + b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + + b6 += b3; + b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + + b0 += b5; + b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + + b2 += b7; + b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + + b6 += b1; + b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + + b0 += b7; + b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + + b2 += b5; + b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + + b4 += b3; + b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + + b1 += k2; + b0 += b1 + k1; + b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + + b3 += k4; + b2 += b3 + k3; + b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + + b5 += k6 + t1; + b4 += b5 + k5; + b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + + b7 += k8 + 1; + b6 += b7 + k7 + t2; + b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + + b2 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + + b4 += b7; + b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + + b6 += b5; + b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + + b0 += b3; + b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + + b4 += b1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + + b6 += b3; + b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + + b0 += b5; + b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + + b2 += b7; + b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + + b6 += b1; + b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + + b0 += b7; + b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + + b2 += b5; + b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + + b4 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + + b1 += k3; + b0 += b1 + k2; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + + b3 += k5; + b2 += b3 + k4; + b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + + b5 += k7 + t2; + b4 += b5 + k6; + b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + + b7 += k0 + 2; + b6 += b7 + k8 + t0; + b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + + b2 += b1; + b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + + b4 += b7; + b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + + b6 += b5; + b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + + b0 += b3; + b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + + b4 += b1; + b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + + b6 += b3; + b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + + b0 += b5; + b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + + b2 += b7; + b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + + b6 += b1; + b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + + b0 += b7; + b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + + b2 += b5; + b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + + b4 += b3; + b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + + b1 += k4; + b0 += b1 + k3; + b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + + b3 += k6; + b2 += b3 + k5; + b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + + b5 += k8 + t0; + b4 += b5 + k7; + b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + + b7 += k1 + 3; + b6 += b7 + k0 + t1; + b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + + b2 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + + b4 += b7; + b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + + b6 += b5; + b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + + b0 += b3; + b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + + b4 += b1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + + b6 += b3; + b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + + b0 += b5; + b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + + b2 += b7; + b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + + b6 += b1; + b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + + b0 += b7; + b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + + b2 += b5; + b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + + b4 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + + b1 += k5; + b0 += b1 + k4; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + + b3 += k7; + b2 += b3 + k6; + b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + + b5 += k0 + t1; + b4 += b5 + k8; + b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + + b7 += k2 + 4; + b6 += b7 + k1 + t2; + b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + + b2 += b1; + b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + + b4 += b7; + b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + + b6 += b5; + b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + + b0 += b3; + b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + + b4 += b1; + b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + + b6 += b3; + b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + + b0 += b5; + b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + + b2 += b7; + b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + + b6 += b1; + b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + + b0 += b7; + b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + + b2 += b5; + b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + + b4 += b3; + b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + + b1 += k6; + b0 += b1 + k5; + b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + + b3 += k8; + b2 += b3 + k7; + b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + + b5 += k1 + t2; + b4 += b5 + k0; + b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + + b7 += k3 + 5; + b6 += b7 + k2 + t0; + b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + + b2 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + + b4 += b7; + b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + + b6 += b5; + b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + + b0 += b3; + b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + + b4 += b1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + + b6 += b3; + b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + + b0 += b5; + b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + + b2 += b7; + b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + + b6 += b1; + b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + + b0 += b7; + b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + + b2 += b5; + b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + + b4 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + + b1 += k7; + b0 += b1 + k6; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + + b3 += k0; + b2 += b3 + k8; + b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + + b5 += k2 + t0; + b4 += b5 + k1; + b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + + b7 += k4 + 6; + b6 += b7 + k3 + t1; + b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + + b2 += b1; + b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + + b4 += b7; + b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + + b6 += b5; + b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + + b0 += b3; + b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + + b4 += b1; + b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + + b6 += b3; + b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + + b0 += b5; + b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + + b2 += b7; + b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + + b6 += b1; + b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + + b0 += b7; + b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + + b2 += b5; + b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + + b4 += b3; + b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + + b1 += k8; + b0 += b1 + k7; + b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + + b3 += k1; + b2 += b3 + k0; + b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + + b5 += k3 + t1; + b4 += b5 + k2; + b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + + b7 += k5 + 7; + b6 += b7 + k4 + t2; + b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + + b2 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + + b4 += b7; + b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + + b6 += b5; + b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + + b0 += b3; + b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + + b4 += b1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + + b6 += b3; + b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + + b0 += b5; + b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + + b2 += b7; + b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + + b6 += b1; + b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + + b0 += b7; + b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + + b2 += b5; + b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + + b4 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + + b1 += k0; + b0 += b1 + k8; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + + b3 += k2; + b2 += b3 + k1; + b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + + b5 += k4 + t2; + b4 += b5 + k3; + b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + + b7 += k6 + 8; + b6 += b7 + k5 + t0; + b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + + b2 += b1; + b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + + b4 += b7; + b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + + b6 += b5; + b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + + b0 += b3; + b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + + b4 += b1; + b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + + b6 += b3; + b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + + b0 += b5; + b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + + b2 += b7; + b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + + b6 += b1; + b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + + b0 += b7; + b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + + b2 += b5; + b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + + b4 += b3; + b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + + b1 += k1; + b0 += b1 + k0; + b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + + b3 += k3; + b2 += b3 + k2; + b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + + b5 += k5 + t0; + b4 += b5 + k4; + b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + + b7 += k7 + 9; + b6 += b7 + k6 + t1; + b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + + b2 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + + b4 += b7; + b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + + b6 += b5; + b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + + b0 += b3; + b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + + b4 += b1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + + b6 += b3; + b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + + b0 += b5; + b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + + b2 += b7; + b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + + b6 += b1; + b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + + b0 += b7; + b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + + b2 += b5; + b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + + b4 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + + b1 += k2; + b0 += b1 + k1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + + b3 += k4; + b2 += b3 + k3; + b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + + b5 += k6 + t1; + b4 += b5 + k5; + b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + + b7 += k8 + 10; + b6 += b7 + k7 + t2; + b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + + b2 += b1; + b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + + b4 += b7; + b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + + b6 += b5; + b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + + b0 += b3; + b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + + b4 += b1; + b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + + b6 += b3; + b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + + b0 += b5; + b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + + b2 += b7; + b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + + b6 += b1; + b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + + b0 += b7; + b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + + b2 += b5; + b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + + b4 += b3; + b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + + b1 += k3; + b0 += b1 + k2; + b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + + b3 += k5; + b2 += b3 + k4; + b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + + b5 += k7 + t2; + b4 += b5 + k6; + b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + + b7 += k0 + 11; + b6 += b7 + k8 + t0; + b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + + b2 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + + b4 += b7; + b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + + b6 += b5; + b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + + b0 += b3; + b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + + b4 += b1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + + b6 += b3; + b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + + b0 += b5; + b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + + b2 += b7; + b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + + b6 += b1; + b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + + b0 += b7; + b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + + b2 += b5; + b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + + b4 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + + b1 += k4; + b0 += b1 + k3; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + + b3 += k6; + b2 += b3 + k5; + b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + + b5 += k8 + t0; + b4 += b5 + k7; + b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + + b7 += k1 + 12; + b6 += b7 + k0 + t1; + b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + + b2 += b1; + b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + + b4 += b7; + b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + + b6 += b5; + b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + + b0 += b3; + b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + + b4 += b1; + b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + + b6 += b3; + b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + + b0 += b5; + b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + + b2 += b7; + b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + + b6 += b1; + b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + + b0 += b7; + b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + + b2 += b5; + b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + + b4 += b3; + b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + + b1 += k5; + b0 += b1 + k4; + b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + + b3 += k7; + b2 += b3 + k6; + b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + + b5 += k0 + t1; + b4 += b5 + k8; + b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + + b7 += k2 + 13; + b6 += b7 + k1 + t2; + b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + + b2 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + + b4 += b7; + b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + + b6 += b5; + b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + + b0 += b3; + b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + + b4 += b1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + + b6 += b3; + b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + + b0 += b5; + b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + + b2 += b7; + b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + + b6 += b1; + b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + + b0 += b7; + b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + + b2 += b5; + b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + + b4 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + + b1 += k6; + b0 += b1 + k5; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + + b3 += k8; + b2 += b3 + k7; + b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + + b5 += k1 + t2; + b4 += b5 + k0; + b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + + b7 += k3 + 14; + b6 += b7 + k2 + t0; + b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + + b2 += b1; + b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + + b4 += b7; + b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + + b6 += b5; + b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + + b0 += b3; + b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + + b4 += b1; + b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + + b6 += b3; + b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + + b0 += b5; + b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + + b2 += b7; + b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + + b6 += b1; + b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + + b0 += b7; + b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + + b2 += b5; + b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + + b4 += b3; + b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + + b1 += k7; + b0 += b1 + k6; + b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + + b3 += k0; + b2 += b3 + k8; + b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + + b5 += k2 + t0; + b4 += b5 + k1; + b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + + b7 += k4 + 15; + b6 += b7 + k3 + t1; + b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + + b2 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + + b4 += b7; + b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + + b6 += b5; + b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + + b0 += b3; + b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + + b4 += b1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + + b6 += b3; + b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + + b0 += b5; + b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + + b2 += b7; + b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + + b6 += b1; + b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + + b0 += b7; + b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + + b2 += b5; + b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + + b4 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + + b1 += k8; + b0 += b1 + k7; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b0; + + b3 += k1; + b2 += b3 + k0; + b3 = ((b3 << 36) | (b3 >> (64 - 36))) ^ b2; + + b5 += k3 + t1; + b4 += b5 + k2; + b5 = ((b5 << 19) | (b5 >> (64 - 19))) ^ b4; + + b7 += k5 + 16; + b6 += b7 + k4 + t2; + b7 = ((b7 << 37) | (b7 >> (64 - 37))) ^ b6; + + b2 += b1; + b1 = ((b1 << 33) | (b1 >> (64 - 33))) ^ b2; + + b4 += b7; + b7 = ((b7 << 27) | (b7 >> (64 - 27))) ^ b4; + + b6 += b5; + b5 = ((b5 << 14) | (b5 >> (64 - 14))) ^ b6; + + b0 += b3; + b3 = ((b3 << 42) | (b3 >> (64 - 42))) ^ b0; + + b4 += b1; + b1 = ((b1 << 17) | (b1 >> (64 - 17))) ^ b4; + + b6 += b3; + b3 = ((b3 << 49) | (b3 >> (64 - 49))) ^ b6; + + b0 += b5; + b5 = ((b5 << 36) | (b5 >> (64 - 36))) ^ b0; + + b2 += b7; + b7 = ((b7 << 39) | (b7 >> (64 - 39))) ^ b2; + + b6 += b1; + b1 = ((b1 << 44) | (b1 >> (64 - 44))) ^ b6; + + b0 += b7; + b7 = ((b7 << 9) | (b7 >> (64 - 9))) ^ b0; + + b2 += b5; + b5 = ((b5 << 54) | (b5 >> (64 - 54))) ^ b2; + + b4 += b3; + b3 = ((b3 << 56) | (b3 >> (64 - 56))) ^ b4; + + b1 += k0; + b0 += b1 + k8; + b1 = ((b1 << 39) | (b1 >> (64 - 39))) ^ b0; + + b3 += k2; + b2 += b3 + k1; + b3 = ((b3 << 30) | (b3 >> (64 - 30))) ^ b2; + + b5 += k4 + t2; + b4 += b5 + k3; + b5 = ((b5 << 34) | (b5 >> (64 - 34))) ^ b4; + + b7 += k6 + 17; + b6 += b7 + k5 + t0; + b7 = ((b7 << 24) | (b7 >> (64 - 24))) ^ b6; + + b2 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b2; + + b4 += b7; + b7 = ((b7 << 50) | (b7 >> (64 - 50))) ^ b4; + + b6 += b5; + b5 = ((b5 << 10) | (b5 >> (64 - 10))) ^ b6; + + b0 += b3; + b3 = ((b3 << 17) | (b3 >> (64 - 17))) ^ b0; + + b4 += b1; + b1 = ((b1 << 25) | (b1 >> (64 - 25))) ^ b4; + + b6 += b3; + b3 = ((b3 << 29) | (b3 >> (64 - 29))) ^ b6; + + b0 += b5; + b5 = ((b5 << 39) | (b5 >> (64 - 39))) ^ b0; + + b2 += b7; + b7 = ((b7 << 43) | (b7 >> (64 - 43))) ^ b2; + + b6 += b1; + b1 = ((b1 << 8) | (b1 >> (64 - 8))) ^ b6; + + b0 += b7; + b7 = ((b7 << 35) | (b7 >> (64 - 35))) ^ b0; + + b2 += b5; + b5 = ((b5 << 56) | (b5 >> (64 - 56))) ^ b2; + + b4 += b3; + b3 = ((b3 << 22) | (b3 >> (64 - 22))) ^ b4; + + output[0] = b0 + k0; + output[1] = b1 + k1; + output[2] = b2 + k2; + output[3] = b3 + k3; + output[4] = b4 + k4; + output[5] = b5 + k5 + t0; + output[6] = b6 + k6 + t1; + output[7] = b7 + k7 + 18; +} + +void threefish_decrypt_512(struct threefish_key *key_ctx, u64 *input, + u64 *output) +{ + u64 b0 = input[0], b1 = input[1], + b2 = input[2], b3 = input[3], + b4 = input[4], b5 = input[5], + b6 = input[6], b7 = input[7]; + u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], + k2 = key_ctx->key[2], k3 = key_ctx->key[3], + k4 = key_ctx->key[4], k5 = key_ctx->key[5], + k6 = key_ctx->key[6], k7 = key_ctx->key[7], + k8 = key_ctx->key[8]; + u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], + t2 = key_ctx->tweak[2]; + + u64 tmp; + + b0 -= k0; + b1 -= k1; + b2 -= k2; + b3 -= k3; + b4 -= k4; + b5 -= k5 + t0; + b6 -= k6 + t1; + b7 -= k7 + 18; + + tmp = b3 ^ b4; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 56) | (tmp << (64 - 56)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 35) | (tmp << (64 - 35)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 8) | (tmp << (64 - 8)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 43) | (tmp << (64 - 43)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 29) | (tmp << (64 - 29)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 17) | (tmp << (64 - 17)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 50) | (tmp << (64 - 50)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 24) | (tmp << (64 - 24)); + b6 -= b7 + k5 + t0; + b7 -= k6 + 17; + + tmp = b5 ^ b4; + b5 = (tmp >> 34) | (tmp << (64 - 34)); + b4 -= b5 + k3; + b5 -= k4 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 30) | (tmp << (64 - 30)); + b2 -= b3 + k1; + b3 -= k2; + + tmp = b1 ^ b0; + b1 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b1 + k8; + b1 -= k0; + + tmp = b3 ^ b4; + b3 = (tmp >> 56) | (tmp << (64 - 56)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 54) | (tmp << (64 - 54)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 44) | (tmp << (64 - 44)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 39) | (tmp << (64 - 39)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 36) | (tmp << (64 - 36)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 49) | (tmp << (64 - 49)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 17) | (tmp << (64 - 17)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 42) | (tmp << (64 - 42)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 14) | (tmp << (64 - 14)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 27) | (tmp << (64 - 27)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 37) | (tmp << (64 - 37)); + b6 -= b7 + k4 + t2; + b7 -= k5 + 16; + + tmp = b5 ^ b4; + b5 = (tmp >> 19) | (tmp << (64 - 19)); + b4 -= b5 + k2; + b5 -= k3 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 36) | (tmp << (64 - 36)); + b2 -= b3 + k0; + b3 -= k1; + + tmp = b1 ^ b0; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b1 + k7; + b1 -= k8; + + tmp = b3 ^ b4; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 56) | (tmp << (64 - 56)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 35) | (tmp << (64 - 35)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 8) | (tmp << (64 - 8)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 43) | (tmp << (64 - 43)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 29) | (tmp << (64 - 29)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 17) | (tmp << (64 - 17)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 50) | (tmp << (64 - 50)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 24) | (tmp << (64 - 24)); + b6 -= b7 + k3 + t1; + b7 -= k4 + 15; + + tmp = b5 ^ b4; + b5 = (tmp >> 34) | (tmp << (64 - 34)); + b4 -= b5 + k1; + b5 -= k2 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 30) | (tmp << (64 - 30)); + b2 -= b3 + k8; + b3 -= k0; + + tmp = b1 ^ b0; + b1 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b1 + k6; + b1 -= k7; + + tmp = b3 ^ b4; + b3 = (tmp >> 56) | (tmp << (64 - 56)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 54) | (tmp << (64 - 54)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 44) | (tmp << (64 - 44)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 39) | (tmp << (64 - 39)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 36) | (tmp << (64 - 36)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 49) | (tmp << (64 - 49)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 17) | (tmp << (64 - 17)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 42) | (tmp << (64 - 42)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 14) | (tmp << (64 - 14)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 27) | (tmp << (64 - 27)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 37) | (tmp << (64 - 37)); + b6 -= b7 + k2 + t0; + b7 -= k3 + 14; + + tmp = b5 ^ b4; + b5 = (tmp >> 19) | (tmp << (64 - 19)); + b4 -= b5 + k0; + b5 -= k1 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 36) | (tmp << (64 - 36)); + b2 -= b3 + k7; + b3 -= k8; + + tmp = b1 ^ b0; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b1 + k5; + b1 -= k6; + + tmp = b3 ^ b4; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 56) | (tmp << (64 - 56)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 35) | (tmp << (64 - 35)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 8) | (tmp << (64 - 8)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 43) | (tmp << (64 - 43)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 29) | (tmp << (64 - 29)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 17) | (tmp << (64 - 17)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 50) | (tmp << (64 - 50)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 24) | (tmp << (64 - 24)); + b6 -= b7 + k1 + t2; + b7 -= k2 + 13; + + tmp = b5 ^ b4; + b5 = (tmp >> 34) | (tmp << (64 - 34)); + b4 -= b5 + k8; + b5 -= k0 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 30) | (tmp << (64 - 30)); + b2 -= b3 + k6; + b3 -= k7; + + tmp = b1 ^ b0; + b1 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b1 + k4; + b1 -= k5; + + tmp = b3 ^ b4; + b3 = (tmp >> 56) | (tmp << (64 - 56)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 54) | (tmp << (64 - 54)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 44) | (tmp << (64 - 44)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 39) | (tmp << (64 - 39)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 36) | (tmp << (64 - 36)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 49) | (tmp << (64 - 49)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 17) | (tmp << (64 - 17)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 42) | (tmp << (64 - 42)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 14) | (tmp << (64 - 14)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 27) | (tmp << (64 - 27)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 37) | (tmp << (64 - 37)); + b6 -= b7 + k0 + t1; + b7 -= k1 + 12; + + tmp = b5 ^ b4; + b5 = (tmp >> 19) | (tmp << (64 - 19)); + b4 -= b5 + k7; + b5 -= k8 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 36) | (tmp << (64 - 36)); + b2 -= b3 + k5; + b3 -= k6; + + tmp = b1 ^ b0; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b1 + k3; + b1 -= k4; + + tmp = b3 ^ b4; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 56) | (tmp << (64 - 56)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 35) | (tmp << (64 - 35)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 8) | (tmp << (64 - 8)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 43) | (tmp << (64 - 43)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 29) | (tmp << (64 - 29)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 17) | (tmp << (64 - 17)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 50) | (tmp << (64 - 50)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 24) | (tmp << (64 - 24)); + b6 -= b7 + k8 + t0; + b7 -= k0 + 11; + + tmp = b5 ^ b4; + b5 = (tmp >> 34) | (tmp << (64 - 34)); + b4 -= b5 + k6; + b5 -= k7 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 30) | (tmp << (64 - 30)); + b2 -= b3 + k4; + b3 -= k5; + + tmp = b1 ^ b0; + b1 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b1 + k2; + b1 -= k3; + + tmp = b3 ^ b4; + b3 = (tmp >> 56) | (tmp << (64 - 56)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 54) | (tmp << (64 - 54)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 44) | (tmp << (64 - 44)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 39) | (tmp << (64 - 39)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 36) | (tmp << (64 - 36)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 49) | (tmp << (64 - 49)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 17) | (tmp << (64 - 17)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 42) | (tmp << (64 - 42)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 14) | (tmp << (64 - 14)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 27) | (tmp << (64 - 27)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 37) | (tmp << (64 - 37)); + b6 -= b7 + k7 + t2; + b7 -= k8 + 10; + + tmp = b5 ^ b4; + b5 = (tmp >> 19) | (tmp << (64 - 19)); + b4 -= b5 + k5; + b5 -= k6 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 36) | (tmp << (64 - 36)); + b2 -= b3 + k3; + b3 -= k4; + + tmp = b1 ^ b0; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b1 + k1; + b1 -= k2; + + tmp = b3 ^ b4; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 56) | (tmp << (64 - 56)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 35) | (tmp << (64 - 35)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 8) | (tmp << (64 - 8)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 43) | (tmp << (64 - 43)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 29) | (tmp << (64 - 29)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 17) | (tmp << (64 - 17)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 50) | (tmp << (64 - 50)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 24) | (tmp << (64 - 24)); + b6 -= b7 + k6 + t1; + b7 -= k7 + 9; + + tmp = b5 ^ b4; + b5 = (tmp >> 34) | (tmp << (64 - 34)); + b4 -= b5 + k4; + b5 -= k5 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 30) | (tmp << (64 - 30)); + b2 -= b3 + k2; + b3 -= k3; + + tmp = b1 ^ b0; + b1 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b1 + k0; + b1 -= k1; + + tmp = b3 ^ b4; + b3 = (tmp >> 56) | (tmp << (64 - 56)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 54) | (tmp << (64 - 54)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 44) | (tmp << (64 - 44)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 39) | (tmp << (64 - 39)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 36) | (tmp << (64 - 36)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 49) | (tmp << (64 - 49)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 17) | (tmp << (64 - 17)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 42) | (tmp << (64 - 42)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 14) | (tmp << (64 - 14)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 27) | (tmp << (64 - 27)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 37) | (tmp << (64 - 37)); + b6 -= b7 + k5 + t0; + b7 -= k6 + 8; + + tmp = b5 ^ b4; + b5 = (tmp >> 19) | (tmp << (64 - 19)); + b4 -= b5 + k3; + b5 -= k4 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 36) | (tmp << (64 - 36)); + b2 -= b3 + k1; + b3 -= k2; + + tmp = b1 ^ b0; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b1 + k8; + b1 -= k0; + + tmp = b3 ^ b4; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 56) | (tmp << (64 - 56)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 35) | (tmp << (64 - 35)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 8) | (tmp << (64 - 8)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 43) | (tmp << (64 - 43)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 29) | (tmp << (64 - 29)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 17) | (tmp << (64 - 17)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 50) | (tmp << (64 - 50)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 24) | (tmp << (64 - 24)); + b6 -= b7 + k4 + t2; + b7 -= k5 + 7; + + tmp = b5 ^ b4; + b5 = (tmp >> 34) | (tmp << (64 - 34)); + b4 -= b5 + k2; + b5 -= k3 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 30) | (tmp << (64 - 30)); + b2 -= b3 + k0; + b3 -= k1; + + tmp = b1 ^ b0; + b1 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b1 + k7; + b1 -= k8; + + tmp = b3 ^ b4; + b3 = (tmp >> 56) | (tmp << (64 - 56)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 54) | (tmp << (64 - 54)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 44) | (tmp << (64 - 44)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 39) | (tmp << (64 - 39)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 36) | (tmp << (64 - 36)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 49) | (tmp << (64 - 49)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 17) | (tmp << (64 - 17)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 42) | (tmp << (64 - 42)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 14) | (tmp << (64 - 14)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 27) | (tmp << (64 - 27)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 37) | (tmp << (64 - 37)); + b6 -= b7 + k3 + t1; + b7 -= k4 + 6; + + tmp = b5 ^ b4; + b5 = (tmp >> 19) | (tmp << (64 - 19)); + b4 -= b5 + k1; + b5 -= k2 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 36) | (tmp << (64 - 36)); + b2 -= b3 + k8; + b3 -= k0; + + tmp = b1 ^ b0; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b1 + k6; + b1 -= k7; + + tmp = b3 ^ b4; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 56) | (tmp << (64 - 56)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 35) | (tmp << (64 - 35)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 8) | (tmp << (64 - 8)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 43) | (tmp << (64 - 43)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 29) | (tmp << (64 - 29)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 17) | (tmp << (64 - 17)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 50) | (tmp << (64 - 50)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 24) | (tmp << (64 - 24)); + b6 -= b7 + k2 + t0; + b7 -= k3 + 5; + + tmp = b5 ^ b4; + b5 = (tmp >> 34) | (tmp << (64 - 34)); + b4 -= b5 + k0; + b5 -= k1 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 30) | (tmp << (64 - 30)); + b2 -= b3 + k7; + b3 -= k8; + + tmp = b1 ^ b0; + b1 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b1 + k5; + b1 -= k6; + + tmp = b3 ^ b4; + b3 = (tmp >> 56) | (tmp << (64 - 56)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 54) | (tmp << (64 - 54)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 44) | (tmp << (64 - 44)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 39) | (tmp << (64 - 39)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 36) | (tmp << (64 - 36)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 49) | (tmp << (64 - 49)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 17) | (tmp << (64 - 17)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 42) | (tmp << (64 - 42)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 14) | (tmp << (64 - 14)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 27) | (tmp << (64 - 27)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 37) | (tmp << (64 - 37)); + b6 -= b7 + k1 + t2; + b7 -= k2 + 4; + + tmp = b5 ^ b4; + b5 = (tmp >> 19) | (tmp << (64 - 19)); + b4 -= b5 + k8; + b5 -= k0 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 36) | (tmp << (64 - 36)); + b2 -= b3 + k6; + b3 -= k7; + + tmp = b1 ^ b0; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b1 + k4; + b1 -= k5; + + tmp = b3 ^ b4; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 56) | (tmp << (64 - 56)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 35) | (tmp << (64 - 35)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 8) | (tmp << (64 - 8)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 43) | (tmp << (64 - 43)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 29) | (tmp << (64 - 29)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 17) | (tmp << (64 - 17)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 50) | (tmp << (64 - 50)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 24) | (tmp << (64 - 24)); + b6 -= b7 + k0 + t1; + b7 -= k1 + 3; + + tmp = b5 ^ b4; + b5 = (tmp >> 34) | (tmp << (64 - 34)); + b4 -= b5 + k7; + b5 -= k8 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 30) | (tmp << (64 - 30)); + b2 -= b3 + k5; + b3 -= k6; + + tmp = b1 ^ b0; + b1 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b1 + k3; + b1 -= k4; + + tmp = b3 ^ b4; + b3 = (tmp >> 56) | (tmp << (64 - 56)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 54) | (tmp << (64 - 54)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 44) | (tmp << (64 - 44)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 39) | (tmp << (64 - 39)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 36) | (tmp << (64 - 36)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 49) | (tmp << (64 - 49)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 17) | (tmp << (64 - 17)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 42) | (tmp << (64 - 42)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 14) | (tmp << (64 - 14)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 27) | (tmp << (64 - 27)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 37) | (tmp << (64 - 37)); + b6 -= b7 + k8 + t0; + b7 -= k0 + 2; + + tmp = b5 ^ b4; + b5 = (tmp >> 19) | (tmp << (64 - 19)); + b4 -= b5 + k6; + b5 -= k7 + t2; + + tmp = b3 ^ b2; + b3 = (tmp >> 36) | (tmp << (64 - 36)); + b2 -= b3 + k4; + b3 -= k5; + + tmp = b1 ^ b0; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b1 + k2; + b1 -= k3; + + tmp = b3 ^ b4; + b3 = (tmp >> 22) | (tmp << (64 - 22)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 56) | (tmp << (64 - 56)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 35) | (tmp << (64 - 35)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 8) | (tmp << (64 - 8)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 43) | (tmp << (64 - 43)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 29) | (tmp << (64 - 29)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 25) | (tmp << (64 - 25)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 17) | (tmp << (64 - 17)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 50) | (tmp << (64 - 50)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 24) | (tmp << (64 - 24)); + b6 -= b7 + k7 + t2; + b7 -= k8 + 1; + + tmp = b5 ^ b4; + b5 = (tmp >> 34) | (tmp << (64 - 34)); + b4 -= b5 + k5; + b5 -= k6 + t1; + + tmp = b3 ^ b2; + b3 = (tmp >> 30) | (tmp << (64 - 30)); + b2 -= b3 + k3; + b3 -= k4; + + tmp = b1 ^ b0; + b1 = (tmp >> 39) | (tmp << (64 - 39)); + b0 -= b1 + k1; + b1 -= k2; + + tmp = b3 ^ b4; + b3 = (tmp >> 56) | (tmp << (64 - 56)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 54) | (tmp << (64 - 54)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b7; + + tmp = b1 ^ b6; + b1 = (tmp >> 44) | (tmp << (64 - 44)); + b6 -= b1; + + tmp = b7 ^ b2; + b7 = (tmp >> 39) | (tmp << (64 - 39)); + b2 -= b7; + + tmp = b5 ^ b0; + b5 = (tmp >> 36) | (tmp << (64 - 36)); + b0 -= b5; + + tmp = b3 ^ b6; + b3 = (tmp >> 49) | (tmp << (64 - 49)); + b6 -= b3; + + tmp = b1 ^ b4; + b1 = (tmp >> 17) | (tmp << (64 - 17)); + b4 -= b1; + + tmp = b3 ^ b0; + b3 = (tmp >> 42) | (tmp << (64 - 42)); + b0 -= b3; + + tmp = b5 ^ b6; + b5 = (tmp >> 14) | (tmp << (64 - 14)); + b6 -= b5; + + tmp = b7 ^ b4; + b7 = (tmp >> 27) | (tmp << (64 - 27)); + b4 -= b7; + + tmp = b1 ^ b2; + b1 = (tmp >> 33) | (tmp << (64 - 33)); + b2 -= b1; + + tmp = b7 ^ b6; + b7 = (tmp >> 37) | (tmp << (64 - 37)); + b6 -= b7 + k6 + t1; + b7 -= k7; + + tmp = b5 ^ b4; + b5 = (tmp >> 19) | (tmp << (64 - 19)); + b4 -= b5 + k4; + b5 -= k5 + t0; + + tmp = b3 ^ b2; + b3 = (tmp >> 36) | (tmp << (64 - 36)); + b2 -= b3 + k2; + b3 -= k3; + + tmp = b1 ^ b0; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b0 -= b1 + k0; + b1 -= k1; + + output[0] = b0; + output[1] = b1; + output[2] = b2; + output[3] = b3; + + output[7] = b7; + output[6] = b6; + output[5] = b5; + output[4] = b4; +} + +void threefish_encrypt_1024(struct threefish_key *key_ctx, u64 *input, + u64 *output) +{ + u64 b0 = input[0], b1 = input[1], + b2 = input[2], b3 = input[3], + b4 = input[4], b5 = input[5], + b6 = input[6], b7 = input[7], + b8 = input[8], b9 = input[9], + b10 = input[10], b11 = input[11], + b12 = input[12], b13 = input[13], + b14 = input[14], b15 = input[15]; + u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], + k2 = key_ctx->key[2], k3 = key_ctx->key[3], + k4 = key_ctx->key[4], k5 = key_ctx->key[5], + k6 = key_ctx->key[6], k7 = key_ctx->key[7], + k8 = key_ctx->key[8], k9 = key_ctx->key[9], + k10 = key_ctx->key[10], k11 = key_ctx->key[11], + k12 = key_ctx->key[12], k13 = key_ctx->key[13], + k14 = key_ctx->key[14], k15 = key_ctx->key[15], + k16 = key_ctx->key[16]; + u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], + t2 = key_ctx->tweak[2]; + + b1 += k1; + b0 += b1 + k0; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k3; + b2 += b3 + k2; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k5; + b4 += b5 + k4; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k7; + b6 += b7 + k6; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k9; + b8 += b9 + k8; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k11; + b10 += b11 + k10; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k13 + t0; + b12 += b13 + k12; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k15; + b14 += b15 + k14 + t1; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k2; + b0 += b1 + k1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k4; + b2 += b3 + k3; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k6; + b4 += b5 + k5; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k8; + b6 += b7 + k7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k10; + b8 += b9 + k9; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k12; + b10 += b11 + k11; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k14 + t1; + b12 += b13 + k13; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k16 + 1; + b14 += b15 + k15 + t2; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + b1 += k3; + b0 += b1 + k2; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k5; + b2 += b3 + k4; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k7; + b4 += b5 + k6; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k9; + b6 += b7 + k8; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k11; + b8 += b9 + k10; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k13; + b10 += b11 + k12; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k15 + t2; + b12 += b13 + k14; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k0 + 2; + b14 += b15 + k16 + t0; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k4; + b0 += b1 + k3; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k6; + b2 += b3 + k5; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k8; + b4 += b5 + k7; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k10; + b6 += b7 + k9; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k12; + b8 += b9 + k11; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k14; + b10 += b11 + k13; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k16 + t0; + b12 += b13 + k15; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k1 + 3; + b14 += b15 + k0 + t1; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + b1 += k5; + b0 += b1 + k4; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k7; + b2 += b3 + k6; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k9; + b4 += b5 + k8; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k11; + b6 += b7 + k10; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k13; + b8 += b9 + k12; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k15; + b10 += b11 + k14; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k0 + t1; + b12 += b13 + k16; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k2 + 4; + b14 += b15 + k1 + t2; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k6; + b0 += b1 + k5; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k8; + b2 += b3 + k7; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k10; + b4 += b5 + k9; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k12; + b6 += b7 + k11; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k14; + b8 += b9 + k13; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k16; + b10 += b11 + k15; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k1 + t2; + b12 += b13 + k0; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k3 + 5; + b14 += b15 + k2 + t0; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + b1 += k7; + b0 += b1 + k6; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k9; + b2 += b3 + k8; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k11; + b4 += b5 + k10; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k13; + b6 += b7 + k12; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k15; + b8 += b9 + k14; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k0; + b10 += b11 + k16; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k2 + t0; + b12 += b13 + k1; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k4 + 6; + b14 += b15 + k3 + t1; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k8; + b0 += b1 + k7; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k10; + b2 += b3 + k9; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k12; + b4 += b5 + k11; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k14; + b6 += b7 + k13; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k16; + b8 += b9 + k15; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k1; + b10 += b11 + k0; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k3 + t1; + b12 += b13 + k2; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k5 + 7; + b14 += b15 + k4 + t2; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + b1 += k9; + b0 += b1 + k8; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k11; + b2 += b3 + k10; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k13; + b4 += b5 + k12; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k15; + b6 += b7 + k14; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k0; + b8 += b9 + k16; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k2; + b10 += b11 + k1; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k4 + t2; + b12 += b13 + k3; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k6 + 8; + b14 += b15 + k5 + t0; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k10; + b0 += b1 + k9; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k12; + b2 += b3 + k11; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k14; + b4 += b5 + k13; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k16; + b6 += b7 + k15; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k1; + b8 += b9 + k0; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k3; + b10 += b11 + k2; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k5 + t0; + b12 += b13 + k4; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k7 + 9; + b14 += b15 + k6 + t1; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + b1 += k11; + b0 += b1 + k10; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k13; + b2 += b3 + k12; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k15; + b4 += b5 + k14; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k0; + b6 += b7 + k16; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k2; + b8 += b9 + k1; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k4; + b10 += b11 + k3; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k6 + t1; + b12 += b13 + k5; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k8 + 10; + b14 += b15 + k7 + t2; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k12; + b0 += b1 + k11; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k14; + b2 += b3 + k13; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k16; + b4 += b5 + k15; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k1; + b6 += b7 + k0; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k3; + b8 += b9 + k2; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k5; + b10 += b11 + k4; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k7 + t2; + b12 += b13 + k6; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k9 + 11; + b14 += b15 + k8 + t0; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + b1 += k13; + b0 += b1 + k12; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k15; + b2 += b3 + k14; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k0; + b4 += b5 + k16; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k2; + b6 += b7 + k1; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k4; + b8 += b9 + k3; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k6; + b10 += b11 + k5; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k8 + t0; + b12 += b13 + k7; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k10 + 12; + b14 += b15 + k9 + t1; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k14; + b0 += b1 + k13; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k16; + b2 += b3 + k15; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k1; + b4 += b5 + k0; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k3; + b6 += b7 + k2; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k5; + b8 += b9 + k4; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k7; + b10 += b11 + k6; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k9 + t1; + b12 += b13 + k8; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k11 + 13; + b14 += b15 + k10 + t2; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + b1 += k15; + b0 += b1 + k14; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k0; + b2 += b3 + k16; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k2; + b4 += b5 + k1; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k4; + b6 += b7 + k3; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k6; + b8 += b9 + k5; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k8; + b10 += b11 + k7; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k10 + t2; + b12 += b13 + k9; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k12 + 14; + b14 += b15 + k11 + t0; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k16; + b0 += b1 + k15; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k1; + b2 += b3 + k0; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k3; + b4 += b5 + k2; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k5; + b6 += b7 + k4; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k7; + b8 += b9 + k6; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k9; + b10 += b11 + k8; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k11 + t0; + b12 += b13 + k10; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k13 + 15; + b14 += b15 + k12 + t1; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + b1 += k0; + b0 += b1 + k16; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k2; + b2 += b3 + k1; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k4; + b4 += b5 + k3; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k6; + b6 += b7 + k5; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k8; + b8 += b9 + k7; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k10; + b10 += b11 + k9; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k12 + t1; + b12 += b13 + k11; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k14 + 16; + b14 += b15 + k13 + t2; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k1; + b0 += b1 + k0; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k3; + b2 += b3 + k2; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k5; + b4 += b5 + k4; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k7; + b6 += b7 + k6; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k9; + b8 += b9 + k8; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k11; + b10 += b11 + k10; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k13 + t2; + b12 += b13 + k12; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k15 + 17; + b14 += b15 + k14 + t0; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + b1 += k2; + b0 += b1 + k1; + b1 = ((b1 << 24) | (b1 >> (64 - 24))) ^ b0; + + b3 += k4; + b2 += b3 + k3; + b3 = ((b3 << 13) | (b3 >> (64 - 13))) ^ b2; + + b5 += k6; + b4 += b5 + k5; + b5 = ((b5 << 8) | (b5 >> (64 - 8))) ^ b4; + + b7 += k8; + b6 += b7 + k7; + b7 = ((b7 << 47) | (b7 >> (64 - 47))) ^ b6; + + b9 += k10; + b8 += b9 + k9; + b9 = ((b9 << 8) | (b9 >> (64 - 8))) ^ b8; + + b11 += k12; + b10 += b11 + k11; + b11 = ((b11 << 17) | (b11 >> (64 - 17))) ^ b10; + + b13 += k14 + t0; + b12 += b13 + k13; + b13 = ((b13 << 22) | (b13 >> (64 - 22))) ^ b12; + + b15 += k16 + 18; + b14 += b15 + k15 + t1; + b15 = ((b15 << 37) | (b15 >> (64 - 37))) ^ b14; + + b0 += b9; + b9 = ((b9 << 38) | (b9 >> (64 - 38))) ^ b0; + + b2 += b13; + b13 = ((b13 << 19) | (b13 >> (64 - 19))) ^ b2; + + b6 += b11; + b11 = ((b11 << 10) | (b11 >> (64 - 10))) ^ b6; + + b4 += b15; + b15 = ((b15 << 55) | (b15 >> (64 - 55))) ^ b4; + + b10 += b7; + b7 = ((b7 << 49) | (b7 >> (64 - 49))) ^ b10; + + b12 += b3; + b3 = ((b3 << 18) | (b3 >> (64 - 18))) ^ b12; + + b14 += b5; + b5 = ((b5 << 23) | (b5 >> (64 - 23))) ^ b14; + + b8 += b1; + b1 = ((b1 << 52) | (b1 >> (64 - 52))) ^ b8; + + b0 += b7; + b7 = ((b7 << 33) | (b7 >> (64 - 33))) ^ b0; + + b2 += b5; + b5 = ((b5 << 4) | (b5 >> (64 - 4))) ^ b2; + + b4 += b3; + b3 = ((b3 << 51) | (b3 >> (64 - 51))) ^ b4; + + b6 += b1; + b1 = ((b1 << 13) | (b1 >> (64 - 13))) ^ b6; + + b12 += b15; + b15 = ((b15 << 34) | (b15 >> (64 - 34))) ^ b12; + + b14 += b13; + b13 = ((b13 << 41) | (b13 >> (64 - 41))) ^ b14; + + b8 += b11; + b11 = ((b11 << 59) | (b11 >> (64 - 59))) ^ b8; + + b10 += b9; + b9 = ((b9 << 17) | (b9 >> (64 - 17))) ^ b10; + + b0 += b15; + b15 = ((b15 << 5) | (b15 >> (64 - 5))) ^ b0; + + b2 += b11; + b11 = ((b11 << 20) | (b11 >> (64 - 20))) ^ b2; + + b6 += b13; + b13 = ((b13 << 48) | (b13 >> (64 - 48))) ^ b6; + + b4 += b9; + b9 = ((b9 << 41) | (b9 >> (64 - 41))) ^ b4; + + b14 += b1; + b1 = ((b1 << 47) | (b1 >> (64 - 47))) ^ b14; + + b8 += b5; + b5 = ((b5 << 28) | (b5 >> (64 - 28))) ^ b8; + + b10 += b3; + b3 = ((b3 << 16) | (b3 >> (64 - 16))) ^ b10; + + b12 += b7; + b7 = ((b7 << 25) | (b7 >> (64 - 25))) ^ b12; + + b1 += k3; + b0 += b1 + k2; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b0; + + b3 += k5; + b2 += b3 + k4; + b3 = ((b3 << 9) | (b3 >> (64 - 9))) ^ b2; + + b5 += k7; + b4 += b5 + k6; + b5 = ((b5 << 37) | (b5 >> (64 - 37))) ^ b4; + + b7 += k9; + b6 += b7 + k8; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b6; + + b9 += k11; + b8 += b9 + k10; + b9 = ((b9 << 12) | (b9 >> (64 - 12))) ^ b8; + + b11 += k13; + b10 += b11 + k12; + b11 = ((b11 << 47) | (b11 >> (64 - 47))) ^ b10; + + b13 += k15 + t1; + b12 += b13 + k14; + b13 = ((b13 << 44) | (b13 >> (64 - 44))) ^ b12; + + b15 += k0 + 19; + b14 += b15 + k16 + t2; + b15 = ((b15 << 30) | (b15 >> (64 - 30))) ^ b14; + + b0 += b9; + b9 = ((b9 << 16) | (b9 >> (64 - 16))) ^ b0; + + b2 += b13; + b13 = ((b13 << 34) | (b13 >> (64 - 34))) ^ b2; + + b6 += b11; + b11 = ((b11 << 56) | (b11 >> (64 - 56))) ^ b6; + + b4 += b15; + b15 = ((b15 << 51) | (b15 >> (64 - 51))) ^ b4; + + b10 += b7; + b7 = ((b7 << 4) | (b7 >> (64 - 4))) ^ b10; + + b12 += b3; + b3 = ((b3 << 53) | (b3 >> (64 - 53))) ^ b12; + + b14 += b5; + b5 = ((b5 << 42) | (b5 >> (64 - 42))) ^ b14; + + b8 += b1; + b1 = ((b1 << 41) | (b1 >> (64 - 41))) ^ b8; + + b0 += b7; + b7 = ((b7 << 31) | (b7 >> (64 - 31))) ^ b0; + + b2 += b5; + b5 = ((b5 << 44) | (b5 >> (64 - 44))) ^ b2; + + b4 += b3; + b3 = ((b3 << 47) | (b3 >> (64 - 47))) ^ b4; + + b6 += b1; + b1 = ((b1 << 46) | (b1 >> (64 - 46))) ^ b6; + + b12 += b15; + b15 = ((b15 << 19) | (b15 >> (64 - 19))) ^ b12; + + b14 += b13; + b13 = ((b13 << 42) | (b13 >> (64 - 42))) ^ b14; + + b8 += b11; + b11 = ((b11 << 44) | (b11 >> (64 - 44))) ^ b8; + + b10 += b9; + b9 = ((b9 << 25) | (b9 >> (64 - 25))) ^ b10; + + b0 += b15; + b15 = ((b15 << 9) | (b15 >> (64 - 9))) ^ b0; + + b2 += b11; + b11 = ((b11 << 48) | (b11 >> (64 - 48))) ^ b2; + + b6 += b13; + b13 = ((b13 << 35) | (b13 >> (64 - 35))) ^ b6; + + b4 += b9; + b9 = ((b9 << 52) | (b9 >> (64 - 52))) ^ b4; + + b14 += b1; + b1 = ((b1 << 23) | (b1 >> (64 - 23))) ^ b14; + + b8 += b5; + b5 = ((b5 << 31) | (b5 >> (64 - 31))) ^ b8; + + b10 += b3; + b3 = ((b3 << 37) | (b3 >> (64 - 37))) ^ b10; + + b12 += b7; + b7 = ((b7 << 20) | (b7 >> (64 - 20))) ^ b12; + + output[0] = b0 + k3; + output[1] = b1 + k4; + output[2] = b2 + k5; + output[3] = b3 + k6; + output[4] = b4 + k7; + output[5] = b5 + k8; + output[6] = b6 + k9; + output[7] = b7 + k10; + output[8] = b8 + k11; + output[9] = b9 + k12; + output[10] = b10 + k13; + output[11] = b11 + k14; + output[12] = b12 + k15; + output[13] = b13 + k16 + t2; + output[14] = b14 + k0 + t0; + output[15] = b15 + k1 + 20; +} + +void threefish_decrypt_1024(struct threefish_key *key_ctx, u64 *input, + u64 *output) +{ + u64 b0 = input[0], b1 = input[1], + b2 = input[2], b3 = input[3], + b4 = input[4], b5 = input[5], + b6 = input[6], b7 = input[7], + b8 = input[8], b9 = input[9], + b10 = input[10], b11 = input[11], + b12 = input[12], b13 = input[13], + b14 = input[14], b15 = input[15]; + u64 k0 = key_ctx->key[0], k1 = key_ctx->key[1], + k2 = key_ctx->key[2], k3 = key_ctx->key[3], + k4 = key_ctx->key[4], k5 = key_ctx->key[5], + k6 = key_ctx->key[6], k7 = key_ctx->key[7], + k8 = key_ctx->key[8], k9 = key_ctx->key[9], + k10 = key_ctx->key[10], k11 = key_ctx->key[11], + k12 = key_ctx->key[12], k13 = key_ctx->key[13], + k14 = key_ctx->key[14], k15 = key_ctx->key[15], + k16 = key_ctx->key[16]; + u64 t0 = key_ctx->tweak[0], t1 = key_ctx->tweak[1], + t2 = key_ctx->tweak[2]; + u64 tmp; + + b0 -= k3; + b1 -= k4; + b2 -= k5; + b3 -= k6; + b4 -= k7; + b5 -= k8; + b6 -= k9; + b7 -= k10; + b8 -= k11; + b9 -= k12; + b10 -= k13; + b11 -= k14; + b12 -= k15; + b13 -= k16 + t2; + b14 -= k0 + t0; + b15 -= k1 + 20; + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k16 + t2; + b15 -= k0 + 19; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k14; + b13 -= k15 + t1; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k12; + b11 -= k13; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k10; + b9 -= k11; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k8; + b7 -= k9; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k6; + b5 -= k7; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k4; + b3 -= k5; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k2; + b1 -= k3; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k15 + t1; + b15 -= k16 + 18; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k13; + b13 -= k14 + t0; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k11; + b11 -= k12; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k9; + b9 -= k10; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k7; + b7 -= k8; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k5; + b5 -= k6; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k3; + b3 -= k4; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k1; + b1 -= k2; + + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k14 + t0; + b15 -= k15 + 17; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k12; + b13 -= k13 + t2; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k10; + b11 -= k11; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k8; + b9 -= k9; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k6; + b7 -= k7; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k4; + b5 -= k5; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k2; + b3 -= k3; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k0; + b1 -= k1; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k13 + t2; + b15 -= k14 + 16; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k11; + b13 -= k12 + t1; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k9; + b11 -= k10; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k7; + b9 -= k8; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k5; + b7 -= k6; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k3; + b5 -= k4; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k1; + b3 -= k2; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k16; + b1 -= k0; + + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k12 + t1; + b15 -= k13 + 15; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k10; + b13 -= k11 + t0; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k8; + b11 -= k9; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k6; + b9 -= k7; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k4; + b7 -= k5; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k2; + b5 -= k3; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k0; + b3 -= k1; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k15; + b1 -= k16; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k11 + t0; + b15 -= k12 + 14; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k9; + b13 -= k10 + t2; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k7; + b11 -= k8; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k5; + b9 -= k6; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k3; + b7 -= k4; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k1; + b5 -= k2; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k16; + b3 -= k0; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k14; + b1 -= k15; + + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k10 + t2; + b15 -= k11 + 13; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k8; + b13 -= k9 + t1; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k6; + b11 -= k7; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k4; + b9 -= k5; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k2; + b7 -= k3; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k0; + b5 -= k1; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k15; + b3 -= k16; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k13; + b1 -= k14; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k9 + t1; + b15 -= k10 + 12; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k7; + b13 -= k8 + t0; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k5; + b11 -= k6; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k3; + b9 -= k4; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k1; + b7 -= k2; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k16; + b5 -= k0; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k14; + b3 -= k15; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k12; + b1 -= k13; + + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k8 + t0; + b15 -= k9 + 11; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k6; + b13 -= k7 + t2; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k4; + b11 -= k5; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k2; + b9 -= k3; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k0; + b7 -= k1; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k15; + b5 -= k16; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k13; + b3 -= k14; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k11; + b1 -= k12; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k7 + t2; + b15 -= k8 + 10; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k5; + b13 -= k6 + t1; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k3; + b11 -= k4; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k1; + b9 -= k2; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k16; + b7 -= k0; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k14; + b5 -= k15; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k12; + b3 -= k13; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k10; + b1 -= k11; + + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k6 + t1; + b15 -= k7 + 9; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k4; + b13 -= k5 + t0; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k2; + b11 -= k3; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k0; + b9 -= k1; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k15; + b7 -= k16; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k13; + b5 -= k14; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k11; + b3 -= k12; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k9; + b1 -= k10; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k5 + t0; + b15 -= k6 + 8; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k3; + b13 -= k4 + t2; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k1; + b11 -= k2; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k16; + b9 -= k0; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k14; + b7 -= k15; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k12; + b5 -= k13; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k10; + b3 -= k11; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k8; + b1 -= k9; + + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k4 + t2; + b15 -= k5 + 7; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k2; + b13 -= k3 + t1; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k0; + b11 -= k1; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k15; + b9 -= k16; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k13; + b7 -= k14; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k11; + b5 -= k12; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k9; + b3 -= k10; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k7; + b1 -= k8; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k3 + t1; + b15 -= k4 + 6; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k1; + b13 -= k2 + t0; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k16; + b11 -= k0; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k14; + b9 -= k15; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k12; + b7 -= k13; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k10; + b5 -= k11; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k8; + b3 -= k9; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k6; + b1 -= k7; + + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k2 + t0; + b15 -= k3 + 5; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k0; + b13 -= k1 + t2; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k15; + b11 -= k16; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k13; + b9 -= k14; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k11; + b7 -= k12; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k9; + b5 -= k10; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k7; + b3 -= k8; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k5; + b1 -= k6; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k1 + t2; + b15 -= k2 + 4; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k16; + b13 -= k0 + t1; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k14; + b11 -= k15; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k12; + b9 -= k13; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k10; + b7 -= k11; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k8; + b5 -= k9; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k6; + b3 -= k7; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k4; + b1 -= k5; + + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k0 + t1; + b15 -= k1 + 3; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k15; + b13 -= k16 + t0; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k13; + b11 -= k14; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k11; + b9 -= k12; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k9; + b7 -= k10; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k7; + b5 -= k8; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k5; + b3 -= k6; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k3; + b1 -= k4; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k16 + t0; + b15 -= k0 + 2; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k14; + b13 -= k15 + t2; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k12; + b11 -= k13; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k10; + b9 -= k11; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k8; + b7 -= k9; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k6; + b5 -= k7; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k4; + b3 -= k5; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k2; + b1 -= k3; + + tmp = b7 ^ b12; + b7 = (tmp >> 20) | (tmp << (64 - 20)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 37) | (tmp << (64 - 37)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 31) | (tmp << (64 - 31)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 52) | (tmp << (64 - 52)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 35) | (tmp << (64 - 35)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 48) | (tmp << (64 - 48)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 9) | (tmp << (64 - 9)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 25) | (tmp << (64 - 25)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 44) | (tmp << (64 - 44)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 19) | (tmp << (64 - 19)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 46) | (tmp << (64 - 46)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 47) | (tmp << (64 - 47)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 44) | (tmp << (64 - 44)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 42) | (tmp << (64 - 42)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 53) | (tmp << (64 - 53)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 4) | (tmp << (64 - 4)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 56) | (tmp << (64 - 56)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 34) | (tmp << (64 - 34)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 16) | (tmp << (64 - 16)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 30) | (tmp << (64 - 30)); + b14 -= b15 + k15 + t2; + b15 -= k16 + 1; + + tmp = b13 ^ b12; + b13 = (tmp >> 44) | (tmp << (64 - 44)); + b12 -= b13 + k13; + b13 -= k14 + t1; + + tmp = b11 ^ b10; + b11 = (tmp >> 47) | (tmp << (64 - 47)); + b10 -= b11 + k11; + b11 -= k12; + + tmp = b9 ^ b8; + b9 = (tmp >> 12) | (tmp << (64 - 12)); + b8 -= b9 + k9; + b9 -= k10; + + tmp = b7 ^ b6; + b7 = (tmp >> 31) | (tmp << (64 - 31)); + b6 -= b7 + k7; + b7 -= k8; + + tmp = b5 ^ b4; + b5 = (tmp >> 37) | (tmp << (64 - 37)); + b4 -= b5 + k5; + b5 -= k6; + + tmp = b3 ^ b2; + b3 = (tmp >> 9) | (tmp << (64 - 9)); + b2 -= b3 + k3; + b3 -= k4; + + tmp = b1 ^ b0; + b1 = (tmp >> 41) | (tmp << (64 - 41)); + b0 -= b1 + k1; + b1 -= k2; + + tmp = b7 ^ b12; + b7 = (tmp >> 25) | (tmp << (64 - 25)); + b12 -= b7; + + tmp = b3 ^ b10; + b3 = (tmp >> 16) | (tmp << (64 - 16)); + b10 -= b3; + + tmp = b5 ^ b8; + b5 = (tmp >> 28) | (tmp << (64 - 28)); + b8 -= b5; + + tmp = b1 ^ b14; + b1 = (tmp >> 47) | (tmp << (64 - 47)); + b14 -= b1; + + tmp = b9 ^ b4; + b9 = (tmp >> 41) | (tmp << (64 - 41)); + b4 -= b9; + + tmp = b13 ^ b6; + b13 = (tmp >> 48) | (tmp << (64 - 48)); + b6 -= b13; + + tmp = b11 ^ b2; + b11 = (tmp >> 20) | (tmp << (64 - 20)); + b2 -= b11; + + tmp = b15 ^ b0; + b15 = (tmp >> 5) | (tmp << (64 - 5)); + b0 -= b15; + + tmp = b9 ^ b10; + b9 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b9; + + tmp = b11 ^ b8; + b11 = (tmp >> 59) | (tmp << (64 - 59)); + b8 -= b11; + + tmp = b13 ^ b14; + b13 = (tmp >> 41) | (tmp << (64 - 41)); + b14 -= b13; + + tmp = b15 ^ b12; + b15 = (tmp >> 34) | (tmp << (64 - 34)); + b12 -= b15; + + tmp = b1 ^ b6; + b1 = (tmp >> 13) | (tmp << (64 - 13)); + b6 -= b1; + + tmp = b3 ^ b4; + b3 = (tmp >> 51) | (tmp << (64 - 51)); + b4 -= b3; + + tmp = b5 ^ b2; + b5 = (tmp >> 4) | (tmp << (64 - 4)); + b2 -= b5; + + tmp = b7 ^ b0; + b7 = (tmp >> 33) | (tmp << (64 - 33)); + b0 -= b7; + + tmp = b1 ^ b8; + b1 = (tmp >> 52) | (tmp << (64 - 52)); + b8 -= b1; + + tmp = b5 ^ b14; + b5 = (tmp >> 23) | (tmp << (64 - 23)); + b14 -= b5; + + tmp = b3 ^ b12; + b3 = (tmp >> 18) | (tmp << (64 - 18)); + b12 -= b3; + + tmp = b7 ^ b10; + b7 = (tmp >> 49) | (tmp << (64 - 49)); + b10 -= b7; + + tmp = b15 ^ b4; + b15 = (tmp >> 55) | (tmp << (64 - 55)); + b4 -= b15; + + tmp = b11 ^ b6; + b11 = (tmp >> 10) | (tmp << (64 - 10)); + b6 -= b11; + + tmp = b13 ^ b2; + b13 = (tmp >> 19) | (tmp << (64 - 19)); + b2 -= b13; + + tmp = b9 ^ b0; + b9 = (tmp >> 38) | (tmp << (64 - 38)); + b0 -= b9; + + tmp = b15 ^ b14; + b15 = (tmp >> 37) | (tmp << (64 - 37)); + b14 -= b15 + k14 + t1; + b15 -= k15; + + tmp = b13 ^ b12; + b13 = (tmp >> 22) | (tmp << (64 - 22)); + b12 -= b13 + k12; + b13 -= k13 + t0; + + tmp = b11 ^ b10; + b11 = (tmp >> 17) | (tmp << (64 - 17)); + b10 -= b11 + k10; + b11 -= k11; + + tmp = b9 ^ b8; + b9 = (tmp >> 8) | (tmp << (64 - 8)); + b8 -= b9 + k8; + b9 -= k9; + + tmp = b7 ^ b6; + b7 = (tmp >> 47) | (tmp << (64 - 47)); + b6 -= b7 + k6; + b7 -= k7; + + tmp = b5 ^ b4; + b5 = (tmp >> 8) | (tmp << (64 - 8)); + b4 -= b5 + k4; + b5 -= k5; + + tmp = b3 ^ b2; + b3 = (tmp >> 13) | (tmp << (64 - 13)); + b2 -= b3 + k2; + b3 -= k3; + + tmp = b1 ^ b0; + b1 = (tmp >> 24) | (tmp << (64 - 24)); + b0 -= b1 + k0; + b1 -= k1; + + output[15] = b15; + output[14] = b14; + output[13] = b13; + output[12] = b12; + output[11] = b11; + output[10] = b10; + output[9] = b9; + output[8] = b8; + output[7] = b7; + output[6] = b6; + output[5] = b5; + output[4] = b4; + output[3] = b3; + output[2] = b2; + output[1] = b1; + output[0] = b0; +} -- cgit v1.2.3 From a82100e78cdf099f6c36fc4b0e2dc1b7d558f1db Mon Sep 17 00:00:00 2001 From: Jake Edge Date: Tue, 20 May 2014 08:00:33 -0600 Subject: staging/skein: comment typos fix some comment typos Signed-off-by: Jake Edge Acked-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/threefish_api.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/skein/threefish_api.h b/drivers/staging/skein/threefish_api.h index 2fce154b59e5..8d5ddf8b3a9b 100644 --- a/drivers/staging/skein/threefish_api.h +++ b/drivers/staging/skein/threefish_api.h @@ -12,7 +12,7 @@ * follow the openSSL design but at the same time take care of some Threefish * specific behaviour and possibilities. * - * These are the low level functions that deal with Threefisch blocks only. + * These are the low level functions that deal with Threefish blocks only. * Implementations for cipher modes such as ECB, CFB, or CBC may use these * functions. * @@ -77,9 +77,9 @@ void threefish_set_key(struct threefish_key *key_ctx, u64 *key_data, u64 *tweak); /** - * Encrypt Threefisch block (bytes). + * Encrypt Threefish block (bytes). * - * The buffer must have at least the same length (number of bits) aas the + * The buffer must have at least the same length (number of bits) as the * state size for this key. The function uses the first @c state_size bits * of the input buffer, encrypts them and stores the result in the output * buffer. @@ -95,9 +95,9 @@ void threefish_encrypt_block_bytes(struct threefish_key *key_ctx, u8 *in, u8 *out); /** - * Encrypt Threefisch block (words). + * Encrypt Threefish block (words). * - * The buffer must have at least the same length (number of bits) aas the + * The buffer must have at least the same length (number of bits) as the * state size for this key. The function uses the first @c state_size bits * of the input buffer, encrypts them and stores the result in the output * buffer. @@ -115,9 +115,9 @@ void threefish_encrypt_block_words(struct threefish_key *key_ctx, u64 *in, u64 *out); /** - * Decrypt Threefisch block (bytes). + * Decrypt Threefish block (bytes). * - * The buffer must have at least the same length (number of bits) aas the + * The buffer must have at least the same length (number of bits) as the * state size for this key. The function uses the first @c state_size bits * of the input buffer, decrypts them and stores the result in the output * buffer @@ -133,9 +133,9 @@ void threefish_decrypt_block_bytes(struct threefish_key *key_ctx, u8 *in, u8 *out); /** - * Decrypt Threefisch block (words). + * Decrypt Threefish block (words). * - * The buffer must have at least the same length (number of bits) aas the + * The buffer must have at least the same length (number of bits) as the * state size for this key. The function uses the first @c state_size bits * of the input buffer, encrypts them and stores the result in the output * buffer. -- cgit v1.2.3 From 007dfe5ad6d039df784b44285bae89654eab3258 Mon Sep 17 00:00:00 2001 From: Jake Edge Date: Tue, 20 May 2014 08:02:28 -0600 Subject: staging/skein: variable/member name cleanup Rename a few more variables and structure member names to lower case. Signed-off-by: Jake Edge Acked-by: Jason Cooper Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/skein.c | 148 +++++++++++++++++----------------- drivers/staging/skein/skein.h | 34 ++++---- drivers/staging/skein/skein_api.c | 32 ++++---- drivers/staging/skein/skein_api.h | 2 +- drivers/staging/skein/skein_block.c | 155 ++++++++++++++++++------------------ 5 files changed, 186 insertions(+), 185 deletions(-) diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c index f76d5850c7dd..8cc83587b1f1 100644 --- a/drivers/staging/skein/skein.c +++ b/drivers/staging/skein/skein.c @@ -33,16 +33,16 @@ int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len) switch (hash_bit_len) { /* use pre-computed values, where available */ case 256: - memcpy(ctx->X, SKEIN_256_IV_256, sizeof(ctx->X)); + memcpy(ctx->x, SKEIN_256_IV_256, sizeof(ctx->x)); break; case 224: - memcpy(ctx->X, SKEIN_256_IV_224, sizeof(ctx->X)); + memcpy(ctx->x, SKEIN_256_IV_224, sizeof(ctx->x)); break; case 160: - memcpy(ctx->X, SKEIN_256_IV_160, sizeof(ctx->X)); + memcpy(ctx->x, SKEIN_256_IV_160, sizeof(ctx->x)); break; case 128: - memcpy(ctx->X, SKEIN_256_IV_128, sizeof(ctx->X)); + memcpy(ctx->x, SKEIN_256_IV_128, sizeof(ctx->x)); break; default: /* here if there is no precomputed IV value available */ @@ -63,11 +63,11 @@ int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len) /* compute the initial chaining values from config block */ /* zero the chaining variables */ - memset(ctx->X, 0, sizeof(ctx->X)); + memset(ctx->x, 0, sizeof(ctx->x)); skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); break; } - /* The chaining vars ctx->X are now initialized for hash_bit_len. */ + /* The chaining vars ctx->x are now initialized for hash_bit_len. */ /* Set up to process the data message portion of the hash (default) */ skein_start_new_type(ctx, MSG); /* T0=0, T1= MSG type */ @@ -89,25 +89,25 @@ int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hash_bit_len, skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); skein_assert_ret(key_bytes == 0 || key != NULL, SKEIN_FAIL); - /* compute the initial chaining values ctx->X[], based on key */ + /* compute the initial chaining values ctx->x[], based on key */ if (key_bytes == 0) { /* is there a key? */ /* no key: use all zeroes as key for config block */ - memset(ctx->X, 0, sizeof(ctx->X)); + memset(ctx->x, 0, sizeof(ctx->x)); } else { /* here to pre-process a key */ - skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); + skein_assert(sizeof(cfg.b) >= sizeof(ctx->x)); /* do a mini-Init right here */ /* set output hash bit count = state size */ - ctx->h.hash_bit_len = 8*sizeof(ctx->X); + ctx->h.hash_bit_len = 8*sizeof(ctx->x); /* set tweaks: T0 = 0; T1 = KEY type */ skein_start_new_type(ctx, KEY); /* zero the initial chaining variables */ - memset(ctx->X, 0, sizeof(ctx->X)); + memset(ctx->x, 0, sizeof(ctx->x)); /* hash the key */ skein_256_update(ctx, key, key_bytes); /* put result into cfg.b[] */ skein_256_final_pad(ctx, cfg.b); - /* copy over into ctx->X[] */ - memcpy(ctx->X, cfg.b, sizeof(cfg.b)); + /* copy over into ctx->x[] */ + memcpy(ctx->x, cfg.b, sizeof(cfg.b)); } /* * build/process the config block, type == CONFIG (could be @@ -130,7 +130,7 @@ int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hash_bit_len, /* compute the initial chaining values from config block */ skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); - /* The chaining vars ctx->X are now initialized */ + /* The chaining vars ctx->x are now initialized */ /* Set up to process the data message portion of the hash (default) */ skein_start_new_type(ctx, MSG); @@ -197,12 +197,12 @@ int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg, int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val) { size_t i, n, byte_cnt; - u64 X[SKEIN_256_STATE_WORDS]; + u64 x[SKEIN_256_STATE_WORDS]; /* catch uninitialized context */ skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* tag as the final block */ - ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; + ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; /* zero pad b[] if necessary */ if (ctx->h.b_cnt < SKEIN_256_BLOCK_BYTES) memset(&ctx->b[ctx->h.b_cnt], 0, @@ -219,7 +219,7 @@ int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val) /* zero out b[], so it can hold the counter */ memset(ctx->b, 0, sizeof(ctx->b)); /* keep a local copy of counter mode "key" */ - memcpy(X, ctx->X, sizeof(X)); + memcpy(x, ctx->x, sizeof(x)); for (i = 0; i*SKEIN_256_BLOCK_BYTES < byte_cnt; i++) { /* build the counter block */ ((u64 *)ctx->b)[0] = skein_swap64((u64) i); @@ -231,12 +231,12 @@ int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val) if (n >= SKEIN_256_BLOCK_BYTES) n = SKEIN_256_BLOCK_BYTES; /* "output" the ctr mode bytes */ - skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->X, + skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->x, n); skein_show_final(256, &ctx->h, n, hash_val+i*SKEIN_256_BLOCK_BYTES); /* restore the counter mode key for next time */ - memcpy(ctx->X, X, sizeof(X)); + memcpy(ctx->x, x, sizeof(x)); } return SKEIN_SUCCESS; } @@ -259,16 +259,16 @@ int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len) switch (hash_bit_len) { /* use pre-computed values, where available */ case 512: - memcpy(ctx->X, SKEIN_512_IV_512, sizeof(ctx->X)); + memcpy(ctx->x, SKEIN_512_IV_512, sizeof(ctx->x)); break; case 384: - memcpy(ctx->X, SKEIN_512_IV_384, sizeof(ctx->X)); + memcpy(ctx->x, SKEIN_512_IV_384, sizeof(ctx->x)); break; case 256: - memcpy(ctx->X, SKEIN_512_IV_256, sizeof(ctx->X)); + memcpy(ctx->x, SKEIN_512_IV_256, sizeof(ctx->x)); break; case 224: - memcpy(ctx->X, SKEIN_512_IV_224, sizeof(ctx->X)); + memcpy(ctx->x, SKEIN_512_IV_224, sizeof(ctx->x)); break; default: /* here if there is no precomputed IV value available */ @@ -289,13 +289,13 @@ int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len) /* compute the initial chaining values from config block */ /* zero the chaining variables */ - memset(ctx->X, 0, sizeof(ctx->X)); + memset(ctx->x, 0, sizeof(ctx->x)); skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); break; } /* - * The chaining vars ctx->X are now initialized for the given + * The chaining vars ctx->x are now initialized for the given * hash_bit_len. */ /* Set up to process the data message portion of the hash (default) */ @@ -319,25 +319,25 @@ int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hash_bit_len, skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); skein_assert_ret(key_bytes == 0 || key != NULL, SKEIN_FAIL); - /* compute the initial chaining values ctx->X[], based on key */ + /* compute the initial chaining values ctx->x[], based on key */ if (key_bytes == 0) { /* is there a key? */ /* no key: use all zeroes as key for config block */ - memset(ctx->X, 0, sizeof(ctx->X)); + memset(ctx->x, 0, sizeof(ctx->x)); } else { /* here to pre-process a key */ - skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); + skein_assert(sizeof(cfg.b) >= sizeof(ctx->x)); /* do a mini-Init right here */ /* set output hash bit count = state size */ - ctx->h.hash_bit_len = 8*sizeof(ctx->X); + ctx->h.hash_bit_len = 8*sizeof(ctx->x); /* set tweaks: T0 = 0; T1 = KEY type */ skein_start_new_type(ctx, KEY); /* zero the initial chaining variables */ - memset(ctx->X, 0, sizeof(ctx->X)); + memset(ctx->x, 0, sizeof(ctx->x)); /* hash the key */ skein_512_update(ctx, key, key_bytes); /* put result into cfg.b[] */ skein_512_final_pad(ctx, cfg.b); - /* copy over into ctx->X[] */ - memcpy(ctx->X, cfg.b, sizeof(cfg.b)); + /* copy over into ctx->x[] */ + memcpy(ctx->x, cfg.b, sizeof(cfg.b)); } /* * build/process the config block, type == CONFIG (could be @@ -359,7 +359,7 @@ int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hash_bit_len, /* compute the initial chaining values from config block */ skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); - /* The chaining vars ctx->X are now initialized */ + /* The chaining vars ctx->x are now initialized */ /* Set up to process the data message portion of the hash (default) */ skein_start_new_type(ctx, MSG); @@ -426,12 +426,12 @@ int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg, int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val) { size_t i, n, byte_cnt; - u64 X[SKEIN_512_STATE_WORDS]; + u64 x[SKEIN_512_STATE_WORDS]; /* catch uninitialized context */ skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* tag as the final block */ - ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; + ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; /* zero pad b[] if necessary */ if (ctx->h.b_cnt < SKEIN_512_BLOCK_BYTES) memset(&ctx->b[ctx->h.b_cnt], 0, @@ -448,7 +448,7 @@ int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val) /* zero out b[], so it can hold the counter */ memset(ctx->b, 0, sizeof(ctx->b)); /* keep a local copy of counter mode "key" */ - memcpy(X, ctx->X, sizeof(X)); + memcpy(x, ctx->x, sizeof(x)); for (i = 0; i*SKEIN_512_BLOCK_BYTES < byte_cnt; i++) { /* build the counter block */ ((u64 *)ctx->b)[0] = skein_swap64((u64) i); @@ -460,12 +460,12 @@ int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val) if (n >= SKEIN_512_BLOCK_BYTES) n = SKEIN_512_BLOCK_BYTES; /* "output" the ctr mode bytes */ - skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->X, + skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->x, n); skein_show_final(512, &ctx->h, n, hash_val+i*SKEIN_512_BLOCK_BYTES); /* restore the counter mode key for next time */ - memcpy(ctx->X, X, sizeof(X)); + memcpy(ctx->x, x, sizeof(x)); } return SKEIN_SUCCESS; } @@ -488,13 +488,13 @@ int skein_1024_init(struct skein_1024_ctx *ctx, size_t hash_bit_len) switch (hash_bit_len) { /* use pre-computed values, where available */ case 512: - memcpy(ctx->X, SKEIN_1024_IV_512, sizeof(ctx->X)); + memcpy(ctx->x, SKEIN_1024_IV_512, sizeof(ctx->x)); break; case 384: - memcpy(ctx->X, SKEIN_1024_IV_384, sizeof(ctx->X)); + memcpy(ctx->x, SKEIN_1024_IV_384, sizeof(ctx->x)); break; case 1024: - memcpy(ctx->X, SKEIN_1024_IV_1024, sizeof(ctx->X)); + memcpy(ctx->x, SKEIN_1024_IV_1024, sizeof(ctx->x)); break; default: /* here if there is no precomputed IV value available */ @@ -515,12 +515,12 @@ int skein_1024_init(struct skein_1024_ctx *ctx, size_t hash_bit_len) /* compute the initial chaining values from config block */ /* zero the chaining variables */ - memset(ctx->X, 0, sizeof(ctx->X)); + memset(ctx->x, 0, sizeof(ctx->x)); skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); break; } - /* The chaining vars ctx->X are now initialized for the hash_bit_len. */ + /* The chaining vars ctx->x are now initialized for the hash_bit_len. */ /* Set up to process the data message portion of the hash (default) */ skein_start_new_type(ctx, MSG); /* T0=0, T1= MSG type */ @@ -542,25 +542,25 @@ int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t hash_bit_len, skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); skein_assert_ret(key_bytes == 0 || key != NULL, SKEIN_FAIL); - /* compute the initial chaining values ctx->X[], based on key */ + /* compute the initial chaining values ctx->x[], based on key */ if (key_bytes == 0) { /* is there a key? */ /* no key: use all zeroes as key for config block */ - memset(ctx->X, 0, sizeof(ctx->X)); + memset(ctx->x, 0, sizeof(ctx->x)); } else { /* here to pre-process a key */ - skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); + skein_assert(sizeof(cfg.b) >= sizeof(ctx->x)); /* do a mini-Init right here */ /* set output hash bit count = state size */ - ctx->h.hash_bit_len = 8*sizeof(ctx->X); + ctx->h.hash_bit_len = 8*sizeof(ctx->x); /* set tweaks: T0 = 0; T1 = KEY type */ skein_start_new_type(ctx, KEY); /* zero the initial chaining variables */ - memset(ctx->X, 0, sizeof(ctx->X)); + memset(ctx->x, 0, sizeof(ctx->x)); /* hash the key */ skein_1024_update(ctx, key, key_bytes); /* put result into cfg.b[] */ skein_1024_final_pad(ctx, cfg.b); - /* copy over into ctx->X[] */ - memcpy(ctx->X, cfg.b, sizeof(cfg.b)); + /* copy over into ctx->x[] */ + memcpy(ctx->x, cfg.b, sizeof(cfg.b)); } /* * build/process the config block, type == CONFIG (could be @@ -583,7 +583,7 @@ int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t hash_bit_len, /* compute the initial chaining values from config block */ skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); - /* The chaining vars ctx->X are now initialized */ + /* The chaining vars ctx->x are now initialized */ /* Set up to process the data message portion of the hash (default) */ skein_start_new_type(ctx, MSG); @@ -650,12 +650,12 @@ int skein_1024_update(struct skein_1024_ctx *ctx, const u8 *msg, int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val) { size_t i, n, byte_cnt; - u64 X[SKEIN_1024_STATE_WORDS]; + u64 x[SKEIN_1024_STATE_WORDS]; /* catch uninitialized context */ skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL); /* tag as the final block */ - ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; + ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; /* zero pad b[] if necessary */ if (ctx->h.b_cnt < SKEIN_1024_BLOCK_BYTES) memset(&ctx->b[ctx->h.b_cnt], 0, @@ -672,7 +672,7 @@ int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val) /* zero out b[], so it can hold the counter */ memset(ctx->b, 0, sizeof(ctx->b)); /* keep a local copy of counter mode "key" */ - memcpy(X, ctx->X, sizeof(X)); + memcpy(x, ctx->x, sizeof(x)); for (i = 0; i*SKEIN_1024_BLOCK_BYTES < byte_cnt; i++) { /* build the counter block */ ((u64 *)ctx->b)[0] = skein_swap64((u64) i); @@ -684,12 +684,12 @@ int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val) if (n >= SKEIN_1024_BLOCK_BYTES) n = SKEIN_1024_BLOCK_BYTES; /* "output" the ctr mode bytes */ - skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx->X, + skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx->x, n); skein_show_final(1024, &ctx->h, n, hash_val+i*SKEIN_1024_BLOCK_BYTES); /* restore the counter mode key for next time */ - memcpy(ctx->X, X, sizeof(X)); + memcpy(ctx->x, x, sizeof(x)); } return SKEIN_SUCCESS; } @@ -705,7 +705,7 @@ int skein_256_final_pad(struct skein_256_ctx *ctx, u8 *hash_val) skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); /* tag as the final block */ - ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; + ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; /* zero pad b[] if necessary */ if (ctx->h.b_cnt < SKEIN_256_BLOCK_BYTES) memset(&ctx->b[ctx->h.b_cnt], 0, @@ -714,7 +714,7 @@ int skein_256_final_pad(struct skein_256_ctx *ctx, u8 *hash_val) skein_256_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); /* "output" the state bytes */ - skein_put64_lsb_first(hash_val, ctx->X, SKEIN_256_BLOCK_BYTES); + skein_put64_lsb_first(hash_val, ctx->x, SKEIN_256_BLOCK_BYTES); return SKEIN_SUCCESS; } @@ -727,7 +727,7 @@ int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hash_val) skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); /* tag as the final block */ - ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; + ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; /* zero pad b[] if necessary */ if (ctx->h.b_cnt < SKEIN_512_BLOCK_BYTES) memset(&ctx->b[ctx->h.b_cnt], 0, @@ -736,7 +736,7 @@ int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hash_val) skein_512_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); /* "output" the state bytes */ - skein_put64_lsb_first(hash_val, ctx->X, SKEIN_512_BLOCK_BYTES); + skein_put64_lsb_first(hash_val, ctx->x, SKEIN_512_BLOCK_BYTES); return SKEIN_SUCCESS; } @@ -749,7 +749,7 @@ int skein_1024_final_pad(struct skein_1024_ctx *ctx, u8 *hash_val) skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL); /* tag as the final block */ - ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; + ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; /* zero pad b[] if necessary */ if (ctx->h.b_cnt < SKEIN_1024_BLOCK_BYTES) memset(&ctx->b[ctx->h.b_cnt], 0, @@ -758,7 +758,7 @@ int skein_1024_final_pad(struct skein_1024_ctx *ctx, u8 *hash_val) skein_1024_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); /* "output" the state bytes */ - skein_put64_lsb_first(hash_val, ctx->X, SKEIN_1024_BLOCK_BYTES); + skein_put64_lsb_first(hash_val, ctx->x, SKEIN_1024_BLOCK_BYTES); return SKEIN_SUCCESS; } @@ -769,7 +769,7 @@ int skein_1024_final_pad(struct skein_1024_ctx *ctx, u8 *hash_val) int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val) { size_t i, n, byte_cnt; - u64 X[SKEIN_256_STATE_WORDS]; + u64 x[SKEIN_256_STATE_WORDS]; /* catch uninitialized context */ skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); @@ -781,7 +781,7 @@ int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val) /* zero out b[], so it can hold the counter */ memset(ctx->b, 0, sizeof(ctx->b)); /* keep a local copy of counter mode "key" */ - memcpy(X, ctx->X, sizeof(X)); + memcpy(x, ctx->x, sizeof(x)); for (i = 0; i*SKEIN_256_BLOCK_BYTES < byte_cnt; i++) { /* build the counter block */ ((u64 *)ctx->b)[0] = skein_swap64((u64) i); @@ -793,12 +793,12 @@ int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val) if (n >= SKEIN_256_BLOCK_BYTES) n = SKEIN_256_BLOCK_BYTES; /* "output" the ctr mode bytes */ - skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->X, + skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->x, n); skein_show_final(256, &ctx->h, n, hash_val+i*SKEIN_256_BLOCK_BYTES); /* restore the counter mode key for next time */ - memcpy(ctx->X, X, sizeof(X)); + memcpy(ctx->x, x, sizeof(x)); } return SKEIN_SUCCESS; } @@ -808,7 +808,7 @@ int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val) int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val) { size_t i, n, byte_cnt; - u64 X[SKEIN_512_STATE_WORDS]; + u64 x[SKEIN_512_STATE_WORDS]; /* catch uninitialized context */ skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); @@ -820,7 +820,7 @@ int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val) /* zero out b[], so it can hold the counter */ memset(ctx->b, 0, sizeof(ctx->b)); /* keep a local copy of counter mode "key" */ - memcpy(X, ctx->X, sizeof(X)); + memcpy(x, ctx->x, sizeof(x)); for (i = 0; i*SKEIN_512_BLOCK_BYTES < byte_cnt; i++) { /* build the counter block */ ((u64 *)ctx->b)[0] = skein_swap64((u64) i); @@ -832,12 +832,12 @@ int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val) if (n >= SKEIN_512_BLOCK_BYTES) n = SKEIN_512_BLOCK_BYTES; /* "output" the ctr mode bytes */ - skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->X, + skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->x, n); skein_show_final(256, &ctx->h, n, hash_val+i*SKEIN_512_BLOCK_BYTES); /* restore the counter mode key for next time */ - memcpy(ctx->X, X, sizeof(X)); + memcpy(ctx->x, x, sizeof(x)); } return SKEIN_SUCCESS; } @@ -847,7 +847,7 @@ int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val) int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val) { size_t i, n, byte_cnt; - u64 X[SKEIN_1024_STATE_WORDS]; + u64 x[SKEIN_1024_STATE_WORDS]; /* catch uninitialized context */ skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL); @@ -859,7 +859,7 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val) /* zero out b[], so it can hold the counter */ memset(ctx->b, 0, sizeof(ctx->b)); /* keep a local copy of counter mode "key" */ - memcpy(X, ctx->X, sizeof(X)); + memcpy(x, ctx->x, sizeof(x)); for (i = 0; i*SKEIN_1024_BLOCK_BYTES < byte_cnt; i++) { /* build the counter block */ ((u64 *)ctx->b)[0] = skein_swap64((u64) i); @@ -871,12 +871,12 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val) if (n >= SKEIN_1024_BLOCK_BYTES) n = SKEIN_1024_BLOCK_BYTES; /* "output" the ctr mode bytes */ - skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx->X, + skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx->x, n); skein_show_final(256, &ctx->h, n, hash_val+i*SKEIN_1024_BLOCK_BYTES); /* restore the counter mode key for next time */ - memcpy(ctx->X, X, sizeof(X)); + memcpy(ctx->x, x, sizeof(x)); } return SKEIN_SUCCESS; } diff --git a/drivers/staging/skein/skein.h b/drivers/staging/skein/skein.h index 2c87ff74aaea..e6669f196e5d 100644 --- a/drivers/staging/skein/skein.h +++ b/drivers/staging/skein/skein.h @@ -66,24 +66,24 @@ enum { struct skein_ctx_hdr { size_t hash_bit_len; /* size of hash result, in bits */ size_t b_cnt; /* current byte count in buffer b[] */ - u64 T[SKEIN_MODIFIER_WORDS]; /* tweak: T[0]=byte cnt, T[1]=flags */ + u64 tweak[SKEIN_MODIFIER_WORDS]; /* tweak[0]=byte cnt, tweak[1]=flags */ }; struct skein_256_ctx { /* 256-bit Skein hash context structure */ struct skein_ctx_hdr h; /* common header context variables */ - u64 X[SKEIN_256_STATE_WORDS]; /* chaining variables */ + u64 x[SKEIN_256_STATE_WORDS]; /* chaining variables */ u8 b[SKEIN_256_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ }; struct skein_512_ctx { /* 512-bit Skein hash context structure */ struct skein_ctx_hdr h; /* common header context variables */ - u64 X[SKEIN_512_STATE_WORDS]; /* chaining variables */ + u64 x[SKEIN_512_STATE_WORDS]; /* chaining variables */ u8 b[SKEIN_512_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ }; struct skein_1024_ctx { /* 1024-bit Skein hash context structure */ struct skein_ctx_hdr h; /* common header context variables */ - u64 X[SKEIN_1024_STATE_WORDS]; /* chaining variables */ + u64 x[SKEIN_1024_STATE_WORDS]; /* chaining variables */ u8 b[SKEIN_1024_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ }; @@ -150,7 +150,7 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); ** reference and optimized code. ******************************************************************/ -/* tweak word T[1]: bit field starting positions */ +/* tweak word tweak[1]: bit field starting positions */ #define SKEIN_T1_BIT(BIT) ((BIT) - 64) /* second word */ #define SKEIN_T1_POS_TREE_LVL SKEIN_T1_BIT(112) /* 112..118 hash tree level */ @@ -159,16 +159,16 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); #define SKEIN_T1_POS_FIRST SKEIN_T1_BIT(126) /* 126 first blk flag */ #define SKEIN_T1_POS_FINAL SKEIN_T1_BIT(127) /* 127 final blk flag */ -/* tweak word T[1]: flag bit definition(s) */ +/* tweak word tweak[1]: flag bit definition(s) */ #define SKEIN_T1_FLAG_FIRST (((u64) 1) << SKEIN_T1_POS_FIRST) #define SKEIN_T1_FLAG_FINAL (((u64) 1) << SKEIN_T1_POS_FINAL) #define SKEIN_T1_FLAG_BIT_PAD (((u64) 1) << SKEIN_T1_POS_BIT_PAD) -/* tweak word T[1]: tree level bit field mask */ +/* tweak word tweak[1]: tree level bit field mask */ #define SKEIN_T1_TREE_LVL_MASK (((u64)0x7F) << SKEIN_T1_POS_TREE_LVL) #define SKEIN_T1_TREE_LEVEL(n) (((u64) (n)) << SKEIN_T1_POS_TREE_LVL) -/* tweak word T[1]: block type field */ +/* tweak word tweak[1]: block type field */ #define SKEIN_BLK_TYPE_KEY (0) /* key, for MAC and KDF */ #define SKEIN_BLK_TYPE_CFG (4) /* configuration block */ #define SKEIN_BLK_TYPE_PERS (8) /* personalization string */ @@ -232,9 +232,9 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); ** Skein macros for getting/setting tweak words, etc. ** These are useful for partial input bytes, hash tree init/update, etc. **/ -#define skein_get_tweak(ctx_ptr, TWK_NUM) ((ctx_ptr)->h.T[TWK_NUM]) +#define skein_get_tweak(ctx_ptr, TWK_NUM) ((ctx_ptr)->h.tweak[TWK_NUM]) #define skein_set_tweak(ctx_ptr, TWK_NUM, t_val) { \ - (ctx_ptr)->h.T[TWK_NUM] = (t_val); \ + (ctx_ptr)->h.tweak[TWK_NUM] = (t_val); \ } #define skein_get_T0(ctx_ptr) skein_get_tweak(ctx_ptr, 0) @@ -254,7 +254,7 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); /* * setup for starting with a new type: - * h.T[0]=0; h.T[1] = NEW_TYPE; h.b_cnt=0; + * h.tweak[0]=0; h.tweak[1] = NEW_TYPE; h.b_cnt=0; */ #define skein_start_new_type(ctx_ptr, BLK_TYPE) { \ skein_set_T0_T1(ctx_ptr, 0, SKEIN_T1_FLAG_FIRST | \ @@ -263,14 +263,14 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); } #define skein_clear_first_flag(hdr) { \ - (hdr).T[1] &= ~SKEIN_T1_FLAG_FIRST; \ + (hdr).tweak[1] &= ~SKEIN_T1_FLAG_FIRST; \ } #define skein_set_bit_pad_flag(hdr) { \ - (hdr).T[1] |= SKEIN_T1_FLAG_BIT_PAD; \ + (hdr).tweak[1] |= SKEIN_T1_FLAG_BIT_PAD; \ } #define skein_set_tree_level(hdr, height) { \ - (hdr).T[1] |= SKEIN_T1_TREE_LEVEL(height); \ + (hdr).tweak[1] |= SKEIN_T1_TREE_LEVEL(height); \ } /***************************************************************** @@ -279,9 +279,9 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); #ifdef SKEIN_DEBUG /* examine/display intermediate values? */ #include "skein_debug.h" #else /* default is no callouts */ -#define skein_show_block(bits, ctx, X, blk_ptr, w_ptr, ks_event_ptr, ks_odd_ptr) -#define skein_show_round(bits, ctx, r, X) -#define skein_show_r_ptr(bits, ctx, r, X_ptr) +#define skein_show_block(bits, ctx, x, blk_ptr, w_ptr, ks_event_ptr, ks_odd_ptr) +#define skein_show_round(bits, ctx, r, x) +#define skein_show_r_ptr(bits, ctx, r, x_ptr) #define skein_show_final(bits, ctx, cnt, out_ptr) #define skein_show_key(bits, ctx, key, key_bytes) #endif diff --git a/drivers/staging/skein/skein_api.c b/drivers/staging/skein/skein_api.c index eaf7af4c8007..6e700eefc00c 100644 --- a/drivers/staging/skein/skein_api.c +++ b/drivers/staging/skein/skein_api.c @@ -40,8 +40,8 @@ int skein_ctx_prepare(struct skein_ctx *ctx, enum skein_size size) int skein_init(struct skein_ctx *ctx, size_t hash_bit_len) { int ret = SKEIN_FAIL; - size_t X_len = 0; - u64 *X = NULL; + size_t x_len = 0; + u64 *x = NULL; u64 tree_info = SKEIN_CFG_TREE_INFO_SEQUENTIAL; skein_assert_ret(ctx, SKEIN_FAIL); @@ -50,8 +50,8 @@ int skein_init(struct skein_ctx *ctx, size_t hash_bit_len) * contexts are a union in out context and thus have tha maximum * memory available. The beauty of C :-) . */ - X = ctx->m.s256.X; - X_len = ctx->skein_size/8; + x = ctx->m.s256.x; + x_len = ctx->skein_size/8; /* * If size is the same and hash bit length is zero then reuse * the save chaining variables. @@ -76,7 +76,7 @@ int skein_init(struct skein_ctx *ctx, size_t hash_bit_len) * Save chaining variables for this combination of size and * hash_bit_len */ - memcpy(ctx->X_save, X, X_len); + memcpy(ctx->x_save, x, x_len); } return ret; } @@ -85,14 +85,14 @@ int skein_mac_init(struct skein_ctx *ctx, const u8 *key, size_t key_len, size_t hash_bit_len) { int ret = SKEIN_FAIL; - u64 *X = NULL; - size_t X_len = 0; + u64 *x = NULL; + size_t x_len = 0; u64 tree_info = SKEIN_CFG_TREE_INFO_SEQUENTIAL; skein_assert_ret(ctx, SKEIN_FAIL); - X = ctx->m.s256.X; - X_len = ctx->skein_size/8; + x = ctx->m.s256.x; + x_len = ctx->skein_size/8; skein_assert_ret(hash_bit_len, SKEIN_BAD_HASHLEN); @@ -120,25 +120,25 @@ int skein_mac_init(struct skein_ctx *ctx, const u8 *key, size_t key_len, * Save chaining variables for this combination of key, * key_len, hash_bit_len */ - memcpy(ctx->X_save, X, X_len); + memcpy(ctx->x_save, x, x_len); } return ret; } void skein_reset(struct skein_ctx *ctx) { - size_t X_len = 0; - u64 *X = NULL; + size_t x_len = 0; + u64 *x = NULL; /* * The following two lines rely of the fact that the real Skein * contexts are a union in out context and thus have tha maximum * memory available. The beautiy of C :-) . */ - X = ctx->m.s256.X; - X_len = ctx->skein_size/8; + x = ctx->m.s256.x; + x_len = ctx->skein_size/8; /* Restore the chaing variable, reset byte counter */ - memcpy(X, ctx->X_save, X_len); + memcpy(x, ctx->x_save, x_len); /* Setup context to process the message */ skein_start_new_type(&ctx->m, MSG); @@ -200,7 +200,7 @@ int skein_update_bits(struct skein_ctx *ctx, const u8 *msg, * Skein's real partial block buffer. * If this layout ever changes we have to adapt this as well. */ - up = (u8 *)ctx->m.s256.X + ctx->skein_size / 8; + up = (u8 *)ctx->m.s256.x + ctx->skein_size / 8; /* set tweak flag for the skein_final call */ skein_set_bit_pad_flag(ctx->m.h); diff --git a/drivers/staging/skein/skein_api.h b/drivers/staging/skein/skein_api.h index db808ae434ff..e02fa19d9458 100644 --- a/drivers/staging/skein/skein_api.h +++ b/drivers/staging/skein/skein_api.h @@ -100,7 +100,7 @@ enum skein_size { */ struct skein_ctx { u64 skein_size; - u64 X_save[SKEIN_MAX_STATE_WORDS]; /* save area for state variables */ + u64 x_save[SKEIN_MAX_STATE_WORDS]; /* save area for state variables */ union { struct skein_ctx_hdr h; struct skein_256_ctx s256; diff --git a/drivers/staging/skein/skein_block.c b/drivers/staging/skein/skein_block.c index 76c4113ea5c8..f49eb2e9e5af 100644 --- a/drivers/staging/skein/skein_block.c +++ b/drivers/staging/skein/skein_block.c @@ -32,7 +32,8 @@ #define ts (kw + KW_TWK_BASE) #ifdef SKEIN_DEBUG -#define debug_save_tweak(ctx) { ctx->h.T[0] = ts[0]; ctx->h.T[1] = ts[1]; } +#define debug_save_tweak(ctx) { \ + ctx->h.tweak[0] = ts[0]; ctx->h.tweak[1] = ts[1]; } #else #define debug_save_tweak(ctx) #endif @@ -71,8 +72,8 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, X_ptr[0] = &X0; X_ptr[1] = &X1; X_ptr[2] = &X2; X_ptr[3] = &X3; #endif skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ - ts[0] = ctx->h.T[0]; - ts[1] = ctx->h.T[1]; + ts[0] = ctx->h.tweak[0]; + ts[1] = ctx->h.tweak[1]; do { /* * this implementation only supports 2**64 input bytes @@ -81,10 +82,10 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, ts[0] += byte_cnt_add; /* update processed length */ /* precompute the key schedule for this block */ - ks[0] = ctx->X[0]; - ks[1] = ctx->X[1]; - ks[2] = ctx->X[2]; - ks[3] = ctx->X[3]; + ks[0] = ctx->x[0]; + ks[1] = ctx->x[1]; + ks[2] = ctx->x[2]; + ks[3] = ctx->x[3]; ks[4] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ SKEIN_KS_PARITY; ts[2] = ts[0] ^ ts[1]; @@ -92,7 +93,7 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, /* get input block in little-endian format */ skein_get64_lsb_first(w, blk_ptr, WCNT); debug_save_tweak(ctx); - skein_show_block(BLK_BITS, &ctx->h, ctx->X, blk_ptr, w, ks, ts); + skein_show_block(BLK_BITS, &ctx->h, ctx->x, blk_ptr, w, ks, ts); X0 = w[0] + ks[0]; /* do the first full key injection */ X1 = w[1] + ks[1] + ts[0]; @@ -101,7 +102,7 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, /* show starting state values */ skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, - X_ptr); + x_ptr); blk_ptr += SKEIN_256_BLOCK_BYTES; @@ -220,17 +221,17 @@ do { \ #endif } /* do the final "feedforward" xor, update context chaining */ - ctx->X[0] = X0 ^ w[0]; - ctx->X[1] = X1 ^ w[1]; - ctx->X[2] = X2 ^ w[2]; - ctx->X[3] = X3 ^ w[3]; + ctx->x[0] = X0 ^ w[0]; + ctx->x[1] = X1 ^ w[1]; + ctx->x[2] = X2 ^ w[2]; + ctx->x[3] = X3 ^ w[3]; - skein_show_round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X); + skein_show_round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->x); ts[1] &= ~SKEIN_T1_FLAG_FIRST; } while (--blk_cnt); - ctx->h.T[0] = ts[0]; - ctx->h.T[1] = ts[1]; + ctx->h.tweak[0] = ts[0]; + ctx->h.tweak[1] = ts[1]; } #if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF) @@ -282,8 +283,8 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, #endif skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ - ts[0] = ctx->h.T[0]; - ts[1] = ctx->h.T[1]; + ts[0] = ctx->h.tweak[0]; + ts[1] = ctx->h.tweak[1]; do { /* * this implementation only supports 2**64 input bytes @@ -292,14 +293,14 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, ts[0] += byte_cnt_add; /* update processed length */ /* precompute the key schedule for this block */ - ks[0] = ctx->X[0]; - ks[1] = ctx->X[1]; - ks[2] = ctx->X[2]; - ks[3] = ctx->X[3]; - ks[4] = ctx->X[4]; - ks[5] = ctx->X[5]; - ks[6] = ctx->X[6]; - ks[7] = ctx->X[7]; + ks[0] = ctx->x[0]; + ks[1] = ctx->x[1]; + ks[2] = ctx->x[2]; + ks[3] = ctx->x[3]; + ks[4] = ctx->x[4]; + ks[5] = ctx->x[5]; + ks[6] = ctx->x[6]; + ks[7] = ctx->x[7]; ks[8] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ ks[4] ^ ks[5] ^ ks[6] ^ ks[7] ^ SKEIN_KS_PARITY; @@ -308,7 +309,7 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, /* get input block in little-endian format */ skein_get64_lsb_first(w, blk_ptr, WCNT); debug_save_tweak(ctx); - skein_show_block(BLK_BITS, &ctx->h, ctx->X, blk_ptr, w, ks, ts); + skein_show_block(BLK_BITS, &ctx->h, ctx->x, blk_ptr, w, ks, ts); X0 = w[0] + ks[0]; /* do the first full key injection */ X1 = w[1] + ks[1]; @@ -448,20 +449,20 @@ do { \ } /* do the final "feedforward" xor, update context chaining */ - ctx->X[0] = X0 ^ w[0]; - ctx->X[1] = X1 ^ w[1]; - ctx->X[2] = X2 ^ w[2]; - ctx->X[3] = X3 ^ w[3]; - ctx->X[4] = X4 ^ w[4]; - ctx->X[5] = X5 ^ w[5]; - ctx->X[6] = X6 ^ w[6]; - ctx->X[7] = X7 ^ w[7]; - skein_show_round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X); + ctx->x[0] = X0 ^ w[0]; + ctx->x[1] = X1 ^ w[1]; + ctx->x[2] = X2 ^ w[2]; + ctx->x[3] = X3 ^ w[3]; + ctx->x[4] = X4 ^ w[4]; + ctx->x[5] = X5 ^ w[5]; + ctx->x[6] = X6 ^ w[6]; + ctx->x[7] = X7 ^ w[7]; + skein_show_round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->x); ts[1] &= ~SKEIN_T1_FLAG_FIRST; } while (--blk_cnt); - ctx->h.T[0] = ts[0]; - ctx->h.T[1] = ts[1]; + ctx->h.tweak[0] = ts[0]; + ctx->h.tweak[1] = ts[1]; } #if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF) @@ -520,8 +521,8 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, #endif skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ - ts[0] = ctx->h.T[0]; - ts[1] = ctx->h.T[1]; + ts[0] = ctx->h.tweak[0]; + ts[1] = ctx->h.tweak[1]; do { /* * this implementation only supports 2**64 input bytes @@ -530,22 +531,22 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, ts[0] += byte_cnt_add; /* update processed length */ /* precompute the key schedule for this block */ - ks[0] = ctx->X[0]; - ks[1] = ctx->X[1]; - ks[2] = ctx->X[2]; - ks[3] = ctx->X[3]; - ks[4] = ctx->X[4]; - ks[5] = ctx->X[5]; - ks[6] = ctx->X[6]; - ks[7] = ctx->X[7]; - ks[8] = ctx->X[8]; - ks[9] = ctx->X[9]; - ks[10] = ctx->X[10]; - ks[11] = ctx->X[11]; - ks[12] = ctx->X[12]; - ks[13] = ctx->X[13]; - ks[14] = ctx->X[14]; - ks[15] = ctx->X[15]; + ks[0] = ctx->x[0]; + ks[1] = ctx->x[1]; + ks[2] = ctx->x[2]; + ks[3] = ctx->x[3]; + ks[4] = ctx->x[4]; + ks[5] = ctx->x[5]; + ks[6] = ctx->x[6]; + ks[7] = ctx->x[7]; + ks[8] = ctx->x[8]; + ks[9] = ctx->x[9]; + ks[10] = ctx->x[10]; + ks[11] = ctx->x[11]; + ks[12] = ctx->x[12]; + ks[13] = ctx->x[13]; + ks[14] = ctx->x[14]; + ks[15] = ctx->x[15]; ks[16] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ ks[4] ^ ks[5] ^ ks[6] ^ ks[7] ^ ks[8] ^ ks[9] ^ ks[10] ^ ks[11] ^ @@ -556,7 +557,7 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, /* get input block in little-endian format */ skein_get64_lsb_first(w, blk_ptr, WCNT); debug_save_tweak(ctx); - skein_show_block(BLK_BITS, &ctx->h, ctx->X, blk_ptr, w, ks, ts); + skein_show_block(BLK_BITS, &ctx->h, ctx->x, blk_ptr, w, ks, ts); X00 = w[0] + ks[0]; /* do the first full key injection */ X01 = w[1] + ks[1]; @@ -735,30 +736,30 @@ do { \ } /* do the final "feedforward" xor, update context chaining */ - ctx->X[0] = X00 ^ w[0]; - ctx->X[1] = X01 ^ w[1]; - ctx->X[2] = X02 ^ w[2]; - ctx->X[3] = X03 ^ w[3]; - ctx->X[4] = X04 ^ w[4]; - ctx->X[5] = X05 ^ w[5]; - ctx->X[6] = X06 ^ w[6]; - ctx->X[7] = X07 ^ w[7]; - ctx->X[8] = X08 ^ w[8]; - ctx->X[9] = X09 ^ w[9]; - ctx->X[10] = X10 ^ w[10]; - ctx->X[11] = X11 ^ w[11]; - ctx->X[12] = X12 ^ w[12]; - ctx->X[13] = X13 ^ w[13]; - ctx->X[14] = X14 ^ w[14]; - ctx->X[15] = X15 ^ w[15]; - - skein_show_round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X); + ctx->x[0] = X00 ^ w[0]; + ctx->x[1] = X01 ^ w[1]; + ctx->x[2] = X02 ^ w[2]; + ctx->x[3] = X03 ^ w[3]; + ctx->x[4] = X04 ^ w[4]; + ctx->x[5] = X05 ^ w[5]; + ctx->x[6] = X06 ^ w[6]; + ctx->x[7] = X07 ^ w[7]; + ctx->x[8] = X08 ^ w[8]; + ctx->x[9] = X09 ^ w[9]; + ctx->x[10] = X10 ^ w[10]; + ctx->x[11] = X11 ^ w[11]; + ctx->x[12] = X12 ^ w[12]; + ctx->x[13] = X13 ^ w[13]; + ctx->x[14] = X14 ^ w[14]; + ctx->x[15] = X15 ^ w[15]; + + skein_show_round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->x); ts[1] &= ~SKEIN_T1_FLAG_FIRST; blk_ptr += SKEIN_1024_BLOCK_BYTES; } while (--blk_cnt); - ctx->h.T[0] = ts[0]; - ctx->h.T[1] = ts[1]; + ctx->h.tweak[0] = ts[0]; + ctx->h.tweak[1] = ts[1]; } #if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF) -- cgit v1.2.3 From 78de2c063710988b5bf0883c186c366e997c3193 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 May 2014 16:25:33 -0500 Subject: staging: r8192ee: Add source files for core driver This part is the equivalent of rtlwifi in the wireless tree. As the changes needed for the RTL8192EE have not yet been merged, a separate version is still needed. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192ee/base.c | 1852 +++++++++++++++++++++++++ drivers/staging/rtl8192ee/base.h | 163 +++ drivers/staging/rtl8192ee/cam.c | 337 +++++ drivers/staging/rtl8192ee/cam.h | 52 + drivers/staging/rtl8192ee/compat.h | 70 + drivers/staging/rtl8192ee/core.c | 1600 ++++++++++++++++++++++ drivers/staging/rtl8192ee/core.h | 39 + drivers/staging/rtl8192ee/debug.c | 978 +++++++++++++ drivers/staging/rtl8192ee/debug.h | 221 +++ drivers/staging/rtl8192ee/efuse.c | 1233 +++++++++++++++++ drivers/staging/rtl8192ee/efuse.h | 127 ++ drivers/staging/rtl8192ee/pci.c | 2397 ++++++++++++++++++++++++++++++++ drivers/staging/rtl8192ee/pci.h | 342 +++++ drivers/staging/rtl8192ee/ps.c | 983 ++++++++++++++ drivers/staging/rtl8192ee/ps.h | 52 + drivers/staging/rtl8192ee/rc.c | 288 ++++ drivers/staging/rtl8192ee/rc.h | 47 + drivers/staging/rtl8192ee/regd.c | 448 ++++++ drivers/staging/rtl8192ee/regd.h | 63 + drivers/staging/rtl8192ee/stats.c | 290 ++++ drivers/staging/rtl8192ee/stats.h | 43 + drivers/staging/rtl8192ee/wifi.h | 2645 ++++++++++++++++++++++++++++++++++++ 22 files changed, 14270 insertions(+) create mode 100644 drivers/staging/rtl8192ee/base.c create mode 100644 drivers/staging/rtl8192ee/base.h create mode 100644 drivers/staging/rtl8192ee/cam.c create mode 100644 drivers/staging/rtl8192ee/cam.h create mode 100644 drivers/staging/rtl8192ee/compat.h create mode 100644 drivers/staging/rtl8192ee/core.c create mode 100644 drivers/staging/rtl8192ee/core.h create mode 100644 drivers/staging/rtl8192ee/debug.c create mode 100644 drivers/staging/rtl8192ee/debug.h create mode 100644 drivers/staging/rtl8192ee/efuse.c create mode 100644 drivers/staging/rtl8192ee/efuse.h create mode 100644 drivers/staging/rtl8192ee/pci.c create mode 100644 drivers/staging/rtl8192ee/pci.h create mode 100644 drivers/staging/rtl8192ee/ps.c create mode 100644 drivers/staging/rtl8192ee/ps.h create mode 100644 drivers/staging/rtl8192ee/rc.c create mode 100644 drivers/staging/rtl8192ee/rc.h create mode 100644 drivers/staging/rtl8192ee/regd.c create mode 100644 drivers/staging/rtl8192ee/regd.h create mode 100644 drivers/staging/rtl8192ee/stats.c create mode 100644 drivers/staging/rtl8192ee/stats.h create mode 100644 drivers/staging/rtl8192ee/wifi.h diff --git a/drivers/staging/rtl8192ee/base.c b/drivers/staging/rtl8192ee/base.c new file mode 100644 index 000000000000..64ade216a153 --- /dev/null +++ b/drivers/staging/rtl8192ee/base.c @@ -0,0 +1,1852 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#include +#include +#include "wifi.h" +#include "rc.h" +#include "base.h" +#include "efuse.h" +#include "cam.h" +#include "ps.h" +#include "regd.h" +#include "pci.h" + +/* + *NOTICE!!!: This file will be very big, we hsould + *keep it clear under follwing roles: + * + *This file include follwing part, so, if you add new + *functions into this file, please check which part it + *should includes. or check if you should add new part + *for this file: + * + *1) mac80211 init functions + *2) tx information functions + *3) functions called by core.c + *4) wq & timer callback functions + *5) frame process functions + *6) IOT functions + *7) sysfs functions + *8) vif functions + *9) ... + */ + +/********************************************************* + * + * mac80211 init functions + * + *********************************************************/ +static struct ieee80211_channel rtl_channeltable_2g[] = { + {.center_freq = 2412, .hw_value = 1,}, + {.center_freq = 2417, .hw_value = 2,}, + {.center_freq = 2422, .hw_value = 3,}, + {.center_freq = 2427, .hw_value = 4,}, + {.center_freq = 2432, .hw_value = 5,}, + {.center_freq = 2437, .hw_value = 6,}, + {.center_freq = 2442, .hw_value = 7,}, + {.center_freq = 2447, .hw_value = 8,}, + {.center_freq = 2452, .hw_value = 9,}, + {.center_freq = 2457, .hw_value = 10,}, + {.center_freq = 2462, .hw_value = 11,}, + {.center_freq = 2467, .hw_value = 12,}, + {.center_freq = 2472, .hw_value = 13,}, + {.center_freq = 2484, .hw_value = 14,}, +}; + +static struct ieee80211_channel rtl_channeltable_5g[] = { + {.center_freq = 5180, .hw_value = 36,}, + {.center_freq = 5200, .hw_value = 40,}, + {.center_freq = 5220, .hw_value = 44,}, + {.center_freq = 5240, .hw_value = 48,}, + {.center_freq = 5260, .hw_value = 52,}, + {.center_freq = 5280, .hw_value = 56,}, + {.center_freq = 5300, .hw_value = 60,}, + {.center_freq = 5320, .hw_value = 64,}, + {.center_freq = 5500, .hw_value = 100,}, + {.center_freq = 5520, .hw_value = 104,}, + {.center_freq = 5540, .hw_value = 108,}, + {.center_freq = 5560, .hw_value = 112,}, + {.center_freq = 5580, .hw_value = 116,}, + {.center_freq = 5600, .hw_value = 120,}, + {.center_freq = 5620, .hw_value = 124,}, + {.center_freq = 5640, .hw_value = 128,}, + {.center_freq = 5660, .hw_value = 132,}, + {.center_freq = 5680, .hw_value = 136,}, + {.center_freq = 5700, .hw_value = 140,}, + {.center_freq = 5745, .hw_value = 149,}, + {.center_freq = 5765, .hw_value = 153,}, + {.center_freq = 5785, .hw_value = 157,}, + {.center_freq = 5805, .hw_value = 161,}, + {.center_freq = 5825, .hw_value = 165,}, +}; + +static struct ieee80211_rate rtl_ratetable_2g[] = { + {.bitrate = 10, .hw_value = 0x00,}, + {.bitrate = 20, .hw_value = 0x01,}, + {.bitrate = 55, .hw_value = 0x02,}, + {.bitrate = 110, .hw_value = 0x03,}, + {.bitrate = 60, .hw_value = 0x04,}, + {.bitrate = 90, .hw_value = 0x05,}, + {.bitrate = 120, .hw_value = 0x06,}, + {.bitrate = 180, .hw_value = 0x07,}, + {.bitrate = 240, .hw_value = 0x08,}, + {.bitrate = 360, .hw_value = 0x09,}, + {.bitrate = 480, .hw_value = 0x0a,}, + {.bitrate = 540, .hw_value = 0x0b,}, +}; + +static struct ieee80211_rate rtl_ratetable_5g[] = { + {.bitrate = 60, .hw_value = 0x04,}, + {.bitrate = 90, .hw_value = 0x05,}, + {.bitrate = 120, .hw_value = 0x06,}, + {.bitrate = 180, .hw_value = 0x07,}, + {.bitrate = 240, .hw_value = 0x08,}, + {.bitrate = 360, .hw_value = 0x09,}, + {.bitrate = 480, .hw_value = 0x0a,}, + {.bitrate = 540, .hw_value = 0x0b,}, +}; + +static const struct ieee80211_supported_band rtl_band_2ghz = { + .band = IEEE80211_BAND_2GHZ, + + .channels = rtl_channeltable_2g, + .n_channels = ARRAY_SIZE(rtl_channeltable_2g), + + .bitrates = rtl_ratetable_2g, + .n_bitrates = ARRAY_SIZE(rtl_ratetable_2g), + + .ht_cap = {0}, +}; + +static struct ieee80211_supported_band rtl_band_5ghz = { + .band = IEEE80211_BAND_5GHZ, + + .channels = rtl_channeltable_5g, + .n_channels = ARRAY_SIZE(rtl_channeltable_5g), + + .bitrates = rtl_ratetable_5g, + .n_bitrates = ARRAY_SIZE(rtl_ratetable_5g), + + .ht_cap = {0}, +}; + +static const u8 tid_to_ac[] = { + 2, /* IEEE80211_AC_BE */ + 3, /* IEEE80211_AC_BK */ + 3, /* IEEE80211_AC_BK */ + 2, /* IEEE80211_AC_BE */ + 1, /* IEEE80211_AC_VI */ + 1, /* IEEE80211_AC_VI */ + 0, /* IEEE80211_AC_VO */ + 0, /* IEEE80211_AC_VO */ +}; + +u8 rtl92e_tid_to_ac(struct ieee80211_hw *hw, u8 tid) +{ + return tid_to_ac[tid]; +} + +static void _rtl_init_hw_ht_capab(struct ieee80211_hw *hw, + struct ieee80211_sta_ht_cap *ht_cap) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + + ht_cap->ht_supported = true; + ht_cap->cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 | + IEEE80211_HT_CAP_SGI_40 | + IEEE80211_HT_CAP_SGI_20 | + IEEE80211_HT_CAP_DSSSCCK40 | IEEE80211_HT_CAP_MAX_AMSDU; + + if (rtlpriv->rtlhal.disable_amsdu_8k) + ht_cap->cap &= ~IEEE80211_HT_CAP_MAX_AMSDU; + + /* + *Maximum length of AMPDU that the STA can receive. + *Length = 2 ^ (13 + max_ampdu_length_exp) - 1 (octets) + */ + ht_cap->ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K; + + /*Minimum MPDU start spacing , */ + ht_cap->ampdu_density = IEEE80211_HT_MPDU_DENSITY_16; + + ht_cap->mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; + + /* + *hw->wiphy->bands[IEEE80211_BAND_2GHZ] + *base on ant_num + *rx_mask: RX mask + *if rx_ant =1 rx_mask[0]=0xff;==>MCS0-MCS7 + *if rx_ant =2 rx_mask[1]=0xff;==>MCS8-MCS15 + *if rx_ant >=3 rx_mask[2]=0xff; + *if BW_40 rx_mask[4]=0x01; + *highest supported RX rate + */ + if (rtlpriv->dm.supp_phymode_switch) { + RT_TRACE(COMP_INIT, DBG_EMERG, ("Support phy mode switch\n")); + + ht_cap->mcs.rx_mask[0] = 0xFF; + ht_cap->mcs.rx_mask[1] = 0xFF; + ht_cap->mcs.rx_mask[4] = 0x01; + + ht_cap->mcs.rx_highest = cpu_to_le16(MAX_BIT_RATE_40MHZ_MCS15); + } else { + if (get_rf_type(rtlphy) == RF_1T2R || + get_rf_type(rtlphy) == RF_2T2R) { + RT_TRACE(COMP_INIT, DBG_DMESG, ("1T2R or 2T2R\n")); + + ht_cap->mcs.rx_mask[0] = 0xFF; + ht_cap->mcs.rx_mask[1] = 0xFF; + ht_cap->mcs.rx_mask[4] = 0x01; + + ht_cap->mcs.rx_highest = cpu_to_le16(MAX_BIT_RATE_40MHZ_MCS15); + } else if (get_rf_type(rtlphy) == RF_1T1R) { + RT_TRACE(COMP_INIT, DBG_DMESG, ("1T1R\n")); + + ht_cap->mcs.rx_mask[0] = 0xFF; + ht_cap->mcs.rx_mask[1] = 0x00; + ht_cap->mcs.rx_mask[4] = 0x01; + + ht_cap->mcs.rx_highest = cpu_to_le16(MAX_BIT_RATE_40MHZ_MCS7); + } + } +} + +static void _rtl_init_hw_vht_capab(struct ieee80211_hw *hw, + struct ieee80211_sta_vht_cap *vht_cap) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtlpriv); + + if (rtlhal->hw_type == HARDWARE_TYPE_RTL8812AE) { + u16 mcs_map; + vht_cap->vht_supported = true; + vht_cap->cap = + IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895 | + IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991 | + IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454 | + IEEE80211_VHT_CAP_SHORT_GI_80 | + IEEE80211_VHT_CAP_TXSTBC | + IEEE80211_VHT_CAP_RXSTBC_1 | + IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE | + IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE | + IEEE80211_VHT_CAP_HTC_VHT | + IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK | + IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN | + IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN | + 0; + + mcs_map = IEEE80211_VHT_MCS_SUPPORT_0_9 << 0 | + IEEE80211_VHT_MCS_SUPPORT_0_9 << 2 | + IEEE80211_VHT_MCS_NOT_SUPPORTED << 4 | + IEEE80211_VHT_MCS_NOT_SUPPORTED << 6 | + IEEE80211_VHT_MCS_NOT_SUPPORTED << 8 | + IEEE80211_VHT_MCS_NOT_SUPPORTED << 10 | + IEEE80211_VHT_MCS_NOT_SUPPORTED << 12 | + IEEE80211_VHT_MCS_NOT_SUPPORTED << 14; + + vht_cap->vht_mcs.rx_mcs_map = cpu_to_le16(mcs_map); + vht_cap->vht_mcs.rx_highest = + cpu_to_le16(MAX_BIT_RATE_SHORT_GI_2NSS_80MHZ_MCS9); + vht_cap->vht_mcs.tx_mcs_map = cpu_to_le16(mcs_map); + vht_cap->vht_mcs.tx_highest = + cpu_to_le16(MAX_BIT_RATE_SHORT_GI_2NSS_80MHZ_MCS9); + } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8821AE) { + u16 mcs_map; + + vht_cap->vht_supported = true; + vht_cap->cap = + IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895 | + IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991 | + IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454 | + IEEE80211_VHT_CAP_SHORT_GI_80 | + IEEE80211_VHT_CAP_TXSTBC | + IEEE80211_VHT_CAP_RXSTBC_1 | + IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE | + IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE | + IEEE80211_VHT_CAP_HTC_VHT | + IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK | + IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN | + IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN | + 0; + + mcs_map = IEEE80211_VHT_MCS_SUPPORT_0_9 << 0 | + IEEE80211_VHT_MCS_NOT_SUPPORTED << 2 | + IEEE80211_VHT_MCS_NOT_SUPPORTED << 4 | + IEEE80211_VHT_MCS_NOT_SUPPORTED << 6 | + IEEE80211_VHT_MCS_NOT_SUPPORTED << 8 | + IEEE80211_VHT_MCS_NOT_SUPPORTED << 10 | + IEEE80211_VHT_MCS_NOT_SUPPORTED << 12 | + IEEE80211_VHT_MCS_NOT_SUPPORTED << 14; + + vht_cap->vht_mcs.rx_mcs_map = cpu_to_le16(mcs_map); + vht_cap->vht_mcs.rx_highest = + cpu_to_le16(MAX_BIT_RATE_SHORT_GI_1NSS_80MHZ_MCS9); + vht_cap->vht_mcs.tx_mcs_map = cpu_to_le16(mcs_map); + vht_cap->vht_mcs.tx_highest = + cpu_to_le16(MAX_BIT_RATE_SHORT_GI_1NSS_80MHZ_MCS9); + } +} + +static void _rtl_init_mac80211(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtlpriv); + struct rtl_mac *rtlmac = rtl_mac(rtl_priv(hw)); + struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); + struct ieee80211_supported_band *sband; + + + if (rtlhal->macphymode == SINGLEMAC_SINGLEPHY && + rtlhal->bandset == BAND_ON_BOTH) { + /* 1: 2.4 G bands */ + /* <1> use mac->bands as mem for hw->wiphy->bands */ + sband = &(rtlmac->bands[IEEE80211_BAND_2GHZ]); + + /* <2> set hw->wiphy->bands[IEEE80211_BAND_2GHZ] + * to default value(1T1R) */ + memcpy(&(rtlmac->bands[IEEE80211_BAND_2GHZ]), &rtl_band_2ghz, + sizeof(struct ieee80211_supported_band)); + + /* <3> init ht cap base on ant_num */ + _rtl_init_hw_ht_capab(hw, &sband->ht_cap); + + /* <4> set mac->sband to wiphy->sband */ + hw->wiphy->bands[IEEE80211_BAND_2GHZ] = sband; + + /* 2: 5 G bands */ + /* <1> use mac->bands as mem for hw->wiphy->bands */ + sband = &(rtlmac->bands[IEEE80211_BAND_5GHZ]); + + /* <2> set hw->wiphy->bands[IEEE80211_BAND_5GHZ] + * to default value(1T1R) */ + memcpy(&(rtlmac->bands[IEEE80211_BAND_5GHZ]), &rtl_band_5ghz, + sizeof(struct ieee80211_supported_band)); + + /* <3> init ht cap base on ant_num */ + _rtl_init_hw_ht_capab(hw, &sband->ht_cap); + + _rtl_init_hw_vht_capab(hw, &sband->vht_cap); + + /* <4> set mac->sband to wiphy->sband */ + hw->wiphy->bands[IEEE80211_BAND_5GHZ] = sband; + } else { + if (rtlhal->current_bandtype == BAND_ON_2_4G) { + /* <1> use mac->bands as mem for hw->wiphy->bands */ + sband = &(rtlmac->bands[IEEE80211_BAND_2GHZ]); + + /* <2> set hw->wiphy->bands[IEEE80211_BAND_2GHZ] + * to default value(1T1R) */ + memcpy(&(rtlmac->bands[IEEE80211_BAND_2GHZ]), + &rtl_band_2ghz, + sizeof(struct ieee80211_supported_band)); + + /* <3> init ht cap base on ant_num */ + _rtl_init_hw_ht_capab(hw, &sband->ht_cap); + + /* <4> set mac->sband to wiphy->sband */ + hw->wiphy->bands[IEEE80211_BAND_2GHZ] = sband; + } else if (rtlhal->current_bandtype == BAND_ON_5G) { + /* <1> use mac->bands as mem for hw->wiphy->bands */ + sband = &(rtlmac->bands[IEEE80211_BAND_5GHZ]); + + /* <2> set hw->wiphy->bands[IEEE80211_BAND_5GHZ] + * to default value(1T1R) */ + memcpy(&(rtlmac->bands[IEEE80211_BAND_5GHZ]), + &rtl_band_5ghz, + sizeof(struct ieee80211_supported_band)); + + /* <3> init ht cap base on ant_num */ + _rtl_init_hw_ht_capab(hw, &sband->ht_cap); + + _rtl_init_hw_vht_capab(hw, &sband->vht_cap); + + /* <4> set mac->sband to wiphy->sband */ + hw->wiphy->bands[IEEE80211_BAND_5GHZ] = sband; + } else { + RT_TRACE(COMP_INIT, DBG_EMERG, + ("Err BAND %d\n", rtlhal->current_bandtype)); + } + } + /* <5> set hw caps */ + hw->flags = IEEE80211_HW_SIGNAL_DBM | + IEEE80211_HW_RX_INCLUDES_FCS | + IEEE80211_HW_AMPDU_AGGREGATION | + IEEE80211_HW_REPORTS_TX_ACK_STATUS | + IEEE80211_HW_CONNECTION_MONITOR | + /* IEEE80211_HW_SUPPORTS_CQM_RSSI | */ + IEEE80211_HW_MFP_CAPABLE | 0; + + /* swlps or hwlps has been set in diff chip in init_sw_vars */ + if (rtlpriv->psc.b_swctrl_lps) + hw->flags |= IEEE80211_HW_SUPPORTS_PS | + IEEE80211_HW_PS_NULLFUNC_STACK | + /* IEEE80211_HW_SUPPORTS_DYNAMIC_PS | */ + 0; +/**/ + hw->wiphy->interface_modes = + BIT(NL80211_IFTYPE_AP) | + BIT(NL80211_IFTYPE_STATION) | + BIT(NL80211_IFTYPE_ADHOC) | + BIT(NL80211_IFTYPE_MESH_POINT) | + BIT(NL80211_IFTYPE_P2P_CLIENT) | + BIT(NL80211_IFTYPE_P2P_GO); + hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; + + hw->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; + + hw->wiphy->rts_threshold = 2347; + + hw->queues = AC_MAX; + hw->extra_tx_headroom = RTL_TX_HEADER_SIZE; + + /* TODO: Correct this value for our hw */ + /* TODO: define these hard code value */ + /* hw->channel_change_time = 100; kernel does not use it*/ + hw->max_listen_interval = 10; + hw->max_rate_tries = 4; + /* hw->max_rates = 1; */ + hw->sta_data_size = sizeof(struct rtl_sta_info); + +/* wowlan is not supported by kernel if CONFIG_PM is not defined */ +#ifdef CONFIG_PM + if (rtlpriv->psc.wo_wlan_mode) { + if (rtlpriv->psc.wo_wlan_mode & WAKE_ON_MAGIC_PACKET) + rtlpriv->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT; + if (rtlpriv->psc.wo_wlan_mode & WAKE_ON_PATTERN_MATCH) { + rtlpriv->wowlan.n_patterns = + MAX_SUPPORT_WOL_PATTERN_NUM; + rtlpriv->wowlan.pattern_min_len = MIN_WOL_PATTERN_SIZE; + rtlpriv->wowlan.pattern_max_len = MAX_WOL_PATTERN_SIZE; + } + hw->wiphy->wowlan = &(rtlpriv->wowlan); + } +#endif + + /* <6> mac address */ + if (is_valid_ether_addr(rtlefuse->dev_addr)) { + SET_IEEE80211_PERM_ADDR(hw, rtlefuse->dev_addr); + } else { + u8 rtlmac[] = { 0x00, 0xe0, 0x4c, 0x81, 0x92, 0x00 }; + get_random_bytes((rtlmac + (ETH_ALEN - 1)), 1); + SET_IEEE80211_PERM_ADDR(hw, rtlmac); + } +} + +static void _rtl_init_deferred_work(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + /* <1> timer */ + init_timer(&rtlpriv->works.watchdog_timer); + setup_timer(&rtlpriv->works.watchdog_timer, + rtl92e_watch_dog_timer_callback, (unsigned long)hw); + init_timer(&rtlpriv->works.dualmac_easyconcurrent_retrytimer); + setup_timer(&rtlpriv->works.dualmac_easyconcurrent_retrytimer, + rtl92e_easy_concurrent_retrytimer_callback, (unsigned long)hw); + /* <2> work queue */ + rtlpriv->works.hw = hw; + rtlpriv->works.rtl_wq = alloc_workqueue(rtlpriv->cfg->name, 0, 0); + INIT_DELAYED_WORK(&rtlpriv->works.watchdog_wq, + (void *)rtl92e_watchdog_wq_callback); + INIT_DELAYED_WORK(&rtlpriv->works.ips_nic_off_wq, + (void *)rtl92e_ips_nic_off_wq_callback); + INIT_DELAYED_WORK(&rtlpriv->works.ps_work, + (void *)rtl92e_swlps_wq_callback); + INIT_DELAYED_WORK(&rtlpriv->works.ps_rfon_wq, + (void *)rtl92e_swlps_rfon_wq_callback); + INIT_DELAYED_WORK(&rtlpriv->works.fwevt_wq, + (void *)rtl92e_fwevt_wq_callback); +} + +void rtl92e_deinit_deferred_work(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + del_timer_sync(&rtlpriv->works.watchdog_timer); + + cancel_delayed_work(&rtlpriv->works.watchdog_wq); + cancel_delayed_work(&rtlpriv->works.ips_nic_off_wq); + cancel_delayed_work(&rtlpriv->works.ps_work); + cancel_delayed_work(&rtlpriv->works.ps_rfon_wq); + cancel_delayed_work(&rtlpriv->works.fwevt_wq); +} + +void rtl92e_init_rfkill(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + bool radio_state; + bool blocked; + u8 valid = 0; + + /*set init state to on */ + rtlpriv->rfkill.rfkill_state = 1; + wiphy_rfkill_set_hw_state(hw->wiphy, 0); + + radio_state = rtlpriv->cfg->ops->radio_onoff_checking(hw, &valid); + + if (valid) { + pr_info("rtlwifi: wireless switch is %s\n", + rtlpriv->rfkill.rfkill_state ? "on" : "off"); + + rtlpriv->rfkill.rfkill_state = radio_state; + + blocked = (rtlpriv->rfkill.rfkill_state == 1) ? 0 : 1; + wiphy_rfkill_set_hw_state(hw->wiphy, blocked); + } + + wiphy_rfkill_start_polling(hw->wiphy); +} + +void rtl92e_deinit_rfkill(struct ieee80211_hw *hw) +{ + wiphy_rfkill_stop_polling(hw->wiphy); +} + +#ifdef VIF_TODO +static void rtl_init_vif(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + INIT_LIST_HEAD(&rtlpriv->vif_priv.vif_list); + + rtlpriv->vif_priv.vifs = 0; +} +#endif + +int rtl92e_init_core(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *rtlmac = rtl_mac(rtl_priv(hw)); + + /* <1> init mac80211 */ + _rtl_init_mac80211(hw); + rtlmac->hw = hw; + rtlmac->link_state = MAC80211_NOLINK; + + /* <2> rate control register */ + hw->rate_control_algorithm = "rtl_rc"; + + /* + * <3> init CRDA must come after init + * mac80211 hw in _rtl_init_mac80211. + */ + if (rtl92e_regd_init(hw, rtl92e_reg_notifier)) { + RT_TRACE(COMP_ERR, DBG_EMERG, ("REGD init failed\n")); + return 1; + } + + /* <4> locks */ + mutex_init(&rtlpriv->locks.conf_mutex); + spin_lock_init(&rtlpriv->locks.ips_lock); + spin_lock_init(&rtlpriv->locks.irq_th_lock); + spin_lock_init(&rtlpriv->locks.h2c_lock); + spin_lock_init(&rtlpriv->locks.rf_ps_lock); + spin_lock_init(&rtlpriv->locks.rf_lock); + spin_lock_init(&rtlpriv->locks.lps_lock); + spin_lock_init(&rtlpriv->locks.waitq_lock); + spin_lock_init(&rtlpriv->locks.entry_list_lock); + spin_lock_init(&rtlpriv->locks.cck_and_rw_pagea_lock); + spin_lock_init(&rtlpriv->locks.check_sendpkt_lock); + spin_lock_init(&rtlpriv->locks.fw_ps_lock); + spin_lock_init(&rtlpriv->locks.iqk_lock); + /* <5> init list */ + INIT_LIST_HEAD(&rtlpriv->entry_list); + + /* <6> init deferred work */ + _rtl_init_deferred_work(hw); + + /* <7> */ +#ifdef VIF_TODO + rtl_init_vif(hw); +#endif + + return 0; +} + +void rtl92e_deinit_core(struct ieee80211_hw *hw) +{ +} + +void rtl92e_init_rx_config(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + + rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_RCR, (u8 *)(&mac->rx_conf)); +} + +/********************************************************* + * + * tx information functions + * + *********************************************************/ +static void _rtl_qurey_shortpreamble_mode(struct ieee80211_hw *hw, + struct rtl_tcb_desc *tcb_desc, + struct ieee80211_tx_info *info) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u8 rate_flag = info->control.rates[0].flags; + + tcb_desc->use_shortpreamble = false; + + /* 1M can only use Long Preamble. 11B spec */ + if (tcb_desc->hw_rate == rtlpriv->cfg->maps[RTL_RC_CCK_RATE1M]) + return; + else if (rate_flag & IEEE80211_TX_RC_USE_SHORT_PREAMBLE) + tcb_desc->use_shortpreamble = true; + + return; +} + +static void _rtl_query_shortgi(struct ieee80211_hw *hw, + struct ieee80211_sta *sta, + struct rtl_tcb_desc *tcb_desc, + struct ieee80211_tx_info *info) +{ + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + u8 rate_flag = info->control.rates[0].flags; + u8 sgi_40 = 0, sgi_20 = 0, bw_40 = 0; + u8 sgi_80 = 0, bw_80 = 0; + tcb_desc->use_shortgi = false; + + if (sta == NULL) + return; + + sgi_40 = sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40; + sgi_20 = sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20; + sgi_80 = sta->vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_80; + + if (!(sta->ht_cap.ht_supported) && !(sta->vht_cap.vht_supported)) + return; + + if (!sgi_40 && !sgi_20) + return; + + if (mac->opmode == NL80211_IFTYPE_STATION) { + bw_40 = mac->bw_40; + bw_80 = mac->bw_80; + } else if (mac->opmode == NL80211_IFTYPE_AP || + mac->opmode == NL80211_IFTYPE_ADHOC || + mac->opmode == NL80211_IFTYPE_MESH_POINT) { + bw_40 = sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40; + bw_80 = sta->vht_cap.vht_supported; + } + + if (bw_80) { + if (sgi_80) + tcb_desc->use_shortgi = true; + else + tcb_desc->use_shortgi = false; + } else { + if (bw_40 && sgi_40) + tcb_desc->use_shortgi = true; + else if (!bw_40 && sgi_20) + tcb_desc->use_shortgi = true; + } + + if (!(rate_flag & IEEE80211_TX_RC_SHORT_GI)) + tcb_desc->use_shortgi = false; +} + +static void _rtl_query_protection_mode(struct ieee80211_hw *hw, + struct rtl_tcb_desc *tcb_desc, + struct ieee80211_tx_info *info) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u8 rate_flag = info->control.rates[0].flags; + + /* Common Settings */ + tcb_desc->b_rts_stbc = false; + tcb_desc->b_cts_enable = false; + tcb_desc->rts_sc = 0; + tcb_desc->b_rts_bw = false; + tcb_desc->b_rts_use_shortpreamble = false; + tcb_desc->b_rts_use_shortgi = false; + + if (rate_flag & IEEE80211_TX_RC_USE_CTS_PROTECT) { + /* Use CTS-to-SELF in protection mode. */ + tcb_desc->b_rts_enable = true; + tcb_desc->b_cts_enable = true; + tcb_desc->rts_rate = rtlpriv->cfg->maps[RTL_RC_OFDM_RATE24M]; + } else if (rate_flag & IEEE80211_TX_RC_USE_RTS_CTS) { + /* Use RTS-CTS in protection mode. */ + tcb_desc->b_rts_enable = true; + tcb_desc->rts_rate = rtlpriv->cfg->maps[RTL_RC_OFDM_RATE24M]; + } +} + +static void _rtl_txrate_selectmode(struct ieee80211_hw *hw, + struct ieee80211_sta *sta, + struct rtl_tcb_desc *tcb_desc) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct rtl_sta_info *sta_entry = NULL; + u8 ratr_index = 7; + + if (sta) { + sta_entry = (struct rtl_sta_info *)sta->drv_priv; + ratr_index = sta_entry->ratr_index; + } + if (!tcb_desc->disable_ratefallback || !tcb_desc->use_driver_rate) { + if (mac->opmode == NL80211_IFTYPE_STATION) { + tcb_desc->ratr_index = 0; + } else if (mac->opmode == NL80211_IFTYPE_ADHOC || + mac->opmode == NL80211_IFTYPE_MESH_POINT) { + if (tcb_desc->b_multicast || tcb_desc->b_broadcast) { + tcb_desc->hw_rate = + rtlpriv->cfg->maps[RTL_RC_CCK_RATE2M]; + tcb_desc->use_driver_rate = 1; + tcb_desc->ratr_index = RATR_INX_WIRELESS_MC; + } else { + tcb_desc->ratr_index = ratr_index; + } + } else if (mac->opmode == NL80211_IFTYPE_AP) { + tcb_desc->ratr_index = ratr_index; + } + } + + if (rtlpriv->dm.b_useramask) { + tcb_desc->ratr_index = ratr_index; + /* TODO we will differentiate adhoc and station futrue */ + if (mac->opmode == NL80211_IFTYPE_STATION || + mac->opmode == NL80211_IFTYPE_MESH_POINT) { + tcb_desc->mac_id = 0; + + if (mac->mode == WIRELESS_MODE_AC_5G) + tcb_desc->ratr_index = + RATR_INX_WIRELESS_AC_5N; + else if (mac->mode == WIRELESS_MODE_AC_24G) + tcb_desc->ratr_index = + RATR_INX_WIRELESS_AC_24N; + else if (mac->mode == WIRELESS_MODE_N_24G) + tcb_desc->ratr_index = RATR_INX_WIRELESS_NGB; + else if (mac->mode == WIRELESS_MODE_N_5G) + tcb_desc->ratr_index = RATR_INX_WIRELESS_NG; + else if (mac->mode & WIRELESS_MODE_G) + tcb_desc->ratr_index = RATR_INX_WIRELESS_GB; + else if (mac->mode & WIRELESS_MODE_B) + tcb_desc->ratr_index = RATR_INX_WIRELESS_B; + else if (mac->mode & WIRELESS_MODE_A) + tcb_desc->ratr_index = RATR_INX_WIRELESS_G; + + } else if (mac->opmode == NL80211_IFTYPE_AP || + mac->opmode == NL80211_IFTYPE_ADHOC) { + if (sta) { + if (sta->aid > 0) + tcb_desc->mac_id = sta->aid + 1; + else + tcb_desc->mac_id = 1; + } else { + tcb_desc->mac_id = 0; + } + } + } +} + +static void _rtl_query_bandwidth_mode(struct ieee80211_hw *hw, + struct ieee80211_sta *sta, + struct rtl_tcb_desc *tcb_desc) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + + tcb_desc->packet_bw = 0; + if (!sta) + return; + if (mac->opmode == NL80211_IFTYPE_AP || + mac->opmode == NL80211_IFTYPE_ADHOC || + mac->opmode == NL80211_IFTYPE_MESH_POINT) { + if (!(sta->ht_cap.ht_supported) || + !(sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40)) + return; + } else if (mac->opmode == NL80211_IFTYPE_STATION) { + if (!mac->bw_40 || !(sta->ht_cap.ht_supported)) + return; + } + if (tcb_desc->b_multicast || tcb_desc->b_broadcast) + return; + + /*use legency rate, shall use 20MHz */ + if (tcb_desc->hw_rate <= rtlpriv->cfg->maps[RTL_RC_OFDM_RATE54M]) + return; + + tcb_desc->packet_bw = HT_CHANNEL_WIDTH_20_40; + + if (rtlpriv->rtlhal.hw_type == HARDWARE_TYPE_RTL8812AE || + rtlpriv->rtlhal.hw_type == HARDWARE_TYPE_RTL8821AE) { + if (mac->opmode == NL80211_IFTYPE_AP || + mac->opmode == NL80211_IFTYPE_ADHOC || + mac->opmode == NL80211_IFTYPE_MESH_POINT) { + if (!(sta->vht_cap.vht_supported)) { + return; + } else if (mac->opmode == NL80211_IFTYPE_STATION) { + if (!mac->bw_80 || + !(sta->vht_cap.vht_supported)) + return; + } + } + if (tcb_desc->hw_rate <= + rtlpriv->cfg->maps[RTL_RC_HT_RATEMCS15]) + return; + tcb_desc->packet_bw = HT_CHANNEL_WIDTH_80; + } +} + +static u8 _rtl_get_vht_highest_n_rate(struct ieee80211_hw *hw, + struct ieee80211_sta *sta) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + u8 hw_rate; + u16 map = le16_to_cpu(sta->vht_cap.vht_mcs.tx_mcs_map); + + if ((get_rf_type(rtlphy) == RF_2T2R) && + (map & 0x000c) != 0x000c0) { + if ((map & 0x000c) >> 2 == IEEE80211_VHT_MCS_SUPPORT_0_7) + hw_rate = + rtlpriv->cfg->maps[RTL_RC_VHT_RATE_2SS_MCS7]; + else if ((map & 0x000c) >> 2 == IEEE80211_VHT_MCS_SUPPORT_0_8) + hw_rate = rtlpriv->cfg->maps[RTL_RC_VHT_RATE_2SS_MCS9]; + else + hw_rate = rtlpriv->cfg->maps[RTL_RC_VHT_RATE_2SS_MCS9]; + } else { + if ((map & 0x0003) == IEEE80211_VHT_MCS_SUPPORT_0_7) + hw_rate = rtlpriv->cfg->maps[RTL_RC_VHT_RATE_1SS_MCS7]; + else if ((map & 0x0003) == IEEE80211_VHT_MCS_SUPPORT_0_8) + hw_rate = rtlpriv->cfg->maps[RTL_RC_VHT_RATE_1SS_MCS9]; + else + hw_rate = rtlpriv->cfg->maps[RTL_RC_VHT_RATE_1SS_MCS9]; + } + + return hw_rate; +} + +static u8 _rtl_get_highest_n_rate(struct ieee80211_hw *hw, + struct ieee80211_sta *sta) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + u8 hw_rate; + + if ((get_rf_type(rtlphy) == RF_2T2R) && + (sta->ht_cap.mcs.rx_mask[1] != 0)) + hw_rate = rtlpriv->cfg->maps[RTL_RC_HT_RATEMCS15]; + else + hw_rate = rtlpriv->cfg->maps[RTL_RC_HT_RATEMCS7]; + + return hw_rate; +} + +void stg_rtl_get_tcb_desc(struct ieee80211_hw *hw, + struct ieee80211_tx_info *info, + struct ieee80211_sta *sta, + struct sk_buff *skb, struct rtl_tcb_desc *tcb_desc) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *rtlmac = rtl_mac(rtl_priv(hw)); + struct ieee80211_hdr *hdr = rtl_get_hdr(skb); + struct ieee80211_rate *txrate; + __le16 fc = rtl_get_fc(skb); + + txrate = ieee80211_get_tx_rate(hw, info); + if (txrate != NULL) + tcb_desc->hw_rate = txrate->hw_value; + + if (ieee80211_is_data(fc)) { + /* + *we set data rate INX 0 + *in rtl_rc.c if skb is special data or + *mgt which need low data rate. + */ + + /* + *So tcb_desc->hw_rate is just used for + *special data and mgt frames + */ + if (info->control.rates[0].idx == 0 || + ieee80211_is_nullfunc(fc)) { + tcb_desc->use_driver_rate = true; + tcb_desc->ratr_index = RATR_INX_WIRELESS_MC; + + tcb_desc->disable_ratefallback = 1; + } else { + /* + *because hw will nerver use hw_rate + *when tcb_desc->use_driver_rate = false + *so we never set highest N rate here, + *and N rate will all be controled by FW + *when tcb_desc->use_driver_rate = false + */ + if (sta && sta->vht_cap.vht_supported) { + tcb_desc->hw_rate = + _rtl_get_vht_highest_n_rate(hw, sta); + } else if (sta && (sta->ht_cap.ht_supported)) { + tcb_desc->hw_rate = + _rtl_get_highest_n_rate(hw, sta); + } else { + if (rtlmac->mode == WIRELESS_MODE_B) { + tcb_desc->hw_rate = + rtlpriv->cfg->maps[RTL_RC_CCK_RATE11M]; + } else { + tcb_desc->hw_rate = + rtlpriv->cfg->maps[RTL_RC_OFDM_RATE54M]; + } + } + } + + if (is_multicast_ether_addr(ieee80211_get_DA(hdr))) + tcb_desc->b_multicast = 1; + else if (is_broadcast_ether_addr(ieee80211_get_DA(hdr))) + tcb_desc->b_broadcast = 1; + + _rtl_txrate_selectmode(hw, sta, tcb_desc); + _rtl_query_bandwidth_mode(hw, sta, tcb_desc); + _rtl_qurey_shortpreamble_mode(hw, tcb_desc, info); + _rtl_query_shortgi(hw, sta, tcb_desc, info); + _rtl_query_protection_mode(hw, tcb_desc, info); + } else { + tcb_desc->use_driver_rate = true; + tcb_desc->ratr_index = RATR_INX_WIRELESS_MC; + tcb_desc->disable_ratefallback = 1; + tcb_desc->mac_id = 0; + tcb_desc->packet_bw = 0; + } +} +EXPORT_SYMBOL(stg_rtl_get_tcb_desc); + +bool rtl92e_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb) +{ + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct rtl_priv *rtlpriv = rtl_priv(hw); + __le16 fc = rtl_get_fc(skb); + + if (rtlpriv->dm.supp_phymode_switch && + mac->link_state < MAC80211_LINKED && + (ieee80211_is_auth(fc) || ieee80211_is_probe_req(fc))) { + if (rtlpriv->cfg->ops->check_switch_to_dmdp) + rtlpriv->cfg->ops->check_switch_to_dmdp(hw); + } + if (ieee80211_is_auth(fc)) { + RT_TRACE(COMP_SEND, DBG_DMESG, ("MAC80211_LINKING\n")); + rtl92e_ips_nic_on(hw); + + mac->link_state = MAC80211_LINKING; + /* Dul mac */ + rtlpriv->phy.b_need_iqk = true; + } + return true; +} + +struct sk_buff *rtl92e_make_del_ba(struct ieee80211_hw *hw, u8 *sa, + u8 *bssid, u16 tid); + +bool rtl92e_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx) +{ + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct ieee80211_hdr *hdr = rtl_get_hdr(skb); + struct rtl_priv *rtlpriv = rtl_priv(hw); + __le16 fc = rtl_get_fc(skb); + u8 *act = (u8 *)(((u8 *)skb->data + MAC80211_3ADDR_LEN)); + u8 category; + + if (!ieee80211_is_action(fc)) + return true; + + category = *act; + act++; + switch (category) { + case ACT_CAT_BA: + switch (*act) { + case ACT_ADDBAREQ: + if (mac->act_scanning) + return false; + + RT_TRACE((COMP_SEND | COMP_RECV), DBG_DMESG, + ("%s ACT_ADDBAREQ From:%pM\n", + is_tx ? "Tx" : "Rx", hdr->addr2)); + RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, "req\n", + skb->data, skb->len); + if (!is_tx) { + struct ieee80211_sta *sta = NULL; + struct rtl_sta_info *sta_entry = NULL; + struct ieee80211_mgmt *mgmt = (void *)skb->data; + u16 capab = 0, tid = 0; + struct rtl_tid_data *tid_data; + struct sk_buff *skb_delba = NULL; + struct ieee80211_rx_status rx_status = { 0 }; + + rcu_read_lock(); + sta = rtl_find_sta(hw, hdr->addr3); + if (sta == NULL) { + RT_TRACE((COMP_SEND | COMP_RECV), + DBG_TRACE, ("sta is NULL\n")); + rcu_read_unlock(); + return true; + } + + sta_entry = + (struct rtl_sta_info *)sta->drv_priv; + if (!sta_entry) { + rcu_read_unlock(); + return true; + } + capab = le16_to_cpu(mgmt->u.action.u.addba_req.capab); + tid = (capab & + IEEE80211_ADDBA_PARAM_TID_MASK) >> 2; + tid_data = &sta_entry->tids[tid]; + if (tid_data->agg.rx_agg_state == + RTL_RX_AGG_START) { + skb_delba = rtl92e_make_del_ba(hw, + hdr->addr2, + hdr->addr3, + tid); + if (skb_delba) { + rx_status.freq = + hw->conf.chandef.chan->center_freq; + rx_status.band = + hw->conf.chandef.chan->band; + rx_status.flag |= RX_FLAG_DECRYPTED; + rx_status.flag |= RX_FLAG_MACTIME_MPDU; + rx_status.rate_idx = 0; + rx_status.signal = 50 + 10; + memcpy(IEEE80211_SKB_RXCB(skb_delba), + &rx_status, sizeof(rx_status)); + RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, + "fake del\n", + skb_delba->data, skb_delba->len); + ieee80211_rx_irqsafe(hw, skb_delba); + } + } + rcu_read_unlock(); + } + break; + case ACT_ADDBARSP: + RT_TRACE((COMP_SEND | COMP_RECV), DBG_DMESG, + ("%s ACT_ADDBARSP From :%pM\n", + is_tx ? "Tx" : "Rx", hdr->addr2)); + break; + case ACT_DELBA: + RT_TRACE((COMP_SEND | COMP_RECV), DBG_DMESG, + ("ACT_ADDBADEL From :%pM\n", hdr->addr2)); + break; + } + break; + default: + break; + } + + return true; +} + +/*should call before software enc*/ +u8 rtl92e_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, + u8 is_tx) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + __le16 fc = rtl_get_fc(skb); + u16 ether_type; + u8 mac_hdr_len = ieee80211_get_hdrlen_from_skb(skb); + const struct iphdr *ip; + + if (!ieee80211_is_data(fc)) + goto end; + + ip = (struct iphdr *)((u8 *)skb->data + mac_hdr_len + + SNAP_SIZE + PROTOC_TYPE_SIZE); + ether_type = be16_to_cpup((__be16 *) + (skb->data + mac_hdr_len + SNAP_SIZE)); + + if (ETH_P_IP == ether_type) { + if (IPPROTO_UDP == ip->protocol) { + struct udphdr *udp = (struct udphdr *)((u8 *)ip + + (ip->ihl << 2)); + if (((((u8 *)udp)[1] == 68) && + (((u8 *)udp)[3] == 67)) || + ((((u8 *)udp)[1] == 67) && + (((u8 *)udp)[3] == 68))) { + /* + * 68 : UDP BOOTP client + * 67 : UDP BOOTP server + */ + RT_TRACE((COMP_SEND | COMP_RECV), + DBG_DMESG, ("dhcp %s !!\n", + (is_tx) ? "Tx" : "Rx")); + + if (is_tx) { + rtlpriv->ra.is_special_data = true; + if (rtlpriv->cfg->ops->get_btc_status()) + rtlpriv->btcoexist.btc_ops->btc_special_packet_notify( + rtlpriv, 1); + rtl92e_lps_leave(hw); + ppsc->last_delaylps_stamp_jiffies = + jiffies; + } + + return true; + } + } + } else if (ETH_P_ARP == ether_type) { + if (is_tx) { + rtlpriv->ra.is_special_data = true; + if (rtlpriv->cfg->ops->get_btc_status()) + rtlpriv->btcoexist.btc_ops->btc_special_packet_notify( + rtlpriv, 1); + rtl92e_lps_leave(hw); + ppsc->last_delaylps_stamp_jiffies = jiffies; + } + + return true; + } else if (ETH_P_PAE == ether_type) { + RT_TRACE((COMP_SEND | COMP_RECV), DBG_DMESG, + ("802.1X %s EAPOL pkt!!\n", (is_tx) ? "Tx" : "Rx")); + + if (is_tx) { + rtlpriv->ra.is_special_data = true; + rtl92e_lps_leave(hw); + ppsc->last_delaylps_stamp_jiffies = jiffies; + } + + return true; + } else if (0x86DD == ether_type) { + return true; + } + +end: + rtlpriv->ra.is_special_data = false; + return false; +} + +/********************************************************* + * + * functions called by core.c + * + *********************************************************/ +int rtl92e_tx_agg_start(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_sta *sta, u16 tid, u16 *ssn) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_tid_data *tid_data; + struct rtl_sta_info *sta_entry = NULL; + + if (sta == NULL) + return -EINVAL; + + if (unlikely(tid >= MAX_TID_COUNT)) + return -EINVAL; + + sta_entry = (struct rtl_sta_info *)sta->drv_priv; + if (!sta_entry) + return -ENXIO; + tid_data = &sta_entry->tids[tid]; + + RT_TRACE(COMP_SEND, DBG_DMESG, + ("on ra = %pM tid = %d seq:%d\n", sta->addr, tid, + tid_data->seq_number)); + + *ssn = tid_data->seq_number; + tid_data->agg.agg_state = RTL_AGG_START; + + ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid); + return 0; +} + +int rtl92e_tx_agg_stop(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_sta *sta, u16 tid) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_tid_data *tid_data; + struct rtl_sta_info *sta_entry = NULL; + + if (sta == NULL) + return -EINVAL; + + /* Comparing an array to null is not useful */ + /*if (!sta->addr) { + RT_TRACE(COMP_ERR, DBG_EMERG, ("ra = NULL\n")); + return -EINVAL; + }*/ + + RT_TRACE(COMP_SEND, DBG_DMESG, + ("on ra = %pM tid = %d\n", sta->addr, tid)); + + if (unlikely(tid >= MAX_TID_COUNT)) + return -EINVAL; + + sta_entry = (struct rtl_sta_info *)sta->drv_priv; + tid_data = &sta_entry->tids[tid]; + sta_entry->tids[tid].agg.agg_state = RTL_AGG_STOP; + + ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); + return 0; +} + +int rtl92e_rx_agg_start(struct ieee80211_hw *hw, + struct ieee80211_sta *sta, u16 tid) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_tid_data *tid_data; + struct rtl_sta_info *sta_entry = NULL; + + if (sta == NULL) + return -EINVAL; + + if (unlikely(tid >= MAX_TID_COUNT)) + return -EINVAL; + + sta_entry = (struct rtl_sta_info *)sta->drv_priv; + if (!sta_entry) + return -ENXIO; + tid_data = &sta_entry->tids[tid]; + + RT_TRACE(COMP_RECV, DBG_DMESG, + ("on ra = %pM tid = %d seq:%d\n", sta->addr, tid, + tid_data->seq_number)); + + tid_data->agg.rx_agg_state = RTL_RX_AGG_START; + return 0; +} + +int rtl92e_rx_agg_stop(struct ieee80211_hw *hw, + struct ieee80211_sta *sta, u16 tid) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_tid_data *tid_data; + struct rtl_sta_info *sta_entry = NULL; + + if (sta == NULL) + return -EINVAL; + + /* Comparing an array to null is not useful */ + /*if (!sta->addr) { + RT_TRACE(COMP_ERR, DBG_EMERG, ("ra = NULL\n")); + return -EINVAL; + }*/ + + RT_TRACE(COMP_SEND, DBG_DMESG, + ("on ra = %pM tid = %d\n", sta->addr, tid)); + + if (unlikely(tid >= MAX_TID_COUNT)) + return -EINVAL; + + sta_entry = (struct rtl_sta_info *)sta->drv_priv; + tid_data = &sta_entry->tids[tid]; + sta_entry->tids[tid].agg.rx_agg_state = RTL_RX_AGG_STOP; + + return 0; +} + +int rtl92e_tx_agg_oper(struct ieee80211_hw *hw, + struct ieee80211_sta *sta, u16 tid) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_tid_data *tid_data; + struct rtl_sta_info *sta_entry = NULL; + + if (sta == NULL) + return -EINVAL; + + /* Comparing an array to null is not useful */ + /*if (!sta->addr) { + RT_TRACE(COMP_ERR, DBG_EMERG, ("ra = NULL\n")); + return -EINVAL; + }*/ + + RT_TRACE(COMP_SEND, DBG_DMESG, + ("on ra = %pM tid = %d\n", sta->addr, tid)); + + if (unlikely(tid >= MAX_TID_COUNT)) + return -EINVAL; + + sta_entry = (struct rtl_sta_info *)sta->drv_priv; + tid_data = &sta_entry->tids[tid]; + sta_entry->tids[tid].agg.agg_state = RTL_AGG_OPERATIONAL; + + return 0; +} + +/********************************************************* + * + * wq & timer callback functions + * + *********************************************************/ +/* this function is used for roaming */ +void rtl92e_beacon_statistic(struct ieee80211_hw *hw, struct sk_buff *skb) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; + + if (rtlpriv->mac80211.opmode != NL80211_IFTYPE_STATION) + return; + + if (rtlpriv->mac80211.link_state < MAC80211_LINKED) + return; + + /* check if this really is a beacon */ + if (!ieee80211_is_beacon(hdr->frame_control) && + !ieee80211_is_probe_resp(hdr->frame_control)) + return; + + /* min. beacon length + FCS_LEN */ + if (skb->len <= 40 + FCS_LEN) + return; + + /* and only beacons from the associated BSSID, please */ + if (!ether_addr_equal(hdr->addr3, rtlpriv->mac80211.bssid)) + return; + + rtlpriv->link_info.bcn_rx_inperiod++; +} + +void rtl92e_watchdog_wq_callback(void *data) +{ + struct rtl_works *rtlworks = container_of_dwork_rtl(data, + struct rtl_works, + watchdog_wq); + struct ieee80211_hw *hw = rtlworks->hw; + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + bool b_busytraffic = false; + bool b_tx_busy_traffic = false; + bool b_rx_busy_traffic = false; + bool b_higher_busytraffic = false; + bool b_higher_busyrxtraffic = false; + u8 idx, tid; + u32 rx_cnt_inp4eriod = 0; + u32 tx_cnt_inp4eriod = 0; + u32 aver_rx_cnt_inperiod = 0; + u32 aver_tx_cnt_inperiod = 0; + u32 aver_tidtx_inperiod[MAX_TID_COUNT] = {0}; + u32 tidtx_inp4eriod[MAX_TID_COUNT] = {0}; + bool benter_ps = false; + + if (is_hal_stop(rtlhal)) + return; + + /* <1> Determine if action frame is allowed */ + if (mac->link_state > MAC80211_NOLINK) { + if (mac->cnt_after_linked < 20) + mac->cnt_after_linked++; + } else { + mac->cnt_after_linked = 0; + } + + /* <2> to check if traffic busy, if + * busytraffic we don't change channel */ + if (mac->link_state >= MAC80211_LINKED) { + /* (1) get aver_rx_cnt_inperiod & aver_tx_cnt_inperiod */ + for (idx = 0; idx <= 2; idx++) { + rtlpriv->link_info.num_rx_in4period[idx] = + rtlpriv->link_info.num_rx_in4period[idx + 1]; + rtlpriv->link_info.num_tx_in4period[idx] = + rtlpriv->link_info.num_tx_in4period[idx + 1]; + } + rtlpriv->link_info.num_rx_in4period[3] = + rtlpriv->link_info.num_rx_inperiod; + rtlpriv->link_info.num_tx_in4period[3] = + rtlpriv->link_info.num_tx_inperiod; + for (idx = 0; idx <= 3; idx++) { + rx_cnt_inp4eriod += + rtlpriv->link_info.num_rx_in4period[idx]; + tx_cnt_inp4eriod += + rtlpriv->link_info.num_tx_in4period[idx]; + } + aver_rx_cnt_inperiod = rx_cnt_inp4eriod / 4; + aver_tx_cnt_inperiod = tx_cnt_inp4eriod / 4; + + /* (2) check traffic busy */ + if (aver_rx_cnt_inperiod > 100 || aver_tx_cnt_inperiod > 100) { + b_busytraffic = true; + if (aver_rx_cnt_inperiod > aver_tx_cnt_inperiod) + b_rx_busy_traffic = true; + else + b_tx_busy_traffic = false; + } + + /* Higher Tx/Rx data. */ + if (aver_rx_cnt_inperiod > 4000 || + aver_tx_cnt_inperiod > 4000) { + b_higher_busytraffic = true; + + /* Extremely high Rx data. */ + if (aver_rx_cnt_inperiod > 5000) + b_higher_busyrxtraffic = true; + } + + /* check every tid's tx traffic */ + for (tid = 0; tid <= 7; tid++) { + for (idx = 0; idx <= 2; idx++) + rtlpriv->link_info.tidtx_in4period[tid][idx] = + rtlpriv->link_info.tidtx_in4period[tid] + [idx + 1]; + rtlpriv->link_info.tidtx_in4period[tid][3] = + rtlpriv->link_info.tidtx_inperiod[tid]; + + for (idx = 0; idx <= 3; idx++) + tidtx_inp4eriod[tid] += + rtlpriv->link_info.tidtx_in4period[tid][idx]; + aver_tidtx_inperiod[tid] = tidtx_inp4eriod[tid] / 4; + if (aver_tidtx_inperiod[tid] > 5000) + rtlpriv->link_info.higher_busytxtraffic[tid] = + true; + else + rtlpriv->link_info.higher_busytxtraffic[tid] = + false; + } + + if (((rtlpriv->link_info.num_rx_inperiod + + rtlpriv->link_info.num_tx_inperiod) > 8) || + (rtlpriv->link_info.num_rx_inperiod > 2)) + benter_ps = false; + else + benter_ps = true; + + /* LeisurePS only work in infra mode. */ + if (benter_ps) + rtl92e_lps_enter(hw); + else + rtl92e_lps_leave(hw); + } + + rtlpriv->link_info.num_rx_inperiod = 0; + rtlpriv->link_info.num_tx_inperiod = 0; + for (tid = 0; tid <= 7; tid++) + rtlpriv->link_info.tidtx_inperiod[tid] = 0; + + rtlpriv->link_info.b_busytraffic = b_busytraffic; + rtlpriv->link_info.b_rx_busy_traffic = b_rx_busy_traffic; + rtlpriv->link_info.b_tx_busy_traffic = b_tx_busy_traffic; + rtlpriv->link_info.b_higher_busytraffic = b_higher_busytraffic; + rtlpriv->link_info.b_higher_busyrxtraffic = b_higher_busyrxtraffic; + + /* <3> DM */ + rtlpriv->cfg->ops->dm_watchdog(hw); + + /* <4> roaming */ + if (mac->link_state == MAC80211_LINKED && + mac->opmode == NL80211_IFTYPE_STATION) { + if ((rtlpriv->link_info.bcn_rx_inperiod + + rtlpriv->link_info.num_rx_inperiod) == 0) { + rtlpriv->link_info.roam_times++; + RT_TRACE(COMP_ERR, DBG_DMESG, + ("AP off for %d s\n", + (rtlpriv->link_info.roam_times * 2))); + + /* if we can't recv beacon for 10s, + * we should reconnect this AP */ + if (rtlpriv->link_info.roam_times >= 5) { + RT_TRACE(COMP_ERR, DBG_EMERG, + ("AP off, try to reconnect now\n")); + rtlpriv->link_info.roam_times = 0; + ieee80211_connection_loss( + rtlpriv->mac80211.vif); + } + } else { + rtlpriv->link_info.roam_times = 0; + } + } + + if (rtlpriv->cfg->ops->get_btc_status()) + rtlpriv->btcoexist.btc_ops->btc_periodical(rtlpriv); + + rtlpriv->link_info.bcn_rx_inperiod = 0; +} + +void rtl92e_watch_dog_timer_callback(unsigned long data) +{ + struct ieee80211_hw *hw = (struct ieee80211_hw *)data; + struct rtl_priv *rtlpriv = rtl_priv(hw); + + queue_delayed_work(rtlpriv->works.rtl_wq, + &rtlpriv->works.watchdog_wq, 0); + + mod_timer(&rtlpriv->works.watchdog_timer, + jiffies + MSECS(RTL_WATCH_DOG_TIME)); +} +void rtl92e_fwevt_wq_callback(void *data) +{ + struct rtl_works *rtlworks = + container_of_dwork_rtl(data, struct rtl_works, fwevt_wq); + struct ieee80211_hw *hw = rtlworks->hw; + struct rtl_priv *rtlpriv = rtl_priv(hw); + + rtlpriv->cfg->ops->c2h_command_handle(hw); +} +void rtl92e_easy_concurrent_retrytimer_callback(unsigned long data) +{ + struct ieee80211_hw *hw = (struct ieee80211_hw *)data; + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_priv *buddy_priv = rtlpriv->buddy_priv; + + if (buddy_priv == NULL) + return; + + rtlpriv->cfg->ops->dualmac_easy_concurrent(hw); +} +/********************************************************* + * + * frame process functions + * + *********************************************************/ +u8 *rtl92e_find_ie(u8 *data, unsigned int len, u8 ie) +{ + struct ieee80211_mgmt *mgmt = (void *)data; + u8 *pos, *end; + + pos = (u8 *)mgmt->u.beacon.variable; + end = data + len; + while (pos < end) { + if (pos + 2 + pos[1] > end) + return NULL; + + if (pos[0] == ie) + return pos; + + pos += 2 + pos[1]; + } + return NULL; +} + +/* when we use 2 rx ants we send IEEE80211_SMPS_OFF */ +/* when we use 1 rx ant we send IEEE80211_SMPS_STATIC */ +static struct sk_buff *rtl_make_smps_action(struct ieee80211_hw *hw, + enum ieee80211_smps_mode smps, + u8 *da, u8 *bssid) +{ + struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); + struct sk_buff *skb; + struct ieee80211_mgmt_compat *action_frame; + + /* 27 = header + category + action + smps mode */ + skb = dev_alloc_skb(27 + hw->extra_tx_headroom); + if (!skb) + return NULL; + + skb_reserve(skb, hw->extra_tx_headroom); + action_frame = (void *)skb_put(skb, 27); + memset(action_frame, 0, 27); + ether_addr_copy(action_frame->da, da); + ether_addr_copy(action_frame->sa, rtlefuse->dev_addr); + ether_addr_copy(action_frame->bssid, bssid); + action_frame->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | + IEEE80211_STYPE_ACTION); + action_frame->u.action.category = WLAN_CATEGORY_HT; + action_frame->u.action.u.ht_smps.action = WLAN_HT_ACTION_SMPS; + switch (smps) { + case IEEE80211_SMPS_AUTOMATIC:/* 0 */ + case IEEE80211_SMPS_NUM_MODES:/* 4 */ + WARN_ON(1); + /* Here will get a 'MISSING_BREAK' in Coverity Test, just ignore it. + * According to Kernel Code, here is right. + */ + case IEEE80211_SMPS_OFF:/* 1 */ /*MIMO_PS_NOLIMIT*/ + action_frame->u.action.u.ht_smps.smps_control = + WLAN_HT_SMPS_CONTROL_DISABLED;/* 0 */ + break; + case IEEE80211_SMPS_STATIC:/* 2 */ /*MIMO_PS_STATIC*/ + action_frame->u.action.u.ht_smps.smps_control = + WLAN_HT_SMPS_CONTROL_STATIC;/* 1 */ + break; + case IEEE80211_SMPS_DYNAMIC:/* 3 */ /*MIMO_PS_DYNAMIC*/ + action_frame->u.action.u.ht_smps.smps_control = + WLAN_HT_SMPS_CONTROL_DYNAMIC;/* 3 */ + break; + } + + return skb; +} + +int stg_rtl_send_smps_action(struct ieee80211_hw *hw, + struct ieee80211_sta *sta, + enum ieee80211_smps_mode smps) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + struct sk_buff *skb = NULL; + struct rtl_tcb_desc tcb_desc; + u8 bssid[ETH_ALEN] = {0}; + + memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc)); + + if (rtlpriv->mac80211.act_scanning) + goto err_free; + + if (!sta) + goto err_free; + + if (unlikely(is_hal_stop(rtlhal) || ppsc->rfpwr_state != ERFON)) + goto err_free; + + if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status)) + goto err_free; + + if (rtlpriv->mac80211.opmode == NL80211_IFTYPE_AP) + ether_addr_copy(bssid, rtlpriv->efuse.dev_addr); + else + ether_addr_copy(bssid, rtlpriv->mac80211.bssid); + + skb = rtl_make_smps_action(hw, smps, sta->addr, bssid); + /* this is a type = mgmt * stype = action frame */ + if (skb) { + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct rtl_sta_info *sta_entry = + (struct rtl_sta_info *)sta->drv_priv; + sta_entry->mimo_ps = smps; + /* rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0); */ + + info->control.rates[0].idx = 0; + info->band = hw->conf.chandef.chan->band; + rtlpriv->intf_ops->adapter_tx(hw, sta, skb, &tcb_desc); + } + return 1; + +err_free: + return 0; +} +EXPORT_SYMBOL(stg_rtl_send_smps_action); + +/* because mac80211 have issues when can receive del ba + * so here we just make a fake del_ba if we receive a ba_req + * but rx_agg was opened to let mac80211 release some ba + * related resources, so please this del_ba for tx */ +struct sk_buff *rtl92e_make_del_ba(struct ieee80211_hw *hw, + u8 *sa, u8 *bssid, u16 tid) +{ + struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); + struct sk_buff *skb; + struct ieee80211_mgmt *action_frame; + u16 params; + + /* 27 = header + category + action + smps mode */ + skb = dev_alloc_skb(34 + hw->extra_tx_headroom); + if (!skb) + return NULL; + + skb_reserve(skb, hw->extra_tx_headroom); + action_frame = (void *)skb_put(skb, 34); + memset(action_frame, 0, 34); + ether_addr_copy(action_frame->sa, sa); + ether_addr_copy(action_frame->da, rtlefuse->dev_addr); + ether_addr_copy(action_frame->bssid, bssid); + action_frame->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | + IEEE80211_STYPE_ACTION); + action_frame->u.action.category = WLAN_CATEGORY_BACK; + action_frame->u.action.u.delba.action_code = WLAN_ACTION_DELBA; + params = (u16)(1 << 11); /* bit 11 initiator */ + params |= (u16)(tid << 12); /* bit 15:12 TID number */ + + action_frame->u.action.u.delba.params = cpu_to_le16(params); + action_frame->u.action.u.delba.reason_code = + cpu_to_le16(WLAN_REASON_QSTA_TIMEOUT); + + return skb; +} + +/********************************************************* + * + * IOT functions + * + *********************************************************/ +static bool rtl_chk_vendor_ouisub(struct ieee80211_hw *hw, + struct octet_string vendor_ie) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + bool matched = false; + static u8 athcap_1[] = { 0x00, 0x03, 0x7F }; + static u8 athcap_2[] = { 0x00, 0x13, 0x74 }; + static u8 broadcap_1[] = { 0x00, 0x10, 0x18 }; + static u8 broadcap_2[] = { 0x00, 0x0a, 0xf7 }; + static u8 broadcap_3[] = { 0x00, 0x05, 0xb5 }; + static u8 racap[] = { 0x00, 0x0c, 0x43 }; + static u8 ciscocap[] = { 0x00, 0x40, 0x96 }; + static u8 marvcap[] = { 0x00, 0x50, 0x43 }; + + if (memcmp(vendor_ie.octet, athcap_1, 3) == 0 || + memcmp(vendor_ie.octet, athcap_2, 3) == 0) { + rtlpriv->mac80211.vendor = PEER_ATH; + matched = true; + } else if (memcmp(vendor_ie.octet, broadcap_1, 3) == 0 || + memcmp(vendor_ie.octet, broadcap_2, 3) == 0 || + memcmp(vendor_ie.octet, broadcap_3, 3) == 0) { + rtlpriv->mac80211.vendor = PEER_BROAD; + matched = true; + } else if (memcmp(vendor_ie.octet, racap, 3) == 0) { + rtlpriv->mac80211.vendor = PEER_RAL; + matched = true; + } else if (memcmp(vendor_ie.octet, ciscocap, 3) == 0) { + rtlpriv->mac80211.vendor = PEER_CISCO; + matched = true; + } else if (memcmp(vendor_ie.octet, marvcap, 3) == 0) { + rtlpriv->mac80211.vendor = PEER_MARV; + matched = true; + } + + return matched; +} + +static bool rtl_find_221_ie(struct ieee80211_hw *hw, u8 *data, unsigned int len) +{ + struct ieee80211_mgmt *mgmt = (void *)data; + struct octet_string vendor_ie; + u8 *pos, *end; + + pos = (u8 *)mgmt->u.beacon.variable; + end = data + len; + while (pos < end) { + if (pos[0] == 221) { + vendor_ie.length = pos[1]; + vendor_ie.octet = &pos[2]; + if (rtl_chk_vendor_ouisub(hw, vendor_ie)) + return true; + } + + if (pos + 2 + pos[1] > end) + return false; + + pos += 2 + pos[1]; + } + return false; +} + +void rtl92e_recognize_peer(struct ieee80211_hw *hw, u8 *data, unsigned int len) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct ieee80211_hdr *hdr = (void *)data; + u32 vendor = PEER_UNKNOWN; + + static u8 ap3_1[3] = { 0x00, 0x14, 0xbf }; + static u8 ap3_2[3] = { 0x00, 0x1a, 0x70 }; + static u8 ap3_3[3] = { 0x00, 0x1d, 0x7e }; + static u8 ap4_1[3] = { 0x00, 0x90, 0xcc }; + static u8 ap4_2[3] = { 0x00, 0x0e, 0x2e }; + static u8 ap4_3[3] = { 0x00, 0x18, 0x02 }; + static u8 ap4_4[3] = { 0x00, 0x17, 0x3f }; + static u8 ap4_5[3] = { 0x00, 0x1c, 0xdf }; + static u8 ap5_1[3] = { 0x00, 0x1c, 0xf0 }; + static u8 ap5_2[3] = { 0x00, 0x21, 0x91 }; + static u8 ap5_3[3] = { 0x00, 0x24, 0x01 }; + static u8 ap5_4[3] = { 0x00, 0x15, 0xe9 }; + static u8 ap5_5[3] = { 0x00, 0x17, 0x9A }; + static u8 ap5_6[3] = { 0x00, 0x18, 0xE7 }; + static u8 ap6_1[3] = { 0x00, 0x17, 0x94 }; + static u8 ap7_1[3] = { 0x00, 0x14, 0xa4 }; + + if (mac->opmode != NL80211_IFTYPE_STATION) + return; + + if (mac->link_state == MAC80211_NOLINK) { + mac->vendor = PEER_UNKNOWN; + return; + } + + if (mac->cnt_after_linked > 2) + return; + + /* check if this really is a beacon */ + if (!ieee80211_is_beacon(hdr->frame_control)) + return; + + /* min. beacon length + FCS_LEN */ + if (len <= 40 + FCS_LEN) + return; + + /* and only beacons from the associated BSSID, please */ + if (!ether_addr_equal(hdr->addr3, rtlpriv->mac80211.bssid)) + return; + + if (rtl_find_221_ie(hw, data, len)) + vendor = mac->vendor; + + if ((memcmp(mac->bssid, ap5_1, 3) == 0) || + (memcmp(mac->bssid, ap5_2, 3) == 0) || + (memcmp(mac->bssid, ap5_3, 3) == 0) || + (memcmp(mac->bssid, ap5_4, 3) == 0) || + (memcmp(mac->bssid, ap5_5, 3) == 0) || + (memcmp(mac->bssid, ap5_6, 3) == 0) || + vendor == PEER_ATH) { + vendor = PEER_ATH; + RT_TRACE(COMP_MAC80211, DBG_LOUD, ("=>ath find\n")); + } else if ((memcmp(mac->bssid, ap4_4, 3) == 0) || + (memcmp(mac->bssid, ap4_5, 3) == 0) || + (memcmp(mac->bssid, ap4_1, 3) == 0) || + (memcmp(mac->bssid, ap4_2, 3) == 0) || + (memcmp(mac->bssid, ap4_3, 3) == 0) || + vendor == PEER_RAL) { + RT_TRACE(COMP_MAC80211, DBG_LOUD, ("=>ral findn\n")); + vendor = PEER_RAL; + } else if (memcmp(mac->bssid, ap6_1, 3) == 0 || + vendor == PEER_CISCO) { + vendor = PEER_CISCO; + RT_TRACE(COMP_MAC80211, DBG_LOUD, ("=>cisco find\n")); + } else if ((memcmp(mac->bssid, ap3_1, 3) == 0) || + (memcmp(mac->bssid, ap3_2, 3) == 0) || + (memcmp(mac->bssid, ap3_3, 3) == 0) || + vendor == PEER_BROAD) { + RT_TRACE(COMP_MAC80211, DBG_LOUD, ("=>broad find\n")); + vendor = PEER_BROAD; + } else if (memcmp(mac->bssid, ap7_1, 3) == 0 || + vendor == PEER_MARV) { + vendor = PEER_MARV; + RT_TRACE(COMP_MAC80211, DBG_LOUD, ("=>marv find\n")); + } + + mac->vendor = vendor; +} + +/********************************************************* + * + * sysfs functions + * + *********************************************************/ +struct rtl_global_var global_var = {}; + +int rtl_core_module_init(void) +{ + static int here_once; + + if (here_once++) + return 0; + + if (rtl92e_rate_control_register()) + pr_debug("rtl: Unable to register rtl_rc, use default RC !!\n"); + + /* init some global vars */ + INIT_LIST_HEAD(&global_var.glb_priv_list); + spin_lock_init(&global_var.glb_list_lock); + + return 0; +} +void rtl_core_module_exit(void) +{ + /*RC*/ + rtl92e_rate_control_unregister(); +} diff --git a/drivers/staging/rtl8192ee/base.h b/drivers/staging/rtl8192ee/base.h new file mode 100644 index 000000000000..c7929a7b02fd --- /dev/null +++ b/drivers/staging/rtl8192ee/base.h @@ -0,0 +1,163 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#ifndef __RTL_BASE_H__ +#define __RTL_BASE_H__ + +#include "compat.h" + +enum ap_peer { + PEER_UNKNOWN = 0, + PEER_RTL = 1, + PEER_RTL_92SE = 2, + PEER_BROAD = 3, + PEER_RAL = 4, + PEER_ATH = 5, + PEER_CISCO = 6, + PEER_MARV = 7, + PEER_AIRGO = 9, + PEER_MAX = 10, +}; + +#define RTL_DUMMY_OFFSET 0 +#define RTL_DUMMY_UNIT 8 +#define RTL_TX_DUMMY_SIZE (RTL_DUMMY_OFFSET * RTL_DUMMY_UNIT) +#define RTL_TX_DESC_SIZE 32 +#define RTL_TX_HEADER_SIZE (RTL_TX_DESC_SIZE + RTL_TX_DUMMY_SIZE) + +#define HT_AMSDU_SIZE_4K 3839 +#define HT_AMSDU_SIZE_8K 7935 + +#define MAX_BIT_RATE_40MHZ_MCS15 300 /* Mbps */ +#define MAX_BIT_RATE_40MHZ_MCS7 150 /* Mbps */ + +#define MAX_BIT_RATE_SHORT_GI_2NSS_80MHZ_MCS9 867 /* Mbps */ +#define MAX_BIT_RATE_SHORT_GI_2NSS_80MHZ_MCS7 650 /* Mbps */ +#define MAX_BIT_RATE_LONG_GI_2NSS_80MHZ_MCS9 780 /* Mbps */ +#define MAX_BIT_RATE_LONG_GI_2NSS_80MHZ_MCS7 585 /* Mbps */ + +#define MAX_BIT_RATE_SHORT_GI_1NSS_80MHZ_MCS9 434 /* Mbps */ +#define MAX_BIT_RATE_SHORT_GI_1NSS_80MHZ_MCS7 325 /* Mbps */ +#define MAX_BIT_RATE_LONG_GI_1NSS_80MHZ_MCS9 390 /* Mbps */ +#define MAX_BIT_RATE_LONG_GI_1NSS_80MHZ_MCS7 293 /* Mbps */ + + +#define RTL_RATE_COUNT_LEGACY 12 +#define RTL_CHANNEL_COUNT 14 + +#define FRAME_OFFSET_FRAME_CONTROL 0 +#define FRAME_OFFSET_DURATION 2 +#define FRAME_OFFSET_ADDRESS1 4 +#define FRAME_OFFSET_ADDRESS2 10 +#define FRAME_OFFSET_ADDRESS3 16 +#define FRAME_OFFSET_SEQUENCE 22 +#define FRAME_OFFSET_ADDRESS4 24 + +#define SET_80211_HDR_FRAME_CONTROL(_hdr, _val) \ + WRITEEF2BYTE(_hdr, _val) +#define SET_80211_HDR_TYPE_AND_SUBTYPE(_hdr, _val) \ + WRITEEF1BYTE(_hdr, _val) +#define SET_80211_HDR_PWR_MGNT(_hdr, _val) \ + SET_BITS_TO_LE_2BYTE(_hdr, 12, 1, _val) +#define SET_80211_HDR_TO_DS(_hdr, _val) \ + SET_BITS_TO_LE_2BYTE(_hdr, 8, 1, _val) + +#define SET_80211_PS_POLL_AID(_hdr, _val) \ + (*(u16 *)((u8 *)(_hdr) + 2) = _val) +#define SET_80211_PS_POLL_BSSID(_hdr, _val) \ + memcpy(((u8 *)(_hdr)) + 4, (u8 *)(_val), ETH_ALEN) +#define SET_80211_PS_POLL_TA(_hdr, _val) \ + memcpy(((u8 *)(_hdr)) + 10, (u8 *)(_val), ETH_ALEN) + +#define SET_80211_HDR_DURATION(_hdr, _val) \ + WRITEEF2BYTE((u8 *)(_hdr)+FRAME_OFFSET_DURATION, _val) +#define SET_80211_HDR_ADDRESS1(_hdr, _val) \ + CP_MACADDR((u8 *)(_hdr)+FRAME_OFFSET_ADDRESS1, (u8 *)(_val)) +#define SET_80211_HDR_ADDRESS2(_hdr, _val) \ + CP_MACADDR((u8 *)(_hdr)+FRAME_OFFSET_ADDRESS2, (u8 *)(_val)) +#define SET_80211_HDR_ADDRESS3(_hdr, _val) \ + CP_MACADDR((u8 *)(_hdr)+FRAME_OFFSET_ADDRESS3, (u8 *)(_val)) +#define SET_80211_HDR_FRAGMENT_SEQUENCE(_hdr, _val) \ + WRITEEF2BYTE((u8 *)(_hdr)+FRAME_OFFSET_SEQUENCE, _val) + +#define SET_BEACON_PROBE_RSP_TIME_STAMP_LOW(__phdr, __val) \ + WRITEEF4BYTE(((u8 *)(__phdr)) + 24, __val) +#define SET_BEACON_PROBE_RSP_TIME_STAMP_HIGH(__phdr, __val) \ + WRITEEF4BYTE(((u8 *)(__phdr)) + 28, __val) +#define SET_BEACON_PROBE_RSP_BEACON_INTERVAL(__phdr, __val) \ + WRITEEF2BYTE(((u8 *)(__phdr)) + 32, __val) +#define GET_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr) \ + READEF2BYTE(((u8 *)(__phdr)) + 34) +#define SET_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr, __val) \ + WRITEEF2BYTE(((u8 *)(__phdr)) + 34, __val) +#define MASK_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr, __val) \ + SET_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr, \ + (GET_BEACON_PROBE_RSP_CAPABILITY_INFO(__phdr) & (~(__val)))) + +int rtl92e_init_core(struct ieee80211_hw *hw); +void rtl92e_deinit_core(struct ieee80211_hw *hw); +void rtl92e_init_rx_config(struct ieee80211_hw *hw); +void rtl92e_init_rfkill(struct ieee80211_hw *hw); +void rtl92e_deinit_rfkill(struct ieee80211_hw *hw); + +void rtl92e_watch_dog_timer_callback(unsigned long data); +void rtl92e_deinit_deferred_work(struct ieee80211_hw *hw); + +bool rtl92e_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx); +bool rtl92e_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb); +u8 rtl92e_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, + u8 is_tx); +void rtl92e_beacon_statistic(struct ieee80211_hw *hw, struct sk_buff *skb); +void rtl92e_watch_dog_timer_callback(unsigned long data); +int rtl92e_tx_agg_start(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_sta *sta, u16 tid, u16 *ssn); +int rtl92e_tx_agg_stop(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_sta *sta, u16 tid); +int rtl92e_tx_agg_oper(struct ieee80211_hw *hw, + struct ieee80211_sta *sta, u16 tid); +int rtl92e_rx_agg_start(struct ieee80211_hw *hw, + struct ieee80211_sta *sta, u16 tid); +int rtl92e_rx_agg_stop(struct ieee80211_hw *hw, + struct ieee80211_sta *sta, u16 tid); +void rtl92e_watchdog_wq_callback(void *data); +void rtl92e_fwevt_wq_callback(void *data); + +void stg_rtl_get_tcb_desc(struct ieee80211_hw *hw, + struct ieee80211_tx_info *info, + struct ieee80211_sta *sta, + struct sk_buff *skb, struct rtl_tcb_desc *tcb_desc); + +int stg_rtl_send_smps_action(struct ieee80211_hw *hw, + struct ieee80211_sta *sta, + enum ieee80211_smps_mode smps); +u8 *rtl92e_find_ie(u8 *data, unsigned int len, u8 ie); +void rtl92e_recognize_peer(struct ieee80211_hw *hw, u8 *data, unsigned int len); +u8 rtl92e_tid_to_ac(struct ieee80211_hw *hw, u8 tid); +void rtl92e_easy_concurrent_retrytimer_callback(unsigned long data); +extern struct rtl_global_var global_var; +int rtl_core_module_init(void); +void rtl_core_module_exit(void); + +#endif diff --git a/drivers/staging/rtl8192ee/cam.c b/drivers/staging/rtl8192ee/cam.c new file mode 100644 index 000000000000..e32c329da870 --- /dev/null +++ b/drivers/staging/rtl8192ee/cam.c @@ -0,0 +1,337 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ +#include "wifi.h" +#include "cam.h" + +void rtl92e_cam_reset_sec_info(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + rtlpriv->sec.use_defaultkey = false; + rtlpriv->sec.pairwise_enc_algorithm = NO_ENCRYPTION; + rtlpriv->sec.group_enc_algorithm = NO_ENCRYPTION; + memset(rtlpriv->sec.key_buf, 0, KEY_BUF_SIZE * MAX_KEY_LEN); + memset(rtlpriv->sec.key_len, 0, KEY_BUF_SIZE); + rtlpriv->sec.pairwise_key = NULL; +} + +static void rtl_cam_program_entry(struct ieee80211_hw *hw, u32 entry_no, + u8 *mac_addr, u8 *key_cont_128, u16 us_config) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + u32 target_command; + u32 target_content = 0; + u8 entry_i; + + RT_PRINT_DATA(rtlpriv, COMP_SEC, DBG_DMESG, "Key content:", + key_cont_128, 16); + + for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) { + target_command = entry_i + CAM_CONTENT_COUNT * entry_no; + target_command = target_command | BIT(31) | BIT(16); + + if (entry_i == 0) { + target_content = (u32) (*(mac_addr + 0)) << 16 | + (u32) (*(mac_addr + 1)) << 24 | (u32) us_config; + + rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[WCAMI], + target_content); + rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM], + target_command); + + RT_TRACE(COMP_SEC, DBG_LOUD, + ("WRITE %x: %x\n", + rtlpriv->cfg->maps[WCAMI], target_content)); + RT_TRACE(COMP_SEC, DBG_LOUD, + ("The Key ID is %d\n", entry_no)); + RT_TRACE(COMP_SEC, DBG_LOUD, + ("WRITE %x: %x\n", + rtlpriv->cfg->maps[RWCAM], target_command)); + } else if (entry_i == 1) { + target_content = (u32) (*(mac_addr + 5)) << 24 | + (u32) (*(mac_addr + 4)) << 16 | + (u32) (*(mac_addr + 3)) << 8 | + (u32) (*(mac_addr + 2)); + + rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[WCAMI], + target_content); + rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM], + target_command); + + RT_TRACE(COMP_SEC, DBG_LOUD, + ("WRITE A4: %x\n", target_content)); + RT_TRACE(COMP_SEC, DBG_LOUD, + ("WRITE A0: %x\n", target_command)); + } else { + target_content = + (u32) (*(key_cont_128 + (entry_i * 4 - 8) + 3)) << + 24 | (u32) (*(key_cont_128 + (entry_i * 4 - 8) + 2)) + << 16 | + (u32) (*(key_cont_128 + (entry_i * 4 - 8) + 1)) << 8 + | (u32) (*(key_cont_128 + (entry_i * 4 - 8) + 0)); + + rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[WCAMI], + target_content); + rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM], + target_command); + udelay(100); + + RT_TRACE(COMP_SEC, DBG_LOUD, + ("WRITE A4: %x\n", target_content)); + RT_TRACE(COMP_SEC, DBG_LOUD, + ("WRITE A0: %x\n", target_command)); + } + } + + RT_TRACE(COMP_SEC, DBG_LOUD, + ("after set key, usconfig:%x\n", us_config)); +} + +u8 stg_rtl_cam_add_one_entry(struct ieee80211_hw *hw, u8 *mac_addr, + u32 ul_key_id, u32 ul_entry_idx, u32 ul_enc_alg, + u32 ul_default_key, u8 *key_content) +{ + u32 us_config; + struct rtl_priv *rtlpriv = rtl_priv(hw); + + RT_TRACE(COMP_SEC, DBG_DMESG, + ("EntryNo:%x, ulKeyId=%x, ulEncAlg=%x, ulUseDK=%x MacAddr %pM\n", + ul_entry_idx, ul_key_id, ul_enc_alg, + ul_default_key, mac_addr)); + + if (ul_key_id == TOTAL_CAM_ENTRY) { + RT_TRACE(COMP_ERR, DBG_WARNING, + ("ulKeyId exceed!\n")); + return 0; + } + + if (ul_default_key == 1) + us_config = CFG_VALID | ((u16) (ul_enc_alg) << 2); + else + us_config = CFG_VALID | ((ul_enc_alg) << 2) | ul_key_id; + + rtl_cam_program_entry(hw, ul_entry_idx, mac_addr, + (u8 *)key_content, us_config); + + RT_TRACE(COMP_SEC, DBG_DMESG, ("end\n")); + + return 1; +} +EXPORT_SYMBOL(stg_rtl_cam_add_one_entry); + +int stg_rtl_cam_delete_one_entry(struct ieee80211_hw *hw, + u8 *mac_addr, u32 ul_key_id) +{ + u32 ul_command; + struct rtl_priv *rtlpriv = rtl_priv(hw); + + RT_TRACE(COMP_SEC, DBG_DMESG, ("key_idx:%d\n", ul_key_id)); + + ul_command = ul_key_id * CAM_CONTENT_COUNT; + ul_command = ul_command | BIT(31) | BIT(16); + + rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[WCAMI], 0); + rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM], ul_command); + + RT_TRACE(COMP_SEC, DBG_DMESG, + ("stg_rtl_cam_delete_one_entry(): WRITE A4: %x\n", 0)); + RT_TRACE(COMP_SEC, DBG_DMESG, + ("stg_rtl_cam_delete_one_entry(): WRITE A0: %x\n", + ul_command)); + return 0; +} +EXPORT_SYMBOL(stg_rtl_cam_delete_one_entry); + +void stg_rtl_cam_reset_all_entry(struct ieee80211_hw *hw) +{ + u32 ul_command; + struct rtl_priv *rtlpriv = rtl_priv(hw); + + ul_command = BIT(31) | BIT(30); + rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM], ul_command); +} +EXPORT_SYMBOL(stg_rtl_cam_reset_all_entry); + +void stg_rtl_cam_mark_invalid(struct ieee80211_hw *hw, u8 uc_index) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + u32 ul_command; + u32 ul_content; + u32 ul_enc_algo = rtlpriv->cfg->maps[SEC_CAM_AES]; + + switch (rtlpriv->sec.pairwise_enc_algorithm) { + case WEP40_ENCRYPTION: + ul_enc_algo = rtlpriv->cfg->maps[SEC_CAM_WEP40]; + break; + case WEP104_ENCRYPTION: + ul_enc_algo = rtlpriv->cfg->maps[SEC_CAM_WEP104]; + break; + case TKIP_ENCRYPTION: + ul_enc_algo = rtlpriv->cfg->maps[SEC_CAM_TKIP]; + break; + case AESCCMP_ENCRYPTION: + ul_enc_algo = rtlpriv->cfg->maps[SEC_CAM_AES]; + break; + default: + ul_enc_algo = rtlpriv->cfg->maps[SEC_CAM_AES]; + } + + ul_content = (uc_index & 3) | ((u16) (ul_enc_algo) << 2); + + ul_content |= BIT(15); + ul_command = CAM_CONTENT_COUNT * uc_index; + ul_command = ul_command | BIT(31) | BIT(16); + + rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[WCAMI], ul_content); + rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM], ul_command); + + RT_TRACE(COMP_SEC, DBG_DMESG, + ("stg_rtl_cam_mark_invalid(): WRITE A4: %x\n", ul_content)); + RT_TRACE(COMP_SEC, DBG_DMESG, + ("stg_rtl_cam_mark_invalid(): WRITE A0: %x\n", ul_command)); +} +EXPORT_SYMBOL(stg_rtl_cam_mark_invalid); + +void stg_rtl_cam_empty_entry(struct ieee80211_hw *hw, u8 uc_index) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + u32 ul_command; + u32 ul_content; + u32 ul_encalgo = rtlpriv->cfg->maps[SEC_CAM_AES]; + u8 entry_i; + + switch (rtlpriv->sec.pairwise_enc_algorithm) { + case WEP40_ENCRYPTION: + ul_encalgo = rtlpriv->cfg->maps[SEC_CAM_WEP40]; + break; + case WEP104_ENCRYPTION: + ul_encalgo = rtlpriv->cfg->maps[SEC_CAM_WEP104]; + break; + case TKIP_ENCRYPTION: + ul_encalgo = rtlpriv->cfg->maps[SEC_CAM_TKIP]; + break; + case AESCCMP_ENCRYPTION: + ul_encalgo = rtlpriv->cfg->maps[SEC_CAM_AES]; + break; + default: + ul_encalgo = rtlpriv->cfg->maps[SEC_CAM_AES]; + } + + for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) { + if (entry_i == 0) { + ul_content = + (uc_index & 0x03) | ((u16) (ul_encalgo) << 2); + ul_content |= BIT(15); + + } else { + ul_content = 0; + } + + ul_command = CAM_CONTENT_COUNT * uc_index + entry_i; + ul_command = ul_command | BIT(31) | BIT(16); + + rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[WCAMI], ul_content); + rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM], ul_command); + + RT_TRACE(COMP_SEC, DBG_LOUD, + ("stg_rtl_cam_empty_entry(): WRITE A4: %x\n", + ul_content)); + RT_TRACE(COMP_SEC, DBG_LOUD, + ("stg_rtl_cam_empty_entry(): WRITE A0: %x\n", + ul_command)); + } +} +EXPORT_SYMBOL(stg_rtl_cam_empty_entry); + +u8 stg_rtl_cam_get_free_entry(struct ieee80211_hw *hw, u8 *sta_addr) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u32 bitmap = (rtlpriv->sec.hwsec_cam_bitmap) >> 4; + u8 entry_idx = 0; + u8 i, *addr; + + if (!sta_addr) { + RT_TRACE(COMP_SEC, DBG_EMERG, + ("sta_addr is NULL\n")); + return TOTAL_CAM_ENTRY; + } + /* Does STA already exist? */ + for (i = 4; i < TOTAL_CAM_ENTRY; i++) { + addr = rtlpriv->sec.hwsec_cam_sta_addr[i]; + if (memcmp(addr, sta_addr, ETH_ALEN) == 0) + return i; + } + /* Get a free CAM entry. */ + for (entry_idx = 4; entry_idx < TOTAL_CAM_ENTRY; entry_idx++) { + if ((bitmap & BIT(0)) == 0) { + RT_TRACE(COMP_SEC, DBG_EMERG, + ("-----hwsec_cam_bitmap: 0x%x entry_idx=%d\n", + rtlpriv->sec.hwsec_cam_bitmap, entry_idx)); + rtlpriv->sec.hwsec_cam_bitmap |= BIT(0) << entry_idx; + memcpy(rtlpriv->sec.hwsec_cam_sta_addr[entry_idx], + sta_addr, ETH_ALEN); + return entry_idx; + } + bitmap = bitmap >> 1; + } + return TOTAL_CAM_ENTRY; +} +EXPORT_SYMBOL(stg_rtl_cam_get_free_entry); + +void stg_rtl_cam_del_entry(struct ieee80211_hw *hw, u8 *sta_addr) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u32 bitmap; + u8 i, *addr; + + if (NULL == sta_addr) { + RT_TRACE(COMP_SEC, DBG_EMERG, + ("sta_addr is NULL.\n")); + return; + } + + if (is_zero_ether_addr(sta_addr)) { + RT_TRACE(COMP_SEC, DBG_EMERG, + ("sta_addr is 00:00:00:00:00:00.\n")); + return; + } + /* Does STA already exist? */ + for (i = 4; i < TOTAL_CAM_ENTRY; i++) { + addr = rtlpriv->sec.hwsec_cam_sta_addr[i]; + bitmap = (rtlpriv->sec.hwsec_cam_bitmap) >> i; + if (((bitmap & BIT(0)) == BIT(0)) && + (memcmp(addr, sta_addr, ETH_ALEN) == 0)) { + /* Remove from HW Security CAM */ + memset(rtlpriv->sec.hwsec_cam_sta_addr[i], 0, ETH_ALEN); + rtlpriv->sec.hwsec_cam_bitmap &= ~(BIT(0) << i); + pr_info("&&&&&&&&&del entry %d\n", i); + } + } + return; +} +EXPORT_SYMBOL(stg_rtl_cam_del_entry); diff --git a/drivers/staging/rtl8192ee/cam.h b/drivers/staging/rtl8192ee/cam.h new file mode 100644 index 000000000000..b3a9464e7ed0 --- /dev/null +++ b/drivers/staging/rtl8192ee/cam.h @@ -0,0 +1,52 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#ifndef __RTL_CAM_H_ +#define __RTL_CAM_H_ + +#define CAM_CONTENT_COUNT 8 + +#define CFG_DEFAULT_KEY BIT(5) +#define CFG_VALID BIT(15) + +#define PAIRWISE_KEYIDX 0 +#define CAM_PAIRWISE_KEY_POSITION 4 + +#define CAM_CONFIG_USEDK 1 +#define CAM_CONFIG_NO_USEDK 0 + +void stg_rtl_cam_reset_all_entry(struct ieee80211_hw *hw); +u8 stg_rtl_cam_add_one_entry(struct ieee80211_hw *hw, u8 *mac_addr, + u32 ul_key_id, u32 ul_entry_idx, u32 ul_enc_alg, + u32 ul_default_key, u8 *key_content); +int stg_rtl_cam_delete_one_entry(struct ieee80211_hw *hw, u8 *mac_addr, + u32 ul_key_id); +void stg_rtl_cam_mark_invalid(struct ieee80211_hw *hw, u8 uc_index); +void stg_rtl_cam_empty_entry(struct ieee80211_hw *hw, u8 uc_index); +void rtl92e_cam_reset_sec_info(struct ieee80211_hw *hw); +u8 stg_rtl_cam_get_free_entry(struct ieee80211_hw *hw, u8 *sta_addr); +void stg_rtl_cam_del_entry(struct ieee80211_hw *hw, u8 *sta_addr); + +#endif diff --git a/drivers/staging/rtl8192ee/compat.h b/drivers/staging/rtl8192ee/compat.h new file mode 100644 index 000000000000..72a3c13afeda --- /dev/null +++ b/drivers/staging/rtl8192ee/compat.h @@ -0,0 +1,70 @@ +#ifndef __RTL_COMPAT_H__ +#define __RTL_COMPAT_H__ + + +#define RX_FLAG_MACTIME_MPDU RX_FLAG_MACTIME_START + +#define IEEE80211_KEY_FLAG_SW_MGMT IEEE80211_KEY_FLAG_SW_MGMT_TX + +struct ieee80211_mgmt_compat { + __le16 frame_control; + __le16 duration; + u8 da[6]; + u8 sa[6]; + u8 bssid[6]; + __le16 seq_ctrl; + union { + struct { + u8 category; + union { + struct { + u8 action_code; + u8 dialog_token; + u8 status_code; + u8 variable[0]; + } __packed wme_action; + struct { + u8 action_code; + u8 dialog_token; + __le16 capab; + __le16 timeout; + __le16 start_seq_num; + } __packed addba_req; + struct{ + u8 action_code; + u8 dialog_token; + __le16 status; + __le16 capab; + __le16 timeout; + } __packed addba_resp; + struct { + u8 action_code; + __le16 params; + __le16 reason_code; + } __packed delba; + struct { + u8 action_code; + /* capab_info for open and confirm, + * reason for close + */ + __le16 aux; + /* Followed in plink_confirm by status + * code, AID and supported rates, + * and directly by supported rates in + * plink_open and plink_close + */ + u8 variable[0]; + } __packed plink_action; + struct { + u8 action_code; + u8 variable[0]; + } __packed mesh_action; + struct { + u8 action; + u8 smps_control; + } __packed ht_smps; + } u; + } __packed action; + } u; +} __packed; +#endif diff --git a/drivers/staging/rtl8192ee/core.c b/drivers/staging/rtl8192ee/core.c new file mode 100644 index 000000000000..76ea356163b6 --- /dev/null +++ b/drivers/staging/rtl8192ee/core.c @@ -0,0 +1,1600 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#include "wifi.h" +#include "core.h" +#include "cam.h" +#include "base.h" +#include "ps.h" + +#include "btcoexist/rtl_btc.h" + +/*mutex for start & stop is must here. */ +static int rtl_op_start(struct ieee80211_hw *hw) +{ + int err = 0; + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + + if (!is_hal_stop(rtlhal)) + return 0; + if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status)) + return 0; + mutex_lock(&rtlpriv->locks.conf_mutex); + err = rtlpriv->intf_ops->adapter_start(hw); + if (err) + goto out; + rtl92e_watch_dog_timer_callback((unsigned long)hw); + +out: + mutex_unlock(&rtlpriv->locks.conf_mutex); + return err; +} + +static void rtl_op_stop(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + bool b_support_remote_wakeup = false; + + if (is_hal_stop(rtlhal)) + return; + + rtlpriv->cfg->ops->get_hw_reg(hw, HAL_DEF_WOWLAN, + (u8 *)(&b_support_remote_wakeup)); + /* here is must, because adhoc do stop and start, + * but stop with RFOFF may cause something wrong, + * like adhoc TP */ + if (unlikely(ppsc->rfpwr_state == ERFOFF)) + rtl92e_ips_nic_on(hw); + + mutex_lock(&rtlpriv->locks.conf_mutex); + /* if wowlan supported, DON'T clear connected info */ + if (!(b_support_remote_wakeup && + rtlhal->b_enter_pnp_sleep)) { + mac->link_state = MAC80211_NOLINK; + memset(mac->bssid, 0, 6); + mac->vendor = PEER_UNKNOWN; + + /* reset sec info */ + rtl92e_cam_reset_sec_info(hw); + + rtl92e_deinit_deferred_work(hw); + } + rtlpriv->intf_ops->adapter_stop(hw); + + mutex_unlock(&rtlpriv->locks.conf_mutex); +} + +static void rtl_op_tx(struct ieee80211_hw *hw, + struct ieee80211_tx_control *control, + struct sk_buff *skb) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + struct rtl_tcb_desc tcb_desc; + memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc)); + + if (unlikely(is_hal_stop(rtlhal) || ppsc->rfpwr_state != ERFON)) + goto err_free; + + if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status)) + goto err_free; + + if (!rtlpriv->intf_ops->waitq_insert(hw, control->sta, skb)) + rtlpriv->intf_ops->adapter_tx(hw, control->sta, skb, &tcb_desc); + return; + +err_free: + dev_kfree_skb_any(skb); + return; +} + +static int rtl_op_add_interface(struct ieee80211_hw *hw, + struct ieee80211_vif *vif) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + int err = 0; + + if (mac->vif) { + RT_TRACE(COMP_ERR, DBG_WARNING, + ("vif has been set!! mac->vif = 0x%p\n", mac->vif)); + return -EOPNOTSUPP; + } + + vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER; + + rtl92e_ips_nic_on(hw); + + mutex_lock(&rtlpriv->locks.conf_mutex); + switch (ieee80211_vif_type_p2p(vif)) { + case NL80211_IFTYPE_P2P_CLIENT: + mac->p2p = P2P_ROLE_CLIENT; + /*fall through*/ + case NL80211_IFTYPE_STATION: + if (mac->beacon_enabled == 1) { + RT_TRACE(COMP_MAC80211, DBG_LOUD, + ("NL80211_IFTYPE_STATION\n")); + mac->beacon_enabled = 0; + rtlpriv->cfg->ops->update_interrupt_mask(hw, 0, + rtlpriv->cfg->maps[RTL_IBSS_INT_MASKS]); + } + break; + case NL80211_IFTYPE_ADHOC: + RT_TRACE(COMP_MAC80211, DBG_LOUD, + ("NL80211_IFTYPE_ADHOC\n")); + mac->link_state = MAC80211_LINKED; + rtlpriv->cfg->ops->set_bcn_reg(hw); + if (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G) + mac->basic_rates = 0xfff; + else + mac->basic_rates = 0xff0; + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE, + (u8 *)(&mac->basic_rates)); + break; + case NL80211_IFTYPE_P2P_GO: + mac->p2p = P2P_ROLE_GO; + /*fall through*/ + case NL80211_IFTYPE_AP: + RT_TRACE(COMP_MAC80211, DBG_LOUD, + ("NL80211_IFTYPE_AP\n")); + + mac->link_state = MAC80211_LINKED; + rtlpriv->cfg->ops->set_bcn_reg(hw); + if (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G) + mac->basic_rates = 0xfff; + else + mac->basic_rates = 0xff0; + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE, + (u8 *)(&mac->basic_rates)); + break; + case NL80211_IFTYPE_MESH_POINT: + RT_TRACE(COMP_MAC80211, DBG_LOUD, + ("NL80211_IFTYPE_MESH_POINT\n")); + + mac->link_state = MAC80211_LINKED; + rtlpriv->cfg->ops->set_bcn_reg(hw); + if (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G) + mac->basic_rates = 0xfff; + else + mac->basic_rates = 0xff0; + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE, + (u8 *)(&mac->basic_rates)); + break; + default: + RT_TRACE(COMP_ERR, DBG_EMERG, + ("operation mode %d is not support!\n", vif->type)); + err = -EOPNOTSUPP; + goto out; + } + +#ifdef VIF_TODO + if (!rtl_set_vif_info(hw, vif)) + goto out; +#endif + + if (mac->p2p) { + RT_TRACE(COMP_MAC80211, DBG_LOUD, + ("p2p role %x\n", vif->type)); + mac->basic_rates = 0xff0;/*disable cck rate for p2p*/ + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE, + (u8 *)(&mac->basic_rates)); + } + mac->vif = vif; + mac->opmode = vif->type; + rtlpriv->cfg->ops->set_network_type(hw, vif->type); + ether_addr_copy(mac->mac_addr, vif->addr); + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ETHER_ADDR, mac->mac_addr); + +out: + mutex_unlock(&rtlpriv->locks.conf_mutex); + return err; +} + +static void rtl_op_remove_interface(struct ieee80211_hw *hw, + struct ieee80211_vif *vif) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + + mutex_lock(&rtlpriv->locks.conf_mutex); + + /* Free beacon resources */ + if ((vif->type == NL80211_IFTYPE_AP) || + (vif->type == NL80211_IFTYPE_ADHOC) || + (vif->type == NL80211_IFTYPE_MESH_POINT)) { + if (mac->beacon_enabled == 1) { + mac->beacon_enabled = 0; + rtlpriv->cfg->ops->update_interrupt_mask(hw, 0, + rtlpriv->cfg->maps[RTL_IBSS_INT_MASKS]); + } + } + + /* + *Note: We assume NL80211_IFTYPE_UNSPECIFIED as + *NO LINK for our hardware. + */ + mac->p2p = 0; + mac->vif = NULL; + mac->link_state = MAC80211_NOLINK; + memset(mac->bssid, 0, 6); + mac->vendor = PEER_UNKNOWN; + mac->opmode = NL80211_IFTYPE_UNSPECIFIED; + rtlpriv->cfg->ops->set_network_type(hw, mac->opmode); + + mutex_unlock(&rtlpriv->locks.conf_mutex); +} +/**/ +static int rtl_op_change_interface(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + enum nl80211_iftype new_type, bool p2p) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + int ret; + rtl_op_remove_interface(hw, vif); + + vif->type = new_type; + vif->p2p = p2p; + ret = rtl_op_add_interface(hw, vif); + RT_TRACE(COMP_MAC80211, DBG_LOUD, + (" p2p %x\n", p2p)); + return ret; +} + +#ifdef CONFIG_PM +static u16 crc16_ccitt(u8 data, u16 crc) +{ + u8 shift_in, data_bit, crc_bit11, crc_bit4, crc_bit15; + u8 i; + u16 result; + + for (i = 0; i < 8; i++) { + crc_bit15 = ((crc & BIT(15)) ? 1 : 0); + data_bit = (data & (BIT(0) << i) ? 1 : 0); + shift_in = crc_bit15 ^ data_bit; + + result = crc << 1; + if (shift_in == 0) + result &= (~BIT(0)); + else + result |= BIT(0); + + crc_bit11 = ((crc & BIT(11)) ? 1 : 0) ^ shift_in; + if (crc_bit11 == 0) + result &= (~BIT(12)); + else + result |= BIT(12); + + crc_bit4 = ((crc & BIT(4)) ? 1 : 0) ^ shift_in; + if (crc_bit4 == 0) + result &= (~BIT(5)); + else + result |= BIT(5); + + crc = result; + } + + return crc; +} + +static u16 _calculate_wol_pattern_crc(u8 *pattern, u16 len) +{ + u16 crc = 0xffff; + u32 i; + + for (i = 0; i < len; i++) + crc = crc16_ccitt(pattern[i], crc); + crc = ~crc; + + return crc; +} + +static void _rtl_add_wowlan_patterns(struct ieee80211_hw *hw, + struct cfg80211_wowlan *wow) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *mac = &(rtlpriv->mac80211); + struct cfg80211_pkt_pattern *patterns = wow->patterns; + struct rtl_wow_pattern rtl_pattern; + u8 *pattern_os, *mask_os; + u8 mask[MAX_WOL_BIT_MASK_SIZE] = {0}; + u8 content[MAX_WOL_PATTERN_SIZE] = {0}; + u8 broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + u8 multicast_addr1[2] = {0x33, 0x33}; + u8 multicast_addr2[3] = {0x01, 0x00, 0x5e}; + u8 i, mask_len; + u16 j, len; + + for (i = 0; i < wow->n_patterns; i++) { + memset(&rtl_pattern, 0, sizeof(struct rtl_wow_pattern)); + memset(mask, 0, MAX_WOL_BIT_MASK_SIZE); + if (patterns[i].pattern_len > MAX_WOL_PATTERN_SIZE) { + RT_TRACE(COMP_POWER, DBG_WARNING, + ("Pattern[%d] is too long\n", i)); + continue; + } + pattern_os = patterns[i].pattern; + mask_len = DIV_ROUND_UP(patterns[i].pattern_len, 8); + mask_os = patterns[i].mask; + RT_PRINT_DATA(rtlpriv, COMP_POWER, DBG_TRACE, + "pattern content\n", pattern_os, + patterns[i].pattern_len); + RT_PRINT_DATA(rtlpriv, COMP_POWER, DBG_TRACE, + "mask content\n", mask_os, mask_len); + /* 1. unicast? multicast? or broadcast? */ + if (memcmp(pattern_os, broadcast_addr, 6) == 0) + rtl_pattern.type = BROADCAST_PATTERN; + else if (memcmp(pattern_os, multicast_addr1, 2) == 0 || + memcmp(pattern_os, multicast_addr2, 3) == 0) + rtl_pattern.type = MULTICAST_PATTERN; + else if (memcmp(pattern_os, mac->mac_addr, 6) == 0) + rtl_pattern.type = UNICAST_PATTERN; + else + rtl_pattern.type = UNKNOWN_TYPE; + + /* 2. translate mask_from_os to mask_for_hw */ + +/****************************************************************************** + * pattern from OS uses 'ethenet frame', like this: + + | 6 | 6 | 2 | 20 | Variable | 4 | + |--------+--------+------+-----------+------------+-----| + | 802.3 Mac Header | IP Header | TCP Packet | FCS | + | DA | SA | Type | + + * BUT, packet catched by our HW is in '802.11 frame', begin from LLC, + + | 24 or 30 | 6 | 2 | 20 | Variable | 4 | + |-------------------+--------+------+-----------+------------+-----| + | 802.11 MAC Header | LLC | IP Header | TCP Packet | FCS | + | Others | Tpye | + + * Therefore, we need translate mask_from_OS to mask_to_hw. + * We should left-shift mask by 6 bits, then set the new bit[0~5] = 0, + * because new mask[0~5] means 'SA', but our HW packet begins from LLC, + * bit[0~5] corresponds to first 6 Bytes in LLC, they just don't match. + ******************************************************************************/ + + /* Shift 6 bits */ + for (j = 0; j < mask_len - 1; j++) { + mask[j] = mask_os[j] >> 6; + mask[j] |= (mask_os[j + 1] & 0x3F) << 2; + } + mask[j] = (mask_os[j] >> 6) & 0x3F; + /* Set bit 0-5 to zero */ + mask[0] &= 0xC0; + + RT_PRINT_DATA(rtlpriv, COMP_POWER, DBG_TRACE, + "mask to hw\n", mask, mask_len); + for (j = 0; j < (MAX_WOL_BIT_MASK_SIZE + 1) / 4; j++) { + rtl_pattern.mask[j] = mask[j * 4]; + rtl_pattern.mask[j] |= (mask[j * 4 + 1] << 8); + rtl_pattern.mask[j] |= (mask[j * 4 + 2] << 16); + rtl_pattern.mask[j] |= (mask[j * 4 + 3] << 24); + } + + /* To get the wake up pattern from the mask. + * We do not count first 12 bits which means + * DA[6] and SA[6] in the pattern to match HW design. */ + len = 0; + for (j = 12; j < patterns[i].pattern_len; j++) { + if ((mask_os[j / 8] >> (j % 8)) & 0x01) { + content[len] = pattern_os[j]; + len++; + } + } + + RT_PRINT_DATA(rtlpriv, COMP_POWER, DBG_TRACE, + "pattern to hw\n", content, len); + /* 3. calculate crc */ + rtl_pattern.crc = _calculate_wol_pattern_crc(content, len); + RT_TRACE(COMP_POWER, DBG_TRACE, + ("CRC_Remainder = 0x%x", rtl_pattern.crc)); + + /* 4. write crc & mask_for_hw to hw */ + rtlpriv->cfg->ops->add_wowlan_pattern(hw, &rtl_pattern, i); + } + rtl_write_byte(rtlpriv, 0x698, wow->n_patterns); +} + +static int rtl_op_suspend(struct ieee80211_hw *hw, + struct cfg80211_wowlan *wow) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtlpriv); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + struct timeval ts; + + RT_TRACE(COMP_POWER, DBG_DMESG, ("\n")); + if (WARN_ON(!wow)) + return -EINVAL; + + /* to resolve s4 can not wake up*/ + do_gettimeofday(&ts); + rtlhal->last_suspend_sec = ts.tv_sec; + + if ((ppsc->wo_wlan_mode & WAKE_ON_PATTERN_MATCH) && wow->n_patterns) + _rtl_add_wowlan_patterns(hw, wow); + + rtlhal->driver_is_goingto_unload = true; + rtlhal->b_enter_pnp_sleep = true; + + rtl92e_lps_leave(hw); + rtl_op_stop(hw); + device_set_wakeup_enable(wiphy_dev(hw->wiphy), true); + return 0; +} + +static int rtl_op_resume(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtlpriv); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct timeval ts; + + RT_TRACE(COMP_POWER, DBG_DMESG, ("\n")); + rtlhal->driver_is_goingto_unload = false; + rtlhal->b_enter_pnp_sleep = false; + rtlhal->b_wake_from_pnp_sleep = true; + + /* to resovle s4 can not wake up*/ + do_gettimeofday(&ts); + if (ts.tv_sec - rtlhal->last_suspend_sec < 5) + return -1; + + rtl_op_start(hw); + device_set_wakeup_enable(wiphy_dev(hw->wiphy), false); + ieee80211_resume_disconnect(mac->vif); + rtlhal->b_wake_from_pnp_sleep = false; + return 0; +} +#endif + +static int rtl_op_config(struct ieee80211_hw *hw, u32 changed) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + struct ieee80211_conf *conf = &hw->conf; + + if (mac->skip_scan) + return 1; + + + mutex_lock(&rtlpriv->locks.conf_mutex); + if (changed & IEEE80211_CONF_CHANGE_LISTEN_INTERVAL) { /* BIT(2) */ + RT_TRACE(COMP_MAC80211, DBG_LOUD, + ("IEEE80211_CONF_CHANGE_LISTEN_INTERVAL\n")); + } + + /*For IPS */ + if (changed & IEEE80211_CONF_CHANGE_IDLE) { + if (hw->conf.flags & IEEE80211_CONF_IDLE) + rtl92e_ips_nic_off(hw); + else + rtl92e_ips_nic_on(hw); + } else { + /* + *although rfoff may not cause by ips, but we will + *check the reason in set_rf_power_state function + */ + if (unlikely(ppsc->rfpwr_state == ERFOFF)) + rtl92e_ips_nic_on(hw); + } + + /*For LPS */ + if (changed & IEEE80211_CONF_CHANGE_PS) { + cancel_delayed_work(&rtlpriv->works.ps_work); + cancel_delayed_work(&rtlpriv->works.ps_rfon_wq); + if (conf->flags & IEEE80211_CONF_PS) { + rtlpriv->psc.sw_ps_enabled = true; + /* sleep here is must, or we may recv the beacon and + * cause mac80211 into wrong ps state, this will cause + * power save nullfunc send fail, and further cause + * pkt loss, So sleep must quickly but not immediatly + * because that will cause nullfunc send by mac80211 + * fail, and cause pkt loss, we have tested that 5mA + * is worked very well */ + if (!rtlpriv->psc.multi_buffered) + queue_delayed_work(rtlpriv->works.rtl_wq, + &rtlpriv->works.ps_work, + MSECS(5)); + } else { + rtl92e_swlps_rf_awake(hw); + rtlpriv->psc.sw_ps_enabled = false; + } + } + + if (changed & IEEE80211_CONF_CHANGE_RETRY_LIMITS) { + RT_TRACE(COMP_MAC80211, DBG_LOUD, + ("IEEE80211_CONF_CHANGE_RETRY_LIMITS %x\n", + hw->conf.long_frame_max_tx_count)); + mac->retry_long = hw->conf.long_frame_max_tx_count; + mac->retry_short = hw->conf.long_frame_max_tx_count; + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RETRY_LIMIT, + (u8 *)(&hw->conf.long_frame_max_tx_count)); + } + if (changed & IEEE80211_CONF_CHANGE_CHANNEL && + !rtlpriv->proximity.proxim_on) { + struct ieee80211_channel *channel = hw->conf.chandef.chan; + enum nl80211_chan_width width = hw->conf.chandef.width; + u8 wide_chan = (u8) channel->hw_value; + enum nl80211_channel_type channel_type = NL80211_CHAN_NO_HT; + + /* channel_type is for 20&40M */ + if (width < NL80211_CHAN_WIDTH_80) + channel_type = cfg80211_get_chandef_type(&(hw->conf.chandef)); + if (mac->act_scanning) + mac->n_channels++; + + if (rtlpriv->dm.supp_phymode_switch && + mac->link_state < MAC80211_LINKED && + !mac->act_scanning) { + if (rtlpriv->cfg->ops->check_switch_to_dmdp) + rtlpriv->cfg->ops->check_switch_to_dmdp(hw); + } + + /* + *because we should back channel to + *current_network.chan in in scanning, + *So if set_chan == current_network.chan + *we should set it. + *because mac80211 tell us wrong bw40 + *info for cisco1253 bw20, so we modify + *it here based on UPPER & LOWER + */ + + if (width >= NL80211_CHAN_WIDTH_80) { + if (width == NL80211_CHAN_WIDTH_80) { + u32 center_freq = hw->conf.chandef.center_freq1; + u32 primary_freq = + (u32)hw->conf.chandef.chan->center_freq; + + rtlphy->current_chan_bw = + HT_CHANNEL_WIDTH_80; + mac->bw_80 = true; + mac->bw_40 = true; + if (center_freq > primary_freq) { + mac->cur_80_prime_sc = + PRIME_CHNL_OFFSET_LOWER; + if (center_freq - primary_freq == 10) { + mac->cur_40_prime_sc = + PRIME_CHNL_OFFSET_UPPER; + + wide_chan += 2; + } else if (center_freq - primary_freq == 30) { + mac->cur_40_prime_sc = + PRIME_CHNL_OFFSET_LOWER; + + wide_chan += 6; + } + } else { + mac->cur_80_prime_sc = + PRIME_CHNL_OFFSET_UPPER; + if (primary_freq - center_freq == 10) { + mac->cur_40_prime_sc = + PRIME_CHNL_OFFSET_LOWER; + + wide_chan -= 2; + } else if (primary_freq - center_freq == 30) { + mac->cur_40_prime_sc = + PRIME_CHNL_OFFSET_UPPER; + + wide_chan -= 6; + } + } + } + } else { + switch (channel_type) { + case NL80211_CHAN_HT20: + case NL80211_CHAN_NO_HT: + /* SC */ + mac->cur_40_prime_sc = + PRIME_CHNL_OFFSET_DONT_CARE; + rtlphy->current_chan_bw = + HT_CHANNEL_WIDTH_20; + mac->bw_40 = false; + mac->bw_80 = false; + break; + case NL80211_CHAN_HT40MINUS: + /* SC */ + mac->cur_40_prime_sc = + PRIME_CHNL_OFFSET_UPPER; + rtlphy->current_chan_bw = + HT_CHANNEL_WIDTH_20_40; + mac->bw_40 = true; + mac->bw_80 = false; + + /*wide channel */ + wide_chan -= 2; + break; + case NL80211_CHAN_HT40PLUS: + /* SC */ + mac->cur_40_prime_sc = + PRIME_CHNL_OFFSET_LOWER; + rtlphy->current_chan_bw = + HT_CHANNEL_WIDTH_20_40; + mac->bw_40 = true; + mac->bw_80 = false; + /*wide channel */ + wide_chan += 2; + break; + default: + mac->bw_40 = false; + mac->bw_80 = false; + RT_TRACE(COMP_ERR, DBG_EMERG, + ("switch case not processed\n")); + break; + } + } + + if (wide_chan <= 0) + wide_chan = 1; + + /* in scanning, when before we offchannel we may send a ps=1 + * null to AP, and then we may send a ps = 0 null to AP quickly, + * but first null have cause AP's put lots of packet to hw tx + * buffer, these packet must be tx before off channel so we must + * delay more time to let AP flush these packets before + * offchannel, or dis-association or delete BA will happen by AP + */ + if (rtlpriv->mac80211.offchan_deley) { + rtlpriv->mac80211.offchan_deley = false; + mdelay(50); + } + + rtlphy->current_channel = wide_chan; + + rtlpriv->cfg->ops->switch_channel(hw); + rtlpriv->cfg->ops->set_channel_access(hw); + rtlpriv->cfg->ops->set_bw_mode(hw, + channel_type); + } + + mutex_unlock(&rtlpriv->locks.conf_mutex); + + return 0; +} + +static void rtl_op_configure_filter(struct ieee80211_hw *hw, + unsigned int changed_flags, + unsigned int *new_flags, u64 multicast) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + + *new_flags &= RTL_SUPPORTED_FILTERS; + if (0 == changed_flags) + return; + + /*TODO: we disable broadcase now, so enable here */ + if (changed_flags & FIF_ALLMULTI) { + if (*new_flags & FIF_ALLMULTI) { + mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_AM] | + rtlpriv->cfg->maps[MAC_RCR_AB]; + RT_TRACE(COMP_MAC80211, DBG_LOUD, + ("Enable receive multicast frame.\n")); + } else { + mac->rx_conf &= ~(rtlpriv->cfg->maps[MAC_RCR_AM] | + rtlpriv->cfg->maps[MAC_RCR_AB]); + RT_TRACE(COMP_MAC80211, DBG_LOUD, + ("Disable receive multicast frame.\n")); + } + } + + if (changed_flags & FIF_FCSFAIL) { + if (*new_flags & FIF_FCSFAIL) { + mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_ACRC32]; + RT_TRACE(COMP_MAC80211, DBG_LOUD, + ("Enable receive FCS error frame.\n")); + } else { + mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_ACRC32]; + RT_TRACE(COMP_MAC80211, DBG_LOUD, + ("Disable receive FCS error frame.\n")); + } + } + + /* if ssid not set to hw don't check bssid + * here just used for linked scanning, & linked + * and nolink check bssid is set in set network_type */ + if ((changed_flags & FIF_BCN_PRBRESP_PROMISC) && + (mac->link_state >= MAC80211_LINKED)) { + if (mac->opmode != NL80211_IFTYPE_AP && + mac->opmode != NL80211_IFTYPE_MESH_POINT) { + if (*new_flags & FIF_BCN_PRBRESP_PROMISC) + rtlpriv->cfg->ops->set_chk_bssid(hw, false); + else + rtlpriv->cfg->ops->set_chk_bssid(hw, true); + } + } + + if (changed_flags & FIF_CONTROL) { + if (*new_flags & FIF_CONTROL) { + mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_ACF]; + + RT_TRACE(COMP_MAC80211, DBG_LOUD, + ("Enable receive control frame.\n")); + } else { + mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_ACF]; + RT_TRACE(COMP_MAC80211, DBG_LOUD, + ("Disable receive control frame.\n")); + } + } + + if (changed_flags & FIF_OTHER_BSS) { + if (*new_flags & FIF_OTHER_BSS) { + mac->rx_conf |= rtlpriv->cfg->maps[MAC_RCR_AAP]; + RT_TRACE(COMP_MAC80211, DBG_LOUD, + ("Enable receive other BSS's frame.\n")); + } else { + mac->rx_conf &= ~rtlpriv->cfg->maps[MAC_RCR_AAP]; + RT_TRACE(COMP_MAC80211, DBG_LOUD, + ("Disable receive other BSS's frame.\n")); + } + } +} +static int rtl_op_sta_add(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct rtl_sta_info *sta_entry; + + if (sta) { + sta_entry = (struct rtl_sta_info *)sta->drv_priv; + spin_lock_bh(&rtlpriv->locks.entry_list_lock); + list_add_tail(&sta_entry->list, &rtlpriv->entry_list); + spin_unlock_bh(&rtlpriv->locks.entry_list_lock); + if (rtlhal->current_bandtype == BAND_ON_2_4G) { + sta_entry->wireless_mode = WIRELESS_MODE_G; + if (sta->supp_rates[0] <= 0xf) + sta_entry->wireless_mode = WIRELESS_MODE_B; + if (sta->ht_cap.ht_supported) + sta_entry->wireless_mode = WIRELESS_MODE_N_24G; + + if (vif->type == NL80211_IFTYPE_ADHOC) + sta_entry->wireless_mode = WIRELESS_MODE_G; + } else if (rtlhal->current_bandtype == BAND_ON_5G) { + sta_entry->wireless_mode = WIRELESS_MODE_A; + if (sta->ht_cap.ht_supported) + sta_entry->wireless_mode = WIRELESS_MODE_N_5G; + if (sta->vht_cap.vht_supported) + sta_entry->wireless_mode = WIRELESS_MODE_AC_5G; + + if (vif->type == NL80211_IFTYPE_ADHOC) + sta_entry->wireless_mode = WIRELESS_MODE_A; + } + /*disable cck rate for p2p*/ + if (mac->p2p) + sta->supp_rates[0] &= 0xfffffff0; + + ether_addr_copy(sta_entry->mac_addr, sta->addr); + RT_TRACE(COMP_MAC80211, DBG_DMESG, + ("Add sta addr is %pM\n", sta->addr)); + rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0); + } + + return 0; +} + +static int rtl_op_sta_remove(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_sta_info *sta_entry; + if (sta) { + RT_TRACE(COMP_MAC80211, DBG_DMESG, + ("Remove sta addr is %pM\n", sta->addr)); + sta_entry = (struct rtl_sta_info *)sta->drv_priv; + sta_entry->wireless_mode = 0; + sta_entry->ratr_index = 0; + spin_lock_bh(&rtlpriv->locks.entry_list_lock); + list_del(&sta_entry->list); + spin_unlock_bh(&rtlpriv->locks.entry_list_lock); + } + return 0; +} +static int _rtl_get_hal_qnum(u16 queue) +{ + int qnum; + + switch (queue) { + case 0: + qnum = AC3_VO; + break; + case 1: + qnum = AC2_VI; + break; + case 2: + qnum = AC0_BE; + break; + case 3: + qnum = AC1_BK; + break; + default: + qnum = AC0_BE; + break; + } + return qnum; +} + +/* + *for mac80211 VO=0, VI=1, BE=2, BK=3 + *for rtl819x BE=0, BK=1, VI=2, VO=3 + */ +static int rtl_op_conf_tx(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, u16 queue, + const struct ieee80211_tx_queue_params *param) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + int aci; + + if (queue >= AC_MAX) { + RT_TRACE(COMP_ERR, DBG_WARNING, + ("queue number %d is incorrect!\n", queue)); + return -EINVAL; + } + + aci = _rtl_get_hal_qnum(queue); + mac->ac[aci].aifs = param->aifs; + mac->ac[aci].cw_min = cpu_to_le16(param->cw_min); + mac->ac[aci].cw_max = cpu_to_le16(param->cw_max); + mac->ac[aci].tx_op = cpu_to_le16(param->txop); + memcpy(&mac->edca_param[aci], param, sizeof(*param)); + rtlpriv->cfg->ops->set_qos(hw, aci); + return 0; +} + +static void rtl_op_bss_info_changed(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_bss_conf *bss_conf, + u32 changed) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtlpriv); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + + mutex_lock(&rtlpriv->locks.conf_mutex); + if ((vif->type == NL80211_IFTYPE_ADHOC) || + (vif->type == NL80211_IFTYPE_AP) || + (vif->type == NL80211_IFTYPE_MESH_POINT)) { + if ((changed & BSS_CHANGED_BEACON) || + (changed & BSS_CHANGED_BEACON_ENABLED && + bss_conf->enable_beacon)) { + if (mac->beacon_enabled == 0) { + RT_TRACE(COMP_MAC80211, DBG_DMESG, + ("BSS_CHANGED_BEACON_ENABLED\n")); + + /*start hw beacon interrupt. */ + /*rtlpriv->cfg->ops->set_bcn_reg(hw); */ + mac->beacon_enabled = 1; + rtlpriv->cfg->ops->update_interrupt_mask(hw, + rtlpriv->cfg->maps + [RTL_IBSS_INT_MASKS], 0); + + if (rtlpriv->cfg->ops->linked_set_reg) + rtlpriv->cfg->ops->linked_set_reg(hw); + } + } + if ((changed & BSS_CHANGED_BEACON_ENABLED) && + !bss_conf->enable_beacon) { + if (mac->beacon_enabled == 1) { + RT_TRACE(COMP_MAC80211, DBG_DMESG, + ("ADHOC DISABLE BEACON\n")); + + mac->beacon_enabled = 0; + rtlpriv->cfg->ops->update_interrupt_mask(hw, 0, + rtlpriv->cfg->maps + [RTL_IBSS_INT_MASKS]); + } + } + if (changed & BSS_CHANGED_BEACON_INT) { + RT_TRACE(COMP_BEACON, DBG_TRACE, + ("BSS_CHANGED_BEACON_INT\n")); + mac->beacon_interval = bss_conf->beacon_int; + rtlpriv->cfg->ops->set_bcn_intv(hw); + } + } + + /*TODO: reference to enum ieee80211_bss_change */ + if (changed & BSS_CHANGED_ASSOC) { + u8 mstatus; + if (bss_conf->assoc) { + struct ieee80211_sta *sta = NULL; + u8 keep_alive = 10; + + mstatus = RT_MEDIA_CONNECT; + /* we should reset all sec info & cam + * before set cam after linked, we should not + * reset in disassoc, that will cause tkip->wep + * fail because some flag will be wrong */ + /* reset sec info */ + rtl92e_cam_reset_sec_info(hw); + /* reset cam to fix wep fail issue + * when change from wpa to wep */ + stg_rtl_cam_reset_all_entry(hw); + + mac->link_state = MAC80211_LINKED; + mac->cnt_after_linked = 0; + mac->assoc_id = bss_conf->aid; + memcpy(mac->bssid, bss_conf->bssid, 6); + + if (rtlpriv->cfg->ops->linked_set_reg) + rtlpriv->cfg->ops->linked_set_reg(hw); + + rcu_read_lock(); + sta = ieee80211_find_sta(vif, (u8 *)bss_conf->bssid); + if (!sta) { + pr_err("ieee80211_find_sta returned NULL\n"); + rcu_read_unlock(); + goto out; + } + + if (vif->type == NL80211_IFTYPE_STATION && sta) + rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0); + RT_TRACE(COMP_EASY_CONCURRENT, DBG_LOUD, + ("send PS STATIC frame\n")); + if (rtlpriv->dm.supp_phymode_switch) { + if (sta->ht_cap.ht_supported) + stg_rtl_send_smps_action(hw, sta, + IEEE80211_SMPS_STATIC); + } + + if (rtlhal->current_bandtype == BAND_ON_5G) { + mac->mode = WIRELESS_MODE_A; + } else { + if (sta->supp_rates[0] <= 0xf) + mac->mode = WIRELESS_MODE_B; + else + mac->mode = WIRELESS_MODE_G; + } + + if (sta->ht_cap.ht_supported) { + if (rtlhal->current_bandtype == BAND_ON_2_4G) + mac->mode = WIRELESS_MODE_N_24G; + else + mac->mode = WIRELESS_MODE_N_5G; + } + + if (sta->vht_cap.vht_supported) { + if (rtlhal->current_bandtype == BAND_ON_5G) + mac->mode = WIRELESS_MODE_AC_5G; + else + mac->mode = WIRELESS_MODE_AC_24G; + } + + rcu_read_unlock(); + + /* to avoid AP Disassociation caused by inactivity */ + rtlpriv->cfg->ops->set_hw_reg(hw, + HW_VAR_KEEP_ALIVE, + (u8 *)(&keep_alive)); + + RT_TRACE(COMP_MAC80211, DBG_DMESG, + ("BSS_CHANGED_ASSOC\n")); + } else { + mstatus = RT_MEDIA_DISCONNECT; + + if (mac->link_state == MAC80211_LINKED) + rtl92e_lps_leave(hw); + if (ppsc->p2p_ps_info.p2p_ps_mode > P2P_PS_NONE) + rtl92e_p2p_ps_cmd(hw, P2P_PS_DISABLE); + mac->link_state = MAC80211_NOLINK; + memset(mac->bssid, 0, 6); + mac->vendor = PEER_UNKNOWN; + mac->mode = 0; + + if (rtlpriv->dm.supp_phymode_switch) { + if (rtlpriv->cfg->ops->check_switch_to_dmdp) + rtlpriv->cfg->ops->check_switch_to_dmdp(hw); + } + RT_TRACE(COMP_MAC80211, DBG_DMESG, + ("BSS_CHANGED_UN_ASSOC\n")); + } + rtlpriv->cfg->ops->set_network_type(hw, vif->type); + /* For FW LPS: + * To tell firmware we have connected or disconnected*/ + rtlpriv->cfg->ops->set_hw_reg(hw, + HW_VAR_H2C_FW_JOINBSSRPT, + (u8 *)(&mstatus)); + ppsc->report_linked = (mstatus == RT_MEDIA_CONNECT) ? + true : false; + + if (rtlpriv->cfg->ops->get_btc_status()) + rtlpriv->btcoexist.btc_ops->btc_mediastatus_notify( + rtlpriv, mstatus); + } + + if (changed & BSS_CHANGED_ERP_CTS_PROT) { + RT_TRACE(COMP_MAC80211, DBG_TRACE, + ("BSS_CHANGED_ERP_CTS_PROT\n")); + mac->use_cts_protect = bss_conf->use_cts_prot; + } + + if (changed & BSS_CHANGED_ERP_PREAMBLE) { + RT_TRACE(COMP_MAC80211, DBG_LOUD, + ("BSS_CHANGED_ERP_PREAMBLE use short preamble:%x\n", + bss_conf->use_short_preamble)); + + mac->short_preamble = bss_conf->use_short_preamble; + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ACK_PREAMBLE, + (u8 *)(&mac->short_preamble)); + } + + if (changed & BSS_CHANGED_ERP_SLOT) { + RT_TRACE(COMP_MAC80211, DBG_TRACE, + ("BSS_CHANGED_ERP_SLOT\n")); + + if (bss_conf->use_short_slot) + mac->slot_time = RTL_SLOT_TIME_9; + else + mac->slot_time = RTL_SLOT_TIME_20; + + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SLOT_TIME, + (u8 *)(&mac->slot_time)); + } + + if (changed & BSS_CHANGED_HT) { + struct ieee80211_sta *sta = NULL; + + RT_TRACE(COMP_MAC80211, DBG_TRACE, + ("BSS_CHANGED_HT\n")); + + rcu_read_lock(); + sta = ieee80211_find_sta(vif, (u8 *)bss_conf->bssid); + if (sta) { + if (sta->ht_cap.ampdu_density > + mac->current_ampdu_density) + mac->current_ampdu_density = + sta->ht_cap.ampdu_density; + if (sta->ht_cap.ampdu_factor < + mac->current_ampdu_factor) + mac->current_ampdu_factor = + sta->ht_cap.ampdu_factor; + } + rcu_read_unlock(); + + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SHORTGI_DENSITY, + (u8 *)(&mac->max_mss_density)); + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AMPDU_FACTOR, + &mac->current_ampdu_factor); + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AMPDU_MIN_SPACE, + &mac->current_ampdu_density); + } + + if (changed & BSS_CHANGED_BSSID) { + u32 basic_rates; + struct ieee80211_sta *sta = NULL; + + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BSSID, + (u8 *)bss_conf->bssid); + + RT_TRACE(COMP_MAC80211, DBG_DMESG, + ("bssid: %pM\n", bss_conf->bssid)); + + mac->vendor = PEER_UNKNOWN; + memcpy(mac->bssid, bss_conf->bssid, 6); + + rcu_read_lock(); + sta = ieee80211_find_sta(vif, (u8 *)bss_conf->bssid); + if (!sta) { + rcu_read_unlock(); + goto out; + } + + if (rtlhal->current_bandtype == BAND_ON_5G) { + mac->mode = WIRELESS_MODE_A; + } else { + if (sta->supp_rates[0] <= 0xf) + mac->mode = WIRELESS_MODE_B; + else + mac->mode = WIRELESS_MODE_G; + } + + if (sta->ht_cap.ht_supported) { + if (rtlhal->current_bandtype == BAND_ON_2_4G) + mac->mode = WIRELESS_MODE_N_24G; + else + mac->mode = WIRELESS_MODE_N_5G; + } + + if (sta->vht_cap.vht_supported) { + if (rtlhal->current_bandtype == BAND_ON_5G) + mac->mode = WIRELESS_MODE_AC_5G; + else + mac->mode = WIRELESS_MODE_AC_24G; + } + + /* just station need it, because ibss & ap mode will + * set in sta_add, and will be NULL here */ + if (vif->type == NL80211_IFTYPE_STATION) { + struct rtl_sta_info *sta_entry; + sta_entry = (struct rtl_sta_info *)sta->drv_priv; + sta_entry->wireless_mode = mac->mode; + } + + if (sta->ht_cap.ht_supported) { + mac->ht_enable = true; + + /* + * for cisco 1252 bw20 it's wrong + * if (ht_cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) { + * mac->bw_40 = true; + * } + * */ + } + + if (sta->vht_cap.vht_supported) + mac->vht_enable = true; + + if (changed & BSS_CHANGED_BASIC_RATES) { + /* for 5G must << RATE_6M_INDEX=4, + * because 5G have no cck rate*/ + if (rtlhal->current_bandtype == BAND_ON_5G) + basic_rates = sta->supp_rates[1] << 4; + else + basic_rates = sta->supp_rates[0]; + + mac->basic_rates = basic_rates; + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_BASIC_RATE, + (u8 *)(&basic_rates)); + } + rcu_read_unlock(); + } +out: + mutex_unlock(&rtlpriv->locks.conf_mutex); +} + +static u64 rtl_op_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u64 tsf; + + rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_CORRECT_TSF, (u8 *)(&tsf)); + return tsf; +} + +static void rtl_op_set_tsf(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, u64 tsf) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + u8 bibss = (mac->opmode == NL80211_IFTYPE_ADHOC) ? 1 : 0; + + mac->tsf = tsf; + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_CORRECT_TSF, (u8 *)(&bibss)); +} + +static void rtl_op_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u8 tmp = 0; + + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_DUAL_TSF_RST, (u8 *)(&tmp)); +} + +static void rtl_op_sta_notify(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + enum sta_notify_cmd cmd, + struct ieee80211_sta *sta) +{ + switch (cmd) { + case STA_NOTIFY_SLEEP: + break; + case STA_NOTIFY_AWAKE: + break; + default: + break; + } +} + +static int rtl_op_ampdu_action(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + enum ieee80211_ampdu_mlme_action action, + struct ieee80211_sta *sta, u16 tid, u16 *ssn, + u8 buf_size) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + switch (action) { + case IEEE80211_AMPDU_TX_START: + RT_TRACE(COMP_MAC80211, DBG_TRACE, + ("IEEE80211_AMPDU_TX_START: TID:%d\n", tid)); + return rtl92e_tx_agg_start(hw, vif, sta, tid, ssn); + break; + case IEEE80211_AMPDU_TX_STOP_CONT: + case IEEE80211_AMPDU_TX_STOP_FLUSH: + case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: + RT_TRACE(COMP_MAC80211, DBG_TRACE, + ("IEEE80211_AMPDU_TX_STOP: TID:%d\n", tid)); + return rtl92e_tx_agg_stop(hw, vif, sta, tid); + break; + case IEEE80211_AMPDU_TX_OPERATIONAL: + RT_TRACE(COMP_MAC80211, DBG_TRACE, + ("IEEE80211_AMPDU_TX_OPERATIONAL:TID:%d\n", tid)); + rtl92e_tx_agg_oper(hw, sta, tid); + break; + case IEEE80211_AMPDU_RX_START: + RT_TRACE(COMP_MAC80211, DBG_TRACE, + ("IEEE80211_AMPDU_RX_START:TID:%d\n", tid)); + return rtl92e_rx_agg_start(hw, sta, tid); + break; + case IEEE80211_AMPDU_RX_STOP: + RT_TRACE(COMP_MAC80211, DBG_TRACE, + ("IEEE80211_AMPDU_RX_STOP:TID:%d\n", tid)); + return rtl92e_rx_agg_stop(hw, sta, tid); + break; + default: + RT_TRACE(COMP_ERR, DBG_EMERG, + ("IEEE80211_AMPDU_ERR!!!!:\n")); + return -EOPNOTSUPP; + } + return 0; +} + +static void rtl_op_sw_scan_start(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + + RT_TRACE(COMP_MAC80211, DBG_LOUD, ("\n")); + mac->act_scanning = true; + if (rtlpriv->link_info.b_higher_busytraffic) { + mac->skip_scan = true; + return; + } + + if (rtlpriv->cfg->ops->get_btc_status()) + rtlpriv->btcoexist.btc_ops->btc_scan_notify(rtlpriv, 1); + + if (rtlpriv->dm.supp_phymode_switch) { + if (rtlpriv->cfg->ops->check_switch_to_dmdp) + rtlpriv->cfg->ops->check_switch_to_dmdp(hw); + } + + if (mac->link_state == MAC80211_LINKED) { + rtl92e_lps_leave(hw); + mac->link_state = MAC80211_LINKED_SCANNING; + } else { + rtl92e_ips_nic_on(hw); + } + + /* Dul mac */ + rtlpriv->rtlhal.b_load_imrandiqk_setting_for2g = false; + + rtlpriv->cfg->ops->led_control(hw, LED_CTL_SITE_SURVEY); + rtlpriv->cfg->ops->scan_operation_backup(hw, SCAN_OPT_BACKUP_BAND0); +} + +static void rtl_op_sw_scan_complete(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + + RT_TRACE(COMP_MAC80211, DBG_LOUD, ("\n")); + mac->act_scanning = false; + mac->skip_scan = false; + if (rtlpriv->link_info.b_higher_busytraffic) + return; + + /* p2p will use 1/6/11 to scan */ + if (mac->n_channels == 3) + mac->p2p_in_use = true; + else + mac->p2p_in_use = false; + mac->n_channels = 0; + /* Dul mac */ + rtlpriv->rtlhal.b_load_imrandiqk_setting_for2g = false; + + if (mac->link_state == MAC80211_LINKED_SCANNING) { + mac->link_state = MAC80211_LINKED; + if (mac->opmode == NL80211_IFTYPE_STATION) { + /* fix fwlps issue */ + rtlpriv->cfg->ops->set_network_type(hw, mac->opmode); + } + } + + rtlpriv->cfg->ops->scan_operation_backup(hw, SCAN_OPT_RESTORE); + if (rtlpriv->cfg->ops->get_btc_status()) + rtlpriv->btcoexist.btc_ops->btc_scan_notify(rtlpriv, 0); +} + +static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, + struct ieee80211_vif *vif, struct ieee80211_sta *sta, + struct ieee80211_key_conf *key) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u8 key_type = NO_ENCRYPTION; + u8 key_idx; + bool group_key = false; + bool wep_only = false; + int err = 0; + u8 mac_addr[ETH_ALEN]; + u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; + + if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) { + RT_TRACE(COMP_ERR, DBG_WARNING, + ("not open hw encryption\n")); + return -ENOSPC; /*User disabled HW-crypto */ + } + /* To support IBSS, use sw-crypto for GTK */ + if (((vif->type == NL80211_IFTYPE_ADHOC) || + (vif->type == NL80211_IFTYPE_MESH_POINT)) && + !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) + return -ENOSPC; + RT_TRACE(COMP_SEC, DBG_DMESG, + ("%s hardware based encryption for keyidx: %d, mac: %pM\n", + cmd == SET_KEY ? "Using" : "Disabling", key->keyidx, + sta ? sta->addr : bcast_addr)); + rtlpriv->sec.being_setkey = true; + rtl92e_ips_nic_on(hw); + mutex_lock(&rtlpriv->locks.conf_mutex); + /* <1> get encryption alg */ + + switch (key->cipher) { + case WLAN_CIPHER_SUITE_WEP40: + key_type = WEP40_ENCRYPTION; + RT_TRACE(COMP_SEC, DBG_DMESG, ("alg:WEP40\n")); + break; + case WLAN_CIPHER_SUITE_WEP104: + RT_TRACE(COMP_SEC, DBG_DMESG, ("alg:WEP104\n")); + key_type = WEP104_ENCRYPTION; + break; + case WLAN_CIPHER_SUITE_TKIP: + key_type = TKIP_ENCRYPTION; + RT_TRACE(COMP_SEC, DBG_DMESG, ("alg:TKIP\n")); + break; + case WLAN_CIPHER_SUITE_CCMP: + key_type = AESCCMP_ENCRYPTION; + RT_TRACE(COMP_SEC, DBG_DMESG, ("alg:CCMP\n")); + break; + case WLAN_CIPHER_SUITE_AES_CMAC: + /* HW don't support CMAC encryption, + * use software CMAC encryption */ + key_type = AESCMAC_ENCRYPTION; + RT_TRACE(COMP_SEC, DBG_DMESG, ("alg:CMAC\n")); + RT_TRACE(COMP_SEC, DBG_DMESG, + ("HW don't support CMAC encrypiton, use software CMAC encryption\n")); + err = -EOPNOTSUPP; + goto out_unlock; + default: + RT_TRACE(COMP_ERR, DBG_EMERG, + ("alg_err:%x!!!!:\n", key->cipher)); + goto out_unlock; + } + if (key_type == WEP40_ENCRYPTION || + key_type == WEP104_ENCRYPTION || + vif->type == NL80211_IFTYPE_ADHOC) + rtlpriv->sec.use_defaultkey = true; + + /* <2> get key_idx */ + key_idx = (u8) (key->keyidx); + if (key_idx > 3) + goto out_unlock; + /* <3> if pairwise key enable_hw_sec */ + group_key = !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE); + + /* wep always be group key, but there are two conditions: + * 1) wep only: is just for wep enc, in this condition + * rtlpriv->sec.pairwise_enc_algorithm == NO_ENCRYPTION + * will be true & enable_hw_sec will be set when wep + * ke setting. + * 2) wep(group) + AES(pairwise): some AP like cisco + * may use it, in this condition enable_hw_sec will not + * be set when wep key setting */ + /* we must reset sec_info after lingked before set key, + * or some flag will be wrong*/ + if (vif->type == NL80211_IFTYPE_AP || + vif->type == NL80211_IFTYPE_MESH_POINT) { + if (!group_key || key_type == WEP40_ENCRYPTION || + key_type == WEP104_ENCRYPTION) { + if (group_key) + wep_only = true; + rtlpriv->cfg->ops->enable_hw_sec(hw); + } + } else { + if ((!group_key) || (vif->type == NL80211_IFTYPE_ADHOC) || + rtlpriv->sec.pairwise_enc_algorithm == NO_ENCRYPTION) { + if (rtlpriv->sec.pairwise_enc_algorithm == + NO_ENCRYPTION && + (key_type == WEP40_ENCRYPTION || + key_type == WEP104_ENCRYPTION)) + wep_only = true; + rtlpriv->sec.pairwise_enc_algorithm = key_type; + RT_TRACE(COMP_SEC, DBG_DMESG, + ("set enable_hw_sec, key_type:%x(OPEN:0 WEP40:1 TKIP:2 AES:4 WEP104:5)\n", + key_type)); + rtlpriv->cfg->ops->enable_hw_sec(hw); + } + } + /* <4> set key based on cmd */ + switch (cmd) { + case SET_KEY: + if (wep_only) { + RT_TRACE(COMP_SEC, DBG_DMESG, + ("set WEP(group/pairwise) key\n")); + /* Pairwise key with an assigned MAC address. */ + rtlpriv->sec.pairwise_enc_algorithm = key_type; + rtlpriv->sec.group_enc_algorithm = key_type; + /*set local buf about wep key. */ + memcpy(rtlpriv->sec.key_buf[key_idx], + key->key, key->keylen); + rtlpriv->sec.key_len[key_idx] = key->keylen; + eth_zero_addr(mac_addr); + } else if (group_key) { /* group key */ + RT_TRACE(COMP_SEC, DBG_DMESG, + ("set group key\n")); + /* group key */ + rtlpriv->sec.group_enc_algorithm = key_type; + /*set local buf about group key. */ + memcpy(rtlpriv->sec.key_buf[key_idx], + key->key, key->keylen); + rtlpriv->sec.key_len[key_idx] = key->keylen; + ether_addr_copy(mac_addr, bcast_addr); + } else { /* pairwise key */ + RT_TRACE(COMP_SEC, DBG_DMESG, + ("set pairwise key\n")); + if (!sta) { + RT_ASSERT(false, + ("pairwise key without mac_addr\n")); + + err = -EOPNOTSUPP; + goto out_unlock; + } + /* Pairwise key with an assigned MAC address. */ + rtlpriv->sec.pairwise_enc_algorithm = key_type; + /*set local buf about pairwise key. */ + memcpy(rtlpriv->sec.key_buf[PAIRWISE_KEYIDX], + key->key, key->keylen); + rtlpriv->sec.key_len[PAIRWISE_KEYIDX] = key->keylen; + rtlpriv->sec.pairwise_key = + rtlpriv->sec.key_buf[PAIRWISE_KEYIDX]; + ether_addr_copy(mac_addr, sta->addr); + } + rtlpriv->cfg->ops->set_key(hw, key_idx, mac_addr, + group_key, key_type, wep_only, + false); + /* <5> tell mac80211 do something: */ + /*must use sw generate IV, or can not work !!!!. */ + key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; + key->hw_key_idx = key_idx; + if (key_type == TKIP_ENCRYPTION) + key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; + /*use software CCMP encryption for management frames (MFP) */ + if (key_type == AESCCMP_ENCRYPTION) + key->flags |= IEEE80211_KEY_FLAG_SW_MGMT; + break; + case DISABLE_KEY: + RT_TRACE(COMP_SEC, DBG_DMESG, + ("disable key delete one entry\n")); + /*set local buf about wep key. */ + if (vif->type == NL80211_IFTYPE_AP || + vif->type == NL80211_IFTYPE_MESH_POINT) { + if (sta) + stg_rtl_cam_del_entry(hw, sta->addr); + } + memset(rtlpriv->sec.key_buf[key_idx], 0, key->keylen); + rtlpriv->sec.key_len[key_idx] = 0; + eth_zero_addr(mac_addr); + /* + *mac80211 will delete entrys one by one, + *so don't use stg_rtl_cam_reset_all_entry + *or clear all entry here. + */ + stg_rtl_cam_delete_one_entry(hw, mac_addr, key_idx); + break; + default: + RT_TRACE(COMP_ERR, DBG_EMERG, + ("cmd_err:%x!!!!:\n", cmd)); + } +out_unlock: + mutex_unlock(&rtlpriv->locks.conf_mutex); + rtlpriv->sec.being_setkey = false; + return err; +} + +static void rtl_op_rfkill_poll(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + bool radio_state; + bool blocked; + u8 valid = 0; + + if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status)) + return; + + mutex_lock(&rtlpriv->locks.conf_mutex); + + /*if Radio On return true here */ + radio_state = rtlpriv->cfg->ops->radio_onoff_checking(hw, &valid); + + if (valid) { + if (unlikely(radio_state != rtlpriv->rfkill.rfkill_state)) { + rtlpriv->rfkill.rfkill_state = radio_state; + + RT_TRACE(COMP_RF, DBG_DMESG, + (KERN_INFO "wireless radio switch turned %s\n", + radio_state ? "on" : "off")); + + blocked = (rtlpriv->rfkill.rfkill_state == 1) ? 0 : 1; + wiphy_rfkill_set_hw_state(hw->wiphy, blocked); + } + } + + mutex_unlock(&rtlpriv->locks.conf_mutex); +} + +/* this function is called by mac80211 to flush tx buffer + * before switch channle or power save, or tx buffer packet + * maybe send after offchannel or rf sleep, this may cause + * dis-association by AP */ +static void rtl_op_flush(struct ieee80211_hw *hw, + u32 queues, bool drop) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + if (rtlpriv->intf_ops->flush) + rtlpriv->intf_ops->flush(hw, queues, drop); +} + +const struct ieee80211_ops rtl92e_ops = { + .start = rtl_op_start, + .stop = rtl_op_stop, + .tx = rtl_op_tx, + .add_interface = rtl_op_add_interface, + .remove_interface = rtl_op_remove_interface, + .change_interface = rtl_op_change_interface, +#ifdef CONFIG_PM + .suspend = rtl_op_suspend, + .resume = rtl_op_resume, +#endif + .config = rtl_op_config, + .configure_filter = rtl_op_configure_filter, + .set_key = rtl_op_set_key, + .conf_tx = rtl_op_conf_tx, + .bss_info_changed = rtl_op_bss_info_changed, + .get_tsf = rtl_op_get_tsf, + .set_tsf = rtl_op_set_tsf, + .reset_tsf = rtl_op_reset_tsf, + .sta_notify = rtl_op_sta_notify, + .ampdu_action = rtl_op_ampdu_action, + .sw_scan_start = rtl_op_sw_scan_start, + .sw_scan_complete = rtl_op_sw_scan_complete, + .rfkill_poll = rtl_op_rfkill_poll, + .sta_add = rtl_op_sta_add, + .sta_remove = rtl_op_sta_remove, + .flush = rtl_op_flush, +}; diff --git a/drivers/staging/rtl8192ee/core.h b/drivers/staging/rtl8192ee/core.h new file mode 100644 index 000000000000..ef75ad5f029a --- /dev/null +++ b/drivers/staging/rtl8192ee/core.h @@ -0,0 +1,39 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * Tmis 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. + * + * Tme full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#ifndef __RTL_CORE_H__ +#define __RTL_CORE_H__ + +#define RTL_SUPPORTED_FILTERS \ + (FIF_PROMISC_IN_BSS | \ + FIF_ALLMULTI | FIF_CONTROL | \ + FIF_OTHER_BSS | \ + FIF_FCSFAIL | \ + FIF_BCN_PRBRESP_PROMISC) + +#define RTL_SUPPORTED_CTRL_FILTER 0xFF + +extern const struct ieee80211_ops rtl92e_ops; +#endif diff --git a/drivers/staging/rtl8192ee/debug.c b/drivers/staging/rtl8192ee/debug.c new file mode 100644 index 000000000000..feec3948585d --- /dev/null +++ b/drivers/staging/rtl8192ee/debug.c @@ -0,0 +1,978 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * Tmis 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#include "wifi.h" +#include "cam.h" + +#define GET_INODE_DATA(__node) PDE_DATA(__node) + + +void rtl92e_dbgp_flag_init(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u8 i; + + rtlpriv->dbg.global_debuglevel = DBG_DMESG; + + rtlpriv->dbg.global_debugcomponents = + COMP_ERR | + COMP_FW | + COMP_INIT | + COMP_RECV | + COMP_SEND | + COMP_MLME | + COMP_SCAN | + COMP_INTR | + COMP_LED | + COMP_SEC | + COMP_BEACON | + COMP_RATE | + COMP_RXDESC | + COMP_DIG | + COMP_TXAGC | + COMP_POWER | + COMP_POWER_TRACKING | + COMP_BB_POWERSAVING | + COMP_SWAS | + COMP_RF | + COMP_TURBO | + COMP_RATR | + COMP_CMD | + COMP_EASY_CONCURRENT | + COMP_EFUSE | + COMP_QOS | COMP_MAC80211 | COMP_REGD | + COMP_CHAN | + COMP_BT_COEXIST | + COMP_IQK | + 0; + + for (i = 0; i < DBGP_TYPE_MAX; i++) + rtlpriv->dbg.dbgp_type[i] = 0; + + /*Init Debug flag enable condition */ +} + +static struct proc_dir_entry *proc_topdir; + +static int rtl_proc_get_mac_0(struct seq_file *m, void *v) +{ + struct ieee80211_hw *hw = m->private; + struct rtl_priv *rtlpriv = rtl_priv(hw); + int i, n, page; + int max = 0xff; + page = 0x000; + + for (n = 0; n <= max; ) { + seq_printf(m, "\n%8.8x ", n + page); + for (i = 0; i < 4 && n <= max; i++, n += 4) + seq_printf(m, "%8.8x ", + rtl_read_dword(rtlpriv, (page | n))); + } + seq_puts(m, "\n"); + return 0; +} + +static int dl_proc_open_mac_0(struct inode *inode, struct file *file) +{ + return single_open(file, rtl_proc_get_mac_0, GET_INODE_DATA(inode)); +} + +static const struct file_operations file_ops_mac_0 = { + .open = dl_proc_open_mac_0, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +static int rtl_proc_get_mac_1(struct seq_file *m, void *v) +{ + struct ieee80211_hw *hw = m->private; + struct rtl_priv *rtlpriv = rtl_priv(hw); + int i, n, page; + int max = 0xff; + page = 0x100; + + for (n = 0; n <= max; ) { + seq_printf(m, "\n%8.8x ", n + page); + for (i = 0; i < 4 && n <= max; i++, n += 4) + seq_printf(m, "%8.8x ", + rtl_read_dword(rtlpriv, (page | n))); + } + seq_puts(m, "\n"); + return 0; +} + +static int dl_proc_open_mac_1(struct inode *inode, struct file *file) +{ + return single_open(file, rtl_proc_get_mac_1, GET_INODE_DATA(inode)); +} + +static const struct file_operations file_ops_mac_1 = { + .open = dl_proc_open_mac_1, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +static int rtl_proc_get_mac_2(struct seq_file *m, void *v) +{ + struct ieee80211_hw *hw = m->private; + struct rtl_priv *rtlpriv = rtl_priv(hw); + int i, n, page; + int max = 0xff; + page = 0x200; + + for (n = 0; n <= max; ) { + seq_printf(m, "\n%8.8x ", n + page); + for (i = 0; i < 4 && n <= max; i++, n += 4) + seq_printf(m, "%8.8x ", + rtl_read_dword(rtlpriv, (page | n))); + } + seq_puts(m, "\n"); + return 0; +} + +static int dl_proc_open_mac_2(struct inode *inode, struct file *file) +{ + return single_open(file, rtl_proc_get_mac_2, GET_INODE_DATA(inode)); +} + +static const struct file_operations file_ops_mac_2 = { + .open = dl_proc_open_mac_2, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +static int rtl_proc_get_mac_3(struct seq_file *m, void *v) +{ + struct ieee80211_hw *hw = m->private; + struct rtl_priv *rtlpriv = rtl_priv(hw); + int i, n, page; + int max = 0xff; + page = 0x300; + + for (n = 0; n <= max; ) { + seq_printf(m, "\n%8.8x ", n + page); + for (i = 0; i < 4 && n <= max; i++, n += 4) + seq_printf(m, "%8.8x ", + rtl_read_dword(rtlpriv, (page | n))); + } + seq_puts(m, "\n"); + return 0; +} + +static int dl_proc_open_mac_3(struct inode *inode, struct file *file) +{ + return single_open(file, rtl_proc_get_mac_3, GET_INODE_DATA(inode)); +} + +static const struct file_operations file_ops_mac_3 = { + .open = dl_proc_open_mac_3, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +static int rtl_proc_get_mac_4(struct seq_file *m, void *v) +{ + struct ieee80211_hw *hw = m->private; + struct rtl_priv *rtlpriv = rtl_priv(hw); + int i, n, page; + int max = 0xff; + page = 0x400; + + for (n = 0; n <= max; ) { + seq_printf(m, "\n%8.8x ", n + page); + for (i = 0; i < 4 && n <= max; i++, n += 4) + seq_printf(m, "%8.8x ", + rtl_read_dword(rtlpriv, (page | n))); + } + seq_puts(m, "\n"); + return 0; +} + +static int dl_proc_open_mac_4(struct inode *inode, struct file *file) +{ + return single_open(file, rtl_proc_get_mac_4, GET_INODE_DATA(inode)); +} + +static const struct file_operations file_ops_mac_4 = { + .open = dl_proc_open_mac_4, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +static int rtl_proc_get_mac_5(struct seq_file *m, void *v) +{ + struct ieee80211_hw *hw = m->private; + struct rtl_priv *rtlpriv = rtl_priv(hw); + int i, n, page; + int max = 0xff; + page = 0x500; + + for (n = 0; n <= max; ) { + seq_printf(m, "\n%8.8x ", n + page); + for (i = 0; i < 4 && n <= max; i++, n += 4) + seq_printf(m, "%8.8x ", + rtl_read_dword(rtlpriv, (page | n))); + } + seq_puts(m, "\n"); + return 0; +} + +static int dl_proc_open_mac_5(struct inode *inode, struct file *file) +{ + return single_open(file, rtl_proc_get_mac_5, GET_INODE_DATA(inode)); +} + +static const struct file_operations file_ops_mac_5 = { + .open = dl_proc_open_mac_5, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +static int rtl_proc_get_mac_6(struct seq_file *m, void *v) +{ + struct ieee80211_hw *hw = m->private; + struct rtl_priv *rtlpriv = rtl_priv(hw); + int i, n, page; + int max = 0xff; + page = 0x600; + + for (n = 0; n <= max; ) { + seq_printf(m, "\n%8.8x ", n + page); + for (i = 0; i < 4 && n <= max; i++, n += 4) + seq_printf(m, "%8.8x ", + rtl_read_dword(rtlpriv, (page | n))); + } + seq_puts(m, "\n"); + return 0; +} + +static int dl_proc_open_mac_6(struct inode *inode, struct file *file) +{ + return single_open(file, rtl_proc_get_mac_6, GET_INODE_DATA(inode)); +} + +static const struct file_operations file_ops_mac_6 = { + .open = dl_proc_open_mac_6, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +static int rtl_proc_get_mac_7(struct seq_file *m, void *v) +{ + struct ieee80211_hw *hw = m->private; + struct rtl_priv *rtlpriv = rtl_priv(hw); + int i, n, page; + int max = 0xff; + page = 0x700; + + for (n = 0; n <= max; ) { + seq_printf(m, "\n%8.8x ", n + page); + for (i = 0; i < 4 && n <= max; i++, n += 4) + seq_printf(m, "%8.8x ", + rtl_read_dword(rtlpriv, (page | n))); + } + seq_puts(m, "\n"); + return 0; +} + +static int dl_proc_open_mac_7(struct inode *inode, struct file *file) +{ + return single_open(file, rtl_proc_get_mac_7, GET_INODE_DATA(inode)); +} + +static const struct file_operations file_ops_mac_7 = { + .open = dl_proc_open_mac_7, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +static int rtl_proc_get_bb_8(struct seq_file *m, void *v) +{ + struct ieee80211_hw *hw = m->private; + int i, n, page; + int max = 0xff; + page = 0x800; + + for (n = 0; n <= max; ) { + seq_printf(m, "\n%8.8x ", n + page); + for (i = 0; i < 4 && n <= max; i++, n += 4) + seq_printf(m, "%8.8x ", + rtl_get_bbreg(hw, (page | n), 0xffffffff)); + } + seq_puts(m, "\n"); + return 0; +} + +static int dl_proc_open_bb_8(struct inode *inode, struct file *file) +{ + return single_open(file, rtl_proc_get_bb_8, GET_INODE_DATA(inode)); +} + +static const struct file_operations file_ops_bb_8 = { + .open = dl_proc_open_bb_8, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +static int rtl_proc_get_bb_9(struct seq_file *m, void *v) +{ + struct ieee80211_hw *hw = m->private; + int i, n, page; + int max = 0xff; + page = 0x900; + + for (n = 0; n <= max; ) { + seq_printf(m, "\n%8.8x ", n + page); + for (i = 0; i < 4 && n <= max; i++, n += 4) + seq_printf(m, "%8.8x ", + rtl_get_bbreg(hw, (page | n), 0xffffffff)); + } + seq_puts(m, "\n"); + return 0; +} + +static int dl_proc_open_bb_9(struct inode *inode, struct file *file) +{ + return single_open(file, rtl_proc_get_bb_9, GET_INODE_DATA(inode)); +} + +static const struct file_operations file_ops_bb_9 = { + .open = dl_proc_open_bb_9, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +static int rtl_proc_get_bb_a(struct seq_file *m, void *v) +{ + struct ieee80211_hw *hw = m->private; + int i, n, page; + int max = 0xff; + page = 0xa00; + + for (n = 0; n <= max; ) { + seq_printf(m, "\n%8.8x ", n + page); + for (i = 0; i < 4 && n <= max; i++, n += 4) + seq_printf(m, "%8.8x ", + rtl_get_bbreg(hw, (page | n), 0xffffffff)); + } + seq_puts(m, "\n"); + return 0; +} + +static int dl_proc_open_bb_a(struct inode *inode, struct file *file) +{ + return single_open(file, rtl_proc_get_bb_a, GET_INODE_DATA(inode)); +} + +static const struct file_operations file_ops_bb_a = { + .open = dl_proc_open_bb_a, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +static int rtl_proc_get_bb_b(struct seq_file *m, void *v) +{ + struct ieee80211_hw *hw = m->private; + int i, n, page; + int max = 0xff; + page = 0xb00; + + for (n = 0; n <= max; ) { + seq_printf(m, "\n%8.8x ", n + page); + for (i = 0; i < 4 && n <= max; i++, n += 4) + seq_printf(m, "%8.8x ", + rtl_get_bbreg(hw, (page | n), 0xffffffff)); + } + seq_puts(m, "\n"); + return 0; +} + +static int dl_proc_open_bb_b(struct inode *inode, struct file *file) +{ + return single_open(file, rtl_proc_get_bb_b, GET_INODE_DATA(inode)); +} + +static const struct file_operations file_ops_bb_b = { + .open = dl_proc_open_bb_b, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +static int rtl_proc_get_bb_c(struct seq_file *m, void *v) +{ + struct ieee80211_hw *hw = m->private; + int i, n, page; + int max = 0xff; + page = 0xc00; + + for (n = 0; n <= max; ) { + seq_printf(m, "\n%8.8x ", n + page); + for (i = 0; i < 4 && n <= max; i++, n += 4) + seq_printf(m, "%8.8x ", + rtl_get_bbreg(hw, (page | n), 0xffffffff)); + } + seq_puts(m, "\n"); + return 0; +} + +static int dl_proc_open_bb_c(struct inode *inode, struct file *file) +{ + return single_open(file, rtl_proc_get_bb_c, GET_INODE_DATA(inode)); +} + +static const struct file_operations file_ops_bb_c = { + .open = dl_proc_open_bb_c, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +static int rtl_proc_get_bb_d(struct seq_file *m, void *v) +{ + struct ieee80211_hw *hw = m->private; + int i, n, page; + int max = 0xff; + page = 0xd00; + + for (n = 0; n <= max; ) { + seq_printf(m, "\n%8.8x ", n + page); + for (i = 0; i < 4 && n <= max; i++, n += 4) + seq_printf(m, "%8.8x ", + rtl_get_bbreg(hw, (page | n), 0xffffffff)); + } + seq_puts(m, "\n"); + return 0; +} + +static int dl_proc_open_bb_d(struct inode *inode, struct file *file) +{ + return single_open(file, rtl_proc_get_bb_d, GET_INODE_DATA(inode)); +} + +static const struct file_operations file_ops_bb_d = { + .open = dl_proc_open_bb_d, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +static int rtl_proc_get_bb_e(struct seq_file *m, void *v) +{ + struct ieee80211_hw *hw = m->private; + int i, n, page; + int max = 0xff; + page = 0xe00; + + for (n = 0; n <= max; ) { + seq_printf(m, "\n%8.8x ", n + page); + for (i = 0; i < 4 && n <= max; i++, n += 4) + seq_printf(m, "%8.8x ", + rtl_get_bbreg(hw, (page | n), 0xffffffff)); + } + seq_puts(m, "\n"); + return 0; +} + +static int dl_proc_open_bb_e(struct inode *inode, struct file *file) +{ + return single_open(file, rtl_proc_get_bb_e, GET_INODE_DATA(inode)); +} + +static const struct file_operations file_ops_bb_e = { + .open = dl_proc_open_bb_e, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +static int rtl_proc_get_bb_f(struct seq_file *m, void *v) +{ + struct ieee80211_hw *hw = m->private; + int i, n, page; + int max = 0xff; + page = 0xf00; + + for (n = 0; n <= max; ) { + seq_printf(m, "\n%8.8x ", n + page); + for (i = 0; i < 4 && n <= max; i++, n += 4) + seq_printf(m, "%8.8x ", + rtl_get_bbreg(hw, (page | n), 0xffffffff)); + } + seq_puts(m, "\n"); + return 0; +} + +static int dl_proc_open_bb_f(struct inode *inode, struct file *file) +{ + return single_open(file, rtl_proc_get_bb_f, GET_INODE_DATA(inode)); +} + +static const struct file_operations file_ops_bb_f = { + .open = dl_proc_open_bb_f, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +static int rtl_proc_get_reg_rf_a(struct seq_file *m, void *v) +{ + struct ieee80211_hw *hw = m->private; + int i, n; + int max = 0x40; + + for (n = 0; n <= max; ) { + seq_printf(m, "\n%8.8x ", n); + for (i = 0; i < 4 && n <= max; n += 1, i++) + seq_printf(m, "%8.8x ", + rtl_get_rfreg(hw, RF90_PATH_A, n, 0xffffffff)); + } + seq_puts(m, "\n"); + return 0; +} + +static int dl_proc_open_rf_a(struct inode *inode, struct file *file) +{ + return single_open(file, rtl_proc_get_reg_rf_a, GET_INODE_DATA(inode)); +} + +static const struct file_operations file_ops_rf_a = { + .open = dl_proc_open_rf_a, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +static int rtl_proc_get_reg_rf_b(struct seq_file *m, void *v) +{ + struct ieee80211_hw *hw = m->private; + int i, n; + int max = 0x40; + + for (n = 0; n <= max; ) { + seq_printf(m, "\n%8.8x ", n); + for (i = 0; i < 4 && n <= max; n += 1, i++) + seq_printf(m, "%8.8x ", + rtl_get_rfreg(hw, RF90_PATH_B, n, + 0xffffffff)); + } + seq_puts(m, "\n"); + return 0; +} + +static int dl_proc_open_rf_b(struct inode *inode, struct file *file) +{ + return single_open(file, rtl_proc_get_reg_rf_b, GET_INODE_DATA(inode)); +} + +static const struct file_operations file_ops_rf_b = { + .open = dl_proc_open_rf_b, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +static int rtl_proc_get_cam_register_1(struct seq_file *m, void *v) +{ + struct ieee80211_hw *hw = m->private; + struct rtl_priv *rtlpriv = rtl_priv(hw); + u32 target_cmd = 0; + u32 target_val = 0; + u8 entry_i = 0; + u32 ulstatus; + int i = 100, j = 0; + + /* This dump the current register page */ + seq_puts(m, + "\n#################### SECURITY CAM (0-10) ##################\n "); + + for (j = 0; j < 11; j++) { + seq_printf(m, "\nD: %2x > ", j); + for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) { + /* polling bit, and No Write enable, and address */ + target_cmd = entry_i + CAM_CONTENT_COUNT * j; + target_cmd = target_cmd | BIT(31); + + /* Check polling bit is clear */ + while ((i--) >= 0) { + ulstatus = rtl_read_dword(rtlpriv, + rtlpriv->cfg->maps[RWCAM]); + if (ulstatus & BIT(31)) + continue; + else + break; + } + + rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM], + target_cmd); + target_val = rtl_read_dword(rtlpriv, + rtlpriv->cfg->maps[RCAMO]); + seq_printf(m, "%8.8x ", target_val); + } + } + seq_puts(m, "\n"); + return 0; +} + +static int dl_proc_open_cam_1(struct inode *inode, struct file *file) +{ + return single_open(file, rtl_proc_get_cam_register_1, + GET_INODE_DATA(inode)); +} + +static const struct file_operations file_ops_cam_1 = { + .open = dl_proc_open_cam_1, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +static int rtl_proc_get_cam_register_2(struct seq_file *m, void *v) +{ + struct ieee80211_hw *hw = m->private; + struct rtl_priv *rtlpriv = rtl_priv(hw); + u32 target_cmd = 0; + u32 target_val = 0; + u8 entry_i = 0; + u32 ulstatus; + int i = 100, j = 0; + + /* This dump the current register page */ + seq_puts(m, + "\n################### SECURITY CAM (11-21) ##################\n "); + + for (j = 11; j < 22; j++) { + seq_printf(m, "\nD: %2x > ", j); + for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) { + target_cmd = entry_i + CAM_CONTENT_COUNT * j; + target_cmd = target_cmd | BIT(31); + + while ((i--) >= 0) { + ulstatus = rtl_read_dword(rtlpriv, + rtlpriv->cfg->maps[RWCAM]); + if (ulstatus & BIT(31)) + continue; + else + break; + } + + rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM], + target_cmd); + target_val = rtl_read_dword(rtlpriv, + rtlpriv->cfg->maps[RCAMO]); + seq_printf(m, "%8.8x ", target_val); + } + } + seq_puts(m, "\n"); + return 0; +} + +static int dl_proc_open_cam_2(struct inode *inode, struct file *file) +{ + return single_open(file, rtl_proc_get_cam_register_2, + GET_INODE_DATA(inode)); +} + +static const struct file_operations file_ops_cam_2 = { + .open = dl_proc_open_cam_2, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +static int rtl_proc_get_cam_register_3(struct seq_file *m, void *v) +{ + struct ieee80211_hw *hw = m->private; + struct rtl_priv *rtlpriv = rtl_priv(hw); + u32 target_cmd = 0; + u32 target_val = 0; + u8 entry_i = 0; + u32 ulstatus; + int i = 100, j = 0; + + /* This dump the current register page */ + seq_puts(m, + "\n################### SECURITY CAM (22-31) ##################\n "); + + for (j = 22; j < TOTAL_CAM_ENTRY; j++) { + seq_printf(m, "\nD: %2x > ", j); + for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) { + target_cmd = entry_i+CAM_CONTENT_COUNT*j; + target_cmd = target_cmd | BIT(31); + + while ((i--) >= 0) { + ulstatus = rtl_read_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM]); + if (ulstatus & BIT(31)) + continue; + else + break; + } + + rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM], + target_cmd); + target_val = rtl_read_dword(rtlpriv, + rtlpriv->cfg->maps[RCAMO]); + seq_printf(m, "%8.8x ", target_val); + } + } + seq_puts(m, "\n"); + return 0; +} + +static int dl_proc_open_cam_3(struct inode *inode, struct file *file) +{ + return single_open(file, rtl_proc_get_cam_register_3, + GET_INODE_DATA(inode)); +} + +static const struct file_operations file_ops_cam_3 = { + .open = dl_proc_open_cam_3, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +void rtl_proc_add_one(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); + struct proc_dir_entry *entry; + + snprintf(rtlpriv->dbg.proc_name, 18, "%x-%x-%x-%x-%x-%x", + rtlefuse->dev_addr[0], rtlefuse->dev_addr[1], + rtlefuse->dev_addr[2], rtlefuse->dev_addr[3], + rtlefuse->dev_addr[4], rtlefuse->dev_addr[5]); + + rtlpriv->dbg.proc_dir = proc_mkdir(rtlpriv->dbg.proc_name, proc_topdir); + if (!rtlpriv->dbg.proc_dir) { + RT_TRACE(COMP_INIT, DBG_EMERG, + ("Unable to init /proc/net/%s/%s\n", + rtlpriv->cfg->name, + rtlpriv->dbg.proc_name)); + return; + } + + entry = proc_create_data("mac-0", S_IFREG | S_IRUGO, + rtlpriv->dbg.proc_dir, &file_ops_mac_0, hw); + if (!entry) + RT_TRACE(COMP_INIT, DBG_EMERG, + ("Unable to initialize /proc/net/%s/%s/mac-0\n", + rtlpriv->cfg->name, rtlpriv->dbg.proc_name)); + + entry = proc_create_data("mac-1", S_IFREG | S_IRUGO, + rtlpriv->dbg.proc_dir, &file_ops_mac_1, hw); + if (!entry) + RT_TRACE(COMP_INIT, COMP_ERR, + ("Unable to initialize /proc/net/%s/%s/mac-1\n", + rtlpriv->cfg->name, rtlpriv->dbg.proc_name)); + + entry = proc_create_data("mac-2", S_IFREG | S_IRUGO, + rtlpriv->dbg.proc_dir, &file_ops_mac_2, hw); + if (!entry) + RT_TRACE(COMP_INIT, COMP_ERR, + ("Unable to initialize /proc/net/%s/%s/mac-2\n", + rtlpriv->cfg->name, rtlpriv->dbg.proc_name)); + + entry = proc_create_data("mac-3", S_IFREG | S_IRUGO, + rtlpriv->dbg.proc_dir, &file_ops_mac_3, hw); + if (!entry) + RT_TRACE(COMP_INIT, COMP_ERR, + ("Unable to initialize /proc/net/%s/%s/mac-3\n", + rtlpriv->cfg->name, rtlpriv->dbg.proc_name)); + + entry = proc_create_data("mac-4", S_IFREG | S_IRUGO, + rtlpriv->dbg.proc_dir, &file_ops_mac_4, hw); + if (!entry) + RT_TRACE(COMP_INIT, COMP_ERR, + ("Unable to initialize /proc/net/%s/%s/mac-4\n", + rtlpriv->cfg->name, rtlpriv->dbg.proc_name)); + + entry = proc_create_data("mac-5", S_IFREG | S_IRUGO, + rtlpriv->dbg.proc_dir, &file_ops_mac_5, hw); + if (!entry) + RT_TRACE(COMP_INIT, COMP_ERR, + ("Unable to initialize /proc/net/%s/%s/mac-5\n", + rtlpriv->cfg->name, rtlpriv->dbg.proc_name)); + + entry = proc_create_data("mac-6", S_IFREG | S_IRUGO, + rtlpriv->dbg.proc_dir, &file_ops_mac_6, hw); + if (!entry) + RT_TRACE(COMP_INIT, COMP_ERR, + ("Unable to initialize /proc/net/%s/%s/mac-6\n", + rtlpriv->cfg->name, rtlpriv->dbg.proc_name)); + + entry = proc_create_data("mac-7", S_IFREG | S_IRUGO, + rtlpriv->dbg.proc_dir, &file_ops_mac_7, hw); + if (!entry) + RT_TRACE(COMP_INIT, COMP_ERR, + ("Unable to initialize /proc/net/%s/%s/mac-7\n", + rtlpriv->cfg->name, rtlpriv->dbg.proc_name)); + + entry = proc_create_data("bb-8", S_IFREG | S_IRUGO, + rtlpriv->dbg.proc_dir, &file_ops_bb_8, hw); + if (!entry) + RT_TRACE(COMP_INIT, COMP_ERR, + ("Unable to initialize /proc/net/%s/%s/bb-8\n", + rtlpriv->cfg->name, rtlpriv->dbg.proc_name)); + + entry = proc_create_data("bb-9", S_IFREG | S_IRUGO, + rtlpriv->dbg.proc_dir, &file_ops_bb_9, hw); + if (!entry) + RT_TRACE(COMP_INIT, COMP_ERR, + ("Unable to initialize /proc/net/%s/%s/bb-9\n", + rtlpriv->cfg->name, rtlpriv->dbg.proc_name)); + + entry = proc_create_data("bb-a", S_IFREG | S_IRUGO, + rtlpriv->dbg.proc_dir, &file_ops_bb_a, hw); + if (!entry) + RT_TRACE(COMP_INIT, COMP_ERR, + ("Unable to initialize /proc/net/%s/%s/bb-a\n", + rtlpriv->cfg->name, rtlpriv->dbg.proc_name)); + + entry = proc_create_data("bb-b", S_IFREG | S_IRUGO, + rtlpriv->dbg.proc_dir, &file_ops_bb_b, hw); + if (!entry) + RT_TRACE(COMP_INIT, COMP_ERR, + ("Unable to initialize /proc/net/%s/%s/bb-b\n", + rtlpriv->cfg->name, rtlpriv->dbg.proc_name)); + + entry = proc_create_data("bb-c", S_IFREG | S_IRUGO, + rtlpriv->dbg.proc_dir, &file_ops_bb_c, hw); + if (!entry) + RT_TRACE(COMP_INIT, COMP_ERR, + ("Unable to initialize /proc/net/%s/%s/bb-c\n", + rtlpriv->cfg->name, rtlpriv->dbg.proc_name)); + + entry = proc_create_data("bb-d", S_IFREG | S_IRUGO, + rtlpriv->dbg.proc_dir, &file_ops_bb_d, hw); + if (!entry) + RT_TRACE(COMP_INIT, COMP_ERR, + ("Unable to initialize /proc/net/%s/%s/bb-d\n", + rtlpriv->cfg->name, rtlpriv->dbg.proc_name)); + + entry = proc_create_data("bb-e", S_IFREG | S_IRUGO, + rtlpriv->dbg.proc_dir, &file_ops_bb_e, hw); + if (!entry) + RT_TRACE(COMP_INIT, COMP_ERR, + ("Unable to initialize /proc/net/%s/%s/bb-e\n", + rtlpriv->cfg->name, rtlpriv->dbg.proc_name)); + + entry = proc_create_data("bb-f", S_IFREG | S_IRUGO, + rtlpriv->dbg.proc_dir, &file_ops_bb_f, hw); + if (!entry) + RT_TRACE(COMP_INIT, COMP_ERR, + ("Unable to initialize /proc/net/%s/%s/bb-f\n", + rtlpriv->cfg->name, rtlpriv->dbg.proc_name)); + + entry = proc_create_data("rf-a", S_IFREG | S_IRUGO, + rtlpriv->dbg.proc_dir, &file_ops_rf_a, hw); + if (!entry) + RT_TRACE(COMP_INIT, COMP_ERR, + ("Unable to initialize /proc/net/%s/%s/rf-a\n", + rtlpriv->cfg->name, rtlpriv->dbg.proc_name)); + + entry = proc_create_data("rf-b", S_IFREG | S_IRUGO, + rtlpriv->dbg.proc_dir, &file_ops_rf_b, hw); + if (!entry) + RT_TRACE(COMP_INIT, COMP_ERR, + ("Unable to initialize /proc/net/%s/%s/rf-b\n", + rtlpriv->cfg->name, rtlpriv->dbg.proc_name)); + + entry = proc_create_data("cam-1", S_IFREG | S_IRUGO, + rtlpriv->dbg.proc_dir, &file_ops_cam_1, hw); + if (!entry) + RT_TRACE(COMP_INIT, COMP_ERR, + ("Unable to initialize /proc/net/%s/%s/cam-1\n", + rtlpriv->cfg->name, rtlpriv->dbg.proc_name)); + + entry = proc_create_data("cam-2", S_IFREG | S_IRUGO, + rtlpriv->dbg.proc_dir, &file_ops_cam_2, hw); + if (!entry) + RT_TRACE(COMP_INIT, COMP_ERR, + ("Unable to initialize /proc/net/%s/%s/cam-2\n", + rtlpriv->cfg->name, rtlpriv->dbg.proc_name)); + + entry = proc_create_data("cam-3", S_IFREG | S_IRUGO, + rtlpriv->dbg.proc_dir, &file_ops_cam_3, hw); + if (!entry) + RT_TRACE(COMP_INIT, COMP_ERR, + ("Unable to initialize /proc/net/%s/%s/cam-3\n", + rtlpriv->cfg->name, rtlpriv->dbg.proc_name)); +} + +void rtl_proc_remove_one(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + if (rtlpriv->dbg.proc_dir) { + remove_proc_entry("mac-0", rtlpriv->dbg.proc_dir); + remove_proc_entry("mac-1", rtlpriv->dbg.proc_dir); + remove_proc_entry("mac-2", rtlpriv->dbg.proc_dir); + remove_proc_entry("mac-3", rtlpriv->dbg.proc_dir); + remove_proc_entry("mac-4", rtlpriv->dbg.proc_dir); + remove_proc_entry("mac-5", rtlpriv->dbg.proc_dir); + remove_proc_entry("mac-6", rtlpriv->dbg.proc_dir); + remove_proc_entry("mac-7", rtlpriv->dbg.proc_dir); + remove_proc_entry("bb-8", rtlpriv->dbg.proc_dir); + remove_proc_entry("bb-9", rtlpriv->dbg.proc_dir); + remove_proc_entry("bb-a", rtlpriv->dbg.proc_dir); + remove_proc_entry("bb-b", rtlpriv->dbg.proc_dir); + remove_proc_entry("bb-c", rtlpriv->dbg.proc_dir); + remove_proc_entry("bb-d", rtlpriv->dbg.proc_dir); + remove_proc_entry("bb-e", rtlpriv->dbg.proc_dir); + remove_proc_entry("bb-f", rtlpriv->dbg.proc_dir); + remove_proc_entry("rf-a", rtlpriv->dbg.proc_dir); + remove_proc_entry("rf-b", rtlpriv->dbg.proc_dir); + remove_proc_entry("cam-1", rtlpriv->dbg.proc_dir); + remove_proc_entry("cam-2", rtlpriv->dbg.proc_dir); + remove_proc_entry("cam-3", rtlpriv->dbg.proc_dir); + + remove_proc_entry(rtlpriv->dbg.proc_name, proc_topdir); + + rtlpriv->dbg.proc_dir = NULL; + } +} + +void rtl_proc_add_topdir(void) +{ + proc_topdir = proc_mkdir("rtlwifi", init_net.proc_net); +} + +void rtl_proc_remove_topdir(void) +{ + if (proc_topdir) + remove_proc_entry("rtlwifi", init_net.proc_net); +} diff --git a/drivers/staging/rtl8192ee/debug.h b/drivers/staging/rtl8192ee/debug.h new file mode 100644 index 000000000000..093128d1f368 --- /dev/null +++ b/drivers/staging/rtl8192ee/debug.h @@ -0,0 +1,221 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * Tmis 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. + * + * Tmis 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. + * + * Tme full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#ifndef __RTL_DEBUG_H__ +#define __RTL_DEBUG_H__ + +/*-------------------------------------------------------------- + Debug level +--------------------------------------------------------------*/ +/* + *Fatal bug. + *For example, Tx/Rx/IO locked up, + *memory access violation, + *resource allocation failed, + *unexpected HW behavior, HW BUG + *and so on. + */ +#define DBG_EMERG 1 + +/* + *Abnormal, rare, or unexpeted cases. + *For example, Packet/IO Ctl canceled, + *device suprisely unremoved and so on. + */ +#define DBG_WARNING 2 + +/* + *Normal case driver developer should + *open, we can see link status like + *assoc/AddBA/DHCP/adapter start and + *so on basic and useful infromations. + */ +#define DBG_DMESG 3 + +/* + *Normal case with useful information + *about current SW or HW state. + *For example, Tx/Rx descriptor to fill, + *Tx/Rx descriptor completed status, + *SW protocol state change, dynamic + *mechanism state change and so on. + */ +#define DBG_LOUD 4 + +/* + *Normal case with detail execution + *flow or information. + */ +#define DBG_TRACE 5 + +/*-------------------------------------------------------------- + Define the rt_trace components +--------------------------------------------------------------*/ +#define COMP_ERR BIT(0) +#define COMP_FW BIT(1) +#define COMP_INIT BIT(2) /*For init/deinit */ +#define COMP_RECV BIT(3) /*For Rx. */ +#define COMP_SEND BIT(4) /*For Tx. */ +#define COMP_MLME BIT(5) /*For MLME. */ +#define COMP_SCAN BIT(6) /*For Scan. */ +#define COMP_INTR BIT(7) /*For interrupt Related. */ +#define COMP_LED BIT(8) /*For LED. */ +#define COMP_SEC BIT(9) /*For sec. */ +#define COMP_BEACON BIT(10) /*For beacon. */ +#define COMP_RATE BIT(11) /*For rate. */ +#define COMP_RXDESC BIT(12) /*For rx desc. */ +#define COMP_DIG BIT(13) /*For DIG */ +#define COMP_TXAGC BIT(14) /*For Tx power */ +#define COMP_HIPWR BIT(15) /*For High Power Mechanism */ +#define COMP_POWER BIT(16) /*For lps/ips/aspm. */ +#define COMP_POWER_TRACKING BIT(17) /*For TX POWER TRACKING */ +#define COMP_BB_POWERSAVING BIT(18) +#define COMP_SWAS BIT(19) /*For SW Antenna Switch */ +#define COMP_RF BIT(20) /*For RF. */ +#define COMP_TURBO BIT(21) /*For EDCA TURBO. */ +#define COMP_RATR BIT(22) +#define COMP_CMD BIT(23) +#define COMP_EFUSE BIT(24) +#define COMP_QOS BIT(25) +#define COMP_MAC80211 BIT(26) +#define COMP_REGD BIT(27) +#define COMP_CHAN BIT(28) +#define COMP_EASY_CONCURRENT BIT(29) +#define COMP_BT_COEXIST BIT(30) +#define COMP_IQK BIT(31) + +/*-------------------------------------------------------------- + Define the rt_print components +--------------------------------------------------------------*/ +/* Define EEPROM and EFUSE check module bit*/ +#define EEPROM_W BIT(0) +#define EFUSE_PG BIT(1) +#define EFUSE_READ_ALL BIT(2) + +/* Define init check for module bit*/ +#define INIT_EEPROM BIT(0) +#define INIT_TxPower BIT(1) +#define INIT_IQK BIT(2) +#define INIT_RF BIT(3) + +/* Define PHY-BB/RF/MAC check module bit */ +#define PHY_BBR BIT(0) +#define PHY_BBW BIT(1) +#define PHY_RFR BIT(2) +#define PHY_RFW BIT(3) +#define PHY_MACR BIT(4) +#define PHY_MACW BIT(5) +#define PHY_ALLR BIT(6) +#define PHY_ALLW BIT(7) +#define PHY_TXPWR BIT(8) +#define PHY_PWRDIFF BIT(9) + +/* Define Dynamic Mechanism check module bit --> FDM */ +#define WA_IOT BIT(0) +#define DM_PWDB BIT(1) +#define DM_MONITOR BIT(2) +#define DM_DIG BIT(3) +#define DM_EDCA_TURBO BIT(4) + +enum dbgp_flag_e { + FQOS = 0, + FTX = 1, + FRX = 2, + FSEC = 3, + FMGNT = 4, + FMLME = 5, + FRESOURCE = 6, + FBEACON = 7, + FISR = 8, + FPHY = 9, + FMP = 10, + FEEPROM = 11, + FPWR = 12, + FDM = 13, + FDBGCtrl = 14, + FC2H = 15, + FBT = 16, + FINIT = 17, + FIOCTL = 18, + DBGP_TYPE_MAX +}; + +#define RT_ASSERT(_exp , fmt) \ + do { \ + if (!(_exp)) { \ + pr_debug("%s:%s(): ", KBUILD_MODNAME, \ + __func__); \ + pr_cont fmt; \ + } \ + } while (0) + +#define RT_TRACE(comp, level, fmt)\ + do { \ + if (unlikely(((comp) & rtlpriv->dbg.global_debugcomponents) && \ + ((level) <= rtlpriv->dbg.global_debuglevel))) {\ + pr_debug("%s-%d:%s():<%lx> ", \ + KBUILD_MODNAME, \ + rtlpriv->rtlhal.interfaceindex, __func__, \ + in_interrupt()); \ + pr_cont fmt; \ + } \ + } while (0) + +#define RTPRINT(rtlpriv, dbgtype, dbgflag, fmt, ...) \ +do { \ + if (unlikely(rtlpriv->dbg.dbgp_type[dbgtype] & dbgflag)) { \ + pr_debug(KBUILD_MODNAME ": " fmt, \ + ##__VA_ARGS__); \ + } \ +} while (0) + +#define RT_PRINT_DATA(rtlpriv, _comp, _level, _titlestring, _hexdata, \ + _hexdatalen) \ + do {\ + if (unlikely(((_comp) & rtlpriv->dbg.global_debugcomponents) &&\ + (_level <= rtlpriv->dbg.global_debuglevel))) { \ + int __i; \ + u8 *ptr = (u8 *)_hexdata; \ + pr_debug("%s: ", KBUILD_MODNAME); \ + pr_cont("In process \"%s\" (pid %i):", \ + current->comm, \ + current->pid); \ + pr_cont(_titlestring); \ + for (__i = 0; __i < (int)_hexdatalen; __i++) { \ + pr_cont("%02X%s", ptr[__i], (((__i + 1) % 4) \ + == 0) ? " " : " ");\ + if (((__i + 1) % 16) == 0) \ + pr_cont("\n"); \ + } \ + pr_cont("\n"); \ + } \ + } while (0) + +void rtl92e_dbgp_flag_init(struct ieee80211_hw *hw); +void rtl_proc_add_one(struct ieee80211_hw *hw); +void rtl_proc_remove_one(struct ieee80211_hw *hw); +void rtl_proc_add_topdir(void); +void rtl_proc_remove_topdir(void); +#endif diff --git a/drivers/staging/rtl8192ee/efuse.c b/drivers/staging/rtl8192ee/efuse.c new file mode 100644 index 000000000000..3fae18369831 --- /dev/null +++ b/drivers/staging/rtl8192ee/efuse.c @@ -0,0 +1,1233 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * Tmis 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ +#include "wifi.h" +#include "efuse.h" + +static const u8 MAX_PGPKT_SIZE = 9; +static const u8 PGPKT_DATA_SIZE = 8; +static const int EFUSE_MAX_SIZE = 512; + +static const struct efuse_map RTL8712_SDIO_EFUSE_TABLE[] = { + {0, 0, 0, 2}, + {0, 1, 0, 2}, + {0, 2, 0, 2}, + {1, 0, 0, 1}, + {1, 0, 1, 1}, + {1, 1, 0, 1}, + {1, 1, 1, 3}, + {1, 3, 0, 17}, + {3, 3, 1, 48}, + {10, 0, 0, 6}, + {10, 3, 0, 1}, + {10, 3, 1, 1}, + {11, 0, 0, 28} +}; + +static void efuse92e_shadow_read_1byte(struct ieee80211_hw *hw, u16 offset, + u8 *value); +static void efuse92e_shadow_read_2byte(struct ieee80211_hw *hw, u16 offset, + u16 *value); +static void efuse92e_shadow_read_4byte(struct ieee80211_hw *hw, u16 offset, + u32 *value); +static void efuse92e_shadow_write_1byte(struct ieee80211_hw *hw, u16 offset, + u8 value); +static void efuse92e_shadow_write_2byte(struct ieee80211_hw *hw, u16 offset, + u16 value); +static void efuse92e_shadow_write_4byte(struct ieee80211_hw *hw, u16 offset, + u32 value); +static int efuse_one_byte_write(struct ieee80211_hw *hw, u16 addr, + u8 data); +static void efuse_read_all_map(struct ieee80211_hw *hw, u8 *efuse); +static int efuse_pg_packet_read(struct ieee80211_hw *hw, u8 offset, + u8 *data); +static int efuse_pg_packet_write(struct ieee80211_hw *hw, u8 offset, + u8 word_en, u8 *data); +static void efuse_word_enable_data_read(u8 word_en, u8 *sourdata, + u8 *targetdata); +static u8 efuse_word_enable_data_write(struct ieee80211_hw *hw, + u16 efuse_addr, u8 word_en, u8 *data); +static void efuse_power_switch(struct ieee80211_hw *hw, u8 bwrite, + u8 pwrstate); +static u16 efuse_get_current_size(struct ieee80211_hw *hw); +static u8 efuse_calculate_word_cnts(u8 word_en); + +void efuse92e_initialize(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u8 bytetemp; + u8 temp; + + bytetemp = rtl_read_byte(rtlpriv, rtlpriv->cfg->maps[SYS_FUNC_EN] + 1); + temp = bytetemp | 0x20; + rtl_write_byte(rtlpriv, rtlpriv->cfg->maps[SYS_FUNC_EN] + 1, temp); + + bytetemp = rtl_read_byte(rtlpriv, rtlpriv->cfg->maps[SYS_ISO_CTRL] + 1); + temp = bytetemp & 0xFE; + rtl_write_byte(rtlpriv, rtlpriv->cfg->maps[SYS_ISO_CTRL] + 1, temp); + + bytetemp = rtl_read_byte(rtlpriv, rtlpriv->cfg->maps[EFUSE_TEST] + 3); + temp = bytetemp | 0x80; + rtl_write_byte(rtlpriv, rtlpriv->cfg->maps[EFUSE_TEST] + 3, temp); + + rtl_write_byte(rtlpriv, 0x2F8, 0x3); + + rtl_write_byte(rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL] + 3, 0x72); +} + +u8 stg_efuse_read_1byte(struct ieee80211_hw *hw, u16 address) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u8 data; + u8 bytetemp; + u8 temp; + u32 k = 0; + const u32 efuse_real_content_len = + rtlpriv->cfg->maps[EFUSE_REAL_CONTENT_SIZE]; + + if (address < efuse_real_content_len) { + temp = address & 0xFF; + rtl_write_byte(rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL] + 1, + temp); + bytetemp = rtl_read_byte(rtlpriv, + rtlpriv->cfg->maps[EFUSE_CTRL] + 2); + temp = ((address >> 8) & 0x03) | (bytetemp & 0xFC); + rtl_write_byte(rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL] + 2, + temp); + + bytetemp = rtl_read_byte(rtlpriv, + rtlpriv->cfg->maps[EFUSE_CTRL] + 3); + temp = bytetemp & 0x7F; + rtl_write_byte(rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL] + 3, + temp); + + bytetemp = rtl_read_byte(rtlpriv, + rtlpriv->cfg->maps[EFUSE_CTRL] + 3); + while (!(bytetemp & 0x80)) { + bytetemp = rtl_read_byte(rtlpriv, + rtlpriv->cfg-> + maps[EFUSE_CTRL] + 3); + k++; + if (k == 1000) { + k = 0; + break; + } + } + data = rtl_read_byte(rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL]); + return data; + } else { + return 0xFF; + } +} +EXPORT_SYMBOL(stg_efuse_read_1byte); + +void efuse92e_write_1byte(struct ieee80211_hw *hw, u16 address, u8 value) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u8 bytetemp; + u8 temp; + u32 k = 0; + const u32 efuse_real_content_len = + rtlpriv->cfg->maps[EFUSE_REAL_CONTENT_SIZE]; + + RT_TRACE(COMP_EFUSE, DBG_LOUD, + ("Addr=%x Data =%x\n", address, value)); + + if (address < efuse_real_content_len) { + rtl_write_byte(rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL], value); + + temp = address & 0xFF; + rtl_write_byte(rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL] + 1, + temp); + bytetemp = rtl_read_byte(rtlpriv, + rtlpriv->cfg->maps[EFUSE_CTRL] + 2); + + temp = ((address >> 8) & 0x03) | (bytetemp & 0xFC); + rtl_write_byte(rtlpriv, + rtlpriv->cfg->maps[EFUSE_CTRL] + 2, temp); + + bytetemp = rtl_read_byte(rtlpriv, + rtlpriv->cfg->maps[EFUSE_CTRL] + 3); + temp = bytetemp | 0x80; + rtl_write_byte(rtlpriv, + rtlpriv->cfg->maps[EFUSE_CTRL] + 3, temp); + + bytetemp = rtl_read_byte(rtlpriv, + rtlpriv->cfg->maps[EFUSE_CTRL] + 3); + + while (bytetemp & 0x80) { + bytetemp = rtl_read_byte(rtlpriv, + rtlpriv->cfg-> + maps[EFUSE_CTRL] + 3); + k++; + if (k == 100) { + k = 0; + break; + } + } + } +} + +void read92e_efuse_byte(struct ieee80211_hw *hw, u16 _offset, u8 *pbuf) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u32 value32; + u8 readbyte; + u16 retry; + + rtl_write_byte(rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL] + 1, + (_offset & 0xff)); + readbyte = rtl_read_byte(rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL] + 2); + rtl_write_byte(rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL] + 2, + ((_offset >> 8) & 0x03) | (readbyte & 0xfc)); + + readbyte = rtl_read_byte(rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL] + 3); + rtl_write_byte(rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL] + 3, + (readbyte & 0x7f)); + + retry = 0; + value32 = rtl_read_dword(rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL]); + while (!(((value32 >> 24) & 0xff) & 0x80) && (retry < 10000)) { + value32 = rtl_read_dword(rtlpriv, + rtlpriv->cfg->maps[EFUSE_CTRL]); + retry++; + } + + udelay(50); + value32 = rtl_read_dword(rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL]); + + *pbuf = (u8) (value32 & 0xff); +} + +void read92e_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, + u8 *pbuf) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); + u8 *efuse_tbl; + u8 rtemp8[1]; + u16 efuse_addr = 0; + u8 offset, wren; + u8 u1temp = 0; + u16 i; + u16 j; + const u16 efuse_max_section = + rtlpriv->cfg->maps[EFUSE_MAX_SECTION_MAP]; + const u32 efuse_real_content_len = + rtlpriv->cfg->maps[EFUSE_REAL_CONTENT_SIZE]; + u16 **efuse_word; + u16 efuse_utilized = 0; + u8 efuse_usage; + + if ((_offset + _size_byte) > rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE]) { + RT_TRACE(COMP_EFUSE, DBG_LOUD, + ("read92e_efuse(): Invalid offset(%#x) with read bytes(%#x)!!\n", + _offset, _size_byte)); + return; + } + + /* allocate memory for efuse_tbl and efuse_word */ + efuse_tbl = kmalloc(rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE] * + sizeof(u8), GFP_ATOMIC); + if (!efuse_tbl) + return; + efuse_word = kzalloc(EFUSE_MAX_WORD_UNIT * sizeof(u16 *), GFP_ATOMIC); + if (!efuse_word) + goto out; + for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) { + efuse_word[i] = kmalloc(efuse_max_section * sizeof(u16), + GFP_ATOMIC); + if (!efuse_word[i]) + goto done; + } + + for (i = 0; i < efuse_max_section; i++) + for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++) + efuse_word[j][j] = 0xFFFF; + + read92e_efuse_byte(hw, efuse_addr, rtemp8); + if (*rtemp8 != 0xFF) { + efuse_utilized++; + RTPRINT(rtlpriv, FEEPROM, EFUSE_READ_ALL, + "Addr=%d\n", efuse_addr); + efuse_addr++; + } + + while ((*rtemp8 != 0xFF) && (efuse_addr < efuse_real_content_len)) { + /* Check PG header for section num. */ + if ((*rtemp8 & 0x1F) == 0x0F) {/* extended header */ + u1temp = ((*rtemp8 & 0xE0) >> 5); + read92e_efuse_byte(hw, efuse_addr, rtemp8); + + if ((*rtemp8 & 0x0F) == 0x0F) { + efuse_addr++; + read92e_efuse_byte(hw, efuse_addr, rtemp8); + + if (*rtemp8 != 0xFF && + (efuse_addr < efuse_real_content_len)) { + efuse_addr++; + } + continue; + } else { + offset = ((*rtemp8 & 0xF0) >> 1) | u1temp; + wren = (*rtemp8 & 0x0F); + efuse_addr++; + } + } else { + offset = ((*rtemp8 >> 4) & 0x0f); + wren = (*rtemp8 & 0x0f); + } + + if (offset < efuse_max_section) { + RTPRINT(rtlpriv, FEEPROM, EFUSE_READ_ALL, + "offset-%d Worden=%x\n", offset, wren); + + for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) { + if (!(wren & 0x01)) { + RTPRINT(rtlpriv, FEEPROM, + EFUSE_READ_ALL, "Addr=%d\n", + efuse_addr); + + read92e_efuse_byte(hw, efuse_addr, + rtemp8); + efuse_addr++; + efuse_utilized++; + efuse_word[i][offset] = (*rtemp8 & + 0xff); + + if (efuse_addr >= + efuse_real_content_len) + break; + + RTPRINT(rtlpriv, FEEPROM, + EFUSE_READ_ALL, "Addr=%d\n", + efuse_addr); + + read92e_efuse_byte(hw, efuse_addr, + rtemp8); + efuse_addr++; + efuse_utilized++; + efuse_word[i][offset] |= + (((u16) *rtemp8 << 8) & 0xff00); + + if (efuse_addr >= + efuse_real_content_len) + break; + } + + wren >>= 1; + } + } + + RTPRINT(rtlpriv, FEEPROM, EFUSE_READ_ALL, + "Addr=%d\n", efuse_addr); + read92e_efuse_byte(hw, efuse_addr, rtemp8); + if (*rtemp8 != 0xFF && (efuse_addr < efuse_real_content_len)) { + efuse_utilized++; + efuse_addr++; + } + } + + for (i = 0; i < efuse_max_section; i++) { + for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++) { + efuse_tbl[(i * 8) + (j * 2)] = + (efuse_word[j][i] & 0xff); + efuse_tbl[(i * 8) + ((j * 2) + 1)] = + ((efuse_word[j][i] >> 8) & 0xff); + } + } + + for (i = 0; i < _size_byte; i++) + pbuf[i] = efuse_tbl[_offset + i]; + + rtlefuse->efuse_usedbytes = efuse_utilized; + efuse_usage = (u8) ((efuse_utilized * 100) / efuse_real_content_len); + rtlefuse->efuse_usedpercentage = efuse_usage; + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_EFUSE_BYTES, + (u8 *)&efuse_utilized); + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_EFUSE_USAGE, + (u8 *)&efuse_usage); +done: + for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) + kfree(efuse_word[i]); + kfree(efuse_word); +out: + kfree(efuse_tbl); +} + +bool efuse92e_shadow_update_chk(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); + u8 section_idx, i, Base; + u16 words_need = 0, hdr_num = 0, totalbytes, efuse_used; + bool bwordchanged, bresult = true; + + for (section_idx = 0; section_idx < 16; section_idx++) { + Base = section_idx * 8; + bwordchanged = false; + + for (i = 0; i < 8; i = i + 2) { + if ((rtlefuse->efuse_map[EFUSE_INIT_MAP][Base + i] != + rtlefuse->efuse_map[EFUSE_MODIFY_MAP][Base + i]) || + (rtlefuse->efuse_map[EFUSE_INIT_MAP][Base + i + 1] != + rtlefuse->efuse_map[EFUSE_MODIFY_MAP][Base + i + + 1])) { + words_need++; + bwordchanged = true; + } + } + + if (bwordchanged) + hdr_num++; + } + + totalbytes = hdr_num + words_need * 2; + efuse_used = rtlefuse->efuse_usedbytes; + + if ((totalbytes + efuse_used) >= + (EFUSE_MAX_SIZE - rtlpriv->cfg->maps[EFUSE_OOB_PROTECT_BYTES_LEN])) + bresult = false; + + RT_TRACE(COMP_EFUSE, DBG_LOUD, + ("efuse92e_shadow_update_chk(): totalbytes(%#x), hdr_num(%#x), words_need(%#x), efuse_used(%d)\n", + totalbytes, hdr_num, words_need, efuse_used)); + + return bresult; +} + +void efuse92e_shadow_read(struct ieee80211_hw *hw, u8 type, + u16 offset, u32 *value) +{ + if (type == 1) + efuse92e_shadow_read_1byte(hw, offset, (u8 *)value); + else if (type == 2) + efuse92e_shadow_read_2byte(hw, offset, (u16 *)value); + else if (type == 4) + efuse92e_shadow_read_4byte(hw, offset, (u32 *)value); +} +EXPORT_SYMBOL(efuse92e_shadow_read); + +void efuse92e_shadow_write(struct ieee80211_hw *hw, u8 type, u16 offset, + u32 value) +{ + if (type == 1) + efuse92e_shadow_write_1byte(hw, offset, (u8)value); + else if (type == 2) + efuse92e_shadow_write_2byte(hw, offset, (u16)value); + else if (type == 4) + efuse92e_shadow_write_4byte(hw, offset, (u32)value); +} + +bool efuse92e_shadow_update(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); + u16 i, offset, base; + u8 word_en = 0x0F; + u8 first_pg = false; + + RT_TRACE(COMP_EFUSE, DBG_LOUD, ("\n")); + + if (!efuse92e_shadow_update_chk(hw)) { + efuse_read_all_map(hw, &rtlefuse->efuse_map[EFUSE_INIT_MAP][0]); + memcpy(&rtlefuse->efuse_map[EFUSE_MODIFY_MAP][0], + &rtlefuse->efuse_map[EFUSE_INIT_MAP][0], + rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE]); + + RT_TRACE(COMP_EFUSE, DBG_LOUD, + ("efuse out of capacity!!\n")); + return false; + } + efuse_power_switch(hw, true, true); + + for (offset = 0; offset < 16; offset++) { + word_en = 0x0F; + base = offset * 8; + + for (i = 0; i < 8; i++) { + if (first_pg) { + word_en &= ~(BIT(i / 2)); + + rtlefuse->efuse_map[EFUSE_INIT_MAP][base + i] = + rtlefuse->efuse_map[EFUSE_MODIFY_MAP][base + i]; + } else { + if (rtlefuse->efuse_map[EFUSE_INIT_MAP][base + i] != + rtlefuse->efuse_map[EFUSE_MODIFY_MAP][base + i]) { + word_en &= ~(BIT(i / 2)); + + rtlefuse->efuse_map[EFUSE_INIT_MAP][base + i] = + rtlefuse->efuse_map[EFUSE_MODIFY_MAP][base + i]; + } + } + } + + if (word_en != 0x0F) { + u8 tmpdata[8]; + memcpy(tmpdata, + (&rtlefuse->efuse_map[EFUSE_MODIFY_MAP][base]), + 8); + RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_LOUD, + "U-efuse\n", tmpdata, 8); + + if (!efuse_pg_packet_write(hw, (u8) offset, word_en, + tmpdata)) { + RT_TRACE(COMP_ERR, DBG_WARNING, + ("PG section(%#x) fail!!\n", offset)); + break; + } + } + } + + efuse_power_switch(hw, true, false); + efuse_read_all_map(hw, &rtlefuse->efuse_map[EFUSE_INIT_MAP][0]); + + memcpy(&rtlefuse->efuse_map[EFUSE_MODIFY_MAP][0], + &rtlefuse->efuse_map[EFUSE_INIT_MAP][0], + rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE]); + + RT_TRACE(COMP_EFUSE, DBG_LOUD, ("\n")); + return true; +} + +void stg_rtl_efuse92e_shadow_map_update(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); + + if (rtlefuse->autoload_failflag) { + memset(&rtlefuse->efuse_map[EFUSE_INIT_MAP][0], + 0xFF, rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE]); + } else { + efuse_read_all_map(hw, &rtlefuse->efuse_map[EFUSE_INIT_MAP][0]); + } + + memcpy(&rtlefuse->efuse_map[EFUSE_MODIFY_MAP][0], + &rtlefuse->efuse_map[EFUSE_INIT_MAP][0], + rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE]); +} +EXPORT_SYMBOL(stg_rtl_efuse92e_shadow_map_update); + +void efuse92e_force_write_vendor_Id(struct ieee80211_hw *hw) +{ + u8 tmpdata[8] = { 0xFF, 0xFF, 0xEC, 0x10, 0xFF, 0xFF, 0xFF, 0xFF }; + + efuse_power_switch(hw, true, true); + efuse_pg_packet_write(hw, 1, 0xD, tmpdata); + efuse_power_switch(hw, true, false); +} + +void efuse92e_re_pg_section(struct ieee80211_hw *hw, u8 section_idx) +{ +} + +static void efuse92e_shadow_read_1byte(struct ieee80211_hw *hw, + u16 offset, u8 *value) +{ + struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); + *value = rtlefuse->efuse_map[EFUSE_MODIFY_MAP][offset]; +} + +static void efuse92e_shadow_read_2byte(struct ieee80211_hw *hw, + u16 offset, u16 *value) +{ + struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); + + *value = rtlefuse->efuse_map[EFUSE_MODIFY_MAP][offset]; + *value |= rtlefuse->efuse_map[EFUSE_MODIFY_MAP][offset + 1] << 8; +} + +static void efuse92e_shadow_read_4byte(struct ieee80211_hw *hw, + u16 offset, u32 *value) +{ + struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); + + *value = rtlefuse->efuse_map[EFUSE_MODIFY_MAP][offset]; + *value |= rtlefuse->efuse_map[EFUSE_MODIFY_MAP][offset + 1] << 8; + *value |= rtlefuse->efuse_map[EFUSE_MODIFY_MAP][offset + 2] << 16; + *value |= rtlefuse->efuse_map[EFUSE_MODIFY_MAP][offset + 3] << 24; +} + +static void efuse92e_shadow_write_1byte(struct ieee80211_hw *hw, + u16 offset, u8 value) +{ + struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); + + rtlefuse->efuse_map[EFUSE_MODIFY_MAP][offset] = value; +} + +static void efuse92e_shadow_write_2byte(struct ieee80211_hw *hw, + u16 offset, u16 value) +{ + struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); + + rtlefuse->efuse_map[EFUSE_MODIFY_MAP][offset] = value & 0x00FF; + rtlefuse->efuse_map[EFUSE_MODIFY_MAP][offset + 1] = value >> 8; +} + +static void efuse92e_shadow_write_4byte(struct ieee80211_hw *hw, + u16 offset, u32 value) +{ + struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); + + rtlefuse->efuse_map[EFUSE_MODIFY_MAP][offset] = + (u8) (value & 0x000000FF); + rtlefuse->efuse_map[EFUSE_MODIFY_MAP][offset + 1] = + (u8) ((value >> 8) & 0x0000FF); + rtlefuse->efuse_map[EFUSE_MODIFY_MAP][offset + 2] = + (u8) ((value >> 16) & 0x00FF); + rtlefuse->efuse_map[EFUSE_MODIFY_MAP][offset + 3] = + (u8) ((value >> 24) & 0xFF); +} + +int stg_efuse_one_byte_read(struct ieee80211_hw *hw, u16 addr, u8 *data) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u8 tmpidx = 0; + int bresult; + + rtl_write_byte(rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL] + 1, + (u8) (addr & 0xff)); + rtl_write_byte(rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL] + 2, + ((u8) ((addr >> 8) & 0x03)) | + (rtl_read_byte(rtlpriv, + rtlpriv->cfg->maps[EFUSE_CTRL] + 2) & + 0xFC)); + + rtl_write_byte(rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL] + 3, 0x72); + + while (!(0x80 & rtl_read_byte(rtlpriv, + rtlpriv->cfg->maps[EFUSE_CTRL] + 3)) && + (tmpidx < 100)) { + tmpidx++; + } + + if (tmpidx < 100) { + *data = rtl_read_byte(rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL]); + bresult = true; + } else { + *data = 0xff; + bresult = false; + } + return bresult; +} +EXPORT_SYMBOL(stg_efuse_one_byte_read); + +static int efuse_one_byte_write(struct ieee80211_hw *hw, u16 addr, u8 data) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u8 tmpidx = 0; + bool bresult; + + RT_TRACE(COMP_EFUSE, DBG_LOUD, + ("Addr = %x Data=%x\n", addr, data)); + + rtl_write_byte(rtlpriv, + rtlpriv->cfg->maps[EFUSE_CTRL] + 1, (u8) (addr & 0xff)); + rtl_write_byte(rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL] + 2, + (rtl_read_byte(rtlpriv, + rtlpriv->cfg->maps[EFUSE_CTRL] + + 2) & 0xFC) | (u8) ((addr >> 8) & 0x03)); + + rtl_write_byte(rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL], data); + rtl_write_byte(rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL] + 3, 0xF2); + + while ((0x80 & rtl_read_byte(rtlpriv, + rtlpriv->cfg->maps[EFUSE_CTRL] + 3)) && + (tmpidx < 100)) { + tmpidx++; + } + + if (tmpidx < 100) + bresult = true; + else + bresult = false; + + return bresult; +} + +static void efuse_read_all_map(struct ieee80211_hw *hw, u8 *efuse) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + efuse_power_switch(hw, false, true); + read92e_efuse(hw, 0, rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE], efuse); + efuse_power_switch(hw, false, false); +} + +static void efuse_read_data_case1(struct ieee80211_hw *hw, u16 *efuse_addr, + u8 efuse_data, u8 offset, u8 *tmpdata, + u8 *readstate) +{ + bool bdataempty = true; + u8 hoffset; + u8 tmpidx; + u8 hworden; + u8 word_cnts; + + hoffset = (efuse_data >> 4) & 0x0F; + hworden = efuse_data & 0x0F; + word_cnts = efuse_calculate_word_cnts(hworden); + + if (hoffset == offset) { + for (tmpidx = 0; tmpidx < word_cnts * 2; tmpidx++) { + if (stg_efuse_one_byte_read(hw, *efuse_addr + 1 + tmpidx, + &efuse_data)) { + tmpdata[tmpidx] = efuse_data; + if (efuse_data != 0xff) + bdataempty = false; + } + } + + if (!bdataempty) { + *readstate = PG_STATE_DATA; + } else { + *efuse_addr = *efuse_addr + (word_cnts * 2) + 1; + *readstate = PG_STATE_HEADER; + } + + } else { + *efuse_addr = *efuse_addr + (word_cnts * 2) + 1; + *readstate = PG_STATE_HEADER; + } +} + +static int efuse_pg_packet_read(struct ieee80211_hw *hw, u8 offset, u8 *data) +{ + u8 readstate = PG_STATE_HEADER; + + bool bcontinual = true; + + u8 efuse_data, word_cnts = 0; + u16 efuse_addr = 0; + u8 hworden = 0; + u8 tmpdata[8]; + + if (data == NULL) + return false; + if (offset > 15) + return false; + + memset(data, 0xff, PGPKT_DATA_SIZE * sizeof(u8)); + memset(tmpdata, 0xff, PGPKT_DATA_SIZE * sizeof(u8)); + + while (bcontinual && (efuse_addr < EFUSE_MAX_SIZE)) { + if (readstate & PG_STATE_HEADER) { + if (stg_efuse_one_byte_read(hw, efuse_addr, &efuse_data) && + (efuse_data != 0xFF)) + efuse_read_data_case1(hw, &efuse_addr, + efuse_data, offset, + tmpdata, &readstate); + else + bcontinual = false; + } else if (readstate & PG_STATE_DATA) { + efuse_word_enable_data_read(hworden, tmpdata, data); + efuse_addr = efuse_addr + (word_cnts * 2) + 1; + readstate = PG_STATE_HEADER; + } + } + + if ((data[0] == 0xff) && (data[1] == 0xff) && + (data[2] == 0xff) && (data[3] == 0xff) && + (data[4] == 0xff) && (data[5] == 0xff) && + (data[6] == 0xff) && (data[7] == 0xff)) + return false; + else + return true; +} + +static void efuse_write_data_case1(struct ieee80211_hw *hw, u16 *efuse_addr, + u8 efuse_data, u8 offset, + int *bcontinual, u8 *write_state, + struct pgpkt_struct *target_pkt, + int *repeat_times, int *bresult, u8 word_en) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct pgpkt_struct tmp_pkt; + int bdataempty = true; + u8 originaldata[8 * sizeof(u8)]; + u8 badworden = 0x0F; + u8 match_word_en, tmp_word_en; + u8 tmpindex; + u8 tmp_header = efuse_data; + u8 tmp_word_cnts; + + tmp_pkt.offset = (tmp_header >> 4) & 0x0F; + tmp_pkt.word_en = tmp_header & 0x0F; + tmp_word_cnts = efuse_calculate_word_cnts(tmp_pkt.word_en); + + if (tmp_pkt.offset != target_pkt->offset) { + *efuse_addr = *efuse_addr + (tmp_word_cnts * 2) + 1; + *write_state = PG_STATE_HEADER; + } else { + for (tmpindex = 0; tmpindex < (tmp_word_cnts * 2); tmpindex++) { + if (stg_efuse_one_byte_read(hw, + (*efuse_addr + 1 + tmpindex), + &efuse_data) && + (efuse_data != 0xFF)) + bdataempty = false; + } + + if (!bdataempty) { + *efuse_addr = *efuse_addr + (tmp_word_cnts * 2) + 1; + *write_state = PG_STATE_HEADER; + } else { + match_word_en = 0x0F; + if (!((target_pkt->word_en & BIT(0)) | + (tmp_pkt.word_en & BIT(0)))) + match_word_en &= (~BIT(0)); + + if (!((target_pkt->word_en & BIT(1)) | + (tmp_pkt.word_en & BIT(1)))) + match_word_en &= (~BIT(1)); + + if (!((target_pkt->word_en & BIT(2)) | + (tmp_pkt.word_en & BIT(2)))) + match_word_en &= (~BIT(2)); + + if (!((target_pkt->word_en & BIT(3)) | + (tmp_pkt.word_en & BIT(3)))) + match_word_en &= (~BIT(3)); + + if ((match_word_en & 0x0F) != 0x0F) { + badworden = efuse_word_enable_data_write(hw, + *efuse_addr + 1, + tmp_pkt.word_en, + target_pkt->data); + + if (0x0F != (badworden & 0x0F)) { + u8 reorg_offset = offset; + u8 reorg_worden = badworden; + efuse_pg_packet_write(hw, reorg_offset, + reorg_worden, + originaldata); + } + + tmp_word_en = 0x0F; + if ((target_pkt->word_en & BIT(0)) ^ + (match_word_en & BIT(0))) + tmp_word_en &= (~BIT(0)); + + if ((target_pkt->word_en & BIT(1)) ^ + (match_word_en & BIT(1))) + tmp_word_en &= (~BIT(1)); + + if ((target_pkt->word_en & BIT(2)) ^ + (match_word_en & BIT(2))) + tmp_word_en &= (~BIT(2)); + + if ((target_pkt->word_en & BIT(3)) ^ + (match_word_en & BIT(3))) + tmp_word_en &= (~BIT(3)); + + if ((tmp_word_en & 0x0F) != 0x0F) { + *efuse_addr = efuse_get_current_size(hw); + target_pkt->offset = offset; + target_pkt->word_en = tmp_word_en; + } else { + *bcontinual = false; + } + *write_state = PG_STATE_HEADER; + *repeat_times += 1; + if (*repeat_times > EFUSE_REPEAT_THRESHOLD_) { + *bcontinual = false; + *bresult = false; + } + } else { + *efuse_addr += (2 * tmp_word_cnts) + 1; + target_pkt->offset = offset; + target_pkt->word_en = word_en; + *write_state = PG_STATE_HEADER; + } + } + } + RTPRINT(rtlpriv, FEEPROM, EFUSE_PG, "efuse PG_STATE_HEADER-1\n"); +} + +static void efuse_write_data_case2(struct ieee80211_hw *hw, u16 *efuse_addr, + int *bcontinual, u8 *write_state, + struct pgpkt_struct target_pkt, + int *repeat_times, int *bresult) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct pgpkt_struct tmp_pkt; + u8 pg_header; + u8 tmp_header; + u8 originaldata[8 * sizeof(u8)]; + u8 tmp_word_cnts; + u8 badworden = 0x0F; + + pg_header = ((target_pkt.offset << 4) & 0xf0) | target_pkt.word_en; + efuse_one_byte_write(hw, *efuse_addr, pg_header); + stg_efuse_one_byte_read(hw, *efuse_addr, &tmp_header); + + if (tmp_header == pg_header) { + *write_state = PG_STATE_DATA; + } else if (tmp_header == 0xFF) { + *write_state = PG_STATE_HEADER; + *repeat_times += 1; + if (*repeat_times > EFUSE_REPEAT_THRESHOLD_) { + *bcontinual = false; + *bresult = false; + } + } else { + tmp_pkt.offset = (tmp_header >> 4) & 0x0F; + tmp_pkt.word_en = tmp_header & 0x0F; + + tmp_word_cnts = efuse_calculate_word_cnts(tmp_pkt.word_en); + + memset(originaldata, 0xff, 8 * sizeof(u8)); + + if (efuse_pg_packet_read(hw, tmp_pkt.offset, originaldata)) { + badworden = efuse_word_enable_data_write(hw, + *efuse_addr + 1, + tmp_pkt.word_en, + originaldata); + + if (0x0F != (badworden & 0x0F)) { + u8 reorg_offset = tmp_pkt.offset; + u8 reorg_worden = badworden; + efuse_pg_packet_write(hw, reorg_offset, + reorg_worden, + originaldata); + *efuse_addr = efuse_get_current_size(hw); + } else { + *efuse_addr = *efuse_addr + + (tmp_word_cnts * 2) + 1; + } + } else { + *efuse_addr = *efuse_addr + (tmp_word_cnts * 2) + 1; + } + + *write_state = PG_STATE_HEADER; + *repeat_times += 1; + if (*repeat_times > EFUSE_REPEAT_THRESHOLD_) { + *bcontinual = false; + *bresult = false; + } + + RTPRINT(rtlpriv, FEEPROM, EFUSE_PG, + "efuse PG_STATE_HEADER-2\n"); + } +} + +static int efuse_pg_packet_write(struct ieee80211_hw *hw, + u8 offset, u8 word_en, u8 *data) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct pgpkt_struct target_pkt; + u8 write_state = PG_STATE_HEADER; + int bcontinual = true, bdataempty = true, bresult = true; + u16 efuse_addr = 0; + u8 efuse_data; + u8 target_word_cnts = 0; + u8 badworden = 0x0F; + static int repeat_times; + + if (efuse_get_current_size(hw) >= (EFUSE_MAX_SIZE - + rtlpriv->cfg->maps[EFUSE_OOB_PROTECT_BYTES_LEN])) { + RTPRINT(rtlpriv, FEEPROM, EFUSE_PG, + "efuse_pg_packet_write error\n"); + return false; + } + + target_pkt.offset = offset; + target_pkt.word_en = word_en; + + memset(target_pkt.data, 0xFF, 8 * sizeof(u8)); + + efuse_word_enable_data_read(word_en, data, target_pkt.data); + target_word_cnts = efuse_calculate_word_cnts(target_pkt.word_en); + + RTPRINT(rtlpriv, FEEPROM, EFUSE_PG, "efuse Power ON\n"); + + while (bcontinual && (efuse_addr < (EFUSE_MAX_SIZE - + rtlpriv->cfg->maps[EFUSE_OOB_PROTECT_BYTES_LEN]))) { + if (write_state == PG_STATE_HEADER) { + bdataempty = true; + badworden = 0x0F; + RTPRINT(rtlpriv, FEEPROM, EFUSE_PG, + "efuse PG_STATE_HEADER\n"); + + if (stg_efuse_one_byte_read(hw, efuse_addr, &efuse_data) && + (efuse_data != 0xFF)) + efuse_write_data_case1(hw, &efuse_addr, + efuse_data, offset, + &bcontinual, + &write_state, + &target_pkt, + &repeat_times, &bresult, + word_en); + else + efuse_write_data_case2(hw, &efuse_addr, + &bcontinual, + &write_state, + target_pkt, + &repeat_times, + &bresult); + + } else if (write_state == PG_STATE_DATA) { + RTPRINT(rtlpriv, FEEPROM, EFUSE_PG, + "efuse PG_STATE_DATA\n"); + badworden = 0x0f; + badworden = + efuse_word_enable_data_write(hw, efuse_addr + 1, + target_pkt.word_en, + target_pkt.data); + + if ((badworden & 0x0F) == 0x0F) { + bcontinual = false; + } else { + efuse_addr = + efuse_addr + (2 * target_word_cnts) + 1; + + target_pkt.offset = offset; + target_pkt.word_en = badworden; + target_word_cnts = + efuse_calculate_word_cnts(target_pkt. + word_en); + write_state = PG_STATE_HEADER; + repeat_times++; + if (repeat_times > EFUSE_REPEAT_THRESHOLD_) { + bcontinual = false; + bresult = false; + } + RTPRINT(rtlpriv, FEEPROM, EFUSE_PG, + "efuse PG_STATE_HEADER-3\n"); + } + } + } + + if (efuse_addr >= (EFUSE_MAX_SIZE - + rtlpriv->cfg->maps[EFUSE_OOB_PROTECT_BYTES_LEN])) { + RT_TRACE(COMP_EFUSE, DBG_LOUD, + ("efuse_addr(%#x) Out of size!!\n", efuse_addr)); + } + + return true; +} + +static void efuse_word_enable_data_read(u8 word_en, u8 *sourdata, + u8 *targetdata) +{ + if (!(word_en & BIT(0))) { + targetdata[0] = sourdata[0]; + targetdata[1] = sourdata[1]; + } + + if (!(word_en & BIT(1))) { + targetdata[2] = sourdata[2]; + targetdata[3] = sourdata[3]; + } + + if (!(word_en & BIT(2))) { + targetdata[4] = sourdata[4]; + targetdata[5] = sourdata[5]; + } + + if (!(word_en & BIT(3))) { + targetdata[6] = sourdata[6]; + targetdata[7] = sourdata[7]; + } +} + +static u8 efuse_word_enable_data_write(struct ieee80211_hw *hw, + u16 efuse_addr, u8 word_en, u8 *data) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u16 tmpaddr; + u16 start_addr = efuse_addr; + u8 badworden = 0x0F; + u8 tmpdata[8]; + + memset(tmpdata, 0xff, PGPKT_DATA_SIZE); + RT_TRACE(COMP_EFUSE, DBG_LOUD, + ("word_en = %x efuse_addr=%x\n", word_en, efuse_addr)); + + if (!(word_en & BIT(0))) { + tmpaddr = start_addr; + efuse_one_byte_write(hw, start_addr++, data[0]); + efuse_one_byte_write(hw, start_addr++, data[1]); + + stg_efuse_one_byte_read(hw, tmpaddr, &tmpdata[0]); + stg_efuse_one_byte_read(hw, tmpaddr + 1, &tmpdata[1]); + if ((data[0] != tmpdata[0]) || (data[1] != tmpdata[1])) + badworden &= (~BIT(0)); + } + + if (!(word_en & BIT(1))) { + tmpaddr = start_addr; + efuse_one_byte_write(hw, start_addr++, data[2]); + efuse_one_byte_write(hw, start_addr++, data[3]); + + stg_efuse_one_byte_read(hw, tmpaddr, &tmpdata[2]); + stg_efuse_one_byte_read(hw, tmpaddr + 1, &tmpdata[3]); + if ((data[2] != tmpdata[2]) || (data[3] != tmpdata[3])) + badworden &= (~BIT(1)); + } + + if (!(word_en & BIT(2))) { + tmpaddr = start_addr; + efuse_one_byte_write(hw, start_addr++, data[4]); + efuse_one_byte_write(hw, start_addr++, data[5]); + + stg_efuse_one_byte_read(hw, tmpaddr, &tmpdata[4]); + stg_efuse_one_byte_read(hw, tmpaddr + 1, &tmpdata[5]); + if ((data[4] != tmpdata[4]) || (data[5] != tmpdata[5])) + badworden &= (~BIT(2)); + } + + if (!(word_en & BIT(3))) { + tmpaddr = start_addr; + efuse_one_byte_write(hw, start_addr++, data[6]); + efuse_one_byte_write(hw, start_addr++, data[7]); + + stg_efuse_one_byte_read(hw, tmpaddr, &tmpdata[6]); + stg_efuse_one_byte_read(hw, tmpaddr + 1, &tmpdata[7]); + if ((data[6] != tmpdata[6]) || (data[7] != tmpdata[7])) + badworden &= (~BIT(3)); + } + + return badworden; +} + +static void efuse_power_switch(struct ieee80211_hw *hw, u8 bwrite, u8 pwrstate) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + u8 tempval; + u16 tmpv16; + + if (pwrstate && (rtlhal->hw_type != HARDWARE_TYPE_RTL8192SE)) { + if (rtlhal->hw_type != HARDWARE_TYPE_RTL8192CE && + rtlhal->hw_type != HARDWARE_TYPE_RTL8192DE) { + rtl_write_byte(rtlpriv, + rtlpriv->cfg->maps[EFUSE_ACCESS], 0x69); + } else { + tmpv16 = rtl_read_word(rtlpriv, + rtlpriv->cfg->maps[SYS_ISO_CTRL]); + if (!(tmpv16 & rtlpriv->cfg->maps[EFUSE_PWC_EV12V])) { + tmpv16 |= rtlpriv->cfg->maps[EFUSE_PWC_EV12V]; + rtl_write_word(rtlpriv, + rtlpriv->cfg->maps[SYS_ISO_CTRL], + tmpv16); + } + } + tmpv16 = rtl_read_word(rtlpriv, + rtlpriv->cfg->maps[SYS_FUNC_EN]); + if (!(tmpv16 & rtlpriv->cfg->maps[EFUSE_FEN_ELDR])) { + tmpv16 |= rtlpriv->cfg->maps[EFUSE_FEN_ELDR]; + rtl_write_word(rtlpriv, + rtlpriv->cfg->maps[SYS_FUNC_EN], tmpv16); + } + + tmpv16 = rtl_read_word(rtlpriv, rtlpriv->cfg->maps[SYS_CLK]); + if ((!(tmpv16 & rtlpriv->cfg->maps[EFUSE_LOADER_CLK_EN])) || + (!(tmpv16 & rtlpriv->cfg->maps[EFUSE_ANA8M]))) { + tmpv16 |= (rtlpriv->cfg->maps[EFUSE_LOADER_CLK_EN] | + rtlpriv->cfg->maps[EFUSE_ANA8M]); + rtl_write_word(rtlpriv, + rtlpriv->cfg->maps[SYS_CLK], tmpv16); + } + } + + if (pwrstate) { + if (bwrite) { + tempval = rtl_read_byte(rtlpriv, + rtlpriv->cfg->maps[EFUSE_TEST] + + 3); + + if (rtlhal->hw_type == HARDWARE_TYPE_RTL8812AE) { + tempval &= ~(BIT(3) | BIT(4) | BIT(5) | BIT(6)); + tempval |= (VOLTAGE_V25 << 3); + } else if (rtlhal->hw_type != HARDWARE_TYPE_RTL8192SE) { + tempval &= 0x0F; + tempval |= (VOLTAGE_V25 << 4); + } + + rtl_write_byte(rtlpriv, + rtlpriv->cfg->maps[EFUSE_TEST] + 3, + (tempval | 0x80)); + } + + if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192SE) { + rtl_write_byte(rtlpriv, rtlpriv->cfg->maps[EFUSE_CLK], + 0x03); + } + } else { + if (rtlhal->hw_type != HARDWARE_TYPE_RTL8192CE && + rtlhal->hw_type != HARDWARE_TYPE_RTL8192DE) + rtl_write_byte(rtlpriv, + rtlpriv->cfg->maps[EFUSE_ACCESS], 0); + if (bwrite) { + tempval = rtl_read_byte(rtlpriv, + rtlpriv->cfg->maps[EFUSE_TEST] + + 3); + rtl_write_byte(rtlpriv, + rtlpriv->cfg->maps[EFUSE_TEST] + 3, + (tempval & 0x7F)); + } + + if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192SE) { + rtl_write_byte(rtlpriv, rtlpriv->cfg->maps[EFUSE_CLK], + 0x02); + } + } +} + +static u16 efuse_get_current_size(struct ieee80211_hw *hw) +{ + int bcontinual = true; + u16 efuse_addr = 0; + u8 hoffset, hworden; + u8 efuse_data, word_cnts; + + while (bcontinual && + stg_efuse_one_byte_read(hw, efuse_addr, &efuse_data) && + (efuse_addr < EFUSE_MAX_SIZE)) { + if (efuse_data != 0xFF) { + hoffset = (efuse_data >> 4) & 0x0F; + hworden = efuse_data & 0x0F; + word_cnts = efuse_calculate_word_cnts(hworden); + efuse_addr = efuse_addr + (word_cnts * 2) + 1; + } else { + bcontinual = false; + } + } + + return efuse_addr; +} + +static u8 efuse_calculate_word_cnts(u8 word_en) +{ + u8 word_cnts = 0; + if (!(word_en & BIT(0))) + word_cnts++; + if (!(word_en & BIT(1))) + word_cnts++; + if (!(word_en & BIT(2))) + word_cnts++; + if (!(word_en & BIT(3))) + word_cnts++; + return word_cnts; +} diff --git a/drivers/staging/rtl8192ee/efuse.h b/drivers/staging/rtl8192ee/efuse.h new file mode 100644 index 000000000000..cc3e1116b3e4 --- /dev/null +++ b/drivers/staging/rtl8192ee/efuse.h @@ -0,0 +1,127 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#ifndef __RTL_EFUSE_H_ +#define __RTL_EFUSE_H_ + +#define EFUSE_IC_ID_OFFSET 506 + +/* +#define EFUSE_REAL_CONTENT_LEN 512 +#define EFUSE_MAP_LEN 128 +#define EFUSE_MAX_SECTION 16 +#define EFUSE_MAX_WORD_UNIT 4 +#define EFUSE_IC_ID_OFFSET 506 +*/ + +#define EFUSE_MAX_WORD_UNIT 4 + +#define EFUSE_INIT_MAP 0 +#define EFUSE_MODIFY_MAP 1 + +#define PG_STATE_HEADER 0x01 +#define PG_STATE_WORD_0 0x02 +#define PG_STATE_WORD_1 0x04 +#define PG_STATE_WORD_2 0x08 +#define PG_STATE_WORD_3 0x10 +#define PG_STATE_DATA 0x20 + +#define PG_SWBYTE_H 0x01 +#define PG_SWBYTE_L 0x02 + +#define _POWERON_DELAY_ +#define _PRE_EXECUTE_READ_CMD_ + +#define EFUSE_REPEAT_THRESHOLD_ 3 +#define EFUSE_ERROE_HANDLE 1 + +struct efuse_map { + u8 offset; + u8 word_start; + u8 byte_start; + u8 byte_cnts; +}; + +struct pgpkt_struct { + u8 offset; + u8 word_en; + u8 data[8]; +}; + +enum efuse_data_item { + EFUSE_CHIP_ID = 0, + EFUSE_LDO_SETTING, + EFUSE_CLK_SETTING, + EFUSE_SDIO_SETTING, + EFUSE_CCCR, + EFUSE_SDIO_MODE, + EFUSE_OCR, + EFUSE_F0CIS, + EFUSE_F1CIS, + EFUSE_MAC_ADDR, + EFUSE_EEPROM_VER, + EFUSE_CHAN_PLAN, + EFUSE_TXPW_TAB +}; + +enum { + VOLTAGE_V25 = 0x03, + LDOE25_SHIFT = 28, +}; + +struct efuse_priv { + u8 id[2]; + u8 ldo_setting[2]; + u8 clk_setting[2]; + u8 cccr; + u8 sdio_mode; + u8 ocr[3]; + u8 cis0[17]; + u8 cis1[48]; + u8 mac_addr[6]; + u8 eeprom_verno; + u8 channel_plan; + u8 tx_power_b[14]; + u8 tx_power_g[14]; +}; + +void read92e_efuse_byte(struct ieee80211_hw *hw, u16 _offset, u8 *pbuf); +void efuse92e_initialize(struct ieee80211_hw *hw); +u8 stg_efuse_read_1byte(struct ieee80211_hw *hw, u16 address); +int stg_efuse_one_byte_read(struct ieee80211_hw *hw, u16 addr, u8 *data); +void efuse92e_write_1byte(struct ieee80211_hw *hw, u16 address, u8 value); +void read92e_efuse(struct ieee80211_hw *hw, u16 _offset, + u16 _size_byte, u8 *pbuf); +void efuse92e_shadow_read(struct ieee80211_hw *hw, u8 type, + u16 offset, u32 *value); +void efuse92e_shadow_write(struct ieee80211_hw *hw, u8 type, + u16 offset, u32 value); +bool efuse92e_shadow_update(struct ieee80211_hw *hw); +bool efuse92e_shadow_update_chk(struct ieee80211_hw *hw); +void stg_rtl_efuse92e_shadow_map_update(struct ieee80211_hw *hw); +void efuse92e_force_write_vendor_Id(struct ieee80211_hw *hw); +void efuse92e_re_pg_section(struct ieee80211_hw *hw, u8 section_idx); + +#endif diff --git a/drivers/staging/rtl8192ee/pci.c b/drivers/staging/rtl8192ee/pci.c new file mode 100644 index 000000000000..3fe9b7ba01d6 --- /dev/null +++ b/drivers/staging/rtl8192ee/pci.c @@ -0,0 +1,2397 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#include "core.h" +#include "wifi.h" +#include "pci.h" +#include "base.h" +#include "ps.h" +#include "efuse.h" + +static const u16 pcibridge_vendors[PCI_BRIDGE_VENDOR_MAX] = { + INTEL_VENDOR_ID, + ATI_VENDOR_ID, + AMD_VENDOR_ID, + SIS_VENDOR_ID +}; + +static const u8 ac_to_hwq[] = { + VO_QUEUE, + VI_QUEUE, + BE_QUEUE, + BK_QUEUE +}; + +static u8 _rtl_mac_to_hwqueue(struct ieee80211_hw *hw, + struct sk_buff *skb) +{ + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + __le16 fc = rtl_get_fc(skb); + u8 queue_index = skb_get_queue_mapping(skb); + + if (unlikely(ieee80211_is_beacon(fc))) + return BEACON_QUEUE; + if (ieee80211_is_mgmt(fc) || ieee80211_is_ctl(fc)) + return MGNT_QUEUE; + if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192SE) + if (ieee80211_is_nullfunc(fc)) + return HIGH_QUEUE; + + return ac_to_hwq[queue_index]; +} + +/* Update PCI dependent default settings*/ +static void _rtl_pci_update_default_setting(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + u8 pcibridge_vendor = pcipriv->ndis_adapter.pcibridge_vendor; + u8 init_aspm; + + ppsc->reg_rfps_level = 0; + ppsc->b_support_aspm = 0; + + /*Update PCI ASPM setting */ + ppsc->const_amdpci_aspm = rtlpci->const_amdpci_aspm; + switch (rtlpci->const_pci_aspm) { + case 0: + /*No ASPM */ + break; + + case 1: + /*ASPM dynamically enabled/disable. */ + ppsc->reg_rfps_level |= RT_RF_LPS_LEVEL_ASPM; + break; + + case 2: + /*ASPM with Clock Req dynamically enabled/disable. */ + ppsc->reg_rfps_level |= (RT_RF_LPS_LEVEL_ASPM | + RT_RF_OFF_LEVL_CLK_REQ); + break; + + case 3: + /* + * Always enable ASPM and Clock Req + * from initialization to halt. + * */ + ppsc->reg_rfps_level &= ~(RT_RF_LPS_LEVEL_ASPM); + ppsc->reg_rfps_level |= (RT_RF_PS_LEVEL_ALWAYS_ASPM | + RT_RF_OFF_LEVL_CLK_REQ); + break; + + case 4: + /* + * Always enable ASPM without Clock Req + * from initialization to halt. + * */ + ppsc->reg_rfps_level &= ~(RT_RF_LPS_LEVEL_ASPM | + RT_RF_OFF_LEVL_CLK_REQ); + ppsc->reg_rfps_level |= RT_RF_PS_LEVEL_ALWAYS_ASPM; + break; + } + + ppsc->reg_rfps_level |= RT_RF_OFF_LEVL_HALT_NIC; + + /*Update Radio OFF setting */ + switch (rtlpci->const_hwsw_rfoff_d3) { + case 1: + if (ppsc->reg_rfps_level & RT_RF_LPS_LEVEL_ASPM) + ppsc->reg_rfps_level |= RT_RF_OFF_LEVL_ASPM; + break; + + case 2: + if (ppsc->reg_rfps_level & RT_RF_LPS_LEVEL_ASPM) + ppsc->reg_rfps_level |= RT_RF_OFF_LEVL_ASPM; + ppsc->reg_rfps_level |= RT_RF_OFF_LEVL_HALT_NIC; + break; + + case 3: + ppsc->reg_rfps_level |= RT_RF_OFF_LEVL_PCI_D3; + break; + } + + /*Set HW definition to determine if it supports ASPM. */ + switch (rtlpci->const_support_pciaspm) { + case 0:{ + /*Not support ASPM. */ + bool b_support_aspm = false; + ppsc->b_support_aspm = b_support_aspm; + break; + } + case 1:{ + /*Support ASPM. */ + bool b_support_aspm = true; + bool b_support_backdoor = true; + ppsc->b_support_aspm = b_support_aspm; + + /*if (priv->oem_id == RT_CID_TOSHIBA && + !priv->ndis_adapter.amd_l1_patch) + b_support_backdoor = false; */ + + ppsc->b_support_backdoor = b_support_backdoor; + + break; + } + case 2: + /*ASPM value set by chipset. */ + if (pcibridge_vendor == PCI_BRIDGE_VENDOR_INTEL) { + bool b_support_aspm = true; + ppsc->b_support_aspm = b_support_aspm; + } + break; + default: + RT_TRACE(COMP_ERR, DBG_EMERG, + ("switch case not process\n")); + break; + } + + /* toshiba aspm issue, toshiba will set aspm selfly + * so we should not set aspm in driver */ + pci_read_config_byte(rtlpci->pdev, 0x80, &init_aspm); + if (rtlpriv->rtlhal.hw_type == HARDWARE_TYPE_RTL8192SE && + init_aspm == 0x43) + ppsc->b_support_aspm = false; +} + +static bool _rtl_pci_platform_switch_device_pci_aspm(struct ieee80211_hw *hw, + u8 value) +{ + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + bool bresult = false; + + if (rtlhal->hw_type != HARDWARE_TYPE_RTL8192SE) + value |= 0x40; + + pci_write_config_byte(rtlpci->pdev, 0x80, value); + + return bresult; +} + +/*When we set 0x01 to enable clk request. Set 0x0 to disable clk req.*/ +static bool _rtl_pci_switch_clk_req(struct ieee80211_hw *hw, u8 value) +{ + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + bool bresult = false; + + pci_write_config_byte(rtlpci->pdev, 0x81, value); + bresult = true; + + if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192SE) + udelay(100); + + return bresult; +} + +/*Disable RTL8192SE ASPM & Disable Pci Bridge ASPM*/ +static void rtl_pci_disable_aspm(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + u8 pcibridge_vendor = pcipriv->ndis_adapter.pcibridge_vendor; + u32 pcicfg_addrport = pcipriv->ndis_adapter.pcicfg_addrport; + u8 num4bytes = pcipriv->ndis_adapter.num4bytes; + /*Retrieve original configuration settings. */ + u8 linkctrl_reg = pcipriv->ndis_adapter.linkctrl_reg; + u16 pcibridge_linkctrlreg = pcipriv->ndis_adapter. + pcibridge_linkctrlreg; + u16 aspmlevel = 0; + + if (!ppsc->b_support_aspm) + return; + + if (pcibridge_vendor == PCI_BRIDGE_VENDOR_UNKNOWN) { + RT_TRACE(COMP_POWER, DBG_TRACE, + ("PCI(Bridge) UNKNOWN.\n")); + + return; + } + + if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_CLK_REQ) { + RT_CLEAR_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_CLK_REQ); + _rtl_pci_switch_clk_req(hw, 0x0); + } + + if (1) { + /*for promising device will in L0 state after an I/O. */ + u8 tmp_u1b; + pci_read_config_byte(rtlpci->pdev, 0x80, &tmp_u1b); + } + + /*Set corresponding value. */ + aspmlevel |= BIT(0) | BIT(1); + linkctrl_reg &= ~aspmlevel; + pcibridge_linkctrlreg &= ~(BIT(0) | BIT(1)); + + _rtl_pci_platform_switch_device_pci_aspm(hw, linkctrl_reg); + udelay(50); + + /*4 Disable Pci Bridge ASPM */ + rtl_pci_raw_write_port_ulong(PCI_CONF_ADDRESS, + pcicfg_addrport + (num4bytes << 2)); + rtl_pci_raw_write_port_uchar(PCI_CONF_DATA, pcibridge_linkctrlreg); + + udelay(50); +} + +/* + *Enable RTL8192SE ASPM & Enable Pci Bridge ASPM for + *power saving We should follow the sequence to enable + *RTL8192SE first then enable Pci Bridge ASPM + *or the system will show bluescreen. + */ +static void rtl_pci_enable_aspm(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + u8 pcibridge_vendor = pcipriv->ndis_adapter.pcibridge_vendor; + u32 pcicfg_addrport = pcipriv->ndis_adapter.pcicfg_addrport; + u8 num4bytes = pcipriv->ndis_adapter.num4bytes; + u16 aspmlevel; + u8 u_pcibridge_aspmsetting; + u8 u_device_aspmsetting; + + if (!ppsc->b_support_aspm) + return; + + if (pcibridge_vendor == PCI_BRIDGE_VENDOR_UNKNOWN) { + RT_TRACE(COMP_POWER, DBG_TRACE, + ("PCI(Bridge) UNKNOWN.\n")); + return; + } + + /*4 Enable Pci Bridge ASPM */ + rtl_pci_raw_write_port_ulong(PCI_CONF_ADDRESS, + pcicfg_addrport + (num4bytes << 2)); + + u_pcibridge_aspmsetting = + pcipriv->ndis_adapter.pcibridge_linkctrlreg | + rtlpci->const_hostpci_aspm_setting; + + if (pcibridge_vendor == PCI_BRIDGE_VENDOR_INTEL) + u_pcibridge_aspmsetting &= ~BIT(0); + + rtl_pci_raw_write_port_uchar(PCI_CONF_DATA, u_pcibridge_aspmsetting); + + RT_TRACE(COMP_INIT, DBG_LOUD, + ("PlatformEnableASPM(): Write reg[%x] = %x\n", + (pcipriv->ndis_adapter.pcibridge_pciehdr_offset + 0x10), + u_pcibridge_aspmsetting)); + + udelay(50); + + /*Get ASPM level (with/without Clock Req) */ + aspmlevel = rtlpci->const_devicepci_aspm_setting; + u_device_aspmsetting = pcipriv->ndis_adapter.linkctrl_reg; + + /*_rtl_pci_platform_switch_device_pci_aspm(dev,*/ + /*(priv->ndis_adapter.linkctrl_reg | ASPMLevel)); */ + + u_device_aspmsetting |= aspmlevel; + + _rtl_pci_platform_switch_device_pci_aspm(hw, u_device_aspmsetting); + + if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_CLK_REQ) { + _rtl_pci_switch_clk_req(hw, (ppsc->reg_rfps_level & + RT_RF_OFF_LEVL_CLK_REQ) ? 1 : 0); + RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_CLK_REQ); + } + udelay(100); +} + +static bool rtl_pci_get_amd_l1_patch(struct ieee80211_hw *hw) +{ + struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); + u32 pcicfg_addrport = pcipriv->ndis_adapter.pcicfg_addrport; + + bool status = false; + u8 offset_e0; + unsigned offset_e4; + + rtl_pci_raw_write_port_ulong(PCI_CONF_ADDRESS, pcicfg_addrport + 0xE0); + rtl_pci_raw_write_port_uchar(PCI_CONF_DATA, 0xA0); + + rtl_pci_raw_write_port_ulong(PCI_CONF_ADDRESS, pcicfg_addrport + 0xE0); + rtl_pci_raw_read_port_uchar(PCI_CONF_DATA, &offset_e0); + + if (offset_e0 == 0xA0) { + rtl_pci_raw_write_port_ulong(PCI_CONF_ADDRESS, + pcicfg_addrport + 0xE4); + rtl_pci_raw_read_port_ulong(PCI_CONF_DATA, &offset_e4); + if (offset_e4 & BIT(23)) + status = true; + } + + return status; +} + +static bool rtl_pci_check_buddy_priv(struct ieee80211_hw *hw, + struct rtl_priv **buddy_priv) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); + bool find_buddy_priv = false; + struct rtl_priv *tpriv = NULL; + struct rtl_pci_priv *tpcipriv = NULL; + + if (!list_empty(&rtlpriv->glb_var->glb_priv_list)) { + list_for_each_entry(tpriv, &rtlpriv->glb_var->glb_priv_list, + list) { + if (tpriv == NULL) + break; + + tpcipriv = (struct rtl_pci_priv *)tpriv->priv; + RT_TRACE(COMP_INIT, DBG_LOUD, + ("pcipriv->ndis_adapter.funcnumber %x\n", + pcipriv->ndis_adapter.funcnumber)); + RT_TRACE(COMP_INIT, DBG_LOUD, + ("tpcipriv->ndis_adapter.funcnumber %x\n", + tpcipriv->ndis_adapter.funcnumber)); + + if ((pcipriv->ndis_adapter.busnumber == + tpcipriv->ndis_adapter.busnumber) && + (pcipriv->ndis_adapter.devnumber == + tpcipriv->ndis_adapter.devnumber) && + (pcipriv->ndis_adapter.funcnumber != + tpcipriv->ndis_adapter.funcnumber)) { + find_buddy_priv = true; + break; + } + } + } + + RT_TRACE(COMP_INIT, DBG_LOUD, + ("find_buddy_priv %d\n", find_buddy_priv)); + + if (find_buddy_priv) + *buddy_priv = tpriv; + + return find_buddy_priv; +} + +static void rtl_pci_get_linkcontrol_field(struct ieee80211_hw *hw) +{ + struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); + u8 capabilityoffset = pcipriv->ndis_adapter.pcibridge_pciehdr_offset; + u32 pcicfg_addrport = pcipriv->ndis_adapter.pcicfg_addrport; + u8 linkctrl_reg; + u8 num4bbytes; + + num4bbytes = (capabilityoffset + 0x10) / 4; + + /*Read Link Control Register */ + rtl_pci_raw_write_port_ulong(PCI_CONF_ADDRESS, + pcicfg_addrport + (num4bbytes << 2)); + rtl_pci_raw_read_port_uchar(PCI_CONF_DATA, &linkctrl_reg); + + pcipriv->ndis_adapter.pcibridge_linkctrlreg = linkctrl_reg; +} + +static void rtl_pci_parse_configuration(struct pci_dev *pdev, + struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); + + u8 tmp; + int pos; + u8 linkctrl_reg; + + /*Link Control Register */ + pos = pci_find_capability(pdev, PCI_CAP_ID_EXP); + pci_read_config_byte(pdev, pos + PCI_EXP_LNKCTL, &linkctrl_reg); + pcipriv->ndis_adapter.linkctrl_reg = linkctrl_reg; + + RT_TRACE(COMP_INIT, DBG_TRACE, + ("Link Control Register =%x\n", + pcipriv->ndis_adapter.linkctrl_reg)); + + pci_read_config_byte(pdev, 0x98, &tmp); + tmp |= BIT(4); + pci_write_config_byte(pdev, 0x98, tmp); + + tmp = 0x17; + pci_write_config_byte(pdev, 0x70f, tmp); +} + +static void rtl_pci_init_aspm(struct ieee80211_hw *hw) +{ + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + + _rtl_pci_update_default_setting(hw); + + if (ppsc->reg_rfps_level & RT_RF_PS_LEVEL_ALWAYS_ASPM) { + /*Always enable ASPM & Clock Req. */ + rtl_pci_enable_aspm(hw); + RT_SET_PS_LEVEL(ppsc, RT_RF_PS_LEVEL_ALWAYS_ASPM); + } +} + +static void _rtl_pci_io_handler_init(struct device *dev, + struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + rtlpriv->io.dev = dev; + + rtlpriv->io.write8_async = pci_write8_async; + rtlpriv->io.write16_async = pci_write16_async; + rtlpriv->io.write32_async = pci_write32_async; + + rtlpriv->io.read8_sync = pci_read8_sync; + rtlpriv->io.read16_sync = pci_read16_sync; + rtlpriv->io.read32_sync = pci_read32_sync; +} + +static bool _rtl_pci_update_earlymode_info(struct ieee80211_hw *hw, + struct sk_buff *skb, + struct rtl_tcb_desc *tcb_desc, + u8 tid) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + struct sk_buff *next_skb; + u8 additionlen = FCS_LEN; + + /* here open is 4, wep/tkip is 8, aes is 12*/ + if (info->control.hw_key) + additionlen += info->control.hw_key->icv_len; + + /* The most skb num is 6 */ + tcb_desc->empkt_num = 0; + spin_lock_bh(&rtlpriv->locks.waitq_lock); + skb_queue_walk(&rtlpriv->mac80211.skb_waitq[tid], next_skb) { + struct ieee80211_tx_info *next_info; + + next_info = IEEE80211_SKB_CB(next_skb); + if (next_info->flags & IEEE80211_TX_CTL_AMPDU) { + tcb_desc->empkt_len[tcb_desc->empkt_num] = + next_skb->len + additionlen; + tcb_desc->empkt_num++; + } else { + break; + } + + if (skb_queue_is_last(&rtlpriv->mac80211.skb_waitq[tid], + next_skb)) + break; + + if (tcb_desc->empkt_num >= rtlhal->max_earlymode_num) + break; + } + spin_unlock_bh(&rtlpriv->locks.waitq_lock); + return true; +} + +/* just for early mode now */ +static void _rtl_pci_tx_chk_waitq(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + struct sk_buff *skb = NULL; + struct ieee80211_tx_info *info = NULL; + int tid; /* should be int */ + + if (!rtlpriv->rtlhal.b_earlymode_enable) + return; + if (rtlpriv->dm.supp_phymode_switch && + (rtlpriv->easy_concurrent_ctl.bswitch_in_process || + (rtlpriv->buddy_priv && + rtlpriv->buddy_priv->easy_concurrent_ctl.bswitch_in_process))) + return; + /* we juse use em for BE/BK/VI/VO */ + for (tid = 7; tid >= 0; tid--) { + u8 hw_queue = ac_to_hwq[rtl92e_tid_to_ac(hw, tid)]; + struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[hw_queue]; + while (!mac->act_scanning && + rtlpriv->psc.rfpwr_state == ERFON) { + struct rtl_tcb_desc tcb_desc; + memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc)); + + spin_lock_bh(&rtlpriv->locks.waitq_lock); + if (!skb_queue_empty(&mac->skb_waitq[tid]) && + (ring->entries - skb_queue_len(&ring->queue) > + rtlhal->max_earlymode_num)) { + skb = skb_dequeue(&mac->skb_waitq[tid]); + } else { + spin_unlock_bh(&rtlpriv->locks.waitq_lock); + break; + } + spin_unlock_bh(&rtlpriv->locks.waitq_lock); + + /* Some macaddr can't do early mode. like + * multicast/broadcast/no_qos data */ + info = IEEE80211_SKB_CB(skb); + if (info->flags & IEEE80211_TX_CTL_AMPDU) + _rtl_pci_update_earlymode_info(hw, skb, + &tcb_desc, tid); + + rtlpriv->intf_ops->adapter_tx(hw, NULL, skb, &tcb_desc); + } + } +} + +static void _rtl_pci_tx_isr(struct ieee80211_hw *hw, int prio) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[prio]; + + while (skb_queue_len(&ring->queue)) { + struct sk_buff *skb; + struct ieee80211_tx_info *info; + __le16 fc; + u8 tid; + u8 *entry; + + + if (rtlpriv->use_new_trx_flow) + entry = (u8 *)(&ring->buffer_desc[ring->idx]); + else + entry = (u8 *)(&ring->desc[ring->idx]); + + if (rtlpriv->cfg->ops->is_tx_desc_closed && + !rtlpriv->cfg->ops->is_tx_desc_closed(hw, prio, ring->idx)) + return; + + ring->idx = (ring->idx + 1) % ring->entries; + + skb = __skb_dequeue(&ring->queue); + + pci_unmap_single(rtlpci->pdev, + rtlpriv->cfg->ops-> + get_desc((u8 *)entry, true, + HW_DESC_TXBUFF_ADDR), + skb->len, PCI_DMA_TODEVICE); + + /* remove early mode header */ + if (rtlpriv->rtlhal.b_earlymode_enable) + skb_pull(skb, EM_HDR_LEN); + + RT_TRACE((COMP_INTR | COMP_SEND), DBG_TRACE, + ("new ring->idx:%d, free: skb_queue_len:%d, free: seq:%d\n", + ring->idx, + skb_queue_len(&ring->queue), + *(u16 *)(skb->data + 22))); + + if (prio == TXCMD_QUEUE) { + dev_kfree_skb(skb); + goto tx_status_ok; + } + + /* for sw LPS, just after NULL skb send out, we can + * sure AP knows that we are sleeping, our we should not let + * rf to sleep + */ + fc = rtl_get_fc(skb); + if (ieee80211_is_nullfunc(fc)) { + if (ieee80211_has_pm(fc)) { + rtlpriv->mac80211.offchan_deley = true; + rtlpriv->psc.state_inap = 1; + } else { + rtlpriv->psc.state_inap = 0; + } + } + if (ieee80211_is_action(fc)) { + struct ieee80211_mgmt_compat *action_frame = + (struct ieee80211_mgmt_compat *)skb->data; + if (action_frame->u.action.u.ht_smps.action == + WLAN_HT_ACTION_SMPS) { + dev_kfree_skb(skb); + goto tx_status_ok; + } + } + + /* update tid tx pkt num */ + tid = rtl_get_tid(skb); + if (tid <= 7) + rtlpriv->link_info.tidtx_inperiod[tid]++; + + info = IEEE80211_SKB_CB(skb); + ieee80211_tx_info_clear_status(info); + + info->flags |= IEEE80211_TX_STAT_ACK; + /*info->status.rates[0].count = 1; */ + + ieee80211_tx_status_irqsafe(hw, skb); + + if ((ring->entries - skb_queue_len(&ring->queue)) == 2) { + RT_TRACE(COMP_ERR, DBG_LOUD, + ("more desc left, wake skb_queue@%d,ring->idx = %d, skb_queue_len = 0x%d\n", + prio, ring->idx, + skb_queue_len(&ring->queue))); + + ieee80211_wake_queue(hw, skb_get_queue_mapping + (skb)); + } +tx_status_ok: + skb = NULL; + } + + if (((rtlpriv->link_info.num_rx_inperiod + + rtlpriv->link_info.num_tx_inperiod) > 8) || + (rtlpriv->link_info.num_rx_inperiod > 2)) { + rtl92e_lps_leave(hw); + } +} + +static int _rtl_pci_init_one_rxdesc(struct ieee80211_hw *hw, + u8 *entry, int rxring_idx, int desc_idx) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + struct sk_buff *skb; + u32 bufferaddress; + u8 tmp_one = 1; + + skb = dev_alloc_skb(rtlpci->rxbuffersize); + if (!skb) + return 0; + rtlpci->rx_ring[rxring_idx].rx_buf[desc_idx] = skb; + + /* just set skb->cb to mapping addr + * for pci_unmap_single use + */ + *((dma_addr_t *)skb->cb) = pci_map_single(rtlpci->pdev, + skb_tail_pointer(skb), rtlpci->rxbuffersize, + PCI_DMA_FROMDEVICE); + bufferaddress = *((dma_addr_t *)skb->cb); + if (pci_dma_mapping_error(rtlpci->pdev, bufferaddress)) + return 0; + if (rtlpriv->use_new_trx_flow) { + rtlpriv->cfg->ops->set_desc(hw, (u8 *)entry, false, + HW_DESC_RX_PREPARE, + (u8 *)&bufferaddress); + } else { + rtlpriv->cfg->ops->set_desc(hw, (u8 *)entry, false, + HW_DESC_RXBUFF_ADDR, + (u8 *)&bufferaddress); + rtlpriv->cfg->ops->set_desc(hw, (u8 *)entry, false, + HW_DESC_RXPKT_LEN, + (u8 *)&rtlpci->rxbuffersize); + rtlpriv->cfg->ops->set_desc(hw, (u8 *)entry, false, + HW_DESC_RXOWN, + (u8 *)&tmp_one); + } + return 1; +} + +/* inorder to receive 8K AMSDU we have set skb to + * 9100bytes in init rx ring, but if this packet is + * not a AMSDU, this so big packet will be sent to + * TCP/IP directly, this cause big packet ping fail + * like: "ping -s 65507", so here we will realloc skb + * based on the true size of packet, I think mac80211 + * do it will be better, but now mac80211 haven't */ + +/* but some platform will fail when alloc skb sometimes. + * in this condition, we will send the old skb to + * mac80211 directly, this will not cause any other + * issues, but only be losted by TCP/IP */ +static void _rtl_pci_rx_to_mac80211(struct ieee80211_hw *hw, + struct sk_buff *skb, + struct ieee80211_rx_status rx_status) +{ + if (unlikely(!rtl92e_action_proc(hw, skb, false))) { + dev_kfree_skb_any(skb); + } else { + struct sk_buff *uskb = NULL; + u8 *pdata; + + uskb = dev_alloc_skb(skb->len + 128); + if (likely(uskb)) { + memcpy(IEEE80211_SKB_RXCB(uskb), &rx_status, + sizeof(rx_status)); + pdata = (u8 *)skb_put(uskb, skb->len); + memcpy(pdata, skb->data, skb->len); + dev_kfree_skb_any(skb); + + ieee80211_rx_irqsafe(hw, uskb); + } else { + ieee80211_rx_irqsafe(hw, skb); + } + } +} + +/*hsisr interrupt handler*/ +static void _rtl_pci_hs_interrupt(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + + rtl_write_byte(rtlpriv, rtlpriv->cfg->maps[MAC_HSISR], + rtl_read_byte(rtlpriv, rtlpriv->cfg->maps[MAC_HSISR]) | + rtlpci->sys_irq_mask); +} + +static void _rtl_receive_one(struct ieee80211_hw *hw, struct sk_buff *skb, + struct ieee80211_rx_status rx_status) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct ieee80211_hdr *hdr = rtl_get_hdr(skb); + __le16 fc = rtl_get_fc(skb); + bool unicast = false; + + memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, sizeof(rx_status)); + + if (is_broadcast_ether_addr(hdr->addr1)) { + ;/*TODO*/ + } else if (is_multicast_ether_addr(hdr->addr1)) { + ;/*TODO*/ + } else { + unicast = true; + rtlpriv->stats.rxbytesunicast += skb->len; + } + + rtl92e_is_special_data(hw, skb, false); + if (ieee80211_is_data(fc)) { + rtlpriv->cfg->ops->led_control(hw, LED_CTL_RX); + + if (unicast) + rtlpriv->link_info.num_rx_inperiod++; + } + + /* static bcn for roaming */ + rtl92e_beacon_statistic(hw, skb); + rtl92e_p2p_info(hw, (void *)skb->data, skb->len); + + /* for sw lps */ + rtl92e_swlps_beacon(hw, (void *)skb->data, skb->len); + rtl92e_recognize_peer(hw, (void *)skb->data, skb->len); + if ((rtlpriv->mac80211.opmode == NL80211_IFTYPE_AP) && + (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G) && + (ieee80211_is_beacon(fc) || + ieee80211_is_probe_resp(fc))) + dev_kfree_skb_any(skb); + else + _rtl_pci_rx_to_mac80211(hw, skb, rx_status); +} + +static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + struct ieee80211_rx_status rx_status = { 0 }; + int rxring_idx = RTL_PCI_RX_MPDU_QUEUE; + unsigned int count = rtlpci->rxringcount; + u8 hw_queue = 0; + unsigned int rx_remained_cnt; + u8 own; + u8 tmp_one; + static int err_count; + struct rtl_stats stats = { + .signal = 0, + .rate = 0, + }; + + /*RX NORMAL PKT */ + while (count--) { + struct ieee80211_hdr *hdr; + __le16 fc; + u16 len; + /*rx buffer descriptor */ + struct rtl_rx_buffer_desc *buffer_desc = NULL; + /*if use new trx flow, it means wifi info */ + struct rtl_rx_desc *pdesc = NULL; + /*rx pkt */ + struct sk_buff *skb = rtlpci->rx_ring[rxring_idx].rx_buf[ + rtlpci->rx_ring[rxring_idx].idx]; + + if (rtlpriv->use_new_trx_flow) { + rx_remained_cnt = + rtlpriv->cfg->ops->rx_desc_buff_remained_cnt(hw, + hw_queue); + if (rx_remained_cnt < 1) + return; + + } else { /* rx descriptor */ + pdesc = &rtlpci->rx_ring[rxring_idx].desc[ + rtlpci->rx_ring[rxring_idx].idx]; + + own = (u8) rtlpriv->cfg->ops->get_desc((u8 *)pdesc, + false, + HW_DESC_OWN); + if (own) /* wait data to be filled by hardware */ + return; + } + + /* If we get here, the data is filled already + * Attention !!! + * We can NOT access 'skb' before 'pci_unmap_single' + */ + pci_unmap_single(rtlpci->pdev, *((dma_addr_t *)skb->cb), + rtlpci->rxbuffersize, PCI_DMA_FROMDEVICE); + + if (rtlpriv->use_new_trx_flow) { + buffer_desc = &rtlpci->rx_ring[rxring_idx].buffer_desc[ + rtlpci->rx_ring[rxring_idx].idx]; + /*means rx wifi info*/ + pdesc = (struct rtl_rx_desc *)skb->data; + } + memset(&rx_status , 0 , sizeof(rx_status)); + rtlpriv->cfg->ops->query_rx_desc(hw, &stats, + &rx_status, (u8 *)pdesc, skb); + + if (rtlpriv->use_new_trx_flow) + rtlpriv->cfg->ops->rx_check_dma_ok(hw, + (u8 *)buffer_desc, + hw_queue); + len = rtlpriv->cfg->ops->get_desc((u8 *)pdesc, false, + HW_DESC_RXPKT_LEN); + + if (skb->end - skb->tail > len) { + skb_put(skb, len); + if (rtlpriv->use_new_trx_flow) + skb_reserve(skb, stats.rx_drvinfo_size + + stats.rx_bufshift + 24); + else + skb_reserve(skb, stats.rx_drvinfo_size + + stats.rx_bufshift); + + } else { + if (err_count++ < 10) { + pr_info("skb->end (%d) - skb->tail (%d) > len (%d)\n", + skb->end, skb->tail, len); + RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_EMERG, + "RX desc\n", + (u8 *)pdesc, 32); + } + break; + } + + /* handle command packet here */ + if (rtlpriv->cfg->ops->rx_command_packet(hw, stats, skb)) { + dev_kfree_skb_any(skb); + goto end; + } + + /* NOTICE This can not be use for mac80211, + *this is done in mac80211 code, + *if you done here sec DHCP will fail + *skb_trim(skb, skb->len - 4); + */ + + hdr = rtl_get_hdr(skb); + fc = rtl_get_fc(skb); + + if (!stats.b_crc && !stats.b_hwerror) + _rtl_receive_one(hw, skb, rx_status); + else + dev_kfree_skb_any(skb); + if (rtlpriv->use_new_trx_flow) { + rtlpci->rx_ring[hw_queue].next_rx_rp += 1; + rtlpci->rx_ring[hw_queue].next_rx_rp %= + RTL_PCI_MAX_RX_COUNT; + + + rx_remained_cnt--; + rtl_write_word(rtlpriv, 0x3B4, + rtlpci->rx_ring[hw_queue].next_rx_rp); + } + if (((rtlpriv->link_info.num_rx_inperiod + + rtlpriv->link_info.num_tx_inperiod) > 8) || + (rtlpriv->link_info.num_rx_inperiod > 2)) { + rtl92e_lps_leave(hw); + } +end: + if (rtlpriv->use_new_trx_flow) { + _rtl_pci_init_one_rxdesc(hw, (u8 *)buffer_desc, + rxring_idx, + rtlpci->rx_ring[rxring_idx].idx); + } else { + _rtl_pci_init_one_rxdesc(hw, (u8 *)pdesc, rxring_idx, + rtlpci->rx_ring[rxring_idx].idx); + + if (rtlpci->rx_ring[rxring_idx].idx == + rtlpci->rxringcount - 1) + rtlpriv->cfg->ops->set_desc(hw, (u8 *)pdesc, + false, + HW_DESC_RXERO, + (u8 *)&tmp_one); + } + rtlpci->rx_ring[rxring_idx].idx = + (rtlpci->rx_ring[rxring_idx].idx + 1) % + rtlpci->rxringcount; + } +} + +static irqreturn_t _rtl_pci_interrupt(int irq, void *dev_id) +{ + struct ieee80211_hw *hw = dev_id; + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + unsigned long flags; + u32 inta = 0; + u32 intb = 0; + + if (rtlpci->irq_enabled == 0) + return IRQ_HANDLED; + + spin_lock_irqsave(&rtlpriv->locks.irq_th_lock , flags); + rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[MAC_HIMR], 0x0); + rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[MAC_HIMRE], 0x0); + + /*read ISR: 4/8bytes */ + rtlpriv->cfg->ops->interrupt_recognized(hw, &inta, &intb); + + /*Shared IRQ or HW disappared */ + if (!inta || inta == 0xffff) + goto done; + /*<1> beacon related */ + if (inta & rtlpriv->cfg->maps[RTL_IMR_TBDOK]) + RT_TRACE(COMP_INTR, DBG_TRACE, ("beacon ok interrupt!\n")); + + if (unlikely(inta & rtlpriv->cfg->maps[RTL_IMR_TBDER])) + RT_TRACE(COMP_INTR, DBG_TRACE, ("beacon err interrupt!\n")); + + if (inta & rtlpriv->cfg->maps[RTL_IMR_BDOK]) + RT_TRACE(COMP_INTR, DBG_TRACE, ("beacon interrupt!\n")); + + if (inta & rtlpriv->cfg->maps[RTL_IMR_BcnInt]) { + RT_TRACE(COMP_INTR, DBG_TRACE, + ("prepare beacon for interrupt!\n")); + tasklet_schedule(&rtlpriv->works.irq_prepare_bcn_tasklet); + } + + /*<2> tx related */ + if (unlikely(intb & rtlpriv->cfg->maps[RTL_IMR_TXFOVW])) + RT_TRACE(COMP_ERR, DBG_TRACE, ("IMR_TXFOVW!\n")); + + if (inta & rtlpriv->cfg->maps[RTL_IMR_MGNTDOK]) { + RT_TRACE(COMP_INTR, DBG_TRACE, ("Manage ok interrupt!\n")); + _rtl_pci_tx_isr(hw, MGNT_QUEUE); + } + + if (inta & rtlpriv->cfg->maps[RTL_IMR_HIGHDOK]) { + RT_TRACE(COMP_INTR, DBG_TRACE, ("HIGH_QUEUE ok interrupt!\n")); + _rtl_pci_tx_isr(hw, HIGH_QUEUE); + } + + if (inta & rtlpriv->cfg->maps[RTL_IMR_BKDOK]) { + rtlpriv->link_info.num_tx_inperiod++; + + RT_TRACE(COMP_INTR, DBG_TRACE, ("BK Tx OK interrupt!\n")); + _rtl_pci_tx_isr(hw, BK_QUEUE); + } + + if (inta & rtlpriv->cfg->maps[RTL_IMR_BEDOK]) { + rtlpriv->link_info.num_tx_inperiod++; + + RT_TRACE(COMP_INTR, DBG_TRACE, ("BE TX OK interrupt!\n")); + _rtl_pci_tx_isr(hw, BE_QUEUE); + } + + if (inta & rtlpriv->cfg->maps[RTL_IMR_VIDOK]) { + rtlpriv->link_info.num_tx_inperiod++; + + RT_TRACE(COMP_INTR, DBG_TRACE, ("VI TX OK interrupt!\n")); + _rtl_pci_tx_isr(hw, VI_QUEUE); + } + + if (inta & rtlpriv->cfg->maps[RTL_IMR_VODOK]) { + rtlpriv->link_info.num_tx_inperiod++; + + RT_TRACE(COMP_INTR, DBG_TRACE, ("Vo TX OK interrupt!\n")); + _rtl_pci_tx_isr(hw, VO_QUEUE); + } + + if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192SE) { + if (inta & rtlpriv->cfg->maps[RTL_IMR_COMDOK]) { + rtlpriv->link_info.num_tx_inperiod++; + + RT_TRACE(COMP_INTR, DBG_TRACE, + ("CMD TX OK interrupt!\n")); + _rtl_pci_tx_isr(hw, TXCMD_QUEUE); + } + } + + /*<3> rx related */ + if (inta & rtlpriv->cfg->maps[RTL_IMR_ROK]) { + RT_TRACE(COMP_INTR, DBG_TRACE, ("Rx ok interrupt!\n")); + _rtl_pci_rx_interrupt(hw); + } + + if (unlikely(inta & rtlpriv->cfg->maps[RTL_IMR_RDU])) { + RT_TRACE(COMP_ERR, DBG_WARNING, + ("rx descriptor unavailable!\n")); + _rtl_pci_rx_interrupt(hw); + } + + if (unlikely(intb & rtlpriv->cfg->maps[RTL_IMR_RXFOVW])) { + RT_TRACE(COMP_ERR, DBG_WARNING, ("rx overflow !\n")); + _rtl_pci_rx_interrupt(hw); + } + + /*<4> fw related*/ + if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723AE) { + if (inta & rtlpriv->cfg->maps[RTL_IMR_C2HCMD]) { + RT_TRACE(COMP_INTR, DBG_TRACE, + ("firmware interrupt!\n")); + queue_delayed_work(rtlpriv->works.rtl_wq, + &rtlpriv->works.fwevt_wq, 0); + } + } + + /*<5> hsisr related*/ + /* Only 8188EE & 8723BE Supported. + * If Other ICs Come in, System will corrupt, + * because maps[RTL_IMR_HSISR_IND] & maps[MAC_HSISR] + * are not initialized*/ + if (rtlhal->hw_type == HARDWARE_TYPE_RTL8188EE || + rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) { + if (unlikely(inta & rtlpriv->cfg->maps[RTL_IMR_HSISR_IND])) { + RT_TRACE(COMP_INTR, DBG_TRACE, + ("hsisr interrupt!\n")); + _rtl_pci_hs_interrupt(hw); + } + } + + + if (rtlpriv->rtlhal.b_earlymode_enable) + tasklet_schedule(&rtlpriv->works.irq_tasklet); + +done: + rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[MAC_HIMR], + rtlpci->irq_mask[0]); + rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[MAC_HIMRE], + rtlpci->irq_mask[1]); + spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags); + return IRQ_HANDLED; +} + +static void _rtl_pci_irq_tasklet(struct ieee80211_hw *hw) +{ + _rtl_pci_tx_chk_waitq(hw); +} + +static void _rtl_pci_prepare_bcn_tasklet(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct rtl8192_tx_ring *ring = NULL; + struct ieee80211_hdr *hdr = NULL; + struct ieee80211_tx_info *info = NULL; + struct sk_buff *pskb = NULL; + struct rtl_tx_desc *pdesc = NULL; + struct rtl_tcb_desc tcb_desc; + /*This is for new trx flow*/ + struct rtl_tx_buffer_desc *pbuffer_desc = NULL; + u8 temp_one = 1; + + memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc)); + ring = &rtlpci->tx_ring[BEACON_QUEUE]; + pskb = __skb_dequeue(&ring->queue); + if (pskb) + kfree_skb(pskb); + + /*NB: the beacon data buffer must be 32-bit aligned. */ + pskb = ieee80211_beacon_get(hw, mac->vif); + if (pskb == NULL) + return; + hdr = rtl_get_hdr(pskb); + info = IEEE80211_SKB_CB(pskb); + pdesc = &ring->desc[0]; + if (rtlpriv->use_new_trx_flow) + pbuffer_desc = &ring->buffer_desc[0]; + + rtlpriv->cfg->ops->fill_tx_desc(hw, hdr, (u8 *)pdesc, + (u8 *)pbuffer_desc, info, NULL, pskb, + BEACON_QUEUE, &tcb_desc); + + __skb_queue_tail(&ring->queue, pskb); + + rtlpriv->cfg->ops->set_desc(hw, (u8 *)pdesc, true, HW_DESC_OWN, + (u8 *)&temp_one); + + return; +} + +static void _rtl_pci_init_trx_var(struct ieee80211_hw *hw) +{ + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtlpriv); + u8 i; + u16 desc_num; + + if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) + desc_num = TX_DESC_NUM_92E; + else + desc_num = RT_TXDESC_NUM; + + for (i = 0; i < RTL_PCI_MAX_TX_QUEUE_COUNT; i++) + rtlpci->txringcount[i] = desc_num; + /* + *we just alloc 2 desc for beacon queue, + *because we just need first desc in hw beacon. + */ + rtlpci->txringcount[BEACON_QUEUE] = 2; + + /* + *BE queue need more descriptor for performance + *consideration or, No more tx desc will happen, + *and may cause mac80211 mem leakage. + */ + if (!rtl_priv(hw)->use_new_trx_flow) + rtlpci->txringcount[BE_QUEUE] = RT_TXDESC_NUM_BE_QUEUE; + + rtlpci->rxbuffersize = 9100; /*2048/1024; */ + rtlpci->rxringcount = RTL_PCI_MAX_RX_COUNT; /*64; */ +} + +static void _rtl_pci_init_struct(struct ieee80211_hw *hw, + struct pci_dev *pdev) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + + rtlpriv->rtlhal.up_first_time = true; + rtlpriv->rtlhal.being_init_adapter = false; + + rtlhal->hw = hw; + rtlpci->pdev = pdev; + + /*Tx/Rx related var */ + _rtl_pci_init_trx_var(hw); + + /*IBSS*/ mac->beacon_interval = 100; + + /*AMPDU*/ + mac->min_space_cfg = 0; + mac->max_mss_density = 0; + /*set sane AMPDU defaults */ + mac->current_ampdu_density = 7; + mac->current_ampdu_factor = 3; + + /*QOS*/ + rtlpci->acm_method = eAcmWay2_SW; + + /*task */ + tasklet_init(&rtlpriv->works.irq_tasklet, + (void (*)(unsigned long))_rtl_pci_irq_tasklet, + (unsigned long)hw); + tasklet_init(&rtlpriv->works.irq_prepare_bcn_tasklet, + (void (*)(unsigned long))_rtl_pci_prepare_bcn_tasklet, + (unsigned long)hw); +} + +static int _rtl_pci_init_tx_ring(struct ieee80211_hw *hw, + unsigned int prio, unsigned int entries) +{ + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_tx_buffer_desc *buffer_desc; + struct rtl_tx_desc *desc; + dma_addr_t buffer_desc_dma, desc_dma; + u32 nextdescaddress; + int i; + + /* alloc tx buffer desc for new trx flow*/ + if (rtlpriv->use_new_trx_flow) { + buffer_desc = pci_alloc_consistent(rtlpci->pdev, + sizeof(*buffer_desc) * entries, + &buffer_desc_dma); + + if (!buffer_desc || (unsigned long)buffer_desc & 0xFF) { + RT_TRACE(COMP_ERR, DBG_EMERG, + ("Cannot allocate TX ring (prio = %d)\n", + prio)); + return -ENOMEM; + } + + memset(buffer_desc, 0, sizeof(*buffer_desc) * entries); + rtlpci->tx_ring[prio].buffer_desc = buffer_desc; + rtlpci->tx_ring[prio].buffer_desc_dma = buffer_desc_dma; + + rtlpci->tx_ring[prio].cur_tx_rp = 0; + rtlpci->tx_ring[prio].cur_tx_wp = 0; + rtlpci->tx_ring[prio].avl_desc = entries; + } + + /* alloc dma for this ring */ + desc = pci_alloc_consistent(rtlpci->pdev, + sizeof(*desc) * entries, &desc_dma); + + if (!desc || (unsigned long)desc & 0xFF) { + RT_TRACE(COMP_ERR, DBG_EMERG, + ("Cannot allocate TX ring (prio = %d)\n", prio)); + return -ENOMEM; + } + + memset(desc, 0, sizeof(*desc) * entries); + rtlpci->tx_ring[prio].desc = desc; + rtlpci->tx_ring[prio].dma = desc_dma; + + rtlpci->tx_ring[prio].idx = 0; + rtlpci->tx_ring[prio].entries = entries; + skb_queue_head_init(&rtlpci->tx_ring[prio].queue); + RT_TRACE(COMP_INIT, DBG_LOUD, + ("queue:%d, ring_addr:%p\n", prio, desc)); + + /* init every desc in this ring */ + if (!rtlpriv->use_new_trx_flow) { + for (i = 0; i < entries; i++) { + nextdescaddress = (u32) desc_dma + + ((i + 1) % entries) * + sizeof(*desc); + + rtlpriv->cfg->ops->set_desc(hw, (u8 *)&(desc[i]), + true, + HW_DESC_TX_NEXTDESC_ADDR, + (u8 *)&nextdescaddress); + } + } + return 0; +} + +static int _rtl_pci_init_rx_ring(struct ieee80211_hw *hw, int rxring_idx) +{ + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + struct rtl_priv *rtlpriv = rtl_priv(hw); + int i; + + if (rtlpriv->use_new_trx_flow) { + struct rtl_rx_buffer_desc *entry = NULL; + /* alloc dma for this ring */ + rtlpci->rx_ring[rxring_idx].buffer_desc = + pci_alloc_consistent(rtlpci->pdev, + sizeof(*rtlpci->rx_ring[rxring_idx]. + buffer_desc) * + rtlpci->rxringcount, + &rtlpci->rx_ring[rxring_idx].dma); + if (!rtlpci->rx_ring[rxring_idx].buffer_desc || + (unsigned long)rtlpci->rx_ring[rxring_idx].buffer_desc & 0xFF) { + RT_TRACE(COMP_ERR, DBG_EMERG, + ("Cannot allocate RX ring\n")); + return -ENOMEM; + } + + memset(rtlpci->rx_ring[rxring_idx].buffer_desc, 0, + sizeof(*rtlpci->rx_ring[rxring_idx].buffer_desc) * + rtlpci->rxringcount); + + /* init every desc in this ring */ + rtlpci->rx_ring[rxring_idx].idx = 0; + + for (i = 0; i < rtlpci->rxringcount; i++) { + entry = &rtlpci->rx_ring[rxring_idx].buffer_desc[i]; + if (!_rtl_pci_init_one_rxdesc(hw, (u8 *)entry, + rxring_idx, i)) + return -ENOMEM; + } + } else { + struct rtl_rx_desc *entry = NULL; + u8 tmp_one = 1; + /* alloc dma for this ring */ + rtlpci->rx_ring[rxring_idx].desc = + pci_alloc_consistent(rtlpci->pdev, + sizeof(*rtlpci->rx_ring[rxring_idx]. + desc) * rtlpci->rxringcount, + &rtlpci->rx_ring[rxring_idx].dma); + if (!rtlpci->rx_ring[rxring_idx].desc || + (unsigned long)rtlpci->rx_ring[rxring_idx].desc & 0xFF) { + RT_TRACE(COMP_ERR, DBG_EMERG, + ("Cannot allocate RX ring\n")); + return -ENOMEM; + } + memset(rtlpci->rx_ring[rxring_idx].desc, 0, + sizeof(*rtlpci->rx_ring[rxring_idx].desc) * + rtlpci->rxringcount); + + /* init every desc in this ring */ + rtlpci->rx_ring[rxring_idx].idx = 0; + for (i = 0; i < rtlpci->rxringcount; i++) { + entry = &rtlpci->rx_ring[rxring_idx].desc[i]; + if (!_rtl_pci_init_one_rxdesc(hw, (u8 *)entry, + rxring_idx, i)) + return -ENOMEM; + } + rtlpriv->cfg->ops->set_desc(hw, (u8 *)entry, false, + HW_DESC_RXERO, (u8 *) &tmp_one); + } + return 0; +} + +static void _rtl_pci_free_tx_ring(struct ieee80211_hw *hw, + unsigned int prio) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[prio]; + + /* free every desc in this ring */ + while (skb_queue_len(&ring->queue)) { + struct sk_buff *skb = __skb_dequeue(&ring->queue); + u8 *entry; + + if (rtlpriv->use_new_trx_flow) + entry = (u8 *)(&ring->buffer_desc[ring->idx]); + else + entry = (u8 *)(&ring->desc[ring->idx]); + + pci_unmap_single(rtlpci->pdev, + rtlpriv->cfg->ops->get_desc((u8 *)entry, true, + HW_DESC_TXBUFF_ADDR), + skb->len, PCI_DMA_TODEVICE); + kfree_skb(skb); + ring->idx = (ring->idx + 1) % ring->entries; + } + + /* free dma of this ring */ + pci_free_consistent(rtlpci->pdev, + sizeof(*ring->desc) * ring->entries, + ring->desc, ring->dma); + ring->desc = NULL; + if (rtlpriv->use_new_trx_flow) { + pci_free_consistent(rtlpci->pdev, + sizeof(*ring->buffer_desc) * ring->entries, + ring->buffer_desc, ring->buffer_desc_dma); + ring->buffer_desc = NULL; + } +} + +static void _rtl_pci_free_rx_ring(struct ieee80211_hw *hw, int rxring_idx) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + int i; + + /* free every desc in this ring */ + for (i = 0; i < rtlpci->rxringcount; i++) { + struct sk_buff *skb = rtlpci->rx_ring[rxring_idx].rx_buf[i]; + + if (!skb) + continue; + + pci_unmap_single(rtlpci->pdev, *((dma_addr_t *)skb->cb), + rtlpci->rxbuffersize, PCI_DMA_FROMDEVICE); + kfree_skb(skb); + } + + /* free dma of this ring */ + if (rtlpriv->use_new_trx_flow) { + pci_free_consistent(rtlpci->pdev, + sizeof(*rtlpci->rx_ring[rxring_idx]. + buffer_desc) * rtlpci->rxringcount, + rtlpci->rx_ring[rxring_idx].buffer_desc, + rtlpci->rx_ring[rxring_idx].dma); + rtlpci->rx_ring[rxring_idx].buffer_desc = NULL; + } else { + pci_free_consistent(rtlpci->pdev, + sizeof(*rtlpci->rx_ring[rxring_idx].desc) * + rtlpci->rxringcount, + rtlpci->rx_ring[rxring_idx].desc, + rtlpci->rx_ring[rxring_idx].dma); + rtlpci->rx_ring[rxring_idx].desc = NULL; + } +} + +static int _rtl_pci_init_trx_ring(struct ieee80211_hw *hw) +{ + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + int ret; + int i, rxring_idx; + + /* rxring_idx 0:RX_MPDU_QUEUE + * rxring_idx 1:RX_CMD_QUEUE */ + for (rxring_idx = 0; rxring_idx < RTL_PCI_MAX_RX_QUEUE; rxring_idx++) { + ret = _rtl_pci_init_rx_ring(hw, rxring_idx); + if (ret) + return ret; + } + + for (i = 0; i < RTL_PCI_MAX_TX_QUEUE_COUNT; i++) { + ret = _rtl_pci_init_tx_ring(hw, i, + rtlpci->txringcount[i]); + if (ret) + goto err_free_rings; + } + + return 0; + +err_free_rings: + for (rxring_idx = 0; rxring_idx < RTL_PCI_MAX_RX_QUEUE; rxring_idx++) + _rtl_pci_free_rx_ring(hw, rxring_idx); + + for (i = 0; i < RTL_PCI_MAX_TX_QUEUE_COUNT; i++) + if (rtlpci->tx_ring[i].desc || + rtlpci->tx_ring[i].buffer_desc) + _rtl_pci_free_tx_ring(hw, i); + + return 1; +} + +static int _rtl_pci_deinit_trx_ring(struct ieee80211_hw *hw) +{ + u32 i, rxring_idx; + + /*free rx rings */ + for (rxring_idx = 0; rxring_idx < RTL_PCI_MAX_RX_QUEUE; rxring_idx++) + _rtl_pci_free_rx_ring(hw, rxring_idx); + + /*free tx rings */ + for (i = 0; i < RTL_PCI_MAX_TX_QUEUE_COUNT; i++) + _rtl_pci_free_tx_ring(hw, i); + + return 0; +} + +int rtl92e_pci_reset_trx_ring(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + int i, rxring_idx; + unsigned long flags; + u8 tmp_one = 1; + /* rxring_idx 0:RX_MPDU_QUEUE */ + /* rxring_idx 1:RX_CMD_QUEUE */ + for (rxring_idx = 0; rxring_idx < RTL_PCI_MAX_RX_QUEUE; rxring_idx++) { + /* force the rx_ring[RX_MPDU_QUEUE] + * RX_CMD_QUEUE].idx to the first one + * If using the new trx flow, do nothing + */ + if (!rtlpriv->use_new_trx_flow && + rtlpci->rx_ring[rxring_idx].desc) { + struct rtl_rx_desc *entry = NULL; + + for (i = 0; i < rtlpci->rxringcount; i++) { + entry = &rtlpci->rx_ring[rxring_idx].desc[i]; + rtlpriv->cfg->ops->set_desc(hw, (u8 *)entry, + false, + HW_DESC_RXOWN, + &tmp_one); + } + } + rtlpci->rx_ring[rxring_idx].idx = 0; + } + + /* after reset, release previous pending packet, + * and force the tx idx to the first one + */ + spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags); + for (i = 0; i < RTL_PCI_MAX_TX_QUEUE_COUNT; i++) { + if (rtlpci->tx_ring[i].desc || + rtlpci->tx_ring[i].buffer_desc) { + struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[i]; + + while (skb_queue_len(&ring->queue)) { + struct sk_buff *skb = + __skb_dequeue(&ring->queue); + u8 *entry; + + if (rtlpriv->use_new_trx_flow) + entry = (u8 *)(&ring->buffer_desc + [ring->idx]); + else + entry = (u8 *)(&ring->desc[ring->idx]); + + pci_unmap_single(rtlpci->pdev, + rtlpriv->cfg->ops->get_desc( + (u8 *)entry, true, + HW_DESC_TXBUFF_ADDR), + skb->len, PCI_DMA_TODEVICE); + kfree_skb(skb); + ring->idx = (ring->idx + 1) % ring->entries; + } + ring->idx = 0; + } + } + + spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags); + + return 0; +} + +static bool rtl_pci_tx_chk_waitq_insert(struct ieee80211_hw *hw, + struct ieee80211_sta *sta, + struct sk_buff *skb) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_sta_info *sta_entry = NULL; + u8 tid = rtl_get_tid(skb); + __le16 fc = rtl_get_fc(skb); + + if (!sta) + return false; + sta_entry = (struct rtl_sta_info *)sta->drv_priv; + + if (!rtlpriv->rtlhal.b_earlymode_enable) + return false; + if (ieee80211_is_nullfunc(fc)) + return false; + if (ieee80211_is_qos_nullfunc(fc)) + return false; + if (ieee80211_is_pspoll(fc)) + return false; + + if (sta_entry->tids[tid].agg.agg_state != RTL_AGG_OPERATIONAL) + return false; + if (_rtl_mac_to_hwqueue(hw, skb) > VO_QUEUE) + return false; + if (tid > 7) + return false; + /* maybe every tid should be checked */ + if (!rtlpriv->link_info.higher_busytxtraffic[tid]) + return false; + + spin_lock_bh(&rtlpriv->locks.waitq_lock); + skb_queue_tail(&rtlpriv->mac80211.skb_waitq[tid], skb); + spin_unlock_bh(&rtlpriv->locks.waitq_lock); + + return true; +} + +static int rtl_pci_tx(struct ieee80211_hw *hw, + struct ieee80211_sta *sta, + struct sk_buff *skb, + struct rtl_tcb_desc *ptcb_desc) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_sta_info *sta_entry = NULL; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct rtl8192_tx_ring *ring; + struct rtl_tx_desc *pdesc; + struct rtl_tx_buffer_desc *ptx_bd_desc = NULL; + u16 idx; + u8 own; + u8 temp_one = 1; + u8 hw_queue = _rtl_mac_to_hwqueue(hw, skb); + unsigned long flags; + struct ieee80211_hdr *hdr = rtl_get_hdr(skb); + __le16 fc = rtl_get_fc(skb); + u8 *pda_addr = hdr->addr1; + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + /*ssn */ + u8 tid = 0; + u16 seq_number = 0; + + if (ieee80211_is_mgmt(fc)) + rtl92e_tx_mgmt_proc(hw, skb); + + if (rtlpriv->psc.sw_ps_enabled) { + if (ieee80211_is_data(fc) && !ieee80211_is_nullfunc(fc) && + !ieee80211_has_pm(fc)) + hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); + } + + rtl92e_action_proc(hw, skb, true); + + if (is_multicast_ether_addr(pda_addr)) + rtlpriv->stats.txbytesmulticast += skb->len; + else if (is_broadcast_ether_addr(pda_addr)) + rtlpriv->stats.txbytesbroadcast += skb->len; + else + rtlpriv->stats.txbytesunicast += skb->len; + + spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags); + ring = &rtlpci->tx_ring[hw_queue]; + if (hw_queue != BEACON_QUEUE) { + if (rtlpriv->use_new_trx_flow) + idx = ring->cur_tx_wp; + else + idx = (ring->idx + skb_queue_len(&ring->queue)) % + ring->entries; + } else { + idx = 0; + } + + pdesc = &ring->desc[idx]; + + if (rtlpriv->use_new_trx_flow) { + ptx_bd_desc = &ring->buffer_desc[idx]; + } else { + own = (u8) rtlpriv->cfg->ops->get_desc((u8 *)pdesc, + true, HW_DESC_OWN); + + if ((own == 1) && (hw_queue != BEACON_QUEUE)) { + RT_TRACE(COMP_ERR, DBG_WARNING, + ("No more TX desc@%d, ring->idx = %d, idx = %d, skb_queue_len = 0x%d\n", + hw_queue, ring->idx, idx, + skb_queue_len(&ring->queue))); + + spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, + flags); + return skb->len; + } + } + + if (ieee80211_is_data_qos(fc)) { + tid = rtl_get_tid(skb); + if (sta) { + sta_entry = (struct rtl_sta_info *)sta->drv_priv; + seq_number = (le16_to_cpu(hdr->seq_ctrl) & + IEEE80211_SCTL_SEQ) >> 4; + seq_number += 1; + + if (!ieee80211_has_morefrags(hdr->frame_control)) + sta_entry->tids[tid].seq_number = seq_number; + } + } + + if (ieee80211_is_data(fc)) + rtlpriv->cfg->ops->led_control(hw, LED_CTL_TX); + + rtlpriv->cfg->ops->fill_tx_desc(hw, hdr, (u8 *)pdesc, + (u8 *)ptx_bd_desc, info, sta, skb, + hw_queue, ptcb_desc); + + __skb_queue_tail(&ring->queue, skb); + if (rtlpriv->use_new_trx_flow) { + rtlpriv->cfg->ops->set_desc(hw, (u8 *)pdesc, true, + HW_DESC_OWN, (u8 *)&hw_queue); + } else { + rtlpriv->cfg->ops->set_desc(hw, (u8 *)pdesc, true, + HW_DESC_OWN, (u8 *)&temp_one); + } + + if ((ring->entries - skb_queue_len(&ring->queue)) < 2 && + hw_queue != BEACON_QUEUE) { + RT_TRACE(COMP_ERR, DBG_LOUD, + ("less desc left, stop skb_queue@%d, ring->idx = %d, idx = %d, skb_queue_len = 0x%d\n", + hw_queue, ring->idx, idx, + skb_queue_len(&ring->queue))); + + ieee80211_stop_queue(hw, skb_get_queue_mapping(skb)); + } + + spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags); + + if (rtlpriv->cfg->ops->tx_polling) + rtlpriv->cfg->ops->tx_polling(hw, hw_queue); + + return 0; +} +static void rtl_pci_flush(struct ieee80211_hw *hw, u32 queues, bool drop) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + u16 i = 0; + int queue_id; + struct rtl8192_tx_ring *ring; + + if (mac->skip_scan) + return; + + for (queue_id = RTL_PCI_MAX_TX_QUEUE_COUNT - 1; queue_id >= 0;) { + u32 queue_len; + if (((queues >> queue_id) & 0x1) == 0) { + queue_id--; + continue; + } + ring = &pcipriv->dev.tx_ring[queue_id]; + queue_len = skb_queue_len(&ring->queue); + if (queue_len == 0 || queue_id == BEACON_QUEUE || + queue_id == TXCMD_QUEUE) { + queue_id--; + continue; + } else { + msleep(5); + i++; + } + + /* we just wait 1s for all queues */ + if (rtlpriv->psc.rfpwr_state == ERFOFF || + is_hal_stop(rtlhal) || i >= 200) + return; + } +} + +static void rtl_pci_deinit(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + + _rtl_pci_deinit_trx_ring(hw); + + synchronize_irq(rtlpci->pdev->irq); + tasklet_kill(&rtlpriv->works.irq_tasklet); + + flush_workqueue(rtlpriv->works.rtl_wq); + destroy_workqueue(rtlpriv->works.rtl_wq); +} + +static int rtl_pci_init(struct ieee80211_hw *hw, struct pci_dev *pdev) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + int err; + + _rtl_pci_init_struct(hw, pdev); + + err = _rtl_pci_init_trx_ring(hw); + if (err) { + RT_TRACE(COMP_ERR, DBG_EMERG, + ("tx ring initialization failed")); + return err; + } + + return 1; +} + +static int rtl_pci_start(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + int err = 0; + + RT_TRACE(COMP_INIT, DBG_DMESG, (" rtl_pci_start\n")); + rtl92e_pci_reset_trx_ring(hw); + + rtlpriv->rtlhal.driver_is_goingto_unload = false; + if (rtlpriv->cfg->ops->get_btc_status()) { + rtlpriv->btcoexist.btc_ops->btc_init_variables(rtlpriv); + rtlpriv->btcoexist.btc_ops->btc_init_hal_vars(rtlpriv); + } + + err = rtlpriv->cfg->ops->hw_init(hw); + if (err) { + RT_TRACE(COMP_INIT, DBG_DMESG, + ("Failed to config hardware err %x!\n" , err)); + return err; + } + + rtlpriv->cfg->ops->enable_interrupt(hw); + RT_TRACE(COMP_INIT, DBG_LOUD, ("enable_interrupt OK\n")); + + rtl92e_init_rx_config(hw); + + /*should after adapter start and interrupt enable. */ + set_hal_start(rtlhal); + + RT_CLEAR_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC); + + rtlpriv->rtlhal.up_first_time = false; + + RT_TRACE(COMP_INIT, DBG_DMESG, ("rtl_pci_start OK\n")); + return 0; +} + +static void rtl_pci_stop(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + u8 RFInProgressTimeOut = 0; + + if (rtlpriv->cfg->ops->get_btc_status()) + rtlpriv->btcoexist.btc_ops->btc_halt_notify(); + + /* + *should before disable interrrupt&adapter + *and will do it immediately. + */ + set_hal_stop(rtlhal); + + rtlpriv->cfg->ops->disable_interrupt(hw); + + spin_lock(&rtlpriv->locks.rf_ps_lock); + while (ppsc->rfchange_inprogress) { + spin_unlock(&rtlpriv->locks.rf_ps_lock); + if (RFInProgressTimeOut > 100) { + spin_lock(&rtlpriv->locks.rf_ps_lock); + break; + } + mdelay(1); + RFInProgressTimeOut++; + spin_lock(&rtlpriv->locks.rf_ps_lock); + } + ppsc->rfchange_inprogress = true; + spin_unlock(&rtlpriv->locks.rf_ps_lock); + + rtlpriv->rtlhal.driver_is_goingto_unload = true; + rtlpriv->cfg->ops->hw_disable(hw); + rtlpriv->cfg->ops->led_control(hw, LED_CTL_POWER_OFF); + + spin_lock(&rtlpriv->locks.rf_ps_lock); + ppsc->rfchange_inprogress = false; + spin_unlock(&rtlpriv->locks.rf_ps_lock); + + rtl_pci_enable_aspm(hw); +} + +static bool _rtl_pci_find_adapter(struct pci_dev *pdev, + struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + struct pci_dev *bridge_pdev = pdev->bus->self; + u16 venderid; + u16 deviceid; + u8 revisionid; + u16 irqline; + u8 tmp; + + venderid = pdev->vendor; + deviceid = pdev->device; + pci_read_config_byte(pdev, 0x8, &revisionid); + pci_read_config_word(pdev, 0x3C, &irqline); + + if (deviceid == RTL_PCI_8192_DID || + deviceid == RTL_PCI_0044_DID || + deviceid == RTL_PCI_0047_DID || + deviceid == RTL_PCI_8192SE_DID || + deviceid == RTL_PCI_8174_DID || + deviceid == RTL_PCI_8173_DID || + deviceid == RTL_PCI_8172_DID || + deviceid == RTL_PCI_8171_DID) { + switch (revisionid) { + case RTL_PCI_REVISION_ID_8192PCIE: + RT_TRACE(COMP_INIT, DBG_DMESG, + ("8192E is found but not supported now-vid/did=%x/%x\n", + venderid, deviceid)); + rtlhal->hw_type = HARDWARE_TYPE_RTL8192E; + return false; + break; + case RTL_PCI_REVISION_ID_8192SE: + RT_TRACE(COMP_INIT, DBG_DMESG, + ("8192SE is found - vid/did=%x/%x\n", + venderid, deviceid)); + rtlhal->hw_type = HARDWARE_TYPE_RTL8192SE; + break; + default: + RT_TRACE(COMP_ERR, DBG_WARNING, + ("Err: Unknown device - vid/did=%x/%x\n", + venderid, deviceid)); + rtlhal->hw_type = HARDWARE_TYPE_RTL8192SE; + break; + } + } else if (deviceid == RTL_PCI_8723AE_DID) { + rtlhal->hw_type = HARDWARE_TYPE_RTL8723AE; + RT_TRACE(COMP_INIT, DBG_DMESG, + ("8723AE PCI-E is found - vid/did=%x/%x\n", + venderid, deviceid)); + } else if (deviceid == RTL_PCI_8192CET_DID || + deviceid == RTL_PCI_8192CE_DID || + deviceid == RTL_PCI_8191CE_DID || + deviceid == RTL_PCI_8188CE_DID) { + rtlhal->hw_type = HARDWARE_TYPE_RTL8192CE; + RT_TRACE(COMP_INIT, DBG_DMESG, + ("8192C PCI-E is found - vid/did=%x/%x\n", + venderid, deviceid)); + } else if (deviceid == RTL_PCI_8192DE_DID || + deviceid == RTL_PCI_8192DE_DID2) { + rtlhal->hw_type = HARDWARE_TYPE_RTL8192DE; + RT_TRACE(COMP_INIT, DBG_DMESG, + ("8192D PCI-E is found - vid/did=%x/%x\n", + venderid, deviceid)); + } else if (deviceid == RTL_PCI_8188EE_DID) { + rtlhal->hw_type = HARDWARE_TYPE_RTL8188EE; + RT_TRACE(COMP_INIT , DBG_LOUD, + ("Find adapter, Hardware type is 8188EE\n")); + } else if (deviceid == RTL_PCI_8723BE_DID) { + rtlhal->hw_type = HARDWARE_TYPE_RTL8723BE; + RT_TRACE(COMP_INIT , DBG_LOUD, + ("Find adapter, Hardware type is 8723BE\n")); + } else if (deviceid == RTL_PCI_8192EE_DID) { + rtlhal->hw_type = HARDWARE_TYPE_RTL8192EE; + RT_TRACE(COMP_INIT , DBG_LOUD, + ("Find adapter, Hardware type is 8192EE\n")); + } else if (deviceid == RTL_PCI_8821AE_DID) { + rtlhal->hw_type = HARDWARE_TYPE_RTL8821AE; + RT_TRACE(COMP_INIT , DBG_LOUD, + ("Find adapter, Hardware type is 8821AE\n")); + } else if (deviceid == RTL_PCI_8812AE_DID) { + rtlhal->hw_type = HARDWARE_TYPE_RTL8812AE; + RT_TRACE(COMP_INIT , DBG_LOUD, + ("Find adapter, Hardware type is 8812AE\n")); + } else { + RT_TRACE(COMP_ERR, DBG_WARNING, + ("Err: Unknown device - vid/did=%x/%x\n", + venderid, deviceid)); + + rtlhal->hw_type = RTL_DEFAULT_HARDWARE_TYPE; + } + + if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192DE) { + if (revisionid == 0 || revisionid == 1) { + if (revisionid == 0) { + RT_TRACE(COMP_INIT, DBG_LOUD, + ("Find 92DE MAC0.\n")); + rtlhal->interfaceindex = 0; + } else if (revisionid == 1) { + RT_TRACE(COMP_INIT, DBG_LOUD, + ("Find 92DE MAC1.\n")); + rtlhal->interfaceindex = 1; + } + } else { + RT_TRACE(COMP_INIT, DBG_LOUD, + ("Unknown device - VendorID/DeviceID=%x/%x, Revision=%x\n", + venderid, deviceid, revisionid)); + rtlhal->interfaceindex = 0; + } + } + + /* 92ee use new trx flow */ + if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) + rtlpriv->use_new_trx_flow = true; + else + rtlpriv->use_new_trx_flow = false; + + /*find bus info */ + pcipriv->ndis_adapter.busnumber = pdev->bus->number; + pcipriv->ndis_adapter.devnumber = PCI_SLOT(pdev->devfn); + pcipriv->ndis_adapter.funcnumber = PCI_FUNC(pdev->devfn); + + /*find bridge info */ + pcipriv->ndis_adapter.pcibridge_vendor = PCI_BRIDGE_VENDOR_UNKNOWN; + /* some ARM have no bridge_pdev and will crash here + * so we should check if bridge_pdev is NULL */ + if (bridge_pdev) { + pcipriv->ndis_adapter.pcibridge_vendorid = bridge_pdev->vendor; + for (tmp = 0; tmp < PCI_BRIDGE_VENDOR_MAX; tmp++) { + if (bridge_pdev->vendor == pcibridge_vendors[tmp]) { + pcipriv->ndis_adapter.pcibridge_vendor = tmp; + RT_TRACE(COMP_INIT, DBG_DMESG, + ("Pci Bridge Vendor is found index: %d\n", + tmp)); + break; + } + } + } + + if (pcipriv->ndis_adapter.pcibridge_vendor != + PCI_BRIDGE_VENDOR_UNKNOWN) { + pcipriv->ndis_adapter.pcibridge_busnum = + bridge_pdev->bus->number; + pcipriv->ndis_adapter.pcibridge_devnum = + PCI_SLOT(bridge_pdev->devfn); + pcipriv->ndis_adapter.pcibridge_funcnum = + PCI_FUNC(bridge_pdev->devfn); + pcipriv->ndis_adapter.pcicfg_addrport = + (pcipriv->ndis_adapter.pcibridge_busnum << 16) | + (pcipriv->ndis_adapter.pcibridge_devnum << 11) | + (pcipriv->ndis_adapter.pcibridge_funcnum << 8) | (1 << 31); + pcipriv->ndis_adapter.pcibridge_pciehdr_offset = + pci_pcie_cap(bridge_pdev); + pcipriv->ndis_adapter.num4bytes = + (pcipriv->ndis_adapter.pcibridge_pciehdr_offset + 0x10) / 4; + + rtl_pci_get_linkcontrol_field(hw); + + if (pcipriv->ndis_adapter.pcibridge_vendor == + PCI_BRIDGE_VENDOR_AMD) { + pcipriv->ndis_adapter.amd_l1_patch = + rtl_pci_get_amd_l1_patch(hw); + } + } + + RT_TRACE(COMP_INIT, DBG_DMESG, + ("pcidev busnumber:devnumber:funcnumber:vendor:link_ctl %d:%d:%d:%x:%x\n", + pcipriv->ndis_adapter.busnumber, + pcipriv->ndis_adapter.devnumber, + pcipriv->ndis_adapter.funcnumber, + pdev->vendor, pcipriv->ndis_adapter.linkctrl_reg)); + + RT_TRACE(COMP_INIT, DBG_DMESG, + ("pci_bridge busnumber:devnumber:funcnumber:vendor:pcie_cap:link_ctl_reg:amd %d:%d:%d:%x:%x:%x:%x\n", + pcipriv->ndis_adapter.pcibridge_busnum, + pcipriv->ndis_adapter.pcibridge_devnum, + pcipriv->ndis_adapter.pcibridge_funcnum, + pcibridge_vendors[pcipriv->ndis_adapter.pcibridge_vendor], + pcipriv->ndis_adapter.pcibridge_pciehdr_offset, + pcipriv->ndis_adapter.pcibridge_linkctrlreg, + pcipriv->ndis_adapter.amd_l1_patch)); + + rtl_pci_parse_configuration(pdev, hw); + list_add_tail(&rtlpriv->list, &rtlpriv->glb_var->glb_priv_list); + return true; +} + +static int rtl_pci_intr_mode_msi(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(pcipriv); + int ret; + ret = pci_enable_msi(rtlpci->pdev); + if (ret < 0) + return ret; + + ret = request_irq(rtlpci->pdev->irq, &_rtl_pci_interrupt, + IRQF_SHARED, KBUILD_MODNAME, hw); + if (ret < 0) { + pci_disable_msi(rtlpci->pdev); + return ret; + } + + rtlpci->using_msi = true; + + RT_TRACE(COMP_INIT|COMP_INTR, DBG_DMESG, ("MSI Interrupt Mode!\n")); + return 0; +} + +static int rtl_pci_intr_mode_legacy(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(pcipriv); + int ret; + + ret = request_irq(rtlpci->pdev->irq, &_rtl_pci_interrupt, + IRQF_SHARED, KBUILD_MODNAME, hw); + if (ret < 0) + return ret; + + rtlpci->using_msi = false; + RT_TRACE(COMP_INIT|COMP_INTR, DBG_DMESG, + ("Pin-based Interrupt Mode!\n")); + return 0; +} + +static int rtl_pci_intr_mode_decide(struct ieee80211_hw *hw) +{ + struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(pcipriv); + int ret; + if (rtlpci->msi_support) { + ret = rtl_pci_intr_mode_msi(hw); + if (ret < 0) + ret = rtl_pci_intr_mode_legacy(hw); + } else { + ret = rtl_pci_intr_mode_legacy(hw); + } + return ret; +} + +/* this is used for other modules get + * hw pointer in rtl_pci_get_hw_pointer */ +static struct ieee80211_hw *hw_export; + +int stg_rtl_pci_probe(struct pci_dev *pdev, + const struct pci_device_id *id) +{ + struct ieee80211_hw *hw = NULL; + struct rtl_priv *rtlpriv = NULL; + struct rtl_pci_priv *pcipriv = NULL; + struct rtl_pci *rtlpci; + unsigned long pmem_start, pmem_len, pmem_flags; + int err; + + err = pci_enable_device(pdev); + if (err) { + RT_ASSERT(false, + ("%s : Cannot enable new PCI device\n", + pci_name(pdev))); + return err; + } + + if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { + if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) { + RT_ASSERT(false, + ("Unable to obtain 32bit DMA for consistent allocations\n")); + pci_disable_device(pdev); + return -ENOMEM; + } + } + + pci_set_master(pdev); + + hw = ieee80211_alloc_hw(sizeof(struct rtl_pci_priv) + + sizeof(struct rtl_priv), &rtl92e_ops); + if (!hw) { + RT_ASSERT(false, + ("%s : ieee80211 alloc failed\n", pci_name(pdev))); + err = -ENOMEM; + goto fail1; + } + hw_export = hw; + + SET_IEEE80211_DEV(hw, &pdev->dev); + pci_set_drvdata(pdev, hw); + + rtlpriv = hw->priv; + pcipriv = (void *)rtlpriv->priv; + pcipriv->dev.pdev = pdev; + + /* init cfg & intf_ops */ + rtlpriv->rtlhal.interface = INTF_PCI; + rtlpriv->cfg = (struct rtl_hal_cfg *)(id->driver_data); + rtlpriv->intf_ops = &rtl92e_pci_ops; + rtlpriv->glb_var = &global_var; + + /* + *init dbgp flags before all + *other functions, because we will + *use it in other funtions like + *RT_TRACE/RT_PRINT/RTL_PRINT_DATA + *you can not use these macro + *before this + */ + rtl92e_dbgp_flag_init(hw); + + /* MEM map */ + err = pci_request_regions(pdev, KBUILD_MODNAME); + if (err) { + RT_ASSERT(false, ("Can't obtain PCI resources\n")); + return err; + } + + pmem_start = pci_resource_start(pdev, rtlpriv->cfg->bar_id); + pmem_len = pci_resource_len(pdev, rtlpriv->cfg->bar_id); + pmem_flags = pci_resource_flags(pdev, rtlpriv->cfg->bar_id); + + /*shared mem start */ + rtlpriv->io.pci_mem_start = + (unsigned long)pci_iomap(pdev, + rtlpriv->cfg->bar_id, pmem_len); + if (rtlpriv->io.pci_mem_start == 0) { + RT_ASSERT(false, ("Can't map PCI mem\n")); + goto fail2; + } + + RT_TRACE(COMP_INIT, DBG_DMESG, + ("mem mapped space: start: 0x%08lx len:%08lx flags:%08lx, after map:0x%08lx\n", + pmem_start, pmem_len, pmem_flags, + rtlpriv->io.pci_mem_start)); + + /* Disable Clk Request */ + pci_write_config_byte(pdev, 0x81, 0); + /* leave D3 mode */ + pci_write_config_byte(pdev, 0x44, 0); + pci_write_config_byte(pdev, 0x04, 0x06); + pci_write_config_byte(pdev, 0x04, 0x07); + + /* The next statement is needed when built as single module */ + rtl_core_module_init(); + + /* find adapter */ + /* if chip not support, will return false */ + if (!_rtl_pci_find_adapter(pdev, hw)) + goto fail3; + + /* Init IO handler */ + _rtl_pci_io_handler_init(&pdev->dev, hw); + + /*like read eeprom and so on */ + rtlpriv->cfg->ops->read_eeprom_info(hw); + + if (rtlpriv->cfg->ops->init_sw_vars(hw)) { + RT_TRACE(COMP_ERR, DBG_EMERG, ("Can't init_sw_vars.\n")); + goto fail3; + } + + rtlpriv->cfg->ops->init_sw_leds(hw); + + /*aspm */ + rtl_pci_init_aspm(hw); + + /* Init mac80211 sw */ + err = rtl92e_init_core(hw); + if (err) { + RT_TRACE(COMP_ERR, DBG_EMERG, + ("Can't allocate sw for mac80211.\n")); + goto fail3; + } + + /* Init PCI sw */ + err = !rtl_pci_init(hw, pdev); + if (err) { + RT_TRACE(COMP_ERR, DBG_EMERG, ("Failed to init PCI.\n")); + goto fail3; + } + + err = ieee80211_register_hw(hw); + if (err) { + RT_TRACE(COMP_ERR, DBG_EMERG, + ("Can't register mac80211 hw.\n")); + goto fail3; + } else { + rtlpriv->mac80211.mac80211_registered = 1; + } + /* the wiphy must have been registed to + * cfg80211 prior to regulatory_hint */ + if (regulatory_hint(hw->wiphy, rtlpriv->regd.alpha2)) + RT_TRACE(COMP_ERR, DBG_WARNING, ("regulatory_hint fail\n")); + + /* add for prov */ + rtl_proc_add_one(hw); + + /*init rfkill */ + rtl92e_init_rfkill(hw); + + rtlpci = rtl_pcidev(pcipriv); + err = rtl_pci_intr_mode_decide(hw); + if (err) { + RT_TRACE(COMP_INIT, DBG_DMESG, + ("%s: failed to register IRQ handler\n", + wiphy_name(hw->wiphy))); + goto fail3; + } else { + rtlpci->irq_alloc = 1; + } + + set_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status); + return 0; + +fail3: + pci_set_drvdata(pdev, NULL); + rtl92e_deinit_core(hw); + ieee80211_free_hw(hw); + + if (rtlpriv->io.pci_mem_start != 0) + pci_iounmap(pdev, (void __iomem *)rtlpriv->io.pci_mem_start); + +fail2: + pci_release_regions(pdev); + +fail1: + + pci_disable_device(pdev); + + return -ENODEV; +} +EXPORT_SYMBOL(stg_rtl_pci_probe); + +struct ieee80211_hw *rtl_pci_get_hw_pointer(void) +{ + return hw_export; +} +EXPORT_SYMBOL(rtl_pci_get_hw_pointer); + +void stg_rtl_pci_disconnect(struct pci_dev *pdev) +{ + struct ieee80211_hw *hw = pci_get_drvdata(pdev); + struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(pcipriv); + struct rtl_mac *rtlmac = rtl_mac(rtlpriv); + + clear_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status); + + /* add for prov */ + rtl_proc_remove_one(hw); + + /*ieee80211_unregister_hw will call ops_stop */ + if (rtlmac->mac80211_registered == 1) { + ieee80211_unregister_hw(hw); + rtlmac->mac80211_registered = 0; + } else { + rtl92e_deinit_deferred_work(hw); + rtlpriv->intf_ops->adapter_stop(hw); + } + + /*deinit rfkill */ + rtl92e_deinit_rfkill(hw); + + rtl_pci_deinit(hw); + rtl92e_deinit_core(hw); + rtlpriv->cfg->ops->deinit_sw_vars(hw); + + if (rtlpci->irq_alloc) { + synchronize_irq(rtlpci->pdev->irq); + free_irq(rtlpci->pdev->irq, hw); + rtlpci->irq_alloc = 0; + } + + if (rtlpci->using_msi) + pci_disable_msi(rtlpci->pdev); + + list_del(&rtlpriv->list); + if (rtlpriv->io.pci_mem_start != 0) { + pci_iounmap(pdev, (void __iomem *)rtlpriv->io.pci_mem_start); + pci_release_regions(pdev); + } + + pci_disable_device(pdev); + + rtl_pci_disable_aspm(hw); + + pci_set_drvdata(pdev, NULL); + + ieee80211_free_hw(hw); +} +EXPORT_SYMBOL(stg_rtl_pci_disconnect); + +/*************************************** +kernel pci power state define: +PCI_D0 ((pci_power_t __force) 0) +PCI_D1 ((pci_power_t __force) 1) +PCI_D2 ((pci_power_t __force) 2) +PCI_D3hot ((pci_power_t __force) 3) +PCI_D3cold ((pci_power_t __force) 4) +PCI_UNKNOWN ((pci_power_t __force) 5) + +This function is called when system +goes into suspend state mac80211 will +call rtl_mac_stop() from the mac80211 +suspend function first, So there is +no need to call hw_disable here. +****************************************/ +int stg_rtl_pci_suspend(struct device *dev) +{ + struct pci_dev *pdev = to_pci_dev(dev); + struct ieee80211_hw *hw = pci_get_drvdata(pdev); + struct rtl_priv *rtlpriv = rtl_priv(hw); + + rtlpriv->cfg->ops->hw_suspend(hw); + rtl92e_deinit_rfkill(hw); + + return 0; +} +EXPORT_SYMBOL(stg_rtl_pci_suspend); + +int stg_rtl_pci_resume(struct device *dev) +{ + struct pci_dev *pdev = to_pci_dev(dev); + struct ieee80211_hw *hw = pci_get_drvdata(pdev); + struct rtl_priv *rtlpriv = rtl_priv(hw); + + rtlpriv->cfg->ops->hw_resume(hw); + rtl92e_init_rfkill(hw); + + return 0; +} +EXPORT_SYMBOL(stg_rtl_pci_resume); + +struct rtl_intf_ops rtl92e_pci_ops = { + .read92e_efuse_byte = read92e_efuse_byte, + .adapter_start = rtl_pci_start, + .adapter_stop = rtl_pci_stop, + .check_buddy_priv = rtl_pci_check_buddy_priv, + .adapter_tx = rtl_pci_tx, + .flush = rtl_pci_flush, + .reset_trx_ring = rtl92e_pci_reset_trx_ring, + .waitq_insert = rtl_pci_tx_chk_waitq_insert, + + .disable_aspm = rtl_pci_disable_aspm, + .enable_aspm = rtl_pci_enable_aspm, +}; diff --git a/drivers/staging/rtl8192ee/pci.h b/drivers/staging/rtl8192ee/pci.h new file mode 100644 index 000000000000..62c23a7f450d --- /dev/null +++ b/drivers/staging/rtl8192ee/pci.h @@ -0,0 +1,342 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#ifndef __RTL_PCI_H__ +#define __RTL_PCI_H__ + +#include +/* +1: MSDU packet queue, +2: Rx Command Queue +*/ +#define RTL_PCI_RX_MPDU_QUEUE 0 +#define RTL_PCI_RX_CMD_QUEUE 1 +#define RTL_PCI_MAX_RX_QUEUE 2 + +#define RTL_PCI_MAX_RX_COUNT 512/*64*/ +#define RTL_PCI_MAX_TX_QUEUE_COUNT 9 + +#define RT_TXDESC_NUM 128 +#define TX_DESC_NUM_92E 512 +#define RT_TXDESC_NUM_BE_QUEUE 256 + +#define BK_QUEUE 0 +#define BE_QUEUE 1 +#define VI_QUEUE 2 +#define VO_QUEUE 3 +#define BEACON_QUEUE 4 +#define TXCMD_QUEUE 5 +#define MGNT_QUEUE 6 +#define HIGH_QUEUE 7 +#define HCCA_QUEUE 8 + +#define RTL_PCI_DEVICE(vend, dev, cfg) \ + .vendor = (vend), \ + .device = (dev), \ + .subvendor = PCI_ANY_ID, \ + .subdevice = PCI_ANY_ID,\ + .driver_data = (kernel_ulong_t)&(cfg) + +#define INTEL_VENDOR_ID 0x8086 +#define SIS_VENDOR_ID 0x1039 +#define ATI_VENDOR_ID 0x1002 +#define ATI_DEVICE_ID 0x7914 +#define AMD_VENDOR_ID 0x1022 + +#define PCI_MAX_BRIDGE_NUMBER 255 +#define PCI_MAX_DEVICES 32 +#define PCI_MAX_FUNCTION 8 + +#define PCI_CONF_ADDRESS 0x0CF8 /*PCI Configuration Space Address */ +#define PCI_CONF_DATA 0x0CFC /*PCI Configuration Space Data */ + +#define PCI_CLASS_BRIDGE_DEV 0x06 +#define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04 +#define PCI_CAPABILITY_ID_PCI_EXPRESS 0x10 +#define PCI_CAP_ID_EXP 0x10 + +#define U1DONTCARE 0xFF +#define U2DONTCARE 0xFFFF +#define U4DONTCARE 0xFFFFFFFF + +#define RTL_PCI_8192_DID 0x8192 /*8192 PCI-E */ +#define RTL_PCI_8192SE_DID 0x8192 /*8192 SE */ +#define RTL_PCI_8174_DID 0x8174 /*8192 SE */ +#define RTL_PCI_8173_DID 0x8173 /*8191 SE Crab */ +#define RTL_PCI_8172_DID 0x8172 /*8191 SE RE */ +#define RTL_PCI_8171_DID 0x8171 /*8191 SE Unicron */ +#define RTL_PCI_0045_DID 0x0045 /*8190 PCI for Ceraga */ +#define RTL_PCI_0046_DID 0x0046 /*8190 Cardbus for Ceraga */ +#define RTL_PCI_0044_DID 0x0044 /*8192e PCIE for Ceraga */ +#define RTL_PCI_0047_DID 0x0047 /*8192e Express Card for Ceraga */ +#define RTL_PCI_700F_DID 0x700F +#define RTL_PCI_701F_DID 0x701F +#define RTL_PCI_DLINK_DID 0x3304 +#define RTL_PCI_8723AE_DID 0x8723 /*8723e */ +#define RTL_PCI_8192CET_DID 0x8191 /*8192ce */ +#define RTL_PCI_8192CE_DID 0x8178 /*8192ce */ +#define RTL_PCI_8191CE_DID 0x8177 /*8192ce */ +#define RTL_PCI_8188CE_DID 0x8176 /*8192ce */ +#define RTL_PCI_8192CU_DID 0x8191 /*8192ce */ +#define RTL_PCI_8192DE_DID 0x8193 /*8192de */ +#define RTL_PCI_8192DE_DID2 0x002B /*92DE*/ +#define RTL_PCI_8188EE_DID 0x8179 /*8188ee*/ +#define RTL_PCI_8723BE_DID 0xB723 /*8723be*/ +#define RTL_PCI_8192EE_DID 0x818B /*8192ee*/ +#define RTL_PCI_8821AE_DID 0x8821 /*8821ae*/ +#define RTL_PCI_8812AE_DID 0x8812 /*8812ae*/ + +/*8192 support 16 pages of IO registers*/ +#define RTL_MEM_MAPPED_IO_RANGE_8190PCI 0x1000 +#define RTL_MEM_MAPPED_IO_RANGE_8192PCIE 0x4000 +#define RTL_MEM_MAPPED_IO_RANGE_8192SE 0x4000 +#define RTL_MEM_MAPPED_IO_RANGE_8192CE 0x4000 +#define RTL_MEM_MAPPED_IO_RANGE_8192DE 0x4000 + +#define RTL_PCI_REVISION_ID_8190PCI 0x00 +#define RTL_PCI_REVISION_ID_8192PCIE 0x01 +#define RTL_PCI_REVISION_ID_8192SE 0x10 +#define RTL_PCI_REVISION_ID_8192CE 0x1 +#define RTL_PCI_REVISION_ID_8192DE 0x0 + +#define RTL_DEFAULT_HARDWARE_TYPE HARDWARE_TYPE_RTL8192CE + +enum pci_bridge_vendor { + PCI_BRIDGE_VENDOR_INTEL = 0x0, /*0b'0000,0001 */ + PCI_BRIDGE_VENDOR_ATI, /*0b'0000,0010*/ + PCI_BRIDGE_VENDOR_AMD, /*0b'0000,0100*/ + PCI_BRIDGE_VENDOR_SIS, /*0b'0000,1000*/ + PCI_BRIDGE_VENDOR_UNKNOWN, /*0b'0100,0000*/ + PCI_BRIDGE_VENDOR_MAX, +}; + +struct rtl_pci_capabilities_header { + u8 capability_id; + u8 next; +}; + +/* In new TRX flow, Buffer_desc is new concept + * But TX wifi info == TX descriptor in old flow + * RX wifi info == RX descriptor in old flow */ +struct rtl_tx_buffer_desc { +#if (RTL8192EE_SEG_NUM == 2) + u32 dword[2*(DMA_IS_64BIT + 1)*8]; /*seg = 8*/ +#elif (RTL8192EE_SEG_NUM == 1) + u32 dword[2*(DMA_IS_64BIT + 1)*4]; /*seg = 4*/ +#elif (RTL8192EE_SEG_NUM == 0) + u32 dword[2*(DMA_IS_64BIT + 1)*2]; /*seg = 2*/ +#endif +} __packed; + +struct rtl_tx_desc {/*old: tx desc new: tx wifi info*/ + u32 dword[16]; +} __packed; + +struct rtl_rx_buffer_desc { /*rx buffer desc*/ + u32 dword[2]; +} __packed; + +struct rtl_rx_desc { /*old: rx desc new: rx wifi info*/ + u32 dword[8]; +} __packed; + +struct rtl_tx_cmd_desc { + u32 dword[16]; +} __packed; + +struct rtl8192_tx_ring { + struct rtl_tx_desc *desc; /*tx desc / tx wifi info*/ + dma_addr_t dma; /*tx desc dma memory / tx wifi info dma memory*/ + unsigned int idx; + unsigned int entries; + struct sk_buff_head queue; + /*add for new trx flow*/ + struct rtl_tx_buffer_desc *buffer_desc; /*tx buffer descriptor*/ + dma_addr_t buffer_desc_dma; /*tx bufferd desc dma memory*/ + u16 avl_desc; /* available_desc_to_write */ + u16 cur_tx_wp; /* current_tx_write_point */ + u16 cur_tx_rp; /* current_tx_read_point */ +}; + +struct rtl8192_rx_ring { + struct rtl_rx_desc *desc;/*for old trx flow, not uesd in new trx*/ + /*dma matches either 'desc' or 'buffer_desc'*/ + dma_addr_t dma; + unsigned int idx; + struct sk_buff *rx_buf[RTL_PCI_MAX_RX_COUNT]; + /*add for new trx flow*/ + struct rtl_rx_buffer_desc *buffer_desc; /*rx buffer descriptor*/ + u16 next_rx_rp; /* next_rx_read_point */ +}; + +struct rtl_pci { + struct pci_dev *pdev; + bool irq_enabled; + + /*Tx */ + struct rtl8192_tx_ring tx_ring[RTL_PCI_MAX_TX_QUEUE_COUNT]; + int txringcount[RTL_PCI_MAX_TX_QUEUE_COUNT]; + u32 transmit_config; + + /*Rx */ + struct rtl8192_rx_ring rx_ring[RTL_PCI_MAX_RX_QUEUE]; + int rxringcount; + u16 rxbuffersize; + u32 receive_config; + + /*irq */ + u8 irq_alloc; + u32 irq_mask[2]; + u32 sys_irq_mask; + + /*Bcn control register setting */ + u32 reg_bcn_ctrl_val; + + /*ASPM*/ u8 const_pci_aspm; + u8 const_amdpci_aspm; + u8 const_hwsw_rfoff_d3; + u8 const_support_pciaspm; + /*pci-e bridge */ + u8 const_hostpci_aspm_setting; + /*pci-e device */ + u8 const_devicepci_aspm_setting; + /*If it supports ASPM, Offset[560h] = 0x40, + otherwise Offset[560h] = 0x00. */ + bool b_support_aspm; + bool b_support_backdoor; + + /*QOS & EDCA */ + enum acm_method acm_method; + + u16 shortretry_limit; + u16 longretry_limit; + + /* MSI support */ + bool msi_support; + bool using_msi; +}; + +struct mp_adapter { + u8 linkctrl_reg; + + u8 busnumber; + u8 devnumber; + u8 funcnumber; + + u8 pcibridge_busnum; + u8 pcibridge_devnum; + u8 pcibridge_funcnum; + + u8 pcibridge_vendor; + u16 pcibridge_vendorid; + u16 pcibridge_deviceid; + + u32 pcicfg_addrport; + u8 num4bytes; + + u8 pcibridge_pciehdr_offset; + u8 pcibridge_linkctrlreg; + + bool amd_l1_patch; +}; + +struct rtl_pci_priv { + struct rtl_pci dev; + struct mp_adapter ndis_adapter; + struct rtl_led_ctl ledctl; + struct bt_coexist_info btcoexist; +}; + +#define rtl_pcipriv(hw) (((struct rtl_pci_priv *)(rtl_priv(hw))->priv)) +#define rtl_pcidev(pcipriv) (&((pcipriv)->dev)) + +int rtl92e_pci_reset_trx_ring(struct ieee80211_hw *hw); + +extern struct rtl_intf_ops rtl92e_pci_ops; + +int stg_rtl_pci_probe(struct pci_dev *pdev, + const struct pci_device_id *id); +void stg_rtl_pci_disconnect(struct pci_dev *pdev); +int stg_rtl_pci_suspend(struct device *dev); +int stg_rtl_pci_resume(struct device *dev); + +static inline u8 pci_read8_sync(struct rtl_priv *rtlpriv, u32 addr) +{ + return 0xff & readb((u8 __iomem *)rtlpriv->io.pci_mem_start + addr); +} + +static inline u16 pci_read16_sync(struct rtl_priv *rtlpriv, u32 addr) +{ + return readw((u8 __iomem *)rtlpriv->io.pci_mem_start + addr); +} + +static inline u32 pci_read32_sync(struct rtl_priv *rtlpriv, u32 addr) +{ + return readl((u8 __iomem *)rtlpriv->io.pci_mem_start + addr); +} + +static inline void pci_write8_async(struct rtl_priv *rtlpriv, u32 addr, u8 val) +{ + writeb(val, (u8 __iomem *)rtlpriv->io.pci_mem_start + addr); +} + +static inline void pci_write16_async(struct rtl_priv *rtlpriv, + u32 addr, u16 val) +{ + writew(val, (u8 __iomem *)rtlpriv->io.pci_mem_start + addr); +} + +static inline void pci_write32_async(struct rtl_priv *rtlpriv, + u32 addr, u32 val) +{ + writel(val, (u8 __iomem *)rtlpriv->io.pci_mem_start + addr); +} + +static inline void rtl_pci_raw_write_port_ulong(u32 port, u32 val) +{ + outl(val, port); +} + +static inline void rtl_pci_raw_write_port_uchar(u32 port, u8 val) +{ + outb(val, port); +} + +static inline void rtl_pci_raw_read_port_uchar(u32 port, u8 *pval) +{ + *pval = inb(port); +} + +static inline void rtl_pci_raw_read_port_ushort(u32 port, u16 *pval) +{ + *pval = inw(port); +} + +static inline void rtl_pci_raw_read_port_ulong(u32 port, u32 *pval) +{ + *pval = inl(port); +} + +#endif diff --git a/drivers/staging/rtl8192ee/ps.c b/drivers/staging/rtl8192ee/ps.c new file mode 100644 index 000000000000..90c3fc2e62b6 --- /dev/null +++ b/drivers/staging/rtl8192ee/ps.c @@ -0,0 +1,983 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#include "wifi.h" +#include "base.h" +#include "ps.h" +#include "btcoexist/rtl_btc.h" + +bool stg_rtl_ps_enable_nic(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + bool init_status = true; + + /*<1> reset trx ring */ + if (rtlhal->interface == INTF_PCI) + rtlpriv->intf_ops->reset_trx_ring(hw); + + if (is_hal_stop(rtlhal)) + RT_TRACE(COMP_ERR, DBG_WARNING, ("Driver is already down!\n")); + + /*<2> Enable Adapter */ + rtlpriv->cfg->ops->hw_init(hw); + RT_CLEAR_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC); + /*init_status = false; */ + + /*<3> Enable Interrupt */ + rtlpriv->cfg->ops->enable_interrupt(hw); + + /* */ + rtl92e_watch_dog_timer_callback((unsigned long)hw); + + return init_status; +} +EXPORT_SYMBOL(stg_rtl_ps_enable_nic); + +bool stg_rtl_ps_disable_nic(struct ieee80211_hw *hw) +{ + bool status = true; + struct rtl_priv *rtlpriv = rtl_priv(hw); + + /*<1> Stop all timer */ + rtl92e_deinit_deferred_work(hw); + + /*<2> Disable Interrupt */ + rtlpriv->cfg->ops->disable_interrupt(hw); + + /*<3> Disable Adapter */ + rtlpriv->cfg->ops->hw_disable(hw); + + return status; +} +EXPORT_SYMBOL(stg_rtl_ps_disable_nic); + +bool stg_rtl_ps_set_rf_state(struct ieee80211_hw *hw, + enum rf_pwrstate state_toset, + u32 changesource, bool protect_or_not) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + enum rf_pwrstate rtstate; + bool b_actionallowed = false; + u16 rfwait_cnt = 0; + + /*protect_or_not = true; */ + + if (protect_or_not) + goto no_protect; + + /* + *Only one thread can change + *the RF state at one time, and others + *should wait to be executed. + */ + while (true) { + spin_lock(&rtlpriv->locks.rf_ps_lock); + if (ppsc->rfchange_inprogress) { + spin_unlock(&rtlpriv->locks.rf_ps_lock); + + RT_TRACE(COMP_ERR, DBG_WARNING, + ("RF Change in progress! Wait to set..state_toset(%d)\n", + state_toset)); + + /* Set RF after the previous action is done. */ + while (ppsc->rfchange_inprogress) { + rfwait_cnt++; + mdelay(1); + /* + *Wait too long, return false to avoid + *to be stuck here. + */ + if (rfwait_cnt > 100) + return false; + } + } else { + ppsc->rfchange_inprogress = true; + spin_unlock(&rtlpriv->locks.rf_ps_lock); + break; + } + } + +no_protect: + rtstate = ppsc->rfpwr_state; + + switch (state_toset) { + case ERFON: + ppsc->rfoff_reason &= (~changesource); + + if ((changesource == RF_CHANGE_BY_HW) && + (ppsc->b_hwradiooff)) { + ppsc->b_hwradiooff = false; + } + if (!ppsc->rfoff_reason) { + ppsc->rfoff_reason = 0; + b_actionallowed = true; + } + break; + case ERFOFF: + if ((changesource == RF_CHANGE_BY_HW) && + (!ppsc->b_hwradiooff)) { + ppsc->b_hwradiooff = true; + } + ppsc->rfoff_reason |= changesource; + b_actionallowed = true; + break; + case ERFSLEEP: + ppsc->rfoff_reason |= changesource; + b_actionallowed = true; + break; + default: + RT_TRACE(COMP_ERR, DBG_EMERG, ("switch case not process\n")); + break; + } + + if (b_actionallowed) + rtlpriv->cfg->ops->set_rf_power_state(hw, state_toset); + + if (!protect_or_not) { + spin_lock(&rtlpriv->locks.rf_ps_lock); + ppsc->rfchange_inprogress = false; + spin_unlock(&rtlpriv->locks.rf_ps_lock); + } + + return b_actionallowed; +} +EXPORT_SYMBOL(stg_rtl_ps_set_rf_state); + +static void _rtl_ps_inactive_ps(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + + ppsc->b_swrf_processing = true; + + if (ppsc->inactive_pwrstate == ERFON && rtlhal->interface == INTF_PCI) { + if ((ppsc->reg_rfps_level & RT_RF_OFF_LEVL_ASPM) && + RT_IN_PS_LEVEL(ppsc, RT_PS_LEVEL_ASPM) && + rtlhal->interface == INTF_PCI) { + rtlpriv->intf_ops->disable_aspm(hw); + RT_CLEAR_PS_LEVEL(ppsc, RT_PS_LEVEL_ASPM); + } + } + + stg_rtl_ps_set_rf_state(hw, ppsc->inactive_pwrstate, + RF_CHANGE_BY_IPS, false); + + if (ppsc->inactive_pwrstate == ERFOFF && + rtlhal->interface == INTF_PCI) { + if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_ASPM && + !RT_IN_PS_LEVEL(ppsc, RT_PS_LEVEL_ASPM)) { + rtlpriv->intf_ops->enable_aspm(hw); + RT_SET_PS_LEVEL(ppsc, RT_PS_LEVEL_ASPM); + } + } + + ppsc->b_swrf_processing = false; +} + +void rtl92e_ips_nic_off_wq_callback(void *data) +{ + struct rtl_works *rtlworks = + container_of_dwork_rtl(data, struct rtl_works, ips_nic_off_wq); + struct ieee80211_hw *hw = rtlworks->hw; + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + enum rf_pwrstate rtstate; + + if (mac->opmode != NL80211_IFTYPE_STATION) { + RT_TRACE(COMP_ERR, DBG_WARNING, ("not station return\n")); + return; + } + + if (mac->p2p_in_use) + return; + + if (mac->link_state > MAC80211_NOLINK) + return; + + if (is_hal_stop(rtlhal)) + return; + + if (rtlpriv->sec.being_setkey) + return; + + if (rtlpriv->cfg->ops->bt_turn_off_bt_coexist_before_enter_lps) + rtlpriv->cfg->ops->bt_turn_off_bt_coexist_before_enter_lps(hw); + + if (ppsc->b_inactiveps) { + rtstate = ppsc->rfpwr_state; + + /* + *Do not enter IPS in the following conditions: + *(1) RF is already OFF or Sleep + *(2) b_swrf_processing (indicates the IPS is still under going) + *(3) Connectted (only disconnected can trigger IPS) + *(4) IBSS (send Beacon) + *(5) AP mode (send Beacon) + *(6) monitor mode (rcv packet) + */ + + if (rtstate == ERFON && + !ppsc->b_swrf_processing && + (mac->link_state == MAC80211_NOLINK) && + !mac->act_scanning) { + RT_TRACE(COMP_RF, DBG_LOUD, + ("IPSEnter(): Turn off RF.\n")); + + ppsc->inactive_pwrstate = ERFOFF; + ppsc->b_in_powersavemode = true; + + /* call before RF off */ + if (rtlpriv->cfg->ops->get_btc_status()) + rtlpriv->btcoexist.btc_ops->btc_ips_notify(rtlpriv, + ppsc->inactive_pwrstate); + + /*rtl92e_pci_reset_trx_ring(hw); */ + _rtl_ps_inactive_ps(hw); + } + } +} + +void rtl92e_ips_nic_off(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + /* + *because when link with ap, mac80211 will ask us + *to disable nic quickly after scan before linking, + *this will cause link failed, so we delay 100ms here + */ + queue_delayed_work(rtlpriv->works.rtl_wq, + &rtlpriv->works.ips_nic_off_wq, MSECS(100)); +} + +/* NOTICE: any opmode should exc nic_on, or disable without + * nic_on may something wrong, like adhoc TP*/ +void rtl92e_ips_nic_on(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + enum rf_pwrstate rtstate; + + cancel_delayed_work(&rtlpriv->works.ips_nic_off_wq); + + spin_lock(&rtlpriv->locks.ips_lock); + if (ppsc->b_inactiveps) { + rtstate = ppsc->rfpwr_state; + + if (rtstate != ERFON && + !ppsc->b_swrf_processing && + ppsc->rfoff_reason <= RF_CHANGE_BY_IPS) { + ppsc->inactive_pwrstate = ERFON; + ppsc->b_in_powersavemode = false; + _rtl_ps_inactive_ps(hw); + /* call after RF on */ + if (rtlpriv->cfg->ops->get_btc_status()) + rtlpriv->btcoexist.btc_ops->btc_ips_notify(rtlpriv, + ppsc->inactive_pwrstate); + } + } + spin_unlock(&rtlpriv->locks.ips_lock); +} + +/*for FW LPS*/ + +/* + *Determine if we can set Fw into PS mode + *in current condition.Return true if it + *can enter PS mode. + */ +static bool rtl_get_fwlps_doze(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + u32 ps_timediff; + + ps_timediff = jiffies_to_msecs(jiffies - + ppsc->last_delaylps_stamp_jiffies); + + if (ps_timediff < 2000) { + RT_TRACE(COMP_POWER, DBG_LOUD, + ("Delay enter Fw LPS for DHCP, ARP, or EAPOL exchanging state\n")); + return false; + } + + if (mac->link_state != MAC80211_LINKED) + return false; + + if (mac->opmode == NL80211_IFTYPE_ADHOC) + return false; + + return true; +} + +/* Change current and default preamble mode.*/ +void rtl_lps_set_psmode(struct ieee80211_hw *hw, u8 rt_psmode) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + bool enter_fwlps; + + if (mac->opmode == NL80211_IFTYPE_ADHOC) + return; + + if (mac->link_state != MAC80211_LINKED) + return; + + if (ppsc->dot11_psmode == rt_psmode) + return; + + /* Update power save mode configured. */ + ppsc->dot11_psmode = rt_psmode; + + /* + * + *1. Enter PS mode + * Set RPWM to Fw to turn RF off and send H2C fw_pwrmode + * cmd to set Fw into PS mode. + *2. Leave PS mode + * Send H2C fw_pwrmode cmd to Fw to set Fw into Active + * mode and set RPWM to turn RF on. + */ + + if ((ppsc->b_fwctrl_lps) && ppsc->report_linked) { + if (ppsc->dot11_psmode == EACTIVE) { + RT_TRACE(COMP_RF, DBG_DMESG, + ("FW LPS leave ps_mode:%x\n", + FW_PS_ACTIVE_MODE)); + enter_fwlps = false; + ppsc->pwr_mode = FW_PS_ACTIVE_MODE; + ppsc->smart_ps = 0; + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_FW_LPS_ACTION, + (u8 *)(&enter_fwlps)); + if (ppsc->p2p_ps_info.opp_ps) + rtl92e_p2p_ps_cmd(hw , P2P_PS_ENABLE); + + if (rtlpriv->cfg->ops->get_btc_status()) + rtlpriv->btcoexist.btc_ops->btc_lps_notify(rtlpriv, rt_psmode); + } else { + if (rtl_get_fwlps_doze(hw)) { + RT_TRACE(COMP_RF, DBG_DMESG, + ("FW LPS enter ps_mode:%x\n", + ppsc->fwctrl_psmode)); + if (rtlpriv->cfg->ops->get_btc_status()) + rtlpriv->btcoexist.btc_ops->btc_lps_notify(rtlpriv, rt_psmode); + enter_fwlps = true; + ppsc->pwr_mode = ppsc->fwctrl_psmode; + ppsc->smart_ps = 2; + rtlpriv->cfg->ops->set_hw_reg(hw, + HW_VAR_FW_LPS_ACTION, + (u8 *)(&enter_fwlps)); + + } else { + /* Reset the power save related parameters. */ + ppsc->dot11_psmode = EACTIVE; + } + } + } +} + +/*Enter the leisure power save mode.*/ +void rtl92e_lps_enter(struct ieee80211_hw *hw) +{ + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + struct rtl_priv *rtlpriv = rtl_priv(hw); + unsigned long flag; + + if (!ppsc->b_fwctrl_lps) + return; + + if (rtlpriv->sec.being_setkey) + return; + + if (rtlpriv->link_info.b_busytraffic) + return; + + /*sleep after linked 10s, to let DHCP and 4-way handshake ok enough!! */ + if (mac->cnt_after_linked < 5) + return; + + if (mac->opmode == NL80211_IFTYPE_ADHOC) + return; + + if (mac->link_state != MAC80211_LINKED) + return; + + spin_lock_irqsave(&rtlpriv->locks.lps_lock, flag); + + /* Idle for a while if we connect to AP a while ago. */ + if (mac->cnt_after_linked >= 2) { + if (ppsc->dot11_psmode == EACTIVE) { + RT_TRACE(COMP_POWER, DBG_LOUD, + ("Enter 802.11 power save mode...\n")); + + rtl_lps_set_psmode(hw, EAUTOPS); + } + } + + spin_unlock_irqrestore(&rtlpriv->locks.lps_lock, flag); +} +EXPORT_SYMBOL(rtl92e_lps_enter); + +/*Leave the leisure power save mode.*/ +void rtl92e_lps_leave(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + unsigned long flag; + + spin_lock_irqsave(&rtlpriv->locks.lps_lock, flag); + + if (ppsc->b_fwctrl_lps) { + if (ppsc->dot11_psmode != EACTIVE) { + if (ppsc->reg_rfps_level & RT_RF_LPS_LEVEL_ASPM && + RT_IN_PS_LEVEL(ppsc, RT_PS_LEVEL_ASPM) && + rtlhal->interface == INTF_PCI) { + rtlpriv->intf_ops->disable_aspm(hw); + RT_CLEAR_PS_LEVEL(ppsc, RT_PS_LEVEL_ASPM); + } + + RT_TRACE(COMP_POWER, DBG_LOUD, + ("Busy Traffic,Leave 802.11 power save..\n")); + + rtl_lps_set_psmode(hw, EACTIVE); + } + } + spin_unlock_irqrestore(&rtlpriv->locks.lps_lock, flag); +} +EXPORT_SYMBOL(rtl92e_lps_leave); + +/* For sw LPS*/ +void rtl92e_swlps_beacon(struct ieee80211_hw *hw, void *data, unsigned int len) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct ieee80211_hdr *hdr = (void *)data; + struct ieee80211_tim_ie *tim_ie; + u8 *tim; + u8 tim_len; + bool u_buffed; + bool m_buffed; + + if (mac->opmode != NL80211_IFTYPE_STATION) + return; + + if (!rtlpriv->psc.b_swctrl_lps) + return; + + if (rtlpriv->mac80211.link_state != MAC80211_LINKED) + return; + + if (!rtlpriv->psc.sw_ps_enabled) + return; + + if (rtlpriv->psc.b_fwctrl_lps) + return; + + if (likely(!(hw->conf.flags & IEEE80211_CONF_PS))) + return; + + /* check if this really is a beacon */ + if (!ieee80211_is_beacon(hdr->frame_control)) + return; + + /* min. beacon length + FCS_LEN */ + if (len <= 40 + FCS_LEN) + return; + + /* and only beacons from the associated BSSID, please */ + if (!ether_addr_equal(hdr->addr3, rtlpriv->mac80211.bssid)) + return; + + rtlpriv->psc.last_beacon = jiffies; + + tim = rtl92e_find_ie(data, len - FCS_LEN, WLAN_EID_TIM); + if (!tim) + return; + + if (tim[1] < sizeof(*tim_ie)) + return; + + tim_len = tim[1]; + tim_ie = (struct ieee80211_tim_ie *)&tim[2]; + + if (!WARN_ON_ONCE(!hw->conf.ps_dtim_period)) + rtlpriv->psc.dtim_counter = tim_ie->dtim_count; + + /* Check whenever the PHY can be turned off again. */ + + /* 1. What about buffered unicast traffic for our AID? */ + u_buffed = ieee80211_check_tim(tim_ie, tim_len, + rtlpriv->mac80211.assoc_id); + + /* 2. Maybe the AP wants to send multicast/broadcast data? */ + m_buffed = tim_ie->bitmap_ctrl & 0x01; + rtlpriv->psc.multi_buffered = m_buffed; + + /* unicast will process by mac80211 through + * set ~IEEE80211_CONF_PS, So we just check + * multicast frames here */ + if (!m_buffed) {/*&&) { !rtlpriv->psc.tx_doing) { */ + /* back to low-power land. and delay is + * prevent null power save frame tx fail */ + queue_delayed_work(rtlpriv->works.rtl_wq, + &rtlpriv->works.ps_work, MSECS(5)); + } else { + RT_TRACE(COMP_POWER, DBG_DMESG, + ("u_bufferd: %x, m_buffered: %x\n", + u_buffed, m_buffed)); + } +} + +void rtl92e_swlps_rf_awake(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + unsigned long flag; + + if (!rtlpriv->psc.b_swctrl_lps) + return; + if (mac->link_state != MAC80211_LINKED) + return; + + if (ppsc->reg_rfps_level & RT_RF_LPS_LEVEL_ASPM && + RT_IN_PS_LEVEL(ppsc, RT_PS_LEVEL_ASPM)) { + rtlpriv->intf_ops->disable_aspm(hw); + RT_CLEAR_PS_LEVEL(ppsc, RT_PS_LEVEL_ASPM); + } + + spin_lock_irqsave(&rtlpriv->locks.lps_lock, flag); + stg_rtl_ps_set_rf_state(hw, ERFON, RF_CHANGE_BY_PS, false); + spin_unlock_irqrestore(&rtlpriv->locks.lps_lock, flag); +} + +void rtl92e_swlps_rfon_wq_callback(void *data) +{ + struct rtl_works *rtlworks = + container_of_dwork_rtl(data, struct rtl_works, ps_rfon_wq); + struct ieee80211_hw *hw = rtlworks->hw; + + rtl92e_swlps_rf_awake(hw); +} + +void rtl92e_swlps_rf_sleep(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + unsigned long flag; + u8 sleep_intv; + + if (!rtlpriv->psc.sw_ps_enabled) + return; + + if ((rtlpriv->sec.being_setkey) || + (mac->opmode == NL80211_IFTYPE_ADHOC)) + return; + + /*sleep after linked 10s, to let DHCP and 4-way handshake ok enough!! */ + if ((mac->link_state != MAC80211_LINKED) || (mac->cnt_after_linked < 5)) + return; + + if (rtlpriv->link_info.b_busytraffic) + return; + + spin_lock(&rtlpriv->locks.rf_ps_lock); + if (rtlpriv->psc.rfchange_inprogress) { + spin_unlock(&rtlpriv->locks.rf_ps_lock); + return; + } + spin_unlock(&rtlpriv->locks.rf_ps_lock); + + spin_lock_irqsave(&rtlpriv->locks.lps_lock, flag); + stg_rtl_ps_set_rf_state(hw, ERFSLEEP, RF_CHANGE_BY_PS , false); + spin_unlock_irqrestore(&rtlpriv->locks.lps_lock, flag); + + if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_ASPM && + !RT_IN_PS_LEVEL(ppsc, RT_PS_LEVEL_ASPM)) { + rtlpriv->intf_ops->enable_aspm(hw); + RT_SET_PS_LEVEL(ppsc, RT_PS_LEVEL_ASPM); + } + + /* here is power save alg, when this beacon is DTIM + * we will set sleep time to dtim_period * n; + * when this beacon is not DTIM, we will set sleep + * time to sleep_intv = rtlpriv->psc.dtim_counter or + * MAX_SW_LPS_SLEEP_INTV(default set to 5) */ + + if (rtlpriv->psc.dtim_counter == 0) { + if (hw->conf.ps_dtim_period == 1) + sleep_intv = hw->conf.ps_dtim_period * 2; + else + sleep_intv = hw->conf.ps_dtim_period; + } else { + sleep_intv = rtlpriv->psc.dtim_counter; + } + + if (sleep_intv > MAX_SW_LPS_SLEEP_INTV) + sleep_intv = MAX_SW_LPS_SLEEP_INTV; + + /* this print should always be dtim_conter = 0 & + * sleep = dtim_period, that meaons, we should + * awake before every dtim */ + RT_TRACE(COMP_POWER, DBG_DMESG, + ("dtim_counter:%x will sleep :%d beacon_intv\n", + rtlpriv->psc.dtim_counter, sleep_intv)); + + /* we tested that 40ms is enough for sw & hw sw delay */ + queue_delayed_work(rtlpriv->works.rtl_wq, &rtlpriv->works.ps_rfon_wq, + MSECS(sleep_intv*mac->vif->bss_conf.beacon_int-40)); +} + + +void rtl92e_swlps_wq_callback(void *data) +{ + struct rtl_works *rtlworks = + container_of_dwork_rtl(data, struct rtl_works, ps_work); + struct ieee80211_hw *hw = rtlworks->hw; + struct rtl_priv *rtlpriv = rtl_priv(hw); + bool ps = false; + + ps = (hw->conf.flags & IEEE80211_CONF_PS); + + /* we can sleep after ps null send ok */ + if (rtlpriv->psc.state_inap) { + rtl92e_swlps_rf_sleep(hw); + + if (rtlpriv->psc.state && !ps) { + rtlpriv->psc.sleep_ms = + jiffies_to_msecs(jiffies - + rtlpriv->psc.last_action); + } + + if (ps) + rtlpriv->psc.last_slept = jiffies; + + rtlpriv->psc.last_action = jiffies; + rtlpriv->psc.state = ps; + } +} + +static void rtl_p2p_noa_ie(struct ieee80211_hw *hw, void *data, + unsigned int len) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct ieee80211_mgmt *mgmt = (void *)data; + struct rtl_p2p_ps_info *p2pinfo = &(rtlpriv->psc.p2p_ps_info); + u8 *pos, *end, *ie; + u16 noa_len; + static u8 p2p_oui_ie_type[4] = {0x50, 0x6f, 0x9a, 0x09}; + u8 noa_num, index , i, noa_index = 0; + bool find_p2p_ie = false , find_p2p_ps_ie = false; + pos = (u8 *)mgmt->u.beacon.variable; + end = data + len; + ie = NULL; + + while (pos + 1 < end) { + if (pos + 2 + pos[1] > end) + return; + + if (pos[0] == 221 && pos[1] > 4) { + if (memcmp(&pos[2], p2p_oui_ie_type, 4) == 0) { + ie = pos + 2+4; + break; + } + } + pos += 2 + pos[1]; + } + + if (ie == NULL) + return; + find_p2p_ie = true; + /*to find noa ie*/ + while (ie + 1 < end) { + noa_len = READEF2BYTE((__le16 *)&ie[1]); + if (ie + 3 + ie[1] > end) + return; + + if (ie[0] == 12) { + find_p2p_ps_ie = true; + if ((noa_len - 2) % 13 != 0) { + RT_TRACE(COMP_INIT, DBG_LOUD, + ("P2P notice of absence: invalid length%d\n", + noa_len)); + return; + } else { + noa_num = (noa_len - 2) / 13; + } + noa_index = ie[3]; + if (rtlpriv->psc.p2p_ps_info.p2p_ps_mode == + P2P_PS_NONE || noa_index != p2pinfo->noa_index) { + RT_TRACE(COMP_FW, DBG_LOUD, + ("update NOA ie.\n")); + p2pinfo->noa_index = noa_index; + p2pinfo->opp_ps = (ie[4] >> 7); + p2pinfo->ctwindow = ie[4] & 0x7F; + p2pinfo->noa_num = noa_num; + index = 5; + for (i = 0; i < noa_num; i++) { + p2pinfo->noa_count_type[i] = + READEF1BYTE(ie+index); + index += 1; + p2pinfo->noa_duration[i] = + READEF4BYTE((__le32 *)ie+index); + index += 4; + p2pinfo->noa_interval[i] = + READEF4BYTE((__le32 *)ie+index); + index += 4; + p2pinfo->noa_start_time[i] = + READEF4BYTE((__le32 *)ie+index); + index += 4; + } + + if (p2pinfo->opp_ps == 1) { + p2pinfo->p2p_ps_mode = P2P_PS_CTWINDOW; + /* Driver should wait LPS + * entering CTWindow*/ + if (rtlpriv->psc.b_fw_current_inpsmode) { + rtl92e_p2p_ps_cmd(hw, + P2P_PS_ENABLE); + } + } else if (p2pinfo->noa_num > 0) { + p2pinfo->p2p_ps_mode = P2P_PS_NOA; + rtl92e_p2p_ps_cmd(hw, P2P_PS_ENABLE); + } else if (p2pinfo->p2p_ps_mode > P2P_PS_NONE) { + rtl92e_p2p_ps_cmd(hw, P2P_PS_DISABLE); + } + } + + break; + } + ie += 3 + noa_len; + } + + if (find_p2p_ie) { + if ((p2pinfo->p2p_ps_mode > P2P_PS_NONE) && + (!find_p2p_ps_ie)) + rtl92e_p2p_ps_cmd(hw, P2P_PS_DISABLE); + } +} + +static void rtl_p2p_action_ie(struct ieee80211_hw *hw, void *data, + unsigned int len) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct ieee80211_mgmt *mgmt = (void *)data; + struct rtl_p2p_ps_info *p2pinfo = &(rtlpriv->psc.p2p_ps_info); + bool find_p2p_ie = false, find_p2p_ps_ie = false; + u8 noa_num, index, i, noa_index = 0; + u8 *pos, *end, *ie; + u16 noa_len; + static u8 p2p_oui_ie_type[4] = {0x50, 0x6f, 0x9a, 0x09}; + + pos = (u8 *)&mgmt->u.action.category; + end = data + len; + ie = NULL; + + if (pos[0] == 0x7f) { + if (memcmp(&pos[1], p2p_oui_ie_type, 4) == 0) + ie = pos + 3+4; + } + + if (ie == NULL) + return; + find_p2p_ie = true; + + RT_TRACE(COMP_FW, DBG_LOUD, ("action frame find P2P IE.\n")); + /*to find noa ie*/ + while (ie + 1 < end) { + noa_len = READEF2BYTE((__le16 *)&ie[1]); + if (ie + 3 + ie[1] > end) + return; + + if (ie[0] == 12) { + RT_TRACE(COMP_FW, DBG_LOUD, ("find NOA IE\n")); + RT_PRINT_DATA(rtlpriv, COMP_FW, DBG_LOUD, "noa ie ", + ie, noa_len); + find_p2p_ps_ie = true; + if ((noa_len - 2) % 13 != 0) { + RT_TRACE(COMP_FW, DBG_LOUD, + ("P2P notice of absence: invalid length%d\n", + noa_len)); + return; + } else { + noa_num = (noa_len - 2) / 13; + } + noa_index = ie[3]; + if (rtlpriv->psc.p2p_ps_info.p2p_ps_mode == + P2P_PS_NONE || + noa_index != p2pinfo->noa_index) { + p2pinfo->noa_index = noa_index; + p2pinfo->opp_ps = (ie[4] >> 7); + p2pinfo->ctwindow = ie[4] & 0x7F; + p2pinfo->noa_num = noa_num; + index = 5; + for (i = 0; i < noa_num; i++) { + p2pinfo->noa_count_type[i] = + READEF1BYTE(ie+index); + index += 1; + p2pinfo->noa_duration[i] = + READEF4BYTE((__le32 *)ie+index); + index += 4; + p2pinfo->noa_interval[i] = + READEF4BYTE((__le32 *)ie+index); + index += 4; + p2pinfo->noa_start_time[i] = + READEF4BYTE((__le32 *)ie+index); + index += 4; + } + + if (p2pinfo->opp_ps == 1) { + p2pinfo->p2p_ps_mode = P2P_PS_CTWINDOW; + /* Driver should wait LPS + * entering CTWindow */ + if (rtlpriv->psc.b_fw_current_inpsmode) { + rtl92e_p2p_ps_cmd(hw, + P2P_PS_ENABLE); + } + } else if (p2pinfo->noa_num > 0) { + p2pinfo->p2p_ps_mode = P2P_PS_NOA; + rtl92e_p2p_ps_cmd(hw, P2P_PS_ENABLE); + } else if (p2pinfo->p2p_ps_mode > P2P_PS_NONE) { + rtl92e_p2p_ps_cmd(hw, P2P_PS_DISABLE); + } + } + + break; + } + ie += 3 + noa_len; + } +} + +void rtl92e_p2p_ps_cmd(struct ieee80211_hw *hw, u8 p2p_ps_state) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_ps_ctl *rtlps = rtl_psc(rtl_priv(hw)); + struct rtl_p2p_ps_info *p2pinfo = &(rtlpriv->psc.p2p_ps_info); + + RT_TRACE(COMP_FW, DBG_LOUD, ("p2p state %x\n", p2p_ps_state)); + switch (p2p_ps_state) { + case P2P_PS_DISABLE: + p2pinfo->p2p_ps_state = p2p_ps_state; + rtlpriv->cfg->ops->set_hw_reg(hw, + HW_VAR_H2C_FW_P2P_PS_OFFLOAD, + (u8 *)(&p2p_ps_state)); + + p2pinfo->noa_index = 0; + p2pinfo->ctwindow = 0; + p2pinfo->opp_ps = 0; + p2pinfo->noa_num = 0; + p2pinfo->p2p_ps_mode = P2P_PS_NONE; + if (rtlps->b_fw_current_inpsmode) { + if (rtlps->smart_ps == 0) { + rtlps->smart_ps = 2; + rtlpriv->cfg->ops->set_hw_reg(hw, + HW_VAR_H2C_FW_PWRMODE, + (u8 *)(&rtlps->pwr_mode)); + } + } + break; + case P2P_PS_ENABLE: + if (p2pinfo->p2p_ps_mode > P2P_PS_NONE) { + p2pinfo->p2p_ps_state = p2p_ps_state; + + if (p2pinfo->ctwindow > 0) { + if (rtlps->smart_ps != 0) { + rtlps->smart_ps = 0; + rtlpriv->cfg->ops->set_hw_reg( + hw, HW_VAR_H2C_FW_PWRMODE, + (u8 *)(&rtlps->pwr_mode)); + } + } + rtlpriv->cfg->ops->set_hw_reg(hw, + HW_VAR_H2C_FW_P2P_PS_OFFLOAD, + (u8 *)(&p2p_ps_state)); + } + break; + case P2P_PS_SCAN: + case P2P_PS_SCAN_DONE: + case P2P_PS_ALLSTASLEEP: + if (p2pinfo->p2p_ps_mode > P2P_PS_NONE) { + p2pinfo->p2p_ps_state = p2p_ps_state; + rtlpriv->cfg->ops->set_hw_reg(hw, + HW_VAR_H2C_FW_P2P_PS_OFFLOAD, + (u8 *)(&p2p_ps_state)); + } + break; + default: + break; + } + RT_TRACE(COMP_FW, DBG_LOUD, (" ctwindow %x oppps %x\n", + p2pinfo->ctwindow , p2pinfo->opp_ps)); + RT_TRACE(COMP_FW, DBG_LOUD, + ("count %x duration %x index %x interval %x start time %x noa num %x\n", + p2pinfo->noa_count_type[0], + p2pinfo->noa_duration[0], + p2pinfo->noa_index, + p2pinfo->noa_interval[0], + p2pinfo->noa_start_time[0], + p2pinfo->noa_num)); + RT_TRACE(COMP_FW, DBG_LOUD, ("end\n")); +} + +void rtl92e_p2p_info(struct ieee80211_hw *hw, void *data, unsigned int len) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct ieee80211_hdr *hdr = (void *)data; + + if (!mac->p2p) + return; + if (mac->link_state != MAC80211_LINKED) + return; + /* min. beacon length + FCS_LEN */ + if (len <= 40 + FCS_LEN) + return; + + /* and only beacons from the associated BSSID, please */ + if (!ether_addr_equal(hdr->addr3, rtlpriv->mac80211.bssid)) + return; + + /* check if this really is a beacon */ + if (!(ieee80211_is_beacon(hdr->frame_control) || + ieee80211_is_probe_resp(hdr->frame_control) || + ieee80211_is_action(hdr->frame_control))) + return; + + if (ieee80211_is_action(hdr->frame_control)) + rtl_p2p_action_ie(hw , data , len - FCS_LEN); + else + rtl_p2p_noa_ie(hw , data , len - FCS_LEN); +} diff --git a/drivers/staging/rtl8192ee/ps.h b/drivers/staging/rtl8192ee/ps.h new file mode 100644 index 000000000000..1533661a2f43 --- /dev/null +++ b/drivers/staging/rtl8192ee/ps.h @@ -0,0 +1,52 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#ifndef __REALTEK_RTL_PCI_PS_H__ +#define __REALTEK_RTL_PCI_PS_H__ + +#define MAX_SW_LPS_SLEEP_INTV 5 + +bool stg_rtl_ps_set_rf_state(struct ieee80211_hw *hw, + enum rf_pwrstate state_toset, u32 changesource, + bool protect_or_not); +bool stg_rtl_ps_enable_nic(struct ieee80211_hw *hw); +bool stg_rtl_ps_disable_nic(struct ieee80211_hw *hw); +void rtl92e_ips_nic_off(struct ieee80211_hw *hw); +void rtl92e_ips_nic_on(struct ieee80211_hw *hw); +void rtl92e_ips_nic_off_wq_callback(void *data); +void rtl92e_lps_enter(struct ieee80211_hw *hw); +void rtl92e_lps_leave(struct ieee80211_hw *hw); + +void rtl_lps_set_psmode(struct ieee80211_hw *hw, u8 rt_psmode); + +void rtl92e_swlps_beacon(struct ieee80211_hw *hw, void *data, unsigned int len); +void rtl92e_swlps_wq_callback(void *data); +void rtl92e_swlps_rfon_wq_callback(void *data); +void rtl92e_swlps_rf_awake(struct ieee80211_hw *hw); +void rtl92e_swlps_rf_sleep(struct ieee80211_hw *hw); +void rtl92e_p2p_ps_cmd(struct ieee80211_hw *hw , u8 p2p_ps_state); +void rtl92e_p2p_info(struct ieee80211_hw *hw, void *data, unsigned int len); + +#endif diff --git a/drivers/staging/rtl8192ee/rc.c b/drivers/staging/rtl8192ee/rc.c new file mode 100644 index 000000000000..f0ce6a99ab00 --- /dev/null +++ b/drivers/staging/rtl8192ee/rc.c @@ -0,0 +1,288 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#include "wifi.h" +#include "base.h" +#include "rc.h" + +/* + *Finds the highest rate index we can use + *if skb is special data like DHCP/EAPOL, we set should + *it to lowest rate CCK_1M, otherwise we set rate to + *highest rate based on wireless mode used for iwconfig + *show Tx rate. + */ +static u8 _rtl_rc_get_highest_rix(struct rtl_priv *rtlpriv, + struct ieee80211_sta *sta, + struct sk_buff *skb, bool not_data) +{ + struct rtl_hal *rtlhal = rtl_hal(rtlpriv); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + struct rtl_sta_info *sta_entry = NULL; + u8 wireless_mode = 0; + + /* + *this rate is no use for true rate, firmware + *will control rate at all it just used for + *1.show in iwconfig in B/G mode + *2.in stg_rtl_get_tcb_desc when we check rate is + * 1M we will not use FW rate but user rate. + */ + + if (sta) { + sta_entry = (struct rtl_sta_info *)sta->drv_priv; + wireless_mode = sta_entry->wireless_mode; + } + + if (rtl92e_is_special_data(rtlpriv->mac80211.hw, skb, true) || + not_data) { + return 0; + } else { + if (rtlhal->current_bandtype == BAND_ON_2_4G) { + if (wireless_mode == WIRELESS_MODE_B) { + return B_MODE_MAX_RIX; + } else if (wireless_mode == WIRELESS_MODE_G) { + return G_MODE_MAX_RIX; + } else if (wireless_mode == WIRELESS_MODE_N_24G) { + if (get_rf_type(rtlphy) != RF_2T2R) + return N_MODE_MCS7_RIX; + else + return N_MODE_MCS15_RIX; + } else if (wireless_mode == WIRELESS_MODE_AC_24G) { + return AC_MODE_MCS9_RIX; + } else { + return 0; + } + } else { + if (wireless_mode == WIRELESS_MODE_A) { + return A_MODE_MAX_RIX; + } else if (wireless_mode == WIRELESS_MODE_N_5G) { + if (get_rf_type(rtlphy) != RF_2T2R) + return N_MODE_MCS7_RIX; + else + return N_MODE_MCS15_RIX; + } else if (wireless_mode == WIRELESS_MODE_AC_5G) { + return AC_MODE_MCS9_RIX; + } else { + return 0; + } + } + } +} + +static void _rtl_rc_rate_set_series(struct rtl_priv *rtlpriv, + struct ieee80211_sta *sta, + struct ieee80211_tx_rate *rate, + struct ieee80211_tx_rate_control *txrc, + u8 tries, char rix, int rtsctsenable, + bool not_data) +{ + struct rtl_mac *mac = rtl_mac(rtlpriv); + u8 sgi_20 = 0, sgi_40 = 0, sgi_80 = 0; + + if (sta) { + sgi_20 = sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20; + sgi_40 = sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40; + sgi_80 = sta->vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_80; + } + rate->count = tries; + rate->idx = rix >= 0x00 ? rix : 0x00; + + if (!not_data) { + if (txrc->short_preamble) + rate->flags |= IEEE80211_TX_RC_USE_SHORT_PREAMBLE; + if (mac->opmode == NL80211_IFTYPE_AP || + mac->opmode == NL80211_IFTYPE_ADHOC) { + if (sta && (sta->ht_cap.cap & + IEEE80211_HT_CAP_SUP_WIDTH_20_40)) + rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH; + if (sta && (sta->vht_cap.vht_supported)) + rate->flags |= IEEE80211_TX_RC_80_MHZ_WIDTH; + } else { + if (mac->bw_40) + rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH; + if (mac->bw_80) + rate->flags |= IEEE80211_TX_RC_80_MHZ_WIDTH; + } + + if (sgi_20 || sgi_40 || sgi_80) + rate->flags |= IEEE80211_TX_RC_SHORT_GI; + if (sta && sta->ht_cap.ht_supported) + rate->flags |= IEEE80211_TX_RC_MCS; + if (sta && sta->vht_cap.vht_supported) + rate->flags |= IEEE80211_TX_RC_VHT_MCS; + } +} + +static void rtl_get_rate(void *ppriv, struct ieee80211_sta *sta, + void *priv_sta, + struct ieee80211_tx_rate_control *txrc) +{ + struct rtl_priv *rtlpriv = ppriv; + struct sk_buff *skb = txrc->skb; + struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); + struct ieee80211_tx_rate *rates = tx_info->control.rates; + __le16 fc = rtl_get_fc(skb); + u8 try_per_rate, i, rix; + bool not_data = !ieee80211_is_data(fc); + + if (rate_control_send_low(sta, priv_sta, txrc)) + return; + + rix = _rtl_rc_get_highest_rix(rtlpriv, sta, skb, not_data); + try_per_rate = 1; + _rtl_rc_rate_set_series(rtlpriv, sta, &rates[0], txrc, + try_per_rate, rix, 1, not_data); + + if (!not_data) { + for (i = 1; i < 4; i++) + _rtl_rc_rate_set_series(rtlpriv, sta, &rates[i], + txrc, i, (rix - i), 1, + not_data); + } +} + +static bool _rtl_tx_aggr_check(struct rtl_priv *rtlpriv, + struct rtl_sta_info *sta_entry, u16 tid) +{ + struct rtl_mac *mac = rtl_mac(rtlpriv); + + if (mac->act_scanning) + return false; + + if (mac->opmode == NL80211_IFTYPE_STATION && + mac->cnt_after_linked < 3) + return false; + + if (sta_entry->tids[tid].agg.agg_state == RTL_AGG_STOP) + return true; + + return false; +} + +/*mac80211 Rate Control callbacks*/ +static void rtl_tx_status(void *ppriv, + struct ieee80211_supported_band *sband, + struct ieee80211_sta *sta, void *priv_sta, + struct sk_buff *skb) +{ + struct rtl_priv *rtlpriv = ppriv; + struct rtl_mac *mac = rtl_mac(rtlpriv); + struct ieee80211_hdr *hdr = rtl_get_hdr(skb); + __le16 fc = rtl_get_fc(skb); + struct rtl_sta_info *sta_entry; + + if (!priv_sta || !ieee80211_is_data(fc)) + return; + + if (rtl92e_is_special_data(mac->hw, skb, true)) + return; + + if (is_multicast_ether_addr(ieee80211_get_DA(hdr)) || + is_broadcast_ether_addr(ieee80211_get_DA(hdr))) + return; + + if (sta) { + /* Check if aggregation has to be enabled for this tid */ + sta_entry = (struct rtl_sta_info *)sta->drv_priv; + if ((sta->ht_cap.ht_supported) && + !(skb->protocol == cpu_to_be16(ETH_P_PAE))) { + if (ieee80211_is_data_qos(fc)) { + u8 tid = rtl_get_tid(skb); + if (_rtl_tx_aggr_check(rtlpriv, sta_entry, + tid)) { + sta_entry->tids[tid].agg.agg_state = + RTL_AGG_PROGRESS; + ieee80211_start_tx_ba_session(sta, tid, + 5000); + } + } + } + } +} + +static void rtl_rate_init(void *ppriv, + struct ieee80211_supported_band *sband, + struct cfg80211_chan_def *chandef, + struct ieee80211_sta *sta, void *priv_sta) +{ +} + +static void *rtl_rate_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + return rtlpriv; +} + +static void rtl_rate_free(void *rtlpriv) +{ + return; +} + +static void *rtl_rate_alloc_sta(void *ppriv, + struct ieee80211_sta *sta, gfp_t gfp) +{ + struct rtl_priv *rtlpriv = ppriv; + struct rtl_rate_priv *rate_priv; + + rate_priv = kzalloc(sizeof(*rate_priv), gfp); + if (!rate_priv) { + RT_TRACE(COMP_ERR, DBG_EMERG, + ("Unable to allocate private rc structure\n")); + return NULL; + } + + rtlpriv->rate_priv = rate_priv; + + return rate_priv; +} + +static void rtl_rate_free_sta(void *rtlpriv, + struct ieee80211_sta *sta, void *priv_sta) +{ + struct rtl_rate_priv *rate_priv = priv_sta; + kfree(rate_priv); +} + +static struct rate_control_ops rtl_rate_ops = { + .name = "rtl_rc", + .alloc = rtl_rate_alloc, + .free = rtl_rate_free, + .alloc_sta = rtl_rate_alloc_sta, + .free_sta = rtl_rate_free_sta, + .rate_init = rtl_rate_init, + .tx_status = rtl_tx_status, + .get_rate = rtl_get_rate, +}; + +int rtl92e_rate_control_register(void) +{ + return ieee80211_rate_control_register(&rtl_rate_ops); +} + +void rtl92e_rate_control_unregister(void) +{ + ieee80211_rate_control_unregister(&rtl_rate_ops); +} diff --git a/drivers/staging/rtl8192ee/rc.h b/drivers/staging/rtl8192ee/rc.h new file mode 100644 index 000000000000..928f570b4b8e --- /dev/null +++ b/drivers/staging/rtl8192ee/rc.h @@ -0,0 +1,47 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#ifndef __RTL_RC_H__ +#define __RTL_RC_H__ + +#define B_MODE_MAX_RIX 3 +#define G_MODE_MAX_RIX 11 +#define A_MODE_MAX_RIX 7 + +/* in mac80211 mcs0-mcs15 is idx0-idx15*/ +#define N_MODE_MCS7_RIX 7 +#define N_MODE_MCS15_RIX 15 + +#define AC_MODE_MCS7_RIX 7 +#define AC_MODE_MCS8_RIX 8 +#define AC_MODE_MCS9_RIX 9 + +struct rtl_rate_priv { + u8 ht_cap; +}; + +int rtl92e_rate_control_register(void); +void rtl92e_rate_control_unregister(void); +#endif diff --git a/drivers/staging/rtl8192ee/regd.c b/drivers/staging/rtl8192ee/regd.c new file mode 100644 index 000000000000..7272fae68ec6 --- /dev/null +++ b/drivers/staging/rtl8192ee/regd.c @@ -0,0 +1,448 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#include "wifi.h" +#include "regd.h" + +static struct country_code_to_enum_rd allcountries[] = { + {COUNTRY_CODE_FCC, "US"}, + {COUNTRY_CODE_IC, "US"}, + {COUNTRY_CODE_ETSI, "EC"}, + {COUNTRY_CODE_SPAIN, "EC"}, + {COUNTRY_CODE_FRANCE, "EC"}, + {COUNTRY_CODE_MKK, "JP"}, + {COUNTRY_CODE_MKK1, "JP"}, + {COUNTRY_CODE_ISRAEL, "EC"}, + {COUNTRY_CODE_TELEC, "JP"}, + {COUNTRY_CODE_MIC, "JP"}, + {COUNTRY_CODE_GLOBAL_DOMAIN, "JP"}, + {COUNTRY_CODE_WORLD_WIDE_13, "EC"}, + {COUNTRY_CODE_TELEC_NETGEAR, "EC"}, +}; + +/* + *Only these channels all allow active + *scan on all world regulatory domains + */ +#define RTL819x_2GHZ_CH01_11 \ + REG_RULE(2412-10, 2462+10, 40, 0, 20, 0) + +/* + *We enable active scan on these a case + *by case basis by regulatory domain + */ +#define RTL819x_2GHZ_CH12_13 \ + REG_RULE(2467-10, 2472+10, 40, 0, 20,\ + NL80211_RRF_PASSIVE_SCAN) + +#define RTL819x_2GHZ_CH14 \ + REG_RULE(2484-10, 2484+10, 40, 0, 20, \ + NL80211_RRF_PASSIVE_SCAN | \ + NL80211_RRF_NO_OFDM) + +/* 5G chan 36 - chan 64*/ +#define RTL819x_5GHZ_5150_5350 \ + REG_RULE(5150-10, 5350+10, 80, 0, 30, \ + NL80211_RRF_PASSIVE_SCAN | \ + NL80211_RRF_NO_IBSS) + +/* 5G chan 100 - chan 165*/ +#define RTL819x_5GHZ_5470_5850 \ + REG_RULE(5470-10, 5850+10, 80, 0, 30, \ + NL80211_RRF_PASSIVE_SCAN | \ + NL80211_RRF_NO_IBSS) + +/* 5G chan 149 - chan 165*/ +#define RTL819x_5GHZ_5725_5850 \ + REG_RULE(5725-10, 5850+10, 80, 0, 30, \ + NL80211_RRF_PASSIVE_SCAN | \ + NL80211_RRF_NO_IBSS) + +#define RTL819x_5GHZ_ALL \ + (RTL819x_5GHZ_5150_5350, RTL819x_5GHZ_5470_5850) + +static const struct ieee80211_regdomain rtl_regdom_11 = { + .n_reg_rules = 1, + .alpha2 = "99", + .reg_rules = { + RTL819x_2GHZ_CH01_11, + } +}; + +static const struct ieee80211_regdomain rtl_regdom_12_13 = { + .n_reg_rules = 2, + .alpha2 = "99", + .reg_rules = { + RTL819x_2GHZ_CH01_11, + RTL819x_2GHZ_CH12_13, + } +}; + +static const struct ieee80211_regdomain rtl_regdom_no_midband = { + .n_reg_rules = 3, + .alpha2 = "99", + .reg_rules = { + RTL819x_2GHZ_CH01_11, + RTL819x_5GHZ_5150_5350, + RTL819x_5GHZ_5725_5850, + } +}; + +static const struct ieee80211_regdomain rtl_regdom_60_64 = { + .n_reg_rules = 3, + .alpha2 = "99", + .reg_rules = { + RTL819x_2GHZ_CH01_11, + RTL819x_2GHZ_CH12_13, + RTL819x_5GHZ_5725_5850, + } +}; + +static const struct ieee80211_regdomain rtl_regdom_14_60_64 = { + .n_reg_rules = 4, + .alpha2 = "99", + .reg_rules = { + RTL819x_2GHZ_CH01_11, + RTL819x_2GHZ_CH12_13, + RTL819x_2GHZ_CH14, + RTL819x_5GHZ_5725_5850, + } +}; + +static const struct ieee80211_regdomain rtl_regdom_14 = { + .n_reg_rules = 3, + .alpha2 = "99", + .reg_rules = { + RTL819x_2GHZ_CH01_11, + RTL819x_2GHZ_CH12_13, + RTL819x_2GHZ_CH14, + } +}; + +static bool _rtl_is_radar_freq(u16 center_freq) +{ + return center_freq >= 5260 && center_freq <= 5700; +} + +static void _rtl_reg_apply_beaconing_flags(struct wiphy *wiphy, + enum nl80211_reg_initiator initiator) +{ + enum ieee80211_band band; + struct ieee80211_supported_band *sband; + const struct ieee80211_reg_rule *reg_rule; + struct ieee80211_channel *ch; + unsigned int i; + + for (band = 0; band < IEEE80211_NUM_BANDS; band++) { + if (!wiphy->bands[band]) + continue; + + sband = wiphy->bands[band]; + + for (i = 0; i < sband->n_channels; i++) { + ch = &sband->channels[i]; + if (_rtl_is_radar_freq(ch->center_freq) || + (ch->flags & IEEE80211_CHAN_RADAR)) + continue; + if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) { + reg_rule = freq_reg_info(wiphy, + ch->center_freq); + if (IS_ERR(reg_rule)) + continue; + + /* + *If 11d had a rule for this channel ensure + *we enable adhoc/beaconing if it allows us to + *use it. Note that we would have disabled it + *by applying our static world regdomain by + *default during init, prior to calling our + *regulatory_hint(). + */ + + if (!(reg_rule->flags & NL80211_RRF_NO_IBSS)) + ch->flags &= ~IEEE80211_CHAN_NO_IBSS; + if (!(reg_rule->flags & + NL80211_RRF_PASSIVE_SCAN)) + ch->flags &= + ~IEEE80211_CHAN_PASSIVE_SCAN; + } else { + if (ch->beacon_found) + ch->flags &= ~(IEEE80211_CHAN_NO_IBSS | + IEEE80211_CHAN_PASSIVE_SCAN); + } + } + } +} + +/* Allows active scan scan on Ch 12 and 13 */ +static void _rtl_reg_apply_active_scan_flags(struct wiphy *wiphy, + enum nl80211_reg_initiator + initiator) +{ + struct ieee80211_supported_band *sband; + struct ieee80211_channel *ch; + const struct ieee80211_reg_rule *reg_rule; + + if (!wiphy->bands[IEEE80211_BAND_2GHZ]) + return; + sband = wiphy->bands[IEEE80211_BAND_2GHZ]; + + /* + *If no country IE has been received always enable active scan + *on these channels. This is only done for specific regulatory SKUs + */ + if (initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE) { + ch = &sband->channels[11]; /* CH 12 */ + if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN) + ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN; + ch = &sband->channels[12]; /* CH 13 */ + if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN) + ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN; + return; + } + + /* + *If a country IE has been recieved check its rule for this + *channel first before enabling active scan. The passive scan + *would have been enforced by the initial processing of our + *custom regulatory domain. + */ + + ch = &sband->channels[11]; /* CH 12 */ + reg_rule = freq_reg_info(wiphy, ch->center_freq); + if (!IS_ERR(reg_rule)) { + if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN)) + if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN) + ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN; + } + + ch = &sband->channels[12]; /* CH 13 */ + reg_rule = freq_reg_info(wiphy, ch->center_freq); + if (!IS_ERR(reg_rule)) { + if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN)) + if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN) + ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN; + } +} + +/* + *Always apply Radar/DFS rules on + *freq range 5260 MHz - 5700 MHz + */ +static void _rtl_reg_apply_radar_flags(struct wiphy *wiphy) +{ + struct ieee80211_supported_band *sband; + struct ieee80211_channel *ch; + unsigned int i; + + if (!wiphy->bands[IEEE80211_BAND_5GHZ]) + return; + + sband = wiphy->bands[IEEE80211_BAND_5GHZ]; + + for (i = 0; i < sband->n_channels; i++) { + ch = &sband->channels[i]; + if (!_rtl_is_radar_freq(ch->center_freq)) + continue; + + /* + *We always enable radar detection/DFS on this + *frequency range. Additionally we also apply on + *this frequency range: + *- If STA mode does not yet have DFS supports disable + * active scanning + *- If adhoc mode does not support DFS yet then disable + * adhoc in the frequency. + *- If AP mode does not yet support radar detection/DFS + *do not allow AP mode + */ + if (!(ch->flags & IEEE80211_CHAN_DISABLED)) + ch->flags |= IEEE80211_CHAN_RADAR | + IEEE80211_CHAN_NO_IBSS | + IEEE80211_CHAN_PASSIVE_SCAN; + } +} + +static void _rtl_reg_apply_world_flags(struct wiphy *wiphy, + enum nl80211_reg_initiator initiator, + struct rtl_regulatory *reg) +{ + _rtl_reg_apply_beaconing_flags(wiphy, initiator); + _rtl_reg_apply_active_scan_flags(wiphy, initiator); + return; +} + +static void _rtl_dump_channel_map(struct wiphy *wiphy) +{ + enum ieee80211_band band; + struct ieee80211_supported_band *sband; + struct ieee80211_channel *ch; + unsigned int i; + + for (band = 0; band < IEEE80211_NUM_BANDS; band++) { + if (!wiphy->bands[band]) + continue; + sband = wiphy->bands[band]; + for (i = 0; i < sband->n_channels; i++) + ch = &sband->channels[i]; + } +} + +static int _rtl92e_reg_notifier_apply(struct wiphy *wiphy, + struct regulatory_request *request, + struct rtl_regulatory *reg) +{ + /* We always apply this */ + _rtl_reg_apply_radar_flags(wiphy); + + switch (request->initiator) { + case NL80211_REGDOM_SET_BY_DRIVER: + case NL80211_REGDOM_SET_BY_CORE: + case NL80211_REGDOM_SET_BY_USER: + break; + case NL80211_REGDOM_SET_BY_COUNTRY_IE: + _rtl_reg_apply_world_flags(wiphy, request->initiator, reg); + break; + } + + _rtl_dump_channel_map(wiphy); + + return 0; +} + +static const struct ieee80211_regdomain *_rtl_regdomain_select( + struct rtl_regulatory *reg) +{ + switch (reg->country_code) { + case COUNTRY_CODE_FCC: + return &rtl_regdom_no_midband; + case COUNTRY_CODE_IC: + return &rtl_regdom_11; + case COUNTRY_CODE_ETSI: + case COUNTRY_CODE_TELEC_NETGEAR: + return &rtl_regdom_60_64; + case COUNTRY_CODE_SPAIN: + case COUNTRY_CODE_FRANCE: + case COUNTRY_CODE_ISRAEL: + case COUNTRY_CODE_WORLD_WIDE_13: + return &rtl_regdom_12_13; + case COUNTRY_CODE_MKK: + case COUNTRY_CODE_MKK1: + case COUNTRY_CODE_TELEC: + case COUNTRY_CODE_MIC: + return &rtl_regdom_14_60_64; + case COUNTRY_CODE_GLOBAL_DOMAIN: + return &rtl_regdom_14; + default: + return &rtl_regdom_no_midband; + } +} + +static int _rtl92e_regd_init_wiphy(struct rtl_regulatory *reg, + struct wiphy *wiphy, + void (*reg_notifier)(struct wiphy *wiphy, + struct regulatory_request * + request)) +{ + const struct ieee80211_regdomain *regd; + + wiphy->reg_notifier = reg_notifier; + + wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG; + wiphy->regulatory_flags &= ~REGULATORY_STRICT_REG; + wiphy->regulatory_flags &= ~REGULATORY_DISABLE_BEACON_HINTS; + + regd = _rtl_regdomain_select(reg); + wiphy_apply_custom_regulatory(wiphy, regd); + _rtl_reg_apply_radar_flags(wiphy); + _rtl_reg_apply_world_flags(wiphy, NL80211_REGDOM_SET_BY_DRIVER, reg); + return 0; +} + +static struct country_code_to_enum_rd *_rtl_regd_find_country(u16 countrycode) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(allcountries); i++) { + if (allcountries[i].countrycode == countrycode) + return &allcountries[i]; + } + return NULL; +} + +int rtl92e_regd_init(struct ieee80211_hw *hw, + void (*reg_notifier)(struct wiphy *wiphy, + struct regulatory_request *request)) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct wiphy *wiphy = hw->wiphy; + struct country_code_to_enum_rd *country = NULL; + + if (wiphy == NULL || &rtlpriv->regd == NULL) + return -EINVAL; + + /* init country_code from efuse channel plan */ + rtlpriv->regd.country_code = rtlpriv->efuse.channel_plan; + + RT_TRACE(COMP_REGD, DBG_TRACE, + (KERN_DEBUG "rtl: EEPROM regdomain: 0x%0x\n", + rtlpriv->regd.country_code)); + + if (rtlpriv->regd.country_code >= COUNTRY_CODE_MAX) { + RT_TRACE(COMP_REGD, DBG_DMESG, + ("rtl: EEPROM indicates invalid contry code world wide 13 should be used\n")); + + rtlpriv->regd.country_code = COUNTRY_CODE_WORLD_WIDE_13; + } + + country = _rtl_regd_find_country(rtlpriv->regd.country_code); + + if (country) { + rtlpriv->regd.alpha2[0] = country->iso_name[0]; + rtlpriv->regd.alpha2[1] = country->iso_name[1]; + } else { + rtlpriv->regd.alpha2[0] = '0'; + rtlpriv->regd.alpha2[1] = '0'; + } + + RT_TRACE(COMP_REGD, DBG_TRACE, + (KERN_DEBUG "rtl: Country alpha2 being used: %c%c\n", + rtlpriv->regd.alpha2[0], rtlpriv->regd.alpha2[1])); + + _rtl92e_regd_init_wiphy(&rtlpriv->regd, wiphy, reg_notifier); + + return 0; +} + +void rtl92e_reg_notifier(struct wiphy *wiphy, + struct regulatory_request *request) +{ + struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); + struct rtl_priv *rtlpriv = rtl_priv(hw); + + RT_TRACE(COMP_REGD, DBG_LOUD, ("\n")); + + _rtl92e_reg_notifier_apply(wiphy, request, &rtlpriv->regd); +} diff --git a/drivers/staging/rtl8192ee/regd.h b/drivers/staging/rtl8192ee/regd.h new file mode 100644 index 000000000000..1f26f0e5261f --- /dev/null +++ b/drivers/staging/rtl8192ee/regd.h @@ -0,0 +1,63 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#ifndef __RTL_REGD_H__ +#define __RTL_REGD_H__ + +/* for kernel 3.14 , both value are changed to IEEE80211_CHAN_NO_IR*/ +#define IEEE80211_CHAN_NO_IBSS IEEE80211_CHAN_NO_IR +#define IEEE80211_CHAN_PASSIVE_SCAN IEEE80211_CHAN_NO_IR + +struct country_code_to_enum_rd { + u16 countrycode; + const char *iso_name; +}; + +enum country_code_type_t { + COUNTRY_CODE_FCC = 0, + COUNTRY_CODE_IC = 1, + COUNTRY_CODE_ETSI = 2, + COUNTRY_CODE_SPAIN = 3, + COUNTRY_CODE_FRANCE = 4, + COUNTRY_CODE_MKK = 5, + COUNTRY_CODE_MKK1 = 6, + COUNTRY_CODE_ISRAEL = 7, + COUNTRY_CODE_TELEC = 8, + COUNTRY_CODE_MIC = 9, + COUNTRY_CODE_GLOBAL_DOMAIN = 10, + COUNTRY_CODE_WORLD_WIDE_13 = 11, + COUNTRY_CODE_TELEC_NETGEAR = 12, + + /*add new channel plan above this line */ + COUNTRY_CODE_MAX +}; + +int rtl92e_regd_init(struct ieee80211_hw *hw, + void (*reg_notifier)(struct wiphy *wiphy, + struct regulatory_request *request)); +void rtl92e_reg_notifier(struct wiphy *wiphy, + struct regulatory_request *request); + +#endif diff --git a/drivers/staging/rtl8192ee/stats.c b/drivers/staging/rtl8192ee/stats.c new file mode 100644 index 000000000000..7ac302b1a71f --- /dev/null +++ b/drivers/staging/rtl8192ee/stats.c @@ -0,0 +1,290 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ +#include "wifi.h" +#include "stats.h" + +u8 stg_rtl_query_rxpwrpercentage(char antpower) +{ + if ((antpower <= -100) || (antpower >= 20)) + return 0; + else if (antpower >= 0) + return 100; + else + return 100 + antpower; +} +EXPORT_SYMBOL(stg_rtl_query_rxpwrpercentage); + +u8 stg_rtl_evm_db_to_percentage(char value) +{ + char ret_val; + ret_val = value; + + if (ret_val >= 0) + ret_val = 0; + if (ret_val <= -33) + ret_val = -33; + ret_val = 0 - ret_val; + ret_val *= 3; + if (ret_val == 99) + ret_val = 100; + + return ret_val; +} +EXPORT_SYMBOL(stg_rtl_evm_db_to_percentage); + +u8 rtl_evm_dbm_jaguar(char value) +{ + char ret_val; + ret_val = value; + + /* -33dB~0dB to 33dB ~ 0dB*/ + if (ret_val == -128) + ret_val = 127; + else if (ret_val < 0) + ret_val = 0 - ret_val; + + ret_val = ret_val >> 1; + return ret_val; +} +EXPORT_SYMBOL(rtl_evm_dbm_jaguar); + +static long rtl_translate_todbm(struct ieee80211_hw *hw, + u8 signal_strength_index) +{ + long signal_power; + + signal_power = (long)((signal_strength_index + 1) >> 1); + signal_power -= 95; + return signal_power; +} + +long stg_rtl_signal_scale_mapping(struct ieee80211_hw *hw, long currsig) +{ + long retsig; + + if (currsig >= 61 && currsig <= 100) + retsig = 90 + ((currsig - 60) / 4); + else if (currsig >= 41 && currsig <= 60) + retsig = 78 + ((currsig - 40) / 2); + else if (currsig >= 31 && currsig <= 40) + retsig = 66 + (currsig - 30); + else if (currsig >= 21 && currsig <= 30) + retsig = 54 + (currsig - 20); + else if (currsig >= 5 && currsig <= 20) + retsig = 42 + (((currsig - 5) * 2) / 3); + else if (currsig == 4) + retsig = 36; + else if (currsig == 3) + retsig = 27; + else if (currsig == 2) + retsig = 18; + else if (currsig == 1) + retsig = 9; + else + retsig = currsig; + + return retsig; +} +EXPORT_SYMBOL(stg_rtl_signal_scale_mapping); + +static void rtl_process_ui_rssi(struct ieee80211_hw *hw, struct rtl_stats *pstatus) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + u8 rfpath; + u32 last_rssi, tmpval; + + if (!pstatus->b_packet_toself && !pstatus->b_packet_beacon) + return; + + rtlpriv->stats.pwdb_all_cnt += pstatus->rx_pwdb_all; + rtlpriv->stats.rssi_calculate_cnt++; + + if (rtlpriv->stats.ui_rssi.total_num++ >= PHY_RSSI_SLID_WIN_MAX) { + rtlpriv->stats.ui_rssi.total_num = PHY_RSSI_SLID_WIN_MAX; + last_rssi = rtlpriv->stats.ui_rssi.elements[ + rtlpriv->stats.ui_rssi.index]; + rtlpriv->stats.ui_rssi.total_val -= last_rssi; + } + rtlpriv->stats.ui_rssi.total_val += pstatus->signalstrength; + rtlpriv->stats.ui_rssi.elements[rtlpriv->stats.ui_rssi.index++] = + pstatus->signalstrength; + if (rtlpriv->stats.ui_rssi.index >= PHY_RSSI_SLID_WIN_MAX) + rtlpriv->stats.ui_rssi.index = 0; + tmpval = rtlpriv->stats.ui_rssi.total_val / + rtlpriv->stats.ui_rssi.total_num; + rtlpriv->stats.signal_strength = rtl_translate_todbm(hw, + (u8) tmpval); + pstatus->rssi = rtlpriv->stats.signal_strength; + + if (pstatus->b_is_cck) + return; + + for (rfpath = RF90_PATH_A; rfpath < rtlphy->num_total_rfpath; + rfpath++) { + if (rtlpriv->stats.rx_rssi_percentage[rfpath] == 0) { + rtlpriv->stats.rx_rssi_percentage[rfpath] = + pstatus->rx_mimo_signalstrength[rfpath]; + } + if (pstatus->rx_mimo_signalstrength[rfpath] > + rtlpriv->stats.rx_rssi_percentage[rfpath]) { + rtlpriv->stats.rx_rssi_percentage[rfpath] = + ((rtlpriv->stats.rx_rssi_percentage[rfpath] * + (RX_SMOOTH_FACTOR - 1)) + + (pstatus->rx_mimo_signalstrength[rfpath])) / + (RX_SMOOTH_FACTOR); + rtlpriv->stats.rx_rssi_percentage[rfpath] = + rtlpriv->stats.rx_rssi_percentage[rfpath] + 1; + } else { + rtlpriv->stats.rx_rssi_percentage[rfpath] = + ((rtlpriv->stats.rx_rssi_percentage[rfpath] * + (RX_SMOOTH_FACTOR - 1)) + + (pstatus->rx_mimo_signalstrength[rfpath])) / + (RX_SMOOTH_FACTOR); + } + rtlpriv->stats.rx_snr_db[rfpath] = pstatus->rx_snr[rfpath]; + rtlpriv->stats.rx_evm_dbm[rfpath] = + pstatus->rx_mimo_evm_dbm[rfpath]; + rtlpriv->stats.rx_cfo_short[rfpath] = + pstatus->cfo_short[rfpath]; + rtlpriv->stats.rx_cfo_tail[rfpath] = pstatus->cfo_tail[rfpath]; + } +} + +static void rtl_update_rxsignalstatistics(struct ieee80211_hw *hw, + struct rtl_stats *pstatus) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + int weighting = 0; + + if (rtlpriv->stats.recv_signal_power == 0) + rtlpriv->stats.recv_signal_power = pstatus->recvsignalpower; + if (pstatus->recvsignalpower > rtlpriv->stats.recv_signal_power) + weighting = 5; + else if (pstatus->recvsignalpower < rtlpriv->stats.recv_signal_power) + weighting = (-5); + rtlpriv->stats.recv_signal_power = (rtlpriv->stats.recv_signal_power * + 5 + pstatus->recvsignalpower + weighting) / 6; +} + +static void rtl_process_pwdb(struct ieee80211_hw *hw, struct rtl_stats *pstatus) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_sta_info *drv_priv = NULL; + struct ieee80211_sta *sta = NULL; + long undecorated_smoothed_pwdb; + + rcu_read_lock(); + if (rtlpriv->mac80211.opmode != NL80211_IFTYPE_STATION) + sta = rtl_find_sta(hw, pstatus->psaddr); + + /* adhoc or ap mode */ + if (sta) { + drv_priv = (struct rtl_sta_info *)sta->drv_priv; + undecorated_smoothed_pwdb = + drv_priv->rssi_stat.undecorated_smoothed_pwdb; + } else { + undecorated_smoothed_pwdb = + rtlpriv->dm.undecorated_smoothed_pwdb; + } + + if (undecorated_smoothed_pwdb < 0) + undecorated_smoothed_pwdb = pstatus->rx_pwdb_all; + if (pstatus->rx_pwdb_all > (u32) undecorated_smoothed_pwdb) { + undecorated_smoothed_pwdb = (((undecorated_smoothed_pwdb) * + (RX_SMOOTH_FACTOR - 1)) + + (pstatus->rx_pwdb_all)) / (RX_SMOOTH_FACTOR); + undecorated_smoothed_pwdb = undecorated_smoothed_pwdb + 1; + } else { + undecorated_smoothed_pwdb = (((undecorated_smoothed_pwdb) * + (RX_SMOOTH_FACTOR - 1)) + + (pstatus->rx_pwdb_all)) / (RX_SMOOTH_FACTOR); + } + + if (sta) { + drv_priv->rssi_stat.undecorated_smoothed_pwdb = + undecorated_smoothed_pwdb; + } else { + rtlpriv->dm.undecorated_smoothed_pwdb = undecorated_smoothed_pwdb; + } + rcu_read_unlock(); + + rtl_update_rxsignalstatistics(hw, pstatus); +} + +static void rtl_process_ui_link_quality(struct ieee80211_hw *hw, + struct rtl_stats *pstatus) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u32 last_evm, n_stream, tmpval; + + if (pstatus->signalquality == 0) + return; + + if (rtlpriv->stats.ui_link_quality.total_num++ >= + PHY_LINKQUALITY_SLID_WIN_MAX) { + rtlpriv->stats.ui_link_quality.total_num = + PHY_LINKQUALITY_SLID_WIN_MAX; + last_evm = rtlpriv->stats.ui_link_quality.elements[ + rtlpriv->stats.ui_link_quality.index]; + rtlpriv->stats.ui_link_quality.total_val -= last_evm; + } + rtlpriv->stats.ui_link_quality.total_val += pstatus->signalquality; + rtlpriv->stats.ui_link_quality.elements[ + rtlpriv->stats.ui_link_quality.index++] = + pstatus->signalquality; + if (rtlpriv->stats.ui_link_quality.index >= + PHY_LINKQUALITY_SLID_WIN_MAX) + rtlpriv->stats.ui_link_quality.index = 0; + tmpval = rtlpriv->stats.ui_link_quality.total_val / + rtlpriv->stats.ui_link_quality.total_num; + rtlpriv->stats.signal_quality = tmpval; + rtlpriv->stats.last_sigstrength_inpercent = tmpval; + for (n_stream = 0; n_stream < 2; n_stream++) { + if (pstatus->rx_mimo_signalquality[n_stream] != -1) { + if (rtlpriv->stats.rx_evm_percentage[n_stream] == 0) { + rtlpriv->stats.rx_evm_percentage[n_stream] = + pstatus->rx_mimo_signalquality[n_stream]; + } + rtlpriv->stats.rx_evm_percentage[n_stream] = + ((rtlpriv->stats.rx_evm_percentage[n_stream] + * (RX_SMOOTH_FACTOR - 1)) + + (pstatus->rx_mimo_signalquality[n_stream] * 1)) / + (RX_SMOOTH_FACTOR); + } + } +} + +void stg_rtl_process_phyinfo(struct ieee80211_hw *hw, u8 *buffer, + struct rtl_stats *pstatus) +{ + if (!pstatus->b_packet_matchbssid) + return; + + rtl_process_ui_rssi(hw, pstatus); + rtl_process_pwdb(hw, pstatus); + rtl_process_ui_link_quality(hw, pstatus); +} +EXPORT_SYMBOL(stg_rtl_process_phyinfo); diff --git a/drivers/staging/rtl8192ee/stats.h b/drivers/staging/rtl8192ee/stats.h new file mode 100644 index 000000000000..072842785308 --- /dev/null +++ b/drivers/staging/rtl8192ee/stats.h @@ -0,0 +1,43 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#ifndef __RTL_STATS_H__ +#define __RTL_STATS_H__ + +#define PHY_RSSI_SLID_WIN_MAX 100 +#define PHY_LINKQUALITY_SLID_WIN_MAX 20 +#define PHY_BEACON_RSSI_SLID_WIN_MAX 10 + +/* Rx smooth factor */ +#define RX_SMOOTH_FACTOR 20 + +u8 stg_rtl_query_rxpwrpercentage(char antpower); +u8 stg_rtl_evm_db_to_percentage(char value); +u8 rtl_evm_dbm_jaguar(char value); +long stg_rtl_signal_scale_mapping(struct ieee80211_hw *hw, long currsig); +void stg_rtl_process_phyinfo(struct ieee80211_hw *hw, u8 *buffer, + struct rtl_stats *pstatus); + +#endif diff --git a/drivers/staging/rtl8192ee/wifi.h b/drivers/staging/rtl8192ee/wifi.h new file mode 100644 index 000000000000..9cb08116d384 --- /dev/null +++ b/drivers/staging/rtl8192ee/wifi.h @@ -0,0 +1,2645 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#ifndef __RTL_WIFI_H__ +#define __RTL_WIFI_H__ + +#include +#include +#include +#include +#include +#include +#include "debug.h" + + +#define RF_CHANGE_BY_INIT 0 +#define RF_CHANGE_BY_IPS BIT(28) +#define RF_CHANGE_BY_PS BIT(29) +#define RF_CHANGE_BY_HW BIT(30) +#define RF_CHANGE_BY_SW BIT(31) + +#define IQK_ADDA_REG_NUM 16 +#define IQK_MAC_REG_NUM 4 +#define IQK_THRESHOLD 8 + +#define MAX_KEY_LEN 61 +#define KEY_BUF_SIZE 5 + +/* QoS related. */ +/*aci: 0x00 Best Effort*/ +/*aci: 0x01 Background*/ +/*aci: 0x10 Video*/ +/*aci: 0x11 Voice*/ +/*Max: define total number.*/ +#define AC0_BE 0 +#define AC1_BK 1 +#define AC2_VI 2 +#define AC3_VO 3 +#define AC_MAX 4 +#define QOS_QUEUE_NUM 4 +#define RTL_MAC80211_NUM_QUEUE 5 + +#define QBSS_LOAD_SIZE 5 +#define MAX_WMMELE_LENGTH 64 + +#define TOTAL_CAM_ENTRY 32 + +/*slot time for 11g. */ +#define RTL_SLOT_TIME_9 9 +#define RTL_SLOT_TIME_20 20 + +/*related with tcp/ip. */ +/*if_ehther.h*/ +#define ETH_P_PAE 0x888E /*Port Access Entity + *(IEEE 802.1X) */ +#define ETH_P_IP 0x0800 /*Internet Protocol packet */ +#define ETH_P_ARP 0x0806 /*Address Resolution packet */ +#define SNAP_SIZE 6 +#define PROTOC_TYPE_SIZE 2 + +/*related with 802.11 frame*/ +#define MAC80211_3ADDR_LEN 24 +#define MAC80211_4ADDR_LEN 30 + +#define CHANNEL_MAX_NUMBER (14 + 24 + 21) /* 14 is the max + * channel number */ +#define CHANNEL_MAX_NUMBER_2G 14 +#define CHANNEL_MAX_NUMBER_5G 54 /* Please refer to + *"phy_GetChnlGroup8812A" and + * "Hal_ReadTxPowerInfo8812A"*/ + +#define MAX_REGULATION_NUM 4 +#define MAX_RF_PATH_NUM 2 +#define MAX_RATE_SECTION_NUM 6 +#define MAX_2_4G_BANDWITH_NUM 2 +#define MAX_5G_BANDWITH_NUM 4 + + + + +#define CHANNEL_MAX_NUMBER_5G_80M 7 +#define CHANNEL_GROUP_MAX (3 + 9) /* ch1~3, ch4~9, ch10~14 + * total three groups */ +#define MAX_PG_GROUP 13 +#define CHANNEL_GROUP_MAX_2G 3 +#define CHANNEL_GROUP_IDX_5GL 3 +#define CHANNEL_GROUP_IDX_5GM 6 +#define CHANNEL_GROUP_IDX_5GH 9 +#define CHANNEL_GROUP_MAX_5G 9 +#define CHANNEL_MAX_NUMBER_2G 14 +#define AVG_THERMAL_NUM 8 +#define AVG_THERMAL_NUM_92E 4 +#define AVG_THERMAL_NUM_88E 4 +#define AVG_THERMAL_NUM_8723BE 4 +#define MAX_TID_COUNT 9 +#define MAX_NUM_RATES 264 + +/*for 88E use*/ +/*It must always set to 4, otherwise read efuse table secquence will be wrong.*/ +#define MAX_TX_COUNT 4 +#define MAX_RF_PATH 4 +#define MAX_CHNL_GROUP_24G 6 +#define MAX_CHNL_GROUP_5G 14 + +/* BK, BE, VI, VO, HCCA, MANAGEMENT, COMMAND, HIGH, BEACON. */ +#define MAX_TX_QUEUE 9 + +#define TX_PWR_BY_RATE_NUM_BAND 2 +#define TX_PWR_BY_RATE_NUM_RF 4 +#define TX_PWR_BY_RATE_NUM_SECTION 12 +#define MAX_BASE_NUM_IN_PHY_REG_PG_24G 6 +#define MAX_BASE_NUM_IN_PHY_REG_PG_5G 5 + +#define DELTA_SWINGIDX_SIZE 30 +#define BAND_NUM 3 +/*Now, it's just for 8192ee + *not OK yet, keep it 0*/ +#define DMA_IS_64BIT 0 +#define RTL8192EE_SEG_NUM 1 /* 0:2 seg, 1: 4 seg, 2: 8 seg */ + + +#define PACKET_NORMAL 0 +#define PACKET_DHCP 1 +#define PACKET_ARP 2 +#define PACKET_EAPOL 3 + +#define MAX_SUPPORT_WOL_PATTERN_NUM 16 +#define RSVD_WOL_PATTERN_NUM 1 +#define WKFMCAM_ADDR_NUM 6 +#define WKFMCAM_SIZE 24 + +#define MAX_WOL_BIT_MASK_SIZE 16 +/* MIN LEN keeps 13 here */ +#define MIN_WOL_PATTERN_SIZE 13 +#define MAX_WOL_PATTERN_SIZE 128 + +#define WAKE_ON_MAGIC_PACKET BIT(0) +#define WAKE_ON_PATTERN_MATCH BIT(1) + +#define WOL_REASON_PTK_UPDATE BIT(0) +#define WOL_REASON_GTK_UPDATE BIT(1) +#define WOL_REASON_DISASSOC BIT(2) +#define WOL_REASON_DEAUTH BIT(3) +#define WOL_REASON_AP_LOST BIT(4) +#define WOL_REASON_MAGIC_PKT BIT(5) +#define WOL_REASON_UNICAST_PKT BIT(6) +#define WOL_REASON_PATTERN_PKT BIT(7) +#define WOL_REASON_RTD3_SSID_MATCH BIT(8) +#define WOL_REASON_REALWOW_V2_WAKEUPPKT BIT(9) +#define WOL_REASON_REALWOW_V2_ACKLOST BIT(10) + +struct txpower_info_2g { + u8 index_cck_base[MAX_RF_PATH][MAX_CHNL_GROUP_24G]; + u8 index_bw40_base[MAX_RF_PATH][MAX_CHNL_GROUP_24G]; + /*If only one tx, only BW20 and OFDM are used.*/ + u8 cck_diff[MAX_RF_PATH][MAX_TX_COUNT]; + u8 ofdm_diff[MAX_RF_PATH][MAX_TX_COUNT]; + u8 bw20_diff[MAX_RF_PATH][MAX_TX_COUNT]; + u8 bw40_diff[MAX_RF_PATH][MAX_TX_COUNT]; +}; + +struct txpower_info_5g { + u8 index_bw40_base[MAX_RF_PATH][MAX_CHNL_GROUP_5G]; + /*If only one tx, only BW20, OFDM, BW80 and BW160 are used.*/ + u8 ofdm_diff[MAX_RF_PATH][MAX_TX_COUNT]; + u8 bw20_diff[MAX_RF_PATH][MAX_TX_COUNT]; + u8 bw40_diff[MAX_RF_PATH][MAX_TX_COUNT]; + u8 bw80_diff[MAX_RF_PATH][MAX_TX_COUNT]; + u8 bw160_diff[MAX_RF_PATH][MAX_TX_COUNT]; +}; + + +/* for early mode */ +#define EM_HDR_LEN 8 +#define FCS_LEN 4 + +#define MAX_VIRTUAL_MAC 1 + +enum rf_tx_num { + RF_1TX = 0, + RF_2TX, + RF_MAX_TX_NUM, + RF_TX_NUM_NONIMPLEMENT, +}; + +enum rate_section { + CCK = 0, + OFDM, + HT_MCS0_MCS7, + HT_MCS8_MCS15, + VHT_1SSMCS0_1SSMCS9, + VHT_2SSMCS0_2SSMCS9, +}; + +enum intf_type { + INTF_PCI = 0, + INTF_USB = 1, +}; + +enum radio_path { + RF90_PATH_A = 0, + RF90_PATH_B = 1, + RF90_PATH_C = 2, + RF90_PATH_D = 3, +}; + +enum regulation_txpwr_lmt { + TXPWR_LMT_FCC = 0, + TXPWR_LMT_MKK = 1, + TXPWR_LMT_ETSI = 2, + TXPWR_LMT_WW = 3, + + TXPWR_LMT_MAX_REGULATION_NUM = 4 +}; + + +enum rt_eeprom_type { + EEPROM_93C46, + EEPROM_93C56, + EEPROM_BOOT_EFUSE, +}; + +enum rtl_status { + RTL_STATUS_INTERFACE_START = 0, +}; + +enum hardware_type { + HARDWARE_TYPE_RTL8192E, + HARDWARE_TYPE_RTL8192U, + HARDWARE_TYPE_RTL8192SE, + HARDWARE_TYPE_RTL8192SU, + HARDWARE_TYPE_RTL8192CE, + HARDWARE_TYPE_RTL8192CU, + HARDWARE_TYPE_RTL8192DE, + HARDWARE_TYPE_RTL8192DU, + HARDWARE_TYPE_RTL8723AE, + HARDWARE_TYPE_RTL8188EE, + HARDWARE_TYPE_RTL8723BE, + HARDWARE_TYPE_RTL8192EE, + HARDWARE_TYPE_RTL8821AE, + HARDWARE_TYPE_RTL8812AE, + /* keep it last */ + HARDWARE_TYPE_NUM +}; + +enum scan_operation_backup_opt { + SCAN_OPT_BACKUP_BAND0 = 0, + SCAN_OPT_BACKUP_BAND1, + SCAN_OPT_RESTORE, + SCAN_OPT_MAX +}; + +/*RF state.*/ +enum rf_pwrstate { + ERFON, + ERFSLEEP, + ERFOFF +}; + +struct bb_reg_def { + u32 rfintfs; + u32 rfintfi; + u32 rfintfo; + u32 rfintfe; + u32 rf3wire_offset; + u32 rflssi_select; + u32 rftxgain_stage; + u32 rfhssi_para1; + u32 rfhssi_para2; + u32 rfswitch_control; + u32 rfagc_control1; + u32 rfagc_control2; + u32 rfrxiq_imbalance; + u32 rfrx_afe; + u32 rftxiq_imbalance; + u32 rftx_afe; + u32 rflssi_readback; + u32 rflssi_readbackpi; +}; + +enum io_type { + IO_CMD_PAUSE_BAND0_DM_BY_SCAN = 0, + IO_CMD_PAUSE_BAND1_DM_BY_SCAN = 1, + IO_CMD_RESUME_DM_BY_SCAN = 2, +}; + +enum hw_variables { + HW_VAR_ETHER_ADDR, + HW_VAR_MULTICAST_REG, + HW_VAR_BASIC_RATE, + HW_VAR_BSSID, + HW_VAR_MEDIA_STATUS, + HW_VAR_SECURITY_CONF, + HW_VAR_BEACON_INTERVAL, + HW_VAR_ATIM_WINDOW, + HW_VAR_LISTEN_INTERVAL, + HW_VAR_CS_COUNTER, + HW_VAR_DEFAULTKEY0, + HW_VAR_DEFAULTKEY1, + HW_VAR_DEFAULTKEY2, + HW_VAR_DEFAULTKEY3, + HW_VAR_SIFS, + HW_VAR_R2T_SIFS, + HW_VAR_DIFS, + HW_VAR_EIFS, + HW_VAR_SLOT_TIME, + HW_VAR_ACK_PREAMBLE, + HW_VAR_CW_CONFIG, + HW_VAR_CW_VALUES, + HW_VAR_RATE_FALLBACK_CONTROL, + HW_VAR_CONTENTION_WINDOW, + HW_VAR_RETRY_COUNT, + HW_VAR_TR_SWITCH, + HW_VAR_COMMAND, + HW_VAR_WPA_CONFIG, + HW_VAR_AMPDU_MIN_SPACE, + HW_VAR_SHORTGI_DENSITY, + HW_VAR_AMPDU_FACTOR, + HW_VAR_MCS_RATE_AVAILABLE, + HW_VAR_AC_PARAM, + HW_VAR_ACM_CTRL, + HW_VAR_DIS_Req_Qsize, + HW_VAR_CCX_CHNL_LOAD, + HW_VAR_CCX_NOISE_HISTOGRAM, + HW_VAR_CCX_CLM_NHM, + HW_VAR_TxOPLimit, + HW_VAR_TURBO_MODE, + HW_VAR_RF_STATE, + HW_VAR_RF_OFF_BY_HW, + HW_VAR_BUS_SPEED, + HW_VAR_SET_DEV_POWER, + + HW_VAR_RCR, + HW_VAR_RATR_0, + HW_VAR_RRSR, + HW_VAR_CPU_RST, + HW_VAR_CECHK_BSSID, + HW_VAR_LBK_MODE, + HW_VAR_AES_11N_FIX, + HW_VAR_USB_RX_AGGR, + HW_VAR_USER_CONTROL_TURBO_MODE, + HW_VAR_RETRY_LIMIT, + HW_VAR_INIT_TX_RATE, + HW_VAR_TX_RATE_REG, + HW_VAR_EFUSE_USAGE, + HW_VAR_EFUSE_BYTES, + HW_VAR_AUTOLOAD_STATUS, + HW_VAR_RF_2R_DISABLE, + HW_VAR_SET_RPWM, + HW_VAR_H2C_FW_PWRMODE, + HW_VAR_H2C_FW_JOINBSSRPT, + HW_VAR_H2C_FW_MEDIASTATUSRPT, + HW_VAR_H2C_FW_P2P_PS_OFFLOAD, + HW_VAR_FW_PSMODE_STATUS, + HW_VAR_INIT_RTS_RATE, + HW_VAR_RESUME_CLK_ON, + HW_VAR_FW_LPS_ACTION, + HW_VAR_1X1_RECV_COMBINE, + HW_VAR_STOP_SEND_BEACON, + HW_VAR_TSF_TIMER, + HW_VAR_IO_CMD, + + HW_VAR_RF_RECOVERY, + HW_VAR_H2C_FW_UPDATE_GTK, + HW_VAR_WF_MASK, + HW_VAR_WF_CRC, + HW_VAR_WF_IS_MAC_ADDR, + HW_VAR_H2C_FW_OFFLOAD, + HW_VAR_RESET_WFCRC, + + HW_VAR_HANDLE_FW_C2H, + HW_VAR_DL_FW_RSVD_PAGE, + HW_VAR_AID, + HW_VAR_HW_SEQ_ENABLE, + HW_VAR_CORRECT_TSF, + HW_VAR_BCN_VALID, + HW_VAR_FWLPS_RF_ON, + HW_VAR_DUAL_TSF_RST, + HW_VAR_SWITCH_EPHY_WoWLAN, + HW_VAR_INT_MIGRATION, + HW_VAR_INT_AC, + HW_VAR_RF_TIMING, + + HAL_DEF_WOWLAN, + HW_VAR_MRC, + HW_VAR_KEEP_ALIVE, + HW_VAR_NAV_UPPER, +}; + +enum rt_media_status { + RT_MEDIA_DISCONNECT = 0, + RT_MEDIA_CONNECT = 1 +}; + +enum rt_oem_id { + RT_CID_DEFAULT = 0, + RT_CID_8187_ALPHA0 = 1, + RT_CID_8187_SERCOMM_PS = 2, + RT_CID_8187_HW_LED = 3, + RT_CID_8187_NETGEAR = 4, + RT_CID_WHQL = 5, + RT_CID_819x_CAMEO = 6, + RT_CID_819x_RUNTOP = 7, + RT_CID_819x_Senao = 8, + RT_CID_TOSHIBA = 9, + RT_CID_819x_Netcore = 10, + RT_CID_Nettronix = 11, + RT_CID_DLINK = 12, + RT_CID_PRONET = 13, + RT_CID_COREGA = 14, + RT_CID_819x_ALPHA = 15, + RT_CID_819x_Sitecom = 16, + RT_CID_CCX = 17, + RT_CID_819x_Lenovo = 18, + RT_CID_819x_QMI = 19, + RT_CID_819x_Edimax_Belkin = 20, + RT_CID_819x_Sercomm_Belkin = 21, + RT_CID_819x_CAMEO1 = 22, + RT_CID_819x_MSI = 23, + RT_CID_819x_Acer = 24, + RT_CID_819x_HP = 27, + RT_CID_819x_CLEVO = 28, + RT_CID_819x_Arcadyan_Belkin = 29, + RT_CID_819x_SAMSUNG = 30, + RT_CID_819x_WNC_COREGA = 31, + RT_CID_819x_Foxcoon = 32, + RT_CID_819x_DELL = 33, + RT_CID_819x_PRONETS = 34, + RT_CID_819x_Edimax_ASUS = 35, + RT_CID_NETGEAR = 36, + RT_CID_PLANEX = 37, + RT_CID_CC_C = 38, +}; + +enum hw_descs { + HW_DESC_OWN, + HW_DESC_RXOWN, + HW_DESC_TX_NEXTDESC_ADDR, + HW_DESC_TXBUFF_ADDR, + HW_DESC_RXBUFF_ADDR, + HW_DESC_RXPKT_LEN, + HW_DESC_RXERO, + HW_DESC_RX_PREPARE, +}; + +enum prime_sc { + PRIME_CHNL_OFFSET_DONT_CARE = 0, + PRIME_CHNL_OFFSET_LOWER = 1, + PRIME_CHNL_OFFSET_UPPER = 2, +}; + +enum rf_type { + RF_1T1R = 0, + RF_1T2R = 1, + RF_2T2R = 2, + RF_2T2R_GREEN = 3, +}; + +enum ht_channel_width { + HT_CHANNEL_WIDTH_20 = 0, + HT_CHANNEL_WIDTH_20_40 = 1, + HT_CHANNEL_WIDTH_80 = 2, +}; + +/* Ref: 802.11i sepc D10.0 7.3.2.25.1 +Cipher Suites Encryption Algorithms */ +enum rt_enc_alg { + NO_ENCRYPTION = 0, + WEP40_ENCRYPTION = 1, + TKIP_ENCRYPTION = 2, + RSERVED_ENCRYPTION = 3, + AESCCMP_ENCRYPTION = 4, + WEP104_ENCRYPTION = 5, + AESCMAC_ENCRYPTION = 6, /*IEEE802.11w */ +}; + +enum rtl_hal_state { + _HAL_STATE_STOP = 0, + _HAL_STATE_START = 1, +}; + +enum rtl_var_map { + /*reg map */ + SYS_ISO_CTRL = 0, + SYS_FUNC_EN, + SYS_CLK, + MAC_RCR_AM, + MAC_RCR_AB, + MAC_RCR_ACRC32, + MAC_RCR_ACF, + MAC_RCR_AAP, + MAC_HIMR, + MAC_HIMRE, + MAC_HSISR, + + /*efuse map */ + EFUSE_TEST, + EFUSE_CTRL, + EFUSE_CLK, + EFUSE_CLK_CTRL, + EFUSE_PWC_EV12V, + EFUSE_FEN_ELDR, + EFUSE_LOADER_CLK_EN, + EFUSE_ANA8M, + EFUSE_HWSET_MAX_SIZE, + EFUSE_MAX_SECTION_MAP, + EFUSE_REAL_CONTENT_SIZE, + EFUSE_OOB_PROTECT_BYTES_LEN, + EFUSE_ACCESS, + /*CAM map */ + RWCAM, + WCAMI, + RCAMO, + CAMDBG, + SECR, + SEC_CAM_NONE, + SEC_CAM_WEP40, + SEC_CAM_TKIP, + SEC_CAM_AES, + SEC_CAM_WEP104, + + /*IMR map */ + RTL_IMR_BCNDMAINT6, /*Beacon DMA Interrupt 6 */ + RTL_IMR_BCNDMAINT5, /*Beacon DMA Interrupt 5 */ + RTL_IMR_BCNDMAINT4, /*Beacon DMA Interrupt 4 */ + RTL_IMR_BCNDMAINT3, /*Beacon DMA Interrupt 3 */ + RTL_IMR_BCNDMAINT2, /*Beacon DMA Interrupt 2 */ + RTL_IMR_BCNDMAINT1, /*Beacon DMA Interrupt 1 */ + RTL_IMR_BCNDOK8, /*Beacon Queue DMA OK Interrup 8 */ + RTL_IMR_BCNDOK7, /*Beacon Queue DMA OK Interrup 7 */ + RTL_IMR_BCNDOK6, /*Beacon Queue DMA OK Interrup 6 */ + RTL_IMR_BCNDOK5, /*Beacon Queue DMA OK Interrup 5 */ + RTL_IMR_BCNDOK4, /*Beacon Queue DMA OK Interrup 4 */ + RTL_IMR_BCNDOK3, /*Beacon Queue DMA OK Interrup 3 */ + RTL_IMR_BCNDOK2, /*Beacon Queue DMA OK Interrup 2 */ + RTL_IMR_BCNDOK1, /*Beacon Queue DMA OK Interrup 1 */ + RTL_IMR_TIMEOUT2, /*Timeout interrupt 2 */ + RTL_IMR_TIMEOUT1, /*Timeout interrupt 1 */ + RTL_IMR_TXFOVW, /*Transmit FIFO Overflow */ + RTL_IMR_PSTIMEOUT, /*Power save time out interrupt */ + RTL_IMR_BcnInt, /*Beacon DMA Interrupt 0 */ + RTL_IMR_RXFOVW, /*Receive FIFO Overflow */ + RTL_IMR_RDU, /*Receive Descriptor Unavailable */ + RTL_IMR_ATIMEND, /*For 92C,ATIM Window End Interrupt */ + RTL_IMR_BDOK, /*Beacon Queue DMA OK Interrup */ + RTL_IMR_HIGHDOK, /*High Queue DMA OK Interrupt */ + RTL_IMR_COMDOK, /*Command Queue DMA OK Interrupt*/ + RTL_IMR_TBDOK, /*Transmit Beacon OK interrup */ + RTL_IMR_MGNTDOK, /*Management Queue DMA OK Interrupt */ + RTL_IMR_TBDER, /*For 92C,Transmit Beacon Error Interrupt */ + RTL_IMR_BKDOK, /*AC_BK DMA OK Interrupt */ + RTL_IMR_BEDOK, /*AC_BE DMA OK Interrupt */ + RTL_IMR_VIDOK, /*AC_VI DMA OK Interrupt */ + RTL_IMR_VODOK, /*AC_VO DMA Interrupt */ + RTL_IMR_ROK, /*Receive DMA OK Interrupt */ + RTL_IMR_HSISR_IND, /*HSISR Interrupt*/ + RTL_IBSS_INT_MASKS, /*(RTL_IMR_BcnInt | RTL_IMR_TBDOK | + * RTL_IMR_TBDER) */ + RTL_IMR_C2HCMD, /*fw interrupt*/ + + /*CCK Rates, TxHT = 0 */ + RTL_RC_CCK_RATE1M, + RTL_RC_CCK_RATE2M, + RTL_RC_CCK_RATE5_5M, + RTL_RC_CCK_RATE11M, + + /*OFDM Rates, TxHT = 0 */ + RTL_RC_OFDM_RATE6M, + RTL_RC_OFDM_RATE9M, + RTL_RC_OFDM_RATE12M, + RTL_RC_OFDM_RATE18M, + RTL_RC_OFDM_RATE24M, + RTL_RC_OFDM_RATE36M, + RTL_RC_OFDM_RATE48M, + RTL_RC_OFDM_RATE54M, + + RTL_RC_HT_RATEMCS7, + RTL_RC_HT_RATEMCS15, + + RTL_RC_VHT_RATE_1SS_MCS7, + RTL_RC_VHT_RATE_1SS_MCS8, + RTL_RC_VHT_RATE_1SS_MCS9, + RTL_RC_VHT_RATE_2SS_MCS7, + RTL_RC_VHT_RATE_2SS_MCS8, + RTL_RC_VHT_RATE_2SS_MCS9, + + /*keep it last */ + RTL_VAR_MAP_MAX, +}; + +/*Firmware PS mode for control LPS.*/ +enum _fw_ps_mode { + FW_PS_ACTIVE_MODE = 0, + FW_PS_MIN_MODE = 1, + FW_PS_MAX_MODE = 2, + FW_PS_DTIM_MODE = 3, + FW_PS_VOIP_MODE = 4, + FW_PS_UAPSD_WMM_MODE = 5, + FW_PS_UAPSD_MODE = 6, + FW_PS_IBSS_MODE = 7, + FW_PS_WWLAN_MODE = 8, + FW_PS_PM_Radio_Off = 9, + FW_PS_PM_Card_Disable = 10, +}; + +enum rt_psmode { + EACTIVE, /*Active/Continuous access. */ + EMAXPS, /*Max power save mode. */ + EFASTPS, /*Fast power save mode. */ + EAUTOPS, /*Auto power save mode. */ +}; + +/*LED related.*/ +enum led_ctl_mode { + LED_CTL_POWER_ON = 1, + LED_CTL_LINK = 2, + LED_CTL_NO_LINK = 3, + LED_CTL_TX = 4, + LED_CTL_RX = 5, + LED_CTL_SITE_SURVEY = 6, + LED_CTL_POWER_OFF = 7, + LED_CTL_START_TO_LINK = 8, + LED_CTL_START_WPS = 9, + LED_CTL_STOP_WPS = 10, +}; + +enum rtl_led_pin { + LED_PIN_GPIO0, + LED_PIN_LED0, + LED_PIN_LED1, + LED_PIN_LED2 +}; + +/*QoS related.*/ +/*acm implementation method.*/ +enum acm_method { + eAcmWay0_SwAndHw = 0, + eAcmWay1_HW = 1, + eAcmWay2_SW = 2, +}; + +enum macphy_mode { + SINGLEMAC_SINGLEPHY = 0, + DUALMAC_DUALPHY, + DUALMAC_SINGLEPHY, +}; + +enum band_type { + BAND_ON_2_4G = 0, + BAND_ON_5G, + BAND_ON_BOTH, + BANDMAX +}; + +/*aci/aifsn Field. +Ref: WMM spec 2.2.2: WME Parameter Element, p.12.*/ +union aci_aifsn { + u8 char_data; + + struct { + u8 aifsn:4; + u8 acm:1; + u8 aci:2; + u8 reserved:1; + } f; /* Field */ +}; + +/*mlme related.*/ +enum wireless_mode { + WIRELESS_MODE_UNKNOWN = 0x00, + WIRELESS_MODE_A = 0x01, + WIRELESS_MODE_B = 0x02, + WIRELESS_MODE_G = 0x04, + WIRELESS_MODE_AUTO = 0x08, + WIRELESS_MODE_N_24G = 0x10, + WIRELESS_MODE_N_5G = 0x20, + WIRELESS_MODE_AC_5G = 0x40, + WIRELESS_MODE_AC_24G = 0x80, + WIRELESS_MODE_AC_ONLY = 0x100, + WIRELESS_MODE_MAX = 0x800 +}; + +enum ratr_table_mode { + RATR_INX_WIRELESS_NGB = 0, + RATR_INX_WIRELESS_NG = 1, + RATR_INX_WIRELESS_NB = 2, + RATR_INX_WIRELESS_N = 3, + RATR_INX_WIRELESS_GB = 4, + RATR_INX_WIRELESS_G = 5, + RATR_INX_WIRELESS_B = 6, + RATR_INX_WIRELESS_MC = 7, + RATR_INX_WIRELESS_AC_5N = 8, + RATR_INX_WIRELESS_AC_24N = 9, +}; + +enum rtl_link_state { + MAC80211_NOLINK = 0, + MAC80211_LINKING = 1, + MAC80211_LINKED = 2, + MAC80211_LINKED_SCANNING = 3, +}; + +enum act_category { + ACT_CAT_QOS = 1, + ACT_CAT_DLS = 2, + ACT_CAT_BA = 3, + ACT_CAT_HT = 7, + ACT_CAT_WMM = 17, +}; + +enum ba_action { + ACT_ADDBAREQ = 0, + ACT_ADDBARSP = 1, + ACT_DELBA = 2, +}; + +enum rt_polarity_ctl { + RT_POLARITY_LOW_ACT = 0, + RT_POLARITY_HIGH_ACT = 1, +}; + +/* After 8188E, we use V2 reason define. 88C/8723A use V1 reason. */ +enum fw_wow_reason_v2 { + FW_WOW_V2_PTK_UPDATE_EVENT = 0x01, + FW_WOW_V2_GTK_UPDATE_EVENT = 0x02, + FW_WOW_V2_DISASSOC_EVENT = 0x04, + FW_WOW_V2_DEAUTH_EVENT = 0x08, + FW_WOW_V2_FW_DISCONNECT_EVENT = 0x10, + FW_WOW_V2_MAGIC_PKT_EVENT = 0x21, + FW_WOW_V2_UNICAST_PKT_EVENT = 0x22, + FW_WOW_V2_PATTERN_PKT_EVENT = 0x23, + FW_WOW_V2_RTD3_SSID_MATCH_EVENT = 0x24, + FW_WOW_V2_REALWOW_V2_WAKEUPPKT = 0x30, + FW_WOW_V2_REALWOW_V2_ACKLOST = 0x31, + FW_WOW_V2_REASON_MAX = 0xff, +}; + +enum wolpattern_type { + UNICAST_PATTERN = 0, + MULTICAST_PATTERN = 1, + BROADCAST_PATTERN = 2, + DONT_CARE_DA = 3, + UNKNOWN_TYPE = 4, +}; + +struct octet_string { + u8 *octet; + u16 length; +}; + +struct rtl_hdr_3addr { + __le16 frame_ctl; + __le16 duration_id; + u8 addr1[ETH_ALEN]; + u8 addr2[ETH_ALEN]; + u8 addr3[ETH_ALEN]; + __le16 seq_ctl; + u8 payload[0]; +} __packed; + +struct rtl_info_element { + u8 id; + u8 len; + u8 data[0]; +} __packed; + +struct rtl_probe_rsp { + struct rtl_hdr_3addr header; + u32 time_stamp[2]; + __le16 beacon_interval; + __le16 capability; + /*SSID, supported rates, FH params, DS params, + CF params, IBSS params, TIM (if beacon), RSN */ + struct rtl_info_element info_element[0]; +} __packed; + +/*LED related.*/ +/*ledpin Identify how to implement this SW led.*/ +struct rtl_led { + void *hw; + enum rtl_led_pin ledpin; + bool b_ledon; +}; + +struct rtl_led_ctl { + bool bled_opendrain; + struct rtl_led sw_led0; + struct rtl_led sw_led1; +}; + +struct rtl_qos_parameters { + __le16 cw_min; + __le16 cw_max; + u8 aifs; + u8 flag; + __le16 tx_op; +} __packed; + +struct rt_smooth_data { + u32 elements[100]; /*array to store values */ + u32 index; /*index to current array to store */ + u32 total_num; /*num of valid elements */ + u32 total_val; /*sum of valid elements */ +}; + +struct rtl_ht_agg { + u16 txq_id; + u16 wait_for_ba; + u16 start_idx; + u64 bitmap; + u32 rate_n_flags; + u8 agg_state; + u8 rx_agg_state; +}; + +struct rtl_tid_data { + u16 seq_number; + struct rtl_ht_agg agg; +}; + +struct rssi_sta { + long undecorated_smoothed_pwdb; +}; + +struct rtl_sta_info { + struct list_head list; + u8 ratr_index; + u8 wireless_mode; + u8 mimo_ps; + u8 mac_addr[6]; + struct rtl_tid_data tids[MAX_TID_COUNT]; + + /* just used for ap adhoc or mesh*/ + struct rssi_sta rssi_stat; +} __packed; + +struct false_alarm_statistics { + u32 cnt_parity_fail; + u32 cnt_rate_illegal; + u32 cnt_crc8_fail; + u32 cnt_mcs_fail; + u32 cnt_fast_fsync_fail; + u32 cnt_sb_search_fail; + u32 cnt_ofdm_fail; + u32 cnt_cck_fail; + u32 cnt_all; + u32 cnt_ofdm_cca; + u32 cnt_cck_cca; + u32 cnt_cca_all; + u32 cnt_bw_usc; + u32 cnt_bw_lsc; +}; + +struct init_gain { + u8 xaagccore1; + u8 xbagccore1; + u8 xcagccore1; + u8 xdagccore1; + u8 cca; + +}; + +struct wireless_stats { + unsigned long txbytesunicast; + unsigned long txbytesmulticast; + unsigned long txbytesbroadcast; + unsigned long rxbytesunicast; + + long rx_snr_db[4]; + /*Correct smoothed ss in Dbm, only used + in driver to report real power now. */ + long recv_signal_power; + long signal_quality; + long last_sigstrength_inpercent; + + u32 rssi_calculate_cnt; + u32 pwdb_all_cnt; + + /*Transformed, in dbm. Beautified signal + strength for UI, not correct. */ + long signal_strength; + + u8 rx_rssi_percentage[4]; + u8 rx_evm_dbm[4]; + u8 rx_evm_percentage[2]; + + u16 rx_cfo_short[4]; + u16 rx_cfo_tail[4]; + + struct rt_smooth_data ui_rssi; + struct rt_smooth_data ui_link_quality; +}; + +struct rate_adaptive { + u8 rate_adaptive_disabled; + u8 ratr_state; + u16 reserve; + + u32 high_rssi_thresh_for_ra; + u32 high2low_rssi_thresh_for_ra; + u8 low2high_rssi_thresh_for_ra; + u32 low_rssi_thresh_for_ra; + u32 upper_rssi_threshold_ratr; + u32 middleupper_rssi_threshold_ratr; + u32 middle_rssi_threshold_ratr; + u32 middlelow_rssi_threshold_ratr; + u32 low_rssi_threshold_ratr; + u32 ultralow_rssi_threshold_ratr; + u32 low_rssi_threshold_ratr_40m; + u32 low_rssi_threshold_ratr_20m; + u8 ping_rssi_enable; + u32 ping_rssi_ratr; + u32 ping_rssi_thresh_for_ra; + u32 last_ratr; + u8 pre_ratr_state; + u8 ldpc_thres; + bool use_ldpc; + bool lower_rts_rate; + bool is_special_data; +}; + +struct regd_pair_mapping { + u16 reg_dmnenum; + u16 reg_5ghz_ctl; + u16 reg_2ghz_ctl; +}; + +struct dynamic_primary_cca { + u8 pricca_flag; + u8 intf_flag; + u8 intf_type; + u8 dup_rts_flag; + u8 monitor_flag; + u8 ch_offset; + u8 mf_state; +}; + +struct rtl_regulatory { + char alpha2[2]; + u16 country_code; + u16 max_power_level; + u32 tp_scale; + u16 current_rd; + u16 current_rd_ext; + int16_t power_limit; + struct regd_pair_mapping *regpair; +}; + +struct rtl_rfkill { + bool rfkill_state; /*0 is off, 1 is on */ +}; + +/*for P2P PS**/ +#define P2P_MAX_NOA_NUM 2 + +enum p2p_role { + P2P_ROLE_DISABLE = 0, + P2P_ROLE_DEVICE = 1, + P2P_ROLE_CLIENT = 2, + P2P_ROLE_GO = 3 +}; + +enum p2p_ps_state { + P2P_PS_DISABLE = 0, + P2P_PS_ENABLE = 1, + P2P_PS_SCAN = 2, + P2P_PS_SCAN_DONE = 3, + P2P_PS_ALLSTASLEEP = 4, /* for P2P GO */ +}; + +enum p2p_ps_mode { + P2P_PS_NONE = 0, + P2P_PS_CTWINDOW = 1, + P2P_PS_NOA = 2, + P2P_PS_MIX = 3, /* CTWindow and NoA*/ +}; + +struct rtl_p2p_ps_info { + enum p2p_ps_mode p2p_ps_mode; /* indicate p2p ps mode */ + enum p2p_ps_state p2p_ps_state; /* indicate p2p ps state */ + u8 noa_index; /* Identifies and instance of Notice of Absence timing. */ + /* Client traffic window. A period of time in TU after TBTT. */ + u8 ctwindow; + u8 opp_ps; /* opportunistic power save. */ + u8 noa_num; /* number of NoA descriptor in P2P IE. */ + /* Count for owner, Type of client. */ + u8 noa_count_type[P2P_MAX_NOA_NUM]; + /* Max duration for owner, preferred or + * min acceptable duration for client. */ + u32 noa_duration[P2P_MAX_NOA_NUM]; + /* Length of interval for owner, preferred or + * max acceptable interval of client. */ + u32 noa_interval[P2P_MAX_NOA_NUM]; + /* schedule expressed in terms of the lower 4 bytes of the TSF timer. */ + u32 noa_start_time[P2P_MAX_NOA_NUM]; +}; + +struct p2p_ps_offload_t { + u8 Offload_En:1; + u8 role:1; /* 1: Owner, 0: Client */ + u8 CTWindow_En:1; + u8 NoA0_En:1; + u8 NoA1_En:1; + u8 AllStaSleep:1; + u8 discovery:1; + u8 reserved:1; +}; + +#define IQK_MATRIX_REG_NUM 8 +/* Channels_2_4G_NUM + Channels_5G_20M_NUM + Channels_5G */ +#define IQK_MATRIX_SETTINGS_NUM (14 + 24 + 21) +struct iqk_matrix_regs { + bool b_iqk_done; + long value[1][IQK_MATRIX_REG_NUM]; +}; + +struct rtl_phy { + struct bb_reg_def phyreg_def[4]; /*Radio A/B/C/D */ + struct init_gain initgain_backup; + enum io_type current_io_type; + + u8 rf_mode; + u8 rf_type; + u8 current_chan_bw; + u8 set_bwmode_inprogress; + u8 sw_chnl_inprogress; + u8 sw_chnl_stage; + u8 sw_chnl_step; + u8 current_channel; + u8 h2c_box_num; + u8 set_io_inprogress; + u8 lck_inprogress; + bool iqk_inprogress; + + /* record for power tracking */ + s32 reg_e94; + s32 reg_e9c; + s32 reg_ea4; + s32 reg_eac; + s32 reg_eb4; + s32 reg_ebc; + s32 reg_ec4; + s32 reg_ecc; + u8 rfpienable; + u8 reserve_0; + u16 reserve_1; + u32 reg_c04, reg_c08, reg_874; + u32 adda_backup[16]; + u32 iqk_mac_backup[IQK_MAC_REG_NUM]; + u32 iqk_bb_backup[10]; + bool iqk_initialized; + + bool rfpath_rx_enable[MAX_RF_PATH]; + /*Jaguar*/ + u8 reg_837; + /* Dul mac */ + bool b_need_iqk; + struct iqk_matrix_regs iqk_matrix_regsetting[IQK_MATRIX_SETTINGS_NUM]; + + bool b_rfpi_enable; + + u8 pwrgroup_cnt; + u8 bcck_high_power; + /* this is for 88E & 8723A */ + u32 mcs_txpwrlevel_origoffset[MAX_PG_GROUP][16]; + /* this is for 92EE */ + u32 tx_power_by_rate_offset[TX_PWR_BY_RATE_NUM_BAND] + [TX_PWR_BY_RATE_NUM_RF] + [TX_PWR_BY_RATE_NUM_RF] + [TX_PWR_BY_RATE_NUM_SECTION]; + u8 txpwr_by_rate_base_24g[TX_PWR_BY_RATE_NUM_RF] + [TX_PWR_BY_RATE_NUM_RF] + [MAX_BASE_NUM_IN_PHY_REG_PG_24G]; + + u8 txpwr_by_rate_base_5g[TX_PWR_BY_RATE_NUM_RF] + [TX_PWR_BY_RATE_NUM_RF] + [MAX_BASE_NUM_IN_PHY_REG_PG_5G]; + u8 default_initialgain[4]; + + /* the current Tx power level */ + u8 cur_cck_txpwridx; + u8 cur_ofdm24g_txpwridx; + u8 cur_bw20_txpwridx; + u8 cur_bw40_txpwridx; + + char txpwr_limit_2_4g[MAX_REGULATION_NUM] + [MAX_2_4G_BANDWITH_NUM] + [MAX_RATE_SECTION_NUM] + [CHANNEL_MAX_NUMBER_2G] + [MAX_RF_PATH_NUM]; + char txpwr_limit_5g[MAX_REGULATION_NUM] + [MAX_5G_BANDWITH_NUM] + [MAX_RATE_SECTION_NUM] + [CHANNEL_MAX_NUMBER_5G] + [MAX_RF_PATH_NUM]; + + u32 rfreg_chnlval[2]; + bool b_apk_done; + u32 reg_rf3c[2]; /* pathA / pathB */ + + u32 backup_rf_0x1a;/*92ee*/ + /* bfsync */ + u8 framesync; + u32 framesync_c34; + + u8 num_total_rfpath; + u16 rf_pathmap; + + enum rt_polarity_ctl polarity_ctl; +}; + +#define RTL_AGG_STOP 0 +#define RTL_AGG_PROGRESS 1 +#define RTL_AGG_START 2 +#define RTL_AGG_OPERATIONAL 3 +#define RTL_RX_AGG_START 1 +#define RTL_RX_AGG_STOP 0 + +struct rtl_priv; +struct rtl_io { + struct device *dev; + + /*PCI MEM map */ + unsigned long pci_mem_end; /*shared mem end */ + unsigned long pci_mem_start; /*shared mem start */ + + /*PCI IO map */ + unsigned long pci_base_addr; /*device I/O address */ + + void (*write8_async)(struct rtl_priv *rtlpriv, u32 addr, u8 val); + void (*write16_async)(struct rtl_priv *rtlpriv, u32 addr, u16 val); + void (*write32_async)(struct rtl_priv *rtlpriv, u32 addr, u32 val); + + u8 (*read8_sync)(struct rtl_priv *rtlpriv, u32 addr); + u16 (*read16_sync)(struct rtl_priv *rtlpriv, u32 addr); + u32 (*read32_sync)(struct rtl_priv *rtlpriv, u32 addr); + +}; + +struct rtl_mac { + u8 mac_addr[ETH_ALEN]; + u8 mac80211_registered; + u8 beacon_enabled; + + u32 tx_ss_num; + u32 rx_ss_num; + + struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; + struct ieee80211_hw *hw; + struct ieee80211_vif *vif; + enum nl80211_iftype opmode; + + /*Probe Beacon management */ + enum rtl_link_state link_state; + + int n_channels; + int n_bitrates; + + bool offchan_deley; + u8 p2p; /*using p2p role*/ + bool p2p_in_use; + + /*filters */ + u32 rx_conf; + + bool act_scanning; + u8 cnt_after_linked; + bool skip_scan; + + /* early mode */ + /* skb wait queue */ + struct sk_buff_head skb_waitq[MAX_TID_COUNT]; + + /*RDG*/ + bool rdg_en; + + u8 ht_stbc_cap; + u8 ht_cur_stbc; + + /*vht support*/ + u8 vht_enable; + u8 bw_80; + u8 vht_cur_ldpc; + u8 vht_cur_stbc; + u8 vht_stbc_cap; + u8 vht_ldpc_cap; + + /*AP*/ + u8 bssid[6]; + u32 vendor; + u32 basic_rates; /* b/g rates */ + u8 ht_enable; + u8 bw_40; + u8 mode; /* wireless mode */ + u8 slot_time; + u8 short_preamble; + u8 use_cts_protect; + u8 cur_40_prime_sc; + u8 cur_40_prime_sc_bk; + u8 cur_80_prime_sc; + u64 tsf; + u8 retry_short; + u8 retry_long; + u16 assoc_id; + bool bhiddenssid; + + /*IBSS*/ + int beacon_interval; + + /*AMPDU*/ + u8 min_space_cfg; /*For Min spacing configurations */ + u8 max_mss_density; + u8 current_ampdu_factor; + u8 current_ampdu_density; + + /*QOS & EDCA */ + struct ieee80211_tx_queue_params edca_param[RTL_MAC80211_NUM_QUEUE]; + struct rtl_qos_parameters ac[AC_MAX]; +}; + +struct rtl_hal { + struct ieee80211_hw *hw; + + bool driver_is_goingto_unload; + bool up_first_time; + bool bfirst_init; + bool being_init_adapter; + bool b_bbrf_ready; + bool b_mac_func_enable; + bool b_pre_edcca_enable; + + enum intf_type interface; + u16 hw_type; /*92c or 92d or 92s and so on */ + u8 ic_class; + u8 oem_id; + u32 version; /*version of chip */ + u8 state; /*stop 0, start 1 */ + u8 boad_type; + + u8 pa_mode; + u8 pa_type_2g; + u8 pa_type_5g; + u8 lna_type_2g; + u8 lna_type_5g; + u8 external_pa_2g; + u8 external_lna_2g; + u8 external_pa_5g; + u8 external_lna_5g; + u8 rfe_type; + + /*firmware */ + u32 fwsize; + u8 *pfirmware; + u16 fw_version; + u16 fw_subversion; + bool b_h2c_setinprogress; + u8 last_hmeboxnum; + bool bfw_ready; + + /*Reserve page start offset except beacon in TxQ. */ + u8 fw_rsvdpage_startoffset; + u8 h2c_txcmd_seq; + u8 current_ra_rate; + + /* FW Cmd IO related */ + u16 fwcmd_iomap; + u32 fwcmd_ioparam; + bool set_fwcmd_inprogress; + u8 current_fwcmd_io; + + bool bfw_clk_change_in_progress; + bool ballow_sw_to_change_hwclc; + u8 fw_ps_state; + struct p2p_ps_offload_t p2p_ps_offload; + /**/ + bool driver_going2unload; + + /*AMPDU init min space*/ + u8 minspace_cfg; /*For Min spacing configurations */ + + /* Dul mac */ + enum macphy_mode macphymode; + enum band_type current_bandtype; /* 0:2.4G, 1:5G */ + enum band_type current_bandtypebackup; + enum band_type bandset; + /* dual MAC 0--Mac0 1--Mac1 */ + u32 interfaceindex; + /* just for DulMac S3S4 */ + u8 macphyctl_reg; + bool b_earlymode_enable; + u8 max_earlymode_num; + /* Dul mac*/ + bool during_mac0init_radiob; + bool during_mac1init_radioa; + bool reloadtxpowerindex; + /* True if IMR or IQK have done + for 2.4G in scan progress */ + bool b_load_imrandiqk_setting_for2g; + + bool disable_amsdu_8k; + bool bmaster_of_dmsp; + bool bslave_of_dmsp; + + u16 rx_tag;/*for 92ee*/ + u8 rts_en; + + /*for wowlan*/ + bool wow_enable; + bool b_enter_pnp_sleep; + bool b_wake_from_pnp_sleep; + bool wow_enabled; + __kernel_time_t last_suspend_sec; + u32 wowlan_fwsize; + u8 *p_wowlan_firmware; + + u8 hw_rof_enable; /*Enable GPIO[9] as WL RF HW PDn source*/ + + bool real_wow_v2_enable; + bool re_init_llt_table; +}; + +struct rtl_security { + /*default 0 */ + bool use_sw_sec; + + bool being_setkey; + bool use_defaultkey; + /*Encryption Algorithm for Unicast Packet */ + enum rt_enc_alg pairwise_enc_algorithm; + /*Encryption Algorithm for Brocast/Multicast */ + enum rt_enc_alg group_enc_algorithm; + /*Cam Entry Bitmap */ + u32 hwsec_cam_bitmap; + u8 hwsec_cam_sta_addr[TOTAL_CAM_ENTRY][ETH_ALEN]; + /*local Key buffer, indx 0 is for + pairwise key 1-4 is for agoup key. */ + u8 key_buf[KEY_BUF_SIZE][MAX_KEY_LEN]; + u8 key_len[KEY_BUF_SIZE]; + + /*The pointer of Pairwise Key, + it always points to KeyBuf[4] */ + u8 *pairwise_key; +}; + +struct rtl_dig { + u8 dig_enable_flag; + u8 dig_ext_port_stage; + + u32 rssi_lowthresh; + u32 rssi_highthresh; + + u32 fa_lowthresh; + u32 fa_highthresh; + + u8 cursta_connectstate; + u8 presta_connectstate; + u8 curmultista_connectstate; + + u8 pre_igvalue; + u8 cur_igvalue; + + char backoff_val; + char backoff_val_range_max; + char backoff_val_range_min; + u8 rx_gain_range_max; + u8 rx_gain_range_min; + u8 rssi_val_min; + u8 min_undecorated_pwdb_for_dm; + long last_min_undecorated_pwdb_for_dm; + + u8 pre_cck_pd_state; + u8 cur_cck_pd_state; + + u8 large_fa_hit; + u8 forbidden_igi; + u32 recover_cnt; + +}; + +struct rtl_pstbl { + u8 pre_ccastate; + u8 cur_ccasate; + + u8 pre_rfstate; + u8 cur_rfstate; + + long rssi_val_min; + +}; + +#define ASSOCIATE_ENTRY_NUM (32 + 1) + +struct fast_ant_trainning { + u8 bssid[6]; + u8 antsel_rx_keep_0; + u8 antsel_rx_keep_1; + u8 antsel_rx_keep_2; + u32 ant_sum_rssi[7]; + u32 ant_rssi_cnt[7]; + u32 ant_ave_rssi[7]; + u8 fat_state; + u32 train_idx; + u8 antsel_a[ASSOCIATE_ENTRY_NUM]; + u8 antsel_b[ASSOCIATE_ENTRY_NUM]; + u8 antsel_c[ASSOCIATE_ENTRY_NUM]; + u32 main_ant_sum[ASSOCIATE_ENTRY_NUM]; + u32 aux_ant_sum[ASSOCIATE_ENTRY_NUM]; + u32 main_ant_cnt[ASSOCIATE_ENTRY_NUM]; + u32 aux_ant_cnt[ASSOCIATE_ENTRY_NUM]; + u8 rx_idle_ant; + bool b_becomelinked; +}; + +struct dm_phy_dbg_info { + char rx_snrdb[4]; + u64 num_qry_phy_status; + u64 num_qry_phy_status_cck; + u64 num_qry_phy_status_ofdm; + u16 num_qry_beacon_pkt; + u16 num_non_be_pkt; + s32 rx_evm[4]; +}; + +struct rtl_dm { + /*PHY status for DM */ + long entry_min_undecoratedsmoothed_pwdb; + long undecorated_smoothed_pwdb; /*out dm */ + long entry_max_undecoratedsmoothed_pwdb; + bool b_dm_initialgain_enable; + bool bdynamic_txpower_enable; + bool bcurrent_turbo_edca; + bool bis_any_nonbepkts; /*out dm */ + bool bis_cur_rdlstate; + bool btxpower_trackinginit; + bool b_disable_framebursting; + bool b_cck_inch14; + bool btxpower_tracking; + bool b_useramask; + bool brfpath_rxenable[4]; + bool binform_fw_driverctrldm; + bool bcurrent_mrc_switch; + u8 txpowercount; + + u8 thermalvalue_rxgain; + u8 thermalvalue_iqk; + u8 thermalvalue_lck; + u8 thermalvalue; + u8 thermalvalue_avg[AVG_THERMAL_NUM]; + u8 thermalvalue_avg_index; + bool bdone_txpower; + u8 last_dtp_lvl; + u8 dynamic_txhighpower_lvl; /*Tx high power level */ + u8 dm_flag; /*Indicate if each dynamic mechanism's status. */ + u8 dm_type; + u8 txpower_track_control; + bool binterrupt_migration; + bool bdisable_tx_int; + char ofdm_index[MAX_RF_PATH]; + char cck_index; + u8 default_ofdm_index; + u8 default_cck_index; + char delta_power_index[MAX_RF_PATH]; + char delta_power_index_last[MAX_RF_PATH]; + char power_index_offset[MAX_RF_PATH]; + char aboslute_ofdm_swing_idx[MAX_RF_PATH]; + char remnant_ofdm_swing_idx[MAX_RF_PATH]; + char remnant_cck_idx; + bool modify_txagc_flag_path_a; + bool modify_txagc_flag_path_b; + + bool b_one_entry_only; + struct dm_phy_dbg_info dbginfo; + /* Dynamic ATC switch */ + + bool atc_status; + bool large_cfo_hit; + bool is_freeze; + int cfo_tail[2]; + int cfo_ave_pre; + int crystal_cap; + u8 cfo_threshold; + u32 packet_count; + u32 packet_count_pre; + u8 tx_rate; + + + /*88e tx power tracking*/ + u8 bb_swing_idx_ofdm[2]; + u8 bb_swing_idx_ofdm_current; + u8 bb_swing_idx_ofdm_base[MAX_RF_PATH]; + bool bb_swing_flag_Ofdm; + u8 bb_swing_idx_cck; + u8 bb_swing_idx_cck_current; + u8 bb_swing_idx_cck_base; + bool bb_swing_flag_cck; + + char bb_swing_diff_2g; + char bb_swing_diff_5g; + + /* DMSP */ + bool supp_phymode_switch; + + /* DulMac */ + struct rtl_dig dm_digtable; + struct rtl_pstbl dm_pstable; + struct fast_ant_trainning fat_table; + + u8 linked_interval; + + u64 last_tx_ok_cnt; + u64 last_rx_ok_cnt; + + bool cck_high_power; +}; + +#define EFUSE_MAX_LOGICAL_SIZE 256 + +struct rtl_efuse { + bool bautoLoad_ok; + bool bootfromefuse; + u16 max_physical_size; + + u8 efuse_map[2][EFUSE_MAX_LOGICAL_SIZE]; + u16 efuse_usedbytes; + u8 efuse_usedpercentage; + u8 autoload_failflag; + u8 autoload_status; + + short epromtype; + u16 eeprom_vid; + u16 eeprom_did; + u16 eeprom_svid; + u16 eeprom_smid; + u8 eeprom_oemid; + u16 eeprom_channelplan; + u8 eeprom_version; + + u8 dev_addr[6]; + u8 board_type; + u8 wowlan_enable; + u8 antenna_div_cfg; + u8 antenna_div_type; + + bool b_txpwr_fromeprom; + u8 eeprom_crystalcap; + u8 eeprom_tssi[2]; + u8 eeprom_tssi_5g[3][2]; /* for 5GL/5GM/5GH band. */ + u8 eeprom_pwrlimit_ht20[CHANNEL_GROUP_MAX]; + u8 eeprom_pwrlimit_ht40[CHANNEL_GROUP_MAX]; + u8 eeprom_chnlarea_txpwr_cck[2][CHANNEL_GROUP_MAX_2G]; + u8 eeprom_chnlarea_txpwr_ht40_1s[2][CHANNEL_GROUP_MAX]; + u8 eeprom_chnlarea_txpwr_ht40_2sdiif[2][CHANNEL_GROUP_MAX]; + + + u8 internal_pa_5g[2]; /* pathA / pathB */ + u8 eeprom_c9; + u8 eeprom_cc; + + /*For power group */ + u8 eeprom_pwrgroup[2][3]; + u8 pwrgroup_ht20[2][CHANNEL_MAX_NUMBER]; + u8 pwrgroup_ht40[2][CHANNEL_MAX_NUMBER]; + + u8 txpwrlevel_cck[MAX_RF_PATH][CHANNEL_MAX_NUMBER_2G]; + /*For HT 40MHZ pwr */ + u8 txpwrlevel_ht40_1s[MAX_RF_PATH][CHANNEL_MAX_NUMBER]; + /*For HT 40MHZ pwr */ + u8 txpwrlevel_ht40_2s[MAX_RF_PATH][CHANNEL_MAX_NUMBER]; + + /*--------------------------------------------------------* + * 8192CE\8192SE\8192DE\8723AE use the following 4 arrays, + * other ICs (8188EE\8723BE\8192EE\8812AE...) + * define new arrays in Windows code. + * BUT, in linux code, we use the same array for all ICs. + * + * The Correspondance relation between two arrays is: + * txpwr_cckdiff[][] == CCK_24G_Diff[][] + * txpwr_ht20diff[][] == BW20_24G_Diff[][] + * txpwr_ht40diff[][] == BW40_24G_Diff[][] + * txpwr_legacyhtdiff[][] == OFDM_24G_Diff[][] + * + * Sizes of these arrays are decided by the larger ones. + */ + char txpwr_cckdiff[MAX_RF_PATH][CHANNEL_MAX_NUMBER]; + char txpwr_ht20diff[MAX_RF_PATH][CHANNEL_MAX_NUMBER]; + char txpwr_ht40diff[MAX_RF_PATH][CHANNEL_MAX_NUMBER]; + char txpwr_legacyhtdiff[MAX_RF_PATH][CHANNEL_MAX_NUMBER]; + /*--------------------------------------------------------*/ + + u8 txpwr_5g_bw40base[MAX_RF_PATH][CHANNEL_MAX_NUMBER]; + u8 txpwr_5g_bw80base[MAX_RF_PATH][CHANNEL_MAX_NUMBER_5G_80M]; + char txpwr_5g_ofdmdiff[MAX_RF_PATH][MAX_TX_COUNT]; + char txpwr_5g_bw20diff[MAX_RF_PATH][MAX_TX_COUNT]; + char txpwr_5g_bw40diff[MAX_RF_PATH][MAX_TX_COUNT]; + char txpwr_5g_bw80diff[MAX_RF_PATH][MAX_TX_COUNT]; + + u8 txpwr_safetyflag; /* Band edge enable flag */ + u16 eeprom_txpowerdiff; + u8 legacy_httxpowerdiff; /* Legacy to HT rate power diff */ + u8 antenna_txpwdiff[3]; + + u8 eeprom_regulatory; + u8 eeprom_thermalmeter; + u8 thermalmeter[2];/*ThermalMeter, index 0 for RFIC0, and 1 for RFIC1 */ + u16 tssi_13dbm; + u8 crystalcap; /* CrystalCap. */ + u8 delta_iqk; + u8 delta_lck; + + u8 legacy_ht_txpowerdiff; /*Legacy to HT rate power diff */ + bool b_apk_thermalmeterignore; + + bool b1x1_recvcombine; + bool b1ss_support; + + /*channel plan */ + u8 channel_plan; +}; + +struct rtl_ps_ctl { + bool pwrdomain_protect; + bool b_in_powersavemode; + bool rfchange_inprogress; + bool b_swrf_processing; + bool b_hwradiooff; + /* + * just for PCIE ASPM + * If it supports ASPM, Offset[560h] = 0x40, + * otherwise Offset[560h] = 0x00. + * */ + bool b_support_aspm; + bool b_support_backdoor; + + /*for LPS */ + enum rt_psmode dot11_psmode; /*Power save mode configured. */ + bool b_swctrl_lps; + bool b_fwctrl_lps; + u8 fwctrl_psmode; + /*For Fw control LPS mode */ + u8 b_reg_fwctrl_lps; + /*Record Fw PS mode status. */ + bool b_fw_current_inpsmode; + u8 reg_max_lps_awakeintvl; + bool report_linked; + bool b_low_power_enable;/*for 32k*/ + + /*for IPS */ + bool b_inactiveps; + + u32 rfoff_reason; + + /*RF OFF Level */ + u32 cur_ps_level; + u32 reg_rfps_level; + + /*just for PCIE ASPM */ + u8 const_amdpci_aspm; + + enum rf_pwrstate inactive_pwrstate; + enum rf_pwrstate rfpwr_state; /*cur power state */ + + /* for SW LPS*/ + bool sw_ps_enabled; + bool state; + bool state_inap; + bool multi_buffered; + u16 nullfunc_seq; + unsigned int dtim_counter; + unsigned int sleep_ms; + unsigned long last_sleep_jiffies; + unsigned long last_awake_jiffies; + unsigned long last_delaylps_stamp_jiffies; + unsigned long last_dtim; + unsigned long last_beacon; + unsigned long last_action; + unsigned long last_slept; + + /*For P2P PS */ + struct rtl_p2p_ps_info p2p_ps_info; + u8 pwr_mode; + u8 smart_ps; + + /* wake up on line */ + u8 wo_wlan_mode; + u8 arp_offload_enable; + u8 gtk_offload_enable; + /* Used for WOL, indicates the reason for waking event.*/ + u32 wakeup_reason; + /* Record the last waking time for comparison with setting key. */ + u64 last_wakeup_time; +}; + +struct rtl_stats { + u8 psaddr[ETH_ALEN]; + u32 mac_time[2]; + s8 rssi; + u8 signal; + u8 noise; + u8 rate; /* hw desc rate */ + u8 rawdata; + u8 received_channel; + u8 control; + u8 mask; + u8 freq; + u16 len; + u64 tsf; + u32 beacon_time; + u8 nic_type; + u16 length; + u8 signalquality; /*in 0-100 index. */ + /* + * Real power in dBm for this packet, + * no beautification and aggregation. + * */ + s32 recvsignalpower; + s8 rxpower; /*in dBm Translate from PWdB */ + u8 signalstrength; /*in 0-100 index. */ + u16 b_hwerror:1; + u16 b_crc:1; + u16 b_icv:1; + u16 b_shortpreamble:1; + u16 antenna:1; + u16 decrypted:1; + u16 wakeup:1; + u32 timestamp_low; + u32 timestamp_high; + bool b_shift; + + u8 rx_drvinfo_size; + u8 rx_bufshift; + bool b_isampdu; + bool b_isfirst_ampdu; + bool rx_is40Mhzpacket; + u8 rx_packet_bw; + u32 rx_pwdb_all; + u8 rx_mimo_signalstrength[4]; /*in 0~100 index */ + s8 rx_mimo_signalquality[4]; + u8 rx_mimo_evm_dbm[4]; + u16 cfo_short[4]; /* per-path's Cfo_short */ + u16 cfo_tail[4]; + + u8 rx_pwr[4]; /* per-path's pwdb */ + u8 rx_snr[4]; /* per-path's SNR */ + u8 bandwidth; + u8 bt_coex_pwr_adjust; + bool b_packet_matchbssid; + bool b_is_cck; + bool b_is_ht; + bool b_packet_toself; + bool b_packet_beacon; /*for rssi */ + char cck_adc_pwdb[4]; /*for rx path selection */ + + bool b_is_vht; + bool b_is_short_gi; + u8 vht_nss; + + u8 packet_report_type; + + u32 macid; + u8 wake_match; + u32 bt_rx_rssi_percentage; + u32 macid_valid_entry[2]; +}; + +struct rt_link_detect { + /* count for raoming */ + u32 bcn_rx_inperiod; + u32 roam_times; + + u32 num_tx_in4period[4]; + u32 num_rx_in4period[4]; + + u32 num_tx_inperiod; + u32 num_rx_inperiod; + + bool b_busytraffic; + bool b_tx_busy_traffic; + bool b_rx_busy_traffic; + bool b_higher_busytraffic; + bool b_higher_busyrxtraffic; + + u32 tidtx_in4period[MAX_TID_COUNT][4]; + u32 tidtx_inperiod[MAX_TID_COUNT]; + bool higher_busytxtraffic[MAX_TID_COUNT]; +}; + +struct rtl_tcb_desc { + u8 packet_bw:2; + u8 b_multicast:1; + u8 b_broadcast:1; + + u8 b_rts_stbc:1; + u8 b_rts_enable:1; + u8 b_cts_enable:1; + u8 b_rts_use_shortpreamble:1; + u8 b_rts_use_shortgi:1; + u8 rts_sc:1; + u8 b_rts_bw:1; + u8 rts_rate; + + u8 use_shortgi:1; + u8 use_shortpreamble:1; + u8 use_driver_rate:1; + u8 disable_ratefallback:1; + + u8 ratr_index; + u8 mac_id; + u8 hw_rate; + + u8 b_last_inipkt:1; + u8 b_cmd_or_init:1; + u8 queue_index; + + /* early mode */ + u8 empkt_num; + /* The max value by HW */ + u32 empkt_len[10]; + bool btx_enable_sw_calc_duration; + /* used for hal construct pkt, + * we may set desc when tx */ + u8 self_desc; +}; + +struct rtl_wow_pattern { + u8 type; + u16 crc; + u32 mask[4]; +}; + +struct proxim { + bool proxim_on; + + void *proximity_priv; + int (*proxim_rx)(struct ieee80211_hw *hw, struct rtl_stats *status, + struct sk_buff *skb); + u8 (*proxim_get_var)(struct ieee80211_hw *hw, u8 type); +}; + +struct rtl_hal_ops { + int (*init_sw_vars)(struct ieee80211_hw *hw); + void (*deinit_sw_vars)(struct ieee80211_hw *hw); + void (*read_eeprom_info)(struct ieee80211_hw *hw); + void (*interrupt_recognized)(struct ieee80211_hw *hw, + u32 *p_inta, u32 *p_intb); + int (*hw_init)(struct ieee80211_hw *hw); + void (*hw_disable)(struct ieee80211_hw *hw); + void (*hw_suspend)(struct ieee80211_hw *hw); + void (*hw_resume)(struct ieee80211_hw *hw); + void (*enable_interrupt)(struct ieee80211_hw *hw); + void (*disable_interrupt)(struct ieee80211_hw *hw); + int (*set_network_type)(struct ieee80211_hw *hw, + enum nl80211_iftype type); + void (*set_chk_bssid)(struct ieee80211_hw *hw, + bool check_bssid); + void (*set_bw_mode)(struct ieee80211_hw *hw, + enum nl80211_channel_type ch_type); + u8 (*switch_channel)(struct ieee80211_hw *hw); + void (*set_qos)(struct ieee80211_hw *hw, int aci); + void (*set_bcn_reg)(struct ieee80211_hw *hw); + void (*set_bcn_intv)(struct ieee80211_hw *hw); + void (*update_interrupt_mask)(struct ieee80211_hw *hw, + u32 add_msr, u32 rm_msr); + void (*get_hw_reg)(struct ieee80211_hw *hw, u8 variable, u8 *val); + void (*set_hw_reg)(struct ieee80211_hw *hw, u8 variable, u8 *val); + void (*update_rate_tbl)(struct ieee80211_hw *hw, + struct ieee80211_sta *sta, u8 rssi_level); + void (*pre_fill_tx_bd_desc)(struct ieee80211_hw *hw, u8 *tx_bd_desc, + u8 *desc, u8 queue_index, + struct sk_buff *skb, dma_addr_t addr); + u16 (*rx_desc_buff_remained_cnt)(struct ieee80211_hw *hw, + u8 queue_index); + void (*rx_check_dma_ok)(struct ieee80211_hw *hw, u8 *header_desc, + u8 queue_index); + void (*fill_tx_desc)(struct ieee80211_hw *hw, + struct ieee80211_hdr *hdr, + u8 *pdesc_tx, u8 *pbd_desc, + struct ieee80211_tx_info *info, + struct ieee80211_sta *sta, + struct sk_buff *skb, u8 hw_queue, + struct rtl_tcb_desc *ptcb_desc); + void (*fill_tx_cmddesc)(struct ieee80211_hw *hw, u8 *pdesc, + bool b_firstseg, bool b_lastseg, + struct sk_buff *skb); + bool (*query_rx_desc)(struct ieee80211_hw *hw, + struct rtl_stats *status, + struct ieee80211_rx_status *rx_status, + u8 *pdesc, struct sk_buff *skb); + void (*set_channel_access)(struct ieee80211_hw *hw); + bool (*radio_onoff_checking)(struct ieee80211_hw *hw, u8 *valid); + void (*dm_watchdog)(struct ieee80211_hw *hw); + void (*scan_operation_backup)(struct ieee80211_hw *hw, u8 operation); + bool (*set_rf_power_state)(struct ieee80211_hw *hw, + enum rf_pwrstate rfpwr_state); + void (*led_control)(struct ieee80211_hw *hw, + enum led_ctl_mode ledaction); + void (*set_desc)(struct ieee80211_hw *hw, u8 *pdesc, bool istx, + u8 desc_name, u8 *val); + u32 (*get_desc)(u8 *pdesc, bool istx, u8 desc_name); + bool (*is_tx_desc_closed)(struct ieee80211_hw *hw, + u8 hw_queue, u16 index); + void (*tx_polling)(struct ieee80211_hw *hw, u8 hw_queue); + void (*enable_hw_sec)(struct ieee80211_hw *hw); + void (*set_key)(struct ieee80211_hw *hw, u32 key_index, + u8 *p_macaddr, bool is_group, u8 enc_algo, + bool is_wepkey, bool clear_all); + void (*init_sw_leds)(struct ieee80211_hw *hw); + u32 (*get_bbreg)(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask); + void (*set_bbreg)(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask, + u32 data); + u32 (*get_rfreg)(struct ieee80211_hw *hw, enum radio_path rfpath, + u32 regaddr, u32 bitmask); + void (*set_rfreg)(struct ieee80211_hw *hw, enum radio_path rfpath, + u32 regaddr, u32 bitmask, u32 data); + void (*allow_all_destaddr)(struct ieee80211_hw *hw, + bool allow_all_da, bool write_into_reg); + void (*linked_set_reg)(struct ieee80211_hw *hw); + void (*check_switch_to_dmdp)(struct ieee80211_hw *hw); + void (*dualmac_easy_concurrent)(struct ieee80211_hw *hw); + void (*dualmac_switch_to_dmdp)(struct ieee80211_hw *hw); + void (*c2h_command_handle)(struct ieee80211_hw *hw); + void (*bt_wifi_media_status_notify)(struct ieee80211_hw *hw, + bool mstate); + void (*bt_turn_off_bt_coexist_before_enter_lps)(struct ieee80211_hw *w); + void (*fill_h2c_cmd)(struct ieee80211_hw *hw, u8 element_id, + u32 cmd_len, u8 *p_cmdbuffer); + bool (*get_btc_status)(void); + u32 (*rx_command_packet)(struct ieee80211_hw *hw, + struct rtl_stats status, struct sk_buff *skb); + void (*add_wowlan_pattern)(struct ieee80211_hw *hw, + struct rtl_wow_pattern *rtl_pattern, + u8 index); +}; + +struct rtl_intf_ops { + /*com */ + void (*read92e_efuse_byte)(struct ieee80211_hw *hw, u16 _offset, + u8 *pbuf); + int (*adapter_start)(struct ieee80211_hw *hw); + void (*adapter_stop)(struct ieee80211_hw *hw); + bool (*check_buddy_priv)(struct ieee80211_hw *hw, + struct rtl_priv **buddy_priv); + + int (*adapter_tx)(struct ieee80211_hw *hw, + struct ieee80211_sta *sta, + struct sk_buff *skb, + struct rtl_tcb_desc *ptcb_desc); + void (*flush)(struct ieee80211_hw *hw, u32 queues, bool drop); + int (*reset_trx_ring)(struct ieee80211_hw *hw); + bool (*waitq_insert)(struct ieee80211_hw *hw, + struct ieee80211_sta *sta, + struct sk_buff *skb); + + /*pci */ + void (*disable_aspm)(struct ieee80211_hw *hw); + void (*enable_aspm)(struct ieee80211_hw *hw); + + /*usb */ +}; + +struct rtl_mod_params { + /* default: 0 = using hardware encryption */ + bool sw_crypto; + + /* default: 0 = DBG_EMERG (0)*/ + int debug; + + /* default: 1 = using no linked power save */ + bool b_inactiveps; + + /* default: 1 = using linked sw power save */ + bool b_swctrl_lps; + + /* default: 1 = using linked fw power save */ + bool b_fwctrl_lps; +}; + +struct rtl_hal_cfg { + u8 bar_id; + bool write_readback; + char *name; + char *fw_name; + struct rtl_hal_ops *ops; + struct rtl_mod_params *mod_params; + + /*this map used for some registers or vars + defined int HAL but used in MAIN */ + u32 maps[RTL_VAR_MAP_MAX]; + +}; + +struct rtl_locks { + /* mutex */ + struct mutex conf_mutex; + + /*spin lock */ + spinlock_t ips_lock; + spinlock_t irq_th_lock; + spinlock_t h2c_lock; + spinlock_t rf_ps_lock; + spinlock_t rf_lock; + spinlock_t lps_lock; + spinlock_t waitq_lock; + spinlock_t entry_list_lock; + + /*FW clock change */ + spinlock_t fw_ps_lock; + + /*Dul mac*/ + spinlock_t cck_and_rw_pagea_lock; + + /*Easy concurrent*/ + spinlock_t check_sendpkt_lock; + + spinlock_t iqk_lock; +}; + +struct rtl_works { + struct ieee80211_hw *hw; + + /*timer */ + struct timer_list watchdog_timer; + struct timer_list dualmac_easyconcurrent_retrytimer; + struct timer_list fw_clockoff_timer; + struct timer_list fast_antenna_trainning_timer; + /*task */ + struct tasklet_struct irq_tasklet; + struct tasklet_struct irq_prepare_bcn_tasklet; + + /*work queue */ + struct workqueue_struct *rtl_wq; + struct delayed_work watchdog_wq; + struct delayed_work ips_nic_off_wq; + + /* For SW LPS */ + struct delayed_work ps_work; + struct delayed_work ps_rfon_wq; + struct delayed_work fwevt_wq; +}; + +struct rtl_debug { + u32 dbgp_type[DBGP_TYPE_MAX]; + u32 global_debuglevel; + u64 global_debugcomponents; + + /* add for proc debug */ + struct proc_dir_entry *proc_dir; + char proc_name[20]; +}; + +#define MIMO_PS_STATIC 0 +#define MIMO_PS_DYNAMIC 1 +#define MIMO_PS_NOLIMIT 3 + +struct rtl_dualmac_easy_concurrent_ctl { + enum band_type currentbandtype_backfordmdp; + bool bclose_bbandrf_for_dmsp; + bool bchange_to_dmdp; + bool bchange_to_dmsp; + bool bswitch_in_process; +}; + +struct rtl_dmsp_ctl { + bool bactivescan_for_slaveofdmsp; + bool bscan_for_anothermac_fordmsp; + bool bscan_for_itself_fordmsp; + bool bwritedig_for_anothermacofdmsp; + u32 curdigvalue_for_anothermacofdmsp; + bool bchangecckpdstate_for_anothermacofdmsp; + u8 curcckpdstate_for_anothermacofdmsp; + bool bchangetxhighpowerlvl_for_anothermacofdmsp; + u8 curtxhighlvl_for_anothermacofdmsp; + long rssivalmin_for_anothermacofdmsp; +}; + +struct rtl_global_var { + /* from this list we can get + * other adapter's rtl_priv */ + struct list_head glb_priv_list; + spinlock_t glb_list_lock; +}; + +struct rtl_btc_info { + u8 bt_type; + u8 btcoexist; + u8 ant_num; +}; + +struct rtl_btc_ops { + void (*btc_init_variables)(struct rtl_priv *rtlpriv); + void (*btc_init_hal_vars)(struct rtl_priv *rtlpriv); + void (*btc_init_hw_config)(struct rtl_priv *rtlpriv); + void (*btc_ips_notify)(struct rtl_priv *rtlpriv, u8 type); + void (*btc_lps_notify)(struct rtl_priv *rtlpriv, u8 type); + void (*btc_scan_notify)(struct rtl_priv *rtlpriv, u8 scantype); + void (*btc_connect_notify)(struct rtl_priv *rtlpriv, u8 action); + void (*btc_mediastatus_notify)(struct rtl_priv *rtlpriv, + enum rt_media_status mstatus); + void (*btc_periodical)(struct rtl_priv *rtlpriv); + void (*btc_halt_notify)(void); + void (*btc_btinfo_notify)(struct rtl_priv *rtlpriv, + u8 *tmp_buf, u8 length); + bool (*btc_is_limited_dig)(struct rtl_priv *rtlpriv); + bool (*btc_is_disable_edca_turbo)(struct rtl_priv *rtlpriv); + bool (*btc_is_bt_disabled)(struct rtl_priv *rtlpriv); + void (*btc_special_packet_notify)(struct rtl_priv *rtlpriv, + u8 pkt_type); +}; + +struct rtl_bt_coexist { + struct rtl_btc_ops *btc_ops; + struct rtl_btc_info btc_info; +}; + + +struct rtl_priv { + struct list_head list; + struct rtl_priv *buddy_priv; + struct rtl_global_var *glb_var; + struct rtl_dualmac_easy_concurrent_ctl easy_concurrent_ctl; + struct rtl_dmsp_ctl dmsp_ctl; + struct rtl_locks locks; + struct rtl_works works; + struct rtl_mac mac80211; + struct rtl_hal rtlhal; + struct rtl_regulatory regd; + struct rtl_rfkill rfkill; + struct rtl_io io; + struct rtl_phy phy; + struct rtl_dm dm; + struct rtl_security sec; + struct rtl_efuse efuse; + + struct rtl_ps_ctl psc; + struct rate_adaptive ra; + struct dynamic_primary_cca primarycca; + struct wireless_stats stats; + struct rt_link_detect link_info; + struct false_alarm_statistics falsealm_cnt; + + struct rtl_rate_priv *rate_priv; + + struct rtl_debug dbg; + + /* sta entry list for ap adhoc or mesh */ + struct list_head entry_list; + + /* + *hal_cfg : for diff cards + *intf_ops : for diff interrface usb/pcie + */ + struct rtl_hal_cfg *cfg; + struct rtl_intf_ops *intf_ops; + + /*this var will be set by set_bit, + and was used to indicate status of + interface or hardware */ + unsigned long status; + + /* intel Proximity, should be alloc mem + * in intel Proximity module and can only + * be used in intel Proximity mode */ + struct proxim proximity; + + /*for bt coexist use*/ + struct rtl_bt_coexist btcoexist; + + /* seperate 92ee from other ICs, + * 92ee use new trx flow. */ + bool use_new_trx_flow; + +#ifdef CONFIG_PM + struct wiphy_wowlan_support wowlan; +#endif + /*This must be the last item so + that it points to the data allocated + beyond this structure like: + rtl_pci_priv or rtl_usb_priv */ + u8 priv[0]; +}; + +#define rtl_priv(hw) (((struct rtl_priv *)(hw)->priv)) +#define rtl_mac(rtlpriv) (&((rtlpriv)->mac80211)) +#define rtl_hal(rtlpriv) (&((rtlpriv)->rtlhal)) +#define rtl_efuse(rtlpriv) (&((rtlpriv)->efuse)) +#define rtl_psc(rtlpriv) (&((rtlpriv)->psc)) +#define rtl_sec(rtlpriv) (&((rtlpriv)->sec)) +#define rtl_dm(rtlpriv) (&((rtlpriv)->dm)) +/*************************************** + Bluetooth Co-existance Related +****************************************/ + +enum bt_ant_num { + ANT_X2 = 0, + ANT_X1 = 1, +}; + +enum bt_co_type { + BT_2WIRE = 0, + BT_ISSC_3WIRE = 1, + BT_ACCEL = 2, + BT_CSR_BC4 = 3, + BT_CSR_BC8 = 4, + BT_RTL8756 = 5, + BT_RTL8723A = 6, + BT_RTL8821A = 7, + BT_RTL8723B = 8, + BT_RTL8192E = 9, + BT_RTL8812A = 11, +}; + +enum bt_total_ant_num { + ANT_TOTAL_X2 = 0, + ANT_TOTAL_X1 = 1 +}; + +enum bt_cur_state { + BT_OFF = 0, + BT_ON = 1, +}; + +enum bt_service_type { + BT_SCO = 0, + BT_A2DP = 1, + BT_HID = 2, + BT_HID_IDLE = 3, + BT_SCAN = 4, + BT_IDLE = 5, + BT_OTHER_ACTION = 6, + BT_BUSY = 7, + BT_OTHERBUSY = 8, + BT_PAN = 9, +}; + +enum bt_radio_shared { + BT_RADIO_SHARED = 0, + BT_RADIO_INDIVIDUAL = 1, +}; + +struct bt_coexist_info { + /* EEPROM BT info. */ + u8 eeprom_bt_coexist; + u8 eeprom_bt_type; + u8 eeprom_bt_ant_num; + u8 eeprom_bt_ant_isolation; + u8 eeprom_bt_radio_shared; + + u8 bt_coexistence; + u8 bt_ant_num; + u8 bt_coexist_type; + u8 bt_state; + u8 bt_cur_state; /* 0:on, 1:off */ + u8 bt_ant_isolation; /* 0:good, 1:bad */ + u8 bt_pape_ctrl; /* 0:SW, 1:SW/HW dynamic */ + u8 bt_service; + u8 bt_radio_shared_type; + u8 bt_rfreg_origin_1e; + u8 bt_rfreg_origin_1f; + u8 bt_rssi_state; + u32 ratio_tx; + u32 ratio_pri; + u32 bt_edca_ul; + u32 bt_edca_dl; + + bool b_init_set; + bool b_bt_busy_traffic; + bool b_bt_traffic_mode_set; + bool b_bt_non_traffic_mode_set; + + bool b_fw_coexist_all_off; + bool b_sw_coexist_all_off; + bool b_hw_coexist_all_off; + u32 current_state; + u32 previous_state; + u32 current_state_h; + u32 previous_state_h; + + u8 bt_pre_rssi_state; + u8 bt_pre_rssi_state1; + + u8 b_reg_bt_iso; + u8 b_reg_bt_sco; + bool b_balance_on; + u8 bt_active_zero_cnt; + bool b_cur_bt_disabled; + bool b_pre_bt_disabled; + + u8 bt_profile_case; + u8 bt_profile_action; + bool b_bt_busy; + bool b_hold_for_bt_operation; + u8 lps_counter; +}; + +/**************************************** + mem access macro define start + Call endian free function when + 1. Read/write packet content. + 2. Before write integer to IO. + 3. After read integer from IO. +****************************************/ +/* Convert little data endian to host ordering */ +#define EF1BYTE(_val) \ + ((u8)(_val)) +#define EF2BYTE(_val) \ + (le16_to_cpu(_val)) +#define EF4BYTE(_val) \ + (le32_to_cpu(_val)) + +/* Read data from memory */ +#define READEF1BYTE(_ptr) \ + EF1BYTE(*((u8 *)(_ptr))) +/* Read le16 data from memory and convert to host ordering */ +#define READEF2BYTE(_ptr) \ + EF2BYTE(*(_ptr)) +#define READEF4BYTE(_ptr) \ + EF4BYTE(*(_ptr)) + +/* Write data to memory */ +#define WRITEEF1BYTE(_ptr, _val) \ + (*((u8 *)(_ptr))) = EF1BYTE(_val) +/* Write le16 data to memory in host ordering */ +#define WRITEEF2BYTE(_ptr, _val) \ + (*((u16 *)(_ptr))) = EF2BYTE(_val) +#define WRITEEF4BYTE(_ptr, _val) \ + (*((u32 *)(_ptr))) = EF2BYTE(_val) + +/* Create a bit mask + * Examples: + * BIT_LEN_MASK_32(0) => 0x00000000 + * BIT_LEN_MASK_32(1) => 0x00000001 + * BIT_LEN_MASK_32(2) => 0x00000003 + * BIT_LEN_MASK_32(32) => 0xFFFFFFFF + */ +#define BIT_LEN_MASK_32(__bitlen) \ + (0xFFFFFFFF >> (32 - (__bitlen))) +#define BIT_LEN_MASK_16(__bitlen) \ + (0xFFFF >> (16 - (__bitlen))) +#define BIT_LEN_MASK_8(__bitlen) \ + (0xFF >> (8 - (__bitlen))) + +/* Create an offset bit mask + * Examples: + * BIT_OFFSET_LEN_MASK_32(0, 2) => 0x00000003 + * BIT_OFFSET_LEN_MASK_32(16, 2) => 0x00030000 + */ +#define BIT_OFFSET_LEN_MASK_32(__bitoffset, __bitlen) \ + (BIT_LEN_MASK_32(__bitlen) << (__bitoffset)) +#define BIT_OFFSET_LEN_MASK_16(__bitoffset, __bitlen) \ + (BIT_LEN_MASK_16(__bitlen) << (__bitoffset)) +#define BIT_OFFSET_LEN_MASK_8(__bitoffset, __bitlen) \ + (BIT_LEN_MASK_8(__bitlen) << (__bitoffset)) + +/*Description: + * Return 4-byte value in host byte ordering from + * 4-byte pointer in little-endian system. + */ +#define LE_P4BYTE_TO_HOST_4BYTE(__pstart) \ + (EF4BYTE(*((__le32 *)(__pstart)))) +#define LE_P2BYTE_TO_HOST_2BYTE(__pstart) \ + (EF2BYTE(*((__le16 *)(__pstart)))) +#define LE_P1BYTE_TO_HOST_1BYTE(__pstart) \ + (EF1BYTE(*((u8 *)(__pstart)))) + +/*Description: +Translate subfield (continuous bits in little-endian) of 4-byte +value to host byte ordering.*/ +#define LE_BITS_TO_4BYTE(__pstart, __bitoffset, __bitlen) \ + ( \ + (LE_P4BYTE_TO_HOST_4BYTE(__pstart) >> (__bitoffset)) & \ + BIT_LEN_MASK_32(__bitlen) \ + ) +#define LE_BITS_TO_2BYTE(__pstart, __bitoffset, __bitlen) \ + ( \ + (LE_P2BYTE_TO_HOST_2BYTE(__pstart) >> (__bitoffset)) & \ + BIT_LEN_MASK_16(__bitlen) \ + ) +#define LE_BITS_TO_1BYTE(__pstart, __bitoffset, __bitlen) \ + ( \ + (LE_P1BYTE_TO_HOST_1BYTE(__pstart) >> (__bitoffset)) & \ + BIT_LEN_MASK_8(__bitlen) \ + ) + +/* Description: + * Mask subfield (continuous bits in little-endian) of 4-byte value + * and return the result in 4-byte value in host byte ordering. + */ +#define LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) \ + ( \ + LE_P4BYTE_TO_HOST_4BYTE(__pstart) & \ + (~BIT_OFFSET_LEN_MASK_32(__bitoffset, __bitlen)) \ + ) +#define LE_BITS_CLEARED_TO_2BYTE(__pstart, __bitoffset, __bitlen) \ + ( \ + LE_P2BYTE_TO_HOST_2BYTE(__pstart) & \ + (~BIT_OFFSET_LEN_MASK_16(__bitoffset, __bitlen)) \ + ) +#define LE_BITS_CLEARED_TO_1BYTE(__pstart, __bitoffset, __bitlen) \ + ( \ + LE_P1BYTE_TO_HOST_1BYTE(__pstart) & \ + (~BIT_OFFSET_LEN_MASK_8(__bitoffset, __bitlen)) \ + ) + +/* Description: + * Set subfield of little-endian 4-byte value to specified value. + */ +#define SET_BITS_TO_LE_4BYTE(__pstart, __bitoffset, __bitlen, __val) \ + *((u32 *)(__pstart)) = \ + ( \ + LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) | \ + ((((u32)__val) & BIT_LEN_MASK_32(__bitlen)) << (__bitoffset)) \ + ); +#define SET_BITS_TO_LE_2BYTE(__pstart, __bitoffset, __bitlen, __val) \ + *((u16 *)(__pstart)) = \ + ( \ + LE_BITS_CLEARED_TO_2BYTE(__pstart, __bitoffset, __bitlen) | \ + ((((u16)__val) & BIT_LEN_MASK_16(__bitlen)) << (__bitoffset)) \ + ); +#define SET_BITS_TO_LE_1BYTE(__pstart, __bitoffset, __bitlen, __val) \ + *((u8 *)(__pstart)) = EF1BYTE \ + ( \ + LE_BITS_CLEARED_TO_1BYTE(__pstart, __bitoffset, __bitlen) | \ + ((((u8)__val) & BIT_LEN_MASK_8(__bitlen)) << (__bitoffset)) \ + ); + +#define N_BYTE_ALIGMENT(__value, __aligment) ((__aligment == 1) ? \ + (__value) : (((__value + __aligment - 1) / __aligment) * __aligment)) + +/**************************************** + mem access macro define end +****************************************/ + +#define byte(x , n) ((x >> (8 * n)) & 0xff) + +#define packet_get_type(_packet) (EF1BYTE((_packet).octet[0]) & 0xFC) +#define RTL_WATCH_DOG_TIME 2000 +#define MSECS(t) msecs_to_jiffies(t) +#define WLAN_FC_GET_VERS(fc) (le16_to_cpu(fc) & IEEE80211_FCTL_VERS) +#define WLAN_FC_GET_TYPE(fc) (le16_to_cpu(fc) & IEEE80211_FCTL_FTYPE) +#define WLAN_FC_GET_STYPE(fc) (le16_to_cou(fc) & IEEE80211_FCTL_STYPE) +#define WLAN_FC_MORE_DATA(fc) (le16_to_cpu(fc) & IEEE80211_FCTL_MOREDATA) +#define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4) +#define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ) +#define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4) + +#define RT_RF_OFF_LEVL_ASPM BIT(0) /*PCI ASPM */ +#define RT_RF_OFF_LEVL_CLK_REQ BIT(1) /*PCI clock request */ +#define RT_RF_OFF_LEVL_PCI_D3 BIT(2) /*PCI D3 mode */ +/*NIC halt, re-initialize hw parameters*/ +#define RT_RF_OFF_LEVL_HALT_NIC BIT(3) +#define RT_RF_OFF_LEVL_FREE_FW BIT(4) /*FW free, re-download the FW */ +#define RT_RF_OFF_LEVL_FW_32K BIT(5) /*FW in 32k */ +/*Always enable ASPM and Clock Req in initialization.*/ +#define RT_RF_PS_LEVEL_ALWAYS_ASPM BIT(6) +/* no matter RFOFF or SLEEP we set PS_ASPM_LEVL*/ +#define RT_PS_LEVEL_ASPM BIT(7) +/*When LPS is on, disable 2R if no packet is received or transmittd.*/ +#define RT_RF_LPS_DISALBE_2R BIT(30) +#define RT_RF_LPS_LEVEL_ASPM BIT(31) /*LPS with ASPM */ +#define RT_IN_PS_LEVEL(ppsc, _ps_flg) \ + ((ppsc->cur_ps_level & _ps_flg) ? true : false) +#define RT_CLEAR_PS_LEVEL(ppsc, _ps_flg) \ + (ppsc->cur_ps_level &= (~(_ps_flg))) +#define RT_SET_PS_LEVEL(ppsc, _ps_flg) \ + (ppsc->cur_ps_level |= _ps_flg) + +#define container_of_dwork_rtl(x , y , z) \ + container_of(container_of(x, struct delayed_work, work), y, z) + +#define FILL_OCTET_STRING(_os , _octet , _len) \ + (_os).octet = (u8 *)(_octet); \ + (_os).length = (_len); + +#define CP_MACADDR(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 LDPC_HT_ENABLE_RX BIT(0) +#define LDPC_HT_ENABLE_TX BIT(1) +#define LDPC_HT_TEST_TX_ENABLE BIT(2) +#define LDPC_HT_CAP_TX BIT(3) + +#define STBC_HT_ENABLE_RX BIT(0) +#define STBC_HT_ENABLE_TX BIT(1) +#define STBC_HT_TEST_TX_ENABLE BIT(2) +#define STBC_HT_CAP_TX BIT(3) + + +#define LDPC_VHT_ENABLE_RX BIT(0) +#define LDPC_VHT_ENABLE_TX BIT(1) +#define LDPC_VHT_TEST_TX_ENABLE BIT(2) +#define LDPC_VHT_CAP_TX BIT(3) + +#define STBC_VHT_ENABLE_RX BIT(0) +#define STBC_VHT_ENABLE_TX BIT(1) +#define STBC_VHT_TEST_TX_ENABLE BIT(2) +#define STBC_VHT_CAP_TX BIT(3) + + +static inline u8 rtl_read_byte(struct rtl_priv *rtlpriv, u32 addr) +{ + return rtlpriv->io.read8_sync(rtlpriv, addr); +} + +static inline u16 rtl_read_word(struct rtl_priv *rtlpriv, u32 addr) +{ + return rtlpriv->io.read16_sync(rtlpriv, addr); +} + +static inline u32 rtl_read_dword(struct rtl_priv *rtlpriv, u32 addr) +{ + return rtlpriv->io.read32_sync(rtlpriv, addr); +} + +static inline void rtl_write_byte(struct rtl_priv *rtlpriv, u32 addr, u8 val8) +{ + rtlpriv->io.write8_async(rtlpriv, addr, val8); + + if (rtlpriv->cfg->write_readback) + rtlpriv->io.read8_sync(rtlpriv, addr); +} + +static inline void rtl_write_word(struct rtl_priv *rtlpriv, u32 addr, u16 val16) +{ + rtlpriv->io.write16_async(rtlpriv, addr, val16); + + if (rtlpriv->cfg->write_readback) + rtlpriv->io.read16_sync(rtlpriv, addr); +} + +static inline void rtl_write_dword(struct rtl_priv *rtlpriv, + u32 addr, u32 val32) +{ + rtlpriv->io.write32_async(rtlpriv, addr, val32); + + if (rtlpriv->cfg->write_readback) + rtlpriv->io.read32_sync(rtlpriv, addr); +} + +static inline u32 rtl_get_bbreg(struct ieee80211_hw *hw, + u32 regaddr, u32 bitmask) +{ + return ((struct rtl_priv *)(hw)->priv)->cfg->ops->get_bbreg(hw, + regaddr, + bitmask); +} + +static inline void rtl_set_bbreg(struct ieee80211_hw *hw, u32 regaddr, + u32 bitmask, u32 data) +{ + struct rtl_priv *rtlpriv = hw->priv; + + rtlpriv->cfg->ops->set_bbreg(hw, regaddr, bitmask, data); +} + +static inline u32 rtl_get_rfreg(struct ieee80211_hw *hw, + enum radio_path rfpath, u32 regaddr, + u32 bitmask) +{ + return ((struct rtl_priv *)(hw)->priv)->cfg->ops->get_rfreg(hw, + rfpath, + regaddr, + bitmask); +} + +static inline void rtl_set_rfreg(struct ieee80211_hw *hw, + enum radio_path rfpath, u32 regaddr, + u32 bitmask, u32 data) +{ + ((struct rtl_priv *)(hw)->priv)->cfg->ops->set_rfreg(hw, + rfpath, regaddr, + bitmask, data); +} + +static inline bool is_hal_stop(struct rtl_hal *rtlhal) +{ + return _HAL_STATE_STOP == rtlhal->state; +} + +static inline void set_hal_start(struct rtl_hal *rtlhal) +{ + rtlhal->state = _HAL_STATE_START; +} + +static inline void set_hal_stop(struct rtl_hal *rtlhal) +{ + rtlhal->state = _HAL_STATE_STOP; +} + +static inline u8 get_rf_type(struct rtl_phy *rtlphy) +{ + return rtlphy->rf_type; +} + +static inline struct ieee80211_hdr *rtl_get_hdr(struct sk_buff *skb) +{ + return (struct ieee80211_hdr *)(skb->data); +} + +static inline __le16 rtl_get_fc(struct sk_buff *skb) +{ + return rtl_get_hdr(skb)->frame_control; +} + +static inline u16 rtl_get_tid_h(struct ieee80211_hdr *hdr) +{ + return (ieee80211_get_qos_ctl(hdr))[0] & IEEE80211_QOS_CTL_TID_MASK; +} + +static inline u16 rtl_get_tid(struct sk_buff *skb) +{ + return rtl_get_tid_h(rtl_get_hdr(skb)); +} + +static inline struct ieee80211_sta *rtl_find_sta(struct ieee80211_hw *hw, + u8 *mac_addr) +{ + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + return ieee80211_find_sta(mac->vif, mac_addr); +} + +struct ieee80211_hw *rtl_pci_get_hw_pointer(void); +#endif -- cgit v1.2.3 From e22f4eda7fe495b5cdac5c27684487ab5f0a913f Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 May 2014 16:25:34 -0500 Subject: staging: r8192ee: Add code for Bluetooth coexistence In the wireless tree, this code forms a separate mini driver. As the changes needed for the later drivers has not yet been merged, a separate version is needed here. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192ee/btcoexist/halbt_precomp.h | 50 + .../staging/rtl8192ee/btcoexist/halbtc8192e2ant.c | 4110 ++++++++++++++++++++ .../staging/rtl8192ee/btcoexist/halbtc8192e2ant.h | 161 + .../staging/rtl8192ee/btcoexist/halbtc8723b1ant.c | 3146 +++++++++++++++ .../staging/rtl8192ee/btcoexist/halbtc8723b1ant.h | 160 + .../staging/rtl8192ee/btcoexist/halbtc8723b2ant.c | 3929 +++++++++++++++++++ .../staging/rtl8192ee/btcoexist/halbtc8723b2ant.h | 145 + .../staging/rtl8192ee/btcoexist/halbtc8821a1ant.c | 2780 +++++++++++++ .../staging/rtl8192ee/btcoexist/halbtc8821a1ant.h | 158 + .../staging/rtl8192ee/btcoexist/halbtc8821a2ant.c | 3438 ++++++++++++++++ .../staging/rtl8192ee/btcoexist/halbtc8821a2ant.h | 179 + drivers/staging/rtl8192ee/btcoexist/halbtcoutsrc.c | 1307 +++++++ drivers/staging/rtl8192ee/btcoexist/halbtcoutsrc.h | 537 +++ drivers/staging/rtl8192ee/btcoexist/rtl_btc.c | 194 + drivers/staging/rtl8192ee/btcoexist/rtl_btc.h | 62 + 15 files changed, 20356 insertions(+) create mode 100644 drivers/staging/rtl8192ee/btcoexist/halbt_precomp.h create mode 100644 drivers/staging/rtl8192ee/btcoexist/halbtc8192e2ant.c create mode 100644 drivers/staging/rtl8192ee/btcoexist/halbtc8192e2ant.h create mode 100644 drivers/staging/rtl8192ee/btcoexist/halbtc8723b1ant.c create mode 100644 drivers/staging/rtl8192ee/btcoexist/halbtc8723b1ant.h create mode 100644 drivers/staging/rtl8192ee/btcoexist/halbtc8723b2ant.c create mode 100644 drivers/staging/rtl8192ee/btcoexist/halbtc8723b2ant.h create mode 100644 drivers/staging/rtl8192ee/btcoexist/halbtc8821a1ant.c create mode 100644 drivers/staging/rtl8192ee/btcoexist/halbtc8821a1ant.h create mode 100644 drivers/staging/rtl8192ee/btcoexist/halbtc8821a2ant.c create mode 100644 drivers/staging/rtl8192ee/btcoexist/halbtc8821a2ant.h create mode 100644 drivers/staging/rtl8192ee/btcoexist/halbtcoutsrc.c create mode 100644 drivers/staging/rtl8192ee/btcoexist/halbtcoutsrc.h create mode 100644 drivers/staging/rtl8192ee/btcoexist/rtl_btc.c create mode 100644 drivers/staging/rtl8192ee/btcoexist/rtl_btc.h diff --git a/drivers/staging/rtl8192ee/btcoexist/halbt_precomp.h b/drivers/staging/rtl8192ee/btcoexist/halbt_precomp.h new file mode 100644 index 000000000000..56e6c4651891 --- /dev/null +++ b/drivers/staging/rtl8192ee/btcoexist/halbt_precomp.h @@ -0,0 +1,50 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek 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. + * + * + ******************************************************************************/ +#ifndef __HALBT_PRECOMP_H__ +#define __HALBT_PRECOMP_H__ +/************************************************************* + * include files + *************************************************************/ +#include "../wifi.h" +#include "../efuse.h" +#include "../base.h" +#include "../regd.h" +#include "../cam.h" +#include "../ps.h" +#include "../pci.h" + +#include "halbtcoutsrc.h" + + +#include "halbtc8192e2ant.h" +#include "halbtc8723b1ant.h" +#include "halbtc8723b2ant.h" +#include "halbtc8821a2ant.h" +#include "halbtc8821a1ant.h" + +#define MASKBYTE0 0xff +#define MASKBYTE1 0xff00 +#define MASKBYTE2 0xff0000 +#define MASKBYTE3 0xff000000 +#define MASKHWORD 0xffff0000 +#define MASKLWORD 0x0000ffff +#define MASKDWORD 0xffffffff +#define MASK12BITS 0xfff +#define MASKH4BITS 0xf0000000 +#define MASKOFDM_D 0xffc00000 +#define MASKCCK 0x3f3f3f3f + +#endif /* __HALBT_PRECOMP_H__ */ diff --git a/drivers/staging/rtl8192ee/btcoexist/halbtc8192e2ant.c b/drivers/staging/rtl8192ee/btcoexist/halbtc8192e2ant.c new file mode 100644 index 000000000000..ab2cc2fadd80 --- /dev/null +++ b/drivers/staging/rtl8192ee/btcoexist/halbtc8192e2ant.c @@ -0,0 +1,4110 @@ +/************************************************************** + * Description: + * + * This file is for RTL8192E Co-exist mechanism + * + * History + * 2012/11/15 Cosa first check in. + * + **************************************************************/ + +/************************************************************** + * include files + **************************************************************/ +#include "halbt_precomp.h" +/************************************************************** + * Global variables, these are static variables + **************************************************************/ +static struct coex_dm_8192e_2ant glcoex_dm_8192e_2ant; +static struct coex_dm_8192e_2ant *coex_dm = &glcoex_dm_8192e_2ant; +static struct coex_sta_8192e_2ant glcoex_sta_8192e_2ant; +static struct coex_sta_8192e_2ant *coex_sta = &glcoex_sta_8192e_2ant; + +static const char *const glbt_infosrc8192e2ant[] = { + "BT Info[wifi fw]", + "BT Info[bt rsp]", + "BT Info[bt auto report]", +}; + +static u32 glcoex_ver_date_8192e_2ant = 20130902; +static u32 glcoex_ver_8192e_2ant = 0x34; + +/************************************************************** + * local function proto type if needed + **************************************************************/ +/************************************************************** + * local function start with halbtc8192e2ant_ + **************************************************************/ +static u8 halbtc8192e2ant_btrssi_state(u8 level_num, u8 rssi_thresh, + u8 rssi_thresh1) +{ + int btrssi = 0; + u8 btrssi_state = coex_sta->pre_bt_rssi_state; + + btrssi = coex_sta->bt_rssi; + + if (level_num == 2) { + if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) || + (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW)) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "BT Rssi pre state = LOW\n"); + if (btrssi >= (rssi_thresh + + BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT)) { + btrssi_state = BTC_RSSI_STATE_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "BT Rssi state switch to High\n"); + } else { + btrssi_state = BTC_RSSI_STATE_STAY_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "BT Rssi state stay at Low\n"); + } + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "BT Rssi pre state = HIGH\n"); + if (btrssi < rssi_thresh) { + btrssi_state = BTC_RSSI_STATE_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "BT Rssi state switch to Low\n"); + } else { + btrssi_state = BTC_RSSI_STATE_STAY_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "BT Rssi state stay at High\n"); + } + } + } else if (level_num == 3) { + if (rssi_thresh > rssi_thresh1) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "BT Rssi thresh error!!\n"); + return coex_sta->pre_bt_rssi_state; + } + + if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) || + (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW)) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "BT Rssi pre state = LOW\n"); + if (btrssi >= (rssi_thresh + + BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT)) { + btrssi_state = BTC_RSSI_STATE_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "BT Rssi state switch to Medium\n"); + } else { + btrssi_state = BTC_RSSI_STATE_STAY_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "BT Rssi state stay at Low\n"); + } + } else if ((coex_sta->pre_bt_rssi_state == + BTC_RSSI_STATE_MEDIUM) || + (coex_sta->pre_bt_rssi_state == + BTC_RSSI_STATE_STAY_MEDIUM)) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi pre state = MEDIUM\n"); + if (btrssi >= (rssi_thresh1 + + BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT)) { + btrssi_state = BTC_RSSI_STATE_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "BT Rssi state switch to High\n"); + } else if (btrssi < rssi_thresh) { + btrssi_state = BTC_RSSI_STATE_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "BT Rssi state switch to Low\n"); + } else { + btrssi_state = BTC_RSSI_STATE_STAY_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "BT Rssi state stay at Medium\n"); + } + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "BT Rssi pre state = HIGH\n"); + if (btrssi < rssi_thresh1) { + btrssi_state = BTC_RSSI_STATE_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "BT Rssi state switch to Medium\n"); + } else { + btrssi_state = BTC_RSSI_STATE_STAY_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "BT Rssi state stay at High\n"); + } + } + } + + coex_sta->pre_bt_rssi_state = btrssi_state; + + return btrssi_state; +} + +static u8 halbtc8192e2ant_wifirssi_state(struct btc_coexist *btcoexist, + u8 index, u8 level_num, u8 rssi_thresh, + u8 rssi_thresh1) +{ + int wifirssi = 0; + u8 wifirssi_state = coex_sta->pre_wifi_rssi_state[index]; + + btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifirssi); + + if (level_num == 2) { + if ((coex_sta->pre_wifi_rssi_state[index] == + BTC_RSSI_STATE_LOW) || + (coex_sta->pre_wifi_rssi_state[index] == + BTC_RSSI_STATE_STAY_LOW)) { + if (wifirssi >= (rssi_thresh + + BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT)) { + wifirssi_state = BTC_RSSI_STATE_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "wifi RSSI state switch to High\n"); + } else { + wifirssi_state = BTC_RSSI_STATE_STAY_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "wifi RSSI state stay at Low\n"); + } + } else { + if (wifirssi < rssi_thresh) { + wifirssi_state = BTC_RSSI_STATE_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "wifi RSSI state switch to Low\n"); + } else { + wifirssi_state = BTC_RSSI_STATE_STAY_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "wifi RSSI state stay at High\n"); + } + } + } else if (level_num == 3) { + if (rssi_thresh > rssi_thresh1) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, + "wifi RSSI thresh error!!\n"); + return coex_sta->pre_wifi_rssi_state[index]; + } + + if ((coex_sta->pre_wifi_rssi_state[index] == + BTC_RSSI_STATE_LOW) || + (coex_sta->pre_wifi_rssi_state[index] == + BTC_RSSI_STATE_STAY_LOW)) { + if (wifirssi >= (rssi_thresh + + BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT)) { + wifirssi_state = BTC_RSSI_STATE_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "wifi RSSI state switch to Medium\n"); + } else { + wifirssi_state = BTC_RSSI_STATE_STAY_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "wifi RSSI state stay at Low\n"); + } + } else if ((coex_sta->pre_wifi_rssi_state[index] == + BTC_RSSI_STATE_MEDIUM) || + (coex_sta->pre_wifi_rssi_state[index] == + BTC_RSSI_STATE_STAY_MEDIUM)) { + if (wifirssi >= (rssi_thresh1 + + BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT)) { + wifirssi_state = BTC_RSSI_STATE_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "wifi RSSI state switch to High\n"); + } else if (wifirssi < rssi_thresh) { + wifirssi_state = BTC_RSSI_STATE_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "wifi RSSI state switch to Low\n"); + } else { + wifirssi_state = BTC_RSSI_STATE_STAY_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "wifi RSSI state stay at Medium\n"); + } + } else { + if (wifirssi < rssi_thresh1) { + wifirssi_state = BTC_RSSI_STATE_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "wifi RSSI state switch to Medium\n"); + } else { + wifirssi_state = BTC_RSSI_STATE_STAY_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "wifi RSSI state stay at High\n"); + } + } + } + + coex_sta->pre_wifi_rssi_state[index] = wifirssi_state; + + return wifirssi_state; +} + +static void halbtc_monitor_bt_enable_disable(struct btc_coexist *btcoexist) +{ + static bool pre_bt_disabled; + static u32 bt_disable_cnt; + bool bt_active = true, bt_disabled = false; + + /* This function check if bt is disabled */ + + if (coex_sta->high_priority_tx == 0 && + coex_sta->high_priority_rx == 0 && + coex_sta->low_priority_tx == 0 && + coex_sta->low_priority_rx == 0) + bt_active = false; + + if (coex_sta->high_priority_tx == 0xffff && + coex_sta->high_priority_rx == 0xffff && + coex_sta->low_priority_tx == 0xffff && + coex_sta->low_priority_rx == 0xffff) + bt_active = false; + + if (bt_active) { + bt_disable_cnt = 0; + bt_disabled = false; + btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_DISABLE, + &bt_disabled); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, + "[BTCoex], BT is enabled !!\n"); + } else { + bt_disable_cnt++; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, + "[BTCoex], bt all counters = 0, %d times!!\n", + bt_disable_cnt); + if (bt_disable_cnt >= 2) { + bt_disabled = true; + btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_DISABLE, + &bt_disabled); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, + "[BTCoex], BT is disabled !!\n"); + } + } + if (pre_bt_disabled != bt_disabled) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, + "[BTCoex], BT is from %s to %s!!\n", + (pre_bt_disabled ? "disabled" : "enabled"), + (bt_disabled ? "disabled" : "enabled")); + pre_bt_disabled = bt_disabled; + } +} + +static u32 halbtc8192e2ant_decidera_mask(struct btc_coexist *btcoexist, + u8 sstype, u32 ra_masktype) +{ + u32 disra_mask = 0x0; + + switch (ra_masktype) { + case 0: /* normal mode */ + if (sstype == 2) + disra_mask = 0x0; /* enable 2ss */ + else + disra_mask = 0xfff00000;/* disable 2ss */ + break; + case 1: /* disable cck 1/2 */ + if (sstype == 2) + disra_mask = 0x00000003;/* enable 2ss */ + else + disra_mask = 0xfff00003;/* disable 2ss */ + break; + case 2: /* disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4 */ + if (sstype == 2) + disra_mask = 0x0001f1f7;/* enable 2ss */ + else + disra_mask = 0xfff1f1f7;/* disable 2ss */ + break; + default: + break; + } + + return disra_mask; +} + +static void halbtc8192e2ant_updatera_mask(struct btc_coexist *btcoexist, + bool force_exec, u32 dis_ratemask) +{ + coex_dm->curra_mask = dis_ratemask; + + if (force_exec || (coex_dm->prera_mask != coex_dm->curra_mask)) + btcoexist->btc_set(btcoexist, BTC_SET_ACT_UPDATE_ra_mask, + &coex_dm->curra_mask); + coex_dm->prera_mask = coex_dm->curra_mask; +} + +static void autorate_fallback_retry(struct btc_coexist *btcoexist, + bool force_exec, u8 type) +{ + bool wifi_under_bmode = false; + + coex_dm->cur_arfrtype = type; + + if (force_exec || (coex_dm->pre_arfrtype != coex_dm->cur_arfrtype)) { + switch (coex_dm->cur_arfrtype) { + case 0: /* normal mode */ + btcoexist->btc_write_4byte(btcoexist, 0x430, + coex_dm->backup_arfr_cnt1); + btcoexist->btc_write_4byte(btcoexist, 0x434, + coex_dm->backup_arfr_cnt2); + break; + case 1: + btcoexist->btc_get(btcoexist, + BTC_GET_BL_WIFI_UNDER_B_MODE, + &wifi_under_bmode); + if (wifi_under_bmode) { + btcoexist->btc_write_4byte(btcoexist, 0x430, + 0x0); + btcoexist->btc_write_4byte(btcoexist, 0x434, + 0x01010101); + } else { + btcoexist->btc_write_4byte(btcoexist, 0x430, + 0x0); + btcoexist->btc_write_4byte(btcoexist, 0x434, + 0x04030201); + } + break; + default: + break; + } + } + + coex_dm->pre_arfrtype = coex_dm->cur_arfrtype; +} + +static void halbtc8192e2ant_retrylimit(struct btc_coexist *btcoexist, + bool force_exec, u8 type) +{ + coex_dm->cur_retrylimit_type = type; + + if (force_exec || (coex_dm->pre_retrylimit_type != + coex_dm->cur_retrylimit_type)) { + switch (coex_dm->cur_retrylimit_type) { + case 0: /* normal mode */ + btcoexist->btc_write_2byte(btcoexist, 0x42a, + coex_dm->backup_retrylimit); + break; + case 1: /* retry limit = 8 */ + btcoexist->btc_write_2byte(btcoexist, 0x42a, + 0x0808); + break; + default: + break; + } + } + + coex_dm->pre_retrylimit_type = coex_dm->cur_retrylimit_type; +} + +static void halbtc8192e2ant_ampdu_maxtime(struct btc_coexist *btcoexist, + bool force_exec, u8 type) +{ + coex_dm->cur_ampdutime_type = type; + + if (force_exec || (coex_dm->pre_ampdutime_type != + coex_dm->cur_ampdutime_type)) { + switch (coex_dm->cur_ampdutime_type) { + case 0: /* normal mode */ + btcoexist->btc_write_1byte(btcoexist, 0x456, + coex_dm->backup_ampdu_maxtime); + break; + case 1: /* AMPDU timw = 0x38 * 32us */ + btcoexist->btc_write_1byte(btcoexist, 0x456, 0x38); + break; + default: + break; + } + } + + coex_dm->pre_ampdutime_type = coex_dm->cur_ampdutime_type; +} + +static void halbtc8192e2ant_limited_tx(struct btc_coexist *btcoexist, + bool force_exec, u8 ra_masktype, + u8 arfr_type, u8 retrylimit_type, + u8 ampdutime_type) +{ + u32 disra_mask = 0x0; + + coex_dm->curra_masktype = ra_masktype; + disra_mask = halbtc8192e2ant_decidera_mask(btcoexist, + coex_dm->cur_sstype, + ra_masktype); + halbtc8192e2ant_updatera_mask(btcoexist, force_exec, disra_mask); + + autorate_fallback_retry(btcoexist, force_exec, arfr_type); + halbtc8192e2ant_retrylimit(btcoexist, force_exec, retrylimit_type); + halbtc8192e2ant_ampdu_maxtime(btcoexist, force_exec, ampdutime_type); +} + +static void halbtc8192e2ant_limited_rx(struct btc_coexist *btcoexist, + bool force_exec, bool rej_ap_agg_pkt, + bool b_bt_ctrl_agg_buf_size, + u8 agg_buf_size) +{ + bool reject_rx_agg = rej_ap_agg_pkt; + bool bt_ctrl_rx_agg_size = b_bt_ctrl_agg_buf_size; + u8 rx_agg_size = agg_buf_size; + + /********************************************* + * Rx Aggregation related setting + *********************************************/ + btcoexist->btc_set(btcoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, + &reject_rx_agg); + /* decide BT control aggregation buf size or not */ + btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, + &bt_ctrl_rx_agg_size); + /* aggregation buf size, only work + * when BT control Rx aggregation size. */ + btcoexist->btc_set(btcoexist, BTC_SET_U1_AGG_BUF_SIZE, &rx_agg_size); + /* real update aggregation setting */ + btcoexist->btc_set(btcoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL); +} + +static void halbtc8192e2ant_monitor_bt_ctr(struct btc_coexist *btcoexist) +{ + u32 reg_hp_txrx, reg_lp_txrx, u32tmp; + u32 reg_hp_tx = 0, reg_hp_rx = 0, reg_lp_tx = 0, reg_lp_rx = 0; + + reg_hp_txrx = 0x770; + reg_lp_txrx = 0x774; + + u32tmp = btcoexist->btc_read_4byte(btcoexist, reg_hp_txrx); + reg_hp_tx = u32tmp & MASKLWORD; + reg_hp_rx = (u32tmp & MASKHWORD)>>16; + + u32tmp = btcoexist->btc_read_4byte(btcoexist, reg_lp_txrx); + reg_lp_tx = u32tmp & MASKLWORD; + reg_lp_rx = (u32tmp & MASKHWORD)>>16; + + coex_sta->high_priority_tx = reg_hp_tx; + coex_sta->high_priority_rx = reg_hp_rx; + coex_sta->low_priority_tx = reg_lp_tx; + coex_sta->low_priority_rx = reg_lp_rx; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, + "[BTCoex] High Priority Tx/Rx (reg 0x%x) = 0x%x(%d)/0x%x(%d)\n", + reg_hp_txrx, reg_hp_tx, reg_hp_tx, reg_hp_rx, reg_hp_rx); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, + "[BTCoex] Low Priority Tx/Rx (reg 0x%x) = 0x%x(%d)/0x%x(%d)\n", + reg_lp_txrx, reg_lp_tx, reg_lp_tx, reg_lp_rx, reg_lp_rx); + + /* reset counter */ + btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc); +} + +static void halbtc8192e2ant_querybt_info(struct btc_coexist *btcoexist) +{ + u8 h2c_parameter[1] = {0}; + + coex_sta->c2h_bt_info_req_sent = true; + + h2c_parameter[0] |= BIT(0); /* trigger */ + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], Query Bt Info, FW write 0x61 = 0x%x\n", + h2c_parameter[0]); + + btcoexist->btc_fill_h2c(btcoexist, 0x61, 1, h2c_parameter); +} + +static void halbtc8192e2ant_update_btlink_info(struct btc_coexist *btcoexist) +{ + struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; + bool bt_hson = false; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hson); + + bt_link_info->bt_link_exist = coex_sta->bt_link_exist; + bt_link_info->sco_exist = coex_sta->sco_exist; + bt_link_info->a2dp_exist = coex_sta->a2dp_exist; + bt_link_info->pan_exist = coex_sta->pan_exist; + bt_link_info->hid_exist = coex_sta->hid_exist; + + /* work around for HS mode. */ + if (bt_hson) { + bt_link_info->pan_exist = true; + bt_link_info->bt_link_exist = true; + } + + /* check if Sco only */ + if (bt_link_info->sco_exist && + !bt_link_info->a2dp_exist && + !bt_link_info->pan_exist && + !bt_link_info->hid_exist) + bt_link_info->sco_only = true; + else + bt_link_info->sco_only = false; + + /* check if A2dp only */ + if (!bt_link_info->sco_exist && + bt_link_info->a2dp_exist && + !bt_link_info->pan_exist && + !bt_link_info->hid_exist) + bt_link_info->a2dp_only = true; + else + bt_link_info->a2dp_only = false; + + /* check if Pan only */ + if (!bt_link_info->sco_exist && + !bt_link_info->a2dp_exist && + bt_link_info->pan_exist && + !bt_link_info->hid_exist) + bt_link_info->pan_only = true; + else + bt_link_info->pan_only = false; + + /* check if Hid only */ + if (!bt_link_info->sco_exist && + !bt_link_info->a2dp_exist && + !bt_link_info->pan_exist && + bt_link_info->hid_exist) + bt_link_info->hid_only = true; + else + bt_link_info->hid_only = false; +} + +static u8 halbtc8192e2ant_action_algorithm(struct btc_coexist *btcoexist) +{ + struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; + struct btc_stack_info *stack_info = &btcoexist->stack_info; + bool bt_hson = false; + u8 algorithm = BT_8192E_2ANT_COEX_ALGO_UNDEFINED; + u8 num_diffprofile = 0; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hson); + + if (!bt_link_info->bt_link_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "No BT link exists!!!\n"); + return algorithm; + } + + if (bt_link_info->sco_exist) + num_diffprofile++; + if (bt_link_info->hid_exist) + num_diffprofile++; + if (bt_link_info->pan_exist) + num_diffprofile++; + if (bt_link_info->a2dp_exist) + num_diffprofile++; + + if (num_diffprofile == 1) { + if (bt_link_info->sco_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "SCO only\n"); + algorithm = BT_8192E_2ANT_COEX_ALGO_SCO; + } else { + if (bt_link_info->hid_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "HID only\n"); + algorithm = BT_8192E_2ANT_COEX_ALGO_HID; + } else if (bt_link_info->a2dp_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "A2DP only\n"); + algorithm = BT_8192E_2ANT_COEX_ALGO_A2DP; + } else if (bt_link_info->pan_exist) { + if (bt_hson) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "PAN(HS) only\n"); + algorithm = + BT_8192E_2ANT_COEX_ALGO_PANHS; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "PAN(EDR) only\n"); + algorithm = + BT_8192E_2ANT_COEX_ALGO_PANEDR; + } + } + } + } else if (num_diffprofile == 2) { + if (bt_link_info->sco_exist) { + if (bt_link_info->hid_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "SCO + HID\n"); + algorithm = BT_8192E_2ANT_COEX_ALGO_SCO; + } else if (bt_link_info->a2dp_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "SCO + A2DP ==> SCO\n"); + algorithm = BT_8192E_2ANT_COEX_ALGO_PANEDR_HID; + } else if (bt_link_info->pan_exist) { + if (bt_hson) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "SCO + PAN(HS)\n"); + algorithm = BT_8192E_2ANT_COEX_ALGO_SCO; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "SCO + PAN(EDR)\n"); + algorithm = + BT_8192E_2ANT_COEX_ALGO_SCO_PAN; + } + } + } else { + if (bt_link_info->hid_exist && + bt_link_info->a2dp_exist) { + if (stack_info->num_of_hid >= 2) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "HID*2 + A2DP\n"); + algorithm = + BT_8192E_2ANT_COEX_ALGO_HID_A2DP_PANEDR; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "HID + A2DP\n"); + algorithm = + BT_8192E_2ANT_COEX_ALGO_HID_A2DP; + } + } else if (bt_link_info->hid_exist && + bt_link_info->pan_exist) { + if (bt_hson) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "HID + PAN(HS)\n"); + algorithm = BT_8192E_2ANT_COEX_ALGO_HID; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "HID + PAN(EDR)\n"); + algorithm = + BT_8192E_2ANT_COEX_ALGO_PANEDR_HID; + } + } else if (bt_link_info->pan_exist && + bt_link_info->a2dp_exist) { + if (bt_hson) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "A2DP + PAN(HS)\n"); + algorithm = + BT_8192E_2ANT_COEX_ALGO_A2DP_PANHS; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "A2DP + PAN(EDR)\n"); + algorithm = + BT_8192E_2ANT_COEX_ALGO_PANEDR_A2DP; + } + } + } + } else if (num_diffprofile == 3) { + if (bt_link_info->sco_exist) { + if (bt_link_info->hid_exist && + bt_link_info->a2dp_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "SCO + HID + A2DP ==> HID\n"); + algorithm = BT_8192E_2ANT_COEX_ALGO_PANEDR_HID; + } else if (bt_link_info->hid_exist && + bt_link_info->pan_exist) { + if (bt_hson) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "SCO + HID + PAN(HS)\n"); + algorithm = BT_8192E_2ANT_COEX_ALGO_SCO; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "SCO + HID + PAN(EDR)\n"); + algorithm = + BT_8192E_2ANT_COEX_ALGO_SCO_PAN; + } + } else if (bt_link_info->pan_exist && + bt_link_info->a2dp_exist) { + if (bt_hson) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "SCO + A2DP + PAN(HS)\n"); + algorithm = BT_8192E_2ANT_COEX_ALGO_SCO; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "SCO + A2DP + PAN(EDR)\n"); + algorithm = + BT_8192E_2ANT_COEX_ALGO_PANEDR_HID; + } + } + } else { + if (bt_link_info->hid_exist && + bt_link_info->pan_exist && + bt_link_info->a2dp_exist) { + if (bt_hson) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "HID + A2DP + PAN(HS)\n"); + algorithm = + BT_8192E_2ANT_COEX_ALGO_HID_A2DP; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "HID + A2DP + PAN(EDR)\n"); + algorithm = + BT_8192E_2ANT_COEX_ALGO_HID_A2DP_PANEDR; + } + } + } + } else if (num_diffprofile >= 3) { + if (bt_link_info->sco_exist) { + if (bt_link_info->hid_exist && + bt_link_info->pan_exist && + bt_link_info->a2dp_exist) { + if (bt_hson) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "ErrorSCO+HID+A2DP+PAN(HS)\n"); + + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "SCO+HID+A2DP+PAN(EDR)\n"); + algorithm = + BT_8192E_2ANT_COEX_ALGO_PANEDR_HID; + } + } + } + } + + return algorithm; +} + +static void halbtc8192e2ant_setfw_dac_swinglevel(struct btc_coexist *btcoexist, + u8 dac_swinglvl) +{ + u8 h2c_parameter[1] = {0}; + + /* There are several type of dacswing + * 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6 */ + h2c_parameter[0] = dac_swinglvl; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], Set Dac Swing Level = 0x%x\n", dac_swinglvl); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], FW write 0x64 = 0x%x\n", h2c_parameter[0]); + + btcoexist->btc_fill_h2c(btcoexist, 0x64, 1, h2c_parameter); +} + +static void halbtc8192e2ant_set_fwdec_btpwr(struct btc_coexist *btcoexist, + u8 dec_btpwr_lvl) +{ + u8 h2c_parameter[1] = {0}; + + h2c_parameter[0] = dec_btpwr_lvl; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex] decrease Bt Power level = %d, FW write 0x62 = 0x%x\n", + dec_btpwr_lvl, h2c_parameter[0]); + + btcoexist->btc_fill_h2c(btcoexist, 0x62, 1, h2c_parameter); +} + +static void halbtc8192e2ant_dec_btpwr(struct btc_coexist *btcoexist, + bool force_exec, u8 dec_btpwr_lvl) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, + "[BTCoex], %s Dec BT power level = %d\n", + (force_exec ? "force to" : ""), dec_btpwr_lvl); + coex_dm->cur_dec_bt_pwr = dec_btpwr_lvl; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], preBtDecPwrLvl =%d, curBtDecPwrLvl =%d\n", + coex_dm->pre_dec_bt_pwr, coex_dm->cur_dec_bt_pwr); + } + halbtc8192e2ant_set_fwdec_btpwr(btcoexist, coex_dm->cur_dec_bt_pwr); + + coex_dm->pre_dec_bt_pwr = coex_dm->cur_dec_bt_pwr; +} + +static void halbtc8192e2ant_set_bt_autoreport(struct btc_coexist *btcoexist, + bool enable_autoreport) +{ + u8 h2c_parameter[1] = {0}; + + h2c_parameter[0] = 0; + + if (enable_autoreport) + h2c_parameter[0] |= BIT(0); + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], BT FW auto report : %s, FW write 0x68 = 0x%x\n", + (enable_autoreport ? "Enabled!!" : "Disabled!!"), + h2c_parameter[0]); + + btcoexist->btc_fill_h2c(btcoexist, 0x68, 1, h2c_parameter); +} + +static void halbtc8192e2ant_bt_autoreport(struct btc_coexist *btcoexist, + bool force_exec, + bool enable_autoreport) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, + "[BTCoex], %s BT Auto report = %s\n", + (force_exec ? "force to" : ""), + ((enable_autoreport) ? "Enabled" : "Disabled")); + coex_dm->cur_bt_auto_report = enable_autoreport; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex] bPreBtAutoReport =%d, bCurBtAutoReport =%d\n", + coex_dm->pre_bt_auto_report, + coex_dm->cur_bt_auto_report); + + if (coex_dm->pre_bt_auto_report == coex_dm->cur_bt_auto_report) + return; + } + halbtc8192e2ant_set_bt_autoreport(btcoexist, + coex_dm->cur_bt_auto_report); + + coex_dm->pre_bt_auto_report = coex_dm->cur_bt_auto_report; +} + +static void halbtc8192e2ant_fw_dac_swinglvl(struct btc_coexist *btcoexist, + bool force_exec, u8 fw_dac_swinglvl) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, + "[BTCoex], %s set FW Dac Swing level = %d\n", + (force_exec ? "force to" : ""), fw_dac_swinglvl); + coex_dm->cur_fw_dac_swing_lvl = fw_dac_swinglvl; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex] preFwDacSwingLvl =%d, curFwDacSwingLvl =%d\n", + coex_dm->pre_fw_dac_swing_lvl, + coex_dm->cur_fw_dac_swing_lvl); + + if (coex_dm->pre_fw_dac_swing_lvl == + coex_dm->cur_fw_dac_swing_lvl) + return; + } + + halbtc8192e2ant_setfw_dac_swinglevel(btcoexist, + coex_dm->cur_fw_dac_swing_lvl); + + coex_dm->pre_fw_dac_swing_lvl = coex_dm->cur_fw_dac_swing_lvl; +} + +static void set_sw_rf_rx_lpf_corner(struct btc_coexist *btcoexist, + bool rx_rf_shrink_on) +{ + if (rx_rf_shrink_on) { + /* Shrink RF Rx LPF corner */ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], Shrink RF Rx LPF corner!!\n"); + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1e, + 0xfffff, 0xffffc); + } else { + /* Resume RF Rx LPF corner + * After initialized, we can use coex_dm->btRf0x1eBackup */ + if (btcoexist->initilized) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], Resume RF Rx LPF corner!!\n"); + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1e, + 0xfffff, + coex_dm->bt_rf0x1e_backup); + } + } +} + +static void halbtc8192e2ant_rf_shrink(struct btc_coexist *btcoexist, + bool force_exec, bool rx_rf_shrink_on) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, + "[BTCoex], %s turn Rx RF Shrink = %s\n", + (force_exec ? "force to" : ""), + ((rx_rf_shrink_on) ? "ON" : "OFF")); + coex_dm->cur_rf_rx_lpf_shrink = rx_rf_shrink_on; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, + "[BTCoex]bPreRfRxLpfShrink =%d, bCurRfRxLpfShrink =%d\n", + coex_dm->pre_rf_rx_lpf_shrink, + coex_dm->cur_rf_rx_lpf_shrink); + + if (coex_dm->pre_rf_rx_lpf_shrink == + coex_dm->cur_rf_rx_lpf_shrink) + return; + } + set_sw_rf_rx_lpf_corner(btcoexist, coex_dm->cur_rf_rx_lpf_shrink); + + coex_dm->pre_rf_rx_lpf_shrink = coex_dm->cur_rf_rx_lpf_shrink; +} + +static void halbtc8192e2ant_set_dac_swingreg(struct btc_coexist *btcoexist, + u32 level) +{ + u8 val = (u8)level; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], Write SwDacSwing = 0x%x\n", level); + btcoexist->btc_write_1byte_bitmask(btcoexist, 0x883, 0x3e, val); +} + +static void setsw_fulltime_dacswing(struct btc_coexist *btcoexist, + bool sw_dac_swingon, + u32 sw_dac_swinglvl) +{ + if (sw_dac_swingon) + halbtc8192e2ant_set_dac_swingreg(btcoexist, sw_dac_swinglvl); + else + halbtc8192e2ant_set_dac_swingreg(btcoexist, 0x18); +} + +static void halbtc8192e2ant_dacswing(struct btc_coexist *btcoexist, + bool force_exec, bool dac_swingon, + u32 dac_swinglvl) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, + "[BTCoex], %s turn DacSwing =%s, dac_swinglvl = 0x%x\n", + (force_exec ? "force to" : ""), + ((dac_swingon) ? "ON" : "OFF"), dac_swinglvl); + coex_dm->cur_dac_swing_on = dac_swingon; + coex_dm->cur_dac_swing_lvl = dac_swinglvl; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, + "[BTCoex], bPreDacSwingOn =%d, preDacSwingLvl = 0x%x, ", + coex_dm->pre_dac_swing_on, + coex_dm->pre_dac_swing_lvl); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, + "bCurDacSwingOn =%d, curDacSwingLvl = 0x%x\n", + coex_dm->cur_dac_swing_on, + coex_dm->cur_dac_swing_lvl); + + if ((coex_dm->pre_dac_swing_on == coex_dm->cur_dac_swing_on) && + (coex_dm->pre_dac_swing_lvl == coex_dm->cur_dac_swing_lvl)) + return; + } + mdelay(30); + setsw_fulltime_dacswing(btcoexist, dac_swingon, dac_swinglvl); + + coex_dm->pre_dac_swing_on = coex_dm->cur_dac_swing_on; + coex_dm->pre_dac_swing_lvl = coex_dm->cur_dac_swing_lvl; +} + +static void halbtc8192e2ant_set_agc_table(struct btc_coexist *btcoexist, + bool agc_table_en) +{ + /* BB AGC Gain Table */ + if (agc_table_en) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], BB Agc Table On!\n"); + btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x0a1A0001); + btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x091B0001); + btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x081C0001); + btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x071D0001); + btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x061E0001); + btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x051F0001); + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], BB Agc Table Off!\n"); + btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xaa1A0001); + btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa91B0001); + btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa81C0001); + btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa71D0001); + btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa61E0001); + btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa51F0001); + } +} + +static void halbtc8192e2ant_agctable(struct btc_coexist *btcoexist, + bool force_exec, bool agc_table_en) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, + "[BTCoex], %s %s Agc Table\n", + (force_exec ? "force to" : ""), + ((agc_table_en) ? "Enable" : "Disable")); + coex_dm->cur_agc_table_en = agc_table_en; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, + "[BTCoex], bPreAgcTableEn =%d, bCurAgcTableEn =%d\n", + coex_dm->pre_agc_table_en, coex_dm->cur_agc_table_en); + + if (coex_dm->pre_agc_table_en == coex_dm->cur_agc_table_en) + return; + } + halbtc8192e2ant_set_agc_table(btcoexist, agc_table_en); + + coex_dm->pre_agc_table_en = coex_dm->cur_agc_table_en; +} + +static void halbtc8192e2ant_set_coex_table(struct btc_coexist *btcoexist, + u32 val0x6c0, u32 val0x6c4, + u32 val0x6c8, u8 val0x6cc) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], set coex table, set 0x6c0 = 0x%x\n", val0x6c0); + btcoexist->btc_write_4byte(btcoexist, 0x6c0, val0x6c0); + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], set coex table, set 0x6c4 = 0x%x\n", val0x6c4); + btcoexist->btc_write_4byte(btcoexist, 0x6c4, val0x6c4); + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], set coex table, set 0x6c8 = 0x%x\n", val0x6c8); + btcoexist->btc_write_4byte(btcoexist, 0x6c8, val0x6c8); + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], set coex table, set 0x6cc = 0x%x\n", val0x6cc); + btcoexist->btc_write_1byte(btcoexist, 0x6cc, val0x6cc); +} + +static void halbtc_coex_table(struct btc_coexist *btcoexist, bool force_exec, + u32 val0x6c0, u32 val0x6c4, + u32 val0x6c8, u8 val0x6cc) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, + "[BTCoex], %s write Coex Table 0x6c0 = 0x%x, ", + (force_exec ? "force to" : ""), val0x6c0); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, + "0x6c4 = 0x%x, 0x6c8 = 0x%x, 0x6cc = 0x%x\n", + val0x6c4, val0x6c8, val0x6cc); + coex_dm->cur_val0x6c0 = val0x6c0; + coex_dm->cur_val0x6c4 = val0x6c4; + coex_dm->cur_val0x6c8 = val0x6c8; + coex_dm->cur_val0x6cc = val0x6cc; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, + "[BTCoex], preVal0x6c0 = 0x%x, preVal0x6c4 = 0x%x, ", + coex_dm->pre_val0x6c0, coex_dm->pre_val0x6c4); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, + "preVal0x6c8 = 0x%x, preVal0x6cc = 0x%x!!\n", + coex_dm->pre_val0x6c8, coex_dm->pre_val0x6cc); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, + "[BTCoex], curVal0x6c0 = 0x%x, curVal0x6c4 = 0x%x\n", + coex_dm->cur_val0x6c0, coex_dm->cur_val0x6c4); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, + "curVal0x6c8 = 0x%x, curVal0x6cc = 0x%x !!\n", + coex_dm->cur_val0x6c8, coex_dm->cur_val0x6cc); + + if ((coex_dm->pre_val0x6c0 == coex_dm->cur_val0x6c0) && + (coex_dm->pre_val0x6c4 == coex_dm->cur_val0x6c4) && + (coex_dm->pre_val0x6c8 == coex_dm->cur_val0x6c8) && + (coex_dm->pre_val0x6cc == coex_dm->cur_val0x6cc)) + return; + } + halbtc8192e2ant_set_coex_table(btcoexist, val0x6c0, val0x6c4, + val0x6c8, val0x6cc); + + coex_dm->pre_val0x6c0 = coex_dm->cur_val0x6c0; + coex_dm->pre_val0x6c4 = coex_dm->cur_val0x6c4; + coex_dm->pre_val0x6c8 = coex_dm->cur_val0x6c8; + coex_dm->pre_val0x6cc = coex_dm->cur_val0x6cc; +} + +static void halbtc_coex_table_with_type(struct btc_coexist *btcoexist, + bool force_exec, u8 type) +{ + switch (type) { + case 0: + halbtc_coex_table(btcoexist, force_exec, 0x55555555, + 0x5a5a5a5a, 0xffffff, 0x3); + break; + case 1: + halbtc_coex_table(btcoexist, force_exec, 0x5a5a5a5a, + 0x5a5a5a5a, 0xffffff, 0x3); + break; + case 2: + halbtc_coex_table(btcoexist, force_exec, 0x55555555, + 0x5ffb5ffb, 0xffffff, 0x3); + break; + case 3: + halbtc_coex_table(btcoexist, force_exec, 0xdfffdfff, + 0x5fdb5fdb, 0xffffff, 0x3); + break; + case 4: + halbtc_coex_table(btcoexist, force_exec, 0xdfffdfff, + 0x5ffb5ffb, 0xffffff, 0x3); + break; + default: + break; + } +} + +static void halbtc8192e2ant_set_fw_ignore_wlanact(struct btc_coexist *btcoexist, + bool enable) +{ + u8 h2c_parameter[1] = {0}; + + if (enable) + h2c_parameter[0] |= BIT(0); /* function enable */ + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex]set FW for BT Ignore Wlan_Act, FW write 0x63 = 0x%x\n", + h2c_parameter[0]); + + btcoexist->btc_fill_h2c(btcoexist, 0x63, 1, h2c_parameter); +} + +static void halbtc8192e2ant_ignorewlanact(struct btc_coexist *btcoexist, + bool force_exec, bool enable) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, + "[BTCoex], %s turn Ignore WlanAct %s\n", + (force_exec ? "force to" : ""), (enable ? "ON" : "OFF")); + coex_dm->cur_ignore_wlan_act = enable; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], bPreIgnoreWlanAct = %d ", + coex_dm->pre_ignore_wlan_act); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "bCurIgnoreWlanAct = %d!!\n", + coex_dm->cur_ignore_wlan_act); + + if (coex_dm->pre_ignore_wlan_act == + coex_dm->cur_ignore_wlan_act) + return; + } + halbtc8192e2ant_set_fw_ignore_wlanact(btcoexist, enable); + + coex_dm->pre_ignore_wlan_act = coex_dm->cur_ignore_wlan_act; +} + +static void halbtc8192e2ant_setfwpstdma(struct btc_coexist *btcoexist, u8 byte1, + u8 byte2, u8 byte3, u8 byte4, u8 byte5) +{ + u8 h2c_parameter[5]; + + h2c_parameter[0] = byte1; + h2c_parameter[1] = byte2; + h2c_parameter[2] = byte3; + h2c_parameter[3] = byte4; + h2c_parameter[4] = byte5; + + coex_dm->ps_tdma_para[0] = byte1; + coex_dm->ps_tdma_para[1] = byte2; + coex_dm->ps_tdma_para[2] = byte3; + coex_dm->ps_tdma_para[3] = byte4; + coex_dm->ps_tdma_para[4] = byte5; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], FW write 0x60(5bytes) = 0x%x%08x\n", + h2c_parameter[0], + h2c_parameter[1] << 24 | h2c_parameter[2] << 16 | + h2c_parameter[3] << 8 | h2c_parameter[4]); + + btcoexist->btc_fill_h2c(btcoexist, 0x60, 5, h2c_parameter); +} + +static void halbtc_sw_mechanism1(struct btc_coexist *btcoexist, + bool shrink_rx_lpf, bool low_penalty_ra, + bool limited_dig, bool btlan_constrain) +{ + halbtc8192e2ant_rf_shrink(btcoexist, NORMAL_EXEC, shrink_rx_lpf); +} + +static void halbtc_sw_mechanism2(struct btc_coexist *btcoexist, + bool agc_table_shift, bool adc_backoff, + bool sw_dac_swing, u32 dac_swinglvl) +{ + halbtc8192e2ant_agctable(btcoexist, NORMAL_EXEC, agc_table_shift); + halbtc8192e2ant_dacswing(btcoexist, NORMAL_EXEC, sw_dac_swing, + dac_swinglvl); +} + +static void halbtc8192e2ant_ps_tdma(struct btc_coexist *btcoexist, + bool force_exec, bool turn_on, u8 type) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, + "[BTCoex], %s turn %s PS TDMA, type =%d\n", + (force_exec ? "force to" : ""), + (turn_on ? "ON" : "OFF"), type); + coex_dm->cur_ps_tdma_on = turn_on; + coex_dm->cur_ps_tdma = type; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], bPrePsTdmaOn = %d, bCurPsTdmaOn = %d!!\n", + coex_dm->pre_ps_tdma_on, coex_dm->cur_ps_tdma_on); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], prePsTdma = %d, curPsTdma = %d!!\n", + coex_dm->pre_ps_tdma, coex_dm->cur_ps_tdma); + + if ((coex_dm->pre_ps_tdma_on == coex_dm->cur_ps_tdma_on) && + (coex_dm->pre_ps_tdma == coex_dm->cur_ps_tdma)) + return; + } + if (turn_on) { + switch (type) { + case 1: + default: + halbtc8192e2ant_setfwpstdma(btcoexist, 0xe3, 0x1a, + 0x1a, 0xe1, 0x90); + break; + case 2: + halbtc8192e2ant_setfwpstdma(btcoexist, 0xe3, 0x12, + 0x12, 0xe1, 0x90); + break; + case 3: + halbtc8192e2ant_setfwpstdma(btcoexist, 0xe3, 0x1c, + 0x3, 0xf1, 0x90); + break; + case 4: + halbtc8192e2ant_setfwpstdma(btcoexist, 0xe3, 0x10, + 0x3, 0xf1, 0x90); + break; + case 5: + halbtc8192e2ant_setfwpstdma(btcoexist, 0xe3, 0x1a, + 0x1a, 0x60, 0x90); + break; + case 6: + halbtc8192e2ant_setfwpstdma(btcoexist, 0xe3, 0x12, + 0x12, 0x60, 0x90); + break; + case 7: + halbtc8192e2ant_setfwpstdma(btcoexist, 0xe3, 0x1c, + 0x3, 0x70, 0x90); + break; + case 8: + halbtc8192e2ant_setfwpstdma(btcoexist, 0xa3, 0x10, + 0x3, 0x70, 0x90); + break; + case 9: + halbtc8192e2ant_setfwpstdma(btcoexist, 0xe3, 0x1a, + 0x1a, 0xe1, 0x10); + break; + case 10: + halbtc8192e2ant_setfwpstdma(btcoexist, 0xe3, 0x12, + 0x12, 0xe1, 0x10); + break; + case 11: + halbtc8192e2ant_setfwpstdma(btcoexist, 0xe3, 0x1c, + 0x3, 0xf1, 0x10); + break; + case 12: + halbtc8192e2ant_setfwpstdma(btcoexist, 0xe3, 0x10, + 0x3, 0xf1, 0x10); + break; + case 13: + halbtc8192e2ant_setfwpstdma(btcoexist, 0xe3, 0x1a, + 0x1a, 0xe0, 0x10); + break; + case 14: + halbtc8192e2ant_setfwpstdma(btcoexist, 0xe3, 0x12, + 0x12, 0xe0, 0x10); + break; + case 15: + halbtc8192e2ant_setfwpstdma(btcoexist, 0xe3, 0x1c, + 0x3, 0xf0, 0x10); + break; + case 16: + halbtc8192e2ant_setfwpstdma(btcoexist, 0xe3, 0x12, + 0x3, 0xf0, 0x10); + break; + case 17: + halbtc8192e2ant_setfwpstdma(btcoexist, 0x61, 0x20, + 0x03, 0x10, 0x10); + break; + case 18: + halbtc8192e2ant_setfwpstdma(btcoexist, 0xe3, 0x5, + 0x5, 0xe1, 0x90); + break; + case 19: + halbtc8192e2ant_setfwpstdma(btcoexist, 0xe3, 0x25, + 0x25, 0xe1, 0x90); + break; + case 20: + halbtc8192e2ant_setfwpstdma(btcoexist, 0xe3, 0x25, + 0x25, 0x60, 0x90); + break; + case 21: + halbtc8192e2ant_setfwpstdma(btcoexist, 0xe3, 0x15, + 0x03, 0x70, 0x90); + break; + case 71: + halbtc8192e2ant_setfwpstdma(btcoexist, 0xe3, 0x1a, + 0x1a, 0xe1, 0x90); + break; + } + } else { + /* disable PS tdma */ + switch (type) { + default: + case 0: + halbtc8192e2ant_setfwpstdma(btcoexist, 0x8, 0x0, 0x0, + 0x0, 0x0); + btcoexist->btc_write_1byte(btcoexist, 0x92c, 0x4); + break; + case 1: + halbtc8192e2ant_setfwpstdma(btcoexist, 0x0, 0x0, 0x0, + 0x8, 0x0); + mdelay(5); + btcoexist->btc_write_1byte(btcoexist, 0x92c, 0x20); + break; + } + } + + /* update pre state */ + coex_dm->pre_ps_tdma_on = coex_dm->cur_ps_tdma_on; + coex_dm->pre_ps_tdma = coex_dm->cur_ps_tdma; +} + +static void set_switch_sstype(struct btc_coexist *btcoexist, u8 sstype) +{ + u8 mimops = BTC_MIMO_PS_DYNAMIC; + u32 disra_mask = 0x0; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], REAL set SS Type = %d\n", sstype); + + disra_mask = halbtc8192e2ant_decidera_mask(btcoexist, sstype, + coex_dm->curra_masktype); + halbtc8192e2ant_updatera_mask(btcoexist, FORCE_EXEC, disra_mask); + + if (sstype == 1) { + halbtc8192e2ant_ps_tdma(btcoexist, FORCE_EXEC, false, 1); + /* switch ofdm path */ + btcoexist->btc_write_1byte(btcoexist, 0xc04, 0x11); + btcoexist->btc_write_1byte(btcoexist, 0xd04, 0x1); + btcoexist->btc_write_4byte(btcoexist, 0x90c, 0x81111111); + /* switch cck patch */ + btcoexist->btc_write_1byte_bitmask(btcoexist, 0xe77, 0x4, 0x1); + btcoexist->btc_write_1byte(btcoexist, 0xa07, 0x81); + mimops = BTC_MIMO_PS_STATIC; + } else if (sstype == 2) { + halbtc8192e2ant_ps_tdma(btcoexist, FORCE_EXEC, false, 0); + btcoexist->btc_write_1byte(btcoexist, 0xc04, 0x33); + btcoexist->btc_write_1byte(btcoexist, 0xd04, 0x3); + btcoexist->btc_write_4byte(btcoexist, 0x90c, 0x81121313); + btcoexist->btc_write_1byte_bitmask(btcoexist, 0xe77, 0x4, 0x0); + btcoexist->btc_write_1byte(btcoexist, 0xa07, 0x41); + mimops = BTC_MIMO_PS_DYNAMIC; + } + /* set rx 1ss or 2ss */ + btcoexist->btc_set(btcoexist, BTC_SET_ACT_SEND_MIMO_PS, &mimops); +} + +static void halbtc8192e2ant_switch_sstype(struct btc_coexist *btcoexist, + bool force_exec, u8 new_sstype) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], %s Switch SS Type = %d\n", + (force_exec ? "force to" : ""), new_sstype); + coex_dm->cur_sstype = new_sstype; + + if (!force_exec) { + if (coex_dm->pre_sstype == coex_dm->cur_sstype) + return; + } + set_switch_sstype(btcoexist, coex_dm->cur_sstype); + + coex_dm->pre_sstype = coex_dm->cur_sstype; +} + +static void halbtc8192e2ant_coex_alloff(struct btc_coexist *btcoexist) +{ + /* fw all off */ + halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1); + halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, 6); + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0); + + /* sw all off */ + halbtc_sw_mechanism1(btcoexist, false, false, false, false); + halbtc_sw_mechanism2(btcoexist, false, false, false, 0x18); + + /* hw all off */ + halbtc_coex_table_with_type(btcoexist, NORMAL_EXEC, 0); +} + +static void halbtc8192e2ant_init_coex_dm(struct btc_coexist *btcoexist) +{ + /* force to reset coex mechanism */ + + halbtc8192e2ant_ps_tdma(btcoexist, FORCE_EXEC, false, 1); + halbtc8192e2ant_fw_dac_swinglvl(btcoexist, FORCE_EXEC, 6); + halbtc8192e2ant_dec_btpwr(btcoexist, FORCE_EXEC, 0); + + halbtc_coex_table_with_type(btcoexist, FORCE_EXEC, 0); + halbtc8192e2ant_switch_sstype(btcoexist, FORCE_EXEC, 2); + + halbtc_sw_mechanism1(btcoexist, false, false, false, false); + halbtc_sw_mechanism2(btcoexist, false, false, false, 0x18); +} + +static void halbtc8192e2ant_action_bt_inquiry(struct btc_coexist *btcoexist) +{ + bool low_pwr_disable = true; + + btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, + &low_pwr_disable); + + halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC, 1); + + halbtc_coex_table_with_type(btcoexist, NORMAL_EXEC, 2); + halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 3); + halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, 6); + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0); + + halbtc_sw_mechanism1(btcoexist, false, false, false, false); + halbtc_sw_mechanism2(btcoexist, false, false, false, 0x18); +} + +static bool halbtc8192e2ant_is_common_action(struct btc_coexist *btcoexist) +{ + struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; + bool common = false, wifi_connected = false, wifi_busy = false; + bool bt_hson = false, low_pwr_disable = false; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hson); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, + &wifi_connected); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); + + if (bt_link_info->sco_exist || bt_link_info->hid_exist) + halbtc8192e2ant_limited_tx(btcoexist, NORMAL_EXEC, 1, 0, 0, 0); + else + halbtc8192e2ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0); + + if (!wifi_connected) { + low_pwr_disable = false; + btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, + &low_pwr_disable); + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Wifi non-connected idle!!\n"); + + if ((BT_8192E_2ANT_BT_STATUS_NON_CONNECTED_IDLE == + coex_dm->bt_status) || + (BT_8192E_2ANT_BT_STATUS_CONNECTED_IDLE == + coex_dm->bt_status)) { + halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC, + 2); + halbtc_coex_table_with_type(btcoexist, + NORMAL_EXEC, 1); + halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, + 0); + } else { + halbtc8192e2ant_switch_sstype(btcoexist, + NORMAL_EXEC, 1); + halbtc_coex_table_with_type(btcoexist, + NORMAL_EXEC, 0); + halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, + false, 1); + } + + halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, 6); + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0); + + halbtc_sw_mechanism1(btcoexist, false, false, false, + false); + halbtc_sw_mechanism2(btcoexist, false, false, false, + 0x18); + + common = true; + } else { + if (BT_8192E_2ANT_BT_STATUS_NON_CONNECTED_IDLE == + coex_dm->bt_status) { + low_pwr_disable = false; + btcoexist->btc_set(btcoexist, + BTC_SET_ACT_DISABLE_LOW_POWER, + &low_pwr_disable); + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "Wifi connected + BT non connected-idle!!\n"); + + halbtc8192e2ant_switch_sstype(btcoexist, + NORMAL_EXEC, 2); + halbtc_coex_table_with_type(btcoexist, + NORMAL_EXEC, 1); + halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, + false, 0); + halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, + 6); + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0); + + halbtc_sw_mechanism1(btcoexist, false, false, + false, false); + halbtc_sw_mechanism2(btcoexist, false, false, + false, 0x18); + + common = true; + } else if (BT_8192E_2ANT_BT_STATUS_CONNECTED_IDLE == + coex_dm->bt_status) { + low_pwr_disable = true; + btcoexist->btc_set(btcoexist, + BTC_SET_ACT_DISABLE_LOW_POWER, + &low_pwr_disable); + + if (bt_hson) + return false; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "Wifi connected + BT connected-idle!!\n"); + + halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC, + 2); + halbtc_coex_table_with_type(btcoexist, + NORMAL_EXEC, 1); + halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, + false, 0); + halbtc8192e2ant_fw_dac_swinglvl(btcoexist, + NORMAL_EXEC, 6); + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0); + + halbtc_sw_mechanism1(btcoexist, true, false, + false, false); + halbtc_sw_mechanism2(btcoexist, false, false, + false, 0x18); + + common = true; + } else { + low_pwr_disable = true; + btcoexist->btc_set(btcoexist, + BTC_SET_ACT_DISABLE_LOW_POWER, + &low_pwr_disable); + + if (wifi_busy) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "Wifi Connected-Busy + BT Busy!!\n"); + common = false; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "Wifi Connected-Idle + BT Busy!!\n"); + + halbtc8192e2ant_switch_sstype(btcoexist, + NORMAL_EXEC, 1); + halbtc_coex_table_with_type(btcoexist, + NORMAL_EXEC, 2); + halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, + true, 21); + halbtc8192e2ant_fw_dac_swinglvl(btcoexist, + NORMAL_EXEC, 6); + halbtc8192e2ant_dec_btpwr(btcoexist, + NORMAL_EXEC, 0); + halbtc_sw_mechanism1(btcoexist, false, + false, false, + false); + halbtc_sw_mechanism2(btcoexist, false, + false, false, + 0x18); + common = true; + } + } + } + return common; +} + +static void halbtc8192e2ant_tdma_duration_adjust(struct btc_coexist *btcoexist, + bool sco_hid, bool tx_pause, + u8 max_interval) +{ + static int up, dn, m, n, wait_cnt; + /* 0: no change, +1: increase WiFi duration, + * -1: decrease WiFi duration */ + int result; + u8 retry_cnt = 0; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, + "[BTCoex], TdmaDurationAdjust()\n"); + + if (!coex_dm->auto_tdma_adjust) { + coex_dm->auto_tdma_adjust = true; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], first run TdmaDurationAdjust()!!\n"); + if (sco_hid) { + if (tx_pause) { + if (max_interval == 1) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 13); + coex_dm->ps_tdma_du_adj_type = 13; + } else if (max_interval == 2) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 14); + coex_dm->ps_tdma_du_adj_type = 14; + } else if (max_interval == 3) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } else { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } + } else { + if (max_interval == 1) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 9); + coex_dm->ps_tdma_du_adj_type = 9; + } else if (max_interval == 2) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 10); + coex_dm->ps_tdma_du_adj_type = 10; + } else if (max_interval == 3) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } else { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } + } + } else { + if (tx_pause) { + if (max_interval == 1) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 5); + coex_dm->ps_tdma_du_adj_type = 5; + } else if (max_interval == 2) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 6); + coex_dm->ps_tdma_du_adj_type = 6; + } else if (max_interval == 3) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } else { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } + } else { + if (max_interval == 1) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 1); + coex_dm->ps_tdma_du_adj_type = 1; + } else if (max_interval == 2) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 2); + coex_dm->ps_tdma_du_adj_type = 2; + } else if (max_interval == 3) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } else { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } + } + } + + up = 0; + dn = 0; + m = 1; + n = 3; + result = 0; + wait_cnt = 0; + } else { + /* accquire the BT TRx retry count from BT_Info byte2 */ + retry_cnt = coex_sta->bt_retry_cnt; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], retry_cnt = %d\n", retry_cnt); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], up =%d, dn =%d, m =%d, n =%d, wait_cnt =%d\n", + up, dn, m, n, wait_cnt); + result = 0; + wait_cnt++; + /* no retry in the last 2-second duration */ + if (retry_cnt == 0) { + up++; + dn--; + + if (dn <= 0) + dn = 0; + + if (up >= n) { + wait_cnt = 0; + n = 3; + up = 0; + dn = 0; + result = 1; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_TRACE_FW_DETAIL, + "[BTCoex]Increase wifi duration!!\n"); + } + } else if (retry_cnt <= 3) { + up--; + dn++; + + if (up <= 0) + up = 0; + + if (dn == 2) { + if (wait_cnt <= 2) + m++; + else + m = 1; + + if (m >= 20) + m = 20; + + n = 3 * m; + up = 0; + dn = 0; + wait_cnt = 0; + result = -1; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_TRACE_FW_DETAIL, + "Reduce wifi duration for retry<3\n"); + } + } else { + if (wait_cnt == 1) + m++; + else + m = 1; + + if (m >= 20) + m = 20; + + n = 3*m; + up = 0; + dn = 0; + wait_cnt = 0; + result = -1; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "Decrease wifi duration for retryCounter>3!!\n"); + } + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], max Interval = %d\n", max_interval); + if (max_interval == 1) { + if (tx_pause) { + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_TRACE_FW_DETAIL, + "[BTCoex], TxPause = 1\n"); + + if (coex_dm->cur_ps_tdma == 71) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 5); + coex_dm->ps_tdma_du_adj_type = 5; + } else if (coex_dm->cur_ps_tdma == 1) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 5); + coex_dm->ps_tdma_du_adj_type = 5; + } else if (coex_dm->cur_ps_tdma == 2) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 6); + coex_dm->ps_tdma_du_adj_type = 6; + } else if (coex_dm->cur_ps_tdma == 3) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } else if (coex_dm->cur_ps_tdma == 4) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 8); + coex_dm->ps_tdma_du_adj_type = 8; + } + if (coex_dm->cur_ps_tdma == 9) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 13); + coex_dm->ps_tdma_du_adj_type = 13; + } else if (coex_dm->cur_ps_tdma == 10) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 14); + coex_dm->ps_tdma_du_adj_type = 14; + } else if (coex_dm->cur_ps_tdma == 11) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } else if (coex_dm->cur_ps_tdma == 12) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 16); + coex_dm->ps_tdma_du_adj_type = 16; + } + + if (result == -1) { + if (coex_dm->cur_ps_tdma == 5) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 6); + coex_dm->ps_tdma_du_adj_type = + 6; + } else if (coex_dm->cur_ps_tdma == 6) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = + 7; + } else if (coex_dm->cur_ps_tdma == 7) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 8); + coex_dm->ps_tdma_du_adj_type = + 8; + } else if (coex_dm->cur_ps_tdma == 13) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 14); + coex_dm->ps_tdma_du_adj_type = + 14; + } else if (coex_dm->cur_ps_tdma == 14) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = + 15; + } else if (coex_dm->cur_ps_tdma == 15) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 16); + coex_dm->ps_tdma_du_adj_type = + 16; + } + } else if (result == 1) { + if (coex_dm->cur_ps_tdma == 8) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = + 7; + } else if (coex_dm->cur_ps_tdma == 7) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 6); + coex_dm->ps_tdma_du_adj_type = + 6; + } else if (coex_dm->cur_ps_tdma == 6) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 5); + coex_dm->ps_tdma_du_adj_type = + 5; + } else if (coex_dm->cur_ps_tdma == 16) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = + 15; + } else if (coex_dm->cur_ps_tdma == 15) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 14); + coex_dm->ps_tdma_du_adj_type = + 14; + } else if (coex_dm->cur_ps_tdma == 14) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 13); + coex_dm->ps_tdma_du_adj_type = + 13; + } + } + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_TRACE_FW_DETAIL, + "[BTCoex], TxPause = 0\n"); + if (coex_dm->cur_ps_tdma == 5) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 71); + coex_dm->ps_tdma_du_adj_type = 71; + } else if (coex_dm->cur_ps_tdma == 6) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 2); + coex_dm->ps_tdma_du_adj_type = 2; + } else if (coex_dm->cur_ps_tdma == 7) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } else if (coex_dm->cur_ps_tdma == 8) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 4); + coex_dm->ps_tdma_du_adj_type = 4; + } + if (coex_dm->cur_ps_tdma == 13) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 9); + coex_dm->ps_tdma_du_adj_type = 9; + } else if (coex_dm->cur_ps_tdma == 14) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 10); + coex_dm->ps_tdma_du_adj_type = 10; + } else if (coex_dm->cur_ps_tdma == 15) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } else if (coex_dm->cur_ps_tdma == 16) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 12); + coex_dm->ps_tdma_du_adj_type = 12; + } + + if (result == -1) { + if (coex_dm->cur_ps_tdma == 71) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 1); + coex_dm->ps_tdma_du_adj_type = + 1; + } else if (coex_dm->cur_ps_tdma == 1) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 2); + coex_dm->ps_tdma_du_adj_type = + 2; + } else if (coex_dm->cur_ps_tdma == 2) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = + 3; + } else if (coex_dm->cur_ps_tdma == 3) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 4); + coex_dm->ps_tdma_du_adj_type = + 4; + } else if (coex_dm->cur_ps_tdma == 9) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 10); + coex_dm->ps_tdma_du_adj_type = + 10; + } else if (coex_dm->cur_ps_tdma == 10) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = + 11; + } else if (coex_dm->cur_ps_tdma == 11) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 12); + coex_dm->ps_tdma_du_adj_type = + 12; + } + } else if (result == 1) { + if (coex_dm->cur_ps_tdma == 4) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = + 3; + } else if (coex_dm->cur_ps_tdma == 3) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 2); + coex_dm->ps_tdma_du_adj_type = + 2; + } else if (coex_dm->cur_ps_tdma == 2) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 1); + coex_dm->ps_tdma_du_adj_type = + 1; + } else if (coex_dm->cur_ps_tdma == 1) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 71); + coex_dm->ps_tdma_du_adj_type = + 71; + } else if (coex_dm->cur_ps_tdma == 12) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = + 11; + } else if (coex_dm->cur_ps_tdma == 11) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 10); + coex_dm->ps_tdma_du_adj_type = + 10; + } else if (coex_dm->cur_ps_tdma == 10) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 9); + coex_dm->ps_tdma_du_adj_type = + 9; + } + } + } + } else if (max_interval == 2) { + if (tx_pause) { + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_TRACE_FW_DETAIL, + "[BTCoex], TxPause = 1\n"); + if (coex_dm->cur_ps_tdma == 1) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 6); + coex_dm->ps_tdma_du_adj_type = 6; + } else if (coex_dm->cur_ps_tdma == 2) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 6); + coex_dm->ps_tdma_du_adj_type = 6; + } else if (coex_dm->cur_ps_tdma == 3) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } else if (coex_dm->cur_ps_tdma == 4) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 8); + coex_dm->ps_tdma_du_adj_type = 8; + } + if (coex_dm->cur_ps_tdma == 9) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 14); + coex_dm->ps_tdma_du_adj_type = 14; + } else if (coex_dm->cur_ps_tdma == 10) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 14); + coex_dm->ps_tdma_du_adj_type = 14; + } else if (coex_dm->cur_ps_tdma == 11) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } else if (coex_dm->cur_ps_tdma == 12) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 16); + coex_dm->ps_tdma_du_adj_type = 16; + } + if (result == -1) { + if (coex_dm->cur_ps_tdma == 5) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 6); + coex_dm->ps_tdma_du_adj_type = + 6; + } else if (coex_dm->cur_ps_tdma == 6) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = + 7; + } else if (coex_dm->cur_ps_tdma == 7) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 8); + coex_dm->ps_tdma_du_adj_type = + 8; + } else if (coex_dm->cur_ps_tdma == 13) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 14); + coex_dm->ps_tdma_du_adj_type = + 14; + } else if (coex_dm->cur_ps_tdma == 14) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = + 15; + } else if (coex_dm->cur_ps_tdma == 15) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 16); + coex_dm->ps_tdma_du_adj_type = + 16; + } + } else if (result == 1) { + if (coex_dm->cur_ps_tdma == 8) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = + 7; + } else if (coex_dm->cur_ps_tdma == 7) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 6); + coex_dm->ps_tdma_du_adj_type = + 6; + } else if (coex_dm->cur_ps_tdma == 6) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 6); + coex_dm->ps_tdma_du_adj_type = + 6; + } else if (coex_dm->cur_ps_tdma == 16) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = + 15; + } else if (coex_dm->cur_ps_tdma == 15) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 14); + coex_dm->ps_tdma_du_adj_type = + 14; + } else if (coex_dm->cur_ps_tdma == 14) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 14); + coex_dm->ps_tdma_du_adj_type = + 14; + } + } + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_TRACE_FW_DETAIL, + "[BTCoex], TxPause = 0\n"); + if (coex_dm->cur_ps_tdma == 5) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 2); + coex_dm->ps_tdma_du_adj_type = 2; + } else if (coex_dm->cur_ps_tdma == 6) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 2); + coex_dm->ps_tdma_du_adj_type = 2; + } else if (coex_dm->cur_ps_tdma == 7) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } else if (coex_dm->cur_ps_tdma == 8) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 4); + coex_dm->ps_tdma_du_adj_type = 4; + } + if (coex_dm->cur_ps_tdma == 13) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 10); + coex_dm->ps_tdma_du_adj_type = 10; + } else if (coex_dm->cur_ps_tdma == 14) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 10); + coex_dm->ps_tdma_du_adj_type = 10; + } else if (coex_dm->cur_ps_tdma == 15) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } else if (coex_dm->cur_ps_tdma == 16) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 12); + coex_dm->ps_tdma_du_adj_type = 12; + } + if (result == -1) { + if (coex_dm->cur_ps_tdma == 1) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 2); + coex_dm->ps_tdma_du_adj_type = + 2; + } else if (coex_dm->cur_ps_tdma == 2) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = + 3; + } else if (coex_dm->cur_ps_tdma == 3) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 4); + coex_dm->ps_tdma_du_adj_type = + 4; + } else if (coex_dm->cur_ps_tdma == 9) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 10); + coex_dm->ps_tdma_du_adj_type = + 10; + } else if (coex_dm->cur_ps_tdma == 10) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = + 11; + } else if (coex_dm->cur_ps_tdma == 11) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 12); + coex_dm->ps_tdma_du_adj_type = + 12; + } + } else if (result == 1) { + if (coex_dm->cur_ps_tdma == 4) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = + 3; + } else if (coex_dm->cur_ps_tdma == 3) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 2); + coex_dm->ps_tdma_du_adj_type = + 2; + } else if (coex_dm->cur_ps_tdma == 2) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 2); + coex_dm->ps_tdma_du_adj_type = + 2; + } else if (coex_dm->cur_ps_tdma == 12) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = + 11; + } else if (coex_dm->cur_ps_tdma == 11) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 10); + coex_dm->ps_tdma_du_adj_type = + 10; + } else if (coex_dm->cur_ps_tdma == 10) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 10); + coex_dm->ps_tdma_du_adj_type = + 10; + } + } + } + } else if (max_interval == 3) { + if (tx_pause) { + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_TRACE_FW_DETAIL, + "[BTCoex], TxPause = 1\n"); + if (coex_dm->cur_ps_tdma == 1) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } else if (coex_dm->cur_ps_tdma == 2) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } else if (coex_dm->cur_ps_tdma == 3) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } else if (coex_dm->cur_ps_tdma == 4) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 8); + coex_dm->ps_tdma_du_adj_type = 8; + } + if (coex_dm->cur_ps_tdma == 9) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } else if (coex_dm->cur_ps_tdma == 10) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } else if (coex_dm->cur_ps_tdma == 11) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } else if (coex_dm->cur_ps_tdma == 12) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 16); + coex_dm->ps_tdma_du_adj_type = 16; + } + if (result == -1) { + if (coex_dm->cur_ps_tdma == 5) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = + 7; + } else if (coex_dm->cur_ps_tdma == 6) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = + 7; + } else if (coex_dm->cur_ps_tdma == 7) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 8); + coex_dm->ps_tdma_du_adj_type = + 8; + } else if (coex_dm->cur_ps_tdma == 13) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = + 15; + } else if (coex_dm->cur_ps_tdma == 14) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = + 15; + } else if (coex_dm->cur_ps_tdma == 15) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 16); + coex_dm->ps_tdma_du_adj_type = + 16; + } + } else if (result == 1) { + if (coex_dm->cur_ps_tdma == 8) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = + 7; + } else if (coex_dm->cur_ps_tdma == 7) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = + 7; + } else if (coex_dm->cur_ps_tdma == 6) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = + 7; + } else if (coex_dm->cur_ps_tdma == 16) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = + 15; + } else if (coex_dm->cur_ps_tdma == 15) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = + 15; + } else if (coex_dm->cur_ps_tdma == 14) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = + 15; + } + } + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_TRACE_FW_DETAIL, + "[BTCoex], TxPause = 0\n"); + if (coex_dm->cur_ps_tdma == 5) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } else if (coex_dm->cur_ps_tdma == 6) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } else if (coex_dm->cur_ps_tdma == 7) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } else if (coex_dm->cur_ps_tdma == 8) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 4); + coex_dm->ps_tdma_du_adj_type = 4; + } + if (coex_dm->cur_ps_tdma == 13) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } else if (coex_dm->cur_ps_tdma == 14) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } else if (coex_dm->cur_ps_tdma == 15) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } else if (coex_dm->cur_ps_tdma == 16) { + halbtc8192e2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 12); + coex_dm->ps_tdma_du_adj_type = 12; + } + if (result == -1) { + if (coex_dm->cur_ps_tdma == 1) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = + 3; + } else if (coex_dm->cur_ps_tdma == 2) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = + 3; + } else if (coex_dm->cur_ps_tdma == 3) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 4); + coex_dm->ps_tdma_du_adj_type = + 4; + } else if (coex_dm->cur_ps_tdma == 9) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = + 11; + } else if (coex_dm->cur_ps_tdma == 10) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = + 11; + } else if (coex_dm->cur_ps_tdma == 11) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 12); + coex_dm->ps_tdma_du_adj_type = + 12; + } + } else if (result == 1) { + if (coex_dm->cur_ps_tdma == 4) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = + 3; + } else if (coex_dm->cur_ps_tdma == 3) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = + 3; + } else if (coex_dm->cur_ps_tdma == 2) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = + 3; + } else if (coex_dm->cur_ps_tdma == 12) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = + 11; + } else if (coex_dm->cur_ps_tdma == 11) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = + 11; + } else if (coex_dm->cur_ps_tdma == 10) { + halbtc8192e2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = + 11; + } + } + } + } + } + + /* if current PsTdma not match with + * the recorded one (when scan, dhcp...), + * then we have to adjust it back to the previous record one. */ + if (coex_dm->cur_ps_tdma != coex_dm->ps_tdma_du_adj_type) { + bool scan = false, link = false, roam = false; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], PsTdma type dismatch!!!, "); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "curPsTdma =%d, recordPsTdma =%d\n", + coex_dm->cur_ps_tdma, coex_dm->ps_tdma_du_adj_type); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam); + + if (!scan && !link && !roam) + halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, + true, + coex_dm->ps_tdma_du_adj_type); + else + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_TRACE_FW_DETAIL, + "[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n"); + } +} + +/* SCO only or SCO+PAN(HS) */ +static void halbtc8192e2ant_action_sco(struct btc_coexist *btcoexist) +{ + u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_STAY_LOW; + u32 wifi_bw; + + wifirssi_state = halbtc8192e2ant_wifirssi_state(btcoexist, 0, 2, 15, 0); + + halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC, 1); + halbtc8192e2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8); + + halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, 6); + + halbtc_coex_table_with_type(btcoexist, NORMAL_EXEC, 4); + + btrssi_state = halbtc8192e2ant_btrssi_state(3, 34, 42); + + if ((btrssi_state == BTC_RSSI_STATE_LOW) || + (btrssi_state == BTC_RSSI_STATE_STAY_LOW)) { + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0); + halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 13); + } else if ((btrssi_state == BTC_RSSI_STATE_MEDIUM) || + (btrssi_state == BTC_RSSI_STATE_STAY_MEDIUM)) { + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 2); + halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 9); + } else if ((btrssi_state == BTC_RSSI_STATE_HIGH) || + (btrssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 4); + halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 9); + } + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + + /* sw mechanism */ + if (BTC_WIFI_BW_HT40 == wifi_bw) { + if ((wifirssi_state == BTC_RSSI_STATE_HIGH) || + (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc_sw_mechanism1(btcoexist, true, true, + false, false); + halbtc_sw_mechanism2(btcoexist, true, false, + false, 0x6); + } else { + halbtc_sw_mechanism1(btcoexist, true, true, + false, false); + halbtc_sw_mechanism2(btcoexist, false, false, + false, 0x6); + } + } else { + if ((wifirssi_state == BTC_RSSI_STATE_HIGH) || + (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc_sw_mechanism1(btcoexist, false, true, + false, false); + halbtc_sw_mechanism2(btcoexist, true, false, + false, 0x6); + } else { + halbtc_sw_mechanism1(btcoexist, false, true, + false, false); + halbtc_sw_mechanism2(btcoexist, false, false, + false, 0x6); + } + } +} + +static void halbtc8192e2ant_action_sco_pan(struct btc_coexist *btcoexist) +{ + u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_STAY_LOW; + u32 wifi_bw; + + wifirssi_state = halbtc8192e2ant_wifirssi_state(btcoexist, 0, 2, 15, 0); + + halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC, 1); + halbtc8192e2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8); + + halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, 6); + + halbtc_coex_table_with_type(btcoexist, NORMAL_EXEC, 4); + + btrssi_state = halbtc8192e2ant_btrssi_state(3, 34, 42); + + if ((btrssi_state == BTC_RSSI_STATE_LOW) || + (btrssi_state == BTC_RSSI_STATE_STAY_LOW)) { + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0); + halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14); + } else if ((btrssi_state == BTC_RSSI_STATE_MEDIUM) || + (btrssi_state == BTC_RSSI_STATE_STAY_MEDIUM)) { + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 2); + halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 10); + } else if ((btrssi_state == BTC_RSSI_STATE_HIGH) || + (btrssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 4); + halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 10); + } + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + + /* sw mechanism */ + if (BTC_WIFI_BW_HT40 == wifi_bw) { + if ((wifirssi_state == BTC_RSSI_STATE_HIGH) || + (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc_sw_mechanism1(btcoexist, true, true, + false, false); + halbtc_sw_mechanism2(btcoexist, true, false, + false, 0x6); + } else { + halbtc_sw_mechanism1(btcoexist, true, true, + false, false); + halbtc_sw_mechanism2(btcoexist, false, false, + false, 0x6); + } + } else { + if ((wifirssi_state == BTC_RSSI_STATE_HIGH) || + (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc_sw_mechanism1(btcoexist, false, true, + false, false); + halbtc_sw_mechanism2(btcoexist, true, false, + false, 0x6); + } else { + halbtc_sw_mechanism1(btcoexist, false, true, + false, false); + halbtc_sw_mechanism2(btcoexist, false, false, + false, 0x6); + } + } +} + +static void halbtc8192e2ant_action_hid(struct btc_coexist *btcoexist) +{ + u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH; + u32 wifi_bw; + + wifirssi_state = halbtc8192e2ant_wifirssi_state(btcoexist, 0, 2, 15, 0); + btrssi_state = halbtc8192e2ant_btrssi_state(3, 34, 42); + + halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC, 1); + halbtc8192e2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8); + + halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, 6); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + + halbtc_coex_table_with_type(btcoexist, NORMAL_EXEC, 3); + + if ((btrssi_state == BTC_RSSI_STATE_LOW) || + (btrssi_state == BTC_RSSI_STATE_STAY_LOW)) { + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0); + halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 13); + } else if ((btrssi_state == BTC_RSSI_STATE_MEDIUM) || + (btrssi_state == BTC_RSSI_STATE_STAY_MEDIUM)) { + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 2); + halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 9); + } else if ((btrssi_state == BTC_RSSI_STATE_HIGH) || + (btrssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 4); + halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 9); + } + + /* sw mechanism */ + if (BTC_WIFI_BW_HT40 == wifi_bw) { + if ((wifirssi_state == BTC_RSSI_STATE_HIGH) || + (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc_sw_mechanism1(btcoexist, true, true, + false, false); + halbtc_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc_sw_mechanism1(btcoexist, true, true, + false, false); + halbtc_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } else { + if ((wifirssi_state == BTC_RSSI_STATE_HIGH) || + (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc_sw_mechanism1(btcoexist, false, true, + false, false); + halbtc_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc_sw_mechanism1(btcoexist, false, true, + false, false); + halbtc_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } +} + +/* A2DP only / PAN(EDR) only/ A2DP+PAN(HS) */ +static void halbtc8192e2ant_action_a2dp(struct btc_coexist *btcoexist) +{ + u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH; + u32 wifi_bw; + bool long_dist = false; + + wifirssi_state = halbtc8192e2ant_wifirssi_state(btcoexist, 0, 2, 15, 0); + btrssi_state = halbtc8192e2ant_btrssi_state(3, 34, 42); + + if ((btrssi_state == BTC_RSSI_STATE_LOW || + btrssi_state == BTC_RSSI_STATE_STAY_LOW) && + (wifirssi_state == BTC_RSSI_STATE_LOW || + wifirssi_state == BTC_RSSI_STATE_STAY_LOW)) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], A2dp, wifi/bt rssi both LOW!!\n"); + long_dist = true; + } + if (long_dist) { + halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC, 2); + halbtc8192e2ant_limited_rx(btcoexist, NORMAL_EXEC, false, true, + 0x4); + } else { + halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC, 1); + halbtc8192e2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, + 0x8); + } + + halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, 6); + + if (long_dist) + halbtc_coex_table_with_type(btcoexist, NORMAL_EXEC, 0); + else + halbtc_coex_table_with_type(btcoexist, NORMAL_EXEC, 2); + + if (long_dist) { + halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 17); + coex_dm->auto_tdma_adjust = false; + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0); + } else { + if ((btrssi_state == BTC_RSSI_STATE_LOW) || + (btrssi_state == BTC_RSSI_STATE_STAY_LOW)) { + halbtc8192e2ant_tdma_duration_adjust(btcoexist, false, + true, 1); + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0); + } else if ((btrssi_state == BTC_RSSI_STATE_MEDIUM) || + (btrssi_state == BTC_RSSI_STATE_STAY_MEDIUM)) { + halbtc8192e2ant_tdma_duration_adjust(btcoexist, false, + false, 1); + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 2); + } else if ((btrssi_state == BTC_RSSI_STATE_HIGH) || + (btrssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8192e2ant_tdma_duration_adjust(btcoexist, false, + false, 1); + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 4); + } + } + + /* sw mechanism */ + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + if (BTC_WIFI_BW_HT40 == wifi_bw) { + if ((wifirssi_state == BTC_RSSI_STATE_HIGH) || + (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc_sw_mechanism1(btcoexist, true, false, + false, false); + halbtc_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc_sw_mechanism1(btcoexist, true, false, + false, false); + halbtc_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } else { + if ((wifirssi_state == BTC_RSSI_STATE_HIGH) || + (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc_sw_mechanism1(btcoexist, false, false, + false, false); + halbtc_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc_sw_mechanism1(btcoexist, false, false, + false, false); + halbtc_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } +} + +static void halbtc8192e2ant_action_a2dp_pan_hs(struct btc_coexist *btcoexist) +{ + u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH; + u32 wifi_bw; + + wifirssi_state = halbtc8192e2ant_wifirssi_state(btcoexist, 0, 2, 15, 0); + btrssi_state = halbtc8192e2ant_btrssi_state(3, 34, 42); + + halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC, 1); + halbtc8192e2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8); + + halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, 6); + halbtc_coex_table_with_type(btcoexist, NORMAL_EXEC, 2); + + if ((btrssi_state == BTC_RSSI_STATE_LOW) || + (btrssi_state == BTC_RSSI_STATE_STAY_LOW)) { + halbtc8192e2ant_tdma_duration_adjust(btcoexist, false, true, 2); + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0); + } else if ((btrssi_state == BTC_RSSI_STATE_MEDIUM) || + (btrssi_state == BTC_RSSI_STATE_STAY_MEDIUM)) { + halbtc8192e2ant_tdma_duration_adjust(btcoexist, false, false, + 2); + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 2); + } else if ((btrssi_state == BTC_RSSI_STATE_HIGH) || + (btrssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8192e2ant_tdma_duration_adjust(btcoexist, false, false, + 2); + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 4); + } + + /* sw mechanism */ + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + if (BTC_WIFI_BW_HT40 == wifi_bw) { + if ((wifirssi_state == BTC_RSSI_STATE_HIGH) || + (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc_sw_mechanism1(btcoexist, true, false, + false, false); + halbtc_sw_mechanism2(btcoexist, true, false, + true, 0x6); + } else { + halbtc_sw_mechanism1(btcoexist, true, false, + false, false); + halbtc_sw_mechanism2(btcoexist, false, false, + true, 0x6); + } + } else { + if ((wifirssi_state == BTC_RSSI_STATE_HIGH) || + (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc_sw_mechanism1(btcoexist, false, false, + false, false); + halbtc_sw_mechanism2(btcoexist, true, false, + true, 0x6); + } else { + halbtc_sw_mechanism1(btcoexist, false, false, + false, false); + halbtc_sw_mechanism2(btcoexist, false, false, + true, 0x6); + } + } +} + +static void halbtc8192e2ant_action_pan_edr(struct btc_coexist *btcoexist) +{ + u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH; + u32 wifi_bw; + + wifirssi_state = halbtc8192e2ant_wifirssi_state(btcoexist, 0, 2, 15, 0); + btrssi_state = halbtc8192e2ant_btrssi_state(3, 34, 42); + + halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC, 1); + halbtc8192e2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8); + + halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, 6); + + halbtc_coex_table_with_type(btcoexist, NORMAL_EXEC, 2); + + if ((btrssi_state == BTC_RSSI_STATE_LOW) || + (btrssi_state == BTC_RSSI_STATE_STAY_LOW)) { + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0); + halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5); + } else if ((btrssi_state == BTC_RSSI_STATE_MEDIUM) || + (btrssi_state == BTC_RSSI_STATE_STAY_MEDIUM)) { + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 2); + halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 1); + } else if ((btrssi_state == BTC_RSSI_STATE_HIGH) || + (btrssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 4); + halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 1); + } + + /* sw mechanism */ + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + if (BTC_WIFI_BW_HT40 == wifi_bw) { + if ((wifirssi_state == BTC_RSSI_STATE_HIGH) || + (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc_sw_mechanism1(btcoexist, true, false, + false, false); + halbtc_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc_sw_mechanism1(btcoexist, true, false, + false, false); + halbtc_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } else { + if ((wifirssi_state == BTC_RSSI_STATE_HIGH) || + (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc_sw_mechanism1(btcoexist, false, false, + false, false); + halbtc_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc_sw_mechanism1(btcoexist, false, false, + false, false); + halbtc_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } +} + +/* PAN(HS) only */ +static void halbtc8192e2ant_action_pan_hs(struct btc_coexist *btcoexist) +{ + u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH; + u32 wifi_bw; + + wifirssi_state = halbtc8192e2ant_wifirssi_state(btcoexist, 0, 2, 15, 0); + btrssi_state = halbtc8192e2ant_btrssi_state(3, 34, 42); + + halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC, 1); + halbtc8192e2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8); + + halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, 6); + + halbtc_coex_table_with_type(btcoexist, NORMAL_EXEC, 2); + + if ((btrssi_state == BTC_RSSI_STATE_LOW) || + (btrssi_state == BTC_RSSI_STATE_STAY_LOW)) { + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0); + } else if ((btrssi_state == BTC_RSSI_STATE_MEDIUM) || + (btrssi_state == BTC_RSSI_STATE_STAY_MEDIUM)) { + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 2); + } else if ((btrssi_state == BTC_RSSI_STATE_HIGH) || + (btrssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 4); + } + halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + if (BTC_WIFI_BW_HT40 == wifi_bw) { + if ((wifirssi_state == BTC_RSSI_STATE_HIGH) || + (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc_sw_mechanism1(btcoexist, true, false, + false, false); + halbtc_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc_sw_mechanism1(btcoexist, true, false, + false, false); + halbtc_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } else { + if ((wifirssi_state == BTC_RSSI_STATE_HIGH) || + (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc_sw_mechanism1(btcoexist, false, false, + false, false); + halbtc_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc_sw_mechanism1(btcoexist, false, false, + false, false); + halbtc_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } +} + +/* PAN(EDR)+A2DP */ +static void halbtc8192e2ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist) +{ + u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH; + u32 wifi_bw; + + wifirssi_state = halbtc8192e2ant_wifirssi_state(btcoexist, 0, 2, 15, 0); + btrssi_state = halbtc8192e2ant_btrssi_state(3, 34, 42); + + halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC, 1); + halbtc8192e2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8); + + halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, 6); + + halbtc_coex_table_with_type(btcoexist, NORMAL_EXEC, 2); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + + if ((btrssi_state == BTC_RSSI_STATE_LOW) || + (btrssi_state == BTC_RSSI_STATE_STAY_LOW)) { + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0); + halbtc8192e2ant_tdma_duration_adjust(btcoexist, false, true, 3); + } else if ((btrssi_state == BTC_RSSI_STATE_MEDIUM) || + (btrssi_state == BTC_RSSI_STATE_STAY_MEDIUM)) { + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 2); + halbtc8192e2ant_tdma_duration_adjust(btcoexist, false, false, + 3); + } else if ((btrssi_state == BTC_RSSI_STATE_HIGH) || + (btrssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 4); + halbtc8192e2ant_tdma_duration_adjust(btcoexist, false, false, + 3); + } + + /* sw mechanism */ + if (BTC_WIFI_BW_HT40 == wifi_bw) { + if ((wifirssi_state == BTC_RSSI_STATE_HIGH) || + (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc_sw_mechanism1(btcoexist, true, false, + false, false); + halbtc_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc_sw_mechanism1(btcoexist, true, false, + false, false); + halbtc_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } else { + if ((wifirssi_state == BTC_RSSI_STATE_HIGH) || + (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc_sw_mechanism1(btcoexist, false, false, + false, false); + halbtc_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc_sw_mechanism1(btcoexist, false, false, + false, false); + halbtc_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } +} + +static void halbtc8192e2ant_action_pan_edr_hid(struct btc_coexist *btcoexist) +{ + u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH; + u32 wifi_bw; + + wifirssi_state = halbtc8192e2ant_wifirssi_state(btcoexist, 0, 2, 15, 0); + btrssi_state = halbtc8192e2ant_btrssi_state(3, 34, 42); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + + halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC, 1); + halbtc8192e2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8); + + halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, 6); + + halbtc_coex_table_with_type(btcoexist, NORMAL_EXEC, 3); + + if ((btrssi_state == BTC_RSSI_STATE_LOW) || + (btrssi_state == BTC_RSSI_STATE_STAY_LOW)) { + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0); + halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14); + } else if ((btrssi_state == BTC_RSSI_STATE_MEDIUM) || + (btrssi_state == BTC_RSSI_STATE_STAY_MEDIUM)) { + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 2); + halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 10); + } else if ((btrssi_state == BTC_RSSI_STATE_HIGH) || + (btrssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 4); + halbtc8192e2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 10); + } + + /* sw mechanism */ + if (BTC_WIFI_BW_HT40 == wifi_bw) { + if ((wifirssi_state == BTC_RSSI_STATE_HIGH) || + (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc_sw_mechanism1(btcoexist, true, true, + false, false); + halbtc_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc_sw_mechanism1(btcoexist, true, true, + false, false); + halbtc_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } else { + if ((wifirssi_state == BTC_RSSI_STATE_HIGH) || + (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc_sw_mechanism1(btcoexist, false, true, + false, false); + halbtc_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc_sw_mechanism1(btcoexist, false, true, + false, false); + halbtc_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } +} + +/* HID+A2DP+PAN(EDR) */ +static void action_hid_a2dp_pan_edr(struct btc_coexist *btcoexist) +{ + u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH; + u32 wifi_bw; + + wifirssi_state = halbtc8192e2ant_wifirssi_state(btcoexist, 0, 2, 15, 0); + btrssi_state = halbtc8192e2ant_btrssi_state(3, 34, 42); + + halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC, 1); + halbtc8192e2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8); + + halbtc8192e2ant_fw_dac_swinglvl(btcoexist, NORMAL_EXEC, 6); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + + halbtc_coex_table_with_type(btcoexist, NORMAL_EXEC, 3); + + if ((btrssi_state == BTC_RSSI_STATE_LOW) || + (btrssi_state == BTC_RSSI_STATE_STAY_LOW)) { + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0); + halbtc8192e2ant_tdma_duration_adjust(btcoexist, true, true, 3); + } else if ((btrssi_state == BTC_RSSI_STATE_MEDIUM) || + (btrssi_state == BTC_RSSI_STATE_STAY_MEDIUM)) { + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 2); + halbtc8192e2ant_tdma_duration_adjust(btcoexist, true, false, 3); + } else if ((btrssi_state == BTC_RSSI_STATE_HIGH) || + (btrssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 4); + halbtc8192e2ant_tdma_duration_adjust(btcoexist, true, false, 3); + } + + /* sw mechanism */ + if (BTC_WIFI_BW_HT40 == wifi_bw) { + if ((wifirssi_state == BTC_RSSI_STATE_HIGH) || + (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc_sw_mechanism1(btcoexist, true, true, + false, false); + halbtc_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc_sw_mechanism1(btcoexist, true, true, + false, false); + halbtc_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } else { + if ((wifirssi_state == BTC_RSSI_STATE_HIGH) || + (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc_sw_mechanism1(btcoexist, false, true, + false, false); + halbtc_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc_sw_mechanism1(btcoexist, false, true, + false, false); + halbtc_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } +} + +static void halbtc8192e2ant_action_hid_a2dp(struct btc_coexist *btcoexist) +{ + u8 wifirssi_state, btrssi_state = BTC_RSSI_STATE_HIGH; + u32 wifi_bw; + + wifirssi_state = halbtc8192e2ant_wifirssi_state(btcoexist, 0, 2, 15, 0); + btrssi_state = halbtc8192e2ant_btrssi_state(3, 34, 42); + + halbtc8192e2ant_switch_sstype(btcoexist, NORMAL_EXEC, 1); + halbtc8192e2ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 0x8); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + + halbtc_coex_table_with_type(btcoexist, NORMAL_EXEC, 3); + + if ((btrssi_state == BTC_RSSI_STATE_LOW) || + (btrssi_state == BTC_RSSI_STATE_STAY_LOW)) { + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 0); + halbtc8192e2ant_tdma_duration_adjust(btcoexist, true, true, 2); + } else if ((btrssi_state == BTC_RSSI_STATE_MEDIUM) || + (btrssi_state == BTC_RSSI_STATE_STAY_MEDIUM)) { + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 2); + halbtc8192e2ant_tdma_duration_adjust(btcoexist, true, false, 2); + } else if ((btrssi_state == BTC_RSSI_STATE_HIGH) || + (btrssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8192e2ant_dec_btpwr(btcoexist, NORMAL_EXEC, 4); + halbtc8192e2ant_tdma_duration_adjust(btcoexist, true, false, 2); + } + + /* sw mechanism */ + if (BTC_WIFI_BW_HT40 == wifi_bw) { + if ((wifirssi_state == BTC_RSSI_STATE_HIGH) || + (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc_sw_mechanism1(btcoexist, true, true, + false, false); + halbtc_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc_sw_mechanism1(btcoexist, true, true, + false, false); + halbtc_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } else { + if ((wifirssi_state == BTC_RSSI_STATE_HIGH) || + (wifirssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc_sw_mechanism1(btcoexist, false, true, + false, false); + halbtc_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc_sw_mechanism1(btcoexist, false, true, + false, false); + halbtc_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } +} + +static void halbtc8192e2ant_run_coexist_mechanism(struct btc_coexist *btcoexist) +{ + u8 algorithm = 0; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], RunCoexistMechanism() ===>\n"); + + if (btcoexist->manual_control) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], return for Manual CTRL <===\n"); + return; + } + + if (coex_sta->under_ips) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], wifi is under IPS !!!\n"); + return; + } + + algorithm = halbtc8192e2ant_action_algorithm(btcoexist); + if (coex_sta->c2h_bt_inquiry_page && + (BT_8192E_2ANT_COEX_ALGO_PANHS != algorithm)) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT is under inquiry/page scan !!\n"); + halbtc8192e2ant_action_bt_inquiry(btcoexist); + return; + } + + coex_dm->cur_algorithm = algorithm; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Algorithm = %d\n", coex_dm->cur_algorithm); + + if (halbtc8192e2ant_is_common_action(btcoexist)) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action 2-Ant common.\n"); + coex_dm->auto_tdma_adjust = false; + } else { + if (coex_dm->cur_algorithm != coex_dm->pre_algorithm) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex] preAlgorithm =%d, curAlgorithm =%d\n", + coex_dm->pre_algorithm, + coex_dm->cur_algorithm); + coex_dm->auto_tdma_adjust = false; + } + switch (coex_dm->cur_algorithm) { + case BT_8192E_2ANT_COEX_ALGO_SCO: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "Action 2-Ant, algorithm = SCO.\n"); + halbtc8192e2ant_action_sco(btcoexist); + break; + case BT_8192E_2ANT_COEX_ALGO_SCO_PAN: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "Action 2-Ant, algorithm = SCO+PAN(EDR).\n"); + halbtc8192e2ant_action_sco_pan(btcoexist); + break; + case BT_8192E_2ANT_COEX_ALGO_HID: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "Action 2-Ant, algorithm = HID.\n"); + halbtc8192e2ant_action_hid(btcoexist); + break; + case BT_8192E_2ANT_COEX_ALGO_A2DP: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "Action 2-Ant, algorithm = A2DP.\n"); + halbtc8192e2ant_action_a2dp(btcoexist); + break; + case BT_8192E_2ANT_COEX_ALGO_A2DP_PANHS: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "Action 2-Ant, algorithm = A2DP+PAN(HS).\n"); + halbtc8192e2ant_action_a2dp_pan_hs(btcoexist); + break; + case BT_8192E_2ANT_COEX_ALGO_PANEDR: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "Action 2-Ant, algorithm = PAN(EDR).\n"); + halbtc8192e2ant_action_pan_edr(btcoexist); + break; + case BT_8192E_2ANT_COEX_ALGO_PANHS: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "Action 2-Ant, algorithm = HS mode.\n"); + halbtc8192e2ant_action_pan_hs(btcoexist); + break; + case BT_8192E_2ANT_COEX_ALGO_PANEDR_A2DP: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "Action 2-Ant, algorithm = PAN+A2DP.\n"); + halbtc8192e2ant_action_pan_edr_a2dp(btcoexist); + break; + case BT_8192E_2ANT_COEX_ALGO_PANEDR_HID: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "Action 2-Ant, algorithm = PAN(EDR)+HID.\n"); + halbtc8192e2ant_action_pan_edr_hid(btcoexist); + break; + case BT_8192E_2ANT_COEX_ALGO_HID_A2DP_PANEDR: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "Action 2-Ant, algorithm = HID+A2DP+PAN.\n"); + action_hid_a2dp_pan_edr(btcoexist); + break; + case BT_8192E_2ANT_COEX_ALGO_HID_A2DP: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "Action 2-Ant, algorithm = HID+A2DP.\n"); + halbtc8192e2ant_action_hid_a2dp(btcoexist); + break; + default: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "Action 2-Ant, algorithm = unknown!!\n"); + /* halbtc8192e2ant_coex_alloff(btcoexist); */ + break; + } + coex_dm->pre_algorithm = coex_dm->cur_algorithm; + } +} + +static void halbtc8192e2ant_init_hwconfig(struct btc_coexist *btcoexist, + bool backup) +{ + u16 u16tmp = 0; + u8 u8tmp = 0; + + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], 2Ant Init HW Config!!\n"); + + if (backup) { + /* backup rf 0x1e value */ + coex_dm->bt_rf0x1e_backup = + btcoexist->btc_get_rf_reg(btcoexist, BTC_RF_A, + 0x1e, 0xfffff); + + coex_dm->backup_arfr_cnt1 = btcoexist->btc_read_4byte(btcoexist, + 0x430); + coex_dm->backup_arfr_cnt2 = btcoexist->btc_read_4byte(btcoexist, + 0x434); + coex_dm->backup_retrylimit = btcoexist->btc_read_2byte( + btcoexist, + 0x42a); + coex_dm->backup_ampdu_maxtime = btcoexist->btc_read_1byte( + btcoexist, + 0x456); + } + + /* antenna sw ctrl to bt */ + btcoexist->btc_write_1byte(btcoexist, 0x4f, 0x6); + btcoexist->btc_write_1byte(btcoexist, 0x944, 0x24); + btcoexist->btc_write_4byte(btcoexist, 0x930, 0x700700); + btcoexist->btc_write_1byte(btcoexist, 0x92c, 0x20); + if (btcoexist->chip_interface == BTC_INTF_USB) + btcoexist->btc_write_4byte(btcoexist, 0x64, 0x30430004); + else + btcoexist->btc_write_4byte(btcoexist, 0x64, 0x30030004); + + halbtc_coex_table_with_type(btcoexist, FORCE_EXEC, 0); + + /* antenna switch control parameter */ + btcoexist->btc_write_4byte(btcoexist, 0x858, 0x55555555); + + /* coex parameters */ + btcoexist->btc_write_1byte(btcoexist, 0x778, 0x3); + /* 0x790[5:0] = 0x5 */ + u8tmp = btcoexist->btc_read_1byte(btcoexist, 0x790); + u8tmp &= 0xc0; + u8tmp |= 0x5; + btcoexist->btc_write_1byte(btcoexist, 0x790, u8tmp); + + /* enable counter statistics */ + btcoexist->btc_write_1byte(btcoexist, 0x76e, 0x4); + + /* enable PTA */ + btcoexist->btc_write_1byte(btcoexist, 0x40, 0x20); + /* enable mailbox interface */ + u16tmp = btcoexist->btc_read_2byte(btcoexist, 0x40); + u16tmp |= BIT(9); + btcoexist->btc_write_2byte(btcoexist, 0x40, u16tmp); + + /* enable PTA I2C mailbox */ + u8tmp = btcoexist->btc_read_1byte(btcoexist, 0x101); + u8tmp |= BIT(4); + btcoexist->btc_write_1byte(btcoexist, 0x101, u8tmp); + + /* enable bt clock when wifi is disabled. */ + u8tmp = btcoexist->btc_read_1byte(btcoexist, 0x93); + u8tmp |= BIT(0); + btcoexist->btc_write_1byte(btcoexist, 0x93, u8tmp); + /* enable bt clock when suspend. */ + u8tmp = btcoexist->btc_read_1byte(btcoexist, 0x7); + u8tmp |= BIT(0); + btcoexist->btc_write_1byte(btcoexist, 0x7, u8tmp); +} + +/************************************************************* + * work around function start with wa_halbtc8192e2ant_ + *************************************************************/ + +/************************************************************ + * extern function start with EXhalbtc8192e2ant_ + ************************************************************/ + +void ex_halbtc8192e2ant_init_hwconfig(struct btc_coexist *btcoexist) +{ + halbtc8192e2ant_init_hwconfig(btcoexist, true); +} + +void ex_halbtc8192e2ant_init_coex_dm(struct btc_coexist *btcoexist) +{ + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], Coex Mechanism Init!!\n"); + halbtc8192e2ant_init_coex_dm(btcoexist); +} + +void ex_halbtc8192e2ant_display_coex_info(struct btc_coexist *btcoexist) +{ + struct btc_board_info *board_info = &btcoexist->board_info; + struct btc_stack_info *stack_info = &btcoexist->stack_info; + u8 *cli_buf = btcoexist->cli_buf; + u8 u8tmp[4], i, bt_info_ext, ps_tdma_case = 0; + u16 u16tmp[4]; + u32 u32tmp[4]; + bool roam = false, scan = false, link = false, wifi_under_5g = false; + bool bt_hson = false, wifi_busy = false; + int wifirssi = 0, bt_hs_rssi = 0; + u32 wifi_bw, wifi_traffic_dir; + u8 wifi_dot11_chnl, wifi_hs_chnl; + u32 fw_ver = 0, bt_patch_ver = 0; + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\r\n ============[BT Coexist info] ============"); + CL_PRINTF(cli_buf); + + if (btcoexist->manual_control) { + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\r\n ===========[Under Manual Control] ==========="); + CL_PRINTF(cli_buf); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\r\n =========================================="); + CL_PRINTF(cli_buf); + } + + if (!board_info->bt_exist) { + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n BT not exists !!!"); + CL_PRINTF(cli_buf); + return; + } + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism: ", + board_info->pg_ant_num, board_info->btdm_ant_num); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", + "BT stack/ hci ext ver", + ((stack_info->profile_notified) ? "Yes" : "No"), + stack_info->hci_version); + CL_PRINTF(cli_buf); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER, &bt_patch_ver); + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\r\n %-35s = %d_%d/ 0x%x/ 0x%x(%d)", + "CoexVer/ FwVer/ PatchVer", + glcoex_ver_date_8192e_2ant, glcoex_ver_8192e_2ant, + fw_ver, bt_patch_ver, bt_patch_ver); + CL_PRINTF(cli_buf); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hson); + btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_DOT11_CHNL, + &wifi_dot11_chnl); + btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifi_hs_chnl); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d(%d)", + "Dot11 channel / HsMode(HsChnl)", + wifi_dot11_chnl, bt_hson, wifi_hs_chnl); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", + "H2C Wifi inform bt chnl Info", coex_dm->wifi_chnl_info[0], + coex_dm->wifi_chnl_info[1], coex_dm->wifi_chnl_info[2]); + CL_PRINTF(cli_buf); + + btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifirssi); + btcoexist->btc_get(btcoexist, BTC_GET_S4_HS_RSSI, &bt_hs_rssi); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", + "Wifi rssi/ HS rssi", wifirssi, bt_hs_rssi); + CL_PRINTF(cli_buf); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", + "Wifi link/ roam/ scan", link, roam, scan); + CL_PRINTF(cli_buf); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g); + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, + &wifi_traffic_dir); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %s/ %s ", + "Wifi status", (wifi_under_5g ? "5G" : "2.4G"), + ((BTC_WIFI_BW_LEGACY == wifi_bw) ? "Legacy" : + (((BTC_WIFI_BW_HT40 == wifi_bw) ? "HT40" : "HT20"))), + ((!wifi_busy) ? "idle" : + ((BTC_WIFI_TRAFFIC_TX == wifi_traffic_dir) ? + "uplink" : "downlink"))); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ", + "BT [status/ rssi/ retryCnt]", + ((btcoexist->bt_info.bt_disabled) ? ("disabled") : + ((coex_sta->c2h_bt_inquiry_page) ? + ("inquiry/page scan") : + ((BT_8192E_2ANT_BT_STATUS_NON_CONNECTED_IDLE == + coex_dm->bt_status) ? "non-connected idle" : + ((BT_8192E_2ANT_BT_STATUS_CONNECTED_IDLE == + coex_dm->bt_status) ? "connected-idle" : "busy")))), + coex_sta->bt_rssi, coex_sta->bt_retry_cnt); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", + "SCO/HID/PAN/A2DP", stack_info->sco_exist, + stack_info->hid_exist, stack_info->pan_exist, + stack_info->a2dp_exist); + CL_PRINTF(cli_buf); + btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_BT_LINK_INFO); + + bt_info_ext = coex_sta->bt_info_ext; + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", + "BT Info A2DP rate", + (bt_info_ext & BIT(0)) ? "Basic rate" : "EDR rate"); + CL_PRINTF(cli_buf); + + for (i = 0; i < BT_INFO_SRC_8192E_2ANT_MAX; i++) { + if (coex_sta->bt_info_c2h_cnt[i]) { + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\r\n %-35s = %02x %02x %02x %02x ", + glbt_infosrc8192e2ant[i], + coex_sta->bt_info_c2h[i][0], + coex_sta->bt_info_c2h[i][1], + coex_sta->bt_info_c2h[i][2], + coex_sta->bt_info_c2h[i][3]); + CL_PRINTF(cli_buf); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "%02x %02x %02x(%d)", + coex_sta->bt_info_c2h[i][4], + coex_sta->bt_info_c2h[i][5], + coex_sta->bt_info_c2h[i][6], + coex_sta->bt_info_c2h_cnt[i]); + CL_PRINTF(cli_buf); + } + } + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/%s", + "PS state, IPS/LPS", + ((coex_sta->under_ips ? "IPS ON" : "IPS OFF")), + ((coex_sta->under_lps ? "LPS ON" : "LPS OFF"))); + CL_PRINTF(cli_buf); + btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_FW_PWR_MODE_CMD); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "SS Type", + coex_dm->cur_sstype); + CL_PRINTF(cli_buf); + + /* Sw mechanism */ + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s", + "============[Sw mechanism] ============"); + CL_PRINTF(cli_buf); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", + "SM1[ShRf/ LpRA/ LimDig]", coex_dm->cur_rf_rx_lpf_shrink, + coex_dm->cur_low_penalty_ra, coex_dm->limited_dig); + CL_PRINTF(cli_buf); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d(0x%x) ", + "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", + coex_dm->cur_agc_table_en, coex_dm->cur_adc_back_off, + coex_dm->cur_dac_swing_on, coex_dm->cur_dac_swing_lvl); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Rate Mask", + btcoexist->bt_info.ra_mask); + CL_PRINTF(cli_buf); + + /* Fw mechanism */ + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s", + "============[Fw mechanism] ============"); + CL_PRINTF(cli_buf); + + ps_tdma_case = coex_dm->cur_ps_tdma; + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d)", + "PS TDMA", coex_dm->ps_tdma_para[0], + coex_dm->ps_tdma_para[1], coex_dm->ps_tdma_para[2], + coex_dm->ps_tdma_para[3], coex_dm->ps_tdma_para[4], + ps_tdma_case, coex_dm->auto_tdma_adjust); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", + "DecBtPwr/ IgnWlanAct", + coex_dm->cur_dec_bt_pwr, coex_dm->cur_ignore_wlan_act); + CL_PRINTF(cli_buf); + + /* Hw setting */ + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s", + "============[Hw setting] ============"); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", + "RF-A, 0x1e initVal", coex_dm->bt_rf0x1e_backup); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x", + "backup ARFR1/ARFR2/RL/AMaxTime", coex_dm->backup_arfr_cnt1, + coex_dm->backup_arfr_cnt2, coex_dm->backup_retrylimit, + coex_dm->backup_ampdu_maxtime); + CL_PRINTF(cli_buf); + + u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x430); + u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x434); + u16tmp[0] = btcoexist->btc_read_2byte(btcoexist, 0x42a); + u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x456); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x", + "0x430/0x434/0x42a/0x456", + u32tmp[0], u32tmp[1], u16tmp[0], u8tmp[0]); + CL_PRINTF(cli_buf); + + u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xc04); + u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0xd04); + u32tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0x90c); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", + "0xc04/ 0xd04/ 0x90c", u32tmp[0], u32tmp[1], u32tmp[2]); + CL_PRINTF(cli_buf); + + u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x778); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x778", + u8tmp[0]); + CL_PRINTF(cli_buf); + + u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x92c); + u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x930); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", + "0x92c/ 0x930", (u8tmp[0]), u32tmp[0]); + CL_PRINTF(cli_buf); + + u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x40); + u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0x4f); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", + "0x40/ 0x4f", u8tmp[0], u8tmp[1]); + CL_PRINTF(cli_buf); + + u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x550); + u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x522); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", + "0x550(bcn ctrl)/0x522", u32tmp[0], u8tmp[0]); + CL_PRINTF(cli_buf); + + u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xc50); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0xc50(dig)", + u32tmp[0]); + CL_PRINTF(cli_buf); + + u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x6c0); + u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x6c4); + u32tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0x6c8); + u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x6cc); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", + "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", + u32tmp[0], u32tmp[1], u32tmp[2], u8tmp[0]); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", + "0x770(hp rx[31:16]/tx[15:0])", + coex_sta->high_priority_rx, coex_sta->high_priority_tx); + CL_PRINTF(cli_buf); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", + "0x774(lp rx[31:16]/tx[15:0])", + coex_sta->low_priority_rx, coex_sta->low_priority_tx); + CL_PRINTF(cli_buf); +#if (BT_AUTO_REPORT_ONLY_8192E_2ANT == 1) + halbtc8192e2ant_monitor_bt_ctr(btcoexist); +#endif + btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_COEX_STATISTICS); +} + +void ex_halbtc8192e2ant_ips_notify(struct btc_coexist *btcoexist, u8 type) +{ + if (BTC_IPS_ENTER == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], IPS ENTER notify\n"); + coex_sta->under_ips = true; + halbtc8192e2ant_coex_alloff(btcoexist); + } else if (BTC_IPS_LEAVE == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], IPS LEAVE notify\n"); + coex_sta->under_ips = false; + } +} + +void ex_halbtc8192e2ant_lps_notify(struct btc_coexist *btcoexist, u8 type) +{ + if (BTC_LPS_ENABLE == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], LPS ENABLE notify\n"); + coex_sta->under_lps = true; + } else if (BTC_LPS_DISABLE == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], LPS DISABLE notify\n"); + coex_sta->under_lps = false; + } +} + +void ex_halbtc8192e2ant_scan_notify(struct btc_coexist *btcoexist, u8 type) +{ + if (BTC_SCAN_START == type) + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], SCAN START notify\n"); + else if (BTC_SCAN_FINISH == type) + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], SCAN FINISH notify\n"); +} + +void ex_halbtc8192e2ant_connect_notify(struct btc_coexist *btcoexist, u8 type) +{ + if (BTC_ASSOCIATE_START == type) + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], CONNECT START notify\n"); + else if (BTC_ASSOCIATE_FINISH == type) + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], CONNECT FINISH notify\n"); +} + +void ex_halbtc8192e2ant_media_status_notify(struct btc_coexist *btcoexist, + u8 type) +{ + u8 h2c_parameter[3] = {0}; + u32 wifi_bw; + u8 wifi_center_chnl; + + if (btcoexist->manual_control || + btcoexist->stop_coex_dm || + btcoexist->bt_info.bt_disabled) + return; + + if (BTC_MEDIA_CONNECT == type) + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], MEDIA connect notify\n"); + else + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], MEDIA disconnect notify\n"); + + /* only 2.4G we need to inform bt the chnl mask */ + btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, + &wifi_center_chnl); + if ((BTC_MEDIA_CONNECT == type) && + (wifi_center_chnl <= 14)) { + h2c_parameter[0] = 0x1; + h2c_parameter[1] = wifi_center_chnl; + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + if (BTC_WIFI_BW_HT40 == wifi_bw) + h2c_parameter[2] = 0x30; + else + h2c_parameter[2] = 0x20; + } + + coex_dm->wifi_chnl_info[0] = h2c_parameter[0]; + coex_dm->wifi_chnl_info[1] = h2c_parameter[1]; + coex_dm->wifi_chnl_info[2] = h2c_parameter[2]; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], FW write 0x66 = 0x%x\n", + h2c_parameter[0] << 16 | h2c_parameter[1] << 8 | + h2c_parameter[2]); + + btcoexist->btc_fill_h2c(btcoexist, 0x66, 3, h2c_parameter); +} + +void ex_halbtc8192e2ant_special_packet_notify(struct btc_coexist *btcoexist, + u8 type) +{ + if (type == BTC_PACKET_DHCP) + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], DHCP Packet notify\n"); +} + +void ex_halbtc8192e2ant_bt_info_notify(struct btc_coexist *btcoexist, + u8 *tmp_buf, u8 length) +{ + u8 bt_info = 0; + u8 i, rspsource = 0; + bool bt_busy = false, limited_dig = false; + bool wifi_connected = false; + + coex_sta->c2h_bt_info_req_sent = false; + + rspsource = tmp_buf[0] & 0xf; + if (rspsource >= BT_INFO_SRC_8192E_2ANT_MAX) + rspsource = BT_INFO_SRC_8192E_2ANT_WIFI_FW; + coex_sta->bt_info_c2h_cnt[rspsource]++; + + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], Bt info[%d], length =%d, hex data =[", + rspsource, length); + for (i = 0; i < length; i++) { + coex_sta->bt_info_c2h[rspsource][i] = tmp_buf[i]; + if (i == 1) + bt_info = tmp_buf[i]; + if (i == length-1) + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "0x%02x]\n", tmp_buf[i]); + else + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "0x%02x, ", tmp_buf[i]); + } + + if (BT_INFO_SRC_8192E_2ANT_WIFI_FW != rspsource) { + coex_sta->bt_retry_cnt = /* [3:0] */ + coex_sta->bt_info_c2h[rspsource][2] & 0xf; + + coex_sta->bt_rssi = + coex_sta->bt_info_c2h[rspsource][3] * 2 + 10; + + coex_sta->bt_info_ext = + coex_sta->bt_info_c2h[rspsource][4]; + + /* Here we need to resend some wifi info to BT + * because bt is reset and loss of the info. */ + if ((coex_sta->bt_info_ext & BIT(1))) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "bit1, send wifi BW&Chnl to BT!!\n"); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, + &wifi_connected); + if (wifi_connected) + ex_halbtc8192e2ant_media_status_notify( + btcoexist, + BTC_MEDIA_CONNECT); + else + ex_halbtc8192e2ant_media_status_notify( + btcoexist, + BTC_MEDIA_DISCONNECT); + } + + if ((coex_sta->bt_info_ext & BIT(3))) { + if (!btcoexist->manual_control && + !btcoexist->stop_coex_dm) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "bit3, BT NOT ignore Wlan active!\n"); + halbtc8192e2ant_ignorewlanact(btcoexist, + FORCE_EXEC, + false); + } + } else { + /* BT already NOT ignore Wlan active, + * do nothing here. */ + } + +#if (BT_AUTO_REPORT_ONLY_8192E_2ANT == 0) + if ((coex_sta->bt_info_ext & BIT(4))) { + /* BT auto report already enabled, do nothing */ + } else { + halbtc8192e2ant_bt_autoreport(btcoexist, FORCE_EXEC, + true); + } +#endif + } + + /* check BIT(2) first ==> check if bt is under inquiry or page scan */ + if (bt_info & BT_INFO_8192E_2ANT_B_INQ_PAGE) + coex_sta->c2h_bt_inquiry_page = true; + else + coex_sta->c2h_bt_inquiry_page = false; + + /* set link exist status */ + if (!(bt_info&BT_INFO_8192E_2ANT_B_CONNECTION)) { + coex_sta->bt_link_exist = false; + coex_sta->pan_exist = false; + coex_sta->a2dp_exist = false; + coex_sta->hid_exist = false; + coex_sta->sco_exist = false; + } else {/* connection exists */ + coex_sta->bt_link_exist = true; + if (bt_info & BT_INFO_8192E_2ANT_B_FTP) + coex_sta->pan_exist = true; + else + coex_sta->pan_exist = false; + if (bt_info & BT_INFO_8192E_2ANT_B_A2DP) + coex_sta->a2dp_exist = true; + else + coex_sta->a2dp_exist = false; + if (bt_info & BT_INFO_8192E_2ANT_B_HID) + coex_sta->hid_exist = true; + else + coex_sta->hid_exist = false; + if (bt_info & BT_INFO_8192E_2ANT_B_SCO_ESCO) + coex_sta->sco_exist = true; + else + coex_sta->sco_exist = false; + } + + halbtc8192e2ant_update_btlink_info(btcoexist); + + if (!(bt_info&BT_INFO_8192E_2ANT_B_CONNECTION)) { + coex_dm->bt_status = BT_8192E_2ANT_BT_STATUS_NON_CONNECTED_IDLE; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT Non-Connected idle!!!\n"); + } else if (bt_info == BT_INFO_8192E_2ANT_B_CONNECTION) { + coex_dm->bt_status = BT_8192E_2ANT_BT_STATUS_CONNECTED_IDLE; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], bt_infoNotify(), BT Connected-idle!!!\n"); + } else if ((bt_info&BT_INFO_8192E_2ANT_B_SCO_ESCO) || + (bt_info&BT_INFO_8192E_2ANT_B_SCO_BUSY)) { + coex_dm->bt_status = BT_8192E_2ANT_BT_STATUS_SCO_BUSY; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], bt_infoNotify(), BT SCO busy!!!\n"); + } else if (bt_info&BT_INFO_8192E_2ANT_B_ACL_BUSY) { + coex_dm->bt_status = BT_8192E_2ANT_BT_STATUS_ACL_BUSY; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], bt_infoNotify(), BT ACL busy!!!\n"); + } else { + coex_dm->bt_status = BT_8192E_2ANT_BT_STATUS_MAX; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex]bt_infoNotify(), BT Non-Defined state!!!\n"); + } + + if ((BT_8192E_2ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) || + (BT_8192E_2ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) || + (BT_8192E_2ANT_BT_STATUS_ACL_SCO_BUSY == coex_dm->bt_status)) { + bt_busy = true; + limited_dig = true; + } else { + bt_busy = false; + limited_dig = false; + } + + btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bt_busy); + + coex_dm->limited_dig = limited_dig; + btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_LIMITED_DIG, &limited_dig); + + halbtc8192e2ant_run_coexist_mechanism(btcoexist); +} + +void ex_halbtc8192e2ant_stack_operation_notify(struct btc_coexist *btcoexist, + u8 type) +{ +} + +void ex_halbtc8192e2ant_halt_notify(struct btc_coexist *btcoexist) +{ + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, "[BTCoex], Halt notify\n"); + + halbtc8192e2ant_ignorewlanact(btcoexist, FORCE_EXEC, true); + ex_halbtc8192e2ant_media_status_notify(btcoexist, BTC_MEDIA_DISCONNECT); +} + +void ex_halbtc8192e2ant_periodical(struct btc_coexist *btcoexist) +{ + static u8 dis_ver_info_cnt; + u32 fw_ver = 0, bt_patch_ver = 0; + struct btc_board_info *board_info = &btcoexist->board_info; + struct btc_stack_info *stack_info = &btcoexist->stack_info; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "======================= Periodical =======================\n"); + if (dis_ver_info_cnt <= 5) { + dis_ver_info_cnt += 1; + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "************************************************\n"); + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n", + board_info->pg_ant_num, board_info->btdm_ant_num, + board_info->btdm_ant_pos); + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "BT stack/ hci ext ver = %s / %d\n", + ((stack_info->profile_notified) ? "Yes" : "No"), + stack_info->hci_version); + btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER, + &bt_patch_ver); + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver); + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n", + glcoex_ver_date_8192e_2ant, glcoex_ver_8192e_2ant, + fw_ver, bt_patch_ver, bt_patch_ver); + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "************************************************\n"); + } + +#if (BT_AUTO_REPORT_ONLY_8192E_2ANT == 0) + halbtc8192e2ant_querybt_info(btcoexist); + halbtc8192e2ant_monitor_bt_ctr(btcoexist); + halbtc_monitor_bt_enable_disable(btcoexist); +#else + if (halbtc8192e2ant_iswifi_status_changed(btcoexist) || + coex_dm->auto_tdma_adjust) + halbtc8192e2ant_run_coexist_mechanism(btcoexist); +#endif +} diff --git a/drivers/staging/rtl8192ee/btcoexist/halbtc8192e2ant.h b/drivers/staging/rtl8192ee/btcoexist/halbtc8192e2ant.h new file mode 100644 index 000000000000..ece3e10e6df7 --- /dev/null +++ b/drivers/staging/rtl8192ee/btcoexist/halbtc8192e2ant.h @@ -0,0 +1,161 @@ +/***************************************************************** + * The following is for 8192E 2Ant BT Co-exist definition + *****************************************************************/ +#define BT_AUTO_REPORT_ONLY_8192E_2ANT 0 + +#define BT_INFO_8192E_2ANT_B_FTP BIT(7) +#define BT_INFO_8192E_2ANT_B_A2DP BIT(6) +#define BT_INFO_8192E_2ANT_B_HID BIT(5) +#define BT_INFO_8192E_2ANT_B_SCO_BUSY BIT(4) +#define BT_INFO_8192E_2ANT_B_ACL_BUSY BIT(3) +#define BT_INFO_8192E_2ANT_B_INQ_PAGE BIT(2) +#define BT_INFO_8192E_2ANT_B_SCO_ESCO BIT(1) +#define BT_INFO_8192E_2ANT_B_CONNECTION BIT(0) + +#define BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT 2 + +enum bt_info_src_8192e_2ant { + BT_INFO_SRC_8192E_2ANT_WIFI_FW = 0x0, + BT_INFO_SRC_8192E_2ANT_BT_RSP = 0x1, + BT_INFO_SRC_8192E_2ANT_BT_ACTIVE_SEND = 0x2, + BT_INFO_SRC_8192E_2ANT_MAX +}; + +enum bt_8192e_2ant_bt_status { + BT_8192E_2ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0, + BT_8192E_2ANT_BT_STATUS_CONNECTED_IDLE = 0x1, + BT_8192E_2ANT_BT_STATUS_INQ_PAGE = 0x2, + BT_8192E_2ANT_BT_STATUS_ACL_BUSY = 0x3, + BT_8192E_2ANT_BT_STATUS_SCO_BUSY = 0x4, + BT_8192E_2ANT_BT_STATUS_ACL_SCO_BUSY = 0x5, + BT_8192E_2ANT_BT_STATUS_MAX +}; + +enum bt_8192e_2ant_coex_algo { + BT_8192E_2ANT_COEX_ALGO_UNDEFINED = 0x0, + BT_8192E_2ANT_COEX_ALGO_SCO = 0x1, + BT_8192E_2ANT_COEX_ALGO_SCO_PAN = 0x2, + BT_8192E_2ANT_COEX_ALGO_HID = 0x3, + BT_8192E_2ANT_COEX_ALGO_A2DP = 0x4, + BT_8192E_2ANT_COEX_ALGO_A2DP_PANHS = 0x5, + BT_8192E_2ANT_COEX_ALGO_PANEDR = 0x6, + BT_8192E_2ANT_COEX_ALGO_PANHS = 0x7, + BT_8192E_2ANT_COEX_ALGO_PANEDR_A2DP = 0x8, + BT_8192E_2ANT_COEX_ALGO_PANEDR_HID = 0x9, + BT_8192E_2ANT_COEX_ALGO_HID_A2DP_PANEDR = 0xa, + BT_8192E_2ANT_COEX_ALGO_HID_A2DP = 0xb, + BT_8192E_2ANT_COEX_ALGO_MAX = 0xc +}; + +struct coex_dm_8192e_2ant { + /* fw mechanism */ + u8 pre_dec_bt_pwr; + u8 cur_dec_bt_pwr; + u8 pre_fw_dac_swing_lvl; + u8 cur_fw_dac_swing_lvl; + bool cur_ignore_wlan_act; + bool pre_ignore_wlan_act; + u8 pre_ps_tdma; + u8 cur_ps_tdma; + u8 ps_tdma_para[5]; + u8 ps_tdma_du_adj_type; + bool reset_tdma_adjust; + bool auto_tdma_adjust; + bool pre_ps_tdma_on; + bool cur_ps_tdma_on; + bool pre_bt_auto_report; + bool cur_bt_auto_report; + + /* sw mechanism */ + bool pre_rf_rx_lpf_shrink; + bool cur_rf_rx_lpf_shrink; + u32 bt_rf0x1e_backup; + bool pre_low_penalty_ra; + bool cur_low_penalty_ra; + bool pre_dac_swing_on; + u32 pre_dac_swing_lvl; + bool cur_dac_swing_on; + u32 cur_dac_swing_lvl; + bool pre_adc_back_off; + bool cur_adc_back_off; + bool pre_agc_table_en; + bool cur_agc_table_en; + u32 pre_val0x6c0; + u32 cur_val0x6c0; + u32 pre_val0x6c4; + u32 cur_val0x6c4; + u32 pre_val0x6c8; + u32 cur_val0x6c8; + u8 pre_val0x6cc; + u8 cur_val0x6cc; + bool limited_dig; + + u32 backup_arfr_cnt1; /* Auto Rate Fallback Retry cnt */ + u32 backup_arfr_cnt2; /* Auto Rate Fallback Retry cnt */ + u16 backup_retrylimit; + u8 backup_ampdu_maxtime; + + /* algorithm related */ + u8 pre_algorithm; + u8 cur_algorithm; + u8 bt_status; + u8 wifi_chnl_info[3]; + + u8 pre_sstype; + u8 cur_sstype; + + u32 prera_mask; + u32 curra_mask; + u8 curra_masktype; + u8 pre_arfrtype; + u8 cur_arfrtype; + u8 pre_retrylimit_type; + u8 cur_retrylimit_type; + u8 pre_ampdutime_type; + u8 cur_ampdutime_type; +}; + +struct coex_sta_8192e_2ant { + bool bt_link_exist; + bool sco_exist; + bool a2dp_exist; + bool hid_exist; + bool pan_exist; + + bool under_lps; + bool under_ips; + u32 high_priority_tx; + u32 high_priority_rx; + u32 low_priority_tx; + u32 low_priority_rx; + u8 bt_rssi; + u8 pre_bt_rssi_state; + u8 pre_wifi_rssi_state[4]; + bool c2h_bt_info_req_sent; + u8 bt_info_c2h[BT_INFO_SRC_8192E_2ANT_MAX][10]; + u32 bt_info_c2h_cnt[BT_INFO_SRC_8192E_2ANT_MAX]; + bool c2h_bt_inquiry_page; + u8 bt_retry_cnt; + u8 bt_info_ext; +}; + +/**************************************************************** + * The following is interface which will notify coex module. + ****************************************************************/ +void ex_halbtc8192e2ant_init_hwconfig(struct btc_coexist *btcoexist); +void ex_halbtc8192e2ant_init_coex_dm(struct btc_coexist *btcoexist); +void ex_halbtc8192e2ant_ips_notify(struct btc_coexist *btcoexist, u8 type); +void ex_halbtc8192e2ant_lps_notify(struct btc_coexist *btcoexist, u8 type); +void ex_halbtc8192e2ant_scan_notify(struct btc_coexist *btcoexist, u8 type); +void ex_halbtc8192e2ant_connect_notify(struct btc_coexist *btcoexist, u8 type); +void ex_halbtc8192e2ant_media_status_notify(struct btc_coexist *btcoexist, + u8 type); +void ex_halbtc8192e2ant_special_packet_notify(struct btc_coexist *btcoexist, + u8 type); +void ex_halbtc8192e2ant_bt_info_notify(struct btc_coexist *btcoexist, + u8 *tmpbuf, u8 length); +void ex_halbtc8192e2ant_stack_operation_notify(struct btc_coexist *btcoexist, + u8 type); +void ex_halbtc8192e2ant_halt_notify(struct btc_coexist *btcoexist); +void ex_halbtc8192e2ant_periodical(struct btc_coexist *btcoexist); +void ex_halbtc8192e2ant_display_coex_info(struct btc_coexist *btcoexist); diff --git a/drivers/staging/rtl8192ee/btcoexist/halbtc8723b1ant.c b/drivers/staging/rtl8192ee/btcoexist/halbtc8723b1ant.c new file mode 100644 index 000000000000..d561c54524b7 --- /dev/null +++ b/drivers/staging/rtl8192ee/btcoexist/halbtc8723b1ant.c @@ -0,0 +1,3146 @@ +/*************************************************************** + * Description: + * + * This file is for RTL8723B Co-exist mechanism + * + * History + * 2012/11/15 Cosa first check in. + * + ***************************************************************/ + +/*************************************************************** + * include files + ***************************************************************/ +#include "halbt_precomp.h" +/*************************************************************** + * Global variables, these are static variables + ***************************************************************/ +static struct coex_dm_8723b_1ant glcoex_dm_8723b_1ant; +static struct coex_dm_8723b_1ant *coex_dm = &glcoex_dm_8723b_1ant; +static struct coex_sta_8723b_1ant glcoex_sta_8723b_1ant; +static struct coex_sta_8723b_1ant *coex_sta = &glcoex_sta_8723b_1ant; + +static const char *const glb_infosrc8723b1ant[] = { + "BT Info[wifi fw]", + "BT Info[bt rsp]", + "BT Info[bt auto report]", +}; + +static u32 glcoex_ver_date_8723b_1ant = 20130918; +static u32 glcoex_ver_8723b_1ant = 0x47; + +/*************************************************************** + * local function proto type if needed + ***************************************************************/ +/*************************************************************** + * local function start with halbtc8723b1ant_ + ***************************************************************/ +static u8 halbtc8723b1ant_bt_rssi_state(u8 level_num, u8 rssi_thresh, + u8 rssi_thresh1) +{ + s32 bt_rssi = 0; + u8 rssi_state = coex_sta->pre_bt_rssi_state; + + bt_rssi = coex_sta->bt_rssi; + + if (level_num == 2) { + if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) || + (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW)) { + if (bt_rssi >= rssi_thresh + + BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT) { + rssi_state = BTC_RSSI_STATE_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state switch to High\n"); + } else { + rssi_state = BTC_RSSI_STATE_STAY_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state stay at Low\n"); + } + } else { + if (bt_rssi < rssi_thresh) { + rssi_state = BTC_RSSI_STATE_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state switch to Low\n"); + } else { + rssi_state = BTC_RSSI_STATE_STAY_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state stay at High\n"); + } + } + } else if (level_num == 3) { + if (rssi_thresh > rssi_thresh1) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi thresh error!!\n"); + return coex_sta->pre_bt_rssi_state; + } + + if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) || + (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW)) { + if (bt_rssi >= rssi_thresh + + BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT) { + rssi_state = BTC_RSSI_STATE_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state switch to Medium\n"); + } else { + rssi_state = BTC_RSSI_STATE_STAY_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state stay at Low\n"); + } + } else if ((coex_sta->pre_bt_rssi_state == + BTC_RSSI_STATE_MEDIUM) || + (coex_sta->pre_bt_rssi_state == + BTC_RSSI_STATE_STAY_MEDIUM)) { + if (bt_rssi >= rssi_thresh1 + + BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT) { + rssi_state = BTC_RSSI_STATE_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state switch to High\n"); + } else if (bt_rssi < rssi_thresh) { + rssi_state = BTC_RSSI_STATE_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state switch to Low\n"); + } else { + rssi_state = BTC_RSSI_STATE_STAY_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state stay at Medium\n"); + } + } else { + if (bt_rssi < rssi_thresh1) { + rssi_state = BTC_RSSI_STATE_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state switch to Medium\n"); + } else { + rssi_state = BTC_RSSI_STATE_STAY_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state stay at High\n"); + } + } + } + + coex_sta->pre_bt_rssi_state = rssi_state; + + return rssi_state; +} + +static u8 halbtc8723b1ant_wifi_rssi_state(struct btc_coexist *btcoexist, + u8 index, u8 level_num, + u8 rssi_thresh, u8 rssi_thresh1) +{ + s32 wifi_rssi = 0; + u8 wifi_rssi_state = coex_sta->pre_wifi_rssi_state[index]; + + btcoexist->btc_get(btcoexist, + BTC_GET_S4_WIFI_RSSI, &wifi_rssi); + + if (level_num == 2) { + if ((coex_sta->pre_wifi_rssi_state[index] == + BTC_RSSI_STATE_LOW) || + (coex_sta->pre_wifi_rssi_state[index] == + BTC_RSSI_STATE_STAY_LOW)) { + if (wifi_rssi >= rssi_thresh + + BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT) { + wifi_rssi_state = BTC_RSSI_STATE_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state switch to High\n"); + } else { + wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state stay at Low\n"); + } + } else { + if (wifi_rssi < rssi_thresh) { + wifi_rssi_state = BTC_RSSI_STATE_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state switch to Low\n"); + } else { + wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state stay at High\n"); + } + } + } else if (level_num == 3) { + if (rssi_thresh > rssi_thresh1) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI thresh error!!\n"); + return coex_sta->pre_wifi_rssi_state[index]; + } + + if ((coex_sta->pre_wifi_rssi_state[index] == + BTC_RSSI_STATE_LOW) || + (coex_sta->pre_wifi_rssi_state[index] == + BTC_RSSI_STATE_STAY_LOW)) { + if (wifi_rssi >= rssi_thresh + + BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT) { + wifi_rssi_state = BTC_RSSI_STATE_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state switch to Medium\n"); + } else { + wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state stay at Low\n"); + } + } else if ((coex_sta->pre_wifi_rssi_state[index] == + BTC_RSSI_STATE_MEDIUM) || + (coex_sta->pre_wifi_rssi_state[index] == + BTC_RSSI_STATE_STAY_MEDIUM)) { + if (wifi_rssi >= rssi_thresh1 + + BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT) { + wifi_rssi_state = BTC_RSSI_STATE_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state switch to High\n"); + } else if (wifi_rssi < rssi_thresh) { + wifi_rssi_state = BTC_RSSI_STATE_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state switch to Low\n"); + } else { + wifi_rssi_state = BTC_RSSI_STATE_STAY_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state stay at Medium\n"); + } + } else { + if (wifi_rssi < rssi_thresh1) { + wifi_rssi_state = BTC_RSSI_STATE_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state switch to Medium\n"); + } else { + wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state stay at High\n"); + } + } + } + + coex_sta->pre_wifi_rssi_state[index] = wifi_rssi_state; + + return wifi_rssi_state; +} + +static void halbtc8723b1ant_updatera_mask(struct btc_coexist *btcoexist, + bool force_exec, u32 dis_rate_mask) +{ + coex_dm->curra_mask = dis_rate_mask; + + if (force_exec || (coex_dm->prera_mask != coex_dm->curra_mask)) + btcoexist->btc_set(btcoexist, BTC_SET_ACT_UPDATE_ra_mask, + &coex_dm->curra_mask); + + coex_dm->prera_mask = coex_dm->curra_mask; +} + +static void auto_rate_fallback_retry(struct btc_coexist *btcoexist, + bool force_exec, u8 type) +{ + bool wifi_under_bmode = false; + + coex_dm->cur_arfr_type = type; + + if (force_exec || (coex_dm->pre_arfr_type != coex_dm->cur_arfr_type)) { + switch (coex_dm->cur_arfr_type) { + case 0: /* normal mode */ + btcoexist->btc_write_4byte(btcoexist, 0x430, + coex_dm->backup_arfr_cnt1); + btcoexist->btc_write_4byte(btcoexist, 0x434, + coex_dm->backup_arfr_cnt2); + break; + case 1: + btcoexist->btc_get(btcoexist, + BTC_GET_BL_WIFI_UNDER_B_MODE, + &wifi_under_bmode); + if (wifi_under_bmode) { + btcoexist->btc_write_4byte(btcoexist, + 0x430, 0x0); + btcoexist->btc_write_4byte(btcoexist, + 0x434, 0x01010101); + } else { + btcoexist->btc_write_4byte(btcoexist, + 0x430, 0x0); + btcoexist->btc_write_4byte(btcoexist, + 0x434, 0x04030201); + } + break; + default: + break; + } + } + + coex_dm->pre_arfr_type = coex_dm->cur_arfr_type; +} + +static void halbtc8723b1ant_retry_limit(struct btc_coexist *btcoexist, + bool force_exec, u8 type) +{ + coex_dm->cur_retry_limit_type = type; + + if (force_exec || (coex_dm->pre_retry_limit_type != + coex_dm->cur_retry_limit_type)) { + switch (coex_dm->cur_retry_limit_type) { + case 0: /* normal mode */ + btcoexist->btc_write_2byte(btcoexist, 0x42a, + coex_dm->backup_retry_limit); + break; + case 1: /* retry limit = 8 */ + btcoexist->btc_write_2byte(btcoexist, 0x42a, 0x0808); + break; + default: + break; + } + } + + coex_dm->pre_retry_limit_type = coex_dm->cur_retry_limit_type; +} + +static void halbtc8723b1ant_ampdu_maxtime(struct btc_coexist *btcoexist, + bool force_exec, u8 type) +{ + coex_dm->cur_ampdu_time_type = type; + + if (force_exec || (coex_dm->pre_ampdu_time_type != + coex_dm->cur_ampdu_time_type)) { + switch (coex_dm->cur_ampdu_time_type) { + case 0: /* normal mode */ + btcoexist->btc_write_1byte(btcoexist, 0x456, + coex_dm->backup_ampdu_max_time); + break; + case 1: /* AMPDU timw = 0x38 * 32us */ + btcoexist->btc_write_1byte(btcoexist, + 0x456, 0x38); + break; + default: + break; + } + } + + coex_dm->pre_ampdu_time_type = coex_dm->cur_ampdu_time_type; +} + +static void halbtc8723b1ant_limited_tx(struct btc_coexist *btcoexist, + bool force_exec, u8 ra_masktype, + u8 arfr_type, u8 retry_limit_type, + u8 ampdu_time_type) +{ + switch (ra_masktype) { + case 0: /* normal mode */ + halbtc8723b1ant_updatera_mask(btcoexist, force_exec, 0x0); + break; + case 1: /* disable cck 1/2 */ + halbtc8723b1ant_updatera_mask(btcoexist, force_exec, + 0x00000003); + break; + /* disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4*/ + case 2: + halbtc8723b1ant_updatera_mask(btcoexist, force_exec, + 0x0001f1f7); + break; + default: + break; + } + + auto_rate_fallback_retry(btcoexist, force_exec, arfr_type); + halbtc8723b1ant_retry_limit(btcoexist, force_exec, retry_limit_type); + halbtc8723b1ant_ampdu_maxtime(btcoexist, force_exec, ampdu_time_type); +} + +static void halbtc8723b1ant_limited_rx(struct btc_coexist *btcoexist, + bool force_exec, bool rej_ap_agg_pkt, + bool b_bt_ctrl_agg_buf_size, u8 agg_buf_size) +{ + bool reject_rx_agg = rej_ap_agg_pkt; + bool bt_ctrl_rx_agg_size = b_bt_ctrl_agg_buf_size; + u8 rxaggsize = agg_buf_size; + + /********************************************** + * Rx Aggregation related setting + **********************************************/ + btcoexist->btc_set(btcoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, + &reject_rx_agg); + /* decide BT control aggregation buf size or not */ + btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, + &bt_ctrl_rx_agg_size); + /* aggregation buf size, only work + *when BT control Rx aggregation size. */ + btcoexist->btc_set(btcoexist, BTC_SET_U1_AGG_BUF_SIZE, &rxaggsize); + /* real update aggregation setting */ + btcoexist->btc_set(btcoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL); +} + +static void halbtc8723b1ant_monitor_bt_ctr(struct btc_coexist *btcoexist) +{ + u32 reg_hp_txrx, reg_lp_txrx, u32tmp; + u32 reg_hp_tx = 0, reg_hp_rx = 0; + u32 reg_lp_tx = 0, reg_lp_rx = 0; + + reg_hp_txrx = 0x770; + reg_lp_txrx = 0x774; + + u32tmp = btcoexist->btc_read_4byte(btcoexist, reg_hp_txrx); + reg_hp_tx = u32tmp & MASKLWORD; + reg_hp_rx = (u32tmp & MASKHWORD) >> 16; + + u32tmp = btcoexist->btc_read_4byte(btcoexist, reg_lp_txrx); + reg_lp_tx = u32tmp & MASKLWORD; + reg_lp_rx = (u32tmp & MASKHWORD) >> 16; + + coex_sta->high_priority_tx = reg_hp_tx; + coex_sta->high_priority_rx = reg_hp_rx; + coex_sta->low_priority_tx = reg_lp_tx; + coex_sta->low_priority_rx = reg_lp_rx; + + /* reset counter */ + btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc); +} + +static void halbtc8723b1ant_query_bt_info(struct btc_coexist *btcoexist) +{ + u8 h2c_parameter[1] = {0}; + + coex_sta->c2h_bt_info_req_sent = true; + + h2c_parameter[0] |= BIT(0); /* trigger*/ + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], Query Bt Info, FW write 0x61 = 0x%x\n", + h2c_parameter[0]); + + btcoexist->btc_fill_h2c(btcoexist, 0x61, 1, h2c_parameter); +} + +static bool is_wifi_status_changed(struct btc_coexist *btcoexist) +{ + static bool pre_wifi_busy; + static bool pre_under_4way, pre_bt_hs_on; + bool wifi_busy = false, under_4way = false, bt_hs_on = false; + bool wifi_connected = false; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, + &wifi_connected); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, + &under_4way); + + if (wifi_connected) { + if (wifi_busy != pre_wifi_busy) { + pre_wifi_busy = wifi_busy; + return true; + } + if (under_4way != pre_under_4way) { + pre_under_4way = under_4way; + return true; + } + if (bt_hs_on != pre_bt_hs_on) { + pre_bt_hs_on = bt_hs_on; + return true; + } + } + + return false; +} + +static void halbtc8723b1ant_update_bt_link_info(struct btc_coexist *btcoexist) +{ + struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; + bool bt_hs_on = false; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); + + bt_link_info->bt_link_exist = coex_sta->bt_link_exist; + bt_link_info->sco_exist = coex_sta->sco_exist; + bt_link_info->a2dp_exist = coex_sta->a2dp_exist; + bt_link_info->pan_exist = coex_sta->pan_exist; + bt_link_info->hid_exist = coex_sta->hid_exist; + + /* work around for HS mode. */ + if (bt_hs_on) { + bt_link_info->pan_exist = true; + bt_link_info->bt_link_exist = true; + } + + /* check if Sco only */ + if (bt_link_info->sco_exist && !bt_link_info->a2dp_exist && + !bt_link_info->pan_exist && !bt_link_info->hid_exist) + bt_link_info->sco_only = true; + else + bt_link_info->sco_only = false; + + /* check if A2dp only */ + if (!bt_link_info->sco_exist && bt_link_info->a2dp_exist && + !bt_link_info->pan_exist && !bt_link_info->hid_exist) + bt_link_info->a2dp_only = true; + else + bt_link_info->a2dp_only = false; + + /* check if Pan only */ + if (!bt_link_info->sco_exist && !bt_link_info->a2dp_exist && + bt_link_info->pan_exist && !bt_link_info->hid_exist) + bt_link_info->pan_only = true; + else + bt_link_info->pan_only = false; + + /* check if Hid only */ + if (!bt_link_info->sco_exist && !bt_link_info->a2dp_exist && + !bt_link_info->pan_exist && bt_link_info->hid_exist) + bt_link_info->hid_only = true; + else + bt_link_info->hid_only = false; +} + +static u8 halbtc8723b1ant_action_algorithm(struct btc_coexist *btcoexist) +{ + struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; + bool bt_hs_on = false; + u8 algorithm = BT_8723B_1ANT_COEX_ALGO_UNDEFINED; + u8 numofdiffprofile = 0; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); + + if (!bt_link_info->bt_link_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], No BT link exists!!!\n"); + return algorithm; + } + + if (bt_link_info->sco_exist) + numofdiffprofile++; + if (bt_link_info->hid_exist) + numofdiffprofile++; + if (bt_link_info->pan_exist) + numofdiffprofile++; + if (bt_link_info->a2dp_exist) + numofdiffprofile++; + + if (numofdiffprofile == 1) { + if (bt_link_info->sco_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT Profile = SCO only\n"); + algorithm = BT_8723B_1ANT_COEX_ALGO_SCO; + } else { + if (bt_link_info->hid_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT Profile = HID only\n"); + algorithm = BT_8723B_1ANT_COEX_ALGO_HID; + } else if (bt_link_info->a2dp_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT Profile = A2DP only\n"); + algorithm = BT_8723B_1ANT_COEX_ALGO_A2DP; + } else if (bt_link_info->pan_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT Profile = PAN(HS) only\n"); + algorithm = + BT_8723B_1ANT_COEX_ALGO_PANHS; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT Profile = PAN(EDR) only\n"); + algorithm = + BT_8723B_1ANT_COEX_ALGO_PANEDR; + } + } + } + } else if (numofdiffprofile == 2) { + if (bt_link_info->sco_exist) { + if (bt_link_info->hid_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT Profile = SCO + HID\n"); + algorithm = BT_8723B_1ANT_COEX_ALGO_HID; + } else if (bt_link_info->a2dp_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT Profile = SCO + A2DP ==> SCO\n"); + algorithm = BT_8723B_1ANT_COEX_ALGO_SCO; + } else if (bt_link_info->pan_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT Profile = SCO + PAN(HS)\n"); + algorithm = BT_8723B_1ANT_COEX_ALGO_SCO; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT Profile = SCO + PAN(EDR)\n"); + algorithm = + BT_8723B_1ANT_COEX_ALGO_PANEDR_HID; + } + } + } else { + if (bt_link_info->hid_exist && + bt_link_info->a2dp_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT Profile = HID + A2DP\n"); + algorithm = BT_8723B_1ANT_COEX_ALGO_HID_A2DP; + } else if (bt_link_info->hid_exist && + bt_link_info->pan_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT Profile = HID + PAN(HS)\n"); + algorithm = + BT_8723B_1ANT_COEX_ALGO_HID_A2DP; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT Profile = HID + PAN(EDR)\n"); + algorithm = + BT_8723B_1ANT_COEX_ALGO_PANEDR_HID; + } + } else if (bt_link_info->pan_exist && + bt_link_info->a2dp_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT Profile = A2DP + PAN(HS)\n"); + algorithm = + BT_8723B_1ANT_COEX_ALGO_A2DP_PANHS; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT Profile = A2DP + PAN(EDR)\n"); + algorithm = + BT_8723B_1ANT_COEX_ALGO_PANEDR_A2DP; + } + } + } + } else if (numofdiffprofile == 3) { + if (bt_link_info->sco_exist) { + if (bt_link_info->hid_exist && + bt_link_info->a2dp_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT Profile = SCO + HID + A2DP ==> HID\n"); + algorithm = BT_8723B_1ANT_COEX_ALGO_HID; + } else if (bt_link_info->hid_exist && + bt_link_info->pan_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT Profile = SCO + HID + PAN(HS)\n"); + algorithm = + BT_8723B_1ANT_COEX_ALGO_HID_A2DP; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT Profile = SCO + HID + PAN(EDR)\n"); + algorithm = + BT_8723B_1ANT_COEX_ALGO_PANEDR_HID; + } + } else if (bt_link_info->pan_exist && + bt_link_info->a2dp_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT Profile = SCO + A2DP + PAN(HS)\n"); + algorithm = BT_8723B_1ANT_COEX_ALGO_SCO; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT Profile = SCO + A2DP + PAN(EDR) ==> HID\n"); + algorithm = + BT_8723B_1ANT_COEX_ALGO_PANEDR_HID; + } + } + } else { + if (bt_link_info->hid_exist && + bt_link_info->pan_exist && + bt_link_info->a2dp_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT Profile = HID + A2DP + PAN(HS)\n"); + algorithm = + BT_8723B_1ANT_COEX_ALGO_HID_A2DP; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT Profile = HID + A2DP + PAN(EDR)\n"); + algorithm = + BT_8723B_1ANT_COEX_ALGO_HID_A2DP_PANEDR; + } + } + } + } else if (numofdiffprofile >= 3) { + if (bt_link_info->sco_exist) { + if (bt_link_info->hid_exist && + bt_link_info->pan_exist && + bt_link_info->a2dp_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Error!!! BT Profile = SCO + HID + A2DP + PAN(HS)\n"); + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT Profile = SCO + HID + A2DP + PAN(EDR) ==>PAN(EDR)+HID\n"); + algorithm = + BT_8723B_1ANT_COEX_ALGO_PANEDR_HID; + } + } + } + } + + return algorithm; +} + +static void set_sw_penalty_tx_rate_adapt(struct btc_coexist *btcoexist, + bool low_penalty_ra) +{ + u8 h2c_parameter[6] = {0}; + + h2c_parameter[0] = 0x6; /* opCode, 0x6 = Retry_Penalty */ + + if (low_penalty_ra) { + h2c_parameter[1] |= BIT(0); + /*normal rate except MCS7/6/5, OFDM54/48/36 */ + h2c_parameter[2] = 0x00; + h2c_parameter[3] = 0xf7; /*MCS7 or OFDM54 */ + h2c_parameter[4] = 0xf8; /*MCS6 or OFDM48 */ + h2c_parameter[5] = 0xf9; /*MCS5 or OFDM36 */ + } + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], set WiFi Low-Penalty Retry: %s", + (low_penalty_ra ? "ON!!" : "OFF!!")); + + btcoexist->btc_fill_h2c(btcoexist, 0x69, 6, h2c_parameter); +} + +static void halbtc8723b1ant_low_penalty_ra(struct btc_coexist *btcoexist, + bool force_exec, bool low_penalty_ra) +{ + coex_dm->cur_low_penalty_ra = low_penalty_ra; + + if (!force_exec) { + if (coex_dm->pre_low_penalty_ra == coex_dm->cur_low_penalty_ra) + return; + } + set_sw_penalty_tx_rate_adapt(btcoexist, coex_dm->cur_low_penalty_ra); + + coex_dm->pre_low_penalty_ra = coex_dm->cur_low_penalty_ra; +} + +static void halbtc8723b1ant_set_coex_table(struct btc_coexist *btcoexist, + u32 val0x6c0, u32 val0x6c4, + u32 val0x6c8, u8 val0x6cc) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], set coex table, set 0x6c0 = 0x%x\n", val0x6c0); + btcoexist->btc_write_4byte(btcoexist, 0x6c0, val0x6c0); + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], set coex table, set 0x6c4 = 0x%x\n", val0x6c4); + btcoexist->btc_write_4byte(btcoexist, 0x6c4, val0x6c4); + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], set coex table, set 0x6c8 = 0x%x\n", val0x6c8); + btcoexist->btc_write_4byte(btcoexist, 0x6c8, val0x6c8); + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], set coex table, set 0x6cc = 0x%x\n", val0x6cc); + btcoexist->btc_write_1byte(btcoexist, 0x6cc, val0x6cc); +} + +static void halbtc8723b1ant_coex_table(struct btc_coexist *btcoexist, + bool force_exec, u32 val0x6c0, + u32 val0x6c4, u32 val0x6c8, + u8 val0x6cc) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, + "[BTCoex], %s write Coex Table 0x6c0 = 0x%x, 0x6c4 = 0x%x, 0x6cc = 0x%x\n", + (force_exec ? "force to" : ""), + val0x6c0, val0x6c4, val0x6cc); + coex_dm->cur_val0x6c0 = val0x6c0; + coex_dm->cur_val0x6c4 = val0x6c4; + coex_dm->cur_val0x6c8 = val0x6c8; + coex_dm->cur_val0x6cc = val0x6cc; + + if (!force_exec) { + if ((coex_dm->pre_val0x6c0 == coex_dm->cur_val0x6c0) && + (coex_dm->pre_val0x6c4 == coex_dm->cur_val0x6c4) && + (coex_dm->pre_val0x6c8 == coex_dm->cur_val0x6c8) && + (coex_dm->pre_val0x6cc == coex_dm->cur_val0x6cc)) + return; + } + halbtc8723b1ant_set_coex_table(btcoexist, val0x6c0, val0x6c4, + val0x6c8, val0x6cc); + + coex_dm->pre_val0x6c0 = coex_dm->cur_val0x6c0; + coex_dm->pre_val0x6c4 = coex_dm->cur_val0x6c4; + coex_dm->pre_val0x6c8 = coex_dm->cur_val0x6c8; + coex_dm->pre_val0x6cc = coex_dm->cur_val0x6cc; +} + +static void coex_table_with_type(struct btc_coexist *btcoexist, + bool force_exec, u8 type) +{ + switch (type) { + case 0: + halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x55555555, + 0x55555555, 0xffffff, 0x3); + break; + case 1: + halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x55555555, + 0x5a5a5a5a, 0xffffff, 0x3); + break; + case 2: + halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x5a5a5a5a, + 0x5a5a5a5a, 0xffffff, 0x3); + break; + case 3: + halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x55555555, + 0xaaaaaaaa, 0xffffff, 0x3); + break; + case 4: + halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x55555555, + 0x5aaa5aaa, 0xffffff, 0x3); + break; + case 5: + halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x5a5a5a5a, + 0xaaaa5a5a, 0xffffff, 0x3); + break; + case 6: + halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x55555555, + 0xaaaa5a5a, 0xffffff, 0x3); + break; + case 7: + halbtc8723b1ant_coex_table(btcoexist, force_exec, 0xaaaaaaaa, + 0xaaaaaaaa, 0xffffff, 0x3); + break; + default: + break; + } +} + +static void set_fw_ignore_wlan_act(struct btc_coexist *btcoexist, + bool enable) +{ + u8 h2c_parameter[1] = {0}; + + if (enable) + h2c_parameter[0] |= BIT(0); /* function enable */ + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63 = 0x%x\n", + h2c_parameter[0]); + + btcoexist->btc_fill_h2c(btcoexist, 0x63, 1, h2c_parameter); +} + +static void halbtc8723b1ant_ignore_wlan_act(struct btc_coexist *btcoexist, + bool force_exec, bool enable) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, + "[BTCoex], %s turn Ignore WlanAct %s\n", + (force_exec ? "force to" : ""), (enable ? "ON" : "OFF")); + coex_dm->cur_ignore_wlan_act = enable; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], bPreIgnoreWlanAct = %d, bCurIgnoreWlanAct = %d!!\n", + coex_dm->pre_ignore_wlan_act, + coex_dm->cur_ignore_wlan_act); + + if (coex_dm->pre_ignore_wlan_act == + coex_dm->cur_ignore_wlan_act) + return; + } + set_fw_ignore_wlan_act(btcoexist, enable); + + coex_dm->pre_ignore_wlan_act = coex_dm->cur_ignore_wlan_act; +} + +static void halbtc8723b1ant_set_fw_ps_tdma(struct btc_coexist *btcoexist, + u8 byte1, u8 byte2, u8 byte3, + u8 byte4, u8 byte5) +{ + u8 h2c_parameter[5] = {0}; + u8 real_byte1 = byte1, real_byte5 = byte5; + bool ap_enable = false; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, + &ap_enable); + + if (ap_enable) { + if ((byte1 & BIT(4)) && !(byte1 & BIT(5))) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], FW for 1Ant AP mode\n"); + real_byte1 &= ~BIT(4); + real_byte1 |= BIT(5); + + real_byte5 |= BIT(5); + real_byte5 &= ~BIT(6); + } + } + + h2c_parameter[0] = real_byte1; + h2c_parameter[1] = byte2; + h2c_parameter[2] = byte3; + h2c_parameter[3] = byte4; + h2c_parameter[4] = real_byte5; + + coex_dm->ps_tdma_para[0] = real_byte1; + coex_dm->ps_tdma_para[1] = byte2; + coex_dm->ps_tdma_para[2] = byte3; + coex_dm->ps_tdma_para[3] = byte4; + coex_dm->ps_tdma_para[4] = real_byte5; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], PS-TDMA H2C cmd = 0x%x%08x\n", + h2c_parameter[0], + h2c_parameter[1] << 24 | + h2c_parameter[2] << 16 | + h2c_parameter[3] << 8 | + h2c_parameter[4]); + + btcoexist->btc_fill_h2c(btcoexist, 0x60, 5, h2c_parameter); +} + +static void halbtc8723b1ant_set_lps_rpwm(struct btc_coexist *btcoexist, + u8 lps_val, u8 rpwm_val) +{ + u8 lps = lps_val; + u8 rpwm = rpwm_val; + + btcoexist->btc_set(btcoexist, BTC_SET_U1_LPS_VAL, &lps); + btcoexist->btc_set(btcoexist, BTC_SET_U1_RPWM_VAL, &rpwm); +} + +static void halbtc8723b1ant_lpsrpwm(struct btc_coexist *btcoexist, + bool force_exec, + u8 lps_val, u8 rpwm_val) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, + "[BTCoex], %s set lps/rpwm = 0x%x/0x%x\n", + (force_exec ? "force to" : ""), lps_val, rpwm_val); + coex_dm->cur_lps = lps_val; + coex_dm->cur_rpwm = rpwm_val; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], LPS-RxBeaconMode = 0x%x, LPS-RPWM = 0x%x!!\n", + coex_dm->cur_lps, coex_dm->cur_rpwm); + + if ((coex_dm->pre_lps == coex_dm->cur_lps) && + (coex_dm->pre_rpwm == coex_dm->cur_rpwm)) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], LPS-RPWM_Last = 0x%x, LPS-RPWM_Now = 0x%x!!\n", + coex_dm->pre_rpwm, coex_dm->cur_rpwm); + + return; + } + } + halbtc8723b1ant_set_lps_rpwm(btcoexist, lps_val, rpwm_val); + + coex_dm->pre_lps = coex_dm->cur_lps; + coex_dm->pre_rpwm = coex_dm->cur_rpwm; +} + +static void halbtc8723b1ant_sw_mechanism(struct btc_coexist *btcoexist, + bool low_penalty_ra) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, + "[BTCoex], SM[LpRA] = %d\n", low_penalty_ra); + + halbtc8723b1ant_low_penalty_ra(btcoexist, NORMAL_EXEC, low_penalty_ra); +} + +static void halbtc8723b1ant_setantpath(struct btc_coexist *btcoexist, + u8 ant_pos_type, bool init_hw_cfg, + bool wifi_off) +{ + struct btc_board_info *brd_info = &btcoexist->board_info; + u32 fw_ver = 0, u32tmp = 0; + bool pg_ext_switch = false; + bool use_ext_switch = false; + u8 h2c_parameter[2] = {0}; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_EXT_SWITCH, &pg_ext_switch); + /* [31:16] = fw ver, [15:0] = fw sub ver */ + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver); + + if ((fw_ver < 0xc0000) || pg_ext_switch) + use_ext_switch = true; + + if (init_hw_cfg) { + /*BT select s0/s1 is controlled by WiFi */ + btcoexist->btc_write_1byte_bitmask(btcoexist, 0x67, 0x20, 0x1); + + /*Force GNT_BT to Normal */ + btcoexist->btc_write_1byte_bitmask(btcoexist, 0x765, 0x18, 0x0); + } else if (wifi_off) { + /*Force GNT_BT to High */ + btcoexist->btc_write_1byte_bitmask(btcoexist, 0x765, 0x18, 0x3); + /*BT select s0/s1 is controlled by BT */ + btcoexist->btc_write_1byte_bitmask(btcoexist, 0x67, 0x20, 0x0); + + /* 0x4c[24:23] = 00, Set Antenna control by BT_RFE_CTRL + * BT Vendor 0xac = 0xf002 */ + u32tmp = btcoexist->btc_read_4byte(btcoexist, 0x4c); + u32tmp &= ~BIT(23); + u32tmp &= ~BIT(24); + btcoexist->btc_write_4byte(btcoexist, 0x4c, u32tmp); + } + + if (use_ext_switch) { + if (init_hw_cfg) { + /* 0x4c[23] = 0, 0x4c[24] = 1 Antenna ctrl by WL/BT */ + u32tmp = btcoexist->btc_read_4byte(btcoexist, 0x4c); + u32tmp &= ~BIT(23); + u32tmp |= BIT(24); + btcoexist->btc_write_4byte(btcoexist, 0x4c, u32tmp); + + if (brd_info->btdm_ant_pos == + BTC_ANTENNA_AT_MAIN_PORT) { + /* Main Ant to BT for IPS case 0x4c[23] = 1 */ + btcoexist->btc_write_1byte_bitmask(btcoexist, + 0x64, 0x1, + 0x1); + + /*tell firmware "no antenna inverse"*/ + h2c_parameter[0] = 0; + h2c_parameter[1] = 1; /*ext switch type*/ + btcoexist->btc_fill_h2c(btcoexist, 0x65, 2, + h2c_parameter); + } else { + /*Aux Ant to BT for IPS case 0x4c[23] = 1 */ + btcoexist->btc_write_1byte_bitmask(btcoexist, + 0x64, 0x1, + 0x0); + + /*tell firmware "antenna inverse"*/ + h2c_parameter[0] = 1; + h2c_parameter[1] = 1; /*ext switch type*/ + btcoexist->btc_fill_h2c(btcoexist, 0x65, 2, + h2c_parameter); + } + } + + /* fixed internal switch first*/ + /* fixed internal switch S1->WiFi, S0->BT*/ + if (brd_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) + btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0); + else/* fixed internal switch S0->WiFi, S1->BT*/ + btcoexist->btc_write_2byte(btcoexist, 0x948, 0x280); + + /* ext switch setting */ + switch (ant_pos_type) { + case BTC_ANT_PATH_WIFI: + if (brd_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) + btcoexist->btc_write_1byte_bitmask(btcoexist, + 0x92c, 0x3, + 0x1); + else + btcoexist->btc_write_1byte_bitmask(btcoexist, + 0x92c, 0x3, + 0x2); + break; + case BTC_ANT_PATH_BT: + if (brd_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) + btcoexist->btc_write_1byte_bitmask(btcoexist, + 0x92c, 0x3, + 0x2); + else + btcoexist->btc_write_1byte_bitmask(btcoexist, + 0x92c, 0x3, + 0x1); + break; + default: + case BTC_ANT_PATH_PTA: + if (brd_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) + btcoexist->btc_write_1byte_bitmask(btcoexist, + 0x92c, 0x3, + 0x1); + else + btcoexist->btc_write_1byte_bitmask(btcoexist, + 0x92c, 0x3, + 0x2); + break; + } + + } else { + if (init_hw_cfg) { + /* 0x4c[23] = 1, 0x4c[24] = 0 Antenna control by 0x64*/ + u32tmp = btcoexist->btc_read_4byte(btcoexist, 0x4c); + u32tmp |= BIT(23); + u32tmp &= ~BIT(24); + btcoexist->btc_write_4byte(btcoexist, 0x4c, u32tmp); + + if (brd_info->btdm_ant_pos == + BTC_ANTENNA_AT_MAIN_PORT) { + /*Main Ant to WiFi for IPS case 0x4c[23] = 1*/ + btcoexist->btc_write_1byte_bitmask(btcoexist, + 0x64, 0x1, + 0x0); + + /*tell firmware "no antenna inverse"*/ + h2c_parameter[0] = 0; + h2c_parameter[1] = 0; /*internal switch type*/ + btcoexist->btc_fill_h2c(btcoexist, 0x65, 2, + h2c_parameter); + } else { + /*Aux Ant to BT for IPS case 0x4c[23] = 1*/ + btcoexist->btc_write_1byte_bitmask(btcoexist, + 0x64, 0x1, + 0x1); + + /*tell firmware "antenna inverse"*/ + h2c_parameter[0] = 1; + h2c_parameter[1] = 0; /*internal switch type*/ + btcoexist->btc_fill_h2c(btcoexist, 0x65, 2, + h2c_parameter); + } + } + + /* fixed external switch first*/ + /*Main->WiFi, Aux->BT*/ + if (brd_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) + btcoexist->btc_write_1byte_bitmask(btcoexist, 0x92c, + 0x3, 0x1); + else/*Main->BT, Aux->WiFi */ + btcoexist->btc_write_1byte_bitmask(btcoexist, 0x92c, + 0x3, 0x2); + + /* internal switch setting*/ + switch (ant_pos_type) { + case BTC_ANT_PATH_WIFI: + if (brd_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) + btcoexist->btc_write_2byte(btcoexist, 0x948, + 0x0); + else + btcoexist->btc_write_2byte(btcoexist, 0x948, + 0x280); + break; + case BTC_ANT_PATH_BT: + if (brd_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) + btcoexist->btc_write_2byte(btcoexist, 0x948, + 0x280); + else + btcoexist->btc_write_2byte(btcoexist, 0x948, + 0x0); + break; + default: + case BTC_ANT_PATH_PTA: + if (brd_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) + btcoexist->btc_write_2byte(btcoexist, 0x948, + 0x200); + else + btcoexist->btc_write_2byte(btcoexist, 0x948, + 0x80); + break; + } + } +} + +static void halbtc8723b1ant_ps_tdma(struct btc_coexist *btcoexist, + bool force_exec, bool turn_on, u8 type) +{ + bool wifi_busy = false; + u8 rssi_adjust_val = 0; + + coex_dm->cur_ps_tdma_on = turn_on; + coex_dm->cur_ps_tdma = type; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); + + if (!force_exec) { + if (coex_dm->cur_ps_tdma_on) + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], ******** TDMA(on, %d) *********\n", + coex_dm->cur_ps_tdma); + else + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], ******** TDMA(off, %d) ********\n", + coex_dm->cur_ps_tdma); + + if ((coex_dm->pre_ps_tdma_on == coex_dm->cur_ps_tdma_on) && + (coex_dm->pre_ps_tdma == coex_dm->cur_ps_tdma)) + return; + } + if (turn_on) { + switch (type) { + default: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x1a, + 0x1a, 0x0, 0x50); + break; + case 1: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x3a, + 0x03, 0x10, 0x50); + + rssi_adjust_val = 11; + break; + case 2: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x2b, + 0x03, 0x10, 0x50); + rssi_adjust_val = 14; + break; + case 3: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x1d, + 0x1d, 0x0, 0x52); + break; + case 4: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x93, 0x15, + 0x3, 0x14, 0x0); + rssi_adjust_val = 17; + break; + case 5: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x61, 0x15, + 0x3, 0x11, 0x10); + break; + case 6: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x61, 0x20, + 0x3, 0x11, 0x13); + break; + case 7: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x13, 0xc, + 0x5, 0x0, 0x0); + break; + case 8: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x93, 0x25, + 0x3, 0x10, 0x0); + break; + case 9: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x21, + 0x3, 0x10, 0x50); + rssi_adjust_val = 18; + break; + case 10: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x13, 0xa, + 0xa, 0x0, 0x40); + break; + case 11: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x15, + 0x03, 0x10, 0x50); + rssi_adjust_val = 20; + break; + case 12: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x0a, + 0x0a, 0x0, 0x50); + break; + case 13: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x15, + 0x15, 0x0, 0x50); + break; + case 14: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x21, + 0x3, 0x10, 0x52); + break; + case 15: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x13, 0xa, + 0x3, 0x8, 0x0); + break; + case 16: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x93, 0x15, + 0x3, 0x10, 0x0); + rssi_adjust_val = 18; + break; + case 18: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x93, 0x25, + 0x3, 0x10, 0x0); + rssi_adjust_val = 14; + break; + case 20: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x61, 0x35, + 0x03, 0x11, 0x10); + break; + case 21: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x61, 0x25, + 0x03, 0x11, 0x11); + break; + case 22: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x61, 0x25, + 0x03, 0x11, 0x10); + break; + case 23: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x25, + 0x3, 0x31, 0x18); + rssi_adjust_val = 22; + break; + case 24: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x15, + 0x3, 0x31, 0x18); + rssi_adjust_val = 22; + break; + case 25: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xe3, 0xa, + 0x3, 0x31, 0x18); + rssi_adjust_val = 22; + break; + case 26: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xe3, 0xa, + 0x3, 0x31, 0x18); + rssi_adjust_val = 22; + break; + case 27: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x25, + 0x3, 0x31, 0x98); + rssi_adjust_val = 22; + break; + case 28: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x69, 0x25, + 0x3, 0x31, 0x0); + break; + case 29: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xab, 0x1a, + 0x1a, 0x1, 0x10); + break; + case 30: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x14, + 0x3, 0x10, 0x50); + break; + case 31: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xd3, 0x1a, + 0x1a, 0, 0x58); + break; + case 32: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x61, 0xa, + 0x3, 0x10, 0x0); + break; + case 33: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xa3, 0x25, + 0x3, 0x30, 0x90); + break; + case 34: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x53, 0x1a, + 0x1a, 0x0, 0x10); + break; + case 35: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x63, 0x1a, + 0x1a, 0x0, 0x10); + break; + case 36: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xd3, 0x12, + 0x3, 0x14, 0x50); + break; + /* SoftAP only with no sta associated, BT disable , + * TDMA mode for power saving + * here softap mode screen off will cost 70-80mA for phone */ + case 40: + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x23, 0x18, + 0x00, 0x10, 0x24); + break; + } + } else { + switch (type) { + case 8: /*PTA Control */ + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x8, 0x0, + 0x0, 0x0, 0x0); + halbtc8723b1ant_setantpath(btcoexist, BTC_ANT_PATH_PTA, + false, false); + break; + case 0: + default: /*Software control, Antenna at BT side */ + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x0, 0x0, + 0x0, 0x0, 0x0); + halbtc8723b1ant_setantpath(btcoexist, BTC_ANT_PATH_BT, + false, false); + break; + case 9: /*Software control, Antenna at WiFi side */ + halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x0, 0x0, + 0x0, 0x0, 0x0); + halbtc8723b1ant_setantpath(btcoexist, BTC_ANT_PATH_WIFI, + false, false); + break; + } + } + rssi_adjust_val = 0; + btcoexist->btc_set(btcoexist, + BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE, + &rssi_adjust_val); + + /* update pre state */ + coex_dm->pre_ps_tdma_on = coex_dm->cur_ps_tdma_on; + coex_dm->pre_ps_tdma = coex_dm->cur_ps_tdma; +} + +static bool halbtc8723b1ant_is_common_action(struct btc_coexist *btcoexist) +{ + bool commom = false, wifi_connected = false; + bool wifi_busy = false; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, + &wifi_connected); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); + + if (!wifi_connected && + BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == coex_dm->bt_status) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Wifi non connected-idle + BT non connected-idle!!\n"); + halbtc8723b1ant_sw_mechanism(btcoexist, false); + commom = true; + } else if (wifi_connected && + (BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == + coex_dm->bt_status)) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Wifi connected + BT non connected-idle!!\n"); + halbtc8723b1ant_sw_mechanism(btcoexist, false); + commom = true; + } else if (!wifi_connected && + (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == + coex_dm->bt_status)) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Wifi non connected-idle + BT connected-idle!!\n"); + halbtc8723b1ant_sw_mechanism(btcoexist, false); + commom = true; + } else if (wifi_connected && + (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == + coex_dm->bt_status)) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Wifi connected + BT connected-idle!!\n"); + halbtc8723b1ant_sw_mechanism(btcoexist, false); + commom = true; + } else if (!wifi_connected && + (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE != + coex_dm->bt_status)) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + ("[BTCoex], Wifi non connected-idle + BT Busy!!\n")); + halbtc8723b1ant_sw_mechanism(btcoexist, false); + commom = true; + } else { + if (wifi_busy) + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Wifi Connected-Busy + BT Busy!!\n"); + else + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Wifi Connected-Idle + BT Busy!!\n"); + + commom = false; + } + + return commom; +} + +static void tdma_duration_adjust_for_acl(struct btc_coexist *btcoexist, + u8 wifi_status) +{ + static s32 up, dn, m, n, wait_count; + /* 0: no change, +1: increase WiFi duration, + * -1: decrease WiFi duration */ + s32 result; + u8 retry_count = 0, bt_info_ext; + bool wifi_busy = false; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, + "[BTCoex], TdmaDurationAdjustForAcl()\n"); + + if (BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY == wifi_status) + wifi_busy = true; + else + wifi_busy = false; + + if ((BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == + wifi_status) || + (BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN == wifi_status) || + (BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT == wifi_status)) { + if (coex_dm->cur_ps_tdma != 1 && coex_dm->cur_ps_tdma != 2 && + coex_dm->cur_ps_tdma != 3 && coex_dm->cur_ps_tdma != 9) { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, + true, 9); + coex_dm->ps_tdma_du_adj_type = 9; + + up = 0; + dn = 0; + m = 1; + n = 3; + result = 0; + wait_count = 0; + } + return; + } + + if (!coex_dm->auto_tdma_adjust) { + coex_dm->auto_tdma_adjust = true; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], first run TdmaDurationAdjust()!!\n"); + + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 2); + coex_dm->ps_tdma_du_adj_type = 2; + + up = 0; + dn = 0; + m = 1; + n = 3; + result = 0; + wait_count = 0; + } else { + /*accquire the BT TRx retry count from BT_Info byte2 */ + retry_count = coex_sta->bt_retry_cnt; + bt_info_ext = coex_sta->bt_info_ext; + result = 0; + wait_count++; + /* no retry in the last 2-second duration */ + if (retry_count == 0) { + up++; + dn--; + + if (dn <= 0) + dn = 0; + + if (up >= n) { + wait_count = 0; + n = 3; + up = 0; + dn = 0; + result = 1; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_TRACE_FW_DETAIL, + "[BTCoex], Increase wifi duration!!\n"); + } + } else if (retry_count <= 3) { + up--; + dn++; + + if (up <= 0) + up = 0; + + if (dn == 2) { + if (wait_count <= 2) + m++; + else + m = 1; + + if (m >= 20) + m = 20; + + n = 3 * m; + up = 0; + dn = 0; + wait_count = 0; + result = -1; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_TRACE_FW_DETAIL, + "[BTCoex], Decrease wifi duration for retryCounter<3!!\n"); + } + } else { + if (wait_count == 1) + m++; + else + m = 1; + + if (m >= 20) + m = 20; + + n = 3 * m; + up = 0; + dn = 0; + wait_count = 0; + result = -1; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], Decrease wifi duration for retryCounter>3!!\n"); + } + + if (result == -1) { + if ((BT_INFO_8723B_1ANT_A2DP_BASIC_RATE(bt_info_ext)) && + ((coex_dm->cur_ps_tdma == 1) || + (coex_dm->cur_ps_tdma == 2))) { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, + true, 9); + coex_dm->ps_tdma_du_adj_type = 9; + } else if (coex_dm->cur_ps_tdma == 1) { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, + true, 2); + coex_dm->ps_tdma_du_adj_type = 2; + } else if (coex_dm->cur_ps_tdma == 2) { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, + true, 9); + coex_dm->ps_tdma_du_adj_type = 9; + } else if (coex_dm->cur_ps_tdma == 9) { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } + } else if (result == 1) { + if ((BT_INFO_8723B_1ANT_A2DP_BASIC_RATE(bt_info_ext)) && + ((coex_dm->cur_ps_tdma == 1) || + (coex_dm->cur_ps_tdma == 2))) { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, + true, 9); + coex_dm->ps_tdma_du_adj_type = 9; + } else if (coex_dm->cur_ps_tdma == 11) { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, + true, 9); + coex_dm->ps_tdma_du_adj_type = 9; + } else if (coex_dm->cur_ps_tdma == 9) { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, + true, 2); + coex_dm->ps_tdma_du_adj_type = 2; + } else if (coex_dm->cur_ps_tdma == 2) { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, + true, 1); + coex_dm->ps_tdma_du_adj_type = 1; + } + } else { /*no change */ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex],********* TDMA(on, %d) ********\n", + coex_dm->cur_ps_tdma); + } + + if (coex_dm->cur_ps_tdma != 1 && coex_dm->cur_ps_tdma != 2 && + coex_dm->cur_ps_tdma != 9 && coex_dm->cur_ps_tdma != 11) { + /* recover to previous adjust type */ + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, + coex_dm->ps_tdma_du_adj_type); + } + } +} + +static void pstdmacheckforpowersavestate(struct btc_coexist *btcoexist, + bool new_ps_state) +{ + u8 lps_mode = 0x0; + + btcoexist->btc_get(btcoexist, BTC_GET_U1_LPS_MODE, &lps_mode); + + if (lps_mode) { /* already under LPS state */ + if (new_ps_state) { + /* keep state under LPS, do nothing. */ + } else { + /* will leave LPS state, turn off psTdma first */ + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, + false, 0); + } + } else { /* NO PS state */ + if (new_ps_state) { + /* will enter LPS state, turn off psTdma first */ + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, + false, 0); + } else { + /* keep state under NO PS state, do nothing. */ + } + } +} + +static void halbtc8723b1ant_power_save_state(struct btc_coexist *btcoexist, + u8 ps_type, u8 lps_val, + u8 rpwm_val) +{ + bool low_pwr_disable = false; + + switch (ps_type) { + case BTC_PS_WIFI_NATIVE: + /* recover to original 32k low power setting */ + low_pwr_disable = false; + btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, + &low_pwr_disable); + btcoexist->btc_set(btcoexist, BTC_SET_ACT_NORMAL_LPS, NULL); + break; + case BTC_PS_LPS_ON: + pstdmacheckforpowersavestate(btcoexist, true); + halbtc8723b1ant_lpsrpwm(btcoexist, NORMAL_EXEC, lps_val, + rpwm_val); + /* when coex force to enter LPS, do not enter 32k low power. */ + low_pwr_disable = true; + btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, + &low_pwr_disable); + /* power save must executed before psTdma. */ + btcoexist->btc_set(btcoexist, BTC_SET_ACT_ENTER_LPS, NULL); + break; + case BTC_PS_LPS_OFF: + pstdmacheckforpowersavestate(btcoexist, false); + btcoexist->btc_set(btcoexist, BTC_SET_ACT_LEAVE_LPS, NULL); + break; + default: + break; + } +} + +/*************************************************** + * + * Software Coex Mechanism start + * + ***************************************************/ +/* SCO only or SCO+PAN(HS) */ +static void halbtc8723b1ant_action_sco(struct btc_coexist *btcoexist) +{ + halbtc8723b1ant_sw_mechanism(btcoexist, true); +} + +static void halbtc8723b1ant_action_hid(struct btc_coexist *btcoexist) +{ + halbtc8723b1ant_sw_mechanism(btcoexist, true); +} + +/*A2DP only / PAN(EDR) only/ A2DP+PAN(HS) */ +static void halbtc8723b1ant_action_a2dp(struct btc_coexist *btcoexist) +{ + halbtc8723b1ant_sw_mechanism(btcoexist, false); +} + +static void halbtc8723b1ant_action_a2dp_pan_hs(struct btc_coexist *btcoexist) +{ + halbtc8723b1ant_sw_mechanism(btcoexist, false); +} + +static void halbtc8723b1ant_action_pan_edr(struct btc_coexist *btcoexist) +{ + halbtc8723b1ant_sw_mechanism(btcoexist, false); +} + +/* PAN(HS) only */ +static void halbtc8723b1ant_action_pan_hs(struct btc_coexist *btcoexist) +{ + halbtc8723b1ant_sw_mechanism(btcoexist, false); +} + +/*PAN(EDR)+A2DP */ +static void halbtc8723b1ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist) +{ + halbtc8723b1ant_sw_mechanism(btcoexist, false); +} + +static void halbtc8723b1ant_action_pan_edr_hid(struct btc_coexist *btcoexist) +{ + halbtc8723b1ant_sw_mechanism(btcoexist, true); +} + +/* HID+A2DP+PAN(EDR) */ +static void action_hid_a2dp_pan_edr(struct btc_coexist *btcoexist) +{ + halbtc8723b1ant_sw_mechanism(btcoexist, true); +} + +static void halbtc8723b1ant_action_hid_a2dp(struct btc_coexist *btcoexist) +{ + halbtc8723b1ant_sw_mechanism(btcoexist, true); +} + +/***************************************************** + * + * Non-Software Coex Mechanism start + * + *****************************************************/ +static void halbtc8723b1ant_action_wifi_multiport(struct btc_coexist *btcoexist) +{ + halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, + 0x0, 0x0); + + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8); + coex_table_with_type(btcoexist, NORMAL_EXEC, 2); +} + +static void halbtc8723b1ant_action_hs(struct btc_coexist *btcoexist) +{ + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5); + coex_table_with_type(btcoexist, NORMAL_EXEC, 2); +} + +static void halbtc8723b1ant_action_bt_inquiry(struct btc_coexist *btcoexist) +{ + struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; + bool wifi_connected = false, ap_enable = false; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, + &ap_enable); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, + &wifi_connected); + + if (!wifi_connected) { + halbtc8723b1ant_power_save_state(btcoexist, + BTC_PS_WIFI_NATIVE, 0x0, 0x0); + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8); + coex_table_with_type(btcoexist, NORMAL_EXEC, 2); + } else if (bt_link_info->sco_exist || bt_link_info->hid_only) { + /* SCO/HID-only busy */ + halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, + 0x0, 0x0); + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 32); + coex_table_with_type(btcoexist, NORMAL_EXEC, 1); + } else { + if (ap_enable) + halbtc8723b1ant_power_save_state(btcoexist, + BTC_PS_WIFI_NATIVE, + 0x0, 0x0); + else + halbtc8723b1ant_power_save_state(btcoexist, + BTC_PS_LPS_ON, + 0x50, 0x4); + + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 30); + coex_table_with_type(btcoexist, NORMAL_EXEC, 1); + } +} + +static void action_bt_sco_hid_only_busy(struct btc_coexist *btcoexist, + u8 wifi_status) +{ + struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; + bool wifi_connected = false; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, + &wifi_connected); + + /* tdma and coex table */ + + if (bt_link_info->sco_exist) { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5); + coex_table_with_type(btcoexist, NORMAL_EXEC, 2); + } else { /* HID */ + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 6); + coex_table_with_type(btcoexist, NORMAL_EXEC, 5); + } +} + +static void halbtc8723b1ant_action_wifi_connected_bt_acl_busy( + struct btc_coexist *btcoexist, + u8 wifi_status) +{ + struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; + u8 rssi_state; + + rssi_state = halbtc8723b1ant_bt_rssi_state(2, 28, 0); + + if (bt_link_info->hid_only) { /*HID */ + action_bt_sco_hid_only_busy(btcoexist, wifi_status); + coex_dm->auto_tdma_adjust = false; + return; + } else if (bt_link_info->a2dp_only) { /*A2DP */ + if (BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE == wifi_status) { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, + 8); + coex_table_with_type(btcoexist, NORMAL_EXEC, 2); + coex_dm->auto_tdma_adjust = false; + } else if ((rssi_state == BTC_RSSI_STATE_HIGH) || + (rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + tdma_duration_adjust_for_acl(btcoexist, wifi_status); + coex_table_with_type(btcoexist, NORMAL_EXEC, 1); + } else { /*for low BT RSSI */ + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, + true, 11); + coex_table_with_type(btcoexist, NORMAL_EXEC, 1); + coex_dm->auto_tdma_adjust = false; + } + } else if (bt_link_info->hid_exist && + bt_link_info->a2dp_exist) { /*HID+A2DP */ + if ((rssi_state == BTC_RSSI_STATE_HIGH) || + (rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, + true, 14); + coex_dm->auto_tdma_adjust = false; + } else { /*for low BT RSSI*/ + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, + true, 14); + coex_dm->auto_tdma_adjust = false; + } + + coex_table_with_type(btcoexist, NORMAL_EXEC, 6); + /*PAN(OPP, FTP), HID+PAN(OPP, FTP) */ + } else if (bt_link_info->pan_only || + (bt_link_info->hid_exist && bt_link_info->pan_exist)) { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 3); + coex_table_with_type(btcoexist, NORMAL_EXEC, 6); + coex_dm->auto_tdma_adjust = false; + /*A2DP+PAN(OPP, FTP), HID+A2DP+PAN(OPP, FTP)*/ + } else if ((bt_link_info->a2dp_exist && bt_link_info->pan_exist) || + (bt_link_info->hid_exist && bt_link_info->a2dp_exist && + bt_link_info->pan_exist)) { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 13); + coex_table_with_type(btcoexist, NORMAL_EXEC, 1); + coex_dm->auto_tdma_adjust = false; + } else { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 11); + coex_table_with_type(btcoexist, NORMAL_EXEC, 1); + coex_dm->auto_tdma_adjust = false; + } +} + +static void action_wifi_not_connected(struct btc_coexist *btcoexist) +{ + /* power save state */ + halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, + 0x0, 0x0); + + /* tdma and coex table */ + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8); + coex_table_with_type(btcoexist, NORMAL_EXEC, 0); +} + +static void action_wifi_not_connected_scan(struct btc_coexist *btcoexist) +{ + struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; + halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, + 0x0, 0x0); + + /* tdma and coex table */ + if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) { + if (bt_link_info->a2dp_exist && bt_link_info->pan_exist) { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, + true, 22); + coex_table_with_type(btcoexist, NORMAL_EXEC, 1); + } else if (bt_link_info->pan_only) { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, + true, 20); + coex_table_with_type(btcoexist, NORMAL_EXEC, 2); + } else { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, + true, 20); + coex_table_with_type(btcoexist, NORMAL_EXEC, 1); + } + } else if ((BT_8723B_1ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) || + (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == + coex_dm->bt_status)) { + action_bt_sco_hid_only_busy(btcoexist, + BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN); + } else { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8); + coex_table_with_type(btcoexist, NORMAL_EXEC, 2); + } +} + +static void action_wifi_not_connected_asso_auth(struct btc_coexist *btcoexist) +{ + struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; + + halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, + 0x0, 0x0); + + if ((BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == coex_dm->bt_status) || + (bt_link_info->sco_exist) || (bt_link_info->hid_only) || + (bt_link_info->a2dp_only) || (bt_link_info->pan_only)) { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8); + coex_table_with_type(btcoexist, NORMAL_EXEC, 7); + } else { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20); + coex_table_with_type(btcoexist, NORMAL_EXEC, 1); + } +} + +static void action_wifi_connected_scan(struct btc_coexist *btcoexist) +{ + struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; + + halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, + 0x0, 0x0); + + /* tdma and coex table */ + if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) { + if (bt_link_info->a2dp_exist && bt_link_info->pan_exist) { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, + true, 22); + coex_table_with_type(btcoexist, NORMAL_EXEC, 1); + } else if (bt_link_info->pan_only) { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, + true, 20); + coex_table_with_type(btcoexist, NORMAL_EXEC, 2); + } else { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, + true, 20); + coex_table_with_type(btcoexist, NORMAL_EXEC, 1); + } + } else if ((BT_8723B_1ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) || + (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == + coex_dm->bt_status)) { + action_bt_sco_hid_only_busy(btcoexist, + BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN); + } else { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8); + coex_table_with_type(btcoexist, NORMAL_EXEC, 2); + } +} + +static void action_wifi_connected_special_packet(struct btc_coexist *btcoexist) +{ + bool hs_connecting = false; + struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_CONNECTING, &hs_connecting); + + halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, + 0x0, 0x0); + + /* tdma and coex table */ + if ((BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == coex_dm->bt_status) || + (bt_link_info->sco_exist) || (bt_link_info->hid_only) || + (bt_link_info->a2dp_only) || (bt_link_info->pan_only)) { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8); + coex_table_with_type(btcoexist, NORMAL_EXEC, 7); + } else { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20); + coex_table_with_type(btcoexist, NORMAL_EXEC, 1); + } +} + +static void halbtc8723b1ant_action_wifi_connected(struct btc_coexist *btcoexist) +{ + bool wifi_busy = false; + bool scan = false, link = false, roam = false; + bool under_4way = false, ap_enable = false; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], CoexForWifiConnect() ===>\n"); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, + &under_4way); + if (under_4way) { + action_wifi_connected_special_packet(btcoexist); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], CoexForWifiConnect(), return for wifi is under 4way<===\n"); + return; + } + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam); + + if (scan || link || roam) { + if (scan) + action_wifi_connected_scan(btcoexist); + else + action_wifi_connected_special_packet(btcoexist); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], CoexForWifiConnect(), return for wifi is under scan<===\n"); + return; + } + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, + &ap_enable); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); + /* power save state */ + if (!ap_enable && + BT_8723B_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status && + !btcoexist->bt_link_info.hid_only) { + if (!wifi_busy && btcoexist->bt_link_info.a2dp_only) + halbtc8723b1ant_power_save_state(btcoexist, + BTC_PS_WIFI_NATIVE, + 0x0, 0x0); + else + halbtc8723b1ant_power_save_state(btcoexist, + BTC_PS_LPS_ON, + 0x50, 0x4); + } else { + halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, + 0x0, 0x0); + } + /* tdma and coex table */ + if (!wifi_busy) { + if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) { + halbtc8723b1ant_action_wifi_connected_bt_acl_busy(btcoexist, + BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE); + } else if ((BT_8723B_1ANT_BT_STATUS_SCO_BUSY == + coex_dm->bt_status) || + (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == + coex_dm->bt_status)) { + action_bt_sco_hid_only_busy(btcoexist, + BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE); + } else { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, + false, 8); + coex_table_with_type(btcoexist, NORMAL_EXEC, 2); + } + } else { + if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) { + halbtc8723b1ant_action_wifi_connected_bt_acl_busy(btcoexist, + BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY); + } else if ((BT_8723B_1ANT_BT_STATUS_SCO_BUSY == + coex_dm->bt_status) || + (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == + coex_dm->bt_status)) { + action_bt_sco_hid_only_busy(btcoexist, + BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY); + } else { + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8); + coex_table_with_type(btcoexist, NORMAL_EXEC, 2); + } + } +} + +static void run_sw_coexist_mechanism(struct btc_coexist *btcoexist) +{ + u8 algorithm = 0; + + algorithm = halbtc8723b1ant_action_algorithm(btcoexist); + coex_dm->cur_algorithm = algorithm; + + if (!halbtc8723b1ant_is_common_action(btcoexist)) { + switch (coex_dm->cur_algorithm) { + case BT_8723B_1ANT_COEX_ALGO_SCO: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action algorithm = SCO.\n"); + halbtc8723b1ant_action_sco(btcoexist); + break; + case BT_8723B_1ANT_COEX_ALGO_HID: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action algorithm = HID.\n"); + halbtc8723b1ant_action_hid(btcoexist); + break; + case BT_8723B_1ANT_COEX_ALGO_A2DP: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action algorithm = A2DP.\n"); + halbtc8723b1ant_action_a2dp(btcoexist); + break; + case BT_8723B_1ANT_COEX_ALGO_A2DP_PANHS: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action algorithm = A2DP+PAN(HS).\n"); + halbtc8723b1ant_action_a2dp_pan_hs(btcoexist); + break; + case BT_8723B_1ANT_COEX_ALGO_PANEDR: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action algorithm = PAN(EDR).\n"); + halbtc8723b1ant_action_pan_edr(btcoexist); + break; + case BT_8723B_1ANT_COEX_ALGO_PANHS: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action algorithm = HS mode.\n"); + halbtc8723b1ant_action_pan_hs(btcoexist); + break; + case BT_8723B_1ANT_COEX_ALGO_PANEDR_A2DP: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action algorithm = PAN+A2DP.\n"); + halbtc8723b1ant_action_pan_edr_a2dp(btcoexist); + break; + case BT_8723B_1ANT_COEX_ALGO_PANEDR_HID: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action algorithm = PAN(EDR)+HID.\n"); + halbtc8723b1ant_action_pan_edr_hid(btcoexist); + break; + case BT_8723B_1ANT_COEX_ALGO_HID_A2DP_PANEDR: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action algorithm = HID+A2DP+PAN.\n"); + action_hid_a2dp_pan_edr(btcoexist); + break; + case BT_8723B_1ANT_COEX_ALGO_HID_A2DP: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action algorithm = HID+A2DP.\n"); + halbtc8723b1ant_action_hid_a2dp(btcoexist); + break; + default: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action algorithm = coexist All Off!!\n"); + break; + } + coex_dm->pre_algorithm = coex_dm->cur_algorithm; + } +} + +static void halbtc8723b1ant_run_coexist_mechanism(struct btc_coexist *btcoexist) +{ + struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; + bool wifi_connected = false, bt_hs_on = false; + bool increase_scan_dev_num = false; + bool b_bt_ctrl_agg_buf_size = false; + u8 agg_buf_size = 5; + u8 wifi_rssi_state = BTC_RSSI_STATE_HIGH; + u32 wifi_link_status = 0; + u32 num_of_wifi_link = 0; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], RunCoexistMechanism() ===>\n"); + + if (btcoexist->manual_control) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n"); + return; + } + + if (btcoexist->stop_coex_dm) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], RunCoexistMechanism(), return for Stop Coex DM <===\n"); + return; + } + + if (coex_sta->under_ips) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], wifi is under IPS !!!\n"); + return; + } + + if ((BT_8723B_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) || + (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) || + (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == coex_dm->bt_status)) + increase_scan_dev_num = true; + + btcoexist->btc_set(btcoexist, BTC_SET_BL_INC_SCAN_DEV_NUM, + &increase_scan_dev_num); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, + &wifi_connected); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS, + &wifi_link_status); + num_of_wifi_link = wifi_link_status >> 16; + if (num_of_wifi_link >= 2) { + halbtc8723b1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0); + halbtc8723b1ant_limited_rx(btcoexist, NORMAL_EXEC, false, + b_bt_ctrl_agg_buf_size, + agg_buf_size); + halbtc8723b1ant_action_wifi_multiport(btcoexist); + return; + } + + if (!bt_link_info->sco_exist && !bt_link_info->hid_exist) { + halbtc8723b1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0); + } else { + if (wifi_connected) { + wifi_rssi_state = + halbtc8723b1ant_wifi_rssi_state(btcoexist, + 1, 2, 30, 0); + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8723b1ant_limited_tx(btcoexist, + NORMAL_EXEC, + 1, 1, 1, 1); + } else { + halbtc8723b1ant_limited_tx(btcoexist, + NORMAL_EXEC, + 1, 1, 1, 1); + } + } else { + halbtc8723b1ant_limited_tx(btcoexist, NORMAL_EXEC, + 0, 0, 0, 0); + } + } + + if (bt_link_info->sco_exist) { + b_bt_ctrl_agg_buf_size = true; + agg_buf_size = 0x3; + } else if (bt_link_info->hid_exist) { + b_bt_ctrl_agg_buf_size = true; + agg_buf_size = 0x5; + } else if (bt_link_info->a2dp_exist || bt_link_info->pan_exist) { + b_bt_ctrl_agg_buf_size = true; + agg_buf_size = 0x8; + } + halbtc8723b1ant_limited_rx(btcoexist, NORMAL_EXEC, false, + b_bt_ctrl_agg_buf_size, agg_buf_size); + + run_sw_coexist_mechanism(btcoexist); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); + + if (coex_sta->c2h_bt_inquiry_page) { + halbtc8723b1ant_action_bt_inquiry(btcoexist); + return; + } else if (bt_hs_on) { + halbtc8723b1ant_action_hs(btcoexist); + return; + } + + if (!wifi_connected) { + bool scan = false, link = false, roam = false; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], wifi is non connected-idle !!!\n"); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam); + + if (scan || link || roam) { + if (scan) + action_wifi_not_connected_scan(btcoexist); + else + action_wifi_not_connected_asso_auth(btcoexist); + } else { + action_wifi_not_connected(btcoexist); + } + } else { /* wifi LPS/Busy */ + halbtc8723b1ant_action_wifi_connected(btcoexist); + } +} + +static void halbtc8723b1ant_init_coex_dm(struct btc_coexist *btcoexist) +{ + /* sw all off */ + halbtc8723b1ant_sw_mechanism(btcoexist, false); + + halbtc8723b1ant_ps_tdma(btcoexist, FORCE_EXEC, false, 8); + coex_table_with_type(btcoexist, FORCE_EXEC, 0); +} + +static void init_hw_config(struct btc_coexist *btcoexist, bool backup) +{ + u32 u32tmp = 0; + u8 u8tmp = 0; + u32 cnt_bt_cal_chk = 0; + + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], 1Ant Init HW Config!!\n"); + + if (backup) {/* backup rf 0x1e value */ + coex_dm->backup_arfr_cnt1 = + btcoexist->btc_read_4byte(btcoexist, 0x430); + coex_dm->backup_arfr_cnt2 = + btcoexist->btc_read_4byte(btcoexist, 0x434); + coex_dm->backup_retry_limit = + btcoexist->btc_read_2byte(btcoexist, 0x42a); + coex_dm->backup_ampdu_max_time = + btcoexist->btc_read_1byte(btcoexist, 0x456); + } + + /* WiFi goto standby while GNT_BT 0-->1 */ + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x780); + /* BT goto standby while GNT_BT 1-->0 */ + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x2, 0xfffff, 0x500); + + btcoexist->btc_write_1byte(btcoexist, 0x974, 0xff); + btcoexist->btc_write_1byte_bitmask(btcoexist, 0x944, 0x3, 0x3); + btcoexist->btc_write_1byte(btcoexist, 0x930, 0x77); + + /* BT calibration check */ + while (cnt_bt_cal_chk <= 20) { + u32tmp = btcoexist->btc_read_4byte(btcoexist, 0x49d); + cnt_bt_cal_chk++; + if (u32tmp & BIT(0)) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], ########### BT calibration(cnt =%d) ###########\n", + cnt_bt_cal_chk); + mdelay(50); + } else { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], ********** BT NOT calibration (cnt =%d)**********\n", + cnt_bt_cal_chk); + break; + } + } + + /* 0x790[5:0] = 0x5 */ + u8tmp = btcoexist->btc_read_1byte(btcoexist, 0x790); + u8tmp &= 0xc0; + u8tmp |= 0x5; + btcoexist->btc_write_1byte(btcoexist, 0x790, u8tmp); + + /* Enable counter statistics */ + /*0x76e[3] = 1, WLAN_Act control by PTA */ + btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc); + btcoexist->btc_write_1byte(btcoexist, 0x778, 0x1); + btcoexist->btc_write_1byte_bitmask(btcoexist, 0x40, 0x20, 0x1); + + /*Antenna config */ + halbtc8723b1ant_setantpath(btcoexist, BTC_ANT_PATH_PTA, true, false); + /* PTA parameter */ + coex_table_with_type(btcoexist, FORCE_EXEC, 0); +} + +static void halbtc8723b1ant_wifi_off_hw_cfg(struct btc_coexist *btcoexist) +{ + /* set wlan_act to low */ + btcoexist->btc_write_1byte(btcoexist, 0x76e, 0x4); +} + +/************************************************************** + * work around function start with wa_halbtc8723b1ant_ + **************************************************************/ +/************************************************************** + * extern function start with EXhalbtc8723b1ant_ + **************************************************************/ + +void ex_halbtc8723b1ant_init_hwconfig(struct btc_coexist *btcoexist) +{ + init_hw_config(btcoexist, true); +} + +void ex_halbtc8723b1ant_init_coex_dm(struct btc_coexist *btcoexist) +{ + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], Coex Mechanism Init!!\n"); + + btcoexist->stop_coex_dm = false; + + halbtc8723b1ant_init_coex_dm(btcoexist); + + halbtc8723b1ant_query_bt_info(btcoexist); +} + +void ex_halbtc8723b1ant_display_coex_info(struct btc_coexist *btcoexist) +{ + struct btc_board_info *brd_info = &btcoexist->board_info; + struct btc_stack_info *stack_info = &btcoexist->stack_info; + struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; + u8 *cli_buf = btcoexist->cli_buf; + u8 u8tmp[4], i, bt_info_ext, stdmacase = 0; + u16 u16tmp[4]; + u32 u32tmp[4]; + bool roam = false, scan = false; + bool link = false, wifi_under_5g = false; + bool bt_hs_on = false, wifi_busy = false; + s32 wifi_rssi = 0, bt_hs_rssi = 0; + u32 wifi_bw, wifi_traffic_dir, fa_ofdm, fa_cck, wifi_link_status; + u8 wifi_dot11_chnl, wifi_hs_chnl; + u32 fw_ver = 0, bt_patch_ver = 0; + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\r\n ============[BT Coexist info] ============"); + CL_PRINTF(cli_buf); + + if (btcoexist->manual_control) { + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\r\n ============[Under Manual Control] =========="); + CL_PRINTF(cli_buf); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\r\n =========================================="); + CL_PRINTF(cli_buf); + } + if (btcoexist->stop_coex_dm) { + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\r\n ============[Coex is STOPPED] ============"); + CL_PRINTF(cli_buf); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\r\n =========================================="); + CL_PRINTF(cli_buf); + } + + if (!brd_info->bt_exist) { + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n BT not exists !!!"); + CL_PRINTF(cli_buf); + return; + } + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d", + "Ant PG Num/ Ant Mech/ Ant Pos: ", + brd_info->pg_ant_num, brd_info->btdm_ant_num, + brd_info->btdm_ant_pos); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", + "BT stack/ hci ext ver", + ((stack_info->profile_notified) ? "Yes" : "No"), + stack_info->hci_version); + CL_PRINTF(cli_buf); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER, &bt_patch_ver); + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\r\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)", + "CoexVer/ FwVer/ PatchVer", + glcoex_ver_date_8723b_1ant, glcoex_ver_8723b_1ant, + fw_ver, bt_patch_ver, bt_patch_ver); + CL_PRINTF(cli_buf); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); + btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_DOT11_CHNL, + &wifi_dot11_chnl); + btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifi_hs_chnl); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d(%d)", + "Dot11 channel / HsChnl(HsMode)", + wifi_dot11_chnl, wifi_hs_chnl, bt_hs_on); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", + "H2C Wifi inform bt chnl Info", + coex_dm->wifi_chnl_info[0], coex_dm->wifi_chnl_info[1], + coex_dm->wifi_chnl_info[2]); + CL_PRINTF(cli_buf); + + btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi); + btcoexist->btc_get(btcoexist, BTC_GET_S4_HS_RSSI, &bt_hs_rssi); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", + "Wifi rssi/ HS rssi", wifi_rssi, bt_hs_rssi); + CL_PRINTF(cli_buf); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", + "Wifi link/ roam/ scan", link, roam, scan); + CL_PRINTF(cli_buf); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, + &wifi_under_5g); + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, + &wifi_traffic_dir); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %s/ %s ", + "Wifi status", (wifi_under_5g ? "5G" : "2.4G"), + ((BTC_WIFI_BW_LEGACY == wifi_bw) ? "Legacy" : + (((BTC_WIFI_BW_HT40 == wifi_bw) ? "HT40" : "HT20"))), + ((!wifi_busy) ? "idle" : + ((BTC_WIFI_TRAFFIC_TX == wifi_traffic_dir) ? + "uplink" : "downlink"))); + CL_PRINTF(cli_buf); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS, + &wifi_link_status); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d/ %d", + "sta/vwifi/hs/p2pGo/p2pGc", + ((wifi_link_status & WIFI_STA_CONNECTED) ? 1 : 0), + ((wifi_link_status & WIFI_AP_CONNECTED) ? 1 : 0), + ((wifi_link_status & WIFI_HS_CONNECTED) ? 1 : 0), + ((wifi_link_status & WIFI_P2P_GO_CONNECTED) ? 1 : 0), + ((wifi_link_status & WIFI_P2P_GC_CONNECTED) ? 1 : 0)); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ", + "BT [status/ rssi/ retryCnt]", + ((btcoexist->bt_info.bt_disabled) ? ("disabled") : + ((coex_sta->c2h_bt_inquiry_page) ? ("inquiry/page scan") : + ((BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == coex_dm->bt_status) ? + "non-connected idle" : + ((BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == coex_dm->bt_status) ? + "connected-idle" : "busy")))), + coex_sta->bt_rssi, coex_sta->bt_retry_cnt); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", + "SCO/HID/PAN/A2DP", bt_link_info->sco_exist, + bt_link_info->hid_exist, bt_link_info->pan_exist, + bt_link_info->a2dp_exist); + CL_PRINTF(cli_buf); + btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_BT_LINK_INFO); + + bt_info_ext = coex_sta->bt_info_ext; + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", + "BT Info A2DP rate", + (bt_info_ext & BIT(0)) ? "Basic rate" : "EDR rate"); + CL_PRINTF(cli_buf); + + for (i = 0; i < BT_INFO_SRC_8723B_1ANT_MAX; i++) { + if (coex_sta->bt_info_c2h_cnt[i]) { + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", + glb_infosrc8723b1ant[i], + coex_sta->bt_info_c2h[i][0], + coex_sta->bt_info_c2h[i][1], + coex_sta->bt_info_c2h[i][2], + coex_sta->bt_info_c2h[i][3], + coex_sta->bt_info_c2h[i][4], + coex_sta->bt_info_c2h[i][5], + coex_sta->bt_info_c2h[i][6], + coex_sta->bt_info_c2h_cnt[i]); + CL_PRINTF(cli_buf); + } + } + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\r\n %-35s = %s/%s, (0x%x/0x%x)", + "PS state, IPS/LPS, (lps/rpwm)", + ((coex_sta->under_ips ? "IPS ON" : "IPS OFF")), + ((coex_sta->under_lps ? "LPS ON" : "LPS OFF")), + btcoexist->bt_info.lps_val, + btcoexist->bt_info.rpwm_val); + CL_PRINTF(cli_buf); + btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_FW_PWR_MODE_CMD); + + if (!btcoexist->manual_control) { + /* Sw mechanism */ + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s", + "============[Sw mechanism] ============"); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/", + "SM[LowPenaltyRA]", coex_dm->cur_low_penalty_ra); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s/ %d ", + "DelBA/ BtCtrlAgg/ AggSize", + (btcoexist->bt_info.reject_agg_pkt ? "Yes" : "No"), + (btcoexist->bt_info.b_bt_ctrl_buf_size ? "Yes" : "No"), + btcoexist->bt_info.agg_buf_size); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", + "Rate Mask", btcoexist->bt_info.ra_mask); + CL_PRINTF(cli_buf); + + /* Fw mechanism */ + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s", + "============[Fw mechanism] ============"); + CL_PRINTF(cli_buf); + + stdmacase = coex_dm->cur_ps_tdma; + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d)", + "PS TDMA", coex_dm->ps_tdma_para[0], + coex_dm->ps_tdma_para[1], coex_dm->ps_tdma_para[2], + coex_dm->ps_tdma_para[3], coex_dm->ps_tdma_para[4], + stdmacase, coex_dm->auto_tdma_adjust); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d ", + "IgnWlanAct", coex_dm->cur_ignore_wlan_act); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", + "Latest error condition(should be 0)", + coex_dm->error_condition); + CL_PRINTF(cli_buf); + } + + /* Hw setting */ + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s", + "============[Hw setting] ============"); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x", + "backup ARFR1/ARFR2/RL/AMaxTime", coex_dm->backup_arfr_cnt1, + coex_dm->backup_arfr_cnt2, coex_dm->backup_retry_limit, + coex_dm->backup_ampdu_max_time); + CL_PRINTF(cli_buf); + + u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x430); + u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x434); + u16tmp[0] = btcoexist->btc_read_2byte(btcoexist, 0x42a); + u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x456); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x", + "0x430/0x434/0x42a/0x456", + u32tmp[0], u32tmp[1], u16tmp[0], u8tmp[0]); + CL_PRINTF(cli_buf); + + u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x778); + u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x6cc); + u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x880); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", + "0x778/0x6cc/0x880[29:25]", u8tmp[0], u32tmp[0], + (u32tmp[1] & 0x3e000000) >> 25); + CL_PRINTF(cli_buf); + + u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x948); + u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x67); + u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0x765); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = 0x%x/ 0x%x/ 0x%x", + "0x948/ 0x67[5] / 0x765", + u32tmp[0], ((u8tmp[0] & 0x20) >> 5), u8tmp[1]); + CL_PRINTF(cli_buf); + + u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x92c); + u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x930); + u32tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0x944); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", + "0x92c[1:0]/ 0x930[7:0]/0x944[1:0]", + u32tmp[0] & 0x3, u32tmp[1] & 0xff, u32tmp[2] & 0x3); + CL_PRINTF(cli_buf); + + u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x39); + u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0x40); + u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x4c); + u8tmp[2] = btcoexist->btc_read_1byte(btcoexist, 0x64); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", + "0x38[11]/0x40/0x4c[24:23]/0x64[0]", + ((u8tmp[0] & 0x8)>>3), u8tmp[1], + ((u32tmp[0] & 0x01800000) >> 23), u8tmp[2] & 0x1); + CL_PRINTF(cli_buf); + + u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x550); + u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x522); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", + "0x550(bcn ctrl)/0x522", u32tmp[0], u8tmp[0]); + CL_PRINTF(cli_buf); + + u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xc50); + u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x49c); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", + "0xc50(dig)/0x49c(null-drop)", u32tmp[0] & 0xff, u8tmp[0]); + CL_PRINTF(cli_buf); + + u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xda0); + u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0xda4); + u32tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0xda8); + u32tmp[3] = btcoexist->btc_read_4byte(btcoexist, 0xcf0); + + u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0xa5b); + u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0xa5c); + + fa_ofdm = ((u32tmp[0] & 0xffff0000) >> 16) + + ((u32tmp[1] & 0xffff0000) >> 16) + + (u32tmp[1] & 0xffff) + + (u32tmp[2] & 0xffff) + + ((u32tmp[3] & 0xffff0000) >> 16) + + (u32tmp[3] & 0xffff); + fa_cck = (u8tmp[0] << 8) + u8tmp[1]; + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", + "OFDM-CCA/OFDM-FA/CCK-FA", + u32tmp[0] & 0xffff, fa_ofdm, fa_cck); + CL_PRINTF(cli_buf); + + u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x6c0); + u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x6c4); + u32tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0x6c8); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", + "0x6c0/0x6c4/0x6c8(coexTable)", + u32tmp[0], u32tmp[1], u32tmp[2]); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", + "0x770(high-pri rx/tx)", coex_sta->high_priority_rx, + coex_sta->high_priority_tx); + CL_PRINTF(cli_buf); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", + "0x774(low-pri rx/tx)", coex_sta->low_priority_rx, + coex_sta->low_priority_tx); + CL_PRINTF(cli_buf); +#if (BT_AUTO_REPORT_ONLY_8723B_1ANT == 1) + halbtc8723b1ant_monitor_bt_ctr(btcoexist); +#endif + btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_COEX_STATISTICS); +} + +void ex_halbtc8723b1ant_ips_notify(struct btc_coexist *btcoexist, u8 type) +{ + if (btcoexist->manual_control || btcoexist->stop_coex_dm) + return; + + if (BTC_IPS_ENTER == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], IPS ENTER notify\n"); + coex_sta->under_ips = true; + + halbtc8723b1ant_setantpath(btcoexist, BTC_ANT_PATH_BT, + false, true); + /* set PTA control */ + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 0); + coex_table_with_type(btcoexist, + NORMAL_EXEC, 0); + halbtc8723b1ant_wifi_off_hw_cfg(btcoexist); + } else if (BTC_IPS_LEAVE == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], IPS LEAVE notify\n"); + coex_sta->under_ips = false; + + init_hw_config(btcoexist, false); + halbtc8723b1ant_init_coex_dm(btcoexist); + halbtc8723b1ant_query_bt_info(btcoexist); + } +} + +void ex_halbtc8723b1ant_lps_notify(struct btc_coexist *btcoexist, u8 type) +{ + if (btcoexist->manual_control || btcoexist->stop_coex_dm) + return; + + if (BTC_LPS_ENABLE == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], LPS ENABLE notify\n"); + coex_sta->under_lps = true; + } else if (BTC_LPS_DISABLE == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], LPS DISABLE notify\n"); + coex_sta->under_lps = false; + } +} + +void ex_halbtc8723b1ant_scan_notify(struct btc_coexist *btcoexist, u8 type) +{ + bool wifi_connected = false, bt_hs_on = false; + u32 wifi_link_status = 0; + u32 num_of_wifi_link = 0; + bool bt_ctrl_agg_buf_size = false; + u8 agg_buf_size = 5; + + if (btcoexist->manual_control || btcoexist->stop_coex_dm || + btcoexist->bt_info.bt_disabled) + return; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, + &wifi_connected); + + halbtc8723b1ant_query_bt_info(btcoexist); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS, + &wifi_link_status); + num_of_wifi_link = wifi_link_status >> 16; + if (num_of_wifi_link >= 2) { + halbtc8723b1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0); + halbtc8723b1ant_limited_rx(btcoexist, NORMAL_EXEC, false, + bt_ctrl_agg_buf_size, agg_buf_size); + halbtc8723b1ant_action_wifi_multiport(btcoexist); + return; + } + + if (coex_sta->c2h_bt_inquiry_page) { + halbtc8723b1ant_action_bt_inquiry(btcoexist); + return; + } else if (bt_hs_on) { + halbtc8723b1ant_action_hs(btcoexist); + return; + } + + if (BTC_SCAN_START == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], SCAN START notify\n"); + if (!wifi_connected) /* non-connected scan */ + action_wifi_not_connected_scan(btcoexist); + else /* wifi is connected */ + action_wifi_connected_scan(btcoexist); + } else if (BTC_SCAN_FINISH == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], SCAN FINISH notify\n"); + if (!wifi_connected) /* non-connected scan */ + action_wifi_not_connected(btcoexist); + else + halbtc8723b1ant_action_wifi_connected(btcoexist); + } +} + +void ex_halbtc8723b1ant_connect_notify(struct btc_coexist *btcoexist, u8 type) +{ + bool wifi_connected = false, bt_hs_on = false; + u32 wifi_link_status = 0; + u32 num_of_wifi_link = 0; + bool bt_ctrl_agg_buf_size = false; + u8 agg_buf_size = 5; + + if (btcoexist->manual_control || btcoexist->stop_coex_dm || + btcoexist->bt_info.bt_disabled) + return; + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS, + &wifi_link_status); + num_of_wifi_link = wifi_link_status>>16; + if (num_of_wifi_link >= 2) { + halbtc8723b1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0); + halbtc8723b1ant_limited_rx(btcoexist, NORMAL_EXEC, false, + bt_ctrl_agg_buf_size, agg_buf_size); + halbtc8723b1ant_action_wifi_multiport(btcoexist); + return; + } + + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); + if (coex_sta->c2h_bt_inquiry_page) { + halbtc8723b1ant_action_bt_inquiry(btcoexist); + return; + } else if (bt_hs_on) { + halbtc8723b1ant_action_hs(btcoexist); + return; + } + + if (BTC_ASSOCIATE_START == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], CONNECT START notify\n"); + action_wifi_not_connected_asso_auth(btcoexist); + } else if (BTC_ASSOCIATE_FINISH == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], CONNECT FINISH notify\n"); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, + &wifi_connected); + if (!wifi_connected) /* non-connected scan */ + action_wifi_not_connected(btcoexist); + else + halbtc8723b1ant_action_wifi_connected(btcoexist); + } +} + +void ex_halbtc8723b1ant_media_status_notify(struct btc_coexist *btcoexist, + u8 type) +{ + u8 h2c_parameter[3] = {0}; + u32 wifi_bw; + u8 wificentralchnl; + + if (btcoexist->manual_control || btcoexist->stop_coex_dm || + btcoexist->bt_info.bt_disabled) + return; + + if (BTC_MEDIA_CONNECT == type) + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], MEDIA connect notify\n"); + else + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], MEDIA disconnect notify\n"); + + /* only 2.4G we need to inform bt the chnl mask */ + btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, + &wificentralchnl); + + if ((BTC_MEDIA_CONNECT == type) && + (wificentralchnl <= 14)) { + h2c_parameter[0] = 0x0; + h2c_parameter[1] = wificentralchnl; + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + if (BTC_WIFI_BW_HT40 == wifi_bw) + h2c_parameter[2] = 0x30; + else + h2c_parameter[2] = 0x20; + } + + coex_dm->wifi_chnl_info[0] = h2c_parameter[0]; + coex_dm->wifi_chnl_info[1] = h2c_parameter[1]; + coex_dm->wifi_chnl_info[2] = h2c_parameter[2]; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], FW write 0x66 = 0x%x\n", + h2c_parameter[0] << 16 | h2c_parameter[1] << 8 | + h2c_parameter[2]); + + btcoexist->btc_fill_h2c(btcoexist, 0x66, 3, h2c_parameter); +} + +void ex_halbtc8723b1ant_special_packet_notify(struct btc_coexist *btcoexist, + u8 type) +{ + bool bt_hs_on = false; + u32 wifi_link_status = 0; + u32 num_of_wifi_link = 0; + bool bt_ctrl_agg_buf_size = false; + u8 agg_buf_size = 5; + + if (btcoexist->manual_control || btcoexist->stop_coex_dm || + btcoexist->bt_info.bt_disabled) + return; + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_LINK_STATUS, + &wifi_link_status); + num_of_wifi_link = wifi_link_status >> 16; + if (num_of_wifi_link >= 2) { + halbtc8723b1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0); + halbtc8723b1ant_limited_rx(btcoexist, NORMAL_EXEC, false, + bt_ctrl_agg_buf_size, agg_buf_size); + halbtc8723b1ant_action_wifi_multiport(btcoexist); + return; + } + + coex_sta->special_pkt_period_cnt = 0; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); + if (coex_sta->c2h_bt_inquiry_page) { + halbtc8723b1ant_action_bt_inquiry(btcoexist); + return; + } else if (bt_hs_on) { + halbtc8723b1ant_action_hs(btcoexist); + return; + } + + if (BTC_PACKET_DHCP == type || + BTC_PACKET_EAPOL == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], special Packet(%d) notify\n", type); + action_wifi_connected_special_packet(btcoexist); + } +} + +void ex_halbtc8723b1ant_bt_info_notify(struct btc_coexist *btcoexist, + u8 *tmp_buf, u8 length) +{ + u8 bt_info = 0; + u8 i, rsp_source = 0; + bool wifi_connected = false; + bool bt_busy = false; + + coex_sta->c2h_bt_info_req_sent = false; + + rsp_source = tmp_buf[0] & 0xf; + if (rsp_source >= BT_INFO_SRC_8723B_1ANT_MAX) + rsp_source = BT_INFO_SRC_8723B_1ANT_WIFI_FW; + coex_sta->bt_info_c2h_cnt[rsp_source]++; + + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], Bt info[%d], length =%d, hex data =[", + rsp_source, length); + for (i = 0; i < length; i++) { + coex_sta->bt_info_c2h[rsp_source][i] = tmp_buf[i]; + if (i == 1) + bt_info = tmp_buf[i]; + if (i == length - 1) + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "0x%02x]\n", tmp_buf[i]); + else + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "0x%02x, ", tmp_buf[i]); + } + + if (BT_INFO_SRC_8723B_1ANT_WIFI_FW != rsp_source) { + coex_sta->bt_retry_cnt = /* [3:0] */ + coex_sta->bt_info_c2h[rsp_source][2] & 0xf; + + coex_sta->bt_rssi = + coex_sta->bt_info_c2h[rsp_source][3] * 2 + 10; + + coex_sta->bt_info_ext = + coex_sta->bt_info_c2h[rsp_source][4]; + + /* Here we need to resend some wifi info to BT + * because bt is reset and loss of the info.*/ + if (coex_sta->bt_info_ext & BIT(1)) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n"); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, + &wifi_connected); + if (wifi_connected) + ex_halbtc8723b1ant_media_status_notify(btcoexist, + BTC_MEDIA_CONNECT); + else + ex_halbtc8723b1ant_media_status_notify(btcoexist, + BTC_MEDIA_DISCONNECT); + } + + if (coex_sta->bt_info_ext & BIT(3)) { + if (!btcoexist->manual_control && + !btcoexist->stop_coex_dm) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT ext info bit3 check, set BT NOT ignore Wlan active!!\n"); + halbtc8723b1ant_ignore_wlan_act(btcoexist, + FORCE_EXEC, + false); + } + } else { + /* BT already NOT ignore Wlan active, do nothing here.*/ + } +#if (BT_AUTO_REPORT_ONLY_8723B_1ANT == 0) + if (coex_sta->bt_info_ext & BIT(4)) { + /* BT auto report already enabled, do nothing */ + } else { + halbtc8723b1ant_bt_auto_report(btcoexist, FORCE_EXEC, + true); + } +#endif + } + + /* check BIT(2) first ==> check if bt is under inquiry or page scan */ + if (bt_info & BT_INFO_8723B_1ANT_B_INQ_PAGE) + coex_sta->c2h_bt_inquiry_page = true; + else + coex_sta->c2h_bt_inquiry_page = false; + + /* set link exist status */ + if (!(bt_info & BT_INFO_8723B_1ANT_B_CONNECTION)) { + coex_sta->bt_link_exist = false; + coex_sta->pan_exist = false; + coex_sta->a2dp_exist = false; + coex_sta->hid_exist = false; + coex_sta->sco_exist = false; + } else { /* connection exists */ + coex_sta->bt_link_exist = true; + if (bt_info & BT_INFO_8723B_1ANT_B_FTP) + coex_sta->pan_exist = true; + else + coex_sta->pan_exist = false; + if (bt_info & BT_INFO_8723B_1ANT_B_A2DP) + coex_sta->a2dp_exist = true; + else + coex_sta->a2dp_exist = false; + if (bt_info & BT_INFO_8723B_1ANT_B_HID) + coex_sta->hid_exist = true; + else + coex_sta->hid_exist = false; + if (bt_info & BT_INFO_8723B_1ANT_B_SCO_ESCO) + coex_sta->sco_exist = true; + else + coex_sta->sco_exist = false; + } + + halbtc8723b1ant_update_bt_link_info(btcoexist); + + if (!(bt_info&BT_INFO_8723B_1ANT_B_CONNECTION)) { + coex_dm->bt_status = BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BtInfoNotify(), BT Non-Connected idle!\n"); + /* connection exists but no busy */ + } else if (bt_info == BT_INFO_8723B_1ANT_B_CONNECTION) { + coex_dm->bt_status = BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n"); + } else if ((bt_info & BT_INFO_8723B_1ANT_B_SCO_ESCO) || + (bt_info & BT_INFO_8723B_1ANT_B_SCO_BUSY)) { + coex_dm->bt_status = BT_8723B_1ANT_BT_STATUS_SCO_BUSY; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BtInfoNotify(), BT SCO busy!!!\n"); + } else if (bt_info & BT_INFO_8723B_1ANT_B_ACL_BUSY) { + if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY != coex_dm->bt_status) + coex_dm->auto_tdma_adjust = false; + + coex_dm->bt_status = BT_8723B_1ANT_BT_STATUS_ACL_BUSY; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BtInfoNotify(), BT ACL busy!!!\n"); + } else { + coex_dm->bt_status = + BT_8723B_1ANT_BT_STATUS_MAX; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BtInfoNotify(), BT Non-Defined state!!\n"); + } + + if ((BT_8723B_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) || + (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) || + (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == coex_dm->bt_status)) + bt_busy = true; + else + bt_busy = false; + btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bt_busy); + + halbtc8723b1ant_run_coexist_mechanism(btcoexist); +} + +void ex_halbtc8723b1ant_halt_notify(struct btc_coexist *btcoexist) +{ + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, "[BTCoex], Halt notify\n"); + + btcoexist->stop_coex_dm = true; + + halbtc8723b1ant_setantpath(btcoexist, BTC_ANT_PATH_BT, false, true); + + halbtc8723b1ant_wifi_off_hw_cfg(btcoexist); + halbtc8723b1ant_ignore_wlan_act(btcoexist, FORCE_EXEC, true); + + halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, + 0x0, 0x0); + halbtc8723b1ant_ps_tdma(btcoexist, FORCE_EXEC, false, 0); + + ex_halbtc8723b1ant_media_status_notify(btcoexist, BTC_MEDIA_DISCONNECT); +} + +void ex_halbtc8723b1ant_pnp_notify(struct btc_coexist *btcoexist, u8 pnp_state) +{ + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, "[BTCoex], Pnp notify\n"); + + if (BTC_WIFI_PNP_SLEEP == pnp_state) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], Pnp notify to SLEEP\n"); + btcoexist->stop_coex_dm = true; + halbtc8723b1ant_setantpath(btcoexist, BTC_ANT_PATH_BT, false, + true); + halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, + 0x0, 0x0); + halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 0); + coex_table_with_type(btcoexist, NORMAL_EXEC, 2); + halbtc8723b1ant_wifi_off_hw_cfg(btcoexist); + } else if (BTC_WIFI_PNP_WAKE_UP == pnp_state) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], Pnp notify to WAKE UP\n"); + btcoexist->stop_coex_dm = false; + init_hw_config(btcoexist, false); + halbtc8723b1ant_init_coex_dm(btcoexist); + halbtc8723b1ant_query_bt_info(btcoexist); + } +} + +void ex_halbtc8723b1ant_coex_dm_reset(struct btc_coexist *btcoexist) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], *****************Coex DM Reset****************\n"); + + init_hw_config(btcoexist, false); + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x2, 0xfffff, 0x0); + halbtc8723b1ant_init_coex_dm(btcoexist); +} + +void ex_halbtc8723b1ant_periodical(struct btc_coexist *btcoexist) +{ + struct btc_board_info *brd_info = &btcoexist->board_info; + struct btc_stack_info *stack_info = &btcoexist->stack_info; + static u8 dis_ver_info_cnt; + u32 fw_ver = 0, bt_patch_ver = 0; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], ========================== Periodical ===========================\n"); + + if (dis_ver_info_cnt <= 5) { + dis_ver_info_cnt += 1; + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], ****************************************************************\n"); + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n", + brd_info->pg_ant_num, brd_info->btdm_ant_num, + brd_info->btdm_ant_pos); + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], BT stack/ hci ext ver = %s / %d\n", + ((stack_info->profile_notified) ? "Yes" : "No"), + stack_info->hci_version); + btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER, + &bt_patch_ver); + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver); + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n", + glcoex_ver_date_8723b_1ant, + glcoex_ver_8723b_1ant, fw_ver, + bt_patch_ver, bt_patch_ver); + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], ****************************************************************\n"); + } + +#if (BT_AUTO_REPORT_ONLY_8723B_1ANT == 0) + halbtc8723b1ant_query_bt_info(btcoexist); + halbtc8723b1ant_monitor_bt_ctr(btcoexist); + halbtc8723b1ant_monitor_bt_enable_disable(btcoexist); +#else + if (is_wifi_status_changed(btcoexist) || + coex_dm->auto_tdma_adjust) { + halbtc8723b1ant_run_coexist_mechanism(btcoexist); + } + + coex_sta->special_pkt_period_cnt++; +#endif +} + diff --git a/drivers/staging/rtl8192ee/btcoexist/halbtc8723b1ant.h b/drivers/staging/rtl8192ee/btcoexist/halbtc8723b1ant.h new file mode 100644 index 000000000000..bded3738f24f --- /dev/null +++ b/drivers/staging/rtl8192ee/btcoexist/halbtc8723b1ant.h @@ -0,0 +1,160 @@ +/********************************************************************** + * The following is for 8723B 1ANT BT Co-exist definition + **********************************************************************/ +#define BT_AUTO_REPORT_ONLY_8723B_1ANT 1 + +#define BT_INFO_8723B_1ANT_B_FTP BIT(7) +#define BT_INFO_8723B_1ANT_B_A2DP BIT(6) +#define BT_INFO_8723B_1ANT_B_HID BIT(5) +#define BT_INFO_8723B_1ANT_B_SCO_BUSY BIT(4) +#define BT_INFO_8723B_1ANT_B_ACL_BUSY BIT(3) +#define BT_INFO_8723B_1ANT_B_INQ_PAGE BIT(2) +#define BT_INFO_8723B_1ANT_B_SCO_ESCO BIT(1) +#define BT_INFO_8723B_1ANT_B_CONNECTION BIT(0) + +#define BT_INFO_8723B_1ANT_A2DP_BASIC_RATE(_BT_INFO_EXT_) \ + (((_BT_INFO_EXT_&BIT(0))) ? true : false) + +#define BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT 2 + +enum BT_INFO_SRC_8723B_1ANT { + BT_INFO_SRC_8723B_1ANT_WIFI_FW = 0x0, + BT_INFO_SRC_8723B_1ANT_BT_RSP = 0x1, + BT_INFO_SRC_8723B_1ANT_BT_ACTIVE_SEND = 0x2, + BT_INFO_SRC_8723B_1ANT_MAX +}; + +enum BT_8723B_1ANT_BT_STATUS { + BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0, + BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE = 0x1, + BT_8723B_1ANT_BT_STATUS_INQ_PAGE = 0x2, + BT_8723B_1ANT_BT_STATUS_ACL_BUSY = 0x3, + BT_8723B_1ANT_BT_STATUS_SCO_BUSY = 0x4, + BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY = 0x5, + BT_8723B_1ANT_BT_STATUS_MAX +}; + +enum BT_8723B_1ANT_WIFI_STATUS { + BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_IDLE = 0x0, + BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN = 0x1, + BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN = 0x2, + BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT = 0x3, + BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE = 0x4, + BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY = 0x5, + BT_8723B_1ANT_WIFI_STATUS_MAX +}; + +enum BT_8723B_1ANT_COEX_ALGO { + BT_8723B_1ANT_COEX_ALGO_UNDEFINED = 0x0, + BT_8723B_1ANT_COEX_ALGO_SCO = 0x1, + BT_8723B_1ANT_COEX_ALGO_HID = 0x2, + BT_8723B_1ANT_COEX_ALGO_A2DP = 0x3, + BT_8723B_1ANT_COEX_ALGO_A2DP_PANHS = 0x4, + BT_8723B_1ANT_COEX_ALGO_PANEDR = 0x5, + BT_8723B_1ANT_COEX_ALGO_PANHS = 0x6, + BT_8723B_1ANT_COEX_ALGO_PANEDR_A2DP = 0x7, + BT_8723B_1ANT_COEX_ALGO_PANEDR_HID = 0x8, + BT_8723B_1ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9, + BT_8723B_1ANT_COEX_ALGO_HID_A2DP = 0xa, + BT_8723B_1ANT_COEX_ALGO_MAX = 0xb, +}; + +struct coex_dm_8723b_1ant { + /* fw mechanism */ + bool cur_ignore_wlan_act; + bool pre_ignore_wlan_act; + u8 pre_ps_tdma; + u8 cur_ps_tdma; + u8 ps_tdma_para[5]; + u8 ps_tdma_du_adj_type; + bool auto_tdma_adjust; + bool pre_ps_tdma_on; + bool cur_ps_tdma_on; + bool pre_bt_auto_report; + bool cur_bt_auto_report; + u8 pre_lps; + u8 cur_lps; + u8 pre_rpwm; + u8 cur_rpwm; + + /* sw mechanism */ + bool pre_low_penalty_ra; + bool cur_low_penalty_ra; + u32 pre_val0x6c0; + u32 cur_val0x6c0; + u32 pre_val0x6c4; + u32 cur_val0x6c4; + u32 pre_val0x6c8; + u32 cur_val0x6c8; + u8 pre_val0x6cc; + u8 cur_val0x6cc; + bool limited_dig; + + u32 backup_arfr_cnt1; /* Auto Rate Fallback Retry cnt */ + u32 backup_arfr_cnt2; /* Auto Rate Fallback Retry cnt */ + u16 backup_retry_limit; + u8 backup_ampdu_max_time; + + /* algorithm related */ + u8 pre_algorithm; + u8 cur_algorithm; + u8 bt_status; + u8 wifi_chnl_info[3]; + + u32 prera_mask; + u32 curra_mask; + u8 pre_arfr_type; + u8 cur_arfr_type; + u8 pre_retry_limit_type; + u8 cur_retry_limit_type; + u8 pre_ampdu_time_type; + u8 cur_ampdu_time_type; + + u8 error_condition; +}; + +struct coex_sta_8723b_1ant { + bool bt_link_exist; + bool sco_exist; + bool a2dp_exist; + bool hid_exist; + bool pan_exist; + + bool under_lps; + bool under_ips; + u32 special_pkt_period_cnt; + u32 high_priority_tx; + u32 high_priority_rx; + u32 low_priority_tx; + u32 low_priority_rx; + u8 bt_rssi; + u8 pre_bt_rssi_state; + u8 pre_wifi_rssi_state[4]; + bool c2h_bt_info_req_sent; + u8 bt_info_c2h[BT_INFO_SRC_8723B_1ANT_MAX][10]; + u32 bt_info_c2h_cnt[BT_INFO_SRC_8723B_1ANT_MAX]; + bool c2h_bt_inquiry_page; + u8 bt_retry_cnt; + u8 bt_info_ext; +}; + +/************************************************************************* + * The following is interface which will notify coex module. + *************************************************************************/ +void ex_halbtc8723b1ant_init_hwconfig(struct btc_coexist *btcoexist); +void ex_halbtc8723b1ant_init_coex_dm(struct btc_coexist *btcoexist); +void ex_halbtc8723b1ant_ips_notify(struct btc_coexist *btcoexist, u8 type); +void ex_halbtc8723b1ant_lps_notify(struct btc_coexist *btcoexist, u8 type); +void ex_halbtc8723b1ant_scan_notify(struct btc_coexist *btcoexist, u8 type); +void ex_halbtc8723b1ant_connect_notify(struct btc_coexist *btcoexist, u8 type); +void ex_halbtc8723b1ant_media_status_notify(struct btc_coexist *btcoexist, + u8 type); +void ex_halbtc8723b1ant_special_packet_notify(struct btc_coexist *btcoexist, + u8 type); +void ex_halbtc8723b1ant_bt_info_notify(struct btc_coexist *btcoexist, + u8 *tmpbuf, u8 length); +void ex_halbtc8723b1ant_halt_notify(struct btc_coexist *btcoexist); +void ex_halbtc8723b1ant_pnp_notify(struct btc_coexist *btcoexist, u8 state); +void ex_halbtc8723b1ant_coex_dm_reset(struct btc_coexist *btcoexist); +void ex_halbtc8723b1ant_periodical(struct btc_coexist *btcoexist); +void ex_halbtc8723b1ant_display_coex_info(struct btc_coexist *btcoexist); diff --git a/drivers/staging/rtl8192ee/btcoexist/halbtc8723b2ant.c b/drivers/staging/rtl8192ee/btcoexist/halbtc8723b2ant.c new file mode 100644 index 000000000000..836206357e68 --- /dev/null +++ b/drivers/staging/rtl8192ee/btcoexist/halbtc8723b2ant.c @@ -0,0 +1,3929 @@ +/*************************************************************** + * Description: + * + * This file is for RTL8723B Co-exist mechanism + * + * History + * 2012/11/15 Cosa first check in. + * + **************************************************************/ +/************************************************************** + * include files + **************************************************************/ +#include "halbt_precomp.h" +/************************************************************** + * Global variables, these are static variables + **************************************************************/ +static struct coex_dm_8723b_2ant glcoex_dm_8723b_2ant; +static struct coex_dm_8723b_2ant *coex_dm = &glcoex_dm_8723b_2ant; +static struct coex_sta_8723b_2ant glcoex_sta_8723b_2ant; +static struct coex_sta_8723b_2ant *coex_sta = &glcoex_sta_8723b_2ant; + +static const char *const glbt_info_src_8723b_2ant[] = { + "BT Info[wifi fw]", + "BT Info[bt rsp]", + "BT Info[bt auto report]", +}; + +static u32 glcoex_ver_date_8723b_2ant = 20131113; +static u32 glcoex_ver_8723b_2ant = 0x3f; + +/************************************************************** + * local function proto type if needed + **************************************************************/ +/************************************************************** + * local function start with halbtc8723b2ant_ + **************************************************************/ +static u8 halbtc8723b2ant_bt_rssi_state(u8 level_num, u8 rssi_thresh, + u8 rssi_thresh1) +{ + s32 bt_rssi = 0; + u8 bt_rssi_state = coex_sta->pre_bt_rssi_state; + + bt_rssi = coex_sta->bt_rssi; + + if (level_num == 2) { + if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) || + (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW)) { + if (bt_rssi >= rssi_thresh + + BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT) { + bt_rssi_state = BTC_RSSI_STATE_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state switch to High\n"); + } else { + bt_rssi_state = BTC_RSSI_STATE_STAY_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state stay at Low\n"); + } + } else { + if (bt_rssi < rssi_thresh) { + bt_rssi_state = BTC_RSSI_STATE_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state switch to Low\n"); + } else { + bt_rssi_state = BTC_RSSI_STATE_STAY_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state stay at High\n"); + } + } + } else if (level_num == 3) { + if (rssi_thresh > rssi_thresh1) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi thresh error!!\n"); + return coex_sta->pre_bt_rssi_state; + } + + if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) || + (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW)) { + if (bt_rssi >= rssi_thresh + + BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT) { + bt_rssi_state = BTC_RSSI_STATE_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state switch to Medium\n"); + } else { + bt_rssi_state = BTC_RSSI_STATE_STAY_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state stay at Low\n"); + } + } else if ((coex_sta->pre_bt_rssi_state == + BTC_RSSI_STATE_MEDIUM) || + (coex_sta->pre_bt_rssi_state == + BTC_RSSI_STATE_STAY_MEDIUM)) { + if (bt_rssi >= rssi_thresh1 + + BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT) { + bt_rssi_state = BTC_RSSI_STATE_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state switch to High\n"); + } else if (bt_rssi < rssi_thresh) { + bt_rssi_state = BTC_RSSI_STATE_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state switch to Low\n"); + } else { + bt_rssi_state = BTC_RSSI_STATE_STAY_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state stay at Medium\n"); + } + } else { + if (bt_rssi < rssi_thresh1) { + bt_rssi_state = BTC_RSSI_STATE_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state switch to Medium\n"); + } else { + bt_rssi_state = BTC_RSSI_STATE_STAY_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state stay at High\n"); + } + } + } + + coex_sta->pre_bt_rssi_state = bt_rssi_state; + + return bt_rssi_state; +} + +static u8 halbtc8723b2ant_wifi_rssi_state(struct btc_coexist *btcoexist, + u8 index, u8 level_num, + u8 rssi_thresh, u8 rssi_thresh1) +{ + s32 wifi_rssi = 0; + u8 wifi_rssi_state = coex_sta->pre_wifi_rssi_state[index]; + + btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi); + + if (level_num == 2) { + if ((coex_sta->pre_wifi_rssi_state[index] == + BTC_RSSI_STATE_LOW) || + (coex_sta->pre_wifi_rssi_state[index] == + BTC_RSSI_STATE_STAY_LOW)) { + if (wifi_rssi >= rssi_thresh + + BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT) { + wifi_rssi_state = BTC_RSSI_STATE_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state switch to High\n"); + } else { + wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state stay at Low\n"); + } + } else { + if (wifi_rssi < rssi_thresh) { + wifi_rssi_state = BTC_RSSI_STATE_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state switch to Low\n"); + } else { + wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state stay at High\n"); + } + } + } else if (level_num == 3) { + if (rssi_thresh > rssi_thresh1) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI thresh error!!\n"); + return coex_sta->pre_wifi_rssi_state[index]; + } + + if ((coex_sta->pre_wifi_rssi_state[index] == + BTC_RSSI_STATE_LOW) || + (coex_sta->pre_wifi_rssi_state[index] == + BTC_RSSI_STATE_STAY_LOW)) { + if (wifi_rssi >= rssi_thresh + + BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT) { + wifi_rssi_state = BTC_RSSI_STATE_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state switch to Medium\n"); + } else { + wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state stay at Low\n"); + } + } else if ((coex_sta->pre_wifi_rssi_state[index] == + BTC_RSSI_STATE_MEDIUM) || + (coex_sta->pre_wifi_rssi_state[index] == + BTC_RSSI_STATE_STAY_MEDIUM)) { + if (wifi_rssi >= rssi_thresh1 + + BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT) { + wifi_rssi_state = BTC_RSSI_STATE_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state switch to High\n"); + } else if (wifi_rssi < rssi_thresh) { + wifi_rssi_state = BTC_RSSI_STATE_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state switch to Low\n"); + } else { + wifi_rssi_state = BTC_RSSI_STATE_STAY_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state stay at Medium\n"); + } + } else { + if (wifi_rssi < rssi_thresh1) { + wifi_rssi_state = BTC_RSSI_STATE_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state switch to Medium\n"); + } else { + wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state stay at High\n"); + } + } + } + + coex_sta->pre_wifi_rssi_state[index] = wifi_rssi_state; + + return wifi_rssi_state; +} + +static void halbtc8723b2ant_monitor_bt_ctr(struct btc_coexist *btcoexist) +{ + u32 reg_hp_txrx, reg_lp_txrx, u32tmp; + u32 reg_hp_tx = 0, reg_hp_rx = 0; + u32 reg_lp_tx = 0, reg_lp_rx = 0; + + reg_hp_txrx = 0x770; + reg_lp_txrx = 0x774; + + u32tmp = btcoexist->btc_read_4byte(btcoexist, reg_hp_txrx); + reg_hp_tx = u32tmp & MASKLWORD; + reg_hp_rx = (u32tmp & MASKHWORD) >> 16; + + u32tmp = btcoexist->btc_read_4byte(btcoexist, reg_lp_txrx); + reg_lp_tx = u32tmp & MASKLWORD; + reg_lp_rx = (u32tmp & MASKHWORD) >> 16; + + coex_sta->high_priority_tx = reg_hp_tx; + coex_sta->high_priority_rx = reg_hp_rx; + coex_sta->low_priority_tx = reg_lp_tx; + coex_sta->low_priority_rx = reg_lp_rx; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, + "[BTCoex], High Priority Tx/Rx(reg 0x%x) = 0x%x(%d)/0x%x(%d)\n", + reg_hp_txrx, reg_hp_tx, reg_hp_tx, reg_hp_rx, reg_hp_rx); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, + "[BTCoex], Low Priority Tx/Rx(reg 0x%x) = 0x%x(%d)/0x%x(%d)\n", + reg_lp_txrx, reg_lp_tx, reg_lp_tx, reg_lp_rx, reg_lp_rx); + + /* reset counter */ + btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc); +} + +static void halbtc8723b2ant_query_bt_info(struct btc_coexist *btcoexist) +{ + u8 h2c_parameter[1] = {0}; + + coex_sta->c2h_bt_info_req_sent = true; + + h2c_parameter[0] |= BIT(0); /* trigger */ + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], Query Bt Info, FW write 0x61 = 0x%x\n", + h2c_parameter[0]); + + btcoexist->btc_fill_h2c(btcoexist, 0x61, 1, h2c_parameter); +} + +static bool is_wifi_status_changed(struct btc_coexist *btcoexist) +{ + static bool pre_wifi_busy; + static bool pre_under_4way; + static bool pre_bt_hs_on; + bool wifi_busy = false, under_4way = false, bt_hs_on = false; + bool wifi_connected = false; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, + &wifi_connected); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, + &under_4way); + + if (wifi_connected) { + if (wifi_busy != pre_wifi_busy) { + pre_wifi_busy = wifi_busy; + return true; + } + + if (under_4way != pre_under_4way) { + pre_under_4way = under_4way; + return true; + } + + if (bt_hs_on != pre_bt_hs_on) { + pre_bt_hs_on = bt_hs_on; + return true; + } + } + + return false; +} + +static void halbtc8723b2ant_update_bt_link_info(struct btc_coexist *btcoexist) +{ + /*struct btc_stack_info *stack_info = &btcoexist->stack_info;*/ + struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; + bool bt_hs_on = false; + +#if (BT_AUTO_REPORT_ONLY_8723B_2ANT == 1) /* profile from bt patch */ + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); + + bt_link_info->bt_link_exist = coex_sta->bt_link_exist; + bt_link_info->sco_exist = coex_sta->sco_exist; + bt_link_info->a2dp_exist = coex_sta->a2dp_exist; + bt_link_info->pan_exist = coex_sta->pan_exist; + bt_link_info->hid_exist = coex_sta->hid_exist; + + /* work around for HS mode. */ + if (bt_hs_on) { + bt_link_info->pan_exist = true; + bt_link_info->bt_link_exist = true; + } +#else /* profile from bt stack */ + bt_link_info->bt_link_exist = stack_info->bt_link_exist; + bt_link_info->sco_exist = stack_info->sco_exist; + bt_link_info->a2dp_exist = stack_info->a2dp_exist; + bt_link_info->pan_exist = stack_info->pan_exist; + bt_link_info->hid_exist = stack_info->hid_exist; + + /*for win-8 stack HID report error*/ + if (!stack_info->hid_exist) + stack_info->hid_exist = coex_sta->hid_exist; + /*sync BTInfo with BT firmware and stack*/ + /* when stack HID report error, here we use the info from bt fw.*/ + if (!stack_info->bt_link_exist) + stack_info->bt_link_exist = coex_sta->bt_link_exist; +#endif + /* check if Sco only */ + if (bt_link_info->sco_exist && !bt_link_info->a2dp_exist && + !bt_link_info->pan_exist && !bt_link_info->hid_exist) + bt_link_info->sco_only = true; + else + bt_link_info->sco_only = false; + + /* check if A2dp only */ + if (!bt_link_info->sco_exist && bt_link_info->a2dp_exist && + !bt_link_info->pan_exist && !bt_link_info->hid_exist) + bt_link_info->a2dp_only = true; + else + bt_link_info->a2dp_only = false; + + /* check if Pan only */ + if (!bt_link_info->sco_exist && !bt_link_info->a2dp_exist && + bt_link_info->pan_exist && !bt_link_info->hid_exist) + bt_link_info->pan_only = true; + else + bt_link_info->pan_only = false; + + /* check if Hid only */ + if (!bt_link_info->sco_exist && !bt_link_info->a2dp_exist && + !bt_link_info->pan_exist && bt_link_info->hid_exist) + bt_link_info->hid_only = true; + else + bt_link_info->hid_only = false; +} + +static u8 halbtc8723b2ant_action_algorithm(struct btc_coexist *btcoexist) +{ + struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; + bool bt_hs_on = false; + u8 algorithm = BT_8723B_2ANT_COEX_ALGO_UNDEFINED; + u8 num_of_diff_profile = 0; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); + + if (!bt_link_info->bt_link_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], No BT link exists!!!\n"); + return algorithm; + } + + if (bt_link_info->sco_exist) + num_of_diff_profile++; + if (bt_link_info->hid_exist) + num_of_diff_profile++; + if (bt_link_info->pan_exist) + num_of_diff_profile++; + if (bt_link_info->a2dp_exist) + num_of_diff_profile++; + + if (num_of_diff_profile == 1) { + if (bt_link_info->sco_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], SCO only\n"); + algorithm = BT_8723B_2ANT_COEX_ALGO_SCO; + } else { + if (bt_link_info->hid_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], HID only\n"); + algorithm = BT_8723B_2ANT_COEX_ALGO_HID; + } else if (bt_link_info->a2dp_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], A2DP only\n"); + algorithm = BT_8723B_2ANT_COEX_ALGO_A2DP; + } else if (bt_link_info->pan_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], PAN(HS) only\n"); + algorithm = + BT_8723B_2ANT_COEX_ALGO_PANHS; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], PAN(EDR) only\n"); + algorithm = + BT_8723B_2ANT_COEX_ALGO_PANEDR; + } + } + } + } else if (num_of_diff_profile == 2) { + if (bt_link_info->sco_exist) { + if (bt_link_info->hid_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], SCO + HID\n"); + algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; + } else if (bt_link_info->a2dp_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], SCO + A2DP ==> SCO\n"); + algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; + } else if (bt_link_info->pan_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], SCO + PAN(HS)\n"); + algorithm = BT_8723B_2ANT_COEX_ALGO_SCO; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], SCO + PAN(EDR)\n"); + algorithm = + BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; + } + } + } else { + if (bt_link_info->hid_exist && + bt_link_info->a2dp_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], HID + A2DP\n"); + algorithm = BT_8723B_2ANT_COEX_ALGO_HID_A2DP; + } else if (bt_link_info->hid_exist && + bt_link_info->pan_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], HID + PAN(HS)\n"); + algorithm = BT_8723B_2ANT_COEX_ALGO_HID; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], HID + PAN(EDR)\n"); + algorithm = + BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; + } + } else if (bt_link_info->pan_exist && + bt_link_info->a2dp_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], A2DP + PAN(HS)\n"); + algorithm = + BT_8723B_2ANT_COEX_ALGO_A2DP_PANHS; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], A2DP + PAN(EDR)\n"); + algorithm = + BT_8723B_2ANT_COEX_ALGO_PANEDR_A2DP; + } + } + } + } else if (num_of_diff_profile == 3) { + if (bt_link_info->sco_exist) { + if (bt_link_info->hid_exist && + bt_link_info->a2dp_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], SCO + HID + A2DP ==> HID\n"); + algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; + } else if (bt_link_info->hid_exist && + bt_link_info->pan_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], SCO + HID + PAN(HS)\n"); + algorithm = + BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], SCO + HID + PAN(EDR)\n"); + algorithm = + BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; + } + } else if (bt_link_info->pan_exist && + bt_link_info->a2dp_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], SCO + A2DP + PAN(HS)\n"); + algorithm = + BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n"); + algorithm = + BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; + } + } + } else { + if (bt_link_info->hid_exist && + bt_link_info->pan_exist && + bt_link_info->a2dp_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], HID + A2DP + PAN(HS)\n"); + algorithm = + BT_8723B_2ANT_COEX_ALGO_HID_A2DP; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], HID + A2DP + PAN(EDR)\n"); + algorithm = + BT_8723B_2ANT_COEX_ALGO_HID_A2DP_PANEDR; + } + } + } + } else if (num_of_diff_profile >= 3) { + if (bt_link_info->sco_exist) { + if (bt_link_info->hid_exist && + bt_link_info->pan_exist && + bt_link_info->a2dp_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n"); + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], SCO + HID + A2DP + PAN(EDR) ==>PAN(EDR)+HID\n"); + algorithm = + BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; + } + } + } + } + + return algorithm; +} + +static bool halbtc8723b2ant_need_to_dec_bt_pwr(struct btc_coexist *btcoexist) +{ + bool ret = false; + bool bt_hs_on = false, wifi_connected = false; + s32 bt_hs_rssi = 0; + u8 bt_rssi_state; + + if (!btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, + &bt_hs_on)) + return false; + if (!btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, + &wifi_connected)) + return false; + if (!btcoexist->btc_get(btcoexist, BTC_GET_S4_HS_RSSI, + &bt_hs_rssi)) + return false; + + bt_rssi_state = halbtc8723b2ant_bt_rssi_state(2, 29, 0); + + if (wifi_connected) { + if (bt_hs_on) { + if (bt_hs_rssi > 37) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, + "[BTCoex], Need to decrease bt power for HS mode!!\n"); + ret = true; + } + } else { + if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || + (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, + "[BTCoex], Need to decrease bt power for Wifi is connected!!\n"); + ret = true; + } + } + } + + return ret; +} + +static void set_fw_dac_swing_level(struct btc_coexist *btcoexist, + u8 dac_swing_lvl) +{ + u8 h2c_parameter[1] = {0}; + + /* There are several type of dacswing + * 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6 */ + h2c_parameter[0] = dac_swing_lvl; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], Set Dac Swing Level = 0x%x\n", dac_swing_lvl); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], FW write 0x64 = 0x%x\n", h2c_parameter[0]); + + btcoexist->btc_fill_h2c(btcoexist, 0x64, 1, h2c_parameter); +} + +static void halbtc8723b2ant_set_fw_dec_bt_pwr(struct btc_coexist *btcoexist, + bool dec_bt_pwr) +{ + u8 h2c_parameter[1] = {0}; + + h2c_parameter[0] = 0; + + if (dec_bt_pwr) + h2c_parameter[0] |= BIT(1); + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], decrease Bt Power : %s, FW write 0x62 = 0x%x\n", + (dec_bt_pwr ? "Yes!!" : "No!!"), h2c_parameter[0]); + + btcoexist->btc_fill_h2c(btcoexist, 0x62, 1, h2c_parameter); +} + +static void halbtc8723b2ant_dec_bt_pwr(struct btc_coexist *btcoexist, + bool force_exec, bool dec_bt_pwr) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, + "[BTCoex], %s Dec BT power = %s\n", + (force_exec ? "force to" : ""), (dec_bt_pwr ? "ON" : "OFF")); + coex_dm->cur_dec_bt_pwr = dec_bt_pwr; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], bPreDecBtPwr =%d, bCurDecBtPwr =%d\n", + coex_dm->pre_dec_bt_pwr, coex_dm->cur_dec_bt_pwr); + + if (coex_dm->pre_dec_bt_pwr == coex_dm->cur_dec_bt_pwr) + return; + } + halbtc8723b2ant_set_fw_dec_bt_pwr(btcoexist, coex_dm->cur_dec_bt_pwr); + + coex_dm->pre_dec_bt_pwr = coex_dm->cur_dec_bt_pwr; +} + +static void halbtc8723b2ant_fw_dac_swing_lvl(struct btc_coexist *btcoexist, + bool force_exec, + u8 fw_dac_swing_lvl) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, + "[BTCoex], %s set FW Dac Swing level = %d\n", + (force_exec ? "force to" : ""), fw_dac_swing_lvl); + coex_dm->cur_fw_dac_swing_lvl = fw_dac_swing_lvl; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], preFwDacSwingLvl =%d, curFwDacSwingLvl =%d\n", + coex_dm->pre_fw_dac_swing_lvl, + coex_dm->cur_fw_dac_swing_lvl); + + if (coex_dm->pre_fw_dac_swing_lvl == + coex_dm->cur_fw_dac_swing_lvl) + return; + } + + set_fw_dac_swing_level(btcoexist, coex_dm->cur_fw_dac_swing_lvl); + coex_dm->pre_fw_dac_swing_lvl = coex_dm->cur_fw_dac_swing_lvl; +} + +static void set_sw_rf_rx_lpf_corner(struct btc_coexist *btcoexist, + bool rx_rf_shrink_on) +{ + if (rx_rf_shrink_on) { + /* Shrink RF Rx LPF corner */ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], Shrink RF Rx LPF corner!!\n"); + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1e, + 0xfffff, 0xffffc); + } else { + /* Resume RF Rx LPF corner */ + /* After initialized, we can use coex_dm->btRf0x1eBackup */ + if (btcoexist->initilized) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], Resume RF Rx LPF corner!!\n"); + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1e, + 0xfffff, + coex_dm->bt_rf0x1e_backup); + } + } +} + +static void halbtc8723b2ant_rf_shrink(struct btc_coexist *btcoexist, + bool force_exec, bool rx_rf_shrink_on) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, + "[BTCoex], %s turn Rx RF Shrink = %s\n", + (force_exec ? "force to" : ""), + (rx_rf_shrink_on ? "ON" : "OFF")); + coex_dm->cur_rf_rx_lpf_shrink = rx_rf_shrink_on; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, + "[BTCoex], bPreRfRxLpfShrink =%d, bCurRfRxLpfShrink =%d\n", + coex_dm->pre_rf_rx_lpf_shrink, + coex_dm->cur_rf_rx_lpf_shrink); + + if (coex_dm->pre_rf_rx_lpf_shrink == + coex_dm->cur_rf_rx_lpf_shrink) + return; + } + set_sw_rf_rx_lpf_corner(btcoexist, coex_dm->cur_rf_rx_lpf_shrink); + + coex_dm->pre_rf_rx_lpf_shrink = coex_dm->cur_rf_rx_lpf_shrink; +} + +static void set_sw_penalty_txrate_adaptive( + struct btc_coexist *btcoexist, + bool low_penalty_ra) +{ + u8 h2c_parameter[6] = {0}; + + h2c_parameter[0] = 0x6; /* opCode, 0x6 = Retry_Penalty*/ + + if (low_penalty_ra) { + h2c_parameter[1] |= BIT(0); + /*normal rate except MCS7/6/5, OFDM54/48/36*/ + h2c_parameter[2] = 0x00; + h2c_parameter[3] = 0xf7; /*MCS7 or OFDM54*/ + h2c_parameter[4] = 0xf8; /*MCS6 or OFDM48*/ + h2c_parameter[5] = 0xf9; /*MCS5 or OFDM36*/ + } + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], set WiFi Low-Penalty Retry: %s", + (low_penalty_ra ? "ON!!" : "OFF!!")); + + btcoexist->btc_fill_h2c(btcoexist, 0x69, 6, h2c_parameter); +} + +static void halbtc8723b2ant_low_penalty_ra(struct btc_coexist *btcoexist, + bool force_exec, bool low_penalty_ra) +{ + /*return; */ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, + "[BTCoex], %s turn LowPenaltyRA = %s\n", + (force_exec ? "force to" : ""), + (low_penalty_ra ? "ON" : "OFF")); + coex_dm->cur_low_penalty_ra = low_penalty_ra; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, + "[BTCoex], bPreLowPenaltyRa =%d, bCurLowPenaltyRa =%d\n", + coex_dm->pre_low_penalty_ra, + coex_dm->cur_low_penalty_ra); + + if (coex_dm->pre_low_penalty_ra == coex_dm->cur_low_penalty_ra) + return; + } + set_sw_penalty_txrate_adaptive(btcoexist, coex_dm->cur_low_penalty_ra); + + coex_dm->pre_low_penalty_ra = coex_dm->cur_low_penalty_ra; +} + +static void halbtc8723b2ant_set_dac_swing_reg(struct btc_coexist *btcoexist, + u32 level) +{ + u8 val = (u8) level; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], Write SwDacSwing = 0x%x\n", level); + btcoexist->btc_write_1byte_bitmask(btcoexist, 0x883, 0x3e, val); +} + +static void set_sw_fulltime_dac_swing(struct btc_coexist *btcoexist, + bool sw_dac_swing_on, + u32 sw_dac_swing_lvl) +{ + if (sw_dac_swing_on) + halbtc8723b2ant_set_dac_swing_reg(btcoexist, sw_dac_swing_lvl); + else + halbtc8723b2ant_set_dac_swing_reg(btcoexist, 0x18); +} + +static void halbtc8723b2ant_dac_swing(struct btc_coexist *btcoexist, + bool force_exec, bool dac_swing_on, + u32 dac_swing_lvl) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, + "[BTCoex], %s turn DacSwing =%s, dac_swing_lvl = 0x%x\n", + (force_exec ? "force to" : ""), + (dac_swing_on ? "ON" : "OFF"), dac_swing_lvl); + coex_dm->cur_dac_swing_on = dac_swing_on; + coex_dm->cur_dac_swing_lvl = dac_swing_lvl; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, + "[BTCoex], bPreDacSwingOn =%d, preDacSwingLvl = 0x%x, bCurDacSwingOn =%d, curDacSwingLvl = 0x%x\n", + coex_dm->pre_dac_swing_on, coex_dm->pre_dac_swing_lvl, + coex_dm->cur_dac_swing_on, + coex_dm->cur_dac_swing_lvl); + + if ((coex_dm->pre_dac_swing_on == coex_dm->cur_dac_swing_on) && + (coex_dm->pre_dac_swing_lvl == coex_dm->cur_dac_swing_lvl)) + return; + } + mdelay(30); + set_sw_fulltime_dac_swing(btcoexist, dac_swing_on, + dac_swing_lvl); + + coex_dm->pre_dac_swing_on = coex_dm->cur_dac_swing_on; + coex_dm->pre_dac_swing_lvl = coex_dm->cur_dac_swing_lvl; +} + +static void halbtc8723b2ant_set_agc_table(struct btc_coexist *btcoexist, + bool agc_table_en) +{ + u8 rssi_adjust_val = 0; + + /* BB AGC Gain Table */ + if (agc_table_en) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], BB Agc Table On!\n"); + btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x6e1A0001); + btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x6d1B0001); + btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x6c1C0001); + btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x6b1D0001); + btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x6a1E0001); + btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x691F0001); + btcoexist->btc_write_4byte(btcoexist, 0xc78, 0x68200001); + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], BB Agc Table Off!\n"); + btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xaa1A0001); + btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa91B0001); + btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa81C0001); + btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa71D0001); + btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa61E0001); + btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa51F0001); + btcoexist->btc_write_4byte(btcoexist, 0xc78, 0xa4200001); + } + + /* RF Gain */ + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0xef, 0xfffff, 0x02000); + if (agc_table_en) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], Agc Table On!\n"); + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x3b, + 0xfffff, 0x38fff); + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x3b, + 0xfffff, 0x38ffe); + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], Agc Table Off!\n"); + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x3b, + 0xfffff, 0x380c3); + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x3b, + 0xfffff, 0x28ce6); + } + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0xef, 0xfffff, 0x0); + + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0xed, 0xfffff, 0x1); + + if (agc_table_en) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], Agc Table On!\n"); + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x40, + 0xfffff, 0x38fff); + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x40, + 0xfffff, 0x38ffe); + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], Agc Table Off!\n"); + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x40, + 0xfffff, 0x380c3); + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x40, + 0xfffff, 0x28ce6); + } + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0xed, 0xfffff, 0x0); + + /* set rssiAdjustVal for wifi module. */ + if (agc_table_en) + rssi_adjust_val = 8; + btcoexist->btc_set(btcoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, + &rssi_adjust_val); +} + +static void halbtc8723b2ant_agc_table(struct btc_coexist *btcoexist, + bool force_exec, bool agc_table_en) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, + "[BTCoex], %s %s Agc Table\n", + (force_exec ? "force to" : ""), + (agc_table_en ? "Enable" : "Disable")); + coex_dm->cur_agc_table_en = agc_table_en; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, + "[BTCoex], bPreAgcTableEn =%d, bCurAgcTableEn =%d\n", + coex_dm->pre_agc_table_en, coex_dm->cur_agc_table_en); + + if (coex_dm->pre_agc_table_en == coex_dm->cur_agc_table_en) + return; + } + halbtc8723b2ant_set_agc_table(btcoexist, agc_table_en); + + coex_dm->pre_agc_table_en = coex_dm->cur_agc_table_en; +} + +static void halbtc8723b2ant_set_coex_table(struct btc_coexist *btcoexist, + u32 val0x6c0, u32 val0x6c4, + u32 val0x6c8, u8 val0x6cc) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], set coex table, set 0x6c0 = 0x%x\n", val0x6c0); + btcoexist->btc_write_4byte(btcoexist, 0x6c0, val0x6c0); + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], set coex table, set 0x6c4 = 0x%x\n", val0x6c4); + btcoexist->btc_write_4byte(btcoexist, 0x6c4, val0x6c4); + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], set coex table, set 0x6c8 = 0x%x\n", val0x6c8); + btcoexist->btc_write_4byte(btcoexist, 0x6c8, val0x6c8); + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], set coex table, set 0x6cc = 0x%x\n", val0x6cc); + btcoexist->btc_write_1byte(btcoexist, 0x6cc, val0x6cc); +} + +static void halbtc8723b2ant_coex_table(struct btc_coexist *btcoexist, + bool force_exec, u32 val0x6c0, + u32 val0x6c4, u32 val0x6c8, + u8 val0x6cc) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, + "[BTCoex], %s write Coex Table 0x6c0 = 0x%x, 0x6c4 = 0x%x, 0x6c8 = 0x%x, 0x6cc = 0x%x\n", + (force_exec ? "force to" : ""), val0x6c0, + val0x6c4, val0x6c8, val0x6cc); + coex_dm->cur_val0x6c0 = val0x6c0; + coex_dm->cur_val0x6c4 = val0x6c4; + coex_dm->cur_val0x6c8 = val0x6c8; + coex_dm->cur_val0x6cc = val0x6cc; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, + "[BTCoex], preVal0x6c0 = 0x%x, preVal0x6c4 = 0x%x, preVal0x6c8 = 0x%x, preVal0x6cc = 0x%x !!\n", + coex_dm->pre_val0x6c0, coex_dm->pre_val0x6c4, + coex_dm->pre_val0x6c8, coex_dm->pre_val0x6cc); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, + "[BTCoex], curVal0x6c0 = 0x%x, curVal0x6c4 = 0x%x, curVal0x6c8 = 0x%x, curVal0x6cc = 0x%x !!\n", + coex_dm->cur_val0x6c0, coex_dm->cur_val0x6c4, + coex_dm->cur_val0x6c8, coex_dm->cur_val0x6cc); + + if ((coex_dm->pre_val0x6c0 == coex_dm->cur_val0x6c0) && + (coex_dm->pre_val0x6c4 == coex_dm->cur_val0x6c4) && + (coex_dm->pre_val0x6c8 == coex_dm->cur_val0x6c8) && + (coex_dm->pre_val0x6cc == coex_dm->cur_val0x6cc)) + return; + } + halbtc8723b2ant_set_coex_table(btcoexist, val0x6c0, val0x6c4, + val0x6c8, val0x6cc); + + coex_dm->pre_val0x6c0 = coex_dm->cur_val0x6c0; + coex_dm->pre_val0x6c4 = coex_dm->cur_val0x6c4; + coex_dm->pre_val0x6c8 = coex_dm->cur_val0x6c8; + coex_dm->pre_val0x6cc = coex_dm->cur_val0x6cc; +} + +static void coex_table_with_type(struct btc_coexist *btcoexist, + bool force_exec, u8 type) +{ + switch (type) { + case 0: + halbtc8723b2ant_coex_table(btcoexist, force_exec, 0x55555555, + 0x55555555, 0xffff, 0x3); + break; + case 1: + halbtc8723b2ant_coex_table(btcoexist, force_exec, 0x55555555, + 0x5afa5afa, 0xffff, 0x3); + break; + case 2: + halbtc8723b2ant_coex_table(btcoexist, force_exec, 0x5a5a5a5a, + 0x5a5a5a5a, 0xffff, 0x3); + break; + case 3: + halbtc8723b2ant_coex_table(btcoexist, force_exec, 0xaaaaaaaa, + 0xaaaaaaaa, 0xffff, 0x3); + break; + case 4: + halbtc8723b2ant_coex_table(btcoexist, force_exec, 0xffffffff, + 0xffffffff, 0xffff, 0x3); + break; + case 5: + halbtc8723b2ant_coex_table(btcoexist, force_exec, 0x5fff5fff, + 0x5fff5fff, 0xffff, 0x3); + break; + case 6: + halbtc8723b2ant_coex_table(btcoexist, force_exec, 0x55ff55ff, + 0x5a5a5a5a, 0xffff, 0x3); + break; + case 7: + halbtc8723b2ant_coex_table(btcoexist, force_exec, 0x55ff55ff, + 0x5afa5afa, 0xffff, 0x3); + break; + case 8: + halbtc8723b2ant_coex_table(btcoexist, force_exec, 0x5aea5aea, + 0x5aea5aea, 0xffff, 0x3); + break; + case 9: + halbtc8723b2ant_coex_table(btcoexist, force_exec, 0x55ff55ff, + 0x5aea5aea, 0xffff, 0x3); + break; + case 10: + halbtc8723b2ant_coex_table(btcoexist, force_exec, 0x55ff55ff, + 0x5aff5aff, 0xffff, 0x3); + break; + case 11: + halbtc8723b2ant_coex_table(btcoexist, force_exec, 0x55ff55ff, + 0x5a5f5a5f, 0xffff, 0x3); + break; + case 12: + halbtc8723b2ant_coex_table(btcoexist, force_exec, 0x55ff55ff, + 0x5f5f5f5f, 0xffff, 0x3); + break; + default: + break; + } +} + +static void set_fw_ignore_wlan_act(struct btc_coexist *btcoexist, + bool enable) +{ + u8 h2c_parameter[1] = {0}; + + if (enable) + h2c_parameter[0] |= BIT(0);/* function enable*/ + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63 = 0x%x\n", + h2c_parameter[0]); + + btcoexist->btc_fill_h2c(btcoexist, 0x63, 1, h2c_parameter); +} + +static void halbtc8723b2ant_ignore_wlan_act(struct btc_coexist *btcoexist, + bool force_exec, bool enable) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, + "[BTCoex], %s turn Ignore WlanAct %s\n", + (force_exec ? "force to" : ""), (enable ? "ON" : "OFF")); + coex_dm->cur_ignore_wlan_act = enable; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], bPreIgnoreWlanAct = %d, bCurIgnoreWlanAct = %d!!\n", + coex_dm->pre_ignore_wlan_act, + coex_dm->cur_ignore_wlan_act); + + if (coex_dm->pre_ignore_wlan_act == + coex_dm->cur_ignore_wlan_act) + return; + } + set_fw_ignore_wlan_act(btcoexist, enable); + + coex_dm->pre_ignore_wlan_act = coex_dm->cur_ignore_wlan_act; +} + +static void set_fw_ps_tdma(struct btc_coexist *btcoexist, u8 byte1, + u8 byte2, u8 byte3, u8 byte4, u8 byte5) +{ + u8 h2c_parameter[5] = {0}; + + h2c_parameter[0] = byte1; + h2c_parameter[1] = byte2; + h2c_parameter[2] = byte3; + h2c_parameter[3] = byte4; + h2c_parameter[4] = byte5; + + coex_dm->ps_tdma_para[0] = byte1; + coex_dm->ps_tdma_para[1] = byte2; + coex_dm->ps_tdma_para[2] = byte3; + coex_dm->ps_tdma_para[3] = byte4; + coex_dm->ps_tdma_para[4] = byte5; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], FW write 0x60(5bytes) = 0x%x%08x\n", + h2c_parameter[0], + h2c_parameter[1] << 24 | h2c_parameter[2] << 16 | + h2c_parameter[3] << 8 | h2c_parameter[4]); + + btcoexist->btc_fill_h2c(btcoexist, 0x60, 5, h2c_parameter); +} + +static void halbtc8723b2ant_sw_mechanism1(struct btc_coexist *btcoexist, + bool shrink_rx_lpf, + bool low_penalty_ra, + bool limited_dig, + bool bt_lna_constrain) +{ + halbtc8723b2ant_rf_shrink(btcoexist, NORMAL_EXEC, shrink_rx_lpf); + halbtc8723b2ant_low_penalty_ra(btcoexist, NORMAL_EXEC, low_penalty_ra); +} + +static void halbtc8723b2ant_sw_mechanism2(struct btc_coexist *btcoexist, + bool agc_table_shift, + bool adc_backoff, + bool sw_dac_swing, u32 dac_swing_lvl) +{ + halbtc8723b2ant_agc_table(btcoexist, NORMAL_EXEC, agc_table_shift); + halbtc8723b2ant_dac_swing(btcoexist, NORMAL_EXEC, sw_dac_swing, + dac_swing_lvl); +} + +static void halbtc8723b2ant_set_ant_path(struct btc_coexist *btcoexist, + u8 antpos_type, bool init_hwcfg, + bool wifi_off) +{ + struct btc_board_info *board_info = &btcoexist->board_info; + u32 fw_ver = 0, u32tmp = 0; + bool pg_ext_switch = false; + bool use_ext_switch = false; + u8 h2c_parameter[2] = {0}; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_EXT_SWITCH, &pg_ext_switch); + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver); + + if ((fw_ver < 0xc0000) || pg_ext_switch) + use_ext_switch = true; + + if (init_hwcfg) { + /* 0x4c[23] = 0, 0x4c[24] = 1 Antenna control by WL/BT */ + u32tmp = btcoexist->btc_read_4byte(btcoexist, 0x4c); + u32tmp &= ~BIT(23); + u32tmp |= BIT(24); + btcoexist->btc_write_4byte(btcoexist, 0x4c, u32tmp); + + btcoexist->btc_write_1byte(btcoexist, 0x974, 0xff); + btcoexist->btc_write_1byte_bitmask(btcoexist, 0x944, 0x3, 0x3); + btcoexist->btc_write_1byte(btcoexist, 0x930, 0x77); + btcoexist->btc_write_1byte_bitmask(btcoexist, 0x67, 0x20, 0x1); + + /* Force GNT_BT to low */ + btcoexist->btc_write_1byte_bitmask(btcoexist, 0x765, 0x18, 0x0); + btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0); + + if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) { + /* tell firmware "no antenna inverse" */ + h2c_parameter[0] = 0; + h2c_parameter[1] = 1; /* ext switch type */ + btcoexist->btc_fill_h2c(btcoexist, 0x65, 2, + h2c_parameter); + } else { + /* tell firmware "antenna inverse" */ + h2c_parameter[0] = 1; + h2c_parameter[1] = 1; /* ext switch type */ + btcoexist->btc_fill_h2c(btcoexist, 0x65, 2, + h2c_parameter); + } + } + + /* ext switch setting */ + if (use_ext_switch) { + /* fixed internal switch S1->WiFi, S0->BT */ + btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0); + switch (antpos_type) { + case BTC_ANT_WIFI_AT_MAIN: + /* ext switch main at wifi */ + btcoexist->btc_write_1byte_bitmask(btcoexist, 0x92c, + 0x3, 0x1); + break; + case BTC_ANT_WIFI_AT_AUX: + /* ext switch aux at wifi */ + btcoexist->btc_write_1byte_bitmask(btcoexist, + 0x92c, 0x3, 0x2); + break; + } + } else { /* internal switch */ + /* fixed ext switch */ + btcoexist->btc_write_1byte_bitmask(btcoexist, 0x92c, 0x3, 0x1); + switch (antpos_type) { + case BTC_ANT_WIFI_AT_MAIN: + /* fixed internal switch S1->WiFi, S0->BT */ + btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0); + break; + case BTC_ANT_WIFI_AT_AUX: + /* fixed internal switch S0->WiFi, S1->BT */ + btcoexist->btc_write_2byte(btcoexist, 0x948, 0x280); + break; + } + } +} + +static void halbtc8723b2ant_ps_tdma(struct btc_coexist *btcoexist, + bool force_exec, bool turn_on, u8 type) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, + "[BTCoex], %s turn %s PS TDMA, type =%d\n", + (force_exec ? "force to" : ""), + (turn_on ? "ON" : "OFF"), type); + coex_dm->cur_ps_tdma_on = turn_on; + coex_dm->cur_ps_tdma = type; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], bPrePsTdmaOn = %d, bCurPsTdmaOn = %d!!\n", + coex_dm->pre_ps_tdma_on, coex_dm->cur_ps_tdma_on); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], prePsTdma = %d, curPsTdma = %d!!\n", + coex_dm->pre_ps_tdma, coex_dm->cur_ps_tdma); + + if ((coex_dm->pre_ps_tdma_on == coex_dm->cur_ps_tdma_on) && + (coex_dm->pre_ps_tdma == coex_dm->cur_ps_tdma)) + return; + } + if (turn_on) { + switch (type) { + case 1: + default: + set_fw_ps_tdma(btcoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90); + break; + case 2: + set_fw_ps_tdma(btcoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90); + break; + case 3: + set_fw_ps_tdma(btcoexist, 0xe3, 0x1c, 0x3, 0xf1, 0x90); + break; + case 4: + set_fw_ps_tdma(btcoexist, 0xe3, 0x10, 0x03, 0xf1, 0x90); + break; + case 5: + set_fw_ps_tdma(btcoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x90); + break; + case 6: + set_fw_ps_tdma(btcoexist, 0xe3, 0x12, 0x12, 0x60, 0x90); + break; + case 7: + set_fw_ps_tdma(btcoexist, 0xe3, 0x1c, 0x3, 0x70, 0x90); + break; + case 8: + set_fw_ps_tdma(btcoexist, 0xa3, 0x10, 0x3, 0x70, 0x90); + break; + case 9: + set_fw_ps_tdma(btcoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90); + break; + case 10: + set_fw_ps_tdma(btcoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90); + break; + case 11: + set_fw_ps_tdma(btcoexist, 0xe3, 0xa, 0xa, 0xe1, 0x90); + break; + case 12: + set_fw_ps_tdma(btcoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90); + break; + case 13: + set_fw_ps_tdma(btcoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x90); + break; + case 14: + set_fw_ps_tdma(btcoexist, 0xe3, 0x12, 0x12, 0x60, 0x90); + break; + case 15: + set_fw_ps_tdma(btcoexist, 0xe3, 0xa, 0xa, 0x60, 0x90); + break; + case 16: + set_fw_ps_tdma(btcoexist, 0xe3, 0x5, 0x5, 0x60, 0x90); + break; + case 17: + set_fw_ps_tdma(btcoexist, 0xa3, 0x2f, 0x2f, 0x60, 0x90); + break; + case 18: + set_fw_ps_tdma(btcoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90); + break; + case 19: + set_fw_ps_tdma(btcoexist, 0xe3, 0x25, 0x25, 0xe1, 0x90); + break; + case 20: + set_fw_ps_tdma(btcoexist, 0xe3, 0x25, 0x25, 0x60, 0x90); + break; + case 21: + set_fw_ps_tdma(btcoexist, 0xe3, 0x15, 0x03, 0x70, 0x90); + break; + case 71: + set_fw_ps_tdma(btcoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90); + break; + } + } else { + /* disable PS tdma */ + switch (type) { + case 0: + set_fw_ps_tdma(btcoexist, 0x0, 0x0, 0x0, 0x40, 0x0); + break; + case 1: + set_fw_ps_tdma(btcoexist, 0x0, 0x0, 0x0, 0x48, 0x0); + break; + default: + set_fw_ps_tdma(btcoexist, 0x0, 0x0, 0x0, 0x40, 0x0); + break; + } + } + + /* update pre state */ + coex_dm->pre_ps_tdma_on = coex_dm->cur_ps_tdma_on; + coex_dm->pre_ps_tdma = coex_dm->cur_ps_tdma; +} + +static void halbtc8723b2ant_coex_alloff(struct btc_coexist *btcoexist) +{ + /* fw all off */ + halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1); + halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); + halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + + /* sw all off */ + halbtc8723b2ant_sw_mechanism1(btcoexist, false, false, false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, false, 0x18); + + /* hw all off */ + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); + coex_table_with_type(btcoexist, NORMAL_EXEC, 0); +} + +static void halbtc8723b2ant_init_coex_dm(struct btc_coexist *btcoexist) +{ + /* force to reset coex mechanism*/ + + halbtc8723b2ant_ps_tdma(btcoexist, FORCE_EXEC, false, 1); + halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, FORCE_EXEC, 6); + halbtc8723b2ant_dec_bt_pwr(btcoexist, FORCE_EXEC, false); + + halbtc8723b2ant_sw_mechanism1(btcoexist, false, false, false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, false, 0x18); +} + +static void halbtc8723b2ant_action_bt_inquiry(struct btc_coexist *btcoexist) +{ + bool wifi_connected = false; + bool low_pwr_disable = true; + + btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, + &low_pwr_disable); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, + &wifi_connected); + + if (wifi_connected) { + coex_table_with_type(btcoexist, NORMAL_EXEC, 7); + halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 3); + } else { + coex_table_with_type(btcoexist, NORMAL_EXEC, 0); + halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1); + } + halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, FORCE_EXEC, 6); + halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + + halbtc8723b2ant_sw_mechanism1(btcoexist, false, false, false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, false, 0x18); + + coex_dm->need_recover_0x948 = true; + coex_dm->backup_0x948 = btcoexist->btc_read_2byte(btcoexist, 0x948); + + halbtc8723b2ant_set_ant_path(btcoexist, BTC_ANT_WIFI_AT_AUX, + false, false); +} + +static bool halbtc8723b2ant_is_common_action(struct btc_coexist *btcoexist) +{ + bool common = false, wifi_connected = false; + bool wifi_busy = false; + bool bt_hs_on = false, low_pwr_disable = false; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, + &wifi_connected); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); + + if (!wifi_connected) { + low_pwr_disable = false; + btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, + &low_pwr_disable); + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Wifi non-connected idle!!\n"); + + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, + 0x0); + coex_table_with_type(btcoexist, NORMAL_EXEC, 0); + halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1); + halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); + halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + + halbtc8723b2ant_sw_mechanism1(btcoexist, false, false, false, + false); + halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, false, + 0x18); + + common = true; + } else { + if (BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE == + coex_dm->bt_status) { + low_pwr_disable = false; + btcoexist->btc_set(btcoexist, + BTC_SET_ACT_DISABLE_LOW_POWER, + &low_pwr_disable); + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Wifi connected + BT non connected-idle!!\n"); + + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, + 0xfffff, 0x0); + coex_table_with_type(btcoexist, + NORMAL_EXEC, 0); + halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, + 1); + halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, + 0xb); + halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, + false); + + halbtc8723b2ant_sw_mechanism1(btcoexist, false, false, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, + false, 0x18); + + common = true; + } else if (BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE == + coex_dm->bt_status) { + low_pwr_disable = true; + btcoexist->btc_set(btcoexist, + BTC_SET_ACT_DISABLE_LOW_POWER, + &low_pwr_disable); + + if (bt_hs_on) + return false; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Wifi connected + BT connected-idle!!\n"); + + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, + 0xfffff, 0x0); + coex_table_with_type(btcoexist, + NORMAL_EXEC, 0); + halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, + 1); + halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, + 0xb); + halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, + false); + + halbtc8723b2ant_sw_mechanism1(btcoexist, true, false, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, + false, 0x18); + + common = true; + } else { + low_pwr_disable = true; + btcoexist->btc_set(btcoexist, + BTC_SET_ACT_DISABLE_LOW_POWER, + &low_pwr_disable); + + if (wifi_busy) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Wifi Connected-Busy + BT Busy!!\n"); + common = false; + } else { + if (bt_hs_on) + return false; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Wifi Connected-Idle + BT Busy!!\n"); + + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, + 0x1, 0xfffff, 0x0); + coex_table_with_type(btcoexist, + NORMAL_EXEC, 7); + halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, + true, 21); + halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, + NORMAL_EXEC, + 0xb); + if (halbtc8723b2ant_need_to_dec_bt_pwr(btcoexist)) + halbtc8723b2ant_dec_bt_pwr(btcoexist, + NORMAL_EXEC, + true); + else + halbtc8723b2ant_dec_bt_pwr(btcoexist, + NORMAL_EXEC, + false); + halbtc8723b2ant_sw_mechanism1(btcoexist, false, + false, false, + false); + halbtc8723b2ant_sw_mechanism2(btcoexist, false, + false, false, + 0x18); + common = true; + } + } + } + + return common; +} +static void halbtc8723b2ant_tdma_duration_adjust(struct btc_coexist *btcoexist, + bool sco_hid, bool tx_pause, + u8 max_interval) +{ + static s32 up, dn, m, n, wait_count; + /*0: no change, +1: increase WiFi duration, -1: decrease WiFi duration*/ + s32 result; + u8 retrycount = 0; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, + "[BTCoex], TdmaDurationAdjust()\n"); + + if (!coex_dm->auto_tdma_adjust) { + coex_dm->auto_tdma_adjust = true; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], first run TdmaDurationAdjust()!!\n"); + if (sco_hid) { + if (tx_pause) { + if (max_interval == 1) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 13); + coex_dm->ps_tdma_du_adj_type = 13; + } else if (max_interval == 2) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 14); + coex_dm->ps_tdma_du_adj_type = 14; + } else if (max_interval == 3) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } else { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } + } else { + if (max_interval == 1) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 9); + coex_dm->ps_tdma_du_adj_type = 9; + } else if (max_interval == 2) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 10); + coex_dm->ps_tdma_du_adj_type = 10; + } else if (max_interval == 3) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } else { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } + } + } else { + if (tx_pause) { + if (max_interval == 1) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 5); + coex_dm->ps_tdma_du_adj_type = 5; + } else if (max_interval == 2) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 6); + coex_dm->ps_tdma_du_adj_type = 6; + } else if (max_interval == 3) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } else { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } + } else { + if (max_interval == 1) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 1); + coex_dm->ps_tdma_du_adj_type = 1; + } else if (max_interval == 2) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 2); + coex_dm->ps_tdma_du_adj_type = 2; + } else if (max_interval == 3) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } else { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } + } + } + + up = 0; + dn = 0; + m = 1; + n = 3; + result = 0; + wait_count = 0; + } else { + /*accquire the BT TRx retry count from BT_Info byte2*/ + retrycount = coex_sta->bt_retry_cnt; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], retrycount = %d\n", retrycount); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], up =%d, dn =%d, m =%d, n =%d, wait_count =%d\n", + up, dn, m, n, wait_count); + result = 0; + wait_count++; + /* no retry in the last 2-second duration*/ + if (retrycount == 0) { + up++; + dn--; + + if (dn <= 0) + dn = 0; + + if (up >= n) { + wait_count = 0; + n = 3; + up = 0; + dn = 0; + result = 1; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_TRACE_FW_DETAIL, + "[BTCoex], Increase wifi duration!!\n"); + } /* <= 3 retry in the last 2-second duration*/ + } else if (retrycount <= 3) { + up--; + dn++; + + if (up <= 0) + up = 0; + + if (dn == 2) { + if (wait_count <= 2) + m++; + else + m = 1; + + if (m >= 20) + m = 20; + + n = 3 * m; + up = 0; + dn = 0; + wait_count = 0; + result = -1; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_TRACE_FW_DETAIL, + "[BTCoex], Decrease wifi duration for retrycounter<3!!\n"); + } + } else { + if (wait_count == 1) + m++; + else + m = 1; + + if (m >= 20) + m = 20; + + n = 3 * m; + up = 0; + dn = 0; + wait_count = 0; + result = -1; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], Decrease wifi duration for retrycounter>3!!\n"); + } + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], max Interval = %d\n", max_interval); + if (max_interval == 1) { + if (tx_pause) { + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_TRACE_FW_DETAIL, + "[BTCoex], TxPause = 1\n"); + + if (coex_dm->cur_ps_tdma == 71) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 5); + coex_dm->ps_tdma_du_adj_type = 5; + } else if (coex_dm->cur_ps_tdma == 1) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 5); + coex_dm->ps_tdma_du_adj_type = 5; + } else if (coex_dm->cur_ps_tdma == 2) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 6); + coex_dm->ps_tdma_du_adj_type = 6; + } else if (coex_dm->cur_ps_tdma == 3) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } else if (coex_dm->cur_ps_tdma == 4) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 8); + coex_dm->ps_tdma_du_adj_type = 8; + } + + if (coex_dm->cur_ps_tdma == 9) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 13); + coex_dm->ps_tdma_du_adj_type = 13; + } else if (coex_dm->cur_ps_tdma == 10) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 14); + coex_dm->ps_tdma_du_adj_type = 14; + } else if (coex_dm->cur_ps_tdma == 11) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } else if (coex_dm->cur_ps_tdma == 12) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 16); + coex_dm->ps_tdma_du_adj_type = 16; + } + + if (result == -1) { + if (coex_dm->cur_ps_tdma == 5) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 6); + coex_dm->ps_tdma_du_adj_type = + 6; + } else if (coex_dm->cur_ps_tdma == 6) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = + 7; + } else if (coex_dm->cur_ps_tdma == 7) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 8); + coex_dm->ps_tdma_du_adj_type = + 8; + } else if (coex_dm->cur_ps_tdma == 13) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 14); + coex_dm->ps_tdma_du_adj_type = + 14; + } else if (coex_dm->cur_ps_tdma == 14) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = + 15; + } else if (coex_dm->cur_ps_tdma == 15) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 16); + coex_dm->ps_tdma_du_adj_type = + 16; + } + } else if (result == 1) { + if (coex_dm->cur_ps_tdma == 8) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = + 7; + } else if (coex_dm->cur_ps_tdma == 7) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 6); + coex_dm->ps_tdma_du_adj_type = + 6; + } else if (coex_dm->cur_ps_tdma == 6) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 5); + coex_dm->ps_tdma_du_adj_type = + 5; + } else if (coex_dm->cur_ps_tdma == 16) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = + 15; + } else if (coex_dm->cur_ps_tdma == 15) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 14); + coex_dm->ps_tdma_du_adj_type = + 14; + } else if (coex_dm->cur_ps_tdma == 14) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 13); + coex_dm->ps_tdma_du_adj_type = + 13; + } + } + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_TRACE_FW_DETAIL, + "[BTCoex], TxPause = 0\n"); + if (coex_dm->cur_ps_tdma == 5) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 71); + coex_dm->ps_tdma_du_adj_type = 71; + } else if (coex_dm->cur_ps_tdma == 6) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 2); + coex_dm->ps_tdma_du_adj_type = 2; + } else if (coex_dm->cur_ps_tdma == 7) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } else if (coex_dm->cur_ps_tdma == 8) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 4); + coex_dm->ps_tdma_du_adj_type = 4; + } + + if (coex_dm->cur_ps_tdma == 13) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 9); + coex_dm->ps_tdma_du_adj_type = 9; + } else if (coex_dm->cur_ps_tdma == 14) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 10); + coex_dm->ps_tdma_du_adj_type = 10; + } else if (coex_dm->cur_ps_tdma == 15) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } else if (coex_dm->cur_ps_tdma == 16) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 12); + coex_dm->ps_tdma_du_adj_type = 12; + } + + if (result == -1) { + if (coex_dm->cur_ps_tdma == 71) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 1); + coex_dm->ps_tdma_du_adj_type = + 1; + } else if (coex_dm->cur_ps_tdma == 1) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 2); + coex_dm->ps_tdma_du_adj_type = + 2; + } else if (coex_dm->cur_ps_tdma == 2) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = + 3; + } else if (coex_dm->cur_ps_tdma == 3) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 4); + coex_dm->ps_tdma_du_adj_type = + 4; + } else if (coex_dm->cur_ps_tdma == 9) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 10); + coex_dm->ps_tdma_du_adj_type = + 10; + } else if (coex_dm->cur_ps_tdma == 10) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = + 11; + } else if (coex_dm->cur_ps_tdma == 11) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 12); + coex_dm->ps_tdma_du_adj_type = + 12; + } + } else if (result == 1) { + if (coex_dm->cur_ps_tdma == 4) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = + 3; + } else if (coex_dm->cur_ps_tdma == 3) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 2); + coex_dm->ps_tdma_du_adj_type = + 2; + } else if (coex_dm->cur_ps_tdma == 2) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 1); + coex_dm->ps_tdma_du_adj_type = + 1; + } else if (coex_dm->cur_ps_tdma == 1) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 71); + coex_dm->ps_tdma_du_adj_type = + 71; + } else if (coex_dm->cur_ps_tdma == 12) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = + 11; + } else if (coex_dm->cur_ps_tdma == 11) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 10); + coex_dm->ps_tdma_du_adj_type = + 10; + } else if (coex_dm->cur_ps_tdma == 10) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 9); + coex_dm->ps_tdma_du_adj_type = + 9; + } + } + } + } else if (max_interval == 2) { + if (tx_pause) { + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_TRACE_FW_DETAIL, + "[BTCoex], TxPause = 1\n"); + if (coex_dm->cur_ps_tdma == 1) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 6); + coex_dm->ps_tdma_du_adj_type = 6; + } else if (coex_dm->cur_ps_tdma == 2) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 6); + coex_dm->ps_tdma_du_adj_type = 6; + } else if (coex_dm->cur_ps_tdma == 3) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } else if (coex_dm->cur_ps_tdma == 4) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 8); + coex_dm->ps_tdma_du_adj_type = 8; + } + if (coex_dm->cur_ps_tdma == 9) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 14); + coex_dm->ps_tdma_du_adj_type = 14; + } else if (coex_dm->cur_ps_tdma == 10) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 14); + coex_dm->ps_tdma_du_adj_type = 14; + } else if (coex_dm->cur_ps_tdma == 11) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } else if (coex_dm->cur_ps_tdma == 12) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 16); + coex_dm->ps_tdma_du_adj_type = 16; + } + if (result == -1) { + if (coex_dm->cur_ps_tdma == 5) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 6); + coex_dm->ps_tdma_du_adj_type = + 6; + } else if (coex_dm->cur_ps_tdma == 6) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = + 7; + } else if (coex_dm->cur_ps_tdma == 7) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 8); + coex_dm->ps_tdma_du_adj_type = + 8; + } else if (coex_dm->cur_ps_tdma == 13) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 14); + coex_dm->ps_tdma_du_adj_type = + 14; + } else if (coex_dm->cur_ps_tdma == 14) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = + 15; + } else if (coex_dm->cur_ps_tdma == 15) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 16); + coex_dm->ps_tdma_du_adj_type = + 16; + } + } else if (result == 1) { + if (coex_dm->cur_ps_tdma == 8) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = + 7; + } else if (coex_dm->cur_ps_tdma == 7) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 6); + coex_dm->ps_tdma_du_adj_type = + 6; + } else if (coex_dm->cur_ps_tdma == 6) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 6); + coex_dm->ps_tdma_du_adj_type = + 6; + } else if (coex_dm->cur_ps_tdma == 16) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = + 15; + } else if (coex_dm->cur_ps_tdma == 15) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 14); + coex_dm->ps_tdma_du_adj_type = + 14; + } else if (coex_dm->cur_ps_tdma == 14) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 14); + coex_dm->ps_tdma_du_adj_type = + 14; + } + } + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_TRACE_FW_DETAIL, + "[BTCoex], TxPause = 0\n"); + if (coex_dm->cur_ps_tdma == 5) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 2); + coex_dm->ps_tdma_du_adj_type = 2; + } else if (coex_dm->cur_ps_tdma == 6) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 2); + coex_dm->ps_tdma_du_adj_type = 2; + } else if (coex_dm->cur_ps_tdma == 7) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } else if (coex_dm->cur_ps_tdma == 8) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 4); + coex_dm->ps_tdma_du_adj_type = 4; + } + if (coex_dm->cur_ps_tdma == 13) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 10); + coex_dm->ps_tdma_du_adj_type = 10; + } else if (coex_dm->cur_ps_tdma == 14) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 10); + coex_dm->ps_tdma_du_adj_type = 10; + } else if (coex_dm->cur_ps_tdma == 15) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } else if (coex_dm->cur_ps_tdma == 16) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 12); + coex_dm->ps_tdma_du_adj_type = 12; + } + if (result == -1) { + if (coex_dm->cur_ps_tdma == 1) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 2); + coex_dm->ps_tdma_du_adj_type = + 2; + } else if (coex_dm->cur_ps_tdma == 2) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = + 3; + } else if (coex_dm->cur_ps_tdma == 3) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 4); + coex_dm->ps_tdma_du_adj_type = + 4; + } else if (coex_dm->cur_ps_tdma == 9) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 10); + coex_dm->ps_tdma_du_adj_type = + 10; + } else if (coex_dm->cur_ps_tdma == 10) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = + 11; + } else if (coex_dm->cur_ps_tdma == 11) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 12); + coex_dm->ps_tdma_du_adj_type = + 12; + } + } else if (result == 1) { + if (coex_dm->cur_ps_tdma == 4) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = + 3; + } else if (coex_dm->cur_ps_tdma == 3) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 2); + coex_dm->ps_tdma_du_adj_type = + 2; + } else if (coex_dm->cur_ps_tdma == 2) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 2); + coex_dm->ps_tdma_du_adj_type = + 2; + } else if (coex_dm->cur_ps_tdma == 12) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = + 11; + } else if (coex_dm->cur_ps_tdma == 11) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 10); + coex_dm->ps_tdma_du_adj_type = + 10; + } else if (coex_dm->cur_ps_tdma == 10) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 10); + coex_dm->ps_tdma_du_adj_type = + 10; + } + } + } + } else if (max_interval == 3) { + if (tx_pause) { + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_TRACE_FW_DETAIL, + "[BTCoex], TxPause = 1\n"); + if (coex_dm->cur_ps_tdma == 1) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } else if (coex_dm->cur_ps_tdma == 2) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } else if (coex_dm->cur_ps_tdma == 3) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } else if (coex_dm->cur_ps_tdma == 4) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 8); + coex_dm->ps_tdma_du_adj_type = 8; + } + if (coex_dm->cur_ps_tdma == 9) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } else if (coex_dm->cur_ps_tdma == 10) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } else if (coex_dm->cur_ps_tdma == 11) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } else if (coex_dm->cur_ps_tdma == 12) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 16); + coex_dm->ps_tdma_du_adj_type = 16; + } + if (result == -1) { + if (coex_dm->cur_ps_tdma == 5) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = + 7; + } else if (coex_dm->cur_ps_tdma == 6) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = + 7; + } else if (coex_dm->cur_ps_tdma == 7) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 8); + coex_dm->ps_tdma_du_adj_type = + 8; + } else if (coex_dm->cur_ps_tdma == 13) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = + 15; + } else if (coex_dm->cur_ps_tdma == 14) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = + 15; + } else if (coex_dm->cur_ps_tdma == 15) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 16); + coex_dm->ps_tdma_du_adj_type = + 16; + } + } else if (result == 1) { + if (coex_dm->cur_ps_tdma == 8) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = + 7; + } else if (coex_dm->cur_ps_tdma == 7) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = + 7; + } else if (coex_dm->cur_ps_tdma == 6) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = + 7; + } else if (coex_dm->cur_ps_tdma == 16) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = + 15; + } else if (coex_dm->cur_ps_tdma == 15) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = + 15; + } else if (coex_dm->cur_ps_tdma == 14) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 15); + coex_dm->ps_tdma_du_adj_type = + 15; + } + } + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_TRACE_FW_DETAIL, + "[BTCoex], TxPause = 0\n"); + if (coex_dm->cur_ps_tdma == 5) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } else if (coex_dm->cur_ps_tdma == 6) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } else if (coex_dm->cur_ps_tdma == 7) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } else if (coex_dm->cur_ps_tdma == 8) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 4); + coex_dm->ps_tdma_du_adj_type = 4; + } + if (coex_dm->cur_ps_tdma == 13) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } else if (coex_dm->cur_ps_tdma == 14) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } else if (coex_dm->cur_ps_tdma == 15) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } else if (coex_dm->cur_ps_tdma == 16) { + halbtc8723b2ant_ps_tdma(btcoexist, + NORMAL_EXEC, + true, 12); + coex_dm->ps_tdma_du_adj_type = 12; + } + if (result == -1) { + if (coex_dm->cur_ps_tdma == 1) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = + 3; + } else if (coex_dm->cur_ps_tdma == 2) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = + 3; + } else if (coex_dm->cur_ps_tdma == 3) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 4); + coex_dm->ps_tdma_du_adj_type = + 4; + } else if (coex_dm->cur_ps_tdma == 9) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = + 11; + } else if (coex_dm->cur_ps_tdma == 10) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = + 11; + } else if (coex_dm->cur_ps_tdma == 11) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 12); + coex_dm->ps_tdma_du_adj_type = + 12; + } + } else if (result == 1) { + if (coex_dm->cur_ps_tdma == 4) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = + 3; + } else if (coex_dm->cur_ps_tdma == 3) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = + 3; + } else if (coex_dm->cur_ps_tdma == 2) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = + 3; + } else if (coex_dm->cur_ps_tdma == 12) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = + 11; + } else if (coex_dm->cur_ps_tdma == 11) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = + 11; + } else if (coex_dm->cur_ps_tdma == 10) { + halbtc8723b2ant_ps_tdma( + btcoexist, + NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = + 11; + } + } + } + } + } + + /*if current PsTdma not match with the recorded one (when scan, dhcp..), + *then we have to adjust it back to the previous record one.*/ + if (coex_dm->cur_ps_tdma != coex_dm->ps_tdma_du_adj_type) { + bool scan = false, link = false, roam = false; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], PsTdma type dismatch!!!, curPsTdma =%d, recordPsTdma =%d\n", + coex_dm->cur_ps_tdma, coex_dm->ps_tdma_du_adj_type); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam); + + if (!scan && !link && !roam) + halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, + coex_dm->ps_tdma_du_adj_type); + else + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n"); + } +} + +/* SCO only or SCO+PAN(HS) */ +static void halbtc8723b2ant_action_sco(struct btc_coexist *btcoexist) +{ + u8 wifi_rssi_state; + u32 wifi_bw; + + wifi_rssi_state = halbtc8723b2ant_wifi_rssi_state(btcoexist, + 0, 2, 15, 0); + + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); + + halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 4); + + if (halbtc8723b2ant_need_to_dec_bt_pwr(btcoexist)) + halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true); + else + halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + + /*for SCO quality at 11b/g mode*/ + if (BTC_WIFI_BW_LEGACY == wifi_bw) + coex_table_with_type(btcoexist, NORMAL_EXEC, 2); + else /*for SCO quality & wifi performance balance at 11n mode*/ + coex_table_with_type(btcoexist, NORMAL_EXEC, 8); + + /*for voice quality */ + halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 0); + + /* sw mechanism */ + if (BTC_WIFI_BW_HT40 == wifi_bw) { + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8723b2ant_sw_mechanism1(btcoexist, true, true, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, true, false, + true, 0x4); + } else { + halbtc8723b2ant_sw_mechanism1(btcoexist, true, true, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, + true, 0x4); + } + } else { + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8723b2ant_sw_mechanism1(btcoexist, false, true, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, true, false, + true, 0x4); + } else { + halbtc8723b2ant_sw_mechanism1(btcoexist, false, true, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, + true, 0x4); + } + } +} + +static void halbtc8723b2ant_action_hid(struct btc_coexist *btcoexist) +{ + u8 wifi_rssi_state, bt_rssi_state; + u32 wifi_bw; + + wifi_rssi_state = halbtc8723b2ant_wifi_rssi_state(btcoexist, + 0, 2, 15, 0); + bt_rssi_state = halbtc8723b2ant_bt_rssi_state(2, 29, 0); + + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); + + halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); + + if (halbtc8723b2ant_need_to_dec_bt_pwr(btcoexist)) + halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true); + else + halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + + if (BTC_WIFI_BW_LEGACY == wifi_bw) /*/for HID at 11b/g mode*/ + coex_table_with_type(btcoexist, NORMAL_EXEC, 7); + else /*for HID quality & wifi performance balance at 11n mode*/ + coex_table_with_type(btcoexist, NORMAL_EXEC, 9); + + if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || + (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) + halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 9); + else + halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 13); + + /* sw mechanism */ + if (BTC_WIFI_BW_HT40 == wifi_bw) { + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8723b2ant_sw_mechanism1(btcoexist, true, true, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc8723b2ant_sw_mechanism1(btcoexist, true, true, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } else { + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8723b2ant_sw_mechanism1(btcoexist, false, true, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc8723b2ant_sw_mechanism1(btcoexist, false, true, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } +} + +/*A2DP only / PAN(EDR) only/ A2DP+PAN(HS)*/ +static void halbtc8723b2ant_action_a2dp(struct btc_coexist *btcoexist) +{ + u8 wifi_rssi_state, wifi_rssi_state1, bt_rssi_state; + u32 wifi_bw; + u8 ap_num = 0; + + wifi_rssi_state = halbtc8723b2ant_wifi_rssi_state(btcoexist, + 0, 2, 15, 0); + wifi_rssi_state1 = halbtc8723b2ant_wifi_rssi_state(btcoexist, + 1, 2, 40, 0); + bt_rssi_state = halbtc8723b2ant_bt_rssi_state(2, 29, 0); + + btcoexist->btc_get(btcoexist, BTC_GET_U1_AP_NUM, &ap_num); + + /* define the office environment */ + /* driver don't know AP num in Linux, so we will never enter this if */ + if (ap_num >= 10 && BTC_RSSI_HIGH(wifi_rssi_state1)) { + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, + 0x0); + halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); + halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + coex_table_with_type(btcoexist, NORMAL_EXEC, 0); + halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1); + + /* sw mechanism */ + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + if (BTC_WIFI_BW_HT40 == wifi_bw) { + halbtc8723b2ant_sw_mechanism1(btcoexist, true, false, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, true, false, + true, 0x18); + } else { + halbtc8723b2ant_sw_mechanism1(btcoexist, false, false, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, true, false, + true, 0x18); + } + return; + } + + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); + + halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); + + if (halbtc8723b2ant_need_to_dec_bt_pwr(btcoexist)) + halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true); + else + halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + + coex_table_with_type(btcoexist, NORMAL_EXEC, 7); + + if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || + (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) + halbtc8723b2ant_tdma_duration_adjust(btcoexist, false, false, 1); + else + halbtc8723b2ant_tdma_duration_adjust(btcoexist, false, true, 1); + + /* sw mechanism */ + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + if (BTC_WIFI_BW_HT40 == wifi_bw) { + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8723b2ant_sw_mechanism1(btcoexist, true, false, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc8723b2ant_sw_mechanism1(btcoexist, true, false, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } else { + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8723b2ant_sw_mechanism1(btcoexist, false, false, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc8723b2ant_sw_mechanism1(btcoexist, false, false, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } +} + +static void halbtc8723b2ant_action_a2dp_pan_hs(struct btc_coexist *btcoexist) +{ + u8 wifi_rssi_state; + u32 wifi_bw; + + wifi_rssi_state = halbtc8723b2ant_wifi_rssi_state(btcoexist, + 0, 2, 15, 0); + + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); + + halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); + + if (halbtc8723b2ant_need_to_dec_bt_pwr(btcoexist)) + halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true); + else + halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + + coex_table_with_type(btcoexist, NORMAL_EXEC, 7); + + halbtc8723b2ant_tdma_duration_adjust(btcoexist, false, true, 2); + + /* sw mechanism */ + btcoexist->btc_get(btcoexist, + BTC_GET_U4_WIFI_BW, &wifi_bw); + if (BTC_WIFI_BW_HT40 == wifi_bw) { + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8723b2ant_sw_mechanism1(btcoexist, true, false, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc8723b2ant_sw_mechanism1(btcoexist, true, false, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } else { + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8723b2ant_sw_mechanism1(btcoexist, false, false, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc8723b2ant_sw_mechanism1(btcoexist, false, false, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } +} + +static void halbtc8723b2ant_action_pan_edr(struct btc_coexist *btcoexist) +{ + u8 wifi_rssi_state, bt_rssi_state; + u32 wifi_bw; + + wifi_rssi_state = halbtc8723b2ant_wifi_rssi_state(btcoexist, + 0, 2, 15, 0); + bt_rssi_state = halbtc8723b2ant_bt_rssi_state(2, 29, 0); + + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); + + halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); + + if (halbtc8723b2ant_need_to_dec_bt_pwr(btcoexist)) + halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true); + else + halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + + coex_table_with_type(btcoexist, NORMAL_EXEC, 10); + + if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || + (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) + halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 1); + else + halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5); + + /* sw mechanism */ + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + if (BTC_WIFI_BW_HT40 == wifi_bw) { + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8723b2ant_sw_mechanism1(btcoexist, true, false, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc8723b2ant_sw_mechanism1(btcoexist, true, false, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } else { + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8723b2ant_sw_mechanism1(btcoexist, false, false, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc8723b2ant_sw_mechanism1(btcoexist, false, false, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } +} + +/*PAN(HS) only*/ +static void halbtc8723b2ant_action_pan_hs(struct btc_coexist *btcoexist) +{ + u8 wifi_rssi_state; + u32 wifi_bw; + + wifi_rssi_state = halbtc8723b2ant_wifi_rssi_state(btcoexist, + 0, 2, 15, 0); + + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); + + halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); + + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) + halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true); + else + halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + + coex_table_with_type(btcoexist, NORMAL_EXEC, 7); + + halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + if (BTC_WIFI_BW_HT40 == wifi_bw) { + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8723b2ant_sw_mechanism1(btcoexist, true, false, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc8723b2ant_sw_mechanism1(btcoexist, true, false, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } else { + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8723b2ant_sw_mechanism1(btcoexist, false, false, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc8723b2ant_sw_mechanism1(btcoexist, false, false, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } +} + +/*PAN(EDR)+A2DP*/ +static void halbtc8723b2ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist) +{ + u8 wifi_rssi_state, bt_rssi_state; + u32 wifi_bw; + + wifi_rssi_state = halbtc8723b2ant_wifi_rssi_state(btcoexist, + 0, 2, 15, 0); + bt_rssi_state = halbtc8723b2ant_bt_rssi_state(2, 29, 0); + + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); + + halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); + + if (halbtc8723b2ant_need_to_dec_bt_pwr(btcoexist)) + halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true); + else + halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + + if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || + (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + coex_table_with_type(btcoexist, NORMAL_EXEC, 12); + if (BTC_WIFI_BW_HT40 == wifi_bw) + halbtc8723b2ant_tdma_duration_adjust(btcoexist, false, + true, 3); + else + halbtc8723b2ant_tdma_duration_adjust(btcoexist, false, + false, 3); + } else { + coex_table_with_type(btcoexist, NORMAL_EXEC, 7); + halbtc8723b2ant_tdma_duration_adjust(btcoexist, false, true, 3); + } + + /* sw mechanism */ + if (BTC_WIFI_BW_HT40 == wifi_bw) { + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8723b2ant_sw_mechanism1(btcoexist, true, false, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc8723b2ant_sw_mechanism1(btcoexist, true, false, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } else { + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8723b2ant_sw_mechanism1(btcoexist, false, false, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc8723b2ant_sw_mechanism1(btcoexist, false, false, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } +} + +static void halbtc8723b2ant_action_pan_edr_hid(struct btc_coexist *btcoexist) +{ + u8 wifi_rssi_state, bt_rssi_state; + u32 wifi_bw; + + wifi_rssi_state = halbtc8723b2ant_wifi_rssi_state(btcoexist, + 0, 2, 15, 0); + bt_rssi_state = halbtc8723b2ant_bt_rssi_state(2, 29, 0); + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + + if (halbtc8723b2ant_need_to_dec_bt_pwr(btcoexist)) + halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true); + else + halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + + if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || + (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + if (BTC_WIFI_BW_HT40 == wifi_bw) { + halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, + 3); + coex_table_with_type(btcoexist, + NORMAL_EXEC, 11); + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, + 0xfffff, 0x780); + } else { + halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, + 6); + coex_table_with_type(btcoexist, + NORMAL_EXEC, 7); + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, + 0xfffff, 0x0); + } + halbtc8723b2ant_tdma_duration_adjust(btcoexist, true, false, 2); + } else { + halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); + coex_table_with_type(btcoexist, NORMAL_EXEC, 11); + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, + 0x0); + halbtc8723b2ant_tdma_duration_adjust(btcoexist, true, true, 2); + } + + /* sw mechanism */ + if (BTC_WIFI_BW_HT40 == wifi_bw) { + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8723b2ant_sw_mechanism1(btcoexist, true, true, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc8723b2ant_sw_mechanism1(btcoexist, true, true, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } else { + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8723b2ant_sw_mechanism1(btcoexist, false, true, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc8723b2ant_sw_mechanism1(btcoexist, false, true, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } +} + +/* HID+A2DP+PAN(EDR) */ +static void halbtc8723b2ant_action_hid_a2dp_pan_edr(struct btc_coexist *btcoexist) +{ + u8 wifi_rssi_state, bt_rssi_state; + u32 wifi_bw; + + wifi_rssi_state = halbtc8723b2ant_wifi_rssi_state(btcoexist, + 0, 2, 15, 0); + bt_rssi_state = halbtc8723b2ant_bt_rssi_state(2, 29, 0); + + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); + + halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); + + if (halbtc8723b2ant_need_to_dec_bt_pwr(btcoexist)) + halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true); + else + halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + + coex_table_with_type(btcoexist, NORMAL_EXEC, 7); + + if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || + (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + if (BTC_WIFI_BW_HT40 == wifi_bw) + halbtc8723b2ant_tdma_duration_adjust(btcoexist, true, + true, 2); + else + halbtc8723b2ant_tdma_duration_adjust(btcoexist, true, + false, 3); + } else { + halbtc8723b2ant_tdma_duration_adjust(btcoexist, true, true, 3); + } + + /* sw mechanism */ + if (BTC_WIFI_BW_HT40 == wifi_bw) { + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8723b2ant_sw_mechanism1(btcoexist, true, true, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc8723b2ant_sw_mechanism1(btcoexist, true, true, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } else { + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8723b2ant_sw_mechanism1(btcoexist, false, true, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc8723b2ant_sw_mechanism1(btcoexist, false, true, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } +} + +static void halbtc8723b2ant_action_hid_a2dp(struct btc_coexist *btcoexist) +{ + u8 wifi_rssi_state, bt_rssi_state; + u32 wifi_bw; + + wifi_rssi_state = halbtc8723b2ant_wifi_rssi_state(btcoexist, + 0, 2, 15, 0); + bt_rssi_state = halbtc8723b2ant_bt_rssi_state(2, 29, 0); + + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); + + halbtc8723b2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); + + if (halbtc8723b2ant_need_to_dec_bt_pwr(btcoexist)) + halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true); + else + halbtc8723b2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + + coex_table_with_type(btcoexist, NORMAL_EXEC, 7); + + if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || + (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) + halbtc8723b2ant_tdma_duration_adjust(btcoexist, true, false, 2); + else + halbtc8723b2ant_tdma_duration_adjust(btcoexist, true, true, 2); + + /* sw mechanism */ + if (BTC_WIFI_BW_HT40 == wifi_bw) { + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8723b2ant_sw_mechanism1(btcoexist, true, true, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc8723b2ant_sw_mechanism1(btcoexist, true, true, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } else { + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8723b2ant_sw_mechanism1(btcoexist, false, true, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, true, false, + false, 0x18); + } else { + halbtc8723b2ant_sw_mechanism1(btcoexist, false, true, + false, false); + halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, + false, 0x18); + } + } +} + +static void halbtc8723b2ant_run_coexist_mechanism(struct btc_coexist *btcoexist) +{ + u8 algorithm = 0; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], RunCoexistMechanism() ===>\n"); + + if (btcoexist->manual_control) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n"); + return; + } + + if (coex_sta->under_ips) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], wifi is under IPS !!!\n"); + return; + } + + algorithm = halbtc8723b2ant_action_algorithm(btcoexist); + if (coex_sta->c2h_bt_inquiry_page && + (BT_8723B_2ANT_COEX_ALGO_PANHS != algorithm)) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT is under inquiry/page scan !!\n"); + halbtc8723b2ant_action_bt_inquiry(btcoexist); + return; + } else { + if (coex_dm->need_recover_0x948) { + coex_dm->need_recover_0x948 = false; + btcoexist->btc_write_2byte(btcoexist, 0x948, + coex_dm->backup_0x948); + } + } + + coex_dm->cur_algorithm = algorithm; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], Algorithm = %d \n", + coex_dm->cur_algorithm); + + if (halbtc8723b2ant_is_common_action(btcoexist)) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action 2-Ant common.\n"); + coex_dm->auto_tdma_adjust = false; + } else { + if (coex_dm->cur_algorithm != coex_dm->pre_algorithm) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], preAlgorithm =%d, curAlgorithm =%d\n", coex_dm->pre_algorithm, + coex_dm->cur_algorithm); + coex_dm->auto_tdma_adjust = false; + } + switch (coex_dm->cur_algorithm) { + case BT_8723B_2ANT_COEX_ALGO_SCO: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action 2-Ant, algorithm = SCO.\n"); + halbtc8723b2ant_action_sco(btcoexist); + break; + case BT_8723B_2ANT_COEX_ALGO_HID: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action 2-Ant, algorithm = HID.\n"); + halbtc8723b2ant_action_hid(btcoexist); + break; + case BT_8723B_2ANT_COEX_ALGO_A2DP: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action 2-Ant, algorithm = A2DP.\n"); + halbtc8723b2ant_action_a2dp(btcoexist); + break; + case BT_8723B_2ANT_COEX_ALGO_A2DP_PANHS: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action 2-Ant, algorithm = A2DP+PAN(HS).\n"); + halbtc8723b2ant_action_a2dp_pan_hs(btcoexist); + break; + case BT_8723B_2ANT_COEX_ALGO_PANEDR: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action 2-Ant, algorithm = PAN(EDR).\n"); + halbtc8723b2ant_action_pan_edr(btcoexist); + break; + case BT_8723B_2ANT_COEX_ALGO_PANHS: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action 2-Ant, algorithm = HS mode.\n"); + halbtc8723b2ant_action_pan_hs(btcoexist); + break; + case BT_8723B_2ANT_COEX_ALGO_PANEDR_A2DP: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action 2-Ant, algorithm = PAN+A2DP.\n"); + halbtc8723b2ant_action_pan_edr_a2dp(btcoexist); + break; + case BT_8723B_2ANT_COEX_ALGO_PANEDR_HID: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action 2-Ant, algorithm = PAN(EDR)+HID.\n"); + halbtc8723b2ant_action_pan_edr_hid(btcoexist); + break; + case BT_8723B_2ANT_COEX_ALGO_HID_A2DP_PANEDR: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action 2-Ant, algorithm = HID+A2DP+PAN.\n"); + halbtc8723b2ant_action_hid_a2dp_pan_edr(btcoexist); + break; + case BT_8723B_2ANT_COEX_ALGO_HID_A2DP: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action 2-Ant, algorithm = HID+A2DP.\n"); + halbtc8723b2ant_action_hid_a2dp(btcoexist); + break; + default: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action 2-Ant, algorithm = coexist All Off!!\n"); + halbtc8723b2ant_coex_alloff(btcoexist); + break; + } + coex_dm->pre_algorithm = coex_dm->cur_algorithm; + } +} + +static void halbtc8723b2ant_wifioff_hwcfg(struct btc_coexist *btcoexist) +{ + /* set wlan_act to low */ + btcoexist->btc_write_1byte(btcoexist, 0x76e, 0x4); + /* Force GNT_BT to High */ + btcoexist->btc_write_1byte_bitmask(btcoexist, 0x765, 0x18, 0x3); + /* BT select s0/s1 is controlled by BT */ + btcoexist->btc_write_1byte_bitmask(btcoexist, 0x67, 0x20, 0x0); +} + +/********************************************************************* + * work around function start with wa_halbtc8723b2ant_ + *********************************************************************/ +/********************************************************************* + * extern function start with EXhalbtc8723b2ant_ + *********************************************************************/ +void ex92e_halbtc8723b2ant_init_hwconfig(struct btc_coexist *btcoexist) +{ + u8 u8tmp = 0; + + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], 2Ant Init HW Config!!\n"); + coex_dm->bt_rf0x1e_backup = + btcoexist->btc_get_rf_reg(btcoexist, BTC_RF_A, 0x1e, 0xfffff); + + /* 0x790[5:0] = 0x5 */ + u8tmp = btcoexist->btc_read_1byte(btcoexist, 0x790); + u8tmp &= 0xc0; + u8tmp |= 0x5; + btcoexist->btc_write_1byte(btcoexist, 0x790, u8tmp); + + /*Antenna config */ + halbtc8723b2ant_set_ant_path(btcoexist, BTC_ANT_WIFI_AT_MAIN, + true, false); + + + + /* PTA parameter */ + coex_table_with_type(btcoexist, FORCE_EXEC, 0); + + /* Enable counter statistics */ + /*0x76e[3] = 1, WLAN_Act control by PTA*/ + btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc); + btcoexist->btc_write_1byte(btcoexist, 0x778, 0x3); + btcoexist->btc_write_1byte_bitmask(btcoexist, 0x40, 0x20, 0x1); +} + +void ex92e_halbtc8723b2ant_init_coex_dm(struct btc_coexist *btcoexist) +{ + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], Coex Mechanism Init!!\n"); + halbtc8723b2ant_init_coex_dm(btcoexist); +} + +void ex_halbtc8723b2ant92e_display_coex_info(struct btc_coexist *btcoexist) +{ + struct btc_board_info *board_info = &btcoexist->board_info; + struct btc_stack_info *stack_info = &btcoexist->stack_info; + struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; + u8 *cli_buf = btcoexist->cli_buf; + u8 u8tmp[4], i, bt_info_ext, ps_tdma_case = 0; + u32 u32tmp[4]; + bool roam = false, scan = false; + bool link = false, wifi_under_5g = false; + bool bt_hs_on = false, wifi_busy = false; + s32 wifi_rssi = 0, bt_hs_rssi = 0; + u32 wifi_bw, wifi_traffic_dir, fa_ofdm, fa_cck; + u8 wifi_dot11_chnl, wifi_hs_chnl; + u32 fw_ver = 0, bt_patch_ver = 0; + u8 ap_num = 0; + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\r\n ============[BT Coexist info] ============"); + CL_PRINTF(cli_buf); + + if (btcoexist->manual_control) { + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\r\n ==========[Under Manual Control] ============"); + CL_PRINTF(cli_buf); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\r\n =========================================="); + CL_PRINTF(cli_buf); + } + + if (!board_info->bt_exist) { + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n BT not exists !!!"); + CL_PRINTF(cli_buf); + return; + } + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", + "Ant PG number/ Ant mechanism: ", + board_info->pg_ant_num, board_info->btdm_ant_num); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", + "BT stack/ hci ext ver", + ((stack_info->profile_notified) ? "Yes" : "No"), + stack_info->hci_version); + CL_PRINTF(cli_buf); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER, &bt_patch_ver); + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\r\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)", + "CoexVer/ fw_ver/ PatchVer", + glcoex_ver_date_8723b_2ant, glcoex_ver_8723b_2ant, + fw_ver, bt_patch_ver, bt_patch_ver); + CL_PRINTF(cli_buf); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); + btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_DOT11_CHNL, + &wifi_dot11_chnl); + btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifi_hs_chnl); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d(%d)", + "Dot11 channel / HsChnl(HsMode)", + wifi_dot11_chnl, wifi_hs_chnl, bt_hs_on); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", + "H2C Wifi inform bt chnl Info", coex_dm->wifi_chnl_info[0], + coex_dm->wifi_chnl_info[1], coex_dm->wifi_chnl_info[2]); + CL_PRINTF(cli_buf); + + btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi); + btcoexist->btc_get(btcoexist, BTC_GET_S4_HS_RSSI, &bt_hs_rssi); + btcoexist->btc_get(btcoexist, BTC_GET_U1_AP_NUM, &ap_num); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d", + "Wifi rssi/ HS rssi/ AP#", wifi_rssi, bt_hs_rssi, ap_num); + CL_PRINTF(cli_buf); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", + "Wifi link/ roam/ scan", link, roam, scan); + CL_PRINTF(cli_buf); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g); + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, + &wifi_traffic_dir); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %s/ %s ", + "Wifi status", (wifi_under_5g ? "5G" : "2.4G"), + ((BTC_WIFI_BW_LEGACY == wifi_bw) ? "Legacy" : + (((BTC_WIFI_BW_HT40 == wifi_bw) ? "HT40" : "HT20"))), + ((!wifi_busy) ? "idle" : + ((BTC_WIFI_TRAFFIC_TX == wifi_traffic_dir) ? + "uplink" : "downlink"))); + CL_PRINTF(cli_buf); + + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", + "SCO/HID/PAN/A2DP", + bt_link_info->sco_exist, bt_link_info->hid_exist, + bt_link_info->pan_exist, bt_link_info->a2dp_exist); + CL_PRINTF(cli_buf); + btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_BT_LINK_INFO); + + bt_info_ext = coex_sta->bt_info_ext; + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", + "BT Info A2DP rate", + (bt_info_ext & BIT(0)) ? "Basic rate" : "EDR rate"); + CL_PRINTF(cli_buf); + + for (i = 0; i < BT_INFO_SRC_8723B_2ANT_MAX; i++) { + if (coex_sta->bt_info_c2h_cnt[i]) { + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", + glbt_info_src_8723b_2ant[i], + coex_sta->bt_info_c2h[i][0], + coex_sta->bt_info_c2h[i][1], + coex_sta->bt_info_c2h[i][2], + coex_sta->bt_info_c2h[i][3], + coex_sta->bt_info_c2h[i][4], + coex_sta->bt_info_c2h[i][5], + coex_sta->bt_info_c2h[i][6], + coex_sta->bt_info_c2h_cnt[i]); + CL_PRINTF(cli_buf); + } + } + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/%s", + "PS state, IPS/LPS", + ((coex_sta->under_ips ? "IPS ON" : "IPS OFF")), + ((coex_sta->under_lps ? "LPS ON" : "LPS OFF"))); + CL_PRINTF(cli_buf); + btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_FW_PWR_MODE_CMD); + + /* Sw mechanism */ + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\r\n %-35s", "============[Sw mechanism] ============"); + CL_PRINTF(cli_buf); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", + "SM1[ShRf/ LpRA/ LimDig]", coex_dm->cur_rf_rx_lpf_shrink, + coex_dm->cur_low_penalty_ra, coex_dm->limited_dig); + CL_PRINTF(cli_buf); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d(0x%x) ", + "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", + coex_dm->cur_agc_table_en, coex_dm->cur_adc_back_off, + coex_dm->cur_dac_swing_on, coex_dm->cur_dac_swing_lvl); + CL_PRINTF(cli_buf); + + /* Fw mechanism */ + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s", + "============[Fw mechanism] ============"); + CL_PRINTF(cli_buf); + + ps_tdma_case = coex_dm->cur_ps_tdma; + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d)", + "PS TDMA", coex_dm->ps_tdma_para[0], + coex_dm->ps_tdma_para[1], coex_dm->ps_tdma_para[2], + coex_dm->ps_tdma_para[3], coex_dm->ps_tdma_para[4], + ps_tdma_case, coex_dm->auto_tdma_adjust); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", + "DecBtPwr/ IgnWlanAct", coex_dm->cur_dec_bt_pwr, + coex_dm->cur_ignore_wlan_act); + CL_PRINTF(cli_buf); + + /* Hw setting */ + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s", + "============[Hw setting] ============"); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", + "RF-A, 0x1e initVal", coex_dm->bt_rf0x1e_backup); + CL_PRINTF(cli_buf); + + u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x778); + u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x880); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", + "0x778/0x880[29:25]", u8tmp[0], + (u32tmp[0]&0x3e000000) >> 25); + CL_PRINTF(cli_buf); + + u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x948); + u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x67); + u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0x765); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", + "0x948/ 0x67[5] / 0x765", + u32tmp[0], ((u8tmp[0]&0x20) >> 5), u8tmp[1]); + CL_PRINTF(cli_buf); + + u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x92c); + u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x930); + u32tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0x944); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", + "0x92c[1:0]/ 0x930[7:0]/0x944[1:0]", + u32tmp[0]&0x3, u32tmp[1]&0xff, u32tmp[2]&0x3); + CL_PRINTF(cli_buf); + + u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x39); + u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0x40); + u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x4c); + u8tmp[2] = btcoexist->btc_read_1byte(btcoexist, 0x64); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", + "0x38[11]/0x40/0x4c[24:23]/0x64[0]", + ((u8tmp[0] & 0x8)>>3), u8tmp[1], + ((u32tmp[0]&0x01800000)>>23), u8tmp[2]&0x1); + CL_PRINTF(cli_buf); + + u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x550); + u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x522); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", + "0x550(bcn ctrl)/0x522", u32tmp[0], u8tmp[0]); + CL_PRINTF(cli_buf); + + u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xc50); + u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x49c); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", + "0xc50(dig)/0x49c(null-drop)", u32tmp[0]&0xff, u8tmp[0]); + CL_PRINTF(cli_buf); + + u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xda0); + u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0xda4); + u32tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0xda8); + u32tmp[3] = btcoexist->btc_read_4byte(btcoexist, 0xcf0); + + u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0xa5b); + u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0xa5c); + + fa_ofdm = ((u32tmp[0]&0xffff0000) >> 16) + + ((u32tmp[1]&0xffff0000) >> 16) + + (u32tmp[1] & 0xffff) + + (u32tmp[2] & 0xffff) + + ((u32tmp[3]&0xffff0000) >> 16) + + (u32tmp[3] & 0xffff); + fa_cck = (u8tmp[0] << 8) + u8tmp[1]; + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", + "OFDM-CCA/OFDM-FA/CCK-FA", + u32tmp[0]&0xffff, fa_ofdm, fa_cck); + CL_PRINTF(cli_buf); + + u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x6c0); + u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x6c4); + u32tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0x6c8); + u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x6cc); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", + "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \ + u32tmp[0], u32tmp[1], u32tmp[2], u8tmp[0]); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", + "0x770(high-pri rx/tx)", + coex_sta->high_priority_rx, coex_sta->high_priority_tx); + CL_PRINTF(cli_buf); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", + "0x774(low-pri rx/tx)", coex_sta->low_priority_rx, + coex_sta->low_priority_tx); + CL_PRINTF(cli_buf); +#if (BT_AUTO_REPORT_ONLY_8723B_2ANT == 1) + halbtc8723b2ant_monitor_bt_ctr(btcoexist); +#endif + btcoexist->btc_disp_dbg_msg(btcoexist, + BTC_DBG_DISP_COEX_STATISTICS); +} + +void ex92e_halbtc8723b2ant_ips_notify(struct btc_coexist *btcoexist, u8 type) +{ + if (BTC_IPS_ENTER == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], IPS ENTER notify\n"); + coex_sta->under_ips = true; + halbtc8723b2ant_wifioff_hwcfg(btcoexist); + halbtc8723b2ant_ignore_wlan_act(btcoexist, FORCE_EXEC, true); + halbtc8723b2ant_coex_alloff(btcoexist); + } else if (BTC_IPS_LEAVE == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], IPS LEAVE notify\n"); + coex_sta->under_ips = false; + ex92e_halbtc8723b2ant_init_hwconfig(btcoexist); + halbtc8723b2ant_init_coex_dm(btcoexist); + halbtc8723b2ant_query_bt_info(btcoexist); + } +} + +void ex92e_halbtc8723b2ant_lps_notify(struct btc_coexist *btcoexist, u8 type) +{ + if (BTC_LPS_ENABLE == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], LPS ENABLE notify\n"); + coex_sta->under_lps = true; + } else if (BTC_LPS_DISABLE == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], LPS DISABLE notify\n"); + coex_sta->under_lps = false; + } +} + +void ex92e_halbtc8723b2ant_scan_notify(struct btc_coexist *btcoexist, u8 type) +{ + if (BTC_SCAN_START == type) + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], SCAN START notify\n"); + else if (BTC_SCAN_FINISH == type) + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], SCAN FINISH notify\n"); +} + +void ex92e_halbtc8723b2ant_connect_notify(struct btc_coexist *btcoexist, u8 type) +{ + if (BTC_ASSOCIATE_START == type) + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], CONNECT START notify\n"); + else if (BTC_ASSOCIATE_FINISH == type) + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], CONNECT FINISH notify\n"); +} + +void ex92e_halbtc8723b2ant_media_status_notify(struct btc_coexist *btcoexist, + u8 type) +{ + u8 h2c_parameter[3] = {0}; + u32 wifi_bw; + u8 wifi_central_chnl; + + if (BTC_MEDIA_CONNECT == type) + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], MEDIA connect notify\n"); + else + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], MEDIA disconnect notify\n"); + + /* only 2.4G we need to inform bt the chnl mask */ + btcoexist->btc_get(btcoexist, + BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifi_central_chnl); + if ((BTC_MEDIA_CONNECT == type) && + (wifi_central_chnl <= 14)) { + h2c_parameter[0] = 0x1; + h2c_parameter[1] = wifi_central_chnl; + btcoexist->btc_get(btcoexist, + BTC_GET_U4_WIFI_BW, &wifi_bw); + if (BTC_WIFI_BW_HT40 == wifi_bw) + h2c_parameter[2] = 0x30; + else + h2c_parameter[2] = 0x20; + } + + coex_dm->wifi_chnl_info[0] = h2c_parameter[0]; + coex_dm->wifi_chnl_info[1] = h2c_parameter[1]; + coex_dm->wifi_chnl_info[2] = h2c_parameter[2]; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], FW write 0x66 = 0x%x\n", + h2c_parameter[0] << 16 | h2c_parameter[1] << 8 | + h2c_parameter[2]); + + btcoexist->btc_fill_h2c(btcoexist, 0x66, 3, h2c_parameter); +} + +void ex92e_halbtc8723b2ant_special_packet_notify(struct btc_coexist *btcoexist, + u8 type) +{ + if (type == BTC_PACKET_DHCP) + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], DHCP Packet notify\n"); +} + +void ex92e_halbtc8723b2ant_bt_info_notify(struct btc_coexist *btcoexist, + u8 *tmpbuf, u8 length) +{ + u8 btInfo = 0; + u8 i, rsp_source = 0; + bool bt_busy = false, limited_dig = false; + bool wifi_connected = false; + + coex_sta->c2h_bt_info_req_sent = false; + + rsp_source = tmpbuf[0]&0xf; + if (rsp_source >= BT_INFO_SRC_8723B_2ANT_MAX) + rsp_source = BT_INFO_SRC_8723B_2ANT_WIFI_FW; + coex_sta->bt_info_c2h_cnt[rsp_source]++; + + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], Bt info[%d], length =%d, hex data =[", + rsp_source, length); + for (i = 0; i < length; i++) { + coex_sta->bt_info_c2h[rsp_source][i] = tmpbuf[i]; + if (i == 1) + btInfo = tmpbuf[i]; + if (i == length-1) + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "0x%02x]\n", tmpbuf[i]); + else + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "0x%02x, ", tmpbuf[i]); + } + + if (btcoexist->manual_control) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BtInfoNotify(), return for Manual CTRL<===\n"); + return; + } + + if (BT_INFO_SRC_8723B_2ANT_WIFI_FW != rsp_source) { + coex_sta->bt_retry_cnt = /* [3:0]*/ + coex_sta->bt_info_c2h[rsp_source][2] & 0xf; + + coex_sta->bt_rssi = + coex_sta->bt_info_c2h[rsp_source][3] * 2 + 10; + + coex_sta->bt_info_ext = + coex_sta->bt_info_c2h[rsp_source][4]; + + /* Here we need to resend some wifi info to BT + because bt is reset and loss of the info.*/ + if ((coex_sta->bt_info_ext & BIT(1))) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n"); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, + &wifi_connected); + if (wifi_connected) + ex92e_halbtc8723b2ant_media_status_notify( + btcoexist, + BTC_MEDIA_CONNECT); + else + ex92e_halbtc8723b2ant_media_status_notify( + btcoexist, + BTC_MEDIA_DISCONNECT); + } + + if ((coex_sta->bt_info_ext & BIT(3))) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n"); + halbtc8723b2ant_ignore_wlan_act(btcoexist, FORCE_EXEC, + false); + } else { + /* BT already NOT ignore Wlan active, do nothing here.*/ + } +#if (BT_AUTO_REPORT_ONLY_8723B_2ANT == 0) + if ((coex_sta->bt_info_ext & BIT(4))) { + /* BT auto report already enabled, do nothing*/ + } else { + halbtc8723b2ant_bt_auto_report(btcoexist, FORCE_EXEC, + true); + } +#endif + } + + /* check BIT(2) first ==> check if bt is under inquiry or page scan*/ + if (btInfo & BT_INFO_8723B_2ANT_B_INQ_PAGE) + coex_sta->c2h_bt_inquiry_page = true; + else + coex_sta->c2h_bt_inquiry_page = false; + + /* set link exist status*/ + if (!(btInfo & BT_INFO_8723B_2ANT_B_CONNECTION)) { + coex_sta->bt_link_exist = false; + coex_sta->pan_exist = false; + coex_sta->a2dp_exist = false; + coex_sta->hid_exist = false; + coex_sta->sco_exist = false; + } else {/* connection exists */ + coex_sta->bt_link_exist = true; + if (btInfo & BT_INFO_8723B_2ANT_B_FTP) + coex_sta->pan_exist = true; + else + coex_sta->pan_exist = false; + if (btInfo & BT_INFO_8723B_2ANT_B_A2DP) + coex_sta->a2dp_exist = true; + else + coex_sta->a2dp_exist = false; + if (btInfo & BT_INFO_8723B_2ANT_B_HID) + coex_sta->hid_exist = true; + else + coex_sta->hid_exist = false; + if (btInfo & BT_INFO_8723B_2ANT_B_SCO_ESCO) + coex_sta->sco_exist = true; + else + coex_sta->sco_exist = false; + } + + halbtc8723b2ant_update_bt_link_info(btcoexist); + + if (!(btInfo & BT_INFO_8723B_2ANT_B_CONNECTION)) { + coex_dm->bt_status = BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n"); + /* connection exists but no busy */ + } else if (btInfo == BT_INFO_8723B_2ANT_B_CONNECTION) { + coex_dm->bt_status = BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n"); + } else if ((btInfo & BT_INFO_8723B_2ANT_B_SCO_ESCO) || + (btInfo & BT_INFO_8723B_2ANT_B_SCO_BUSY)) { + coex_dm->bt_status = + BT_8723B_2ANT_BT_STATUS_SCO_BUSY; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BtInfoNotify(), BT SCO busy!!!\n"); + } else if (btInfo&BT_INFO_8723B_2ANT_B_ACL_BUSY) { + coex_dm->bt_status = + BT_8723B_2ANT_BT_STATUS_ACL_BUSY; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BtInfoNotify(), BT ACL busy!!!\n"); + } else { + coex_dm->bt_status = BT_8723B_2ANT_BT_STATUS_MAX; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n"); + } + + if ((BT_8723B_2ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) || + (BT_8723B_2ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) || + (BT_8723B_2ANT_BT_STATUS_ACL_SCO_BUSY == coex_dm->bt_status)) { + bt_busy = true; + limited_dig = true; + } else { + bt_busy = false; + limited_dig = false; + } + + btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bt_busy); + + coex_dm->limited_dig = limited_dig; + btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_LIMITED_DIG, &limited_dig); + + halbtc8723b2ant_run_coexist_mechanism(btcoexist); +} + +void ex92e_halbtc8723b2ant_halt_notify(struct btc_coexist *btcoexist) +{ + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, "[BTCoex], Halt notify\n"); + + halbtc8723b2ant_wifioff_hwcfg(btcoexist); + halbtc8723b2ant_ignore_wlan_act(btcoexist, FORCE_EXEC, true); + ex92e_halbtc8723b2ant_media_status_notify(btcoexist, BTC_MEDIA_DISCONNECT); +} + +void ex92e_halbtc8723b2ant_periodical(struct btc_coexist *btcoexist) +{ + struct btc_board_info *board_info = &btcoexist->board_info; + struct btc_stack_info *stack_info = &btcoexist->stack_info; + static u8 dis_ver_info_cnt; + u32 fw_ver = 0, bt_patch_ver = 0; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], ========================== Periodical ===========================\n"); + + if (dis_ver_info_cnt <= 5) { + dis_ver_info_cnt += 1; + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], ****************************************************************\n"); + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/%d/%d\n", board_info->pg_ant_num, + board_info->btdm_ant_num, board_info->btdm_ant_pos); + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], BT stack/hci ext ver = %s/%d\n", + ((stack_info->profile_notified) ? "Yes" : "No"), + stack_info->hci_version); + btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER, + &bt_patch_ver); + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver); + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], CoexVer/fw_ver/PatchVer = %d_%x/0x%x/0x%x(%d)\n", + glcoex_ver_date_8723b_2ant, glcoex_ver_8723b_2ant, + fw_ver, bt_patch_ver, bt_patch_ver); + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], ****************************************************************\n"); + } + +#if (BT_AUTO_REPORT_ONLY_8723B_2ANT == 0) + halbtc8723b2ant_query_bt_info(btcoexist); + halbtc8723b2ant_monitor_bt_ctr(btcoexist); + halbtc8723b2ant_monitor_bt_enable_disable(btcoexist); +#else + if (is_wifi_status_changed(btcoexist) || + coex_dm->auto_tdma_adjust) + halbtc8723b2ant_run_coexist_mechanism(btcoexist); +#endif +} diff --git a/drivers/staging/rtl8192ee/btcoexist/halbtc8723b2ant.h b/drivers/staging/rtl8192ee/btcoexist/halbtc8723b2ant.h new file mode 100644 index 000000000000..8437e1c3ecd0 --- /dev/null +++ b/drivers/staging/rtl8192ee/btcoexist/halbtc8723b2ant.h @@ -0,0 +1,145 @@ +/************************************************************************ + * The following is for 8723B 2Ant BT Co-exist definition + ************************************************************************/ +#define BT_AUTO_REPORT_ONLY_8723B_2ANT 1 + + +#define BT_INFO_8723B_2ANT_B_FTP BIT(7) +#define BT_INFO_8723B_2ANT_B_A2DP BIT(6) +#define BT_INFO_8723B_2ANT_B_HID BIT(5) +#define BT_INFO_8723B_2ANT_B_SCO_BUSY BIT(4) +#define BT_INFO_8723B_2ANT_B_ACL_BUSY BIT(3) +#define BT_INFO_8723B_2ANT_B_INQ_PAGE BIT(2) +#define BT_INFO_8723B_2ANT_B_SCO_ESCO BIT(1) +#define BT_INFO_8723B_2ANT_B_CONNECTION BIT(0) + +#define BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT 2 + +enum BT_INFO_SRC_8723B_2ANT { + BT_INFO_SRC_8723B_2ANT_WIFI_FW = 0x0, + BT_INFO_SRC_8723B_2ANT_BT_RSP = 0x1, + BT_INFO_SRC_8723B_2ANT_BT_ACTIVE_SEND = 0x2, + BT_INFO_SRC_8723B_2ANT_MAX +}; + +enum BT_8723B_2ANT_BT_STATUS { + BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0, + BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE = 0x1, + BT_8723B_2ANT_BT_STATUS_INQ_PAGE = 0x2, + BT_8723B_2ANT_BT_STATUS_ACL_BUSY = 0x3, + BT_8723B_2ANT_BT_STATUS_SCO_BUSY = 0x4, + BT_8723B_2ANT_BT_STATUS_ACL_SCO_BUSY = 0x5, + BT_8723B_2ANT_BT_STATUS_MAX +}; + +enum BT_8723B_2ANT_COEX_ALGO { + BT_8723B_2ANT_COEX_ALGO_UNDEFINED = 0x0, + BT_8723B_2ANT_COEX_ALGO_SCO = 0x1, + BT_8723B_2ANT_COEX_ALGO_HID = 0x2, + BT_8723B_2ANT_COEX_ALGO_A2DP = 0x3, + BT_8723B_2ANT_COEX_ALGO_A2DP_PANHS = 0x4, + BT_8723B_2ANT_COEX_ALGO_PANEDR = 0x5, + BT_8723B_2ANT_COEX_ALGO_PANHS = 0x6, + BT_8723B_2ANT_COEX_ALGO_PANEDR_A2DP = 0x7, + BT_8723B_2ANT_COEX_ALGO_PANEDR_HID = 0x8, + BT_8723B_2ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9, + BT_8723B_2ANT_COEX_ALGO_HID_A2DP = 0xa, + BT_8723B_2ANT_COEX_ALGO_MAX = 0xb, +}; + +struct coex_dm_8723b_2ant { + /* fw mechanism */ + bool pre_dec_bt_pwr; + bool cur_dec_bt_pwr; + u8 pre_fw_dac_swing_lvl; + u8 cur_fw_dac_swing_lvl; + bool cur_ignore_wlan_act; + bool pre_ignore_wlan_act; + u8 pre_ps_tdma; + u8 cur_ps_tdma; + u8 ps_tdma_para[5]; + u8 ps_tdma_du_adj_type; + bool reset_tdma_adjust; + bool auto_tdma_adjust; + bool pre_ps_tdma_on; + bool cur_ps_tdma_on; + bool pre_bt_auto_report; + bool cur_bt_auto_report; + + /* sw mechanism */ + bool pre_rf_rx_lpf_shrink; + bool cur_rf_rx_lpf_shrink; + u32 bt_rf0x1e_backup; + bool pre_low_penalty_ra; + bool cur_low_penalty_ra; + bool pre_dac_swing_on; + u32 pre_dac_swing_lvl; + bool cur_dac_swing_on; + u32 cur_dac_swing_lvl; + bool pre_adc_back_off; + bool cur_adc_back_off; + bool pre_agc_table_en; + bool cur_agc_table_en; + u32 pre_val0x6c0; + u32 cur_val0x6c0; + u32 pre_val0x6c4; + u32 cur_val0x6c4; + u32 pre_val0x6c8; + u32 cur_val0x6c8; + u8 pre_val0x6cc; + u8 cur_val0x6cc; + bool limited_dig; + + /* algorithm related */ + u8 pre_algorithm; + u8 cur_algorithm; + u8 bt_status; + u8 wifi_chnl_info[3]; + + bool need_recover_0x948; + u16 backup_0x948; +}; + +struct coex_sta_8723b_2ant { + bool bt_link_exist; + bool sco_exist; + bool a2dp_exist; + bool hid_exist; + bool pan_exist; + + bool under_lps; + bool under_ips; + u32 high_priority_tx; + u32 high_priority_rx; + u32 low_priority_tx; + u32 low_priority_rx; + u8 bt_rssi; + u8 pre_bt_rssi_state; + u8 pre_wifi_rssi_state[4]; + bool c2h_bt_info_req_sent; + u8 bt_info_c2h[BT_INFO_SRC_8723B_2ANT_MAX][10]; + u32 bt_info_c2h_cnt[BT_INFO_SRC_8723B_2ANT_MAX]; + bool c2h_bt_inquiry_page; + u8 bt_retry_cnt; + u8 bt_info_ext; +}; + +/********************************************************************* + * The following is interface which will notify coex module. + *********************************************************************/ +void ex92e_halbtc8723b2ant_init_hwconfig(struct btc_coexist *btcoexist); +void ex92e_halbtc8723b2ant_init_coex_dm(struct btc_coexist *btcoexist); +void ex92e_halbtc8723b2ant_ips_notify(struct btc_coexist *btcoexist, u8 type); +void ex92e_halbtc8723b2ant_lps_notify(struct btc_coexist *btcoexist, u8 type); +void ex92e_halbtc8723b2ant_scan_notify(struct btc_coexist *btcoexist, u8 type); +void ex92e_halbtc8723b2ant_connect_notify(struct btc_coexist *btcoexist, + u8 type); +void ex92e_halbtc8723b2ant_media_status_notify(struct btc_coexist *btcoexist, + u8 type); +void ex92e_halbtc8723b2ant_special_packet_notify(struct btc_coexist *btcoexist, + u8 type); +void ex92e_halbtc8723b2ant_bt_info_notify(struct btc_coexist *btcoexist, + u8 *tmpbuf, u8 length); +void ex92e_halbtc8723b2ant_halt_notify(struct btc_coexist *btcoexist); +void ex92e_halbtc8723b2ant_periodical(struct btc_coexist *btcoexist); +void ex_halbtc8723b2ant92e_display_coex_info(struct btc_coexist *btcoexist); diff --git a/drivers/staging/rtl8192ee/btcoexist/halbtc8821a1ant.c b/drivers/staging/rtl8192ee/btcoexist/halbtc8821a1ant.c new file mode 100644 index 000000000000..fb5286387d80 --- /dev/null +++ b/drivers/staging/rtl8192ee/btcoexist/halbtc8821a1ant.c @@ -0,0 +1,2780 @@ +/* */ +/* Description: */ +/* */ +/* This file is for RTL8821A Co-exist mechanism */ +/* */ +/* History */ +/* 2012/11/15 Cosa first check in. */ +/* */ +/* */ + +/* */ +/* include files */ +/* */ +#include "halbt_precomp.h" +/* */ +/* Global variables, these are static variables */ +/* */ +static struct coex_dm_8821a_1ant glcoex_dm_8821a_1ant; +static struct coex_dm_8821a_1ant *coex_dm = &glcoex_dm_8821a_1ant; +static struct coex_sta_8821a_1ant glcoex_sta_8821a_1ant; +static struct coex_sta_8821a_1ant *coex_sta = &glcoex_sta_8821a_1ant; + +static const char *const glbt_info_src_8821a_1ant[] = { + "BT Info[wifi fw]", + "BT Info[bt rsp]", + "BT Info[bt auto report]", +}; + +static u32 glcoex_ver_date_8821a_1ant = 20130816; +static u32 glcoex_ver_8821a_1ant = 0x41; + +/* local function proto type if needed */ +/* local function start with halbtc8821a1ant_ */ +static u8 halbtc8821a1ant_bt_rssi_state(u8 level_num, u8 rssi_thresh, + u8 rssi_thresh1) +{ + long bt_rssi = 0; + u8 bt_rssi_state = coex_sta->pre_bt_rssi_state; + + bt_rssi = coex_sta->bt_rssi; + + if (level_num == 2) { + if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) || + (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW)) { + if (bt_rssi >= (rssi_thresh+BTC_RSSI_COEX_THRESH_TOL_8821A_1ANT)) { + bt_rssi_state = BTC_RSSI_STATE_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state switch to High\n"); + } else { + bt_rssi_state = BTC_RSSI_STATE_STAY_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state stay at Low\n"); + } + } else { + if (bt_rssi < rssi_thresh) { + bt_rssi_state = BTC_RSSI_STATE_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state switch to Low\n"); + } else { + bt_rssi_state = BTC_RSSI_STATE_STAY_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state stay at High\n"); + } + } + } else if (level_num == 3) { + if (rssi_thresh > rssi_thresh1) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi thresh error!!\n"); + return coex_sta->pre_bt_rssi_state; + } + + if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) || + (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW)) { + if (bt_rssi >= (rssi_thresh+BTC_RSSI_COEX_THRESH_TOL_8821A_1ANT)) { + bt_rssi_state = BTC_RSSI_STATE_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state switch to Medium\n"); + } else { + bt_rssi_state = BTC_RSSI_STATE_STAY_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state stay at Low\n"); + } + } else if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_MEDIUM) || + (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_MEDIUM)) { + if (bt_rssi >= (rssi_thresh1+BTC_RSSI_COEX_THRESH_TOL_8821A_1ANT)) { + bt_rssi_state = BTC_RSSI_STATE_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state switch to High\n"); + } else if (bt_rssi < rssi_thresh) { + bt_rssi_state = BTC_RSSI_STATE_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state switch to Low\n"); + } else { + bt_rssi_state = BTC_RSSI_STATE_STAY_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state stay at Medium\n"); + } + } else { + if (bt_rssi < rssi_thresh1) { + bt_rssi_state = BTC_RSSI_STATE_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state switch to Medium\n"); + } else { + bt_rssi_state = BTC_RSSI_STATE_STAY_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state stay at High\n"); + } + } + } + + coex_sta->pre_bt_rssi_state = bt_rssi_state; + + return bt_rssi_state; +} + +static u8 Wifi_rssi_state(struct btc_coexist *btcoexist, u8 index, + u8 level_num, u8 rssi_thresh, + u8 rssi_thresh1) +{ + long wifi_rssi = 0; + u8 wifi_rssi_state = coex_sta->pre_wifi_rssi_state[index]; + + btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi); + + if (level_num == 2) { + if ((coex_sta->pre_wifi_rssi_state[index] == BTC_RSSI_STATE_LOW) || + (coex_sta->pre_wifi_rssi_state[index] == BTC_RSSI_STATE_STAY_LOW)) { + if (wifi_rssi >= (rssi_thresh+BTC_RSSI_COEX_THRESH_TOL_8821A_1ANT)) { + wifi_rssi_state = BTC_RSSI_STATE_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state switch to High\n"); + } else { + wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state stay at Low\n"); + } + } else { + if (wifi_rssi < rssi_thresh) { + wifi_rssi_state = BTC_RSSI_STATE_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state switch to Low\n"); + } else { + wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state stay at High\n"); + } + } + } else if (level_num == 3) { + if (rssi_thresh > rssi_thresh1) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI thresh error!!\n"); + return coex_sta->pre_wifi_rssi_state[index]; + } + + if ((coex_sta->pre_wifi_rssi_state[index] == + BTC_RSSI_STATE_LOW) || + (coex_sta->pre_wifi_rssi_state[index] == + BTC_RSSI_STATE_STAY_LOW)) { + if (wifi_rssi >= (rssi_thresh + + BTC_RSSI_COEX_THRESH_TOL_8821A_1ANT)) { + wifi_rssi_state = BTC_RSSI_STATE_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state switch to Medium\n"); + } else { + wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state stay at Low\n"); + } + } else if ((coex_sta->pre_wifi_rssi_state[index] == + BTC_RSSI_STATE_MEDIUM) || + (coex_sta->pre_wifi_rssi_state[index] == + BTC_RSSI_STATE_STAY_MEDIUM)) { + if (wifi_rssi >= (rssi_thresh1 + + BTC_RSSI_COEX_THRESH_TOL_8821A_1ANT)) { + wifi_rssi_state = BTC_RSSI_STATE_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state switch to High\n"); + } else if (wifi_rssi < rssi_thresh) { + wifi_rssi_state = BTC_RSSI_STATE_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state switch to Low\n"); + } else { + wifi_rssi_state = BTC_RSSI_STATE_STAY_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state stay at Medium\n"); + } + } else { + if (wifi_rssi < rssi_thresh1) { + wifi_rssi_state = BTC_RSSI_STATE_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state switch to Medium\n"); + } else { + wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state stay at High\n"); + } + } + } + + coex_sta->pre_wifi_rssi_state[index] = wifi_rssi_state; + + return wifi_rssi_state; +} + +static void update_ra_mask(struct btc_coexist *btcoexist, + bool force_exec, u32 dis_rate_mask) +{ + coex_dm->cur_ra_mask = dis_rate_mask; + + if (force_exec || (coex_dm->pre_ra_mask != coex_dm->cur_ra_mask)) { + btcoexist->btc_set(btcoexist, BTC_SET_ACT_UPDATE_ra_mask, + &coex_dm->cur_ra_mask); + } + coex_dm->pre_ra_mask = coex_dm->cur_ra_mask; +} + +static void auto_rate_fallback_retry(struct btc_coexist *btcoexist, + bool force_exec, u8 type) +{ + bool wifi_under_b_mode = false; + + coex_dm->cur_arfr_type = type; + + if (force_exec || (coex_dm->pre_arfr_type != coex_dm->cur_arfr_type)) { + switch (coex_dm->cur_arfr_type) { + case 0: /* normal mode */ + btcoexist->btc_write_4byte(btcoexist, 0x430, + coex_dm->backup_arfr_cnt1); + btcoexist->btc_write_4byte(btcoexist, 0x434, + coex_dm->backup_arfr_cnt2); + break; + case 1: + btcoexist->btc_get(btcoexist, + BTC_GET_BL_WIFI_UNDER_B_MODE, + &wifi_under_b_mode); + if (wifi_under_b_mode) { + btcoexist->btc_write_4byte(btcoexist, + 0x430, 0x0); + btcoexist->btc_write_4byte(btcoexist, + 0x434, + 0x01010101); + } else { + btcoexist->btc_write_4byte(btcoexist, + 0x430, 0x0); + btcoexist->btc_write_4byte(btcoexist, + 0x434, + 0x04030201); + } + break; + default: + break; + } + } + + coex_dm->pre_arfr_type = coex_dm->cur_arfr_type; +} + +static void halbtc8821a1ant_retry_limit(struct btc_coexist *btcoexist, + bool force_exec, u8 type) +{ + coex_dm->cur_retry_limit_type = type; + + if (force_exec || (coex_dm->pre_retry_limit_type != + coex_dm->cur_retry_limit_type)) { + switch (coex_dm->cur_retry_limit_type) { + case 0: /* normal mode */ + btcoexist->btc_write_2byte(btcoexist, 0x42a, coex_dm->backup_retry_limit); + break; + case 1: /* retry limit = 8 */ + btcoexist->btc_write_2byte(btcoexist, 0x42a, 0x0808); + break; + default: + break; + } + } + + coex_dm->pre_retry_limit_type = coex_dm->cur_retry_limit_type; +} + +static void halbtc8821a1ant_ampdu_max_time(struct btc_coexist *btcoexist, + bool force_exec, u8 type) +{ + coex_dm->cur_ampdu_time_type = type; + + if (force_exec || + (coex_dm->pre_ampdu_time_type != coex_dm->cur_ampdu_time_type)) { + switch (coex_dm->cur_ampdu_time_type) { + case 0: /* normal mode */ + btcoexist->btc_write_1byte(btcoexist, 0x456, coex_dm->backup_ampdu_max_time); + break; + case 1: /* AMPDU timw = 0x38 * 32us */ + btcoexist->btc_write_1byte(btcoexist, 0x456, 0x38); + break; + default: + break; + } + } + + coex_dm->pre_ampdu_time_type = coex_dm->cur_ampdu_time_type; +} + +static void halbtc8821a1ant_limited_tx(struct btc_coexist *btcoexist, + bool force_exec, u8 ra_mask_type, + u8 arfr_type, u8 retry_limit_type, + u8 ampdu_time_type) +{ + switch (ra_mask_type) { + case 0: /* normal mode */ + update_ra_mask(btcoexist, force_exec, 0x0); + break; + case 1: /* disable cck 1/2 */ + update_ra_mask(btcoexist, force_exec, 0x00000003); + break; + case 2: /* disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4 */ + update_ra_mask(btcoexist, force_exec, 0x0001f1f7); + break; + default: + break; + } + + auto_rate_fallback_retry(btcoexist, force_exec, arfr_type); + halbtc8821a1ant_retry_limit(btcoexist, force_exec, retry_limit_type); + halbtc8821a1ant_ampdu_max_time(btcoexist, force_exec, ampdu_time_type); +} + +static void halbtc8821a1ant_limited_rx(struct btc_coexist *btcoexist, + bool force_exec, bool rej_ap_agg_pkt, + bool bt_ctrl_agg_buf_size, + u8 agg_buf_size) +{ + bool reject_rx_agg = rej_ap_agg_pkt; + bool bt_ctrl_rx_agg_size = bt_ctrl_agg_buf_size; + u8 rx_agg_size = agg_buf_size; + + /* */ + /* Rx Aggregation related setting */ + /* */ + btcoexist->btc_set(btcoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &reject_rx_agg); + /* decide BT control aggregation buf size or not */ + btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &bt_ctrl_rx_agg_size); + /* aggregation buf size, only work when BT control Rx aggregation size. */ + btcoexist->btc_set(btcoexist, BTC_SET_U1_AGG_BUF_SIZE, &rx_agg_size); + /* real update aggregation setting */ + btcoexist->btc_set(btcoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL); + +} + +static void halbtc8821a1ant_monitor_bt_ctr(struct btc_coexist *btcoexist) +{ + u32 reg_hp_tx_rx, reg_lp_tx_rx, u4_tmp; + u32 reg_hp_tx = 0, reg_hp_rx = 0, reg_lp_tx = 0, reg_lp_rx = 0; + + reg_hp_tx_rx = 0x770; + reg_lp_tx_rx = 0x774; + + u4_tmp = btcoexist->btc_read_4byte(btcoexist, reg_hp_tx_rx); + reg_hp_tx = u4_tmp & MASKLWORD; + reg_hp_rx = (u4_tmp & MASKHWORD)>>16; + + u4_tmp = btcoexist->btc_read_4byte(btcoexist, reg_lp_tx_rx); + reg_lp_tx = u4_tmp & MASKLWORD; + reg_lp_rx = (u4_tmp & MASKHWORD)>>16; + + coex_sta->high_priority_tx = reg_hp_tx; + coex_sta->high_priority_rx = reg_hp_rx; + coex_sta->low_priority_tx = reg_lp_tx; + coex_sta->low_priority_rx = reg_lp_rx; + + /* reset counter */ + btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc); +} + +static void halbtc8821a1ant_query_bt_info(struct btc_coexist *btcoexist) +{ + u8 h2c_parameter[1] = {0}; + + coex_sta->c2h_bt_info_req_sent = true; + + h2c_parameter[0] |= BIT(0); /* trigger */ + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], Query Bt Info, FW write 0x61 = 0x%x\n", + h2c_parameter[0]); + + btcoexist->btc_fill_h2c(btcoexist, 0x61, 1, h2c_parameter); +} + +static void halbtc8821a1ant_update_bt_link_info(struct btc_coexist *btcoexist) +{ + struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; + bool bt_hs_on = false; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); + + bt_link_info->bt_link_exist = coex_sta->bt_link_exist; + bt_link_info->sco_exist = coex_sta->sco_exist; + bt_link_info->a2dp_exist = coex_sta->a2dp_exist; + bt_link_info->pan_exist = coex_sta->pan_exist; + bt_link_info->hid_exist = coex_sta->hid_exist; + + /* work around for HS mode. */ + if (bt_hs_on) { + bt_link_info->pan_exist = true; + bt_link_info->bt_link_exist = true; + } + + /* check if Sco only */ + if (bt_link_info->sco_exist && + !bt_link_info->a2dp_exist && + !bt_link_info->pan_exist && + !bt_link_info->hid_exist) + bt_link_info->sco_only = true; + else + bt_link_info->sco_only = false; + + /* check if A2dp only */ + if (!bt_link_info->sco_exist && + bt_link_info->a2dp_exist && + !bt_link_info->pan_exist && + !bt_link_info->hid_exist) + bt_link_info->a2dp_only = true; + else + bt_link_info->a2dp_only = false; + + /* check if Pan only */ + if (!bt_link_info->sco_exist && + !bt_link_info->a2dp_exist && + bt_link_info->pan_exist && + !bt_link_info->hid_exist) + bt_link_info->pan_only = true; + else + bt_link_info->pan_only = false; + + /* check if Hid only */ + if (!bt_link_info->sco_exist && + !bt_link_info->a2dp_exist && + !bt_link_info->pan_exist && + bt_link_info->hid_exist) + bt_link_info->hid_only = true; + else + bt_link_info->hid_only = false; +} + +static u8 halbtc8821a1ant_action_algorithm(struct btc_coexist *btcoexist) +{ + struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; + bool bt_hs_on = false; + u8 algorithm = BT_8821A_1ANT_COEX_ALGO_UNDEFINED; + u8 num_of_diff_profile = 0; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); + + if (!bt_link_info->bt_link_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], No BT link exists!!!\n"); + return algorithm; + } + + if (bt_link_info->sco_exist) + num_of_diff_profile++; + if (bt_link_info->hid_exist) + num_of_diff_profile++; + if (bt_link_info->pan_exist) + num_of_diff_profile++; + if (bt_link_info->a2dp_exist) + num_of_diff_profile++; + + if (num_of_diff_profile == 1) { + if (bt_link_info->sco_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], BT Profile = SCO only\n"); + algorithm = BT_8821A_1ANT_COEX_ALGO_SCO; + } else { + if (bt_link_info->hid_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], BT Profile = HID only\n"); + algorithm = BT_8821A_1ANT_COEX_ALGO_HID; + } else if (bt_link_info->a2dp_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], BT Profile = A2DP only\n"); + algorithm = BT_8821A_1ANT_COEX_ALGO_A2DP; + } else if (bt_link_info->pan_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], BT Profile = PAN(HS) only\n"); + algorithm = BT_8821A_1ANT_COEX_ALGO_PANHS; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], BT Profile = PAN(EDR) only\n"); + algorithm = BT_8821A_1ANT_COEX_ALGO_PANEDR; + } + } + } + } else if (num_of_diff_profile == 2) { + if (bt_link_info->sco_exist) { + if (bt_link_info->hid_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], BT Profile = SCO + HID\n"); + algorithm = BT_8821A_1ANT_COEX_ALGO_HID; + } else if (bt_link_info->a2dp_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], BT Profile = SCO + A2DP ==> SCO\n"); + algorithm = BT_8821A_1ANT_COEX_ALGO_SCO; + } else if (bt_link_info->pan_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], BT Profile = SCO + PAN(HS)\n"); + algorithm = BT_8821A_1ANT_COEX_ALGO_SCO; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], BT Profile = SCO + PAN(EDR)\n"); + algorithm = BT_8821A_1ANT_COEX_ALGO_PANEDR_HID; + } + } + } else { + if (bt_link_info->hid_exist && + bt_link_info->a2dp_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], BT Profile = HID + A2DP\n"); + algorithm = BT_8821A_1ANT_COEX_ALGO_HID_A2DP; + } else if (bt_link_info->hid_exist && + bt_link_info->pan_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], BT Profile = HID + PAN(HS)\n"); + algorithm = BT_8821A_1ANT_COEX_ALGO_HID_A2DP; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], BT Profile = HID + PAN(EDR)\n"); + algorithm = BT_8821A_1ANT_COEX_ALGO_PANEDR_HID; + } + } else if (bt_link_info->pan_exist && + bt_link_info->a2dp_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], BT Profile = A2DP + PAN(HS)\n"); + algorithm = BT_8821A_1ANT_COEX_ALGO_A2DP_PANHS; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], BT Profile = A2DP + PAN(EDR)\n"); + algorithm = BT_8821A_1ANT_COEX_ALGO_PANEDR_A2DP; + } + } + } + } else if (num_of_diff_profile == 3) { + if (bt_link_info->sco_exist) { + if (bt_link_info->hid_exist && + bt_link_info->a2dp_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], BT Profile = SCO + HID + A2DP ==> HID\n"); + algorithm = BT_8821A_1ANT_COEX_ALGO_HID; + } else if (bt_link_info->hid_exist && + bt_link_info->pan_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], BT Profile = SCO + HID + PAN(HS)\n"); + algorithm = BT_8821A_1ANT_COEX_ALGO_HID_A2DP; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], BT Profile = SCO + HID + PAN(EDR)\n"); + algorithm = BT_8821A_1ANT_COEX_ALGO_PANEDR_HID; + } + } else if (bt_link_info->pan_exist && + bt_link_info->a2dp_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], BT Profile = SCO + A2DP + PAN(HS)\n"); + algorithm = BT_8821A_1ANT_COEX_ALGO_SCO; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], BT Profile = SCO + A2DP + PAN(EDR) ==> HID\n"); + algorithm = BT_8821A_1ANT_COEX_ALGO_PANEDR_HID; + } + } + } else { + if (bt_link_info->hid_exist && + bt_link_info->pan_exist && + bt_link_info->a2dp_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], BT Profile = HID + A2DP + PAN(HS)\n"); + algorithm = BT_8821A_1ANT_COEX_ALGO_HID_A2DP; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], BT Profile = HID + A2DP + PAN(EDR)\n"); + algorithm = BT_8821A_1ANT_COEX_ALGO_HID_A2DP_PANEDR; + } + } + } + } else if (num_of_diff_profile >= 3) { + if (bt_link_info->sco_exist) { + if (bt_link_info->hid_exist && + bt_link_info->pan_exist && + bt_link_info->a2dp_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], Error!!! BT Profile = SCO + HID + A2DP + PAN(HS)\n"); + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], BT Profile = SCO + HID + A2DP + PAN(EDR) ==>PAN(EDR)+HID\n"); + algorithm = BT_8821A_1ANT_COEX_ALGO_PANEDR_HID; + } + } + } + } + + return algorithm; +} + +static void halbtc8821a1ant_set_bt_auto_report(struct btc_coexist *btcoexist, + bool enable_auto_report) +{ + u8 h2c_parameter[1] = {0}; + + h2c_parameter[0] = 0; + + if (enable_auto_report) + h2c_parameter[0] |= BIT(0); + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], BT FW auto report : %s, FW write 0x68 = 0x%x\n", + (enable_auto_report ? "Enabled!!" : "Disabled!!"), + h2c_parameter[0]); + + btcoexist->btc_fill_h2c(btcoexist, 0x68, 1, h2c_parameter); +} + +static void halbtc8821a1ant_bt_auto_report(struct btc_coexist *btcoexist, + bool force_exec, + bool enable_auto_report) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, "[BTCoex], %s BT Auto report = %s\n", + (force_exec ? "force to" : ""), ((enable_auto_report) ? "Enabled" : "Disabled")); + coex_dm->cur_bt_auto_report = enable_auto_report; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, "[BTCoex], pre_bt_auto_report =%d, cur_bt_auto_report =%d\n", + coex_dm->pre_bt_auto_report, coex_dm->cur_bt_auto_report); + + if (coex_dm->pre_bt_auto_report == coex_dm->cur_bt_auto_report) + return; + } + halbtc8821a1ant_set_bt_auto_report(btcoexist, coex_dm->cur_bt_auto_report); + + coex_dm->pre_bt_auto_report = coex_dm->cur_bt_auto_report; +} + +static void set_sw_penalty_tx_rate_adaptive(struct btc_coexist *btcoexist, + bool low_penalty_ra) +{ + u8 h2c_parameter[6] = {0}; + + h2c_parameter[0] = 0x6; /* opCode, 0x6 = Retry_Penalty */ + + if (low_penalty_ra) { + h2c_parameter[1] |= BIT(0); + h2c_parameter[2] = 0x00; /* normal rate except MCS7/6/5, + * OFDM54/48/36 */ + h2c_parameter[3] = 0xf7; /* MCS7 or OFDM54 */ + h2c_parameter[4] = 0xf8; /* MCS6 or OFDM48 */ + h2c_parameter[5] = 0xf9; /* MCS5 or OFDM36 */ + } + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], set WiFi Low-Penalty Retry: %s", + (low_penalty_ra ? "ON!!" : "OFF!!")); + + btcoexist->btc_fill_h2c(btcoexist, 0x69, 6, h2c_parameter); +} + +static void halbtc8821a1ant_low_penalty_ra(struct btc_coexist *btcoexist, + bool force_exec, bool low_penalty_ra) +{ + coex_dm->cur_low_penalty_ra = low_penalty_ra; + + if (!force_exec) { + if (coex_dm->pre_low_penalty_ra == coex_dm->cur_low_penalty_ra) + return; + } + set_sw_penalty_tx_rate_adaptive(btcoexist, coex_dm->cur_low_penalty_ra); + + coex_dm->pre_low_penalty_ra = coex_dm->cur_low_penalty_ra; +} + +static void halbtc8821a1ant_set_coex_table(struct btc_coexist *btcoexist, + u32 val0x6c0, u32 val0x6c4, + u32 val0x6c8, u8 val0x6cc) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], set coex table, set 0x6c0 = 0x%x\n", val0x6c0); + btcoexist->btc_write_4byte(btcoexist, 0x6c0, val0x6c0); + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], set coex table, set 0x6c4 = 0x%x\n", val0x6c4); + btcoexist->btc_write_4byte(btcoexist, 0x6c4, val0x6c4); + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], set coex table, set 0x6c8 = 0x%x\n", val0x6c8); + btcoexist->btc_write_4byte(btcoexist, 0x6c8, val0x6c8); + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], set coex table, set 0x6cc = 0x%x\n", val0x6cc); + btcoexist->btc_write_1byte(btcoexist, 0x6cc, val0x6cc); +} + +static void halbtc8821a1ant_coex_table(struct btc_coexist *btcoexist, + bool force_exec, u32 val0x6c0, + u32 val0x6c4, u32 val0x6c8, u8 val0x6cc) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, + "[BTCoex], %s write Coex Table 0x6c0 = 0x%x, 0x6c4 = 0x%x, 0x6c8 = 0x%x, 0x6cc = 0x%x\n", + (force_exec ? "force to" : ""), val0x6c0, val0x6c4, + val0x6c8, val0x6cc); + coex_dm->cur_val_0x6c0 = val0x6c0; + coex_dm->cur_val_0x6c4 = val0x6c4; + coex_dm->cur_val_0x6c8 = val0x6c8; + coex_dm->cur_val_0x6cc = val0x6cc; + + if (!force_exec) { + if ((coex_dm->pre_val_0x6c0 == coex_dm->cur_val_0x6c0) && + (coex_dm->pre_val_0x6c4 == coex_dm->cur_val_0x6c4) && + (coex_dm->pre_val_0x6c8 == coex_dm->cur_val_0x6c8) && + (coex_dm->pre_val_0x6cc == coex_dm->cur_val_0x6cc)) + return; + } + halbtc8821a1ant_set_coex_table(btcoexist, val0x6c0, val0x6c4, + val0x6c8, val0x6cc); + + coex_dm->pre_val_0x6c0 = coex_dm->cur_val_0x6c0; + coex_dm->pre_val_0x6c4 = coex_dm->cur_val_0x6c4; + coex_dm->pre_val_0x6c8 = coex_dm->cur_val_0x6c8; + coex_dm->pre_val_0x6cc = coex_dm->cur_val_0x6cc; +} + +static void halbtc8821a1ant_coex_table_with_type(struct btc_coexist *btcoexist, + bool force_exec, u8 type) +{ + switch (type) { + case 0: + halbtc8821a1ant_coex_table(btcoexist, force_exec, + 0x55555555, 0x55555555, + 0xffffff, 0x3); + break; + case 1: + halbtc8821a1ant_coex_table(btcoexist, force_exec, + 0x55555555, 0x5a5a5a5a, + 0xffffff, 0x3); + break; + case 2: + halbtc8821a1ant_coex_table(btcoexist, force_exec, + 0x5a5a5a5a, 0x5a5a5a5a, + 0xffffff, 0x3); + break; + case 3: + halbtc8821a1ant_coex_table(btcoexist, force_exec, + 0x55555555, 0xaaaaaaaa, + 0xffffff, 0x3); + break; + case 4: + halbtc8821a1ant_coex_table(btcoexist, force_exec, + 0xffffffff, 0xffffffff, + 0xffffff, 0x3); + break; + case 5: + halbtc8821a1ant_coex_table(btcoexist, force_exec, + 0x5fff5fff, 0x5fff5fff, + 0xffffff, 0x3); + break; + case 6: + halbtc8821a1ant_coex_table(btcoexist, force_exec, + 0x55ff55ff, 0x5a5a5a5a, + 0xffffff, 0x3); + break; + case 7: + halbtc8821a1ant_coex_table(btcoexist, force_exec, + 0x5afa5afa, 0x5afa5afa, + 0xffffff, 0x3); + break; + default: + break; + } +} + +static void halbtc8821a1ant_set_fw_ignore_wlan_act(struct btc_coexist *btcoexist, + bool enable) +{ + u8 h2c_parameter[1] = {0}; + + if (enable) + h2c_parameter[0] |= BIT(0); /* function enable */ + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63 = 0x%x\n", + h2c_parameter[0]); + + btcoexist->btc_fill_h2c(btcoexist, 0x63, 1, h2c_parameter); +} + +static void halbtc8821a1ant_ignore_wlan_act(struct btc_coexist *btcoexist, + bool force_exec, bool enable) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, + "[BTCoex], %s turn Ignore WlanAct %s\n", + (force_exec ? "force to" : ""), (enable ? "ON" : "OFF")); + coex_dm->cur_ignore_wlan_act = enable; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], pre_ignore_wlan_act = %d, cur_ignore_wlan_act = %d!!\n", + coex_dm->pre_ignore_wlan_act, + coex_dm->cur_ignore_wlan_act); + + if (coex_dm->pre_ignore_wlan_act == + coex_dm->cur_ignore_wlan_act) + return; + } + halbtc8821a1ant_set_fw_ignore_wlan_act(btcoexist, enable); + + coex_dm->pre_ignore_wlan_act = coex_dm->cur_ignore_wlan_act; +} + +static void +halbtc8821a1ant_set_fw_pstdma( + struct btc_coexist *btcoexist, + u8 byte1, + u8 byte2, + u8 byte3, + u8 byte4, + u8 byte5 + ) +{ + u8 h2c_parameter[5] = {0}; + + h2c_parameter[0] = byte1; + h2c_parameter[1] = byte2; + h2c_parameter[2] = byte3; + h2c_parameter[3] = byte4; + h2c_parameter[4] = byte5; + + coex_dm->ps_tdma_para[0] = byte1; + coex_dm->ps_tdma_para[1] = byte2; + coex_dm->ps_tdma_para[2] = byte3; + coex_dm->ps_tdma_para[3] = byte4; + coex_dm->ps_tdma_para[4] = byte5; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, "[BTCoex], PS-TDMA H2C cmd = 0x%x%08x\n", + h2c_parameter[0], + h2c_parameter[1]<<24|h2c_parameter[2]<<16|h2c_parameter[3]<<8|h2c_parameter[4]); + + btcoexist->btc_fill_h2c(btcoexist, 0x60, 5, h2c_parameter); +} + +static void +halbtc8821a1ant_set_lps_rpwm( + struct btc_coexist *btcoexist, + u8 lps_val, + u8 rpwm_val + ) +{ + u8 lps = lps_val; + u8 rpwm = rpwm_val; + + btcoexist->btc_set(btcoexist, BTC_SET_U1_LPS_VAL, &lps); + btcoexist->btc_set(btcoexist, BTC_SET_U1_RPWM_VAL, &rpwm); +} + +static void +halbtc8821a1ant_lps_rpwm( + struct btc_coexist *btcoexist, + bool force_exec, + u8 lps_val, + u8 rpwm_val + ) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, "[BTCoex], %s set lps/rpwm = 0x%x/0x%x\n", + (force_exec ? "force to" : ""), lps_val, rpwm_val); + coex_dm->cur_lps = lps_val; + coex_dm->cur_rpwm = rpwm_val; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, "[BTCoex], LPS-RxBeaconMode = 0x%x , LPS-RPWM = 0x%x!!\n", + coex_dm->cur_lps, coex_dm->cur_rpwm); + + if ((coex_dm->pre_lps == coex_dm->cur_lps) && + (coex_dm->pre_rpwm == coex_dm->cur_rpwm)) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, "[BTCoex], LPS-RPWM_Last = 0x%x , LPS-RPWM_Now = 0x%x!!\n", + coex_dm->pre_rpwm, coex_dm->cur_rpwm); + + return; + } + } + halbtc8821a1ant_set_lps_rpwm(btcoexist, lps_val, rpwm_val); + + coex_dm->pre_lps = coex_dm->cur_lps; + coex_dm->pre_rpwm = coex_dm->cur_rpwm; +} + +static void +halbtc8821a1ant_sw_mechanism( + struct btc_coexist *btcoexist, + bool low_penalty_ra + ) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, "[BTCoex], SM[LpRA] = %d\n", low_penalty_ra); + + halbtc8821a1ant_low_penalty_ra(btcoexist, NORMAL_EXEC, low_penalty_ra); +} + +static void +halbtc8821a1ant_set_ant_path( + struct btc_coexist *btcoexist, + u8 ant_pos_type, + bool init_hw_cfg, + bool wifi_off + ) +{ + struct btc_board_info *board_info = &btcoexist->board_info; + u32 u4_tmp = 0; + u8 h2c_parameter[2] = {0}; + + if (init_hw_cfg) { + /* 0x4c[23] = 0, 0x4c[24] = 1 Antenna control by WL/BT */ + u4_tmp = btcoexist->btc_read_4byte(btcoexist, 0x4c); + u4_tmp &= ~BIT(23); + u4_tmp |= BIT(24); + btcoexist->btc_write_4byte(btcoexist, 0x4c, u4_tmp); + + btcoexist->btc_write_1byte_bitmask(btcoexist, 0x975, 0x3, 0x3); + btcoexist->btc_write_1byte(btcoexist, 0xcb4, 0x77); + + if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) { + /* tell firmware "antenna inverse" ==> WRONG firmware antenna control code.==>need fw to fix */ + h2c_parameter[0] = 1; + h2c_parameter[1] = 1; + btcoexist->btc_fill_h2c(btcoexist, 0x65, 2, h2c_parameter); + + btcoexist->btc_write_1byte_bitmask(btcoexist, 0x64, 0x1, 0x1); /* Main Ant to BT for IPS case 0x4c[23] = 1 */ + } else { + /* tell firmware "no antenna inverse" ==> WRONG firmware antenna control code.==>need fw to fix */ + h2c_parameter[0] = 0; + h2c_parameter[1] = 1; + btcoexist->btc_fill_h2c(btcoexist, 0x65, 2, h2c_parameter); + + btcoexist->btc_write_1byte_bitmask(btcoexist, 0x64, 0x1, 0x0); /* Aux Ant to BT for IPS case 0x4c[23] = 1 */ + } + } else if (wifi_off) { + /* 0x4c[24:23] = 00, Set Antenna control by BT_RFE_CTRL BT Vendor 0xac = 0xf002 */ + u4_tmp = btcoexist->btc_read_4byte(btcoexist, 0x4c); + u4_tmp &= ~BIT(23); + u4_tmp &= ~BIT(24); + btcoexist->btc_write_4byte(btcoexist, 0x4c, u4_tmp); + } + + /* ext switch setting */ + switch (ant_pos_type) { + case BTC_ANT_PATH_WIFI: + if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) + btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcb7, 0x30, 0x1); + else + btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcb7, 0x30, 0x2); + break; + case BTC_ANT_PATH_BT: + if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) + btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcb7, 0x30, 0x2); + else + btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcb7, 0x30, 0x1); + break; + case BTC_ANT_PATH_PTA: + default: + if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) + btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcb7, 0x30, 0x1); + else + btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcb7, 0x30, 0x2); + break; + } +} + +static void +halbtc8821a1ant_ps_tdma( + struct btc_coexist *btcoexist, + bool force_exec, + bool turn_on, + u8 type + ) +{ + u8 rssi_adjust_val = 0; + + coex_dm->cur_ps_tdma_on = turn_on; + coex_dm->cur_ps_tdma = type; + + if (!force_exec) { + if (coex_dm->cur_ps_tdma_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, "[BTCoex], ********** TDMA(on, %d) **********\n", + coex_dm->cur_ps_tdma); + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, "[BTCoex], ********** TDMA(off, %d) **********\n", + coex_dm->cur_ps_tdma); + } + + if ((coex_dm->pre_ps_tdma_on == coex_dm->cur_ps_tdma_on) && + (coex_dm->pre_ps_tdma == coex_dm->cur_ps_tdma)) + return; + } + if (turn_on) { + switch (type) { + default: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x51, 0x1a, 0x1a, 0x0, 0x50); + break; + case 1: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x51, 0x3a, 0x03, 0x10, 0x50); + rssi_adjust_val = 11; + break; + case 2: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x51, 0x2b, 0x03, 0x10, 0x50); + rssi_adjust_val = 14; + break; + case 3: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x51, 0x1d, 0x1d, 0x0, 0x10); + break; + case 4: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x93, 0x15, 0x3, 0x14, 0x0); + rssi_adjust_val = 17; + break; + case 5: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x61, 0x15, 0x3, 0x11, 0x10); + break; + case 6: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x13, 0xa, 0x3, 0x0, 0x0); + break; + case 7: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x13, 0xc, 0x5, 0x0, 0x0); + break; + case 8: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x93, 0x25, 0x3, 0x10, 0x0); + break; + case 9: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x51, 0x21, 0x3, 0x10, 0x50); + rssi_adjust_val = 18; + break; + case 10: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x13, 0xa, 0xa, 0x0, 0x40); + break; + case 11: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x51, 0x14, 0x03, 0x10, 0x10); + rssi_adjust_val = 20; + break; + case 12: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x51, 0x0a, 0x0a, 0x0, 0x50); + break; + case 13: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x51, 0x18, 0x18, 0x0, 0x10); + break; + case 14: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x51, 0x21, 0x3, 0x10, 0x10); + break; + case 15: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x13, 0xa, 0x3, 0x8, 0x0); + break; + case 16: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x93, 0x15, 0x3, 0x10, 0x0); + rssi_adjust_val = 18; + break; + case 18: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x93, 0x25, 0x3, 0x10, 0x0); + rssi_adjust_val = 14; + break; + case 20: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x61, 0x35, 0x03, 0x11, 0x10); + break; + case 21: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x61, 0x15, 0x03, 0x11, 0x10); + break; + case 22: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x61, 0x25, 0x03, 0x11, 0x10); + break; + case 23: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0xe3, 0x25, 0x3, 0x31, 0x18); + rssi_adjust_val = 22; + break; + case 24: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0xe3, 0x15, 0x3, 0x31, 0x18); + rssi_adjust_val = 22; + break; + case 25: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0xe3, 0xa, 0x3, 0x31, 0x18); + rssi_adjust_val = 22; + break; + case 26: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0xe3, 0xa, 0x3, 0x31, 0x18); + rssi_adjust_val = 22; + break; + case 27: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0xe3, 0x25, 0x3, 0x31, 0x98); + rssi_adjust_val = 22; + break; + case 28: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x69, 0x25, 0x3, 0x31, 0x0); + break; + case 29: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0xab, 0x1a, 0x1a, 0x1, 0x10); + break; + case 30: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x51, 0x14, 0x3, 0x10, 0x50); + break; + case 31: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0xd3, 0x1a, 0x1a, 0, 0x58); + break; + case 32: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x61, 0xa, 0x3, 0x10, 0x0); + break; + case 33: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0xa3, 0x25, 0x3, 0x30, 0x90); + break; + case 34: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x53, 0x1a, 0x1a, 0x0, 0x10); + break; + case 35: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x63, 0x1a, 0x1a, 0x0, 0x10); + break; + case 36: + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0xd3, 0x12, 0x3, 0x14, 0x50); + break; + } + } else { + /* disable PS tdma */ + switch (type) { + case 8: /* PTA Control */ + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x8, 0x0, 0x0, 0x0, 0x0); + halbtc8821a1ant_set_ant_path(btcoexist, BTC_ANT_PATH_PTA, false, false); + break; + case 0: + default: /* Software control, Antenna at BT side */ + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x0, 0x0, 0x0, 0x0, 0x0); + halbtc8821a1ant_set_ant_path(btcoexist, BTC_ANT_PATH_BT, false, false); + break; + case 9: /* Software control, Antenna at WiFi side */ + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x0, 0x0, 0x0, 0x0, 0x0); + halbtc8821a1ant_set_ant_path(btcoexist, BTC_ANT_PATH_WIFI, false, false); + break; + case 10: /* under 5G */ + halbtc8821a1ant_set_fw_pstdma(btcoexist, 0x0, 0x0, 0x0, 0x8, 0x0); + halbtc8821a1ant_set_ant_path(btcoexist, BTC_ANT_PATH_BT, false, false); + break; + } + } + rssi_adjust_val = 0; + btcoexist->btc_set(btcoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE, &rssi_adjust_val); + + /* update pre state */ + coex_dm->pre_ps_tdma_on = coex_dm->cur_ps_tdma_on; + coex_dm->pre_ps_tdma = coex_dm->cur_ps_tdma; +} + +static bool +halbtc8821a1ant_is_common_action( + struct btc_coexist *btcoexist + ) +{ + bool bCommon = false, wifi_connected = false, wifi_busy = false; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, &wifi_connected); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); + + if (!wifi_connected && + BT_8821A_1ANT_BT_STATUS_NON_CONNECTED_IDLE == coex_dm->bt_status) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], Wifi non connected-idle + BT non connected-idle!!\n"); + halbtc8821a1ant_sw_mechanism(btcoexist, false); + + bCommon = true; + } else if (wifi_connected && + (BT_8821A_1ANT_BT_STATUS_NON_CONNECTED_IDLE == coex_dm->bt_status)) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], Wifi connected + BT non connected-idle!!\n"); + halbtc8821a1ant_sw_mechanism(btcoexist, false); + + bCommon = true; + } else if (!wifi_connected && + (BT_8821A_1ANT_BT_STATUS_CONNECTED_IDLE == coex_dm->bt_status)) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], Wifi non connected-idle + BT connected-idle!!\n"); + halbtc8821a1ant_sw_mechanism(btcoexist, false); + + bCommon = true; + } else if (wifi_connected && + (BT_8821A_1ANT_BT_STATUS_CONNECTED_IDLE == coex_dm->bt_status)) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], Wifi connected + BT connected-idle!!\n"); + halbtc8821a1ant_sw_mechanism(btcoexist, false); + + bCommon = true; + } else if (!wifi_connected && + (BT_8821A_1ANT_BT_STATUS_CONNECTED_IDLE != coex_dm->bt_status)) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], Wifi non connected-idle + BT Busy!!\n"); + halbtc8821a1ant_sw_mechanism(btcoexist, false); + + bCommon = true; + } else { + if (wifi_busy) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], Wifi Connected-Busy + BT Busy!!\n"); + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], Wifi Connected-Idle + BT Busy!!\n"); + } + + bCommon = false; + } + + return bCommon; +} + +static void +halbtc8821a1ant_tdma_duration_adjust_for_acl( + struct btc_coexist *btcoexist, + u8 wifi_status + ) +{ + static long up, dn, m, n, wait_count; + long result; /* 0: no change, +1: increase WiFi duration, -1: decrease WiFi duration */ + u8 retry_count = 0, bt_info_ext; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, "[BTCoex], TdmaDurationAdjustForAcl()\n"); + + if ((BT_8821A_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifi_status) || + (BT_8821A_1ANT_WIFI_STATUS_CONNECTED_SCAN == wifi_status) || + (BT_8821A_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT == wifi_status)) { + if (coex_dm->cur_ps_tdma != 1 && + coex_dm->cur_ps_tdma != 2 && + coex_dm->cur_ps_tdma != 3 && + coex_dm->cur_ps_tdma != 9) { + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 9); + coex_dm->ps_tdma_du_adj_type = 9; + + up = 0; + dn = 0; + m = 1; + n = 3; + result = 0; + wait_count = 0; + } + return; + } + + if (!coex_dm->auto_tdma_adjust) { + coex_dm->auto_tdma_adjust = true; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, "[BTCoex], first run TdmaDurationAdjust()!!\n"); + + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 2); + coex_dm->ps_tdma_du_adj_type = 2; + /* */ + up = 0; + dn = 0; + m = 1; + n = 3; + result = 0; + wait_count = 0; + } else { + /* accquire the BT TRx retry count from BT_Info byte2 */ + retry_count = coex_sta->bt_retry_cnt; + bt_info_ext = coex_sta->bt_info_ext; + /* BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, "[BTCoex], retry_count = %d\n", retry_count)); */ + /* BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, "[BTCoex], up =%d, dn =%d, m =%d, n =%d, wait_count =%d\n", */ + /* up, dn, m, n, wait_count)); */ + result = 0; + wait_count++; + + if (retry_count == 0) { + /* no retry in the last 2-second duration */ + up++; + dn--; + + if (dn <= 0) + dn = 0; + + if (up >= n) { + wait_count = 0; + n = 3; + up = 0; + dn = 0; + result = 1; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, "[BTCoex], Increase wifi duration!!\n"); + } + } else if (retry_count <= 3) { + up--; + dn++; + + if (up <= 0) + up = 0; + + if (dn == 2) { + if (wait_count <= 2) + m++; + else + m = 1; + if (m >= 20) + m = 20; + + n = 3*m; + up = 0; + dn = 0; + wait_count = 0; + result = -1; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, "[BTCoex], Decrease wifi duration for retryCounter<3!!\n"); + } + } else { + if (wait_count == 1) + m++; + else + m = 1; + if (m >= 20) + m = 20; + + n = 3*m; + up = 0; + dn = 0; + wait_count = 0; + result = -1; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, "[BTCoex], Decrease wifi duration for retryCounter>3!!\n"); + } + + if (result == -1) { + if ((BT_INFO_8821A_1ANT_A2DP_BASIC_RATE(bt_info_ext)) && + ((coex_dm->cur_ps_tdma == 1) || (coex_dm->cur_ps_tdma == 2))) { + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 9); + coex_dm->ps_tdma_du_adj_type = 9; + } else if (coex_dm->cur_ps_tdma == 1) { + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 2); + coex_dm->ps_tdma_du_adj_type = 2; + } else if (coex_dm->cur_ps_tdma == 2) { + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 9); + coex_dm->ps_tdma_du_adj_type = 9; + } else if (coex_dm->cur_ps_tdma == 9) { + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } + } else if (result == 1) { + if ((BT_INFO_8821A_1ANT_A2DP_BASIC_RATE(bt_info_ext)) && + ((coex_dm->cur_ps_tdma == 1) || (coex_dm->cur_ps_tdma == 2))) { + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 9); + coex_dm->ps_tdma_du_adj_type = 9; + } else if (coex_dm->cur_ps_tdma == 11) { + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 9); + coex_dm->ps_tdma_du_adj_type = 9; + } else if (coex_dm->cur_ps_tdma == 9) { + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 2); + coex_dm->ps_tdma_du_adj_type = 2; + } else if (coex_dm->cur_ps_tdma == 2) { + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 1); + coex_dm->ps_tdma_du_adj_type = 1; + } + } else { + /* no change */ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, "[BTCoex], ********** TDMA(on, %d) **********\n", + coex_dm->cur_ps_tdma); + } + + if (coex_dm->cur_ps_tdma != 1 && + coex_dm->cur_ps_tdma != 2 && + coex_dm->cur_ps_tdma != 9 && + coex_dm->cur_ps_tdma != 11) { + /* recover to previous adjust type */ + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, coex_dm->ps_tdma_du_adj_type); + } + } +} + +static void +halbtc8821a1ant_ps_tdma_check_for_power_save_state( + struct btc_coexist *btcoexist, + bool new_ps_state + ) +{ + u8 lps_mode = 0x0; + + btcoexist->btc_get(btcoexist, BTC_GET_U1_LPS_MODE, &lps_mode); + + if (lps_mode) { + /* already under LPS state */ + if (!new_ps_state) { + /* will leave LPS state, turn off psTdma first */ + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 0); + } + } else { + /* NO PS state */ + if (new_ps_state) { + /* will enter LPS state, turn off psTdma first */ + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 0); + } else { + /* keep state under NO PS state, do nothing. */ + } + } +} + +static void +halbtc8821a1ant_power_save_state( + struct btc_coexist *btcoexist, + u8 ps_type, + u8 lps_val, + u8 rpwm_val + ) +{ + bool low_pwr_disable = false; + + switch (ps_type) { + case BTC_PS_WIFI_NATIVE: + /* recover to original 32k low power setting */ + low_pwr_disable = false; + btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &low_pwr_disable); + btcoexist->btc_set(btcoexist, BTC_SET_ACT_NORMAL_LPS, NULL); + break; + case BTC_PS_LPS_ON: + halbtc8821a1ant_ps_tdma_check_for_power_save_state(btcoexist, true); + halbtc8821a1ant_lps_rpwm(btcoexist, NORMAL_EXEC, lps_val, rpwm_val); + /* when coex force to enter LPS, do not enter 32k low power. */ + low_pwr_disable = true; + btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &low_pwr_disable); + /* power save must executed before psTdma. */ + btcoexist->btc_set(btcoexist, BTC_SET_ACT_ENTER_LPS, NULL); + break; + case BTC_PS_LPS_OFF: + halbtc8821a1ant_ps_tdma_check_for_power_save_state(btcoexist, false); + btcoexist->btc_set(btcoexist, BTC_SET_ACT_LEAVE_LPS, NULL); + break; + default: + break; + } +} + +static void +halbtc8821a1ant_coex_under_5g( + struct btc_coexist *btcoexist + ) +{ + halbtc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); + + halbtc8821a1ant_ignore_wlan_act(btcoexist, NORMAL_EXEC, true); + + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 10); + + halbtc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0); + + halbtc8821a1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0); + + halbtc8821a1ant_limited_rx(btcoexist, NORMAL_EXEC, false, false, 5); +} + +static void +halbtc8821a1ant_action_wifi_only( + struct btc_coexist *btcoexist + ) +{ + halbtc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0); + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 9); +} + +static void +halbtc8821a1ant_monitor_bt_enable_disable( + struct btc_coexist *btcoexist + ) +{ + static bool pre_bt_disabled; + static u32 bt_disable_cnt; + bool bt_active = true, bt_disabled = false; + + /* This function check if bt is disabled */ + + if (coex_sta->high_priority_tx == 0 && + coex_sta->high_priority_rx == 0 && + coex_sta->low_priority_tx == 0 && + coex_sta->low_priority_rx == 0) { + bt_active = false; + } + if (coex_sta->high_priority_tx == 0xffff && + coex_sta->high_priority_rx == 0xffff && + coex_sta->low_priority_tx == 0xffff && + coex_sta->low_priority_rx == 0xffff) { + bt_active = false; + } + if (bt_active) { + bt_disable_cnt = 0; + bt_disabled = false; + btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_DISABLE, + &bt_disabled); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, + "[BTCoex], BT is enabled !!\n"); + } else { + bt_disable_cnt++; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, + "[BTCoex], bt all counters = 0, %d times!!\n", + bt_disable_cnt); + if (bt_disable_cnt >= 2) { + bt_disabled = true; + btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_DISABLE, + &bt_disabled); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, + "[BTCoex], BT is disabled !!\n"); + halbtc8821a1ant_action_wifi_only(btcoexist); + } + } + if (pre_bt_disabled != bt_disabled) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, + "[BTCoex], BT is from %s to %s!!\n", + (pre_bt_disabled ? "disabled" : "enabled"), + (bt_disabled ? "disabled" : "enabled")); + pre_bt_disabled = bt_disabled; + if (bt_disabled) { + btcoexist->btc_set(btcoexist, + BTC_SET_ACT_LEAVE_LPS, NULL); + btcoexist->btc_set(btcoexist, + BTC_SET_ACT_NORMAL_LPS, NULL); + } + } +} + +/* Software Coex Mechanism start */ +static void halbtc8821a1ant_action_sco(struct btc_coexist *btcoexist) +{ + halbtc8821a1ant_sw_mechanism(btcoexist, true); +} + +static void halbtc8821a1ant_action_hid(struct btc_coexist *btcoexist) +{ + halbtc8821a1ant_sw_mechanism(btcoexist, true); +} + +/* A2DP only / PAN(EDR) only/ A2DP+PAN(HS) */ +static void halbtc8821a1ant_action_a2dp(struct btc_coexist *btcoexist) +{ + halbtc8821a1ant_sw_mechanism(btcoexist, false); +} + +static void halbtc8821a1ant_action_a2dp_pan_hs(struct btc_coexist *btcoexist) +{ + halbtc8821a1ant_sw_mechanism(btcoexist, false); +} + +static void halbtc8821a1ant_action_pan_edr(struct btc_coexist *btcoexist) +{ + halbtc8821a1ant_sw_mechanism(btcoexist, false); +} + +/* PAN(HS) only */ +static void halbtc8821a1ant_action_pan_hs(struct btc_coexist *btcoexist) +{ + halbtc8821a1ant_sw_mechanism(btcoexist, false); +} + +/* PAN(EDR)+A2DP */ +static void halbtc8821a1ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist) +{ + halbtc8821a1ant_sw_mechanism(btcoexist, false); +} + +static void halbtc8821a1ant_action_pan_edr_hid(struct btc_coexist *btcoexist) +{ + halbtc8821a1ant_sw_mechanism(btcoexist, true); +} + +/* HID+A2DP+PAN(EDR) */ +static void halbtc8821a1ant_action_hid_a2dp_pan_edr(struct btc_coexist *btcoexist) +{ + halbtc8821a1ant_sw_mechanism(btcoexist, true); +} + +static void halbtc8821a1ant_action_hid_a2dp(struct btc_coexist *btcoexist) +{ + halbtc8821a1ant_sw_mechanism(btcoexist, true); +} + +/* Non-Software Coex Mechanism start */ +static void halbtc8821a1ant_action_hs(struct btc_coexist *btcoexist) +{ + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5); + halbtc8821a1ant_coex_table_with_type(btcoexist, FORCE_EXEC, 2); +} + +static void halbtc8821a1ant_action_bt_inquiry(struct btc_coexist *btcoexist) +{ + struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; + bool wifi_connected = false; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, &wifi_connected); + + if (!wifi_connected) { + halbtc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5); + halbtc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1); + } else if ((bt_link_info->sco_exist) || + (bt_link_info->hid_only)) { + /* SCO/HID-only busy */ + halbtc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 32); + halbtc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1); + } else { + halbtc8821a1ant_power_save_state(btcoexist, BTC_PS_LPS_ON, 0x50, 0x4); + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 30); + halbtc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1); + } +} + +static void +halbtc8821a1ant_action_bt_sco_hid_only_busy( + struct btc_coexist *btcoexist, + u8 wifi_status + ) +{ + /* tdma and coex table */ + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5); + + if (BT_8821A_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifi_status) + halbtc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1); + else + halbtc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1); +} + +static void action_wifi_connected_bt_acl_busy(struct btc_coexist *btcoexist, u8 wifi_status) +{ + u8 bt_rssi_state; + + struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; + bt_rssi_state = halbtc8821a1ant_bt_rssi_state(2, 28, 0); + + if (bt_link_info->hid_only) { + /* HID */ + halbtc8821a1ant_action_bt_sco_hid_only_busy(btcoexist, wifi_status); + coex_dm->auto_tdma_adjust = false; + return; + } else if (bt_link_info->a2dp_only) { /* A2DP */ + if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || + (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8821a1ant_tdma_duration_adjust_for_acl(btcoexist, wifi_status); + } else { /* for low BT RSSI */ + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 11); + coex_dm->auto_tdma_adjust = false; + } + + halbtc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1); + } else if (bt_link_info->hid_exist && bt_link_info->a2dp_exist) { + /* HID+A2DP */ + if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || + (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14); + coex_dm->auto_tdma_adjust = false; + } else /* for low BT RSSI */ { + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 11); + coex_dm->auto_tdma_adjust = false; + } + + halbtc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1); + } else if ((bt_link_info->pan_only) || (bt_link_info->hid_exist && bt_link_info->pan_exist)) { + /* PAN(OPP, FTP), HID+PAN(OPP, FTP) */ + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 3); + halbtc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1); + coex_dm->auto_tdma_adjust = false; + } else if (((bt_link_info->a2dp_exist) && (bt_link_info->pan_exist)) || + (bt_link_info->hid_exist && bt_link_info->a2dp_exist && + bt_link_info->pan_exist)) { + /* A2DP+PAN(OPP, FTP), HID+A2DP+PAN(OPP, FTP) */ + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 13); + halbtc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1); + coex_dm->auto_tdma_adjust = false; + } else { + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 11); + halbtc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1); + coex_dm->auto_tdma_adjust = false; + } +} + +static void +halbtc8821a1ant_action_wifi_not_connected( + struct btc_coexist *btcoexist + ) +{ + /* power save state */ + halbtc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); + + /* tdma and coex table */ + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8); + halbtc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0); +} + +static void wifi_not_connected_asso_auth_scan(struct btc_coexist *btcoexist) +{ + halbtc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); + + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 22); + halbtc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1); +} + +static void +halbtc8821a1ant_action_wifi_connected_scan( + struct btc_coexist *btcoexist + ) +{ + struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; + + /* power save state */ + halbtc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); + + /* tdma and coex table */ + if (BT_8821A_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) { + if (bt_link_info->a2dp_exist && bt_link_info->pan_exist) { + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 22); + halbtc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1); + } else { + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20); + halbtc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1); + } + } else if ((BT_8821A_1ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) || + (BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY == coex_dm->bt_status)) { + halbtc8821a1ant_action_bt_sco_hid_only_busy(btcoexist, + BT_8821A_1ANT_WIFI_STATUS_CONNECTED_SCAN); + } else { + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20); + halbtc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1); + } +} + +static void action_wifi_connected_special_packet(struct btc_coexist *btcoexist) +{ + bool hs_connecting = false; + struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_CONNECTING, &hs_connecting); + + halbtc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); + + /* tdma and coex table */ + if (BT_8821A_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) { + if (bt_link_info->a2dp_exist && bt_link_info->pan_exist) { + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 22); + halbtc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1); + } else { + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20); + halbtc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1); + } + } else { + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20); + halbtc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1); + } +} + +static void halbtc8821a1ant_action_wifi_connected(struct btc_coexist *btcoexist) +{ + bool wifi_busy = false; + bool scan = false, link = false, roam = false; + bool under_4way = false; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], CoexForWifiConnect() ===>\n"); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &under_4way); + if (under_4way) { + action_wifi_connected_special_packet(btcoexist); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], CoexForWifiConnect(), return for wifi is under 4way<===\n"); + return; + } + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam); + if (scan || link || roam) { + halbtc8821a1ant_action_wifi_connected_scan(btcoexist); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], CoexForWifiConnect(), return for wifi is under scan<===\n"); + return; + } + + /* power save state */ + if (BT_8821A_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status && !btcoexist->bt_link_info.hid_only) + halbtc8821a1ant_power_save_state(btcoexist, BTC_PS_LPS_ON, 0x50, 0x4); + else + halbtc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); + + /* tdma and coex table */ + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); + if (!wifi_busy) { + if (BT_8821A_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) { + action_wifi_connected_bt_acl_busy(btcoexist, + BT_8821A_1ANT_WIFI_STATUS_CONNECTED_IDLE); + } else if ((BT_8821A_1ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) || + (BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY == coex_dm->bt_status)) { + halbtc8821a1ant_action_bt_sco_hid_only_busy(btcoexist, + BT_8821A_1ANT_WIFI_STATUS_CONNECTED_IDLE); + } else { + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5); + halbtc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2); + } + } else { + if (BT_8821A_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) { + action_wifi_connected_bt_acl_busy(btcoexist, + BT_8821A_1ANT_WIFI_STATUS_CONNECTED_BUSY); + } else if ((BT_8821A_1ANT_BT_STATUS_SCO_BUSY == + coex_dm->bt_status) || + (BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY == + coex_dm->bt_status)) { + halbtc8821a1ant_action_bt_sco_hid_only_busy(btcoexist, + BT_8821A_1ANT_WIFI_STATUS_CONNECTED_BUSY); + } else { + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, + true, 5); + halbtc8821a1ant_coex_table_with_type(btcoexist, + NORMAL_EXEC, 2); + } + } +} + +static void run_sw_coexist_mechanism(struct btc_coexist *btcoexist) +{ + u8 algorithm = 0; + + algorithm = halbtc8821a1ant_action_algorithm(btcoexist); + coex_dm->cur_algorithm = algorithm; + + if (!halbtc8821a1ant_is_common_action(btcoexist)) { + switch (coex_dm->cur_algorithm) { + case BT_8821A_1ANT_COEX_ALGO_SCO: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action algorithm = SCO.\n"); + halbtc8821a1ant_action_sco(btcoexist); + break; + case BT_8821A_1ANT_COEX_ALGO_HID: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action algorithm = HID.\n"); + halbtc8821a1ant_action_hid(btcoexist); + break; + case BT_8821A_1ANT_COEX_ALGO_A2DP: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action algorithm = A2DP.\n"); + halbtc8821a1ant_action_a2dp(btcoexist); + break; + case BT_8821A_1ANT_COEX_ALGO_A2DP_PANHS: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action algorithm = A2DP+PAN(HS).\n"); + halbtc8821a1ant_action_a2dp_pan_hs(btcoexist); + break; + case BT_8821A_1ANT_COEX_ALGO_PANEDR: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action algorithm = PAN(EDR).\n"); + halbtc8821a1ant_action_pan_edr(btcoexist); + break; + case BT_8821A_1ANT_COEX_ALGO_PANHS: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action algorithm = HS mode.\n"); + halbtc8821a1ant_action_pan_hs(btcoexist); + break; + case BT_8821A_1ANT_COEX_ALGO_PANEDR_A2DP: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action algorithm = PAN+A2DP.\n"); + halbtc8821a1ant_action_pan_edr_a2dp(btcoexist); + break; + case BT_8821A_1ANT_COEX_ALGO_PANEDR_HID: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action algorithm = PAN(EDR)+HID.\n"); + halbtc8821a1ant_action_pan_edr_hid(btcoexist); + break; + case BT_8821A_1ANT_COEX_ALGO_HID_A2DP_PANEDR: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action algorithm = HID+A2DP+PAN.\n"); + halbtc8821a1ant_action_hid_a2dp_pan_edr(btcoexist); + break; + case BT_8821A_1ANT_COEX_ALGO_HID_A2DP: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action algorithm = HID+A2DP.\n"); + halbtc8821a1ant_action_hid_a2dp(btcoexist); + break; + default: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action algorithm = coexist All Off!!\n"); + break; + } + coex_dm->pre_algorithm = coex_dm->cur_algorithm; + } +} + +static void halbtc8821a1ant_run_coexist_mechanism(struct btc_coexist *btcoexist) +{ + struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; + bool wifi_connected = false, bt_hs_on = false; + bool increase_scan_dev_num = false; + bool bt_ctrl_agg_buf_size = false; + u8 agg_buf_size = 5; + u8 wifi_rssi_state = BTC_RSSI_STATE_HIGH; + bool wifi_under_5g = false; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], RunCoexistMechanism() ===>\n"); + + if (btcoexist->manual_control) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n"); + return; + } + + if (btcoexist->stop_coex_dm) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], RunCoexistMechanism(), return for Stop Coex DM <===\n"); + return; + } + + if (coex_sta->under_ips) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], wifi is under IPS !!!\n"); + return; + } + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, + &wifi_under_5g); + if (wifi_under_5g) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], RunCoexistMechanism(), return for 5G <===\n"); + halbtc8821a1ant_coex_under_5g(btcoexist); + return; + } + + if ((BT_8821A_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) || + (BT_8821A_1ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) || + (BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY == coex_dm->bt_status)) { + increase_scan_dev_num = true; + } + + btcoexist->btc_set(btcoexist, BTC_SET_BL_INC_SCAN_DEV_NUM, + &increase_scan_dev_num); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, + &wifi_connected); + + if (!bt_link_info->sco_exist && !bt_link_info->hid_exist) { + halbtc8821a1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0); + } else { + if (wifi_connected) { + wifi_rssi_state = Wifi_rssi_state(btcoexist, 1, 2, + 30, 0); + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) + halbtc8821a1ant_limited_tx(btcoexist, + NORMAL_EXEC, 1, 1, + 1, 1); + else + halbtc8821a1ant_limited_tx(btcoexist, + NORMAL_EXEC, 1, 1, + 1, 1); + } else { + halbtc8821a1ant_limited_tx(btcoexist, NORMAL_EXEC, + 0, 0, 0, 0); + } + } + + if (bt_link_info->sco_exist) { + bt_ctrl_agg_buf_size = true; + agg_buf_size = 0x3; + } else if (bt_link_info->hid_exist) { + bt_ctrl_agg_buf_size = true; + agg_buf_size = 0x5; + } else if (bt_link_info->a2dp_exist || bt_link_info->pan_exist) { + bt_ctrl_agg_buf_size = true; + agg_buf_size = 0x8; + } + halbtc8821a1ant_limited_rx(btcoexist, NORMAL_EXEC, false, + bt_ctrl_agg_buf_size, agg_buf_size); + + run_sw_coexist_mechanism(btcoexist); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); + if (coex_sta->c2h_bt_inquiry_page) { + halbtc8821a1ant_action_bt_inquiry(btcoexist); + return; + } else if (bt_hs_on) { + halbtc8821a1ant_action_hs(btcoexist); + return; + } + + if (!wifi_connected) { + bool scan = false, link = false, roam = false; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], wifi is non connected-idle !!!\n"); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam); + + if (scan || link || roam) + wifi_not_connected_asso_auth_scan(btcoexist); + else + halbtc8821a1ant_action_wifi_not_connected(btcoexist); + } else { + /* wifi LPS/Busy */ + halbtc8821a1ant_action_wifi_connected(btcoexist); + } +} + +static void halbtc8821a1ant_init_coex_dm(struct btc_coexist *btcoexist) +{ + /* force to reset coex mechanism */ + /* sw all off */ + halbtc8821a1ant_sw_mechanism(btcoexist, false); + + halbtc8821a1ant_ps_tdma(btcoexist, FORCE_EXEC, false, 8); + halbtc8821a1ant_coex_table_with_type(btcoexist, FORCE_EXEC, 0); +} + +static void halbtc8821a1ant_init_hw_config(struct btc_coexist *btcoexist, + bool back_up) +{ + u8 u1_tmp = 0; + bool wifi_under_5g = false; + + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], 1Ant Init HW Config!!\n"); + + if (back_up) { + coex_dm->backup_arfr_cnt1 = + btcoexist->btc_read_4byte(btcoexist, 0x430); + coex_dm->backup_arfr_cnt2 = + btcoexist->btc_read_4byte(btcoexist, 0x434); + coex_dm->backup_retry_limit = + btcoexist->btc_read_2byte(btcoexist, 0x42a); + coex_dm->backup_ampdu_max_time = + btcoexist->btc_read_1byte(btcoexist, 0x456); + } + + /* 0x790[5:0] = 0x5 */ + u1_tmp = btcoexist->btc_read_1byte(btcoexist, 0x790); + u1_tmp &= 0xc0; + u1_tmp |= 0x5; + btcoexist->btc_write_1byte(btcoexist, 0x790, u1_tmp); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g); + + /* Antenna config */ + if (wifi_under_5g) + halbtc8821a1ant_set_ant_path(btcoexist, BTC_ANT_PATH_BT, + true, false); + else + halbtc8821a1ant_set_ant_path(btcoexist, BTC_ANT_PATH_PTA, + true, false); + /* PTA parameter */ + halbtc8821a1ant_coex_table_with_type(btcoexist, FORCE_EXEC, 0); + + /* Enable counter statistics */ + /* 0x76e[3] = 1, WLAN_Act control by PTA */ + btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc); + btcoexist->btc_write_1byte(btcoexist, 0x778, 0x3); + btcoexist->btc_write_1byte_bitmask(btcoexist, 0x40, 0x20, 0x1); +} + +/* */ +/* work around function start with wa_halbtc8821a1ant_ */ +/* */ +/* */ +/* extern function start with EXhalbtc8821a1ant_ */ +/* */ +void +ex_halbtc8821a1ant_init_hwconfig( + struct btc_coexist *btcoexist + ) +{ + halbtc8821a1ant_init_hw_config(btcoexist, true); +} + +void +ex_halbtc8821a1ant_init_coex_dm( + struct btc_coexist *btcoexist + ) +{ + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, "[BTCoex], Coex Mechanism Init!!\n"); + + btcoexist->stop_coex_dm = false; + + halbtc8821a1ant_init_coex_dm(btcoexist); + + halbtc8821a1ant_query_bt_info(btcoexist); +} + +void ex_halbtc8821a1ant_display_coex_info(struct btc_coexist *btcoexist) +{ + struct btc_board_info *board_info = &btcoexist->board_info; + struct btc_stack_info *stack_info = &btcoexist->stack_info; + struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; + u8 *cli_buf = btcoexist->cli_buf; + u8 u1_tmp[4], i, bt_info_ext, ps_tdma_case = 0; + u16 u2_tmp[4]; + u32 u4_tmp[4]; + bool roam = false, scan = false, link = false, wifi_under_5g = false; + bool bt_hs_on = false, wifi_busy = false; + long wifi_rssi = 0, bt_hs_rssi = 0; + u32 wifi_bw, wifi_traffic_dir; + u8 wifi_dot11_chnl, wifi_hs_chnl; + u32 fw_ver = 0, bt_patch_ver = 0; + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\n ============[BT Coexist info] ============"); + CL_PRINTF(cli_buf); + + if (btcoexist->manual_control) { + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\n ============[Under Manual Control] ============"); + CL_PRINTF(cli_buf); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\n =========================================="); + CL_PRINTF(cli_buf); + } + if (btcoexist->stop_coex_dm) { + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\n ============[Coex is STOPPED] ============"); + CL_PRINTF(cli_buf); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\n =========================================="); + CL_PRINTF(cli_buf); + } + + if (!board_info->bt_exist) { + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n BT not exists !!!"); + CL_PRINTF(cli_buf); + return; + } + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %d/ %d/ %d", + "Ant PG Num/ Ant Mech/ Ant Pos: ", + board_info->pg_ant_num, board_info->btdm_ant_num, + board_info->btdm_ant_pos); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %s / %d", + "BT stack/ hci ext ver", + ((stack_info->profile_notified) ? "Yes" : "No"), + stack_info->hci_version); + CL_PRINTF(cli_buf); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER, &bt_patch_ver); + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)", + "CoexVer/ FwVer/ PatchVer", + glcoex_ver_date_8821a_1ant, glcoex_ver_8821a_1ant, fw_ver, + bt_patch_ver, bt_patch_ver); + CL_PRINTF(cli_buf); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); + btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_DOT11_CHNL, + &wifi_dot11_chnl); + btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifi_hs_chnl); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %d / %d(%d)", + "Dot11 channel / HsChnl(HsMode)", + wifi_dot11_chnl, wifi_hs_chnl, bt_hs_on); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %02x %02x %02x ", + "H2C Wifi inform bt chnl Info", + coex_dm->wifi_chnl_info[0], coex_dm->wifi_chnl_info[1], + coex_dm->wifi_chnl_info[2]); + CL_PRINTF(cli_buf); + + btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi); + btcoexist->btc_get(btcoexist, BTC_GET_S4_HS_RSSI, &bt_hs_rssi); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %d/ %d", + "Wifi rssi/ HS rssi", + (int)wifi_rssi, (int)bt_hs_rssi); + CL_PRINTF(cli_buf); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %d/ %d/ %d ", + "Wifi link/ roam/ scan", + link, roam, scan); + CL_PRINTF(cli_buf); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g); + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, + &wifi_traffic_dir); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %s / %s/ %s ", + "Wifi status", + (wifi_under_5g ? "5G" : "2.4G"), + ((BTC_WIFI_BW_LEGACY == wifi_bw) ? "Legacy" : + (((BTC_WIFI_BW_HT40 == wifi_bw) ? "HT40" : "HT20"))), + ((!wifi_busy) ? "idle" : + ((BTC_WIFI_TRAFFIC_TX == wifi_traffic_dir) ? + "uplink" : "downlink"))); + CL_PRINTF(cli_buf); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", + ((btcoexist->bt_info.bt_disabled) ? ("disabled") : + ((coex_sta->c2h_bt_inquiry_page) ? ("inquiry/page scan") : + ((BT_8821A_1ANT_BT_STATUS_NON_CONNECTED_IDLE == + coex_dm->bt_status) ? "non-connected idle" : + ((BT_8821A_1ANT_BT_STATUS_CONNECTED_IDLE == + coex_dm->bt_status) ? "connected-idle" : "busy")))), + coex_sta->bt_rssi, coex_sta->bt_retry_cnt); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %d / %d / %d / %d", + "SCO/HID/PAN/A2DP", + bt_link_info->sco_exist, bt_link_info->hid_exist, + bt_link_info->pan_exist, bt_link_info->a2dp_exist); + CL_PRINTF(cli_buf); + btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_BT_LINK_INFO); + + bt_info_ext = coex_sta->bt_info_ext; + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %s", + "BT Info A2DP rate", + (bt_info_ext & BIT(0)) ? "Basic rate" : "EDR rate"); + CL_PRINTF(cli_buf); + + for (i = 0; i < BT_INFO_SRC_8821A_1ANT_MAX; i++) { + if (coex_sta->bt_info_c2h_cnt[i]) { + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", + glbt_info_src_8821a_1ant[i], + coex_sta->bt_info_c2h[i][0], + coex_sta->bt_info_c2h[i][1], + coex_sta->bt_info_c2h[i][2], + coex_sta->bt_info_c2h[i][3], + coex_sta->bt_info_c2h[i][4], + coex_sta->bt_info_c2h[i][5], + coex_sta->bt_info_c2h[i][6], + coex_sta->bt_info_c2h_cnt[i]); + CL_PRINTF(cli_buf); + } + } + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %s/%s, (0x%x/0x%x)", + "PS state, IPS/LPS, (lps/rpwm)", + ((coex_sta->under_ips ? "IPS ON" : "IPS OFF")), + ((coex_sta->under_lps ? "LPS ON" : "LPS OFF")), + btcoexist->bt_info.lps_val, + btcoexist->bt_info.rpwm_val); + CL_PRINTF(cli_buf); + btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_FW_PWR_MODE_CMD); + + if (!btcoexist->manual_control) { + /* Sw mechanism */ + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\n %-35s", "============[Sw mechanism] ============"); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\n %-35s = %d", "SM[LowPenaltyRA]", + coex_dm->cur_low_penalty_ra); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\n %-35s = %s/ %s/ %d ", "DelBA/ BtCtrlAgg/ AggSize", + (btcoexist->bt_info.reject_agg_pkt ? "Yes" : "No"), + (btcoexist->bt_info.b_bt_ctrl_buf_size ? + "Yes" : "No"), + btcoexist->bt_info.agg_buf_size); + CL_PRINTF(cli_buf); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\n %-35s = 0x%x ", "Rate Mask", + btcoexist->bt_info.ra_mask); + CL_PRINTF(cli_buf); + + /* Fw mechanism */ + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s", + "============[Fw mechanism] ============"); + CL_PRINTF(cli_buf); + + ps_tdma_case = coex_dm->cur_ps_tdma; + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d)", + "PS TDMA", + coex_dm->ps_tdma_para[0], coex_dm->ps_tdma_para[1], + coex_dm->ps_tdma_para[2], coex_dm->ps_tdma_para[3], + coex_dm->ps_tdma_para[4], ps_tdma_case, + coex_dm->auto_tdma_adjust); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = 0x%x ", + "Latest error condition(should be 0)", + coex_dm->error_condition); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %d ", + "IgnWlanAct", + coex_dm->cur_ignore_wlan_act); + CL_PRINTF(cli_buf); + } + + /* Hw setting */ + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s", + "============[Hw setting] ============"); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = 0x%x/0x%x/0x%x/0x%x", + "backup ARFR1/ARFR2/RL/AMaxTime", + coex_dm->backup_arfr_cnt1, coex_dm->backup_arfr_cnt2, + coex_dm->backup_retry_limit, coex_dm->backup_ampdu_max_time); + CL_PRINTF(cli_buf); + + u4_tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x430); + u4_tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x434); + u2_tmp[0] = btcoexist->btc_read_2byte(btcoexist, 0x42a); + u1_tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x456); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = 0x%x/0x%x/0x%x/0x%x", + "0x430/0x434/0x42a/0x456", + u4_tmp[0], u4_tmp[1], u2_tmp[0], u1_tmp[0]); + CL_PRINTF(cli_buf); + + u1_tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x778); + u4_tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xc58); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\n %-35s = 0x%x/ 0x%x", "0x778/ 0xc58[29:25]", + u1_tmp[0], (u4_tmp[0]&0x3e000000) >> 25); + CL_PRINTF(cli_buf); + + u1_tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x8db); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = 0x%x", "0x8db[6:5]", + ((u1_tmp[0]&0x60)>>5)); + CL_PRINTF(cli_buf); + + u1_tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x975); + u4_tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xcb4); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = 0x%x/ 0x%x/ 0x%x", + "0xcb4[29:28]/0xcb4[7:0]/0x974[9:8]", + (u4_tmp[0]&0x30000000)>>28, u4_tmp[0]&0xff, u1_tmp[0] & 0x3); + CL_PRINTF(cli_buf); + + u1_tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x40); + u4_tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x4c); + u1_tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0x64); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = 0x%x/ 0x%x/ 0x%x", + "0x40/0x4c[24:23]/0x64[0]", + u1_tmp[0], ((u4_tmp[0]&0x01800000)>>23), u1_tmp[1]&0x1); + CL_PRINTF(cli_buf); + + u4_tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x550); + u1_tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x522); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = 0x%x/ 0x%x", + "0x550(bcn ctrl)/0x522", + u4_tmp[0], u1_tmp[0]); + CL_PRINTF(cli_buf); + + u4_tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xc50); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = 0x%x", "0xc50(dig)", + u4_tmp[0]&0xff); + CL_PRINTF(cli_buf); + + u4_tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xf48); + u1_tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0xa5d); + u1_tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0xa5c); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = 0x%x/ 0x%x", + "OFDM-FA/ CCK-FA", + u4_tmp[0], (u1_tmp[0]<<8) + u1_tmp[1]); + CL_PRINTF(cli_buf); + + u4_tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x6c0); + u4_tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x6c4); + u4_tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0x6c8); + u1_tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x6cc); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", + "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", + u4_tmp[0], u4_tmp[1], u4_tmp[2], u1_tmp[0]); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %d/ %d", + "0x770(high-pri rx/tx)", + coex_sta->high_priority_rx, coex_sta->high_priority_tx); + CL_PRINTF(cli_buf); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %d/ %d", + "0x774(low-pri rx/tx)", + coex_sta->low_priority_rx, coex_sta->low_priority_tx); + CL_PRINTF(cli_buf); +#if (BT_AUTO_REPORT_ONLY_8821A_1ANT == 1) + halbtc8821a1ant_monitor_bt_ctr(btcoexist); +#endif + btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_COEX_STATISTICS); +} + +void ex_halbtc8821a1ant_ips_notify(struct btc_coexist *btcoexist, u8 type) +{ + if (btcoexist->manual_control || btcoexist->stop_coex_dm) + return; + + if (BTC_IPS_ENTER == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], IPS ENTER notify\n"); + coex_sta->under_ips = true; + halbtc8821a1ant_set_ant_path(btcoexist, BTC_ANT_PATH_BT, + false, true); + /* set PTA control */ + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8); + halbtc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0); + } else if (BTC_IPS_LEAVE == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], IPS LEAVE notify\n"); + coex_sta->under_ips = false; + + halbtc8821a1ant_run_coexist_mechanism(btcoexist); + } +} + +void ex_halbtc8821a1ant_lps_notify(struct btc_coexist *btcoexist, u8 type) +{ + if (btcoexist->manual_control || btcoexist->stop_coex_dm) + return; + + if (BTC_LPS_ENABLE == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], LPS ENABLE notify\n"); + coex_sta->under_lps = true; + } else if (BTC_LPS_DISABLE == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], LPS DISABLE notify\n"); + coex_sta->under_lps = false; + } +} + +void ex_halbtc8821a1ant_scan_notify(struct btc_coexist *btcoexist, u8 type) +{ + bool wifi_connected = false, bt_hs_on = false; + + if (btcoexist->manual_control || + btcoexist->stop_coex_dm || + btcoexist->bt_info.bt_disabled) + return; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, + &wifi_connected); + + halbtc8821a1ant_query_bt_info(btcoexist); + + if (coex_sta->c2h_bt_inquiry_page) { + halbtc8821a1ant_action_bt_inquiry(btcoexist); + return; + } else if (bt_hs_on) { + halbtc8821a1ant_action_hs(btcoexist); + return; + } + + if (BTC_SCAN_START == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], SCAN START notify\n"); + if (!wifi_connected) { + /* non-connected scan */ + wifi_not_connected_asso_auth_scan(btcoexist); + } else { + /* wifi is connected */ + halbtc8821a1ant_action_wifi_connected_scan(btcoexist); + } + } else if (BTC_SCAN_FINISH == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], SCAN FINISH notify\n"); + if (!wifi_connected) /* non-connected scan */ + halbtc8821a1ant_action_wifi_not_connected(btcoexist); + else + halbtc8821a1ant_action_wifi_connected(btcoexist); + } +} + +void ex_halbtc8821a1ant_connect_notify(struct btc_coexist *btcoexist, u8 type) +{ + bool wifi_connected = false, bt_hs_on = false; + + if (btcoexist->manual_control || + btcoexist->stop_coex_dm || + btcoexist->bt_info.bt_disabled) + return; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); + if (coex_sta->c2h_bt_inquiry_page) { + halbtc8821a1ant_action_bt_inquiry(btcoexist); + return; + } else if (bt_hs_on) { + halbtc8821a1ant_action_hs(btcoexist); + return; + } + + if (BTC_ASSOCIATE_START == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], CONNECT START notify\n"); + wifi_not_connected_asso_auth_scan(btcoexist); + } else if (BTC_ASSOCIATE_FINISH == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], CONNECT FINISH notify\n"); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, + &wifi_connected); + if (!wifi_connected) /* non-connected scan */ + halbtc8821a1ant_action_wifi_not_connected(btcoexist); + else + halbtc8821a1ant_action_wifi_connected(btcoexist); + } +} + +void ex_halbtc8821a1ant_media_status_notify(struct btc_coexist *btcoexist, + u8 type) +{ + u8 h2c_parameter[3] = {0}; + u32 wifi_bw; + u8 wifi_central_chnl; + + if (btcoexist->manual_control || + btcoexist->stop_coex_dm || + btcoexist->bt_info.bt_disabled) + return; + + if (BTC_MEDIA_CONNECT == type) + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], MEDIA connect notify\n"); + else + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], MEDIA disconnect notify\n"); + + /* only 2.4G we need to inform bt the chnl mask */ + btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, + &wifi_central_chnl); + if ((BTC_MEDIA_CONNECT == type) && + (wifi_central_chnl <= 14)) { + /* h2c_parameter[0] = 0x1; */ + h2c_parameter[0] = 0x0; + h2c_parameter[1] = wifi_central_chnl; + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + if (BTC_WIFI_BW_HT40 == wifi_bw) + h2c_parameter[2] = 0x30; + else + h2c_parameter[2] = 0x20; + } + + coex_dm->wifi_chnl_info[0] = h2c_parameter[0]; + coex_dm->wifi_chnl_info[1] = h2c_parameter[1]; + coex_dm->wifi_chnl_info[2] = h2c_parameter[2]; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], FW write 0x66 = 0x%x\n", + h2c_parameter[0]<<16|h2c_parameter[1]<<8|h2c_parameter[2]); + + btcoexist->btc_fill_h2c(btcoexist, 0x66, 3, h2c_parameter); +} + +void ex_halbtc8821a1ant_special_packet_notify(struct btc_coexist *btcoexist, + u8 type) +{ + bool bt_hs_on = false; + + if (btcoexist->manual_control || + btcoexist->stop_coex_dm || + btcoexist->bt_info.bt_disabled) + return; + + coex_sta->special_pkt_period_cnt = 0; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); + if (coex_sta->c2h_bt_inquiry_page) { + halbtc8821a1ant_action_bt_inquiry(btcoexist); + return; + } else if (bt_hs_on) { + halbtc8821a1ant_action_hs(btcoexist); + return; + } + + if (BTC_PACKET_DHCP == type || + BTC_PACKET_EAPOL == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], special Packet(%d) notify\n", type); + action_wifi_connected_special_packet(btcoexist); + } +} + +void ex_halbtc8821a1ant_bt_info_notify(struct btc_coexist *btcoexist, + u8 *tmp_buf, u8 length) +{ + u8 bt_info = 0; + u8 i, rsp_source = 0; + bool wifi_connected = false; + bool bt_busy = false; + bool wifi_under_5g = false; + + coex_sta->c2h_bt_info_req_sent = false; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g); + + rsp_source = tmp_buf[0]&0xf; + if (rsp_source >= BT_INFO_SRC_8821A_1ANT_MAX) + rsp_source = BT_INFO_SRC_8821A_1ANT_WIFI_FW; + coex_sta->bt_info_c2h_cnt[rsp_source]++; + + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], Bt info[%d], length =%d, hex data =[", + rsp_source, length); + for (i = 0; i < length; i++) { + coex_sta->bt_info_c2h[rsp_source][i] = tmp_buf[i]; + if (i == 1) + bt_info = tmp_buf[i]; + if (i == length-1) + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "0x%02x]\n", tmp_buf[i]); + else + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "0x%02x, ", tmp_buf[i]); + } + + if (BT_INFO_SRC_8821A_1ANT_WIFI_FW != rsp_source) { + coex_sta->bt_retry_cnt = /* [3:0] */ + coex_sta->bt_info_c2h[rsp_source][2]&0xf; + + coex_sta->bt_rssi = + coex_sta->bt_info_c2h[rsp_source][3]*2+10; + + coex_sta->bt_info_ext = + coex_sta->bt_info_c2h[rsp_source][4]; + + /* Here we need to resend some wifi info to BT */ + /* because bt is reset and loss of the info. */ + if (coex_sta->bt_info_ext & BIT(1)) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n"); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, + &wifi_connected); + if (wifi_connected) + ex_halbtc8821a1ant_media_status_notify(btcoexist, + BTC_MEDIA_CONNECT); + else + ex_halbtc8821a1ant_media_status_notify(btcoexist, + BTC_MEDIA_DISCONNECT); + } + + if ((coex_sta->bt_info_ext & BIT(3)) && !wifi_under_5g) { + if (!btcoexist->manual_control && + !btcoexist->stop_coex_dm) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n"); + halbtc8821a1ant_ignore_wlan_act(btcoexist, + FORCE_EXEC, false); + } + } else { + /* BT already NOT ignore Wlan active, do nothing here. */ + } +#if (BT_AUTO_REPORT_ONLY_8821A_1ANT == 0) + if ((coex_sta->bt_info_ext & BIT(4))) { + /* BT auto report already enabled, do nothing */ + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT ext info bit4 check, set BT to enable Auto Report!!\n"); + halbtc8821a1ant_bt_auto_report(btcoexist, + FORCE_EXEC, true); + } +#endif + } + + /* check BIT(2) first ==> check if bt is under inquiry or page scan */ + if (bt_info & BT_INFO_8821A_1ANT_B_INQ_PAGE) + coex_sta->c2h_bt_inquiry_page = true; + else + coex_sta->c2h_bt_inquiry_page = false; + + /* set link exist status */ + if (!(bt_info&BT_INFO_8821A_1ANT_B_CONNECTION)) { + coex_sta->bt_link_exist = false; + coex_sta->pan_exist = false; + coex_sta->a2dp_exist = false; + coex_sta->hid_exist = false; + coex_sta->sco_exist = false; + } else { + /* connection exists */ + coex_sta->bt_link_exist = true; + if (bt_info & BT_INFO_8821A_1ANT_B_FTP) + coex_sta->pan_exist = true; + else + coex_sta->pan_exist = false; + if (bt_info & BT_INFO_8821A_1ANT_B_A2DP) + coex_sta->a2dp_exist = true; + else + coex_sta->a2dp_exist = false; + if (bt_info & BT_INFO_8821A_1ANT_B_HID) + coex_sta->hid_exist = true; + else + coex_sta->hid_exist = false; + if (bt_info & BT_INFO_8821A_1ANT_B_SCO_ESCO) + coex_sta->sco_exist = true; + else + coex_sta->sco_exist = false; + } + + halbtc8821a1ant_update_bt_link_info(btcoexist); + + if (!(bt_info&BT_INFO_8821A_1ANT_B_CONNECTION)) { + coex_dm->bt_status = BT_8821A_1ANT_BT_STATUS_NON_CONNECTED_IDLE; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n"); + } else if (bt_info == BT_INFO_8821A_1ANT_B_CONNECTION) { + /* connection exists but not busy */ + coex_dm->bt_status = BT_8821A_1ANT_BT_STATUS_CONNECTED_IDLE; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n"); + } else if ((bt_info&BT_INFO_8821A_1ANT_B_SCO_ESCO) || + (bt_info&BT_INFO_8821A_1ANT_B_SCO_BUSY)) { + coex_dm->bt_status = BT_8821A_1ANT_BT_STATUS_SCO_BUSY; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BtInfoNotify(), BT SCO busy!!!\n"); + } else if (bt_info&BT_INFO_8821A_1ANT_B_ACL_BUSY) { + if (BT_8821A_1ANT_BT_STATUS_ACL_BUSY != coex_dm->bt_status) + coex_dm->auto_tdma_adjust = false; + coex_dm->bt_status = BT_8821A_1ANT_BT_STATUS_ACL_BUSY; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BtInfoNotify(), BT ACL busy!!!\n"); + } else { + coex_dm->bt_status = BT_8821A_1ANT_BT_STATUS_MAX; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n"); + } + + if ((BT_8821A_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) || + (BT_8821A_1ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) || + (BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY == coex_dm->bt_status)) + bt_busy = true; + else + bt_busy = false; + btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bt_busy); + + halbtc8821a1ant_run_coexist_mechanism(btcoexist); +} + +void ex_halbtc8821a1ant_halt_notify(struct btc_coexist *btcoexist) +{ + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, "[BTCoex], Halt notify\n"); + + btcoexist->stop_coex_dm = true; + + halbtc8821a1ant_set_ant_path(btcoexist, BTC_ANT_PATH_BT, false, true); + halbtc8821a1ant_ignore_wlan_act(btcoexist, FORCE_EXEC, true); + + halbtc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, + 0x0, 0x0); + halbtc8821a1ant_ps_tdma(btcoexist, FORCE_EXEC, false, 0); + + ex_halbtc8821a1ant_media_status_notify(btcoexist, BTC_MEDIA_DISCONNECT); +} + +void ex_halbtc8821a1ant_pnp_notify(struct btc_coexist *btcoexist, u8 pnp_state) +{ + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, "[BTCoex], Pnp notify\n"); + + if (BTC_WIFI_PNP_SLEEP == pnp_state) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], Pnp notify to SLEEP\n"); + btcoexist->stop_coex_dm = true; + halbtc8821a1ant_ignore_wlan_act(btcoexist, FORCE_EXEC, true); + halbtc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, + 0x0, 0x0); + halbtc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 9); + } else if (BTC_WIFI_PNP_WAKE_UP == pnp_state) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], Pnp notify to WAKE UP\n"); + btcoexist->stop_coex_dm = false; + halbtc8821a1ant_init_hw_config(btcoexist, false); + halbtc8821a1ant_init_coex_dm(btcoexist); + halbtc8821a1ant_query_bt_info(btcoexist); + } +} + +void ex_halbtc8821a1ant_periodical(struct btc_coexist *btcoexist) +{ + static u8 dis_ver_info_cnt; + u32 fw_ver = 0, bt_patch_ver = 0; + struct btc_board_info *board_info = &btcoexist->board_info; + struct btc_stack_info *stack_info = &btcoexist->stack_info; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], ========================== Periodical ===========================\n"); + + if (dis_ver_info_cnt <= 5) { + dis_ver_info_cnt += 1; + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], ****************************************************************\n"); + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n", + board_info->pg_ant_num, board_info->btdm_ant_num, + board_info->btdm_ant_pos); + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], BT stack/ hci ext ver = %s / %d\n", + ((stack_info->profile_notified) ? "Yes" : "No"), + stack_info->hci_version); + btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER, + &bt_patch_ver); + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver); + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n", + glcoex_ver_date_8821a_1ant, glcoex_ver_8821a_1ant, + fw_ver, bt_patch_ver, bt_patch_ver); + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], ****************************************************************\n"); + } + +#if (BT_AUTO_REPORT_ONLY_8821A_1ANT == 0) + halbtc8821a1ant_query_bt_info(btcoexist); + halbtc8821a1ant_monitor_bt_ctr(btcoexist); + halbtc8821a1ant_monitor_bt_enable_disable(btcoexist); +#else + if (halbtc8821a1ant_Is_wifi_status_changed(btcoexist) || + coex_dm->auto_tdma_adjust) { + if (coex_sta->special_pkt_period_cnt > 2) + halbtc8821a1ant_run_coexist_mechanism(btcoexist); + } + + coex_sta->special_pkt_period_cnt++; +#endif +} diff --git a/drivers/staging/rtl8192ee/btcoexist/halbtc8821a1ant.h b/drivers/staging/rtl8192ee/btcoexist/halbtc8821a1ant.h new file mode 100644 index 000000000000..9b991d021a88 --- /dev/null +++ b/drivers/staging/rtl8192ee/btcoexist/halbtc8821a1ant.h @@ -0,0 +1,158 @@ +/* */ +/* The following is for 8821A 1ANT BT Co-exist definition */ +/* */ +#define BT_AUTO_REPORT_ONLY_8821A_1ANT 0 + +#define BT_INFO_8821A_1ANT_B_FTP BIT(7) +#define BT_INFO_8821A_1ANT_B_A2DP BIT(6) +#define BT_INFO_8821A_1ANT_B_HID BIT(5) +#define BT_INFO_8821A_1ANT_B_SCO_BUSY BIT(4) +#define BT_INFO_8821A_1ANT_B_ACL_BUSY BIT(3) +#define BT_INFO_8821A_1ANT_B_INQ_PAGE BIT(2) +#define BT_INFO_8821A_1ANT_B_SCO_ESCO BIT(1) +#define BT_INFO_8821A_1ANT_B_CONNECTION BIT(0) + +#define BT_INFO_8821A_1ANT_A2DP_BASIC_RATE(_BT_INFO_EXT_) \ + (((_BT_INFO_EXT_&BIT(0))) ? true : false) + +#define BTC_RSSI_COEX_THRESH_TOL_8821A_1ANT 2 + +enum BT_INFO_SRC_8821A_1ANT { + BT_INFO_SRC_8821A_1ANT_WIFI_FW = 0x0, + BT_INFO_SRC_8821A_1ANT_BT_RSP = 0x1, + BT_INFO_SRC_8821A_1ANT_BT_ACTIVE_SEND = 0x2, + BT_INFO_SRC_8821A_1ANT_MAX +}; + +enum BT_8821A_1ANT_BT_STATUS { + BT_8821A_1ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0, + BT_8821A_1ANT_BT_STATUS_CONNECTED_IDLE = 0x1, + BT_8821A_1ANT_BT_STATUS_INQ_PAGE = 0x2, + BT_8821A_1ANT_BT_STATUS_ACL_BUSY = 0x3, + BT_8821A_1ANT_BT_STATUS_SCO_BUSY = 0x4, + BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY = 0x5, + BT_8821A_1ANT_BT_STATUS_MAX +}; + +enum BT_8821A_1ANT_WIFI_STATUS { + BT_8821A_1ANT_WIFI_STATUS_NON_CONNECTED_IDLE = 0x0, + BT_8821A_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN = 0x1, + BT_8821A_1ANT_WIFI_STATUS_CONNECTED_SCAN = 0x2, + BT_8821A_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT = 0x3, + BT_8821A_1ANT_WIFI_STATUS_CONNECTED_IDLE = 0x4, + BT_8821A_1ANT_WIFI_STATUS_CONNECTED_BUSY = 0x5, + BT_8821A_1ANT_WIFI_STATUS_MAX +}; + +enum BT_8821A_1ANT_COEX_ALGO { + BT_8821A_1ANT_COEX_ALGO_UNDEFINED = 0x0, + BT_8821A_1ANT_COEX_ALGO_SCO = 0x1, + BT_8821A_1ANT_COEX_ALGO_HID = 0x2, + BT_8821A_1ANT_COEX_ALGO_A2DP = 0x3, + BT_8821A_1ANT_COEX_ALGO_A2DP_PANHS = 0x4, + BT_8821A_1ANT_COEX_ALGO_PANEDR = 0x5, + BT_8821A_1ANT_COEX_ALGO_PANHS = 0x6, + BT_8821A_1ANT_COEX_ALGO_PANEDR_A2DP = 0x7, + BT_8821A_1ANT_COEX_ALGO_PANEDR_HID = 0x8, + BT_8821A_1ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9, + BT_8821A_1ANT_COEX_ALGO_HID_A2DP = 0xa, + BT_8821A_1ANT_COEX_ALGO_MAX = 0xb, +}; + +struct coex_dm_8821a_1ant { + /* fw mechanism */ + bool cur_ignore_wlan_act; + bool pre_ignore_wlan_act; + u8 pre_ps_tdma; + u8 cur_ps_tdma; + u8 ps_tdma_para[5]; + u8 ps_tdma_du_adj_type; + bool auto_tdma_adjust; + bool pre_ps_tdma_on; + bool cur_ps_tdma_on; + bool pre_bt_auto_report; + bool cur_bt_auto_report; + u8 pre_lps; + u8 cur_lps; + u8 pre_rpwm; + u8 cur_rpwm; + + /* sw mechanism */ + bool pre_low_penalty_ra; + bool cur_low_penalty_ra; + u32 pre_val_0x6c0; + u32 cur_val_0x6c0; + u32 pre_val_0x6c4; + u32 cur_val_0x6c4; + u32 pre_val_0x6c8; + u32 cur_val_0x6c8; + u8 pre_val_0x6cc; + u8 cur_val_0x6cc; + + u32 backup_arfr_cnt1; /* Auto Rate Fallback Retry cnt */ + u32 backup_arfr_cnt2; /* Auto Rate Fallback Retry cnt */ + u16 backup_retry_limit; + u8 backup_ampdu_max_time; + + /* algorithm related */ + u8 pre_algorithm; + u8 cur_algorithm; + u8 bt_status; + u8 wifi_chnl_info[3]; + + u32 pre_ra_mask; + u32 cur_ra_mask; + u8 pre_arfr_type; + u8 cur_arfr_type; + u8 pre_retry_limit_type; + u8 cur_retry_limit_type; + u8 pre_ampdu_time_type; + u8 cur_ampdu_time_type; + + u8 error_condition; +}; + +struct coex_sta_8821a_1ant { + bool bt_link_exist; + bool sco_exist; + bool a2dp_exist; + bool hid_exist; + bool pan_exist; + + bool under_lps; + bool under_ips; + u32 special_pkt_period_cnt; + u32 high_priority_tx; + u32 high_priority_rx; + u32 low_priority_tx; + u32 low_priority_rx; + u8 bt_rssi; + u8 pre_bt_rssi_state; + u8 pre_wifi_rssi_state[4]; + bool c2h_bt_info_req_sent; + u8 bt_info_c2h[BT_INFO_SRC_8821A_1ANT_MAX][10]; + u32 bt_info_c2h_cnt[BT_INFO_SRC_8821A_1ANT_MAX]; + bool c2h_bt_inquiry_page; + u8 bt_retry_cnt; + u8 bt_info_ext; +}; + +/* The following is interface which will notify coex module. */ +void ex_halbtc8821a1ant_init_hwconfig(struct btc_coexist *btcoexist); +void ex_halbtc8821a1ant_init_coex_dm(struct btc_coexist *btcoexist); +void ex_halbtc8821a1ant_ips_notify(struct btc_coexist *btcoexist, u8 type); +void ex_halbtc8821a1ant_lps_notify(struct btc_coexist *btcoexist, u8 type); +void ex_halbtc8821a1ant_scan_notify(struct btc_coexist *btcoexist, u8 type); +void ex_halbtc8821a1ant_connect_notify(struct btc_coexist *btcoexist, u8 type); +void ex_halbtc8821a1ant_media_status_notify(struct btc_coexist *btcoexist, + u8 type); +void ex_halbtc8821a1ant_special_packet_notify(struct btc_coexist *btcoexist, + u8 type); +void ex_halbtc8821a1ant_bt_info_notify(struct btc_coexist *btcoexist, + u8 *tmpbuf, u8 length); +void ex_halbtc8821a1ant_halt_notify(struct btc_coexist *btcoexist); +void ex_halbtc8821a1ant_pnp_notify(struct btc_coexist *btcoexist, u8 pnpstate); +void ex_halbtc8821a1ant_periodical(struct btc_coexist *btcoexist); +void ex_halbtc8821a1ant_display_coex_info(struct btc_coexist *btcoexist); +void ex_halbtc8821a1ant_dbg_control(struct btc_coexist *btcoexist, u8 op_code, + u8 op_len, u8 *data); diff --git a/drivers/staging/rtl8192ee/btcoexist/halbtc8821a2ant.c b/drivers/staging/rtl8192ee/btcoexist/halbtc8821a2ant.c new file mode 100644 index 000000000000..7fb590739014 --- /dev/null +++ b/drivers/staging/rtl8192ee/btcoexist/halbtc8821a2ant.c @@ -0,0 +1,3438 @@ +/* Description: */ +/* This file is for RTL8821A Co-exist mechanism */ +/* History */ +/* 2012/08/22 Cosa first check in. */ +/* 2012/11/14 Cosa Revise for 8821A 2Ant out sourcing. */ + +/* include files */ +#include "halbt_precomp.h" +/* Global variables, these are static variables */ +static struct coex_dm_8821a_2ant glcoex_dm_8821a_2ant; +static struct coex_dm_8821a_2ant *coex_dm = &glcoex_dm_8821a_2ant; +static struct coex_sta_8821a_2ant glcoex_sta_8821a_2ant; +static struct coex_sta_8821a_2ant *coex_sta = &glcoex_sta_8821a_2ant; + +static const char *const glbt_info_src_8821a_2ant[] = { + "BT Info[wifi fw]", + "BT Info[bt rsp]", + "BT Info[bt auto report]", +}; + +static u32 glcoex_ver_date_8821a_2ant = 20130618; +static u32 glcoex_ver_8821a_2ant = 0x5050; + +/* local function proto type if needed */ +/* local function start with halbtc8821a2ant_ */ +static u8 halbtc8821a2ant_bt_rssi_state(u8 level_num, u8 rssi_thresh, + u8 rssi_thresh1) +{ + long bt_rssi = 0; + u8 bt_rssi_state = coex_sta->pre_bt_rssi_state; + + bt_rssi = coex_sta->bt_rssi; + + if (level_num == 2) { + if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) || + (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW)) { + if (bt_rssi >= (rssi_thresh + + BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT)) { + bt_rssi_state = BTC_RSSI_STATE_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state switch to High\n"); + } else { + bt_rssi_state = BTC_RSSI_STATE_STAY_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state stay at Low\n"); + } + } else { + if (bt_rssi < rssi_thresh) { + bt_rssi_state = BTC_RSSI_STATE_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state switch to Low\n"); + } else { + bt_rssi_state = BTC_RSSI_STATE_STAY_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state stay at High\n"); + } + } + } else if (level_num == 3) { + if (rssi_thresh > rssi_thresh1) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi thresh error!!\n"); + return coex_sta->pre_bt_rssi_state; + } + + if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) || + (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW)) { + if (bt_rssi >= (rssi_thresh + + BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT)) { + bt_rssi_state = BTC_RSSI_STATE_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state switch to Medium\n"); + } else { + bt_rssi_state = BTC_RSSI_STATE_STAY_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state stay at Low\n"); + } + } else if ((coex_sta->pre_bt_rssi_state == + BTC_RSSI_STATE_MEDIUM) || + (coex_sta->pre_bt_rssi_state == + BTC_RSSI_STATE_STAY_MEDIUM)) { + if (bt_rssi >= (rssi_thresh1 + + BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT)) { + bt_rssi_state = BTC_RSSI_STATE_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state switch to High\n"); + } else if (bt_rssi < rssi_thresh) { + bt_rssi_state = BTC_RSSI_STATE_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state switch to Low\n"); + } else { + bt_rssi_state = BTC_RSSI_STATE_STAY_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state stay at Medium\n"); + } + } else { + if (bt_rssi < rssi_thresh1) { + bt_rssi_state = BTC_RSSI_STATE_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state switch to Medium\n"); + } else { + bt_rssi_state = BTC_RSSI_STATE_STAY_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_BT_RSSI_STATE, + "[BTCoex], BT Rssi state stay at High\n"); + } + } + } + + coex_sta->pre_bt_rssi_state = bt_rssi_state; + + return bt_rssi_state; +} + +static u8 wifi21a_rssi_state(struct btc_coexist *btcoexist, + u8 index, u8 level_num, + u8 rssi_thresh, u8 rssi_thresh1) +{ + long wifi_rssi = 0; + u8 wifi_rssi_state = coex_sta->pre_wifi_rssi_state[index]; + + btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi); + + if (level_num == 2) { + if ((coex_sta->pre_wifi_rssi_state[index] == + BTC_RSSI_STATE_LOW) || + (coex_sta->pre_wifi_rssi_state[index] == + BTC_RSSI_STATE_STAY_LOW)) { + if (wifi_rssi >= (rssi_thresh + + BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT)) { + wifi_rssi_state = BTC_RSSI_STATE_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state switch to High\n"); + } else { + wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state stay at Low\n"); + } + } else { + if (wifi_rssi < rssi_thresh) { + wifi_rssi_state = BTC_RSSI_STATE_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state switch to Low\n"); + } else { + wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state stay at High\n"); + } + } + } else if (level_num == 3) { + if (rssi_thresh > rssi_thresh1) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI thresh error!!\n"); + return coex_sta->pre_wifi_rssi_state[index]; + } + + if ((coex_sta->pre_wifi_rssi_state[index] == + BTC_RSSI_STATE_LOW) || + (coex_sta->pre_wifi_rssi_state[index] == + BTC_RSSI_STATE_STAY_LOW)) { + if (wifi_rssi >= (rssi_thresh + + BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT)) { + wifi_rssi_state = BTC_RSSI_STATE_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state switch to Medium\n"); + } else { + wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state stay at Low\n"); + } + } else if ((coex_sta->pre_wifi_rssi_state[index] == + BTC_RSSI_STATE_MEDIUM) || + (coex_sta->pre_wifi_rssi_state[index] == + BTC_RSSI_STATE_STAY_MEDIUM)) { + if (wifi_rssi >= (rssi_thresh1+BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT)) { + wifi_rssi_state = BTC_RSSI_STATE_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state switch to High\n"); + } else if (wifi_rssi < rssi_thresh) { + wifi_rssi_state = BTC_RSSI_STATE_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state switch to Low\n"); + } else { + wifi_rssi_state = BTC_RSSI_STATE_STAY_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state stay at Medium\n"); + } + } else { + if (wifi_rssi < rssi_thresh1) { + wifi_rssi_state = BTC_RSSI_STATE_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state switch to Medium\n"); + } else { + wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, + "[BTCoex], wifi RSSI state stay at High\n"); + } + } + } + + coex_sta->pre_wifi_rssi_state[index] = wifi_rssi_state; + + return wifi_rssi_state; +} + +static void monitor_bt_enable_disable(struct btc_coexist *btcoexist) +{ + static bool pre_bt_disabled; + static u32 bt_disable_cnt; + bool bt_active = true, bt_disabled = false; + + /* This function check if bt is disabled */ + + if (coex_sta->high_priority_tx == 0 && + coex_sta->high_priority_rx == 0 && + coex_sta->low_priority_tx == 0 && + coex_sta->low_priority_rx == 0) + bt_active = false; + if (coex_sta->high_priority_tx == 0xffff && + coex_sta->high_priority_rx == 0xffff && + coex_sta->low_priority_tx == 0xffff && + coex_sta->low_priority_rx == 0xffff) + bt_active = false; + if (bt_active) { + bt_disable_cnt = 0; + bt_disabled = false; + btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_DISABLE, + &bt_disabled); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, + "[BTCoex], BT is enabled !!\n"); + } else { + bt_disable_cnt++; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, + "[BTCoex], bt all counters = 0, %d times!!\n", + bt_disable_cnt); + if (bt_disable_cnt >= 2) { + bt_disabled = true; + btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_DISABLE, + &bt_disabled); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, + "[BTCoex], BT is disabled !!\n"); + } + } + if (pre_bt_disabled != bt_disabled) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, + "[BTCoex], BT is from %s to %s!!\n", + (pre_bt_disabled ? "disabled" : "enabled"), + (bt_disabled ? "disabled" : "enabled")); + pre_bt_disabled = bt_disabled; + } +} + +static void halbtc8821a2ant_monitor_bt_ctr(struct btc_coexist *btcoexist) +{ + u32 reg_hp_txrx, reg_lp_txrx, u4tmp; + u32 reg_hp_tx = 0, reg_hp_rx = 0, reg_lp_tx = 0, reg_lp_rx = 0; + + reg_hp_txrx = 0x770; + reg_lp_txrx = 0x774; + + u4tmp = btcoexist->btc_read_4byte(btcoexist, reg_hp_txrx); + reg_hp_tx = u4tmp & MASKLWORD; + reg_hp_rx = (u4tmp & MASKHWORD)>>16; + + u4tmp = btcoexist->btc_read_4byte(btcoexist, reg_lp_txrx); + reg_lp_tx = u4tmp & MASKLWORD; + reg_lp_rx = (u4tmp & MASKHWORD)>>16; + + coex_sta->high_priority_tx = reg_hp_tx; + coex_sta->high_priority_rx = reg_hp_rx; + coex_sta->low_priority_tx = reg_lp_tx; + coex_sta->low_priority_rx = reg_lp_rx; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, + "[BTCoex], High Priority Tx/Rx (reg 0x%x) = 0x%x(%d)/0x%x(%d)\n", + reg_hp_txrx, reg_hp_tx, reg_hp_tx, reg_hp_rx, reg_hp_rx); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, + "[BTCoex], Low Priority Tx/Rx (reg 0x%x) = 0x%x(%d)/0x%x(%d)\n", + reg_lp_txrx, reg_lp_tx, reg_lp_tx, reg_lp_rx, reg_lp_rx); + + /* reset counter */ + btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc); +} + +static void halbtc8821a2ant_query_bt_info(struct btc_coexist *btcoexist) +{ + u8 h2c_parameter[1] = {0}; + + coex_sta->c2h_bt_info_req_sent = true; + + h2c_parameter[0] |= BIT(0); /* trigger */ + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], Query Bt Info, FW write 0x61 = 0x%x\n", + h2c_parameter[0]); + + btcoexist->btc_fill_h2c(btcoexist, 0x61, 1, h2c_parameter); +} + +static u8 halbtc8821a2ant_action_algorithm(struct btc_coexist *btcoexist) +{ + struct btc_stack_info *stack_info = &btcoexist->stack_info; + bool bt_hs_on = false; + u8 algorithm = BT_8821A_2ANT_COEX_ALGO_UNDEFINED; + u8 num_of_diff_profile = 0; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); + + /* for win-8 stack HID report error */ + if (!stack_info->hid_exist) { + /* sync BTInfo with BT firmware and stack */ + stack_info->hid_exist = coex_sta->hid_exist; + } + /* when stack HID report error, here we use the info from bt fw. */ + if (!stack_info->bt_link_exist) + stack_info->bt_link_exist = coex_sta->bt_link_exist; + + if (!coex_sta->bt_link_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], No profile exists!!!\n"); + return algorithm; + } + + if (coex_sta->sco_exist) + num_of_diff_profile++; + if (coex_sta->hid_exist) + num_of_diff_profile++; + if (coex_sta->pan_exist) + num_of_diff_profile++; + if (coex_sta->a2dp_exist) + num_of_diff_profile++; + + if (num_of_diff_profile == 1) { + if (coex_sta->sco_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], SCO only\n"); + algorithm = BT_8821A_2ANT_COEX_ALGO_SCO; + } else { + if (coex_sta->hid_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], HID only\n"); + algorithm = BT_8821A_2ANT_COEX_ALGO_HID; + } else if (coex_sta->a2dp_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], A2DP only\n"); + algorithm = BT_8821A_2ANT_COEX_ALGO_A2DP; + } else if (coex_sta->pan_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], PAN(HS) only\n"); + algorithm = BT_8821A_2ANT_COEX_ALGO_PANHS; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], PAN(EDR) only\n"); + algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR; + } + } + } + } else if (num_of_diff_profile == 2) { + if (coex_sta->sco_exist) { + if (coex_sta->hid_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], SCO + HID\n"); + algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID; + } else if (coex_sta->a2dp_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], SCO + A2DP ==> SCO\n"); + algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID; + } else if (coex_sta->pan_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], SCO + PAN(HS)\n"); + algorithm = BT_8821A_2ANT_COEX_ALGO_SCO; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], SCO + PAN(EDR)\n"); + algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID; + } + } + } else { + if (coex_sta->hid_exist && + coex_sta->a2dp_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], HID + A2DP\n"); + algorithm = BT_8821A_2ANT_COEX_ALGO_HID_A2DP; + } else if (coex_sta->hid_exist && + coex_sta->pan_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], HID + PAN(HS)\n"); + algorithm = BT_8821A_2ANT_COEX_ALGO_HID; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], HID + PAN(EDR)\n"); + algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID; + } + } else if (coex_sta->pan_exist && + coex_sta->a2dp_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], A2DP + PAN(HS)\n"); + algorithm = BT_8821A_2ANT_COEX_ALGO_A2DP_PANHS; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], A2DP + PAN(EDR)\n"); + algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_A2DP; + } + } + } + } else if (num_of_diff_profile == 3) { + if (coex_sta->sco_exist) { + if (coex_sta->hid_exist && + coex_sta->a2dp_exist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], SCO + HID + A2DP ==> HID\n"); + algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID; + } else if (coex_sta->hid_exist && + coex_sta->pan_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], SCO + HID + PAN(HS)\n"); + algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], SCO + HID + PAN(EDR)\n"); + algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID; + } + } else if (coex_sta->pan_exist && + coex_sta->a2dp_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], SCO + A2DP + PAN(HS)\n"); + algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n"); + algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID; + } + } + } else { + if (coex_sta->hid_exist && + coex_sta->pan_exist && + coex_sta->a2dp_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], HID + A2DP + PAN(HS)\n"); + algorithm = BT_8821A_2ANT_COEX_ALGO_HID_A2DP; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], HID + A2DP + PAN(EDR)\n"); + algorithm = BT_8821A_2ANT_COEX_ALGO_HID_A2DP_PANEDR; + } + } + } + } else if (num_of_diff_profile >= 3) { + if (coex_sta->sco_exist) { + if (coex_sta->hid_exist && + coex_sta->pan_exist && + coex_sta->a2dp_exist) { + if (bt_hs_on) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n"); + + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], SCO + HID + A2DP + PAN(EDR) ==>PAN(EDR)+HID\n"); + algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID; + } + } + } + } + return algorithm; +} + +static bool halbtc8821a2ant_need_to_dec_bt_pwr(struct btc_coexist *btcoexist) +{ + bool ret = false; + bool bt_hs_on = false, wifi_connected = false; + long bt_hs_rssi = 0; + u8 bt_rssi_state; + + if (!btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on)) + return false; + if (!btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, + &wifi_connected)) + return false; + if (!btcoexist->btc_get(btcoexist, BTC_GET_S4_HS_RSSI, &bt_hs_rssi)) + return false; + + bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2, 35, 0); + + if (wifi_connected) { + if (bt_hs_on) { + if (bt_hs_rssi > 37) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, + "[BTCoex], Need to decrease bt power for HS mode!!\n"); + ret = true; + } + } else { + if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || + (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, + "[BTCoex], Need to decrease bt power for Wifi is connected!!\n"); + ret = true; + } + } + } + return ret; +} + +static void set_fw_dac_swing_level(struct btc_coexist *btcoexist, + u8 dac_swing_lvl) +{ + u8 h2c_parameter[1] = {0}; + + /* There are several type of dacswing */ + /* 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6 */ + h2c_parameter[0] = dac_swing_lvl; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], Set Dac Swing Level = 0x%x\n", dac_swing_lvl); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], FW write 0x64 = 0x%x\n", h2c_parameter[0]); + + btcoexist->btc_fill_h2c(btcoexist, 0x64, 1, h2c_parameter); +} + +static void halbtc8821a2ant_set_fw_dec_bt_pwr(struct btc_coexist *btcoexist, + bool dec_bt_pwr) +{ + u8 h2c_parameter[1] = {0}; + + h2c_parameter[0] = 0; + + if (dec_bt_pwr) + h2c_parameter[0] |= BIT(1); + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], decrease Bt Power : %s, FW write 0x62 = 0x%x\n", + (dec_bt_pwr ? "Yes!!" : "No!!"), h2c_parameter[0]); + + btcoexist->btc_fill_h2c(btcoexist, 0x62, 1, h2c_parameter); +} + +static void halbtc8821a2ant_dec_bt_pwr(struct btc_coexist *btcoexist, + bool force_exec, bool dec_bt_pwr) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, + "[BTCoex], %s Dec BT power = %s\n", + (force_exec ? "force to" : ""), + ((dec_bt_pwr) ? "ON" : "OFF")); + coex_dm->cur_dec_bt_pwr = dec_bt_pwr; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], pre_dec_bt_pwr =%d, cur_dec_bt_pwr =%d\n", + coex_dm->pre_dec_bt_pwr, coex_dm->cur_dec_bt_pwr); + + if (coex_dm->pre_dec_bt_pwr == coex_dm->cur_dec_bt_pwr) + return; + } + halbtc8821a2ant_set_fw_dec_bt_pwr(btcoexist, coex_dm->cur_dec_bt_pwr); + + coex_dm->pre_dec_bt_pwr = coex_dm->cur_dec_bt_pwr; +} + +static void set_fw_bt_lna_constrain(struct btc_coexist *btcoexist, + bool bt_lna_cons_on) +{ + u8 h2c_parameter[2] = {0}; + + h2c_parameter[0] = 0x3; /* opCode, 0x3 = BT_SET_LNA_CONSTRAIN */ + + if (bt_lna_cons_on) + h2c_parameter[1] |= BIT(0); + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], set BT LNA Constrain: %s, FW write 0x69 = 0x%x\n", + (bt_lna_cons_on ? "ON!!" : "OFF!!"), + h2c_parameter[0]<<8|h2c_parameter[1]); + + btcoexist->btc_fill_h2c(btcoexist, 0x69, 2, h2c_parameter); +} + +static void set_bt_lna_constrain(struct btc_coexist *btcoexist, bool force_exec, + bool bt_lna_cons_on) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, + "[BTCoex], %s BT Constrain = %s\n", + (force_exec ? "force" : ""), + ((bt_lna_cons_on) ? "ON" : "OFF")); + coex_dm->cur_bt_lna_constrain = bt_lna_cons_on; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], pre_bt_lna_constrain =%d, cur_bt_lna_constrain =%d\n", + coex_dm->pre_bt_lna_constrain, + coex_dm->cur_bt_lna_constrain); + + if (coex_dm->pre_bt_lna_constrain == + coex_dm->cur_bt_lna_constrain) + return; + } + set_fw_bt_lna_constrain(btcoexist, coex_dm->cur_bt_lna_constrain); + + coex_dm->pre_bt_lna_constrain = coex_dm->cur_bt_lna_constrain; +} + +static void halbtc8821a2ant_set_fw_bt_psd_mode(struct btc_coexist *btcoexist, + u8 bt_psd_mode) +{ + u8 h2c_parameter[2] = {0}; + + h2c_parameter[0] = 0x2; /* opCode, 0x2 = BT_SET_PSD_MODE */ + + h2c_parameter[1] = bt_psd_mode; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], set BT PSD mode = 0x%x, FW write 0x69 = 0x%x\n", + h2c_parameter[1], + h2c_parameter[0] << 8 | h2c_parameter[1]); + + btcoexist->btc_fill_h2c(btcoexist, 0x69, 2, h2c_parameter); +} + +static void halbtc8821a2ant_set_bt_psd_mode(struct btc_coexist *btcoexist, + bool force_exec, u8 bt_psd_mode) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, + "[BTCoex], %s BT PSD mode = 0x%x\n", + (force_exec ? "force" : ""), bt_psd_mode); + coex_dm->cur_bt_psd_mode = bt_psd_mode; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], pre_bt_psd_mode = 0x%x, cur_bt_psd_mode = 0x%x\n", + coex_dm->pre_bt_psd_mode, coex_dm->cur_bt_psd_mode); + + if (coex_dm->pre_bt_psd_mode == coex_dm->cur_bt_psd_mode) + return; + } + halbtc8821a2ant_set_fw_bt_psd_mode(btcoexist, coex_dm->cur_bt_psd_mode); + + coex_dm->pre_bt_psd_mode = coex_dm->cur_bt_psd_mode; +} + +static void halbtc8821a2ant_set_bt_auto_report(struct btc_coexist *btcoexist, + bool enable_auto_report) +{ + u8 h2c_parameter[1] = {0}; + + h2c_parameter[0] = 0; + + if (enable_auto_report) + h2c_parameter[0] |= BIT(0); + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], BT FW auto report : %s, FW write 0x68 = 0x%x\n", + (enable_auto_report ? "Enabled!!" : "Disabled!!"), + h2c_parameter[0]); + + btcoexist->btc_fill_h2c(btcoexist, 0x68, 1, h2c_parameter); +} + +static void halbtc8821a2ant_bt_auto_report(struct btc_coexist *btcoexist, + bool force_exec, + bool enable_auto_report) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, + "[BTCoex], %s BT Auto report = %s\n", + (force_exec ? "force to" : ""), + ((enable_auto_report) ? "Enabled" : "Disabled")); + coex_dm->cur_bt_auto_report = enable_auto_report; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], pre_bt_auto_report =%d, cur_bt_auto_report =%d\n", + coex_dm->pre_bt_auto_report, + coex_dm->cur_bt_auto_report); + + if (coex_dm->pre_bt_auto_report == coex_dm->cur_bt_auto_report) + return; + } + halbtc8821a2ant_set_bt_auto_report(btcoexist, + coex_dm->cur_bt_auto_report); + + coex_dm->pre_bt_auto_report = coex_dm->cur_bt_auto_report; +} + +static void halbtc8821a2ant_fw_dac_swing_lvl(struct btc_coexist *btcoexist, + bool force_exec, + u8 fw_dac_swing_lvl) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, + "[BTCoex], %s set FW Dac Swing level = %d\n", + (force_exec ? "force to" : ""), fw_dac_swing_lvl); + coex_dm->cur_fw_dac_swing_lvl = fw_dac_swing_lvl; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], pre_fw_dac_swing_lvl =%d, cur_fw_dac_swing_lvl =%d\n", + coex_dm->pre_fw_dac_swing_lvl, + coex_dm->cur_fw_dac_swing_lvl); + + if (coex_dm->pre_fw_dac_swing_lvl == + coex_dm->cur_fw_dac_swing_lvl) + return; + } + + set_fw_dac_swing_level(btcoexist, coex_dm->cur_fw_dac_swing_lvl); + + coex_dm->pre_fw_dac_swing_lvl = coex_dm->cur_fw_dac_swing_lvl; +} + +static void set_sw_rf_rx_lpf_corner(struct btc_coexist *btcoexist, + bool rx_rf_shrink_on) +{ + if (rx_rf_shrink_on) { + /* Shrink RF Rx LPF corner */ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], Shrink RF Rx LPF corner!!\n"); + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1e, + 0xfffff, 0xffffc); + } else { + /* Resume RF Rx LPF corner */ + /* After initialized, we can use coex_dm->bt_rf0x1e_backup */ + if (btcoexist->initilized) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], Resume RF Rx LPF corner!!\n"); + btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1e, + 0xfffff, + coex_dm->bt_rf0x1e_backup); + } + } +} + +static void halbtc8821a2ant_RfShrink(struct btc_coexist *btcoexist, + bool force_exec, bool rx_rf_shrink_on) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, + "[BTCoex], %s turn Rx RF Shrink = %s\n", + (force_exec ? "force to" : ""), + ((rx_rf_shrink_on) ? "ON" : "OFF")); + coex_dm->cur_rf_rx_lpf_shrink = rx_rf_shrink_on; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, + "[BTCoex], pre_rf_rx_lpf_shrink =%d, cur_rf_rx_lpf_shrink =%d\n", + coex_dm->pre_rf_rx_lpf_shrink, + coex_dm->cur_rf_rx_lpf_shrink); + + if (coex_dm->pre_rf_rx_lpf_shrink == + coex_dm->cur_rf_rx_lpf_shrink) + return; + } + set_sw_rf_rx_lpf_corner(btcoexist, coex_dm->cur_rf_rx_lpf_shrink); + + coex_dm->pre_rf_rx_lpf_shrink = coex_dm->cur_rf_rx_lpf_shrink; +} + +static void set_sw_penalty_tx_rate_adap(struct btc_coexist *btcoexist, + bool low_penalty_ra) +{ + u8 h2c_parameter[6] = {0}; + + h2c_parameter[0] = 0x6; /* opCode, 0x6 = Retry_Penalty */ + + if (low_penalty_ra) { + h2c_parameter[1] |= BIT(0); + /* normal rate except MCS7/6/5, OFDM54/48/36 */ + h2c_parameter[2] = 0x00; + h2c_parameter[3] = 0xf7; /* MCS7 or OFDM54 */ + h2c_parameter[4] = 0xf8; /* MCS6 or OFDM48 */ + h2c_parameter[5] = 0xf9; /* MCS5 or OFDM36 */ + } + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], set WiFi Low-Penalty Retry: %s", + (low_penalty_ra ? "ON!!" : "OFF!!")); + + btcoexist->btc_fill_h2c(btcoexist, 0x69, 6, h2c_parameter); +} + +static void halbtc8821a2ant_low_penalty_ra(struct btc_coexist *btcoexist, + bool force_exec, bool low_penalty_ra) +{ + /* return; */ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, + "[BTCoex], %s turn LowPenaltyRA = %s\n", + (force_exec ? "force to" : ""), + ((low_penalty_ra) ? "ON" : "OFF")); + coex_dm->cur_low_penalty_ra = low_penalty_ra; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, + "[BTCoex], pre_low_penalty_ra =%d, cur_low_penalty_ra =%d\n", + coex_dm->pre_low_penalty_ra, + coex_dm->cur_low_penalty_ra); + + if (coex_dm->pre_low_penalty_ra == coex_dm->cur_low_penalty_ra) + return; + } + set_sw_penalty_tx_rate_adap(btcoexist, coex_dm->cur_low_penalty_ra); + + coex_dm->pre_low_penalty_ra = coex_dm->cur_low_penalty_ra; +} + +static void halbtc8821a2ant_set_dac_swing_reg(struct btc_coexist *btcoexist, + u32 level) +{ + u8 val = (u8)level; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], Write SwDacSwing = 0x%x\n", level); + btcoexist->btc_write_1byte_bitmask(btcoexist, 0xc5b, 0x3e, val); +} + +static void set_sw_fulltime_dac_swing(struct btc_coexist *btcoexist, + bool sw_dac_swing_on, + u32 sw_dac_swing_lvl) +{ + if (sw_dac_swing_on) + halbtc8821a2ant_set_dac_swing_reg(btcoexist, sw_dac_swing_lvl); + else + halbtc8821a2ant_set_dac_swing_reg(btcoexist, 0x18); +} + +static void halbtc8821a2ant_dac_swing(struct btc_coexist *btcoexist, + bool force_exec, bool dac_swing_on, + u32 dac_swing_lvl) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, + "[BTCoex], %s turn DacSwing =%s, dac_swing_lvl = 0x%x\n", + (force_exec ? "force to" : ""), + ((dac_swing_on) ? "ON" : "OFF"), dac_swing_lvl); + coex_dm->cur_dac_swing_on = dac_swing_on; + coex_dm->cur_dac_swing_lvl = dac_swing_lvl; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, + "[BTCoex], pre_dac_swing_on =%d, pre_dac_swing_lvl = 0x%x, cur_dac_swing_on =%d, cur_dac_swing_lvl = 0x%x\n", + coex_dm->pre_dac_swing_on, + coex_dm->pre_dac_swing_lvl, + coex_dm->cur_dac_swing_on, + coex_dm->cur_dac_swing_lvl); + + if ((coex_dm->pre_dac_swing_on == coex_dm->cur_dac_swing_on) && + (coex_dm->pre_dac_swing_lvl == coex_dm->cur_dac_swing_lvl)) + return; + } + mdelay(30); + set_sw_fulltime_dac_swing(btcoexist, dac_swing_on, dac_swing_lvl); + + coex_dm->pre_dac_swing_on = coex_dm->cur_dac_swing_on; + coex_dm->pre_dac_swing_lvl = coex_dm->cur_dac_swing_lvl; +} + +static void halbtc8821a2ant_set_adc_back_off(struct btc_coexist *btcoexist, + bool adc_back_off) +{ + if (adc_back_off) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], BB BackOff Level On!\n"); + btcoexist->btc_write_1byte_bitmask(btcoexist, 0x8db, 0x60, 0x3); + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], BB BackOff Level Off!\n"); + btcoexist->btc_write_1byte_bitmask(btcoexist, 0x8db, 0x60, 0x1); + } +} + +static void halbtc8821a2ant_adc_back_off(struct btc_coexist *btcoexist, + bool force_exec, bool adc_back_off) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, + "[BTCoex], %s turn AdcBackOff = %s\n", + (force_exec ? "force to" : ""), + ((adc_back_off) ? "ON" : "OFF")); + coex_dm->cur_adc_back_off = adc_back_off; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, + "[BTCoex], pre_adc_back_off =%d, cur_adc_back_off =%d\n", + coex_dm->pre_adc_back_off, coex_dm->cur_adc_back_off); + + if (coex_dm->pre_adc_back_off == coex_dm->cur_adc_back_off) + return; + } + halbtc8821a2ant_set_adc_back_off(btcoexist, coex_dm->cur_adc_back_off); + + coex_dm->pre_adc_back_off = coex_dm->cur_adc_back_off; +} + +static void halbtc8821a2ant_set_coex_table(struct btc_coexist *btcoexist, + u32 val0x6c0, u32 val0x6c4, + u32 val0x6c8, u8 val0x6cc) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], set coex table, set 0x6c0 = 0x%x\n", val0x6c0); + btcoexist->btc_write_4byte(btcoexist, 0x6c0, val0x6c0); + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], set coex table, set 0x6c4 = 0x%x\n", val0x6c4); + btcoexist->btc_write_4byte(btcoexist, 0x6c4, val0x6c4); + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], set coex table, set 0x6c8 = 0x%x\n", val0x6c8); + btcoexist->btc_write_4byte(btcoexist, 0x6c8, val0x6c8); + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, + "[BTCoex], set coex table, set 0x6cc = 0x%x\n", val0x6cc); + btcoexist->btc_write_1byte(btcoexist, 0x6cc, val0x6cc); +} + +static void halbtc8821a2ant_coex_table(struct btc_coexist *btcoexist, + bool force_exec, u32 val0x6c0, + u32 val0x6c4, u32 val0x6c8, u8 val0x6cc) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, + "[BTCoex], %s write Coex Table 0x6c0 = 0x%x, 0x6c4 = 0x%x, 0x6c8 = 0x%x, 0x6cc = 0x%x\n", + (force_exec ? "force to" : ""), + val0x6c0, val0x6c4, val0x6c8, val0x6cc); + coex_dm->cur_val0x6c0 = val0x6c0; + coex_dm->cur_val0x6c4 = val0x6c4; + coex_dm->cur_val0x6c8 = val0x6c8; + coex_dm->cur_val0x6cc = val0x6cc; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, + "[BTCoex], pre_val0x6c0 = 0x%x, pre_val0x6c4 = 0x%x, pre_val0x6c8 = 0x%x, pre_val0x6cc = 0x%x !!\n", + coex_dm->pre_val0x6c0, coex_dm->pre_val0x6c4, + coex_dm->pre_val0x6c8, coex_dm->pre_val0x6cc); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, + "[BTCoex], cur_val0x6c0 = 0x%x, cur_val0x6c4 = 0x%x, cur_val0x6c8 = 0x%x, cur_val0x6cc = 0x%x !!\n", + coex_dm->cur_val0x6c0, coex_dm->cur_val0x6c4, + coex_dm->cur_val0x6c8, coex_dm->cur_val0x6cc); + + if ((coex_dm->pre_val0x6c0 == coex_dm->cur_val0x6c0) && + (coex_dm->pre_val0x6c4 == coex_dm->cur_val0x6c4) && + (coex_dm->pre_val0x6c8 == coex_dm->cur_val0x6c8) && + (coex_dm->pre_val0x6cc == coex_dm->cur_val0x6cc)) + return; + } + halbtc8821a2ant_set_coex_table(btcoexist, val0x6c0, val0x6c4, + val0x6c8, val0x6cc); + + coex_dm->pre_val0x6c0 = coex_dm->cur_val0x6c0; + coex_dm->pre_val0x6c4 = coex_dm->cur_val0x6c4; + coex_dm->pre_val0x6c8 = coex_dm->cur_val0x6c8; + coex_dm->pre_val0x6cc = coex_dm->cur_val0x6cc; +} + +static void set_fw_ignore_wlan_act(struct btc_coexist *btcoexist, bool enable) +{ + u8 h2c_parameter[1] = {0}; + + if (enable) + h2c_parameter[0] |= BIT(0); /* function enable */ + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63 = 0x%x\n", + h2c_parameter[0]); + + btcoexist->btc_fill_h2c(btcoexist, 0x63, 1, h2c_parameter); +} + +static void halbtc8821a2ant_ignore_wlan_act(struct btc_coexist *btcoexist, + bool force_exec, bool enable) +{ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, + "[BTCoex], %s turn Ignore WlanAct %s\n", + (force_exec ? "force to" : ""), (enable ? "ON" : "OFF")); + coex_dm->cur_ignore_wlan_act = enable; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], pre_ignore_wlan_act = %d, cur_ignore_wlan_act = %d!!\n", + coex_dm->pre_ignore_wlan_act, + coex_dm->cur_ignore_wlan_act); + if (coex_dm->pre_ignore_wlan_act == + coex_dm->cur_ignore_wlan_act) + return; + } + set_fw_ignore_wlan_act(btcoexist, enable); + + coex_dm->pre_ignore_wlan_act = coex_dm->cur_ignore_wlan_act; +} + +static void halbtc8821a2ant_set_fw_pstdma(struct btc_coexist *btcoexist, + u8 byte1, u8 byte2, u8 byte3, + u8 byte4, u8 byte5) +{ + u8 h2c_parameter[5] = {0}; + + h2c_parameter[0] = byte1; + h2c_parameter[1] = byte2; + h2c_parameter[2] = byte3; + h2c_parameter[3] = byte4; + h2c_parameter[4] = byte5; + + coex_dm->ps_tdma_para[0] = byte1; + coex_dm->ps_tdma_para[1] = byte2; + coex_dm->ps_tdma_para[2] = byte3; + coex_dm->ps_tdma_para[3] = byte4; + coex_dm->ps_tdma_para[4] = byte5; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], FW write 0x60(5bytes) = 0x%x%08x\n", + h2c_parameter[0], + h2c_parameter[1] << 24 | h2c_parameter[2] << 16 | + h2c_parameter[3]<<8|h2c_parameter[4]); + + btcoexist->btc_fill_h2c(btcoexist, 0x60, 5, h2c_parameter); +} + +static void sw_mechanism1(struct btc_coexist *btcoexist, bool shrink_rx_lpf, + bool low_penalty_ra, bool limited_dig, + bool bt_lna_constrain) +{ + u32 wifi_bw; + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + + if (BTC_WIFI_BW_HT40 != wifi_bw) { /* only shrink RF Rx LPF for HT40 */ + if (shrink_rx_lpf) + shrink_rx_lpf = false; + } + + halbtc8821a2ant_RfShrink(btcoexist, NORMAL_EXEC, shrink_rx_lpf); + halbtc8821a2ant_low_penalty_ra(btcoexist, NORMAL_EXEC, low_penalty_ra); + + /* no limited DIG */ + /* set_bt_lna_constrain(btcoexist, NORMAL_EXEC, bBTLNAConstrain); */ +} + +static void sw_mechanism2(struct btc_coexist *btcoexist, bool agc_table_shift, + bool adc_back_off, bool sw_dac_swing, + u32 dac_swing_lvl) +{ + /* halbtc8821a2ant_AgcTable(btcoexist, NORMAL_EXEC, bAGCTableShift); */ + halbtc8821a2ant_adc_back_off(btcoexist, NORMAL_EXEC, adc_back_off); + halbtc8821a2ant_dac_swing(btcoexist, NORMAL_EXEC, sw_dac_swing, + sw_dac_swing); +} + +static void halbtc8821a2ant_set_ant_path(struct btc_coexist *btcoexist, + u8 ant_pos_type, bool init_hw_cfg, + bool wifi_off) +{ + struct btc_board_info *board_info = &btcoexist->board_info; + u32 u4tmp = 0; + u8 h2c_parameter[2] = {0}; + + if (init_hw_cfg) { + /* 0x4c[23] = 0, 0x4c[24] = 1 Antenna control by WL/BT */ + u4tmp = btcoexist->btc_read_4byte(btcoexist, 0x4c); + u4tmp &= ~BIT(23); + u4tmp |= BIT(24); + btcoexist->btc_write_4byte(btcoexist, 0x4c, u4tmp); + + btcoexist->btc_write_4byte(btcoexist, 0x974, 0x3ff); + btcoexist->btc_write_1byte(btcoexist, 0xcb4, 0x77); + + if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) { + /* tell firmware "antenna inverse" ==> WRONG firmware + * antenna control code.==>need fw to fix */ + h2c_parameter[0] = 1; + h2c_parameter[1] = 1; + btcoexist->btc_fill_h2c(btcoexist, 0x65, 2, h2c_parameter); + } else { + /* tell firmware "no antenna inverse" ==> WRONG firmware + * antenna control code.==>need fw to fix */ + h2c_parameter[0] = 0; + h2c_parameter[1] = 1; + btcoexist->btc_fill_h2c(btcoexist, 0x65, 2, + h2c_parameter); + } + } + + /* ext switch setting */ + switch (ant_pos_type) { + case BTC_ANT_WIFI_AT_MAIN: + btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcb7, 0x30, 0x1); + break; + case BTC_ANT_WIFI_AT_AUX: + btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcb7, 0x30, 0x2); + break; + } +} + +static void ps21a_tdma(struct btc_coexist *btcoexist, bool force_exec, + bool turn_on, u8 type) +{ + /* bool turn_on_by_cnt = false; */ + /* u8 ps_tdma_type_by_cnt = 0; */ + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, + "[BTCoex], %s turn %s PS TDMA, type =%d\n", + (force_exec ? "force to" : ""), + (turn_on ? "ON" : "OFF"), type); + coex_dm->cur_ps_tdma_on = turn_on; + coex_dm->cur_ps_tdma = type; + + if (!force_exec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], pre_ps_tdma_on = %d, cur_ps_tdma_on = %d!!\n", + coex_dm->pre_ps_tdma_on, coex_dm->cur_ps_tdma_on); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], pre_ps_tdma = %d, cur_ps_tdma = %d!!\n", + coex_dm->pre_ps_tdma, coex_dm->cur_ps_tdma); + + if ((coex_dm->pre_ps_tdma_on == coex_dm->cur_ps_tdma_on) && + (coex_dm->pre_ps_tdma == coex_dm->cur_ps_tdma)) + return; + } + if (turn_on) { + switch (type) { + case 1: + default: + halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x1a, + 0x1a, 0xe1, 0x90); + break; + case 2: + halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x12, + 0x12, 0xe1, 0x90); + break; + case 3: + halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x1c, + 0x3, 0xf1, 0x90); + break; + case 4: + halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x10, + 0x03, 0xf1, 0x90); + break; + case 5: + halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x1a, + 0x1a, 0x60, 0x90); + break; + case 6: + halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x12, + 0x12, 0x60, 0x90); + break; + case 7: + halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x1c, + 0x3, 0x70, 0x90); + break; + case 8: + halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xa3, 0x10, + 0x3, 0x70, 0x90); + break; + case 9: + halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x1a, + 0x1a, 0xe1, 0x90); + break; + case 10: + halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x12, + 0x12, 0xe1, 0x90); + break; + case 11: + halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0xa, + 0xa, 0xe1, 0x90); + break; + case 12: + halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x5, + 0x5, 0xe1, 0x90); + break; + case 13: + halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x1a, + 0x1a, 0x60, 0x90); + break; + case 14: + halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x12, + 0x12, 0x60, 0x90); + break; + case 15: + halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0xa, + 0xa, 0x60, 0x90); + break; + case 16: + halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x5, + 0x5, 0x60, 0x90); + break; + case 17: + halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xa3, 0x2f, + 0x2f, 0x60, 0x90); + break; + case 18: + halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x5, + 0x5, 0xe1, 0x90); + break; + case 19: + halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x25, + 0x25, 0xe1, 0x90); + break; + case 20: + halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x25, + 0x25, 0x60, 0x90); + break; + case 21: + halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x15, + 0x03, 0x70, 0x90); + break; + case 71: + halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x1a, + 0x1a, 0xe1, 0x90); + break; + } + } else { + /* disable PS tdma */ + switch (type) { + case 0: + halbtc8821a2ant_set_fw_pstdma(btcoexist, 0x0, 0x0, 0x0, + 0x40, 0x0); + break; + case 1: + halbtc8821a2ant_set_fw_pstdma(btcoexist, 0x0, 0x0, 0x0, + 0x48, 0x0); + break; + default: + halbtc8821a2ant_set_fw_pstdma(btcoexist, 0x0, 0x0, 0x0, + 0x40, 0x0); + break; + } + } + + /* update pre state */ + coex_dm->pre_ps_tdma_on = coex_dm->cur_ps_tdma_on; + coex_dm->pre_ps_tdma = coex_dm->cur_ps_tdma; +} + +static void halbtc8821a2ant_coex_all_off(struct btc_coexist *btcoexist) +{ + /* fw all off */ + ps21a_tdma(btcoexist, NORMAL_EXEC, false, 1); + halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); + halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + + /* sw all off */ + sw_mechanism1(btcoexist, false, false, false, false); + sw_mechanism2(btcoexist, false, false, false, 0x18); + + /* hw all off */ + halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55555555, + 0x55555555, 0xffff, 0x3); +} + +static void halbtc8821a2ant_coex_under_5g(struct btc_coexist *btcoexist) +{ + halbtc8821a2ant_coex_all_off(btcoexist); +} + +static void halbtc8821a2ant_init_coex_dm(struct btc_coexist *btcoexist) +{ + /* force to reset coex mechanism */ + halbtc8821a2ant_coex_table(btcoexist, FORCE_EXEC, 0x55555555, + 0x55555555, 0xffff, 0x3); + + ps21a_tdma(btcoexist, FORCE_EXEC, false, 1); + halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, FORCE_EXEC, 6); + halbtc8821a2ant_dec_bt_pwr(btcoexist, FORCE_EXEC, false); + + sw_mechanism1(btcoexist, false, false, false, false); + sw_mechanism2(btcoexist, false, false, false, 0x18); +} + +static void halbtc8821a2ant_bt_inquiry_page(struct btc_coexist *btcoexist) +{ + bool low_pwr_disable = true; + + btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, + &low_pwr_disable); + + halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, + 0x5afa5afa, 0xffff, 0x3); + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 3); +} + +static bool halbtc8821a2ant_is_common_action(struct btc_coexist *btcoexist) +{ + bool common = false, wifi_connected = false, wifi_busy = false; + bool low_pwr_disable = false; + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, + &wifi_connected); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); + + halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, + 0x5afa5afa, 0xffff, 0x3); + + if (!wifi_connected && + BT_8821A_2ANT_BT_STATUS_IDLE == coex_dm->bt_status) { + low_pwr_disable = false; + btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, + &low_pwr_disable); + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Wifi IPS + BT IPS!!\n"); + + ps21a_tdma(btcoexist, NORMAL_EXEC, false, 1); + halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); + halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + + sw_mechanism1(btcoexist, false, false, false, false); + sw_mechanism2(btcoexist, false, false, false, 0x18); + + common = true; + } else if (wifi_connected && + (BT_8821A_2ANT_BT_STATUS_IDLE == coex_dm->bt_status)) { + low_pwr_disable = false; + btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, + &low_pwr_disable); + + if (wifi_busy) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Wifi Busy + BT IPS!!\n"); + ps21a_tdma(btcoexist, NORMAL_EXEC, false, 1); + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Wifi LPS + BT IPS!!\n"); + ps21a_tdma(btcoexist, NORMAL_EXEC, false, 1); + } + + halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); + halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + + sw_mechanism1(btcoexist, false, false, false, false); + sw_mechanism2(btcoexist, false, false, false, 0x18); + + common = true; + } else if (!wifi_connected && + (BT_8821A_2ANT_BT_STATUS_CONNECTED_IDLE == + coex_dm->bt_status)) { + low_pwr_disable = true; + btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, + &low_pwr_disable); + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Wifi IPS + BT LPS!!\n"); + + ps21a_tdma(btcoexist, NORMAL_EXEC, false, 1); + halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); + halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + + sw_mechanism1(btcoexist, false, false, false, false); + sw_mechanism2(btcoexist, false, false, false, 0x18); + + common = true; + } else if (wifi_connected && + (BT_8821A_2ANT_BT_STATUS_CONNECTED_IDLE == + coex_dm->bt_status)) { + low_pwr_disable = true; + btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, + &low_pwr_disable); + + if (wifi_busy) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Wifi Busy + BT LPS!!\n"); + ps21a_tdma(btcoexist, NORMAL_EXEC, false, 1); + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Wifi LPS + BT LPS!!\n"); + ps21a_tdma(btcoexist, NORMAL_EXEC, false, 1); + } + + halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); + halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + + sw_mechanism1(btcoexist, true, true, true, true); + sw_mechanism2(btcoexist, false, false, false, 0x18); + + common = true; + } else if (!wifi_connected && + (BT_8821A_2ANT_BT_STATUS_NON_IDLE == coex_dm->bt_status)) { + low_pwr_disable = false; + btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, + &low_pwr_disable); + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Wifi IPS + BT Busy!!\n"); + + ps21a_tdma(btcoexist, NORMAL_EXEC, false, 1); + halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); + halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + + sw_mechanism1(btcoexist, false, false, false, false); + sw_mechanism2(btcoexist, false, false, false, 0x18); + + common = true; + } else { + low_pwr_disable = true; + btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, + &low_pwr_disable); + + if (wifi_busy) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Wifi Busy + BT Busy!!\n"); + common = false; + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Wifi LPS + BT Busy!!\n"); + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 21); + + if (halbtc8821a2ant_need_to_dec_bt_pwr(btcoexist)) + halbtc8821a2ant_dec_bt_pwr(btcoexist, + NORMAL_EXEC, true); + else + halbtc8821a2ant_dec_bt_pwr(btcoexist, + NORMAL_EXEC, false); + + common = true; + } + sw_mechanism1(btcoexist, true, true, true, true); + } + return common; +} + +static void tdma_duration_adjust(struct btc_coexist *btcoexist, + bool sco_hid, bool tx_pause, u8 max_interval) +{ + static long up, dn, m, n, wait_count; + long result; + /* 0: no change, +1: incr WiFi duration, -1: decr WiFi duration */ + u8 retry_count = 0; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, + "[BTCoex], TdmaDurationAdjust()\n"); + + if (coex_dm->reset_tdma_adjust) { + coex_dm->reset_tdma_adjust = false; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], first run TdmaDurationAdjust()!!\n"); + if (sco_hid) { + if (tx_pause) { + if (max_interval == 1) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 13); + coex_dm->ps_tdma_du_adj_type = 13; + } else if (max_interval == 2) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 14); + coex_dm->ps_tdma_du_adj_type = 14; + } else if (max_interval == 3) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } else { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } + } else { + if (max_interval == 1) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 9); + coex_dm->ps_tdma_du_adj_type = 9; + } else if (max_interval == 2) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 10); + coex_dm->ps_tdma_du_adj_type = 10; + } else if (max_interval == 3) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } else { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } + } + } else { + if (tx_pause) { + if (max_interval == 1) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 5); + coex_dm->ps_tdma_du_adj_type = 5; + } else if (max_interval == 2) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 6); + coex_dm->ps_tdma_du_adj_type = 6; + } else if (max_interval == 3) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } else { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } + } else { + if (max_interval == 1) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 1); + coex_dm->ps_tdma_du_adj_type = 1; + } else if (max_interval == 2) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 2); + coex_dm->ps_tdma_du_adj_type = 2; + } else if (max_interval == 3) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } else { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } + } + } + up = 0; + dn = 0; + m = 1; + n = 3; + result = 0; + wait_count = 0; + } else { + /* accquire the BT TRx retry count from BT_Info byte2 */ + retry_count = coex_sta->bt_retry_cnt; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], retry_count = %d\n", retry_count); + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], up =%d, dn =%d, m =%d, n =%d, wait_count =%d\n", + (int)up, (int)dn, (int)m, (int)n, (int)wait_count); + result = 0; + wait_count++; + + if (retry_count == 0) { + /* no retry in the last 2-second duration */ + up++; + dn--; + + if (dn <= 0) + dn = 0; + + if (up >= n) { + wait_count = 0; + n = 3; + up = 0; + dn = 0; + result = 1; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_TRACE_FW_DETAIL, + "[BTCoex], Increase wifi duration!!\n"); + } + } else if (retry_count <= 3) { + /* <= 3 retry in the last 2-second duration */ + up--; + dn++; + + if (up <= 0) + up = 0; + + if (dn == 2) { + if (wait_count <= 2) + m++; + else + m = 1; + + if (m >= 20) + m = 20; + + n = 3*m; + up = 0; + dn = 0; + wait_count = 0; + result = -1; + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_TRACE_FW_DETAIL, + "[BTCoex], Decrease wifi duration for retryCounter<3!!\n"); + } + } else { + if (wait_count == 1) + m++; + else + m = 1; + + if (m >= 20) + m = 20; + + n = 3*m; + up = 0; + dn = 0; + wait_count = 0; + result = -1; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], Decrease wifi duration for retryCounter>3!!\n"); + } + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], max Interval = %d\n", max_interval); + if (max_interval == 1) { + if (tx_pause) { + /* TODO: refactor here */ + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_TRACE_FW_DETAIL, + "[BTCoex], TxPause = 1\n"); + if (coex_dm->cur_ps_tdma == 71) { + ps21a_tdma(btcoexist, + NORMAL_EXEC, + true, 5); + coex_dm->ps_tdma_du_adj_type = 5; + } else if (coex_dm->cur_ps_tdma == 1) { + ps21a_tdma(btcoexist, + NORMAL_EXEC, + true, 5); + coex_dm->ps_tdma_du_adj_type = 5; + } else if (coex_dm->cur_ps_tdma == 2) { + ps21a_tdma(btcoexist, + NORMAL_EXEC, + true, 6); + coex_dm->ps_tdma_du_adj_type = 6; + } else if (coex_dm->cur_ps_tdma == 3) { + ps21a_tdma(btcoexist, + NORMAL_EXEC, + true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } else if (coex_dm->cur_ps_tdma == 4) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 8); + coex_dm->ps_tdma_du_adj_type = 8; + } + if (coex_dm->cur_ps_tdma == 9) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 13); + coex_dm->ps_tdma_du_adj_type = 13; + } else if (coex_dm->cur_ps_tdma == 10) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 14); + coex_dm->ps_tdma_du_adj_type = 14; + } else if (coex_dm->cur_ps_tdma == 11) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } else if (coex_dm->cur_ps_tdma == 12) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 16); + coex_dm->ps_tdma_du_adj_type = 16; + } + + if (result == -1) { + if (coex_dm->cur_ps_tdma == 5) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 6); + coex_dm->ps_tdma_du_adj_type = 6; + } else if (coex_dm->cur_ps_tdma == 6) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } else if (coex_dm->cur_ps_tdma == 7) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 8); + coex_dm->ps_tdma_du_adj_type = 8; + } else if (coex_dm->cur_ps_tdma == 13) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 14); + coex_dm->ps_tdma_du_adj_type = 14; + } else if (coex_dm->cur_ps_tdma == 14) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } else if (coex_dm->cur_ps_tdma == 15) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 16); + coex_dm->ps_tdma_du_adj_type = 16; + } + } else if (result == 1) { + if (coex_dm->cur_ps_tdma == 8) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } else if (coex_dm->cur_ps_tdma == 7) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 6); + coex_dm->ps_tdma_du_adj_type = 6; + } else if (coex_dm->cur_ps_tdma == 6) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 5); + coex_dm->ps_tdma_du_adj_type = 5; + } else if (coex_dm->cur_ps_tdma == 16) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } else if (coex_dm->cur_ps_tdma == 15) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 14); + coex_dm->ps_tdma_du_adj_type = 14; + } else if (coex_dm->cur_ps_tdma == 14) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 13); + coex_dm->ps_tdma_du_adj_type = 13; + } + } + } else { + /* TODO: refactor here */ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, "[BTCoex], TxPause = 0\n"); + if (coex_dm->cur_ps_tdma == 5) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 71); + coex_dm->ps_tdma_du_adj_type = 71; + } else if (coex_dm->cur_ps_tdma == 6) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 2); + coex_dm->ps_tdma_du_adj_type = 2; + } else if (coex_dm->cur_ps_tdma == 7) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } else if (coex_dm->cur_ps_tdma == 8) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 4); + coex_dm->ps_tdma_du_adj_type = 4; + } + if (coex_dm->cur_ps_tdma == 13) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 9); + coex_dm->ps_tdma_du_adj_type = 9; + } else if (coex_dm->cur_ps_tdma == 14) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 10); + coex_dm->ps_tdma_du_adj_type = 10; + } else if (coex_dm->cur_ps_tdma == 15) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } else if (coex_dm->cur_ps_tdma == 16) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 12); + coex_dm->ps_tdma_du_adj_type = 12; + } + + if (result == -1) { + if (coex_dm->cur_ps_tdma == 71) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 1); + coex_dm->ps_tdma_du_adj_type = 1; + } else if (coex_dm->cur_ps_tdma == 1) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 2); + coex_dm->ps_tdma_du_adj_type = 2; + } else if (coex_dm->cur_ps_tdma == 2) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } else if (coex_dm->cur_ps_tdma == 3) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 4); + coex_dm->ps_tdma_du_adj_type = 4; + } else if (coex_dm->cur_ps_tdma == 9) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 10); + coex_dm->ps_tdma_du_adj_type = 10; + } else if (coex_dm->cur_ps_tdma == 10) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } else if (coex_dm->cur_ps_tdma == 11) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 12); + coex_dm->ps_tdma_du_adj_type = 12; + } + } else if (result == 1) { + if (coex_dm->cur_ps_tdma == 4) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } else if (coex_dm->cur_ps_tdma == 3) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 2); + coex_dm->ps_tdma_du_adj_type = 2; + } else if (coex_dm->cur_ps_tdma == 2) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 1); + coex_dm->ps_tdma_du_adj_type = 1; + } else if (coex_dm->cur_ps_tdma == 1) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 71); + coex_dm->ps_tdma_du_adj_type = 71; + } else if (coex_dm->cur_ps_tdma == 12) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } else if (coex_dm->cur_ps_tdma == 11) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 10); + coex_dm->ps_tdma_du_adj_type = 10; + } else if (coex_dm->cur_ps_tdma == 10) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 9); + coex_dm->ps_tdma_du_adj_type = 9; + } + } + } + } else if (max_interval == 2) { + if (tx_pause) { + /* TODO: refactor here */ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, "[BTCoex], TxPause = 1\n"); + if (coex_dm->cur_ps_tdma == 1) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 6); + coex_dm->ps_tdma_du_adj_type = 6; + } else if (coex_dm->cur_ps_tdma == 2) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 6); + coex_dm->ps_tdma_du_adj_type = 6; + } else if (coex_dm->cur_ps_tdma == 3) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } else if (coex_dm->cur_ps_tdma == 4) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 8); + coex_dm->ps_tdma_du_adj_type = 8; + } + if (coex_dm->cur_ps_tdma == 9) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 14); + coex_dm->ps_tdma_du_adj_type = 14; + } else if (coex_dm->cur_ps_tdma == 10) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 14); + coex_dm->ps_tdma_du_adj_type = 14; + } else if (coex_dm->cur_ps_tdma == 11) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } else if (coex_dm->cur_ps_tdma == 12) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 16); + coex_dm->ps_tdma_du_adj_type = 16; + } + if (result == -1) { + if (coex_dm->cur_ps_tdma == 5) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 6); + coex_dm->ps_tdma_du_adj_type = 6; + } else if (coex_dm->cur_ps_tdma == 6) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } else if (coex_dm->cur_ps_tdma == 7) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 8); + coex_dm->ps_tdma_du_adj_type = 8; + } else if (coex_dm->cur_ps_tdma == 13) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 14); + coex_dm->ps_tdma_du_adj_type = 14; + } else if (coex_dm->cur_ps_tdma == 14) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } else if (coex_dm->cur_ps_tdma == 15) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 16); + coex_dm->ps_tdma_du_adj_type = 16; + } + } else if (result == 1) { + if (coex_dm->cur_ps_tdma == 8) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } else if (coex_dm->cur_ps_tdma == 7) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 6); + coex_dm->ps_tdma_du_adj_type = 6; + } else if (coex_dm->cur_ps_tdma == 6) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 6); + coex_dm->ps_tdma_du_adj_type = 6; + } else if (coex_dm->cur_ps_tdma == 16) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } else if (coex_dm->cur_ps_tdma == 15) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 14); + coex_dm->ps_tdma_du_adj_type = 14; + } else if (coex_dm->cur_ps_tdma == 14) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 14); + coex_dm->ps_tdma_du_adj_type = 14; + } + } + } else { + /* TODO: refactor here */ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], TxPause = 0\n"); + if (coex_dm->cur_ps_tdma == 5) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 2); + coex_dm->ps_tdma_du_adj_type = 2; + } else if (coex_dm->cur_ps_tdma == 6) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 2); + coex_dm->ps_tdma_du_adj_type = 2; + } else if (coex_dm->cur_ps_tdma == 7) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } else if (coex_dm->cur_ps_tdma == 8) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 4); + coex_dm->ps_tdma_du_adj_type = 4; + } + if (coex_dm->cur_ps_tdma == 13) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 10); + coex_dm->ps_tdma_du_adj_type = 10; + } else if (coex_dm->cur_ps_tdma == 14) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 10); + coex_dm->ps_tdma_du_adj_type = 10; + } else if (coex_dm->cur_ps_tdma == 15) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } else if (coex_dm->cur_ps_tdma == 16) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 12); + coex_dm->ps_tdma_du_adj_type = 12; + } + if (result == -1) { + if (coex_dm->cur_ps_tdma == 1) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 2); + coex_dm->ps_tdma_du_adj_type = 2; + } else if (coex_dm->cur_ps_tdma == 2) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } else if (coex_dm->cur_ps_tdma == 3) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 4); + coex_dm->ps_tdma_du_adj_type = 4; + } else if (coex_dm->cur_ps_tdma == 9) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 10); + coex_dm->ps_tdma_du_adj_type = 10; + } else if (coex_dm->cur_ps_tdma == 10) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } else if (coex_dm->cur_ps_tdma == 11) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 12); + coex_dm->ps_tdma_du_adj_type = 12; + } + } else if (result == 1) { + if (coex_dm->cur_ps_tdma == 4) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } else if (coex_dm->cur_ps_tdma == 3) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 2); + coex_dm->ps_tdma_du_adj_type = 2; + } else if (coex_dm->cur_ps_tdma == 2) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 2); + coex_dm->ps_tdma_du_adj_type = 2; + } else if (coex_dm->cur_ps_tdma == 12) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } else if (coex_dm->cur_ps_tdma == 11) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 10); + coex_dm->ps_tdma_du_adj_type = 10; + } else if (coex_dm->cur_ps_tdma == 10) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 10); + coex_dm->ps_tdma_du_adj_type = 10; + } + } + } + } else if (max_interval == 3) { + if (tx_pause) { + /* TODO: refactor here */ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], TxPause = 1\n"); + if (coex_dm->cur_ps_tdma == 1) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } else if (coex_dm->cur_ps_tdma == 2) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } else if (coex_dm->cur_ps_tdma == 3) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } else if (coex_dm->cur_ps_tdma == 4) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 8); + coex_dm->ps_tdma_du_adj_type = 8; + } + if (coex_dm->cur_ps_tdma == 9) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } else if (coex_dm->cur_ps_tdma == 10) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } else if (coex_dm->cur_ps_tdma == 11) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } else if (coex_dm->cur_ps_tdma == 12) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 16); + coex_dm->ps_tdma_du_adj_type = 16; + } + if (result == -1) { + if (coex_dm->cur_ps_tdma == 5) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } else if (coex_dm->cur_ps_tdma == 6) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } else if (coex_dm->cur_ps_tdma == 7) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 8); + coex_dm->ps_tdma_du_adj_type = 8; + } else if (coex_dm->cur_ps_tdma == 13) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } else if (coex_dm->cur_ps_tdma == 14) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } else if (coex_dm->cur_ps_tdma == 15) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 16); + coex_dm->ps_tdma_du_adj_type = 16; + } + } else if (result == 1) { + if (coex_dm->cur_ps_tdma == 8) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } else if (coex_dm->cur_ps_tdma == 7) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } else if (coex_dm->cur_ps_tdma == 6) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); + coex_dm->ps_tdma_du_adj_type = 7; + } else if (coex_dm->cur_ps_tdma == 16) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } else if (coex_dm->cur_ps_tdma == 15) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } else if (coex_dm->cur_ps_tdma == 14) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); + coex_dm->ps_tdma_du_adj_type = 15; + } + } + } else { + BTC_PRINT(BTC_MSG_ALGORITHM, + ALGO_TRACE_FW_DETAIL, + "[BTCoex], TxPause = 0\n"); + if (coex_dm->cur_ps_tdma == 5) { + ps21a_tdma(btcoexist, NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } else if (coex_dm->cur_ps_tdma == 6) { + ps21a_tdma(btcoexist, NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } else if (coex_dm->cur_ps_tdma == 7) { + ps21a_tdma(btcoexist, NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } else if (coex_dm->cur_ps_tdma == 8) { + ps21a_tdma(btcoexist, NORMAL_EXEC, + true, 4); + coex_dm->ps_tdma_du_adj_type = 4; + } + if (coex_dm->cur_ps_tdma == 13) { + ps21a_tdma(btcoexist, NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } else if (coex_dm->cur_ps_tdma == 14) { + ps21a_tdma(btcoexist, NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } else if (coex_dm->cur_ps_tdma == 15) { + ps21a_tdma(btcoexist, NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } else if (coex_dm->cur_ps_tdma == 16) { + ps21a_tdma(btcoexist, NORMAL_EXEC, + true, 12); + coex_dm->ps_tdma_du_adj_type = 12; + } + if (result == -1) { + if (coex_dm->cur_ps_tdma == 1) { + ps21a_tdma(btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } else if (coex_dm->cur_ps_tdma == 2) { + ps21a_tdma(btcoexist, + NORMAL_EXEC, + true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } else if (coex_dm->cur_ps_tdma == 3) { + ps21a_tdma(btcoexist, + NORMAL_EXEC, + true, 4); + coex_dm->ps_tdma_du_adj_type = 4; + } else if (coex_dm->cur_ps_tdma == 9) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } else if (coex_dm->cur_ps_tdma == 10) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } else if (coex_dm->cur_ps_tdma == 11) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 12); + coex_dm->ps_tdma_du_adj_type = 12; + } + } else if (result == 1) { + if (coex_dm->cur_ps_tdma == 4) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } else if (coex_dm->cur_ps_tdma == 3) { + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } else if (coex_dm->cur_ps_tdma == 2) { + ps21a_tdma(btcoexist, + NORMAL_EXEC, true, 3); + coex_dm->ps_tdma_du_adj_type = 3; + } else if (coex_dm->cur_ps_tdma == 12) { + ps21a_tdma(btcoexist, NORMAL_EXEC, + true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } else if (coex_dm->cur_ps_tdma == 11) { + ps21a_tdma(btcoexist, + NORMAL_EXEC, true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } else if (coex_dm->cur_ps_tdma == 10) { + ps21a_tdma(btcoexist, + NORMAL_EXEC, true, 11); + coex_dm->ps_tdma_du_adj_type = 11; + } + } + } + } + } + + /* if current PsTdma not match with the recorded one + * (when scan, dhcp...), + * then we have to adjust it back to the previous record one. */ + if (coex_dm->cur_ps_tdma != coex_dm->ps_tdma_du_adj_type) { + bool scan = false, link = false, roam = false; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], PsTdma type dismatch!!!, cur_ps_tdma =%d, recordPsTdma =%d\n", + coex_dm->cur_ps_tdma, coex_dm->ps_tdma_du_adj_type); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam); + + if (!scan && !link && !roam) + ps21a_tdma(btcoexist, NORMAL_EXEC, true, + coex_dm->ps_tdma_du_adj_type); + else + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, + "[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n"); + } + + /* when tdma_duration_adjust() is called, fw dac swing is + * included in the function. */ + halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 0x6); +} + +/* SCO only or SCO+PAN(HS) */ +static void halbtc8821a2ant_action_sco(struct btc_coexist *btcoexist) +{ + u8 wifi_rssi_state, bt_rssi_state; + u32 wifi_bw; + + wifi_rssi_state = wifi21a_rssi_state(btcoexist, 0, 2, 15, 0); + bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2, 35, 0); + + halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 4); + + if (halbtc8821a2ant_need_to_dec_bt_pwr(btcoexist)) + halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true); + else + halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + + if (BTC_WIFI_BW_LEGACY == wifi_bw) /* for SCO quality at 11b/g mode */ + halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x5a5a5a5a, + 0x5a5a5a5a, 0xffff, 0x3); + else /* for SCO quality & wifi performance balance at 11n mode */ + halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x5aea5aea, + 0x5aea5aea, 0xffff, 0x3); + + if (BTC_WIFI_BW_HT40 == wifi_bw) { + /* fw mechanism */ + /* ps21a_tdma(btcoexist, NORMAL_EXEC, true, 5); */ + + if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || + (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) + ps21a_tdma(btcoexist, NORMAL_EXEC, + false, 0); /* for voice qual */ + else + ps21a_tdma(btcoexist, NORMAL_EXEC, + false, 0); /* for voice qual */ + + /* sw mechanism */ + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + sw_mechanism1(btcoexist, true, true, false, false); + sw_mechanism2(btcoexist, true, false, false, 0x18); + } else { + sw_mechanism1(btcoexist, true, true, false, false); + sw_mechanism2(btcoexist, false, false, false, 0x18); + } + } else { + /* fw mechanism */ + + if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || + (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) + ps21a_tdma(btcoexist, NORMAL_EXEC, + false, 0); /* for voice qual */ + else + ps21a_tdma(btcoexist, NORMAL_EXEC, + false, 0); /* for voice qual */ + + /* sw mechanism */ + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + sw_mechanism1(btcoexist, false, true, false, false); + sw_mechanism2(btcoexist, true, false, false, 0x18); + } else { + sw_mechanism1(btcoexist, false, true, false, false); + sw_mechanism2(btcoexist, false, false, false, 0x18); + } + } +} + +static void halbtc8821a2ant_action_hid(struct btc_coexist *btcoexist) +{ + u8 wifi_rssi_state, bt_rssi_state; + u32 wifi_bw; + + wifi_rssi_state = wifi21a_rssi_state(btcoexist, 0, 2, 15, 0); + bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2, 35, 0); + + halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); + + if (halbtc8821a2ant_need_to_dec_bt_pwr(btcoexist)) + halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true); + else + halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + + if (BTC_WIFI_BW_LEGACY == wifi_bw) /* for HID at 11b/g mode */ + halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, + 0x5a5a5a5a, 0xffff, 0x3); + else /* for HID quality & wifi performance balance at 11n mode */ + halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, + 0x5aea5aea, 0xffff, 0x3); + + if (BTC_WIFI_BW_HT40 == wifi_bw) { + /* fw mechanism */ + if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || + (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 9); + else + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 13); + /* sw mechanism */ + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + sw_mechanism1(btcoexist, true, true, false, false); + sw_mechanism2(btcoexist, true, false, false, 0x18); + } else { + sw_mechanism1(btcoexist, true, true, false, false); + sw_mechanism2(btcoexist, false, false, false, 0x18); + } + } else { + /* fw mechanism */ + if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || + (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 9); + else + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 13); + + /* sw mechanism */ + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + sw_mechanism1(btcoexist, false, true, false, false); + sw_mechanism2(btcoexist, true, false, false, 0x18); + } else { + sw_mechanism1(btcoexist, false, true, false, false); + sw_mechanism2(btcoexist, false, false, false, 0x18); + } + } +} + +/* A2DP only / PAN(EDR) only/ A2DP+PAN(HS) */ +static void halbtc8821a2ant_action_a2dp(struct btc_coexist *btcoexist) +{ + u8 wifi_rssi_state, bt_rssi_state; + u32 wifi_bw; + + wifi_rssi_state = wifi21a_rssi_state(btcoexist, 0, 2, 15, 0); + bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2, 35, 0); + + /* fw dac swing is called in tdma_duration_adjust() */ + /* halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); */ + + if (halbtc8821a2ant_need_to_dec_bt_pwr(btcoexist)) + halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true); + else + halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + + if (BTC_WIFI_BW_HT40 == wifi_bw) { + /* fw mechanism */ + if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || + (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) + tdma_duration_adjust(btcoexist, false, false, 1); + else + tdma_duration_adjust(btcoexist, false, true, 1); + + /* sw mechanism */ + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + sw_mechanism1(btcoexist, true, false, false, false); + sw_mechanism2(btcoexist, true, false, false, 0x18); + } else { + sw_mechanism1(btcoexist, true, false, false, false); + sw_mechanism2(btcoexist, false, false, false, 0x18); + } + } else { + /* fw mechanism */ + if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || + (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) + tdma_duration_adjust(btcoexist, false, false, 1); + else + tdma_duration_adjust(btcoexist, false, true, 1); + + /* sw mechanism */ + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + sw_mechanism1(btcoexist, false, false, false, false); + sw_mechanism2(btcoexist, true, false, false, 0x18); + } else { + sw_mechanism1(btcoexist, false, false, false, false); + sw_mechanism2(btcoexist, false, false, false, 0x18); + } + } +} + +static void halbtc8821a2ant_action_a2dp_pan_hs(struct btc_coexist *btcoexist) +{ + u8 wifi_rssi_state, bt_rssi_state, bt_info_ext; + u32 wifi_bw; + + bt_info_ext = coex_sta->bt_info_ext; + wifi_rssi_state = wifi21a_rssi_state(btcoexist, 0, 2, 15, 0); + bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2, 35, 0); + + /* fw dac swing is called in tdma_duration_adjust() */ + /* halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); */ + + if (halbtc8821a2ant_need_to_dec_bt_pwr(btcoexist)) + halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true); + else + halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + + if (BTC_WIFI_BW_HT40 == wifi_bw) { + /* fw mechanism */ + if (bt_info_ext & BIT(0)) /* a2dp basic rate */ + tdma_duration_adjust(btcoexist, false, true, 2); + else /* a2dp edr rate */ + tdma_duration_adjust(btcoexist, false, true, 1); + + /* sw mechanism */ + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + sw_mechanism1(btcoexist, true, false, false, false); + sw_mechanism2(btcoexist, true, false, false, 0x18); + } else { + sw_mechanism1(btcoexist, true, false, false, false); + sw_mechanism2(btcoexist, false, false, false, 0x18); + } + } else { + /* fw mechanism */ + if (bt_info_ext & BIT(0)) /* a2dp basic rate */ + tdma_duration_adjust(btcoexist, false, true, 2); + else /* a2dp edr rate */ + tdma_duration_adjust(btcoexist, false, true, 1); + + /* sw mechanism */ + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + sw_mechanism1(btcoexist, false, false, false, false); + sw_mechanism2(btcoexist, true, false, false, 0x18); + } else { + sw_mechanism1(btcoexist, false, false, false, false); + sw_mechanism2(btcoexist, false, false, false, 0x18); + } + } +} + +static void halbtc8821a2ant_action_pan_edr(struct btc_coexist *btcoexist) +{ + u8 wifi_rssi_state, bt_rssi_state; + u32 wifi_bw; + + wifi_rssi_state = wifi21a_rssi_state(btcoexist, 0, 2, 15, 0); + bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2, 35, 0); + + halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); + + if (halbtc8821a2ant_need_to_dec_bt_pwr(btcoexist)) + halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true); + else + halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + + if (BTC_WIFI_BW_LEGACY == wifi_bw) /* for HID at 11b/g mode */ + halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, + 0x5aff5aff, 0xffff, 0x3); + else /* for HID quality & wifi performance balance at 11n mode */ + halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, + 0x5aff5aff, 0xffff, 0x3); + + if (BTC_WIFI_BW_HT40 == wifi_bw) { + /* fw mechanism */ + if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || + (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 1); + else + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 5); + + /* sw mechanism */ + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + sw_mechanism1(btcoexist, true, false, false, false); + sw_mechanism2(btcoexist, true, false, false, 0x18); + } else { + sw_mechanism1(btcoexist, true, false, false, false); + sw_mechanism2(btcoexist, false, false, false, 0x18); + } + } else { + /* fw mechanism */ + if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || + (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 1); + else + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 5); + + /* sw mechanism */ + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + sw_mechanism1(btcoexist, false, false, false, false); + sw_mechanism2(btcoexist, true, false, false, 0x18); + } else { + sw_mechanism1(btcoexist, false, false, false, false); + sw_mechanism2(btcoexist, false, false, false, 0x18); + } + } +} + +/* PAN(HS) only */ +static void halbtc8821a2ant_action_pan_hs(struct btc_coexist *btcoexist) +{ + u8 wifi_rssi_state, bt_rssi_state; + u32 wifi_bw; + + wifi_rssi_state = wifi21a_rssi_state(btcoexist, 0, 2, 15, 0); + bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2, 35, 0); + + halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + + if (BTC_WIFI_BW_HT40 == wifi_bw) { + /* fw mechanism */ + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) + halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, + true); + else + halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, + false); + ps21a_tdma(btcoexist, NORMAL_EXEC, false, 1); + + /* sw mechanism */ + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + sw_mechanism1(btcoexist, true, false, false, false); + sw_mechanism2(btcoexist, true, false, false, 0x18); + } else { + sw_mechanism1(btcoexist, true, false, false, false); + sw_mechanism2(btcoexist, false, false, false, 0x18); + } + } else { + /* fw mechanism */ + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) + halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, + true); + else + halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, + false); + + if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || + (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) + ps21a_tdma(btcoexist, NORMAL_EXEC, false, 1); + else + ps21a_tdma(btcoexist, NORMAL_EXEC, false, 1); + + /* sw mechanism */ + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + sw_mechanism1(btcoexist, false, false, false, false); + sw_mechanism2(btcoexist, true, false, false, 0x18); + } else { + sw_mechanism1(btcoexist, false, false, false, false); + sw_mechanism2(btcoexist, false, false, false, 0x18); + } + } +} + +/* PAN(EDR)+A2DP */ +static void halbtc8821a2ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist) +{ + u8 wifi_rssi_state, bt_rssi_state, bt_info_ext; + u32 wifi_bw; + + bt_info_ext = coex_sta->bt_info_ext; + wifi_rssi_state = wifi21a_rssi_state(btcoexist, 0, 2, 15, 0); + bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2, 35, 0); + + halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); + + if (halbtc8821a2ant_need_to_dec_bt_pwr(btcoexist)) + halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true); + else + halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + + if (BTC_WIFI_BW_LEGACY == wifi_bw) /* for HID at 11b/g mode */ + halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, + 0x5afa5afa, 0xffff, 0x3); + else /* for HID quality & wifi performance balance at 11n mode */ + halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, + 0x5afa5afa, 0xffff, 0x3); + + if (BTC_WIFI_BW_HT40 == wifi_bw) { + /* fw mechanism */ + if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || + (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + if (bt_info_ext & BIT(0)) /* a2dp basic rate */ + tdma_duration_adjust(btcoexist, false, + false, 3); + else /* a2dp edr rate */ + tdma_duration_adjust(btcoexist, false, + false, 3); + } else { + if (bt_info_ext & BIT(0)) /* a2dp basic rate */ + tdma_duration_adjust(btcoexist, false, true, 3); + else /* a2dp edr rate */ + tdma_duration_adjust(btcoexist, false, true, 3); + } + + /* sw mechanism */ + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + sw_mechanism1(btcoexist, true, false, false, false); + sw_mechanism2(btcoexist, true, false, false, 0x18); + } else { + sw_mechanism1(btcoexist, true, false, false, false); + sw_mechanism2(btcoexist, false, false, false, 0x18); + }; + } else { + /* fw mechanism */ + if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || + (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + if (bt_info_ext & BIT(0)) /* a2dp basic rate */ + tdma_duration_adjust(btcoexist, false, + false, 3); + else /* a2dp edr rate */ + tdma_duration_adjust(btcoexist, false, + false, 3); + } else { + if (bt_info_ext & BIT(0)) /* a2dp basic rate */ + tdma_duration_adjust(btcoexist, false, true, 3); + else /* a2dp edr rate */ + tdma_duration_adjust(btcoexist, false, true, 3); + } + + /* sw mechanism */ + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + sw_mechanism1(btcoexist, false, false, false, false); + sw_mechanism2(btcoexist, true, false, false, 0x18); + } else { + sw_mechanism1(btcoexist, false, false, false, false); + sw_mechanism2(btcoexist, false, false, false, 0x18); + } + } +} + +static void halbtc8821a2ant_action_pan_edr_hid(struct btc_coexist *btcoexist) +{ + u8 wifi_rssi_state, bt_rssi_state; + u32 wifi_bw; + + wifi_rssi_state = wifi21a_rssi_state(btcoexist, 0, 2, 15, 0); + bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2, 35, 0); + + halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); + + if (halbtc8821a2ant_need_to_dec_bt_pwr(btcoexist)) + halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true); + else + halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + + if (BTC_WIFI_BW_LEGACY == wifi_bw) /* for HID at 11b/g mode */ + halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, + 0x5a5f5a5f, 0xffff, 0x3); + else /* for HID quality & wifi performance balance at 11n mode */ + halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, + 0x5a5f5a5f, 0xffff, 0x3); + + if (BTC_WIFI_BW_HT40 == wifi_bw) { + halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 3); + /* fw mechanism */ + if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || + (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 10); + else + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 14); + + /* sw mechanism */ + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + sw_mechanism1(btcoexist, true, true, false, false); + sw_mechanism2(btcoexist, true, false, false, 0x18); + } else { + sw_mechanism1(btcoexist, true, true, false, false); + sw_mechanism2(btcoexist, false, false, false, 0x18); + } + } else { + halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); + /* fw mechanism */ + if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || + (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 10); + else + ps21a_tdma(btcoexist, NORMAL_EXEC, true, 14); + + /* sw mechanism */ + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + sw_mechanism1(btcoexist, false, true, false, false); + sw_mechanism2(btcoexist, true, false, false, 0x18); + } else { + sw_mechanism1(btcoexist, false, true, false, false); + sw_mechanism2(btcoexist, false, false, false, 0x18); + } + } +} + +/* HID+A2DP+PAN(EDR) */ +static void action_hid_a2dp_pan_edr(struct btc_coexist *btcoexist) +{ + u8 wifi_rssi_state, bt_rssi_state, bt_info_ext; + u32 wifi_bw; + + bt_info_ext = coex_sta->bt_info_ext; + wifi_rssi_state = wifi21a_rssi_state(btcoexist, 0, 2, 15, 0); + bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2, 35, 0); + + halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); + + if (halbtc8821a2ant_need_to_dec_bt_pwr(btcoexist)) + halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true); + else + halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + + if (BTC_WIFI_BW_LEGACY == wifi_bw) /* for HID at 11b/g mode */ + halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, + 0x5a5a5a5a, 0xffff, 0x3); + else /* for HID quality & wifi performance balance at 11n mode */ + halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, + 0x5a5a5a5a, 0xffff, 0x3); + + if (BTC_WIFI_BW_HT40 == wifi_bw) { + /* fw mechanism */ + if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || + (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + if (bt_info_ext & BIT(0)) { /* a2dp basic rate */ + tdma_duration_adjust(btcoexist, true, true, 3); + } else { + /* a2dp edr rate */ + tdma_duration_adjust(btcoexist, true, true, 3); + } + } else { + if (bt_info_ext & BIT(0)) /* a2dp basic rate */ + tdma_duration_adjust(btcoexist, true, true, 3); + else /* a2dp edr rate */ + tdma_duration_adjust(btcoexist, true, true, 3); + } + + /* sw mechanism */ + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + sw_mechanism1(btcoexist, true, true, false, false); + sw_mechanism2(btcoexist, true, false, false, 0x18); + } else { + sw_mechanism1(btcoexist, true, true, false, false); + sw_mechanism2(btcoexist, false, false, false, 0x18); + } + } else { + /* fw mechanism */ + if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || + (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + if (bt_info_ext & BIT(0)) /* a2dp basic rate */ + tdma_duration_adjust(btcoexist, true, false, 3); + else /* a2dp edr rate */ + tdma_duration_adjust(btcoexist, true, false, 3); + } else { + if (bt_info_ext & BIT(0)) { + /* a2dp basic rate */ + tdma_duration_adjust(btcoexist, true, true, 3); + } else /* a2dp edr rate */ { + tdma_duration_adjust(btcoexist, true, true, 3); + } + } + + /* sw mechanism */ + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + sw_mechanism1(btcoexist, false, true, false, false); + sw_mechanism2(btcoexist, true, false, false, 0x18); + } else { + sw_mechanism1(btcoexist, false, true, false, false); + sw_mechanism2(btcoexist, false, false, false, 0x18); + } + } +} + +static void halbtc8821a2ant_action_hid_a2dp(struct btc_coexist *btcoexist) +{ + u8 wifi_rssi_state, bt_rssi_state, bt_info_ext; + u32 wifi_bw; + + bt_info_ext = coex_sta->bt_info_ext; + wifi_rssi_state = wifi21a_rssi_state(btcoexist, 0, 2, 15, 0); + bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2, 35, 0); + + if (halbtc8821a2ant_need_to_dec_bt_pwr(btcoexist)) + halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true); + else + halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + + if (BTC_WIFI_BW_LEGACY == wifi_bw) /* for HID at 11b/g mode */ + halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, + 0x5f5b5f5b, 0xffffff, 0x3); + else /* for HID quality & wifi performance balance at 11n mode */ + halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, + 0x5f5b5f5b, 0xffffff, 0x3); + + if (BTC_WIFI_BW_HT40 == wifi_bw) { + /* fw mechanism */ + if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || + (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + if (bt_info_ext & BIT(0)) /* a2dp basic rate */ + tdma_duration_adjust(btcoexist, true, true, 2); + else /* a2dp edr rate */ + tdma_duration_adjust(btcoexist, true, true, 2); + } else { + if (bt_info_ext & BIT(0)) /* a2dp basic rate */ + tdma_duration_adjust(btcoexist, true, true, 2); + else /* a2dp edr rate */ + tdma_duration_adjust(btcoexist, true, true, 2); + } + + /* sw mechanism */ + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + sw_mechanism1(btcoexist, true, true, false, false); + sw_mechanism2(btcoexist, true, false, false, 0x18); + } else { + sw_mechanism1(btcoexist, true, true, false, false); + sw_mechanism2(btcoexist, false, false, false, 0x18); + } + } else { + /* fw mechanism */ + if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || + (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + if (bt_info_ext & BIT(0)) /* a2dp basic rate */ + tdma_duration_adjust(btcoexist, true, true, 2); + else /* a2dp edr rate */ + tdma_duration_adjust(btcoexist, true, true, 2); + } else { + if (bt_info_ext & BIT(0)) /* a2dp basic rate */ + tdma_duration_adjust(btcoexist, true, true, 2); + else /* a2dp edr rate */ + tdma_duration_adjust(btcoexist, true, true, 2); + } + + /* sw mechanism */ + if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || + (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { + sw_mechanism1(btcoexist, false, true, false, false); + sw_mechanism2(btcoexist, true, false, false, 0x18); + } else { + sw_mechanism1(btcoexist, false, true, false, false); + sw_mechanism2(btcoexist, false, false, false, 0x18); + } + } +} + +static void halbtc8821a2ant_run_coexist_mechanism(struct btc_coexist *btcoexist) +{ + bool wifi_under_5g = false; + u8 algorithm = 0; + + if (btcoexist->manual_control) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Manual control!!!\n"); + return; + } + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g); + + if (wifi_under_5g) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], RunCoexistMechanism(), run 5G coex setting!!<===\n"); + halbtc8821a2ant_coex_under_5g(btcoexist); + return; + } + + algorithm = halbtc8821a2ant_action_algorithm(btcoexist); + if (coex_sta->c2h_bt_inquiry_page && + (BT_8821A_2ANT_COEX_ALGO_PANHS != algorithm)) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], BT is under inquiry/page scan !!\n"); + halbtc8821a2ant_bt_inquiry_page(btcoexist); + return; + } + + coex_dm->cur_algorithm = algorithm; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Algorithm = %d\n", coex_dm->cur_algorithm); + + if (halbtc8821a2ant_is_common_action(btcoexist)) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action 2-Ant common.\n"); + coex_dm->reset_tdma_adjust = true; + } else { + if (coex_dm->cur_algorithm != coex_dm->pre_algorithm) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], pre_algorithm =%d, cur_algorithm =%d\n", + coex_dm->pre_algorithm, + coex_dm->cur_algorithm); + coex_dm->reset_tdma_adjust = true; + } + switch (coex_dm->cur_algorithm) { + case BT_8821A_2ANT_COEX_ALGO_SCO: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action 2-Ant, algorithm = SCO.\n"); + halbtc8821a2ant_action_sco(btcoexist); + break; + case BT_8821A_2ANT_COEX_ALGO_HID: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action 2-Ant, algorithm = HID.\n"); + halbtc8821a2ant_action_hid(btcoexist); + break; + case BT_8821A_2ANT_COEX_ALGO_A2DP: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action 2-Ant, algorithm = A2DP.\n"); + halbtc8821a2ant_action_a2dp(btcoexist); + break; + case BT_8821A_2ANT_COEX_ALGO_A2DP_PANHS: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action 2-Ant, algorithm = A2DP+PAN(HS).\n"); + halbtc8821a2ant_action_a2dp_pan_hs(btcoexist); + break; + case BT_8821A_2ANT_COEX_ALGO_PANEDR: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action 2-Ant, algorithm = PAN(EDR).\n"); + halbtc8821a2ant_action_pan_edr(btcoexist); + break; + case BT_8821A_2ANT_COEX_ALGO_PANHS: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action 2-Ant, algorithm = HS mode.\n"); + halbtc8821a2ant_action_pan_hs(btcoexist); + break; + case BT_8821A_2ANT_COEX_ALGO_PANEDR_A2DP: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action 2-Ant, algorithm = PAN+A2DP.\n"); + halbtc8821a2ant_action_pan_edr_a2dp(btcoexist); + break; + case BT_8821A_2ANT_COEX_ALGO_PANEDR_HID: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action 2-Ant, algorithm = PAN(EDR)+HID.\n"); + halbtc8821a2ant_action_pan_edr_hid(btcoexist); + break; + case BT_8821A_2ANT_COEX_ALGO_HID_A2DP_PANEDR: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action 2-Ant, algorithm = HID+A2DP+PAN.\n"); + action_hid_a2dp_pan_edr(btcoexist); + break; + case BT_8821A_2ANT_COEX_ALGO_HID_A2DP: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action 2-Ant, algorithm = HID+A2DP.\n"); + halbtc8821a2ant_action_hid_a2dp(btcoexist); + break; + default: + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], Action 2-Ant, algorithm = coexist All Off!!\n"); + halbtc8821a2ant_coex_all_off(btcoexist); + break; + } + coex_dm->pre_algorithm = coex_dm->cur_algorithm; + } +} + +/* work around function start with wa_halbtc8821a2ant_ */ +/* extern function start with EXhalbtc8821a2ant_ */ +void ex_halbtc8821a2ant_init_hwconfig(struct btc_coexist *btcoexist) +{ + u8 u1tmp = 0; + + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], 2Ant Init HW Config!!\n"); + + /* backup rf 0x1e value */ + coex_dm->bt_rf0x1e_backup = + btcoexist->btc_get_rf_reg(btcoexist, BTC_RF_A, 0x1e, 0xfffff); + + /* 0x790[5:0] = 0x5 */ + u1tmp = btcoexist->btc_read_1byte(btcoexist, 0x790); + u1tmp &= 0xc0; + u1tmp |= 0x5; + btcoexist->btc_write_1byte(btcoexist, 0x790, u1tmp); + + /* Antenna config */ + halbtc8821a2ant_set_ant_path(btcoexist, BTC_ANT_WIFI_AT_MAIN, + true, false); + + /* PTA parameter */ + halbtc8821a2ant_coex_table(btcoexist, FORCE_EXEC, + 0x55555555, 0x55555555, + 0xffff, 0x3); + + /* Enable counter statistics */ + /* 0x76e[3] = 1, WLAN_Act control by PTA */ + btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc); + btcoexist->btc_write_1byte(btcoexist, 0x778, 0x3); + btcoexist->btc_write_1byte_bitmask(btcoexist, 0x40, 0x20, 0x1); +} + +void ex_halbtc8821a2ant_init_coex_dm(struct btc_coexist *btcoexist) +{ + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], Coex Mechanism Init!!\n"); + + halbtc8821a2ant_init_coex_dm(btcoexist); +} + +void ex_halbtc8821a2ant_display_coex_info(struct btc_coexist *btcoexist) +{ + struct btc_board_info *board_info = &btcoexist->board_info; + struct btc_stack_info *stack_info = &btcoexist->stack_info; + u8 *cli_buf = btcoexist->cli_buf; + u8 u1tmp[4], i, bt_info_ext, ps_tdma_case = 0; + u32 u4tmp[4]; + bool roam = false, scan = false, link = false, wifi_under_5g = false; + bool bt_hs_on = false, wifi_busy = false; + long wifi_rssi = 0, bt_hs_rssi = 0; + u32 wifi_bw, wifi_traffic_dir; + u8 wifi_dot_11_chnl, wifi_hs_chnl; + u32 fw_ver = 0, bt_patch_ver = 0; + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\n ============[BT Coexist info] ============"); + CL_PRINTF(cli_buf); + + if (!board_info->bt_exist) { + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n BT not exists !!!"); + CL_PRINTF(cli_buf); + return; + } + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %d/ %d ", + "Ant PG number/ Ant mechanism: ", + board_info->pg_ant_num, board_info->btdm_ant_num); + CL_PRINTF(cli_buf); + + if (btcoexist->manual_control) { + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s", + "[Action Manual control]!!"); + CL_PRINTF(cli_buf); + } + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %s / %d", + "BT stack/ hci ext ver", + ((stack_info->profile_notified) ? "Yes" : "No"), + stack_info->hci_version); + CL_PRINTF(cli_buf); + + btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER, &bt_patch_ver); + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %d_%d/ 0x%x/ 0x%x(%d)", + "CoexVer/ FwVer/ PatchVer", + glcoex_ver_date_8821a_2ant, glcoex_ver_8821a_2ant, + fw_ver, bt_patch_ver, bt_patch_ver); + CL_PRINTF(cli_buf); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); + btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_DOT11_CHNL, + &wifi_dot_11_chnl); + btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifi_hs_chnl); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %d / %d(%d)", + "Dot11 channel / HsMode(HsChnl)", + wifi_dot_11_chnl, bt_hs_on, wifi_hs_chnl); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\n %-35s = %02x %02x %02x ", "H2C Wifi inform bt chnl Info", + coex_dm->wifi_chnl_info[0], coex_dm->wifi_chnl_info[1], + coex_dm->wifi_chnl_info[2]); + CL_PRINTF(cli_buf); + + btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi); + btcoexist->btc_get(btcoexist, BTC_GET_S4_HS_RSSI, &bt_hs_rssi); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\n %-35s = %ld/ %ld", "Wifi rssi/ HS rssi", + wifi_rssi, bt_hs_rssi); + CL_PRINTF(cli_buf); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %d/ %d/ %d ", + "Wifi link/ roam/ scan", + link, roam, scan); + CL_PRINTF(cli_buf); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g); + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, + &wifi_traffic_dir); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %s / %s/ %s ", + "Wifi status", + (wifi_under_5g ? "5G" : "2.4G"), + ((BTC_WIFI_BW_LEGACY == wifi_bw) ? "Legacy" : + (((BTC_WIFI_BW_HT40 == wifi_bw) ? "HT40" : "HT20"))), + ((!wifi_busy) ? "idle" : + ((BTC_WIFI_TRAFFIC_TX == wifi_traffic_dir) ? "uplink" : + "downlink"))); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = [%s/ %d/ %d] ", + "BT [status/ rssi/ retryCnt]", + ((coex_sta->c2h_bt_inquiry_page) ? ("inquiry/page scan") : + ((BT_8821A_2ANT_BT_STATUS_IDLE == coex_dm->bt_status) ? + "idle" : ((BT_8821A_2ANT_BT_STATUS_CONNECTED_IDLE == + coex_dm->bt_status) ? "connected-idle" : "busy"))), + coex_sta->bt_rssi, coex_sta->bt_retry_cnt); + CL_PRINTF(cli_buf); + + if (stack_info->profile_notified) { + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", + stack_info->sco_exist, stack_info->hid_exist, + stack_info->pan_exist, stack_info->a2dp_exist); + CL_PRINTF(cli_buf); + + btcoexist->btc_disp_dbg_msg(btcoexist, + BTC_DBG_DISP_BT_LINK_INFO); + } + + bt_info_ext = coex_sta->bt_info_ext; + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %s", + "BT Info A2DP rate", + (bt_info_ext & BIT(0)) ? "Basic rate" : "EDR rate"); + CL_PRINTF(cli_buf); + + for (i = 0; i < BT_INFO_SRC_8821A_2ANT_MAX; i++) { + if (coex_sta->bt_info_c2h_cnt[i]) { + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", + glbt_info_src_8821a_2ant[i], + coex_sta->bt_info_c2h[i][0], + coex_sta->bt_info_c2h[i][1], + coex_sta->bt_info_c2h[i][2], + coex_sta->bt_info_c2h[i][3], + coex_sta->bt_info_c2h[i][4], + coex_sta->bt_info_c2h[i][5], + coex_sta->bt_info_c2h[i][6], + coex_sta->bt_info_c2h_cnt[i]); + CL_PRINTF(cli_buf); + } + } + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %s/%s", + "PS state, IPS/LPS", + ((coex_sta->under_ips ? "IPS ON" : "IPS OFF")), + ((coex_sta->under_lps ? "LPS ON" : "LPS OFF"))); + CL_PRINTF(cli_buf); + btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_FW_PWR_MODE_CMD); + + /* Sw mechanism */ + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s", + "============[Sw mechanism] ============"); + CL_PRINTF(cli_buf); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %d/ %d/ %d/ %d ", + "SM1[ShRf/ LpRA/ LimDig/ btLna]", + coex_dm->cur_rf_rx_lpf_shrink, coex_dm->cur_low_penalty_ra, + coex_dm->limited_dig, coex_dm->cur_bt_lna_constrain); + CL_PRINTF(cli_buf); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %d/ %d/ %d(0x%x) ", + "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", + coex_dm->cur_agc_table_en, coex_dm->cur_adc_back_off, + coex_dm->cur_dac_swing_on, coex_dm->cur_dac_swing_lvl); + CL_PRINTF(cli_buf); + + /* Fw mechanism */ + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s", + "============[Fw mechanism] ============"); + CL_PRINTF(cli_buf); + + if (!btcoexist->manual_control) { + ps_tdma_case = coex_dm->cur_ps_tdma; + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\n %-35s = %02x %02x %02x %02x %02x case-%d", + "PS TDMA", + coex_dm->ps_tdma_para[0], coex_dm->ps_tdma_para[1], + coex_dm->ps_tdma_para[2], coex_dm->ps_tdma_para[3], + coex_dm->ps_tdma_para[4], ps_tdma_case); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %d/ %d ", + "DecBtPwr/ IgnWlanAct", + coex_dm->cur_dec_bt_pwr, + coex_dm->cur_ignore_wlan_act); + CL_PRINTF(cli_buf); + } + + /* Hw setting */ + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\n %-35s", "============[Hw setting] ============"); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = 0x%x", + "RF-A, 0x1e initVal", + coex_dm->bt_rf0x1e_backup); + CL_PRINTF(cli_buf); + + u1tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x778); + u1tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0x6cc); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = 0x%x/ 0x%x ", + "0x778 (W_Act)/ 0x6cc (CoTab Sel)", + u1tmp[0], u1tmp[1]); + CL_PRINTF(cli_buf); + + u1tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x8db); + u1tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0xc5b); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = 0x%x/ 0x%x", + "0x8db(ADC)/0xc5b[29:25](DAC)", + ((u1tmp[0]&0x60)>>5), ((u1tmp[1]&0x3e)>>1)); + CL_PRINTF(cli_buf); + + u4tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xcb4); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = 0x%x/ 0x%x", + "0xcb4[7:0](ctrl)/ 0xcb4[29:28](val)", + u4tmp[0]&0xff, ((u4tmp[0]&0x30000000)>>28)); + CL_PRINTF(cli_buf); + + u1tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x40); + u4tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x4c); + u4tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x974); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = 0x%x/ 0x%x/ 0x%x", + "0x40/ 0x4c[24:23]/ 0x974", + u1tmp[0], ((u4tmp[0]&0x01800000)>>23), u4tmp[1]); + CL_PRINTF(cli_buf); + + u4tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x550); + u1tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x522); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = 0x%x/ 0x%x", + "0x550(bcn ctrl)/0x522", + u4tmp[0], u1tmp[0]); + CL_PRINTF(cli_buf); + + u4tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xc50); + u1tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0xa0a); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = 0x%x/ 0x%x", + "0xc50(DIG)/0xa0a(CCK-TH)", + u4tmp[0], u1tmp[0]); + CL_PRINTF(cli_buf); + + u4tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xf48); + u1tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0xa5b); + u1tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0xa5c); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, + "\n %-35s = 0x%x/ 0x%x", "OFDM-FA/ CCK-FA", + u4tmp[0], (u1tmp[0]<<8) + u1tmp[1]); + CL_PRINTF(cli_buf); + + u4tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x6c0); + u4tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x6c4); + u4tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0x6c8); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = 0x%x/ 0x%x/ 0x%x", + "0x6c0/0x6c4/0x6c8", + u4tmp[0], u4tmp[1], u4tmp[2]); + CL_PRINTF(cli_buf); + + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %d/ %d", + "0x770 (hi-pri Rx/Tx)", + coex_sta->high_priority_rx, coex_sta->high_priority_tx); + CL_PRINTF(cli_buf); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %d/ %d", + "0x774(low-pri Rx/Tx)", + coex_sta->low_priority_rx, coex_sta->low_priority_tx); + CL_PRINTF(cli_buf); + + /* Tx mgnt queue hang or not, 0x41b should = 0xf, ex: 0xd ==>hang */ + u1tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x41b); + CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = 0x%x", + "0x41b (mgntQ hang chk == 0xf)", + u1tmp[0]); + CL_PRINTF(cli_buf); + + btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_COEX_STATISTICS); +} + +void ex_halbtc8821a2ant_ips_notify(struct btc_coexist *btcoexist, u8 type) +{ + if (BTC_IPS_ENTER == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], IPS ENTER notify\n"); + coex_sta->under_ips = true; + halbtc8821a2ant_coex_all_off(btcoexist); + } else if (BTC_IPS_LEAVE == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], IPS LEAVE notify\n"); + coex_sta->under_ips = false; + } +} + +void ex_halbtc8821a2ant_lps_notify(struct btc_coexist *btcoexist, u8 type) +{ + if (BTC_LPS_ENABLE == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], LPS ENABLE notify\n"); + coex_sta->under_lps = true; + } else if (BTC_LPS_DISABLE == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], LPS DISABLE notify\n"); + coex_sta->under_lps = false; + } +} + +void ex_halbtc8821a2ant_scan_notify(struct btc_coexist *btcoexist, u8 type) +{ + if (BTC_SCAN_START == type) + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], SCAN START notify\n"); + else if (BTC_SCAN_FINISH == type) + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], SCAN FINISH notify\n"); +} + +void ex_halbtc8821a2ant_connect_notify(struct btc_coexist *btcoexist, u8 type) +{ + if (BTC_ASSOCIATE_START == type) + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], CONNECT START notify\n"); + else if (BTC_ASSOCIATE_FINISH == type) + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], CONNECT FINISH notify\n"); +} + +void ex_halbtc8821a2ant_media_status_notify(struct btc_coexist *btcoexist, + u8 type) +{ + u8 h2c_parameter[3] = {0}; + u32 wifi_bw; + u8 wifi_central_chnl; + + if (BTC_MEDIA_CONNECT == type) + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], MEDIA connect notify\n"); + else + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], MEDIA disconnect notify\n"); + + /* only 2.4G we need to inform bt the chnl mask */ + btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, + &wifi_central_chnl); + if ((BTC_MEDIA_CONNECT == type) && + (wifi_central_chnl <= 14)) { + h2c_parameter[0] = 0x1; + h2c_parameter[1] = wifi_central_chnl; + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); + if (BTC_WIFI_BW_HT40 == wifi_bw) + h2c_parameter[2] = 0x30; + else + h2c_parameter[2] = 0x20; + } + + coex_dm->wifi_chnl_info[0] = h2c_parameter[0]; + coex_dm->wifi_chnl_info[1] = h2c_parameter[1]; + coex_dm->wifi_chnl_info[2] = h2c_parameter[2]; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, + "[BTCoex], FW write 0x66 = 0x%x\n", + h2c_parameter[0] << 16 | + h2c_parameter[1] << 8 | h2c_parameter[2]); + + btcoexist->btc_fill_h2c(btcoexist, 0x66, 3, h2c_parameter); +} + +void ex_halbtc8821a2ant_special_packet_notify(struct btc_coexist *btcoexist, + u8 type) +{ + if (type == BTC_PACKET_DHCP) + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], DHCP Packet notify\n"); +} + +void ex_halbtc8821a2ant_bt_info_notify(struct btc_coexist *btcoexist, + u8 *tmp_buf, u8 length) +{ + u8 bt_info = 0; + u8 i, rsp_source = 0; + static u32 set_bt_lna_cnt, set_bt_psd_mode; + bool bt_busy = false, limited_dig = false; + bool wifi_connected = false, bt_hs_on = false; + + coex_sta->c2h_bt_info_req_sent = false; + rsp_source = tmp_buf[0]&0xf; + if (rsp_source >= BT_INFO_SRC_8821A_2ANT_MAX) + rsp_source = BT_INFO_SRC_8821A_2ANT_WIFI_FW; + coex_sta->bt_info_c2h_cnt[rsp_source]++; + + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, + "[BTCoex], Bt info[%d], length =%d, hex data =[", + rsp_source, length); + for (i = 0; i < length; i++) { + coex_sta->bt_info_c2h[rsp_source][i] = tmp_buf[i]; + if (i == 1) + bt_info = tmp_buf[i]; + if (i == length-1) + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, "0x%02x]\n", + tmp_buf[i]); + else + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, "0x%02x, ", + tmp_buf[i]); + } + + if (BT_INFO_SRC_8821A_2ANT_WIFI_FW != rsp_source) { + coex_sta->bt_retry_cnt = /* [3:0] */ + coex_sta->bt_info_c2h[rsp_source][2]&0xf; + coex_sta->bt_rssi = + coex_sta->bt_info_c2h[rsp_source][3]*2+10; + coex_sta->bt_info_ext = + coex_sta->bt_info_c2h[rsp_source][4]; + + /* Here we need to resend some wifi info to BT */ + /* because bt is reset and loss of the info. */ + if ((coex_sta->bt_info_ext & BIT(1))) { + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, + &wifi_connected); + if (wifi_connected) + ex_halbtc8821a2ant_media_status_notify(btcoexist, + BTC_MEDIA_CONNECT); + else + ex_halbtc8821a2ant_media_status_notify(btcoexist, + BTC_MEDIA_DISCONNECT); + + set_bt_psd_mode = 0; + } + if (set_bt_psd_mode <= 3) { + /* fix CH-BW mode */ + halbtc8821a2ant_set_bt_psd_mode(btcoexist, + FORCE_EXEC, 0x0); + set_bt_psd_mode++; + } + + if (coex_dm->cur_bt_lna_constrain) { + if (!(coex_sta->bt_info_ext & BIT(2))) { + if (set_bt_lna_cnt <= 3) { + set_bt_lna_constrain(btcoexist, + FORCE_EXEC, true); + set_bt_lna_cnt++; + } + } + } else { + set_bt_lna_cnt = 0; + } + + if ((coex_sta->bt_info_ext & BIT(3))) + halbtc8821a2ant_ignore_wlan_act(btcoexist, + FORCE_EXEC, false); + else + /* BT already NOT ignore Wlan active, do nothing here */ + + if (!(coex_sta->bt_info_ext & BIT(4))) + halbtc8821a2ant_bt_auto_report(btcoexist, + FORCE_EXEC, true); + } + + btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); + /* check BIT(2) first ==> check if bt is under inquiry or page scan */ + if (bt_info & BT_INFO_8821A_2ANT_B_INQ_PAGE) { + coex_sta->c2h_bt_inquiry_page = true; + coex_dm->bt_status = BT_8821A_2ANT_BT_STATUS_NON_IDLE; + } else { + coex_sta->c2h_bt_inquiry_page = false; + if (bt_info == 0x1) { /* connection exists but not busy */ + coex_sta->bt_link_exist = true; + coex_dm->bt_status = + BT_8821A_2ANT_BT_STATUS_CONNECTED_IDLE; + } else if (bt_info & BT_INFO_8821A_2ANT_B_CONNECTION) { + /* connection exists and some link is busy */ + coex_sta->bt_link_exist = true; + if (bt_info & BT_INFO_8821A_2ANT_B_FTP) + coex_sta->pan_exist = true; + else + coex_sta->pan_exist = false; + if (bt_info & BT_INFO_8821A_2ANT_B_A2DP) + coex_sta->a2dp_exist = true; + else + coex_sta->a2dp_exist = false; + if (bt_info & BT_INFO_8821A_2ANT_B_HID) + coex_sta->hid_exist = true; + else + coex_sta->hid_exist = false; + if (bt_info & BT_INFO_8821A_2ANT_B_SCO_ESCO) + coex_sta->sco_exist = true; + else + coex_sta->sco_exist = false; + coex_dm->bt_status = BT_8821A_2ANT_BT_STATUS_NON_IDLE; + } else { + coex_sta->bt_link_exist = false; + coex_sta->pan_exist = false; + coex_sta->a2dp_exist = false; + coex_sta->hid_exist = false; + coex_sta->sco_exist = false; + coex_dm->bt_status = BT_8821A_2ANT_BT_STATUS_IDLE; + } + + if (bt_hs_on) + coex_dm->bt_status = BT_8821A_2ANT_BT_STATUS_NON_IDLE; + } + + if (BT_8821A_2ANT_BT_STATUS_NON_IDLE == coex_dm->bt_status) + bt_busy = true; + else + bt_busy = false; + btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bt_busy); + + if (BT_8821A_2ANT_BT_STATUS_IDLE != coex_dm->bt_status) + limited_dig = true; + else + limited_dig = false; + coex_dm->limited_dig = limited_dig; + btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_LIMITED_DIG, &limited_dig); + + halbtc8821a2ant_run_coexist_mechanism(btcoexist); +} + +void ex_halbtc8821a2ant_halt_notify(struct btc_coexist *btcoexist) +{ + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, "[BTCoex], Halt notify\n"); + + halbtc8821a2ant_ignore_wlan_act(btcoexist, FORCE_EXEC, true); + ex_halbtc8821a2ant_media_status_notify(btcoexist, BTC_MEDIA_DISCONNECT); +} + +void ex_halbtc8821a2ant_periodical(struct btc_coexist *btcoexist) +{ + static u8 dis_ver_info_cnt; + u32 fw_ver = 0, bt_patch_ver = 0; + struct btc_board_info *board_info = &btcoexist->board_info; + struct btc_stack_info *stack_info = &btcoexist->stack_info; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "[BTCoex], ========================== Periodical ===========================\n"); + + if (dis_ver_info_cnt <= 5) { + dis_ver_info_cnt += 1; + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], ****************************************************************\n"); + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n", + board_info->pg_ant_num, board_info->btdm_ant_num, + board_info->btdm_ant_pos); + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], BT stack/ hci ext ver = %s / %d\n", + ((stack_info->profile_notified) ? "Yes" : "No"), + stack_info->hci_version); + btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER, + &bt_patch_ver); + btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver); + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n", + glcoex_ver_date_8821a_2ant, + glcoex_ver_8821a_2ant, + fw_ver, bt_patch_ver, bt_patch_ver); + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, + "[BTCoex], ****************************************************************\n"); + } + + halbtc8821a2ant_query_bt_info(btcoexist); + halbtc8821a2ant_monitor_bt_ctr(btcoexist); + monitor_bt_enable_disable(btcoexist); +} diff --git a/drivers/staging/rtl8192ee/btcoexist/halbtc8821a2ant.h b/drivers/staging/rtl8192ee/btcoexist/halbtc8821a2ant.h new file mode 100644 index 000000000000..745506b48d60 --- /dev/null +++ b/drivers/staging/rtl8192ee/btcoexist/halbtc8821a2ant.h @@ -0,0 +1,179 @@ +/* */ +/* The following is for 8821A 2Ant BT Co-exist definition */ +/* */ +#define BT_INFO_8821A_2ANT_B_FTP BIT(7) +#define BT_INFO_8821A_2ANT_B_A2DP BIT(6) +#define BT_INFO_8821A_2ANT_B_HID BIT(5) +#define BT_INFO_8821A_2ANT_B_SCO_BUSY BIT(4) +#define BT_INFO_8821A_2ANT_B_ACL_BUSY BIT(3) +#define BT_INFO_8821A_2ANT_B_INQ_PAGE BIT(2) +#define BT_INFO_8821A_2ANT_B_SCO_ESCO BIT(1) +#define BT_INFO_8821A_2ANT_B_CONNECTION BIT(0) + +#define BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT 2 + +enum BT_INFO_SRC_8821A_2ANT { + BT_INFO_SRC_8821A_2ANT_WIFI_FW = 0x0, + BT_INFO_SRC_8821A_2ANT_BT_RSP = 0x1, + BT_INFO_SRC_8821A_2ANT_BT_ACTIVE_SEND = 0x2, + BT_INFO_SRC_8821A_2ANT_MAX +}; + +enum BT_8821A_2ANT_BT_STATUS { + BT_8821A_2ANT_BT_STATUS_IDLE = 0x0, + BT_8821A_2ANT_BT_STATUS_CONNECTED_IDLE = 0x1, + BT_8821A_2ANT_BT_STATUS_NON_IDLE = 0x2, + BT_8821A_2ANT_BT_STATUS_MAX +}; + +enum BT_8821A_2ANT_COEX_ALGO { + BT_8821A_2ANT_COEX_ALGO_UNDEFINED = 0x0, + BT_8821A_2ANT_COEX_ALGO_SCO = 0x1, + BT_8821A_2ANT_COEX_ALGO_HID = 0x2, + BT_8821A_2ANT_COEX_ALGO_A2DP = 0x3, + BT_8821A_2ANT_COEX_ALGO_A2DP_PANHS = 0x4, + BT_8821A_2ANT_COEX_ALGO_PANEDR = 0x5, + BT_8821A_2ANT_COEX_ALGO_PANHS = 0x6, + BT_8821A_2ANT_COEX_ALGO_PANEDR_A2DP = 0x7, + BT_8821A_2ANT_COEX_ALGO_PANEDR_HID = 0x8, + BT_8821A_2ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9, + BT_8821A_2ANT_COEX_ALGO_HID_A2DP = 0xa, + BT_8821A_2ANT_COEX_ALGO_MAX = 0xb, +}; + +struct coex_dm_8821a_2ant { + /* fw mechanism */ + bool pre_dec_bt_pwr; + bool cur_dec_bt_pwr; + bool pre_bt_lna_constrain; + bool cur_bt_lna_constrain; + u8 pre_bt_psd_mode; + u8 cur_bt_psd_mode; + u8 pre_fw_dac_swing_lvl; + u8 cur_fw_dac_swing_lvl; + bool cur_ignore_wlan_act; + bool pre_ignore_wlan_act; + u8 pre_ps_tdma; + u8 cur_ps_tdma; + u8 ps_tdma_para[5]; + u8 ps_tdma_du_adj_type; + bool reset_tdma_adjust; + bool pre_ps_tdma_on; + bool cur_ps_tdma_on; + bool pre_bt_auto_report; + bool cur_bt_auto_report; + + /* sw mechanism */ + bool pre_rf_rx_lpf_shrink; + bool cur_rf_rx_lpf_shrink; + u32 bt_rf0x1e_backup; + bool pre_low_penalty_ra; + bool cur_low_penalty_ra; + bool pre_dac_swing_on; + u32 pre_dac_swing_lvl; + bool cur_dac_swing_on; + u32 cur_dac_swing_lvl; + bool pre_adc_back_off; + bool cur_adc_back_off; + bool pre_agc_table_en; + bool cur_agc_table_en; + u32 pre_val0x6c0; + u32 cur_val0x6c0; + u32 pre_val0x6c4; + u32 cur_val0x6c4; + u32 pre_val0x6c8; + u32 cur_val0x6c8; + u8 pre_val0x6cc; + u8 cur_val0x6cc; + bool limited_dig; + + /* algorithm related */ + u8 pre_algorithm; + u8 cur_algorithm; + u8 bt_status; + u8 wifi_chnl_info[3]; +}; + +struct coex_sta_8821a_2ant { + bool bt_link_exist; + bool sco_exist; + bool a2dp_exist; + bool hid_exist; + bool pan_exist; + + bool under_lps; + bool under_ips; + u32 high_priority_tx; + u32 high_priority_rx; + u32 low_priority_tx; + u32 low_priority_rx; + u8 bt_rssi; + u8 pre_bt_rssi_state; + u8 pre_wifi_rssi_state[4]; + bool c2h_bt_info_req_sent; + u8 bt_info_c2h[BT_INFO_SRC_8821A_2ANT_MAX][10]; + u32 bt_info_c2h_cnt[BT_INFO_SRC_8821A_2ANT_MAX]; + bool c2h_bt_inquiry_page; + u8 bt_retry_cnt; + u8 bt_info_ext; +}; + +/* */ +/* The following is interface which will notify coex module. */ +/* */ +void +ex_halbtc8821a2ant_init_hwconfig( + struct btc_coexist *btcoexist + ); +void +ex_halbtc8821a2ant_init_coex_dm( + struct btc_coexist *btcoexist + ); +void +ex_halbtc8821a2ant_ips_notify( + struct btc_coexist *btcoexist, + u8 type + ); +void +ex_halbtc8821a2ant_lps_notify( + struct btc_coexist *btcoexist, + u8 type + ); +void +ex_halbtc8821a2ant_scan_notify( + struct btc_coexist *btcoexist, + u8 type + ); +void +ex_halbtc8821a2ant_connect_notify( + struct btc_coexist *btcoexist, + u8 type + ); +void +ex_halbtc8821a2ant_media_status_notify( + struct btc_coexist *btcoexist, + u8 type + ); +void +ex_halbtc8821a2ant_special_packet_notify( + struct btc_coexist *btcoexist, + u8 type + ); +void +ex_halbtc8821a2ant_bt_info_notify( + struct btc_coexist *btcoexist, + u8 *tmp_buf, + u8 length + ); +void +ex_halbtc8821a2ant_halt_notify( + struct btc_coexist *btcoexist + ); +void +ex_halbtc8821a2ant_periodical( + struct btc_coexist *btcoexist + ); +void +ex_halbtc8821a2ant_display_coex_info( + struct btc_coexist *btcoexist + ); diff --git a/drivers/staging/rtl8192ee/btcoexist/halbtcoutsrc.c b/drivers/staging/rtl8192ee/btcoexist/halbtcoutsrc.c new file mode 100644 index 000000000000..9757f138a37f --- /dev/null +++ b/drivers/staging/rtl8192ee/btcoexist/halbtcoutsrc.c @@ -0,0 +1,1307 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2013 Realtek 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. + * + * + ******************************************************************************/ + +#include "halbt_precomp.h" + +/*********************************************** + * Global variables + ***********************************************/ +static const char *const bt_profile_string[] = { + "NONE", + "A2DP", + "PAN", + "HID", + "SCO", +}; + +static const char *const bt_spec_string[] = { + "1.0b", + "1.1", + "1.2", + "2.0+EDR", + "2.1+EDR", + "3.0+HS", + "4.0", +}; + +static const char *const bt_link_role_string[] = { + "Master", + "Slave", +}; + +static const char *const h2c_state_string[] = { + "successful", + "h2c busy", + "rf off", + "fw not read", +}; + +static const char *const io_state_string[] = { + "IO_STATUS_SUCCESS", + "IO_STATUS_FAIL_CANNOT_IO", + "IO_STATUS_FAIL_RF_OFF", + "IO_STATUS_FAIL_FW_READ_CLEAR_TIMEOUT", + "IO_STATUS_FAIL_WAIT_IO_EVENT_TIMEOUT", + "IO_STATUS_INVALID_LEN", + "IO_STATUS_IO_IDLE_QUEUE_EMPTY", + "IO_STATUS_IO_INSERT_WAIT_QUEUE_FAIL", + "IO_STATUS_UNKNOWN_FAIL", + "IO_STATUS_WRONG_LEVEL", + "IO_STATUS_H2C_STOPPED", +}; + +struct btc_coexist gl92e_bt_coexist; + +u32 btc_92edbg_type[BTC_MSG_MAX]; +static u8 btc_dbg_buf[100]; + +/*************************************************** + * Debug related function + ***************************************************/ +static bool is_any_client_connect_to_ap(struct btc_coexist *btcoexist) +{ + struct rtl_priv *rtlpriv = btcoexist->adapter; + struct rtl_mac *mac = rtl_mac(rtlpriv); + struct rtl_sta_info *drv_priv; + u8 cnt = 0; + + if (mac->opmode == NL80211_IFTYPE_ADHOC || + mac->opmode == NL80211_IFTYPE_MESH_POINT || + mac->opmode == NL80211_IFTYPE_AP) { + spin_lock_bh(&rtlpriv->locks.entry_list_lock); + list_for_each_entry(drv_priv, &rtlpriv->entry_list, list) { + cnt++; + } + spin_unlock_bh(&rtlpriv->locks.entry_list_lock); + } + if (cnt > 0) + return true; + else + return false; +} + +static bool halbtc_is_bt_coexist_available(struct btc_coexist *btcoexist) +{ + if (!btcoexist->binded || NULL == btcoexist->adapter) + return false; + + return true; +} + +static bool halbtc_is_wifi_busy(struct rtl_priv *rtlpriv) +{ + if (rtlpriv->link_info.b_busytraffic) + return true; + else + return false; +} + + +static void halbtc_dbg_init(void) +{ + u8 i; + + for (i = 0; i < BTC_MSG_MAX; i++) + btc_92edbg_type[i] = 0; + + btc_92edbg_type[BTC_MSG_INTERFACE] = 0; + + btc_92edbg_type[BTC_MSG_ALGORITHM] = 0; +} + +static bool halbtc_is_bt40(struct rtl_priv *adapter) +{ + struct rtl_priv *rtlpriv = adapter; + struct rtl_phy *rtlphy = &(rtlpriv->phy); + bool is_ht40 = true; + enum ht_channel_width bw = rtlphy->current_chan_bw; + + + if (bw == HT_CHANNEL_WIDTH_20) + is_ht40 = false; + else if (bw == HT_CHANNEL_WIDTH_20_40) + is_ht40 = true; + + return is_ht40; +} + +static bool halbtc_legacy(struct rtl_priv *adapter) +{ + struct rtl_priv *rtlpriv = adapter; + struct rtl_mac *mac = rtl_mac(rtlpriv); + + bool is_legacy = false; + + if ((mac->mode == WIRELESS_MODE_B) || (mac->mode == WIRELESS_MODE_G)) + is_legacy = true; + + return is_legacy; +} + +bool halbtc92e_is_wifi_uplink(struct rtl_priv *adapter) +{ + struct rtl_priv *rtlpriv = adapter; + + if (rtlpriv->link_info.b_tx_busy_traffic) + return true; + else + return false; +} + +static u32 halbtc_get_wifi_bw(struct btc_coexist *btcoexist) +{ + struct rtl_priv *rtlpriv = + (struct rtl_priv *)btcoexist->adapter; + u32 wifi_bw = BTC_WIFI_BW_HT20; + + if (halbtc_is_bt40(rtlpriv)) { + wifi_bw = BTC_WIFI_BW_HT40; + } else { + if (halbtc_legacy(rtlpriv)) + wifi_bw = BTC_WIFI_BW_LEGACY; + else + wifi_bw = BTC_WIFI_BW_HT20; + } + return wifi_bw; +} + +static u8 halbtc_get_wifi_central_chnl(struct btc_coexist *btcoexist) +{ + struct rtl_priv *rtlpriv = btcoexist->adapter; + struct rtl_phy *rtlphy = &(rtlpriv->phy); + u8 chnl = 1; + + + if (rtlphy->current_channel != 0) + chnl = rtlphy->current_channel; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, + "halbtc_get_wifi_central_chnl:%d\n", chnl); + return chnl; +} + +static void halbtc_leave_lps(struct btc_coexist *btcoexist) +{ + struct rtl_priv *rtlpriv; + struct rtl_ps_ctl *ppsc; + bool ap_enable = false; + + rtlpriv = btcoexist->adapter; + ppsc = rtl_psc(rtlpriv); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, + &ap_enable); + + if (ap_enable) { + pr_debug("halbtc_leave_lps()<--dont leave lps under AP mode\n"); + return; + } + + btcoexist->bt_info.bt_ctrl_lps = true; + btcoexist->bt_info.bt_lps_on = false; + rtl92e_lps_leave(rtlpriv->mac80211.hw); +} + +static void halbtc_enter_lps(struct btc_coexist *btcoexist) +{ + struct rtl_priv *rtlpriv; + struct rtl_ps_ctl *ppsc; + bool ap_enable = false; + + rtlpriv = btcoexist->adapter; + ppsc = rtl_psc(rtlpriv); + + btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, + &ap_enable); + + if (ap_enable) { + pr_debug("halbtc_enter_lps()<--dont enter lps under AP mode\n"); + return; + } + + btcoexist->bt_info.bt_ctrl_lps = true; + btcoexist->bt_info.bt_lps_on = false; + rtl92e_lps_enter(rtlpriv->mac80211.hw); +} + +static void halbtc_normal_lps(struct btc_coexist *btcoexist) +{ + if (btcoexist->bt_info.bt_ctrl_lps) { + btcoexist->bt_info.bt_lps_on = false; + btcoexist->bt_info.bt_ctrl_lps = false; + } +} + +static void halbtc_aggregation_check(struct btc_coexist *btcoexist) +{ +} + +static u32 halbtcoutsrc_get_wifi_link_status(struct btc_coexist *btcoexist) +{ + /*------------------------------------ + * return value: + * [31:16] => connected port number + * [15:0] => port connected bit define + *------------------------------------ + */ + + struct rtl_priv *rtlpriv = btcoexist->adapter; + struct rtl_mac *mac = rtl_mac(rtlpriv); + u32 ret_val = 0; + u32 port_connected_status = 0, num_of_connected_port = 0; + + if (mac->opmode == NL80211_IFTYPE_STATION && + mac->link_state >= MAC80211_LINKED) { + port_connected_status |= WIFI_STA_CONNECTED; + num_of_connected_port++; + } + /* AP & ADHOC & MESH */ + if (is_any_client_connect_to_ap(btcoexist)) { + port_connected_status |= WIFI_AP_CONNECTED; + num_of_connected_port++; + } + /*if (BT_HsConnectionEstablished(Adapter)) + { + port_connected_status |= WIFI_HS_CONNECTED; + num_of_connected_port++; + }*/ + /* TODO: + * P2P Connected Status */ + + ret_val = (num_of_connected_port << 16) | port_connected_status; + + return ret_val; +} + + +static u32 halbtc_get_bt_patch_version(struct btc_coexist *btcoexist) +{ + return 0; +} + +static s32 halbtc_get_wifi_rssi(struct rtl_priv *adapter) +{ + struct rtl_priv *rtlpriv = adapter; + s32 undecorated_smoothed_pwdb = 0; + + if (rtlpriv->mac80211.link_state >= MAC80211_LINKED) + undecorated_smoothed_pwdb = + rtlpriv->dm.undecorated_smoothed_pwdb; + else /* associated entry pwdb */ + undecorated_smoothed_pwdb = + rtlpriv->dm.undecorated_smoothed_pwdb; + return undecorated_smoothed_pwdb; +} + +static bool halbtc_get(void *void_btcoexist, u8 get_type, void *out_buf) +{ + struct btc_coexist *btcoexist = (struct btc_coexist *)void_btcoexist; + struct rtl_priv *rtlpriv = btcoexist->adapter; + struct rtl_phy *rtlphy = &(rtlpriv->phy); + struct rtl_mac *mac = rtl_mac(rtlpriv); + struct rtl_hal *rtlhal = rtl_hal(rtlpriv); + bool *bool_tmp = (bool *)out_buf; + int *s32_tmp = (int *)out_buf; + u32 *u32_tmp = (u32 *)out_buf; + u8 *u8_tmp = (u8 *)out_buf; + bool tmp = false; + + + if (!halbtc_is_bt_coexist_available(btcoexist)) + return false; + + + switch (get_type) { + case BTC_GET_BL_HS_OPERATION: + *bool_tmp = false; + break; + case BTC_GET_BL_HS_CONNECTING: + *bool_tmp = false; + break; + case BTC_GET_BL_WIFI_CONNECTED: + if (rtlpriv->mac80211.opmode == NL80211_IFTYPE_STATION && + rtlpriv->mac80211.link_state >= MAC80211_LINKED) + tmp = true; + if (is_any_client_connect_to_ap(btcoexist)) + tmp = true; + *bool_tmp = tmp; + break; + case BTC_GET_BL_WIFI_BUSY: + if (halbtc_is_wifi_busy(rtlpriv)) + *bool_tmp = true; + else + *bool_tmp = false; + break; + case BTC_GET_BL_WIFI_SCAN: + if (mac->act_scanning) + *bool_tmp = true; + else + *bool_tmp = false; + break; + case BTC_GET_BL_WIFI_LINK: + if (mac->link_state == MAC80211_LINKING) + *bool_tmp = true; + else + *bool_tmp = false; + break; + case BTC_GET_BL_WIFI_ROAM: /*TODO*/ + *bool_tmp = false; + break; + case BTC_GET_BL_WIFI_4_WAY_PROGRESS: /*TODO*/ + *bool_tmp = false; + break; + case BTC_GET_BL_WIFI_UNDER_5G: + *bool_tmp = false; /*TODO*/ + + case BTC_GET_BL_WIFI_DHCP: /*TODO*/ + break; + case BTC_GET_BL_WIFI_SOFTAP_IDLE: + *bool_tmp = true; + break; + case BTC_GET_BL_WIFI_SOFTAP_LINKING: + *bool_tmp = false; + break; + case BTC_GET_BL_WIFI_IN_EARLY_SUSPEND: + *bool_tmp = false; + break; + case BTC_GET_BL_WIFI_AP_MODE_ENABLE: + *bool_tmp = false; + break; + case BTC_GET_BL_WIFI_ENABLE_ENCRYPTION: + if (NO_ENCRYPTION == rtlpriv->sec.pairwise_enc_algorithm) + *bool_tmp = false; + else + *bool_tmp = true; + break; + case BTC_GET_BL_WIFI_UNDER_B_MODE: + if (WIRELESS_MODE_B == rtlpriv->mac80211.mode) + *bool_tmp = true; + else + *bool_tmp = false; + break; + case BTC_GET_BL_EXT_SWITCH: + *bool_tmp = false; + break; + case BTC_GET_S4_WIFI_RSSI: + *s32_tmp = halbtc_get_wifi_rssi(rtlpriv); + break; + case BTC_GET_S4_HS_RSSI: /*TODO*/ + *s32_tmp = halbtc_get_wifi_rssi(rtlpriv); + break; + case BTC_GET_U4_WIFI_BW: + *u32_tmp = halbtc_get_wifi_bw(btcoexist); + break; + case BTC_GET_U4_WIFI_TRAFFIC_DIRECTION: + if (halbtc92e_is_wifi_uplink(rtlpriv)) + *u32_tmp = BTC_WIFI_TRAFFIC_TX; + else + *u32_tmp = BTC_WIFI_TRAFFIC_RX; + break; + case BTC_GET_U4_WIFI_FW_VER: + *u32_tmp = (rtlhal->fw_version << 16) | rtlhal->fw_subversion; + break; + case BTC_GET_U4_WIFI_LINK_STATUS: + *u32_tmp = halbtcoutsrc_get_wifi_link_status(btcoexist); + break; + case BTC_GET_U4_BT_PATCH_VER: + *u32_tmp = halbtc_get_bt_patch_version(btcoexist); + break; + case BTC_GET_U1_WIFI_DOT11_CHNL: + *u8_tmp = rtlphy->current_channel; + break; + case BTC_GET_U1_WIFI_CENTRAL_CHNL: + *u8_tmp = halbtc_get_wifi_central_chnl(btcoexist); + break; + case BTC_GET_U1_WIFI_HS_CHNL: + *u8_tmp = 1;/* BT_OperateChnl(rtlpriv); */ + break; + case BTC_GET_U1_MAC_PHY_MODE: + *u8_tmp = BTC_MP_UNKNOWN; + break; + case BTC_GET_U1_AP_NUM: + /* driver don't know AP num in Linux, + * So, the return value here is not right */ + *u8_tmp = 1;/* pDefMgntInfo->NumBssDesc4Query; */ + break; + + /************* 1Ant **************/ + case BTC_GET_U1_LPS_MODE: + *u8_tmp = btcoexist->pwr_mode_val[0]; + break; + + default: + break; + } + + return true; +} + +static bool halbtc_set(void *void_btcoexist, u8 set_type, void *in_buf) +{ + struct btc_coexist *btcoexist = (struct btc_coexist *)void_btcoexist; + bool *bool_tmp = (bool *)in_buf; + u8 *u8_tmp = (u8 *)in_buf; + u32 *u32_tmp = (u32 *)in_buf; + + + if (!halbtc_is_bt_coexist_available(btcoexist)) + return false; + + switch (set_type) { + /* set some bool type variables. */ + case BTC_SET_BL_BT_DISABLE: + btcoexist->bt_info.bt_disabled = *bool_tmp; + break; + case BTC_SET_BL_BT_TRAFFIC_BUSY: + btcoexist->bt_info.bt_busy = *bool_tmp; + break; + case BTC_SET_BL_BT_LIMITED_DIG: + btcoexist->bt_info.limited_dig = *bool_tmp; + break; + case BTC_SET_BL_FORCE_TO_ROAM: + btcoexist->bt_info.force_to_roam = *bool_tmp; + break; + case BTC_SET_BL_TO_REJ_AP_AGG_PKT: + btcoexist->bt_info.reject_agg_pkt = *bool_tmp; + break; + case BTC_SET_BL_BT_CTRL_AGG_SIZE: + btcoexist->bt_info.b_bt_ctrl_buf_size = *bool_tmp; + break; + case BTC_SET_BL_INC_SCAN_DEV_NUM: + btcoexist->bt_info.increase_scan_dev_num = *bool_tmp; + break; + /* set some u1Byte type variables. */ + case BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON: + btcoexist->bt_info.rssi_adjust_for_agc_table_on = *u8_tmp; + break; + case BTC_SET_U1_AGG_BUF_SIZE: + btcoexist->bt_info.agg_buf_size = *u8_tmp; + break; + /* the following are some action which will be triggered */ + case BTC_SET_ACT_GET_BT_RSSI: + /*BTHCI_SendGetBtRssiEvent(rtlpriv);*/ + break; + case BTC_SET_ACT_AGGREGATE_CTRL: + halbtc_aggregation_check(btcoexist); + break; + + /* 1Ant */ + case BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE: + btcoexist->bt_info.rssi_adjust_for_1ant_coex_type = *u8_tmp; + break; + case BTC_SET_U1_LPS_VAL: + btcoexist->bt_info.lps_val = *u8_tmp; + break; + case BTC_SET_U1_RPWM_VAL: + btcoexist->bt_info.rpwm_val = *u8_tmp; + break; + /* the following are some action which will be triggered */ + case BTC_SET_ACT_LEAVE_LPS: + halbtc_leave_lps(btcoexist); + break; + case BTC_SET_ACT_ENTER_LPS: + halbtc_enter_lps(btcoexist); + break; + case BTC_SET_ACT_NORMAL_LPS: + halbtc_normal_lps(btcoexist); + break; + case BTC_SET_ACT_DISABLE_LOW_POWER: + break; + case BTC_SET_ACT_UPDATE_ra_mask: + btcoexist->bt_info.ra_mask = *u32_tmp; + break; + case BTC_SET_ACT_SEND_MIMO_PS: + break; + case BTC_SET_ACT_INC_FORCE_EXEC_PWR_CMD_CNT: + btcoexist->bt_info.force_exec_pwr_cmd_cnt++; + break; + case BTC_SET_ACT_CTRL_BT_INFO: /*wait for 8812/8821*/ + break; + case BTC_SET_ACT_CTRL_BT_COEX: + break; + default: + break; + } + + return true; +} + +static void halbtc_display_coex_statistics(struct btc_coexist *btcoexist) +{ +} + +static void halbtc_display_bt_link_info(struct btc_coexist *btcoexist) +{ +} + +static void halbtc_display_bt_fw_info(struct btc_coexist *btcoexist) +{ +} + +static void halbtc_display_fw_pwr_mode_cmd(struct btc_coexist *btcoexist) +{ +} + +/************************************************************ + * IO related function + ************************************************************/ +static u8 halbtc_read_1byte(void *bt_context, u32 reg_addr) +{ + struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; + struct rtl_priv *rtlpriv = btcoexist->adapter; + + return rtl_read_byte(rtlpriv, reg_addr); +} + + +static u16 halbtc_read_2byte(void *bt_context, u32 reg_addr) +{ + struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; + struct rtl_priv *rtlpriv = btcoexist->adapter; + + return rtl_read_word(rtlpriv, reg_addr); +} + + +static u32 halbtc_read_4byte(void *bt_context, u32 reg_addr) +{ + struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; + struct rtl_priv *rtlpriv = btcoexist->adapter; + + return rtl_read_dword(rtlpriv, reg_addr); +} + + +static void halbtc_write_1byte(void *bt_context, u32 reg_addr, u8 data) +{ + struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; + struct rtl_priv *rtlpriv = btcoexist->adapter; + + rtl_write_byte(rtlpriv, reg_addr, data); +} + +static void halbtc_bitmask_write_1byte(void *bt_context, u32 reg_addr, + u8 bit_mask, u8 data) +{ + struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; + struct rtl_priv *rtlpriv = btcoexist->adapter; + u8 original_value, bit_shift = 0; + u8 i; + + if (bit_mask != MASKBYTE0) {/*if not "byte" write*/ + original_value = rtl_read_byte(rtlpriv, reg_addr); + for (i = 0; i <= 7; i++) { + if ((bit_mask>>i)&0x1) + break; + } + bit_shift = i; + data = (original_value & (~bit_mask)) | + ((data << bit_shift) & bit_mask); + } + rtl_write_byte(rtlpriv, reg_addr, data); +} + + +static void halbtc_write_2byte(void *bt_context, u32 reg_addr, u16 data) +{ + struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; + struct rtl_priv *rtlpriv = btcoexist->adapter; + + rtl_write_word(rtlpriv, reg_addr, data); +} + + +static void halbtc_write_4byte(void *bt_context, u32 reg_addr, u32 data) +{ + struct btc_coexist *btcoexist = + (struct btc_coexist *)bt_context; + struct rtl_priv *rtlpriv = btcoexist->adapter; + + rtl_write_dword(rtlpriv, reg_addr, data); +} + + +static void halbtc_set_bbreg(void *bt_context, u32 reg_addr, + u32 bit_mask, u32 data) +{ + struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; + struct rtl_priv *rtlpriv = btcoexist->adapter; + + rtl_set_bbreg(rtlpriv->mac80211.hw, reg_addr, bit_mask, data); +} + + +static u32 halbtc_get_bbreg(void *bt_context, u32 reg_addr, u32 bit_mask) +{ + struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; + struct rtl_priv *rtlpriv = btcoexist->adapter; + + return rtl_get_bbreg(rtlpriv->mac80211.hw, reg_addr, bit_mask); +} + + +static void halbtc_set_rfreg(void *bt_context, u8 rf_path, u32 reg_addr, + u32 bit_mask, u32 data) +{ + struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; + struct rtl_priv *rtlpriv = btcoexist->adapter; + + rtl_set_rfreg(rtlpriv->mac80211.hw, rf_path, reg_addr, bit_mask, data); +} + + +static u32 halbtc_get_rfreg(void *bt_context, u8 rf_path, u32 reg_addr, + u32 bit_mask) +{ + struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; + struct rtl_priv *rtlpriv = btcoexist->adapter; + + return rtl_get_rfreg(rtlpriv->mac80211.hw, rf_path, reg_addr, bit_mask); +} + + +static void halbtc_fill_h2c_cmd(void *bt_context, u8 element_id, + u32 cmd_len, u8 *cmd_buf) +{ + struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; + struct rtl_priv *rtlpriv = btcoexist->adapter; + + rtlpriv->cfg->ops->fill_h2c_cmd(rtlpriv->mac80211.hw, element_id, + cmd_len, cmd_buf); +} + +static void halbtc_display_dbg_msg(void *bt_context, u8 disp_type) +{ + struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; + switch (disp_type) { + case BTC_DBG_DISP_COEX_STATISTICS: + halbtc_display_coex_statistics(btcoexist); + break; + case BTC_DBG_DISP_BT_LINK_INFO: + halbtc_display_bt_link_info(btcoexist); + break; + case BTC_DBG_DISP_BT_FW_VER: + halbtc_display_bt_fw_info(btcoexist); + break; + case BTC_DBG_DISP_FW_PWR_MODE_CMD: + halbtc_display_fw_pwr_mode_cmd(btcoexist); + break; + default: + break; + } +} + +static bool halbtc_under_ips(struct btc_coexist *btcoexist) +{ + struct rtl_priv *rtlpriv = btcoexist->adapter; + struct rtl_ps_ctl *ppsc = rtl_psc(rtlpriv); + enum rf_pwrstate rtstate; + + if (ppsc->b_inactiveps) { + rtstate = ppsc->rfpwr_state; + + if (rtstate != ERFON && + ppsc->rfoff_reason == RF_CHANGE_BY_IPS) + return true; + } + + return false; +} + +/***************************************************************** + * Extern functions called by other module + *****************************************************************/ +bool exhalbtc92e_initlize_variables(struct rtl_priv *adapter) +{ + struct btc_coexist *btcoexist = &gl92e_bt_coexist; + + btcoexist->statistics.cnt_bind++; + + halbtc_dbg_init(); + + if (btcoexist->binded) + return false; + else + btcoexist->binded = true; + +#if (defined(CONFIG_PCI_HCI)) + btcoexist->chip_interface = BTC_INTF_PCI; +#elif (defined(CONFIG_USB_HCI)) + btcoexist->chip_interface = BTC_INTF_USB; +#elif (defined(CONFIG_SDIO_HCI)) + btcoexist->chip_interface = BTC_INTF_SDIO; +#elif (defined(CONFIG_GSPI_HCI)) + btcoexist->chip_interface = BTC_INTF_GSPI; +#else + btcoexist->chip_interface = BTC_INTF_UNKNOWN; +#endif + + if (NULL == btcoexist->adapter) + btcoexist->adapter = adapter; + + btcoexist->stack_info.profile_notified = false; + + btcoexist->btc_read_1byte = halbtc_read_1byte; + btcoexist->btc_write_1byte = halbtc_write_1byte; + btcoexist->btc_write_1byte_bitmask = halbtc_bitmask_write_1byte; + btcoexist->btc_read_2byte = halbtc_read_2byte; + btcoexist->btc_write_2byte = halbtc_write_2byte; + btcoexist->btc_read_4byte = halbtc_read_4byte; + btcoexist->btc_write_4byte = halbtc_write_4byte; + + btcoexist->btc_set_bb_reg = halbtc_set_bbreg; + btcoexist->btc_get_bb_reg = halbtc_get_bbreg; + + btcoexist->btc_set_rf_reg = halbtc_set_rfreg; + btcoexist->btc_get_rf_reg = halbtc_get_rfreg; + + btcoexist->btc_fill_h2c = halbtc_fill_h2c_cmd; + btcoexist->btc_disp_dbg_msg = halbtc_display_dbg_msg; + + btcoexist->btc_get = halbtc_get; + btcoexist->btc_set = halbtc_set; + + btcoexist->cli_buf = &btc_dbg_buf[0]; + + btcoexist->bt_info.b_bt_ctrl_buf_size = false; + btcoexist->bt_info.agg_buf_size = 5; + + btcoexist->bt_info.increase_scan_dev_num = false; + return true; +} + +void exhalbtc92e_init_hw_config(struct btc_coexist *btcoexist) +{ + struct rtl_priv *rtlpriv = btcoexist->adapter; + struct rtl_hal *rtlhal = rtl_hal(rtlpriv); + + if (!halbtc_is_bt_coexist_available(btcoexist)) + return; + + btcoexist->statistics.cnt_init_hw_config++; + + if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) { + if (btcoexist->board_info.btdm_ant_num == 2) + ex92e_halbtc8723b2ant_init_hwconfig(btcoexist); + else if (btcoexist->board_info.btdm_ant_num == 1) + ex_halbtc8723b1ant_init_hwconfig(btcoexist); + } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) { + ex_halbtc8192e2ant_init_hwconfig(btcoexist); + } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8821AE) { + if (btcoexist->board_info.btdm_ant_num == 2) + ex_halbtc8821a2ant_init_hwconfig(btcoexist); + else if (btcoexist->board_info.btdm_ant_num == 1) + ex_halbtc8821a1ant_init_hwconfig(btcoexist); + } +} + +void exhalbtc92e_init_coex_dm(struct btc_coexist *btcoexist) +{ + struct rtl_priv *rtlpriv = btcoexist->adapter; + struct rtl_hal *rtlhal = rtl_hal(rtlpriv); + + if (!halbtc_is_bt_coexist_available(btcoexist)) + return; + + btcoexist->statistics.cnt_init_coex_dm++; + + if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) { + if (btcoexist->board_info.btdm_ant_num == 2) + ex92e_halbtc8723b2ant_init_coex_dm(btcoexist); + else if (btcoexist->board_info.btdm_ant_num == 1) + ex_halbtc8723b1ant_init_coex_dm(btcoexist); + } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) { + ex_halbtc8192e2ant_init_coex_dm(btcoexist); + } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8821AE) { + if (btcoexist->board_info.btdm_ant_num == 2) + ex_halbtc8821a2ant_init_coex_dm(btcoexist); + else if (btcoexist->board_info.btdm_ant_num == 1) + ex_halbtc8821a1ant_init_coex_dm(btcoexist); + } + + btcoexist->initilized = true; +} + +void exhalbtc92e_ips_notify(struct btc_coexist *btcoexist, u8 type) +{ + struct rtl_priv *rtlpriv = btcoexist->adapter; + struct rtl_hal *rtlhal = rtl_hal(rtlpriv); + u8 ips_type; + + if (!halbtc_is_bt_coexist_available(btcoexist)) + return; + btcoexist->statistics.cnt_ips_notify++; + if (btcoexist->manual_control) + return; + + if (ERFOFF == type) + ips_type = BTC_IPS_ENTER; + else + ips_type = BTC_IPS_LEAVE; + + if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) { + if (btcoexist->board_info.btdm_ant_num == 2) + ex92e_halbtc8723b2ant_ips_notify(btcoexist, ips_type); + else if (btcoexist->board_info.btdm_ant_num == 1) + ex_halbtc8723b1ant_ips_notify(btcoexist, ips_type); + } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) { + ex_halbtc8192e2ant_ips_notify(btcoexist, ips_type); + } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8821AE) { + if (btcoexist->board_info.btdm_ant_num == 2) + ex_halbtc8821a2ant_ips_notify(btcoexist, ips_type); + else if (btcoexist->board_info.btdm_ant_num == 1) + ex_halbtc8821a1ant_ips_notify(btcoexist, ips_type); + } +} + +void exhalbtc92e_lps_notify(struct btc_coexist *btcoexist, u8 type) +{ + struct rtl_priv *rtlpriv = btcoexist->adapter; + struct rtl_hal *rtlhal = rtl_hal(rtlpriv); + u8 lps_type; + + if (!halbtc_is_bt_coexist_available(btcoexist)) + return; + btcoexist->statistics.cnt_lps_notify++; + if (btcoexist->manual_control) + return; + + if (EACTIVE == type) + lps_type = BTC_LPS_DISABLE; + else + lps_type = BTC_LPS_ENABLE; + + if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) { + if (btcoexist->board_info.btdm_ant_num == 2) + ex92e_halbtc8723b2ant_lps_notify(btcoexist, lps_type); + else if (btcoexist->board_info.btdm_ant_num == 1) + ex_halbtc8723b1ant_lps_notify(btcoexist, lps_type); + } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) { + ex_halbtc8192e2ant_lps_notify(btcoexist, lps_type); + } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8821AE) { + if (btcoexist->board_info.btdm_ant_num == 2) + ex_halbtc8821a2ant_lps_notify(btcoexist, lps_type); + else if (btcoexist->board_info.btdm_ant_num == 1) + ex_halbtc8821a1ant_lps_notify(btcoexist, lps_type); + } +} + +void exhalbtc92e_scan_notify(struct btc_coexist *btcoexist, u8 type) +{ + struct rtl_priv *rtlpriv = btcoexist->adapter; + struct rtl_hal *rtlhal = rtl_hal(rtlpriv); + u8 scan_type; + + if (!halbtc_is_bt_coexist_available(btcoexist)) + return; + btcoexist->statistics.cnt_scan_notify++; + if (btcoexist->manual_control) + return; + + if (type) + scan_type = BTC_SCAN_START; + else + scan_type = BTC_SCAN_FINISH; + + if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) { + if (btcoexist->board_info.btdm_ant_num == 2) + ex92e_halbtc8723b2ant_scan_notify(btcoexist, scan_type); + else if (btcoexist->board_info.btdm_ant_num == 1) + ex_halbtc8723b1ant_scan_notify(btcoexist, scan_type); + } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) { + ex_halbtc8192e2ant_scan_notify(btcoexist, scan_type); + } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8821AE) { + if (btcoexist->board_info.btdm_ant_num == 2) + ex_halbtc8821a2ant_scan_notify(btcoexist, scan_type); + else if (btcoexist->board_info.btdm_ant_num == 1) + ex_halbtc8821a1ant_scan_notify(btcoexist, scan_type); + } +} + +void exhalbtc92e_connect_notify(struct btc_coexist *btcoexist, u8 action) +{ + struct rtl_priv *rtlpriv = btcoexist->adapter; + struct rtl_hal *rtlhal = rtl_hal(rtlpriv); + u8 asso_type; + + if (!halbtc_is_bt_coexist_available(btcoexist)) + return; + btcoexist->statistics.cnt_connect_notify++; + if (btcoexist->manual_control) + return; + + if (action) + asso_type = BTC_ASSOCIATE_START; + else + asso_type = BTC_ASSOCIATE_FINISH; + + if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) { + if (btcoexist->board_info.btdm_ant_num == 2) + ex92e_halbtc8723b2ant_connect_notify(btcoexist, + asso_type); + else if (btcoexist->board_info.btdm_ant_num == 1) + ex_halbtc8723b1ant_connect_notify(btcoexist, asso_type); + } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) { + ex_halbtc8192e2ant_connect_notify(btcoexist, asso_type); + } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8821AE) { + if (btcoexist->board_info.btdm_ant_num == 2) + ex_halbtc8821a2ant_connect_notify(btcoexist, + asso_type); + else if (btcoexist->board_info.btdm_ant_num == 1) + ex_halbtc8821a1ant_connect_notify(btcoexist, + asso_type); + } +} + +void exhalbtc92e_mediastatus_notify(struct btc_coexist *btcoexist, + enum rt_media_status media_status) +{ + struct rtl_priv *rtlpriv = btcoexist->adapter; + struct rtl_hal *rtlhal = rtl_hal(rtlpriv); + u8 status; + + if (!halbtc_is_bt_coexist_available(btcoexist)) + return; + btcoexist->statistics.cnt_media_status_notify++; + if (btcoexist->manual_control) + return; + + if (RT_MEDIA_CONNECT == media_status) + status = BTC_MEDIA_CONNECT; + else + status = BTC_MEDIA_DISCONNECT; + + if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) { + if (btcoexist->board_info.btdm_ant_num == 2) + ex92e_halbtc8723b2ant_media_status_notify(btcoexist, + status); + else if (btcoexist->board_info.btdm_ant_num == 1) + ex_halbtc8723b1ant_media_status_notify(btcoexist, + status); + } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) { + ex_halbtc8192e2ant_media_status_notify(btcoexist, status); + } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8821AE) { + if (btcoexist->board_info.btdm_ant_num == 2) + ex_halbtc8821a2ant_media_status_notify(btcoexist, + status); + else if (btcoexist->board_info.btdm_ant_num == 1) + ex_halbtc8821a1ant_media_status_notify(btcoexist, + status); + } +} + +void exhalbtc92e_special_packet_notify(struct btc_coexist *btcoexist, + u8 pkt_type) +{ + struct rtl_priv *rtlpriv = btcoexist->adapter; + struct rtl_hal *rtlhal = rtl_hal(rtlpriv); + u8 packet_type; + + if (!halbtc_is_bt_coexist_available(btcoexist)) + return; + btcoexist->statistics.cnt_special_packet_notify++; + if (btcoexist->manual_control) + return; + + if (PACKET_DHCP == pkt_type) { + packet_type = BTC_PACKET_DHCP; + } else if (PACKET_EAPOL == pkt_type) { + packet_type = BTC_PACKET_EAPOL; + } else if (PACKET_ARP == pkt_type) { + packet_type = BTC_PACKET_ARP; + } else { + packet_type = BTC_PACKET_UNKNOWN; + return; + } + + if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) { + if (btcoexist->board_info.btdm_ant_num == 2) + ex92e_halbtc8723b2ant_special_packet_notify(btcoexist, + packet_type); + else if (btcoexist->board_info.btdm_ant_num == 1) + ex_halbtc8723b1ant_special_packet_notify(btcoexist, + packet_type); + } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8821AE) { + if (btcoexist->board_info.btdm_ant_num == 2) + ex_halbtc8821a2ant_special_packet_notify(btcoexist, + packet_type); + else if (btcoexist->board_info.btdm_ant_num == 1) + ex_halbtc8821a1ant_special_packet_notify(btcoexist, + packet_type); + } +} + +void exhalbtc92e_bt_info_notify(struct btc_coexist *btcoexist, + u8 *tmp_buf, u8 length) +{ + struct rtl_priv *rtlpriv = btcoexist->adapter; + struct rtl_hal *rtlhal = rtl_hal(rtlpriv); + if (!halbtc_is_bt_coexist_available(btcoexist)) + return; + btcoexist->statistics.cnt_bt_info_notify++; + + if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) { + if (btcoexist->board_info.btdm_ant_num == 2) + ex92e_halbtc8723b2ant_bt_info_notify(btcoexist, + tmp_buf, length); + else if (btcoexist->board_info.btdm_ant_num == 1) + ex_halbtc8723b1ant_bt_info_notify(btcoexist, tmp_buf, + length); + } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) { + /* ex_halbtc8192e2ant_bt_info_notify(btcoexist, + tmp_buf, length); */ + } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8821AE) { + if (btcoexist->board_info.btdm_ant_num == 2) + ex_halbtc8821a2ant_bt_info_notify(btcoexist, + tmp_buf, length); + else if (btcoexist->board_info.btdm_ant_num == 1) + ex_halbtc8821a1ant_bt_info_notify(btcoexist, + tmp_buf, length); + } +} + +void exhalbtc92e_stack_operation_notify(struct btc_coexist *btcoexist, u8 type) +{ + u8 stack_op_type; + + if (!halbtc_is_bt_coexist_available(btcoexist)) + return; + btcoexist->statistics.cnt_stack_operation_notify++; + if (btcoexist->manual_control) + return; + + if ((HCI_BT_OP_INQUIRY_START == type) || + (HCI_BT_OP_PAGING_START == type) || + (HCI_BT_OP_PAIRING_START == type)) + stack_op_type = BTC_STACK_OP_INQ_PAGE_PAIR_START; + else if ((HCI_BT_OP_INQUIRY_FINISH == type) || + (HCI_BT_OP_PAGING_SUCCESS == type) || + (HCI_BT_OP_PAGING_UNSUCCESS == type) || + (HCI_BT_OP_PAIRING_FINISH == type)) + stack_op_type = BTC_STACK_OP_INQ_PAGE_PAIR_FINISH; + else + stack_op_type = BTC_STACK_OP_NONE; +} + +void exhalbtc92e_halt_notify(struct btc_coexist *btcoexist) +{ + struct rtl_priv *rtlpriv = btcoexist->adapter; + struct rtl_hal *rtlhal = rtl_hal(rtlpriv); + if (!halbtc_is_bt_coexist_available(btcoexist)) + return; + + btcoexist->binded = false; + + if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) { + if (btcoexist->board_info.btdm_ant_num == 2) + ex92e_halbtc8723b2ant_halt_notify(btcoexist); + else if (btcoexist->board_info.btdm_ant_num == 1) + ex_halbtc8723b1ant_halt_notify(btcoexist); + } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) { + ex_halbtc8192e2ant_halt_notify(btcoexist); + } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8821AE) { + if (btcoexist->board_info.btdm_ant_num == 2) + ex_halbtc8821a2ant_halt_notify(btcoexist); + else if (btcoexist->board_info.btdm_ant_num == 1) + ex_halbtc8821a1ant_halt_notify(btcoexist); + } +} + +void exhalbtc92e_pnp_notify(struct btc_coexist *btcoexist, u8 pnp_state) +{ + struct rtl_priv *rtlpriv = btcoexist->adapter; + struct rtl_hal *rtlhal = rtl_hal(rtlpriv); + + if (!halbtc_is_bt_coexist_available(btcoexist)) + return; + + if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) { + if (btcoexist->board_info.btdm_ant_num == 1) + ex_halbtc8723b1ant_pnp_notify(btcoexist, pnp_state); + } +} + +void exhalbtc_coex_dm_switch(struct btc_coexist *btcoexist) +{ + struct rtl_priv *rtlpriv = btcoexist->adapter; + struct rtl_hal *rtlhal = rtl_hal(rtlpriv); + if (!halbtc_is_bt_coexist_available(btcoexist)) + return; + btcoexist->statistics.cnt_coex_dm_switch++; + + if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) { + if (btcoexist->board_info.btdm_ant_num == 1) { + btcoexist->stop_coex_dm = true; + ex_halbtc8723b1ant_coex_dm_reset(btcoexist); + exhalbtc92e_set_ant_num(BT_COEX_ANT_TYPE_DETECTED, 2); + ex92e_halbtc8723b2ant_init_hwconfig(btcoexist); + ex92e_halbtc8723b2ant_init_coex_dm(btcoexist); + btcoexist->stop_coex_dm = false; + } + } +} + +void exhalbtc92e_periodical(struct btc_coexist *btcoexist) +{ + struct rtl_priv *rtlpriv = btcoexist->adapter; + struct rtl_hal *rtlhal = rtl_hal(rtlpriv); + if (!halbtc_is_bt_coexist_available(btcoexist)) + return; + btcoexist->statistics.cnt_periodical++; + + if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) { + if (btcoexist->board_info.btdm_ant_num == 2) + ex92e_halbtc8723b2ant_periodical(btcoexist); + else if (btcoexist->board_info.btdm_ant_num == 1) + ex_halbtc8723b1ant_periodical(btcoexist); + } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192EE) { + ex_halbtc8192e2ant_periodical(btcoexist); + } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8821AE) { + if (btcoexist->board_info.btdm_ant_num == 2) + ex_halbtc8821a2ant_periodical(btcoexist); + else if (btcoexist->board_info.btdm_ant_num == 1) + if (!halbtc_under_ips(btcoexist)) + ex_halbtc8821a1ant_periodical(btcoexist); + } +} + +void exhalbtc92e_dbg_control(struct btc_coexist *btcoexist, + u8 code, u8 len, u8 *data) +{ + if (!halbtc_is_bt_coexist_available(btcoexist)) + return; + btcoexist->statistics.cnt_dbg_ctrl++; +} + +void exhalbtc92e_stack_update_profile_info(void) +{ +} + +void exhalbtc92e_update_min_bt_rssi(char bt_rssi) +{ + struct btc_coexist *btcoexist = &gl92e_bt_coexist; + + if (!halbtc_is_bt_coexist_available(btcoexist)) + return; + + btcoexist->stack_info.min_bt_rssi = bt_rssi; +} + + +void exhalbtc92e_set_hci_version(u16 hci_version) +{ + struct btc_coexist *btcoexist = &gl92e_bt_coexist; + + if (!halbtc_is_bt_coexist_available(btcoexist)) + return; + + btcoexist->stack_info.hci_version = hci_version; +} + +void exhalbtc92e_set_bt_patch_version(u16 bt_hci_version, u16 bt_patch_version) +{ + struct btc_coexist *btcoexist = &gl92e_bt_coexist; + + if (!halbtc_is_bt_coexist_available(btcoexist)) + return; + + btcoexist->bt_info.bt_real_fw_ver = bt_patch_version; + btcoexist->bt_info.bt_hci_ver = bt_hci_version; +} + +void exhalbtc92e_set_bt_exist(bool bt_exist) +{ + gl92e_bt_coexist.board_info.bt_exist = bt_exist; +} + +void exhalbtc92e_set_chip_type(u8 chip_type) +{ + switch (chip_type) { + default: + case BT_2WIRE: + case BT_ISSC_3WIRE: + case BT_ACCEL: + case BT_RTL8756: + gl92e_bt_coexist.board_info.bt_chip_type = BTC_CHIP_UNDEF; + break; + case BT_CSR_BC4: + gl92e_bt_coexist.board_info.bt_chip_type = BTC_CHIP_CSR_BC4; + break; + case BT_CSR_BC8: + gl92e_bt_coexist.board_info.bt_chip_type = BTC_CHIP_CSR_BC8; + break; + case BT_RTL8723A: + gl92e_bt_coexist.board_info.bt_chip_type = BTC_CHIP_RTL8723A; + break; + case BT_RTL8821A: + gl92e_bt_coexist.board_info.bt_chip_type = BTC_CHIP_RTL8821; + break; + case BT_RTL8723B: + gl92e_bt_coexist.board_info.bt_chip_type = BTC_CHIP_RTL8723B; + break; + } +} + +void exhalbtc92e_set_ant_num(u8 type, u8 ant_num) +{ + if (BT_COEX_ANT_TYPE_PG == type) { + gl92e_bt_coexist.board_info.pg_ant_num = ant_num; + gl92e_bt_coexist.board_info.btdm_ant_num = ant_num; + /* The antenna position: + * Main (default) or Aux for pgAntNum = 2 && btdmAntNum = 1. + * The antenna position should be determined by + * auto-detect mechanism. + * The following is assumed to main, + * and those must be modified + * if y auto-detect mechanism is ready + */ + if ((gl92e_bt_coexist.board_info.pg_ant_num == 2) && + (gl92e_bt_coexist.board_info.btdm_ant_num == 1)) + gl92e_bt_coexist.board_info.btdm_ant_pos = + BTC_ANTENNA_AT_MAIN_PORT; + else + gl92e_bt_coexist.board_info.btdm_ant_pos = + BTC_ANTENNA_AT_MAIN_PORT; + } else if (BT_COEX_ANT_TYPE_ANTDIV == type) { + gl92e_bt_coexist.board_info.btdm_ant_num = ant_num; + gl92e_bt_coexist.board_info.btdm_ant_pos = + BTC_ANTENNA_AT_MAIN_PORT; + } else if (BT_COEX_ANT_TYPE_DETECTED == type) { + gl92e_bt_coexist.board_info.btdm_ant_num = ant_num; + gl92e_bt_coexist.board_info.btdm_ant_pos = + BTC_ANTENNA_AT_MAIN_PORT; + } +} + +void exhalbtc92e_display_bt_coex_info(struct btc_coexist *btcoexist) +{ + struct rtl_priv *rtlpriv = btcoexist->adapter; + struct rtl_hal *rtlhal = rtl_hal(rtlpriv); + + if (!halbtc_is_bt_coexist_available(btcoexist)) + return; + + if (rtlhal->hw_type == HARDWARE_TYPE_RTL8723BE) { + if (btcoexist->board_info.btdm_ant_num == 2) + ex_halbtc8723b2ant92e_display_coex_info(btcoexist); + else if (btcoexist->board_info.btdm_ant_num == 1) + ex_halbtc8723b1ant_display_coex_info(btcoexist); + } else if (rtlhal->hw_type == HARDWARE_TYPE_RTL8821AE) { + if (btcoexist->board_info.btdm_ant_num == 2) + ex_halbtc8821a2ant_display_coex_info(btcoexist); + else if (btcoexist->board_info.btdm_ant_num == 1) + ex_halbtc8821a1ant_display_coex_info(btcoexist); + } +} diff --git a/drivers/staging/rtl8192ee/btcoexist/halbtcoutsrc.h b/drivers/staging/rtl8192ee/btcoexist/halbtcoutsrc.h new file mode 100644 index 000000000000..c0a4286430a5 --- /dev/null +++ b/drivers/staging/rtl8192ee/btcoexist/halbtcoutsrc.h @@ -0,0 +1,537 @@ +#ifndef __HALBTC_OUT_SRC_H__ +#define __HALBTC_OUT_SRC_H__ + +#include "../wifi.h" + +#define NORMAL_EXEC false +#define FORCE_EXEC true + +#define BTC_RF_A RF90_PATH_A +#define BTC_RF_B RF90_PATH_B +#define BTC_RF_C RF90_PATH_C +#define BTC_RF_D RF90_PATH_D + +#define BTC_SMSP SINGLEMAC_SINGLEPHY +#define BTC_DMDP DUALMAC_DUALPHY +#define BTC_DMSP DUALMAC_SINGLEPHY +#define BTC_MP_UNKNOWN 0xff + +#define IN +#define OUT + +#define BT_TMP_BUF_SIZE 100 + +#define BT_COEX_ANT_TYPE_PG 0 +#define BT_COEX_ANT_TYPE_ANTDIV 1 +#define BT_COEX_ANT_TYPE_DETECTED 2 + +#define BTC_MIMO_PS_STATIC 0 +#define BTC_MIMO_PS_DYNAMIC 1 + +#define BTC_RATE_DISABLE 0 +#define BTC_RATE_ENABLE 1 + +/* single Antenna definition */ +#define BTC_ANT_PATH_WIFI 0 +#define BTC_ANT_PATH_BT 1 +#define BTC_ANT_PATH_PTA 2 +/* dual Antenna definition */ +#define BTC_ANT_WIFI_AT_MAIN 0 +#define BTC_ANT_WIFI_AT_AUX 1 +/* coupler Antenna definition */ +#define BTC_ANT_WIFI_AT_CPL_MAIN 0 +#define BTC_ANT_WIFI_AT_CPL_AUX 1 + +enum btc_chip_interface { + BTC_INTF_UNKNOWN = 0, + BTC_INTF_PCI = 1, + BTC_INTF_USB = 2, + BTC_INTF_SDIO = 3, + BTC_INTF_GSPI = 4, + BTC_INTF_MAX +}; + +enum btc_chip_type { + BTC_CHIP_UNDEF = 0, + BTC_CHIP_CSR_BC4 = 1, + BTC_CHIP_CSR_BC8 = 2, + BTC_CHIP_RTL8723A = 3, + BTC_CHIP_RTL8821 = 4, + BTC_CHIP_RTL8723B = 5, + BTC_CHIP_MAX +}; + +enum btc_msg_type { + BTC_MSG_INTERFACE = 0x0, + BTC_MSG_ALGORITHM = 0x1, + BTC_MSG_MAX +}; + +extern u32 btc_92edbg_type[]; + +/* following is for BTC_MSG_INTERFACE */ +#define INTF_INIT BIT(0) +#define INTF_NOTIFY BIT(2) + +/* following is for BTC_ALGORITHM */ +#define ALGO_BT_RSSI_STATE BIT(0) +#define ALGO_WIFI_RSSI_STATE BIT(1) +#define ALGO_BT_MONITOR BIT(2) +#define ALGO_TRACE BIT(3) +#define ALGO_TRACE_FW BIT(4) +#define ALGO_TRACE_FW_DETAIL BIT(5) +#define ALGO_TRACE_FW_EXEC BIT(6) +#define ALGO_TRACE_SW BIT(7) +#define ALGO_TRACE_SW_DETAIL BIT(8) +#define ALGO_TRACE_SW_EXEC BIT(9) + +/* following is for wifi link status */ +#define WIFI_STA_CONNECTED BIT(0) +#define WIFI_AP_CONNECTED BIT(1) +#define WIFI_HS_CONNECTED BIT(2) +#define WIFI_P2P_GO_CONNECTED BIT(3) +#define WIFI_P2P_GC_CONNECTED BIT(4) + + +#define CL_SPRINTF snprintf +#define CL_PRINTF printk + +#define BTC_PRINT(dbgtype, dbgflag, printstr, ...) \ + do { \ + if (unlikely(btc_92edbg_type[dbgtype] & dbgflag)) {\ + pr_debug(printstr, ##__VA_ARGS__); \ + } \ + } while (0) + +#define BTC_PRINT_F(dbgtype, dbgflag, printstr, ...) \ + do { \ + if (unlikely(btc_92edbg_type[dbgtype] & dbgflag)) {\ + pr_debug("%s: ", __func__); \ + pr_cont(printstr, ##__VA_ARGS__); \ + } \ + } while (0) + +#define BTC_PRINT_ADDR(dbgtype, dbgflag, printstr, _ptr) \ + do { \ + if (unlikely(btc_92edbg_type[dbgtype] & dbgflag)) { \ + int __i; \ + u8 *__ptr = (u8 *)_ptr; \ + pr_debug printstr; \ + for (__i = 0; __i < 6; __i++) \ + pr_cont("%02X%s", __ptr[__i], \ + (__i == 5) ? "" : "-"); \ + pr_debug("\n"); \ + } \ + } while (0) + +#define BTC_PRINT_DATA(dbgtype, dbgflag, _titlestring, _hexdata, _hexdatalen) \ + do { \ + if (unlikely(btc_92edbg_type[dbgtype] & dbgflag)) { \ + int __i; \ + u8 *__ptr = (u8 *)_hexdata; \ + pr_debug(_titlestring); \ + for (__i = 0; __i < (int)_hexdatalen; __i++) { \ + pr_cont("%02X%s", __ptr[__i], (((__i + 1) % 4) \ + == 0) ? " " : " ");\ + if (((__i + 1) % 16) == 0) \ + pr_cont("\n"); \ + } \ + pr_debug("\n"); \ + } \ + } while (0) + + +#define BTC_RSSI_HIGH(_rssi_) \ + ((_rssi_ == BTC_RSSI_STATE_HIGH || \ + _rssi_ == BTC_RSSI_STATE_STAY_HIGH) ? true : false) +#define BTC_RSSI_MEDIUM(_rssi_) \ + ((_rssi_ == BTC_RSSI_STATE_MEDIUM || \ + _rssi_ == BTC_RSSI_STATE_STAY_MEDIUM) ? true : false) +#define BTC_RSSI_LOW(_rssi_) \ + ((_rssi_ == BTC_RSSI_STATE_LOW || \ + _rssi_ == BTC_RSSI_STATE_STAY_LOW) ? true : false) + + +enum btc_power_save_type { + BTC_PS_WIFI_NATIVE = 0, + BTC_PS_LPS_ON = 1, + BTC_PS_LPS_OFF = 2, + BTC_PS_LPS_MAX +}; + +struct btc_board_info { + /* The following is some board information */ + u8 bt_chip_type; + u8 pg_ant_num; /* pg ant number */ + u8 btdm_ant_num; /* ant number for btdm */ + u8 btdm_ant_pos; + bool bt_exist; +}; + +enum btc_dbg_opcode { + BTC_DBG_SET_COEX_NORMAL = 0x0, + BTC_DBG_SET_COEX_WIFI_ONLY = 0x1, + BTC_DBG_SET_COEX_BT_ONLY = 0x2, + BTC_DBG_MAX +}; + +enum btc_rssi_state { + BTC_RSSI_STATE_HIGH = 0x0, + BTC_RSSI_STATE_MEDIUM = 0x1, + BTC_RSSI_STATE_LOW = 0x2, + BTC_RSSI_STATE_STAY_HIGH = 0x3, + BTC_RSSI_STATE_STAY_MEDIUM = 0x4, + BTC_RSSI_STATE_STAY_LOW = 0x5, + BTC_RSSI_MAX +}; + +enum btc_wifi_role { + BTC_ROLE_STATION = 0x0, + BTC_ROLE_AP = 0x1, + BTC_ROLE_IBSS = 0x2, + BTC_ROLE_HS_MODE = 0x3, + BTC_ROLE_MAX +}; + +enum btc_wifi_bw_mode { + BTC_WIFI_BW_LEGACY = 0x0, + BTC_WIFI_BW_HT20 = 0x1, + BTC_WIFI_BW_HT40 = 0x2, + BTC_WIFI_BW_MAX +}; + +enum btc_wifi_traffic_dir { + BTC_WIFI_TRAFFIC_TX = 0x0, + BTC_WIFI_TRAFFIC_RX = 0x1, + BTC_WIFI_TRAFFIC_MAX +}; + +enum btc_wifi_pnp { + BTC_WIFI_PNP_WAKE_UP = 0x0, + BTC_WIFI_PNP_SLEEP = 0x1, + BTC_WIFI_PNP_MAX +}; + + +enum btc_get_type { + /* type bool */ + BTC_GET_BL_HS_OPERATION, + BTC_GET_BL_HS_CONNECTING, + BTC_GET_BL_WIFI_CONNECTED, + BTC_GET_BL_WIFI_BUSY, + BTC_GET_BL_WIFI_SCAN, + BTC_GET_BL_WIFI_LINK, + BTC_GET_BL_WIFI_DHCP, + BTC_GET_BL_WIFI_SOFTAP_IDLE, + BTC_GET_BL_WIFI_SOFTAP_LINKING, + BTC_GET_BL_WIFI_IN_EARLY_SUSPEND, + BTC_GET_BL_WIFI_ROAM, + BTC_GET_BL_WIFI_4_WAY_PROGRESS, + BTC_GET_BL_WIFI_UNDER_5G, + BTC_GET_BL_WIFI_AP_MODE_ENABLE, + BTC_GET_BL_WIFI_ENABLE_ENCRYPTION, + BTC_GET_BL_WIFI_UNDER_B_MODE, + BTC_GET_BL_EXT_SWITCH, + + /* type s4Byte */ + BTC_GET_S4_WIFI_RSSI, + BTC_GET_S4_HS_RSSI, + + /* type u32 */ + BTC_GET_U4_WIFI_BW, + BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, + BTC_GET_U4_WIFI_FW_VER, + BTC_GET_U4_WIFI_LINK_STATUS, + BTC_GET_U4_BT_PATCH_VER, + + /* type u1Byte */ + BTC_GET_U1_WIFI_DOT11_CHNL, + BTC_GET_U1_WIFI_CENTRAL_CHNL, + BTC_GET_U1_WIFI_HS_CHNL, + BTC_GET_U1_MAC_PHY_MODE, + BTC_GET_U1_AP_NUM, + + /* for 1Ant */ + BTC_GET_U1_LPS_MODE, + BTC_GET_BL_BT_SCO_BUSY, + + /* for test mode */ + BTC_GET_DRIVER_TEST_CFG, + BTC_GET_MAX +}; + + +enum btc_set_type { + /* type bool */ + BTC_SET_BL_BT_DISABLE, + BTC_SET_BL_BT_TRAFFIC_BUSY, + BTC_SET_BL_BT_LIMITED_DIG, + BTC_SET_BL_FORCE_TO_ROAM, + BTC_SET_BL_TO_REJ_AP_AGG_PKT, + BTC_SET_BL_BT_CTRL_AGG_SIZE, + BTC_SET_BL_INC_SCAN_DEV_NUM, + + /* type u1Byte */ + BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, + BTC_SET_U1_AGG_BUF_SIZE, + + /* type trigger some action */ + BTC_SET_ACT_GET_BT_RSSI, + BTC_SET_ACT_AGGREGATE_CTRL, + + /********* for 1Ant **********/ + /* type bool */ + BTC_SET_BL_BT_SCO_BUSY, + /* type u1Byte */ + BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE, + BTC_SET_U1_LPS_VAL, + BTC_SET_U1_RPWM_VAL, + BTC_SET_U1_1ANT_LPS, + BTC_SET_U1_1ANT_RPWM, + /* type trigger some action */ + BTC_SET_ACT_LEAVE_LPS, + BTC_SET_ACT_ENTER_LPS, + BTC_SET_ACT_NORMAL_LPS, + BTC_SET_ACT_INC_FORCE_EXEC_PWR_CMD_CNT, + BTC_SET_ACT_DISABLE_LOW_POWER, + BTC_SET_ACT_UPDATE_ra_mask, + BTC_SET_ACT_SEND_MIMO_PS, + /* BT Coex related */ + BTC_SET_ACT_CTRL_BT_INFO, + BTC_SET_ACT_CTRL_BT_COEX, + /***************************/ + BTC_SET_MAX +}; + +enum btc_dbg_disp_type { + BTC_DBG_DISP_COEX_STATISTICS = 0x0, + BTC_DBG_DISP_BT_LINK_INFO = 0x1, + BTC_DBG_DISP_BT_FW_VER = 0x2, + BTC_DBG_DISP_FW_PWR_MODE_CMD = 0x3, + BTC_DBG_DISP_MAX +}; + +enum btc_notify_type_ips { + BTC_IPS_LEAVE = 0x0, + BTC_IPS_ENTER = 0x1, + BTC_IPS_MAX +}; + +enum btc_notify_type_lps { + BTC_LPS_DISABLE = 0x0, + BTC_LPS_ENABLE = 0x1, + BTC_LPS_MAX +}; + +enum btc_notify_type_scan { + BTC_SCAN_FINISH = 0x0, + BTC_SCAN_START = 0x1, + BTC_SCAN_MAX +}; + +enum btc_notify_type_associate { + BTC_ASSOCIATE_FINISH = 0x0, + BTC_ASSOCIATE_START = 0x1, + BTC_ASSOCIATE_MAX +}; + +enum btc_notify_type_media_status { + BTC_MEDIA_DISCONNECT = 0x0, + BTC_MEDIA_CONNECT = 0x1, + BTC_MEDIA_MAX +}; + +enum btc_notify_type_special_packet { + BTC_PACKET_UNKNOWN = 0x0, + BTC_PACKET_DHCP = 0x1, + BTC_PACKET_ARP = 0x2, + BTC_PACKET_EAPOL = 0x3, + BTC_PACKET_MAX +}; + +enum hci_ext_bt_operation { + HCI_BT_OP_NONE = 0x0, + HCI_BT_OP_INQUIRY_START = 0x1, + HCI_BT_OP_INQUIRY_FINISH = 0x2, + HCI_BT_OP_PAGING_START = 0x3, + HCI_BT_OP_PAGING_SUCCESS = 0x4, + HCI_BT_OP_PAGING_UNSUCCESS = 0x5, + HCI_BT_OP_PAIRING_START = 0x6, + HCI_BT_OP_PAIRING_FINISH = 0x7, + HCI_BT_OP_BT_DEV_ENABLE = 0x8, + HCI_BT_OP_BT_DEV_DISABLE = 0x9, + HCI_BT_OP_MAX +}; + +enum btc_notify_type_stack_operation { + BTC_STACK_OP_NONE = 0x0, + BTC_STACK_OP_INQ_PAGE_PAIR_START = 0x1, + BTC_STACK_OP_INQ_PAGE_PAIR_FINISH = 0x2, + BTC_STACK_OP_MAX +}; + + +struct btc_bt_info { + bool bt_disabled; + u8 rssi_adjust_for_agc_table_on; + u8 rssi_adjust_for_1ant_coex_type; + bool bt_busy; + u8 agg_buf_size; + bool limited_dig; + bool reject_agg_pkt; + bool b_bt_ctrl_buf_size; + bool increase_scan_dev_num; + u16 bt_hci_ver; + u16 bt_real_fw_ver; + u8 bt_fw_ver; + + bool bt_disable_low_pwr; + + /* the following is for 1Ant solution */ + bool bt_ctrl_lps; + bool bt_pwr_save_mode; + bool bt_lps_on; + bool force_to_roam; + u8 force_exec_pwr_cmd_cnt; + u8 lps_val; + u8 rpwm_val; + u32 ra_mask; +}; + +struct btc_stack_info { + bool profile_notified; + u16 hci_version; /* stack hci version */ + u8 num_of_link; + bool bt_link_exist; + bool sco_exist; + bool acl_exist; + bool a2dp_exist; + bool hid_exist; + u8 num_of_hid; + bool pan_exist; + bool unknown_acl_exist; + char min_bt_rssi; +}; + +struct btc_statistics { + u32 cnt_bind; + u32 cnt_init_hw_config; + u32 cnt_init_coex_dm; + u32 cnt_ips_notify; + u32 cnt_lps_notify; + u32 cnt_scan_notify; + u32 cnt_connect_notify; + u32 cnt_media_status_notify; + u32 cnt_special_packet_notify; + u32 cnt_bt_info_notify; + u32 cnt_periodical; + u32 cnt_coex_dm_switch; + u32 cnt_stack_operation_notify; + u32 cnt_dbg_ctrl; +}; + +struct btc_bt_link_info { + bool bt_link_exist; + bool sco_exist; + bool sco_only; + bool a2dp_exist; + bool a2dp_only; + bool hid_exist; + bool hid_only; + bool pan_exist; + bool pan_only; +}; + +enum btc_antenna_pos { + BTC_ANTENNA_AT_MAIN_PORT = 0x1, + BTC_ANTENNA_AT_AUX_PORT = 0x2, +}; + +struct btc_coexist { + /* make sure only one adapter can bind the data context */ + bool binded; + /* default adapter */ + void *adapter; + struct btc_board_info board_info; + /* some bt info referenced by non-bt module */ + struct btc_bt_info bt_info; + struct btc_stack_info stack_info; + enum btc_chip_interface chip_interface; + struct btc_bt_link_info bt_link_info; + + bool initilized; + bool stop_coex_dm; + bool manual_control; + u8 *cli_buf; + struct btc_statistics statistics; + u8 pwr_mode_val[10]; + + /* function pointers io related */ + u8 (*btc_read_1byte)(void *btc_context, u32 reg_addr); + void (*btc_write_1byte)(void *btc_context, u32 reg_addr, u8 data); + void (*btc_write_1byte_bitmask)(void *btc_context, u32 reg_addr, + u8 bit_mask, u8 data1b); + u16 (*btc_read_2byte)(void *btc_context, u32 reg_addr); + void (*btc_write_2byte)(void *btc_context, u32 reg_addr, u16 data); + u32 (*btc_read_4byte)(void *btc_context, u32 reg_addr); + void (*btc_write_4byte)(void *btc_context, u32 reg_addr, u32 data); + + void (*btc_set_bb_reg)(void *btc_context, u32 reg_addr, + u32 bit_mask, u32 data); + u32 (*btc_get_bb_reg)(void *btc_context, u32 reg_addr, + u32 bit_mask); + + void (*btc_set_rf_reg)(void *btc_context, u8 rf_path, u32 reg_addr, + u32 bit_mask, u32 data); + u32 (*btc_get_rf_reg)(void *btc_context, u8 rf_path, + u32 reg_addr, u32 bit_mask); + + + void (*btc_fill_h2c)(void *btc_context, u8 element_id, + u32 cmd_len, u8 *cmd_buffer); + + void (*btc_disp_dbg_msg)(void *btcoexist, u8 disp_type); + + bool (*btc_get)(void *btcoexist, u8 get_type, void *out_buf); + bool (*btc_set)(void *btcoexist, u8 set_type, void *in_buf); +}; + + +bool halbtc92e_is_wifi_uplink(struct rtl_priv *adapter); + + +extern struct btc_coexist gl92e_bt_coexist; + +bool exhalbtc92e_initlize_variables(struct rtl_priv *adapter); +void exhalbtc92e_init_hw_config(struct btc_coexist *btcoexist); +void exhalbtc92e_init_coex_dm(struct btc_coexist *btcoexist); +void exhalbtc92e_ips_notify(struct btc_coexist *btcoexist, u8 type); +void exhalbtc92e_lps_notify(struct btc_coexist *btcoexist, u8 type); +void exhalbtc92e_scan_notify(struct btc_coexist *btcoexist, u8 type); +void exhalbtc92e_connect_notify(struct btc_coexist *btcoexist, u8 action); +void exhalbtc92e_mediastatus_notify(struct btc_coexist *btcoexist, + enum rt_media_status media_status); +void exhalbtc92e_special_packet_notify(struct btc_coexist *btcoexist, + u8 pkt_type); +void exhalbtc92e_bt_info_notify(struct btc_coexist *btcoexist, u8 *tmp_buf, + u8 length); +void exhalbtc92e_stack_operation_notify(struct btc_coexist *btcoexist, u8 type); +void exhalbtc92e_halt_notify(struct btc_coexist *btcoexist); +void exhalbtc92e_pnp_notify(struct btc_coexist *btcoexist, u8 pnp_state); +void exhalbtc_coex_dm_switch(struct btc_coexist *btcoexist); +void exhalbtc92e_periodical(struct btc_coexist *btcoexist); +void exhalbtc92e_dbg_control(struct btc_coexist *btcoexist, u8 code, u8 len, + u8 *data); +void exhalbtc92e_stack_update_profile_info(void); +void exhalbtc92e_set_hci_version(u16 hci_version); +void exhalbtc92e_set_bt_patch_version(u16 bt_hci_version, u16 bt_patch_version); +void exhalbtc92e_update_min_bt_rssi(char bt_rssi); +void exhalbtc92e_set_bt_exist(bool bt_exist); +void exhalbtc92e_set_chip_type(u8 chip_type); +void exhalbtc92e_set_ant_num(u8 type, u8 ant_num); +void exhalbtc92e_display_bt_coex_info(struct btc_coexist *btcoexist); +void exhalbtc_signal_compensation(struct btc_coexist *btcoexist, + u8 *rssi_wifi, u8 *rssi_bt); +void exhalbtc_lps_leave(struct btc_coexist *btcoexist); +void exhalbtc_low_wifi_traffic_notify(struct btc_coexist *btcoexist); +#endif diff --git a/drivers/staging/rtl8192ee/btcoexist/rtl_btc.c b/drivers/staging/rtl8192ee/btcoexist/rtl_btc.c new file mode 100644 index 000000000000..50c012a4c174 --- /dev/null +++ b/drivers/staging/rtl8192ee/btcoexist/rtl_btc.c @@ -0,0 +1,194 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ +#include +#include + +#include "rtl_btc.h" +#include "halbt_precomp.h" + +static struct rtl_btc_ops rtl_btc_operation = { + .btc_init_variables = rtl92e_btc_init_variables, + .btc_init_hal_vars = rtl92e_btc_init_hal_vars, + .btc_init_hw_config = rtl92e_btc_init_hw_config, + .btc_ips_notify = rtl92e_btc_ips_notify, + .btc_lps_notify = rtl_btc_lps_notify, + .btc_scan_notify = rtl92e_btc_scan_notify, + .btc_connect_notify = rtl92e_btc_connect_notify, + .btc_mediastatus_notify = rtl92e_btc_mediastatus_notify, + .btc_periodical = rtl92e_btc_periodical, + .btc_halt_notify = rtl92e_btc_halt_notify, + .btc_btinfo_notify = rtl92e_btc_btinfo_notify, + .btc_is_limited_dig = rtl92e_btc_is_limited_dig, + .btc_is_disable_edca_turbo = rtl92e_btc_is_disable_edca_turbo, + .btc_is_bt_disabled = rtl92e_btc_is_bt_disabled, + .btc_special_packet_notify = rtl_btc_special_packet_notify, +}; + +void rtl92e_btc_init_variables(struct rtl_priv *rtlpriv) +{ + exhalbtc92e_initlize_variables(rtlpriv); +} + +void rtl92e_btc_init_hal_vars(struct rtl_priv *rtlpriv) +{ + u8 ant_num; + u8 bt_exist; + u8 bt_type; + ant_num = rtl92e_get_hwpg_ant_num(rtlpriv); + RT_TRACE(COMP_INIT, DBG_DMESG, + ("%s, antNum is %d\n", __func__, ant_num)); + + bt_exist = rtl92e_get_hwpg_bt_exist(rtlpriv); + RT_TRACE(COMP_INIT, DBG_DMESG, + ("%s, bt_exist is %d\n", __func__, bt_exist)); + exhalbtc92e_set_bt_exist(bt_exist); + + bt_type = rtl92e_get_hwpg_bt_type(rtlpriv); + RT_TRACE(COMP_INIT, DBG_DMESG, + ("%s, bt_type is %d\n", __func__, bt_type)); + exhalbtc92e_set_chip_type(bt_type); + + exhalbtc92e_set_ant_num(BT_COEX_ANT_TYPE_PG, ant_num); +} + +void rtl92e_btc_init_hw_config(struct rtl_priv *rtlpriv) +{ + exhalbtc92e_init_hw_config(&gl92e_bt_coexist); + exhalbtc92e_init_coex_dm(&gl92e_bt_coexist); +} + +void rtl92e_btc_ips_notify(struct rtl_priv *rtlpriv, u8 type) +{ + exhalbtc92e_ips_notify(&gl92e_bt_coexist, type); +} + +void rtl_btc_lps_notify(struct rtl_priv *rtlpriv, u8 type) +{ + exhalbtc92e_lps_notify(&gl92e_bt_coexist, type); +} + +void rtl92e_btc_scan_notify(struct rtl_priv *rtlpriv, u8 scantype) +{ + exhalbtc92e_scan_notify(&gl92e_bt_coexist, scantype); +} + +void rtl92e_btc_connect_notify(struct rtl_priv *rtlpriv, u8 action) +{ + exhalbtc92e_connect_notify(&gl92e_bt_coexist, action); +} + +void rtl92e_btc_mediastatus_notify(struct rtl_priv *rtlpriv, + enum rt_media_status mstatus) +{ + exhalbtc92e_mediastatus_notify(&gl92e_bt_coexist, mstatus); +} + +void rtl92e_btc_periodical(struct rtl_priv *rtlpriv) +{ + exhalbtc92e_periodical(&gl92e_bt_coexist); +} + +void rtl92e_btc_halt_notify(void) +{ + exhalbtc92e_halt_notify(&gl92e_bt_coexist); +} + +void rtl92e_btc_btinfo_notify(struct rtl_priv *rtlpriv, u8 *tmp_buf, u8 length) +{ + exhalbtc92e_bt_info_notify(&gl92e_bt_coexist, tmp_buf, length); +} + +bool rtl92e_btc_is_limited_dig(struct rtl_priv *rtlpriv) +{ + return gl92e_bt_coexist.bt_info.limited_dig; +} + +bool rtl92e_btc_is_disable_edca_turbo(struct rtl_priv *rtlpriv) +{ + bool bt_change_edca = false; + u32 cur_edca_val; + u32 edca_bt_hs_uplink = 0x5ea42b, edca_bt_hs_downlink = 0x5ea42b; + u32 edca_hs; + u32 edca_addr = 0x504; + + cur_edca_val = rtl_read_dword(rtlpriv, edca_addr); + if (halbtc92e_is_wifi_uplink(rtlpriv)) { + if (cur_edca_val != edca_bt_hs_uplink) { + edca_hs = edca_bt_hs_uplink; + bt_change_edca = true; + } + } else { + if (cur_edca_val != edca_bt_hs_downlink) { + edca_hs = edca_bt_hs_downlink; + bt_change_edca = true; + } + } + + if (bt_change_edca) + rtl_write_dword(rtlpriv, edca_addr, edca_hs); + + return true; +} + +bool rtl92e_btc_is_bt_disabled(struct rtl_priv *rtlpriv) +{ + /* It seems 'bt_disabled' is never be initialized or set. */ + if (gl92e_bt_coexist.bt_info.bt_disabled) + return true; + else + return false; +} + +void rtl_btc_special_packet_notify(struct rtl_priv *rtlpriv, u8 pkt_type) +{ + return exhalbtc92e_special_packet_notify(&gl92e_bt_coexist, pkt_type); +} + +struct rtl_btc_ops *stg_rtl_btc_get_ops_pointer(void) +{ + return &rtl_btc_operation; +} +EXPORT_SYMBOL(stg_rtl_btc_get_ops_pointer); + +u8 rtl92e_get_hwpg_ant_num(struct rtl_priv *rtlpriv) +{ + u8 num; + + if (rtlpriv->btcoexist.btc_info.ant_num == ANT_X2) + num = 2; + else + num = 1; + + return num; +} +u8 rtl92e_get_hwpg_bt_exist(struct rtl_priv *rtlpriv) +{ + return rtlpriv->btcoexist.btc_info.btcoexist; +} + +u8 rtl92e_get_hwpg_bt_type(struct rtl_priv *rtlpriv) +{ + return rtlpriv->btcoexist.btc_info.bt_type; +} diff --git a/drivers/staging/rtl8192ee/btcoexist/rtl_btc.h b/drivers/staging/rtl8192ee/btcoexist/rtl_btc.h new file mode 100644 index 000000000000..9530eb1a6649 --- /dev/null +++ b/drivers/staging/rtl8192ee/btcoexist/rtl_btc.h @@ -0,0 +1,62 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * Larry Finger + * + *****************************************************************************/ + +#ifndef __RTL_BTC_H__ +#define __RTL_BTC_H__ + +#include "halbt_precomp.h" + +void rtl92e_btc_init_variables(struct rtl_priv *rtlpriv); +void rtl92e_btc_init_hal_vars(struct rtl_priv *rtlpriv); +void rtl92e_btc_init_hw_config(struct rtl_priv *rtlpriv); +void rtl92e_btc_ips_notify(struct rtl_priv *rtlpriv, u8 type); +void rtl_btc_lps_notify(struct rtl_priv *rtlpriv, u8 type); +void rtl92e_btc_scan_notify(struct rtl_priv *rtlpriv, u8 scantype); +void rtl92e_btc_connect_notify(struct rtl_priv *rtlpriv, u8 action); +void rtl92e_btc_mediastatus_notify(struct rtl_priv *rtlpriv, + enum rt_media_status mstatus); +void rtl92e_btc_periodical(struct rtl_priv *rtlpriv); +void rtl92e_btc_halt_notify(void); +void rtl92e_btc_btinfo_notify(struct rtl_priv *rtlpriv, u8 *tmpbuf, u8 length); +bool rtl92e_btc_is_limited_dig(struct rtl_priv *rtlpriv); +bool rtl92e_btc_is_disable_edca_turbo(struct rtl_priv *rtlpriv); +bool rtl92e_btc_is_bt_disabled(struct rtl_priv *rtlpriv); +void rtl_btc_special_packet_notify(struct rtl_priv *rtlpriv, u8 pkt_type); + + +struct rtl_btc_ops *stg_rtl_btc_get_ops_pointer(void); + +u8 rtl92e_get_hwpg_ant_num(struct rtl_priv *rtlpriv); +u8 rtl92e_get_hwpg_bt_exist(struct rtl_priv *rtlpriv); +u8 rtl92e_get_hwpg_bt_type(struct rtl_priv *rtlpriv); +enum rt_media_status mgnt_link_status_query(struct ieee80211_hw *hw); + + + + + + + + +#endif -- cgit v1.2.3 From 0338f0c2e2420505ae815c57a79f7f553a8071bf Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 May 2014 16:25:35 -0500 Subject: staging: r8192ee: Add the files in the rtl8192ee directory These files are specific to the RTL8192EE Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192ee/rtl8192ee/def.h | 106 + drivers/staging/rtl8192ee/rtl8192ee/dm.c | 1258 +++++++++ drivers/staging/rtl8192ee/rtl8192ee/dm.h | 343 +++ drivers/staging/rtl8192ee/rtl8192ee/fw.c | 945 +++++++ drivers/staging/rtl8192ee/rtl8192ee/fw.h | 213 ++ drivers/staging/rtl8192ee/rtl8192ee/hw.c | 2544 ++++++++++++++++++ drivers/staging/rtl8192ee/rtl8192ee/hw.h | 67 + drivers/staging/rtl8192ee/rtl8192ee/led.c | 134 + drivers/staging/rtl8192ee/rtl8192ee/led.h | 37 + drivers/staging/rtl8192ee/rtl8192ee/phy.c | 3282 +++++++++++++++++++++++ drivers/staging/rtl8192ee/rtl8192ee/phy.h | 154 ++ drivers/staging/rtl8192ee/rtl8192ee/pwrseq.c | 108 + drivers/staging/rtl8192ee/rtl8192ee/pwrseq.h | 355 +++ drivers/staging/rtl8192ee/rtl8192ee/pwrseqcmd.c | 139 + drivers/staging/rtl8192ee/rtl8192ee/pwrseqcmd.h | 69 + drivers/staging/rtl8192ee/rtl8192ee/reg.h | 2240 ++++++++++++++++ drivers/staging/rtl8192ee/rtl8192ee/rf.c | 150 ++ drivers/staging/rtl8192ee/rtl8192ee/rf.h | 39 + drivers/staging/rtl8192ee/rtl8192ee/sw.c | 428 +++ drivers/staging/rtl8192ee/rtl8192ee/sw.h | 39 + drivers/staging/rtl8192ee/rtl8192ee/table.c | 882 ++++++ drivers/staging/rtl8192ee/rtl8192ee/table.h | 48 + drivers/staging/rtl8192ee/rtl8192ee/trx.c | 1286 +++++++++ drivers/staging/rtl8192ee/rtl8192ee/trx.h | 877 ++++++ 24 files changed, 15743 insertions(+) create mode 100644 drivers/staging/rtl8192ee/rtl8192ee/def.h create mode 100644 drivers/staging/rtl8192ee/rtl8192ee/dm.c create mode 100644 drivers/staging/rtl8192ee/rtl8192ee/dm.h create mode 100644 drivers/staging/rtl8192ee/rtl8192ee/fw.c create mode 100644 drivers/staging/rtl8192ee/rtl8192ee/fw.h create mode 100644 drivers/staging/rtl8192ee/rtl8192ee/hw.c create mode 100644 drivers/staging/rtl8192ee/rtl8192ee/hw.h create mode 100644 drivers/staging/rtl8192ee/rtl8192ee/led.c create mode 100644 drivers/staging/rtl8192ee/rtl8192ee/led.h create mode 100644 drivers/staging/rtl8192ee/rtl8192ee/phy.c create mode 100644 drivers/staging/rtl8192ee/rtl8192ee/phy.h create mode 100644 drivers/staging/rtl8192ee/rtl8192ee/pwrseq.c create mode 100644 drivers/staging/rtl8192ee/rtl8192ee/pwrseq.h create mode 100644 drivers/staging/rtl8192ee/rtl8192ee/pwrseqcmd.c create mode 100644 drivers/staging/rtl8192ee/rtl8192ee/pwrseqcmd.h create mode 100644 drivers/staging/rtl8192ee/rtl8192ee/reg.h create mode 100644 drivers/staging/rtl8192ee/rtl8192ee/rf.c create mode 100644 drivers/staging/rtl8192ee/rtl8192ee/rf.h create mode 100644 drivers/staging/rtl8192ee/rtl8192ee/sw.c create mode 100644 drivers/staging/rtl8192ee/rtl8192ee/sw.h create mode 100644 drivers/staging/rtl8192ee/rtl8192ee/table.c create mode 100644 drivers/staging/rtl8192ee/rtl8192ee/table.h create mode 100644 drivers/staging/rtl8192ee/rtl8192ee/trx.c create mode 100644 drivers/staging/rtl8192ee/rtl8192ee/trx.h diff --git a/drivers/staging/rtl8192ee/rtl8192ee/def.h b/drivers/staging/rtl8192ee/rtl8192ee/def.h new file mode 100644 index 000000000000..7566c1e8baeb --- /dev/null +++ b/drivers/staging/rtl8192ee/rtl8192ee/def.h @@ -0,0 +1,106 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#ifndef __RTL92E_DEF_H__ +#define __RTL92E_DEF_H__ + +#define RX_DESC_NUM_92E 512 + +#define HAL_PRIME_CHNL_OFFSET_DONT_CARE 0 +#define HAL_PRIME_CHNL_OFFSET_LOWER 1 +#define HAL_PRIME_CHNL_OFFSET_UPPER 2 + +#define RX_MPDU_QUEUE 0 + +#define IS_HT_RATE(_rate) \ + (_rate >= DESC92C_RATEMCS0) +#define IS_CCK_RATE(_rate) \ + (_rate >= DESC92C_RATE1M && _rate <= DESC92C_RATE11M) +#define IS_OFDM_RATE(_rate) \ + (_rate >= DESC92C_RATE6M && _rate <= DESC92C_RATE54M) + + +enum version_8192e { + VERSION_TEST_CHIP_2T2R_8192E = 0x0024, + VERSION_NORMAL_CHIP_2T2R_8192E = 0x102C, + VERSION_UNKNOWN = 0xFF, +}; + +enum rx_packet_type { + NORMAL_RX, + TX_REPORT1, + TX_REPORT2, + HIS_REPORT, + C2H_PACKET, +}; + +enum rtl_desc_qsel { + QSLT_BK = 0x2, + QSLT_BE = 0x0, + QSLT_VI = 0x5, + QSLT_VO = 0x7, + QSLT_BEACON = 0x10, + QSLT_HIGH = 0x11, + QSLT_MGNT = 0x12, + QSLT_CMD = 0x13, +}; + +enum rtl_desc92c_rate { + DESC92C_RATE1M = 0x00, + DESC92C_RATE2M = 0x01, + DESC92C_RATE5_5M = 0x02, + DESC92C_RATE11M = 0x03, + + DESC92C_RATE6M = 0x04, + DESC92C_RATE9M = 0x05, + DESC92C_RATE12M = 0x06, + DESC92C_RATE18M = 0x07, + DESC92C_RATE24M = 0x08, + DESC92C_RATE36M = 0x09, + DESC92C_RATE48M = 0x0a, + DESC92C_RATE54M = 0x0b, + + DESC92C_RATEMCS0 = 0x0c, + DESC92C_RATEMCS1 = 0x0d, + DESC92C_RATEMCS2 = 0x0e, + DESC92C_RATEMCS3 = 0x0f, + DESC92C_RATEMCS4 = 0x10, + DESC92C_RATEMCS5 = 0x11, + DESC92C_RATEMCS6 = 0x12, + DESC92C_RATEMCS7 = 0x13, + DESC92C_RATEMCS8 = 0x14, + DESC92C_RATEMCS9 = 0x15, + DESC92C_RATEMCS10 = 0x16, + DESC92C_RATEMCS11 = 0x17, + DESC92C_RATEMCS12 = 0x18, + DESC92C_RATEMCS13 = 0x19, + DESC92C_RATEMCS14 = 0x1a, + DESC92C_RATEMCS15 = 0x1b, +}; +#endif diff --git a/drivers/staging/rtl8192ee/rtl8192ee/dm.c b/drivers/staging/rtl8192ee/rtl8192ee/dm.c new file mode 100644 index 000000000000..41c2d98e81db --- /dev/null +++ b/drivers/staging/rtl8192ee/rtl8192ee/dm.c @@ -0,0 +1,1258 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#include "../wifi.h" +#include "../base.h" +#include "../pci.h" +#include "reg.h" +#include "def.h" +#include "phy.h" +#include "dm.h" +#include "fw.h" +#include "trx.h" + +struct dig_t dm_dig; + +static const u32 ofdmswing_table[OFDM_TABLE_SIZE] = { + 0x7f8001fe, /* 0, +6.0dB */ + 0x788001e2, /* 1, +5.5dB */ + 0x71c001c7, /* 2, +5.0dB */ + 0x6b8001ae, /* 3, +4.5dB */ + 0x65400195, /* 4, +4.0dB */ + 0x5fc0017f, /* 5, +3.5dB */ + 0x5a400169, /* 6, +3.0dB */ + 0x55400155, /* 7, +2.5dB */ + 0x50800142, /* 8, +2.0dB */ + 0x4c000130, /* 9, +1.5dB */ + 0x47c0011f, /* 10, +1.0dB */ + 0x43c0010f, /* 11, +0.5dB */ + 0x40000100, /* 12, +0dB */ + 0x3c8000f2, /* 13, -0.5dB */ + 0x390000e4, /* 14, -1.0dB */ + 0x35c000d7, /* 15, -1.5dB */ + 0x32c000cb, /* 16, -2.0dB */ + 0x300000c0, /* 17, -2.5dB */ + 0x2d4000b5, /* 18, -3.0dB */ + 0x2ac000ab, /* 19, -3.5dB */ + 0x288000a2, /* 20, -4.0dB */ + 0x26000098, /* 21, -4.5dB */ + 0x24000090, /* 22, -5.0dB */ + 0x22000088, /* 23, -5.5dB */ + 0x20000080, /* 24, -6.0dB */ + 0x1e400079, /* 25, -6.5dB */ + 0x1c800072, /* 26, -7.0dB */ + 0x1b00006c, /* 27. -7.5dB */ + 0x19800066, /* 28, -8.0dB */ + 0x18000060, /* 29, -8.5dB */ + 0x16c0005b, /* 30, -9.0dB */ + 0x15800056, /* 31, -9.5dB */ + 0x14400051, /* 32, -10.0dB */ + 0x1300004c, /* 33, -10.5dB */ + 0x12000048, /* 34, -11.0dB */ + 0x11000044, /* 35, -11.5dB */ + 0x10000040, /* 36, -12.0dB */ + 0x0f00003c, /* 37, -12.5dB */ + 0x0e400039, /* 38, -13.0dB */ + 0x0d800036, /* 39, -13.5dB */ + 0x0cc00033, /* 40, -14.0dB */ + 0x0c000030, /* 41, -14.5dB */ + 0x0b40002d, /* 42, -15.0dB */ +}; + +static const u8 cckswing_table_ch1ch13[CCK_TABLE_SIZE][8] = { + {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}, /* 0, +0dB */ + {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04}, /* 1, -0.5dB */ + {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, /* 2, -1.0dB */ + {0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03}, /* 3, -1.5dB */ + {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, /* 4, -2.0dB */ + {0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03}, /* 5, -2.5dB */ + {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03}, /* 6, -3.0dB */ + {0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03}, /* 7, -3.5dB */ + {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02}, /* 8, -4.0dB */ + {0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02}, /* 9, -4.5dB */ + {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02}, /* 10, -5.0dB */ + {0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02}, /* 11, -5.5dB */ + {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02}, /* 12, -6.0dB */ + {0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02}, /* 13, -6.5dB */ + {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02}, /* 14, -7.0dB */ + {0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02}, /* 15, -7.5dB */ + {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01}, /* 16, -8.0dB */ + {0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02}, /* 17, -8.5dB */ + {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01}, /* 18, -9.0dB */ + {0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, /* 19, -9.5dB */ + {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, /* 20, -10.0dB */ + {0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01}, /* 21, -10.5dB */ + {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01}, /* 22, -11.0dB */ + {0x0e, 0x0e, 0x0c, 0x0a, 0x08, 0x05, 0x02, 0x01}, /* 23, -11.5dB */ + {0x0d, 0x0d, 0x0c, 0x0a, 0x07, 0x05, 0x02, 0x01}, /* 24, -12.0dB */ + {0x0d, 0x0c, 0x0b, 0x09, 0x07, 0x04, 0x02, 0x01}, /* 25, -12.5dB */ + {0x0c, 0x0c, 0x0a, 0x09, 0x06, 0x04, 0x02, 0x01}, /* 26, -13.0dB */ + {0x0b, 0x0b, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01}, /* 27, -13.5dB */ + {0x0b, 0x0a, 0x09, 0x08, 0x06, 0x04, 0x02, 0x01}, /* 28, -14.0dB */ + {0x0a, 0x0a, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01}, /* 29, -14.5dB */ + {0x0a, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01}, /* 30, -15.0dB */ + {0x09, 0x09, 0x08, 0x06, 0x05, 0x03, 0x01, 0x01}, /* 31, -15.5dB */ + {0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01} /* 32, -16.0dB */ +}; + +static const u8 cckswing_table_ch14[CCK_TABLE_SIZE][8] = { + {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00}, /* 0, +0dB */ + {0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00}, /* 1, -0.5dB */ + {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, /* 2, -1.0dB */ + {0x2d, 0x2d, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00}, /* 3, -1.5dB */ + {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, /* 4, -2.0dB */ + {0x28, 0x28, 0x24, 0x14, 0x00, 0x00, 0x00, 0x00}, /* 5, -2.5dB */ + {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00}, /* 6, -3.0dB */ + {0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00}, /* 7, -3.5dB */ + {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00}, /* 8, -4.0dB */ + {0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00}, /* 9, -4.5dB */ + {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00}, /* 10, -5.0dB */ + {0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00}, /* 11, -5.5dB */ + {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00}, /* 12, -6.0dB */ + {0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00}, /* 13, -6.5dB */ + {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00}, /* 14, -7.0dB */ + {0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00}, /* 15, -7.5dB */ + {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00}, /* 16, -8.0dB */ + {0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00}, /* 17, -8.5dB */ + {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00}, /* 18, -9.0dB */ + {0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, /* 19, -9.5dB */ + {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, /* 20, -10.0dB */ + {0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00}, /* 21, -10.5dB */ + {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00}, /* 22, -11.0dB */ + {0x0e, 0x0e, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, /* 23, -11.5dB */ + {0x0d, 0x0d, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, /* 24, -12.0dB */ + {0x0d, 0x0c, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 25, -12.5dB */ + {0x0c, 0x0c, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 26, -13.0dB */ + {0x0b, 0x0b, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 27, -13.5dB */ + {0x0b, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 28, -14.0dB */ + {0x0a, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 29, -14.5dB */ + {0x0a, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 30, -15.0dB */ + {0x09, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 31, -15.5dB */ + {0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00} /* 32, -16.0dB */ +}; + +static void rtl92ee_dm_diginit(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + dm_dig.cur_igvalue = rtl_get_bbreg(hw, DM_REG_IGI_A_11N, + DM_BIT_IGI_11N); + dm_dig.rssi_lowthresh = DM_DIG_THRESH_LOW; + dm_dig.rssi_highthresh = DM_DIG_THRESH_HIGH; + dm_dig.fa_lowthresh = DM_FALSEALARM_THRESH_LOW; + dm_dig.fa_highthresh = DM_FALSEALARM_THRESH_HIGH; + dm_dig.rx_gain_range_max = DM_DIG_MAX; + dm_dig.rx_gain_range_min = DM_DIG_MIN; + dm_dig.backoff_val = DM_DIG_BACKOFF_DEFAULT; + dm_dig.backoff_val_range_max = DM_DIG_BACKOFF_MAX; + dm_dig.backoff_val_range_min = DM_DIG_BACKOFF_MIN; + dm_dig.pre_cck_cca_thres = 0xff; + dm_dig.cur_cck_cca_thres = 0x83; + dm_dig.forbidden_igi = DM_DIG_MIN; + dm_dig.large_fa_hit = 0; + dm_dig.recover_cnt = 0; + dm_dig.dig_dynamic_min_0 = DM_DIG_MIN; + dm_dig.dig_dynamic_min_1 = DM_DIG_MIN; + dm_dig.b_media_connect_0 = false; + dm_dig.b_media_connect_1 = false; + rtlpriv->dm.b_dm_initialgain_enable = true; + dm_dig.bt30_cur_igi = 0x32; +} + +static void rtl92ee_dm_false_alarm_counter_statistics(struct ieee80211_hw *hw) +{ + u32 ret_value; + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct false_alarm_statistics *falsealm_cnt = &(rtlpriv->falsealm_cnt); + + rtl_set_bbreg(hw, DM_REG_OFDM_FA_HOLDC_11N, BIT(31), 1); + rtl_set_bbreg(hw, DM_REG_OFDM_FA_RSTD_11N, BIT(31), 1); + + ret_value = rtl_get_bbreg(hw, DM_REG_OFDM_FA_TYPE1_11N, MASKDWORD); + falsealm_cnt->cnt_fast_fsync_fail = (ret_value & 0xffff); + falsealm_cnt->cnt_sb_search_fail = ((ret_value & 0xffff0000) >> 16); + + ret_value = rtl_get_bbreg(hw, DM_REG_OFDM_FA_TYPE2_11N, MASKDWORD); + falsealm_cnt->cnt_ofdm_cca = (ret_value & 0xffff); + falsealm_cnt->cnt_parity_fail = ((ret_value & 0xffff0000) >> 16); + + ret_value = rtl_get_bbreg(hw, DM_REG_OFDM_FA_TYPE3_11N, MASKDWORD); + falsealm_cnt->cnt_rate_illegal = (ret_value & 0xffff); + falsealm_cnt->cnt_crc8_fail = ((ret_value & 0xffff0000) >> 16); + + ret_value = rtl_get_bbreg(hw, DM_REG_OFDM_FA_TYPE4_11N, MASKDWORD); + falsealm_cnt->cnt_mcs_fail = (ret_value & 0xffff); + + falsealm_cnt->cnt_ofdm_fail = falsealm_cnt->cnt_parity_fail + + falsealm_cnt->cnt_rate_illegal + + falsealm_cnt->cnt_crc8_fail + + falsealm_cnt->cnt_mcs_fail + + falsealm_cnt->cnt_fast_fsync_fail + + falsealm_cnt->cnt_sb_search_fail; + + ret_value = rtl_get_bbreg(hw, DM_REG_SC_CNT_11N, MASKDWORD); + falsealm_cnt->cnt_bw_lsc = (ret_value & 0xffff); + falsealm_cnt->cnt_bw_usc = ((ret_value & 0xffff0000) >> 16); + + rtl_set_bbreg(hw, DM_REG_CCK_FA_RST_11N, BIT(12), 1); + rtl_set_bbreg(hw, DM_REG_CCK_FA_RST_11N, BIT(14), 1); + + ret_value = rtl_get_bbreg(hw, DM_REG_CCK_FA_LSB_11N, MASKBYTE0); + falsealm_cnt->cnt_cck_fail = ret_value; + + ret_value = rtl_get_bbreg(hw, DM_REG_CCK_FA_MSB_11N, MASKBYTE3); + falsealm_cnt->cnt_cck_fail += (ret_value & 0xff) << 8; + + ret_value = rtl_get_bbreg(hw, DM_REG_CCK_CCA_CNT_11N, MASKDWORD); + falsealm_cnt->cnt_cck_cca = ((ret_value & 0xff) << 8) | + ((ret_value & 0xFF00) >> 8); + + falsealm_cnt->cnt_all = falsealm_cnt->cnt_fast_fsync_fail + + falsealm_cnt->cnt_sb_search_fail + + falsealm_cnt->cnt_parity_fail + + falsealm_cnt->cnt_rate_illegal + + falsealm_cnt->cnt_crc8_fail + + falsealm_cnt->cnt_mcs_fail + + falsealm_cnt->cnt_cck_fail; + + falsealm_cnt->cnt_cca_all = falsealm_cnt->cnt_ofdm_cca + + falsealm_cnt->cnt_cck_cca; + + /*reset false alarm counter registers*/ + rtl_set_bbreg(hw, DM_REG_OFDM_FA_RSTC_11N, BIT(31), 1); + rtl_set_bbreg(hw, DM_REG_OFDM_FA_RSTC_11N, BIT(31), 0); + rtl_set_bbreg(hw, DM_REG_OFDM_FA_RSTD_11N, BIT(27), 1); + rtl_set_bbreg(hw, DM_REG_OFDM_FA_RSTD_11N, BIT(27), 0); + /*update ofdm counter*/ + rtl_set_bbreg(hw, DM_REG_OFDM_FA_HOLDC_11N, BIT(31), 0); + rtl_set_bbreg(hw, DM_REG_OFDM_FA_RSTD_11N, BIT(31), 0); + /*reset CCK CCA counter*/ + rtl_set_bbreg(hw, DM_REG_CCK_FA_RST_11N, BIT(13) | BIT(12), 0); + rtl_set_bbreg(hw, DM_REG_CCK_FA_RST_11N, BIT(13) | BIT(12), 2); + /*reset CCK FA counter*/ + rtl_set_bbreg(hw, DM_REG_CCK_FA_RST_11N, BIT(15) | BIT(14), 0); + rtl_set_bbreg(hw, DM_REG_CCK_FA_RST_11N, BIT(15) | BIT(14), 2); + + + RT_TRACE(COMP_DIG, DBG_TRACE, + ("cnt_parity_fail = %d, cnt_rate_illegal = %d, " + "cnt_crc8_fail = %d, cnt_mcs_fail = %d\n", + falsealm_cnt->cnt_parity_fail, + falsealm_cnt->cnt_rate_illegal, + falsealm_cnt->cnt_crc8_fail, falsealm_cnt->cnt_mcs_fail)); + + RT_TRACE(COMP_DIG, DBG_TRACE, + ("cnt_ofdm_fail = %x, cnt_cck_fail = %x, cnt_all = %x\n", + falsealm_cnt->cnt_ofdm_fail, + falsealm_cnt->cnt_cck_fail, falsealm_cnt->cnt_all)); +} + +static void rtl92ee_dm_cck_packet_detection_thresh(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u8 cur_cck_cca_thresh; + if (rtlpriv->mac80211.link_state >= MAC80211_LINKED) { + if (dm_dig.rssi_val_min > 25) { + cur_cck_cca_thresh = 0xcd; + } else if ((dm_dig.rssi_val_min <= 25) && + (dm_dig.rssi_val_min > 10)) { + cur_cck_cca_thresh = 0x83; + } else { + if (rtlpriv->falsealm_cnt.cnt_cck_fail > 1000) + cur_cck_cca_thresh = 0x83; + else + cur_cck_cca_thresh = 0x40; + } + } else { + if (rtlpriv->falsealm_cnt.cnt_cck_fail > 1000) + cur_cck_cca_thresh = 0x83; + else + cur_cck_cca_thresh = 0x40; + } + rtl92ee_dm_write_cck_cca_thres(hw, cur_cck_cca_thresh); +} + +static void rtl92ee_dm_dig(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + u8 dig_dynamic_min , dig_maxofmin; + bool bfirstconnect , bfirstdisconnect; + u8 dm_dig_max, dm_dig_min; + u8 current_igi = dm_dig.cur_igvalue; + u8 offset; + + /* AP, BT */ + if (mac->act_scanning == true) + return; + + dig_dynamic_min = dm_dig.dig_dynamic_min_0; + bfirstconnect = (mac->link_state >= MAC80211_LINKED) && + (dm_dig.b_media_connect_0 == false); + bfirstdisconnect = (mac->link_state < MAC80211_LINKED) && + (dm_dig.b_media_connect_0 == true); + + dm_dig_max = 0x5a; + dm_dig_min = DM_DIG_MIN; + dig_maxofmin = DM_DIG_MAX_AP; + + if (mac->link_state >= MAC80211_LINKED) { + if ((dm_dig.rssi_val_min + 10) > dm_dig_max) + dm_dig.rx_gain_range_max = dm_dig_max; + else if ((dm_dig.rssi_val_min + 10) < dm_dig_min) + dm_dig.rx_gain_range_max = dm_dig_min; + else + dm_dig.rx_gain_range_max = dm_dig.rssi_val_min + 10; + + if (rtlpriv->dm.b_one_entry_only) { + offset = 0; + if (dm_dig.rssi_val_min - offset < dm_dig_min) + dig_dynamic_min = dm_dig_min; + else if (dm_dig.rssi_val_min - offset > + dig_maxofmin) + dig_dynamic_min = dig_maxofmin; + else + dig_dynamic_min = dm_dig.rssi_val_min - offset; + } else { + dig_dynamic_min = dm_dig_min; + } + + } else { + dm_dig.rx_gain_range_max = dm_dig_max; + dig_dynamic_min = dm_dig_min; + RT_TRACE(COMP_DIG, DBG_LOUD, ("no link\n")); + } + + if (rtlpriv->falsealm_cnt.cnt_all > 10000) { + if (dm_dig.large_fa_hit != 3) + dm_dig.large_fa_hit++; + if (dm_dig.forbidden_igi < current_igi) { + dm_dig.forbidden_igi = current_igi; + dm_dig.large_fa_hit = 1; + } + + if (dm_dig.large_fa_hit >= 3) { + if (dm_dig.forbidden_igi + 1 > dm_dig.rx_gain_range_max) + dm_dig.rx_gain_range_min = + dm_dig.rx_gain_range_max; + else + dm_dig.rx_gain_range_min = + dm_dig.forbidden_igi + 1; + dm_dig.recover_cnt = 3600; + } + } else { + if (dm_dig.recover_cnt != 0) { + dm_dig.recover_cnt--; + } else { + if (dm_dig.large_fa_hit < 3) { + if ((dm_dig.forbidden_igi - 1) < + dig_dynamic_min) { + dm_dig.forbidden_igi = dig_dynamic_min; + dm_dig.rx_gain_range_min = + dig_dynamic_min; + } else { + dm_dig.forbidden_igi--; + dm_dig.rx_gain_range_min = + dm_dig.forbidden_igi + 1; + } + } else { + dm_dig.large_fa_hit = 0; + } + } + } + + if (rtlpriv->dm.dbginfo.num_qry_beacon_pkt < 5) + dm_dig.rx_gain_range_min = dm_dig_min; + + if (dm_dig.rx_gain_range_min > dm_dig.rx_gain_range_max) + dm_dig.rx_gain_range_min = dm_dig.rx_gain_range_max; + + if (mac->link_state >= MAC80211_LINKED) { + if (bfirstconnect) { + if (dm_dig.rssi_val_min <= dig_maxofmin) + current_igi = dm_dig.rssi_val_min; + else + current_igi = dig_maxofmin; + + dm_dig.large_fa_hit = 0; + } else { + if (rtlpriv->falsealm_cnt.cnt_all > DM_DIG_FA_TH2) + current_igi += 4; + else if (rtlpriv->falsealm_cnt.cnt_all > DM_DIG_FA_TH1) + current_igi += 2; + else if (rtlpriv->falsealm_cnt.cnt_all < DM_DIG_FA_TH0) + current_igi -= 2; + + if (rtlpriv->dm.dbginfo.num_qry_beacon_pkt < 5 && + rtlpriv->falsealm_cnt.cnt_all < DM_DIG_FA_TH1) + current_igi = dm_dig.rx_gain_range_min; + } + } else { + if (bfirstdisconnect) { + current_igi = dm_dig.rx_gain_range_min; + } else { + if (rtlpriv->falsealm_cnt.cnt_all > 10000) + current_igi += 4; + else if (rtlpriv->falsealm_cnt.cnt_all > 8000) + current_igi += 2; + else if (rtlpriv->falsealm_cnt.cnt_all < 500) + current_igi -= 2; + } + } + + if (current_igi > dm_dig.rx_gain_range_max) + current_igi = dm_dig.rx_gain_range_max; + if (current_igi < dm_dig.rx_gain_range_min) + current_igi = dm_dig.rx_gain_range_min; + + rtl92ee_dm_write_dig(hw , current_igi); + dm_dig.b_media_connect_0 = ((mac->link_state >= MAC80211_LINKED) ? + true : false); + dm_dig.dig_dynamic_min_0 = dig_dynamic_min; +} + +void rtl92ee_dm_write_cck_cca_thres(struct ieee80211_hw *hw, u8 cur_thres) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + if (dm_dig.cur_cck_cca_thres != cur_thres) + rtl_write_byte(rtlpriv, DM_REG_CCK_CCA_11N, cur_thres); + + dm_dig.pre_cck_cca_thres = dm_dig.cur_cck_cca_thres; + dm_dig.cur_cck_cca_thres = cur_thres; +} + +void rtl92ee_dm_write_dig(struct ieee80211_hw *hw, u8 current_igi) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + if (dm_dig.stop_dig) + return; + + if (dm_dig.cur_igvalue != current_igi) { + rtl_set_bbreg(hw, ROFDM0_XAAGCCORE1, 0x7f, current_igi); + if (rtlpriv->phy.rf_type != RF_1T1R) + rtl_set_bbreg(hw, ROFDM0_XBAGCCORE1, 0x7f, current_igi); + } + dm_dig.pre_igvalue = dm_dig.cur_igvalue; + dm_dig.cur_igvalue = current_igi; +} + +static void rtl92ee_rssi_dump_to_register(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + rtl_write_byte(rtlpriv, RA_RSSIDUMP, + rtlpriv->stats.rx_rssi_percentage[0]); + rtl_write_byte(rtlpriv, RB_RSSIDUMP, + rtlpriv->stats.rx_rssi_percentage[1]); + /*It seems the following values is not initialized. + *According to Windows code, + *these value will only be valid when JAGUAR chips*/ + /* Rx EVM */ + rtl_write_byte(rtlpriv, RS1_RXEVMDUMP, rtlpriv->stats.rx_evm_dbm[0]); + rtl_write_byte(rtlpriv, RS2_RXEVMDUMP, rtlpriv->stats.rx_evm_dbm[1]); + /* Rx SNR */ + rtl_write_byte(rtlpriv, RA_RXSNRDUMP, + (u8)(rtlpriv->stats.rx_snr_db[0])); + rtl_write_byte(rtlpriv, RB_RXSNRDUMP, + (u8)(rtlpriv->stats.rx_snr_db[1])); + /* Rx Cfo_Short */ + rtl_write_word(rtlpriv, RA_CFOSHORTDUMP, + rtlpriv->stats.rx_cfo_short[0]); + rtl_write_word(rtlpriv, RB_CFOSHORTDUMP, + rtlpriv->stats.rx_cfo_short[1]); + /* Rx Cfo_Tail */ + rtl_write_word(rtlpriv, RA_CFOLONGDUMP, rtlpriv->stats.rx_cfo_tail[0]); + rtl_write_word(rtlpriv, RB_CFOLONGDUMP, rtlpriv->stats.rx_cfo_tail[1]); +} + +static void rtl92ee_dm_find_minimum_rssi(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_dig *rtl_dm_dig = &(rtlpriv->dm.dm_digtable); + struct rtl_mac *mac = rtl_mac(rtlpriv); + + /* Determine the minimum RSSI */ + if ((mac->link_state < MAC80211_LINKED) && + (rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb == 0)) { + rtl_dm_dig->min_undecorated_pwdb_for_dm = 0; + RT_TRACE(COMP_BB_POWERSAVING, DBG_LOUD, + ("Not connected to any\n")); + } + if (mac->link_state >= MAC80211_LINKED) { + if (mac->opmode == NL80211_IFTYPE_AP || + mac->opmode == NL80211_IFTYPE_ADHOC) { + rtl_dm_dig->min_undecorated_pwdb_for_dm = + rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; + RT_TRACE(COMP_BB_POWERSAVING, DBG_LOUD, + ("AP Client PWDB = 0x%lx\n", + rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb)); + } else { + rtl_dm_dig->min_undecorated_pwdb_for_dm = + rtlpriv->dm.undecorated_smoothed_pwdb; + RT_TRACE(COMP_BB_POWERSAVING, DBG_LOUD, + ("STA Default Port PWDB = 0x%x\n", + rtl_dm_dig->min_undecorated_pwdb_for_dm)); + } + } else { + rtl_dm_dig->min_undecorated_pwdb_for_dm = + rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; + RT_TRACE(COMP_BB_POWERSAVING, DBG_LOUD, + ("AP Ext Port or disconnet PWDB = 0x%x\n", + rtl_dm_dig->min_undecorated_pwdb_for_dm)); + } + RT_TRACE(COMP_DIG, DBG_LOUD, ("MinUndecoratedPWDBForDM =%d\n", + rtl_dm_dig->min_undecorated_pwdb_for_dm)); +} + +static void rtl92ee_dm_check_rssi_monitor(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *mac = rtl_mac(rtlpriv); + struct rtl_dm *dm = rtl_dm(rtlpriv); + struct rtl_sta_info *drv_priv; + u8 h2c[4] = { 0 }; + long max = 0, min = 0xff; + u8 i = 0; + + if (mac->opmode == NL80211_IFTYPE_AP || + mac->opmode == NL80211_IFTYPE_ADHOC || + mac->opmode == NL80211_IFTYPE_MESH_POINT) { + /* AP & ADHOC & MESH */ + spin_lock_bh(&rtlpriv->locks.entry_list_lock); + list_for_each_entry(drv_priv, &rtlpriv->entry_list, list) { + struct rssi_sta *stat = &(drv_priv->rssi_stat); + if (stat->undecorated_smoothed_pwdb < min) + min = stat->undecorated_smoothed_pwdb; + if (stat->undecorated_smoothed_pwdb > max) + max = stat->undecorated_smoothed_pwdb; + + h2c[3] = 0; + h2c[2] = (u8) (dm->undecorated_smoothed_pwdb & 0xFF); + h2c[1] = 0x20; + h2c[0] = ++i; + rtl92ee_fill_h2c_cmd(hw, H2C_92E_RSSI_REPORT, 4, h2c); + } + spin_unlock_bh(&rtlpriv->locks.entry_list_lock); + + /* If associated entry is found */ + if (max != 0) { + dm->entry_max_undecoratedsmoothed_pwdb = max; + RTPRINT(rtlpriv, FDM, DM_PWDB, + "EntryMaxPWDB = 0x%lx(%ld)\n", max, max); + } else { + dm->entry_max_undecoratedsmoothed_pwdb = 0; + } + /* If associated entry is found */ + if (min != 0xff) { + dm->entry_min_undecoratedsmoothed_pwdb = min; + RTPRINT(rtlpriv, FDM, DM_PWDB, + "EntryMinPWDB = 0x%lx(%ld)\n", min, min); + } else { + dm->entry_min_undecoratedsmoothed_pwdb = 0; + } + } + + /* Indicate Rx signal strength to FW. */ + if (dm->b_useramask) { + h2c[3] = 0; + h2c[2] = (u8) (dm->undecorated_smoothed_pwdb & 0xFF); + h2c[1] = 0x20; + h2c[0] = 0; + rtl92ee_fill_h2c_cmd(hw, H2C_92E_RSSI_REPORT, 4, h2c); + } else { + rtl_write_byte(rtlpriv, 0x4fe, dm->undecorated_smoothed_pwdb); + } + rtl92ee_rssi_dump_to_register(hw); + rtl92ee_dm_find_minimum_rssi(hw); + dm_dig.rssi_val_min = dm->dm_digtable.min_undecorated_pwdb_for_dm; +} + +static void rtl92ee_dm_init_primary_cca_check(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtlpriv); + struct dynamic_primary_cca *primarycca = &(rtlpriv->primarycca); + + rtlhal->rts_en = 0; + primarycca->dup_rts_flag = 0; + primarycca->intf_flag = 0; + primarycca->intf_type = 0; + primarycca->monitor_flag = 0; + primarycca->ch_offset = 0; + primarycca->mf_state = 0; +} + +static bool rtl92ee_dm_is_edca_turbo_disable(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + if (rtlpriv->mac80211.mode == WIRELESS_MODE_B) + return true; + + return false; +} + +void rtl92ee_dm_init_edca_turbo(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + rtlpriv->dm.bcurrent_turbo_edca = false; + rtlpriv->dm.bis_cur_rdlstate = false; + rtlpriv->dm.bis_any_nonbepkts = false; +} + +static void rtl92ee_dm_check_edca_turbo(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + static u64 last_txok_cnt; + static u64 last_rxok_cnt; + u64 cur_txok_cnt = 0; + u64 cur_rxok_cnt = 0; + u32 edca_be_ul = 0x5ea42b; + u32 edca_be_dl = 0x5ea42b; /*not sure*/ + u32 edca_be = 0x5ea42b; + bool b_is_cur_rdlstate; + bool b_edca_turbo_on = false; + + if (rtlpriv->dm.dbginfo.num_non_be_pkt > 0x100) + rtlpriv->dm.bis_any_nonbepkts = true; + rtlpriv->dm.dbginfo.num_non_be_pkt = 0; + + cur_txok_cnt = rtlpriv->stats.txbytesunicast - last_txok_cnt; + cur_rxok_cnt = rtlpriv->stats.rxbytesunicast - last_rxok_cnt; + + /*b_bias_on_rx = false;*/ + b_edca_turbo_on = ((!rtlpriv->dm.bis_any_nonbepkts) && + (!rtlpriv->dm.b_disable_framebursting)) ? + true : false; + + if (rtl92ee_dm_is_edca_turbo_disable(hw)) + goto dm_CheckEdcaTurbo_EXIT; + + if (b_edca_turbo_on) { + b_is_cur_rdlstate = (cur_rxok_cnt > cur_txok_cnt * 4) ? + true : false; + + edca_be = b_is_cur_rdlstate ? edca_be_dl : edca_be_ul; + rtl_write_dword(rtlpriv , REG_EDCA_BE_PARAM , edca_be); + rtlpriv->dm.bis_cur_rdlstate = b_is_cur_rdlstate; + rtlpriv->dm.bcurrent_turbo_edca = true; + } else { + if (rtlpriv->dm.bcurrent_turbo_edca) { + u8 tmp = AC0_BE; + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AC_PARAM, + (u8 *) (&tmp)); + } + rtlpriv->dm.bcurrent_turbo_edca = false; + } + +dm_CheckEdcaTurbo_EXIT: + rtlpriv->dm.bis_any_nonbepkts = false; + last_txok_cnt = rtlpriv->stats.txbytesunicast; + last_rxok_cnt = rtlpriv->stats.rxbytesunicast; +} + +static void rtl92ee_dm_dynamic_edcca(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u8 reg_c50 , reg_c58; + bool b_fw_current_in_ps_mode = false; + + rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_FW_PSMODE_STATUS, + (u8 *)(&b_fw_current_in_ps_mode)); + if (b_fw_current_in_ps_mode) + return; + + reg_c50 = rtl_get_bbreg(hw, ROFDM0_XAAGCCORE1, MASKBYTE0); + reg_c58 = rtl_get_bbreg(hw, ROFDM0_XBAGCCORE1, MASKBYTE0); + + if (reg_c50 > 0x28 && reg_c58 > 0x28) { + if (!rtlpriv->rtlhal.b_pre_edcca_enable) { + rtl_write_byte(rtlpriv, ROFDM0_ECCATHRESHOLD, 0x03); + rtl_write_byte(rtlpriv, ROFDM0_ECCATHRESHOLD + 2, 0x00); + rtlpriv->rtlhal.b_pre_edcca_enable = true; + } + } else if (reg_c50 < 0x25 && reg_c58 < 0x25) { + if (rtlpriv->rtlhal.b_pre_edcca_enable) { + rtl_write_byte(rtlpriv, ROFDM0_ECCATHRESHOLD, 0x7f); + rtl_write_byte(rtlpriv, ROFDM0_ECCATHRESHOLD + 2, 0x7f); + rtlpriv->rtlhal.b_pre_edcca_enable = false; + } + } +} + +static void rtl92ee_dm_adaptivity(struct ieee80211_hw *hw) +{ + rtl92ee_dm_dynamic_edcca(hw); +} + +static void rtl92ee_dm_write_dynamic_cca(struct ieee80211_hw *hw, u8 cur_mf_state) +{ + struct dynamic_primary_cca *primarycca = &(rtl_priv(hw)->primarycca); + + if (primarycca->mf_state != cur_mf_state) + rtl_set_bbreg(hw, DM_REG_L1SBD_PD_CH_11N, BIT(8) | BIT(7), + cur_mf_state); + + primarycca->mf_state = cur_mf_state; +} + +static void rtl92ee_dm_dynamic_primary_cca_ckeck(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct false_alarm_statistics *falsealm_cnt = &(rtlpriv->falsealm_cnt); + struct dynamic_primary_cca *primarycca = &(rtlpriv->primarycca); + bool is40mhz = false; + u64 ofdm_cca, ofdm_fa, bw_usc_cnt, bw_lsc_cnt; + u8 sec_ch_offset; + u8 cur_mf_state; + static u8 count_down = MONITOR_TIME; + + ofdm_cca = falsealm_cnt->cnt_ofdm_cca; + ofdm_fa = falsealm_cnt->cnt_ofdm_fail; + bw_usc_cnt = falsealm_cnt->cnt_bw_usc; + bw_lsc_cnt = falsealm_cnt->cnt_bw_lsc; + is40mhz = rtlpriv->mac80211.bw_40; + sec_ch_offset = rtlpriv->mac80211.cur_40_prime_sc; + /* NIC: 2: sec is below, 1: sec is above */ + + if (rtlpriv->mac80211.opmode == NL80211_IFTYPE_AP) { + cur_mf_state = MF_USC_LSC; + rtl92ee_dm_write_dynamic_cca(hw, cur_mf_state); + return; + } + + if (rtlpriv->mac80211.link_state < MAC80211_LINKED) + return; + + if (is40mhz) + return; + + if (primarycca->pricca_flag == 0) { + /* Primary channel is above + * NOTE: duplicate CTS can remove this condition*/ + if (sec_ch_offset == 2) { + if ((ofdm_cca > OFDMCCA_TH) && + (bw_lsc_cnt > (bw_usc_cnt + BW_IND_BIAS)) && + (ofdm_fa > (ofdm_cca >> 1))) { + primarycca->intf_type = 1; + primarycca->intf_flag = 1; + cur_mf_state = MF_USC; + rtl92ee_dm_write_dynamic_cca(hw, cur_mf_state); + primarycca->pricca_flag = 1; + } else if ((ofdm_cca > OFDMCCA_TH) && + (bw_lsc_cnt > (bw_usc_cnt + BW_IND_BIAS)) && + (ofdm_fa < (ofdm_cca >> 1))) { + primarycca->intf_type = 2; + primarycca->intf_flag = 1; + cur_mf_state = MF_USC; + rtl92ee_dm_write_dynamic_cca(hw, cur_mf_state); + primarycca->pricca_flag = 1; + primarycca->dup_rts_flag = 1; + rtlpriv->rtlhal.rts_en = 1; + } else { + primarycca->intf_type = 0; + primarycca->intf_flag = 0; + cur_mf_state = MF_USC_LSC; + rtl92ee_dm_write_dynamic_cca(hw, cur_mf_state); + rtlpriv->rtlhal.rts_en = 0; + primarycca->dup_rts_flag = 0; + } + } else if (sec_ch_offset == 1) { + if ((ofdm_cca > OFDMCCA_TH) && + (bw_usc_cnt > (bw_lsc_cnt + BW_IND_BIAS)) && + (ofdm_fa > (ofdm_cca >> 1))) { + primarycca->intf_type = 1; + primarycca->intf_flag = 1; + cur_mf_state = MF_LSC; + rtl92ee_dm_write_dynamic_cca(hw, cur_mf_state); + primarycca->pricca_flag = 1; + } else if ((ofdm_cca > OFDMCCA_TH) && + (bw_usc_cnt > (bw_lsc_cnt + BW_IND_BIAS)) && + (ofdm_fa < (ofdm_cca >> 1))) { + primarycca->intf_type = 2; + primarycca->intf_flag = 1; + cur_mf_state = MF_LSC; + rtl92ee_dm_write_dynamic_cca(hw, cur_mf_state); + primarycca->pricca_flag = 1; + primarycca->dup_rts_flag = 1; + rtlpriv->rtlhal.rts_en = 1; + } else { + primarycca->intf_type = 0; + primarycca->intf_flag = 0; + cur_mf_state = MF_USC_LSC; + rtl92ee_dm_write_dynamic_cca(hw, cur_mf_state); + rtlpriv->rtlhal.rts_en = 0; + primarycca->dup_rts_flag = 0; + } + } + } else {/* PrimaryCCA->PriCCA_flag == 1 */ + count_down--; + if (count_down == 0) { + count_down = MONITOR_TIME; + primarycca->pricca_flag = 0; + cur_mf_state = MF_USC_LSC; + /* default */ + rtl92ee_dm_write_dynamic_cca(hw, cur_mf_state); + rtlpriv->rtlhal.rts_en = 0; + primarycca->dup_rts_flag = 0; + primarycca->intf_type = 0; + primarycca->intf_flag = 0; + } + } +} + +static void rtl92ee_dm_dynamic_atc_switch(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_dm *rtldm = rtl_dm(rtl_priv(hw)); + u8 crystal_cap; + u32 packet_count; + int cfo_khz_a , cfo_khz_b , cfo_ave = 0, adjust_xtal = 0; + int cfo_ave_diff; + + if (rtlpriv->mac80211.link_state < MAC80211_LINKED) { + if (rtldm->atc_status == ATC_STATUS_OFF) { + rtl_set_bbreg(hw, ROFDM1_CFOTRACKING, BIT(11), + ATC_STATUS_ON); + rtldm->atc_status = ATC_STATUS_ON; + } + /* Disable CFO tracking for BT */ + if (rtlpriv->cfg->ops->get_btc_status()) { + if (!rtlpriv->btcoexist.btc_ops->btc_is_bt_disabled(rtlpriv)) { + RT_TRACE(COMP_BT_COEXIST, DBG_LOUD, + ("odm_DynamicATCSwitch(): " + "Disable CFO tracking for BT!!\n")); + return; + } + } + /* Reset Crystal Cap */ + if (rtldm->crystal_cap != rtlpriv->efuse.crystalcap) { + rtldm->crystal_cap = rtlpriv->efuse.crystalcap; + crystal_cap = rtldm->crystal_cap & 0x3f; + rtl_set_bbreg(hw, REG_MAC_PHY_CTRL, 0xFFF000, + (crystal_cap | (crystal_cap << 6))); + } + } else { + cfo_khz_a = (int)(rtldm->cfo_tail[0] * 3125) / 1280; + cfo_khz_b = (int)(rtldm->cfo_tail[1] * 3125) / 1280; + packet_count = rtldm->packet_count; + + if (packet_count == rtldm->packet_count_pre) + return; + + rtldm->packet_count_pre = packet_count; + + if (rtlpriv->phy.rf_type == RF_1T1R) + cfo_ave = cfo_khz_a; + else + cfo_ave = (int)(cfo_khz_a + cfo_khz_b) >> 1; + + cfo_ave_diff = (rtldm->cfo_ave_pre >= cfo_ave) ? + (rtldm->cfo_ave_pre - cfo_ave) : + (cfo_ave - rtldm->cfo_ave_pre); + + if (cfo_ave_diff > 20 && rtldm->large_cfo_hit == 0) { + rtldm->large_cfo_hit = 1; + return; + } else { + rtldm->large_cfo_hit = 0; + } + + rtldm->cfo_ave_pre = cfo_ave; + + if (cfo_ave >= -rtldm->cfo_threshold && + cfo_ave <= rtldm->cfo_threshold && rtldm->is_freeze == 0) { + if (rtldm->cfo_threshold == CFO_THRESHOLD_XTAL) { + rtldm->cfo_threshold = CFO_THRESHOLD_XTAL + 10; + rtldm->is_freeze = 1; + } else { + rtldm->cfo_threshold = CFO_THRESHOLD_XTAL; + } + } + + if (cfo_ave > rtldm->cfo_threshold && rtldm->crystal_cap < 0x3f) + adjust_xtal = ((cfo_ave - CFO_THRESHOLD_XTAL) >> 2) + 1; + else if ((cfo_ave < -rtlpriv->dm.cfo_threshold) && + rtlpriv->dm.crystal_cap > 0) + adjust_xtal = ((cfo_ave + CFO_THRESHOLD_XTAL) >> 2) - 1; + + if (adjust_xtal != 0) { + rtldm->is_freeze = 0; + rtldm->crystal_cap += adjust_xtal; + + if (rtldm->crystal_cap > 0x3f) + rtldm->crystal_cap = 0x3f; + else if (rtldm->crystal_cap < 0) + rtldm->crystal_cap = 0; + + crystal_cap = rtldm->crystal_cap & 0x3f; + rtl_set_bbreg(hw, REG_MAC_PHY_CTRL, 0xFFF000, + (crystal_cap | (crystal_cap << 6))); + } + + if (cfo_ave < CFO_THRESHOLD_ATC && + cfo_ave > -CFO_THRESHOLD_ATC) { + if (rtldm->atc_status == ATC_STATUS_ON) { + rtl_set_bbreg(hw, ROFDM1_CFOTRACKING, BIT(11), + ATC_STATUS_OFF); + rtldm->atc_status = ATC_STATUS_OFF; + } + } else { + if (rtldm->atc_status == ATC_STATUS_OFF) { + rtl_set_bbreg(hw, ROFDM1_CFOTRACKING, BIT(11), + ATC_STATUS_ON); + rtldm->atc_status = ATC_STATUS_ON; + } + } + } +} + +static void rtl92ee_dm_init_txpower_tracking(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_dm *dm = rtl_dm(rtlpriv); + u8 path; + + dm->btxpower_tracking = true; + dm->default_ofdm_index = 30; + dm->default_cck_index = 20; + + dm->bb_swing_idx_cck_base = dm->default_cck_index; + dm->cck_index = dm->default_cck_index; + + for (path = RF90_PATH_A; path < MAX_RF_PATH; path++) { + dm->bb_swing_idx_ofdm_base[path] = dm->default_ofdm_index; + dm->ofdm_index[path] = dm->default_ofdm_index; + dm->delta_power_index[path] = 0; + dm->delta_power_index_last[path] = 0; + dm->power_index_offset[path] = 0; + } +} + +void rtl92ee_dm_init_rate_adaptive_mask(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rate_adaptive *p_ra = &(rtlpriv->ra); + + p_ra->ratr_state = DM_RATR_STA_INIT; + p_ra->pre_ratr_state = DM_RATR_STA_INIT; + + if (rtlpriv->dm.dm_type == DM_TYPE_BYDRIVER) + rtlpriv->dm.b_useramask = true; + else + rtlpriv->dm.b_useramask = false; + + p_ra->ldpc_thres = 35; + p_ra->use_ldpc = false; + p_ra->high_rssi_thresh_for_ra = 50; + p_ra->low_rssi_thresh_for_ra = 20; + +} + +static bool _rtl92ee_dm_ra_state_check(struct ieee80211_hw *hw, + s32 rssi, u8 *ratr_state) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rate_adaptive *p_ra = &(rtlpriv->ra); + const u8 go_up_gap = 5; + u32 high_rssithresh_for_ra = p_ra->high_rssi_thresh_for_ra; + u32 low_rssithresh_for_ra = p_ra->low_rssi_thresh_for_ra; + u8 state; + + /* Threshold Adjustment: + * when RSSI state trends to go up one or two levels, + * make sure RSSI is high enough. + * Here GoUpGap is added to solve + * the boundary's level alternation issue. + */ + switch (*ratr_state) { + case DM_RATR_STA_INIT: + case DM_RATR_STA_HIGH: + break; + + case DM_RATR_STA_MIDDLE: + high_rssithresh_for_ra += go_up_gap; + break; + + case DM_RATR_STA_LOW: + high_rssithresh_for_ra += go_up_gap; + low_rssithresh_for_ra += go_up_gap; + break; + + default: + RT_TRACE(COMP_RATR, DBG_DMESG, + ("wrong rssi level setting %d !", *ratr_state)); + break; + } + + /* Decide RATRState by RSSI. */ + if (rssi > high_rssithresh_for_ra) + state = DM_RATR_STA_HIGH; + else if (rssi > low_rssithresh_for_ra) + state = DM_RATR_STA_MIDDLE; + else + state = DM_RATR_STA_LOW; + + if (*ratr_state != state) { + *ratr_state = state; + return true; + } + + return false; +} + +static void rtl92ee_dm_refresh_rate_adaptive_mask(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct rate_adaptive *p_ra = &(rtlpriv->ra); + struct ieee80211_sta *sta = NULL; + + if (is_hal_stop(rtlhal)) { + RT_TRACE(COMP_RATE, DBG_LOUD, + ("driver is going to unload\n")); + return; + } + + if (!rtlpriv->dm.b_useramask) { + RT_TRACE(COMP_RATE, DBG_LOUD, + ("driver does not control rate adaptive mask\n")); + return; + } + + if (mac->link_state == MAC80211_LINKED && + mac->opmode == NL80211_IFTYPE_STATION) { + + if (rtlpriv->dm.undecorated_smoothed_pwdb < p_ra->ldpc_thres) { + p_ra->use_ldpc = true; + p_ra->lower_rts_rate = true; + } else if (rtlpriv->dm.undecorated_smoothed_pwdb > + (p_ra->ldpc_thres - 5)) { + p_ra->use_ldpc = false; + p_ra->lower_rts_rate = false; + } + if (_rtl92ee_dm_ra_state_check(hw, + rtlpriv->dm.undecorated_smoothed_pwdb, + &(p_ra->ratr_state))) { + + rcu_read_lock(); + sta = rtl_find_sta(hw, mac->bssid); + if (sta) + rtlpriv->cfg->ops->update_rate_tbl(hw, sta, + p_ra->ratr_state); + rcu_read_unlock(); + + p_ra->pre_ratr_state = p_ra->ratr_state; + } + } +} + +static void rtl92ee_dm_init_dynamic_atc_switch(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + rtlpriv->dm.crystal_cap = rtlpriv->efuse.crystalcap; + + rtlpriv->dm.atc_status = rtl_get_bbreg(hw, ROFDM1_CFOTRACKING, BIT(11)); + rtlpriv->dm.cfo_threshold = CFO_THRESHOLD_XTAL; +} + +void rtl92ee_dm_init(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + rtlpriv->dm.dm_type = DM_TYPE_BYDRIVER; + + rtl92ee_dm_diginit(hw); + rtl92ee_dm_init_rate_adaptive_mask(hw); + rtl92ee_dm_init_primary_cca_check(hw); + rtl92ee_dm_init_edca_turbo(hw); + rtl92ee_dm_init_txpower_tracking(hw); + rtl92ee_dm_init_dynamic_atc_switch(hw); +} + +static void rtl92ee_dm_common_info_self_update(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u8 cnt = 0; + struct rtl_sta_info *drv_priv; + + rtlpriv->dm.b_one_entry_only = false; + + if (rtlpriv->mac80211.opmode == NL80211_IFTYPE_STATION && + rtlpriv->mac80211.link_state >= MAC80211_LINKED) { + rtlpriv->dm.b_one_entry_only = true; + return; + } + + if (rtlpriv->mac80211.opmode == NL80211_IFTYPE_AP || + rtlpriv->mac80211.opmode == NL80211_IFTYPE_ADHOC || + rtlpriv->mac80211.opmode == NL80211_IFTYPE_MESH_POINT) { + spin_lock_bh(&rtlpriv->locks.entry_list_lock); + list_for_each_entry(drv_priv, &rtlpriv->entry_list, list) { + cnt++; + } + spin_unlock_bh(&rtlpriv->locks.entry_list_lock); + + if (cnt == 1) + rtlpriv->dm.b_one_entry_only = true; + } +} + +void rtl92ee_dm_dynamic_arfb_select(struct ieee80211_hw *hw, + u8 rate, bool collision_state) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + if (rate >= DESC92C_RATEMCS8 && rate <= DESC92C_RATEMCS12) { + if (collision_state == 1) { + if (rate == DESC92C_RATEMCS12) { + rtl_write_dword(rtlpriv, REG_DARFRC, 0x0); + rtl_write_dword(rtlpriv, REG_DARFRC + 4, + 0x07060501); + } else if (rate == DESC92C_RATEMCS11) { + rtl_write_dword(rtlpriv, REG_DARFRC, 0x0); + rtl_write_dword(rtlpriv, REG_DARFRC + 4, + 0x07070605); + } else if (rate == DESC92C_RATEMCS10) { + rtl_write_dword(rtlpriv, REG_DARFRC, 0x0); + rtl_write_dword(rtlpriv, REG_DARFRC + 4, + 0x08080706); + } else if (rate == DESC92C_RATEMCS9) { + rtl_write_dword(rtlpriv, REG_DARFRC, 0x0); + rtl_write_dword(rtlpriv, REG_DARFRC + 4, + 0x08080707); + } else { + rtl_write_dword(rtlpriv, REG_DARFRC, 0x0); + rtl_write_dword(rtlpriv, REG_DARFRC + 4, + 0x09090808); + } + } else { /* collision_state == 0 */ + if (rate == DESC92C_RATEMCS12) { + rtl_write_dword(rtlpriv, REG_DARFRC, + 0x05010000); + rtl_write_dword(rtlpriv, REG_DARFRC + 4, + 0x09080706); + } else if (rate == DESC92C_RATEMCS11) { + rtl_write_dword(rtlpriv, REG_DARFRC, + 0x06050000); + rtl_write_dword(rtlpriv, REG_DARFRC + 4, + 0x09080807); + } else if (rate == DESC92C_RATEMCS10) { + rtl_write_dword(rtlpriv, REG_DARFRC, + 0x07060000); + rtl_write_dword(rtlpriv, REG_DARFRC + 4, + 0x0a090908); + } else if (rate == DESC92C_RATEMCS9) { + rtl_write_dword(rtlpriv, REG_DARFRC, + 0x07070000); + rtl_write_dword(rtlpriv, REG_DARFRC + 4, + 0x0a090808); + } else { + rtl_write_dword(rtlpriv, REG_DARFRC, + 0x08080000); + rtl_write_dword(rtlpriv, REG_DARFRC + 4, + 0x0b0a0909); + } + } + } else { /* MCS13~MCS15, 1SS, G-mode */ + if (collision_state == 1) { + if (rate == DESC92C_RATEMCS15) { + rtl_write_dword(rtlpriv, REG_DARFRC, + 0x00000000); + rtl_write_dword(rtlpriv, REG_DARFRC + 4, + 0x05040302); + } else if (rate == DESC92C_RATEMCS14) { + rtl_write_dword(rtlpriv, REG_DARFRC, + 0x00000000); + rtl_write_dword(rtlpriv, REG_DARFRC + 4, + 0x06050302); + } else if (rate == DESC92C_RATEMCS13) { + rtl_write_dword(rtlpriv, REG_DARFRC, + 0x00000000); + rtl_write_dword(rtlpriv, REG_DARFRC + 4, + 0x07060502); + } else { + rtl_write_dword(rtlpriv, REG_DARFRC, + 0x00000000); + rtl_write_dword(rtlpriv, REG_DARFRC + 4, + 0x06050402); + } + } else{ /* collision_state == 0 */ + if (rate == DESC92C_RATEMCS15) { + rtl_write_dword(rtlpriv, REG_DARFRC, + 0x03020000); + rtl_write_dword(rtlpriv, REG_DARFRC + 4, + 0x07060504); + } else if (rate == DESC92C_RATEMCS14) { + rtl_write_dword(rtlpriv, REG_DARFRC, + 0x03020000); + rtl_write_dword(rtlpriv, REG_DARFRC + 4, + 0x08070605); + } else if (rate == DESC92C_RATEMCS13) { + rtl_write_dword(rtlpriv, REG_DARFRC, + 0x05020000); + rtl_write_dword(rtlpriv, REG_DARFRC + 4, + 0x09080706); + } else { + rtl_write_dword(rtlpriv, REG_DARFRC, + 0x04020000); + rtl_write_dword(rtlpriv, REG_DARFRC + 4, + 0x08070605); + } + } + } +} + +void rtl92ee_dm_watchdog(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + bool b_fw_current_inpsmode = false; + bool b_fw_ps_awake = true; + + rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_FW_PSMODE_STATUS, + (u8 *) (&b_fw_current_inpsmode)); + rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_FWLPS_RF_ON, + (u8 *) (&b_fw_ps_awake)); + if (ppsc->p2p_ps_info.p2p_ps_mode) + b_fw_ps_awake = false; + + if ((ppsc->rfpwr_state == ERFON) && + ((!b_fw_current_inpsmode) && b_fw_ps_awake) && + (!ppsc->rfchange_inprogress)) { + rtl92ee_dm_common_info_self_update(hw); + rtl92ee_dm_false_alarm_counter_statistics(hw); + rtl92ee_dm_check_rssi_monitor(hw); + rtl92ee_dm_dig(hw); + rtl92ee_dm_adaptivity(hw); + rtl92ee_dm_cck_packet_detection_thresh(hw); + rtl92ee_dm_refresh_rate_adaptive_mask(hw); + rtl92ee_dm_check_edca_turbo(hw); + rtl92ee_dm_dynamic_atc_switch(hw); + rtl92ee_dm_dynamic_primary_cca_ckeck(hw); + } +} diff --git a/drivers/staging/rtl8192ee/rtl8192ee/dm.h b/drivers/staging/rtl8192ee/rtl8192ee/dm.h new file mode 100644 index 000000000000..30b8fa6d3f78 --- /dev/null +++ b/drivers/staging/rtl8192ee/rtl8192ee/dm.h @@ -0,0 +1,343 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#ifndef __RTL92E_DM_H__ +#define __RTL92E_DM_H__ + +#define OFDMCCA_TH 500 +#define BW_IND_BIAS 500 +#define MF_USC 2 +#define MF_LSC 1 +#define MF_USC_LSC 0 +#define MONITOR_TIME 30 + +#define MAIN_ANT 0 +#define AUX_ANT 1 +#define MAIN_ANT_CG_TRX 1 +#define AUX_ANT_CG_TRX 0 +#define MAIN_ANT_CGCS_RX 0 +#define AUX_ANT_CGCS_RX 1 + +/*RF REG LIST*/ +#define DM_REG_RF_MODE_11N 0x00 +#define DM_REG_RF_0B_11N 0x0B +#define DM_REG_CHNBW_11N 0x18 +#define DM_REG_T_METER_11N 0x24 +#define DM_REG_RF_25_11N 0x25 +#define DM_REG_RF_26_11N 0x26 +#define DM_REG_RF_27_11N 0x27 +#define DM_REG_RF_2B_11N 0x2B +#define DM_REG_RF_2C_11N 0x2C +#define DM_REG_RXRF_A3_11N 0x3C +#define DM_REG_T_METER_92D_11N 0x42 +#define DM_REG_T_METER_92E_11N 0x42 + + + +/*BB REG LIST*/ +/*PAGE 8 */ +#define DM_REG_BB_CTRL_11N 0x800 +#define DM_REG_RF_PIN_11N 0x804 +#define DM_REG_PSD_CTRL_11N 0x808 +#define DM_REG_TX_ANT_CTRL_11N 0x80C +#define DM_REG_BB_PWR_SAV5_11N 0x818 +#define DM_REG_CCK_RPT_FORMAT_11N 0x824 +#define DM_REG_RX_DEFUALT_A_11N 0x858 +#define DM_REG_RX_DEFUALT_B_11N 0x85A +#define DM_REG_BB_PWR_SAV3_11N 0x85C +#define DM_REG_ANTSEL_CTRL_11N 0x860 +#define DM_REG_RX_ANT_CTRL_11N 0x864 +#define DM_REG_PIN_CTRL_11N 0x870 +#define DM_REG_BB_PWR_SAV1_11N 0x874 +#define DM_REG_ANTSEL_PATH_11N 0x878 +#define DM_REG_BB_3WIRE_11N 0x88C +#define DM_REG_SC_CNT_11N 0x8C4 +#define DM_REG_PSD_DATA_11N 0x8B4 +/*PAGE 9*/ +#define DM_REG_ANT_MAPPING1_11N 0x914 +#define DM_REG_ANT_MAPPING2_11N 0x918 +/*PAGE A*/ +#define DM_REG_CCK_ANTDIV_PARA1_11N 0xA00 +#define DM_REG_CCK_CCA_11N 0xA0A +#define DM_REG_CCK_ANTDIV_PARA2_11N 0xA0C +#define DM_REG_CCK_ANTDIV_PARA3_11N 0xA10 +#define DM_REG_CCK_ANTDIV_PARA4_11N 0xA14 +#define DM_REG_CCK_FILTER_PARA1_11N 0xA22 +#define DM_REG_CCK_FILTER_PARA2_11N 0xA23 +#define DM_REG_CCK_FILTER_PARA3_11N 0xA24 +#define DM_REG_CCK_FILTER_PARA4_11N 0xA25 +#define DM_REG_CCK_FILTER_PARA5_11N 0xA26 +#define DM_REG_CCK_FILTER_PARA6_11N 0xA27 +#define DM_REG_CCK_FILTER_PARA7_11N 0xA28 +#define DM_REG_CCK_FILTER_PARA8_11N 0xA29 +#define DM_REG_CCK_FA_RST_11N 0xA2C +#define DM_REG_CCK_FA_MSB_11N 0xA58 +#define DM_REG_CCK_FA_LSB_11N 0xA5C +#define DM_REG_CCK_CCA_CNT_11N 0xA60 +#define DM_REG_BB_PWR_SAV4_11N 0xA74 +/*PAGE B */ +#define DM_REG_LNA_SWITCH_11N 0xB2C +#define DM_REG_PATH_SWITCH_11N 0xB30 +#define DM_REG_RSSI_CTRL_11N 0xB38 +#define DM_REG_CONFIG_ANTA_11N 0xB68 +#define DM_REG_RSSI_BT_11N 0xB9C +/*PAGE C */ +#define DM_REG_OFDM_FA_HOLDC_11N 0xC00 +#define DM_REG_RX_PATH_11N 0xC04 +#define DM_REG_TRMUX_11N 0xC08 +#define DM_REG_OFDM_FA_RSTC_11N 0xC0C +#define DM_REG_RXIQI_MATRIX_11N 0xC14 +#define DM_REG_TXIQK_MATRIX_LSB1_11N 0xC4C +#define DM_REG_IGI_A_11N 0xC50 +#define DM_REG_ANTDIV_PARA2_11N 0xC54 +#define DM_REG_IGI_B_11N 0xC58 +#define DM_REG_ANTDIV_PARA3_11N 0xC5C +#define DM_REG_L1SBD_PD_CH_11N 0XC6C +#define DM_REG_BB_PWR_SAV2_11N 0xC70 +#define DM_REG_RX_OFF_11N 0xC7C +#define DM_REG_TXIQK_MATRIXA_11N 0xC80 +#define DM_REG_TXIQK_MATRIXB_11N 0xC88 +#define DM_REG_TXIQK_MATRIXA_LSB2_11N 0xC94 +#define DM_REG_TXIQK_MATRIXB_LSB2_11N 0xC9C +#define DM_REG_RXIQK_MATRIX_LSB_11N 0xCA0 +#define DM_REG_ANTDIV_PARA1_11N 0xCA4 +#define DM_REG_OFDM_FA_TYPE1_11N 0xCF0 +/*PAGE D */ +#define DM_REG_OFDM_FA_RSTD_11N 0xD00 +#define DM_REG_OFDM_FA_TYPE2_11N 0xDA0 +#define DM_REG_OFDM_FA_TYPE3_11N 0xDA4 +#define DM_REG_OFDM_FA_TYPE4_11N 0xDA8 +/*PAGE E */ +#define DM_REG_TXAGC_A_6_18_11N 0xE00 +#define DM_REG_TXAGC_A_24_54_11N 0xE04 +#define DM_REG_TXAGC_A_1_MCS32_11N 0xE08 +#define DM_REG_TXAGC_A_MCS0_3_11N 0xE10 +#define DM_REG_TXAGC_A_MCS4_7_11N 0xE14 +#define DM_REG_TXAGC_A_MCS8_11_11N 0xE18 +#define DM_REG_TXAGC_A_MCS12_15_11N 0xE1C +#define DM_REG_FPGA0_IQK_11N 0xE28 +#define DM_REG_TXIQK_TONE_A_11N 0xE30 +#define DM_REG_RXIQK_TONE_A_11N 0xE34 +#define DM_REG_TXIQK_PI_A_11N 0xE38 +#define DM_REG_RXIQK_PI_A_11N 0xE3C +#define DM_REG_TXIQK_11N 0xE40 +#define DM_REG_RXIQK_11N 0xE44 +#define DM_REG_IQK_AGC_PTS_11N 0xE48 +#define DM_REG_IQK_AGC_RSP_11N 0xE4C +#define DM_REG_BLUETOOTH_11N 0xE6C +#define DM_REG_RX_WAIT_CCA_11N 0xE70 +#define DM_REG_TX_CCK_RFON_11N 0xE74 +#define DM_REG_TX_CCK_BBON_11N 0xE78 +#define DM_REG_OFDM_RFON_11N 0xE7C +#define DM_REG_OFDM_BBON_11N 0xE80 +#define DM_REG_TX2RX_11N 0xE84 +#define DM_REG_TX2TX_11N 0xE88 +#define DM_REG_RX_CCK_11N 0xE8C +#define DM_REG_RX_OFDM_11N 0xED0 +#define DM_REG_RX_WAIT_RIFS_11N 0xED4 +#define DM_REG_RX2RX_11N 0xED8 +#define DM_REG_STANDBY_11N 0xEDC +#define DM_REG_SLEEP_11N 0xEE0 +#define DM_REG_PMPD_ANAEN_11N 0xEEC + + +/*MAC REG LIST*/ +#define DM_REG_BB_RST_11N 0x02 +#define DM_REG_ANTSEL_PIN_11N 0x4C +#define DM_REG_EARLY_MODE_11N 0x4D0 +#define DM_REG_RSSI_MONITOR_11N 0x4FE +#define DM_REG_EDCA_VO_11N 0x500 +#define DM_REG_EDCA_VI_11N 0x504 +#define DM_REG_EDCA_BE_11N 0x508 +#define DM_REG_EDCA_BK_11N 0x50C +#define DM_REG_TXPAUSE_11N 0x522 +#define DM_REG_RESP_TX_11N 0x6D8 +#define DM_REG_ANT_TRAIN_PARA1_11N 0x7b0 +#define DM_REG_ANT_TRAIN_PARA2_11N 0x7b4 + + +/*DIG Related*/ +#define DM_BIT_IGI_11N 0x0000007F + + + +#define HAL_DM_DIG_DISABLE BIT(0) +#define HAL_DM_HIPWR_DISABLE BIT(1) + +#define OFDM_TABLE_LENGTH 43 +#define CCK_TABLE_LENGTH 33 + +#define OFDM_TABLE_SIZE 43 +#define CCK_TABLE_SIZE 33 + +#define BW_AUTO_SWITCH_HIGH_LOW 25 +#define BW_AUTO_SWITCH_LOW_HIGH 30 + +#define DM_DIG_THRESH_HIGH 40 +#define DM_DIG_THRESH_LOW 35 + +#define DM_FALSEALARM_THRESH_LOW 400 +#define DM_FALSEALARM_THRESH_HIGH 1000 + +#define DM_DIG_MAX 0x3e +#define DM_DIG_MIN 0x1e + +#define DM_DIG_MAX_AP 0x32 +#define DM_DIG_MIN_AP 0x20 + +#define DM_DIG_FA_UPPER 0x3e +#define DM_DIG_FA_LOWER 0x1e +#define DM_DIG_FA_TH0 0x200 +#define DM_DIG_FA_TH1 0x300 +#define DM_DIG_FA_TH2 0x400 + +#define DM_DIG_BACKOFF_MAX 12 +#define DM_DIG_BACKOFF_MIN -4 +#define DM_DIG_BACKOFF_DEFAULT 10 + +#define RXPATHSELECTION_SS_TH_lOW 30 +#define RXPATHSELECTION_DIFF_TH 18 + +#define DM_RATR_STA_INIT 0 +#define DM_RATR_STA_HIGH 1 +#define DM_RATR_STA_MIDDLE 2 +#define DM_RATR_STA_LOW 3 + +#define CTS2SELF_THVAL 30 +#define REGC38_TH 20 + +#define WAIOTTHVal 25 + +#define TXHIGHPWRLEVEL_NORMAL 0 +#define TXHIGHPWRLEVEL_LEVEL1 1 +#define TXHIGHPWRLEVEL_LEVEL2 2 +#define TXHIGHPWRLEVEL_BT1 3 +#define TXHIGHPWRLEVEL_BT2 4 + +#define DM_TYPE_BYFW 0 +#define DM_TYPE_BYDRIVER 1 + +#define TX_POWER_NEAR_FIELD_THRESH_LVL2 74 +#define TX_POWER_NEAR_FIELD_THRESH_LVL1 67 +#define TXPWRTRACK_MAX_IDX 6 + +/* Dynamic ATC switch */ +#define ATC_STATUS_OFF 0x0 /* enable */ +#define ATC_STATUS_ON 0x1 /* disable */ +#define CFO_THRESHOLD_XTAL 10 /* kHz */ +#define CFO_THRESHOLD_ATC 80 /* kHz */ + +/* RSSI Dump Message */ +#define RA_RSSIDUMP 0xcb0 +#define RB_RSSIDUMP 0xcb1 +#define RS1_RXEVMDUMP 0xcb2 +#define RS2_RXEVMDUMP 0xcb3 +#define RA_RXSNRDUMP 0xcb4 +#define RB_RXSNRDUMP 0xcb5 +#define RA_CFOSHORTDUMP 0xcb6 +#define RB_CFOSHORTDUMP 0xcb8 +#define RA_CFOLONGDUMP 0xcba +#define RB_CFOLONGDUMP 0xcbc + +struct ps_t { + u8 pre_ccastate; + u8 cur_ccasate; + u8 pre_rfstate; + u8 cur_rfstate; + long rssi_val_min; + +}; + +struct dig_t { + u8 dig_enable_flag; + u8 dig_ext_port_stage; + u32 rssi_lowthresh; + u32 rssi_highthresh; + + u32 fa_lowthresh; + u32 fa_highthresh; + + u8 cursta_connectctate; + u8 presta_connectstate; + u8 curmultista_connectstate; + + u8 pre_igvalue; + u8 cur_igvalue; + u8 backup_igvalue; + u8 bt30_cur_igi; + u8 stop_dig; + + char backoff_val; + char backoff_val_range_max; + char backoff_val_range_min; + u8 rx_gain_range_max; + u8 rx_gain_range_min; + u8 rssi_val_min; + + u8 pre_cck_cca_thres; + u8 cur_cck_cca_thres; + u8 pre_cck_pd_state; + u8 cur_cck_pd_state; + + u8 large_fa_hit; + u8 forbidden_igi; + u32 recover_cnt; + + char th_l2h_ini; + char th_edcca_hl_diff; + char igi_base; + u8 igi_target; + bool force_edcca; + u8 adapen_rssi; + + u8 dig_dynamic_min_0; + u8 dig_dynamic_min_1; + bool b_media_connect_0; + bool b_media_connect_1; + + u32 antdiv_rssi_max; + u32 rssi_max; +}; + +enum pwr_track_control_method { + BBSWING, + TXAGC +}; + +extern struct dig_t dm_dig; +void rtl92ee_dm_init(struct ieee80211_hw *hw); +void rtl92ee_dm_watchdog(struct ieee80211_hw *hw); +void rtl92ee_dm_write_cck_cca_thres(struct ieee80211_hw *hw, + u8 cur_thres); +void rtl92ee_dm_write_dig(struct ieee80211_hw *hw, u8 current_igi); +void rtl92ee_dm_init_edca_turbo(struct ieee80211_hw *hw); +void rtl92ee_dm_init_rate_adaptive_mask(struct ieee80211_hw *hw); +void rtl92ee_dm_dynamic_arfb_select(struct ieee80211_hw *hw, + u8 rate, bool collision_state); +#endif diff --git a/drivers/staging/rtl8192ee/rtl8192ee/fw.c b/drivers/staging/rtl8192ee/rtl8192ee/fw.c new file mode 100644 index 000000000000..ea6cafa80f48 --- /dev/null +++ b/drivers/staging/rtl8192ee/rtl8192ee/fw.c @@ -0,0 +1,945 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#include "../wifi.h" +#include "../pci.h" +#include "../base.h" +#include "reg.h" +#include "def.h" +#include "fw.h" +#include "dm.h" + +static void _rtl92ee_enable_fw_download(struct ieee80211_hw *hw, bool enable) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u8 tmp; + + if (enable) { + rtl_write_byte(rtlpriv, REG_MCUFWDL, 0x05); + + tmp = rtl_read_byte(rtlpriv, REG_MCUFWDL + 2); + rtl_write_byte(rtlpriv, REG_MCUFWDL + 2, tmp & 0xf7); + } else { + + tmp = rtl_read_byte(rtlpriv, REG_MCUFWDL); + rtl_write_byte(rtlpriv, REG_MCUFWDL, tmp & 0xfe); + } +} + +static void _rtl92ee_fw_block_write(struct ieee80211_hw *hw, + const u8 *buffer, u32 size) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u32 blockSize = sizeof(u32); + u8 *bufferPtr = (u8 *) buffer; + u32 *pu4BytePtr = (u32 *) buffer; + u32 i, offset, blockCount, remainSize; + + blockCount = size / blockSize; + remainSize = size % blockSize; + + for (i = 0; i < blockCount; i++) { + offset = i * blockSize; + rtl_write_dword(rtlpriv, (FW_8192C_START_ADDRESS + offset), + *(pu4BytePtr + i)); + } + + if (remainSize) { + offset = blockCount * blockSize; + bufferPtr += offset; + for (i = 0; i < remainSize; i++) { + rtl_write_byte(rtlpriv, + (FW_8192C_START_ADDRESS + offset + i), + *(bufferPtr + i)); + } + } +} + +static void _rtl92ee_fw_page_write(struct ieee80211_hw *hw, u32 page, + const u8 *buffer, u32 size) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u8 value8; + u8 u8page = (u8) (page & 0x07); + + value8 = (rtl_read_byte(rtlpriv, REG_MCUFWDL + 2) & 0xF8) | u8page; + rtl_write_byte(rtlpriv, (REG_MCUFWDL + 2), value8); + + _rtl92ee_fw_block_write(hw, buffer, size); +} + +static void _rtl92ee_fill_dummy(u8 *pfwbuf, u32 *pfwlen) +{ + u32 fwlen = *pfwlen; + u8 remain = (u8) (fwlen % 4); + + remain = (remain == 0) ? 0 : (4 - remain); + + while (remain > 0) { + pfwbuf[fwlen] = 0; + fwlen++; + remain--; + } + + *pfwlen = fwlen; +} + +static void _rtl92ee_write_fw(struct ieee80211_hw *hw, + enum version_8192e version, + u8 *buffer, u32 size) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u8 *bufferPtr = (u8 *) buffer; + u32 pageNums, remainSize; + u32 page, offset; + + RT_TRACE(COMP_FW, DBG_LOUD , ("FW size is %d bytes,\n", size)); + + _rtl92ee_fill_dummy(bufferPtr, &size); + + pageNums = size / FW_8192C_PAGE_SIZE; + remainSize = size % FW_8192C_PAGE_SIZE; + + if (pageNums > 8) { + RT_TRACE(COMP_ERR, DBG_EMERG, + ("Page numbers should not greater then 8\n")); + } + + for (page = 0; page < pageNums; page++) { + offset = page * FW_8192C_PAGE_SIZE; + _rtl92ee_fw_page_write(hw, page, (bufferPtr + offset), + FW_8192C_PAGE_SIZE); + udelay(2); + } + + if (remainSize) { + offset = pageNums * FW_8192C_PAGE_SIZE; + page = pageNums; + _rtl92ee_fw_page_write(hw, page, (bufferPtr + offset), + remainSize); + } + +} + +static int _rtl92ee_fw_free_to_go(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + int err = -EIO; + u32 counter = 0; + u32 value32; + + do { + value32 = rtl_read_dword(rtlpriv, REG_MCUFWDL); + } while ((counter++ < FW_8192C_POLLING_TIMEOUT_COUNT) && + (!(value32 & FWDL_ChkSum_rpt))); + + if (counter >= FW_8192C_POLLING_TIMEOUT_COUNT) { + RT_TRACE(COMP_ERR, DBG_EMERG, + ("chksum report faill ! REG_MCUFWDL:0x%08x .\n", + value32)); + goto exit; + } + + RT_TRACE(COMP_FW, DBG_TRACE, + ("Checksum report OK ! REG_MCUFWDL:0x%08x .\n", value32)); + + value32 = rtl_read_dword(rtlpriv, REG_MCUFWDL); + value32 |= MCUFWDL_RDY; + value32 &= ~WINTINI_RDY; + rtl_write_dword(rtlpriv, REG_MCUFWDL, value32); + + rtl92ee_firmware_selfreset(hw); + counter = 0; + + do { + value32 = rtl_read_dword(rtlpriv, REG_MCUFWDL); + if (value32 & WINTINI_RDY) { + RT_TRACE(COMP_FW, DBG_LOUD , + ("Polling FW ready success!! REG_MCUFWDL:" + "0x%08x. count = %d\n", value32, counter)); + err = 0; + goto exit; + } + + udelay(FW_8192C_POLLING_DELAY*10); + + } while (counter++ < FW_8192C_POLLING_TIMEOUT_COUNT); + + RT_TRACE(COMP_ERR, DBG_EMERG, + ("Polling FW ready fail!! REG_MCUFWDL:0x%08x. count = %d\n", + value32, counter)); + +exit: + return err; +} + +int rtl92ee_download_fw(struct ieee80211_hw *hw, bool buse_wake_on_wlan_fw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + struct rtl92c_firmware_header *pfwheader; + u8 *pfwdata; + u32 fwsize; + int err; + enum version_8192e version = rtlhal->version; + + if (!rtlhal->pfirmware) + return 1; + + pfwheader = (struct rtl92c_firmware_header *)rtlhal->pfirmware; + rtlhal->fw_version = pfwheader->version; + rtlhal->fw_subversion = pfwheader->subversion; + pfwdata = (u8 *) rtlhal->pfirmware; + fwsize = rtlhal->fwsize; + RT_TRACE(COMP_FW, DBG_DMESG, + ("normal Firmware SIZE %d\n" , fwsize)); + + if (IS_FW_HEADER_EXIST(pfwheader)) { + RT_TRACE(COMP_FW, DBG_DMESG, + ("Firmware Version(%d), Signature(%#x), Size(%d)\n", + pfwheader->version, pfwheader->signature, + (int)sizeof(struct rtl92c_firmware_header))); + + pfwdata = pfwdata + sizeof(struct rtl92c_firmware_header); + fwsize = fwsize - sizeof(struct rtl92c_firmware_header); + } else { + RT_TRACE(COMP_FW, DBG_DMESG, + ("Firmware no Header, Signature(%#x)\n", + pfwheader->signature)); + } + + if (rtlhal->b_mac_func_enable) { + if (rtl_read_byte(rtlpriv, REG_MCUFWDL) & BIT(7)) { + rtl_write_byte(rtlpriv, REG_MCUFWDL, 0); + rtl92ee_firmware_selfreset(hw); + } + } + _rtl92ee_enable_fw_download(hw, true); + _rtl92ee_write_fw(hw, version, pfwdata, fwsize); + _rtl92ee_enable_fw_download(hw, false); + + err = _rtl92ee_fw_free_to_go(hw); + if (err) { + RT_TRACE(COMP_ERR, DBG_EMERG, + ("Firmware is not ready to run!\n")); + } else { + RT_TRACE(COMP_FW, DBG_LOUD , + ("Firmware is ready to run!\n")); + } + + return 0; +} + +static bool _rtl92ee_check_fw_read_last_h2c(struct ieee80211_hw *hw, u8 boxnum) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u8 val_hmetfr; + bool result = false; + + val_hmetfr = rtl_read_byte(rtlpriv, REG_HMETFR); + if (((val_hmetfr >> boxnum) & BIT(0)) == 0) + result = true; + return result; +} + +static void _rtl92ee_fill_h2c_command(struct ieee80211_hw *hw, u8 element_id, + u32 cmd_len, u8 *p_cmdbuffer) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + u8 boxnum; + u16 box_reg = 0, box_extreg = 0; + u8 u1b_tmp; + bool isfw_read = false; + u8 buf_index = 0; + bool bwrite_sucess = false; + u8 wait_h2c_limmit = 100; + u8 boxcontent[4], boxextcontent[4]; + u32 h2c_waitcounter = 0; + unsigned long flag; + u8 idx; + + if (ppsc->dot11_psmode != EACTIVE || + ppsc->inactive_pwrstate == ERFOFF) { + RT_TRACE(COMP_CMD, DBG_LOUD , + ("FillH2CCommand8192E(): " + "Return because RF is off!!!\n")); + return; + } + + RT_TRACE(COMP_CMD, DBG_LOUD , ("come in\n")); + + /* 1. Prevent race condition in setting H2C cmd. + * (copy from MgntActSet_RF_State().) + */ + while (true) { + spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag); + if (rtlhal->b_h2c_setinprogress) { + RT_TRACE(COMP_CMD, DBG_LOUD , + ("H2C set in progress! Wait to set.." + "element_id(%d).\n", element_id)); + + while (rtlhal->b_h2c_setinprogress) { + spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, + flag); + h2c_waitcounter++; + RT_TRACE(COMP_CMD, DBG_LOUD , + ("Wait 100 us (%d times)...\n", + h2c_waitcounter)); + udelay(100); + + if (h2c_waitcounter > 1000) + return; + spin_lock_irqsave(&rtlpriv->locks.h2c_lock, + flag); + } + spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag); + } else { + rtlhal->b_h2c_setinprogress = true; + spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag); + break; + } + } + + while (!bwrite_sucess) { + /* cosa remove this because never reach this. */ + /*wait_writeh2c_limmit--; + if (wait_writeh2c_limmit == 0) { + RT_TRACE(COMP_ERR, DBG_EMERG, + ("Write H2C fail because no trigger " + "for FW INT!\n")); + break; + } + */ + /* 2. Find the last BOX number which has been writen. */ + boxnum = rtlhal->last_hmeboxnum; + switch (boxnum) { + case 0: + box_reg = REG_HMEBOX_0; + box_extreg = REG_HMEBOX_EXT_0; + break; + case 1: + box_reg = REG_HMEBOX_1; + box_extreg = REG_HMEBOX_EXT_1; + break; + case 2: + box_reg = REG_HMEBOX_2; + box_extreg = REG_HMEBOX_EXT_2; + break; + case 3: + box_reg = REG_HMEBOX_3; + box_extreg = REG_HMEBOX_EXT_3; + break; + default: + RT_TRACE(COMP_ERR, DBG_EMERG, + ("switch case not process\n")); + break; + } + + /* 3. Check if the box content is empty. */ + isfw_read = false; + u1b_tmp = rtl_read_byte(rtlpriv, REG_CR); + + if (u1b_tmp != 0xea) { + isfw_read = true; + } else { + if (rtl_read_byte(rtlpriv, REG_TXDMA_STATUS) == 0xea || + rtl_read_byte(rtlpriv, REG_TXPKT_EMPTY) == 0xea) + rtl_write_byte(rtlpriv, REG_SYS_CFG1 + 3, 0xff); + } + + if (isfw_read == true) { + wait_h2c_limmit = 100; + isfw_read = _rtl92ee_check_fw_read_last_h2c(hw, boxnum); + while (!isfw_read) { + wait_h2c_limmit--; + if (wait_h2c_limmit == 0) { + RT_TRACE(COMP_CMD, DBG_LOUD , + ("Wating too long for FW" + "read clear HMEBox(%d)!!!\n", + boxnum)); + break; + } + udelay(10); + isfw_read = _rtl92ee_check_fw_read_last_h2c(hw, + boxnum); + u1b_tmp = rtl_read_byte(rtlpriv, 0x130); + RT_TRACE(COMP_CMD, DBG_LOUD , + ("Wating for FW read clear HMEBox(%d)!!! 0x130 = %2x\n", + boxnum, u1b_tmp)); + } + } + + /* If Fw has not read the last + H2C cmd, break and give up this H2C. */ + if (!isfw_read) { + RT_TRACE(COMP_CMD, DBG_LOUD , + ("Write H2C reg BOX[%d] fail, Fw don't read.\n", + boxnum)); + break; + } + /* 4. Fill the H2C cmd into box */ + memset(boxcontent, 0, sizeof(boxcontent)); + memset(boxextcontent, 0, sizeof(boxextcontent)); + boxcontent[0] = element_id; + RT_TRACE(COMP_CMD, DBG_LOUD , + ("Write element_id box_reg(%4x) = %2x\n", + box_reg, element_id)); + + switch (cmd_len) { + case 1: + case 2: + case 3: + /*boxcontent[0] &= ~(BIT(7));*/ + memcpy((u8 *) (boxcontent) + 1, + p_cmdbuffer + buf_index, cmd_len); + + for (idx = 0; idx < 4; idx++) { + rtl_write_byte(rtlpriv, box_reg + idx, + boxcontent[idx]); + } + break; + case 4: + case 5: + case 6: + case 7: + /*boxcontent[0] |= (BIT(7));*/ + memcpy((u8 *) (boxextcontent), + p_cmdbuffer + buf_index+3, cmd_len-3); + memcpy((u8 *) (boxcontent) + 1, + p_cmdbuffer + buf_index, 3); + + for (idx = 0; idx < 4; idx++) { + rtl_write_byte(rtlpriv, box_extreg + idx, + boxextcontent[idx]); + } + + for (idx = 0; idx < 4; idx++) { + rtl_write_byte(rtlpriv, box_reg + idx, + boxcontent[idx]); + } + break; + default: + RT_TRACE(COMP_ERR, DBG_EMERG, + ("switch case not process\n")); + break; + } + + bwrite_sucess = true; + + rtlhal->last_hmeboxnum = boxnum + 1; + if (rtlhal->last_hmeboxnum == 4) + rtlhal->last_hmeboxnum = 0; + + RT_TRACE(COMP_CMD, DBG_LOUD , + ("pHalData->last_hmeboxnum = %d\n", + rtlhal->last_hmeboxnum)); + } + + spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag); + rtlhal->b_h2c_setinprogress = false; + spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag); + + RT_TRACE(COMP_CMD, DBG_LOUD , ("go out\n")); +} + +void rtl92ee_fill_h2c_cmd(struct ieee80211_hw *hw, + u8 element_id, u32 cmd_len, u8 *p_cmdbuffer) +{ + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + u32 tmp_cmdbuf[2]; + + if (rtlhal->bfw_ready == false) { + RT_ASSERT(false, ("return H2C cmd because of Fw " + "download fail!!!\n")); + return; + } + + memset(tmp_cmdbuf, 0, 8); + memcpy(tmp_cmdbuf, p_cmdbuffer, cmd_len); + _rtl92ee_fill_h2c_command(hw, element_id, cmd_len, (u8 *)&tmp_cmdbuf); + + return; +} + +void rtl92ee_firmware_selfreset(struct ieee80211_hw *hw) +{ + u8 u1b_tmp; + struct rtl_priv *rtlpriv = rtl_priv(hw); + + u1b_tmp = rtl_read_byte(rtlpriv, REG_RSV_CTRL + 1); + rtl_write_byte(rtlpriv, REG_RSV_CTRL + 1, (u1b_tmp & (~BIT(0)))); + + u1b_tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1); + rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, (u1b_tmp & (~BIT(2)))); + + udelay(50); + + u1b_tmp = rtl_read_byte(rtlpriv, REG_RSV_CTRL + 1); + rtl_write_byte(rtlpriv, REG_RSV_CTRL + 1, (u1b_tmp | BIT(0))); + + u1b_tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1); + rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, (u1b_tmp | BIT(2))); + + RT_TRACE(COMP_INIT, DBG_LOUD , + (" _8051Reset92E(): 8051 reset success .\n")); +} + +void rtl92ee_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u8 u1_h2c_set_pwrmode[H2C_92E_PWEMODE_LENGTH] = { 0 }; + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + u8 rlbm , power_state = 0; + RT_TRACE(COMP_POWER, DBG_LOUD , ("FW LPS mode = %d\n", mode)); + + SET_H2CCMD_PWRMODE_PARM_MODE(u1_h2c_set_pwrmode, ((mode) ? 1 : 0)); + rlbm = 0;/*YJ, temp, 120316. FW now not support RLBM = 2.*/ + SET_H2CCMD_PWRMODE_PARM_RLBM(u1_h2c_set_pwrmode, rlbm); + SET_H2CCMD_PWRMODE_PARM_SMART_PS(u1_h2c_set_pwrmode, + (rtlpriv->mac80211.p2p) ? + ppsc->smart_ps : 1); + SET_H2CCMD_PWRMODE_PARM_AWAKE_INTERVAL(u1_h2c_set_pwrmode, + ppsc->reg_max_lps_awakeintvl); + SET_H2CCMD_PWRMODE_PARM_ALL_QUEUE_UAPSD(u1_h2c_set_pwrmode, 0); + if (mode == FW_PS_ACTIVE_MODE) + power_state |= FW_PWR_STATE_ACTIVE; + else + power_state |= FW_PWR_STATE_RF_OFF; + SET_H2CCMD_PWRMODE_PARM_PWR_STATE(u1_h2c_set_pwrmode, power_state); + + RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, + "rtl92c_set_fw_pwrmode(): u1_h2c_set_pwrmode\n", + u1_h2c_set_pwrmode, H2C_92E_PWEMODE_LENGTH); + rtl92ee_fill_h2c_cmd(hw, H2C_92E_SETPWRMODE, H2C_92E_PWEMODE_LENGTH, + u1_h2c_set_pwrmode); + +} + +void rtl92ee_set_fw_media_status_rpt_cmd(struct ieee80211_hw *hw, u8 mstatus) +{ + u8 parm[3] = { 0 , 0 , 0 }; + /* parm[0]: bit0 = 0-->Disconnect, bit0 = 1-->Connect + * bit1 = 0-->update Media Status to MACID + * bit1 = 1-->update Media Status from MACID to MACID_End + * parm[1]: MACID, if this is INFRA_STA, MacID = 0 + * parm[2]: MACID_End*/ + + SET_H2CCMD_MSRRPT_PARM_OPMODE(parm, mstatus); + SET_H2CCMD_MSRRPT_PARM_MACID_IND(parm, 0); + + rtl92ee_fill_h2c_cmd(hw, H2C_92E_MSRRPT, 3, parm); +} + +static bool _rtl92ee_cmd_send_packet(struct ieee80211_hw *hw, + struct sk_buff *skb) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + struct rtl8192_tx_ring *ring; + struct rtl_tx_desc *pdesc; + unsigned long flags; + struct sk_buff *pskb = NULL; + + ring = &rtlpci->tx_ring[BEACON_QUEUE]; + + pskb = __skb_dequeue(&ring->queue); + if (pskb) + kfree_skb(pskb); + + spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags); + /*this is wrong, fill_tx_cmddesc needs update*/ + pdesc = &ring->desc[0]; + + rtlpriv->cfg->ops->fill_tx_cmddesc(hw, (u8 *) pdesc, 1, 1, skb); + + __skb_queue_tail(&ring->queue, skb); + + spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags); + + return true; +} + +#define BEACON_PG 0 /* ->1 */ +#define PSPOLL_PG 2 +#define NULL_PG 3 +#define PROBERSP_PG 4 /* ->5 */ + +#define TOTAL_RESERVED_PKT_LEN 768 + + + +static u8 reserved_page_packet[TOTAL_RESERVED_PKT_LEN] = { + /* page 0 beacon */ + 0x80, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0x00, 0xE0, 0x4C, 0x02, 0xB1, 0x78, + 0xEC, 0x1A, 0x59, 0x0B, 0xAD, 0xD4, 0x20, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x64, 0x00, 0x10, 0x04, 0x00, 0x05, 0x54, 0x65, + 0x73, 0x74, 0x32, 0x01, 0x08, 0x82, 0x84, 0x0B, + 0x16, 0x24, 0x30, 0x48, 0x6C, 0x03, 0x01, 0x06, + 0x06, 0x02, 0x00, 0x00, 0x2A, 0x01, 0x02, 0x32, + 0x04, 0x0C, 0x12, 0x18, 0x60, 0x2D, 0x1A, 0x6C, + 0x09, 0x03, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x3D, 0x00, 0xDD, 0x07, 0x00, 0xE0, 0x4C, + 0x02, 0x02, 0x00, 0x00, 0xDD, 0x18, 0x00, 0x50, + 0xF2, 0x01, 0x01, 0x00, 0x00, 0x50, 0xF2, 0x04, + 0x01, 0x00, 0x00, 0x50, 0xF2, 0x04, 0x01, 0x00, + + /* page 1 beacon */ + 0x00, 0x50, 0xF2, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x28, 0x8C, 0x00, 0x12, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + + /* page 2 ps-poll */ + 0xA4, 0x10, 0x01, 0xC0, 0xEC, 0x1A, 0x59, 0x0B, + 0xAD, 0xD4, 0x00, 0xE0, 0x4C, 0x02, 0xB1, 0x78, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x00, 0x28, 0x8C, 0x00, 0x12, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + + /* page 3 null */ + 0x48, 0x01, 0x00, 0x00, 0xEC, 0x1A, 0x59, 0x0B, + 0xAD, 0xD4, 0x00, 0xE0, 0x4C, 0x02, 0xB1, 0x78, + 0xEC, 0x1A, 0x59, 0x0B, 0xAD, 0xD4, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x72, 0x00, 0x28, 0x8C, 0x00, 0x12, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + + /* page 4 probe_resp */ + 0x50, 0x00, 0x00, 0x00, 0x00, 0x40, 0x10, 0x10, + 0x00, 0x03, 0x00, 0xE0, 0x4C, 0x76, 0x00, 0x42, + 0x00, 0x40, 0x10, 0x10, 0x00, 0x03, 0x00, 0x00, + 0x9E, 0x46, 0x15, 0x32, 0x27, 0xF2, 0x2D, 0x00, + 0x64, 0x00, 0x00, 0x04, 0x00, 0x0C, 0x6C, 0x69, + 0x6E, 0x6B, 0x73, 0x79, 0x73, 0x5F, 0x77, 0x6C, + 0x61, 0x6E, 0x01, 0x04, 0x82, 0x84, 0x8B, 0x96, + 0x03, 0x01, 0x01, 0x06, 0x02, 0x00, 0x00, 0x2A, + 0x01, 0x00, 0x32, 0x08, 0x24, 0x30, 0x48, 0x6C, + 0x0C, 0x12, 0x18, 0x60, 0x2D, 0x1A, 0x6C, 0x18, + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3D, 0x00, 0xDD, 0x06, 0x00, 0xE0, 0x4C, 0x02, + 0x01, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + + /* page 5 probe_resp */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + + + +void rtl92ee_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct sk_buff *skb = NULL; + + u32 totalpacketlen; + bool rtstatus; + u8 u1RsvdPageLoc[5] = { 0 }; + bool b_dlok = false; + + u8 *beacon; + u8 *p_pspoll; + u8 *nullfunc; + u8 *p_probersp; + /*--------------------------------------------------------- + (1) beacon + ---------------------------------------------------------*/ + beacon = &reserved_page_packet[BEACON_PG * 128]; + SET_80211_HDR_ADDRESS2(beacon, mac->mac_addr); + SET_80211_HDR_ADDRESS3(beacon, mac->bssid); + + /*------------------------------------------------------- + (2) ps-poll + --------------------------------------------------------*/ + p_pspoll = &reserved_page_packet[PSPOLL_PG * 128]; + SET_80211_PS_POLL_AID(p_pspoll, (mac->assoc_id | 0xc000)); + SET_80211_PS_POLL_BSSID(p_pspoll, mac->bssid); + SET_80211_PS_POLL_TA(p_pspoll, mac->mac_addr); + + SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(u1RsvdPageLoc, PSPOLL_PG); + + /*-------------------------------------------------------- + (3) null data + ---------------------------------------------------------*/ + nullfunc = &reserved_page_packet[NULL_PG * 128]; + SET_80211_HDR_ADDRESS1(nullfunc, mac->bssid); + SET_80211_HDR_ADDRESS2(nullfunc, mac->mac_addr); + SET_80211_HDR_ADDRESS3(nullfunc, mac->bssid); + + SET_H2CCMD_RSVDPAGE_LOC_NULL_DATA(u1RsvdPageLoc, NULL_PG); + + /*--------------------------------------------------------- + (4) probe response + ----------------------------------------------------------*/ + p_probersp = &reserved_page_packet[PROBERSP_PG * 128]; + SET_80211_HDR_ADDRESS1(p_probersp, mac->bssid); + SET_80211_HDR_ADDRESS2(p_probersp, mac->mac_addr); + SET_80211_HDR_ADDRESS3(p_probersp, mac->bssid); + + SET_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(u1RsvdPageLoc, PROBERSP_PG); + + totalpacketlen = TOTAL_RESERVED_PKT_LEN; + + RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD , + "rtl92ee_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL\n", + &reserved_page_packet[0], totalpacketlen); + RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD , + "rtl92ee_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL\n", + u1RsvdPageLoc, 3); + + + skb = dev_alloc_skb(totalpacketlen); + memcpy((u8 *) skb_put(skb, totalpacketlen), + &reserved_page_packet, totalpacketlen); + + rtstatus = _rtl92ee_cmd_send_packet(hw, skb); + + if (rtstatus) + b_dlok = true; + + if (b_dlok) { + RT_TRACE(COMP_POWER, DBG_LOUD , + ("Set RSVD page location to Fw.\n")); + RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD , + "H2C_RSVDPAGE:\n", u1RsvdPageLoc, 3); + rtl92ee_fill_h2c_cmd(hw, H2C_92E_RSVDPAGE, + sizeof(u1RsvdPageLoc), u1RsvdPageLoc); + } else + RT_TRACE(COMP_ERR, DBG_WARNING, + ("Set RSVD page location to Fw FAIL!!!!!!.\n")); +} + +/*Shoud check FW support p2p or not.*/ +static void rtl92ee_set_p2p_ctw_period_cmd(struct ieee80211_hw *hw, u8 ctwindow) +{ + u8 u1_ctwindow_period[1] = {ctwindow}; + + rtl92ee_fill_h2c_cmd(hw, H2C_92E_P2P_PS_CTW_CMD, 1, u1_ctwindow_period); + +} + +void rtl92ee_set_p2p_ps_offload_cmd(struct ieee80211_hw *hw, u8 p2p_ps_state) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_ps_ctl *rtlps = rtl_psc(rtl_priv(hw)); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + struct rtl_p2p_ps_info *p2pinfo = &(rtlps->p2p_ps_info); + struct p2p_ps_offload_t *p2p_ps_offload = &rtlhal->p2p_ps_offload; + u8 i; + u16 ctwindow; + u32 start_time, tsf_low; + + switch (p2p_ps_state) { + case P2P_PS_DISABLE: + RT_TRACE(COMP_FW, DBG_LOUD , ("P2P_PS_DISABLE\n")); + memset(p2p_ps_offload, 0, 1); + break; + case P2P_PS_ENABLE: + RT_TRACE(COMP_FW, DBG_LOUD , ("P2P_PS_ENABLE\n")); + /* update CTWindow value. */ + if (p2pinfo->ctwindow > 0) { + p2p_ps_offload->CTWindow_En = 1; + ctwindow = p2pinfo->ctwindow; + rtl92ee_set_p2p_ctw_period_cmd(hw, ctwindow); + } + /* hw only support 2 set of NoA */ + for (i = 0 ; i < p2pinfo->noa_num ; i++) { + /* To control the register setting for which NOA*/ + rtl_write_byte(rtlpriv, 0x5cf, (i << 4)); + if (i == 0) + p2p_ps_offload->NoA0_En = 1; + else + p2p_ps_offload->NoA1_En = 1; + /* config P2P NoA Descriptor Register */ + rtl_write_dword(rtlpriv, 0x5E0, + p2pinfo->noa_duration[i]); + rtl_write_dword(rtlpriv, 0x5E4, + p2pinfo->noa_interval[i]); + + /*Get Current TSF value */ + tsf_low = rtl_read_dword(rtlpriv, REG_TSFTR); + + start_time = p2pinfo->noa_start_time[i]; + if (p2pinfo->noa_count_type[i] != 1) { + while (start_time <= (tsf_low + (50 * 1024))) { + start_time += p2pinfo->noa_interval[i]; + if (p2pinfo->noa_count_type[i] != 255) + p2pinfo->noa_count_type[i]--; + } + } + rtl_write_dword(rtlpriv, 0x5E8, start_time); + rtl_write_dword(rtlpriv, 0x5EC, + p2pinfo->noa_count_type[i]); + } + if ((p2pinfo->opp_ps == 1) || (p2pinfo->noa_num > 0)) { + /* rst p2p circuit */ + rtl_write_byte(rtlpriv, REG_DUAL_TSF_RST, BIT(4)); + p2p_ps_offload->Offload_En = 1; + + if (P2P_ROLE_GO == rtlpriv->mac80211.p2p) { + p2p_ps_offload->role = 1; + p2p_ps_offload->AllStaSleep = 0; + } else { + p2p_ps_offload->role = 0; + } + p2p_ps_offload->discovery = 0; + } + break; + case P2P_PS_SCAN: + RT_TRACE(COMP_FW, DBG_LOUD , ("P2P_PS_SCAN\n")); + p2p_ps_offload->discovery = 1; + break; + case P2P_PS_SCAN_DONE: + RT_TRACE(COMP_FW, DBG_LOUD , ("P2P_PS_SCAN_DONE\n")); + p2p_ps_offload->discovery = 0; + p2pinfo->p2p_ps_state = P2P_PS_ENABLE; + break; + default: + break; + } + + rtl92ee_fill_h2c_cmd(hw, H2C_92E_P2P_PS_OFFLOAD, 1, + (u8 *)p2p_ps_offload); + +} + +static void _rtl92ee_c2h_ra_report_handler(struct ieee80211_hw *hw, + u8 *cmd_buf, u8 cmd_len) +{ + u8 rate = cmd_buf[0] & 0x3F; + bool collision_state = cmd_buf[3] & BIT(0); + + rtl92ee_dm_dynamic_arfb_select(hw, rate, collision_state); +} + +static void _rtl92ee_c2h_content_parsing(struct ieee80211_hw *hw, u8 c2h_cmd_id, + u8 c2h_cmd_len, u8 *tmp_buf) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + switch (c2h_cmd_id) { + case C2H_8192E_DBG: + RT_TRACE(COMP_FW, DBG_TRACE , ("[C2H], C2H_8723BE_DBG!!\n")); + break; + case C2H_8192E_TXBF: + RT_TRACE(COMP_FW, DBG_TRACE , ("[C2H], C2H_8192E_TXBF!!\n")); + break; + case C2H_8192E_TX_REPORT: + RT_TRACE(COMP_FW, DBG_TRACE , ("[C2H], C2H_8723BE_TX_REPORT!\n")); + break; + case C2H_8192E_BT_INFO: + RT_TRACE(COMP_FW, DBG_TRACE , ("[C2H], C2H_8723BE_BT_INFO!!\n")); + rtlpriv->btcoexist.btc_ops->btc_btinfo_notify(rtlpriv, tmp_buf, + c2h_cmd_len); + break; + case C2H_8192E_BT_MP: + RT_TRACE(COMP_FW, DBG_TRACE, ("[C2H], C2H_8723BE_BT_MP!!\n")); + break; + case C2H_8192E_RA_RPT: + _rtl92ee_c2h_ra_report_handler(hw, tmp_buf, c2h_cmd_len); + break; + default: + RT_TRACE(COMP_FW, DBG_TRACE, + ("[C2H], Unkown packet!! CmdId(%#X)!\n", c2h_cmd_id)); + break; + } +} + +void rtl92ee_c2h_packet_handler(struct ieee80211_hw *hw, u8 *buffer, u8 len) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u8 c2h_cmd_id = 0, c2h_cmd_seq = 0, c2h_cmd_len = 0; + u8 *tmp_buf = NULL; + + c2h_cmd_id = buffer[0]; + c2h_cmd_seq = buffer[1]; + c2h_cmd_len = len - 2; + tmp_buf = buffer + 2; + + RT_TRACE(COMP_FW, DBG_TRACE, + ("[C2H packet], c2hCmdId = 0x%x, c2hCmdSeq = 0x%x, c2hCmdLen =%d\n", + c2h_cmd_id, c2h_cmd_seq, c2h_cmd_len)); + + RT_PRINT_DATA(rtlpriv, COMP_FW, DBG_TRACE, + "[C2H packet], Content Hex:\n", tmp_buf, c2h_cmd_len); + + _rtl92ee_c2h_content_parsing(hw, c2h_cmd_id, c2h_cmd_len, tmp_buf); +} diff --git a/drivers/staging/rtl8192ee/rtl8192ee/fw.h b/drivers/staging/rtl8192ee/rtl8192ee/fw.h new file mode 100644 index 000000000000..143992d5f622 --- /dev/null +++ b/drivers/staging/rtl8192ee/rtl8192ee/fw.h @@ -0,0 +1,213 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * Larry Finger + * + *****************************************************************************/ + +#ifndef __RTL92E__FW__H__ +#define __RTL92E__FW__H__ + +#define FW_8192C_SIZE 0x8000 +#define FW_8192C_START_ADDRESS 0x1000 +#define FW_8192C_END_ADDRESS 0x5FFF +#define FW_8192C_PAGE_SIZE 4096 +#define FW_8192C_POLLING_DELAY 5 +#define FW_8192C_POLLING_TIMEOUT_COUNT 3000 + +#define IS_FW_HEADER_EXIST(_pfwhdr) \ + ((_pfwhdr->signature&0xFFF0) == 0x92E0) +#define USE_OLD_WOWLAN_DEBUG_FW 0 + +#define H2C_92E_RSVDPAGE_LOC_LEN 5 +#define H2C_92E_PWEMODE_LENGTH 5 +#define H2C_92E_JOINBSSRPT_LENGTH 1 +#define H2C_92E_AP_OFFLOAD_LENGTH 3 +#define H2C_92E_WOWLAN_LENGTH 3 +#define H2C_92E_KEEP_ALIVE_CTRL_LENGTH 3 +#if (USE_OLD_WOWLAN_DEBUG_FW == 0) +#define H2C_92E_REMOTE_WAKE_CTRL_LEN 1 +#else +#define H2C_92E_REMOTE_WAKE_CTRL_LEN 3 +#endif +#define H2C_92E_AOAC_GLOBAL_INFO_LEN 2 +#define H2C_92E_AOAC_RSVDPAGE_LOC_LEN 7 + + +/* Fw PS state for RPWM. +*BIT[2:0] = HW state +*BIT[3] = Protocol PS state, 1: register active state, 0: register sleep state +*BIT[4] = sub-state +*/ +#define FW_PS_RF_ON BIT(2) +#define FW_PS_REGISTER_ACTIVE BIT(3) + +#define FW_PS_ACK BIT(6) +#define FW_PS_TOGGLE BIT(7) + + /* 92E RPWM value*/ + /* BIT[0] = 1: 32k, 0: 40M*/ +#define FW_PS_CLOCK_OFF BIT(0) /* 32k */ +#define FW_PS_CLOCK_ON 0 /* 40M */ + +#define FW_PS_STATE_MASK (0x0F) +#define FW_PS_STATE_HW_MASK (0x07) +#define FW_PS_STATE_INT_MASK (0x3F) + +#define FW_PS_STATE(x) (FW_PS_STATE_MASK & (x)) + +#define FW_PS_STATE_ALL_ON_92E (FW_PS_CLOCK_ON) +#define FW_PS_STATE_RF_ON_92E (FW_PS_CLOCK_ON) +#define FW_PS_STATE_RF_OFF_92E (FW_PS_CLOCK_ON) +#define FW_PS_STATE_RF_OFF_LOW_PWR (FW_PS_CLOCK_OFF) + +/* For 92E H2C PwrMode Cmd ID 5.*/ +#define FW_PWR_STATE_ACTIVE ((FW_PS_RF_ON) | (FW_PS_REGISTER_ACTIVE)) +#define FW_PWR_STATE_RF_OFF 0 + +#define FW_PS_IS_ACK(x) ((x) & FW_PS_ACK) + +#define IS_IN_LOW_POWER_STATE_92E(FwPSState) \ + (FW_PS_STATE(FwPSState) == FW_PS_CLOCK_OFF) + +#define FW_PWR_STATE_ACTIVE ((FW_PS_RF_ON) | (FW_PS_REGISTER_ACTIVE)) +#define FW_PWR_STATE_RF_OFF 0 + +struct rtl92c_firmware_header { + u16 signature; + u8 category; + u8 function; + u16 version; + u8 subversion; + u8 rsvd1; + u8 month; + u8 date; + u8 hour; + u8 minute; + u16 ramcodeSize; + u16 rsvd2; + u32 svnindex; + u32 rsvd3; + u32 rsvd4; + u32 rsvd5; +}; + +enum rtl8192c_h2c_cmd { + H2C_92E_RSVDPAGE = 0, + H2C_92E_MSRRPT = 1, + H2C_92E_SCAN = 2, + H2C_92E_KEEP_ALIVE_CTRL = 3, + H2C_92E_DISCONNECT_DECISION = 4, +#if (USE_OLD_WOWLAN_DEBUG_FW == 1) + H2C_92E_WO_WLAN = 5, +#endif + H2C_92E_INIT_OFFLOAD = 6, +#if (USE_OLD_WOWLAN_DEBUG_FW == 1) + H2C_92E_REMOTE_WAKE_CTRL = 7, +#endif + H2C_92E_AP_OFFLOAD = 8, + H2C_92E_BCN_RSVDPAGE = 9, + H2C_92E_PROBERSP_RSVDPAGE = 10, + + H2C_92E_SETPWRMODE = 0x20, + H2C_92E_PS_TUNING_PARA = 0x21, + H2C_92E_PS_TUNING_PARA2 = 0x22, + H2C_92E_PS_LPS_PARA = 0x23, + H2C_92E_P2P_PS_OFFLOAD = 024, + +#if (USE_OLD_WOWLAN_DEBUG_FW == 0) + H2C_92E_WO_WLAN = 0x80, + H2C_92E_REMOTE_WAKE_CTRL = 0x81, + H2C_92E_AOAC_GLOBAL_INFO = 0x82, + H2C_92E_AOAC_RSVDPAGE = 0x83, +#endif + H2C_92E_RA_MASK = 0x40, + H2C_92E_RSSI_REPORT = 0x42, + H2C_92E_SELECTIVE_SUSPEND_ROF_CMD, + H2C_92E_P2P_PS_MODE, + H2C_92E_PSD_RESULT, + /*Not defined CTW CMD for P2P yet*/ + H2C_92E_P2P_PS_CTW_CMD, + MAX_92E_H2CCMD +}; + +enum rtl8192e_c2h_evt { + C2H_8192E_DBG = 0, + C2H_8192E_LB = 1, + C2H_8192E_TXBF = 2, + C2H_8192E_TX_REPORT = 3, + C2H_8192E_BT_INFO = 9, + C2H_8192E_BT_MP = 11, + C2H_8192E_RA_RPT = 12, + MAX_8192E_C2HEVENT +}; + +#define pagenum_128(_len) \ + (u32)(((_len) >> 7) + ((_len) & 0x7F ? 1 : 0)) + +#define SET_H2CCMD_PWRMODE_PARM_MODE(__ph2ccmd, __val) \ + SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val) +#define SET_H2CCMD_PWRMODE_PARM_RLBM(__pH2CCmd, __val) \ + SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 0, 4, __val) +#define SET_H2CCMD_PWRMODE_PARM_SMART_PS(__pH2CCmd, __val) \ + SET_BITS_TO_LE_1BYTE((__pH2CCmd)+1, 4, 4, __val) +#define SET_H2CCMD_PWRMODE_PARM_AWAKE_INTERVAL(__pH2CCmd, __val) \ + SET_BITS_TO_LE_1BYTE((__pH2CCmd)+2, 0, 8, __val) +#define SET_H2CCMD_PWRMODE_PARM_ALL_QUEUE_UAPSD(__pH2CCmd, __val) \ + SET_BITS_TO_LE_1BYTE((__pH2CCmd)+3, 0, 8, __val) +#define SET_H2CCMD_PWRMODE_PARM_PWR_STATE(__pH2CCmd, __val) \ + SET_BITS_TO_LE_1BYTE((__pH2CCmd)+4, 0, 8, __val) +#define GET_92E_H2CCMD_PWRMODE_PARM_MODE(__pH2CCmd) \ + LE_BITS_TO_1BYTE(__pH2CCmd, 0, 8) + +#define SET_H2CCMD_JOINBSSRPT_PARM_OPMODE(__ph2ccmd, __val) \ + SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val) +#define SET_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(__ph2ccmd, __val) \ + SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val) +#define SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(__ph2ccmd, __val) \ + SET_BITS_TO_LE_1BYTE((__ph2ccmd)+1, 0, 8, __val) +#define SET_H2CCMD_RSVDPAGE_LOC_NULL_DATA(__ph2ccmd, __val) \ + SET_BITS_TO_LE_1BYTE((__ph2ccmd)+2, 0, 8, __val) + +/* _MEDIA_STATUS_RPT_PARM_CMD1 */ +#define SET_H2CCMD_MSRRPT_PARM_OPMODE(__pH2CCmd, __Value) \ + SET_BITS_TO_LE_1BYTE(__pH2CCmd, 0, 1, __Value) +#define SET_H2CCMD_MSRRPT_PARM_MACID_IND(__pH2CCmd, __Value) \ + SET_BITS_TO_LE_1BYTE(__pH2CCmd, 1, 1, __Value) +#define SET_H2CCMD_MSRRPT_PARM_MACID(__pH2CCmd, __Value) \ + SET_BITS_TO_LE_1BYTE(__pH2CCmd+1, 0, 8, __Value) +#define SET_H2CCMD_MSRRPT_PARM_MACID_END(__pH2CCmd, __Value) \ + SET_BITS_TO_LE_1BYTE(__pH2CCmd+2, 0, 8, __Value) + + +int rtl92ee_download_fw(struct ieee80211_hw *hw, bool buse_wake_on_wlan_fw); +void rtl92ee_fill_h2c_cmd(struct ieee80211_hw *hw, u8 element_id, + u32 cmd_len, u8 *p_cmdbuffer); +void rtl92ee_firmware_selfreset(struct ieee80211_hw *hw); +void rtl92ee_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode); +void rtl92ee_set_fw_media_status_rpt_cmd(struct ieee80211_hw *hw, u8 mstatus); +void rtl92ee_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished); +void rtl92ee_set_p2p_ps_offload_cmd(struct ieee80211_hw *hw, u8 p2p_ps_state); +void rtl92ee_c2h_packet_handler(struct ieee80211_hw *hw, u8 *buffer, u8 len); +#endif diff --git a/drivers/staging/rtl8192ee/rtl8192ee/hw.c b/drivers/staging/rtl8192ee/rtl8192ee/hw.c new file mode 100644 index 000000000000..26af119e2ca4 --- /dev/null +++ b/drivers/staging/rtl8192ee/rtl8192ee/hw.c @@ -0,0 +1,2544 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#include "../wifi.h" +#include "../efuse.h" +#include "../base.h" +#include "../regd.h" +#include "../cam.h" +#include "../ps.h" +#include "../pci.h" +#include "reg.h" +#include "def.h" +#include "phy.h" +#include "dm.h" +#include "fw.h" +#include "led.h" +#include "hw.h" +#include "pwrseqcmd.h" +#include "pwrseq.h" + +#define LLT_CONFIG 5 + +static void _rtl92ee_set_bcn_ctrl_reg(struct ieee80211_hw *hw, + u8 set_bits, u8 clear_bits) +{ + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + struct rtl_priv *rtlpriv = rtl_priv(hw); + + rtlpci->reg_bcn_ctrl_val |= set_bits; + rtlpci->reg_bcn_ctrl_val &= ~clear_bits; + + rtl_write_byte(rtlpriv, REG_BCN_CTRL, (u8) rtlpci->reg_bcn_ctrl_val); +} + +static void _rtl92ee_stop_tx_beacon(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u8 tmp; + + tmp = rtl_read_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2); + rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2, tmp & (~BIT(6))); + rtl_write_byte(rtlpriv, REG_TBTT_PROHIBIT + 1, 0x64); + tmp = rtl_read_byte(rtlpriv, REG_TBTT_PROHIBIT + 2); + tmp &= ~(BIT(0)); + rtl_write_byte(rtlpriv, REG_TBTT_PROHIBIT + 2, tmp); +} + +static void _rtl92ee_resume_tx_beacon(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u8 tmp; + + tmp = rtl_read_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2); + rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2, tmp | BIT(6)); + rtl_write_byte(rtlpriv, REG_TBTT_PROHIBIT + 1, 0xff); + tmp = rtl_read_byte(rtlpriv, REG_TBTT_PROHIBIT + 2); + tmp |= BIT(0); + rtl_write_byte(rtlpriv, REG_TBTT_PROHIBIT + 2, tmp); +} + +static void _rtl92ee_enable_bcn_sub_func(struct ieee80211_hw *hw) +{ + _rtl92ee_set_bcn_ctrl_reg(hw, 0, BIT(1)); +} + +static void _rtl92ee_return_beacon_queue_skb(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[BEACON_QUEUE]; + + while (skb_queue_len(&ring->queue)) { + struct rtl_tx_buffer_desc *entry = + &ring->buffer_desc[ring->idx]; + struct sk_buff *skb = __skb_dequeue(&ring->queue); + + pci_unmap_single(rtlpci->pdev, + rtlpriv->cfg->ops->get_desc( + (u8 *) entry, true, HW_DESC_TXBUFF_ADDR), + skb->len, PCI_DMA_TODEVICE); + kfree_skb(skb); + ring->idx = (ring->idx + 1) % ring->entries; + } + +} +static void _rtl92ee_disable_bcn_sub_func(struct ieee80211_hw *hw) +{ + _rtl92ee_set_bcn_ctrl_reg(hw, BIT(1), 0); +} + +static void _rtl92ee_set_fw_clock_on(struct ieee80211_hw *hw, + u8 rpwm_val, bool b_need_turn_off_ckk) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + bool b_support_remote_wake_up; + u32 count = 0 , isr_regaddr , content; + bool b_schedule_timer = b_need_turn_off_ckk; + rtlpriv->cfg->ops->get_hw_reg(hw, HAL_DEF_WOWLAN, + (u8 *) (&b_support_remote_wake_up)); + + if (!rtlhal->bfw_ready) + return; + if (!rtlpriv->psc.b_fw_current_inpsmode) + return; + + while (1) { + spin_lock_bh(&rtlpriv->locks.fw_ps_lock); + if (rtlhal->bfw_clk_change_in_progress) { + while (rtlhal->bfw_clk_change_in_progress) { + spin_unlock_bh(&rtlpriv->locks.fw_ps_lock); + count++; + udelay(100); + if (count > 1000) + return; + spin_lock_bh(&rtlpriv->locks.fw_ps_lock); + } + spin_unlock_bh(&rtlpriv->locks.fw_ps_lock); + } else { + rtlhal->bfw_clk_change_in_progress = false; + spin_unlock_bh(&rtlpriv->locks.fw_ps_lock); + break; + } + } + + if (IS_IN_LOW_POWER_STATE_92E(rtlhal->fw_ps_state)) { + rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_SET_RPWM, + (u8 *) (&rpwm_val)); + if (FW_PS_IS_ACK(rpwm_val)) { + isr_regaddr = REG_HISR; + content = rtl_read_dword(rtlpriv, isr_regaddr); + while (!(content & IMR_CPWM) && (count < 500)) { + udelay(50); + count++; + content = rtl_read_dword(rtlpriv, isr_regaddr); + } + + if (content & IMR_CPWM) { + rtl_write_word(rtlpriv , isr_regaddr, 0x0100); + rtlhal->fw_ps_state = FW_PS_STATE_RF_ON_92E; + RT_TRACE(COMP_POWER, DBG_LOUD, + ("Receive CPWM INT!!! PSState = %X\n", + rtlhal->fw_ps_state)); + } + } + + spin_lock_bh(&rtlpriv->locks.fw_ps_lock); + rtlhal->bfw_clk_change_in_progress = false; + spin_unlock_bh(&rtlpriv->locks.fw_ps_lock); + if (b_schedule_timer) { + mod_timer(&rtlpriv->works.fw_clockoff_timer, + jiffies + MSECS(10)); + } + + } else { + spin_lock_bh(&rtlpriv->locks.fw_ps_lock); + rtlhal->bfw_clk_change_in_progress = false; + spin_unlock_bh(&rtlpriv->locks.fw_ps_lock); + } + + +} + +static void _rtl92ee_set_fw_clock_off(struct ieee80211_hw *hw, u8 rpwm_val) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + struct rtl8192_tx_ring *ring; + enum rf_pwrstate rtstate; + bool b_schedule_timer = false; + u8 queue; + + if (!rtlhal->bfw_ready) + return; + if (!rtlpriv->psc.b_fw_current_inpsmode) + return; + if (!rtlhal->ballow_sw_to_change_hwclc) + return; + + rtlpriv->cfg->ops->get_hw_reg(hw , HW_VAR_RF_STATE , (u8 *)(&rtstate)); + if (rtstate == ERFOFF || rtlpriv->psc.inactive_pwrstate == ERFOFF) + return; + + for (queue = 0; queue < RTL_PCI_MAX_TX_QUEUE_COUNT; queue++) { + ring = &rtlpci->tx_ring[queue]; + if (skb_queue_len(&ring->queue)) { + b_schedule_timer = true; + break; + } + } + + if (b_schedule_timer) { + mod_timer(&rtlpriv->works.fw_clockoff_timer, + jiffies + MSECS(10)); + return; + } + + if (FW_PS_STATE(rtlhal->fw_ps_state) != FW_PS_STATE_RF_OFF_LOW_PWR) { + spin_lock_bh(&rtlpriv->locks.fw_ps_lock); + if (!rtlhal->bfw_clk_change_in_progress) { + rtlhal->bfw_clk_change_in_progress = true; + spin_unlock_bh(&rtlpriv->locks.fw_ps_lock); + rtlhal->fw_ps_state = FW_PS_STATE(rpwm_val); + rtl_write_word(rtlpriv, REG_HISR, 0x0100); + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SET_RPWM, + (u8 *) (&rpwm_val)); + spin_lock_bh(&rtlpriv->locks.fw_ps_lock); + rtlhal->bfw_clk_change_in_progress = false; + spin_unlock_bh(&rtlpriv->locks.fw_ps_lock); + } else { + spin_unlock_bh(&rtlpriv->locks.fw_ps_lock); + mod_timer(&rtlpriv->works.fw_clockoff_timer, + jiffies + MSECS(10)); + } + } +} + +static void _rtl92ee_set_fw_ps_rf_on(struct ieee80211_hw *hw) +{ + u8 rpwm_val = 0; + rpwm_val |= (FW_PS_STATE_RF_OFF_92E | FW_PS_ACK); + _rtl92ee_set_fw_clock_on(hw, rpwm_val, true); +} + +static void _rtl92ee_set_fw_ps_rf_off_low_power(struct ieee80211_hw *hw) +{ + u8 rpwm_val = 0; + rpwm_val |= FW_PS_STATE_RF_OFF_LOW_PWR; + _rtl92ee_set_fw_clock_off(hw, rpwm_val); +} +void rtl92ee_fw_clk_off_timer_callback(unsigned long data) +{ + struct ieee80211_hw *hw = (struct ieee80211_hw *)data; + + _rtl92ee_set_fw_ps_rf_off_low_power(hw); +} + +static void _rtl92ee_fwlps_leave(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + bool b_fw_current_inps = false; + u8 rpwm_val = 0, fw_pwrmode = FW_PS_ACTIVE_MODE; + + if (ppsc->b_low_power_enable) { + rpwm_val = (FW_PS_STATE_ALL_ON_92E | FW_PS_ACK);/* RF on */ + _rtl92ee_set_fw_clock_on(hw, rpwm_val, false); + rtlhal->ballow_sw_to_change_hwclc = false; + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_H2C_FW_PWRMODE, + (u8 *) (&fw_pwrmode)); + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_FW_PSMODE_STATUS, + (u8 *) (&b_fw_current_inps)); + } else { + rpwm_val = FW_PS_STATE_ALL_ON_92E; /* RF on */ + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SET_RPWM, + (u8 *) (&rpwm_val)); + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_H2C_FW_PWRMODE, + (u8 *) (&fw_pwrmode)); + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_FW_PSMODE_STATUS, + (u8 *) (&b_fw_current_inps)); + } +} + +static void _rtl92ee_fwlps_enter(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + bool b_fw_current_inps = true; + u8 rpwm_val; + + if (ppsc->b_low_power_enable) { + rpwm_val = FW_PS_STATE_RF_OFF_LOW_PWR; /* RF off */ + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_FW_PSMODE_STATUS, + (u8 *) (&b_fw_current_inps)); + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_H2C_FW_PWRMODE, + (u8 *) (&ppsc->fwctrl_psmode)); + rtlhal->ballow_sw_to_change_hwclc = true; + _rtl92ee_set_fw_clock_off(hw, rpwm_val); + } else { + rpwm_val = FW_PS_STATE_RF_OFF_92E; /* RF off */ + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_FW_PSMODE_STATUS, + (u8 *) (&b_fw_current_inps)); + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_H2C_FW_PWRMODE, + (u8 *) (&ppsc->fwctrl_psmode)); + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SET_RPWM, + (u8 *) (&rpwm_val)); + } +} + +void rtl92ee_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + + switch (variable) { + case HW_VAR_RCR: + *((u32 *) (val)) = rtlpci->receive_config; + break; + case HW_VAR_RF_STATE: + *((enum rf_pwrstate *)(val)) = ppsc->rfpwr_state; + break; + case HW_VAR_FWLPS_RF_ON:{ + enum rf_pwrstate rfState; + u32 val_rcr; + + rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_RF_STATE, + (u8 *) (&rfState)); + if (rfState == ERFOFF) { + *((bool *) (val)) = true; + } else { + val_rcr = rtl_read_dword(rtlpriv, REG_RCR); + val_rcr &= 0x00070000; + if (val_rcr) + *((bool *) (val)) = false; + else + *((bool *) (val)) = true; + } + break; } + case HW_VAR_FW_PSMODE_STATUS: + *((bool *) (val)) = ppsc->b_fw_current_inpsmode; + break; + case HW_VAR_CORRECT_TSF:{ + u64 tsf; + u32 *ptsf_low = (u32 *) &tsf; + u32 *ptsf_high = ((u32 *) &tsf) + 1; + + *ptsf_high = rtl_read_dword(rtlpriv, (REG_TSFTR + 4)); + *ptsf_low = rtl_read_dword(rtlpriv, REG_TSFTR); + + *((u64 *) (val)) = tsf; + + break; } + default: + RT_TRACE(COMP_ERR, DBG_LOUD, + ("switch case not process %x\n", variable)); + break; + } +} + +static void _rtl92ee_download_rsvd_page(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u8 tmp_regcr, tmp_reg422; + u8 bcnvalid_reg, txbc_reg; + u8 count = 0, dlbcn_count = 0; + bool b_recover = false; + + /*Set REG_CR bit 8. DMA beacon by SW.*/ + tmp_regcr = rtl_read_byte(rtlpriv, REG_CR + 1); + rtl_write_byte(rtlpriv, REG_CR + 1, tmp_regcr | BIT(0)); + + /* Disable Hw protection for a time which revserd for Hw sending beacon. + * Fix download reserved page packet fail + * that access collision with the protection time. + * 2010.05.11. Added by tynli. */ + _rtl92ee_set_bcn_ctrl_reg(hw, 0, BIT(3)); + _rtl92ee_set_bcn_ctrl_reg(hw, BIT(4), 0); + + /* Set FWHW_TXQ_CTRL 0x422[6]= 0 to + * tell Hw the packet is not a real beacon frame. + */ + tmp_reg422 = rtl_read_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2); + rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2, tmp_reg422 & (~BIT(6))); + + if (tmp_reg422 & BIT(6)) + b_recover = true; + + do { + /* Clear beacon valid check bit */ + bcnvalid_reg = rtl_read_byte(rtlpriv, REG_DWBCN0_CTRL + 2); + rtl_write_byte(rtlpriv, REG_DWBCN0_CTRL + 2, + bcnvalid_reg | BIT(0)); + + /* Return Beacon TCB */ + _rtl92ee_return_beacon_queue_skb(hw); + + /* download rsvd page */ + rtl92ee_set_fw_rsvdpagepkt(hw, false); + + txbc_reg = rtl_read_byte(rtlpriv, REG_MGQ_TXBD_NUM + 3); + count = 0; + while ((txbc_reg & BIT(4)) && count < 20) { + count++; + udelay(10); + txbc_reg = rtl_read_byte(rtlpriv, REG_MGQ_TXBD_NUM + 3); + } + rtl_write_byte(rtlpriv, REG_MGQ_TXBD_NUM + 3, + txbc_reg | BIT(4)); + + /* check rsvd page download OK. */ + bcnvalid_reg = rtl_read_byte(rtlpriv, REG_DWBCN0_CTRL + 2); + count = 0; + while (!(bcnvalid_reg & BIT(0)) && count < 20) { + count++; + udelay(50); + bcnvalid_reg = rtl_read_byte(rtlpriv, + REG_DWBCN0_CTRL + 2); + } + + if (bcnvalid_reg & BIT(0)) + rtl_write_byte(rtlpriv, REG_DWBCN0_CTRL + 2, BIT(0)); + + dlbcn_count++; + } while (!(bcnvalid_reg & BIT(0)) && dlbcn_count < 5); + + if (!(bcnvalid_reg & BIT(0))) + RT_TRACE(COMP_INIT, DBG_LOUD, ("Download RSVD page failed!\n")); + + /* Enable Bcn */ + _rtl92ee_set_bcn_ctrl_reg(hw, BIT(3), 0); + _rtl92ee_set_bcn_ctrl_reg(hw, 0, BIT(4)); + + if (b_recover) + rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2, tmp_reg422); + + tmp_regcr = rtl_read_byte(rtlpriv, REG_CR + 1); + rtl_write_byte(rtlpriv, REG_CR + 1, tmp_regcr & (~BIT(0))); + +} + +void rtl92ee_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct rtl_efuse *efuse = rtl_efuse(rtl_priv(hw)); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + u8 idx; + + switch (variable) { + case HW_VAR_ETHER_ADDR:{ + for (idx = 0; idx < ETH_ALEN; idx++) { + rtl_write_byte(rtlpriv, (REG_MACID + idx), val[idx]); + } + break; } + case HW_VAR_BASIC_RATE:{ + u16 b_rate_cfg = ((u16 *) val)[0]; + b_rate_cfg = b_rate_cfg & 0x15f; + b_rate_cfg |= 0x01; + b_rate_cfg = (b_rate_cfg | 0xd) & (~BIT(1)); + rtl_write_byte(rtlpriv, REG_RRSR, b_rate_cfg & 0xff); + rtl_write_byte(rtlpriv, REG_RRSR + 1, (b_rate_cfg >> 8) & 0xff); + break; } + case HW_VAR_BSSID: + for (idx = 0; idx < ETH_ALEN; idx++) { + rtl_write_byte(rtlpriv, (REG_BSSID + idx), val[idx]); + } + break; + case HW_VAR_SIFS: + rtl_write_byte(rtlpriv, REG_SIFS_CTX + 1, val[0]); + rtl_write_byte(rtlpriv, REG_SIFS_TRX + 1, val[1]); + + rtl_write_byte(rtlpriv, REG_SPEC_SIFS + 1, val[0]); + rtl_write_byte(rtlpriv, REG_MAC_SPEC_SIFS + 1, val[0]); + + if (!mac->ht_enable) + rtl_write_word(rtlpriv, REG_RESP_SIFS_OFDM, 0x0e0e); + else + rtl_write_word(rtlpriv, REG_RESP_SIFS_OFDM, + *((u16 *) val)); + break; + case HW_VAR_SLOT_TIME:{ + u8 e_aci; + + RT_TRACE(COMP_MLME, DBG_TRACE, + ("HW_VAR_SLOT_TIME %x\n", val[0])); + + rtl_write_byte(rtlpriv, REG_SLOT, val[0]); + + for (e_aci = 0; e_aci < AC_MAX; e_aci++) { + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AC_PARAM, + (u8 *) (&e_aci)); + } + break; } + case HW_VAR_ACK_PREAMBLE:{ + u8 reg_tmp; + u8 short_preamble = (bool) (*(u8 *) val); + reg_tmp = (rtlpriv->mac80211.cur_40_prime_sc) << 5; + if (short_preamble) + reg_tmp |= 0x80; + rtl_write_byte(rtlpriv, REG_RRSR + 2, reg_tmp); + rtlpriv->mac80211.short_preamble = short_preamble; + break; } + case HW_VAR_WPA_CONFIG: + rtl_write_byte(rtlpriv, REG_SECCFG, *((u8 *) val)); + break; + case HW_VAR_AMPDU_FACTOR:{ + u8 regtoset_normal[4] = { 0x41, 0xa8, 0x72, 0xb9 }; + u8 fac; + u8 *reg = NULL; + u8 i = 0; + + reg = regtoset_normal; + + fac = *((u8 *) val); + if (fac <= 3) { + fac = (1 << (fac + 2)); + if (fac > 0xf) + fac = 0xf; + for (i = 0; i < 4; i++) { + if ((reg[i] & 0xf0) > (fac << 4)) + reg[i] = (reg[i] & 0x0f) | (fac << 4); + if ((reg[i] & 0x0f) > fac) + reg[i] = (reg[i] & 0xf0) | fac; + rtl_write_byte(rtlpriv, + (REG_AGGLEN_LMT + i), + reg[i]); + } + RT_TRACE(COMP_MLME, DBG_LOUD, + ("Set HW_VAR_AMPDU_FACTOR:%#x\n", fac)); + } + break; } + case HW_VAR_AC_PARAM:{ + u8 e_aci = *((u8 *) val); + + if (rtlpci->acm_method != eAcmWay2_SW) + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ACM_CTRL, + (u8 *) (&e_aci)); + break; } + case HW_VAR_ACM_CTRL:{ + u8 e_aci = *((u8 *) val); + union aci_aifsn *aifs = (union aci_aifsn *)(&(mac->ac[0].aifs)); + + u8 acm = aifs->f.acm; + u8 acm_ctrl = rtl_read_byte(rtlpriv, REG_ACMHWCTRL); + + acm_ctrl = acm_ctrl | ((rtlpci->acm_method == 2) ? 0x0 : 0x1); + + if (acm) { + switch (e_aci) { + case AC0_BE: + acm_ctrl |= AcmHw_BeqEn; + break; + case AC2_VI: + acm_ctrl |= AcmHw_ViqEn; + break; + case AC3_VO: + acm_ctrl |= AcmHw_VoqEn; + break; + default: + RT_TRACE(COMP_ERR, DBG_WARNING, + ("HW_VAR_ACM_CTRL acm set " + "failed: eACI is %d\n", acm)); + break; + } + } else { + switch (e_aci) { + case AC0_BE: + acm_ctrl &= (~AcmHw_BeqEn); + break; + case AC2_VI: + acm_ctrl &= (~AcmHw_ViqEn); + break; + case AC3_VO: + acm_ctrl &= (~AcmHw_BeqEn); + break; + default: + RT_TRACE(COMP_ERR, DBG_LOUD, + ("switch case not process \n")); + break; + } + } + + RT_TRACE(COMP_QOS, DBG_TRACE, + ("SetHwReg8190pci(): [HW_VAR_ACM_CTRL] Write 0x%X\n", + acm_ctrl)); + rtl_write_byte(rtlpriv, REG_ACMHWCTRL, acm_ctrl); + break; } + case HW_VAR_RCR:{ + rtl_write_dword(rtlpriv, REG_RCR, ((u32 *) (val))[0]); + rtlpci->receive_config = ((u32 *) (val))[0]; + break; } + case HW_VAR_RETRY_LIMIT:{ + u8 retry_limit = ((u8 *) (val))[0]; + + rtl_write_word(rtlpriv, REG_RETRY_LIMIT, + retry_limit << RETRY_LIMIT_SHORT_SHIFT | + retry_limit << RETRY_LIMIT_LONG_SHIFT); + break; } + case HW_VAR_DUAL_TSF_RST: + rtl_write_byte(rtlpriv, REG_DUAL_TSF_RST, (BIT(0) | BIT(1))); + break; + case HW_VAR_EFUSE_BYTES: + efuse->efuse_usedbytes = *((u16 *) val); + break; + case HW_VAR_EFUSE_USAGE: + efuse->efuse_usedpercentage = *((u8 *) val); + break; + case HW_VAR_IO_CMD: + rtl92ee_phy_set_io_cmd(hw, (*(enum io_type *)val)); + break; + case HW_VAR_SET_RPWM:{ + u8 rpwm_val; + + rpwm_val = rtl_read_byte(rtlpriv, REG_PCIE_HRPWM); + udelay(1); + + if (rpwm_val & BIT(7)) { + rtl_write_byte(rtlpriv, REG_PCIE_HRPWM, (*(u8 *) val)); + } else { + rtl_write_byte(rtlpriv, REG_PCIE_HRPWM, + ((*(u8 *) val) | BIT(7))); + } + break; } + case HW_VAR_H2C_FW_PWRMODE: + rtl92ee_set_fw_pwrmode_cmd(hw, (*(u8 *) val)); + break; + case HW_VAR_FW_PSMODE_STATUS: + ppsc->b_fw_current_inpsmode = *((bool *) val); + break; + case HW_VAR_RESUME_CLK_ON: + _rtl92ee_set_fw_ps_rf_on(hw); + break; + case HW_VAR_FW_LPS_ACTION:{ + bool b_enter_fwlps = *((bool *) val); + + if (b_enter_fwlps) + _rtl92ee_fwlps_enter(hw); + else + _rtl92ee_fwlps_leave(hw); + break; } + case HW_VAR_H2C_FW_JOINBSSRPT:{ + u8 mstatus = (*(u8 *) val); + + if (mstatus == RT_MEDIA_CONNECT) { + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AID, NULL); + _rtl92ee_download_rsvd_page(hw); + } + rtl92ee_set_fw_media_status_rpt_cmd(hw, mstatus); + break; } + case HW_VAR_H2C_FW_P2P_PS_OFFLOAD: + rtl92ee_set_p2p_ps_offload_cmd(hw , (*(u8 *) val)); + break; + case HW_VAR_AID:{ + u16 u2btmp; + u2btmp = rtl_read_word(rtlpriv, REG_BCN_PSR_RPT); + u2btmp &= 0xC000; + rtl_write_word(rtlpriv, REG_BCN_PSR_RPT, + (u2btmp | mac->assoc_id)); + break; } + case HW_VAR_CORRECT_TSF:{ + u8 btype_ibss = ((u8 *) (val))[0]; + + if (btype_ibss == true) + _rtl92ee_stop_tx_beacon(hw); + + _rtl92ee_set_bcn_ctrl_reg(hw, 0, BIT(3)); + + rtl_write_dword(rtlpriv, REG_TSFTR, + (u32) (mac->tsf & 0xffffffff)); + rtl_write_dword(rtlpriv, REG_TSFTR + 4, + (u32) ((mac->tsf >> 32) & 0xffffffff)); + + _rtl92ee_set_bcn_ctrl_reg(hw, BIT(3), 0); + + if (btype_ibss == true) + _rtl92ee_resume_tx_beacon(hw); + break; } + case HW_VAR_KEEP_ALIVE: { + u8 array[2]; + array[0] = 0xff; + array[1] = *((u8 *)val); + rtl92ee_fill_h2c_cmd(hw, H2C_92E_KEEP_ALIVE_CTRL, 2, array); + break; } + default: + RT_TRACE(COMP_ERR, DBG_LOUD, + ("switch case not process %x\n", variable)); + break; + } +} + +static bool _rtl92ee_llt_table_init(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u8 txpktbuf_bndy; + u8 u8tmp, testcnt = 0; + + txpktbuf_bndy = 0xFA; + + rtl_write_dword(rtlpriv, REG_RQPN, 0x80E90808); + + rtl_write_byte(rtlpriv, REG_TRXFF_BNDY, txpktbuf_bndy); + rtl_write_word(rtlpriv, REG_TRXFF_BNDY + 2, 0x3d00 - 1); + + rtl_write_byte(rtlpriv, REG_DWBCN0_CTRL + 1, txpktbuf_bndy); + rtl_write_byte(rtlpriv, REG_DWBCN1_CTRL + 1, txpktbuf_bndy); + + rtl_write_byte(rtlpriv, REG_BCNQ_BDNY, txpktbuf_bndy); + rtl_write_byte(rtlpriv, REG_BCNQ1_BDNY, txpktbuf_bndy); + + rtl_write_byte(rtlpriv, REG_MGQ_BDNY, txpktbuf_bndy); + rtl_write_byte(rtlpriv, 0x45D, txpktbuf_bndy); + + rtl_write_byte(rtlpriv, REG_PBP, 0x31); + rtl_write_byte(rtlpriv, REG_RX_DRVINFO_SZ, 0x4); + + u8tmp = rtl_read_byte(rtlpriv, REG_AUTO_LLT + 2); + rtl_write_byte(rtlpriv, REG_AUTO_LLT + 2, u8tmp | BIT(0)); + + while (u8tmp & BIT(0)) { + u8tmp = rtl_read_byte(rtlpriv, REG_AUTO_LLT + 2); + udelay(10); + testcnt++; + if (testcnt > 10) + break; + } + + return true; +} + +static void _rtl92ee_gen_refresh_led_state(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + struct rtl_led *pLed0 = &(pcipriv->ledctl.sw_led0); + + if (rtlpriv->rtlhal.up_first_time) + return; + + if (ppsc->rfoff_reason == RF_CHANGE_BY_IPS) + rtl92ee_sw_led_on(hw, pLed0); + else if (ppsc->rfoff_reason == RF_CHANGE_BY_INIT) + rtl92ee_sw_led_on(hw, pLed0); + else + rtl92ee_sw_led_off(hw, pLed0); +} + +static bool _rtl92ee_init_mac(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + + u8 bytetmp; + u16 wordtmp; + u32 dwordtmp; + + rtl_write_byte(rtlpriv, REG_RSV_CTRL, 0x0); + + dwordtmp = rtl_read_dword(rtlpriv, REG_SYS_CFG1); + if (dwordtmp & BIT(24)) { + rtl_write_byte(rtlpriv, 0x7c, 0xc3); + } else { + bytetmp = rtl_read_byte(rtlpriv, 0x16); + rtl_write_byte(rtlpriv, 0x16, bytetmp | BIT(4) | BIT(6)); + rtl_write_byte(rtlpriv, 0x7c, 0x83); + } + /* 1. 40Mhz crystal source*/ + bytetmp = rtl_read_byte(rtlpriv, REG_AFE_CTRL2); + bytetmp &= 0xfb; + rtl_write_byte(rtlpriv, REG_AFE_CTRL2, bytetmp); + + dwordtmp = rtl_read_dword(rtlpriv, REG_AFE_CTRL4); + dwordtmp &= 0xfffffc7f; + rtl_write_dword(rtlpriv, REG_AFE_CTRL4, dwordtmp); + + /* 2. 92E AFE parameter + *MP chip then check version */ + bytetmp = rtl_read_byte(rtlpriv, REG_AFE_CTRL2); + bytetmp &= 0xbf; + rtl_write_byte(rtlpriv, REG_AFE_CTRL2, bytetmp); + + dwordtmp = rtl_read_dword(rtlpriv, REG_AFE_CTRL4); + dwordtmp &= 0xffdfffff; + rtl_write_dword(rtlpriv, REG_AFE_CTRL4, dwordtmp); + + /* HW Power on sequence */ + if (!rtl92e_hal_pwrseqcmdparsing(rtlpriv, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, + PWR_INTF_PCI_MSK, Rtl8192E_NIC_ENABLE_FLOW)) { + RT_TRACE(COMP_INIT, DBG_LOUD, + ("init MAC Fail as rtl92e_hal_pwrseqcmdparsing\n")); + return false; + } + + /* Release MAC IO register reset */ + bytetmp = rtl_read_byte(rtlpriv, REG_CR); + bytetmp = 0xff; + rtl_write_byte(rtlpriv, REG_CR, bytetmp); + mdelay(2); + bytetmp = 0x7f; + rtl_write_byte(rtlpriv, REG_HWSEQ_CTRL, bytetmp); + mdelay(2); + + /* Add for wakeup online */ + bytetmp = rtl_read_byte(rtlpriv, REG_SYS_CLKR); + rtl_write_byte(rtlpriv, REG_SYS_CLKR, bytetmp | BIT(3)); + bytetmp = rtl_read_byte(rtlpriv, REG_GPIO_MUXCFG + 1); + rtl_write_byte(rtlpriv, REG_GPIO_MUXCFG + 1, bytetmp & (~BIT(4))); + /* Release MAC IO register reset */ + rtl_write_word(rtlpriv, REG_CR, 0x2ff); + + if (!rtlhal->b_mac_func_enable) { + if (_rtl92ee_llt_table_init(hw) == false) { + RT_TRACE(COMP_INIT, DBG_LOUD, + ("LLT table init fail \n")); + return false; + } + } + + rtl_write_dword(rtlpriv, REG_HISR, 0xffffffff); + rtl_write_dword(rtlpriv, REG_HISRE, 0xffffffff); + + wordtmp = rtl_read_word(rtlpriv, REG_TRXDMA_CTRL); + wordtmp &= 0xf; + wordtmp |= 0xF5B1; + rtl_write_word(rtlpriv, REG_TRXDMA_CTRL, wordtmp); + /* Reported Tx status from HW for rate adaptive.*/ + rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 1, 0x1F); + + /* Set RCR register */ + rtl_write_dword(rtlpriv, REG_RCR, rtlpci->receive_config); + rtl_write_word(rtlpriv, REG_RXFLTMAP2, 0xffff); + + /* Set TCR register */ + rtl_write_dword(rtlpriv, REG_TCR, rtlpci->transmit_config); + + /* Set TX/RX descriptor physical address(from OS API). */ + rtl_write_dword(rtlpriv, REG_BCNQ_DESA, + ((u64) rtlpci->tx_ring[BEACON_QUEUE].buffer_desc_dma) & + DMA_BIT_MASK(32)); + rtl_write_dword(rtlpriv, REG_MGQ_DESA, + (u64) rtlpci->tx_ring[MGNT_QUEUE].buffer_desc_dma & + DMA_BIT_MASK(32)); + rtl_write_dword(rtlpriv, REG_VOQ_DESA, + (u64) rtlpci->tx_ring[VO_QUEUE].buffer_desc_dma & + DMA_BIT_MASK(32)); + rtl_write_dword(rtlpriv, REG_VIQ_DESA, + (u64) rtlpci->tx_ring[VI_QUEUE].buffer_desc_dma & + DMA_BIT_MASK(32)); + + rtl_write_dword(rtlpriv, REG_BEQ_DESA, + (u64) rtlpci->tx_ring[BE_QUEUE].buffer_desc_dma & + DMA_BIT_MASK(32)); + + dwordtmp = rtl_read_dword(rtlpriv, REG_BEQ_DESA); + + rtl_write_dword(rtlpriv, REG_BKQ_DESA, + (u64) rtlpci->tx_ring[BK_QUEUE].buffer_desc_dma & + DMA_BIT_MASK(32)); + rtl_write_dword(rtlpriv, REG_HQ0_DESA, + (u64) rtlpci->tx_ring[HIGH_QUEUE].buffer_desc_dma & + DMA_BIT_MASK(32)); + + rtl_write_dword(rtlpriv, REG_RX_DESA, + (u64) rtlpci->rx_ring[RX_MPDU_QUEUE].dma & + DMA_BIT_MASK(32)); + + /* if we want to support 64 bit DMA, we should set it here, + * but now we do not support 64 bit DMA*/ + + + rtl_write_dword(rtlpriv, REG_TSFTIMER_HCI, 0x3fffffff); + + bytetmp = rtl_read_byte(rtlpriv, REG_PCIE_CTRL_REG + 3); + rtl_write_byte(rtlpriv, REG_PCIE_CTRL_REG + 3, bytetmp | 0xF7); + + rtl_write_dword(rtlpriv, REG_INT_MIG, 0); + + rtl_write_dword(rtlpriv, REG_MCUTST_1, 0x0); + + rtl_write_word(rtlpriv, REG_MGQ_TXBD_NUM, + TX_DESC_NUM_92E | ((RTL8192EE_SEG_NUM << 12) & 0x3000)); + rtl_write_word(rtlpriv, REG_VOQ_TXBD_NUM, + TX_DESC_NUM_92E | ((RTL8192EE_SEG_NUM << 12) & 0x3000)); + rtl_write_word(rtlpriv, REG_VIQ_TXBD_NUM, + TX_DESC_NUM_92E | ((RTL8192EE_SEG_NUM << 12) & 0x3000)); + rtl_write_word(rtlpriv, REG_BEQ_TXBD_NUM, + TX_DESC_NUM_92E | ((RTL8192EE_SEG_NUM << 12) & 0x3000)); + rtl_write_word(rtlpriv, REG_VOQ_TXBD_NUM, + TX_DESC_NUM_92E | ((RTL8192EE_SEG_NUM << 12) & 0x3000)); + rtl_write_word(rtlpriv, REG_BKQ_TXBD_NUM, + TX_DESC_NUM_92E | ((RTL8192EE_SEG_NUM << 12) & 0x3000)); + rtl_write_word(rtlpriv, REG_HI0Q_TXBD_NUM, + TX_DESC_NUM_92E | ((RTL8192EE_SEG_NUM << 12) & 0x3000)); + rtl_write_word(rtlpriv, REG_HI1Q_TXBD_NUM, + TX_DESC_NUM_92E | ((RTL8192EE_SEG_NUM << 12) & 0x3000)); + rtl_write_word(rtlpriv, REG_HI2Q_TXBD_NUM, + TX_DESC_NUM_92E | ((RTL8192EE_SEG_NUM << 12) & 0x3000)); + rtl_write_word(rtlpriv, REG_HI3Q_TXBD_NUM, + TX_DESC_NUM_92E | ((RTL8192EE_SEG_NUM << 12) & 0x3000)); + rtl_write_word(rtlpriv, REG_HI4Q_TXBD_NUM, + TX_DESC_NUM_92E | ((RTL8192EE_SEG_NUM << 12) & 0x3000)); + rtl_write_word(rtlpriv, REG_HI5Q_TXBD_NUM, + TX_DESC_NUM_92E | ((RTL8192EE_SEG_NUM << 12) & 0x3000)); + rtl_write_word(rtlpriv, REG_HI6Q_TXBD_NUM, + TX_DESC_NUM_92E | ((RTL8192EE_SEG_NUM << 12) & 0x3000)); + rtl_write_word(rtlpriv, REG_HI7Q_TXBD_NUM, + TX_DESC_NUM_92E | ((RTL8192EE_SEG_NUM << 12) & 0x3000)); + /*Rx*/ +#if (DMA_IS_64BIT == 1) + rtl_write_word(rtlpriv, REG_RX_RXBD_NUM, + RX_DESC_NUM_92E | + ((RTL8192EE_SEG_NUM << 13) & 0x6000) | 0x8000); +#else + rtl_write_word(rtlpriv, REG_RX_RXBD_NUM, + RX_DESC_NUM_92E | + ((RTL8192EE_SEG_NUM << 13) & 0x6000) | 0x0000); +#endif + + rtl_write_dword(rtlpriv, REG_TSFTIMER_HCI, 0XFFFFFFFF); + + _rtl92ee_gen_refresh_led_state(hw); + return true; +} + +static void _rtl92ee_hw_configure(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + u32 reg_rrsr; + + reg_rrsr = RATE_ALL_CCK | RATE_ALL_OFDM_AG; + /* Init value for RRSR. */ + rtl_write_dword(rtlpriv, REG_RRSR, reg_rrsr); + + /* ARFB table 9 for 11ac 5G 2SS */ + rtl_write_dword(rtlpriv, REG_ARFR0, 0x00000010); + rtl_write_dword(rtlpriv, REG_ARFR0 + 4, 0x3e0ff000); + + /* ARFB table 10 for 11ac 5G 1SS */ + rtl_write_dword(rtlpriv, REG_ARFR1, 0x00000010); + rtl_write_dword(rtlpriv, REG_ARFR1 + 4, 0x000ff000); + + /* Set SLOT time */ + rtl_write_byte(rtlpriv, REG_SLOT, 0x09); + + /* CF-End setting. */ + rtl_write_word(rtlpriv, REG_FWHW_TXQ_CTRL, 0x1F80); + + /* Set retry limit */ + rtl_write_word(rtlpriv, REG_RETRY_LIMIT, 0x0707); + + /* BAR settings */ + rtl_write_dword(rtlpriv, REG_BAR_MODE_CTRL, 0x0201ffff); + + /* Set Data / Response auto rate fallack retry count */ + rtl_write_dword(rtlpriv, REG_DARFRC, 0x01000000); + rtl_write_dword(rtlpriv, REG_DARFRC + 4, 0x07060504); + rtl_write_dword(rtlpriv, REG_RARFRC, 0x01000000); + rtl_write_dword(rtlpriv, REG_RARFRC + 4, 0x07060504); + + /* Beacon related, for rate adaptive */ + rtl_write_byte(rtlpriv, REG_ATIMWND, 0x2); + rtl_write_byte(rtlpriv, REG_BCN_MAX_ERR, 0xff); + + rtlpci->reg_bcn_ctrl_val = 0x1d; + rtl_write_byte(rtlpriv, REG_BCN_CTRL, rtlpci->reg_bcn_ctrl_val); + + /* Marked out by Bruce, 2010-09-09. + * This register is configured for the 2nd Beacon (multiple BSSID). + * We shall disable this register if we only support 1 BSSID. + * vivi guess 92d also need this, also 92d now doesnot set this reg + */ + rtl_write_byte(rtlpriv, REG_BCN_CTRL_1, 0); + + /* TBTT prohibit hold time. Suggested by designer TimChen. */ + rtl_write_byte(rtlpriv, REG_TBTT_PROHIBIT + 1 , 0xff); /* 8 ms */ + + rtl_write_byte(rtlpriv, REG_PIFS, 0); + rtl_write_byte(rtlpriv, REG_AGGR_BREAK_TIME, 0x16); + + rtl_write_word(rtlpriv, REG_NAV_PROT_LEN, 0x0040); + rtl_write_word(rtlpriv, REG_PROT_MODE_CTRL, 0x08ff); + + /* For Rx TP. Suggested by SD1 Richard. Added by tynli. 2010.04.12.*/ + rtl_write_dword(rtlpriv, REG_FAST_EDCA_CTRL, 0x03086666); + + /* ACKTO for IOT issue. */ + rtl_write_byte(rtlpriv, REG_ACKTO, 0x40); + + /* Set Spec SIFS (used in NAV) */ + rtl_write_word(rtlpriv, REG_SPEC_SIFS, 0x100a); + rtl_write_word(rtlpriv, REG_MAC_SPEC_SIFS, 0x100a); + + /* Set SIFS for CCK */ + rtl_write_word(rtlpriv, REG_SIFS_CTX, 0x100a); + + /* Set SIFS for OFDM */ + rtl_write_word(rtlpriv, REG_SIFS_TRX, 0x100a); + + /* Note Data sheet don't define */ + rtl_write_word(rtlpriv, 0x4C7, 0x80); + + rtl_write_byte(rtlpriv, REG_RX_PKT_LIMIT, 0x20); + + rtl_write_word(rtlpriv, REG_MAX_AGGR_NUM, 0x1717); + + /* Set Multicast Address. 2009.01.07. by tynli. */ + rtl_write_dword(rtlpriv, REG_MAR, 0xffffffff); + rtl_write_dword(rtlpriv, REG_MAR + 4, 0xffffffff); +} + +static void _rtl92ee_enable_aspm_back_door(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + u32 tmp32 = 0, count = 0; + u8 tmp8 = 0; + + rtl_write_word(rtlpriv, REG_BACKDOOR_DBI_DATA, 0x78); + rtl_write_byte(rtlpriv, REG_BACKDOOR_DBI_DATA + 2, 0x2); + tmp8 = rtl_read_byte(rtlpriv, REG_BACKDOOR_DBI_DATA + 2); + count = 0; + while (tmp8 && count < 20) { + udelay(10); + tmp8 = rtl_read_byte(rtlpriv, REG_BACKDOOR_DBI_DATA + 2); + count++; + } + + if (0 == tmp8) { + tmp32 = rtl_read_dword(rtlpriv, REG_BACKDOOR_DBI_RDATA); + if ((tmp32 & 0xff00) != 0x2000) { + tmp32 &= 0xffff00ff; + rtl_write_dword(rtlpriv, REG_BACKDOOR_DBI_WDATA, + tmp32 | BIT(13)); + rtl_write_word(rtlpriv, REG_BACKDOOR_DBI_DATA, 0xf078); + rtl_write_byte(rtlpriv, REG_BACKDOOR_DBI_DATA + 2, 0x1); + + tmp8 = rtl_read_byte(rtlpriv , REG_BACKDOOR_DBI_DATA + 2); + count = 0; + while (tmp8 && count < 20) { + udelay(10); + tmp8 = rtl_read_byte(rtlpriv, + REG_BACKDOOR_DBI_DATA + 2); + count++; + } + } + } + + rtl_write_word(rtlpriv, REG_BACKDOOR_DBI_DATA, 0x70c); + rtl_write_byte(rtlpriv, REG_BACKDOOR_DBI_DATA + 2, 0x2); + tmp8 = rtl_read_byte(rtlpriv, REG_BACKDOOR_DBI_DATA + 2); + count = 0; + while (tmp8 && count < 20) { + udelay(10); + tmp8 = rtl_read_byte(rtlpriv, REG_BACKDOOR_DBI_DATA + 2); + count++; + } + if (0 == tmp8) { + tmp32 = rtl_read_dword(rtlpriv, REG_BACKDOOR_DBI_RDATA); + rtl_write_dword(rtlpriv, REG_BACKDOOR_DBI_WDATA, + tmp32 | BIT(31)); + rtl_write_word(rtlpriv, REG_BACKDOOR_DBI_DATA, 0xf70c); + rtl_write_byte(rtlpriv, REG_BACKDOOR_DBI_DATA + 2, 0x1); + } + + tmp8 = rtl_read_byte(rtlpriv, REG_BACKDOOR_DBI_DATA + 2); + count = 0; + while (tmp8 && count < 20) { + udelay(10); + tmp8 = rtl_read_byte(rtlpriv, REG_BACKDOOR_DBI_DATA + 2); + count++; + } + + + rtl_write_word(rtlpriv, REG_BACKDOOR_DBI_DATA, 0x718); + rtl_write_byte(rtlpriv, REG_BACKDOOR_DBI_DATA + 2, 0x2); + tmp8 = rtl_read_byte(rtlpriv, REG_BACKDOOR_DBI_DATA + 2); + count = 0; + while (tmp8 && count < 20) { + udelay(10); + tmp8 = rtl_read_byte(rtlpriv, REG_BACKDOOR_DBI_DATA + 2); + count++; + } + if (ppsc->b_support_backdoor || (0 == tmp8)) { + tmp32 = rtl_read_dword(rtlpriv, REG_BACKDOOR_DBI_RDATA); + rtl_write_dword(rtlpriv, REG_BACKDOOR_DBI_WDATA, + tmp32 | BIT(11) | BIT(12)); + rtl_write_word(rtlpriv, REG_BACKDOOR_DBI_DATA, 0xf718); + rtl_write_byte(rtlpriv, REG_BACKDOOR_DBI_DATA + 2, 0x1); + } + tmp8 = rtl_read_byte(rtlpriv, REG_BACKDOOR_DBI_DATA + 2); + count = 0; + while (tmp8 && count < 20) { + udelay(10); + tmp8 = rtl_read_byte(rtlpriv, REG_BACKDOOR_DBI_DATA + 2); + count++; + } +} + +void rtl92ee_enable_hw_security_config(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u8 sec_reg_value; + u8 tmp; + + RT_TRACE(COMP_INIT, DBG_DMESG, + ("PairwiseEncAlgorithm = %d GroupEncAlgorithm = %d\n", + rtlpriv->sec.pairwise_enc_algorithm, + rtlpriv->sec.group_enc_algorithm)); + + if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) { + RT_TRACE(COMP_SEC, DBG_DMESG, ("not open hw encryption\n")); + return; + } + + sec_reg_value = SCR_TxEncEnable | SCR_RxDecEnable; + + if (rtlpriv->sec.use_defaultkey) { + sec_reg_value |= SCR_TxUseDK; + sec_reg_value |= SCR_RxUseDK; + } + + sec_reg_value |= (SCR_RXBCUSEDK | SCR_TXBCUSEDK); + + tmp = rtl_read_byte(rtlpriv, REG_CR + 1); + rtl_write_byte(rtlpriv, REG_CR + 1, tmp | BIT(1)); + + RT_TRACE(COMP_SEC, DBG_DMESG, + ("The SECR-value %x \n", sec_reg_value)); + + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_WPA_CONFIG, &sec_reg_value); + +} + +int rtl92ee_hw_init(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + bool rtstatus = true; + int err = 0; + u8 tmp_u1b , u1byte; + u32 tmp_u4b; + + RT_TRACE(COMP_INIT , DBG_LOUD , (" Rtl8192EE hw init\n")); + rtlpriv->rtlhal.being_init_adapter = true; + rtlpriv->intf_ops->disable_aspm(hw); + + tmp_u1b = rtl_read_byte(rtlpriv, REG_SYS_CLKR+1); + u1byte = rtl_read_byte(rtlpriv, REG_CR); + if ((tmp_u1b & BIT(3)) && (u1byte != 0 && u1byte != 0xEA)) { + rtlhal->b_mac_func_enable = true; + } else { + rtlhal->b_mac_func_enable = false; + rtlhal->fw_ps_state = FW_PS_STATE_ALL_ON_92E; + } + + rtstatus = _rtl92ee_init_mac(hw); + + rtl_write_byte(rtlpriv, 0x577, 0x03); + + /*for Crystal 40 Mhz setting */ + rtl_write_byte(rtlpriv, REG_AFE_CTRL4, 0x2A); + rtl_write_byte(rtlpriv, REG_AFE_CTRL4 + 1, 0x00); + rtl_write_byte(rtlpriv, REG_AFE_CTRL2, 0x83); + + /*Forced the antenna b to wifi */ + if (rtlpriv->btcoexist.btc_info.btcoexist == 1) { + rtl_write_byte(rtlpriv, 0x64, 0); + rtl_write_byte(rtlpriv, 0x65, 1); + } + if (rtstatus != true) { + RT_TRACE(COMP_ERR, DBG_EMERG, ("Init MAC failed\n")); + err = 1; + return err; + } + rtlhal->rx_tag = 0; + rtl_write_word(rtlpriv, REG_PCIE_CTRL_REG, 0x8000); + err = rtl92ee_download_fw(hw , false); + if (err) { + RT_TRACE(COMP_ERR, DBG_WARNING, + ("Failed to download FW. Init HW without FW now..\n")); + err = 1; + rtlhal->bfw_ready = false; + return err; + } else { + rtlhal->bfw_ready = true; + } + /*fw related variable initialize */ + ppsc->b_fw_current_inpsmode = false; + rtlhal->fw_ps_state = FW_PS_STATE_ALL_ON_92E; + rtlhal->bfw_clk_change_in_progress = false; + rtlhal->ballow_sw_to_change_hwclc = false; + rtlhal->last_hmeboxnum = 0; + + + rtl92ee_phy_mac_config(hw); + + rtl92ee_phy_bb_config(hw); + + rtl92ee_phy_rf_config(hw); + + rtlphy->rfreg_chnlval[0] = rtl_get_rfreg(hw, RF90_PATH_A, + RF_CHNLBW, RFREG_OFFSET_MASK); + rtlphy->rfreg_chnlval[1] = rtl_get_rfreg(hw, RF90_PATH_B, + RF_CHNLBW, RFREG_OFFSET_MASK); + rtlphy->backup_rf_0x1a = (u32) rtl_get_rfreg(hw, RF90_PATH_A, RF_RX_G1, + RFREG_OFFSET_MASK); + rtlphy->rfreg_chnlval[0] = (rtlphy->rfreg_chnlval[0] & 0xfffff3ff) | + BIT(10) | BIT(11); + + rtl_set_rfreg(hw, RF90_PATH_A, RF_CHNLBW, RFREG_OFFSET_MASK, + rtlphy->rfreg_chnlval[0]); + rtl_set_rfreg(hw, RF90_PATH_B, RF_CHNLBW, RFREG_OFFSET_MASK, + rtlphy->rfreg_chnlval[0]); + + /*---- Set CCK and OFDM Block "ON"----*/ + rtl_set_bbreg(hw, RFPGA0_RFMOD, BCCKEN, 0x1); + rtl_set_bbreg(hw, RFPGA0_RFMOD, BOFDMEN, 0x1); + + /* Must set this, + * otherwise the rx sensitivity will be very pool. Maddest + */ + rtl_set_rfreg(hw, RF90_PATH_A, 0xB1, RFREG_OFFSET_MASK, 0x54418); + + /*Set Hardware(MAC default setting.)*/ + _rtl92ee_hw_configure(hw); + + rtlhal->b_mac_func_enable = true; + + stg_rtl_cam_reset_all_entry(hw); + rtl92ee_enable_hw_security_config(hw); + + ppsc->rfpwr_state = ERFON; + + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ETHER_ADDR, mac->mac_addr); + _rtl92ee_enable_aspm_back_door(hw); + rtlpriv->intf_ops->enable_aspm(hw); + + rtl92ee_bt_hw_init(hw); + + rtlpriv->rtlhal.being_init_adapter = false; + + if (ppsc->rfpwr_state == ERFON) { + if (rtlphy->iqk_initialized) { + rtl92ee_phy_iq_calibrate(hw, true); + } else { + rtl92ee_phy_iq_calibrate(hw, false); + rtlphy->iqk_initialized = true; + } + } + + rtlphy->rfpath_rx_enable[0] = true; + if (rtlphy->rf_type == RF_2T2R) + rtlphy->rfpath_rx_enable[1] = true; + + stg_efuse_one_byte_read(hw, 0x1FA, &tmp_u1b); + if (!(tmp_u1b & BIT(0))) { + rtl_set_rfreg(hw, RF90_PATH_A, 0x15, 0x0F, 0x05); + RT_TRACE(COMP_INIT, DBG_LOUD, ("PA BIAS path A\n")); + } + + if ((!(tmp_u1b & BIT(1))) && (rtlphy->rf_type == RF_2T2R)) { + rtl_set_rfreg(hw, RF90_PATH_B, 0x15, 0x0F, 0x05); + RT_TRACE(COMP_INIT, DBG_LOUD, ("PA BIAS path B\n")); + } + + rtl_write_byte(rtlpriv, REG_NAV_UPPER, ((30000 + 127) / 128)); + + /*Fixed LDPC rx hang issue. */ + tmp_u4b = rtl_read_dword(rtlpriv, REG_SYS_SWR_CTRL1); + rtl_write_byte(rtlpriv, REG_SYS_SWR_CTRL2, 0x75); + tmp_u4b = (tmp_u4b & 0xfff00fff) | (0x7E << 12); + rtl_write_dword(rtlpriv, REG_SYS_SWR_CTRL1, tmp_u4b); + + rtl92ee_dm_init(hw); + + rtl_write_dword(rtlpriv, 0x4fc, 0); + + RT_TRACE(COMP_INIT , DBG_LOUD , ("end of Rtl8192EE hw init %x\n" , err)); + return 0; +} + +static enum version_8192e _rtl92ee_read_chip_version(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + enum version_8192e version = VERSION_UNKNOWN; + u32 value32; + + rtlphy->rf_type = RF_2T2R; + + value32 = rtl_read_dword(rtlpriv, REG_SYS_CFG1); + if (value32 & TRP_VAUX_EN) + version = (enum version_8192e) VERSION_TEST_CHIP_2T2R_8192E; + else + version = (enum version_8192e) VERSION_NORMAL_CHIP_2T2R_8192E; + + RT_TRACE(COMP_INIT, DBG_LOUD, + ("Chip RF Type: %s\n", (rtlphy->rf_type == RF_2T2R) ? + "RF_2T2R" : "RF_1T1R")); + + return version; +} + +static int _rtl92ee_set_media_status(struct ieee80211_hw *hw, + enum nl80211_iftype type) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u8 bt_msr = rtl_read_byte(rtlpriv, MSR); + enum led_ctl_mode ledaction = LED_CTL_NO_LINK; + u8 mode = MSR_NOLINK; + bt_msr &= 0xfc; + + switch (type) { + case NL80211_IFTYPE_UNSPECIFIED: + mode = MSR_NOLINK; + RT_TRACE(COMP_INIT, DBG_TRACE, + ("Set Network type to NO LINK!\n")); + break; + case NL80211_IFTYPE_ADHOC: + case NL80211_IFTYPE_MESH_POINT: + mode = MSR_ADHOC; + RT_TRACE(COMP_INIT, DBG_TRACE, + ("Set Network type to Ad Hoc!\n")); + break; + case NL80211_IFTYPE_STATION: + mode = MSR_INFRA; + ledaction = LED_CTL_LINK; + RT_TRACE(COMP_INIT, DBG_TRACE, + ("Set Network type to STA!\n")); + break; + case NL80211_IFTYPE_AP: + mode = MSR_AP; + ledaction = LED_CTL_LINK; + RT_TRACE(COMP_INIT, DBG_TRACE, + ("Set Network type to AP!\n")); + break; + default: + RT_TRACE(COMP_ERR, DBG_EMERG, + ("Network type %d not support!\n", type)); + return 1; + break; + } + + /* MSR_INFRA == Link in infrastructure network; + * MSR_ADHOC == Link in ad hoc network; + * Therefore, check link state is necessary. + * + * MSR_AP == AP mode; link state is not cared here. + */ + if (mode != MSR_AP && rtlpriv->mac80211.link_state < MAC80211_LINKED) { + mode = MSR_NOLINK; + ledaction = LED_CTL_NO_LINK; + } + + if (mode == MSR_NOLINK || mode == MSR_INFRA) { + _rtl92ee_stop_tx_beacon(hw); + _rtl92ee_enable_bcn_sub_func(hw); + } else if (mode == MSR_ADHOC || mode == MSR_AP) { + _rtl92ee_resume_tx_beacon(hw); + _rtl92ee_disable_bcn_sub_func(hw); + } else { + RT_TRACE(COMP_ERR, DBG_WARNING, + ("Set HW_VAR_MEDIA_STATUS: " + "No such media status(%x).\n", mode)); + } + + rtl_write_byte(rtlpriv, (MSR), bt_msr | mode); + rtlpriv->cfg->ops->led_control(hw, ledaction); + if (mode == MSR_AP) + rtl_write_byte(rtlpriv, REG_BCNTCFG + 1, 0x00); + else + rtl_write_byte(rtlpriv, REG_BCNTCFG + 1, 0x66); + return 0; +} + +void rtl92ee_set_check_bssid(struct ieee80211_hw *hw, bool check_bssid) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + u32 reg_rcr = rtlpci->receive_config; + + if (rtlpriv->psc.rfpwr_state != ERFON) + return; + + if (check_bssid == true) { + reg_rcr |= (RCR_CBSSID_DATA | RCR_CBSSID_BCN); + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RCR, + (u8 *) (®_rcr)); + _rtl92ee_set_bcn_ctrl_reg(hw, 0, BIT(4)); + } else if (check_bssid == false) { + reg_rcr &= (~(RCR_CBSSID_DATA | RCR_CBSSID_BCN)); + _rtl92ee_set_bcn_ctrl_reg(hw, BIT(4), 0); + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RCR, + (u8 *) (®_rcr)); + } +} + +int rtl92ee_set_network_type(struct ieee80211_hw *hw, enum nl80211_iftype type) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + if (_rtl92ee_set_media_status(hw, type)) + return -EOPNOTSUPP; + + if (rtlpriv->mac80211.link_state == MAC80211_LINKED) { + if (type != NL80211_IFTYPE_AP && + type != NL80211_IFTYPE_MESH_POINT) + rtl92ee_set_check_bssid(hw, true); + } else { + rtl92ee_set_check_bssid(hw, false); + } + + return 0; +} + +/* don't set REG_EDCA_BE_PARAM here because mac80211 will send pkt when scan */ +void rtl92ee_set_qos(struct ieee80211_hw *hw, int aci) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + rtl92ee_dm_init_edca_turbo(hw); + switch (aci) { + case AC1_BK: + rtl_write_dword(rtlpriv, REG_EDCA_BK_PARAM, 0xa44f); + break; + case AC0_BE: + /* rtl_write_dword(rtlpriv, REG_EDCA_BE_PARAM, u4b_ac_param); */ + break; + case AC2_VI: + rtl_write_dword(rtlpriv, REG_EDCA_VI_PARAM, 0x5e4322); + break; + case AC3_VO: + rtl_write_dword(rtlpriv, REG_EDCA_VO_PARAM, 0x2f3222); + break; + default: + RT_ASSERT(false, ("invalid aci: %d !\n", aci)); + break; + } +} + +static void rtl92ee_clear_interrupt(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u32 tmp; + + tmp = rtl_read_dword(rtlpriv, REG_HISR); + rtl_write_dword(rtlpriv, REG_HISR, tmp); + + tmp = rtl_read_dword(rtlpriv, REG_HISRE); + rtl_write_dword(rtlpriv, REG_HISRE, tmp); + + tmp = rtl_read_dword(rtlpriv, REG_HSISR); + rtl_write_dword(rtlpriv, REG_HSISR, tmp); +} + +void rtl92ee_enable_interrupt(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + + rtl92ee_clear_interrupt(hw);/*clear it here first*/ + + rtl_write_dword(rtlpriv, REG_HIMR, rtlpci->irq_mask[0] & 0xFFFFFFFF); + rtl_write_dword(rtlpriv, REG_HIMRE, rtlpci->irq_mask[1] & 0xFFFFFFFF); + rtlpci->irq_enabled = true; +} + +void rtl92ee_disable_interrupt(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + + rtl_write_dword(rtlpriv, REG_HIMR, IMR_DISABLED); + rtl_write_dword(rtlpriv, REG_HIMRE, IMR_DISABLED); + rtlpci->irq_enabled = false; + /*synchronize_irq(rtlpci->pdev->irq);*/ +} + +static void _rtl92ee_poweroff_adapter(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + u8 u1b_tmp; + rtlhal->b_mac_func_enable = false; + + RT_TRACE(COMP_INIT , DBG_LOUD , ("POWER OFF adapter \n")); + + /* Run LPS WL RFOFF flow */ + rtl92e_hal_pwrseqcmdparsing(rtlpriv, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, + PWR_INTF_PCI_MSK, Rtl8192E_NIC_LPS_ENTER_FLOW); + /* turn off RF */ + rtl_write_byte(rtlpriv, REG_RF_CTRL, 0x00); + + /* ==== Reset digital sequence ====== */ + if ((rtl_read_byte(rtlpriv, REG_MCUFWDL) & BIT(7)) && rtlhal->bfw_ready) + rtl92ee_firmware_selfreset(hw); + + /* Reset MCU */ + u1b_tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1); + rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, (u1b_tmp & (~BIT(2)))); + + /* reset MCU ready status */ + rtl_write_byte(rtlpriv, REG_MCUFWDL, 0x00); + + /* HW card disable configuration. */ + rtl92e_hal_pwrseqcmdparsing(rtlpriv, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, + PWR_INTF_PCI_MSK, Rtl8192E_NIC_DISABLE_FLOW); + + /* Reset MCU IO Wrapper */ + u1b_tmp = rtl_read_byte(rtlpriv, REG_RSV_CTRL + 1); + rtl_write_byte(rtlpriv, REG_RSV_CTRL + 1, (u1b_tmp & (~BIT(0)))); + u1b_tmp = rtl_read_byte(rtlpriv, REG_RSV_CTRL + 1); + rtl_write_byte(rtlpriv, REG_RSV_CTRL + 1, (u1b_tmp | BIT(0))); + + /* lock ISO/CLK/Power control register */ + rtl_write_byte(rtlpriv, REG_RSV_CTRL, 0x0E); +} + +void rtl92ee_card_disable(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + enum nl80211_iftype opmode; + + RT_TRACE(COMP_INIT , DBG_LOUD , ("RTL8192ee card disable\n")); + + RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC); + + mac->link_state = MAC80211_NOLINK; + opmode = NL80211_IFTYPE_UNSPECIFIED; + + _rtl92ee_set_media_status(hw, opmode); + + if (rtlpriv->rtlhal.driver_is_goingto_unload || + ppsc->rfoff_reason > RF_CHANGE_BY_PS) + rtlpriv->cfg->ops->led_control(hw, LED_CTL_POWER_OFF); + + _rtl92ee_poweroff_adapter(hw); + + /* after power off we should do iqk again */ + rtlpriv->phy.iqk_initialized = false; +} + +void rtl92ee_interrupt_recognized(struct ieee80211_hw *hw, + u32 *p_inta, u32 *p_intb) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + + *p_inta = rtl_read_dword(rtlpriv, ISR) & rtlpci->irq_mask[0]; + rtl_write_dword(rtlpriv, ISR, *p_inta); + + *p_intb = rtl_read_dword(rtlpriv, REG_HISRE) & rtlpci->irq_mask[1]; + rtl_write_dword(rtlpriv, REG_HISRE, *p_intb); +} + +void rtl92ee_set_beacon_related_registers(struct ieee80211_hw *hw) +{ + + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + u16 bcn_interval, atim_window; + + bcn_interval = mac->beacon_interval; + atim_window = 2; /*FIX MERGE */ + rtl92ee_disable_interrupt(hw); + rtl_write_word(rtlpriv, REG_ATIMWND, atim_window); + rtl_write_word(rtlpriv, REG_BCN_INTERVAL, bcn_interval); + rtl_write_word(rtlpriv, REG_BCNTCFG, 0x660f); + rtl_write_byte(rtlpriv, REG_RXTSF_OFFSET_CCK, 0x18); + rtl_write_byte(rtlpriv, REG_RXTSF_OFFSET_OFDM, 0x18); + rtl_write_byte(rtlpriv, 0x606, 0x30); + rtlpci->reg_bcn_ctrl_val |= BIT(3); + rtl_write_byte(rtlpriv, REG_BCN_CTRL, (u8) rtlpci->reg_bcn_ctrl_val); +} + +void rtl92ee_set_beacon_interval(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + u16 bcn_interval = mac->beacon_interval; + + RT_TRACE(COMP_BEACON, DBG_DMESG, + ("beacon_interval:%d\n", bcn_interval)); + rtl_write_word(rtlpriv, REG_BCN_INTERVAL, bcn_interval); +} + +void rtl92ee_update_interrupt_mask(struct ieee80211_hw *hw, + u32 add_msr, u32 rm_msr) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + + RT_TRACE(COMP_INTR, DBG_LOUD, + ("add_msr:%x, rm_msr:%x\n", add_msr, rm_msr)); + + if (add_msr) + rtlpci->irq_mask[0] |= add_msr; + if (rm_msr) + rtlpci->irq_mask[0] &= (~rm_msr); + rtl92ee_disable_interrupt(hw); + rtl92ee_enable_interrupt(hw); +} + +static u8 _rtl92ee_get_chnl_group(u8 chnl) +{ + u8 group = 0; + + if (chnl <= 14) { + if (1 <= chnl && chnl <= 2) + group = 0; + else if (3 <= chnl && chnl <= 5) + group = 1; + else if (6 <= chnl && chnl <= 8) + group = 2; + else if (9 <= chnl && chnl <= 11) + group = 3; + else if (12 <= chnl && chnl <= 14) + group = 4; + } else { + if (36 <= chnl && chnl <= 42) + group = 0; + else if (44 <= chnl && chnl <= 48) + group = 1; + else if (50 <= chnl && chnl <= 58) + group = 2; + else if (60 <= chnl && chnl <= 64) + group = 3; + else if (100 <= chnl && chnl <= 106) + group = 4; + else if (108 <= chnl && chnl <= 114) + group = 5; + else if (116 <= chnl && chnl <= 122) + group = 6; + else if (124 <= chnl && chnl <= 130) + group = 7; + else if (132 <= chnl && chnl <= 138) + group = 8; + else if (140 <= chnl && chnl <= 144) + group = 9; + else if (149 <= chnl && chnl <= 155) + group = 10; + else if (157 <= chnl && chnl <= 161) + group = 11; + else if (165 <= chnl && chnl <= 171) + group = 12; + else if (173 <= chnl && chnl <= 177) + group = 13; + } + return group; +} + +static void _rtl8192ee_read_power_value_fromprom(struct ieee80211_hw *hw, + struct txpower_info_2g *pwr2g, + struct txpower_info_5g *pwr5g, + bool autoload_fail, u8 *hwinfo) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u32 rf, addr = EEPROM_TX_PWR_INX, group, i = 0; + + RT_TRACE(COMP_INIT, DBG_LOUD, + ("hal_ReadPowerValueFromPROM92E(): PROMContent[0x%x]= 0x%x\n", + (addr + 1), hwinfo[addr + 1])); + if (0xFF == hwinfo[addr+1]) /*YJ, add, 120316*/ + autoload_fail = true; + + if (autoload_fail) { + RT_TRACE(COMP_INIT, DBG_LOUD, + ("auto load fail : Use Default value!\n")); + for (rf = 0 ; rf < MAX_RF_PATH ; rf++) { + /* 2.4G default value */ + for (group = 0 ; group < MAX_CHNL_GROUP_24G; group++) { + pwr2g->index_cck_base[rf][group] = 0x2D; + pwr2g->index_bw40_base[rf][group] = 0x2D; + } + for (i = 0; i < MAX_TX_COUNT; i++) { + if (i == 0) { + pwr2g->bw20_diff[rf][0] = 0x02; + pwr2g->ofdm_diff[rf][0] = 0x04; + } else { + pwr2g->bw20_diff[rf][i] = 0xFE; + pwr2g->bw40_diff[rf][i] = 0xFE; + pwr2g->cck_diff[rf][i] = 0xFE; + pwr2g->ofdm_diff[rf][i] = 0xFE; + } + } + + /*5G default value*/ + for (group = 0 ; group < MAX_CHNL_GROUP_5G; group++) + pwr5g->index_bw40_base[rf][group] = 0x2A; + + for (i = 0; i < MAX_TX_COUNT; i++) { + if (i == 0) { + pwr5g->ofdm_diff[rf][0] = 0x04; + pwr5g->bw20_diff[rf][0] = 0x00; + pwr5g->bw80_diff[rf][0] = 0xFE; + pwr5g->bw160_diff[rf][0] = 0xFE; + } else { + pwr5g->ofdm_diff[rf][0] = 0xFE; + pwr5g->bw20_diff[rf][0] = 0xFE; + pwr5g->bw40_diff[rf][0] = 0xFE; + pwr5g->bw80_diff[rf][0] = 0xFE; + pwr5g->bw160_diff[rf][0] = 0xFE; + } + } + } + return; + } + + rtl_priv(hw)->efuse.b_txpwr_fromeprom = true; + + for (rf = 0 ; rf < MAX_RF_PATH ; rf++) { + /*2.4G default value*/ + for (group = 0 ; group < MAX_CHNL_GROUP_24G; group++) { + pwr2g->index_cck_base[rf][group] = hwinfo[addr++]; + if (pwr2g->index_cck_base[rf][group] == 0xFF) + pwr2g->index_cck_base[rf][group] = 0x2D; + + } + for (group = 0 ; group < MAX_CHNL_GROUP_24G - 1; group++) { + pwr2g->index_bw40_base[rf][group] = hwinfo[addr++]; + if (pwr2g->index_bw40_base[rf][group] == 0xFF) + pwr2g->index_bw40_base[rf][group] = 0x2D; + } + for (i = 0; i < MAX_TX_COUNT; i++) { + if (i == 0) { + pwr2g->bw40_diff[rf][i] = 0; + if (hwinfo[addr] == 0xFF) { + pwr2g->bw20_diff[rf][i] = 0x02; + } else { + pwr2g->bw20_diff[rf][i] = (hwinfo[addr] + & 0xf0) >> 4; + if (pwr2g->bw20_diff[rf][i] & BIT(3)) + pwr2g->bw20_diff[rf][i] |= 0xF0; + } + + if (hwinfo[addr] == 0xFF) { + pwr2g->ofdm_diff[rf][i] = 0x04; + } else { + pwr2g->ofdm_diff[rf][i] = (hwinfo[addr] + & 0x0f); + if (pwr2g->ofdm_diff[rf][i] & BIT(3)) + pwr2g->ofdm_diff[rf][i] |= 0xF0; + } + pwr2g->cck_diff[rf][i] = 0; + addr++; + } else { + if (hwinfo[addr] == 0xFF) { + pwr2g->bw40_diff[rf][i] = 0xFE; + } else { + pwr2g->bw40_diff[rf][i] = (hwinfo[addr] + & 0xf0) >> 4; + if (pwr2g->bw40_diff[rf][i] & BIT(3)) + pwr2g->bw40_diff[rf][i] |= 0xF0; + } + + if (hwinfo[addr] == 0xFF) { + pwr2g->bw20_diff[rf][i] = 0xFE; + } else { + pwr2g->bw20_diff[rf][i] = (hwinfo[addr] + & 0x0f); + if (pwr2g->bw20_diff[rf][i] & BIT(3)) + pwr2g->bw20_diff[rf][i] |= 0xF0; + } + addr++; + + if (hwinfo[addr] == 0xFF) { + pwr2g->ofdm_diff[rf][i] = 0xFE; + } else { + pwr2g->ofdm_diff[rf][i] = (hwinfo[addr] + & 0xf0) >> 4; + if (pwr2g->ofdm_diff[rf][i] & BIT(3)) + pwr2g->ofdm_diff[rf][i] |= 0xF0; + } + + if (hwinfo[addr] == 0xFF) { + pwr2g->cck_diff[rf][i] = 0xFE; + } else { + pwr2g->cck_diff[rf][i] = (hwinfo[addr] + & 0x0f); + if (pwr2g->cck_diff[rf][i] & BIT(3)) + pwr2g->cck_diff[rf][i] |= 0xF0; + } + addr++; + } + } + + /*5G default value*/ + for (group = 0 ; group < MAX_CHNL_GROUP_5G; group++) { + pwr5g->index_bw40_base[rf][group] = hwinfo[addr++]; + if (pwr5g->index_bw40_base[rf][group] == 0xFF) + pwr5g->index_bw40_base[rf][group] = 0xFE; + } + + for (i = 0; i < MAX_TX_COUNT; i++) { + if (i == 0) { + pwr5g->bw40_diff[rf][i] = 0; + + if (hwinfo[addr] == 0xFF) { + pwr5g->bw20_diff[rf][i] = 0; + } else { + pwr5g->bw20_diff[rf][0] = (hwinfo[addr] + & 0xf0) >> 4; + if (pwr5g->bw20_diff[rf][i] & BIT(3)) + pwr5g->bw20_diff[rf][i] |= 0xF0; + } + + if (hwinfo[addr] == 0xFF) { + pwr5g->ofdm_diff[rf][i] = 0x04; + } else { + pwr5g->ofdm_diff[rf][0] = (hwinfo[addr] + & 0x0f); + if (pwr5g->ofdm_diff[rf][i] & BIT(3)) + pwr5g->ofdm_diff[rf][i] |= 0xF0; + } + addr++; + } else { + if (hwinfo[addr] == 0xFF) { + pwr5g->bw40_diff[rf][i] = 0xFE; + } else { + pwr5g->bw40_diff[rf][i] = (hwinfo[addr] + & 0xf0) >> 4; + if (pwr5g->bw40_diff[rf][i] & BIT(3)) + pwr5g->bw40_diff[rf][i] |= 0xF0; + } + + if (hwinfo[addr] == 0xFF) { + pwr5g->bw20_diff[rf][i] = 0xFE; + } else { + pwr5g->bw20_diff[rf][i] = (hwinfo[addr] + & 0x0f); + if (pwr5g->bw20_diff[rf][i] & BIT(3)) + pwr5g->bw20_diff[rf][i] |= 0xF0; + } + addr++; + } + } + + if (hwinfo[addr] == 0xFF) { + pwr5g->ofdm_diff[rf][1] = 0xFE; + pwr5g->ofdm_diff[rf][2] = 0xFE; + } else { + pwr5g->ofdm_diff[rf][1] = (hwinfo[addr] & 0xf0) >> 4; + pwr5g->ofdm_diff[rf][2] = (hwinfo[addr] & 0x0f); + } + addr++; + + if (hwinfo[addr] == 0xFF) + pwr5g->ofdm_diff[rf][3] = 0xFE; + else + pwr5g->ofdm_diff[rf][3] = (hwinfo[addr] & 0x0f); + addr++; + + for (i = 1; i < MAX_TX_COUNT; i++) { + if (pwr5g->ofdm_diff[rf][i] == 0xFF) + pwr5g->ofdm_diff[rf][i] = 0xFE; + else if (pwr5g->ofdm_diff[rf][i] & BIT(3)) + pwr5g->ofdm_diff[rf][i] |= 0xF0; + } + + for (i = 0; i < MAX_TX_COUNT; i++) { + if (hwinfo[addr] == 0xFF) { + pwr5g->bw80_diff[rf][i] = 0xFE; + } else { + pwr5g->bw80_diff[rf][i] = (hwinfo[addr] & 0xf0) + >> 4; + if (pwr5g->bw80_diff[rf][i] & BIT(3)) + pwr5g->bw80_diff[rf][i] |= 0xF0; + } + + if (hwinfo[addr] == 0xFF) { + pwr5g->bw160_diff[rf][i] = 0xFE; + } else { + pwr5g->bw160_diff[rf][i] = (hwinfo[addr] & 0x0f); + if (pwr5g->bw160_diff[rf][i] & BIT(3)) + pwr5g->bw160_diff[rf][i] |= 0xF0; + } + addr++; + } + } +} +static void _rtl92ee_read_txpower_info_from_hwpg(struct ieee80211_hw *hw, + bool autoload_fail, u8 *hwinfo) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_efuse *efu = rtl_efuse(rtl_priv(hw)); + struct txpower_info_2g pwr2g; + struct txpower_info_5g pwr5g; + u8 channel5g[CHANNEL_MAX_NUMBER_5G] = { + 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, + 56, 58, 60, 62, 64, 100, 102, 104, 106, + 108, 110, 112, 114, 116, 118, 120, 122, + 124, 126, 128, 130, 132, 134, 136, 138, + 140, 142, 144, 149, 151, 153, 155, 157, + 159, 161, 163, 165, 167, 168, 169, 171, + 173, 175, 177}; + u8 channel5g_80m[CHANNEL_MAX_NUMBER_5G_80M] = { + 42, 58, 106, 122, 138, 155, 171}; + u8 rf, idx; + u8 i; + + _rtl8192ee_read_power_value_fromprom(hw, &pwr2g, &pwr5g, + autoload_fail, hwinfo); + + for (rf = 0; rf < MAX_RF_PATH; rf++) { + for (i = 0; i < 14; i++) { + idx = _rtl92ee_get_chnl_group(i + 1); + + if (i == CHANNEL_MAX_NUMBER_2G - 1) { + efu->txpwrlevel_cck[rf][i] = + pwr2g.index_cck_base[rf][5]; + efu->txpwrlevel_ht40_1s[rf][i] = + pwr2g.index_bw40_base[rf][idx]; + } else { + efu->txpwrlevel_cck[rf][i] = + pwr2g.index_cck_base[rf][idx]; + efu->txpwrlevel_ht40_1s[rf][i] = + pwr2g.index_bw40_base[rf][idx]; + } + } + for (i = 0; i < CHANNEL_MAX_NUMBER_5G; i++) { + idx = _rtl92ee_get_chnl_group(channel5g[i]); + efu->txpwr_5g_bw40base[rf][i] = + pwr5g.index_bw40_base[rf][idx]; + } + for (i = 0; i < CHANNEL_MAX_NUMBER_5G_80M; i++) { + u8 upper, lower; + idx = _rtl92ee_get_chnl_group(channel5g_80m[i]); + upper = pwr5g.index_bw40_base[rf][idx]; + lower = pwr5g.index_bw40_base[rf][idx + 1]; + + efu->txpwr_5g_bw80base[rf][i] = (upper + lower) / 2; + } + for (i = 0; i < MAX_TX_COUNT; i++) { + efu->txpwr_cckdiff[rf][i] = pwr2g.cck_diff[rf][i]; + efu->txpwr_legacyhtdiff[rf][i] = pwr2g.ofdm_diff[rf][i]; + efu->txpwr_ht20diff[rf][i] = pwr2g.bw20_diff[rf][i]; + efu->txpwr_ht40diff[rf][i] = pwr2g.bw40_diff[rf][i]; + + efu->txpwr_5g_ofdmdiff[rf][i] = pwr5g.ofdm_diff[rf][i]; + efu->txpwr_5g_bw20diff[rf][i] = pwr5g.bw20_diff[rf][i]; + efu->txpwr_5g_bw40diff[rf][i] = pwr5g.bw40_diff[rf][i]; + efu->txpwr_5g_bw80diff[rf][i] = pwr5g.bw80_diff[rf][i]; + } + } + + if (!autoload_fail) + efu->eeprom_thermalmeter = hwinfo[EEPROM_THERMAL_METER_92E]; + else + efu->eeprom_thermalmeter = EEPROM_DEFAULT_THERMALMETER; + + if (efu->eeprom_thermalmeter == 0xff || autoload_fail) { + efu->b_apk_thermalmeterignore = true; + efu->eeprom_thermalmeter = EEPROM_DEFAULT_THERMALMETER; + } + + efu->thermalmeter[0] = efu->eeprom_thermalmeter; + RTPRINT(rtlpriv, FINIT, INIT_TxPower, + "thermalmeter = 0x%x\n", efu->eeprom_thermalmeter); + + if (!autoload_fail) { + efu->eeprom_regulatory = hwinfo[EEPROM_RF_BOARD_OPTION_92E] + & 0x07; + if (hwinfo[EEPROM_RF_BOARD_OPTION_92E] == 0xFF) + efu->eeprom_regulatory = 0; + } else { + efu->eeprom_regulatory = 0; + } + RTPRINT(rtlpriv, FINIT, INIT_TxPower, + "eeprom_regulatory = 0x%x\n", efu->eeprom_regulatory); +} + +static void _rtl92ee_read_adapter_info(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + u16 i, usvalue; + u8 hwinfo[HWSET_MAX_SIZE]; + u16 eeprom_id; + + if (rtlefuse->epromtype == EEPROM_BOOT_EFUSE) { + stg_rtl_efuse92e_shadow_map_update(hw); + + memcpy(hwinfo, &rtlefuse->efuse_map[EFUSE_INIT_MAP][0], + HWSET_MAX_SIZE); + } else if (rtlefuse->epromtype == EEPROM_93C46) { + RT_TRACE(COMP_ERR, DBG_EMERG, + ("RTL819X Not boot from eeprom, check it !!")); + return; + } else { + RT_TRACE(COMP_ERR, DBG_EMERG, + ("boot from neither eeprom nor efuse, check it !!")); + return; + } + + RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_LOUD, "MAP \n", + hwinfo, HWSET_MAX_SIZE); + + eeprom_id = *((u16 *) &hwinfo[0]); + if (eeprom_id != RTL8192E_EEPROM_ID) { + RT_TRACE(COMP_ERR, DBG_WARNING, + ("EEPROM ID(%#x) is invalid!!\n", eeprom_id)); + rtlefuse->autoload_failflag = true; + } else { + RT_TRACE(COMP_INIT, DBG_LOUD, ("Autoload OK\n")); + rtlefuse->autoload_failflag = false; + } + + if (rtlefuse->autoload_failflag == true) + return; + /*VID DID SVID SDID*/ + rtlefuse->eeprom_vid = *(u16 *) &hwinfo[EEPROM_VID]; + rtlefuse->eeprom_did = *(u16 *) &hwinfo[EEPROM_DID]; + rtlefuse->eeprom_svid = *(u16 *) &hwinfo[EEPROM_SVID]; + rtlefuse->eeprom_smid = *(u16 *) &hwinfo[EEPROM_SMID]; + RT_TRACE(COMP_INIT, DBG_LOUD, ("EEPROMId = 0x%4x\n", eeprom_id)); + RT_TRACE(COMP_INIT, DBG_LOUD, + ("EEPROM VID = 0x%4x\n", rtlefuse->eeprom_vid)); + RT_TRACE(COMP_INIT, DBG_LOUD, + ("EEPROM DID = 0x%4x\n", rtlefuse->eeprom_did)); + RT_TRACE(COMP_INIT, DBG_LOUD, + ("EEPROM SVID = 0x%4x\n", rtlefuse->eeprom_svid)); + RT_TRACE(COMP_INIT, DBG_LOUD, + ("EEPROM SMID = 0x%4x\n", rtlefuse->eeprom_smid)); + /*customer ID*/ + rtlefuse->eeprom_oemid = *(u8 *) &hwinfo[EEPROM_CUSTOMER_ID]; + if (rtlefuse->eeprom_oemid == 0xFF) + rtlefuse->eeprom_oemid = 0; + + RT_TRACE(COMP_INIT, DBG_LOUD, + ("EEPROM Customer ID: 0x%2x\n", rtlefuse->eeprom_oemid)); + /*EEPROM version*/ + rtlefuse->eeprom_version = *(u8 *) &hwinfo[EEPROM_VERSION]; + /*mac address*/ + for (i = 0; i < 6; i += 2) { + usvalue = *(u16 *) &hwinfo[EEPROM_MAC_ADDR + i]; + *((u16 *) (&rtlefuse->dev_addr[i])) = usvalue; + } + + RT_TRACE(COMP_INIT, DBG_DMESG, + ("dev_addr: %pM\n", rtlefuse->dev_addr)); + /*channel plan */ + rtlefuse->eeprom_channelplan = *(u8 *) &hwinfo[EEPROM_CHANNELPLAN]; + /* set channel paln to world wide 13 */ + rtlefuse->channel_plan = COUNTRY_CODE_WORLD_WIDE_13; + /*tx power*/ + _rtl92ee_read_txpower_info_from_hwpg(hw, rtlefuse->autoload_failflag, + hwinfo); + + rtl92ee_read_bt_coexist_info_from_hwpg(hw, rtlefuse->autoload_failflag, + hwinfo); + + /*board type*/ + rtlefuse->board_type = (((*(u8 *) &hwinfo[EEPROM_RF_BOARD_OPTION_92E]) + & 0xE0) >> 5); + if ((*(u8 *) &hwinfo[EEPROM_RF_BOARD_OPTION_92E]) == 0xFF) + rtlefuse->board_type = 0; + + rtlhal->boad_type = rtlefuse->board_type; + /*parse xtal*/ + rtlefuse->crystalcap = hwinfo[EEPROM_XTAL_92E]; + if (hwinfo[EEPROM_XTAL_92E] == 0xFF) + rtlefuse->crystalcap = 0x20; + + /*antenna diversity*/ + rtlefuse->antenna_div_type = NO_ANTDIV; + rtlefuse->antenna_div_cfg = 0; + + if (rtlhal->oem_id == RT_CID_DEFAULT) { + switch (rtlefuse->eeprom_oemid) { + case EEPROM_CID_DEFAULT: + if (rtlefuse->eeprom_did == 0x818B) { + if ((rtlefuse->eeprom_svid == 0x10EC) && + (rtlefuse->eeprom_smid == 0x001B)) + rtlhal->oem_id = RT_CID_819x_Lenovo; + } else { + rtlhal->oem_id = RT_CID_DEFAULT; + } + break; + default: + rtlhal->oem_id = RT_CID_DEFAULT; + break; + } + } +} + +static void _rtl92ee_hal_customized_behavior(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + + pcipriv->ledctl.bled_opendrain = true; + + RT_TRACE(COMP_INIT, DBG_DMESG, + ("RT Customized ID: 0x%02X\n", rtlhal->oem_id)); +} + +void rtl92ee_read_eeprom_info(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + u8 tmp_u1b; + + rtlhal->version = _rtl92ee_read_chip_version(hw); + if (get_rf_type(rtlphy) == RF_1T1R) + rtlpriv->dm.brfpath_rxenable[0] = true; + else + rtlpriv->dm.brfpath_rxenable[0] = + rtlpriv->dm.brfpath_rxenable[1] = true; + RT_TRACE(COMP_INIT, DBG_LOUD, ("VersionID = 0x%4x\n", + rtlhal->version)); + tmp_u1b = rtl_read_byte(rtlpriv, REG_9346CR); + if (tmp_u1b & BIT(4)) { + RT_TRACE(COMP_INIT, DBG_DMESG, ("Boot from EEPROM\n")); + rtlefuse->epromtype = EEPROM_93C46; + } else { + RT_TRACE(COMP_INIT, DBG_DMESG, ("Boot from EFUSE\n")); + rtlefuse->epromtype = EEPROM_BOOT_EFUSE; + } + if (tmp_u1b & BIT(5)) { + RT_TRACE(COMP_INIT, DBG_LOUD, ("Autoload OK\n")); + rtlefuse->autoload_failflag = false; + _rtl92ee_read_adapter_info(hw); + } else { + RT_TRACE(COMP_ERR, DBG_EMERG, ("Autoload ERR!!\n")); + } + _rtl92ee_hal_customized_behavior(hw); + + rtlphy->rfpath_rx_enable[0] = true; + if (rtlphy->rf_type == RF_2T2R) + rtlphy->rfpath_rx_enable[1] = true; +} + +static u8 _rtl92ee_mrate_idx_to_arfr_id(struct ieee80211_hw *hw, u8 rate_index) +{ + u8 ret = 0; + + switch (rate_index) { + case RATR_INX_WIRELESS_NGB: + ret = 0; + break; + case RATR_INX_WIRELESS_N: + case RATR_INX_WIRELESS_NG: + ret = 4; + break; + case RATR_INX_WIRELESS_NB: + ret = 2; + break; + case RATR_INX_WIRELESS_GB: + ret = 6; + break; + case RATR_INX_WIRELESS_G: + ret = 7; + break; + case RATR_INX_WIRELESS_B: + ret = 8; + break; + default: + ret = 0; + break; + } + return ret; +} + +static void rtl92ee_update_hal_rate_mask(struct ieee80211_hw *hw, + struct ieee80211_sta *sta, + u8 rssi_level) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct rtl_sta_info *sta_entry = NULL; + u32 ratr_bitmap; + u8 ratr_index; + u8 b_curtxbw_40mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) + ? 1 : 0; + u8 b_curshortgi_40mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40) ? + 1 : 0; + u8 b_curshortgi_20mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20) ? + 1 : 0; + enum wireless_mode wirelessmode = 0; + bool b_shortgi = false; + u8 rate_mask[7] = {0}; + u8 macid = 0; + /*u8 mimo_ps = IEEE80211_SMPS_OFF;*/ + sta_entry = (struct rtl_sta_info *) sta->drv_priv; + wirelessmode = sta_entry->wireless_mode; + if (mac->opmode == NL80211_IFTYPE_STATION || + mac->opmode == NL80211_IFTYPE_MESH_POINT) + b_curtxbw_40mhz = mac->bw_40; + else if (mac->opmode == NL80211_IFTYPE_AP || + mac->opmode == NL80211_IFTYPE_ADHOC) + macid = sta->aid + 1; + + ratr_bitmap = sta->supp_rates[0]; + if (mac->opmode == NL80211_IFTYPE_ADHOC) + ratr_bitmap = 0xfff; + + ratr_bitmap |= (sta->ht_cap.mcs.rx_mask[1] << 20 | + sta->ht_cap.mcs.rx_mask[0] << 12); + + switch (wirelessmode) { + case WIRELESS_MODE_B: + ratr_index = RATR_INX_WIRELESS_B; + if (ratr_bitmap & 0x0000000c) + ratr_bitmap &= 0x0000000d; + else + ratr_bitmap &= 0x0000000f; + break; + case WIRELESS_MODE_G: + ratr_index = RATR_INX_WIRELESS_GB; + + if (rssi_level == 1) + ratr_bitmap &= 0x00000f00; + else if (rssi_level == 2) + ratr_bitmap &= 0x00000ff0; + else + ratr_bitmap &= 0x00000ff5; + break; + case WIRELESS_MODE_N_24G: + if (b_curtxbw_40mhz) + ratr_index = RATR_INX_WIRELESS_NGB; + else + ratr_index = RATR_INX_WIRELESS_NB; + + if (rtlphy->rf_type == RF_1T1R) { + if (b_curtxbw_40mhz) { + if (rssi_level == 1) + ratr_bitmap &= 0x000f0000; + else if (rssi_level == 2) + ratr_bitmap &= 0x000ff000; + else + ratr_bitmap &= 0x000ff015; + } else { + if (rssi_level == 1) + ratr_bitmap &= 0x000f0000; + else if (rssi_level == 2) + ratr_bitmap &= 0x000ff000; + else + ratr_bitmap &= 0x000ff005; + } + } else { + if (b_curtxbw_40mhz) { + if (rssi_level == 1) + ratr_bitmap &= 0x0f8f0000; + else if (rssi_level == 2) + ratr_bitmap &= 0x0ffff000; + else + ratr_bitmap &= 0x0ffff015; + } else { + if (rssi_level == 1) + ratr_bitmap &= 0x0f8f0000; + else if (rssi_level == 2) + ratr_bitmap &= 0x0ffff000; + else + ratr_bitmap &= 0x0ffff005; + } + } + + if ((b_curtxbw_40mhz && b_curshortgi_40mhz) || + (!b_curtxbw_40mhz && b_curshortgi_20mhz)) { + + if (macid == 0) + b_shortgi = true; + else if (macid == 1) + b_shortgi = false; + } + break; + default: + ratr_index = RATR_INX_WIRELESS_NGB; + + if (rtlphy->rf_type == RF_1T1R) + ratr_bitmap &= 0x000ff0ff; + else + ratr_bitmap &= 0x0f8ff0ff; + break; + } + ratr_index = _rtl92ee_mrate_idx_to_arfr_id(hw, ratr_index); + sta_entry->ratr_index = ratr_index; + + RT_TRACE(COMP_RATR, DBG_DMESG, + ("ratr_bitmap :%x\n", ratr_bitmap)); + *(u32 *) &rate_mask = (ratr_bitmap & 0x0fffffff) | + (ratr_index << 28); + rate_mask[0] = macid; + rate_mask[1] = ratr_index | (b_shortgi ? 0x80 : 0x00); + rate_mask[2] = b_curtxbw_40mhz; + rate_mask[3] = (u8)(ratr_bitmap & 0x000000ff); + rate_mask[4] = (u8)((ratr_bitmap & 0x0000ff00) >> 8); + rate_mask[5] = (u8)((ratr_bitmap & 0x00ff0000) >> 16); + rate_mask[6] = (u8)((ratr_bitmap & 0xff000000) >> 24); + RT_TRACE(COMP_RATR, DBG_DMESG, + ("Rate_index:%x, ratr_val:%x, %x:%x:%x:%x:%x:%x:%x\n", + ratr_index, ratr_bitmap, rate_mask[0], rate_mask[1], + rate_mask[2], rate_mask[3], rate_mask[4], + rate_mask[5], rate_mask[6])); + rtl92ee_fill_h2c_cmd(hw, H2C_92E_RA_MASK, 7, rate_mask); + _rtl92ee_set_bcn_ctrl_reg(hw, BIT(3), 0); +} + + +void rtl92ee_update_hal_rate_tbl(struct ieee80211_hw *hw, + struct ieee80211_sta *sta, u8 rssi_level) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + if (rtlpriv->dm.b_useramask) + rtl92ee_update_hal_rate_mask(hw, sta, rssi_level); +} + +void rtl92ee_update_channel_access_setting(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + u16 sifs_timer; + + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SLOT_TIME, + (u8 *) &mac->slot_time); + if (!mac->ht_enable) + sifs_timer = 0x0a0a; + else + sifs_timer = 0x0e0e; + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SIFS, (u8 *) &sifs_timer); +} + +bool rtl92ee_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid) +{ + *valid = 1; + return true; +} + +void rtl92ee_set_key(struct ieee80211_hw *hw, u32 key_index, + u8 *p_macaddr, bool is_group, u8 enc_algo, + bool is_wepkey, bool clear_all) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); + u8 *macaddr = p_macaddr; + u32 entry_id = 0; + bool is_pairwise = false; + + static u8 cam_const_addr[4][6] = { + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x02}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x03} + }; + static u8 cam_const_broad[] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff + }; + + if (clear_all) { + u8 idx = 0; + u8 cam_offset = 0; + u8 clear_number = 5; + + RT_TRACE(COMP_SEC, DBG_DMESG, ("clear_all\n")); + + for (idx = 0; idx < clear_number; idx++) { + stg_rtl_cam_mark_invalid(hw, cam_offset + idx); + stg_rtl_cam_empty_entry(hw, cam_offset + idx); + + if (idx < 5) { + memset(rtlpriv->sec.key_buf[idx], 0, + MAX_KEY_LEN); + rtlpriv->sec.key_len[idx] = 0; + } + } + + } else { + switch (enc_algo) { + case WEP40_ENCRYPTION: + enc_algo = CAM_WEP40; + break; + case WEP104_ENCRYPTION: + enc_algo = CAM_WEP104; + break; + case TKIP_ENCRYPTION: + enc_algo = CAM_TKIP; + break; + case AESCCMP_ENCRYPTION: + enc_algo = CAM_AES; + break; + default: + RT_TRACE(COMP_ERR, DBG_LOUD, + ("switch case not process \n")); + enc_algo = CAM_TKIP; + break; + } + + if (is_wepkey || rtlpriv->sec.use_defaultkey) { + macaddr = cam_const_addr[key_index]; + entry_id = key_index; + } else { + if (is_group) { + macaddr = cam_const_broad; + entry_id = key_index; + } else { + if (mac->opmode == NL80211_IFTYPE_AP || + mac->opmode == NL80211_IFTYPE_MESH_POINT) { + entry_id = stg_rtl_cam_get_free_entry(hw, + p_macaddr); + if (entry_id >= TOTAL_CAM_ENTRY) { + RT_TRACE(COMP_SEC, DBG_EMERG, + ("Can not find free hw security cam entry\n")); + return; + } + } else { + entry_id = CAM_PAIRWISE_KEY_POSITION; + } + + key_index = PAIRWISE_KEYIDX; + is_pairwise = true; + } + } + + if (rtlpriv->sec.key_len[key_index] == 0) { + RT_TRACE(COMP_SEC, DBG_DMESG, + ("delete one entry, entry_id is %d\n", + entry_id)); + if (mac->opmode == NL80211_IFTYPE_AP || + mac->opmode == NL80211_IFTYPE_MESH_POINT) + stg_rtl_cam_del_entry(hw, p_macaddr); + stg_rtl_cam_delete_one_entry(hw, p_macaddr, entry_id); + } else { + RT_TRACE(COMP_SEC, DBG_DMESG, ("add one entry\n")); + if (is_pairwise) { + RT_TRACE(COMP_SEC, DBG_DMESG, + ("set Pairwiase key\n")); + + stg_rtl_cam_add_one_entry(hw, macaddr, key_index, + entry_id, enc_algo, + CAM_CONFIG_NO_USEDK, + rtlpriv->sec.key_buf[key_index]); + } else { + RT_TRACE(COMP_SEC, DBG_DMESG, + ("set group key\n")); + + if (mac->opmode == NL80211_IFTYPE_ADHOC) { + stg_rtl_cam_add_one_entry(hw, + rtlefuse->dev_addr, + PAIRWISE_KEYIDX, + CAM_PAIRWISE_KEY_POSITION, + enc_algo, CAM_CONFIG_NO_USEDK, + rtlpriv->sec.key_buf[entry_id]); + } + + stg_rtl_cam_add_one_entry(hw, macaddr, key_index, + entry_id, enc_algo, + CAM_CONFIG_NO_USEDK, + rtlpriv->sec.key_buf[entry_id]); + } + } + } +} + +void rtl92ee_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw, + bool auto_load_fail, u8 *hwinfo) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u8 value; + + if (!auto_load_fail) { + value = hwinfo[EEPROM_RF_BOARD_OPTION_92E]; + if (((value & 0xe0) >> 5) == 0x1) + rtlpriv->btcoexist.btc_info.btcoexist = 1; + else + rtlpriv->btcoexist.btc_info.btcoexist = 0; + + rtlpriv->btcoexist.btc_info.bt_type = BT_RTL8192E; + rtlpriv->btcoexist.btc_info.ant_num = ANT_TOTAL_X2; + } else { + rtlpriv->btcoexist.btc_info.btcoexist = 1; + rtlpriv->btcoexist.btc_info.bt_type = BT_RTL8192E; + rtlpriv->btcoexist.btc_info.ant_num = ANT_TOTAL_X1; + } +} + +void rtl92ee_bt_reg_init(struct ieee80211_hw *hw) +{ + struct rtl_pci_priv *rtlpcipriv = rtl_pcipriv(hw); + + /* 0:Low, 1:High, 2:From Efuse. */ + rtlpcipriv->btcoexist.b_reg_bt_iso = 2; + /* 0:Idle, 1:None-SCO, 2:SCO, 3:From Counter. */ + rtlpcipriv->btcoexist.b_reg_bt_sco = 3; + /* 0:Disable BT control A-MPDU, 1:Enable BT control A-MPDU. */ + rtlpcipriv->btcoexist.b_reg_bt_sco = 0; +} + +void rtl92ee_bt_hw_init(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + if (rtlpriv->cfg->ops->get_btc_status()) { + rtlpriv->btcoexist.btc_ops->btc_init_hw_config(rtlpriv); + } +} + +void rtl92ee_suspend(struct ieee80211_hw *hw) +{ +} + +void rtl92ee_resume(struct ieee80211_hw *hw) +{ +} + +/* Turn on AAP (RCR:bit 0) for promicuous mode. */ +void rtl92ee_allow_all_destaddr(struct ieee80211_hw *hw, + bool allow_all_da, bool write_into_reg) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + + if (allow_all_da) /* Set BIT0 */ + rtlpci->receive_config |= RCR_AAP; + else /* Clear BIT0 */ + rtlpci->receive_config &= ~RCR_AAP; + + if (write_into_reg) + rtl_write_dword(rtlpriv, REG_RCR, rtlpci->receive_config); + + RT_TRACE(COMP_TURBO | COMP_INIT, DBG_LOUD, + ("receive_config = 0x%08X, write_into_reg =%d\n", + rtlpci->receive_config, write_into_reg)); +} diff --git a/drivers/staging/rtl8192ee/rtl8192ee/hw.h b/drivers/staging/rtl8192ee/rtl8192ee/hw.h new file mode 100644 index 000000000000..e99d7bde1c6f --- /dev/null +++ b/drivers/staging/rtl8192ee/rtl8192ee/hw.h @@ -0,0 +1,67 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#ifndef __RTL92E_HW_H__ +#define __RTL92E_HW_H__ + + +void rtl92ee_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val); +void rtl92ee_read_eeprom_info(struct ieee80211_hw *hw); +void rtl92ee_interrupt_recognized(struct ieee80211_hw *hw, + u32 *p_inta, u32 *p_intb); +int rtl92ee_hw_init(struct ieee80211_hw *hw); +void rtl92ee_card_disable(struct ieee80211_hw *hw); +void rtl92ee_enable_interrupt(struct ieee80211_hw *hw); +void rtl92ee_disable_interrupt(struct ieee80211_hw *hw); +int rtl92ee_set_network_type(struct ieee80211_hw *hw, enum nl80211_iftype type); +void rtl92ee_set_check_bssid(struct ieee80211_hw *hw, bool check_bssid); +void rtl92ee_set_qos(struct ieee80211_hw *hw, int aci); +void rtl92ee_set_beacon_related_registers(struct ieee80211_hw *hw); +void rtl92ee_set_beacon_interval(struct ieee80211_hw *hw); +void rtl92ee_update_interrupt_mask(struct ieee80211_hw *hw, + u32 add_msr, u32 rm_msr); +void rtl92ee_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val); +void rtl92ee_update_hal_rate_tbl(struct ieee80211_hw *hw, + struct ieee80211_sta *sta, u8 rssi_level); +void rtl92ee_update_channel_access_setting(struct ieee80211_hw *hw); +bool rtl92ee_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid); +void rtl92ee_enable_hw_security_config(struct ieee80211_hw *hw); +void rtl92ee_set_key(struct ieee80211_hw *hw, u32 key_index, + u8 *p_macaddr, bool is_group, u8 enc_algo, + bool is_wepkey, bool clear_all); +void rtl92ee_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw, + bool autoload_fail, u8 *hwinfo); +void rtl92ee_bt_reg_init(struct ieee80211_hw *hw); +void rtl92ee_bt_hw_init(struct ieee80211_hw *hw); +void rtl92ee_suspend(struct ieee80211_hw *hw); +void rtl92ee_resume(struct ieee80211_hw *hw); +void rtl92ee_allow_all_destaddr(struct ieee80211_hw *hw, bool allow_all_da, + bool write_into_reg); +void rtl92ee_fw_clk_off_timer_callback(unsigned long data); +#endif diff --git a/drivers/staging/rtl8192ee/rtl8192ee/led.c b/drivers/staging/rtl8192ee/rtl8192ee/led.c new file mode 100644 index 000000000000..3b459c93a843 --- /dev/null +++ b/drivers/staging/rtl8192ee/rtl8192ee/led.c @@ -0,0 +1,134 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#include "../wifi.h" +#include "../pci.h" +#include "led.h" +#include "reg.h" + +static void _rtl92ee_init_led(struct ieee80211_hw *hw, + struct rtl_led *pled, enum rtl_led_pin ledpin) +{ + pled->hw = hw; + pled->ledpin = ledpin; + pled->b_ledon = false; +} + +void rtl92ee_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled) +{ + u32 ledcfg; + struct rtl_priv *rtlpriv = rtl_priv(hw); + + RT_TRACE(COMP_LED, DBG_LOUD, + ("LedAddr:%X ledpin =%d\n", REG_LEDCFG2, pled->ledpin)); + + switch (pled->ledpin) { + case LED_PIN_GPIO0: + break; + case LED_PIN_LED0: + ledcfg = rtl_read_dword(rtlpriv, REG_GPIO_PIN_CTRL) | BIT(21); + ledcfg &= ~BIT(13) & ~BIT(29); + rtl_write_dword(rtlpriv, REG_GPIO_PIN_CTRL, ledcfg); + break; + case LED_PIN_LED1: + break; + default: + RT_TRACE(COMP_ERR, DBG_EMERG, + ("switch case not process\n")); + break; + } + pled->b_ledon = true; +} + +void rtl92ee_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u32 ledcfg; + + RT_TRACE(COMP_LED, DBG_LOUD, + ("LedAddr:%X ledpin =%d\n", REG_LEDCFG2, pled->ledpin)); + + switch (pled->ledpin) { + case LED_PIN_GPIO0: + break; + case LED_PIN_LED0: + ledcfg = rtl_read_dword(rtlpriv , REG_GPIO_PIN_CTRL) | ~BIT(21); + ledcfg &= ~BIT(29); + rtl_write_dword(rtlpriv, REG_GPIO_PIN_CTRL, ledcfg); + break; + case LED_PIN_LED1: + break; + default: + RT_TRACE(COMP_ERR, DBG_LOUD, + ("switch case not process\n")); + break; + } + pled->b_ledon = false; +} + +void rtl92ee_init_sw_leds(struct ieee80211_hw *hw) +{ + struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); + _rtl92ee_init_led(hw, &(pcipriv->ledctl.sw_led0), LED_PIN_LED0); + _rtl92ee_init_led(hw, &(pcipriv->ledctl.sw_led1), LED_PIN_LED1); +} + +static void _rtl92ee_sw_led_control(struct ieee80211_hw *hw, + enum led_ctl_mode ledaction) +{ + struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); + struct rtl_led *pLed0 = &(pcipriv->ledctl.sw_led0); + switch (ledaction) { + case LED_CTL_POWER_ON: + case LED_CTL_LINK: + case LED_CTL_NO_LINK: + rtl92ee_sw_led_on(hw, pLed0); + break; + case LED_CTL_POWER_OFF: + rtl92ee_sw_led_off(hw, pLed0); + break; + default: + break; + } +} + +void rtl92ee_led_control(struct ieee80211_hw *hw, enum led_ctl_mode ledaction) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + + if ((ppsc->rfoff_reason > RF_CHANGE_BY_PS) && + (ledaction == LED_CTL_TX || + ledaction == LED_CTL_RX || + ledaction == LED_CTL_SITE_SURVEY || + ledaction == LED_CTL_LINK || + ledaction == LED_CTL_NO_LINK || + ledaction == LED_CTL_START_TO_LINK || + ledaction == LED_CTL_POWER_ON)) { + return; + } + RT_TRACE(COMP_LED, DBG_TRACE, ("ledaction %d,\n", ledaction)); + _rtl92ee_sw_led_control(hw, ledaction); +} diff --git a/drivers/staging/rtl8192ee/rtl8192ee/led.h b/drivers/staging/rtl8192ee/rtl8192ee/led.h new file mode 100644 index 000000000000..7302eda535d9 --- /dev/null +++ b/drivers/staging/rtl8192ee/rtl8192ee/led.h @@ -0,0 +1,37 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#ifndef __RTL92E_LED_H__ +#define __RTL92E_LED_H__ + +void rtl92ee_init_sw_leds(struct ieee80211_hw *hw); +void rtl92ee_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled); +void rtl92ee_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled); +void rtl92ee_led_control(struct ieee80211_hw *hw, enum led_ctl_mode ledaction); +#endif diff --git a/drivers/staging/rtl8192ee/rtl8192ee/phy.c b/drivers/staging/rtl8192ee/rtl8192ee/phy.c new file mode 100644 index 000000000000..beef284615e5 --- /dev/null +++ b/drivers/staging/rtl8192ee/rtl8192ee/phy.c @@ -0,0 +1,3282 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#include "../wifi.h" +#include "../pci.h" +#include "../ps.h" +#include "reg.h" +#include "def.h" +#include "phy.h" +#include "rf.h" +#include "dm.h" +#include "table.h" + +static u32 _rtl92ee_phy_rf_serial_read(struct ieee80211_hw *hw, + enum radio_path rfpath, u32 offset); +static void _rtl92ee_phy_rf_serial_write(struct ieee80211_hw *hw, + enum radio_path rfpath, u32 offset, + u32 data); +static u32 _rtl92ee_phy_calculate_bit_shift(u32 bitmask); +static bool _rtl92ee_phy_bb8192ee_config_parafile(struct ieee80211_hw *hw); +static bool _rtl92ee_phy_config_mac_with_headerfile(struct ieee80211_hw *hw); +static bool _rtl92ee_phy_config_bb_with_headerfile(struct ieee80211_hw *hw, + u8 configtype); +static bool _rtl92ee_phy_config_bb_with_pgheaderfile(struct ieee80211_hw *hw, + u8 configtype); +static void _rtl92ee_phy_init_bb_rf_register_definition(struct ieee80211_hw *hw); +static bool _rtl92ee_phy_set_sw_chnl_cmdarray(struct swchnlcmd *cmdtable, + u32 cmdtableidx, u32 cmdtablesz, + enum swchnlcmd_id cmdid, + u32 para1, u32 para2, + u32 msdelay); +static bool _rtl92ee_phy_sw_chnl_step_by_step(struct ieee80211_hw *hw, + u8 channel, u8 *stage, + u8 *step, u32 *delay); +static long _rtl92ee_phy_txpwr_idx_to_dbm(struct ieee80211_hw *hw, + enum wireless_mode wirelessmode, + u8 txpwridx); +static void rtl92ee_phy_set_rf_on(struct ieee80211_hw *hw); +static void rtl92ee_phy_set_io(struct ieee80211_hw *hw); + +u32 rtl92ee_phy_query_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u32 returnvalue, originalvalue, bitshift; + + RT_TRACE(COMP_RF, DBG_TRACE, + ("regaddr(%#x), bitmask(%#x)\n", regaddr, bitmask)); + originalvalue = rtl_read_dword(rtlpriv, regaddr); + bitshift = _rtl92ee_phy_calculate_bit_shift(bitmask); + returnvalue = (originalvalue & bitmask) >> bitshift; + + RT_TRACE(COMP_RF, DBG_TRACE, + ("BBR MASK = 0x%x Addr[0x%x]= 0x%x\n", + bitmask, regaddr, originalvalue)); + + return returnvalue; +} + +void rtl92ee_phy_set_bb_reg(struct ieee80211_hw *hw, u32 regaddr, + u32 bitmask, u32 data) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u32 originalvalue, bitshift; + + RT_TRACE(COMP_RF, DBG_TRACE, + ("regaddr(%#x), bitmask(%#x), data(%#x)\n", + regaddr, bitmask, data)); + + if (bitmask != MASKDWORD) { + originalvalue = rtl_read_dword(rtlpriv, regaddr); + bitshift = _rtl92ee_phy_calculate_bit_shift(bitmask); + data = ((originalvalue & (~bitmask)) | (data << bitshift)); + } + + rtl_write_dword(rtlpriv, regaddr, data); + + RT_TRACE(COMP_RF, DBG_TRACE, + ("regaddr(%#x), bitmask(%#x), data(%#x)\n", + regaddr, bitmask, data)); +} + +u32 rtl92ee_phy_query_rf_reg(struct ieee80211_hw *hw, + enum radio_path rfpath, u32 regaddr, u32 bitmask) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u32 original_value, readback_value, bitshift; + unsigned long flags; + + RT_TRACE(COMP_RF, DBG_TRACE, + ("regaddr(%#x), rfpath(%#x), bitmask(%#x)\n", + regaddr, rfpath, bitmask)); + + spin_lock_irqsave(&rtlpriv->locks.rf_lock, flags); + + + original_value = _rtl92ee_phy_rf_serial_read(hw , rfpath, regaddr); + bitshift = _rtl92ee_phy_calculate_bit_shift(bitmask); + readback_value = (original_value & bitmask) >> bitshift; + + spin_unlock_irqrestore(&rtlpriv->locks.rf_lock, flags); + + RT_TRACE(COMP_RF, DBG_TRACE, + ("regaddr(%#x), rfpath(%#x), bitmask(%#x), original_value(%#x)\n", + regaddr, rfpath, bitmask, original_value)); + + return readback_value; +} + +void rtl92ee_phy_set_rf_reg(struct ieee80211_hw *hw, + enum radio_path rfpath, + u32 addr, u32 bitmask, u32 data) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u32 original_value, bitshift; + unsigned long flags; + + RT_TRACE(COMP_RF, DBG_TRACE, + ("regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n", + addr, bitmask, data, rfpath)); + + spin_lock_irqsave(&rtlpriv->locks.rf_lock, flags); + + if (bitmask != RFREG_OFFSET_MASK) { + original_value = _rtl92ee_phy_rf_serial_read(hw, rfpath, addr); + bitshift = _rtl92ee_phy_calculate_bit_shift(bitmask); + data = (original_value & (~bitmask)) | (data << bitshift); + } + + _rtl92ee_phy_rf_serial_write(hw, rfpath, addr, data); + + spin_unlock_irqrestore(&rtlpriv->locks.rf_lock, flags); + + RT_TRACE(COMP_RF, DBG_TRACE, + ("regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n", + addr, bitmask, data, rfpath)); +} + +static u32 _rtl92ee_phy_rf_serial_read(struct ieee80211_hw *hw, + enum radio_path rfpath, u32 offset) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + struct bb_reg_def *pphyreg = &rtlphy->phyreg_def[rfpath]; + u32 newoffset; + u32 tmplong, tmplong2; + u8 rfpi_enable = 0; + u32 retvalue; + + offset &= 0xff; + newoffset = offset; + if (RT_CANNOT_IO(hw)) { + RT_TRACE(COMP_ERR, DBG_EMERG, ("return all one\n")); + return 0xFFFFFFFF; + } + tmplong = rtl_get_bbreg(hw, RFPGA0_XA_HSSIPARAMETER2, MASKDWORD); + if (rfpath == RF90_PATH_A) + tmplong2 = tmplong; + else + tmplong2 = rtl_get_bbreg(hw, pphyreg->rfhssi_para2, MASKDWORD); + tmplong2 = (tmplong2 & (~BLSSIREADADDRESS)) | + (newoffset << 23) | BLSSIREADEDGE; + rtl_set_bbreg(hw, RFPGA0_XA_HSSIPARAMETER2, MASKDWORD, + tmplong & (~BLSSIREADEDGE)); + mdelay(1); + rtl_set_bbreg(hw, pphyreg->rfhssi_para2, MASKDWORD, tmplong2); + mdelay(1); + mdelay(1); + if (rfpath == RF90_PATH_A) + rfpi_enable = (u8) rtl_get_bbreg(hw, RFPGA0_XA_HSSIPARAMETER1, + BIT(8)); + else if (rfpath == RF90_PATH_B) + rfpi_enable = (u8) rtl_get_bbreg(hw, RFPGA0_XB_HSSIPARAMETER1, + BIT(8)); + if (rfpi_enable) + retvalue = rtl_get_bbreg(hw, pphyreg->rflssi_readbackpi, + BLSSIREADBACKDATA); + else + retvalue = rtl_get_bbreg(hw, pphyreg->rflssi_readback, + BLSSIREADBACKDATA); + RT_TRACE(COMP_RF, DBG_TRACE, + ("RFR-%d Addr[0x%x]= 0x%x\n", + rfpath, pphyreg->rflssi_readback, retvalue)); + return retvalue; +} + +static void _rtl92ee_phy_rf_serial_write(struct ieee80211_hw *hw, + enum radio_path rfpath, u32 offset, + u32 data) +{ + u32 data_and_addr; + u32 newoffset; + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + struct bb_reg_def *pphyreg = &rtlphy->phyreg_def[rfpath]; + + if (RT_CANNOT_IO(hw)) { + RT_TRACE(COMP_ERR, DBG_EMERG, ("stop\n")); + return; + } + offset &= 0xff; + newoffset = offset; + data_and_addr = ((newoffset << 20) | (data & 0x000fffff)) & 0x0fffffff; + rtl_set_bbreg(hw, pphyreg->rf3wire_offset, MASKDWORD, data_and_addr); + RT_TRACE(COMP_RF, DBG_TRACE, + ("RFW-%d Addr[0x%x]= 0x%x\n", rfpath, + pphyreg->rf3wire_offset, data_and_addr)); +} + +static u32 _rtl92ee_phy_calculate_bit_shift(u32 bitmask) +{ + u32 i; + + for (i = 0; i <= 31; i++) { + if (((bitmask >> i) & 0x1) == 1) + break; + } + return i; +} + +bool rtl92ee_phy_mac_config(struct ieee80211_hw *hw) +{ + bool rtstatus = _rtl92ee_phy_config_mac_with_headerfile(hw); + + return rtstatus; +} + +bool rtl92ee_phy_bb_config(struct ieee80211_hw *hw) +{ + bool rtstatus = true; + struct rtl_priv *rtlpriv = rtl_priv(hw); + u16 regval; + u32 tmp; + u8 crystal_cap; + + _rtl92ee_phy_init_bb_rf_register_definition(hw); + regval = rtl_read_word(rtlpriv, REG_SYS_FUNC_EN); + rtl_write_word(rtlpriv, REG_SYS_FUNC_EN, + regval | BIT(13) | BIT(0) | BIT(1)); + + rtl_write_byte(rtlpriv, REG_RF_CTRL, RF_EN | RF_RSTB | RF_SDMRSTB); + rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, + FEN_PPLL | FEN_PCIEA | FEN_DIO_PCIE | + FEN_BB_GLB_RSTn | FEN_BBRSTB); + + rtl_write_byte(rtlpriv, REG_AFE_XTAL_CTRL + 1, 0x80); + + tmp = rtl_read_dword(rtlpriv, 0x4c); + rtl_write_dword(rtlpriv, 0x4c, tmp | BIT(23)); + + rtstatus = _rtl92ee_phy_bb8192ee_config_parafile(hw); + + crystal_cap = rtlpriv->efuse.eeprom_crystalcap & 0x3F; + rtl_set_bbreg(hw, REG_MAC_PHY_CTRL, 0xFFF000, + (crystal_cap | (crystal_cap << 6))); + return rtstatus; +} + +bool rtl92ee_phy_rf_config(struct ieee80211_hw *hw) +{ + return rtl92ee_phy_rf6052_config(hw); +} + +static bool _check_condition(struct ieee80211_hw *hw, + const u32 condition) +{ + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); + u32 _board = rtlefuse->board_type; /*need efuse define*/ + u32 _interface = rtlhal->interface; + u32 _platform = 0x08;/*SupportPlatform */ + u32 cond = condition; + + if (condition == 0xCDCDCDCD) + return true; + cond = condition & 0xFF; + if ((_board != cond) && (cond != 0xFF)) + return false; + cond = condition & 0xFF00; + cond = cond >> 8; + if ((_interface & cond) == 0 && cond != 0x07) + return false; + cond = condition & 0xFF0000; + cond = cond >> 16; + if ((_platform & cond) == 0 && cond != 0x0F) + return false; + return true; +} + +static void _rtl92ee_config_rf_reg(struct ieee80211_hw *hw, u32 addr, u32 data, + enum radio_path rfpath, u32 regaddr) +{ + if (addr == 0xfe || addr == 0xffe) { + mdelay(50); + } else { + rtl_set_rfreg(hw, rfpath, regaddr, RFREG_OFFSET_MASK, data); + udelay(1); + + if (addr == 0xb6) { + u32 getvalue; + u8 count = 0; + getvalue = rtl_get_rfreg(hw, rfpath, addr, MASKDWORD); + udelay(1); + + while ((getvalue >> 8) != (data >> 8)) { + count++; + rtl_set_rfreg(hw, rfpath, regaddr, + RFREG_OFFSET_MASK, data); + udelay(1); + getvalue = rtl_get_rfreg(hw, rfpath, addr, + MASKDWORD); + if (count > 5) + break; + } + } + + if (addr == 0xb2) { + u32 getvalue; + u8 count = 0; + getvalue = rtl_get_rfreg(hw, rfpath, addr, MASKDWORD); + + udelay(1); + + while (getvalue != data) { + count++; + rtl_set_rfreg(hw, rfpath, regaddr, + RFREG_OFFSET_MASK, data); + udelay(1); + rtl_set_rfreg(hw, rfpath, 0x18, + RFREG_OFFSET_MASK, 0x0fc07); + udelay(1); + getvalue = rtl_get_rfreg(hw, rfpath, addr, + MASKDWORD); + if (count > 5) + break; + } + } + } +} + +static void _rtl92ee_config_rf_radio_a(struct ieee80211_hw *hw, + u32 addr, u32 data) +{ + u32 content = 0x1000; /*RF Content: radio_a_txt*/ + u32 maskforphyset = (u32)(content & 0xE000); + + _rtl92ee_config_rf_reg(hw, addr, data, RF90_PATH_A, + addr | maskforphyset); +} + +static void _rtl92ee_config_rf_radio_b(struct ieee80211_hw *hw, + u32 addr, u32 data) +{ + u32 content = 0x1001; /*RF Content: radio_b_txt*/ + u32 maskforphyset = (u32)(content & 0xE000); + + _rtl92ee_config_rf_reg(hw, addr, data, RF90_PATH_B, + addr | maskforphyset); +} + +static void _rtl92ee_config_bb_reg(struct ieee80211_hw *hw, + u32 addr, u32 data) +{ + if (addr == 0xfe) + mdelay(50); + else if (addr == 0xfd) + mdelay(5); + else if (addr == 0xfc) + mdelay(1); + else if (addr == 0xfb) + udelay(50); + else if (addr == 0xfa) + udelay(5); + else if (addr == 0xf9) + udelay(1); + else + rtl_set_bbreg(hw, addr, MASKDWORD , data); + + udelay(1); +} + +static void _rtl92ee_phy_init_tx_power_by_rate(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + + u8 band = BAND_ON_2_4G, rf = 0, txnum = 0, sec = 0; + + for (; band <= BAND_ON_5G; ++band) + for (; rf < TX_PWR_BY_RATE_NUM_RF; ++rf) + for (; txnum < TX_PWR_BY_RATE_NUM_RF; ++txnum) + for (; sec < TX_PWR_BY_RATE_NUM_SECTION; ++sec) + rtlphy->tx_power_by_rate_offset + [band][rf][txnum][sec] = 0; +} + +static void _rtl92ee_phy_set_txpower_by_rate_base(struct ieee80211_hw *hw, + u8 band, u8 path, + u8 rate_section, u8 txnum, u8 value) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + + if (path > RF90_PATH_D) { + RT_TRACE(COMP_INIT, DBG_LOUD, ("Invalid Rf Path %d\n", path)); + return; + } + if (band == BAND_ON_2_4G) { + switch (rate_section) { + case CCK: + rtlphy->txpwr_by_rate_base_24g[path][txnum][0] = value; + break; + case OFDM: + rtlphy->txpwr_by_rate_base_24g[path][txnum][1] = value; + break; + case HT_MCS0_MCS7: + rtlphy->txpwr_by_rate_base_24g[path][txnum][2] = value; + break; + case HT_MCS8_MCS15: + rtlphy->txpwr_by_rate_base_24g[path][txnum][3] = value; + break; + default: + RT_TRACE(COMP_INIT, DBG_LOUD, + ("Invalid RateSection %d in 2.4G, Rf %d,%dTx\n", + rate_section, path, txnum)); + break; + }; + } else { + RT_TRACE(COMP_INIT, DBG_LOUD, ("Invalid Band %d\n", band)); + } +} + +static u8 _rtl92ee_phy_get_txpower_by_rate_base(struct ieee80211_hw *hw, u8 band, + u8 path, u8 txnum, u8 rate_section) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + u8 value = 0; + if (path > RF90_PATH_D) { + RT_TRACE(COMP_INIT, DBG_LOUD, ("Invalid Rf Path %d\n", path)); + return 0; + } + if (band == BAND_ON_2_4G) { + switch (rate_section) { + case CCK: + value = rtlphy->txpwr_by_rate_base_24g[path][txnum][0]; + break; + case OFDM: + value = rtlphy->txpwr_by_rate_base_24g[path][txnum][1]; + break; + case HT_MCS0_MCS7: + value = rtlphy->txpwr_by_rate_base_24g[path][txnum][2]; + break; + case HT_MCS8_MCS15: + value = rtlphy->txpwr_by_rate_base_24g[path][txnum][3]; + break; + default: + RT_TRACE(COMP_INIT, DBG_LOUD, + ("Invalid RateSection %d in 2.4G, Rf %d,%dTx\n", + rate_section, path, txnum)); + break; + }; + } else { + RT_TRACE(COMP_INIT, DBG_LOUD, ("Invalid Band %d()\n", band)); + } + return value; +} + +static void _rtl92ee_phy_store_txpower_by_rate_base(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + u16 raw = 0; + u8 base = 0, path = 0; + + for (path = RF90_PATH_A; path <= RF90_PATH_B; ++path) { + if (path == RF90_PATH_A) { + raw = (u16) (rtlphy->tx_power_by_rate_offset[BAND_ON_2_4G][path][RF_1TX][3] >> 24) & 0xFF; + base = (raw >> 4) * 10 + (raw & 0xF); + _rtl92ee_phy_set_txpower_by_rate_base(hw, BAND_ON_2_4G, + path, CCK, RF_1TX, + base); + } else if (path == RF90_PATH_B) { + raw = (u16) (rtlphy->tx_power_by_rate_offset[BAND_ON_2_4G][path][RF_1TX][3] >> 0) & 0xFF; + base = (raw >> 4) * 10 + (raw & 0xF); + _rtl92ee_phy_set_txpower_by_rate_base(hw, BAND_ON_2_4G, + path, CCK, RF_1TX, + base); + } + raw = (u16) (rtlphy->tx_power_by_rate_offset[BAND_ON_2_4G][path][RF_1TX][1] >> 24) & 0xFF; + base = (raw >> 4) * 10 + (raw & 0xF); + _rtl92ee_phy_set_txpower_by_rate_base(hw, BAND_ON_2_4G, path, + OFDM, RF_1TX, base); + + raw = (u16) (rtlphy->tx_power_by_rate_offset[BAND_ON_2_4G][path][RF_1TX][5] >> 24) & 0xFF; + base = (raw >> 4) * 10 + (raw & 0xF); + _rtl92ee_phy_set_txpower_by_rate_base(hw, BAND_ON_2_4G, path, + HT_MCS0_MCS7, RF_1TX, + base); + + raw = (u16) (rtlphy->tx_power_by_rate_offset[BAND_ON_2_4G][path][RF_2TX][7] >> 24) & 0xFF; + base = (raw >> 4) * 10 + (raw & 0xF); + _rtl92ee_phy_set_txpower_by_rate_base(hw, BAND_ON_2_4G, path, + HT_MCS8_MCS15, RF_2TX, + base); + } +} + +static void _phy_convert_txpower_dbm_to_relative_value(u32 *data, u8 start, + u8 end, u8 base) +{ + char i = 0; + u8 tmp = 0; + u32 temp_data = 0; + + for (i = 3; i >= 0; --i) { + if (i >= start && i <= end) { + /* Get the exact value */ + tmp = (u8) (*data >> (i * 8)) & 0xF; + tmp += ((u8) ((*data >> (i * 8 + 4)) & 0xF)) * 10; + + /* Change the value to a relative value */ + tmp = (tmp > base) ? tmp - base : base - tmp; + } else { + tmp = (u8) (*data >> (i * 8)) & 0xFF; + } + temp_data <<= 8; + temp_data |= tmp; + } + *data = temp_data; +} + +static void _rtl92ee_phy_convert_txpower_dbm_to_relative_value(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + u8 base = 0, rf = 0, band = BAND_ON_2_4G; + + for (rf = RF90_PATH_A; rf <= RF90_PATH_B; ++rf) { + if (rf == RF90_PATH_A) { + base = _rtl92ee_phy_get_txpower_by_rate_base(hw, band, + rf, RF_1TX, + CCK); + _phy_convert_txpower_dbm_to_relative_value( + &(rtlphy->tx_power_by_rate_offset[band][rf][RF_1TX][2]), + 1, 1, base); + _phy_convert_txpower_dbm_to_relative_value( + &(rtlphy->tx_power_by_rate_offset[band][rf][RF_1TX][3]), + 1, 3, base); + } else if (rf == RF90_PATH_B) { + base = _rtl92ee_phy_get_txpower_by_rate_base(hw, band, + rf, RF_1TX, + CCK); + _phy_convert_txpower_dbm_to_relative_value( + &(rtlphy->tx_power_by_rate_offset[band][rf][RF_1TX][3]), + 0, 0, base); + _phy_convert_txpower_dbm_to_relative_value( + &(rtlphy->tx_power_by_rate_offset[band][rf][RF_1TX][2]), + 1, 3, base); + } + base = _rtl92ee_phy_get_txpower_by_rate_base(hw, band, rf, + RF_1TX, OFDM); + _phy_convert_txpower_dbm_to_relative_value( + &(rtlphy->tx_power_by_rate_offset[band][rf][RF_1TX][0]), + 0, 3, base); + _phy_convert_txpower_dbm_to_relative_value( + &(rtlphy->tx_power_by_rate_offset[band][rf][RF_1TX][1]), + 0, 3, base); + + base = _rtl92ee_phy_get_txpower_by_rate_base(hw, band, rf, + RF_1TX, + HT_MCS0_MCS7); + _phy_convert_txpower_dbm_to_relative_value( + &(rtlphy->tx_power_by_rate_offset[band][rf][RF_1TX][4]), + 0, 3, base); + _phy_convert_txpower_dbm_to_relative_value( + &(rtlphy->tx_power_by_rate_offset[band][rf][RF_1TX][5]), + 0, 3, base); + base = _rtl92ee_phy_get_txpower_by_rate_base(hw, band, rf, + RF_2TX, + HT_MCS8_MCS15); + _phy_convert_txpower_dbm_to_relative_value( + &(rtlphy->tx_power_by_rate_offset[band][rf][RF_2TX][6]), + 0, 3, base); + _phy_convert_txpower_dbm_to_relative_value( + &(rtlphy->tx_power_by_rate_offset[band][rf][RF_2TX][7]), + 0, 3, base); + } + RT_TRACE(COMP_POWER, DBG_TRACE, + ("<== _rtl92ee_phy_convert_txpower_dbm_to_relative_value()\n")); +} + +static void _rtl92ee_phy_txpower_by_rate_configuration(struct ieee80211_hw *hw) +{ + _rtl92ee_phy_store_txpower_by_rate_base(hw); + _rtl92ee_phy_convert_txpower_dbm_to_relative_value(hw); +} + +static bool _rtl92ee_phy_bb8192ee_config_parafile(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); + bool rtstatus; + + rtstatus = _rtl92ee_phy_config_bb_with_headerfile(hw, + BASEBAND_CONFIG_PHY_REG); + if (!rtstatus) { + RT_TRACE(COMP_ERR, DBG_EMERG, ("Write BB Reg Fail!!")); + return false; + } + + _rtl92ee_phy_init_tx_power_by_rate(hw); + if (rtlefuse->autoload_failflag == false) { + rtlphy->pwrgroup_cnt = 0; + rtstatus = _rtl92ee_phy_config_bb_with_pgheaderfile(hw, + BASEBAND_CONFIG_PHY_REG); + } + _rtl92ee_phy_txpower_by_rate_configuration(hw); + if (!rtstatus) { + RT_TRACE(COMP_ERR, DBG_EMERG, ("BB_PG Reg Fail!!")); + return false; + } + rtstatus = _rtl92ee_phy_config_bb_with_headerfile(hw, + BASEBAND_CONFIG_AGC_TAB); + if (!rtstatus) { + RT_TRACE(COMP_ERR, DBG_EMERG, ("AGC Table Fail\n")); + return false; + } + rtlphy->bcck_high_power = (bool) (rtl_get_bbreg(hw, + RFPGA0_XA_HSSIPARAMETER2, + 0x200)); + + return true; +} + +static bool _rtl92ee_phy_config_mac_with_headerfile(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u32 i; + u32 arraylength; + u32 *ptrarray; + + RT_TRACE(COMP_INIT, DBG_TRACE, ("Read Rtl8192EMACPHY_Array\n")); + arraylength = RTL8192EE_MAC_ARRAY_LEN; + ptrarray = RTL8192EE_MAC_ARRAY; + RT_TRACE(COMP_INIT, DBG_LOUD, + ("Img:RTL8192EE_MAC_ARRAY LEN %d\n" , arraylength)); + for (i = 0; i < arraylength; i = i + 2) + rtl_write_byte(rtlpriv, ptrarray[i], (u8) ptrarray[i + 1]); + return true; +} + +static bool _rtl92ee_phy_config_bb_with_headerfile(struct ieee80211_hw *hw, + u8 configtype) +{ + #define READ_NEXT_PAIR(v1, v2, i) \ + do { \ + i += 2; \ + v1 = array[i]; \ + v2 = array[i+1]; \ + } while (0) + + int i; + u32 *array; + u16 len; + struct rtl_priv *rtlpriv = rtl_priv(hw); + u32 v1 = 0, v2 = 0; + + if (configtype == BASEBAND_CONFIG_PHY_REG) { + len = RTL8192EE_PHY_REG_ARRAY_LEN; + array = RTL8192EE_PHY_REG_ARRAY; + + for (i = 0; i < len; i = i + 2) { + v1 = array[i]; + v2 = array[i+1]; + if (v1 < 0xcdcdcdcd) { + _rtl92ee_config_bb_reg(hw, v1, v2); + } else {/*This line is the start line of branch.*/ + /* to protect READ_NEXT_PAIR not overrun */ + if (i >= len - 2) + break; + + if (!_check_condition(hw , array[i])) { + /*Discard the following pairs*/ + READ_NEXT_PAIR(v1, v2, i); + while (v2 != 0xDEAD && + v2 != 0xCDEF && + v2 != 0xCDCD && i < len - 2) + READ_NEXT_PAIR(v1, v2, i); + i -= 2; /* prevent from for-loop += 2*/ + } else{/* Configure matched pairs and + * skip to end of if-else. */ + READ_NEXT_PAIR(v1, v2, i); + while (v2 != 0xDEAD && + v2 != 0xCDEF && + v2 != 0xCDCD && i < len - 2) { + _rtl92ee_config_bb_reg(hw, v1, + v2); + READ_NEXT_PAIR(v1, v2, i); + } + + while (v2 != 0xDEAD && i < len - 2) + READ_NEXT_PAIR(v1, v2, i); + } + } + } + } else if (configtype == BASEBAND_CONFIG_AGC_TAB) { + len = RTL8192EE_AGC_TAB_ARRAY_LEN; + array = RTL8192EE_AGC_TAB_ARRAY; + + for (i = 0; i < len; i = i + 2) { + v1 = array[i]; + v2 = array[i+1]; + if (v1 < 0xCDCDCDCD) { + rtl_set_bbreg(hw, array[i], MASKDWORD, + array[i + 1]); + udelay(1); + continue; + } else{/*This line is the start line of branch.*/ + /* to protect READ_NEXT_PAIR not overrun */ + if (i >= len - 2) + break; + + if (!_check_condition(hw , array[i])) { + /*Discard the following pairs*/ + READ_NEXT_PAIR(v1, v2, i); + while (v2 != 0xDEAD && + v2 != 0xCDEF && + v2 != 0xCDCD && + i < len - 2) + READ_NEXT_PAIR(v1, v2, i); + i -= 2; /* prevent from for-loop += 2*/ + } else {/* Configure matched pairs and + * skip to end of if-else.*/ + READ_NEXT_PAIR(v1, v2, i); + while (v2 != 0xDEAD && + v2 != 0xCDEF && + v2 != 0xCDCD && + i < len - 2) { + rtl_set_bbreg(hw, + array[i], + MASKDWORD, + array[i + 1]); + udelay(1); + READ_NEXT_PAIR(v1 , v2 , i); + } + + while (v2 != 0xDEAD && + i < len - 2) + READ_NEXT_PAIR(v1 , v2 , i); + } + } + RT_TRACE(COMP_INIT, DBG_TRACE, + ("The agctab_array_table[0] is %x Rtl818EEPHY_REGArray[1] is %x\n", + array[i], + array[i + 1])); + } + } + return true; +} + +static u8 _rtl92ee_get_rate_section_index(u32 regaddr) +{ + u8 index = 0; + + switch (regaddr) { + case RTXAGC_A_RATE18_06: + index = 0; + break; + case RTXAGC_A_RATE54_24: + index = 1; + break; + case RTXAGC_A_CCK1_MCS32: + index = 2; + break; + case RTXAGC_B_CCK11_A_CCK2_11: + index = 3; + break; + case RTXAGC_A_MCS03_MCS00: + index = 4; + break; + case RTXAGC_A_MCS07_MCS04: + index = 5; + break; + case RTXAGC_A_MCS11_MCS08: + index = 6; + break; + case RTXAGC_A_MCS15_MCS12: + index = 7; + break; + case RTXAGC_B_RATE18_06: + index = 0; + break; + case RTXAGC_B_RATE54_24: + index = 1; + break; + case RTXAGC_B_CCK1_55_MCS32: + index = 2; + break; + case RTXAGC_B_MCS03_MCS00: + index = 4; + break; + case RTXAGC_B_MCS07_MCS04: + index = 5; + break; + case RTXAGC_B_MCS11_MCS08: + index = 6; + break; + case RTXAGC_B_MCS15_MCS12: + index = 7; + break; + default: + regaddr &= 0xFFF; + if (regaddr >= 0xC20 && regaddr <= 0xC4C) + index = (u8) ((regaddr - 0xC20) / 4); + else if (regaddr >= 0xE20 && regaddr <= 0xE4C) + index = (u8) ((regaddr - 0xE20) / 4); + break; + }; + return index; +} + +static void _rtl92ee_store_tx_power_by_rate(struct ieee80211_hw *hw, + enum band_type band, + enum radio_path rfpath, + u32 txnum, u32 regaddr, + u32 bitmask, u32 data) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + u8 section = _rtl92ee_get_rate_section_index(regaddr); + + if (band != BAND_ON_2_4G && band != BAND_ON_5G) { + RT_TRACE(FPHY, PHY_TXPWR, ("Invalid Band %d\n", band)); + return; + } + + if (rfpath > MAX_RF_PATH - 1) { + RT_TRACE(FPHY, PHY_TXPWR, ("Invalid RfPath %d\n", rfpath)); + return; + } + if (txnum > MAX_RF_PATH - 1) { + RT_TRACE(FPHY, PHY_TXPWR, ("Invalid TxNum %d\n", txnum)); + return; + } + + rtlphy->tx_power_by_rate_offset[band][rfpath][txnum][section] = data; +} + +static bool _rtl92ee_phy_config_bb_with_pgheaderfile(struct ieee80211_hw *hw, + u8 configtype) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + int i; + u32 *phy_regarray_table_pg; + u16 phy_regarray_pg_len; + u32 v1 = 0, v2 = 0, v3 = 0, v4 = 0, v5 = 0, v6 = 0; + + phy_regarray_pg_len = RTL8192EE_PHY_REG_ARRAY_PG_LEN; + phy_regarray_table_pg = RTL8192EE_PHY_REG_ARRAY_PG; + + if (configtype == BASEBAND_CONFIG_PHY_REG) { + for (i = 0; i < phy_regarray_pg_len; i = i + 6) { + v1 = phy_regarray_table_pg[i]; + v2 = phy_regarray_table_pg[i+1]; + v3 = phy_regarray_table_pg[i+2]; + v4 = phy_regarray_table_pg[i+3]; + v5 = phy_regarray_table_pg[i+4]; + v6 = phy_regarray_table_pg[i+5]; + + if (v1 < 0xcdcdcdcd) { + _rtl92ee_store_tx_power_by_rate(hw, v1, v2, v3, + v4, v5, v6); + continue; + } + } + } else { + RT_TRACE(COMP_SEND, DBG_TRACE, + ("configtype != BaseBand_Config_PHY_REG\n")); + } + return true; +} + +bool rtl92ee_phy_config_rf_with_headerfile(struct ieee80211_hw *hw, + enum radio_path rfpath) +{ + #define READ_NEXT_RF_PAIR(v1, v2, i) \ + do { \ + i += 2; \ + v1 = array[i]; \ + v2 = array[i+1]; \ + } while (0) + + int i; + u32 *array; + u16 len; + struct rtl_priv *rtlpriv = rtl_priv(hw); + u32 v1 = 0, v2 = 0; + + switch (rfpath) { + case RF90_PATH_A: + len = RTL8192EE_RADIOA_ARRAY_LEN; + array = RTL8192EE_RADIOA_ARRAY; + RT_TRACE(COMP_INIT, DBG_LOUD, + ("Radio_A:RTL8192EE_RADIOA_ARRAY %d\n" , len)); + RT_TRACE(COMP_INIT, DBG_LOUD, ("Radio No %x\n", rfpath)); + for (i = 0; i < len; i = i + 2) { + v1 = array[i]; + v2 = array[i+1]; + if (v1 < 0xcdcdcdcd) { + _rtl92ee_config_rf_radio_a(hw, v1, v2); + continue; + } else {/*This line is the start line of branch.*/ + /* to protect READ_NEXT_PAIR not overrun */ + if (i >= len - 2) + break; + + if (!_check_condition(hw , array[i])) { + /*Discard the following pairs*/ + READ_NEXT_RF_PAIR(v1, v2, i); + while (v2 != 0xDEAD && + v2 != 0xCDEF && + v2 != 0xCDCD && i < len - 2) + READ_NEXT_RF_PAIR(v1, v2, i); + i -= 2; /* prevent from for-loop += 2*/ + } else {/* Configure matched pairs and + * skip to end of if-else.*/ + READ_NEXT_RF_PAIR(v1, v2, i); + while (v2 != 0xDEAD && + v2 != 0xCDEF && + v2 != 0xCDCD && i < len - 2) { + _rtl92ee_config_rf_radio_a(hw, + v1, + v2); + READ_NEXT_RF_PAIR(v1, v2, i); + } + + while (v2 != 0xDEAD && i < len - 2) + READ_NEXT_RF_PAIR(v1, v2, i); + } + } + } + break; + + case RF90_PATH_B: + len = RTL8192EE_RADIOB_ARRAY_LEN; + array = RTL8192EE_RADIOB_ARRAY; + RT_TRACE(COMP_INIT, DBG_LOUD, + ("Radio_A:RTL8192EE_RADIOB_ARRAY %d\n" , len)); + RT_TRACE(COMP_INIT, DBG_LOUD, ("Radio No %x\n", rfpath)); + for (i = 0; i < len; i = i + 2) { + v1 = array[i]; + v2 = array[i+1]; + if (v1 < 0xcdcdcdcd) { + _rtl92ee_config_rf_radio_b(hw, v1, v2); + continue; + } else {/*This line is the start line of branch.*/ + /* to protect READ_NEXT_PAIR not overrun */ + if (i >= len - 2) + break; + + if (!_check_condition(hw , array[i])) { + /*Discard the following pairs*/ + READ_NEXT_RF_PAIR(v1, v2, i); + while (v2 != 0xDEAD && + v2 != 0xCDEF && + v2 != 0xCDCD && i < len - 2) + READ_NEXT_RF_PAIR(v1, v2, i); + i -= 2; /* prevent from for-loop += 2*/ + } else {/* Configure matched pairs and + * skip to end of if-else.*/ + READ_NEXT_RF_PAIR(v1, v2, i); + while (v2 != 0xDEAD && + v2 != 0xCDEF && + v2 != 0xCDCD && i < len - 2) { + _rtl92ee_config_rf_radio_b(hw, + v1, + v2); + READ_NEXT_RF_PAIR(v1, v2, i); + } + + while (v2 != 0xDEAD && i < len - 2) + READ_NEXT_RF_PAIR(v1, v2, i); + } + } + } + break; + case RF90_PATH_C: + RT_TRACE(COMP_ERR, DBG_EMERG, + ("switch case not process\n")); + break; + case RF90_PATH_D: + RT_TRACE(COMP_ERR, DBG_EMERG, + ("switch case not process\n")); + break; + } + return true; +} + +void rtl92ee_phy_get_hw_reg_originalvalue(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + + rtlphy->default_initialgain[0] = + (u8) rtl_get_bbreg(hw, ROFDM0_XAAGCCORE1, MASKBYTE0); + rtlphy->default_initialgain[1] = + (u8) rtl_get_bbreg(hw, ROFDM0_XBAGCCORE1, MASKBYTE0); + rtlphy->default_initialgain[2] = + (u8) rtl_get_bbreg(hw, ROFDM0_XCAGCCORE1, MASKBYTE0); + rtlphy->default_initialgain[3] = + (u8) rtl_get_bbreg(hw, ROFDM0_XDAGCCORE1, MASKBYTE0); + + RT_TRACE(COMP_INIT, DBG_TRACE, + ("Default initial gain (c50 = 0x%x, c58 = 0x%x, c60 = 0x%x, c68 = 0x%x\n", + rtlphy->default_initialgain[0], + rtlphy->default_initialgain[1], + rtlphy->default_initialgain[2], + rtlphy->default_initialgain[3])); + + rtlphy->framesync = (u8) rtl_get_bbreg(hw, + ROFDM0_RXDETECTOR3, MASKBYTE0); + rtlphy->framesync_c34 = rtl_get_bbreg(hw, + ROFDM0_RXDETECTOR2, MASKDWORD); + + RT_TRACE(COMP_INIT, DBG_TRACE, + ("Default framesync (0x%x) = 0x%x\n", + ROFDM0_RXDETECTOR3, rtlphy->framesync)); +} + +static void _rtl92ee_phy_init_bb_rf_register_definition(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + + rtlphy->phyreg_def[RF90_PATH_A].rfintfs = RFPGA0_XAB_RFINTERFACESW; + rtlphy->phyreg_def[RF90_PATH_B].rfintfs = RFPGA0_XAB_RFINTERFACESW; + + rtlphy->phyreg_def[RF90_PATH_A].rfintfo = RFPGA0_XA_RFINTERFACEOE; + rtlphy->phyreg_def[RF90_PATH_B].rfintfo = RFPGA0_XB_RFINTERFACEOE; + + rtlphy->phyreg_def[RF90_PATH_A].rfintfe = RFPGA0_XA_RFINTERFACEOE; + rtlphy->phyreg_def[RF90_PATH_B].rfintfe = RFPGA0_XB_RFINTERFACEOE; + + rtlphy->phyreg_def[RF90_PATH_A].rf3wire_offset = + RFPGA0_XA_LSSIPARAMETER; + rtlphy->phyreg_def[RF90_PATH_B].rf3wire_offset = + RFPGA0_XB_LSSIPARAMETER; + + rtlphy->phyreg_def[RF90_PATH_A].rfhssi_para2 = RFPGA0_XA_HSSIPARAMETER2; + rtlphy->phyreg_def[RF90_PATH_B].rfhssi_para2 = RFPGA0_XB_HSSIPARAMETER2; + + rtlphy->phyreg_def[RF90_PATH_A].rflssi_readback = + RFPGA0_XA_LSSIREADBACK; + rtlphy->phyreg_def[RF90_PATH_B].rflssi_readback = + RFPGA0_XB_LSSIREADBACK; + + rtlphy->phyreg_def[RF90_PATH_A].rflssi_readbackpi = + TRANSCEIVEA_HSPI_READBACK; + rtlphy->phyreg_def[RF90_PATH_B].rflssi_readbackpi = + TRANSCEIVEB_HSPI_READBACK; +} + +void rtl92ee_phy_get_txpower_level(struct ieee80211_hw *hw, long *powerlevel) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + u8 txpwr_level; + long txpwr_dbm; + + txpwr_level = rtlphy->cur_cck_txpwridx; + txpwr_dbm = _rtl92ee_phy_txpwr_idx_to_dbm(hw, WIRELESS_MODE_B, + txpwr_level); + txpwr_level = rtlphy->cur_ofdm24g_txpwridx; + if (_rtl92ee_phy_txpwr_idx_to_dbm(hw, WIRELESS_MODE_G, txpwr_level) > + txpwr_dbm) + txpwr_dbm = _rtl92ee_phy_txpwr_idx_to_dbm(hw, WIRELESS_MODE_G, + txpwr_level); + txpwr_level = rtlphy->cur_ofdm24g_txpwridx; + if (_rtl92ee_phy_txpwr_idx_to_dbm(hw, WIRELESS_MODE_N_24G, + txpwr_level) > txpwr_dbm) + txpwr_dbm = _rtl92ee_phy_txpwr_idx_to_dbm(hw, + WIRELESS_MODE_N_24G, + txpwr_level); + *powerlevel = txpwr_dbm; +} + +static u8 _rtl92ee_phy_get_ratesection_intxpower_byrate(enum radio_path path, + u8 rate) +{ + u8 rate_section = 0; + + switch (rate) { + case DESC92C_RATE1M: + rate_section = 2; + break; + + case DESC92C_RATE2M: + case DESC92C_RATE5_5M: + if (path == RF90_PATH_A) + rate_section = 3; + else if (path == RF90_PATH_B) + rate_section = 2; + break; + + case DESC92C_RATE11M: + rate_section = 3; + break; + + case DESC92C_RATE6M: + case DESC92C_RATE9M: + case DESC92C_RATE12M: + case DESC92C_RATE18M: + rate_section = 0; + break; + + case DESC92C_RATE24M: + case DESC92C_RATE36M: + case DESC92C_RATE48M: + case DESC92C_RATE54M: + rate_section = 1; + break; + + case DESC92C_RATEMCS0: + case DESC92C_RATEMCS1: + case DESC92C_RATEMCS2: + case DESC92C_RATEMCS3: + rate_section = 4; + break; + + case DESC92C_RATEMCS4: + case DESC92C_RATEMCS5: + case DESC92C_RATEMCS6: + case DESC92C_RATEMCS7: + rate_section = 5; + break; + + case DESC92C_RATEMCS8: + case DESC92C_RATEMCS9: + case DESC92C_RATEMCS10: + case DESC92C_RATEMCS11: + rate_section = 6; + break; + + case DESC92C_RATEMCS12: + case DESC92C_RATEMCS13: + case DESC92C_RATEMCS14: + case DESC92C_RATEMCS15: + rate_section = 7; + break; + + default: + RT_ASSERT(true, ("Rate_Section is Illegal\n")); + break; + } + + return rate_section; +} + +static u8 _rtl92ee_get_txpower_by_rate(struct ieee80211_hw *hw, + enum band_type band, + enum radio_path rf, u8 rate) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + u8 shift = 0, sec, tx_num; + char diff = 0; + + sec = _rtl92ee_phy_get_ratesection_intxpower_byrate(rf, rate); + tx_num = RF_TX_NUM_NONIMPLEMENT; + + if (tx_num == RF_TX_NUM_NONIMPLEMENT) { + if ((rate >= DESC92C_RATEMCS8 && rate <= DESC92C_RATEMCS15)) + tx_num = RF_2TX; + else + tx_num = RF_1TX; + } + + switch (rate) { + case DESC92C_RATE1M: + shift = 0; + break; + case DESC92C_RATE2M: + shift = 8; + break; + case DESC92C_RATE5_5M: + shift = 16; + break; + case DESC92C_RATE11M: + shift = 24; + break; + + case DESC92C_RATE6M: + shift = 0; + break; + case DESC92C_RATE9M: + shift = 8; + break; + case DESC92C_RATE12M: + shift = 16; + break; + case DESC92C_RATE18M: + shift = 24; + break; + + case DESC92C_RATE24M: + shift = 0; + break; + case DESC92C_RATE36M: + shift = 8; + break; + case DESC92C_RATE48M: + shift = 16; + break; + case DESC92C_RATE54M: + shift = 24; + break; + + case DESC92C_RATEMCS0: + shift = 0; + break; + case DESC92C_RATEMCS1: + shift = 8; + break; + case DESC92C_RATEMCS2: + shift = 16; + break; + case DESC92C_RATEMCS3: + shift = 24; + break; + + case DESC92C_RATEMCS4: + shift = 0; + break; + case DESC92C_RATEMCS5: + shift = 8; + break; + case DESC92C_RATEMCS6: + shift = 16; + break; + case DESC92C_RATEMCS7: + shift = 24; + break; + + case DESC92C_RATEMCS8: + shift = 0; + break; + case DESC92C_RATEMCS9: + shift = 8; + break; + case DESC92C_RATEMCS10: + shift = 16; + break; + case DESC92C_RATEMCS11: + shift = 24; + break; + + case DESC92C_RATEMCS12: + shift = 0; + break; + case DESC92C_RATEMCS13: + shift = 8; + break; + case DESC92C_RATEMCS14: + shift = 16; + break; + case DESC92C_RATEMCS15: + shift = 24; + break; + + default: + RT_ASSERT(true, ("Rate_Section is Illegal\n")); + break; + } + + diff = (u8) (rtlphy->tx_power_by_rate_offset[band][rf][tx_num][sec] >> + shift) & 0xff; + + return diff; +} + +static u8 _rtl92ee_get_txpower_index(struct ieee80211_hw *hw, + enum radio_path rfpath, u8 rate, + u8 bw, u8 channel) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_efuse *rtlefuse = rtl_efuse(rtlpriv); + u8 index = (channel - 1); + u8 tx_power = 0; + u8 diff = 0; + + if (channel < 1 || channel > 14) { + index = 0; + RT_TRACE(COMP_POWER_TRACKING, DBG_DMESG, + ("Illegal channel!!\n")); + } + + if (IS_CCK_RATE(rate)) + tx_power = rtlefuse->txpwrlevel_cck[rfpath][index]; + else if (DESC92C_RATE6M <= rate) + tx_power = rtlefuse->txpwrlevel_ht40_1s[rfpath][index]; + + /* OFDM-1T*/ + if (DESC92C_RATE6M <= rate && rate <= DESC92C_RATE54M && + !IS_CCK_RATE(rate)) + tx_power += rtlefuse->txpwr_legacyhtdiff[rfpath][TX_1S]; + + /* BW20-1S, BW20-2S */ + if (bw == HT_CHANNEL_WIDTH_20) { + if (DESC92C_RATEMCS0 <= rate && rate <= DESC92C_RATEMCS15) + tx_power += rtlefuse->txpwr_ht20diff[rfpath][TX_1S]; + if (DESC92C_RATEMCS8 <= rate && rate <= DESC92C_RATEMCS15) + tx_power += rtlefuse->txpwr_ht20diff[rfpath][TX_2S]; + } else if (bw == HT_CHANNEL_WIDTH_20_40) {/* BW40-1S, BW40-2S */ + if (DESC92C_RATEMCS0 <= rate && rate <= DESC92C_RATEMCS15) + tx_power += rtlefuse->txpwr_ht40diff[rfpath][TX_1S]; + if (DESC92C_RATEMCS8 <= rate && rate <= DESC92C_RATEMCS15) + tx_power += rtlefuse->txpwr_ht40diff[rfpath][TX_2S]; + } + + if (rtlefuse->eeprom_regulatory != 2) + diff = _rtl92ee_get_txpower_by_rate(hw, BAND_ON_2_4G, + rfpath, rate); + + tx_power += diff; + + if (tx_power > MAX_POWER_INDEX) + tx_power = MAX_POWER_INDEX; + + return tx_power; +} + +static void _rtl92ee_set_txpower_index(struct ieee80211_hw *hw, u8 pwr_idx, + enum radio_path rfpath, u8 rate) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + if (rfpath == RF90_PATH_A) { + switch (rate) { + case DESC92C_RATE1M: + rtl_set_bbreg(hw, RTXAGC_A_CCK1_MCS32, + MASKBYTE1, pwr_idx); + break; + case DESC92C_RATE2M: + rtl_set_bbreg(hw, RTXAGC_B_CCK11_A_CCK2_11, + MASKBYTE1, pwr_idx); + break; + case DESC92C_RATE5_5M: + rtl_set_bbreg(hw, RTXAGC_B_CCK11_A_CCK2_11, + MASKBYTE2, pwr_idx); + break; + case DESC92C_RATE11M: + rtl_set_bbreg(hw, RTXAGC_B_CCK11_A_CCK2_11, + MASKBYTE3, pwr_idx); + break; + case DESC92C_RATE6M: + rtl_set_bbreg(hw, RTXAGC_A_RATE18_06, + MASKBYTE0, pwr_idx); + break; + case DESC92C_RATE9M: + rtl_set_bbreg(hw, RTXAGC_A_RATE18_06, + MASKBYTE1, pwr_idx); + break; + case DESC92C_RATE12M: + rtl_set_bbreg(hw, RTXAGC_A_RATE18_06, + MASKBYTE2, pwr_idx); + break; + case DESC92C_RATE18M: + rtl_set_bbreg(hw, RTXAGC_A_RATE18_06, + MASKBYTE3, pwr_idx); + break; + case DESC92C_RATE24M: + rtl_set_bbreg(hw, RTXAGC_A_RATE54_24, + MASKBYTE0, pwr_idx); + break; + case DESC92C_RATE36M: + rtl_set_bbreg(hw, RTXAGC_A_RATE54_24, + MASKBYTE1, pwr_idx); + break; + case DESC92C_RATE48M: + rtl_set_bbreg(hw, RTXAGC_A_RATE54_24, + MASKBYTE2, pwr_idx); + break; + case DESC92C_RATE54M: + rtl_set_bbreg(hw, RTXAGC_A_RATE54_24, + MASKBYTE3, pwr_idx); + break; + case DESC92C_RATEMCS0: + rtl_set_bbreg(hw, RTXAGC_A_MCS03_MCS00, + MASKBYTE0, pwr_idx); + break; + case DESC92C_RATEMCS1: + rtl_set_bbreg(hw, RTXAGC_A_MCS03_MCS00, + MASKBYTE1, pwr_idx); + break; + case DESC92C_RATEMCS2: + rtl_set_bbreg(hw, RTXAGC_A_MCS03_MCS00, + MASKBYTE2, pwr_idx); + break; + case DESC92C_RATEMCS3: + rtl_set_bbreg(hw, RTXAGC_A_MCS03_MCS00, + MASKBYTE3, pwr_idx); + break; + case DESC92C_RATEMCS4: + rtl_set_bbreg(hw, RTXAGC_A_MCS07_MCS04, + MASKBYTE0, pwr_idx); + break; + case DESC92C_RATEMCS5: + rtl_set_bbreg(hw, RTXAGC_A_MCS07_MCS04, + MASKBYTE1, pwr_idx); + break; + case DESC92C_RATEMCS6: + rtl_set_bbreg(hw, RTXAGC_A_MCS07_MCS04, + MASKBYTE2, pwr_idx); + break; + case DESC92C_RATEMCS7: + rtl_set_bbreg(hw, RTXAGC_A_MCS07_MCS04, + MASKBYTE3, pwr_idx); + break; + case DESC92C_RATEMCS8: + rtl_set_bbreg(hw, RTXAGC_A_MCS11_MCS08, + MASKBYTE0, pwr_idx); + break; + case DESC92C_RATEMCS9: + rtl_set_bbreg(hw, RTXAGC_A_MCS11_MCS08, + MASKBYTE1, pwr_idx); + break; + case DESC92C_RATEMCS10: + rtl_set_bbreg(hw, RTXAGC_A_MCS11_MCS08, + MASKBYTE2, pwr_idx); + break; + case DESC92C_RATEMCS11: + rtl_set_bbreg(hw, RTXAGC_A_MCS11_MCS08, + MASKBYTE3, pwr_idx); + break; + case DESC92C_RATEMCS12: + rtl_set_bbreg(hw, RTXAGC_A_MCS15_MCS12, + MASKBYTE0, pwr_idx); + break; + case DESC92C_RATEMCS13: + rtl_set_bbreg(hw, RTXAGC_A_MCS15_MCS12, + MASKBYTE1, pwr_idx); + break; + case DESC92C_RATEMCS14: + rtl_set_bbreg(hw, RTXAGC_A_MCS15_MCS12, + MASKBYTE2, pwr_idx); + break; + case DESC92C_RATEMCS15: + rtl_set_bbreg(hw, RTXAGC_A_MCS15_MCS12, + MASKBYTE3, pwr_idx); + break; + default: + RT_TRACE(COMP_POWER, DBG_LOUD, ("Invalid Rate!!\n")); + break; + } + } else if (rfpath == RF90_PATH_B) { + switch (rate) { + case DESC92C_RATE1M: + rtl_set_bbreg(hw, RTXAGC_B_CCK1_55_MCS32, + MASKBYTE1, pwr_idx); + break; + case DESC92C_RATE2M: + rtl_set_bbreg(hw, RTXAGC_B_CCK1_55_MCS32, + MASKBYTE2, pwr_idx); + break; + case DESC92C_RATE5_5M: + rtl_set_bbreg(hw, RTXAGC_B_CCK1_55_MCS32, + MASKBYTE3, pwr_idx); + break; + case DESC92C_RATE11M: + rtl_set_bbreg(hw, RTXAGC_B_CCK11_A_CCK2_11, + MASKBYTE0, pwr_idx); + break; + case DESC92C_RATE6M: + rtl_set_bbreg(hw, RTXAGC_B_RATE18_06, + MASKBYTE0, pwr_idx); + break; + case DESC92C_RATE9M: + rtl_set_bbreg(hw, RTXAGC_B_RATE18_06, + MASKBYTE1, pwr_idx); + break; + case DESC92C_RATE12M: + rtl_set_bbreg(hw, RTXAGC_B_RATE18_06, + MASKBYTE2, pwr_idx); + break; + case DESC92C_RATE18M: + rtl_set_bbreg(hw, RTXAGC_B_RATE18_06, + MASKBYTE3, pwr_idx); + break; + case DESC92C_RATE24M: + rtl_set_bbreg(hw, RTXAGC_B_RATE54_24, + MASKBYTE0, pwr_idx); + break; + case DESC92C_RATE36M: + rtl_set_bbreg(hw, RTXAGC_B_RATE54_24, + MASKBYTE1, pwr_idx); + break; + case DESC92C_RATE48M: + rtl_set_bbreg(hw, RTXAGC_B_RATE54_24, + MASKBYTE2, pwr_idx); + break; + case DESC92C_RATE54M: + rtl_set_bbreg(hw, RTXAGC_B_RATE54_24, + MASKBYTE3, pwr_idx); + break; + case DESC92C_RATEMCS0: + rtl_set_bbreg(hw, RTXAGC_B_MCS03_MCS00, + MASKBYTE0, pwr_idx); + break; + case DESC92C_RATEMCS1: + rtl_set_bbreg(hw, RTXAGC_B_MCS03_MCS00, + MASKBYTE1, pwr_idx); + break; + case DESC92C_RATEMCS2: + rtl_set_bbreg(hw, RTXAGC_B_MCS03_MCS00, + MASKBYTE2, pwr_idx); + break; + case DESC92C_RATEMCS3: + rtl_set_bbreg(hw, RTXAGC_B_MCS03_MCS00, + MASKBYTE3, pwr_idx); + break; + case DESC92C_RATEMCS4: + rtl_set_bbreg(hw, RTXAGC_B_MCS07_MCS04, + MASKBYTE0, pwr_idx); + break; + case DESC92C_RATEMCS5: + rtl_set_bbreg(hw, RTXAGC_B_MCS07_MCS04, + MASKBYTE1, pwr_idx); + break; + case DESC92C_RATEMCS6: + rtl_set_bbreg(hw, RTXAGC_B_MCS07_MCS04, + MASKBYTE2, pwr_idx); + break; + case DESC92C_RATEMCS7: + rtl_set_bbreg(hw, RTXAGC_B_MCS07_MCS04, + MASKBYTE3, pwr_idx); + break; + case DESC92C_RATEMCS8: + rtl_set_bbreg(hw, RTXAGC_B_MCS11_MCS08, + MASKBYTE0, pwr_idx); + break; + case DESC92C_RATEMCS9: + rtl_set_bbreg(hw, RTXAGC_B_MCS11_MCS08, + MASKBYTE1, pwr_idx); + break; + case DESC92C_RATEMCS10: + rtl_set_bbreg(hw, RTXAGC_B_MCS11_MCS08, + MASKBYTE2, pwr_idx); + break; + case DESC92C_RATEMCS11: + rtl_set_bbreg(hw, RTXAGC_B_MCS11_MCS08, + MASKBYTE3, pwr_idx); + break; + case DESC92C_RATEMCS12: + rtl_set_bbreg(hw, RTXAGC_B_MCS15_MCS12, + MASKBYTE0, pwr_idx); + break; + case DESC92C_RATEMCS13: + rtl_set_bbreg(hw, RTXAGC_B_MCS15_MCS12, + MASKBYTE1, pwr_idx); + break; + case DESC92C_RATEMCS14: + rtl_set_bbreg(hw, RTXAGC_B_MCS15_MCS12, + MASKBYTE2, pwr_idx); + break; + case DESC92C_RATEMCS15: + rtl_set_bbreg(hw, RTXAGC_B_MCS15_MCS12, + MASKBYTE3, pwr_idx); + break; + default: + RT_TRACE(COMP_POWER, DBG_LOUD, ("Invalid Rate!!\n")); + break; + } + } else { + RT_TRACE(COMP_POWER, DBG_LOUD, ("Invalid RFPath!!\n")); + } +} + +static void rtl92ee_phy_set_txpower_index_by_rate_array(struct ieee80211_hw *hw, + enum radio_path rfpath, u8 bw, + u8 channel, u8 *rates, u8 size) +{ + u8 i; + u8 power_index; + for (i = 0; i < size; i++) { + power_index = _rtl92ee_get_txpower_index(hw, rfpath, rates[i], + bw, channel); + _rtl92ee_set_txpower_index(hw, power_index, rfpath, rates[i]); + } +} + +static void rtl92ee_phy_set_txpower_index_by_rate_section(struct ieee80211_hw *hw, + enum radio_path rfpath, + u8 channel, + enum rate_section section) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtlpriv); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + + if (section == CCK) { + u8 cck_rates[] = {DESC92C_RATE1M, DESC92C_RATE2M, + DESC92C_RATE5_5M, DESC92C_RATE11M}; + if (rtlhal->current_bandtype == BAND_ON_2_4G) + rtl92ee_phy_set_txpower_index_by_rate_array(hw, rfpath, + rtlphy->current_chan_bw, + channel, cck_rates, 4); + } else if (section == OFDM) { + u8 ofdm_rates[] = {DESC92C_RATE6M, DESC92C_RATE9M, + DESC92C_RATE12M, DESC92C_RATE18M, + DESC92C_RATE24M, DESC92C_RATE36M, + DESC92C_RATE48M, DESC92C_RATE54M}; + rtl92ee_phy_set_txpower_index_by_rate_array(hw, rfpath, + rtlphy->current_chan_bw, + channel, ofdm_rates, 8); + } else if (section == HT_MCS0_MCS7) { + u8 ht_rates1t[] = {DESC92C_RATEMCS0, DESC92C_RATEMCS1, + DESC92C_RATEMCS2, DESC92C_RATEMCS3, + DESC92C_RATEMCS4, DESC92C_RATEMCS5, + DESC92C_RATEMCS6, DESC92C_RATEMCS7}; + rtl92ee_phy_set_txpower_index_by_rate_array(hw, rfpath, + rtlphy->current_chan_bw, + channel, ht_rates1t, 8); + } else if (section == HT_MCS8_MCS15) { + u8 ht_rates2t[] = {DESC92C_RATEMCS8, DESC92C_RATEMCS9, + DESC92C_RATEMCS10, DESC92C_RATEMCS11, + DESC92C_RATEMCS12, DESC92C_RATEMCS13, + DESC92C_RATEMCS14, DESC92C_RATEMCS15}; + rtl92ee_phy_set_txpower_index_by_rate_array(hw, rfpath, + rtlphy->current_chan_bw, + channel, ht_rates2t, 8); + } else + RT_TRACE(FPHY, PHY_TXPWR, + ("Invalid RateSection %d\n", section)); +} + +void rtl92ee_phy_set_txpower_level(struct ieee80211_hw *hw, u8 channel) +{ + struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); + struct rtl_phy *rtlphy = &(rtl_priv(hw)->phy); + enum radio_path rfpath; + + if (rtlefuse->b_txpwr_fromeprom == false) + return; + for (rfpath = RF90_PATH_A; rfpath < rtlphy->num_total_rfpath; + rfpath++) { + rtl92ee_phy_set_txpower_index_by_rate_section(hw, rfpath, + channel, CCK); + rtl92ee_phy_set_txpower_index_by_rate_section(hw, rfpath, + channel, OFDM); + rtl92ee_phy_set_txpower_index_by_rate_section(hw, rfpath, + channel, + HT_MCS0_MCS7); + if (rtlphy->num_total_rfpath >= 2) + rtl92ee_phy_set_txpower_index_by_rate_section(hw, + rfpath, channel, + HT_MCS8_MCS15); + } +} + +static long _rtl92ee_phy_txpwr_idx_to_dbm(struct ieee80211_hw *hw, + enum wireless_mode wirelessmode, + u8 txpwridx) +{ + long offset; + long pwrout_dbm; + + switch (wirelessmode) { + case WIRELESS_MODE_B: + offset = -7; + break; + case WIRELESS_MODE_G: + case WIRELESS_MODE_N_24G: + offset = -8; + break; + default: + offset = -8; + break; + } + pwrout_dbm = txpwridx / 2 + offset; + return pwrout_dbm; +} + +void rtl92ee_phy_scan_operation_backup(struct ieee80211_hw *hw, u8 operation) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + enum io_type iotype; + + if (!is_hal_stop(rtlhal)) { + switch (operation) { + case SCAN_OPT_BACKUP_BAND0: + iotype = IO_CMD_PAUSE_BAND0_DM_BY_SCAN; + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_IO_CMD, + (u8 *)&iotype); + + break; + case SCAN_OPT_RESTORE: + iotype = IO_CMD_RESUME_DM_BY_SCAN; + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_IO_CMD, + (u8 *)&iotype); + break; + default: + RT_TRACE(COMP_ERR, DBG_EMERG, + ("Unknown Scan Backup operation.\n")); + break; + } + } +} + +void rtl92ee_phy_set_bw_mode_callback(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + u8 reg_bw_opmode; + u8 reg_prsr_rsc; + + RT_TRACE(COMP_SCAN, DBG_TRACE, + ("Switch to %s bandwidth\n", + rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20 ? + "20MHz" : "40MHz")); + + if (is_hal_stop(rtlhal)) { + rtlphy->set_bwmode_inprogress = false; + return; + } + + reg_bw_opmode = rtl_read_byte(rtlpriv, REG_BWOPMODE); + reg_prsr_rsc = rtl_read_byte(rtlpriv, REG_RRSR + 2); + + switch (rtlphy->current_chan_bw) { + case HT_CHANNEL_WIDTH_20: + reg_bw_opmode |= BW_OPMODE_20MHZ; + rtl_write_byte(rtlpriv, REG_BWOPMODE, reg_bw_opmode); + break; + case HT_CHANNEL_WIDTH_20_40: + reg_bw_opmode &= ~BW_OPMODE_20MHZ; + rtl_write_byte(rtlpriv, REG_BWOPMODE, reg_bw_opmode); + reg_prsr_rsc = (reg_prsr_rsc & 0x90) | + (mac->cur_40_prime_sc << 5); + rtl_write_byte(rtlpriv, REG_RRSR + 2, reg_prsr_rsc); + break; + default: + RT_TRACE(COMP_ERR, DBG_EMERG, + ("unknown bandwidth: %#X\n", rtlphy->current_chan_bw)); + break; + } + + switch (rtlphy->current_chan_bw) { + case HT_CHANNEL_WIDTH_20: + rtl_set_bbreg(hw, RFPGA0_RFMOD, BRFMOD, 0x0); + rtl_set_bbreg(hw, RFPGA1_RFMOD, BRFMOD, 0x0); + rtl_set_bbreg(hw, ROFDM0_TXPSEUDONOISEWGT, + (BIT(31) | BIT(30)), 0); + break; + case HT_CHANNEL_WIDTH_20_40: + rtl_set_bbreg(hw, RFPGA0_RFMOD, BRFMOD, 0x1); + rtl_set_bbreg(hw, RFPGA1_RFMOD, BRFMOD, 0x1); + rtl_set_bbreg(hw, RCCK0_SYSTEM, BCCK_SIDEBAND, + (mac->cur_40_prime_sc >> 1)); + rtl_set_bbreg(hw, ROFDM1_LSTF, 0xC00, + mac->cur_40_prime_sc); + + rtl_set_bbreg(hw, 0x818, (BIT(26) | BIT(27)), + (mac->cur_40_prime_sc == + HAL_PRIME_CHNL_OFFSET_LOWER) ? 2 : 1); + break; + default: + RT_TRACE(COMP_ERR, DBG_EMERG, + ("unknown bandwidth: %#X\n", rtlphy->current_chan_bw)); + break; + } + rtl92ee_phy_rf6052_set_bandwidth(hw, rtlphy->current_chan_bw); + rtlphy->set_bwmode_inprogress = false; + RT_TRACE(COMP_SCAN, DBG_LOUD, ("\n")); +} + +void rtl92ee_phy_set_bw_mode(struct ieee80211_hw *hw, + enum nl80211_channel_type ch_type) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + u8 tmp_bw = rtlphy->current_chan_bw; + + if (rtlphy->set_bwmode_inprogress) + return; + rtlphy->set_bwmode_inprogress = true; + if ((!is_hal_stop(rtlhal)) && !(RT_CANNOT_IO(hw))) { + rtl92ee_phy_set_bw_mode_callback(hw); + } else { + RT_TRACE(COMP_ERR, DBG_WARNING, + ("false driver sleep or unload\n")); + rtlphy->set_bwmode_inprogress = false; + rtlphy->current_chan_bw = tmp_bw; + } +} + +void rtl92ee_phy_sw_chnl_callback(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + u32 delay; + + RT_TRACE(COMP_SCAN, DBG_TRACE, + ("switch to channel%d\n", rtlphy->current_channel)); + if (is_hal_stop(rtlhal)) + return; + do { + if (!rtlphy->sw_chnl_inprogress) + break; + if (!_rtl92ee_phy_sw_chnl_step_by_step + (hw, rtlphy->current_channel, &rtlphy->sw_chnl_stage, + &rtlphy->sw_chnl_step, &delay)) { + if (delay > 0) + mdelay(delay); + else + continue; + } else { + rtlphy->sw_chnl_inprogress = false; + } + break; + } while (true); + RT_TRACE(COMP_SCAN, DBG_TRACE, ("\n")); +} + +u8 rtl92ee_phy_sw_chnl(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + + if (rtlphy->sw_chnl_inprogress) + return 0; + if (rtlphy->set_bwmode_inprogress) + return 0; + RT_ASSERT((rtlphy->current_channel <= 14), + ("WIRELESS_MODE_G but channel>14")); + rtlphy->sw_chnl_inprogress = true; + rtlphy->sw_chnl_stage = 0; + rtlphy->sw_chnl_step = 0; + if (!(is_hal_stop(rtlhal)) && !(RT_CANNOT_IO(hw))) { + rtl92ee_phy_sw_chnl_callback(hw); + RT_TRACE(COMP_CHAN, DBG_LOUD, + ("sw_chnl_inprogress false schdule workitem current channel %d\n", + rtlphy->current_channel)); + rtlphy->sw_chnl_inprogress = false; + } else { + RT_TRACE(COMP_CHAN, DBG_LOUD, + ("sw_chnl_inprogress false driver sleep or unload\n")); + rtlphy->sw_chnl_inprogress = false; + } + return 1; +} + +static bool _rtl92ee_phy_sw_chnl_step_by_step(struct ieee80211_hw *hw, + u8 channel, u8 *stage, u8 *step, + u32 *delay) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + struct swchnlcmd precommoncmd[MAX_PRECMD_CNT]; + u32 precommoncmdcnt; + struct swchnlcmd postcommoncmd[MAX_POSTCMD_CNT]; + u32 postcommoncmdcnt; + struct swchnlcmd rfdependcmd[MAX_RFDEPENDCMD_CNT]; + u32 rfdependcmdcnt; + struct swchnlcmd *currentcmd = NULL; + u8 rfpath; + u8 num_total_rfpath = rtlphy->num_total_rfpath; + + precommoncmdcnt = 0; + _rtl92ee_phy_set_sw_chnl_cmdarray(precommoncmd, precommoncmdcnt++, + MAX_PRECMD_CNT, + CMDID_SET_TXPOWEROWER_LEVEL, 0, 0, 0); + _rtl92ee_phy_set_sw_chnl_cmdarray(precommoncmd, precommoncmdcnt++, + MAX_PRECMD_CNT, CMDID_END, 0, 0, 0); + + postcommoncmdcnt = 0; + + _rtl92ee_phy_set_sw_chnl_cmdarray(postcommoncmd, postcommoncmdcnt++, + MAX_POSTCMD_CNT, CMDID_END, 0, 0, 0); + + rfdependcmdcnt = 0; + + RT_ASSERT((channel >= 1 && channel <= 14), + ("illegal channel for Zebra: %d\n", channel)); + + _rtl92ee_phy_set_sw_chnl_cmdarray(rfdependcmd, rfdependcmdcnt++, + MAX_RFDEPENDCMD_CNT, + CMDID_RF_WRITEREG, + RF_CHNLBW, channel, 10); + + _rtl92ee_phy_set_sw_chnl_cmdarray(rfdependcmd, rfdependcmdcnt++, + MAX_RFDEPENDCMD_CNT, CMDID_END, + 0, 0, 0); + + do { + switch (*stage) { + case 0: + currentcmd = &precommoncmd[*step]; + break; + case 1: + currentcmd = &rfdependcmd[*step]; + break; + case 2: + currentcmd = &postcommoncmd[*step]; + break; + default: + RT_TRACE(COMP_ERR, DBG_EMERG, + ("Invalid 'stage' = %d, Check it!\n" , + *stage)); + return true; + break; + } + + if (currentcmd->cmdid == CMDID_END) { + if ((*stage) == 2) { + return true; + } else { + (*stage)++; + (*step) = 0; + continue; + } + } + + switch (currentcmd->cmdid) { + case CMDID_SET_TXPOWEROWER_LEVEL: + rtl92ee_phy_set_txpower_level(hw, channel); + break; + case CMDID_WRITEPORT_ULONG: + rtl_write_dword(rtlpriv, currentcmd->para1, + currentcmd->para2); + break; + case CMDID_WRITEPORT_USHORT: + rtl_write_word(rtlpriv, currentcmd->para1, + (u16) currentcmd->para2); + break; + case CMDID_WRITEPORT_UCHAR: + rtl_write_byte(rtlpriv, currentcmd->para1, + (u8) currentcmd->para2); + break; + case CMDID_RF_WRITEREG: + for (rfpath = 0; rfpath < num_total_rfpath; rfpath++) { + rtlphy->rfreg_chnlval[rfpath] = + ((rtlphy->rfreg_chnlval[rfpath] & + 0xfffff00) | currentcmd->para2); + + rtl_set_rfreg(hw, (enum radio_path)rfpath, + currentcmd->para1, + 0x3ff, + rtlphy->rfreg_chnlval[rfpath]); + } + break; + default: + RT_TRACE(COMP_ERR, DBG_EMERG, + ("switch case not process\n")); + break; + } + + break; + } while (true); + + (*delay) = currentcmd->msdelay; + (*step)++; + return false; +} + +static bool _rtl92ee_phy_set_sw_chnl_cmdarray(struct swchnlcmd *cmdtable, + u32 cmdtableidx, u32 cmdtablesz, + enum swchnlcmd_id cmdid, + u32 para1, u32 para2, u32 msdelay) +{ + struct swchnlcmd *pcmd; + + if (cmdtable == NULL) { + RT_ASSERT(false, ("cmdtable cannot be NULL.\n")); + return false; + } + + if (cmdtableidx >= cmdtablesz) + return false; + + pcmd = cmdtable + cmdtableidx; + pcmd->cmdid = cmdid; + pcmd->para1 = para1; + pcmd->para2 = para2; + pcmd->msdelay = msdelay; + return true; +} + +static u8 _rtl92ee_phy_path_a_iqk(struct ieee80211_hw *hw, bool config_pathb) +{ + u32 reg_eac, reg_e94, reg_e9c; + u8 result = 0x00; + /* path-A IQK setting */ + /* PA/PAD controlled by 0x0 */ + rtl_set_bbreg(hw, RFPGA0_IQK, MASKDWORD, 0x00000000); + rtl_set_rfreg(hw, RF90_PATH_A, 0xdf, RFREG_OFFSET_MASK, 0x180); + rtl_set_bbreg(hw, RFPGA0_IQK, MASKDWORD, 0x80800000); + + rtl_set_bbreg(hw, RTx_IQK_Tone_A, MASKDWORD, 0x18008c1c); + rtl_set_bbreg(hw, RRx_IQK_Tone_A, MASKDWORD, 0x38008c1c); + rtl_set_bbreg(hw, RTx_IQK_Tone_B, MASKDWORD, 0x38008c1c); + rtl_set_bbreg(hw, RRx_IQK_Tone_B, MASKDWORD, 0x38008c1c); + + rtl_set_bbreg(hw, RTx_IQK_PI_A, MASKDWORD, 0x82140303); + rtl_set_bbreg(hw, RRx_IQK_PI_A, MASKDWORD, 0x68160000); + + /*LO calibration setting*/ + rtl_set_bbreg(hw, RIQK_AGC_Rsp, MASKDWORD, 0x00462911); + + /*One shot, path A LOK & IQK*/ + rtl_set_bbreg(hw, RIQK_AGC_Pts, MASKDWORD, 0xf9000000); + rtl_set_bbreg(hw, RIQK_AGC_Pts, MASKDWORD, 0xf8000000); + + mdelay(IQK_DELAY_TIME); + + reg_eac = rtl_get_bbreg(hw, 0xeac, MASKDWORD); + reg_e94 = rtl_get_bbreg(hw, 0xe94, MASKDWORD); + reg_e9c = rtl_get_bbreg(hw, 0xe9c, MASKDWORD); + + if (!(reg_eac & BIT(28)) && + (((reg_e94 & 0x03FF0000) >> 16) != 0x142) && + (((reg_e9c & 0x03FF0000) >> 16) != 0x42)) + result |= 0x01; + else + return result; + + return result; +} + +static u8 _rtl92ee_phy_path_b_iqk(struct ieee80211_hw *hw) +{ + u32 reg_eac, reg_eb4, reg_ebc; + u8 result = 0x00; + + /* PA/PAD controlled by 0x0 */ + rtl_set_bbreg(hw, RFPGA0_IQK, MASKDWORD, 0x00000000); + rtl_set_rfreg(hw, RF90_PATH_B, 0xdf, RFREG_OFFSET_MASK, 0x180); + rtl_set_bbreg(hw, RFPGA0_IQK, MASKDWORD, 0x80800000); + + rtl_set_bbreg(hw, 0xe28, MASKDWORD, 0x00000000); + rtl_set_bbreg(hw, 0xe28, MASKDWORD, 0x80800000); + + rtl_set_bbreg(hw, RTx_IQK_Tone_A, MASKDWORD, 0x38008c1c); + rtl_set_bbreg(hw, RRx_IQK_Tone_A, MASKDWORD, 0x38008c1c); + rtl_set_bbreg(hw, RTx_IQK_Tone_B, MASKDWORD, 0x18008c1c); + rtl_set_bbreg(hw, RRx_IQK_Tone_B, MASKDWORD, 0x38008c1c); + + rtl_set_bbreg(hw, RTx_IQK_PI_B, MASKDWORD, 0x821403e2); + rtl_set_bbreg(hw, RRx_IQK_PI_B, MASKDWORD, 0x68160000); + + /* LO calibration setting */ + rtl_set_bbreg(hw, RIQK_AGC_Rsp, MASKDWORD, 0x00462911); + + /*One shot, path B LOK & IQK*/ + rtl_set_bbreg(hw, RIQK_AGC_Pts, MASKDWORD, 0xfa000000); + rtl_set_bbreg(hw, RIQK_AGC_Pts, MASKDWORD, 0xf8000000); + + mdelay(IQK_DELAY_TIME); + + reg_eac = rtl_get_bbreg(hw, 0xeac, MASKDWORD); + reg_eb4 = rtl_get_bbreg(hw, 0xeb4, MASKDWORD); + reg_ebc = rtl_get_bbreg(hw, 0xebc, MASKDWORD); + + if (!(reg_eac & BIT(31)) && + (((reg_eb4 & 0x03FF0000) >> 16) != 0x142) && + (((reg_ebc & 0x03FF0000) >> 16) != 0x42)) + result |= 0x01; + else + return result; + + return result; +} + +static u8 _rtl92ee_phy_path_a_rx_iqk(struct ieee80211_hw *hw, bool config_pathb) +{ + u32 reg_eac, reg_e94, reg_e9c, reg_ea4 , u32temp; + u8 result = 0x00; + + /*Get TXIMR Setting*/ + /*Modify RX IQK mode table*/ + rtl_set_bbreg(hw, RFPGA0_IQK, MASKDWORD, 0x00000000); + + rtl_set_rfreg(hw, RF90_PATH_A, RF_WE_LUT, RFREG_OFFSET_MASK, 0x800a0); + rtl_set_rfreg(hw, RF90_PATH_A, RF_RCK_OS, RFREG_OFFSET_MASK, 0x30000); + rtl_set_rfreg(hw, RF90_PATH_A, RF_TXPA_G1, RFREG_OFFSET_MASK, 0x0000f); + rtl_set_rfreg(hw, RF90_PATH_A, RF_TXPA_G2, RFREG_OFFSET_MASK, 0xf117b); + + /*PA/PAD control by 0x56, and set = 0x0*/ + rtl_set_rfreg(hw, RF90_PATH_A, 0xdf, RFREG_OFFSET_MASK, 0x980); + rtl_set_rfreg(hw, RF90_PATH_A, 0x56, RFREG_OFFSET_MASK, 0x51000); + + /*enter IQK mode*/ + rtl_set_bbreg(hw, RFPGA0_IQK, MASKDWORD, 0x80800000); + + /*IQK Setting*/ + rtl_set_bbreg(hw, RTx_IQK, MASKDWORD, 0x01007c00); + rtl_set_bbreg(hw, RRx_IQK, MASKDWORD, 0x01004800); + + /*path a IQK setting*/ + rtl_set_bbreg(hw, RTx_IQK_Tone_A, MASKDWORD, 0x18008c1c); + rtl_set_bbreg(hw, RRx_IQK_Tone_A, MASKDWORD, 0x38008c1c); + rtl_set_bbreg(hw, RTx_IQK_Tone_B, MASKDWORD, 0x38008c1c); + rtl_set_bbreg(hw, RRx_IQK_Tone_B, MASKDWORD, 0x38008c1c); + + rtl_set_bbreg(hw, RTx_IQK_PI_A, MASKDWORD, 0x82160c1f); + rtl_set_bbreg(hw, RRx_IQK_PI_A, MASKDWORD, 0x68160c1f); + + /*LO calibration Setting*/ + rtl_set_bbreg(hw, RIQK_AGC_Rsp, MASKDWORD, 0x0046a911); + + /*one shot, path A LOK & iqk*/ + rtl_set_bbreg(hw, RIQK_AGC_Pts, MASKDWORD, 0xfa000000); + rtl_set_bbreg(hw, RIQK_AGC_Pts, MASKDWORD, 0xf8000000); + + mdelay(IQK_DELAY_TIME); + + /* Check failed */ + reg_eac = rtl_get_bbreg(hw, RRx_Power_After_IQK_A_2, MASKDWORD); + reg_e94 = rtl_get_bbreg(hw, RTx_Power_Before_IQK_A, MASKDWORD); + reg_e9c = rtl_get_bbreg(hw, RTx_Power_After_IQK_A, MASKDWORD); + + if (!(reg_eac & BIT(28)) && + (((reg_e94 & 0x03FF0000) >> 16) != 0x142) && + (((reg_e9c & 0x03FF0000) >> 16) != 0x42)) { + result |= 0x01; + } else { + /* PA/PAD controlled by 0x0 */ + rtl_set_bbreg(hw, RFPGA0_IQK, MASKDWORD, 0x00000000); + rtl_set_rfreg(hw, RF90_PATH_A, 0xdf, RFREG_OFFSET_MASK, 0x180); + return result; + } + + u32temp = 0x80007C00 | (reg_e94 & 0x3FF0000) | + ((reg_e9c & 0x3FF0000) >> 16); + rtl_set_bbreg(hw, RTx_IQK, MASKDWORD, u32temp); + /*RX IQK*/ + /*Modify RX IQK mode table*/ + rtl_set_bbreg(hw, RFPGA0_IQK, MASKDWORD, 0x00000000); + + rtl_set_rfreg(hw, RF90_PATH_A, RF_WE_LUT, RFREG_OFFSET_MASK, 0x800a0); + + rtl_set_rfreg(hw, RF90_PATH_A, RF_RCK_OS, RFREG_OFFSET_MASK, 0x30000); + rtl_set_rfreg(hw, RF90_PATH_A, RF_TXPA_G1, RFREG_OFFSET_MASK, 0x0000f); + rtl_set_rfreg(hw, RF90_PATH_A, RF_TXPA_G2, RFREG_OFFSET_MASK, 0xf7ffa); + + /*PA/PAD control by 0x56, and set = 0x0*/ + rtl_set_rfreg(hw, RF90_PATH_A, 0xdf, RFREG_OFFSET_MASK, 0x980); + rtl_set_rfreg(hw, RF90_PATH_A, 0x56, RFREG_OFFSET_MASK, 0x51000); + + /*enter IQK mode*/ + rtl_set_bbreg(hw, RFPGA0_IQK, MASKDWORD, 0x80800000); + + /*IQK Setting*/ + rtl_set_bbreg(hw, RRx_IQK, MASKDWORD, 0x01004800); + + /*path a IQK setting*/ + rtl_set_bbreg(hw, RTx_IQK_Tone_A, MASKDWORD, 0x38008c1c); + rtl_set_bbreg(hw, RRx_IQK_Tone_A, MASKDWORD, 0x18008c1c); + rtl_set_bbreg(hw, RTx_IQK_Tone_B, MASKDWORD, 0x38008c1c); + rtl_set_bbreg(hw, RRx_IQK_Tone_B, MASKDWORD, 0x38008c1c); + + rtl_set_bbreg(hw, RTx_IQK_PI_A, MASKDWORD, 0x82160c1f); + rtl_set_bbreg(hw, RRx_IQK_PI_A, MASKDWORD, 0x28160c1f); + + /*LO calibration Setting*/ + rtl_set_bbreg(hw, RIQK_AGC_Rsp, MASKDWORD, 0x0046a891); + /*one shot, path A LOK & iqk*/ + rtl_set_bbreg(hw, RIQK_AGC_Pts, MASKDWORD, 0xfa000000); + rtl_set_bbreg(hw, RIQK_AGC_Pts, MASKDWORD, 0xf8000000); + + mdelay(IQK_DELAY_TIME); + /*Check failed*/ + reg_eac = rtl_get_bbreg(hw, RRx_Power_After_IQK_A_2, MASKDWORD); + reg_ea4 = rtl_get_bbreg(hw, RRx_Power_Before_IQK_A_2, MASKDWORD); + + /*PA/PAD controlled by 0x0*/ + /*leave IQK mode*/ + rtl_set_bbreg(hw, RFPGA0_IQK, MASKDWORD, 0x00000000); + rtl_set_rfreg(hw, RF90_PATH_A, 0xdf, RFREG_OFFSET_MASK, 0x180); + /*if Tx is OK, check whether Rx is OK*/ + if (!(reg_eac & BIT(27)) && + (((reg_ea4 & 0x03FF0000) >> 16) != 0x132) && + (((reg_eac & 0x03FF0000) >> 16) != 0x36)) + result |= 0x02; + + return result; +} + +static u8 _rtl92ee_phy_path_b_rx_iqk(struct ieee80211_hw *hw, bool config_pathb) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u32 reg_eac, reg_eb4, reg_ebc, reg_ecc, reg_ec4, u32temp; + u8 result = 0x00; + + /*Get TXIMR Setting*/ + /*Modify RX IQK mode table*/ + rtl_set_bbreg(hw, RFPGA0_IQK, MASKDWORD, 0x00000000); + + rtl_set_rfreg(hw, RF90_PATH_B, RF_WE_LUT, RFREG_OFFSET_MASK, 0x800a0); + rtl_set_rfreg(hw, RF90_PATH_B, RF_RCK_OS, RFREG_OFFSET_MASK, 0x30000); + rtl_set_rfreg(hw, RF90_PATH_B, RF_TXPA_G1, RFREG_OFFSET_MASK, 0x0000f); + rtl_set_rfreg(hw, RF90_PATH_B, RF_TXPA_G2, RFREG_OFFSET_MASK, 0xf117b); + + /*PA/PAD all off*/ + rtl_set_rfreg(hw, RF90_PATH_B, 0xdf, RFREG_OFFSET_MASK, 0x980); + rtl_set_rfreg(hw, RF90_PATH_B, 0x56, RFREG_OFFSET_MASK, 0x51000); + + rtl_set_bbreg(hw, RFPGA0_IQK, MASKDWORD, 0x80800000); + + /*IQK Setting*/ + rtl_set_bbreg(hw, RTx_IQK, MASKDWORD, 0x01007c00); + rtl_set_bbreg(hw, RRx_IQK, MASKDWORD, 0x01004800); + + /*path a IQK setting*/ + rtl_set_bbreg(hw, RTx_IQK_Tone_A, MASKDWORD, 0x38008c1c); + rtl_set_bbreg(hw, RRx_IQK_Tone_A, MASKDWORD, 0x38008c1c); + rtl_set_bbreg(hw, RTx_IQK_Tone_B, MASKDWORD, 0x18008c1c); + rtl_set_bbreg(hw, RRx_IQK_Tone_B, MASKDWORD, 0x38008c1c); + + rtl_set_bbreg(hw, RTx_IQK_PI_B, MASKDWORD, 0x82160c1f); + rtl_set_bbreg(hw, RRx_IQK_PI_B, MASKDWORD, 0x68160c1f); + + /*LO calibration Setting*/ + rtl_set_bbreg(hw, RIQK_AGC_Rsp, MASKDWORD, 0x0046a911); + + /*one shot, path A LOK & iqk*/ + rtl_set_bbreg(hw, RIQK_AGC_Pts, MASKDWORD, 0xfa000000); + rtl_set_bbreg(hw, RIQK_AGC_Pts, MASKDWORD, 0xf8000000); + + mdelay(IQK_DELAY_TIME); + + /* Check failed */ + reg_eac = rtl_get_bbreg(hw, RRx_Power_After_IQK_A_2, MASKDWORD); + reg_eb4 = rtl_get_bbreg(hw, RTx_Power_Before_IQK_B, MASKDWORD); + reg_ebc = rtl_get_bbreg(hw, RTx_Power_After_IQK_B, MASKDWORD); + + if (!(reg_eac & BIT(31)) && + (((reg_eb4 & 0x03FF0000) >> 16) != 0x142) && + (((reg_ebc & 0x03FF0000) >> 16) != 0x42)) { + result |= 0x01; + } else { + /* PA/PAD controlled by 0x0 */ + rtl_set_bbreg(hw, RFPGA0_IQK, MASKDWORD, 0x00000000); + rtl_set_rfreg(hw, RF90_PATH_B, 0xdf, RFREG_OFFSET_MASK, 0x180); + return result; + } + + u32temp = 0x80007C00 | (reg_eb4 & 0x3FF0000) | + ((reg_ebc & 0x3FF0000) >> 16); + rtl_set_bbreg(hw, RTx_IQK, MASKDWORD, u32temp); + /*RX IQK*/ + /*Modify RX IQK mode table*/ + rtl_set_bbreg(hw, RFPGA0_IQK, MASKDWORD, 0x00000000); + rtl_set_rfreg(hw, RF90_PATH_B, RF_WE_LUT, RFREG_OFFSET_MASK, 0x800a0); + + rtl_set_rfreg(hw, RF90_PATH_B, RF_RCK_OS, RFREG_OFFSET_MASK, 0x30000); + rtl_set_rfreg(hw, RF90_PATH_B, RF_TXPA_G1, RFREG_OFFSET_MASK, 0x0000f); + rtl_set_rfreg(hw, RF90_PATH_B, RF_TXPA_G2, RFREG_OFFSET_MASK, 0xf7ffa); + + /*PA/PAD all off*/ + rtl_set_rfreg(hw, RF90_PATH_B, 0xdf, RFREG_OFFSET_MASK, 0x980); + rtl_set_rfreg(hw, RF90_PATH_B, 0x56, RFREG_OFFSET_MASK, 0x51000); + + /*enter IQK mode*/ + rtl_set_bbreg(hw, RFPGA0_IQK, MASKDWORD, 0x80800000); + + /*IQK Setting*/ + rtl_set_bbreg(hw, RRx_IQK, MASKDWORD, 0x01004800); + + /*path b IQK setting*/ + rtl_set_bbreg(hw, RTx_IQK_Tone_A, MASKDWORD, 0x38008c1c); + rtl_set_bbreg(hw, RRx_IQK_Tone_A, MASKDWORD, 0x38008c1c); + rtl_set_bbreg(hw, RTx_IQK_Tone_B, MASKDWORD, 0x38008c1c); + rtl_set_bbreg(hw, RRx_IQK_Tone_B, MASKDWORD, 0x18008c1c); + + rtl_set_bbreg(hw, RTx_IQK_PI_B, MASKDWORD, 0x82160c1f); + rtl_set_bbreg(hw, RRx_IQK_PI_B, MASKDWORD, 0x28160c1f); + + /*LO calibration Setting*/ + rtl_set_bbreg(hw, RIQK_AGC_Rsp, MASKDWORD, 0x0046a891); + /*one shot, path A LOK & iqk*/ + rtl_set_bbreg(hw, RIQK_AGC_Pts, MASKDWORD, 0xfa000000); + rtl_set_bbreg(hw, RIQK_AGC_Pts, MASKDWORD, 0xf8000000); + + mdelay(IQK_DELAY_TIME); + /*Check failed*/ + reg_eac = rtl_get_bbreg(hw, RRx_Power_After_IQK_A_2, MASKDWORD); + reg_ec4 = rtl_get_bbreg(hw, RRx_Power_Before_IQK_B_2, MASKDWORD); + reg_ecc = rtl_get_bbreg(hw, RRx_Power_After_IQK_B_2, MASKDWORD); + /*PA/PAD controlled by 0x0*/ + /*leave IQK mode*/ + rtl_set_bbreg(hw, RFPGA0_IQK, MASKDWORD, 0x00000000); + rtl_set_rfreg(hw, RF90_PATH_B, 0xdf, RFREG_OFFSET_MASK, 0x180); + /*if Tx is OK, check whether Rx is OK*/ + if (!(reg_eac & BIT(30)) && + (((reg_ec4 & 0x03FF0000) >> 16) != 0x132) && + (((reg_ecc & 0x03FF0000) >> 16) != 0x36)) + result |= 0x02; + else + RT_TRACE(COMP_RF, DBG_LOUD, ("Path B Rx IQK fail!!\n")); + + return result; +} + +static void _rtl92ee_phy_path_a_fill_iqk_matrix(struct ieee80211_hw *hw, + bool b_iqk_ok, long result[][8], + u8 final_candidate, + bool btxonly) +{ + u32 oldval_0, x, tx0_a, reg; + long y, tx0_c; + + if (final_candidate == 0xFF) { + return; + } else if (b_iqk_ok) { + oldval_0 = (rtl_get_bbreg(hw, ROFDM0_XATXIQIMBALANCE, + MASKDWORD) >> 22) & 0x3FF; + x = result[final_candidate][0]; + if ((x & 0x00000200) != 0) + x = x | 0xFFFFFC00; + tx0_a = (x * oldval_0) >> 8; + rtl_set_bbreg(hw, ROFDM0_XATXIQIMBALANCE, 0x3FF, tx0_a); + rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, BIT(31), + ((x * oldval_0 >> 7) & 0x1)); + y = result[final_candidate][1]; + if ((y & 0x00000200) != 0) + y = y | 0xFFFFFC00; + tx0_c = (y * oldval_0) >> 8; + rtl_set_bbreg(hw, ROFDM0_XCTXAFE, 0xF0000000, + ((tx0_c & 0x3C0) >> 6)); + rtl_set_bbreg(hw, ROFDM0_XATXIQIMBALANCE, 0x003F0000, + (tx0_c & 0x3F)); + rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, BIT(29), + ((y * oldval_0 >> 7) & 0x1)); + + if (btxonly) + return; + + reg = result[final_candidate][2]; + rtl_set_bbreg(hw, ROFDM0_XARXIQIMBALANCE, 0x3FF, reg); + + reg = result[final_candidate][3] & 0x3F; + rtl_set_bbreg(hw, ROFDM0_XARXIQIMBALANCE, 0xFC00, reg); + + reg = (result[final_candidate][3] >> 6) & 0xF; + rtl_set_bbreg(hw, ROFDM0_RXIQEXTANTA, 0xF0000000, reg); + } +} + +static void _rtl92ee_phy_path_b_fill_iqk_matrix(struct ieee80211_hw *hw, + bool b_iqk_ok, long result[][8], + u8 final_candidate, + bool btxonly) +{ + u32 oldval_1, x, tx1_a, reg; + long y, tx1_c; + + if (final_candidate == 0xFF) { + return; + } else if (b_iqk_ok) { + oldval_1 = (rtl_get_bbreg(hw, ROFDM0_XATXIQIMBALANCE, + MASKDWORD) >> 22) & 0x3FF; + x = result[final_candidate][4]; + if ((x & 0x00000200) != 0) + x = x | 0xFFFFFC00; + tx1_a = (x * oldval_1) >> 8; + rtl_set_bbreg(hw, ROFDM0_XATXIQIMBALANCE, 0x3FF, tx1_a); + rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, BIT(27), + ((x * oldval_1 >> 7) & 0x1)); + y = result[final_candidate][5]; + if ((y & 0x00000200) != 0) + y = y | 0xFFFFFC00; + tx1_c = (y * oldval_1) >> 8; + rtl_set_bbreg(hw, ROFDM0_XDTXAFE, 0xF0000000, + ((tx1_c & 0x3C0) >> 6)); + rtl_set_bbreg(hw, ROFDM0_XBTXIQIMBALANCE, 0x003F0000, + (tx1_c & 0x3F)); + rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, BIT(25), + ((y * oldval_1 >> 7) & 0x1)); + + if (btxonly) + return; + + reg = result[final_candidate][6]; + rtl_set_bbreg(hw, ROFDM0_XBRXIQIMBALANCE, 0x3FF, reg); + + reg = result[final_candidate][7] & 0x3F; + rtl_set_bbreg(hw, ROFDM0_XBRXIQIMBALANCE, 0xFC00, reg); + + reg = (result[final_candidate][7] >> 6) & 0xF; + rtl_set_bbreg(hw, ROFDM0_AGCRSSITABLE, 0xF0000000, reg); + } +} + +static void _rtl92ee_phy_save_adda_registers(struct ieee80211_hw *hw, + u32 *addareg, u32 *addabackup, + u32 registernum) +{ + u32 i; + + for (i = 0; i < registernum; i++) + addabackup[i] = rtl_get_bbreg(hw, addareg[i], MASKDWORD); +} + +static void _rtl92ee_phy_save_mac_registers(struct ieee80211_hw *hw, + u32 *macreg, u32 *macbackup) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u32 i; + + for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) + macbackup[i] = rtl_read_byte(rtlpriv, macreg[i]); + + macbackup[i] = rtl_read_dword(rtlpriv, macreg[i]); +} + +static void _rtl92ee_phy_reload_adda_registers(struct ieee80211_hw *hw, + u32 *addareg, u32 *addabackup, + u32 regiesternum) +{ + u32 i; + + for (i = 0; i < regiesternum; i++) + rtl_set_bbreg(hw, addareg[i], MASKDWORD, addabackup[i]); +} + +static void _rtl92ee_phy_reload_mac_registers(struct ieee80211_hw *hw, + u32 *macreg, u32 *macbackup) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u32 i; + + for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) + rtl_write_byte(rtlpriv, macreg[i], (u8) macbackup[i]); + rtl_write_dword(rtlpriv, macreg[i], macbackup[i]); +} + +static void _rtl92ee_phy_path_adda_on(struct ieee80211_hw *hw, u32 *addareg, + bool is_patha_on, bool is2t) +{ + u32 pathon; + u32 i; + + pathon = is_patha_on ? 0x0fc01616 : 0x0fc01616; + if (!is2t) { + pathon = 0x0fc01616; + rtl_set_bbreg(hw, addareg[0], MASKDWORD, 0x0fc01616); + } else { + rtl_set_bbreg(hw, addareg[0], MASKDWORD, pathon); + } + + for (i = 1; i < IQK_ADDA_REG_NUM; i++) + rtl_set_bbreg(hw, addareg[i], MASKDWORD, pathon); +} + +static void _rtl92ee_phy_mac_setting_calibration(struct ieee80211_hw *hw, + u32 *macreg, u32 *macbackup) +{ + rtl_set_bbreg(hw, 0x520, 0x00ff0000, 0xff); +} + +static void _rtl92ee_phy_path_a_standby(struct ieee80211_hw *hw) +{ + rtl_set_bbreg(hw, 0xe28, MASKDWORD, 0x0); + rtl_set_rfreg(hw, RF90_PATH_A, 0, RFREG_OFFSET_MASK, 0x10000); + rtl_set_bbreg(hw, 0xe28, MASKDWORD, 0x80800000); +} + +static bool _rtl92ee_phy_simularity_compare(struct ieee80211_hw *hw, + long result[][8], u8 c1, u8 c2) +{ + u32 i, j, diff, simularity_bitmap, bound; + + u8 final_candidate[2] = { 0xFF, 0xFF }; + bool bresult = true/*, is2t = true*/; + s32 tmp1, tmp2; + + bound = 8; + + simularity_bitmap = 0; + + for (i = 0; i < bound; i++) { + if ((i == 1) || (i == 3) || (i == 5) || (i == 7)) { + if ((result[c1][i] & 0x00000200) != 0) + tmp1 = result[c1][i] | 0xFFFFFC00; + else + tmp1 = result[c1][i]; + + if ((result[c2][i] & 0x00000200) != 0) + tmp2 = result[c2][i] | 0xFFFFFC00; + else + tmp2 = result[c2][i]; + } else { + tmp1 = result[c1][i]; + tmp2 = result[c2][i]; + } + + diff = (tmp1 > tmp2) ? (tmp1 - tmp2) : (tmp2 - tmp1); + + if (diff > MAX_TOLERANCE) { + if ((i == 2 || i == 6) && !simularity_bitmap) { + if (result[c1][i] + result[c1][i + 1] == 0) + final_candidate[(i / 4)] = c2; + else if (result[c2][i] + result[c2][i + 1] == 0) + final_candidate[(i / 4)] = c1; + else + simularity_bitmap |= (1 << i); + } else { + simularity_bitmap |= (1 << i); + } + } + } + + if (simularity_bitmap == 0) { + for (i = 0; i < (bound / 4); i++) { + if (final_candidate[i] != 0xFF) { + for (j = i * 4; j < (i + 1) * 4 - 2; j++) + result[3][j] = + result[final_candidate[i]][j]; + bresult = false; + } + } + return bresult; + } else { + if (!(simularity_bitmap & 0x03)) {/*path A TX OK*/ + for (i = 0; i < 2; i++) + result[3][i] = result[c1][i]; + } + if (!(simularity_bitmap & 0x0c)) {/*path A RX OK*/ + for (i = 2; i < 4; i++) + result[3][i] = result[c1][i]; + } + if (!(simularity_bitmap & 0x30)) {/*path B TX OK*/ + for (i = 4; i < 6; i++) + result[3][i] = result[c1][i]; + } + if (!(simularity_bitmap & 0xc0)) {/*path B RX OK*/ + for (i = 6; i < 8; i++) + result[3][i] = result[c1][i]; + } + return false; + } +} + +static void _rtl92ee_phy_iq_calibrate(struct ieee80211_hw *hw, + long result[][8], u8 t, bool is2t) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + u32 i; + u8 patha_ok, pathb_ok; + u8 tmp_0xc50 = (u8) rtl_get_bbreg(hw, 0xc50, MASKBYTE0); + u8 tmp_0xc58 = (u8) rtl_get_bbreg(hw, 0xc58, MASKBYTE0); + u32 adda_reg[IQK_ADDA_REG_NUM] = { + 0x85c, 0xe6c, 0xe70, 0xe74, + 0xe78, 0xe7c, 0xe80, 0xe84, + 0xe88, 0xe8c, 0xed0, 0xed4, + 0xed8, 0xedc, 0xee0, 0xeec + }; + + u32 iqk_mac_reg[IQK_MAC_REG_NUM] = { + 0x522, 0x550, 0x551, 0x040 + }; + + u32 iqk_bb_reg[IQK_BB_REG_NUM] = { + ROFDM0_TRXPATHENABLE, ROFDM0_TRMUXPAR, + RFPGA0_XCD_RFINTERFACESW, 0xb68, 0xb6c, + 0x870, 0x860, + 0x864, 0x800 + }; + + const u32 retrycount = 2; + + + if (t == 0) { + _rtl92ee_phy_save_adda_registers(hw, adda_reg, + rtlphy->adda_backup, + IQK_ADDA_REG_NUM); + _rtl92ee_phy_save_mac_registers(hw, iqk_mac_reg, + rtlphy->iqk_mac_backup); + _rtl92ee_phy_save_adda_registers(hw, iqk_bb_reg, + rtlphy->iqk_bb_backup, + IQK_BB_REG_NUM); + } + + _rtl92ee_phy_path_adda_on(hw, adda_reg, true, is2t); + + /*BB setting*/ + rtl_set_bbreg(hw, RFPGA0_RFMOD, BIT(24), 0x00); + rtl_set_bbreg(hw, ROFDM0_TRXPATHENABLE, MASKDWORD, 0x03a05600); + rtl_set_bbreg(hw, ROFDM0_TRMUXPAR, MASKDWORD, 0x000800e4); + rtl_set_bbreg(hw, RFPGA0_XCD_RFINTERFACESW, MASKDWORD, 0x22208200); + + rtl_set_bbreg(hw, RFPGA0_XAB_RFINTERFACESW, BIT(10), 0x01); + rtl_set_bbreg(hw, RFPGA0_XAB_RFINTERFACESW, BIT(26), 0x01); + rtl_set_bbreg(hw, RFPGA0_XA_RFINTERFACEOE, BIT(10), 0x01); + rtl_set_bbreg(hw, RFPGA0_XB_RFINTERFACEOE, BIT(10), 0x01); + + _rtl92ee_phy_mac_setting_calibration(hw, iqk_mac_reg, + rtlphy->iqk_mac_backup); + /* Page B init*/ + /* IQ calibration setting*/ + rtl_set_bbreg(hw, RFPGA0_IQK, MASKDWORD, 0x80800000); + rtl_set_bbreg(hw, RTx_IQK, MASKDWORD, 0x01007c00); + rtl_set_bbreg(hw, RRx_IQK, MASKDWORD, 0x01004800); + + for (i = 0; i < retrycount; i++) { + patha_ok = _rtl92ee_phy_path_a_iqk(hw, is2t); + + if (patha_ok == 0x01) { + RT_TRACE(COMP_RF, DBG_LOUD, + ("Path A Tx IQK Success!!\n")); + result[t][0] = (rtl_get_bbreg(hw, + RTx_Power_Before_IQK_A, + MASKDWORD) & 0x3FF0000) + >> 16; + result[t][1] = (rtl_get_bbreg(hw, RTx_Power_After_IQK_A, + MASKDWORD) & 0x3FF0000) + >> 16; + break; + } else { + RT_TRACE(COMP_RF, DBG_LOUD, + ("Path A Tx IQK Fail!!, ret = 0x%x\n", + patha_ok)); + } + } + + for (i = 0 ; i < retrycount ; i++) { + patha_ok = _rtl92ee_phy_path_a_rx_iqk(hw, is2t); + + if (patha_ok == 0x03) { + RT_TRACE(COMP_RF, DBG_LOUD, + ("Path A Rx IQK Success!!\n")); + result[t][2] = (rtl_get_bbreg(hw, + RRx_Power_Before_IQK_A_2, + MASKDWORD) & 0x3FF0000) + >> 16; + result[t][3] = (rtl_get_bbreg(hw, + RRx_Power_After_IQK_A_2, + MASKDWORD) & 0x3FF0000) + >> 16; + break; + } else { + RT_TRACE(COMP_RF, DBG_LOUD, + ("Path A Rx IQK Fail!!, ret = 0x%x\n", + patha_ok)); + } + } + + if (0x00 == patha_ok) + RT_TRACE(COMP_RF, DBG_LOUD, ("Path A IQK failed!!, ret = 0\n")); + + if (is2t) { + _rtl92ee_phy_path_a_standby(hw); + /* Turn Path B ADDA on */ + _rtl92ee_phy_path_adda_on(hw, adda_reg, false, is2t); + + /* IQ calibration setting */ + rtl_set_bbreg(hw, RFPGA0_IQK, MASKDWORD, 0x80800000); + rtl_set_bbreg(hw, RTx_IQK, MASKDWORD, 0x01007c00); + rtl_set_bbreg(hw, RRx_IQK, MASKDWORD, 0x01004800); + + for (i = 0 ; i < retrycount ; i++) { + pathb_ok = _rtl92ee_phy_path_b_iqk(hw); + if (pathb_ok == 0x01) { + RT_TRACE(COMP_RF, DBG_LOUD, + ("Path B Tx IQK Success!!\n")); + result[t][4] = (rtl_get_bbreg(hw, + RTx_Power_Before_IQK_B, + MASKDWORD) & 0x3FF0000) + >> 16; + result[t][5] = (rtl_get_bbreg(hw, + RTx_Power_After_IQK_B, + MASKDWORD) & 0x3FF0000) + >> 16; + break; + } else { + RT_TRACE(COMP_RF, DBG_LOUD, + ("Path B Tx IQK Fail!!, ret = 0x%x\n", + pathb_ok)); + } + } + + for (i = 0 ; i < retrycount ; i++) { + pathb_ok = _rtl92ee_phy_path_b_rx_iqk(hw, is2t); + if (pathb_ok == 0x03) { + RT_TRACE(COMP_RF, DBG_LOUD, + ("Path B Rx IQK Success!!\n")); + result[t][6] = (rtl_get_bbreg(hw, + RRx_Power_Before_IQK_B_2, + MASKDWORD) & 0x3FF0000) + >> 16; + result[t][7] = (rtl_get_bbreg(hw, + RRx_Power_After_IQK_B_2, + MASKDWORD) & 0x3FF0000) + >> 16; + break; + } else { + RT_TRACE(COMP_RF, DBG_LOUD, + ("Path B Rx IQK Fail!!, ret = 0x%x\n", + pathb_ok)); + } + } + + if (0x00 == pathb_ok) + RT_TRACE(COMP_RF, DBG_LOUD, + ("Path B IQK failed!!, ret = 0\n")); + } + /* Back to BB mode, load original value */ + RT_TRACE(COMP_RF, DBG_LOUD, + ("IQK:Back to BB mode, load original value!\n")); + rtl_set_bbreg(hw, RFPGA0_IQK, MASKDWORD, 0); + + if (t != 0) { + /* Reload ADDA power saving parameters */ + _rtl92ee_phy_reload_adda_registers(hw, adda_reg, + rtlphy->adda_backup, + IQK_ADDA_REG_NUM); + + /* Reload MAC parameters */ + _rtl92ee_phy_reload_mac_registers(hw, iqk_mac_reg, + rtlphy->iqk_mac_backup); + + _rtl92ee_phy_reload_adda_registers(hw, iqk_bb_reg, + rtlphy->iqk_bb_backup, + IQK_BB_REG_NUM); + + /* Restore RX initial gain */ + rtl_set_bbreg(hw, 0xc50, MASKBYTE0, 0x50); + rtl_set_bbreg(hw, 0xc50, MASKBYTE0, tmp_0xc50); + if (is2t) { + rtl_set_bbreg(hw, 0xc50, MASKBYTE0, 0x50); + rtl_set_bbreg(hw, 0xc58, MASKBYTE0, tmp_0xc58); + } + + /* load 0xe30 IQC default value */ + rtl_set_bbreg(hw, RTx_IQK_Tone_A, MASKDWORD, 0x01008c00); + rtl_set_bbreg(hw, RRx_IQK_Tone_A, MASKDWORD, 0x01008c00); + } + RT_TRACE(COMP_RF, DBG_LOUD, ("_rtl92ee_phy_iq_calibrate() <==\n")); +} + +static void _rtl92ee_phy_lc_calibrate(struct ieee80211_hw *hw, bool is2t) +{ + u8 tmpreg; + u32 rf_a_mode = 0, rf_b_mode = 0, lc_cal; + struct rtl_priv *rtlpriv = rtl_priv(hw); + + tmpreg = rtl_read_byte(rtlpriv, 0xd03); + + if ((tmpreg & 0x70) != 0) + rtl_write_byte(rtlpriv, 0xd03, tmpreg & 0x8F); + else + rtl_write_byte(rtlpriv, REG_TXPAUSE, 0xFF); + + if ((tmpreg & 0x70) != 0) { + rf_a_mode = rtl_get_rfreg(hw, RF90_PATH_A, 0x00, MASK12BITS); + + if (is2t) + rf_b_mode = rtl_get_rfreg(hw, RF90_PATH_B, 0x00, + MASK12BITS); + + rtl_set_rfreg(hw, RF90_PATH_A, 0x00, MASK12BITS, + (rf_a_mode & 0x8FFFF) | 0x10000); + + if (is2t) + rtl_set_rfreg(hw, RF90_PATH_B, 0x00, MASK12BITS, + (rf_b_mode & 0x8FFFF) | 0x10000); + } + lc_cal = rtl_get_rfreg(hw, RF90_PATH_A, 0x18, MASK12BITS); + + rtl_set_rfreg(hw, RF90_PATH_A, 0x18, MASK12BITS, lc_cal | 0x08000); + + mdelay(100); + + if ((tmpreg & 0x70) != 0) { + rtl_write_byte(rtlpriv, 0xd03, tmpreg); + rtl_set_rfreg(hw, RF90_PATH_A, 0x00, MASK12BITS, rf_a_mode); + + if (is2t) + rtl_set_rfreg(hw, RF90_PATH_B, 0x00, MASK12BITS, + rf_b_mode); + } else { + rtl_write_byte(rtlpriv, REG_TXPAUSE, 0x00); + } + RT_TRACE(COMP_INIT , DBG_LOUD , ("\n")); +} + +static void _rtl92ee_phy_set_rfpath_switch(struct ieee80211_hw *hw, + bool bmain, bool is2t) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); + RT_TRACE(COMP_INIT , DBG_LOUD , ("\n")); + + if (is_hal_stop(rtlhal)) { + u8 u1btmp; + u1btmp = rtl_read_byte(rtlpriv, REG_LEDCFG0); + rtl_write_byte(rtlpriv, REG_LEDCFG0, u1btmp | BIT(7)); + rtl_set_bbreg(hw, rFPGA0_XAB_RFPARAMETER, BIT(13), 0x01); + } + if (is2t) { + if (bmain) + rtl_set_bbreg(hw, RFPGA0_XB_RFINTERFACEOE, + BIT(5) | BIT(6), 0x1); + else + rtl_set_bbreg(hw, RFPGA0_XB_RFINTERFACEOE, + BIT(5) | BIT(6), 0x2); + } else { + rtl_set_bbreg(hw, RFPGA0_XAB_RFINTERFACESW, BIT(8) | BIT(9), 0); + rtl_set_bbreg(hw, 0x914, MASKLWORD, 0x0201); + + /* We use the RF definition of MAIN and AUX, + * left antenna and right antenna repectively. + * Default output at AUX.*/ + if (bmain) { + rtl_set_bbreg(hw, RFPGA0_XA_RFINTERFACEOE, + BIT(14) | BIT(13) | BIT(12), 0); + rtl_set_bbreg(hw, RFPGA0_XB_RFINTERFACEOE, + BIT(5) | BIT(4) | BIT(3), 0); + if (rtlefuse->antenna_div_type == CGCS_RX_HW_ANTDIV) + rtl_set_bbreg(hw, rConfig_ram64x16, BIT(31), 0); + } else { + rtl_set_bbreg(hw, RFPGA0_XA_RFINTERFACEOE, + BIT(14) | BIT(13) | BIT(12), 1); + rtl_set_bbreg(hw, RFPGA0_XB_RFINTERFACEOE, + BIT(5) | BIT(4) | BIT(3), 1); + if (rtlefuse->antenna_div_type == CGCS_RX_HW_ANTDIV) + rtl_set_bbreg(hw, rConfig_ram64x16, BIT(31), 1); + } + } +} + +#undef IQK_ADDA_REG_NUM +#undef IQK_DELAY_TIME + +static u8 rtl92ee_get_rightchnlplace_for_iqk(u8 chnl) +{ + u8 channel_all[59] = { + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, + 60, 62, 64, 100, 102, 104, 106, 108, 110, 112, + 114, 116, 118, 120, 122, 124, 126, 128, 130, + 132, 134, 136, 138, 140, 149, 151, 153, 155, + 157, 159, 161, 163, 165 + }; + u8 place = chnl; + + if (chnl > 14) { + for (place = 14; place < sizeof(channel_all); place++) { + if (channel_all[place] == chnl) + return place - 13; + } + } + + return 0; +} + +void rtl92ee_phy_iq_calibrate(struct ieee80211_hw *hw, bool b_recovery) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + long result[4][8]; + u8 i, final_candidate; + bool b_patha_ok, b_pathb_ok; + long reg_e94, reg_e9c, reg_ea4, reg_eac; + long reg_eb4, reg_ebc, reg_ec4, reg_ecc; + bool is12simular, is13simular, is23simular; + u8 idx; + u32 iqk_bb_reg[IQK_BB_REG_NUM] = { + ROFDM0_XARXIQIMBALANCE, + ROFDM0_XBRXIQIMBALANCE, + ROFDM0_ECCATHRESHOLD, + ROFDM0_AGCRSSITABLE, + ROFDM0_XATXIQIMBALANCE, + ROFDM0_XBTXIQIMBALANCE, + ROFDM0_XCTXAFE, + ROFDM0_XDTXAFE, + ROFDM0_RXIQEXTANTA + }; + + if (b_recovery) { + _rtl92ee_phy_reload_adda_registers(hw, iqk_bb_reg, + rtlphy->iqk_bb_backup, 9); + return; + } + + for (i = 0; i < 8; i++) { + result[0][i] = 0; + result[1][i] = 0; + result[2][i] = 0; + + if ((i == 0) || (i == 2) || (i == 4) || (i == 6)) + result[3][i] = 0x100; + else + result[3][i] = 0; + } + final_candidate = 0xff; + b_patha_ok = false; + b_pathb_ok = false; + is12simular = false; + is23simular = false; + is13simular = false; + for (i = 0; i < 3; i++) { + _rtl92ee_phy_iq_calibrate(hw, result, i, true); + if (i == 1) { + is12simular = _rtl92ee_phy_simularity_compare(hw, + result, + 0, 1); + if (is12simular) { + final_candidate = 0; + break; + } + } + + if (i == 2) { + is13simular = _rtl92ee_phy_simularity_compare(hw, + result, + 0, 2); + if (is13simular) { + final_candidate = 0; + break; + } + is23simular = _rtl92ee_phy_simularity_compare(hw, + result, + 1, 2); + if (is23simular) + final_candidate = 1; + else + final_candidate = 3; + } + } + for (i = 0; i < 4; i++) { + reg_e94 = result[i][0]; + reg_e9c = result[i][1]; + reg_ea4 = result[i][2]; + reg_eac = result[i][3]; + reg_eb4 = result[i][4]; + reg_ebc = result[i][5]; + reg_ec4 = result[i][6]; + reg_ecc = result[i][7]; + } + if (final_candidate != 0xff) { + reg_e94 = result[final_candidate][0]; + rtlphy->reg_e94 = reg_e94; + reg_e9c = result[final_candidate][1]; + rtlphy->reg_e9c = reg_e9c; + reg_ea4 = result[final_candidate][2]; + reg_eac = result[final_candidate][3]; + reg_eb4 = result[final_candidate][4]; + rtlphy->reg_eb4 = reg_eb4; + reg_ebc = result[final_candidate][5]; + rtlphy->reg_ebc = reg_ebc; + reg_ec4 = result[final_candidate][6]; + reg_ecc = result[final_candidate][7]; + b_patha_ok = true; + b_pathb_ok = true; + } else { + rtlphy->reg_e94 = 0x100; + rtlphy->reg_eb4 = 0x100; + rtlphy->reg_e9c = 0x0; + rtlphy->reg_ebc = 0x0; + } + + if (reg_e94 != 0) /*&&(reg_ea4 != 0) */ + _rtl92ee_phy_path_a_fill_iqk_matrix(hw, b_patha_ok, result, + final_candidate, + (reg_ea4 == 0)); + + _rtl92ee_phy_path_b_fill_iqk_matrix(hw, b_pathb_ok, result, + final_candidate, + (reg_ec4 == 0)); + + idx = rtl92ee_get_rightchnlplace_for_iqk(rtlphy->current_channel); + + /* To Fix BSOD when final_candidate is 0xff + * by sherry 20120321 */ + if (final_candidate < 4) { + for (i = 0; i < IQK_MATRIX_REG_NUM; i++) + rtlphy->iqk_matrix_regsetting[idx].value[0][i] = + result[final_candidate][i]; + + rtlphy->iqk_matrix_regsetting[idx].b_iqk_done = true; + } + _rtl92ee_phy_save_adda_registers(hw, iqk_bb_reg, + rtlphy->iqk_bb_backup, 9); +} + +void rtl92ee_phy_lc_calibrate(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + struct rtl_hal *rtlhal = &(rtlpriv->rtlhal); + u32 timeout = 2000, timecount = 0; + + while (rtlpriv->mac80211.act_scanning && timecount < timeout) { + udelay(50); + timecount += 50; + } + + rtlphy->lck_inprogress = true; + RTPRINT(rtlpriv, FINIT, INIT_IQK, + "LCK:Start!!! currentband %x delay %d ms\n", + rtlhal->current_bandtype, timecount); + + _rtl92ee_phy_lc_calibrate(hw, false); + + rtlphy->lck_inprogress = false; +} + +void rtl92ee_phy_ap_calibrate(struct ieee80211_hw *hw, char delta) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + + if (rtlphy->b_apk_done) + return; + + return; +} + +void rtl92ee_phy_set_rfpath_switch(struct ieee80211_hw *hw, bool bmain) +{ + _rtl92ee_phy_set_rfpath_switch(hw, bmain, false); +} + +bool rtl92ee_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + bool b_postprocessing = false; + + RT_TRACE(COMP_CMD, DBG_TRACE, + ("-->IO Cmd(%#x), set_io_inprogress(%d)\n", + iotype, rtlphy->set_io_inprogress)); + do { + switch (iotype) { + case IO_CMD_RESUME_DM_BY_SCAN: + RT_TRACE(COMP_CMD, DBG_TRACE, + ("[IO CMD] Resume DM after scan.\n")); + b_postprocessing = true; + break; + case IO_CMD_PAUSE_BAND0_DM_BY_SCAN: + RT_TRACE(COMP_CMD, DBG_TRACE, + ("[IO CMD] Pause DM before scan.\n")); + b_postprocessing = true; + break; + default: + RT_TRACE(COMP_ERR, DBG_EMERG, + ("switch case not process\n")); + break; + } + } while (false); + if (b_postprocessing && !rtlphy->set_io_inprogress) { + rtlphy->set_io_inprogress = true; + rtlphy->current_io_type = iotype; + } else { + return false; + } + rtl92ee_phy_set_io(hw); + RT_TRACE(COMP_CMD, DBG_TRACE, ("IO Type(%#x)\n", iotype)); + return true; +} + +static void rtl92ee_phy_set_io(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + + RT_TRACE(COMP_CMD, DBG_TRACE, + ("--->Cmd(%#x), set_io_inprogress(%d)\n", + rtlphy->current_io_type, rtlphy->set_io_inprogress)); + switch (rtlphy->current_io_type) { + case IO_CMD_RESUME_DM_BY_SCAN: + rtl92ee_dm_write_dig(hw , rtlphy->initgain_backup.xaagccore1); + rtl92ee_dm_write_cck_cca_thres(hw, rtlphy->initgain_backup.cca); + RT_TRACE(COMP_CMD, DBG_TRACE , ("no set txpower\n")); + rtl92ee_phy_set_txpower_level(hw, rtlphy->current_channel); + break; + case IO_CMD_PAUSE_BAND0_DM_BY_SCAN: + /* 8192eebt */ + rtlphy->initgain_backup.xaagccore1 = dm_dig.cur_igvalue; + rtl92ee_dm_write_dig(hw, 0x17); + rtlphy->initgain_backup.cca = dm_dig.cur_cck_cca_thres; + rtl92ee_dm_write_cck_cca_thres(hw, 0x40); + break; + default: + RT_TRACE(COMP_ERR, DBG_EMERG, + ("switch case not process\n")); + break; + } + rtlphy->set_io_inprogress = false; + RT_TRACE(COMP_CMD, DBG_TRACE, + ("(%#x)\n", rtlphy->current_io_type)); +} + +static void rtl92ee_phy_set_rf_on(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + rtl_write_byte(rtlpriv, REG_SPS0_CTRL, 0x2b); + rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE3); + /*rtl_write_byte(rtlpriv, REG_APSD_CTRL, 0x00);*/ + rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE2); + rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE3); + rtl_write_byte(rtlpriv, REG_TXPAUSE, 0x00); +} + +static void _rtl92ee_phy_set_rf_sleep(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + rtl_write_byte(rtlpriv, REG_TXPAUSE, 0xFF); + rtl_set_rfreg(hw, RF90_PATH_A, 0x00, RFREG_OFFSET_MASK, 0x00); + + rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, 0xE2); + rtl_write_byte(rtlpriv, REG_SPS0_CTRL, 0x22); +} + +static bool _rtl92ee_phy_set_rf_power_state(struct ieee80211_hw *hw, + enum rf_pwrstate rfpwr_state) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + bool bresult = true; + u8 i, queue_id; + struct rtl8192_tx_ring *ring = NULL; + + switch (rfpwr_state) { + case ERFON: + if ((ppsc->rfpwr_state == ERFOFF) && + RT_IN_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC)) { + bool rtstatus; + u32 init_count = 0; + do { + init_count++; + RT_TRACE(COMP_RF, DBG_DMESG, + ("IPS Set eRf nic enable\n")); + rtstatus = stg_rtl_ps_enable_nic(hw); + } while (!rtstatus && (init_count < 10)); + RT_CLEAR_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC); + } else { + RT_TRACE(COMP_RF, DBG_DMESG, + ("Set ERFON sleeped:%d ms\n", + jiffies_to_msecs(jiffies - + ppsc->last_sleep_jiffies))); + ppsc->last_awake_jiffies = jiffies; + rtl92ee_phy_set_rf_on(hw); + } + if (mac->link_state == MAC80211_LINKED) + rtlpriv->cfg->ops->led_control(hw, LED_CTL_LINK); + else + rtlpriv->cfg->ops->led_control(hw, LED_CTL_NO_LINK); + break; + case ERFOFF: + for (queue_id = 0, i = 0; + queue_id < RTL_PCI_MAX_TX_QUEUE_COUNT;) { + ring = &pcipriv->dev.tx_ring[queue_id]; + if (skb_queue_len(&ring->queue) == 0) { + queue_id++; + continue; + } else { + RT_TRACE(COMP_ERR, DBG_WARNING, + ("eRf Off/Sleep: %d times TcbBusyQueue[%d] =%d before " + "doze!\n", (i + 1), queue_id, + skb_queue_len(&ring->queue))); + + udelay(10); + i++; + } + if (i >= MAX_DOZE_WAITING_TIMES_9x) { + RT_TRACE(COMP_ERR, DBG_WARNING, + ("\n ERFSLEEP: %d times TcbBusyQueue[%d] = %d !\n", + MAX_DOZE_WAITING_TIMES_9x, + queue_id, + skb_queue_len(&ring->queue))); + break; + } + } + + if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_HALT_NIC) { + RT_TRACE(COMP_RF, DBG_DMESG, + ("IPS Set eRf nic disable\n")); + stg_rtl_ps_disable_nic(hw); + RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC); + } else { + if (ppsc->rfoff_reason == RF_CHANGE_BY_IPS) { + rtlpriv->cfg->ops->led_control(hw, + LED_CTL_NO_LINK); + } else { + rtlpriv->cfg->ops->led_control(hw, + LED_CTL_POWER_OFF); + } + } + break; + case ERFSLEEP: + if (ppsc->rfpwr_state == ERFOFF) + break; + for (queue_id = 0, i = 0; + queue_id < RTL_PCI_MAX_TX_QUEUE_COUNT;) { + ring = &pcipriv->dev.tx_ring[queue_id]; + if (skb_queue_len(&ring->queue) == 0) { + queue_id++; + continue; + } else { + RT_TRACE(COMP_ERR, DBG_WARNING, + ("eRf Off/Sleep: %d times TcbBusyQueue[%d] =%d before doze!\n", + (i + 1), queue_id, + skb_queue_len(&ring->queue))); + udelay(10); + i++; + } + if (i >= MAX_DOZE_WAITING_TIMES_9x) { + RT_TRACE(COMP_ERR, DBG_WARNING, + ("\n ERFSLEEP: %d times TcbBusyQueue[%d] = %d !\n", + MAX_DOZE_WAITING_TIMES_9x, + queue_id, + skb_queue_len(&ring->queue))); + break; + } + } + RT_TRACE(COMP_RF, DBG_DMESG, + ("Set ERFSLEEP awaked:%d ms\n", + jiffies_to_msecs(jiffies - + ppsc->last_awake_jiffies))); + ppsc->last_sleep_jiffies = jiffies; + _rtl92ee_phy_set_rf_sleep(hw); + break; + default: + RT_TRACE(COMP_ERR, DBG_EMERG, + ("switch case not process\n")); + bresult = false; + break; + } + if (bresult) + ppsc->rfpwr_state = rfpwr_state; + return bresult; +} + +bool rtl92ee_phy_set_rf_power_state(struct ieee80211_hw *hw, + enum rf_pwrstate rfpwr_state) +{ + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + + bool bresult = false; + + if (rfpwr_state == ppsc->rfpwr_state) + return bresult; + bresult = _rtl92ee_phy_set_rf_power_state(hw, rfpwr_state); + return bresult; +} diff --git a/drivers/staging/rtl8192ee/rtl8192ee/phy.h b/drivers/staging/rtl8192ee/rtl8192ee/phy.h new file mode 100644 index 000000000000..5be6c4866e14 --- /dev/null +++ b/drivers/staging/rtl8192ee/rtl8192ee/phy.h @@ -0,0 +1,154 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#ifndef __RTL92E_PHY_H__ +#define __RTL92E_PHY_H__ + +/*It must always set to 4, otherwise read efuse table secquence will be wrong.*/ +#define MAX_TX_COUNT 4 +#define TX_1S 0 +#define TX_2S 1 +#define TX_3S 2 +#define TX_4S 3 + +#define MAX_POWER_INDEX 0x3f + +#define MAX_PRECMD_CNT 16 +#define MAX_RFDEPENDCMD_CNT 16 +#define MAX_POSTCMD_CNT 16 + +#define MAX_DOZE_WAITING_TIMES_9x 64 + +#define RT_CANNOT_IO(hw) false +#define HIGHPOWER_RADIOA_ARRAYLEN 22 + +#define IQK_ADDA_REG_NUM 16 +#define IQK_MAC_REG_NUM 4 +#define IQK_BB_REG_NUM 9 +#define MAX_TOLERANCE 5 +#define IQK_DELAY_TIME 10 +#define index_mapping_NUM 15 + +#define APK_BB_REG_NUM 5 +#define APK_AFE_REG_NUM 16 +#define APK_CURVE_REG_NUM 4 +#define PATH_NUM 2 + +#define LOOP_LIMIT 5 +#define MAX_STALL_TIME 50 +#define AntennaDiversityValue 0x80 +#define MAX_TXPWR_IDX_NMODE_92S 63 +#define Reset_Cnt_Limit 3 + +#define RF6052_MAX_PATH 2 + +#define CT_OFFSET_MAC_ADDR 0X16 + +#define CT_OFFSET_CCK_TX_PWR_IDX 0x5A +#define CT_OFFSET_HT401S_TX_PWR_IDX 0x60 +#define CT_OFFSET_HT402S_TX_PWR_IDX_DIFF 0x66 +#define CT_OFFSET_HT20_TX_PWR_IDX_DIFF 0x69 +#define CT_OFFSET_OFDM_TX_PWR_IDX_DIFF 0x6C + +#define CT_OFFSET_HT40_MAX_PWR_OFFSET 0x6F +#define CT_OFFSET_HT20_MAX_PWR_OFFSET 0x72 + +#define CT_OFFSET_CHANNEL_PLAH 0x75 +#define CT_OFFSET_THERMAL_METER 0x78 +#define CT_OFFSET_RF_OPTION 0x79 +#define CT_OFFSET_VERSION 0x7E +#define CT_OFFSET_CUSTOMER_ID 0x7F + +#define RTL92C_MAX_PATH_NUM 2 + +enum swchnlcmd_id { + CMDID_END, + CMDID_SET_TXPOWEROWER_LEVEL, + CMDID_BBREGWRITE10, + CMDID_WRITEPORT_ULONG, + CMDID_WRITEPORT_USHORT, + CMDID_WRITEPORT_UCHAR, + CMDID_RF_WRITEREG, +}; + +struct swchnlcmd { + enum swchnlcmd_id cmdid; + u32 para1; + u32 para2; + u32 msdelay; +}; + +enum baseband_config_type { + BASEBAND_CONFIG_PHY_REG = 0, + BASEBAND_CONFIG_AGC_TAB = 1, +}; + +enum ant_div_type { + NO_ANTDIV = 0xFF, + CG_TRX_HW_ANTDIV = 0x01, + CGCS_RX_HW_ANTDIV = 0x02, + FIXED_HW_ANTDIV = 0x03, + CG_TRX_SMART_ANTDIV = 0x04, + CGCS_RX_SW_ANTDIV = 0x05, + +}; +extern u32 rtl92ee_phy_query_bb_reg(struct ieee80211_hw *hw, + u32 regaddr, u32 bitmask); +extern void rtl92ee_phy_set_bb_reg(struct ieee80211_hw *hw, + u32 regaddr, u32 bitmask, u32 data); +extern u32 rtl92ee_phy_query_rf_reg(struct ieee80211_hw *hw, + enum radio_path rfpath, u32 regaddr, + u32 bitmask); +extern void rtl92ee_phy_set_rf_reg(struct ieee80211_hw *hw, + enum radio_path rfpath, u32 regaddr, + u32 bitmask, u32 data); +extern bool rtl92ee_phy_mac_config(struct ieee80211_hw *hw); +extern bool rtl92ee_phy_bb_config(struct ieee80211_hw *hw); +extern bool rtl92ee_phy_rf_config(struct ieee80211_hw *hw); +extern void rtl92ee_phy_get_hw_reg_originalvalue(struct ieee80211_hw *hw); +extern void rtl92ee_phy_get_txpower_level(struct ieee80211_hw *hw, + long *powerlevel); +extern void rtl92ee_phy_set_txpower_level(struct ieee80211_hw *hw, u8 channel); +extern void rtl92ee_phy_scan_operation_backup(struct ieee80211_hw *hw, + u8 operation); +extern void rtl92ee_phy_set_bw_mode_callback(struct ieee80211_hw *hw); +extern void rtl92ee_phy_set_bw_mode(struct ieee80211_hw *hw, + enum nl80211_channel_type ch_type); +extern void rtl92ee_phy_sw_chnl_callback(struct ieee80211_hw *hw); +extern u8 rtl92ee_phy_sw_chnl(struct ieee80211_hw *hw); +extern void rtl92ee_phy_iq_calibrate(struct ieee80211_hw *hw, bool b_recovery); +void rtl92ee_phy_ap_calibrate(struct ieee80211_hw *hw, char delta); +void rtl92ee_phy_lc_calibrate(struct ieee80211_hw *hw); +void rtl92ee_phy_set_rfpath_switch(struct ieee80211_hw *hw, bool bmain); +bool rtl92ee_phy_config_rf_with_headerfile(struct ieee80211_hw *hw, + enum radio_path rfpath); +bool rtl92ee_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype); +extern bool rtl92ee_phy_set_rf_power_state(struct ieee80211_hw *hw, + enum rf_pwrstate rfpwr_state); +#endif diff --git a/drivers/staging/rtl8192ee/rtl8192ee/pwrseq.c b/drivers/staging/rtl8192ee/rtl8192ee/pwrseq.c new file mode 100644 index 000000000000..08a2df8dfd21 --- /dev/null +++ b/drivers/staging/rtl8192ee/rtl8192ee/pwrseq.c @@ -0,0 +1,108 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#include "pwrseqcmd.h" +#include "pwrseq.h" + + +/* + drivers should parse below arrays and do the corresponding actions +*/ +/*3 Power on Array*/ +struct wlan_pwr_cfg rtl8192E_power_on_flow[RTL8192E_TRANS_CARDEMU_TO_ACT_STEPS + + RTL8192E_TRANS_END_STEPS] = { + RTL8192E_TRANS_CARDEMU_TO_ACT + RTL8192E_TRANS_END +}; + +/*3Radio off GPIO Array */ +struct wlan_pwr_cfg rtl8192E_radio_off_flow[RTL8192E_TRANS_ACT_TO_CARDEMU_STEPS + + RTL8192E_TRANS_END_STEPS] = { + RTL8192E_TRANS_ACT_TO_CARDEMU + RTL8192E_TRANS_END +}; + +/*3Card Disable Array*/ +struct wlan_pwr_cfg rtl8192E_card_disable_flow + [RTL8192E_TRANS_ACT_TO_CARDEMU_STEPS + + RTL8192E_TRANS_CARDEMU_TO_PDN_STEPS + + RTL8192E_TRANS_END_STEPS] = { + RTL8192E_TRANS_ACT_TO_CARDEMU + RTL8192E_TRANS_CARDEMU_TO_CARDDIS + RTL8192E_TRANS_END +}; + +/*3 Card Enable Array*/ +struct wlan_pwr_cfg rtl8192E_card_enable_flow + [RTL8192E_TRANS_ACT_TO_CARDEMU_STEPS + + RTL8192E_TRANS_CARDEMU_TO_PDN_STEPS + + RTL8192E_TRANS_END_STEPS] = { + RTL8192E_TRANS_CARDDIS_TO_CARDEMU + RTL8192E_TRANS_CARDEMU_TO_ACT + RTL8192E_TRANS_END +}; + +/*3Suspend Array*/ +struct wlan_pwr_cfg rtl8192E_suspend_flow[RTL8192E_TRANS_ACT_TO_CARDEMU_STEPS + + RTL8192E_TRANS_CARDEMU_TO_SUS_STEPS + + RTL8192E_TRANS_END_STEPS] = { + RTL8192E_TRANS_ACT_TO_CARDEMU + RTL8192E_TRANS_CARDEMU_TO_SUS + RTL8192E_TRANS_END +}; + +/*3 Resume Array*/ +struct wlan_pwr_cfg rtl8192E_resume_flow[RTL8192E_TRANS_ACT_TO_CARDEMU_STEPS + + RTL8192E_TRANS_CARDEMU_TO_SUS_STEPS + + RTL8192E_TRANS_END_STEPS] = { + RTL8192E_TRANS_SUS_TO_CARDEMU + RTL8192E_TRANS_CARDEMU_TO_ACT + RTL8192E_TRANS_END +}; + +/*3HWPDN Array*/ +struct wlan_pwr_cfg rtl8192E_hwpdn_flow[RTL8192E_TRANS_ACT_TO_CARDEMU_STEPS + + RTL8192E_TRANS_CARDEMU_TO_PDN_STEPS + + RTL8192E_TRANS_END_STEPS] = { + RTL8192E_TRANS_ACT_TO_CARDEMU + RTL8192E_TRANS_CARDEMU_TO_PDN + RTL8192E_TRANS_END +}; + +/*3 Enter LPS */ +struct wlan_pwr_cfg rtl8192E_enter_lps_flow[RTL8192E_TRANS_ACT_TO_LPS_STEPS + + RTL8192E_TRANS_END_STEPS] = { + /*FW behavior*/ + RTL8192E_TRANS_ACT_TO_LPS + RTL8192E_TRANS_END +}; + +/*3 Leave LPS */ +struct wlan_pwr_cfg rtl8192E_leave_lps_flow[RTL8192E_TRANS_LPS_TO_ACT_STEPS + + RTL8192E_TRANS_END_STEPS] = { + /*FW behavior*/ + RTL8192E_TRANS_LPS_TO_ACT + RTL8192E_TRANS_END +}; diff --git a/drivers/staging/rtl8192ee/rtl8192ee/pwrseq.h b/drivers/staging/rtl8192ee/rtl8192ee/pwrseq.h new file mode 100644 index 000000000000..528897213224 --- /dev/null +++ b/drivers/staging/rtl8192ee/rtl8192ee/pwrseq.h @@ -0,0 +1,355 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#ifndef __RTL92E_PWRSEQ_H__ +#define __RTL92E_PWRSEQ_H__ + +#include "pwrseqcmd.h" +/* + Check document WM-20110607-Paul-RTL8192E_Power_Architecture-R02.vsd + There are 6 HW Power States: + 0: POFF--Power Off + 1: PDN--Power Down + 2: CARDEMU--Card Emulation + 3: ACT--Active Mode + 4: LPS--Low Power State + 5: SUS--Suspend + + The transision from different states are defined below + TRANS_CARDEMU_TO_ACT + TRANS_ACT_TO_CARDEMU + TRANS_CARDEMU_TO_SUS + TRANS_SUS_TO_CARDEMU + TRANS_CARDEMU_TO_PDN + TRANS_ACT_TO_LPS + TRANS_LPS_TO_ACT + + TRANS_END + PWR SEQ Version: rtl8192E_PwrSeq_V09.h +*/ + +#define RTL8192E_TRANS_CARDEMU_TO_ACT_STEPS 18 +#define RTL8192E_TRANS_ACT_TO_CARDEMU_STEPS 18 +#define RTL8192E_TRANS_CARDEMU_TO_SUS_STEPS 18 +#define RTL8192E_TRANS_SUS_TO_CARDEMU_STEPS 18 +#define RTL8192E_TRANS_CARDEMU_TO_PDN_STEPS 18 +#define RTL8192E_TRANS_PDN_TO_CARDEMU_STEPS 18 +#define RTL8192E_TRANS_ACT_TO_LPS_STEPS 23 +#define RTL8192E_TRANS_LPS_TO_ACT_STEPS 23 +#define RTL8192E_TRANS_END_STEPS 1 + + +#define RTL8192E_TRANS_CARDEMU_TO_ACT \ + /* format */ \ + /* comments here */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value },*/\ + /* disable HWPDN 0x04[15]=0*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, BIT(7), 0}, \ + /* disable SW LPS 0x04[10]=0*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, BIT(2), 0}, \ + /* disable WL suspend*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, (BIT(4)|BIT(3)), 0}, \ + /* wait till 0x04[17] = 1 power ready*/ \ + {0x0006, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_POLLING, BIT(1), BIT(1)}, \ + /* release WLON reset 0x04[16]=1*/ \ + {0x0006, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, BIT(0), BIT(0)}, \ + /* polling until return 0*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, BIT(0), BIT(0)}, \ + /**/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_POLLING, BIT(0), 0}, + + +#define RTL8192E_TRANS_ACT_TO_CARDEMU \ + /* format */ \ + /* comments here */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value },*/\ + /*0x1F[7:0] = 0 turn off RF*/ \ + {0x001F, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, 0xFF, 0}, \ + /*0x4C[23]=0x4E[7]=0, switch DPDT_SEL_P output from register 0x65[2] */\ + {0x004E, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, BIT(7), 0}, \ + /*0x04[9] = 1 turn off MAC by HW state machine*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, BIT(1), BIT(1)}, \ + /*wait till 0x04[9] = 0 polling until return 0 to disable*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_POLLING, BIT(1), 0}, + + +#define RTL8192E_TRANS_CARDEMU_TO_SUS \ + /* format */ \ + /* comments here */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value },*/\ + /*0x04[12:11] = 2b'11 enable WL suspend for PCIe*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, BIT(4) | BIT(3), (BIT(4) | BIT(3))},\ + /*0x04[12:11] = 2b'01 enable WL suspend*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ + PWR_INTF_USB_MSK | PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, \ + PWR_CMD_WRITE, BIT(3)|BIT(4), BIT(3)}, \ + /*0x04[12:11] = 2b'11 enable WL suspend for PCIe*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, BIT(3) | BIT(4), BIT(3) | BIT(4)},\ + /*Set SDIO suspend local register*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, \ + PWR_BASEADDR_SDIO , PWR_CMD_WRITE, BIT(0), BIT(0)}, \ + /*wait power state to suspend*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, \ + PWR_BASEADDR_SDIO , PWR_CMD_POLLING, BIT(1), 0}, + + +#define RTL8192E_TRANS_SUS_TO_CARDEMU \ + /* format */ \ + /* comments here */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value },*/\ + /*Set SDIO suspend local register*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, \ + PWR_BASEADDR_SDIO , PWR_CMD_WRITE, BIT(0), 0}, \ + /*wait power state to suspend*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, \ + PWR_BASEADDR_SDIO , PWR_CMD_POLLING, BIT(1), BIT(1)}, \ + /*0x04[12:11] = 2b'01enable WL suspend*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, BIT(3) | BIT(4), 0}, + + +#define RTL8192E_TRANS_CARDEMU_TO_CARDDIS \ + /* format */ \ + /* comments here */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value },*/\ + /*0x07=0x20 , SOP option to disable BG/MB*/ \ + {0x0007, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, 0xFF, 0x20}, \ + /*Unlock small LDO Register*/ \ + {0x00CC, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, BIT(2), BIT(2)}, \ + /*Disable small LDO*/ \ + {0x0011, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, BIT(0), 0}, \ + /*0x04[12:11] = 2b'01 enable WL suspend*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ + PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK,PWR_BASEADDR_MAC, \ + PWR_CMD_WRITE, BIT(3)|BIT(4), BIT(3)}, \ + /*0x04[10] = 1, enable SW LPS*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, BIT(2), BIT(2)}, \ + /*Set SDIO suspend local register*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, \ + PWR_BASEADDR_SDIO , PWR_CMD_WRITE, BIT(0), BIT(0)}, \ + /*wait power state to suspend*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, \ + PWR_BASEADDR_SDIO , PWR_CMD_POLLING, BIT(1), 0}, + + +#define RTL8192E_TRANS_CARDDIS_TO_CARDEMU \ + /* format */ \ + /* comments here */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value },*/\ + /*Set SDIO suspend local register*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, \ + PWR_BASEADDR_SDIO , PWR_CMD_WRITE, BIT(0), 0}, \ + /*wait power state to suspend*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, \ + PWR_BASEADDR_SDIO , PWR_CMD_POLLING, BIT(1), BIT(1)}, \ + /*Enable small LDO*/ \ + {0x0011, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, BIT(0), BIT(0)}, \ + /*Lock small LDO Register*/ \ + {0x00CC, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, BIT(2), 0}, \ + /*0x04[12:11] = 2b'01enable WL suspend*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, BIT(3) | BIT(4), 0}, + + +#define RTL8192E_TRANS_CARDEMU_TO_PDN \ + /* format */ \ + /* comments here */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value },*/\ + /* 0x04[16] = 0*/ \ + {0x0006, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, BIT(0), 0}, \ + /* 0x04[15] = 1*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, BIT(7), BIT(7)}, + + +#define RTL8192E_TRANS_PDN_TO_CARDEMU \ + /* format */ \ + /* comments here */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value },*/\ + /* 0x04[15] = 0*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, BIT(7), 0}, + + +#define RTL8192E_TRANS_ACT_TO_LPS \ + /* format */ \ + /* comments here */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value },*/\ + /*PCIe DMA stop*/ \ + {0x0301, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, 0xFF, 0xFF}, \ + /*Tx Pause*/ \ + {0x0522, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, 0xFF, 0xFF}, \ + /*Should be zero if no packet is transmitting*/ \ + {0x05F8, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_POLLING, 0xFF, 0}, \ + /*Should be zero if no packet is transmitting*/ \ + {0x05F9, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_POLLING, 0xFF, 0}, \ + /*Should be zero if no packet is transmitting*/ \ + {0x05FA, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_POLLING, 0xFF, 0}, \ + /*Should be zero if no packet is transmitting*/ \ + {0x05FB, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_POLLING, 0xFF, 0}, \ + /*CCK and OFDM are disabled,and clock are gated*/ \ + {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, BIT(0), 0}, \ + /*Delay 1us*/ \ + {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_DELAY, 0, PWRSEQ_DELAY_US}, \ + /*Whole BB is reset*/ \ + {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, BIT(1), 0}, \ + /*Reset MAC TRX*/ \ + {0x0100, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, 0xFF, 0x03}, \ + /*check if removed later*/ \ + {0x0101, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, BIT(1), 0}, \ + /*When driver enter Sus/ Disable, enable LOP for BT*/ \ + {0x0093, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, 0xFF, 0x00}, \ + /*Respond TxOK to scheduler*/ \ + {0x0553, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, BIT(5), BIT(5)}, + + +#define RTL8192E_TRANS_LPS_TO_ACT \ + /* format */ \ + /* comments here */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value },*/\ + /*SDIO RPWM, For Repeatly In and out, Taggle bit should be changed*/\ + {0x0080, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, \ + PWR_BASEADDR_SDIO , PWR_CMD_WRITE, 0xFF, 0x84}, \ + /*USB RPWM*/ \ + {0xFE58, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, 0xFF, 0x84}, \ + /*PCIe RPWM*/ \ + {0x0361, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, 0xFF, 0x84}, \ + /*Delay*/ \ + {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_DELAY, 0, PWRSEQ_DELAY_MS}, \ + /*0x08[4] = 0 switch TSF to 40M*/ \ + {0x0008, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, BIT(4), 0}, \ + /*Polling 0x109[7]=0 TSF in 40M*/ \ + {0x0109, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_POLLING, BIT(7), 0}, \ + /*0x101[1] = 1*/ \ + {0x0101, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, BIT(1), BIT(1)}, \ + /*0x100[7:0] = 0xFF enable WMAC TRX*/ \ + {0x0100, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, 0xFF, 0xFF}, \ + /* 0x02[1:0] = 2b'11 enable BB macro*/ \ + {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, BIT(1) | BIT(0), BIT(1) | BIT(0)},\ + /*0x522 = 0*/ \ + {0x0522, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, 0xFF, 0}, \ + /*Clear ISR*/ \ + {0x013D, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + PWR_BASEADDR_MAC , PWR_CMD_WRITE, 0xFF, 0xFF}, + + +#define RTL8192E_TRANS_END \ + /* format */ \ + /* comments here */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value },*/\ + {0xFFFF, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, \ + 0, PWR_CMD_END, 0, 0}, + +extern struct wlan_pwr_cfg rtl8192E_power_on_flow + [RTL8192E_TRANS_CARDEMU_TO_ACT_STEPS + + RTL8192E_TRANS_END_STEPS]; +extern struct wlan_pwr_cfg rtl8192E_radio_off_flow + [RTL8192E_TRANS_ACT_TO_CARDEMU_STEPS + + RTL8192E_TRANS_END_STEPS]; +extern struct wlan_pwr_cfg rtl8192E_card_disable_flow + [RTL8192E_TRANS_ACT_TO_CARDEMU_STEPS + + RTL8192E_TRANS_CARDEMU_TO_PDN_STEPS + + RTL8192E_TRANS_END_STEPS]; +extern struct wlan_pwr_cfg rtl8192E_card_enable_flow + [RTL8192E_TRANS_ACT_TO_CARDEMU_STEPS + + RTL8192E_TRANS_CARDEMU_TO_PDN_STEPS + + RTL8192E_TRANS_END_STEPS]; +extern struct wlan_pwr_cfg rtl8192E_suspend_flow + [RTL8192E_TRANS_ACT_TO_CARDEMU_STEPS + + RTL8192E_TRANS_CARDEMU_TO_SUS_STEPS + + RTL8192E_TRANS_END_STEPS]; +extern struct wlan_pwr_cfg rtl8192E_resume_flow + [RTL8192E_TRANS_ACT_TO_CARDEMU_STEPS + + RTL8192E_TRANS_CARDEMU_TO_SUS_STEPS + + RTL8192E_TRANS_END_STEPS]; +extern struct wlan_pwr_cfg rtl8192E_hwpdn_flow + [RTL8192E_TRANS_ACT_TO_CARDEMU_STEPS + + RTL8192E_TRANS_CARDEMU_TO_PDN_STEPS + + RTL8192E_TRANS_END_STEPS]; +extern struct wlan_pwr_cfg rtl8192E_enter_lps_flow + [RTL8192E_TRANS_ACT_TO_LPS_STEPS + + RTL8192E_TRANS_END_STEPS]; +extern struct wlan_pwr_cfg rtl8192E_leave_lps_flow + [RTL8192E_TRANS_LPS_TO_ACT_STEPS + + RTL8192E_TRANS_END_STEPS]; + + +/* RTL8192EE Power Configuration CMDs for PCIe interface */ +#define Rtl8192E_NIC_PWR_ON_FLOW rtl8192E_power_on_flow +#define Rtl8192E_NIC_RF_OFF_FLOW rtl8192E_radio_off_flow +#define Rtl8192E_NIC_DISABLE_FLOW rtl8192E_card_disable_flow +#define Rtl8192E_NIC_ENABLE_FLOW rtl8192E_card_enable_flow +#define Rtl8192E_NIC_SUSPEND_FLOW rtl8192E_suspend_flow +#define Rtl8192E_NIC_RESUME_FLOW rtl8192E_resume_flow +#define Rtl8192E_NIC_PDN_FLOW rtl8192E_hwpdn_flow +#define Rtl8192E_NIC_LPS_ENTER_FLOW rtl8192E_enter_lps_flow +#define Rtl8192E_NIC_LPS_LEAVE_FLOW rtl8192E_leave_lps_flow +#endif diff --git a/drivers/staging/rtl8192ee/rtl8192ee/pwrseqcmd.c b/drivers/staging/rtl8192ee/rtl8192ee/pwrseqcmd.c new file mode 100644 index 000000000000..efb00f622361 --- /dev/null +++ b/drivers/staging/rtl8192ee/rtl8192ee/pwrseqcmd.c @@ -0,0 +1,139 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#include "pwrseq.h" + + +/* +* Description: +* This routine deal with the Power Configuration CMDs +* parsing for RTL8723/RTL8188E Series IC. +* Assumption: +* We should follow specific format which was released from HW SD. +* +* 2011.07.07, added by Roger. +*/ +bool rtl92e_hal_pwrseqcmdparsing(struct rtl_priv *rtlpriv, u8 cut_version, + u8 fab_version, u8 interface_type, + struct wlan_pwr_cfg pwrcfgcmd[]) + +{ + struct wlan_pwr_cfg pwr_cfg_cmd = {0}; + bool b_polling_bit = false; + u32 ary_idx = 0; + u8 value = 0; + u32 offset = 0; + u32 polling_count = 0; + u32 max_polling_cnt = 5000; + + do { + pwr_cfg_cmd = pwrcfgcmd[ary_idx]; + RT_TRACE(COMP_INIT, DBG_TRACE, + ("offset(%#x), cut_msk(%#x), fab_msk(%#x), interface_msk(%#x), base(%#x), cmd(%#x), msk(%#x), value(%#x)\n", + GET_PWR_CFG_OFFSET(pwr_cfg_cmd), + GET_PWR_CFG_CUT_MASK(pwr_cfg_cmd), + GET_PWR_CFG_FAB_MASK(pwr_cfg_cmd), + GET_PWR_CFG_INTF_MASK(pwr_cfg_cmd), + GET_PWR_CFG_BASE(pwr_cfg_cmd), + GET_PWR_CFG_CMD(pwr_cfg_cmd), + GET_PWR_CFG_MASK(pwr_cfg_cmd), + GET_PWR_CFG_VALUE(pwr_cfg_cmd))); + + if ((GET_PWR_CFG_FAB_MASK(pwr_cfg_cmd)&fab_version) && + (GET_PWR_CFG_CUT_MASK(pwr_cfg_cmd)&cut_version) && + (GET_PWR_CFG_INTF_MASK(pwr_cfg_cmd)&interface_type)) { + switch (GET_PWR_CFG_CMD(pwr_cfg_cmd)) { + case PWR_CMD_READ: + RT_TRACE(COMP_INIT, DBG_TRACE, + ("PWR_CMD_READ\n")); + break; + + case PWR_CMD_WRITE: + RT_TRACE(COMP_INIT, DBG_TRACE, + ("PWR_CMD_WRITE\n")); + offset = GET_PWR_CFG_OFFSET(pwr_cfg_cmd); + + /*Read the value from system register*/ + value = rtl_read_byte(rtlpriv, offset); + value &= (~(GET_PWR_CFG_MASK(pwr_cfg_cmd))); + value |= (GET_PWR_CFG_VALUE(pwr_cfg_cmd) & + GET_PWR_CFG_MASK(pwr_cfg_cmd)); + + /*Write value back to sytem register*/ + rtl_write_byte(rtlpriv, offset, value); + break; + + case PWR_CMD_POLLING: + RT_TRACE(COMP_INIT, DBG_TRACE, + ("PWR_CMD_POLLING\n")); + b_polling_bit = false; + offset = GET_PWR_CFG_OFFSET(pwr_cfg_cmd); + + do { + value = rtl_read_byte(rtlpriv, offset); + + value &= GET_PWR_CFG_MASK(pwr_cfg_cmd); + if (value == + (GET_PWR_CFG_VALUE(pwr_cfg_cmd) & + GET_PWR_CFG_MASK(pwr_cfg_cmd))) + b_polling_bit = true; + else + udelay(10); + + if (polling_count++ > max_polling_cnt) { + RT_TRACE(COMP_INIT, DBG_LOUD, + ("polling fail\n")); + return false; + } + } while (!b_polling_bit); + + break; + + case PWR_CMD_DELAY: + RT_TRACE(COMP_INIT, DBG_TRACE, + ("PWR_CMD_DELAY\n")); + if (GET_PWR_CFG_VALUE(pwr_cfg_cmd) == + PWRSEQ_DELAY_US) + udelay(GET_PWR_CFG_OFFSET(pwr_cfg_cmd)); + else + mdelay(GET_PWR_CFG_OFFSET(pwr_cfg_cmd)); + break; + + case PWR_CMD_END: + RT_TRACE(COMP_INIT, DBG_TRACE, + ("PWR_CMD_END\n")); + return true; + break; + + default: + RT_ASSERT(false, ("Unknown CMD!!\n")); + break; + } + } + + ary_idx++; + } while (1); + return true; +} diff --git a/drivers/staging/rtl8192ee/rtl8192ee/pwrseqcmd.h b/drivers/staging/rtl8192ee/rtl8192ee/pwrseqcmd.h new file mode 100644 index 000000000000..ec40ea8b8c26 --- /dev/null +++ b/drivers/staging/rtl8192ee/rtl8192ee/pwrseqcmd.h @@ -0,0 +1,69 @@ +#ifndef __RTL92E_PWRSEQCMD_H__ +#define __RTL92E_PWRSEQCMD_H__ + +#include "../wifi.h" +/*---------------------------------------------*/ +/* The value of cmd: 4 bits */ +/*---------------------------------------------*/ +#define PWR_CMD_READ 0x00 +#define PWR_CMD_WRITE 0x01 +#define PWR_CMD_POLLING 0x02 +#define PWR_CMD_DELAY 0x03 +#define PWR_CMD_END 0x04 + +/* define the base address of each block */ +#define PWR_BASEADDR_MAC 0x00 +#define PWR_BASEADDR_USB 0x01 +#define PWR_BASEADDR_PCIE 0x02 +#define PWR_BASEADDR_SDIO 0x03 + +#define PWR_INTF_SDIO_MSK BIT(0) +#define PWR_INTF_USB_MSK BIT(1) +#define PWR_INTF_PCI_MSK BIT(2) +#define PWR_INTF_ALL_MSK (BIT(0) | BIT(1) | BIT(2) | BIT(3)) + +#define PWR_FAB_TSMC_MSK BIT(0) +#define PWR_FAB_UMC_MSK BIT(1) +#define PWR_FAB_ALL_MSK (BIT(0) | BIT(1) | BIT(2) | BIT(3)) + +#define PWR_CUT_TESTCHIP_MSK BIT(0) +#define PWR_CUT_A_MSK BIT(1) +#define PWR_CUT_B_MSK BIT(2) +#define PWR_CUT_C_MSK BIT(3) +#define PWR_CUT_D_MSK BIT(4) +#define PWR_CUT_E_MSK BIT(5) +#define PWR_CUT_F_MSK BIT(6) +#define PWR_CUT_G_MSK BIT(7) +#define PWR_CUT_ALL_MSK 0xFF + + +enum pwrseq_delay_unit { + PWRSEQ_DELAY_US, + PWRSEQ_DELAY_MS, +}; + +struct wlan_pwr_cfg { + u16 offset; + u8 cut_msk; + u8 fab_msk:4; + u8 interface_msk:4; + u8 base:4; + u8 cmd:4; + u8 msk; + u8 value; +}; + +#define GET_PWR_CFG_OFFSET(__PWR_CMD) __PWR_CMD.offset +#define GET_PWR_CFG_CUT_MASK(__PWR_CMD) __PWR_CMD.cut_msk +#define GET_PWR_CFG_FAB_MASK(__PWR_CMD) __PWR_CMD.fab_msk +#define GET_PWR_CFG_INTF_MASK(__PWR_CMD) __PWR_CMD.interface_msk +#define GET_PWR_CFG_BASE(__PWR_CMD) __PWR_CMD.base +#define GET_PWR_CFG_CMD(__PWR_CMD) __PWR_CMD.cmd +#define GET_PWR_CFG_MASK(__PWR_CMD) __PWR_CMD.msk +#define GET_PWR_CFG_VALUE(__PWR_CMD) __PWR_CMD.value + +bool rtl92e_hal_pwrseqcmdparsing(struct rtl_priv *rtlpriv, u8 cut_version, + u8 fab_version, u8 interface_type, + struct wlan_pwr_cfg pwrcfgcmd[]); + +#endif diff --git a/drivers/staging/rtl8192ee/rtl8192ee/reg.h b/drivers/staging/rtl8192ee/rtl8192ee/reg.h new file mode 100644 index 000000000000..08c07577239f --- /dev/null +++ b/drivers/staging/rtl8192ee/rtl8192ee/reg.h @@ -0,0 +1,2240 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#ifndef __RTL92E_REG_H__ +#define __RTL92E_REG_H__ + +#define TXPKT_BUF_SELECT 0x69 +#define RXPKT_BUF_SELECT 0xA5 +#define DISABLE_TRXPKT_BUF_ACCESS 0x0 + +#define REG_SYS_ISO_CTRL 0x0000 +#define REG_SYS_FUNC_EN 0x0002 +#define REG_APS_FSMCO 0x0004 +#define REG_SYS_CLKR 0x0008 +#define REG_9346CR 0x000A +#define REG_EE_VPD 0x000C +#define REG_SYS_SWR_CTRL1 0x0010 +#define REG_SPS0_CTRL 0x0011 +#define REG_SYS_SWR_CTRL2 0x0014 +#define REG_SYS_SWR_CTRL3 0x0018 +#define REG_RSV_CTRL 0x001C +#define REG_RF_CTRL 0x001F +#define REG_LPLDO_CTRL 0x0023 +#define REG_AFE_CTRL1 0x0024 +#define REG_AFE_XTAL_CTRL 0x0024 +#define REG_AFE_CTRL2 0x0028 +#define REG_MAC_PHY_CTRL 0x002c +#define REG_AFE_CTRL3 0x002c +#define REG_EFUSE_CTRL 0x0030 +#define REG_EFUSE_TEST 0x0034 +#define REG_PWR_DATA 0x0038 +#define REG_CAL_TIMER 0x003C +#define REG_ACLK_MON 0x003E +#define REG_GPIO_MUXCFG 0x0040 +#define REG_GPIO_IO_SEL 0x0042 +#define REG_MAC_PINMUX_CFG 0x0043 +#define REG_GPIO_PIN_CTRL 0x0044 +#define REG_GPIO_INTM 0x0048 +#define REG_LEDCFG0 0x004C +#define REG_LEDCFG1 0x004D +#define REG_LEDCFG2 0x004E +#define REG_LEDCFG3 0x004F +#define REG_FSIMR 0x0050 +#define REG_FSISR 0x0054 +#define REG_HSIMR 0x0058 +#define REG_HSISR 0x005c +#define REG_SDIO_CTRL 0x0070 +#define REG_OPT_CTRL 0x0074 +#define REG_GPIO_OUTPUT 0x006c +#define REG_AFE_CTRL4 0x0078 +#define REG_MCUFWDL 0x0080 + +#define REG_HIMR 0x00B0 +#define REG_HISR 0x00B4 +#define REG_HIMRE 0x00B8 +#define REG_HISRE 0x00BC + +#define REG_EFUSE_ACCESS 0x00CF +#define REG_HPON_FSM 0x00EC +#define REG_SYS_CFG1 0x00F0 +#define REG_SYS_CFG2 0x00FC + + +#define REG_CR 0x0100 +#define REG_PBP 0x0104 +#define REG_PKT_BUFF_ACCESS_CTRL 0x0106 +#define REG_TRXDMA_CTRL 0x010C +#define REG_TRXFF_BNDY 0x0114 +#define REG_TRXFF_STATUS 0x0118 +#define REG_RXFF_PTR 0x011C + +#define REG_CPWM 0x012F +#define REG_FWIMR 0x0130 +#define REG_FWISR 0x0134 +#define REG_PKTBUF_DBG_CTRL 0x0140 +#define REG_RXPKTBUF_CTRL 0x0142 +#define REG_PKTBUF_DBG_DATA_L 0x0144 +#define REG_PKTBUF_DBG_DATA_H 0x0148 + +#define REG_TC0_CTRL 0x0150 +#define REG_TC1_CTRL 0x0154 +#define REG_TC2_CTRL 0x0158 +#define REG_TC3_CTRL 0x015C +#define REG_TC4_CTRL 0x0160 +#define REG_TCUNIT_BASE 0x0164 +#define REG_RSVD3 0x0168 +#define REG_C2HEVT_MSG_NORMAL 0x01A0 +#define REG_C2HEVT_CLEAR 0x01AF +#define REG_MCUTST_1 0x01c0 +#define REG_MCUTST_WOWLAN 0x01C7 +#define REG_FMETHR 0x01C8 +#define REG_HMETFR 0x01CC +#define REG_HMEBOX_0 0x01D0 +#define REG_HMEBOX_1 0x01D4 +#define REG_HMEBOX_2 0x01D8 +#define REG_HMEBOX_3 0x01DC + +#define REG_LLT_INIT 0x01E0 + +#define REG_HMEBOX_EXT_0 0x01F0 +#define REG_HMEBOX_EXT_1 0x01F4 +#define REG_HMEBOX_EXT_2 0x01F8 +#define REG_HMEBOX_EXT_3 0x01FC + +/*----------------------------------------------------- + * + * 0x0200h ~ 0x027Fh TXDMA Configuration + * + *-----------------------------------------------------*/ +#define REG_RQPN 0x0200 +#define REG_FIFOPAGE 0x0204 +#define REG_DWBCN0_CTRL 0x0208 +#define REG_TXDMA_OFFSET_CHK 0x020C +#define REG_TXDMA_STATUS 0x0210 +#define REG_RQPN_NPQ 0x0214 +#define REG_AUTO_LLT 0x0224 +#define REG_DWBCN1_CTRL 0x0228 + +/*----------------------------------------------------- + * + * 0x0280h ~ 0x02FFh RXDMA Configuration + * + *-----------------------------------------------------*/ +#define REG_RXDMA_AGG_PG_TH 0x0280 +#define REG_FW_UPD_RDPTR 0x0284 +#define REG_RXDMA_CONTROL 0x0286 +#define REG_RXPKT_NUM 0x0287 +#define REG_RXDMA_STATUS 0x0288 +#define REG_RXDMA_PRO 0x0290 +#define REG_EARLY_MODE_CONTROL 0x02BC +#define REG_RSVD5 0x02F0 +#define REG_RSVD6 0x02F4 + +/*----------------------------------------------------- + * + * 0x0300h ~ 0x03FFh PCIe + * + *-----------------------------------------------------*/ +#define REG_PCIE_CTRL_REG 0x0300 +#define REG_INT_MIG 0x0304 +#define REG_BCNQ_DESA 0x0308 +#define REG_MGQ_DESA 0x0310 +#define REG_VOQ_DESA 0x0318 +#define REG_VIQ_DESA 0x0320 +#define REG_BEQ_DESA 0x0328 +#define REG_BKQ_DESA 0x0330 +#define REG_RX_DESA 0x0338 +#define REG_HQ0_DESA 0x0340 +#define REG_HQ1_DESA 0x0348 +#define REG_HQ2_DESA 0x0350 +#define REG_HQ3_DESA 0x0358 +#define REG_HQ4_DESA 0x0360 +#define REG_HQ5_DESA 0x0368 +#define REG_HQ6_DESA 0x0370 +#define REG_HQ7_DESA 0x0378 +#define REG_MGQ_TXBD_NUM 0x0380 +#define REG_RX_RXBD_NUM 0x0382 +#define REG_VOQ_TXBD_NUM 0x0384 +#define REG_VIQ_TXBD_NUM 0x0386 +#define REG_BEQ_TXBD_NUM 0x0388 +#define REG_BKQ_TXBD_NUM 0x038A +#define REG_HI0Q_TXBD_NUM 0x038C +#define REG_HI1Q_TXBD_NUM 0x038E +#define REG_HI2Q_TXBD_NUM 0x0390 +#define REG_HI3Q_TXBD_NUM 0x0392 +#define REG_HI4Q_TXBD_NUM 0x0394 +#define REG_HI5Q_TXBD_NUM 0x0396 +#define REG_HI6Q_TXBD_NUM 0x0398 +#define REG_HI7Q_TXBD_NUM 0x039A +#define REG_TSFTIMER_HCI 0x039C +/*Read Write Point*/ +#define REG_VOQ_TXBD_IDX 0x03A0 +#define REG_VIQ_TXBD_IDX 0x03A4 +#define REG_BEQ_TXBD_IDX 0x03A8 +#define REG_BKQ_TXBD_IDX 0x03AC +#define REG_MGQ_TXBD_IDX 0x03B0 +#define REG_RXQ_TXBD_IDX 0x03B4 + +#define REG_HI0Q_TXBD_IDX 0x03B8 +#define REG_HI1Q_TXBD_IDX 0x03BC +#define REG_HI2Q_TXBD_IDX 0x03C0 +#define REG_HI3Q_TXBD_IDX 0x03C4 + +#define REG_HI4Q_TXBD_IDX 0x03C8 +#define REG_HI5Q_TXBD_IDX 0x03CC +#define REG_HI6Q_TXBD_IDX 0x03D0 +#define REG_HI7Q_TXBD_IDX 0x03D4 +#define REG_PCIE_HCPWM 0x03D8 +#define REG_PCIE_CTRL2 0x03DB +#define REG_PCIE_HRPWM 0x03DC +#define REG_H2C_MSG_DRV2FW_INFO 0x03E0 +#define REG_PCIE_C2H_MSG_REQUEST 0x03E4 +#define REG_BACKDOOR_DBI_WDATA 0x03E8 +#define REG_BACKDOOR_DBI_RDATA 0x03EC +#define REG_BACKDOOR_DBI_DATA 0x03F0 +#define REG_MDIO 0x03F4 +#define REG_MDIO_DATA 0x03F8 + +#define REG_HDAQ_DESA_NODEF 0x0000 +#define REG_CMDQ_DESA_NODEF 0x0000 +/* spec version 11 + *----------------------------------------------------- + * + * 0x0400h ~ 0x047Fh Protocol Configuration + * + *-----------------------------------------------------*/ +#define REG_VOQ_INFORMATION 0x0400 +#define REG_VIQ_INFORMATION 0x0404 +#define REG_BEQ_INFORMATION 0x0408 +#define REG_BKQ_INFORMATION 0x040C +#define REG_MGQ_INFORMATION 0x0410 +#define REG_HGQ_INFORMATION 0x0414 +#define REG_BCNQ_INFORMATION 0x0418 +#define REG_TXPKT_EMPTY 0x041A + + +#define REG_FWHW_TXQ_CTRL 0x0420 +#define REG_HWSEQ_CTRL 0x0423 +#define REG_BCNQ_BDNY 0x0424 +#define REG_MGQ_BDNY 0x0425 +#define REG_LIFECTRL_CTRL 0x0426 +#define REG_MULTI_BCNQ_OFFSET 0x0427 +#define REG_SPEC_SIFS 0x0428 +#define REG_RETRY_LIMIT 0x042A +#define REG_TXBF_CTRL 0x042C +#define REG_DARFRC 0x0430 +#define REG_RARFRC 0x0438 +#define REG_RRSR 0x0440 +#define REG_ARFR0 0x0444 +#define REG_ARFR1 0x044C +#define REG_AMPDU_MAX_TIME 0x0456 +#define REG_BCNQ1_BDNY 0x0457 +#define REG_AGGLEN_LMT 0x0458 +#define REG_AMPDU_MIN_SPACE 0x045C +#define REG_TXPKTBUF_WMAC_LBK_BF_HD 0x045D +#define REG_NDPA_OPT_CTRL 0x045F +#define REG_FAST_EDCA_CTRL 0x0460 +#define REG_RD_RESP_PKT_TH 0x0463 +#define REG_POWER_STAGE1 0x04B4 +#define REG_POWER_STAGE2 0x04B8 +#define REG_AMPDU_BURST_MODE 0x04BC +#define REG_PKT_VO_VI_LIFE_TIME 0x04C0 +#define REG_PKT_BE_BK_LIFE_TIME 0x04C2 +#define REG_STBC_SETTING 0x04C4 +#define REG_PROT_MODE_CTRL 0x04C8 +#define REG_MAX_AGGR_NUM 0x04CA +#define REG_RTS_MAX_AGGR_NUM 0x04CB +#define REG_BAR_MODE_CTRL 0x04CC +#define REG_RA_TRY_RATE_AGG_LMT 0x04CF +#define REG_MACID_PKT_DROP0 0x04D0 + +/*----------------------------------------------------- + * + * 0x0500h ~ 0x05FFh EDCA Configuration + * + *-----------------------------------------------------*/ +#define REG_EDCA_VO_PARAM 0x0500 +#define REG_EDCA_VI_PARAM 0x0504 +#define REG_EDCA_BE_PARAM 0x0508 +#define REG_EDCA_BK_PARAM 0x050C +#define REG_BCNTCFG 0x0510 +#define REG_PIFS 0x0512 +#define REG_RDG_PIFS 0x0513 +#define REG_SIFS_CTX 0x0514 +#define REG_SIFS_TRX 0x0516 +#define REG_AGGR_BREAK_TIME 0x051A +#define REG_SLOT 0x051B +#define REG_TX_PTCL_CTRL 0x0520 +#define REG_TXPAUSE 0x0522 +#define REG_DIS_TXREQ_CLR 0x0523 +#define REG_RD_CTRL 0x0524 + +#define REG_TBTT_PROHIBIT 0x0540 +#define REG_RD_NAV_NXT 0x0544 +#define REG_NAV_PROT_LEN 0x0546 +#define REG_BCN_CTRL 0x0550 +#define REG_BCN_CTRL_1 0x0551 +#define REG_MBID_NUM 0x0552 +#define REG_DUAL_TSF_RST 0x0553 +#define REG_BCN_INTERVAL 0x0554 +#define REG_DRVERLYINT 0x0558 +#define REG_BCNDMATIM 0x0559 +#define REG_ATIMWND 0x055A +#define REG_BCN_MAX_ERR 0x055D +#define REG_RXTSF_OFFSET_CCK 0x055E +#define REG_RXTSF_OFFSET_OFDM 0x055F +#define REG_TSFTR 0x0560 +#define REG_CTWND 0x0572 +#define REG_PSTIMER 0x0580 +#define REG_TIMER0 0x0584 +#define REG_TIMER1 0x0588 +#define REG_BCN_PREDL_ITV 0x058F +#define REG_ACMHWCTRL 0x05C0 + +/*----------------------------------------------------- + * + * 0x0600h ~ 0x07FFh WMAC Configuration + * + *-----------------------------------------------------*/ +#define REG_MAC_CR 0x0600 +#define REG_BWOPMODE 0x0603 +#define REG_TCR 0x0604 +#define REG_RCR 0x0608 +#define REG_RX_PKT_LIMIT 0x060C +#define REG_RX_DLK_TIME 0x060D +#define REG_RX_DRVINFO_SZ 0x060F + +#define REG_MACID 0x0610 +#define REG_BSSID 0x0618 +#define REG_MAR 0x0620 +#define REG_MBIDCAMCFG 0x0628 + +#define REG_USTIME_EDCA 0x0638 +#define REG_MAC_SPEC_SIFS 0x063A +#define REG_RESP_SIFS_CCK 0x063C +#define REG_RESP_SIFS_OFDM 0x063E +#define REG_ACKTO 0x0640 +#define REG_CTS2TO 0x0641 +#define REG_EIFS 0x0642 + +#define REG_NAV_UPPER 0x0652 + +/* Security*/ +#define REG_CAMCMD 0x0670 +#define REG_CAMWRITE 0x0674 +#define REG_CAMREAD 0x0678 +#define REG_CAMDBG 0x067C +#define REG_SECCFG 0x0680 + +/* Power*/ +#define REG_WOW_CTRL 0x0690 +#define REG_PS_RX_INFO 0x0692 +#define REG_UAPSD_TID 0x0693 +#define REG_WKFMCAM_NUM 0x0698 +#define REG_WKFMCAM_RWD 0x069C +#define REG_RXFLTMAP0 0x06A0 +#define REG_RXFLTMAP1 0x06A2 +#define REG_RXFLTMAP2 0x06A4 +#define REG_BCN_PSR_RPT 0x06A8 +#define REG_BT_COEX_TABLE 0x06C0 +#define REG_BFMER0_INFO 0x06E4 +#define REG_BFMER1_INFO 0x06EC +#define REG_CSI_RPT_PARAM_BW20 0x06F4 +#define REG_CSI_RPT_PARAM_BW40 0x06F8 +#define REG_CSI_RPT_PARAM_BW80 0x06FC +/* Hardware Port 2*/ +#define REG_MACID1 0x0700 +#define REG_BSSID1 0x0708 +#define REG_BFMEE_SEL 0x0714 +#define REG_SND_PTCL_CTRL 0x0718 + + +#define CR9346 REG_9346CR +#define MSR (REG_CR + 2) +#define ISR REG_HISR +#define TSFR REG_TSFTR + +#define MACIDR0 REG_MACID +#define MACIDR4 (REG_MACID + 4) + +#define PBP REG_PBP + +#define IDR0 MACIDR0 +#define IDR4 MACIDR4 + +#define UNUSED_REGISTER 0x1BF +#define DCAM UNUSED_REGISTER +#define PSR UNUSED_REGISTER +#define BBADDR UNUSED_REGISTER +#define PHYDATAR UNUSED_REGISTER + +#define INVALID_BBRF_VALUE 0x12345678 + +#define MAX_MSS_DENSITY_2T 0x13 +#define MAX_MSS_DENSITY_1T 0x0A + +#define CMDEEPROM_EN BIT(5) +#define CMDEEPROM_SEL BIT(4) +#define CMD9346CR_9356SEL BIT(4) +#define AUTOLOAD_EEPROM (CMDEEPROM_EN | CMDEEPROM_SEL) +#define AUTOLOAD_EFUSE CMDEEPROM_EN + +#define GPIOSEL_GPIO 0 +#define GPIOSEL_ENBT BIT(5) + +#define GPIO_IN REG_GPIO_PIN_CTRL +#define GPIO_OUT (REG_GPIO_PIN_CTRL + 1) +#define GPIO_IO_SEL (REG_GPIO_PIN_CTRL + 2) +#define GPIO_MOD (REG_GPIO_PIN_CTRL + 3) + +#define MSR_NOLINK 0x00 +#define MSR_ADHOC 0x01 +#define MSR_INFRA 0x02 +#define MSR_AP 0x03 + +#define RRSR_RSC_OFFSET 21 +#define RRSR_SHORT_OFFSET 23 +#define RRSR_RSC_BW_40M 0x600000 +#define RRSR_RSC_UPSUBCHNL 0x400000 +#define RRSR_RSC_LOWSUBCHNL 0x200000 +#define RRSR_SHORT 0x800000 +#define RRSR_1M BIT(0) +#define RRSR_2M BIT(1) +#define RRSR_5_5M BIT(2) +#define RRSR_11M BIT(3) +#define RRSR_6M BIT(4) +#define RRSR_9M BIT(5) +#define RRSR_12M BIT(6) +#define RRSR_18M BIT(7) +#define RRSR_24M BIT(8) +#define RRSR_36M BIT(9) +#define RRSR_48M BIT(10) +#define RRSR_54M BIT(11) +#define RRSR_MCS0 BIT(12) +#define RRSR_MCS1 BIT(13) +#define RRSR_MCS2 BIT(14) +#define RRSR_MCS3 BIT(15) +#define RRSR_MCS4 BIT(16) +#define RRSR_MCS5 BIT(17) +#define RRSR_MCS6 BIT(18) +#define RRSR_MCS7 BIT(19) +#define BRSR_ACKSHORTPMB BIT(23) + +#define RATR_1M 0x00000001 +#define RATR_2M 0x00000002 +#define RATR_55M 0x00000004 +#define RATR_11M 0x00000008 +#define RATR_6M 0x00000010 +#define RATR_9M 0x00000020 +#define RATR_12M 0x00000040 +#define RATR_18M 0x00000080 +#define RATR_24M 0x00000100 +#define RATR_36M 0x00000200 +#define RATR_48M 0x00000400 +#define RATR_54M 0x00000800 +#define RATR_MCS0 0x00001000 +#define RATR_MCS1 0x00002000 +#define RATR_MCS2 0x00004000 +#define RATR_MCS3 0x00008000 +#define RATR_MCS4 0x00010000 +#define RATR_MCS5 0x00020000 +#define RATR_MCS6 0x00040000 +#define RATR_MCS7 0x00080000 +#define RATR_MCS8 0x00100000 +#define RATR_MCS9 0x00200000 +#define RATR_MCS10 0x00400000 +#define RATR_MCS11 0x00800000 +#define RATR_MCS12 0x01000000 +#define RATR_MCS13 0x02000000 +#define RATR_MCS14 0x04000000 +#define RATR_MCS15 0x08000000 + +#define RATE_1M BIT(0) +#define RATE_2M BIT(1) +#define RATE_5_5M BIT(2) +#define RATE_11M BIT(3) +#define RATE_6M BIT(4) +#define RATE_9M BIT(5) +#define RATE_12M BIT(6) +#define RATE_18M BIT(7) +#define RATE_24M BIT(8) +#define RATE_36M BIT(9) +#define RATE_48M BIT(10) +#define RATE_54M BIT(11) +#define RATE_MCS0 BIT(12) +#define RATE_MCS1 BIT(13) +#define RATE_MCS2 BIT(14) +#define RATE_MCS3 BIT(15) +#define RATE_MCS4 BIT(16) +#define RATE_MCS5 BIT(17) +#define RATE_MCS6 BIT(18) +#define RATE_MCS7 BIT(19) +#define RATE_MCS8 BIT(20) +#define RATE_MCS9 BIT(21) +#define RATE_MCS10 BIT(22) +#define RATE_MCS11 BIT(23) +#define RATE_MCS12 BIT(24) +#define RATE_MCS13 BIT(25) +#define RATE_MCS14 BIT(26) +#define RATE_MCS15 BIT(27) + +#define RATE_ALL_CCK (RATR_1M | RATR_2M | RATR_55M | RATR_11M) +#define RATE_ALL_OFDM_AG (RATR_6M | RATR_9M | RATR_12M | RATR_18M |\ + RATR_24M | RATR_36M | RATR_48M | RATR_54M) +#define RATE_ALL_OFDM_1SS (RATR_MCS0 | RATR_MCS1 | RATR_MCS2 |\ + RATR_MCS3 | RATR_MCS4 | RATR_MCS5 |\ + RATR_MCS6 | RATR_MCS7) +#define RATE_ALL_OFDM_2SS (RATR_MCS8 | RATR_MCS9 | RATR_MCS10 |\ + RATR_MCS11 | RATR_MCS12 | RATR_MCS13 |\ + RATR_MCS14 | RATR_MCS15) + +#define BW_OPMODE_20MHZ BIT(2) +#define BW_OPMODE_5G BIT(1) +#define CAM_VALID BIT(15) +#define CAM_NOTVALID 0x0000 +#define CAM_USEDK BIT(5) + +#define CAM_NONE 0x0 +#define CAM_WEP40 0x01 +#define CAM_TKIP 0x02 +#define CAM_AES 0x04 +#define CAM_WEP104 0x05 + +#define TOTAL_CAM_ENTRY 32 +#define HALF_CAM_ENTRY 16 + +#define CAM_WRITE BIT(16) +#define CAM_READ 0x00000000 +#define CAM_POLLINIG BIT(31) + +#define SCR_USEDK 0x01 +#define SCR_TXSEC_ENABLE 0x02 +#define SCR_RXSEC_ENABLE 0x04 + + +/********************************************* +* 8192EE IMR/ISR bits +**********************************************/ +#define IMR_DISABLED 0x0 +/* IMR DW0(0x0060-0063) Bit 0-31 */ +#define IMR_TIMER2 BIT(31) +#define IMR_TIMER1 BIT(30) +#define IMR_PSTIMEOUT BIT(29) +#define IMR_GTINT4 BIT(28) +#define IMR_GTINT3 BIT(27) +#define IMR_TBDER BIT(26) +#define IMR_TBDOK BIT(25) +#define IMR_TSF_BIT32_TOGGLE BIT(24) +#define IMR_BCNDMAINT0 BIT(20) +#define IMR_BCNDOK0 BIT(16) +#define IMR_BCNDMAINT_E BIT(14) +#define IMR_ATIMEND BIT(12) +#define IMR_HISR1_IND_INT BIT(11) +#define IMR_C2HCMD BIT(10) +#define IMR_CPWM2 BIT(9) +#define IMR_CPWM BIT(8) +#define IMR_HIGHDOK BIT(7) +#define IMR_MGNTDOK BIT(6) +#define IMR_BKDOK BIT(5) +#define IMR_BEDOK BIT(4) +#define IMR_VIDOK BIT(3) +#define IMR_VODOK BIT(2) +#define IMR_RDU BIT(1) +#define IMR_ROK BIT(0) + +/* IMR DW1(0x00B4-00B7) Bit 0-31 */ +#define IMR_MCUERR BIT(28) +#define IMR_BCNDMAINT7 BIT(27) +#define IMR_BCNDMAINT6 BIT(26) +#define IMR_BCNDMAINT5 BIT(25) +#define IMR_BCNDMAINT4 BIT(24) +#define IMR_BCNDMAINT3 BIT(23) +#define IMR_BCNDMAINT2 BIT(22) +#define IMR_BCNDMAINT1 BIT(21) +#define IMR_BCNDOK7 BIT(20) +#define IMR_BCNDOK6 BIT(19) +#define IMR_BCNDOK5 BIT(18) +#define IMR_BCNDOK4 BIT(17) +#define IMR_BCNDOK3 BIT(16) +#define IMR_BCNDOK2 BIT(15) +#define IMR_BCNDOK1 BIT(14) +#define IMR_ATIMEND_E BIT(13) +#define IMR_TXERR BIT(11) +#define IMR_RXERR BIT(10) +#define IMR_TXFOVW BIT(9) +#define IMR_RXFOVW BIT(8) + + +#define HWSET_MAX_SIZE 512 +#define EFUSE_MAX_SECTION 64 +#define EFUSE_REAL_CONTENT_LEN 256 +#define EFUSE_OOB_PROTECT_BYTES 18 + + +#define EEPROM_DEFAULT_TSSI 0x0 +#define EEPROM_DEFAULT_TXPOWERDIFF 0x0 +#define EEPROM_DEFAULT_CRYSTALCAP 0x5 +#define EEPROM_DEFAULT_BOARDTYPE 0x02 +#define EEPROM_DEFAULT_TXPOWER 0x1010 +#define EEPROM_DEFAULT_HT2T_TXPWR 0x10 + +#define EEPROM_DEFAULT_LEGACYHTTXPOWERDIFF 0x3 +#define EEPROM_DEFAULT_THERMALMETER 0x1A +#define EEPROM_DEFAULT_ANTTXPOWERDIFF 0x0 +#define EEPROM_DEFAULT_TXPWDIFF_CRYSTALCAP 0x5 +#define EEPROM_DEFAULT_TXPOWERLEVEL 0x22 +#define EEPROM_DEFAULT_HT40_2SDIFF 0x0 +#define EEPROM_DEFAULT_HT20_DIFF 2 +#define EEPROM_DEFAULT_LEGACYHTTXPOWERDIFF 0x3 +#define EEPROM_DEFAULT_HT40_PWRMAXOFFSET 0 +#define EEPROM_DEFAULT_HT20_PWRMAXOFFSET 0 + +#define RF_OPTION1 0x79 +#define RF_OPTION2 0x7A +#define RF_OPTION3 0x7B +#define RF_OPTION4 0x7C + +#define EEPROM_DEFAULT_PID 0x1234 +#define EEPROM_DEFAULT_VID 0x5678 +#define EEPROM_DEFAULT_CUSTOMERID 0xAB +#define EEPROM_DEFAULT_SUBCUSTOMERID 0xCD +#define EEPROM_DEFAULT_VERSION 0 + +#define EEPROM_CHANNEL_PLAN_FCC 0x0 +#define EEPROM_CHANNEL_PLAN_IC 0x1 +#define EEPROM_CHANNEL_PLAN_ETSI 0x2 +#define EEPROM_CHANNEL_PLAN_SPAIN 0x3 +#define EEPROM_CHANNEL_PLAN_FRANCE 0x4 +#define EEPROM_CHANNEL_PLAN_MKK 0x5 +#define EEPROM_CHANNEL_PLAN_MKK1 0x6 +#define EEPROM_CHANNEL_PLAN_ISRAEL 0x7 +#define EEPROM_CHANNEL_PLAN_TELEC 0x8 +#define EEPROM_CHANNEL_PLAN_GLOBAL_DOMAIN 0x9 +#define EEPROM_CHANNEL_PLAN_WORLD_WIDE_13 0xA +#define EEPROM_CHANNEL_PLAN_NCC 0xB +#define EEPROM_CHANNEL_PLAN_BY_HW_MASK 0x80 + +#define EEPROM_CID_DEFAULT 0x0 +#define EEPROM_CID_TOSHIBA 0x4 +#define EEPROM_CID_CCX 0x10 +#define EEPROM_CID_QMI 0x0D +#define EEPROM_CID_WHQL 0xFE + +#define RTL8192E_EEPROM_ID 0x8129 + +#define EEPROM_HPON 0x02 +#define EEPROM_CLK 0x06 +#define EEPROM_TESTR 0x08 + + +#define EEPROM_TXPOWERCCK 0x10 +#define EEPROM_TXPOWERHT40_1S 0x16 +#define EEPROM_TXPOWERHT20DIFF 0x1B +#define EEPROM_TXPOWER_OFDMDIFF 0x1B + + + +#define EEPROM_TX_PWR_INX 0x10 + +#define EEPROM_CHANNELPLAN 0xB8 +#define EEPROM_XTAL_92E 0xB9 +#define EEPROM_THERMAL_METER_92E 0xBA +#define EEPROM_IQK_LCK_92E 0xBB + +#define EEPROM_RF_BOARD_OPTION_92E 0xC1 +#define EEPROM_RF_FEATURE_OPTION_92E 0xC2 +#define EEPROM_RF_BT_SETTING_92E 0xC3 +#define EEPROM_VERSION 0xC4 +#define EEPROM_CUSTOMER_ID 0xC5 +#define EEPROM_RF_ANTENNA_OPT_92E 0xC9 + +#define EEPROM_MAC_ADDR 0xD0 +#define EEPROM_VID 0xD6 +#define EEPROM_DID 0xD8 +#define EEPROM_SVID 0xDA +#define EEPROM_SMID 0xDC + +#define STOPBECON BIT(6) +#define STOPHIGHT BIT(5) +#define STOPMGT BIT(4) +#define STOPVO BIT(3) +#define STOPVI BIT(2) +#define STOPBE BIT(1) +#define STOPBK BIT(0) + +#define RCR_APPFCS BIT(31) +#define RCR_APP_MIC BIT(30) +#define RCR_APP_ICV BIT(29) +#define RCR_APP_PHYST_RXFF BIT(28) +#define RCR_APP_BA_SSN BIT(27) +#define RCR_ENMBID BIT(24) +#define RCR_LSIGEN BIT(23) +#define RCR_MFBEN BIT(22) +#define RCR_HTC_LOC_CTRL BIT(14) +#define RCR_AMF BIT(13) +#define RCR_ACF BIT(12) +#define RCR_ADF BIT(11) +#define RCR_AICV BIT(9) +#define RCR_ACRC32 BIT(8) +#define RCR_CBSSID_BCN BIT(7) +#define RCR_CBSSID_DATA BIT(6) +#define RCR_CBSSID RCR_CBSSID_DATA +#define RCR_APWRMGT BIT(5) +#define RCR_ADD3 BIT(4) +#define RCR_AB BIT(3) +#define RCR_AM BIT(2) +#define RCR_APM BIT(1) +#define RCR_AAP BIT(0) +#define RCR_MXDMA_OFFSET 8 +#define RCR_FIFO_OFFSET 13 + +#define RSV_CTRL 0x001C +#define RD_CTRL 0x0524 + +#define REG_USB_INFO 0xFE17 +#define REG_USB_SPECIAL_OPTION 0xFE55 +#define REG_USB_DMA_AGG_TO 0xFE5B +#define REG_USB_AGG_TO 0xFE5C +#define REG_USB_AGG_TH 0xFE5D + +#define REG_USB_VID 0xFE60 +#define REG_USB_PID 0xFE62 +#define REG_USB_OPTIONAL 0xFE64 +#define REG_USB_CHIRP_K 0xFE65 +#define REG_USB_PHY 0xFE66 +#define REG_USB_MAC_ADDR 0xFE70 +#define REG_USB_HRPWM 0xFE58 +#define REG_USB_HCPWM 0xFE57 + +#define SW18_FPWM BIT(3) + +#define ISO_MD2PP BIT(0) +#define ISO_UA2USB BIT(1) +#define ISO_UD2CORE BIT(2) +#define ISO_PA2PCIE BIT(3) +#define ISO_PD2CORE BIT(4) +#define ISO_IP2MAC BIT(5) +#define ISO_DIOP BIT(6) +#define ISO_DIOE BIT(7) +#define ISO_EB2CORE BIT(8) +#define ISO_DIOR BIT(9) + +#define PWC_EV25V BIT(14) +#define PWC_EV12V BIT(15) + +#define FEN_BBRSTB BIT(0) +#define FEN_BB_GLB_RSTn BIT(1) +#define FEN_USBA BIT(2) +#define FEN_UPLL BIT(3) +#define FEN_USBD BIT(4) +#define FEN_DIO_PCIE BIT(5) +#define FEN_PCIEA BIT(6) +#define FEN_PPLL BIT(7) +#define FEN_PCIED BIT(8) +#define FEN_DIOE BIT(9) +#define FEN_CPUEN BIT(10) +#define FEN_DCORE BIT(11) +#define FEN_ELDR BIT(12) +#define FEN_DIO_RF BIT(13) +#define FEN_HWPDN BIT(14) +#define FEN_MREGEN BIT(15) + +#define PFM_LDALL BIT(0) +#define PFM_ALDN BIT(1) +#define PFM_LDKP BIT(2) +#define PFM_WOWL BIT(3) +#define EnPDN BIT(4) +#define PDN_PL BIT(5) +#define APFM_ONMAC BIT(8) +#define APFM_OFF BIT(9) +#define APFM_RSM BIT(10) +#define AFSM_HSUS BIT(11) +#define AFSM_PCIE BIT(12) +#define APDM_MAC BIT(13) +#define APDM_HOST BIT(14) +#define APDM_HPDN BIT(15) +#define RDY_MACON BIT(16) +#define SUS_HOST BIT(17) +#define ROP_ALD BIT(20) +#define ROP_PWR BIT(21) +#define ROP_SPS BIT(22) +#define SOP_MRST BIT(25) +#define SOP_FUSE BIT(26) +#define SOP_ABG BIT(27) +#define SOP_AMB BIT(28) +#define SOP_RCK BIT(29) +#define SOP_A8M BIT(30) +#define XOP_BTCK BIT(31) + +#define ANAD16V_EN BIT(0) +#define ANA8M BIT(1) +#define MACSLP BIT(4) +#define LOADER_CLK_EN BIT(5) +#define _80M_SSC_DIS BIT(7) +#define _80M_SSC_EN_HO BIT(8) +#define PHY_SSC_RSTB BIT(9) +#define SEC_CLK_EN BIT(10) +#define MAC_CLK_EN BIT(11) +#define SYS_CLK_EN BIT(12) +#define RING_CLK_EN BIT(13) + +#define BOOT_FROM_EEPROM BIT(4) +#define EEPROM_EN BIT(5) + +#define AFE_BGEN BIT(0) +#define AFE_MBEN BIT(1) +#define MAC_ID_EN BIT(7) + +#define WLOCK_ALL BIT(0) +#define WLOCK_00 BIT(1) +#define WLOCK_04 BIT(2) +#define WLOCK_08 BIT(3) +#define WLOCK_40 BIT(4) +#define R_DIS_PRST_0 BIT(5) +#define R_DIS_PRST_1 BIT(6) +#define LOCK_ALL_EN BIT(7) + +#define RF_EN BIT(0) +#define RF_RSTB BIT(1) +#define RF_SDMRSTB BIT(2) + +#define LDA15_EN BIT(0) +#define LDA15_STBY BIT(1) +#define LDA15_OBUF BIT(2) +#define LDA15_REG_VOS BIT(3) +#define _LDA15_VOADJ(x) (((x) & 0x7) << 4) + +#define LDV12_EN BIT(0) +#define LDV12_SDBY BIT(1) +#define LPLDO_HSM BIT(2) +#define LPLDO_LSM_DIS BIT(3) +#define _LDV12_VADJ(x) (((x) & 0xF) << 4) + +#define XTAL_EN BIT(0) +#define XTAL_BSEL BIT(1) +#define _XTAL_BOSC(x) (((x) & 0x3) << 2) +#define _XTAL_CADJ(x) (((x) & 0xF) << 4) +#define XTAL_GATE_USB BIT(8) +#define _XTAL_USB_DRV(x) (((x) & 0x3) << 9) +#define XTAL_GATE_AFE BIT(11) +#define _XTAL_AFE_DRV(x) (((x) & 0x3) << 12) +#define XTAL_RF_GATE BIT(14) +#define _XTAL_RF_DRV(x) (((x) & 0x3) << 15) +#define XTAL_GATE_DIG BIT(17) +#define _XTAL_DIG_DRV(x) (((x) & 0x3) << 18) +#define XTAL_BT_GATE BIT(20) +#define _XTAL_BT_DRV(x) (((x) & 0x3) << 21) +#define _XTAL_GPIO(x) (((x) & 0x7) << 23) + +#define CKDLY_AFE BIT(26) +#define CKDLY_USB BIT(27) +#define CKDLY_DIG BIT(28) +#define CKDLY_BT BIT(29) + +#define APLL_EN BIT(0) +#define APLL_320_EN BIT(1) +#define APLL_FREF_SEL BIT(2) +#define APLL_EDGE_SEL BIT(3) +#define APLL_WDOGB BIT(4) +#define APLL_LPFEN BIT(5) + +#define APLL_REF_CLK_13MHZ 0x1 +#define APLL_REF_CLK_19_2MHZ 0x2 +#define APLL_REF_CLK_20MHZ 0x3 +#define APLL_REF_CLK_25MHZ 0x4 +#define APLL_REF_CLK_26MHZ 0x5 +#define APLL_REF_CLK_38_4MHZ 0x6 +#define APLL_REF_CLK_40MHZ 0x7 + +#define APLL_320EN BIT(14) +#define APLL_80EN BIT(15) +#define APLL_1MEN BIT(24) + +#define ALD_EN BIT(18) +#define EF_PD BIT(19) +#define EF_FLAG BIT(31) + +#define EF_TRPT BIT(7) +#define LDOE25_EN BIT(31) + +#define RSM_EN BIT(0) +#define Timer_EN BIT(4) + +#define TRSW0EN BIT(2) +#define TRSW1EN BIT(3) +#define EROM_EN BIT(4) +#define EnBT BIT(5) +#define EnUart BIT(8) +#define Uart_910 BIT(9) +#define EnPMAC BIT(10) +#define SIC_SWRST BIT(11) +#define EnSIC BIT(12) +#define SIC_23 BIT(13) +#define EnHDP BIT(14) +#define SIC_LBK BIT(15) + +#define LED0PL BIT(4) +#define LED1PL BIT(12) +#define LED0DIS BIT(7) + +#define MCUFWDL_EN BIT(0) +#define MCUFWDL_RDY BIT(1) +#define FWDL_ChkSum_rpt BIT(2) +#define MACINI_RDY BIT(3) +#define BBINI_RDY BIT(4) +#define RFINI_RDY BIT(5) +#define WINTINI_RDY BIT(6) +#define CPRST BIT(23) + +#define XCLK_VLD BIT(0) +#define ACLK_VLD BIT(1) +#define UCLK_VLD BIT(2) +#define PCLK_VLD BIT(3) +#define PCIRSTB BIT(4) +#define V15_VLD BIT(5) +#define TRP_B15V_EN BIT(7) +#define SIC_IDLE BIT(8) +#define BD_MAC2 BIT(9) +#define BD_MAC1 BIT(10) +#define IC_MACPHY_MODE BIT(11) +#define VENDOR_ID BIT(19) +#define PAD_HWPD_IDN BIT(22) +#define TRP_VAUX_EN BIT(23) +#define TRP_BT_EN BIT(24) +#define BD_PKG_SEL BIT(25) +#define BD_HCI_SEL BIT(26) +#define TYPE_ID BIT(27) + +#define CHIP_VER_RTL_MASK 0xF000 +#define CHIP_VER_RTL_SHIFT 12 + +#define REG_LBMODE (REG_CR + 3) + +#define HCI_TXDMA_EN BIT(0) +#define HCI_RXDMA_EN BIT(1) +#define TXDMA_EN BIT(2) +#define RXDMA_EN BIT(3) +#define PROTOCOL_EN BIT(4) +#define SCHEDULE_EN BIT(5) +#define MACTXEN BIT(6) +#define MACRXEN BIT(7) +#define ENSWBCN BIT(8) +#define ENSEC BIT(9) + +#define _NETTYPE(x) (((x) & 0x3) << 16) +#define MASK_NETTYPE 0x30000 +#define NT_NO_LINK 0x0 +#define NT_LINK_AD_HOC 0x1 +#define NT_LINK_AP 0x2 +#define NT_AS_AP 0x3 + +#define _LBMODE(x) (((x) & 0xF) << 24) +#define MASK_LBMODE 0xF000000 +#define LOOPBACK_NORMAL 0x0 +#define LOOPBACK_IMMEDIATELY 0xB +#define LOOPBACK_MAC_DELAY 0x3 +#define LOOPBACK_PHY 0x1 +#define LOOPBACK_DMA 0x7 + +#define GET_RX_PAGE_SIZE(value) ((value) & 0xF) +#define GET_TX_PAGE_SIZE(value) (((value) & 0xF0) >> 4) +#define _PSRX_MASK 0xF +#define _PSTX_MASK 0xF0 +#define _PSRX(x) (x) +#define _PSTX(x) ((x) << 4) + +#define PBP_64 0x0 +#define PBP_128 0x1 +#define PBP_256 0x2 +#define PBP_512 0x3 +#define PBP_1024 0x4 + +#define RXDMA_ARBBW_EN BIT(0) +#define RXSHFT_EN BIT(1) +#define RXDMA_AGG_EN BIT(2) +#define QS_VO_QUEUE BIT(8) +#define QS_VI_QUEUE BIT(9) +#define QS_BE_QUEUE BIT(10) +#define QS_BK_QUEUE BIT(11) +#define QS_MANAGER_QUEUE BIT(12) +#define QS_HIGH_QUEUE BIT(13) + +#define HQSEL_VOQ BIT(0) +#define HQSEL_VIQ BIT(1) +#define HQSEL_BEQ BIT(2) +#define HQSEL_BKQ BIT(3) +#define HQSEL_MGTQ BIT(4) +#define HQSEL_HIQ BIT(5) + +#define _TXDMA_HIQ_MAP(x) (((x)&0x3) << 14) +#define _TXDMA_MGQ_MAP(x) (((x)&0x3) << 12) +#define _TXDMA_BKQ_MAP(x) (((x)&0x3) << 10) +#define _TXDMA_BEQ_MAP(x) (((x)&0x3) << 8) +#define _TXDMA_VIQ_MAP(x) (((x)&0x3) << 6) +#define _TXDMA_VOQ_MAP(x) (((x)&0x3) << 4) + +#define QUEUE_LOW 1 +#define QUEUE_NORMAL 2 +#define QUEUE_HIGH 3 + +#define _LLT_NO_ACTIVE 0x0 +#define _LLT_WRITE_ACCESS 0x1 +#define _LLT_READ_ACCESS 0x2 + +#define _LLT_INIT_DATA(x) ((x) & 0xFF) +#define _LLT_INIT_ADDR(x) (((x) & 0xFF) << 8) +#define _LLT_OP(x) (((x) & 0x3) << 30) +#define _LLT_OP_VALUE(x) (((x) >> 30) & 0x3) + +#define BB_WRITE_READ_MASK (BIT(31) | BIT(30)) +#define BB_WRITE_EN BIT(30) +#define BB_READ_EN BIT(31) + +#define _HPQ(x) ((x) & 0xFF) +#define _LPQ(x) (((x) & 0xFF) << 8) +#define _PUBQ(x) (((x) & 0xFF) << 16) +#define _NPQ(x) ((x) & 0xFF) + +#define HPQ_PUBLIC_DIS BIT(24) +#define LPQ_PUBLIC_DIS BIT(25) +#define LD_RQPN BIT(31) + +#define BCN_VALID BIT(16) +#define BCN_HEAD(x) (((x) & 0xFF) << 8) +#define BCN_HEAD_MASK 0xFF00 + +#define BLK_DESC_NUM_SHIFT 4 +#define BLK_DESC_NUM_MASK 0xF + +#define DROP_DATA_EN BIT(9) + +#define EN_AMPDU_RTY_NEW BIT(7) + +#define _INIRTSMCS_SEL(x) ((x) & 0x3F) + +#define _SPEC_SIFS_CCK(x) ((x) & 0xFF) +#define _SPEC_SIFS_OFDM(x) (((x) & 0xFF) << 8) + +#define RATE_REG_BITMAP_ALL 0xFFFFF + +#define _RRSC_BITMAP(x) ((x) & 0xFFFFF) + +#define _RRSR_RSC(x) (((x) & 0x3) << 21) +#define RRSR_RSC_RESERVED 0x0 +#define RRSR_RSC_UPPER_SUBCHANNEL 0x1 +#define RRSR_RSC_LOWER_SUBCHANNEL 0x2 +#define RRSR_RSC_DUPLICATE_MODE 0x3 + +#define USE_SHORT_G1 BIT(20) + +#define _AGGLMT_MCS0(x) ((x) & 0xF) +#define _AGGLMT_MCS1(x) (((x) & 0xF) << 4) +#define _AGGLMT_MCS2(x) (((x) & 0xF) << 8) +#define _AGGLMT_MCS3(x) (((x) & 0xF) << 12) +#define _AGGLMT_MCS4(x) (((x) & 0xF) << 16) +#define _AGGLMT_MCS5(x) (((x) & 0xF) << 20) +#define _AGGLMT_MCS6(x) (((x) & 0xF) << 24) +#define _AGGLMT_MCS7(x) (((x) & 0xF) << 28) + +#define RETRY_LIMIT_SHORT_SHIFT 8 +#define RETRY_LIMIT_LONG_SHIFT 0 + +#define _DARF_RC1(x) ((x) & 0x1F) +#define _DARF_RC2(x) (((x) & 0x1F) << 8) +#define _DARF_RC3(x) (((x) & 0x1F) << 16) +#define _DARF_RC4(x) (((x) & 0x1F) << 24) +#define _DARF_RC5(x) ((x) & 0x1F) +#define _DARF_RC6(x) (((x) & 0x1F) << 8) +#define _DARF_RC7(x) (((x) & 0x1F) << 16) +#define _DARF_RC8(x) (((x) & 0x1F) << 24) + +#define _RARF_RC1(x) ((x) & 0x1F) +#define _RARF_RC2(x) (((x) & 0x1F) << 8) +#define _RARF_RC3(x) (((x) & 0x1F) << 16) +#define _RARF_RC4(x) (((x) & 0x1F) << 24) +#define _RARF_RC5(x) ((x) & 0x1F) +#define _RARF_RC6(x) (((x) & 0x1F) << 8) +#define _RARF_RC7(x) (((x) & 0x1F) << 16) +#define _RARF_RC8(x) (((x) & 0x1F) << 24) + +#define AC_PARAM_TXOP_LIMIT_OFFSET 16 +#define AC_PARAM_ECW_MAX_OFFSET 12 +#define AC_PARAM_ECW_MIN_OFFSET 8 +#define AC_PARAM_AIFS_OFFSET 0 + +#define _AIFS(x) (x) +#define _ECW_MAX_MIN(x) ((x) << 8) +#define _TXOP_LIMIT(x) ((x) << 16) + +#define _BCNIFS(x) ((x) & 0xFF) +#define _BCNECW(x) ((((x) & 0xF)) << 8) + +#define _LRL(x) ((x) & 0x3F) +#define _SRL(x) (((x) & 0x3F) << 8) + +#define _SIFS_CCK_CTX(x) ((x) & 0xFF) +#define _SIFS_CCK_TRX(x) (((x) & 0xFF) << 8); + +#define _SIFS_OFDM_CTX(x) ((x) & 0xFF) +#define _SIFS_OFDM_TRX(x) (((x) & 0xFF) << 8); + +#define _TBTT_PROHIBIT_HOLD(x) (((x) & 0xFF) << 8) + +#define DIS_EDCA_CNT_DWN BIT(11) + +#define EN_MBSSID BIT(1) +#define EN_TXBCN_RPT BIT(2) +#define EN_BCN_FUNCTION BIT(3) + +#define TSFTR_RST BIT(0) +#define TSFTR1_RST BIT(1) + +#define STOP_BCNQ BIT(6) + +#define DIS_TSF_UDT0_NORMAL_CHIP BIT(4) +#define DIS_TSF_UDT0_TEST_CHIP BIT(5) + +#define AcmHw_HwEn BIT(0) +#define AcmHw_BeqEn BIT(1) +#define AcmHw_ViqEn BIT(2) +#define AcmHw_VoqEn BIT(3) +#define AcmHw_BeqStatus BIT(4) +#define AcmHw_ViqStatus BIT(5) +#define AcmHw_VoqStatus BIT(6) + +#define APSDOFF BIT(6) +#define APSDOFF_STATUS BIT(7) + +#define BW_20MHZ BIT(2) + +#define RATE_BITMAP_ALL 0xFFFFF + +#define RATE_RRSR_CCK_ONLY_1M 0xFFFF1 + +#define TSFRST BIT(0) +#define DIS_GCLK BIT(1) +#define PAD_SEL BIT(2) +#define PWR_ST BIT(6) +#define PWRBIT_OW_EN BIT(7) +#define ACRC BIT(8) +#define CFENDFORM BIT(9) +#define ICV BIT(10) + +#define AAP BIT(0) +#define APM BIT(1) +#define AM BIT(2) +#define AB BIT(3) +#define ADD3 BIT(4) +#define APWRMGT BIT(5) +#define CBSSID BIT(6) +#define CBSSID_DATA BIT(6) +#define CBSSID_BCN BIT(7) +#define ACRC32 BIT(8) +#define AICV BIT(9) +#define ADF BIT(11) +#define ACF BIT(12) +#define AMF BIT(13) +#define HTC_LOC_CTRL BIT(14) +#define UC_DATA_EN BIT(16) +#define BM_DATA_EN BIT(17) +#define MFBEN BIT(22) +#define LSIGEN BIT(23) +#define EnMBID BIT(24) +#define APP_BASSN BIT(27) +#define APP_PHYSTS BIT(28) +#define APP_ICV BIT(29) +#define APP_MIC BIT(30) +#define APP_FCS BIT(31) + +#define _MIN_SPACE(x) ((x) & 0x7) +#define _SHORT_GI_PADDING(x) (((x) & 0x1F) << 3) + +#define RXERR_TYPE_OFDM_PPDU 0 +#define RXERR_TYPE_OFDM_FALSE_ALARM 1 +#define RXERR_TYPE_OFDM_MPDU_OK 2 +#define RXERR_TYPE_OFDM_MPDU_FAIL 3 +#define RXERR_TYPE_CCK_PPDU 4 +#define RXERR_TYPE_CCK_FALSE_ALARM 5 +#define RXERR_TYPE_CCK_MPDU_OK 6 +#define RXERR_TYPE_CCK_MPDU_FAIL 7 +#define RXERR_TYPE_HT_PPDU 8 +#define RXERR_TYPE_HT_FALSE_ALARM 9 +#define RXERR_TYPE_HT_MPDU_TOTAL 10 +#define RXERR_TYPE_HT_MPDU_OK 11 +#define RXERR_TYPE_HT_MPDU_FAIL 12 +#define RXERR_TYPE_RX_FULL_DROP 15 + +#define RXERR_COUNTER_MASK 0xFFFFF +#define RXERR_RPT_RST BIT(27) +#define _RXERR_RPT_SEL(type) ((type) << 28) + +#define SCR_TxUseDK BIT(0) +#define SCR_RxUseDK BIT(1) +#define SCR_TxEncEnable BIT(2) +#define SCR_RxDecEnable BIT(3) +#define SCR_SKByA2 BIT(4) +#define SCR_NoSKMC BIT(5) +#define SCR_TXBCUSEDK BIT(6) +#define SCR_RXBCUSEDK BIT(7) + +#define USB_IS_HIGH_SPEED 0 +#define USB_IS_FULL_SPEED 1 +#define USB_SPEED_MASK BIT(5) + +#define USB_NORMAL_SIE_EP_MASK 0xF +#define USB_NORMAL_SIE_EP_SHIFT 4 + +#define USB_TEST_EP_MASK 0x30 +#define USB_TEST_EP_SHIFT 4 + +#define USB_AGG_EN BIT(3) + +#define MAC_ADDR_LEN 6 +#define LAST_ENTRY_OF_TX_PKT_BUFFER 175 + +#define POLLING_LLT_THRESHOLD 20 +#define POLLING_READY_TIMEOUT_COUNT 3000 + +#define MAX_MSS_DENSITY_2T 0x13 +#define MAX_MSS_DENSITY_1T 0x0A + +#define EPROM_CMD_OPERATING_MODE_MASK ((1 << 7) | (1 << 6)) +#define EPROM_CMD_CONFIG 0x3 +#define EPROM_CMD_LOAD 1 + +#define HWSET_MAX_SIZE_92S HWSET_MAX_SIZE + +#define HAL_8192C_HW_GPIO_WPS_BIT BIT(2) + +#define RPMAC_RESET 0x100 +#define RPMAC_TXSTART 0x104 +#define RPMAC_TXLEGACYSIG 0x108 +#define RPMAC_TXHTSIG1 0x10c +#define RPMAC_TXHTSIG2 0x110 +#define RPMAC_PHYDEBUG 0x114 +#define RPMAC_TXPACKETNUM 0x118 +#define RPMAC_TXIDLE 0x11c +#define RPMAC_TXMACHEADER0 0x120 +#define RPMAC_TXMACHEADER1 0x124 +#define RPMAC_TXMACHEADER2 0x128 +#define RPMAC_TXMACHEADER3 0x12c +#define RPMAC_TXMACHEADER4 0x130 +#define RPMAC_TXMACHEADER5 0x134 +#define RPMAC_TXDADATYPE 0x138 +#define RPMAC_TXRANDOMSEED 0x13c +#define RPMAC_CCKPLCPPREAMBLE 0x140 +#define RPMAC_CCKPLCPHEADER 0x144 +#define RPMAC_CCKCRC16 0x148 +#define RPMAC_OFDMRXCRC32OK 0x170 +#define RPMAC_OFDMRXCRC32Er 0x174 +#define RPMAC_OFDMRXPARITYER 0x178 +#define RPMAC_OFDMRXCRC8ER 0x17c +#define RPMAC_CCKCRXRC16ER 0x180 +#define RPMAC_CCKCRXRC32ER 0x184 +#define RPMAC_CCKCRXRC32OK 0x188 +#define RPMAC_TXSTATUS 0x18c + +#define RFPGA0_RFMOD 0x800 + +#define RFPGA0_TXINFO 0x804 +#define RFPGA0_PSDFUNCTION 0x808 + +#define RFPGA0_TXGAINSTAGE 0x80c + +#define RFPGA0_RFTIMING1 0x810 +#define RFPGA0_RFTIMING2 0x814 + +#define RFPGA0_XA_HSSIPARAMETER1 0x820 +#define RFPGA0_XA_HSSIPARAMETER2 0x824 +#define RFPGA0_XB_HSSIPARAMETER1 0x828 +#define RFPGA0_XB_HSSIPARAMETER2 0x82c + +#define RFPGA0_XA_LSSIPARAMETER 0x840 +#define RFPGA0_XB_LSSIPARAMETER 0x844 + +#define RFPGA0_RFWAKEUPPARAMETER 0x850 +#define RFPGA0_RFSLEEPUPPARAMETER 0x854 + +#define RFPGA0_XAB_SWITCHCONTROL 0x858 +#define RFPGA0_XCD_SWITCHCONTROL 0x85c + +#define RFPGA0_XA_RFINTERFACEOE 0x860 +#define RFPGA0_XB_RFINTERFACEOE 0x864 + +#define RFPGA0_XAB_RFINTERFACESW 0x870 +#define RFPGA0_XCD_RFINTERFACESW 0x874 + +#define rFPGA0_XAB_RFPARAMETER 0x878 +#define rFPGA0_XCD_RFPARAMETER 0x87c + +#define RFPGA0_ANALOGPARAMETER1 0x880 +#define RFPGA0_ANALOGPARAMETER2 0x884 +#define RFPGA0_ANALOGPARAMETER3 0x888 +#define RFPGA0_ANALOGPARAMETER4 0x88c + +#define RFPGA0_XA_LSSIREADBACK 0x8a0 +#define RFPGA0_XB_LSSIREADBACK 0x8a4 +#define RFPGA0_XC_LSSIREADBACK 0x8a8 +#define RFPGA0_XD_LSSIREADBACK 0x8ac + +#define RFPGA0_PSDREPORT 0x8b4 +#define TRANSCEIVEA_HSPI_READBACK 0x8b8 +#define TRANSCEIVEB_HSPI_READBACK 0x8bc +#define REG_SC_CNT 0x8c4 +#define RFPGA0_XAB_RFINTERFACERB 0x8e0 +#define RFPGA0_XCD_RFINTERFACERB 0x8e4 + +#define RFPGA1_RFMOD 0x900 + +#define RFPGA1_TXBLOCK 0x904 +#define RFPGA1_DEBUGSELECT 0x908 +#define RFPGA1_TXINFO 0x90c + +#define RCCK0_SYSTEM 0xa00 + +#define RCCK0_AFESETTING 0xa04 +#define RCCK0_CCA 0xa08 + +#define RCCK0_RXAGC1 0xa0c +#define RCCK0_RXAGC2 0xa10 + +#define RCCK0_RXHP 0xa14 + +#define RCCK0_DSPPARAMETER1 0xa18 +#define RCCK0_DSPPARAMETER2 0xa1c + +#define RCCK0_TXFILTER1 0xa20 +#define RCCK0_TXFILTER2 0xa24 +#define RCCK0_DEBUGPORT 0xa28 +#define RCCK0_FALSEALARMREPORT 0xa2c +#define RCCK0_TRSSIREPORT 0xa50 +#define RCCK0_RXREPORT 0xa54 +#define RCCK0_FACOUNTERLOWER 0xa5c +#define RCCK0_FACOUNTERUPPER 0xa58 +#define RCCK0_CCA_CNT 0xa60 + + +/* PageB(0xB00) */ +#define rPdp_AntA 0xb00 +#define rPdp_AntA_4 0xb04 +#define rPdp_AntA_8 0xb08 +#define rPdp_AntA_C 0xb0c +#define rPdp_AntA_10 0xb10 +#define rPdp_AntA_14 0xb14 +#define rPdp_AntA_18 0xb18 +#define rPdp_AntA_1C 0xb1c +#define rPdp_AntA_20 0xb20 +#define rPdp_AntA_24 0xb24 + +#define rConfig_Pmpd_AntA 0xb28 +#define rConfig_ram64x16 0xb2c + +#define rBndA 0xb30 +#define rHssiPar 0xb34 + +#define rConfig_AntA 0xb68 +#define rConfig_AntB 0xb6c + +#define rPdp_AntB 0xb70 +#define rPdp_AntB_4 0xb74 +#define rPdp_AntB_8 0xb78 +#define rPdp_AntB_C 0xb7c +#define rPdp_AntB_10 0xb80 +#define rPdp_AntB_14 0xb84 +#define rPdp_AntB_18 0xb88 +#define rPdp_AntB_1C 0xb8c +#define rPdp_AntB_20 0xb90 +#define rPdp_AntB_24 0xb94 + +#define rConfig_Pmpd_AntB 0xb98 + +#define rBndB 0xba0 + +#define rAPK 0xbd8 +#define rPm_Rx0_AntA 0xbdc +#define rPm_Rx1_AntA 0xbe0 +#define rPm_Rx2_AntA 0xbe4 +#define rPm_Rx3_AntA 0xbe8 +#define rPm_Rx0_AntB 0xbec +#define rPm_Rx1_AntB 0xbf0 +#define rPm_Rx2_AntB 0xbf4 +#define rPm_Rx3_AntB 0xbf8 + +/*Page C*/ +#define ROFDM0_LSTF 0xc00 + +#define ROFDM0_TRXPATHENABLE 0xc04 +#define ROFDM0_TRMUXPAR 0xc08 +#define ROFDM0_TRSWISOLATION 0xc0c + +#define ROFDM0_XARXAFE 0xc10 +#define ROFDM0_XARXIQIMBALANCE 0xc14 +#define ROFDM0_XBRXAFE 0xc18 +#define ROFDM0_XBRXIQIMBALANCE 0xc1c +#define ROFDM0_XCRXAFE 0xc20 +#define ROFDM0_XCRXIQIMBANLANCE 0xc24 +#define ROFDM0_XDRXAFE 0xc28 +#define ROFDM0_XDRXIQIMBALANCE 0xc2c + +#define ROFDM0_RXDETECTOR1 0xc30 +#define ROFDM0_RXDETECTOR2 0xc34 +#define ROFDM0_RXDETECTOR3 0xc38 +#define ROFDM0_RXDETECTOR4 0xc3c + +#define ROFDM0_RXDSP 0xc40 +#define ROFDM0_CFOANDDAGC 0xc44 +#define ROFDM0_CCADROPTHRESHOLD 0xc48 +#define ROFDM0_ECCATHRESHOLD 0xc4c + +#define ROFDM0_XAAGCCORE1 0xc50 +#define ROFDM0_XAAGCCORE2 0xc54 +#define ROFDM0_XBAGCCORE1 0xc58 +#define ROFDM0_XBAGCCORE2 0xc5c +#define ROFDM0_XCAGCCORE1 0xc60 +#define ROFDM0_XCAGCCORE2 0xc64 +#define ROFDM0_XDAGCCORE1 0xc68 +#define ROFDM0_XDAGCCORE2 0xc6c + +#define ROFDM0_AGCPARAMETER1 0xc70 +#define ROFDM0_AGCPARAMETER2 0xc74 +#define ROFDM0_AGCRSSITABLE 0xc78 +#define ROFDM0_HTSTFAGC 0xc7c + +#define ROFDM0_XATXIQIMBALANCE 0xc80 +#define ROFDM0_XATXAFE 0xc84 +#define ROFDM0_XBTXIQIMBALANCE 0xc88 +#define ROFDM0_XBTXAFE 0xc8c +#define ROFDM0_XCTXIQIMBALANCE 0xc90 +#define ROFDM0_XCTXAFE 0xc94 +#define ROFDM0_XDTXIQIMBALANCE 0xc98 +#define ROFDM0_XDTXAFE 0xc9c + +#define ROFDM0_RXIQEXTANTA 0xca0 +#define ROFDM0_TXCOEFF1 0xca4 +#define ROFDM0_TXCOEFF2 0xca8 +#define ROFDM0_TXCOEFF3 0xcac +#define ROFDM0_TXCOEFF4 0xcb0 +#define ROFDM0_TXCOEFF5 0xcb4 +#define ROFDM0_TXCOEFF6 0xcb8 + +#define ROFDM0_RXHPPARAMETER 0xce0 +#define ROFDM0_TXPSEUDONOISEWGT 0xce4 +#define ROFDM0_FRAMESYNC 0xcf0 +#define ROFDM0_DFSREPORT 0xcf4 + + +#define ROFDM1_LSTF 0xd00 +#define ROFDM1_TRXPATHENABLE 0xd04 + +#define ROFDM1_CF0 0xd08 +#define ROFDM1_CSI1 0xd10 +#define ROFDM1_SBD 0xd14 +#define ROFDM1_CSI2 0xd18 +#define ROFDM1_CFOTRACKING 0xd2c +#define ROFDM1_TRXMESAURE1 0xd34 +#define ROFDM1_INTFDET 0xd3c +#define ROFDM1_PSEUDONOISESTATEAB 0xd50 +#define ROFDM1_PSEUDONOISESTATECD 0xd54 +#define ROFDM1_RXPSEUDONOISEWGT 0xd58 + +#define ROFDM_PHYCOUNTER1 0xda0 +#define ROFDM_PHYCOUNTER2 0xda4 +#define ROFDM_PHYCOUNTER3 0xda8 + +#define ROFDM_SHORTCFOAB 0xdac +#define ROFDM_SHORTCFOCD 0xdb0 +#define ROFDM_LONGCFOAB 0xdb4 +#define ROFDM_LONGCFOCD 0xdb8 +#define ROFDM_TAILCF0AB 0xdbc +#define ROFDM_TAILCF0CD 0xdc0 +#define ROFDM_PWMEASURE1 0xdc4 +#define ROFDM_PWMEASURE2 0xdc8 +#define ROFDM_BWREPORT 0xdcc +#define ROFDM_AGCREPORT 0xdd0 +#define ROFDM_RXSNR 0xdd4 +#define ROFDM_RXEVMCSI 0xdd8 +#define ROFDM_SIGREPORT 0xddc + +#define RTXAGC_A_RATE18_06 0xe00 +#define RTXAGC_A_RATE54_24 0xe04 +#define RTXAGC_A_CCK1_MCS32 0xe08 +#define RTXAGC_A_MCS03_MCS00 0xe10 +#define RTXAGC_A_MCS07_MCS04 0xe14 +#define RTXAGC_A_MCS11_MCS08 0xe18 +#define RTXAGC_A_MCS15_MCS12 0xe1c + +#define RTXAGC_B_RATE18_06 0x830 +#define RTXAGC_B_RATE54_24 0x834 +#define RTXAGC_B_CCK1_55_MCS32 0x838 +#define RTXAGC_B_MCS03_MCS00 0x83c +#define RTXAGC_B_MCS07_MCS04 0x848 +#define RTXAGC_B_MCS11_MCS08 0x84c +#define RTXAGC_B_MCS15_MCS12 0x868 +#define RTXAGC_B_CCK11_A_CCK2_11 0x86c + +#define RFPGA0_IQK 0xe28 +#define RTx_IQK_Tone_A 0xe30 +#define RRx_IQK_Tone_A 0xe34 +#define RTx_IQK_PI_A 0xe38 +#define RRx_IQK_PI_A 0xe3c + +#define RTx_IQK 0xe40 +#define RRx_IQK 0xe44 +#define RIQK_AGC_Pts 0xe48 +#define RIQK_AGC_Rsp 0xe4c +#define RTx_IQK_Tone_B 0xe50 +#define RRx_IQK_Tone_B 0xe54 +#define RTx_IQK_PI_B 0xe58 +#define RRx_IQK_PI_B 0xe5c +#define RIQK_AGC_Cont 0xe60 + +#define RBlue_Tooth 0xe6c +#define RRx_Wait_CCA 0xe70 +#define RTx_CCK_RFON 0xe74 +#define RTx_CCK_BBON 0xe78 +#define RTx_OFDM_RFON 0xe7c +#define RTx_OFDM_BBON 0xe80 +#define RTx_To_Rx 0xe84 +#define RTx_To_Tx 0xe88 +#define RRx_CCK 0xe8c + +#define RTx_Power_Before_IQK_A 0xe94 +#define RTx_Power_After_IQK_A 0xe9c + +#define RRx_Power_Before_IQK_A 0xea0 +#define RRx_Power_Before_IQK_A_2 0xea4 +#define RRx_Power_After_IQK_A 0xea8 +#define RRx_Power_After_IQK_A_2 0xeac + +#define RTx_Power_Before_IQK_B 0xeb4 +#define RTx_Power_After_IQK_B 0xebc + +#define RRx_Power_Before_IQK_B 0xec0 +#define RRx_Power_Before_IQK_B_2 0xec4 +#define RRx_Power_After_IQK_B 0xec8 +#define RRx_Power_After_IQK_B_2 0xecc + +#define RRx_OFDM 0xed0 +#define RRx_Wait_RIFS 0xed4 +#define RRx_TO_Rx 0xed8 +#define RStandby 0xedc +#define RSleep 0xee0 +#define RPMPD_ANAEN 0xeec + +#define RZEBRA1_HSSIENABLE 0x0 +#define RZEBRA1_TRXENABLE1 0x1 +#define RZEBRA1_TRXENABLE2 0x2 +#define RZEBRA1_AGC 0x4 +#define RZEBRA1_CHARGEPUMP 0x5 +#define RZEBRA1_CHANNEL 0x7 + +#define RZEBRA1_TXGAIN 0x8 +#define RZEBRA1_TXLPF 0x9 +#define RZEBRA1_RXLPF 0xb +#define RZEBRA1_RXHPFCORNER 0xc + +#define RGLOBALCTRL 0 +#define RRTL8256_TXLPF 19 +#define RRTL8256_RXLPF 11 +#define RRTL8258_TXLPF 0x11 +#define RRTL8258_RXLPF 0x13 +#define RRTL8258_RSSILPF 0xa + +#define RF_AC 0x00 + +#define RF_IQADJ_G1 0x01 +#define RF_IQADJ_G2 0x02 +#define RF_POW_TRSW 0x05 + +#define RF_GAIN_RX 0x06 +#define RF_GAIN_TX 0x07 + +#define RF_TXM_IDAC 0x08 +#define RF_BS_IQGEN 0x0F + +#define RF_MODE1 0x10 +#define RF_MODE2 0x11 + +#define RF_RX_AGC_HP 0x12 +#define RF_TX_AGC 0x13 +#define RF_BIAS 0x14 +#define RF_IPA 0x15 +#define RF_POW_ABILITY 0x17 +#define RF_MODE_AG 0x18 +#define RRFCHANNEL 0x18 +#define RF_CHNLBW 0x18 +#define RF_TOP 0x19 + +#define RF_RX_G1 0x1A +#define RF_RX_G2 0x1B + +#define RF_RX_BB2 0x1C +#define RF_RX_BB1 0x1D + +#define RF_RCK1 0x1E +#define RF_RCK2 0x1F + +#define RF_TX_G1 0x20 +#define RF_TX_G2 0x21 +#define RF_TX_G3 0x22 + +#define RF_TX_BB1 0x23 +#define RF_T_METER 0x42 + +#define RF_SYN_G1 0x25 +#define RF_SYN_G2 0x26 +#define RF_SYN_G3 0x27 +#define RF_SYN_G4 0x28 +#define RF_SYN_G5 0x29 +#define RF_SYN_G6 0x2A +#define RF_SYN_G7 0x2B +#define RF_SYN_G8 0x2C + +#define RF_RCK_OS 0x30 +#define RF_TXPA_G1 0x31 +#define RF_TXPA_G2 0x32 +#define RF_TXPA_G3 0x33 + +#define RF_TX_BIAS_A 0x35 +#define RF_TX_BIAS_D 0x36 +#define RF_LOBF_9 0x38 +#define RF_RXRF_A3 0x3C +#define RF_TRSW 0x3F + +#define RF_TXRF_A2 0x41 +#define RF_TXPA_G4 0x46 +#define RF_TXPA_A4 0x4B + +#define RF_WE_LUT 0xEF + +#define BBBRESETB 0x100 +#define BGLOBALRESETB 0x200 +#define BOFDMTXSTART 0x4 +#define BCCKTXSTART 0x8 +#define BCRC32DEBUG 0x100 +#define BPMACLOOPBACK 0x10 +#define BTXLSIG 0xffffff +#define BOFDMTXRATE 0xf +#define BOFDMTXRESERVED 0x10 +#define BOFDMTXLENGTH 0x1ffe0 +#define BOFDMTXPARITY 0x20000 +#define BTXHTSIG1 0xffffff +#define BTXHTMCSRATE 0x7f +#define BTXHTBW 0x80 +#define BTXHTLENGTH 0xffff00 +#define BTXHTSIG2 0xffffff +#define BTXHTSMOOTHING 0x1 +#define BTXHTSOUNDING 0x2 +#define BTXHTRESERVED 0x4 +#define BTXHTAGGREATION 0x8 +#define BTXHTSTBC 0x30 +#define BTXHTADVANCECODING 0x40 +#define BTXHTSHORTGI 0x80 +#define BTXHTNUMBERHT_LTF 0x300 +#define BTXHTCRC8 0x3fc00 +#define BCOUNTERRESET 0x10000 +#define BNUMOFOFDMTX 0xffff +#define BNUMOFCCKTX 0xffff0000 +#define BTXIDLEINTERVAL 0xffff +#define BOFDMSERVICE 0xffff0000 +#define BTXMACHEADER 0xffffffff +#define BTXDATAINIT 0xff +#define BTXHTMODE 0x100 +#define BTXDATATYPE 0x30000 +#define BTXRANDOMSEED 0xffffffff +#define BCCKTXPREAMBLE 0x1 +#define BCCKTXSFD 0xffff0000 +#define BCCKTXSIG 0xff +#define BCCKTXSERVICE 0xff00 +#define BCCKLENGTHEXT 0x8000 +#define BCCKTXLENGHT 0xffff0000 +#define BCCKTXCRC16 0xffff +#define BCCKTXSTATUS 0x1 +#define BOFDMTXSTATUS 0x2 +#define IS_BB_REG_OFFSET_92S(_Offset) \ + ((_Offset >= 0x800) && (_Offset <= 0xfff)) + +#define BRFMOD 0x1 +#define BJAPANMODE 0x2 +#define BCCKTXSC 0x30 +#define BCCKEN 0x1000000 +#define BOFDMEN 0x2000000 + +#define BOFDMRXADCPHASE 0x10000 +#define BOFDMTXDACPHASE 0x40000 +#define BXATXAGC 0x3f + +#define BXBTXAGC 0xf00 +#define BXCTXAGC 0xf000 +#define BXDTXAGC 0xf0000 + +#define BPASTART 0xf0000000 +#define BTRSTART 0x00f00000 +#define BRFSTART 0x0000f000 +#define BBBSTART 0x000000f0 +#define BBBCCKSTART 0x0000000f +#define BPAEND 0xf +#define BTREND 0x0f000000 +#define BRFEND 0x000f0000 +#define BCCAMASK 0x000000f0 +#define BR2RCCAMASK 0x00000f00 +#define BHSSI_R2TDELAY 0xf8000000 +#define BHSSI_T2RDELAY 0xf80000 +#define BCONTXHSSI 0x400 +#define BIGFROMCCK 0x200 +#define BAGCADDRESS 0x3f +#define BRXHPTX 0x7000 +#define BRXHP2RX 0x38000 +#define BRXHPCCKINI 0xc0000 +#define BAGCTXCODE 0xc00000 +#define BAGCRXCODE 0x300000 + +#define B3WIREDATALENGTH 0x800 +#define B3WIREADDREAALENGTH 0x400 + +#define B3WIRERFPOWERDOWN 0x1 +#define B5GPAPEPOLARITY 0x40000000 +#define B2GPAPEPOLARITY 0x80000000 +#define BRFSW_TXDEFAULTANT 0x3 +#define BRFSW_TXOPTIONANT 0x30 +#define BRFSW_RXDEFAULTANT 0x300 +#define BRFSW_RXOPTIONANT 0x3000 +#define BRFSI_3WIREDATA 0x1 +#define BRFSI_3WIRECLOCK 0x2 +#define BRFSI_3WIRELOAD 0x4 +#define BRFSI_3WIRERW 0x8 +#define BRFSI_3WIRE 0xf + +#define BRFSI_RFENV 0x10 + +#define BRFSI_TRSW 0x20 +#define BRFSI_TRSWB 0x40 +#define BRFSI_ANTSW 0x100 +#define BRFSI_ANTSWB 0x200 +#define BRFSI_PAPE 0x400 +#define BRFSI_PAPE5G 0x800 +#define BBANDSELECT 0x1 +#define BHTSIG2_GI 0x80 +#define BHTSIG2_SMOOTHING 0x01 +#define BHTSIG2_SOUNDING 0x02 +#define BHTSIG2_AGGREATON 0x08 +#define BHTSIG2_STBC 0x30 +#define BHTSIG2_ADVCODING 0x40 +#define BHTSIG2_NUMOFHTLTF 0x300 +#define BHTSIG2_CRC8 0x3fc +#define BHTSIG1_MCS 0x7f +#define BHTSIG1_BANDWIDTH 0x80 +#define BHTSIG1_HTLENGTH 0xffff +#define BLSIG_RATE 0xf +#define BLSIG_RESERVED 0x10 +#define BLSIG_LENGTH 0x1fffe +#define BLSIG_PARITY 0x20 +#define BCCKRXPHASE 0x4 + +#define BLSSIREADADDRESS 0x7f800000 +#define BLSSIREADEDGE 0x80000000 + +#define BLSSIREADBACKDATA 0xfffff + +#define BLSSIREADOKFLAG 0x1000 +#define BCCKSAMPLERATE 0x8 +#define BREGULATOR0STANDBY 0x1 +#define BREGULATORPLLSTANDBY 0x2 +#define BREGULATOR1STANDBY 0x4 +#define BPLLPOWERUP 0x8 +#define BDPLLPOWERUP 0x10 +#define BDA10POWERUP 0x20 +#define BAD7POWERUP 0x200 +#define BDA6POWERUP 0x2000 +#define BXTALPOWERUP 0x4000 +#define B40MDCLKPOWERUP 0x8000 +#define BDA6DEBUGMODE 0x20000 +#define BDA6SWING 0x380000 + +#define BADCLKPHASE 0x4000000 +#define B80MCLKDELAY 0x18000000 +#define BAFEWATCHDOGENABLE 0x20000000 + +#define BXTALCAP01 0xc0000000 +#define BXTALCAP23 0x3 +#define BXTALCAP92X 0x0f000000 +#define BXTALCAP 0x0f000000 + +#define BINTDIFCLKENABLE 0x400 +#define BEXTSIGCLKENABLE 0x800 +#define BBANDGAP_MBIAS_POWERUP 0x10000 +#define BAD11SH_GAIN 0xc0000 +#define BAD11NPUT_RANGE 0x700000 +#define BAD110P_CURRENT 0x3800000 +#define BLPATH_LOOPBACK 0x4000000 +#define BQPATH_LOOPBACK 0x8000000 +#define BAFE_LOOPBACK 0x10000000 +#define BDA10_SWING 0x7e0 +#define BDA10_REVERSE 0x800 +#define BDA_CLK_SOURCE 0x1000 +#define BDA7INPUT_RANGE 0x6000 +#define BDA7_GAIN 0x38000 +#define BDA7OUTPUT_CM_MODE 0x40000 +#define BDA7INPUT_CM_MODE 0x380000 +#define BDA7CURRENT 0xc00000 +#define BREGULATOR_ADJUST 0x7000000 +#define BAD11POWERUP_ATTX 0x1 +#define BDA10PS_ATTX 0x10 +#define BAD11POWERUP_ATRX 0x100 +#define BDA10PS_ATRX 0x1000 +#define BCCKRX_AGC_FORMAT 0x200 +#define BPSDFFT_SAMPLE_POINT 0xc000 +#define BPSD_AVERAGE_NUM 0x3000 +#define BIQPATH_CONTROL 0xc00 +#define BPSD_FREQ 0x3ff +#define BPSD_ANTENNA_PATH 0x30 +#define BPSD_IQ_SWITCH 0x40 +#define BPSD_RX_TRIGGER 0x400000 +#define BPSD_TX_TRIGGER 0x80000000 +#define BPSD_SINE_TONE_SCALE 0x7f000000 +#define BPSD_REPORT 0xffff + +#define BOFDM_TXSC 0x30000000 +#define BCCK_TXON 0x1 +#define BOFDM_TXON 0x2 +#define BDEBUG_PAGE 0xfff +#define BDEBUG_ITEM 0xff +#define BANTL 0x10 +#define BANT_NONHT 0x100 +#define BANT_HT1 0x1000 +#define BANT_HT2 0x10000 +#define BANT_HT1S1 0x100000 +#define BANT_NONHTS1 0x1000000 + +#define BCCK_BBMODE 0x3 +#define BCCK_TXPOWERSAVING 0x80 +#define BCCK_RXPOWERSAVING 0x40 + +#define BCCK_SIDEBAND 0x10 + +#define BCCK_SCRAMBLE 0x8 +#define BCCK_ANTDIVERSITY 0x8000 +#define BCCK_CARRIER_RECOVERY 0x4000 +#define BCCK_TXRATE 0x3000 +#define BCCK_DCCANCEL 0x0800 +#define BCCK_ISICANCEL 0x0400 +#define BCCK_MATCH_FILTER 0x0200 +#define BCCK_EQUALIZER 0x0100 +#define BCCK_PREAMBLE_DETECT 0x800000 +#define BCCK_FAST_FALSECCA 0x400000 +#define BCCK_CH_ESTSTART 0x300000 +#define BCCK_CCA_COUNT 0x080000 +#define BCCK_CS_LIM 0x070000 +#define BCCK_BIST_MODE 0x80000000 +#define BCCK_CCAMASK 0x40000000 +#define BCCK_TX_DAC_PHASE 0x4 +#define BCCK_RX_ADC_PHASE 0x20000000 +#define BCCKR_CP_MODE 0x0100 +#define BCCK_TXDC_OFFSET 0xf0 +#define BCCK_RXDC_OFFSET 0xf +#define BCCK_CCA_MODE 0xc000 +#define BCCK_FALSECS_LIM 0x3f00 +#define BCCK_CS_RATIO 0xc00000 +#define BCCK_CORGBIT_SEL 0x300000 +#define BCCK_PD_LIM 0x0f0000 +#define BCCK_NEWCCA 0x80000000 +#define BCCK_RXHP_OF_IG 0x8000 +#define BCCK_RXIG 0x7f00 +#define BCCK_LNA_POLARITY 0x800000 +#define BCCK_RX1ST_BAIN 0x7f0000 +#define BCCK_RF_EXTEND 0x20000000 +#define BCCK_RXAGC_SATLEVEL 0x1f000000 +#define BCCK_RXAGC_SATCOUNT 0xe0 +#define bCCKRxRFSettle 0x1f +#define BCCK_FIXED_RXAGC 0x8000 +#define BCCK_ANTENNA_POLARITY 0x2000 +#define BCCK_TXFILTER_TYPE 0x0c00 +#define BCCK_RXAGC_REPORTTYPE 0x0300 +#define BCCK_RXDAGC_EN 0x80000000 +#define BCCK_RXDAGC_PERIOD 0x20000000 +#define BCCK_RXDAGC_SATLEVEL 0x1f000000 +#define BCCK_TIMING_RECOVERY 0x800000 +#define BCCK_TXC0 0x3f0000 +#define BCCK_TXC1 0x3f000000 +#define BCCK_TXC2 0x3f +#define BCCK_TXC3 0x3f00 +#define BCCK_TXC4 0x3f0000 +#define BCCK_TXC5 0x3f000000 +#define BCCK_TXC6 0x3f +#define BCCK_TXC7 0x3f00 +#define BCCK_DEBUGPORT 0xff0000 +#define BCCK_DAC_DEBUG 0x0f000000 +#define BCCK_FALSEALARM_ENABLE 0x8000 +#define BCCK_FALSEALARM_READ 0x4000 +#define BCCK_TRSSI 0x7f +#define BCCK_RXAGC_REPORT 0xfe +#define BCCK_RXREPORT_ANTSEL 0x80000000 +#define BCCK_RXREPORT_MFOFF 0x40000000 +#define BCCK_RXREPORT_SQLOSS 0x20000000 +#define BCCK_RXREPORT_PKTLOSS 0x10000000 +#define BCCK_RXREPORT_LOCKEDBIT 0x08000000 +#define BCCK_RXREPORT_RATEERROR 0x04000000 +#define BCCK_RXREPORT_RXRATE 0x03000000 +#define BCCK_RXFA_COUNTER_LOWER 0xff +#define BCCK_RXFA_COUNTER_UPPER 0xff000000 +#define BCCK_RXHPAGC_START 0xe000 +#define BCCK_RXHPAGC_FINAL 0x1c00 +#define BCCK_RXFALSEALARM_ENABLE 0x8000 +#define BCCK_FACOUNTER_FREEZE 0x4000 +#define BCCK_TXPATH_SEL 0x10000000 +#define BCCK_DEFAULT_RXPATH 0xc000000 +#define BCCK_OPTION_RXPATH 0x3000000 + +#define BNUM_OFSTF 0x3 +#define BSHIFT_L 0xc0 +#define BGI_TH 0xc +#define BRXPATH_A 0x1 +#define BRXPATH_B 0x2 +#define BRXPATH_C 0x4 +#define BRXPATH_D 0x8 +#define BTXPATH_A 0x1 +#define BTXPATH_B 0x2 +#define BTXPATH_C 0x4 +#define BTXPATH_D 0x8 +#define BTRSSI_FREQ 0x200 +#define BADC_BACKOFF 0x3000 +#define BDFIR_BACKOFF 0xc000 +#define BTRSSI_LATCH_PHASE 0x10000 +#define BRX_LDC_OFFSET 0xff +#define BRX_QDC_OFFSET 0xff00 +#define BRX_DFIR_MODE 0x1800000 +#define BRX_DCNF_TYPE 0xe000000 +#define BRXIQIMB_A 0x3ff +#define BRXIQIMB_B 0xfc00 +#define BRXIQIMB_C 0x3f0000 +#define BRXIQIMB_D 0xffc00000 +#define BDC_DC_NOTCH 0x60000 +#define BRXNB_NOTCH 0x1f000000 +#define BPD_TH 0xf +#define BPD_TH_OPT2 0xc000 +#define BPWED_TH 0x700 +#define BIFMF_WIN_L 0x800 +#define BPD_OPTION 0x1000 +#define BMF_WIN_L 0xe000 +#define BBW_SEARCH_L 0x30000 +#define BWIN_ENH_L 0xc0000 +#define BBW_TH 0x700000 +#define BED_TH2 0x3800000 +#define BBW_OPTION 0x4000000 +#define BRADIO_TH 0x18000000 +#define BWINDOW_L 0xe0000000 +#define BSBD_OPTION 0x1 +#define BFRAME_TH 0x1c +#define BFS_OPTION 0x60 +#define BDC_SLOPE_CHECK 0x80 +#define BFGUARD_COUNTER_DC_L 0xe00 +#define BFRAME_WEIGHT_SHORT 0x7000 +#define BSUB_TUNE 0xe00000 +#define BFRAME_DC_LENGTH 0xe000000 +#define BSBD_START_OFFSET 0x30000000 +#define BFRAME_TH_2 0x7 +#define BFRAME_GI2_TH 0x38 +#define BGI2_SYNC_EN 0x40 +#define BSARCH_SHORT_EARLY 0x300 +#define BSARCH_SHORT_LATE 0xc00 +#define BSARCH_GI2_LATE 0x70000 +#define BCFOANTSUM 0x1 +#define BCFOACC 0x2 +#define BCFOSTARTOFFSET 0xc +#define BCFOLOOPBACK 0x70 +#define BCFOSUMWEIGHT 0x80 +#define BDAGCENABLE 0x10000 +#define BTXIQIMB_A 0x3ff +#define BTXIQIMB_b 0xfc00 +#define BTXIQIMB_C 0x3f0000 +#define BTXIQIMB_D 0xffc00000 +#define BTXIDCOFFSET 0xff +#define BTXIQDCOFFSET 0xff00 +#define BTXDFIRMODE 0x10000 +#define BTXPESUDO_NOISEON 0x4000000 +#define BTXPESUDO_NOISE_A 0xff +#define BTXPESUDO_NOISE_B 0xff00 +#define BTXPESUDO_NOISE_C 0xff0000 +#define BTXPESUDO_NOISE_D 0xff000000 +#define BCCA_DROPOPTION 0x20000 +#define BCCA_DROPTHRES 0xfff00000 +#define BEDCCA_H 0xf +#define BEDCCA_L 0xf0 +#define BLAMBDA_ED 0x300 +#define BRX_INITIALGAIN 0x7f +#define BRX_ANTDIV_EN 0x80 +#define BRX_AGC_ADDRESS_FOR_LNA 0x7f00 +#define BRX_HIGHPOWER_FLOW 0x8000 +#define BRX_AGC_FREEZE_THRES 0xc0000 +#define BRX_FREEZESTEP_AGC1 0x300000 +#define BRX_FREEZESTEP_AGC2 0xc00000 +#define BRX_FREEZESTEP_AGC3 0x3000000 +#define BRX_FREEZESTEP_AGC0 0xc000000 +#define BRXRSSI_CMP_EN 0x10000000 +#define BRXQUICK_AGCEN 0x20000000 +#define BRXAGC_FREEZE_THRES_MODE 0x40000000 +#define BRX_OVERFLOW_CHECKTYPE 0x80000000 +#define BRX_AGCSHIFT 0x7f +#define BTRSW_TRI_ONLY 0x80 +#define BPOWER_THRES 0x300 +#define BRXAGC_EN 0x1 +#define BRXAGC_TOGETHER_EN 0x2 +#define BRXAGC_MIN 0x4 +#define BRXHP_INI 0x7 +#define BRXHP_TRLNA 0x70 +#define BRXHP_RSSI 0x700 +#define BRXHP_BBP1 0x7000 +#define BRXHP_BBP2 0x70000 +#define BRXHP_BBP3 0x700000 +#define BRSSI_H 0x7f0000 +#define BRSSI_GEN 0x7f000000 +#define BRXSETTLE_TRSW 0x7 +#define BRXSETTLE_LNA 0x38 +#define BRXSETTLE_RSSI 0x1c0 +#define BRXSETTLE_BBP 0xe00 +#define BRXSETTLE_RXHP 0x7000 +#define BRXSETTLE_ANTSW_RSSI 0x38000 +#define BRXSETTLE_ANTSW 0xc0000 +#define BRXPROCESS_TIME_DAGC 0x300000 +#define BRXSETTLE_HSSI 0x400000 +#define BRXPROCESS_TIME_BBPPW 0x800000 +#define BRXANTENNA_POWER_SHIFT 0x3000000 +#define BRSSI_TABLE_SELECT 0xc000000 +#define BRXHP_FINAL 0x7000000 +#define BRXHPSETTLE_BBP 0x7 +#define BRXHTSETTLE_HSSI 0x8 +#define BRXHTSETTLE_RXHP 0x70 +#define BRXHTSETTLE_BBPPW 0x80 +#define BRXHTSETTLE_IDLE 0x300 +#define BRXHTSETTLE_RESERVED 0x1c00 +#define BRXHT_RXHP_EN 0x8000 +#define BRXAGC_FREEZE_THRES 0x30000 +#define BRXAGC_TOGETHEREN 0x40000 +#define BRXHTAGC_MIN 0x80000 +#define BRXHTAGC_EN 0x100000 +#define BRXHTDAGC_EN 0x200000 +#define BRXHT_RXHP_BBP 0x1c00000 +#define BRXHT_RXHP_FINAL 0xe0000000 +#define BRXPW_RADIO_TH 0x3 +#define BRXPW_RADIO_EN 0x4 +#define BRXMF_HOLD 0x3800 +#define BRXPD_DELAY_TH1 0x38 +#define BRXPD_DELAY_TH2 0x1c0 +#define BRXPD_DC_COUNT_MAX 0x600 +#define BRXPD_DELAY_TH 0x8000 +#define BRXPROCESS_DELAY 0xf0000 +#define BRXSEARCHRANGE_GI2_EARLY 0x700000 +#define BRXFRAME_FUARD_COUNTER_L 0x3800000 +#define BRXSGI_GUARD_L 0xc000000 +#define BRXSGI_SEARCH_L 0x30000000 +#define BRXSGI_TH 0xc0000000 +#define BDFSCNT0 0xff +#define BDFSCNT1 0xff00 +#define BDFSFLAG 0xf0000 +#define BMF_WEIGHT_SUM 0x300000 +#define BMINIDX_TH 0x7f000000 +#define BDAFORMAT 0x40000 +#define BTXCH_EMU_ENABLE 0x01000000 +#define BTRSW_ISOLATION_A 0x7f +#define BTRSW_ISOLATION_B 0x7f00 +#define BTRSW_ISOLATION_C 0x7f0000 +#define BTRSW_ISOLATION_D 0x7f000000 +#define BEXT_LNA_GAIN 0x7c00 + +#define BSTBC_EN 0x4 +#define BANTENNA_MAPPING 0x10 +#define BNSS 0x20 +#define BCFO_ANTSUM_ID 0x200 +#define BPHY_COUNTER_RESET 0x8000000 +#define BCFO_REPORT_GET 0x4000000 +#define BOFDM_CONTINUE_TX 0x10000000 +#define BOFDM_SINGLE_CARRIER 0x20000000 +#define BOFDM_SINGLE_TONE 0x40000000 +#define BHT_DETECT 0x100 +#define BCFOEN 0x10000 +#define BCFOVALUE 0xfff00000 +#define BSIGTONE_RE 0x3f +#define BSIGTONE_IM 0x7f00 +#define BCOUNTER_CCA 0xffff +#define BCOUNTER_PARITYFAIL 0xffff0000 +#define BCOUNTER_RATEILLEGAL 0xffff +#define BCOUNTER_CRC8FAIL 0xffff0000 +#define BCOUNTER_MCSNOSUPPORT 0xffff +#define BCOUNTER_FASTSYNC 0xffff +#define BSHORTCFO 0xfff +#define BSHORTCFOT_LENGTH 12 +#define BSHORTCFOF_LENGTH 11 +#define BLONGCFO 0x7ff +#define BLONGCFOT_LENGTH 11 +#define BLONGCFOF_LENGTH 11 +#define BTAILCFO 0x1fff +#define BTAILCFOT_LENGTH 13 +#define BTAILCFOF_LENGTH 12 +#define BNOISE_EN_PWDB 0xffff +#define BCC_POWER_DB 0xffff0000 +#define BMOISE_PWDB 0xffff +#define BPOWERMEAST_LENGTH 10 +#define BPOWERMEASF_LENGTH 3 +#define BRX_HT_BW 0x1 +#define BRXSC 0x6 +#define BRX_HT 0x8 +#define BNB_INTF_DET_ON 0x1 +#define BINTF_WIN_LEN_CFG 0x30 +#define BNB_INTF_TH_CFG 0x1c0 +#define BRFGAIN 0x3f +#define BTABLESEL 0x40 +#define BTRSW 0x80 +#define BRXSNR_A 0xff +#define BRXSNR_B 0xff00 +#define BRXSNR_C 0xff0000 +#define BRXSNR_D 0xff000000 +#define BSNR_EVMT_LENGTH 8 +#define BSNR_EVMF_LENGTH 1 +#define BCSI1ST 0xff +#define BCSI2ND 0xff00 +#define BRXEVM1ST 0xff0000 +#define BRXEVM2ND 0xff000000 +#define BSIGEVM 0xff +#define BPWDB 0xff00 +#define BSGIEN 0x10000 + +#define BSFACTOR_QMA1 0xf +#define BSFACTOR_QMA2 0xf0 +#define BSFACTOR_QMA3 0xf00 +#define BSFACTOR_QMA4 0xf000 +#define BSFACTOR_QMA5 0xf0000 +#define BSFACTOR_QMA6 0xf0000 +#define BSFACTOR_QMA7 0xf00000 +#define BSFACTOR_QMA8 0xf000000 +#define BSFACTOR_QMA9 0xf0000000 +#define BCSI_SCHEME 0x100000 + +#define BNOISE_LVL_TOP_SET 0x3 +#define BCHSMOOTH 0x4 +#define BCHSMOOTH_CFG1 0x38 +#define BCHSMOOTH_CFG2 0x1c0 +#define BCHSMOOTH_CFG3 0xe00 +#define BCHSMOOTH_CFG4 0x7000 +#define BMRCMODE 0x800000 +#define BTHEVMCFG 0x7000000 + +#define BLOOP_FIT_TYPE 0x1 +#define BUPD_CFO 0x40 +#define BUPD_CFO_OFFDATA 0x80 +#define BADV_UPD_CFO 0x100 +#define BADV_TIME_CTRL 0x800 +#define BUPD_CLKO 0x1000 +#define BFC 0x6000 +#define BTRACKING_MODE 0x8000 +#define BPHCMP_ENABLE 0x10000 +#define BUPD_CLKO_LTF 0x20000 +#define BCOM_CH_CFO 0x40000 +#define BCSI_ESTI_MODE 0x80000 +#define BADV_UPD_EQZ 0x100000 +#define BUCHCFG 0x7000000 +#define BUPDEQZ 0x8000000 + +#define BRX_PESUDO_NOISE_ON 0x20000000 +#define BRX_PESUDO_NOISE_A 0xff +#define BRX_PESUDO_NOISE_B 0xff00 +#define BRX_PESUDO_NOISE_C 0xff0000 +#define BRX_PESUDO_NOISE_D 0xff000000 +#define BRX_PESUDO_NOISESTATE_A 0xffff +#define BRX_PESUDO_NOISESTATE_B 0xffff0000 +#define BRX_PESUDO_NOISESTATE_C 0xffff +#define BRX_PESUDO_NOISESTATE_D 0xffff0000 + +#define BZEBRA1_HSSIENABLE 0x8 +#define BZEBRA1_TRXCONTROL 0xc00 +#define BZEBRA1_TRXGAINSETTING 0x07f +#define BZEBRA1_RXCOUNTER 0xc00 +#define BZEBRA1_TXCHANGEPUMP 0x38 +#define BZEBRA1_RXCHANGEPUMP 0x7 +#define BZEBRA1_CHANNEL_NUM 0xf80 +#define BZEBRA1_TXLPFBW 0x400 +#define BZEBRA1_RXLPFBW 0x600 + +#define BRTL8256REG_MODE_CTRL1 0x100 +#define BRTL8256REG_MODE_CTRL0 0x40 +#define BRTL8256REG_TXLPFBW 0x18 +#define BRTL8256REG_RXLPFBW 0x600 + +#define BRTL8258_TXLPFBW 0xc +#define BRTL8258_RXLPFBW 0xc00 +#define BRTL8258_RSSILPFBW 0xc0 + +#define BBYTE0 0x1 +#define BBYTE1 0x2 +#define BBYTE2 0x4 +#define BBYTE3 0x8 +#define BWORD0 0x3 +#define BWORD1 0xc +#define BWORD 0xf + +#define MASKBYTE0 0xff +#define MASKBYTE1 0xff00 +#define MASKBYTE2 0xff0000 +#define MASKBYTE3 0xff000000 +#define MASKHWORD 0xffff0000 +#define MASKLWORD 0x0000ffff +#define MASKDWORD 0xffffffff +#define MASK12BITS 0xfff +#define MASKH4BITS 0xf0000000 +#define MASKOFDM_D 0xffc00000 +#define MASKCCK 0x3f3f3f3f + +#define MASK4BITS 0x0f +#define MASK20BITS 0xfffff +#define RFREG_OFFSET_MASK 0xfffff + +#define BENABLE 0x1 +#define BDISABLE 0x0 + +#define LEFT_ANTENNA 0x0 +#define RIGHT_ANTENNA 0x1 + +#define TCHECK_TXSTATUS 500 +#define TUPDATE_RXCOUNTER 100 + +#define REG_UN_used_register 0x01bf + +/* WOL bit information */ +#define HAL92C_WOL_PTK_UPDATE_EVENT BIT(0) +#define HAL92C_WOL_GTK_UPDATE_EVENT BIT(1) +#define HAL92C_WOL_DISASSOC_EVENT BIT(2) +#define HAL92C_WOL_DEAUTH_EVENT BIT(3) +#define HAL92C_WOL_FW_DISCONNECT_EVENT BIT(4) + +#define WOL_REASON_PTK_UPDATE BIT(0) +#define WOL_REASON_GTK_UPDATE BIT(1) +#define WOL_REASON_DISASSOC BIT(2) +#define WOL_REASON_DEAUTH BIT(3) +#define WOL_REASON_FW_DISCONNECT BIT(4) +#endif diff --git a/drivers/staging/rtl8192ee/rtl8192ee/rf.c b/drivers/staging/rtl8192ee/rtl8192ee/rf.c new file mode 100644 index 000000000000..4f5a49ebca10 --- /dev/null +++ b/drivers/staging/rtl8192ee/rtl8192ee/rf.c @@ -0,0 +1,150 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#include "../wifi.h" +#include "reg.h" +#include "def.h" +#include "phy.h" +#include "rf.h" +#include "dm.h" + +static bool _rtl92ee_phy_rf6052_config_parafile(struct ieee80211_hw *hw); + +void rtl92ee_phy_rf6052_set_bandwidth(struct ieee80211_hw *hw, u8 bandwidth) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + + switch (bandwidth) { + case HT_CHANNEL_WIDTH_20: + rtlphy->rfreg_chnlval[0] = ((rtlphy->rfreg_chnlval[0] & + 0xfffff3ff) | BIT(10) | BIT(11)); + rtl_set_rfreg(hw, RF90_PATH_A, RF_CHNLBW, RFREG_OFFSET_MASK, + rtlphy->rfreg_chnlval[0]); + rtl_set_rfreg(hw, RF90_PATH_B, RF_CHNLBW, RFREG_OFFSET_MASK, + rtlphy->rfreg_chnlval[0]); + break; + case HT_CHANNEL_WIDTH_20_40: + rtlphy->rfreg_chnlval[0] = ((rtlphy->rfreg_chnlval[0] & + 0xfffff3ff) | BIT(10)); + rtl_set_rfreg(hw, RF90_PATH_A, RF_CHNLBW, RFREG_OFFSET_MASK, + rtlphy->rfreg_chnlval[0]); + rtl_set_rfreg(hw, RF90_PATH_B, RF_CHNLBW, RFREG_OFFSET_MASK, + rtlphy->rfreg_chnlval[0]); + break; + default: + RT_TRACE(COMP_ERR, DBG_EMERG, + ("unknown bandwidth: %#X\n", bandwidth)); + break; + } +} + +bool rtl92ee_phy_rf6052_config(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + + if (rtlphy->rf_type == RF_1T1R) + rtlphy->num_total_rfpath = 1; + else + rtlphy->num_total_rfpath = 2; + return _rtl92ee_phy_rf6052_config_parafile(hw); +} + +static bool _rtl92ee_phy_rf6052_config_parafile(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_phy *rtlphy = &(rtlpriv->phy); + u32 u4_regvalue = 0; + u8 rfpath; + bool rtstatus = true; + struct bb_reg_def *pphyreg; + + for (rfpath = 0; rfpath < rtlphy->num_total_rfpath; rfpath++) { + pphyreg = &rtlphy->phyreg_def[rfpath]; + + switch (rfpath) { + case RF90_PATH_A: + case RF90_PATH_C: + u4_regvalue = rtl_get_bbreg(hw, pphyreg->rfintfs, + BRFSI_RFENV); + break; + case RF90_PATH_B: + case RF90_PATH_D: + u4_regvalue = rtl_get_bbreg(hw, pphyreg->rfintfs, + BRFSI_RFENV << 16); + break; + } + + rtl_set_bbreg(hw, pphyreg->rfintfe, BRFSI_RFENV << 16, 0x1); + udelay(1); + + rtl_set_bbreg(hw, pphyreg->rfintfo, BRFSI_RFENV, 0x1); + udelay(1); + + rtl_set_bbreg(hw, pphyreg->rfhssi_para2, + B3WIREADDREAALENGTH, 0x0); + udelay(1); + + rtl_set_bbreg(hw, pphyreg->rfhssi_para2, B3WIREDATALENGTH, 0x0); + udelay(1); + + switch (rfpath) { + case RF90_PATH_A: + rtstatus = rtl92ee_phy_config_rf_with_headerfile(hw, + (enum radio_path)rfpath); + break; + case RF90_PATH_B: + rtstatus = rtl92ee_phy_config_rf_with_headerfile(hw, + (enum radio_path)rfpath); + break; + case RF90_PATH_C: + break; + case RF90_PATH_D: + break; + } + + switch (rfpath) { + case RF90_PATH_A: + case RF90_PATH_C: + rtl_set_bbreg(hw, pphyreg->rfintfs, + BRFSI_RFENV, u4_regvalue); + break; + case RF90_PATH_B: + case RF90_PATH_D: + rtl_set_bbreg(hw, pphyreg->rfintfs, + BRFSI_RFENV << 16, u4_regvalue); + break; + } + if (!rtstatus) { + RT_TRACE(COMP_INIT, DBG_TRACE, + ("Radio[%d] Fail!!", rfpath)); + return false; + } + } + + RT_TRACE(COMP_INIT, DBG_TRACE, ("\n")); + return rtstatus; +} diff --git a/drivers/staging/rtl8192ee/rtl8192ee/rf.h b/drivers/staging/rtl8192ee/rtl8192ee/rf.h new file mode 100644 index 000000000000..5bc394af4761 --- /dev/null +++ b/drivers/staging/rtl8192ee/rtl8192ee/rf.h @@ -0,0 +1,39 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#ifndef __RTL92E_RF_H__ +#define __RTL92E_RF_H__ + +#define RF6052_MAX_TX_PWR 0x3F +#define RF6052_MAX_REG 0x3F + +extern void rtl92ee_phy_rf6052_set_bandwidth(struct ieee80211_hw *hw, + u8 bandwidth); +extern bool rtl92ee_phy_rf6052_config(struct ieee80211_hw *hw); +#endif diff --git a/drivers/staging/rtl8192ee/rtl8192ee/sw.c b/drivers/staging/rtl8192ee/rtl8192ee/sw.c new file mode 100644 index 000000000000..f9c5729e2cd9 --- /dev/null +++ b/drivers/staging/rtl8192ee/rtl8192ee/sw.c @@ -0,0 +1,428 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#include +#include + +#include "../wifi.h" +#include "../core.h" +#include "../pci.h" +#include "reg.h" +#include "def.h" +#include "phy.h" +#include "dm.h" +#include "hw.h" +#include "sw.h" +#include "fw.h" +#include "trx.h" +#include "led.h" +#include "table.h" + +#include "../btcoexist/rtl_btc.h" + + +static void rtl92ee_init_aspm_vars(struct ieee80211_hw *hw) +{ + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + + /*close ASPM for AMD defaultly */ + rtlpci->const_amdpci_aspm = 0; + + /* + * ASPM PS mode. + * 0 - Disable ASPM, + * 1 - Enable ASPM without Clock Req, + * 2 - Enable ASPM with Clock Req, + * 3 - Alwyas Enable ASPM with Clock Req, + * 4 - Always Enable ASPM without Clock Req. + * set defult to RTL8192CE:3 RTL8192E:2 + * */ + rtlpci->const_pci_aspm = 3; + + /*Setting for PCI-E device */ + rtlpci->const_devicepci_aspm_setting = 0x03; + + /*Setting for PCI-E bridge */ + rtlpci->const_hostpci_aspm_setting = 0x02; + + /* + * In Hw/Sw Radio Off situation. + * 0 - Default, + * 1 - From ASPM setting without low Mac Pwr, + * 2 - From ASPM setting with low Mac Pwr, + * 3 - Bus D3 + * set default to RTL8192CE:0 RTL8192SE:2 + */ + rtlpci->const_hwsw_rfoff_d3 = 0; + + /* + * This setting works for those device with + * backdoor ASPM setting such as EPHY setting. + * 0 - Not support ASPM, + * 1 - Support ASPM, + * 2 - According to chipset. + */ + rtlpci->const_support_pciaspm = 1; +} + +int rtl92ee_init_sw_vars(struct ieee80211_hw *hw) +{ + int err = 0; + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + const struct firmware *firmware; + char *fw_name = NULL; + + rtl92ee_bt_reg_init(hw); + + rtlpci->msi_support = true; + rtlpriv->btcoexist.btc_ops = stg_rtl_btc_get_ops_pointer(); + + rtlpriv->dm.b_dm_initialgain_enable = 1; + rtlpriv->dm.dm_flag = 0; + rtlpriv->dm.b_disable_framebursting = 0; + /*rtlpriv->dm.thermalvalue = 0;*/ + rtlpci->transmit_config = CFENDFORM | BIT(15); + + /*just 2.4G band*/ + rtlpriv->rtlhal.current_bandtype = BAND_ON_2_4G; + rtlpriv->rtlhal.bandset = BAND_ON_2_4G; + rtlpriv->rtlhal.macphymode = SINGLEMAC_SINGLEPHY; + + rtlpci->receive_config = (RCR_APPFCS | + RCR_APP_MIC | + RCR_APP_ICV | + RCR_APP_PHYST_RXFF | + RCR_HTC_LOC_CTRL | + RCR_AMF | + RCR_ACF | + RCR_ADF | + RCR_AICV | + RCR_ACRC32 | + RCR_AB | + RCR_AM | + RCR_APM | + 0); + + rtlpci->irq_mask[0] = (u32) (IMR_PSTIMEOUT | + /* IMR_TBDER | + IMR_TBDOK | + IMR_BCNDMAINT0 |*/ + IMR_C2HCMD | + IMR_HIGHDOK | + IMR_MGNTDOK | + IMR_BKDOK | + IMR_BEDOK | + IMR_VIDOK | + IMR_VODOK | + IMR_RDU | + IMR_ROK | + 0); + rtlpci->irq_mask[1] = (u32) (IMR_RXFOVW | 0); + + /* for debug level */ + rtlpriv->dbg.global_debuglevel = rtlpriv->cfg->mod_params->debug; + /* for LPS & IPS */ + rtlpriv->psc.b_inactiveps = rtlpriv->cfg->mod_params->b_inactiveps; + rtlpriv->psc.b_swctrl_lps = rtlpriv->cfg->mod_params->b_swctrl_lps; + rtlpriv->psc.b_fwctrl_lps = rtlpriv->cfg->mod_params->b_fwctrl_lps; + rtlpriv->psc.b_reg_fwctrl_lps = 3; + rtlpriv->psc.reg_max_lps_awakeintvl = 5; + /* for ASPM, you can close aspm through + * set const_support_pciaspm = 0 */ + rtl92ee_init_aspm_vars(hw); + + if (rtlpriv->psc.b_reg_fwctrl_lps == 1) + rtlpriv->psc.fwctrl_psmode = FW_PS_MIN_MODE; + else if (rtlpriv->psc.b_reg_fwctrl_lps == 2) + rtlpriv->psc.fwctrl_psmode = FW_PS_MAX_MODE; + else if (rtlpriv->psc.b_reg_fwctrl_lps == 3) + rtlpriv->psc.fwctrl_psmode = FW_PS_DTIM_MODE; + + /* for early mode */ + rtlpriv->rtlhal.b_earlymode_enable = false; + + /*low power */ + rtlpriv->psc.b_low_power_enable = false; + + + /* for firmware buf */ + rtlpriv->rtlhal.pfirmware = vmalloc(0x8000); + if (!rtlpriv->rtlhal.pfirmware) { + RT_TRACE(COMP_ERR, DBG_EMERG, + ("Can't alloc buffer for fw.\n")); + return 1; + } + + fw_name = "rtlwifi/rtl8192eefw.bin"; + err = request_firmware(&firmware, fw_name, rtlpriv->io.dev); + + if (err) { + RT_TRACE(COMP_ERR, DBG_EMERG, + ("Failed to request firmware!\n")); + return 1; + } + if (firmware->size > 0x8000) { + RT_TRACE(COMP_ERR, DBG_EMERG, + ("Firmware is too big!\n")); + release_firmware(firmware); + return 1; + } + memcpy(rtlpriv->rtlhal.pfirmware, firmware->data, firmware->size); + rtlpriv->rtlhal.fwsize = firmware->size; + release_firmware(firmware); + + return err; +} + +void rtl92ee_deinit_sw_vars(struct ieee80211_hw *hw) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + if (rtlpriv->rtlhal.pfirmware) { + vfree(rtlpriv->rtlhal.pfirmware); + rtlpriv->rtlhal.pfirmware = NULL; + } +} + +/* get bt coexist status */ +bool rtl92ee_get_btc_status(void) +{ + return true; +} + + +static struct rtl_hal_ops rtl8192ee_hal_ops = { + .init_sw_vars = rtl92ee_init_sw_vars, + .deinit_sw_vars = rtl92ee_deinit_sw_vars, + .read_eeprom_info = rtl92ee_read_eeprom_info, + .interrupt_recognized = rtl92ee_interrupt_recognized,/*need check*/ + .hw_init = rtl92ee_hw_init, + .hw_disable = rtl92ee_card_disable, + .hw_suspend = rtl92ee_suspend, + .hw_resume = rtl92ee_resume, + .enable_interrupt = rtl92ee_enable_interrupt, + .disable_interrupt = rtl92ee_disable_interrupt, + .set_network_type = rtl92ee_set_network_type, + .set_chk_bssid = rtl92ee_set_check_bssid, + .set_qos = rtl92ee_set_qos, + .set_bcn_reg = rtl92ee_set_beacon_related_registers, + .set_bcn_intv = rtl92ee_set_beacon_interval, + .update_interrupt_mask = rtl92ee_update_interrupt_mask, + .get_hw_reg = rtl92ee_get_hw_reg, + .set_hw_reg = rtl92ee_set_hw_reg, + .update_rate_tbl = rtl92ee_update_hal_rate_tbl, + .pre_fill_tx_bd_desc = rtl92ee_pre_fill_tx_bd_desc, + .rx_desc_buff_remained_cnt = rtl92ee_rx_desc_buff_remained_cnt, + .rx_check_dma_ok = rtl92ee_rx_check_dma_ok, + .fill_tx_desc = rtl92ee_tx_fill_desc, + .fill_tx_cmddesc = rtl92ee_tx_fill_cmddesc, + .query_rx_desc = rtl92ee_rx_query_desc, + .set_channel_access = rtl92ee_update_channel_access_setting, + .radio_onoff_checking = rtl92ee_gpio_radio_on_off_checking, + .set_bw_mode = rtl92ee_phy_set_bw_mode, + .switch_channel = rtl92ee_phy_sw_chnl, + .dm_watchdog = rtl92ee_dm_watchdog, + .scan_operation_backup = rtl92ee_phy_scan_operation_backup, + .set_rf_power_state = rtl92ee_phy_set_rf_power_state, + .led_control = rtl92ee_led_control, + .set_desc = rtl92ee_set_desc, + .get_desc = rtl92ee_get_desc, + .is_tx_desc_closed = rtl92ee_is_tx_desc_closed, + .enable_hw_sec = rtl92ee_enable_hw_security_config, + .set_key = rtl92ee_set_key, + .init_sw_leds = rtl92ee_init_sw_leds, + .allow_all_destaddr = rtl92ee_allow_all_destaddr, + .get_bbreg = rtl92ee_phy_query_bb_reg, + .set_bbreg = rtl92ee_phy_set_bb_reg, + .get_rfreg = rtl92ee_phy_query_rf_reg, + .set_rfreg = rtl92ee_phy_set_rf_reg, + .fill_h2c_cmd = rtl92ee_fill_h2c_cmd, + .get_btc_status = rtl92ee_get_btc_status, + .rx_command_packet = rtl92ee_rx_command_packet, +}; + +static struct rtl_mod_params rtl92ee_mod_params = { + .sw_crypto = false, + .b_inactiveps = true, + .b_swctrl_lps = false, + .b_fwctrl_lps = true, + .debug = DBG_EMERG, +}; + +static struct rtl_hal_cfg rtl92ee_hal_cfg = { + .bar_id = 2, + .write_readback = true, + .name = "rtl92ee_pci", + .fw_name = "rtlwifi/rtl8192eefw.bin", + .ops = &rtl8192ee_hal_ops, + .mod_params = &rtl92ee_mod_params, + + .maps[SYS_ISO_CTRL] = REG_SYS_ISO_CTRL, + .maps[SYS_FUNC_EN] = REG_SYS_FUNC_EN, + .maps[SYS_CLK] = REG_SYS_CLKR, + .maps[MAC_RCR_AM] = AM, + .maps[MAC_RCR_AB] = AB, + .maps[MAC_RCR_ACRC32] = ACRC32, + .maps[MAC_RCR_ACF] = ACF, + .maps[MAC_RCR_AAP] = AAP, + .maps[MAC_HIMR] = REG_HIMR, + .maps[MAC_HIMRE] = REG_HIMRE, + + .maps[EFUSE_ACCESS] = REG_EFUSE_ACCESS, + + .maps[EFUSE_TEST] = REG_EFUSE_TEST, + .maps[EFUSE_CTRL] = REG_EFUSE_CTRL, + .maps[EFUSE_CLK] = 0, + .maps[EFUSE_CLK_CTRL] = REG_EFUSE_CTRL, + .maps[EFUSE_PWC_EV12V] = PWC_EV12V, + .maps[EFUSE_FEN_ELDR] = FEN_ELDR, + .maps[EFUSE_LOADER_CLK_EN] = LOADER_CLK_EN, + .maps[EFUSE_ANA8M] = ANA8M, + .maps[EFUSE_HWSET_MAX_SIZE] = HWSET_MAX_SIZE, + .maps[EFUSE_MAX_SECTION_MAP] = EFUSE_MAX_SECTION, + .maps[EFUSE_REAL_CONTENT_SIZE] = EFUSE_REAL_CONTENT_LEN, + .maps[EFUSE_OOB_PROTECT_BYTES_LEN] = EFUSE_OOB_PROTECT_BYTES, + + .maps[RWCAM] = REG_CAMCMD, + .maps[WCAMI] = REG_CAMWRITE, + .maps[RCAMO] = REG_CAMREAD, + .maps[CAMDBG] = REG_CAMDBG, + .maps[SECR] = REG_SECCFG, + .maps[SEC_CAM_NONE] = CAM_NONE, + .maps[SEC_CAM_WEP40] = CAM_WEP40, + .maps[SEC_CAM_TKIP] = CAM_TKIP, + .maps[SEC_CAM_AES] = CAM_AES, + .maps[SEC_CAM_WEP104] = CAM_WEP104, + + .maps[RTL_IMR_BCNDMAINT6] = IMR_BCNDMAINT6, + .maps[RTL_IMR_BCNDMAINT5] = IMR_BCNDMAINT5, + .maps[RTL_IMR_BCNDMAINT4] = IMR_BCNDMAINT4, + .maps[RTL_IMR_BCNDMAINT3] = IMR_BCNDMAINT3, + .maps[RTL_IMR_BCNDMAINT2] = IMR_BCNDMAINT2, + .maps[RTL_IMR_BCNDMAINT1] = IMR_BCNDMAINT1, +/* .maps[RTL_IMR_BCNDOK8] = IMR_BCNDOK8, */ /*need check*/ + .maps[RTL_IMR_BCNDOK7] = IMR_BCNDOK7, + .maps[RTL_IMR_BCNDOK6] = IMR_BCNDOK6, + .maps[RTL_IMR_BCNDOK5] = IMR_BCNDOK5, + .maps[RTL_IMR_BCNDOK4] = IMR_BCNDOK4, + .maps[RTL_IMR_BCNDOK3] = IMR_BCNDOK3, + .maps[RTL_IMR_BCNDOK2] = IMR_BCNDOK2, + .maps[RTL_IMR_BCNDOK1] = IMR_BCNDOK1, +/* .maps[RTL_IMR_TIMEOUT2] = IMR_TIMEOUT2,*/ +/* .maps[RTL_IMR_TIMEOUT1] = IMR_TIMEOUT1,*/ + + .maps[RTL_IMR_TXFOVW] = IMR_TXFOVW, + .maps[RTL_IMR_PSTIMEOUT] = IMR_PSTIMEOUT, + .maps[RTL_IMR_BcnInt] = IMR_BCNDMAINT0, + .maps[RTL_IMR_RXFOVW] = IMR_RXFOVW, + .maps[RTL_IMR_RDU] = IMR_RDU, + .maps[RTL_IMR_ATIMEND] = IMR_ATIMEND, + .maps[RTL_IMR_BDOK] = IMR_BCNDOK0, + .maps[RTL_IMR_MGNTDOK] = IMR_MGNTDOK, + .maps[RTL_IMR_TBDER] = IMR_TBDER, + .maps[RTL_IMR_HIGHDOK] = IMR_HIGHDOK, + .maps[RTL_IMR_TBDOK] = IMR_TBDOK, + .maps[RTL_IMR_BKDOK] = IMR_BKDOK, + .maps[RTL_IMR_BEDOK] = IMR_BEDOK, + .maps[RTL_IMR_VIDOK] = IMR_VIDOK, + .maps[RTL_IMR_VODOK] = IMR_VODOK, + .maps[RTL_IMR_ROK] = IMR_ROK, + .maps[RTL_IBSS_INT_MASKS] = (IMR_BCNDMAINT0 | IMR_TBDOK | IMR_TBDER), + + .maps[RTL_RC_CCK_RATE1M] = DESC92C_RATE1M, + .maps[RTL_RC_CCK_RATE2M] = DESC92C_RATE2M, + .maps[RTL_RC_CCK_RATE5_5M] = DESC92C_RATE5_5M, + .maps[RTL_RC_CCK_RATE11M] = DESC92C_RATE11M, + .maps[RTL_RC_OFDM_RATE6M] = DESC92C_RATE6M, + .maps[RTL_RC_OFDM_RATE9M] = DESC92C_RATE9M, + .maps[RTL_RC_OFDM_RATE12M] = DESC92C_RATE12M, + .maps[RTL_RC_OFDM_RATE18M] = DESC92C_RATE18M, + .maps[RTL_RC_OFDM_RATE24M] = DESC92C_RATE24M, + .maps[RTL_RC_OFDM_RATE36M] = DESC92C_RATE36M, + .maps[RTL_RC_OFDM_RATE48M] = DESC92C_RATE48M, + .maps[RTL_RC_OFDM_RATE54M] = DESC92C_RATE54M, + + .maps[RTL_RC_HT_RATEMCS7] = DESC92C_RATEMCS7, + .maps[RTL_RC_HT_RATEMCS15] = DESC92C_RATEMCS15, +}; + +static struct pci_device_id rtl92ee_pci_ids[] = { + {RTL_PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x818B, rtl92ee_hal_cfg)}, + {}, +}; + +MODULE_DEVICE_TABLE(pci, rtl92ee_pci_ids); + +MODULE_AUTHOR("Realtek WlanFAE "); +MODULE_AUTHOR("Larry Finger "); +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("Realtek 8192E 802.11n PCI wireless"); +MODULE_FIRMWARE("rtlwifi/rtl8192eefw.bin"); + +module_param_named(swenc, rtl92ee_mod_params.sw_crypto, bool, 0444); +module_param_named(debug, rtl92ee_mod_params.debug, int, 0444); +module_param_named(ips, rtl92ee_mod_params.b_inactiveps, bool, 0444); +module_param_named(swlps, rtl92ee_mod_params.b_swctrl_lps, bool, 0444); +module_param_named(fwlps, rtl92ee_mod_params.b_fwctrl_lps, bool, 0444); +MODULE_PARM_DESC(swenc, "using hardware crypto (default 0 [hardware])\n"); +MODULE_PARM_DESC(ips, "using no link power save (default 1 is open)\n"); +MODULE_PARM_DESC(fwlps, "using linked fw control power save (default 1 is open)\n"); +MODULE_PARM_DESC(debug, "Set debug level (0-5) (default 0)"); + +static SIMPLE_DEV_PM_OPS(rtlwifi_pm_ops, stg_rtl_pci_suspend, + stg_rtl_pci_resume); + +static struct pci_driver rtl92ee_driver = { + .name = KBUILD_MODNAME, + .id_table = rtl92ee_pci_ids, + .probe = stg_rtl_pci_probe, + .remove = stg_rtl_pci_disconnect, + + .driver.pm = &rtlwifi_pm_ops, +}; + +static int __init rtl92ee_module_init(void) +{ + int ret; + ret = rtl_core_module_init(); + if (ret) + return ret; + + ret = pci_register_driver(&rtl92ee_driver); + if (ret) + RT_ASSERT(false, (": No device found\n")); + + return ret; +} + +static void __exit rtl92ee_module_exit(void) +{ + pci_unregister_driver(&rtl92ee_driver); + rtl_core_module_exit(); +} + +module_init(rtl92ee_module_init); +module_exit(rtl92ee_module_exit); diff --git a/drivers/staging/rtl8192ee/rtl8192ee/sw.h b/drivers/staging/rtl8192ee/rtl8192ee/sw.h new file mode 100644 index 000000000000..0170257a20c9 --- /dev/null +++ b/drivers/staging/rtl8192ee/rtl8192ee/sw.h @@ -0,0 +1,39 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#ifndef __RTL92E_SW_H__ +#define __RTL92E_SW_H__ + +int rtl92ee_init_sw_vars(struct ieee80211_hw *hw); +void rtl92ee_deinit_sw_vars(struct ieee80211_hw *hw); +bool rtl92ee_get_btc_status(void); +int rtl_core_module_init(void); +void rtl_core_module_exit(void); + +#endif diff --git a/drivers/staging/rtl8192ee/rtl8192ee/table.c b/drivers/staging/rtl8192ee/rtl8192ee/table.c new file mode 100644 index 000000000000..c7eb9be53cc4 --- /dev/null +++ b/drivers/staging/rtl8192ee/rtl8192ee/table.c @@ -0,0 +1,882 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Created on 2010/ 5/18, 1:41 + * + * Larry Finger + * + *****************************************************************************/ + +#include "table.h" +u32 RTL8192EE_PHY_REG_ARRAY[] = { + 0x800, 0x80040000, + 0x804, 0x00000003, + 0x808, 0x0000FC00, + 0x80C, 0x0000000A, + 0x810, 0x10001331, + 0x814, 0x020C3D10, + 0x818, 0x02220385, + 0x81C, 0x00000000, + 0x820, 0x01000100, + 0x824, 0x00390204, + 0x828, 0x01000100, + 0x82C, 0x00390204, + 0x830, 0x32323232, + 0x834, 0x30303030, + 0x838, 0x30303030, + 0x83C, 0x30303030, + 0x840, 0x00010000, + 0x844, 0x00010000, + 0x848, 0x28282828, + 0x84C, 0x28282828, + 0x850, 0x00000000, + 0x854, 0x00000000, + 0x858, 0x009A009A, + 0x85C, 0x01000014, + 0x860, 0x66F60000, + 0x864, 0x061F0000, + 0x868, 0x30303030, + 0x86C, 0x30303030, + 0x870, 0x00000000, + 0x874, 0x55004200, + 0x878, 0x08080808, + 0x87C, 0x00000000, + 0x880, 0xB0000C1C, + 0x884, 0x00000001, + 0x888, 0x00000000, + 0x88C, 0xCC0000C0, + 0x890, 0x00000800, + 0x894, 0xFFFFFFFE, + 0x898, 0x40302010, + 0x900, 0x00000000, + 0x904, 0x00000023, + 0x908, 0x00000000, + 0x90C, 0x81121313, + 0x910, 0x806C0001, + 0x914, 0x00000001, + 0x918, 0x00000000, + 0x91C, 0x00010000, + 0x924, 0x00000001, + 0x928, 0x00000000, + 0x92C, 0x00000000, + 0x930, 0x00000000, + 0x934, 0x00000000, + 0x938, 0x00000000, + 0x93C, 0x00000000, + 0x940, 0x00000000, + 0x944, 0x00000000, + 0x94C, 0x00000008, + 0xA00, 0x00D0C7C8, + 0xA04, 0x81FF000C, + 0xA08, 0x8C838300, + 0xA0C, 0x2E68120F, + 0xA10, 0x95009B78, + 0xA14, 0x1114D028, + 0xA18, 0x00881117, + 0xA1C, 0x89140F00, + 0xA20, 0x1A1B0000, + 0xA24, 0x090E1317, + 0xA28, 0x00000204, + 0xA2C, 0x00D30000, + 0xA70, 0x101FBF00, + 0xA74, 0x00000007, + 0xA78, 0x00000900, + 0xA7C, 0x225B0606, + 0xA80, 0x218075B1, + 0xB38, 0x00000000, + 0xC00, 0x48071D40, + 0xC04, 0x03A05633, + 0xC08, 0x000000E4, + 0xC0C, 0x6C6C6C6C, + 0xC10, 0x08800000, + 0xC14, 0x40000100, + 0xC18, 0x08800000, + 0xC1C, 0x40000100, + 0xC20, 0x00000000, + 0xC24, 0x00000000, + 0xC28, 0x00000000, + 0xC2C, 0x00000000, + 0xC30, 0x69E9AC47, + 0xC34, 0x469652AF, + 0xC38, 0x49795994, + 0xC3C, 0x0A97971C, + 0xC40, 0x1F7C403F, + 0xC44, 0x000100B7, + 0xC48, 0xEC020107, + 0xC4C, 0x007F037F, + 0xFF010718, 0xABCD, + 0xC50, 0x00340220, + 0xCDCDCDCD, 0xCDCD, + 0xC50, 0x00340020, + 0xFF010718, 0xDEAD, + 0xC54, 0x0080801F, + 0xFF010718, 0xABCD, + 0xC58, 0x00000220, + 0xCDCDCDCD, 0xCDCD, + 0xC58, 0x00000020, + 0xFF010718, 0xDEAD, + 0xC5C, 0x00248492, + 0xC60, 0x00000000, + 0xC64, 0x7112848B, + 0xC68, 0x47C00BFF, + 0xC6C, 0x00000036, + 0xC70, 0x00000600, + 0xC74, 0x02013169, + 0xC78, 0x0000001F, + 0xC7C, 0x00B91612, + 0xFF010718, 0xABCD, + 0xC80, 0x2D4000B5, + 0xCDCDCDCD, 0xCDCD, + 0xC80, 0x40000100, + 0xFF010718, 0xDEAD, + 0xC84, 0x21F60000, + 0xFF010718, 0xABCD, + 0xC88, 0x2D4000B5, + 0xCDCDCDCD, 0xCDCD, + 0xC88, 0x40000100, + 0xFF010718, 0xDEAD, + 0xC8C, 0xA0E40000, + 0xC90, 0x00121820, + 0xC94, 0x00000000, + 0xC98, 0x00121820, + 0xC9C, 0x00007F7F, + 0xCA0, 0x00000000, + 0xCA4, 0x000300A0, + 0xCA8, 0x00000000, + 0xCAC, 0x00000000, + 0xCB0, 0x00000000, + 0xCB4, 0x00000000, + 0xCB8, 0x00000000, + 0xCBC, 0x28000000, + 0xCC0, 0x00000000, + 0xCC4, 0x00000000, + 0xCC8, 0x00000000, + 0xCCC, 0x00000000, + 0xCD0, 0x00000000, + 0xCD4, 0x00000000, + 0xCD8, 0x64B22427, + 0xCDC, 0x00766932, + 0xCE0, 0x00222222, + 0xCE4, 0x00040000, + 0xCE8, 0x77644302, + 0xCEC, 0x2F97D40C, + 0xD00, 0x00080740, + 0xD04, 0x00020403, + 0xD08, 0x0000907F, + 0xD0C, 0x20010201, + 0xD10, 0xA0633333, + 0xD14, 0x3333BC43, + 0xD18, 0x7A8F5B6B, + 0xD1C, 0x0000007F, + 0xD2C, 0xCC979975, + 0xD30, 0x00000000, + 0xD34, 0x80608000, + 0xD38, 0x00000000, + 0xD3C, 0x00127353, + 0xD40, 0x00000000, + 0xD44, 0x00000000, + 0xD48, 0x00000000, + 0xD4C, 0x00000000, + 0xD50, 0x6437140A, + 0xD54, 0x00000000, + 0xD58, 0x00000282, + 0xD5C, 0x30032064, + 0xD60, 0x4653DE68, + 0xD64, 0x04518A3C, + 0xD68, 0x00002101, + 0xD6C, 0x2A201C16, + 0xD70, 0x1812362E, + 0xD74, 0x322C2220, + 0xD78, 0x000E3C24, + 0xD80, 0x01081008, + 0xD84, 0x00000800, + 0xD88, 0xF0B50000, + 0xE00, 0x30303030, + 0xE04, 0x30303030, + 0xE08, 0x03903030, + 0xE10, 0x30303030, + 0xE14, 0x30303030, + 0xE18, 0x30303030, + 0xE1C, 0x30303030, + 0xE28, 0x00000000, + 0xE30, 0x1000DC1F, + 0xE34, 0x10008C1F, + 0xE38, 0x02140102, + 0xE3C, 0x681604C2, + 0xE40, 0x01007C00, + 0xE44, 0x01004800, + 0xE48, 0xFB000000, + 0xE4C, 0x000028D1, + 0xE50, 0x1000DC1F, + 0xE54, 0x10008C1F, + 0xE58, 0x02140102, + 0xE5C, 0x28160D05, + 0xE60, 0x00000008, + 0xE68, 0x0FC05656, + 0xE6C, 0x03C09696, + 0xE70, 0x03C09696, + 0xE74, 0x0C005656, + 0xE78, 0x0C005656, + 0xE7C, 0x0C005656, + 0xE80, 0x0C005656, + 0xE84, 0x03C09696, + 0xE88, 0x0C005656, + 0xE8C, 0x03C09696, + 0xED0, 0x03C09696, + 0xED4, 0x03C09696, + 0xED8, 0x03C09696, + 0xEDC, 0x0000D6D6, + 0xEE0, 0x0000D6D6, + 0xEEC, 0x0FC01616, + 0xEE4, 0xB0000C1C, + 0xEE8, 0x00000001, + 0xF14, 0x00000003, + 0xF4C, 0x00000000, + 0xF00, 0x00000300, +}; + +u32 RTL8192EE_PHY_REG_ARRAY_PG[] = { + 0, 0, 0, 0x00000e08, 0x0000ff00, 0x00003200, + 0, 0, 1, 0x00000e08, 0x0000ff00, 0x00003200, + 0, 0, 0, 0x0000086c, 0xffffff00, 0x32323200, + 0, 0, 1, 0x0000086c, 0xffffff00, 0x32323200, + 0, 0, 0, 0x00000e00, 0xffffffff, 0x34343636, + 0, 0, 1, 0x00000e00, 0xffffffff, 0x34343636, + 0, 0, 0, 0x00000e04, 0xffffffff, 0x28283032, + 0, 0, 1, 0x00000e04, 0xffffffff, 0x28283032, + 0, 0, 0, 0x00000e10, 0xffffffff, 0x34363840, + 0, 0, 1, 0x00000e10, 0xffffffff, 0x34363840, + 0, 0, 0, 0x00000e14, 0xffffffff, 0x26283032, + 0, 0, 1, 0x00000e14, 0xffffffff, 0x26283032, + 0, 0, 1, 0x00000e18, 0xffffffff, 0x36384040, + 0, 0, 1, 0x00000e1c, 0xffffffff, 0x24262832, + 0, 1, 0, 0x00000838, 0xffffff00, 0x32323200, + 0, 1, 1, 0x00000838, 0xffffff00, 0x32323200, + 0, 1, 0, 0x0000086c, 0x000000ff, 0x00000032, + 0, 1, 1, 0x0000086c, 0x000000ff, 0x00000032, + 0, 1, 0, 0x00000830, 0xffffffff, 0x34343636, + 0, 1, 1, 0x00000830, 0xffffffff, 0x34343636, + 0, 1, 0, 0x00000834, 0xffffffff, 0x28283032, + 0, 1, 1, 0x00000834, 0xffffffff, 0x28283032, + 0, 1, 0, 0x0000083c, 0xffffffff, 0x34363840, + 0, 1, 1, 0x0000083c, 0xffffffff, 0x34363840, + 0, 1, 0, 0x00000848, 0xffffffff, 0x26283032, + 0, 1, 1, 0x00000848, 0xffffffff, 0x26283032, + 0, 1, 1, 0x0000084c, 0xffffffff, 0x36384040, + 0, 1, 1, 0x00000868, 0xffffffff, 0x24262832 +}; + +u32 RTL8192EE_RADIOA_ARRAY[] = { + 0x07F, 0x00000082, + 0x081, 0x0003FC00, + 0x000, 0x00030000, + 0x008, 0x00008400, + 0x018, 0x00000407, + 0x019, 0x00000012, + 0x01B, 0x00000064, + 0x01E, 0x00080009, + 0x01F, 0x00000880, + 0x02F, 0x0001A060, + 0x03F, 0x00000000, + 0x042, 0x000060C0, + 0x057, 0x000D0000, + 0x058, 0x000BE180, + 0x067, 0x00001552, + 0x083, 0x00000000, + 0x0B0, 0x000FF9F1, + 0x0B1, 0x00055418, + 0x0B2, 0x0008CC00, + 0x0B4, 0x00043083, + 0x0B5, 0x00008166, + 0x0B6, 0x0000803E, + 0x0B7, 0x0001C69F, + 0x0B8, 0x0000407F, + 0x0B9, 0x00080001, + 0x0BA, 0x00040001, + 0x0BB, 0x00000400, + 0x0BF, 0x000C0000, + 0x0C2, 0x00002400, + 0x0C3, 0x00000009, + 0x0C4, 0x00040C91, + 0x0C5, 0x00099999, + 0x0C6, 0x000000A3, + 0x0C7, 0x00088820, + 0x0C8, 0x00076C06, + 0x0C9, 0x00000000, + 0x0CA, 0x00080000, + 0x0DF, 0x00000180, + 0x0EF, 0x000001A0, + 0x051, 0x00069545, + 0x052, 0x0007E45E, + 0x053, 0x00000071, + 0x056, 0x00051FF3, + 0x035, 0x000000A8, + 0x035, 0x000001E2, + 0x035, 0x000002A8, + 0x036, 0x00001C24, + 0x036, 0x00009C24, + 0x036, 0x00011C24, + 0x036, 0x00019C24, + 0x018, 0x00000C07, + 0x05A, 0x00048000, + 0x019, 0x000739D0, + 0xFF010718, 0xABCD, + 0x034, 0x0000A093, + 0x034, 0x0000908F, + 0x034, 0x0000808C, + 0x034, 0x0000704D, + 0x034, 0x0000604A, + 0x034, 0x00005047, + 0x034, 0x0000400A, + 0x034, 0x00003007, + 0x034, 0x00002004, + 0x034, 0x00001001, + 0x034, 0x00000000, + 0xCDCDCDCD, 0xCDCD, + 0x034, 0x0000ADD7, + 0x034, 0x00009DD4, + 0x034, 0x00008DD1, + 0x034, 0x00007DCE, + 0x034, 0x00006DCB, + 0x034, 0x00005DC8, + 0x034, 0x00004DC5, + 0x034, 0x000034CC, + 0x034, 0x0000244F, + 0x034, 0x0000144C, + 0x034, 0x00000014, + 0xFF010718, 0xDEAD, + 0x000, 0x00030159, + 0x084, 0x00068180, + 0x086, 0x0000014E, + 0x087, 0x00048E00, + 0x08E, 0x00065540, + 0x08F, 0x00088000, + 0x0EF, 0x000020A0, + 0xFF010718, 0xABCD, + 0x03B, 0x000F07B0, + 0xCDCDCDCD, 0xCDCD, + 0x03B, 0x000F02B0, + 0xFF010718, 0xDEAD, + 0x03B, 0x000EF7B0, + 0x03B, 0x000D4FB0, + 0x03B, 0x000CF060, + 0x03B, 0x000B0090, + 0x03B, 0x000A0080, + 0x03B, 0x00090080, + 0x03B, 0x0008F780, + 0xFF010718, 0xABCD, + 0x03B, 0x000787B0, + 0xCDCDCDCD, 0xCDCD, + 0x03B, 0x00078730, + 0xFF010718, 0xDEAD, + 0x03B, 0x00060FB0, + 0x03B, 0x0005FFA0, + 0x03B, 0x00040620, + 0x03B, 0x00037090, + 0x03B, 0x00020080, + 0x03B, 0x0001F060, + 0x03B, 0x0000FFB0, + 0x0EF, 0x000000A0, + 0x0FE, 0x00000000, + 0x018, 0x0000FC07, + 0x0FE, 0x00000000, + 0x0FE, 0x00000000, + 0x0FE, 0x00000000, + 0x0FE, 0x00000000, + 0x01E, 0x00000001, + 0x01F, 0x00080000, + 0x000, 0x00033E70, +}; + +u32 RTL8192EE_RADIOB_ARRAY[] = { + 0x07F, 0x00000082, + 0x081, 0x0003FC00, + 0x000, 0x00030000, + 0x008, 0x00008400, + 0x018, 0x00000407, + 0x019, 0x00000012, + 0x01B, 0x00000064, + 0x01E, 0x00080009, + 0x01F, 0x00000880, + 0x02F, 0x0001A060, + 0x03F, 0x00000000, + 0x042, 0x000060C0, + 0x057, 0x000D0000, + 0x058, 0x000BE180, + 0x067, 0x00001552, + 0x07F, 0x00000082, + 0x081, 0x0003F000, + 0x083, 0x00000000, + 0x0DF, 0x00000180, + 0x0EF, 0x000001A0, + 0x051, 0x00069545, + 0x052, 0x0007E42E, + 0x053, 0x00000071, + 0x056, 0x00051FF3, + 0x035, 0x000000A8, + 0x035, 0x000001E0, + 0x035, 0x000002A8, + 0x036, 0x00001CA8, + 0x036, 0x00009C24, + 0x036, 0x00011C24, + 0x036, 0x00019C24, + 0x018, 0x00000C07, + 0x05A, 0x00048000, + 0x019, 0x000739D0, + 0xFF010718, 0xABCD, + 0x034, 0x0000A093, + 0x034, 0x0000908F, + 0x034, 0x0000808C, + 0x034, 0x0000704D, + 0x034, 0x0000604A, + 0x034, 0x00005047, + 0x034, 0x0000400A, + 0x034, 0x00003007, + 0x034, 0x00002004, + 0x034, 0x00001001, + 0x034, 0x00000000, + 0xCDCDCDCD, 0xCDCD, + 0x034, 0x0000ADD7, + 0x034, 0x00009DD4, + 0x034, 0x00008DD1, + 0x034, 0x00007DCE, + 0x034, 0x00006DCB, + 0x034, 0x00005DC8, + 0x034, 0x00004DC5, + 0x034, 0x000034CC, + 0x034, 0x0000244F, + 0x034, 0x0000144C, + 0x034, 0x00000014, + 0xFF010718, 0xDEAD, + 0x000, 0x00030159, + 0x084, 0x00068180, + 0x086, 0x000000CE, + 0x087, 0x00048A00, + 0x08E, 0x00065540, + 0x08F, 0x00088000, + 0x0EF, 0x000020A0, + 0xFF010718, 0xABCD, + 0x03B, 0x000F07B0, + 0xCDCDCDCD, 0xCDCD, + 0x03B, 0x000F02B0, + 0xFF010718, 0xDEAD, + 0x03B, 0x000EF7B0, + 0x03B, 0x000D4FB0, + 0x03B, 0x000CF060, + 0x03B, 0x000B0090, + 0x03B, 0x000A0080, + 0x03B, 0x00090080, + 0x03B, 0x0008F780, + 0xFF010718, 0xABCD, + 0x03B, 0x000787B0, + 0xCDCDCDCD, 0xCDCD, + 0x03B, 0x00078730, + 0xFF010718, 0xDEAD, + 0x03B, 0x00060FB0, + 0x03B, 0x0005FFA0, + 0x03B, 0x00040620, + 0x03B, 0x00037090, + 0x03B, 0x00020080, + 0x03B, 0x0001F060, + 0x03B, 0x0000FFB0, + 0x0EF, 0x000000A0, + 0x000, 0x00010159, + 0x0FE, 0x00000000, + 0x0FE, 0x00000000, + 0x0FE, 0x00000000, + 0x0FE, 0x00000000, + 0x01E, 0x00000001, + 0x01F, 0x00080000, + 0x000, 0x00033E70, +}; + +u32 RTL8192EE_MAC_ARRAY[] = { + 0x011, 0x000000EB, + 0x012, 0x00000007, + 0x014, 0x00000075, + 0x303, 0x000000A7, + 0x428, 0x0000000A, + 0x429, 0x00000010, + 0x430, 0x00000000, + 0x431, 0x00000000, + 0x432, 0x00000000, + 0x433, 0x00000001, + 0x434, 0x00000004, + 0x435, 0x00000005, + 0x436, 0x00000007, + 0x437, 0x00000008, + 0x43C, 0x00000004, + 0x43D, 0x00000005, + 0x43E, 0x00000007, + 0x43F, 0x00000008, + 0x440, 0x0000005D, + 0x441, 0x00000001, + 0x442, 0x00000000, + 0x444, 0x00000010, + 0x445, 0x00000000, + 0x446, 0x00000000, + 0x447, 0x00000000, + 0x448, 0x00000000, + 0x449, 0x000000F0, + 0x44A, 0x0000000F, + 0x44B, 0x0000003E, + 0x44C, 0x00000010, + 0x44D, 0x00000000, + 0x44E, 0x00000000, + 0x44F, 0x00000000, + 0x450, 0x00000000, + 0x451, 0x000000F0, + 0x452, 0x0000000F, + 0x453, 0x00000000, + 0x456, 0x0000005E, + 0x460, 0x00000066, + 0x461, 0x00000066, + 0x4C8, 0x000000FF, + 0x4C9, 0x00000008, + 0x4CC, 0x000000FF, + 0x4CD, 0x000000FF, + 0x4CE, 0x00000001, + 0x500, 0x00000026, + 0x501, 0x000000A2, + 0x502, 0x0000002F, + 0x503, 0x00000000, + 0x504, 0x00000028, + 0x505, 0x000000A3, + 0x506, 0x0000005E, + 0x507, 0x00000000, + 0x508, 0x0000002B, + 0x509, 0x000000A4, + 0x50A, 0x0000005E, + 0x50B, 0x00000000, + 0x50C, 0x0000004F, + 0x50D, 0x000000A4, + 0x50E, 0x00000000, + 0x50F, 0x00000000, + 0x512, 0x0000001C, + 0x514, 0x0000000A, + 0x516, 0x0000000A, + 0x525, 0x0000004F, + 0x540, 0x00000012, + 0x541, 0x00000064, + 0x550, 0x00000010, + 0x551, 0x00000010, + 0x559, 0x00000002, + 0x55C, 0x00000050, + 0x55D, 0x000000FF, + 0x605, 0x00000030, + 0x608, 0x0000000E, + 0x609, 0x0000002A, + 0x620, 0x000000FF, + 0x621, 0x000000FF, + 0x622, 0x000000FF, + 0x623, 0x000000FF, + 0x624, 0x000000FF, + 0x625, 0x000000FF, + 0x626, 0x000000FF, + 0x627, 0x000000FF, + 0x638, 0x00000050, + 0x63C, 0x0000000A, + 0x63D, 0x0000000A, + 0x63E, 0x0000000E, + 0x63F, 0x0000000E, + 0x640, 0x00000040, + 0x642, 0x00000040, + 0x643, 0x00000000, + 0x652, 0x000000C8, + 0x66E, 0x00000005, + 0x700, 0x00000021, + 0x701, 0x00000043, + 0x702, 0x00000065, + 0x703, 0x00000087, + 0x708, 0x00000021, + 0x709, 0x00000043, + 0x70A, 0x00000065, + 0x70B, 0x00000087, +}; + +u32 RTL8192EE_AGC_TAB_ARRAY[] = { + 0xFF010718, 0xABCD, + 0xC78, 0xFA000001, + 0xC78, 0xF9010001, + 0xC78, 0xF8020001, + 0xC78, 0xF7030001, + 0xC78, 0xF6040001, + 0xC78, 0xF5050001, + 0xC78, 0xF4060001, + 0xC78, 0xF3070001, + 0xC78, 0xF2080001, + 0xC78, 0xF1090001, + 0xC78, 0xF00A0001, + 0xC78, 0xEF0B0001, + 0xC78, 0xEE0C0001, + 0xC78, 0xED0D0001, + 0xC78, 0xEC0E0001, + 0xC78, 0xEB0F0001, + 0xC78, 0xEA100001, + 0xC78, 0xE9110001, + 0xC78, 0xE8120001, + 0xC78, 0xE7130001, + 0xC78, 0xE6140001, + 0xC78, 0xE5150001, + 0xC78, 0xE4160001, + 0xC78, 0xE3170001, + 0xC78, 0xE2180001, + 0xC78, 0xE1190001, + 0xC78, 0x8A1A0001, + 0xC78, 0x891B0001, + 0xC78, 0x881C0001, + 0xC78, 0x871D0001, + 0xC78, 0x861E0001, + 0xC78, 0x851F0001, + 0xC78, 0x84200001, + 0xC78, 0x83210001, + 0xC78, 0x82220001, + 0xC78, 0x6A230001, + 0xC78, 0x69240001, + 0xC78, 0x68250001, + 0xC78, 0x67260001, + 0xC78, 0x66270001, + 0xC78, 0x65280001, + 0xC78, 0x64290001, + 0xC78, 0x632A0001, + 0xC78, 0x622B0001, + 0xC78, 0x612C0001, + 0xC78, 0x602D0001, + 0xC78, 0x472E0001, + 0xC78, 0x462F0001, + 0xC78, 0x45300001, + 0xC78, 0x44310001, + 0xC78, 0x43320001, + 0xC78, 0x42330001, + 0xC78, 0x41340001, + 0xC78, 0x40350001, + 0xC78, 0x40360001, + 0xC78, 0x40370001, + 0xC78, 0x40380001, + 0xC78, 0x40390001, + 0xC78, 0x403A0001, + 0xC78, 0x403B0001, + 0xC78, 0x403C0001, + 0xC78, 0x403D0001, + 0xC78, 0x403E0001, + 0xC78, 0x403F0001, + 0xCDCDCDCD, 0xCDCD, + 0xC78, 0xFB000001, + 0xC78, 0xFB010001, + 0xC78, 0xFB020001, + 0xC78, 0xFB030001, + 0xC78, 0xFB040001, + 0xC78, 0xFB050001, + 0xC78, 0xFA060001, + 0xC78, 0xF9070001, + 0xC78, 0xF8080001, + 0xC78, 0xF7090001, + 0xC78, 0xF60A0001, + 0xC78, 0xF50B0001, + 0xC78, 0xF40C0001, + 0xC78, 0xF30D0001, + 0xC78, 0xF20E0001, + 0xC78, 0xF10F0001, + 0xC78, 0xF0100001, + 0xC78, 0xEF110001, + 0xC78, 0xEE120001, + 0xC78, 0xED130001, + 0xC78, 0xEC140001, + 0xC78, 0xEB150001, + 0xC78, 0xEA160001, + 0xC78, 0xE9170001, + 0xC78, 0xE8180001, + 0xC78, 0xE7190001, + 0xC78, 0xC81A0001, + 0xC78, 0xC71B0001, + 0xC78, 0xC61C0001, + 0xC78, 0x071D0001, + 0xC78, 0x061E0001, + 0xC78, 0x051F0001, + 0xC78, 0x04200001, + 0xC78, 0x03210001, + 0xC78, 0xAA220001, + 0xC78, 0xA9230001, + 0xC78, 0xA8240001, + 0xC78, 0xA7250001, + 0xC78, 0xA6260001, + 0xC78, 0x85270001, + 0xC78, 0x84280001, + 0xC78, 0x83290001, + 0xC78, 0x252A0001, + 0xC78, 0x242B0001, + 0xC78, 0x232C0001, + 0xC78, 0x222D0001, + 0xC78, 0x672E0001, + 0xC78, 0x662F0001, + 0xC78, 0x65300001, + 0xC78, 0x64310001, + 0xC78, 0x63320001, + 0xC78, 0x62330001, + 0xC78, 0x61340001, + 0xC78, 0x45350001, + 0xC78, 0x44360001, + 0xC78, 0x43370001, + 0xC78, 0x42380001, + 0xC78, 0x41390001, + 0xC78, 0x403A0001, + 0xC78, 0x403B0001, + 0xC78, 0x403C0001, + 0xC78, 0x403D0001, + 0xC78, 0x403E0001, + 0xC78, 0x403F0001, + 0xFF010718, 0xDEAD, + 0xFF010718, 0xABCD, + 0xC78, 0xFA400001, + 0xC78, 0xF9410001, + 0xC78, 0xF8420001, + 0xC78, 0xF7430001, + 0xC78, 0xF6440001, + 0xC78, 0xF5450001, + 0xC78, 0xF4460001, + 0xC78, 0xF3470001, + 0xC78, 0xF2480001, + 0xC78, 0xF1490001, + 0xC78, 0xF04A0001, + 0xC78, 0xEF4B0001, + 0xC78, 0xEE4C0001, + 0xC78, 0xED4D0001, + 0xC78, 0xEC4E0001, + 0xC78, 0xEB4F0001, + 0xC78, 0xEA500001, + 0xC78, 0xE9510001, + 0xC78, 0xE8520001, + 0xC78, 0xE7530001, + 0xC78, 0xE6540001, + 0xC78, 0xE5550001, + 0xC78, 0xE4560001, + 0xC78, 0xE3570001, + 0xC78, 0xE2580001, + 0xC78, 0xE1590001, + 0xC78, 0x8A5A0001, + 0xC78, 0x895B0001, + 0xC78, 0x885C0001, + 0xC78, 0x875D0001, + 0xC78, 0x865E0001, + 0xC78, 0x855F0001, + 0xC78, 0x84600001, + 0xC78, 0x83610001, + 0xC78, 0x82620001, + 0xC78, 0x6A630001, + 0xC78, 0x69640001, + 0xC78, 0x68650001, + 0xC78, 0x67660001, + 0xC78, 0x66670001, + 0xC78, 0x65680001, + 0xC78, 0x64690001, + 0xC78, 0x636A0001, + 0xC78, 0x626B0001, + 0xC78, 0x616C0001, + 0xC78, 0x606D0001, + 0xC78, 0x476E0001, + 0xC78, 0x466F0001, + 0xC78, 0x45700001, + 0xC78, 0x44710001, + 0xC78, 0x43720001, + 0xC78, 0x42730001, + 0xC78, 0x41740001, + 0xC78, 0x40750001, + 0xC78, 0x40760001, + 0xC78, 0x40770001, + 0xC78, 0x40780001, + 0xC78, 0x40790001, + 0xC78, 0x407A0001, + 0xC78, 0x407B0001, + 0xC78, 0x407C0001, + 0xC78, 0x407D0001, + 0xC78, 0x407E0001, + 0xC78, 0x407F0001, + 0xC50, 0x00040222, + 0xC50, 0x00040220, + 0xCDCDCDCD, 0xCDCD, + 0xC78, 0xFB400001, + 0xC78, 0xFB410001, + 0xC78, 0xFB420001, + 0xC78, 0xFB430001, + 0xC78, 0xFB440001, + 0xC78, 0xFB450001, + 0xC78, 0xFA460001, + 0xC78, 0xF9470001, + 0xC78, 0xF8480001, + 0xC78, 0xF7490001, + 0xC78, 0xF64A0001, + 0xC78, 0xF54B0001, + 0xC78, 0xF44C0001, + 0xC78, 0xF34D0001, + 0xC78, 0xF24E0001, + 0xC78, 0xF14F0001, + 0xC78, 0xF0500001, + 0xC78, 0xEF510001, + 0xC78, 0xEE520001, + 0xC78, 0xED530001, + 0xC78, 0xEC540001, + 0xC78, 0xEB550001, + 0xC78, 0xEA560001, + 0xC78, 0xE9570001, + 0xC78, 0xE8580001, + 0xC78, 0xE7590001, + 0xC78, 0xE65A0001, + 0xC78, 0xE55B0001, + 0xC78, 0xE45C0001, + 0xC78, 0xE35D0001, + 0xC78, 0xE25E0001, + 0xC78, 0xE15F0001, + 0xC78, 0x8A600001, + 0xC78, 0x89610001, + 0xC78, 0x88620001, + 0xC78, 0x87630001, + 0xC78, 0x86640001, + 0xC78, 0x85650001, + 0xC78, 0x84660001, + 0xC78, 0x83670001, + 0xC78, 0x82680001, + 0xC78, 0x6B690001, + 0xC78, 0x6A6A0001, + 0xC78, 0x696B0001, + 0xC78, 0x686C0001, + 0xC78, 0x676D0001, + 0xC78, 0x666E0001, + 0xC78, 0x656F0001, + 0xC78, 0x64700001, + 0xC78, 0x63710001, + 0xC78, 0x62720001, + 0xC78, 0x61730001, + 0xC78, 0x49740001, + 0xC78, 0x48750001, + 0xC78, 0x47760001, + 0xC78, 0x46770001, + 0xC78, 0x45780001, + 0xC78, 0x44790001, + 0xC78, 0x437A0001, + 0xC78, 0x427B0001, + 0xC78, 0x417C0001, + 0xC78, 0x407D0001, + 0xC78, 0x407E0001, + 0xC78, 0x407F0001, + 0xC50, 0x00040022, + 0xC50, 0x00040020, + 0xFF010718, 0xDEAD, +}; diff --git a/drivers/staging/rtl8192ee/rtl8192ee/table.h b/drivers/staging/rtl8192ee/rtl8192ee/table.h new file mode 100644 index 000000000000..e0f419823b36 --- /dev/null +++ b/drivers/staging/rtl8192ee/rtl8192ee/table.h @@ -0,0 +1,48 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Created on 2010/ 5/18, 1:41 + * + * Larry Finger + * + *****************************************************************************/ + +#ifndef __RTL92E_TABLE__H_ +#define __RTL92E_TABLE__H_ + +#include +#define RTL8192EE_PHY_REG_ARRAY_LEN 448 +extern u32 RTL8192EE_PHY_REG_ARRAY[]; +#define RTL8192EE_PHY_REG_ARRAY_PG_LEN 168 +extern u32 RTL8192EE_PHY_REG_ARRAY_PG[]; +#define RTL8192EE_RADIOA_ARRAY_LEN 238 +extern u32 RTL8192EE_RADIOA_ARRAY[]; +#define RTL8192EE_RADIOB_ARRAY_LEN 198 +extern u32 RTL8192EE_RADIOB_ARRAY[]; +#define RTL8192EE_MAC_ARRAY_LEN 202 +extern u32 RTL8192EE_MAC_ARRAY[]; +#define RTL8192EE_AGC_TAB_ARRAY_LEN 532 +extern u32 RTL8192EE_AGC_TAB_ARRAY[]; +#endif diff --git a/drivers/staging/rtl8192ee/rtl8192ee/trx.c b/drivers/staging/rtl8192ee/rtl8192ee/trx.c new file mode 100644 index 000000000000..c930f52ec8c8 --- /dev/null +++ b/drivers/staging/rtl8192ee/rtl8192ee/trx.c @@ -0,0 +1,1286 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * 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. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#include "../wifi.h" +#include "../pci.h" +#include "../base.h" +#include "../stats.h" +#include "reg.h" +#include "def.h" +#include "phy.h" +#include "trx.h" +#include "led.h" +#include "dm.h" +#include "fw.h" + +static u8 _rtl92ee_map_hwqueue_to_fwqueue(struct sk_buff *skb, u8 hw_queue) +{ + __le16 fc = rtl_get_fc(skb); + + if (unlikely(ieee80211_is_beacon(fc))) + return QSLT_BEACON; + if (ieee80211_is_mgmt(fc) || ieee80211_is_ctl(fc)) + return QSLT_MGNT; + + return skb->priority; +} + +/* mac80211's rate_idx is like this: + * + * 2.4G band:rx_status->band == IEEE80211_BAND_2GHZ + * + * B/G rate: + * (rx_status->flag & RX_FLAG_HT) = 0, + * DESC92C_RATE1M-->DESC92C_RATE54M ==> idx is 0-->11, + * + * N rate: + * (rx_status->flag & RX_FLAG_HT) = 1, + * DESC92C_RATEMCS0-->DESC92C_RATEMCS15 ==> idx is 0-->15 + * + * 5G band:rx_status->band == IEEE80211_BAND_5GHZ + * A rate: + * (rx_status->flag & RX_FLAG_HT) = 0, + * DESC92C_RATE6M-->DESC92C_RATE54M ==> idx is 0-->7, + * + * N rate: + * (rx_status->flag & RX_FLAG_HT) = 1, + * DESC92C_RATEMCS0-->DESC92C_RATEMCS15 ==> idx is 0-->15 + */ +static int _rtl92ee_rate_mapping(struct ieee80211_hw *hw, + bool isht, u8 desc_rate) +{ + int rate_idx; + + if (!false) { + if (IEEE80211_BAND_2GHZ == hw->conf.chandef.chan->band) { + switch (desc_rate) { + case DESC92C_RATE1M: + rate_idx = 0; + break; + case DESC92C_RATE2M: + rate_idx = 1; + break; + case DESC92C_RATE5_5M: + rate_idx = 2; + break; + case DESC92C_RATE11M: + rate_idx = 3; + break; + case DESC92C_RATE6M: + rate_idx = 4; + break; + case DESC92C_RATE9M: + rate_idx = 5; + break; + case DESC92C_RATE12M: + rate_idx = 6; + break; + case DESC92C_RATE18M: + rate_idx = 7; + break; + case DESC92C_RATE24M: + rate_idx = 8; + break; + case DESC92C_RATE36M: + rate_idx = 9; + break; + case DESC92C_RATE48M: + rate_idx = 10; + break; + case DESC92C_RATE54M: + rate_idx = 11; + break; + default: + rate_idx = 0; + break; + } + } else { + switch (desc_rate) { + case DESC92C_RATE6M: + rate_idx = 0; + break; + case DESC92C_RATE9M: + rate_idx = 1; + break; + case DESC92C_RATE12M: + rate_idx = 2; + break; + case DESC92C_RATE18M: + rate_idx = 3; + break; + case DESC92C_RATE24M: + rate_idx = 4; + break; + case DESC92C_RATE36M: + rate_idx = 5; + break; + case DESC92C_RATE48M: + rate_idx = 6; + break; + case DESC92C_RATE54M: + rate_idx = 7; + break; + default: + rate_idx = 0; + break; + } + } + } else { + switch (desc_rate) { + case DESC92C_RATEMCS0: + rate_idx = 0; + break; + case DESC92C_RATEMCS1: + rate_idx = 1; + break; + case DESC92C_RATEMCS2: + rate_idx = 2; + break; + case DESC92C_RATEMCS3: + rate_idx = 3; + break; + case DESC92C_RATEMCS4: + rate_idx = 4; + break; + case DESC92C_RATEMCS5: + rate_idx = 5; + break; + case DESC92C_RATEMCS6: + rate_idx = 6; + break; + case DESC92C_RATEMCS7: + rate_idx = 7; + break; + case DESC92C_RATEMCS8: + rate_idx = 8; + break; + case DESC92C_RATEMCS9: + rate_idx = 9; + break; + case DESC92C_RATEMCS10: + rate_idx = 10; + break; + case DESC92C_RATEMCS11: + rate_idx = 11; + break; + case DESC92C_RATEMCS12: + rate_idx = 12; + break; + case DESC92C_RATEMCS13: + rate_idx = 13; + break; + case DESC92C_RATEMCS14: + rate_idx = 14; + break; + case DESC92C_RATEMCS15: + rate_idx = 15; + break; + default: + rate_idx = 0; + break; + } + } + return rate_idx; +} + +static void _rtl92ee_query_rxphystatus(struct ieee80211_hw *hw, + struct rtl_stats *pstatus, u8 *pdesc, + struct rx_fwinfo *p_drvinfo, + bool bpacket_match_bssid, + bool bpacket_toself, + bool b_packet_beacon) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct phy_status_rpt *p_phystrpt = (struct phy_status_rpt *)p_drvinfo; + char rx_pwr_all = 0, rx_pwr[4]; + u8 rf_rx_num = 0, evm, pwdb_all; + u8 i, max_spatial_stream; + u32 rssi, total_rssi = 0; + bool b_is_cck = pstatus->b_is_cck; + u8 lan_idx , vga_idx; + + /* Record it for next packet processing */ + pstatus->b_packet_matchbssid = bpacket_match_bssid; + pstatus->b_packet_toself = bpacket_toself; + pstatus->b_packet_beacon = b_packet_beacon; + pstatus->rx_mimo_signalquality[0] = -1; + pstatus->rx_mimo_signalquality[1] = -1; + + if (b_is_cck) { + u8 cck_highpwr; + u8 cck_agc_rpt; + /* CCK Driver info Structure is not the same as OFDM packet. */ + cck_agc_rpt = p_phystrpt->cck_agc_rpt_ofdm_cfosho_a; + + /* (1)Hardware does not provide RSSI for CCK */ + /* (2)PWDB, Average PWDB cacluated by + * hardware (for rate adaptive) */ + cck_highpwr = (u8) rtl_get_bbreg(hw, RFPGA0_XA_HSSIPARAMETER2, + BIT(9)); + + lan_idx = ((cck_agc_rpt & 0xE0) >> 5); + vga_idx = (cck_agc_rpt & 0x1f); + switch (lan_idx) { + case 7: /*VGA_idx = 27~2*/ + if (vga_idx <= 27) + rx_pwr_all = -100 + 2 * (27 - vga_idx); + else + rx_pwr_all = -100; + break; + case 6: /*VGA_idx = 2~0*/ + rx_pwr_all = -48 + 2 * (2 - vga_idx); + break; + case 5: /*VGA_idx = 7~5*/ + rx_pwr_all = -42 + 2 * (7 - vga_idx); + break; + case 4: /*VGA_idx = 7~4*/ + rx_pwr_all = -36 + 2 * (7 - vga_idx); + break; + case 3: /*VGA_idx = 7~0*/ + rx_pwr_all = -24 + 2 * (7 - vga_idx); + break; + case 2: /*VGA_idx = 5~0*/ + if (cck_highpwr) + rx_pwr_all = -12 + 2 * (5 - vga_idx); + else + rx_pwr_all = -6 + 2 * (5 - vga_idx); + break; + case 1: + rx_pwr_all = 8 - 2 * vga_idx; + break; + case 0: + rx_pwr_all = 14 - 2 * vga_idx; + break; + default: + break; + } + rx_pwr_all += 16; + pwdb_all = stg_rtl_query_rxpwrpercentage(rx_pwr_all); + + if (!cck_highpwr) { + if (pwdb_all >= 80) + pwdb_all = ((pwdb_all - 80) << 1) + + ((pwdb_all - 80) >> 1) + 80; + else if ((pwdb_all <= 78) && (pwdb_all >= 20)) + pwdb_all += 3; + if (pwdb_all > 100) + pwdb_all = 100; + } + + pstatus->rx_pwdb_all = pwdb_all; + pstatus->bt_rx_rssi_percentage = pwdb_all; + pstatus->recvsignalpower = rx_pwr_all; + + /* (3) Get Signal Quality (EVM) */ + if (bpacket_match_bssid) { + u8 sq, sq_rpt; + + if (pstatus->rx_pwdb_all > 40) { + sq = 100; + } else { + sq_rpt = p_phystrpt->cck_sig_qual_ofdm_pwdb_all; + if (sq_rpt > 64) + sq = 0; + else if (sq_rpt < 20) + sq = 100; + else + sq = ((64 - sq_rpt) * 100) / 44; + } + + pstatus->signalquality = sq; + pstatus->rx_mimo_signalquality[0] = sq; + pstatus->rx_mimo_signalquality[1] = -1; + } + } else { + /* (1)Get RSSI for HT rate */ + for (i = RF90_PATH_A; i < RF6052_MAX_PATH; i++) { + /* we will judge RF RX path now. */ + if (rtlpriv->dm.brfpath_rxenable[i]) + rf_rx_num++; + + rx_pwr[i] = ((p_phystrpt->path_agc[i].gain & 0x3f) * 2) + - 110; + + pstatus->rx_pwr[i] = rx_pwr[i]; + /* Translate DBM to percentage. */ + rssi = stg_rtl_query_rxpwrpercentage(rx_pwr[i]); + total_rssi += rssi; + + pstatus->rx_mimo_signalstrength[i] = (u8)rssi; + } + + /* (2)PWDB, Average PWDB cacluated by + * hardware (for rate adaptive) */ + rx_pwr_all = ((p_phystrpt->cck_sig_qual_ofdm_pwdb_all >> 1) + & 0x7f) - 110; + + pwdb_all = stg_rtl_query_rxpwrpercentage(rx_pwr_all); + pstatus->rx_pwdb_all = pwdb_all; + pstatus->bt_rx_rssi_percentage = pwdb_all; + pstatus->rxpower = rx_pwr_all; + pstatus->recvsignalpower = rx_pwr_all; + + /* (3)EVM of HT rate */ + if (pstatus->rate >= DESC92C_RATEMCS8 && + pstatus->rate <= DESC92C_RATEMCS15) + max_spatial_stream = 2; + else + max_spatial_stream = 1; + + for (i = 0; i < max_spatial_stream; i++) { + evm = stg_rtl_evm_db_to_percentage( + p_phystrpt->stream_rxevm[i]); + + if (bpacket_match_bssid) { + /* Fill value in RFD, Get the first + * spatial stream only */ + if (i == 0) + pstatus->signalquality = (u8)(evm & + 0xff); + pstatus->rx_mimo_signalquality[i] = (u8)(evm & + 0xff); + } + } + + if (bpacket_match_bssid) { + for (i = RF90_PATH_A; i <= RF90_PATH_B; i++) + rtl_priv(hw)->dm.cfo_tail[i] = + (int)p_phystrpt->path_cfotail[i]; + + if (rtl_priv(hw)->dm.packet_count == 0xffffffff) + rtl_priv(hw)->dm.packet_count = 0; + else + rtl_priv(hw)->dm.packet_count++; + } + } + + /* UI BSS List signal strength(in percentage), + * make it good looking, from 0~100. */ + if (b_is_cck) + pstatus->signalstrength = (u8)(stg_rtl_signal_scale_mapping(hw, + pwdb_all)); + else if (rf_rx_num != 0) + pstatus->signalstrength = (u8)(stg_rtl_signal_scale_mapping(hw, + total_rssi /= rf_rx_num)); +} + +static void _rtl92ee_translate_rx_signal_stuff(struct ieee80211_hw *hw, + struct sk_buff *skb, + struct rtl_stats *pstatus, + u8 *pdesc, + struct rx_fwinfo *p_drvinfo) +{ + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); + struct ieee80211_hdr *hdr; + u8 *tmp_buf; + u8 *praddr; + u8 *psaddr; + __le16 fc; + u16 cpu_fc, type; + bool b_packet_matchbssid, b_packet_toself, b_packet_beacon; + + tmp_buf = skb->data + pstatus->rx_drvinfo_size + + pstatus->rx_bufshift + 24; + + hdr = (struct ieee80211_hdr *)tmp_buf; + fc = hdr->frame_control; + cpu_fc = le16_to_cpu(fc); + type = WLAN_FC_GET_TYPE(fc); + praddr = hdr->addr1; + psaddr = ieee80211_get_SA(hdr); + ether_addr_copy(pstatus->psaddr, psaddr); + + b_packet_matchbssid = ((IEEE80211_FTYPE_CTL != type) && + (ether_addr_equal(mac->bssid, + (cpu_fc & IEEE80211_FCTL_TODS) ? + hdr->addr1 : + (cpu_fc & IEEE80211_FCTL_FROMDS) ? + hdr->addr2 : hdr->addr3)) && + (!pstatus->b_hwerror) && (!pstatus->b_crc) && + (!pstatus->b_icv)); + + b_packet_toself = b_packet_matchbssid && + (ether_addr_equal(praddr, rtlefuse->dev_addr)); + + if (ieee80211_is_beacon(fc)) + b_packet_beacon = true; + else + b_packet_beacon = false; + + if (b_packet_beacon && b_packet_matchbssid) + rtl_priv(hw)->dm.dbginfo.num_qry_beacon_pkt++; + + if (b_packet_matchbssid && ieee80211_is_data_qos(fc) && + !is_multicast_ether_addr(ieee80211_get_DA(hdr))) { + struct ieee80211_qos_hdr *hdr_qos = + (struct ieee80211_qos_hdr *)tmp_buf; + u16 tid = le16_to_cpu(hdr_qos->qos_ctrl) & 0xf; + if (tid != 0 && tid != 3) + rtl_priv(hw)->dm.dbginfo.num_non_be_pkt++; + } + _rtl92ee_query_rxphystatus(hw, pstatus, pdesc, p_drvinfo, + b_packet_matchbssid, b_packet_toself, + b_packet_beacon); + stg_rtl_process_phyinfo(hw, tmp_buf, pstatus); +} + +static void _rtl92ee_insert_emcontent(struct rtl_tcb_desc *ptcb_desc, + u8 *virtualaddress) +{ + u32 dwtmp = 0; + memset(virtualaddress, 0, 8); + + SET_EARLYMODE_PKTNUM(virtualaddress, ptcb_desc->empkt_num); + if (ptcb_desc->empkt_num == 1) { + dwtmp = ptcb_desc->empkt_len[0]; + } else { + dwtmp = ptcb_desc->empkt_len[0]; + dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0) + 4; + dwtmp += ptcb_desc->empkt_len[1]; + } + SET_EARLYMODE_LEN0(virtualaddress, dwtmp); + + if (ptcb_desc->empkt_num <= 3) { + dwtmp = ptcb_desc->empkt_len[2]; + } else { + dwtmp = ptcb_desc->empkt_len[2]; + dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0) + 4; + dwtmp += ptcb_desc->empkt_len[3]; + } + SET_EARLYMODE_LEN1(virtualaddress, dwtmp); + if (ptcb_desc->empkt_num <= 5) { + dwtmp = ptcb_desc->empkt_len[4]; + } else { + dwtmp = ptcb_desc->empkt_len[4]; + dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0) + 4; + dwtmp += ptcb_desc->empkt_len[5]; + } + SET_EARLYMODE_LEN2_1(virtualaddress, dwtmp & 0xF); + SET_EARLYMODE_LEN2_2(virtualaddress, dwtmp >> 4); + if (ptcb_desc->empkt_num <= 7) { + dwtmp = ptcb_desc->empkt_len[6]; + } else { + dwtmp = ptcb_desc->empkt_len[6]; + dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0) + 4; + dwtmp += ptcb_desc->empkt_len[7]; + } + SET_EARLYMODE_LEN3(virtualaddress, dwtmp); + if (ptcb_desc->empkt_num <= 9) { + dwtmp = ptcb_desc->empkt_len[8]; + } else { + dwtmp = ptcb_desc->empkt_len[8]; + dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0) + 4; + dwtmp += ptcb_desc->empkt_len[9]; + } + SET_EARLYMODE_LEN4(virtualaddress, dwtmp); +} + +bool rtl92ee_rx_query_desc(struct ieee80211_hw *hw, + struct rtl_stats *status, + struct ieee80211_rx_status *rx_status, + u8 *pdesc, struct sk_buff *skb) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rx_fwinfo *p_drvinfo; + struct ieee80211_hdr *hdr; + + u32 phystatus = GET_RX_DESC_PHYST(pdesc); + status->length = (u16) GET_RX_DESC_PKT_LEN(pdesc); + status->rx_drvinfo_size = (u8) GET_RX_DESC_DRV_INFO_SIZE(pdesc) * + RX_DRV_INFO_SIZE_UNIT; + status->rx_bufshift = (u8)(GET_RX_DESC_SHIFT(pdesc) & 0x03); + status->b_icv = (u16) GET_RX_DESC_ICV(pdesc); + status->b_crc = (u16) GET_RX_DESC_CRC32(pdesc); + status->b_hwerror = (status->b_crc | status->b_icv); + status->decrypted = !GET_RX_DESC_SWDEC(pdesc); + status->rate = (u8) GET_RX_DESC_RXMCS(pdesc); + status->b_isampdu = (bool)(GET_RX_DESC_PAGGR(pdesc) == 1); + status->timestamp_low = GET_RX_DESC_TSFL(pdesc); + status->b_is_cck = RX_HAL_IS_CCK_RATE(status->rate); + + status->macid = GET_RX_DESC_MACID(pdesc); + if (GET_RX_STATUS_DESC_MAGIC_MATCH(pdesc)) + status->wake_match = BIT(2); + else if (GET_RX_STATUS_DESC_MAGIC_MATCH(pdesc)) + status->wake_match = BIT(1); + else if (GET_RX_STATUS_DESC_UNICAST_MATCH(pdesc)) + status->wake_match = BIT(0); + else + status->wake_match = 0; + if (status->wake_match) + RT_TRACE(COMP_RXDESC , DBG_LOUD, + ("GGGGGGGGGGGGGet Wakeup Packet!! WakeMatch =%d\n", + status->wake_match)); + rx_status->freq = hw->conf.chandef.chan->center_freq; + rx_status->band = hw->conf.chandef.chan->band; + + hdr = (struct ieee80211_hdr *)(skb->data + status->rx_drvinfo_size + + status->rx_bufshift + 24); + + if (status->b_crc) + rx_status->flag |= RX_FLAG_FAILED_FCS_CRC; + + if (status->rx_is40Mhzpacket) + rx_status->flag |= RX_FLAG_40MHZ; + + if (status->b_is_ht) + rx_status->flag |= RX_FLAG_HT; + + rx_status->flag |= RX_FLAG_MACTIME_MPDU; + + /* hw will set status->decrypted true, if it finds the + * frame is open data frame or mgmt frame. */ + /* So hw will not decryption robust managment frame + * for IEEE80211w but still set status->decrypted + * true, so here we should set it back to undecrypted + * for IEEE80211w frame, and mac80211 sw will help + * to decrypt it */ + if (status->decrypted) { + if (!hdr) { + WARN_ON_ONCE(true); + pr_err("decrypted is true but hdr NULL, from skb %p\n", + rtl_get_hdr(skb)); + return false; + } + + if ((!_ieee80211_is_robust_mgmt_frame(hdr)) && + (ieee80211_has_protected(hdr->frame_control))) + rx_status->flag |= RX_FLAG_DECRYPTED; + else + rx_status->flag &= ~RX_FLAG_DECRYPTED; + } + + /* rate_idx: index of data rate into band's + * supported rates or MCS index if HT rates + * are use (RX_FLAG_HT)*/ + /* Notice: this is diff with windows define */ + rx_status->rate_idx = _rtl92ee_rate_mapping(hw, + status->b_is_ht, + status->rate); + + rx_status->mactime = status->timestamp_low; + if (phystatus) { + p_drvinfo = (struct rx_fwinfo *)(skb->data + + status->rx_bufshift + 24); + + _rtl92ee_translate_rx_signal_stuff(hw, skb, status, pdesc, + p_drvinfo); + } + + /*rx_status->qual = status->signal; */ + rx_status->signal = status->recvsignalpower + 10; + /*rx_status->noise = -status->noise; */ + if (status->packet_report_type == TX_REPORT2) { + status->macid_valid_entry[0] = + GET_RX_RPT2_DESC_MACID_VALID_1(pdesc); + status->macid_valid_entry[1] = + GET_RX_RPT2_DESC_MACID_VALID_2(pdesc); + } + return true; +} + +/*in Windows, this == Rx_92EE_Interrupt*/ +void rtl92ee_rx_check_dma_ok(struct ieee80211_hw *hw, u8 *header_desc, + u8 queue_index) +{ + u8 first_seg; + u8 last_seg; + u16 total_len; + u16 read_cnt = 0; + if (header_desc == NULL) + return; + + total_len = (u16)GET_RX_BUFFER_DESC_TOTAL_LENGTH(header_desc); + + first_seg = (u8)GET_RX_BUFFER_DESC_FS(header_desc); + + last_seg = (u8)GET_RX_BUFFER_DESC_LS(header_desc); + + while (total_len == 0 && first_seg == 0 && last_seg == 0) { + read_cnt++; + total_len = (u16)GET_RX_BUFFER_DESC_TOTAL_LENGTH(header_desc); + first_seg = (u8)GET_RX_BUFFER_DESC_FS(header_desc); + last_seg = (u8)GET_RX_BUFFER_DESC_LS(header_desc); + + if (read_cnt > 20) + break; + } +} + +u16 rtl92ee_rx_desc_buff_remained_cnt(struct ieee80211_hw *hw , u8 queue_index) +{ + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + struct rtl_priv *rtlpriv = rtl_priv(hw); + u16 read_point = 0 , write_point = 0 , remind_cnt = 0; + u32 tmp_4byte = 0; + static u16 last_read_point; + static bool start_rx; + + tmp_4byte = rtl_read_dword(rtlpriv, REG_RXQ_TXBD_IDX); + read_point = (u16)((tmp_4byte>>16) & 0x7ff); + write_point = (u16)(tmp_4byte & 0x7ff); + + if (write_point != rtlpci->rx_ring[queue_index].next_rx_rp) { + RT_TRACE(COMP_RXDESC, DBG_DMESG, + ("!!!write point is 0x%x, reg 0x3B4 value is 0x%x\n", + write_point, tmp_4byte)); + tmp_4byte = rtl_read_dword(rtlpriv, REG_RXQ_TXBD_IDX); + read_point = (u16)((tmp_4byte>>16) & 0x7ff); + write_point = (u16)(tmp_4byte & 0x7ff); + } + + if (read_point > 0) + start_rx = true; + if (!start_rx) + return 0; + + if ((last_read_point > (RX_DESC_NUM_92E / 2)) && + (read_point <= (RX_DESC_NUM_92E / 2))) { + remind_cnt = RX_DESC_NUM_92E - write_point; + } else { + remind_cnt = (read_point >= write_point) ? + (read_point - write_point) : + (RX_DESC_NUM_92E - write_point + read_point); + } + + if (remind_cnt == 0) + return 0; + + rtlpci->rx_ring[queue_index].next_rx_rp = write_point; + + last_read_point = read_point; + return remind_cnt; +} + +static u16 get_desc_addr_fr_q(u16 queue_index) +{ + u16 desc_address = REG_BEQ_TXBD_IDX; + + switch (queue_index) { + case BK_QUEUE: + desc_address = REG_BKQ_TXBD_IDX; + break; + case BE_QUEUE: + desc_address = REG_BEQ_TXBD_IDX; + break; + case VI_QUEUE: + desc_address = REG_VIQ_TXBD_IDX; + break; + case VO_QUEUE: + desc_address = REG_VOQ_TXBD_IDX; + break; + case BEACON_QUEUE: + desc_address = REG_BEQ_TXBD_IDX; + break; + case TXCMD_QUEUE: + desc_address = REG_BEQ_TXBD_IDX; + break; + case MGNT_QUEUE: + desc_address = REG_MGQ_TXBD_IDX; + break; + case HIGH_QUEUE: + desc_address = REG_HI0Q_TXBD_IDX; + break; + case HCCA_QUEUE: + desc_address = REG_BEQ_TXBD_IDX; + break; + default: + break; + } + return desc_address; +} + +void rtl92ee_get_available_desc(struct ieee80211_hw *hw , u8 q_idx) +{ + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + struct rtl_priv *rtlpriv = rtl_priv(hw); + u16 point_diff = 0; + u16 current_tx_read_point = 0, current_tx_write_point = 0; + u32 tmp_4byte; + tmp_4byte = rtl_read_dword(rtlpriv, + get_desc_addr_fr_q(q_idx)); + current_tx_read_point = (u16)((tmp_4byte >> 16) & 0x0fff); + current_tx_write_point = (u16)((tmp_4byte) & 0x0fff); + + point_diff = ((current_tx_read_point > current_tx_write_point) ? + (current_tx_read_point - current_tx_write_point) : + (TX_DESC_NUM_92E - current_tx_write_point + + current_tx_read_point)); + + rtlpci->tx_ring[q_idx].avl_desc = point_diff; +} + +void rtl92ee_pre_fill_tx_bd_desc(struct ieee80211_hw *hw, + u8 *tx_bd_desc, u8 *desc, u8 queue_index, + struct sk_buff *skb, dma_addr_t addr) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + u32 pkt_len = skb->len; + u16 desc_size = 40; /*tx desc size*/ + u32 psblen = 0; + u16 tx_page_size = 0; + u32 total_packet_size = 0; + u16 current_bd_desc; + u8 i = 0; + u16 real_desc_size = 0x28; + u16 append_early_mode_size = 0; +#if (RTL8192EE_SEG_NUM == 0) + u8 segmentnum = 2; +#elif (RTL8192EE_SEG_NUM == 1) + u8 segmentnum = 4; +#elif (RTL8192EE_SEG_NUM == 2) + u8 segmentnum = 8; +#endif + + tx_page_size = 2; + current_bd_desc = rtlpci->tx_ring[queue_index].cur_tx_wp; + + + total_packet_size = desc_size+pkt_len; + + if (rtlpriv->rtlhal.b_earlymode_enable) { + if (queue_index < BEACON_QUEUE) { + append_early_mode_size = 8; + total_packet_size += append_early_mode_size; + } + } + + if (tx_page_size > 0) { + psblen = (pkt_len + real_desc_size + append_early_mode_size) / + (tx_page_size * 128); + + if (psblen * (tx_page_size * 128) < total_packet_size) + psblen += 1; + } + + /* Reset */ + SET_TX_BUFF_DESC_LEN_0(tx_bd_desc , 0); + SET_TX_BUFF_DESC_PSB(tx_bd_desc , 0); + SET_TX_BUFF_DESC_OWN(tx_bd_desc , 0); + + for (i = 1; i < segmentnum; i++) { + SET_TXBUFFER_DESC_LEN_WITH_OFFSET(tx_bd_desc, i, 0); + SET_TXBUFFER_DESC_AMSDU_WITH_OFFSET(tx_bd_desc, i, 0); + SET_TXBUFFER_DESC_ADD_LOW_WITH_OFFSET(tx_bd_desc, i, 0); +#if (DMA_IS_64BIT == 1) + SET_TXBUFFER_DESC_ADD_HIGT_WITH_OFFSET(tx_bd_desc, i, 0); +#endif + } + SET_TX_BUFF_DESC_LEN_1(tx_bd_desc, 0); + SET_TX_BUFF_DESC_AMSDU_1(tx_bd_desc, 0); + + SET_TX_BUFF_DESC_LEN_2(tx_bd_desc, 0); + SET_TX_BUFF_DESC_AMSDU_2(tx_bd_desc, 0); + SET_TX_BUFF_DESC_LEN_3(tx_bd_desc, 0); + SET_TX_BUFF_DESC_AMSDU_3(tx_bd_desc, 0); + /* Clear all status */ + CLEAR_PCI_TX_DESC_CONTENT(desc, TX_DESC_SIZE); + + if (rtlpriv->rtlhal.b_earlymode_enable) { + if (queue_index < BEACON_QUEUE) { + /* These macros need braces */ + SET_TX_BUFF_DESC_LEN_0(tx_bd_desc , desc_size + 8); + } else { + SET_TX_BUFF_DESC_LEN_0(tx_bd_desc , desc_size); + } + } else { + SET_TX_BUFF_DESC_LEN_0(tx_bd_desc , desc_size); + } + SET_TX_BUFF_DESC_PSB(tx_bd_desc , psblen); + SET_TX_BUFF_DESC_ADDR_LOW_0(tx_bd_desc, + rtlpci->tx_ring[queue_index].dma + + (current_bd_desc * TX_DESC_SIZE)); + + SET_TXBUFFER_DESC_LEN_WITH_OFFSET(tx_bd_desc, 1, pkt_len); + /* don't using extendsion mode. */ + SET_TXBUFFER_DESC_AMSDU_WITH_OFFSET(tx_bd_desc, 1, 0); + SET_TXBUFFER_DESC_ADD_LOW_WITH_OFFSET(tx_bd_desc, 1, addr); + + SET_TX_DESC_PKT_SIZE(desc, (u16)(pkt_len)); + SET_TX_DESC_TX_BUFFER_SIZE(desc, (u16)(pkt_len)); +} + +void rtl92ee_tx_fill_desc(struct ieee80211_hw *hw, + struct ieee80211_hdr *hdr, u8 *pdesc_tx, + u8 *pbd_desc_tx, + struct ieee80211_tx_info *info, + struct ieee80211_sta *sta, + struct sk_buff *skb, + u8 hw_queue, struct rtl_tcb_desc *ptcb_desc) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + struct rtl_hal *rtlhal = rtl_hal(rtlpriv); + u8 *pdesc = (u8 *)pdesc_tx; + u16 seq_number; + __le16 fc = hdr->frame_control; + unsigned int buf_len = 0; + u8 fw_qsel = _rtl92ee_map_hwqueue_to_fwqueue(skb, hw_queue); + bool b_firstseg = ((hdr->seq_ctrl & + cpu_to_le16(IEEE80211_SCTL_FRAG)) == 0); + bool b_lastseg = ((hdr->frame_control & + cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) == 0); + dma_addr_t mapping; + u8 bw_40 = 0; + u8 short_gi = 0; + + if (mac->opmode == NL80211_IFTYPE_STATION) { + bw_40 = mac->bw_40; + } else if (mac->opmode == NL80211_IFTYPE_AP || + mac->opmode == NL80211_IFTYPE_ADHOC) { + if (sta) + bw_40 = sta->ht_cap.cap & + IEEE80211_HT_CAP_SUP_WIDTH_20_40; + } + seq_number = (le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_SEQ) >> 4; + stg_rtl_get_tcb_desc(hw, info, sta, skb, ptcb_desc); + /* reserve 8 byte for AMPDU early mode */ + if (rtlhal->b_earlymode_enable) { + skb_push(skb, EM_HDR_LEN); + memset(skb->data, 0, EM_HDR_LEN); + } + buf_len = skb->len; + mapping = pci_map_single(rtlpci->pdev, skb->data, skb->len, + PCI_DMA_TODEVICE); + if (pci_dma_mapping_error(rtlpci->pdev, mapping)) { + RT_TRACE(COMP_SEND, DBG_TRACE, + ("DMA mapping error")); + return; + } + if (pbd_desc_tx != NULL) + rtl92ee_pre_fill_tx_bd_desc(hw, pbd_desc_tx, pdesc, hw_queue, + skb, mapping); + + if (ieee80211_is_nullfunc(fc) || ieee80211_is_ctl(fc)) { + b_firstseg = true; + b_lastseg = true; + } + if (b_firstseg) { + if (rtlhal->b_earlymode_enable) { + SET_TX_DESC_PKT_OFFSET(pdesc, 1); + SET_TX_DESC_OFFSET(pdesc, + USB_HWDESC_HEADER_LEN + EM_HDR_LEN); + if (ptcb_desc->empkt_num) { + RT_TRACE(COMP_SEND, DBG_TRACE, + ("Insert 8 byte.pTcb->EMPktNum:%d\n", + ptcb_desc->empkt_num)); + _rtl92ee_insert_emcontent(ptcb_desc, + (u8 *)(skb->data)); + } + } else { + SET_TX_DESC_OFFSET(pdesc, USB_HWDESC_HEADER_LEN); + } + + SET_TX_DESC_TX_RATE(pdesc, ptcb_desc->hw_rate); + + if (ieee80211_is_mgmt(fc)) { + ptcb_desc->use_driver_rate = true; + } else { + if (rtlpriv->ra.is_special_data) { + ptcb_desc->use_driver_rate = true; + SET_TX_DESC_TX_RATE(pdesc, DESC92C_RATE11M); + } else { + ptcb_desc->use_driver_rate = false; + } + } + + if (ptcb_desc->hw_rate > DESC92C_RATEMCS0) + short_gi = (ptcb_desc->use_shortgi) ? 1 : 0; + else + short_gi = (ptcb_desc->use_shortpreamble) ? 1 : 0; + + if (info->flags & IEEE80211_TX_CTL_AMPDU) { + SET_TX_DESC_AGG_ENABLE(pdesc, 1); + SET_TX_DESC_MAX_AGG_NUM(pdesc, 0x14); + } + SET_TX_DESC_SEQ(pdesc, seq_number); + SET_TX_DESC_RTS_ENABLE(pdesc, + ((ptcb_desc->b_rts_enable && + !ptcb_desc->b_cts_enable) ? 1 : 0)); + SET_TX_DESC_HW_RTS_ENABLE(pdesc , 0); + SET_TX_DESC_CTS2SELF(pdesc, + ((ptcb_desc->b_cts_enable) ? 1 : 0)); + + SET_TX_DESC_RTS_RATE(pdesc, ptcb_desc->rts_rate); + SET_TX_DESC_RTS_SC(pdesc, ptcb_desc->rts_sc); + SET_TX_DESC_RTS_SHORT(pdesc, + ((ptcb_desc->rts_rate <= DESC92C_RATE54M) ? + (ptcb_desc->b_rts_use_shortpreamble ? 1 : 0) : + (ptcb_desc->b_rts_use_shortgi ? 1 : 0))); + + if (ptcb_desc->btx_enable_sw_calc_duration) + SET_TX_DESC_NAV_USE_HDR(pdesc, 1); + + if (bw_40) { + if (ptcb_desc->packet_bw == HT_CHANNEL_WIDTH_20_40) { + SET_TX_DESC_DATA_BW(pdesc, 1); + SET_TX_DESC_TX_SUB_CARRIER(pdesc, 3); + } else { + SET_TX_DESC_DATA_BW(pdesc, 0); + SET_TX_DESC_TX_SUB_CARRIER(pdesc, + mac->cur_40_prime_sc); + } + } else { + SET_TX_DESC_DATA_BW(pdesc, 0); + SET_TX_DESC_TX_SUB_CARRIER(pdesc, 0); + } + + SET_TX_DESC_LINIP(pdesc, 0); + if (sta) { + u8 ampdu_density = sta->ht_cap.ampdu_density; + SET_TX_DESC_AMPDU_DENSITY(pdesc, ampdu_density); + } + if (info->control.hw_key) { + struct ieee80211_key_conf *key = info->control.hw_key; + switch (key->cipher) { + case WLAN_CIPHER_SUITE_WEP40: + case WLAN_CIPHER_SUITE_WEP104: + case WLAN_CIPHER_SUITE_TKIP: + SET_TX_DESC_SEC_TYPE(pdesc, 0x1); + break; + case WLAN_CIPHER_SUITE_CCMP: + SET_TX_DESC_SEC_TYPE(pdesc, 0x3); + break; + default: + SET_TX_DESC_SEC_TYPE(pdesc, 0x0); + break; + } + } + + SET_TX_DESC_QUEUE_SEL(pdesc, fw_qsel); + SET_TX_DESC_DATA_RATE_FB_LIMIT(pdesc, 0x1F); + SET_TX_DESC_RTS_RATE_FB_LIMIT(pdesc, 0xF); + SET_TX_DESC_DISABLE_FB(pdesc, + ptcb_desc->disable_ratefallback ? 1 : 0); + SET_TX_DESC_USE_RATE(pdesc, ptcb_desc->use_driver_rate ? 1 : 0); + + /*SET_TX_DESC_PWR_STATUS(pdesc, pwr_status);*/ + /* Set TxRate and RTSRate in TxDesc */ + /* This prevent Tx initial rate of new-coming packets */ + /* from being overwritten by retried packet rate.*/ + if (!ptcb_desc->use_driver_rate) { + /*SET_TX_DESC_RTS_RATE(pdesc, 0x08); */ + /* SET_TX_DESC_TX_RATE(pdesc, 0x0b); */ + } + if (ieee80211_is_data_qos(fc)) { + if (mac->rdg_en) { + RT_TRACE(COMP_SEND, DBG_TRACE, + ("Enable RDG function.\n")); + SET_TX_DESC_RDG_ENABLE(pdesc, 1); + SET_TX_DESC_HTC(pdesc, 1); + } + } + } + + SET_TX_DESC_FIRST_SEG(pdesc, (b_firstseg ? 1 : 0)); + SET_TX_DESC_LAST_SEG(pdesc, (b_lastseg ? 1 : 0)); + SET_TX_DESC_TX_BUFFER_ADDRESS(pdesc, mapping); + if (rtlpriv->dm.b_useramask) { + SET_TX_DESC_RATE_ID(pdesc, ptcb_desc->ratr_index); + SET_TX_DESC_MACID(pdesc, ptcb_desc->mac_id); + } else { + SET_TX_DESC_RATE_ID(pdesc, 0xC + ptcb_desc->ratr_index); + SET_TX_DESC_MACID(pdesc, ptcb_desc->ratr_index); + } + + SET_TX_DESC_MORE_FRAG(pdesc, (b_lastseg ? 0 : 1)); + if (is_multicast_ether_addr(ieee80211_get_DA(hdr)) || + is_broadcast_ether_addr(ieee80211_get_DA(hdr))) { + SET_TX_DESC_BMC(pdesc, 1); + } + RT_TRACE(COMP_SEND, DBG_TRACE, ("\n")); +} + +void rtl92ee_tx_fill_cmddesc(struct ieee80211_hw *hw, + u8 *pdesc, bool b_firstseg, + bool b_lastseg, struct sk_buff *skb) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + u8 fw_queue = QSLT_BEACON; + + dma_addr_t mapping = pci_map_single(rtlpci->pdev, + skb->data, skb->len, + PCI_DMA_TODEVICE); + + + u8 txdesc_len = 40; + + if (pci_dma_mapping_error(rtlpci->pdev, mapping)) { + RT_TRACE(COMP_SEND, DBG_TRACE, + ("DMA mapping error")); + return; + } + CLEAR_PCI_TX_DESC_CONTENT(pdesc, txdesc_len); + + if (b_firstseg) + SET_TX_DESC_OFFSET(pdesc, txdesc_len); + + SET_TX_DESC_TX_RATE(pdesc, DESC92C_RATE1M); + + SET_TX_DESC_SEQ(pdesc, 0); + + SET_TX_DESC_LINIP(pdesc, 0); + + SET_TX_DESC_QUEUE_SEL(pdesc, fw_queue); + + SET_TX_DESC_FIRST_SEG(pdesc, 1); + SET_TX_DESC_LAST_SEG(pdesc, 1); + + SET_TX_DESC_TX_BUFFER_SIZE(pdesc, (u16)(skb->len)); + + SET_TX_DESC_TX_BUFFER_ADDRESS(pdesc, mapping); + + SET_TX_DESC_RATE_ID(pdesc, 7); + SET_TX_DESC_MACID(pdesc, 0); + + SET_TX_DESC_OWN(pdesc, 1); + + SET_TX_DESC_PKT_SIZE((u8 *)pdesc, (u16)(skb->len)); + + SET_TX_DESC_FIRST_SEG(pdesc, 1); + SET_TX_DESC_LAST_SEG(pdesc, 1); + + SET_TX_DESC_OFFSET(pdesc, 40); + + SET_TX_DESC_USE_RATE(pdesc, 1); + + RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD, + "H2C Tx Cmd Content\n", pdesc, txdesc_len); +} + + +void rtl92ee_set_desc(struct ieee80211_hw *hw, u8 *pdesc, bool istx, + u8 desc_name, u8 *val) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u16 cur_tx_rp = 0; + u16 cur_tx_wp = 0; + static u16 last_txw_point; + static bool over_run; + u32 tmp = 0; + u8 q_idx = *val; + + if (istx) { + switch (desc_name) { + case HW_DESC_TX_NEXTDESC_ADDR: + SET_TX_DESC_NEXT_DESC_ADDRESS(pdesc, *(u32 *)val); + break; + case HW_DESC_OWN:{ + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[q_idx]; + u16 max_tx_desc = ring->entries; + if (q_idx == BEACON_QUEUE) { + ring->cur_tx_wp = 0; + ring->cur_tx_rp = 0; + SET_TX_BUFF_DESC_OWN(pdesc, 1); + return; + } + ring->cur_tx_wp = ((ring->cur_tx_wp + 1) % max_tx_desc); + + if (over_run) { + ring->cur_tx_wp = 0; + over_run = false; + } + if (ring->avl_desc > 1) { + ring->avl_desc--; + + rtl_write_word(rtlpriv, + get_desc_addr_fr_q(q_idx), + ring->cur_tx_wp); + + if (q_idx == 1) + last_txw_point = cur_tx_wp; + } + + if (ring->avl_desc < (max_tx_desc - 15)) { + u16 point_diff = 0; + tmp = rtl_read_dword(rtlpriv, + get_desc_addr_fr_q(q_idx)); + cur_tx_rp = (u16)((tmp >> 16) & 0x0fff); + cur_tx_wp = (u16)(tmp & 0x0fff); + + ring->cur_tx_wp = cur_tx_wp; + ring->cur_tx_rp = cur_tx_rp; + point_diff = ((cur_tx_rp > cur_tx_wp) ? + (cur_tx_rp - cur_tx_wp) : + (TX_DESC_NUM_92E - 1 - + cur_tx_wp + cur_tx_rp)); + + ring->avl_desc = point_diff; + } + } + break; + } + } else { + switch (desc_name) { + case HW_DESC_RX_PREPARE: + SET_RX_BUFFER_DESC_LS(pdesc , 0); + SET_RX_BUFFER_DESC_FS(pdesc , 0); + SET_RX_BUFFER_DESC_TOTAL_LENGTH(pdesc , 0); + + SET_RX_BUFFER_DESC_DATA_LENGTH(pdesc, + MAX_RECEIVE_BUFFER_SIZE + + RX_DESC_SIZE); + + SET_RX_BUFFER_PHYSICAL_LOW(pdesc, *(u32 *)val); + break; + case HW_DESC_RXERO: + SET_RX_DESC_EOR(pdesc, 1); + break; + default: + RT_ASSERT(false, + ("ERR rxdesc :%d not process\n", desc_name)); + break; + } + } +} + +u32 rtl92ee_get_desc(u8 *pdesc, bool istx, u8 desc_name) +{ + u32 ret = 0; + + if (istx) { + switch (desc_name) { + case HW_DESC_OWN: + ret = GET_TX_DESC_OWN(pdesc); + break; + case HW_DESC_TXBUFF_ADDR: + ret = GET_TXBUFFER_DESC_ADDR_LOW(pdesc, 1); + break; + default: + RT_ASSERT(false, + ("ERR txdesc :%d not process\n", desc_name)); + break; + } + } else { + switch (desc_name) { + case HW_DESC_OWN: + ret = GET_RX_DESC_OWN(pdesc); + break; + case HW_DESC_RXPKT_LEN: + ret = GET_RX_DESC_PKT_LEN(pdesc); + break; + case HW_DESC_RXBUFF_ADDR: + ret = GET_RX_DESC_BUFF_ADDR(pdesc); + break; + default: + RT_ASSERT(false, + ("ERR rxdesc :%d not process\n", desc_name)); + break; + } + } + return ret; +} + +bool rtl92ee_is_tx_desc_closed(struct ieee80211_hw *hw, u8 hw_queue, u16 index) +{ + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + struct rtl_priv *rtlpriv = rtl_priv(hw); + u16 read_point, write_point, available_desc_num; + bool ret = false; + static u8 stop_report_cnt; + struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[hw_queue]; + + /*checking Read/Write Point each interrupt wastes CPU utilization.*/ + if (stop_report_cnt > 15 || !rtlpriv->link_info.b_busytraffic) { + u16 point_diff = 0; + u16 cur_tx_rp, cur_tx_wp; + u32 tmpu32; + + tmpu32 = rtl_read_dword(rtlpriv, get_desc_addr_fr_q(hw_queue)); + cur_tx_rp = (u16)((tmpu32 >> 16) & 0x0fff); + cur_tx_wp = (u16)(tmpu32 & 0x0fff); + + ring->cur_tx_wp = cur_tx_wp; + ring->cur_tx_rp = cur_tx_rp; + point_diff = ((cur_tx_rp > cur_tx_wp) ? + (cur_tx_rp - cur_tx_wp) : + (TX_DESC_NUM_92E - cur_tx_wp + cur_tx_rp)); + + ring->avl_desc = point_diff; + } + + read_point = ring->cur_tx_rp; + write_point = ring->cur_tx_wp; + available_desc_num = ring->avl_desc; + + if (write_point > read_point) { + if (index < write_point && index >= read_point) + ret = false; + else + ret = true; + } else if (write_point < read_point) { + if (index > write_point && index < read_point) + ret = true; + else + ret = false; + } else { + if (index != read_point) + ret = true; + } + + if (hw_queue == BEACON_QUEUE) + ret = true; + + if (rtlpriv->rtlhal.driver_is_goingto_unload || + rtlpriv->psc.rfoff_reason > RF_CHANGE_BY_PS) + ret = true; + + if (hw_queue < BEACON_QUEUE) { + if (!ret) + stop_report_cnt++; + else + stop_report_cnt = 0; + } + + return ret; +} + +u32 rtl92ee_rx_command_packet(struct ieee80211_hw *hw, + struct rtl_stats status, + struct sk_buff *skb) +{ + u32 result = 0; + struct rtl_priv *rtlpriv = rtl_priv(hw); + + switch (status.packet_report_type) { + case NORMAL_RX: + result = 0; + break; + case C2H_PACKET: + rtl92ee_c2h_packet_handler(hw, skb->data, (u8) skb->len); + result = 1; + break; + default: + RT_TRACE(COMP_RECV, DBG_TRACE, ("No this packet type!!\n")); + break; + } + + return result; +} diff --git a/drivers/staging/rtl8192ee/rtl8192ee/trx.h b/drivers/staging/rtl8192ee/rtl8192ee/trx.h new file mode 100644 index 000000000000..c2cd5813a2b9 --- /dev/null +++ b/drivers/staging/rtl8192ee/rtl8192ee/trx.h @@ -0,0 +1,877 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * wlanfae + * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, + * Hsinchu 300, Taiwan. + * + * Larry Finger + * + *****************************************************************************/ + +#ifndef __RTL92E_TRX_H__ +#define __RTL92E_TRX_H__ + + + +#if (DMA_IS_64BIT == 1) +#if (RTL8192EE_SEG_NUM == 2) +#define TX_BD_DESC_SIZE 128 +#elif (RTL8192EE_SEG_NUM == 1) +#define TX_BD_DESC_SIZE 64 +#elif (RTL8192EE_SEG_NUM == 0) +#define TX_BD_DESC_SIZE 32 +#endif +#else +#if (RTL8192EE_SEG_NUM == 2) +#define TX_BD_DESC_SIZE 64 +#elif (RTL8192EE_SEG_NUM == 1) +#define TX_BD_DESC_SIZE 32 +#elif (RTL8192EE_SEG_NUM == 0) +#define TX_BD_DESC_SIZE 16 +#endif +#endif + +#define TX_DESC_SIZE 64 + +#define RX_DRV_INFO_SIZE_UNIT 8 + +#define TX_DESC_NEXT_DESC_OFFSET 40 +#define USB_HWDESC_HEADER_LEN 40 + +#define RX_DESC_SIZE 24 +#define MAX_RECEIVE_BUFFER_SIZE 8192 + +#define SET_TX_DESC_PKT_SIZE(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc, 0, 16, __val) +#define SET_TX_DESC_OFFSET(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc, 16, 8, __val) +#define SET_TX_DESC_BMC(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc, 24, 1, __val) +#define SET_TX_DESC_HTC(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc, 25, 1, __val) +#define SET_TX_DESC_LAST_SEG(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc, 26, 1, __val) +#define SET_TX_DESC_FIRST_SEG(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc, 27, 1, __val) +#define SET_TX_DESC_LINIP(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc, 28, 1, __val) +#define SET_TX_DESC_NO_ACM(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc, 29, 1, __val) +#define SET_TX_DESC_GF(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc, 30, 1, __val) +#define SET_TX_DESC_OWN(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc, 31, 1, __val) + +#define GET_TX_DESC_PKT_SIZE(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc, 0, 16) +#define GET_TX_DESC_OFFSET(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc, 16, 8) +#define GET_TX_DESC_BMC(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc, 24, 1) +#define GET_TX_DESC_HTC(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc, 25, 1) +#define GET_TX_DESC_LAST_SEG(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc, 26, 1) +#define GET_TX_DESC_FIRST_SEG(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc, 27, 1) +#define GET_TX_DESC_LINIP(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc, 28, 1) +#define GET_TX_DESC_NO_ACM(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc, 29, 1) +#define GET_TX_DESC_GF(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc, 30, 1) +#define GET_TX_DESC_OWN(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc, 31, 1) + +#define SET_TX_DESC_MACID(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+4, 0, 7, __val) +#define SET_TX_DESC_QUEUE_SEL(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+4, 8, 5, __val) +#define SET_TX_DESC_RDG_NAV_EXT(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+4, 13, 1, __val) +#define SET_TX_DESC_LSIG_TXOP_EN(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+4, 14, 1, __val) +#define SET_TX_DESC_PIFS(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+4, 15, 1, __val) +#define SET_TX_DESC_RATE_ID(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+4, 16, 5, __val) +#define SET_TX_DESC_EN_DESC_ID(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+4, 21, 1, __val) +#define SET_TX_DESC_SEC_TYPE(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+4, 22, 2, __val) +#define SET_TX_DESC_PKT_OFFSET(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+4, 24, 5, __val) +#define SET_TX_DESC_MORE_DATA(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+4, 29, 1, __val) +#define SET_TX_DESC_TXOP_PS_CAP(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+4, 30, 1, __val) +#define SET_TX_DESC_TXOP_PS_MODE(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+4, 31, 1, __val) + + +#define GET_TX_DESC_MACID(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 0, 5) +#define GET_TX_DESC_AGG_ENABLE(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 5, 1) +#define GET_TX_DESC_AGG_BREAK(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 6, 1) +#define GET_TX_DESC_RDG_ENABLE(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 7, 1) +#define GET_TX_DESC_QUEUE_SEL(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 8, 5) +#define GET_TX_DESC_RDG_NAV_EXT(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 13, 1) +#define GET_TX_DESC_LSIG_TXOP_EN(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 14, 1) +#define GET_TX_DESC_PIFS(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 15, 1) +#define GET_TX_DESC_RATE_ID(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 16, 4) +#define GET_TX_DESC_NAV_USE_HDR(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 20, 1) +#define GET_TX_DESC_EN_DESC_ID(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 21, 1) +#define GET_TX_DESC_SEC_TYPE(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 22, 2) +#define GET_TX_DESC_PKT_OFFSET(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 24, 5) + +#define SET_TX_DESC_PAID(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+8, 0, 9, __val) +#define SET_TX_DESC_CCA_RTS(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+8, 10, 2, __val) +#define SET_TX_DESC_AGG_ENABLE(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+8, 12, 1, __val) +#define SET_TX_DESC_RDG_ENABLE(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+8, 13, 1, __val) +#define SET_TX_DESC_NULL_0(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+8, 14, 1, __val) +#define SET_TX_DESC_NULL_1(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+8, 15, 1, __val) +#define SET_TX_DESC_BK(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+8, 16, 1, __val) +#define SET_TX_DESC_MORE_FRAG(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+8, 17, 1, __val) +#define SET_TX_DESC_RAW(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+8, 18, 1, __val) +#define SET_TX_DESC_SPE_RPT(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+8, 19, 1, __val) +#define SET_TX_DESC_AMPDU_DENSITY(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+8, 20, 3, __val) +#define SET_TX_DESC_BT_NULL(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+8, 23, 1, __val) +#define SET_TX_DESC_GID(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+8, 24, 6, __val) + +#define SET_TX_DESC_WHEADER_LEN(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+12, 0, 4, __val) +#define SET_TX_DESC_CHK_EN(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+12, 4, 1, __val) +#define SET_TX_DESC_EARLY_RATE(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+12, 5, 1, __val) +#define SET_TX_DESC_HWSEQ_SEL(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+12, 6, 2, __val) +#define SET_TX_DESC_USE_RATE(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+12, 8, 1, __val) +#define SET_TX_DESC_DISABLE_RTS_FB(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+12, 9, 1, __val) +#define SET_TX_DESC_DISABLE_FB(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+12, 10, 1, __val) +#define SET_TX_DESC_CTS2SELF(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+12, 11, 1, __val) +#define SET_TX_DESC_RTS_ENABLE(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+12, 12, 1, __val) +#define SET_TX_DESC_HW_RTS_ENABLE(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+12, 13, 1, __val) +#define SET_TX_DESC_HW_PORT_ID(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+12, 14, 1, __val) +#define SET_TX_DESC_NAV_USE_HDR(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+12, 15, 1, __val) +#define SET_TX_DESC_USE_MAX_LEN(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+12, 16, 1, __val) +#define SET_TX_DESC_MAX_AGG_NUM(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+12, 17, 5, __val) +#define SET_TX_DESC_NDPA(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+12, 22, 2, __val) +#define SET_TX_DESC_AMPDU_MAX_TIME(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+12, 24, 8, __val) + + +/* Dword 4 */ +#define SET_TX_DESC_TX_RATE(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+16, 0, 7, __val) +#define SET_TX_DESC_TRY_RATE(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+16, 7, 1, __val) +#define SET_TX_DESC_DATA_RATE_FB_LIMIT(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+16, 8, 5, __val) +#define SET_TX_DESC_RTS_RATE_FB_LIMIT(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+16, 13, 4, __val) +#define SET_TX_DESC_RETRY_LIMIT_ENABLE(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+16, 17, 1, __val) +#define SET_TX_DESC_DATA_RETRY_LIMIT(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+16, 18, 6, __val) +#define SET_TX_DESC_RTS_RATE(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+16, 24, 5, __val) +#define SET_TX_DESC_PCTS_ENABLE(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+16, 29, 1, __val) +#define SET_TX_DESC_PCTS_MASK_IDX(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+16, 30, 2, __val) + + +/* Dword 5 */ +#define SET_TX_DESC_TX_SUB_CARRIER(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+20, 0, 4, __val) +#define SET_TX_DESC_DATA_SHORT(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+20, 4, 1, __val) +#define SET_TX_DESC_DATA_BW(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+20, 5, 2, __val) +#define SET_TX_DESC_DATA_LDPC(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+20, 7, 1, __val) +#define SET_TX_DESC_DATA_STBC(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+20, 8, 2, __val) +#define SET_TX_DESC_VCS_STBC(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+20, 10, 2, __val) +#define SET_TX_DESC_RTS_SHORT(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+20, 12, 1, __val) +#define SET_TX_DESC_RTS_SC(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+20, 13, 4, __val) +#define SET_TX_DESC_TX_ANT(__pdesc , __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+20, 24, 4, __val) +#define SET_TX_DESC_TX_POWER_0_PSET(__pdesc , __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+20, 28, 3, __val) + +/* Dword 6 */ +#define SET_TX_DESC_SW_DEFINE(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+24, 0, 12, __val) +#define SET_TX_DESC_ANTSEL_A(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+24, 16, 3, __val) +#define SET_TX_DESC_ANTSEL_B(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+24, 19, 3, __val) +#define SET_TX_DESC_ANTSEL_C(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+24, 22, 3, __val) +#define SET_TX_DESC_ANTSEL_D(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+24, 25, 3, __val) + +/* Dword 7 */ +#define SET_TX_DESC_TX_BUFFER_SIZE(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+28, 0, 16, __val) +#define SET_TX_DESC_USB_TXAGG_NUM(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+28, 24, 8, __val) + +/* Dword 8 */ +#define SET_TX_DESC_RTS_RC(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+32 , 0 , 6 , __val) +#define SET_TX_DESC_BAR_RTY_TH(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+32 , 6 , 2 , __val) +#define SET_TX_DESC_DATA_RC(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+32 , 8 , 6 , __val) +#define SET_TX_DESC_ENABLE_HW_SELECT(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+32 , 15 , 1 , __val) +#define SET_TX_DESC_NEXT_HEAD_PAGE(__pdesc , __val)(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+32 , 16 , 8 , __val) +#define SET_TX_DESC_TAIL_PAGE(__pdesc , __val)(__pdesc, __val)\ + SET_BITS_TO_LE_4BYTE(__pdesc+32 , 24 , 8 , __val) + +/* Dword 9 */ +#define SET_TX_DESC_PADDING_LENGTH(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+36 , 0 , 11 , __val) +#define SET_TX_DESC_TXBF_PATH(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+36 , 11 , 1 , __val) +#define SET_TX_DESC_SEQ(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+36 , 12 , 12 , __val) +#define SET_TX_DESC_FINAL_DATA_RATE(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+36 , 24 , 8 , __val) + +/* Dword 10 */ +#define SET_TX_DESC_TX_BUFFER_ADDRESS(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+40 , 0 , 32 , __val) + + +/* Dword 11*/ +#define SET_TX_DESC_NEXT_DESC_ADDRESS(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+48 , 0 , 32 , __val) + + +#define SET_EARLYMODE_PKTNUM(__paddr , __val) \ + SET_BITS_TO_LE_4BYTE(__paddr , 0 , 4 , __val) +#define SET_EARLYMODE_LEN0(__paddr , __val) \ + SET_BITS_TO_LE_4BYTE(__paddr , 4 , 15 , __val) +#define SET_EARLYMODE_LEN1(__paddr , __val) \ + SET_BITS_TO_LE_4BYTE(__paddr , 16 , 2 , __val) +#define SET_EARLYMODE_LEN1_1(__paddr , __val) \ + SET_BITS_TO_LE_4BYTE(__paddr , 19 , 13 , __val) +#define SET_EARLYMODE_LEN1_2(__paddr , __val) \ + SET_BITS_TO_LE_4BYTE(__paddr+4 , 0 , 2 , __val) +#define SET_EARLYMODE_LEN2(__paddr , __val) \ + SET_BITS_TO_LE_4BYTE(__paddr+4 , 2 , 15 , __val) +#define SET_EARLYMODE_LEN2_1(__paddr , __val) \ + SET_BITS_TO_LE_4BYTE(__paddr , 2 , 4 , __val) +#define SET_EARLYMODE_LEN2_2(__paddr , __val) \ + SET_BITS_TO_LE_4BYTE(__paddr+4 , 0 , 8 , __val) +#define SET_EARLYMODE_LEN3(__paddr , __val) \ + SET_BITS_TO_LE_4BYTE(__paddr+4 , 17 , 15, __val) +#define SET_EARLYMODE_LEN4(__paddr , __val) \ + SET_BITS_TO_LE_4BYTE(__paddr+4 , 20 , 12 , __val) + + +/* TX/RX buffer descriptor */ + +#define SET_TX_EXTBUFF_DESC_LEN(__pdesc, __val, __set) \ + SET_BITS_TO_LE_4BYTE(__pdesc+(__set*16) , 0 , 16 , __val) +#define SET_TX_EXTBUFF_DESC_ADDR_LOW(__pdesc, __val, __set)\ + SET_BITS_TO_LE_4BYTE(__pdesc+(__set*16)+4 , 0 , 32 , __val) +#define SET_TX_EXTBUFF_DESC_ADDR_HIGH(__pdesc, __val , __set)\ + SET_BITS_TO_LE_4BYTE(__pdesc+(__set*16)+8 , 0 , 32 , __val) + + + +/* for Txfilldescroptor92ee, fill the desc content. */ +#if (DMA_IS_64BIT == 1) +#define SET_TXBUFFER_DESC_LEN_WITH_OFFSET(__pdesc, __offset, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+(__offset*16), 0, 16, __val) +#define SET_TXBUFFER_DESC_AMSDU_WITH_OFFSET(__pdesc, __offset, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+(__offset*16), 31, 1, __val) +#define SET_TXBUFFER_DESC_ADD_LOW_WITH_OFFSET(__pdesc, __offset, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+(__offset*16)+4, 0, 32, __val) +#define SET_TXBUFFER_DESC_ADD_HIGT_WITH_OFFSET(__pdesc, __offset, __val)\ + SET_BITS_TO_LE_4BYTE(__pdesc+(__offset*16)+8, 0, 32, __val) +#define GET_TXBUFFER_DESC_ADDR_LOW(__pdesc, __offset) \ + LE_BITS_TO_4BYTE(__pdesc+(__offset*16)+4, 0, 32) +#else +#define SET_TXBUFFER_DESC_LEN_WITH_OFFSET(__pdesc, __offset, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+(__offset*8), 0, 16, __val) +#define SET_TXBUFFER_DESC_AMSDU_WITH_OFFSET(__pdesc, __offset, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+(__offset*8), 31, 1, __val) +#define SET_TXBUFFER_DESC_ADD_LOW_WITH_OFFSET(__pdesc, __offset, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+(__offset*8)+4, 0, 32, __val) +#define SET_TXBUFFER_DESC_ADD_HIGT_WITH_OFFSET(__pdesc, __offset, __val) +#define GET_TXBUFFER_DESC_ADDR_LOW(__pdesc, __offset) \ + LE_BITS_TO_4BYTE(__pdesc+(__offset*8)+4, 0, 32) +#endif + +/* Dword 0 */ +#define SET_TX_BUFF_DESC_LEN_0(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc, 0, 14, __val) +#define SET_TX_BUFF_DESC_PSB(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc, 16, 15, __val) +#define SET_TX_BUFF_DESC_OWN(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc, 31, 1, __val) + +/* Dword 1 */ +#define SET_TX_BUFF_DESC_ADDR_LOW_0(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+4, 0, 32, __val) +#if (DMA_IS_64BIT == 1) +/* Dword 2 */ +#define SET_TX_BUFF_DESC_ADDR_HIGH_0(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+8, 0, 32, __val) +/* Dword 3 / RESERVED 0 */ +/* Dword 4 */ +#define SET_TX_BUFF_DESC_LEN_1(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+16, 0, 16, __val) +#define SET_TX_BUFF_DESC_AMSDU_1(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+16, 31, 1, __val) +/* Dword 5 */ +#define SET_TX_BUFF_DESC_ADDR_LOW_1(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+20, 0, 32, __val) +/* Dword 6 */ +#define SET_TX_BUFF_DESC_ADDR_HIGH_1(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+24, 0, 32, __val) +/* Dword 7 / RESERVED 0 */ +/* Dword 8 */ +#define SET_TX_BUFF_DESC_LEN_2(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+32, 0, 16, __val) +#define SET_TX_BUFF_DESC_AMSDU_2(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+32, 31, 1, __val) +/* Dword 9 */ +#define SET_TX_BUFF_DESC_ADDR_LOW_2(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+36, 0, 32, __val) +/* Dword 10 */ +#define SET_TX_BUFF_DESC_ADDR_HIGH_2(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+40, 0, 32, __val) +/* Dword 11 / RESERVED 0 */ +/* Dword 12 */ +#define SET_TX_BUFF_DESC_LEN_3(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+48, 0, 16, __val) +#define SET_TX_BUFF_DESC_AMSDU_3(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+48, 31, 1, __val) +/* Dword 13 */ +#define SET_TX_BUFF_DESC_ADDR_LOW_3(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+52, 0, 32, __val) +/* Dword 14 */ +#define SET_TX_BUFF_DESC_ADDR_HIGH_3(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+56, 0, 32, __val) +/* Dword 15 / RESERVED 0 */ +#else +#define SET_TX_BUFF_DESC_ADDR_HIGH_0(__pdesc, __val) +/* Dword 2 */ +#define SET_TX_BUFF_DESC_LEN_1(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+8, 0, 16, __val) +#define SET_TX_BUFF_DESC_AMSDU_1(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+8, 31, 1, __val) +/* Dword 3 */ +#define SET_TX_BUFF_DESC_ADDR_LOW_1(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+12, 0, 32, __val) +#define SET_TX_BUFF_DESC_ADDR_HIGH_1(__pdesc, __val) +/* Dword 4 */ +#define SET_TX_BUFF_DESC_LEN_2(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+16, 0, 16, __val) +#define SET_TX_BUFF_DESC_AMSDU_2(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+16, 31, 1, __val) +/* Dword 5 */ +#define SET_TX_BUFF_DESC_ADDR_LOW_2(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+20, 0, 32, __val) +#define SET_TX_BUFF_DESC_ADDR_HIGH_2(__pdesc, __val) +/* Dword 6 */ +#define SET_TX_BUFF_DESC_LEN_3(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+24, 0, 16, __val) +#define SET_TX_BUFF_DESC_AMSDU_3(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+24, 31, 1, __val) +/* Dword 7 */ +#define SET_TX_BUFF_DESC_ADDR_LOW_3(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+28, 0, 32, __val) +#define SET_TX_BUFF_DESC_ADDR_HIGH_3(__pdesc, __val) +#endif + +/* RX buffer */ + +/* DWORD 0 */ +#define SET_RX_BUFFER_DESC_DATA_LENGTH(__pRxStatusDesc , __val) \ + SET_BITS_TO_LE_4BYTE(__pRxStatusDesc , 0, 14, __val) +#define SET_RX_BUFFER_DESC_LS(__pRxStatusDesc , __val) \ + SET_BITS_TO_LE_4BYTE(__pRxStatusDesc , 15, 1, __val) +#define SET_RX_BUFFER_DESC_FS(__pRxStatusDesc , __val) \ + SET_BITS_TO_LE_4BYTE(__pRxStatusDesc , 16, 1, __val) +#define SET_RX_BUFFER_DESC_TOTAL_LENGTH(__pRxStatusDesc , __val) \ + SET_BITS_TO_LE_4BYTE(__pRxStatusDesc , 16, 15, __val) + +#define GET_RX_BUFFER_DESC_OWN(__pRxStatusDesc) \ + LE_BITS_TO_4BYTE(__pRxStatusDesc , 31, 1) +#define GET_RX_BUFFER_DESC_LS(__pRxStatusDesc) \ + LE_BITS_TO_4BYTE(__pRxStatusDesc , 15, 1) +#define GET_RX_BUFFER_DESC_FS(__pRxStatusDesc) \ + LE_BITS_TO_4BYTE(__pRxStatusDesc , 16, 1) +#define GET_RX_BUFFER_DESC_TOTAL_LENGTH(__pRxStatusDesc) \ + LE_BITS_TO_4BYTE(__pRxStatusDesc , 16, 15) + + +/* DWORD 1 */ +#define SET_RX_BUFFER_PHYSICAL_LOW(__pRxStatusDesc , __val) \ + SET_BITS_TO_LE_4BYTE(__pRxStatusDesc+4, 0, 32, __val) + +/* DWORD 2 */ +#define SET_RX_BUFFER_PHYSICAL_HIGH(__pRxStatusDesc , __val) \ + SET_BITS_TO_LE_4BYTE(__pRxStatusDesc+8, 0, 32, __val) + +#define GET_RX_DESC_PKT_LEN(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc, 0, 14) +#define GET_RX_DESC_CRC32(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc, 14, 1) +#define GET_RX_DESC_ICV(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc, 15, 1) +#define GET_RX_DESC_DRV_INFO_SIZE(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc, 16, 4) +#define GET_RX_DESC_SECURITY(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc, 20, 3) +#define GET_RX_DESC_QOS(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc, 23, 1) +#define GET_RX_DESC_SHIFT(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc, 24, 2) +#define GET_RX_DESC_PHYST(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc, 26, 1) +#define GET_RX_DESC_SWDEC(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc, 27, 1) +#define GET_RX_DESC_LS(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc, 28, 1) +#define GET_RX_DESC_FS(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc, 29, 1) +#define GET_RX_DESC_EOR(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc, 30, 1) +#define GET_RX_DESC_OWN(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc, 31, 1) + +#define SET_RX_DESC_PKT_LEN(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc, 0, 14, __val) +#define SET_RX_DESC_EOR(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc, 30, 1, __val) +#define SET_RX_DESC_OWN(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc, 31, 1, __val) + +#define GET_RX_DESC_MACID(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 0, 7) +#define GET_RX_DESC_TID(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 8, 4) +#define GET_RX_DESC_MACID_VLD(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 12, 1) +#define GET_RX_DESC_AMSDU(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 13, 1) +#define GET_RX_DESC_RXID_MATCH(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 14, 1) +#define GET_RX_DESC_PAGGR(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 15, 1) +#define GET_RX_DESC_A1_FIT(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 16, 4) +#define GET_RX_DESC_TCPOFFLOAD_CHKERR(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 20, 1) +#define GET_RX_DESC_TCPOFFLOAD_IPVER(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 21, 1) +#define GET_RX_DESC_TCPOFFLOAD_IS_TCPUDP(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 22, 1) +#define GET_RX_DESC_TCPOFFLOAD_CHK_VLD(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 23, 1) +#define GET_RX_DESC_PAM(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 24, 1) +#define GET_RX_DESC_PWR(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 25, 1) +#define GET_RX_DESC_MD(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 26, 1) +#define GET_RX_DESC_MF(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 27, 1) +#define GET_RX_DESC_TYPE(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 28, 2) +#define GET_RX_DESC_MC(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 30, 1) +#define GET_RX_DESC_BC(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+4, 31, 1) +#define GET_RX_DESC_SEQ(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+8, 0, 12) +#define GET_RX_DESC_FRAG(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+8, 12, 4) +#define GET_RX_DESC_RX_IS_QOS(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+8, 16, 1) + +#define GET_RX_DESC_RXMCS(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+12, 0, 7) +#define GET_RX_DESC_HTC(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+12, 10, 1) +#define GET_RX_STATUS_DESC_EOSP(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+12, 11, 1) +#define GET_RX_STATUS_DESC_BSSID_FIT(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+12, 12, 2) +#define GET_RX_STATUS_DESC_DMA_AGG_NUM(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+12, 16, 8) +#define GET_RX_STATUS_DESC_PATTERN_MATCH(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+12, 29, 1) +#define GET_RX_STATUS_DESC_UNICAST_MATCH(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+12, 30, 1) +#define GET_RX_STATUS_DESC_MAGIC_MATCH(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+12, 31, 1) + + +#define GET_RX_DESC_TSFL(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+20, 0, 32) + +#define GET_RX_DESC_BUFF_ADDR(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+24, 0, 32) +#define GET_RX_DESC_BUFF_ADDR64(__pdesc) \ + LE_BITS_TO_4BYTE(__pdesc+28, 0, 32) + +#define SET_RX_DESC_BUFF_ADDR(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+24, 0, 32, __val) +#define SET_RX_DESC_BUFF_ADDR64(__pdesc, __val) \ + SET_BITS_TO_LE_4BYTE(__pdesc+28, 0, 32, __val) + + +/* TX report 2 format in Rx desc*/ + +#define GET_RX_RPT2_DESC_PKT_LEN(__pRxStatusDesc) \ + LE_BITS_TO_4BYTE(__pRxStatusDesc , 0, 9) +#define GET_RX_RPT2_DESC_MACID_VALID_1(__pRxStatusDesc) \ + LE_BITS_TO_4BYTE(__pRxStatusDesc+16, 0, 32) +#define GET_RX_RPT2_DESC_MACID_VALID_2(__pRxStatusDesc) \ + LE_BITS_TO_4BYTE(__pRxStatusDesc+20, 0, 32) + + +#define CLEAR_PCI_TX_DESC_CONTENT(__pdesc, _size) \ +do { \ + if (_size > TX_DESC_NEXT_DESC_OFFSET) \ + memset(__pdesc, 0, TX_DESC_NEXT_DESC_OFFSET); \ + else \ + memset(__pdesc, 0, _size); \ +} while (0) + +#define RX_HAL_IS_CCK_RATE(rxmcs)\ + (rxmcs == DESC92C_RATE1M ||\ + rxmcs == DESC92C_RATE2M ||\ + rxmcs == DESC92C_RATE5_5M ||\ + rxmcs == DESC92C_RATE11M) + +#define IS_LITTLE_ENDIAN 1 + +struct phy_rx_agc_info_t { + #if IS_LITTLE_ENDIAN + u8 gain:7 , trsw:1; + #else + u8 trsw:1 , gain:7; + #endif +}; +struct phy_status_rpt { + struct phy_rx_agc_info_t path_agc[2]; + u8 ch_corr[2]; + u8 cck_sig_qual_ofdm_pwdb_all; + u8 cck_agc_rpt_ofdm_cfosho_a; + u8 cck_rpt_b_ofdm_cfosho_b; + u8 rsvd_1; + u8 noise_power_db_msb; + u8 path_cfotail[2]; + u8 pcts_mask[2]; + u8 stream_rxevm[2]; + u8 path_rxsnr[2]; + u8 noise_power_db_lsb; + u8 rsvd_2[3]; + u8 stream_csi[2]; + u8 stream_target_csi[2]; + u8 sig_evm; + u8 rsvd_3; +#if IS_LITTLE_ENDIAN + u8 antsel_rx_keep_2:1; /*ex_intf_flg:1;*/ + u8 sgi_en:1; + u8 rxsc:2; + u8 idle_long:1; + u8 r_ant_train_en:1; + u8 ant_sel_b:1; + u8 ant_sel:1; +#else /* _BIG_ENDIAN_ */ + u8 ant_sel:1; + u8 ant_sel_b:1; + u8 r_ant_train_en:1; + u8 idle_long:1; + u8 rxsc:2; + u8 sgi_en:1; + u8 antsel_rx_keep_2:1; /*ex_intf_flg:1;*/ +#endif +} __packed; + +struct rx_fwinfo { + u8 gain_trsw[4]; + u8 pwdb_all; + u8 cfosho[4]; + u8 cfotail[4]; + char rxevm[2]; + char rxsnr[4]; + u8 pdsnr[2]; + u8 csi_current[2]; + u8 csi_target[2]; + u8 sigevm; + u8 max_ex_pwr; + u8 ex_intf_flag:1; + u8 sgi_en:1; + u8 rxsc:2; + u8 reserve:4; +} __packed; + +struct tx_desc { + u32 pktsize:16; + u32 offset:8; + u32 bmc:1; + u32 htc:1; + u32 lastseg:1; + u32 firstseg:1; + u32 linip:1; + u32 noacm:1; + u32 gf:1; + u32 own:1; + + u32 macid:6; + u32 rsvd0:2; + u32 queuesel:5; + u32 rd_nav_ext:1; + u32 lsig_txop_en:1; + u32 pifs:1; + u32 rateid:4; + u32 nav_usehdr:1; + u32 en_descid:1; + u32 sectype:2; + u32 pktoffset:8; + + u32 rts_rc:6; + u32 data_rc:6; + u32 agg_en:1; + u32 rdg_en:1; + u32 bar_retryht:2; + u32 agg_break:1; + u32 morefrag:1; + u32 raw:1; + u32 ccx:1; + u32 ampdudensity:3; + u32 bt_int:1; + u32 ant_sela:1; + u32 ant_selb:1; + u32 txant_cck:2; + u32 txant_l:2; + u32 txant_ht:2; + + u32 nextheadpage:8; + u32 tailpage:8; + u32 seq:12; + u32 cpu_handle:1; + u32 tag1:1; + u32 trigger_int:1; + u32 hwseq_en:1; + + u32 rtsrate:5; + u32 apdcfe:1; + u32 qos:1; + u32 hwseq_ssn:1; + u32 userrate:1; + u32 dis_rtsfb:1; + u32 dis_datafb:1; + u32 cts2self:1; + u32 rts_en:1; + u32 hwrts_en:1; + u32 portid:1; + u32 pwr_status:3; + u32 waitdcts:1; + u32 cts2ap_en:1; + u32 txsc:2; + u32 stbc:2; + u32 txshort:1; + u32 txbw:1; + u32 rtsshort:1; + u32 rtsbw:1; + u32 rtssc:2; + u32 rtsstbc:2; + + u32 txrate:6; + u32 shortgi:1; + u32 ccxt:1; + u32 txrate_fb_lmt:5; + u32 rtsrate_fb_lmt:4; + u32 retrylmt_en:1; + u32 txretrylmt:6; + u32 usb_txaggnum:8; + + u32 txagca:5; + u32 txagcb:5; + u32 usemaxlen:1; + u32 maxaggnum:5; + u32 mcsg1maxlen:4; + u32 mcsg2maxlen:4; + u32 mcsg3maxlen:4; + u32 mcs7sgimaxlen:4; + + u32 txbuffersize:16; + u32 sw_offset30:8; + u32 sw_offset31:4; + u32 rsvd1:1; + u32 antsel_c:1; + u32 null_0:1; + u32 null_1:1; + + u32 txbuffaddr; + u32 txbufferaddr64; + u32 nextdescaddress; + u32 nextdescaddress64; + + u32 reserve_pass_pcie_mm_limit[4]; +} __packed; + +struct rx_desc { + u32 length:14; + u32 crc32:1; + u32 icverror:1; + u32 drv_infosize:4; + u32 security:3; + u32 qos:1; + u32 shift:2; + u32 phystatus:1; + u32 swdec:1; + u32 lastseg:1; + u32 firstseg:1; + u32 eor:1; + u32 own:1; + + u32 macid:6; + u32 tid:4; + u32 hwrsvd:5; + u32 paggr:1; + u32 faggr:1; + u32 a1_fit:4; + u32 a2_fit:4; + u32 pam:1; + u32 pwr:1; + u32 moredata:1; + u32 morefrag:1; + u32 type:2; + u32 mc:1; + u32 bc:1; + + u32 seq:12; + u32 frag:4; + u32 nextpktlen:14; + u32 nextind:1; + u32 rsvd:1; + + u32 rxmcs:6; + u32 rxht:1; + u32 amsdu:1; + u32 splcp:1; + u32 bandwidth:1; + u32 htc:1; + u32 tcpchk_rpt:1; + u32 ipcchk_rpt:1; + u32 tcpchk_valid:1; + u32 hwpcerr:1; + u32 hwpcind:1; + u32 iv0:16; + + u32 iv1; + + u32 tsfl; + + u32 bufferaddress; + u32 bufferaddress64; + +} __packed; + +void rtl92ee_rx_check_dma_ok(struct ieee80211_hw *hw, u8 *header_desc, + u8 queue_index); +u16 rtl92ee_rx_desc_buff_remained_cnt(struct ieee80211_hw *hw, + u8 queue_index); +void rtl92ee_get_available_desc(struct ieee80211_hw *hw , u8 queue_index); +void rtl92ee_pre_fill_tx_bd_desc(struct ieee80211_hw *hw, + u8 *tx_bd_desc, u8 *desc, u8 queue_index, + struct sk_buff *skb, dma_addr_t addr); + + +void rtl92ee_tx_fill_desc(struct ieee80211_hw *hw, + struct ieee80211_hdr *hdr, u8 *pdesc_tx, + u8 *pbd_desc_tx, + struct ieee80211_tx_info *info, + struct ieee80211_sta *sta, + struct sk_buff *skb, + u8 hw_queue, struct rtl_tcb_desc *ptcb_desc); +bool rtl92ee_rx_query_desc(struct ieee80211_hw *hw, + struct rtl_stats *status, + struct ieee80211_rx_status *rx_status, + u8 *pdesc, struct sk_buff *skb); +void rtl92ee_set_desc(struct ieee80211_hw *hw, u8 *pdesc, bool istx, + u8 desc_name, u8 *val); + +u32 rtl92ee_get_desc(u8 *pdesc, bool istx, u8 desc_name); +bool rtl92ee_is_tx_desc_closed(struct ieee80211_hw *hw, u8 hw_queue, u16 index); +void rtl92ee_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 *pdesc, + bool b_firstseg, bool b_lastseg, + struct sk_buff *skb); +u32 rtl92ee_rx_command_packet(struct ieee80211_hw *hw, + struct rtl_stats status, + struct sk_buff *skb); +#endif -- cgit v1.2.3 From 0629f3b8c33899140b48d5897259eab8ebae78ca Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 May 2014 16:25:36 -0500 Subject: staging: r8192ee: Turn on build of the new driver In addition, this commit contains a TODO file for this driver Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 ++ drivers/staging/Makefile | 1 + drivers/staging/rtl8192ee/Kconfig | 8 ++++++++ drivers/staging/rtl8192ee/Makefile | 40 ++++++++++++++++++++++++++++++++++++++ drivers/staging/rtl8192ee/TODO | 12 ++++++++++++ 5 files changed, 63 insertions(+) create mode 100644 drivers/staging/rtl8192ee/Kconfig create mode 100644 drivers/staging/rtl8192ee/Makefile create mode 100644 drivers/staging/rtl8192ee/TODO diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 0c3887778f38..f0cf26959fae 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -48,6 +48,8 @@ source "drivers/staging/rtl8712/Kconfig" source "drivers/staging/rtl8188eu/Kconfig" +source "drivers/staging/rtl8192ee/Kconfig" + source "drivers/staging/rtl8723au/Kconfig" source "drivers/staging/rtl8821ae/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 7bf91a616066..f60f26f537df 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -16,6 +16,7 @@ obj-$(CONFIG_RTL8192U) += rtl8192u/ obj-$(CONFIG_RTL8192E) += rtl8192e/ obj-$(CONFIG_R8712U) += rtl8712/ obj-$(CONFIG_R8188EU) += rtl8188eu/ +obj-$(CONFIG_R8192EE) += rtl8192ee/ obj-$(CONFIG_R8723AU) += rtl8723au/ obj-$(CONFIG_R8821AE) += rtl8821ae/ obj-$(CONFIG_RTS5139) += rts5139/ diff --git a/drivers/staging/rtl8192ee/Kconfig b/drivers/staging/rtl8192ee/Kconfig new file mode 100644 index 000000000000..92c5f442df3d --- /dev/null +++ b/drivers/staging/rtl8192ee/Kconfig @@ -0,0 +1,8 @@ +config R8192EE + tristate "Realtek RTL8192EE Wireless Network Adapter" + select FW_LOADER + ---help--- + This is the driver for Realtek RTL8192EE 802.11 PCIe + wireless network adapters. + + If you choose to build it as a module, it will be called r8192ee diff --git a/drivers/staging/rtl8192ee/Makefile b/drivers/staging/rtl8192ee/Makefile new file mode 100644 index 000000000000..31708620d7e7 --- /dev/null +++ b/drivers/staging/rtl8192ee/Makefile @@ -0,0 +1,40 @@ + +PCI_MAIN_OBJS := base.o \ + cam.o \ + core.o \ + debug.o \ + efuse.o \ + pci.o \ + ps.o \ + rc.o \ + regd.o \ + stats.o + +PCI_8192EE_HAL_OBJS:= \ + rtl8192ee/dm.o \ + rtl8192ee/fw.o \ + rtl8192ee/hw.o \ + rtl8192ee/led.o \ + rtl8192ee/phy.o \ + rtl8192ee/pwrseq.o \ + rtl8192ee/pwrseqcmd.o \ + rtl8192ee/rf.o \ + rtl8192ee/sw.o \ + rtl8192ee/table.o \ + rtl8192ee/trx.o + + + +BT_COEXIST_OBJS:= btcoexist/halbtc8192e2ant.o\ + btcoexist/halbtc8723b1ant.o\ + btcoexist/halbtc8723b2ant.o\ + btcoexist/halbtc8821a1ant.o\ + btcoexist/halbtc8821a2ant.o\ + btcoexist/halbtcoutsrc.o\ + btcoexist/rtl_btc.o + +r8192ee-objs += $(PCI_MAIN_OBJS) $(PCI_8192EE_HAL_OBJS) $(BT_COEXIST_OBJS) + +obj-$(CONFIG_R8192EE) += r8192ee.o + +ccflags-y += -D__CHECK_ENDIAN__ diff --git a/drivers/staging/rtl8192ee/TODO b/drivers/staging/rtl8192ee/TODO new file mode 100644 index 000000000000..162092a0316b --- /dev/null +++ b/drivers/staging/rtl8192ee/TODO @@ -0,0 +1,12 @@ +TODO: +- convert any remaining unusual variable types +- find codes that can use %pM and %Nph formatting +- checkpatch.pl fixes - most of the remaining ones are lines too long. Many + of them will require refactoring +- merge Realtek's bugfixes and new features into the driver +- Convert the versions of rtlwifi and btcoexist in drivers/net/wireless/rtlwifi/... + to work with the RTL8192EE +- move this driver to drivers/net/wireless/rtlwifi + +Please send any patches to Greg Kroah-Hartman , +and Larry Finger . -- cgit v1.2.3 From 96808173627faebd1c39ab7af7630061bdd81c2a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:25 +0200 Subject: staging: rtl8723au: Fix compiling with CONFIG_8723AU_BT_COEXIST=n Reported-by: Jim Davis Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/Makefile | 3 ++- drivers/staging/rtl8723au/core/rtw_cmd.c | 1 + drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 3 --- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 1 + drivers/staging/rtl8723au/include/rtl8723a_hal.h | 2 ++ 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723au/Makefile b/drivers/staging/rtl8723au/Makefile index 950446e4ee1b..f85f4b38bccf 100644 --- a/drivers/staging/rtl8723au/Makefile +++ b/drivers/staging/rtl8723au/Makefile @@ -24,7 +24,6 @@ r8723au-y := \ hal/HalHWImg8723A_RF.o \ hal/HalPwrSeqCmd.o \ hal/odm_RegConfig8723A.o \ - hal/rtl8723a_bt-coexist.o \ hal/odm_debug.o \ hal/odm_interface.o \ hal/odm_HWConfig.o \ @@ -50,6 +49,8 @@ r8723au-y := \ os_dep/usb_ops_linux.o \ os_dep/xmit_linux.o +r8723au-$(CONFIG_8723AU_BT_COEXIST) += hal/rtl8723a_bt-coexist.o + obj-$(CONFIG_R8723AU) := r8723au.o ccflags-y += -D__CHECK_ENDIAN__ -I$(src)/include diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 2f3fbb3d1bbb..b9ee28a8730c 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -19,6 +19,7 @@ #include #include #include +#include #ifdef CONFIG_8723AU_BT_COEXIST #include diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 9f9facd4a28a..9338cb94167c 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -22,10 +22,7 @@ #include #include #include - -#ifdef CONFIG_8723AU_BT_COEXIST #include -#endif static int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); static int OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index 7ae9748dcd7b..96337a87b1d8 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -18,6 +18,7 @@ #include #include #include +#include #ifdef CONFIG_8723AU_BT_COEXIST #include diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index 1aa65e067209..2dc7c93df62e 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -29,8 +29,10 @@ #include "rtl8723a_cmd.h" #include "rtl8723a_sreset.h" #include "rtw_efuse.h" +#include "rtw_eeprom.h" #include "odm_precomp.h" +#include "odm.h" /* 2TODO: We should define 8192S firmware related macro settings here!! */ -- cgit v1.2.3 From efc7144ff163bb1305ec8585e9e2f93ad9b06bd9 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:26 +0200 Subject: staging: rtl8723au: Use nl80211_iftype instead of driver's own custom types In addition move rtw_set_802_11_infrastructure_mode23a() to ioctl_cfg80211.c and declare it static. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 5 +- drivers/staging/rtl8723au/core/rtw_cmd.c | 19 ++-- drivers/staging/rtl8723au/core/rtw_ioctl_set.c | 86 ------------------ drivers/staging/rtl8723au/core/rtw_mlme.c | 21 +++-- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 41 +++++---- drivers/staging/rtl8723au/core/rtw_sreset.c | 2 +- drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 10 ++- drivers/staging/rtl8723au/include/rtw_cmd.h | 5 +- drivers/staging/rtl8723au/include/rtw_ioctl_set.h | 2 - drivers/staging/rtl8723au/include/wlan_bssdef.h | 14 +-- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 105 +++++++++++++++++++--- 11 files changed, 149 insertions(+), 161 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 0b7a4a68b5f4..5847fc5f6f36 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -824,7 +824,8 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, memcpy(ie, pbuf, pbss_network->IELength); - if (pbss_network->InfrastructureMode!= Ndis802_11APMode) + if (pbss_network->ifmode != NL80211_IFTYPE_AP && + pbss_network->ifmode != NL80211_IFTYPE_P2P_GO) return _FAIL; pbss_network->Rssi = 0; @@ -1898,7 +1899,7 @@ void rtw_ap_restore_network(struct rtw_adapter *padapter) struct sta_info *chk_alive_list[NUM_STA]; int i; - rtw_setopmode_cmd23a(padapter, Ndis802_11APMode); + rtw_setopmode_cmd23a(padapter, NL80211_IFTYPE_AP); set_channel_bwmode23a(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index b9ee28a8730c..b28afb1b8380 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -477,11 +477,11 @@ int rtw_joinbss_cmd23a(struct rtw_adapter *padapter, struct security_priv *psecuritypriv = &padapter->securitypriv; struct registry_priv *pregistrypriv = &padapter->registrypriv; struct ht_priv *phtpriv = &pmlmepriv->htpriv; - enum ndis_802_11_net_infra ndis_network_mode; + enum nl80211_iftype ifmode; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - ndis_network_mode = pnetwork->network.InfrastructureMode; + ifmode = pnetwork->network.ifmode; rtw_led_control(padapter, LED_CTL_START_TO_LINK); @@ -505,16 +505,15 @@ int rtw_joinbss_cmd23a(struct rtw_adapter *padapter, /* for hidden ap to set fw_state here */ if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE)) { - switch (ndis_network_mode) { - case Ndis802_11IBSS: + switch (ifmode) { + case NL80211_IFTYPE_ADHOC: set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); break; - case Ndis802_11Infrastructure: + case NL80211_IFTYPE_P2P_CLIENT: + case NL80211_IFTYPE_STATION: set_fwstate(pmlmepriv, WIFI_STATION_STATE); break; - case Ndis802_11APMode: - case Ndis802_11AutoUnknown: - case Ndis802_11InfrastructureMax: + default: break; } } @@ -673,7 +672,7 @@ exit: } int rtw_setopmode_cmd23a(struct rtw_adapter *padapter, - enum ndis_802_11_net_infra networktype) + enum nl80211_iftype ifmode) { struct cmd_obj *ph2c; struct setopmode_parm *psetop; @@ -694,7 +693,7 @@ int rtw_setopmode_cmd23a(struct rtw_adapter *padapter, } init_h2fwcmd_w_parm_no_rsp(ph2c, psetop, _SetOpMode_CMD_); - psetop->mode = (u8)networktype; + psetop->mode = ifmode; res = rtw_enqueue_cmd23a(pcmdpriv, ph2c); exit: diff --git a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c index a2dfb93b04eb..d496ae35095a 100644 --- a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c @@ -279,92 +279,6 @@ exit: return status; } -int rtw_set_802_11_infrastructure_mode23a(struct rtw_adapter* padapter, - enum ndis_802_11_net_infra networktype) -{ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wlan_network *cur_network = &pmlmepriv->cur_network; - enum ndis_802_11_net_infra* pold_state; - - pold_state = &cur_network->network.InfrastructureMode; - - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_notice_, - ("+rtw_set_802_11_infrastructure_mode23a: old =%d new =%d " - "fw_state = 0x%08x\n", - *pold_state, networktype, get_fwstate(pmlmepriv))); - - if (*pold_state != networktype) { - spin_lock_bh(&pmlmepriv->lock); - - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, - (" change mode!")); - - if (*pold_state == Ndis802_11APMode) { - /* change to other mode from Ndis802_11APMode */ - cur_network->join_res = -1; - -#ifdef CONFIG_8723AU_AP_MODE - stop_ap_mode23a(padapter); -#endif - } - - if (check_fwstate(pmlmepriv, _FW_LINKED) || - *pold_state == Ndis802_11IBSS) - rtw_disassoc_cmd23a(padapter, 0, true); - - if (check_fwstate(pmlmepriv, _FW_LINKED) || - check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) - rtw_free_assoc_resources23a(padapter, 1); - - if (*pold_state == Ndis802_11Infrastructure || - *pold_state == Ndis802_11IBSS) { - if (check_fwstate(pmlmepriv, _FW_LINKED)) { - /* will clr Linked_state; before this function, - we must have chked whether issue - dis-assoc_cmd or not */ - rtw_indicate_disconnect23a(padapter); - } - } - - *pold_state = networktype; - - _clr_fwstate_(pmlmepriv, ~WIFI_NULL_STATE); - - switch (networktype) - { - case Ndis802_11IBSS: - set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); - break; - - case Ndis802_11Infrastructure: - set_fwstate(pmlmepriv, WIFI_STATION_STATE); - break; - - case Ndis802_11APMode: - set_fwstate(pmlmepriv, WIFI_AP_STATE); -#ifdef CONFIG_8723AU_AP_MODE - start_ap_mode23a(padapter); - /* rtw_indicate_connect23a(padapter); */ -#endif - break; - - case Ndis802_11AutoUnknown: - case Ndis802_11InfrastructureMax: - break; - } - - /* SecClearAllKeys(adapter); */ - - /* RT_TRACE(COMP_OID_SET, DBG_LOUD, - ("set_infrastructure: fw_state:%x after changing mode\n", */ - /* get_fwstate(pmlmepriv))); */ - - spin_unlock_bh(&pmlmepriv->lock); - } - - return _SUCCESS; -} - int rtw_set_802_11_bssid23a_list_scan(struct rtw_adapter *padapter, struct cfg80211_ssid *pssid, int ssid_max_num) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index a7371a874573..b5e548e8fa80 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -52,8 +52,7 @@ int rtw_init_mlme_priv23a(struct rtw_adapter *padapter) pmlmepriv->nic_hdl = padapter; pmlmepriv->fw_state = 0; - pmlmepriv->cur_network.network.InfrastructureMode = - Ndis802_11AutoUnknown; + pmlmepriv->cur_network.network.ifmode = NL80211_IFTYPE_UNSPECIFIED; /* 1: active, 0: pasive. Maybe someday we should rename this varable to "active_mode" (Jeff) */ pmlmepriv->scan_mode = SCAN_ACTIVE; @@ -616,8 +615,8 @@ static int rtw_is_desired_network(struct rtw_adapter *adapter, } if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { - if (pnetwork->network.InfrastructureMode != - pmlmepriv->cur_network.network.InfrastructureMode) + if (pnetwork->network.ifmode != + pmlmepriv->cur_network.network.ifmode) bselected = false; } @@ -1137,14 +1136,15 @@ rtw_joinbss_update_network23a(struct rtw_adapter *padapter, rtw_set_signal_stat_timer(&padapter->recvpriv); /* update fw_state will clr _FW_UNDER_LINKING here indirectly */ - switch (pnetwork->network.InfrastructureMode) { - case Ndis802_11Infrastructure: - if (pmlmepriv->fw_state&WIFI_UNDER_WPS) + switch (pnetwork->network.ifmode) { + case NL80211_IFTYPE_P2P_CLIENT: + case NL80211_IFTYPE_STATION: + if (pmlmepriv->fw_state & WIFI_UNDER_WPS) pmlmepriv->fw_state = WIFI_STATION_STATE|WIFI_UNDER_WPS; else pmlmepriv->fw_state = WIFI_STATION_STATE; break; - case Ndis802_11IBSS: + case NL80211_IFTYPE_ADHOC: pmlmepriv->fw_state = WIFI_ADHOC_STATE; break; default: @@ -2179,11 +2179,10 @@ void rtw_update_registrypriv_dev_network23a(struct rtw_adapter* adapter) "DSConfig = 0x%x\n", pregistrypriv->channel, pdev_network->Configuration.DSConfig)); - if (cur_network->network.InfrastructureMode == Ndis802_11IBSS) + if (cur_network->network.ifmode == NL80211_IFTYPE_ADHOC) pdev_network->Configuration.ATIMWindow = 0; - pdev_network->InfrastructureMode = - cur_network->network.InfrastructureMode; + pdev_network->ifmode = cur_network->network.ifmode; /* 1. Supported rates */ /* 2. IE */ diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 9338cb94167c..aaf4fd0e129e 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -4596,7 +4596,7 @@ int collect_bss_info23a(struct rtw_adapter *padapter, if (ieee80211_is_probe_req(mgmt->frame_control)) { /* FIXME */ - bssid->InfrastructureMode = Ndis802_11Infrastructure; + bssid->ifmode = NL80211_IFTYPE_STATION; ether_addr_copy(bssid->MacAddress, mgmt->sa); bssid->Privacy = 1; return _SUCCESS; @@ -4608,10 +4608,10 @@ int collect_bss_info23a(struct rtw_adapter *padapter, le32_to_cpu(bssid->Configuration.BeaconPeriod); if (capab_info & BIT(0)) { - bssid->InfrastructureMode = Ndis802_11Infrastructure; + bssid->ifmode = NL80211_IFTYPE_STATION; ether_addr_copy(bssid->MacAddress, mgmt->sa); } else { - bssid->InfrastructureMode = Ndis802_11IBSS; + bssid->ifmode = NL80211_IFTYPE_ADHOC; ether_addr_copy(bssid->MacAddress, mgmt->bssid); } @@ -5814,22 +5814,32 @@ int NULL_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) int setopmode_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { - u8 type; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + enum nl80211_iftype type; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; const struct setopmode_parm *psetop = (struct setopmode_parm *)pbuf; - if (psetop->mode == Ndis802_11APMode) { + switch (psetop->mode) { + case NL80211_IFTYPE_P2P_GO: + case NL80211_IFTYPE_AP: pmlmeinfo->state = WIFI_FW_AP_STATE; type = _HW_STATE_AP_; - } else if (psetop->mode == Ndis802_11Infrastructure) { - pmlmeinfo->state &= ~(BIT(0)|BIT(1));/* clear state */ - pmlmeinfo->state |= WIFI_FW_STATION_STATE;/* set to STATION_STATE */ + break; + case NL80211_IFTYPE_P2P_CLIENT: + case NL80211_IFTYPE_STATION: + /* clear state */ + pmlmeinfo->state &= ~(BIT(0)|BIT(1)); + /* set to STATION_STATE */ + pmlmeinfo->state |= WIFI_FW_STATION_STATE; type = _HW_STATE_STATION_; - } else if (psetop->mode == Ndis802_11IBSS) + break; + case NL80211_IFTYPE_ADHOC: type = _HW_STATE_ADHOC_; - else + break; + default: type = _HW_STATE_NOLINK_; + break; + } hw_var_set_opmode(padapter, type); /* Set_NETYPE0_MSR(padapter, type); */ @@ -5845,11 +5855,10 @@ int createbss_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) const struct wlan_bssid_ex *pparm = (struct wlan_bssid_ex *)pbuf; /* u32 initialgain; */ - if (pparm->InfrastructureMode == Ndis802_11APMode) { + if (pparm->ifmode == NL80211_IFTYPE_AP || + pparm->ifmode == NL80211_IFTYPE_P2P_GO) { #ifdef CONFIG_8723AU_AP_MODE - - if (pmlmeinfo->state == WIFI_FW_AP_STATE) - { + if (pmlmeinfo->state == WIFI_FW_AP_STATE) { /* todo: */ return H2C_SUCCESS; } @@ -5857,7 +5866,7 @@ int createbss_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) } /* below is for ad-hoc master */ - if (pparm->InfrastructureMode == Ndis802_11IBSS) { + if (pparm->ifmode == NL80211_IFTYPE_ADHOC) { rtw_joinbss_reset23a(padapter); pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20; diff --git a/drivers/staging/rtl8723au/core/rtw_sreset.c b/drivers/staging/rtl8723au/core/rtw_sreset.c index 5e6d5fc9166b..7e698c524431 100644 --- a/drivers/staging/rtl8723au/core/rtw_sreset.c +++ b/drivers/staging/rtl8723au/core/rtw_sreset.c @@ -126,7 +126,7 @@ static void sreset_restore_network_station(struct rtw_adapter *padapter) struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u8 threshold; - rtw_setopmode_cmd23a(padapter, Ndis802_11Infrastructure); + rtw_setopmode_cmd23a(padapter, NL80211_IFTYPE_STATION); /* TH = 1 => means that invalidate usb rx aggregation */ /* TH = 0 => means that validate usb rx aggregation, use init value. */ diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c index ea344214357d..54ef5dc30b78 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c @@ -354,8 +354,9 @@ static void ConstructNullFunctionData( if (bForcePowerSave) SetPwrMgt(fctrl); - switch (cur_network->network.InfrastructureMode) { - case Ndis802_11Infrastructure: + switch (cur_network->network.ifmode) { + case NL80211_IFTYPE_P2P_CLIENT: + case NL80211_IFTYPE_STATION: SetToDs(fctrl); memcpy(pwlanhdr->addr1, get_my_bssid23a(&pmlmeinfo->network), ETH_ALEN); @@ -363,7 +364,8 @@ static void ConstructNullFunctionData( ETH_ALEN); memcpy(pwlanhdr->addr3, StaAddr, ETH_ALEN); break; - case Ndis802_11APMode: + case NL80211_IFTYPE_P2P_GO: + case NL80211_IFTYPE_AP: SetFrDs(fctrl); memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN); memcpy(pwlanhdr->addr2, @@ -371,7 +373,7 @@ static void ConstructNullFunctionData( memcpy(pwlanhdr->addr3, myid(&padapter->eeprompriv), ETH_ALEN); break; - case Ndis802_11IBSS: + case NL80211_IFTYPE_ADHOC: default: memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN); memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); diff --git a/drivers/staging/rtl8723au/include/rtw_cmd.h b/drivers/staging/rtl8723au/include/rtw_cmd.h index 427596e123d9..50f810629144 100644 --- a/drivers/staging/rtl8723au/include/rtw_cmd.h +++ b/drivers/staging/rtl8723au/include/rtw_cmd.h @@ -170,8 +170,7 @@ struct disconnect_parm { }; struct setopmode_parm { - u8 mode; - u8 rsvd[3]; + enum nl80211_iftype mode; }; /* @@ -689,7 +688,7 @@ int rtw_setstakey_cmd23a(struct rtw_adapter *padapter, u8 *psta, u8 unicast_key int rtw_clearstakey_cmd23a(struct rtw_adapter *padapter, u8 *psta, u8 entry, u8 enqueue); int rtw_joinbss_cmd23a(struct rtw_adapter *padapter, struct wlan_network* pnetwork); int rtw_disassoc_cmd23a(struct rtw_adapter *padapter, u32 deauth_timeout_ms, bool enqueue); -int rtw_setopmode_cmd23a(struct rtw_adapter *padapter, enum ndis_802_11_net_infra networktype); +int rtw_setopmode_cmd23a(struct rtw_adapter *padapter, enum nl80211_iftype ifmode); int rtw_setdatarate_cmd(struct rtw_adapter *padapter, u8 *rateset); int rtw_setbasicrate_cmd(struct rtw_adapter *padapter, u8 *rateset); int rtw_setbbreg_cmd(struct rtw_adapter * padapter, u8 offset, u8 val); diff --git a/drivers/staging/rtl8723au/include/rtw_ioctl_set.h b/drivers/staging/rtl8723au/include/rtw_ioctl_set.h index 13f7fcb2a73a..637f33b0c2dc 100644 --- a/drivers/staging/rtl8723au/include/rtw_ioctl_set.h +++ b/drivers/staging/rtl8723au/include/rtw_ioctl_set.h @@ -24,8 +24,6 @@ int rtw_set_802_11_add_wep23a(struct rtw_adapter * padapter, int rtw_set_802_11_bssid23a_list_scan(struct rtw_adapter *padapter, struct cfg80211_ssid *pssid, int ssid_max_num); -int rtw_set_802_11_infrastructure_mode23a(struct rtw_adapter *padapter, - enum ndis_802_11_net_infra networktype); int rtw_set_802_11_ssid23a(struct rtw_adapter * padapter, struct cfg80211_ssid * ssid); diff --git a/drivers/staging/rtl8723au/include/wlan_bssdef.h b/drivers/staging/rtl8723au/include/wlan_bssdef.h index 92287ebe5b9b..0799d800c699 100644 --- a/drivers/staging/rtl8723au/include/wlan_bssdef.h +++ b/drivers/staging/rtl8723au/include/wlan_bssdef.h @@ -50,14 +50,6 @@ struct ndis_802_11_config { struct ndis_802_11_configuration_fh FHConfig; }; -enum ndis_802_11_net_infra { - Ndis802_11IBSS, - Ndis802_11Infrastructure, - Ndis802_11AutoUnknown, - Ndis802_11InfrastructureMax, /* Not a real value, defined as upper bound */ - Ndis802_11APMode -}; - struct ndis_802_11_fixed_ies { u8 Timestamp[8]; u16 BeaconInterval; @@ -139,10 +131,6 @@ enum NDIS_802_11_STATUS_TYPE { /* MIC check time, 60 seconds. */ #define MIC_CHECK_TIME 60000000 -#ifndef Ndis802_11APMode -#define Ndis802_11APMode (Ndis802_11InfrastructureMax+1) -#endif - struct wlan_phy_info { u8 SignalStrength;/* in percentage) */ u8 SignalQuality;/* in percentage) */ @@ -172,7 +160,7 @@ struct wlan_bssid_ex { long Rssi;/* in dBM, raw data , get from PHY) */ enum ndis_802_11_net_type NetworkTypeInUse; struct ndis_802_11_config Configuration; - enum ndis_802_11_net_infra InfrastructureMode; + enum nl80211_iftype ifmode; unsigned char SupportedRates[NDIS_802_11_LENGTH_RATES_EX]; struct wlan_phy_info PhyInfo; u32 IELength; diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 182f57c2d86b..aac1d418d9dd 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -1291,18 +1291,103 @@ exit: return ret; } +int cfg80211_infrastructure_mode(struct rtw_adapter* padapter, + enum nl80211_iftype ifmode) +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct wlan_network *cur_network = &pmlmepriv->cur_network; + enum nl80211_iftype old_mode; + + old_mode = cur_network->network.ifmode; + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_notice_, + ("+%s: old =%d new =%d fw_state = 0x%08x\n", __func__, + old_mode, ifmode, get_fwstate(pmlmepriv))); + + if (old_mode != ifmode) { + spin_lock_bh(&pmlmepriv->lock); + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, + (" change mode!")); + + if (old_mode == NL80211_IFTYPE_AP || + old_mode == NL80211_IFTYPE_P2P_GO) { + /* change to other mode from Ndis802_11APMode */ + cur_network->join_res = -1; + +#ifdef CONFIG_8723AU_AP_MODE + stop_ap_mode23a(padapter); +#endif + } + + if (check_fwstate(pmlmepriv, _FW_LINKED) || + old_mode == NL80211_IFTYPE_ADHOC) + rtw_disassoc_cmd23a(padapter, 0, true); + + if (check_fwstate(pmlmepriv, _FW_LINKED) || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) + rtw_free_assoc_resources23a(padapter, 1); + + if (old_mode == NL80211_IFTYPE_STATION || + old_mode == NL80211_IFTYPE_P2P_CLIENT || + old_mode == NL80211_IFTYPE_ADHOC) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + /* will clr Linked_state; before this function, + we must have chked whether issue + dis-assoc_cmd or not */ + rtw_indicate_disconnect23a(padapter); + } + } + + cur_network->network.ifmode = ifmode; + + _clr_fwstate_(pmlmepriv, ~WIFI_NULL_STATE); + + switch (ifmode) { + case NL80211_IFTYPE_ADHOC: + set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); + break; + + case NL80211_IFTYPE_P2P_CLIENT: + case NL80211_IFTYPE_STATION: + set_fwstate(pmlmepriv, WIFI_STATION_STATE); + break; + + case NL80211_IFTYPE_P2P_GO: + case NL80211_IFTYPE_AP: + set_fwstate(pmlmepriv, WIFI_AP_STATE); +#ifdef CONFIG_8723AU_AP_MODE + start_ap_mode23a(padapter); + /* rtw_indicate_connect23a(padapter); */ +#endif + break; + + default: + break; + } + + /* SecClearAllKeys(adapter); */ + + /* RT_TRACE(COMP_OID_SET, DBG_LOUD, + ("set_infrastructure: fw_state:%x after changing mode\n", */ + /* get_fwstate(pmlmepriv))); */ + + spin_unlock_bh(&pmlmepriv->lock); + } + + return _SUCCESS; +} + static int cfg80211_rtw_change_iface(struct wiphy *wiphy, struct net_device *ndev, enum nl80211_iftype type, u32 *flags, struct vif_params *params) { enum nl80211_iftype old_type; - enum ndis_802_11_net_infra networkType; struct rtw_adapter *padapter = wiphy_to_adapter(wiphy); struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct wireless_dev *rtw_wdev = wiphy_to_wdev(wiphy); int ret = 0; - u8 change = false; DBG_8723A("%s(%s): call netdev_open23a\n", __func__, ndev->name); if (netdev_open23a(ndev) != 0) { @@ -1320,22 +1405,17 @@ static int cfg80211_rtw_change_iface(struct wiphy *wiphy, __func__, ndev->name, old_type, type); if (old_type != type) { - change = true; pmlmeext->action_public_rxseq = 0xffff; pmlmeext->action_public_dialog_token = 0xff; } switch (type) { case NL80211_IFTYPE_ADHOC: - networkType = Ndis802_11IBSS; - break; case NL80211_IFTYPE_P2P_CLIENT: case NL80211_IFTYPE_STATION: - networkType = Ndis802_11Infrastructure; - break; case NL80211_IFTYPE_P2P_GO: case NL80211_IFTYPE_AP: - networkType = Ndis802_11APMode; + case NL80211_IFTYPE_UNSPECIFIED: break; default: return -EOPNOTSUPP; @@ -1343,14 +1423,13 @@ static int cfg80211_rtw_change_iface(struct wiphy *wiphy, rtw_wdev->iftype = type; - if (rtw_set_802_11_infrastructure_mode23a - (padapter, networkType) != _SUCCESS) { + if (cfg80211_infrastructure_mode(padapter, type) != _SUCCESS) { rtw_wdev->iftype = old_type; ret = -EPERM; goto exit; } - rtw_setopmode_cmd23a(padapter, networkType); + rtw_setopmode_cmd23a(padapter, type); exit: return ret; @@ -1982,8 +2061,8 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, goto exit; } - if (rtw_set_802_11_infrastructure_mode23a - (padapter, pnetwork->network.InfrastructureMode) != _SUCCESS) { + if (cfg80211_infrastructure_mode( + padapter, pnetwork->network.ifmode) != _SUCCESS) { ret = -EPERM; goto exit; } -- cgit v1.2.3 From 409b47c4b1ccfb96c0a55c83fd7199bf365a850f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:27 +0200 Subject: staging: rtl8723au: Get rid of write only NetworkTypeInUse and matching enum Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 18 ----------------- drivers/staging/rtl8723au/core/rtw_mlme.c | 27 ------------------------- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 2 -- drivers/staging/rtl8723au/include/wlan_bssdef.h | 9 --------- 4 files changed, 56 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 5847fc5f6f36..f71e55a647fb 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -1008,24 +1008,6 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, if (p && ie_len > 0) pHT_info_ie = p; - switch (network_type) { - case WIRELESS_11B: - pbss_network->NetworkTypeInUse = Ndis802_11DS; - break; - case WIRELESS_11G: - case WIRELESS_11BG: - case WIRELESS_11G_24N: - case WIRELESS_11BG_24N: - pbss_network->NetworkTypeInUse = Ndis802_11OFDM24; - break; - case WIRELESS_11A: - pbss_network->NetworkTypeInUse = Ndis802_11OFDM5; - break; - default : - pbss_network->NetworkTypeInUse = Ndis802_11OFDM24; - break; - } - pmlmepriv->cur_network.network_type = network_type; pmlmepriv->htpriv.ht_option = false; diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index b5e548e8fa80..b912d09d6550 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -2146,33 +2146,6 @@ void rtw_update_registrypriv_dev_network23a(struct rtw_adapter* adapter) pdev_network->Rssi = 0; - switch (pregistrypriv->wireless_mode) - { - case WIRELESS_11B: - pdev_network->NetworkTypeInUse = Ndis802_11DS; - break; - case WIRELESS_11G: - case WIRELESS_11BG: - case WIRELESS_11_24N: - case WIRELESS_11G_24N: - case WIRELESS_11BG_24N: - pdev_network->NetworkTypeInUse = Ndis802_11OFDM24; - break; - case WIRELESS_11A: - case WIRELESS_11A_5N: - pdev_network->NetworkTypeInUse = Ndis802_11OFDM5; - break; - case WIRELESS_11ABGN: - if (pregistrypriv->channel > 14) - pdev_network->NetworkTypeInUse = Ndis802_11OFDM5; - else - pdev_network->NetworkTypeInUse = Ndis802_11OFDM24; - break; - default : - /* TODO */ - break; - } - pdev_network->Configuration.DSConfig = pregistrypriv->channel; RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("pregistrypriv->channel =%d, pdev_network->Configuration." diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index aaf4fd0e129e..0bfc91fe034f 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -4564,8 +4564,6 @@ int collect_bss_info23a(struct rtw_adapter *padapter, memcpy(bssid->SupportedRates + i, p + 2, p[1]); } - bssid->NetworkTypeInUse = Ndis802_11OFDM24; - if (bssid->IELength < 12) return _FAIL; diff --git a/drivers/staging/rtl8723au/include/wlan_bssdef.h b/drivers/staging/rtl8723au/include/wlan_bssdef.h index 0799d800c699..e6b225c7d5d5 100644 --- a/drivers/staging/rtl8723au/include/wlan_bssdef.h +++ b/drivers/staging/rtl8723au/include/wlan_bssdef.h @@ -22,14 +22,6 @@ #define NDIS_802_11_LENGTH_RATES 8 #define NDIS_802_11_LENGTH_RATES_EX 16 -enum ndis_802_11_net_type { - Ndis802_11FH, - Ndis802_11DS, - Ndis802_11OFDM5, - Ndis802_11OFDM24, - Ndis802_11NetworkTypeMax /* just an upper bound */ -}; - struct ndis_802_11_configuration_fh { u32 Length; /* Length of structure */ u32 HopPattern; /* As defined by 802.11, MSB set */ @@ -158,7 +150,6 @@ struct wlan_bssid_ex { struct cfg80211_ssid Ssid; u32 Privacy; long Rssi;/* in dBM, raw data , get from PHY) */ - enum ndis_802_11_net_type NetworkTypeInUse; struct ndis_802_11_config Configuration; enum nl80211_iftype ifmode; unsigned char SupportedRates[NDIS_802_11_LENGTH_RATES_EX]; -- cgit v1.2.3 From 3e3a1adf133f2a85f1397cbde85a51487332e16a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:28 +0200 Subject: staging: rtl8723au: HalEEValueCheck(): content of a u8 is always >= 0 Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index e2d426ae0671..0afc74253fe4 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1720,9 +1720,9 @@ static void Hal_EEValueCheck(u8 EEType, void *pInValue, void *pOutValue) u8 *pIn, *pOut; pIn = (u8 *) pInValue; pOut = (u8 *) pOutValue; - if (*pIn >= 0 && *pIn <= 63) { + if (*pIn <= 63) *pOut = *pIn; - } else { + else { RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("EETYPE_TX_PWR, value =%d is invalid, set " "to default = 0x%x\n", -- cgit v1.2.3 From 9216c517fb0192d1828169d8af2bac59ee8e3173 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:29 +0200 Subject: staging: rtl8723au: Fix up some random bit-flag handling Randomly mixing true/false/_FAIL/0/1 is a recipe for disaster Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 2 +- drivers/staging/rtl8723au/core/rtw_mlme.c | 5 ++--- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 2 +- drivers/staging/rtl8723au/core/rtw_recv.c | 12 ++++++------ drivers/staging/rtl8723au/core/rtw_security.c | 4 ++-- drivers/staging/rtl8723au/core/rtw_xmit.c | 6 +++--- drivers/staging/rtl8723au/include/rtw_security.h | 9 ++++----- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 14 +++++++------- drivers/staging/rtl8723au/os_dep/os_intfs.c | 2 +- 9 files changed, 27 insertions(+), 29 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index b28afb1b8380..5abe936e479e 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -755,7 +755,7 @@ int rtw_setstakey_cmd23a(struct rtw_adapter *padapter, u8 *psta, u8 unicast_key) } /* jeff: set this becasue at least sw key is ready */ - padapter->securitypriv.busetkipkey = true; + padapter->securitypriv.busetkipkey = 1; res = rtw_enqueue_cmd23a(pcmdpriv, ph2c); diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index b912d09d6550..8c6b0947ee92 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -1027,9 +1027,8 @@ rtw_joinbss_update_stainfo(struct rtw_adapter *padapter, /* security related */ if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { - padapter->securitypriv.binstallGrpkey = false; - padapter->securitypriv.busetkipkey = false; - padapter->securitypriv.bgrpkey_handshake = false; + padapter->securitypriv.binstallGrpkey = 0; + padapter->securitypriv.busetkipkey = 0; psta->ieee8021x_blocked = true; psta->dot118021XPrivacy = diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index 96337a87b1d8..707b5ccd951b 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -306,7 +306,7 @@ static u8 PS_RDY_CHECK(struct rtw_adapter * padapter) if (pwrpriv->bInSuspend) return false; if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X && - padapter->securitypriv.binstallGrpkey == false) { + !padapter->securitypriv.binstallGrpkey) { DBG_8723A("Group handshake still in progress !!!\n"); return false; } diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index eda495a1d5d8..84e6a1875cf4 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -313,7 +313,7 @@ int recvframe_chkmic(struct rtw_adapter *adapter, RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic: bcmc key\n")); - if (psecuritypriv->binstallGrpkey == false) { + if (!psecuritypriv->binstallGrpkey) { res = _FAIL; RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, @@ -442,9 +442,9 @@ int recvframe_chkmic(struct rtw_adapter *adapter, res = _FAIL; } else { /* mic checked ok */ - if ((psecuritypriv->bcheck_grpkey == false) && - (is_multicast_ether_addr(prxattrib->ra))) { - psecuritypriv->bcheck_grpkey = true; + if (!psecuritypriv->bcheck_grpkey && + is_multicast_ether_addr(prxattrib->ra)) { + psecuritypriv->bcheck_grpkey = 1; RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("psecuritypriv->bcheck_grp" @@ -507,7 +507,7 @@ struct recv_frame *decryptor(struct rtw_adapter *padapter, } if ((prxattrib->encrypt > 0) && ((prxattrib->bdecrypted == 0))) { - psecuritypriv->hw_decrypted = false; + psecuritypriv->hw_decrypted = 0; switch (prxattrib->encrypt) { case _WEP40_: case _WEP104_: @@ -525,7 +525,7 @@ struct recv_frame *decryptor(struct rtw_adapter *padapter, } else if (prxattrib->bdecrypted == 1 && prxattrib->encrypt > 0 && (psecuritypriv->busetkipkey == 1 || prxattrib->encrypt != _TKIP_)) { - psecuritypriv->hw_decrypted = true; + psecuritypriv->hw_decrypted = 1; } if (res == _FAIL) { diff --git a/drivers/staging/rtl8723au/core/rtw_security.c b/drivers/staging/rtl8723au/core/rtw_security.c index 77709fea856c..96347e73b4f6 100644 --- a/drivers/staging/rtl8723au/core/rtw_security.c +++ b/drivers/staging/rtl8723au/core/rtw_security.c @@ -744,7 +744,7 @@ int rtw_tkip_decrypt23a(struct rtw_adapter *padapter, if (stainfo!= NULL) { if (is_multicast_ether_addr(prxattrib->ra)) { - if (psecuritypriv->binstallGrpkey == false) { + if (psecuritypriv->binstallGrpkey == 0) { res = _FAIL; DBG_8723A("%s:rx bc/mc packets, but didn't install group key!!!!!!!!!!\n", __func__); goto exit; @@ -1645,7 +1645,7 @@ void rtw_use_tkipkey_handler23a(void *FunctionContext) struct rtw_adapter *padapter = (struct rtw_adapter *)FunctionContext; RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("^^^rtw_use_tkipkey_handler23a ^^^\n")); - padapter->securitypriv.busetkipkey = true; + padapter->securitypriv.busetkipkey = 1; RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("^^^rtw_use_tkipkey_handler23a padapter->securitypriv.busetkipkey =%d^^^\n", padapter->securitypriv.busetkipkey)); diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 65e7de8de916..eeaaa8fc7a4c 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -604,10 +604,10 @@ static int update_attrib(struct rtw_adapter *padapter, pattrib->iv_len = 8; pattrib->icv_len = 4; - if (padapter->securitypriv.busetkipkey == _FAIL) { + if (!padapter->securitypriv.busetkipkey) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("\npadapter->securitypriv.busetkip" - "key(%d) == _FAIL drop packet\n", + "key(%d) == false drop packet\n", padapter->securitypriv.busetkipkey)); res = _FAIL; goto exit; @@ -630,7 +630,7 @@ static int update_attrib(struct rtw_adapter *padapter, RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("update_attrib: encrypt =%d\n", pattrib->encrypt)); - if (pattrib->encrypt && psecuritypriv->hw_decrypted == false) { + if (pattrib->encrypt && !psecuritypriv->hw_decrypted) { pattrib->bswenc = true; RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("update_attrib: encrypt =%d bswenc = true\n", diff --git a/drivers/staging/rtl8723au/include/rtw_security.h b/drivers/staging/rtl8723au/include/rtw_security.h index e9e850616359..d117a2053396 100644 --- a/drivers/staging/rtl8723au/include/rtw_security.h +++ b/drivers/staging/rtl8723au/include/rtw_security.h @@ -139,11 +139,10 @@ struct security_priv { u8 wps_ie[MAX_WPS_IE_LEN];/* added in assoc req */ int wps_ie_len; - u8 binstallGrpkey; - u8 busetkipkey; - u8 bcheck_grpkey; - u8 bgrpkey_handshake; - s32 hw_decrypted; + unsigned int binstallGrpkey:1; + unsigned int busetkipkey:1; + unsigned int bcheck_grpkey:1; + unsigned int hw_decrypted:1; u32 ndisauthtype; /* enum ndis_802_11_auth_mode */ u32 ndisencryptstatus; /* NDIS_802_11_ENCRYPTION_STATUS */ struct wlan_bssid_ex sec_bss; /* for joinbss (h2c buffer) usage */ diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index aac1d418d9dd..35ed47a79d27 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -689,7 +689,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, idx].skey, ¶m->u.crypt.key[24], 8); - psecuritypriv->busetkipkey = true; + psecuritypriv->busetkipkey = 1; } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) { DBG_8723A("%s, set group_key, CCMP\n", @@ -712,7 +712,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, psecuritypriv->dot118021XGrpKeyid = param->u.crypt.idx; - psecuritypriv->binstallGrpkey = true; + psecuritypriv->binstallGrpkey = 1; psecuritypriv->dot11PrivacyAlgrthm = psecuritypriv->dot118021XGrpPrivacy; @@ -767,7 +767,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, memcpy(psta->dot11tkiprxmickey.skey, ¶m->u.crypt.key[24], 8); - psecuritypriv->busetkipkey = true; + psecuritypriv->busetkipkey = 1; } else if (!strcmp(param->u.crypt.alg, "CCMP")) { @@ -831,7 +831,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, skey, ¶m->u.crypt.key[24], 8); - psecuritypriv->busetkipkey = true; + psecuritypriv->busetkipkey = 1; } else if (!strcmp(param->u.crypt.alg, "CCMP")) { psecuritypriv->dot118021XGrpPrivacy = @@ -852,7 +852,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, psecuritypriv->dot118021XGrpKeyid = param->u.crypt.idx; - psecuritypriv->binstallGrpkey = true; + psecuritypriv->binstallGrpkey = 1; psecuritypriv->dot11PrivacyAlgrthm = psecuritypriv->dot118021XGrpPrivacy; @@ -1003,7 +1003,7 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, 8); padapter->securitypriv. - busetkipkey = false; + busetkipkey = 0; } DBG_8723A(" ~~~~set sta key:unicastkey\n"); @@ -1029,7 +1029,7 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, skey, ¶m->u.crypt.key[24], 8); padapter->securitypriv.binstallGrpkey = - true; + 1; /* DEBUG_ERR((" param->u.crypt.key_len" "=%d\n", param->u.crypt.key_len)); */ DBG_8723A diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index 5be8dd9e1fea..d6d0e9a1c936 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -401,7 +401,7 @@ static int rtw_init_default_value(struct rtw_adapter *padapter) pmlmepriv->htpriv.ampdu_enable = false;/* set to disabled */ /* security_priv */ - psecuritypriv->binstallGrpkey = _FAIL; + psecuritypriv->binstallGrpkey = 0; /* open system */ psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; -- cgit v1.2.3 From af97d6cd7bbf604c87601aedbf8ce5dc0088a2d7 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:30 +0200 Subject: staging: rtl8723au: Add -Wtype-limits to CFLAGS Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/Makefile b/drivers/staging/rtl8723au/Makefile index f85f4b38bccf..f0615d666d91 100644 --- a/drivers/staging/rtl8723au/Makefile +++ b/drivers/staging/rtl8723au/Makefile @@ -53,4 +53,4 @@ r8723au-$(CONFIG_8723AU_BT_COEXIST) += hal/rtl8723a_bt-coexist.o obj-$(CONFIG_R8723AU) := r8723au.o -ccflags-y += -D__CHECK_ENDIAN__ -I$(src)/include +ccflags-y += -Wtype-limits -D__CHECK_ENDIAN__ -I$(src)/include -- cgit v1.2.3 From 7989bcf3e21683f413dd1488718166d3ff474bf3 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:31 +0200 Subject: staging: rtl8723au: Store algorithm type in a u32 This will allow us to switch to using WLAN_CIPHER_SUITE_* later Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtw_cmd.h | 4 ++-- drivers/staging/rtl8723au/include/rtw_security.h | 6 +++--- drivers/staging/rtl8723au/include/sta_info.h | 2 +- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723au/include/rtw_cmd.h b/drivers/staging/rtl8723au/include/rtw_cmd.h index 50f810629144..383cd39bd4fe 100644 --- a/drivers/staging/rtl8723au/include/rtw_cmd.h +++ b/drivers/staging/rtl8723au/include/rtw_cmd.h @@ -219,7 +219,7 @@ when 802.1x ==> keyid > 2 ==> unicast key */ struct setkey_parm { - u8 algorithm; /* encryption algorithm, could be none, wep40, TKIP, CCMP, wep104 */ + u32 algorithm; /* encryption algorithm, could be none, wep40, TKIP, CCMP, wep104 */ u8 keyid; u8 grpkey; /* 1: this is the grpkey for 802.1x. 0: this is the unicast key for 802.1x */ u8 set_tx; /* 1: main tx key for wep. 0: other key. */ @@ -237,8 +237,8 @@ when shared key ==> algorithm/keyid */ struct set_stakey_parm { u8 addr[ETH_ALEN]; - u8 algorithm; u8 id;/* currently for erasing cam entry if algorithm == _NO_PRIVACY_ */ + u32 algorithm; u8 key[16]; }; diff --git a/drivers/staging/rtl8723au/include/rtw_security.h b/drivers/staging/rtl8723au/include/rtw_security.h index d117a2053396..7a707bcc5998 100644 --- a/drivers/staging/rtl8723au/include/rtw_security.h +++ b/drivers/staging/rtl8723au/include/rtw_security.h @@ -177,13 +177,13 @@ do {\ case dot11AuthAlgrthm_Open:\ case dot11AuthAlgrthm_Shared:\ case dot11AuthAlgrthm_Auto:\ - encry_algo = (u8)psecuritypriv->dot11PrivacyAlgrthm;\ + encry_algo = psecuritypriv->dot11PrivacyAlgrthm;\ break;\ case dot11AuthAlgrthm_8021X:\ if (bmcst)\ - encry_algo = (u8)psecuritypriv->dot118021XGrpPrivacy;\ + encry_algo = psecuritypriv->dot118021XGrpPrivacy;\ else\ - encry_algo = (u8)psta->dot118021XPrivacy;\ + encry_algo = psta->dot118021XPrivacy;\ break;\ } \ } while (0) diff --git a/drivers/staging/rtl8723au/include/sta_info.h b/drivers/staging/rtl8723au/include/sta_info.h index 747e7db2113e..1282c831d483 100644 --- a/drivers/staging/rtl8723au/include/sta_info.h +++ b/drivers/staging/rtl8723au/include/sta_info.h @@ -97,7 +97,7 @@ struct sta_info { u8 hwaddr[ETH_ALEN]; uint ieee8021x_blocked; /* 0: allowed, 1:blocked */ - uint dot118021XPrivacy; /* aes, tkip... */ + u32 dot118021XPrivacy; /* aes, tkip... */ union Keytype dot11tkiptxmickey; union Keytype dot11tkiprxmickey; union Keytype dot118021x_UncstKey; diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 35ed47a79d27..62e8c824406a 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -457,7 +457,7 @@ static int set_pairwise_key(struct rtw_adapter *padapter, struct sta_info *psta) init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_); - psetstakey_para->algorithm = (u8) psta->dot118021XPrivacy; + psetstakey_para->algorithm = psta->dot118021XPrivacy; memcpy(psetstakey_para->addr, psta->hwaddr, ETH_ALEN); @@ -469,7 +469,7 @@ exit: return res; } -static int set_group_key(struct rtw_adapter *padapter, u8 *key, u8 alg, +static int set_group_key(struct rtw_adapter *padapter, u8 *key, u32 alg, u8 keyid) { u8 keylen; -- cgit v1.2.3 From 1de36ec31680acd2cd06c3c5204e2ed1dee8f59b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:32 +0200 Subject: staging: rtl8723au: We don't support SMS4 or WEP+WPA mixed encryption Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_recv.c | 4 ---- drivers/staging/rtl8723au/include/odm.h | 2 -- drivers/staging/rtl8723au/include/rtw_security.h | 2 -- 3 files changed, 8 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 84e6a1875cf4..a2dc5d8187f9 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -1421,10 +1421,6 @@ static int validate_recv_data_frame(struct rtw_adapter *adapter, pattrib->iv_len = 8; pattrib->icv_len = 8; break; - case _SMS4_: - pattrib->iv_len = 18; - pattrib->icv_len = 16; - break; default: pattrib->iv_len = 0; pattrib->icv_len = 0; diff --git a/drivers/staging/rtl8723au/include/odm.h b/drivers/staging/rtl8723au/include/odm.h index c851eda14a74..5ad0a1408225 100644 --- a/drivers/staging/rtl8723au/include/odm.h +++ b/drivers/staging/rtl8723au/include/odm.h @@ -524,8 +524,6 @@ enum odm_security { ODM_SEC_RESERVE = 3, ODM_SEC_AESCCMP = 4, ODM_SEC_WEP104 = 5, - ODM_WEP_WPA_MIXED = 6, /* WEP + WPA */ - ODM_SEC_SMS4 = 7, }; /* ODM_CMNINFO_BW */ diff --git a/drivers/staging/rtl8723au/include/rtw_security.h b/drivers/staging/rtl8723au/include/rtw_security.h index 7a707bcc5998..1a7fed8e25b7 100644 --- a/drivers/staging/rtl8723au/include/rtw_security.h +++ b/drivers/staging/rtl8723au/include/rtw_security.h @@ -25,8 +25,6 @@ #define _TKIP_WTMIC_ 0x3 #define _AES_ 0x4 #define _WEP104_ 0x5 -#define _WEP_WPA_MIXED_ 0x07 /* WEP + WPA */ -#define _SMS4_ 0x06 #define is_wep_enc(alg) (((alg) == _WEP40_) || ((alg) == _WEP104_)) -- cgit v1.2.3 From 07a4b1b1bcd36ee981cfbbd910062e3593864b18 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:33 +0200 Subject: staging: rtl8723au: Remove unused enum odm_security Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/odm.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/rtl8723au/include/odm.h b/drivers/staging/rtl8723au/include/odm.h index 5ad0a1408225..183d8ff1ab9b 100644 --- a/drivers/staging/rtl8723au/include/odm.h +++ b/drivers/staging/rtl8723au/include/odm.h @@ -516,16 +516,6 @@ enum odm_sec_chnl_offset { ODM_ABOVE = 2 }; -/* ODM_CMNINFO_SEC_MODE */ -enum odm_security { - ODM_SEC_OPEN = 0, - ODM_SEC_WEP40 = 1, - ODM_SEC_TKIP = 2, - ODM_SEC_RESERVE = 3, - ODM_SEC_AESCCMP = 4, - ODM_SEC_WEP104 = 5, -}; - /* ODM_CMNINFO_BW */ enum odm_band_width { ODM_BW20M = 0, -- cgit v1.2.3 From 9e3d6df2df8dbc4c2c5fb733dc494dfc82e0e2ae Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:34 +0200 Subject: staging: rtl8723au: Use WLAN_CIPHER_SUITE_* to mark crypto type Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 29 +++-- drivers/staging/rtl8723au/core/rtw_cmd.c | 9 +- drivers/staging/rtl8723au/core/rtw_ioctl_set.c | 6 +- drivers/staging/rtl8723au/core/rtw_mlme.c | 15 +-- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 15 ++- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 6 +- drivers/staging/rtl8723au/core/rtw_recv.c | 30 +++--- drivers/staging/rtl8723au/core/rtw_security.c | 20 ++-- drivers/staging/rtl8723au/core/rtw_sreset.c | 6 +- drivers/staging/rtl8723au/core/rtw_xmit.c | 38 +++---- drivers/staging/rtl8723au/hal/hal_com.c | 11 +- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 11 +- drivers/staging/rtl8723au/hal/rtl8723au_xmit.c | 11 +- drivers/staging/rtl8723au/include/rtw_recv.h | 2 +- drivers/staging/rtl8723au/include/rtw_security.h | 10 +- drivers/staging/rtl8723au/include/rtw_xmit.h | 2 +- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 122 +++++++++++----------- drivers/staging/rtl8723au/os_dep/mlme_linux.c | 4 +- drivers/staging/rtl8723au/os_dep/os_intfs.c | 4 +- 19 files changed, 177 insertions(+), 174 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index f71e55a647fb..ad9198367ccc 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -679,7 +679,10 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) if (pmlmepriv->cur_network.join_res != true) { /* setting only at first time */ /* WEP Key will be set before this function, do not clear CAM. */ - if ((psecuritypriv->dot11PrivacyAlgrthm != _WEP40_) && (psecuritypriv->dot11PrivacyAlgrthm != _WEP104_)) + if (psecuritypriv->dot11PrivacyAlgrthm != + WLAN_CIPHER_SUITE_WEP40 && + psecuritypriv->dot11PrivacyAlgrthm != + WLAN_CIPHER_SUITE_WEP104) flush_all_cam_entry23a(padapter); /* clear CAM */ } @@ -897,8 +900,8 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, /* wpa2 */ group_cipher = 0; pairwise_cipher = 0; - psecuritypriv->wpa2_group_cipher = _NO_PRIVACY_; - psecuritypriv->wpa2_pairwise_cipher = _NO_PRIVACY_; + psecuritypriv->wpa2_group_cipher = 0; + psecuritypriv->wpa2_pairwise_cipher = 0; p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_RSN, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); if (p && ie_len > 0) { @@ -918,8 +921,8 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, ie_len = 0; group_cipher = 0; pairwise_cipher = 0; - psecuritypriv->wpa_group_cipher = _NO_PRIVACY_; - psecuritypriv->wpa_pairwise_cipher = _NO_PRIVACY_; + psecuritypriv->wpa_group_cipher = 0; + psecuritypriv->wpa_pairwise_cipher = 0; for (p = ie + _BEACON_IE_OFFSET_; ;p += (ie_len + 2)) { p = rtw_get_ie23a(p, WLAN_EID_VENDOR_SPECIFIC, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_ - @@ -1887,16 +1890,20 @@ void rtw_ap_restore_network(struct rtw_adapter *padapter) start_bss_network(padapter, (u8*)&mlmepriv->cur_network.network); - if ((padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_) || - (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_)) - { + if (padapter->securitypriv.dot11PrivacyAlgrthm == + WLAN_CIPHER_SUITE_TKIP || + padapter->securitypriv.dot11PrivacyAlgrthm == + WLAN_CIPHER_SUITE_CCMP) { /* restore group key, WEP keys is restored in ips_leave23a() */ - rtw_set_key23a(padapter, psecuritypriv, psecuritypriv->dot118021XGrpKeyid, 0); + rtw_set_key23a(padapter, psecuritypriv, + psecuritypriv->dot118021XGrpKeyid, 0); } /* per sta pairwise key and settings */ - if ((padapter->securitypriv.dot11PrivacyAlgrthm != _TKIP_) && - (padapter->securitypriv.dot11PrivacyAlgrthm != _AES_)) { + if (padapter->securitypriv.dot11PrivacyAlgrthm != + WLAN_CIPHER_SUITE_TKIP && + padapter->securitypriv.dot11PrivacyAlgrthm != + WLAN_CIPHER_SUITE_CCMP) { return; } diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 5abe936e479e..bf9e56229a30 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -587,13 +587,14 @@ int rtw_joinbss_cmd23a(struct rtw_adapter *padapter, phtpriv->ht_option = false; if (pregistrypriv->ht_enable) { + u32 algo = padapter->securitypriv.dot11PrivacyAlgrthm; /* Added by Albert 2010/06/23 */ /* For the WEP mode, we will use the bg mode to do the connection to avoid some IOT issue. */ /* Especially for Realtek 8192u SoftAP. */ - if ((padapter->securitypriv.dot11PrivacyAlgrthm != _WEP40_) && - (padapter->securitypriv.dot11PrivacyAlgrthm != _WEP104_) && - (padapter->securitypriv.dot11PrivacyAlgrthm != _TKIP_)) { + if (algo != WLAN_CIPHER_SUITE_WEP40 && + algo != WLAN_CIPHER_SUITE_WEP104 && + algo != WLAN_CIPHER_SUITE_TKIP) { /* rtw_restructure_ht_ie23a */ rtw_restructure_ht_ie23a(padapter, &pnetwork->network.IEs[0], @@ -807,7 +808,7 @@ int rtw_clearstakey_cmd23a(struct rtw_adapter *padapter, u8 *psta, u8 entry, ether_addr_copy(psetstakey_para->addr, sta->hwaddr); - psetstakey_para->algorithm = _NO_PRIVACY_; + psetstakey_para->algorithm = 0; psetstakey_para->id = entry; diff --git a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c index d496ae35095a..347ea999ec4a 100644 --- a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c @@ -382,17 +382,17 @@ int rtw_set_802_11_add_wep23a(struct rtw_adapter* padapter, switch (wep->KeyLength) { case 5: - psecuritypriv->dot11PrivacyAlgrthm = _WEP40_; + psecuritypriv->dot11PrivacyAlgrthm = WLAN_CIPHER_SUITE_WEP40; RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("MgntActrtw_set_802_11_add_wep23a:wep->KeyLength = 5\n")); break; case 13: - psecuritypriv->dot11PrivacyAlgrthm = _WEP104_; + psecuritypriv->dot11PrivacyAlgrthm = WLAN_CIPHER_SUITE_WEP104; RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("MgntActrtw_set_802_11_add_wep23a:wep->KeyLength = 13\n")); break; default: - psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_; + psecuritypriv->dot11PrivacyAlgrthm = 0; RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("MgntActrtw_set_802_11_add_wep23a:wep->KeyLength!= 5 " "or 13\n")); diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 8c6b0947ee92..42efc171b89b 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -340,10 +340,10 @@ int rtw_is_same_ibss23a(struct rtw_adapter *adapter, int ret = true; struct security_priv *psecuritypriv = &adapter->securitypriv; - if (psecuritypriv->dot11PrivacyAlgrthm != _NO_PRIVACY_ && + if (psecuritypriv->dot11PrivacyAlgrthm != 0 && pnetwork->network.Privacy == 0) ret = false; - else if (psecuritypriv->dot11PrivacyAlgrthm == _NO_PRIVACY_ && + else if (psecuritypriv->dot11PrivacyAlgrthm == 0 && pnetwork->network.Privacy == 1) ret = false; else @@ -1911,23 +1911,23 @@ int rtw_set_key23a(struct rtw_adapter *adapter, "keyid = (u8)keyid =%d\n", psetkeyparm->algorithm, keyid)); switch (psetkeyparm->algorithm) { - case _WEP40_: + case WLAN_CIPHER_SUITE_WEP40: keylen = 5; memcpy(&psetkeyparm->key[0], &psecuritypriv->dot11DefKey[keyid].skey[0], keylen); break; - case _WEP104_: + case WLAN_CIPHER_SUITE_WEP104: keylen = 13; memcpy(&psetkeyparm->key[0], &psecuritypriv->dot11DefKey[keyid].skey[0], keylen); break; - case _TKIP_: + case WLAN_CIPHER_SUITE_TKIP: keylen = 16; memcpy(&psetkeyparm->key, &psecuritypriv->dot118021XGrpKey[keyid], keylen); psetkeyparm->grpkey = 1; break; - case _AES_: + case WLAN_CIPHER_SUITE_CCMP: keylen = 16; memcpy(&psetkeyparm->key, &psecuritypriv->dot118021XGrpKey[keyid], keylen); @@ -2250,7 +2250,8 @@ unsigned int rtw_restructure_ht_ie23a(struct rtw_adapter *padapter, u8 *in_ie, &max_rx_ampdu_factor); ht_capie.ampdu_params_info = max_rx_ampdu_factor & 0x03; - if (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_) + if (padapter->securitypriv.dot11PrivacyAlgrthm == + WLAN_CIPHER_SUITE_CCMP) ht_capie.ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_DENSITY& (0x07 << 2)); else diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 0bfc91fe034f..dd6c7fac41a0 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -336,7 +336,7 @@ static void init_mlme_ext_priv23a_value(struct rtw_adapter* padapter) pmlmeinfo->key_index = 0; pmlmeinfo->iv = 0; - pmlmeinfo->enc_algo = _NO_PRIVACY_; + pmlmeinfo->enc_algo = 0; pmlmeinfo->authModeToggle = 0; memset(pmlmeinfo->chg_txt, 0, 128); @@ -883,8 +883,8 @@ OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) DBG_8723A("auth alg =%x, seq =%X\n", algorithm, seq); if (auth_mode == 2 && - psecuritypriv->dot11PrivacyAlgrthm != _WEP40_ && - psecuritypriv->dot11PrivacyAlgrthm != _WEP104_) + psecuritypriv->dot11PrivacyAlgrthm != WLAN_CIPHER_SUITE_WEP40 && + psecuritypriv->dot11PrivacyAlgrthm != WLAN_CIPHER_SUITE_WEP104) auth_mode = 0; /* rx a shared-key auth but shared not enabled, or */ @@ -2305,7 +2305,7 @@ void update_mgntframe_attrib23a(struct rtw_adapter *padapter, else pattrib->raid = 5;/* a/g mode */ - pattrib->encrypt = _NO_PRIVACY_; + pattrib->encrypt = 0; pattrib->bswenc = false; pattrib->qos_en = false; @@ -3098,7 +3098,7 @@ void issue_auth23a(struct rtw_adapter *padapter, struct sta_info *psta, pattrib->hdrlen = sizeof(struct ieee80211_hdr_3addr); - pattrib->encrypt = _WEP40_; + pattrib->encrypt = WLAN_CIPHER_SUITE_WEP40; pattrib->icv_len = 4; @@ -6282,7 +6282,7 @@ int set_stakey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) struct sta_info *psta; struct sta_priv *pstapriv = &padapter->stapriv; - if (pparm->algorithm == _NO_PRIVACY_) /* clear cam entry */ + if (pparm->algorithm == 0) /* clear cam entry */ { clear_cam_entry23a(padapter, pparm->id); return H2C_SUCCESS_RSP; @@ -6323,8 +6323,7 @@ int set_stakey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) /* below for sta mode */ - if (pparm->algorithm == _NO_PRIVACY_) /* clear cam entry */ - { + if (pparm->algorithm == 0) { /* clear cam entry */ clear_cam_entry23a(padapter, pparm->id); return H2C_SUCCESS; } diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index 707b5ccd951b..8af8e572c73b 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -79,8 +79,10 @@ int ips_leave23a(struct rtw_adapter * padapter) DBG_8723A_LEVEL(_drv_always_, "nolinked power save leave\n"); - if (psecuritypriv->dot11PrivacyAlgrthm == _WEP40_ || - psecuritypriv->dot11PrivacyAlgrthm == _WEP104_) { + if (psecuritypriv->dot11PrivacyAlgrthm == + WLAN_CIPHER_SUITE_WEP40 || + psecuritypriv->dot11PrivacyAlgrthm == + WLAN_CIPHER_SUITE_WEP104) { DBG_8723A("==>%s, channel(%d), processing(%x)\n", __func__, padapter->mlmeextpriv.cur_channel, pwrpriv->bips_processing); diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index a2dc5d8187f9..3275287ca25a 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -296,9 +296,9 @@ int recvframe_chkmic(struct rtw_adapter *adapter, stainfo = rtw_get_stainfo23a(&adapter->stapriv, &prxattrib->ta[0]); - if (prxattrib->encrypt == _TKIP_) { + if (prxattrib->encrypt == WLAN_CIPHER_SUITE_TKIP) { RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, - ("\n recvframe_chkmic:prxattrib->encrypt == _TKIP_\n")); + ("\n recvframe_chkmic:prxattrib->encrypt == WLAN_CIPHER_SUITE_TKIP\n")); RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic:da = 0x%02x:0x%02x:0x%02x:0x%02x:" "0x%02x:0x%02x\n", prxattrib->ra[0], @@ -491,13 +491,13 @@ struct recv_frame *decryptor(struct rtw_adapter *padapter, prxattrib->key_index); switch (prxattrib->encrypt) { - case _WEP40_: - case _WEP104_: + case WLAN_CIPHER_SUITE_WEP40: + case WLAN_CIPHER_SUITE_WEP104: prxattrib->key_index = psecuritypriv->dot11PrivacyKeyIndex; break; - case _TKIP_: - case _AES_: + case WLAN_CIPHER_SUITE_TKIP: + case WLAN_CIPHER_SUITE_CCMP: default: prxattrib->key_index = psecuritypriv->dot118021XGrpKeyid; @@ -509,14 +509,14 @@ struct recv_frame *decryptor(struct rtw_adapter *padapter, if ((prxattrib->encrypt > 0) && ((prxattrib->bdecrypted == 0))) { psecuritypriv->hw_decrypted = 0; switch (prxattrib->encrypt) { - case _WEP40_: - case _WEP104_: + case WLAN_CIPHER_SUITE_WEP40: + case WLAN_CIPHER_SUITE_WEP104: rtw_wep_decrypt23a(padapter, precv_frame); break; - case _TKIP_: + case WLAN_CIPHER_SUITE_TKIP: res = rtw_tkip_decrypt23a(padapter, precv_frame); break; - case _AES_: + case WLAN_CIPHER_SUITE_CCMP: res = rtw_aes_decrypt23a(padapter, precv_frame); break; default: @@ -524,7 +524,7 @@ struct recv_frame *decryptor(struct rtw_adapter *padapter, } } else if (prxattrib->bdecrypted == 1 && prxattrib->encrypt > 0 && (psecuritypriv->busetkipkey == 1 || - prxattrib->encrypt != _TKIP_)) { + prxattrib->encrypt != WLAN_CIPHER_SUITE_TKIP)) { psecuritypriv->hw_decrypted = 1; } @@ -1408,16 +1408,16 @@ static int validate_recv_data_frame(struct rtw_adapter *adapter, switch (pattrib->encrypt) { - case _WEP40_: - case _WEP104_: + case WLAN_CIPHER_SUITE_WEP40: + case WLAN_CIPHER_SUITE_WEP104: pattrib->iv_len = 4; pattrib->icv_len = 4; break; - case _TKIP_: + case WLAN_CIPHER_SUITE_TKIP: pattrib->iv_len = 8; pattrib->icv_len = 4; break; - case _AES_: + case WLAN_CIPHER_SUITE_CCMP: pattrib->iv_len = 8; pattrib->icv_len = 8; break; diff --git a/drivers/staging/rtl8723au/core/rtw_security.c b/drivers/staging/rtl8723au/core/rtw_security.c index 96347e73b4f6..aeb503b1f066 100644 --- a/drivers/staging/rtl8723au/core/rtw_security.c +++ b/drivers/staging/rtl8723au/core/rtw_security.c @@ -170,7 +170,8 @@ void rtw_wep_encrypt23a(struct rtw_adapter *padapter, pframe = pxmitframe->buf_addr + hw_hdr_offset; /* start to encrypt each fragment */ - if ((pattrib->encrypt != _WEP40_) && (pattrib->encrypt != _WEP104_)) + if (pattrib->encrypt != WLAN_CIPHER_SUITE_WEP40 && + pattrib->encrypt != WLAN_CIPHER_SUITE_WEP104) return; index = psecuritypriv->dot11PrivacyKeyIndex; @@ -225,7 +226,8 @@ void rtw_wep_decrypt23a(struct rtw_adapter *padapter, pframe = skb->data; /* start to decrypt recvframe */ - if ((prxattrib->encrypt != _WEP40_) && (prxattrib->encrypt != _WEP104_)) + if (prxattrib->encrypt != WLAN_CIPHER_SUITE_WEP40 && + prxattrib->encrypt != WLAN_CIPHER_SUITE_WEP104) return; iv = pframe + prxattrib->hdrlen; @@ -637,14 +639,10 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter, pframe = pxmitframe->buf_addr + hw_hdr_offset; /* 4 start to encrypt each fragment */ - if (pattrib->encrypt == _TKIP_) { - + if (pattrib->encrypt == WLAN_CIPHER_SUITE_TKIP) { if (pattrib->psta) - { stainfo = pattrib->psta; - } - else - { + else { DBG_8723A("%s, call rtw_get_stainfo()\n", __func__); stainfo = rtw_get_stainfo23a(&padapter->stapriv, &pattrib->ra[0]); @@ -737,7 +735,7 @@ int rtw_tkip_decrypt23a(struct rtw_adapter *padapter, pframe = skb->data; /* 4 start to decrypt recvframe */ - if (prxattrib->encrypt == _TKIP_) { + if (prxattrib->encrypt == WLAN_CIPHER_SUITE_TKIP) { stainfo = rtw_get_stainfo23a(&padapter->stapriv, &prxattrib->ta[0]); @@ -1323,7 +1321,7 @@ int rtw_aes_encrypt23a(struct rtw_adapter *padapter, pframe = pxmitframe->buf_addr + hw_hdr_offset; /* 4 start to encrypt each fragment */ - if (pattrib->encrypt != _AES_) + if (pattrib->encrypt != WLAN_CIPHER_SUITE_CCMP) return _FAIL; if (pattrib->psta) { @@ -1598,7 +1596,7 @@ int rtw_aes_decrypt23a(struct rtw_adapter *padapter, pframe = skb->data; /* 4 start to encrypt each fragment */ - if (prxattrib->encrypt != _AES_) + if (prxattrib->encrypt != WLAN_CIPHER_SUITE_CCMP) return _FAIL; stainfo = rtw_get_stainfo23a(&padapter->stapriv, &prxattrib->ta[0]); diff --git a/drivers/staging/rtl8723au/core/rtw_sreset.c b/drivers/staging/rtl8723au/core/rtw_sreset.c index 7e698c524431..18a42a27b488 100644 --- a/drivers/staging/rtl8723au/core/rtw_sreset.c +++ b/drivers/staging/rtl8723au/core/rtw_sreset.c @@ -105,8 +105,10 @@ static void sreset_restore_security_station(struct rtw_adapter *padapter) rtl8723a_set_sec_cfg(padapter, val8); - if ((padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_) || - (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_)) { + if (padapter->securitypriv.dot11PrivacyAlgrthm == + WLAN_CIPHER_SUITE_TKIP || + padapter->securitypriv.dot11PrivacyAlgrthm == + WLAN_CIPHER_SUITE_CCMP) { psta = rtw_get_stainfo23a(pstapriv, get_bssid(mlmepriv)); if (psta == NULL) { /* DEBUG_ERR(("Set wpa_set_encryption: Obtain Sta_info fail\n")); */ diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index eeaaa8fc7a4c..0472258c416b 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -296,9 +296,10 @@ static void update_attrib_vcs_info(struct rtw_adapter *padapter, struct xmit_fra } else { while (true) { /* IOT action */ - if ((pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_ATHEROS) && - (pattrib->ampdu_en) && - (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_)) { + if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_ATHEROS && + pattrib->ampdu_en && + padapter->securitypriv.dot11PrivacyAlgrthm == + WLAN_CIPHER_SUITE_CCMP) { pattrib->vcs_mode = CTS_TO_SELF; break; } @@ -594,13 +595,13 @@ static int update_attrib(struct rtw_adapter *padapter, } switch (pattrib->encrypt) { - case _WEP40_: - case _WEP104_: + case WLAN_CIPHER_SUITE_WEP40: + case WLAN_CIPHER_SUITE_WEP104: pattrib->iv_len = 4; pattrib->icv_len = 4; break; - case _TKIP_: + case WLAN_CIPHER_SUITE_TKIP: pattrib->iv_len = 8; pattrib->icv_len = 4; @@ -614,9 +615,10 @@ static int update_attrib(struct rtw_adapter *padapter, } break; - case _AES_: + case WLAN_CIPHER_SUITE_CCMP: RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, - ("pattrib->encrypt =%d (_AES_)\n", pattrib->encrypt)); + ("pattrib->encrypt =%d (WLAN_CIPHER_SUITE_CCMP)\n", + pattrib->encrypt)); pattrib->iv_len = 8; pattrib->icv_len = 8; break; @@ -680,7 +682,7 @@ static int xmitframe_addmic(struct rtw_adapter *padapter, hw_hdr_offset = TXDESC_OFFSET; - if (pattrib->encrypt == _TKIP_) { + if (pattrib->encrypt == WLAN_CIPHER_SUITE_TKIP) { /* encode mic code */ if (stainfo) { u8 null_key[16]={0x0, 0x0, 0x0, 0x0, @@ -834,14 +836,14 @@ static int xmitframe_swencrypt(struct rtw_adapter *padapter, RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_, ("### xmitframe_swencrypt\n")); switch (pattrib->encrypt) { - case _WEP40_: - case _WEP104_: + case WLAN_CIPHER_SUITE_WEP40: + case WLAN_CIPHER_SUITE_WEP104: rtw_wep_encrypt23a(padapter, pxmitframe); break; - case _TKIP_: + case WLAN_CIPHER_SUITE_TKIP: rtw_tkip_encrypt23a(padapter, pxmitframe); break; - case _AES_: + case WLAN_CIPHER_SUITE_CCMP: rtw_aes_encrypt23a(padapter, pxmitframe); break; default: @@ -1052,7 +1054,7 @@ u32 rtw_calculate_wlan_pkt_size_by_attribue23a(struct pkt_attrib *pattrib) len = pattrib->hdrlen + pattrib->iv_len; /* WLAN Header and IV */ len += SNAP_SIZE + sizeof(u16); /* LLC */ len += pattrib->pktlen; - if (pattrib->encrypt == _TKIP_) len += 8; /* MIC */ + if (pattrib->encrypt == WLAN_CIPHER_SUITE_TKIP) len += 8; /* MIC */ len += ((pattrib->bswenc) ? pattrib->icv_len : 0); /* ICV */ return len; @@ -1144,12 +1146,12 @@ int rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *skb, if (pattrib->iv_len) { if (psta) { switch (pattrib->encrypt) { - case _WEP40_: - case _WEP104_: + case WLAN_CIPHER_SUITE_WEP40: + case WLAN_CIPHER_SUITE_WEP104: WEP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); break; - case _TKIP_: + case WLAN_CIPHER_SUITE_TKIP: if (bmcst) TKIP_IV(pattrib->iv, psta->dot11txpn, @@ -1158,7 +1160,7 @@ int rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *skb, TKIP_IV(pattrib->iv, psta->dot11txpn, 0); break; - case _AES_: + case WLAN_CIPHER_SUITE_CCMP: if (bmcst) AES_IV(pattrib->iv, psta->dot11txpn, diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index 1ec214594774..af7e6b375841 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -419,15 +419,14 @@ rtl8723a_set_ampdu_min_space(struct rtw_adapter *padapter, u8 MinSpacingToSet) if (MinSpacingToSet <= 7) { switch (padapter->securitypriv.dot11PrivacyAlgrthm) { - case _NO_PRIVACY_: - case _AES_: + case 0: + case WLAN_CIPHER_SUITE_CCMP: SecMinSpace = 0; break; - case _WEP40_: - case _WEP104_: - case _TKIP_: - case _TKIP_WTMIC_: + case WLAN_CIPHER_SUITE_WEP40: + case WLAN_CIPHER_SUITE_WEP104: + case WLAN_CIPHER_SUITE_TKIP: SecMinSpace = 6; break; default: diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 0afc74253fe4..a29fa76931c1 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -2081,18 +2081,17 @@ static void fill_txdesc_sectype(struct pkt_attrib *pattrib, if ((pattrib->encrypt > 0) && !pattrib->bswenc) { switch (pattrib->encrypt) { /* SEC_TYPE */ - case _WEP40_: - case _WEP104_: - case _TKIP_: - case _TKIP_WTMIC_: + case WLAN_CIPHER_SUITE_WEP40: + case WLAN_CIPHER_SUITE_WEP104: + case WLAN_CIPHER_SUITE_TKIP: ptxdesc->sectype = 1; break; - case _AES_: + case WLAN_CIPHER_SUITE_CCMP: ptxdesc->sectype = 3; break; - case _NO_PRIVACY_: + case 0: default: break; } diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c b/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c index d2caafa6b026..a67850fe6e5d 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c +++ b/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c @@ -73,19 +73,18 @@ static void fill_txdesc_sectype(struct pkt_attrib *pattrib, struct tx_desc *ptxd if ((pattrib->encrypt > 0) && !pattrib->bswenc) { switch (pattrib->encrypt) { /* SEC_TYPE */ - case _WEP40_: - case _WEP104_: + case WLAN_CIPHER_SUITE_WEP40: + case WLAN_CIPHER_SUITE_WEP104: ptxdesc->txdw1 |= cpu_to_le32((0x01<<22)&0x00c00000); break; - case _TKIP_: - case _TKIP_WTMIC_: + case WLAN_CIPHER_SUITE_TKIP: /* ptxdesc->txdw1 |= cpu_to_le32((0x02<<22)&0x00c00000); */ ptxdesc->txdw1 |= cpu_to_le32((0x01<<22)&0x00c00000); break; - case _AES_: + case WLAN_CIPHER_SUITE_CCMP: ptxdesc->txdw1 |= cpu_to_le32((0x03<<22)&0x00c00000); break; - case _NO_PRIVACY_: + case 0: default: break; } diff --git a/drivers/staging/rtl8723au/include/rtw_recv.h b/drivers/staging/rtl8723au/include/rtw_recv.h index fd381c594b14..f846bb5e7ab7 100644 --- a/drivers/staging/rtl8723au/include/rtw_recv.h +++ b/drivers/staging/rtl8723au/include/rtw_recv.h @@ -111,7 +111,7 @@ struct rx_pkt_attrib { u8 privacy; /* in frame_ctrl field */ u8 bdecrypted; /* when 0 indicate no encrypt. when non-zero, indicate the algorith */ - u8 encrypt; + u32 encrypt; u8 iv_len; u8 icv_len; u8 crc_err; diff --git a/drivers/staging/rtl8723au/include/rtw_security.h b/drivers/staging/rtl8723au/include/rtw_security.h index 1a7fed8e25b7..e235ecd3e5e7 100644 --- a/drivers/staging/rtl8723au/include/rtw_security.h +++ b/drivers/staging/rtl8723au/include/rtw_security.h @@ -19,14 +19,8 @@ #include -#define _NO_PRIVACY_ 0x0 -#define _WEP40_ 0x1 -#define _TKIP_ 0x2 -#define _TKIP_WTMIC_ 0x3 -#define _AES_ 0x4 -#define _WEP104_ 0x5 - -#define is_wep_enc(alg) (((alg) == _WEP40_) || ((alg) == _WEP104_)) +#define is_wep_enc(alg) (alg == WLAN_CIPHER_SUITE_WEP40 || \ + alg == WLAN_CIPHER_SUITE_WEP104) #define _WPA2_IE_ID_ 0x30 diff --git a/drivers/staging/rtl8723au/include/rtw_xmit.h b/drivers/staging/rtl8723au/include/rtw_xmit.h index 155ac5d42b1d..33d0bc4ffd30 100644 --- a/drivers/staging/rtl8723au/include/rtw_xmit.h +++ b/drivers/staging/rtl8723au/include/rtw_xmit.h @@ -124,8 +124,8 @@ struct pkt_attrib { u16 hdrlen; /* the WLAN Header Len */ u32 pktlen; /* the original 802.3 pkt raw_data len */ u32 last_txcmdsz; + u32 encrypt; /* when 0 indicate no encrypt. */ u8 nr_frags; - u8 encrypt; /* when 0 indicate no encrypt. */ u8 iv_len; u8 icv_len; u8 iv[18]; diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 62e8c824406a..e5662a82debd 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -506,15 +506,14 @@ static int set_group_key(struct rtw_adapter *padapter, u8 *key, u32 alg, psetkeyparm->set_tx = 1; switch (alg) { - case _WEP40_: + case WLAN_CIPHER_SUITE_WEP40: keylen = 5; break; - case _WEP104_: + case WLAN_CIPHER_SUITE_WEP104: keylen = 13; break; - case _TKIP_: - case _TKIP_WTMIC_: - case _AES_: + case WLAN_CIPHER_SUITE_TKIP: + case WLAN_CIPHER_SUITE_CCMP: default: keylen = 16; } @@ -536,17 +535,17 @@ exit: static int set_wep_key(struct rtw_adapter *padapter, u8 *key, u8 keylen, u8 keyid) { - u8 alg; + u32 alg; switch (keylen) { case 5: - alg = _WEP40_; + alg = WLAN_CIPHER_SUITE_WEP40; break; case 13: - alg = _WEP104_; + alg = WLAN_CIPHER_SUITE_WEP104; break; default: - alg = _NO_PRIVACY_; + alg = 0; } return set_group_key(padapter, key, alg, keyid); @@ -626,12 +625,12 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, psecuritypriv->ndisencryptstatus = Ndis802_11Encryption1Enabled; - psecuritypriv->dot11PrivacyAlgrthm = _WEP40_; - psecuritypriv->dot118021XGrpPrivacy = _WEP40_; + psecuritypriv->dot11PrivacyAlgrthm = WLAN_CIPHER_SUITE_WEP40; + psecuritypriv->dot118021XGrpPrivacy = WLAN_CIPHER_SUITE_WEP40; if (wep_key_len == 13) { - psecuritypriv->dot11PrivacyAlgrthm = _WEP104_; - psecuritypriv->dot118021XGrpPrivacy = _WEP104_; + psecuritypriv->dot11PrivacyAlgrthm = WLAN_CIPHER_SUITE_WEP104; + psecuritypriv->dot118021XGrpPrivacy = WLAN_CIPHER_SUITE_WEP104; } psecuritypriv->dot11PrivacyKeyIndex = wep_key_idx; @@ -660,17 +659,17 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); - psecuritypriv->dot118021XGrpPrivacy = _WEP40_; + psecuritypriv->dot118021XGrpPrivacy = WLAN_CIPHER_SUITE_WEP40; if (param->u.crypt.key_len == 13) { psecuritypriv->dot118021XGrpPrivacy = - _WEP104_; + WLAN_CIPHER_SUITE_WEP104; } } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) { DBG_8723A("%s, set group_key, TKIP\n", __func__); - psecuritypriv->dot118021XGrpPrivacy = _TKIP_; + psecuritypriv->dot118021XGrpPrivacy = WLAN_CIPHER_SUITE_TKIP; memcpy(psecuritypriv-> dot118021XGrpKey[param->u.crypt.idx]. @@ -695,7 +694,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, DBG_8723A("%s, set group_key, CCMP\n", __func__); - psecuritypriv->dot118021XGrpPrivacy = _AES_; + psecuritypriv->dot118021XGrpPrivacy = WLAN_CIPHER_SUITE_CCMP; memcpy(psecuritypriv-> dot118021XGrpKey[param->u.crypt.idx]. @@ -707,7 +706,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, __func__); psecuritypriv->dot118021XGrpPrivacy = - _NO_PRIVACY_; + 0; } psecuritypriv->dot118021XGrpKeyid = param->u.crypt.idx; @@ -749,16 +748,16 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, DBG_8723A("%s, set pairwise key, WEP\n", __func__); - psta->dot118021XPrivacy = _WEP40_; + psta->dot118021XPrivacy = WLAN_CIPHER_SUITE_WEP40; if (param->u.crypt.key_len == 13) { psta->dot118021XPrivacy = - _WEP104_; + WLAN_CIPHER_SUITE_WEP104; } } else if (!strcmp(param->u.crypt.alg, "TKIP")) { DBG_8723A("%s, set pairwise key, " "TKIP\n", __func__); - psta->dot118021XPrivacy = _TKIP_; + psta->dot118021XPrivacy = WLAN_CIPHER_SUITE_TKIP; /* DEBUG_ERR("set key length :param->u.crypt.key_len =%d\n", param->u.crypt.key_len); */ /* set mic key */ @@ -774,12 +773,12 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, DBG_8723A("%s, set pairwise key, " "CCMP\n", __func__); - psta->dot118021XPrivacy = _AES_; + psta->dot118021XPrivacy = WLAN_CIPHER_SUITE_CCMP; } else { DBG_8723A("%s, set pairwise key, " "none\n", __func__); - psta->dot118021XPrivacy = _NO_PRIVACY_; + psta->dot118021XPrivacy = 0; } set_pairwise_key(padapter, psta); @@ -798,15 +797,15 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, key_len)); psecuritypriv->dot118021XGrpPrivacy = - _WEP40_; + WLAN_CIPHER_SUITE_WEP40; if (param->u.crypt.key_len == 13) { psecuritypriv-> dot118021XGrpPrivacy = - _WEP104_; + WLAN_CIPHER_SUITE_WEP104; } } else if (!strcmp(param->u.crypt.alg, "TKIP")) { psecuritypriv->dot118021XGrpPrivacy = - _TKIP_; + WLAN_CIPHER_SUITE_TKIP; memcpy(psecuritypriv-> dot118021XGrpKey[param->u.crypt. @@ -835,7 +834,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, } else if (!strcmp(param->u.crypt.alg, "CCMP")) { psecuritypriv->dot118021XGrpPrivacy = - _AES_; + WLAN_CIPHER_SUITE_CCMP; memcpy(psecuritypriv-> dot118021XGrpKey[param->u.crypt. @@ -846,7 +845,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, key_len)); } else { psecuritypriv->dot118021XGrpPrivacy = - _NO_PRIVACY_; + 0; } psecuritypriv->dot118021XGrpKeyid = @@ -932,12 +931,12 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, psecuritypriv->ndisencryptstatus = Ndis802_11Encryption1Enabled; - psecuritypriv->dot11PrivacyAlgrthm = _WEP40_; - psecuritypriv->dot118021XGrpPrivacy = _WEP40_; + psecuritypriv->dot11PrivacyAlgrthm = WLAN_CIPHER_SUITE_WEP40; + psecuritypriv->dot118021XGrpPrivacy = WLAN_CIPHER_SUITE_WEP40; if (wep_key_len == 13) { - psecuritypriv->dot11PrivacyAlgrthm = _WEP104_; - psecuritypriv->dot118021XGrpPrivacy = _WEP104_; + psecuritypriv->dot11PrivacyAlgrthm = WLAN_CIPHER_SUITE_WEP104; + psecuritypriv->dot118021XGrpPrivacy = WLAN_CIPHER_SUITE_WEP104; } psecuritypriv->dot11PrivacyKeyIndex = wep_key_idx; @@ -1203,18 +1202,18 @@ static int cfg80211_rtw_set_default_key(struct wiphy *wiphy, __func__, ndev->name, key_index, unicast, multicast); if ((key_index < WEP_KEYS) && - ((psecuritypriv->dot11PrivacyAlgrthm == _WEP40_) || - (psecuritypriv->dot11PrivacyAlgrthm == _WEP104_))) { + ((psecuritypriv->dot11PrivacyAlgrthm == WLAN_CIPHER_SUITE_WEP40) || + (psecuritypriv->dot11PrivacyAlgrthm == WLAN_CIPHER_SUITE_WEP104))) { /* set wep default key */ psecuritypriv->ndisencryptstatus = Ndis802_11Encryption1Enabled; psecuritypriv->dot11PrivacyKeyIndex = key_index; - psecuritypriv->dot11PrivacyAlgrthm = _WEP40_; - psecuritypriv->dot118021XGrpPrivacy = _WEP40_; + psecuritypriv->dot11PrivacyAlgrthm = WLAN_CIPHER_SUITE_WEP40; + psecuritypriv->dot118021XGrpPrivacy = WLAN_CIPHER_SUITE_WEP40; if (psecuritypriv->dot11DefKeylen[key_index] == 13) { - psecuritypriv->dot11PrivacyAlgrthm = _WEP104_; - psecuritypriv->dot118021XGrpPrivacy = _WEP104_; + psecuritypriv->dot11PrivacyAlgrthm = WLAN_CIPHER_SUITE_WEP104; + psecuritypriv->dot118021XGrpPrivacy = WLAN_CIPHER_SUITE_WEP104; } /* set the flag to represent that wep default key @@ -1705,30 +1704,30 @@ static int rtw_cfg80211_set_cipher(struct security_priv *psecuritypriv, DBG_8723A("%s, ucast =%d, cipher = 0x%x\n", __func__, ucast, cipher); if (!cipher) { - *profile_cipher = _NO_PRIVACY_; + *profile_cipher = 0; psecuritypriv->ndisencryptstatus = ndisencryptstatus; return 0; } switch (cipher) { case IW_AUTH_CIPHER_NONE: - *profile_cipher = _NO_PRIVACY_; + *profile_cipher = 0; ndisencryptstatus = Ndis802_11EncryptionDisabled; break; case WLAN_CIPHER_SUITE_WEP40: - *profile_cipher = _WEP40_; + *profile_cipher = WLAN_CIPHER_SUITE_WEP40; ndisencryptstatus = Ndis802_11Encryption1Enabled; break; case WLAN_CIPHER_SUITE_WEP104: - *profile_cipher = _WEP104_; + *profile_cipher = WLAN_CIPHER_SUITE_WEP104; ndisencryptstatus = Ndis802_11Encryption1Enabled; break; case WLAN_CIPHER_SUITE_TKIP: - *profile_cipher = _TKIP_; + *profile_cipher = WLAN_CIPHER_SUITE_TKIP; ndisencryptstatus = Ndis802_11Encryption2Enabled; break; case WLAN_CIPHER_SUITE_CCMP: - *profile_cipher = _AES_; + *profile_cipher = WLAN_CIPHER_SUITE_CCMP; ndisencryptstatus = Ndis802_11Encryption3Enabled; break; default: @@ -1838,27 +1837,27 @@ static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie, switch (group_cipher) { case WPA_CIPHER_NONE: - padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; + padapter->securitypriv.dot118021XGrpPrivacy = 0; padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; break; case WPA_CIPHER_WEP40: - padapter->securitypriv.dot118021XGrpPrivacy = _WEP40_; + padapter->securitypriv.dot118021XGrpPrivacy = WLAN_CIPHER_SUITE_WEP40; padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; break; case WPA_CIPHER_TKIP: - padapter->securitypriv.dot118021XGrpPrivacy = _TKIP_; + padapter->securitypriv.dot118021XGrpPrivacy = WLAN_CIPHER_SUITE_TKIP; padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; break; case WPA_CIPHER_CCMP: - padapter->securitypriv.dot118021XGrpPrivacy = _AES_; + padapter->securitypriv.dot118021XGrpPrivacy = WLAN_CIPHER_SUITE_CCMP; padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; break; case WPA_CIPHER_WEP104: - padapter->securitypriv.dot118021XGrpPrivacy = _WEP104_; + padapter->securitypriv.dot118021XGrpPrivacy = WLAN_CIPHER_SUITE_WEP104; padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; break; @@ -1866,27 +1865,27 @@ static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie, switch (pairwise_cipher) { case WPA_CIPHER_NONE: - padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; + padapter->securitypriv.dot11PrivacyAlgrthm = 0; padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; break; case WPA_CIPHER_WEP40: - padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; + padapter->securitypriv.dot11PrivacyAlgrthm = WLAN_CIPHER_SUITE_WEP40; padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; break; case WPA_CIPHER_TKIP: - padapter->securitypriv.dot11PrivacyAlgrthm = _TKIP_; + padapter->securitypriv.dot11PrivacyAlgrthm = WLAN_CIPHER_SUITE_TKIP; padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; break; case WPA_CIPHER_CCMP: - padapter->securitypriv.dot11PrivacyAlgrthm = _AES_; + padapter->securitypriv.dot11PrivacyAlgrthm = WLAN_CIPHER_SUITE_CCMP; padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; break; case WPA_CIPHER_WEP104: - padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; + padapter->securitypriv.dot11PrivacyAlgrthm = WLAN_CIPHER_SUITE_WEP104; padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; break; @@ -1911,9 +1910,10 @@ static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie, } /* TKIP and AES disallow multicast packets until installing group key */ - if (padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_ || - padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_WTMIC_ || - padapter->securitypriv.dot11PrivacyAlgrthm == _AES_) + if (padapter->securitypriv.dot11PrivacyAlgrthm == + WLAN_CIPHER_SUITE_TKIP || + padapter->securitypriv.dot11PrivacyAlgrthm == + WLAN_CIPHER_SUITE_CCMP) /* WPS open need to enable multicast */ /* check_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS) == true)*/ rtl8723a_off_rcr_am(padapter); @@ -2068,8 +2068,8 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, } psecuritypriv->ndisencryptstatus = Ndis802_11EncryptionDisabled; - psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_; - psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_; + psecuritypriv->dot11PrivacyAlgrthm = 0; + psecuritypriv->dot118021XGrpPrivacy = 0; psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; psecuritypriv->ndisauthtype = Ndis802_11AuthModeOpen; @@ -2135,9 +2135,9 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, if (wep_key_len == 13) { padapter->securitypriv.dot11PrivacyAlgrthm = - _WEP104_; + WLAN_CIPHER_SUITE_WEP104; padapter->securitypriv.dot118021XGrpPrivacy = - _WEP104_; + WLAN_CIPHER_SUITE_WEP104; } } else { ret = -EINVAL; diff --git a/drivers/staging/rtl8723au/os_dep/mlme_linux.c b/drivers/staging/rtl8723au/os_dep/mlme_linux.c index c0e79f56d2eb..ac618fb8b762 100644 --- a/drivers/staging/rtl8723au/os_dep/mlme_linux.c +++ b/drivers/staging/rtl8723au/os_dep/mlme_linux.c @@ -60,10 +60,10 @@ void rtw_reset_securitypriv23a(struct rtw_adapter *adapter) /* open system */ psec_priv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; - psec_priv->dot11PrivacyAlgrthm = _NO_PRIVACY_; + psec_priv->dot11PrivacyAlgrthm = 0; psec_priv->dot11PrivacyKeyIndex = 0; - psec_priv->dot118021XGrpPrivacy = _NO_PRIVACY_; + psec_priv->dot118021XGrpPrivacy = 0; psec_priv->dot118021XGrpKeyid = 1; psec_priv->ndisauthtype = Ndis802_11AuthModeOpen; diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index d6d0e9a1c936..d572f643ba59 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -405,11 +405,11 @@ static int rtw_init_default_value(struct rtw_adapter *padapter) /* open system */ psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; - psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_; + psecuritypriv->dot11PrivacyAlgrthm = 0; psecuritypriv->dot11PrivacyKeyIndex = 0; - psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_; + psecuritypriv->dot118021XGrpPrivacy = 0; psecuritypriv->dot118021XGrpKeyid = 1; psecuritypriv->ndisauthtype = Ndis802_11AuthModeOpen; -- cgit v1.2.3 From e0827909a27c5d90bf88f714e108de9419fd8b29 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:35 +0200 Subject: staging: rtl8723au: Introduce struct rtw_wep_key to store our wep keys Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ioctl_set.c | 39 ++++++++++++----------- drivers/staging/rtl8723au/core/rtw_mlme.c | 4 +-- drivers/staging/rtl8723au/core/rtw_security.c | 11 +++---- drivers/staging/rtl8723au/include/rtw_security.h | 8 +++-- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 29 +++++++++-------- 5 files changed, 49 insertions(+), 42 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c index 347ea999ec4a..19e2e68ff85c 100644 --- a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c @@ -396,7 +396,8 @@ int rtw_set_802_11_add_wep23a(struct rtw_adapter* padapter, RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("MgntActrtw_set_802_11_add_wep23a:wep->KeyLength!= 5 " "or 13\n")); - break; + res = _FAIL; + goto exit; } RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, @@ -404,29 +405,29 @@ int rtw_set_802_11_add_wep23a(struct rtw_adapter* padapter, "wep->KeyIndex = 0x%x keyid =%x\n", wep->KeyLength, wep->KeyIndex, keyid)); - memcpy(&psecuritypriv->dot11DefKey[keyid].skey[0], - &wep->KeyMaterial, wep->KeyLength); + memcpy(&psecuritypriv->wep_key[keyid].key, &wep->KeyMaterial, + wep->KeyLength); - psecuritypriv->dot11DefKeylen[keyid] = wep->KeyLength; + psecuritypriv->wep_key[keyid].keylen = wep->KeyLength; psecuritypriv->dot11PrivacyKeyIndex = keyid; RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, - ("rtw_set_802_11_add_wep23a:security key material : %x %x %x %x " - "%x %x %x %x %x %x %x %x %x\n", - psecuritypriv->dot11DefKey[keyid].skey[0], - psecuritypriv->dot11DefKey[keyid].skey[1], - psecuritypriv->dot11DefKey[keyid].skey[2], - psecuritypriv->dot11DefKey[keyid].skey[3], - psecuritypriv->dot11DefKey[keyid].skey[4], - psecuritypriv->dot11DefKey[keyid].skey[5], - psecuritypriv->dot11DefKey[keyid].skey[6], - psecuritypriv->dot11DefKey[keyid].skey[7], - psecuritypriv->dot11DefKey[keyid].skey[8], - psecuritypriv->dot11DefKey[keyid].skey[9], - psecuritypriv->dot11DefKey[keyid].skey[10], - psecuritypriv->dot11DefKey[keyid].skey[11], - psecuritypriv->dot11DefKey[keyid].skey[12])); + ("rtw_set_802_11_add_wep23a:security key material : " + "%x %x %x %x %x %x %x %x %x %x %x %x %x\n", + psecuritypriv->wep_key[keyid].key[0], + psecuritypriv->wep_key[keyid].key[1], + psecuritypriv->wep_key[keyid].key[2], + psecuritypriv->wep_key[keyid].key[3], + psecuritypriv->wep_key[keyid].key[4], + psecuritypriv->wep_key[keyid].key[5], + psecuritypriv->wep_key[keyid].key[6], + psecuritypriv->wep_key[keyid].key[7], + psecuritypriv->wep_key[keyid].key[8], + psecuritypriv->wep_key[keyid].key[9], + psecuritypriv->wep_key[keyid].key[10], + psecuritypriv->wep_key[keyid].key[11], + psecuritypriv->wep_key[keyid].key[12])); res = rtw_set_key23a(padapter, psecuritypriv, keyid, 1); diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 42efc171b89b..5dace9b9e830 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -1914,12 +1914,12 @@ int rtw_set_key23a(struct rtw_adapter *adapter, case WLAN_CIPHER_SUITE_WEP40: keylen = 5; memcpy(&psetkeyparm->key[0], - &psecuritypriv->dot11DefKey[keyid].skey[0], keylen); + &psecuritypriv->wep_key[keyid].key, keylen); break; case WLAN_CIPHER_SUITE_WEP104: keylen = 13; memcpy(&psetkeyparm->key[0], - &psecuritypriv->dot11DefKey[keyid].skey[0], keylen); + &psecuritypriv->wep_key[keyid].key, keylen); break; case WLAN_CIPHER_SUITE_TKIP: keylen = 16; diff --git a/drivers/staging/rtl8723au/core/rtw_security.c b/drivers/staging/rtl8723au/core/rtw_security.c index aeb503b1f066..d6c07adc7bf4 100644 --- a/drivers/staging/rtl8723au/core/rtw_security.c +++ b/drivers/staging/rtl8723au/core/rtw_security.c @@ -175,12 +175,12 @@ void rtw_wep_encrypt23a(struct rtw_adapter *padapter, return; index = psecuritypriv->dot11PrivacyKeyIndex; - keylength = psecuritypriv->dot11DefKeylen[index]; + keylength = psecuritypriv->wep_key[index].keylen; for (curfragnum = 0; curfragnum < pattrib->nr_frags ; curfragnum++) { iv = pframe + pattrib->hdrlen; memcpy(&wepkey[0], iv, 3); - memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[index].skey[0], + memcpy(&wepkey[3], &psecuritypriv->wep_key[index].key, keylength); payload = pframe + pattrib->iv_len + pattrib->hdrlen; @@ -233,11 +233,10 @@ void rtw_wep_decrypt23a(struct rtw_adapter *padapter, iv = pframe + prxattrib->hdrlen; /* keyindex = (iv[3]&0x3); */ keyindex = prxattrib->key_index; - keylength = psecuritypriv->dot11DefKeylen[keyindex]; + keylength = psecuritypriv->wep_key[keyindex].keylen; memcpy(&wepkey[0], iv, 3); /* memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[psecuritypriv->dot11PrivacyKeyIndex].skey[0], keylength); */ - memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[keyindex].skey[0], - keylength); + memcpy(&wepkey[3], &psecuritypriv->wep_key[keyindex].key, keylength); length = skb->len - prxattrib->hdrlen - prxattrib->iv_len; payload = pframe + prxattrib->iv_len + prxattrib->hdrlen; @@ -250,7 +249,7 @@ void rtw_wep_decrypt23a(struct rtw_adapter *padapter, *((u32 *)crc) = le32_to_cpu(getcrc32(payload, length - 4)); if (crc[3] != payload[length - 1] || crc[2] != payload[length - 2] || - crc[1] != payload[length - 3] || crc[0] != payload[length - 4]) { + crc[1] != payload[length - 3] || crc[0] != payload[length - 4]) { RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_wep_decrypt23a:icv error crc[3](%x)!= payload" "[length-1](%x) || crc[2](%x)!= payload[length-2](%x)" diff --git a/drivers/staging/rtl8723au/include/rtw_security.h b/drivers/staging/rtl8723au/include/rtw_security.h index e235ecd3e5e7..f44fd3334329 100644 --- a/drivers/staging/rtl8723au/include/rtw_security.h +++ b/drivers/staging/rtl8723au/include/rtw_security.h @@ -17,6 +17,7 @@ #include #include +#include #define is_wep_enc(alg) (alg == WLAN_CIPHER_SUITE_WEP40 || \ @@ -84,6 +85,10 @@ union Keytype { u32 lkey[4]; }; +struct rtw_wep_key { + u8 key[WLAN_KEY_LEN_WEP104 + 1]; /* 14 */ + u16 keylen; +}; struct rt_pmkid_list { u8 bUsed; @@ -104,8 +109,7 @@ struct security_priv { u32 dot11PrivacyKeyIndex; /* this is only valid for legendary * wep, 0~3 for key id. (tx key index) */ - union Keytype dot11DefKey[4]; /* this is only valid for def. key */ - u32 dot11DefKeylen[4]; + struct rtw_wep_key wep_key[NUM_WEP_KEYS]; u32 dot118021XGrpPrivacy; /* specify the privacy algthm. * used for Grp key diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index e5662a82debd..08d6b3472bf6 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -532,7 +532,7 @@ exit: return res; } -static int set_wep_key(struct rtw_adapter *padapter, u8 *key, u8 keylen, +static int set_wep_key(struct rtw_adapter *padapter, u8 *key, u16 keylen, u8 keyid) { u32 alg; @@ -556,7 +556,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, u32 param_len) { int ret = 0; - u32 wep_key_len; + u16 wep_key_len; u8 wep_key_idx; struct sta_info *psta = NULL, *pbcmc_sta = NULL; struct rtw_adapter *padapter = netdev_priv(dev); @@ -636,10 +636,10 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, psecuritypriv->dot11PrivacyKeyIndex = wep_key_idx; } - memcpy(&psecuritypriv->dot11DefKey[wep_key_idx].skey[0], + memcpy(&psecuritypriv->wep_key[wep_key_idx].key, param->u.crypt.key, wep_key_len); - psecuritypriv->dot11DefKeylen[wep_key_idx] = wep_key_len; + psecuritypriv->wep_key[wep_key_idx].keylen = wep_key_len; set_wep_key(padapter, param->u.crypt.key, wep_key_len, wep_key_idx); @@ -883,7 +883,8 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, struct ieee_param *param, u32 param_len) { int ret = 0; - u32 wep_key_idx, wep_key_len; + u32 wep_key_idx; + u16 wep_key_len; struct rtw_adapter *padapter = netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv *psecuritypriv = &padapter->securitypriv; @@ -942,10 +943,10 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, psecuritypriv->dot11PrivacyKeyIndex = wep_key_idx; } - memcpy(&psecuritypriv->dot11DefKey[wep_key_idx].skey[0], + memcpy(&psecuritypriv->wep_key[wep_key_idx].key, param->u.crypt.key, wep_key_len); - psecuritypriv->dot11DefKeylen[wep_key_idx] = wep_key_len; + psecuritypriv->wep_key[wep_key_idx].keylen = wep_key_len; rtw_set_key23a(padapter, psecuritypriv, wep_key_idx, 0); @@ -1201,9 +1202,9 @@ static int cfg80211_rtw_set_default_key(struct wiphy *wiphy, DBG_8723A("%s(%s): key_index =%d, unicast =%d, multicast =%d.\n", __func__, ndev->name, key_index, unicast, multicast); - if ((key_index < WEP_KEYS) && - ((psecuritypriv->dot11PrivacyAlgrthm == WLAN_CIPHER_SUITE_WEP40) || - (psecuritypriv->dot11PrivacyAlgrthm == WLAN_CIPHER_SUITE_WEP104))) { + if (key_index < NUM_WEP_KEYS && + (psecuritypriv->dot11PrivacyAlgrthm == WLAN_CIPHER_SUITE_WEP40 || + psecuritypriv->dot11PrivacyAlgrthm == WLAN_CIPHER_SUITE_WEP104)) { /* set wep default key */ psecuritypriv->ndisencryptstatus = Ndis802_11Encryption1Enabled; @@ -1211,9 +1212,11 @@ static int cfg80211_rtw_set_default_key(struct wiphy *wiphy, psecuritypriv->dot11PrivacyAlgrthm = WLAN_CIPHER_SUITE_WEP40; psecuritypriv->dot118021XGrpPrivacy = WLAN_CIPHER_SUITE_WEP40; - if (psecuritypriv->dot11DefKeylen[key_index] == 13) { - psecuritypriv->dot11PrivacyAlgrthm = WLAN_CIPHER_SUITE_WEP104; - psecuritypriv->dot118021XGrpPrivacy = WLAN_CIPHER_SUITE_WEP104; + if (psecuritypriv->wep_key[key_index].keylen == 13) { + psecuritypriv->dot11PrivacyAlgrthm = + WLAN_CIPHER_SUITE_WEP104; + psecuritypriv->dot118021XGrpPrivacy = + WLAN_CIPHER_SUITE_WEP104; } /* set the flag to represent that wep default key -- cgit v1.2.3 From 1e6e7f6030f3cec00641c5a356b5986723f33df6 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:36 +0200 Subject: staging: rtl8723au: Move rtw_set_802_11_add_wep23a() to ioctl_cfg80211.c This is only called from ioctl_cfg80211.c so we can move it here and declare it static. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ioctl_set.c | 76 ---------------------- drivers/staging/rtl8723au/include/rtw_ioctl_set.h | 2 - drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 77 ++++++++++++++++++++++- 3 files changed, 76 insertions(+), 79 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c index 19e2e68ff85c..99a662d83fc1 100644 --- a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c @@ -360,82 +360,6 @@ int rtw_set_802_11_authentication_mode23a(struct rtw_adapter* padapter, return res; } -int rtw_set_802_11_add_wep23a(struct rtw_adapter* padapter, - struct ndis_802_11_wep *wep) -{ - u8 bdefaultkey; - u8 btransmitkey; - int keyid, res; - struct security_priv *psecuritypriv = &padapter->securitypriv; - - bdefaultkey = (wep->KeyIndex & 0x40000000) > 0 ? false : true; - btransmitkey = (wep->KeyIndex & 0x80000000) > 0 ? true : false; - keyid = wep->KeyIndex & 0x3fffffff; - - if (keyid >= 4) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("MgntActrtw_set_802_11_add_wep23a:keyid>4 =>fail\n")); - res = _FAIL; - goto exit; - } - - switch (wep->KeyLength) - { - case 5: - psecuritypriv->dot11PrivacyAlgrthm = WLAN_CIPHER_SUITE_WEP40; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, - ("MgntActrtw_set_802_11_add_wep23a:wep->KeyLength = 5\n")); - break; - case 13: - psecuritypriv->dot11PrivacyAlgrthm = WLAN_CIPHER_SUITE_WEP104; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, - ("MgntActrtw_set_802_11_add_wep23a:wep->KeyLength = 13\n")); - break; - default: - psecuritypriv->dot11PrivacyAlgrthm = 0; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, - ("MgntActrtw_set_802_11_add_wep23a:wep->KeyLength!= 5 " - "or 13\n")); - res = _FAIL; - goto exit; - } - - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, - ("rtw_set_802_11_add_wep23a:befor memcpy, wep->KeyLength = 0x%x " - "wep->KeyIndex = 0x%x keyid =%x\n", - wep->KeyLength, wep->KeyIndex, keyid)); - - memcpy(&psecuritypriv->wep_key[keyid].key, &wep->KeyMaterial, - wep->KeyLength); - - psecuritypriv->wep_key[keyid].keylen = wep->KeyLength; - - psecuritypriv->dot11PrivacyKeyIndex = keyid; - - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, - ("rtw_set_802_11_add_wep23a:security key material : " - "%x %x %x %x %x %x %x %x %x %x %x %x %x\n", - psecuritypriv->wep_key[keyid].key[0], - psecuritypriv->wep_key[keyid].key[1], - psecuritypriv->wep_key[keyid].key[2], - psecuritypriv->wep_key[keyid].key[3], - psecuritypriv->wep_key[keyid].key[4], - psecuritypriv->wep_key[keyid].key[5], - psecuritypriv->wep_key[keyid].key[6], - psecuritypriv->wep_key[keyid].key[7], - psecuritypriv->wep_key[keyid].key[8], - psecuritypriv->wep_key[keyid].key[9], - psecuritypriv->wep_key[keyid].key[10], - psecuritypriv->wep_key[keyid].key[11], - psecuritypriv->wep_key[keyid].key[12])); - - res = rtw_set_key23a(padapter, psecuritypriv, keyid, 1); - -exit: - - return res; -} - /* * rtw_get_cur_max_rate23a - * @adapter: pointer to _adapter structure diff --git a/drivers/staging/rtl8723au/include/rtw_ioctl_set.h b/drivers/staging/rtl8723au/include/rtw_ioctl_set.h index 637f33b0c2dc..040543bff1b2 100644 --- a/drivers/staging/rtl8723au/include/rtw_ioctl_set.h +++ b/drivers/staging/rtl8723au/include/rtw_ioctl_set.h @@ -19,8 +19,6 @@ int rtw_set_802_11_authentication_mode23a(struct rtw_adapter *pdapter, enum ndis_802_11_auth_mode authmode); -int rtw_set_802_11_add_wep23a(struct rtw_adapter * padapter, - struct ndis_802_11_wep *wep); int rtw_set_802_11_bssid23a_list_scan(struct rtw_adapter *padapter, struct cfg80211_ssid *pssid, int ssid_max_num); diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 08d6b3472bf6..d89b400bc683 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -1935,6 +1935,81 @@ exit: return ret; } +static int rtw_cfg80211_add_wep(struct rtw_adapter* padapter, + struct ndis_802_11_wep *wep) +{ + u8 bdefaultkey; + u8 btransmitkey; + int keyid, res; + struct security_priv *psecuritypriv = &padapter->securitypriv; + + bdefaultkey = (wep->KeyIndex & 0x40000000) > 0 ? false : true; + btransmitkey = (wep->KeyIndex & 0x80000000) > 0 ? true : false; + keyid = wep->KeyIndex & 0x3fffffff; + + if (keyid >= 4) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("%s:keyid>4 =>fail\n", __func__)); + res = _FAIL; + goto exit; + } + + switch (wep->KeyLength) + { + case 5: + psecuritypriv->dot11PrivacyAlgrthm = WLAN_CIPHER_SUITE_WEP40; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, + ("%s:wep->KeyLength = 5\n", __func__)); + break; + case 13: + psecuritypriv->dot11PrivacyAlgrthm = WLAN_CIPHER_SUITE_WEP104; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, + ("%s:wep->KeyLength = 13\n", __func__)); + break; + default: + psecuritypriv->dot11PrivacyAlgrthm = 0; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, + ("%s:wep->KeyLength!= 5 or 13\n", __func__)); + res = _FAIL; + goto exit; + } + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, + ("%s:before memcpy, wep->KeyLength = 0x%x " + "wep->KeyIndex = 0x%x keyid =%x\n", __func__, + wep->KeyLength, wep->KeyIndex, keyid)); + + memcpy(&psecuritypriv->wep_key[keyid].key, &wep->KeyMaterial, + wep->KeyLength); + + psecuritypriv->wep_key[keyid].keylen = wep->KeyLength; + + psecuritypriv->dot11PrivacyKeyIndex = keyid; + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, + ("%s:security key material : " + "%x %x %x %x %x %x %x %x %x %x %x %x %x\n", __func__, + psecuritypriv->wep_key[keyid].key[0], + psecuritypriv->wep_key[keyid].key[1], + psecuritypriv->wep_key[keyid].key[2], + psecuritypriv->wep_key[keyid].key[3], + psecuritypriv->wep_key[keyid].key[4], + psecuritypriv->wep_key[keyid].key[5], + psecuritypriv->wep_key[keyid].key[6], + psecuritypriv->wep_key[keyid].key[7], + psecuritypriv->wep_key[keyid].key[8], + psecuritypriv->wep_key[keyid].key[9], + psecuritypriv->wep_key[keyid].key[10], + psecuritypriv->wep_key[keyid].key[11], + psecuritypriv->wep_key[keyid].key[12])); + + res = rtw_set_key23a(padapter, psecuritypriv, keyid, 1); + +exit: + + return res; +} + static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, struct cfg80211_connect_params *sme) { @@ -2152,7 +2227,7 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, memcpy(pwep->KeyMaterial, (void *)sme->key, pwep->KeyLength); - if (rtw_set_802_11_add_wep23a(padapter, pwep) != _SUCCESS) + if (rtw_cfg80211_add_wep(padapter, pwep) != _SUCCESS) ret = -EOPNOTSUPP; kfree(pwep); -- cgit v1.2.3 From 6893c8ebba521ea9d0f1cc4a53233fcb09271d52 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:37 +0200 Subject: staging: rtl8723au: rtw_cfg80211_add_wep(): Get rid of unused keyindex flags Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index d89b400bc683..bc27b590443a 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -1935,16 +1935,12 @@ exit: return ret; } -static int rtw_cfg80211_add_wep(struct rtw_adapter* padapter, +static int rtw_cfg80211_add_wep(struct rtw_adapter *padapter, struct ndis_802_11_wep *wep) { - u8 bdefaultkey; - u8 btransmitkey; int keyid, res; struct security_priv *psecuritypriv = &padapter->securitypriv; - bdefaultkey = (wep->KeyIndex & 0x40000000) > 0 ? false : true; - btransmitkey = (wep->KeyIndex & 0x80000000) > 0 ? true : false; keyid = wep->KeyIndex & 0x3fffffff; if (keyid >= 4) { @@ -2223,7 +2219,6 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, } pwep->KeyIndex = wep_key_idx; - pwep->KeyIndex |= 0x80000000; memcpy(pwep->KeyMaterial, (void *)sme->key, pwep->KeyLength); -- cgit v1.2.3 From deff11554fa4a0bf0f3616d29f0636ab5ff52758 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:38 +0200 Subject: staging: rtl8723au: Make rtw_cfg80211_add_wep() take a struct rtw_wep_key This allows the removal of the ugly struct ndis_8802_11_wep and simplify rtw_cfg80211_add_wep(). In addition remove unused element ndiswep from struct security_priv. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtw_security.h | 1 - drivers/staging/rtl8723au/include/wlan_bssdef.h | 7 --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 73 ++++++++--------------- 3 files changed, 26 insertions(+), 55 deletions(-) diff --git a/drivers/staging/rtl8723au/include/rtw_security.h b/drivers/staging/rtl8723au/include/rtw_security.h index f44fd3334329..8b8433365e32 100644 --- a/drivers/staging/rtl8723au/include/rtw_security.h +++ b/drivers/staging/rtl8723au/include/rtw_security.h @@ -142,7 +142,6 @@ struct security_priv { u32 ndisauthtype; /* enum ndis_802_11_auth_mode */ u32 ndisencryptstatus; /* NDIS_802_11_ENCRYPTION_STATUS */ struct wlan_bssid_ex sec_bss; /* for joinbss (h2c buffer) usage */ - struct ndis_802_11_wep ndiswep; u8 assoc_info[600]; u8 szofcapability[256]; /* for wpa2 usage */ u8 oidassociation[512]; /* for wpa/wpa2 usage */ diff --git a/drivers/staging/rtl8723au/include/wlan_bssdef.h b/drivers/staging/rtl8723au/include/wlan_bssdef.h index e6b225c7d5d5..76a4578d4bba 100644 --- a/drivers/staging/rtl8723au/include/wlan_bssdef.h +++ b/drivers/staging/rtl8723au/include/wlan_bssdef.h @@ -99,13 +99,6 @@ struct ndis_802_11_key { u8 KeyMaterial[32]; /* variable length depending on above field */ }; -struct ndis_802_11_wep { - u32 Length; /* Length of this structure */ - u32 KeyIndex; /* 0 is the per-client key, 1-N are global */ - u32 KeyLength; /* length of key in bytes */ - u8 KeyMaterial[16];/* variable length depending on above field */ -}; - enum NDIS_802_11_STATUS_TYPE { Ndis802_11StatusType_Authentication, Ndis802_11StatusType_MediaStreamMode, diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index bc27b590443a..c84ce00a717f 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -1936,22 +1936,19 @@ exit: } static int rtw_cfg80211_add_wep(struct rtw_adapter *padapter, - struct ndis_802_11_wep *wep) + struct rtw_wep_key *wep, u8 keyid) { - int keyid, res; + int res; struct security_priv *psecuritypriv = &padapter->securitypriv; - keyid = wep->KeyIndex & 0x3fffffff; - - if (keyid >= 4) { + if (keyid >= NUM_WEP_KEYS) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("%s:keyid>4 =>fail\n", __func__)); res = _FAIL; goto exit; } - switch (wep->KeyLength) - { + switch (wep->keylen) { case 5: psecuritypriv->dot11PrivacyAlgrthm = WLAN_CIPHER_SUITE_WEP40; RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, @@ -1971,14 +1968,10 @@ static int rtw_cfg80211_add_wep(struct rtw_adapter *padapter, } RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, - ("%s:before memcpy, wep->KeyLength = 0x%x " - "wep->KeyIndex = 0x%x keyid =%x\n", __func__, - wep->KeyLength, wep->KeyIndex, keyid)); - - memcpy(&psecuritypriv->wep_key[keyid].key, &wep->KeyMaterial, - wep->KeyLength); + ("%s:before memcpy, wep->KeyLength = 0x%x keyid =%x\n", + __func__, wep->keylen, keyid)); - psecuritypriv->wep_key[keyid].keylen = wep->KeyLength; + memcpy(&psecuritypriv->wep_key[keyid], wep, sizeof(struct rtw_wep_key)); psecuritypriv->dot11PrivacyKeyIndex = keyid; @@ -2176,57 +2169,43 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, if ((psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_Shared || psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_Auto) && sme->key) { - u32 wep_key_idx, wep_key_len, wep_total_len; - struct ndis_802_11_wep *pwep = NULL; + struct rtw_wep_key wep_key; + u8 wep_key_idx, wep_key_len; DBG_8723A("%s(): Shared/Auto WEP\n", __func__); wep_key_idx = sme->key_idx; wep_key_len = sme->key_len; - if (sme->key_idx > WEP_KEYS) { + if (wep_key_idx > WEP_KEYS || !wep_key_len || + wep_key_len > WLAN_KEY_LEN_WEP104) { ret = -EINVAL; goto exit; } - if (wep_key_len > 0) { - wep_key_len = wep_key_len <= 5 ? 5 : 13; - wep_total_len = - wep_key_len + - offsetof(struct ndis_802_11_wep, KeyMaterial); - pwep = (struct ndis_802_11_wep *)kmalloc(wep_total_len, - GFP_KERNEL); - if (pwep == NULL) { - DBG_8723A(" wpa_set_encryption: pwep " - "allocate fail !!!\n"); - ret = -ENOMEM; - goto exit; - } + wep_key_len = wep_key_len <= 5 ? 5 : 13; - memset(pwep, 0, wep_total_len); + memset(&wep_key, 0, sizeof(struct rtw_wep_key)); - pwep->KeyLength = wep_key_len; - pwep->Length = wep_total_len; + wep_key.keylen = wep_key_len; - if (wep_key_len == 13) { - padapter->securitypriv.dot11PrivacyAlgrthm = - WLAN_CIPHER_SUITE_WEP104; - padapter->securitypriv.dot118021XGrpPrivacy = - WLAN_CIPHER_SUITE_WEP104; - } + if (wep_key_len == 13) { + padapter->securitypriv.dot11PrivacyAlgrthm = + WLAN_CIPHER_SUITE_WEP104; + padapter->securitypriv.dot118021XGrpPrivacy = + WLAN_CIPHER_SUITE_WEP104; } else { - ret = -EINVAL; - goto exit; + padapter->securitypriv.dot11PrivacyAlgrthm = + WLAN_CIPHER_SUITE_WEP40; + padapter->securitypriv.dot118021XGrpPrivacy = + WLAN_CIPHER_SUITE_WEP40; } - pwep->KeyIndex = wep_key_idx; - - memcpy(pwep->KeyMaterial, (void *)sme->key, pwep->KeyLength); + memcpy(wep_key.key, (void *)sme->key, wep_key.keylen); - if (rtw_cfg80211_add_wep(padapter, pwep) != _SUCCESS) + if (rtw_cfg80211_add_wep(padapter, &wep_key, wep_key_idx) != + _SUCCESS) ret = -EOPNOTSUPP; - kfree(pwep); - if (ret < 0) goto exit; } -- cgit v1.2.3 From 9a3c056873ccb0286ab1fdf2e6c6a99f28b1b5c7 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:39 +0200 Subject: staging: rtl8723au: Get rid of unused struct ndis_802_11_configuration_fh Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 5 ----- drivers/staging/rtl8723au/include/wlan_bssdef.h | 9 --------- 2 files changed, 14 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 5dace9b9e830..6ae6521c4858 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -2124,11 +2124,6 @@ void rtw_init_registrypriv_dev_network23a(struct rtw_adapter* adapter) pdev_network->Configuration.Length=sizeof(struct ndis_802_11_config); pdev_network->Configuration.BeaconPeriod = 100; - pdev_network->Configuration.FHConfig.Length = 0; - pdev_network->Configuration.FHConfig.HopPattern = 0; - pdev_network->Configuration.FHConfig.HopSet = 0; - pdev_network->Configuration.FHConfig.DwellTime = 0; - } void rtw_update_registrypriv_dev_network23a(struct rtw_adapter* adapter) diff --git a/drivers/staging/rtl8723au/include/wlan_bssdef.h b/drivers/staging/rtl8723au/include/wlan_bssdef.h index 76a4578d4bba..2b913b8e546f 100644 --- a/drivers/staging/rtl8723au/include/wlan_bssdef.h +++ b/drivers/staging/rtl8723au/include/wlan_bssdef.h @@ -22,14 +22,6 @@ #define NDIS_802_11_LENGTH_RATES 8 #define NDIS_802_11_LENGTH_RATES_EX 16 -struct ndis_802_11_configuration_fh { - u32 Length; /* Length of structure */ - u32 HopPattern; /* As defined by 802.11, MSB set */ - u32 HopSet; /* to one if non-802.11 */ - u32 DwellTime; /* units are Kusec */ -}; - - /* FW will only save the channel number in DSConfig. ODI Handler will convert the channel number to freq. number. @@ -39,7 +31,6 @@ struct ndis_802_11_config { u32 BeaconPeriod; /* units are Kusec */ u32 ATIMWindow; /* units are Kusec */ u32 DSConfig; /* Frequency, units are kHz */ - struct ndis_802_11_configuration_fh FHConfig; }; struct ndis_802_11_fixed_ies { -- cgit v1.2.3 From 37cb982c2685029e716bfeccf55ec244a6919a32 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:40 +0200 Subject: staging: rtl8723au: Get rid of struct ndis_802_11_config This exposed a nice endian bug in collect_bss_info23a() where two bytes in little-endian order were copied into a u32 and afterwards le32_to_cpu() was applied to it.... Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 13 +++---- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 8 ++-- drivers/staging/rtl8723au/core/rtw_mlme.c | 18 ++++----- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 46 ++++++++++------------- drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 6 +-- drivers/staging/rtl8723au/include/wlan_bssdef.h | 15 ++------ drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 6 +-- 7 files changed, 46 insertions(+), 66 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index ad9198367ccc..e86e5f892c58 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -391,7 +391,7 @@ void add_RATid23a(struct rtw_adapter *padapter, struct sta_info *psta, u8 rssi_l shortGIrate = psta_ht->sgi; } - if (pcur_network->Configuration.DSConfig > 14) { + if (pcur_network->DSConfig > 14) { /* 5G band */ if (tx_ra_bitmap & 0xffff000) sta_band |= WIRELESS_11_5N | WIRELESS_11A; @@ -484,7 +484,7 @@ static void update_bmc_sta(struct rtw_adapter *padapter) tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value23a(psta->bssrateset[i]&0x7f); } - if (pcur_network->Configuration.DSConfig > 14) { + if (pcur_network->DSConfig > 14) { /* force to A mode. 5G doesn't support CCK rates */ network_type = WIRELESS_11A; tx_ra_bitmap = 0x150; /* 6, 12, 24 Mbps */ @@ -653,8 +653,8 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) struct wlan_bssid_ex *pnetwork_mlmeext = &pmlmeinfo->network; struct HT_info_element *pht_info = NULL; - bcn_interval = (u16)pnetwork->Configuration.BeaconPeriod; - cur_channel = pnetwork->Configuration.DSConfig; + bcn_interval = (u16)pnetwork->BeaconPeriod; + cur_channel = pnetwork->DSConfig; cur_bwmode = HT_CHANNEL_WIDTH_20;; cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; @@ -838,7 +838,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, /* beacon interval */ /* ie + 8; 8: TimeStamp, 2: Beacon Interval 2:Capability */ pbeacon = rtw_get_beacon_interval23a_from_ie(ie); - pbss_network->Configuration.BeaconPeriod = get_unaligned_le16(pbeacon); + pbss_network->BeaconPeriod = get_unaligned_le16(pbeacon); /* capability */ cap = get_unaligned_le16(ie); @@ -854,13 +854,12 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, /* chnnel */ channel = 0; - pbss_network->Configuration.Length = 0; p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_DS_PARAMS, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); if (p && ie_len > 0) channel = *(p + 2); - pbss_network->Configuration.DSConfig = channel; + pbss_network->DSConfig = channel; memset(supportRate, 0, NDIS_802_11_LENGTH_RATES_EX); /* get supported rates */ diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index 78607fc5c862..9ee05df39976 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -395,7 +395,7 @@ int rtw_generate_ie23a(struct registry_priv *pregistrypriv) /* beacon interval : 2bytes */ /* BCN_INTERVAL; */ - *(u16*)ie = cpu_to_le16((u16)pdev_network->Configuration.BeaconPeriod); + *(u16*)ie = cpu_to_le16(pdev_network->BeaconPeriod); sz += 2; ie += 2; @@ -419,7 +419,7 @@ int rtw_generate_ie23a(struct registry_priv *pregistrypriv) /* supported rates */ if (pregistrypriv->wireless_mode == WIRELESS_11ABGN) { - if (pdev_network->Configuration.DSConfig > 14) + if (pdev_network->DSConfig > 14) wireless_mode = WIRELESS_11A_5N; else wireless_mode = WIRELESS_11BG_24N; @@ -442,12 +442,12 @@ int rtw_generate_ie23a(struct registry_priv *pregistrypriv) /* DS parameter set */ ie = rtw_set_ie23a(ie, WLAN_EID_DS_PARAMS, 1, - (u8 *)&pdev_network->Configuration.DSConfig, &sz); + (u8 *)&pdev_network->DSConfig, &sz); /* IBSS Parameter Set */ ie = rtw_set_ie23a(ie, WLAN_EID_IBSS_PARAMS, 2, - (u8 *)&pdev_network->Configuration.ATIMWindow, &sz); + (u8 *)&pdev_network->ATIMWindow, &sz); if (rateLen > 8) { ie = rtw_set_ie23a(ie, WLAN_EID_EXT_SUPP_RATES, (rateLen - 8), diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 6ae6521c4858..40a3d6ff4a6c 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -367,7 +367,7 @@ int is_same_network23a(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst) d_cap = get_unaligned_le16(rtw_get_capability23a_from_ie(dst->IEs)); return ((src->Ssid.ssid_len == dst->Ssid.ssid_len) && - /* (src->Configuration.DSConfig == dst->Configuration.DSConfig) && */ + /* (src->DSConfig == dst->DSConfig) && */ ether_addr_equal(src->MacAddress, dst->MacAddress) && ((!memcmp(src->Ssid.ssid, dst->Ssid.ssid, src->Ssid.ssid_len))) && ((s_cap & WLAN_CAPABILITY_IBSS) == @@ -416,7 +416,7 @@ void update_network23a(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, DBG_8723A("%s %s(%pM, ch%u) ss_ori:%3u, sq_ori:%3u, rssi_ori:%3ld, " "ss_smp:%3u, sq_smp:%3u, rssi_smp:%3ld\n", __func__, src->Ssid.ssid, src->MacAddress, - src->Configuration.DSConfig, ss_ori, sq_ori, rssi_ori, + src->DSConfig, ss_ori, sq_ori, rssi_ori, ss_smp, sq_smp, rssi_smp ); @@ -1795,7 +1795,7 @@ int rtw_select_and_join_from_scanned_queue23a(struct mlme_priv *pmlmepriv) DBG_8723A("%s: candidate: %s("MAC_FMT", ch:%u)\n", __func__, candidate->network.Ssid.ssid, MAC_ARG(candidate->network.MacAddress), - candidate->network.Configuration.DSConfig); + candidate->network.DSConfig); } /* check for situation of _FW_LINKED */ @@ -2122,8 +2122,7 @@ void rtw_init_registrypriv_dev_network23a(struct rtw_adapter* adapter) memcpy(&pdev_network->Ssid, &pregistrypriv->ssid, sizeof(struct cfg80211_ssid)); - pdev_network->Configuration.Length=sizeof(struct ndis_802_11_config); - pdev_network->Configuration.BeaconPeriod = 100; + pdev_network->BeaconPeriod = 100; } void rtw_update_registrypriv_dev_network23a(struct rtw_adapter* adapter) @@ -2140,14 +2139,13 @@ void rtw_update_registrypriv_dev_network23a(struct rtw_adapter* adapter) pdev_network->Rssi = 0; - pdev_network->Configuration.DSConfig = pregistrypriv->channel; + pdev_network->DSConfig = pregistrypriv->channel; RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("pregistrypriv->channel =%d, pdev_network->Configuration." - "DSConfig = 0x%x\n", pregistrypriv->channel, - pdev_network->Configuration.DSConfig)); + ("pregistrypriv->channel =%d, pdev_network->DSConfig = 0x%x\n", + pregistrypriv->channel, pdev_network->DSConfig)); if (cur_network->network.ifmode == NL80211_IFTYPE_ADHOC) - pdev_network->Configuration.ATIMWindow = 0; + pdev_network->ATIMWindow = 0; pdev_network->ifmode = cur_network->network.ifmode; diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index dd6c7fac41a0..41ca73ca0349 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -2536,15 +2536,14 @@ void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms) /* DS parameter set */ pframe = rtw_set_ie23a(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *) - &cur_network->Configuration.DSConfig, - &pattrib->pktlen); + &cur_network->DSConfig, &pattrib->pktlen); /* if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) */ { u8 erpinfo = 0; u32 ATIMWindow; /* IBSS Parameter Set... */ - /* ATIMWindow = cur->Configuration.ATIMWindow; */ + /* ATIMWindow = cur->ATIMWindow; */ ATIMWindow = 0; pframe = rtw_set_ie23a(pframe, WLAN_EID_IBSS_PARAMS, 2, (unsigned char *)&ATIMWindow, @@ -2766,15 +2765,14 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, /* DS parameter set */ pframe = rtw_set_ie23a(pframe, WLAN_EID_DS_PARAMS, 1, - (unsigned char *) - &cur_network->Configuration.DSConfig, + (unsigned char *)&cur_network->DSConfig, &pattrib->pktlen); if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { u8 erpinfo = 0; u32 ATIMWindow; /* IBSS Parameter Set... */ - /* ATIMWindow = cur->Configuration.ATIMWindow; */ + /* ATIMWindow = cur->ATIMWindow; */ ATIMWindow = 0; pframe = rtw_set_ie23a(pframe, WLAN_EID_IBSS_PARAMS, 2, (unsigned char *)&ATIMWindow, @@ -4231,11 +4229,11 @@ static void issue_action_BSSCoexistPacket(struct rtw_adapter *padapter) pbss_network->IEs + _FIXED_IE_LENGTH_, pbss_network->IELength -_FIXED_IE_LENGTH_); if (!p || !p[1]) { /* non-HT */ - if (pbss_network->Configuration.DSConfig <= 0 || - pbss_network->Configuration.DSConfig > 14) + if (pbss_network->DSConfig <= 0 || + pbss_network->DSConfig > 14) continue; - ICS[0][pbss_network->Configuration.DSConfig] = 1; + ICS[0][pbss_network->DSConfig] = 1; if (ICS[0][0] == 0) ICS[0][0] = 1; @@ -4571,11 +4569,10 @@ int collect_bss_info23a(struct rtw_adapter *padapter, p = cfg80211_find_ie(WLAN_EID_DS_PARAMS, bssid->IEs + ie_offset, bssid->IELength - ie_offset); - bssid->Configuration.DSConfig = 0; - bssid->Configuration.Length = 0; + bssid->DSConfig = 0; if (p) { - bssid->Configuration.DSConfig = p[2]; + bssid->DSConfig = p[2]; } else {/* In 5G, some ap do not have DSSET IE */ /* checking HT info for channel */ p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, @@ -4584,12 +4581,9 @@ int collect_bss_info23a(struct rtw_adapter *padapter, if (p) { struct HT_info_element *HT_info = (struct HT_info_element *)(p + 2); - bssid->Configuration.DSConfig = - HT_info->primary_channel; - } else { /* use current channel */ - bssid->Configuration.DSConfig = - rtw_get_oper_ch23a(padapter); - } + bssid->DSConfig = HT_info->primary_channel; + } else /* use current channel */ + bssid->DSConfig = rtw_get_oper_ch23a(padapter); } if (ieee80211_is_probe_req(mgmt->frame_control)) { @@ -4600,10 +4594,8 @@ int collect_bss_info23a(struct rtw_adapter *padapter, return _SUCCESS; } - memcpy(&bssid->Configuration.BeaconPeriod, - rtw_get_beacon_interval23a_from_ie(bssid->IEs), 2); - bssid->Configuration.BeaconPeriod = - le32_to_cpu(bssid->Configuration.BeaconPeriod); + bssid->BeaconPeriod = get_unaligned_le16( + rtw_get_beacon_interval23a_from_ie(bssid->IEs)); if (capab_info & BIT(0)) { bssid->ifmode = NL80211_IFTYPE_STATION; @@ -4618,7 +4610,7 @@ int collect_bss_info23a(struct rtw_adapter *padapter, else bssid->Privacy = 0; - bssid->Configuration.ATIMWindow = 0; + bssid->ATIMWindow = 0; /* 20/40 BSS Coexistence check */ if (pregistrypriv->wifi_spec == 1 && @@ -4640,7 +4632,7 @@ int collect_bss_info23a(struct rtw_adapter *padapter, /* mark bss info receving from nearby channel as SignalQuality 101 */ - if (bssid->Configuration.DSConfig != rtw_get_oper_ch23a(padapter)) + if (bssid->DSConfig != rtw_get_oper_ch23a(padapter)) bssid->PhyInfo.SignalQuality = 101; return _SUCCESS; @@ -4652,7 +4644,7 @@ void start_create_ibss23a(struct rtw_adapter* padapter) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; - pmlmeext->cur_channel = (u8)pnetwork->Configuration.DSConfig; + pmlmeext->cur_channel = (u8)pnetwork->DSConfig; pmlmeinfo->bcn_interval = get_beacon_interval23a(pnetwork); /* update wireless mode */ @@ -4707,7 +4699,7 @@ void start_clnt_join23a(struct rtw_adapter* padapter) struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; int beacon_timeout; - pmlmeext->cur_channel = (u8)pnetwork->Configuration.DSConfig; + pmlmeext->cur_channel = (u8)pnetwork->DSConfig; pmlmeinfo->bcn_interval = get_beacon_interval23a(pnetwork); /* update wireless mode */ @@ -5035,7 +5027,7 @@ static void process_80211d(struct rtw_adapter *padapter, } /* If channel is used by AP, set channel scan type to active */ - channel = bssid->Configuration.DSConfig; + channel = bssid->DSConfig; chplan_new = pmlmeext->channel_set; i = 0; while (i < MAX_CHANNEL_NUM && chplan_new[i].ChannelNum != 0) { diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c index 54ef5dc30b78..457ce921a2c7 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c @@ -267,15 +267,15 @@ static void ConstructBeacon(struct rtw_adapter *padapter, u8 *pframe, u32 *pLeng /* DS parameter set */ pframe = rtw_set_ie23a(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *) - &cur_network->Configuration.DSConfig, &pktlen); + &cur_network->DSConfig, &pktlen); if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { u32 ATIMWindow; /* IBSS Parameter Set... */ - /* ATIMWindow = cur->Configuration.ATIMWindow; */ + /* ATIMWindow = cur->ATIMWindow; */ ATIMWindow = 0; pframe = rtw_set_ie23a(pframe, WLAN_EID_IBSS_PARAMS, 2, - (unsigned char *)(&ATIMWindow), &pktlen); + (unsigned char *)&ATIMWindow, &pktlen); } /* todo: ERP IE */ diff --git a/drivers/staging/rtl8723au/include/wlan_bssdef.h b/drivers/staging/rtl8723au/include/wlan_bssdef.h index 2b913b8e546f..3c330f370cc7 100644 --- a/drivers/staging/rtl8723au/include/wlan_bssdef.h +++ b/drivers/staging/rtl8723au/include/wlan_bssdef.h @@ -22,17 +22,6 @@ #define NDIS_802_11_LENGTH_RATES 8 #define NDIS_802_11_LENGTH_RATES_EX 16 -/* - FW will only save the channel number in DSConfig. - ODI Handler will convert the channel number to freq. number. -*/ -struct ndis_802_11_config { - u32 Length; /* Length of structure */ - u32 BeaconPeriod; /* units are Kusec */ - u32 ATIMWindow; /* units are Kusec */ - u32 DSConfig; /* Frequency, units are kHz */ -}; - struct ndis_802_11_fixed_ies { u8 Timestamp[8]; u16 BeaconInterval; @@ -134,7 +123,9 @@ struct wlan_bssid_ex { struct cfg80211_ssid Ssid; u32 Privacy; long Rssi;/* in dBM, raw data , get from PHY) */ - struct ndis_802_11_config Configuration; + u16 BeaconPeriod; /* units are Kusec */ + u32 ATIMWindow; /* units are Kusec */ + u32 DSConfig; /* Frequency, units are kHz */ enum nl80211_iftype ifmode; unsigned char SupportedRates[NDIS_802_11_LENGTH_RATES_EX]; struct wlan_phy_info PhyInfo; diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index c84ce00a717f..6a99dafa8f8c 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -276,7 +276,7 @@ static int rtw_cfg80211_inform_bss(struct rtw_adapter *padapter, goto exit; } - channel = pnetwork->network.Configuration.DSConfig; + channel = pnetwork->network.DSConfig; if (channel <= RTW_CH_MAX_2G_CHANNEL) freq = ieee80211_channel_to_frequency(channel, IEEE80211_BAND_2GHZ); @@ -367,7 +367,7 @@ void rtw_cfg80211_indicate_connect(struct rtw_adapter *padapter) struct wiphy *wiphy = pwdev->wiphy; struct ieee80211_channel *notify_channel; u32 freq; - u16 channel = cur_network->network.Configuration.DSConfig; + u16 channel = cur_network->network.DSConfig; if (channel <= RTW_CH_MAX_2G_CHANNEL) freq = @@ -1475,7 +1475,7 @@ void rtw_cfg80211_surveydone_event_callback(struct rtw_adapter *padapter) contains the channel to which this network belongs */ if (rtw_ch_set_search_ch23a (padapter->mlmeextpriv.channel_set, - pnetwork->network.Configuration.DSConfig) >= 0) + pnetwork->network.DSConfig) >= 0) rtw_cfg80211_inform_bss(padapter, pnetwork); } -- cgit v1.2.3 From c164bcff6832766593125b4b9e150e1dce76728a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:41 +0200 Subject: staging: rtli8723au: Get rid of struct ndis_802_11_fixed_ies Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 10 +++++---- drivers/staging/rtl8723au/core/rtw_mlme.c | 22 ++++++++++++++----- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 20 +++++++++++------- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 28 ++++++++++++++++++------- drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 9 ++++++-- drivers/staging/rtl8723au/include/wlan_bssdef.h | 6 ------ 6 files changed, 62 insertions(+), 33 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index e86e5f892c58..878d2b525af0 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -652,6 +652,7 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *pnetwork_mlmeext = &pmlmeinfo->network; struct HT_info_element *pht_info = NULL; + int bcn_fixed_size; bcn_interval = (u16)pnetwork->BeaconPeriod; cur_channel = pnetwork->DSConfig; @@ -723,11 +724,12 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) DYNAMIC_ALL_FUNC_ENABLE); } /* set channel, bwmode */ + bcn_fixed_size = offsetof(struct ieee80211_mgmt, u.beacon.variable) - + offsetof(struct ieee80211_mgmt, u.beacon); + p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, - pnetwork->IEs + - sizeof(struct ndis_802_11_fixed_ies), - pnetwork->IELength - - sizeof(struct ndis_802_11_fixed_ies)); + pnetwork->IEs + bcn_fixed_size, + pnetwork->IELength - bcn_fixed_size); if (p && p[1]) { pht_info = (struct HT_info_element *)(p + 2); diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 40a3d6ff4a6c..da254855e507 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -469,11 +469,16 @@ static void update_current_network(struct rtw_adapter *adapter, if (check_fwstate(pmlmepriv, _FW_LINKED) && is_same_network23a(&pmlmepriv->cur_network.network, pnetwork)) { + int bcn_size; update_network23a(&pmlmepriv->cur_network.network, pnetwork,adapter, true); + + bcn_size = offsetof(struct ieee80211_mgmt, u.beacon.variable) - + offsetof(struct ieee80211_mgmt, u.beacon); + rtw_update_protection23a(adapter, pmlmepriv->cur_network.network.IEs + - sizeof (struct ndis_802_11_fixed_ies), + bcn_size, pmlmepriv->cur_network.network.IELength); } } @@ -1101,6 +1106,7 @@ rtw_joinbss_update_network23a(struct rtw_adapter *padapter, { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_network *cur_network = &pmlmepriv->cur_network; + int bcn_size; DBG_8723A("%s\n", __func__); @@ -1153,9 +1159,11 @@ rtw_joinbss_update_network23a(struct rtw_adapter *padapter, break; } + bcn_size = offsetof(struct ieee80211_mgmt, u.beacon.variable) - + offsetof(struct ieee80211_mgmt, u.beacon); + rtw_update_protection23a(padapter, cur_network->network.IEs + - sizeof (struct ndis_802_11_fixed_ies), - cur_network->network.IELength); + bcn_size, cur_network->network.IELength); rtw_update_ht_cap23a(padapter, cur_network->network.IEs, cur_network->network.IELength); @@ -2282,6 +2290,7 @@ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len) struct registry_priv *pregistrypriv = &padapter->registrypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + int bcn_fixed_size; if (!phtpriv->ht_option) return; @@ -2291,9 +2300,12 @@ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len) DBG_8723A("+rtw_update_ht_cap23a()\n"); + bcn_fixed_size = offsetof(struct ieee80211_mgmt, u.beacon.variable) - + offsetof(struct ieee80211_mgmt, u.beacon); + /* Adjust pie + ie_len for our searches */ - pie += sizeof (struct ndis_802_11_fixed_ies); - ie_len -= sizeof (struct ndis_802_11_fixed_ies); + pie += bcn_fixed_size; + ie_len -= bcn_fixed_size; /* maybe needs check if ap supports rx ampdu. */ if (phtpriv->ampdu_enable == false && diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 41ca73ca0349..8c73fed9b4fd 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -3278,7 +3278,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - int bssrate_len = 0, sta_bssrate_len = 0, pie_len; + int bssrate_len = 0, sta_bssrate_len = 0, pie_len, bcn_fixed_size; u8 * pie; pmgntframe = alloc_mgtxmitframe23a(pxmitpriv); @@ -3393,9 +3393,11 @@ void issue_assocreq23a(struct rtw_adapter *padapter) bssrate_len, bssrate, &pattrib->pktlen); /* RSN */ - pie = pmlmeinfo->network.IEs + sizeof(struct ndis_802_11_fixed_ies); - pie_len = pmlmeinfo->network.IELength - - sizeof(struct ndis_802_11_fixed_ies); + bcn_fixed_size = offsetof(struct ieee80211_mgmt, u.beacon.variable) - + offsetof(struct ieee80211_mgmt, u.beacon); + + pie = pmlmeinfo->network.IEs + bcn_fixed_size; + pie_len = pmlmeinfo->network.IELength - bcn_fixed_size; p = cfg80211_find_ie(WLAN_EID_RSN, pie, pie_len); if (p) @@ -3471,8 +3473,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) } /* vendor specific IE, such as WPA, WMM, WPS */ - for (i = sizeof(struct ndis_802_11_fixed_ies); - i < pmlmeinfo->network.IELength;) { + for (i = bcn_fixed_size; i < pmlmeinfo->network.IELength;) { pIE = (struct ndis_802_11_var_ies *) (pmlmeinfo->network.IEs + i); @@ -5900,6 +5901,7 @@ int join_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) const struct wlan_bssid_ex *pparm = (struct wlan_bssid_ex *)pbuf; struct HT_info_element *pht_info; u32 i; + int bcn_fixed_size; /* u32 initialgain; */ /* u32 acparm; */ @@ -5945,8 +5947,10 @@ int join_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) /* pmlmeinfo->assoc_AP_vendor = check_assoc_AP23a(pnetwork->IEs, pnetwork->IELength); */ - for (i = sizeof(struct ndis_802_11_fixed_ies); i < pnetwork->IELength;) - { + bcn_fixed_size = offsetof(struct ieee80211_mgmt, u.beacon.variable) - + offsetof(struct ieee80211_mgmt, u.beacon); + + for (i = bcn_fixed_size; i < pnetwork->IELength;) { pIE = (struct ndis_802_11_var_ies *)(pnetwork->IEs + i); switch (pIE->ElementID) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index c4c47164b990..ce73cbecd20b 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -1173,10 +1173,13 @@ bool is_ap_in_tkip23a(struct rtw_adapter *padapter) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; + int bcn_fixed_size; + + bcn_fixed_size = offsetof(struct ieee80211_mgmt, u.beacon.variable) - + offsetof(struct ieee80211_mgmt, u.beacon); if (rtw_get_capability23a(cur_network) & WLAN_CAPABILITY_PRIVACY) { - for (i = sizeof(struct ndis_802_11_fixed_ies); - i < pmlmeinfo->network.IELength;) { + for (i = bcn_fixed_size; i < pmlmeinfo->network.IELength;) { pIE = (struct ndis_802_11_var_ies *) (pmlmeinfo->network.IEs + i); @@ -1207,10 +1210,13 @@ bool should_forbid_n_rate23a(struct rtw_adapter * padapter) struct ndis_802_11_var_ies *pIE; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_bssid_ex *cur_network = &pmlmepriv->cur_network.network; + int bcn_fixed_size; + + bcn_fixed_size = offsetof(struct ieee80211_mgmt, u.beacon.variable) - + offsetof(struct ieee80211_mgmt, u.beacon); if (rtw_get_capability23a(cur_network) & WLAN_CAPABILITY_PRIVACY) { - for (i = sizeof(struct ndis_802_11_fixed_ies); - i < cur_network->IELength;) { + for (i = bcn_fixed_size; i < cur_network->IELength;) { pIE = (struct ndis_802_11_var_ies *) (cur_network->IEs + i); @@ -1248,10 +1254,13 @@ bool is_ap_in_wep23a(struct rtw_adapter *padapter) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; + int bcn_fixed_size; + + bcn_fixed_size = offsetof(struct ieee80211_mgmt, u.beacon.variable) - + offsetof(struct ieee80211_mgmt, u.beacon); if (rtw_get_capability23a(cur_network) & WLAN_CAPABILITY_PRIVACY) { - for (i = sizeof(struct ndis_802_11_fixed_ies); - i < pmlmeinfo->network.IELength;) { + for (i = bcn_fixed_size; i < pmlmeinfo->network.IELength;) { pIE = (struct ndis_802_11_var_ies *) (pmlmeinfo->network.IEs + i); @@ -1432,14 +1441,17 @@ void update_tx_basic_rate23a(struct rtw_adapter *padapter, u8 wirelessmode) unsigned char check_assoc_AP23a(u8 *pframe, uint len) { - unsigned int i; + int i, bcn_fixed_size; struct ndis_802_11_var_ies *pIE; u8 epigram_vendor_flag; u8 ralink_vendor_flag; epigram_vendor_flag = 0; ralink_vendor_flag = 0; - for (i = sizeof(struct ndis_802_11_fixed_ies); i < len;) { + bcn_fixed_size = offsetof(struct ieee80211_mgmt, u.beacon.variable) - + offsetof(struct ieee80211_mgmt, u.beacon); + + for (i = bcn_fixed_size; i < len;) { pIE = (struct ndis_802_11_var_ies *)(pframe + i); switch (pIE->ElementID) { diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c index 457ce921a2c7..11660622d6b2 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c @@ -210,6 +210,7 @@ static void ConstructBeacon(struct rtw_adapter *padapter, u8 *pframe, u32 *pLeng struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + int bcn_fixed_size; /* DBG_8723A("%s\n", __FUNCTION__); */ @@ -246,9 +247,13 @@ static void ConstructBeacon(struct rtw_adapter *padapter, u8 *pframe, u32 *pLeng pktlen += 2; if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { + bcn_fixed_size = + offsetof(struct ieee80211_mgmt, u.beacon.variable) - + offsetof(struct ieee80211_mgmt, u.beacon); + /* DBG_8723A("ie len =%d\n", cur_network->IELength); */ - pktlen += cur_network->IELength - sizeof(struct ndis_802_11_fixed_ies); - memcpy(pframe, cur_network->IEs+sizeof(struct ndis_802_11_fixed_ies), pktlen); + pktlen += cur_network->IELength - bcn_fixed_size; + memcpy(pframe, cur_network->IEs + bcn_fixed_size, pktlen); goto _ConstructBeacon; } diff --git a/drivers/staging/rtl8723au/include/wlan_bssdef.h b/drivers/staging/rtl8723au/include/wlan_bssdef.h index 3c330f370cc7..c0dfcda689b8 100644 --- a/drivers/staging/rtl8723au/include/wlan_bssdef.h +++ b/drivers/staging/rtl8723au/include/wlan_bssdef.h @@ -22,12 +22,6 @@ #define NDIS_802_11_LENGTH_RATES 8 #define NDIS_802_11_LENGTH_RATES_EX 16 -struct ndis_802_11_fixed_ies { - u8 Timestamp[8]; - u16 BeaconInterval; - u16 Capabilities; -}; - struct ndis_802_11_var_ies { u8 ElementID; u8 Length; -- cgit v1.2.3 From b171da3c6ee98f170b1064319095b9516851a757 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:42 +0200 Subject: staging: rtl8723au: Get rid of struct ndis_802_11_var_ies Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 23 ++-- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 55 +++++---- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 143 +++++++++++------------ drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 12 +- drivers/staging/rtl8723au/include/wlan_bssdef.h | 6 - 5 files changed, 108 insertions(+), 131 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 878d2b525af0..0f21e2c1e538 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -889,7 +889,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_ERP_INFO, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); if (p && ie_len > 0) - ERP_IE_handler23a(padapter, (struct ndis_802_11_var_ies *)p); + ERP_IE_handler23a(padapter, p); /* update privacy/security */ if (cap & BIT(4)) @@ -1024,9 +1024,9 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, if (pregistrypriv->ampdu_enable == 1) pmlmepriv->htpriv.ampdu_enable = true; - HT_caps_handler23a(padapter, (struct ndis_802_11_var_ies *)pHT_caps_ie); + HT_caps_handler23a(padapter, pHT_caps_ie); - HT_info_handler23a(padapter, (struct ndis_802_11_var_ies *)pHT_info_ie); + HT_info_handler23a(padapter, pHT_info_ie); } pbss_network->Length = get_wlan_bssid_ex_sz(pbss_network); @@ -1182,23 +1182,20 @@ static void update_bcn_erpinfo_ie(struct rtw_adapter *padapter) /* parsing ERP_IE */ p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_ERP_INFO, &len, (pnetwork->IELength - _BEACON_IE_OFFSET_)); - if (p && len>0) - { - struct ndis_802_11_var_ies * pIE = (struct ndis_802_11_var_ies *)p; - + if (p && len > 0) { if (pmlmepriv->num_sta_non_erp == 1) - pIE->data[0] |= WLAN_ERP_NON_ERP_PRESENT | + p[2] |= WLAN_ERP_NON_ERP_PRESENT | WLAN_ERP_USE_PROTECTION; else - pIE->data[0] &= ~(WLAN_ERP_NON_ERP_PRESENT | - WLAN_ERP_USE_PROTECTION); + p[2] &= ~(WLAN_ERP_NON_ERP_PRESENT | + WLAN_ERP_USE_PROTECTION); if (pmlmepriv->num_sta_no_short_preamble > 0) - pIE->data[0] |= WLAN_ERP_BARKER_PREAMBLE; + p[2] |= WLAN_ERP_BARKER_PREAMBLE; else - pIE->data[0] &= ~(WLAN_ERP_BARKER_PREAMBLE); + p[2] &= ~(WLAN_ERP_BARKER_PREAMBLE); - ERP_IE_handler23a(padapter, pIE); + ERP_IE_handler23a(padapter, p); } } diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 8c73fed9b4fd..951fbab1144c 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1735,7 +1735,6 @@ OnAssocReq23aFail: static int OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { - struct ndis_802_11_var_ies *pIE; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -1743,6 +1742,7 @@ OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) struct ieee80211_mgmt *pmgmt = (struct ieee80211_mgmt *) skb->data; int res, i; unsigned short status; + u8 *p; u8 *pframe = skb->data; int pkt_len = skb->len; @@ -1783,31 +1783,31 @@ OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) /* for not to handle the synchronous IO in the tasklet */ for (i = offsetof(struct ieee80211_mgmt, u.assoc_resp.variable); i < pkt_len;) { - pIE = (struct ndis_802_11_var_ies *)(pframe + i); + p = pframe + i; - switch (pIE->ElementID) + switch (p[0]) { case WLAN_EID_VENDOR_SPECIFIC: - if (!memcmp(pIE->data, WMM_PARA_OUI23A, 6))/* WMM */ - WMM_param_handler23a(padapter, pIE); + if (!memcmp(p + 2, WMM_PARA_OUI23A, 6))/* WMM */ + WMM_param_handler23a(padapter, p); break; case WLAN_EID_HT_CAPABILITY: /* HT caps */ - HT_caps_handler23a(padapter, pIE); + HT_caps_handler23a(padapter, p); break; case WLAN_EID_HT_OPERATION: /* HT info */ - HT_info_handler23a(padapter, pIE); + HT_info_handler23a(padapter, p); break; case WLAN_EID_ERP_INFO: - ERP_IE_handler23a(padapter, pIE); + ERP_IE_handler23a(padapter, p); default: break; } - i += (pIE->Length + 2); + i += (p[1] + 2); } pmlmeinfo->state &= ~WIFI_FW_ASSOC_STATE; @@ -3272,14 +3272,13 @@ void issue_assocreq23a(struct rtw_adapter *padapter) __le16 *fctrl; unsigned int i, j, index = 0; unsigned char rf_type, bssrate[NumRates], sta_bssrate[NumRates]; - struct ndis_802_11_var_ies *pIE; struct registry_priv *pregpriv = &padapter->registrypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; int bssrate_len = 0, sta_bssrate_len = 0, pie_len, bcn_fixed_size; - u8 * pie; + u8 *pie; pmgntframe = alloc_mgtxmitframe23a(pxmitpriv); if (!pmgntframe) @@ -3474,26 +3473,25 @@ void issue_assocreq23a(struct rtw_adapter *padapter) /* vendor specific IE, such as WPA, WMM, WPS */ for (i = bcn_fixed_size; i < pmlmeinfo->network.IELength;) { - pIE = (struct ndis_802_11_var_ies *) - (pmlmeinfo->network.IEs + i); + p = pmlmeinfo->network.IEs + i; - switch (pIE->ElementID) - { + switch (p[0]) { case WLAN_EID_VENDOR_SPECIFIC: - if (!memcmp(pIE->data, RTW_WPA_OUI23A_TYPE, 4) || - !memcmp(pIE->data, WMM_OUI23A, 4) || - !memcmp(pIE->data, WPS_OUI23A, 4)) { + if (!memcmp(p + 2, RTW_WPA_OUI23A_TYPE, 4) || + !memcmp(p + 2, WMM_OUI23A, 4) || + !memcmp(p + 2, WPS_OUI23A, 4)) { + u8 plen = p[1]; if (!padapter->registrypriv.wifi_spec) { /* Commented by Kurt 20110629 */ /* In some older APs, WPS handshake */ /* would be fail if we append vender extensions informations to AP */ - if (!memcmp(pIE->data, WPS_OUI23A, 4)) - pIE->Length = 14; + if (!memcmp(p + 2, WPS_OUI23A, 4)) + plen = 14; } pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, - pIE->Length, pIE->data, + plen, p + 2, &pattrib->pktlen); } break; @@ -3502,7 +3500,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) break; } - i += pIE->Length + 2; + i += p[1] + 2; } if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) @@ -5893,7 +5891,6 @@ int createbss_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) int join_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { - struct ndis_802_11_var_ies * pIE; struct registry_priv *pregpriv = &padapter->registrypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -5902,6 +5899,7 @@ int join_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) struct HT_info_element *pht_info; u32 i; int bcn_fixed_size; + u8 *p; /* u32 initialgain; */ /* u32 acparm; */ @@ -5951,12 +5949,11 @@ int join_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) offsetof(struct ieee80211_mgmt, u.beacon); for (i = bcn_fixed_size; i < pnetwork->IELength;) { - pIE = (struct ndis_802_11_var_ies *)(pnetwork->IEs + i); + p = pnetwork->IEs + i; - switch (pIE->ElementID) - { + switch (p[0]) { case WLAN_EID_VENDOR_SPECIFIC:/* Get WMM IE. */ - if (!memcmp(pIE->data, WMM_OUI23A, 4)) + if (!memcmp(p + 2, WMM_OUI23A, 4)) pmlmeinfo->WMM_enable = 1; break; @@ -5969,7 +5966,7 @@ int join_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) /* spec case only for cisco's ap because cisco's ap * issue assoc rsp using mcs rate @40MHz or @20MHz */ - pht_info = (struct HT_info_element *)(pIE->data); + pht_info = (struct HT_info_element *)(p + 2); if ((pregpriv->cbw40_enable) && (pht_info->infos[0] & BIT(2))) { @@ -6001,7 +5998,7 @@ int join_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) break; } - i += (pIE->Length + 2); + i += (p[1] + 2); } hw_var_set_bssid(padapter, pmlmeinfo->network.MacAddress); diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index ce73cbecd20b..68ba22555d38 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -512,8 +512,7 @@ void flush_all_cam_entry23a(struct rtw_adapter *padapter) memset(pmlmeinfo->FW_sta_info, 0, sizeof(pmlmeinfo->FW_sta_info)); } -int WMM_param_handler23a(struct rtw_adapter *padapter, - struct ndis_802_11_var_ies *pIE) +int WMM_param_handler23a(struct rtw_adapter *padapter, u8 *p) { /* struct registry_priv *pregpriv = &padapter->registrypriv; */ struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -526,7 +525,7 @@ int WMM_param_handler23a(struct rtw_adapter *padapter, } pmlmeinfo->WMM_enable = 1; - memcpy(&pmlmeinfo->WMM_param, (pIE->data + 6), + memcpy(&pmlmeinfo->WMM_param, p + 2 + 6, sizeof(struct WMM_para_element)); return true; } @@ -642,8 +641,7 @@ void WMMOnAssocRsp23a(struct rtw_adapter *padapter) return; } -static void bwmode_update_check(struct rtw_adapter *padapter, - struct ndis_802_11_var_ies *pIE) +static void bwmode_update_check(struct rtw_adapter *padapter, u8 *p) { struct HT_info_element *pHT_info; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -654,14 +652,14 @@ static void bwmode_update_check(struct rtw_adapter *padapter, unsigned char new_bwmode; unsigned char new_ch_offset; - if (!pIE) + if (!p) return; if (!phtpriv->ht_option) return; - if (pIE->Length > sizeof(struct HT_info_element)) + if (p[1] > sizeof(struct HT_info_element)) return; - pHT_info = (struct HT_info_element *)pIE->data; + pHT_info = (struct HT_info_element *)(p + 2); if ((pHT_info->infos[0] & BIT(2)) && pregistrypriv->cbw40_enable) { new_bwmode = HT_CHANNEL_WIDTH_40; @@ -690,7 +688,7 @@ static void bwmode_update_check(struct rtw_adapter *padapter, pmlmeext->cur_ch_offset = new_ch_offset; /* update HT info also */ - HT_info_handler23a(padapter, pIE); + HT_info_handler23a(padapter, p); } else pmlmeinfo->bwmode_updated = false; @@ -721,8 +719,7 @@ static void bwmode_update_check(struct rtw_adapter *padapter, } } -void HT_caps_handler23a(struct rtw_adapter *padapter, - struct ndis_802_11_var_ies * pIE) +void HT_caps_handler23a(struct rtw_adapter *padapter, u8 *p) { unsigned int i; u8 rf_type; @@ -732,7 +729,7 @@ void HT_caps_handler23a(struct rtw_adapter *padapter, struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct ht_priv *phtpriv = &pmlmepriv->htpriv; - if (!pIE) + if (!p) return; if (phtpriv->ht_option == false) @@ -740,24 +737,25 @@ void HT_caps_handler23a(struct rtw_adapter *padapter, pmlmeinfo->HT_caps_enable = 1; - for (i = 0; i < pIE->Length; i++) { + for (i = 0; i < p[1]; i++) { if (i != 2) { /* Commented by Albert 2010/07/12 */ /* Got the endian issue here. */ - pmlmeinfo->HT_caps.u.HT_cap[i] &= (pIE->data[i]); + pmlmeinfo->HT_caps.u.HT_cap[i] &= p[i + 2]; } else { /* modify from fw by Thomas 2010/11/17 */ - if ((pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x3) > (pIE->data[i] & 0x3)) - max_AMPDU_len = pIE->data[i] & 0x3; + if ((pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x3) > (p[i + 2] & 0x3)) + max_AMPDU_len = p[i + 2] & 0x3; else max_AMPDU_len = pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x3; - if ((pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) > (pIE->data[i] & 0x1c)) + if ((pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) > (p[i + 2] & 0x1c)) min_MPDU_spacing = pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c; else - min_MPDU_spacing = (pIE->data[i] & 0x1c); + min_MPDU_spacing = p[i + 2] & 0x1c; - pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para = max_AMPDU_len | min_MPDU_spacing; + pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para = + max_AMPDU_len | min_MPDU_spacing; } } @@ -783,25 +781,24 @@ void HT_caps_handler23a(struct rtw_adapter *padapter, return; } -void HT_info_handler23a(struct rtw_adapter *padapter, - struct ndis_802_11_var_ies *pIE) +void HT_info_handler23a(struct rtw_adapter *padapter, u8 *p) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct ht_priv *phtpriv = &pmlmepriv->htpriv; - if (!pIE) + if (!p) return; if (phtpriv->ht_option == false) return; - if (pIE->Length > sizeof(struct HT_info_element)) + if (p[1] > sizeof(struct HT_info_element)) return; pmlmeinfo->HT_info_enable = 1; - memcpy(&pmlmeinfo->HT_info, pIE->data, pIE->Length); + memcpy(&pmlmeinfo->HT_info, p + 2, p[1]); return; } @@ -838,17 +835,16 @@ void HTOnAssocRsp23a(struct rtw_adapter *padapter) rtl8723a_set_ampdu_factor(padapter, max_AMPDU_len); } -void ERP_IE_handler23a(struct rtw_adapter *padapter, - struct ndis_802_11_var_ies *pIE) +void ERP_IE_handler23a(struct rtw_adapter *padapter, u8 *p) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - if (pIE->Length > 1) + if (p[1] > 1) return; pmlmeinfo->ERP_enable = 1; - memcpy(&pmlmeinfo->ERP_IE, pIE->data, pIE->Length); + memcpy(&pmlmeinfo->ERP_IE, p + 2, p[1]); } void VCS_update23a(struct rtw_adapter *padapter, struct sta_info *psta) @@ -1138,41 +1134,42 @@ _mismatch: return _FAIL; } -void update_beacon23a_info(struct rtw_adapter *padapter, u8 *pframe, uint pkt_len, struct sta_info *psta) +void update_beacon23a_info(struct rtw_adapter *padapter, u8 *pframe, + uint pkt_len, struct sta_info *psta) { unsigned int i; unsigned int len; - struct ndis_802_11_var_ies * pIE; + u8 *p; len = pkt_len - (_BEACON_IE_OFFSET_ + sizeof(struct ieee80211_hdr_3addr)); for (i = 0; i < len;) { - pIE = (struct ndis_802_11_var_ies *)(pframe + (_BEACON_IE_OFFSET_ + sizeof(struct ieee80211_hdr_3addr)) + i); + p = (u8 *)(pframe + (_BEACON_IE_OFFSET_ + sizeof(struct ieee80211_hdr_3addr)) + i); - switch (pIE->ElementID) { + switch (p[0]) { case WLAN_EID_HT_OPERATION: /* HT info */ /* HT_info_handler23a(padapter, pIE); */ - bwmode_update_check(padapter, pIE); + bwmode_update_check(padapter, p); break; case WLAN_EID_ERP_INFO: - ERP_IE_handler23a(padapter, pIE); + ERP_IE_handler23a(padapter, p); VCS_update23a(padapter, psta); break; default: break; } - i += (pIE->Length + 2); + i += (p[1] + 2); } } bool is_ap_in_tkip23a(struct rtw_adapter *padapter) { u32 i; - struct ndis_802_11_var_ies *pIE; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; + const u8 *p; int bcn_fixed_size; bcn_fixed_size = offsetof(struct ieee80211_mgmt, u.beacon.variable) - @@ -1180,24 +1177,22 @@ bool is_ap_in_tkip23a(struct rtw_adapter *padapter) if (rtw_get_capability23a(cur_network) & WLAN_CAPABILITY_PRIVACY) { for (i = bcn_fixed_size; i < pmlmeinfo->network.IELength;) { - pIE = (struct ndis_802_11_var_ies *) - (pmlmeinfo->network.IEs + i); + p = pmlmeinfo->network.IEs + i; - switch (pIE->ElementID) { + switch (p[0]) { case WLAN_EID_VENDOR_SPECIFIC: - if (!memcmp(pIE->data, RTW_WPA_OUI23A_TYPE, 4)&& - !memcmp((pIE->data + 12), - WPA_TKIP_CIPHER, 4)) + if (!memcmp(p + 2, RTW_WPA_OUI23A_TYPE, 4) && + !memcmp(p + 2 + 12, WPA_TKIP_CIPHER, 4)) return true; break; case WLAN_EID_RSN: - if (!memcmp(pIE->data + 8, RSN_TKIP_CIPHER, 4)) + if (!memcmp(p + 2 + 8, RSN_TKIP_CIPHER, 4)) return true; break; default: break; } - i += (pIE->Length + 2); + i += (p[1] + 2); } return false; } else @@ -1207,9 +1202,9 @@ bool is_ap_in_tkip23a(struct rtw_adapter *padapter) bool should_forbid_n_rate23a(struct rtw_adapter * padapter) { u32 i; - struct ndis_802_11_var_ies *pIE; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_bssid_ex *cur_network = &pmlmepriv->cur_network.network; + const u8 *p; int bcn_fixed_size; bcn_fixed_size = offsetof(struct ieee80211_mgmt, u.beacon.variable) - @@ -1217,29 +1212,28 @@ bool should_forbid_n_rate23a(struct rtw_adapter * padapter) if (rtw_get_capability23a(cur_network) & WLAN_CAPABILITY_PRIVACY) { for (i = bcn_fixed_size; i < cur_network->IELength;) { - pIE = (struct ndis_802_11_var_ies *) - (cur_network->IEs + i); + p = cur_network->IEs + i; - switch (pIE->ElementID) { + switch (p[0]) { case WLAN_EID_VENDOR_SPECIFIC: - if (!memcmp(pIE->data, RTW_WPA_OUI23A_TYPE, 4)&& - (!memcmp(pIE->data + 12, + if (!memcmp(p + 2, RTW_WPA_OUI23A_TYPE, 4) && + (!memcmp(p + 2 + 12, WPA_CIPHER_SUITE_CCMP23A, 4) || - !memcmp(pIE->data + 16, + !memcmp(p + 2 + 16, WPA_CIPHER_SUITE_CCMP23A, 4))) return false; break; case WLAN_EID_RSN: - if (!memcmp(pIE->data + 8, + if (!memcmp(p + 2 + 8, RSN_CIPHER_SUITE_CCMP23A, 4) || - !memcmp(pIE->data + 12, + !memcmp(p + 2 + 12, RSN_CIPHER_SUITE_CCMP23A, 4)) return false; default: break; } - i += (pIE->Length + 2); + i += (p[1] + 2); } return true; } else { @@ -1250,10 +1244,10 @@ bool should_forbid_n_rate23a(struct rtw_adapter * padapter) bool is_ap_in_wep23a(struct rtw_adapter *padapter) { u32 i; - struct ndis_802_11_var_ies *pIE; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; + const u8 *p; int bcn_fixed_size; bcn_fixed_size = offsetof(struct ieee80211_mgmt, u.beacon.variable) - @@ -1261,12 +1255,11 @@ bool is_ap_in_wep23a(struct rtw_adapter *padapter) if (rtw_get_capability23a(cur_network) & WLAN_CAPABILITY_PRIVACY) { for (i = bcn_fixed_size; i < pmlmeinfo->network.IELength;) { - pIE = (struct ndis_802_11_var_ies *) - (pmlmeinfo->network.IEs + i); + p = pmlmeinfo->network.IEs + i; - switch (pIE->ElementID) { + switch (p[0]) { case WLAN_EID_VENDOR_SPECIFIC: - if (!memcmp(pIE->data, RTW_WPA_OUI23A_TYPE, 4)) + if (!memcmp(p + 2, RTW_WPA_OUI23A_TYPE, 4)) return false; break; case WLAN_EID_RSN: @@ -1276,7 +1269,7 @@ bool is_ap_in_wep23a(struct rtw_adapter *padapter) break; } - i += (pIE->Length + 2); + i += (p[1] + 2); } return true; @@ -1442,9 +1435,9 @@ void update_tx_basic_rate23a(struct rtw_adapter *padapter, u8 wirelessmode) unsigned char check_assoc_AP23a(u8 *pframe, uint len) { int i, bcn_fixed_size; - struct ndis_802_11_var_ies *pIE; u8 epigram_vendor_flag; u8 ralink_vendor_flag; + const u8 *p; epigram_vendor_flag = 0; ralink_vendor_flag = 0; @@ -1452,39 +1445,39 @@ unsigned char check_assoc_AP23a(u8 *pframe, uint len) offsetof(struct ieee80211_mgmt, u.beacon); for (i = bcn_fixed_size; i < len;) { - pIE = (struct ndis_802_11_var_ies *)(pframe + i); + p = pframe + i; - switch (pIE->ElementID) { + switch (p[0]) { case WLAN_EID_VENDOR_SPECIFIC: - if (!memcmp(pIE->data, ARTHEROS_OUI1, 3) || - !memcmp(pIE->data, ARTHEROS_OUI2, 3)) { + if (!memcmp(p + 2, ARTHEROS_OUI1, 3) || + !memcmp(p + 2, ARTHEROS_OUI2, 3)) { DBG_8723A("link to Artheros AP\n"); return HT_IOT_PEER_ATHEROS; - } else if (!memcmp(pIE->data, BROADCOM_OUI1, 3) || - !memcmp(pIE->data, BROADCOM_OUI2, 3) || - !memcmp(pIE->data, BROADCOM_OUI2, 3)) { + } else if (!memcmp(p + 2, BROADCOM_OUI1, 3) || + !memcmp(p + 2, BROADCOM_OUI2, 3) || + !memcmp(p + 2, BROADCOM_OUI2, 3)) { DBG_8723A("link to Broadcom AP\n"); return HT_IOT_PEER_BROADCOM; - } else if (!memcmp(pIE->data, MARVELL_OUI, 3)) { + } else if (!memcmp(p + 2, MARVELL_OUI, 3)) { DBG_8723A("link to Marvell AP\n"); return HT_IOT_PEER_MARVELL; - } else if (!memcmp(pIE->data, RALINK_OUI, 3)) { + } else if (!memcmp(p + 2, RALINK_OUI, 3)) { if (!ralink_vendor_flag) ralink_vendor_flag = 1; else { DBG_8723A("link to Ralink AP\n"); return HT_IOT_PEER_RALINK; } - } else if (!memcmp(pIE->data, CISCO_OUI, 3)) { + } else if (!memcmp(p + 2, CISCO_OUI, 3)) { DBG_8723A("link to Cisco AP\n"); return HT_IOT_PEER_CISCO; - } else if (!memcmp(pIE->data, REALTEK_OUI, 3)) { + } else if (!memcmp(p + 2, REALTEK_OUI, 3)) { DBG_8723A("link to Realtek 96B\n"); return HT_IOT_PEER_REALTEK; - } else if (!memcmp(pIE->data, AIRGOCAP_OUI, 3)) { + } else if (!memcmp(p + 2, AIRGOCAP_OUI, 3)) { DBG_8723A("link to Airgo Cap\n"); return HT_IOT_PEER_AIRGO; - } else if (!memcmp(pIE->data, EPIGRAM_OUI, 3)) { + } else if (!memcmp(p + 2, EPIGRAM_OUI, 3)) { epigram_vendor_flag = 1; if (ralink_vendor_flag) { DBG_8723A("link to Tenda W311R AP\n"); @@ -1497,7 +1490,7 @@ unsigned char check_assoc_AP23a(u8 *pframe, uint len) break; } - i += (pIE->Length + 2); + i += (p[1] + 2); } if (ralink_vendor_flag && !epigram_vendor_flag) { diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 346ee16ca248..043ed7ad11b8 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -514,18 +514,14 @@ bool is_IBSS_empty23a(struct rtw_adapter *padapter); unsigned char check_assoc_AP23a(u8 *pframe, uint len); -int WMM_param_handler23a(struct rtw_adapter *padapter, - struct ndis_802_11_var_ies *pIE); +int WMM_param_handler23a(struct rtw_adapter *padapter, u8 *p); void WMMOnAssocRsp23a(struct rtw_adapter *padapter); -void HT_caps_handler23a(struct rtw_adapter *padapter, - struct ndis_802_11_var_ies *pIE); -void HT_info_handler23a(struct rtw_adapter *padapter, - struct ndis_802_11_var_ies *pIE); +void HT_caps_handler23a(struct rtw_adapter *padapter, u8 *p); +void HT_info_handler23a(struct rtw_adapter *padapter, u8 *p); void HTOnAssocRsp23a(struct rtw_adapter *padapter); -void ERP_IE_handler23a(struct rtw_adapter *padapter, - struct ndis_802_11_var_ies *pIE); +void ERP_IE_handler23a(struct rtw_adapter *padapter, u8 *p); void VCS_update23a(struct rtw_adapter *padapter, struct sta_info *psta); void update_beacon23a_info(struct rtw_adapter *padapter, u8 *pframe, uint len, diff --git a/drivers/staging/rtl8723au/include/wlan_bssdef.h b/drivers/staging/rtl8723au/include/wlan_bssdef.h index c0dfcda689b8..09d35f110b97 100644 --- a/drivers/staging/rtl8723au/include/wlan_bssdef.h +++ b/drivers/staging/rtl8723au/include/wlan_bssdef.h @@ -22,12 +22,6 @@ #define NDIS_802_11_LENGTH_RATES 8 #define NDIS_802_11_LENGTH_RATES_EX 16 -struct ndis_802_11_var_ies { - u8 ElementID; - u8 Length; - u8 data[1]; -}; - /* Length is the 4 bytes multiples of the sum of * sizeof(6 * sizeof(unsigned char)) + 2 + sizeof(struct ndis_802_11_ssid) + * sizeof(u32) + sizeof(long) + sizeof(enum ndis_802_11_net_type) + -- cgit v1.2.3 From 5acab75263ec6b862676fd100c3a939f7b6f762c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:43 +0200 Subject: staging: rtl8723au: wlan_bssdef.h: Remove some more unused #defines Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/wlan_bssdef.h | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/drivers/staging/rtl8723au/include/wlan_bssdef.h b/drivers/staging/rtl8723au/include/wlan_bssdef.h index 09d35f110b97..664015d049e8 100644 --- a/drivers/staging/rtl8723au/include/wlan_bssdef.h +++ b/drivers/staging/rtl8723au/include/wlan_bssdef.h @@ -67,23 +67,6 @@ struct ndis_802_11_key { u8 KeyMaterial[32]; /* variable length depending on above field */ }; -enum NDIS_802_11_STATUS_TYPE { - Ndis802_11StatusType_Authentication, - Ndis802_11StatusType_MediaStreamMode, - Ndis802_11StatusType_PMKID_CandidateList, - Ndis802_11StatusTypeMax /* not a real type, just an upper bound */ -}; - -/* mask for authentication/integrity fields */ -#define NDIS_802_11_AUTH_REQUEST_AUTH_FIELDS 0x0f -#define NDIS_802_11_AUTH_REQUEST_REAUTH 0x01 -#define NDIS_802_11_AUTH_REQUEST_KEYUPDATE 0x02 -#define NDIS_802_11_AUTH_REQUEST_PAIRWISE_ERROR 0x06 -#define NDIS_802_11_AUTH_REQUEST_GROUP_ERROR 0x0E - -/* MIC check time, 60 seconds. */ -#define MIC_CHECK_TIME 60000000 - struct wlan_phy_info { u8 SignalStrength;/* in percentage) */ u8 SignalQuality;/* in percentage) */ -- cgit v1.2.3 From 8e3ddadf740e6d1b3678129b315817f48d801475 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:44 +0200 Subject: staging: rtl8723au: Get rid of ClearMFrag/SetMFrag Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 9 +++++---- drivers/staging/rtl8723au/include/wifi.h | 6 ------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 0472258c416b..a75ca65e76e6 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -1078,6 +1078,7 @@ int rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *skb, struct sta_info *psta; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct pkt_attrib *pattrib = &pxmitframe->attrib; + struct ieee80211_hdr *hdr; s32 frg_inx, frg_len, mpdu_len, llc_sz, mem_sz; u8 *pframe, *mem_start; u8 hw_hdr_offset; @@ -1136,8 +1137,7 @@ int rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *skb, mpdu_len = frg_len; pframe = mem_start; - - SetMFrag(mem_start); + hdr = (struct ieee80211_hdr *)mem_start; pframe += pattrib->hdrlen; mpdu_len -= pattrib->hdrlen; @@ -1220,8 +1220,8 @@ int rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *skb, llc_sz : 0) + ((pattrib->bswenc) ? pattrib->icv_len : 0) + mem_sz; - - ClearMFrag(mem_start); + hdr->frame_control &= + ~cpu_to_le16(IEEE80211_FCTL_MOREFRAGS); break; } else { @@ -1229,6 +1229,7 @@ int rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *skb, ("%s: There're still something in packet!\n", __func__)); } + hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREFRAGS); mem_start = PTR_ALIGN(pframe, 4) + hw_hdr_offset; memcpy(mem_start, pbuf_start + hw_hdr_offset, pattrib->hdrlen); diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index 4eb36336ca65..2d1e33aa6988 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -87,12 +87,6 @@ enum WIFI_REG_DOMAIN { #define SetFrDs(pbuf) \ (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_FROMDS)) -#define SetMFrag(pbuf) \ - (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) - -#define ClearMFrag(pbuf) \ - (*(__le16 *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_MOREFRAGS))) - #define SetRetry(pbuf) \ (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_RETRY)) -- cgit v1.2.3 From e80c2859b16fbfe209e7ee7cf2b2b65deb890971 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:45 +0200 Subject: staging: rtl8723au: wifi.h: Remove unused SetRetry() + SetAMsdu() macros Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/wifi.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index 2d1e33aa6988..4a84d0c72afb 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -87,9 +87,6 @@ enum WIFI_REG_DOMAIN { #define SetFrDs(pbuf) \ (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_FROMDS)) -#define SetRetry(pbuf) \ - (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_RETRY)) - #define SetPwrMgt(pbuf) \ (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_PM)) @@ -138,9 +135,6 @@ enum WIFI_REG_DOMAIN { #define SetAckpolicy(pbuf, ack) \ (*(__le16 *)(pbuf) |= cpu_to_le16((ack & 3) << 5)) -#define SetAMsdu(pbuf, amsdu) \ - (*(__le16 *)(pbuf) |= cpu_to_le16((amsdu & 1) << 7)) - #define _ASOCREQ_IE_OFFSET_ 4 /* excluding wlan_hdr */ #define _ASOCRSP_IE_OFFSET_ 6 #define _REASOCREQ_IE_OFFSET_ 10 -- cgit v1.2.3 From e1c04628f70bdb1a6ad8ba270f67ef4ab2aa4a43 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:46 +0200 Subject: staging: rtl8723au: Use kernel provided WLAN_CAPABILITY_* definitions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 6 +++--- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 7 +++---- drivers/staging/rtl8723au/include/wifi.h | 12 ------------ 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index 9ee05df39976..28a7a0c81166 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -402,13 +402,13 @@ int rtw_generate_ie23a(struct registry_priv *pregistrypriv) /* capability info */ *(u16*)ie = 0; - *(u16*)ie |= cpu_to_le16(cap_IBSS); + *(u16*)ie |= cpu_to_le16(WLAN_CAPABILITY_IBSS); if (pregistrypriv->preamble == PREAMBLE_SHORT) - *(u16*)ie |= cpu_to_le16(cap_ShortPremble); + *(u16*)ie |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE); if (pdev_network->Privacy) - *(u16*)ie |= cpu_to_le16(cap_Privacy); + *(u16*)ie |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); sz += 2; ie += 2; diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 951fbab1144c..d3d192d9a272 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -4652,7 +4652,7 @@ void start_create_ibss23a(struct rtw_adapter* padapter) /* udpate capability */ caps = rtw_get_capability23a(pnetwork); update_capinfo23a(padapter, caps); - if (caps&cap_IBSS) { /* adhoc master */ + if (caps & WLAN_CAPABILITY_IBSS) { /* adhoc master */ rtl8723a_set_sec_cfg(padapter, 0xcf); /* switch channel */ @@ -4707,7 +4707,7 @@ void start_clnt_join23a(struct rtw_adapter* padapter) /* udpate capability */ caps = rtw_get_capability23a(pnetwork); update_capinfo23a(padapter, caps); - if (caps&cap_ESS) { + if (caps & WLAN_CAPABILITY_ESS) { /* switch channel */ set_channel_bwmode23a(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); @@ -4728,8 +4728,7 @@ void start_clnt_join23a(struct rtw_adapter* padapter) mod_timer(&padapter->mlmepriv.assoc_timer, jiffies + msecs_to_jiffies((REAUTH_TO * REAUTH_LIMIT) + (REASSOC_TO*REASSOC_LIMIT) + beacon_timeout)); pmlmeinfo->state = WIFI_FW_AUTH_NULL | WIFI_FW_STATION_STATE; - } - else if (caps&cap_IBSS) { /* adhoc client */ + } else if (caps & WLAN_CAPABILITY_IBSS) { /* adhoc client */ Set_MSR23a(padapter, WIFI_FW_ADHOC_STATE); rtl8723a_set_sec_cfg(padapter, 0xcf); diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index 4a84d0c72afb..149564f92c80 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -164,18 +164,6 @@ enum WIFI_REG_DOMAIN { #define _STATUS_CODE_ 2 #define _TIMESTAMP_ 8 -#define cap_ESS BIT(0) -#define cap_IBSS BIT(1) -#define cap_CFPollable BIT(2) -#define cap_CFRequest BIT(3) -#define cap_Privacy BIT(4) -#define cap_ShortPremble BIT(5) -#define cap_PBCC BIT(6) -#define cap_ChAgility BIT(7) -#define cap_SpecMgmt BIT(8) -#define cap_QoS BIT(9) -#define cap_ShortSlot BIT(10) - /*----------------------------------------------------------------------------- Below is the definition for WMM ------------------------------------------------------------------------------*/ -- cgit v1.2.3 From 2c50c7cbf08d3d308ddd7a0cfcad76cc72897918 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:47 +0200 Subject: staging: rtl8723au: Use kernel provided IEEE80211_HT_OP_MODE_* defines In addition remove unused HT_INFO_STBC_PARAM_* defines Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 22 +++++++++++----------- drivers/staging/rtl8723au/include/wifi.h | 16 ---------------- 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 0f21e2c1e538..a5353153eb8d 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -1387,28 +1387,28 @@ static int rtw_ht_operation_update(struct rtw_adapter *padapter) DBG_8723A("%s current operation mode = 0x%X\n", __func__, pmlmepriv->ht_op_mode); - if (!(pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT) + if (!(pmlmepriv->ht_op_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT) && pmlmepriv->num_sta_ht_no_gf) { pmlmepriv->ht_op_mode |= - HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT; + IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT; op_mode_changes++; } else if ((pmlmepriv->ht_op_mode & - HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT) && + IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT) && pmlmepriv->num_sta_ht_no_gf == 0) { pmlmepriv->ht_op_mode &= - ~HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT; + ~IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT; op_mode_changes++; } - if (!(pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT) && + if (!(pmlmepriv->ht_op_mode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT) && (pmlmepriv->num_sta_no_ht || pmlmepriv->olbc_ht)) { - pmlmepriv->ht_op_mode |= HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT; + pmlmepriv->ht_op_mode |= IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT; op_mode_changes++; } else if ((pmlmepriv->ht_op_mode & - HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT) && + IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT) && (pmlmepriv->num_sta_no_ht == 0 && !pmlmepriv->olbc_ht)) { pmlmepriv->ht_op_mode &= - ~HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT; + ~IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT; op_mode_changes++; } @@ -1418,7 +1418,7 @@ static int rtw_ht_operation_update(struct rtw_adapter *padapter) */ new_op_mode = 0; if (pmlmepriv->num_sta_no_ht || - (pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT)) + (pmlmepriv->ht_op_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT)) new_op_mode = OP_MODE_MIXED; else if ((le16_to_cpu(phtpriv_ap->ht_cap.cap_info) & IEEE80211_HT_CAP_SUP_WIDTH_20_40) && @@ -1429,9 +1429,9 @@ static int rtw_ht_operation_update(struct rtw_adapter *padapter) else new_op_mode = OP_MODE_PURE; - cur_op_mode = pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_OP_MODE_MASK; + cur_op_mode = pmlmepriv->ht_op_mode & IEEE80211_HT_OP_MODE_PROTECTION; if (cur_op_mode != new_op_mode) { - pmlmepriv->ht_op_mode &= ~HT_INFO_OPERATION_MODE_OP_MODE_MASK; + pmlmepriv->ht_op_mode &= ~IEEE80211_HT_OP_MODE_PROTECTION; pmlmepriv->ht_op_mode |= new_op_mode; op_mode_changes++; } diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index 149564f92c80..bfe1eb36f179 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -241,22 +241,6 @@ struct ADDBA_request { #define HT_INFO_HT_PARAM_CTRL_ACCESS_ONLY ((u8) BIT(4)) #define HT_INFO_HT_PARAM_SRV_INTERVAL_GRANULARITY ((u8) BIT(5)) -#define HT_INFO_OPERATION_MODE_OP_MODE_MASK \ - ((u16) (0x0001 | 0x0002)) -#define HT_INFO_OPERATION_MODE_OP_MODE_OFFSET 0 -#define HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT ((u8) BIT(2)) -#define HT_INFO_OPERATION_MODE_TRANSMIT_BURST_LIMIT ((u8) BIT(3)) -#define HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT ((u8) BIT(4)) - -#define HT_INFO_STBC_PARAM_DUAL_BEACON ((u16) BIT(6)) -#define HT_INFO_STBC_PARAM_DUAL_STBC_PROTECT ((u16) BIT(7)) -#define HT_INFO_STBC_PARAM_SECONDARY_BCN ((u16) BIT(8)) -#define HT_INFO_STBC_PARAM_LSIG_TXOP_PROTECT_ALLOWED ((u16) BIT(9)) -#define HT_INFO_STBC_PARAM_PCO_ACTIVE ((u16) BIT(10)) -#define HT_INFO_STBC_PARAM_PCO_PHASE ((u16) BIT(11)) - - - /* ===============WPS Section=============== */ /* For WPSv1.0 */ #define WPSOUI 0x0050f204 -- cgit v1.2.3 From 7e14ed5f8fcc14c7a9c20be341b2d8cbe28efda9 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:48 +0200 Subject: staging: rtl8723au: Use kernel provided IEEE80211_HT_PARAM_* defines Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ioctl_set.c | 2 +- drivers/staging/rtl8723au/include/wifi.h | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c index 99a662d83fc1..f65443c62baf 100644 --- a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c @@ -399,7 +399,7 @@ u16 rtw_get_cur_max_rate23a(struct rtw_adapter *adapter) /* cur_bwmod is updated by beacon, pmlmeinfo is updated by association response */ bw_40MHz = (pmlmeext->cur_bwmode && - (HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH & + (IEEE80211_HT_PARAM_CHAN_WIDTH_ANY & pmlmeinfo->HT_info.infos[0])) ? 1:0; /* short_GI = (pht_capie->cap_info & (IEEE80211_HT_CAP diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index bfe1eb36f179..d7234838f4ee 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -233,14 +233,6 @@ struct ADDBA_request { #define OP_MODE_20MHZ_HT_STA_ASSOCED 2 #define OP_MODE_MIXED 3 -#define HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK ((u8) BIT(0) | BIT(1)) -#define HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE ((u8) BIT(0)) -#define HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW ((u8) BIT(0) | BIT(1)) -#define HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH ((u8) BIT(2)) -#define HT_INFO_HT_PARAM_RIFS_MODE ((u8) BIT(3)) -#define HT_INFO_HT_PARAM_CTRL_ACCESS_ONLY ((u8) BIT(4)) -#define HT_INFO_HT_PARAM_SRV_INTERVAL_GRANULARITY ((u8) BIT(5)) - /* ===============WPS Section=============== */ /* For WPSv1.0 */ #define WPSOUI 0x0050f204 -- cgit v1.2.3 From 15b4ff5d8b9d9f36feda6fd07888965870514371 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:49 +0200 Subject: staging: rtl8723au: Remove unused enum WIFI_REG_DOMAIN Must be the 17th duplicate of this list in the kernel Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/wifi.h | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index d7234838f4ee..2be12e4ff46e 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -66,21 +66,6 @@ enum WIFI_FRAME_SUBTYPE { }; -enum WIFI_REG_DOMAIN { - DOMAIN_FCC = 1, - DOMAIN_IC = 2, - DOMAIN_ETSI = 3, - DOMAIN_SPAIN = 4, - DOMAIN_FRANCE = 5, - DOMAIN_MKK = 6, - DOMAIN_ISRAEL = 7, - DOMAIN_MKK1 = 8, - DOMAIN_MKK2 = 9, - DOMAIN_MKK3 = 10, - DOMAIN_MAX -}; - - #define SetToDs(pbuf) \ (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_TODS)) -- cgit v1.2.3 From 95a4c8c25fe6d10947b4aa897451b2ab7d7cc48b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:50 +0200 Subject: staging: rtl8723au: wifi.h: Remove a pile of unused WDS_ defines Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/wifi.h | 67 -------------------------------- 1 file changed, 67 deletions(-) diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index 2be12e4ff46e..e7cf64a14c09 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -219,8 +219,6 @@ struct ADDBA_request { #define OP_MODE_MIXED 3 /* ===============WPS Section=============== */ -/* For WPSv1.0 */ -#define WPSOUI 0x0050f204 /* WPS attribute ID */ #define WPS_ATTR_VER1 0x104A #define WPS_ATTR_SIMPLE_CONF_STATE 0x1044 @@ -242,71 +240,6 @@ struct ADDBA_request { #define WPS_ATTR_VENDOR_EXT 0x1049 #define WPS_ATTR_SELECTED_REGISTRAR 0x1041 -/* Value of WPS attribute "WPS_ATTR_DEVICE_NAME */ -#define WPS_MAX_DEVICE_NAME_LEN 32 - -/* Value of WPS Request Type Attribute */ -#define WPS_REQ_TYPE_ENROLLEE_INFO_ONLY 0x00 -#define WPS_REQ_TYPE_ENROLLEE_OPEN_8021X 0x01 -#define WPS_REQ_TYPE_REGISTRAR 0x02 -#define WPS_REQ_TYPE_WLAN_MANAGER_REGISTRAR 0x03 - -/* Value of WPS Response Type Attribute */ -#define WPS_RESPONSE_TYPE_INFO_ONLY 0x00 -#define WPS_RESPONSE_TYPE_8021X 0x01 -#define WPS_RESPONSE_TYPE_REGISTRAR 0x02 -#define WPS_RESPONSE_TYPE_AP 0x03 - -/* Value of WPS WiFi Simple Configuration State Attribute */ -#define WPS_WSC_STATE_NOT_CONFIG 0x01 -#define WPS_WSC_STATE_CONFIG 0x02 - -/* Value of WPS Version Attribute */ -#define WPS_VERSION_1 0x10 - -/* Value of WPS Configuration Method Attribute */ -#define WPS_CONFIG_METHOD_FLASH 0x0001 -#define WPS_CONFIG_METHOD_ETHERNET 0x0002 -#define WPS_CONFIG_METHOD_LABEL 0x0004 -#define WPS_CONFIG_METHOD_DISPLAY 0x0008 -#define WPS_CONFIG_METHOD_E_NFC 0x0010 -#define WPS_CONFIG_METHOD_I_NFC 0x0020 -#define WPS_CONFIG_METHOD_NFC 0x0040 -#define WPS_CONFIG_METHOD_PBC 0x0080 -#define WPS_CONFIG_METHOD_KEYPAD 0x0100 -#define WPS_CONFIG_METHOD_VPBC 0x0280 -#define WPS_CONFIG_METHOD_PPBC 0x0480 -#define WPS_CONFIG_METHOD_VDISPLAY 0x2008 -#define WPS_CONFIG_METHOD_PDISPLAY 0x4008 - -/* Value of Category ID of WPS Primary Device Type Attribute */ -#define WPS_PDT_CID_DISPLAYS 0x0007 -#define WPS_PDT_CID_MULIT_MEDIA 0x0008 -#define WPS_PDT_CID_RTK_WIDI WPS_PDT_CID_MULIT_MEDIA - -/* Value of Sub Category ID of WPS Primary Device Type Attribute */ -#define WPS_PDT_SCID_MEDIA_SERVER 0x0005 -#define WPS_PDT_SCID_RTK_DMP WPS_PDT_SCID_MEDIA_SERVER - -/* Value of Device Password ID */ -#define WPS_DPID_PIN 0x0000 -#define WPS_DPID_USER_SPEC 0x0001 -#define WPS_DPID_MACHINE_SPEC 0x0002 -#define WPS_DPID_REKEY 0x0003 -#define WPS_DPID_PBC 0x0004 -#define WPS_DPID_REGISTRAR_SPEC 0x0005 - -/* Value of WPS RF Bands Attribute */ -#define WPS_RF_BANDS_2_4_GHZ 0x01 -#define WPS_RF_BANDS_5_GHZ 0x02 - -/* Value of WPS Association State Attribute */ -#define WPS_ASSOC_STATE_NOT_ASSOCIATED 0x00 -#define WPS_ASSOC_STATE_CONNECTION_SUCCESS 0x01 -#define WPS_ASSOC_STATE_CONFIGURATION_FAILURE 0x02 -#define WPS_ASSOC_STATE_ASSOCIATION_FAILURE 0x03 -#define WPS_ASSOC_STATE_IP_FAILURE 0x04 - /* P2P Public Action Frame ( Management Frame ) */ #define P2P_PUB_ACTION_ACTION 0x09 -- cgit v1.2.3 From c38992872dcc01dabcf912e5ac390b355f6bae7e Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:51 +0200 Subject: staging: rtl8723au: Get rid of last HT OP mode duplicate defines Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 9 ++++----- drivers/staging/rtl8723au/include/wifi.h | 5 ----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index a5353153eb8d..850e2e51f198 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -1416,18 +1416,17 @@ static int rtw_ht_operation_update(struct rtw_adapter *padapter) * station is associated. Probably it's a theoretical case, since * it looks like all known HT STAs support greenfield. */ - new_op_mode = 0; if (pmlmepriv->num_sta_no_ht || (pmlmepriv->ht_op_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT)) - new_op_mode = OP_MODE_MIXED; + new_op_mode = IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED; else if ((le16_to_cpu(phtpriv_ap->ht_cap.cap_info) & IEEE80211_HT_CAP_SUP_WIDTH_20_40) && pmlmepriv->num_sta_ht_20mhz) - new_op_mode = OP_MODE_20MHZ_HT_STA_ASSOCED; + new_op_mode = IEEE80211_HT_OP_MODE_PROTECTION_20MHZ; else if (pmlmepriv->olbc_ht) - new_op_mode = OP_MODE_MAY_BE_LEGACY_STAS; + new_op_mode = IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER; else - new_op_mode = OP_MODE_PURE; + new_op_mode = IEEE80211_HT_OP_MODE_PROTECTION_NONE; cur_op_mode = pmlmepriv->ht_op_mode & IEEE80211_HT_OP_MODE_PROTECTION; if (cur_op_mode != new_op_mode) { diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index e7cf64a14c09..64ead4f0dc4c 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -213,11 +213,6 @@ struct ADDBA_request { } __packed; -#define OP_MODE_PURE 0 -#define OP_MODE_MAY_BE_LEGACY_STAS 1 -#define OP_MODE_20MHZ_HT_STA_ASSOCED 2 -#define OP_MODE_MIXED 3 - /* ===============WPS Section=============== */ /* WPS attribute ID */ #define WPS_ATTR_VER1 0x104A -- cgit v1.2.3 From aa69fa6571882dba333978a9fae431d2c289f0d5 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:52 +0200 Subject: staging: rtl8723au: cfg80211_rtw_mgmt_tx(): type is always -1 Rip out P2P defines since they are effectively never used. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/wifi.h | 14 -------------- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 19 ------------------- 2 files changed, 33 deletions(-) diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index 64ead4f0dc4c..b0a6ae3bca97 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -235,20 +235,6 @@ struct ADDBA_request { #define WPS_ATTR_VENDOR_EXT 0x1049 #define WPS_ATTR_SELECTED_REGISTRAR 0x1041 -/* P2P Public Action Frame ( Management Frame ) */ -#define P2P_PUB_ACTION_ACTION 0x09 - -/* P2P Public Action Frame Type */ -#define P2P_GO_NEGO_REQ 0 -#define P2P_GO_NEGO_RESP 1 -#define P2P_GO_NEGO_CONF 2 -#define P2P_INVIT_REQ 3 -#define P2P_INVIT_RESP 4 -#define P2P_DEVDISC_REQ 5 -#define P2P_DEVDISC_RESP 6 -#define P2P_PROVISION_DISC_REQ 7 -#define P2P_PROVISION_DISC_RESP 8 - /* WPS Configuration Method */ #define WPS_CM_NONE 0x0000 #define WPS_CM_LABEL 0x0004 diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 6a99dafa8f8c..5ef72b2aa9a1 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -3198,14 +3198,12 @@ static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, { struct rtw_adapter *padapter = (struct rtw_adapter *)wiphy_to_adapter(wiphy); - struct rtw_wdev_priv *pwdev_priv = wdev_to_priv(padapter->rtw_wdev); int ret = 0; int tx_ret; u32 dump_limit = RTW_MAX_MGMT_TX_CNT; u32 dump_cnt = 0; bool ack = true; u8 category, action; - int type = (-1); unsigned long start = jiffies; #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) size_t len = params->len; @@ -3252,23 +3250,6 @@ static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, dump_limit, jiffies_to_msecs(jiffies - start)); } - switch (type) { - case P2P_GO_NEGO_CONF: - rtw_clear_scan_deny(padapter); - break; - case P2P_INVIT_RESP: - if (pwdev_priv->invit_info.flags & BIT(0) - && pwdev_priv->invit_info.status == 0) { - DBG_8723A("%s(%s): agree with invitation of " - "persistent group\n", - __func__, padapter->pnetdev->name); - rtw_set_scan_deny(padapter, 5000); - rtw_pwr_wakeup_ex(padapter, 5000); - rtw_clear_scan_deny(padapter); - } - break; - } - exit: return ret; } -- cgit v1.2.3 From 14423cd7024a99d6fa0a6ac875d03e6b0fa3cff6 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:53 +0200 Subject: staging: rtl8723au: ioctl_cfg80211.c: Rip out < 3.14 kernel support Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 5ef72b2aa9a1..b8f012cc13ef 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -3185,15 +3185,7 @@ exit: } static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0)) - struct ieee80211_channel *chan, - bool offchan, - unsigned int wait, - const u8 *buf, size_t len, - bool no_cck, bool dont_wait_for_ack, -#else struct cfg80211_mgmt_tx_params *params, -#endif u64 *cookie) { struct rtw_adapter *padapter = @@ -3205,11 +3197,9 @@ static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, bool ack = true; u8 category, action; unsigned long start = jiffies; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) size_t len = params->len; struct ieee80211_channel *chan = params->chan; const u8 *buf = params->buf; -#endif struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)buf; u8 tx_ch = (u8) ieee80211_frequency_to_channel(chan->center_freq); -- cgit v1.2.3 From 9a7e35f1eabe4090f7f9943d51afe2a4b6086aae Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:54 +0200 Subject: staging: rtl8723au: rtw_cfg80211_inform_bss(): Use get_unaligned_le16() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index b8f012cc13ef..f72588ef237f 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -289,7 +289,7 @@ static int rtw_cfg80211_inform_bss(struct rtw_adapter *padapter, notify_timestamp = jiffies_to_msecs(jiffies) * 1000; /* uSec */ notify_interval = - le16_to_cpu(*(u16 *) + get_unaligned_le16( rtw_get_beacon_interval23a_from_ie(pnetwork->network.IEs)); notify_capability = get_unaligned_le16( -- cgit v1.2.3 From 1daffaeecb4bf01c4a34fc2330c745ace5af3f60 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:55 +0200 Subject: staging: rtl8723au: ioctl_cfg80211.c: Properly initialize seq_ctrl Using SetSeqNum() on an uninitialized stack frame leaves us open to leaving random fragment bits set in seq_ctrl in the frame header. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index f72588ef237f..63230d4684c7 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -262,8 +262,6 @@ static int rtw_cfg80211_inform_bss(struct rtw_adapter *padapter, u8 buf[MAX_BSSINFO_LEN], *pbuf; size_t len; struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; - struct wireless_dev *wdev = padapter->rtw_wdev; struct wiphy *wiphy = wdev->wiphy; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -311,10 +309,9 @@ static int rtw_cfg80211_inform_bss(struct rtw_adapter *padapter, pbuf = buf; pwlanhdr = (struct ieee80211_hdr *)pbuf; - fctrl = &pwlanhdr->frame_control; - *(fctrl) = 0; - SetSeqNum(pwlanhdr, 0); + pwlanhdr->frame_control = 0; + pwlanhdr->seq_ctrl = 0; if (pnetwork->network.reserved == 1) { /* WIFI_BEACON */ eth_broadcast_addr(pwlanhdr->addr1); @@ -2464,14 +2461,15 @@ void rtw_cfg80211_indicate_sta_disassoc(struct rtw_adapter *padapter, u8 *pmgmt_frame; uint frame_len; struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; - u8 mgmt_buf[128] = { 0 }; + u8 mgmt_buf[128]; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct net_device *ndev = padapter->pnetdev; DBG_8723A("%s(padapter =%p,%s)\n", __func__, padapter, ndev->name); + memset(mgmt_buf, 0, 128); + #if defined(RTW_USE_CFG80211_STA_EVENT) cfg80211_del_sta(ndev, da, GFP_ATOMIC); #else /* defined(RTW_USE_CFG80211_STA_EVENT) */ @@ -2486,14 +2484,14 @@ void rtw_cfg80211_indicate_sta_disassoc(struct rtw_adapter *padapter, pmgmt_frame = mgmt_buf; pwlanhdr = (struct ieee80211_hdr *)pmgmt_frame; - fctrl = &pwlanhdr->frame_control; - *(fctrl) = 0; + pwlanhdr->frame_control = 0; memcpy(pwlanhdr->addr1, myid(&padapter->eeprompriv), ETH_ALEN); memcpy(pwlanhdr->addr2, da, ETH_ALEN); memcpy(pwlanhdr->addr3, get_my_bssid23a(&pmlmeinfo->network), ETH_ALEN); - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pwlanhdr->seq_ctrl = + cpu_to_le16(IEEE80211_SN_TO_SEQ(pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; SetFrameSubType(pmgmt_frame, WIFI_DEAUTH); -- cgit v1.2.3 From 0b218f4c6b1a824c6ed68328f9ad47a76384140b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:56 +0200 Subject: staging: rtl8723au: rtl8723a_cmd.c: Properly initialize seq_ctrl Control frames will not be fragmented, so we should fully initialize the seq_ctrl field to zero. This avoids leftover stack bits remaining set in the generated frame's seq_ctrl field. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 57 +++++++++++++--------------- 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c index 11660622d6b2..bfe754fef8ca 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c @@ -204,7 +204,6 @@ void rtl8723a_set_FwPwrMode_cmd(struct rtw_adapter *padapter, u8 Mode) static void ConstructBeacon(struct rtw_adapter *padapter, u8 *pframe, u32 *pLength) { struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; u32 rate_len, pktlen; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -216,15 +215,15 @@ static void ConstructBeacon(struct rtw_adapter *padapter, u8 *pframe, u32 *pLeng pwlanhdr = (struct ieee80211_hdr *)pframe; - fctrl = &pwlanhdr->frame_control; - *(fctrl) = 0; + pwlanhdr->frame_control = 0; memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); memcpy(pwlanhdr->addr3, get_my_bssid23a(cur_network), ETH_ALEN); - SetSeqNum(pwlanhdr, 0/*pmlmeext->mgnt_seq*/); - /* pmlmeext->mgnt_seq++; */ + /* A Beacon frame shouldn't have fragment bits set */ + pwlanhdr->seq_ctrl = 0; + SetFrameSubType(pframe, WIFI_BEACON); pframe += sizeof(struct ieee80211_hdr_3addr); @@ -334,28 +333,26 @@ static void ConstructPSPoll(struct rtw_adapter *padapter, u8 *pframe, u32 *pLeng *pLength = 16; } -static void ConstructNullFunctionData( - struct rtw_adapter *padapter, - u8 *pframe, - u32 *pLength, - u8 *StaAddr, - u8 bQoS, - u8 AC, - u8 bEosp, - u8 bForcePowerSave) +static void +ConstructNullFunctionData(struct rtw_adapter *padapter, u8 *pframe, + u32 *pLength, u8 *StaAddr, u8 bQoS, u8 AC, + u8 bEosp, u8 bForcePowerSave) { struct ieee80211_hdr *pwlanhdr; __le16 *fctrl; u32 pktlen; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wlan_network *cur_network = &pmlmepriv->cur_network; + struct wlan_network *cur_network = &pmlmepriv->cur_network; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; pwlanhdr = (struct ieee80211_hdr *)pframe; + pwlanhdr->frame_control = 0; + pwlanhdr->seq_ctrl = 0; + fctrl = &pwlanhdr->frame_control; - *(fctrl) = 0; + if (bForcePowerSave) SetPwrMgt(fctrl); @@ -387,8 +384,6 @@ static void ConstructNullFunctionData( break; } - SetSeqNum(pwlanhdr, 0); - if (bQoS == true) { struct ieee80211_qos_hdr *pwlanqoshdr; @@ -408,10 +403,10 @@ static void ConstructNullFunctionData( *pLength = pktlen; } -static void ConstructProbeRsp(struct rtw_adapter *padapter, u8 *pframe, u32 *pLength, u8 *StaAddr, bool bHideSSID) +static void ConstructProbeRsp(struct rtw_adapter *padapter, u8 *pframe, + u32 *pLength, u8 *StaAddr, bool bHideSSID) { struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; u8 *mac, *bssid; u32 pktlen; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -425,14 +420,14 @@ static void ConstructProbeRsp(struct rtw_adapter *padapter, u8 *pframe, u32 *pLe mac = myid(&padapter->eeprompriv); bssid = cur_network->MacAddress; - fctrl = &pwlanhdr->frame_control; - *(fctrl) = 0; + pwlanhdr->frame_control = 0; + pwlanhdr->seq_ctrl = 0; + memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN); memcpy(pwlanhdr->addr2, mac, ETH_ALEN); memcpy(pwlanhdr->addr3, bssid, ETH_ALEN); - SetSeqNum(pwlanhdr, 0); - SetFrameSubType(fctrl, WIFI_PROBERSP); + SetFrameSubType(&pwlanhdr->frame_control, WIFI_PROBERSP); pktlen = sizeof(struct ieee80211_hdr_3addr); pframe += pktlen; @@ -521,13 +516,13 @@ static void SetFwRsvdPagePkt(struct rtw_adapter *padapter, bool bDLFinished) /* 3 (3) null data */ RsvdPageLoc.LocNullData = PageNum; - ConstructNullFunctionData( - padapter, - &ReservedPagePacket[BufIndex], - &NullDataLength, - get_my_bssid23a(&pmlmeinfo->network), - false, 0, 0, false); - rtl8723a_fill_fake_txdesc(padapter, &ReservedPagePacket[BufIndex-TxDescLen], NullDataLength, false, false); + ConstructNullFunctionData(padapter, &ReservedPagePacket[BufIndex], + &NullDataLength, + get_my_bssid23a(&pmlmeinfo->network), + false, 0, 0, false); + rtl8723a_fill_fake_txdesc(padapter, + &ReservedPagePacket[BufIndex-TxDescLen], + NullDataLength, false, false); PageNeed = (u8)PageNum_128(TxDescLen + NullDataLength); PageNum += PageNeed; -- cgit v1.2.3 From 670ce6889c21629329fbefa148ae712458c63a7b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:57 +0200 Subject: staging: rtl8723au: rtw_make_wlanhdr23a(): Use IEEE80211_SN_TO_SEQ() to set seq_ctrl Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index a75ca65e76e6..e9882a5b0966 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -953,7 +953,9 @@ int rtw_make_wlanhdr23a(struct rtw_adapter *padapter, u8 *hdr, psta->sta_xmitpriv.txseq_tid[pattrib->priority]++; psta->sta_xmitpriv.txseq_tid[pattrib->priority] &= 0xFFF; pattrib->seqnum = psta->sta_xmitpriv.txseq_tid[pattrib->priority]; - SetSeqNum(hdr, pattrib->seqnum); + /* We dont need to worry about frag bits here */ + pwlanhdr->seq_ctrl = cpu_to_le16(IEEE80211_SN_TO_SEQ( + pattrib->seqnum)); /* check if enable ampdu */ if (pattrib->ht_en && psta->htpriv.ampdu_enable) { if (pattrib->priority >= 16) -- cgit v1.2.3 From 39ef89153ce9690efc00d45448fda23ad416ce51 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:58 +0200 Subject: staging: rtl8723au: Declare rtw_make_wlanhdr() static Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 9 ++++----- drivers/staging/rtl8723au/include/rtw_xmit.h | 2 -- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index e9882a5b0966..2ebb3df87690 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -858,8 +858,8 @@ static int xmitframe_swencrypt(struct rtw_adapter *padapter, return _SUCCESS; } -int rtw_make_wlanhdr23a(struct rtw_adapter *padapter, u8 *hdr, - struct pkt_attrib *pattrib) +static int rtw_make_wlanhdr(struct rtw_adapter *padapter, u8 *hdr, + struct pkt_attrib *pattrib) { u16 *qc; @@ -1119,10 +1119,9 @@ int rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *skb, mem_start = pbuf_start + hw_hdr_offset; - if (rtw_make_wlanhdr23a(padapter, mem_start, pattrib) == _FAIL) { + if (rtw_make_wlanhdr(padapter, mem_start, pattrib) == _FAIL) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, - ("rtw_xmitframe_coalesce23a: rtw_make_wlanhdr23a " - "fail; drop pkt\n")); + ("%s: rtw_make_wlanhdr fail; drop pkt\n", __func__)); res = _FAIL; goto exit; } diff --git a/drivers/staging/rtl8723au/include/rtw_xmit.h b/drivers/staging/rtl8723au/include/rtw_xmit.h index 33d0bc4ffd30..53030b6a376e 100644 --- a/drivers/staging/rtl8723au/include/rtw_xmit.h +++ b/drivers/staging/rtl8723au/include/rtw_xmit.h @@ -350,8 +350,6 @@ s32 rtw_free_xmitbuf23a(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf); void rtw_count_tx_stats23a(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe, int sz); void rtw_update_protection23a(struct rtw_adapter *padapter, u8 *ie, uint ie_len); -s32 rtw_make_wlanhdr23a(struct rtw_adapter *padapter, u8 *hdr, - struct pkt_attrib *pattrib); s32 rtw_put_snap23a(u8 *data, u16 h_proto); struct xmit_frame *rtw_alloc_xmitframe23a_ext(struct xmit_priv *pxmitpriv); struct xmit_frame *rtw_alloc_xmitframe23a_once(struct xmit_priv *pxmitpriv); -- cgit v1.2.3 From aeda82507d5016f04594e3d5b50af9551fa9c734 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:37:59 +0200 Subject: staging: rtl8723au: Get rid of SetSeqNum() In every last use case, the header was just cleared with memset() so there is no need to use the complex SetSeqNum() macro when cpu_to_le16(IEEE80211_SN_TO_SEQ()) output will do just fine. In addition, get rid of __le16 *fctrl usage when there is no need for it. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 75 +++++++++++++-------------- drivers/staging/rtl8723au/include/wifi.h | 7 --- 2 files changed, 37 insertions(+), 45 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index d3d192d9a272..b8d829f95da0 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -2425,7 +2425,6 @@ void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms) struct pkt_attrib *pattrib; unsigned char *pframe; struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; unsigned int rate_len; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -2458,15 +2457,13 @@ void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms) pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct ieee80211_hdr *)pframe; - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; + pwlanhdr->frame_control = 0; + pwlanhdr->seq_ctrl = 0; ether_addr_copy(pwlanhdr->addr1, bc_addr); ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); ether_addr_copy(pwlanhdr->addr3, get_my_bssid23a(cur_network)); - SetSeqNum(pwlanhdr, 0 /*pmlmeext->mgnt_seq*/); - /* pmlmeext->mgnt_seq++; */ SetFrameSubType(pframe, WIFI_BEACON); pframe += sizeof(struct ieee80211_hdr_3addr); @@ -2592,7 +2589,6 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, struct pkt_attrib *pattrib; unsigned char *pframe; struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; unsigned char *mac, *bssid; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; #ifdef CONFIG_8723AU_AP_MODE @@ -2630,15 +2626,16 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, mac = myid(&padapter->eeprompriv); bssid = cur_network->MacAddress; - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; + pwlanhdr->frame_control = 0; + ether_addr_copy(pwlanhdr->addr1, da); ether_addr_copy(pwlanhdr->addr2, mac); ether_addr_copy(pwlanhdr->addr3, bssid); - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pwlanhdr->seq_ctrl = + cpu_to_le16(IEEE80211_SN_TO_SEQ(pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; - SetFrameSubType(fctrl, WIFI_PROBERSP); + SetFrameSubType(&pwlanhdr->frame_control, WIFI_PROBERSP); pattrib->hdrlen = sizeof(struct ieee80211_hdr_3addr); pattrib->pktlen = pattrib->hdrlen; @@ -2808,7 +2805,6 @@ static int _issue_probereq23a(struct rtw_adapter *padapter, struct pkt_attrib *pattrib; unsigned char *pframe; struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; unsigned char *mac; unsigned char bssrate[NumRates]; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; @@ -2834,8 +2830,7 @@ static int _issue_probereq23a(struct rtw_adapter *padapter, mac = myid(&padapter->eeprompriv); - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; + pwlanhdr->frame_control = 0; if (da) { /* unicast probe request frame */ @@ -2849,7 +2844,9 @@ static int _issue_probereq23a(struct rtw_adapter *padapter, ether_addr_copy(pwlanhdr->addr2, mac); - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pwlanhdr->seq_ctrl = + cpu_to_le16(IEEE80211_SN_TO_SEQ(pmlmeext->mgnt_seq)); + pmlmeext->mgnt_seq++; SetFrameSubType(pframe, WIFI_PROBEREQ); @@ -2983,8 +2980,10 @@ void issue_auth23a(struct rtw_adapter *padapter, struct sta_info *psta, fctrl = &pwlanhdr->frame_control; *fctrl = 0; - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pwlanhdr->seq_ctrl = + cpu_to_le16(IEEE80211_SN_TO_SEQ(pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_AUTH); pframe += sizeof(struct ieee80211_hdr_3addr); @@ -3151,7 +3150,9 @@ void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status, ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); ether_addr_copy(pwlanhdr->addr3, get_my_bssid23a(&pmlmeinfo->network)); - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pwlanhdr->seq_ctrl = + cpu_to_le16(IEEE80211_SN_TO_SEQ(pmlmeext->mgnt_seq)); + pmlmeext->mgnt_seq++; if (pkt_type == WIFI_ASSOCRSP || pkt_type == WIFI_REASSOCRSP) SetFrameSubType(pwlanhdr, pkt_type); @@ -3269,7 +3270,6 @@ void issue_assocreq23a(struct rtw_adapter *padapter) unsigned char *pframe; const u8 *p; struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; unsigned int i, j, index = 0; unsigned char rf_type, bssrate[NumRates], sta_bssrate[NumRates]; struct registry_priv *pregpriv = &padapter->registrypriv; @@ -3293,13 +3293,14 @@ void issue_assocreq23a(struct rtw_adapter *padapter) pframe = (u8 *)pmgntframe->buf_addr + TXDESC_OFFSET; pwlanhdr = (struct ieee80211_hdr *)pframe; - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; + pwlanhdr->frame_control = 0; + ether_addr_copy(pwlanhdr->addr1, get_my_bssid23a(&pmlmeinfo->network)); ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); ether_addr_copy(pwlanhdr->addr3, get_my_bssid23a(&pmlmeinfo->network)); - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pwlanhdr->seq_ctrl = + cpu_to_le16(IEEE80211_SN_TO_SEQ(pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; SetFrameSubType(pframe, WIFI_ASSOCREQ); @@ -3578,7 +3579,8 @@ static int _issue_nulldata23a(struct rtw_adapter *padapter, unsigned char *da, ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); ether_addr_copy(pwlanhdr->addr3, get_my_bssid23a(&pmlmeinfo->network)); - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pwlanhdr->seq_ctrl = + cpu_to_le16(IEEE80211_SN_TO_SEQ(pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; SetFrameSubType(pframe, WIFI_DATA_NULL); @@ -3709,7 +3711,8 @@ static int _issue_qos_nulldata23a(struct rtw_adapter *padapter, ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); ether_addr_copy(pwlanhdr->addr3, get_my_bssid23a(&pmlmeinfo->network)); - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pwlanhdr->seq_ctrl = + cpu_to_le16(IEEE80211_SN_TO_SEQ(pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; SetFrameSubType(pframe, WIFI_QOS_DATA_NULL); @@ -3788,7 +3791,6 @@ static int _issue_deauth23a(struct rtw_adapter *padapter, unsigned char *da, struct pkt_attrib *pattrib; unsigned char *pframe; struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -3809,14 +3811,14 @@ static int _issue_deauth23a(struct rtw_adapter *padapter, unsigned char *da, pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct ieee80211_hdr *)pframe; - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; + pwlanhdr->frame_control = 0; ether_addr_copy(pwlanhdr->addr1, da); ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); ether_addr_copy(pwlanhdr->addr3, get_my_bssid23a(&pmlmeinfo->network)); - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pwlanhdr->seq_ctrl = + cpu_to_le16(IEEE80211_SN_TO_SEQ(pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; SetFrameSubType(pframe, WIFI_DEAUTH); @@ -3900,7 +3902,6 @@ void issue_action_spct_ch_switch23a(struct rtw_adapter *padapter, struct pkt_attrib *pattrib; unsigned char *pframe; struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; u8 category, action; @@ -3920,14 +3921,14 @@ void issue_action_spct_ch_switch23a(struct rtw_adapter *padapter, pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct ieee80211_hdr *)pframe; - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; + pwlanhdr->frame_control = 0; ether_addr_copy(pwlanhdr->addr1, ra); /* RA */ ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); /* TA */ ether_addr_copy(pwlanhdr->addr3, ra); /* DA = RA */ - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pwlanhdr->seq_ctrl = + cpu_to_le16(IEEE80211_SN_TO_SEQ(pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; SetFrameSubType(pframe, WIFI_ACTION); @@ -3966,7 +3967,6 @@ void issue_action_BA23a(struct rtw_adapter *padapter, struct pkt_attrib *pattrib; u8 *pframe; struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -3992,15 +3992,15 @@ void issue_action_BA23a(struct rtw_adapter *padapter, pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct ieee80211_hdr *)pframe; - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; + pwlanhdr->frame_control = 0; /* memcpy(pwlanhdr->addr1, get_my_bssid23a(&pmlmeinfo->network), ETH_ALEN); */ ether_addr_copy(pwlanhdr->addr1, raddr); ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); ether_addr_copy(pwlanhdr->addr3, get_my_bssid23a(&pmlmeinfo->network)); - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pwlanhdr->seq_ctrl = + cpu_to_le16(IEEE80211_SN_TO_SEQ(pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; SetFrameSubType(pframe, WIFI_ACTION); @@ -4146,7 +4146,6 @@ static void issue_action_BSSCoexistPacket(struct rtw_adapter *padapter) struct pkt_attrib *pattrib; u8 *pframe; struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; struct wlan_network *pnetwork; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -4182,14 +4181,14 @@ static void issue_action_BSSCoexistPacket(struct rtw_adapter *padapter) pframe = (u8 *)pmgntframe->buf_addr + TXDESC_OFFSET; pwlanhdr = (struct ieee80211_hdr *)pframe; - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; + pwlanhdr->frame_control = 0; ether_addr_copy(pwlanhdr->addr1, get_my_bssid23a(&pmlmeinfo->network)); ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); ether_addr_copy(pwlanhdr->addr3, get_my_bssid23a(&pmlmeinfo->network)); - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pwlanhdr->seq_ctrl = + cpu_to_le16(IEEE80211_SN_TO_SEQ(pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; SetFrameSubType(pframe, WIFI_ACTION); diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index b0a6ae3bca97..e776727c8d9b 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -100,13 +100,6 @@ enum WIFI_FRAME_SUBTYPE { cpu_to_le16(0x0f & (num)); \ } while (0) -#define SetSeqNum(pbuf, num) \ - do { \ - *(__le16 *)((size_t)(pbuf) + 22) = \ - ((*(__le16 *)((size_t)(pbuf) + 22)) & cpu_to_le16((unsigned short)0x000f)) | \ - cpu_to_le16((unsigned short)(0xfff0 & (num << 4))); \ - } while (0) - #define SetDuration(pbuf, dur) \ (*(__le16 *)((unsigned long)(pbuf) + 2) = \ cpu_to_le16(0xffff & (dur))) -- cgit v1.2.3 From 2bdbf939e0e6451d2617ff0bf47eb50987b36d04 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:00 +0200 Subject: staging: rtl8723au: wifi.h: Remove unused SetFragNum() macro Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/wifi.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index e776727c8d9b..8d3066c1817a 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -93,13 +93,6 @@ enum WIFI_FRAME_SUBTYPE { *(__le16 *)(pbuf) |= cpu_to_le16(type); \ } while (0) -#define SetFragNum(pbuf, num) \ - do { \ - *(unsigned short *)((unsigned long)(pbuf) + 22) = \ - ((*(unsigned short *)((unsigned long)(pbuf) + 22)) & le16_to_cpu(~(0x000f))) | \ - cpu_to_le16(0x0f & (num)); \ - } while (0) - #define SetDuration(pbuf, dur) \ (*(__le16 *)((unsigned long)(pbuf) + 2) = \ cpu_to_le16(0xffff & (dur))) -- cgit v1.2.3 From fd602993ba7c975c143356968001b713f20b3ccd Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:01 +0200 Subject: staging: rtl8723au: Get rid of ugly SetDuration() macro usage Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 5 +++-- drivers/staging/rtl8723au/include/wifi.h | 4 ---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c index bfe754fef8ca..a58de6775bca 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c @@ -306,7 +306,8 @@ _ConstructBeacon: } -static void ConstructPSPoll(struct rtw_adapter *padapter, u8 *pframe, u32 *pLength) +static void ConstructPSPoll(struct rtw_adapter *padapter, + u8 *pframe, u32 *pLength) { struct ieee80211_hdr *pwlanhdr; __le16 *fctrl; @@ -322,7 +323,7 @@ static void ConstructPSPoll(struct rtw_adapter *padapter, u8 *pframe, u32 *pLeng SetFrameSubType(pframe, WIFI_PSPOLL); /* AID. */ - SetDuration(pframe, (pmlmeinfo->aid | 0xc000)); + pwlanhdr->duration_id = cpu_to_le16(pmlmeinfo->aid | 0xc000); /* BSSID. */ memcpy(pwlanhdr->addr1, get_my_bssid23a(&pmlmeinfo->network), ETH_ALEN); diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index 8d3066c1817a..3791561ac3a8 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -93,10 +93,6 @@ enum WIFI_FRAME_SUBTYPE { *(__le16 *)(pbuf) |= cpu_to_le16(type); \ } while (0) -#define SetDuration(pbuf, dur) \ - (*(__le16 *)((unsigned long)(pbuf) + 2) = \ - cpu_to_le16(0xffff & (dur))) - #define SetPriority(pbuf, tid) \ (*(__le16 *)(pbuf) |= cpu_to_le16(tid & 0xf)) -- cgit v1.2.3 From c6716e1f84b2ad6edf8073ad60df36baf8d59cfd Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:02 +0200 Subject: staging: rtl8723au: Get rid of SetPrivacy()/SetPwrMgt()/SetMData() macros Set these bits directly in the code instead of fiddling with wrapper macros. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 7 ++++--- drivers/staging/rtl8723au/core/rtw_xmit.c | 6 ++++-- drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 7 ++----- drivers/staging/rtl8723au/include/wifi.h | 9 --------- 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index b8d829f95da0..2c12ba68e890 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -3091,7 +3091,8 @@ void issue_auth23a(struct rtw_adapter *padapter, struct sta_info *psta, pmlmeinfo->chg_txt, &pattrib->pktlen); - SetPrivacy(fctrl); + pwlanhdr->frame_control |= + cpu_to_le16(IEEE80211_FCTL_PROTECTED); pattrib->hdrlen = sizeof(struct ieee80211_hdr_3addr); @@ -3573,7 +3574,7 @@ static int _issue_nulldata23a(struct rtw_adapter *padapter, unsigned char *da, SetToDs(fctrl); if (power_mode) - SetPwrMgt(fctrl); + pwlanhdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); ether_addr_copy(pwlanhdr->addr1, da); ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); @@ -3697,7 +3698,7 @@ static int _issue_qos_nulldata23a(struct rtw_adapter *padapter, SetToDs(fctrl); if (pattrib->mdata) - SetMData(fctrl); + pwlanhdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA); qc = (unsigned short *)(pframe + pattrib->hdrlen - 2); diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 2ebb3df87690..a82afcb88518 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -936,9 +936,11 @@ static int rtw_make_wlanhdr(struct rtw_adapter *padapter, u8 *hdr, goto exit; } if (pattrib->mdata) - SetMData(fctrl); + pwlanhdr->frame_control |= + cpu_to_le16(IEEE80211_FCTL_MOREDATA); if (pattrib->encrypt) - SetPrivacy(fctrl); + pwlanhdr->frame_control |= + cpu_to_le16(IEEE80211_FCTL_PROTECTED); if (qos_option) { qc = (unsigned short *)(hdr + pattrib->hdrlen - 2); if (pattrib->priority) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c index a58de6775bca..dc044cf4031d 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c @@ -310,16 +310,13 @@ static void ConstructPSPoll(struct rtw_adapter *padapter, u8 *pframe, u32 *pLength) { struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; pwlanhdr = (struct ieee80211_hdr *)pframe; /* Frame control. */ - fctrl = &pwlanhdr->frame_control; - *(fctrl) = 0; - SetPwrMgt(fctrl); + pwlanhdr->frame_control = cpu_to_le16(IEEE80211_FCTL_PM); SetFrameSubType(pframe, WIFI_PSPOLL); /* AID. */ @@ -355,7 +352,7 @@ ConstructNullFunctionData(struct rtw_adapter *padapter, u8 *pframe, fctrl = &pwlanhdr->frame_control; if (bForcePowerSave) - SetPwrMgt(fctrl); + pwlanhdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); switch (cur_network->network.ifmode) { case NL80211_IFTYPE_P2P_CLIENT: diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index 3791561ac3a8..4052de75fe12 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -72,15 +72,6 @@ enum WIFI_FRAME_SUBTYPE { #define SetFrDs(pbuf) \ (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_FROMDS)) -#define SetPwrMgt(pbuf) \ - (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_PM)) - -#define SetMData(pbuf) \ - (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_MOREDATA)) - -#define SetPrivacy(pbuf) \ - (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_PROTECTED)) - #define SetFrameType(pbuf, type) \ do { \ *(__le16 *)(pbuf) &= __constant_cpu_to_le16(~(BIT(3) | BIT(2))); \ -- cgit v1.2.3 From 316f6211b492051c4060bf5f2edfb0efe98d9315 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:03 +0200 Subject: staging: rtl8723au: rtl8723a_update_ramask(): Get rid of annoying debug message There really is no need to print this message for anyone not trying to debug the driver: rtl8723a_update_ramask => mac_id:0, networkType:0x0b, mask:0x000fffff Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_halinit.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index e0d2d6e205c3..d30ba1b022ed 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1603,10 +1603,9 @@ void rtl8723a_update_ramask(struct rtw_adapter *padapter, rate_bitmap = 0x0fffffff; rate_bitmap = ODM_Get_Rate_Bitmap23a(&pHalData->odmpriv, mac_id, mask, rssi_level); - printk(KERN_DEBUG "%s => mac_id:%d, networkType:0x%02x, " - "mask:0x%08x\n\t ==> rssi_level:%d, rate_bitmap:0x%08x\n", - __func__, - mac_id, networkType, mask, rssi_level, rate_bitmap); + DBG_8723A("%s => mac_id:%d, networkType:0x%02x, " + "mask:0x%08x\n\t ==> rssi_level:%d, rate_bitmap:0x%08x\n", + __func__, mac_id, networkType, mask, rssi_level, rate_bitmap); mask &= rate_bitmap; mask |= ((raid<<28)&0xf0000000); -- cgit v1.2.3 From ec3f4e2ae1efc43ac8b63bd31877f86fffecd2c7 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:04 +0200 Subject: staging: rtl8723au: rtl8723a_cmd.c: Use ieee80211.h defines to set qos_ctrl Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c index dc044cf4031d..eb747d602f88 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c @@ -383,13 +383,14 @@ ConstructNullFunctionData(struct rtw_adapter *padapter, u8 *pframe, } if (bQoS == true) { - struct ieee80211_qos_hdr *pwlanqoshdr; + struct ieee80211_qos_hdr *qoshdr; + qoshdr = (struct ieee80211_qos_hdr *)pframe; SetFrameSubType(pframe, WIFI_QOS_DATA_NULL); - pwlanqoshdr = (struct ieee80211_qos_hdr *)pframe; - SetPriority(&pwlanqoshdr->qos_ctrl, AC); - SetEOSP(&pwlanqoshdr->qos_ctrl, bEosp); + qoshdr->qos_ctrl = cpu_to_le16(AC & IEEE80211_QOS_CTL_TID_MASK); + if (bEosp) + qoshdr->qos_ctrl |= cpu_to_le16(IEEE80211_QOS_CTL_EOSP); pktlen = sizeof(struct ieee80211_qos_hdr); } else { -- cgit v1.2.3 From e5b2a429f06df64ce3b13c9f0394a4b90f1dacce Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:05 +0200 Subject: staging: rl8723au: rtw_make_wlanhdr(): Use ieee80211_qos_hdr Use the kernel provided struct and defines to fill in qos_ctrl Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index a82afcb88518..f99e59c7f9f9 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -861,9 +861,8 @@ static int xmitframe_swencrypt(struct rtw_adapter *padapter, static int rtw_make_wlanhdr(struct rtw_adapter *padapter, u8 *hdr, struct pkt_attrib *pattrib) { - u16 *qc; - struct ieee80211_hdr *pwlanhdr = (struct ieee80211_hdr *)hdr; + struct ieee80211_qos_hdr *qoshdr; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; u8 qos_option = false; int res = _SUCCESS; @@ -942,11 +941,18 @@ static int rtw_make_wlanhdr(struct rtw_adapter *padapter, u8 *hdr, pwlanhdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); if (qos_option) { - qc = (unsigned short *)(hdr + pattrib->hdrlen - 2); - if (pattrib->priority) - SetPriority(qc, pattrib->priority); - SetEOSP(qc, pattrib->eosp); - SetAckpolicy(qc, pattrib->ack_policy); + qoshdr = (struct ieee80211_qos_hdr *)hdr; + + qoshdr->qos_ctrl = cpu_to_le16( + pattrib->priority & IEEE80211_QOS_CTL_TID_MASK); + + qoshdr->qos_ctrl |= cpu_to_le16( + (pattrib->ack_policy << 5) & + IEEE80211_QOS_CTL_ACK_POLICY_MASK); + + if (pattrib->eosp) + qoshdr->qos_ctrl |= + cpu_to_le16(IEEE80211_QOS_CTL_EOSP); } /* TODO: fill HT Control Field */ -- cgit v1.2.3 From 24af77b4af497bcf03e289e2181182eab300f2aa Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:06 +0200 Subject: staging: rtl8723au: _issue_qos_nulldata23a(): Use struct ieee80211_qos_hdr Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 2c12ba68e890..5defb71c7491 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -3662,9 +3662,8 @@ static int _issue_qos_nulldata23a(struct rtw_adapter *padapter, struct xmit_frame *pmgntframe; struct pkt_attrib *pattrib; unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; + struct ieee80211_qos_hdr *pwlanhdr; __le16 *fctrl; - u16 *qc; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -3687,7 +3686,7 @@ static int _issue_qos_nulldata23a(struct rtw_adapter *padapter, memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; + pwlanhdr = (struct ieee80211_qos_hdr *)pframe; fctrl = &pwlanhdr->frame_control; *fctrl = 0; @@ -3700,13 +3699,11 @@ static int _issue_qos_nulldata23a(struct rtw_adapter *padapter, if (pattrib->mdata) pwlanhdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA); - qc = (unsigned short *)(pframe + pattrib->hdrlen - 2); - - SetPriority(qc, tid); - - SetEOSP(qc, pattrib->eosp); - - SetAckpolicy(qc, pattrib->ack_policy); + pwlanhdr->qos_ctrl = cpu_to_le16(tid & IEEE80211_QOS_CTL_TID_MASK); + pwlanhdr->qos_ctrl |= cpu_to_le16((pattrib->ack_policy << 5) & + IEEE80211_QOS_CTL_ACK_POLICY_MASK); + if (pattrib->eosp) + pwlanhdr->qos_ctrl |= cpu_to_le16(IEEE80211_QOS_CTL_EOSP); ether_addr_copy(pwlanhdr->addr1, da); ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); -- cgit v1.2.3 From cd70034159f9c368f389816918f9e71468745a3a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:07 +0200 Subject: staging: rtl8723au: Get rid of obsolete SetPriority()/SetEOSP()/SetAckpolicy() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/wifi.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index 4052de75fe12..bfc0e1f3b71f 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -84,15 +84,6 @@ enum WIFI_FRAME_SUBTYPE { *(__le16 *)(pbuf) |= cpu_to_le16(type); \ } while (0) -#define SetPriority(pbuf, tid) \ - (*(__le16 *)(pbuf) |= cpu_to_le16(tid & 0xf)) - -#define SetEOSP(pbuf, eosp) \ - (*(__le16 *)(pbuf) |= cpu_to_le16((eosp & 1) << 4)) - -#define SetAckpolicy(pbuf, ack) \ - (*(__le16 *)(pbuf) |= cpu_to_le16((ack & 3) << 5)) - #define _ASOCREQ_IE_OFFSET_ 4 /* excluding wlan_hdr */ #define _ASOCRSP_IE_OFFSET_ 6 #define _REASOCREQ_IE_OFFSET_ 10 -- cgit v1.2.3 From 0d280584c0c95b49859a6ffc2d9d2171e605716f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:08 +0200 Subject: staging: rtl8723au: Remove unused SetFrameType() macro Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/wifi.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index bfc0e1f3b71f..6b2f83ed909a 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -72,12 +72,6 @@ enum WIFI_FRAME_SUBTYPE { #define SetFrDs(pbuf) \ (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_FROMDS)) -#define SetFrameType(pbuf, type) \ - do { \ - *(__le16 *)(pbuf) &= __constant_cpu_to_le16(~(BIT(3) | BIT(2))); \ - *(__le16 *)(pbuf) |= __constant_cpu_to_le16(type); \ - } while (0) - #define SetFrameSubType(pbuf, type) \ do { \ *(__le16 *)(pbuf) &= cpu_to_le16(~(BIT(7) | BIT(6) | BIT(5) | BIT(4) | BIT(3) | BIT(2))); \ -- cgit v1.2.3 From b2f72caefea52659c3324ef4febfbd725dd6b60a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:09 +0200 Subject: staging: rtl8723au: rtw_xmit.c: Use IEEE80211_[FS]TYPE_ defines In addition pkt_attrib->type a u16 and get rid of pattrib->stype Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 8 ++++---- drivers/staging/rtl8723au/include/rtw_xmit.h | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index f99e59c7f9f9..d92673bdcf89 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -422,7 +422,7 @@ static void set_qos(struct sk_buff *skb, struct pkt_attrib *pattrib) pattrib->priority = UserPriority; pattrib->hdrlen = sizeof(struct ieee80211_qos_hdr); - pattrib->subtype = WIFI_QOS_DATA_TYPE; + pattrib->type = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_DATA; } static int update_attrib(struct rtw_adapter *padapter, @@ -537,7 +537,7 @@ static int update_attrib(struct rtw_adapter *padapter, pattrib->pkt_hdrlen = ETH_HLEN; pattrib->hdrlen = sizeof(struct ieee80211_hdr_3addr); - pattrib->subtype = WIFI_DATA_TYPE; + pattrib->type = IEEE80211_FTYPE_DATA; pattrib->priority = 0; if (check_fwstate(pmlmepriv, WIFI_AP_STATE | WIFI_ADHOC_STATE | @@ -895,9 +895,9 @@ static int rtw_make_wlanhdr(struct rtw_adapter *padapter, u8 *hdr, memset(hdr, 0, WLANHDR_OFFSET); - SetFrameSubType(fctrl, pattrib->subtype); + pwlanhdr->frame_control = cpu_to_le16(pattrib->type); - if (pattrib->subtype & WIFI_DATA_TYPE) { + if (pattrib->type & IEEE80211_FTYPE_DATA) { if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true)) { /* to_ds = 1, fr_ds = 0; */ /* Data transfer to AP */ diff --git a/drivers/staging/rtl8723au/include/rtw_xmit.h b/drivers/staging/rtl8723au/include/rtw_xmit.h index 53030b6a376e..32a844170327 100644 --- a/drivers/staging/rtl8723au/include/rtw_xmit.h +++ b/drivers/staging/rtl8723au/include/rtw_xmit.h @@ -114,8 +114,7 @@ struct hw_xmit { /* reduce size */ struct pkt_attrib { - u8 type; - u8 subtype; + u16 type; u8 bswenc; u8 dhcp_pkt; u16 ether_type; -- cgit v1.2.3 From 6023377b47167a90f0d776f44f97ad6b21126718 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 14:36:48 +0200 Subject: staging: rtl8723au: rtl8723a_cmd.c: Use ieee80211.h provided fctl bits v2: Fix endian bug reported by Dan Carpenter Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c index eb747d602f88..d4609c4bfc64 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c @@ -215,7 +215,8 @@ static void ConstructBeacon(struct rtw_adapter *padapter, u8 *pframe, u32 *pLeng pwlanhdr = (struct ieee80211_hdr *)pframe; - pwlanhdr->frame_control = 0; + pwlanhdr->frame_control = + cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON); memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); @@ -224,8 +225,6 @@ static void ConstructBeacon(struct rtw_adapter *padapter, u8 *pframe, u32 *pLeng /* A Beacon frame shouldn't have fragment bits set */ pwlanhdr->seq_ctrl = 0; - SetFrameSubType(pframe, WIFI_BEACON); - pframe += sizeof(struct ieee80211_hdr_3addr); pktlen = sizeof (struct ieee80211_hdr_3addr); @@ -316,8 +315,9 @@ static void ConstructPSPoll(struct rtw_adapter *padapter, pwlanhdr = (struct ieee80211_hdr *)pframe; /* Frame control. */ - pwlanhdr->frame_control = cpu_to_le16(IEEE80211_FCTL_PM); - SetFrameSubType(pframe, WIFI_PSPOLL); + pwlanhdr->frame_control = + cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL); + pwlanhdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); /* AID. */ pwlanhdr->duration_id = cpu_to_le16(pmlmeinfo->aid | 0xc000); @@ -386,7 +386,9 @@ ConstructNullFunctionData(struct rtw_adapter *padapter, u8 *pframe, struct ieee80211_qos_hdr *qoshdr; qoshdr = (struct ieee80211_qos_hdr *)pframe; - SetFrameSubType(pframe, WIFI_QOS_DATA_NULL); + qoshdr->frame_control |= + cpu_to_le16(IEEE80211_FTYPE_DATA | + IEEE80211_STYPE_QOS_NULLFUNC); qoshdr->qos_ctrl = cpu_to_le16(AC & IEEE80211_QOS_CTL_TID_MASK); if (bEosp) @@ -394,7 +396,9 @@ ConstructNullFunctionData(struct rtw_adapter *padapter, u8 *pframe, pktlen = sizeof(struct ieee80211_qos_hdr); } else { - SetFrameSubType(pframe, WIFI_DATA_NULL); + pwlanhdr->frame_control |= + cpu_to_le16(IEEE80211_FTYPE_DATA | + IEEE80211_STYPE_NULLFUNC); pktlen = sizeof(struct ieee80211_hdr_3addr); } @@ -419,15 +423,15 @@ static void ConstructProbeRsp(struct rtw_adapter *padapter, u8 *pframe, mac = myid(&padapter->eeprompriv); bssid = cur_network->MacAddress; - pwlanhdr->frame_control = 0; + pwlanhdr->frame_control = + cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); + pwlanhdr->seq_ctrl = 0; memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN); memcpy(pwlanhdr->addr2, mac, ETH_ALEN); memcpy(pwlanhdr->addr3, bssid, ETH_ALEN); - SetFrameSubType(&pwlanhdr->frame_control, WIFI_PROBERSP); - pktlen = sizeof(struct ieee80211_hdr_3addr); pframe += pktlen; -- cgit v1.2.3 From 036cdd9cb34a10aabb80a97a41fb9dcfead7d113 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:11 +0200 Subject: staging: rtl8723au: ioctl_cfg80211.c: Use ieee80211.h provided fctl bits Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 63230d4684c7..ad4fe79123b1 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -310,15 +310,17 @@ static int rtw_cfg80211_inform_bss(struct rtw_adapter *padapter, pwlanhdr = (struct ieee80211_hdr *)pbuf; - pwlanhdr->frame_control = 0; pwlanhdr->seq_ctrl = 0; if (pnetwork->network.reserved == 1) { /* WIFI_BEACON */ eth_broadcast_addr(pwlanhdr->addr1); - SetFrameSubType(pbuf, WIFI_BEACON); + pwlanhdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | + IEEE80211_STYPE_BEACON); } else { memcpy(pwlanhdr->addr1, myid(&padapter->eeprompriv), ETH_ALEN); - SetFrameSubType(pbuf, WIFI_PROBERSP); + pwlanhdr->frame_control = + cpu_to_le16(IEEE80211_FTYPE_MGMT | + IEEE80211_STYPE_PROBE_RESP); } memcpy(pwlanhdr->addr2, pnetwork->network.MacAddress, ETH_ALEN); @@ -2484,7 +2486,8 @@ void rtw_cfg80211_indicate_sta_disassoc(struct rtw_adapter *padapter, pmgmt_frame = mgmt_buf; pwlanhdr = (struct ieee80211_hdr *)pmgmt_frame; - pwlanhdr->frame_control = 0; + pwlanhdr->frame_control = + cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DEAUTH); memcpy(pwlanhdr->addr1, myid(&padapter->eeprompriv), ETH_ALEN); memcpy(pwlanhdr->addr2, da, ETH_ALEN); @@ -2493,7 +2496,6 @@ void rtw_cfg80211_indicate_sta_disassoc(struct rtw_adapter *padapter, pwlanhdr->seq_ctrl = cpu_to_le16(IEEE80211_SN_TO_SEQ(pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; - SetFrameSubType(pmgmt_frame, WIFI_DEAUTH); pmgmt_frame += sizeof(struct ieee80211_hdr_3addr); frame_len = sizeof(struct ieee80211_hdr_3addr); -- cgit v1.2.3 From c2bfb149b43a1ed636ff8a536a130733f892274f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:12 +0200 Subject: staging: rtl8723au: rtw_mlme_ext.c: Get rid of most WIFI_* frame type usage Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 49 ++++++++++++--------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 5defb71c7491..1178500bef7b 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -2457,15 +2457,14 @@ void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms) pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct ieee80211_hdr *)pframe; - pwlanhdr->frame_control = 0; + pwlanhdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | + IEEE80211_STYPE_BEACON); pwlanhdr->seq_ctrl = 0; ether_addr_copy(pwlanhdr->addr1, bc_addr); ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); ether_addr_copy(pwlanhdr->addr3, get_my_bssid23a(cur_network)); - SetFrameSubType(pframe, WIFI_BEACON); - pframe += sizeof(struct ieee80211_hdr_3addr); pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); @@ -2626,7 +2625,8 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, mac = myid(&padapter->eeprompriv); bssid = cur_network->MacAddress; - pwlanhdr->frame_control = 0; + pwlanhdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | + IEEE80211_STYPE_PROBE_RESP); ether_addr_copy(pwlanhdr->addr1, da); ether_addr_copy(pwlanhdr->addr2, mac); @@ -2635,7 +2635,6 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, pwlanhdr->seq_ctrl = cpu_to_le16(IEEE80211_SN_TO_SEQ(pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; - SetFrameSubType(&pwlanhdr->frame_control, WIFI_PROBERSP); pattrib->hdrlen = sizeof(struct ieee80211_hdr_3addr); pattrib->pktlen = pattrib->hdrlen; @@ -2830,7 +2829,8 @@ static int _issue_probereq23a(struct rtw_adapter *padapter, mac = myid(&padapter->eeprompriv); - pwlanhdr->frame_control = 0; + pwlanhdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | + IEEE80211_STYPE_PROBE_REQ); if (da) { /* unicast probe request frame */ @@ -2848,7 +2848,6 @@ static int _issue_probereq23a(struct rtw_adapter *padapter, cpu_to_le16(IEEE80211_SN_TO_SEQ(pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_PROBEREQ); pframe += sizeof (struct ieee80211_hdr_3addr); pattrib->pktlen = sizeof (struct ieee80211_hdr_3addr); @@ -2957,7 +2956,6 @@ void issue_auth23a(struct rtw_adapter *padapter, struct sta_info *psta, struct pkt_attrib *pattrib; unsigned char *pframe; struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; unsigned int val32; unsigned short val16; int use_shared_key = 0; @@ -2977,15 +2975,12 @@ void issue_auth23a(struct rtw_adapter *padapter, struct sta_info *psta, pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct ieee80211_hdr *)pframe; - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; - + pwlanhdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | + IEEE80211_STYPE_AUTH); pwlanhdr->seq_ctrl = cpu_to_le16(IEEE80211_SN_TO_SEQ(pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_AUTH); - pframe += sizeof(struct ieee80211_hdr_3addr); pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); @@ -3294,7 +3289,8 @@ void issue_assocreq23a(struct rtw_adapter *padapter) pframe = (u8 *)pmgntframe->buf_addr + TXDESC_OFFSET; pwlanhdr = (struct ieee80211_hdr *)pframe; - pwlanhdr->frame_control = 0; + pwlanhdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | + IEEE80211_STYPE_ASSOC_REQ); ether_addr_copy(pwlanhdr->addr1, get_my_bssid23a(&pmlmeinfo->network)); ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); @@ -3303,7 +3299,6 @@ void issue_assocreq23a(struct rtw_adapter *padapter) pwlanhdr->seq_ctrl = cpu_to_le16(IEEE80211_SN_TO_SEQ(pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_ASSOCREQ); pframe += sizeof(struct ieee80211_hdr_3addr); pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); @@ -3566,7 +3561,8 @@ static int _issue_nulldata23a(struct rtw_adapter *padapter, unsigned char *da, pwlanhdr = (struct ieee80211_hdr *)pframe; fctrl = &pwlanhdr->frame_control; - *fctrl = 0; + pwlanhdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | + IEEE80211_STYPE_NULLFUNC); if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) SetFrDs(fctrl); @@ -3583,7 +3579,6 @@ static int _issue_nulldata23a(struct rtw_adapter *padapter, unsigned char *da, pwlanhdr->seq_ctrl = cpu_to_le16(IEEE80211_SN_TO_SEQ(pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_DATA_NULL); pframe += sizeof(struct ieee80211_hdr_3addr); pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); @@ -3689,7 +3684,8 @@ static int _issue_qos_nulldata23a(struct rtw_adapter *padapter, pwlanhdr = (struct ieee80211_qos_hdr *)pframe; fctrl = &pwlanhdr->frame_control; - *fctrl = 0; + pwlanhdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | + IEEE80211_STYPE_QOS_NULLFUNC); if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) SetFrDs(fctrl); @@ -3712,7 +3708,6 @@ static int _issue_qos_nulldata23a(struct rtw_adapter *padapter, pwlanhdr->seq_ctrl = cpu_to_le16(IEEE80211_SN_TO_SEQ(pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_QOS_DATA_NULL); pframe += sizeof(struct ieee80211_qos_hdr); pattrib->pktlen = sizeof(struct ieee80211_qos_hdr); @@ -3809,7 +3804,8 @@ static int _issue_deauth23a(struct rtw_adapter *padapter, unsigned char *da, pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct ieee80211_hdr *)pframe; - pwlanhdr->frame_control = 0; + pwlanhdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | + IEEE80211_STYPE_DEAUTH); ether_addr_copy(pwlanhdr->addr1, da); ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); @@ -3818,7 +3814,6 @@ static int _issue_deauth23a(struct rtw_adapter *padapter, unsigned char *da, pwlanhdr->seq_ctrl = cpu_to_le16(IEEE80211_SN_TO_SEQ(pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_DEAUTH); pframe += sizeof(struct ieee80211_hdr_3addr); pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); @@ -3919,7 +3914,8 @@ void issue_action_spct_ch_switch23a(struct rtw_adapter *padapter, pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct ieee80211_hdr *)pframe; - pwlanhdr->frame_control = 0; + pwlanhdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | + IEEE80211_STYPE_ACTION); ether_addr_copy(pwlanhdr->addr1, ra); /* RA */ ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); /* TA */ @@ -3928,7 +3924,6 @@ void issue_action_spct_ch_switch23a(struct rtw_adapter *padapter, pwlanhdr->seq_ctrl = cpu_to_le16(IEEE80211_SN_TO_SEQ(pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_ACTION); pframe += sizeof(struct ieee80211_hdr_3addr); pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); @@ -3990,7 +3985,8 @@ void issue_action_BA23a(struct rtw_adapter *padapter, pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct ieee80211_hdr *)pframe; - pwlanhdr->frame_control = 0; + pwlanhdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | + IEEE80211_STYPE_ACTION); /* memcpy(pwlanhdr->addr1, get_my_bssid23a(&pmlmeinfo->network), ETH_ALEN); */ ether_addr_copy(pwlanhdr->addr1, raddr); @@ -4000,7 +3996,6 @@ void issue_action_BA23a(struct rtw_adapter *padapter, pwlanhdr->seq_ctrl = cpu_to_le16(IEEE80211_SN_TO_SEQ(pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_ACTION); pframe += sizeof(struct ieee80211_hdr_3addr); pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); @@ -4179,7 +4174,8 @@ static void issue_action_BSSCoexistPacket(struct rtw_adapter *padapter) pframe = (u8 *)pmgntframe->buf_addr + TXDESC_OFFSET; pwlanhdr = (struct ieee80211_hdr *)pframe; - pwlanhdr->frame_control = 0; + pwlanhdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | + IEEE80211_STYPE_ACTION); ether_addr_copy(pwlanhdr->addr1, get_my_bssid23a(&pmlmeinfo->network)); ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); @@ -4188,7 +4184,6 @@ static void issue_action_BSSCoexistPacket(struct rtw_adapter *padapter) pwlanhdr->seq_ctrl = cpu_to_le16(IEEE80211_SN_TO_SEQ(pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_ACTION); pframe += sizeof(struct ieee80211_hdr_3addr); pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); -- cgit v1.2.3 From 5986a3f23a471b17b8b50d9878ded3bfb1dd549d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:13 +0200 Subject: staging: rtl8723au: Declare issue_asocrsp() static Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 19 +++++++++++-------- drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 2 -- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 1178500bef7b..453b53f0955f 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -46,6 +46,9 @@ static int OnAction23a_ht(struct rtw_adapter *padapter, struct recv_frame *precv static int OnAction23a_wmm(struct rtw_adapter *padapter, struct recv_frame *precv_frame); static int OnAction23a_p2p(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static void issue_asocrsp(struct rtw_adapter *padapter, unsigned short status, + struct sta_info *pstat, int pkt_type); + static struct mlme_handler mlme_sta_tbl[]={ {"OnAssocReq23a", &OnAssocReq23a}, {"OnAssocRsp23a", &OnAssocRsp23a}, @@ -1693,11 +1696,11 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) /* issue assoc rsp before notify station join event. */ if (ieee80211_is_assoc_req(mgmt->frame_control)) - issue_asocrsp23a(padapter, status, pstat, - WIFI_ASSOCRSP); + issue_asocrsp(padapter, status, pstat, + WIFI_ASSOCRSP); else - issue_asocrsp23a(padapter, status, pstat, - WIFI_REASSOCRSP); + issue_asocrsp(padapter, status, pstat, + WIFI_REASSOCRSP); /* 2 - report to upper layer */ DBG_8723A("indicate_sta_join_event to upper layer - hostapd\n"); @@ -1722,9 +1725,9 @@ OnAssocReq23aFail: #ifdef CONFIG_8723AU_AP_MODE pstat->aid = 0; if (ieee80211_is_assoc_req(mgmt->frame_control)) - issue_asocrsp23a(padapter, status, pstat, WIFI_ASSOCRSP); + issue_asocrsp(padapter, status, pstat, WIFI_ASSOCRSP); else - issue_asocrsp23a(padapter, status, pstat, WIFI_REASSOCRSP); + issue_asocrsp(padapter, status, pstat, WIFI_REASSOCRSP); #endif #endif /* CONFIG_8723AU_AP_MODE */ @@ -3108,8 +3111,8 @@ void issue_auth23a(struct rtw_adapter *padapter, struct sta_info *psta, return; } -void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status, - struct sta_info *pstat, int pkt_type) +static void issue_asocrsp(struct rtw_adapter *padapter, unsigned short status, + struct sta_info *pstat, int pkt_type) { #ifdef CONFIG_8723AU_AP_MODE struct xmit_frame *pmgntframe; diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 043ed7ad11b8..7f2607d97161 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -580,8 +580,6 @@ void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms); void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, u8 is_valid_p2p_probereq); void issue_assocreq23a(struct rtw_adapter *padapter); -void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status, - struct sta_info *pstat, int pkt_type); void issue_auth23a(struct rtw_adapter *padapter, struct sta_info *psta, unsigned short status); void issue_probereq23a(struct rtw_adapter *padapter, struct cfg80211_ssid *pssid, -- cgit v1.2.3 From 6ebd294804dfbba9a850395e9543c51d8149ff80 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:14 +0200 Subject: staging: rtl8723au: Fix issue_assocrsp() to use IEEE80211_STYPE_* defines Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 28 +++++++++++++-------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 453b53f0955f..e58b71796bd7 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -46,8 +46,8 @@ static int OnAction23a_ht(struct rtw_adapter *padapter, struct recv_frame *precv static int OnAction23a_wmm(struct rtw_adapter *padapter, struct recv_frame *precv_frame); static int OnAction23a_p2p(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -static void issue_asocrsp(struct rtw_adapter *padapter, unsigned short status, - struct sta_info *pstat, int pkt_type); +static void issue_assocrsp(struct rtw_adapter *padapter, unsigned short status, + struct sta_info *pstat, u16 pkt_type); static struct mlme_handler mlme_sta_tbl[]={ {"OnAssocReq23a", &OnAssocReq23a}, @@ -1696,11 +1696,11 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) /* issue assoc rsp before notify station join event. */ if (ieee80211_is_assoc_req(mgmt->frame_control)) - issue_asocrsp(padapter, status, pstat, - WIFI_ASSOCRSP); + issue_assocrsp(padapter, status, pstat, + IEEE80211_STYPE_ASSOC_RESP); else - issue_asocrsp(padapter, status, pstat, - WIFI_REASSOCRSP); + issue_assocrsp(padapter, status, pstat, + IEEE80211_STYPE_REASSOC_RESP); /* 2 - report to upper layer */ DBG_8723A("indicate_sta_join_event to upper layer - hostapd\n"); @@ -1725,9 +1725,11 @@ OnAssocReq23aFail: #ifdef CONFIG_8723AU_AP_MODE pstat->aid = 0; if (ieee80211_is_assoc_req(mgmt->frame_control)) - issue_asocrsp(padapter, status, pstat, WIFI_ASSOCRSP); + issue_assocrsp(padapter, status, pstat, + IEEE80211_STYPE_ASSOC_RESP); else - issue_asocrsp(padapter, status, pstat, WIFI_REASSOCRSP); + issue_assocrsp(padapter, status, pstat, + IEEE80211_STYPE_REASSOC_RESP); #endif #endif /* CONFIG_8723AU_AP_MODE */ @@ -3111,8 +3113,8 @@ void issue_auth23a(struct rtw_adapter *padapter, struct sta_info *psta, return; } -static void issue_asocrsp(struct rtw_adapter *padapter, unsigned short status, - struct sta_info *pstat, int pkt_type) +static void issue_assocrsp(struct rtw_adapter *padapter, unsigned short status, + struct sta_info *pstat, u16 pkt_type) { #ifdef CONFIG_8723AU_AP_MODE struct xmit_frame *pmgntframe; @@ -3143,7 +3145,7 @@ static void issue_asocrsp(struct rtw_adapter *padapter, unsigned short status, pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct ieee80211_hdr *)pframe; - pwlanhdr->frame_control = 0; + pwlanhdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | pkt_type); ether_addr_copy(pwlanhdr->addr1, pstat->hwaddr); ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); @@ -3153,10 +3155,6 @@ static void issue_asocrsp(struct rtw_adapter *padapter, unsigned short status, cpu_to_le16(IEEE80211_SN_TO_SEQ(pmlmeext->mgnt_seq)); pmlmeext->mgnt_seq++; - if (pkt_type == WIFI_ASSOCRSP || pkt_type == WIFI_REASSOCRSP) - SetFrameSubType(pwlanhdr, pkt_type); - else - return; pattrib->hdrlen = sizeof(struct ieee80211_hdr_3addr); pattrib->pktlen += pattrib->hdrlen; -- cgit v1.2.3 From d181ee37267db42d63b1bd58d5b4af7756219933 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:15 +0200 Subject: staging: rtl8723au: Get rid of duplicate ieee80211 frame_control defines This is all defined nicely in ieee80211.h, this was all duplication serving no other purpose than to obfuscate the code. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/wifi.h | 49 -------------------------------- 1 file changed, 49 deletions(-) diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index 6b2f83ed909a..65cc4a9e1e2e 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -23,61 +23,12 @@ */ #define WiFiNavUpperUs 30000 /* 30 ms */ -enum WIFI_FRAME_TYPE { - WIFI_MGT_TYPE = (0), - WIFI_CTRL_TYPE = (BIT(2)), - WIFI_DATA_TYPE = (BIT(3)), - WIFI_QOS_DATA_TYPE = (BIT(7)|BIT(3)), /* QoS Data */ -}; - -enum WIFI_FRAME_SUBTYPE { - /* below is for mgt frame */ - WIFI_ASSOCREQ = (0 | WIFI_MGT_TYPE), - WIFI_ASSOCRSP = (BIT(4) | WIFI_MGT_TYPE), - WIFI_REASSOCREQ = (BIT(5) | WIFI_MGT_TYPE), - WIFI_REASSOCRSP = (BIT(5) | BIT(4) | WIFI_MGT_TYPE), - WIFI_PROBEREQ = (BIT(6) | WIFI_MGT_TYPE), - WIFI_PROBERSP = (BIT(6) | BIT(4) | WIFI_MGT_TYPE), - WIFI_BEACON = (BIT(7) | WIFI_MGT_TYPE), - WIFI_ATIM = (BIT(7) | BIT(4) | WIFI_MGT_TYPE), - WIFI_DISASSOC = (BIT(7) | BIT(5) | WIFI_MGT_TYPE), - WIFI_AUTH = (BIT(7) | BIT(5) | BIT(4) | WIFI_MGT_TYPE), - WIFI_DEAUTH = (BIT(7) | BIT(6) | WIFI_MGT_TYPE), - WIFI_ACTION = (BIT(7) | BIT(6) | BIT(4) | WIFI_MGT_TYPE), - - /* below is for control frame */ - WIFI_PSPOLL = (BIT(7) | BIT(5) | WIFI_CTRL_TYPE), - WIFI_RTS = (BIT(7) | BIT(5) | BIT(4) | WIFI_CTRL_TYPE), - WIFI_CTS = (BIT(7) | BIT(6) | WIFI_CTRL_TYPE), - WIFI_ACK = (BIT(7) | BIT(6) | BIT(4) | WIFI_CTRL_TYPE), - WIFI_CFEND = (BIT(7) | BIT(6) | BIT(5) | WIFI_CTRL_TYPE), - WIFI_CFEND_CFACK = (BIT(7) | BIT(6) | BIT(5) | BIT(4) | WIFI_CTRL_TYPE), - - /* below is for data frame */ - WIFI_DATA = (0 | WIFI_DATA_TYPE), - WIFI_DATA_CFACK = (BIT(4) | WIFI_DATA_TYPE), - WIFI_DATA_CFPOLL = (BIT(5) | WIFI_DATA_TYPE), - WIFI_DATA_CFACKPOLL = (BIT(5) | BIT(4) | WIFI_DATA_TYPE), - WIFI_DATA_NULL = (BIT(6) | WIFI_DATA_TYPE), - WIFI_CF_ACK = (BIT(6) | BIT(4) | WIFI_DATA_TYPE), - WIFI_CF_POLL = (BIT(6) | BIT(5) | WIFI_DATA_TYPE), - WIFI_CF_ACKPOLL = (BIT(6) | BIT(5) | BIT(4) | WIFI_DATA_TYPE), - WIFI_QOS_DATA_NULL = (BIT(6) | WIFI_QOS_DATA_TYPE), -}; - - #define SetToDs(pbuf) \ (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_TODS)) #define SetFrDs(pbuf) \ (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_FROMDS)) -#define SetFrameSubType(pbuf, type) \ - do { \ - *(__le16 *)(pbuf) &= cpu_to_le16(~(BIT(7) | BIT(6) | BIT(5) | BIT(4) | BIT(3) | BIT(2))); \ - *(__le16 *)(pbuf) |= cpu_to_le16(type); \ - } while (0) - #define _ASOCREQ_IE_OFFSET_ 4 /* excluding wlan_hdr */ #define _ASOCRSP_IE_OFFSET_ 6 #define _REASOCREQ_IE_OFFSET_ 10 -- cgit v1.2.3 From 863b314f8434e286ef54fa4508fc9110e5255b13 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:16 +0200 Subject: staging: rtl8723au: rtw_mlme_ext.c: Get rid of SetToDs()/SetFrDs() usage Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index e58b71796bd7..f724799b6bb1 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -3534,7 +3534,6 @@ static int _issue_nulldata23a(struct rtw_adapter *padapter, unsigned char *da, struct pkt_attrib *pattrib; unsigned char *pframe; struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; struct xmit_priv *pxmitpriv; struct mlme_ext_priv *pmlmeext; struct mlme_ext_info *pmlmeinfo; @@ -3561,14 +3560,13 @@ static int _issue_nulldata23a(struct rtw_adapter *padapter, unsigned char *da, pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct ieee80211_hdr *)pframe; - fctrl = &pwlanhdr->frame_control; pwlanhdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC); if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) - SetFrDs(fctrl); + pwlanhdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_FROMDS); else if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) - SetToDs(fctrl); + pwlanhdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_TODS); if (power_mode) pwlanhdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); @@ -3659,7 +3657,6 @@ static int _issue_qos_nulldata23a(struct rtw_adapter *padapter, struct pkt_attrib *pattrib; unsigned char *pframe; struct ieee80211_qos_hdr *pwlanhdr; - __le16 *fctrl; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -3684,14 +3681,13 @@ static int _issue_qos_nulldata23a(struct rtw_adapter *padapter, pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct ieee80211_qos_hdr *)pframe; - fctrl = &pwlanhdr->frame_control; pwlanhdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_NULLFUNC); if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) - SetFrDs(fctrl); + pwlanhdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_FROMDS); else if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) - SetToDs(fctrl); + pwlanhdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_TODS); if (pattrib->mdata) pwlanhdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA); -- cgit v1.2.3 From c26e95737be5e07c68f7b2828fa3c5d5ff2387e0 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:17 +0200 Subject: staging: rtl8723au: rtw_xmit.c: Get rid of SetToDs()/SetFrDs() usage Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index d92673bdcf89..3869386f441a 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -866,7 +866,6 @@ static int rtw_make_wlanhdr(struct rtw_adapter *padapter, u8 *hdr, struct mlme_priv *pmlmepriv = &padapter->mlmepriv; u8 qos_option = false; int res = _SUCCESS; - __le16 *fctrl = &pwlanhdr->frame_control; struct sta_info *psta; @@ -901,7 +900,8 @@ static int rtw_make_wlanhdr(struct rtw_adapter *padapter, u8 *hdr, if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true)) { /* to_ds = 1, fr_ds = 0; */ /* Data transfer to AP */ - SetToDs(fctrl); + pwlanhdr->frame_control |= + cpu_to_le16(IEEE80211_FCTL_TODS); memcpy(pwlanhdr->addr1, get_bssid(pmlmepriv), ETH_ALEN); memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN); memcpy(pwlanhdr->addr3, pattrib->dst, ETH_ALEN); @@ -912,7 +912,8 @@ static int rtw_make_wlanhdr(struct rtw_adapter *padapter, u8 *hdr, } else if ((check_fwstate(pmlmepriv, WIFI_AP_STATE) == true)) { /* to_ds = 0, fr_ds = 1; */ - SetFrDs(fctrl); + pwlanhdr->frame_control |= + cpu_to_le16(IEEE80211_FCTL_FROMDS); memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN); memcpy(pwlanhdr->addr2, get_bssid(pmlmepriv), ETH_ALEN); memcpy(pwlanhdr->addr3, pattrib->src, ETH_ALEN); -- cgit v1.2.3 From cade4108a8380bd47cbb0ee9ffdcd3a25edb56b7 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:18 +0200 Subject: staging: rtl8723au: rtl8723a_cmd.c: Get rid of SetToDs()/SetFrDs() usage Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c index d4609c4bfc64..e78f773af105 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c @@ -337,7 +337,6 @@ ConstructNullFunctionData(struct rtw_adapter *padapter, u8 *pframe, u8 bEosp, u8 bForcePowerSave) { struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; u32 pktlen; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_network *cur_network = &pmlmepriv->cur_network; @@ -349,15 +348,13 @@ ConstructNullFunctionData(struct rtw_adapter *padapter, u8 *pframe, pwlanhdr->frame_control = 0; pwlanhdr->seq_ctrl = 0; - fctrl = &pwlanhdr->frame_control; - if (bForcePowerSave) pwlanhdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); switch (cur_network->network.ifmode) { case NL80211_IFTYPE_P2P_CLIENT: case NL80211_IFTYPE_STATION: - SetToDs(fctrl); + pwlanhdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_TODS); memcpy(pwlanhdr->addr1, get_my_bssid23a(&pmlmeinfo->network), ETH_ALEN); memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), @@ -366,7 +363,7 @@ ConstructNullFunctionData(struct rtw_adapter *padapter, u8 *pframe, break; case NL80211_IFTYPE_P2P_GO: case NL80211_IFTYPE_AP: - SetFrDs(fctrl); + pwlanhdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_FROMDS); memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN); memcpy(pwlanhdr->addr2, get_my_bssid23a(&pmlmeinfo->network), ETH_ALEN); -- cgit v1.2.3 From 33a46422a0a5b376441e3f98f69c1d05108dc7b1 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:19 +0200 Subject: staging: rtl8723au: wifi.h: Get rid of last ugly frame_control manipulation macros Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/wifi.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index 65cc4a9e1e2e..cccea6a50b3a 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -23,12 +23,6 @@ */ #define WiFiNavUpperUs 30000 /* 30 ms */ -#define SetToDs(pbuf) \ - (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_TODS)) - -#define SetFrDs(pbuf) \ - (*(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_FROMDS)) - #define _ASOCREQ_IE_OFFSET_ 4 /* excluding wlan_hdr */ #define _ASOCRSP_IE_OFFSET_ 6 #define _REASOCREQ_IE_OFFSET_ 10 -- cgit v1.2.3 From 0e176853f95d6cd2a9373f08579523b2b2d9baa7 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:20 +0200 Subject: staging: rtl8723au: rtw_mlme_ext.c: Declare a number of functions static These are all just used locally, no point cluttering the kernel namespace with them. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 121 +++++++++++++---------- drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 17 ---- 2 files changed, 70 insertions(+), 68 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index f724799b6bb1..edf29ce4eb00 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -46,8 +46,25 @@ static int OnAction23a_ht(struct rtw_adapter *padapter, struct recv_frame *precv static int OnAction23a_wmm(struct rtw_adapter *padapter, struct recv_frame *precv_frame); static int OnAction23a_p2p(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static void issue_assocreq(struct rtw_adapter *padapter); static void issue_assocrsp(struct rtw_adapter *padapter, unsigned short status, struct sta_info *pstat, u16 pkt_type); +static void issue_probereq(struct rtw_adapter *padapter, + struct cfg80211_ssid *pssid, u8 *da); +static int issue_probereq_ex(struct rtw_adapter *padapter, + struct cfg80211_ssid *pssid, + u8 *da, int try_cnt, int wait_ms); +static void issue_probersp(struct rtw_adapter *padapter, unsigned char *da, + u8 is_valid_p2p_probereq); +static void issue_auth(struct rtw_adapter *padapter, struct sta_info *psta, + unsigned short status); +static int issue_deauth_ex(struct rtw_adapter *padapter, u8 *da, + unsigned short reason, int try_cnt, int wait_ms); +static void start_clnt_assoc(struct rtw_adapter *padapter); +static void start_clnt_auth(struct rtw_adapter *padapter); +static void start_clnt_join(struct rtw_adapter *padapter); +static void start_create_ibss(struct rtw_adapter *padapter); + static struct mlme_handler mlme_sta_tbl[]={ {"OnAssocReq23a", &OnAssocReq23a}, @@ -698,7 +715,7 @@ OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) if (check_fwstate(pmlmepriv, _FW_LINKED) && pmlmepriv->cur_network.join_res) - issue_probersp23a(padapter, mgmt->sa, false); + issue_probersp(padapter, mgmt->sa, false); out: return _SUCCESS; @@ -787,7 +804,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) rtw_update_TSF(pmlmeext, mgmt); /* start auth */ - start_clnt_auth23a(padapter); + start_clnt_auth(padapter); return _SUCCESS; } @@ -1012,10 +1029,10 @@ OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) } } - /* Now, we are going to issue_auth23a... */ + /* Now, we are going to issue_auth... */ pstat->auth_seq = seq + 1; - issue_auth23a(padapter, pstat, WLAN_STATUS_SUCCESS); + issue_auth(padapter, pstat, WLAN_STATUS_SUCCESS); if (pstat->state & WIFI_FW_AUTH_SUCCESS) pstat->auth_seq = 0; @@ -1032,7 +1049,7 @@ auth_fail: pstat->auth_seq = 2; memcpy(pstat->hwaddr, sa, 6); - issue_auth23a(padapter, pstat, (unsigned short)status); + issue_auth(padapter, pstat, (unsigned short)status); #endif return _FAIL; @@ -1094,7 +1111,7 @@ OnAuth23aClient23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) memcpy((void *)(pmlmeinfo->chg_txt), p + 2, p[1]); pmlmeinfo->auth_seq = 3; - issue_auth23a(padapter, NULL, 0); + issue_auth(padapter, NULL, 0); set_link_timer(pmlmeext, REAUTH_TO); return _SUCCESS; @@ -1116,7 +1133,7 @@ OnAuth23aClient23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) if (go2asoc) { DBG_8723A_LEVEL(_drv_always_, "auth success, start assoc\n"); - start_clnt_assoc23a(padapter); + start_clnt_assoc(padapter); return _SUCCESS; } @@ -2586,8 +2603,8 @@ _issue_bcn: dump_mgntframe23a(padapter, pmgntframe); } -void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, - u8 is_valid_p2p_probereq) +static void issue_probersp(struct rtw_adapter *padapter, unsigned char *da, + u8 is_valid_p2p_probereq) { struct xmit_frame *pmgntframe; struct pkt_attrib *pattrib; @@ -2801,8 +2818,8 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, return; } -static int _issue_probereq23a(struct rtw_adapter *padapter, - struct cfg80211_ssid *pssid, u8 *da, int wait_ack) +static int _issue_probereq(struct rtw_adapter *padapter, + struct cfg80211_ssid *pssid, u8 *da, int wait_ack) { int ret = _FAIL; struct xmit_frame *pmgntframe; @@ -2818,7 +2835,7 @@ static int _issue_probereq23a(struct rtw_adapter *padapter, u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, - ("+issue_probereq23a\n")); + ("+%s\n", __func__)); if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) goto exit; @@ -2901,23 +2918,23 @@ exit: return ret; } -inline void issue_probereq23a(struct rtw_adapter *padapter, - struct cfg80211_ssid *pssid, u8 *da) +static inline void issue_probereq(struct rtw_adapter *padapter, + struct cfg80211_ssid *pssid, u8 *da) { - _issue_probereq23a(padapter, pssid, da, false); + _issue_probereq(padapter, pssid, da, false); } -int issue_probereq23a_ex23a(struct rtw_adapter *padapter, - struct cfg80211_ssid *pssid, u8 *da, - int try_cnt, int wait_ms) +static int issue_probereq_ex(struct rtw_adapter *padapter, + struct cfg80211_ssid *pssid, u8 *da, + int try_cnt, int wait_ms) { int ret; int i = 0; unsigned long start = jiffies; do { - ret = _issue_probereq23a(padapter, pssid, da, - wait_ms > 0 ? true : false); + ret = _issue_probereq(padapter, pssid, da, + wait_ms > 0 ? true : false); i++; @@ -2954,8 +2971,8 @@ exit: } /* if psta == NULL, indiate we are station(client) now... */ -void issue_auth23a(struct rtw_adapter *padapter, struct sta_info *psta, - unsigned short status) +static void issue_auth(struct rtw_adapter *padapter, struct sta_info *psta, + unsigned short status) { struct xmit_frame *pmgntframe; struct pkt_attrib *pattrib; @@ -3259,7 +3276,7 @@ static void issue_assocrsp(struct rtw_adapter *padapter, unsigned short status, #endif } -void issue_assocreq23a(struct rtw_adapter *padapter) +static void issue_assocreq(struct rtw_adapter *padapter) { int ret = _FAIL; struct xmit_frame *pmgntframe; @@ -3774,8 +3791,8 @@ exit: return ret; } -static int _issue_deauth23a(struct rtw_adapter *padapter, unsigned char *da, - unsigned short reason, u8 wait_ack) +static int _issue_deauth(struct rtw_adapter *padapter, unsigned char *da, + unsigned short reason, u8 wait_ack) { struct xmit_frame *pmgntframe; struct pkt_attrib *pattrib; @@ -3837,19 +3854,19 @@ int issue_deauth23a(struct rtw_adapter *padapter, unsigned char *da, unsigned short reason) { DBG_8723A("%s to "MAC_FMT"\n", __func__, MAC_ARG(da)); - return _issue_deauth23a(padapter, da, reason, false); + return _issue_deauth(padapter, da, reason, false); } -int issue_deauth23a_ex23a(struct rtw_adapter *padapter, u8 *da, - unsigned short reason, int try_cnt, int wait_ms) +static int issue_deauth_ex(struct rtw_adapter *padapter, u8 *da, + unsigned short reason, int try_cnt, int wait_ms) { int ret; int i = 0; unsigned long start = jiffies; do { - ret = _issue_deauth23a(padapter, da, reason, - wait_ms >0 ? true : false); + ret = _issue_deauth(padapter, da, reason, + wait_ms >0 ? true : false); i++; @@ -4392,17 +4409,17 @@ void site_survey23a(struct rtw_adapter *padapter) for (i = 0;isitesurvey_res.ssid[i].ssid_len) { /* todo: to issue two probe req??? */ - issue_probereq23a(padapter, &pmlmeext->sitesurvey_res.ssid[i], NULL); + issue_probereq(padapter, &pmlmeext->sitesurvey_res.ssid[i], NULL); /* msleep(SURVEY_TO>>1); */ - issue_probereq23a(padapter, &pmlmeext->sitesurvey_res.ssid[i], NULL); + issue_probereq(padapter, &pmlmeext->sitesurvey_res.ssid[i], NULL); } } if (pmlmeext->sitesurvey_res.scan_mode == SCAN_ACTIVE) { /* todo: to issue two probe req??? */ - issue_probereq23a(padapter, NULL, NULL); + issue_probereq(padapter, NULL, NULL); /* msleep(SURVEY_TO>>1); */ - issue_probereq23a(padapter, NULL, NULL); + issue_probereq(padapter, NULL, NULL); } } @@ -4626,7 +4643,7 @@ int collect_bss_info23a(struct rtw_adapter *padapter, return _SUCCESS; } -void start_create_ibss23a(struct rtw_adapter* padapter) +static void start_create_ibss(struct rtw_adapter* padapter) { unsigned short caps; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -4673,12 +4690,12 @@ void start_create_ibss23a(struct rtw_adapter* padapter) } else { - DBG_8723A("start_create_ibss23a, invalid cap:%x\n", caps); + DBG_8723A("%s: invalid cap:%x\n", __func__, caps); return; } } -void start_clnt_join23a(struct rtw_adapter* padapter) +static void start_clnt_join(struct rtw_adapter* padapter) { unsigned short caps; u8 val8; @@ -4738,7 +4755,7 @@ void start_clnt_join23a(struct rtw_adapter* padapter) } } -void start_clnt_auth23a(struct rtw_adapter* padapter) +static void start_clnt_auth(struct rtw_adapter* padapter) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -4762,12 +4779,12 @@ void start_clnt_auth23a(struct rtw_adapter* padapter) issue_deauth23a(padapter, (&pmlmeinfo->network)->MacAddress, WLAN_REASON_DEAUTH_LEAVING); DBG_8723A_LEVEL(_drv_always_, "start auth\n"); - issue_auth23a(padapter, NULL, 0); + issue_auth(padapter, NULL, 0); set_link_timer(pmlmeext, REAUTH_TO); } -void start_clnt_assoc23a(struct rtw_adapter* padapter) +static void start_clnt_assoc(struct rtw_adapter* padapter) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -4777,7 +4794,7 @@ void start_clnt_assoc23a(struct rtw_adapter* padapter) pmlmeinfo->state &= (~(WIFI_FW_AUTH_NULL | WIFI_FW_AUTH_STATE)); pmlmeinfo->state |= (WIFI_FW_AUTH_SUCCESS | WIFI_FW_ASSOC_STATE); - issue_assocreq23a(padapter); + issue_assocreq(padapter); set_link_timer(pmlmeext, REASSOC_TO); } @@ -5559,7 +5576,7 @@ void linked_status_chk23a(struct rtw_adapter *padapter) } if (rx_chk != _SUCCESS) - issue_probereq23a_ex23a(padapter, &pmlmeinfo->network.Ssid, psta->hwaddr, 3, 1); + issue_probereq_ex(padapter, &pmlmeinfo->network.Ssid, psta->hwaddr, 3, 1); if ((tx_chk != _SUCCESS && pmlmeinfo->link_count++ == 0xf) || rx_chk != _SUCCESS) { tx_chk = issue_nulldata23a(padapter, psta->hwaddr, 0, 3, 1); @@ -5575,9 +5592,9 @@ void linked_status_chk23a(struct rtw_adapter *padapter) } else { if (rx_chk != _SUCCESS) { if (pmlmeext->retry == 0) { - issue_probereq23a(padapter, &pmlmeinfo->network.Ssid, pmlmeinfo->network.MacAddress); - issue_probereq23a(padapter, &pmlmeinfo->network.Ssid, pmlmeinfo->network.MacAddress); - issue_probereq23a(padapter, &pmlmeinfo->network.Ssid, pmlmeinfo->network.MacAddress); + issue_probereq(padapter, &pmlmeinfo->network.Ssid, pmlmeinfo->network.MacAddress); + issue_probereq(padapter, &pmlmeinfo->network.Ssid, pmlmeinfo->network.MacAddress); + issue_probereq(padapter, &pmlmeinfo->network.Ssid, pmlmeinfo->network.MacAddress); } } @@ -5728,7 +5745,7 @@ static void link_timer_hdl(unsigned long data) DBG_8723A("link_timer_hdl: auth timeout and try again\n"); pmlmeinfo->auth_seq = 1; - issue_auth23a(padapter, NULL, 0); + issue_auth(padapter, NULL, 0); set_link_timer(pmlmeext, REAUTH_TO); } else if (pmlmeinfo->state & WIFI_FW_ASSOC_STATE) @@ -5742,7 +5759,7 @@ static void link_timer_hdl(unsigned long data) } DBG_8723A("link_timer_hdl: assoc timeout and try again\n"); - issue_assocreq23a(padapter); + issue_assocreq(padapter); set_link_timer(pmlmeext, REASSOC_TO); } @@ -5871,7 +5888,7 @@ int createbss_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) memcpy(pnetwork, pparm, sizeof(struct wlan_bssid_ex)); - start_create_ibss23a(padapter); + start_create_ibss(padapter); } return H2C_SUCCESS; @@ -5895,7 +5912,7 @@ int join_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) { if (pmlmeinfo->state & WIFI_FW_STATION_STATE) - issue_deauth23a_ex23a(padapter, pnetwork->MacAddress, + issue_deauth_ex(padapter, pnetwork->MacAddress, WLAN_REASON_DEAUTH_LEAVING, 5, 100); pmlmeinfo->state = WIFI_FW_NULL_STATE; @@ -5995,7 +6012,7 @@ int join_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) /* cancel link timer */ del_timer_sync(&pmlmeext->link_timer); - start_clnt_join23a(padapter); + start_clnt_join(padapter); return H2C_SUCCESS; } @@ -6009,7 +6026,9 @@ int disconnect_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) if (is_client_associated_to_ap23a(padapter)) { - issue_deauth23a_ex23a(padapter, pnetwork->MacAddress, WLAN_REASON_DEAUTH_LEAVING, param->deauth_timeout_ms/100, 100); + issue_deauth_ex(padapter, pnetwork->MacAddress, + WLAN_REASON_DEAUTH_LEAVING, + param->deauth_timeout_ms/100, 100); } /* set_opmode_cmd(padapter, infra_client_with_mlme); */ diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 7f2607d97161..c8b2c8dc9afb 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -577,23 +577,12 @@ s32 dump_mgntframe23a_and_wait_ack23a(struct rtw_adapter *padapter, struct xmit_frame *pmgntframe); void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms); -void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, - u8 is_valid_p2p_probereq); -void issue_assocreq23a(struct rtw_adapter *padapter); -void issue_auth23a(struct rtw_adapter *padapter, struct sta_info *psta, - unsigned short status); -void issue_probereq23a(struct rtw_adapter *padapter, struct cfg80211_ssid *pssid, - u8 *da); -s32 issue_probereq23a_ex23a(struct rtw_adapter *padapter, struct cfg80211_ssid *pssid, - u8 *da, int try_cnt, int wait_ms); int issue_nulldata23a(struct rtw_adapter *padapter, unsigned char *da, unsigned int power_mode, int try_cnt, int wait_ms); int issue_qos_nulldata23a(struct rtw_adapter *padapter, unsigned char *da, u16 tid, int try_cnt, int wait_ms); int issue_deauth23a(struct rtw_adapter *padapter, unsigned char *da, unsigned short reason); -int issue_deauth23a_ex23a(struct rtw_adapter *padapter, u8 *da, unsigned short reason, - int try_cnt, int wait_ms); void issue_action_spct_ch_switch23a(struct rtw_adapter *padapter, u8 *ra, u8 new_ch, u8 ch_offset); void issue_action_BA23a(struct rtw_adapter *padapter, @@ -602,12 +591,6 @@ void issue_action_BA23a(struct rtw_adapter *padapter, int send_delba23a(struct rtw_adapter *padapter, u8 initiator, u8 *addr); int send_beacon23a(struct rtw_adapter *padapter); -void start_clnt_assoc23a(struct rtw_adapter *padapter); -void start_clnt_auth23a(struct rtw_adapter *padapter); -void start_clnt_join23a(struct rtw_adapter *padapter); -void start_create_ibss23a(struct rtw_adapter *padapter); - - void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, int join_res); void mlmeext_sta_del_event_callback23a(struct rtw_adapter *padapter); void mlmeext_sta_add_event_callback23a(struct rtw_adapter *padapter, struct sta_info *psta); -- cgit v1.2.3 From a402b8003ca35ce51d29bf24a93f9e7c099edb83 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:21 +0200 Subject: staging: rtl8723au: rtw_mlme_ext.c: Fix compile warnings Fixup #ifdefs to not build issue_assocrsp() and OnAuth23a() when CONFIG_8723AU_AP_MODE is not set. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index edf29ce4eb00..bc70548b4ee9 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -32,7 +32,6 @@ static int DoReserved23a(struct rtw_adapter *padapter, struct recv_frame *precv_ static int OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); static int OnAtim23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); static int OnDisassoc23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -static int OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); static int OnAuth23aClient23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); static int OnDeAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); static int OnAction23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); @@ -47,8 +46,6 @@ static int OnAction23a_wmm(struct rtw_adapter *padapter, struct recv_frame *prec static int OnAction23a_p2p(struct rtw_adapter *padapter, struct recv_frame *precv_frame); static void issue_assocreq(struct rtw_adapter *padapter); -static void issue_assocrsp(struct rtw_adapter *padapter, unsigned short status, - struct sta_info *pstat, u16 pkt_type); static void issue_probereq(struct rtw_adapter *padapter, struct cfg80211_ssid *pssid, u8 *da); static int issue_probereq_ex(struct rtw_adapter *padapter, @@ -65,6 +62,11 @@ static void start_clnt_auth(struct rtw_adapter *padapter); static void start_clnt_join(struct rtw_adapter *padapter); static void start_create_ibss(struct rtw_adapter *padapter); +#ifdef CONFIG_8723AU_AP_MODE +static int OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static void issue_assocrsp(struct rtw_adapter *padapter, unsigned short status, + struct sta_info *pstat, u16 pkt_type); +#endif static struct mlme_handler mlme_sta_tbl[]={ {"OnAssocReq23a", &OnAssocReq23a}, @@ -867,10 +869,10 @@ out: return _SUCCESS; } +#ifdef CONFIG_8723AU_AP_MODE static int OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { -#ifdef CONFIG_8723AU_AP_MODE static struct sta_info stat; struct sta_info *pstat = NULL; struct sta_priv *pstapriv = &padapter->stapriv; @@ -1051,9 +1053,9 @@ auth_fail: issue_auth(padapter, pstat, (unsigned short)status); -#endif return _FAIL; } +#endif static int OnAuth23aClient23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) @@ -3130,10 +3132,10 @@ static void issue_auth(struct rtw_adapter *padapter, struct sta_info *psta, return; } +#ifdef CONFIG_8723AU_AP_MODE static void issue_assocrsp(struct rtw_adapter *padapter, unsigned short status, struct sta_info *pstat, u16 pkt_type) { -#ifdef CONFIG_8723AU_AP_MODE struct xmit_frame *pmgntframe; struct ieee80211_hdr *pwlanhdr; struct pkt_attrib *pattrib; @@ -3273,8 +3275,8 @@ static void issue_assocrsp(struct rtw_adapter *padapter, unsigned short status, pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe23a(padapter, pmgntframe); -#endif } +#endif static void issue_assocreq(struct rtw_adapter *padapter) { -- cgit v1.2.3 From f3c9d6409be5ec1d8925be2f04daaa0f6a9ff3bb Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:22 +0200 Subject: staging: rtl8723au: Don't compile rtw_ap.c when CONFIG_8723AU_AP_MODE=n Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/Makefile | 2 +- drivers/staging/rtl8723au/core/rtw_ap.c | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723au/Makefile b/drivers/staging/rtl8723au/Makefile index f0615d666d91..a6316af94b79 100644 --- a/drivers/staging/rtl8723au/Makefile +++ b/drivers/staging/rtl8723au/Makefile @@ -1,5 +1,4 @@ r8723au-y := \ - core/rtw_ap.o \ core/rtw_cmd.o \ core/rtw_efuse.o \ core/rtw_ioctl_set.o \ @@ -50,6 +49,7 @@ r8723au-y := \ os_dep/xmit_linux.o r8723au-$(CONFIG_8723AU_BT_COEXIST) += hal/rtl8723a_bt-coexist.o +r8723au-$(CONFIG_8723AU_AP_MODE) += core/rtw_ap.o obj-$(CONFIG_R8723AU) := r8723au.o diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 850e2e51f198..c8700b38386d 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -21,8 +21,6 @@ #include #include -#ifdef CONFIG_8723AU_AP_MODE - extern unsigned char WMM_OUI23A[]; extern unsigned char WPS_OUI23A[]; extern unsigned char P2P_OUI23A[]; @@ -2028,5 +2026,3 @@ void stop_ap_mode23a(struct rtw_adapter *padapter) rtw23a_free_mlme_priv_ie_data(pmlmepriv); } - -#endif /* CONFIG_8723AU_AP_MODE */ -- cgit v1.2.3 From 9b0cb4b6a6133adcf441e8a162155a9e9e5ddde1 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:23 +0200 Subject: staging: rtl8723au: Declare SetBWMode23a() static Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 5 +++-- drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 2 -- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 68ba22555d38..ce581a2c8f10 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -340,7 +340,8 @@ void SelectChannel23a(struct rtw_adapter *padapter, unsigned char channel) mutex_unlock(&adapter_to_dvobj(padapter)->setch_mutex); } -void SetBWMode23a(struct rtw_adapter *padapter, unsigned short bwmode, unsigned char channel_offset) +static void set_bwmode(struct rtw_adapter *padapter, unsigned short bwmode, + unsigned char channel_offset) { mutex_lock(&adapter_to_dvobj(padapter)->setbw_mutex); @@ -390,7 +391,7 @@ void set_channel_bwmode23a(struct rtw_adapter *padapter, unsigned char channel, mutex_unlock(&adapter_to_dvobj(padapter)->setch_mutex); - SetBWMode23a(padapter, bwmode, channel_offset); + set_bwmode(padapter, bwmode, channel_offset); } int get_bsstype23a(unsigned short capability) diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index c8b2c8dc9afb..8d15297c3cb4 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -483,8 +483,6 @@ void rtw_set_oper_ch23aoffset23a(struct rtw_adapter *adapter, u8 offset); void set_channel_bwmode23a(struct rtw_adapter *padapter, unsigned char channel, unsigned char channel_offset, unsigned short bwmode); void SelectChannel23a(struct rtw_adapter *padapter, unsigned char channel); -void SetBWMode23a(struct rtw_adapter *padapter, unsigned short bwmode, - unsigned char channel_offset); unsigned int decide_wait_for_beacon_timeout23a(unsigned int bcn_interval); -- cgit v1.2.3 From 41a5a460ed18a88b7efc8a7257416857daa76356 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:24 +0200 Subject: staging: rtl8723au: Get rid of unused get_bsstype23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 9 --------- drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 1 - 2 files changed, 10 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index ce581a2c8f10..256385c2f382 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -394,15 +394,6 @@ void set_channel_bwmode23a(struct rtw_adapter *padapter, unsigned char channel, set_bwmode(padapter, bwmode, channel_offset); } -int get_bsstype23a(unsigned short capability) -{ - if (capability & BIT(0)) - return WIFI_FW_AP_STATE; - else if (capability & BIT(1)) - return WIFI_FW_ADHOC_STATE; - return 0; -} - inline u8 *get_my_bssid23a(struct wlan_bssid_ex *pnetwork) { return pnetwork->MacAddress; diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 8d15297c3cb4..b5f3dbbeb157 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -502,7 +502,6 @@ int collect_bss_info23a(struct rtw_adapter *padapter, void update_network23a(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, struct rtw_adapter *padapter, bool update_ie); -int get_bsstype23a(unsigned short capability); u8 *get_my_bssid23a(struct wlan_bssid_ex *pnetwork); u16 get_beacon_interval23a(struct wlan_bssid_ex *bss); -- cgit v1.2.3 From cdaf6ef7673531ae5124893ec27fa296c0fd8724 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:25 +0200 Subject: staging: rtl8723au: Move dummy_event_callback() to rtw_mlme_ext.c In addition get rid of a couple of empty *_event_callback() handlers and use dummy_event_callback() instead. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 14 -------------- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 14 +++++++++----- drivers/staging/rtl8723au/include/rtw_mlme.h | 3 --- drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 3 --- 4 files changed, 9 insertions(+), 25 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index da254855e507..148e11f2837b 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -818,14 +818,6 @@ rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf) rtw_cfg80211_surveydone_event_callback(adapter); } -void rtw_dummy_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf) -{ -} - -void rtw23a_fwdbg_event_callback(struct rtw_adapter *adapter, const u8 *pbuf) -{ -} - static void free_scanqueue(struct mlme_priv *pmlmepriv) { struct wlan_network *pnetwork; @@ -1540,12 +1532,6 @@ void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf) spin_unlock_bh(&pmlmepriv->lock); } -void rtw_cpwm_event_callback23a(struct rtw_adapter *padapter, const u8 *pbuf) -{ - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, - ("+rtw_cpwm_event_callback23a !!!\n")); -} - /* * rtw23a_join_to_handler - Timeout/faliure handler for CMD JoinBss * @adapter: pointer to _adapter structure diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index bc70548b4ee9..58ff635c5157 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -235,9 +235,13 @@ static struct rt_channel_plan_map RTW_ChannelPlanMap[RT_CHANNEL_DOMAIN_MAX] = { static struct rt_channel_plan_map RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE = {0x03, 0x02}; /* use the conbination for max channel numbers */ +static void dummy_event_callback(struct rtw_adapter *adapter, const u8 *pbuf) +{ +} + static struct fwevent wlanevents[] = { - {0, rtw_dummy_event_callback23a}, /*0*/ + {0, &dummy_event_callback}, /*0*/ {0, NULL}, {0, NULL}, {0, NULL}, @@ -251,17 +255,17 @@ static struct fwevent wlanevents[] = {0, &rtw23a_joinbss_event_cb}, /*10*/ {sizeof(struct stassoc_event), &rtw_stassoc_event_callback23a}, {sizeof(struct stadel_event), &rtw_stadel_event_callback23a}, - {0, &rtw_atimdone_event_callback23a}, - {0, rtw_dummy_event_callback23a}, + {0, &dummy_event_callback}, + {0, &dummy_event_callback}, {0, NULL}, /*15*/ {0, NULL}, {0, NULL}, {0, NULL}, - {0, rtw23a_fwdbg_event_callback}, + {0, &dummy_event_callback}, {0, NULL}, /*20*/ {0, NULL}, {0, NULL}, - {0, &rtw_cpwm_event_callback23a}, + {0, &dummy_event_callback}, {0, NULL}, }; diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index 2b72d5bd4d28..b1f2b5fa94e1 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -338,9 +338,6 @@ void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, const u8 *pbu void rtw23a_joinbss_event_cb(struct rtw_adapter *adapter, const u8 *pbuf); void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf); void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf); -void rtw_atimdone_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf); -void rtw_cpwm_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf); - int event_thread(void *context); void rtw23a_join_to_handler(unsigned long); diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index b5f3dbbeb157..afbd807299b9 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -670,9 +670,6 @@ struct C2HEvent_Header { unsigned int rsvd; }; -void rtw_dummy_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf); -void rtw23a_fwdbg_event_callback(struct rtw_adapter *adapter, const u8 *pbuf); - enum rtw_c2h_event { GEN_EVT_CODE(_Read_MACREG) = 0, /*0*/ GEN_EVT_CODE(_Read_BBREG), -- cgit v1.2.3 From 77931b7b541cad066641cca6dcb10d75e1542ec1 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:26 +0200 Subject: staging: rtl8723au: Get rid of some unused tdls definitions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtw_cmd.h | 1 - drivers/staging/rtl8723au/include/rtw_mlme.h | 27 --------------------------- 2 files changed, 28 deletions(-) diff --git a/drivers/staging/rtl8723au/include/rtw_cmd.h b/drivers/staging/rtl8723au/include/rtw_cmd.h index 383cd39bd4fe..efcbf5c84779 100644 --- a/drivers/staging/rtl8723au/include/rtw_cmd.h +++ b/drivers/staging/rtl8723au/include/rtw_cmd.h @@ -719,7 +719,6 @@ int rtw_set_ch_cmd23a(struct rtw_adapter*padapter, u8 ch, u8 bw, u8 ch_offset, u int rtw_set_chplan_cmd(struct rtw_adapter*padapter, u8 chplan, u8 enqueue); int rtw_led_blink_cmd(struct rtw_adapter*padapter, struct led_8723a *pLed); int rtw_set_csa_cmd(struct rtw_adapter*padapter, u8 new_ch_no); -int rtw_tdls_cmd(struct rtw_adapter*padapter, u8 *addr, u8 option); int rtw_c2h_wk_cmd23a(struct rtw_adapter *padapter, u8 *c2h_evt); diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index b1f2b5fa94e1..1bb9e6cce796 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -179,33 +179,6 @@ struct scan_limit_info { u8 operation_ch[2]; /* Store the operation channel of invitation request frame */ }; -struct tdls_ss_record { /* signal strength record */ - u8 macaddr[ETH_ALEN]; - u8 RxPWDBAll; - u8 is_tdls_sta; /* true: direct link sta, false: else */ -}; - -struct tdls_info { - u8 ap_prohibited; - uint setup_state; - u8 sta_cnt; - /* 1:tdls sta == (NUM_STA-1), reach max direct link no; 0: else; */ - u8 sta_maximum; - struct tdls_ss_record ss_record; - u8 macid_index; /* macid entry that is ready to write */ - /* cam entry that is trying to clear, using it in direct link teardown*/ - u8 clear_cam; - u8 ch_sensing; - u8 cur_channel; - u8 candidate_ch; - u8 collect_pkt_num[MAX_CHANNEL_NUM]; - spinlock_t cmd_lock; - spinlock_t hdl_lock; - u8 watchdog_count; - u8 dev_discovered; /* WFD_TDLS: for sigma test */ - u8 enable; -}; - struct mlme_priv { spinlock_t lock; int fw_state; -- cgit v1.2.3 From 60682873a0b22b699b8137a1b2b0d5c2454295bb Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:27 +0200 Subject: staging: rtl8723au: rtw_cmd.h: Remove some more unused #defines Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtw_cmd.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/rtl8723au/include/rtw_cmd.h b/drivers/staging/rtl8723au/include/rtw_cmd.h index efcbf5c84779..c49237b04a33 100644 --- a/drivers/staging/rtl8723au/include/rtw_cmd.h +++ b/drivers/staging/rtl8723au/include/rtw_cmd.h @@ -816,11 +816,6 @@ enum rtw_h2c_cmd { MAX_H2CCMD }; -#define _GetBBReg_CMD_ _Read_BBREG_CMD_ -#define _SetBBReg_CMD_ _Write_BBREG_CMD_ -#define _GetRFReg_CMD_ _Read_RFREG_CMD_ -#define _SetRFReg_CMD_ _Write_RFREG_CMD_ - extern struct _cmd_callback rtw_cmd_callback[]; #endif /* _CMD_H_ */ -- cgit v1.2.3 From 7f234006d4701f6d86048f6bb605634b6b373960 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:28 +0200 Subject: staging: rtl8723au: rtw_ieee80211.c: Remove a number of unused functions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 47 -------------------------- drivers/staging/rtl8723au/include/ieee80211.h | 2 -- 2 files changed, 49 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index 28a7a0c81166..85eac7d65a4a 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -159,18 +159,6 @@ inline u8 *rtw_set_ie23a_ch_switch (u8 *buf, u32 *buf_len, u8 ch_switch_mode, return rtw_set_ie23a(buf, WLAN_EID_CHANNEL_SWITCH, 3, ie_data, buf_len); } -inline u8 secondary_ch_offset_to_hal_ch_offset23a(u8 ch_offset) -{ - if (ch_offset == SCN) - return HAL_PRIME_CHNL_OFFSET_DONT_CARE; - else if (ch_offset == SCA) - return HAL_PRIME_CHNL_OFFSET_UPPER; - else if (ch_offset == SCB) - return HAL_PRIME_CHNL_OFFSET_LOWER; - - return HAL_PRIME_CHNL_OFFSET_DONT_CARE; -} - inline u8 hal_ch_offset_to_secondary_ch_offset23a(u8 ch_offset) { if (ch_offset == HAL_PRIME_CHNL_OFFSET_DONT_CARE) @@ -190,19 +178,6 @@ inline u8 *rtw_set_ie23a_secondary_ch_offset(u8 *buf, u32 *buf_len, 1, &secondary_ch_offset, buf_len); } -inline u8 *rtw_set_ie23a_mesh_ch_switch_parm(u8 *buf, u32 *buf_len, u8 ttl, - u8 flags, u16 reason, u16 precedence) -{ - u8 ie_data[6]; - - ie_data[0] = ttl; - ie_data[1] = flags; - put_unaligned_le16(reason, (u8*)&ie_data[2]); - put_unaligned_le16(precedence, (u8*)&ie_data[4]); - - return rtw_set_ie23a(buf, 0x118, 6, ie_data, buf_len); -} - /*---------------------------------------------------------------------------- index: the information element id index, limit is the limit for search -----------------------------------------------------------------------------*/ @@ -863,28 +838,6 @@ u8 *rtw_get_wps_attr_content23a(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, return NULL; } -static u8 key_char2num(u8 ch) -{ - if (ch >= '0' && ch <= '9') - return ch - '0'; - else if (ch >= 'a' && ch <= 'f') - return ch - 'a' + 10; - else if (ch >= 'A' && ch <= 'F') - return ch - 'A' + 10; - else - return 0xff; -} - -u8 str_2char2num23a(u8 hch, u8 lch) -{ - return key_char2num(hch) * 10 + key_char2num(lch); -} - -u8 key_2char2num23a(u8 hch, u8 lch) -{ - return key_char2num(hch) << 4 | key_char2num(lch); -} - static int rtw_get_cipher_info(struct wlan_network *pnetwork) { const u8 *pbuf; diff --git a/drivers/staging/rtl8723au/include/ieee80211.h b/drivers/staging/rtl8723au/include/ieee80211.h index ee600ab7d1c7..2a9a3d2dbc01 100644 --- a/drivers/staging/rtl8723au/include/ieee80211.h +++ b/drivers/staging/rtl8723au/include/ieee80211.h @@ -425,11 +425,9 @@ enum secondary_ch_offset { SCA = 1, /* secondary channel above */ SCB = 3, /* secondary channel below */ }; -u8 secondary_ch_offset_to_hal_ch_offset23a(u8 ch_offset); u8 hal_ch_offset_to_secondary_ch_offset23a(u8 ch_offset); u8 *rtw_set_ie23a_ch_switch(u8 *buf, u32 *buf_len, u8 ch_switch_mode, u8 new_ch, u8 ch_switch_cnt); u8 *rtw_set_ie23a_secondary_ch_offset(u8 *buf, u32 *buf_len, u8 secondary_ch_offset); -u8 *rtw_set_ie23a_mesh_ch_switch_parm(u8 *buf, u32 *buf_len, u8 ttl, u8 flags, u16 reason, u16 precedence); u8 *rtw_get_ie23a(u8*pbuf, int index, int *len, int limit); u8 *rtw_get_ie23a_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, u8 oui_len, u8 *ie, uint *ielen); -- cgit v1.2.3 From a9e9d363a0fc52a81b2c897e5fc28653d0ddd0ae Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:29 +0200 Subject: staging: rtl8723au: rtw_get_bcn_info23a(): Use cfg80211_find_ie() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index 85eac7d65a4a..dc237fe3c89c 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -909,8 +909,7 @@ void rtw_get_bcn_info23a(struct wlan_network *pnetwork) u16 wpa_len = 0, rsn_len = 0; struct HT_info_element *pht_info = NULL; struct ieee80211_ht_cap *pht_cap = NULL; - unsigned int len; - unsigned char *p; + const u8 *p; cap = get_unaligned_le16( rtw_get_capability23a_from_ie(pnetwork->network.IEs)); @@ -951,20 +950,20 @@ void rtw_get_bcn_info23a(struct wlan_network *pnetwork) /* get bwmode and ch_offset */ /* parsing HT_CAP_IE */ - p = rtw_get_ie23a(pnetwork->network.IEs + _FIXED_IE_LENGTH_, - WLAN_EID_HT_CAPABILITY, &len, - pnetwork->network.IELength - _FIXED_IE_LENGTH_); - if (p && len > 0) { + p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, + pnetwork->network.IEs + _FIXED_IE_LENGTH_, + pnetwork->network.IELength - _FIXED_IE_LENGTH_); + if (p && p[1] > 0) { pht_cap = (struct ieee80211_ht_cap *)(p + 2); pnetwork->BcnInfo.ht_cap_info = pht_cap->cap_info; } else { pnetwork->BcnInfo.ht_cap_info = 0; } /* parsing HT_INFO_IE */ - p = rtw_get_ie23a(pnetwork->network.IEs + _FIXED_IE_LENGTH_, - WLAN_EID_HT_OPERATION, &len, + p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, + pnetwork->network.IEs + _FIXED_IE_LENGTH_, pnetwork->network.IELength - _FIXED_IE_LENGTH_); - if (p && len > 0) { + if (p && p[1] > 0) { pht_info = (struct HT_info_element *)(p + 2); pnetwork->BcnInfo.ht_info_infos_0 = pht_info->infos[0]; } else { -- cgit v1.2.3 From 56b8412996ea400369d153bbddd381daf2c6fb6b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:30 +0200 Subject: staging: rtl8723au: rtw_get_bcn_info23a(): Don't zero variables unncessarily In addition remove excessive brackets. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index dc237fe3c89c..88ef166f6647 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -903,12 +903,12 @@ static int rtw_get_cipher_info(struct wlan_network *pnetwork) void rtw_get_bcn_info23a(struct wlan_network *pnetwork) { - unsigned short cap = 0; + unsigned short cap; u8 bencrypt = 0; /* u8 wpa_ie[255], rsn_ie[255]; */ u16 wpa_len = 0, rsn_len = 0; - struct HT_info_element *pht_info = NULL; - struct ieee80211_ht_cap *pht_cap = NULL; + struct HT_info_element *pht_info; + struct ieee80211_ht_cap *pht_cap; const u8 *p; cap = get_unaligned_le16( @@ -916,9 +916,9 @@ void rtw_get_bcn_info23a(struct wlan_network *pnetwork) if (cap & WLAN_CAPABILITY_PRIVACY) { bencrypt = 1; pnetwork->network.Privacy = 1; - } else { + } else pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_OPENSYS; - } + rtw_get_sec_ie23a(pnetwork->network.IEs, pnetwork->network.IELength, NULL, &rsn_len, NULL, &wpa_len); RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, @@ -932,11 +932,11 @@ void rtw_get_bcn_info23a(struct wlan_network *pnetwork) ("rtw_get_bcn_info23a: wpa_len =%d rsn_len =%d\n", wpa_len, rsn_len)); - if (rsn_len > 0) { + if (rsn_len > 0) pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_WPA2; - } else if (wpa_len > 0) { + else if (wpa_len > 0) pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_WPA; - } else { + else { if (bencrypt) pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_WEP; } @@ -956,9 +956,9 @@ void rtw_get_bcn_info23a(struct wlan_network *pnetwork) if (p && p[1] > 0) { pht_cap = (struct ieee80211_ht_cap *)(p + 2); pnetwork->BcnInfo.ht_cap_info = pht_cap->cap_info; - } else { + } else pnetwork->BcnInfo.ht_cap_info = 0; - } + /* parsing HT_INFO_IE */ p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, pnetwork->network.IEs + _FIXED_IE_LENGTH_, @@ -966,9 +966,8 @@ void rtw_get_bcn_info23a(struct wlan_network *pnetwork) if (p && p[1] > 0) { pht_info = (struct HT_info_element *)(p + 2); pnetwork->BcnInfo.ht_info_infos_0 = pht_info->infos[0]; - } else { + } else pnetwork->BcnInfo.ht_info_infos_0 = 0; - } } /* show MCS rate, unit: 100Kbps */ -- cgit v1.2.3 From 38eb09b5be235eeaf1c4d0a2100d3cb2a3e0b3a3 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:31 +0200 Subject: staging: rtl8723au: rtw_cfg80211_monitor_if_xmit_entry() use struct ieee80211_mgmt Use struct ieee80211_mgmt to parse action frame. In addition remove unused functions rtw_cfg80211_rx_p2p_action_public() and rtw_cfg80211_rx_action_p2p() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/ioctl_cfg80211.h | 4 -- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 63 +++------------------- 2 files changed, 6 insertions(+), 61 deletions(-) diff --git a/drivers/staging/rtl8723au/include/ioctl_cfg80211.h b/drivers/staging/rtl8723au/include/ioctl_cfg80211.h index 0eb9036d7250..ed91ba0d24d4 100644 --- a/drivers/staging/rtl8723au/include/ioctl_cfg80211.h +++ b/drivers/staging/rtl8723au/include/ioctl_cfg80211.h @@ -85,10 +85,6 @@ void rtw_cfg80211_indicate_sta_disassoc(struct rtw_adapter *padapter, void rtw_cfg80211_issue_p2p_provision_request23a(struct rtw_adapter *padapter, const u8 *buf, size_t len); -void rtw_cfg80211_rx_p2p_action_public(struct rtw_adapter *padapter, - u8 *pmgmt_frame, uint frame_len); -void rtw_cfg80211_rx_action_p2p(struct rtw_adapter *padapter, - u8 *pmgmt_frame, uint frame_len); void rtw_cfg80211_rx_action(struct rtw_adapter *adapter, u8 *frame, uint frame_len, const char*msg); diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index ad4fe79123b1..c3b71501b0ce 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -2596,6 +2596,7 @@ static int rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, return ret; } else if (ieee80211_is_action(dot11_hdr->frame_control)) { + struct ieee80211_mgmt *mgmt; /* only for action frames */ struct xmit_frame *pmgntframe; struct pkt_attrib *pattrib; @@ -2607,17 +2608,13 @@ static int rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, u32 len = skb->len; u8 category, action; - if (rtw_action_frame_parse23a(skb->data, len, &category, - &action) == false) { - DBG_8723A("%s(%s): frame_control:0x%x\n", - __func__, ndev->name, - le16_to_cpu(dot11_hdr->frame_control)); - goto fail; - } + mgmt = (struct ieee80211_mgmt *)dot11_hdr; DBG_8723A("RTW_Tx:da =" MAC_FMT " via %s(%s)\n", - MAC_ARG(dot11_hdr->addr1), __func__, ndev->name); - if (category == WLAN_CATEGORY_PUBLIC) + MAC_ARG(mgmt->da), __func__, ndev->name); + category = mgmt->u.action.category; + action = mgmt->u.action.u.wme_action.action_code; + if (mgmt->u.action.category == WLAN_CATEGORY_PUBLIC) DBG_8723A("RTW_Tx:%s\n", action_public_str23a(action)); else DBG_8723A("RTW_Tx:category(%u), action(%u)\n", category, @@ -3034,54 +3031,6 @@ static int cfg80211_rtw_change_bss(struct wiphy *wiphy, struct net_device *ndev, } #endif /* CONFIG_8723AU_AP_MODE */ -void rtw_cfg80211_rx_action_p2p(struct rtw_adapter *padapter, u8 *pmgmt_frame, - uint frame_len) -{ - s32 freq; - int channel; - u8 category, action; - - channel = rtw_get_oper_ch23a(padapter); - - DBG_8723A("RTW_Rx:cur_ch =%d\n", channel); - rtw_action_frame_parse23a(pmgmt_frame, frame_len, &category, &action); - DBG_8723A("RTW_Rx:category(%u), action(%u)\n", category, action); - - if (channel <= RTW_CH_MAX_2G_CHANNEL) - freq = ieee80211_channel_to_frequency(channel, - IEEE80211_BAND_2GHZ); - else - freq = ieee80211_channel_to_frequency(channel, - IEEE80211_BAND_5GHZ); - - rtw_cfg80211_rx_mgmt(padapter, freq, 0, pmgmt_frame, frame_len, - GFP_ATOMIC); -} - -void rtw_cfg80211_rx_p2p_action_public(struct rtw_adapter *padapter, - u8 *pmgmt_frame, uint frame_len) -{ - s32 freq; - int channel; - u8 category, action; - - channel = rtw_get_oper_ch23a(padapter); - - DBG_8723A("RTW_Rx:cur_ch =%d\n", channel); - rtw_action_frame_parse23a(pmgmt_frame, frame_len, &category, &action); - DBG_8723A("RTW_Rx:category(%u), action(%u)\n", category, action); - - if (channel <= RTW_CH_MAX_2G_CHANNEL) - freq = ieee80211_channel_to_frequency(channel, - IEEE80211_BAND_2GHZ); - else - freq = ieee80211_channel_to_frequency(channel, - IEEE80211_BAND_5GHZ); - - rtw_cfg80211_rx_mgmt(padapter, freq, 0, pmgmt_frame, frame_len, - GFP_ATOMIC); -} - void rtw_cfg80211_rx_action(struct rtw_adapter *adapter, u8 *frame, uint frame_len, const char *msg) { -- cgit v1.2.3 From ea2ea44079784794838dc0ae953967990f8457d5 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:32 +0200 Subject: staging: rtl8723au: rtw_cfg80211_rx_action(): Use ieee80211_mgmt to parse action frame Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 26 ++++++++++------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index c3b71501b0ce..06d73e5549cc 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -3034,20 +3034,19 @@ static int cfg80211_rtw_change_bss(struct wiphy *wiphy, struct net_device *ndev, void rtw_cfg80211_rx_action(struct rtw_adapter *adapter, u8 *frame, uint frame_len, const char *msg) { + struct ieee80211_mgmt *hdr = (struct ieee80211_mgmt *)frame; s32 freq; int channel; - u8 category, action; channel = rtw_get_oper_ch23a(adapter); - rtw_action_frame_parse23a(frame, frame_len, &category, &action); - DBG_8723A("RTW_Rx:cur_ch =%d\n", channel); if (msg) DBG_8723A("RTW_Rx:%s\n", msg); else - DBG_8723A("RTW_Rx:category(%u), action(%u)\n", category, - action); + DBG_8723A("RTW_Rx:category(%u), action(%u)\n", + hdr->u.action.category, + hdr->u.action.u.wme_action.action_code); if (channel <= RTW_CH_MAX_2G_CHANNEL) freq = ieee80211_channel_to_frequency(channel, @@ -3149,9 +3148,12 @@ static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, size_t len = params->len; struct ieee80211_channel *chan = params->chan; const u8 *buf = params->buf; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)buf; + struct ieee80211_mgmt *hdr = (struct ieee80211_mgmt *)buf; u8 tx_ch = (u8) ieee80211_frequency_to_channel(chan->center_freq); + if (!ieee80211_is_action(hdr->frame_control)) + return -EINVAL; + /* cookie generation */ *cookie = (unsigned long)buf; @@ -3162,15 +3164,10 @@ static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, rtw_cfg80211_mgmt_tx_status(padapter, *cookie, buf, len, ack, GFP_KERNEL); - if (rtw_action_frame_parse23a(buf, len, &category, &action) == false) { - DBG_8723A("%s(%s): frame_control:0x%x\n", __func__, - padapter->pnetdev->name, - le16_to_cpu(hdr->frame_control)); - goto exit; - } - DBG_8723A("RTW_Tx:tx_ch =%d, da =" MAC_FMT "\n", tx_ch, - MAC_ARG(hdr->addr1)); + MAC_ARG(hdr->da)); + category = hdr->u.action.category; + action = hdr->u.action.u.wme_action.action_code; if (category == WLAN_CATEGORY_PUBLIC) DBG_8723A("RTW_Tx:%s\n", action_public_str23a(action)); else @@ -3189,7 +3186,6 @@ static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, dump_limit, jiffies_to_msecs(jiffies - start)); } -exit: return ret; } -- cgit v1.2.3 From 96df4b65f3dd9fd8f7529c802d4f27f6576e379d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:33 +0200 Subject: staging: rtl8723au: Remove obsolete rtw_action_frame_parse23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 31 -------------------------- drivers/staging/rtl8723au/include/ieee80211.h | 1 - 2 files changed, 32 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index 88ef166f6647..adb86a54bdb2 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -1041,37 +1041,6 @@ u16 rtw_mcs_rate23a(u8 rf_type, u8 bw_40MHz, u8 short_GI_20, u8 short_GI_40, return max_rate; } -int rtw_action_frame_parse23a(const u8 *frame, u32 frame_len, u8* category, - u8 *action) -{ - const u8 *frame_body = frame + sizeof(struct ieee80211_hdr_3addr); - u16 fc; - u8 c, a = 0; - - fc = le16_to_cpu(((struct ieee80211_hdr_3addr *)frame)->frame_control); - - if ((fc & (IEEE80211_FCTL_FTYPE|IEEE80211_FCTL_STYPE)) != - (IEEE80211_FTYPE_MGMT|IEEE80211_STYPE_ACTION)) { - return false; - } - - c = frame_body[0]; - - switch (c) { - case WLAN_CATEGORY_VENDOR_SPECIFIC: /* vendor-specific */ - break; - default: - a = frame_body[1]; - } - - if (category) - *category = c; - if (action) - *action = a; - - return true; -} - static const char *_action_public_str23a[] = { "ACT_PUB_BSSCOEXIST", "ACT_PUB_DSE_ENABLE", diff --git a/drivers/staging/rtl8723au/include/ieee80211.h b/drivers/staging/rtl8723au/include/ieee80211.h index 2a9a3d2dbc01..e69f1cc67883 100644 --- a/drivers/staging/rtl8723au/include/ieee80211.h +++ b/drivers/staging/rtl8723au/include/ieee80211.h @@ -460,7 +460,6 @@ void rtw_get_bcn_info23a(struct wlan_network *pnetwork); u16 rtw_mcs_rate23a(u8 rf_type, u8 bw_40MHz, u8 short_GI_20, u8 short_GI_40, unsigned char * MCS_rate); -int rtw_action_frame_parse23a(const u8 *frame, u32 frame_len, u8* category, u8 *action); const char *action_public_str23a(u8 action); #endif /* IEEE80211_H */ -- cgit v1.2.3 From 662c9bf87edd93c9dc59aa87e3524b7c545ae633 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:34 +0200 Subject: staging: rtl8723au: Declare rtw_site_survey() static Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 8 ++++---- drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 58ff635c5157..1a36e640690d 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -4384,7 +4384,7 @@ bool IsLegal5GChannel(struct rtw_adapter *Adapter, u8 channel) return false; } -void site_survey23a(struct rtw_adapter *padapter) +static void rtw_site_survey(struct rtw_adapter *padapter) { unsigned char survey_channel = 0; enum rt_scan_type ScanType = SCAN_PASSIVE; @@ -4401,7 +4401,7 @@ void site_survey23a(struct rtw_adapter *padapter) } if (survey_channel != 0) { - /* PAUSE 4-AC Queue when site_survey23a */ + /* PAUSE 4-AC Queue when site_survey */ if (pmlmeext->sitesurvey_res.channel_idx == 0) set_channel_bwmode23a(padapter, survey_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, @@ -4440,7 +4440,7 @@ void site_survey23a(struct rtw_adapter *padapter) pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); - /* flush 4-AC Queue after site_survey23a */ + /* flush 4-AC Queue after rtw_site_survey */ /* val8 = 0; */ /* config MSR */ @@ -6213,7 +6213,7 @@ int sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) pmlmeext->sitesurvey_res.state = SCAN_PROCESS; } - site_survey23a(padapter); + rtw_site_survey(padapter); return H2C_SUCCESS; } diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index afbd807299b9..0f757307ebb6 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -495,7 +495,6 @@ void flush_all_cam_entry23a(struct rtw_adapter *padapter); bool IsLegal5GChannel(struct rtw_adapter *Adapter, u8 channel); -void site_survey23a(struct rtw_adapter *padapter); int collect_bss_info23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame, struct wlan_bssid_ex *bssid); -- cgit v1.2.3 From 1feec0d8d82f037b9051d8b251cf87999e9fece8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:35 +0200 Subject: staging: rtl8723au: rtw_mlme_ext.c: Improve bad formatting in event handlers Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 133 +++++++++++++------------- 1 file changed, 67 insertions(+), 66 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 1a36e640690d..068253faae70 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -6225,20 +6225,18 @@ int setauth_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (pparm->mode < 4) - { pmlmeinfo->auth_algo = pparm->mode; - } return H2C_SUCCESS; } int setkey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { - unsigned short ctrl; + unsigned short ctrl; const struct setkey_parm *pparm = (struct setkey_parm *)pbuf; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - unsigned char null_sta[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + unsigned char null_sta[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; /* main tx key for wep. */ if (pparm->set_tx) @@ -6247,8 +6245,9 @@ int setkey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) /* write cam */ ctrl = BIT(15) | ((pparm->algorithm) << 2) | pparm->keyid; - DBG_8723A_LEVEL(_drv_always_, "set group key to hw: alg:%d(WEP40-1 WEP104-5 TKIP-2 AES-4) " - "keyid:%d\n", pparm->algorithm, pparm->keyid); + DBG_8723A_LEVEL(_drv_always_, "set group key to hw: alg:%d(WEP40-1 " + "WEP104-5 TKIP-2 AES-4) keyid:%d\n", + pparm->algorithm, pparm->keyid); rtl8723a_cam_write(padapter, pparm->keyid, ctrl, null_sta, pparm->key); /* allow multicast packets to driver */ @@ -6261,7 +6260,7 @@ int set_stakey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { u16 ctrl = 0; u8 cam_id;/* cam_entry */ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; const struct set_stakey_parm *pparm = (struct set_stakey_parm *)pbuf; @@ -6280,51 +6279,51 @@ int set_stakey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) cam_id = 4; - DBG_8723A_LEVEL(_drv_always_, "set pairwise key to hw: alg:%d(WEP40-1 WEP104-5 TKIP-2 AES-4) camid:%d\n", + DBG_8723A_LEVEL(_drv_always_, "set pairwise key to hw: alg:%d(WEP40-1 " + "WEP104-5 TKIP-2 AES-4) camid:%d\n", pparm->algorithm, cam_id); - if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) - { - + if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) { struct sta_info *psta; struct sta_priv *pstapriv = &padapter->stapriv; - if (pparm->algorithm == 0) /* clear cam entry */ - { + if (pparm->algorithm == 0) { /* clear cam entry */ clear_cam_entry23a(padapter, pparm->id); return H2C_SUCCESS_RSP; } psta = rtw_get_stainfo23a(pstapriv, pparm->addr); - if (psta) - { - ctrl = (BIT(15) | ((pparm->algorithm) << 2)); + if (psta) { + ctrl = BIT(15) | (pparm->algorithm << 2); - DBG_8723A("r871x_set_stakey_hdl23a(): enc_algorithm =%d\n", pparm->algorithm); + DBG_8723A("r871x_set_stakey_hdl23a(): enc_algorithm " + "=%d\n", pparm->algorithm); - if ((psta->mac_id<1) || (psta->mac_id>(NUM_STA-4))) - { - DBG_8723A("r871x_set_stakey_hdl23a():set_stakey failed, mac_id(aid) =%d\n", psta->mac_id); + if (psta->mac_id < 1 || psta->mac_id > (NUM_STA - 4)) { + DBG_8723A("r871x_set_stakey_hdl23a():set_stakey" + " failed, mac_id(aid) =%d\n", + psta->mac_id); return H2C_REJECTED; } - cam_id = (psta->mac_id + 3);/* 0~3 for default key, cmd_id = macid + 3, macid = aid+1; */ + /* 0~3 for default key, cmd_id = macid + 3, + macid = aid+1; */ + cam_id = (psta->mac_id + 3); - DBG_8723A("Write CAM, mac_addr =%x:%x:%x:%x:%x:%x, cam_entry =%d\n", pparm->addr[0], - pparm->addr[1], pparm->addr[2], pparm->addr[3], pparm->addr[4], - pparm->addr[5], cam_id); + DBG_8723A("Write CAM, mac_addr =%x:%x:%x:%x:%x:%x, " + "cam_entry =%d\n", pparm->addr[0], + pparm->addr[1], pparm->addr[2], + pparm->addr[3], pparm->addr[4], + pparm->addr[5], cam_id); rtl8723a_cam_write(padapter, cam_id, ctrl, pparm->addr, pparm->key); return H2C_SUCCESS_RSP; - - } - else - { - DBG_8723A("r871x_set_stakey_hdl23a(): sta has been free\n"); + } else { + DBG_8723A("r871x_set_stakey_hdl23a(): sta has been " + "free\n"); return H2C_REJECTED; } - } /* below for sta mode */ @@ -6334,7 +6333,7 @@ int set_stakey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) return H2C_SUCCESS; } - ctrl = BIT(15) | ((pparm->algorithm) << 2); + ctrl = BIT(15) | (pparm->algorithm << 2); rtl8723a_cam_write(padapter, cam_id, ctrl, pparm->addr, pparm->key); @@ -6346,39 +6345,38 @@ int set_stakey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) int add_ba_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { const struct addBaReq_parm *pparm = (struct addBaReq_parm *)pbuf; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct sta_info *psta; - struct sta_info *psta = rtw_get_stainfo23a(&padapter->stapriv, pparm->addr); + psta = rtw_get_stainfo23a(&padapter->stapriv, pparm->addr); if (!psta) return H2C_SUCCESS; if (((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && - (pmlmeinfo->HT_enable)) || - ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)) { + pmlmeinfo->HT_enable) || + (pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) { issue_action_BA23a(padapter, pparm->addr, - WLAN_ACTION_ADDBA_REQ, (u16)pparm->tid); + WLAN_ACTION_ADDBA_REQ, (u16)pparm->tid); mod_timer(&psta->addba_retry_timer, jiffies + msecs_to_jiffies(ADDBA_TO)); - } else { + } else psta->htpriv.candidate_tid_bitmap &= ~BIT(pparm->tid); - } + return H2C_SUCCESS; } int set_tx_beacon_cmd23a(struct rtw_adapter* padapter) { - struct cmd_obj *ph2c; + struct cmd_obj *ph2c; struct Tx_Beacon_param *ptxBeacon_parm; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - u8 res = _SUCCESS; + u8 res = _SUCCESS; int len_diff = 0; - - ph2c = (struct cmd_obj *)kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (!ph2c) { res = _FAIL; @@ -6402,14 +6400,12 @@ int set_tx_beacon_cmd23a(struct rtw_adapter* padapter) pmlmeinfo->hidden_ssid_mode); ptxBeacon_parm->network.IELength += len_diff; - init_h2fwcmd_w_parm_no_rsp(ph2c, ptxBeacon_parm, GEN_CMD_CODE(_TX_Beacon)); + init_h2fwcmd_w_parm_no_rsp(ph2c, ptxBeacon_parm, + GEN_CMD_CODE(_TX_Beacon)); res = rtw_enqueue_cmd23a(pcmdpriv, ph2c); exit: - - - return res; } @@ -6427,15 +6423,17 @@ int mlme_evt_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) /* checking if event code is valid */ if (evt_code >= MAX_C2HEVT) { - RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nEvent Code(%d) mismatch!\n", evt_code)); + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, + ("\nEvent Code(%d) mismatch!\n", evt_code)); goto _abort_event_; } /* checking if event size match the event parm size */ - if ((wlanevents[evt_code].parmsize != 0) && - (wlanevents[evt_code].parmsize != evt_sz)) { - RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nEvent(%d) Parm Size mismatch (%d vs %d)!\n", - evt_code, wlanevents[evt_code].parmsize, evt_sz)); + if (wlanevents[evt_code].parmsize != 0 && + wlanevents[evt_code].parmsize != evt_sz) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, + ("\nEvent(%d) Parm Size mismatch (%d vs %d)!\n", + evt_code, wlanevents[evt_code].parmsize, evt_sz)); goto _abort_event_; } @@ -6457,14 +6455,12 @@ int h2c_msg_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) int tx_beacon_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { - if (send_beacon23a(padapter) == _FAIL) - { + if (send_beacon23a(padapter) == _FAIL) { DBG_8723A("issue_beacon23a, fail!\n"); return H2C_PARAMETERS_ERROR; } #ifdef CONFIG_8723AU_AP_MODE - else /* tx bc/mc frames after update TIM */ - { + else { /* tx bc/mc frames after update TIM */ struct sta_info *psta_bmc; struct list_head *plist, *phead, *ptmp; struct xmit_frame *pxmitframe; @@ -6476,8 +6472,7 @@ int tx_beacon_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) if (!psta_bmc) return H2C_SUCCESS; - if ((pstapriv->tim_bitmap&BIT(0)) && (psta_bmc->sleepq_len>0)) - { + if (pstapriv->tim_bitmap & BIT(0) && psta_bmc->sleepq_len > 0) { msleep(10);/* 10ms, ATIM(HIQ) Windows */ /* spin_lock_bh(&psta_bmc->sleep_q.lock); */ spin_lock_bh(&pxmitpriv->lock); @@ -6508,7 +6503,6 @@ int tx_beacon_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) /* spin_unlock_bh(&psta_bmc->sleep_q.lock); */ spin_unlock_bh(&pxmitpriv->lock); } - } #endif @@ -6533,7 +6527,8 @@ int set_ch_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) pmlmeext->cur_ch_offset = set_ch_parm->ch_offset; pmlmeext->cur_bwmode = set_ch_parm->bw; - set_channel_bwmode23a(padapter, set_ch_parm->ch, set_ch_parm->ch_offset, set_ch_parm->bw); + set_channel_bwmode23a(padapter, set_ch_parm->ch, + set_ch_parm->ch_offset, set_ch_parm->bw); return H2C_SUCCESS; } @@ -6548,8 +6543,11 @@ int set_chplan_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) setChannelPlan_param = (struct SetChannelPlan_param *)pbuf; - pmlmeext->max_chan_nums = init_channel_set(padapter, setChannelPlan_param->channel_plan, pmlmeext->channel_set); - init_channel_list(padapter, pmlmeext->channel_set, pmlmeext->max_chan_nums, &pmlmeext->channel_list); + pmlmeext->max_chan_nums = + init_channel_set(padapter, setChannelPlan_param->channel_plan, + pmlmeext->channel_set); + init_channel_list(padapter, pmlmeext->channel_set, + pmlmeext->max_chan_nums, &pmlmeext->channel_list); return H2C_SUCCESS; } @@ -6573,11 +6571,14 @@ int set_csa_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) /* TDLS_WRCR : write RCR DATA BIT */ /* TDLS_SD_PTI : issue peer traffic indication */ -/* TDLS_CS_OFF : go back to the channel linked with AP, terminating channel switch procedure */ -/* TDLS_INIT_CH_SEN : init channel sensing, receive all data and mgnt frame */ -/* TDLS_DONE_CH_SEN: channel sensing and report candidate channel */ +/* TDLS_CS_OFF : go back to the channel linked with AP, + terminating channel switch procedure */ +/* TDLS_INIT_CH_SEN : init channel sensing, receive all data and + mgnt frame */ +/* TDLS_DONE_CH_SEN : channel sensing and report candidate channel */ /* TDLS_OFF_CH : first time set channel to off channel */ -/* TDLS_BASE_CH : go back tp the channel linked with AP when set base channel as target channel */ +/* TDLS_BASE_CH : go back tp the channel linked with AP when set + base channel as target channel */ /* TDLS_P_OFF_CH : periodically go to off channel */ /* TDLS_P_BASE_CH : periodically go back to base channel */ /* TDLS_RS_RCR : restore RCR */ -- cgit v1.2.3 From d5bacb1a35eaf1d2d6c98e73e5a1bdb4904be417 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 21 May 2014 09:38:36 +0200 Subject: staging: rtl8723au: rtw_mlme_ext.c: Fixup some more unreadable formatting Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 208 +++++++++++++------------- 1 file changed, 103 insertions(+), 105 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 068253faae70..b78e453b7a0f 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -5458,20 +5458,17 @@ void mlmeext_sta_add_event_callback23a(struct rtw_adapter *padapter, struct sta_ DBG_8723A("%s\n", __func__); - if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) - { - if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)/* adhoc master or sta_count>1 */ + if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { + /* adhoc master or sta_count>1 */ + if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) { /* nothing to do */ - } - else/* adhoc client */ - { + } else { /* adhoc client */ /* correcting TSF */ rtw_correct_TSF(padapter); /* start beacon */ - if (send_beacon23a(padapter) == _FAIL) - { + if (send_beacon23a(padapter) != _SUCCESS) { pmlmeinfo->FW_sta_info[psta->mac_id].status = 0; pmlmeinfo->state ^= WIFI_FW_ADHOC_STATE; @@ -5480,9 +5477,7 @@ void mlmeext_sta_add_event_callback23a(struct rtw_adapter *padapter, struct sta_ } pmlmeinfo->state |= WIFI_FW_ASSOC_SUCCESS; - } - hw_var_set_mlme_join(padapter, 2); } @@ -5497,25 +5492,27 @@ void mlmeext_sta_add_event_callback23a(struct rtw_adapter *padapter, struct sta_ void mlmeext_sta_del_event_callback23a(struct rtw_adapter *padapter) { - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - if (is_client_associated_to_ap23a(padapter) || is_IBSS_empty23a(padapter)) - { + if (is_client_associated_to_ap23a(padapter) || + is_IBSS_empty23a(padapter)) { /* set_opmode_cmd(padapter, infra_client_with_mlme); */ hw_var_set_mlme_disconnect(padapter); hw_var_set_bssid(padapter, null_addr); /* restore to initial setting. */ - update_tx_basic_rate23a(padapter, padapter->registrypriv.wireless_mode); + update_tx_basic_rate23a(padapter, + padapter->registrypriv.wireless_mode); /* switch to the 20M Hz mode after disconnect */ pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20; pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - /* SelectChannel23a(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset); */ - set_channel_bwmode23a(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); + set_channel_bwmode23a(padapter, pmlmeext->cur_channel, + pmlmeext->cur_ch_offset, + pmlmeext->cur_bwmode); flush_all_cam_entry23a(padapter); @@ -5532,7 +5529,7 @@ static u8 chk_ap_is_alive(struct rtw_adapter *padapter, struct sta_info *psta) { u8 ret = false; - if ((sta_rx_data_pkts(psta) == sta_last_rx_data_pkts(psta)) && + if (sta_rx_data_pkts(psta) == sta_last_rx_data_pkts(psta) && sta_rx_beacon_pkts(psta) == sta_last_rx_beacon_pkts(psta) && sta_rx_probersp_pkts(psta) == sta_last_rx_probersp_pkts(psta)) ret = false; @@ -5545,12 +5542,12 @@ static u8 chk_ap_is_alive(struct rtw_adapter *padapter, struct sta_info *psta) void linked_status_chk23a(struct rtw_adapter *padapter) { - u32 i; - struct sta_info *psta; + u32 i; + struct sta_info *psta; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct sta_priv *pstapriv = &padapter->stapriv; + struct sta_priv *pstapriv = &padapter->stapriv; rtl8723a_sreset_linked_status_check(padapter); @@ -5562,8 +5559,9 @@ void linked_status_chk23a(struct rtw_adapter *padapter) rx_chk_limit = 4; - if ((psta = rtw_get_stainfo23a(pstapriv, pmlmeinfo->network.MacAddress)) != NULL) - { + psta = rtw_get_stainfo23a(pstapriv, + pmlmeinfo->network.MacAddress); + if (psta) { bool is_p2p_enable = false; if (chk_ap_is_alive(padapter, psta) == false) @@ -5572,29 +5570,41 @@ void linked_status_chk23a(struct rtw_adapter *padapter) if (pxmitpriv->last_tx_pkts == pxmitpriv->tx_pkts) tx_chk = _FAIL; - if (pmlmeext->active_keep_alive_check && (rx_chk == _FAIL || tx_chk == _FAIL)) { + if (pmlmeext->active_keep_alive_check && + (rx_chk == _FAIL || tx_chk == _FAIL)) { u8 backup_oper_channel = 0; - /* switch to correct channel of current network before issue keep-alive frames */ - if (rtw_get_oper_ch23a(padapter) != pmlmeext->cur_channel) { - backup_oper_channel = rtw_get_oper_ch23a(padapter); - SelectChannel23a(padapter, pmlmeext->cur_channel); + /* switch to correct channel of current + network before issue keep-alive frames */ + if (rtw_get_oper_ch23a(padapter) != + pmlmeext->cur_channel) { + backup_oper_channel = + rtw_get_oper_ch23a(padapter); + SelectChannel23a(padapter, + pmlmeext->cur_channel); } if (rx_chk != _SUCCESS) issue_probereq_ex(padapter, &pmlmeinfo->network.Ssid, psta->hwaddr, 3, 1); - if ((tx_chk != _SUCCESS && pmlmeinfo->link_count++ == 0xf) || rx_chk != _SUCCESS) { - tx_chk = issue_nulldata23a(padapter, psta->hwaddr, 0, 3, 1); - /* if tx acked and p2p disabled, set rx_chk _SUCCESS to reset retry count */ - if (tx_chk == _SUCCESS && !is_p2p_enable) + if ((tx_chk != _SUCCESS && + pmlmeinfo->link_count++ == 0xf) || + rx_chk != _SUCCESS) { + tx_chk = issue_nulldata23a(padapter, + psta->hwaddr, + 0, 3, 1); + /* if tx acked and p2p disabled, + set rx_chk _SUCCESS to reset retry + count */ + if (tx_chk == _SUCCESS && + !is_p2p_enable) rx_chk = _SUCCESS; } /* back to the original operation channel */ if (backup_oper_channel>0) - SelectChannel23a(padapter, backup_oper_channel); - + SelectChannel23a(padapter, + backup_oper_channel); } else { if (rx_chk != _SUCCESS) { if (pmlmeext->retry == 0) { @@ -5604,8 +5614,11 @@ void linked_status_chk23a(struct rtw_adapter *padapter) } } - if (tx_chk != _SUCCESS && pmlmeinfo->link_count++ == 0xf) - tx_chk = issue_nulldata23a(padapter, NULL, 0, 1, 0); + if (tx_chk != _SUCCESS && + pmlmeinfo->link_count++ == 0xf) + tx_chk = issue_nulldata23a(padapter, + NULL, 0, 1, + 0); } if (rx_chk == _FAIL) { @@ -5619,57 +5632,46 @@ void linked_status_chk23a(struct rtw_adapter *padapter) WLAN_REASON_EXPIRATION_CHK); return; } - } else { + } else pmlmeext->retry = 0; - } - if (tx_chk == _FAIL) { + if (tx_chk == _FAIL) pmlmeinfo->link_count &= 0xf; - } else { + else { pxmitpriv->last_tx_pkts = pxmitpriv->tx_pkts; pmlmeinfo->link_count = 0; } - } /* end of if ((psta = rtw_get_stainfo23a(pstapriv, passoc_res->network.MacAddress)) != NULL) */ - } - else if (is_client_associated_to_ibss23a(padapter)) - { + } + } else if (is_client_associated_to_ibss23a(padapter)) { /* linked IBSS mode */ /* for each assoc list entry to check the rx pkt counter */ - for (i = IBSS_START_MAC_ID; i < NUM_STA; i++) - { - if (pmlmeinfo->FW_sta_info[i].status == 1) - { + for (i = IBSS_START_MAC_ID; i < NUM_STA; i++) { + if (pmlmeinfo->FW_sta_info[i].status == 1) { psta = pmlmeinfo->FW_sta_info[i].psta; - if (NULL == psta) continue; + if (!psta) + continue; - if (pmlmeinfo->FW_sta_info[i].rx_pkt == sta_rx_pkts(psta)) - { + if (pmlmeinfo->FW_sta_info[i].rx_pkt == + sta_rx_pkts(psta)) { - if (pmlmeinfo->FW_sta_info[i].retry<3) - { + if (pmlmeinfo->FW_sta_info[i].retry<3) { pmlmeinfo->FW_sta_info[i].retry++; - } - else - { + } else { pmlmeinfo->FW_sta_info[i].retry = 0; pmlmeinfo->FW_sta_info[i].status = 0; report_del_sta_event23a(padapter, psta->hwaddr, 65535/* indicate disconnect caused by no rx */ ); } - } - else - { + } else { pmlmeinfo->FW_sta_info[i].retry = 0; pmlmeinfo->FW_sta_info[i].rx_pkt = (u32)sta_rx_pkts(psta); } } } - /* set_link_timer(pmlmeext, DISCONNECT_TO); */ - } } @@ -5707,7 +5709,8 @@ static void survey_timer_hdl(unsigned long data) goto exit_survey_timer_hdl; } - init_h2fwcmd_w_parm_no_rsp(ph2c, psurveyPara, GEN_CMD_CODE(_SiteSurvey)); + init_h2fwcmd_w_parm_no_rsp(ph2c, psurveyPara, + GEN_CMD_CODE(_SiteSurvey)); rtw_enqueue_cmd23a(pcmdpriv, ph2c); } @@ -5725,17 +5728,13 @@ static void link_timer_hdl(unsigned long data) struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; /* struct sta_priv *pstapriv = &padapter->stapriv; */ - if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) - { + if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { DBG_8723A("link_timer_hdl:no beacon while connecting\n"); pmlmeinfo->state = WIFI_FW_NULL_STATE; report_join_res23a(padapter, -3); - } - else if (pmlmeinfo->state & WIFI_FW_AUTH_STATE) - { + } else if (pmlmeinfo->state & WIFI_FW_AUTH_STATE) { /* re-auth timer */ - if (++pmlmeinfo->reauth_count > REAUTH_LIMIT) - { + if (++pmlmeinfo->reauth_count > REAUTH_LIMIT) { /* if (pmlmeinfo->auth_algo != dot11AuthAlgrthm_Auto) */ /* */ pmlmeinfo->state = 0; @@ -5744,8 +5743,8 @@ static void link_timer_hdl(unsigned long data) /* */ /* else */ /* */ - /* pmlmeinfo->auth_algo = dot11AuthAlgrthm_Shared; */ - /* pmlmeinfo->reauth_count = 0; */ + /* pmlmeinfo->auth_algo = dot11AuthAlgrthm_Shared; */ + /* pmlmeinfo->reauth_count = 0; */ /* */ } @@ -5753,12 +5752,9 @@ static void link_timer_hdl(unsigned long data) pmlmeinfo->auth_seq = 1; issue_auth(padapter, NULL, 0); set_link_timer(pmlmeext, REAUTH_TO); - } - else if (pmlmeinfo->state & WIFI_FW_ASSOC_STATE) - { + } else if (pmlmeinfo->state & WIFI_FW_ASSOC_STATE) { /* re-assoc timer */ - if (++pmlmeinfo->reassoc_count > REASSOC_LIMIT) - { + if (++pmlmeinfo->reassoc_count > REASSOC_LIMIT) { pmlmeinfo->state = WIFI_FW_NULL_STATE; report_join_res23a(padapter, -2); return; @@ -5782,11 +5778,9 @@ static void addba_timer_hdl(unsigned long data) phtpriv = &psta->htpriv; - if ((phtpriv->ht_option == true) && (phtpriv->ampdu_enable == true)) - { + if (phtpriv->ht_option == true && phtpriv->ampdu_enable == true) { if (phtpriv->candidate_tid_bitmap) phtpriv->candidate_tid_bitmap = 0x0; - } } @@ -5902,8 +5896,8 @@ int createbss_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) int join_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { - struct registry_priv *pregpriv = &padapter->registrypriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct registry_priv *pregpriv = &padapter->registrypriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; const struct wlan_bssid_ex *pparm = (struct wlan_bssid_ex *)pbuf; @@ -5915,8 +5909,7 @@ int join_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) /* u32 acparm; */ /* check already connecting to AP or not */ - if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) - { + if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) { if (pmlmeinfo->state & WIFI_FW_STATION_STATE) issue_deauth_ex(padapter, pnetwork->MacAddress, WLAN_REASON_DEAUTH_LEAVING, 5, 100); @@ -6026,12 +6019,11 @@ int join_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) int disconnect_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { const struct disconnect_parm *param = (struct disconnect_parm *)pbuf; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; - if (is_client_associated_to_ap23a(padapter)) - { + if (is_client_associated_to_ap23a(padapter)) { issue_deauth_ex(padapter, pnetwork->MacAddress, WLAN_REASON_DEAUTH_LEAVING, param->deauth_timeout_ms/100, 100); @@ -6047,8 +6039,8 @@ int disconnect_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) /* restore to initial setting. */ update_tx_basic_rate23a(padapter, padapter->registrypriv.wireless_mode); - if (((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) || - ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)) + if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE || + (pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) rtl8723a_set_bcn_func(padapter, 0); /* Stop BCN */ /* set MSR to no link state -> infra. mode */ @@ -6060,7 +6052,8 @@ int disconnect_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20; pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - set_channel_bwmode23a(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); + set_channel_bwmode23a(padapter, pmlmeext->cur_channel, + pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); flush_all_cam_entry23a(padapter); @@ -6087,13 +6080,15 @@ rtw_scan_ch_decision(struct rtw_adapter *padapter, /* acquire channels from in */ j = 0; for (i = 0;ichannel_set, in[i].hw_value)) >= 0 - ) - { - memcpy(&out[j], &in[i], sizeof(struct rtw_ieee80211_channel)); - - if (pmlmeext->channel_set[set_idx].ScanType == SCAN_PASSIVE) + if (in[i].hw_value && + !(in[i].flags & IEEE80211_CHAN_DISABLED) && + (set_idx = rtw_ch_set_search_ch23a(pmlmeext->channel_set, + in[i].hw_value)) >= 0) { + memcpy(&out[j], &in[i], + sizeof(struct rtw_ieee80211_channel)); + + if (pmlmeext->channel_set[set_idx].ScanType == + SCAN_PASSIVE) out[j].flags &= IEEE80211_CHAN_NO_IR; j++; @@ -6114,7 +6109,7 @@ rtw_scan_ch_decision(struct rtw_adapter *padapter, } } - if (padapter->setband == GHZ_24) { /* 2.4G */ + if (padapter->setband == GHZ_24) { /* 2.4G */ for (i = 0; i < j ; i++) { if (out[i].hw_value > 35) memset(&out[i], 0, @@ -6123,10 +6118,11 @@ rtw_scan_ch_decision(struct rtw_adapter *padapter, scan_ch_num++; } j = scan_ch_num; - } else if (padapter->setband == GHZ_50) { /* 5G */ + } else if (padapter->setband == GHZ_50) { /* 5G */ for (i = 0; i < j ; i++) { if (out[i].hw_value > 35) { - memcpy(&out[scan_ch_num++], &out[i], sizeof(struct rtw_ieee80211_channel)); + memcpy(&out[scan_ch_num++], &out[i], + sizeof(struct rtw_ieee80211_channel)); } } j = scan_ch_num; @@ -6174,8 +6170,10 @@ int sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) /* switch to correct channel of current network before issue keep-alive frames */ - if (rtw_get_oper_ch23a(padapter) != pmlmeext->cur_channel) - SelectChannel23a(padapter, pmlmeext->cur_channel); + if (rtw_get_oper_ch23a(padapter) != + pmlmeext->cur_channel) + SelectChannel23a(padapter, + pmlmeext->cur_channel); issue_nulldata23a(padapter, NULL, 1, 3, 500); @@ -6189,8 +6187,8 @@ int sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) } } - if ((pmlmeext->sitesurvey_res.state == SCAN_START) || - (pmlmeext->sitesurvey_res.state == SCAN_TXNULL)) { + if (pmlmeext->sitesurvey_res.state == SCAN_START || + pmlmeext->sitesurvey_res.state == SCAN_TXNULL) { /* disable dynamic functions, such as high power, DIG */ rtl8723a_odm_support_ability_backup(padapter); rtl8723a_odm_support_ability_clr(padapter, @@ -6221,7 +6219,7 @@ int sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) int setauth_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) { const struct setauth_parm *pparm = (struct setauth_parm *)pbuf; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (pparm->mode < 4) @@ -6243,7 +6241,7 @@ int setkey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) pmlmeinfo->key_index = pparm->keyid; /* write cam */ - ctrl = BIT(15) | ((pparm->algorithm) << 2) | pparm->keyid; + ctrl = BIT(15) | (pparm->algorithm) << 2 | pparm->keyid; DBG_8723A_LEVEL(_drv_always_, "set group key to hw: alg:%d(WEP40-1 " "WEP104-5 TKIP-2 AES-4) keyid:%d\n", -- cgit v1.2.3 From be13f2919108e135c96a4e59515349cd275c4eae Mon Sep 17 00:00:00 2001 From: Karim Raslan Date: Wed, 21 May 2014 09:38:37 +0200 Subject: staging: rtl8723au: rtw_sta_mgt: change rtw_alloc_stainfo23a to use gfp_t instead if int This should fix a few sparse warnings like the following: CHECK drivers/staging/rtl8723au/core/rtw_ap.c drivers/staging/rtl8723au/core/rtw_ap.c:1054:45: warning: incorrect type in argument 3 (different base types) drivers/staging/rtl8723au/core/rtw_ap.c:1054:45: expected int [signed] gfp drivers/staging/rtl8723au/core/rtw_ap.c:1054:45: got restricted gfp_t Signed-off-by: Karim Raslan Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_sta_mgt.c | 2 +- drivers/staging/rtl8723au/include/sta_info.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c index f65d6d72624b..b829c2eb0c5a 100644 --- a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c @@ -107,7 +107,7 @@ int _rtw_free_sta_priv23a(struct sta_priv *pstapriv) } struct sta_info * -rtw_alloc_stainfo23a(struct sta_priv *pstapriv, u8 *hwaddr, int gfp) +rtw_alloc_stainfo23a(struct sta_priv *pstapriv, u8 *hwaddr, gfp_t gfp) { struct list_head *phash_list; struct sta_info *psta; diff --git a/drivers/staging/rtl8723au/include/sta_info.h b/drivers/staging/rtl8723au/include/sta_info.h index 1282c831d483..d1939a67390c 100644 --- a/drivers/staging/rtl8723au/include/sta_info.h +++ b/drivers/staging/rtl8723au/include/sta_info.h @@ -362,7 +362,7 @@ static inline u32 wifi_mac_hash(const u8 *mac) int _rtw_init_sta_priv23a(struct sta_priv *pstapriv); int _rtw_free_sta_priv23a(struct sta_priv *pstapriv); -struct sta_info *rtw_alloc_stainfo23a(struct sta_priv *pstapriv, u8 *hwaddr, int gfp); +struct sta_info *rtw_alloc_stainfo23a(struct sta_priv *pstapriv, u8 *hwaddr, gfp_t gfp); int rtw_free_stainfo23a(struct rtw_adapter *padapter, struct sta_info *psta); void rtw_free_all_stainfo23a(struct rtw_adapter *padapter); struct sta_info *rtw_get_stainfo23a(struct sta_priv *pstapriv, const u8 *hwaddr); -- cgit v1.2.3 From 48039e70b647424ee9cf529af7846effb270f417 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Wed, 21 May 2014 09:38:38 +0200 Subject: staging: realtek: Convert /n to \n Use proper line terminations. Signed-off-by: Joe Perches Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/usb_ops_linux.c | 2 +- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 2 +- drivers/staging/rtl8723au/hal/usb_ops_linux.c | 4 ++-- drivers/staging/rtl8723au/os_dep/usb_intf.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/usb_ops_linux.c b/drivers/staging/rtl8188eu/hal/usb_ops_linux.c index d8fc7472eb90..d9f60ab8c44d 100644 --- a/drivers/staging/rtl8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/hal/usb_ops_linux.c @@ -558,7 +558,7 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) rtw_read_port(adapt, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); break; case -EINPROGRESS: - DBG_88E("ERROR: URB IS IN PROGRESS!/n"); + DBG_88E("ERROR: URB IS IN PROGRESS!\n"); break; default: break; diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index 8ed2ac89f5c5..c63e2634c800 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -88,7 +88,7 @@ static u8 rtw_init_intf_priv(struct dvobj_priv *dvobj) dvobj->usb_alloc_vendor_req_buf = rtw_zmalloc(MAX_USB_IO_CTL_SIZE); if (dvobj->usb_alloc_vendor_req_buf == NULL) { - DBG_88E("alloc usb_vendor_req_buf failed... /n"); + DBG_88E("alloc usb_vendor_req_buf failed...\n"); rst = _FAIL; goto exit; } diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index 73b49aca95e1..df2e884dbb8b 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -439,7 +439,7 @@ urb_submit: case -EPROTO: break; case -EINPROGRESS: - DBG_8723A("ERROR: URB IS IN PROGRESS!/n"); + DBG_8723A("ERROR: URB IS IN PROGRESS!\n"); break; default: break; @@ -734,7 +734,7 @@ static void usb_read_port_complete(struct urb *purb) precvbuf); break; case -EINPROGRESS: - DBG_8723A("ERROR: URB IS IN PROGRESS!/n"); + DBG_8723A("ERROR: URB IS IN PROGRESS!\n"); break; default: break; diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index d00ccdcaacc5..f78be19aa333 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -107,7 +107,7 @@ static int rtw_init_intf_priv(struct dvobj_priv *dvobj) dvobj->usb_alloc_vendor_req_buf = kzalloc(MAX_USB_IO_CTL_SIZE, GFP_KERNEL); if (dvobj->usb_alloc_vendor_req_buf == NULL) { - DBG_8723A("alloc usb_vendor_req_buf failed... /n"); + DBG_8723A("alloc usb_vendor_req_buf failed...\n"); rst = _FAIL; goto exit; } -- cgit v1.2.3 From 4a6eea4dcbc0328c3126fed264c42b0725bea659 Mon Sep 17 00:00:00 2001 From: Benoit Taine Date: Thu, 22 May 2014 15:08:33 +0200 Subject: staging: rtl8723au: Use kmemdup() instead of memcpy() to duplicate memory This issue was reported by coccicheck using the semantic patch at scripts/coccinelle/api/memdup.cocci, and tested by compilation. Signed-off-by: Benoit Taine Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 3 +-- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 17 +++++++---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index a29fa76931c1..20c93e471adc 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -339,12 +339,11 @@ int rtl8723a_FirmwareDownload(struct rtw_adapter *padapter) rtStatus = _FAIL; goto Exit; } - firmware_buf = kzalloc(fw->size, GFP_KERNEL); + firmware_buf = kmemdup(fw->data, fw->size, GFP_KERNEL); if (!firmware_buf) { rtStatus = _FAIL; goto Exit; } - memcpy(firmware_buf, fw->data, fw->size); buf = firmware_buf; fw_size = fw->size; release_firmware(fw); diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 06d73e5549cc..f75a82596243 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -1506,14 +1506,14 @@ static int rtw_cfg80211_set_probe_req_wpsp2pie(struct rtw_adapter *padapter, pmlmepriv->wps_probe_req_ie = NULL; } - pmlmepriv->wps_probe_req_ie = - kmalloc(wps_ielen, GFP_KERNEL); + pmlmepriv->wps_probe_req_ie = kmemdup(wps_ie, + wps_ielen, + GFP_KERNEL); if (pmlmepriv->wps_probe_req_ie == NULL) { DBG_8723A("%s()-%d: kmalloc() ERROR!\n", __func__, __LINE__); return -EINVAL; } - memcpy(pmlmepriv->wps_probe_req_ie, wps_ie, wps_ielen); pmlmepriv->wps_probe_req_ie_len = wps_ielen; } } @@ -1777,12 +1777,11 @@ static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie, ret = -EINVAL; goto exit; } - buf = kzalloc(ielen, GFP_KERNEL); + buf = kmemdup(pie, ielen, GFP_KERNEL); if (buf == NULL) { ret = -ENOMEM; goto exit; } - memcpy(buf, pie, ielen); /* dump */ DBG_8723A("set wpa_ie(length:%zu):\n", ielen); @@ -3225,14 +3224,13 @@ static int rtw_cfg80211_set_beacon_wpsp2pie(struct net_device *ndev, char *buf, pmlmepriv->wps_beacon_ie = NULL; } - pmlmepriv->wps_beacon_ie = - kmalloc(wps_ielen, GFP_KERNEL); + pmlmepriv->wps_beacon_ie = kmemdup(wps_ie, wps_ielen, + GFP_KERNEL); if (pmlmepriv->wps_beacon_ie == NULL) { DBG_8723A("%s()-%d: kmalloc() ERROR!\n", __func__, __LINE__); return -EINVAL; } - memcpy(pmlmepriv->wps_beacon_ie, wps_ie, wps_ielen); pmlmepriv->wps_beacon_ie_len = wps_ielen; #ifdef CONFIG_8723AU_AP_MODE @@ -3317,14 +3315,13 @@ static int rtw_cfg80211_set_assoc_resp_wpsp2pie(struct net_device *net, pmlmepriv->wps_assoc_resp_ie = NULL; } - pmlmepriv->wps_assoc_resp_ie = kmalloc(len, GFP_KERNEL); + pmlmepriv->wps_assoc_resp_ie = kmemdup(buf, len, GFP_KERNEL); if (pmlmepriv->wps_assoc_resp_ie == NULL) { DBG_8723A("%s()-%d: kmalloc() ERROR!\n", __func__, __LINE__); return -EINVAL; } - memcpy(pmlmepriv->wps_assoc_resp_ie, buf, len); pmlmepriv->wps_assoc_resp_ie_len = len; } -- cgit v1.2.3 From 8522851e3bc1b2198ec0e7eb48694ae326dc6840 Mon Sep 17 00:00:00 2001 From: Paul McQuade Date: Tue, 8 Apr 2014 16:32:48 +0100 Subject: Staging:Octeon-usb:octeon-hcd.c return value return value instead of function. Signed-off-by: Paul McQuade Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/octeon-hcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index 8b8ce7293c52..2d15001b3061 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -3483,7 +3483,7 @@ static int octeon_usb_hub_status_data(struct usb_hcd *hcd, char *buf) buf[0] = 0; buf[0] = port_status.connect_change << 1; - return (buf[0] != 0); + return buf[0] != 0; } static int octeon_usb_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex, char *buf, u16 wLength) -- cgit v1.2.3 From 65bc0aaa9c2aa691e313a92250463008fb63266d Mon Sep 17 00:00:00 2001 From: David Matlack Date: Mon, 5 May 2014 21:02:31 -0700 Subject: staging: slicoss: fix use-after-free in slic_entry_probe This patch fixes a use-after-free bug that can cause a kernel oops. If slic_card_init fails then slic_entry_probe (the pci probe() function for this device) will return error without cleaning up memory. Signed-off-by: David Matlack Signed-off-by: Greg Kroah-Hartman --- drivers/staging/slicoss/slicoss.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index f350e6028ed2..0b0a7b4e20e4 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -3594,7 +3594,6 @@ static int slic_entry_probe(struct pci_dev *pcidev, struct net_device *netdev; struct adapter *adapter; void __iomem *memmapped_ioaddr = NULL; - u32 status = 0; ulong mmio_start = 0; ulong mmio_len = 0; struct sliccard *card = NULL; @@ -3685,16 +3684,11 @@ static int slic_entry_probe(struct pci_dev *pcidev, adapter->allocated = 1; } - status = slic_card_init(card, adapter); + err = slic_card_init(card, adapter); + if (err) + goto err_out_unmap; - if (status != 0) { - card->state = CARD_FAIL; - adapter->state = ADAPT_FAIL; - adapter->linkstate = LINK_DOWN; - dev_err(&pcidev->dev, "FAILED status[%x]\n", status); - } else { - slic_adapter_set_hwaddr(adapter); - } + slic_adapter_set_hwaddr(adapter); netdev->base_addr = (unsigned long)adapter->memorybase; netdev->irq = adapter->irq; @@ -3711,7 +3705,7 @@ static int slic_entry_probe(struct pci_dev *pcidev, cards_found++; - return status; + return 0; err_out_unmap: iounmap(memmapped_ioaddr); -- cgit v1.2.3 From a286e34de0568903e93d54beb1c62ce19f1b5031 Mon Sep 17 00:00:00 2001 From: David Matlack Date: Mon, 5 May 2014 21:02:32 -0700 Subject: staging: slicoss: fix multiple free-after-free in slic_entry_remove This patch fixes two free-after-free bugs in slic_entry_remove. Specifically, slic_unmap_mmio_space() iounmaps adapter->slic_regs, which is the same region of memory as dev->base_addr (iounmap-ed a few lines later). Next, both release_mem_region() and pci_release_regions() are called on the same pci_dev struct. Signed-off-by: David Matlack Signed-off-by: Greg Kroah-Hartman --- drivers/staging/slicoss/slicoss.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index 0b0a7b4e20e4..c6c1c4082d76 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -2954,8 +2954,6 @@ static void slic_card_cleanup(struct sliccard *card) static void slic_entry_remove(struct pci_dev *pcidev) { struct net_device *dev = pci_get_drvdata(pcidev); - u32 mmio_start = 0; - uint mmio_len = 0; struct adapter *adapter = netdev_priv(dev); struct sliccard *card; struct mcast_address *mcaddr, *mlist; @@ -2964,12 +2962,6 @@ static void slic_entry_remove(struct pci_dev *pcidev) slic_unmap_mmio_space(adapter); unregister_netdev(dev); - mmio_start = pci_resource_start(pcidev, 0); - mmio_len = pci_resource_len(pcidev, 0); - - release_mem_region(mmio_start, mmio_len); - - iounmap((void __iomem *)dev->base_addr); /* free multicast addresses */ mlist = adapter->mcastaddrs; while (mlist) { -- cgit v1.2.3 From 563dce372fac66674c18a66777f0a01343a8e373 Mon Sep 17 00:00:00 2001 From: David Matlack Date: Mon, 5 May 2014 21:02:33 -0700 Subject: staging: slicoss: remove unused members of struct adapter This patch removes two fields from the private "struct adapter". Specifically, memorybase duplicate of slic_regs memorylength written once and never read. This field is trivially computed with pci_resource_len if it's ever needed in the future. Signed-off-by: David Matlack Signed-off-by: Greg Kroah-Hartman --- drivers/staging/slicoss/slic.h | 2 -- drivers/staging/slicoss/slicoss.c | 4 +--- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h index 702902cdb461..379c4f7a8875 100644 --- a/drivers/staging/slicoss/slic.h +++ b/drivers/staging/slicoss/slic.h @@ -420,8 +420,6 @@ struct adapter { ushort devid; ushort subsysid; u32 irq; - void __iomem *memorybase; - u32 memorylength; u32 drambase; u32 dramlength; uint queues_initialized; diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index c6c1c4082d76..e8d38cf5a62a 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -3421,7 +3421,6 @@ static void slic_init_adapter(struct net_device *netdev, adapter->busnumber = pcidev->bus->number; adapter->slotnumber = ((pcidev->devfn >> 3) & 0x1F); adapter->functionnumber = (pcidev->devfn & 0x7); - adapter->memorylength = pci_resource_len(pcidev, 0); adapter->slic_regs = (__iomem struct slic_regs *)memaddr; adapter->irq = pcidev->irq; /* adapter->netdev = netdev;*/ @@ -3430,7 +3429,6 @@ static void slic_init_adapter(struct net_device *netdev, adapter->chipid = chip_idx; adapter->port = 0; /*adapter->functionnumber;*/ adapter->cardindex = adapter->port; - adapter->memorybase = memaddr; spin_lock_init(&adapter->upr_lock.lock); spin_lock_init(&adapter->bit64reglock.lock); spin_lock_init(&adapter->adapter_lock.lock); @@ -3682,7 +3680,7 @@ static int slic_entry_probe(struct pci_dev *pcidev, slic_adapter_set_hwaddr(adapter); - netdev->base_addr = (unsigned long)adapter->memorybase; + netdev->base_addr = (unsigned long) memmapped_ioaddr; netdev->irq = adapter->irq; netdev->netdev_ops = &slic_netdev_ops; -- cgit v1.2.3 From 04cc3c8a8013ea966e4623e0f20ba49529eac2ab Mon Sep 17 00:00:00 2001 From: David Matlack Date: Mon, 5 May 2014 21:02:34 -0700 Subject: staging: slicoss: remove gratuitous debug infrastructure As per the TODO file, this patch removes the gratuitous debug infrastructure. As an extra incentive for removing this code, the debugfs files are not cleaned up properly. For example, if register_netdev() fails in slic_entry_probe() then all debugfs files get left behind, even after the driver module is unloaded. Touching these files quickly leads to an oops. Signed-off-by: David Matlack Signed-off-by: Greg Kroah-Hartman --- drivers/staging/slicoss/TODO | 1 - drivers/staging/slicoss/slic.h | 3 - drivers/staging/slicoss/slicoss.c | 450 +------------------------------------- 3 files changed, 3 insertions(+), 451 deletions(-) diff --git a/drivers/staging/slicoss/TODO b/drivers/staging/slicoss/TODO index 62ff1008b1ee..20cc9abdc466 100644 --- a/drivers/staging/slicoss/TODO +++ b/drivers/staging/slicoss/TODO @@ -18,7 +18,6 @@ TODO: use ethtool instead - reorder code to elminate use of forward declarations - don't keep private linked list of drivers. - - remove all the gratiutous debug infrastructure - use PCI_DEVICE() - do ethtool correctly using ethtool_ops - NAPI? diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h index 379c4f7a8875..7de57c4c7fe7 100644 --- a/drivers/staging/slicoss/slic.h +++ b/drivers/staging/slicoss/slic.h @@ -310,8 +310,6 @@ struct sliccard { u32 loadtimerset; uint config_set; struct slic_config config; - struct dentry *debugfs_dir; - struct dentry *debugfs_cardinfo; struct adapter *master; struct adapter *adapter[SLIC_MAX_PORTS]; struct sliccard *next; @@ -450,7 +448,6 @@ struct adapter { u32 pingtimerset; struct timer_list loadtimer; u32 loadtimerset; - struct dentry *debugfs_entry; struct slic_spinlock upr_lock; struct slic_spinlock bit64reglock; struct slic_rspqueue rspqueue; diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index e8d38cf5a62a..db51cd29f225 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -81,7 +81,6 @@ #include #include #include -#include #include #include #include @@ -104,19 +103,13 @@ static char *slic_banner = "Alacritech SLIC Technology(tm) Server " "and Storage Accelerator (Non-Accelerated)"; static char *slic_proc_version = "2.0.351 2006/07/14 12:26:00"; -static char *slic_product_name = "SLIC Technology(tm) Server " - "and Storage Accelerator (Non-Accelerated)"; -static char *slic_vendor = "Alacritech, Inc."; -static int slic_debug = 1; -static int debug = -1; static struct net_device *head_netdevice; static struct base_driver slic_global = { {}, 0, 0, 0, 1, NULL, NULL }; static int intagg_delay = 100; static u32 dynamic_intagg; static unsigned int rcv_count; -static struct dentry *slic_debugfs; #define DRV_NAME "slicoss" #define DRV_VERSION "2.0.1" @@ -1801,430 +1794,6 @@ static u32 slic_rcvqueue_reinsert(struct adapter *adapter, struct sk_buff *skb) return rcvq->count; } -static int slic_debug_card_show(struct seq_file *seq, void *v) -{ -#ifdef MOOKTODO - int i; - struct sliccard *card = seq->private; - struct slic_config *config = &card->config; - unsigned char *fru = (unsigned char *)(&card->config.atk_fru); - unsigned char *oemfru = (unsigned char *)(&card->config.OemFru); -#endif - - seq_printf(seq, "driver_version : %s\n", slic_proc_version); - seq_puts(seq, "Microcode versions:\n"); - seq_printf(seq, " Gigabit (gb) : %s %s\n", - MOJAVE_UCODE_VERS_STRING, MOJAVE_UCODE_VERS_DATE); - seq_printf(seq, " Gigabit Receiver : %s %s\n", - GB_RCVUCODE_VERS_STRING, GB_RCVUCODE_VERS_DATE); - seq_printf(seq, "Vendor : %s\n", slic_vendor); - seq_printf(seq, "Product Name : %s\n", slic_product_name); -#ifdef MOOKTODO - seq_printf(seq, "VendorId : %4.4X\n", - config->VendorId); - seq_printf(seq, "DeviceId : %4.4X\n", - config->DeviceId); - seq_printf(seq, "RevisionId : %2.2x\n", - config->RevisionId); - seq_printf(seq, "Bus # : %d\n", card->busnumber); - seq_printf(seq, "Device # : %d\n", card->slotnumber); - seq_printf(seq, "Interfaces : %d\n", card->card_size); - seq_printf(seq, " Initialized : %d\n", - card->adapters_activated); - seq_printf(seq, " Allocated : %d\n", - card->adapters_allocated); - for (i = 0; i < card->card_size; i++) { - seq_printf(seq, - " MAC%d : %2.2X %2.2X %2.2X %2.2X %2.2X %2.2X\n", - i, config->macinfo[i].macaddrA[0], - config->macinfo[i].macaddrA[1], - config->macinfo[i].macaddrA[2], - config->macinfo[i].macaddrA[3], - config->macinfo[i].macaddrA[4], - config->macinfo[i].macaddrA[5]); - } - seq_puts(seq, " IF Init State Duplex/Speed irq\n"); - seq_puts(seq, " -------------------------------\n"); - for (i = 0; i < card->adapters_allocated; i++) { - struct adapter *adapter; - - adapter = card->adapter[i]; - if (adapter) { - seq_printf(seq, - " %d %d %s %s %s 0x%X\n", - adapter->physport, adapter->state, - SLIC_LINKSTATE(adapter->linkstate), - SLIC_DUPLEX(adapter->linkduplex), - SLIC_SPEED(adapter->linkspeed), - (uint) adapter->irq); - } - } - seq_printf(seq, "Generation # : %4.4X\n", card->gennumber); - seq_printf(seq, "RcvQ max entries : %4.4X\n", - SLIC_RCVQ_ENTRIES); - seq_printf(seq, "Ping Status : %8.8X\n", - card->pingstatus); - seq_printf(seq, "Minimum grant : %2.2x\n", - config->MinGrant); - seq_printf(seq, "Maximum Latency : %2.2x\n", config->MaxLat); - seq_printf(seq, "PciStatus : %4.4x\n", - config->Pcistatus); - seq_printf(seq, "Debug Device Id : %4.4x\n", - config->DbgDevId); - seq_printf(seq, "DRAM ROM Function : %4.4x\n", - config->DramRomFn); - seq_printf(seq, "Network interface Pin 1 : %2.2x\n", - config->NetIntPin1); - seq_printf(seq, "Network interface Pin 2 : %2.2x\n", - config->NetIntPin1); - seq_printf(seq, "Network interface Pin 3 : %2.2x\n", - config->NetIntPin1); - seq_printf(seq, "PM capabilities : %4.4X\n", - config->PMECapab); - seq_printf(seq, "Network Clock Controls : %4.4X\n", - config->NwClkCtrls); - - switch (config->FruFormat) { - case ATK_FRU_FORMAT: - { - seq_puts(seq, - "Vendor : Alacritech, Inc.\n"); - seq_printf(seq, - "Assembly # : %c%c%c%c%c%c\n", - fru[0], fru[1], fru[2], fru[3], fru[4], - fru[5]); - seq_printf(seq, - "Revision # : %c%c\n", - fru[6], fru[7]); - - if (config->OEMFruFormat == VENDOR4_FRU_FORMAT) { - seq_printf(seq, - "Serial # : %c%c%c%c%c%c%c%c%c%c%c%c\n", - fru[8], fru[9], fru[10], - fru[11], fru[12], fru[13], - fru[16], fru[17], fru[18], - fru[19], fru[20], fru[21]); - } else { - seq_printf(seq, - "Serial # : %c%c%c%c%c%c%c%c%c%c%c%c%c%c\n", - fru[8], fru[9], fru[10], - fru[11], fru[12], fru[13], - fru[14], fru[15], fru[16], - fru[17], fru[18], fru[19], - fru[20], fru[21]); - } - break; - } - - default: - { - seq_puts(seq, - "Vendor : Alacritech, Inc.\n"); - seq_puts(seq, - "Serial # : Empty FRU\n"); - break; - } - } - - switch (config->OEMFruFormat) { - case VENDOR1_FRU_FORMAT: - { - seq_puts(seq, "FRU Information:\n"); - seq_printf(seq, " Commodity # : %c\n", - oemfru[0]); - seq_printf(seq, - " Assembly # : %c%c%c%c\n", - oemfru[1], oemfru[2], oemfru[3], oemfru[4]); - seq_printf(seq, - " Revision # : %c%c\n", - oemfru[5], oemfru[6]); - seq_printf(seq, - " Supplier # : %c%c\n", - oemfru[7], oemfru[8]); - seq_printf(seq, - " Date : %c%c\n", - oemfru[9], oemfru[10]); - seq_sprintf(seq, - " Sequence # : %c%c%c\n", - oemfru[11], oemfru[12], oemfru[13]); - break; - } - - case VENDOR2_FRU_FORMAT: - { - seq_puts(seq, "FRU Information:\n"); - seq_printf(seq, - " Part # : %c%c%c%c%c%c%c%c\n", - oemfru[0], oemfru[1], oemfru[2], - oemfru[3], oemfru[4], oemfru[5], - oemfru[6], oemfru[7]); - seq_printf(seq, - " Supplier # : %c%c%c%c%c\n", - oemfru[8], oemfru[9], oemfru[10], - oemfru[11], oemfru[12]); - seq_printf(seq, - " Date : %c%c%c\n", - oemfru[13], oemfru[14], oemfru[15]); - seq_sprintf(seq, - " Sequence # : %c%c%c%c\n", - oemfru[16], oemfru[17], oemfru[18], - oemfru[19]); - break; - } - - case VENDOR3_FRU_FORMAT: - { - seq_puts(seq, "FRU Information:\n"); - } - - case VENDOR4_FRU_FORMAT: - { - seq_puts(seq, "FRU Information:\n"); - seq_printf(seq, - " FRU Number : %c%c%c%c%c%c%c%c\n", - oemfru[0], oemfru[1], oemfru[2], - oemfru[3], oemfru[4], oemfru[5], - oemfru[6], oemfru[7]); - seq_sprintf(seq, - " Part Number : %c%c%c%c%c%c%c%c\n", - oemfru[8], oemfru[9], oemfru[10], - oemfru[11], oemfru[12], oemfru[13], - oemfru[14], oemfru[15]); - seq_printf(seq, - " EC Level : %c%c%c%c%c%c%c%c\n", - oemfru[16], oemfru[17], oemfru[18], - oemfru[19], oemfru[20], oemfru[21], - oemfru[22], oemfru[23]); - break; - } - - default: - break; - } -#endif - - return 0; -} - -static int slic_debug_adapter_show(struct seq_file *seq, void *v) -{ - struct adapter *adapter = seq->private; - struct net_device *netdev = adapter->netdev; - - seq_printf(seq, "info: interface : %s\n", - adapter->netdev->name); - seq_printf(seq, "info: status : %s\n", - SLIC_LINKSTATE(adapter->linkstate)); - seq_printf(seq, "info: port : %d\n", - adapter->physport); - seq_printf(seq, "info: speed : %s\n", - SLIC_SPEED(adapter->linkspeed)); - seq_printf(seq, "info: duplex : %s\n", - SLIC_DUPLEX(adapter->linkduplex)); - seq_printf(seq, "info: irq : 0x%X\n", - (uint) adapter->irq); - seq_printf(seq, "info: Interrupt Agg Delay: %d usec\n", - adapter->card->loadlevel_current); - seq_printf(seq, "info: RcvQ max entries : %4.4X\n", - SLIC_RCVQ_ENTRIES); - seq_printf(seq, "info: RcvQ current : %4.4X\n", - adapter->rcvqueue.count); - seq_printf(seq, "rx stats: packets : %8.8lX\n", - netdev->stats.rx_packets); - seq_printf(seq, "rx stats: bytes : %8.8lX\n", - netdev->stats.rx_bytes); - seq_printf(seq, "rx stats: broadcasts : %8.8X\n", - adapter->rcv_broadcasts); - seq_printf(seq, "rx stats: multicasts : %8.8X\n", - adapter->rcv_multicasts); - seq_printf(seq, "rx stats: unicasts : %8.8X\n", - adapter->rcv_unicasts); - seq_printf(seq, "rx stats: errors : %8.8X\n", - (u32) adapter->slic_stats.iface.rcv_errors); - seq_printf(seq, "rx stats: Missed errors : %8.8X\n", - (u32) adapter->slic_stats.iface.rcv_discards); - seq_printf(seq, "rx stats: drops : %8.8X\n", - (u32) adapter->rcv_drops); - seq_printf(seq, "tx stats: packets : %8.8lX\n", - netdev->stats.tx_packets); - seq_printf(seq, "tx stats: bytes : %8.8lX\n", - netdev->stats.tx_bytes); - seq_printf(seq, "tx stats: errors : %8.8X\n", - (u32) adapter->slic_stats.iface.xmt_errors); - seq_printf(seq, "rx stats: multicasts : %8.8lX\n", - netdev->stats.multicast); - seq_printf(seq, "tx stats: collision errors : %8.8X\n", - (u32) adapter->slic_stats.iface.xmit_collisions); - seq_printf(seq, "perf: Max rcv frames/isr : %8.8X\n", - adapter->max_isr_rcvs); - seq_printf(seq, "perf: Rcv interrupt yields : %8.8X\n", - adapter->rcv_interrupt_yields); - seq_printf(seq, "perf: Max xmit complete/isr : %8.8X\n", - adapter->max_isr_xmits); - seq_printf(seq, "perf: error interrupts : %8.8X\n", - adapter->error_interrupts); - seq_printf(seq, "perf: error rmiss interrupts : %8.8X\n", - adapter->error_rmiss_interrupts); - seq_printf(seq, "perf: rcv interrupts : %8.8X\n", - adapter->rcv_interrupts); - seq_printf(seq, "perf: xmit interrupts : %8.8X\n", - adapter->xmit_interrupts); - seq_printf(seq, "perf: link event interrupts : %8.8X\n", - adapter->linkevent_interrupts); - seq_printf(seq, "perf: UPR interrupts : %8.8X\n", - adapter->upr_interrupts); - seq_printf(seq, "perf: interrupt count : %8.8X\n", - adapter->num_isrs); - seq_printf(seq, "perf: false interrupts : %8.8X\n", - adapter->false_interrupts); - seq_printf(seq, "perf: All register writes : %8.8X\n", - adapter->all_reg_writes); - seq_printf(seq, "perf: ICR register writes : %8.8X\n", - adapter->icr_reg_writes); - seq_printf(seq, "perf: ISR register writes : %8.8X\n", - adapter->isr_reg_writes); - seq_printf(seq, "ifevents: overflow 802 errors : %8.8X\n", - adapter->if_events.oflow802); - seq_printf(seq, "ifevents: transport overflow errors: %8.8X\n", - adapter->if_events.Tprtoflow); - seq_printf(seq, "ifevents: underflow errors : %8.8X\n", - adapter->if_events.uflow802); - seq_printf(seq, "ifevents: receive early : %8.8X\n", - adapter->if_events.rcvearly); - seq_printf(seq, "ifevents: buffer overflows : %8.8X\n", - adapter->if_events.Bufov); - seq_printf(seq, "ifevents: carrier errors : %8.8X\n", - adapter->if_events.Carre); - seq_printf(seq, "ifevents: Long : %8.8X\n", - adapter->if_events.Longe); - seq_printf(seq, "ifevents: invalid preambles : %8.8X\n", - adapter->if_events.Invp); - seq_printf(seq, "ifevents: CRC errors : %8.8X\n", - adapter->if_events.Crc); - seq_printf(seq, "ifevents: dribble nibbles : %8.8X\n", - adapter->if_events.Drbl); - seq_printf(seq, "ifevents: Code violations : %8.8X\n", - adapter->if_events.Code); - seq_printf(seq, "ifevents: TCP checksum errors : %8.8X\n", - adapter->if_events.TpCsum); - seq_printf(seq, "ifevents: TCP header short errors : %8.8X\n", - adapter->if_events.TpHlen); - seq_printf(seq, "ifevents: IP checksum errors : %8.8X\n", - adapter->if_events.IpCsum); - seq_printf(seq, "ifevents: IP frame incompletes : %8.8X\n", - adapter->if_events.IpLen); - seq_printf(seq, "ifevents: IP headers shorts : %8.8X\n", - adapter->if_events.IpHlen); - - return 0; -} -static int slic_debug_adapter_open(struct inode *inode, struct file *file) -{ - return single_open(file, slic_debug_adapter_show, inode->i_private); -} - -static int slic_debug_card_open(struct inode *inode, struct file *file) -{ - return single_open(file, slic_debug_card_show, inode->i_private); -} - -static const struct file_operations slic_debug_adapter_fops = { - .owner = THIS_MODULE, - .open = slic_debug_adapter_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static const struct file_operations slic_debug_card_fops = { - .owner = THIS_MODULE, - .open = slic_debug_card_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static void slic_debug_adapter_create(struct adapter *adapter) -{ - struct dentry *d; - char name[7]; - struct sliccard *card = adapter->card; - - if (!card->debugfs_dir) - return; - - sprintf(name, "port%d", adapter->port); - d = debugfs_create_file(name, S_IRUGO, - card->debugfs_dir, adapter, - &slic_debug_adapter_fops); - if (!d || IS_ERR(d)) - pr_info(PFX "%s: debugfs create failed\n", name); - else - adapter->debugfs_entry = d; -} - -static void slic_debug_adapter_destroy(struct adapter *adapter) -{ - debugfs_remove(adapter->debugfs_entry); - adapter->debugfs_entry = NULL; -} - -static void slic_debug_card_create(struct sliccard *card) -{ - struct dentry *d; - char name[IFNAMSIZ]; - - snprintf(name, sizeof(name), "slic%d", card->cardnum); - d = debugfs_create_dir(name, slic_debugfs); - if (!d || IS_ERR(d)) - pr_info(PFX "%s: debugfs create dir failed\n", - name); - else { - card->debugfs_dir = d; - d = debugfs_create_file("cardinfo", S_IRUGO, - slic_debugfs, card, - &slic_debug_card_fops); - if (!d || IS_ERR(d)) - pr_info(PFX "%s: debugfs create failed\n", - name); - else - card->debugfs_cardinfo = d; - } -} - -static void slic_debug_card_destroy(struct sliccard *card) -{ - int i; - - for (i = 0; i < card->card_size; i++) { - struct adapter *adapter; - - adapter = card->adapter[i]; - if (adapter) - slic_debug_adapter_destroy(adapter); - } - debugfs_remove(card->debugfs_cardinfo); - debugfs_remove(card->debugfs_dir); -} - -static void slic_debug_init(void) -{ - struct dentry *ent; - - ent = debugfs_create_dir("slic", NULL); - if (!ent || IS_ERR(ent)) { - pr_info(PFX "debugfs create directory failed\n"); - return; - } - - slic_debugfs = ent; -} - -static void slic_debug_cleanup(void) -{ - debugfs_remove(slic_debugfs); -} - /* * slic_link_event_handler - * @@ -2946,8 +2515,6 @@ static void slic_card_cleanup(struct sliccard *card) del_timer_sync(&card->loadtimer); } - slic_debug_card_destroy(card); - kfree(card); } @@ -3401,7 +2968,6 @@ static void slic_init_driver(void) if (slic_first_init) { slic_first_init = 0; spin_lock_init(&slic_global.driver_lock.lock); - slic_debug_init(); } } @@ -3518,8 +3084,6 @@ static u32 slic_card_locate(struct adapter *adapter) } } slic_global.num_slic_cards++; - - slic_debug_card_create(card); } else { /* Card exists, find the card this adapter belongs to */ while (card) { @@ -3596,9 +3160,9 @@ static int slic_entry_probe(struct pci_dev *pcidev, if (err) return err; - if (slic_debug > 0 && did_version++ == 0) { - dev_dbg(&pcidev->dev, "%s\n", slic_banner); - dev_dbg(&pcidev->dev, "%s\n", slic_proc_version); + if (did_version++ == 0) { + dev_info(&pcidev->dev, "%s\n", slic_banner); + dev_info(&pcidev->dev, "%s\n", slic_proc_version); } if (!pci_set_dma_mask(pcidev, DMA_BIT_MASK(64))) { @@ -3684,8 +3248,6 @@ static int slic_entry_probe(struct pci_dev *pcidev, netdev->irq = adapter->irq; netdev->netdev_ops = &slic_netdev_ops; - slic_debug_adapter_create(adapter); - strcpy(netdev->name, "eth%d"); err = register_netdev(netdev); if (err) { @@ -3719,18 +3281,12 @@ static int __init slic_module_init(void) { slic_init_driver(); - if (debug >= 0 && slic_debug != debug) - pr_debug("debug level is %d.\n", debug); - if (debug >= 0) - slic_debug = debug; - return pci_register_driver(&slic_driver); } static void __exit slic_module_cleanup(void) { pci_unregister_driver(&slic_driver); - slic_debug_cleanup(); } module_init(slic_module_init); -- cgit v1.2.3 From 9bc97445a39d37d4092a6a268b7dac93beb86f13 Mon Sep 17 00:00:00 2001 From: David Matlack Date: Mon, 5 May 2014 21:02:35 -0700 Subject: staging: slicoss: fix dma memory leak This patch fixes a memory leak in slic_card_init. If the driver fails to poll for an interrupt after requesting config data from the device the dma memory is never freed. Signed-off-by: David Matlack Signed-off-by: Greg Kroah-Hartman --- drivers/staging/slicoss/slicoss.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index db51cd29f225..fea584517e78 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -2851,6 +2851,9 @@ static int slic_card_init(struct sliccard *card, struct adapter *adapter) &slic_regs->slic_isp, 0, &slic_regs->slic_addr_upper, 0, FLUSH); + pci_free_consistent(adapter->pcidev, + sizeof(struct slic_eeprom), + peeprom, phys_config); return -EINVAL; } } -- cgit v1.2.3 From 0783c636d1872123b68522b5afb257917c3d5aa9 Mon Sep 17 00:00:00 2001 From: David Matlack Date: Mon, 5 May 2014 21:02:36 -0700 Subject: staging: slicoss: fix 64-bit isr address bug This patch fixes a bug that only manifests when the physical address of the interrupt status register is >4GB. Specifically, the driver was only telling the device about the lower 32 bits of the ISR. This patch adds the upper 32 bits. Signed-off-by: David Matlack Signed-off-by: Greg Kroah-Hartman --- drivers/staging/slicoss/slicoss.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index fea584517e78..fde0ff97f5fb 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -2814,7 +2814,8 @@ static int slic_card_init(struct sliccard *card, struct adapter *adapter) spin_lock_irqsave(&adapter->bit64reglock.lock, adapter->bit64reglock.flags); - slic_reg32_write(&slic_regs->slic_addr_upper, 0, DONT_FLUSH); + slic_reg32_write(&slic_regs->slic_addr_upper, + SLIC_GET_ADDR_HIGH(&pshmem->isr), DONT_FLUSH); slic_reg32_write(&slic_regs->slic_isp, SLIC_GET_ADDR_LOW(&pshmem->isr), FLUSH); spin_unlock_irqrestore(&adapter->bit64reglock.lock, -- cgit v1.2.3 From dedabbbcb5ed7c75664b4ca66a525c09fe6acf12 Mon Sep 17 00:00:00 2001 From: David Matlack Date: Mon, 5 May 2014 21:02:37 -0700 Subject: staging: slicoss: fix use-after-free bug in slic_entry_remove This patch fixes a use-after-free bug that causes a null pointer dereference in slic_entry_halt. Since unregister_netdev() will ultimately call slic_entry_halt (the net_device ndo_stop() virtual function for this device), we should call it before freeing the memory used by slic_entry_halt. Signed-off-by: David Matlack Signed-off-by: Greg Kroah-Hartman --- drivers/staging/slicoss/slicoss.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index fde0ff97f5fb..3010501120d2 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -2525,9 +2525,10 @@ static void slic_entry_remove(struct pci_dev *pcidev) struct sliccard *card; struct mcast_address *mcaddr, *mlist; + unregister_netdev(dev); + slic_adapter_freeresources(adapter); slic_unmap_mmio_space(adapter); - unregister_netdev(dev); /* free multicast addresses */ mlist = adapter->mcastaddrs; -- cgit v1.2.3 From 55b62cdfe9089cdaaeac52404d916cbffcfb0ab3 Mon Sep 17 00:00:00 2001 From: David Matlack Date: Mon, 19 May 2014 22:03:59 -0700 Subject: staging: slicoss: fix eeprom checksum code Rewrite slic_eeprom_cksum() to fix bugs and make readable. This patch technically has no effect on the user as failed eeprom checksums are ignored anyway. The original implementation had the following issues: 1. 2 of the 3 unrolled loops had the following bug: while ((len -= 32) >= 0) { [...] sum += w[15]; w = (u16 *)((ulong) w + 16); /* verify */ } This processes 32-bytes of data but only increments the word pointer by 16 bytes. Fixing both of these bugs seems to fix slic_eeprom_cksum(). 2. Non-descriptive variable names, use of unions, and macros that change local state make the code difficult to read. 3. The checksum loop is unrolled which makes the code harder to reason about while providing small performance improvement: - max eeprom length is 0x80 bytes (MAX_EECODE_SIZE), that's only 0x40 iterations - checksum is only computed during pci probe(), so not very often Tested on Mojave card Signed-off-by: David Matlack Signed-off-by: Greg Kroah-Hartman --- drivers/staging/slicoss/slicoss.c | 110 ++++++-------------------------------- 1 file changed, 15 insertions(+), 95 deletions(-) diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index 3010501120d2..6ad180b6ec85 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -1144,105 +1144,26 @@ static void slic_config_get(struct adapter *adapter, u32 config, } /* - * this is here to checksum the eeprom, there is some ucode bug - * which prevens us from using the ucode result. - * remove this once ucode is fixed. + * Compute a checksum of the EEPROM according to RFC 1071. */ -static ushort slic_eeprom_cksum(char *m, int len) +static u16 slic_eeprom_cksum(void *eeprom, unsigned len) { -#define ADDCARRY(x) (x > 65535 ? x -= 65535 : x) -#define REDUCE {l_util.l = sum; sum = l_util.s[0] + l_util.s[1]; ADDCARRY(sum);\ - } - - u16 *w; - u32 sum = 0; - u32 byte_swapped = 0; - u32 w_int; - - union { - char c[2]; - ushort s; - } s_util; + u16 *wp = eeprom; + u32 checksum = 0; - union { - ushort s[2]; - int l; - } l_util; + while (len > 1) { + checksum += *(wp++); + len -= 2; + } - l_util.l = 0; - s_util.s = 0; + if (len > 0) + checksum += *(u8 *) wp; - w = (u16 *)m; -#if BITS_PER_LONG == 64 - w_int = (u32) ((ulong) w & 0x00000000FFFFFFFF); -#else - w_int = (u32) (w); -#endif - if ((1 & w_int) && (len > 0)) { - REDUCE; - sum <<= 8; - s_util.c[0] = *(unsigned char *)w; - w = (u16 *)((char *)w + 1); - len--; - byte_swapped = 1; - } - - /* Unroll the loop to make overhead from branches &c small. */ - while ((len -= 32) >= 0) { - sum += w[0]; - sum += w[1]; - sum += w[2]; - sum += w[3]; - sum += w[4]; - sum += w[5]; - sum += w[6]; - sum += w[7]; - sum += w[8]; - sum += w[9]; - sum += w[10]; - sum += w[11]; - sum += w[12]; - sum += w[13]; - sum += w[14]; - sum += w[15]; - w = (u16 *)((ulong) w + 16); /* verify */ - } - len += 32; - while ((len -= 8) >= 0) { - sum += w[0]; - sum += w[1]; - sum += w[2]; - sum += w[3]; - w = (u16 *)((ulong) w + 4); /* verify */ - } - len += 8; - if (len != 0 || byte_swapped != 0) { - REDUCE; - while ((len -= 2) >= 0) - sum += *w++; /* verify */ - if (byte_swapped) { - REDUCE; - sum <<= 8; - byte_swapped = 0; - if (len == -1) { - s_util.c[1] = *(char *) w; - sum += s_util.s; - len = 0; - } else { - len = -1; - } - } else if (len == -1) { - s_util.c[0] = *(char *) w; - } + while (checksum >> 16) + checksum = (checksum & 0xFFFF) + ((checksum >> 16) & 0xFFFF); - if (len == -1) { - s_util.c[1] = 0; - sum += s_util.s; - } - } - REDUCE; - return (ushort) sum; + return ~checksum; } static void slic_rspqueue_free(struct adapter *adapter) @@ -2902,9 +2823,8 @@ static int slic_card_init(struct sliccard *card, struct adapter *adapter) /* calculate the EEPROM checksum */ - calc_chksum = - ~slic_eeprom_cksum((char *) peeprom, - (eecodesize - 2)); + calc_chksum = slic_eeprom_cksum(peeprom, + eecodesize - 2); /* if the ucdoe chksum flag bit worked, we wouldn't need this -- cgit v1.2.3 From 28277a55fd8e9d0c53647734d824a6bf7ba92e04 Mon Sep 17 00:00:00 2001 From: David Matlack Date: Mon, 19 May 2014 22:04:00 -0700 Subject: staging: slicoss: fail on corrupt eeprom Remove fail_on_bad_eeprom, which was always 0 and thus being used to ignore incorrect checksumming. This means devices with corrupt eeprom will now cause the driver to fail. Since fail_on_bad_eeprom was the last member in use of struct slic_reg_params, remove that struct altogether. Signed-off-by: David Matlack Signed-off-by: Greg Kroah-Hartman --- drivers/staging/slicoss/slic.h | 7 ------- drivers/staging/slicoss/slicoss.c | 3 +-- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h index 7de57c4c7fe7..15a24c024d22 100644 --- a/drivers/staging/slicoss/slic.h +++ b/drivers/staging/slicoss/slic.h @@ -362,12 +362,6 @@ struct slic_shmem { volatile struct slic_stats inicstats; }; -struct slic_reg_params { - u32 linkspeed; - u32 linkduplex; - u32 fail_on_bad_eeprom; -}; - struct slic_upr { uint adapter; u32 upr_request; @@ -493,7 +487,6 @@ struct adapter { u32 intagg_period; struct inicpm_state *inicpm_info; void *pinicpm_info; - struct slic_reg_params reg_params; struct slic_ifevents if_events; struct slic_stats inicstats_prev; struct slicnet_stats slic_stats; diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index 6ad180b6ec85..9ff1a31faf2e 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -2850,8 +2850,7 @@ static int slic_card_init(struct sliccard *card, struct adapter *adapter) sizeof(struct slic_eeprom), peeprom, phys_config); - if ((!card->config.EepromValid) && - (adapter->reg_params.fail_on_bad_eeprom)) { + if (!card->config.EepromValid) { slic_reg64_write(adapter, &slic_regs->slic_isp, 0, &slic_regs->slic_addr_upper, 0, FLUSH); -- cgit v1.2.3 From 47a401a8aec98b152e328858bbb4406c7e3b61e1 Mon Sep 17 00:00:00 2001 From: David Matlack Date: Thu, 22 May 2014 21:38:45 -0700 Subject: staging: slicoss: handle errors from slic_config_get slic_config_get() can fail. Change the return type from void to int and handle the error in slic_card_init(). So now, instead of silently failing (and then timing out waiting for the config data), the driver will fail loudly at request time. Signed-off-by: David Matlack Signed-off-by: Greg Kroah-Hartman --- drivers/staging/slicoss/slicoss.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index 9ff1a31faf2e..86dd47210f96 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -1133,14 +1133,10 @@ static void slic_upr_request_complete(struct adapter *adapter, u32 isr) adapter->upr_lock.flags); } -static void slic_config_get(struct adapter *adapter, u32 config, - u32 config_h) +static int slic_config_get(struct adapter *adapter, u32 config, u32 config_h) { - int status; - - status = slic_upr_request(adapter, - SLIC_UPR_RCONFIG, - (u32) config, (u32) config_h, 0, 0); + return slic_upr_request(adapter, SLIC_UPR_RCONFIG, config, config_h, + 0, 0); } /* @@ -2743,7 +2739,12 @@ static int slic_card_init(struct sliccard *card, struct adapter *adapter) spin_unlock_irqrestore(&adapter->bit64reglock.lock, adapter->bit64reglock.flags); - slic_config_get(adapter, phys_configl, phys_configh); + status = slic_config_get(adapter, phys_configl, phys_configh); + if (status) { + dev_err(&adapter->pcidev->dev, + "Failed to fetch config data from device.\n"); + goto card_init_err; + } for (;;) { if (adapter->pshmem->isr) { @@ -2774,10 +2775,8 @@ static int slic_card_init(struct sliccard *card, struct adapter *adapter) &slic_regs->slic_isp, 0, &slic_regs->slic_addr_upper, 0, FLUSH); - pci_free_consistent(adapter->pcidev, - sizeof(struct slic_eeprom), - peeprom, phys_config); - return -EINVAL; + status = -EINVAL; + goto card_init_err; } } } @@ -2885,6 +2884,11 @@ static int slic_card_init(struct sliccard *card, struct adapter *adapter) card->reset_in_progress = 0; return 0; + +card_init_err: + pci_free_consistent(adapter->pcidev, sizeof(struct slic_eeprom), + peeprom, phys_config); + return status; } static void slic_init_driver(void) -- cgit v1.2.3 From 3db5540dfd889bc008db3ff2f868cce0f6fb2a04 Mon Sep 17 00:00:00 2001 From: Ken Cox Date: Thu, 22 May 2014 12:31:09 -0500 Subject: Staging: unisys: Fix sparse warnings Fix sparse warnings caused by incorrect references to IO space. Signed-off-by: Ken Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/uislib/uislib.c | 2 +- drivers/staging/unisys/visorchannel/visorchannel.h | 6 +++--- drivers/staging/unisys/visorchannel/visorchannel_funcs.c | 4 ++-- drivers/staging/unisys/visorutil/memregion.h | 2 +- drivers/staging/unisys/visorutil/memregion_direct.c | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 166a518a04f6..e3903ee72443 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -131,7 +131,7 @@ init_msg_header(CONTROLVM_MESSAGE *msg, U32 id, uint rsp, uint svr) static __iomem void * init_vbus_channel(U64 channelAddr, U32 channelBytes, int isServer) { - void *rc = NULL; + void __iomem *rc = NULL; void __iomem *pChan = uislib_ioremap_cache(channelAddr, channelBytes); if (!pChan) { LOGERR("CONTROLVM_BUS_CREATE error: ioremap_cache of channelAddr:%Lx for channelBytes:%llu failed", diff --git a/drivers/staging/unisys/visorchannel/visorchannel.h b/drivers/staging/unisys/visorchannel/visorchannel.h index a00dfb55c8d2..784f03a2ef6d 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel.h +++ b/drivers/staging/unisys/visorchannel/visorchannel.h @@ -73,11 +73,11 @@ void visorchannel_debug(VISORCHANNEL *channel, int nQueues, struct seq_file *seq, U32 off); void visorchannel_dump_section(VISORCHANNEL *chan, char *s, int off, int len, struct seq_file *seq); -void *visorchannel_get_header(VISORCHANNEL *channel); +void __iomem *visorchannel_get_header(VISORCHANNEL *channel); #define VISORCHANNEL_CHANGE_SERVER_STATE(chan, chanId, newstate) \ do { \ - U8 *p = (U8 *)visorchannel_get_header(chan); \ + U8 *p = (U8 __iomem *)visorchannel_get_header(chan); \ if (p) { \ ULTRA_CHANNEL_SERVER_TRANSITION(p, chanId, SrvState, \ newstate, logCtx); \ @@ -92,7 +92,7 @@ void *visorchannel_get_header(VISORCHANNEL *channel); #define VISORCHANNEL_CHANGE_CLIENT_STATE(chan, chanId, newstate) \ do { \ - U8 *p = (U8 *)visorchannel_get_header(chan); \ + U8 *p = (U8 __iomem *)visorchannel_get_header(chan); \ if (p) { \ ULTRA_CHANNEL_CLIENT_TRANSITION(p, chanId, \ newstate, logCtx); \ diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c index bc4fc671a0b9..a44da7c84ae3 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c +++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c @@ -279,10 +279,10 @@ Away: } EXPORT_SYMBOL_GPL(visorchannel_clear); -void * +void __iomem * visorchannel_get_header(VISORCHANNEL *channel) { - return (void *) &(channel->chan_hdr); + return (void __iomem *) &(channel->chan_hdr); } EXPORT_SYMBOL_GPL(visorchannel_get_header); diff --git a/drivers/staging/unisys/visorutil/memregion.h b/drivers/staging/unisys/visorutil/memregion.h index 796631652b77..f4a65d2fcf02 100644 --- a/drivers/staging/unisys/visorutil/memregion.h +++ b/drivers/staging/unisys/visorutil/memregion.h @@ -38,6 +38,6 @@ HOSTADDRESS visor_memregion_get_physaddr(MEMREGION *memregion); ulong visor_memregion_get_nbytes(MEMREGION *memregion); void memregion_dump(MEMREGION *memregion, char *s, ulong off, ulong len, struct seq_file *seq); -void *visor_memregion_get_pointer(MEMREGION *memregion); +void __iomem *visor_memregion_get_pointer(MEMREGION *memregion); #endif diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c index d39fde9c1a60..28dfba0490f2 100644 --- a/drivers/staging/unisys/visorutil/memregion_direct.c +++ b/drivers/staging/unisys/visorutil/memregion_direct.c @@ -29,7 +29,7 @@ struct MEMREGION_Tag { HOSTADDRESS physaddr; ulong nbytes; - void *mapped; + void __iomem *mapped; BOOL requested; BOOL overlapped; }; @@ -93,7 +93,7 @@ visor_memregion_create_overlapped(MEMREGION *parent, ulong offset, ulong nbytes) memregion->physaddr = parent->physaddr + offset; memregion->nbytes = nbytes; - memregion->mapped = ((u8 *) (parent->mapped)) + offset; + memregion->mapped = ((u8 __iomem *) (parent->mapped)) + offset; memregion->requested = FALSE; memregion->overlapped = TRUE; return memregion; @@ -149,7 +149,7 @@ visor_memregion_get_nbytes(MEMREGION *memregion) } EXPORT_SYMBOL_GPL(visor_memregion_get_nbytes); -void * +void __iomem * visor_memregion_get_pointer(MEMREGION *memregion) { return memregion->mapped; -- cgit v1.2.3 From 385914c39df504d9497f82c3b7189f9e57fdb2c5 Mon Sep 17 00:00:00 2001 From: Ken Cox Date: Thu, 22 May 2014 12:31:11 -0500 Subject: Staging: unisys: virthba: declare virthba_queue_command as static virthba_queue_command() is only used inside virthba.c so declare it static. Signed-off-by: Ken Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/virthba/virthba.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c index d528388d596f..5c5aa7001767 100644 --- a/drivers/staging/unisys/virthba/virthba.c +++ b/drivers/staging/unisys/virthba/virthba.c @@ -91,7 +91,7 @@ static const struct x86_cpu_id unisys_spar_ids[] = { MODULE_DEVICE_TABLE(x86cpu, unisys_spar_ids); #ifdef DEF_SCSI_QCMD -DEF_SCSI_QCMD(virthba_queue_command) +static DEF_SCSI_QCMD(virthba_queue_command) #else #define virthba_queue_command virthba_queue_command_lck #endif -- cgit v1.2.3 From 60e1741fc30719171c81030b6f50f6838fc5fd30 Mon Sep 17 00:00:00 2001 From: Ken Cox Date: Thu, 22 May 2014 12:31:12 -0500 Subject: Staging: unisys: Remove unused macros from visorchannel/visorchannel.h VISORCHANNEL_CHANGE_SERVER_STATE and VISORCHANNEL_CHANGE_CLIENT_STATE are never used in any of the source so they have been removed. VISORCHANNEL_CHANGE_CLIENT_STATE would have caused a broken kernel build after commit a8d7f21d, but since it was never used the kernel continued to build. Reported-by: Dan Carpenter Signed-off-by: Ken Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchannel/visorchannel.h | 30 ---------------------- 1 file changed, 30 deletions(-) diff --git a/drivers/staging/unisys/visorchannel/visorchannel.h b/drivers/staging/unisys/visorchannel/visorchannel.h index 784f03a2ef6d..ecf0d11117e9 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel.h +++ b/drivers/staging/unisys/visorchannel/visorchannel.h @@ -75,34 +75,4 @@ void visorchannel_dump_section(VISORCHANNEL *chan, char *s, int off, int len, struct seq_file *seq); void __iomem *visorchannel_get_header(VISORCHANNEL *channel); -#define VISORCHANNEL_CHANGE_SERVER_STATE(chan, chanId, newstate) \ - do { \ - U8 *p = (U8 __iomem *)visorchannel_get_header(chan); \ - if (p) { \ - ULTRA_CHANNEL_SERVER_TRANSITION(p, chanId, SrvState, \ - newstate, logCtx); \ - visorchannel_write \ - (chan, \ - offsetof(ULTRA_CHANNEL_PROTOCOL, SrvState), \ - p + \ - offsetof(ULTRA_CHANNEL_PROTOCOL, SrvState), \ - sizeof(U32)); \ - } \ - } while (0) - -#define VISORCHANNEL_CHANGE_CLIENT_STATE(chan, chanId, newstate) \ - do { \ - U8 *p = (U8 __iomem *)visorchannel_get_header(chan); \ - if (p) { \ - ULTRA_CHANNEL_CLIENT_TRANSITION(p, chanId, \ - newstate, logCtx); \ - visorchannel_write \ - (chan, \ - offsetof(ULTRA_CHANNEL_PROTOCOL, CliStateOS), \ - p + \ - offsetof(ULTRA_CHANNEL_PROTOCOL, CliStateOS), \ - sizeof(U32)); \ - } \ - } while (0) - #endif -- cgit v1.2.3 From e40d1c8ad91420a2224f557e5b4c43c5c4148847 Mon Sep 17 00:00:00 2001 From: Ken Cox Date: Thu, 22 May 2014 12:31:13 -0500 Subject: Staging: unisys: Fixup sparse warnings for dereferencing noderef types. Fixed the usage of the following so they don't try to dereference pointers to iomem. CHANNEL_U64_MISMATCH CHANNEL_U32_MISMATCH wait_for_valid_guid Signed-off-by: Ken Cox Signed-off-by: Greg Kroah-Hartman --- .../unisys/common-spar/include/channels/channel.h | 16 ++++++++------- drivers/staging/unisys/include/uisutils.h | 23 ++++++++++++++-------- drivers/staging/unisys/uislib/uislib.c | 4 ++-- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/common-spar/include/channels/channel.h index 237a852c2fc0..d19711de1140 100644 --- a/drivers/staging/unisys/common-spar/include/channels/channel.h +++ b/drivers/staging/unisys/common-spar/include/channels/channel.h @@ -333,8 +333,9 @@ ULTRA_check_channel_client(void __iomem *pChannel, (pChannel))->Size) < expectedMinBytes) { CHANNEL_U64_MISMATCH(expectedTypeGuid, channelName, "size", expectedMinBytes, - ((CHANNEL_HEADER __iomem *) - (pChannel))->Size, fileName, + readq(&((CHANNEL_HEADER __iomem *) + (pChannel))->Size), + fileName, lineNumber, logCtx); return 0; } @@ -344,9 +345,9 @@ ULTRA_check_channel_client(void __iomem *pChannel, != expectedVersionId) { CHANNEL_U32_MISMATCH(expectedTypeGuid, channelName, "version", expectedVersionId, - ((CHANNEL_HEADER __iomem *) - (pChannel))->VersionId, fileName, - lineNumber, logCtx); + readl(&((CHANNEL_HEADER __iomem *) + (pChannel))->VersionId), + fileName, lineNumber, logCtx); return 0; } if (expectedSignature > 0) /* caller wants us to verify @@ -355,8 +356,9 @@ ULTRA_check_channel_client(void __iomem *pChannel, != expectedSignature) { CHANNEL_U64_MISMATCH(expectedTypeGuid, channelName, "signature", expectedSignature, - ((CHANNEL_HEADER __iomem *) - (pChannel))->Signature, fileName, + readq(&((CHANNEL_HEADER __iomem *) + (pChannel))->Signature), + fileName, lineNumber, logCtx); return 0; } diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h index f4845f2ffa06..70776c93cc50 100644 --- a/drivers/staging/unisys/include/uisutils.h +++ b/drivers/staging/unisys/include/uisutils.h @@ -194,14 +194,21 @@ struct chaninfo { * correctly at DEVICE_CREATE time, INSTEAD OF waiting until * DEVICE_CONFIGURE time. */ -#define WAIT_FOR_VALID_GUID(guid) \ - do { \ - while (uuid_le_cmp(guid, NULL_UUID_LE) == 0) { \ - LOGERR("Waiting for non-0 GUID (why???)...\n"); \ - UIS_THREAD_WAIT_SEC(5); \ - } \ - LOGERR("OK... GUID is non-0 now\n"); \ - } while (0) +static inline void +wait_for_valid_guid(uuid_le __iomem *guid) +{ + uuid_le tmpguid; + + while (1) { + memcpy_fromio((void *)&tmpguid, + (void __iomem *)guid, sizeof(uuid_le)); + if (uuid_le_cmp(tmpguid, NULL_UUID_LE) != 0) + break; + LOGERR("Waiting for non-0 GUID (why???)...\n"); + UIS_THREAD_WAIT_SEC(5); + } + LOGERR("OK... GUID is non-0 now\n"); +} /* CopyFragsInfoFromSkb returns the number of entries added to frags array * Returns -1 on failure. diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index e3903ee72443..d4a7ef821bae 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -447,7 +447,7 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) struct guest_msgs cmd; if (!uuid_le_cmp(dev->channelTypeGuid, UltraVhbaChannelProtocolGuid)) { - WAIT_FOR_VALID_GUID(((CHANNEL_HEADER + wait_for_valid_guid(&((CHANNEL_HEADER __iomem *) (dev-> chanptr))-> Type); @@ -472,7 +472,7 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) } else if (!uuid_le_cmp(dev->channelTypeGuid, UltraVnicChannelProtocolGuid)) { - WAIT_FOR_VALID_GUID(((CHANNEL_HEADER + wait_for_valid_guid(&((CHANNEL_HEADER __iomem *) (dev-> chanptr))-> Type); -- cgit v1.2.3 From 2079c4aaf658d66c71d44297d0c0368264981b4e Mon Sep 17 00:00:00 2001 From: Ken Cox Date: Thu, 22 May 2014 12:31:14 -0500 Subject: Staging: unisys: visorchipset: Remove filexfer.c There is not any code using the functionality in filexfer.c so I removed it and filexfer.h. Signed-off-by: Ken Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorchipset/Makefile | 2 +- drivers/staging/unisys/visorchipset/filexfer.c | 506 --------------------- drivers/staging/unisys/visorchipset/filexfer.h | 147 ------ .../unisys/visorchipset/visorchipset_main.c | 8 - 4 files changed, 1 insertion(+), 662 deletions(-) delete mode 100644 drivers/staging/unisys/visorchipset/filexfer.c delete mode 100644 drivers/staging/unisys/visorchipset/filexfer.h diff --git a/drivers/staging/unisys/visorchipset/Makefile b/drivers/staging/unisys/visorchipset/Makefile index f5e8650e1b0e..ead4b9c02715 100644 --- a/drivers/staging/unisys/visorchipset/Makefile +++ b/drivers/staging/unisys/visorchipset/Makefile @@ -4,7 +4,7 @@ obj-$(CONFIG_UNISYS_VISORCHIPSET) += visorchipset.o -visorchipset-y := visorchipset_main.o controlvm_direct.o file.o filexfer.o \ +visorchipset-y := visorchipset_main.o controlvm_direct.o file.o \ parser.o ccflags-y += -Idrivers/staging/unisys/include diff --git a/drivers/staging/unisys/visorchipset/filexfer.c b/drivers/staging/unisys/visorchipset/filexfer.c deleted file mode 100644 index f950d6e85b5f..000000000000 --- a/drivers/staging/unisys/visorchipset/filexfer.c +++ /dev/null @@ -1,506 +0,0 @@ -/* filexfer.c - * - * Copyright © 2013 - 2013 UNISYS CORPORATION - * All rights reserved. - * - * 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, GOOD TITLE or - * NON INFRINGEMENT. See the GNU General Public License for more - * details. - */ - -/* Code here-in is the "glue" that connects controlvm messages with the - * sparfilexfer driver, which is used to transfer file contents as payload - * across the controlvm channel. - */ - -#include "globals.h" -#include "controlvm.h" -#include "visorchipset.h" -#include "filexfer.h" - -#ifdef ENABLE_SPARFILEXFER /* sparfilexfer kernel module enabled in build */ -#include "sparfilexfer.h" - -/* Driver-global memory */ -static LIST_HEAD(Request_list); /* list of struct any_request *, via - * req_list memb */ - -/* lock for above pool for allocation of any_request structs, and pool -* name; note that kmem_cache_create requires that we keep the storage -* for the pool name for the life of the pool - */ -static DEFINE_SPINLOCK(Request_list_lock); - -static struct kmem_cache *Request_memory_pool; -static const char Request_memory_pool_name[] = "filexfer_request_pool"; -size_t Caller_req_context_bytes = 0; /* passed to filexfer_constructor() */ - -/* This structure defines a single controlvm GETFILE conversation, which - * consists of a single controlvm request message and 1 or more controlvm - * response messages. - */ -struct getfile_request { - CONTROLVM_MESSAGE_HEADER controlvm_header; - atomic_t buffers_in_use; - GET_CONTIGUOUS_CONTROLVM_PAYLOAD_FUNC get_contiguous_controlvm_payload; - CONTROLVM_RESPOND_WITH_PAYLOAD_FUNC controlvm_respond_with_payload; -}; - -/* This structure defines a single controlvm PUTFILE conversation, which - * consists of a single controlvm request with a filename, and additional - * controlvm messages with file data. - */ -struct putfile_request { - GET_CONTROLVM_FILEDATA_FUNC get_controlvm_filedata; - CONTROLVM_RESPOND_FUNC controlvm_end_putFile; -}; - -/* This structure defines a single file transfer operation, which can either - * be a GETFILE or PUTFILE. - */ -struct any_request { - struct list_head req_list; - ulong2 file_request_number; - ulong2 data_sequence_number; - TRANSMITFILE_DUMP_FUNC dump_func; - BOOL is_get; - union { - struct getfile_request get; - struct putfile_request put; - }; - /* Size of caller_context_data will be - * bytes. I aligned this because I - * am paranoid about what happens when an arbitrary data - * structure with unknown alignment requirements gets copied - * here. I want caller_context_data to be aligned to the - * coarsest possible alignment boundary that could be required - * for any user data structure. - */ - u8 caller_context_data[1] __aligned(sizeof(ulong2)); -}; - -/* - * Links the any_request into the global list of allocated requests - * (). - */ -static void -unit_tracking_create(struct list_head *dev_list_link) -{ - unsigned long flags; - spin_lock_irqsave(&Request_list_lock, flags); - list_add(dev_list_link, &Request_list); - spin_unlock_irqrestore(&Request_list_lock, flags); -} - -/* Unlinks a any_request from the global list (). - */ -static void -unit_tracking_destroy(struct list_head *dev_list_link) -{ - unsigned long flags; - spin_lock_irqsave(&Request_list_lock, flags); - list_del(dev_list_link); - spin_unlock_irqrestore(&Request_list_lock, flags); -} - -/* Allocate memory for and return a new any_request struct, and - * link it to the global list of outstanding requests. - */ -static struct any_request * -alloc_request(char *fn, int ln) -{ - struct any_request *req = (struct any_request *) - (visorchipset_cache_alloc(Request_memory_pool, - FALSE, - fn, ln)); - if (!req) - return NULL; - memset(req, 0, sizeof(struct any_request) + Caller_req_context_bytes); - unit_tracking_create(&req->req_list); - return req; -} - -/* Book-end for alloc_request(). - */ -static void -free_request(struct any_request *req, char *fn, int ln) -{ - unit_tracking_destroy(&req->req_list); - visorchipset_cache_free(Request_memory_pool, req, fn, ln); -} - -/* Constructor for filexfer.o. - */ -int -filexfer_constructor(size_t req_context_bytes) -{ - int rc = -1; - - Caller_req_context_bytes = req_context_bytes; - Request_memory_pool = - kmem_cache_create(Request_memory_pool_name, - sizeof(struct any_request) + - Caller_req_context_bytes, - 0, SLAB_HWCACHE_ALIGN, NULL); - if (!Request_memory_pool) { - LOGERR("failed to alloc Request_memory_pool"); - rc = -ENOMEM; - goto Away; - } - rc = 0; -Away: - if (rc < 0) { - if (Request_memory_pool) { - kmem_cache_destroy(Request_memory_pool); - Request_memory_pool = NULL; - } - } - return rc; -} - -/* Destructor for filexfer.o. - */ -void -filexfer_destructor(void) -{ - if (Request_memory_pool) { - kmem_cache_destroy(Request_memory_pool); - Request_memory_pool = NULL; - } -} - -/* This function will obtain an available chunk from the controlvm payload area, - * store the size in bytes of the chunk in , and return a pointer - * to the chunk. The function is passed to the sparfilexfer driver, which calls - * it whenever payload space is required to copy file data into. - */ -static void * -get_empty_bucket_for_getfile_data(void *context, - ulong min_size, ulong max_size, - ulong *actual_size) -{ - void *bucket; - struct any_request *req = (struct any_request *) context; - - if (!req->is_get) { - LOGERR("%s - unexpected call", __func__); - return NULL; - } - bucket = (*req->get.get_contiguous_controlvm_payload) - (min_size, max_size, actual_size); - if (bucket != NULL) { - atomic_inc(&req->get.buffers_in_use); - DBGINF("%s - sent %lu-byte buffer", __func__, *actual_size); - } - return bucket; -} - -/* This function will send a controlvm response with data in the payload - * (whose space was obtained with get_empty_bucket_for_getfile_data). The - * function is passed to the sparfilexfer driver, which calls it whenever it - * wants to send file data back across the controlvm channel. - */ -static int -send_full_getfile_data_bucket(void *context, void *bucket, - ulong bucket_actual_size, ulong bucket_used_size) -{ - struct any_request *req = (struct any_request *) context; - - if (!req->is_get) { - LOGERR("%s - unexpected call", __func__); - return 0; - } - DBGINF("sending buffer for %lu/%lu", - bucket_used_size, bucket_actual_size); - if (!(*req->get.controlvm_respond_with_payload) - (&req->get.controlvm_header, - req->file_request_number, - req->data_sequence_number++, - 0, bucket, bucket_actual_size, bucket_used_size, TRUE)) - atomic_dec(&req->get.buffers_in_use); - return 0; -} - -/* This function will send a controlvm response indicating the end of a - * GETFILE transfer. The function is passed to the sparfilexfer driver. - */ -static void -send_end_of_getfile_data(void *context, int status) -{ - struct any_request *req = (struct any_request *) context; - if (!req->is_get) { - LOGERR("%s - unexpected call", __func__); - return; - } - LOGINF("status=%d", status); - (*req->get.controlvm_respond_with_payload) - (&req->get.controlvm_header, - req->file_request_number, - req->data_sequence_number++, status, NULL, 0, 0, FALSE); - free_request(req, __FILE__, __LINE__); - module_put(THIS_MODULE); -} - -/* This function supplies data for a PUTFILE transfer. - * The function is passed to the sparfilexfer driver. - */ -static int -get_putfile_data(void *context, void *pbuf, size_t bufsize, - BOOL buf_is_userspace, size_t *bytes_transferred) -{ - struct any_request *req = (struct any_request *) context; - if (req->is_get) { - LOGERR("%s - unexpected call", __func__); - return -1; - } - return (*req->put.get_controlvm_filedata) (&req->caller_context_data[0], - pbuf, bufsize, - buf_is_userspace, - bytes_transferred); -} - -/* This function is called to indicate the end of a PUTFILE transfer. - * The function is passed to the sparfilexfer driver. - */ -static void -end_putfile(void *context, int status) -{ - struct any_request *req = (struct any_request *) context; - if (req->is_get) { - LOGERR("%s - unexpected call", __func__); - return; - } - (*req->put.controlvm_end_putFile) (&req->caller_context_data[0], - status); - free_request(req, __FILE__, __LINE__); - module_put(THIS_MODULE); -} - -/* Refer to filexfer.h for description. */ -BOOL -filexfer_getFile(CONTROLVM_MESSAGE_HEADER *msgHdr, - ulong2 file_request_number, - uint uplink_index, - uint disk_index, - char *file_name, - GET_CONTIGUOUS_CONTROLVM_PAYLOAD_FUNC - get_contiguous_controlvm_payload, - CONTROLVM_RESPOND_WITH_PAYLOAD_FUNC - controlvm_respond_with_payload, - TRANSMITFILE_DUMP_FUNC dump_func) -{ - BOOL use_count_up = FALSE; - BOOL failed = TRUE; - struct any_request *req = alloc_request(__FILE__, __LINE__); - - if (!req) { - LOGERR("allocation of any_request failed"); - goto Away; - } - /* We need to increment this module's use count because we're handing - * off pointers to functions within this module to be used by - * another module. - */ - __module_get(THIS_MODULE); - use_count_up = TRUE; - req->is_get = TRUE; - req->file_request_number = file_request_number; - req->data_sequence_number = 0; - req->dump_func = dump_func; - req->get.controlvm_header = *msgHdr; - atomic_set(&req->get.buffers_in_use, 0); - req->get.get_contiguous_controlvm_payload = - get_contiguous_controlvm_payload; - req->get.controlvm_respond_with_payload = - controlvm_respond_with_payload; - if (sparfilexfer_local2remote(req, /* context, passed to - * callback funcs */ - file_name, - file_request_number, - uplink_index, - disk_index, - get_empty_bucket_for_getfile_data, - send_full_getfile_data_bucket, - send_end_of_getfile_data) < 0) { - LOGERR("sparfilexfer_local2remote failed"); - goto Away; - } - failed = FALSE; -Away: - if (failed) { - if (use_count_up) { - module_put(THIS_MODULE); - use_count_up = FALSE; - } - if (req) { - free_request(req, __FILE__, __LINE__); - req = NULL; - } - return FALSE; - } else { - return TRUE; - /* success; send callbacks will be called for responses */ - } -} - -/* Refer to filexfer.h for description. */ -void * -filexfer_putFile(CONTROLVM_MESSAGE_HEADER *msgHdr, - ulong2 file_request_number, - uint uplink_index, - uint disk_index, - char *file_name, - TRANSMITFILE_INIT_CONTEXT_FUNC init_context, - GET_CONTROLVM_FILEDATA_FUNC get_controlvm_filedata, - CONTROLVM_RESPOND_FUNC controlvm_end_putFile, - TRANSMITFILE_DUMP_FUNC dump_func) -{ - BOOL use_count_up = FALSE; - BOOL failed = TRUE; - struct any_request *req = alloc_request(__FILE__, __LINE__); - void *caller_ctx = NULL; - - if (!req) { - LOGERR("allocation of any_request failed"); - goto Away; - } - caller_ctx = (void *) (&(req->caller_context_data[0])); - /* We need to increment this module's use count because we're handing - * off pointers to functions within this module to be used by - * another module. - */ - __module_get(THIS_MODULE); - use_count_up = TRUE; - req->is_get = FALSE; - req->file_request_number = file_request_number; - req->data_sequence_number = 0; - req->dump_func = dump_func; - req->put.get_controlvm_filedata = get_controlvm_filedata; - req->put.controlvm_end_putFile = controlvm_end_putFile; - (*init_context) (caller_ctx, msgHdr, file_request_number); - if (sparfilexfer_remote2local(req, /* context, passed to - * callback funcs */ - file_name, - file_request_number, - uplink_index, - disk_index, - get_putfile_data, end_putfile) < 0) { - LOGERR("sparfilexfer_remote2local failed"); - goto Away; - } - failed = FALSE; -Away: - if (failed) { - if (use_count_up) { - module_put(THIS_MODULE); - use_count_up = FALSE; - } - if (req) { - free_request(req, __FILE__, __LINE__); - req = NULL; - } - return NULL; - } else { - return caller_ctx; - /* success; callbacks will be called for responses */ - } -} - -static void -dump_get_request(struct seq_file *f, struct getfile_request *getreq) -{ - seq_printf(f, " buffers_in_use=%d\n", - atomic_read(&getreq->buffers_in_use)); -} - -static void -dump_put_request(struct seq_file *f, struct putfile_request *putreq) -{ -} - -static void -dump_request(struct seq_file *f, struct any_request *req) -{ - seq_printf(f, "* %s id=%llu seq=%llu\n", - ((req->is_get) ? "Get" : "Put"), - req->file_request_number, req->data_sequence_number); - if (req->is_get) - dump_get_request(f, &req->get); - else - dump_put_request(f, &req->put); - if (req->dump_func) - (*req->dump_func) (f, &(req->caller_context_data[0]), " "); -} - -void -filexfer_dump(struct seq_file *f) -{ - ulong flags; - struct list_head *entry; - - seq_puts(f, "Outstanding TRANSMIT_FILE requests:\n"); - spin_lock_irqsave(&Request_list_lock, flags); - list_for_each(entry, &Request_list) { - struct any_request *req; - req = list_entry(entry, struct any_request, req_list); - dump_request(f, req); - } - spin_unlock_irqrestore(&Request_list_lock, flags); -} - -#else /* ifdef ENABLE_SPARFILEXFER */ -int -filexfer_constructor(size_t req_context_bytes) -{ - return 0; /* success */ -} - -void -filexfer_destructor(void) -{ -} - -BOOL -filexfer_getFile(CONTROLVM_MESSAGE_HEADER *msgHdr, - u64 file_request_number, - uint uplink_index, - uint disk_index, - char *file_name, - GET_CONTIGUOUS_CONTROLVM_PAYLOAD_FUNC - get_contiguous_controlvm_payload, - CONTROLVM_RESPOND_WITH_PAYLOAD_FUNC - controlvm_respond_with_payload, - TRANSMITFILE_DUMP_FUNC dump_func) -{ - /* since no sparfilexfer module exists to call, we just fail */ - return FALSE; -} - -void * -filexfer_putFile(CONTROLVM_MESSAGE_HEADER *msgHdr, - u64 file_request_number, - uint uplink_index, - uint disk_index, - char *file_name, - TRANSMITFILE_INIT_CONTEXT_FUNC init_context, - GET_CONTROLVM_FILEDATA_FUNC get_controlvm_filedata, - CONTROLVM_RESPOND_FUNC controlvm_end_putFile, - TRANSMITFILE_DUMP_FUNC dump_func) -{ - /* since no sparfilexfer module exists to call, we just fail */ - return NULL; -} - -void -filexfer_dump(struct seq_file *f) -{ -} - -#endif /* ifdef ENABLE_SPARFILEXFER */ diff --git a/drivers/staging/unisys/visorchipset/filexfer.h b/drivers/staging/unisys/visorchipset/filexfer.h deleted file mode 100644 index a1bfca69cdcf..000000000000 --- a/drivers/staging/unisys/visorchipset/filexfer.h +++ /dev/null @@ -1,147 +0,0 @@ -/* filexfer.h - * - * Copyright © 2013 - 2013 UNISYS CORPORATION - * All rights reserved. - * - * 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, GOOD TITLE or - * NON INFRINGEMENT. See the GNU General Public License for more - * details. - */ - -/* This header file defines the interface that filexfer.c provides to other - * code in the visorchipset driver. - */ - -#ifndef __FILEXFER_H__ -#define __FILEXFER_H__ - -#include "globals.h" -#include "controlvmchannel.h" -#include - -typedef void *(*GET_CONTIGUOUS_CONTROLVM_PAYLOAD_FUNC) (ulong min_size, - ulong max_size, - ulong *actual_size); - -typedef BOOL -(*CONTROLVM_RESPOND_WITH_PAYLOAD_FUNC) (CONTROLVM_MESSAGE_HEADER *msgHdr, - u64 fileRequestNumber, - u64 dataSequenceNumber, - int response, - void *bucket, ulong payloadChunkSize, - ulong payloadUsedBytes, BOOL partial); - -typedef void -(*TRANSMITFILE_INIT_CONTEXT_FUNC)(void *ctx, - const CONTROLVM_MESSAGE_HEADER *hdr, - u64 file_request_number); -typedef void (*TRANSMITFILE_DUMP_FUNC) (struct seq_file *f, void *ctx, - const char *pfx); -typedef int (*GET_CONTROLVM_FILEDATA_FUNC) (void *ctx, - void *buf, size_t bufsize, - BOOL buf_is_userspace, - size_t *bytes_transferred); -typedef void (*CONTROLVM_RESPOND_FUNC) (void *ctx, int response); - -/* Call once to initialize filexfer.o. - * req_context_bytes number of bytes the caller needs to keep track of each file - * transfer conversation. The passed to filexfer_putFile() is - * assumed to be this many bytes in size. Code within filexfer.o will copy this - * into a dynamically-allocated area, and pass back a pointer to that area in - * callback functions. - */ -int filexfer_constructor(size_t req_context_bytes); - -/* Call once to clean up filexfer.o */ -void filexfer_destructor(void); - -/* Call this to dump diagnostic info about all outstanding getFiles/putFiles */ -void filexfer_dump(struct seq_file *f); - -/* Call to transfer a file from the local filesystem (i.e., from the environment - * where this driver is running) across the controlvm channel to a remote - * environment. 1 or more controlvm responses will be sent as a result, each - * of which whose payload contains file data. Only the last controlvm message - * will have Flags.partialCompletion==0. - * - * msgHdr the controlvm message header of the GETFILE request which - * we just received - * file_request_number this is all data from the GETFILE request that - * uplink_index define which file is to be transferred - * disk_index - * file_name - * get_contiguous_controlvm_payload function to call when space is needed - * in the payload area - * controlvm_respond_with_payload function to call to send each controlvm - * response containing file data as the - * payload; returns FALSE only if the - * payload buffer was freed inline - * dump_func function to dump context data in - * human-readable format - * - * Returns TRUE iff the file transfer request has been successfully initiated, - * or FALSE to indicate failure. - */ -BOOL -filexfer_getFile(CONTROLVM_MESSAGE_HEADER *msgHdr, - u64 file_request_number, - uint uplink_index, - uint disk_index, - char *file_name, - GET_CONTIGUOUS_CONTROLVM_PAYLOAD_FUNC - get_contiguous_controlvm_payload, - CONTROLVM_RESPOND_WITH_PAYLOAD_FUNC - controlvm_respond_with_payload, - TRANSMITFILE_DUMP_FUNC dump_func); - -/* Call to create a file in the local filesystem (i.e., in the environment - * where this driver is running) from data received as payload in - * controlvm channel messages from a remote environment. 1 or more controlvm - * messages will be received for this transfer, and only the last will have - * Flags.partialCompletion==0. - * - * msgHdr the controlvm message header of the PUTFILE request which - * we just received - * file_request_number this is all data from the PUTFILE request that - * uplink_index define which file is to be created in the local - * disk_index filesystem - * file_name - * init_context function to call to initialize the - * -sized storage area returned by - * this func; note that it would NOT be sufficient to - * allow the caller to initialize this upon return, as - * the the other user-supplied callbacks might have - * already been called by then - * get_controlvm_filedata function to call to obtain more data for the file - * being written; refer to get_controlvm_filedata() - * in visorchipset_main.c for a complete description - * of parameters - * controlvm_end_putFile function to call to indicate that creation of the - * local file has completed; set to a - * negative value to indicate an error - * dump_func function to dump context data in human-readable - * format - * - * Returns a pointer to a dynamically-allocated storage area of size - * which the caller can use, or NULL for error. The - * caller should NEVER free the returned pointer, but should expect to receive - * it as the argument when callback functions are called. - */ -void *filexfer_putFile(CONTROLVM_MESSAGE_HEADER *msgHdr, - u64 file_request_number, - uint uplink_index, - uint disk_index, - char *file_name, - TRANSMITFILE_INIT_CONTEXT_FUNC init_context, - GET_CONTROLVM_FILEDATA_FUNC get_controlvm_filedata, - CONTROLVM_RESPOND_FUNC controlvm_end_putFile, - TRANSMITFILE_DUMP_FUNC dump_func); - -#endif diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index 02874e69c4fc..0a602b9c130b 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -28,7 +28,6 @@ #include "uisutils.h" #include "controlvmcompletionstatus.h" #include "guestlinuxdebug.h" -#include "filexfer.h" #include #include @@ -2773,12 +2772,6 @@ visorchipset_init(void) ProcDir, ¶hotplug_proc_fops); memset(&g_DelDumpMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER)); - if (filexfer_constructor(sizeof(struct putfile_request)) < 0) { - ERRDRV("filexfer_constructor failed: (status=-1)\n"); - POSTCODE_LINUX_2(CHIPSET_INIT_FAILURE_PC, DIAG_SEVERITY_ERR); - rc = -1; - goto Away; - } Putfile_buffer_list_pool = kmem_cache_create(Putfile_buffer_list_pool_name, sizeof(struct putfile_buffer_entry), @@ -2862,7 +2855,6 @@ visorchipset_exit(void) kmem_cache_destroy(Putfile_buffer_list_pool); Putfile_buffer_list_pool = NULL; } - filexfer_destructor(); if (ControlVmObject) { visor_proc_DestroyObject(ControlVmObject); ControlVmObject = NULL; -- cgit v1.2.3 From 7ca83759a6e3a870711324e0bffd77d02c5d5628 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 17 Apr 2014 10:35:22 -0500 Subject: staging: r8188eu: Fix some sparse warnings In a patch entitles "staging: r8188eu: Fix case where ethtype was never obtained and always be checked against 0" (commit ID unknown), I introduce an endian error. This patch fixes that, and removes two additional sparse warnings. drivers/staging/rtl8188eu/core/rtw_recv.c:653:6: warning: symbol 'process_pwrbit_data' was not declared. Should it be static? drivers/staging/rtl8188eu/core/rtw_recv.c:1828:5: warning: symbol 'enqueue_reorder_recvframe' was not declared. Should it be static? Reported-by: Dan Carpenter Signed-off-by: Larry Finger Cc: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_recv.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index da26fa5cb259..723996eeb4ed 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -505,6 +505,7 @@ static struct recv_frame *portctrl(struct adapter *adapter, u16 ether_type; u16 eapol_type = 0x888e;/* for Funia BD's WPA issue */ struct rx_pkt_attrib *pattrib; + __be16 be_tmp; pstapriv = &adapter->stapriv; @@ -524,8 +525,8 @@ static struct recv_frame *portctrl(struct adapter *adapter, if (auth_alg == 2) { /* get ether_type */ ptr = ptr + pfhdr->attrib.hdrlen + LLC_HEADER_SIZE; - memcpy(ðer_type, ptr, 2); - ether_type = ntohs((unsigned short)ether_type); + memcpy(&be_tmp, ptr, 2); + ether_type = ntohs(be_tmp); if ((psta != NULL) && (psta->ieee8021x_blocked)) { /* blocked */ @@ -598,8 +599,8 @@ static int recv_decache(struct recv_frame *precv_frame, u8 bretry, return _SUCCESS; } -void process_pwrbit_data(struct adapter *padapter, - struct recv_frame *precv_frame) +static void process_pwrbit_data(struct adapter *padapter, + struct recv_frame *precv_frame) { #ifdef CONFIG_88EU_AP_MODE unsigned char pwrbit; @@ -1773,8 +1774,8 @@ static int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_n return true; } -int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, - struct recv_frame *prframe) +static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, + struct recv_frame *prframe) { struct rx_pkt_attrib *pattrib = &prframe->attrib; struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; -- cgit v1.2.3 From 599a2c02a784934b9bf0725920c1bc235b9b28ce Mon Sep 17 00:00:00 2001 From: Kim Nylund Date: Thu, 1 May 2014 10:24:09 -0500 Subject: staging: r8188eu: Add support for Dlink DWA-121 802.11n Wireless N 150 Pico Adapter This is a new device supported by this driver. Signed-off-by: Kim Nylund Signed-off-by: Larry Finger Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index c63e2634c800..e8ccb576b4b5 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -55,6 +55,7 @@ static struct usb_device_id rtw_usb_id_tbl[] = { /*=== Customer ID ===*/ /****** 8188EUS ********/ {USB_DEVICE(0x07b8, 0x8179)}, /* Abocom - Abocom */ + {USB_DEVICE(0x2001, 0x3308)}, /* DLink DWA-121 REV A1 */ {USB_DEVICE(0x2001, 0x330F)}, /* DLink DWA-125 REV D1 */ {USB_DEVICE(0x2001, 0x3310)}, /* Dlink DWA-123 REV D1 */ {} /* Terminating entry */ -- cgit v1.2.3 From db4d7173c173d2e3fe5344f95131e3280a678ffa Mon Sep 17 00:00:00 2001 From: Dominique van den Broeck Date: Sun, 4 May 2014 16:46:27 +0200 Subject: staging/rtl8192e: userspace ptr deref + incorrect declarations . userspace pointer dereference ; These issues have been fixed by a concurrent patch: . missing inclusions of needed header files (fixed by concurrent patch); . unrequired static function declaration (confusing another *.c file). Signed-off-by: Dominique van den Broeck Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_wx.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c index de7609716435..52870041fcb7 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c @@ -1131,11 +1131,18 @@ static int r8192_wx_set_PromiscuousMode(struct net_device *dev, struct r8192_priv *priv = rtllib_priv(dev); struct rtllib_device *ieee = priv->rtllib; - u32 *info_buf = (u32 *)(wrqu->data.pointer); + u32 info_buf[3]; - u32 oid = info_buf[0]; - u32 bPromiscuousOn = info_buf[1]; - u32 bFilterSourceStationFrame = info_buf[2]; + u32 oid; + u32 bPromiscuousOn; + u32 bFilterSourceStationFrame; + + if (copy_from_user(info_buf, wrqu->data.pointer, sizeof(info_buf))) + return -EFAULT; + + oid = info_buf[0]; + bPromiscuousOn = info_buf[1]; + bFilterSourceStationFrame = info_buf[2]; if (OID_RT_INTEL_PROMISCUOUS_MODE == oid) { ieee->IntelPromiscuousModeInfo.bPromiscuousOn = -- cgit v1.2.3 From d901aaa723a7ea4601b0984534dde70adc81a38c Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 24 Apr 2014 13:57:49 +0930 Subject: drivers/staging/speakup/: avoid world-writable sysfs files. In line with practice for module parameters, we're adding a build-time check that sysfs files aren't world-writable. Cc: Christopher Brannon Cc: Samuel Thibault Signed-off-by: Rusty Russell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/speakup/kobjects.c | 62 ++++++++++++++++---------------- drivers/staging/speakup/speakup_acntpc.c | 14 ++++---- drivers/staging/speakup/speakup_acntsa.c | 14 ++++---- drivers/staging/speakup/speakup_apollo.c | 16 ++++----- drivers/staging/speakup/speakup_audptr.c | 16 ++++----- drivers/staging/speakup/speakup_bns.c | 14 ++++---- drivers/staging/speakup/speakup_decext.c | 16 ++++----- drivers/staging/speakup/speakup_decpc.c | 16 ++++----- drivers/staging/speakup/speakup_dectlk.c | 16 ++++----- drivers/staging/speakup/speakup_dtlk.c | 20 +++++------ drivers/staging/speakup/speakup_dummy.c | 14 ++++---- drivers/staging/speakup/speakup_keypc.c | 10 +++--- drivers/staging/speakup/speakup_ltlk.c | 20 +++++------ drivers/staging/speakup/speakup_soft.c | 22 ++++++------ drivers/staging/speakup/speakup_spkout.c | 16 ++++----- drivers/staging/speakup/speakup_txprt.c | 14 ++++---- 16 files changed, 150 insertions(+), 150 deletions(-) diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c index 7495b890b6f0..2ef7f6f201a8 100644 --- a/drivers/staging/speakup/kobjects.c +++ b/drivers/staging/speakup/kobjects.c @@ -851,75 +851,75 @@ static ssize_t message_store(struct kobject *kobj, struct kobj_attribute *attr, * Declare the attributes. */ static struct kobj_attribute keymap_attribute = - __ATTR(keymap, S_IWUSR|S_IRUGO, keymap_show, keymap_store); + __ATTR_RW(keymap); static struct kobj_attribute silent_attribute = - __ATTR(silent, S_IWUGO, NULL, silent_store); + __ATTR_WO(silent); static struct kobj_attribute synth_attribute = - __ATTR(synth, S_IWUGO|S_IRUGO, synth_show, synth_store); + __ATTR_RW(synth); static struct kobj_attribute synth_direct_attribute = - __ATTR(synth_direct, S_IWUGO, NULL, synth_direct_store); + __ATTR_WO(synth_direct); static struct kobj_attribute version_attribute = __ATTR_RO(version); static struct kobj_attribute delimiters_attribute = - __ATTR(delimiters, S_IWUGO|S_IRUGO, punc_show, punc_store); + __ATTR(delimiters, S_IWUSR|S_IRUGO, punc_show, punc_store); static struct kobj_attribute ex_num_attribute = - __ATTR(ex_num, S_IWUGO|S_IRUGO, punc_show, punc_store); + __ATTR(ex_num, S_IWUSR|S_IRUGO, punc_show, punc_store); static struct kobj_attribute punc_all_attribute = - __ATTR(punc_all, S_IWUGO|S_IRUGO, punc_show, punc_store); + __ATTR(punc_all, S_IWUSR|S_IRUGO, punc_show, punc_store); static struct kobj_attribute punc_most_attribute = - __ATTR(punc_most, S_IWUGO|S_IRUGO, punc_show, punc_store); + __ATTR(punc_most, S_IWUSR|S_IRUGO, punc_show, punc_store); static struct kobj_attribute punc_some_attribute = - __ATTR(punc_some, S_IWUGO|S_IRUGO, punc_show, punc_store); + __ATTR(punc_some, S_IWUSR|S_IRUGO, punc_show, punc_store); static struct kobj_attribute repeats_attribute = - __ATTR(repeats, S_IWUGO|S_IRUGO, punc_show, punc_store); + __ATTR(repeats, S_IWUSR|S_IRUGO, punc_show, punc_store); static struct kobj_attribute attrib_bleep_attribute = - __ATTR(attrib_bleep, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(attrib_bleep, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute bell_pos_attribute = - __ATTR(bell_pos, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(bell_pos, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute bleep_time_attribute = - __ATTR(bleep_time, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(bleep_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute bleeps_attribute = - __ATTR(bleeps, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(bleeps, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute cursor_time_attribute = - __ATTR(cursor_time, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(cursor_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute key_echo_attribute = - __ATTR(key_echo, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(key_echo, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute no_interrupt_attribute = - __ATTR(no_interrupt, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(no_interrupt, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute punc_level_attribute = - __ATTR(punc_level, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(punc_level, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute reading_punc_attribute = - __ATTR(reading_punc, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(reading_punc, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute say_control_attribute = - __ATTR(say_control, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(say_control, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute say_word_ctl_attribute = - __ATTR(say_word_ctl, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(say_word_ctl, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute spell_delay_attribute = - __ATTR(spell_delay, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(spell_delay, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); /* * These attributes are i18n related. */ static struct kobj_attribute announcements_attribute = - __ATTR(announcements, S_IWUGO|S_IRUGO, message_show, message_store); + __ATTR(announcements, S_IWUSR|S_IRUGO, message_show, message_store); static struct kobj_attribute characters_attribute = - __ATTR(characters, S_IWUGO|S_IRUGO, chars_chartab_show, chars_chartab_store); + __ATTR(characters, S_IWUSR|S_IRUGO, chars_chartab_show, chars_chartab_store); static struct kobj_attribute chartab_attribute = - __ATTR(chartab, S_IWUGO|S_IRUGO, chars_chartab_show, chars_chartab_store); + __ATTR(chartab, S_IWUSR|S_IRUGO, chars_chartab_show, chars_chartab_store); static struct kobj_attribute ctl_keys_attribute = - __ATTR(ctl_keys, S_IWUGO|S_IRUGO, message_show, message_store); + __ATTR(ctl_keys, S_IWUSR|S_IRUGO, message_show, message_store); static struct kobj_attribute colors_attribute = - __ATTR(colors, S_IWUGO|S_IRUGO, message_show, message_store); + __ATTR(colors, S_IWUSR|S_IRUGO, message_show, message_store); static struct kobj_attribute formatted_attribute = - __ATTR(formatted, S_IWUGO|S_IRUGO, message_show, message_store); + __ATTR(formatted, S_IWUSR|S_IRUGO, message_show, message_store); static struct kobj_attribute function_names_attribute = - __ATTR(function_names, S_IWUGO|S_IRUGO, message_show, message_store); + __ATTR(function_names, S_IWUSR|S_IRUGO, message_show, message_store); static struct kobj_attribute key_names_attribute = - __ATTR(key_names, S_IWUGO|S_IRUGO, message_show, message_store); + __ATTR(key_names, S_IWUSR|S_IRUGO, message_show, message_store); static struct kobj_attribute states_attribute = - __ATTR(states, S_IWUGO|S_IRUGO, message_show, message_store); + __ATTR(states, S_IWUSR|S_IRUGO, message_show, message_store); /* * Create groups of attributes so that we can create and destroy them all diff --git a/drivers/staging/speakup/speakup_acntpc.c b/drivers/staging/speakup/speakup_acntpc.c index e7dfa434bd96..31f952b9049b 100644 --- a/drivers/staging/speakup/speakup_acntpc.c +++ b/drivers/staging/speakup/speakup_acntpc.c @@ -62,22 +62,22 @@ static struct var_t vars[] = { * These attributes will appear in /sys/accessibility/speakup/acntpc. */ static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_start, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_stop, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute pitch_attribute = - __ATTR(pitch, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(pitch, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute rate_attribute = - __ATTR(rate, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(rate, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute tone_attribute = - __ATTR(tone, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(tone, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute vol_attribute = - __ATTR(vol, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(vol, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute delay_time_attribute = __ATTR(delay_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute direct_attribute = - __ATTR(direct, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(direct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute full_time_attribute = __ATTR(full_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute jiffy_delta_attribute = diff --git a/drivers/staging/speakup/speakup_acntsa.c b/drivers/staging/speakup/speakup_acntsa.c index c7f014ed9628..1f374845f610 100644 --- a/drivers/staging/speakup/speakup_acntsa.c +++ b/drivers/staging/speakup/speakup_acntsa.c @@ -47,22 +47,22 @@ static struct var_t vars[] = { * These attributes will appear in /sys/accessibility/speakup/acntsa. */ static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_start, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_stop, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute pitch_attribute = - __ATTR(pitch, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(pitch, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute rate_attribute = - __ATTR(rate, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(rate, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute tone_attribute = - __ATTR(tone, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(tone, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute vol_attribute = - __ATTR(vol, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(vol, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute delay_time_attribute = __ATTR(delay_time, S_IRUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute direct_attribute = - __ATTR(direct, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(direct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute full_time_attribute = __ATTR(full_time, S_IRUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute jiffy_delta_attribute = diff --git a/drivers/staging/speakup/speakup_apollo.c b/drivers/staging/speakup/speakup_apollo.c index 38c8c2221e4e..678b263e551c 100644 --- a/drivers/staging/speakup/speakup_apollo.c +++ b/drivers/staging/speakup/speakup_apollo.c @@ -53,24 +53,24 @@ static struct var_t vars[] = { * These attributes will appear in /sys/accessibility/speakup/apollo. */ static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_start, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_stop, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute lang_attribute = - __ATTR(lang, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(lang, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute pitch_attribute = - __ATTR(pitch, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(pitch, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute rate_attribute = - __ATTR(rate, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(rate, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute voice_attribute = - __ATTR(voice, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(voice, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute vol_attribute = - __ATTR(vol, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(vol, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute delay_time_attribute = __ATTR(delay_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute direct_attribute = - __ATTR(direct, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(direct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute full_time_attribute = __ATTR(full_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute jiffy_delta_attribute = diff --git a/drivers/staging/speakup/speakup_audptr.c b/drivers/staging/speakup/speakup_audptr.c index de5b4a5f43b6..362f9747e48d 100644 --- a/drivers/staging/speakup/speakup_audptr.c +++ b/drivers/staging/speakup/speakup_audptr.c @@ -49,24 +49,24 @@ static struct var_t vars[] = { * These attributes will appear in /sys/accessibility/speakup/audptr. */ static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_start, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_stop, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute pitch_attribute = - __ATTR(pitch, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(pitch, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute punct_attribute = - __ATTR(punct, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(punct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute rate_attribute = - __ATTR(rate, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(rate, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute tone_attribute = - __ATTR(tone, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(tone, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute vol_attribute = - __ATTR(vol, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(vol, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute delay_time_attribute = __ATTR(delay_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute direct_attribute = - __ATTR(direct, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(direct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute full_time_attribute = __ATTR(full_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute jiffy_delta_attribute = diff --git a/drivers/staging/speakup/speakup_bns.c b/drivers/staging/speakup/speakup_bns.c index 4939e8c7272e..2f070282a85d 100644 --- a/drivers/staging/speakup/speakup_bns.c +++ b/drivers/staging/speakup/speakup_bns.c @@ -44,22 +44,22 @@ static struct var_t vars[] = { * These attributes will appear in /sys/accessibility/speakup/bns. */ static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_start, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_stop, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute pitch_attribute = - __ATTR(pitch, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(pitch, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute rate_attribute = - __ATTR(rate, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(rate, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute tone_attribute = - __ATTR(tone, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(tone, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute vol_attribute = - __ATTR(vol, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(vol, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute delay_time_attribute = __ATTR(delay_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute direct_attribute = - __ATTR(direct, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(direct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute full_time_attribute = __ATTR(full_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute jiffy_delta_attribute = diff --git a/drivers/staging/speakup/speakup_decext.c b/drivers/staging/speakup/speakup_decext.c index b17af9803929..67b7de1d8c75 100644 --- a/drivers/staging/speakup/speakup_decext.c +++ b/drivers/staging/speakup/speakup_decext.c @@ -70,24 +70,24 @@ static struct var_t vars[] = { * These attributes will appear in /sys/accessibility/speakup/decext. */ static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_start, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_stop, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute pitch_attribute = - __ATTR(pitch, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(pitch, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute punct_attribute = - __ATTR(punct, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(punct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute rate_attribute = - __ATTR(rate, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(rate, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute voice_attribute = - __ATTR(voice, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(voice, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute vol_attribute = - __ATTR(vol, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(vol, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute delay_time_attribute = __ATTR(delay_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute direct_attribute = - __ATTR(direct, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(direct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute full_time_attribute = __ATTR(full_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute jiffy_delta_attribute = diff --git a/drivers/staging/speakup/speakup_decpc.c b/drivers/staging/speakup/speakup_decpc.c index cfa4bc032358..67678d8888c2 100644 --- a/drivers/staging/speakup/speakup_decpc.c +++ b/drivers/staging/speakup/speakup_decpc.c @@ -164,24 +164,24 @@ static struct var_t vars[] = { * These attributes will appear in /sys/accessibility/speakup/decpc. */ static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_start, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_stop, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute pitch_attribute = - __ATTR(pitch, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(pitch, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute punct_attribute = - __ATTR(punct, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(punct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute rate_attribute = - __ATTR(rate, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(rate, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute voice_attribute = - __ATTR(voice, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(voice, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute vol_attribute = - __ATTR(vol, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(vol, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute delay_time_attribute = __ATTR(delay_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute direct_attribute = - __ATTR(direct, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(direct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute full_time_attribute = __ATTR(full_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute jiffy_delta_attribute = diff --git a/drivers/staging/speakup/speakup_dectlk.c b/drivers/staging/speakup/speakup_dectlk.c index 1fcae55dabba..af848686be71 100644 --- a/drivers/staging/speakup/speakup_dectlk.c +++ b/drivers/staging/speakup/speakup_dectlk.c @@ -70,24 +70,24 @@ static struct var_t vars[] = { * These attributes will appear in /sys/accessibility/speakup/dectlk. */ static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_start, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_stop, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute pitch_attribute = - __ATTR(pitch, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(pitch, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute punct_attribute = - __ATTR(punct, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(punct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute rate_attribute = - __ATTR(rate, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(rate, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute voice_attribute = - __ATTR(voice, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(voice, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute vol_attribute = - __ATTR(vol, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(vol, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute delay_time_attribute = __ATTR(delay_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute direct_attribute = - __ATTR(direct, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(direct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute full_time_attribute = __ATTR(full_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute jiffy_delta_attribute = diff --git a/drivers/staging/speakup/speakup_dtlk.c b/drivers/staging/speakup/speakup_dtlk.c index 5c6c34191e8d..98d1f497e4e0 100644 --- a/drivers/staging/speakup/speakup_dtlk.c +++ b/drivers/staging/speakup/speakup_dtlk.c @@ -67,28 +67,28 @@ static struct var_t vars[] = { * These attributes will appear in /sys/accessibility/speakup/dtlk. */ static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_start, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_stop, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute freq_attribute = - __ATTR(freq, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(freq, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute pitch_attribute = - __ATTR(pitch, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(pitch, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute punct_attribute = - __ATTR(punct, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(punct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute rate_attribute = - __ATTR(rate, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(rate, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute tone_attribute = - __ATTR(tone, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(tone, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute voice_attribute = - __ATTR(voice, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(voice, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute vol_attribute = - __ATTR(vol, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(vol, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute delay_time_attribute = __ATTR(delay_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute direct_attribute = - __ATTR(direct, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(direct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute full_time_attribute = __ATTR(full_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute jiffy_delta_attribute = diff --git a/drivers/staging/speakup/speakup_dummy.c b/drivers/staging/speakup/speakup_dummy.c index e19e9994bbb5..362342a194af 100644 --- a/drivers/staging/speakup/speakup_dummy.c +++ b/drivers/staging/speakup/speakup_dummy.c @@ -46,22 +46,22 @@ static struct var_t vars[] = { * These attributes will appear in /sys/accessibility/speakup/dummy. */ static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_start, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_stop, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute pitch_attribute = - __ATTR(pitch, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(pitch, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute rate_attribute = - __ATTR(rate, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(rate, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute tone_attribute = - __ATTR(tone, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(tone, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute vol_attribute = - __ATTR(vol, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(vol, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute delay_time_attribute = __ATTR(delay_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute direct_attribute = - __ATTR(direct, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(direct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute full_time_attribute = __ATTR(full_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute jiffy_delta_attribute = diff --git a/drivers/staging/speakup/speakup_keypc.c b/drivers/staging/speakup/speakup_keypc.c index 9c246d701a95..9d30c1945f92 100644 --- a/drivers/staging/speakup/speakup_keypc.c +++ b/drivers/staging/speakup/speakup_keypc.c @@ -59,18 +59,18 @@ static struct var_t vars[] = { * These attributes will appear in /sys/accessibility/speakup/keypc. */ static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_start, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_stop, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute pitch_attribute = - __ATTR(pitch, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(pitch, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute rate_attribute = - __ATTR(rate, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(rate, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute delay_time_attribute = __ATTR(delay_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute direct_attribute = - __ATTR(direct, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(direct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute full_time_attribute = __ATTR(full_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute jiffy_delta_attribute = diff --git a/drivers/staging/speakup/speakup_ltlk.c b/drivers/staging/speakup/speakup_ltlk.c index c9be6f52c254..d6de72295d33 100644 --- a/drivers/staging/speakup/speakup_ltlk.c +++ b/drivers/staging/speakup/speakup_ltlk.c @@ -50,28 +50,28 @@ static struct var_t vars[] = { * These attributes will appear in /sys/accessibility/speakup/ltlk. */ static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_start, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_stop, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute freq_attribute = - __ATTR(freq, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(freq, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute pitch_attribute = - __ATTR(pitch, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(pitch, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute punct_attribute = - __ATTR(punct, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(punct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute rate_attribute = - __ATTR(rate, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(rate, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute tone_attribute = - __ATTR(tone, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(tone, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute voice_attribute = - __ATTR(voice, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(voice, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute vol_attribute = - __ATTR(vol, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(vol, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute delay_time_attribute = __ATTR(delay_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute direct_attribute = - __ATTR(direct, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(direct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute full_time_attribute = __ATTR(full_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute jiffy_delta_attribute = diff --git a/drivers/staging/speakup/speakup_soft.c b/drivers/staging/speakup/speakup_soft.c index ee6089502a96..9ed726509261 100644 --- a/drivers/staging/speakup/speakup_soft.c +++ b/drivers/staging/speakup/speakup_soft.c @@ -61,35 +61,35 @@ static struct var_t vars[] = { * These attributes will appear in /sys/accessibility/speakup/soft. */ static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_start, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_stop, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute freq_attribute = - __ATTR(freq, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(freq, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute pitch_attribute = - __ATTR(pitch, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(pitch, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute punct_attribute = - __ATTR(punct, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(punct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute rate_attribute = - __ATTR(rate, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(rate, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute tone_attribute = - __ATTR(tone, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(tone, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute voice_attribute = - __ATTR(voice, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(voice, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute vol_attribute = - __ATTR(vol, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(vol, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); /* * We should uncomment the following definition, when we agree on a * method of passing a language designation to the software synthesizer. * static struct kobj_attribute lang_attribute = - * __ATTR(lang, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + * __ATTR(lang, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); */ static struct kobj_attribute delay_time_attribute = __ATTR(delay_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute direct_attribute = - __ATTR(direct, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(direct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute full_time_attribute = __ATTR(full_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute jiffy_delta_attribute = diff --git a/drivers/staging/speakup/speakup_spkout.c b/drivers/staging/speakup/speakup_spkout.c index 711cf114df83..77f2dc2c3d97 100644 --- a/drivers/staging/speakup/speakup_spkout.c +++ b/drivers/staging/speakup/speakup_spkout.c @@ -48,24 +48,24 @@ static struct var_t vars[] = { * These attributes will appear in /sys/accessibility/speakup/spkout. */ static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_start, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_stop, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute pitch_attribute = - __ATTR(pitch, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(pitch, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute punct_attribute = - __ATTR(punct, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(punct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute rate_attribute = - __ATTR(rate, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(rate, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute tone_attribute = - __ATTR(tone, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(tone, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute vol_attribute = - __ATTR(vol, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(vol, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute delay_time_attribute = __ATTR(delay_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute direct_attribute = - __ATTR(direct, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(direct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute full_time_attribute = __ATTR(full_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute jiffy_delta_attribute = diff --git a/drivers/staging/speakup/speakup_txprt.c b/drivers/staging/speakup/speakup_txprt.c index 3f0be04df071..dbe84b13772c 100644 --- a/drivers/staging/speakup/speakup_txprt.c +++ b/drivers/staging/speakup/speakup_txprt.c @@ -44,22 +44,22 @@ static struct var_t vars[] = { * These attributes will appear in /sys/accessibility/speakup/txprt. */ static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_start, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(caps_stop, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute pitch_attribute = - __ATTR(pitch, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(pitch, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute rate_attribute = - __ATTR(rate, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(rate, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute tone_attribute = - __ATTR(tone, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(tone, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute vol_attribute = - __ATTR(vol, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(vol, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute delay_time_attribute = __ATTR(delay_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute direct_attribute = - __ATTR(direct, S_IWUGO|S_IRUGO, spk_var_show, spk_var_store); + __ATTR(direct, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute full_time_attribute = __ATTR(full_time, S_IWUSR|S_IRUGO, spk_var_show, spk_var_store); static struct kobj_attribute jiffy_delta_attribute = -- cgit v1.2.3 From 6a4193a276f7c976487956c38789d5becc9256e5 Mon Sep 17 00:00:00 2001 From: Bastien Armand Date: Wed, 23 Apr 2014 19:42:11 +0200 Subject: staging: panel: fix regression in lcd_write This patch fix a regression in lcd_write caused by commit 70a8c3eb8546cefe40fb0bc7991e8899b7b91075 Signed-off-by: Bastien Armand Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index 136671a50d6e..acd4b8e013d2 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -1324,7 +1324,7 @@ static ssize_t lcd_write(struct file *file, that need some CPU */ schedule(); - if (get_user(c, buf)) + if (get_user(c, tmp)) return -EFAULT; lcd_write_char(c); -- cgit v1.2.3 From 3ac769042904d53359db70cf77d61d44d7812e40 Mon Sep 17 00:00:00 2001 From: Dominique van den Broeck Date: Wed, 21 May 2014 14:09:59 +0200 Subject: staging: panel: (coding style) Matching braces Style-only modifications to comply with checkpatch.pl --strict --file. . Adds every missing brace in condition statements. Signed-off-by: Dominique van den Broeck Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index acd4b8e013d2..9f07c5bdd805 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -711,10 +711,9 @@ static void pin_to_bits(int pin, unsigned char *d_val, unsigned char *c_val) /* sleeps that many milliseconds with a reschedule */ static void long_sleep(int ms) { - - if (in_interrupt()) + if (in_interrupt()) { mdelay(ms); - else { + } else { current->state = TASK_INTERRUPTIBLE; schedule_timeout((ms * HZ + 999) / 1000); } @@ -1141,13 +1140,13 @@ static inline int handle_lcd_special_code(void) value = 0; while (*esc && cgoffset < 8) { shift ^= 4; - if (*esc >= '0' && *esc <= '9') + if (*esc >= '0' && *esc <= '9') { value |= (*esc - '0') << shift; - else if (*esc >= 'A' && *esc <= 'Z') + } else if (*esc >= 'A' && *esc <= 'Z') { value |= (*esc - 'A' + 10) << shift; - else if (*esc >= 'a' && *esc <= 'z') + } else if (*esc >= 'a' && *esc <= 'z') { value |= (*esc - 'a' + 10) << shift; - else { + } else { esc++; continue; } @@ -1183,8 +1182,9 @@ static inline int handle_lcd_special_code(void) esc++; if (kstrtoul(esc, 10, &lcd_addr_y) < 0) break; - } else + } else { break; + } } lcd_gotoxy(); @@ -1973,10 +1973,11 @@ static int input_name2mask(const char *name, pmask_t *mask, pmask_t *value, if (isdigit(*name)) { out = *name - '0'; om |= (1 << out); - } else if (*name == '-') + } else if (*name == '-') { out = 8; - else + } else { return 0; /* unknown bit name */ + } bit = (out * 5) + in; -- cgit v1.2.3 From fdf4a4948ca8a18c16f6ef1560043db7300ea7f9 Mon Sep 17 00:00:00 2001 From: Dominique van den Broeck Date: Wed, 21 May 2014 14:10:00 +0200 Subject: staging: panel: (coding style) Line alignments and malloc sizeof Style-only modifications to comply with checkpatch.pl --strict --file. . Correctly realigns the lines that needed to be ; . Suppress useless blank rows ; . Fix sizeof() issues in various -malloc() functions. Signed-off-by: Dominique van den Broeck Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index 9f07c5bdd805..0cc5e084653a 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -462,7 +462,7 @@ MODULE_PARM_DESC(lcd_type, static int lcd_proto = -1; module_param(lcd_proto, int, 0000); MODULE_PARM_DESC(lcd_proto, - "LCD communication: 0=parallel (//), 1=serial, 2=TI LCD Interface"); + "LCD communication: 0=parallel (//), 1=serial, 2=TI LCD Interface"); static int lcd_charset = -1; module_param(lcd_charset, int, 0000); @@ -951,7 +951,6 @@ static void lcd_clear_display(void) static void lcd_init_display(void) { - lcd_flags = ((lcd_height > 1) ? LCD_FLAG_N : 0) | LCD_FLAG_D | LCD_FLAG_C | LCD_FLAG_B; @@ -1313,7 +1312,7 @@ static void lcd_write_char(char c) } static ssize_t lcd_write(struct file *file, - const char __user *buf, size_t count, loff_t *ppos) + const char __user *buf, size_t count, loff_t *ppos) { const char __user *tmp = buf; char c; @@ -1590,7 +1589,6 @@ static void lcd_init(void) static ssize_t keypad_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { - unsigned i = *ppos; char __user *tmp = buf; @@ -1615,7 +1613,6 @@ static ssize_t keypad_read(struct file *file, static int keypad_open(struct inode *inode, struct file *file) { - if (keypad_open_cnt) return -EBUSY; /* open only once at a time */ @@ -1745,8 +1742,8 @@ static inline int input_state_high(struct logical_input *input) * release function. * eg: 0 -(press A)-> A -(press B)-> AB : don't match A's release. */ - if (((phys_prev & input->mask) == input->value) - && ((phys_curr & input->mask) > input->value)) { + if (((phys_prev & input->mask) == input->value) && + ((phys_curr & input->mask) > input->value)) { input->state = INPUT_ST_LOW; /* invalidate */ return 1; } @@ -1801,8 +1798,8 @@ static inline void input_state_falling(struct logical_input *input) { #if 0 /* FIXME !!! same comment as in input_state_high */ - if (((phys_prev & input->mask) == input->value) - && ((phys_curr & input->mask) > input->value)) { + if (((phys_prev & input->mask) == input->value) && + ((phys_curr & input->mask) > input->value)) { input->state = INPUT_ST_LOW; /* invalidate */ return; } @@ -1960,9 +1957,10 @@ static int input_name2mask(const char *name, pmask_t *mask, pmask_t *value, while (*name) { int in, out, bit, neg; - for (in = 0; (in < sizeof(sigtab)) && - (sigtab[in] != *name); in++) + for (in = 0; (in < sizeof(sigtab)) && (sigtab[in] != *name); + in++) ; + if (in >= sizeof(sigtab)) return 0; /* input name not found */ neg = (in & 1); /* odd (lower) names are negated */ @@ -2005,7 +2003,7 @@ static struct logical_input *panel_bind_key(const char *name, const char *press, { struct logical_input *key; - key = kzalloc(sizeof(struct logical_input), GFP_KERNEL); + key = kzalloc(sizeof(*key), GFP_KERNEL); if (!key) return NULL; @@ -2043,7 +2041,7 @@ static struct logical_input *panel_bind_callback(char *name, { struct logical_input *callback; - callback = kmalloc(sizeof(struct logical_input), GFP_KERNEL); + callback = kmalloc(sizeof(*callback), GFP_KERNEL); if (!callback) return NULL; -- cgit v1.2.3 From 2ab4b6e7caa02840c40af339e4159a11ed76dc57 Mon Sep 17 00:00:00 2001 From: Daeseok Youn Date: Fri, 9 May 2014 19:02:20 +0900 Subject: staging: cxt1e1: Fix no spaces at the start of a line in musycc.c clean up checkpatch.pl warning: WARNING: please no spaces at the start of a line in Signed-off-by: Daeseok Youn Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cxt1e1/musycc.c | 2627 +++++++++++++++++++-------------------- 1 file changed, 1313 insertions(+), 1314 deletions(-) diff --git a/drivers/staging/cxt1e1/musycc.c b/drivers/staging/cxt1e1/musycc.c index 872cdae02704..2ddf88982a7a 100644 --- a/drivers/staging/cxt1e1/musycc.c +++ b/drivers/staging/cxt1e1/musycc.c @@ -68,65 +68,65 @@ void musycc_update_timeslots(mpi_t *); static int musycc_dump_rxbuffer_ring(mch_t *ch, int lockit) { - struct mdesc *m; - unsigned long flags = 0; + struct mdesc *m; + unsigned long flags = 0; - u_int32_t status; - int n; + u_int32_t status; + int n; - if (lockit) - spin_lock_irqsave(&ch->ch_rxlock, flags); - if (ch->rxd_num == 0) - pr_info(" 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); - { - pr_info("%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)); + if (lockit) + spin_lock_irqsave(&ch->ch_rxlock, flags); + if (ch->rxd_num == 0) + pr_info(" 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); + { + pr_info("%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; + { + u_int32_t *dp; + int len = status & LENGTH_MASK; #if 1 - if (m->data && (status & HOST_RX_OWNED)) + if (m->data && (status & HOST_RX_OWNED)) #else - if (m->data) /* always dump regardless of valid RX - * data */ + 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) - pr_info(" %x[%x]: %08X %08X %08X %08x\n", (u_int32_t) dp, len, - *dp, *(dp + 1), *(dp + 2), *(dp + 3)); - else if (len >= 0x08) - pr_info(" %x[%x]: %08X %08X\n", (u_int32_t) dp, len, - *dp, *(dp + 1)); - else - pr_info(" %x[%x]: %08X\n", (u_int32_t) dp, len, *dp); - } - } + { + dp = (u_int32_t *) OS_phystov((void *) (le32_to_cpu(m->data))); + if (len >= 0x10) + pr_info(" %x[%x]: %08X %08X %08X %08x\n", (u_int32_t) dp, len, + *dp, *(dp + 1), *(dp + 2), *(dp + 3)); + else if (len >= 0x08) + pr_info(" %x[%x]: %08X %08X\n", (u_int32_t) dp, len, + *dp, *(dp + 1)); + else + pr_info(" %x[%x]: %08X\n", (u_int32_t) dp, len, *dp); + } + } #endif - } - m = m->snext; - } - } /* -for- */ - pr_info("\n"); + } + m = m->snext; + } + } /* -for- */ + pr_info("\n"); - if (lockit) - spin_unlock_irqrestore(&ch->ch_rxlock, flags); - return 0; + if (lockit) + spin_unlock_irqrestore(&ch->ch_rxlock, flags); + return 0; } #endif @@ -134,59 +134,59 @@ musycc_dump_rxbuffer_ring(mch_t *ch, int lockit) 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) - pr_info(" 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); - { - pr_info("%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)); + 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) + pr_info(" 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); + { + pr_info("%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) - pr_info(" %x[%x]: %08X %08X %08X %08x\n", (u_int32_t) dp, len, - *dp, *(dp + 1), *(dp + 2), *(dp + 3)); - else if (len >= 0x08) - pr_info(" %x[%x]: %08X %08X\n", (u_int32_t) dp, len, - *dp, *(dp + 1)); - else - pr_info(" %x[%x]: %08X\n", (u_int32_t) dp, len, *dp); - } - } + { + 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) + pr_info(" %x[%x]: %08X %08X %08X %08x\n", (u_int32_t) dp, len, + *dp, *(dp + 1), *(dp + 2), *(dp + 3)); + else if (len >= 0x08) + pr_info(" %x[%x]: %08X %08X\n", (u_int32_t) dp, len, + *dp, *(dp + 1)); + else + pr_info(" %x[%x]: %08X\n", (u_int32_t) dp, len, *dp); + } + } #endif - } - m = m->snext; - } - } /* -for- */ - pr_info("\n"); + } + m = m->snext; + } + } /* -for- */ + pr_info("\n"); - if (lockit) - spin_unlock_irqrestore(&ch->ch_txlock, flags); - return 0; + if (lockit) + spin_unlock_irqrestore(&ch->ch_txlock, flags); + return 0; } #endif @@ -199,55 +199,55 @@ musycc_dump_txbuffer_ring(mch_t *ch, int lockit) 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); - pr_info(">> 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 */ - } - - ch = sd_find_chan(dummy, chan); - if (!ch) { - pr_info(">> musycc_dump_ring: channel %d not up.\n", chan); - return ENOENT; - } - pr_info(">> CI %p CHANNEL %3d @ %p: state %x status/p %x/%x\n", ci, chan, ch, ch->state, - ch->status, ch->p.status); - pr_info("--------------------------------\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); - pr_info("++ 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); - pr_info("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; + mch_t *ch; + + if (chan >= MAX_CHANS_USED) + return SBE_DRVR_FAIL; /* E2BIG */ + { + int bh; + + bh = atomic_read(&ci->bh_pending); + pr_info(">> 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 */ + } + + ch = sd_find_chan(dummy, chan); + if (!ch) { + pr_info(">> musycc_dump_ring: channel %d not up.\n", chan); + return ENOENT; + } + pr_info(">> CI %p CHANNEL %3d @ %p: state %x status/p %x/%x\n", ci, chan, ch, ch->state, + ch->status, ch->p.status); + pr_info("--------------------------------\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); + pr_info("++ 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); + pr_info("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; + unsigned int chan; - for (chan = start_chan; chan < (start_chan + 5); chan++) - musycc_dump_ring(ci, chan); - return SBE_DRVR_SUCCESS; + for (chan = start_chan; chan < (start_chan + 5); chan++) + musycc_dump_ring(ci, chan); + return SBE_DRVR_SUCCESS; } @@ -259,22 +259,22 @@ musycc_dump_rings(ci_t *ci, unsigned int start_chan) 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); + 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); } @@ -283,44 +283,44 @@ musycc_init_mdt(mpi_t *pi) void musycc_update_tx_thp(mch_t *ch) { - struct mdesc *md; - unsigned long flags; + 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; + 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); } - if ((le32_to_cpu(md->status)) & MUSYCC_TX_OWNED) { - /* this is the MD to restart TX with */ - break; + 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 */ } - /* - * 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); + spin_unlock_irqrestore(&ch->ch_txlock, flags); #ifdef RLD_TRANS_DEBUG - pr_info("++ musycc_update_tx_thp[%d]: setting thp = %p, sts %x\n", ch->channum, md, md->status); + pr_info("++ musycc_update_tx_thp[%d]: setting thp = %p, sts %x\n", ch->channum, md, md->status); #endif } @@ -337,96 +337,96 @@ musycc_update_tx_thp(mch_t *ch) void musycc_wq_chan_restart(void *arg) /* channel private structure */ { - mch_t *ch; - mpi_t *pi; - struct mdesc *md; + mch_t *ch; + mpi_t *pi; + struct mdesc *md; #if 0 - unsigned long flags; + unsigned long flags; #endif - ch = container_of(arg, struct c4_chan_info, ch_work); - pi = ch->up; + ch = container_of(arg, struct c4_chan_info, ch_work); + pi = ch->up; #ifdef RLD_TRANS_DEBUG - pr_info("wq_chan_restart[%d]: start_RT[%d/%d] status %x\n", - ch->channum, ch->ch_start_rx, ch->ch_start_tx, ch->status); + pr_info("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 **/ - /**********************************/ + /**********************************/ + /** check for RX restart request **/ + /**********************************/ - if ((ch->ch_start_rx) && (ch->status & RX_ENABLED)) { + if ((ch->ch_start_rx) && (ch->status & RX_ENABLED)) { - ch->ch_start_rx = 0; + ch->ch_start_rx = 0; #if defined(RLD_TRANS_DEBUG) || defined(RLD_RXACT_DEBUG) - { - static int hereb4 = 7; + { + static int hereb4 = 7; - if (hereb4) { /* RLD DEBUG */ - hereb4--; + if (hereb4) { /* RLD DEBUG */ + hereb4--; #ifdef RLD_TRANS_DEBUG - md = &ch->mdr[ch->rxix_irq_srv]; - pr_info("++ 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); + md = &ch->mdr[ch->rxix_irq_srv]; + pr_info("++ 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]; - pr_info("++ 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 */ + md = &ch->mdr[ch->rxix_irq_srv]; + pr_info("++ 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 **/ - /**********************************/ + 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 ((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); + spin_lock_irqsave(&ch->ch_txlock, flags); #endif - md = ch->txd_irq_srv; - if (!md) { + md = ch->txd_irq_srv; + if (!md) { #ifdef RLD_TRANS_DEBUG - pr_info("-- musycc_wq_chan_restart[%d]: WARNING, starting NULL md\n", ch->channum); + pr_info("-- musycc_wq_chan_restart[%d]: WARNING, starting NULL md\n", ch->channum); #endif #if 0 - spin_unlock_irqrestore(&ch->ch_txlock, flags); + 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; + } 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 */ + spin_unlock_irqrestore(&ch->ch_txlock, flags); /* allow interrupts for service request */ #endif #ifdef RLD_TRANS_DEBUG - pr_info("++ 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); + pr_info("++ 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); - } + 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 */ - pr_info("-- 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); + else { + /* retain request to start until retried and we have data to xmit */ + pr_info("-- 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 */ + spin_unlock_irqrestore(&ch->ch_txlock, flags); /* allow interrupts for service request */ #endif - } + } #endif - } + } } @@ -439,31 +439,30 @@ void musycc_chan_restart(mch_t *ch) { #ifdef RLD_RESTART_DEBUG - pr_info("++ musycc_chan_restart[%d]: txd_irq_srv @ %p = sts %x\n", - ch->channum, ch->txd_irq_srv, ch->txd_irq_srv->status); + pr_info("++ musycc_chan_restart[%d]: txd_irq_srv @ %p = sts %x\n", + ch->channum, ch->txd_irq_srv, ch->txd_irq_srv->status); #endif - /* 2.6 - find next unprocessed message, then set TX thp to it */ + /* 2.6 - find next unprocessed message, then set TX thp to it */ #ifdef RLD_RESTART_DEBUG - pr_info(">> musycc_chan_restart: scheduling Chan %x workQ @ %p\n", ch->channum, &ch->ch_work); + pr_info(">> 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 () */ - + c4_wk_chan_restart(ch); /* work queue mechanism fires off: Ref: + * musycc_wq_chan_restart () */ } void rld_put_led(mpi_t *pi, u_int32_t ledval) { - static u_int32_t led = 0; + static u_int32_t led = 0; - if (ledval == 0) - led = 0; - else - led |= ledval; + if (ledval == 0) + led = 0; + else + led |= ledval; - pci_write_32((u_int32_t *) &pi->up->cpldbase->leds, led); /* RLD DEBUG TRANHANG */ + pci_write_32((u_int32_t *) &pi->up->cpldbase->leds, led); /* RLD DEBUG TRANHANG */ } @@ -472,100 +471,100 @@ rld_put_led(mpi_t *pi, u_int32_t ledval) void musycc_serv_req(mpi_t *pi, u_int32_t req) { - volatile u_int32_t r; - int rcnt; + 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." - */ + /* + * 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 */ + SD_SEM_TAKE(&pi->sr_sem_busy, "serv"); /* only 1 thru here, per + * group */ - if (pi->sr_last == req) { + if (pi->sr_last == req) { #ifdef RLD_TRANS_DEBUG - pr_info(">> same SR, Port %d Req %x\n", pi->portnum, req); + pr_info(">> 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. - */ + /* + * 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))) { + 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 - pr_info(">> same CHAN ACT SR, Port %d Req %x => issue SR_NOOP CMD\n", pi->portnum, req); + pr_info(">> 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 */ + 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 - pr_info(">> same Port SR_NOOP skipped, Port %d\n", pi->portnum); + pr_info(">> same Port SR_NOOP skipped, Port %d\n", pi->portnum); #endif - SD_SEM_GIVE(&pi->sr_sem_busy); /* allow this next request */ - return; + SD_SEM_GIVE(&pi->sr_sem_busy); /* allow this next request */ + return; + } } - } - rcnt = 0; - pi->sr_last = req; + 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 (cxt1e1_log_level >= LOG_MONITOR) - pr_info("%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) { - pr_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) { + pci_write_32((u_int32_t *) &pi->reg->srd, req); + FLUSH_MEM_WRITE(); + /* - * 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. + * 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." */ - 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 */ + 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 (cxt1e1_log_level >= LOG_MONITOR) + pr_info("%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) { + pr_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 */ } @@ -573,94 +572,94 @@ rewrite: void musycc_update_timeslots(mpi_t *pi) { - int i, ch; - char e1mode = IS_FRAME_ANY_E1(pi->p.port_mode); + 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]; + for (i = 0; i < 32; i++) { + int usedby = 0, last = 0, ts, j, bits[8]; - u_int8_t lastval = 0; + 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]; + 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++) - 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]); - } + 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; } - 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); + 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 + void musycc_update_timeslots(mpi_t *pi) { - mch_t *ch; + mch_t *ch; - u_int8_t ts, hmask, tsen; - int gchan; - int i; + u_int8_t ts, hmask, tsen; + int gchan; + int i; #ifdef SBE_PMCC4_ENABLE - hmask = (0x1f << pi->up->p.hypersize) & 0x1f; + hmask = (0x1f << pi->up->p.hypersize) & 0x1f; #endif #ifdef SBE_WAN256T3_ENABLE - hmask = (0x1f << hyperdummy) & 0x1f; + 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); + 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 @@ -672,59 +671,59 @@ musycc_update_timeslots(mpi_t *pi) 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; + 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(cxt1e1_max_mru | (cxt1e1_max_mru << 16)); - FLUSH_MEM_WRITE(); + 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(cxt1e1_max_mru | (cxt1e1_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_serv_req(pi, SR_GROUP_INIT | SR_RX_DIRECTION); + musycc_serv_req(pi, SR_GROUP_INIT | SR_TX_DIRECTION); - musycc_init_mdt(pi); + musycc_init_mdt(pi); - musycc_update_timeslots(pi); + musycc_update_timeslots(pi); } #endif @@ -732,273 +731,273 @@ musycc_init_port(mpi_t *pi) status_t __init musycc_init(ci_t *ci) { - char *regaddr; /* temp for address boundary calculations */ - int i, gchan; + char *regaddr; /* temp for address boundary calculations */ + int i, gchan; - OS_sem_init(&ci->sem_wdbusy, SEM_AVAILABLE); /* watchdog exclusion */ + 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." - */ + /* + * 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 = kzalloc((INT_QUEUE_SIZE + 1) * sizeof(u_int32_t), GFP_KERNEL | GFP_DMA); - if (!regaddr) - 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 */ + if (!regaddr) + 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 < 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]; + 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." - */ + /* + * 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 = kzalloc(sizeof(struct musycc_groupr) + GROUP_BOUNDARY, - GFP_KERNEL | GFP_DMA); - if (!regaddr) { - for (gchan = 0; gchan < i; gchan++) { - pi = &ci->port[gchan]; - kfree(pi->reg); - pi->reg = NULL; - } - return -ENOMEM; + regaddr = kzalloc(sizeof(struct musycc_groupr) + GROUP_BOUNDARY, + GFP_KERNEL | GFP_DMA); + if (!regaddr) { + for (gchan = 0; gchan < i; gchan++) { + pi = &ci->port[gchan]; + kfree(pi->reg); + pi->reg = NULL; + } + 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 */ } - 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); + + /* 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); + 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); + /* 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->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 */ + ci->state = C_RUNNING; /* mark as full interrupt processing + * available */ - musycc_serv_req(&ci->port[0], SR_GLOBAL_INIT); /* FIRST INTERRUPT ! */ + musycc_serv_req(&ci->port[0], SR_GLOBAL_INIT); /* FIRST INTERRUPT ! */ - /* sanity check settable parameters */ + /* sanity check settable parameters */ - if (cxt1e1_max_mru > 0xffe) { - pr_warning("Maximum allowed MRU exceeded, resetting %d to %d.\n", - cxt1e1_max_mru, 0xffe); - cxt1e1_max_mru = 0xffe; - } - if (cxt1e1_max_mtu > 0xffe) { - pr_warning("Maximum allowed MTU exceeded, resetting %d to %d.\n", - cxt1e1_max_mtu, 0xffe); - cxt1e1_max_mtu = 0xffe; - } + if (cxt1e1_max_mru > 0xffe) { + pr_warning("Maximum allowed MRU exceeded, resetting %d to %d.\n", + cxt1e1_max_mru, 0xffe); + cxt1e1_max_mru = 0xffe; + } + if (cxt1e1_max_mtu > 0xffe) { + pr_warning("Maximum allowed MTU exceeded, resetting %d to %d.\n", + cxt1e1_max_mtu, 0xffe); + cxt1e1_max_mtu = 0xffe; + } #ifdef SBE_WAN256T3_ENABLE - for (i = 0; i < MUSYCC_NPORTS; i++) - musycc_init_port(&ci->port[i]); + for (i = 0; i < MUSYCC_NPORTS; i++) + musycc_init_port(&ci->port[i]); #endif - return SBE_DRVR_SUCCESS; /* no error */ + return SBE_DRVR_SUCCESS; /* no error */ } void musycc_bh_tx_eom(mpi_t *pi, int gchan) { - mch_t *ch; - struct mdesc *md; + mch_t *ch; + struct mdesc *md; #if 0 #ifndef SBE_ISR_INLINE - unsigned long flags; + unsigned long flags; #endif #endif - volatile u_int32_t status; - - ch = pi->chan[gchan]; - if (!ch || ch->state != UP) { - if (cxt1e1_log_level >= LOG_ERROR) - pr_info("%s: intr: xmit EOM on uninitialized channel %d\n", - pi->up->devname, gchan); - } - if (!ch || !ch->mdt) - return; /* note: mdt==0 implies a malloc() - * failure w/in chan_up() routine */ + volatile u_int32_t status; + + ch = pi->chan[gchan]; + if (!ch || ch->state != UP) { + if (cxt1e1_log_level >= LOG_ERROR) + pr_info("%s: intr: xmit EOM on uninitialized channel %d\n", + pi->up->devname, gchan); + } + if (!ch || !ch->mdt) + 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); + spin_lock_irq(&ch->ch_txlock); #else - spin_lock_irqsave(&ch->ch_txlock, flags); + 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 */ + do { FLUSH_MEM_READ(); + md = ch->txd_irq_srv; status = le32_to_cpu(md->status); - if (readCount++ > 40) - break; /* don't wait any longer */ - } - if (status & MUSYCC_TX_OWNED) { - if (cxt1e1_log_level >= LOG_MONITOR) { - pr_info("%s: Port %d Chan %2d - unexpected TX msg ownership intr (md %p sts %x)\n", - pi->up->devname, pi->portnum, ch->channum, - md, status); - pr_info("++ 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); + + /* + * 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 (cxt1e1_log_level >= LOG_MONITOR) { + pr_info("%s: Port %d Chan %2d - unexpected TX msg ownership intr (md %p sts %x)\n", + pi->up->devname, pi->portnum, ch->channum, + md, status); + pr_info("++ 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 (cxt1e1_log_level >= LOG_MONITOR) + pr_info("%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); + } } - break; /* Not our mdesc, done */ - } else { - if (cxt1e1_log_level >= LOG_MONITOR) - pr_info("%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) { - /* 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); + ch->txd_irq_srv = md->snext; + + md->data = 0; + if (md->mem_token) { + /* 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); + 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)); - } - } + /* 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 = NULL; - } - md->status = 0; + OS_mem_token_free_irq(md->mem_token); + md->mem_token = NULL; + } + md->status = 0; #ifdef RLD_TXFULL_DEBUG - if (cxt1e1_log_level >= LOG_MONITOR2) - pr_info("~~ tx_eom: tx_full %x txd_free %d -> %d\n", - ch->tx_full, ch->txd_free, ch->txd_free + 1); + if (cxt1e1_log_level >= LOG_MONITOR2) + pr_info("~~ 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(); + ++ch->txd_free; + FLUSH_MEM_WRITE(); + + if ((ch->p.chan_mode != CFG_CH_PROTO_TRANS) && (status & EOBIRQ_ENABLE)) { + if (cxt1e1_log_level >= LOG_MONITOR) + pr_info("%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. + */ - if ((ch->p.chan_mode != CFG_CH_PROTO_TRANS) && (status & EOBIRQ_ENABLE)) { - if (cxt1e1_log_level >= LOG_MONITOR) - pr_info("%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))) { + FLUSH_MEM_READ(); /* - * 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! + * Smooth flow control hysterisis by maintaining task stoppage until half + * the available write buffers are available. */ - if (ch->txd_free >= ch->txd_required) { + 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 (cxt1e1_log_level >= LOG_MONITOR2) - pr_info("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); + if (cxt1e1_log_level >= LOG_MONITOR2) + pr_info("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 */ + 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 (cxt1e1_log_level >= LOG_MONITOR2) - pr_info("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); - } + else if (ch->tx_full) { + if (cxt1e1_log_level >= LOG_MONITOR2) + pr_info("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(); + FLUSH_MEM_WRITE(); #if 0 #ifdef SBE_ISR_INLINE - spin_unlock_irq(&ch->ch_txlock); + spin_unlock_irq(&ch->ch_txlock); #else - spin_unlock_irqrestore(&ch->ch_txlock, flags); + spin_unlock_irqrestore(&ch->ch_txlock, flags); #endif #endif } @@ -1007,217 +1006,217 @@ musycc_bh_tx_eom(mpi_t *pi, int gchan) 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 || ch->state != UP) { - if (cxt1e1_log_level > LOG_ERROR) - pr_info("%s: intr: receive EOM on uninitialized channel %d\n", - pi->up->devname, gchan); - return; - } - if (!ch->mdr) - 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) { + mch_t *ch; + void *m, *m2; + struct mdesc *md; + volatile u_int32_t status; + u_int32_t error; + + ch = pi->chan[gchan]; + if (!ch || ch->state != UP) { + if (cxt1e1_log_level > LOG_ERROR) + pr_info("%s: intr: receive EOM on uninitialized channel %d\n", + pi->up->devname, gchan); + return; + } + if (!ch->mdr) + 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 + 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 ***/ - { - m2 = OS_mem_token_alloc(cxt1e1_max_mru); - if (m2) { - /* 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 = cxt1e1_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(); - } + { + m2 = OS_mem_token_alloc(cxt1e1_max_mru); + if (m2) { + /* 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 = cxt1e1_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); + ci_t *ci = (ci_t *) devp; + volatile u_int32_t status, currInt = 0; + u_int32_t nextInt, intCnt; - /* 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 (cxt1e1_log_level >= LOG_MONITOR) { - pr_info("%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. + * Hardware not available, potential interrupt hang. But since interrupt + * might be shared, just return. */ - 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 { + if (ci->state == C_INIT) + return IRQ_NONE; /* - * 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. + * 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 (cxt1e1_log_level >= LOG_MONITOR) { + pr_info("%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 */ - pr_info(">> %s: intCnt NULL, sts %x, possibly a chained interrupt!\n", - ci->devname, status); + /* chained interrupt = not ours */ + pr_info(">> %s: intCnt NULL, sts %x, possibly a chained interrupt!\n", + ci->devname, status); #endif - return IRQ_NONE; - } + return IRQ_NONE; + } - ci->iqp_tailx = currInt; + ci->iqp_tailx = currInt; - currInt <<= INTRPTS_NEXTINT_S; - ci->intlog.last_status_new = ci->intlog.this_status_new; - ci->intlog.this_status_new = currInt; + currInt <<= INTRPTS_NEXTINT_S; + ci->intlog.last_status_new = ci->intlog.this_status_new; + ci->intlog.this_status_new = currInt; - if ((cxt1e1_log_level >= LOG_WARN) && (status & INTRPTS_INTFULL_M)) - pr_info("%s: Interrupt queue full condition occurred\n", ci->devname); - if (cxt1e1_log_level >= LOG_DEBUG) - pr_info("%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)); + if ((cxt1e1_log_level >= LOG_WARN) && (status & INTRPTS_INTFULL_M)) + pr_info("%s: Interrupt queue full condition occurred\n", ci->devname); + if (cxt1e1_log_level >= LOG_DEBUG) + pr_info("%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(); + 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); + 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); + 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); + (void) musycc_intr_bh_tasklet(ci); + pci_write_32((u_int32_t *) &ci->reg->isd, currInt); #endif - return IRQ_HANDLED; + return IRQ_HANDLED; } @@ -1228,368 +1227,368 @@ 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)) { + 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; + return 0L; #else - return; + return; #endif - } + } #if defined(SBE_ISR_TASKLET) || defined(SBE_ISR_IMMEDIATE) - if (drvr_state != SBE_DRVR_AVAILABLE) { + if (drvr_state != SBE_DRVR_AVAILABLE) { #if defined(SBE_ISR_TASKLET) - return; + return; #elif defined(SBE_ISR_IMMEDIATE) - return 0L; + return 0L; #endif - } + } #elif defined(SBE_ISR_INLINE) - /* no semaphore taken, no double checks */ + /* 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. */ - /**************************************************/ + ci->intlog.drvr_intr_bhcount++; + FLUSH_MEM_READ(); + { + unsigned int bh = atomic_read(&ci->bh_pending); - 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; + 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 (cxt1e1_log_level >= LOG_WARN) - pr_info("%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 losing - * 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; + if ((currInt == badInt) || (currInt == badInt2)) { /* catch failure of Bug + * Fix checking */ + if (cxt1e1_log_level >= LOG_WARN) + pr_info("%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 losing + * 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(); + ci->iqd_p[headx] = __constant_cpu_to_le32(INT_EMPTY_ENTRY); + FLUSH_MEM_WRITE(); - if (cxt1e1_log_level >= LOG_DEBUG) { - if (err != 0) - pr_info(" %08x -> err: %2d,", currInt, err); + if (cxt1e1_log_level >= LOG_DEBUG) { + if (err != 0) + pr_info(" %08x -> err: %2d,", currInt, err); - pr_info("+ 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 (cxt1e1_log_level >= LOG_DEBUG) { - volatile u_int32_t r; - - r = pci_read_32((u_int32_t *) &pi->reg->srd); - pr_info("- 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); + pr_info("+ 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 (cxt1e1_log_level >= LOG_DEBUG) { + volatile u_int32_t r; + + r = pci_read_32((u_int32_t *) &pi->reg->srd); + pr_info("- 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; + 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... - */ + /* + * 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 (cxt1e1_log_level >= LOG_WARN) - pr_info("%s: unexpected interrupt event: %d, iqd[%d]: %08x, port: %d\n", ci->devname, - event, headx, currInt, group); - break; - } /* switch on event */ - + case EVE_NONE: + if (err == ERR_SHT) + ch->s.rx_length_errors++; + break; + default: + if (cxt1e1_log_level >= LOG_WARN) + pr_info("%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. + * Per MUSYCC Manual, Section 6.4.8.3 [Transmit Errors], TX errors + * are service-affecting and require action to resume normal + * bit-level processing. */ - ch->ch_start_tx = CH_START_TX_ONR; - { + 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 || cxt1e1_log_level >= LOG_MONITOR) + if (1 || cxt1e1_log_level >= LOG_MONITOR) #else - if (cxt1e1_log_level >= LOG_MONITOR) + if (cxt1e1_log_level >= LOG_MONITOR) #endif - { - pr_info("%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); + { + pr_info("%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 */ - pr_info("++ 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); - } + if (ch->p.chan_mode == 2) { /* problem = ONR on HDLC + * mode */ + pr_info("++ 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; + } + } + } 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 (cxt1e1_log_level >= LOG_WARN) { + pr_info("%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 (cxt1e1_log_level >= LOG_MONITOR) + pr_info("%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 (cxt1e1_log_level >= LOG_WARN) + pr_info("%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 (cxt1e1_log_level >= LOG_WARN) { - pr_info("%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 (cxt1e1_log_level >= LOG_MONITOR) - pr_info("%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 (cxt1e1_log_level >= LOG_WARN) - pr_info("%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) && (cxt1e1_log_level >= LOG_ERROR)) + pr_info("%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 ((cxt1e1_log_level >= LOG_MONITOR2) && (ci->iqp_headx != ci->iqp_tailx)) { + int bh; - 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) && (cxt1e1_log_level >= LOG_ERROR)) - pr_info("%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 ((cxt1e1_log_level >= LOG_MONITOR2) && (ci->iqp_headx != ci->iqp_tailx)) { - int bh; - - bh = atomic_read(&CI->bh_pending); - pr_info("_bh_: late arrivals, head %d != tail %d, pending %d\n", - ci->iqp_headx, ci->iqp_tailx, bh); - } + bh = atomic_read(&CI->bh_pending); + pr_info("_bh_: late arrivals, head %d != tail %d, pending %d\n", + ci->iqp_headx, ci->iqp_tailx, bh); + } #if defined(SBE_ISR_IMMEDIATE) - return 0L; + return 0L; #endif - /* else, nothing returned */ + /* else, nothing returned */ } #if 0 -int __init + int __init musycc_new_chan(ci_t *ci, int channum, void *user) { - mch_t *ch; + mch_t *ch; - ch = ci->port[channum / MUSYCC_NCHANS].chan[channum % MUSYCC_NCHANS]; + 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 (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; + 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); + 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; + return 0; } #endif #ifdef SBE_PMCC4_ENABLE -status_t + status_t musycc_chan_down(ci_t *dummy, int channum) { - mpi_t *pi; - mch_t *ch; - int i, gchan; - - ch = sd_find_chan(dummy, channum); - if (!ch) - 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) + mpi_t *pi; + mch_t *ch; + int i, gchan; + + ch = sd_find_chan(dummy, channum); + if (!ch) + 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) + OS_mem_token_free(ch->mdt[i].mem_token); + + for (i = 0; i < ch->rxd_num; i++) + if (ch->mdr[i].mem_token) + OS_mem_token_free(ch->mdr[i].mem_token); + + kfree(ch->mdr); + ch->mdr = NULL; + ch->rxd_num = 0; + kfree(ch->mdt); + ch->mdt = NULL; + ch->txd_num = 0; + + musycc_update_timeslots(pi); + c4_fifo_free(pi, ch->gchan); + + pi->openchans--; 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) - OS_mem_token_free(ch->mdt[i].mem_token); - - for (i = 0; i < ch->rxd_num; i++) - if (ch->mdr[i].mem_token) - OS_mem_token_free(ch->mdr[i].mem_token); - - kfree(ch->mdr); - ch->mdr = NULL; - ch->rxd_num = 0; - kfree(ch->mdt); - ch->mdt = NULL; - ch->txd_num = 0; - - musycc_update_timeslots(pi); - c4_fifo_free(pi, ch->gchan); - - pi->openchans--; - return 0; } #endif @@ -1599,33 +1598,33 @@ musycc_chan_down(ci_t *dummy, int channum) 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; - ch = sd_find_chan(ci, channum); - if (!ch) - return ENOENT; - if (ch->state == UP) - musycc_chan_down(ci, channum); - ch->state = UNASSIGNED; - return 0; + mch_t *ch; + + if ((channum < 0) || (channum >= (MUSYCC_NPORTS * MUSYCC_NCHANS))) /* sanity chk param */ + return ECHRNG; + ch = sd_find_chan(ci, channum); + if (!ch) + 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; + mch_t *ch; - if (channum < 0 || channum >= (MUSYCC_NPORTS * MUSYCC_NCHANS)) /* sanity chk param */ - return ECHRNG; - ch = sd_find_chan(ci, channum); - if (!ch) - return ENOENT; + if (channum < 0 || channum >= (MUSYCC_NPORTS * MUSYCC_NCHANS)) /* sanity chk param */ + return ECHRNG; + ch = sd_find_chan(ci, channum); + if (!ch) + return ENOENT; - memset(&ch->s, 0, sizeof(struct sbecom_chan_stats)); - return 0; + memset(&ch->s, 0, sizeof(struct sbecom_chan_stats)); + return 0; } #endif @@ -1633,169 +1632,169 @@ musycc_del_chan_stats(ci_t *ci, int channum) int musycc_start_xmit(ci_t *ci, int channum, void *mem_token) { - mch_t *ch; - struct mdesc *md; - void *m2; + mch_t *ch; + struct mdesc *md; + void *m2; #if 0 - unsigned long flags; + unsigned long flags; #endif - int txd_need_cnt; - u_int32_t len; + int txd_need_cnt; + u_int32_t len; - ch = sd_find_chan(ci, channum); - if (!ch) - return -ENOENT; + ch = sd_find_chan(ci, channum); + if (!ch) + return -ENOENT; - if (ci->state != C_RUNNING) /* full interrupt processing available */ - return -EINVAL; - if (ch->state != UP) - return -EINVAL; + 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 ? */ + if (!(ch->status & TX_ENABLED)) + return -EROFS; /* how else to flag unwritable state ? */ -#ifdef RLD_TRANS_DEBUGx - if (1 || cxt1e1_log_level >= LOG_MONITOR2) +#ifdef RLD_TRANS_DEBUG + if (1 || cxt1e1_log_level >= LOG_MONITOR2) #else - if (cxt1e1_log_level >= LOG_MONITOR2) -#endif - { - pr_info("++ 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 (cxt1e1_log_level >= LOG_MONITOR2) - pr_info("%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 (cxt1e1_log_level >= LOG_DEBUG) - pr_info("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; - } +#endif + { + pr_info("++ 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 (cxt1e1_log_level >= LOG_MONITOR2) + pr_info("%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 (cxt1e1_log_level >= LOG_DEBUG) + pr_info("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); + 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 (cxt1e1_log_level >= LOG_MONITOR2) - pr_info("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); + /************************************************************/ + /** flow control the line if not enough descriptors remain **/ + /************************************************************/ + if (txd_need_cnt > ch->txd_free) { + if (cxt1e1_log_level >= LOG_MONITOR2) + pr_info("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); + 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 */ + 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); + 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; + 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) { + /* + * 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; + /* 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)); + u |= (PADFILL_ENABLE | (ch->p.pad_fill_count << EXTRA_FLAGS)); + } + md->mem_token = len ? NULL : 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; } - md->mem_token = len ? NULL : 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 an ONR was seen, then channel requires poking to restart - * transmission. - */ - if (ch->ch_start_tx) - musycc_chan_restart(ch); + + + /* + * 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 an ONR was seen, then channel requires poking to restart + * transmission. + */ + if (ch->ch_start_tx) + musycc_chan_restart(ch); #ifdef SBE_WAN256T3_ENABLE - wan256t3_led(ci, LED_TX, LEDV_G); + wan256t3_led(ci, LED_TX, LEDV_G); #endif - return 0; + return 0; } -- cgit v1.2.3 From b7923d2215036bc81214818d33352982eaaa7567 Mon Sep 17 00:00:00 2001 From: Daeseok Youn Date: Fri, 9 May 2014 23:54:08 +0900 Subject: staging: cxt1e1: remove dead code in musycc.c Removes "#if 0" blocks. And the musycc_dump_rxbuffer_ring(ch, 0) which is commented out puts in RLD_DEBUG block and uncommented. Because this function may be used for debugging. Signed-off-by: Daeseok Youn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cxt1e1/musycc.c | 136 ++-------------------------------------- 1 file changed, 5 insertions(+), 131 deletions(-) diff --git a/drivers/staging/cxt1e1/musycc.c b/drivers/staging/cxt1e1/musycc.c index 2ddf88982a7a..91fab77e5115 100644 --- a/drivers/staging/cxt1e1/musycc.c +++ b/drivers/staging/cxt1e1/musycc.c @@ -64,7 +64,6 @@ void musycc_update_timeslots(mpi_t *); /*******************************************************************/ -#if 1 static int musycc_dump_rxbuffer_ring(mch_t *ch, int lockit) { @@ -128,9 +127,7 @@ musycc_dump_rxbuffer_ring(mch_t *ch, int lockit) spin_unlock_irqrestore(&ch->ch_rxlock, flags); return 0; } -#endif -#if 1 static int musycc_dump_txbuffer_ring(mch_t *ch, int lockit) { @@ -188,8 +185,6 @@ musycc_dump_txbuffer_ring(mch_t *ch, int lockit) spin_unlock_irqrestore(&ch->ch_txlock, flags); return 0; } -#endif - /* * The following supports a backdoor debug facility which can be used to @@ -340,9 +335,6 @@ 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; @@ -391,22 +383,14 @@ musycc_wq_chan_restart(void *arg) /* channel private structure */ /* 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 pr_info("-- 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 pr_info("++ 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); @@ -421,9 +405,6 @@ musycc_wq_chan_restart(void *arg) /* channel private structure */ 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 } @@ -831,12 +812,6 @@ 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]; @@ -849,13 +824,6 @@ musycc_bh_tx_eom(mpi_t *pi, int gchan) 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; @@ -993,13 +961,6 @@ musycc_bh_tx_eom(mpi_t *pi, int gchan) #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 } @@ -1181,11 +1142,6 @@ musycc_intr_th_handler(void *devp) * 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 */ - pr_info(">> %s: intCnt NULL, sts %x, possibly a chained interrupt!\n", - ci->devname, status); -#endif return IRQ_NONE; } @@ -1360,15 +1316,11 @@ musycc_intr_bh_tasklet(ci_t *ci) 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++; @@ -1444,7 +1396,9 @@ musycc_intr_bh_tasklet(ci_t *ci) if (cxt1e1_log_level >= LOG_WARN) { pr_info("%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 */ +#ifdef RLD_DEBUG + musycc_dump_rxbuffer_ring(ch, 0); +#endif } } musycc_chan_restart(ch); @@ -1511,35 +1465,6 @@ musycc_intr_bh_tasklet(ci_t *ci) /* 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) @@ -1592,52 +1517,12 @@ musycc_chan_down(ci_t *dummy, int channum) } #endif - -#if 0 -/* TODO: determine if these functions will not be needed and can be removed */ -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; - ch = sd_find_chan(ci, channum); - if (!ch) - 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; - ch = sd_find_chan(ci, channum); - if (!ch) - return ENOENT; - - memset(&ch->s, 0, sizeof(struct sbecom_chan_stats)); - return 0; -} -#endif - - 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; @@ -1694,9 +1579,7 @@ musycc_start_xmit(ci_t *ci, int channum, void *mem_token) 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 **/ /************************************************************/ @@ -1707,9 +1590,6 @@ musycc_start_xmit(ci_t *ci, int channum, void *mem_token) 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 */ } /**************************************************/ @@ -1748,12 +1628,6 @@ musycc_start_xmit(ci_t *ci, int channum, void *mem_token) /* 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 ? NULL : mem_token; /* Fill in mds on last -- cgit v1.2.3 From 79cefa55a07d2abb5be6a6dcceb94e001824aef3 Mon Sep 17 00:00:00 2001 From: Daeseok Youn Date: Fri, 9 May 2014 19:08:59 +0900 Subject: staging: cxt1e1: remove redundant curly braces in musycc.c Signed-off-by: Daeseok Youn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cxt1e1/musycc.c | 209 ++++++++++++++++++++-------------------- 1 file changed, 102 insertions(+), 107 deletions(-) diff --git a/drivers/staging/cxt1e1/musycc.c b/drivers/staging/cxt1e1/musycc.c index 91fab77e5115..7a793c3d7389 100644 --- a/drivers/staging/cxt1e1/musycc.c +++ b/drivers/staging/cxt1e1/musycc.c @@ -73,6 +73,10 @@ musycc_dump_rxbuffer_ring(mch_t *ch, int lockit) u_int32_t status; int n; +#ifdef RLD_DUMP_BUFDATA + u_int32_t *dp; + int len = 0; +#endif if (lockit) spin_lock_irqsave(&ch->ch_rxlock, flags); if (ch->rxd_num == 0) @@ -82,45 +86,40 @@ musycc_dump_rxbuffer_ring(mch_t *ch, int lockit) m = &ch->mdr[ch->rxix_irq_srv]; for (n = ch->rxd_num; n; n--) { status = le32_to_cpu(m->status); - { - pr_info("%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)); + pr_info("%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; + len = status & LENGTH_MASK; #if 1 - if (m->data && (status & HOST_RX_OWNED)) + if (m->data && (status & HOST_RX_OWNED)) #else - if (m->data) /* always dump regardless of valid RX - * data */ + 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) - pr_info(" %x[%x]: %08X %08X %08X %08x\n", (u_int32_t) dp, len, - *dp, *(dp + 1), *(dp + 2), *(dp + 3)); - else if (len >= 0x08) - pr_info(" %x[%x]: %08X %08X\n", (u_int32_t) dp, len, - *dp, *(dp + 1)); - else - pr_info(" %x[%x]: %08X\n", (u_int32_t) dp, len, *dp); - } + { + dp = (u_int32_t *) OS_phystov((void *) (le32_to_cpu(m->data))); + if (len >= 0x10) + pr_info(" %x[%x]: %08X %08X %08X %08x\n", (u_int32_t) dp, len, + *dp, *(dp + 1), *(dp + 2), *(dp + 3)); + else if (len >= 0x08) + pr_info(" %x[%x]: %08X %08X\n", (u_int32_t) dp, len, + *dp, *(dp + 1)); + else + pr_info(" %x[%x]: %08X\n", (u_int32_t) dp, len, *dp); } #endif - } m = m->snext; } - } /* -for- */ + } pr_info("\n"); if (lockit) @@ -135,6 +134,10 @@ musycc_dump_txbuffer_ring(mch_t *ch, int lockit) unsigned long flags = 0; u_int32_t status; int n; +#ifdef RLD_DUMP_BUFDATA + u_int32_t *dp; + int len = 0; +#endif if (lockit) spin_lock_irqsave(&ch->ch_txlock, flags); @@ -145,37 +148,32 @@ musycc_dump_txbuffer_ring(mch_t *ch, int lockit) m = ch->txd_irq_srv; for (n = ch->txd_num; n; n--) { status = le32_to_cpu(m->status); - { - pr_info("%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)); + pr_info("%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) - pr_info(" %x[%x]: %08X %08X %08X %08x\n", (u_int32_t) dp, len, - *dp, *(dp + 1), *(dp + 2), *(dp + 3)); - else if (len >= 0x08) - pr_info(" %x[%x]: %08X %08X\n", (u_int32_t) dp, len, - *dp, *(dp + 1)); - else - pr_info(" %x[%x]: %08X\n", (u_int32_t) dp, len, *dp); - } - } -#endif + len = status & LENGTH_MASK; + + if (m->data) { + dp = (u_int32_t *) OS_phystov((void *) (le32_to_cpu(m->data))); + if (len >= 0x10) + pr_info(" %x[%x]: %08X %08X %08X %08x\n", (u_int32_t) dp, len, + *dp, *(dp + 1), *(dp + 2), *(dp + 3)); + else if (len >= 0x08) + pr_info(" %x[%x]: %08X %08X\n", (u_int32_t) dp, len, + *dp, *(dp + 1)); + else + pr_info(" %x[%x]: %08X\n", (u_int32_t) dp, len, *dp); } +#endif m = m->snext; } } /* -for- */ @@ -195,21 +193,19 @@ status_t musycc_dump_ring(ci_t *ci, unsigned int chan) { mch_t *ch; + int bh; if (chan >= MAX_CHANS_USED) return SBE_DRVR_FAIL; /* E2BIG */ - { - int bh; - bh = atomic_read(&ci->bh_pending); - pr_info(">> 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 */ - } + bh = atomic_read(&ci->bh_pending); + pr_info(">> 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 */ ch = sd_find_chan(dummy, chan); if (!ch) { @@ -336,6 +332,10 @@ musycc_wq_chan_restart(void *arg) /* channel private structure */ mpi_t *pi; struct mdesc *md; +#if defined(RLD_TRANS_DEBUG) || defined(RLD_RXACT_DEBUG) + static int hereb4 = 7; +#endif + ch = container_of(arg, struct c4_chan_info, ch_work); pi = ch->up; @@ -353,24 +353,20 @@ musycc_wq_chan_restart(void *arg) /* channel private structure */ ch->ch_start_rx = 0; #if defined(RLD_TRANS_DEBUG) || defined(RLD_RXACT_DEBUG) - { - static int hereb4 = 7; - - if (hereb4) { /* RLD DEBUG */ - hereb4--; + if (hereb4) { /* RLD DEBUG */ + hereb4--; #ifdef RLD_TRANS_DEBUG - md = &ch->mdr[ch->rxix_irq_srv]; - pr_info("++ 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); + md = &ch->mdr[ch->rxix_irq_srv]; + pr_info("++ 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]; - pr_info("++ 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 */ + md = &ch->mdr[ch->rxix_irq_srv]; + pr_info("++ 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); @@ -877,6 +873,9 @@ musycc_bh_tx_eom(mpi_t *pi, int gchan) md->data = 0; if (md->mem_token) { +#ifdef CONFIG_SBE_WAN256T3_NCOMM + int hdlcnum = 0; +#endif /* upcount channel */ atomic_sub(OS_mem_token_tlen(md->mem_token), &ch->tx_pending); /* upcount card */ @@ -888,14 +887,12 @@ musycc_bh_tx_eom(mpi_t *pi, int gchan) #ifdef CONFIG_SBE_WAN256T3_NCOMM /* callback that our packet was sent */ - { - int hdlcnum = (pi->portnum * 32 + gchan); + hdlcnum = (pi->portnum * 32 + gchan); - if (hdlcnum >= 228) { - if (nciProcess_TX_complete) - (*nciProcess_TX_complete) (hdlcnum, - getuserbychan(gchan)); - } + if (hdlcnum >= 228) { + if (nciProcess_TX_complete) + (*nciProcess_TX_complete) (hdlcnum, + getuserbychan(gchan)); } #endif /*** CONFIG_SBE_WAN256T3_NCOMM ***/ @@ -1361,26 +1358,24 @@ musycc_intr_bh_tasklet(ci_t *ci) */ ch->ch_start_tx = CH_START_TX_ONR; - { #ifdef RLD_TRANS_DEBUG - if (1 || cxt1e1_log_level >= LOG_MONITOR) + if (1 || cxt1e1_log_level >= LOG_MONITOR) #else - if (cxt1e1_log_level >= LOG_MONITOR) + if (cxt1e1_log_level >= LOG_MONITOR) #endif - { - pr_info("%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); + { + pr_info("%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 */ - pr_info("++ 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 + if (ch->p.chan_mode == 2) { /* problem = ONR on HDLC + * mode */ + pr_info("++ 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 */ /* -- cgit v1.2.3 From a38223f4c1c0ae5d7448bb49addc6ad499c46442 Mon Sep 17 00:00:00 2001 From: Daeseok Youn Date: Fri, 9 May 2014 19:09:35 +0900 Subject: staging: cxt1e1: Fix line length over 80 characters in musycc.c clean up checkpatch.pl warning: WARNING: Line length over 80 characters Signed-off-by: Daeseok Youn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cxt1e1/musycc.c | 312 +++++++++++++++++++++++++--------------- 1 file changed, 196 insertions(+), 116 deletions(-) diff --git a/drivers/staging/cxt1e1/musycc.c b/drivers/staging/cxt1e1/musycc.c index 7a793c3d7389..c086c60338e1 100644 --- a/drivers/staging/cxt1e1/musycc.c +++ b/drivers/staging/cxt1e1/musycc.c @@ -102,19 +102,24 @@ musycc_dump_rxbuffer_ring(mch_t *ch, int lockit) #if 1 if (m->data && (status & HOST_RX_OWNED)) #else - if (m->data) /* always dump regardless of valid RX - * data */ + /* always dump regardless of valid RX data */ + if (m->data) #endif { - dp = (u_int32_t *) OS_phystov((void *) (le32_to_cpu(m->data))); + dp = (u_int32_t *)OS_phystov((void *)(le32_to_cpu(m->data))); if (len >= 0x10) - pr_info(" %x[%x]: %08X %08X %08X %08x\n", (u_int32_t) dp, len, - *dp, *(dp + 1), *(dp + 2), *(dp + 3)); + pr_info(" %x[%x]: %08X %08X %08X %08x\n", + (u_int32_t)dp, len, + *dp, *(dp + 1), + *(dp + 2), *(dp + 3)); else if (len >= 0x08) - pr_info(" %x[%x]: %08X %08X\n", (u_int32_t) dp, len, + pr_info(" %x[%x]: %08X %08X\n", + (u_int32_t)dp, len, *dp, *(dp + 1)); else - pr_info(" %x[%x]: %08X\n", (u_int32_t) dp, len, *dp); + pr_info(" %x[%x]: %08X\n", + (u_int32_t)dp, + len, *dp); } #endif m = m->snext; @@ -163,15 +168,19 @@ musycc_dump_txbuffer_ring(mch_t *ch, int lockit) len = status & LENGTH_MASK; if (m->data) { - dp = (u_int32_t *) OS_phystov((void *) (le32_to_cpu(m->data))); + dp = (u_int32_t *)OS_phystov((void *)(le32_to_cpu(m->data))); if (len >= 0x10) - pr_info(" %x[%x]: %08X %08X %08X %08x\n", (u_int32_t) dp, len, - *dp, *(dp + 1), *(dp + 2), *(dp + 3)); + pr_info(" %x[%x]: %08X %08X %08X %08x\n", + (u_int32_t) dp, len, + *dp, *(dp + 1), + *(dp + 2), *(dp + 3)); else if (len >= 0x08) - pr_info(" %x[%x]: %08X %08X\n", (u_int32_t) dp, len, + pr_info(" %x[%x]: %08X %08X\n", + (u_int32_t)dp, len, *dp, *(dp + 1)); else - pr_info(" %x[%x]: %08X\n", (u_int32_t) dp, len, *dp); + pr_info(" %x[%x]: %08X\n", + (u_int32_t)dp, len, *dp); } #endif m = m->snext; @@ -212,11 +221,15 @@ musycc_dump_ring(ci_t *ci, unsigned int chan) pr_info(">> musycc_dump_ring: channel %d not up.\n", chan); return ENOENT; } - pr_info(">> CI %p CHANNEL %3d @ %p: state %x status/p %x/%x\n", ci, chan, ch, ch->state, + pr_info(">> CI %p CHANNEL %3d @ %p: state %x status/p %x/%x\n", + ci, chan, ch, ch->state, ch->status, ch->p.status); - pr_info("--------------------------------\nTX Buffer Ring - Channel %d, txd_num %d. (bd/ch pend %d %d), TXD required %d, txpkt %lu\n", + pr_info("--------------------------------\n"); + pr_info("TX 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); + (u_int32_t)atomic_read(&ci->tx_pending), + (u_int32_t)atomic_read(&ch->tx_pending), + ch->txd_required, ch->s.tx_packets); pr_info("++ 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), @@ -311,7 +324,8 @@ musycc_update_tx_thp(mch_t *ch) spin_unlock_irqrestore(&ch->ch_txlock, flags); #ifdef RLD_TRANS_DEBUG - pr_info("++ musycc_update_tx_thp[%d]: setting thp = %p, sts %x\n", ch->channum, md, md->status); + pr_info("++ musycc_update_tx_thp[%d]: setting thp = %p, sts %x\n", + ch->channum, md, md->status); #endif } @@ -358,18 +372,20 @@ musycc_wq_chan_restart(void *arg) /* channel private structure */ #ifdef RLD_TRANS_DEBUG md = &ch->mdr[ch->rxix_irq_srv]; pr_info("++ 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); + 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]; pr_info("++ 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->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); + musycc_serv_req(pi, SR_CHANNEL_ACTIVATE | + SR_RX_DIRECTION | ch->gchan); } /**********************************/ /** check for TX restart request **/ @@ -382,16 +398,20 @@ musycc_wq_chan_restart(void *arg) /* channel private structure */ md = ch->txd_irq_srv; if (!md) { #ifdef RLD_TRANS_DEBUG - pr_info("-- musycc_wq_chan_restart[%d]: WARNING, starting NULL md\n", ch->channum); + pr_info("-- musycc_wq_chan_restart[%d]: WARNING, starting NULL md\n", + ch->channum); #endif - } else if (md->data && ((le32_to_cpu(md->status)) & MUSYCC_TX_OWNED)) { + } else if (md->data && ((le32_to_cpu(md->status)) & + MUSYCC_TX_OWNED)) { ch->ch_start_tx = 0; #ifdef RLD_TRANS_DEBUG pr_info("++ 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); + 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); + musycc_serv_req(pi, SR_CHANNEL_ACTIVATE | + SR_TX_DIRECTION | ch->gchan); } #ifdef RLD_RESTART_DEBUG else { @@ -422,7 +442,8 @@ musycc_chan_restart(mch_t *ch) /* 2.6 - find next unprocessed message, then set TX thp to it */ #ifdef RLD_RESTART_DEBUG - pr_info(">> musycc_chan_restart: scheduling Chan %x workQ @ %p\n", ch->channum, &ch->ch_work); + pr_info(">> 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 () */ @@ -439,7 +460,8 @@ rld_put_led(mpi_t *pi, u_int32_t ledval) else led |= ledval; - pci_write_32((u_int32_t *) &pi->up->cpldbase->leds, led); /* RLD DEBUG TRANHANG */ + /* RLD DEBUG TRANHANG */ + pci_write_32((u_int32_t *) &pi->up->cpldbase->leds, led); } @@ -481,16 +503,21 @@ musycc_serv_req(mpi_t *pi, u_int32_t req) #ifdef RLD_TRANS_DEBUG pr_info(">> 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 */ + /* allow this next request */ + SD_SEM_GIVE(&pi->sr_sem_busy); musycc_serv_req(pi, SR_NOOP); - SD_SEM_TAKE(&pi->sr_sem_busy, "serv"); /* relock & continue w/ - * original req */ + /* relock & continue w/ original req */ + SD_SEM_TAKE(&pi->sr_sem_busy, "serv"); } else if (req == SR_NOOP) { - /* no need to issue back-to-back SR_NOOP commands at this time */ + /* no need to issue back-to-back + * SR_NOOP commands at this time + */ #ifdef RLD_TRANS_DEBUG - pr_info(">> same Port SR_NOOP skipped, Port %d\n", pi->portnum); + pr_info(">> same Port SR_NOOP skipped, Port %d\n", + pi->portnum); #endif - SD_SEM_GIVE(&pi->sr_sem_busy); /* allow this next request */ + /* allow this next request */ + SD_SEM_GIVE(&pi->sr_sem_busy); return; } } @@ -508,22 +535,27 @@ rewrite: * 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 */ + + /* adhere to write timing imposition */ + r = pci_read_32((u_int32_t *) &pi->reg->srd); - if ((r != req) && (req != SR_CHIP_RESET) && (++rcnt <= MUSYCC_SR_RETRY_CNT)) { + if ((r != req) && (req != SR_CHIP_RESET) && + (++rcnt <= MUSYCC_SR_RETRY_CNT)) { if (cxt1e1_log_level >= LOG_MONITOR) pr_info("%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) */ + /* this delay helps reduce reissue counts + * (reason not yet researched) + */ + OS_uwait_dummy(); goto rewrite; } if (rcnt > MUSYCC_SR_RETRY_CNT) { pr_warning("%s: failed service request (#%d)= %x, group %d.\n", - pi->up->devname, MUSYCC_SR_RETRY_CNT, req, pi->portnum); + pi->up->devname, MUSYCC_SR_RETRY_CNT, + req, pi->portnum); SD_SEM_GIVE(&pi->sr_sem_busy); /* allow any next request */ return; } @@ -538,8 +570,8 @@ rewrite: OS_uwait(100000, "icard"); /* 100ms */ } else { FLUSH_MEM_READ(); - SD_SEM_TAKE(&pi->sr_sem_wait, "sakack"); /* sleep until SACK - * interrupt occurs */ + /* sleep until SACK interrupt occurs */ + SD_SEM_TAKE(&pi->sr_sem_wait, "sakack"); } SD_SEM_GIVE(&pi->sr_sem_busy); /* allow any next request */ } @@ -558,15 +590,19 @@ musycc_update_timeslots(mpi_t *pi) 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 */ + ((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 */ + /* make tslot unavailable for this mode */ + pi->tsm[i] = 0xff; else - pi->tsm[i] = 0x00; /* make tslot available for assignment */ + /* make tslot available for assignment */ + pi->tsm[i] = 0x00; 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])) { + if ((pi->chan[ch]->state == UP) && + (pi->chan[ch]->p.bitmask[i])) { usedby++; last = ch; lastval = pi->chan[ch]->p.bitmask[i]; @@ -590,8 +626,10 @@ musycc_update_timeslots(mpi_t *pi) 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->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; @@ -624,7 +662,8 @@ musycc_update_timeslots(mpi_t *pi) hmask = (0x1f << hyperdummy) & 0x1f; #endif for (i = 0; i < 128; i++) { - gchan = ((pi->portnum * MUSYCC_NCHANS) + (i & hmask)) % MUSYCC_NCHANS; + gchan = ((pi->portnum * MUSYCC_NCHANS) + + (i & hmask)) % MUSYCC_NCHANS; ch = pi->chan[gchan]; if (ch->p.mode_56k) tsen = MODE_56KBPS; @@ -711,7 +750,7 @@ 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 */ + OS_sem_init(&ci->sem_wdbusy, SEM_AVAILABLE); /* watchdog exclusion */ /* * Per MUSYCC manual, Section 6.3.4 - "The host must allocate a dword @@ -725,9 +764,9 @@ musycc_init(ci_t *ci) if (!regaddr) 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 */ + /* this calculates closest boundary */ + ci->iqd_p = (u_int32_t *) ((unsigned long)(regaddr + INT_QUEUE_BOUNDARY - 1) & + (~(INT_QUEUE_BOUNDARY - 1))); for (i = 0; i < INT_QUEUE_SIZE; i++) ci->iqd_p[i] = __constant_cpu_to_le32(INT_EMPTY_ENTRY); @@ -753,9 +792,9 @@ musycc_init(ci_t *ci) 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 */ + /* this calculates closest boundary */ + pi->regram = (struct musycc_groupr *) ((unsigned long)(regaddr + GROUP_BOUNDARY - 1) & + (~(GROUP_BOUNDARY - 1))); } /* any board centric MUSYCC commands will use group ZERO as its "home" */ @@ -768,7 +807,8 @@ musycc_init(ci_t *ci) 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); + 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])); @@ -779,7 +819,7 @@ musycc_init(ci_t *ci) ci->state = C_RUNNING; /* mark as full interrupt processing * available */ - musycc_serv_req(&ci->port[0], SR_GLOBAL_INIT); /* FIRST INTERRUPT ! */ + musycc_serv_req(&ci->port[0], SR_GLOBAL_INIT); /* FIRST INTERRUPT ! */ /* sanity check settable parameters */ @@ -844,42 +884,49 @@ musycc_bh_tx_eom(mpi_t *pi, int gchan) 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 */ + /* use call to avoid optimization + * removal of dummy delay */ + OS_uwait_dummy(); FLUSH_MEM_READ(); status = le32_to_cpu(md->status); if (readCount++ > 40) - break; /* don't wait any longer */ + break; /* don't wait any longer */ } if (status & MUSYCC_TX_OWNED) { if (cxt1e1_log_level >= LOG_MONITOR) { pr_info("%s: Port %d Chan %2d - unexpected TX msg ownership intr (md %p sts %x)\n", - pi->up->devname, pi->portnum, ch->channum, - md, status); + pi->up->devname, pi->portnum, + ch->channum, md, status); pr_info("++ 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, + 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); + 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 (cxt1e1_log_level >= LOG_MONITOR) pr_info("%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); + pi->up->devname, pi->portnum, + ch->channum, readCount, + md, status); } } ch->txd_irq_srv = md->snext; md->data = 0; - if (md->mem_token) { + if (md->mem_token) { #ifdef CONFIG_SBE_WAN256T3_NCOMM int hdlcnum = 0; #endif /* upcount channel */ - atomic_sub(OS_mem_token_tlen(md->mem_token), &ch->tx_pending); + 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); + 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); @@ -894,7 +941,7 @@ musycc_bh_tx_eom(mpi_t *pi, int gchan) (*nciProcess_TX_complete) (hdlcnum, getuserbychan(gchan)); } -#endif /*** CONFIG_SBE_WAN256T3_NCOMM ***/ +#endif /* CONFIG_SBE_WAN256T3_NCOMM */ OS_mem_token_free_irq(md->mem_token); md->mem_token = NULL; @@ -908,14 +955,17 @@ musycc_bh_tx_eom(mpi_t *pi, int gchan) ++ch->txd_free; FLUSH_MEM_WRITE(); - if ((ch->p.chan_mode != CFG_CH_PROTO_TRANS) && (status & EOBIRQ_ENABLE)) { + if ((ch->p.chan_mode != CFG_CH_PROTO_TRANS) && + (status & EOBIRQ_ENABLE)) { if (cxt1e1_log_level >= LOG_MONITOR) pr_info("%s: Mode (%x) incorrect EOB status (%x)\n", - pi->up->devname, ch->p.chan_mode, status); + 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)); + } 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 @@ -944,8 +994,8 @@ musycc_bh_tx_eom(mpi_t *pi, int gchan) #endif ch->tx_full = 0; ch->txd_required = 0; - sd_enable_xmit(ch->user); /* re-enable to catch flow controlled - * channel */ + /* re-enable to catch flow controlled channel */ + sd_enable_xmit(ch->user); } } #ifdef RLD_TXFULL_DEBUG @@ -998,7 +1048,9 @@ musycc_bh_rx_eom(mpi_t *pi, int gchan) */ if (hdlcnum >= 228) { if (nciProcess_RX_packet) - (*nciProcess_RX_packet) (hdlcnum, status & 0x3fff, m, ch->user); + (*nciProcess_RX_packet)(hdlcnum, + status & 0x3fff, + m, ch->user); } else #endif /*** CONFIG_SBE_WAN256T3_NCOMM ***/ @@ -1011,7 +1063,8 @@ musycc_bh_rx_eom(mpi_t *pi, int gchan) OS_mem_token_data(m2))); /* pass the received mbuf upward */ - sd_recv_consume(m, status & LENGTH_MASK, ch->user); + sd_recv_consume(m, status & LENGTH_MASK, + ch->user); ch->s.rx_packets++; ch->s.rx_bytes += status & LENGTH_MASK; } else @@ -1092,7 +1145,8 @@ musycc_intr_th_handler(void *devp) if (cxt1e1_log_level >= LOG_MONITOR) { pr_info("%s: note - updated ISD from %08x to %08x\n", ci->devname, status, - (status & (~INTRPTS_NEXTINT_M)) | ci->intlog.this_status_new); + (status & (~INTRPTS_NEXTINT_M)) | + ci->intlog.this_status_new); } /* * Replace bogus status with software corrected value. @@ -1100,7 +1154,8 @@ musycc_intr_th_handler(void *devp) * 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); + status = (status & (~INTRPTS_NEXTINT_M)) | + (ci->intlog.this_status_new); nextInt = INTRPTS_NEXTINT(status); } /**********************************************/ @@ -1149,11 +1204,13 @@ musycc_intr_th_handler(void *devp) ci->intlog.this_status_new = currInt; if ((cxt1e1_log_level >= LOG_WARN) && (status & INTRPTS_INTFULL_M)) - pr_info("%s: Interrupt queue full condition occurred\n", ci->devname); + pr_info("%s: Interrupt queue full condition occurred\n", + ci->devname); if (cxt1e1_log_level >= LOG_DEBUG) pr_info("%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)); + status, nextInt, intCnt, + (intCnt + nextInt) & (INT_QUEUE_SIZE - 1)); FLUSH_MEM_WRITE(); #if defined(SBE_ISR_TASKLET) @@ -1242,16 +1299,18 @@ musycc_intr_bh_tasklet(ci_t *ci) while ((currInt == badInt) || (currInt == badInt2)) { for (loopCount = 0; loopCount < 0x30; loopCount++) - OS_uwait_dummy(); /* use call to avoid optimization removal - * of dummy delay */ + /* use call to avoid optimization + * removal of dummy delay + */ + OS_uwait_dummy(); 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 */ + /* catch failure of Bug Fix checking */ + if ((currInt == badInt) || (currInt == badInt2)) { if (cxt1e1_log_level >= LOG_WARN) pr_info("%s: Illegal Interrupt Detected @ 0x%p, mod %d.)\n", ci->devname, &ci->iqd_p[headx], headx); @@ -1270,7 +1329,8 @@ musycc_intr_bh_tasklet(ci_t *ci) 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 */ + /* insure wrapness */ + ci->iqp_headx = (headx + 1) & (INT_QUEUE_SIZE - 1); FLUSH_MEM_WRITE(); FLUSH_MEM_READ(); continue; @@ -1291,8 +1351,8 @@ musycc_intr_bh_tasklet(ci_t *ci) pr_info("+ 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 */ + /* notice that here we assume 1-1 group - port mapping */ + pi = &ci->port[group]; ch = pi->chan[gchan]; switch (event) { case EVE_SACK: /* Service Request Acknowledge */ @@ -1300,15 +1360,17 @@ musycc_intr_bh_tasklet(ci_t *ci) volatile u_int32_t r; r = pci_read_32((u_int32_t *) &pi->reg->srd); - pr_info("- SACK cmd: %08x (hdw= %08x)\n", pi->sr_last, r); + pr_info("- SACK cmd: %08x (hdw= %08x)\n", + pi->sr_last, r); } - SD_SEM_GIVE(&pi->sr_sem_wait); /* wake up waiting process */ + /* wake up waiting process */ + SD_SEM_GIVE(&pi->sr_sem_wait); break; - case EVE_CHABT: /* Change To Abort Code (0x7e -> 0xff) */ - case EVE_CHIC: /* Change To Idle Code (0xff -> 0x7e) */ + 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) */ + case EVE_EOM: /* End Of Message */ + case EVE_EOB: /* End Of Buffer (Transparent mode) */ if (tx) musycc_bh_tx_eom(pi, gchan); else @@ -1365,14 +1427,21 @@ musycc_intr_bh_tasklet(ci_t *ci) #endif { pr_info("%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); + 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 */ + /* problem = ONR on HDLC mode */ + if (ch->p.chan_mode == 2) { pr_info("++ 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, + (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); + ch->ch_start_tx, + ch->tx_full, + ch->txd_free, + ch->p.chan_mode); musycc_dump_txbuffer_ring(ch, 0); } #endif @@ -1390,7 +1459,8 @@ musycc_intr_bh_tasklet(ci_t *ci) if (cxt1e1_log_level >= LOG_WARN) { pr_info("%s: RX buffer overflow [ONR] on channel %d, mode %x\n", - ci->devname, ch->channum, ch->p.chan_mode); + ci->devname, ch->channum, + ch->p.chan_mode); #ifdef RLD_DEBUG musycc_dump_rxbuffer_ring(ch, 0); #endif @@ -1408,7 +1478,8 @@ musycc_intr_bh_tasklet(ci_t *ci) */ if (cxt1e1_log_level >= LOG_MONITOR) pr_info("%s: TX buffer underrun [BUFF] on channel %d, mode %x\n", - ci->devname, ch->channum, ch->p.chan_mode); + ci->devname, ch->channum, + ch->p.chan_mode); } else { /* RX buffer overrun */ ch->s.rx_over_errors++; /* @@ -1420,7 +1491,8 @@ musycc_intr_bh_tasklet(ci_t *ci) */ if (cxt1e1_log_level >= LOG_WARN) pr_info("%s: RX buffer overrun [BUFF] on channel %d, mode %x\n", - ci->devname, ch->channum, ch->p.chan_mode); + 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 @@ -1440,14 +1512,17 @@ musycc_intr_bh_tasklet(ci_t *ci) } /* switch on err */ /* Check for interrupt lost condition */ - if ((currInt & INTRPT_ILOST_M) && (cxt1e1_log_level >= LOG_ERROR)) + if ((currInt & INTRPT_ILOST_M) && + (cxt1e1_log_level >= LOG_ERROR)) pr_info("%s: Interrupt queue overflow - ILOST asserted\n", ci->devname); - ci->iqp_headx = (headx + 1) & (INT_QUEUE_SIZE - 1); /* insure wrapness */ + /* insure wrapness */ + ci->iqp_headx = (headx + 1) & (INT_QUEUE_SIZE - 1); FLUSH_MEM_WRITE(); FLUSH_MEM_READ(); } /* while */ - if ((cxt1e1_log_level >= LOG_MONITOR2) && (ci->iqp_headx != ci->iqp_tailx)) { + if ((cxt1e1_log_level >= LOG_MONITOR2) && + (ci->iqp_headx != ci->iqp_tailx)) { int bh; bh = atomic_read(&CI->bh_pending); @@ -1525,13 +1600,15 @@ musycc_start_xmit(ci_t *ci, int channum, void *mem_token) if (!ch) return -ENOENT; - if (ci->state != C_RUNNING) /* full interrupt processing available */ + /* full interrupt processing available */ + if (ci->state != C_RUNNING) return -EINVAL; if (ch->state != UP) return -EINVAL; + /* how else to flag unwritable state ? */ if (!(ch->status & TX_ENABLED)) - return -EROFS; /* how else to flag unwritable state ? */ + return -EROFS; #ifdef RLD_TRANS_DEBUG if (1 || cxt1e1_log_level >= LOG_MONITOR2) @@ -1541,7 +1618,8 @@ musycc_start_xmit(ci_t *ci, int channum, void *mem_token) { pr_info("++ 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)); + ch->txd_free, ch->txd_required, + sd_queue_stopped(ch->user)); } /***********************************************/ /** Determine total amount of data to be sent **/ @@ -1558,7 +1636,8 @@ musycc_start_xmit(ci_t *ci, int channum, void *mem_token) if (txd_need_cnt == 0) { if (cxt1e1_log_level >= LOG_MONITOR2) - pr_info("%s channel %d: no TX data in User buffer\n", ci->devname, channum); + pr_info("%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 */ } @@ -1581,7 +1660,8 @@ musycc_start_xmit(ci_t *ci, int channum, void *mem_token) if (txd_need_cnt > ch->txd_free) { if (cxt1e1_log_level >= LOG_MONITOR2) pr_info("start_xmit[%d]: EBUSY - need more descriptors, have %d of %d need %d\n", - channum, ch->txd_free, ch->txd_num, txd_need_cnt); + 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); @@ -1605,7 +1685,8 @@ musycc_start_xmit(ci_t *ci, int channum, void *mem_token) * 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 */ + /* transfer ownership from HOST to MUSYCC */ + u |= MUSYCC_TX_OWNED; if (len) /* not last chunk */ u |= EOBIRQ_ENABLE; @@ -1625,12 +1706,11 @@ musycc_start_xmit(ci_t *ci, int channum, void *mem_token) if (ch->p.pad_fill_count) { u |= (PADFILL_ENABLE | (ch->p.pad_fill_count << EXTRA_FLAGS)); } - md->mem_token = len ? NULL : mem_token; /* Fill in mds on last - * segment, others set ZERO - * so that entire token is - * removed ONLY when ALL - * segments have been - * transmitted. */ + /* Fill in mds on last segment, others set ZERO + * so that entire token is removed ONLY when ALL + * segments have been transmitted. + */ + md->mem_token = len ? NULL : mem_token; md->data = cpu_to_le32(OS_vtophys(OS_mem_token_data(m2))); FLUSH_MEM_WRITE(); -- cgit v1.2.3 From 1dd3cdc7ff3cc190b99be41ab01346ea2039189a Mon Sep 17 00:00:00 2001 From: Daeseok Youn Date: Fri, 9 May 2014 19:10:07 +0900 Subject: staging: cxt1e1: remove set a value to static variable cleanup checkpatch.pl error: ERROR: do not initialise statics to 0 or NULL Signed-off-by: Daeseok Youn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cxt1e1/musycc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/cxt1e1/musycc.c b/drivers/staging/cxt1e1/musycc.c index c086c60338e1..a87f80237f47 100644 --- a/drivers/staging/cxt1e1/musycc.c +++ b/drivers/staging/cxt1e1/musycc.c @@ -1,5 +1,5 @@ -static unsigned int max_intcnt = 0; -static unsigned int max_bh = 0; +static unsigned int max_intcnt; +static unsigned int max_bh; /*----------------------------------------------------------------------------- * musycc.c - @@ -453,7 +453,7 @@ musycc_chan_restart(mch_t *ch) void rld_put_led(mpi_t *pi, u_int32_t ledval) { - static u_int32_t led = 0; + static u_int32_t led; if (ledval == 0) led = 0; -- cgit v1.2.3 From ea3528c26a67bde111d0dd85fae474a559efce41 Mon Sep 17 00:00:00 2001 From: Fernando Apesteguia Date: Wed, 7 May 2014 18:02:44 +0200 Subject: staging: silicom: add blank line after declarations Add blank line after declarations and delete extra blank line at the beginning of the function Signed-off-by: Fernando Apesteguia Signed-off-by: Greg Kroah-Hartman --- drivers/staging/silicom/bpctl_mod.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/silicom/bpctl_mod.c b/drivers/staging/silicom/bpctl_mod.c index 7f3d884d4ddd..266becf84169 100644 --- a/drivers/staging/silicom/bpctl_mod.c +++ b/drivers/staging/silicom/bpctl_mod.c @@ -7448,8 +7448,8 @@ static int bypass_proc_create_dev_sd(struct bpctl_dev *pbp_device_block) static int bypass_proc_remove_dev_sd(struct bpctl_dev *pbp_device_block) { - struct bypass_pfs_sd *current_pfs = &pbp_device_block->bypass_pfs_set; + remove_proc_subtree(current_pfs->dir_name, bp_procfs_dir); current_pfs->bypass_entry = NULL; return 0; -- cgit v1.2.3 From 01cda8d380129f605f3f1cd69bdc98ec6cef44ad Mon Sep 17 00:00:00 2001 From: Christian Engelmayer Date: Wed, 7 May 2014 21:24:00 +0200 Subject: staging: silicom: Remove needless calls of get_status_port_fn() Remove a needless pointer initialisation and call to get_status_port_fn() in functions remove_bypass_tpl_auto() and set_tpl_fn(). Variable 'pbpctl_dev_b' is set correctly later in the function before first use. Signed-off-by: Christian Engelmayer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/silicom/bpctl_mod.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/silicom/bpctl_mod.c b/drivers/staging/silicom/bpctl_mod.c index 266becf84169..03b83b8c91cf 100644 --- a/drivers/staging/silicom/bpctl_mod.c +++ b/drivers/staging/silicom/bpctl_mod.c @@ -4735,10 +4735,9 @@ static void bp_tpl_timer_fn(unsigned long param) static void remove_bypass_tpl_auto(struct bpctl_dev *pbpctl_dev) { - struct bpctl_dev *pbpctl_dev_b = NULL; + struct bpctl_dev *pbpctl_dev_b; if (!pbpctl_dev) return; - pbpctl_dev_b = get_status_port_fn(pbpctl_dev); if (pbpctl_dev->bp_caps & TPL_CAP) { del_timer_sync(&pbpctl_dev->bp_tpl_timer); @@ -4785,12 +4784,10 @@ static int set_bypass_tpl_auto(struct bpctl_dev *pbpctl_dev, unsigned int param) static int set_tpl_fn(struct bpctl_dev *pbpctl_dev, int tpl_mode) { - struct bpctl_dev *pbpctl_dev_b = NULL; + struct bpctl_dev *pbpctl_dev_b; if (!pbpctl_dev) return -1; - pbpctl_dev_b = get_status_port_fn(pbpctl_dev); - if (pbpctl_dev->bp_caps & TPL_CAP) { if (tpl_mode) { pbpctl_dev_b = get_status_port_fn(pbpctl_dev); -- cgit v1.2.3 From 43b54cc91b5d13110a99ef65a981c8bec9e68328 Mon Sep 17 00:00:00 2001 From: Christian Engelmayer Date: Wed, 7 May 2014 21:26:43 +0200 Subject: staging: silicom: Remove unused pointer in bypass_init_module() Pointer 'pbpctl_dev_c' in function bypass_init_module() is unused. Thus remove it. With the last variable declaration gone, there is no more need for an own block. Remove it and adapt the indenting accordingly. Signed-off-by: Christian Engelmayer Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/silicom/bpctl_mod.c | 41 +++++++++++++++---------------------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/drivers/staging/silicom/bpctl_mod.c b/drivers/staging/silicom/bpctl_mod.c index 03b83b8c91cf..e361cde0ec69 100644 --- a/drivers/staging/silicom/bpctl_mod.c +++ b/drivers/staging/silicom/bpctl_mod.c @@ -6368,33 +6368,26 @@ static int __init bypass_init_module(void) sema_init(&bpctl_sema, 1); spin_lock_init(&bpvm_lock); - { - - struct bpctl_dev *pbpctl_dev_c = NULL; - for (idx_dev = 0, dev = bpctl_dev_arr; - idx_dev < device_num && dev->pdev; - idx_dev++, dev++) { - if (dev->bp_10g9) { - pbpctl_dev_c = get_status_port_fn(dev); - if (is_bypass_fn(dev)) { - printk(KERN_INFO "%s found, ", - dev->name); - dev->bp_fw_ver = bypass_fw_ver(dev); - printk("firmware version: 0x%x\n", - dev->bp_fw_ver); - } - dev->wdt_status = WDT_STATUS_UNKNOWN; - dev->reset_time = 0; - atomic_set(&dev->wdt_busy, 0); - dev->bp_status_un = 1; - - bypass_caps_init(dev); - - init_bypass_wd_auto(dev); - init_bypass_tpl_auto(dev); + for (idx_dev = 0, dev = bpctl_dev_arr; + idx_dev < device_num && dev->pdev; + idx_dev++, dev++) { + if (dev->bp_10g9) { + if (is_bypass_fn(dev)) { + printk(KERN_INFO "%s found, ", dev->name); + dev->bp_fw_ver = bypass_fw_ver(dev); + printk("firmware version: 0x%x\n", + dev->bp_fw_ver); } + dev->wdt_status = WDT_STATUS_UNKNOWN; + dev->reset_time = 0; + atomic_set(&dev->wdt_busy, 0); + dev->bp_status_un = 1; + + bypass_caps_init(dev); + init_bypass_wd_auto(dev); + init_bypass_tpl_auto(dev); } } -- cgit v1.2.3 From 8ea6cdf527aa4439604a4712ff2a35373471e367 Mon Sep 17 00:00:00 2001 From: Peter Senna Tschudin Date: Tue, 20 May 2014 12:33:45 +0200 Subject: staging: et131x: Remove useless return variables This patch remove variables that are initialized with a constant, are never updated, and are only used as parameter of return. Return the constant instead of using a variable. Verified by compilation only. The coccinelle script that find and fixes this issue is: // @@ type T; constant C; identifier ret; @@ - T ret = C; ... when != ret - return ret; + return C; // Signed-off-by: Peter Senna Tschudin Acked-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index d329cf314360..1ac718476edb 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -4237,7 +4237,6 @@ static int et131x_ioctl(struct net_device *netdev, struct ifreq *reqbuf, static int et131x_set_packet_filter(struct et131x_adapter *adapter) { int filter = adapter->packet_filter; - int status = 0; u32 ctrl; u32 pf_ctrl; @@ -4288,7 +4287,7 @@ static int et131x_set_packet_filter(struct et131x_adapter *adapter) writel(pf_ctrl, &adapter->regs->rxmac.pf_ctrl); writel(ctrl, &adapter->regs->rxmac.ctrl); } - return status; + return 0; } /* et131x_multicast - The handler to configure multicasting on the interface */ -- cgit v1.2.3 From f03fcca08c74b76f0a8686620e2a065d4ddfe4a1 Mon Sep 17 00:00:00 2001 From: Maarten de Jonge Date: Sun, 4 May 2014 19:26:51 +0200 Subject: staging: et131x: add blank lines after declarations Signed-off-by: Maarten de Jonge Acked-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et131x.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c index 1ac718476edb..0901ef5d6e8a 100644 --- a/drivers/staging/et131x/et131x.c +++ b/drivers/staging/et131x/et131x.c @@ -762,6 +762,7 @@ static int et131x_init_eeprom(struct et131x_adapter *adapter) */ if (eestatus & 0x4C) { int write_failed = 0; + if (pdev->revision == 0x01) { int i; static const u8 eedata[4] = { 0xFE, 0x13, 0x10, 0xFF }; @@ -2091,6 +2092,7 @@ static void et1310_disable_phy_coma(struct et131x_adapter *adapter) static inline u32 bump_free_buff_ring(u32 *free_buff_ring, u32 limit) { u32 tmp_free_buff_ring = *free_buff_ring; + tmp_free_buff_ring++; /* This works for all cases where limit < 1024. The 1023 case * works because 1023++ is 1024 which means the if condition is not -- cgit v1.2.3 From 788a8291374807c7fdbb303210876d044477215a Mon Sep 17 00:00:00 2001 From: Daniele Forsi Date: Sun, 27 Apr 2014 14:34:48 +0200 Subject: staging: et131x: Remove empty file Module.symvers It was added by commit e0349d5ba (staging: et131x: Remove unused rcv_pend_lock spinlock) Signed-off-by: Daniele Forsi Acked-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/Module.symvers | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 drivers/staging/et131x/Module.symvers diff --git a/drivers/staging/et131x/Module.symvers b/drivers/staging/et131x/Module.symvers deleted file mode 100644 index e69de29bb2d1..000000000000 -- cgit v1.2.3 From b44ab1b0df0a3d35ca31dca077c22ec545906626 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Mon, 28 Apr 2014 08:01:07 -0300 Subject: imx-hdmi: Make checkpatch happy WARNING: Missing a blank line after declarations #160: FILE: drivers/staging/imx-drm/imx-hdmi.c:160: + u8 val = hdmi_readb(hdmi, reg) & ~mask; + val |= data & mask; WARNING: Missing a blank line after declarations #1609: FILE: drivers/staging/imx-drm/imx-hdmi.c:1609: + const struct platform_device_id *device_id = of_id->data; + hdmi->dev_type = device_id->driver_data; total: 0 errors, 2 warnings, 1767 lines checked drivers/staging/imx-drm/imx-hdmi.c has style problems, please review. If any of these errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. Signed-off-by: Fabio Estevam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/imx-hdmi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/imx-drm/imx-hdmi.c b/drivers/staging/imx-drm/imx-hdmi.c index 886a0d49031b..1b440483f28f 100644 --- a/drivers/staging/imx-drm/imx-hdmi.c +++ b/drivers/staging/imx-drm/imx-hdmi.c @@ -157,6 +157,7 @@ static inline u8 hdmi_readb(struct imx_hdmi *hdmi, int offset) static void hdmi_modb(struct imx_hdmi *hdmi, u8 data, u8 mask, unsigned reg) { u8 val = hdmi_readb(hdmi, reg) & ~mask; + val |= data & mask; hdmi_writeb(hdmi, val, reg); } @@ -1606,6 +1607,7 @@ static int imx_hdmi_bind(struct device *dev, struct device *master, void *data) if (of_id) { const struct platform_device_id *device_id = of_id->data; + hdmi->dev_type = device_id->driver_data; } -- cgit v1.2.3 From 00d8521dcd236d1b8f664f54a0309e96bfdcb4f9 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 23 May 2014 20:46:41 +0900 Subject: staging: remove rts5139 driver code Roger writes: Since all patches have been applied and the device is now supported by the new driver, would you remove the former staging one at drivers/staging/rts5139? Cc: Roger Tseng Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 - drivers/staging/Makefile | 1 - drivers/staging/rts5139/Kconfig | 16 - drivers/staging/rts5139/Makefile | 43 - drivers/staging/rts5139/TODO | 9 - drivers/staging/rts5139/debug.h | 46 - drivers/staging/rts5139/ms.c | 4182 ---------------------------- drivers/staging/rts5139/ms.h | 261 -- drivers/staging/rts5139/ms_mg.c | 643 ----- drivers/staging/rts5139/ms_mg.h | 42 - drivers/staging/rts5139/rts51x.c | 846 ------ drivers/staging/rts5139/rts51x.h | 194 -- drivers/staging/rts5139/rts51x_card.c | 940 ------- drivers/staging/rts5139/rts51x_card.h | 870 ------ drivers/staging/rts5139/rts51x_chip.c | 1014 ------- drivers/staging/rts5139/rts51x_chip.h | 821 ------ drivers/staging/rts5139/rts51x_fop.c | 295 -- drivers/staging/rts5139/rts51x_fop.h | 57 - drivers/staging/rts5139/rts51x_scsi.c | 2135 -------------- drivers/staging/rts5139/rts51x_scsi.h | 154 - drivers/staging/rts5139/rts51x_transport.c | 738 ----- drivers/staging/rts5139/rts51x_transport.h | 67 - drivers/staging/rts5139/sd.c | 3274 ---------------------- drivers/staging/rts5139/sd.h | 275 -- drivers/staging/rts5139/sd_cprm.c | 1056 ------- drivers/staging/rts5139/sd_cprm.h | 54 - drivers/staging/rts5139/trace.h | 95 - drivers/staging/rts5139/xd.c | 2145 -------------- drivers/staging/rts5139/xd.h | 191 -- 29 files changed, 20466 deletions(-) delete mode 100644 drivers/staging/rts5139/Kconfig delete mode 100644 drivers/staging/rts5139/Makefile delete mode 100644 drivers/staging/rts5139/TODO delete mode 100644 drivers/staging/rts5139/debug.h delete mode 100644 drivers/staging/rts5139/ms.c delete mode 100644 drivers/staging/rts5139/ms.h delete mode 100644 drivers/staging/rts5139/ms_mg.c delete mode 100644 drivers/staging/rts5139/ms_mg.h delete mode 100644 drivers/staging/rts5139/rts51x.c delete mode 100644 drivers/staging/rts5139/rts51x.h delete mode 100644 drivers/staging/rts5139/rts51x_card.c delete mode 100644 drivers/staging/rts5139/rts51x_card.h delete mode 100644 drivers/staging/rts5139/rts51x_chip.c delete mode 100644 drivers/staging/rts5139/rts51x_chip.h delete mode 100644 drivers/staging/rts5139/rts51x_fop.c delete mode 100644 drivers/staging/rts5139/rts51x_fop.h delete mode 100644 drivers/staging/rts5139/rts51x_scsi.c delete mode 100644 drivers/staging/rts5139/rts51x_scsi.h delete mode 100644 drivers/staging/rts5139/rts51x_transport.c delete mode 100644 drivers/staging/rts5139/rts51x_transport.h delete mode 100644 drivers/staging/rts5139/sd.c delete mode 100644 drivers/staging/rts5139/sd.h delete mode 100644 drivers/staging/rts5139/sd_cprm.c delete mode 100644 drivers/staging/rts5139/sd_cprm.h delete mode 100644 drivers/staging/rts5139/trace.h delete mode 100644 drivers/staging/rts5139/xd.c delete mode 100644 drivers/staging/rts5139/xd.h diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index f0cf26959fae..4f38fc000a37 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -54,8 +54,6 @@ source "drivers/staging/rtl8723au/Kconfig" source "drivers/staging/rtl8821ae/Kconfig" -source "drivers/staging/rts5139/Kconfig" - source "drivers/staging/rts5208/Kconfig" source "drivers/staging/frontier/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index f60f26f537df..1e97ad2177de 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -19,7 +19,6 @@ obj-$(CONFIG_R8188EU) += rtl8188eu/ obj-$(CONFIG_R8192EE) += rtl8192ee/ obj-$(CONFIG_R8723AU) += rtl8723au/ obj-$(CONFIG_R8821AE) += rtl8821ae/ -obj-$(CONFIG_RTS5139) += rts5139/ obj-$(CONFIG_RTS5208) += rts5208/ obj-$(CONFIG_TRANZPORT) += frontier/ obj-$(CONFIG_IDE_PHISON) += phison/ diff --git a/drivers/staging/rts5139/Kconfig b/drivers/staging/rts5139/Kconfig deleted file mode 100644 index afd526bf422a..000000000000 --- a/drivers/staging/rts5139/Kconfig +++ /dev/null @@ -1,16 +0,0 @@ -config RTS5139 - tristate "Realtek RTS5139 USB card reader support" - depends on USB && SCSI - help - Say Y here to include driver code to support the Realtek - RTS5139 USB card readers. - - If this driver is compiled as a module, it will be named rts5139. - -config RTS5139_DEBUG - bool "Realtek RTS5139 Card Reader verbose debug" - depends on RTS5139 - help - Say Y here in order to have the rts5139 code generate - verbose debugging messages. - diff --git a/drivers/staging/rts5139/Makefile b/drivers/staging/rts5139/Makefile deleted file mode 100644 index 75dd31224e62..000000000000 --- a/drivers/staging/rts5139/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -# Driver for Realtek RTS51xx USB card reader -# -# Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. -# -# 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, 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, see . -# -# Author: -# wwang (wei_wang@realsil.com.cn) -# No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China -# Maintainer: -# Edwin Rong (edwin_rong@realsil.com.cn) -# No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China -# -# Makefile for the RTS51xx USB Card Reader drivers. -# - -obj-$(CONFIG_RTS5139) := rts5139.o - -ccflags-y := -Idrivers/scsi - -rts5139-y := \ - rts51x_transport.o \ - rts51x_scsi.o \ - rts51x_fop.o \ - rts51x.o \ - rts51x_chip.o \ - rts51x_card.o \ - xd.o \ - sd.o \ - ms.o \ - sd_cprm.o \ - ms_mg.o diff --git a/drivers/staging/rts5139/TODO b/drivers/staging/rts5139/TODO deleted file mode 100644 index dd5fabb8ea70..000000000000 --- a/drivers/staging/rts5139/TODO +++ /dev/null @@ -1,9 +0,0 @@ -TODO: -- support more USB card reader of Realtek family -- use kernel coding style -- checkpatch.pl fixes -- stop having thousands of lines of code duplicated with staging/rts_pstor -- This driver contains an entire SD/MMC stack -- it should use the stack in - drivers/mmc instead, as a host driver e.g. drivers/mmc/host/realtek-usb.c; - see drivers/mmc/host/ushc.c as an example. -- This driver presents cards as SCSI devices, but they should be MMC devices. diff --git a/drivers/staging/rts5139/debug.h b/drivers/staging/rts5139/debug.h deleted file mode 100644 index 73dec133a1bf..000000000000 --- a/drivers/staging/rts5139/debug.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Driver for Realtek RTS51xx USB card reader - * Header file - * - * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. - * - * 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, 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, see . - * - * Author: - * wwang (wei_wang@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - * Maintainer: - * Edwin Rong (edwin_rong@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - */ - -#ifndef __RTS51X_DEBUG_H -#define __RTS51X_DEBUG_H - -#include - -#define RTS51X_TIP "rts51x: " - -#ifdef CONFIG_RTS5139_DEBUG -#define RTS51X_DEBUGP(x...) printk(KERN_DEBUG RTS51X_TIP x) -#define RTS51X_DEBUGPN(x...) printk(KERN_DEBUG x) -#define RTS51X_DEBUGPX(x...) printk(x) -#define RTS51X_DEBUG(x) x -#else -#define RTS51X_DEBUGP(x...) -#define RTS51X_DEBUGPN(x...) -#define RTS51X_DEBUGPX(x...) -#define RTS51X_DEBUG(x) -#endif - -#endif /* __RTS51X_DEBUG_H */ diff --git a/drivers/staging/rts5139/ms.c b/drivers/staging/rts5139/ms.c deleted file mode 100644 index a843a2f4392b..000000000000 --- a/drivers/staging/rts5139/ms.c +++ /dev/null @@ -1,4182 +0,0 @@ -/* Driver for Realtek RTS51xx USB card reader - * - * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. - * - * 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, 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, see . - * - * Author: - * wwang (wei_wang@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - * Maintainer: - * Edwin Rong (edwin_rong@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - */ - -#include -#include -#include -#include -#include - -#include "debug.h" -#include "trace.h" -#include "rts51x.h" -#include "rts51x_transport.h" -#include "rts51x_scsi.h" -#include "rts51x_card.h" -#include "ms.h" -#include "ms_mg.h" - -static inline void ms_set_err_code(struct rts51x_chip *chip, u8 err_code) -{ - struct ms_info *ms_card = &(chip->ms_card); - - ms_card->err_code = err_code; -} - -static inline int ms_check_err_code(struct rts51x_chip *chip, u8 err_code) -{ - struct ms_info *ms_card = &(chip->ms_card); - - return ms_card->err_code == err_code; -} - -static int ms_parse_err_code(struct rts51x_chip *chip) -{ - TRACE_RET(chip, STATUS_FAIL); -} - -static int ms_transfer_tpc(struct rts51x_chip *chip, u8 trans_mode, u8 tpc, - u8 cnt, u8 cfg) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval; - - RTS51X_DEBUGP("ms_transfer_tpc: tpc = 0x%x\n", tpc); - - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TPC, 0xFF, tpc); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_BYTE_CNT, 0xFF, cnt); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANS_CFG, 0xFF, cfg); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, - PINGPONG_BUFFER); - - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANSFER, 0xFF, - MS_TRANSFER_START | trans_mode); - rts51x_add_cmd(chip, CHECK_REG_CMD, MS_TRANSFER, MS_TRANSFER_END, - MS_TRANSFER_END); - - rts51x_add_cmd(chip, READ_REG_CMD, MS_TRANS_CFG, 0, 0); - - retval = rts51x_send_cmd(chip, MODE_CR, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = rts51x_get_rsp(chip, 2, 5000); - if (CHECK_MS_TRANS_FAIL(chip, retval)) { - rts51x_clear_ms_error(chip); - ms_set_err_code(chip, MS_TO_ERROR); - TRACE_RET(chip, ms_parse_err_code(chip)); - } - - if (!(tpc & 0x08)) { /* Read Packet */ - /* Check CRC16 & Ready Timeout */ - if (chip->rsp_buf[1] & MS_CRC16_ERR) { - ms_set_err_code(chip, MS_CRC16_ERROR); - TRACE_RET(chip, ms_parse_err_code(chip)); - } - } else { /* Write Packet */ - if (CHK_MSPRO(ms_card) && !(chip->rsp_buf[1] & 0x80)) { - if (chip->rsp_buf[1] & (MS_INT_ERR | MS_INT_CMDNK)) { - ms_set_err_code(chip, MS_CMD_NK); - TRACE_RET(chip, ms_parse_err_code(chip)); - } - } - } - - /* Check Timeout of Ready Signal */ - if (chip->rsp_buf[1] & MS_RDY_TIMEOUT) { - rts51x_clear_ms_error(chip); - ms_set_err_code(chip, MS_TO_ERROR); - TRACE_RET(chip, ms_parse_err_code(chip)); - } - - return STATUS_SUCCESS; -} - -int ms_transfer_data(struct rts51x_chip *chip, u8 trans_mode, u8 tpc, - u16 sec_cnt, u8 cfg, int mode_2k, int use_sg, void *buf, - int buf_len) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval; - u8 val, err_code = 0, flag = 0; - enum dma_data_direction dir; - unsigned int pipe; - - if (!buf || !buf_len) - TRACE_RET(chip, STATUS_FAIL); - - if (trans_mode == MS_TM_AUTO_READ) { - pipe = RCV_BULK_PIPE(chip); - dir = DMA_FROM_DEVICE; - flag = MODE_CDIR; - err_code = MS_FLASH_READ_ERROR; - } else if (trans_mode == MS_TM_AUTO_WRITE) { - pipe = SND_BULK_PIPE(chip); - dir = DMA_TO_DEVICE; - flag = MODE_CDOR; - err_code = MS_FLASH_WRITE_ERROR; - } else { - TRACE_RET(chip, STATUS_FAIL); - } - - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TPC, 0xFF, tpc); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_SECTOR_CNT_H, 0xFF, - (u8) (sec_cnt >> 8)); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_SECTOR_CNT_L, 0xFF, - (u8) sec_cnt); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANS_CFG, 0xFF, cfg); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, - RING_BUFFER); - - if (mode_2k) - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_CFG, MS_2K_SECTOR_MODE, - MS_2K_SECTOR_MODE); - else - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_CFG, MS_2K_SECTOR_MODE, - 0); - - rts51x_trans_dma_enable(dir, chip, sec_cnt * 512, DMA_512); - - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANSFER, 0xFF, - MS_TRANSFER_START | trans_mode); - rts51x_add_cmd(chip, CHECK_REG_CMD, MS_TRANSFER, MS_TRANSFER_END, - MS_TRANSFER_END); - - retval = rts51x_send_cmd(chip, flag | STAGE_MS_STATUS, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = - rts51x_transfer_data_rcc(chip, pipe, buf, buf_len, use_sg, NULL, - 15000, flag); - if (retval != STATUS_SUCCESS) { - ms_set_err_code(chip, err_code); - rts51x_clear_ms_error(chip); - TRACE_RET(chip, retval); - } - - retval = rts51x_get_rsp(chip, 3, 15000); - if (CHECK_MS_TRANS_FAIL(chip, retval)) { - ms_set_err_code(chip, err_code); - rts51x_clear_ms_error(chip); - TRACE_RET(chip, STATUS_FAIL); - } - - ms_card->last_rw_int = val = chip->rsp_buf[1]; - if (val & (MS_INT_CMDNK | MS_INT_ERR | MS_CRC16_ERR | MS_RDY_TIMEOUT)) - TRACE_RET(chip, STATUS_FAIL); - - return STATUS_SUCCESS; -} - -int ms_write_bytes(struct rts51x_chip *chip, u8 tpc, u8 cnt, u8 cfg, u8 *data, - int data_len) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval, i; - - if (!data || (data_len < cnt)) - TRACE_RET(chip, STATUS_ERROR); - - rts51x_init_cmd(chip); - - for (i = 0; i < cnt; i++) { - rts51x_add_cmd(chip, WRITE_REG_CMD, PPBUF_BASE2 + i, 0xFF, - data[i]); - } - if (cnt % 2) - rts51x_add_cmd(chip, WRITE_REG_CMD, PPBUF_BASE2 + i, - 0xFF, 0xFF); - - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TPC, 0xFF, tpc); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_BYTE_CNT, 0xFF, cnt); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANS_CFG, 0xFF, cfg); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, - PINGPONG_BUFFER); - - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANSFER, 0xFF, - MS_TRANSFER_START | MS_TM_WRITE_BYTES); - rts51x_add_cmd(chip, CHECK_REG_CMD, MS_TRANSFER, MS_TRANSFER_END, - MS_TRANSFER_END); - - retval = rts51x_send_cmd(chip, MODE_CR, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = rts51x_get_rsp(chip, 1, 5000); - if (CHECK_MS_TRANS_FAIL(chip, retval)) { - u8 val = 0; - - rts51x_ep0_read_register(chip, MS_TRANS_CFG, &val); - RTS51X_DEBUGP("MS_TRANS_CFG: 0x%02x\n", val); - - rts51x_clear_ms_error(chip); - - if (!(tpc & 0x08)) { /* Read Packet */ - /* Check CRC16 & Ready Timeout */ - if (val & MS_CRC16_ERR) { - ms_set_err_code(chip, MS_CRC16_ERROR); - TRACE_RET(chip, ms_parse_err_code(chip)); - } - } else { /* Write Packet */ - if (CHK_MSPRO(ms_card) && !(val & 0x80)) { - if (val & (MS_INT_ERR | MS_INT_CMDNK)) { - ms_set_err_code(chip, MS_CMD_NK); - TRACE_RET(chip, - ms_parse_err_code(chip)); - } - } - } - - /* Check Timeout of Ready Signal */ - if (val & MS_RDY_TIMEOUT) { - ms_set_err_code(chip, MS_TO_ERROR); - TRACE_RET(chip, ms_parse_err_code(chip)); - } - - ms_set_err_code(chip, MS_TO_ERROR); - TRACE_RET(chip, ms_parse_err_code(chip)); - } - - return STATUS_SUCCESS; -} - -int ms_read_bytes(struct rts51x_chip *chip, u8 tpc, u8 cnt, u8 cfg, u8 *data, - int data_len) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval, i; - - if (!data) - TRACE_RET(chip, STATUS_ERROR); - - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TPC, 0xFF, tpc); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_BYTE_CNT, 0xFF, cnt); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANS_CFG, 0xFF, cfg); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, - PINGPONG_BUFFER); - - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANSFER, 0xFF, - MS_TRANSFER_START | MS_TM_READ_BYTES); - rts51x_add_cmd(chip, CHECK_REG_CMD, MS_TRANSFER, MS_TRANSFER_END, - MS_TRANSFER_END); - - for (i = 0; i < data_len - 1; i++) - rts51x_add_cmd(chip, READ_REG_CMD, PPBUF_BASE2 + i, 0, 0); - - if (data_len % 2) - rts51x_add_cmd(chip, READ_REG_CMD, PPBUF_BASE2 + data_len, 0, - 0); - else - rts51x_add_cmd(chip, READ_REG_CMD, PPBUF_BASE2 + data_len - 1, - 0, 0); - - retval = rts51x_send_cmd(chip, MODE_CR, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = rts51x_get_rsp(chip, data_len + 1, 5000); - if (CHECK_MS_TRANS_FAIL(chip, retval)) { - u8 val = 0; - - rts51x_ep0_read_register(chip, MS_TRANS_CFG, &val); - RTS51X_DEBUGP("MS_TRANS_CFG: 0x%02x\n", val); - - rts51x_clear_ms_error(chip); - - if (!(tpc & 0x08)) { /* Read Packet */ - /* Check CRC16 & Ready Timeout */ - if (val & MS_CRC16_ERR) { - ms_set_err_code(chip, MS_CRC16_ERROR); - TRACE_RET(chip, ms_parse_err_code(chip)); - } - } else { /* Write Packet */ - if (CHK_MSPRO(ms_card) && !(val & 0x80)) { - if (val & (MS_INT_ERR | MS_INT_CMDNK)) { - ms_set_err_code(chip, MS_CMD_NK); - TRACE_RET(chip, - ms_parse_err_code(chip)); - } - } - } - - /* Check Timeout of Ready Signal */ - if (val & MS_RDY_TIMEOUT) { - ms_set_err_code(chip, MS_TO_ERROR); - TRACE_RET(chip, ms_parse_err_code(chip)); - } - - ms_set_err_code(chip, MS_TO_ERROR); - TRACE_RET(chip, ms_parse_err_code(chip)); - } - - rts51x_read_rsp_buf(chip, 1, data, data_len); - - return STATUS_SUCCESS; -} - -int ms_set_rw_reg_addr(struct rts51x_chip *chip, - u8 read_start, u8 read_cnt, u8 write_start, u8 write_cnt) -{ - int retval, i; - u8 data[4]; - - data[0] = read_start; - data[1] = read_cnt; - data[2] = write_start; - data[3] = write_cnt; - - for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { - retval = - ms_write_bytes(chip, SET_RW_REG_ADRS, 4, NO_WAIT_INT, data, - 4); - if (retval == STATUS_SUCCESS) - return STATUS_SUCCESS; - rts51x_clear_ms_error(chip); - } - - TRACE_RET(chip, STATUS_FAIL); -} - -static int ms_send_cmd(struct rts51x_chip *chip, u8 cmd, u8 cfg) -{ - u8 data[2]; - - data[0] = cmd; - data[1] = 0; - - return ms_write_bytes(chip, PRO_SET_CMD, 1, cfg, data, 1); -} - -static int ms_set_cmd(struct rts51x_chip *chip, - u8 read_start, u8 read_count, - u8 write_start, u8 write_count, - u8 cmd, u8 cfg, u8 *data, int data_len, u8 *int_stat) -{ - int retval, i; - u8 val; - - if (!data || (data_len <= 0) || (data_len > 128)) { - RTS51X_DEBUGP("ms_set_cmd (data_len = %d)\n", data_len); - TRACE_RET(chip, STATUS_FAIL); - } - - retval = - ms_set_rw_reg_addr(chip, read_start, read_count, write_start, - write_count); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { - retval = - ms_write_bytes(chip, WRITE_REG, write_count, NO_WAIT_INT, - data, data_len); - if (retval == STATUS_SUCCESS) - break; - } - if (i == MS_MAX_RETRY_COUNT) - TRACE_RET(chip, STATUS_FAIL); - - ms_set_err_code(chip, MS_NO_ERROR); - - for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { - retval = ms_send_cmd(chip, cmd, WAIT_INT); - if (retval == STATUS_SUCCESS) - break; - } - if (i == MS_MAX_RETRY_COUNT) - TRACE_RET(chip, STATUS_FAIL); - /* GET_INT Register */ - ms_set_err_code(chip, MS_NO_ERROR); - retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (int_stat) - *int_stat = val; - - return STATUS_SUCCESS; -} - -#ifdef MS_SPEEDUP -static int ms_auto_set_cmd(struct rts51x_chip *chip, - u8 read_start, u8 read_count, - u8 write_start, u8 write_count, - u8 cmd, u8 cfg, u8 *data, int data_len, - u8 *int_stat) -{ - int retval; - int i; - - if (!data || (data_len <= 0) || (data_len > 128)) { - RTS51X_DEBUGP("ms_auto_set_cmd (data_len = %d)\n", data_len); - TRACE_RET(chip, STATUS_FAIL); - } - - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_READ_START, 0xFF, read_start); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_READ_COUNT, 0xFF, read_count); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_WRITE_START, 0xFF, write_start); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_WRITE_COUNT, 0xFF, write_count); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_COMMAND, 0xFF, cmd); - - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANS_CFG, 0xFF, cfg); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, - PINGPONG_BUFFER); - - for (i = 0; i < data_len; i++) { - rts51x_add_cmd(chip, WRITE_REG_CMD, PPBUF_BASE2 + i, 0xFF, - data[i]); - } - - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANSFER, 0xFF, - MS_TRANSFER_START | MS_TM_SET_CMD); - rts51x_add_cmd(chip, CHECK_REG_CMD, MS_TRANSFER, MS_TRANSFER_END, - MS_TRANSFER_END); - - retval = rts51x_send_cmd(chip, MODE_CR | STAGE_MS_STATUS, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = rts51x_get_rsp(chip, 3, 5000); - - if (CHECK_MS_TRANS_FAIL(chip, retval)) { - rts51x_clear_ms_error(chip); - TRACE_RET(chip, STATUS_FAIL); - } - - if (int_stat) - *int_stat = chip->rsp_buf[2]; - - return STATUS_SUCCESS; -} -#endif - -static int ms_set_init_para(struct rts51x_chip *chip) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval; - - if (CHK_HG8BIT(ms_card)) { - if (chip->asic_code) - ms_card->ms_clock = chip->option.asic_ms_hg_clk; - else - ms_card->ms_clock = chip->option.fpga_ms_hg_clk; - } else if (CHK_MSPRO(ms_card) || CHK_MS4BIT(ms_card)) { - if (chip->asic_code) - ms_card->ms_clock = chip->option.asic_ms_4bit_clk; - else - ms_card->ms_clock = chip->option.fpga_ms_4bit_clk; - } else { - if (chip->asic_code) - ms_card->ms_clock = 38; - else - ms_card->ms_clock = CLK_40; - } - - retval = switch_clock(chip, ms_card->ms_clock); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = rts51x_select_card(chip, MS_CARD); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - return STATUS_SUCCESS; -} - -int ms_switch_clock(struct rts51x_chip *chip) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval; - - retval = rts51x_select_card(chip, MS_CARD); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = switch_clock(chip, ms_card->ms_clock); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - return STATUS_SUCCESS; -} - -static void ms_pull_ctl_disable(struct rts51x_chip *chip) -{ - if (CHECK_PKG(chip, LQFP48)) { - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0x95); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0xA5); - } else { - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0x65); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0x95); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x56); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0x59); - } -} - -static void ms_pull_ctl_enable(struct rts51x_chip *chip) -{ - if (CHECK_PKG(chip, LQFP48)) { - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0x95); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0xA5); - } else { - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0x65); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0x95); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0x59); - } -} - -static int ms_prepare_reset(struct rts51x_chip *chip) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval; - - ms_card->ms_type = 0; - ms_card->check_ms_flow = 0; - ms_card->switch_8bit_fail = 0; - ms_card->delay_write.delay_write_flag = 0; - - ms_card->pro_under_formatting = 0; - - rts51x_init_cmd(chip); - - if (chip->asic_code) { - ms_pull_ctl_enable(chip); - } else { - rts51x_add_cmd(chip, WRITE_REG_CMD, FPGA_PULL_CTL, - FPGA_MS_PULL_CTL_BIT | 0x20, 0); - } - /* Tri-state MS output */ - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_OE, MS_OUTPUT_EN, 0); - - if (!chip->option.FT2_fast_mode) { - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, POWER_MASK, - POWER_OFF); - } - - retval = rts51x_send_cmd(chip, MODE_C, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (!chip->option.FT2_fast_mode) { - wait_timeout(250); - - rts51x_card_power_on(chip, MS_CARD); - wait_timeout(150); - -#ifdef SUPPORT_OCP - rts51x_get_card_status(chip, &(chip->card_status)); - /* get OCP status */ - chip->ocp_stat = (chip->card_status >> 4) & 0x03; - - if (chip->ocp_stat & (MS_OCP_NOW | MS_OCP_EVER)) { - RTS51X_DEBUGP("Over current, OCPSTAT is 0x%x\n", - chip->ocp_stat); - TRACE_RET(chip, STATUS_FAIL); - } -#endif - } - - rts51x_init_cmd(chip); - - /* Enable MS Output */ - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_OE, MS_OUTPUT_EN, - MS_OUTPUT_EN); - - /* Reset Registers */ - if (chip->asic_code) - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_CFG, 0xFF, - SAMPLE_TIME_RISING | PUSH_TIME_DEFAULT | - NO_EXTEND_TOGGLE | MS_BUS_WIDTH_1); - else - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_CFG, 0xFF, - SAMPLE_TIME_FALLING | PUSH_TIME_DEFAULT | - NO_EXTEND_TOGGLE | MS_BUS_WIDTH_1); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANS_CFG, 0xFF, - NO_WAIT_INT | NO_AUTO_READ_INT_REG); - - retval = rts51x_send_cmd(chip, MODE_C, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - return ms_set_init_para(chip); -} - -static int ms_identify_media_type(struct rts51x_chip *chip, int switch_8bit_bus) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval, i; - u8 val; - - retval = ms_set_rw_reg_addr(chip, Pro_StatusReg, 6, SystemParm, 1); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - /* Get Register form MS-PRO card */ - for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { - retval = - ms_transfer_tpc(chip, MS_TM_READ_BYTES, READ_REG, 6, - NO_WAIT_INT); - if (retval == STATUS_SUCCESS) - break; - } - if (i == MS_MAX_RETRY_COUNT) - TRACE_RET(chip, STATUS_FAIL); - - RTS51X_READ_REG(chip, PPBUF_BASE2 + 2, &val); - RTS51X_DEBUGP("Type register: 0x%x\n", val); - if (val != 0x01) { - if (val != 0x02) - ms_card->check_ms_flow = 1; - TRACE_RET(chip, STATUS_FAIL); - } - /* Category Register */ - RTS51X_READ_REG(chip, PPBUF_BASE2 + 4, &val); - RTS51X_DEBUGP("Category register: 0x%x\n", val); - if (val != 0) { - ms_card->check_ms_flow = 1; - TRACE_RET(chip, STATUS_FAIL); - } - /* Class Register */ - RTS51X_READ_REG(chip, PPBUF_BASE2 + 5, &val); - RTS51X_DEBUGP("Class register: 0x%x\n", val); - if (val == 0) { - RTS51X_READ_REG(chip, PPBUF_BASE2, &val); - if (val & WRT_PRTCT) - chip->card_wp |= MS_CARD; - else - chip->card_wp &= ~MS_CARD; - } else if ((val == 0x01) || (val == 0x02) || (val == 0x03)) { - chip->card_wp |= MS_CARD; - } else { - ms_card->check_ms_flow = 1; - TRACE_RET(chip, STATUS_FAIL); - } - - ms_card->ms_type |= TYPE_MSPRO; - - /* Check MSPro-HG Card, use IF Mode Register to distinguish */ - RTS51X_READ_REG(chip, PPBUF_BASE2 + 3, &val); - RTS51X_DEBUGP("IF Mode register: 0x%x\n", val); - if (val == 0) { - ms_card->ms_type &= 0x0F; - } else if (val == 7) { - if (switch_8bit_bus) - ms_card->ms_type |= MS_HG; - else - ms_card->ms_type &= 0x0F; - } else { - TRACE_RET(chip, STATUS_FAIL); - } - - /* end Procedure to identify Media Type */ - return STATUS_SUCCESS; -} - -static int ms_confirm_cpu_startup(struct rts51x_chip *chip) -{ - int retval, i, k; - u8 val; - - /* Confirm CPU StartUp */ - k = 0; - do { - if (monitor_card_cd(chip, MS_CARD) == CD_NOT_EXIST) - TRACE_RET(chip, STATUS_FAIL); - - for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { - retval = - ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, - 1); - if (retval == STATUS_SUCCESS) - break; - } - if (i == MS_MAX_RETRY_COUNT) - TRACE_RET(chip, STATUS_FAIL); - - if (k > 100) - TRACE_RET(chip, STATUS_FAIL); - k++; - wait_timeout(100); - } while (!(val & INT_REG_CED)); - - for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { - retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); - if (retval == STATUS_SUCCESS) - break; - } - if (i == MS_MAX_RETRY_COUNT) - TRACE_RET(chip, STATUS_FAIL); - - if (val & INT_REG_ERR) { - if (val & INT_REG_CMDNK) { /* CMDNK = 1 */ - chip->card_wp |= (MS_CARD); - } else { /* CMDNK = 0 */ - TRACE_RET(chip, STATUS_FAIL); - } - } - /*-- end confirm CPU startup */ - - return STATUS_SUCCESS; -} - -static int ms_switch_parallel_bus(struct rts51x_chip *chip) -{ - int retval, i; - u8 data[2]; - - data[0] = PARALLEL_4BIT_IF; - data[1] = 0; - for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { - retval = - ms_write_bytes(chip, WRITE_REG, 1, NO_WAIT_INT, data, 2); - if (retval == STATUS_SUCCESS) - break; - } - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - return STATUS_SUCCESS; -} - -static int ms_switch_8bit_bus(struct rts51x_chip *chip) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval, i; - u8 data[2]; - - data[0] = PARALLEL_8BIT_IF; - data[1] = 0; - for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { - retval = - ms_write_bytes(chip, WRITE_REG, 1, NO_WAIT_INT, data, 2); - if (retval == STATUS_SUCCESS) - break; - } - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - - RTS51X_WRITE_REG(chip, MS_CFG, 0x98, - MS_BUS_WIDTH_8 | SAMPLE_TIME_FALLING); - ms_card->ms_type |= MS_8BIT; - - retval = ms_set_init_para(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { - retval = - ms_transfer_tpc(chip, MS_TM_READ_BYTES, GET_INT, 1, - NO_WAIT_INT); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - - return STATUS_SUCCESS; -} - -static int ms_pro_reset_flow(struct rts51x_chip *chip, int switch_8bit_bus) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval, i; - - for (i = 0; i < 3; i++) { - retval = ms_prepare_reset(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = ms_identify_media_type(chip, switch_8bit_bus); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = ms_confirm_cpu_startup(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = ms_switch_parallel_bus(chip); - if (retval != STATUS_SUCCESS) { - if (monitor_card_cd(chip, MS_CARD) == CD_NOT_EXIST) - TRACE_RET(chip, STATUS_FAIL); - continue; - } else { - break; - } - } - - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - RTS51X_WRITE_REG(chip, MS_CFG, 0x18, MS_BUS_WIDTH_4); - - RTS51X_WRITE_REG(chip, MS_CFG, PUSH_TIME_ODD, PUSH_TIME_ODD); - - retval = ms_set_init_para(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (CHK_MSHG(ms_card) && switch_8bit_bus) { - retval = ms_switch_8bit_bus(chip); - if (retval != STATUS_SUCCESS) { - ms_card->switch_8bit_fail = 1; - TRACE_RET(chip, retval); - } - } - - return STATUS_SUCCESS; -} - -#ifdef XC_POWERCLASS -static int msxc_change_power(struct rts51x_chip *chip, u8 mode) -{ - int retval; - u8 buf[6]; - - rts51x_ms_cleanup_work(chip); - - /* Set Parameter Register */ - retval = ms_set_rw_reg_addr(chip, 0, 0, Pro_DataCount1, 6); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - buf[0] = 0; - buf[1] = mode; - buf[2] = 0; - buf[3] = 0; - buf[4] = 0; - buf[5] = 0; - - retval = ms_write_bytes(chip, PRO_WRITE_REG, 6, NO_WAIT_INT, buf, 6); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = ms_send_cmd(chip, XC_CHG_POWER, WAIT_INT); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - RTS51X_READ_REG(chip, MS_TRANS_CFG, buf); - if (buf[0] & (MS_INT_CMDNK | MS_INT_ERR)) - TRACE_RET(chip, STATUS_FAIL); - - return STATUS_SUCCESS; -} -#endif - -static int ms_read_attribute_info(struct rts51x_chip *chip) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval, i; - u8 val, *buf, class_code, device_type, sub_class, data[16]; - u16 total_blk = 0, blk_size = 0; -#ifdef SUPPORT_MSXC - u32 xc_total_blk = 0, xc_blk_size = 0; -#endif - u32 sys_info_addr = 0, sys_info_size; -#ifdef SUPPORT_PCGL_1P18 - u32 model_name_addr = 0, model_name_size; - int found_sys_info = 0, found_model_name = 0; -#endif - - retval = ms_set_rw_reg_addr(chip, Pro_IntReg, 2, Pro_SystemParm, 7); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (CHK_MS8BIT(ms_card)) - data[0] = PARALLEL_8BIT_IF; - else - data[0] = PARALLEL_4BIT_IF; - data[1] = 0; - - data[2] = 0x40; - data[3] = 0; - data[4] = 0; - data[5] = 0; - /* Start address 0 */ - data[6] = 0; - data[7] = 0; - - for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { - retval = - ms_write_bytes(chip, PRO_WRITE_REG, 7, NO_WAIT_INT, data, - 8); - if (retval == STATUS_SUCCESS) - break; - } - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - buf = kmalloc(64 * 512, GFP_KERNEL); - if (buf == NULL) - TRACE_RET(chip, STATUS_NOMEM); - - for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { - retval = ms_send_cmd(chip, PRO_READ_ATRB, WAIT_INT); - if (retval != STATUS_SUCCESS) - continue; - - retval = rts51x_read_register(chip, MS_TRANS_CFG, &val); - if (retval != STATUS_SUCCESS) { - kfree(buf); - TRACE_RET(chip, STATUS_FAIL); - } - if (!(val & MS_INT_BREQ)) { - kfree(buf); - TRACE_RET(chip, STATUS_FAIL); - } - - retval = - ms_transfer_data(chip, MS_TM_AUTO_READ, PRO_READ_LONG_DATA, - 0x40, WAIT_INT, 0, 0, buf, 64 * 512); - if (retval == STATUS_SUCCESS) - break; - else - rts51x_clear_ms_error(chip); - } - if (retval != STATUS_SUCCESS) { - kfree(buf); - TRACE_RET(chip, retval); - } - - i = 0; - do { - retval = rts51x_read_register(chip, MS_TRANS_CFG, &val); - if (retval != STATUS_SUCCESS) { - kfree(buf); - TRACE_RET(chip, retval); - } - - if ((val & MS_INT_CED) || !(val & MS_INT_BREQ)) - break; - - retval = - ms_transfer_tpc(chip, MS_TM_NORMAL_READ, PRO_READ_LONG_DATA, - 0, WAIT_INT); - if (retval != STATUS_SUCCESS) { - kfree(buf); - TRACE_RET(chip, retval); - } - - i++; - } while (i < 1024); - - if (retval != STATUS_SUCCESS) { - kfree(buf); - TRACE_RET(chip, retval); - } - - if ((buf[0] != 0xa5) && (buf[1] != 0xc3)) { - /* Signature code is wrong */ - kfree(buf); - TRACE_RET(chip, STATUS_FAIL); - } - - if ((buf[4] < 1) || (buf[4] > 12)) { - kfree(buf); - TRACE_RET(chip, STATUS_FAIL); - } - - for (i = 0; i < buf[4]; i++) { - int cur_addr_off = 16 + i * 12; - -#ifdef SUPPORT_MSXC - if ((buf[cur_addr_off + 8] == 0x10) - || (buf[cur_addr_off + 8] == 0x13)) { -#else - if (buf[cur_addr_off + 8] == 0x10) { -#endif - sys_info_addr = ((u32) buf[cur_addr_off + 0] << 24) | - ((u32) buf[cur_addr_off + 1] << 16) | - ((u32) buf[cur_addr_off + 2] << 8) | - buf[cur_addr_off + 3]; - sys_info_size = - ((u32) buf[cur_addr_off + 4] << 24) | - ((u32) buf[cur_addr_off + 5] << 16) | - ((u32) buf[cur_addr_off + 6] << 8) | - buf[cur_addr_off + 7]; - RTS51X_DEBUGP("sys_info_addr = 0x%x, sys_info_size = 0x%x\n", - sys_info_addr, sys_info_size); - if (sys_info_size != 96) { - kfree(buf); - TRACE_RET(chip, STATUS_FAIL); - } - if (sys_info_addr < 0x1A0) { - kfree(buf); - TRACE_RET(chip, STATUS_FAIL); - } - if ((sys_info_size + sys_info_addr) > 0x8000) { - kfree(buf); - TRACE_RET(chip, STATUS_FAIL); - } -#ifdef SUPPORT_MSXC - if (buf[cur_addr_off + 8] == 0x13) - ms_card->ms_type |= MS_XC; -#endif -#ifdef SUPPORT_PCGL_1P18 - found_sys_info = 1; -#else - break; -#endif - } -#ifdef SUPPORT_PCGL_1P18 - if (buf[cur_addr_off + 8] == 0x15) { - model_name_addr = ((u32) buf[cur_addr_off + 0] << 24) | - ((u32) buf[cur_addr_off + 1] << 16) | - ((u32) buf[cur_addr_off + 2] << 8) | - buf[cur_addr_off + 3]; - model_name_size = - ((u32) buf[cur_addr_off + 4] << 24) | - ((u32) buf[cur_addr_off + 5] << 16) | - ((u32) buf[cur_addr_off + 6] << 8) | - buf[cur_addr_off + 7]; - RTS51X_DEBUGP("model_name_addr = 0x%x, model_name_size = 0x%x\n", - model_name_addr, model_name_size); - if (model_name_size != 48) { - kfree(buf); - TRACE_RET(chip, STATUS_FAIL); - } - if (model_name_addr < 0x1A0) { - kfree(buf); - TRACE_RET(chip, STATUS_FAIL); - } - if ((model_name_size + model_name_addr) > 0x8000) { - kfree(buf); - TRACE_RET(chip, STATUS_FAIL); - } - - found_model_name = 1; - } - - if (found_sys_info && found_model_name) - break; -#endif - } - - if (i == buf[4]) { - kfree(buf); - TRACE_RET(chip, STATUS_FAIL); - } - - class_code = buf[sys_info_addr + 0]; - device_type = buf[sys_info_addr + 56]; - sub_class = buf[sys_info_addr + 46]; -#ifdef SUPPORT_MSXC - if (CHK_MSXC(ms_card)) { - xc_total_blk = ((u32) buf[sys_info_addr + 6] << 24) | - ((u32) buf[sys_info_addr + 7] << 16) | - ((u32) buf[sys_info_addr + 8] << 8) | - buf[sys_info_addr + 9]; - xc_blk_size = ((u32) buf[sys_info_addr + 32] << 24) | - ((u32) buf[sys_info_addr + 33] << 16) | - ((u32) buf[sys_info_addr + 34] << 8) | - buf[sys_info_addr + 35]; - RTS51X_DEBUGP("xc_total_blk = 0x%x, xc_blk_size = 0x%x\n", - xc_total_blk, xc_blk_size); - } else { - total_blk = - ((u16) buf[sys_info_addr + 6] << 8) | buf[sys_info_addr + - 7]; - blk_size = - ((u16) buf[sys_info_addr + 2] << 8) | buf[sys_info_addr + - 3]; - RTS51X_DEBUGP("total_blk = 0x%x, blk_size = 0x%x\n", total_blk, - blk_size); - } -#else - total_blk = - ((u16) buf[sys_info_addr + 6] << 8) | buf[sys_info_addr + 7]; - blk_size = ((u16) buf[sys_info_addr + 2] << 8) | buf[sys_info_addr + 3]; - RTS51X_DEBUGP("total_blk = 0x%x, blk_size = 0x%x\n", total_blk, - blk_size); -#endif - - RTS51X_DEBUGP("class_code = 0x%x, device_type = 0x%x," - "sub_class = 0x%x\n", - class_code, device_type, sub_class); - - memcpy(ms_card->raw_sys_info, buf + sys_info_addr, 96); -#ifdef SUPPORT_PCGL_1P18 - memcpy(ms_card->raw_model_name, buf + model_name_addr, 48); -#endif - - kfree(buf); - - /* Confirm System Information */ -#ifdef SUPPORT_MSXC - if (CHK_MSXC(ms_card)) { - if (class_code != 0x03) - TRACE_RET(chip, STATUS_FAIL); - } else { - if (class_code != 0x02) - TRACE_RET(chip, STATUS_FAIL); - } -#else - if (class_code != 0x02) - TRACE_RET(chip, STATUS_FAIL); -#endif - - if (device_type != 0x00) { - if ((device_type == 0x01) || (device_type == 0x02) - || (device_type == 0x03)) - chip->card_wp |= MS_CARD; - else - TRACE_RET(chip, STATUS_FAIL); - } - if (sub_class & 0xC0) - TRACE_RET(chip, STATUS_FAIL); - - RTS51X_DEBUGP("class_code: 0x%x, device_type: 0x%x, sub_class: 0x%x\n", - class_code, device_type, sub_class); - -#ifdef SUPPORT_MSXC - if (CHK_MSXC(ms_card)) { - chip->capacity[chip->card2lun[MS_CARD]] = ms_card->capacity = - xc_total_blk * xc_blk_size; - } else { - chip->capacity[chip->card2lun[MS_CARD]] = ms_card->capacity = - total_blk * blk_size; - } -#else - chip->capacity[chip->card2lun[MS_CARD]] = ms_card->capacity = - total_blk * blk_size; -#endif - - return STATUS_SUCCESS; -} - -static int reset_ms_pro(struct rts51x_chip *chip) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval; -#ifdef XC_POWERCLASS - u8 change_power_class = 2; -#endif - -#ifdef XC_POWERCLASS -Retry: -#endif - retval = ms_pro_reset_flow(chip, 1); - if (retval != STATUS_SUCCESS) { - if (ms_card->switch_8bit_fail) { - retval = ms_pro_reset_flow(chip, 0); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } else { - TRACE_RET(chip, retval); - } - } - - retval = ms_read_attribute_info(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); -#ifdef XC_POWERCLASS - if (CHK_HG8BIT(ms_card)) - change_power_class = 0; - - if (change_power_class && CHK_MSXC(ms_card)) { - u8 power_class_mode = (ms_card->raw_sys_info[46] & 0x18) >> 3; - RTS51X_DEBUGP("power_class_mode = 0x%x", power_class_mode); - if (change_power_class > power_class_mode) - change_power_class = power_class_mode; - if (change_power_class) { - retval = msxc_change_power(chip, change_power_class); - if (retval != STATUS_SUCCESS) { - change_power_class--; - goto Retry; - } - } - } -#endif - -#ifdef SUPPORT_MAGIC_GATE - retval = rts51x_mg_set_tpc_para_sub(chip, 0, 0); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); -#endif - - if (CHK_HG8BIT(ms_card)) - chip->card_bus_width[chip->card2lun[MS_CARD]] = 8; - else - chip->card_bus_width[chip->card2lun[MS_CARD]] = 4; - - return STATUS_SUCCESS; -} - -static int ms_read_status_reg(struct rts51x_chip *chip) -{ - int retval; - u8 val[2]; - - retval = ms_set_rw_reg_addr(chip, StatusReg0, 2, 0, 0); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = ms_read_bytes(chip, READ_REG, 2, NO_WAIT_INT, val, 2); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - if (val[1] & (STS_UCDT | STS_UCEX | STS_UCFG)) { - ms_set_err_code(chip, MS_FLASH_READ_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } - - return STATUS_SUCCESS; -} - -static int ms_check_boot_block(struct rts51x_chip *chip, u16 block_addr) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval; - u8 extra[MS_EXTRA_SIZE], data[10], val = 0; - - if (CHK_MS4BIT(ms_card)) { - /* Parallel interface */ - data[0] = 0x88; - } else { - /* Serial interface */ - data[0] = 0x80; - } - /* Block Address */ - data[1] = 0; - data[2] = (u8) (block_addr >> 8); - data[3] = (u8) block_addr; - /* Page Number - * Extra data access mode */ - data[4] = 0x40; - data[5] = 0; - - retval = ms_set_cmd(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, 6, - BLOCK_READ, WAIT_INT, data, 6, &val); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (val & INT_REG_CMDNK) { - ms_set_err_code(chip, MS_CMD_NK); - TRACE_RET(chip, STATUS_FAIL); - } - if (val & INT_REG_CED) { - if (val & INT_REG_ERR) { - retval = ms_read_status_reg(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - retval = - ms_set_rw_reg_addr(chip, OverwriteFlag, - MS_EXTRA_SIZE, SystemParm, 6); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - } - - retval = - ms_read_bytes(chip, READ_REG, MS_EXTRA_SIZE, NO_WAIT_INT, extra, - MS_EXTRA_SIZE); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (!(extra[0] & BLOCK_OK) || (extra[1] & NOT_BOOT_BLOCK)) - TRACE_RET(chip, STATUS_FAIL); - - return STATUS_SUCCESS; -} - -static int ms_read_extra_data(struct rts51x_chip *chip, - u16 block_addr, u8 page_num, u8 *buf, - int buf_len) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval; - u8 val = 0, data[10]; - - if (CHK_MS4BIT(ms_card)) { - /* Parallel interface */ - data[0] = 0x88; - } else { - /* Serial interface */ - data[0] = 0x80; - } - /* Block Address */ - data[1] = 0; - data[2] = (u8) (block_addr >> 8); - data[3] = (u8) block_addr; - /* Page Number - * Extra data access mode */ - data[4] = 0x40; - data[5] = page_num; - -#ifdef MS_SPEEDUP - retval = - ms_auto_set_cmd(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, 6, - BLOCK_READ, WAIT_INT, data, 6, &val); -#else - retval = ms_set_cmd(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, 6, - BLOCK_READ, WAIT_INT, data, 6, &val); -#endif - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (val & INT_REG_CMDNK) { - ms_set_err_code(chip, MS_CMD_NK); - TRACE_RET(chip, STATUS_FAIL); - } - if (val & INT_REG_CED) { - if (val & INT_REG_ERR) { - retval = ms_read_status_reg(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - retval = - ms_set_rw_reg_addr(chip, OverwriteFlag, - MS_EXTRA_SIZE, SystemParm, 6); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - } - - retval = - ms_read_bytes(chip, READ_REG, MS_EXTRA_SIZE, NO_WAIT_INT, data, - MS_EXTRA_SIZE); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (buf && buf_len) { - if (buf_len > MS_EXTRA_SIZE) - buf_len = MS_EXTRA_SIZE; - memcpy(buf, data, buf_len); - } - - return STATUS_SUCCESS; -} - -static int ms_write_extra_data(struct rts51x_chip *chip, - u16 block_addr, u8 page_num, u8 *buf, - int buf_len) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval, i; - u8 val = 0, data[16]; - - if (!buf || (buf_len < MS_EXTRA_SIZE)) - TRACE_RET(chip, STATUS_FAIL); - /* Write REG */ - if (CHK_MS4BIT(ms_card)) { - /* Parallel interface */ - data[0] = 0x88; - } else { - /* Serial interface */ - data[0] = 0x80; - } - /* Block Address */ - data[1] = 0; - data[2] = (u8) (block_addr >> 8); - data[3] = (u8) block_addr; - /* Page Number - * Extra data access mode */ - data[4] = 0x40; - data[5] = page_num; - - for (i = 6; i < MS_EXTRA_SIZE + 6; i++) - data[i] = buf[i - 6]; - -#ifdef MS_SPEEDUP - retval = - ms_auto_set_cmd(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, - 6 + MS_EXTRA_SIZE, BLOCK_WRITE, WAIT_INT, data, 16, - &val); -#else - retval = - ms_set_cmd(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, - 6 + MS_EXTRA_SIZE, BLOCK_WRITE, WAIT_INT, data, 16, - &val); -#endif - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (val & INT_REG_CMDNK) { - ms_set_err_code(chip, MS_CMD_NK); - TRACE_RET(chip, STATUS_FAIL); - } - if (val & INT_REG_CED) { - if (val & INT_REG_ERR) { - ms_set_err_code(chip, MS_FLASH_WRITE_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } - } - - return STATUS_SUCCESS; -} - -static int ms_read_page(struct rts51x_chip *chip, u16 block_addr, u8 page_num) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval; - u8 val = 0, data[6]; - - if (CHK_MS4BIT(ms_card)) { - /* Parallel interface */ - data[0] = 0x88; - } else { - /* Serial interface */ - data[0] = 0x80; - } - /* Block Address */ - data[1] = 0; - data[2] = (u8) (block_addr >> 8); - data[3] = (u8) block_addr; - /* Page Number - * Single page access mode */ - data[4] = 0x20; - data[5] = page_num; - - retval = ms_set_cmd(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, 6, - BLOCK_READ, WAIT_INT, data, 6, &val); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (val & INT_REG_CMDNK) { - ms_set_err_code(chip, MS_CMD_NK); - TRACE_RET(chip, STATUS_FAIL); - } - - if (val & INT_REG_CED) { - if (val & INT_REG_ERR) { - if (!(val & INT_REG_BREQ)) { - ms_set_err_code(chip, MS_FLASH_READ_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } - retval = ms_read_status_reg(chip); - if (retval != STATUS_SUCCESS) - ms_set_err_code(chip, MS_FLASH_WRITE_ERROR); - } else { - if (!(val & INT_REG_BREQ)) { - ms_set_err_code(chip, MS_BREQ_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } - } - } - - retval = - ms_transfer_tpc(chip, MS_TM_NORMAL_READ, READ_PAGE_DATA, 0, - NO_WAIT_INT); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - if (ms_check_err_code(chip, MS_FLASH_WRITE_ERROR)) - TRACE_RET(chip, STATUS_FAIL); - - return STATUS_SUCCESS; -} - -static int ms_set_bad_block(struct rts51x_chip *chip, u16 phy_blk) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval; - u8 val = 0, data[8], extra[MS_EXTRA_SIZE]; - - retval = ms_read_extra_data(chip, phy_blk, 0, extra, MS_EXTRA_SIZE); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - ms_set_err_code(chip, MS_NO_ERROR); - - if (CHK_MS4BIT(ms_card)) { - /* Parallel interface */ - data[0] = 0x88; - } else { - /* Serial interface */ - data[0] = 0x80; - } - /* Block Address */ - data[1] = 0; - data[2] = (u8) (phy_blk >> 8); - data[3] = (u8) phy_blk; - data[4] = 0x80; - data[5] = 0; - data[6] = extra[0] & 0x7F; - data[7] = 0xFF; - -#ifdef MS_SPEEDUP - retval = ms_set_cmd(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, 7, - BLOCK_WRITE, WAIT_INT, data, 7, &val); -#else - retval = ms_set_cmd(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, 7, - BLOCK_WRITE, WAIT_INT, data, 7, &val); -#endif - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (val & INT_REG_CMDNK) { - ms_set_err_code(chip, MS_CMD_NK); - TRACE_RET(chip, STATUS_FAIL); - } - - if (val & INT_REG_CED) { - if (val & INT_REG_ERR) { - ms_set_err_code(chip, MS_FLASH_WRITE_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } - } - - return STATUS_SUCCESS; -} - -static int ms_erase_block(struct rts51x_chip *chip, u16 phy_blk) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval, i = 0; - u8 val = 0, data[6]; - - retval = - ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, - 6); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - ms_set_err_code(chip, MS_NO_ERROR); - - if (CHK_MS4BIT(ms_card)) { - /* Parallel interface */ - data[0] = 0x88; - } else { - /* Serial interface */ - data[0] = 0x80; - } - /* Block Address */ - data[1] = 0; - data[2] = (u8) (phy_blk >> 8); - data[3] = (u8) phy_blk; - data[4] = 0; - data[5] = 0; - -ERASE_RTY: -#ifdef MS_SPEEDUP - retval = - ms_auto_set_cmd(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, 6, - BLOCK_ERASE, WAIT_INT, data, 6, &val); -#else - retval = ms_set_cmd(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, 6, - BLOCK_ERASE, WAIT_INT, data, 6, &val); -#endif - - if (val & INT_REG_CMDNK) { - if (i < 3) { - i++; - goto ERASE_RTY; - } - ms_set_err_code(chip, MS_CMD_NK); - ms_set_bad_block(chip, phy_blk); - TRACE_RET(chip, STATUS_FAIL); - } - - if (val & INT_REG_CED) { - if (val & INT_REG_ERR) { - ms_set_err_code(chip, MS_FLASH_WRITE_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } - } - - return STATUS_SUCCESS; -} - -static void ms_set_page_status(u16 log_blk, u8 type, u8 *extra, int extra_len) -{ - if (!extra || (extra_len < MS_EXTRA_SIZE)) - return; - - memset(extra, 0xFF, MS_EXTRA_SIZE); - - if (type == setPS_NG) - extra[0] = 0xB8; - else - extra[0] = 0x98; - - extra[2] = (u8) (log_blk >> 8); - extra[3] = (u8) log_blk; -} - -static int ms_init_page(struct rts51x_chip *chip, u16 phy_blk, u16 log_blk, - u8 start_page, u8 end_page) -{ - int retval; - u8 extra[MS_EXTRA_SIZE], i; - - memset(extra, 0xff, MS_EXTRA_SIZE); - - extra[0] = 0xf8; /* Block, page OK, data erased */ - extra[1] = 0xff; - extra[2] = (u8) (log_blk >> 8); - extra[3] = (u8) log_blk; - - for (i = start_page; i < end_page; i++) { - if (monitor_card_cd(chip, MS_CARD) == CD_NOT_EXIST) - TRACE_RET(chip, STATUS_FAIL); - - retval = - ms_write_extra_data(chip, phy_blk, i, extra, MS_EXTRA_SIZE); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - - return STATUS_SUCCESS; -} - -static int ms_copy_page(struct rts51x_chip *chip, u16 old_blk, u16 new_blk, - u16 log_blk, u8 start_page, u8 end_page) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval, rty_cnt, uncorrect_flag = 0; - u8 extra[MS_EXTRA_SIZE], val, i, j, data[16]; - - RTS51X_DEBUGP("Copy page from 0x%x to 0x%x, logical block is 0x%x\n", - old_blk, new_blk, log_blk); - RTS51X_DEBUGP("start_page = %d, end_page = %d\n", start_page, - end_page); - - retval = ms_read_extra_data(chip, new_blk, 0, extra, MS_EXTRA_SIZE); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = ms_read_status_reg(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - RTS51X_READ_REG(chip, PPBUF_BASE2, &val); - - if (val & BUF_FULL) { - /* Clear Buffer */ - retval = ms_send_cmd(chip, CLEAR_BUF, WAIT_INT); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - /* GET_INT Register */ - retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (!(val & INT_REG_CED)) { - ms_set_err_code(chip, MS_FLASH_WRITE_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } - } - - for (i = start_page; i < end_page; i++) { - if (monitor_card_cd(chip, MS_CARD) == CD_NOT_EXIST) - TRACE_RET(chip, STATUS_FAIL); - - ms_read_extra_data(chip, old_blk, i, extra, MS_EXTRA_SIZE); - - retval = - ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, - SystemParm, 6); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - /* Write REG */ - ms_set_err_code(chip, MS_NO_ERROR); - - if (CHK_MS4BIT(ms_card)) { - /* Parallel interface */ - data[0] = 0x88; - } else { - /* Serial interface */ - data[0] = 0x80; - } - /* Block Address */ - data[1] = 0; - data[2] = (u8) (old_blk >> 8); - data[3] = (u8) old_blk; - data[4] = 0x20; - data[5] = i; - - retval = - ms_write_bytes(chip, WRITE_REG, 6, NO_WAIT_INT, data, 6); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = ms_send_cmd(chip, BLOCK_READ, WAIT_INT); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - ms_set_err_code(chip, MS_NO_ERROR); - retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (val & INT_REG_CMDNK) { - ms_set_err_code(chip, MS_CMD_NK); - TRACE_RET(chip, STATUS_FAIL); - } - - if (val & INT_REG_CED) { - if (val & INT_REG_ERR) { - retval = ms_read_status_reg(chip); - if (retval != STATUS_SUCCESS) { - uncorrect_flag = 1; - RTS51X_DEBUGP("Uncorrectable error\n"); - } else { - uncorrect_flag = 0; - } - - retval = - ms_transfer_tpc(chip, MS_TM_NORMAL_READ, - READ_PAGE_DATA, 0, NO_WAIT_INT); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - if (uncorrect_flag) { - ms_set_page_status(log_blk, setPS_NG, - extra, MS_EXTRA_SIZE); - if (i == 0) - extra[0] &= 0xEF; - ms_write_extra_data(chip, old_blk, i, - extra, - MS_EXTRA_SIZE); - RTS51X_DEBUGP("page %d : extra[0] = 0x%x\n", - i, extra[0]); - MS_SET_BAD_BLOCK_FLG(ms_card); - - ms_set_page_status(log_blk, setPS_Error, - extra, MS_EXTRA_SIZE); - ms_write_extra_data(chip, new_blk, i, - extra, MS_EXTRA_SIZE); - continue; - } - - for (rty_cnt = 0; rty_cnt < MS_MAX_RETRY_COUNT; - rty_cnt++) { - retval = - ms_transfer_tpc(chip, - MS_TM_NORMAL_WRITE, - WRITE_PAGE_DATA, 0, - NO_WAIT_INT); - if (retval == STATUS_SUCCESS) - break; - } - if (rty_cnt == MS_MAX_RETRY_COUNT) - TRACE_RET(chip, STATUS_FAIL); - } - - if (!(val & INT_REG_BREQ)) { - ms_set_err_code(chip, MS_BREQ_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } - } - - retval = ms_set_rw_reg_addr(chip, OverwriteFlag, - MS_EXTRA_SIZE, SystemParm, - (6 + MS_EXTRA_SIZE)); - - /* Write REG */ - ms_set_err_code(chip, MS_NO_ERROR); - - if (CHK_MS4BIT(ms_card)) { - /* Parallel interface */ - data[0] = 0x88; - } else { - /* Serial interface */ - data[0] = 0x80; - } - /* Block Address */ - data[1] = 0; - data[2] = (u8) (new_blk >> 8); - data[3] = (u8) new_blk; - data[4] = 0x20; - data[5] = i; - - /* for MS check procedure */ - if ((extra[0] & 0x60) != 0x60) - data[6] = extra[0]; - else - data[6] = 0xF8; - - data[6 + 1] = 0xFF; - data[6 + 2] = (u8) (log_blk >> 8); - data[6 + 3] = (u8) log_blk; - - for (j = 4; j <= MS_EXTRA_SIZE; j++) - data[6 + j] = 0xFF; - - retval = - ms_write_bytes(chip, WRITE_REG, (6 + MS_EXTRA_SIZE), - NO_WAIT_INT, data, 16); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = ms_send_cmd(chip, BLOCK_WRITE, WAIT_INT); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - /* GET_INT Register */ - ms_set_err_code(chip, MS_NO_ERROR); - retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (val & INT_REG_CMDNK) { - ms_set_err_code(chip, MS_CMD_NK); - TRACE_RET(chip, STATUS_FAIL); - } - - if (val & INT_REG_CED) { - if (val & INT_REG_ERR) { - ms_set_err_code(chip, MS_FLASH_WRITE_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } - } - - if (i == 0) { - retval = - ms_set_rw_reg_addr(chip, OverwriteFlag, - MS_EXTRA_SIZE, SystemParm, 7); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - ms_set_err_code(chip, MS_NO_ERROR); - - if (CHK_MS4BIT(ms_card)) { - /* Parallel interface */ - data[0] = 0x88; - } else { - /* Serial interface */ - data[0] = 0x80; - } - /* Block Address */ - data[1] = 0; - data[2] = (u8) (old_blk >> 8); - data[3] = (u8) old_blk; - data[4] = 0x80; - data[5] = 0; - data[6] = 0xEF; - data[7] = 0xFF; - - retval = - ms_write_bytes(chip, WRITE_REG, 7, NO_WAIT_INT, - data, 8); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = ms_send_cmd(chip, BLOCK_WRITE, WAIT_INT); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - ms_set_err_code(chip, MS_NO_ERROR); - retval = - ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, - 1); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (val & INT_REG_CMDNK) { - ms_set_err_code(chip, MS_CMD_NK); - TRACE_RET(chip, STATUS_FAIL); - } - - if (val & INT_REG_CED) { - if (val & INT_REG_ERR) { - ms_set_err_code(chip, - MS_FLASH_WRITE_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } - } - } - } - - return STATUS_SUCCESS; -} - -#ifdef MS_SPEEDUP -static int ms_auto_copy_page(struct rts51x_chip *chip, u16 old_blk, u16 new_blk, - u16 log_blk, u8 start_page, u8 end_page) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval; - u8 page_len, bus_width, val = 0; - u8 extra[MS_EXTRA_SIZE]; - - RTS51X_DEBUGP("Auto copy page from 0x%x to 0x%x, logical block is 0x%x\n", - old_blk, new_blk, log_blk); - RTS51X_DEBUGP("start_page = %d, end_page = %d\n", start_page, - end_page); - - page_len = end_page - start_page; - - retval = ms_read_extra_data(chip, new_blk, 0, extra, MS_EXTRA_SIZE); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = ms_read_status_reg(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - RTS51X_READ_REG(chip, PPBUF_BASE2, &val); - - if (val & BUF_FULL) { - retval = ms_send_cmd(chip, CLEAR_BUF, WAIT_INT); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (!(val & INT_REG_CED)) { - ms_set_err_code(chip, MS_FLASH_WRITE_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } - } - - if (CHK_MS4BIT(ms_card)) { - /* Parallel interface */ - bus_width = 0x88; - } else { - /* Serial interface */ - bus_width = 0x80; - } - - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_OLD_BLOCK_0, 0xFF, (u8) old_blk); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_OLD_BLOCK_1, 0xFF, - (u8) (old_blk >> 8)); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_NEW_BLOCK_0, 0xFF, (u8) new_blk); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_NEW_BLOCK_1, 0xFF, - (u8) (new_blk >> 8)); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_LOG_BLOCK_0, 0xFF, (u8) log_blk); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_LOG_BLOCK_1, 0xFF, - (u8) (log_blk >> 8)); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_PAGE_START, 0xFF, start_page); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_PAGE_LENGTH, 0xFF, page_len); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_BUS_WIDTH, 0xFF, bus_width); - - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANSFER, 0xFF, - MS_TRANSFER_START | MS_TM_COPY_PAGE); - rts51x_add_cmd(chip, CHECK_REG_CMD, MS_TRANSFER, MS_TRANSFER_END, - MS_TRANSFER_END); - - retval = rts51x_send_cmd(chip, MODE_CR, 100); - if (retval != STATUS_SUCCESS) { - rts51x_clear_ms_error(chip); - TRACE_RET(chip, retval); - } - - retval = rts51x_get_rsp(chip, 1, 5000); - - if (CHECK_MS_TRANS_FAIL(chip, retval)) { - rts51x_clear_ms_error(chip); - if (retval == STATUS_TIMEDOUT) - TRACE_RET(chip, retval); - TRACE_GOTO(chip, Fail); - } - - return STATUS_SUCCESS; - -Fail: - retval = ms_erase_block(chip, new_blk); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = - ms_copy_page(chip, old_blk, new_blk, log_blk, start_page, end_page); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - return STATUS_SUCCESS; -} -#endif - -static int reset_ms(struct rts51x_chip *chip) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval; - u16 i, reg_addr, block_size; - u8 val, j, *ptr; -#ifndef SUPPORT_MAGIC_GATE - u16 eblock_cnt; -#endif - - retval = ms_prepare_reset(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - ms_card->ms_type |= TYPE_MS; - - retval = ms_send_cmd(chip, MS_RESET, NO_WAIT_INT); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = ms_read_status_reg(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - RTS51X_READ_REG(chip, PPBUF_BASE2, &val); - if (val & WRT_PRTCT) - chip->card_wp |= MS_CARD; - else - chip->card_wp &= ~MS_CARD; - - i = 0; - -RE_SEARCH: - /* Search For Boot Block */ - while (i < (MAX_DEFECTIVE_BLOCK + 2)) { - if (monitor_card_cd(chip, MS_CARD) == CD_NOT_EXIST) - TRACE_RET(chip, STATUS_FAIL); - - retval = ms_check_boot_block(chip, i); - if (retval != STATUS_SUCCESS) { - i++; - continue; - } - - ms_card->boot_block = i; - break; - } - - if (i == (MAX_DEFECTIVE_BLOCK + 2)) { - RTS51X_DEBUGP("No boot block found!"); - TRACE_RET(chip, STATUS_FAIL); - } - for (j = 0; j < 3; j++) { - retval = ms_read_page(chip, ms_card->boot_block, j); - if (retval != STATUS_SUCCESS) { - if (ms_check_err_code(chip, MS_FLASH_WRITE_ERROR)) { - i = ms_card->boot_block + 1; - ms_set_err_code(chip, MS_NO_ERROR); - goto RE_SEARCH; - } - } - } - - /* Read boot block contents */ - retval = ms_read_page(chip, ms_card->boot_block, 0); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - /* Read MS system information as sys_info */ - retval = - rts51x_seq_read_register(chip, PPBUF_BASE2 + 0x1A0, 96, - ms_card->raw_sys_info); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - /* Read useful block contents */ - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, READ_REG_CMD, HEADER_ID0, 0, 0); - rts51x_add_cmd(chip, READ_REG_CMD, HEADER_ID1, 0, 0); - - for (reg_addr = DISABLED_BLOCK0; reg_addr <= DISABLED_BLOCK3; - reg_addr++) { - rts51x_add_cmd(chip, READ_REG_CMD, reg_addr, 0, 0); - } - - for (reg_addr = BLOCK_SIZE_0; reg_addr <= PAGE_SIZE_1; reg_addr++) - rts51x_add_cmd(chip, READ_REG_CMD, reg_addr, 0, 0); - - rts51x_add_cmd(chip, READ_REG_CMD, MS_Device_Type, 0, 0); - rts51x_add_cmd(chip, READ_REG_CMD, MS_4bit_Support, 0, 0); - - retval = rts51x_send_cmd(chip, MODE_CR, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = rts51x_get_rsp(chip, 16, 100); - - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - ptr = rts51x_get_rsp_data(chip); - - RTS51X_DEBUGP("Boot block data:\n"); - RTS51X_DUMP(ptr, 16); - - if (ptr[0] != 0x00 || ptr[1] != 0x01) { - i = ms_card->boot_block + 1; - goto RE_SEARCH; - } - if (ptr[12] != 0x02 || ptr[13] != 0x00) { - i = ms_card->boot_block + 1; - goto RE_SEARCH; - } - if ((ptr[14] == 1) || (ptr[14] == 3)) - chip->card_wp |= MS_CARD; - block_size = ((u16) ptr[6] << 8) | ptr[7]; - if (block_size == 0x0010) { - ms_card->block_shift = 5; - ms_card->page_off = 0x1F; - } else if (block_size == 0x0008) { - ms_card->block_shift = 4; - ms_card->page_off = 0x0F; - } - ms_card->total_block = ((u16) ptr[8] << 8) | ptr[9]; - -#ifdef SUPPORT_MAGIC_GATE - j = ptr[10]; - - if (ms_card->block_shift == 4) { - if (j < 2) - ms_card->capacity = 0x1EE0; - else - ms_card->capacity = 0x3DE0; - } else { - if (j < 5) - ms_card->capacity = 0x7BC0; - else if (j < 0xA) - ms_card->capacity = 0xF7C0; - else if (j < 0x11) - ms_card->capacity = 0x1EF80; - else - ms_card->capacity = 0x3DF00; - } -#else - eblock_cnt = ((u16) ptr[10] << 8) | ptr[11]; - - ms_card->capacity = ((u32) eblock_cnt - 2) << ms_card->block_shift; -#endif - - chip->capacity[chip->card2lun[MS_CARD]] = ms_card->capacity; - - if (ptr[15]) { - retval = ms_set_rw_reg_addr(chip, 0, 0, SystemParm, 1); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - RTS51X_WRITE_REG(chip, PPBUF_BASE2, 0xFF, 0x88); - RTS51X_WRITE_REG(chip, PPBUF_BASE2 + 1, 0xFF, 0); - - retval = - ms_transfer_tpc(chip, MS_TM_WRITE_BYTES, WRITE_REG, 1, - NO_WAIT_INT); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - RTS51X_WRITE_REG(chip, MS_CFG, 0x58 | MS_NO_CHECK_INT, - MS_BUS_WIDTH_4 | PUSH_TIME_ODD | - MS_NO_CHECK_INT); - - ms_card->ms_type |= MS_4BIT; - } - - if (CHK_MS4BIT(ms_card)) - chip->card_bus_width[chip->card2lun[MS_CARD]] = 4; - else - chip->card_bus_width[chip->card2lun[MS_CARD]] = 1; - - return STATUS_SUCCESS; -} - -static int ms_init_l2p_tbl(struct rts51x_chip *chip) -{ - struct ms_info *ms_card = &(chip->ms_card); - int size, i, seg_no, retval; - u16 defect_block, reg_addr; - u8 val1, val2; - - ms_card->segment_cnt = ms_card->total_block >> 9; - RTS51X_DEBUGP("ms_card->segment_cnt = %d\n", ms_card->segment_cnt); - - size = ms_card->segment_cnt * sizeof(struct zone_entry); - ms_card->segment = vmalloc(size); - if (ms_card->segment == NULL) - TRACE_RET(chip, STATUS_FAIL); - memset(ms_card->segment, 0, size); - - retval = ms_read_page(chip, ms_card->boot_block, 1); - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, INIT_FAIL); - - reg_addr = PPBUF_BASE2; - for (i = 0; i < (((ms_card->total_block >> 9) * 10) + 1); i++) { - retval = rts51x_read_register(chip, reg_addr++, &val1); - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, INIT_FAIL); - retval = rts51x_read_register(chip, reg_addr++, &val2); - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, INIT_FAIL); - - defect_block = ((u16) val1 << 8) | val2; - if (defect_block == 0xFFFF) - break; - seg_no = defect_block / 512; - ms_card->segment[seg_no].defect_list[ms_card->segment[seg_no]. - disable_count++] = - defect_block; - } - - for (i = 0; i < ms_card->segment_cnt; i++) { - ms_card->segment[i].build_flag = 0; - ms_card->segment[i].l2p_table = NULL; - ms_card->segment[i].free_table = NULL; - ms_card->segment[i].get_index = 0; - ms_card->segment[i].set_index = 0; - ms_card->segment[i].unused_blk_cnt = 0; - - RTS51X_DEBUGP("defective block count of segment %d is %d\n", - i, ms_card->segment[i].disable_count); - } - - return STATUS_SUCCESS; - -INIT_FAIL: - if (ms_card->segment) { - vfree(ms_card->segment); - ms_card->segment = NULL; - } - - return STATUS_FAIL; -} - -static u16 ms_get_l2p_tbl(struct rts51x_chip *chip, int seg_no, u16 log_off) -{ - struct ms_info *ms_card = &(chip->ms_card); - struct zone_entry *segment; - - if (ms_card->segment == NULL) - return 0xFFFF; - - segment = &(ms_card->segment[seg_no]); - - if (segment->l2p_table) - return segment->l2p_table[log_off]; - - return 0xFFFF; -} - -static void ms_set_l2p_tbl(struct rts51x_chip *chip, int seg_no, u16 log_off, - u16 phy_blk) -{ - struct ms_info *ms_card = &(chip->ms_card); - struct zone_entry *segment; - - if (ms_card->segment == NULL) - return; - - segment = &(ms_card->segment[seg_no]); - if (segment->l2p_table) - segment->l2p_table[log_off] = phy_blk; -} - -static void ms_set_unused_block(struct rts51x_chip *chip, u16 phy_blk) -{ - struct ms_info *ms_card = &(chip->ms_card); - struct zone_entry *segment; - int seg_no; - - seg_no = (int)phy_blk >> 9; - segment = &(ms_card->segment[seg_no]); - - segment->free_table[segment->set_index++] = phy_blk; - if (segment->set_index >= MS_FREE_TABLE_CNT) - segment->set_index = 0; - segment->unused_blk_cnt++; -} - -static u16 ms_get_unused_block(struct rts51x_chip *chip, int seg_no) -{ - struct ms_info *ms_card = &(chip->ms_card); - struct zone_entry *segment; - u16 phy_blk; - - segment = &(ms_card->segment[seg_no]); - - if (segment->unused_blk_cnt <= 0) - return 0xFFFF; - - phy_blk = segment->free_table[segment->get_index]; - segment->free_table[segment->get_index++] = 0xFFFF; - if (segment->get_index >= MS_FREE_TABLE_CNT) - segment->get_index = 0; - segment->unused_blk_cnt--; - - return phy_blk; -} - -static const unsigned short ms_start_idx[] = { - 0, 494, 990, 1486, 1982, 2478, 2974, 3470, - 3966, 4462, 4958, 5454, 5950, 6446, 6942, 7438, 7934 -}; - -static int ms_arbitrate_l2p(struct rts51x_chip *chip, u16 phy_blk, u16 log_off, - u8 us1, u8 us2) -{ - struct ms_info *ms_card = &(chip->ms_card); - struct zone_entry *segment; - int seg_no; - u16 tmp_blk; - - seg_no = (int)phy_blk >> 9; - segment = &(ms_card->segment[seg_no]); - tmp_blk = segment->l2p_table[log_off]; - - if (us1 != us2) { - if (us1 == 0) { - if (!(chip->card_wp & MS_CARD)) - ms_erase_block(chip, tmp_blk); - ms_set_unused_block(chip, tmp_blk); - segment->l2p_table[log_off] = phy_blk; - } else { - if (!(chip->card_wp & MS_CARD)) - ms_erase_block(chip, phy_blk); - ms_set_unused_block(chip, phy_blk); - } - } else { - if (phy_blk < tmp_blk) { - if (!(chip->card_wp & MS_CARD)) - ms_erase_block(chip, phy_blk); - ms_set_unused_block(chip, phy_blk); - } else { - if (!(chip->card_wp & MS_CARD)) - ms_erase_block(chip, tmp_blk); - ms_set_unused_block(chip, tmp_blk); - segment->l2p_table[log_off] = phy_blk; - } - } - - return STATUS_SUCCESS; -} - -static int ms_build_l2p_tbl(struct rts51x_chip *chip, int seg_no) -{ - struct ms_info *ms_card = &(chip->ms_card); - struct zone_entry *segment; - int retval, table_size, disable_cnt, defect_flag, i; - u16 start, end, phy_blk, log_blk, tmp_blk; - u8 extra[MS_EXTRA_SIZE], us1, us2; - - RTS51X_DEBUGP("ms_build_l2p_tbl: %d\n", seg_no); - - if (ms_card->segment == NULL) { - retval = ms_init_l2p_tbl(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - - if (ms_card->segment[seg_no].build_flag) { - RTS51X_DEBUGP("l2p table of segment %d has been built\n", - seg_no); - return STATUS_SUCCESS; - } - - if (seg_no == 0) - table_size = 494; - else - table_size = 496; - - segment = &(ms_card->segment[seg_no]); - - if (segment->l2p_table == NULL) { - segment->l2p_table = vmalloc(table_size * 2); - if (segment->l2p_table == NULL) - TRACE_GOTO(chip, BUILD_FAIL); - } - memset((u8 *) (segment->l2p_table), 0xff, table_size * 2); - - if (segment->free_table == NULL) { - segment->free_table = vmalloc(MS_FREE_TABLE_CNT * 2); - if (segment->free_table == NULL) - TRACE_GOTO(chip, BUILD_FAIL); - } - memset((u8 *) (segment->free_table), 0xff, MS_FREE_TABLE_CNT * 2); - - start = (u16) seg_no << 9; - end = (u16) (seg_no + 1) << 9; - - disable_cnt = segment->disable_count; - - segment->get_index = segment->set_index = 0; - segment->unused_blk_cnt = 0; - - for (phy_blk = start; phy_blk < end; phy_blk++) { - if (disable_cnt) { - defect_flag = 0; - for (i = 0; i < segment->disable_count; i++) { - if (phy_blk == segment->defect_list[i]) { - defect_flag = 1; - break; - } - } - if (defect_flag) { - disable_cnt--; - continue; - } - } - - retval = - ms_read_extra_data(chip, phy_blk, 0, extra, MS_EXTRA_SIZE); - if (retval != STATUS_SUCCESS) { - RTS51X_DEBUGP("read extra data fail\n"); - ms_set_bad_block(chip, phy_blk); - continue; - } - - if (seg_no == ms_card->segment_cnt - 1) { - if (!(extra[1] & NOT_TRANSLATION_TABLE)) { - if (!(chip->card_wp & MS_CARD)) { - retval = ms_erase_block(chip, phy_blk); - if (retval != STATUS_SUCCESS) - continue; - extra[2] = 0xff; - extra[3] = 0xff; - } - } - } - - if (!(extra[0] & BLOCK_OK)) - continue; - if (!(extra[1] & NOT_BOOT_BLOCK)) - continue; - if ((extra[0] & PAGE_OK) != PAGE_OK) - continue; - - log_blk = ((u16) extra[2] << 8) | extra[3]; - - if (log_blk == 0xFFFF) { - if (!(chip->card_wp & MS_CARD)) { - retval = ms_erase_block(chip, phy_blk); - if (retval != STATUS_SUCCESS) - continue; - } - ms_set_unused_block(chip, phy_blk); - continue; - } - - if ((log_blk < ms_start_idx[seg_no]) || - (log_blk >= ms_start_idx[seg_no + 1])) { - if (!(chip->card_wp & MS_CARD)) { - retval = ms_erase_block(chip, phy_blk); - if (retval != STATUS_SUCCESS) - continue; - } - ms_set_unused_block(chip, phy_blk); - continue; - } - - if (segment->l2p_table[log_blk - ms_start_idx[seg_no]] == - 0xFFFF) { - segment->l2p_table[log_blk - ms_start_idx[seg_no]] = - phy_blk; - continue; - } - - us1 = extra[0] & 0x10; - tmp_blk = segment->l2p_table[log_blk - ms_start_idx[seg_no]]; - retval = - ms_read_extra_data(chip, tmp_blk, 0, extra, MS_EXTRA_SIZE); - if (retval != STATUS_SUCCESS) - continue; - us2 = extra[0] & 0x10; - - (void)ms_arbitrate_l2p(chip, phy_blk, - log_blk - ms_start_idx[seg_no], us1, - us2); - continue; - } - - segment->build_flag = 1; - - RTS51X_DEBUGP("unused block count: %d\n", segment->unused_blk_cnt); - - if (seg_no == ms_card->segment_cnt - 1) { - if (segment->unused_blk_cnt < 2) - chip->card_wp |= MS_CARD; - } else { - if (segment->unused_blk_cnt < 1) - chip->card_wp |= MS_CARD; - } - - if (chip->card_wp & MS_CARD) - return STATUS_SUCCESS; - - for (log_blk = ms_start_idx[seg_no]; log_blk < ms_start_idx[seg_no + 1]; - log_blk++) { - if (segment->l2p_table[log_blk - ms_start_idx[seg_no]] == - 0xFFFF) { - phy_blk = ms_get_unused_block(chip, seg_no); - if (phy_blk == 0xFFFF) { - chip->card_wp |= MS_CARD; - return STATUS_SUCCESS; - } - retval = ms_init_page(chip, phy_blk, log_blk, 0, 1); - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, BUILD_FAIL); - segment->l2p_table[log_blk - ms_start_idx[seg_no]] = - phy_blk; - if (seg_no == ms_card->segment_cnt - 1) { - if (segment->unused_blk_cnt < 2) { - chip->card_wp |= MS_CARD; - return STATUS_SUCCESS; - } - } else { - if (segment->unused_blk_cnt < 1) { - chip->card_wp |= MS_CARD; - return STATUS_SUCCESS; - } - } - } - } - - if (seg_no == 0) { - for (log_blk = 0; log_blk < 494; log_blk++) { - tmp_blk = segment->l2p_table[log_blk]; - if (tmp_blk < ms_card->boot_block) { - RTS51X_DEBUGP("Boot block is not the first normal block.\n"); - - if (chip->card_wp & MS_CARD) - break; - - phy_blk = ms_get_unused_block(chip, 0); -#ifdef MS_SPEEDUP - retval = - ms_auto_copy_page(chip, tmp_blk, phy_blk, - log_blk, 0, - ms_card->page_off + 1); -#else - retval = ms_copy_page(chip, tmp_blk, phy_blk, - log_blk, 0, - ms_card->page_off + 1); -#endif - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - segment->l2p_table[log_blk] = phy_blk; - - retval = ms_set_bad_block(chip, tmp_blk); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - } - } - - return STATUS_SUCCESS; - -BUILD_FAIL: - segment->build_flag = 0; - if (segment->l2p_table) { - vfree(segment->l2p_table); - segment->l2p_table = NULL; - } - if (segment->free_table) { - vfree(segment->free_table); - segment->free_table = NULL; - } - - return STATUS_FAIL; -} - -int rts51x_reset_ms_card(struct rts51x_chip *chip) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval; - - memset(ms_card, 0, sizeof(struct ms_info)); - - rts51x_enable_card_clock(chip, MS_CARD); - - retval = rts51x_select_card(chip, MS_CARD); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - ms_card->ms_type = 0; - ms_card->last_rw_int = 0; - - retval = reset_ms_pro(chip); - if (retval != STATUS_SUCCESS) { - if (ms_card->check_ms_flow) { - retval = reset_ms(chip); - if (retval != STATUS_SUCCESS) { - if (chip->option.reset_or_rw_fail_set_pad_drive) { - rts51x_write_register(chip, - CARD_DRIVE_SEL, SD20_DRIVE_MASK, - DRIVE_8mA); - } - TRACE_RET(chip, retval); - } - } else { - if (chip->option.reset_or_rw_fail_set_pad_drive) { - rts51x_write_register(chip, CARD_DRIVE_SEL, - SD20_DRIVE_MASK, - DRIVE_8mA); - } - TRACE_RET(chip, retval); - } - } - - retval = ms_set_init_para(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (!CHK_MSPRO(ms_card)) { - retval = ms_build_l2p_tbl(chip, ms_card->total_block / 512 - 1); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - - RTS51X_DEBUGP("ms_card->ms_type = 0x%x\n", ms_card->ms_type); - - return STATUS_SUCCESS; -} - -static int mspro_set_rw_cmd(struct rts51x_chip *chip, u32 start_sec, - u16 sec_cnt, u8 cmd) -{ - int retval, i; - u8 data[8]; - - data[0] = cmd; - data[1] = (u8) (sec_cnt >> 8); - data[2] = (u8) sec_cnt; - data[3] = (u8) (start_sec >> 24); - data[4] = (u8) (start_sec >> 16); - data[5] = (u8) (start_sec >> 8); - data[6] = (u8) start_sec; - data[7] = 0; - - for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { - retval = - ms_write_bytes(chip, PRO_EX_SET_CMD, 7, WAIT_INT, data, 8); - if (retval == STATUS_SUCCESS) - break; - } - if (i == MS_MAX_RETRY_COUNT) - TRACE_RET(chip, STATUS_FAIL); - - return STATUS_SUCCESS; -} - -static void mspro_stop_seq_mode(struct rts51x_chip *chip) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval; - - if (ms_card->seq_mode) { - retval = ms_switch_clock(chip); - if (retval != STATUS_SUCCESS) - return; - - ms_card->seq_mode = 0; - ms_card->total_sec_cnt = 0; - ms_card->last_rw_int = 0; - ms_send_cmd(chip, PRO_STOP, WAIT_INT); - - rts51x_ep0_write_register(chip, MC_FIFO_CTL, FIFO_FLUSH, - FIFO_FLUSH); - } -} - -static inline int ms_auto_tune_clock(struct rts51x_chip *chip) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval; - - if (chip->asic_code) { - if (ms_card->ms_clock > 30) - ms_card->ms_clock -= 20; - } else { - if (ms_card->ms_clock == CLK_80) - ms_card->ms_clock = CLK_60; - else if (ms_card->ms_clock == CLK_60) - ms_card->ms_clock = CLK_40; - } - - retval = ms_switch_clock(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - return STATUS_SUCCESS; -} - -static int mspro_rw_multi_sector(struct scsi_cmnd *srb, - struct rts51x_chip *chip, u32 start_sector, - u16 sector_cnt) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval, mode_2k = 0; - u16 count; - u8 val, trans_mode, rw_tpc, rw_cmd; - - ms_set_err_code(chip, MS_NO_ERROR); - - ms_card->counter = 0; - - if (CHK_MSHG(ms_card)) { - if ((start_sector % 4) || (sector_cnt % 4)) { - if (srb->sc_data_direction == DMA_FROM_DEVICE) { - rw_tpc = PRO_READ_LONG_DATA; - rw_cmd = PRO_READ_DATA; - } else { - rw_tpc = PRO_WRITE_LONG_DATA; - rw_cmd = PRO_WRITE_DATA; - } - } else { - if (srb->sc_data_direction == DMA_FROM_DEVICE) { - rw_tpc = PRO_READ_QUAD_DATA; - rw_cmd = PRO_READ_2K_DATA; - } else { - rw_tpc = PRO_WRITE_QUAD_DATA; - rw_cmd = PRO_WRITE_2K_DATA; - } - mode_2k = 1; - } - } else { - if (srb->sc_data_direction == DMA_FROM_DEVICE) { - rw_tpc = PRO_READ_LONG_DATA; - rw_cmd = PRO_READ_DATA; - } else { - rw_tpc = PRO_WRITE_LONG_DATA; - rw_cmd = PRO_WRITE_DATA; - } - } - - retval = ms_switch_clock(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (srb->sc_data_direction == DMA_FROM_DEVICE) - trans_mode = MS_TM_AUTO_READ; - else - trans_mode = MS_TM_AUTO_WRITE; - - val = ms_card->last_rw_int; - - if (ms_card->seq_mode) { - if ((ms_card->pre_dir != srb->sc_data_direction) - || ((ms_card->pre_sec_addr + ms_card->pre_sec_cnt) != - start_sector) - || (mode_2k && (ms_card->seq_mode & MODE_512_SEQ)) - || (!mode_2k && (ms_card->seq_mode & MODE_2K_SEQ)) - || !(val & MS_INT_BREQ) - || ((ms_card->total_sec_cnt + sector_cnt) > 0xFE00)) { - ms_card->seq_mode = 0; - ms_card->total_sec_cnt = 0; - ms_card->last_rw_int = 0; - if (val & MS_INT_BREQ) { - retval = ms_send_cmd(chip, PRO_STOP, WAIT_INT); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - rts51x_ep0_write_register(chip, MC_FIFO_CTL, - FIFO_FLUSH, FIFO_FLUSH); - } - } - } - - if (!ms_card->seq_mode) { - ms_card->total_sec_cnt = 0; - if (sector_cnt >= 0x80) { - if ((ms_card->capacity - start_sector) > 0xFE00) - count = 0xFE00; - else - count = - (u16) (ms_card->capacity - start_sector); - if (count > sector_cnt) { - if (mode_2k) - ms_card->seq_mode |= MODE_2K_SEQ; - else - ms_card->seq_mode |= MODE_512_SEQ; - } - } else { - count = sector_cnt; - } - retval = mspro_set_rw_cmd(chip, start_sector, count, rw_cmd); - if (retval != STATUS_SUCCESS) { - ms_card->seq_mode = 0; - TRACE_RET(chip, retval); - } - } - - retval = - ms_transfer_data(chip, trans_mode, rw_tpc, sector_cnt, WAIT_INT, - mode_2k, scsi_sg_count(srb), scsi_sglist(srb), - scsi_bufflen(srb)); - if (retval != STATUS_SUCCESS) { - ms_card->seq_mode = 0; - rts51x_ep0_read_register(chip, MS_TRANS_CFG, &val); - rts51x_clear_ms_error(chip); - if (val & MS_INT_BREQ) - ms_send_cmd(chip, PRO_STOP, WAIT_INT); - if (val & (MS_CRC16_ERR | MS_RDY_TIMEOUT)) { - RTS51X_DEBUGP("MSPro CRC error, tune clock!\n"); - ms_auto_tune_clock(chip); - } - - TRACE_RET(chip, retval); - } - - ms_card->pre_sec_addr = start_sector; - ms_card->pre_sec_cnt = sector_cnt; - ms_card->pre_dir = srb->sc_data_direction; - ms_card->total_sec_cnt += sector_cnt; - - return STATUS_SUCCESS; -} - -static int mspro_read_format_progress(struct rts51x_chip *chip, - const int short_data_len) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval, i; - u32 total_progress, cur_progress; - u8 cnt, tmp; - u8 data[8]; - - ms_card->format_status = FORMAT_FAIL; - - retval = ms_switch_clock(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - RTS51X_READ_REG(chip, MS_TRANS_CFG, &tmp); - - if ((tmp & (MS_INT_CED | MS_INT_CMDNK | MS_INT_ERR)) == MS_INT_CED) { - ms_card->format_status = FORMAT_SUCCESS; - ms_card->pro_under_formatting = 0; - return STATUS_SUCCESS; - } - if (! - ((tmp & (MS_INT_BREQ | MS_INT_CED | MS_INT_CMDNK | MS_INT_ERR)) == - MS_INT_BREQ)) { - ms_card->pro_under_formatting = 0; - TRACE_RET(chip, STATUS_FAIL); - } - - if (short_data_len >= 256) - cnt = 0; - else - cnt = (u8) short_data_len; - - retval = - ms_read_bytes(chip, PRO_READ_SHORT_DATA, cnt, WAIT_INT, data, 8); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - total_progress = - (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3]; - cur_progress = - (data[4] << 24) | (data[5] << 16) | (data[6] << 8) | data[7]; - - RTS51X_DEBUGP("total_progress = %d, cur_progress = %d\n", - total_progress, cur_progress); - - if (total_progress == 0) { - ms_card->progress = 0; - } else { - u64 ulltmp = (u64) cur_progress * (u64) 65535; - do_div(ulltmp, total_progress); - ms_card->progress = (u16) ulltmp; - } - RTS51X_DEBUGP("progress = %d\n", ms_card->progress); - - for (i = 0; i < 2500; i++) { - RTS51X_READ_REG(chip, MS_TRANS_CFG, &tmp); - if (tmp & - (MS_INT_CED | MS_INT_CMDNK | MS_INT_BREQ | MS_INT_ERR)) - break; - - wait_timeout(1); - } - - if (i == 2500) - TRACE_RET(chip, STATUS_FAIL); - - RTS51X_DEBUGP("MSPro format tmp:%d\n", tmp); - - if (tmp & (MS_INT_CMDNK | MS_INT_ERR)) - TRACE_RET(chip, STATUS_FAIL); - if (tmp & MS_INT_CED) { - ms_card->format_status = FORMAT_SUCCESS; - ms_card->pro_under_formatting = 0; - } else if (tmp & MS_INT_BREQ) { - ms_card->format_status = FORMAT_IN_PROGRESS; - } else { - ms_card->format_status = FORMAT_FAIL; - ms_card->pro_under_formatting = 0; - TRACE_RET(chip, STATUS_FAIL); - } - - RTS51X_DEBUGP("MSPro format format_status:%d\n", - ms_card->format_status); - - return STATUS_SUCCESS; -} - -void rts51x_mspro_polling_format_status(struct rts51x_chip *chip) -{ - struct ms_info *ms_card = &(chip->ms_card); - int i; - - if (ms_card->pro_under_formatting) { - for (i = 0; i < 65535; i++) { - mspro_read_format_progress(chip, MS_SHORT_DATA_LEN); - if (ms_card->format_status != FORMAT_IN_PROGRESS) - break; - } - } - - return; -} - -void rts51x_mspro_format_sense(struct rts51x_chip *chip, unsigned int lun) -{ - struct ms_info *ms_card = &(chip->ms_card); - - if (CHK_FORMAT_STATUS(ms_card, FORMAT_SUCCESS)) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_NO_SENSE); - ms_card->pro_under_formatting = 0; - ms_card->progress = 0; - } else if (CHK_FORMAT_STATUS(ms_card, FORMAT_IN_PROGRESS)) { - rts51x_set_sense_data(chip, lun, CUR_ERR, 0x02, 0, 0x04, 0x04, - 0, (u16) (ms_card->progress)); - } else { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_FORMAT_CMD_FAILED); - ms_card->pro_under_formatting = 0; - ms_card->progress = 0; - } -} - -int rts51x_mspro_format(struct scsi_cmnd *srb, struct rts51x_chip *chip, - int short_data_len, int quick_format) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval, i; - u8 buf[8], tmp; - u16 para; - - retval = ms_switch_clock(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = ms_set_rw_reg_addr(chip, 0x00, 0x00, Pro_TPCParm, 0x01); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - memset(buf, 0, 2); - switch (short_data_len) { - case 32: - buf[0] = 0; - break; - case 64: - buf[0] = 1; - break; - case 128: - buf[0] = 2; - break; - case 256: - default: - buf[0] = 3; - break; - } - - for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { - retval = - ms_write_bytes(chip, PRO_WRITE_REG, 1, NO_WAIT_INT, buf, 2); - if (retval == STATUS_SUCCESS) - break; - } - if (i == MS_MAX_RETRY_COUNT) - TRACE_RET(chip, STATUS_FAIL); - /* Format command */ - if (quick_format) - para = 0x0000; - else - para = 0x0001; - retval = mspro_set_rw_cmd(chip, 0, para, PRO_FORMAT); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - /* Check INT */ - RTS51X_READ_REG(chip, MS_TRANS_CFG, &tmp); - if (tmp & (MS_INT_CMDNK | MS_INT_ERR)) - TRACE_RET(chip, STATUS_FAIL); - - if ((tmp & (MS_INT_BREQ | MS_INT_CED)) == MS_INT_BREQ) { - ms_card->pro_under_formatting = 1; - ms_card->progress = 0; - ms_card->format_status = FORMAT_IN_PROGRESS; - return STATUS_SUCCESS; - } - - if (tmp & MS_INT_CED) { - ms_card->pro_under_formatting = 0; - ms_card->progress = 0; - ms_card->format_status = FORMAT_SUCCESS; - rts51x_set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_NO_SENSE); - return STATUS_SUCCESS; - } - - TRACE_RET(chip, STATUS_FAIL); -} - -#ifdef MS_SPEEDUP -static int ms_read_multiple_pages(struct rts51x_chip *chip, u16 phy_blk, - u16 log_blk, u8 start_page, u8 end_page, - u8 *buf, void **ptr, unsigned int *offset) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval; - int send_blkend; - u8 extra[MS_EXTRA_SIZE], val1, val2, data[6]; - u8 page_cnt = end_page - start_page, page_addr, sec_cnt; - - if (end_page != (ms_card->page_off + 1)) - send_blkend = 1; - else - send_blkend = 0; - - retval = - ms_read_extra_data(chip, phy_blk, start_page, extra, MS_EXTRA_SIZE); - if (retval == STATUS_SUCCESS) { - if ((extra[1] & 0x30) != 0x30) { - ms_set_err_code(chip, MS_FLASH_READ_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } - } - - if (CHK_MS4BIT(ms_card)) { - /* Parallel interface */ - data[0] = 0x88; - } else { - /* Serial interface */ - data[0] = 0x80; - } - /* Block Address */ - data[1] = 0; - data[2] = (u8) (phy_blk >> 8); - data[3] = (u8) phy_blk; - /* Page Number - * Extra data access mode */ - data[4] = 0; - data[5] = start_page; - - retval = - ms_auto_set_cmd(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, 6, - BLOCK_READ, WAIT_INT, data, 6, &val1); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - rts51x_init_cmd(chip); - - if (send_blkend) - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_BLKEND, SET_BLKEND, - SET_BLKEND); - else - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_BLKEND, SET_BLKEND, 0); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANS_CFG, WAIT_INT, - NO_WAIT_INT); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_SECTOR_CNT_L, 0xFF, - (u8) page_cnt); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_SECTOR_CNT_H, 0xFF, 0); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TPC, 0xFF, READ_PAGE_DATA); - - rts51x_trans_dma_enable(DMA_FROM_DEVICE, chip, 512 * page_cnt, DMA_512); - - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANSFER, 0xFF, - MS_TRANSFER_START | MS_TM_MULTI_READ); - rts51x_add_cmd(chip, CHECK_REG_CMD, MS_TRANSFER, MS_TRANSFER_END, - MS_TRANSFER_END); - - retval = rts51x_send_cmd(chip, MODE_CDIR | STAGE_MS_STATUS, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = - rts51x_transfer_data_partial(chip, RCV_BULK_PIPE(chip), (void *)buf, - ptr, offset, 512 * page_cnt, - scsi_sg_count(chip->srb), NULL, 2000); - if (retval != STATUS_SUCCESS) { - rts51x_clear_ms_error(chip); - if (retval == STATUS_TIMEDOUT) - TRACE_RET(chip, retval); - TRACE_GOTO(chip, Fail); - } - retval = rts51x_get_rsp(chip, 3, 200); - if (CHECK_MS_TRANS_FAIL(chip, retval)) { - rts51x_clear_ms_error(chip); - if (retval == STATUS_TIMEDOUT) - TRACE_RET(chip, retval); - TRACE_GOTO(chip, Fail); - } - - return STATUS_SUCCESS; - -Fail: - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, READ_REG_CMD, MS_SECTOR_CNT_L, 0, 0); - - retval = rts51x_send_cmd(chip, MODE_CR | STAGE_MS_STATUS, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = rts51x_get_rsp(chip, 3, 200); - - if (CHECK_MS_TRANS_FAIL(chip, retval)) - TRACE_RET(chip, STATUS_FAIL); - - sec_cnt = chip->rsp_buf[0]; - RTS51X_DEBUGP("%d pages need be transferred, %d pages remained\n", - (int)page_cnt, (int)sec_cnt); - page_addr = start_page + (page_cnt - sec_cnt); - - if (CHK_MS4BIT(ms_card)) { - val1 = chip->rsp_buf[1]; - RTS51X_DEBUGP("MS_TRANS_CFG: 0x%x\n", val1); - } else { - val1 = 0; - } - - val2 = chip->rsp_buf[2]; - RTS51X_DEBUGP("GET_INT: 0x%x\n", val2); - - if ((val1 & INT_CMDNK) || (val2 & INT_REG_CMDNK)) { - ms_set_err_code(chip, MS_CMD_NK); - TRACE_RET(chip, STATUS_FAIL); - } - - if ((val1 & INT_ERR) || (val2 & INT_REG_ERR)) { - if ((val1 & INT_BREQ) || (val2 & INT_REG_BREQ)) { - retval = ms_read_status_reg(chip); - if (retval != STATUS_SUCCESS) { - if (!(chip->card_wp & MS_CARD)) { - reset_ms(chip); - ms_set_page_status(log_blk, setPS_NG, - extra, MS_EXTRA_SIZE); - ms_write_extra_data(chip, phy_blk, - page_addr, extra, - MS_EXTRA_SIZE); - } - ms_set_err_code(chip, MS_FLASH_READ_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } - } else { - ms_set_err_code(chip, MS_FLASH_READ_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } - } else { - if (CHK_MS4BIT(ms_card)) { - if (!(val1 & INT_BREQ) && !(val2 & INT_REG_BREQ)) { - ms_set_err_code(chip, MS_BREQ_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } - } else { - if (!(val2 & INT_REG_BREQ)) { - ms_set_err_code(chip, MS_BREQ_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } - } - } - - TRACE_RET(chip, STATUS_FAIL); -} - -static int ms_write_multiple_pages(struct rts51x_chip *chip, u16 old_blk, - u16 new_blk, u16 log_blk, u8 start_page, - u8 end_page, u8 *buf, void **ptr, - unsigned int *offset) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval, i; - int send_blkend; - u8 val, data[16]; - u8 page_cnt = end_page - start_page; - - if ((end_page == (ms_card->page_off + 1)) || (page_cnt == 1)) - send_blkend = 0; - else - send_blkend = 1; - - if (!start_page) { - if (CHK_MS4BIT(ms_card)) { - /* Parallel interface */ - data[0] = 0x88; - } else { - /* Serial interface */ - data[0] = 0x80; - } - /* Block Address */ - data[1] = 0; - data[2] = (u8) (old_blk >> 8); - data[3] = (u8) old_blk; - data[4] = 0x80; - data[5] = 0; - data[6] = 0xEF; - data[7] = 0xFF; - - retval = - ms_auto_set_cmd(chip, OverwriteFlag, MS_EXTRA_SIZE, - SystemParm, 7, BLOCK_WRITE, WAIT_INT, data, - 7, &val); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - - retval = - ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, - (6 + MS_EXTRA_SIZE)); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - ms_set_err_code(chip, MS_NO_ERROR); - - if (CHK_MS4BIT(ms_card)) { - /* Parallel interface */ - data[0] = 0x88; - } else { - /* Serial interface */ - data[0] = 0x80; - } - /* Block Address */ - data[1] = 0; - data[2] = (u8) (new_blk >> 8); - data[3] = (u8) new_blk; - /* Page Number - * Extra data access mode */ - if (page_cnt == 1) { - /* Single page access mode */ - data[4] = 0x20; - } else { - /* Block access mode */ - data[4] = 0; - } - data[5] = start_page; - data[6] = 0xF8; - data[7] = 0xFF; - data[8] = (u8) (log_blk >> 8); - data[9] = (u8) log_blk; - - for (i = 0x0A; i < 0x10; i++) { - /* ECC */ - data[i] = 0xFF; - } - - retval = - ms_auto_set_cmd(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, - (6 + MS_EXTRA_SIZE), BLOCK_WRITE, WAIT_INT, data, - 16, &val); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - rts51x_init_cmd(chip); - - if (send_blkend) - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_BLKEND, SET_BLKEND, - SET_BLKEND); - else - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_BLKEND, SET_BLKEND, 0); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANS_CFG, WAIT_INT, - NO_WAIT_INT); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_SECTOR_CNT_L, 0xFF, - (u8) page_cnt); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_SECTOR_CNT_H, 0xFF, 0); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TPC, 0xFF, WRITE_PAGE_DATA); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, - RING_BUFFER); - - rts51x_trans_dma_enable(DMA_TO_DEVICE, chip, 512 * page_cnt, DMA_512); - - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANSFER, 0xFF, - MS_TRANSFER_START | MS_TM_MULTI_WRITE); - rts51x_add_cmd(chip, CHECK_REG_CMD, MS_TRANSFER, MS_TRANSFER_END, - MS_TRANSFER_END); - - retval = rts51x_send_cmd(chip, MODE_CDOR | STAGE_MS_STATUS, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = - rts51x_transfer_data_partial(chip, SND_BULK_PIPE(chip), (void *)buf, - ptr, offset, 512 * page_cnt, - scsi_sg_count(chip->srb), NULL, 2000); - if (retval != STATUS_SUCCESS) { - rts51x_clear_ms_error(chip); - TRACE_RET(chip, retval); - } - - retval = rts51x_get_rsp(chip, 3, 2000); - - - if (CHECK_MS_TRANS_FAIL(chip, retval)) { - rts51x_clear_ms_error(chip); - TRACE_RET(chip, STATUS_FAIL); - } - - return STATUS_SUCCESS; -} - -#else - -static int ms_read_multiple_pages(struct rts51x_chip *chip, u16 phy_blk, - u16 log_blk, u8 start_page, u8 end_page, - u8 *buf, void **ptr, unsigned int *offset) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval, i; - u8 extra[MS_EXTRA_SIZE], page_addr, val, trans_cfg, data[6]; - - retval = - ms_read_extra_data(chip, phy_blk, start_page, extra, MS_EXTRA_SIZE); - if (retval == STATUS_SUCCESS) { - if ((extra[1] & 0x30) != 0x30) { - ms_set_err_code(chip, MS_FLASH_READ_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } - } - - retval = - ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, - 6); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - /* Write REG */ - if (CHK_MS4BIT(ms_card)) { - /* Parallel interface */ - data[0] = 0x88; - } else { - /* Serial interface */ - data[0] = 0x80; - } - /* Block Address */ - data[1] = 0; - data[2] = (u8) (phy_blk >> 8); - data[3] = (u8) phy_blk; - /* Page Number - * Extra data access mode */ - data[4] = 0; - data[5] = start_page; - - for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { - retval = - ms_write_bytes(chip, WRITE_REG, 6, NO_WAIT_INT, data, 6); - if (retval == STATUS_SUCCESS) - break; - } - if (i == MS_MAX_RETRY_COUNT) - TRACE_RET(chip, STATUS_FAIL); - - ms_set_err_code(chip, MS_NO_ERROR); - - retval = ms_send_cmd(chip, BLOCK_READ, WAIT_INT); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - for (page_addr = start_page; page_addr < end_page; page_addr++) { - ms_set_err_code(chip, MS_NO_ERROR); - - if (monitor_card_cd(chip, MS_CARD) == CD_NOT_EXIST) { - ms_set_err_code(chip, MS_NO_CARD); - chip->card_exist &= ~MS_CARD; - chip->card_ready &= ~MS_CARD; - TRACE_RET(chip, STATUS_FAIL); - } - /* GET_INT Register */ - retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - if (val & INT_REG_CMDNK) { - ms_set_err_code(chip, MS_CMD_NK); - TRACE_RET(chip, STATUS_FAIL); - } - if (val & INT_REG_ERR) { - if (val & INT_REG_BREQ) { - retval = ms_read_status_reg(chip); - if (retval != STATUS_SUCCESS) { - if (!(chip->card_wp & MS_CARD)) { - reset_ms(chip); - ms_set_page_status(log_blk, - setPS_NG, extra, - MS_EXTRA_SIZE); - ms_write_extra_data(chip, - phy_blk, page_addr, - extra, MS_EXTRA_SIZE); - } - ms_set_err_code(chip, - MS_FLASH_READ_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } - } else { - ms_set_err_code(chip, MS_FLASH_READ_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } - } else { - if (!(val & INT_REG_BREQ)) { - ms_set_err_code(chip, MS_BREQ_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } - } - - if (page_addr == (end_page - 1)) { - if (!(val & INT_REG_CED)) { - retval = ms_send_cmd(chip, BLOCK_END, WAIT_INT); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - retval = - ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, - 1); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - if (!(val & INT_REG_CED)) { - ms_set_err_code(chip, MS_FLASH_READ_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } - - trans_cfg = NO_WAIT_INT; - } else { - trans_cfg = WAIT_INT; - } - - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TPC, 0xFF, - READ_PAGE_DATA); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANS_CFG, 0xFF, - trans_cfg); - - rts51x_trans_dma_enable(DMA_FROM_DEVICE, chip, 512, DMA_512); - - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANSFER, 0xFF, - MS_TRANSFER_START | MS_TM_NORMAL_READ); - rts51x_add_cmd(chip, CHECK_REG_CMD, MS_TRANSFER, - MS_TRANSFER_END, MS_TRANSFER_END); - - retval = rts51x_send_cmd(chip, MODE_CDIR, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = - rts51x_transfer_data_partial(chip, RCV_BULK_PIPE(chip), - (void *)buf, ptr, offset, 512, - scsi_sg_count(chip->srb), NULL, - 2000); - if (retval != STATUS_SUCCESS) { - if (retval == STATUS_TIMEDOUT) { - ms_set_err_code(chip, MS_TO_ERROR); - rts51x_clear_ms_error(chip); - TRACE_RET(chip, retval); - } - - retval = - rts51x_ep0_read_register(chip, MS_TRANS_CFG, &val); - if (retval != STATUS_SUCCESS) { - ms_set_err_code(chip, MS_TO_ERROR); - rts51x_clear_ms_error(chip); - TRACE_RET(chip, STATUS_FAIL); - } - if (val & (MS_CRC16_ERR | MS_RDY_TIMEOUT)) { - ms_set_err_code(chip, MS_CRC16_ERROR); - rts51x_clear_ms_error(chip); - TRACE_RET(chip, STATUS_FAIL); - } - } - - retval = rts51x_get_rsp(chip, 1, 2000); - if (CHECK_MS_TRANS_FAIL(chip, retval)) { - if (retval == STATUS_TIMEDOUT) { - ms_set_err_code(chip, MS_TO_ERROR); - rts51x_clear_ms_error(chip); - TRACE_RET(chip, retval); - } - - retval = - rts51x_ep0_read_register(chip, MS_TRANS_CFG, &val); - if (retval != STATUS_SUCCESS) { - ms_set_err_code(chip, MS_TO_ERROR); - rts51x_clear_ms_error(chip); - TRACE_RET(chip, retval); - } - if (val & (MS_CRC16_ERR | MS_RDY_TIMEOUT)) { - ms_set_err_code(chip, MS_CRC16_ERROR); - rts51x_clear_ms_error(chip); - TRACE_RET(chip, STATUS_FAIL); - } - } - } - - return STATUS_SUCCESS; -} - -static int ms_write_multiple_pages(struct rts51x_chip *chip, u16 old_blk, - u16 new_blk, u16 log_blk, u8 start_page, - u8 end_page, u8 *buf, void **ptr, - unsigned int *offset) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval, i; - u8 page_addr, val, data[16]; - - if (!start_page) { - retval = - ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, - SystemParm, 7); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (CHK_MS4BIT(ms_card)) { - /* Parallel interface */ - data[0] = 0x88; - } else { - /* Serial interface */ - data[0] = 0x80; - } - /* Block Address */ - data[1] = 0; - data[2] = (u8) (old_blk >> 8); - data[3] = (u8) old_blk; - data[4] = 0x80; - data[5] = 0; - data[6] = 0xEF; - data[7] = 0xFF; - - retval = - ms_write_bytes(chip, WRITE_REG, 7, NO_WAIT_INT, data, 8); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = ms_send_cmd(chip, BLOCK_WRITE, WAIT_INT); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - /* GET_INT Register */ - ms_set_err_code(chip, MS_NO_ERROR); - retval = - ms_transfer_tpc(chip, MS_TM_READ_BYTES, GET_INT, 1, - NO_WAIT_INT); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - - retval = - ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, SystemParm, - (6 + MS_EXTRA_SIZE)); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - ms_set_err_code(chip, MS_NO_ERROR); - - if (CHK_MS4BIT(ms_card)) { - /* Parallel interface */ - data[0] = 0x88; - } else { - /* Serial interface */ - data[0] = 0x80; - } - /* Block Address */ - data[1] = 0; - data[2] = (u8) (new_blk >> 8); - data[3] = (u8) new_blk; - /* Page Number - * Extra data access mode */ - if ((end_page - start_page) == 1) { - /* Single page access mode */ - data[4] = 0x20; - } else { - /* Block access mode */ - data[4] = 0; - } - data[5] = start_page; - data[6] = 0xF8; - data[7] = 0xFF; - data[8] = (u8) (log_blk >> 8); - data[9] = (u8) log_blk; - - for (i = 0x0A; i < 0x10; i++) { - /* ECC */ - data[i] = 0xFF; - } - - for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { - retval = - ms_write_bytes(chip, WRITE_REG, 6 + MS_EXTRA_SIZE, - NO_WAIT_INT, data, 16); - if (retval == STATUS_SUCCESS) - break; - } - if (i == MS_MAX_RETRY_COUNT) - TRACE_RET(chip, STATUS_FAIL); - - for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { - retval = ms_send_cmd(chip, BLOCK_WRITE, WAIT_INT); - if (retval == STATUS_SUCCESS) - break; - } - if (i == MS_MAX_RETRY_COUNT) - TRACE_RET(chip, STATUS_FAIL); - /* GET_INT Register */ - retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - for (page_addr = start_page; page_addr < end_page; page_addr++) { - ms_set_err_code(chip, MS_NO_ERROR); - - if (monitor_card_cd(chip, MS_CARD) == CD_NOT_EXIST) { - ms_set_err_code(chip, MS_NO_CARD); - TRACE_RET(chip, STATUS_FAIL); - } - - if (val & INT_REG_CMDNK) { - ms_set_err_code(chip, MS_CMD_NK); - TRACE_RET(chip, STATUS_FAIL); - } - if (val & INT_REG_ERR) { - ms_set_err_code(chip, MS_FLASH_WRITE_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } - if (!(val & INT_REG_BREQ)) { - ms_set_err_code(chip, MS_BREQ_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } - - udelay(30); - - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TPC, 0xFF, - WRITE_PAGE_DATA); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANS_CFG, 0xFF, - WAIT_INT); - - rts51x_trans_dma_enable(DMA_TO_DEVICE, chip, 512, DMA_512); - - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANSFER, 0xFF, - MS_TRANSFER_START | MS_TM_NORMAL_WRITE); - rts51x_add_cmd(chip, CHECK_REG_CMD, MS_TRANSFER, - MS_TRANSFER_END, MS_TRANSFER_END); - - retval = rts51x_send_cmd(chip, MODE_CDOR, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = - rts51x_transfer_data_partial(chip, SND_BULK_PIPE(chip), - (void *)buf, ptr, offset, 512, - scsi_sg_count(chip->srb), NULL, - 2000); - if (retval != STATUS_SUCCESS) { - ms_set_err_code(chip, MS_TO_ERROR); - rts51x_clear_ms_error(chip); - - if (retval == STATUS_TIMEDOUT) - TRACE_RET(chip, STATUS_TIMEDOUT); - else - TRACE_RET(chip, STATUS_FAIL); - } - - retval = rts51x_get_rsp(chip, 1, 2000); - if (CHECK_MS_TRANS_FAIL(chip, retval)) { - ms_set_err_code(chip, MS_TO_ERROR); - rts51x_clear_ms_error(chip); - - if (retval == STATUS_TIMEDOUT) - TRACE_RET(chip, STATUS_TIMEDOUT); - else - TRACE_RET(chip, STATUS_FAIL); - } - /* GET_INT Register */ - retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if ((end_page - start_page) == 1) { - if (!(val & INT_REG_CED)) { - /* Command can not be executed */ - ms_set_err_code(chip, MS_FLASH_WRITE_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } - } else { - if (page_addr == (end_page - 1)) { - if (!(val & INT_REG_CED)) { - retval = - ms_send_cmd(chip, BLOCK_END, - WAIT_INT); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - /* GET_INT Register */ - retval = - ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, - &val, 1); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - - if ((page_addr == (end_page - 1)) - || (page_addr == ms_card->page_off)) { - if (!(val & INT_REG_CED)) { - ms_set_err_code(chip, - MS_FLASH_WRITE_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } - } - } - } - - return STATUS_SUCCESS; -} -#endif - -static int ms_finish_write(struct rts51x_chip *chip, u16 old_blk, u16 new_blk, - u16 log_blk, u8 page_off) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval, seg_no; - -#ifdef MS_SPEEDUP - retval = ms_auto_copy_page(chip, old_blk, new_blk, log_blk, - page_off, ms_card->page_off + 1); -#else - retval = ms_copy_page(chip, old_blk, new_blk, log_blk, - page_off, ms_card->page_off + 1); -#endif - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - seg_no = old_blk >> 9; - - if (MS_TST_BAD_BLOCK_FLG(ms_card)) { - MS_CLR_BAD_BLOCK_FLG(ms_card); - ms_set_bad_block(chip, old_blk); - } else { - retval = ms_erase_block(chip, old_blk); - if (retval == STATUS_SUCCESS) - ms_set_unused_block(chip, old_blk); - } - - ms_set_l2p_tbl(chip, seg_no, log_blk - ms_start_idx[seg_no], new_blk); - - return STATUS_SUCCESS; -} - -static int ms_prepare_write(struct rts51x_chip *chip, u16 old_blk, u16 new_blk, - u16 log_blk, u8 start_page) -{ - int retval; - - if (start_page) { -#ifdef MS_SPEEDUP - retval = - ms_auto_copy_page(chip, old_blk, new_blk, log_blk, 0, - start_page); -#else - retval = - ms_copy_page(chip, old_blk, new_blk, log_blk, 0, - start_page); -#endif - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - - return STATUS_SUCCESS; -} - -int rts51x_ms_delay_write(struct rts51x_chip *chip) -{ - struct ms_info *ms_card = &(chip->ms_card); - struct rts51x_ms_delay_write_tag *delay_write = &(ms_card->delay_write); - int retval; - - if (delay_write->delay_write_flag) { - retval = ms_set_init_para(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - delay_write->delay_write_flag = 0; - retval = ms_finish_write(chip, - delay_write->old_phyblock, - delay_write->new_phyblock, - delay_write->logblock, - delay_write->pageoff); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - - return STATUS_SUCCESS; -} - -static inline void rts51x_ms_rw_fail(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - if (srb->sc_data_direction == DMA_FROM_DEVICE) - rts51x_set_sense_type(chip, SCSI_LUN(srb), - SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - else - rts51x_set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_WRITE_ERR); -} - -static int rts51x_ms_rw_multi_sector(struct scsi_cmnd *srb, struct rts51x_chip *chip, - u32 start_sector, u16 sector_cnt) -{ - struct ms_info *ms_card = &(chip->ms_card); - unsigned int lun = SCSI_LUN(srb); - int retval, seg_no; - unsigned int offset = 0; - u16 old_blk = 0, new_blk = 0, log_blk, total_sec_cnt = sector_cnt; - u8 start_page, end_page = 0, page_cnt; - u8 *buf; - void *ptr = NULL; - struct rts51x_ms_delay_write_tag *delay_write = &(ms_card->delay_write); - - ms_set_err_code(chip, MS_NO_ERROR); - - ms_card->counter = 0; - - buf = (u8 *) scsi_sglist(srb); - - retval = ms_switch_clock(chip); - if (retval != STATUS_SUCCESS) { - rts51x_ms_rw_fail(srb, chip); - TRACE_RET(chip, retval); - } - - log_blk = (u16) (start_sector >> ms_card->block_shift); - start_page = (u8) (start_sector & ms_card->page_off); - - for (seg_no = 0; seg_no < ARRAY_SIZE(ms_start_idx) - 1; seg_no++) { - if (log_blk < ms_start_idx[seg_no + 1]) - break; - } - - if (ms_card->segment[seg_no].build_flag == 0) { - retval = ms_build_l2p_tbl(chip, seg_no); - if (retval != STATUS_SUCCESS) { - chip->card_fail |= MS_CARD; - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - TRACE_RET(chip, retval); - } - } - - if (srb->sc_data_direction == DMA_TO_DEVICE) { - if (delay_write->delay_write_flag && - (delay_write->logblock == log_blk) && - (start_page > delay_write->pageoff)) { - delay_write->delay_write_flag = 0; -#ifdef MS_SPEEDUP - retval = ms_auto_copy_page(chip, - delay_write->old_phyblock, - delay_write->new_phyblock, - log_blk, - delay_write->pageoff, - start_page); -#else - retval = ms_copy_page(chip, - delay_write->old_phyblock, - delay_write->new_phyblock, - log_blk, delay_write->pageoff, - start_page); -#endif - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_WRITE_ERR); - TRACE_RET(chip, retval); - } - old_blk = delay_write->old_phyblock; - new_blk = delay_write->new_phyblock; - } else if (delay_write->delay_write_flag && - (delay_write->logblock == log_blk) && - (start_page == delay_write->pageoff)) { - delay_write->delay_write_flag = 0; - old_blk = delay_write->old_phyblock; - new_blk = delay_write->new_phyblock; - } else { - retval = rts51x_ms_delay_write(chip); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_WRITE_ERR); - TRACE_RET(chip, retval); - } - old_blk = - ms_get_l2p_tbl(chip, seg_no, - log_blk - ms_start_idx[seg_no]); - new_blk = ms_get_unused_block(chip, seg_no); - if ((old_blk == 0xFFFF) || (new_blk == 0xFFFF)) { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_WRITE_ERR); - TRACE_RET(chip, STATUS_FAIL); - } - - retval = - ms_prepare_write(chip, old_blk, new_blk, log_blk, - start_page); - if (retval != STATUS_SUCCESS) { - if (monitor_card_cd(chip, MS_CARD) == - CD_NOT_EXIST) { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_NOT_PRESENT); - TRACE_RET(chip, STATUS_FAIL); - } - - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_WRITE_ERR); - TRACE_RET(chip, retval); - } - } - } else { - retval = rts51x_ms_delay_write(chip); - if (retval != STATUS_SUCCESS) { - if (monitor_card_cd(chip, MS_CARD) == CD_NOT_EXIST) { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_NOT_PRESENT); - TRACE_RET(chip, STATUS_FAIL); - } - - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - TRACE_RET(chip, retval); - } - old_blk = - ms_get_l2p_tbl(chip, seg_no, - log_blk - ms_start_idx[seg_no]); - if (old_blk == 0xFFFF) { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - TRACE_RET(chip, STATUS_FAIL); - } - } - - RTS51X_DEBUGP("seg_no = %d, old_blk = 0x%x, new_blk = 0x%x\n", seg_no, - old_blk, new_blk); - - while (total_sec_cnt) { - if ((start_page + total_sec_cnt) > (ms_card->page_off + 1)) - end_page = ms_card->page_off + 1; - else - end_page = start_page + (u8) total_sec_cnt; - page_cnt = end_page - start_page; - - RTS51X_DEBUGP("start_page = %d, end_page = %d, page_cnt = %d\n", - start_page, end_page, page_cnt); - - if (srb->sc_data_direction == DMA_FROM_DEVICE) - retval = ms_read_multiple_pages(chip, - old_blk, log_blk, - start_page, end_page, - buf, &ptr, &offset); - else - retval = ms_write_multiple_pages(chip, old_blk, - new_blk, log_blk, - start_page, end_page, - buf, &ptr, &offset); - - if (retval != STATUS_SUCCESS) { - if (monitor_card_cd(chip, MS_CARD) == CD_NOT_EXIST) { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_NOT_PRESENT); - TRACE_RET(chip, STATUS_FAIL); - } - - rts51x_ms_rw_fail(srb, chip); - TRACE_RET(chip, retval); - } - /* Update L2P table if need */ - if (srb->sc_data_direction == DMA_TO_DEVICE) { - if (end_page == (ms_card->page_off + 1)) { - retval = ms_erase_block(chip, old_blk); - if (retval == STATUS_SUCCESS) - ms_set_unused_block(chip, old_blk); - ms_set_l2p_tbl(chip, seg_no, - log_blk - ms_start_idx[seg_no], - new_blk); - } - } - - total_sec_cnt -= page_cnt; - - if (total_sec_cnt == 0) - break; - - log_blk++; - - for (seg_no = 0; seg_no < ARRAY_SIZE(ms_start_idx) - 1; - seg_no++) { - if (log_blk < ms_start_idx[seg_no + 1]) - break; - } - - if (ms_card->segment[seg_no].build_flag == 0) { - retval = ms_build_l2p_tbl(chip, seg_no); - if (retval != STATUS_SUCCESS) { - chip->card_fail |= MS_CARD; - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_NOT_PRESENT); - TRACE_RET(chip, retval); - } - } - - old_blk = - ms_get_l2p_tbl(chip, seg_no, - log_blk - ms_start_idx[seg_no]); - if (old_blk == 0xFFFF) { - rts51x_ms_rw_fail(srb, chip); - TRACE_RET(chip, STATUS_FAIL); - } - - if (srb->sc_data_direction == DMA_TO_DEVICE) { - new_blk = ms_get_unused_block(chip, seg_no); - if (new_blk == 0xFFFF) { - rts51x_ms_rw_fail(srb, chip); - TRACE_RET(chip, STATUS_FAIL); - } - } - - RTS51X_DEBUGP("seg_no = %d, old_blk = 0x%x, new_blk = 0x%x\n", - seg_no, old_blk, new_blk); - - start_page = 0; - } - - if (srb->sc_data_direction == DMA_TO_DEVICE) { - if (end_page < (ms_card->page_off + 1)) { - delay_write->delay_write_flag = 1; - delay_write->old_phyblock = old_blk; - delay_write->new_phyblock = new_blk; - delay_write->logblock = log_blk; - delay_write->pageoff = end_page; - } - } - - scsi_set_resid(srb, 0); - - return STATUS_SUCCESS; -} - -int rts51x_ms_rw(struct scsi_cmnd *srb, struct rts51x_chip *chip, u32 start_sector, - u16 sector_cnt) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval; - - if (CHK_MSPRO(ms_card)) - retval = - mspro_rw_multi_sector(srb, chip, start_sector, sector_cnt); - else - retval = - rts51x_ms_rw_multi_sector(srb, chip, start_sector, sector_cnt); - - return retval; -} - -void rts51x_ms_free_l2p_tbl(struct rts51x_chip *chip) -{ - struct ms_info *ms_card = &(chip->ms_card); - int i = 0; - - if (ms_card->segment != NULL) { - for (i = 0; i < ms_card->segment_cnt; i++) { - if (ms_card->segment[i].l2p_table != NULL) { - vfree(ms_card->segment[i].l2p_table); - ms_card->segment[i].l2p_table = NULL; - } - if (ms_card->segment[i].free_table != NULL) { - vfree(ms_card->segment[i].free_table); - ms_card->segment[i].free_table = NULL; - } - } - vfree(ms_card->segment); - ms_card->segment = NULL; - } -} - -void rts51x_ms_cleanup_work(struct rts51x_chip *chip) -{ - struct ms_info *ms_card = &(chip->ms_card); - - if (CHK_MSPRO(ms_card)) { - if (ms_card->seq_mode) { - RTS51X_DEBUGP("MS Pro: stop transmission\n"); - mspro_stop_seq_mode(chip); - ms_card->counter = 0; - } - if (CHK_MSHG(ms_card)) { - u8 value; - rts51x_read_register(chip, MS_CFG, &value); - if (value & MS_2K_SECTOR_MODE) - rts51x_write_register(chip, MS_CFG, - MS_2K_SECTOR_MODE, 0x00); - } - } else if ((!CHK_MSPRO(ms_card)) - && ms_card->delay_write.delay_write_flag) { - RTS51X_DEBUGP("MS: delay write\n"); - rts51x_ms_delay_write(chip); - ms_card->counter = 0; - } -} - -static int ms_power_off_card3v3(struct rts51x_chip *chip) -{ - int retval; - - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_CLK_EN, MS_CLK_EN, 0); - if (chip->asic_code) - ms_pull_ctl_disable(chip); - else - rts51x_add_cmd(chip, WRITE_REG_CMD, FPGA_PULL_CTL, - FPGA_MS_PULL_CTL_BIT | 0x20, - FPGA_MS_PULL_CTL_BIT); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_OE, MS_OUTPUT_EN, 0); - if (!chip->option.FT2_fast_mode) { - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, POWER_MASK, - POWER_OFF); - } - - retval = rts51x_send_cmd(chip, MODE_C, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - return STATUS_SUCCESS; -} - -int rts51x_release_ms_card(struct rts51x_chip *chip) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval; - - RTS51X_DEBUGP("rts51x_release_ms_card\n"); - - ms_card->delay_write.delay_write_flag = 0; - ms_card->pro_under_formatting = 0; - - chip->card_ready &= ~MS_CARD; - chip->card_fail &= ~MS_CARD; - chip->card_wp &= ~MS_CARD; - - rts51x_ms_free_l2p_tbl(chip); - - rts51x_write_register(chip, SFSM_ED, HW_CMD_STOP, HW_CMD_STOP); - - memset(ms_card->raw_sys_info, 0, 96); -#ifdef SUPPORT_PCGL_1P18 - memset(ms_card->raw_model_name, 0, 48); -#endif - - retval = ms_power_off_card3v3(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - return STATUS_SUCCESS; -} diff --git a/drivers/staging/rts5139/ms.h b/drivers/staging/rts5139/ms.h deleted file mode 100644 index 857c1974ef24..000000000000 --- a/drivers/staging/rts5139/ms.h +++ /dev/null @@ -1,261 +0,0 @@ -/* Driver for Realtek RTS51xx USB card reader - * Header file - * - * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. - * - * 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, 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, see . - * - * Author: - * wwang (wei_wang@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - * Maintainer: - * Edwin Rong (edwin_rong@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - */ - -#ifndef __RTS51X_MS_H -#define __RTS51X_MS_H - -#include "rts51x_chip.h" - -#define MS_MAX_RETRY_COUNT 3 - -#define MS_EXTRA_SIZE 0x9 - -#define WRT_PRTCT 0x01 - -/* Error Code */ -#define MS_NO_ERROR 0x00 -#define MS_CRC16_ERROR 0x80 -#define MS_TO_ERROR 0x40 -#define MS_NO_CARD 0x20 -#define MS_NO_MEMORY 0x10 -#define MS_CMD_NK 0x08 -#define MS_FLASH_READ_ERROR 0x04 -#define MS_FLASH_WRITE_ERROR 0x02 -#define MS_BREQ_ERROR 0x01 -#define MS_NOT_FOUND 0x03 - -/* Transfer Protocol Command */ -#define READ_PAGE_DATA 0x02 -#define READ_REG 0x04 -#define GET_INT 0x07 -#define WRITE_PAGE_DATA 0x0D -#define WRITE_REG 0x0B -#define SET_RW_REG_ADRS 0x08 -#define SET_CMD 0x0E - -#define PRO_READ_LONG_DATA 0x02 -#define PRO_READ_SHORT_DATA 0x03 -#define PRO_READ_REG 0x04 -#define PRO_READ_QUAD_DATA 0x05 -#define PRO_GET_INT 0x07 -#define PRO_WRITE_LONG_DATA 0x0D -#define PRO_WRITE_SHORT_DATA 0x0C -#define PRO_WRITE_QUAD_DATA 0x0A -#define PRO_WRITE_REG 0x0B -#define PRO_SET_RW_REG_ADRS 0x08 -#define PRO_SET_CMD 0x0E -#define PRO_EX_SET_CMD 0x09 - -#ifdef SUPPORT_MAGIC_GATE -#define MG_GET_ID 0x40 -#define MG_SET_LID 0x41 -#define MG_GET_LEKB 0x42 -#define MG_SET_RD 0x43 -#define MG_MAKE_RMS 0x44 -#define MG_MAKE_KSE 0x45 -#define MG_SET_IBD 0x46 -#define MG_GET_IBD 0x47 -#endif - -#ifdef XC_POWERCLASS -#define XC_CHG_POWER 0x16 -#endif - -/* ++ CMD over Memory Stick */ -/* Flash CMD */ -#define BLOCK_READ 0xAA -#define BLOCK_WRITE 0x55 -#define BLOCK_END 0x33 -#define BLOCK_ERASE 0x99 -#define FLASH_STOP 0xCC - -/* Function CMD */ -#define SLEEP 0x5A -#define CLEAR_BUF 0xC3 -#define MS_RESET 0x3C -/* -- CMD over Memory Stick */ - -/* ++ CMD over Memory Stick Pro */ -/* Flash CMD */ -#define PRO_READ_DATA 0x20 -#define PRO_WRITE_DATA 0x21 -#define PRO_READ_ATRB 0x24 -#define PRO_STOP 0x25 -#define PRO_ERASE 0x26 -#define PRO_READ_2K_DATA 0x27 -#define PRO_WRITE_2K_DATA 0x28 - -/* Function CMD */ -#define PRO_FORMAT 0x10 -#define PRO_SLEEP 0x11 -/* -- CMD over Memory Stick Pro */ - -/* register inside memory stick */ -#define IntReg 0x01 -#define StatusReg0 0x02 -#define StatusReg1 0x03 - -#define SystemParm 0x10 -#define BlockAdrs 0x11 -#define CMDParm 0x14 -#define PageAdrs 0x15 - -#define OverwriteFlag 0x16 -#define ManagemenFlag 0x17 -#define LogicalAdrs 0x18 -#define ReserveArea 0x1A - -/* register inside memory pro */ -#define Pro_IntReg 0x01 -#define Pro_StatusReg 0x02 -#define Pro_TypeReg 0x04 -#define Pro_IFModeReg 0x05 -#define Pro_CatagoryReg 0x06 -#define Pro_ClassReg 0x07 - -#define Pro_SystemParm 0x10 -#define Pro_DataCount1 0x11 -#define Pro_DataCount0 0x12 -#define Pro_DataAddr3 0x13 -#define Pro_DataAddr2 0x14 -#define Pro_DataAddr1 0x15 -#define Pro_DataAddr0 0x16 - -#define Pro_TPCParm 0x17 -#define Pro_CMDParm 0x18 - -/* define for INT Register */ -#define INT_REG_CED 0x80 -#define INT_REG_ERR 0x40 -#define INT_REG_BREQ 0x20 -#define INT_REG_CMDNK 0x01 - -/* INT signal */ -#define INT_CED 0x01 -#define INT_ERR 0x02 -#define INT_BREQ 0x04 -#define INT_CMDNK 0x08 - -/* define for OverwriteFlag Register */ -#define BLOCK_BOOT 0xC0 -#define BLOCK_OK 0x80 -#define PAGE_OK 0x60 -#define DATA_COMPL 0x10 - -/* define for ManagemenFlag Register */ -#define NOT_BOOT_BLOCK 0x4 -#define NOT_TRANSLATION_TABLE 0x8 - -/* Header */ -#define HEADER_ID0 (PPBUF_BASE2) /* 0 */ -#define HEADER_ID1 (PPBUF_BASE2 + 1) /* 1 */ -/* System Entry */ -#define DISABLED_BLOCK0 (PPBUF_BASE2 + 0x170 + 4) /* 2 */ -#define DISABLED_BLOCK1 (PPBUF_BASE2 + 0x170 + 5) /* 3 */ -#define DISABLED_BLOCK2 (PPBUF_BASE2 + 0x170 + 6) /* 4 */ -#define DISABLED_BLOCK3 (PPBUF_BASE2 + 0x170 + 7) /* 5 */ -/* Boot & Attribute Information */ -#define BLOCK_SIZE_0 (PPBUF_BASE2 + 0x1a0 + 2) /* 6 */ -#define BLOCK_SIZE_1 (PPBUF_BASE2 + 0x1a0 + 3) /* 7 */ -#define BLOCK_COUNT_0 (PPBUF_BASE2 + 0x1a0 + 4) /* 8 */ -#define BLOCK_COUNT_1 (PPBUF_BASE2 + 0x1a0 + 5) /* 9 */ -#define EBLOCK_COUNT_0 (PPBUF_BASE2 + 0x1a0 + 6) /* 10 */ -#define EBLOCK_COUNT_1 (PPBUF_BASE2 + 0x1a0 + 7) /* 11 */ -#define PAGE_SIZE_0 (PPBUF_BASE2 + 0x1a0 + 8) /* 12 */ -#define PAGE_SIZE_1 (PPBUF_BASE2 + 0x1a0 + 9) /* 13 */ - -/* joey 2004-08-07 for MS check Procedure */ -#define MS_Device_Type (PPBUF_BASE2 + 0x1D8) /* 14 */ -/* end */ - -/* joey 2004-05-03 */ -#define MS_4bit_Support (PPBUF_BASE2 + 0x1D3) /* 15 */ -/* end */ - -#define setPS_NG 1 -#define setPS_Error 0 - -/* define for Pro_SystemParm Register */ -#define PARALLEL_8BIT_IF 0x40 -#define PARALLEL_4BIT_IF 0x00 -#define SERIAL_IF 0x80 - -/* define for StatusReg0 Register */ -#define BUF_FULL 0x10 -#define BUF_EMPTY 0x20 - -/* define for StatusReg1 Register */ -#define MEDIA_BUSY 0x80 -#define FLASH_BUSY 0x40 -#define DATA_ERROR 0x20 -#define STS_UCDT 0x10 -#define EXTRA_ERROR 0x08 -#define STS_UCEX 0x04 -#define FLAG_ERROR 0x02 -#define STS_UCFG 0x01 - -#define MS_SHORT_DATA_LEN 32 - -#define FORMAT_SUCCESS 0 -#define FORMAT_FAIL 1 -#define FORMAT_IN_PROGRESS 2 - -#define MS_SET_BAD_BLOCK_FLG(ms_card) ((ms_card)->multi_flag |= 0x80) -#define MS_CLR_BAD_BLOCK_FLG(ms_card) ((ms_card)->multi_flag &= 0x7F) -#define MS_TST_BAD_BLOCK_FLG(ms_card) ((ms_card)->multi_flag & 0x80) - -#define CHECK_MS_TRANS_FAIL(chip, retval) \ - (((retval) != STATUS_SUCCESS) || \ - (chip->rsp_buf[0] & MS_TRANSFER_ERR)) - -void rts51x_mspro_polling_format_status(struct rts51x_chip *chip); -void rts51x_mspro_format_sense(struct rts51x_chip *chip, unsigned int lun); - -int rts51x_reset_ms_card(struct rts51x_chip *chip); -int rts51x_ms_rw(struct scsi_cmnd *srb, struct rts51x_chip *chip, u32 start_sector, - u16 sector_cnt); -int rts51x_mspro_format(struct scsi_cmnd *srb, struct rts51x_chip *chip, - int short_data_len, int quick_format); -void rts51x_ms_free_l2p_tbl(struct rts51x_chip *chip); -void rts51x_ms_cleanup_work(struct rts51x_chip *chip); -int rts51x_release_ms_card(struct rts51x_chip *chip); -int rts51x_ms_delay_write(struct rts51x_chip *chip); - -#ifdef SUPPORT_MAGIC_GATE - -int ms_switch_clock(struct rts51x_chip *chip); -int ms_write_bytes(struct rts51x_chip *chip, u8 tpc, u8 cnt, u8 cfg, u8 *data, - int data_len); -int ms_read_bytes(struct rts51x_chip *chip, u8 tpc, u8 cnt, u8 cfg, u8 *data, - int data_len); -int ms_set_rw_reg_addr(struct rts51x_chip *chip, u8 read_start, u8 read_cnt, - u8 write_start, u8 write_cnt); -int ms_transfer_data(struct rts51x_chip *chip, u8 trans_mode, u8 tpc, - u16 sec_cnt, u8 cfg, int mode_2k, int use_sg, void *buf, - int buf_len); -#endif - -#endif /* __RTS51X_MS_H */ diff --git a/drivers/staging/rts5139/ms_mg.c b/drivers/staging/rts5139/ms_mg.c deleted file mode 100644 index c8f26062c682..000000000000 --- a/drivers/staging/rts5139/ms_mg.c +++ /dev/null @@ -1,643 +0,0 @@ -/* Driver for Realtek RTS51xx USB card reader - * - * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. - * - * 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, 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, see . - * - * Author: - * wwang (wei_wang@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - * Maintainer: - * Edwin Rong (edwin_rong@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - */ - -#include -#include -#include -#include - -#include "debug.h" -#include "trace.h" -#include "rts51x.h" -#include "rts51x_transport.h" -#include "rts51x_scsi.h" -#include "rts51x_card.h" -#include "ms.h" -#include "ms_mg.h" - -#ifdef SUPPORT_MAGIC_GATE - -static int mg_check_int_error(struct rts51x_chip *chip) -{ - u8 value; - - rts51x_read_register(chip, MS_TRANS_CFG, &value); - if (value & (INT_ERR | INT_CMDNK)) - TRACE_RET(chip, STATUS_FAIL); - - return STATUS_SUCCESS; -} - -static int mg_send_ex_cmd(struct rts51x_chip *chip, u8 cmd, u8 entry_num) -{ - int retval, i; - u8 data[8]; - - data[0] = cmd; - data[1] = 0; - data[2] = 0; - data[3] = 0; - data[4] = 0; - data[5] = 0; - data[6] = entry_num; - data[7] = 0; - - for (i = 0; i < MS_MAX_RETRY_COUNT; i++) { - retval = - ms_write_bytes(chip, PRO_EX_SET_CMD, 7, WAIT_INT, data, 8); - if (retval == STATUS_SUCCESS) - break; - } - if (i == MS_MAX_RETRY_COUNT) - TRACE_RET(chip, STATUS_FAIL); - retval = mg_check_int_error(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - - return STATUS_SUCCESS; -} - -int rts51x_mg_set_tpc_para_sub(struct rts51x_chip *chip, int type, u8 mg_entry_num) -{ - int retval; - u8 buf[6]; - - RTS51X_DEBUGP("--%s--\n", __func__); - - if (type == 0) - retval = ms_set_rw_reg_addr(chip, 0, 0, Pro_TPCParm, 1); - else - retval = ms_set_rw_reg_addr(chip, 0, 0, Pro_DataCount1, 6); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - buf[0] = 0; - buf[1] = 0; - if (type == 1) { - buf[2] = 0; - buf[3] = 0; - buf[4] = 0; - buf[5] = mg_entry_num; - } - retval = - ms_write_bytes(chip, PRO_WRITE_REG, (type == 0) ? 1 : 6, - NO_WAIT_INT, buf, 6); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - return STATUS_SUCCESS; -} - -/** - * Get MagciGate ID and set Leaf ID to medium. - - * After receiving this SCSI command, adapter shall fulfill 2 tasks - * below in order: - * 1. send GET_ID TPC command to get MagicGate ID and hold it till - * Response&challenge CMD. - * 2. send SET_ID TPC command to medium with Leaf ID released by host - * in this SCSI CMD. - */ -int rts51x_mg_set_leaf_id(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - int retval; - int i; - unsigned int lun = SCSI_LUN(srb); - u8 buf1[32], buf2[12]; - - RTS51X_DEBUGP("--%s--\n", __func__); - - if (scsi_bufflen(srb) < 12) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, STATUS_FAIL); - } - rts51x_ms_cleanup_work(chip); - - retval = ms_switch_clock(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = mg_send_ex_cmd(chip, MG_SET_LID, 0); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_ESTAB); - TRACE_RET(chip, retval); - } - - memset(buf1, 0, 32); - rts51x_get_xfer_buf(buf2, min(12, (int)scsi_bufflen(srb)), srb); - for (i = 0; i < 8; i++) - buf1[8 + i] = buf2[4 + i]; - retval = - ms_write_bytes(chip, PRO_WRITE_SHORT_DATA, 32, WAIT_INT, buf1, 32); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_ESTAB); - TRACE_RET(chip, retval); - } - retval = mg_check_int_error(chip); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_ESTAB); - TRACE_RET(chip, retval); - } - - return STATUS_SUCCESS; -} - -/** - * Send Local EKB to host. - - * After receiving this SCSI command, adapter shall read the divided - * data(1536 bytes totally) from medium by using READ_LONG_DATA TPC - * for 3 times, and report data to host with data-length is 1052 bytes. - */ -int rts51x_mg_get_local_EKB(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - int retval = STATUS_FAIL; - int bufflen; - unsigned int lun = SCSI_LUN(srb); - u8 *buf = NULL; - - RTS51X_DEBUGP("--%s--\n", __func__); - - rts51x_ms_cleanup_work(chip); - - retval = ms_switch_clock(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - buf = kmalloc(1540, GFP_KERNEL); - if (!buf) - TRACE_RET(chip, STATUS_NOMEM); - - buf[0] = 0x04; - buf[1] = 0x1A; - buf[2] = 0x00; - buf[3] = 0x00; - - retval = mg_send_ex_cmd(chip, MG_GET_LEKB, 0); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); - TRACE_GOTO(chip, GetEKBFinish); - } - - retval = ms_transfer_data(chip, MS_TM_AUTO_READ, PRO_READ_LONG_DATA, - 3, WAIT_INT, 0, 0, buf + 4, 1536); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); - rts51x_write_register(chip, CARD_STOP, MS_STOP | MS_CLR_ERR, - MS_STOP | MS_CLR_ERR); - TRACE_GOTO(chip, GetEKBFinish); - } - retval = mg_check_int_error(chip); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); - TRACE_GOTO(chip, GetEKBFinish); - } - - bufflen = min(1052, (int)scsi_bufflen(srb)); - rts51x_set_xfer_buf(buf, bufflen, srb); - -GetEKBFinish: - kfree(buf); - return retval; -} - -/** - * Send challenge(host) to medium. - - * After receiving this SCSI command, adapter shall sequentially issues - * TPC commands to the medium for writing 8-bytes data as challenge - * by host within a short data packet. - */ -int rts51x_mg_chg(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval; - int bufflen; - int i; - unsigned int lun = SCSI_LUN(srb); - u8 buf[32], tmp; - - RTS51X_DEBUGP("--%s--\n", __func__); - - rts51x_ms_cleanup_work(chip); - - retval = ms_switch_clock(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = mg_send_ex_cmd(chip, MG_GET_ID, 0); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM); - TRACE_RET(chip, retval); - } - - retval = - ms_read_bytes(chip, PRO_READ_SHORT_DATA, 32, WAIT_INT, buf, 32); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM); - TRACE_RET(chip, retval); - } - retval = mg_check_int_error(chip); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM); - TRACE_RET(chip, retval); - } - - memcpy(ms_card->magic_gate_id, buf, 16); - - for (i = 0; i < 2500; i++) { - RTS51X_READ_REG(chip, MS_TRANS_CFG, &tmp); - if (tmp & - (MS_INT_CED | MS_INT_CMDNK | MS_INT_BREQ | MS_INT_ERR)) - break; - - wait_timeout(1); - } - - if (i == 2500) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM); - TRACE_RET(chip, STATUS_FAIL); - } - - retval = mg_send_ex_cmd(chip, MG_SET_RD, 0); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM); - TRACE_RET(chip, retval); - } - - bufflen = min(12, (int)scsi_bufflen(srb)); - rts51x_get_xfer_buf(buf, bufflen, srb); - - for (i = 0; i < 8; i++) - buf[i] = buf[4 + i]; - for (i = 0; i < 24; i++) - buf[8 + i] = 0; - retval = - ms_write_bytes(chip, PRO_WRITE_SHORT_DATA, 32, WAIT_INT, buf, 32); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM); - TRACE_RET(chip, retval); - } - retval = mg_check_int_error(chip); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM); - TRACE_RET(chip, retval); - } - - ms_card->mg_auth = 0; - - return STATUS_SUCCESS; -} - -/** - * Send Response and Challenge data to host. - - * After receiving this SCSI command, adapter shall communicates with - * the medium, get parameters(HRd, Rms, MagicGateID) by using READ_SHORT_DATA - * TPC and send the data to host according to certain format required by - * MG-R specification. - * The paremeter MagicGateID is the one that adapter has obtained from - * the medium by TPC commands in Set Leaf ID command phase previously. - */ -int rts51x_mg_get_rsp_chg(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval, i; - int bufflen; - unsigned int lun = SCSI_LUN(srb); - u8 buf1[32], buf2[36], tmp; - - RTS51X_DEBUGP("--%s--\n", __func__); - - rts51x_ms_cleanup_work(chip); - - retval = ms_switch_clock(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = mg_send_ex_cmd(chip, MG_MAKE_RMS, 0); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); - TRACE_RET(chip, retval); - } - - retval = - ms_read_bytes(chip, PRO_READ_SHORT_DATA, 32, WAIT_INT, buf1, 32); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); - TRACE_RET(chip, retval); - } - retval = mg_check_int_error(chip); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); - TRACE_RET(chip, retval); - } - - buf2[0] = 0x00; - buf2[1] = 0x22; - buf2[2] = 0x00; - buf2[3] = 0x00; - - memcpy(buf2 + 4, ms_card->magic_gate_id, 16); - memcpy(buf2 + 20, buf1, 16); - - bufflen = min(36, (int)scsi_bufflen(srb)); - rts51x_set_xfer_buf(buf2, bufflen, srb); - - for (i = 0; i < 2500; i++) { - RTS51X_READ_REG(chip, MS_TRANS_CFG, &tmp); - if (tmp & (MS_INT_CED | MS_INT_CMDNK | - MS_INT_BREQ | MS_INT_ERR)) - break; - - wait_timeout(1); - } - - if (i == 2500) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); - TRACE_RET(chip, STATUS_FAIL); - } - - return STATUS_SUCCESS; -} - -/** - * Send response(host) to medium. - - * After receiving this SCSI command, adapter shall sequentially - * issues TPC commands to the medium for writing 8-bytes data as - * challenge by host within a short data packet. - */ -int rts51x_mg_rsp(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval; - int i; - int bufflen; - unsigned int lun = SCSI_LUN(srb); - u8 buf[32]; - - RTS51X_DEBUGP("--%s--\n", __func__); - - rts51x_ms_cleanup_work(chip); - - retval = ms_switch_clock(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = mg_send_ex_cmd(chip, MG_MAKE_KSE, 0); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); - TRACE_RET(chip, retval); - } - - bufflen = min(12, (int)scsi_bufflen(srb)); - rts51x_get_xfer_buf(buf, bufflen, srb); - - for (i = 0; i < 8; i++) - buf[i] = buf[4 + i]; - for (i = 0; i < 24; i++) - buf[8 + i] = 0; - retval = - ms_write_bytes(chip, PRO_WRITE_SHORT_DATA, 32, WAIT_INT, buf, 32); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); - TRACE_RET(chip, retval); - } - retval = mg_check_int_error(chip); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN); - TRACE_RET(chip, retval); - } - - ms_card->mg_auth = 1; - - return STATUS_SUCCESS; -} - -/** * Send ICV data to host. - - * After receiving this SCSI command, adapter shall read the divided - * data(1024 bytes totally) from medium by using READ_LONG_DATA TPC - * for 2 times, and report data to host with data-length is 1028 bytes. - * - * Since the extra 4 bytes data is just only a prefix to original data - * that read from medium, so that the 4-byte data pushed into Ring buffer - * precedes data transmission from medium to Ring buffer by DMA mechanism - * in order to get maximum performance and minimum code size simultaneously. - */ -int rts51x_mg_get_ICV(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval; - int bufflen; - unsigned int lun = SCSI_LUN(srb); - u8 *buf = NULL; - - RTS51X_DEBUGP("--%s--\n", __func__); - - rts51x_ms_cleanup_work(chip); - - retval = ms_switch_clock(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - buf = kmalloc(1028, GFP_KERNEL); - if (!buf) - TRACE_RET(chip, STATUS_NOMEM); - - buf[0] = 0x04; - buf[1] = 0x02; - buf[2] = 0x00; - buf[3] = 0x00; - - retval = mg_send_ex_cmd(chip, MG_GET_IBD, ms_card->mg_entry_num); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - TRACE_GOTO(chip, GetICVFinish); - } - - retval = ms_transfer_data(chip, MS_TM_AUTO_READ, PRO_READ_LONG_DATA, - 2, WAIT_INT, 0, 0, buf + 4, 1024); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - rts51x_write_register(chip, CARD_STOP, MS_STOP | MS_CLR_ERR, - MS_STOP | MS_CLR_ERR); - TRACE_GOTO(chip, GetICVFinish); - } - retval = mg_check_int_error(chip); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - TRACE_GOTO(chip, GetICVFinish); - } - - bufflen = min(1028, (int)scsi_bufflen(srb)); - rts51x_set_xfer_buf(buf, bufflen, srb); - -GetICVFinish: - kfree(buf); - return retval; -} - -/** - * Send ICV data to medium. - - * After receiving this SCSI command, adapter shall receive 1028 bytes - * and write the later 1024 bytes to medium by WRITE_LONG_DATA TPC - * consecutively. - * - * Since the first 4-bytes data is just only a prefix to original data - * that sent by host, and it should be skipped by shifting DMA pointer - * before writing 1024 bytes to medium. - */ -int rts51x_mg_set_ICV(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - struct ms_info *ms_card = &(chip->ms_card); - int retval; - int bufflen; -#ifdef MG_SET_ICV_SLOW - int i; -#endif - unsigned int lun = SCSI_LUN(srb); - u8 *buf = NULL; - - RTS51X_DEBUGP("--%s--\n", __func__); - - rts51x_ms_cleanup_work(chip); - - retval = ms_switch_clock(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - buf = kmalloc(1028, GFP_KERNEL); - if (!buf) - TRACE_RET(chip, STATUS_NOMEM); - - bufflen = min(1028, (int)scsi_bufflen(srb)); - rts51x_get_xfer_buf(buf, bufflen, srb); - - retval = mg_send_ex_cmd(chip, MG_SET_IBD, ms_card->mg_entry_num); - if (retval != STATUS_SUCCESS) { - if (ms_card->mg_auth == 0) { - if ((buf[5] & 0xC0) != 0) - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MG_KEY_FAIL_NOT_ESTAB); - else - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MG_WRITE_ERR); - } else { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MG_WRITE_ERR); - } - TRACE_GOTO(chip, SetICVFinish); - } - -#ifdef MG_SET_ICV_SLOW - for (i = 0; i < 2; i++) { - udelay(50); - - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TPC, 0xFF, - PRO_WRITE_LONG_DATA); - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANS_CFG, 0xFF, - WAIT_INT); - - rts51x_trans_dma_enable(DMA_TO_DEVICE, chip, 512, DMA_512); - - rts51x_add_cmd(chip, WRITE_REG_CMD, MS_TRANSFER, 0xFF, - MS_TRANSFER_START | MS_TM_NORMAL_WRITE); - rts51x_add_cmd(chip, CHECK_REG_CMD, MS_TRANSFER, - MS_TRANSFER_END, MS_TRANSFER_END); - - retval = rts51x_send_cmd(chip, MODE_CDOR, 100); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MG_WRITE_ERR); - TRACE_GOTO(chip, SetICVFinish); - } - - retval = rts51x_transfer_data_rcc(chip, SND_BULK_PIPE(chip), - buf + 4 + i * 512, 512, 0, - NULL, 3000, STAGE_DO); - if (retval != STATUS_SUCCESS) { - rts51x_clear_ms_error(chip); - if (ms_card->mg_auth == 0) { - if ((buf[5] & 0xC0) != 0) - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MG_KEY_FAIL_NOT_ESTAB); - else - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MG_WRITE_ERR); - } else { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MG_WRITE_ERR); - } - retval = STATUS_FAIL; - TRACE_GOTO(chip, SetICVFinish); - } - - retval = rts51x_get_rsp(chip, 1, 3000); - if (CHECK_MS_TRANS_FAIL(chip, retval) - || mg_check_int_error(chip)) { - rts51x_clear_ms_error(chip); - if (ms_card->mg_auth == 0) { - if ((buf[5] & 0xC0) != 0) - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MG_KEY_FAIL_NOT_ESTAB); - else - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MG_WRITE_ERR); - } else { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MG_WRITE_ERR); - } - retval = STATUS_FAIL; - TRACE_GOTO(chip, SetICVFinish); - } - } -#else - retval = ms_transfer_data(chip, MS_TM_AUTO_WRITE, PRO_WRITE_LONG_DATA, - 2, WAIT_INT, 0, 0, buf + 4, 1024); - if (retval != STATUS_SUCCESS) { - rts51x_clear_ms_error(chip); - if (ms_card->mg_auth == 0) { - if ((buf[5] & 0xC0) != 0) - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MG_KEY_FAIL_NOT_ESTAB); - else - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MG_WRITE_ERR); - } else { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MG_WRITE_ERR); - } - TRACE_GOTO(chip, SetICVFinish); - } -#endif - -SetICVFinish: - kfree(buf); - return retval; -} - -#endif /* SUPPORT_MAGIC_GATE */ diff --git a/drivers/staging/rts5139/ms_mg.h b/drivers/staging/rts5139/ms_mg.h deleted file mode 100644 index 109c71290953..000000000000 --- a/drivers/staging/rts5139/ms_mg.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Driver for Realtek RTS51xx USB card reader - * Header file - * - * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. - * - * 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, 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, see . - * - * Author: - * wwang (wei_wang@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - * Maintainer: - * Edwin Rong (edwin_rong@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - */ - -#ifndef __RTS51X_MS_MG_H -#define __RTS51X_MS_MG_H - -#include "rts51x_chip.h" -#include "ms.h" - -int rts51x_mg_set_tpc_para_sub(struct rts51x_chip *chip, int type, u8 mg_entry_num); -int rts51x_mg_set_leaf_id(struct scsi_cmnd *srb, struct rts51x_chip *chip); -int rts51x_mg_get_local_EKB(struct scsi_cmnd *srb, struct rts51x_chip *chip); -int rts51x_mg_chg(struct scsi_cmnd *srb, struct rts51x_chip *chip); -int rts51x_mg_get_rsp_chg(struct scsi_cmnd *srb, struct rts51x_chip *chip); -int rts51x_mg_rsp(struct scsi_cmnd *srb, struct rts51x_chip *chip); -int rts51x_mg_get_ICV(struct scsi_cmnd *srb, struct rts51x_chip *chip); -int rts51x_mg_set_ICV(struct scsi_cmnd *srb, struct rts51x_chip *chip); - -#endif /* __RTS51X_MS_MG_H */ diff --git a/drivers/staging/rts5139/rts51x.c b/drivers/staging/rts5139/rts51x.c deleted file mode 100644 index 8529cbabc554..000000000000 --- a/drivers/staging/rts5139/rts51x.c +++ /dev/null @@ -1,846 +0,0 @@ -/* Driver for Realtek RTS51xx USB card reader - * - * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. - * - * 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, 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, see . - * - * Author: - * wwang (wei_wang@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - * Maintainer: - * Edwin Rong (edwin_rong@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - */ - -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "debug.h" -#include "ms.h" -#include "rts51x.h" -#include "rts51x_chip.h" -#include "rts51x_card.h" -#include "rts51x_scsi.h" -#include "rts51x_transport.h" -#include "rts51x_fop.h" - -MODULE_DESCRIPTION(RTS51X_DESC); -MODULE_LICENSE("GPL"); -MODULE_VERSION(DRIVER_VERSION); - -static int auto_delink_en; -module_param(auto_delink_en, int, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(auto_delink_en, "enable auto delink"); - -static int ss_en; -module_param(ss_en, int, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(ss_en, "enable selective suspend"); - -static int ss_delay = 50; -module_param(ss_delay, int, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(ss_delay, - "seconds to delay before entering selective suspend"); - -static int needs_remote_wakeup; -module_param(needs_remote_wakeup, int, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(needs_remote_wakeup, "ss state needs remote wakeup supported"); - -#ifdef SUPPORT_FILE_OP -static const struct file_operations rts51x_fops = { - .owner = THIS_MODULE, - .read = rts51x_read, - .write = rts51x_write, - .unlocked_ioctl = rts51x_ioctl, - .open = rts51x_open, - .release = rts51x_release, -}; - -/* - * usb class driver info in order to get a minor number from the usb core, - * and to have the device registered with the driver core - */ -static struct usb_class_driver rts51x_class = { - .name = "rts51x%d", - .fops = &rts51x_fops, - .minor_base = 192, -}; -#endif - -#ifdef CONFIG_PM /* Minimal support for suspend and resume */ - -static inline void usb_autopm_enable(struct usb_interface *intf) -{ - atomic_set(&intf->pm_usage_cnt, 1); - usb_autopm_put_interface(intf); -} - -static inline void usb_autopm_disable(struct usb_interface *intf) -{ - atomic_set(&intf->pm_usage_cnt, 0); - usb_autopm_get_interface(intf); -} - -static void rts51x_try_to_enter_ss(struct rts51x_chip *chip) -{ - pr_debug("Ready to enter SS state\n"); - usb_autopm_enable(chip->usb->pusb_intf); -} - -void rts51x_try_to_exit_ss(struct rts51x_chip *chip) -{ - pr_debug("Exit from SS state\n"); - usb_autopm_disable(chip->usb->pusb_intf); -} - -int rts51x_suspend(struct usb_interface *iface, pm_message_t message) -{ - struct rts51x_chip *chip = usb_get_intfdata(iface); - - pr_debug("%s, message.event = 0x%x\n", __func__, message.event); - - /* Wait until no command is running */ - mutex_lock(&chip->usb->dev_mutex); - - chip->fake_card_ready = chip->card_ready; - rts51x_do_before_power_down(chip); - - if (message.event == PM_EVENT_AUTO_SUSPEND) { - pr_debug("Enter SS state"); - chip->resume_from_scsi = 0; - RTS51X_SET_STAT(chip, STAT_SS); - } else { - pr_debug("Enter SUSPEND state"); - RTS51X_SET_STAT(chip, STAT_SUSPEND); - } - - /* When runtime PM is working, we'll set a flag to indicate - * whether we should autoresume when a SCSI request arrives. */ - - mutex_unlock(&chip->usb->dev_mutex); - return 0; -} - -int rts51x_resume(struct usb_interface *iface) -{ - struct rts51x_chip *chip = usb_get_intfdata(iface); - - pr_debug("%s\n", __func__); - - if (!RTS51X_CHK_STAT(chip, STAT_SS) || !chip->resume_from_scsi) { - mutex_lock(&chip->usb->dev_mutex); - - if (chip->option.ss_en) { - if (GET_PM_USAGE_CNT(chip) <= 0) { - /* Remote wake up, increase pm_usage_cnt */ - pr_debug("Incr pm_usage_cnt\n"); - SET_PM_USAGE_CNT(chip, 1); - } - } - - RTS51X_SET_STAT(chip, STAT_RUN); - - rts51x_init_chip(chip); - rts51x_init_cards(chip); - - mutex_unlock(&chip->usb->dev_mutex); - } - - return 0; -} - -int rts51x_reset_resume(struct usb_interface *iface) -{ - struct rts51x_chip *chip = usb_get_intfdata(iface); - - pr_debug("%s\n", __func__); - - mutex_lock(&chip->usb->dev_mutex); - - RTS51X_SET_STAT(chip, STAT_RUN); - - if (chip->option.ss_en) - SET_PM_USAGE_CNT(chip, 1); - - rts51x_init_chip(chip); - rts51x_init_cards(chip); - - mutex_unlock(&chip->usb->dev_mutex); - - /* FIXME: Notify the subdrivers that they need to reinitialize - * the device */ - return 0; -} - -#else /* CONFIG_PM */ - -static void rts51x_try_to_enter_ss(struct rts51x_chip *chip) -{ -} - -void rts51x_try_to_exit_ss(struct rts51x_chip *chip) -{ -} - -#endif /* CONFIG_PM */ - -/* - * The next two routines get called just before and just after - * a USB port reset, whether from this driver or a different one. - */ - -static int rts51x_pre_reset(struct usb_interface *iface) -{ - struct rts51x_chip *chip = usb_get_intfdata(iface); - - pr_debug("%s\n", __func__); - - /* Make sure no command runs during the reset */ - mutex_lock(&chip->usb->dev_mutex); - return 0; -} - -static int rts51x_post_reset(struct usb_interface *iface) -{ - struct rts51x_chip *chip = usb_get_intfdata(iface); - - pr_debug("%s\n", __func__); - - /* Report the reset to the SCSI core */ - /* usb_stor_report_bus_reset(us); */ - - /* FIXME: Notify the subdrivers that they need to reinitialize - * the device */ - - mutex_unlock(&chip->usb->dev_mutex); - return 0; -} - -static int rts51x_control_thread(void *__chip) -{ - struct rts51x_chip *chip = (struct rts51x_chip *)__chip; - struct Scsi_Host *host = rts51x_to_host(chip); - - for (;;) { - if (wait_for_completion_interruptible(&chip->usb->cmnd_ready)) - break; - - if (test_bit(FLIDX_DISCONNECTING, &chip->usb->dflags)) { - pr_debug("-- exiting from rts51x-control\n"); - break; - } - - /* lock the device pointers */ - mutex_lock(&(chip->usb->dev_mutex)); - - /* lock access to the state */ - scsi_lock(host); - - /* When we are called with no command pending, we're done */ - if (chip->srb == NULL) { - scsi_unlock(host); - mutex_unlock(&chip->usb->dev_mutex); - pr_debug("-- exiting from control thread\n"); - break; - } - - /* has the command timed out *already* ? */ - if (test_bit(FLIDX_TIMED_OUT, &chip->usb->dflags)) { - chip->srb->result = DID_ABORT << 16; - goto abort; - } - - scsi_unlock(host); - - /* reject the command if the direction indicator - * is UNKNOWN - */ - if (chip->srb->sc_data_direction == DMA_BIDIRECTIONAL) { - pr_debug("UNKNOWN data direction\n"); - chip->srb->result = DID_ERROR << 16; - } - - /* reject if target != 0 or if LUN is higher than - * the maximum known LUN - */ - else if (chip->srb->device->id) { - pr_debug("Bad target number (%d:%d)\n", - chip->srb->device->id, - chip->srb->device->lun); - chip->srb->result = DID_BAD_TARGET << 16; - } - - else if (chip->srb->device->lun > chip->max_lun) { - pr_debug("Bad LUN (%d:%d)\n", - chip->srb->device->id, - chip->srb->device->lun); - chip->srb->result = DID_BAD_TARGET << 16; - } - - /* we've got a command, let's do it! */ - else { - RTS51X_DEBUG(rts51x_scsi_show_command(chip->srb)); - rts51x_invoke_transport(chip->srb, chip); - } - - /* lock access to the state */ - scsi_lock(host); - - /* indicate that the command is done */ - if (chip->srb->result != DID_ABORT << 16) - chip->srb->scsi_done(chip->srb); - else -abort : - pr_debug("scsi command aborted\n"); - - /* If an abort request was received we need to signal that - * the abort has finished. The proper test for this is - * the TIMED_OUT flag, not srb->result == DID_ABORT, because - * the timeout might have occurred after the command had - * already completed with a different result code. */ - if (test_bit(FLIDX_TIMED_OUT, &chip->usb->dflags)) { - complete(&(chip->usb->notify)); - - /* Allow USB transfers to resume */ - clear_bit(FLIDX_ABORTING, &chip->usb->dflags); - clear_bit(FLIDX_TIMED_OUT, &chip->usb->dflags); - } - - /* finished working on this command */ - chip->srb = NULL; - scsi_unlock(host); - - /* unlock the device pointers */ - mutex_unlock(&chip->usb->dev_mutex); - } /* for (;;) */ - - complete(&chip->usb->control_exit); - - /* Wait until we are told to stop */ -/* for (;;) { - set_current_state(TASK_INTERRUPTIBLE); - if (kthread_should_stop()) - break; - schedule(); - } - __set_current_state(TASK_RUNNING);*/ - return 0; -} - -static int rts51x_polling_thread(void *__chip) -{ - struct rts51x_chip *chip = (struct rts51x_chip *)__chip; - - for (;;) { - wait_timeout(POLLING_INTERVAL); - - /* if the device has disconnected, we are free to exit */ - if (test_bit(FLIDX_DISCONNECTING, &chip->usb->dflags)) { - pr_debug("-- exiting from rts51x-polling\n"); - break; - } - - /* if the device has disconnected, we are free to exit */ - /* if (kthread_should_stop()) { - printk(KERN_INFO "Stop polling thread!\n"); - break; - } */ - -#ifdef CONFIG_PM - if (RTS51X_CHK_STAT(chip, STAT_SS) || - RTS51X_CHK_STAT(chip, STAT_SS_PRE) || - RTS51X_CHK_STAT(chip, STAT_SUSPEND)) { - continue; - } - - if (ss_en) { - if (RTS51X_CHK_STAT(chip, STAT_IDLE)) { - if (chip->ss_counter < - (ss_delay * 1000 / POLLING_INTERVAL)) { - chip->ss_counter++; - } else { - /* Prepare SS state */ - RTS51X_SET_STAT(chip, STAT_SS_PRE); - rts51x_try_to_enter_ss(chip); - continue; - } - } else { - chip->ss_counter = 0; - } - } -#endif - - rts51x_mspro_polling_format_status(chip); - - /* lock the device pointers */ - mutex_lock(&(chip->usb->dev_mutex)); - - rts51x_polling_func(chip); - - /* unlock the device pointers */ - mutex_unlock(&chip->usb->dev_mutex); - } /* for (;;) */ - - complete(&chip->usb->polling_exit); - - /* Wait until we are told to stop */ - /* for (;;) { - set_current_state(TASK_INTERRUPTIBLE); - if (kthread_should_stop()) - break; - schedule(); - } - __set_current_state(TASK_RUNNING); */ - return 0; -} - -/* Associate our private data with the USB device */ -static int associate_dev(struct rts51x_chip *chip, struct usb_interface *intf) -{ - struct rts51x_usb *rts51x = chip->usb; -#ifdef SUPPORT_FILE_OP - int retval; -#endif - - /* Fill in the device-related fields */ - rts51x->pusb_dev = interface_to_usbdev(intf); - rts51x->pusb_intf = intf; - rts51x->ifnum = intf->cur_altsetting->desc.bInterfaceNumber; - pr_debug("Vendor: 0x%04x, Product: 0x%04x, Revision: 0x%04x\n", - le16_to_cpu(rts51x->pusb_dev->descriptor.idVendor), - le16_to_cpu(rts51x->pusb_dev->descriptor.idProduct), - le16_to_cpu(rts51x->pusb_dev->descriptor.bcdDevice)); - pr_debug("Interface Subclass: 0x%02x, Protocol: 0x%02x\n", - intf->cur_altsetting->desc.bInterfaceSubClass, - intf->cur_altsetting->desc.bInterfaceProtocol); - - /* Store our private data in the interface */ - usb_set_intfdata(intf, chip); - -#ifdef SUPPORT_FILE_OP - /* we can register the device now, as it is ready */ - retval = usb_register_dev(intf, &rts51x_class); - if (retval) { - /* something prevented us from registering this driver */ - pr_debug("Not able to get a minor for this device."); - usb_set_intfdata(intf, NULL); - return -ENOMEM; - } -#endif - - /* Allocate the device-related DMA-mapped buffers */ - rts51x->cr = usb_buffer_alloc(rts51x->pusb_dev, sizeof(*rts51x->cr), - GFP_KERNEL, &rts51x->cr_dma); - if (!rts51x->cr) { - usb_set_intfdata(intf, NULL); - return -ENOMEM; - } - - rts51x->iobuf = usb_buffer_alloc(rts51x->pusb_dev, RTS51X_IOBUF_SIZE, - GFP_KERNEL, &rts51x->iobuf_dma); - if (!rts51x->iobuf) { - usb_set_intfdata(intf, NULL); - return -ENOMEM; - } - return 0; -} - -static void rts51x_init_options(struct rts51x_chip *chip) -{ - struct rts51x_option *option = &(chip->option); - - option->rts51x_mspro_formatter_enable = 1; - - option->fpga_sd_sdr104_clk = CLK_100; - option->fpga_sd_sdr50_clk = CLK_100; - option->fpga_sd_ddr50_clk = CLK_100; - option->fpga_sd_hs_clk = CLK_100; - option->fpga_mmc_52m_clk = CLK_80; - option->fpga_ms_hg_clk = CLK_80; - option->fpga_ms_4bit_clk = CLK_80; - - option->asic_sd_sdr104_clk = 98; - option->asic_sd_sdr50_clk = 98; - option->asic_sd_ddr50_clk = 98; - option->asic_sd_hs_clk = 97; - option->asic_mmc_52m_clk = 95; - option->asic_ms_hg_clk = 116; - option->asic_ms_4bit_clk = 77; - - option->sd_ddr_tx_phase = 0; - option->mmc_ddr_tx_phase = 1; - - option->sd_speed_prior = 0; - option->sd_ctl = - SD_PUSH_POINT_AUTO | SD_SAMPLE_POINT_AUTO | SUPPORT_UHS50_MMC44; - - option->ss_en = ss_en; - option->ss_delay = ss_delay; - - option->auto_delink_en = auto_delink_en; - - option->FT2_fast_mode = 0; - option->pwr_delay = 800; - option->rts51x_xd_rw_step = 0; - option->D3318_off_delay = 50; - option->delink_delay = 100; - option->rts5129_D3318_off_enable = 0; - option->sd20_pad_drive = 0; - option->reset_or_rw_fail_set_pad_drive = 1; - option->debounce_num = 2; - option->led_toggle_interval = 6; - option->rts51x_xd_rwn_step = 0; - option->sd_send_status_en = 0; - option->sdr50_tx_phase = 0x01; - option->sdr50_rx_phase = 0x05; - option->ddr50_tx_phase = 0x09; - option->ddr50_rx_phase = 0x06; - option->sdr50_phase_sel = 0; - option->sd30_pad_drive = 1; - option->ms_errreg_fix = 0; - option->reset_mmc_first = 0; - option->speed_mmc = 1; - option->led_always_on = 0; -} - -/* Get the pipe settings */ -static int get_pipes(struct rts51x_chip *chip) -{ - struct rts51x_usb *rts51x = chip->usb; - struct usb_host_interface *altsetting = - rts51x->pusb_intf->cur_altsetting; - int i; - struct usb_endpoint_descriptor *ep; - struct usb_endpoint_descriptor *ep_in = NULL; - struct usb_endpoint_descriptor *ep_out = NULL; - struct usb_endpoint_descriptor *ep_int = NULL; - - /* - * Find the first endpoint of each type we need. - * We are expecting a minimum of 2 endpoints - in and out (bulk). - * An optional interrupt-in is OK (necessary for CBI protocol). - * We will ignore any others. - */ - for (i = 0; i < altsetting->desc.bNumEndpoints; i++) { - ep = &altsetting->endpoint[i].desc; - - if (usb_endpoint_xfer_bulk(ep)) { - if (usb_endpoint_dir_in(ep)) { - if (!ep_in) - ep_in = ep; - } else { - if (!ep_out) - ep_out = ep; - } - } - - else if (usb_endpoint_is_int_in(ep)) { - if (!ep_int) - ep_int = ep; - } - } - - if (!ep_in || !ep_out) { - pr_debug("Endpoint sanity check failed! Rejecting dev.\n"); - return -EIO; - } - - /* Calculate and store the pipe values */ - rts51x->send_ctrl_pipe = usb_sndctrlpipe(rts51x->pusb_dev, 0); - rts51x->recv_ctrl_pipe = usb_rcvctrlpipe(rts51x->pusb_dev, 0); - rts51x->send_bulk_pipe = usb_sndbulkpipe(rts51x->pusb_dev, - usb_endpoint_num(ep_out)); - rts51x->recv_bulk_pipe = usb_rcvbulkpipe(rts51x->pusb_dev, - usb_endpoint_num(ep_in)); - if (ep_int) { - rts51x->recv_intr_pipe = usb_rcvintpipe(rts51x->pusb_dev, - usb_endpoint_num - (ep_int)); - rts51x->ep_bInterval = ep_int->bInterval; - } - return 0; -} - -/* Initialize all the dynamic resources we need */ -static int rts51x_acquire_resources(struct rts51x_chip *chip) -{ - struct rts51x_usb *rts51x = chip->usb; - int retval; - - rts51x->current_urb = usb_alloc_urb(0, GFP_KERNEL); - if (!rts51x->current_urb) - return -ENOMEM; - - rts51x->intr_urb = usb_alloc_urb(0, GFP_KERNEL); - if (!rts51x->intr_urb) - return -ENOMEM; - - chip->cmd_buf = rts51x->iobuf; - chip->rsp_buf = rts51x->iobuf; - - rts51x_init_options(chip); - - /* Init rts51xx device */ - retval = rts51x_init_chip(chip); - if (retval != STATUS_SUCCESS) - return -EIO; - - return 0; -} - -/* Release all our dynamic resources */ -static void rts51x_release_resources(struct rts51x_chip *chip) -{ - pr_debug("-- %s\n", __func__); - - /* Tell the control thread to exit. The SCSI host must - * already have been removed and the DISCONNECTING flag set - * so that we won't accept any more commands. - */ - pr_debug("-- sending exit command to thread\n"); - complete(&chip->usb->cmnd_ready); - if (chip->usb->ctl_thread) - wait_for_completion(&chip->usb->control_exit); - /* kthread_stop(chip->usb->ctl_thread); */ - if (chip->usb->polling_thread) - wait_for_completion(&chip->usb->polling_exit); - - /* if (chip->usb->polling_thread) - kthread_stop(chip->usb->polling_thread); */ - - wait_timeout(200); - - /* Release rts51xx device here */ - rts51x_release_chip(chip); - - usb_free_urb(chip->usb->current_urb); - usb_free_urb(chip->usb->intr_urb); -} - -/* Dissociate from the USB device */ -static void dissociate_dev(struct rts51x_chip *chip) -{ - struct rts51x_usb *rts51x = chip->usb; - - pr_debug("-- %s\n", __func__); - - /* Free the device-related DMA-mapped buffers */ - if (rts51x->cr) - usb_buffer_free(rts51x->pusb_dev, sizeof(*rts51x->cr), - rts51x->cr, rts51x->cr_dma); - if (rts51x->iobuf) - usb_buffer_free(rts51x->pusb_dev, RTS51X_IOBUF_SIZE, - rts51x->iobuf, rts51x->iobuf_dma); - - /* Remove our private data from the interface */ - usb_set_intfdata(rts51x->pusb_intf, NULL); - -#ifdef SUPPORT_FILE_OP - /* give back our minor */ - usb_deregister_dev(rts51x->pusb_intf, &rts51x_class); -#endif - - kfree(rts51x); - chip->usb = NULL; -} - -/* First stage of disconnect processing: stop SCSI scanning, - * remove the host, and stop accepting new commands - */ -static void quiesce_and_remove_host(struct rts51x_chip *chip) -{ - struct rts51x_usb *rts51x = chip->usb; - struct Scsi_Host *host = rts51x_to_host(chip); - - /* If the device is really gone, cut short reset delays */ - if (rts51x->pusb_dev->state == USB_STATE_NOTATTACHED) - set_bit(FLIDX_DISCONNECTING, &rts51x->dflags); - - /* Removing the host will perform an orderly shutdown: caches - * synchronized, disks spun down, etc. - */ - scsi_remove_host(host); - - /* Prevent any new commands from being accepted and cut short - * reset delays. - */ - scsi_lock(host); - set_bit(FLIDX_DISCONNECTING, &rts51x->dflags); - scsi_unlock(host); -} - -/* Second stage of disconnect processing: deallocate all resources */ -static void release_everything(struct rts51x_chip *chip) -{ - rts51x_release_resources(chip); - dissociate_dev(chip); - - /* Drop our reference to the host; the SCSI core will free it - * (and "chip" along with it) when the refcount becomes 0. */ - scsi_host_put(rts51x_to_host(chip)); -} - -static int rts51x_probe(struct usb_interface *intf, - const struct usb_device_id *id) -{ - struct Scsi_Host *host; - struct rts51x_chip *chip; - struct rts51x_usb *rts51x; - int result; - struct task_struct *th; - - pr_debug("%s detected\n", RTS51X_NAME); - - rts51x = kzalloc(sizeof(*rts51x), GFP_KERNEL); - if (!rts51x) - return -ENOMEM; - - /* - * Ask the SCSI layer to allocate a host structure, with extra - * space at the end for our private us_data structure. - */ - host = scsi_host_alloc(&rts51x_host_template, sizeof(*chip)); - if (!host) { - kfree(rts51x); - return -ENOMEM; - } - - /* - * Allow 16-byte CDBs and thus > 2TB - */ - host->max_cmd_len = 16; - chip = host_to_rts51x(host); - memset(chip, 0, sizeof(struct rts51x_chip)); - - chip->vendor_id = id->idVendor; - chip->product_id = id->idProduct; - - mutex_init(&(rts51x->dev_mutex)); - init_completion(&rts51x->cmnd_ready); - init_completion(&rts51x->control_exit); - init_completion(&rts51x->polling_exit); - init_completion(&(rts51x->notify)); - - chip->usb = rts51x; - - /* Associate the us_data structure with the USB device */ - result = associate_dev(chip, intf); - if (result) - goto bad_device; - - /* Find the endpoints and calculate pipe values */ - result = get_pipes(chip); - if (result) - goto bad_device; - - /* Acquire all the other resources and add the host */ - result = rts51x_acquire_resources(chip); - if (result) - goto bad_device; - - /* Start up our control thread */ - th = kthread_run(rts51x_control_thread, chip, RTS51X_CTL_THREAD); - if (IS_ERR(th)) { - pr_warn("Unable to start control thread\n"); - result = PTR_ERR(th); - goto bad_device; - } - rts51x->ctl_thread = th; - - result = scsi_add_host(rts51x_to_host(chip), &rts51x->pusb_intf->dev); - if (result) { - pr_warn("Unable to add the scsi host\n"); - goto bad_device; - } - scsi_scan_host(rts51x_to_host(chip)); - - /* Start up our polling thread */ - th = kthread_run(rts51x_polling_thread, chip, RTS51X_POLLING_THREAD); - if (IS_ERR(th)) { - pr_warn("Unable to start polling thread\n"); - result = PTR_ERR(th); - goto bad_device; - } - rts51x->polling_thread = th; - -#ifdef CONFIG_PM - if (ss_en) { - rts51x->pusb_intf->needs_remote_wakeup = needs_remote_wakeup; - SET_PM_USAGE_CNT(chip, 1); - pr_debug("pm_usage_cnt = %d\n", GET_PM_USAGE_CNT(chip)); - } -#endif - - return 0; - - /* We come here if there are any problems */ -bad_device: - pr_debug("rts51x_probe() failed\n"); - release_everything(chip); - return result; -} - -static void rts51x_disconnect(struct usb_interface *intf) -{ - struct rts51x_chip *chip = (struct rts51x_chip *)usb_get_intfdata(intf); - - pr_debug("rts51x_disconnect() called\n"); - quiesce_and_remove_host(chip); - release_everything(chip); -} - -/*********************************************************************** - * Initialization and registration - ***********************************************************************/ - -static struct usb_device_id rts5139_usb_ids[] = { - {USB_DEVICE(0x0BDA, 0x0139)}, - {USB_DEVICE(0x0BDA, 0x0129)}, - {} /* Terminating entry */ -}; -EXPORT_SYMBOL_GPL(rts5139_usb_ids); - -MODULE_DEVICE_TABLE(usb, rts5139_usb_ids); - -struct usb_driver rts51x_driver = { - .name = RTS51X_NAME, - .probe = rts51x_probe, - .disconnect = rts51x_disconnect, - .suspend = rts51x_suspend, - .resume = rts51x_resume, - .reset_resume = rts51x_reset_resume, - .pre_reset = rts51x_pre_reset, - .post_reset = rts51x_post_reset, - .id_table = rts5139_usb_ids, - .soft_unbind = 1, -}; - -module_usb_driver(rts51x_driver); diff --git a/drivers/staging/rts5139/rts51x.h b/drivers/staging/rts5139/rts51x.h deleted file mode 100644 index ecc0109a5b1a..000000000000 --- a/drivers/staging/rts5139/rts51x.h +++ /dev/null @@ -1,194 +0,0 @@ -/* Driver for Realtek RTS51xx USB card reader - * Header file - * - * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. - * - * 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, 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, see . - * - * Author: - * wwang (wei_wang@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - * Maintainer: - * Edwin Rong (edwin_rong@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - */ - -#ifndef __RTS51X_H -#define __RTS51X_H - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#define DRIVER_VERSION "v1.04" - -#define RTS51X_DESC "Realtek RTS5139/29 USB card reader driver" -#define RTS51X_NAME "rts5139" -#define RTS51X_CTL_THREAD "rts5139-control" -#define RTS51X_POLLING_THREAD "rts5139-polling" - -#define POLLING_IN_THREAD -#define SUPPORT_FILE_OP - -#define wait_timeout_x(task_state, msecs) \ -do { \ - set_current_state((task_state)); \ - schedule_timeout((msecs) * HZ / 1000); \ -} while (0) - -#define wait_timeout(msecs) wait_timeout_x(TASK_INTERRUPTIBLE, (msecs)) - -#define SCSI_LUN(srb) ((srb)->device->lun) - -/* Size of the DMA-mapped I/O buffer */ -#define RTS51X_IOBUF_SIZE 1024 - -/* Dynamic bitflag definitions (dflags): used in set_bit() etc. */ -#define FLIDX_URB_ACTIVE 0 /* current_urb is in use */ -#define FLIDX_SG_ACTIVE 1 /* current_sg is in use */ -#define FLIDX_ABORTING 2 /* abort is in progress */ -#define FLIDX_DISCONNECTING 3 /* disconnect in progress */ -#define FLIDX_RESETTING 4 /* device reset in progress */ -#define FLIDX_TIMED_OUT 5 /* SCSI midlayer timed out */ - -struct rts51x_chip; - -struct rts51x_usb { - /* The device we're working with - * It's important to note: - * (o) you must hold dev_mutex to change pusb_dev - */ - struct mutex dev_mutex; /* protect pusb_dev */ - struct usb_device *pusb_dev; /* this usb_device */ - struct usb_interface *pusb_intf; /* this interface */ - - unsigned long dflags; /* dynamic atomic bitflags */ - - unsigned int send_bulk_pipe; /* cached pipe values */ - unsigned int recv_bulk_pipe; - unsigned int send_ctrl_pipe; - unsigned int recv_ctrl_pipe; - unsigned int recv_intr_pipe; - - u8 ifnum; /* interface number */ - u8 ep_bInterval; /* interrupt interval */ - - /* control and bulk communications data */ - struct urb *current_urb; /* USB requests */ - struct urb *intr_urb; /* Interrupt USB request */ - struct usb_ctrlrequest *cr; /* control requests */ - struct usb_sg_request current_sg; /* scatter-gather req. */ - unsigned char *iobuf; /* I/O buffer */ - dma_addr_t cr_dma; /* buffer DMA addresses */ - dma_addr_t iobuf_dma; - struct task_struct *ctl_thread; /* the control thread */ - struct task_struct *polling_thread; /* the polling thread */ - - /* mutual exclusion and synchronization structures */ - struct completion cmnd_ready; /* to sleep thread on */ - struct completion control_exit; /* control thread exit */ - struct completion polling_exit; /* polling thread exit */ - struct completion notify; /* thread begin/end */ -}; - -extern struct usb_driver rts51x_driver; - -static inline void get_current_time(u8 *timeval_buf, int buf_len) -{ - struct timeval tv; - - if (!timeval_buf || (buf_len < 8)) - return; - - do_gettimeofday(&tv); - - timeval_buf[0] = (u8) (tv.tv_sec >> 24); - timeval_buf[1] = (u8) (tv.tv_sec >> 16); - timeval_buf[2] = (u8) (tv.tv_sec >> 8); - timeval_buf[3] = (u8) (tv.tv_sec); - timeval_buf[4] = (u8) (tv.tv_usec >> 24); - timeval_buf[5] = (u8) (tv.tv_usec >> 16); - timeval_buf[6] = (u8) (tv.tv_usec >> 8); - timeval_buf[7] = (u8) (tv.tv_usec); -} - -#define SND_CTRL_PIPE(chip) ((chip)->usb->send_ctrl_pipe) -#define RCV_CTRL_PIPE(chip) ((chip)->usb->recv_ctrl_pipe) -#define SND_BULK_PIPE(chip) ((chip)->usb->send_bulk_pipe) -#define RCV_BULK_PIPE(chip) ((chip)->usb->recv_bulk_pipe) -#define RCV_INTR_PIPE(chip) ((chip)->usb->recv_intr_pipe) - -/* The scsi_lock() and scsi_unlock() macros protect the sm_state and the - * single queue element srb for write access */ -#define scsi_unlock(host) spin_unlock_irq(host->host_lock) -#define scsi_lock(host) spin_lock_irq(host->host_lock) - -#define GET_PM_USAGE_CNT(chip) \ - atomic_read(&((chip)->usb->pusb_intf->pm_usage_cnt)) -#define SET_PM_USAGE_CNT(chip, cnt) \ - atomic_set(&((chip)->usb->pusb_intf->pm_usage_cnt), (cnt)) - -/* Compatible macros while we switch over */ -static inline void *usb_buffer_alloc(struct usb_device *dev, size_t size, - gfp_t mem_flags, dma_addr_t *dma) -{ - return usb_alloc_coherent(dev, size, mem_flags, dma); -} - -static inline void usb_buffer_free(struct usb_device *dev, size_t size, - void *addr, dma_addr_t dma) -{ - return usb_free_coherent(dev, size, addr, dma); -} - -/* Convert between us_data and the corresponding Scsi_Host */ -static inline struct Scsi_Host *rts51x_to_host(struct rts51x_chip *chip) -{ - return container_of((void *)chip, struct Scsi_Host, hostdata); -} - -static inline struct rts51x_chip *host_to_rts51x(struct Scsi_Host *host) -{ - return (struct rts51x_chip *)(host->hostdata); -} - -/* struct scsi_cmnd transfer buffer access utilities */ -enum xfer_buf_dir { TO_XFER_BUF, FROM_XFER_BUF }; - -/* General routines provided by the usb-storage standard core */ -#ifdef CONFIG_PM -void rts51x_try_to_exit_ss(struct rts51x_chip *chip); -int rts51x_suspend(struct usb_interface *iface, pm_message_t message); -int rts51x_resume(struct usb_interface *iface); -int rts51x_reset_resume(struct usb_interface *iface); -#else -#define rts51x_suspend NULL -#define rts51x_resume NULL -#define rts51x_reset_resume NULL -#endif - -extern struct scsi_host_template rts51x_host_template; - -#endif /* __RTS51X_H */ diff --git a/drivers/staging/rts5139/rts51x_card.c b/drivers/staging/rts5139/rts51x_card.c deleted file mode 100644 index 03456d9873e5..000000000000 --- a/drivers/staging/rts5139/rts51x_card.c +++ /dev/null @@ -1,940 +0,0 @@ -/* Driver for Realtek RTS51xx USB card reader - * - * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. - * - * 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, 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, see . - * - * Author: - * wwang (wei_wang@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - * Maintainer: - * Edwin Rong (edwin_rong@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - */ - -#include -#include -#include -#include - -#include -#include -#include - -#include "debug.h" -#include "rts51x.h" -#include "rts51x_chip.h" -#include "rts51x_card.h" -#include "rts51x_transport.h" -#include "xd.h" -#include "sd.h" -#include "ms.h" - -void rts51x_do_remaining_work(struct rts51x_chip *chip) -{ - struct sd_info *sd_card = &(chip->sd_card); - struct xd_info *xd_card = &(chip->xd_card); - struct ms_info *ms_card = &(chip->ms_card); - - if (chip->card_ready & SD_CARD) { - if (sd_card->seq_mode) { - RTS51X_SET_STAT(chip, STAT_RUN); - sd_card->counter++; - } else { - sd_card->counter = 0; - } - } - - if (chip->card_ready & XD_CARD) { - if (xd_card->delay_write.delay_write_flag) { - RTS51X_SET_STAT(chip, STAT_RUN); - xd_card->counter++; - } else { - xd_card->counter = 0; - } - } - - if (chip->card_ready & MS_CARD) { - if (CHK_MSPRO(ms_card)) { - if (ms_card->seq_mode) { - RTS51X_SET_STAT(chip, STAT_RUN); - ms_card->counter++; - } else { - ms_card->counter = 0; - } - } else { - if (ms_card->delay_write.delay_write_flag) { - RTS51X_SET_STAT(chip, STAT_RUN); - ms_card->counter++; - } else { - ms_card->counter = 0; - } - } - } - - if (sd_card->counter > POLLING_WAIT_CNT) - rts51x_sd_cleanup_work(chip); - - if (xd_card->counter > POLLING_WAIT_CNT) - rts51x_xd_cleanup_work(chip); - - if (ms_card->counter > POLLING_WAIT_CNT) - rts51x_ms_cleanup_work(chip); -} - -static void do_rts51x_reset_xd_card(struct rts51x_chip *chip) -{ - int retval; - - if (chip->card2lun[XD_CARD] >= MAX_ALLOWED_LUN_CNT) - return; - - retval = rts51x_reset_xd_card(chip); - if (retval == STATUS_SUCCESS) { - chip->card_ready |= XD_CARD; - chip->card_fail &= ~XD_CARD; - chip->rw_card[chip->card2lun[XD_CARD]] = rts51x_xd_rw; - } else { - chip->card_ready &= ~XD_CARD; - chip->card_fail |= XD_CARD; - chip->capacity[chip->card2lun[XD_CARD]] = 0; - chip->rw_card[chip->card2lun[XD_CARD]] = NULL; - - rts51x_init_cmd(chip); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_OE, XD_OUTPUT_EN, 0); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, POWER_MASK, - POWER_OFF); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_CLK_EN, XD_CLK_EN, 0); - rts51x_send_cmd(chip, MODE_C, 100); - } -} - -void rts51x_do_rts51x_reset_sd_card(struct rts51x_chip *chip) -{ - int retval; - - if (chip->card2lun[SD_CARD] >= MAX_ALLOWED_LUN_CNT) - return; - - retval = rts51x_reset_sd_card(chip); - if (retval == STATUS_SUCCESS) { - chip->card_ready |= SD_CARD; - chip->card_fail &= ~SD_CARD; - chip->rw_card[chip->card2lun[SD_CARD]] = rts51x_sd_rw; - } else { - chip->card_ready &= ~SD_CARD; - chip->card_fail |= SD_CARD; - chip->capacity[chip->card2lun[SD_CARD]] = 0; - chip->rw_card[chip->card2lun[SD_CARD]] = NULL; - - rts51x_init_cmd(chip); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_OE, SD_OUTPUT_EN, 0); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, POWER_MASK, - POWER_OFF); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_CLK_EN, SD_CLK_EN, 0); - rts51x_send_cmd(chip, MODE_C, 100); - } -} - -static void do_rts51x_reset_ms_card(struct rts51x_chip *chip) -{ - int retval; - - if (chip->card2lun[MS_CARD] >= MAX_ALLOWED_LUN_CNT) - return; - - retval = rts51x_reset_ms_card(chip); - if (retval == STATUS_SUCCESS) { - chip->card_ready |= MS_CARD; - chip->card_fail &= ~MS_CARD; - chip->rw_card[chip->card2lun[MS_CARD]] = rts51x_ms_rw; - } else { - chip->card_ready &= ~MS_CARD; - chip->card_fail |= MS_CARD; - chip->capacity[chip->card2lun[MS_CARD]] = 0; - chip->rw_card[chip->card2lun[MS_CARD]] = NULL; - - rts51x_init_cmd(chip); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_OE, MS_OUTPUT_EN, 0); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, POWER_MASK, - POWER_OFF); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_CLK_EN, MS_CLK_EN, 0); - rts51x_send_cmd(chip, MODE_C, 100); - } -} - -static void card_cd_debounce(struct rts51x_chip *chip, u8 *need_reset, - u8 *need_release) -{ - int retval; - u8 release_map = 0, reset_map = 0; - u8 value; - - retval = rts51x_get_card_status(chip, &(chip->card_status)); -#ifdef SUPPORT_OCP - chip->ocp_stat = (chip->card_status >> 4) & 0x03; -#endif - - if (retval != STATUS_SUCCESS) - goto Exit_Debounce; - - if (chip->card_exist) { - retval = rts51x_read_register(chip, CARD_INT_PEND, &value); - if (retval != STATUS_SUCCESS) { - rts51x_ep0_write_register(chip, MC_FIFO_CTL, FIFO_FLUSH, - FIFO_FLUSH); - rts51x_ep0_write_register(chip, SFSM_ED, 0xf8, 0xf8); - value = 0; - } - - if (chip->card_exist & XD_CARD) { - if (!(chip->card_status & XD_CD)) - release_map |= XD_CARD; - } else if (chip->card_exist & SD_CARD) { - /* if (!(chip->card_status & SD_CD)) { */ - if (!(chip->card_status & SD_CD) || (value & SD_INT)) - release_map |= SD_CARD; - } else if (chip->card_exist & MS_CARD) { - /* if (!(chip->card_status & MS_CD)) { */ - if (!(chip->card_status & MS_CD) || (value & MS_INT)) - release_map |= MS_CARD; - } - } else { - if (chip->card_status & XD_CD) - reset_map |= XD_CARD; - else if (chip->card_status & SD_CD) - reset_map |= SD_CARD; - else if (chip->card_status & MS_CD) - reset_map |= MS_CARD; - } - - if (CHECK_PKG(chip, QFN24) && reset_map) { - if (chip->card_exist & XD_CARD) { - reset_map = 0; - goto Exit_Debounce; - } - } - - if (reset_map) { - int xd_cnt = 0, sd_cnt = 0, ms_cnt = 0; - int i; - - for (i = 0; i < (chip->option.debounce_num); i++) { - retval = - rts51x_get_card_status(chip, &(chip->card_status)); - if (retval != STATUS_SUCCESS) { - reset_map = release_map = 0; - goto Exit_Debounce; - } - if (chip->card_status & XD_CD) - xd_cnt++; - else - xd_cnt = 0; - if (chip->card_status & SD_CD) - sd_cnt++; - else - sd_cnt = 0; - if (chip->card_status & MS_CD) - ms_cnt++; - else - ms_cnt = 0; - wait_timeout(30); - } - - reset_map = 0; - if (!(chip->card_exist & XD_CARD) - && (xd_cnt > (chip->option.debounce_num - 1))) { - reset_map |= XD_CARD; - } - if (!(chip->card_exist & SD_CARD) - && (sd_cnt > (chip->option.debounce_num - 1))) { - reset_map |= SD_CARD; - } - if (!(chip->card_exist & MS_CARD) - && (ms_cnt > (chip->option.debounce_num - 1))) { - reset_map |= MS_CARD; - } - } - rts51x_write_register(chip, CARD_INT_PEND, XD_INT | MS_INT | SD_INT, - XD_INT | MS_INT | SD_INT); - -Exit_Debounce: - if (need_reset) - *need_reset = reset_map; - if (need_release) - *need_release = release_map; -} - -void rts51x_init_cards(struct rts51x_chip *chip) -{ - u8 need_reset = 0, need_release = 0; - - card_cd_debounce(chip, &need_reset, &need_release); - - if (need_release) { - RTS51X_DEBUGP("need_release = 0x%x\n", need_release); - - rts51x_prepare_run(chip); - RTS51X_SET_STAT(chip, STAT_RUN); - -#ifdef SUPPORT_OCP - if (chip->ocp_stat & (MS_OCP_NOW | MS_OCP_EVER)) { - rts51x_write_register(chip, OCPCTL, MS_OCP_CLEAR, - MS_OCP_CLEAR); - chip->ocp_stat = 0; - RTS51X_DEBUGP("Clear OCP status.\n"); - } -#endif - - if (need_release & XD_CARD) { - chip->card_exist &= ~XD_CARD; - chip->card_ejected = 0; - if (chip->card_ready & XD_CARD) { - rts51x_release_xd_card(chip); - chip->rw_card[chip->card2lun[XD_CARD]] = NULL; - clear_bit(chip->card2lun[XD_CARD], - &(chip->lun_mc)); - } - } - - if (need_release & SD_CARD) { - chip->card_exist &= ~SD_CARD; - chip->card_ejected = 0; - if (chip->card_ready & SD_CARD) { - rts51x_release_sd_card(chip); - chip->rw_card[chip->card2lun[SD_CARD]] = NULL; - clear_bit(chip->card2lun[SD_CARD], - &(chip->lun_mc)); - } - } - - if (need_release & MS_CARD) { - chip->card_exist &= ~MS_CARD; - chip->card_ejected = 0; - if (chip->card_ready & MS_CARD) { - rts51x_release_ms_card(chip); - chip->rw_card[chip->card2lun[MS_CARD]] = NULL; - clear_bit(chip->card2lun[MS_CARD], - &(chip->lun_mc)); - } - } - } - - if (need_reset && !chip->card_ready) { - RTS51X_DEBUGP("need_reset = 0x%x\n", need_reset); - - rts51x_prepare_run(chip); - RTS51X_SET_STAT(chip, STAT_RUN); - - if (need_reset & XD_CARD) { - chip->card_exist |= XD_CARD; - do_rts51x_reset_xd_card(chip); - } else if (need_reset & SD_CARD) { - chip->card_exist |= SD_CARD; - rts51x_do_rts51x_reset_sd_card(chip); - } else if (need_reset & MS_CARD) { - chip->card_exist |= MS_CARD; - do_rts51x_reset_ms_card(chip); - } - } -} - -void rts51x_release_cards(struct rts51x_chip *chip) -{ - if (chip->card_ready & SD_CARD) { - rts51x_sd_cleanup_work(chip); - rts51x_release_sd_card(chip); - chip->card_ready &= ~SD_CARD; - } - - if (chip->card_ready & XD_CARD) { - rts51x_xd_cleanup_work(chip); - rts51x_release_xd_card(chip); - chip->card_ready &= ~XD_CARD; - } - - if (chip->card_ready & MS_CARD) { - rts51x_ms_cleanup_work(chip); - rts51x_release_ms_card(chip); - chip->card_ready &= ~MS_CARD; - } -} - -static inline u8 double_depth(u8 depth) -{ - return (depth > 1) ? (depth - 1) : depth; -} - -int rts51x_switch_ssc_clock(struct rts51x_chip *chip, int clk) -{ - struct sd_info *sd_card = &(chip->sd_card); - struct ms_info *ms_card = &(chip->ms_card); - int retval; - u8 N = (u8) (clk - 2), min_N, max_N; - u8 mcu_cnt, div, max_div, ssc_depth; - int sd_vpclk_phase_reset = 0; - - if (chip->cur_clk == clk) - return STATUS_SUCCESS; - - min_N = 60; - max_N = 120; - max_div = CLK_DIV_4; - - RTS51X_DEBUGP("Switch SSC clock to %dMHz\n", clk); - - if ((clk <= 2) || (N > max_N)) - TRACE_RET(chip, STATUS_FAIL); - - mcu_cnt = (u8) (60 / clk + 3); - if (mcu_cnt > 15) - mcu_cnt = 15; - /* To make sure that the SSC clock div_n is - * equal or greater than min_N */ - div = CLK_DIV_1; - while ((N < min_N) && (div < max_div)) { - N = (N + 2) * 2 - 2; - div++; - } - RTS51X_DEBUGP("N = %d, div = %d\n", N, div); - - if (chip->option.ssc_en) { - if (chip->cur_card == SD_CARD) { - if (CHK_SD_SDR104(sd_card)) { - ssc_depth = chip->option.ssc_depth_sd_sdr104; - } else if (CHK_SD_SDR50(sd_card)) { - ssc_depth = chip->option.ssc_depth_sd_sdr50; - } else if (CHK_SD_DDR50(sd_card)) { - ssc_depth = - double_depth(chip->option. - ssc_depth_sd_ddr50); - } else if (CHK_SD_HS(sd_card)) { - ssc_depth = - double_depth(chip->option.ssc_depth_sd_hs); - } else if (CHK_MMC_52M(sd_card) - || CHK_MMC_DDR52(sd_card)) { - ssc_depth = - double_depth(chip->option. - ssc_depth_mmc_52m); - } else { - ssc_depth = - double_depth(chip->option. - ssc_depth_low_speed); - } - } else if (chip->cur_card == MS_CARD) { - if (CHK_MSPRO(ms_card)) { - if (CHK_HG8BIT(ms_card)) { - ssc_depth = - double_depth(chip->option. - ssc_depth_ms_hg); - } else { - ssc_depth = - double_depth(chip->option. - ssc_depth_ms_4bit); - } - } else { - if (CHK_MS4BIT(ms_card)) { - ssc_depth = - double_depth(chip->option. - ssc_depth_ms_4bit); - } else { - ssc_depth = - double_depth(chip->option. - ssc_depth_low_speed); - } - } - } else { - ssc_depth = - double_depth(chip->option.ssc_depth_low_speed); - } - - if (ssc_depth) { - if (div == CLK_DIV_2) { - /* If clock divided by 2, ssc depth must - * be multiplied by 2 */ - if (ssc_depth > 1) - ssc_depth -= 1; - else - ssc_depth = SSC_DEPTH_2M; - } else if (div == CLK_DIV_4) { - /* If clock divided by 4, ssc depth must - * be multiplied by 4 */ - if (ssc_depth > 2) - ssc_depth -= 2; - else - ssc_depth = SSC_DEPTH_2M; - } - } - } else { - /* Disable SSC */ - ssc_depth = 0; - } - - RTS51X_DEBUGP("ssc_depth = %d\n", ssc_depth); - - rts51x_init_cmd(chip); - rts51x_add_cmd(chip, WRITE_REG_CMD, CLK_DIV, CLK_CHANGE, CLK_CHANGE); - rts51x_add_cmd(chip, WRITE_REG_CMD, CLK_DIV, 0x3F, - (div << 4) | mcu_cnt); - rts51x_add_cmd(chip, WRITE_REG_CMD, SSC_CTL1, SSC_RSTB, 0); - rts51x_add_cmd(chip, WRITE_REG_CMD, SSC_CTL2, SSC_DEPTH_MASK, - ssc_depth); - rts51x_add_cmd(chip, WRITE_REG_CMD, SSC_DIV_N_0, 0xFF, N); - if (sd_vpclk_phase_reset) { - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_VPCLK0_CTL, - PHASE_NOT_RESET, 0); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_VPCLK0_CTL, - PHASE_NOT_RESET, PHASE_NOT_RESET); - } - - retval = rts51x_send_cmd(chip, MODE_C, 2000); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - if (chip->option.ssc_en && ssc_depth) - rts51x_write_register(chip, SSC_CTL1, 0xff, 0xD0); - else - rts51x_write_register(chip, SSC_CTL1, 0xff, 0x50); - udelay(100); - RTS51X_WRITE_REG(chip, CLK_DIV, CLK_CHANGE, 0); - - chip->cur_clk = clk; - - return STATUS_SUCCESS; -} - -int rts51x_switch_normal_clock(struct rts51x_chip *chip, int clk) -{ - int retval; - u8 sel, div, mcu_cnt; - int sd_vpclk_phase_reset = 0; - - if (chip->cur_clk == clk) - return STATUS_SUCCESS; - - if (chip->cur_card == SD_CARD) { - struct sd_info *sd_card = &(chip->sd_card); - if (CHK_SD30_SPEED(sd_card) || CHK_MMC_DDR52(sd_card)) - sd_vpclk_phase_reset = 1; - } - - switch (clk) { - case CLK_20: - RTS51X_DEBUGP("Switch clock to 20MHz\n"); - sel = SSC_80; - div = CLK_DIV_4; - mcu_cnt = 5; - break; - - case CLK_30: - RTS51X_DEBUGP("Switch clock to 30MHz\n"); - sel = SSC_60; - div = CLK_DIV_2; - mcu_cnt = 4; - break; - - case CLK_40: - RTS51X_DEBUGP("Switch clock to 40MHz\n"); - sel = SSC_80; - div = CLK_DIV_2; - mcu_cnt = 3; - break; - - case CLK_50: - RTS51X_DEBUGP("Switch clock to 50MHz\n"); - sel = SSC_100; - div = CLK_DIV_2; - mcu_cnt = 3; - break; - - case CLK_60: - RTS51X_DEBUGP("Switch clock to 60MHz\n"); - sel = SSC_60; - div = CLK_DIV_1; - mcu_cnt = 3; - break; - - case CLK_80: - RTS51X_DEBUGP("Switch clock to 80MHz\n"); - sel = SSC_80; - div = CLK_DIV_1; - mcu_cnt = 2; - break; - - case CLK_100: - RTS51X_DEBUGP("Switch clock to 100MHz\n"); - sel = SSC_100; - div = CLK_DIV_1; - mcu_cnt = 2; - break; - - /* case CLK_120: - RTS51X_DEBUGP("Switch clock to 120MHz\n"); - sel = SSC_120; - div = CLK_DIV_1; - mcu_cnt = 2; - break; - - case CLK_150: - RTS51X_DEBUGP("Switch clock to 150MHz\n"); - sel = SSC_150; - div = CLK_DIV_1; - mcu_cnt = 2; - break; */ - - default: - RTS51X_DEBUGP("Try to switch to an illegal clock (%d)\n", - clk); - TRACE_RET(chip, STATUS_FAIL); - } - - if (!sd_vpclk_phase_reset) { - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, CLK_DIV, CLK_CHANGE, - CLK_CHANGE); - rts51x_add_cmd(chip, WRITE_REG_CMD, CLK_DIV, 0x3F, - (div << 4) | mcu_cnt); - rts51x_add_cmd(chip, WRITE_REG_CMD, SSC_CLK_FPGA_SEL, 0xFF, - sel); - rts51x_add_cmd(chip, WRITE_REG_CMD, CLK_DIV, CLK_CHANGE, 0); - - retval = rts51x_send_cmd(chip, MODE_C, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } else { - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, CLK_DIV, CLK_CHANGE, - CLK_CHANGE); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_VPCLK0_CTL, - PHASE_NOT_RESET, 0); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_VPCLK1_CTL, - PHASE_NOT_RESET, 0); - rts51x_add_cmd(chip, WRITE_REG_CMD, CLK_DIV, 0x3F, - (div << 4) | mcu_cnt); - rts51x_add_cmd(chip, WRITE_REG_CMD, SSC_CLK_FPGA_SEL, 0xFF, - sel); - - retval = rts51x_send_cmd(chip, MODE_C, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - udelay(200); - - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_VPCLK0_CTL, - PHASE_NOT_RESET, PHASE_NOT_RESET); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_VPCLK1_CTL, - PHASE_NOT_RESET, PHASE_NOT_RESET); - - retval = rts51x_send_cmd(chip, MODE_C, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - udelay(200); - - RTS51X_WRITE_REG(chip, CLK_DIV, CLK_CHANGE, 0); - } - - chip->cur_clk = clk; - - return STATUS_SUCCESS; -} - -int rts51x_card_rw(struct scsi_cmnd *srb, struct rts51x_chip *chip, - u32 sec_addr, u16 sec_cnt) -{ - int retval; - unsigned int lun = SCSI_LUN(srb); - int i; - - if (chip->rw_card[lun] == NULL) - return STATUS_FAIL; - - RTS51X_DEBUGP("%s card, sector addr: 0x%x, sector cnt: %d\n", - (srb->sc_data_direction == - DMA_TO_DEVICE) ? "Write" : "Read", sec_addr, sec_cnt); - - chip->rw_need_retry = 0; - for (i = 0; i < 3; i++) { - retval = chip->rw_card[lun] (srb, chip, sec_addr, sec_cnt); - if (retval != STATUS_SUCCESS) { - CATCH_TRIGGER(chip); - if (chip->option.reset_or_rw_fail_set_pad_drive) { - rts51x_write_register(chip, CARD_DRIVE_SEL, - SD20_DRIVE_MASK, - DRIVE_8mA); - } - } - - if (!chip->rw_need_retry) - break; - - RTS51X_DEBUGP("Retry RW, (i = %d\n)", i); - } - - return retval; -} - -u8 rts51x_get_lun_card(struct rts51x_chip *chip, unsigned int lun) -{ - if ((chip->card_ready & chip->lun2card[lun]) == XD_CARD) - return (u8) XD_CARD; - else if ((chip->card_ready & chip->lun2card[lun]) == SD_CARD) - return (u8) SD_CARD; - else if ((chip->card_ready & chip->lun2card[lun]) == MS_CARD) - return (u8) MS_CARD; - - return 0; -} - -static int card_share_mode(struct rts51x_chip *chip, int card) -{ - u8 value; - - if (card == SD_CARD) - value = CARD_SHARE_SD; - else if (card == MS_CARD) - value = CARD_SHARE_MS; - else if (card == XD_CARD) - value = CARD_SHARE_XD; - else - TRACE_RET(chip, STATUS_FAIL); - - RTS51X_WRITE_REG(chip, CARD_SHARE_MODE, CARD_SHARE_MASK, value); - - return STATUS_SUCCESS; -} - -int rts51x_select_card(struct rts51x_chip *chip, int card) -{ - int retval; - - if (chip->cur_card != card) { - u8 mod; - - if (card == SD_CARD) - mod = SD_MOD_SEL; - else if (card == MS_CARD) - mod = MS_MOD_SEL; - else if (card == XD_CARD) - mod = XD_MOD_SEL; - else - TRACE_RET(chip, STATUS_FAIL); - RTS51X_WRITE_REG(chip, CARD_SELECT, 0x07, mod); - chip->cur_card = card; - - retval = card_share_mode(chip, card); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - - return STATUS_SUCCESS; -} - -void rts51x_eject_card(struct rts51x_chip *chip, unsigned int lun) -{ - RTS51X_DEBUGP("eject card\n"); - RTS51X_SET_STAT(chip, STAT_RUN); - rts51x_do_remaining_work(chip); - - if ((chip->card_ready & chip->lun2card[lun]) == SD_CARD) { - rts51x_release_sd_card(chip); - chip->card_ejected |= SD_CARD; - chip->card_ready &= ~SD_CARD; - chip->capacity[lun] = 0; - } else if ((chip->card_ready & chip->lun2card[lun]) == XD_CARD) { - rts51x_release_xd_card(chip); - chip->card_ejected |= XD_CARD; - chip->card_ready &= ~XD_CARD; - chip->capacity[lun] = 0; - } else if ((chip->card_ready & chip->lun2card[lun]) == MS_CARD) { - rts51x_release_ms_card(chip); - chip->card_ejected |= MS_CARD; - chip->card_ready &= ~MS_CARD; - chip->capacity[lun] = 0; - } - rts51x_write_register(chip, CARD_INT_PEND, XD_INT | MS_INT | SD_INT, - XD_INT | MS_INT | SD_INT); -} - -void rts51x_trans_dma_enable(enum dma_data_direction dir, - struct rts51x_chip *chip, u32 byte_cnt, u8 pack_size) -{ - if (pack_size > DMA_1024) - pack_size = DMA_512; - - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, - RING_BUFFER); - - rts51x_add_cmd(chip, WRITE_REG_CMD, MC_DMA_TC3, 0xFF, - (u8) (byte_cnt >> 24)); - rts51x_add_cmd(chip, WRITE_REG_CMD, MC_DMA_TC2, 0xFF, - (u8) (byte_cnt >> 16)); - rts51x_add_cmd(chip, WRITE_REG_CMD, MC_DMA_TC1, 0xFF, - (u8) (byte_cnt >> 8)); - rts51x_add_cmd(chip, WRITE_REG_CMD, MC_DMA_TC0, 0xFF, (u8) byte_cnt); - - if (dir == DMA_FROM_DEVICE) { - rts51x_add_cmd(chip, WRITE_REG_CMD, MC_DMA_CTL, - 0x03 | DMA_PACK_SIZE_MASK, - DMA_DIR_FROM_CARD | DMA_EN | pack_size); - } else { - rts51x_add_cmd(chip, WRITE_REG_CMD, MC_DMA_CTL, - 0x03 | DMA_PACK_SIZE_MASK, - DMA_DIR_TO_CARD | DMA_EN | pack_size); - } -} - -int rts51x_enable_card_clock(struct rts51x_chip *chip, u8 card) -{ - u8 clk_en = 0; - - if (card & XD_CARD) - clk_en |= XD_CLK_EN; - if (card & SD_CARD) - clk_en |= SD_CLK_EN; - if (card & MS_CARD) - clk_en |= MS_CLK_EN; - - RTS51X_WRITE_REG(chip, CARD_CLK_EN, clk_en, clk_en); - - return STATUS_SUCCESS; -} - -int rts51x_card_power_on(struct rts51x_chip *chip, u8 card) -{ - u8 mask, val1, val2; - - mask = POWER_MASK; - val1 = PARTIAL_POWER_ON; - val2 = POWER_ON; - -#ifdef SD_XD_IO_FOLLOW_PWR - if ((card == SD_CARD) || (card == XD_CARD)) { - RTS51X_WRITE_REG(chip, CARD_PWR_CTL, mask | LDO3318_PWR_MASK, - val1 | LDO_SUSPEND); - } else { -#endif - RTS51X_WRITE_REG(chip, CARD_PWR_CTL, mask, val1); -#ifdef SD_XD_IO_FOLLOW_PWR - } -#endif - udelay(chip->option.pwr_delay); - RTS51X_WRITE_REG(chip, CARD_PWR_CTL, mask, val2); -#ifdef SD_XD_IO_FOLLOW_PWR - if (card == SD_CARD) { - rts51x_write_register(chip, CARD_PWR_CTL, LDO3318_PWR_MASK, - LDO_ON); - } -#endif - - return STATUS_SUCCESS; -} - -int monitor_card_cd(struct rts51x_chip *chip, u8 card) -{ - int retval; - u8 card_cd[32] = { 0 }; - - card_cd[SD_CARD] = SD_CD; - card_cd[XD_CARD] = XD_CD; - card_cd[MS_CARD] = MS_CD; - - retval = rts51x_get_card_status(chip, &(chip->card_status)); - if (retval != STATUS_SUCCESS) - return CD_NOT_EXIST; - - if (chip->card_status & card_cd[card]) - return CD_EXIST; - - return CD_NOT_EXIST; -} - -int rts51x_toggle_gpio(struct rts51x_chip *chip, u8 gpio) -{ - int retval; - u8 temp_reg; - u8 gpio_output[4] = { - 0x01, - }; - u8 gpio_oe[4] = { - 0x02, - }; - if (chip->rts5179) { - retval = rts51x_ep0_read_register(chip, CARD_GPIO, &temp_reg); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - temp_reg ^= gpio_oe[gpio]; - temp_reg &= 0xfe; /* bit 0 always set 0 */ - retval = - rts51x_ep0_write_register(chip, CARD_GPIO, 0x03, temp_reg); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - } else { - retval = rts51x_ep0_read_register(chip, CARD_GPIO, &temp_reg); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - temp_reg ^= gpio_output[gpio]; - retval = - rts51x_ep0_write_register(chip, CARD_GPIO, 0xFF, - temp_reg | gpio_oe[gpio]); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - } - - return STATUS_SUCCESS; -} - -int rts51x_turn_on_led(struct rts51x_chip *chip, u8 gpio) -{ - int retval; - u8 gpio_oe[4] = { - 0x02, - }; - u8 gpio_mask[4] = { - 0x03, - }; - - retval = - rts51x_ep0_write_register(chip, CARD_GPIO, gpio_mask[gpio], - gpio_oe[gpio]); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - - return STATUS_SUCCESS; -} - -int rts51x_turn_off_led(struct rts51x_chip *chip, u8 gpio) -{ - int retval; - u8 gpio_output[4] = { - 0x01, - }; - u8 gpio_oe[4] = { - 0x02, - }; - u8 gpio_mask[4] = { - 0x03, - }; - - retval = - rts51x_ep0_write_register(chip, CARD_GPIO, gpio_mask[gpio], - gpio_oe[gpio] | gpio_output[gpio]); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - - return STATUS_SUCCESS; -} diff --git a/drivers/staging/rts5139/rts51x_card.h b/drivers/staging/rts5139/rts51x_card.h deleted file mode 100644 index df8816e0f840..000000000000 --- a/drivers/staging/rts5139/rts51x_card.h +++ /dev/null @@ -1,870 +0,0 @@ -/* Driver for Realtek RTS51xx USB card reader - * Header file - * - * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. - * - * 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, 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, see . - * - * Author: - * wwang (wei_wang@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - * Maintainer: - * Edwin Rong (edwin_rong@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - */ - -#ifndef __RTS51X_CARD_H -#define __RTS51X_CARD_H - -#include "rts51x_chip.h" - -/* Register bit definition */ - -/* Card Power Control Register */ -#define POWER_OFF 0x03 -#define PARTIAL_POWER_ON 0x02 -#define POWER_ON 0x00 -#define POWER_MASK 0x03 -#define LDO3318_PWR_MASK 0x0C -#define LDO_ON 0x00 -#define LDO_SUSPEND 0x08 -#define LDO_OFF 0x0C -#define DV3318_AUTO_PWR_OFF 0x10 -#define FORCE_LDO_POWERB 0x60 - -/* Card Output Enable Register */ -#define XD_OUTPUT_EN 0x02 -#define SD_OUTPUT_EN 0x04 -#define MS_OUTPUT_EN 0x08 - -/* System Clock Control Register */ - -/* System Clock Divider Register */ -#define CLK_CHANGE 0x80 -#define CLK_DIV_1 0x00 -#define CLK_DIV_2 0x01 -#define CLK_DIV_4 0x02 -#define CLK_DIV_8 0x03 - -/* System Clock Select Register */ -#define SSC_60 0 -#define SSC_80 1 -#define SSC_100 2 -#define SSC_120 3 -#define SSC_150 4 - -/* Card Clock Enable Register */ -#define XD_CLK_EN 0x02 -#define SD_CLK_EN 0x04 -#define MS_CLK_EN 0x08 - -/* Card Select Register */ -#define XD_MOD_SEL 1 -#define SD_MOD_SEL 2 -#define MS_MOD_SEL 3 - -/* Card Transfer Reset Register */ -#define XD_STOP 0x02 -#define SD_STOP 0x04 -#define MS_STOP 0x08 -#define XD_CLR_ERR 0x20 -#define SD_CLR_ERR 0x40 -#define MS_CLR_ERR 0x80 - -/* SD30_drive_sel */ -#define SD30_DRIVE_MASK 0x07 - -/* CARD_DRIVE_SEL */ -#define SD20_DRIVE_MASK 0x03 -#define DRIVE_4mA 0x00 -#define DRIVE_8mA 0x01 -#define DRIVE_12mA 0x02 - -/* FPGA_PULL_CTL */ -#define FPGA_MS_PULL_CTL_EN 0xEF -#define FPGA_SD_PULL_CTL_EN 0xF7 -#define FPGA_XD_PULL_CTL_EN1 0xFE -#define FPGA_XD_PULL_CTL_EN2 0xFD -#define FPGA_XD_PULL_CTL_EN3 0xFB - -#define FPGA_MS_PULL_CTL_BIT 0x10 -#define FPGA_SD_PULL_CTL_BIT 0x08 - -/* Card Data Source Register */ -#define PINGPONG_BUFFER 0x01 -#define RING_BUFFER 0x00 - -/* SFSM_ED */ -#define HW_CMD_STOP 0x80 -#define CLR_STAGE_STALL 0x08 -#define CARD_ERR 0x10 - -/* CARD_SHARE_MODE */ -#define CARD_SHARE_LQFP48 0x04 -#define CARD_SHARE_QFN24 0x00 -#define CARD_SHARE_LQFP_SEL 0x04 -#define CARD_SHARE_XD 0x00 -#define CARD_SHARE_SD 0x01 -#define CARD_SHARE_MS 0x02 -#define CARD_SHARE_MASK 0x03 - -/* CARD_AUTO_BLINK */ -#define BLINK_ENABLE 0x08 -#define BLINK_SPEED_MASK 0x07 - -/* CARD_GPIO */ -#define GPIO_OE 0x02 -#define GPIO_OUTPUT 0x01 - -/* CARD_CLK_SOURCE */ -#define CRC_FIX_CLK (0x00 << 0) -#define CRC_VAR_CLK0 (0x01 << 0) -#define CRC_VAR_CLK1 (0x02 << 0) -#define SD30_FIX_CLK (0x00 << 2) -#define SD30_VAR_CLK0 (0x01 << 2) -#define SD30_VAR_CLK1 (0x02 << 2) -#define SAMPLE_FIX_CLK (0x00 << 4) -#define SAMPLE_VAR_CLK0 (0x01 << 4) -#define SAMPLE_VAR_CLK1 (0x02 << 4) - -/* DCM_DRP_CTL */ -#define DCM_RESET 0x08 -#define DCM_LOCKED 0x04 -#define DCM_208M 0x00 -#define DCM_TX 0x01 -#define DCM_RX 0x02 - -/* DCM_DRP_TRIG */ -#define DRP_START 0x80 -#define DRP_DONE 0x40 - -/* DCM_DRP_CFG */ -#define DRP_WRITE 0x80 -#define DRP_READ 0x00 -#define DCM_WRITE_ADDRESS_50 0x50 -#define DCM_WRITE_ADDRESS_51 0x51 -#define DCM_READ_ADDRESS_00 0x00 -#define DCM_READ_ADDRESS_51 0x51 - -/* HW_VERSION */ -#define FPGA_VER 0x80 -#define HW_VER_MASK 0x0F - -/* CD_DEGLITCH_EN */ -#define DISABLE_SD_CD 0x08 -#define DISABLE_MS_CD 0x10 -#define DISABLE_XD_CD 0x20 -#define SD_CD_DEGLITCH_EN 0x01 -#define MS_CD_DEGLITCH_EN 0x02 -#define XD_CD_DEGLITCH_EN 0x04 - -/* OCPCTL */ -#define CARD_OC_DETECT_EN 0x08 -#define CARD_OC_CLR 0x01 - -/* CARD_DMA1_CTL */ -#define EXTEND_DMA1_ASYNC_SIGNAL 0x02 - -/* HS_USB_STAT */ -#define USB_HI_SPEED 0x01 - -/* CFG_MODE_1 */ -#define RTS5179 0x02 - -/* SYS_DUMMY0 */ -#define NYET_EN 0x01 -#define NYET_MSAK 0x01 - -/* SSC_CTL1 */ -#define SSC_RSTB 0x80 -#define SSC_8X_EN 0x40 -#define SSC_FIX_FRAC 0x20 -#define SSC_SEL_1M 0x00 -#define SSC_SEL_2M 0x08 -#define SSC_SEL_4M 0x10 -#define SSC_SEL_8M 0x18 - -/* SSC_CTL2 */ -#define SSC_DEPTH_MASK 0x03 -#define SSC_DEPTH_DISALBE 0x00 -#define SSC_DEPTH_2M 0x01 -#define SSC_DEPTH_1M 0x02 -#define SSC_DEPTH_512K 0x03 - -/* LDO_POWER_CFG */ -#define TUNE_SD18_MASK 0x1C -#define TUNE_SD18_1V8 (0x01 << 2) -#define TUNE_SD18_3V3 (0x07 << 2) - -/* XD_CP_WAITTIME */ -#define WAIT_1F 0x00 -#define WAIT_3F 0x01 -#define WAIT_7F 0x02 -#define WAIT_FF 0x03 - -/* XD_INIT */ -#define XD_PWR_OFF_DELAY0 0x00 -#define XD_PWR_OFF_DELAY1 0x02 -#define XD_PWR_OFF_DELAY2 0x04 -#define XD_PWR_OFF_DELAY3 0x06 -#define XD_AUTO_PWR_OFF_EN 0xF7 -#define XD_NO_AUTO_PWR_OFF 0x08 - -/* XD_DTCTL */ -/* XD_CATCTL */ -#define XD_TIME_RWN_1 0x00 -#define XD_TIME_RWN_STEP 0x20 -#define XD_TIME_RW_1 0x00 -#define XD_TIME_RW_STEP 0x04 -#define XD_TIME_SETUP_1 0x00 -#define XD_TIME_SETUP_STEP 0x01 - -/* XD_CTL */ -#define XD_ECC2_UNCORRECTABLE 0x80 -#define XD_ECC2_ERROR 0x40 -#define XD_ECC1_UNCORRECTABLE 0x20 -#define XD_ECC1_ERROR 0x10 -#define XD_RDY 0x04 -#define XD_CE_EN 0xFD -#define XD_CE_DISEN 0x02 -#define XD_WP_EN 0xFE -#define XD_WP_DISEN 0x01 - -/* XD_TRANSFER */ -#define XD_TRANSFER_START 0x80 -#define XD_TRANSFER_END 0x40 -#define XD_PPB_EMPTY 0x20 -#define XD_ERR 0x10 -#define XD_RESET 0x00 -#define XD_ERASE 0x01 -#define XD_READ_STATUS 0x02 -#define XD_READ_ID 0x03 -#define XD_READ_REDUNDANT 0x04 -#define XD_READ_PAGES 0x05 -#define XD_SET_CMD 0x06 -#define XD_NORMAL_READ 0x07 -#define XD_WRITE_PAGES 0x08 -#define XD_NORMAL_WRITE 0x09 -#define XD_WRITE_REDUNDANT 0x0A -#define XD_SET_ADDR 0x0B -#define XD_COPY_PAGES 0x0C - -/* XD_CFG */ -#define XD_PPB_TO_SIE 0x80 -#define XD_TO_PPB_ONLY 0x00 -#define XD_BA_TRANSFORM 0x40 -#define XD_BA_NO_TRANSFORM 0x00 -#define XD_NO_CALC_ECC 0x20 -#define XD_CALC_ECC 0x00 -#define XD_IGNORE_ECC 0x10 -#define XD_CHECK_ECC 0x00 -#define XD_DIRECT_TO_RB 0x08 -#define XD_ADDR_MASK 0x07 -#define XD_ADDR_LENGTH_0 0x00 -#define XD_ADDR_LENGTH_1 0x01 -#define XD_ADDR_LENGTH_2 0x02 -#define XD_ADDR_LENGTH_3 0x03 -#define XD_ADDR_LENGTH_4 0x04 - -/* XD_PAGE_STATUS */ -#define XD_GPG 0xFF -#define XD_BPG 0x00 - -/* XD_BLOCK_STATUS */ -#define XD_GBLK 0xFF -#define XD_LATER_BBLK 0xF0 - -/* XD_PARITY */ -#define XD_ECC2_ALL1 0x80 -#define XD_ECC1_ALL1 0x40 -#define XD_BA2_ALL0 0x20 -#define XD_BA1_ALL0 0x10 -#define XD_BA1_BA2_EQL 0x04 -#define XD_BA2_VALID 0x02 -#define XD_BA1_VALID 0x01 - -/* XD_CHK_DATA_STATUS */ -#define XD_PGSTS_ZEROBIT_OVER4 0x00 -#define XD_PGSTS_NOT_FF 0x02 -#define XD_AUTO_CHK_DATA_STATUS 0x01 - -/* SD_CFG1 */ -#define SD_CLK_DIVIDE_0 0x00 -#define SD_CLK_DIVIDE_256 0xC0 -#define SD_CLK_DIVIDE_128 0x80 -#define SD_CLK_DIVIDE_MASK 0xC0 -#define SD_BUS_WIDTH_1 0x00 -#define SD_BUS_WIDTH_4 0x01 -#define SD_BUS_WIDTH_8 0x02 -#define SD_ASYNC_FIFO_RST 0x10 -#define SD_20_MODE 0x00 -#define SD_DDR_MODE 0x04 -#define SD_30_MODE 0x08 - -/* SD_CFG2 */ -#define SD_CALCULATE_CRC7 0x00 -#define SD_NO_CALCULATE_CRC7 0x80 -#define SD_CHECK_CRC16 0x00 -#define SD_NO_CHECK_CRC16 0x40 -#define SD_WAIT_CRC_TO_EN 0x20 -#define SD_WAIT_BUSY_END 0x08 -#define SD_NO_WAIT_BUSY_END 0x00 -#define SD_CHECK_CRC7 0x00 -#define SD_NO_CHECK_CRC7 0x04 -#define SD_RSP_LEN_0 0x00 -#define SD_RSP_LEN_6 0x01 -#define SD_RSP_LEN_17 0x02 -/* SD/MMC Response Type Definition */ -/* SD_CALCULATE_CRC7, SD_CHECK_CRC16, - * SD_NO_WAIT_BUSY_END, SD_NO_CHECK_CRC7, - * SD_RSP_LEN_0 */ -#define SD_RSP_TYPE_R0 0x04 -/* SD_CALCULATE_CRC7, SD_CHECK_CRC16, - * SD_NO_WAIT_BUSY_END, SD_CHECK_CRC7, - * SD_RSP_LEN_6 */ -#define SD_RSP_TYPE_R1 0x01 -/* SD_CALCULATE_CRC7, SD_CHECK_CRC16, - * SD_WAIT_BUSY_END, SD_CHECK_CRC7, - * SD_RSP_LEN_6 */ -#define SD_RSP_TYPE_R1b 0x09 -/* SD_CALCULATE_CRC7, SD_CHECK_CRC16, - * SD_NO_WAIT_BUSY_END, SD_CHECK_CRC7, - * SD_RSP_LEN_17 */ -#define SD_RSP_TYPE_R2 0x02 -/* SD_CALCULATE_CRC7, SD_CHECK_CRC16, - * SD_NO_WAIT_BUSY_END, SD_NO_CHECK_CRC7, - * SD_RSP_LEN_6 */ -#define SD_RSP_TYPE_R3 0x05 -/* SD_CALCULATE_CRC7, SD_CHECK_CRC16, - * SD_NO_WAIT_BUSY_END, SD_NO_CHECK_CRC7, - * SD_RSP_LEN_6 */ -#define SD_RSP_TYPE_R4 0x05 -/* SD_CALCULATE_CRC7, SD_CHECK_CRC16, - * SD_NO_WAIT_BUSY_END, SD_CHECK_CRC7, - * SD_RSP_LEN_6 */ -#define SD_RSP_TYPE_R5 0x01 -/* SD_CALCULATE_CRC7, SD_CHECK_CRC16, - * SD_NO_WAIT_BUSY_END, SD_CHECK_CRC7, - * SD_RSP_LEN_6 */ -#define SD_RSP_TYPE_R6 0x01 -/* SD_CALCULATE_CRC7, SD_CHECK_CRC16, - * SD_NO_WAIT_BUSY_END, SD_CHECK_CRC7, - * SD_RSP_LEN_6 */ -#define SD_RSP_TYPE_R7 0x01 - -/* SD_CFG3 */ -#define SD_RSP_80CLK_TIMEOUT_EN 0x01 - -/* SD_STAT1 */ -#define SD_CRC7_ERR 0x80 -#define SD_CRC16_ERR 0x40 -#define SD_CRC_WRITE_ERR 0x20 -#define SD_CRC_WRITE_ERR_MASK 0x1C -#define GET_CRC_TIME_OUT 0x02 -#define SD_TUNING_COMPARE_ERR 0x01 - -/* SD_STAT2 */ -#define SD_RSP_80CLK_TIMEOUT 0x01 - -/* SD_BUS_STAT */ -#define SD_CLK_TOGGLE_EN 0x80 -#define SD_CLK_FORCE_STOP 0x40 -#define SD_DAT3_STATUS 0x10 -#define SD_DAT2_STATUS 0x08 -#define SD_DAT1_STATUS 0x04 -#define SD_DAT0_STATUS 0x02 -#define SD_CMD_STATUS 0x01 - -/* SD_PAD_CTL */ -#define SD_IO_USING_1V8 0x80 -#define SD_IO_USING_3V3 0x7F -#define TYPE_A_DRIVING 0x00 -#define TYPE_B_DRIVING 0x01 -#define TYPE_C_DRIVING 0x02 -#define TYPE_D_DRIVING 0x03 - -/* SD_SAMPLE_POINT_CTL */ -#define DDR_FIX_RX_DAT 0x00 -#define DDR_VAR_RX_DAT 0x80 -#define DDR_FIX_RX_DAT_EDGE 0x00 -#define DDR_FIX_RX_DAT_14_DELAY 0x40 -#define DDR_FIX_RX_CMD 0x00 -#define DDR_VAR_RX_CMD 0x20 -#define DDR_FIX_RX_CMD_POS_EDGE 0x00 -#define DDR_FIX_RX_CMD_14_DELAY 0x10 -#define SD20_RX_POS_EDGE 0x00 -#define SD20_RX_14_DELAY 0x08 -#define SD20_RX_SEL_MASK 0x08 - -/* SD_PUSH_POINT_CTL */ -#define DDR_FIX_TX_CMD_DAT 0x00 -#define DDR_VAR_TX_CMD_DAT 0x80 -#define DDR_FIX_TX_DAT_14_TSU 0x00 -#define DDR_FIX_TX_DAT_12_TSU 0x40 -#define DDR_FIX_TX_CMD_NEG_EDGE 0x00 -#define DDR_FIX_TX_CMD_14_AHEAD 0x20 -#define SD20_TX_NEG_EDGE 0x00 -#define SD20_TX_14_AHEAD 0x10 -#define SD20_TX_SEL_MASK 0x10 -#define DDR_VAR_SDCLK_POL_SWAP 0x01 - -/* SD_TRANSFER */ -#define SD_TRANSFER_START 0x80 -#define SD_TRANSFER_END 0x40 -#define SD_STAT_IDLE 0x20 -#define SD_TRANSFER_ERR 0x10 -/* SD Transfer Mode definition */ -#define SD_TM_NORMAL_WRITE 0x00 -#define SD_TM_AUTO_WRITE_3 0x01 -#define SD_TM_AUTO_WRITE_4 0x02 -#define SD_TM_AUTO_READ_3 0x05 -#define SD_TM_AUTO_READ_4 0x06 -#define SD_TM_CMD_RSP 0x08 -#define SD_TM_AUTO_WRITE_1 0x09 -#define SD_TM_AUTO_WRITE_2 0x0A -#define SD_TM_NORMAL_READ 0x0C -#define SD_TM_AUTO_READ_1 0x0D -#define SD_TM_AUTO_READ_2 0x0E -#define SD_TM_AUTO_TUNING 0x0F - -/* SD_VPTX_CTL / SD_VPRX_CTL */ -#define PHASE_CHANGE 0x80 -#define PHASE_NOT_RESET 0x40 - -/* SD_DCMPS_TX_CTL / SD_DCMPS_RX_CTL */ -#define DCMPS_CHANGE 0x80 -#define DCMPS_CHANGE_DONE 0x40 -#define DCMPS_ERROR 0x20 -#define DCMPS_CURRENT_PHASE 0x1F - -/* SD_CMD_STATE */ -#define SD_CMD_IDLE 0x80 - -/* SD_DATA_STATE */ -#define SD_DATA_IDLE 0x80 - -/* MS_BLKEND */ -#define SET_BLKEND 0x01 - -/* MS_CFG */ -#define SAMPLE_TIME_RISING 0x00 -#define SAMPLE_TIME_FALLING 0x80 -#define PUSH_TIME_DEFAULT 0x00 -#define PUSH_TIME_ODD 0x40 -#define NO_EXTEND_TOGGLE 0x00 -#define EXTEND_TOGGLE_CHK 0x20 -#define MS_BUS_WIDTH_1 0x00 -#define MS_BUS_WIDTH_4 0x10 -#define MS_BUS_WIDTH_8 0x18 -#define MS_2K_SECTOR_MODE 0x04 -#define MS_512_SECTOR_MODE 0x00 -#define MS_TOGGLE_TIMEOUT_EN 0x00 -#define MS_TOGGLE_TIMEOUT_DISEN 0x01 -#define MS_NO_CHECK_INT 0x02 - -/* MS_TRANS_CFG */ -#define WAIT_INT 0x80 -#define NO_WAIT_INT 0x00 -#define NO_AUTO_READ_INT_REG 0x00 -#define AUTO_READ_INT_REG 0x40 -#define MS_CRC16_ERR 0x20 -#define MS_RDY_TIMEOUT 0x10 -#define MS_INT_CMDNK 0x08 -#define MS_INT_BREQ 0x04 -#define MS_INT_ERR 0x02 -#define MS_INT_CED 0x01 - -/* MS_TRANSFER */ -#define MS_TRANSFER_START 0x80 -#define MS_TRANSFER_END 0x40 -#define MS_TRANSFER_ERR 0x20 -#define MS_BS_STATE 0x10 -#define MS_TM_READ_BYTES 0x00 -#define MS_TM_NORMAL_READ 0x01 -#define MS_TM_WRITE_BYTES 0x04 -#define MS_TM_NORMAL_WRITE 0x05 -#define MS_TM_AUTO_READ 0x08 -#define MS_TM_AUTO_WRITE 0x0C -#define MS_TM_SET_CMD 0x06 -#define MS_TM_COPY_PAGE 0x07 -#define MS_TM_MULTI_READ 0x02 -#define MS_TM_MULTI_WRITE 0x03 - -/* MC_DMA_CTL */ -#define DMA_TC_EQ_0 0x80 -#define DMA_DIR_TO_CARD 0x00 -#define DMA_DIR_FROM_CARD 0x02 -#define DMA_EN 0x01 -#define DMA_128 (0 << 2) -#define DMA_256 (1 << 2) -#define DMA_512 (2 << 2) -#define DMA_1024 (3 << 2) -#define DMA_PACK_SIZE_MASK 0x0C - -/* CARD_INT_PEND */ -#define XD_INT 0x10 -#define MS_INT 0x08 -#define SD_INT 0x04 - -/* MC_FIFO_CTL */ -#define FIFO_FLUSH 0x01 - -/* AUTO_DELINK_EN */ -#define AUTO_DELINK 0x02 -#define FORCE_DELINK 0x01 - -/* MC_DMA_RST */ -#define DMA_RESET 0x01 - -#define SSC_POWER_MASK 0x01 -#define SSC_POWER_DOWN 0x01 -#define SSC_POWER_ON 0x00 - -/* OCPCTL */ -#define MS_OCP_DETECT_EN 0x08 -#define MS_OCP_INT_EN 0x04 -#define MS_OCP_INT_CLR 0x02 -#define MS_OCP_CLEAR 0x01 - -/* OCPSTAT */ -#define MS_OCP_DETECT 0x80 -#define MS_OCP_NOW 0x02 -#define MS_OCP_EVER 0x01 - -/* MC_FIFO_STAT */ -#define FIFO_FULL 0x01 -#define FIFO_EMPTY 0x02 - -/* RCCTL */ -#define U_HW_CMD_EN_MASK 0x02 -#define U_HW_CMD_EN 0x02 -#define U_HW_CMD_DIS 0x00 - -/* Register address */ -#define FPDCTL 0xFC00 -#define SSC_DIV_N_0 0xFC07 -#define SSC_CTL1 0xFC09 -#define SSC_CTL2 0xFC0A -#define CFG_MODE_1 0xFC0F -#define RCCTL 0xFC14 -#define SYS_DUMMY0 0xFC30 -#define XD_CP_WAITTIME 0xFD00 -#define XD_CP_PAGELEN 0xFD01 -#define XD_CP_READADDR0 0xFD02 -#define XD_CP_READADDR1 0xFD03 -#define XD_CP_READADDR2 0xFD04 -#define XD_CP_READADDR3 0xFD05 -#define XD_CP_READADDR4 0xFD06 -#define XD_CP_WRITEADDR0 0xFD07 -#define XD_CP_WRITEADDR1 0xFD08 -#define XD_CP_WRITEADDR2 0xFD09 -#define XD_CP_WRITEADDR3 0xFD0A -#define XD_CP_WRITEADDR4 0xFD0B -#define XD_INIT 0xFD10 -#define XD_DTCTL 0xFD11 -#define XD_CTL 0xFD12 -#define XD_TRANSFER 0xFD13 -#define XD_CFG 0xFD14 -#define XD_ADDRESS0 0xFD15 -#define XD_ADDRESS1 0xFD16 -#define XD_ADDRESS2 0xFD17 -#define XD_ADDRESS3 0xFD18 -#define XD_ADDRESS4 0xFD19 -#define XD_DAT 0xFD1A -#define XD_PAGE_CNT 0xFD1B -#define XD_PAGE_STATUS 0xFD1C -#define XD_BLOCK_STATUS 0xFD1D -#define XD_BLOCK_ADDR1_L 0xFD1E -#define XD_BLOCK_ADDR1_H 0xFD1F -#define XD_BLOCK_ADDR2_L 0xFD20 -#define XD_BLOCK_ADDR2_H 0xFD21 -#define XD_BYTE_CNT_L 0xFD22 -#define XD_BYTE_CNT_H 0xFD23 -#define XD_PARITY 0xFD24 -#define XD_ECC_BIT1 0xFD25 -#define XD_ECC_BYTE1 0xFD26 -#define XD_ECC_BIT2 0xFD27 -#define XD_ECC_BYTE2 0xFD28 -#define XD_RESERVED0 0xFD29 -#define XD_RESERVED1 0xFD2A -#define XD_RESERVED2 0xFD2B -#define XD_RESERVED3 0xFD2C -#define XD_CHK_DATA_STATUS 0xFD2D -#define XD_CATCTL 0xFD2E - -#define MS_BLKEND 0xFD30 -#define MS_READ_START 0xFD31 -#define MS_READ_COUNT 0xFD32 -#define MS_WRITE_START 0xFD33 -#define MS_WRITE_COUNT 0xFD34 -#define MS_COMMAND 0xFD35 -#define MS_OLD_BLOCK_0 0xFD36 -#define MS_OLD_BLOCK_1 0xFD37 -#define MS_NEW_BLOCK_0 0xFD38 -#define MS_NEW_BLOCK_1 0xFD39 -#define MS_LOG_BLOCK_0 0xFD3A -#define MS_LOG_BLOCK_1 0xFD3B -#define MS_BUS_WIDTH 0xFD3C -#define MS_PAGE_START 0xFD3D -#define MS_PAGE_LENGTH 0xFD3E -#define MS_CFG 0xFD40 -#define MS_TPC 0xFD41 -#define MS_TRANS_CFG 0xFD42 -#define MS_TRANSFER 0xFD43 -#define MS_INT_REG 0xFD44 -#define MS_BYTE_CNT 0xFD45 -#define MS_SECTOR_CNT_L 0xFD46 -#define MS_SECTOR_CNT_H 0xFD47 -#define MS_DBUS_H 0xFD48 - -#define CARD_DMA1_CTL 0xFD5C -#define CARD_PULL_CTL1 0xFD60 -#define CARD_PULL_CTL2 0xFD61 -#define CARD_PULL_CTL3 0xFD62 -#define CARD_PULL_CTL4 0xFD63 -#define CARD_PULL_CTL5 0xFD64 -#define CARD_PULL_CTL6 0xFD65 -#define CARD_EXIST 0xFD6F -#define CARD_INT_PEND 0xFD71 - -#define LDO_POWER_CFG 0xFD7B - -#define SD_CFG1 0xFDA0 -#define SD_CFG2 0xFDA1 -#define SD_CFG3 0xFDA2 -#define SD_STAT1 0xFDA3 -#define SD_STAT2 0xFDA4 -#define SD_BUS_STAT 0xFDA5 -#define SD_PAD_CTL 0xFDA6 -#define SD_SAMPLE_POINT_CTL 0xFDA7 -#define SD_PUSH_POINT_CTL 0xFDA8 -#define SD_CMD0 0xFDA9 -#define SD_CMD1 0xFDAA -#define SD_CMD2 0xFDAB -#define SD_CMD3 0xFDAC -#define SD_CMD4 0xFDAD -#define SD_CMD5 0xFDAE -#define SD_BYTE_CNT_L 0xFDAF -#define SD_BYTE_CNT_H 0xFDB0 -#define SD_BLOCK_CNT_L 0xFDB1 -#define SD_BLOCK_CNT_H 0xFDB2 -#define SD_TRANSFER 0xFDB3 -#define SD_CMD_STATE 0xFDB5 -#define SD_DATA_STATE 0xFDB6 -#define SD_VPCLK0_CTL 0xFC2A -#define SD_VPCLK1_CTL 0xFC2B -#define SD_DCMPS0_CTL 0xFC2C -#define SD_DCMPS1_CTL 0xFC2D - -#define CARD_DMA1_CTL 0xFD5C - -#define HW_VERSION 0xFC01 - -#define SSC_CLK_FPGA_SEL 0xFC02 -#define CLK_DIV 0xFC03 -#define SFSM_ED 0xFC04 - -#define CD_DEGLITCH_WIDTH 0xFC20 -#define CD_DEGLITCH_EN 0xFC21 -#define AUTO_DELINK_EN 0xFC23 - -#define FPGA_PULL_CTL 0xFC1D -#define CARD_CLK_SOURCE 0xFC2E - -#define CARD_SHARE_MODE 0xFD51 -#define CARD_DRIVE_SEL 0xFD52 -#define CARD_STOP 0xFD53 -#define CARD_OE 0xFD54 -#define CARD_AUTO_BLINK 0xFD55 -#define CARD_GPIO 0xFD56 -#define SD30_DRIVE_SEL 0xFD57 - -#define CARD_DATA_SOURCE 0xFD5D -#define CARD_SELECT 0xFD5E - -#define CARD_CLK_EN 0xFD79 -#define CARD_PWR_CTL 0xFD7A - -#define OCPCTL 0xFD80 -#define OCPPARA1 0xFD81 -#define OCPPARA2 0xFD82 -#define OCPSTAT 0xFD83 - -#define HS_USB_STAT 0xFE01 -#define HS_VCONTROL 0xFE26 -#define HS_VSTAIN 0xFE27 -#define HS_VLOADM 0xFE28 -#define HS_VSTAOUT 0xFE29 - -#define MC_IRQ 0xFF00 -#define MC_IRQEN 0xFF01 -#define MC_FIFO_CTL 0xFF02 -#define MC_FIFO_BC0 0xFF03 -#define MC_FIFO_BC1 0xFF04 -#define MC_FIFO_STAT 0xFF05 -#define MC_FIFO_MODE 0xFF06 -#define MC_FIFO_RD_PTR0 0xFF07 -#define MC_FIFO_RD_PTR1 0xFF08 -#define MC_DMA_CTL 0xFF10 -#define MC_DMA_TC0 0xFF11 -#define MC_DMA_TC1 0xFF12 -#define MC_DMA_TC2 0xFF13 -#define MC_DMA_TC3 0xFF14 -#define MC_DMA_RST 0xFF15 - -/* Memory mapping */ -#define RBUF_SIZE_MASK 0xFBFF -#define RBUF_BASE 0xF000 -#define PPBUF_BASE1 0xF800 -#define PPBUF_BASE2 0xFA00 - -/* int monitor_card_cd */ -#define CD_EXIST 0 -#define CD_NOT_EXIST 1 - -#define DEBOUNCE_CNT 5 - -int monitor_card_cd(struct rts51x_chip *chip, u8 card); - -void rts51x_do_remaining_work(struct rts51x_chip *chip); -void rts51x_do_rts51x_reset_sd_card(struct rts51x_chip *chip); -void rts51x_init_cards(struct rts51x_chip *chip); -void rts51x_release_cards(struct rts51x_chip *chip); -int rts51x_switch_ssc_clock(struct rts51x_chip *chip, int clk); -int rts51x_switch_normal_clock(struct rts51x_chip *chip, int clk); -int rts51x_card_rw(struct scsi_cmnd *srb, struct rts51x_chip *chip, - u32 sec_addr, u16 sec_cnt); -u8 rts51x_get_lun_card(struct rts51x_chip *chip, unsigned int lun); -int rts51x_select_card(struct rts51x_chip *chip, int card); -void rts51x_eject_card(struct rts51x_chip *chip, unsigned int lun); -void rts51x_trans_dma_enable(enum dma_data_direction dir, - struct rts51x_chip *chip, u32 byte_cnt, u8 pack_size); -int rts51x_enable_card_clock(struct rts51x_chip *chip, u8 card); -int rts51x_card_power_on(struct rts51x_chip *chip, u8 card); -int rts51x_toggle_gpio(struct rts51x_chip *chip, u8 gpio); -int rts51x_turn_on_led(struct rts51x_chip *chip, u8 gpio); -int rts51x_turn_off_led(struct rts51x_chip *chip, u8 gpio); - -static inline int check_card_ready(struct rts51x_chip *chip, unsigned int lun) -{ - if (chip->card_ready & chip->lun2card[lun]) - return 1; - - return 0; -} - -static inline int check_card_exist(struct rts51x_chip *chip, unsigned int lun) -{ - if (chip->card_exist & chip->lun2card[lun]) - return 1; - - return 0; -} - -static inline int check_card_wp(struct rts51x_chip *chip, unsigned int lun) -{ - if (chip->card_wp & chip->lun2card[lun]) - return 1; - - return 0; -} - -static inline int check_card_fail(struct rts51x_chip *chip, unsigned int lun) -{ - if (chip->card_fail & chip->lun2card[lun]) - return 1; - - return 0; -} - -static inline int check_card_ejected(struct rts51x_chip *chip, unsigned int lun) -{ - if (chip->card_ejected & chip->lun2card[lun]) - return 1; - - return 0; -} - -static inline int check_fake_card_ready(struct rts51x_chip *chip, - unsigned int lun) -{ - if (chip->fake_card_ready & chip->lun2card[lun]) - return 1; - - return 0; -} - -static inline u8 get_lun2card(struct rts51x_chip *chip, unsigned int lun) -{ - return chip->lun2card[lun]; -} - -static inline int check_lun_mc(struct rts51x_chip *chip, unsigned int lun) -{ - return CHK_BIT(chip->lun_mc, lun); -} - -static inline void set_lun_mc(struct rts51x_chip *chip, unsigned int lun) -{ - SET_BIT(chip->lun_mc, lun); -} - -static inline void clear_lun_mc(struct rts51x_chip *chip, unsigned int lun) -{ - CLR_BIT(chip->lun_mc, lun); -} - -static inline int switch_clock(struct rts51x_chip *chip, int clk) -{ - int retval = 0; - - if (chip->asic_code) - retval = rts51x_switch_ssc_clock(chip, clk); - else - retval = rts51x_switch_normal_clock(chip, clk); - - return retval; -} - -static inline void rts51x_clear_xd_error(struct rts51x_chip *chip) -{ - rts51x_ep0_write_register(chip, CARD_STOP, - XD_STOP | XD_CLR_ERR, XD_STOP | XD_CLR_ERR); - - rts51x_ep0_write_register(chip, MC_FIFO_CTL, FIFO_FLUSH, FIFO_FLUSH); - rts51x_ep0_write_register(chip, MC_DMA_RST, DMA_RESET, DMA_RESET); - rts51x_ep0_write_register(chip, SFSM_ED, 0xf8, 0xf8); -} - -static inline void rts51x_clear_sd_error(struct rts51x_chip *chip) -{ - rts51x_ep0_write_register(chip, CARD_STOP, - SD_STOP | SD_CLR_ERR, SD_STOP | SD_CLR_ERR); - - rts51x_ep0_write_register(chip, MC_FIFO_CTL, FIFO_FLUSH, FIFO_FLUSH); - rts51x_ep0_write_register(chip, MC_DMA_RST, DMA_RESET, DMA_RESET); - rts51x_ep0_write_register(chip, SFSM_ED, 0xf8, 0xf8); -} - -static inline void rts51x_clear_ms_error(struct rts51x_chip *chip) -{ - rts51x_ep0_write_register(chip, CARD_STOP, - MS_STOP | MS_CLR_ERR, MS_STOP | MS_CLR_ERR); - - rts51x_ep0_write_register(chip, MC_FIFO_CTL, FIFO_FLUSH, FIFO_FLUSH); - rts51x_ep0_write_register(chip, MC_DMA_RST, DMA_RESET, DMA_RESET); - rts51x_ep0_write_register(chip, SFSM_ED, 0xf8, 0xf8); -} - -#endif /* __RTS51X_CARD_H */ diff --git a/drivers/staging/rts5139/rts51x_chip.c b/drivers/staging/rts5139/rts51x_chip.c deleted file mode 100644 index 7d7510de170c..000000000000 --- a/drivers/staging/rts5139/rts51x_chip.c +++ /dev/null @@ -1,1014 +0,0 @@ -/* Driver for Realtek RTS51xx USB card reader - * - * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. - * - * 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, 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, see . - * - * Author: - * wwang (wei_wang@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - * Maintainer: - * Edwin Rong (edwin_rong@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - */ - -#include -#include -#include -#include - -#include "debug.h" -#include "trace.h" -#include "rts51x.h" -#include "rts51x_chip.h" -#include "rts51x_card.h" -#include "rts51x_transport.h" -#include "xd.h" -#include "ms.h" -#include "sd.h" - -static int check_sd_speed_prior(u32 sd_speed_prior) -{ - int i, fake_para = 0; - - /* Check the legality of sd_speed_prior */ - for (i = 0; i < 4; i++) { - u8 tmp = (u8) (sd_speed_prior >> (i * 8)); - if ((tmp < 0x01) || (tmp > 0x04)) { - fake_para = 1; - break; - } - } - - return !fake_para; -} - -int rts51x_reset_chip(struct rts51x_chip *chip) -{ - int retval; - - if (CHECK_PKG(chip, LQFP48)) { - RTS51X_WRITE_REG(chip, CARD_PWR_CTL, LDO3318_PWR_MASK, - LDO_SUSPEND); - RTS51X_WRITE_REG(chip, CARD_PWR_CTL, FORCE_LDO_POWERB, - FORCE_LDO_POWERB); - RTS51X_WRITE_REG(chip, CARD_PULL_CTL1, 0x30, 0x10); - RTS51X_WRITE_REG(chip, CARD_PULL_CTL5, 0x03, 0x01); - RTS51X_WRITE_REG(chip, CARD_PULL_CTL6, 0x0C, 0x04); - } - if (chip->asic_code) { - RTS51X_WRITE_REG(chip, SYS_DUMMY0, NYET_MSAK, NYET_EN); - RTS51X_WRITE_REG(chip, CD_DEGLITCH_WIDTH, 0xFF, 0x08); - rts51x_write_register(chip, CD_DEGLITCH_EN, XD_CD_DEGLITCH_EN, - 0x00); - rts51x_write_register(chip, SD30_DRIVE_SEL, SD30_DRIVE_MASK, - chip->option.sd30_pad_drive); - rts51x_write_register(chip, CARD_DRIVE_SEL, SD20_DRIVE_MASK, - chip->option.sd20_pad_drive); - if (chip->rts5179) - rts51x_write_register(chip, CARD_PULL_CTL5, 0x03, 0x01); - if (CHECK_PKG(chip, LQFP48)) { - rts51x_write_register(chip, CARD_PULL_CTL3, - 0x80, 0x80); - rts51x_write_register(chip, CARD_PULL_CTL6, - 0xf0, 0xA0); - } else { - rts51x_write_register(chip, CARD_PULL_CTL1, - 0x30, 0x20); - rts51x_write_register(chip, CARD_PULL_CTL3, - 0x80, 0x80); - rts51x_write_register(chip, CARD_PULL_CTL6, - 0x0c, 0x08); - } - } - if (chip->option.sd_ctl & SUPPORT_UHS50_MMC44) { - SET_UHS50(chip); - RTS51X_DEBUGP("option enable UHS50&MMC44,sd_ctl:0x%x\n", - chip->option.sd_ctl); - } else { - /* if(CHECK_PID(chip, 0x0139)&&CHECK_PKG(chip, LQFP48)) */ - if ((CHECK_PID(chip, 0x0139) && CHECK_PKG(chip, LQFP48)) - || chip->rts5179) { - SET_UHS50(chip); - RTS51X_DEBUGP("PID enable UHS50&MMC44\n"); - } else { - CLEAR_UHS50(chip); - RTS51X_DEBUGP("PID disable UHS50&MMC44\n"); - } - } - - if (chip->option.ms_errreg_fix && (chip->ic_version > 1)) - rts51x_write_register(chip, 0xFD4D, 0x01, 0x01); - retval = rts51x_write_phy_register(chip, 0xC2, 0x7C); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - rts51x_init_cmd(chip); - - /* GPIO OE */ - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_GPIO, GPIO_OE, GPIO_OE); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DMA1_CTL, - EXTEND_DMA1_ASYNC_SIGNAL, EXTEND_DMA1_ASYNC_SIGNAL); - - retval = rts51x_send_cmd(chip, MODE_C, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); -#ifdef SUPPORT_OCP - if (chip->asic_code) { - rts51x_write_register(chip, OCPCTL, MS_OCP_DETECT_EN, - MS_OCP_DETECT_EN); - RTS51X_DEBUGP("Enable OCP detect!\n"); - } -#endif - if (chip->option.FT2_fast_mode) { - rts51x_card_power_on(chip, SD_CARD | MS_CARD | XD_CARD); - wait_timeout(10); - } - - return STATUS_SUCCESS; -} - -int rts51x_init_chip(struct rts51x_chip *chip) -{ - int retval; - u8 val; - - chip->max_lun = 0; - chip->cur_clk = 0; - chip->cur_card = 0; - - chip->card2lun[XD_CARD] = 0; - chip->card2lun[SD_CARD] = 0; - chip->card2lun[MS_CARD] = 0; - chip->card_ejected = 0; - - chip->lun2card[0] = XD_CARD | SD_CARD | MS_CARD; -#ifdef CLOSE_SSC_POWER - rts51x_write_register(chip, FPDCTL, SSC_POWER_MASK, SSC_POWER_ON); - udelay(100); - rts51x_write_register(chip, CLK_DIV, CLK_CHANGE, 0x00); -#endif - RTS51X_SET_STAT(chip, STAT_RUN); - - RTS51X_READ_REG(chip, HW_VERSION, &val); - RTS51X_DEBUGP("HW_VERSION: 0x%x\n", val); - if (val & FPGA_VER) { - chip->asic_code = 0; - RTS51X_DEBUGP("FPGA!\n"); - } else { - chip->asic_code = 1; - RTS51X_DEBUGP("ASIC!\n"); - } - chip->ic_version = val & HW_VER_MASK; - - if (!check_sd_speed_prior(chip->option.sd_speed_prior)) - chip->option.sd_speed_prior = 0x01020403; - RTS51X_DEBUGP("sd_speed_prior = 0x%08x\n", - chip->option.sd_speed_prior); - - RTS51X_READ_REG(chip, CARD_SHARE_MODE, &val); - if (val & CARD_SHARE_LQFP_SEL) { - chip->package = LQFP48; - RTS51X_DEBUGP("Package: LQFP48\n"); - } else { - chip->package = QFN24; - RTS51X_DEBUGP("Package: QFN24\n"); - } - - RTS51X_READ_REG(chip, HS_USB_STAT, &val); - if (val & USB_HI_SPEED) { - chip->usb_speed = USB_20; - RTS51X_DEBUGP("USB High Speed\n"); - } else { - chip->usb_speed = USB_11; - RTS51X_DEBUGP("USB Full Speed\n"); - } - - RTS51X_READ_REG(chip, CFG_MODE_1, &val); - if (val & RTS5179) { - chip->rts5179 = 1; - RTS51X_DEBUGP("device is rts5179\n"); - } else { - chip->rts5179 = 0; - } - - retval = rts51x_reset_chip(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - - return STATUS_SUCCESS; -} - -int rts51x_release_chip(struct rts51x_chip *chip) -{ - rts51x_xd_free_l2p_tbl(chip); - rts51x_ms_free_l2p_tbl(chip); - chip->card_ready = 0; - return STATUS_SUCCESS; -} - -static inline void rts51x_blink_led(struct rts51x_chip *chip) -{ - /* Read/Write */ - if (chip->card_ready) { - if (chip->led_toggle_counter < - chip->option.led_toggle_interval) { - chip->led_toggle_counter++; - } else { - chip->led_toggle_counter = 0; - rts51x_toggle_gpio(chip, LED_GPIO); - } - } -} - -static void rts51x_auto_delink_cmd(struct rts51x_chip *chip) -{ - rts51x_write_register(chip, AUTO_DELINK_EN, - AUTO_DELINK, AUTO_DELINK); -} - -static void rts51x_auto_delink_force_cmd(struct rts51x_chip *chip) -{ - rts51x_write_register(chip, AUTO_DELINK_EN, - AUTO_DELINK | FORCE_DELINK, - AUTO_DELINK | FORCE_DELINK); -} - -#ifdef USING_POLLING_CYCLE_DELINK -/* using polling cycle as delink time */ -static void rts51x_auto_delink_polling_cycle(struct rts51x_chip *chip) -{ - if (chip->auto_delink_counter <= - chip->option.delink_delay * 2) { - if (chip->auto_delink_counter == - chip->option.delink_delay) { - if (chip->card_exist) { - /* False card */ - if (!chip->card_ejected) { - /* if card is not ejected or safely - * remove,then do force delink */ - RTS51X_DEBUGP("False card inserted," - "do force delink\n"); - rts51x_auto_delink_force_cmd(chip); - chip->auto_delink_counter = - chip->option.delink_delay * 2 + 1; - } - } else { - RTS51X_DEBUGP("No card inserted, do delink\n"); - /* rts51x_write_register(chip, CARD_PWR_CTL, - DV3318_AUTO_PWR_OFF, 0); */ - rts51x_auto_delink_cmd(chip); - } - } - if (chip->auto_delink_counter == - chip->option.delink_delay * 2) { - RTS51X_DEBUGP("Try to do force delink\n"); - rts51x_auto_delink_force_cmd(chip); - } - chip->auto_delink_counter++; - } -} - -static void rts51x_auto_delink(struct rts51x_chip *chip) -{ - rts51x_auto_delink_polling_cycle(chip); -} -#else -/* some of called funcs are not implemented, so comment it out */ -static void rts51x_auto_delink(struct rts51x_chip *chip) -{ -} -#endif - -void rts51x_polling_func(struct rts51x_chip *chip) -{ - - rts51x_init_cards(chip); - -#ifdef SUPPORT_OCP - /* if OCP happen and card exist, then close card OE */ - if ((chip->ocp_stat & (MS_OCP_NOW | MS_OCP_EVER)) && - (chip->card_exist)) { - - rts51x_prepare_run(chip); - - if (chip->card_exist & SD_CARD) - rts51x_write_register(chip, CARD_OE, SD_OUTPUT_EN, 0); - else if (chip->card_exist & MS_CARD) - rts51x_write_register(chip, CARD_OE, MS_OUTPUT_EN, 0); - else if (chip->card_exist & XD_CARD) - rts51x_write_register(chip, CARD_OE, XD_OUTPUT_EN, 0); - } -#endif - - if (chip->idle_counter < IDLE_MAX_COUNT) { - chip->idle_counter++; - } else { - if (!RTS51X_CHK_STAT(chip, STAT_IDLE)) { - RTS51X_DEBUGP("Idle state!\n"); - RTS51X_SET_STAT(chip, STAT_IDLE); - chip->led_toggle_counter = 0; - /* Idle state, turn off LED - * to reduce power consumption */ - if (chip->option.led_always_on - && (chip->card_exist & - (SD_CARD | MS_CARD | XD_CARD)) - && (!chip->card_ejected)) { - rts51x_turn_on_led(chip, LED_GPIO); - } else { - if (chip->rts5179) { - rts51x_ep0_write_register(chip, - CARD_GPIO, - 0x03, 0x00); - } else { - rts51x_turn_off_led(chip, LED_GPIO); - } - - } - -#ifdef CLOSE_SSC_POWER - if (!chip->card_ready) { - rts51x_write_register(chip, CLK_DIV, CLK_CHANGE, - CLK_CHANGE); - rts51x_write_register(chip, FPDCTL, - SSC_POWER_MASK, - SSC_POWER_DOWN); - RTS51X_DEBUGP("Close SSC clock power!\n"); - } -#endif - } - } - - switch (RTS51X_GET_STAT(chip)) { - case STAT_RUN: - rts51x_blink_led(chip); - rts51x_do_remaining_work(chip); - break; - - case STAT_IDLE: - break; - - default: - break; - } - - if (chip->option.auto_delink_en && !chip->card_ready) - rts51x_auto_delink(chip); - else - chip->auto_delink_counter = 0; -} - -void rts51x_add_cmd(struct rts51x_chip *chip, - u8 cmd_type, u16 reg_addr, u8 mask, u8 data) -{ - int i; - - if (chip->cmd_idx < ((CMD_BUF_LEN - CMD_OFFSET) / 4)) { - i = CMD_OFFSET + chip->cmd_idx * 4; - chip->cmd_buf[i++] = - ((cmd_type & 0x03) << 6) | (u8) ((reg_addr >> 8) & 0x3F); - chip->cmd_buf[i++] = (u8) reg_addr; - chip->cmd_buf[i++] = mask; - chip->cmd_buf[i++] = data; - chip->cmd_idx++; - } -} - -int rts51x_send_cmd(struct rts51x_chip *chip, u8 flag, int timeout) -{ - int result; - - chip->cmd_buf[CNT_H] = (u8) (chip->cmd_idx >> 8); - chip->cmd_buf[CNT_L] = (u8) (chip->cmd_idx); - chip->cmd_buf[STAGE_FLAG] = flag; - - result = rts51x_transfer_data_rcc(chip, SND_BULK_PIPE(chip), - (void *)(chip->cmd_buf), - chip->cmd_idx * 4 + CMD_OFFSET, - 0, NULL, timeout, MODE_C); - if (result != STATUS_SUCCESS) - TRACE_RET(chip, result); - - return STATUS_SUCCESS; -} - -int rts51x_get_rsp(struct rts51x_chip *chip, int rsp_len, int timeout) -{ - int result; - - if (rsp_len <= 0) - TRACE_RET(chip, STATUS_ERROR); - /* rsp_len must aligned to dword */ - if (rsp_len % 4) - rsp_len += (4 - rsp_len % 4); - - result = rts51x_transfer_data_rcc(chip, RCV_BULK_PIPE(chip), - (void *)chip->rsp_buf, rsp_len, - 0, NULL, timeout, STAGE_R); - if (result != STATUS_SUCCESS) - TRACE_RET(chip, result); - - return STATUS_SUCCESS; -} - -int rts51x_get_card_status(struct rts51x_chip *chip, u16 *status) -{ - int retval; - u16 val; - -#ifdef GET_CARD_STATUS_USING_EPC - retval = rts51x_get_epc_status(chip, &val); - - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); -#else - retval = rts51x_ctrl_transfer(chip, RCV_CTRL_PIPE(chip), 0x02, 0xC0, - 0, 0, &val, 2, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); -#endif - - if (status) - *status = val; - - return STATUS_SUCCESS; -} - -int rts51x_write_register(struct rts51x_chip *chip, u16 addr, u8 mask, u8 data) -{ - int retval; - - rts51x_init_cmd(chip); - rts51x_add_cmd(chip, WRITE_REG_CMD, addr, mask, data); - retval = rts51x_send_cmd(chip, MODE_C, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - - return STATUS_SUCCESS; -} - -int rts51x_read_register(struct rts51x_chip *chip, u16 addr, u8 *data) -{ - int retval; - - if (data) - *data = 0; - rts51x_init_cmd(chip); - rts51x_add_cmd(chip, READ_REG_CMD, addr, 0, 0); - retval = rts51x_send_cmd(chip, MODE_CR, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - - retval = rts51x_get_rsp(chip, 1, 100); - - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - - if (data) - *data = chip->rsp_buf[0]; - - return STATUS_SUCCESS; -} - -int rts51x_ep0_write_register(struct rts51x_chip *chip, u16 addr, u8 mask, - u8 data) -{ - int retval; - u16 value = 0, index = 0; - - value |= (u16) (3 & 0x03) << 14; - value |= (u16) (addr & 0x3FFF); - index |= (u16) mask << 8; - index |= (u16) data; - - retval = rts51x_ctrl_transfer(chip, SND_CTRL_PIPE(chip), 0x00, 0x40, - cpu_to_be16(value), cpu_to_be16(index), - NULL, 0, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - return STATUS_SUCCESS; -} - -int rts51x_ep0_read_register(struct rts51x_chip *chip, u16 addr, u8 *data) -{ - int retval; - u16 value = 0; - u8 val; - - if (data) - *data = 0; - - value |= (u16) (2 & 0x03) << 14; - value |= (u16) (addr & 0x3FFF); - - retval = rts51x_ctrl_transfer(chip, RCV_CTRL_PIPE(chip), 0x00, 0xC0, - cpu_to_be16(value), 0, &val, 1, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (data) - *data = val; - - return STATUS_SUCCESS; -} - -int rts51x_seq_write_register(struct rts51x_chip *chip, u16 addr, u16 len, - u8 *data) -{ - int result; - u16 cmd_len = len + 12; - - if (!data) - TRACE_RET(chip, STATUS_ERROR); - - cmd_len = (cmd_len <= CMD_BUF_LEN) ? cmd_len : CMD_BUF_LEN; - - /* cmd_len must aligned to dword */ - if (cmd_len % 4) - cmd_len += (4 - cmd_len % 4); - - chip->cmd_buf[0] = 'R'; - chip->cmd_buf[1] = 'T'; - chip->cmd_buf[2] = 'C'; - chip->cmd_buf[3] = 'R'; - chip->cmd_buf[PACKET_TYPE] = SEQ_WRITE; - chip->cmd_buf[5] = (u8) (len >> 8); - chip->cmd_buf[6] = (u8) len; - chip->cmd_buf[STAGE_FLAG] = 0; - chip->cmd_buf[8] = (u8) (addr >> 8); - chip->cmd_buf[9] = (u8) addr; - - memcpy(chip->cmd_buf + 12, data, len); - - result = rts51x_transfer_data_rcc(chip, SND_BULK_PIPE(chip), - (void *)(chip->cmd_buf), cmd_len, 0, - NULL, 100, MODE_C); - if (result != STATUS_SUCCESS) - TRACE_RET(chip, result); - - return STATUS_SUCCESS; -} - -int rts51x_seq_read_register(struct rts51x_chip *chip, u16 addr, u16 len, - u8 *data) -{ - int result; - u16 rsp_len; - - if (!data) - TRACE_RET(chip, STATUS_ERROR); - /* rsp_len must aligned to dword */ - if (len % 4) - rsp_len = len + (4 - len % 4); - else - rsp_len = len; - - chip->cmd_buf[0] = 'R'; - chip->cmd_buf[1] = 'T'; - chip->cmd_buf[2] = 'C'; - chip->cmd_buf[3] = 'R'; - chip->cmd_buf[PACKET_TYPE] = SEQ_READ; - chip->cmd_buf[5] = (u8) (rsp_len >> 8); - chip->cmd_buf[6] = (u8) rsp_len; - chip->cmd_buf[STAGE_FLAG] = STAGE_R; - chip->cmd_buf[8] = (u8) (addr >> 8); - chip->cmd_buf[9] = (u8) addr; - - result = rts51x_transfer_data_rcc(chip, SND_BULK_PIPE(chip), - (void *)(chip->cmd_buf), 12, 0, NULL, - 100, MODE_C); - if (result != STATUS_SUCCESS) - TRACE_RET(chip, result); - - result = rts51x_transfer_data_rcc(chip, RCV_BULK_PIPE(chip), - (void *)data, rsp_len, 0, NULL, 100, - STAGE_DI); - if (result != STATUS_SUCCESS) - TRACE_RET(chip, result); - - return STATUS_SUCCESS; -} - -int rts51x_read_ppbuf(struct rts51x_chip *chip, u8 *buf, int buf_len) -{ - int retval; - - if (!buf) - TRACE_RET(chip, STATUS_ERROR); - - retval = - rts51x_seq_read_register(chip, PPBUF_BASE2, (u16) buf_len, buf); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - return STATUS_SUCCESS; -} - -int rts51x_write_ppbuf(struct rts51x_chip *chip, u8 *buf, int buf_len) -{ - int retval; - - if (!buf) - TRACE_RET(chip, STATUS_ERROR); - - retval = - rts51x_seq_write_register(chip, PPBUF_BASE2, (u16) buf_len, buf); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - return STATUS_SUCCESS; -} - -int rts51x_write_phy_register(struct rts51x_chip *chip, u8 addr, u8 val) -{ - int retval; - - RTS51X_DEBUGP("Write 0x%x to phy register 0x%x\n", val, addr); - - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VSTAIN, 0xFF, val); - rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VCONTROL, 0xFF, addr & 0x0F); - rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x00); - rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x00); - rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x01); - rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VCONTROL, 0xFF, - (addr >> 4) & 0x0F); - rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x00); - rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x00); - rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x01); - - retval = rts51x_send_cmd(chip, MODE_C, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - return STATUS_SUCCESS; -} - -int rts51x_read_phy_register(struct rts51x_chip *chip, u8 addr, u8 *val) -{ - int retval; - - RTS51X_DEBUGP("Read from phy register 0x%x\n", addr); - - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VCONTROL, 0xFF, 0x07); - rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x00); - rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x00); - rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x01); - rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VCONTROL, 0xFF, - (addr >> 4) & 0x0F); - rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x00); - rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x00); - rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x01); - rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VCONTROL, 0xFF, addr & 0x0F); - rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x00); - rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x00); - rts51x_add_cmd(chip, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x01); - rts51x_add_cmd(chip, READ_REG_CMD, HS_VSTAOUT, 0, 0); - - retval = rts51x_send_cmd(chip, MODE_CR, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = rts51x_get_rsp(chip, 1, 100); - - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (val) - *val = chip->rsp_buf[0]; - - RTS51X_DEBUGP("Return value: 0x%x\n", chip->rsp_buf[0]); - - return STATUS_SUCCESS; -} - -void rts51x_do_before_power_down(struct rts51x_chip *chip) -{ - RTS51X_DEBUGP("rts51x_do_before_power_down\n"); - - rts51x_prepare_run(chip); - - rts51x_release_cards(chip); - if (chip->rts5179) - rts51x_ep0_write_register(chip, CARD_GPIO, 0x03, 0x00); - else - rts51x_turn_off_led(chip, LED_GPIO); - - chip->cur_clk = 0; - chip->card_exist = 0; - chip->cur_card = 0; - if (chip->asic_code) { - if (CHECK_PKG(chip, LQFP48)) { - rts51x_write_register(chip, CARD_PULL_CTL3, 0x80, 0x00); - rts51x_write_register(chip, CARD_PULL_CTL6, 0xf0, 0x50); - } else { - rts51x_write_register(chip, CARD_PULL_CTL1, 0x30, 0x10); - rts51x_write_register(chip, CARD_PULL_CTL3, 0x80, 0x00); - rts51x_write_register(chip, CARD_PULL_CTL6, 0x0c, 0x04); - } - } - if (CHECK_PKG(chip, LQFP48)) - rts51x_write_register(chip, CARD_PWR_CTL, LDO3318_PWR_MASK, - LDO_OFF); -} - -void rts51x_clear_hw_error(struct rts51x_chip *chip) -{ - rts51x_ep0_write_register(chip, SFSM_ED, 0xf8, 0xf8); -} - -void rts51x_prepare_run(struct rts51x_chip *chip) -{ -#ifdef CLOSE_SSC_POWER - if (RTS51X_CHK_STAT(chip, STAT_IDLE) && (!chip->card_ready)) { - rts51x_write_register(chip, FPDCTL, SSC_POWER_MASK, - SSC_POWER_ON); - udelay(100); - RTS51X_DEBUGP("Open SSC clock power.\n"); - - rts51x_write_register(chip, CLK_DIV, CLK_CHANGE, 0x00); - } -#endif -} - -#ifdef _MSG_TRACE -void rts51x_trace_msg(struct rts51x_chip *chip, unsigned char *buf, int clear) -{ - unsigned char *ptr; - int i, msg_cnt; - - if (!buf) - return; - - ptr = buf; - - if (chip->trace_msg[chip->msg_idx].valid) - msg_cnt = TRACE_ITEM_CNT; - else - msg_cnt = chip->msg_idx; - *(ptr++) = (u8) (msg_cnt >> 24); - *(ptr++) = (u8) (msg_cnt >> 16); - *(ptr++) = (u8) (msg_cnt >> 8); - *(ptr++) = (u8) msg_cnt; - RTS51X_DEBUGP("Trace message count is %d\n", msg_cnt); - - for (i = 1; i <= msg_cnt; i++) { - int j, idx; - - idx = chip->msg_idx - i; - if (idx < 0) - idx += TRACE_ITEM_CNT; - - *(ptr++) = (u8) (chip->trace_msg[idx].line >> 8); - *(ptr++) = (u8) (chip->trace_msg[idx].line); - for (j = 0; j < MSG_FUNC_LEN; j++) - *(ptr++) = chip->trace_msg[idx].func[j]; - for (j = 0; j < MSG_FILE_LEN; j++) - *(ptr++) = chip->trace_msg[idx].file[j]; - for (j = 0; j < TIME_VAL_LEN; j++) - *(ptr++) = chip->trace_msg[idx].timeval_buf[j]; - } - - if (clear) { - chip->msg_idx = 0; - for (i = 0; i < TRACE_ITEM_CNT; i++) - chip->trace_msg[i].valid = 0; - } -} -#endif - -void rts51x_pp_status(struct rts51x_chip *chip, unsigned int lun, u8 *status, - u8 status_len) -{ - struct sd_info *sd_card = &(chip->sd_card); - struct ms_info *ms_card = &(chip->ms_card); - u8 card = rts51x_get_lun_card(chip, lun); -#ifdef SUPPORT_OC - u8 oc_now_mask = 0, oc_ever_mask = 0; -#endif - - if (!status || (status_len < 32)) - return; - /* IC Version */ - status[0] = (u8) RTS51X_GET_PID(chip); - status[1] = (u8) (chip->ic_version); - - /* Auto delink mode */ - if (chip->option.auto_delink_en) - status[2] = 0x10; - else - status[2] = 0x00; - - /* Spec version */ - status[3] = 20; - status[4] = 10; - status[5] = 05; - status[6] = 21; - - /* Card WP */ - if (chip->card_wp) - status[7] = 0x20; - else - status[7] = 0x00; - -#ifdef SUPPORT_OC - /* Over current status */ - status[8] = 0; - oc_now_mask = MS_OCP_NOW; - oc_ever_mask = MS_OCP_EVER; - - if (chip->ocp_stat & oc_now_mask) - status[8] |= 0x02; - if (chip->ocp_stat & oc_ever_mask) - status[8] |= 0x01; -#endif - - if (card == SD_CARD) { - if (CHK_SD(sd_card)) { - if (CHK_SD_HCXC(sd_card)) { - if (sd_card->capacity > 0x4000000) - /* SDXC */ - status[0x0E] = 0x02; - else /* SDHC */ - status[0x0E] = 0x01; - } else { /* SDSC */ - status[0x0E] = 0x00; - } - - if (CHK_SD_SDR104(sd_card)) - status[0x0F] = 0x03; - else if (CHK_SD_DDR50(sd_card)) - status[0x0F] = 0x04; - else if (CHK_SD_SDR50(sd_card)) - status[0x0F] = 0x02; - else if (CHK_SD_HS(sd_card)) - status[0x0F] = 0x01; - else - status[0x0F] = 0x00; /* Normal speed */ - } else { - if (CHK_MMC_SECTOR_MODE(sd_card)) - status[0x0E] = 0x01; /* High capacity */ - else - status[0x0E] = 0x00; /* Normal capacity */ - - if (CHK_MMC_DDR52(sd_card)) - status[0x0F] = 0x03; /* DDR 52M */ - else if (CHK_MMC_52M(sd_card)) - status[0x0F] = 0x02; /* SDR 52M */ - else if (CHK_MMC_26M(sd_card)) - status[0x0F] = 0x01; /* SDR 26M */ - else - status[0x0F] = 0x00; /* Normal speed */ - } - } else if (card == MS_CARD) { - if (CHK_MSPRO(ms_card)) { - if (CHK_MSXC(ms_card)) - status[0x0E] = 0x01; /* XC */ - else - status[0x0E] = 0x00; - - if (CHK_HG8BIT(ms_card)) - status[0x0F] = 0x01; - else - status[0x0F] = 0x00; - } - } - - /* Function 0 - * Support Magic Gate, CPRM and PhyRegister R/W */ - status[0x18] = 0x8A; - - /* Function 2 - * Support OC LUN status & WP LUN status */ - status[0x1A] = 0x28; - - /* Function 2 - * Support OC LUN status & WP LUN status */ - status[0x1A] = 0x28; -} - -void rts51x_read_status(struct rts51x_chip *chip, unsigned int lun, - u8 *rts51x_status, u8 status_len) -{ - if (!rts51x_status || (status_len < 16)) - return; - /* VID */ - rts51x_status[0] = (u8) (RTS51X_GET_VID(chip) >> 8); - rts51x_status[1] = (u8) RTS51X_GET_VID(chip); - - /* PID */ - rts51x_status[2] = (u8) (RTS51X_GET_PID(chip) >> 8); - rts51x_status[3] = (u8) RTS51X_GET_PID(chip); - - /* gbLUN */ - rts51x_status[4] = (u8) lun; - - /* Lun Card Number */ - if (chip->card_exist) { - if (chip->card_exist & XD_CARD) - rts51x_status[5] = 4; /* xD Card */ - else if (chip->card_exist & SD_CARD) - rts51x_status[5] = 2; /* SD Card */ - else if (chip->card_exist & MS_CARD) - rts51x_status[5] = 3; /* MS Card */ - else - rts51x_status[5] = 7; /* Multi */ - } else { - rts51x_status[5] = 7; /* Multi */ - } - - /* Total LUNs */ - rts51x_status[6] = 1; - - /* IC Version */ - rts51x_status[7] = (u8) RTS51X_GET_PID(chip); - rts51x_status[8] = chip->ic_version; - - /* Physical Exist */ - if (check_card_exist(chip, lun)) - rts51x_status[9] = 1; - else - rts51x_status[9] = 0; - - /* Multi Flag */ - rts51x_status[10] = 1; - - /* LUN Valid Map */ - rts51x_status[11] = XD_CARD | SD_CARD | MS_CARD; - - /* Logical Exist */ - if (check_card_ready(chip, lun)) - rts51x_status[12] = 1; - else - rts51x_status[12] = 0; - - /* Detailed Type */ - if (rts51x_get_lun_card(chip, lun) == XD_CARD) { - rts51x_status[13] = 0x40; - } else if (rts51x_get_lun_card(chip, lun) == SD_CARD) { - struct sd_info *sd_card = &(chip->sd_card); - - rts51x_status[13] = 0x20; - if (CHK_SD(sd_card)) { - if (CHK_SD_HCXC(sd_card)) - rts51x_status[13] |= 0x04; /* Hi capacity SD */ - if (CHK_SD_HS(sd_card)) - rts51x_status[13] |= 0x02; /* Hi speed SD */ - } else { - rts51x_status[13] |= 0x08; /* MMC card */ - if (CHK_MMC_52M(sd_card)) - rts51x_status[13] |= 0x02; /* Hi speed */ - if (CHK_MMC_SECTOR_MODE(sd_card)) - rts51x_status[13] |= 0x04; /* Hi capacity */ - } - } else if (rts51x_get_lun_card(chip, lun) == MS_CARD) { - struct ms_info *ms_card = &(chip->ms_card); - - if (CHK_MSPRO(ms_card)) { - rts51x_status[13] = 0x38; /* MS Pro */ - if (CHK_HG8BIT(ms_card)) - rts51x_status[13] |= 0x04; /* HG */ -#ifdef SUPPORT_MSXC - if (CHK_MSXC(ms_card)) - rts51x_status[13] |= 0x01; /* MSXC */ -#endif - } else { - rts51x_status[13] = 0x30; - } - } else { - rts51x_status[13] = 0x70; - } -/* Support OC, auto delink, vendor r/w, get bus width */ - rts51x_status[14] = 0x78; - - rts51x_status[15] = 0x82; -} - -int rts51x_transfer_data_rcc(struct rts51x_chip *chip, unsigned int pipe, - void *buf, unsigned int len, int use_sg, - unsigned int *act_len, int timeout, u8 stage_flag) -{ - int retval; - - retval = - rts51x_transfer_data(chip, pipe, buf, len, use_sg, act_len, - timeout); - - return retval; - -} diff --git a/drivers/staging/rts5139/rts51x_chip.h b/drivers/staging/rts5139/rts51x_chip.h deleted file mode 100644 index 12deb24cfbbe..000000000000 --- a/drivers/staging/rts5139/rts51x_chip.h +++ /dev/null @@ -1,821 +0,0 @@ -/* Driver for Realtek RTS51xx USB card reader - * Header file - * - * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. - * - * 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, 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, see . - * - * Author: - * wwang (wei_wang@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - * Maintainer: - * Edwin Rong (edwin_rong@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - */ - -#ifndef __RTS51X_CHIP_H -#define __RTS51X_CHIP_H - -#include -#include -#include -#include -#include -#include - -#include "trace.h" - -#define SUPPORT_CPRM -#define SUPPORT_MAGIC_GATE -#define SUPPORT_MSXC -#define USING_POLLING_CYCLE_DELINK - -#ifdef SUPPORT_MAGIC_GA -/* Using NORMAL_WRITE instead of AUTO_WRITE to set ICVTE */ -#define MG_SET_ICV_SLOW -#endif - -#ifdef SUPPORT_MSXC -#define XC_POWERCLASS -#define SUPPORT_PCGL_1P18 -#endif - -#define GET_CARD_STATUS_USING_EPC - -#define CLOSE_SSC_POWER - -#define SUPPORT_OCP - -#define MS_SPEEDUP - -#define SD_XD_IO_FOLLOW_PWR - -#define SD_NR 2 -#define MS_NR 3 -#define XD_NR 4 -#define SD_CARD (1 << SD_NR) -#define MS_CARD (1 << MS_NR) -#define XD_CARD (1 << XD_NR) - -#define SD_CD 0x01 -#define MS_CD 0x02 -#define XD_CD 0x04 -#define SD_WP 0x08 - -#define MAX_ALLOWED_LUN_CNT 8 -#define CMD_BUF_LEN 1024 -#define POLLING_INTERVAL 50 /* 50ms */ - -#define XD_FREE_TABLE_CNT 1200 -#define MS_FREE_TABLE_CNT 512 - -/* Bit Operation */ -#define SET_BIT(data, idx) ((data) |= 1 << (idx)) -#define CLR_BIT(data, idx) ((data) &= ~(1 << (idx))) -#define CHK_BIT(data, idx) ((data) & (1 << (idx))) - -/* Command type */ -#define READ_REG_CMD 0 -#define WRITE_REG_CMD 1 -#define CHECK_REG_CMD 2 - -#define PACKET_TYPE 4 -#define CNT_H 5 -#define CNT_L 6 -#define STAGE_FLAG 7 -#define CMD_OFFSET 8 - -/* Packet type */ -#define BATCH_CMD 0 -#define SEQ_READ 1 -#define SEQ_WRITE 2 - -/* Stage flag */ -#define STAGE_R 0x01 -#define STAGE_DI 0x02 -#define STAGE_DO 0x04 -/* Return MS_TRANS_CFG, GET_INT */ -#define STAGE_MS_STATUS 0x08 -/* Return XD_CFG, XD_CTL, XD_PAGE_STATUS */ -#define STAGE_XD_STATUS 0x10 -/* Command stage mode */ -#define MODE_C 0x00 -#define MODE_CR (STAGE_R) -#define MODE_CDIR (STAGE_R | STAGE_DI) -#define MODE_CDOR (STAGE_R | STAGE_DO) - -/* Function return code */ -#ifndef STATUS_SUCCESS -#define STATUS_SUCCESS 0 -#endif - -#define STATUS_FAIL 1 -#define STATUS_TIMEDOUT 4 -#define STATUS_NOMEM 5 -#define STATUS_TRANS_SHORT 6 -#define STATUS_TRANS_LONG 7 -#define STATUS_STALLED 8 -#define STATUS_ERROR 10 - -#define IDLE_MAX_COUNT 10 -#define POLLING_WAIT_CNT 1 -#define LED_GPIO 0 - -/* package */ -#define QFN24 0 -#define LQFP48 1 - -#define USB_11 0 -#define USB_20 1 - -/* - * Transport return codes - */ -/* Transport good, command good */ -#define TRANSPORT_GOOD 0 -/* Transport good, command failed */ -#define TRANSPORT_FAILED 1 -/* Transport bad (i.e. device dead) */ -#define TRANSPORT_ERROR 3 - -/* Supported Clock */ -enum card_clock { CLK_20 = 1, CLK_30, CLK_40, CLK_50, CLK_60, CLK_80, CLK_100 }; - -#ifdef _MSG_TRACE - -#define TRACE_ITEM_CNT 64 - -struct trace_msg_t { - u16 line; -#define MSG_FUNC_LEN 64 - char func[MSG_FUNC_LEN]; -#define MSG_FILE_LEN 32 - char file[MSG_FILE_LEN]; -#define TIME_VAL_LEN 16 - u8 timeval_buf[TIME_VAL_LEN]; - u8 valid; -}; - -#endif /* _MSG_TRACE */ - -/* Size of the autosense data buffer */ -#define SENSE_SIZE 18 - -/* Sense type */ -#define SENSE_TYPE_NO_SENSE 0 -#define SENSE_TYPE_MEDIA_CHANGE 1 -#define SENSE_TYPE_MEDIA_NOT_PRESENT 2 -#define SENSE_TYPE_MEDIA_LBA_OVER_RANGE 3 -#define SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT 4 -#define SENSE_TYPE_MEDIA_WRITE_PROTECT 5 -#define SENSE_TYPE_MEDIA_INVALID_CMD_FIELD 6 -#define SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR 7 -#define SENSE_TYPE_MEDIA_WRITE_ERR 8 -#define SENSE_TYPE_FORMAT_CMD_FAILED 10 -#ifdef SUPPORT_MAGIC_GATE -/* COPY PROTECTION KEY EXCHANGE FAILURE - KEY NOT ESTABLISHED */ -#define SENSE_TYPE_MG_KEY_FAIL_NOT_ESTAB 0x0b -/* COPY PROTECTION KEY EXCHANGE FAILURE - AUTHENTICATION FAILURE */ -#define SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN 0x0c -/* INCOMPATIBLE MEDIUM INSTALLED */ -#define SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM 0x0d -/* WRITE ERROR */ -#define SENSE_TYPE_MG_WRITE_ERR 0x0e -#endif - -/*---- sense key ----*/ -#define ILGAL_REQ 0x05 /* CDB/parameter/identify msg error */ - -/*----------------------------------- - SENSE_DATA ------------------------------------*/ - -/*---- error code ----*/ -#define CUR_ERR 0x70 /* current error */ - -/*---- sense key Information ----*/ - -#define SKSV 0x80 -#define CDB_ILLEGAL 0x40 - -/*---- ASC ----*/ -#define ASC_INVLD_CDB 0x24 - -/*---- ASQC ----*/ -#define ASCQ_INVLD_CDB 0x00 - -struct sense_data_t { - unsigned char err_code; /* error code */ - /* bit7 : valid */ - /* (1 : SCSI2) */ - /* (0 : Vendor specific) */ - /* bit6-0 : error code */ - /* (0x70 : current error) */ - /* (0x71 : specific command error) */ - unsigned char seg_no; /* segment No. */ - unsigned char sense_key; /* byte5 : ILI */ - /* bit3-0 : sense key */ - unsigned char info[4]; /* information */ - unsigned char ad_sense_len; /* additional sense data length */ - unsigned char cmd_info[4]; /* command specific information */ - unsigned char asc; /* ASC */ - unsigned char ascq; /* ASCQ */ - unsigned char rfu; /* FRU */ - unsigned char sns_key_info[3]; /* sense key specific information */ -}; - -/* sd_ctl bit map */ -/* SD push point control, bit 0, 1 */ -#define SD_PUSH_POINT_CTL_MASK 0x03 -#define SD_PUSH_POINT_DELAY 0x01 -#define SD_PUSH_POINT_AUTO 0x02 -/* SD sample point control, bit 2, 3 */ -#define SD_SAMPLE_POINT_CTL_MASK 0x0C -#define SD_SAMPLE_POINT_DELAY 0x04 -#define SD_SAMPLE_POINT_AUTO 0x08 -/* SD DDR Tx phase set by user, bit 4 */ -#define SD_DDR_TX_PHASE_SET_BY_USER 0x10 -/* MMC DDR Tx phase set by user, bit 5 */ -#define MMC_DDR_TX_PHASE_SET_BY_USER 0x20 -/* Support MMC DDR mode, bit 6 */ -/*#define SUPPORT_MMC_DDR_MODE 0x40 */ -#define SUPPORT_UHS50_MMC44 0x40 - -struct rts51x_option { - int rts51x_mspro_formatter_enable; - - /* card clock expected by user for fpga platform */ - int fpga_sd_sdr104_clk; - int fpga_sd_ddr50_clk; - int fpga_sd_sdr50_clk; - int fpga_sd_hs_clk; - int fpga_mmc_52m_clk; - int fpga_ms_hg_clk; - int fpga_ms_4bit_clk; - - /* card clock expected by user for asic platform */ - int asic_sd_sdr104_clk; - int asic_sd_ddr50_clk; - int asic_sd_sdr50_clk; - int asic_sd_hs_clk; - int asic_mmc_52m_clk; - int asic_ms_hg_clk; - int asic_ms_4bit_clk; - - u8 ssc_depth_sd_sdr104; /* sw */ - u8 ssc_depth_sd_ddr50; /* sw */ - u8 ssc_depth_sd_sdr50; /* sw */ - u8 ssc_depth_sd_hs; /* sw */ - u8 ssc_depth_mmc_52m; /* sw */ - u8 ssc_depth_ms_hg; /* sw */ - u8 ssc_depth_ms_4bit; /* sw */ - u8 ssc_depth_low_speed; /* sw */ - - /* SD/MMC Tx phase */ - int sd_ddr_tx_phase; /* Enabled by bit 4 of sd_ctl */ - int mmc_ddr_tx_phase; /* Enabled by bit 5 of sd_ctl */ - - /* priority of choosing sd speed funciton */ - u32 sd_speed_prior; - - /* sd card control */ - u32 sd_ctl; - - /* Enable Selective Suspend */ - int ss_en; - /* Interval to enter SS from IDLE state (second) */ - int ss_delay; - - /* Enable SSC clock */ - int ssc_en; - - int auto_delink_en; - - /* sangdy2010-07-13:add FT2 fast mode */ - int FT2_fast_mode; - /* sangdy2010-07-15: - * add for config delay between 1/4 PMOS and 3/4 PMOS */ - int pwr_delay; - - int rts51x_xd_rw_step; /* add to tune xd tRP */ - int D3318_off_delay; /* add to tune D3318 off delay time */ - int delink_delay; /* add to tune delink delay time */ - /* add for rts5129 to enable/disable D3318 off */ - u8 rts5129_D3318_off_enable; - u8 sd20_pad_drive; /* add to config SD20 PAD drive */ - u8 sd30_pad_drive; /* add to config SD30 pad drive */ - /*if reset or rw fail,then set SD20 pad drive again */ - u8 reset_or_rw_fail_set_pad_drive; - - u8 debounce_num; /* debounce number */ - u8 led_toggle_interval; /* used to control led toggle speed */ - int rts51x_xd_rwn_step; - u8 sd_send_status_en; - /* used to store default phase which is - * used when phase tune all pass. */ - u8 ddr50_tx_phase; - u8 ddr50_rx_phase; - u8 sdr50_tx_phase; - u8 sdr50_rx_phase; - /* used to enable select sdr50 tx phase according to proportion. */ - u8 sdr50_phase_sel; - u8 ms_errreg_fix; - u8 reset_mmc_first; - u8 speed_mmc; /* when set, then try CMD55 only twice */ - u8 led_always_on; /* if set, then led always on when card exist */ - u8 dv18_voltage; /* add to tune dv18 voltage */ -}; - -#define MS_FORMATTER_ENABLED(chip) ((chip)->option.rts51x_mspro_formatter_enable) - -struct rts51x_chip; - -typedef int (*rts51x_card_rw_func) (struct scsi_cmnd *srb, struct rts51x_chip *chip, - u32 sec_addr, u16 sec_cnt); - -/* For MS Card */ -#define MAX_DEFECTIVE_BLOCK 10 - -struct zone_entry { - u16 *l2p_table; - u16 *free_table; - u16 defect_list[MAX_DEFECTIVE_BLOCK]; /* For MS card only */ - int set_index; - int get_index; - int unused_blk_cnt; - int disable_count; - /* To indicate whether the L2P table of this zone has been built. */ - int build_flag; -}; - -struct xd_delay_write_tag { - u32 old_phyblock; - u32 new_phyblock; - u32 logblock; - u8 pageoff; - u8 delay_write_flag; -}; - -struct xd_info { - u8 maker_code; - u8 device_code; - u8 block_shift; - u8 page_off; - u8 addr_cycle; - u16 cis_block; - u8 multi_flag; - u8 err_code; - u32 capacity; - - struct zone_entry *zone; - int zone_cnt; - - struct xd_delay_write_tag delay_write; - - int counter; - - int xd_clock; -}; - -#define TYPE_SD 0x0000 -#define TYPE_MMC 0x0001 - -/* TYPE_SD */ -#define SD_HS 0x0100 -#define SD_SDR50 0x0200 -#define SD_DDR50 0x0400 -#define SD_SDR104 0x0800 -#define SD_HCXC 0x1000 - -/* TYPE_MMC */ -#define MMC_26M 0x0100 -#define MMC_52M 0x0200 -#define MMC_4BIT 0x0400 -#define MMC_8BIT 0x0800 -#define MMC_SECTOR_MODE 0x1000 -#define MMC_DDR52 0x2000 - -/* SD card */ -#define CHK_SD(sd_card) (((sd_card)->sd_type & 0xFF) == TYPE_SD) -#define CHK_SD_HS(sd_card) \ - (CHK_SD(sd_card) && ((sd_card)->sd_type & SD_HS)) -#define CHK_SD_SDR50(sd_card) \ - (CHK_SD(sd_card) && ((sd_card)->sd_type & SD_SDR50)) -#define CHK_SD_DDR50(sd_card) \ - (CHK_SD(sd_card) && ((sd_card)->sd_type & SD_DDR50)) -#define CHK_SD_SDR104(sd_card) \ - (CHK_SD(sd_card) && ((sd_card)->sd_type & SD_SDR104)) -#define CHK_SD_HCXC(sd_card) \ - (CHK_SD(sd_card) && ((sd_card)->sd_type & SD_HCXC)) -#define CHK_SD30_SPEED(sd_card) \ - (CHK_SD_SDR50(sd_card) || CHK_SD_DDR50(sd_card) ||\ - CHK_SD_SDR104(sd_card)) - -#define SET_SD(sd_card) ((sd_card)->sd_type = TYPE_SD) -#define SET_SD_HS(sd_card) ((sd_card)->sd_type |= SD_HS) -#define SET_SD_SDR50(sd_card) ((sd_card)->sd_type |= SD_SDR50) -#define SET_SD_DDR50(sd_card) ((sd_card)->sd_type |= SD_DDR50) -#define SET_SD_SDR104(sd_card) ((sd_card)->sd_type |= SD_SDR104) -#define SET_SD_HCXC(sd_card) ((sd_card)->sd_type |= SD_HCXC) - -#define CLR_SD_HS(sd_card) ((sd_card)->sd_type &= ~SD_HS) -#define CLR_SD_SDR50(sd_card) ((sd_card)->sd_type &= ~SD_SDR50) -#define CLR_SD_DDR50(sd_card) ((sd_card)->sd_type &= ~SD_DDR50) -#define CLR_SD_SDR104(sd_card) ((sd_card)->sd_type &= ~SD_SDR104) -#define CLR_SD_HCXC(sd_card) ((sd_card)->sd_type &= ~SD_HCXC) -#define CLR_SD30_SPEED(sd_card) \ - ((sd_card)->sd_type &= ~(SD_SDR50|SD_DDR50|SD_SDR104)) - -/* MMC card */ -#define CHK_MMC(sd_card) \ - (((sd_card)->sd_type & 0xFF) == TYPE_MMC) -#define CHK_MMC_26M(sd_card) \ - (CHK_MMC(sd_card) && ((sd_card)->sd_type & MMC_26M)) -#define CHK_MMC_52M(sd_card) \ - (CHK_MMC(sd_card) && ((sd_card)->sd_type & MMC_52M)) -#define CHK_MMC_4BIT(sd_card) \ - (CHK_MMC(sd_card) && ((sd_card)->sd_type & MMC_4BIT)) -#define CHK_MMC_8BIT(sd_card) \ - (CHK_MMC(sd_card) && ((sd_card)->sd_type & MMC_8BIT)) -#define CHK_MMC_SECTOR_MODE(sd_card)\ - (CHK_MMC(sd_card) && ((sd_card)->sd_type & MMC_SECTOR_MODE)) -#define CHK_MMC_DDR52(sd_card) \ - (CHK_MMC(sd_card) && ((sd_card)->sd_type & MMC_DDR52)) - -#define SET_MMC(sd_card) ((sd_card)->sd_type = TYPE_MMC) -#define SET_MMC_26M(sd_card) ((sd_card)->sd_type |= MMC_26M) -#define SET_MMC_52M(sd_card) ((sd_card)->sd_type |= MMC_52M) -#define SET_MMC_4BIT(sd_card) ((sd_card)->sd_type |= MMC_4BIT) -#define SET_MMC_8BIT(sd_card) ((sd_card)->sd_type |= MMC_8BIT) -#define SET_MMC_SECTOR_MODE(sd_card) ((sd_card)->sd_type |= MMC_SECTOR_MODE) -#define SET_MMC_DDR52(sd_card) ((sd_card)->sd_type |= MMC_DDR52) - -#define CLR_MMC_26M(sd_card) ((sd_card)->sd_type &= ~MMC_26M) -#define CLR_MMC_52M(sd_card) ((sd_card)->sd_type &= ~MMC_52M) -#define CLR_MMC_4BIT(sd_card) ((sd_card)->sd_type &= ~MMC_4BIT) -#define CLR_MMC_8BIT(sd_card) ((sd_card)->sd_type &= ~MMC_8BIT) -#define CLR_MMC_SECTOR_MODE(sd_card) ((sd_card)->sd_type &= ~MMC_SECTOR_MODE) -#define CLR_MMC_DDR52(sd_card) ((sd_card)->sd_type &= ~MMC_DDR52) - -#define CHK_MMC_HS(sd_card) \ - (CHK_MMC_52M(sd_card) && CHK_MMC_26M(sd_card)) -#define CLR_MMC_HS(sd_card) \ -do { \ - CLR_MMC_DDR52(sd_card); \ - CLR_MMC_52M(sd_card); \ - CLR_MMC_26M(sd_card); \ -} while (0) - -#define SD_SUPPORT_CLASS_TEN 0x01 -#define SD_SUPPORT_1V8 0x02 - -#define SD_SET_CLASS_TEN(sd_card) \ - ((sd_card)->sd_setting |= SD_SUPPORT_CLASS_TEN) -#define SD_CHK_CLASS_TEN(sd_card) \ - ((sd_card)->sd_setting & SD_SUPPORT_CLASS_TEN) -#define SD_CLR_CLASS_TEN(sd_card) \ - ((sd_card)->sd_setting &= ~SD_SUPPORT_CLASS_TEN) -#define SD_SET_1V8(sd_card) \ - ((sd_card)->sd_setting |= SD_SUPPORT_1V8) -#define SD_CHK_1V8(sd_card) \ - ((sd_card)->sd_setting & SD_SUPPORT_1V8) -#define SD_CLR_1V8(sd_card) \ - ((sd_card)->sd_setting &= ~SD_SUPPORT_1V8) -#define CLR_RETRY_SD20_MODE(sd_card) \ - ((sd_card)->retry_SD20_mode = 0) -#define SET_RETRY_SD20_MODE(sd_card) \ - ((sd_card)->retry_SD20_mode = 1) -#define CHK_RETRY_SD20_MODE(sd_card) \ - ((sd_card)->retry_SD20_mode == 1) - -struct sd_info { - u16 sd_type; - u8 err_code; - u8 sd_data_buf_ready; - u32 sd_addr; - u32 capacity; - - u8 raw_csd[16]; - u8 raw_scr[8]; - - /* Sequential RW */ - int seq_mode; - enum dma_data_direction pre_dir; - u32 pre_sec_addr; - u16 pre_sec_cnt; - - int counter; - - int sd_clock; - -#ifdef SUPPORT_CPRM - int sd_pass_thru_en; - int pre_cmd_err; - u8 last_rsp_type; - u8 rsp[17]; -#endif - - u8 func_group1_mask; - u8 func_group2_mask; - u8 func_group3_mask; - u8 func_group4_mask; - - u8 sd_switch_fail; - u8 sd_read_phase; - u8 retry_SD20_mode; /* sangdy2010-06-10 */ - u8 sd_reset_fail; /* sangdy2010-07-01 */ - u8 sd_send_status_en; - -}; - -#define MODE_512_SEQ 0x01 -#define MODE_2K_SEQ 0x02 - -#define TYPE_MS 0x0000 -#define TYPE_MSPRO 0x0001 - -#define MS_4BIT 0x0100 -#define MS_8BIT 0x0200 -#define MS_HG 0x0400 -#define MS_XC 0x0800 - -#define HG8BIT (MS_HG | MS_8BIT) - -#define CHK_MSPRO(ms_card) \ - (((ms_card)->ms_type & 0xFF) == TYPE_MSPRO) -#define CHK_HG8BIT(ms_card) \ - (CHK_MSPRO(ms_card) && (((ms_card)->ms_type & HG8BIT) == HG8BIT)) -#define CHK_MSXC(ms_card) \ - (CHK_MSPRO(ms_card) && ((ms_card)->ms_type & MS_XC)) -#define CHK_MSHG(ms_card) \ - (CHK_MSPRO(ms_card) && ((ms_card)->ms_type & MS_HG)) - -#define CHK_MS8BIT(ms_card) (((ms_card)->ms_type & MS_8BIT)) -#define CHK_MS4BIT(ms_card) (((ms_card)->ms_type & MS_4BIT)) - -struct rts51x_ms_delay_write_tag { - u16 old_phyblock; - u16 new_phyblock; - u16 logblock; - u8 pageoff; - u8 delay_write_flag; -}; - -struct ms_info { - u16 ms_type; - u8 block_shift; - u8 page_off; - u16 total_block; - u16 boot_block; - u32 capacity; - - u8 check_ms_flow; - u8 switch_8bit_fail; - u8 err_code; - - struct zone_entry *segment; - int segment_cnt; - - int pro_under_formatting; - int format_status; - u16 progress; - u8 raw_sys_info[96]; -#ifdef SUPPORT_PCGL_1P18 - u8 raw_model_name[48]; -#endif - - u8 multi_flag; - - /* Sequential RW */ - u8 seq_mode; - enum dma_data_direction pre_dir; - u32 pre_sec_addr; - u16 pre_sec_cnt; - u32 total_sec_cnt; - u8 last_rw_int; - - struct rts51x_ms_delay_write_tag delay_write; - - int counter; - - int ms_clock; - -#ifdef SUPPORT_MAGIC_GATE - u8 magic_gate_id[16]; - u8 mg_entry_num; - int mg_auth; /* flag to indicate authentication process */ -#endif -}; - -#define PRO_UNDER_FORMATTING(ms_card) \ - ((ms_card)->pro_under_formatting) -#define SET_FORMAT_STATUS(ms_card, status) \ - ((ms_card)->format_status = (status)) -#define CHK_FORMAT_STATUS(ms_card, status) \ - ((ms_card)->format_status == (status)) - -struct scsi_cmnd; - -enum CHIP_STAT { STAT_INIT, STAT_IDLE, STAT_RUN, STAT_SS_PRE, STAT_SS, - STAT_SUSPEND }; - -struct rts51x_chip { - u16 vendor_id; - u16 product_id; - char max_lun; - - struct scsi_cmnd *srb; - struct sense_data_t sense_buffer[MAX_ALLOWED_LUN_CNT]; - - int led_toggle_counter; - - int ss_counter; - int idle_counter; - int auto_delink_counter; - enum CHIP_STAT chip_stat; - - int resume_from_scsi; - - /* Card information */ - struct xd_info xd_card; - struct sd_info sd_card; - struct ms_info ms_card; - - int cur_clk; /* current card clock */ - int cur_card; /* Current card module */ - - u8 card_exist; /* card exist bit map (physical exist) */ - u8 card_ready; /* card ready bit map (reset successfully) */ - u8 card_fail; /* card reset fail bit map */ - u8 card_ejected; /* card ejected bit map */ - u8 card_wp; /* card write protected bit map */ - - u8 fake_card_ready; - /* flag to indicate whether to answer MediaChange */ - unsigned long lun_mc; - - /* card bus width */ - u8 card_bus_width[MAX_ALLOWED_LUN_CNT]; - /* card capacity */ - u32 capacity[MAX_ALLOWED_LUN_CNT]; - - /* read/write card function pointer */ - rts51x_card_rw_func rw_card[MAX_ALLOWED_LUN_CNT]; - /* read/write capacity, used for GPIO Toggle */ - u32 rw_cap[MAX_ALLOWED_LUN_CNT]; - /* card to lun mapping table */ - u8 card2lun[32]; - /* lun to card mapping table */ - u8 lun2card[MAX_ALLOWED_LUN_CNT]; - -#ifdef _MSG_TRACE - struct trace_msg_t trace_msg[TRACE_ITEM_CNT]; - int msg_idx; -#endif - - int rw_need_retry; - - /* ASIC or FPGA */ - int asic_code; - - /* QFN24 or LQFP48 */ - int package; - - /* Full Speed or High Speed */ - int usb_speed; - - /*sangdy:enable or disable UHS50 and MMC4.4 */ - int uhs50_mmc44_en; - - u8 ic_version; - - /* Command buffer */ - u8 *cmd_buf; - unsigned int cmd_idx; - /* Response buffer */ - u8 *rsp_buf; - - u16 card_status; - -#ifdef SUPPORT_OCP - u16 ocp_stat; -#endif - - struct rts51x_option option; - struct rts51x_usb *usb; - - u8 rcc_read_response; - int reset_need_retry; - u8 rts5179; -}; - -#define UHS50_EN 0x0001 -#define UHS50_DIS 0x0000 -#define SET_UHS50(chip) ((chip)->uhs50_mmc44_en = UHS50_EN) -#define CLEAR_UHS50(chip) ((chip)->uhs50_mmc44_en = UHS50_DIS) -#define CHECK_UHS50(chip) (((chip)->uhs50_mmc44_en&0xff) == UHS50_EN) - -#define RTS51X_GET_VID(chip) ((chip)->vendor_id) -#define RTS51X_GET_PID(chip) ((chip)->product_id) - -#define RTS51X_SET_STAT(chip, stat) \ -do { \ - if ((stat) != STAT_IDLE) { \ - (chip)->idle_counter = 0; \ - } \ - (chip)->chip_stat = (enum CHIP_STAT)(stat); \ -} while (0) -#define RTS51X_CHK_STAT(chip, stat) ((chip)->chip_stat == (stat)) -#define RTS51X_GET_STAT(chip) ((chip)->chip_stat) - -#define CHECK_PID(chip, pid) (RTS51X_GET_PID(chip) == (pid)) -#define CHECK_PKG(chip, pkg) ((chip)->package == (pkg)) -#define CHECK_USB(chip, speed) ((chip)->usb_speed == (speed)) - -int rts51x_reset_chip(struct rts51x_chip *chip); -int rts51x_init_chip(struct rts51x_chip *chip); -int rts51x_release_chip(struct rts51x_chip *chip); -void rts51x_polling_func(struct rts51x_chip *chip); - -static inline void rts51x_init_cmd(struct rts51x_chip *chip) -{ - chip->cmd_idx = 0; - chip->cmd_buf[0] = 'R'; - chip->cmd_buf[1] = 'T'; - chip->cmd_buf[2] = 'C'; - chip->cmd_buf[3] = 'R'; - chip->cmd_buf[PACKET_TYPE] = BATCH_CMD; -} - -void rts51x_add_cmd(struct rts51x_chip *chip, - u8 cmd_type, u16 reg_addr, u8 mask, u8 data); -int rts51x_send_cmd(struct rts51x_chip *chip, u8 flag, int timeout); -int rts51x_get_rsp(struct rts51x_chip *chip, int rsp_len, int timeout); - -static inline void rts51x_read_rsp_buf(struct rts51x_chip *chip, int offset, - u8 *buf, int buf_len) -{ - memcpy(buf, chip->rsp_buf + offset, buf_len); -} - -static inline u8 *rts51x_get_rsp_data(struct rts51x_chip *chip) -{ - return chip->rsp_buf; -} - -int rts51x_get_card_status(struct rts51x_chip *chip, u16 *status); -int rts51x_write_register(struct rts51x_chip *chip, u16 addr, u8 mask, u8 data); -int rts51x_read_register(struct rts51x_chip *chip, u16 addr, u8 *data); -int rts51x_ep0_write_register(struct rts51x_chip *chip, u16 addr, u8 mask, - u8 data); -int rts51x_ep0_read_register(struct rts51x_chip *chip, u16 addr, u8 *data); -int rts51x_seq_write_register(struct rts51x_chip *chip, u16 addr, u16 len, - u8 *data); -int rts51x_seq_read_register(struct rts51x_chip *chip, u16 addr, u16 len, - u8 *data); -int rts51x_read_ppbuf(struct rts51x_chip *chip, u8 *buf, int buf_len); -int rts51x_write_ppbuf(struct rts51x_chip *chip, u8 *buf, int buf_len); -int rts51x_write_phy_register(struct rts51x_chip *chip, u8 addr, u8 val); -int rts51x_read_phy_register(struct rts51x_chip *chip, u8 addr, u8 *val); -void rts51x_do_before_power_down(struct rts51x_chip *chip); -void rts51x_clear_hw_error(struct rts51x_chip *chip); -void rts51x_prepare_run(struct rts51x_chip *chip); -void rts51x_trace_msg(struct rts51x_chip *chip, unsigned char *buf, int clear); -void rts51x_pp_status(struct rts51x_chip *chip, unsigned int lun, u8 *status, - u8 status_len); -void rts51x_read_status(struct rts51x_chip *chip, unsigned int lun, - u8 *rts51x_status, u8 status_len); -int rts51x_transfer_data_rcc(struct rts51x_chip *chip, unsigned int pipe, - void *buf, unsigned int len, int use_sg, - unsigned int *act_len, int timeout, u8 stage_flag); - -#define RTS51X_WRITE_REG(chip, addr, mask, data) \ -do { \ - int _retval = rts51x_write_register((chip), \ - (addr), (mask), (data)); \ - if (_retval != STATUS_SUCCESS) { \ - TRACE_RET((chip), _retval); \ - } \ -} while (0) - -#define RTS51X_READ_REG(chip, addr, data) \ -do { \ - int _retval = rts51x_read_register((chip), \ - (addr), (data)); \ - if (_retval != STATUS_SUCCESS) { \ - TRACE_RET((chip), _retval); \ - } \ -} while (0) - -#endif /* __RTS51X_CHIP_H */ diff --git a/drivers/staging/rts5139/rts51x_fop.c b/drivers/staging/rts5139/rts51x_fop.c deleted file mode 100644 index cf4e675aea69..000000000000 --- a/drivers/staging/rts5139/rts51x_fop.c +++ /dev/null @@ -1,295 +0,0 @@ -/* Driver for Realtek RTS51xx USB card reader - * - * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. - * - * 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, 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, see . - * - * Author: - * wwang (wei_wang@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - * Maintainer: - * Edwin Rong (edwin_rong@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - */ - -#include "rts51x.h" - -#ifdef SUPPORT_FILE_OP - -#include -#include -#include -#include - -#include "rts51x_chip.h" -#include "rts51x_card.h" -#include "rts51x_fop.h" -#include "sd_cprm.h" - -#define RTS5139_IOC_MAGIC 0x39 - -#define RTS5139_IOC_SD_DIRECT _IOWR(RTS5139_IOC_MAGIC, 0xA0, int) -#define RTS5139_IOC_SD_GET_RSP _IOWR(RTS5139_IOC_MAGIC, 0xA1, int) - -static int rts51x_sd_direct_cmnd(struct rts51x_chip *chip, - struct sd_direct_cmnd *cmnd) -{ - int retval; - u8 dir, cmd12, standby, acmd, cmd_idx, rsp_code; - u8 *buf; - u32 arg, len; - - dir = (cmnd->cmnd[0] >> 3) & 0x03; - cmd12 = (cmnd->cmnd[0] >> 2) & 0x01; - standby = (cmnd->cmnd[0] >> 1) & 0x01; - acmd = cmnd->cmnd[0] & 0x01; - cmd_idx = cmnd->cmnd[1]; - arg = ((u32) (cmnd->cmnd[2]) << 24) | ((u32) (cmnd->cmnd[3]) << 16) | - ((u32) (cmnd->cmnd[4]) << 8) | cmnd->cmnd[5]; - len = - ((u32) (cmnd->cmnd[6]) << 16) | ((u32) (cmnd->cmnd[7]) << 8) | - cmnd->cmnd[8]; - rsp_code = cmnd->cmnd[9]; - - if (dir) { - if (!cmnd->buf || (cmnd->buf_len < len)) - TRACE_RET(chip, STATUS_FAIL); - } - - switch (dir) { - case 0: - /* No data */ - retval = ext_rts51x_sd_execute_no_data(chip, - chip->card2lun[SD_CARD], - cmd_idx, standby, acmd, - rsp_code, arg); - if (retval != TRANSPORT_GOOD) - TRACE_RET(chip, STATUS_FAIL); - break; - - case 1: - /* Read from card */ - buf = kzalloc(cmnd->buf_len, GFP_KERNEL); - if (!buf) - TRACE_RET(chip, STATUS_NOMEM); - - retval = ext_rts51x_sd_execute_read_data(chip, - chip->card2lun[SD_CARD], - cmd_idx, cmd12, standby, acmd, - rsp_code, arg, len, buf, - cmnd->buf_len, 0); - if (retval != TRANSPORT_GOOD) { - kfree(buf); - TRACE_RET(chip, STATUS_FAIL); - } - - retval = - copy_to_user(cmnd->buf, (void *)buf, cmnd->buf_len); - if (retval) { - kfree(buf); - TRACE_RET(chip, STATUS_NOMEM); - } - - kfree(buf); - break; - - case 2: - /* Write to card */ - buf = kmalloc(cmnd->buf_len, GFP_KERNEL); - if (!buf) - TRACE_RET(chip, STATUS_NOMEM); - - retval = - copy_from_user((void *)buf, cmnd->buf, - cmnd->buf_len); - if (retval) { - kfree(buf); - TRACE_RET(chip, STATUS_NOMEM); - } - - retval = - ext_rts51x_sd_execute_write_data(chip, - chip->card2lun[SD_CARD], - cmd_idx, cmd12, standby, acmd, - rsp_code, arg, len, buf, - cmnd->buf_len, 0); - if (retval != TRANSPORT_GOOD) { - kfree(buf); - TRACE_RET(chip, STATUS_FAIL); - } - - kfree(buf); - - break; - - default: - TRACE_RET(chip, STATUS_FAIL); - } - - return STATUS_SUCCESS; -} - -static int rts51x_sd_get_rsp(struct rts51x_chip *chip, struct sd_rsp *rsp) -{ - struct sd_info *sd_card = &(chip->sd_card); - int count = 0, retval; - - if (sd_card->pre_cmd_err) { - sd_card->pre_cmd_err = 0; - TRACE_RET(chip, STATUS_FAIL); - } - - if (sd_card->last_rsp_type == SD_RSP_TYPE_R0) - TRACE_RET(chip, STATUS_FAIL); - else if (sd_card->last_rsp_type == SD_RSP_TYPE_R2) - count = (rsp->rsp_len < 17) ? rsp->rsp_len : 17; - else - count = (rsp->rsp_len < 6) ? rsp->rsp_len : 6; - - retval = copy_to_user(rsp->rsp, (void *)sd_card->rsp, count); - if (retval) - TRACE_RET(chip, STATUS_NOMEM); - - RTS51X_DEBUGP("Response length: %d\n", count); - RTS51X_DEBUGP("Response: 0x%x 0x%x 0x%x 0x%x\n", - sd_card->rsp[0], sd_card->rsp[1], sd_card->rsp[2], - sd_card->rsp[3]); - - return STATUS_SUCCESS; -} - -int rts51x_open(struct inode *inode, struct file *filp) -{ - struct rts51x_chip *chip; - struct usb_interface *interface; - int subminor; - int retval = 0; - - subminor = iminor(inode); - - interface = usb_find_interface(&rts51x_driver, subminor); - if (!interface) { - RTS51X_DEBUGP("%s - error, can't find device for minor %d\n", - __func__, subminor); - retval = -ENODEV; - goto exit; - } - - chip = (struct rts51x_chip *)usb_get_intfdata(interface); - if (!chip) { - RTS51X_DEBUGP("Can't find chip\n"); - retval = -ENODEV; - goto exit; - } - - /* Increase our reference to the host */ - scsi_host_get(rts51x_to_host(chip)); - - /* lock the device pointers */ - mutex_lock(&(chip->usb->dev_mutex)); - - /* save our object in the file's private structure */ - filp->private_data = chip; - - /* unlock the device pointers */ - mutex_unlock(&chip->usb->dev_mutex); - -exit: - return retval; -} - -int rts51x_release(struct inode *inode, struct file *filp) -{ - struct rts51x_chip *chip; - - chip = (struct rts51x_chip *)filp->private_data; - if (chip == NULL) - return -ENODEV; - - /* Drop our reference to the host; the SCSI core will free it - * (and "chip" along with it) when the refcount becomes 0. */ - scsi_host_put(rts51x_to_host(chip)); - - return 0; -} - -ssize_t rts51x_read(struct file *filp, char __user *buf, size_t count, - loff_t *f_pos) -{ - return 0; -} - -ssize_t rts51x_write(struct file *filp, const char __user *buf, size_t count, - loff_t *f_pos) -{ - return 0; -} - -long rts51x_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) -{ - struct rts51x_chip *chip; - struct sd_direct_cmnd cmnd; - struct sd_rsp rsp; - int retval = 0; - - chip = (struct rts51x_chip *)filp->private_data; - if (chip == NULL) - return -ENODEV; - - /* lock the device pointers */ - mutex_lock(&(chip->usb->dev_mutex)); - - switch (cmd) { - case RTS5139_IOC_SD_DIRECT: - retval = - copy_from_user((void *)&cmnd, (void __user *)arg, - sizeof(struct sd_direct_cmnd)); - if (retval) { - retval = -ENOMEM; - TRACE_GOTO(chip, exit); - } - retval = rts51x_sd_direct_cmnd(chip, &cmnd); - if (retval != STATUS_SUCCESS) { - retval = -EIO; - TRACE_GOTO(chip, exit); - } - break; - - case RTS5139_IOC_SD_GET_RSP: - retval = - copy_from_user(&rsp, (void __user *)arg, - sizeof(struct sd_rsp)); - if (retval) { - retval = -ENOMEM; - TRACE_GOTO(chip, exit); - } - retval = rts51x_sd_get_rsp(chip, &rsp); - if (retval != STATUS_SUCCESS) { - retval = -EIO; - TRACE_GOTO(chip, exit); - } - break; - - default: - break; - } - -exit: - /* unlock the device pointers */ - mutex_unlock(&chip->usb->dev_mutex); - - return retval; -} - -#endif diff --git a/drivers/staging/rts5139/rts51x_fop.h b/drivers/staging/rts5139/rts51x_fop.h deleted file mode 100644 index c691ee99720e..000000000000 --- a/drivers/staging/rts5139/rts51x_fop.h +++ /dev/null @@ -1,57 +0,0 @@ -/* Driver for Realtek RTS51xx USB card reader - * - * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. - * - * 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, 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, see . - * - * Author: - * wwang (wei_wang@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - * Maintainer: - * Edwin Rong (edwin_rong@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - */ - -#ifndef __RTS51X_FOP_H -#define __RTS51X_FOP_H - -#include "rts51x.h" - -#ifdef SUPPORT_FILE_OP - -#include -#include - -struct sd_direct_cmnd { - u8 cmnd[12]; - void __user *buf; - int buf_len; -}; - -struct sd_rsp { - void __user *rsp; - int rsp_len; -}; - -int rts51x_open(struct inode *inode, struct file *filp); -int rts51x_release(struct inode *inode, struct file *filp); -ssize_t rts51x_read(struct file *filp, char __user *buf, size_t count, - loff_t *f_pos); -ssize_t rts51x_write(struct file *filp, const char __user *buf, size_t count, - loff_t *f_pos); -long rts51x_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); - -#endif - -#endif /* __RTS51X_FOP_H */ diff --git a/drivers/staging/rts5139/rts51x_scsi.c b/drivers/staging/rts5139/rts51x_scsi.c deleted file mode 100644 index 75282fea38f7..000000000000 --- a/drivers/staging/rts5139/rts51x_scsi.c +++ /dev/null @@ -1,2135 +0,0 @@ -/* Driver for Realtek RTS51xx USB card reader - * - * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. - * - * 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, 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, see . - * - * Author: - * wwang (wei_wang@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - * Maintainer: - * Edwin Rong (edwin_rong@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "debug.h" -#include "rts51x.h" -#include "rts51x_chip.h" -#include "rts51x_scsi.h" -#include "rts51x_card.h" -#include "rts51x_transport.h" -#include "sd_cprm.h" -#include "ms_mg.h" -#include "trace.h" - -void rts51x_scsi_show_command(struct scsi_cmnd *srb) -{ - char *what = NULL; - int i, unknown_cmd = 0; - - switch (srb->cmnd[0]) { - case TEST_UNIT_READY: - what = (char *)"TEST_UNIT_READY"; - break; - case REZERO_UNIT: - what = (char *)"REZERO_UNIT"; - break; - case REQUEST_SENSE: - what = (char *)"REQUEST_SENSE"; - break; - case FORMAT_UNIT: - what = (char *)"FORMAT_UNIT"; - break; - case READ_BLOCK_LIMITS: - what = (char *)"READ_BLOCK_LIMITS"; - break; - case 0x07: - what = (char *)"REASSIGN_BLOCKS"; - break; - case READ_6: - what = (char *)"READ_6"; - break; - case WRITE_6: - what = (char *)"WRITE_6"; - break; - case SEEK_6: - what = (char *)"SEEK_6"; - break; - case READ_REVERSE: - what = (char *)"READ_REVERSE"; - break; - case WRITE_FILEMARKS: - what = (char *)"WRITE_FILEMARKS"; - break; - case SPACE: - what = (char *)"SPACE"; - break; - case INQUIRY: - what = (char *)"INQUIRY"; - break; - case RECOVER_BUFFERED_DATA: - what = (char *)"RECOVER_BUFFERED_DATA"; - break; - case MODE_SELECT: - what = (char *)"MODE_SELECT"; - break; - case RESERVE: - what = (char *)"RESERVE"; - break; - case RELEASE: - what = (char *)"RELEASE"; - break; - case COPY: - what = (char *)"COPY"; - break; - case ERASE: - what = (char *)"ERASE"; - break; - case MODE_SENSE: - what = (char *)"MODE_SENSE"; - break; - case START_STOP: - what = (char *)"START_STOP"; - break; - case RECEIVE_DIAGNOSTIC: - what = (char *)"RECEIVE_DIAGNOSTIC"; - break; - case SEND_DIAGNOSTIC: - what = (char *)"SEND_DIAGNOSTIC"; - break; - case ALLOW_MEDIUM_REMOVAL: - what = (char *)"ALLOW_MEDIUM_REMOVAL"; - break; - case SET_WINDOW: - what = (char *)"SET_WINDOW"; - break; - case READ_CAPACITY: - what = (char *)"READ_CAPACITY"; - break; - case READ_10: - what = (char *)"READ_10"; - break; - case WRITE_10: - what = (char *)"WRITE_10"; - break; - case SEEK_10: - what = (char *)"SEEK_10"; - break; - case WRITE_VERIFY: - what = (char *)"WRITE_VERIFY"; - break; - case VERIFY: - what = (char *)"VERIFY"; - break; - case SEARCH_HIGH: - what = (char *)"SEARCH_HIGH"; - break; - case SEARCH_EQUAL: - what = (char *)"SEARCH_EQUAL"; - break; - case SEARCH_LOW: - what = (char *)"SEARCH_LOW"; - break; - case SET_LIMITS: - what = (char *)"SET_LIMITS"; - break; - case READ_POSITION: - what = (char *)"READ_POSITION"; - break; - case SYNCHRONIZE_CACHE: - what = (char *)"SYNCHRONIZE_CACHE"; - break; - case LOCK_UNLOCK_CACHE: - what = (char *)"LOCK_UNLOCK_CACHE"; - break; - case READ_DEFECT_DATA: - what = (char *)"READ_DEFECT_DATA"; - break; - case MEDIUM_SCAN: - what = (char *)"MEDIUM_SCAN"; - break; - case COMPARE: - what = (char *)"COMPARE"; - break; - case COPY_VERIFY: - what = (char *)"COPY_VERIFY"; - break; - case WRITE_BUFFER: - what = (char *)"WRITE_BUFFER"; - break; - case READ_BUFFER: - what = (char *)"READ_BUFFER"; - break; - case UPDATE_BLOCK: - what = (char *)"UPDATE_BLOCK"; - break; - case READ_LONG: - what = (char *)"READ_LONG"; - break; - case WRITE_LONG: - what = (char *)"WRITE_LONG"; - break; - case CHANGE_DEFINITION: - what = (char *)"CHANGE_DEFINITION"; - break; - case WRITE_SAME: - what = (char *)"WRITE_SAME"; - break; - case GPCMD_READ_SUBCHANNEL: - what = (char *)"READ SUBCHANNEL"; - break; - case READ_TOC: - what = (char *)"READ_TOC"; - break; - case GPCMD_READ_HEADER: - what = (char *)"READ HEADER"; - break; - case GPCMD_PLAY_AUDIO_10: - what = (char *)"PLAY AUDIO (10)"; - break; - case GPCMD_PLAY_AUDIO_MSF: - what = (char *)"PLAY AUDIO MSF"; - break; - case GPCMD_GET_EVENT_STATUS_NOTIFICATION: - what = (char *)"GET EVENT/STATUS NOTIFICATION"; - break; - case GPCMD_PAUSE_RESUME: - what = (char *)"PAUSE/RESUME"; - break; - case LOG_SELECT: - what = (char *)"LOG_SELECT"; - break; - case LOG_SENSE: - what = (char *)"LOG_SENSE"; - break; - case GPCMD_STOP_PLAY_SCAN: - what = (char *)"STOP PLAY/SCAN"; - break; - case GPCMD_READ_DISC_INFO: - what = (char *)"READ DISC INFORMATION"; - break; - case GPCMD_READ_TRACK_RZONE_INFO: - what = (char *)"READ TRACK INFORMATION"; - break; - case GPCMD_RESERVE_RZONE_TRACK: - what = (char *)"RESERVE TRACK"; - break; - case GPCMD_SEND_OPC: - what = (char *)"SEND OPC"; - break; - case MODE_SELECT_10: - what = (char *)"MODE_SELECT_10"; - break; - case GPCMD_REPAIR_RZONE_TRACK: - what = (char *)"REPAIR TRACK"; - break; - case 0x59: - what = (char *)"READ MASTER CUE"; - break; - case MODE_SENSE_10: - what = (char *)"MODE_SENSE_10"; - break; - case GPCMD_CLOSE_TRACK: - what = (char *)"CLOSE TRACK/SESSION"; - break; - case 0x5C: - what = (char *)"READ BUFFER CAPACITY"; - break; - case 0x5D: - what = (char *)"SEND CUE SHEET"; - break; - case GPCMD_BLANK: - what = (char *)"BLANK"; - break; - case REPORT_LUNS: - what = (char *)"REPORT LUNS"; - break; - case MOVE_MEDIUM: - what = (char *)"MOVE_MEDIUM or PLAY AUDIO (12)"; - break; - case READ_12: - what = (char *)"READ_12"; - break; - case WRITE_12: - what = (char *)"WRITE_12"; - break; - case WRITE_VERIFY_12: - what = (char *)"WRITE_VERIFY_12"; - break; - case SEARCH_HIGH_12: - what = (char *)"SEARCH_HIGH_12"; - break; - case SEARCH_EQUAL_12: - what = (char *)"SEARCH_EQUAL_12"; - break; - case SEARCH_LOW_12: - what = (char *)"SEARCH_LOW_12"; - break; - case SEND_VOLUME_TAG: - what = (char *)"SEND_VOLUME_TAG"; - break; - case READ_ELEMENT_STATUS: - what = (char *)"READ_ELEMENT_STATUS"; - break; - case GPCMD_READ_CD_MSF: - what = (char *)"READ CD MSF"; - break; - case GPCMD_SCAN: - what = (char *)"SCAN"; - break; - case GPCMD_SET_SPEED: - what = (char *)"SET CD SPEED"; - break; - case GPCMD_MECHANISM_STATUS: - what = (char *)"MECHANISM STATUS"; - break; - case GPCMD_READ_CD: - what = (char *)"READ CD"; - break; - case 0xE1: - what = (char *)"WRITE CONTINUE"; - break; - case WRITE_LONG_2: - what = (char *)"WRITE_LONG_2"; - break; - case VENDOR_CMND: - what = (char *)"Realtek's vendor command"; - break; - default: - what = (char *)"(unknown command)"; - unknown_cmd = 1; - break; - } - - if (srb->cmnd[0] != TEST_UNIT_READY) - RTS51X_DEBUGP("Command %s (%d bytes)\n", what, srb->cmd_len); - if (unknown_cmd) { - RTS51X_DEBUGP(""); - for (i = 0; i < srb->cmd_len && i < 16; i++) - RTS51X_DEBUGPN(" %02x", srb->cmnd[i]); - RTS51X_DEBUGPN("\n"); - } -} - -void rts51x_set_sense_type(struct rts51x_chip *chip, unsigned int lun, int sense_type) -{ - switch (sense_type) { - case SENSE_TYPE_MEDIA_CHANGE: - rts51x_set_sense_data(chip, lun, CUR_ERR, 0x06, 0, 0x28, 0, 0, 0); - break; - - case SENSE_TYPE_MEDIA_NOT_PRESENT: - rts51x_set_sense_data(chip, lun, CUR_ERR, 0x02, 0, 0x3A, 0, 0, 0); - break; - - case SENSE_TYPE_MEDIA_LBA_OVER_RANGE: - rts51x_set_sense_data(chip, lun, CUR_ERR, 0x05, 0, 0x21, 0, 0, 0); - break; - - case SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT: - rts51x_set_sense_data(chip, lun, CUR_ERR, 0x05, 0, 0x25, 0, 0, 0); - break; - - case SENSE_TYPE_MEDIA_WRITE_PROTECT: - rts51x_set_sense_data(chip, lun, CUR_ERR, 0x07, 0, 0x27, 0, 0, 0); - break; - - case SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR: - rts51x_set_sense_data(chip, lun, CUR_ERR, 0x03, 0, 0x11, 0, 0, 0); - break; - - case SENSE_TYPE_MEDIA_WRITE_ERR: - rts51x_set_sense_data(chip, lun, CUR_ERR, 0x03, 0, 0x0C, 0x02, 0, 0); - break; - - case SENSE_TYPE_MEDIA_INVALID_CMD_FIELD: - rts51x_set_sense_data(chip, lun, CUR_ERR, ILGAL_REQ, 0, - ASC_INVLD_CDB, ASCQ_INVLD_CDB, CDB_ILLEGAL, 1); - break; - - case SENSE_TYPE_FORMAT_CMD_FAILED: - rts51x_set_sense_data(chip, lun, CUR_ERR, 0x03, 0, 0x31, 0x01, 0, 0); - break; - -#ifdef SUPPORT_MAGIC_GATE - case SENSE_TYPE_MG_KEY_FAIL_NOT_ESTAB: - rts51x_set_sense_data(chip, lun, CUR_ERR, 0x05, 0, 0x6F, 0x02, 0, 0); - break; - - case SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN: - rts51x_set_sense_data(chip, lun, CUR_ERR, 0x05, 0, 0x6F, 0x00, 0, 0); - break; - - case SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM: - rts51x_set_sense_data(chip, lun, CUR_ERR, 0x02, 0, 0x30, 0x00, 0, 0); - break; - - case SENSE_TYPE_MG_WRITE_ERR: - rts51x_set_sense_data(chip, lun, CUR_ERR, 0x03, 0, 0x0C, 0x00, 0, 0); - break; -#endif - - case SENSE_TYPE_NO_SENSE: - default: - rts51x_set_sense_data(chip, lun, CUR_ERR, 0, 0, 0, 0, 0, 0); - break; - } -} - -void rts51x_set_sense_data(struct rts51x_chip *chip, unsigned int lun, u8 err_code, - u8 sense_key, u32 info, u8 asc, u8 ascq, u8 sns_key_info0, - u16 sns_key_info1) -{ - struct sense_data_t *sense = &(chip->sense_buffer[lun]); - - sense->err_code = err_code; - sense->sense_key = sense_key; - sense->info[0] = (u8) (info >> 24); - sense->info[1] = (u8) (info >> 16); - sense->info[2] = (u8) (info >> 8); - sense->info[3] = (u8) info; - - sense->ad_sense_len = sizeof(struct sense_data_t) - 8; - sense->asc = asc; - sense->ascq = ascq; - if (sns_key_info0 != 0) { - sense->sns_key_info[0] = SKSV | sns_key_info0; - sense->sns_key_info[1] = (sns_key_info1 & 0xf0) >> 8; - sense->sns_key_info[2] = sns_key_info1 & 0x0f; - } -} - -static int test_unit_ready(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - unsigned int lun = SCSI_LUN(srb); - - rts51x_init_cards(chip); - - if (!check_card_ready(chip, lun)) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - return TRANSPORT_FAILED; - } - - if (!check_lun_mc(chip, lun)) { - set_lun_mc(chip, lun); - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); - return TRANSPORT_FAILED; - } - - return TRANSPORT_GOOD; -} - -static unsigned char formatter_inquiry_str[20] = { - 'M', 'E', 'M', 'O', 'R', 'Y', 'S', 'T', 'I', 'C', 'K', - '-', 'M', 'G', /* Byte[47:49] */ - 0x0B, /* Byte[50]: MG, MS, MSPro, MSXC */ - 0x00, /* Byte[51]: Category Specific Commands */ - 0x00, /* Byte[52]: Access Control and feature */ - 0x20, 0x20, 0x20, /* Byte[53:55] */ -}; - -static int inquiry(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - unsigned int lun = SCSI_LUN(srb); - char *inquiry_default = (char *)"Generic-xD/SD/M.S. 1.00 "; - char *inquiry_string; - unsigned char sendbytes; - unsigned char *buf; - u8 card = rts51x_get_lun_card(chip, lun); - int pro_formatter_flag = 0; - unsigned char inquiry_buf[] = { - QULIFIRE | DRCT_ACCESS_DEV, - RMB_DISC | 0x0D, - 0x00, - 0x01, - 0x1f, - 0x02, - 0, - REL_ADR | WBUS_32 | WBUS_16 | SYNC | LINKED | CMD_QUE | SFT_RE, - }; - - inquiry_string = inquiry_default; - - buf = vmalloc(scsi_bufflen(srb)); - if (buf == NULL) - TRACE_RET(chip, TRANSPORT_ERROR); - - if (MS_FORMATTER_ENABLED(chip) && (get_lun2card(chip, lun) & MS_CARD)) { - if (!card || (card == MS_CARD)) - pro_formatter_flag = 1; - } - - if (pro_formatter_flag) { - if (scsi_bufflen(srb) < 56) - sendbytes = (unsigned char)(scsi_bufflen(srb)); - else - sendbytes = 56; - } else { - if (scsi_bufflen(srb) < 36) - sendbytes = (unsigned char)(scsi_bufflen(srb)); - else - sendbytes = 36; - } - - if (sendbytes > 8) { - memcpy(buf, inquiry_buf, 8); - memcpy(buf + 8, inquiry_string, sendbytes - 8); - if (pro_formatter_flag) - buf[4] = 0x33; /* Additional Length */ - } else { - memcpy(buf, inquiry_buf, sendbytes); - } - - if (pro_formatter_flag) { - if (sendbytes > 36) - memcpy(buf + 36, formatter_inquiry_str, sendbytes - 36); - } - - scsi_set_resid(srb, 0); - - rts51x_set_xfer_buf(buf, scsi_bufflen(srb), srb); - vfree(buf); - - return TRANSPORT_GOOD; -} - -static int start_stop_unit(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - unsigned int lun = SCSI_LUN(srb); - - scsi_set_resid(srb, scsi_bufflen(srb)); - - if (srb->cmnd[1] == 1) - return TRANSPORT_GOOD; - - switch (srb->cmnd[0x4]) { - case STOP_MEDIUM: - /* Media disabled */ - return TRANSPORT_GOOD; - - case UNLOAD_MEDIUM: - /* Media shall be unload */ - if (check_card_ready(chip, lun)) - rts51x_eject_card(chip, lun); - return TRANSPORT_GOOD; - - case MAKE_MEDIUM_READY: - case LOAD_MEDIUM: - if (check_card_ready(chip, lun)) { - return TRANSPORT_GOOD; - } else { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - break; - } - - TRACE_RET(chip, TRANSPORT_ERROR); -} - -static int allow_medium_removal(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - int prevent; - - prevent = srb->cmnd[4] & 0x1; - - scsi_set_resid(srb, 0); - - if (prevent) { - rts51x_set_sense_type(chip, SCSI_LUN(srb), - SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - return TRANSPORT_GOOD; -} - -static void ms_mode_sense(struct rts51x_chip *chip, u8 cmd, - int lun, u8 *buf, int buf_len) -{ - struct ms_info *ms_card = &(chip->ms_card); - int sys_info_offset; - int data_size = buf_len; - int support_format = 0; - int i = 0; - - if (cmd == MODE_SENSE) { - sys_info_offset = 8; - if (data_size > 0x68) - data_size = 0x68; - buf[i++] = 0x67; /* Mode Data Length */ - } else { - sys_info_offset = 12; - if (data_size > 0x6C) - data_size = 0x6C; - buf[i++] = 0x00; /* Mode Data Length (MSB) */ - buf[i++] = 0x6A; /* Mode Data Length (LSB) */ - } - - /* Medium Type Code */ - if (check_card_ready(chip, lun)) { - if (CHK_MSXC(ms_card)) { - support_format = 1; - buf[i++] = 0x40; - } else if (CHK_MSPRO(ms_card)) { - support_format = 1; - buf[i++] = 0x20; - } else { - buf[i++] = 0x10; - } - - /* WP */ - if (check_card_wp(chip, lun)) - buf[i++] = 0x80; - else - buf[i++] = 0x00; - } else { - buf[i++] = 0x00; /* MediaType */ - buf[i++] = 0x00; /* WP */ - } - - buf[i++] = 0x00; /* Reserved */ - - if (cmd == MODE_SENSE_10) { - buf[i++] = 0x00; /* Reserved */ - buf[i++] = 0x00; /* Block descriptor length(MSB) */ - buf[i++] = 0x00; /* Block descriptor length(LSB) */ - - /* The Following Data is the content of "Page 0x20" */ - if (data_size >= 9) - buf[i++] = 0x20; /* Page Code */ - if (data_size >= 10) - buf[i++] = 0x62; /* Page Length */ - if (data_size >= 11) - buf[i++] = 0x00; /* No Access Control */ - if (data_size >= 12) { - if (support_format) - buf[i++] = 0xC0; /* SF, SGM */ - else - buf[i++] = 0x00; - } - } else { - /* The Following Data is the content of "Page 0x20" */ - if (data_size >= 5) - buf[i++] = 0x20; /* Page Code */ - if (data_size >= 6) - buf[i++] = 0x62; /* Page Length */ - if (data_size >= 7) - buf[i++] = 0x00; /* No Access Control */ - if (data_size >= 8) { - if (support_format) - buf[i++] = 0xC0; /* SF, SGM */ - else - buf[i++] = 0x00; - } - } - - if (data_size > sys_info_offset) { - /* 96 Bytes Attribute Data */ - int len = data_size - sys_info_offset; - len = (len < 96) ? len : 96; - - memcpy(buf + sys_info_offset, ms_card->raw_sys_info, len); - } -} - -static int mode_sense(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - unsigned int lun = SCSI_LUN(srb); - unsigned int dataSize; - int status; - int pro_formatter_flag; - unsigned char pageCode, *buf; - u8 card = rts51x_get_lun_card(chip, lun); - - if (!check_card_ready(chip, lun)) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - scsi_set_resid(srb, scsi_bufflen(srb)); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - pro_formatter_flag = 0; - dataSize = 8; - /* In Combo mode, device responses ModeSense command as a MS LUN - * when no card is inserted */ - if ((get_lun2card(chip, lun) & MS_CARD)) { - if (!card || (card == MS_CARD)) { - dataSize = 108; - if (chip->option.rts51x_mspro_formatter_enable) - pro_formatter_flag = 1; - } - } - - buf = kmalloc(dataSize, GFP_KERNEL); - if (buf == NULL) - TRACE_RET(chip, TRANSPORT_ERROR); - - pageCode = srb->cmnd[2] & 0x3f; - - if ((pageCode == 0x3F) || (pageCode == 0x1C) || - (pageCode == 0x00) || (pro_formatter_flag && (pageCode == 0x20))) { - if (srb->cmnd[0] == MODE_SENSE) { - if ((pageCode == 0x3F) || (pageCode == 0x20)) { - ms_mode_sense(chip, srb->cmnd[0], lun, buf, - dataSize); - } else { - dataSize = 4; - buf[0] = 0x03; - buf[1] = 0x00; - if (check_card_wp(chip, lun)) - buf[2] = 0x80; - else - buf[3] = 0x00; - } - } else { - if ((pageCode == 0x3F) || (pageCode == 0x20)) { - ms_mode_sense(chip, srb->cmnd[0], lun, buf, - dataSize); - } else { - dataSize = 8; - buf[0] = 0x00; - buf[1] = 0x06; - buf[2] = 0x00; - if (check_card_wp(chip, lun)) - buf[3] = 0x80; - else - buf[3] = 0x00; - buf[4] = 0x00; - buf[5] = 0x00; - buf[6] = 0x00; - buf[7] = 0x00; - } - } - status = TRANSPORT_GOOD; - } else { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - scsi_set_resid(srb, scsi_bufflen(srb)); - status = TRANSPORT_FAILED; - } - - if (status == TRANSPORT_GOOD) { - unsigned int len = min(scsi_bufflen(srb), dataSize); - rts51x_set_xfer_buf(buf, len, srb); - scsi_set_resid(srb, scsi_bufflen(srb) - len); - } - kfree(buf); - - return status; -} - -static int request_sense(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - struct sense_data_t *sense; - unsigned int lun = SCSI_LUN(srb); - struct ms_info *ms_card = &(chip->ms_card); - unsigned char *tmp, *buf; - - sense = &(chip->sense_buffer[lun]); - - if ((rts51x_get_lun_card(chip, lun) == MS_CARD) - && PRO_UNDER_FORMATTING(ms_card)) { - rts51x_mspro_format_sense(chip, lun); - } - - buf = vmalloc(scsi_bufflen(srb)); - if (buf == NULL) - TRACE_RET(chip, TRANSPORT_ERROR); - - tmp = (unsigned char *)sense; - memcpy(buf, tmp, scsi_bufflen(srb)); - - rts51x_set_xfer_buf(buf, scsi_bufflen(srb), srb); - vfree(buf); - - scsi_set_resid(srb, 0); - /* Reset Sense Data */ - rts51x_set_sense_type(chip, lun, SENSE_TYPE_NO_SENSE); - return TRANSPORT_GOOD; -} - -static int read_write(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - unsigned int lun = SCSI_LUN(srb); - int retval; - u32 start_sec; - u16 sec_cnt; - - if (!check_card_ready(chip, lun) || (chip->capacity[lun] == 0)) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - if (!check_lun_mc(chip, lun)) { - set_lun_mc(chip, lun); - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); - return TRANSPORT_FAILED; - } - - rts51x_prepare_run(chip); - RTS51X_SET_STAT(chip, STAT_RUN); - - if ((srb->cmnd[0] == READ_10) || (srb->cmnd[0] == WRITE_10)) { - start_sec = - ((u32) srb->cmnd[2] << 24) | - ((u32) srb->cmnd[3] << 16) | - ((u32) srb->cmnd[4] << 8) | - ((u32) srb->cmnd[5]); - sec_cnt = ((u16) (srb->cmnd[7]) << 8) | srb->cmnd[8]; - } else if ((srb->cmnd[0] == READ_6) || (srb->cmnd[0] == WRITE_6)) { - start_sec = ((u32) (srb->cmnd[1] & 0x1F) << 16) | - ((u32) srb->cmnd[2] << 8) | ((u32) srb->cmnd[3]); - sec_cnt = srb->cmnd[4]; - } else if ((srb->cmnd[0] == VENDOR_CMND) && - (srb->cmnd[1] == SCSI_APP_CMD) && - ((srb->cmnd[2] == PP_READ10) || - (srb->cmnd[2] == PP_WRITE10))) { - start_sec = ((u32) srb->cmnd[4] << 24) | - ((u32) srb->cmnd[5] << 16) | - ((u32) srb->cmnd[6] << 8) | - ((u32) srb->cmnd[7]); - sec_cnt = ((u16) (srb->cmnd[9]) << 8) | srb->cmnd[10]; - } else { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - if ((start_sec > chip->capacity[lun]) || - ((start_sec + sec_cnt) > chip->capacity[lun])) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_LBA_OVER_RANGE); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - if (sec_cnt == 0) { - scsi_set_resid(srb, 0); - return TRANSPORT_GOOD; - } - - if ((srb->sc_data_direction == DMA_TO_DEVICE) - && check_card_wp(chip, lun)) { - RTS51X_DEBUGP("Write protected card!\n"); - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_PROTECT); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - retval = rts51x_card_rw(srb, chip, start_sec, sec_cnt); - if (retval != STATUS_SUCCESS) { - if (srb->sc_data_direction == DMA_FROM_DEVICE) { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - } else { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR); - } - TRACE_RET(chip, TRANSPORT_FAILED); - } - - scsi_set_resid(srb, 0); - - return TRANSPORT_GOOD; -} - -static int read_format_capacity(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - unsigned char *buf; - unsigned int lun = SCSI_LUN(srb); - unsigned int buf_len; - u8 card = rts51x_get_lun_card(chip, lun); - int desc_cnt; - int i = 0; - - if (!check_card_ready(chip, lun)) { - if (!chip->option.rts51x_mspro_formatter_enable) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - TRACE_RET(chip, TRANSPORT_FAILED); - } - } - - buf_len = (scsi_bufflen(srb) > 12) ? 0x14 : 12; - - buf = kmalloc(buf_len, GFP_KERNEL); - if (buf == NULL) - TRACE_RET(chip, TRANSPORT_ERROR); - - buf[i++] = 0; - buf[i++] = 0; - buf[i++] = 0; - - /* Capacity List Length */ - if ((buf_len > 12) && chip->option.rts51x_mspro_formatter_enable && - (chip->lun2card[lun] & MS_CARD) && (!card || (card == MS_CARD))) { - buf[i++] = 0x10; - desc_cnt = 2; - } else { - buf[i++] = 0x08; - desc_cnt = 1; - } - - while (desc_cnt) { - if (check_card_ready(chip, lun)) { - buf[i++] = (unsigned char)((chip->capacity[lun]) >> 24); - buf[i++] = (unsigned char)((chip->capacity[lun]) >> 16); - buf[i++] = (unsigned char)((chip->capacity[lun]) >> 8); - buf[i++] = (unsigned char)(chip->capacity[lun]); - - if (desc_cnt == 2) - /* Byte[8]: Descriptor Type: Formatted medium */ - buf[i++] = 2; - else - buf[i++] = 0; /* Byte[16] */ - } else { - buf[i++] = 0xFF; - buf[i++] = 0xFF; - buf[i++] = 0xFF; - buf[i++] = 0xFF; - - if (desc_cnt == 2) - /* Byte[8]: Descriptor Type: No medium */ - buf[i++] = 3; - else - buf[i++] = 0; /*Byte[16] */ - } - - buf[i++] = 0x00; - buf[i++] = 0x02; - buf[i++] = 0x00; - - desc_cnt--; - } - - buf_len = min(scsi_bufflen(srb), buf_len); - rts51x_set_xfer_buf(buf, buf_len, srb); - kfree(buf); - - scsi_set_resid(srb, scsi_bufflen(srb) - buf_len); - - return TRANSPORT_GOOD; -} - -static int read_capacity(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - unsigned char *buf; - unsigned int lun = SCSI_LUN(srb); - - if (!check_card_ready(chip, lun)) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - if (!check_lun_mc(chip, lun)) { - set_lun_mc(chip, lun); - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); - return TRANSPORT_FAILED; - } - - buf = kmalloc(8, GFP_KERNEL); - if (buf == NULL) - TRACE_RET(chip, TRANSPORT_ERROR); - - buf[0] = (unsigned char)((chip->capacity[lun] - 1) >> 24); - buf[1] = (unsigned char)((chip->capacity[lun] - 1) >> 16); - buf[2] = (unsigned char)((chip->capacity[lun] - 1) >> 8); - buf[3] = (unsigned char)(chip->capacity[lun] - 1); - - buf[4] = 0x00; - buf[5] = 0x00; - buf[6] = 0x02; - buf[7] = 0x00; - - rts51x_set_xfer_buf(buf, scsi_bufflen(srb), srb); - kfree(buf); - - scsi_set_resid(srb, 0); - - return TRANSPORT_GOOD; -} - -static int get_dev_status(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - unsigned int lun = SCSI_LUN(srb); - unsigned int buf_len; - u8 status[32] = { 0 }; - - rts51x_pp_status(chip, lun, status, 32); - - buf_len = min_t(unsigned int, scsi_bufflen(srb), sizeof(status)); - rts51x_set_xfer_buf(status, buf_len, srb); - scsi_set_resid(srb, scsi_bufflen(srb) - buf_len); - - return TRANSPORT_GOOD; -} - -static int read_status(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - u8 rts51x_status[16]; - unsigned int buf_len; - unsigned int lun = SCSI_LUN(srb); - - rts51x_read_status(chip, lun, rts51x_status, 16); - - buf_len = min_t(unsigned int, scsi_bufflen(srb), sizeof(rts51x_status)); - rts51x_set_xfer_buf(rts51x_status, buf_len, srb); - scsi_set_resid(srb, scsi_bufflen(srb) - buf_len); - - return TRANSPORT_GOOD; -} - -static int read_mem(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - unsigned int lun = SCSI_LUN(srb); - unsigned short addr, len, i; - int retval; - u8 *buf; - - rts51x_prepare_run(chip); - RTS51X_SET_STAT(chip, STAT_RUN); - - addr = ((u16) srb->cmnd[2] << 8) | srb->cmnd[3]; - len = ((u16) srb->cmnd[4] << 8) | srb->cmnd[5]; - - if (addr < 0xe000) { - RTS51X_DEBUGP("filter!addr=0x%x\n", addr); - return TRANSPORT_GOOD; - } - - buf = vmalloc(len); - if (!buf) - TRACE_RET(chip, TRANSPORT_ERROR); - - for (i = 0; i < len; i++) { - retval = rts51x_ep0_read_register(chip, addr + i, buf + i); - if (retval != STATUS_SUCCESS) { - vfree(buf); - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - TRACE_RET(chip, TRANSPORT_FAILED); - } - } - - len = (unsigned short)min(scsi_bufflen(srb), (unsigned int)len); - rts51x_set_xfer_buf(buf, len, srb); - scsi_set_resid(srb, scsi_bufflen(srb) - len); - - vfree(buf); - - return TRANSPORT_GOOD; -} - -static int write_mem(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - unsigned int lun = SCSI_LUN(srb); - unsigned short addr, len, i; - int retval; - u8 *buf; - - rts51x_prepare_run(chip); - RTS51X_SET_STAT(chip, STAT_RUN); - - addr = ((u16) srb->cmnd[2] << 8) | srb->cmnd[3]; - len = ((u16) srb->cmnd[4] << 8) | srb->cmnd[5]; - - if (addr < 0xe000) { - RTS51X_DEBUGP("filter!addr=0x%x\n", addr); - return TRANSPORT_GOOD; - } - - len = (unsigned short)min(scsi_bufflen(srb), (unsigned int)len); - buf = vmalloc(len); - if (!buf) - TRACE_RET(chip, TRANSPORT_ERROR); - - rts51x_get_xfer_buf(buf, len, srb); - - for (i = 0; i < len; i++) { - retval = - rts51x_ep0_write_register(chip, addr + i, 0xFF, buf[i]); - if (retval != STATUS_SUCCESS) { - vfree(buf); - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR); - TRACE_RET(chip, TRANSPORT_FAILED); - } - } - - vfree(buf); - scsi_set_resid(srb, scsi_bufflen(srb) - len); - - return TRANSPORT_GOOD; -} - -static int get_sd_csd(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - struct sd_info *sd_card = &(chip->sd_card); - unsigned int lun = SCSI_LUN(srb); - - if (!check_card_ready(chip, lun)) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - if (rts51x_get_lun_card(chip, lun) != SD_CARD) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - scsi_set_resid(srb, 0); - rts51x_set_xfer_buf(sd_card->raw_csd, scsi_bufflen(srb), srb); - - return TRANSPORT_GOOD; -} - -static int read_phy_register(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - int retval; - u8 addr, len, i; - u8 *buf; - - rts51x_prepare_run(chip); - RTS51X_SET_STAT(chip, STAT_RUN); - - addr = srb->cmnd[5]; - len = srb->cmnd[7]; - - if (len) { - buf = vmalloc(len); - if (!buf) - TRACE_RET(chip, TRANSPORT_ERROR); - - for (i = 0; i < len; i++) { - retval = - rts51x_read_phy_register(chip, addr + i, buf + i); - if (retval != STATUS_SUCCESS) { - vfree(buf); - rts51x_set_sense_type(chip, SCSI_LUN(srb), - SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - TRACE_RET(chip, TRANSPORT_FAILED); - } - } - - len = min(scsi_bufflen(srb), (unsigned int)len); - rts51x_set_xfer_buf(buf, len, srb); - scsi_set_resid(srb, scsi_bufflen(srb) - len); - - vfree(buf); - } - - return TRANSPORT_GOOD; -} - -static int write_phy_register(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - int retval; - u8 addr, len, i; - u8 *buf; - - rts51x_prepare_run(chip); - RTS51X_SET_STAT(chip, STAT_RUN); - - addr = srb->cmnd[5]; - len = srb->cmnd[7]; - - if (len) { - len = min(scsi_bufflen(srb), (unsigned int)len); - - buf = vmalloc(len); - if (buf == NULL) - TRACE_RET(chip, TRANSPORT_ERROR); - - rts51x_get_xfer_buf(buf, len, srb); - scsi_set_resid(srb, scsi_bufflen(srb) - len); - - for (i = 0; i < len; i++) { - retval = - rts51x_write_phy_register(chip, addr + i, buf[i]); - if (retval != STATUS_SUCCESS) { - vfree(buf); - rts51x_set_sense_type(chip, SCSI_LUN(srb), - SENSE_TYPE_MEDIA_WRITE_ERR); - TRACE_RET(chip, TRANSPORT_FAILED); - } - } - - vfree(buf); - } - - return TRANSPORT_GOOD; -} - -static int get_card_bus_width(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - unsigned int lun = SCSI_LUN(srb); - u8 card, bus_width; - - if (!check_card_ready(chip, lun)) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - card = rts51x_get_lun_card(chip, lun); - if ((card == SD_CARD) || (card == MS_CARD)) { - bus_width = chip->card_bus_width[lun]; - } else { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - scsi_set_resid(srb, 0); - rts51x_set_xfer_buf(&bus_width, scsi_bufflen(srb), srb); - - return TRANSPORT_GOOD; -} - -#ifdef _MSG_TRACE -static int trace_msg_cmd(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - unsigned char *buf = NULL; - u8 clear; - unsigned int buf_len; - - buf_len = - 4 + - ((2 + MSG_FUNC_LEN + MSG_FILE_LEN + TIME_VAL_LEN) * TRACE_ITEM_CNT); - - if ((scsi_bufflen(srb) < buf_len) || (scsi_sglist(srb) == NULL)) { - rts51x_set_sense_type(chip, SCSI_LUN(srb), - SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - clear = srb->cmnd[2]; - - buf = vmalloc(scsi_bufflen(srb)); - if (buf == NULL) - TRACE_RET(chip, TRANSPORT_ERROR); - - rts51x_trace_msg(chip, buf, clear); - - rts51x_set_xfer_buf(buf, scsi_bufflen(srb), srb); - vfree(buf); - - scsi_set_resid(srb, 0); - return TRANSPORT_GOOD; -} -#endif - -static int rw_mem_cmd_buf(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - int retval = STATUS_SUCCESS; - unsigned int lun = SCSI_LUN(srb); - u8 cmd_type, mask, value, idx, mode, len; - u16 addr; - u32 timeout; - - rts51x_prepare_run(chip); - RTS51X_SET_STAT(chip, STAT_RUN); - - switch (srb->cmnd[3]) { - case INIT_BATCHCMD: - rts51x_init_cmd(chip); - break; - - case ADD_BATCHCMD: - cmd_type = srb->cmnd[4]; - if (cmd_type > 2) { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - addr = (srb->cmnd[5] << 8) | srb->cmnd[6]; - mask = srb->cmnd[7]; - value = srb->cmnd[8]; - rts51x_add_cmd(chip, cmd_type, addr, mask, value); - break; - - case SEND_BATCHCMD: - mode = srb->cmnd[4]; - len = srb->cmnd[5]; - timeout = - ((u32) srb->cmnd[6] << 24) | ((u32) srb-> - cmnd[7] << 16) | ((u32) srb-> - cmnd[8] << - 8) | ((u32) - srb-> - cmnd - [9]); - retval = rts51x_send_cmd(chip, mode, 1000); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR); - TRACE_RET(chip, TRANSPORT_FAILED); - } - if (mode & STAGE_R) { - retval = rts51x_get_rsp(chip, len, timeout); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - TRACE_RET(chip, TRANSPORT_FAILED); - } - } - break; - - case GET_BATCHRSP: - idx = srb->cmnd[4]; - value = chip->rsp_buf[idx]; - if (scsi_bufflen(srb) < 1) { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - rts51x_set_xfer_buf(&value, 1, srb); - scsi_set_resid(srb, 0); - break; - - default: - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - return TRANSPORT_GOOD; -} - -static int suit_cmd(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - int result; - - switch (srb->cmnd[3]) { - case INIT_BATCHCMD: - case ADD_BATCHCMD: - case SEND_BATCHCMD: - case GET_BATCHRSP: - result = rw_mem_cmd_buf(srb, chip); - break; - default: - result = TRANSPORT_ERROR; - } - - return result; -} - -static int app_cmd(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - int result; - - switch (srb->cmnd[2]) { - case PP_READ10: - case PP_WRITE10: - result = read_write(srb, chip); - break; - - case SUIT_CMD: - result = suit_cmd(srb, chip); - break; - - case READ_PHY: - result = read_phy_register(srb, chip); - break; - - case WRITE_PHY: - result = write_phy_register(srb, chip); - break; - - case GET_DEV_STATUS: - result = get_dev_status(srb, chip); - break; - - default: - rts51x_set_sense_type(chip, SCSI_LUN(srb), - SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - return result; -} - -static int vendor_cmnd(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - int result = TRANSPORT_GOOD; - - switch (srb->cmnd[1]) { - case READ_STATUS: - result = read_status(srb, chip); - break; - - case READ_MEM: - result = read_mem(srb, chip); - break; - - case WRITE_MEM: - result = write_mem(srb, chip); - break; - - case GET_BUS_WIDTH: - result = get_card_bus_width(srb, chip); - break; - - case GET_SD_CSD: - result = get_sd_csd(srb, chip); - break; - -#ifdef _MSG_TRACE - case TRACE_MSG: - result = trace_msg_cmd(srb, chip); - break; -#endif - - case SCSI_APP_CMD: - result = app_cmd(srb, chip); - break; - - default: - rts51x_set_sense_type(chip, SCSI_LUN(srb), - SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - return result; -} - -static int ms_format_cmnd(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - struct ms_info *ms_card = &(chip->ms_card); - unsigned int lun = SCSI_LUN(srb); - int retval, quick_format; - - if (rts51x_get_lun_card(chip, lun) != MS_CARD) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - if ((srb->cmnd[3] != 0x4D) || (srb->cmnd[4] != 0x47) - || (srb->cmnd[5] != 0x66) || (srb->cmnd[6] != 0x6D) - || (srb->cmnd[7] != 0x74)) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - if (srb->cmnd[8] & 0x01) - quick_format = 0; - else - quick_format = 1; - - if (!(chip->card_ready & MS_CARD)) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - if (chip->card_wp & MS_CARD) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_PROTECT); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - if (!CHK_MSPRO(ms_card)) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - rts51x_prepare_run(chip); - RTS51X_SET_STAT(chip, STAT_RUN); - - retval = rts51x_mspro_format(srb, chip, MS_SHORT_DATA_LEN, quick_format); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_FORMAT_CMD_FAILED); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - scsi_set_resid(srb, 0); - return TRANSPORT_GOOD; -} - -#ifdef SUPPORT_PCGL_1P18 -static int get_ms_information(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - struct ms_info *ms_card = &(chip->ms_card); - unsigned int lun = SCSI_LUN(srb); - u8 dev_info_id, data_len; - u8 *buf; - unsigned int buf_len; - int i; - - if (!check_card_ready(chip, lun)) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - TRACE_RET(chip, TRANSPORT_FAILED); - } - if ((rts51x_get_lun_card(chip, lun) != MS_CARD)) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - if ((srb->cmnd[2] != 0xB0) || (srb->cmnd[4] != 0x4D) || - (srb->cmnd[5] != 0x53) || (srb->cmnd[6] != 0x49) || - (srb->cmnd[7] != 0x44)) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - dev_info_id = srb->cmnd[3]; - if ((CHK_MSXC(ms_card) && (dev_info_id == 0x10)) || - (!CHK_MSXC(ms_card) && (dev_info_id == 0x13)) || - !CHK_MSPRO(ms_card)) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - if (dev_info_id == 0x15) - buf_len = data_len = 0x3A; - else - buf_len = data_len = 0x6A; - - buf = kmalloc(buf_len, GFP_KERNEL); - if (!buf) - TRACE_RET(chip, TRANSPORT_ERROR); - - i = 0; - /* GET Memory Stick Media Information Response Header */ - buf[i++] = 0x00; /* Data length MSB */ - buf[i++] = data_len; /* Data length LSB */ - /* Device Information Type Code */ - if (CHK_MSXC(ms_card)) - buf[i++] = 0x03; - else - buf[i++] = 0x02; - /* SGM bit */ - buf[i++] = 0x01; - /* Reserved */ - buf[i++] = 0x00; - buf[i++] = 0x00; - buf[i++] = 0x00; - /* Number of Device Information */ - buf[i++] = 0x01; - - /* Device Information Body - * Device Information ID Number */ - buf[i++] = dev_info_id; - /* Device Information Length */ - if (dev_info_id == 0x15) - data_len = 0x31; - else - data_len = 0x61; - buf[i++] = 0x00; /* Data length MSB */ - buf[i++] = data_len; /* Data length LSB */ - /* Valid Bit */ - buf[i++] = 0x80; - if ((dev_info_id == 0x10) || (dev_info_id == 0x13)) { - /* System Information */ - memcpy(buf + i, ms_card->raw_sys_info, 96); - } else { - /* Model Name */ - memcpy(buf + i, ms_card->raw_model_name, 48); - } - - rts51x_set_xfer_buf(buf, buf_len, srb); - - if (dev_info_id == 0x15) - scsi_set_resid(srb, scsi_bufflen(srb) - 0x3C); - else - scsi_set_resid(srb, scsi_bufflen(srb) - 0x6C); - - kfree(buf); - return STATUS_SUCCESS; -} -#endif - -static int ms_sp_cmnd(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - int retval = TRANSPORT_ERROR; - - if (srb->cmnd[2] == MS_FORMAT) - retval = ms_format_cmnd(srb, chip); -#ifdef SUPPORT_PCGL_1P18 - else if (srb->cmnd[2] == GET_MS_INFORMATION) - retval = get_ms_information(srb, chip); -#endif - - return retval; -} - -#ifdef SUPPORT_CPRM -static int sd_extention_cmnd(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - unsigned int lun = SCSI_LUN(srb); - int result; - - rts51x_prepare_run(chip); - RTS51X_SET_STAT(chip, STAT_RUN); - - rts51x_sd_cleanup_work(chip); - - if (!check_card_ready(chip, lun)) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - TRACE_RET(chip, TRANSPORT_FAILED); - } - if ((rts51x_get_lun_card(chip, lun) != SD_CARD)) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - switch (srb->cmnd[0]) { - case SD_PASS_THRU_MODE: - result = rts51x_sd_pass_thru_mode(srb, chip); - break; - - case SD_EXECUTE_NO_DATA: - result = rts51x_sd_execute_no_data(srb, chip); - break; - - case SD_EXECUTE_READ: - result = rts51x_sd_execute_read_data(srb, chip); - break; - - case SD_EXECUTE_WRITE: - result = rts51x_sd_execute_write_data(srb, chip); - break; - - case SD_GET_RSP: - result = rts51x_sd_get_cmd_rsp(srb, chip); - break; - - case SD_HW_RST: - result = rts51x_sd_hw_rst(srb, chip); - break; - - default: - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - return result; -} -#endif - -#ifdef SUPPORT_MAGIC_GATE -static int mg_report_key(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - struct ms_info *ms_card = &(chip->ms_card); - unsigned int lun = SCSI_LUN(srb); - int retval; - u8 key_format; - - rts51x_prepare_run(chip); - RTS51X_SET_STAT(chip, STAT_RUN); - - rts51x_ms_cleanup_work(chip); - - if (!check_card_ready(chip, lun)) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - TRACE_RET(chip, TRANSPORT_FAILED); - } - if ((rts51x_get_lun_card(chip, lun) != MS_CARD)) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - if (srb->cmnd[7] != KC_MG_R_PRO) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - if (!CHK_MSPRO(ms_card)) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - key_format = srb->cmnd[10] & 0x3F; - - switch (key_format) { - case KF_GET_LOC_EKB: - if ((scsi_bufflen(srb) == 0x41C) && - (srb->cmnd[8] == 0x04) && (srb->cmnd[9] == 0x1C)) { - retval = rts51x_mg_get_local_EKB(srb, chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, TRANSPORT_FAILED); - } else { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - break; - - case KF_RSP_CHG: - if ((scsi_bufflen(srb) == 0x24) && - (srb->cmnd[8] == 0x00) && (srb->cmnd[9] == 0x24)) { - retval = rts51x_mg_get_rsp_chg(srb, chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, TRANSPORT_FAILED); - } else { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - break; - - case KF_GET_ICV: - ms_card->mg_entry_num = srb->cmnd[5]; - if ((scsi_bufflen(srb) == 0x404) && - (srb->cmnd[8] == 0x04) && - (srb->cmnd[9] == 0x04) && - (srb->cmnd[2] == 0x00) && - (srb->cmnd[3] == 0x00) && - (srb->cmnd[4] == 0x00) && (srb->cmnd[5] < 32)) { - retval = rts51x_mg_get_ICV(srb, chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, TRANSPORT_FAILED); - } else { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - break; - - default: - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - scsi_set_resid(srb, 0); - return TRANSPORT_GOOD; -} - -static int mg_send_key(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - struct ms_info *ms_card = &(chip->ms_card); - unsigned int lun = SCSI_LUN(srb); - int retval; - u8 key_format; - - rts51x_prepare_run(chip); - RTS51X_SET_STAT(chip, STAT_RUN); - - rts51x_ms_cleanup_work(chip); - - if (!check_card_ready(chip, lun)) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - TRACE_RET(chip, TRANSPORT_FAILED); - } - if (check_card_wp(chip, lun)) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_PROTECT); - TRACE_RET(chip, TRANSPORT_FAILED); - } - if ((rts51x_get_lun_card(chip, lun) != MS_CARD)) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - if (srb->cmnd[7] != KC_MG_R_PRO) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - if (!CHK_MSPRO(ms_card)) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - key_format = srb->cmnd[10] & 0x3F; - - switch (key_format) { - case KF_SET_LEAF_ID: - if ((scsi_bufflen(srb) == 0x0C) && - (srb->cmnd[8] == 0x00) && (srb->cmnd[9] == 0x0C)) { - retval = rts51x_mg_set_leaf_id(srb, chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, TRANSPORT_FAILED); - } else { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - break; - - case KF_CHG_HOST: - if ((scsi_bufflen(srb) == 0x0C) && - (srb->cmnd[8] == 0x00) && (srb->cmnd[9] == 0x0C)) { - retval = rts51x_mg_chg(srb, chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, TRANSPORT_FAILED); - } else { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - break; - - case KF_RSP_HOST: - if ((scsi_bufflen(srb) == 0x0C) && - (srb->cmnd[8] == 0x00) && (srb->cmnd[9] == 0x0C)) { - retval = rts51x_mg_rsp(srb, chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, TRANSPORT_FAILED); - } else { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - break; - - case KF_SET_ICV: - ms_card->mg_entry_num = srb->cmnd[5]; - if ((scsi_bufflen(srb) == 0x404) && - (srb->cmnd[8] == 0x04) && - (srb->cmnd[9] == 0x04) && - (srb->cmnd[2] == 0x00) && - (srb->cmnd[3] == 0x00) && - (srb->cmnd[4] == 0x00) && (srb->cmnd[5] < 32)) { - retval = rts51x_mg_set_ICV(srb, chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, TRANSPORT_FAILED); - } else { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - break; - - default: - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - scsi_set_resid(srb, 0); - return TRANSPORT_GOOD; -} -#endif - -int rts51x_scsi_handler(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - struct ms_info *ms_card = &(chip->ms_card); - unsigned int lun = SCSI_LUN(srb); - int result = TRANSPORT_GOOD; - - if ((rts51x_get_lun_card(chip, lun) == MS_CARD) && - (ms_card->format_status == FORMAT_IN_PROGRESS)) { - if ((srb->cmnd[0] != REQUEST_SENSE) - && (srb->cmnd[0] != INQUIRY)) { - /* Logical Unit Not Ready Format in Progress */ - rts51x_set_sense_data(chip, lun, CUR_ERR, 0x02, 0, 0x04, 0x04, - 0, (u16) (ms_card->progress)); - TRACE_RET(chip, TRANSPORT_FAILED); - } - } - - switch (srb->cmnd[0]) { - case READ_10: - case WRITE_10: - case READ_6: - case WRITE_6: - result = read_write(srb, chip); - break; - - case TEST_UNIT_READY: - result = test_unit_ready(srb, chip); - break; - - case INQUIRY: - result = inquiry(srb, chip); - break; - - case READ_CAPACITY: - result = read_capacity(srb, chip); - break; - - case START_STOP: - result = start_stop_unit(srb, chip); - break; - - case ALLOW_MEDIUM_REMOVAL: - result = allow_medium_removal(srb, chip); - break; - - case REQUEST_SENSE: - result = request_sense(srb, chip); - break; - - case MODE_SENSE: - case MODE_SENSE_10: - result = mode_sense(srb, chip); - break; - - case 0x23: - result = read_format_capacity(srb, chip); - break; - - case VENDOR_CMND: - result = vendor_cmnd(srb, chip); - break; - - case MS_SP_CMND: - result = ms_sp_cmnd(srb, chip); - break; - -#ifdef SUPPORT_CPRM - case SD_PASS_THRU_MODE: - case SD_EXECUTE_NO_DATA: - case SD_EXECUTE_READ: - case SD_EXECUTE_WRITE: - case SD_GET_RSP: - case SD_HW_RST: - result = sd_extention_cmnd(srb, chip); - break; -#endif - -#ifdef SUPPORT_MAGIC_GATE - case CMD_MSPRO_MG_RKEY: - result = mg_report_key(srb, chip); - break; - - case CMD_MSPRO_MG_SKEY: - result = mg_send_key(srb, chip); - break; -#endif - - case FORMAT_UNIT: - case MODE_SELECT: - case VERIFY: - result = TRANSPORT_GOOD; - break; - - default: - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - result = TRANSPORT_FAILED; - } - - return result; -} - -/*********************************************************************** - * Host functions - ***********************************************************************/ - -int slave_alloc(struct scsi_device *sdev) -{ - /* - * Set the INQUIRY transfer length to 36. We don't use any of - * the extra data and many devices choke if asked for more or - * less than 36 bytes. - */ - sdev->inquiry_len = 36; - return 0; -} - -int slave_configure(struct scsi_device *sdev) -{ - /* Scatter-gather buffers (all but the last) must have a length - * divisible by the bulk maxpacket size. Otherwise a data packet - * would end up being short, causing a premature end to the data - * transfer. Since high-speed bulk pipes have a maxpacket size - * of 512, we'll use that as the scsi device queue's DMA alignment - * mask. Guaranteeing proper alignment of the first buffer will - * have the desired effect because, except at the beginning and - * the end, scatter-gather buffers follow page boundaries. */ - blk_queue_dma_alignment(sdev->request_queue, (512 - 1)); - - /* Set the SCSI level to at least 2. We'll leave it at 3 if that's - * what is originally reported. We need this to avoid confusing - * the SCSI layer with devices that report 0 or 1, but need 10-byte - * commands (ala ATAPI devices behind certain bridges, or devices - * which simply have broken INQUIRY data). - * - * NOTE: This means /dev/sg programs (ala cdrecord) will get the - * actual information. This seems to be the preference for - * programs like that. - * - * NOTE: This also means that /proc/scsi/scsi and sysfs may report - * the actual value or the modified one, depending on where the - * data comes from. - */ - if (sdev->scsi_level < SCSI_2) - sdev->scsi_level = sdev->sdev_target->scsi_level = SCSI_2; - - return 0; -} - -/*********************************************************************** - * /proc/scsi/ functions - ***********************************************************************/ - -/* we use this macro to help us write into the buffer */ -#undef SPRINTF -#define SPRINTF(args...) seq_printf(m, ##args) - -static int write_info(struct Scsi_Host *host, char *buffer, int length) -{ - /* if someone is sending us data, just throw it away */ - return length; -} - -static int show_info(struct seq_file *m, struct Scsi_Host *host) -{ - /* print the controller name */ - SPRINTF(" Host scsi%d: %s\n", host->host_no, RTS51X_NAME); - - /* print product, vendor, and driver version strings */ - SPRINTF(" Vendor: Realtek Corp.\n"); - SPRINTF(" Product: RTS51xx USB Card Reader\n"); - SPRINTF(" Version: %s\n", DRIVER_VERSION); - return 0; -} - -/* queue a command */ -/* This is always called with scsi_lock(host) held */ -static int queuecommand_lck(struct scsi_cmnd *srb, void (*done) (struct scsi_cmnd *)) -{ - struct rts51x_chip *chip = host_to_rts51x(srb->device->host); - - /* check for state-transition errors */ - if (chip->srb != NULL) { - RTS51X_DEBUGP("Error in %s: chip->srb = %p\n", - __func__, chip->srb); - return SCSI_MLQUEUE_HOST_BUSY; - } - - /* fail the command if we are disconnecting */ - if (test_bit(FLIDX_DISCONNECTING, &chip->usb->dflags)) { - RTS51X_DEBUGP("Fail command during disconnect\n"); - srb->result = DID_NO_CONNECT << 16; - done(srb); - return 0; - } - - /* enqueue the command and wake up the control thread */ - srb->scsi_done = done; - chip->srb = srb; - complete(&chip->usb->cmnd_ready); - - return 0; -} - -DEF_SCSI_QCMD(queuecommand) -/*********************************************************************** - * Error handling functions - ***********************************************************************/ -/* Command timeout and abort */ -int command_abort(struct scsi_cmnd *srb) -{ - struct rts51x_chip *chip = host_to_rts51x(srb->device->host); - - RTS51X_DEBUGP("%s called\n", __func__); - - /* us->srb together with the TIMED_OUT, RESETTING, and ABORTING - * bits are protected by the host lock. */ - scsi_lock(rts51x_to_host(chip)); - - /* Is this command still active? */ - if (chip->srb != srb) { - scsi_unlock(rts51x_to_host(chip)); - RTS51X_DEBUGP("-- nothing to abort\n"); - return FAILED; - } - - /* Set the TIMED_OUT bit. Also set the ABORTING bit, but only if - * a device reset isn't already in progress (to avoid interfering - * with the reset). Note that we must retain the host lock while - * calling usb_stor_stop_transport(); otherwise it might interfere - * with an auto-reset that begins as soon as we release the lock. */ - set_bit(FLIDX_TIMED_OUT, &chip->usb->dflags); - if (!test_bit(FLIDX_RESETTING, &chip->usb->dflags)) { - set_bit(FLIDX_ABORTING, &chip->usb->dflags); - /* rts51x_stop_transport(us); */ - } - scsi_unlock(rts51x_to_host(chip)); - - /* Wait for the aborted command to finish */ - wait_for_completion(&chip->usb->notify); - return SUCCESS; -} - -/* This invokes the transport reset mechanism to reset the state of the - * device */ -static int device_reset(struct scsi_cmnd *srb) -{ - int result = 0; - - RTS51X_DEBUGP("%s called\n", __func__); - - return result < 0 ? FAILED : SUCCESS; -} - -/* Simulate a SCSI bus reset by resetting the device's USB port. */ -int bus_reset(struct scsi_cmnd *srb) -{ - int result = 0; - - RTS51X_DEBUGP("%s called\n", __func__); - - return result < 0 ? FAILED : SUCCESS; -} - -static const char *rts5139_info(struct Scsi_Host *host) -{ - return "SCSI emulation for RTS5139 USB card reader"; -} - -struct scsi_host_template rts51x_host_template = { - /* basic userland interface stuff */ - .name = RTS51X_NAME, - .proc_name = RTS51X_NAME, - .show_info = show_info, - .write_info = write_info, - .info = rts5139_info, - - /* command interface -- queued only */ - .queuecommand = queuecommand, - - /* error and abort handlers */ - .eh_abort_handler = command_abort, - .eh_device_reset_handler = device_reset, - .eh_bus_reset_handler = bus_reset, - - /* queue commands only, only one command per LUN */ - .can_queue = 1, - .cmd_per_lun = 1, - - /* unknown initiator id */ - .this_id = -1, - - .slave_alloc = slave_alloc, - .slave_configure = slave_configure, - - /* lots of sg segments can be handled */ - .sg_tablesize = SG_ALL, - - /* limit the total size of a transfer to 120 KB */ - .max_sectors = 240, - - /* merge commands... this seems to help performance, but - * periodically someone should test to see which setting is more - * optimal. - */ - .use_clustering = 1, - - /* emulated HBA */ - .emulated = 1, - - /* we do our own delay after a device or bus reset */ - .skip_settle_delay = 1, - - /* sysfs device attributes */ - /* .sdev_attrs = sysfs_device_attr_list, */ - - /* module management */ - .module = THIS_MODULE -}; - diff --git a/drivers/staging/rts5139/rts51x_scsi.h b/drivers/staging/rts5139/rts51x_scsi.h deleted file mode 100644 index 1a0d70566186..000000000000 --- a/drivers/staging/rts5139/rts51x_scsi.h +++ /dev/null @@ -1,154 +0,0 @@ -/* Driver for Realtek RTS51xx USB card reader - * Header file - * - * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. - * - * 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, 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, see . - * - * Author: - * wwang (wei_wang@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - * Maintainer: - * Edwin Rong (edwin_rong@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - */ - -#ifndef __RTS51X_SCSI_H -#define __RTS51X_SCSI_H - -#include -#include -#include -#include -#include -#include - -#include "rts51x_chip.h" - -#define MS_SP_CMND 0xFA -#define MS_FORMAT 0xA0 -#define GET_MS_INFORMATION 0xB0 - -#define VENDOR_CMND 0xF0 - -#define READ_STATUS 0x09 - -#define READ_MEM 0x0D -#define WRITE_MEM 0x0E -#define GET_BUS_WIDTH 0x13 -#define GET_SD_CSD 0x14 -#define TOGGLE_GPIO 0x15 -#define TRACE_MSG 0x18 - -#define SCSI_APP_CMD 0x10 - -#define PP_READ10 0x1A -#define PP_WRITE10 0x0A -#define READ_HOST_REG 0x1D -#define WRITE_HOST_REG 0x0D -#define SET_VAR 0x05 -#define GET_VAR 0x15 -#define DMA_READ 0x16 -#define DMA_WRITE 0x06 -#define GET_DEV_STATUS 0x10 -#define SET_CHIP_MODE 0x27 -#define SUIT_CMD 0xE0 -#define WRITE_PHY 0x07 -#define READ_PHY 0x17 - -#define INIT_BATCHCMD 0x41 -#define ADD_BATCHCMD 0x42 -#define SEND_BATCHCMD 0x43 -#define GET_BATCHRSP 0x44 - -#ifdef SUPPORT_CPRM -/* SD Pass Through Command Extension */ -#define SD_PASS_THRU_MODE 0xD0 -#define SD_EXECUTE_NO_DATA 0xD1 -#define SD_EXECUTE_READ 0xD2 -#define SD_EXECUTE_WRITE 0xD3 -#define SD_GET_RSP 0xD4 -#define SD_HW_RST 0xD6 -#endif - -#ifdef SUPPORT_MAGIC_GATE -#define CMD_MSPRO_MG_RKEY 0xA4 /* Report Key Command */ -#define CMD_MSPRO_MG_SKEY 0xA3 /* Send Key Command */ - -/* CBWCB field: key class */ -#define KC_MG_R_PRO 0xBE /* MG-R PRO */ - -/* CBWCB field: key format */ -#define KF_SET_LEAF_ID 0x31 /* Set Leaf ID */ -#define KF_GET_LOC_EKB 0x32 /* Get Local EKB */ -#define KF_CHG_HOST 0x33 /* Challenge (host) */ -#define KF_RSP_CHG 0x34 /* Response and Challenge (device) */ -#define KF_RSP_HOST 0x35 /* Response (host) */ -#define KF_GET_ICV 0x36 /* Get ICV */ -#define KF_SET_ICV 0x37 /* SSet ICV */ -#endif - -struct rts51x_chip; - -/*----------------------------------- - Start-Stop-Unit ------------------------------------*/ -#define STOP_MEDIUM 0x00 /* access disable */ -#define MAKE_MEDIUM_READY 0x01 /* access enable */ -#define UNLOAD_MEDIUM 0x02 /* unload */ -#define LOAD_MEDIUM 0x03 /* load */ - -/*----------------------------------- - STANDARD_INQUIRY ------------------------------------*/ -#define QULIFIRE 0x00 -#define AENC_FNC 0x00 -#define TRML_IOP 0x00 -#define REL_ADR 0x00 -#define WBUS_32 0x00 -#define WBUS_16 0x00 -#define SYNC 0x00 -#define LINKED 0x00 -#define CMD_QUE 0x00 -#define SFT_RE 0x00 - -#define VEN_ID_LEN 8 /* Vendor ID Length */ -#define PRDCT_ID_LEN 16 /* Product ID Length */ -#define PRDCT_REV_LEN 4 /* Product LOT Length */ - -#define DRCT_ACCESS_DEV 0x00 /* Direct Access Device */ -#define RMB_DISC 0x80 /* The Device is Removable */ -#define ANSI_SCSI2 0x02 /* Based on ANSI-SCSI2 */ - -#define SCSI 0x00 /* Interface ID */ - -void rts51x_scsi_show_command(struct scsi_cmnd *srb); -void rts51x_set_sense_type(struct rts51x_chip *chip, unsigned int lun, int sense_type); -void rts51x_set_sense_data(struct rts51x_chip *chip, unsigned int lun, u8 err_code, - u8 sense_key, u32 info, u8 asc, u8 ascq, u8 sns_key_info0, - u16 sns_key_info1); - -int rts51x_scsi_handler(struct scsi_cmnd *srb, struct rts51x_chip *chip); - -struct Scsi_Host; -struct scsi_device; -struct scsi_cmnd; - -int slave_alloc(struct scsi_device *sdev); -int slave_configure(struct scsi_device *sdev); -int queuecommand(struct Scsi_Host *, struct scsi_cmnd *); -int command_abort(struct scsi_cmnd *srb); -int bus_reset(struct scsi_cmnd *srb); - -#endif /* __RTS51X_SCSI_H */ diff --git a/drivers/staging/rts5139/rts51x_transport.c b/drivers/staging/rts5139/rts51x_transport.c deleted file mode 100644 index 0db1345df94e..000000000000 --- a/drivers/staging/rts5139/rts51x_transport.c +++ /dev/null @@ -1,738 +0,0 @@ -/* Driver for Realtek RTS51xx USB card reader - * - * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. - * - * 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, 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, see . - * - * Author: - * wwang (wei_wang@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - * Maintainer: - * Edwin Rong (edwin_rong@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - */ - -#include -#include -#include -#include - -#include -#include -#include - -#include "debug.h" -#include "rts51x.h" -#include "rts51x_chip.h" -#include "rts51x_card.h" -#include "rts51x_scsi.h" -#include "rts51x_transport.h" -#include "trace.h" - -/*********************************************************************** - * Scatter-gather transfer buffer access routines - ***********************************************************************/ - -/* Copy a buffer of length buflen to/from the srb's transfer buffer. - * Update the **sgptr and *offset variables so that the next copy will - * pick up from where this one left off. - */ - -unsigned int rts51x_access_sglist(unsigned char *buffer, - unsigned int buflen, void *sglist, - void **sgptr, unsigned int *offset, - enum xfer_buf_dir dir) -{ - unsigned int cnt; - struct scatterlist *sg = (struct scatterlist *)*sgptr; - - /* We have to go through the list one entry - * at a time. Each s-g entry contains some number of pages, and - * each page has to be kmap()'ed separately. If the page is already - * in kernel-addressable memory then kmap() will return its address. - * If the page is not directly accessible -- such as a user buffer - * located in high memory -- then kmap() will map it to a temporary - * position in the kernel's virtual address space. - */ - - if (!sg) - sg = (struct scatterlist *)sglist; - - /* This loop handles a single s-g list entry, which may - * include multiple pages. Find the initial page structure - * and the starting offset within the page, and update - * the *offset and **sgptr values for the next loop. - */ - cnt = 0; - while (cnt < buflen && sg) { - struct page *page = sg_page(sg) + - ((sg->offset + *offset) >> PAGE_SHIFT); - unsigned int poff = (sg->offset + *offset) & (PAGE_SIZE - 1); - unsigned int sglen = sg->length - *offset; - - if (sglen > buflen - cnt) { - - /* Transfer ends within this s-g entry */ - sglen = buflen - cnt; - *offset += sglen; - } else { - - /* Transfer continues to next s-g entry */ - *offset = 0; - sg = sg_next(sg); - } - - /* Transfer the data for all the pages in this - * s-g entry. For each page: call kmap(), do the - * transfer, and call kunmap() immediately after. */ - while (sglen > 0) { - unsigned int plen = min(sglen, (unsigned int) - PAGE_SIZE - poff); - unsigned char *ptr = kmap(page); - - if (dir == TO_XFER_BUF) - memcpy(ptr + poff, buffer + cnt, plen); - else - memcpy(buffer + cnt, ptr + poff, plen); - kunmap(page); - - /* Start at the beginning of the next page */ - poff = 0; - ++page; - cnt += plen; - sglen -= plen; - } - } - *sgptr = sg; - - /* Return the amount actually transferred */ - return cnt; -} - -static unsigned int rts51x_access_xfer_buf(unsigned char *buffer, - unsigned int buflen, struct scsi_cmnd *srb, - struct scatterlist **sgptr, - unsigned int *offset, enum xfer_buf_dir dir) -{ - return rts51x_access_sglist(buffer, buflen, (void *)scsi_sglist(srb), - (void **)sgptr, offset, dir); -} - -/* Store the contents of buffer into srb's transfer buffer and set the - * SCSI residue. - */ -void rts51x_set_xfer_buf(unsigned char *buffer, - unsigned int buflen, struct scsi_cmnd *srb) -{ - unsigned int offset = 0; - struct scatterlist *sg = NULL; - - buflen = min(buflen, scsi_bufflen(srb)); - buflen = rts51x_access_xfer_buf(buffer, buflen, srb, &sg, &offset, - TO_XFER_BUF); - if (buflen < scsi_bufflen(srb)) - scsi_set_resid(srb, scsi_bufflen(srb) - buflen); -} - -void rts51x_get_xfer_buf(unsigned char *buffer, - unsigned int buflen, struct scsi_cmnd *srb) -{ - unsigned int offset = 0; - struct scatterlist *sg = NULL; - - buflen = min(buflen, scsi_bufflen(srb)); - buflen = rts51x_access_xfer_buf(buffer, buflen, srb, &sg, &offset, - FROM_XFER_BUF); - if (buflen < scsi_bufflen(srb)) - scsi_set_resid(srb, scsi_bufflen(srb) - buflen); -} - -/* This is the completion handler which will wake us up when an URB - * completes. - */ -static void urb_done_completion(struct urb *urb) -{ - struct completion *urb_done_ptr = urb->context; - - if (urb_done_ptr) - complete(urb_done_ptr); -} - -/* This is the common part of the URB message submission code - * - * All URBs from the driver involved in handling a queued scsi - * command _must_ pass through this function (or something like it) for the - * abort mechanisms to work properly. - */ -static int rts51x_msg_common(struct rts51x_chip *chip, struct urb *urb, - int timeout) -{ - struct rts51x_usb *rts51x = chip->usb; - struct completion urb_done; - long timeleft; - int status; - - /* don't submit URBs during abort processing */ - if (test_bit(FLIDX_ABORTING, &rts51x->dflags)) - TRACE_RET(chip, -EIO); - - /* set up data structures for the wakeup system */ - init_completion(&urb_done); - - /* fill the common fields in the URB */ - urb->context = &urb_done; - urb->actual_length = 0; - urb->error_count = 0; - urb->status = 0; - - /* we assume that if transfer_buffer isn't us->iobuf then it - * hasn't been mapped for DMA. Yes, this is clunky, but it's - * easier than always having the caller tell us whether the - * transfer buffer has already been mapped. */ - urb->transfer_flags = URB_NO_SETUP_DMA_MAP; - if (urb->transfer_buffer == rts51x->iobuf) { - urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; - urb->transfer_dma = rts51x->iobuf_dma; - } - urb->setup_dma = rts51x->cr_dma; - - /* submit the URB */ - status = usb_submit_urb(urb, GFP_NOIO); - if (status) { - /* something went wrong */ - TRACE_RET(chip, status); - } - - /* since the URB has been submitted successfully, it's now okay - * to cancel it */ - set_bit(FLIDX_URB_ACTIVE, &rts51x->dflags); - - /* did an abort occur during the submission? */ - if (test_bit(FLIDX_ABORTING, &rts51x->dflags)) { - - /* cancel the URB, if it hasn't been cancelled already */ - if (test_and_clear_bit(FLIDX_URB_ACTIVE, &rts51x->dflags)) { - RTS51X_DEBUGP("-- cancelling URB\n"); - usb_unlink_urb(urb); - } - } - - /* wait for the completion of the URB */ - timeleft = - wait_for_completion_interruptible_timeout(&urb_done, - (timeout * HZ / - 1000) ? : - MAX_SCHEDULE_TIMEOUT); - - clear_bit(FLIDX_URB_ACTIVE, &rts51x->dflags); - - if (timeleft <= 0) { - RTS51X_DEBUGP("%s -- cancelling URB\n", - timeleft == 0 ? "Timeout" : "Signal"); - usb_kill_urb(urb); - if (timeleft == 0) - status = -ETIMEDOUT; - else - status = -EINTR; - } else { - status = urb->status; - } - - return status; -} - -static int rts51x_clear_halt(struct rts51x_chip *chip, unsigned int pipe); - -/* - * Interpret the results of a URB transfer - */ -static int interpret_urb_result(struct rts51x_chip *chip, unsigned int pipe, - unsigned int length, int result, - unsigned int partial) -{ - int retval = STATUS_SUCCESS; - - /* RTS51X_DEBUGP("Status code %d; transferred %u/%u\n", - result, partial, length); */ - switch (result) { - /* no error code; did we send all the data? */ - case 0: - if (partial != length) { - RTS51X_DEBUGP("-- short transfer\n"); - TRACE_RET(chip, STATUS_TRANS_SHORT); - } - /* RTS51X_DEBUGP("-- transfer complete\n"); */ - return STATUS_SUCCESS; - /* stalled */ - case -EPIPE: - /* for control endpoints, (used by CB[I]) a stall indicates - * a failed command */ - if (usb_pipecontrol(pipe)) { - RTS51X_DEBUGP("-- stall on control pipe\n"); - TRACE_RET(chip, STATUS_STALLED); - } - /* for other sorts of endpoint, clear the stall */ - RTS51X_DEBUGP("clearing endpoint halt for pipe 0x%x\n", pipe); - if (rts51x_clear_halt(chip, pipe) < 0) - TRACE_RET(chip, STATUS_ERROR); - retval = STATUS_STALLED; - TRACE_GOTO(chip, Exit); - - /* babble - the device tried to send more than - * we wanted to read */ - case -EOVERFLOW: - RTS51X_DEBUGP("-- babble\n"); - retval = STATUS_TRANS_LONG; - TRACE_GOTO(chip, Exit); - - /* the transfer was cancelled by abort, - * disconnect, or timeout */ - case -ECONNRESET: - RTS51X_DEBUGP("-- transfer cancelled\n"); - retval = STATUS_ERROR; - TRACE_GOTO(chip, Exit); - - /* short scatter-gather read transfer */ - case -EREMOTEIO: - RTS51X_DEBUGP("-- short read transfer\n"); - retval = STATUS_TRANS_SHORT; - TRACE_GOTO(chip, Exit); - - /* abort or disconnect in progress */ - case -EIO: - RTS51X_DEBUGP("-- abort or disconnect in progress\n"); - retval = STATUS_ERROR; - TRACE_GOTO(chip, Exit); - - case -ETIMEDOUT: - RTS51X_DEBUGP("-- time out\n"); - retval = STATUS_TIMEDOUT; - TRACE_GOTO(chip, Exit); - - /* the catch-all error case */ - default: - RTS51X_DEBUGP("-- unknown error\n"); - retval = STATUS_ERROR; - TRACE_GOTO(chip, Exit); - } - -Exit: - if ((retval != STATUS_SUCCESS) && !usb_pipecontrol(pipe)) - rts51x_clear_hw_error(chip); - - return retval; -} - -int rts51x_ctrl_transfer(struct rts51x_chip *chip, unsigned int pipe, - u8 request, u8 requesttype, u16 value, u16 index, - void *data, u16 size, int timeout) -{ - struct rts51x_usb *rts51x = chip->usb; - int result; - - RTS51X_DEBUGP("%s: rq=%02x rqtype=%02x value=%04x index=%02x len=%u\n", - __func__, request, requesttype, value, index, size); - - /* fill in the devrequest structure */ - rts51x->cr->bRequestType = requesttype; - rts51x->cr->bRequest = request; - rts51x->cr->wValue = cpu_to_le16(value); - rts51x->cr->wIndex = cpu_to_le16(index); - rts51x->cr->wLength = cpu_to_le16(size); - - /* fill and submit the URB */ - usb_fill_control_urb(rts51x->current_urb, rts51x->pusb_dev, pipe, - (unsigned char *)rts51x->cr, data, size, - urb_done_completion, NULL); - result = rts51x_msg_common(chip, rts51x->current_urb, timeout); - - return interpret_urb_result(chip, pipe, size, result, - rts51x->current_urb->actual_length); -} - -static int rts51x_clear_halt(struct rts51x_chip *chip, unsigned int pipe) -{ - int result; - int endp = usb_pipeendpoint(pipe); - - if (usb_pipein(pipe)) - endp |= USB_DIR_IN; - - result = rts51x_ctrl_transfer(chip, SND_CTRL_PIPE(chip), - USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, - USB_ENDPOINT_HALT, endp, NULL, 0, 3000); - if (result != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - - usb_reset_endpoint(chip->usb->pusb_dev, endp); - - return STATUS_SUCCESS; -} - -static void rts51x_sg_clean(struct usb_sg_request *io) -{ - if (io->urbs) { - while (io->entries--) - usb_free_urb(io->urbs[io->entries]); - kfree(io->urbs); - io->urbs = NULL; - } - io->dev = NULL; -} - -static int rts51x_sg_init(struct usb_sg_request *io, struct usb_device *dev, - unsigned pipe, unsigned period, struct scatterlist *sg, - int nents, size_t length, gfp_t mem_flags) -{ - return usb_sg_init(io, dev, pipe, period, sg, nents, length, mem_flags); -} - -static int rts51x_sg_wait(struct usb_sg_request *io, int timeout) -{ - long timeleft; - int i; - int entries = io->entries; - - /* queue the urbs. */ - spin_lock_irq(&io->lock); - i = 0; - while (i < entries && !io->status) { - int retval; - - io->urbs[i]->dev = io->dev; - retval = usb_submit_urb(io->urbs[i], GFP_ATOMIC); - - /* after we submit, let completions or cancelations fire; - * we handshake using io->status. - */ - spin_unlock_irq(&io->lock); - switch (retval) { - /* maybe the retry will recover */ - case -ENXIO: /* hc didn't queue this one */ - case -EAGAIN: - case -ENOMEM: - io->urbs[i]->dev = NULL; - retval = 0; - yield(); - break; - - /* no error? continue immediately. - * - * NOTE: to work better with UHCI (4K I/O buffer may - * need 3K of TDs) it may be good to limit how many - * URBs are queued at once; N milliseconds? - */ - case 0: - ++i; - cpu_relax(); - break; - - /* fail any uncompleted urbs */ - default: - io->urbs[i]->dev = NULL; - io->urbs[i]->status = retval; - dev_dbg(&io->dev->dev, "%s, submit --> %d\n", - __func__, retval); - usb_sg_cancel(io); - } - spin_lock_irq(&io->lock); - if (retval && (io->status == 0 || io->status == -ECONNRESET)) - io->status = retval; - } - io->count -= entries - i; - if (io->count == 0) - complete(&io->complete); - spin_unlock_irq(&io->lock); - - timeleft = - wait_for_completion_interruptible_timeout(&io->complete, - (timeout * HZ / - 1000) ? : - MAX_SCHEDULE_TIMEOUT); - if (timeleft <= 0) { - RTS51X_DEBUGP("%s -- cancelling SG request\n", - timeleft == 0 ? "Timeout" : "Signal"); - usb_sg_cancel(io); - if (timeleft == 0) - io->status = -ETIMEDOUT; - else - io->status = -EINTR; - } - - rts51x_sg_clean(io); - return io->status; -} - -/* - * Transfer a scatter-gather list via bulk transfer - * - * This function does basically the same thing as usb_stor_bulk_transfer_buf() - * above, but it uses the usbcore scatter-gather library. - */ -static int rts51x_bulk_transfer_sglist(struct rts51x_chip *chip, - unsigned int pipe, - struct scatterlist *sg, int num_sg, - unsigned int length, - unsigned int *act_len, int timeout) -{ - int result; - - /* don't submit s-g requests during abort processing */ - if (test_bit(FLIDX_ABORTING, &chip->usb->dflags)) - TRACE_RET(chip, STATUS_ERROR); - - /* initialize the scatter-gather request block */ - RTS51X_DEBUGP("%s: xfer %u bytes, %d entries\n", __func__, - length, num_sg); - result = - rts51x_sg_init(&chip->usb->current_sg, chip->usb->pusb_dev, pipe, 0, - sg, num_sg, length, GFP_NOIO); - if (result) { - RTS51X_DEBUGP("rts51x_sg_init returned %d\n", result); - TRACE_RET(chip, STATUS_ERROR); - } - - /* since the block has been initialized successfully, it's now - * okay to cancel it */ - set_bit(FLIDX_SG_ACTIVE, &chip->usb->dflags); - - /* did an abort occur during the submission? */ - if (test_bit(FLIDX_ABORTING, &chip->usb->dflags)) { - - /* cancel the request, if it hasn't been cancelled already */ - if (test_and_clear_bit(FLIDX_SG_ACTIVE, &chip->usb->dflags)) { - RTS51X_DEBUGP("-- cancelling sg request\n"); - usb_sg_cancel(&chip->usb->current_sg); - } - } - - /* wait for the completion of the transfer */ - result = rts51x_sg_wait(&chip->usb->current_sg, timeout); - - clear_bit(FLIDX_SG_ACTIVE, &chip->usb->dflags); - - /* result = us->current_sg.status; */ - if (act_len) - *act_len = chip->usb->current_sg.bytes; - return interpret_urb_result(chip, pipe, length, result, - chip->usb->current_sg.bytes); -} - -static int rts51x_bulk_transfer_buf(struct rts51x_chip *chip, - unsigned int pipe, - void *buf, unsigned int length, - unsigned int *act_len, int timeout) -{ - int result; - - /* fill and submit the URB */ - usb_fill_bulk_urb(chip->usb->current_urb, chip->usb->pusb_dev, pipe, - buf, length, urb_done_completion, NULL); - result = rts51x_msg_common(chip, chip->usb->current_urb, timeout); - - /* store the actual length of the data transferred */ - if (act_len) - *act_len = chip->usb->current_urb->actual_length; - return interpret_urb_result(chip, pipe, length, result, - chip->usb->current_urb->actual_length); -} - -int rts51x_transfer_data(struct rts51x_chip *chip, unsigned int pipe, - void *buf, unsigned int len, int use_sg, - unsigned int *act_len, int timeout) -{ - int result; - - if (timeout < 600) - timeout = 600; - - if (use_sg) { - result = - rts51x_bulk_transfer_sglist(chip, pipe, - (struct scatterlist *)buf, - use_sg, len, act_len, timeout); - } else { - result = - rts51x_bulk_transfer_buf(chip, pipe, buf, len, act_len, - timeout); - } - - return result; -} - -int rts51x_transfer_data_partial(struct rts51x_chip *chip, unsigned int pipe, - void *buf, void **ptr, unsigned int *offset, - unsigned int len, int use_sg, - unsigned int *act_len, int timeout) -{ - int result; - - if (timeout < 600) - timeout = 600; - - if (use_sg) { - void *tmp_buf = kmalloc(len, GFP_KERNEL); - if (!tmp_buf) - TRACE_RET(chip, STATUS_NOMEM); - - if (usb_pipeout(pipe)) { - rts51x_access_sglist(tmp_buf, len, buf, ptr, offset, - FROM_XFER_BUF); - } - result = - rts51x_bulk_transfer_buf(chip, pipe, tmp_buf, len, act_len, - timeout); - if (result == STATUS_SUCCESS) { - if (usb_pipein(pipe)) { - rts51x_access_sglist(tmp_buf, len, buf, ptr, - offset, TO_XFER_BUF); - } - } - - kfree(tmp_buf); - } else { - unsigned int step = 0; - if (offset) - step = *offset; - result = - rts51x_bulk_transfer_buf(chip, pipe, buf + step, len, - act_len, timeout); - if (act_len) - step += *act_len; - else - step += len; - if (offset) - *offset = step; - } - - return result; -} - -int rts51x_get_epc_status(struct rts51x_chip *chip, u16 *status) -{ - unsigned int pipe = RCV_INTR_PIPE(chip); - struct usb_host_endpoint *ep; - struct completion urb_done; - int result; - - if (!status) - TRACE_RET(chip, STATUS_ERROR); - - /* set up data structures for the wakeup system */ - init_completion(&urb_done); - - ep = chip->usb->pusb_dev->ep_in[usb_pipeendpoint(pipe)]; - - /* fill and submit the URB */ - /* Set interval to 10 here to match the endpoint descriptor, - * the polling interval is controlled by the polling thread */ - usb_fill_int_urb(chip->usb->intr_urb, chip->usb->pusb_dev, pipe, - status, 2, urb_done_completion, &urb_done, 10); - - result = rts51x_msg_common(chip, chip->usb->intr_urb, 100); - - return interpret_urb_result(chip, pipe, 2, result, - chip->usb->intr_urb->actual_length); -} - -void rts51x_invoke_transport(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - int result; - -#ifdef CONFIG_PM - static const u8 media_not_present[] = { - 0x70, 0, 0x02, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0x3A, 0, 0, 0, 0, 0 - }; - static const u8 invalid_cmd_field[] = { - 0x70, 0, 0x05, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0x24, 0, 0, 0, 0, 0 - }; - - if (chip->option.ss_en) { - if (srb->cmnd[0] == TEST_UNIT_READY) { - if (RTS51X_CHK_STAT(chip, STAT_SS)) { - if (check_fake_card_ready(chip, - SCSI_LUN(srb))) { - srb->result = SAM_STAT_GOOD; - } else { - srb->result = SAM_STAT_CHECK_CONDITION; - memcpy(srb->sense_buffer, - media_not_present, SENSE_SIZE); - } - return; - } - } else if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) { - if (RTS51X_CHK_STAT(chip, STAT_SS)) { - int prevent = srb->cmnd[4] & 0x1; - - if (prevent) { - srb->result = SAM_STAT_CHECK_CONDITION; - memcpy(srb->sense_buffer, - invalid_cmd_field, SENSE_SIZE); - } else { - srb->result = SAM_STAT_GOOD; - } - return; - } - } else { - if (RTS51X_CHK_STAT(chip, STAT_SS) - || RTS51X_CHK_STAT(chip, STAT_SS_PRE)) { - /* Wake up device */ - RTS51X_DEBUGP("Try to wake up device\n"); - chip->resume_from_scsi = 1; - - rts51x_try_to_exit_ss(chip); - - if (RTS51X_CHK_STAT(chip, STAT_SS)) { - wait_timeout(3000); - - rts51x_init_chip(chip); - rts51x_init_cards(chip); - } - } - } - } -#endif - - result = rts51x_scsi_handler(srb, chip); - - /* if there is a transport error, reset and don't auto-sense */ - if (result == TRANSPORT_ERROR) { - RTS51X_DEBUGP("-- transport indicates error, resetting\n"); - srb->result = DID_ERROR << 16; - goto Handle_Errors; - } - - srb->result = SAM_STAT_GOOD; - - /* - * If we have a failure, we're going to do a REQUEST_SENSE - * automatically. Note that we differentiate between a command - * "failure" and an "error" in the transport mechanism. - */ - if (result == TRANSPORT_FAILED) { - /* set the result so the higher layers expect this data */ - srb->result = SAM_STAT_CHECK_CONDITION; - memcpy(srb->sense_buffer, - (unsigned char *)&(chip->sense_buffer[SCSI_LUN(srb)]), - sizeof(struct sense_data_t)); - } - - return; - - /* Error and abort processing: try to resynchronize with the device - * by issuing a port reset. If that fails, try a class-specific - * device reset. */ -Handle_Errors: - return; -} diff --git a/drivers/staging/rts5139/rts51x_transport.h b/drivers/staging/rts5139/rts51x_transport.h deleted file mode 100644 index 024f115540a6..000000000000 --- a/drivers/staging/rts5139/rts51x_transport.h +++ /dev/null @@ -1,67 +0,0 @@ -/* Driver for Realtek RTS51xx USB card reader - * Header file - * - * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. - * - * 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, 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, see . - * - * Author: - * wwang (wei_wang@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - * Maintainer: - * Edwin Rong (edwin_rong@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - */ - -#ifndef __RTS51X_TRANSPORT_H -#define __RTS51X_TRANSPORT_H - -#include - -#include "rts51x.h" -#include "rts51x_chip.h" - -#if 1 /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34) */ -#define URB_NO_SETUP_DMA_MAP 0 -#endif - -unsigned int rts51x_access_sglist(unsigned char *buffer, - unsigned int buflen, void *sglist, - void **sgptr, unsigned int *offset, - enum xfer_buf_dir dir); -void rts51x_set_xfer_buf(unsigned char *buffer, unsigned int buflen, - struct scsi_cmnd *srb); -void rts51x_get_xfer_buf(unsigned char *buffer, unsigned int buflen, - struct scsi_cmnd *srb); - -int rts51x_ctrl_transfer(struct rts51x_chip *chip, unsigned int pipe, - u8 request, u8 requesttype, u16 value, u16 index, - void *data, u16 size, int timeout); -int rts51x_transfer_data(struct rts51x_chip *chip, unsigned int pipe, - void *buf, unsigned int len, int use_sg, - unsigned int *act_len, int timeout); -int rts51x_transfer_data_partial(struct rts51x_chip *chip, unsigned int pipe, - void *buf, void **ptr, unsigned int *offset, - unsigned int len, int use_sg, - unsigned int *act_len, int timeout); - -#ifndef POLLING_IN_THREAD -int rts51x_start_epc_transfer(struct rts51x_chip *chip); -void rts51x_cancel_epc_transfer(struct rts51x_chip *chip); -#endif - -int rts51x_get_epc_status(struct rts51x_chip *chip, u16 *status); -void rts51x_invoke_transport(struct scsi_cmnd *srb, struct rts51x_chip *chip); - -#endif /* __RTS51X_TRANSPORT_H */ diff --git a/drivers/staging/rts5139/sd.c b/drivers/staging/rts5139/sd.c deleted file mode 100644 index da5a9b8fb69c..000000000000 --- a/drivers/staging/rts5139/sd.c +++ /dev/null @@ -1,3274 +0,0 @@ -/* Driver for Realtek RTS51xx USB card reader - * - * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. - * - * 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, 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, see . - * - * Author: - * wwang (wei_wang@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - * Maintainer: - * Edwin Rong (edwin_rong@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - */ - -#include -#include -#include - -#include "debug.h" -#include "trace.h" -#include "rts51x.h" -#include "rts51x_transport.h" -#include "rts51x_scsi.h" -#include "rts51x_card.h" -#include "sd.h" - -static inline void sd_set_reset_fail(struct rts51x_chip *chip, u8 err_code) -{ - struct sd_info *sd_card = &(chip->sd_card); - - sd_card->sd_reset_fail |= err_code; -} - -static inline void sd_clear_reset_fail(struct rts51x_chip *chip) -{ - struct sd_info *sd_card = &(chip->sd_card); - - sd_card->sd_reset_fail = 0; -} - -static inline int sd_check_reset_fail(struct rts51x_chip *chip, u8 err_code) -{ - struct sd_info *sd_card = &(chip->sd_card); - - return sd_card->sd_reset_fail & err_code; -} - -static inline void sd_set_err_code(struct rts51x_chip *chip, u8 err_code) -{ - struct sd_info *sd_card = &(chip->sd_card); - - sd_card->err_code |= err_code; -} - -static inline void sd_clr_err_code(struct rts51x_chip *chip) -{ - struct sd_info *sd_card = &(chip->sd_card); - - sd_card->err_code = 0; -} - -static inline int sd_check_err_code(struct rts51x_chip *chip, u8 err_code) -{ - struct sd_info *sd_card = &(chip->sd_card); - - return sd_card->err_code & err_code; -} - -static int sd_parse_err_code(struct rts51x_chip *chip) -{ - TRACE_RET(chip, STATUS_FAIL); -} - -int sd_check_data0_status(struct rts51x_chip *chip) -{ - int retval; - u8 stat; - - retval = rts51x_ep0_read_register(chip, SD_BUS_STAT, &stat); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - if (!(stat & SD_DAT0_STATUS)) { - sd_set_err_code(chip, SD_BUSY); - TRACE_RET(chip, STATUS_FAIL); - } - - return STATUS_SUCCESS; -} - -static int sd_send_cmd_get_rsp(struct rts51x_chip *chip, u8 cmd_idx, - u32 arg, u8 rsp_type, u8 *rsp, int rsp_len) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval; - int timeout = 50; - u16 reg_addr; - u8 buf[17], stat; - int len = 2; - int rty_cnt = 0; - - sd_clr_err_code(chip); - - RTS51X_DEBUGP("SD/MMC CMD %d, arg = 0x%08x\n", cmd_idx, arg); - - if (rsp_type == SD_RSP_TYPE_R1b) - timeout = 3000; - -RTY_SEND_CMD: - - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD0, 0xFF, 0x40 | cmd_idx); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD1, 0xFF, (u8) (arg >> 24)); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD2, 0xFF, (u8) (arg >> 16)); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD3, 0xFF, (u8) (arg >> 8)); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD4, 0xFF, (u8) arg); - - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG2, 0xFF, rsp_type); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, - PINGPONG_BUFFER); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_TRANSFER, 0xFF, - SD_TM_CMD_RSP | SD_TRANSFER_START); - rts51x_add_cmd(chip, CHECK_REG_CMD, SD_TRANSFER, - SD_TRANSFER_END | SD_STAT_IDLE, - SD_TRANSFER_END | SD_STAT_IDLE); - - rts51x_add_cmd(chip, READ_REG_CMD, SD_STAT1, 0, 0); - - if (CHECK_USB(chip, USB_20)) { - if (rsp_type == SD_RSP_TYPE_R2) { - /* Read data from ping-pong buffer */ - for (reg_addr = PPBUF_BASE2; - reg_addr < PPBUF_BASE2 + 16; reg_addr++) { - rts51x_add_cmd(chip, READ_REG_CMD, reg_addr, 0, - 0); - } - len = 18; - } else if (rsp_type != SD_RSP_TYPE_R0) { - /* Read data from SD_CMDx registers */ - for (reg_addr = SD_CMD0; reg_addr <= SD_CMD4; - reg_addr++) { - rts51x_add_cmd(chip, READ_REG_CMD, reg_addr, 0, - 0); - } - len = 7; - } else { - len = 2; - } - } else { - len = 2; - } - - retval = rts51x_send_cmd(chip, MODE_CR, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = rts51x_get_rsp(chip, len, timeout); - - if (CHECK_SD_TRANS_FAIL(chip, retval)) { - u8 val; - - rts51x_ep0_read_register(chip, SD_STAT1, &val); - RTS51X_DEBUGP("SD_STAT1: 0x%x\n", val); - - rts51x_ep0_read_register(chip, SD_STAT2, &val); - RTS51X_DEBUGP("SD_STAT2: 0x%x\n", val); - - if (val & SD_RSP_80CLK_TIMEOUT) - sd_set_err_code(chip, SD_RSP_TIMEOUT); - - rts51x_ep0_read_register(chip, SD_BUS_STAT, &val); - RTS51X_DEBUGP("SD_BUS_STAT: 0x%x\n", val); - - if (retval == STATUS_TIMEDOUT) { - if (rsp_type & SD_WAIT_BUSY_END) { - retval = sd_check_data0_status(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } else { - sd_set_err_code(chip, SD_TO_ERR); - } - } - rts51x_clear_sd_error(chip); - - TRACE_RET(chip, STATUS_FAIL); - } - - if (rsp_type == SD_RSP_TYPE_R0) - return STATUS_SUCCESS; - - if (CHECK_USB(chip, USB_20)) { - rts51x_read_rsp_buf(chip, 2, buf, len - 2); - } else { - if (rsp_type == SD_RSP_TYPE_R2) { - reg_addr = PPBUF_BASE2; - len = 16; - } else { - reg_addr = SD_CMD0; - len = 5; - } - retval = rts51x_seq_read_register(chip, reg_addr, - (unsigned short)len, buf); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - stat = chip->rsp_buf[1]; - - /* Check (Start,Transmission) bit of Response */ - if ((buf[0] & 0xC0) != 0) { - sd_set_err_code(chip, SD_STS_ERR); - TRACE_RET(chip, STATUS_FAIL); - } - /* Check CRC7 */ - if (!(rsp_type & SD_NO_CHECK_CRC7)) { - if (stat & SD_CRC7_ERR) { - if (cmd_idx == WRITE_MULTIPLE_BLOCK) { - sd_set_err_code(chip, SD_CRC_ERR); - TRACE_RET(chip, STATUS_FAIL); - } - if (rty_cnt < SD_MAX_RETRY_COUNT) { - wait_timeout(20); - rty_cnt++; - goto RTY_SEND_CMD; - } else { - sd_set_err_code(chip, SD_CRC_ERR); - TRACE_RET(chip, STATUS_FAIL); - } - } - } - /* Check Status */ - if ((rsp_type == SD_RSP_TYPE_R1) || (rsp_type == SD_RSP_TYPE_R1b)) { - if ((cmd_idx != SEND_RELATIVE_ADDR) - && (cmd_idx != SEND_IF_COND)) { - if (cmd_idx != STOP_TRANSMISSION) { - if (buf[1] & 0x80) - TRACE_RET(chip, STATUS_FAIL); - } - if (buf[1] & 0x7F) { - RTS51X_DEBUGP("buf[1]: 0x%02x\n", buf[1]); - TRACE_RET(chip, STATUS_FAIL); - } - if (buf[2] & 0xFF) { - RTS51X_DEBUGP("buf[2]: 0x%02x\n", buf[2]); - TRACE_RET(chip, STATUS_FAIL); - } - if (buf[3] & 0x80) { - RTS51X_DEBUGP("buf[3]: 0x%02x\n", buf[3]); - TRACE_RET(chip, STATUS_FAIL); - } - if (buf[3] & 0x01) { - /* Get "READY_FOR_DATA" bit */ - sd_card->sd_data_buf_ready = 1; - } else { - sd_card->sd_data_buf_ready = 0; - } - } - } - - if (rsp && rsp_len) - memcpy(rsp, buf, rsp_len); - - return STATUS_SUCCESS; -} - -static inline void sd_print_debug_reg(struct rts51x_chip *chip) -{ -#ifdef CONFIG_RTS5139_DEBUG - u8 val = 0; - - rts51x_ep0_read_register(chip, SD_STAT1, &val); - RTS51X_DEBUGP("SD_STAT1: 0x%x\n", val); - rts51x_ep0_read_register(chip, SD_STAT2, &val); - RTS51X_DEBUGP("SD_STAT2: 0x%x\n", val); - rts51x_ep0_read_register(chip, SD_BUS_STAT, &val); - RTS51X_DEBUGP("SD_BUS_STAT: 0x%x\n", val); -#endif -} - -int sd_read_data(struct rts51x_chip *chip, u8 trans_mode, u8 *cmd, int cmd_len, - u16 byte_cnt, u16 blk_cnt, u8 bus_width, u8 *buf, int buf_len, - int timeout) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval; - int i; - - sd_clr_err_code(chip); - - if (!buf) - buf_len = 0; - - if (buf_len > 512) - /* This function can't read data more than one page */ - TRACE_RET(chip, STATUS_FAIL); - - rts51x_init_cmd(chip); - - if (cmd_len) { - RTS51X_DEBUGP("SD/MMC CMD %d\n", cmd[0] - 0x40); - for (i = 0; i < (cmd_len < 6 ? cmd_len : 6); i++) { - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD0 + i, 0xFF, - cmd[i]); - } - } - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_L, 0xFF, (u8) byte_cnt); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_H, 0xFF, - (u8) (byte_cnt >> 8)); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_L, 0xFF, (u8) blk_cnt); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_H, 0xFF, - (u8) (blk_cnt >> 8)); - - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG1, 0x03, bus_width); - - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG2, 0xFF, - SD_CALCULATE_CRC7 | SD_CHECK_CRC16 | SD_NO_WAIT_BUSY_END - | SD_CHECK_CRC7 | SD_RSP_LEN_6); - if (trans_mode != SD_TM_AUTO_TUNING) { - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, - PINGPONG_BUFFER); - } - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_TRANSFER, 0xFF, - trans_mode | SD_TRANSFER_START); - rts51x_add_cmd(chip, CHECK_REG_CMD, SD_TRANSFER, SD_TRANSFER_END, - SD_TRANSFER_END); - - retval = rts51x_send_cmd(chip, MODE_CR, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = rts51x_get_rsp(chip, 1, timeout); - - if (CHECK_SD_TRANS_FAIL(chip, retval)) { - sd_print_debug_reg(chip); - if (retval == STATUS_TIMEDOUT) { - sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, - SD_RSP_TYPE_R1, NULL, 0); - } - - TRACE_RET(chip, STATUS_FAIL); - } - - if (buf && buf_len) { - retval = rts51x_read_ppbuf(chip, buf, buf_len); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - - return STATUS_SUCCESS; -} - -static int sd_write_data(struct rts51x_chip *chip, u8 trans_mode, - u8 *cmd, int cmd_len, u16 byte_cnt, u16 blk_cnt, - u8 bus_width, u8 *buf, int buf_len, int timeout) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval; - int i; - - sd_clr_err_code(chip); - - if (!buf) - buf_len = 0; - - /* This function can't write data more than one page */ - if (buf_len > 512) - TRACE_RET(chip, STATUS_FAIL); - - if (buf && buf_len) { - retval = rts51x_write_ppbuf(chip, buf, buf_len); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - - rts51x_init_cmd(chip); - - if (cmd_len) { - RTS51X_DEBUGP("SD/MMC CMD %d\n", cmd[0] - 0x40); - for (i = 0; i < (cmd_len < 6 ? cmd_len : 6); i++) { - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD0 + i, 0xFF, - cmd[i]); - } - } - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_L, 0xFF, (u8) byte_cnt); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_H, 0xFF, - (u8) (byte_cnt >> 8)); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_L, 0xFF, (u8) blk_cnt); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_H, 0xFF, - (u8) (blk_cnt >> 8)); - - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG1, 0x03, bus_width); - - if (cmd_len) { - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG2, 0xFF, - SD_CALCULATE_CRC7 | SD_CHECK_CRC16 | - SD_WAIT_BUSY_END | SD_CHECK_CRC7 | SD_RSP_LEN_6); - - } else { - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG2, 0xFF, - SD_CALCULATE_CRC7 | SD_CHECK_CRC16 | - SD_NO_WAIT_BUSY_END | SD_CHECK_CRC7 | - SD_RSP_LEN_6); - } - - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_TRANSFER, 0xFF, - trans_mode | SD_TRANSFER_START); - rts51x_add_cmd(chip, CHECK_REG_CMD, SD_TRANSFER, SD_TRANSFER_END, - SD_TRANSFER_END); - - retval = rts51x_send_cmd(chip, MODE_CR, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = rts51x_get_rsp(chip, 1, timeout); - - if (CHECK_SD_TRANS_FAIL(chip, retval)) { - sd_print_debug_reg(chip); - - if (retval == STATUS_TIMEDOUT) - sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, - SD_RSP_TYPE_R1, NULL, 0); - - TRACE_RET(chip, STATUS_FAIL); - } - - return STATUS_SUCCESS; -} - -static int sd_check_csd(struct rts51x_chip *chip, char check_wp) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval; - int i; - u8 csd_ver, trans_speed; - u8 rsp[16]; - - for (i = 0; i < 6; i++) { - if (monitor_card_cd(chip, SD_CARD) == CD_NOT_EXIST) { - sd_set_reset_fail(chip, SD_RESET_FAIL); - TRACE_RET(chip, STATUS_FAIL); - } - - retval = - sd_send_cmd_get_rsp(chip, SEND_CSD, sd_card->sd_addr, - SD_RSP_TYPE_R2, rsp, 16); - if (retval == STATUS_SUCCESS) - break; - } - - if (i == 6) - TRACE_RET(chip, STATUS_FAIL); - memcpy(sd_card->raw_csd, rsp + 1, 15); - /* Get CRC7 */ - RTS51X_READ_REG(chip, SD_CMD5, sd_card->raw_csd + 15); - - RTS51X_DEBUGP("CSD Response:\n"); - RTS51X_DUMP(rsp, 16); - - /* Get CSD Version */ - csd_ver = (rsp[1] & 0xc0) >> 6; - RTS51X_DEBUGP("csd_ver = %d\n", csd_ver); - - trans_speed = rsp[4]; - if ((trans_speed & 0x07) == 0x02) { /* 10Mbits/s */ - if ((trans_speed & 0xf8) >= 0x30) { /* >25Mbits/s */ - if (chip->asic_code) - sd_card->sd_clock = 46; - else - sd_card->sd_clock = CLK_50; - } else if ((trans_speed & 0xf8) == 0x28) { /* 20Mbits/s */ - if (chip->asic_code) - sd_card->sd_clock = 39; - else - sd_card->sd_clock = CLK_40; - } else if ((trans_speed & 0xf8) == 0x20) { /* 15Mbits/s */ - if (chip->asic_code) - sd_card->sd_clock = 29; - else - sd_card->sd_clock = CLK_30; - } else if ((trans_speed & 0xf8) >= 0x10) { /* 12Mbits/s */ - if (chip->asic_code) - sd_card->sd_clock = 23; - else - sd_card->sd_clock = CLK_20; - } else if ((trans_speed & 0x08) >= 0x08) { /* 10Mbits/s */ - if (chip->asic_code) - sd_card->sd_clock = 19; - else - sd_card->sd_clock = CLK_20; - } /*else { */ - /*If this ,then slow card will use 30M clock */ - /* TRACE_RET(chip, STATUS_FAIL); */ - /* } */ - } - /*else { - TRACE_RET(chip, STATUS_FAIL); - } */ - if (CHK_MMC_SECTOR_MODE(sd_card)) { - sd_card->capacity = 0; - } else { - /* For High-Capacity Card, CSD_STRUCTURE always be "0x1" */ - if ((!CHK_SD_HCXC(sd_card)) || (csd_ver == 0)) { - /* Calculate total sector according to C_SIZE, - * C_SIZE_MULT & READ_BL_LEN */ - u8 blk_size, c_size_mult; - u16 c_size; - /* Get READ_BL_LEN */ - blk_size = rsp[6] & 0x0F; - /* Get C_SIZE */ - c_size = ((u16) (rsp[7] & 0x03) << 10) - + ((u16) rsp[8] << 2) - + ((u16) (rsp[9] & 0xC0) >> 6); - /* Get C_SIZE_MUL */ - c_size_mult = (u8) ((rsp[10] & 0x03) << 1); - c_size_mult += (rsp[11] & 0x80) >> 7; - /* Calculate total Capacity */ - sd_card->capacity = - (((u32) (c_size + 1)) * - (1 << (c_size_mult + 2))) << (blk_size - 9); - } else { - /* High Capacity Card and Use CSD2.0 Version */ - u32 total_sector = 0; - total_sector = (((u32) rsp[8] & 0x3f) << 16) | - ((u32) rsp[9] << 8) | (u32) rsp[10]; - /* Total Capacity= (C_SIZE+1) * - * 512K Byte = (C_SIZE+1)K Sector,1K = 1024 Bytes */ - sd_card->capacity = (total_sector + 1) << 10; - } - } - - /* We need check Write-Protected Status by Field PERM WP or TEMP WP */ - if (check_wp) { - if (rsp[15] & 0x30) - chip->card_wp |= SD_CARD; - RTS51X_DEBUGP("CSD WP Status: 0x%x\n", rsp[15]); - } - - return STATUS_SUCCESS; -} - -static int sd_set_sample_push_timing(struct rts51x_chip *chip) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval; - - rts51x_init_cmd(chip); - - if (CHK_SD_SDR104(sd_card) || CHK_SD_SDR50(sd_card)) { - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG1, - 0x0C | SD_ASYNC_FIFO_RST, - SD_30_MODE | SD_ASYNC_FIFO_RST); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_CLK_SOURCE, 0xFF, - CRC_VAR_CLK0 | SD30_FIX_CLK | SAMPLE_VAR_CLK1); - } else if (CHK_SD_DDR50(sd_card) || CHK_MMC_DDR52(sd_card)) { - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG1, - 0x0C | SD_ASYNC_FIFO_RST, - SD_DDR_MODE | SD_ASYNC_FIFO_RST); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_CLK_SOURCE, 0xFF, - CRC_VAR_CLK0 | SD30_FIX_CLK | SAMPLE_VAR_CLK1); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_PUSH_POINT_CTL, - DDR_VAR_TX_CMD_DAT, DDR_VAR_TX_CMD_DAT); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_SAMPLE_POINT_CTL, - DDR_VAR_RX_DAT | DDR_VAR_RX_CMD, - DDR_VAR_RX_DAT | DDR_VAR_RX_CMD); - } else { - u8 val = 0; - - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG1, 0x0C, SD_20_MODE); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_CLK_SOURCE, 0xFF, - CRC_FIX_CLK | SD30_VAR_CLK0 | SAMPLE_VAR_CLK1); - - if ((chip->option.sd_ctl & SD_PUSH_POINT_CTL_MASK) == - SD_PUSH_POINT_AUTO) { - val = SD20_TX_NEG_EDGE; - } else if ((chip->option.sd_ctl & SD_PUSH_POINT_CTL_MASK) == - SD_PUSH_POINT_DELAY) { - val = SD20_TX_14_AHEAD; - } else { - val = SD20_TX_NEG_EDGE; - } - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_PUSH_POINT_CTL, - SD20_TX_SEL_MASK, val); - - if ((chip->option.sd_ctl & SD_SAMPLE_POINT_CTL_MASK) == - SD_SAMPLE_POINT_AUTO) { - if (chip->asic_code) { - if (CHK_SD_HS(sd_card) || CHK_MMC_52M(sd_card)) - val = SD20_RX_14_DELAY; - else - val = SD20_RX_POS_EDGE; - } else { - val = SD20_RX_14_DELAY; - } - } else if ((chip->option.sd_ctl & SD_SAMPLE_POINT_CTL_MASK) == - SD_SAMPLE_POINT_DELAY) { - val = SD20_RX_14_DELAY; - } else { - val = SD20_RX_POS_EDGE; - } - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_SAMPLE_POINT_CTL, - SD20_RX_SEL_MASK, val); - } - - if (CHK_MMC_DDR52(sd_card) && CHK_MMC_8BIT(sd_card)) { - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DMA1_CTL, - EXTEND_DMA1_ASYNC_SIGNAL, 0); - } - - retval = rts51x_send_cmd(chip, MODE_C, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - return STATUS_SUCCESS; -} - -static void sd_choose_proper_clock(struct rts51x_chip *chip) -{ - struct sd_info *sd_card = &(chip->sd_card); - - if (CHK_SD_SDR104(sd_card)) { - if (chip->asic_code) - sd_card->sd_clock = chip->option.asic_sd_sdr104_clk; - else - sd_card->sd_clock = chip->option.fpga_sd_sdr104_clk; - } else if (CHK_SD_DDR50(sd_card)) { - if (chip->asic_code) - sd_card->sd_clock = chip->option.asic_sd_ddr50_clk; - else - sd_card->sd_clock = chip->option.fpga_sd_ddr50_clk; - } else if (CHK_SD_SDR50(sd_card)) { - if (chip->asic_code) - sd_card->sd_clock = chip->option.asic_sd_sdr50_clk; - else - sd_card->sd_clock = chip->option.fpga_sd_sdr50_clk; - } else if (CHK_SD_HS(sd_card)) { - if (chip->asic_code) - sd_card->sd_clock = chip->option.asic_sd_hs_clk; - else - sd_card->sd_clock = chip->option.fpga_sd_hs_clk; - } else if (CHK_MMC_52M(sd_card) || CHK_MMC_DDR52(sd_card)) { - if (chip->asic_code) - sd_card->sd_clock = chip->option.asic_mmc_52m_clk; - else - sd_card->sd_clock = chip->option.fpga_mmc_52m_clk; - } else if (CHK_MMC_26M(sd_card)) { - if (chip->asic_code) { - sd_card->sd_clock = 46; - RTS51X_DEBUGP("Set MMC clock to 22.5MHz\n"); - } else { - sd_card->sd_clock = CLK_50; - } - } -} - -static int sd_set_init_para(struct rts51x_chip *chip) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval; - - retval = sd_set_sample_push_timing(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - sd_choose_proper_clock(chip); - - retval = switch_clock(chip, sd_card->sd_clock); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - return STATUS_SUCCESS; -} - -int rts51x_sd_select_card(struct rts51x_chip *chip, int select) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval; - u8 cmd_idx, cmd_type; - u32 addr; - - if (select) { - cmd_idx = SELECT_CARD; - cmd_type = SD_RSP_TYPE_R1; - addr = sd_card->sd_addr; - } else { - cmd_idx = DESELECT_CARD; - cmd_type = SD_RSP_TYPE_R0; - addr = 0; - } - - retval = sd_send_cmd_get_rsp(chip, cmd_idx, addr, cmd_type, NULL, 0); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - return STATUS_SUCCESS; -} - -static int sd_wait_currentstate_dataready(struct rts51x_chip *chip, u8 statechk, - u8 rdychk, u16 pollingcnt) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval; - u8 rsp[5]; - u16 i; - - for (i = 0; i < pollingcnt; i++) { - - retval = - sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, - SD_RSP_TYPE_R1, rsp, 5); - if (retval == STATUS_SUCCESS) { - if (((rsp[3] & 0x1E) == statechk) - && ((rsp[3] & 0x01) == rdychk)) { - return STATUS_SUCCESS; - } - } else { - rts51x_clear_sd_error(chip); - TRACE_RET(chip, STATUS_FAIL); - } - } - - return STATUS_TIMEDOUT; -} - -static int sd_voltage_switch(struct rts51x_chip *chip) -{ - int retval; - u8 stat; - - RTS51X_WRITE_REG(chip, SD_BUS_STAT, - SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP, - SD_CLK_TOGGLE_EN); - - retval = - sd_send_cmd_get_rsp(chip, VOLTAGE_SWITCH, 0, SD_RSP_TYPE_R1, NULL, - 0); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - RTS51X_READ_REG(chip, SD_BUS_STAT, &stat); - if (stat & (SD_CMD_STATUS | SD_DAT3_STATUS | SD_DAT2_STATUS | - SD_DAT1_STATUS | SD_DAT0_STATUS)) - TRACE_RET(chip, STATUS_FAIL); - - rts51x_init_cmd(chip); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BUS_STAT, 0xFF, - SD_CLK_FORCE_STOP); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_PAD_CTL, SD_IO_USING_1V8, - SD_IO_USING_1V8); - if (chip->asic_code) - rts51x_add_cmd(chip, WRITE_REG_CMD, LDO_POWER_CFG, - TUNE_SD18_MASK, TUNE_SD18_1V8); - retval = rts51x_send_cmd(chip, MODE_C, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - wait_timeout(chip->option.D3318_off_delay); - - RTS51X_WRITE_REG(chip, SD_BUS_STAT, 0xFF, SD_CLK_TOGGLE_EN); - wait_timeout(10); - - RTS51X_READ_REG(chip, SD_BUS_STAT, &stat); - if ((stat & (SD_CMD_STATUS | SD_DAT3_STATUS | SD_DAT2_STATUS | - SD_DAT1_STATUS | SD_DAT0_STATUS)) != - (SD_CMD_STATUS | SD_DAT3_STATUS | SD_DAT2_STATUS | - SD_DAT1_STATUS | SD_DAT0_STATUS)) { - rts51x_init_cmd(chip); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BUS_STAT, 0xFF, - SD_CLK_FORCE_STOP); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_CLK_EN, 0xFF, 0); - rts51x_send_cmd(chip, MODE_C, 100); - TRACE_RET(chip, STATUS_FAIL); - } - RTS51X_WRITE_REG(chip, SD_BUS_STAT, - SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP, 0); - - return STATUS_SUCCESS; -} - -static int sd_change_phase(struct rts51x_chip *chip, u8 sample_point, - u8 tune_dir) -{ - u16 SD_VP_CTL, SD_DCMPS_CTL; - u8 val; - int retval; - - RTS51X_DEBUGP("sd_change_phase (sample_point = %d, tune_dir = %d)\n", - sample_point, tune_dir); - - if (tune_dir == TUNE_RX) { - SD_VP_CTL = SD_VPCLK1_CTL; - SD_DCMPS_CTL = SD_DCMPS1_CTL; - } else { - SD_VP_CTL = SD_VPCLK0_CTL; - SD_DCMPS_CTL = SD_DCMPS0_CTL; - } - - if (chip->asic_code) { - RTS51X_WRITE_REG(chip, CLK_DIV, CLK_CHANGE, CLK_CHANGE); - RTS51X_WRITE_REG(chip, SD_VP_CTL, 0x1F, sample_point); - RTS51X_WRITE_REG(chip, SD_VPCLK0_CTL, PHASE_NOT_RESET, 0); - RTS51X_WRITE_REG(chip, SD_VPCLK0_CTL, PHASE_NOT_RESET, - PHASE_NOT_RESET); - RTS51X_WRITE_REG(chip, CLK_DIV, CLK_CHANGE, 0); - } else { -#ifdef CONFIG_RTS5139_DEBUG - RTS51X_READ_REG(chip, SD_VP_CTL, &val); - RTS51X_DEBUGP("SD_VP_CTL: 0x%x\n", val); - RTS51X_READ_REG(chip, SD_DCMPS_CTL, &val); - RTS51X_DEBUGP("SD_DCMPS_CTL: 0x%x\n", val); -#endif - - RTS51X_WRITE_REG(chip, CLK_DIV, CLK_CHANGE, CLK_CHANGE); - udelay(100); - RTS51X_WRITE_REG(chip, SD_VP_CTL, 0xFF, - PHASE_NOT_RESET | sample_point); - udelay(200); - - rts51x_init_cmd(chip); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_DCMPS_CTL, DCMPS_CHANGE, - DCMPS_CHANGE); - rts51x_add_cmd(chip, CHECK_REG_CMD, SD_DCMPS_CTL, - DCMPS_CHANGE_DONE, DCMPS_CHANGE_DONE); - retval = rts51x_send_cmd(chip, MODE_CR, 100); - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, Fail); - - retval = rts51x_get_rsp(chip, 1, 500); - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, Fail); - - val = chip->rsp_buf[0]; - if (val & DCMPS_ERROR) - TRACE_GOTO(chip, Fail); - if ((val & DCMPS_CURRENT_PHASE) != sample_point) - TRACE_GOTO(chip, Fail); - RTS51X_WRITE_REG(chip, SD_DCMPS_CTL, DCMPS_CHANGE, 0); - RTS51X_WRITE_REG(chip, CLK_DIV, CLK_CHANGE, 0); - udelay(100); - } - - RTS51X_WRITE_REG(chip, SD_CFG1, SD_ASYNC_FIFO_RST, 0); - - return STATUS_SUCCESS; - -Fail: -#ifdef CONFIG_RTS5139_DEBUG - rts51x_ep0_read_register(chip, SD_VP_CTL, &val); - RTS51X_DEBUGP("SD_VP_CTL: 0x%x\n", val); - rts51x_ep0_read_register(chip, SD_DCMPS_CTL, &val); - RTS51X_DEBUGP("SD_DCMPS_CTL: 0x%x\n", val); -#endif - - RTS51X_WRITE_REG(chip, SD_DCMPS_CTL, DCMPS_CHANGE, 0); - RTS51X_WRITE_REG(chip, SD_VP_CTL, PHASE_CHANGE, 0); - wait_timeout(10); - - return STATUS_FAIL; -} - -static int sd_check_spec(struct rts51x_chip *chip, u8 bus_width) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval; - u8 cmd[5], buf[8]; - - retval = - sd_send_cmd_get_rsp(chip, APP_CMD, sd_card->sd_addr, SD_RSP_TYPE_R1, - NULL, 0); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - - cmd[0] = 0x40 | SEND_SCR; - cmd[1] = 0; - cmd[2] = 0; - cmd[3] = 0; - cmd[4] = 0; - - retval = - sd_read_data(chip, SD_TM_NORMAL_READ, cmd, 5, 8, 1, bus_width, buf, - 8, 250); - if (retval != STATUS_SUCCESS) { - rts51x_clear_sd_error(chip); - TRACE_RET(chip, retval); - } - - memcpy(sd_card->raw_scr, buf, 8); - - if ((buf[0] & 0x0F) == 0) - TRACE_RET(chip, STATUS_FAIL); - - return STATUS_SUCCESS; -} - -static int sd_query_switch_result(struct rts51x_chip *chip, u8 func_group, - u8 func_to_switch, u8 *buf, int buf_len) -{ - u8 support_mask = 0, query_switch = 0, switch_busy = 0; - int support_offset = 0, query_switch_offset = 0, check_busy_offset = 0; - - if (func_group == SD_FUNC_GROUP_1) { - support_offset = FUNCTION_GROUP1_SUPPORT_OFFSET; - query_switch_offset = FUNCTION_GROUP1_QUERY_SWITCH_OFFSET; - check_busy_offset = FUNCTION_GROUP1_CHECK_BUSY_OFFSET; - - switch (func_to_switch) { - case HS_SUPPORT: - support_mask = HS_SUPPORT_MASK; - query_switch = HS_QUERY_SWITCH_OK; - switch_busy = HS_SWITCH_BUSY; - break; - - case SDR50_SUPPORT: - support_mask = SDR50_SUPPORT_MASK; - query_switch = SDR50_QUERY_SWITCH_OK; - switch_busy = SDR50_SWITCH_BUSY; - break; - - case SDR104_SUPPORT: - support_mask = SDR104_SUPPORT_MASK; - query_switch = SDR104_QUERY_SWITCH_OK; - switch_busy = SDR104_SWITCH_BUSY; - break; - - case DDR50_SUPPORT: - support_mask = DDR50_SUPPORT_MASK; - query_switch = DDR50_QUERY_SWITCH_OK; - switch_busy = DDR50_SWITCH_BUSY; - break; - - default: - TRACE_RET(chip, STATUS_FAIL); - } - } else if (func_group == SD_FUNC_GROUP_3) { - support_offset = FUNCTION_GROUP3_SUPPORT_OFFSET; - query_switch_offset = FUNCTION_GROUP3_QUERY_SWITCH_OFFSET; - check_busy_offset = FUNCTION_GROUP3_CHECK_BUSY_OFFSET; - - switch (func_to_switch) { - case DRIVING_TYPE_A: - support_mask = DRIVING_TYPE_A_MASK; - query_switch = TYPE_A_QUERY_SWITCH_OK; - switch_busy = TYPE_A_SWITCH_BUSY; - break; - - case DRIVING_TYPE_C: - support_mask = DRIVING_TYPE_C_MASK; - query_switch = TYPE_C_QUERY_SWITCH_OK; - switch_busy = TYPE_C_SWITCH_BUSY; - break; - - case DRIVING_TYPE_D: - support_mask = DRIVING_TYPE_D_MASK; - query_switch = TYPE_D_QUERY_SWITCH_OK; - switch_busy = TYPE_D_SWITCH_BUSY; - break; - - default: - TRACE_RET(chip, STATUS_FAIL); - } - } else if (func_group == SD_FUNC_GROUP_4) { - support_offset = FUNCTION_GROUP4_SUPPORT_OFFSET; - query_switch_offset = FUNCTION_GROUP4_QUERY_SWITCH_OFFSET; - check_busy_offset = FUNCTION_GROUP4_CHECK_BUSY_OFFSET; - - switch (func_to_switch) { - case CURRENT_LIMIT_400: - support_mask = CURRENT_LIMIT_400_MASK; - query_switch = CURRENT_LIMIT_400_QUERY_SWITCH_OK; - switch_busy = CURRENT_LIMIT_400_SWITCH_BUSY; - break; - - case CURRENT_LIMIT_600: - support_mask = CURRENT_LIMIT_600_MASK; - query_switch = CURRENT_LIMIT_600_QUERY_SWITCH_OK; - switch_busy = CURRENT_LIMIT_600_SWITCH_BUSY; - break; - - case CURRENT_LIMIT_800: - support_mask = CURRENT_LIMIT_800_MASK; - query_switch = CURRENT_LIMIT_800_QUERY_SWITCH_OK; - switch_busy = CURRENT_LIMIT_800_SWITCH_BUSY; - break; - - default: - TRACE_RET(chip, STATUS_FAIL); - } - } else { - TRACE_RET(chip, STATUS_FAIL); - } - - if (func_group == SD_FUNC_GROUP_4) - buf[query_switch_offset] = - (buf[query_switch_offset] & 0xf0) >> 4; - if (!(buf[support_offset] & support_mask) || - ((buf[query_switch_offset] & 0x0F) != query_switch)) - TRACE_RET(chip, STATUS_FAIL); - - if ((buf[DATA_STRUCTURE_VER_OFFSET] == 0x01) && - ((buf[check_busy_offset] & switch_busy) == switch_busy)) - TRACE_RET(chip, STATUS_FAIL); - - return STATUS_SUCCESS; -} - -static int sd_check_switch_mode(struct rts51x_chip *chip, u8 mode, - u8 func_group, u8 func_to_switch, u8 bus_width) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval; - u8 cmd[5], buf[64]; - - RTS51X_DEBUGP("sd_check_switch_mode (mode = %d, func_group = %d," - "func_to_switch = %d)\n", mode, func_group, func_to_switch); - - cmd[0] = 0x40 | SWITCH; - cmd[1] = mode; - - if (func_group == SD_FUNC_GROUP_1) { - cmd[2] = 0xFF; - cmd[3] = 0xFF; - cmd[4] = 0xF0 + func_to_switch; - } else if (func_group == SD_FUNC_GROUP_3) { - cmd[2] = 0xFF; - cmd[3] = 0xF0 + func_to_switch; - cmd[4] = 0xFF; - } else if (func_group == SD_FUNC_GROUP_4) { - cmd[2] = 0xFF; - cmd[3] = 0x0F + (func_to_switch << 4); - cmd[4] = 0xFF; - } else { - cmd[1] = SD_CHECK_MODE; - cmd[2] = 0xFF; - cmd[3] = 0xFF; - cmd[4] = 0xFF; - } - - retval = - sd_read_data(chip, SD_TM_NORMAL_READ, cmd, 5, 64, 1, bus_width, buf, - 64, 250); - if (retval != STATUS_SUCCESS) { - rts51x_clear_sd_error(chip); - TRACE_RET(chip, retval); - } - - if (func_group == NO_ARGUMENT) { - sd_card->func_group1_mask = buf[0x0D]; - sd_card->func_group2_mask = buf[0x0B]; - sd_card->func_group3_mask = buf[0x09]; - sd_card->func_group4_mask = buf[0x07]; - - RTS51X_DEBUGP("func_group1_mask = 0x%02x\n", buf[0x0D]); - RTS51X_DEBUGP("func_group2_mask = 0x%02x\n", buf[0x0B]); - RTS51X_DEBUGP("func_group3_mask = 0x%02x\n", buf[0x09]); - RTS51X_DEBUGP("func_group4_mask = 0x%02x\n", buf[0x07]); - } else { - if ((buf[0] == 0) && (buf[1] == 0)) - TRACE_RET(chip, STATUS_FAIL); - retval = - sd_query_switch_result(chip, func_group, func_to_switch, - buf, 64); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - - return STATUS_SUCCESS; -} - -static int sd_check_switch(struct rts51x_chip *chip, - u8 func_group, u8 func_to_switch, u8 bus_width) -{ - int retval; - int i; - int switch_good = 0; - - for (i = 0; i < 3; i++) { - if (monitor_card_cd(chip, SD_CARD) == CD_NOT_EXIST) { - sd_set_reset_fail(chip, SD_RESET_FAIL); - TRACE_RET(chip, STATUS_FAIL); - } - - retval = sd_check_switch_mode(chip, SD_CHECK_MODE, func_group, - func_to_switch, bus_width); - if (retval == STATUS_SUCCESS) { - u8 stat; - - retval = sd_check_switch_mode(chip, SD_SWITCH_MODE, - func_group, func_to_switch, bus_width); - if (retval == STATUS_SUCCESS) { - switch_good = 1; - break; - } - - RTS51X_READ_REG(chip, SD_STAT1, &stat); - - if (stat & SD_CRC16_ERR) { - RTS51X_DEBUGP("SD CRC16 error when switching" - "mode\n"); - TRACE_RET(chip, STATUS_FAIL); - } - } - - wait_timeout(20); - } - - if (!switch_good) - TRACE_RET(chip, STATUS_FAIL); - - return STATUS_SUCCESS; -} - -static int sd_switch_function(struct rts51x_chip *chip, u8 bus_width) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval; - int i; - u8 func_to_switch = 0; - - /* Get supported functions */ - retval = sd_check_switch_mode(chip, SD_CHECK_MODE, - NO_ARGUMENT, NO_ARGUMENT, bus_width); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - sd_card->func_group1_mask &= ~(sd_card->sd_switch_fail); - - for (i = 0; i < 4; i++) { - switch ((u8) (chip->option.sd_speed_prior >> (i * 8))) { - case DDR50_SUPPORT: - if ((sd_card->func_group1_mask & DDR50_SUPPORT_MASK) - && (CHECK_UHS50(chip))) - func_to_switch = DDR50_SUPPORT; - break; - - case SDR50_SUPPORT: - if ((sd_card->func_group1_mask & SDR50_SUPPORT_MASK) - && (CHECK_UHS50(chip))) - func_to_switch = SDR50_SUPPORT; - break; - - case HS_SUPPORT: - if (sd_card->func_group1_mask & HS_SUPPORT_MASK) - func_to_switch = HS_SUPPORT; - break; - - default: - continue; - } - - if (func_to_switch) - break; - } - RTS51X_DEBUGP("SD_FUNC_GROUP_1: func_to_switch = 0x%02x", - func_to_switch); - - if (func_to_switch) { - retval = - sd_check_switch(chip, SD_FUNC_GROUP_1, func_to_switch, - bus_width); - if (retval != STATUS_SUCCESS) { - if (func_to_switch == SDR104_SUPPORT) - sd_card->sd_switch_fail = SDR104_SUPPORT_MASK; - else if (func_to_switch == DDR50_SUPPORT) - sd_card->sd_switch_fail = DDR50_SUPPORT_MASK; - else if (func_to_switch == SDR50_SUPPORT) - sd_card->sd_switch_fail = SDR50_SUPPORT_MASK; - else if (func_to_switch == HS_SUPPORT) - sd_card->sd_switch_fail = HS_SUPPORT_MASK; - - TRACE_RET(chip, retval); - } - - if (func_to_switch == SDR104_SUPPORT) - SET_SD_SDR104(sd_card); - else if (func_to_switch == DDR50_SUPPORT) - SET_SD_DDR50(sd_card); - else if (func_to_switch == SDR50_SUPPORT) - SET_SD_SDR50(sd_card); - else - SET_SD_HS(sd_card); - } - - if (CHK_SD_DDR50(sd_card)) - RTS51X_WRITE_REG(chip, SD_CFG1, 0x0C, SD_DDR_MODE); - - func_to_switch = 0; - if (sd_card->func_group4_mask & CURRENT_LIMIT_400_MASK) - func_to_switch = CURRENT_LIMIT_400; - - if (func_to_switch) { - RTS51X_DEBUGP("Try to switch current_limit_400\n"); - retval = - sd_check_switch(chip, SD_FUNC_GROUP_4, func_to_switch, - bus_width); - RTS51X_DEBUGP("Switch current_limit_400 status: (%d)\n", - retval); - } - - return STATUS_SUCCESS; -} - -static int sd_wait_data_idle(struct rts51x_chip *chip) -{ - int retval = STATUS_TIMEDOUT; - int i; - u8 val = 0; - - for (i = 0; i < 100; i++) { - retval = rts51x_ep0_read_register(chip, SD_DATA_STATE, &val); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - if (val & SD_DATA_IDLE) { - retval = STATUS_SUCCESS; - break; - } - udelay(100); - } - RTS51X_DEBUGP("SD_DATA_STATE: 0x%02x\n", val); - - return retval; -} - -static int sd_sdr_tuning_rx_cmd(struct rts51x_chip *chip, u8 sample_point) -{ - int retval; - u8 cmd[5]; - - retval = sd_change_phase(chip, sample_point, TUNE_RX); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - cmd[0] = 0x40 | SEND_TUNING_PATTERN; - cmd[1] = 0; - cmd[2] = 0; - cmd[3] = 0; - cmd[4] = 0; - - retval = sd_read_data(chip, SD_TM_AUTO_TUNING, - cmd, 5, 0x40, 1, SD_BUS_WIDTH_4, NULL, 0, 100); - if (retval != STATUS_SUCCESS) { - /* Wait till SD DATA IDLE */ - (void)sd_wait_data_idle(chip); - - rts51x_clear_sd_error(chip); - TRACE_RET(chip, STATUS_FAIL); - } - - return STATUS_SUCCESS; -} - -static int sd_ddr_tuning_rx_cmd(struct rts51x_chip *chip, u8 sample_point) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval; - u8 cmd[5]; - - retval = sd_change_phase(chip, sample_point, TUNE_RX); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - RTS51X_DEBUGP("sd ddr tuning rx\n"); - - retval = - sd_send_cmd_get_rsp(chip, APP_CMD, sd_card->sd_addr, SD_RSP_TYPE_R1, - NULL, 0); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - cmd[0] = 0x40 | SD_STATUS; - cmd[1] = 0; - cmd[2] = 0; - cmd[3] = 0; - cmd[4] = 0; - - retval = sd_read_data(chip, SD_TM_NORMAL_READ, - cmd, 5, 64, 1, SD_BUS_WIDTH_4, NULL, 0, 100); - if (retval != STATUS_SUCCESS) { - /* Wait till SD DATA IDLE */ - (void)sd_wait_data_idle(chip); - - rts51x_clear_sd_error(chip); - TRACE_RET(chip, STATUS_FAIL); - } - - return STATUS_SUCCESS; -} - -static int mmc_ddr_tunning_rx_cmd(struct rts51x_chip *chip, u8 sample_point) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval; - u8 cmd[5], bus_width; - - if (CHK_MMC_8BIT(sd_card)) - bus_width = SD_BUS_WIDTH_8; - else if (CHK_MMC_4BIT(sd_card)) - bus_width = SD_BUS_WIDTH_4; - else - bus_width = SD_BUS_WIDTH_1; - - retval = sd_change_phase(chip, sample_point, TUNE_RX); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - RTS51X_DEBUGP("mmc ddr tuning rx\n"); - - cmd[0] = 0x40 | SEND_EXT_CSD; - cmd[1] = 0; - cmd[2] = 0; - cmd[3] = 0; - cmd[4] = 0; - - retval = sd_read_data(chip, SD_TM_NORMAL_READ, - cmd, 5, 0x200, 1, bus_width, NULL, 0, 100); - if (retval != STATUS_SUCCESS) { - /* Wait till SD DATA IDLE */ - (void)sd_wait_data_idle(chip); - - rts51x_clear_sd_error(chip); - TRACE_RET(chip, STATUS_FAIL); - } - - return STATUS_SUCCESS; -} - -static int sd_sdr_tuning_tx_cmd(struct rts51x_chip *chip, u8 sample_point) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval; - - retval = sd_change_phase(chip, sample_point, TUNE_TX); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - RTS51X_WRITE_REG(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN, - SD_RSP_80CLK_TIMEOUT_EN); - - retval = sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, - SD_RSP_TYPE_R1, NULL, 0); - if (retval != STATUS_SUCCESS) { - if (sd_check_err_code(chip, SD_RSP_TIMEOUT)) { - /* Tunning TX fail */ - rts51x_ep0_write_register(chip, SD_CFG3, - SD_RSP_80CLK_TIMEOUT_EN, 0); - TRACE_RET(chip, STATUS_FAIL); - } - } - - RTS51X_WRITE_REG(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN, 0); - - return STATUS_SUCCESS; -} - -static int sd_ddr_tuning_tx_cmd(struct rts51x_chip *chip, u8 sample_point) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval; - u8 cmd[5], bus_width; - - retval = sd_change_phase(chip, sample_point, TUNE_TX); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (CHK_SD(sd_card)) { - bus_width = SD_BUS_WIDTH_4; - } else { - if (CHK_MMC_8BIT(sd_card)) - bus_width = SD_BUS_WIDTH_8; - else if (CHK_MMC_4BIT(sd_card)) - bus_width = SD_BUS_WIDTH_4; - else - bus_width = SD_BUS_WIDTH_1; - } - retval = sd_wait_currentstate_dataready(chip, 0x08, 1, 20); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - - RTS51X_WRITE_REG(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN, - SD_RSP_80CLK_TIMEOUT_EN); - - cmd[0] = 0x40 | PROGRAM_CSD; - cmd[1] = 0; - cmd[2] = 0; - cmd[3] = 0; - cmd[4] = 0; - - retval = sd_write_data(chip, SD_TM_AUTO_WRITE_2, - cmd, 5, 16, 1, bus_width, sd_card->raw_csd, 16, 100); - if (retval != STATUS_SUCCESS) { - rts51x_clear_sd_error(chip); - /* Tunning TX fail */ - rts51x_ep0_write_register(chip, SD_CFG3, - SD_RSP_80CLK_TIMEOUT_EN, 0); - TRACE_RET(chip, STATUS_FAIL); - } - - RTS51X_WRITE_REG(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN, 0); - - sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, SD_RSP_TYPE_R1, - NULL, 0); - - return STATUS_SUCCESS; -} - -static u8 sd_search_final_phase(struct rts51x_chip *chip, u32 phase_map, - u8 tune_dir) -{ - struct sd_info *sd_card = &(chip->sd_card); - struct timing_phase_path path[MAX_PHASE + 1]; - int i, j, cont_path_cnt; - int new_block, max_len; - u8 final_phase = 0xFF; - int final_path_idx; - - if (phase_map == 0xffff) { - if (CHK_SD_DDR50(sd_card)) { - if (tune_dir == TUNE_TX) - final_phase = chip->option.ddr50_tx_phase; - else - final_phase = chip->option.ddr50_rx_phase; - RTS51X_DEBUGP("DDR50 tuning dir:%d all pass," - "so select default phase:0x%x.\n", - tune_dir, final_phase); - } else { - if (tune_dir == TUNE_TX) - final_phase = chip->option.sdr50_tx_phase; - else - final_phase = chip->option.sdr50_rx_phase; - RTS51X_DEBUGP("SDR50 tuning dir:%d all pass," - "so select default phase:0x%x.\n", - tune_dir, final_phase); - } - goto Search_Finish; - } - - cont_path_cnt = 0; - new_block = 1; - j = 0; - for (i = 0; i < MAX_PHASE + 1; i++) { - if (phase_map & (1 << i)) { - if (new_block) { - new_block = 0; - j = cont_path_cnt++; - path[j].start = i; - path[j].end = i; - } else { - path[j].end = i; - } - } else { - new_block = 1; - if (cont_path_cnt) { - int idx = cont_path_cnt - 1; - path[idx].len = - path[idx].end - path[idx].start + 1; - path[idx].mid = - path[idx].start + path[idx].len / 2; - } - } - } - - if (cont_path_cnt == 0) { - RTS51X_DEBUGP("No continuous phase path\n"); - goto Search_Finish; - } else { - int idx = cont_path_cnt - 1; - path[idx].len = path[idx].end - path[idx].start + 1; - path[idx].mid = path[idx].start + path[idx].len / 2; - } - - if ((path[0].start == 0) && - (path[cont_path_cnt - 1].end == MAX_PHASE)) { - path[0].start = path[cont_path_cnt - 1].start - MAX_PHASE - 1; - path[0].len += path[cont_path_cnt - 1].len; - path[0].mid = path[0].start + path[0].len / 2; - if (path[0].mid < 0) - path[0].mid += MAX_PHASE + 1; - cont_path_cnt--; - } - max_len = 0; - final_phase = 0; - final_path_idx = 0; - for (i = 0; i < cont_path_cnt; i++) { - if (path[i].len > max_len) { - max_len = path[i].len; - final_phase = (u8) path[i].mid; - final_path_idx = i; - } - - RTS51X_DEBUGP("path[%d].start = %d\n", i, path[i].start); - RTS51X_DEBUGP("path[%d].end = %d\n", i, path[i].end); - RTS51X_DEBUGP("path[%d].len = %d\n", i, path[i].len); - RTS51X_DEBUGP("path[%d].mid = %d\n", i, path[i].mid); - RTS51X_DEBUGP("\n"); - } - - if ((tune_dir == TUNE_TX) && (CHK_SD_SDR50(sd_card)) - && chip->option.sdr50_phase_sel) { - if (max_len > 6) { - int temp_mid = (max_len - 6) / 2; - int temp_final_phase = - path[final_path_idx].end - (max_len - - (3 + temp_mid)); - - if (temp_final_phase < 0) - final_phase = temp_final_phase + MAX_PHASE + 1; - else - final_phase = (u8) temp_final_phase; - } - } - -Search_Finish: - RTS51X_DEBUGP("Final chosen phase: %d\n", final_phase); - return final_phase; -} - -static int sd_tuning_rx(struct rts51x_chip *chip) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval; - int i, j; - u32 raw_phase_map[3], phase_map; - u8 final_phase; - int (*tuning_cmd)(struct rts51x_chip *chip, u8 sample_point); - - if (CHK_SD(sd_card)) { - if (CHK_SD_DDR50(sd_card)) - tuning_cmd = sd_ddr_tuning_rx_cmd; - else - tuning_cmd = sd_sdr_tuning_rx_cmd; - } else { - if (CHK_MMC_DDR52(sd_card)) - tuning_cmd = mmc_ddr_tunning_rx_cmd; - else - TRACE_RET(chip, STATUS_FAIL); - } - - for (i = 0; i < 3; i++) { - raw_phase_map[i] = 0; - for (j = MAX_PHASE; j >= 0; j--) { - if (monitor_card_cd(chip, SD_CARD) == CD_NOT_EXIST) { - sd_set_reset_fail(chip, SD_RESET_FAIL); - TRACE_RET(chip, STATUS_FAIL); - } - - retval = tuning_cmd(chip, (u8) j); - if (retval == STATUS_SUCCESS) - raw_phase_map[i] |= 1 << j; - else - RTS51X_DEBUGP("Tuning phase %d fail\n", j); - } - } - - phase_map = raw_phase_map[0] & raw_phase_map[1] & raw_phase_map[2]; - for (i = 0; i < 3; i++) - RTS51X_DEBUGP("RX raw_phase_map[%d] = 0x%04x\n", i, - raw_phase_map[i]); - RTS51X_DEBUGP("RX phase_map = 0x%04x\n", phase_map); - - final_phase = sd_search_final_phase(chip, phase_map, TUNE_RX); - if (final_phase == 0xFF) - TRACE_RET(chip, STATUS_FAIL); - - retval = tuning_cmd(chip, final_phase); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - return STATUS_SUCCESS; -} - -static int sd_ddr_pre_tuning_tx(struct rts51x_chip *chip) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval; - u8 i; - u8 pre_tune_tx_phase; - u32 pre_tune_phase_map; - - RTS51X_WRITE_REG(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN, - SD_RSP_80CLK_TIMEOUT_EN); - - pre_tune_tx_phase = 0xFF; - pre_tune_phase_map = 0x0000; - for (i = 0; i < MAX_PHASE + 1; i++) { - if (monitor_card_cd(chip, SD_CARD) == CD_NOT_EXIST) { - sd_set_reset_fail(chip, SD_RESET_FAIL); - TRACE_RET(chip, STATUS_FAIL); - } - - retval = sd_change_phase(chip, (u8) i, TUNE_TX); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = - sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, - SD_RSP_TYPE_R1, NULL, 0); - if ((retval == STATUS_SUCCESS) - || !sd_check_err_code(chip, SD_RSP_TIMEOUT)) - pre_tune_phase_map |= (u32) 1 << i; - } - - RTS51X_WRITE_REG(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN, 0); - - pre_tune_tx_phase = - sd_search_final_phase(chip, pre_tune_phase_map, TUNE_TX); - if (pre_tune_tx_phase == 0xFF) - TRACE_RET(chip, STATUS_FAIL); - - sd_change_phase(chip, pre_tune_tx_phase, TUNE_TX); - RTS51X_DEBUGP("DDR TX pre tune phase: %d\n", (int)pre_tune_tx_phase); - - return STATUS_SUCCESS; -} - -static int sd_tuning_tx(struct rts51x_chip *chip) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval; - int i, j; - u32 raw_phase_map[3], phase_map; - u8 final_phase; - int (*tuning_cmd)(struct rts51x_chip *chip, u8 sample_point); - - if (CHK_SD(sd_card)) { - if (CHK_SD_DDR50(sd_card)) - tuning_cmd = sd_ddr_tuning_tx_cmd; - else - tuning_cmd = sd_sdr_tuning_tx_cmd; - } else { - if (CHK_MMC_DDR52(sd_card)) - tuning_cmd = sd_ddr_tuning_tx_cmd; - else - TRACE_RET(chip, STATUS_FAIL); - } - - for (i = 0; i < 3; i++) { - raw_phase_map[i] = 0; - for (j = MAX_PHASE; j >= 0; j--) { - if (monitor_card_cd(chip, SD_CARD) == CD_NOT_EXIST) { - sd_set_reset_fail(chip, SD_RESET_FAIL); - TRACE_RET(chip, STATUS_FAIL); - } - - retval = tuning_cmd(chip, (u8) j); - if (retval == STATUS_SUCCESS) - raw_phase_map[i] |= 1 << j; - else - RTS51X_DEBUGP("Tuning phase %d fail\n", j); - } - } - - phase_map = raw_phase_map[0] & raw_phase_map[1] & raw_phase_map[2]; - for (i = 0; i < 3; i++) - RTS51X_DEBUGP("TX raw_phase_map[%d] = 0x%04x\n", i, - raw_phase_map[i]); - RTS51X_DEBUGP("TX phase_map = 0x%04x\n", phase_map); - - final_phase = sd_search_final_phase(chip, phase_map, TUNE_TX); - if (final_phase == 0xFF) - TRACE_RET(chip, STATUS_FAIL); - - retval = tuning_cmd(chip, final_phase); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - return STATUS_SUCCESS; -} - -static int sd_sdr_tuning(struct rts51x_chip *chip) -{ - int retval; - - retval = sd_tuning_tx(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = sd_tuning_rx(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - return STATUS_SUCCESS; -} - -static int sd_ddr_tuning(struct rts51x_chip *chip) -{ - int retval; - - if (!(chip->option.sd_ctl & SD_DDR_TX_PHASE_SET_BY_USER)) { - retval = sd_ddr_pre_tuning_tx(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } else { - retval = - sd_change_phase(chip, (u8) chip->option.sd_ddr_tx_phase, - TUNE_TX); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - - retval = sd_tuning_rx(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (!(chip->option.sd_ctl & SD_DDR_TX_PHASE_SET_BY_USER)) { - retval = sd_tuning_tx(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - - return STATUS_SUCCESS; -} - -static int mmc_ddr_tuning(struct rts51x_chip *chip) -{ - int retval; - - if (!(chip->option.sd_ctl & MMC_DDR_TX_PHASE_SET_BY_USER)) { - retval = sd_ddr_pre_tuning_tx(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } else { - retval = - sd_change_phase(chip, (u8) chip->option.mmc_ddr_tx_phase, - TUNE_TX); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - - retval = sd_tuning_rx(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (!(chip->option.sd_ctl & MMC_DDR_TX_PHASE_SET_BY_USER)) { - retval = sd_tuning_tx(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - - return STATUS_SUCCESS; -} - -int rts51x_sd_switch_clock(struct rts51x_chip *chip) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval; - int re_tuning = 0; - - retval = rts51x_select_card(chip, SD_CARD); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (CHK_SD30_SPEED(sd_card) || CHK_MMC_DDR52(sd_card)) { - if (sd_card->sd_clock != chip->cur_clk) - re_tuning = 1; - } - - retval = switch_clock(chip, sd_card->sd_clock); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (re_tuning) { - if (CHK_SD(sd_card)) { - if (CHK_SD_DDR50(sd_card)) - retval = sd_ddr_tuning(chip); - else - retval = sd_sdr_tuning(chip); - } else { - if (CHK_MMC_DDR52(sd_card)) - retval = mmc_ddr_tuning(chip); - } - - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - - return STATUS_SUCCESS; -} - -static int sd_prepare_reset(struct rts51x_chip *chip) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval; - - if (chip->asic_code) - sd_card->sd_clock = 29; - else - sd_card->sd_clock = CLK_30; - - /* Set SD Clocks */ - retval = sd_set_init_para(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG1, 0xFF, - SD_CLK_DIVIDE_128 | SD_20_MODE | SD_BUS_WIDTH_1); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_SAMPLE_POINT_CTL, 0xFF, - SD20_RX_POS_EDGE); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_PUSH_POINT_CTL, 0xFF, 0); - - retval = rts51x_send_cmd(chip, MODE_C, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = rts51x_select_card(chip, SD_CARD); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - return STATUS_SUCCESS; -} - -static void sd_pull_ctl_disable(struct rts51x_chip *chip) -{ - if (CHECK_PKG(chip, LQFP48)) { - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0x95); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0xA5); - } else { - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0x65); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0x95); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x56); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0x59); - } -} - -static void sd_pull_ctl_enable(struct rts51x_chip *chip) -{ - if (CHECK_PKG(chip, LQFP48)) { - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0xAA); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0xAA); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0xA9); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0xA5); - } else { - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0xA5); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0x9A); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0xA5); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x9A); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x65); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0x5A); - } -} - -static int sd_init_power(struct rts51x_chip *chip) -{ - int retval; - - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, LDO3318_PWR_MASK, - LDO_ON); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_PAD_CTL, SD_IO_USING_1V8, - SD_IO_USING_3V3); - if (chip->asic_code) - rts51x_add_cmd(chip, WRITE_REG_CMD, LDO_POWER_CFG, - TUNE_SD18_MASK, TUNE_SD18_3V3); - if (chip->asic_code) - sd_pull_ctl_disable(chip); - else - rts51x_add_cmd(chip, WRITE_REG_CMD, FPGA_PULL_CTL, - FPGA_SD_PULL_CTL_BIT | 0x20, - FPGA_SD_PULL_CTL_BIT); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_OE, SD_OUTPUT_EN, 0); - if (!chip->option.FT2_fast_mode) - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, POWER_MASK, - POWER_OFF); - - retval = rts51x_send_cmd(chip, MODE_C, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - if (!chip->option.FT2_fast_mode) { -#ifdef SD_XD_IO_FOLLOW_PWR - if (CHECK_PKG(chip, LQFP48) - || chip->option.rts5129_D3318_off_enable) - rts51x_write_register(chip, CARD_PWR_CTL, - LDO_OFF, LDO_OFF); -#endif - wait_timeout(250); - -#ifdef SD_XD_IO_FOLLOW_PWR - if (CHECK_PKG(chip, LQFP48) - || chip->option.rts5129_D3318_off_enable) { - rts51x_init_cmd(chip); - if (chip->asic_code) - sd_pull_ctl_enable(chip); - else - rts51x_add_cmd(chip, WRITE_REG_CMD, - FPGA_PULL_CTL, - FPGA_SD_PULL_CTL_BIT | 0x20, 0); - retval = rts51x_send_cmd(chip, MODE_C, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } else { - if (chip->asic_code) - rts51x_write_register(chip, CARD_PULL_CTL6, - 0x03, 0x00); - } -#endif - - /* Power on card */ - retval = rts51x_card_power_on(chip, SD_CARD); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - wait_timeout(260); - -#ifdef SUPPORT_OCP - rts51x_get_card_status(chip, &(chip->card_status)); - chip->ocp_stat = (chip->card_status >> 4) & 0x03; - - if (chip->ocp_stat & (MS_OCP_NOW | MS_OCP_EVER)) { - RTS51X_DEBUGP("Over current, OCPSTAT is 0x%x\n", - chip->ocp_stat); - TRACE_RET(chip, STATUS_FAIL); - } -#endif - } - - rts51x_init_cmd(chip); - if (chip->asic_code) { - sd_pull_ctl_enable(chip); - } else { - rts51x_add_cmd(chip, WRITE_REG_CMD, FPGA_PULL_CTL, - FPGA_SD_PULL_CTL_BIT | 0x20, 0); - } - retval = rts51x_send_cmd(chip, MODE_C, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); -#ifdef SD_XD_IO_FOLLOW_PWR - rts51x_write_register(chip, CARD_INT_PEND, XD_INT | MS_INT | SD_INT, - XD_INT | MS_INT | SD_INT); -#endif - - RTS51X_WRITE_REG(chip, CARD_OE, SD_OUTPUT_EN, SD_OUTPUT_EN); - - return STATUS_SUCCESS; -} - -static int sd_dummy_clock(struct rts51x_chip *chip) -{ - RTS51X_WRITE_REG(chip, SD_BUS_STAT, SD_CLK_TOGGLE_EN, SD_CLK_TOGGLE_EN); - wait_timeout(5); - RTS51X_WRITE_REG(chip, SD_BUS_STAT, SD_CLK_TOGGLE_EN, 0x00); - - return STATUS_SUCCESS; -} - -int reset_sd(struct rts51x_chip *chip) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval, i = 0, j = 0, k = 0, hi_cap_flow = 0; - int sd_dont_switch = 0; - int support_1v8 = 0; - u8 rsp[16]; - u8 switch_bus_width; - u32 voltage = 0; - u8 cmd[5], buf[64]; - u16 sd_card_type; - - SET_SD(sd_card); - CLR_RETRY_SD20_MODE(sd_card); -Switch_Fail: - i = 0; - j = 0; - k = 0; - hi_cap_flow = 0; - support_1v8 = 0; - - retval = sd_prepare_reset(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - sd_dummy_clock(chip); - - /* Start Initialization Process of SD Card */ -RTY_SD_RST: - retval = - sd_send_cmd_get_rsp(chip, GO_IDLE_STATE, 0, SD_RSP_TYPE_R0, NULL, - 0); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - wait_timeout(20); - - retval = - sd_send_cmd_get_rsp(chip, SEND_IF_COND, 0x000001AA, SD_RSP_TYPE_R7, - rsp, 5); - if (retval == STATUS_SUCCESS) { - if ((rsp[4] == 0xAA) && ((rsp[3] & 0x0f) == 0x01)) { - hi_cap_flow = 1; - if (CHK_RETRY_SD20_MODE(sd_card)) { - voltage = - SUPPORT_VOLTAGE | - SUPPORT_HIGH_AND_EXTENDED_CAPACITY; - } else { - voltage = - SUPPORT_VOLTAGE | - SUPPORT_HIGH_AND_EXTENDED_CAPACITY | - SUPPORT_MAX_POWER_PERMANCE | SUPPORT_1V8; - } - } - } - - if (!hi_cap_flow) { - voltage = SUPPORT_VOLTAGE; - - retval = - sd_send_cmd_get_rsp(chip, GO_IDLE_STATE, 0, SD_RSP_TYPE_R0, - NULL, 0); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - wait_timeout(20); - } - - /* ACMD41 */ - do { - { - u8 temp = 0; - rts51x_read_register(chip, CARD_INT_PEND, &temp); - RTS51X_DEBUGP("CARD_INT_PEND:%x\n", temp); - if (temp & SD_INT) { - chip->reset_need_retry = 1; - rts51x_write_register(chip, CARD_INT_PEND, - XD_INT | SD_INT | MS_INT, - XD_INT | SD_INT | MS_INT); - sd_set_reset_fail(chip, SD_RESET_FAIL); - TRACE_RET(chip, STATUS_FAIL); - } - } - -RTY_CMD55: - retval = - sd_send_cmd_get_rsp(chip, APP_CMD, 0, SD_RSP_TYPE_R1, NULL, - 0); - if (retval != STATUS_SUCCESS) { - if (monitor_card_cd(chip, SD_CARD) == CD_NOT_EXIST) { - sd_set_reset_fail(chip, SD_RESET_FAIL); - TRACE_RET(chip, STATUS_FAIL); - } - - j++; - if (chip->option.speed_mmc) { - if (j < 2) - goto RTY_CMD55; - else - TRACE_RET(chip, STATUS_FAIL); - } else { - if (j < 3) - goto RTY_SD_RST; - else - TRACE_RET(chip, STATUS_FAIL); - } - } - - retval = - sd_send_cmd_get_rsp(chip, SD_APP_OP_COND, voltage, - SD_RSP_TYPE_R3, rsp, 5); - if (retval != STATUS_SUCCESS) { - k++; - if (k < 3) - goto RTY_SD_RST; - else - TRACE_RET(chip, STATUS_FAIL); - } - - i++; - wait_timeout(20); - } while (!(rsp[1] & 0x80) && (i < 255)); /* Not complete power on */ - - if (i == 255) { - /* Time out */ - TRACE_RET(chip, STATUS_FAIL); - } - - if (hi_cap_flow) { - if (rsp[1] & 0x40) - SET_SD_HCXC(sd_card); - else - CLR_SD_HCXC(sd_card); - if (!CHK_RETRY_SD20_MODE(sd_card)) { - if ((CHK_SD_HCXC(sd_card)) && (CHECK_UHS50(chip))) { - support_1v8 = (rsp[1] & 0x01) ? 1 : 0; - RTS51X_DEBUGP("support_1v8 = %d\n", - support_1v8); - } - } - } else { - CLR_SD_HCXC(sd_card); - support_1v8 = 0; - } - - /* CMD11: Switch Voltage */ - if (support_1v8 && CHECK_UHS50(chip) - && !(((u8) chip->option.sd_speed_prior & SDR104_SUPPORT) == - HS_SUPPORT)) { - retval = sd_voltage_switch(chip); - if (retval != STATUS_SUCCESS) { - SET_RETRY_SD20_MODE(sd_card); - sd_init_power(chip); - RTS51X_DEBUGP("1.8v switch fail\n"); - goto Switch_Fail; - } - } - - /* CMD 2 */ - retval = - sd_send_cmd_get_rsp(chip, ALL_SEND_CID, 0, SD_RSP_TYPE_R2, NULL, 0); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - /* CMD 3 */ - retval = - sd_send_cmd_get_rsp(chip, SEND_RELATIVE_ADDR, 0, SD_RSP_TYPE_R6, - rsp, 5); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - sd_card->sd_addr = (u32) rsp[1] << 24; - sd_card->sd_addr += (u32) rsp[2] << 16; - - /* Get CSD register for Calculating Timing,Capacity, - * Check CSD to determine as if this is the SD ROM card */ - retval = sd_check_csd(chip, 1); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - /* Select SD card */ - retval = rts51x_sd_select_card(chip, 1); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - /* ACMD42 */ - retval = - sd_send_cmd_get_rsp(chip, APP_CMD, sd_card->sd_addr, SD_RSP_TYPE_R1, - NULL, 0); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = - sd_send_cmd_get_rsp(chip, SET_CLR_CARD_DETECT, 0, SD_RSP_TYPE_R1, - NULL, 0); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (support_1v8) { - /* ACMD6 */ - retval = - sd_send_cmd_get_rsp(chip, APP_CMD, sd_card->sd_addr, - SD_RSP_TYPE_R1, NULL, 0); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - /* Enable 4 bit data bus */ - retval = - sd_send_cmd_get_rsp(chip, SET_BUS_WIDTH, 2, SD_RSP_TYPE_R1, - NULL, 0); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - switch_bus_width = SD_BUS_WIDTH_4; - } else { - switch_bus_width = SD_BUS_WIDTH_1; - } - - /* Set block length 512 bytes for all block commands */ - retval = sd_send_cmd_get_rsp(chip, SET_BLOCKLEN, - 0x200, SD_RSP_TYPE_R1, NULL, 0); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - RTS51X_WRITE_REG(chip, SD_CFG1, SD_CLK_DIVIDE_MASK, SD_CLK_DIVIDE_0); - - if (!(sd_card->raw_csd[4] & 0x40)) { - sd_dont_switch = 1; - RTS51X_DEBUGP("Not support class ten\n"); - } - - if (!sd_dont_switch) { - /* Check the card whether flow SD1.1 spec or higher */ - retval = sd_check_spec(chip, switch_bus_width); - if (retval == STATUS_SUCCESS) { - retval = sd_switch_function(chip, switch_bus_width); - if (retval != STATUS_SUCCESS) { - if ((sd_card->sd_switch_fail == - SDR104_SUPPORT_MASK) - || (sd_card->sd_switch_fail == - DDR50_SUPPORT_MASK) - || (sd_card->sd_switch_fail == - SDR50_SUPPORT_MASK)) { - sd_init_power(chip); - SET_RETRY_SD20_MODE(sd_card); - } else if (sd_card->sd_switch_fail == - HS_SUPPORT_MASK) { - sd_dont_switch = 1; - } - goto Switch_Fail; - } - } else { - if (support_1v8) { - SET_RETRY_SD20_MODE(sd_card); - sd_init_power(chip); - sd_dont_switch = 1; - - goto Switch_Fail; - } - } - } - - if (!support_1v8) { - /* ACMD6 */ - retval = - sd_send_cmd_get_rsp(chip, APP_CMD, sd_card->sd_addr, - SD_RSP_TYPE_R1, NULL, 0); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - /* Enable 4 bit data bus */ - retval = - sd_send_cmd_get_rsp(chip, SET_BUS_WIDTH, 2, SD_RSP_TYPE_R1, - NULL, 0); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - - if (CHK_SD30_SPEED(sd_card)) { - rts51x_write_register(chip, SD30_DRIVE_SEL, SD30_DRIVE_MASK, - 0x03); - - retval = sd_set_init_para(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (CHK_SD_DDR50(sd_card)) - retval = sd_ddr_tuning(chip); - else - retval = sd_sdr_tuning(chip); - - if (retval != STATUS_SUCCESS) { - SET_RETRY_SD20_MODE(sd_card); - RTS51X_DEBUGP("tuning phase fail,goto SD20 mode\n"); - sd_init_power(chip); - CLR_SD30_SPEED(sd_card); - goto Switch_Fail; - } - if (STATUS_SUCCESS == - sd_wait_currentstate_dataready(chip, 0x08, 1, 20)) { - cmd[0] = 0x40 | READ_SINGLE_BLOCK; - cmd[1] = 0x00; - cmd[2] = 0x00; - cmd[3] = 0x00; - cmd[4] = 0x00; - retval = - sd_read_data(chip, SD_TM_NORMAL_READ, cmd, 5, 512, - 1, SD_BUS_WIDTH_4, NULL, 0, 600); - if (retval != STATUS_SUCCESS) { - SET_RETRY_SD20_MODE(sd_card); - RTS51X_DEBUGP("read lba0 fail," - "goto SD20 mode\n"); - sd_init_power(chip); - CLR_SD30_SPEED(sd_card); - goto Switch_Fail; - } - } - } - sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, SD_RSP_TYPE_R1, - NULL, 0); - - retval = sd_send_cmd_get_rsp(chip, APP_CMD, sd_card->sd_addr, - SD_RSP_TYPE_R1, NULL, 0); - if (retval == STATUS_SUCCESS) { - int ret; - cmd[0] = 0x40 | SEND_STATUS; - cmd[1] = 0x00; - cmd[2] = 0x00; - cmd[3] = 0x00; - cmd[4] = 0x00; - ret = - sd_read_data(chip, SD_TM_NORMAL_READ, cmd, 5, 64, 1, - SD_BUS_WIDTH_4, buf, 64, 600); - if (ret == STATUS_SUCCESS) { - sd_card_type = ((u16) buf[2] << 8) | (u16) buf[3]; - RTS51X_DEBUGP("sd_card_type:0x%4x\n", sd_card_type); - if ((sd_card_type == 0x0001) - || (sd_card_type == 0x0002)) - chip->card_wp |= SD_CARD; - } else { - rts51x_clear_sd_error(chip); - sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, - SD_RSP_TYPE_R1, NULL, 0); - } - } else { - rts51x_clear_sd_error(chip); - sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, - SD_RSP_TYPE_R1, NULL, 0); - } - - /* Check SD Machanical Write-Protect Switch */ - retval = rts51x_get_card_status(chip, &(chip->card_status)); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - if (chip->card_status & SD_WP) - chip->card_wp |= SD_CARD; - - chip->card_bus_width[chip->card2lun[SD_CARD]] = 4; - - return STATUS_SUCCESS; -} - -static int mmc_test_switch_bus(struct rts51x_chip *chip, u8 width) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval; - u8 buf[8] = { 0 }, bus_width; - u16 byte_cnt; - int len; - - retval = - sd_send_cmd_get_rsp(chip, BUSTEST_W, 0, SD_RSP_TYPE_R1, NULL, 0); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (width == MMC_8BIT_BUS) { - buf[0] = 0x55; - buf[1] = 0xAA; - len = 8; - byte_cnt = 8; - bus_width = SD_BUS_WIDTH_8; - } else { - buf[0] = 0x5A; - len = 4; - byte_cnt = 4; - bus_width = SD_BUS_WIDTH_4; - } - - retval = sd_write_data(chip, SD_TM_AUTO_WRITE_3, - NULL, 0, byte_cnt, 1, bus_width, buf, len, 100); - if (retval != STATUS_SUCCESS) { - u8 val1 = 0, val2 = 0; - rts51x_ep0_read_register(chip, SD_STAT1, &val1); - rts51x_ep0_read_register(chip, SD_STAT2, &val2); - rts51x_clear_sd_error(chip); - if ((val1 & 0xE0) || val2) - TRACE_RET(chip, STATUS_FAIL); - } - RTS51X_DEBUGP("SD/MMC CMD %d\n", BUSTEST_R); - - rts51x_init_cmd(chip); - - /* CMD14 */ - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD0, 0xFF, 0x40 | BUSTEST_R); - - if (width == MMC_8BIT_BUS) - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_L, 0xFF, 0x08); - else - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_L, 0xFF, 0x04); - - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_L, 0xFF, 1); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_H, 0xFF, 0); - - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG2, 0xFF, - SD_CALCULATE_CRC7 | SD_NO_CHECK_CRC16 | - SD_NO_WAIT_BUSY_END | SD_CHECK_CRC7 | SD_RSP_LEN_6); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, - PINGPONG_BUFFER); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_TRANSFER, 0xFF, - SD_TM_NORMAL_READ | SD_TRANSFER_START); - rts51x_add_cmd(chip, CHECK_REG_CMD, SD_TRANSFER, SD_TRANSFER_END, - SD_TRANSFER_END); - - rts51x_add_cmd(chip, READ_REG_CMD, PPBUF_BASE2, 0, 0); - if (width == MMC_8BIT_BUS) { - len = 3; - rts51x_add_cmd(chip, READ_REG_CMD, PPBUF_BASE2 + 1, 0, 0); - } else { - len = 2; - } - - retval = rts51x_send_cmd(chip, MODE_CR, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = rts51x_get_rsp(chip, len, 100); - if (CHECK_SD_TRANS_FAIL(chip, retval)) { - rts51x_clear_sd_error(chip); - TRACE_RET(chip, STATUS_FAIL); - } - - rts51x_read_rsp_buf(chip, 1, buf, 2); - - if (width == MMC_8BIT_BUS) { - RTS51X_DEBUGP("BUSTEST_R [8bits]: 0x%02x 0x%02x\n", - buf[0], buf[1]); - if ((buf[0] == 0xAA) && (buf[1] == 0x55)) { - u8 rsp[5]; - u32 arg; - - if (CHK_MMC_DDR52(sd_card)) - arg = 0x03B70600; - else - arg = 0x03B70200; - /* Switch MMC to 8-bit mode */ - retval = - sd_send_cmd_get_rsp(chip, SWITCH, arg, - SD_RSP_TYPE_R1b, rsp, 5); - if ((retval == STATUS_SUCCESS) - && !(rsp[4] & MMC_SWITCH_ERR)) - return STATUS_SUCCESS; - } - } else { - RTS51X_DEBUGP("BUSTEST_R [4bits]: 0x%02x\n", buf[0]); - if (buf[0] == 0xA5) { - u8 rsp[5]; - u32 arg; - - if (CHK_MMC_DDR52(sd_card)) - arg = 0x03B70500; - else - arg = 0x03B70100; - /* Switch MMC to 4-bit mode */ - retval = - sd_send_cmd_get_rsp(chip, SWITCH, arg, - SD_RSP_TYPE_R1b, rsp, 5); - if ((retval == STATUS_SUCCESS) - && !(rsp[4] & MMC_SWITCH_ERR)) - return STATUS_SUCCESS; - } - } - - TRACE_RET(chip, STATUS_FAIL); -} - -static int mmc_switch_timing_bus(struct rts51x_chip *chip) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval; - u8 card_type, card_type_mask = 0; - u8 buf[6]; - - CLR_MMC_HS(sd_card); - - RTS51X_DEBUGP("SD/MMC CMD %d\n", SEND_EXT_CSD); - - rts51x_init_cmd(chip); - - /* SEND_EXT_CSD command */ - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD0, 0xFF, - 0x40 | SEND_EXT_CSD); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD1, 0xFF, 0); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD2, 0xFF, 0); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD3, 0xFF, 0); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD4, 0xFF, 0); - - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_L, 0xFF, 0); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_H, 0xFF, 2); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_L, 0xFF, 1); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_H, 0xFF, 0); - - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG2, 0xFF, - SD_CALCULATE_CRC7 | SD_CHECK_CRC16 | SD_NO_WAIT_BUSY_END - | SD_CHECK_CRC7 | SD_RSP_LEN_6); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, - PINGPONG_BUFFER); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_TRANSFER, 0xFF, - SD_TM_NORMAL_READ | SD_TRANSFER_START); - rts51x_add_cmd(chip, CHECK_REG_CMD, SD_TRANSFER, SD_TRANSFER_END, - SD_TRANSFER_END); - - rts51x_add_cmd(chip, READ_REG_CMD, PPBUF_BASE2 + 196, 0xFF, 0); - rts51x_add_cmd(chip, READ_REG_CMD, PPBUF_BASE2 + 212, 0xFF, 0); - rts51x_add_cmd(chip, READ_REG_CMD, PPBUF_BASE2 + 213, 0xFF, 0); - rts51x_add_cmd(chip, READ_REG_CMD, PPBUF_BASE2 + 214, 0xFF, 0); - rts51x_add_cmd(chip, READ_REG_CMD, PPBUF_BASE2 + 215, 0xFF, 0); - - retval = rts51x_send_cmd(chip, MODE_CR, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = rts51x_get_rsp(chip, 6, 1000); - - if (CHECK_SD_TRANS_FAIL(chip, retval)) { - if (retval == STATUS_TIMEDOUT) { - rts51x_clear_sd_error(chip); - sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, - SD_RSP_TYPE_R1, NULL, 0); - } - TRACE_RET(chip, STATUS_FAIL); - } - - rts51x_read_rsp_buf(chip, 0, buf, 6); - - if (buf[0] & SD_TRANSFER_ERR) { - sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, - SD_RSP_TYPE_R1, NULL, 0); - TRACE_RET(chip, STATUS_FAIL); - } - if (CHK_MMC_SECTOR_MODE(sd_card)) - sd_card->capacity = - ((u32) buf[5] << 24) | ((u32) buf[4] << 16) | - ((u32) buf[3] << 8) | ((u32) buf[2]); - if (CHECK_UHS50(chip)) - card_type_mask = 0x07; - else - card_type_mask = 0x03; - - card_type = buf[1] & card_type_mask; - if (card_type) { - /* CARD TYPE FIELD = DDR52MHz, 52MHz or 26MHz */ - u8 rsp[5]; - - if (card_type & 0x04) - SET_MMC_DDR52(sd_card); - else if (card_type & 0x02) - SET_MMC_52M(sd_card); - else - SET_MMC_26M(sd_card); - - retval = - sd_send_cmd_get_rsp(chip, SWITCH, 0x03B90100, - SD_RSP_TYPE_R1b, rsp, 5); - if ((retval != STATUS_SUCCESS) || (rsp[4] & MMC_SWITCH_ERR)) - CLR_MMC_HS(sd_card); - } - sd_choose_proper_clock(chip); - retval = switch_clock(chip, sd_card->sd_clock); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - /* Test Bus Procedure */ - if (mmc_test_switch_bus(chip, MMC_8BIT_BUS) == STATUS_SUCCESS) { - SET_MMC_8BIT(sd_card); - chip->card_bus_width[chip->card2lun[SD_CARD]] = 8; - } else if (mmc_test_switch_bus(chip, MMC_4BIT_BUS) == STATUS_SUCCESS) { - SET_MMC_4BIT(sd_card); - chip->card_bus_width[chip->card2lun[SD_CARD]] = 4; - } else { - CLR_MMC_8BIT(sd_card); - CLR_MMC_4BIT(sd_card); - } - - return STATUS_SUCCESS; -} - -static int reset_mmc(struct rts51x_chip *chip) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval, i = 0, j = 0, k = 0; - u8 rsp[16]; - u8 spec_ver = 0; - u8 change_to_ddr52 = 1; - u8 cmd[5]; - -MMC_DDR_FAIL: - - retval = sd_prepare_reset(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - SET_MMC(sd_card); - -RTY_MMC_RST: - retval = - sd_send_cmd_get_rsp(chip, GO_IDLE_STATE, 0, SD_RSP_TYPE_R0, NULL, - 0); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - do { - { - u8 temp = 0; - rts51x_read_register(chip, CARD_INT_PEND, &temp); - if (temp & SD_INT) { - chip->reset_need_retry = 1; - rts51x_write_register(chip, CARD_INT_PEND, - XD_INT | SD_INT | MS_INT, - XD_INT | SD_INT | MS_INT); - sd_set_reset_fail(chip, MMC_RESET_FAIL); - TRACE_RET(chip, STATUS_FAIL); - } - } - - /* CMD 1 */ - retval = sd_send_cmd_get_rsp(chip, SEND_OP_COND, - (SUPPORT_VOLTAGE | 0x40000000), - SD_RSP_TYPE_R3, rsp, 5); - if (retval != STATUS_SUCCESS) { - if (monitor_card_cd(chip, SD_CARD) == CD_NOT_EXIST) { - sd_set_reset_fail(chip, MMC_RESET_FAIL); - TRACE_RET(chip, STATUS_FAIL); - } - - if (sd_check_err_code(chip, SD_BUSY) - || sd_check_err_code(chip, SD_TO_ERR)) { - k++; - if (k < 20) { - sd_clr_err_code(chip); - goto RTY_MMC_RST; - } else { - TRACE_RET(chip, STATUS_FAIL); - } - } else { - j++; - if (j < 100) { - sd_clr_err_code(chip); - goto RTY_MMC_RST; - } else { - TRACE_RET(chip, STATUS_FAIL); - } - } - } - - wait_timeout(20); - i++; - } while (!(rsp[1] & 0x80) && (i < 100)); /* Not complete power on */ - - if (i == 100) { - /* Time out */ - TRACE_RET(chip, STATUS_FAIL); - } - - if ((rsp[1] & 0x60) == 0x40) - SET_MMC_SECTOR_MODE(sd_card); - else - CLR_MMC_SECTOR_MODE(sd_card); - - /* CMD 2 */ - retval = - sd_send_cmd_get_rsp(chip, ALL_SEND_CID, 0, SD_RSP_TYPE_R2, NULL, 0); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - /* CMD 3 */ - sd_card->sd_addr = 0x00100000; - retval = - sd_send_cmd_get_rsp(chip, SET_RELATIVE_ADDR, sd_card->sd_addr, - SD_RSP_TYPE_R6, rsp, 5); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - /* Get CSD register for Calculating Timing,Capacity - * Check CSD to determine as if this is the SD ROM card */ - retval = sd_check_csd(chip, 1); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - /* Get MMC Spec_Ver in the CSD register */ - spec_ver = (sd_card->raw_csd[0] & 0x3C) >> 2; - - /* Select MMC card */ - retval = rts51x_sd_select_card(chip, 1); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - /* Set block length 512 bytes for all block commands */ - retval = - sd_send_cmd_get_rsp(chip, SET_BLOCKLEN, 0x200, SD_RSP_TYPE_R1, NULL, - 0); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - RTS51X_WRITE_REG(chip, SD_CFG1, SD_CLK_DIVIDE_MASK, SD_CLK_DIVIDE_0); - - if (chip->ic_version < 2) - rts51x_write_register(chip, SD30_DRIVE_SEL, SD30_DRIVE_MASK, - 0x02); - rts51x_write_register(chip, CARD_DRIVE_SEL, SD20_DRIVE_MASK, DRIVE_8mA); - - chip->card_bus_width[chip->card2lun[SD_CARD]] = 1; - if (spec_ver == 4) { - /* MMC 4.x Cards */ - (void)mmc_switch_timing_bus(chip); - } - - if (CHK_MMC_SECTOR_MODE(sd_card) && (sd_card->capacity == 0)) - TRACE_RET(chip, STATUS_FAIL); - - if (CHK_MMC_DDR52(sd_card) && change_to_ddr52) { - /* Card is extracted while identifying */ - if (monitor_card_cd(chip, SD_CARD) == CD_NOT_EXIST) - TRACE_RET(chip, STATUS_FAIL); - - retval = sd_set_init_para(chip); - if (retval != STATUS_SUCCESS) { - CLR_MMC_DDR52(sd_card); - sd_init_power(chip); - change_to_ddr52 = 0; - goto MMC_DDR_FAIL; - } - - retval = mmc_ddr_tuning(chip); - if (retval != STATUS_SUCCESS) { - CLR_MMC_DDR52(sd_card); - sd_init_power(chip); - change_to_ddr52 = 0; - goto MMC_DDR_FAIL; - } - - if (STATUS_SUCCESS == - sd_wait_currentstate_dataready(chip, 0x08, 1, 20)) { - cmd[0] = 0x40 | READ_SINGLE_BLOCK; - cmd[1] = 0x00; - cmd[2] = 0x00; - cmd[3] = 0x00; - cmd[4] = 0x00; - if (CHK_MMC_8BIT(sd_card)) { - retval = - sd_read_data(chip, SD_TM_NORMAL_READ, cmd, - 5, 512, 1, SD_BUS_WIDTH_8, - NULL, 0, 600); - } else if (CHK_MMC_4BIT(sd_card)) { - retval = - sd_read_data(chip, SD_TM_NORMAL_READ, cmd, - 5, 512, 1, SD_BUS_WIDTH_4, - NULL, 0, 600); - } else { - retval = - sd_read_data(chip, SD_TM_NORMAL_READ, cmd, - 5, 512, 1, SD_BUS_WIDTH_1, - NULL, 0, 600); - } - - if (retval != STATUS_SUCCESS) { - CLR_MMC_DDR52(sd_card); - change_to_ddr52 = 0; - RTS51X_DEBUGP("read lba0 fail," - "goto SD20 mode\n"); - sd_init_power(chip); - goto MMC_DDR_FAIL; - } - } - } - - retval = rts51x_get_card_status(chip, &(chip->card_status)); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - if (chip->card_status & SD_WP) - chip->card_wp |= SD_CARD; - - return STATUS_SUCCESS; -} - -int rts51x_reset_sd_card(struct rts51x_chip *chip) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval; - int i; - - memset(sd_card, 0, sizeof(struct sd_info)); - - /* Init variables */ - sd_card->sd_type = 0; - sd_card->seq_mode = 0; - sd_card->sd_data_buf_ready = 0; - sd_card->capacity = 0; - sd_card->sd_switch_fail = 0; - - sd_clear_reset_fail(chip); - rts51x_enable_card_clock(chip, SD_CARD); - - sd_init_power(chip); - - chip->reset_need_retry = 0; - for (i = 0; i < 3; i++) { - if (!chip->option.reset_mmc_first) { /* reset sd first */ - retval = reset_sd(chip); - if (retval != STATUS_SUCCESS) { - /* Switch SD bus to 3V3 signal */ - RTS51X_WRITE_REG(chip, SD_PAD_CTL, - SD_IO_USING_1V8, 0); - if (sd_check_reset_fail(chip, SD_RESET_FAIL)) - sd_clear_reset_fail(chip); - else - retval = reset_mmc(chip); - } - } else { /* reset MMC first */ - retval = reset_mmc(chip); - if (retval != STATUS_SUCCESS) { - if (sd_check_reset_fail(chip, MMC_RESET_FAIL)) { - sd_clear_reset_fail(chip); - } else { - retval = reset_sd(chip); - if (retval != STATUS_SUCCESS) { - /* Switch SD bus to - * 3V3 signal */ - RTS51X_WRITE_REG(chip, - SD_PAD_CTL, - SD_IO_USING_1V8, 0); - } - } - } - } - - if ((retval == STATUS_SUCCESS) || (!chip->reset_need_retry)) { - /* if reset success or don't need retry,then break */ - break; - } - if (monitor_card_cd(chip, SD_CARD) == CD_NOT_EXIST) { - /* card is extracted */ - break; - } - RTS51X_DEBUGP("retry reset sd card,%d\n", i); - chip->reset_need_retry = 0; - } - - sd_clear_reset_fail(chip); - chip->reset_need_retry = 0; - - if (retval == STATUS_SUCCESS) { - rts51x_init_cmd(chip); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG1, SD_CLK_DIVIDE_MASK, - SD_CLK_DIVIDE_0); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_L, 0xFF, 0); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_H, 0xFF, 2); - retval = rts51x_send_cmd(chip, MODE_C, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } else { - chip->capacity[chip->card2lun[SD_CARD]] = sd_card->capacity = 0; - if (chip->option.reset_or_rw_fail_set_pad_drive) { - rts51x_write_register(chip, CARD_DRIVE_SEL, - SD20_DRIVE_MASK, DRIVE_8mA); - } - TRACE_RET(chip, STATUS_FAIL); - } - - chip->capacity[chip->card2lun[SD_CARD]] = sd_card->capacity; - - if (chip->option.sd_send_status_en) { - sd_card->sd_send_status_en = 1; - } else { - if (sd_card->capacity > 0x20000) { /* 64MB */ - sd_card->sd_send_status_en = 0; - } else { - sd_card->sd_send_status_en = 1; - } - } - RTS51X_DEBUGP("sd_card->sd_send_status = %d\n", - sd_card->sd_send_status_en); - - retval = sd_set_init_para(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - RTS51X_DEBUGP("sd_card->sd_type = 0x%x\n", sd_card->sd_type); - - return STATUS_SUCCESS; -} - -#define WAIT_DATA_READY_RTY_CNT 255 - -static int wait_data_buf_ready(struct rts51x_chip *chip) -{ - struct sd_info *sd_card = &(chip->sd_card); - int i, retval; - - for (i = 0; i < WAIT_DATA_READY_RTY_CNT; i++) { - if (monitor_card_cd(chip, SD_CARD) == CD_NOT_EXIST) - TRACE_RET(chip, STATUS_FAIL); - - sd_card->sd_data_buf_ready = 0; - - retval = sd_send_cmd_get_rsp(chip, SEND_STATUS, - sd_card->sd_addr, SD_RSP_TYPE_R1, - NULL, 0); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (sd_card->sd_data_buf_ready) - return sd_send_cmd_get_rsp(chip, SEND_STATUS, - sd_card->sd_addr, - SD_RSP_TYPE_R1, NULL, 0); - } - - sd_set_err_code(chip, SD_TO_ERR); - - TRACE_RET(chip, STATUS_FAIL); -} - -static void sd_stop_seq_mode(struct rts51x_chip *chip) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval; - - if (sd_card->seq_mode) { - retval = rts51x_sd_switch_clock(chip); - if (retval != STATUS_SUCCESS) - return; - - retval = sd_send_cmd_get_rsp(chip, STOP_TRANSMISSION, 0, - SD_RSP_TYPE_R1b, NULL, 0); - if (retval != STATUS_SUCCESS) - sd_set_err_code(chip, SD_STS_ERR); - sd_card->seq_mode = 0; - - rts51x_ep0_write_register(chip, MC_FIFO_CTL, FIFO_FLUSH, - FIFO_FLUSH); - } -} - -static inline int sd_auto_tune_clock(struct rts51x_chip *chip) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval; - - if (chip->asic_code) { - if (sd_card->sd_clock > 30) - sd_card->sd_clock -= 20; - } else { - if (sd_card->sd_clock == CLK_100) - sd_card->sd_clock = CLK_80; - else if (sd_card->sd_clock == CLK_80) - sd_card->sd_clock = CLK_60; - else if (sd_card->sd_clock == CLK_60) - sd_card->sd_clock = CLK_50; - } - - retval = rts51x_sd_switch_clock(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - return STATUS_SUCCESS; -} - -int rts51x_sd_rw(struct scsi_cmnd *srb, struct rts51x_chip *chip, u32 start_sector, - u16 sector_cnt) -{ - struct sd_info *sd_card = &(chip->sd_card); - u32 data_addr; - int retval; - u8 flag; - unsigned int pipe; - u8 stageflag; - - sd_card->counter = 0; - - if (!CHK_SD_HCXC(sd_card) && !CHK_MMC_SECTOR_MODE(sd_card)) - data_addr = start_sector << 9; - else - data_addr = start_sector; - - RTS51X_DEBUGP("rts51x_sd_rw, data_addr = 0x%x\n", data_addr); - - sd_clr_err_code(chip); - - retval = rts51x_sd_switch_clock(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (sd_card->seq_mode && ((sd_card->pre_dir != srb->sc_data_direction) - || - ((sd_card->pre_sec_addr + - sd_card->pre_sec_cnt) != start_sector))) { - if ((sd_card->pre_dir == DMA_FROM_DEVICE) - && !CHK_SD30_SPEED(sd_card) - && !CHK_SD_HS(sd_card) - && !CHK_MMC_HS(sd_card) - && sd_card->sd_send_status_en) { - sd_send_cmd_get_rsp(chip, SEND_STATUS, - sd_card->sd_addr, SD_RSP_TYPE_R1, - NULL, 0); - } - - retval = - sd_send_cmd_get_rsp(chip, STOP_TRANSMISSION, 0, - SD_RSP_TYPE_R1b, NULL, 0); - if (retval != STATUS_SUCCESS) { - sd_set_err_code(chip, SD_STS_ERR); - TRACE_RET(chip, sd_parse_err_code(chip)); - } - - sd_card->seq_mode = 0; - - RTS51X_WRITE_REG(chip, MC_FIFO_CTL, FIFO_FLUSH, FIFO_FLUSH); - - if (!CHK_SD30_SPEED(sd_card) - && !CHK_SD_HS(sd_card) - && !CHK_MMC_HS(sd_card) - && sd_card->sd_send_status_en) { - /* random rw, so pre_sec_cnt < 0x80 */ - sd_send_cmd_get_rsp(chip, SEND_STATUS, - sd_card->sd_addr, SD_RSP_TYPE_R1, - NULL, 0); - } - } - - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_L, 0xFF, 0x00); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_H, 0xFF, 0x02); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_L, 0xFF, - (u8) sector_cnt); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_H, 0xFF, - (u8) (sector_cnt >> 8)); - - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, - RING_BUFFER); - - if (CHK_MMC_8BIT(sd_card)) - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG1, 0x03, - SD_BUS_WIDTH_8); - else if (CHK_MMC_4BIT(sd_card) || CHK_SD(sd_card)) - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG1, 0x03, - SD_BUS_WIDTH_4); - else - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG1, 0x03, - SD_BUS_WIDTH_1); - - if (sd_card->seq_mode) { - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG2, 0xFF, - SD_NO_CALCULATE_CRC7 | SD_CHECK_CRC16 | - SD_NO_WAIT_BUSY_END | SD_NO_CHECK_CRC7 | - SD_RSP_LEN_0); - - rts51x_trans_dma_enable(srb->sc_data_direction, chip, sector_cnt * 512, - DMA_512); - - if (srb->sc_data_direction == DMA_FROM_DEVICE) { - flag = MODE_CDIR; - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_TRANSFER, 0xFF, - SD_TM_AUTO_READ_3 | SD_TRANSFER_START); - } else { - flag = MODE_CDOR; - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_TRANSFER, 0xFF, - SD_TM_AUTO_WRITE_3 | SD_TRANSFER_START); - } - - rts51x_add_cmd(chip, CHECK_REG_CMD, SD_TRANSFER, - SD_TRANSFER_END, SD_TRANSFER_END); - - retval = rts51x_send_cmd(chip, flag, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } else { - if (srb->sc_data_direction == DMA_FROM_DEVICE) { - RTS51X_DEBUGP("SD/MMC CMD %d\n", READ_MULTIPLE_BLOCK); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD0, 0xFF, - 0x40 | READ_MULTIPLE_BLOCK); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD1, 0xFF, - (u8) (data_addr >> 24)); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD2, 0xFF, - (u8) (data_addr >> 16)); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD3, 0xFF, - (u8) (data_addr >> 8)); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD4, 0xFF, - (u8) data_addr); - - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG2, 0xFF, - SD_CALCULATE_CRC7 | SD_CHECK_CRC16 | - SD_NO_WAIT_BUSY_END | SD_CHECK_CRC7 | - SD_RSP_LEN_6); - - rts51x_trans_dma_enable(srb->sc_data_direction, chip, - sector_cnt * 512, DMA_512); - - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_TRANSFER, 0xFF, - SD_TM_AUTO_READ_2 | SD_TRANSFER_START); - rts51x_add_cmd(chip, CHECK_REG_CMD, SD_TRANSFER, - SD_TRANSFER_END, SD_TRANSFER_END); - - retval = rts51x_send_cmd(chip, MODE_CDIR, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } else { - retval = rts51x_send_cmd(chip, MODE_C, 50); - if (retval != STATUS_SUCCESS) { - rts51x_clear_sd_error(chip); - - sd_set_err_code(chip, SD_TO_ERR); - TRACE_RET(chip, sd_parse_err_code(chip)); - } - - retval = wait_data_buf_ready(chip); - if (retval != STATUS_SUCCESS) { - sd_set_err_code(chip, SD_TO_ERR); - TRACE_RET(chip, sd_parse_err_code(chip)); - } - - retval = sd_send_cmd_get_rsp(chip, WRITE_MULTIPLE_BLOCK, - data_addr, SD_RSP_TYPE_R1, - NULL, 0); - if (retval != STATUS_SUCCESS) { - sd_set_err_code(chip, SD_CRC_ERR); - TRACE_RET(chip, sd_parse_err_code(chip)); - } - - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG2, 0xFF, - SD_NO_CALCULATE_CRC7 | SD_CHECK_CRC16 | - SD_NO_WAIT_BUSY_END | SD_NO_CHECK_CRC7 | - SD_RSP_LEN_0); - - rts51x_trans_dma_enable(srb->sc_data_direction, chip, - sector_cnt * 512, DMA_512); - - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_TRANSFER, 0xFF, - SD_TM_AUTO_WRITE_3 | SD_TRANSFER_START); - rts51x_add_cmd(chip, CHECK_REG_CMD, SD_TRANSFER, - SD_TRANSFER_END, SD_TRANSFER_END); - - retval = rts51x_send_cmd(chip, MODE_CDOR, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - - sd_card->seq_mode = 1; - } - - if (srb->sc_data_direction == DMA_FROM_DEVICE) { - pipe = RCV_BULK_PIPE(chip); - stageflag = STAGE_DI; - } else { - pipe = SND_BULK_PIPE(chip); - stageflag = STAGE_DO; - } - - retval = - rts51x_transfer_data_rcc(chip, pipe, scsi_sglist(srb), - scsi_bufflen(srb), scsi_sg_count(srb), - NULL, 10000, stageflag); - if (retval != STATUS_SUCCESS) { - u8 stat = 0; - int err = retval; - - sd_print_debug_reg(chip); - - rts51x_ep0_read_register(chip, SD_STAT1, &stat); - RTS51X_DEBUGP("SD_STAT1: 0x%x\n", stat); - - rts51x_clear_sd_error(chip); - - retval = - sd_send_cmd_get_rsp(chip, STOP_TRANSMISSION, 0, - SD_RSP_TYPE_R1b, NULL, 0); - if (retval != STATUS_SUCCESS) { - sd_set_err_code(chip, SD_STS_ERR); - TRACE_RET(chip, retval); - } - - if (stat & (SD_CRC7_ERR | SD_CRC16_ERR | SD_CRC_WRITE_ERR)) { - RTS51X_DEBUGP("SD CRC error, tune clock!\n"); - sd_auto_tune_clock(chip); - } - - sd_card->seq_mode = 0; - - TRACE_RET(chip, err); - } - retval = rts51x_get_rsp(chip, 1, 2000); - if (CHECK_SD_TRANS_FAIL(chip, retval)) { - rts51x_clear_sd_error(chip); - TRACE_RET(chip, STATUS_FAIL); - } - - sd_card->pre_sec_addr = start_sector; - sd_card->pre_sec_cnt = sector_cnt; - sd_card->pre_dir = srb->sc_data_direction; - - return STATUS_SUCCESS; -} - -void rts51x_sd_cleanup_work(struct rts51x_chip *chip) -{ - struct sd_info *sd_card = &(chip->sd_card); - - if (sd_card->seq_mode) { - RTS51X_DEBUGP("SD: stop transmission\n"); - sd_stop_seq_mode(chip); - sd_card->counter = 0; - } -} - -static inline void sd_fill_power_off_card3v3(struct rts51x_chip *chip) -{ - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_CLK_EN, SD_CLK_EN, 0); - - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_OE, SD_OUTPUT_EN, 0); - if (!chip->option.FT2_fast_mode) { -#ifdef SD_XD_IO_FOLLOW_PWR - if (CHECK_PKG(chip, LQFP48) - || chip->option.rts5129_D3318_off_enable) - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, - POWER_MASK | LDO_OFF, - POWER_OFF | LDO_OFF); - else - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, - POWER_MASK, POWER_OFF); -#else - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, POWER_MASK, - POWER_OFF); -#endif - } -} - -static int sd_power_off_card3v3(struct rts51x_chip *chip) -{ - int retval; - - rts51x_init_cmd(chip); - - sd_fill_power_off_card3v3(chip); - - retval = rts51x_send_cmd(chip, MODE_C, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); -#ifdef SD_XD_IO_FOLLOW_PWR - if (!chip->option.FT2_fast_mode) - wait_timeout(chip->option.D3318_off_delay); -#endif - - return STATUS_SUCCESS; -} - -int rts51x_release_sd_card(struct rts51x_chip *chip) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval; - - RTS51X_DEBUGP("rts51x_release_sd_card\n"); - - chip->card_ready &= ~SD_CARD; - chip->card_fail &= ~SD_CARD; - chip->card_wp &= ~SD_CARD; - - memset(sd_card->raw_csd, 0, 16); - memset(sd_card->raw_scr, 0, 8); - - rts51x_write_register(chip, SFSM_ED, HW_CMD_STOP, HW_CMD_STOP); - rts51x_write_register(chip, SD_PAD_CTL, SD_IO_USING_1V8, 0); - if (CHECK_PKG(chip, LQFP48) || chip->option.rts5129_D3318_off_enable) - sd_power_off_card3v3(chip); - - rts51x_init_cmd(chip); - if (!(CHECK_PKG(chip, LQFP48) || chip->option.rts5129_D3318_off_enable)) - sd_fill_power_off_card3v3(chip); - - if (chip->asic_code) - sd_pull_ctl_disable(chip); - else - rts51x_add_cmd(chip, WRITE_REG_CMD, FPGA_PULL_CTL, - FPGA_SD_PULL_CTL_BIT | 0x20, - FPGA_SD_PULL_CTL_BIT); - - /* Switch LDO3318 to 3.3V */ - rts51x_add_cmd(chip, WRITE_REG_CMD, LDO_POWER_CFG, TUNE_SD18_MASK, - TUNE_SD18_3V3); - - if (CHK_MMC_DDR52(sd_card) && CHK_MMC_8BIT(sd_card)) - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DMA1_CTL, - EXTEND_DMA1_ASYNC_SIGNAL, - EXTEND_DMA1_ASYNC_SIGNAL); - if (CHK_SD30_SPEED(sd_card) || CHK_MMC(sd_card)) - rts51x_add_cmd(chip, WRITE_REG_CMD, SD30_DRIVE_SEL, - SD30_DRIVE_MASK, chip->option.sd30_pad_drive); - /* Suspend LDO3318 */ - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, LDO3318_PWR_MASK, - LDO_SUSPEND); - - retval = rts51x_send_cmd(chip, MODE_C, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - wait_timeout(20); - - return STATUS_SUCCESS; -} diff --git a/drivers/staging/rts5139/sd.h b/drivers/staging/rts5139/sd.h deleted file mode 100644 index 7dd943f54c74..000000000000 --- a/drivers/staging/rts5139/sd.h +++ /dev/null @@ -1,275 +0,0 @@ -/* Driver for Realtek RTS51xx USB card reader - * Header file - * - * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. - * - * 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, 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, see . - * - * Author: - * wwang (wei_wang@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - * Maintainer: - * Edwin Rong (edwin_rong@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - */ - -#ifndef __RTS51X_SD_H -#define __RTS51X_SD_H - -#include "rts51x_chip.h" - -#define SD_MAX_RETRY_COUNT 3 - -#define SUPPORT_VOLTAGE 0x003C0000 - -#define SD_RESET_FAIL 0x01 -#define MMC_RESET_FAIL 0x02 - -/* Error Code */ -#define SD_NO_ERROR 0x0 -#define SD_CRC_ERR 0x80 -#define SD_TO_ERR 0x40 -#define SD_NO_CARD 0x20 -#define SD_BUSY 0x10 -#define SD_STS_ERR 0x08 -#define SD_RSP_TIMEOUT 0x04 - -/* MMC/SD Command Index */ -/* Basic command (class 0) */ -#define GO_IDLE_STATE 0 -#define SEND_OP_COND 1 /* reserved for SD */ -#define ALL_SEND_CID 2 -#define SET_RELATIVE_ADDR 3 -#define SEND_RELATIVE_ADDR 3 -#define SET_DSR 4 -#define IO_SEND_OP_COND 5 -#define SWITCH 6 -#define SELECT_CARD 7 -#define DESELECT_CARD 7 -/* CMD8 is "SEND_EXT_CSD" for MMC4.x Spec - * while is "SEND_IF_COND" for SD 2.0 */ -#define SEND_EXT_CSD 8 -#define SEND_IF_COND 8 -/* end */ -#define SEND_CSD 9 -#define SEND_CID 10 -#define VOLTAGE_SWITCH 11 -#define READ_DAT_UTIL_STOP 11 /* reserved for SD */ -#define STOP_TRANSMISSION 12 -#define SEND_STATUS 13 -#define GO_INACTIVE_STATE 15 - -/* Block oriented read commands (class 2) */ -#define SET_BLOCKLEN 16 -#define READ_SINGLE_BLOCK 17 -#define READ_MULTIPLE_BLOCK 18 -#define SEND_TUNING_PATTERN 19 - -/* Bus Width Test */ -#define BUSTEST_R 14 -#define BUSTEST_W 19 -/* end */ - -/* Block oriented write commands (class 4) */ -#define WRITE_BLOCK 24 -#define WRITE_MULTIPLE_BLOCK 25 -#define PROGRAM_CSD 27 - -/* Erase commands */ -#define ERASE_WR_BLK_START 32 -#define ERASE_WR_BLK_END 33 -#define ERASE_CMD 38 - -/* Block Oriented Write Protection Commands */ -#define LOCK_UNLOCK 42 - -#define IO_RW_DIRECT 52 - -/* Application specific commands (class 8) */ -#define APP_CMD 55 -#define GEN_CMD 56 - -/* SD Application command Index */ -#define SET_BUS_WIDTH 6 -#define SD_STATUS 13 -#define SEND_NUM_WR_BLOCKS 22 -#define SET_WR_BLK_ERASE_COUNT 23 -#define SD_APP_OP_COND 41 -#define SET_CLR_CARD_DETECT 42 -#define SEND_SCR 51 - -/* SD TIMEOUT function return error */ -#define SD_READ_COMPLETE 0x00 -#define SD_READ_TO 0x01 -#define SD_READ_ADVENCE 0x02 - -/* SD v1.1 CMD6 SWITCH function */ -#define SD_CHECK_MODE 0x00 -#define SD_SWITCH_MODE 0x80 -#define SD_FUNC_GROUP_1 0x01 -#define SD_FUNC_GROUP_2 0x02 -#define SD_FUNC_GROUP_3 0x03 -#define SD_FUNC_GROUP_4 0x04 -#define SD_CHECK_SPEC_V1_1 0xFF - -/* SD Command Argument */ -#define NO_ARGUMENT 0x00 -#define CHECK_PATTERN 0x000000AA -#define VOLTAGE_SUPPLY_RANGE 0x00000100 /* 2.7~3.6V */ -#define SUPPORT_HIGH_AND_EXTENDED_CAPACITY 0x40000000 -#define SUPPORT_MAX_POWER_PERMANCE 0x10000000 -#define SUPPORT_1V8 0x01000000 - -/* Switch Command Error Code */ -#define SWTICH_NO_ERR 0x00 -#define CARD_NOT_EXIST 0x01 -#define SPEC_NOT_SUPPORT 0x02 -#define CHECK_MODE_ERR 0x03 -#define CHECK_NOT_READY 0x04 -#define SWITCH_CRC_ERR 0x05 -#define SWITCH_MODE_ERR 0x06 -#define SWITCH_PASS 0x07 - -/* Function Group Definition */ -/* Function Group 1 */ -#define HS_SUPPORT 0x01 -#define SDR50_SUPPORT 0x02 -#define SDR104_SUPPORT 0x03 -#define DDR50_SUPPORT 0x04 -#define HS_SUPPORT_MASK 0x02 -#define SDR50_SUPPORT_MASK 0x04 -#define SDR104_SUPPORT_MASK 0x08 -#define DDR50_SUPPORT_MASK 0x10 -#define HS_QUERY_SWITCH_OK 0x01 -#define SDR50_QUERY_SWITCH_OK 0x02 -#define SDR104_QUERY_SWITCH_OK 0x03 -#define DDR50_QUERY_SWITCH_OK 0x04 -#define HS_SWITCH_BUSY 0x02 -#define SDR50_SWITCH_BUSY 0x04 -#define SDR104_SWITCH_BUSY 0x08 -#define DDR50_SWITCH_BUSY 0x10 -#define FUNCTION_GROUP1_SUPPORT_OFFSET 0x0D -#define FUNCTION_GROUP1_QUERY_SWITCH_OFFSET 0x10 -#define FUNCTION_GROUP1_CHECK_BUSY_OFFSET 0x1D -/* Function Group 3 */ -#define DRIVING_TYPE_A 0x01 -#define DRIVING_TYPE_B 0x00 -#define DRIVING_TYPE_C 0x02 -#define DRIVING_TYPE_D 0x03 -#define DRIVING_TYPE_A_MASK 0x02 -#define DRIVING_TYPE_B_MASK 0x01 -#define DRIVING_TYPE_C_MASK 0x04 -#define DRIVING_TYPE_D_MASK 0x08 -#define TYPE_A_QUERY_SWITCH_OK 0x01 -#define TYPE_B_QUERY_SWITCH_OK 0x00 -#define TYPE_C_QUERY_SWITCH_OK 0x02 -#define TYPE_D_QUERY_SWITCH_OK 0x03 -#define TYPE_A_SWITCH_BUSY 0x02 -#define TYPE_B_SWITCH_BUSY 0x01 -#define TYPE_C_SWITCH_BUSY 0x04 -#define TYPE_D_SWITCH_BUSY 0x08 -#define FUNCTION_GROUP3_SUPPORT_OFFSET 0x09 -#define FUNCTION_GROUP3_QUERY_SWITCH_OFFSET 0x0F -#define FUNCTION_GROUP3_CHECK_BUSY_OFFSET 0x19 -/* Function Group 4 */ -#define CURRENT_LIMIT_200 0x00 -#define CURRENT_LIMIT_400 0x01 -#define CURRENT_LIMIT_600 0x02 -#define CURRENT_LIMIT_800 0x03 -#define CURRENT_LIMIT_200_MASK 0x01 -#define CURRENT_LIMIT_400_MASK 0x02 -#define CURRENT_LIMIT_600_MASK 0x04 -#define CURRENT_LIMIT_800_MASK 0x08 -#define CURRENT_LIMIT_200_QUERY_SWITCH_OK 0x00 -#define CURRENT_LIMIT_400_QUERY_SWITCH_OK 0x01 -#define CURRENT_LIMIT_600_QUERY_SWITCH_OK 0x02 -#define CURRENT_LIMIT_800_QUERY_SWITCH_OK 0x03 -#define CURRENT_LIMIT_200_SWITCH_BUSY 0x01 -#define CURRENT_LIMIT_400_SWITCH_BUSY 0x02 -#define CURRENT_LIMIT_600_SWITCH_BUSY 0x04 -#define CURRENT_LIMIT_800_SWITCH_BUSY 0x08 -#define FUNCTION_GROUP4_SUPPORT_OFFSET 0x07 -#define FUNCTION_GROUP4_QUERY_SWITCH_OFFSET 0x0F -#define FUNCTION_GROUP4_CHECK_BUSY_OFFSET 0x17 -/* Switch Function Status Offset */ -#define DATA_STRUCTURE_VER_OFFSET 0x11 /* The high offset */ -#define MAX_PHASE 15 -/* #define TOTAL_READ_PHASE 0x20 */ -/* #define TOTAL_WRITE_PHASE 0x20 */ -/* MMC v4.0 */ -/* #define MMC_52MHZ_SPEED 0x0001 */ -/* #define MMC_26MHZ_SPEED 0x0002 */ -#define MMC_8BIT_BUS 0x0010 -#define MMC_4BIT_BUS 0x0020 -/* #define MMC_SECTOR_MODE 0x0100 */ -#define MMC_SWITCH_ERR 0x80 -/* Tuning direction RX or TX */ -#define TUNE_TX 0x00 -#define TUNE_RX 0x01 -/* For Change_DCM_FreqMode Function */ -#define CHANGE_TX 0x00 -#define CHANGE_RX 0x01 -#define DCM_HIGH_FREQUENCY_MODE 0x00 -#define DCM_LOW_FREQUENCY_MODE 0x01 -#define DCM_HIGH_FREQUENCY_MODE_SET 0x0C -#define DCM_Low_FREQUENCY_MODE_SET 0x00 -/* For Change_FPGA_SSCClock Function */ -#define MULTIPLY_BY_1 0x00 -#define MULTIPLY_BY_2 0x01 -#define MULTIPLY_BY_3 0x02 -#define MULTIPLY_BY_4 0x03 -#define MULTIPLY_BY_5 0x04 -#define MULTIPLY_BY_6 0x05 -#define MULTIPLY_BY_7 0x06 -#define MULTIPLY_BY_8 0x07 -#define MULTIPLY_BY_9 0x08 -#define MULTIPLY_BY_10 0x09 -#define DIVIDE_BY_2 0x01 -#define DIVIDE_BY_3 0x02 -#define DIVIDE_BY_4 0x03 -#define DIVIDE_BY_5 0x04 -#define DIVIDE_BY_6 0x05 -#define DIVIDE_BY_7 0x06 -#define DIVIDE_BY_8 0x07 -#define DIVIDE_BY_9 0x08 -#define DIVIDE_BY_10 0x09 -#define CHECK_SD_TRANS_FAIL(chip, retval) \ - (((retval) != STATUS_SUCCESS) || \ - (chip->rsp_buf[0] & SD_TRANSFER_ERR)) -/* SD Tuning Data Structure */ -/* Record continuous timing phase path */ -struct timing_phase_path { - int start; - int end; - int mid; - int len; -}; - -int rts51x_sd_select_card(struct rts51x_chip *chip, int select); -int rts51x_reset_sd_card(struct rts51x_chip *chip); -int rts51x_sd_switch_clock(struct rts51x_chip *chip); -int rts51x_sd_rw(struct scsi_cmnd *srb, struct rts51x_chip *chip, u32 start_sector, - u16 sector_cnt); -void rts51x_sd_cleanup_work(struct rts51x_chip *chip); -int rts51x_release_sd_card(struct rts51x_chip *chip); - -#ifdef SUPPORT_CPRM -extern int reset_sd(struct rts51x_chip *chip); -extern int sd_check_data0_status(struct rts51x_chip *chip); -extern int sd_read_data(struct rts51x_chip *chip, u8 trans_mode, u8 *cmd, - int cmd_len, u16 byte_cnt, u16 blk_cnt, u8 bus_width, - u8 *buf, int buf_len, int timeout); -#endif - -#endif /* __RTS51X_SD_H */ diff --git a/drivers/staging/rts5139/sd_cprm.c b/drivers/staging/rts5139/sd_cprm.c deleted file mode 100644 index cede6c07394f..000000000000 --- a/drivers/staging/rts5139/sd_cprm.c +++ /dev/null @@ -1,1056 +0,0 @@ -/* Driver for Realtek RTS51xx USB card reader - * - * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. - * - * 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, 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, see . - * - * Author: - * wwang (wei_wang@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - * Maintainer: - * Edwin Rong (edwin_rong@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - */ - -#include -#include -#include -#include - -#include "debug.h" -#include "trace.h" -#include "rts51x.h" -#include "rts51x_transport.h" -#include "rts51x_scsi.h" -#include "rts51x_card.h" -#include "rts51x_chip.h" -#include "sd_cprm.h" -#include "sd.h" - -#ifdef SUPPORT_CPRM - -static inline int get_rsp_type(u8 rsp_code, u8 *rsp_type, int *rsp_len) -{ - if (!rsp_type || !rsp_len) - return STATUS_FAIL; - - switch (rsp_code) { - case 0x03: - *rsp_type = SD_RSP_TYPE_R0; /* no response */ - *rsp_len = 0; - break; - - case 0x04: - *rsp_type = SD_RSP_TYPE_R1; /* R1,R6(,R4,R5) */ - *rsp_len = 6; - break; - - case 0x05: - *rsp_type = SD_RSP_TYPE_R1b; /* R1b */ - *rsp_len = 6; - break; - - case 0x06: - *rsp_type = SD_RSP_TYPE_R2; /* R2 */ - *rsp_len = 17; - break; - - case 0x07: - *rsp_type = SD_RSP_TYPE_R3; /* R3 */ - *rsp_len = 6; - break; - - default: - return STATUS_FAIL; - } - - return STATUS_SUCCESS; -} - -static int ext_sd_send_cmd_get_rsp(struct rts51x_chip *chip, u8 cmd_idx, - u32 arg, u8 rsp_type, u8 *rsp, int rsp_len, - int special_check) -{ - int retval; - int timeout = 50; - u16 reg_addr; - u8 buf[17], stat; - int len = 2; - int rty_cnt = 0; - - RTS51X_DEBUGP("EXT SD/MMC CMD %d\n", cmd_idx); - - if (rsp_type == SD_RSP_TYPE_R1b) - timeout = 3000; - -RTY_SEND_CMD: - - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD0, 0xFF, 0x40 | cmd_idx); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD1, 0xFF, (u8) (arg >> 24)); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD2, 0xFF, (u8) (arg >> 16)); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD3, 0xFF, (u8) (arg >> 8)); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD4, 0xFF, (u8) arg); - - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG2, 0xFF, rsp_type); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, - 0x01, PINGPONG_BUFFER); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_TRANSFER, - 0xFF, SD_TM_CMD_RSP | SD_TRANSFER_START); - rts51x_add_cmd(chip, CHECK_REG_CMD, SD_TRANSFER, SD_TRANSFER_END, - SD_TRANSFER_END); - - rts51x_add_cmd(chip, READ_REG_CMD, SD_STAT1, 0, 0); - - if (CHECK_USB(chip, USB_20)) { - if (rsp_type == SD_RSP_TYPE_R2) { - for (reg_addr = PPBUF_BASE2; - reg_addr < PPBUF_BASE2 + 16; reg_addr++) { - rts51x_add_cmd(chip, READ_REG_CMD, reg_addr, 0, - 0); - } - len = 19; - } else if (rsp_type != SD_RSP_TYPE_R0) { - /* Read data from SD_CMDx registers */ - for (reg_addr = SD_CMD0; reg_addr <= SD_CMD4; - reg_addr++) { - rts51x_add_cmd(chip, READ_REG_CMD, reg_addr, 0, - 0); - } - len = 8; - } else { - len = 3; - } - rts51x_add_cmd(chip, READ_REG_CMD, SD_CMD5, 0, 0); - } else { - len = 2; - } - - retval = rts51x_send_cmd(chip, MODE_CR, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = rts51x_get_rsp(chip, len, timeout); - - if (CHECK_SD_TRANS_FAIL(chip, retval)) { - rts51x_clear_sd_error(chip); - - if (retval == STATUS_TIMEDOUT) { - if (rsp_type & SD_WAIT_BUSY_END) { - retval = sd_check_data0_status(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - } - TRACE_RET(chip, STATUS_FAIL); - } - - if (rsp_type == SD_RSP_TYPE_R0) - return STATUS_SUCCESS; - - if (CHECK_USB(chip, USB_20)) { - rts51x_read_rsp_buf(chip, 2, buf, len - 2); - } else { - if (rsp_type == SD_RSP_TYPE_R2) { - reg_addr = PPBUF_BASE2; - len = 16; - } else { - reg_addr = SD_CMD0; - len = 5; - } - retval = - rts51x_seq_read_register(chip, reg_addr, - (unsigned short)len, buf); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - RTS51X_READ_REG(chip, SD_CMD5, buf + len); - } - stat = chip->rsp_buf[1]; - - if ((buf[0] & 0xC0) != 0) - TRACE_RET(chip, STATUS_FAIL); - - if (!(rsp_type & SD_NO_CHECK_CRC7)) { - if (stat & SD_CRC7_ERR) { - if (cmd_idx == WRITE_MULTIPLE_BLOCK) - TRACE_RET(chip, STATUS_FAIL); - if (rty_cnt < SD_MAX_RETRY_COUNT) { - wait_timeout(20); - rty_cnt++; - goto RTY_SEND_CMD; - } else { - TRACE_RET(chip, STATUS_FAIL); - } - } - } - - if ((cmd_idx == SELECT_CARD) || (cmd_idx == APP_CMD) || - (cmd_idx == SEND_STATUS) || (cmd_idx == STOP_TRANSMISSION)) { - if ((cmd_idx != STOP_TRANSMISSION) && (special_check == 0)) { - if (buf[1] & 0x80) - TRACE_RET(chip, STATUS_FAIL); - } - if (buf[1] & 0x7F) - TRACE_RET(chip, STATUS_FAIL); - if (buf[2] & 0xF8) - TRACE_RET(chip, STATUS_FAIL); - - if (cmd_idx == SELECT_CARD) { - if (rsp_type == SD_RSP_TYPE_R2) { - if ((buf[3] & 0x1E) != 0x04) - TRACE_RET(chip, STATUS_FAIL); - } else if (rsp_type == SD_RSP_TYPE_R2) { - if ((buf[3] & 0x1E) != 0x03) - TRACE_RET(chip, STATUS_FAIL); - } - } - } - - if (rsp && rsp_len) - memcpy(rsp, buf, rsp_len); - - return STATUS_SUCCESS; -} - -static int ext_sd_get_rsp(struct rts51x_chip *chip, int len, - u8 *rsp, u8 rsp_type) -{ - int retval, rsp_len; - u16 reg_addr; - - if (rsp_type == SD_RSP_TYPE_R0) - return STATUS_SUCCESS; - - rts51x_init_cmd(chip); - - if (rsp_type == SD_RSP_TYPE_R2) { - for (reg_addr = PPBUF_BASE2; reg_addr < PPBUF_BASE2 + 16; - reg_addr++) { - rts51x_add_cmd(chip, READ_REG_CMD, reg_addr, 0xFF, 0); - } - rsp_len = 17; - } else if (rsp_type != SD_RSP_TYPE_R0) { - for (reg_addr = SD_CMD0; reg_addr <= SD_CMD4; reg_addr++) - rts51x_add_cmd(chip, READ_REG_CMD, reg_addr, 0xFF, 0); - rsp_len = 6; - } - rts51x_add_cmd(chip, READ_REG_CMD, SD_CMD5, 0xFF, 0); - - retval = rts51x_send_cmd(chip, MODE_CR, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = rts51x_get_rsp(chip, rsp_len, 100); - - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (rsp) { - int min_len = (rsp_len < len) ? rsp_len : len; - - memcpy(rsp, rts51x_get_rsp_data(chip), min_len); - - RTS51X_DEBUGP("min_len = %d\n", min_len); - RTS51X_DEBUGP("Response in cmd buf: 0x%x 0x%x 0x%x 0x%x\n", - rsp[0], rsp[1], rsp[2], rsp[3]); - } - - return STATUS_SUCCESS; -} - -int ext_rts51x_sd_execute_no_data(struct rts51x_chip *chip, unsigned int lun, - u8 cmd_idx, u8 standby, u8 acmd, u8 rsp_code, - u32 arg) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval, rsp_len; - u8 rsp_type; - - retval = rts51x_sd_switch_clock(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, TRANSPORT_FAILED); - - if (sd_card->pre_cmd_err) { - sd_card->pre_cmd_err = 0; - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); - TRACE_RET(chip, TRANSPORT_FAILED); - } - retval = get_rsp_type(rsp_code, &rsp_type, &rsp_len); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - sd_card->last_rsp_type = rsp_type; - - retval = rts51x_sd_switch_clock(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, TRANSPORT_FAILED); - /* Set H/W SD/MMC Bus Width */ - rts51x_write_register(chip, SD_CFG1, 0x03, SD_BUS_WIDTH_4); - - if (standby) { - retval = rts51x_sd_select_card(chip, 0); - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, SD_Execute_Cmd_Failed); - } - - if (acmd) { - retval = - ext_sd_send_cmd_get_rsp(chip, APP_CMD, sd_card->sd_addr, - SD_RSP_TYPE_R1, NULL, 0, 0); - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, SD_Execute_Cmd_Failed); - } - - retval = ext_sd_send_cmd_get_rsp(chip, cmd_idx, arg, rsp_type, - sd_card->rsp, rsp_len, 0); - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, SD_Execute_Cmd_Failed); - - if (standby) { - retval = rts51x_sd_select_card(chip, 1); - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, SD_Execute_Cmd_Failed); - } - - return TRANSPORT_GOOD; - -SD_Execute_Cmd_Failed: - sd_card->pre_cmd_err = 1; - rts51x_set_sense_type(chip, lun, SENSE_TYPE_NO_SENSE); - rts51x_release_sd_card(chip); - rts51x_do_rts51x_reset_sd_card(chip); - if (!(chip->card_ready & SD_CARD)) - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - - TRACE_RET(chip, TRANSPORT_FAILED); -} - -int ext_rts51x_sd_execute_read_data(struct rts51x_chip *chip, unsigned int lun, - u8 cmd_idx, u8 cmd12, u8 standby, - u8 acmd, u8 rsp_code, u32 arg, u32 data_len, - void *data_buf, unsigned int buf_len, int use_sg) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval, rsp_len, i; - int cmd13_checkbit = 0, read_err = 0; - u8 rsp_type, bus_width; - - if (sd_card->pre_cmd_err) { - sd_card->pre_cmd_err = 0; - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - retval = rts51x_sd_switch_clock(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - retval = get_rsp_type(rsp_code, &rsp_type, &rsp_len); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - sd_card->last_rsp_type = rsp_type; - - retval = rts51x_sd_switch_clock(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, TRANSPORT_FAILED); - bus_width = SD_BUS_WIDTH_4; - - if (data_len < 512) { - retval = ext_sd_send_cmd_get_rsp(chip, SET_BLOCKLEN, data_len, - SD_RSP_TYPE_R1, NULL, 0, 0); - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed); - } - - if (standby) { - retval = rts51x_sd_select_card(chip, 0); - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed); - } - - if (acmd) { - retval = - ext_sd_send_cmd_get_rsp(chip, APP_CMD, sd_card->sd_addr, - SD_RSP_TYPE_R1, NULL, 0, 0); - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed); - } - - if (data_len <= 512) { - int min_len; - u8 *buf; - u16 byte_cnt, blk_cnt; - u8 cmd[5]; - unsigned int offset = 0; - void *sg = NULL; - - byte_cnt = (u16) (data_len & 0x3FF); - blk_cnt = 1; - - cmd[0] = 0x40 | cmd_idx; - cmd[1] = (u8) (arg >> 24); - cmd[2] = (u8) (arg >> 16); - cmd[3] = (u8) (arg >> 8); - cmd[4] = (u8) arg; - - buf = kmalloc(data_len, GFP_KERNEL); - if (buf == NULL) - TRACE_RET(chip, TRANSPORT_ERROR); - - retval = sd_read_data(chip, SD_TM_NORMAL_READ, cmd, 5, byte_cnt, - blk_cnt, bus_width, buf, data_len, 2000); - if (retval != STATUS_SUCCESS) { - read_err = 1; - kfree(buf); - rts51x_write_register(chip, CARD_STOP, - SD_STOP | SD_CLR_ERR, - SD_STOP | SD_CLR_ERR); - TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed); - } - - min_len = min(data_len, buf_len); - if (use_sg) - rts51x_access_sglist(buf, min_len, (void *)data_buf, - &sg, &offset, TO_XFER_BUF); - else - memcpy(data_buf, buf, min_len); - - kfree(buf); - } else if (!(data_len & 0x1FF)) { - rts51x_init_cmd(chip); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_H, 0xFF, 0x02); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_L, 0xFF, 0x00); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_H, - 0xFF, (u8) (data_len >> 17)); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_L, - 0xFF, (u8) ((data_len & 0x0001FE00) >> 9)); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD0, 0xFF, - 0x40 | cmd_idx); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD1, 0xFF, - (u8) (arg >> 24)); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD2, 0xFF, - (u8) (arg >> 16)); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD3, 0xFF, - (u8) (arg >> 8)); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CMD4, 0xFF, (u8) arg); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG1, 0x03, bus_width); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_CFG2, 0xFF, rsp_type); - rts51x_trans_dma_enable(DMA_FROM_DEVICE, chip, data_len, DMA_512); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_TRANSFER, 0xFF, - SD_TM_AUTO_READ_2 | SD_TRANSFER_START); - rts51x_add_cmd(chip, CHECK_REG_CMD, SD_TRANSFER, - SD_TRANSFER_END, SD_TRANSFER_END); - retval = rts51x_send_cmd(chip, MODE_CDIR, 100); - if (retval != STATUS_SUCCESS) { - read_err = 1; - rts51x_ep0_write_register(chip, CARD_STOP, - SD_STOP | SD_CLR_ERR, - SD_STOP | SD_CLR_ERR); - TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed); - } - - retval = - rts51x_transfer_data_rcc(chip, RCV_BULK_PIPE(chip), - data_buf, buf_len, use_sg, NULL, - 10000, STAGE_DI); - if (retval != STATUS_SUCCESS) { - read_err = 1; - rts51x_ep0_write_register(chip, CARD_STOP, - SD_STOP | SD_CLR_ERR, - SD_STOP | SD_CLR_ERR); - TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed); - } - retval = rts51x_get_rsp(chip, 1, 500); - if (CHECK_SD_TRANS_FAIL(chip, retval)) { - read_err = 1; - rts51x_ep0_write_register(chip, CARD_STOP, - SD_STOP | SD_CLR_ERR, - SD_STOP | SD_CLR_ERR); - TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed); - } - } else { - TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed); - } - - retval = ext_sd_get_rsp(chip, rsp_len, sd_card->rsp, rsp_type); - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed); - - if (standby) { - retval = rts51x_sd_select_card(chip, 1); - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed); - } - - if (cmd12) { - retval = ext_sd_send_cmd_get_rsp(chip, STOP_TRANSMISSION, - 0, SD_RSP_TYPE_R1b, NULL, 0, - 0); - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed); - } - - if (data_len < 512) { - retval = ext_sd_send_cmd_get_rsp(chip, SET_BLOCKLEN, 0x200, - SD_RSP_TYPE_R1, NULL, 0, 0); - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed); - - rts51x_write_register(chip, SD_BYTE_CNT_H, 0xFF, 0x02); - rts51x_write_register(chip, SD_BYTE_CNT_L, 0xFF, 0x00); - } - - if (standby || cmd12) - cmd13_checkbit = 1; - - for (i = 0; i < 3; i++) { - retval = - ext_sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, - SD_RSP_TYPE_R1, NULL, 0, - cmd13_checkbit); - if (retval == STATUS_SUCCESS) - break; - } - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed); - - return TRANSPORT_GOOD; - -SD_Execute_Read_Cmd_Failed: - sd_card->pre_cmd_err = 1; - rts51x_set_sense_type(chip, lun, SENSE_TYPE_NO_SENSE); - if (read_err) - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - rts51x_release_sd_card(chip); - rts51x_do_rts51x_reset_sd_card(chip); - if (!(chip->card_ready & SD_CARD)) - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - - TRACE_RET(chip, TRANSPORT_FAILED); -} - -int ext_rts51x_sd_execute_write_data(struct rts51x_chip *chip, unsigned int lun, - u8 cmd_idx, u8 cmd12, u8 standby, u8 acmd, - u8 rsp_code, u32 arg, u32 data_len, - void *data_buf, unsigned int buf_len, int use_sg) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval, rsp_len; - int cmd13_checkbit = 0, write_err = 0; - u8 rsp_type; - u32 i; - - if (sd_card->pre_cmd_err) { - sd_card->pre_cmd_err = 0; - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - retval = rts51x_sd_switch_clock(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - - retval = get_rsp_type(rsp_code, &rsp_type, &rsp_len); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - sd_card->last_rsp_type = rsp_type; - - retval = rts51x_sd_switch_clock(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, TRANSPORT_FAILED); - rts51x_write_register(chip, SD_CFG1, 0x03, SD_BUS_WIDTH_4); - - if (data_len < 512) { - retval = ext_sd_send_cmd_get_rsp(chip, SET_BLOCKLEN, data_len, - SD_RSP_TYPE_R1, NULL, 0, 0); - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); - } - - if (standby) { - retval = rts51x_sd_select_card(chip, 0); - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); - } - - if (acmd) { - retval = - ext_sd_send_cmd_get_rsp(chip, APP_CMD, sd_card->sd_addr, - SD_RSP_TYPE_R1, NULL, 0, 0); - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); - } - - retval = ext_sd_send_cmd_get_rsp(chip, cmd_idx, arg, rsp_type, - sd_card->rsp, rsp_len, 0); - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); - - if (data_len <= 512) { - u8 *buf; - unsigned int offset = 0; - void *sg = NULL; - - buf = kmalloc(data_len, GFP_KERNEL); - if (buf == NULL) - TRACE_RET(chip, TRANSPORT_ERROR); - - if (use_sg) - rts51x_access_sglist(buf, data_len, (void *)data_buf, - &sg, &offset, FROM_XFER_BUF); - else - memcpy(buf, data_buf, data_len); - - - if (data_len > 256) { - rts51x_init_cmd(chip); - for (i = 0; i < 256; i++) { - rts51x_add_cmd(chip, WRITE_REG_CMD, - (u16) (PPBUF_BASE2 + i), 0xFF, - buf[i]); - } - retval = rts51x_send_cmd(chip, MODE_C, 250); - if (retval != STATUS_SUCCESS) { - kfree(buf); - TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); - } - - rts51x_init_cmd(chip); - for (i = 256; i < data_len; i++) { - rts51x_add_cmd(chip, WRITE_REG_CMD, - (u16) (PPBUF_BASE2 + i), 0xFF, - buf[i]); - } - retval = rts51x_send_cmd(chip, MODE_C, 250); - if (retval != STATUS_SUCCESS) { - kfree(buf); - TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); - } - } else { - rts51x_init_cmd(chip); - for (i = 0; i < data_len; i++) { - rts51x_add_cmd(chip, WRITE_REG_CMD, - (u16) (PPBUF_BASE2 + i), 0xFF, - buf[i]); - } - retval = rts51x_send_cmd(chip, MODE_C, 250); - if (retval != STATUS_SUCCESS) { - kfree(buf); - TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); - } - } - - kfree(buf); - - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_H, 0xFF, - (u8) ((data_len >> 8) & 0x03)); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_L, 0xFF, - (u8) data_len); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_H, 0xFF, 0x00); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_L, 0xFF, 0x01); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, - PINGPONG_BUFFER); - - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_TRANSFER, 0xFF, - SD_TM_AUTO_WRITE_3 | SD_TRANSFER_START); - rts51x_add_cmd(chip, CHECK_REG_CMD, SD_TRANSFER, - SD_TRANSFER_END, SD_TRANSFER_END); - - retval = rts51x_send_cmd(chip, MODE_CR, 100); - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); - - retval = rts51x_get_rsp(chip, 1, 250); - if (CHECK_SD_TRANS_FAIL(chip, retval)) - TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); - } else if (!(data_len & 0x1FF)) { - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_H, 0xFF, 0x02); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BYTE_CNT_L, 0xFF, 0x00); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_H, - 0xFF, (u8) (data_len >> 17)); - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_L, - 0xFF, (u8) ((data_len & 0x0001FE00) >> 9)); - - rts51x_trans_dma_enable(DMA_TO_DEVICE, chip, data_len, DMA_512); - - rts51x_add_cmd(chip, WRITE_REG_CMD, SD_TRANSFER, 0xFF, - SD_TM_AUTO_WRITE_3 | SD_TRANSFER_START); - rts51x_add_cmd(chip, CHECK_REG_CMD, SD_TRANSFER, - SD_TRANSFER_END, SD_TRANSFER_END); - - retval = rts51x_send_cmd(chip, MODE_CDOR, 100); - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); - - retval = - rts51x_transfer_data_rcc(chip, SND_BULK_PIPE(chip), - data_buf, buf_len, use_sg, NULL, - 10000, STAGE_DO); - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); - - retval = rts51x_get_rsp(chip, 1, 10000); - if (CHECK_SD_TRANS_FAIL(chip, retval)) - TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); - - } else { - TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); - } - - if (retval < 0) { - write_err = 1; - rts51x_write_register(chip, CARD_STOP, SD_STOP | SD_CLR_ERR, - SD_STOP | SD_CLR_ERR); - TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); - } - - if (standby) { - retval = rts51x_sd_select_card(chip, 1); - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); - } - - if (cmd12) { - retval = ext_sd_send_cmd_get_rsp(chip, STOP_TRANSMISSION, - 0, SD_RSP_TYPE_R1b, NULL, 0, - 0); - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); - } - - if (data_len < 512) { - retval = ext_sd_send_cmd_get_rsp(chip, SET_BLOCKLEN, 0x200, - SD_RSP_TYPE_R1, NULL, 0, 0); - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); - - rts51x_write_register(chip, SD_BYTE_CNT_H, 0xFF, 0x02); - rts51x_write_register(chip, SD_BYTE_CNT_L, 0xFF, 0x00); - } - - if (cmd12 || standby) { - /* There is CMD7 or CMD12 sent before CMD13 */ - cmd13_checkbit = 1; - } - - for (i = 0; i < 3; i++) { - retval = - ext_sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, - SD_RSP_TYPE_R1, NULL, 0, - cmd13_checkbit); - if (retval == STATUS_SUCCESS) - break; - } - if (retval != STATUS_SUCCESS) - TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed); - - return TRANSPORT_GOOD; - -SD_Execute_Write_Cmd_Failed: - sd_card->pre_cmd_err = 1; - rts51x_set_sense_type(chip, lun, SENSE_TYPE_NO_SENSE); - if (write_err) - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR); - rts51x_release_sd_card(chip); - rts51x_do_rts51x_reset_sd_card(chip); - if (!(chip->card_ready & SD_CARD)) - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - - TRACE_RET(chip, TRANSPORT_FAILED); -} - -int rts51x_sd_pass_thru_mode(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - struct sd_info *sd_card = &(chip->sd_card); - unsigned int lun = SCSI_LUN(srb); - int len; - u8 buf[18] = { - 0x00, - 0x00, - 0x00, - 0x0E, - 0x00, /* Version Number */ - 0x00, /* WP | Media Type */ - 0x00, /* RCA (Low byte) */ - 0x00, /* RCA (High byte) */ - 0x53, /* 'S' */ - 0x44, /* 'D' */ - 0x20, /* ' ' */ - 0x43, /* 'C' */ - 0x61, /* 'a' */ - 0x72, /* 'r' */ - 0x64, /* 'd' */ - 0x00, /* Max LUN Number */ - 0x00, - 0x00, - }; - - sd_card->pre_cmd_err = 0; - - if (!(CHK_BIT(chip->lun_mc, lun))) { - SET_BIT(chip->lun_mc, lun); - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - if ((0x53 != srb->cmnd[2]) || (0x44 != srb->cmnd[3]) - || (0x20 != srb->cmnd[4]) || (0x43 != srb->cmnd[5]) - || (0x61 != srb->cmnd[6]) || (0x72 != srb->cmnd[7]) - || (0x64 != srb->cmnd[8])) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - switch (srb->cmnd[1] & 0x0F) { - case 0: - sd_card->sd_pass_thru_en = 0; - break; - - case 1: - sd_card->sd_pass_thru_en = 1; - break; - - default: - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - /* 0x01:SD Memory Card; 0x02:Other Media; 0x03:Illegal Media; */ - buf[5] = (1 == CHK_SD(sd_card)) ? 0x01 : 0x02; - if (chip->card_wp & SD_CARD) - buf[5] |= 0x80; - - buf[6] = (u8) (sd_card->sd_addr >> 16); - buf[7] = (u8) (sd_card->sd_addr >> 24); - - buf[15] = chip->max_lun; - - len = min_t(unsigned, 18, scsi_bufflen(srb)); - rts51x_set_xfer_buf(buf, len, srb); - - return TRANSPORT_GOOD; -} - -int rts51x_sd_execute_no_data(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - struct sd_info *sd_card = &(chip->sd_card); - unsigned int lun = SCSI_LUN(srb); - int retval; - u8 cmd_idx, rsp_code; - u8 standby = 0, acmd = 0; - u32 arg; - - if (!sd_card->sd_pass_thru_en) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - cmd_idx = srb->cmnd[2] & 0x3F; - if (srb->cmnd[1] & 0x02) - standby = 1; - if (srb->cmnd[1] & 0x01) - acmd = 1; - - arg = ((u32) srb->cmnd[3] << 24) | ((u32) srb->cmnd[4] << 16) | - ((u32) srb->cmnd[5] << 8) | srb->cmnd[6]; - - rsp_code = srb->cmnd[10]; - - retval = - ext_rts51x_sd_execute_no_data(chip, lun, cmd_idx, standby, acmd, rsp_code, - arg); - scsi_set_resid(srb, 0); - return retval; -} - -int rts51x_sd_execute_read_data(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval; - unsigned int lun = SCSI_LUN(srb); - u8 cmd_idx, rsp_code, send_cmd12 = 0, standby = 0, acmd = 0; - u32 arg, data_len; - - if (!sd_card->sd_pass_thru_en) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - cmd_idx = srb->cmnd[2] & 0x3F; - if (srb->cmnd[1] & 0x04) - send_cmd12 = 1; - if (srb->cmnd[1] & 0x02) - standby = 1; - if (srb->cmnd[1] & 0x01) - acmd = 1; - - arg = ((u32) srb->cmnd[3] << 24) | ((u32) srb->cmnd[4] << 16) | - ((u32) srb->cmnd[5] << 8) | srb->cmnd[6]; - - data_len = - ((u32) srb->cmnd[7] << 16) | ((u32) srb->cmnd[8] << 8) | - srb->cmnd[9]; - rsp_code = srb->cmnd[10]; - - retval = - ext_rts51x_sd_execute_read_data(chip, lun, cmd_idx, send_cmd12, standby, - acmd, rsp_code, arg, data_len, - scsi_sglist(srb), scsi_bufflen(srb), - scsi_sg_count(srb)); - scsi_set_resid(srb, 0); - return retval; -} - -int rts51x_sd_execute_write_data(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - struct sd_info *sd_card = &(chip->sd_card); - int retval; - unsigned int lun = SCSI_LUN(srb); - u8 cmd_idx, rsp_code, send_cmd12 = 0, standby = 0, acmd = 0; - u32 data_len, arg; - - if (!sd_card->sd_pass_thru_en) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - cmd_idx = srb->cmnd[2] & 0x3F; - if (srb->cmnd[1] & 0x04) - send_cmd12 = 1; - if (srb->cmnd[1] & 0x02) - standby = 1; - if (srb->cmnd[1] & 0x01) - acmd = 1; - - data_len = - ((u32) srb->cmnd[7] << 16) | ((u32) srb->cmnd[8] << 8) | - srb->cmnd[9]; - arg = - ((u32) srb->cmnd[3] << 24) | ((u32) srb->cmnd[4] << 16) | - ((u32) srb->cmnd[5] << 8) | srb->cmnd[6]; - rsp_code = srb->cmnd[10]; - - retval = - ext_rts51x_sd_execute_write_data(chip, lun, cmd_idx, send_cmd12, standby, - acmd, rsp_code, arg, data_len, - scsi_sglist(srb), scsi_bufflen(srb), - scsi_sg_count(srb)); - scsi_set_resid(srb, 0); - return retval; -} - -int rts51x_sd_get_cmd_rsp(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - struct sd_info *sd_card = &(chip->sd_card); - unsigned int lun = SCSI_LUN(srb); - int count; - u16 data_len; - - if (!sd_card->sd_pass_thru_en) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - if (sd_card->pre_cmd_err) { - sd_card->pre_cmd_err = 0; - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - data_len = ((u16) srb->cmnd[7] << 8) | srb->cmnd[8]; - - if (sd_card->last_rsp_type == SD_RSP_TYPE_R0) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } else if (sd_card->last_rsp_type == SD_RSP_TYPE_R2) { - count = (data_len < 17) ? data_len : 17; - } else { - count = (data_len < 6) ? data_len : 6; - } - rts51x_set_xfer_buf(sd_card->rsp, count, srb); - - RTS51X_DEBUGP("Response length: %d\n", data_len); - RTS51X_DEBUGP("Response: 0x%x 0x%x 0x%x 0x%x\n", - sd_card->rsp[0], sd_card->rsp[1], sd_card->rsp[2], - sd_card->rsp[3]); - - scsi_set_resid(srb, 0); - return TRANSPORT_GOOD; -} - -int rts51x_sd_hw_rst(struct scsi_cmnd *srb, struct rts51x_chip *chip) -{ - struct sd_info *sd_card = &(chip->sd_card); - unsigned int lun = SCSI_LUN(srb); - int retval; - - if (!sd_card->sd_pass_thru_en) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - if (sd_card->pre_cmd_err) { - sd_card->pre_cmd_err = 0; - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - if ((0x53 != srb->cmnd[2]) || (0x44 != srb->cmnd[3]) - || (0x20 != srb->cmnd[4]) || (0x43 != srb->cmnd[5]) - || (0x61 != srb->cmnd[6]) || (0x72 != srb->cmnd[7]) - || (0x64 != srb->cmnd[8])) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - switch (srb->cmnd[1] & 0x0F) { - case 0: - /* SD Card Power Off -> ON and Initialization */ - retval = rts51x_reset_sd_card(chip); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - sd_card->pre_cmd_err = 1; - TRACE_RET(chip, TRANSPORT_FAILED); - } - break; - - case 1: - /* reset CMD(CMD0) and Initialization - * (without SD Card Power Off -> ON) */ - retval = reset_sd(chip); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); - sd_card->pre_cmd_err = 1; - TRACE_RET(chip, TRANSPORT_FAILED); - } - break; - - default: - rts51x_set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD); - TRACE_RET(chip, TRANSPORT_FAILED); - } - - scsi_set_resid(srb, 0); - return TRANSPORT_GOOD; -} -#endif diff --git a/drivers/staging/rts5139/sd_cprm.h b/drivers/staging/rts5139/sd_cprm.h deleted file mode 100644 index 79dfd27db41a..000000000000 --- a/drivers/staging/rts5139/sd_cprm.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Driver for Realtek RTS51xx USB card reader - * Header file - * - * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. - * - * 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, 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, see . - * - * Author: - * wwang (wei_wang@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - * Maintainer: - * Edwin Rong (edwin_rong@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - */ - -#ifndef __RTS51X_SD_CPRM_H -#define __RTS51X_SD_CPRM_H - -#include "rts51x_chip.h" -#include "sd.h" - -#ifdef SUPPORT_CPRM -int ext_rts51x_sd_execute_no_data(struct rts51x_chip *chip, unsigned int lun, - u8 cmd_idx, u8 standby, u8 acmd, u8 rsp_code, - u32 arg); -int ext_rts51x_sd_execute_read_data(struct rts51x_chip *chip, unsigned int lun, - u8 cmd_idx, u8 cmd12, u8 standby, u8 acmd, - u8 rsp_code, u32 arg, u32 data_len, void *data_buf, - unsigned int buf_len, int use_sg); -int ext_rts51x_sd_execute_write_data(struct rts51x_chip *chip, unsigned int lun, - u8 cmd_idx, u8 cmd12, u8 standby, u8 acmd, - u8 rsp_code, u32 arg, u32 data_len, - void *data_buf, unsigned int buf_len, int use_sg); - -int rts51x_sd_pass_thru_mode(struct scsi_cmnd *srb, struct rts51x_chip *chip); -int rts51x_sd_execute_no_data(struct scsi_cmnd *srb, struct rts51x_chip *chip); -int rts51x_sd_execute_read_data(struct scsi_cmnd *srb, struct rts51x_chip *chip); -int rts51x_sd_execute_write_data(struct scsi_cmnd *srb, struct rts51x_chip *chip); -int rts51x_sd_get_cmd_rsp(struct scsi_cmnd *srb, struct rts51x_chip *chip); -int rts51x_sd_hw_rst(struct scsi_cmnd *srb, struct rts51x_chip *chip); -#endif - -#endif /* __RTS51X_SD_CPRM_H */ diff --git a/drivers/staging/rts5139/trace.h b/drivers/staging/rts5139/trace.h deleted file mode 100644 index ac58b452ecb8..000000000000 --- a/drivers/staging/rts5139/trace.h +++ /dev/null @@ -1,95 +0,0 @@ -/* Driver for Realtek RTS51xx USB card reader - * Header file - * - * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. - * - * 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, 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, see . - * - * Author: - * wwang (wei_wang@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - * Maintainer: - * Edwin Rong (edwin_rong@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - */ - -#ifndef __RTS51X_TRACE_H -#define __RTS51X_TRACE_H - -#include - -#include "debug.h" - -#define _MSG_TRACE - -#ifdef _MSG_TRACE -#define TRACE_RET(chip, ret) \ -do { \ - const char *_file = kbasename(__FILE__); \ - RTS51X_DEBUGP("[%s][%s]:[%d]\n", _file, __func__, __LINE__); \ - (chip)->trace_msg[(chip)->msg_idx].line = (u16)(__LINE__); \ - strncpy((chip)->trace_msg[(chip)->msg_idx].func, \ - __func__, MSG_FUNC_LEN-1); \ - strncpy((chip)->trace_msg[(chip)->msg_idx].file, \ - _file, MSG_FILE_LEN-1); \ - get_current_time((chip)->trace_msg[(chip)->msg_idx].timeval_buf,\ - TIME_VAL_LEN); \ - (chip)->trace_msg[(chip)->msg_idx].valid = 1; \ - (chip)->msg_idx++; \ - if ((chip)->msg_idx >= TRACE_ITEM_CNT) { \ - (chip)->msg_idx = 0; \ - } \ - return ret; \ -} while (0) - -#define TRACE_GOTO(chip, label) \ -do { \ - const char *_file = kbasename(__FILE__); \ - RTS51X_DEBUGP("[%s][%s]:[%d]\n", _file, __func__, __LINE__); \ - (chip)->trace_msg[(chip)->msg_idx].line = (u16)(__LINE__); \ - strncpy((chip)->trace_msg[(chip)->msg_idx].func, \ - __func__, MSG_FUNC_LEN-1); \ - strncpy((chip)->trace_msg[(chip)->msg_idx].file, \ - _file, MSG_FILE_LEN-1); \ - get_current_time((chip)->trace_msg[(chip)->msg_idx].timeval_buf,\ - TIME_VAL_LEN); \ - (chip)->trace_msg[(chip)->msg_idx].valid = 1; \ - (chip)->msg_idx++; \ - if ((chip)->msg_idx >= TRACE_ITEM_CNT) { \ - (chip)->msg_idx = 0; \ - } \ - goto label; \ -} while (0) -#else -#define TRACE_RET(chip, ret) return (ret) -#define TRACE_GOTO(chip, label) goto label -#endif - -#ifdef CONFIG_RTS5139_DEBUG -#define RTS51X_DUMP(buf, buf_len) \ - print_hex_dump(KERN_DEBUG, RTS51X_TIP, DUMP_PREFIX_NONE, \ - 16, 1, (buf), (buf_len), false) - -#define CATCH_TRIGGER(chip) \ -do { \ - rts51x_ep0_write_register((chip), 0xFC31, 0x01, 0x01); \ - RTS51X_DEBUGP("Catch trigger!\n"); \ -} while (0) - -#else -#define RTS51X_DUMP(buf, buf_len) -#define CATCH_TRIGGER(chip) -#endif - -#endif /* __RTS51X_TRACE_H */ diff --git a/drivers/staging/rts5139/xd.c b/drivers/staging/rts5139/xd.c deleted file mode 100644 index be432351be86..000000000000 --- a/drivers/staging/rts5139/xd.c +++ /dev/null @@ -1,2145 +0,0 @@ -/* Driver for Realtek RTS51xx USB card reader - * - * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. - * - * 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, 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, see . - * - * Author: - * wwang (wei_wang@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - * Maintainer: - * Edwin Rong (edwin_rong@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - */ - -#include -#include -#include -#include - -#include "debug.h" -#include "trace.h" -#include "rts51x.h" -#include "rts51x_transport.h" -#include "rts51x_scsi.h" -#include "rts51x_card.h" -#include "xd.h" - -static int xd_build_l2p_tbl(struct rts51x_chip *chip, int zone_no); -static int xd_init_page(struct rts51x_chip *chip, u32 phy_blk, u16 logoff, - u8 start_page, u8 end_page); - -static inline void xd_set_err_code(struct rts51x_chip *chip, u8 err_code) -{ - struct xd_info *xd_card = &(chip->xd_card); - - xd_card->err_code = err_code; -} - -static int xd_set_init_para(struct rts51x_chip *chip) -{ - struct xd_info *xd_card = &(chip->xd_card); - int retval; - - if (chip->asic_code) - xd_card->xd_clock = 47; - else - xd_card->xd_clock = CLK_50; - - retval = switch_clock(chip, xd_card->xd_clock); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - return STATUS_SUCCESS; -} - -static int xd_switch_clock(struct rts51x_chip *chip) -{ - struct xd_info *xd_card = &(chip->xd_card); - int retval; - - retval = rts51x_select_card(chip, XD_CARD); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = switch_clock(chip, xd_card->xd_clock); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - return STATUS_SUCCESS; -} - -static int xd_read_id(struct rts51x_chip *chip, u8 id_cmd, u8 *id_buf, - u8 buf_len) -{ - int retval, i; - - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_DAT, 0xFF, id_cmd); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_TRANSFER, 0xFF, - XD_TRANSFER_START | XD_READ_ID); - rts51x_add_cmd(chip, CHECK_REG_CMD, XD_TRANSFER, XD_TRANSFER_END, - XD_TRANSFER_END); - - for (i = 0; i < 4; i++) { - rts51x_add_cmd(chip, READ_REG_CMD, (u16) (XD_ADDRESS1 + i), 0, - 0); - } - - retval = rts51x_send_cmd(chip, MODE_CR, 20); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = rts51x_get_rsp(chip, 5, 20); - - if (retval != STATUS_SUCCESS) { - rts51x_clear_xd_error(chip); - TRACE_RET(chip, retval); - } - - if (id_buf && buf_len) { - if (buf_len > 4) - buf_len = 4; - rts51x_read_rsp_buf(chip, 1, id_buf, buf_len); - } - - return STATUS_SUCCESS; -} - -static void xd_assign_phy_addr(struct rts51x_chip *chip, u32 addr, u8 mode) -{ - struct xd_info *xd_card = &(chip->xd_card); - - switch (mode) { - case XD_RW_ADDR: - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_ADDRESS0, 0xFF, 0); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_ADDRESS1, 0xFF, - (u8) addr); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_ADDRESS2, 0xFF, - (u8) (addr >> 8)); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_ADDRESS3, 0xFF, - (u8) (addr >> 16)); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CFG, 0xFF, - xd_card->addr_cycle | XD_CALC_ECC | - XD_BA_NO_TRANSFORM); - break; - - case XD_ERASE_ADDR: - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_ADDRESS0, 0xFF, - (u8) addr); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_ADDRESS1, 0xFF, - (u8) (addr >> 8)); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_ADDRESS2, 0xFF, - (u8) (addr >> 16)); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CFG, 0xFF, - (xd_card->addr_cycle - 1) | - XD_CALC_ECC | XD_BA_NO_TRANSFORM); - break; - - default: - break; - } -} - -static int xd_read_redundant(struct rts51x_chip *chip, u32 page_addr, u8 *buf, - int buf_len) -{ - int retval, i; - - rts51x_init_cmd(chip); - - xd_assign_phy_addr(chip, page_addr, XD_RW_ADDR); - - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_TRANSFER, 0xFF, - XD_TRANSFER_START | XD_READ_REDUNDANT); - rts51x_add_cmd(chip, CHECK_REG_CMD, XD_TRANSFER, XD_TRANSFER_END, - XD_TRANSFER_END); - - for (i = 0; i < 6; i++) { - rts51x_add_cmd(chip, READ_REG_CMD, (u16) (XD_PAGE_STATUS + i), - 0, 0); - } - for (i = 0; i < 4; i++) { - rts51x_add_cmd(chip, READ_REG_CMD, (u16) (XD_RESERVED0 + i), 0, - 0); - } - rts51x_add_cmd(chip, READ_REG_CMD, XD_PARITY, 0, 0); - - retval = rts51x_send_cmd(chip, MODE_CR, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = rts51x_get_rsp(chip, 11, 500); - - if (retval != STATUS_SUCCESS) { - rts51x_clear_xd_error(chip); - TRACE_RET(chip, retval); - } - - if (buf && buf_len) { - if (buf_len > 11) - buf_len = 11; - rts51x_read_rsp_buf(chip, 1, buf, buf_len); - } - - return STATUS_SUCCESS; -} - -static int xd_read_data_from_ppb(struct rts51x_chip *chip, int offset, u8 *buf, - int buf_len) -{ - int retval, i; - - if (!buf || (buf_len <= 0)) - TRACE_RET(chip, STATUS_FAIL); - - rts51x_init_cmd(chip); - - for (i = 0; i < buf_len; i++) { - rts51x_add_cmd(chip, READ_REG_CMD, PPBUF_BASE2 + offset + i, 0, - 0); - } - - retval = rts51x_send_cmd(chip, MODE_CR, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = rts51x_get_rsp(chip, buf_len, 200); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - rts51x_read_rsp_buf(chip, 0, buf, buf_len); - - return STATUS_SUCCESS; -} - -static int xd_read_cis(struct rts51x_chip *chip, u32 page_addr, u8 *buf, - int buf_len) -{ - int retval; - u8 reg; - - if (!buf || (buf_len < 10)) - TRACE_RET(chip, STATUS_FAIL); - - rts51x_init_cmd(chip); - - xd_assign_phy_addr(chip, page_addr, XD_RW_ADDR); - - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, - PINGPONG_BUFFER); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_PAGE_CNT, 0xFF, 1); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CHK_DATA_STATUS, - XD_AUTO_CHK_DATA_STATUS, XD_AUTO_CHK_DATA_STATUS); - - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_TRANSFER, 0xFF, - XD_TRANSFER_START | XD_READ_PAGES); - rts51x_add_cmd(chip, CHECK_REG_CMD, XD_TRANSFER, - XD_TRANSFER_END | XD_PPB_EMPTY, - XD_TRANSFER_END | XD_PPB_EMPTY); - - retval = rts51x_send_cmd(chip, MODE_CR, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = rts51x_get_rsp(chip, 1, 500); - if (retval == STATUS_TIMEDOUT) { - rts51x_clear_xd_error(chip); - TRACE_RET(chip, retval); - } - - RTS51X_READ_REG(chip, XD_PAGE_STATUS, ®); - if (reg != XD_GPG) { - rts51x_clear_xd_error(chip); - TRACE_RET(chip, STATUS_FAIL); - } - - RTS51X_READ_REG(chip, XD_CTL, ®); - - if (!(reg & XD_ECC1_ERROR) || !(reg & XD_ECC1_UNCORRECTABLE)) { - retval = xd_read_data_from_ppb(chip, 0, buf, buf_len); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - if (reg & XD_ECC1_ERROR) { /* correctable error */ - u8 ecc_bit, ecc_byte; - - RTS51X_READ_REG(chip, XD_ECC_BIT1, &ecc_bit); - RTS51X_READ_REG(chip, XD_ECC_BYTE1, &ecc_byte); - - RTS51X_DEBUGP("ECC_BIT1 = 0x%x, ECC_BYTE1 = 0x%x\n", - ecc_bit, ecc_byte); - if (ecc_byte < buf_len) { - RTS51X_DEBUGP("Before correct: 0x%x\n", - buf[ecc_byte]); - buf[ecc_byte] ^= (1 << ecc_bit); - RTS51X_DEBUGP("After correct: 0x%x\n", - buf[ecc_byte]); - } - } - } else if (!(reg & XD_ECC2_ERROR) || !(reg & XD_ECC2_UNCORRECTABLE)) { - RTS51X_WRITE_REG(chip, CARD_STOP, XD_STOP | XD_CLR_ERR, - XD_STOP | XD_CLR_ERR); - - retval = xd_read_data_from_ppb(chip, 256, buf, buf_len); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - if (reg & XD_ECC2_ERROR) { - u8 ecc_bit, ecc_byte; - - RTS51X_READ_REG(chip, XD_ECC_BIT2, &ecc_bit); - RTS51X_READ_REG(chip, XD_ECC_BYTE2, &ecc_byte); - - RTS51X_DEBUGP("ECC_BIT2 = 0x%x, ECC_BYTE2 = 0x%x\n", - ecc_bit, ecc_byte); - if (ecc_byte < buf_len) { - RTS51X_DEBUGP("Before correct: 0x%x\n", - buf[ecc_byte]); - buf[ecc_byte] ^= (1 << ecc_bit); - RTS51X_DEBUGP("After correct: 0x%x\n", - buf[ecc_byte]); - } - } - } else { - rts51x_clear_xd_error(chip); - TRACE_RET(chip, STATUS_FAIL); - } - - return STATUS_SUCCESS; -} - -static void xd_pull_ctl_disable(struct rts51x_chip *chip) -{ - if (CHECK_PKG(chip, LQFP48)) { - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0x95); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0xA5); - } else { - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0x65); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0x95); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x56); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0x59); - } -} - -static void xd_pull_ctl_enable(struct rts51x_chip *chip) -{ - if (CHECK_PKG(chip, LQFP48)) { - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0xAA); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0x95); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0xA5); - } else { - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0xA5); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0x59); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0x95); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x55); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0x59); - } -} - -static int reset_xd(struct rts51x_chip *chip) -{ - struct xd_info *xd_card = &(chip->xd_card); - int retval, i, j; - u8 id_buf[4], redunt[11]; - - retval = rts51x_select_card(chip, XD_CARD); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CHK_DATA_STATUS, 0xFF, - XD_PGSTS_NOT_FF); - if (chip->asic_code) - xd_pull_ctl_disable(chip); - else - rts51x_add_cmd(chip, WRITE_REG_CMD, FPGA_PULL_CTL, 0xFF, - (FPGA_XD_PULL_CTL_EN1 & FPGA_XD_PULL_CTL_EN3)); - - if (!chip->option.FT2_fast_mode) { - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_INIT, XD_NO_AUTO_PWR_OFF, - 0); - if (CHECK_PKG(chip, LQFP48) || - chip->option.rts5129_D3318_off_enable) { - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, - DV3318_AUTO_PWR_OFF, - DV3318_AUTO_PWR_OFF); - } - } - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_OE, XD_OUTPUT_EN, 0); - if (!chip->option.FT2_fast_mode) { - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, POWER_MASK, - POWER_OFF); - } - - retval = rts51x_send_cmd(chip, MODE_C, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - if (!chip->option.FT2_fast_mode) { -#ifdef SD_XD_IO_FOLLOW_PWR - if (CHECK_PKG(chip, LQFP48) - || chip->option.rts5129_D3318_off_enable) { - rts51x_write_register(chip, CARD_PWR_CTL, - LDO_OFF, LDO_OFF); - } -#endif - - wait_timeout(250); - -#ifdef SD_XD_IO_FOLLOW_PWR - if (CHECK_PKG(chip, LQFP48) - || chip->option.rts5129_D3318_off_enable) { - rts51x_init_cmd(chip); - if (chip->asic_code) { - xd_pull_ctl_enable(chip); - } else { - rts51x_add_cmd(chip, WRITE_REG_CMD, - FPGA_PULL_CTL, 0xFF, - (FPGA_XD_PULL_CTL_EN1 & - FPGA_XD_PULL_CTL_EN2)); - } - retval = rts51x_send_cmd(chip, MODE_C, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - } -#endif - - retval = rts51x_card_power_on(chip, XD_CARD); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); -#ifdef SUPPORT_OCP - wait_timeout(50); - rts51x_get_card_status(chip, &(chip->card_status)); - chip->ocp_stat = (chip->card_status >> 4) & 0x03; - - if (chip->ocp_stat & (MS_OCP_NOW | MS_OCP_EVER)) { - RTS51X_DEBUGP("Over current, OCPSTAT is 0x%x\n", - chip->ocp_stat); - TRACE_RET(chip, STATUS_FAIL); - } -#endif - } - - rts51x_init_cmd(chip); - - if (chip->asic_code) - xd_pull_ctl_enable(chip); - else - rts51x_add_cmd(chip, WRITE_REG_CMD, FPGA_PULL_CTL, 0xFF, - (FPGA_XD_PULL_CTL_EN1 & FPGA_XD_PULL_CTL_EN2)); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_OE, XD_OUTPUT_EN, - XD_OUTPUT_EN); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CTL, XD_CE_DISEN, XD_CE_DISEN); - - retval = rts51x_send_cmd(chip, MODE_C, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - - if (!chip->option.FT2_fast_mode) - wait_timeout(200); - - retval = xd_set_init_para(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - /* Read ID to check if the timing setting is right */ - for (i = 0; i < 4; i++) { - u8 xd_dat, xd_ctl; - - if (monitor_card_cd(chip, XD_CARD) == CD_NOT_EXIST) - TRACE_RET(chip, STATUS_FAIL); - - rts51x_init_cmd(chip); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_DTCTL, 0xFF, - XD_TIME_SETUP_STEP * 3 + XD_TIME_RW_STEP * - (2 + i + chip->option.rts51x_xd_rw_step) - + XD_TIME_RWN_STEP * - (i + chip->option.rts51x_xd_rwn_step)); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CATCTL, 0xFF, - XD_TIME_SETUP_STEP * 3 + XD_TIME_RW_STEP * (4 + - i) + XD_TIME_RWN_STEP * (3 + i)); - - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_TRANSFER, 0xFF, - XD_TRANSFER_START | XD_RESET); - rts51x_add_cmd(chip, CHECK_REG_CMD, XD_TRANSFER, - XD_TRANSFER_END, XD_TRANSFER_END); - - rts51x_add_cmd(chip, READ_REG_CMD, XD_DAT, 0, 0); - rts51x_add_cmd(chip, READ_REG_CMD, XD_CTL, 0, 0); - - retval = rts51x_send_cmd(chip, MODE_CR, 100); - if (retval != STATUS_SUCCESS) { - rts51x_clear_xd_error(chip); - TRACE_RET(chip, retval); - } - - retval = rts51x_get_rsp(chip, 3, 100); - if (retval != STATUS_SUCCESS) { - rts51x_clear_xd_error(chip); - TRACE_RET(chip, retval); - } - - xd_dat = chip->rsp_buf[1]; - xd_ctl = chip->rsp_buf[2]; - RTS51X_DEBUGP("XD_DAT: 0x%x, XD_CTL: 0x%x\n", xd_dat, xd_ctl); - - if (((xd_dat & READY_FLAG) != READY_STATE) - || !(xd_ctl & XD_RDY)) - continue; - - retval = xd_read_id(chip, READ_ID, id_buf, 4); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - RTS51X_DEBUGP("READ_ID: 0x%x 0x%x 0x%x 0x%x\n", - id_buf[0], id_buf[1], id_buf[2], id_buf[3]); - - xd_card->device_code = id_buf[1]; - - switch (xd_card->device_code) { - case XD_4M_X8_512_1: - case XD_4M_X8_512_2: - xd_card->block_shift = 4; /* 16 pages per block */ - xd_card->page_off = 0x0F; - xd_card->addr_cycle = 3; - xd_card->zone_cnt = 1; - xd_card->capacity = 8000; /* 500 * 2 ^ 4 */ - XD_SET_4MB(xd_card); - break; - case XD_8M_X8_512: - xd_card->block_shift = 4; - xd_card->page_off = 0x0F; - xd_card->addr_cycle = 3; - xd_card->zone_cnt = 1; - xd_card->capacity = 16000; /* 1000 * 2 ^ 4 */ - break; - case XD_16M_X8_512: - XD_PAGE_512(xd_card); /* 32 pages per block */ - xd_card->addr_cycle = 3; - xd_card->zone_cnt = 1; - xd_card->capacity = 32000; /* 1000 * 2 ^ 5 */ - break; - case XD_32M_X8_512: - XD_PAGE_512(xd_card); - xd_card->addr_cycle = 3; - xd_card->zone_cnt = 2; - xd_card->capacity = 64000; /* 2000 * 2 ^ 5 */ - break; - case XD_64M_X8_512: - XD_PAGE_512(xd_card); - xd_card->addr_cycle = 4; - xd_card->zone_cnt = 4; - xd_card->capacity = 128000; /* 4000 * 2 ^ 5 */ - break; - case XD_128M_X8_512: - XD_PAGE_512(xd_card); - xd_card->addr_cycle = 4; - xd_card->zone_cnt = 8; - xd_card->capacity = 256000; /* 8000 * 2 ^ 5 */ - break; - case XD_256M_X8_512: - XD_PAGE_512(xd_card); - xd_card->addr_cycle = 4; - xd_card->zone_cnt = 16; - xd_card->capacity = 512000; /* 16000 * 2 ^ 5 */ - break; - case XD_512M_X8: - XD_PAGE_512(xd_card); - xd_card->addr_cycle = 4; - xd_card->zone_cnt = 32; - xd_card->capacity = 1024000; /* 32000 * 2 ^ 5 */ - break; - case xD_1G_X8_512: - XD_PAGE_512(xd_card); - xd_card->addr_cycle = 4; - xd_card->zone_cnt = 64; - xd_card->capacity = 2048000; /* 64000 * 2 ^ 5 */ - break; - case xD_2G_X8_512: - XD_PAGE_512(xd_card); - xd_card->addr_cycle = 4; - xd_card->zone_cnt = 128; - xd_card->capacity = 4096000; /* 128000 * 2 ^ 5 */ - break; - default: - continue; - } - - /* Confirm timing setting */ - for (j = 0; j < 10; j++) { - retval = xd_read_id(chip, READ_ID, id_buf, 4); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (id_buf[1] != xd_card->device_code) - break; - } - - /* Current timing pass */ - if (j == 10) - break; - } - - if (i == 4) { - xd_card->block_shift = 0; - xd_card->page_off = 0; - xd_card->addr_cycle = 0; - xd_card->capacity = 0; - - TRACE_RET(chip, STATUS_FAIL); - } - - retval = xd_read_id(chip, READ_xD_ID, id_buf, 4); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - RTS51X_DEBUGP("READ_xD_ID: 0x%x 0x%x 0x%x 0x%x\n", - id_buf[0], id_buf[1], id_buf[2], id_buf[3]); - if (id_buf[2] != XD_ID_CODE) - TRACE_RET(chip, STATUS_FAIL); - - /* Search CIS block */ - for (i = 0; i < 24; i++) { - u32 page_addr; - - if (monitor_card_cd(chip, XD_CARD) == CD_NOT_EXIST) - TRACE_RET(chip, STATUS_FAIL); - - page_addr = (u32) i << xd_card->block_shift; - - for (j = 0; j < 3; j++) { - retval = xd_read_redundant(chip, page_addr, redunt, 11); - if (retval == STATUS_SUCCESS) - break; - } - if (j == 3) - continue; - - if (redunt[BLOCK_STATUS] != XD_GBLK) - continue; - - j = 0; - /* Check page status */ - if (redunt[PAGE_STATUS] != XD_GPG) { - for (j = 1; j <= 8; j++) { - retval = - xd_read_redundant(chip, page_addr + j, - redunt, 11); - if (retval == STATUS_SUCCESS) { - if (redunt[PAGE_STATUS] == XD_GPG) - break; - } - } - - if (j == 9) - break; - } - - if ((redunt[BLOCK_STATUS] == XD_GBLK) - && (redunt[PARITY] & XD_BA1_ALL0)) { - u8 buf[10]; - - page_addr += j; - - retval = xd_read_cis(chip, page_addr, buf, 10); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if ((buf[0] == 0x01) && (buf[1] == 0x03) - && (buf[2] == 0xD9) - && (buf[3] == 0x01) && (buf[4] == 0xFF) - && (buf[5] == 0x18) && (buf[6] == 0x02) - && (buf[7] == 0xDF) && (buf[8] == 0x01) - && (buf[9] == 0x20)) { - xd_card->cis_block = (u16) i; - } - } - - break; - } - - RTS51X_DEBUGP("CIS block: 0x%x\n", xd_card->cis_block); - if (xd_card->cis_block == 0xFFFF) - TRACE_RET(chip, STATUS_FAIL); - - chip->capacity[chip->card2lun[XD_CARD]] = xd_card->capacity; - - return STATUS_SUCCESS; -} - -static int xd_check_data_blank(u8 *redunt) -{ - int i; - - for (i = 0; i < 6; i++) { - if (redunt[PAGE_STATUS + i] != 0xFF) - return 0; - } - - if ((redunt[PARITY] & (XD_ECC1_ALL1 | XD_ECC2_ALL1)) != - (XD_ECC1_ALL1 | XD_ECC2_ALL1)) - return 0; - - for (i = 0; i < 4; i++) { - if (redunt[RESERVED0 + i] != 0xFF) - return 0; - } - - return 1; -} - -static u16 xd_load_log_block_addr(u8 *redunt) -{ - u16 addr = 0xFFFF; - - if (redunt[PARITY] & XD_BA1_BA2_EQL) - addr = - ((u16) redunt[BLOCK_ADDR1_H] << 8) | redunt[BLOCK_ADDR1_L]; - else if (redunt[PARITY] & XD_BA1_VALID) - addr = - ((u16) redunt[BLOCK_ADDR1_H] << 8) | redunt[BLOCK_ADDR1_L]; - else if (redunt[PARITY] & XD_BA2_VALID) - addr = - ((u16) redunt[BLOCK_ADDR2_H] << 8) | redunt[BLOCK_ADDR2_L]; - - return addr; -} - -static int xd_init_l2p_tbl(struct rts51x_chip *chip) -{ - struct xd_info *xd_card = &(chip->xd_card); - int size, i; - - RTS51X_DEBUGP("xd_init_l2p_tbl: zone_cnt = %d\n", xd_card->zone_cnt); - - if (xd_card->zone_cnt < 1) - TRACE_RET(chip, STATUS_FAIL); - - size = xd_card->zone_cnt * sizeof(struct zone_entry); - RTS51X_DEBUGP("Buffer size for l2p table is %d\n", size); - - xd_card->zone = vmalloc(size); - if (!xd_card->zone) - TRACE_RET(chip, STATUS_NOMEM); - - for (i = 0; i < xd_card->zone_cnt; i++) { - xd_card->zone[i].build_flag = 0; - xd_card->zone[i].l2p_table = NULL; - xd_card->zone[i].free_table = NULL; - xd_card->zone[i].get_index = 0; - xd_card->zone[i].set_index = 0; - xd_card->zone[i].unused_blk_cnt = 0; - } - - return STATUS_SUCCESS; -} - -static inline void free_zone(struct zone_entry *zone) -{ - RTS51X_DEBUGP("free_zone\n"); - if (!zone) - return; - zone->build_flag = 0; - zone->set_index = 0; - zone->get_index = 0; - zone->unused_blk_cnt = 0; - if (zone->l2p_table) { - vfree(zone->l2p_table); - zone->l2p_table = NULL; - } - if (zone->free_table) { - vfree(zone->free_table); - zone->free_table = NULL; - } -} - -static void xd_set_unused_block(struct rts51x_chip *chip, u32 phy_blk) -{ - struct xd_info *xd_card = &(chip->xd_card); - struct zone_entry *zone; - int zone_no; - - zone_no = (int)phy_blk >> 10; - if (zone_no >= xd_card->zone_cnt) { - RTS51X_DEBUGP("Set unused block to invalid zone" - "(zone_no = %d, zone_cnt = %d)\n", - zone_no, xd_card->zone_cnt); - return; - } - zone = &(xd_card->zone[zone_no]); - - if (zone->free_table == NULL) { - if (xd_build_l2p_tbl(chip, zone_no) != STATUS_SUCCESS) - return; - } - - if ((zone->set_index >= XD_FREE_TABLE_CNT) - || (zone->set_index < 0)) { - free_zone(zone); - RTS51X_DEBUGP("Set unused block fail, invalid set_index\n"); - return; - } - - RTS51X_DEBUGP("Set unused block to index %d\n", zone->set_index); - - zone->free_table[zone->set_index++] = (u16) (phy_blk & 0x3ff); - if (zone->set_index >= XD_FREE_TABLE_CNT) - zone->set_index = 0; - zone->unused_blk_cnt++; -} - -static u32 xd_get_unused_block(struct rts51x_chip *chip, int zone_no) -{ - struct xd_info *xd_card = &(chip->xd_card); - struct zone_entry *zone; - u32 phy_blk; - - if (zone_no >= xd_card->zone_cnt) { - RTS51X_DEBUGP("Get unused block from invalid zone" - "(zone_no = %d, zone_cnt = %d)\n", - zone_no, xd_card->zone_cnt); - TRACE_RET(chip, BLK_NOT_FOUND); - } - zone = &(xd_card->zone[zone_no]); - - if ((zone->unused_blk_cnt == 0) || - (zone->set_index == zone->get_index)) { - free_zone(zone); - RTS51X_DEBUGP("Get unused block fail," - "no unused block available\n"); - TRACE_RET(chip, BLK_NOT_FOUND); - } - if ((zone->get_index >= XD_FREE_TABLE_CNT) || (zone->get_index < 0)) { - free_zone(zone); - RTS51X_DEBUGP("Get unused block fail, invalid get_index\n"); - TRACE_RET(chip, BLK_NOT_FOUND); - } - - RTS51X_DEBUGP("Get unused block from index %d\n", zone->get_index); - - phy_blk = zone->free_table[zone->get_index]; - zone->free_table[zone->get_index++] = 0xFFFF; - if (zone->get_index >= XD_FREE_TABLE_CNT) - zone->get_index = 0; - zone->unused_blk_cnt--; - - phy_blk += ((u32) (zone_no) << 10); - return phy_blk; -} - -static void xd_set_l2p_tbl(struct rts51x_chip *chip, int zone_no, u16 log_off, - u16 phy_off) -{ - struct xd_info *xd_card = &(chip->xd_card); - struct zone_entry *zone; - - zone = &(xd_card->zone[zone_no]); - zone->l2p_table[log_off] = phy_off; -} - -static int xd_delay_write(struct rts51x_chip *chip); - -static u32 xd_get_l2p_tbl(struct rts51x_chip *chip, int zone_no, u16 log_off) -{ - struct xd_info *xd_card = &(chip->xd_card); - struct zone_entry *zone; - int retval; - - zone = &(xd_card->zone[zone_no]); - if (zone->l2p_table[log_off] == 0xFFFF) { - u32 phy_blk = 0; - int i; - - retval = xd_delay_write(chip); - if (retval != STATUS_SUCCESS) { - RTS51X_DEBUGP("In xd_get_l2p_tbl," - "delay write fail!\n"); - TRACE_RET(chip, BLK_NOT_FOUND); - } - - if (zone->unused_blk_cnt <= 0) { - RTS51X_DEBUGP("No unused block!\n"); - TRACE_RET(chip, BLK_NOT_FOUND); - } - - for (i = 0; i < zone->unused_blk_cnt; i++) { - phy_blk = xd_get_unused_block(chip, zone_no); - if (phy_blk == BLK_NOT_FOUND) { - RTS51X_DEBUGP("No unused block available!\n"); - TRACE_RET(chip, BLK_NOT_FOUND); - } - - retval = - xd_init_page(chip, phy_blk, log_off, 0, - xd_card->page_off + 1); - if (retval == STATUS_SUCCESS) - break; - } - if (i >= zone->unused_blk_cnt) { - RTS51X_DEBUGP("No good unused block available!\n"); - TRACE_RET(chip, BLK_NOT_FOUND); - } - - xd_set_l2p_tbl(chip, zone_no, log_off, (u16) (phy_blk & 0x3FF)); - return phy_blk; - } - - return (u32) zone->l2p_table[log_off] + ((u32) (zone_no) << 10); -} - -int rts51x_reset_xd_card(struct rts51x_chip *chip) -{ - struct xd_info *xd_card = &(chip->xd_card); - int retval; - - memset(xd_card, 0, sizeof(struct xd_info)); - - xd_card->block_shift = 0; - xd_card->page_off = 0; - xd_card->addr_cycle = 0; - xd_card->capacity = 0; - xd_card->zone_cnt = 0; - xd_card->cis_block = 0xFFFF; - xd_card->delay_write.delay_write_flag = 0; - - rts51x_enable_card_clock(chip, XD_CARD); - - retval = reset_xd(chip); - if (retval != STATUS_SUCCESS) { - if (chip->option.reset_or_rw_fail_set_pad_drive) { - rts51x_write_register(chip, CARD_DRIVE_SEL, - SD20_DRIVE_MASK, DRIVE_8mA); - } - TRACE_RET(chip, retval); - } - - retval = xd_init_l2p_tbl(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - return STATUS_SUCCESS; -} - -static int xd_mark_bad_block(struct rts51x_chip *chip, u32 phy_blk) -{ - struct xd_info *xd_card = &(chip->xd_card); - int retval; - u32 page_addr; - u8 reg = 0; - - RTS51X_DEBUGP("mark block 0x%x as bad block\n", phy_blk); - - if (phy_blk == BLK_NOT_FOUND) - TRACE_RET(chip, STATUS_FAIL); - - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_PAGE_STATUS, 0xFF, XD_GPG); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_BLOCK_STATUS, 0xFF, - XD_LATER_BBLK); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_BLOCK_ADDR1_H, 0xFF, 0xFF); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_BLOCK_ADDR1_L, 0xFF, 0xFF); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_BLOCK_ADDR2_H, 0xFF, 0xFF); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_BLOCK_ADDR2_L, 0xFF, 0xFF); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_RESERVED0, 0xFF, 0xFF); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_RESERVED1, 0xFF, 0xFF); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_RESERVED2, 0xFF, 0xFF); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_RESERVED3, 0xFF, 0xFF); - - page_addr = phy_blk << xd_card->block_shift; - - xd_assign_phy_addr(chip, page_addr, XD_RW_ADDR); - - /* Specify page count */ - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_PAGE_CNT, 0xFF, - xd_card->page_off + 1); - - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_TRANSFER, 0xFF, - XD_TRANSFER_START | XD_WRITE_REDUNDANT); - rts51x_add_cmd(chip, CHECK_REG_CMD, XD_TRANSFER, XD_TRANSFER_END, - XD_TRANSFER_END); - - retval = rts51x_send_cmd(chip, MODE_CR, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - - retval = rts51x_get_rsp(chip, 1, 100); - - if (retval != STATUS_SUCCESS) { - rts51x_clear_xd_error(chip); - rts51x_ep0_read_register(chip, XD_DAT, ®); - if (reg & PROGRAM_ERROR) - xd_set_err_code(chip, XD_PRG_ERROR); - else - xd_set_err_code(chip, XD_TO_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } - - return STATUS_SUCCESS; -} - -static int xd_init_page(struct rts51x_chip *chip, u32 phy_blk, u16 logoff, - u8 start_page, u8 end_page) -{ - struct xd_info *xd_card = &(chip->xd_card); - int retval; - u32 page_addr; - u8 reg = 0; - - RTS51X_DEBUGP("Init block 0x%x\n", phy_blk); - - if (start_page > end_page) - TRACE_RET(chip, STATUS_FAIL); - if (phy_blk == BLK_NOT_FOUND) - TRACE_RET(chip, STATUS_FAIL); - - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_PAGE_STATUS, 0xFF, 0xFF); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_BLOCK_STATUS, 0xFF, 0xFF); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_BLOCK_ADDR1_H, 0xFF, - (u8) (logoff >> 8)); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_BLOCK_ADDR1_L, 0xFF, - (u8) logoff); - - page_addr = (phy_blk << xd_card->block_shift) + start_page; - - xd_assign_phy_addr(chip, page_addr, XD_RW_ADDR); - - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CFG, XD_BA_TRANSFORM, - XD_BA_TRANSFORM); - - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_PAGE_CNT, 0xFF, - (end_page - start_page)); - - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_TRANSFER, 0xFF, - XD_TRANSFER_START | XD_WRITE_REDUNDANT); - rts51x_add_cmd(chip, CHECK_REG_CMD, XD_TRANSFER, XD_TRANSFER_END, - XD_TRANSFER_END); - - retval = rts51x_send_cmd(chip, MODE_CR, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, STATUS_FAIL); - - retval = rts51x_get_rsp(chip, 1, 500); - - if (retval != STATUS_SUCCESS) { - rts51x_clear_xd_error(chip); - rts51x_ep0_read_register(chip, XD_DAT, ®); - if (reg & PROGRAM_ERROR) { - xd_mark_bad_block(chip, phy_blk); - xd_set_err_code(chip, XD_PRG_ERROR); - } else { - xd_set_err_code(chip, XD_TO_ERROR); - } - TRACE_RET(chip, STATUS_FAIL); - } - - return STATUS_SUCCESS; -} - -static int xd_copy_page(struct rts51x_chip *chip, - u32 old_blk, u32 new_blk, u8 start_page, u8 end_page) -{ - struct xd_info *xd_card = &(chip->xd_card); - u32 old_page, new_page; - u8 i, reg = 0; - int retval; - - RTS51X_DEBUGP("Copy page from block 0x%x to block 0x%x\n", old_blk, - new_blk); - - if (start_page > end_page) - TRACE_RET(chip, STATUS_FAIL); - - if ((old_blk == BLK_NOT_FOUND) || (new_blk == BLK_NOT_FOUND)) - TRACE_RET(chip, STATUS_FAIL); - - old_page = (old_blk << xd_card->block_shift) + start_page; - new_page = (new_blk << xd_card->block_shift) + start_page; - - XD_CLR_BAD_NEWBLK(xd_card); - - RTS51X_WRITE_REG(chip, CARD_DATA_SOURCE, 0x01, PINGPONG_BUFFER); - - for (i = start_page; i < end_page; i++) { - if (monitor_card_cd(chip, XD_CARD) == CD_NOT_EXIST) { - RTS51X_WRITE_REG(chip, CARD_STOP, XD_STOP | XD_CLR_ERR, - XD_STOP | XD_CLR_ERR); - xd_set_err_code(chip, XD_NO_CARD); - TRACE_RET(chip, STATUS_FAIL); - } - - rts51x_init_cmd(chip); - - xd_assign_phy_addr(chip, old_page, XD_RW_ADDR); - - /* Single page read */ - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_PAGE_CNT, 0xFF, 1); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CHK_DATA_STATUS, - XD_AUTO_CHK_DATA_STATUS, 0); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_TRANSFER, 0xFF, - XD_TRANSFER_START | XD_READ_PAGES); - rts51x_add_cmd(chip, CHECK_REG_CMD, XD_TRANSFER, - XD_TRANSFER_END, XD_TRANSFER_END); - - retval = rts51x_send_cmd(chip, MODE_CR | STAGE_XD_STATUS, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = rts51x_get_rsp(chip, 4, 500); - if ((retval != STATUS_SUCCESS) || - (chip->rsp_buf[2] & (XD_ECC1_ERROR | XD_ECC2_ERROR))) { - rts51x_clear_xd_error(chip); - reg = 0; - rts51x_ep0_read_register(chip, XD_CTL, ®); - if (reg & (XD_ECC1_ERROR | XD_ECC2_ERROR)) { - wait_timeout(100); - - if (monitor_card_cd(chip, XD_CARD) == - CD_NOT_EXIST) { - xd_set_err_code(chip, XD_NO_CARD); - TRACE_RET(chip, STATUS_FAIL); - } - - if (((reg & - (XD_ECC1_ERROR | XD_ECC1_UNCORRECTABLE)) - == (XD_ECC1_ERROR | XD_ECC1_UNCORRECTABLE)) - || ((reg & (XD_ECC2_ERROR | - XD_ECC2_UNCORRECTABLE)) == - (XD_ECC2_ERROR | XD_ECC2_UNCORRECTABLE))) { - RTS51X_WRITE_REG(chip, XD_PAGE_STATUS, - 0xFF, XD_BPG); - RTS51X_WRITE_REG(chip, XD_BLOCK_STATUS, - 0xFF, XD_GBLK); - XD_SET_BAD_OLDBLK(xd_card); - RTS51X_DEBUGP("old block 0x%x" - "ecc error\n", old_blk); - } - } else { - xd_set_err_code(chip, XD_TO_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } - } - if (XD_CHK_BAD_OLDBLK(xd_card)) - rts51x_clear_xd_error(chip); - - rts51x_init_cmd(chip); - - xd_assign_phy_addr(chip, new_page, XD_RW_ADDR); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_PAGE_CNT, 0xFF, 1); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_TRANSFER, 0xFF, - XD_TRANSFER_START | XD_WRITE_PAGES); - rts51x_add_cmd(chip, CHECK_REG_CMD, XD_TRANSFER, - XD_TRANSFER_END, XD_TRANSFER_END); - - retval = rts51x_send_cmd(chip, MODE_CR, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = rts51x_get_rsp(chip, 1, 300); - if (retval != STATUS_SUCCESS) { - rts51x_clear_xd_error(chip); - reg = 0; - rts51x_ep0_read_register(chip, XD_DAT, ®); - if (reg & PROGRAM_ERROR) { - xd_mark_bad_block(chip, new_blk); - xd_set_err_code(chip, XD_PRG_ERROR); - XD_SET_BAD_NEWBLK(xd_card); - } else { - xd_set_err_code(chip, XD_TO_ERROR); - } - TRACE_RET(chip, retval); - } - - old_page++; - new_page++; - } - - return STATUS_SUCCESS; -} - -static int xd_reset_cmd(struct rts51x_chip *chip) -{ - int retval; - u8 xd_dat, xd_ctl; - - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_TRANSFER, 0xFF, - XD_TRANSFER_START | XD_RESET); - rts51x_add_cmd(chip, CHECK_REG_CMD, XD_TRANSFER, XD_TRANSFER_END, - XD_TRANSFER_END); - rts51x_add_cmd(chip, READ_REG_CMD, XD_DAT, 0, 0); - rts51x_add_cmd(chip, READ_REG_CMD, XD_CTL, 0, 0); - - retval = rts51x_send_cmd(chip, MODE_CR, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = rts51x_get_rsp(chip, 3, 100); - if (retval != STATUS_SUCCESS) { - rts51x_clear_xd_error(chip); - TRACE_RET(chip, retval); - } - - xd_dat = chip->rsp_buf[1]; - xd_ctl = chip->rsp_buf[2]; - if (((xd_dat & READY_FLAG) == READY_STATE) && (xd_ctl & XD_RDY)) - return STATUS_SUCCESS; - - TRACE_RET(chip, STATUS_FAIL); -} - -static int xd_erase_block(struct rts51x_chip *chip, u32 phy_blk) -{ - struct xd_info *xd_card = &(chip->xd_card); - u32 page_addr; - u8 reg = 0, xd_dat; - int i, retval; - - if (phy_blk == BLK_NOT_FOUND) - TRACE_RET(chip, STATUS_FAIL); - - page_addr = phy_blk << xd_card->block_shift; - - for (i = 0; i < 3; i++) { - rts51x_init_cmd(chip); - - xd_assign_phy_addr(chip, page_addr, XD_ERASE_ADDR); - - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_TRANSFER, 0xFF, - XD_TRANSFER_START | XD_ERASE); - rts51x_add_cmd(chip, CHECK_REG_CMD, XD_TRANSFER, - XD_TRANSFER_END, XD_TRANSFER_END); - rts51x_add_cmd(chip, READ_REG_CMD, XD_DAT, 0, 0); - - retval = rts51x_send_cmd(chip, MODE_CR, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = rts51x_get_rsp(chip, 2, 300); - if (retval != STATUS_SUCCESS) { - rts51x_clear_xd_error(chip); - rts51x_ep0_read_register(chip, XD_DAT, ®); - if (reg & PROGRAM_ERROR) { - xd_mark_bad_block(chip, phy_blk); - xd_set_err_code(chip, XD_PRG_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } else { - xd_set_err_code(chip, XD_ERASE_FAIL); - } - retval = xd_reset_cmd(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - continue; - } - xd_dat = chip->rsp_buf[1]; - if (xd_dat & PROGRAM_ERROR) { - xd_mark_bad_block(chip, phy_blk); - xd_set_err_code(chip, XD_PRG_ERROR); - TRACE_RET(chip, STATUS_FAIL); - } - - return STATUS_SUCCESS; - } - - xd_mark_bad_block(chip, phy_blk); - xd_set_err_code(chip, XD_ERASE_FAIL); - TRACE_RET(chip, STATUS_FAIL); -} - -static int xd_build_l2p_tbl(struct rts51x_chip *chip, int zone_no) -{ - struct xd_info *xd_card = &(chip->xd_card); - struct zone_entry *zone; - int retval; - u32 start, end, i; - u16 max_logoff, cur_fst_page_logoff, cur_lst_page_logoff, - ent_lst_page_logoff; - u8 redunt[11]; - - RTS51X_DEBUGP("xd_build_l2p_tbl: %d\n", zone_no); - - if (xd_card->zone == NULL) { - retval = xd_init_l2p_tbl(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - - if (xd_card->zone[zone_no].build_flag) { - RTS51X_DEBUGP("l2p table of zone %d has been built\n", - zone_no); - return STATUS_SUCCESS; - } - - zone = &(xd_card->zone[zone_no]); - - if (zone->l2p_table == NULL) { - zone->l2p_table = vmalloc(2000); - if (zone->l2p_table == NULL) - TRACE_GOTO(chip, Build_Fail); - } - memset((u8 *) (zone->l2p_table), 0xff, 2000); - - if (zone->free_table == NULL) { - zone->free_table = vmalloc(XD_FREE_TABLE_CNT * 2); - if (zone->free_table == NULL) - TRACE_GOTO(chip, Build_Fail); - } - memset((u8 *) (zone->free_table), 0xff, XD_FREE_TABLE_CNT * 2); - - if (zone_no == 0) { - if (xd_card->cis_block == 0xFFFF) - start = 0; - else - start = xd_card->cis_block + 1; - if (XD_CHK_4MB(xd_card)) { - end = 0x200; - max_logoff = 499; - } else { - end = 0x400; - max_logoff = 999; - } - } else { - start = (u32) (zone_no) << 10; - end = (u32) (zone_no + 1) << 10; - max_logoff = 999; - } - - RTS51X_DEBUGP("start block 0x%x, end block 0x%x\n", start, end); - - zone->set_index = zone->get_index = 0; - zone->unused_blk_cnt = 0; - - for (i = start; i < end; i++) { - u32 page_addr = i << xd_card->block_shift; - u32 phy_block; - - retval = xd_read_redundant(chip, page_addr, redunt, 11); - if (retval != STATUS_SUCCESS) - continue; - - if (redunt[BLOCK_STATUS] != 0xFF) { - RTS51X_DEBUGP("bad block\n"); - continue; - } - - if (xd_check_data_blank(redunt)) { - RTS51X_DEBUGP("blank block\n"); - xd_set_unused_block(chip, i); - continue; - } - - cur_fst_page_logoff = xd_load_log_block_addr(redunt); - if ((cur_fst_page_logoff == 0xFFFF) - || (cur_fst_page_logoff > max_logoff)) { - retval = xd_erase_block(chip, i); - if (retval == STATUS_SUCCESS) - xd_set_unused_block(chip, i); - continue; - } - if ((zone_no == 0) && (cur_fst_page_logoff == 0) - && (redunt[PAGE_STATUS] != XD_GPG)) - XD_SET_MBR_FAIL(xd_card); - - if (zone->l2p_table[cur_fst_page_logoff] == 0xFFFF) { - zone->l2p_table[cur_fst_page_logoff] = - (u16) (i & 0x3FF); - continue; - } - - phy_block = - zone->l2p_table[cur_fst_page_logoff] + - ((u32) ((zone_no) << 10)); - - page_addr = ((i + 1) << xd_card->block_shift) - 1; - - retval = xd_read_redundant(chip, page_addr, redunt, 11); - if (retval != STATUS_SUCCESS) - continue; - - cur_lst_page_logoff = xd_load_log_block_addr(redunt); - if (cur_lst_page_logoff == cur_fst_page_logoff) { - int m; - - page_addr = - ((phy_block + 1) << xd_card->block_shift) - 1; - - for (m = 0; m < 3; m++) { - retval = - xd_read_redundant(chip, page_addr, redunt, - 11); - if (retval == STATUS_SUCCESS) - break; - } - - if (m == 3) { - zone->l2p_table[cur_fst_page_logoff] = - (u16) (i & 0x3FF); - retval = xd_erase_block(chip, phy_block); - if (retval == STATUS_SUCCESS) - xd_set_unused_block(chip, phy_block); - continue; - } - - ent_lst_page_logoff = xd_load_log_block_addr(redunt); - if (ent_lst_page_logoff != cur_fst_page_logoff) { - zone->l2p_table[cur_fst_page_logoff] = - (u16) (i & 0x3FF); - retval = xd_erase_block(chip, phy_block); - if (retval == STATUS_SUCCESS) - xd_set_unused_block(chip, phy_block); - continue; - } else { - retval = xd_erase_block(chip, i); - if (retval == STATUS_SUCCESS) - xd_set_unused_block(chip, i); - } - } else { - retval = xd_erase_block(chip, i); - if (retval == STATUS_SUCCESS) - xd_set_unused_block(chip, i); - } - } - - if (XD_CHK_4MB(xd_card)) - end = 500; - else - end = 1000; - - i = 0; - for (start = 0; start < end; start++) { - if (zone->l2p_table[start] == 0xFFFF) - i++; - } - - RTS51X_DEBUGP("Block count %d, invalid L2P entry %d\n", end, i); - RTS51X_DEBUGP("Total unused block: %d\n", zone->unused_blk_cnt); - - if ((zone->unused_blk_cnt - i) < 1) - chip->card_wp |= XD_CARD; - - zone->build_flag = 1; - - return STATUS_SUCCESS; - -Build_Fail: - if (zone->l2p_table) { - vfree(zone->l2p_table); - zone->l2p_table = NULL; - } - if (zone->free_table) { - vfree(zone->free_table); - zone->free_table = NULL; - } - - return STATUS_FAIL; -} - -static int xd_send_cmd(struct rts51x_chip *chip, u8 cmd) -{ - int retval; - - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_DAT, 0xFF, cmd); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_TRANSFER, 0xFF, - XD_TRANSFER_START | XD_SET_CMD); - rts51x_add_cmd(chip, CHECK_REG_CMD, XD_TRANSFER, XD_TRANSFER_END, - XD_TRANSFER_END); - - retval = rts51x_send_cmd(chip, MODE_CR, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = rts51x_get_rsp(chip, 1, 200); - if (retval != STATUS_SUCCESS) { - rts51x_clear_xd_error(chip); - TRACE_RET(chip, retval); - } - - return STATUS_SUCCESS; -} - -static int xd_read_multiple_pages(struct rts51x_chip *chip, u32 phy_blk, - u32 log_blk, u8 start_page, u8 end_page, - u8 *buf, void **ptr, unsigned int *offset) -{ - struct xd_info *xd_card = &(chip->xd_card); - u32 page_addr, new_blk; - u16 log_off; - u8 reg_val, page_cnt; - int zone_no, retval, i; - - if (start_page > end_page) - TRACE_RET(chip, STATUS_FAIL); - - page_cnt = end_page - start_page; - zone_no = (int)(log_blk / 1000); - log_off = (u16) (log_blk % 1000); - - if ((phy_blk & 0x3FF) == 0x3FF) { - for (i = 0; i < 256; i++) { - page_addr = ((u32) i) << xd_card->block_shift; - - retval = xd_read_redundant(chip, page_addr, NULL, 0); - if (retval == STATUS_SUCCESS) - break; - - if (monitor_card_cd(chip, XD_CARD) == CD_NOT_EXIST) { - xd_set_err_code(chip, XD_NO_CARD); - TRACE_RET(chip, STATUS_FAIL); - } - } - } - - page_addr = (phy_blk << xd_card->block_shift) + start_page; - - rts51x_init_cmd(chip); - - xd_assign_phy_addr(chip, page_addr, XD_RW_ADDR); - - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CFG, XD_PPB_TO_SIE, - XD_PPB_TO_SIE); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, - RING_BUFFER); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_PAGE_CNT, 0xFF, page_cnt); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CHK_DATA_STATUS, - XD_AUTO_CHK_DATA_STATUS, XD_AUTO_CHK_DATA_STATUS); - - rts51x_trans_dma_enable(chip->srb->sc_data_direction, chip, - page_cnt * 512, DMA_512); - - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_TRANSFER, 0xFF, - XD_TRANSFER_START | XD_READ_PAGES); - rts51x_add_cmd(chip, CHECK_REG_CMD, XD_TRANSFER, - XD_TRANSFER_END | XD_PPB_EMPTY, - XD_TRANSFER_END | XD_PPB_EMPTY); - - retval = rts51x_send_cmd(chip, MODE_CDIR, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = - rts51x_transfer_data_partial(chip, RCV_BULK_PIPE(chip), (void *)buf, - ptr, offset, page_cnt * 512, - scsi_sg_count(chip->srb), NULL, 2000); - if (retval != STATUS_SUCCESS) { - rts51x_clear_xd_error(chip); - - if (retval == STATUS_TIMEDOUT) { - xd_set_err_code(chip, XD_TO_ERROR); - TRACE_RET(chip, retval); - } else { - TRACE_GOTO(chip, Fail); - } - } - retval = rts51x_get_rsp(chip, 1, 200); - if (retval != STATUS_SUCCESS) { - rts51x_clear_xd_error(chip); - - if (retval == STATUS_TIMEDOUT) { - xd_set_err_code(chip, XD_TO_ERROR); - TRACE_RET(chip, retval); - } else { - TRACE_GOTO(chip, Fail); - } - } - - return STATUS_SUCCESS; - -Fail: - rts51x_ep0_read_register(chip, XD_PAGE_STATUS, ®_val); - RTS51X_DEBUGP("XD_PAGE_STATUS: 0x%x\n", reg_val); - - if (reg_val != XD_GPG) - xd_set_err_code(chip, XD_PRG_ERROR); - - rts51x_ep0_read_register(chip, XD_CTL, ®_val); - RTS51X_DEBUGP("XD_CTL: 0x%x\n", reg_val); - - /* Handle uncorrectable ECC error */ - if (((reg_val & (XD_ECC1_ERROR | XD_ECC1_UNCORRECTABLE)) - == (XD_ECC1_ERROR | XD_ECC1_UNCORRECTABLE)) - || ((reg_val & (XD_ECC2_ERROR | XD_ECC2_UNCORRECTABLE)) - == (XD_ECC2_ERROR | XD_ECC2_UNCORRECTABLE))) { - wait_timeout(100); - - if (monitor_card_cd(chip, XD_CARD) == CD_NOT_EXIST) { - xd_set_err_code(chip, XD_NO_CARD); - TRACE_RET(chip, STATUS_FAIL); - } - - xd_set_err_code(chip, XD_ECC_ERROR); - - new_blk = xd_get_unused_block(chip, zone_no); - if (new_blk == NO_NEW_BLK) { - XD_CLR_BAD_OLDBLK(xd_card); - TRACE_RET(chip, STATUS_FAIL); - } - retval = - xd_copy_page(chip, phy_blk, new_blk, 0, - xd_card->page_off + 1); - if (retval != STATUS_SUCCESS) { - if (!XD_CHK_BAD_NEWBLK(xd_card)) { - retval = xd_erase_block(chip, new_blk); - if (retval == STATUS_SUCCESS) - xd_set_unused_block(chip, new_blk); - } else { - XD_CLR_BAD_NEWBLK(xd_card); - } - XD_CLR_BAD_OLDBLK(xd_card); - TRACE_RET(chip, STATUS_FAIL); - } - xd_set_l2p_tbl(chip, zone_no, log_off, (u16) (new_blk & 0x3FF)); - xd_erase_block(chip, phy_blk); - xd_mark_bad_block(chip, phy_blk); - XD_CLR_BAD_OLDBLK(xd_card); - } - - TRACE_RET(chip, STATUS_FAIL); -} - -static int xd_finish_write(struct rts51x_chip *chip, - u32 old_blk, u32 new_blk, u32 log_blk, u8 page_off) -{ - struct xd_info *xd_card = &(chip->xd_card); - int retval, zone_no; - u16 log_off; - - RTS51X_DEBUGP("xd_finish_write, old_blk = 0x%x, new_blk = 0x%x," - "log_blk = 0x%x\n", old_blk, new_blk, log_blk); - - if (page_off > xd_card->page_off) - TRACE_RET(chip, STATUS_FAIL); - - zone_no = (int)(log_blk / 1000); - log_off = (u16) (log_blk % 1000); - - if (old_blk == BLK_NOT_FOUND) { - retval = xd_init_page(chip, new_blk, log_off, - page_off, xd_card->page_off + 1); - if (retval != STATUS_SUCCESS) { - retval = xd_erase_block(chip, new_blk); - if (retval == STATUS_SUCCESS) - xd_set_unused_block(chip, new_blk); - TRACE_RET(chip, STATUS_FAIL); - } - } else { - retval = xd_copy_page(chip, old_blk, new_blk, - page_off, xd_card->page_off + 1); - if (retval != STATUS_SUCCESS) { - if (!XD_CHK_BAD_NEWBLK(xd_card)) { - retval = xd_erase_block(chip, new_blk); - if (retval == STATUS_SUCCESS) - xd_set_unused_block(chip, new_blk); - } - XD_CLR_BAD_NEWBLK(xd_card); - TRACE_RET(chip, STATUS_FAIL); - } - - retval = xd_erase_block(chip, old_blk); - if (retval == STATUS_SUCCESS) { - if (XD_CHK_BAD_OLDBLK(xd_card)) { - xd_mark_bad_block(chip, old_blk); - XD_CLR_BAD_OLDBLK(xd_card); - } else { - /* Add source block to unused block */ - xd_set_unused_block(chip, old_blk); - } - } else { - xd_set_err_code(chip, XD_NO_ERROR); - XD_CLR_BAD_OLDBLK(xd_card); - } - } - - /* Add target block to L2P table */ - xd_set_l2p_tbl(chip, zone_no, log_off, (u16) (new_blk & 0x3FF)); - - return STATUS_SUCCESS; -} - -static int xd_prepare_write(struct rts51x_chip *chip, - u32 old_blk, u32 new_blk, u32 log_blk, u8 page_off) -{ - int retval; - - RTS51X_DEBUGP("xd_prepare_write, old_blk = 0x%x, new_blk = 0x%x," - "log_blk = 0x%x, page_off = %d\n", - old_blk, new_blk, log_blk, (int)page_off); - - if (page_off) { - retval = xd_copy_page(chip, old_blk, new_blk, 0, page_off); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - - return STATUS_SUCCESS; -} - -static int xd_write_multiple_pages(struct rts51x_chip *chip, u32 old_blk, - u32 new_blk, u32 log_blk, u8 start_page, - u8 end_page, u8 *buf, void **ptr, - unsigned int *offset) -{ - struct xd_info *xd_card = &(chip->xd_card); - u32 page_addr; - int zone_no, retval; - u16 log_off; - u8 page_cnt, reg_val; - - RTS51X_DEBUGP("xd_write_multiple_pages, old_blk = 0x%x," - "new_blk = 0x%x, log_blk = 0x%x\n", - old_blk, new_blk, log_blk); - - if (start_page > end_page) - TRACE_RET(chip, STATUS_FAIL); - - page_cnt = end_page - start_page; - zone_no = (int)(log_blk / 1000); - log_off = (u16) (log_blk % 1000); - - page_addr = (new_blk << xd_card->block_shift) + start_page; - - /* Send index command */ - retval = xd_send_cmd(chip, READ1_1); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - rts51x_init_cmd(chip); - - /* Prepare redundant field */ - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_BLOCK_ADDR1_H, 0xFF, - (u8) (log_off >> 8)); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_BLOCK_ADDR1_L, 0xFF, - (u8) log_off); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_BLOCK_STATUS, 0xFF, XD_GBLK); - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_PAGE_STATUS, 0xFF, XD_GPG); - - xd_assign_phy_addr(chip, page_addr, XD_RW_ADDR); - - /* Transform the block address by hardware */ - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CFG, XD_BA_TRANSFORM, - XD_BA_TRANSFORM); - - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_PAGE_CNT, 0xFF, page_cnt); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, - RING_BUFFER); - - rts51x_trans_dma_enable(chip->srb->sc_data_direction, chip, - page_cnt * 512, DMA_512); - - rts51x_add_cmd(chip, WRITE_REG_CMD, XD_TRANSFER, 0xFF, - XD_TRANSFER_START | XD_WRITE_PAGES); - rts51x_add_cmd(chip, CHECK_REG_CMD, XD_TRANSFER, XD_TRANSFER_END, - XD_TRANSFER_END); - - retval = rts51x_send_cmd(chip, MODE_CDOR, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - retval = - rts51x_transfer_data_partial(chip, SND_BULK_PIPE(chip), (void *)buf, - ptr, offset, page_cnt * 512, - scsi_sg_count(chip->srb), NULL, 2000); - if (retval != STATUS_SUCCESS) { - rts51x_clear_xd_error(chip); - - if (retval == STATUS_TIMEDOUT) { - xd_set_err_code(chip, XD_TO_ERROR); - TRACE_RET(chip, retval); - } else { - TRACE_GOTO(chip, Fail); - } - } - retval = rts51x_get_rsp(chip, 1, 200); - if (retval != STATUS_SUCCESS) { - rts51x_clear_xd_error(chip); - - if (retval == STATUS_TIMEDOUT) { - xd_set_err_code(chip, XD_TO_ERROR); - TRACE_RET(chip, retval); - } else { - TRACE_GOTO(chip, Fail); - } - } - - if (end_page == (xd_card->page_off + 1)) { - xd_card->delay_write.delay_write_flag = 0; - - if (old_blk != BLK_NOT_FOUND) { - retval = xd_erase_block(chip, old_blk); - if (retval == STATUS_SUCCESS) { - if (XD_CHK_BAD_OLDBLK(xd_card)) { - xd_mark_bad_block(chip, old_blk); - XD_CLR_BAD_OLDBLK(xd_card); - } else { - xd_set_unused_block(chip, old_blk); - } - } else { - xd_set_err_code(chip, XD_NO_ERROR); - XD_CLR_BAD_OLDBLK(xd_card); - } - } - xd_set_l2p_tbl(chip, zone_no, log_off, (u16) (new_blk & 0x3FF)); - } - - return STATUS_SUCCESS; - -Fail: - rts51x_ep0_read_register(chip, XD_DAT, ®_val); - RTS51X_DEBUGP("XD_DAT: 0x%x\n", reg_val); - - if (reg_val & PROGRAM_ERROR) { - xd_set_err_code(chip, XD_PRG_ERROR); - xd_mark_bad_block(chip, new_blk); - } - - TRACE_RET(chip, STATUS_FAIL); -} - -static int xd_delay_write(struct rts51x_chip *chip) -{ - struct xd_info *xd_card = &(chip->xd_card); - struct xd_delay_write_tag *delay_write = &(xd_card->delay_write); - int retval; - - if (delay_write->delay_write_flag) { - RTS51X_DEBUGP("xd_delay_write\n"); - retval = xd_switch_clock(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - delay_write->delay_write_flag = 0; - retval = xd_finish_write(chip, - delay_write->old_phyblock, - delay_write->new_phyblock, - delay_write->logblock, - delay_write->pageoff); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - } - - return STATUS_SUCCESS; -} - -int rts51x_xd_rw(struct scsi_cmnd *srb, struct rts51x_chip *chip, - u32 start_sector, u16 sector_cnt) -{ - struct xd_info *xd_card = &(chip->xd_card); - unsigned int lun = SCSI_LUN(srb); - struct xd_delay_write_tag *delay_write = &(xd_card->delay_write); - int retval, zone_no; - u32 log_blk, old_blk = 0, new_blk = 0; - u16 log_off, total_sec_cnt = sector_cnt; - u8 start_page, end_page = 0, page_cnt; - u8 *buf; - void *ptr = NULL; - unsigned int offset = 0; - - xd_set_err_code(chip, XD_NO_ERROR); - - xd_card->counter = 0; - - RTS51X_DEBUGP("rts51x_xd_rw: scsi_bufflen = %d, scsi_sg_count = %d\n", - scsi_bufflen(srb), scsi_sg_count(srb)); - RTS51X_DEBUGP("Data direction: %s\n", - (srb->sc_data_direction == - DMA_TO_DEVICE) ? "write" : "read"); - - buf = (u8 *) scsi_sglist(srb); - - retval = xd_switch_clock(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - log_blk = start_sector >> xd_card->block_shift; - start_page = (u8) start_sector & xd_card->page_off; - zone_no = (int)(log_blk / 1000); - log_off = (u16) (log_blk % 1000); - - RTS51X_DEBUGP("log_blk = 0x%x\n", log_blk); - - if (xd_card->zone[zone_no].build_flag == 0) { - retval = xd_build_l2p_tbl(chip, zone_no); - if (retval != STATUS_SUCCESS) { - chip->card_fail |= XD_CARD; - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_NOT_PRESENT); - TRACE_RET(chip, retval); - } - } - - if (srb->sc_data_direction == DMA_TO_DEVICE) { - if (delay_write->delay_write_flag && - (delay_write->logblock == log_blk) && - (start_page > delay_write->pageoff)) { - delay_write->delay_write_flag = 0; - if (delay_write->old_phyblock != BLK_NOT_FOUND) { - retval = xd_copy_page(chip, - delay_write->old_phyblock, - delay_write->new_phyblock, - delay_write->pageoff, - start_page); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_WRITE_ERR); - TRACE_RET(chip, retval); - } - } - old_blk = delay_write->old_phyblock; - new_blk = delay_write->new_phyblock; - } else if (delay_write->delay_write_flag && - (delay_write->logblock == log_blk) && - (start_page == delay_write->pageoff)) { - delay_write->delay_write_flag = 0; - old_blk = delay_write->old_phyblock; - new_blk = delay_write->new_phyblock; - } else { - retval = xd_delay_write(chip); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_WRITE_ERR); - TRACE_RET(chip, retval); - } - old_blk = xd_get_l2p_tbl(chip, zone_no, log_off); - new_blk = xd_get_unused_block(chip, zone_no); - if ((old_blk == BLK_NOT_FOUND) - || (new_blk == BLK_NOT_FOUND)) { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_WRITE_ERR); - TRACE_RET(chip, retval); - } - - retval = - xd_prepare_write(chip, old_blk, new_blk, log_blk, - start_page); - if (retval != STATUS_SUCCESS) { - if (monitor_card_cd(chip, XD_CARD) == - CD_NOT_EXIST) { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_NOT_PRESENT); - TRACE_RET(chip, STATUS_FAIL); - } - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_WRITE_ERR); - TRACE_RET(chip, retval); - } - } - } else { - retval = xd_delay_write(chip); - if (retval != STATUS_SUCCESS) { - if (monitor_card_cd(chip, XD_CARD) == CD_NOT_EXIST) { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_NOT_PRESENT); - TRACE_RET(chip, STATUS_FAIL); - } - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - TRACE_RET(chip, retval); - } - - old_blk = xd_get_l2p_tbl(chip, zone_no, log_off); - if (old_blk == BLK_NOT_FOUND) { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - TRACE_RET(chip, STATUS_FAIL); - } - } - - RTS51X_DEBUGP("old_blk = 0x%x\n", old_blk); - if (srb->sc_data_direction == DMA_TO_DEVICE) - RTS51X_DEBUGP("new_blk = 0x%x\n", new_blk); - - while (total_sec_cnt) { - if ((start_page + total_sec_cnt) > (xd_card->page_off + 1)) - end_page = xd_card->page_off + 1; - else - end_page = start_page + (u8) total_sec_cnt; - page_cnt = end_page - start_page; - if (srb->sc_data_direction == DMA_FROM_DEVICE) { - retval = xd_read_multiple_pages(chip, old_blk, log_blk, - start_page, end_page, - buf, &ptr, &offset); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - TRACE_RET(chip, STATUS_FAIL); - } - } else { - retval = - xd_write_multiple_pages(chip, old_blk, new_blk, - log_blk, start_page, - end_page, buf, &ptr, - &offset); - if (retval != STATUS_SUCCESS) { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_WRITE_ERR); - TRACE_RET(chip, STATUS_FAIL); - } - } - - total_sec_cnt -= page_cnt; - - if (total_sec_cnt == 0) - break; - - log_blk++; - zone_no = (int)(log_blk / 1000); - log_off = (u16) (log_blk % 1000); - - if (xd_card->zone[zone_no].build_flag == 0) { - retval = xd_build_l2p_tbl(chip, zone_no); - if (retval != STATUS_SUCCESS) { - chip->card_fail |= XD_CARD; - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_NOT_PRESENT); - TRACE_RET(chip, retval); - } - } - - old_blk = xd_get_l2p_tbl(chip, zone_no, log_off); - if (old_blk == BLK_NOT_FOUND) { - if (srb->sc_data_direction == DMA_FROM_DEVICE) { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR); - } else { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_WRITE_ERR); - } - TRACE_RET(chip, STATUS_FAIL); - } - - if (srb->sc_data_direction == DMA_TO_DEVICE) { - new_blk = xd_get_unused_block(chip, zone_no); - if (new_blk == BLK_NOT_FOUND) { - rts51x_set_sense_type(chip, lun, - SENSE_TYPE_MEDIA_WRITE_ERR); - TRACE_RET(chip, STATUS_FAIL); - } - } - - start_page = 0; - } - - if ((srb->sc_data_direction == DMA_TO_DEVICE) && - (end_page != (xd_card->page_off + 1))) { - delay_write->delay_write_flag = 1; - delay_write->old_phyblock = old_blk; - delay_write->new_phyblock = new_blk; - delay_write->logblock = log_blk; - delay_write->pageoff = end_page; - } - - scsi_set_resid(srb, 0); - - return STATUS_SUCCESS; -} - -void rts51x_xd_free_l2p_tbl(struct rts51x_chip *chip) -{ - struct xd_info *xd_card = &(chip->xd_card); - int i = 0; - - if (xd_card->zone != NULL) { - for (i = 0; i < xd_card->zone_cnt; i++) { - if (xd_card->zone[i].l2p_table != NULL) { - vfree(xd_card->zone[i].l2p_table); - xd_card->zone[i].l2p_table = NULL; - } - if (xd_card->zone[i].free_table != NULL) { - vfree(xd_card->zone[i].free_table); - xd_card->zone[i].free_table = NULL; - } - } - vfree(xd_card->zone); - xd_card->zone = NULL; - } -} - -void rts51x_xd_cleanup_work(struct rts51x_chip *chip) -{ - struct xd_info *xd_card = &(chip->xd_card); - - if (xd_card->delay_write.delay_write_flag) { - RTS51X_DEBUGP("xD: delay write\n"); - xd_delay_write(chip); - xd_card->counter = 0; - } -} - -static int xd_power_off_card3v3(struct rts51x_chip *chip) -{ - int retval; - - rts51x_init_cmd(chip); - - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_CLK_EN, XD_CLK_EN, 0); - - if (chip->asic_code) - xd_pull_ctl_disable(chip); - else - rts51x_add_cmd(chip, WRITE_REG_CMD, FPGA_PULL_CTL, 0xFF, 0xDF); - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_OE, XD_OUTPUT_EN, 0); - if (!chip->option.FT2_fast_mode) { - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, POWER_MASK, - POWER_OFF); - if (CHECK_PKG(chip, LQFP48) - || chip->option.rts5129_D3318_off_enable) - rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, - DV3318_AUTO_PWR_OFF, 0); - } - - retval = rts51x_send_cmd(chip, MODE_C, 100); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - return STATUS_SUCCESS; -} - -int rts51x_release_xd_card(struct rts51x_chip *chip) -{ - struct xd_info *xd_card = &(chip->xd_card); - int retval; - - RTS51X_DEBUGP("rts51x_release_xd_card\n"); - - chip->card_ready &= ~XD_CARD; - chip->card_fail &= ~XD_CARD; - chip->card_wp &= ~XD_CARD; - - xd_card->delay_write.delay_write_flag = 0; - - rts51x_xd_free_l2p_tbl(chip); - - rts51x_write_register(chip, SFSM_ED, HW_CMD_STOP, HW_CMD_STOP); - - retval = xd_power_off_card3v3(chip); - if (retval != STATUS_SUCCESS) - TRACE_RET(chip, retval); - - if (chip->asic_code && CHECK_PKG(chip, QFN24)) - wait_timeout(20); - - return STATUS_SUCCESS; -} diff --git a/drivers/staging/rts5139/xd.h b/drivers/staging/rts5139/xd.h deleted file mode 100644 index 695a0b4d7e52..000000000000 --- a/drivers/staging/rts5139/xd.h +++ /dev/null @@ -1,191 +0,0 @@ -/* Driver for Realtek RTS51xx USB card reader - * Header file - * - * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved. - * - * 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, 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, see . - * - * Author: - * wwang (wei_wang@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - * Maintainer: - * Edwin Rong (edwin_rong@realsil.com.cn) - * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China - */ - -#ifndef __RTS51X_XD_H -#define __RTS51X_XD_H - -/* Error Codes */ -#define XD_NO_ERROR 0x00 -#define XD_NO_MEMORY 0x80 -#define XD_PRG_ERROR 0x40 -#define XD_NO_CARD 0x20 -#define XD_READ_FAIL 0x10 -#define XD_ERASE_FAIL 0x08 -#define XD_WRITE_FAIL 0x04 -#define XD_ECC_ERROR 0x02 -#define XD_TO_ERROR 0x01 - -/* XD Commands */ -#define READ1_1 0x00 -#define READ1_2 0x01 -#define READ2 0x50 -#define READ_ID 0x90 -#define RESET 0xff -#define PAGE_PRG_1 0x80 -#define PAGE_PRG_2 0x10 -#define BLK_ERASE_1 0x60 -#define BLK_ERASE_2 0xD0 -#define READ_STS 0x70 -#define READ_xD_ID 0x9A -#define COPY_BACK_512 0x8A -#define COPY_BACK_2K 0x85 -#define READ1_1_2 0x30 -#define READ1_1_3 0x35 -#define CHG_DAT_OUT_1 0x05 -#define RDM_DAT_OUT_1 0x05 -#define CHG_DAT_OUT_2 0xE0 -#define RDM_DAT_OUT_2 0xE0 -#define CHG_DAT_OUT_2 0xE0 -#define CHG_DAT_IN_1 0x85 -#define CACHE_PRG 0x15 - -/* Redundant Area Related */ -#define XD_EXTRA_SIZE 0x10 -#define XD_2K_EXTRA_SIZE 0x40 - -/* Define for XD Status */ -#define NOT_WRITE_PROTECTED 0x80 -#define READY_STATE 0x40 -#define PROGRAM_ERROR 0x01 -#define PROGRAM_ERROR_N_1 0x02 -#define INTERNAL_READY 0x20 -#define READY_FLAG 0x5F - -/* Define for device code */ -#define XD_8M_X8_512 0xE6 -#define XD_16M_X8_512 0x73 -#define XD_32M_X8_512 0x75 -#define XD_64M_X8_512 0x76 -#define XD_128M_X8_512 0x79 -#define XD_256M_X8_512 0x71 -#define XD_128M_X8_2048 0xF1 -#define XD_256M_X8_2048 0xDA -#define XD_512M_X8 0xDC -#define XD_128M_X16_2048 0xC1 -#define XD_4M_X8_512_1 0xE3 -#define XD_4M_X8_512_2 0xE5 -#define xD_1G_X8_512 0xD3 -#define xD_2G_X8_512 0xD5 - -#define XD_ID_CODE 0xB5 - -#define VENDOR_BLOCK 0xEFFF -#define CIS_BLOCK 0xDFFF - -#define BLK_NOT_FOUND 0xFFFFFFFF - -#define NO_NEW_BLK 0xFFFFFFFF - -#define PAGE_CORRECTABLE 0x0 -#define PAGE_NOTCORRECTABLE 0x1 - -#define NO_OFFSET 0x0 -#define WITH_OFFSET 0x1 - -#define Sect_Per_Page 4 -#define XD_ADDR_MODE_2C XD_ADDR_MODE_2A - -#define ZONE0_BAD_BLOCK 23 -#define NOT_ZONE0_BAD_BLOCK 24 - -/* Assign address mode */ -#define XD_RW_ADDR 0x01 -#define XD_ERASE_ADDR 0x02 - -/* Macro Definition */ -#define XD_PAGE_512(xd_card) \ - do { \ - (xd_card)->block_shift = 5; \ - (xd_card)->page_off = 0x1F; \ - } while (0) - -#define XD_SET_BAD_NEWBLK(xd_card) ((xd_card)->multi_flag |= 0x01) -#define XD_CLR_BAD_NEWBLK(xd_card) ((xd_card)->multi_flag &= ~0x01) -#define XD_CHK_BAD_NEWBLK(xd_card) ((xd_card)->multi_flag & 0x01) - -#define XD_SET_BAD_OLDBLK(xd_card) ((xd_card)->multi_flag |= 0x02) -#define XD_CLR_BAD_OLDBLK(xd_card) ((xd_card)->multi_flag &= ~0x02) -#define XD_CHK_BAD_OLDBLK(xd_card) ((xd_card)->multi_flag & 0x02) - -#define XD_SET_MBR_FAIL(xd_card) ((xd_card)->multi_flag |= 0x04) -#define XD_CLR_MBR_FAIL(xd_card) ((xd_card)->multi_flag &= ~0x04) -#define XD_CHK_MBR_FAIL(xd_card) ((xd_card)->multi_flag & 0x04) - -#define XD_SET_ECC_FLD_ERR(xd_card) ((xd_card)->multi_flag |= 0x08) -#define XD_CLR_ECC_FLD_ERR(xd_card) ((xd_card)->multi_flag &= ~0x08) -#define XD_CHK_ECC_FLD_ERR(xd_card) ((xd_card)->multi_flag & 0x08) - -#define XD_SET_4MB(xd_card) ((xd_card)->multi_flag |= 0x10) -#define XD_CLR_4MB(xd_card) ((xd_card)->multi_flag &= ~0x10) -#define XD_CHK_4MB(xd_card) ((xd_card)->multi_flag & 0x10) - -#define XD_SET_ECC_ERR(xd_card) ((xd_card)->multi_flag |= 0x40) -#define XD_CLR_ECC_ERR(xd_card) ((xd_card)->multi_flag &= ~0x40) -#define XD_CHK_ECC_ERR(xd_card) ((xd_card)->multi_flag & 0x40) - -/* Offset in xD redundant buffer */ -#define PAGE_STATUS 0 -#define BLOCK_STATUS 1 -#define BLOCK_ADDR1_L 2 -#define BLOCK_ADDR1_H 3 -#define BLOCK_ADDR2_L 4 -#define BLOCK_ADDR2_H 5 -#define RESERVED0 6 -#define RESERVED1 7 -#define RESERVED2 8 -#define RESERVED3 9 -#define PARITY 10 - -/* For CIS block */ -#define CIS0_0 0 -#define CIS0_1 1 -#define CIS0_2 2 -#define CIS0_3 3 -#define CIS0_4 4 -#define CIS0_5 5 -#define CIS0_6 6 -#define CIS0_7 7 -#define CIS0_8 8 -#define CIS0_9 9 -#define CIS1_0 256 -#define CIS1_1 (256 + 1) -#define CIS1_2 (256 + 2) -#define CIS1_3 (256 + 3) -#define CIS1_4 (256 + 4) -#define CIS1_5 (256 + 5) -#define CIS1_6 (256 + 6) -#define CIS1_7 (256 + 7) -#define CIS1_8 (256 + 8) -#define CIS1_9 (256 + 9) - -int rts51x_reset_xd_card(struct rts51x_chip *chip); -int rts51x_xd_rw(struct scsi_cmnd *srb, struct rts51x_chip *chip, u32 start_sector, - u16 sector_cnt); -void rts51x_xd_free_l2p_tbl(struct rts51x_chip *chip); -void rts51x_xd_cleanup_work(struct rts51x_chip *chip); -int rts51x_release_xd_card(struct rts51x_chip *chip); - -#endif /* __RTS51X_XD_H */ -- cgit v1.2.3 From f994d8358dd4a2fed481fca42b406292c0708665 Mon Sep 17 00:00:00 2001 From: Jerry Snitselaar Date: Wed, 30 Apr 2014 23:58:55 -0700 Subject: staging: binder: cleanup dereference of noderef expressions Clean up sparse warnings for cred struct dereference. Signed-off-by: Jerry Snitselaar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/binder.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c index 35c00abc3dd1..c78411a22562 100644 --- a/drivers/staging/android/binder.c +++ b/drivers/staging/android/binder.c @@ -1326,6 +1326,7 @@ static void binder_transaction(struct binder_proc *proc, struct binder_transaction *in_reply_to = NULL; struct binder_transaction_log_entry *e; uint32_t return_error; + const struct cred *cred = __task_cred(proc->tsk); e = binder_transaction_log_add(&binder_transaction_log); e->call_type = reply ? 2 : !!(tr->flags & TF_ONE_WAY); @@ -1467,7 +1468,7 @@ static void binder_transaction(struct binder_proc *proc, t->from = thread; else t->from = NULL; - t->sender_euid = proc->tsk->cred->euid; + t->sender_euid = cred->euid; t->to_proc = target_proc; t->to_thread = target_thread; t->code = tr->code; @@ -2600,6 +2601,7 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) struct binder_thread *thread; unsigned int size = _IOC_SIZE(cmd); void __user *ubuf = (void __user *)arg; + const struct cred *cred = current_cred(); /*pr_info("binder_ioctl: %d:%d %x %lx\n", proc->pid, current->pid, cmd, arg);*/ @@ -2685,15 +2687,15 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) goto err; } if (uid_valid(binder_context_mgr_uid)) { - if (!uid_eq(binder_context_mgr_uid, current->cred->euid)) { + if (!uid_eq(binder_context_mgr_uid, cred->euid)) { pr_err("BINDER_SET_CONTEXT_MGR bad uid %d != %d\n", - from_kuid(&init_user_ns, current->cred->euid), + from_kuid(&init_user_ns, cred->euid), from_kuid(&init_user_ns, binder_context_mgr_uid)); ret = -EPERM; goto err; } } else - binder_context_mgr_uid = current->cred->euid; + binder_context_mgr_uid = cred->euid; binder_context_mgr_node = binder_new_node(proc, 0, 0); if (binder_context_mgr_node == NULL) { ret = -ENOMEM; -- cgit v1.2.3 From 7d42043f093ed83ef80f03b17087a1eaaf8d2e06 Mon Sep 17 00:00:00 2001 From: Christian Engelmayer Date: Wed, 7 May 2014 21:44:53 +0200 Subject: staging: binder: fix usage of uninit scalar in binder_transaction() Fix the error path when a cookie mismatch is detected. In that case the function jumps to the exit label without setting the uninitialized, local variable 'return_error'. Detected by Coverity - CID 201453. Signed-off-by: Christian Engelmayer Acked-by: Arve Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/binder.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c index c78411a22562..e8dd7ddcba41 100644 --- a/drivers/staging/android/binder.c +++ b/drivers/staging/android/binder.c @@ -1547,6 +1547,7 @@ static void binder_transaction(struct binder_proc *proc, proc->pid, thread->pid, (u64)fp->binder, node->debug_id, (u64)fp->cookie, (u64)node->cookie); + return_error = BR_FAILED_REPLY; goto err_binder_get_ref_for_node_failed; } ref = binder_get_ref_for_node(target_proc, node); -- cgit v1.2.3 From 87755c0b3af6c8e6307e928184d96b281b3aef1d Mon Sep 17 00:00:00 2001 From: Daeseok Youn Date: Wed, 7 May 2014 15:01:04 +0900 Subject: staging: bcm: use kzalloc instead of kmalloc/memset Signed-off-by: Daeseok Youn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/InterfaceDld.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/bcm/InterfaceDld.c b/drivers/staging/bcm/InterfaceDld.c index 005e4607b260..e1925bdc127c 100644 --- a/drivers/staging/bcm/InterfaceDld.c +++ b/drivers/staging/bcm/InterfaceDld.c @@ -53,8 +53,8 @@ int InterfaceFileReadbackFromChip(PVOID arg, struct file *flp, struct bcm_interface_adapter *psIntfAdapter = arg; int bytes; - buff = kmalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_DMA); - buff_readback = kmalloc(MAX_TRANSFER_CTRL_BYTE_USB , GFP_DMA); + buff = kzalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_DMA); + buff_readback = kzalloc(MAX_TRANSFER_CTRL_BYTE_USB , GFP_DMA); if (!buff || !buff_readback) { kfree(buff); kfree(buff_readback); @@ -64,8 +64,6 @@ int InterfaceFileReadbackFromChip(PVOID arg, struct file *flp, is_config_file = (on_chip_loc == CONFIG_BEGIN_ADDR) ? 1 : 0; - memset(buff_readback, 0, MAX_TRANSFER_CTRL_BYTE_USB); - memset(buff, 0, MAX_TRANSFER_CTRL_BYTE_USB); while (1) { oldfs = get_fs(); set_fs(get_ds()); -- cgit v1.2.3 From 22840adaf7c66bcba826a22e56e81c58c007421a Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 22 May 2014 12:17:25 +0200 Subject: Staging: bcm: Fixed line lengths Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 76 ++++++++++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 26 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index ae7490b4d70e..e5283ddc2023 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -101,9 +101,11 @@ static ssize_t bcm_char_read(struct file *filp, char __user *buf, size_t size, int wait_ret_val = 0; unsigned long ret = 0; - wait_ret_val = wait_event_interruptible(Adapter->process_read_wait_queue, - (pTarang->RxAppControlHead || - Adapter->device_removed)); + wait_ret_val = wait_event_interruptible( + Adapter->process_read_wait_queue, + (pTarang->RxAppControlHead || + Adapter->device_removed)); + if ((wait_ret_val == -ERESTARTSYS)) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Exiting as i've been asked to exit!!!\n"); @@ -410,7 +412,8 @@ static int bcm_char_ioctl_gpio_set_request(void __user *argp, if (IoBuffer.InputLength > sizeof(gpio_info)) return -EINVAL; - if (copy_from_user(&gpio_info, IoBuffer.InputBuffer, IoBuffer.InputLength)) + if (copy_from_user(&gpio_info, IoBuffer.InputBuffer, + IoBuffer.InputLength)) return -EFAULT; uiBit = gpio_info.uiGpioNumber; @@ -516,7 +519,8 @@ static int bcm_char_ioctl_led_thread_state_change_req(void __user *argp, if (IoBuffer.InputLength > sizeof(threadReq)) return -EINVAL; - if (copy_from_user(&threadReq, IoBuffer.InputBuffer, IoBuffer.InputLength)) + if (copy_from_user(&threadReq, IoBuffer.InputBuffer, + IoBuffer.InputLength)) return -EFAULT; /* if LED thread is running(Actively or Inactively) @@ -594,7 +598,8 @@ static int bcm_char_ioctl_gpio_multi_request(void __user *argp, INT Status = STATUS_FAILURE; int bytes; - memset(pgpio_multi_info, 0, MAX_IDX * sizeof(struct bcm_gpio_multi_info)); + memset(pgpio_multi_info, 0, + MAX_IDX * sizeof(struct bcm_gpio_multi_info)); if ((Adapter->IdleMode == TRUE) || (Adapter->bShutStatus == TRUE) || @@ -627,7 +632,7 @@ static int bcm_char_ioctl_gpio_multi_request(void __user *argp, if ((pgpio_multi_info[WIMAX_IDX].uiGPIOMask) & (pgpio_multi_info[WIMAX_IDX].uiGPIOCommand)) { /* Set 1's in GPIO OUTPUT REGISTER */ - *(UINT *)ucResetValue = pgpio_multi_info[WIMAX_IDX].uiGPIOMask & + *(UINT *)ucResetValue = pgpio_multi_info[WIMAX_IDX].uiGPIOMask & pgpio_multi_info[WIMAX_IDX].uiGPIOCommand & pgpio_multi_info[WIMAX_IDX].uiGPIOValue; @@ -643,7 +648,8 @@ static int bcm_char_ioctl_gpio_multi_request(void __user *argp, } /* Clear to 0's in GPIO OUTPUT REGISTER */ - *(UINT *)ucResetValue = (pgpio_multi_info[WIMAX_IDX].uiGPIOMask & + *(UINT *)ucResetValue = + (pgpio_multi_info[WIMAX_IDX].uiGPIOMask & pgpio_multi_info[WIMAX_IDX].uiGPIOCommand & (~(pgpio_multi_info[WIMAX_IDX].uiGPIOValue))); @@ -672,7 +678,8 @@ static int bcm_char_ioctl_gpio_multi_request(void __user *argp, Status = STATUS_SUCCESS; } - pgpio_multi_info[WIMAX_IDX].uiGPIOValue = (*(UINT *)ucResetValue & + pgpio_multi_info[WIMAX_IDX].uiGPIOValue = + (*(UINT *)ucResetValue & pgpio_multi_info[WIMAX_IDX].uiGPIOMask); } @@ -739,11 +746,13 @@ static int bcm_char_ioctl_gpio_mode_request(void __user *argp, if (pgpio_multi_mode[WIMAX_IDX].uiGPIOMask) { /* write all OUT's (1's) */ - *(UINT *) ucResetValue |= (pgpio_multi_mode[WIMAX_IDX].uiGPIOMode & + *(UINT *) ucResetValue |= + (pgpio_multi_mode[WIMAX_IDX].uiGPIOMode & pgpio_multi_mode[WIMAX_IDX].uiGPIOMask); /* write all IN's (0's) */ - *(UINT *) ucResetValue &= ~((~pgpio_multi_mode[WIMAX_IDX].uiGPIOMode) & + *(UINT *) ucResetValue &= + ~((~pgpio_multi_mode[WIMAX_IDX].uiGPIOMode) & pgpio_multi_mode[WIMAX_IDX].uiGPIOMask); /* Currently implemented return the modes of all GPIO's @@ -801,9 +810,11 @@ static int bcm_char_ioctl_misc_request(void __user *argp, return PTR_ERR(pvBuffer); down(&Adapter->LowPowerModeSync); - Status = wait_event_interruptible_timeout(Adapter->lowpower_mode_wait_queue, - !Adapter->bPreparingForLowPowerMode, - (1 * HZ)); + Status = wait_event_interruptible_timeout( + Adapter->lowpower_mode_wait_queue, + !Adapter->bPreparingForLowPowerMode, + (1 * HZ)); + if (Status == -ERESTARTSYS) goto cntrlEnd; @@ -1546,7 +1557,8 @@ static int bcm_char_ioctl_nvm_rw(void __user *argp, do_gettimeofday(&tv1); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, " timetaken by Write/read :%ld msec\n", - (tv1.tv_sec - tv0.tv_sec)*1000 + (tv1.tv_usec - tv0.tv_usec)/1000); + (tv1.tv_sec - tv0.tv_sec)*1000 + + (tv1.tv_usec - tv0.tv_usec)/1000); kfree(pReadData); return STATUS_SUCCESS; @@ -1735,8 +1747,10 @@ static int bcm_char_ioctl_flash2x_section_write(void __user *argp, /* extracting the remainder of the given offset. */ WriteBytes = Adapter->uiSectorSize; - if (WriteOffset % Adapter->uiSectorSize) - WriteBytes = Adapter->uiSectorSize - (WriteOffset % Adapter->uiSectorSize); + if (WriteOffset % Adapter->uiSectorSize) { + WriteBytes = Adapter->uiSectorSize - + (WriteOffset % Adapter->uiSectorSize); + } if (NOB < WriteBytes) WriteBytes = NOB; @@ -1811,7 +1825,9 @@ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, if (IoBuffer.OutputLength != sizeof(struct bcm_flash2x_bitmap)) return -EINVAL; - psFlash2xBitMap = kzalloc(sizeof(struct bcm_flash2x_bitmap), GFP_KERNEL); + psFlash2xBitMap = kzalloc(sizeof(struct bcm_flash2x_bitmap), + GFP_KERNEL); + if (psFlash2xBitMap == NULL) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Memory is not available"); @@ -1860,7 +1876,8 @@ static int bcm_char_ioctl_set_active_section(void __user *argp, return -EINVAL; } - Status = copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer)); + Status = copy_from_user(&IoBuffer, argp, + sizeof(struct bcm_ioctl_buffer)); if (Status) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); @@ -1915,7 +1932,8 @@ static int bcm_char_ioctl_copy_section(void __user *argp, return -EINVAL; } - Status = copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer)); + Status = copy_from_user(&IoBuffer, argp, + sizeof(struct bcm_ioctl_buffer)); if (Status) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed Status :%d", Status); @@ -2006,7 +2024,8 @@ static int bcm_char_ioctl_get_flash_cs_info(void __user *argp, BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, " IOCTL_BCM_GET_FLASH_CS_INFO Called"); - Status = copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer)); + Status = copy_from_user(&IoBuffer, argp, + sizeof(struct bcm_ioctl_buffer)); if (Status) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); @@ -2056,7 +2075,8 @@ static int bcm_char_ioctl_select_dsd(void __user *argp, return -EINVAL; } - Status = copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer)); + Status = copy_from_user(&IoBuffer, argp, + sizeof(struct bcm_ioctl_buffer)); if (Status) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed"); @@ -2205,7 +2225,8 @@ static int bcm_char_ioctl_cntrlmsg_mask(void __user *argp, ULONG RxCntrlMsgBitMask = 0; /* Copy Ioctl Buffer structure */ - Status = copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer)); + Status = copy_from_user(&IoBuffer, argp, + sizeof(struct bcm_ioctl_buffer)); if (Status) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "copy of Ioctl buffer is failed from user space"); @@ -2355,7 +2376,8 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) return Status; case BCM_LED_THREAD_STATE_CHANGE_REQ: - Status = bcm_char_ioctl_led_thread_state_change_req(argp, Adapter); + Status = bcm_char_ioctl_led_thread_state_change_req(argp, + Adapter); return Status; case IOCTL_BCM_GPIO_STATUS_REQUEST: @@ -2394,13 +2416,15 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) case IOCTL_BE_BUCKET_SIZE: Status = 0; - if (get_user(Adapter->BEBucketSize, (unsigned long __user *)arg)) + if (get_user(Adapter->BEBucketSize, + (unsigned long __user *)arg)) Status = -EFAULT; break; case IOCTL_RTPS_BUCKET_SIZE: Status = 0; - if (get_user(Adapter->rtPSBucketSize, (unsigned long __user *)arg)) + if (get_user(Adapter->rtPSBucketSize, + (unsigned long __user *)arg)) Status = -EFAULT; break; -- cgit v1.2.3 From 8224ac2a787540afb77c18cc338284b1ad697b8e Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 22 May 2014 12:17:26 +0200 Subject: Staging: bcm: Outsourced cmd handling to function This patch outsourced the true-branch for the IOCTL_BCM_NVM_READ command handling to shorten the bcm_char_ioctl_nvm_rw() function. Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 70 ++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 28 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index e5283ddc2023..89ecdac1a1dd 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -1,6 +1,44 @@ #include #include "headers.h" + +static int bcm_handle_nvm_read_cmd(struct bcm_mini_adapter *Adapter, + PUCHAR pReadData, struct bcm_nvm_readwrite *stNVMReadWrite) +{ + INT Status = STATUS_FAILURE; + + down(&Adapter->NVMRdmWrmLock); + + if ((Adapter->IdleMode == TRUE) || (Adapter->bShutStatus == TRUE) || + (Adapter->bPreparingForLowPowerMode == TRUE)) { + + BCM_DEBUG_PRINT(Adapter, + DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "Device is in Idle/Shutdown Mode\n"); + up(&Adapter->NVMRdmWrmLock); + kfree(pReadData); + return -EACCES; + } + + Status = BeceemNVMRead(Adapter, (PUINT)pReadData, + stNVMReadWrite->uiOffset, + stNVMReadWrite->uiNumBytes); + up(&Adapter->NVMRdmWrmLock); + + if (Status != STATUS_SUCCESS) { + kfree(pReadData); + return Status; + } + + if (copy_to_user(stNVMReadWrite->pBuffer, pReadData, + stNVMReadWrite->uiNumBytes)) { + kfree(pReadData); + return -EFAULT; + } + + return STATUS_SUCCESS; +} + /*************************************************************** * Function - bcm_char_open() * @@ -1449,34 +1487,10 @@ static int bcm_char_ioctl_nvm_rw(void __user *argp, do_gettimeofday(&tv0); if (IOCTL_BCM_NVM_READ == cmd) { - down(&Adapter->NVMRdmWrmLock); - - if ((Adapter->IdleMode == TRUE) || - (Adapter->bShutStatus == TRUE) || - (Adapter->bPreparingForLowPowerMode == TRUE)) { - - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Device is in Idle/Shutdown Mode\n"); - up(&Adapter->NVMRdmWrmLock); - kfree(pReadData); - return -EACCES; - } - - Status = BeceemNVMRead(Adapter, (PUINT)pReadData, - stNVMReadWrite.uiOffset, stNVMReadWrite.uiNumBytes); - up(&Adapter->NVMRdmWrmLock); - - if (Status != STATUS_SUCCESS) { - kfree(pReadData); - return Status; - } - - if (copy_to_user(stNVMReadWrite.pBuffer, pReadData, - stNVMReadWrite.uiNumBytes)) { - kfree(pReadData); - return -EFAULT; - } + int ret = bcm_handle_nvm_read_cmd(Adapter, pReadData, + &stNVMReadWrite); + if (ret != STATUS_SUCCESS) + return ret; } else { down(&Adapter->NVMRdmWrmLock); -- cgit v1.2.3 From e5c34a1aade7befa50c46381d0cc7b8f61475b31 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 22 May 2014 12:17:27 +0200 Subject: Staging: bcm: Outsourced IsFlash2x() handling This patch outsources the code from the IsFlash2x() check in bcm_char_ioctl_nvm_rw() function to shorten it. Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 98 ++++++++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 43 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 89ecdac1a1dd..93b94b4a1e90 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -39,6 +39,56 @@ static int bcm_handle_nvm_read_cmd(struct bcm_mini_adapter *Adapter, return STATUS_SUCCESS; } +static int handle_flash2x_adapter(struct bcm_mini_adapter *Adapter, + PUCHAR pReadData, struct bcm_nvm_readwrite *stNVMReadWrite) +{ + /* + * New Requirement:- + * DSD section updation will be allowed in two case:- + * 1. if DSD sig is present in DSD header means dongle + * is ok and updation is fruitfull + * 2. if point 1 failes then user buff should have + * DSD sig. this point ensures that if dongle is + * corrupted then user space program first modify + * the DSD header with valid DSD sig so that this + * as well as further write may be worthwhile. + * + * This restriction has been put assuming that + * if DSD sig is corrupted, DSD data won't be + * considered valid. + */ + INT Status; + ULONG ulDSDMagicNumInUsrBuff = 0; + + Status = BcmFlash2xCorruptSig(Adapter, Adapter->eActiveDSD); + if (Status == STATUS_SUCCESS) + return STATUS_SUCCESS; + + if (((stNVMReadWrite->uiOffset + stNVMReadWrite->uiNumBytes) != + Adapter->uiNVMDSDSize) || + (stNVMReadWrite->uiNumBytes < SIGNATURE_SIZE)) { + + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "DSD Sig is present neither in Flash nor User provided Input.."); + up(&Adapter->NVMRdmWrmLock); + kfree(pReadData); + return Status; + } + + ulDSDMagicNumInUsrBuff = + ntohl(*(PUINT)(pReadData + stNVMReadWrite->uiNumBytes - + SIGNATURE_SIZE)); + if (ulDSDMagicNumInUsrBuff != DSD_IMAGE_MAGIC_NUMBER) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "DSD Sig is present neither in Flash nor User provided Input.."); + up(&Adapter->NVMRdmWrmLock); + kfree(pReadData); + return Status; + } + + return STATUS_SUCCESS; +} + /*************************************************************** * Function - bcm_char_open() * @@ -1437,7 +1487,6 @@ static int bcm_char_ioctl_nvm_rw(void __user *argp, struct timeval tv0, tv1; struct bcm_ioctl_buffer IoBuffer; PUCHAR pReadData = NULL; - ULONG ulDSDMagicNumInUsrBuff = 0; INT Status = STATUS_FAILURE; memset(&tv0, 0, sizeof(struct timeval)); @@ -1508,48 +1557,11 @@ static int bcm_char_ioctl_nvm_rw(void __user *argp, Adapter->bHeaderChangeAllowed = TRUE; if (IsFlash2x(Adapter)) { - /* - * New Requirement:- - * DSD section updation will be allowed in two case:- - * 1. if DSD sig is present in DSD header means dongle - * is ok and updation is fruitfull - * 2. if point 1 failes then user buff should have - * DSD sig. this point ensures that if dongle is - * corrupted then user space program first modify - * the DSD header with valid DSD sig so that this - * as well as further write may be worthwhile. - * - * This restriction has been put assuming that - * if DSD sig is corrupted, DSD data won't be - * considered valid. - */ - - Status = BcmFlash2xCorruptSig(Adapter, - Adapter->eActiveDSD); - if (Status != STATUS_SUCCESS) { - if (((stNVMReadWrite.uiOffset + stNVMReadWrite.uiNumBytes) != - Adapter->uiNVMDSDSize) || - (stNVMReadWrite.uiNumBytes < SIGNATURE_SIZE)) { - - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, - OSAL_DBG, DBG_LVL_ALL, - "DSD Sig is present neither in Flash nor User provided Input.."); - up(&Adapter->NVMRdmWrmLock); - kfree(pReadData); - return Status; - } - - ulDSDMagicNumInUsrBuff = ntohl(*(PUINT)(pReadData + stNVMReadWrite.uiNumBytes - SIGNATURE_SIZE)); - if (ulDSDMagicNumInUsrBuff != - DSD_IMAGE_MAGIC_NUMBER) { - BCM_DEBUG_PRINT(Adapter, - DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "DSD Sig is present neither in Flash nor User provided Input.."); - up(&Adapter->NVMRdmWrmLock); - kfree(pReadData); - return Status; - } - } + int ret = handle_flash2x_adapter(Adapter, + pReadData, + &stNVMReadWrite); + if (ret != STATUS_SUCCESS) + return ret; } Status = BeceemNVMWrite(Adapter, (PUINT)pReadData, -- cgit v1.2.3 From 2c11ca29a06a2fe5b54fd5d4d73cf3c536cca2d4 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 22 May 2014 12:17:28 +0200 Subject: Staging: bcm: Indentation fixes in Bcmchar.c Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 218 ++++++++++++++++++++++-------------------- 1 file changed, 115 insertions(+), 103 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 93b94b4a1e90..52809dc3d106 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -241,7 +241,7 @@ static ssize_t bcm_char_read(struct file *filp, char __user *buf, size_t size, } static int bcm_char_ioctl_reg_read_private(void __user *argp, - struct bcm_mini_adapter *Adapter) + struct bcm_mini_adapter *Adapter) { struct bcm_rdm_buffer sRdmBuffer = {0}; struct bcm_ioctl_buffer IoBuffer; @@ -292,7 +292,7 @@ static int bcm_char_ioctl_reg_read_private(void __user *argp, } static int bcm_char_ioctl_reg_write_private(void __user *argp, - struct bcm_mini_adapter *Adapter) + struct bcm_mini_adapter *Adapter) { struct bcm_wrm_buffer sWrmBuffer = {0}; struct bcm_ioctl_buffer IoBuffer; @@ -339,7 +339,7 @@ static int bcm_char_ioctl_reg_write_private(void __user *argp, } static int bcm_char_ioctl_eeprom_reg_read(void __user *argp, - struct bcm_mini_adapter *Adapter) + struct bcm_mini_adapter *Adapter) { struct bcm_rdm_buffer sRdmBuffer = {0}; struct bcm_ioctl_buffer IoBuffer; @@ -407,7 +407,8 @@ static int bcm_char_ioctl_eeprom_reg_read(void __user *argp, } static int bcm_char_ioctl_eeprom_reg_write(void __user *argp, - struct bcm_mini_adapter *Adapter, UINT cmd) + struct bcm_mini_adapter *Adapter, + UINT cmd) { struct bcm_wrm_buffer sWrmBuffer = {0}; struct bcm_ioctl_buffer IoBuffer; @@ -473,7 +474,7 @@ static int bcm_char_ioctl_eeprom_reg_write(void __user *argp, } static int bcm_char_ioctl_gpio_set_request(void __user *argp, - struct bcm_mini_adapter *Adapter) + struct bcm_mini_adapter *Adapter) { struct bcm_gpio_info gpio_info = {0}; struct bcm_ioctl_buffer IoBuffer; @@ -501,7 +502,7 @@ static int bcm_char_ioctl_gpio_set_request(void __user *argp, return -EINVAL; if (copy_from_user(&gpio_info, IoBuffer.InputBuffer, - IoBuffer.InputLength)) + IoBuffer.InputLength)) return -EFAULT; uiBit = gpio_info.uiGpioNumber; @@ -583,7 +584,7 @@ static int bcm_char_ioctl_gpio_set_request(void __user *argp, } static int bcm_char_ioctl_led_thread_state_change_req(void __user *argp, - struct bcm_mini_adapter *Adapter) + struct bcm_mini_adapter *Adapter) { struct bcm_user_thread_req threadReq = {0}; struct bcm_ioctl_buffer IoBuffer; @@ -608,7 +609,7 @@ static int bcm_char_ioctl_led_thread_state_change_req(void __user *argp, return -EINVAL; if (copy_from_user(&threadReq, IoBuffer.InputBuffer, - IoBuffer.InputLength)) + IoBuffer.InputLength)) return -EFAULT; /* if LED thread is running(Actively or Inactively) @@ -634,7 +635,7 @@ static int bcm_char_ioctl_led_thread_state_change_req(void __user *argp, } static int bcm_char_ioctl_gpio_status_request(void __user *argp, - struct bcm_mini_adapter *Adapter) + struct bcm_mini_adapter *Adapter) { struct bcm_gpio_info gpio_info = {0}; struct bcm_ioctl_buffer IoBuffer; @@ -676,7 +677,7 @@ static int bcm_char_ioctl_gpio_status_request(void __user *argp, } static int bcm_char_ioctl_gpio_multi_request(void __user *argp, - struct bcm_mini_adapter *Adapter) + struct bcm_mini_adapter *Adapter) { struct bcm_gpio_multi_info gpio_multi_info[MAX_IDX]; struct bcm_gpio_multi_info *pgpio_multi_info = @@ -687,7 +688,7 @@ static int bcm_char_ioctl_gpio_multi_request(void __user *argp, int bytes; memset(pgpio_multi_info, 0, - MAX_IDX * sizeof(struct bcm_gpio_multi_info)); + MAX_IDX * sizeof(struct bcm_gpio_multi_info)); if ((Adapter->IdleMode == TRUE) || (Adapter->bShutStatus == TRUE) || @@ -703,11 +704,11 @@ static int bcm_char_ioctl_gpio_multi_request(void __user *argp, IoBuffer.OutputLength = sizeof(gpio_multi_info); if (copy_from_user(&gpio_multi_info, IoBuffer.InputBuffer, - IoBuffer.InputLength)) + IoBuffer.InputLength)) return -EFAULT; - if (IsReqGpioIsLedInNVM(Adapter, - pgpio_multi_info[WIMAX_IDX].uiGPIOMask) == false) { + if (IsReqGpioIsLedInNVM(Adapter, pgpio_multi_info[WIMAX_IDX].uiGPIOMask) + == false) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Sorry, Requested GPIO<0x%X> is not correspond to NVM LED bit map<0x%X>!!!", @@ -755,7 +756,7 @@ static int bcm_char_ioctl_gpio_multi_request(void __user *argp, if (pgpio_multi_info[WIMAX_IDX].uiGPIOMask) { bytes = rdmaltWithLock(Adapter, (UINT)GPIO_PIN_STATE_REGISTER, - (PUINT)ucResetValue, sizeof(UINT)); + (PUINT)ucResetValue, sizeof(UINT)); if (bytes < 0) { Status = bytes; @@ -783,7 +784,7 @@ static int bcm_char_ioctl_gpio_multi_request(void __user *argp, } static int bcm_char_ioctl_gpio_mode_request(void __user *argp, - struct bcm_mini_adapter *Adapter) + struct bcm_mini_adapter *Adapter) { struct bcm_gpio_multi_mode gpio_multi_mode[MAX_IDX]; struct bcm_gpio_multi_mode *pgpio_multi_mode = @@ -823,8 +824,8 @@ static int bcm_char_ioctl_gpio_mode_request(void __user *argp, } /* Validating the request */ - if (IsReqGpioIsLedInNVM(Adapter, - pgpio_multi_mode[WIMAX_IDX].uiGPIOMask) == false) { + if (IsReqGpioIsLedInNVM(Adapter, pgpio_multi_mode[WIMAX_IDX].uiGPIOMask) + == false) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Sorry, Requested GPIO<0x%X> is not correspond to NVM LED bit map<0x%X>!!!", pgpio_multi_mode[WIMAX_IDX].uiGPIOMask, @@ -876,7 +877,7 @@ static int bcm_char_ioctl_gpio_mode_request(void __user *argp, } static int bcm_char_ioctl_misc_request(void __user *argp, - struct bcm_mini_adapter *Adapter) + struct bcm_mini_adapter *Adapter) { struct bcm_ioctl_buffer IoBuffer; PVOID pvBuffer = NULL; @@ -921,7 +922,7 @@ cntrlEnd: } static int bcm_char_ioctl_buffer_download_start( - struct bcm_mini_adapter *Adapter) + struct bcm_mini_adapter *Adapter) { INT Status; @@ -932,7 +933,8 @@ static int bcm_char_ioctl_buffer_download_start( } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Starting the firmware download PID =0x%x!!!!\n", current->pid); + "Starting the firmware download PID =0x%x!!!!\n", + current->pid); if (down_trylock(&Adapter->fw_download_sema)) return -EBUSY; @@ -957,7 +959,7 @@ static int bcm_char_ioctl_buffer_download_start( } static int bcm_char_ioctl_buffer_download(void __user *argp, - struct bcm_mini_adapter *Adapter) + struct bcm_mini_adapter *Adapter) { struct bcm_firmware_info *psFwInfo = NULL; struct bcm_ioctl_buffer IoBuffer; @@ -1042,7 +1044,7 @@ static int bcm_char_ioctl_buffer_download(void __user *argp, } static int bcm_char_ioctl_buffer_download_stop(void __user *argp, - struct bcm_mini_adapter *Adapter) + struct bcm_mini_adapter *Adapter) { INT Status; int timeout = 0; @@ -1135,7 +1137,7 @@ static int bcm_char_ioctl_chip_reset(struct bcm_mini_adapter *Adapter) } static int bcm_char_ioctl_qos_threshold(ULONG arg, - struct bcm_mini_adapter *Adapter) + struct bcm_mini_adapter *Adapter) { USHORT uiLoopIndex; @@ -1620,13 +1622,17 @@ static int bcm_char_ioctl_flash2x_section_read(void __user *argp, return -EFAULT; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "\nsFlash2xRead.Section :%x", sFlash2xRead.Section); + "\nsFlash2xRead.Section :%x", + sFlash2xRead.Section); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "\nsFlash2xRead.offset :%x", sFlash2xRead.offset); + "\nsFlash2xRead.offset :%x", + sFlash2xRead.offset); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "\nsFlash2xRead.numOfBytes :%x", sFlash2xRead.numOfBytes); + "\nsFlash2xRead.numOfBytes :%x", + sFlash2xRead.numOfBytes); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "\nsFlash2xRead.bVerify :%x\n", sFlash2xRead.bVerify); + "\nsFlash2xRead.bVerify :%x\n", + sFlash2xRead.bVerify); /* This was internal to driver for raw read. * now it has ben exposed to user space app. @@ -1646,7 +1652,7 @@ static int bcm_char_ioctl_flash2x_section_read(void __user *argp, if (pReadBuff == NULL) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Memory allocation failed for Flash 2.x Read Structure"); + "Memory allocation failed for Flash 2.x Read Structure"); return -ENOMEM; } down(&Adapter->NVMRdmWrmLock); @@ -1656,7 +1662,8 @@ static int bcm_char_ioctl_flash2x_section_read(void __user *argp, (Adapter->bPreparingForLowPowerMode == TRUE)) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); + DBG_LVL_ALL, + "Device is in Idle/Shutdown Mode\n"); up(&Adapter->NVMRdmWrmLock); kfree(pReadBuff); return -EACCES; @@ -1809,8 +1816,10 @@ static int bcm_char_ioctl_flash2x_section_write(void __user *argp, /* Writing the data from Flash 2.x */ Status = BcmFlash2xBulkWrite(Adapter, (PUINT)pWriteBuff, - sFlash2xWrite.Section, WriteOffset, WriteBytes, - sFlash2xWrite.bVerify); + sFlash2xWrite.Section, + WriteOffset, + WriteBytes, + sFlash2xWrite.bVerify); if (Status) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, @@ -1894,24 +1903,24 @@ static int bcm_char_ioctl_set_active_section(void __user *argp, struct bcm_ioctl_buffer IoBuffer; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "IOCTL_BCM_SET_ACTIVE_SECTION Called"); + "IOCTL_BCM_SET_ACTIVE_SECTION Called"); if (IsFlash2x(Adapter) != TRUE) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Flash Does not have 2.x map"); + "Flash Does not have 2.x map"); return -EINVAL; } Status = copy_from_user(&IoBuffer, argp, - sizeof(struct bcm_ioctl_buffer)); + sizeof(struct bcm_ioctl_buffer)); if (Status) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Copy of IOCTL BUFFER failed"); + "Copy of IOCTL BUFFER failed"); return -EFAULT; } Status = copy_from_user(&eFlash2xSectionVal, - IoBuffer.InputBuffer, sizeof(INT)); + IoBuffer.InputBuffer, sizeof(INT)); if (Status) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of flash section val failed"); @@ -1925,7 +1934,7 @@ static int bcm_char_ioctl_set_active_section(void __user *argp, (Adapter->bPreparingForLowPowerMode == TRUE)) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Device is in Idle/Shutdown Mode\n"); + "Device is in Idle/Shutdown Mode\n"); up(&Adapter->NVMRdmWrmLock); return -EACCES; } @@ -1933,8 +1942,8 @@ static int bcm_char_ioctl_set_active_section(void __user *argp, Status = BcmSetActiveSection(Adapter, eFlash2xSectionVal); if (Status) BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Failed to make it's priority Highest. Status %d", - Status); + "Failed to make it's priority Highest. Status %d", + Status); up(&Adapter->NVMRdmWrmLock); @@ -1949,58 +1958,59 @@ static int bcm_char_ioctl_copy_section(void __user *argp, INT Status = STATUS_SUCCESS; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "IOCTL_BCM_COPY_SECTION Called"); + "IOCTL_BCM_COPY_SECTION Called"); Adapter->bAllDSDWriteAllow = false; if (IsFlash2x(Adapter) != TRUE) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Flash Does not have 2.x map"); + "Flash Does not have 2.x map"); return -EINVAL; } Status = copy_from_user(&IoBuffer, argp, - sizeof(struct bcm_ioctl_buffer)); + sizeof(struct bcm_ioctl_buffer)); if (Status) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Copy of IOCTL BUFFER failed Status :%d", Status); + "Copy of IOCTL BUFFER failed Status :%d", + Status); return -EFAULT; } Status = copy_from_user(&sCopySectStrut, IoBuffer.InputBuffer, - sizeof(struct bcm_flash2x_copy_section)); + sizeof(struct bcm_flash2x_copy_section)); if (Status) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Copy of Copy_Section_Struct failed with Status :%d", - Status); + "Copy of Copy_Section_Struct failed with Status :%d", + Status); return -EFAULT; } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Source SEction :%x", sCopySectStrut.SrcSection); + "Source SEction :%x", sCopySectStrut.SrcSection); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Destination SEction :%x", sCopySectStrut.DstSection); + "Destination SEction :%x", sCopySectStrut.DstSection); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "offset :%x", sCopySectStrut.offset); + "offset :%x", sCopySectStrut.offset); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "NOB :%x", sCopySectStrut.numOfBytes); + "NOB :%x", sCopySectStrut.numOfBytes); if (IsSectionExistInFlash(Adapter, sCopySectStrut.SrcSection) == false) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Source Section<%x> does not exist in Flash ", - sCopySectStrut.SrcSection); + "Source Section<%x> does not exist in Flash ", + sCopySectStrut.SrcSection); return -EINVAL; } if (IsSectionExistInFlash(Adapter, sCopySectStrut.DstSection) == false) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Destinatio Section<%x> does not exist in Flash ", - sCopySectStrut.DstSection); + "Destinatio Section<%x> does not exist in Flash ", + sCopySectStrut.DstSection); return -EINVAL; } if (sCopySectStrut.SrcSection == sCopySectStrut.DstSection) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Source and Destination section should be different"); + "Source and Destination section should be different"); return -EINVAL; } @@ -2011,7 +2021,7 @@ static int bcm_char_ioctl_copy_section(void __user *argp, (Adapter->bPreparingForLowPowerMode == TRUE)) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Device is in Idle/Shutdown Mode\n"); + "Device is in Idle/Shutdown Mode\n"); up(&Adapter->NVMRdmWrmLock); return -EACCES; } @@ -2020,13 +2030,13 @@ static int bcm_char_ioctl_copy_section(void __user *argp, sCopySectStrut.SrcSection == ISO_IMAGE2) { if (IsNonCDLessDevice(Adapter)) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Device is Non-CDLess hence won't have ISO !!"); + "Device is Non-CDLess hence won't have ISO !!"); Status = -EINVAL; } else if (sCopySectStrut.numOfBytes == 0) { Status = BcmCopyISO(Adapter, sCopySectStrut); } else { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Partial Copy of ISO section is not Allowed.."); + "Partial Copy of ISO section is not Allowed.."); Status = STATUS_FAILURE; } up(&Adapter->NVMRdmWrmLock); @@ -2048,19 +2058,19 @@ static int bcm_char_ioctl_get_flash_cs_info(void __user *argp, INT Status = STATUS_SUCCESS; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - " IOCTL_BCM_GET_FLASH_CS_INFO Called"); + " IOCTL_BCM_GET_FLASH_CS_INFO Called"); Status = copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer)); if (Status) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Copy of IOCTL BUFFER failed"); + "Copy of IOCTL BUFFER failed"); return -EFAULT; } if (Adapter->eNVMType != NVM_FLASH) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Connected device does not have flash"); + "Connected device does not have flash"); return -EINVAL; } @@ -2069,15 +2079,15 @@ static int bcm_char_ioctl_get_flash_cs_info(void __user *argp, return -EINVAL; if (copy_to_user(IoBuffer.OutputBuffer, - Adapter->psFlash2xCSInfo, - sizeof(struct bcm_flash2x_cs_info))) + Adapter->psFlash2xCSInfo, + sizeof(struct bcm_flash2x_cs_info))) return -EFAULT; } else { if (IoBuffer.OutputLength < sizeof(struct bcm_flash_cs_info)) return -EINVAL; if (copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlashCSInfo, - sizeof(struct bcm_flash_cs_info))) + sizeof(struct bcm_flash_cs_info))) return -EFAULT; } return Status; @@ -2093,46 +2103,46 @@ static int bcm_char_ioctl_select_dsd(void __user *argp, eFlash2xSectionVal = NO_SECTION_VAL; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "IOCTL_BCM_SELECT_DSD Called"); + "IOCTL_BCM_SELECT_DSD Called"); if (IsFlash2x(Adapter) != TRUE) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Flash Does not have 2.x map"); + "Flash Does not have 2.x map"); return -EINVAL; } Status = copy_from_user(&IoBuffer, argp, - sizeof(struct bcm_ioctl_buffer)); + sizeof(struct bcm_ioctl_buffer)); if (Status) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Copy of IOCTL BUFFER failed"); + "Copy of IOCTL BUFFER failed"); return -EFAULT; } Status = copy_from_user(&eFlash2xSectionVal, IoBuffer.InputBuffer, sizeof(INT)); if (Status) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Copy of flash section val failed"); + "Copy of flash section val failed"); return -EFAULT; } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "Read Section :%d", eFlash2xSectionVal); + "Read Section :%d", eFlash2xSectionVal); if ((eFlash2xSectionVal != DSD0) && (eFlash2xSectionVal != DSD1) && (eFlash2xSectionVal != DSD2)) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Passed section<%x> is not DSD section", - eFlash2xSectionVal); + "Passed section<%x> is not DSD section", + eFlash2xSectionVal); return STATUS_FAILURE; } SectOfset = BcmGetSectionValStartOffset(Adapter, eFlash2xSectionVal); if (SectOfset == INVALID_OFFSET) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Provided Section val <%d> does not exist in Flash 2.x", - eFlash2xSectionVal); + "Provided Section val <%d> does not exist in Flash 2.x", + eFlash2xSectionVal); return -EINVAL; } @@ -2158,14 +2168,14 @@ static int bcm_char_ioctl_nvm_raw_read(void __user *argp, if (Adapter->eNVMType != NVM_FLASH) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "NVM TYPE is not Flash"); + "NVM TYPE is not Flash"); return -EINVAL; } /* Copy Ioctl Buffer structure */ if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "copy_from_user 1 failed\n"); + "copy_from_user 1 failed\n"); return -EFAULT; } @@ -2187,7 +2197,7 @@ static int bcm_char_ioctl_nvm_raw_read(void __user *argp, pReadBuff = kzalloc(BuffSize , GFP_KERNEL); if (pReadBuff == NULL) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Memory allocation failed for Flash 2.x Read Structure"); + "Memory allocation failed for Flash 2.x Read Structure"); return -ENOMEM; } down(&Adapter->NVMRdmWrmLock); @@ -2196,8 +2206,8 @@ static int bcm_char_ioctl_nvm_raw_read(void __user *argp, (Adapter->bShutStatus == TRUE) || (Adapter->bPreparingForLowPowerMode == TRUE)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, "Device is in Idle/Shutdown Mode\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "Device is in Idle/Shutdown Mode\n"); kfree(pReadBuff); up(&Adapter->NVMRdmWrmLock); return -EACCES; @@ -2216,17 +2226,19 @@ static int bcm_char_ioctl_nvm_raw_read(void __user *argp, ReadOffset, ReadBytes); if (Status) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Flash 2x read err with Status :%d", Status); + "Flash 2x read err with Status :%d", + Status); break; } BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, pReadBuff, ReadBytes); + DBG_LVL_ALL, pReadBuff, ReadBytes); Status = copy_to_user(OutPutBuff, pReadBuff, ReadBytes); if (Status) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, - "Copy to use failed with status :%d", Status); + "Copy to use failed with status :%d", + Status); up(&Adapter->NVMRdmWrmLock); kfree(pReadBuff); return -EFAULT; @@ -2255,23 +2267,23 @@ static int bcm_char_ioctl_cntrlmsg_mask(void __user *argp, sizeof(struct bcm_ioctl_buffer)); if (Status) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "copy of Ioctl buffer is failed from user space"); + "copy of Ioctl buffer is failed from user space"); return -EFAULT; } if (IoBuffer.InputLength != sizeof(unsigned long)) return -EINVAL; - Status = copy_from_user(&RxCntrlMsgBitMask, - IoBuffer.InputBuffer, IoBuffer.InputLength); + Status = copy_from_user(&RxCntrlMsgBitMask, IoBuffer.InputBuffer, + IoBuffer.InputLength); if (Status) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "copy of control bit mask failed from user space"); + "copy of control bit mask failed from user space"); return -EFAULT; } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "\n Got user defined cntrl msg bit mask :%lx", - RxCntrlMsgBitMask); + "\n Got user defined cntrl msg bit mask :%lx", + RxCntrlMsgBitMask); pTarang->RxCntrlMsgBitMask = RxCntrlMsgBitMask; return Status; @@ -2283,8 +2295,8 @@ static int bcm_char_ioctl_get_device_driver_info(void __user *argp, struct bcm_driver_info DevInfo; struct bcm_ioctl_buffer IoBuffer; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, "Called IOCTL_BCM_GET_DEVICE_DRIVER_INFO\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "Called IOCTL_BCM_GET_DEVICE_DRIVER_INFO\n"); memset(&DevInfo, 0, sizeof(DevInfo)); DevInfo.MaxRDMBufferSize = BUFFER_4K; @@ -2312,7 +2324,7 @@ static int bcm_char_ioctl_time_since_net_entry(void __user *argp, struct bcm_ioctl_buffer IoBuffer; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "IOCTL_BCM_TIME_SINCE_NET_ENTRY called"); + "IOCTL_BCM_TIME_SINCE_NET_ENTRY called"); if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) return -EFAULT; @@ -2324,7 +2336,7 @@ static int bcm_char_ioctl_time_since_net_entry(void __user *argp, get_seconds() - Adapter->liTimeSinceLastNetEntry; if (copy_to_user(IoBuffer.OutputBuffer, &stTimeElapsedSinceNetEntry, - sizeof(struct bcm_time_elapsed))) + sizeof(struct bcm_time_elapsed))) return -EFAULT; return STATUS_SUCCESS; @@ -2403,7 +2415,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) case BCM_LED_THREAD_STATE_CHANGE_REQ: Status = bcm_char_ioctl_led_thread_state_change_req(argp, - Adapter); + Adapter); return Status; case IOCTL_BCM_GPIO_STATUS_REQUEST: @@ -2443,14 +2455,14 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) case IOCTL_BE_BUCKET_SIZE: Status = 0; if (get_user(Adapter->BEBucketSize, - (unsigned long __user *)arg)) + (unsigned long __user *)arg)) Status = -EFAULT; break; case IOCTL_RTPS_BUCKET_SIZE: Status = 0; if (get_user(Adapter->rtPSBucketSize, - (unsigned long __user *)arg)) + (unsigned long __user *)arg)) Status = -EFAULT; break; @@ -2470,7 +2482,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) case IOCTL_GET_PACK_INFO: if (copy_to_user(argp, &Adapter->PackInfo, - sizeof(struct bcm_packet_info)*NO_OF_QUEUES)) + sizeof(struct bcm_packet_info)*NO_OF_QUEUES)) return -EFAULT; Status = STATUS_SUCCESS; break; @@ -2501,7 +2513,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) case IOCTL_BCM_WAKE_UP_DEVICE_FROM_IDLE: if ((false == Adapter->bTriedToWakeUpFromlowPowerMode) && - (TRUE == Adapter->IdleMode)) { + (TRUE == Adapter->IdleMode)) { Adapter->usIdleModePattern = ABORT_IDLE_MODE; Adapter->bWakeUpDevice = TRUE; wake_up(&Adapter->process_rx_cntrlpkt); @@ -2551,7 +2563,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) /* Right Now we are taking care of only DSD */ Adapter->bAllDSDWriteAllow = false; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, - "IOCTL_BCM_IDENTIFY_ACTIVE_SECTION called"); + "IOCTL_BCM_IDENTIFY_ACTIVE_SECTION called"); Status = STATUS_SUCCESS; break; @@ -2584,8 +2596,8 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) return Status; case IOCTL_CLOSE_NOTIFICATION: - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, - DBG_LVL_ALL, "IOCTL_CLOSE_NOTIFICATION"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, + "IOCTL_CLOSE_NOTIFICATION"); break; default: @@ -2619,8 +2631,8 @@ int register_control_device_interface(struct bcm_mini_adapter *Adapter) } Adapter->pstCreatedClassDevice = device_create(bcm_class, NULL, - MKDEV(Adapter->major, 0), - Adapter, DEV_NAME); + MKDEV(Adapter->major, 0), + Adapter, DEV_NAME); if (IS_ERR(Adapter->pstCreatedClassDevice)) { pr_err(DRV_NAME ": class device create failed\n"); -- cgit v1.2.3 From 4c165843ea6ae4d166be5ffc367219a95ffabd4e Mon Sep 17 00:00:00 2001 From: Greg DeAngelis Date: Fri, 2 May 2014 16:40:30 -0400 Subject: staging: bcm: fix lines over 80 characters Signed-off-by: Greg DeAngelis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Transmit.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/staging/bcm/Transmit.c b/drivers/staging/bcm/Transmit.c index 2ed4836b9654..49767468ac23 100644 --- a/drivers/staging/bcm/Transmit.c +++ b/drivers/staging/bcm/Transmit.c @@ -46,12 +46,14 @@ int SendControlPacket(struct bcm_mini_adapter *Adapter, char *pControlPacket) BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Tx"); if (!pControlPacket || !Adapter) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Got NULL Control Packet or Adapter"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, + "Got NULL Control Packet or Adapter"); return STATUS_FAILURE; } if ((atomic_read(&Adapter->CurrNumFreeTxDesc) < ((PLeader->PLength-1)/MAX_DEVICE_DESC_SIZE)+1)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "NO FREE DESCRIPTORS TO SEND CONTROL PACKET"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, + "NO FREE DESCRIPTORS TO SEND CONTROL PACKET"); return STATUS_FAILURE; } @@ -109,7 +111,8 @@ int SetupNextSend(struct bcm_mini_adapter *Adapter, struct sk_buff *Packet, USH (UINT *)&Packet->len, Adapter->PackInfo[QueueIndex].bEthCSSupport); if (status != STATUS_SUCCESS) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "PHS Transmit failed..\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, + "PHS Transmit failed..\n"); goto errExit; } @@ -217,12 +220,15 @@ int tx_pkt_handler(struct bcm_mini_adapter *Adapter /**< pointer to adapter obje Adapter->LinkStatus == SYNC_UP_REQUEST && !Adapter->bSyncUpRequestSent) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Calling LinkMessage"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, + DBG_LVL_ALL, "Calling LinkMessage"); LinkMessage(Adapter); } if ((Adapter->IdleMode || Adapter->bShutStatus) && atomic_read(&Adapter->TotalPacketCount)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Device in Low Power mode...waking up"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, + TX_PACKETS, DBG_LVL_ALL, + "Device in Low Power mode...waking up"); Adapter->usIdleModePattern = ABORT_IDLE_MODE; Adapter->bWakeUpDevice = TRUE; wake_up(&Adapter->process_rx_cntrlpkt); @@ -232,7 +238,8 @@ int tx_pkt_handler(struct bcm_mini_adapter *Adapter /**< pointer to adapter obje atomic_set(&Adapter->TxPktAvail, 0); } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Exiting the tx thread..\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, + "Exiting the tx thread..\n"); Adapter->transmit_packet_thread = NULL; return 0; } -- cgit v1.2.3 From 773e4c41d92c2034ea2db41d4b7036be4c0c616d Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Sun, 4 May 2014 15:45:50 +0800 Subject: staging/lustre: remove Peng Tao from Lustre contact list I am leaving emc for a new company where I cannot have much time working on Lustre. So remove myself from the contact list. I will still be around and continue to contribute as a hobbyist though. Cc: Andreas Dilger Cc: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/TODO | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/TODO b/drivers/staging/lustre/TODO index 0a2b6cb3775e..e325e1e98326 100644 --- a/drivers/staging/lustre/TODO +++ b/drivers/staging/lustre/TODO @@ -9,6 +9,5 @@ * Other minor misc cleanups... Please send any patches to Greg Kroah-Hartman , Andreas Dilger -, Oleg Drokin and -Peng Tao . CCing hpdd-discuss -would be great too. +, Oleg Drokin . CCing +hpdd-discuss would be great too. -- cgit v1.2.3 From e69ae73b62ab9b2831c70af3e4022b385745138e Mon Sep 17 00:00:00 2001 From: Toby Smith Date: Wed, 7 May 2014 16:21:22 +1000 Subject: staging: lustre: fix sparse warning "unexpected unlock" Fix the following warning in lib-eq.c warning: context imbalance in 'lnet_eq_wait_locked' - unexpected unlock Signed-off-by: Toby Smith Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/lnet/lib-eq.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/lustre/lnet/lnet/lib-eq.c b/drivers/staging/lustre/lnet/lnet/lib-eq.c index 7ce07f61b2e1..126984464d90 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-eq.c +++ b/drivers/staging/lustre/lnet/lnet/lib-eq.c @@ -325,6 +325,7 @@ EXPORT_SYMBOL(LNetEQWait); static int lnet_eq_wait_locked(int *timeout_ms) +__must_hold(&the_lnet.ln_eq_wait_lock) { int tms = *timeout_ms; int wait; -- cgit v1.2.3 From 5f5b738480aeacf34cd85e431f3add284410ff40 Mon Sep 17 00:00:00 2001 From: Toby Smith Date: Wed, 7 May 2014 16:21:21 +1000 Subject: staging: lustre: fix sparse warning "should it be static" Fix the following warning in lib-eq.c warning: symbol 'lnet_eq_dequeue_event' was not declared. Should it be static? Signed-off-by: Toby Smith Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/lnet/lib-eq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lnet/lnet/lib-eq.c b/drivers/staging/lustre/lnet/lnet/lib-eq.c index 126984464d90..d25dcd8ba563 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-eq.c +++ b/drivers/staging/lustre/lnet/lnet/lib-eq.c @@ -238,7 +238,7 @@ lnet_eq_enqueue_event(lnet_eq_t *eq, lnet_event_t *ev) lnet_eq_wait_unlock(); } -int +static int lnet_eq_dequeue_event(lnet_eq_t *eq, lnet_event_t *ev) { int new_index = eq->eq_deq_seq & (eq->eq_size - 1); -- cgit v1.2.3 From 114a16b1ba918cd8390daaaaf8d5b02f253c97b2 Mon Sep 17 00:00:00 2001 From: Brilliantov Kirill Vladimirovich Date: Fri, 9 May 2014 14:49:24 +0400 Subject: staging/lustre: fix sparse warning: Using plain integer as NULL pointer Signed-off-by: Brilliantov Kirill Vladimirovich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/osc/lproc_osc.c | 68 +++++++++++++-------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 358e32cd05d2..0cadfcd92262 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -525,44 +525,44 @@ LPROC_SEQ_FOPS_RW_TYPE(osc, import); LPROC_SEQ_FOPS_RW_TYPE(osc, pinger_recov); static struct lprocfs_vars lprocfs_osc_obd_vars[] = { - { "uuid", &osc_uuid_fops, 0, 0 }, - { "ping", &osc_ping_fops, 0, 0222 }, - { "connect_flags", &osc_connect_flags_fops, 0, 0 }, - { "blocksize", &osc_blksize_fops, 0, 0 }, - { "kbytestotal", &osc_kbytestotal_fops, 0, 0 }, - { "kbytesfree", &osc_kbytesfree_fops, 0, 0 }, - { "kbytesavail", &osc_kbytesavail_fops, 0, 0 }, - { "filestotal", &osc_filestotal_fops, 0, 0 }, - { "filesfree", &osc_filesfree_fops, 0, 0 }, - //{ "filegroups", lprocfs_rd_filegroups, 0, 0 }, - { "ost_server_uuid", &osc_server_uuid_fops, 0, 0 }, - { "ost_conn_uuid", &osc_conn_uuid_fops, 0, 0 }, - { "active", &osc_active_fops, 0 }, - { "max_pages_per_rpc", &osc_obd_max_pages_per_rpc_fops, 0 }, - { "max_rpcs_in_flight", &osc_max_rpcs_in_flight_fops, 0 }, - { "destroys_in_flight", &osc_destroys_in_flight_fops, 0, 0 }, - { "max_dirty_mb", &osc_max_dirty_mb_fops, 0 }, - { "osc_cached_mb", &osc_cached_mb_fops, 0 }, - { "cur_dirty_bytes", &osc_cur_dirty_bytes_fops, 0, 0 }, - { "cur_grant_bytes", &osc_cur_grant_bytes_fops, 0 }, - { "cur_lost_grant_bytes", &osc_cur_lost_grant_bytes_fops, 0, 0}, - { "grant_shrink_interval", &osc_grant_shrink_interval_fops, 0 }, - { "checksums", &osc_checksum_fops, 0 }, - { "checksum_type", &osc_checksum_type_fops, 0 }, - { "resend_count", &osc_resend_count_fops, 0}, - { "timeouts", &osc_timeouts_fops, 0, 0 }, - { "contention_seconds", &osc_contention_seconds_fops, 0 }, - { "lockless_truncate", &osc_lockless_truncate_fops, 0 }, - { "import", &osc_import_fops, 0 }, - { "state", &osc_state_fops, 0, 0 }, - { "pinger_recov", &osc_pinger_recov_fops, 0 }, - { 0 } + { "uuid", &osc_uuid_fops, NULL, 0 }, + { "ping", &osc_ping_fops, NULL, 0222 }, + { "connect_flags", &osc_connect_flags_fops, NULL, 0 }, + { "blocksize", &osc_blksize_fops, NULL, 0 }, + { "kbytestotal", &osc_kbytestotal_fops, NULL, 0 }, + { "kbytesfree", &osc_kbytesfree_fops, NULL, 0 }, + { "kbytesavail", &osc_kbytesavail_fops, NULL, 0 }, + { "filestotal", &osc_filestotal_fops, NULL, 0 }, + { "filesfree", &osc_filesfree_fops, NULL, 0 }, + /*{ "filegroups", lprocfs_rd_filegroups, NULL, 0 },*/ + { "ost_server_uuid", &osc_server_uuid_fops, NULL, 0 }, + { "ost_conn_uuid", &osc_conn_uuid_fops, NULL, 0 }, + { "active", &osc_active_fops, NULL }, + { "max_pages_per_rpc", &osc_obd_max_pages_per_rpc_fops, NULL }, + { "max_rpcs_in_flight", &osc_max_rpcs_in_flight_fops, NULL }, + { "destroys_in_flight", &osc_destroys_in_flight_fops, NULL, 0 }, + { "max_dirty_mb", &osc_max_dirty_mb_fops, NULL }, + { "osc_cached_mb", &osc_cached_mb_fops, NULL }, + { "cur_dirty_bytes", &osc_cur_dirty_bytes_fops, NULL, 0 }, + { "cur_grant_bytes", &osc_cur_grant_bytes_fops, NULL }, + { "cur_lost_grant_bytes", &osc_cur_lost_grant_bytes_fops, NULL, 0}, + { "grant_shrink_interval", &osc_grant_shrink_interval_fops, NULL }, + { "checksums", &osc_checksum_fops, NULL }, + { "checksum_type", &osc_checksum_type_fops, NULL }, + { "resend_count", &osc_resend_count_fops, NULL}, + { "timeouts", &osc_timeouts_fops, NULL, 0 }, + { "contention_seconds", &osc_contention_seconds_fops, NULL }, + { "lockless_truncate", &osc_lockless_truncate_fops, NULL }, + { "import", &osc_import_fops, NULL }, + { "state", &osc_state_fops, NULL, 0 }, + { "pinger_recov", &osc_pinger_recov_fops, NULL }, + { NULL } }; LPROC_SEQ_FOPS_RO_TYPE(osc, numrefs); static struct lprocfs_vars lprocfs_osc_module_vars[] = { - { "num_refs", &osc_numrefs_fops, 0, 0 }, - { 0 } + { "num_refs", &osc_numrefs_fops, NULL, 0 }, + { NULL } }; #define pct(a,b) (b ? a * 100 / b : 0) -- cgit v1.2.3 From a8046a28c84e0d7c377f5a3e605c9f6ddfc50dbd Mon Sep 17 00:00:00 2001 From: Zi Shen Lim Date: Sun, 11 May 2014 20:37:23 -0700 Subject: staging/lustre: fix sparse warnings in o2iblnd_cb.c This patch fixes the following sparse warnings: drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:44:1: warning: symbol 'kiblnd_tx_done' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:102:10: warning: symbol 'kiblnd_get_idle_tx' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:131:1: warning: symbol 'kiblnd_drop_rx' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:212:10: warning: symbol 'kiblnd_find_waiting_tx_locked' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:238:1: warning: symbol 'kiblnd_handle_completion' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:277:1: warning: symbol 'kiblnd_send_completion' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:296:1: warning: symbol 'kiblnd_handle_rx' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:457:1: warning: symbol 'kiblnd_rx_complete' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:527:13: warning: symbol 'kiblnd_kvaddr_to_page' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:699:1: warning: symbol 'kiblnd_setup_rd_iov' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:752:1: warning: symbol 'kiblnd_setup_rd_kiov' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:792:1: warning: symbol 'kiblnd_post_tx_locked' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:996:1: warning: symbol 'kiblnd_tx_complete' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:1270:1: warning: symbol 'kiblnd_connect_peer' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:1627:1: warning: symbol 'kiblnd_reply' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:1814:1: warning: symbol 'kiblnd_thread_fini' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:1828:1: warning: symbol 'kiblnd_peer_notify' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:1934:1: warning: symbol 'kiblnd_handle_early_rxs' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:1957:1: warning: symbol 'kiblnd_abort_txs' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:1993:1: warning: symbol 'kiblnd_finalise_conn' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:2167:1: warning: symbol 'kiblnd_reject' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:2178:1: warning: symbol 'kiblnd_passive_connect' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:2452:1: warning: symbol 'kiblnd_reconnect' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:2516:1: warning: symbol 'kiblnd_rejected' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:2655:1: warning: symbol 'kiblnd_check_connreply' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:2754:1: warning: symbol 'kiblnd_active_connect' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:3025:1: warning: symbol 'kiblnd_check_conns' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:3108:1: warning: symbol 'kiblnd_disconnect_conn' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:3247:1: warning: symbol 'kiblnd_complete' was not declared. Should it be static? drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c:904:20: warning: context imbalance in 'kiblnd_post_tx_locked' - unexpected unlock Signed-off-by: Zi Shen Lim Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 60 +++++++++++----------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c index 9bf6c949f5db..dfd16e7ca8a2 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -40,7 +40,7 @@ #include "o2iblnd.h" -void +static void kiblnd_tx_done (lnet_ni_t *ni, kib_tx_t *tx) { lnet_msg_t *lntmsg[2]; @@ -99,7 +99,7 @@ kiblnd_txlist_done (lnet_ni_t *ni, struct list_head *txlist, int status) } } -kib_tx_t * +static kib_tx_t * kiblnd_get_idle_tx(lnet_ni_t *ni, lnet_nid_t target) { kib_net_t *net = (kib_net_t *)ni->ni_data; @@ -127,7 +127,7 @@ kiblnd_get_idle_tx(lnet_ni_t *ni, lnet_nid_t target) return tx; } -void +static void kiblnd_drop_rx(kib_rx_t *rx) { kib_conn_t *conn = rx->rx_conn; @@ -209,7 +209,7 @@ kiblnd_post_rx (kib_rx_t *rx, int credit) return 0; } -kib_tx_t * +static kib_tx_t * kiblnd_find_waiting_tx_locked(kib_conn_t *conn, int txtype, __u64 cookie) { struct list_head *tmp; @@ -234,7 +234,7 @@ kiblnd_find_waiting_tx_locked(kib_conn_t *conn, int txtype, __u64 cookie) return NULL; } -void +static void kiblnd_handle_completion(kib_conn_t *conn, int txtype, int status, __u64 cookie) { kib_tx_t *tx; @@ -273,7 +273,7 @@ kiblnd_handle_completion(kib_conn_t *conn, int txtype, int status, __u64 cookie) kiblnd_tx_done(ni, tx); } -void +static void kiblnd_send_completion(kib_conn_t *conn, int type, int status, __u64 cookie) { lnet_ni_t *ni = conn->ibc_peer->ibp_ni; @@ -292,7 +292,7 @@ kiblnd_send_completion(kib_conn_t *conn, int type, int status, __u64 cookie) kiblnd_queue_tx(tx, conn); } -void +static void kiblnd_handle_rx (kib_rx_t *rx) { kib_msg_t *msg = rx->rx_msg; @@ -453,7 +453,7 @@ kiblnd_handle_rx (kib_rx_t *rx) kiblnd_post_rx(rx, post_credit); } -void +static void kiblnd_rx_complete (kib_rx_t *rx, int status, int nob) { kib_msg_t *msg = rx->rx_msg; @@ -524,7 +524,7 @@ kiblnd_rx_complete (kib_rx_t *rx, int status, int nob) kiblnd_drop_rx(rx); /* Don't re-post rx. */ } -struct page * +static struct page * kiblnd_kvaddr_to_page (unsigned long vaddr) { struct page *page; @@ -695,7 +695,7 @@ kiblnd_map_tx(lnet_ni_t *ni, kib_tx_t *tx, } -int +static int kiblnd_setup_rd_iov(lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd, unsigned int niov, struct iovec *iov, int offset, int nob) { @@ -748,7 +748,7 @@ kiblnd_setup_rd_iov(lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd, return kiblnd_map_tx(ni, tx, rd, sg - tx->tx_frags); } -int +static int kiblnd_setup_rd_kiov (lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd, int nkiov, lnet_kiov_t *kiov, int offset, int nob) { @@ -788,8 +788,10 @@ kiblnd_setup_rd_kiov (lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd, return kiblnd_map_tx(ni, tx, rd, sg - tx->tx_frags); } -int +static int kiblnd_post_tx_locked (kib_conn_t *conn, kib_tx_t *tx, int credit) + __releases(conn->ibc_lock) + __acquires(conn->ibc_lock) { kib_msg_t *msg = tx->tx_msg; kib_peer_t *peer = conn->ibc_peer; @@ -992,7 +994,7 @@ kiblnd_check_sends (kib_conn_t *conn) kiblnd_conn_decref(conn); /* ...until here */ } -void +static void kiblnd_tx_complete (kib_tx_t *tx, int status) { int failed = (status != IB_WC_SUCCESS); @@ -1266,7 +1268,7 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid, return rc; } -void +static void kiblnd_connect_peer (kib_peer_t *peer) { struct rdma_cm_id *cmid; @@ -1623,7 +1625,7 @@ kiblnd_send (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg) return 0; } -void +static void kiblnd_reply (lnet_ni_t *ni, kib_rx_t *rx, lnet_msg_t *lntmsg) { lnet_process_id_t target = lntmsg->msg_target; @@ -1810,7 +1812,7 @@ kiblnd_thread_start(int (*fn)(void *arg), void *arg, char *name) return 0; } -void +static void kiblnd_thread_fini (void) { atomic_dec (&kiblnd_data.kib_nthreads); @@ -1824,7 +1826,7 @@ kiblnd_peer_alive (kib_peer_t *peer) mb(); } -void +static void kiblnd_peer_notify (kib_peer_t *peer) { int error = 0; @@ -1930,7 +1932,7 @@ kiblnd_close_conn(kib_conn_t *conn, int error) write_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags); } -void +static void kiblnd_handle_early_rxs(kib_conn_t *conn) { unsigned long flags; @@ -1953,7 +1955,7 @@ kiblnd_handle_early_rxs(kib_conn_t *conn) write_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags); } -void +static void kiblnd_abort_txs(kib_conn_t *conn, struct list_head *txs) { LIST_HEAD (zombies); @@ -1989,7 +1991,7 @@ kiblnd_abort_txs(kib_conn_t *conn, struct list_head *txs) kiblnd_txlist_done(conn->ibc_peer->ibp_ni, &zombies, -ECONNABORTED); } -void +static void kiblnd_finalise_conn (kib_conn_t *conn) { LASSERT (!in_interrupt()); @@ -2163,7 +2165,7 @@ kiblnd_connreq_done(kib_conn_t *conn, int status) kiblnd_handle_early_rxs(conn); } -void +static void kiblnd_reject(struct rdma_cm_id *cmid, kib_rej_t *rej) { int rc; @@ -2174,7 +2176,7 @@ kiblnd_reject(struct rdma_cm_id *cmid, kib_rej_t *rej) CWARN("Error %d sending reject\n", rc); } -int +static int kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob) { rwlock_t *g_lock = &kiblnd_data.kib_global_lock; @@ -2448,7 +2450,7 @@ kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob) return -ECONNREFUSED; } -void +static void kiblnd_reconnect (kib_conn_t *conn, int version, __u64 incarnation, int why, kib_connparams_t *cp) { @@ -2512,7 +2514,7 @@ kiblnd_reconnect (kib_conn_t *conn, int version, kiblnd_connect_peer(peer); } -void +static void kiblnd_rejected (kib_conn_t *conn, int reason, void *priv, int priv_nob) { kib_peer_t *peer = conn->ibc_peer; @@ -2651,7 +2653,7 @@ kiblnd_rejected (kib_conn_t *conn, int reason, void *priv, int priv_nob) kiblnd_connreq_done(conn, -ECONNREFUSED); } -void +static void kiblnd_check_connreply (kib_conn_t *conn, void *priv, int priv_nob) { kib_peer_t *peer = conn->ibc_peer; @@ -2750,7 +2752,7 @@ kiblnd_check_connreply (kib_conn_t *conn, void *priv, int priv_nob) kiblnd_connreq_done(conn, 0); } -int +static int kiblnd_active_connect (struct rdma_cm_id *cmid) { kib_peer_t *peer = (kib_peer_t *)cmid->context; @@ -3021,7 +3023,7 @@ kiblnd_conn_timed_out_locked(kib_conn_t *conn) kiblnd_check_txs_locked(conn, &conn->ibc_active_txs); } -void +static void kiblnd_check_conns (int idx) { LIST_HEAD (closes); @@ -3104,7 +3106,7 @@ kiblnd_check_conns (int idx) } } -void +static void kiblnd_disconnect_conn (kib_conn_t *conn) { LASSERT (!in_interrupt()); @@ -3243,7 +3245,7 @@ kiblnd_qp_event(struct ib_event *event, void *arg) } } -void +static void kiblnd_complete (struct ib_wc *wc) { switch (kiblnd_wreqid2type(wc->wr_id)) { -- cgit v1.2.3 From a1f659d41eadc9a90b096ca8b330eb72c5555fe5 Mon Sep 17 00:00:00 2001 From: Masaru Nomura Date: Wed, 14 May 2014 22:33:37 +0100 Subject: staging: lustre: socklnd: Remove unnecessary () from return statement Remove unnecessary brackets from return statements in socklnd.c to meet kernel coding style. Signed-off-by: Masaru Nomura Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 42 +++++++++++----------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index a391d134787b..ab19934f2f50 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -58,10 +58,10 @@ ksocknal_ip2iface(lnet_ni_t *ni, __u32 ip) iface = &net->ksnn_interfaces[i]; if (iface->ksni_ipaddr == ip) - return (iface); + return iface; } - return (NULL); + return NULL; } ksock_route_t * @@ -71,7 +71,7 @@ ksocknal_create_route (__u32 ipaddr, int port) LIBCFS_ALLOC (route, sizeof (*route)); if (route == NULL) - return (NULL); + return NULL; atomic_set (&route->ksnr_refcount, 1); route->ksnr_peer = NULL; @@ -85,7 +85,7 @@ ksocknal_create_route (__u32 ipaddr, int port) route->ksnr_conn_count = 0; route->ksnr_share_count = 0; - return (route); + return route; } void @@ -197,9 +197,9 @@ ksocknal_find_peer_locked (lnet_ni_t *ni, lnet_process_id_t id) CDEBUG(D_NET, "got peer [%p] -> %s (%d)\n", peer, libcfs_id2str(id), atomic_read(&peer->ksnp_refcount)); - return (peer); + return peer; } - return (NULL); + return NULL; } ksock_peer_t * @@ -213,7 +213,7 @@ ksocknal_find_peer (lnet_ni_t *ni, lnet_process_id_t id) ksocknal_peer_addref(peer); read_unlock(&ksocknal_data.ksnd_global_lock); - return (peer); + return peer; } void @@ -318,7 +318,7 @@ ksocknal_get_peer_info (lnet_ni_t *ni, int index, } out: read_unlock(&ksocknal_data.ksnd_global_lock); - return (rc); + return rc; } void @@ -506,7 +506,7 @@ ksocknal_add_peer (lnet_ni_t *ni, lnet_process_id_t id, __u32 ipaddr, int port) write_unlock_bh(&ksocknal_data.ksnd_global_lock); - return (0); + return 0; } void @@ -620,7 +620,7 @@ ksocknal_del_peer (lnet_ni_t *ni, lnet_process_id_t id, __u32 ip) ksocknal_txlist_done(ni, &zombies, 1); - return (rc); + return rc; } ksock_conn_t * @@ -652,13 +652,13 @@ ksocknal_get_conn_by_idx (lnet_ni_t *ni, int index) ksocknal_conn_addref(conn); read_unlock(&ksocknal_data. \ ksnd_global_lock); - return (conn); + return conn; } } } read_unlock(&ksocknal_data.ksnd_global_lock); - return (NULL); + return NULL; } ksock_sched_t * @@ -709,7 +709,7 @@ ksocknal_local_ipvec (lnet_ni_t *ni, __u32 *ipaddrs) } read_unlock(&ksocknal_data.ksnd_global_lock); - return (nip); + return nip; } int @@ -741,7 +741,7 @@ ksocknal_match_peerip (ksock_interface_t *iface, __u32 *ips, int nips) } LASSERT (best >= 0); - return (best); + return best; } int @@ -843,7 +843,7 @@ ksocknal_select_ips(ksock_peer_t *peer, __u32 *peerips, int n_peerips) write_unlock_bh(global_lock); - return (n_ips); + return n_ips; } void @@ -1705,7 +1705,7 @@ ksocknal_close_peer_conns_locked (ksock_peer_t *peer, __u32 ipaddr, int why) } } - return (count); + return count; } int @@ -1721,7 +1721,7 @@ ksocknal_close_conn_and_siblings (ksock_conn_t *conn, int why) write_unlock_bh(&ksocknal_data.ksnd_global_lock); - return (count); + return count; } int @@ -1762,7 +1762,7 @@ ksocknal_close_matching_conns (lnet_process_id_t id, __u32 ipaddr) /* wildcards always succeed */ if (id.nid == LNET_NID_ANY || id.pid == LNET_PID_ANY || ipaddr == 0) - return (0); + return 0; if (count == 0) return -ENOENT; @@ -1933,7 +1933,7 @@ ksocknal_push (lnet_ni_t *ni, lnet_process_id_t id) } - return (rc); + return rc; } int @@ -1995,7 +1995,7 @@ ksocknal_add_interface(lnet_ni_t *ni, __u32 ipaddress, __u32 netmask) write_unlock_bh(&ksocknal_data.ksnd_global_lock); - return (rc); + return rc; } void @@ -2084,7 +2084,7 @@ ksocknal_del_interface(lnet_ni_t *ni, __u32 ipaddress) write_unlock_bh(&ksocknal_data.ksnd_global_lock); - return (rc); + return rc; } int -- cgit v1.2.3 From 991cc8d611136913bc1f3eabaa07a197865efcb1 Mon Sep 17 00:00:00 2001 From: Masaru Nomura Date: Thu, 15 May 2014 00:53:38 +0100 Subject: staging: lustre: socklnd: Add a required space Added a required space before open brace and parenthsis in socklnd.c to meet kernel coding style. Signed-off-by: Masaru Nomura Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index ab19934f2f50..538b00b13109 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -1567,7 +1567,7 @@ ksocknal_terminate_conn (ksock_conn_t *conn) conn->ksnc_tx_ready = 1; if (!conn->ksnc_tx_scheduled && - !list_empty(&conn->ksnc_tx_queue)){ + !list_empty(&conn->ksnc_tx_queue)) { list_add_tail (&conn->ksnc_tx_list, &sched->kss_tx_conns); conn->ksnc_tx_scheduled = 1; @@ -2094,7 +2094,7 @@ ksocknal_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg) struct libcfs_ioctl_data *data = arg; int rc; - switch(cmd) { + switch (cmd) { case IOC_LIBCFS_GET_INTERFACE: { ksock_net_t *net = ni->ni_data; ksock_interface_t *iface; -- cgit v1.2.3 From a10f33e960f0acd420f3558f7f094c56a6d9b7e9 Mon Sep 17 00:00:00 2001 From: Masaru Nomura Date: Thu, 15 May 2014 01:03:42 +0100 Subject: staging: lustre: socklnd: Fix indenting Fixed indenting of if statement in socklnd.c to meet kernel coding style. Signed-off-by: Masaru Nomura Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index 538b00b13109..b0dbd5398a00 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -2510,7 +2510,8 @@ ksocknal_debug_peerhash (lnet_ni_t *ni) list_for_each (tmp, &ksocknal_data.ksnd_peers[i]) { peer = list_entry (tmp, ksock_peer_t, ksnp_list); - if (peer->ksnp_ni == ni) break; + if (peer->ksnp_ni == ni) + break; peer = NULL; } -- cgit v1.2.3 From 4b18c358e1f8355d620cc29fbe06db80e804761f Mon Sep 17 00:00:00 2001 From: Masaru Nomura Date: Thu, 15 May 2014 16:23:56 +0100 Subject: staging: lustre: socklnd: Remove unnecessary line continuation Remove unnecessary line continuation '\' in socklnd.c to meet kernel coding style. Signed-off-by: Masaru Nomura Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index b0dbd5398a00..ed95169d709c 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -650,8 +650,7 @@ ksocknal_get_conn_by_idx (lnet_ni_t *ni, int index) conn = list_entry (ctmp, ksock_conn_t, ksnc_list); ksocknal_conn_addref(conn); - read_unlock(&ksocknal_data. \ - ksnd_global_lock); + read_unlock(&ksocknal_data.ksnd_global_lock); return conn; } } @@ -2295,12 +2294,12 @@ ksocknal_base_shutdown(void) for (j = 0; j < info->ksi_nthreads_max; j++) { sched = &info->ksi_scheds[j]; - LASSERT(list_empty(&sched->\ - kss_tx_conns)); - LASSERT(list_empty(&sched->\ - kss_rx_conns)); - LASSERT(list_empty(&sched-> \ - kss_zombie_noop_txs)); + LASSERT(list_empty( + &sched->kss_tx_conns)); + LASSERT(list_empty( + &sched->kss_rx_conns)); + LASSERT(list_empty( + &sched->kss_zombie_noop_txs)); LASSERT(sched->kss_nconns == 0); } } @@ -2680,8 +2679,8 @@ ksocknal_search_new_ipif(ksock_net_t *net) list_for_each_entry(tmp, &ksocknal_data.ksnd_nets, ksnn_list) { for (j = 0; !found && j < tmp->ksnn_ninterfaces; j++) { - char *ifnam2 = &tmp->ksnn_interfaces[j].\ - ksni_name[0]; + char *ifnam2 = + &tmp->ksnn_interfaces[j].ksni_name[0]; char *colon2 = strchr(ifnam2, ':'); if (colon2 != NULL) -- cgit v1.2.3 From 71397095763ca7f6b71a7193882eefb16d672928 Mon Sep 17 00:00:00 2001 From: Masaru Nomura Date: Thu, 15 May 2014 18:54:05 +0100 Subject: staging: lustre: socklnd: Remove unnecessary return brackets Remove unnecessary brackets from return statements in socklnd.c, socklnd.h, socklnd_cb.c and socklnd_lib-linux.c to meet kernel coding style. Signed-off-by: Masaru Nomura Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 6 +- .../staging/lustre/lnet/klnds/socklnd/socklnd.h | 4 +- .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 82 +++++++++++----------- .../lustre/lnet/klnds/socklnd/socklnd_lib-linux.c | 26 +++---- 4 files changed, 59 insertions(+), 59 deletions(-) diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index ed95169d709c..775dcd29c200 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -459,7 +459,7 @@ ksocknal_add_peer (lnet_ni_t *ni, lnet_process_id_t id, __u32 ipaddr, int port) if (id.nid == LNET_NID_ANY || id.pid == LNET_PID_ANY) - return (-EINVAL); + return -EINVAL; /* Have a brand new peer ready... */ rc = ksocknal_create_peer(&peer, ni, id); @@ -469,7 +469,7 @@ ksocknal_add_peer (lnet_ni_t *ni, lnet_process_id_t id, __u32 ipaddr, int port) route = ksocknal_create_route (ipaddr, port); if (route == NULL) { ksocknal_peer_decref(peer); - return (-ENOMEM); + return -ENOMEM; } write_lock_bh(&ksocknal_data.ksnd_global_lock); @@ -1950,7 +1950,7 @@ ksocknal_add_interface(lnet_ni_t *ni, __u32 ipaddress, __u32 netmask) if (ipaddress == 0 || netmask == 0) - return (-EINVAL); + return -EINVAL; write_lock_bh(&ksocknal_data.ksnd_global_lock); diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h index df2be7a7f46e..109a23932471 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h @@ -418,7 +418,7 @@ ksocknal_nid2peerlist (lnet_nid_t nid) { unsigned int hash = ((unsigned int)nid) % ksocknal_data.ksnd_peer_hash_size; - return (&ksocknal_data.ksnd_peers [hash]); + return &ksocknal_data.ksnd_peers[hash]; } static inline void @@ -452,7 +452,7 @@ ksocknal_connsock_addref (ksock_conn_t *conn) } read_unlock(&ksocknal_data.ksnd_global_lock); - return (rc); + return rc; } static inline void diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c index bdf95ea8a54d..75bd6583493e 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c @@ -120,7 +120,7 @@ ksocknal_send_iov (ksock_conn_t *conn, ksock_tx_t *tx) rc = ksocknal_lib_send_iov(conn, tx); if (rc <= 0) /* sent nothing? */ - return (rc); + return rc; nob = rc; LASSERT (nob <= tx->tx_resid); @@ -133,7 +133,7 @@ ksocknal_send_iov (ksock_conn_t *conn, ksock_tx_t *tx) if (nob < (int) iov->iov_len) { iov->iov_base = (void *)((char *)iov->iov_base + nob); iov->iov_len -= nob; - return (rc); + return rc; } nob -= iov->iov_len; @@ -141,7 +141,7 @@ ksocknal_send_iov (ksock_conn_t *conn, ksock_tx_t *tx) tx->tx_niov--; } while (nob != 0); - return (rc); + return rc; } int @@ -158,7 +158,7 @@ ksocknal_send_kiov (ksock_conn_t *conn, ksock_tx_t *tx) rc = ksocknal_lib_send_kiov(conn, tx); if (rc <= 0) /* sent nothing? */ - return (rc); + return rc; nob = rc; LASSERT (nob <= tx->tx_resid); @@ -179,7 +179,7 @@ ksocknal_send_kiov (ksock_conn_t *conn, ksock_tx_t *tx) tx->tx_nkiov--; } while (nob != 0); - return (rc); + return rc; } int @@ -198,7 +198,7 @@ ksocknal_transmit (ksock_conn_t *conn, ksock_tx_t *tx) rc = ksocknal_connsock_addref(conn); if (rc != 0) { LASSERT (conn->ksnc_closing); - return (-ESHUTDOWN); + return -ESHUTDOWN; } do { @@ -245,7 +245,7 @@ ksocknal_transmit (ksock_conn_t *conn, ksock_tx_t *tx) } while (tx->tx_resid != 0); ksocknal_connsock_decref(conn); - return (rc); + return rc; } int @@ -262,7 +262,7 @@ ksocknal_recv_iov (ksock_conn_t *conn) rc = ksocknal_lib_recv_iov(conn); if (rc <= 0) - return (rc); + return rc; /* received something... */ nob = rc; @@ -282,7 +282,7 @@ ksocknal_recv_iov (ksock_conn_t *conn) if (nob < (int)iov->iov_len) { iov->iov_len -= nob; iov->iov_base = (void *)((char *)iov->iov_base + nob); - return (-EAGAIN); + return -EAGAIN; } nob -= iov->iov_len; @@ -290,7 +290,7 @@ ksocknal_recv_iov (ksock_conn_t *conn) conn->ksnc_rx_niov--; } while (nob != 0); - return (rc); + return rc; } int @@ -306,7 +306,7 @@ ksocknal_recv_kiov (ksock_conn_t *conn) rc = ksocknal_lib_recv_kiov(conn); if (rc <= 0) - return (rc); + return rc; /* received something... */ nob = rc; @@ -353,7 +353,7 @@ ksocknal_receive (ksock_conn_t *conn) rc = ksocknal_connsock_addref(conn); if (rc != 0) { LASSERT (conn->ksnc_closing); - return (-ESHUTDOWN); + return -ESHUTDOWN; } for (;;) { @@ -515,11 +515,11 @@ ksocknal_process_transmit (ksock_conn_t *conn, ksock_tx_t *tx) /* Sent everything OK */ LASSERT (rc == 0); - return (0); + return 0; } if (rc == -EAGAIN) - return (rc); + return rc; if (rc == -ENOMEM) { static int counter; @@ -542,7 +542,7 @@ ksocknal_process_transmit (ksock_conn_t *conn, ksock_tx_t *tx) wake_up (&ksocknal_data.ksnd_reaper_waitq); spin_unlock_bh(&ksocknal_data.ksnd_reaper_lock); - return (rc); + return rc; } /* Actual error */ @@ -576,7 +576,7 @@ ksocknal_process_transmit (ksock_conn_t *conn, ksock_tx_t *tx) ksocknal_close_conn_and_siblings (conn, (conn->ksnc_closing) ? 0 : rc); - return (rc); + return rc; } void @@ -808,10 +808,10 @@ ksocknal_find_connectable_route_locked (ksock_peer_t *peer) continue; } - return (route); + return route; } - return (NULL); + return NULL; } ksock_route_t * @@ -826,10 +826,10 @@ ksocknal_find_connecting_route_locked (ksock_peer_t *peer) LASSERT (!route->ksnr_connecting || route->ksnr_scheduled); if (route->ksnr_scheduled) - return (route); + return route; } - return (NULL); + return NULL; } int @@ -857,7 +857,7 @@ ksocknal_launch_packet (lnet_ni_t *ni, ksock_tx_t *tx, lnet_process_id_t id) * connection... */ ksocknal_queue_tx_locked (tx, conn); read_unlock(g_lock); - return (0); + return 0; } } } @@ -901,7 +901,7 @@ ksocknal_launch_packet (lnet_ni_t *ni, ksock_tx_t *tx, lnet_process_id_t id) /* Connection exists; queue message on it */ ksocknal_queue_tx_locked (tx, conn); write_unlock_bh(g_lock); - return (0); + return 0; } if (peer->ksnp_accepting > 0 || @@ -920,7 +920,7 @@ ksocknal_launch_packet (lnet_ni_t *ni, ksock_tx_t *tx, lnet_process_id_t id) /* NB Routes may be ignored if connections to them failed recently */ CNETERR("No usable routes to %s\n", libcfs_id2str(id)); - return (-EHOSTUNREACH); + return -EHOSTUNREACH; } int @@ -965,7 +965,7 @@ ksocknal_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg) type, desc_size); if (lntmsg->msg_vmflush) cfs_memory_pressure_restore(mpflag); - return (-ENOMEM); + return -ENOMEM; } tx->tx_conn = NULL; /* set when assigned a conn */ @@ -999,10 +999,10 @@ ksocknal_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg) cfs_memory_pressure_restore(mpflag); if (rc == 0) - return (0); + return 0; ksocknal_free_tx(tx); - return (-EIO); + return -EIO; } int @@ -1078,7 +1078,7 @@ ksocknal_new_packet (ksock_conn_t *conn, int nob_to_skip) conn->ksnc_rx_kiov = NULL; conn->ksnc_rx_nkiov = 0; conn->ksnc_rx_csum = ~0; - return (1); + return 1; } /* Set up to skip as much as possible now. If there's more left @@ -1106,7 +1106,7 @@ ksocknal_new_packet (ksock_conn_t *conn, int nob_to_skip) conn->ksnc_rx_kiov = NULL; conn->ksnc_rx_nkiov = 0; conn->ksnc_rx_nob_wanted = skipped; - return (0); + return 0; } int @@ -1153,7 +1153,7 @@ ksocknal_process_receive (ksock_conn_t *conn) if (conn->ksnc_rx_nob_wanted != 0) { /* short read */ - return (-EAGAIN); + return -EAGAIN; } } switch (conn->ksnc_rx_state) { @@ -1172,7 +1172,7 @@ ksocknal_process_receive (ksock_conn_t *conn) conn->ksnc_msg.ksm_type); ksocknal_new_packet(conn, 0); ksocknal_close_conn_and_siblings(conn, -EPROTO); - return (-EPROTO); + return -EPROTO; } if (conn->ksnc_msg.ksm_type == KSOCK_MSG_NOOP && @@ -1184,7 +1184,7 @@ ksocknal_process_receive (ksock_conn_t *conn) conn->ksnc_msg.ksm_csum, conn->ksnc_rx_csum); ksocknal_new_packet(conn, 0); ksocknal_close_conn_and_siblings(conn, -EPROTO); - return (-EIO); + return -EIO; } if (conn->ksnc_msg.ksm_zc_cookies[1] != 0) { @@ -1204,7 +1204,7 @@ ksocknal_process_receive (ksock_conn_t *conn) cookie, conn->ksnc_msg.ksm_zc_cookies[1]); ksocknal_new_packet(conn, 0); ksocknal_close_conn_and_siblings(conn, -EPROTO); - return (rc); + return rc; } } @@ -1252,7 +1252,7 @@ ksocknal_process_receive (ksock_conn_t *conn) ksocknal_new_packet(conn, 0); ksocknal_close_conn_and_siblings (conn, rc); ksocknal_conn_decref(conn); - return (-EPROTO); + return -EPROTO; } /* I'm racing with ksocknal_recv() */ @@ -1295,7 +1295,7 @@ ksocknal_process_receive (ksock_conn_t *conn) if (rc != 0) { ksocknal_new_packet(conn, 0); ksocknal_close_conn_and_siblings (conn, rc); - return (-EPROTO); + return -EPROTO; } /* Fall through */ @@ -1311,7 +1311,7 @@ ksocknal_process_receive (ksock_conn_t *conn) /* Not Reached */ LBUG (); - return (-EINVAL); /* keep gcc happy */ + return -EINVAL; /* keep gcc happy */ } int @@ -1679,13 +1679,13 @@ ksocknal_invert_type(int type) { case SOCKLND_CONN_ANY: case SOCKLND_CONN_CONTROL: - return (type); + return type; case SOCKLND_CONN_BULK_IN: return SOCKLND_CONN_BULK_OUT; case SOCKLND_CONN_BULK_OUT: return SOCKLND_CONN_BULK_IN; default: - return (SOCKLND_CONN_NONE); + return SOCKLND_CONN_NONE; } } @@ -2291,7 +2291,7 @@ ksocknal_find_timed_out_conn (ksock_peer_t *peer) break; } - return (conn); + return conn; } if (conn->ksnc_rx_started && @@ -2307,7 +2307,7 @@ ksocknal_find_timed_out_conn (ksock_peer_t *peer) conn->ksnc_rx_state, conn->ksnc_rx_nob_wanted, conn->ksnc_rx_nob_left); - return (conn); + return conn; } if ((!list_empty(&conn->ksnc_tx_queue) || @@ -2322,11 +2322,11 @@ ksocknal_find_timed_out_conn (ksock_peer_t *peer) libcfs_id2str(peer->ksnp_id), &conn->ksnc_ipaddr, conn->ksnc_port); - return (conn); + return conn; } } - return (NULL); + return NULL; } static inline void diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c index 82b7d9f2862c..d18bab19cd9a 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c @@ -380,7 +380,7 @@ ksocknal_lib_recv_kiov (ksock_conn_t *conn) kunmap(kiov[i].kiov_page); } - return (rc); + return rc; } void @@ -433,7 +433,7 @@ ksocknal_lib_get_conn_tunables (ksock_conn_t *conn, int *txmem, int *rxmem, int if (rc != 0) { LASSERT (conn->ksnc_closing); *txmem = *rxmem = *nagle = 0; - return (-ESHUTDOWN); + return -ESHUTDOWN; } rc = libcfs_sock_getbuf(sock, txmem, rxmem); @@ -450,7 +450,7 @@ ksocknal_lib_get_conn_tunables (ksock_conn_t *conn, int *txmem, int *rxmem, int else *txmem = *rxmem = *nagle = 0; - return (rc); + return rc; } int @@ -476,7 +476,7 @@ ksocknal_lib_setup_sock (struct socket *sock) (char *)&linger, sizeof (linger)); if (rc != 0) { CERROR ("Can't set SO_LINGER: %d\n", rc); - return (rc); + return rc; } option = -1; @@ -484,7 +484,7 @@ ksocknal_lib_setup_sock (struct socket *sock) (char *)&option, sizeof (option)); if (rc != 0) { CERROR ("Can't set SO_LINGER2: %d\n", rc); - return (rc); + return rc; } if (!*ksocknal_tunables.ksnd_nagle) { @@ -494,7 +494,7 @@ ksocknal_lib_setup_sock (struct socket *sock) (char *)&option, sizeof (option)); if (rc != 0) { CERROR ("Can't disable nagle: %d\n", rc); - return (rc); + return rc; } } @@ -505,7 +505,7 @@ ksocknal_lib_setup_sock (struct socket *sock) CERROR ("Can't set buffer tx %d, rx %d buffers: %d\n", *ksocknal_tunables.ksnd_tx_buffer_size, *ksocknal_tunables.ksnd_rx_buffer_size, rc); - return (rc); + return rc; } /* TCP_BACKOFF_* sockopt tunables unsupported in stock kernels */ @@ -522,34 +522,34 @@ ksocknal_lib_setup_sock (struct socket *sock) (char *)&option, sizeof (option)); if (rc != 0) { CERROR ("Can't set SO_KEEPALIVE: %d\n", rc); - return (rc); + return rc; } if (!do_keepalive) - return (0); + return 0; rc = kernel_setsockopt(sock, SOL_TCP, TCP_KEEPIDLE, (char *)&keep_idle, sizeof (keep_idle)); if (rc != 0) { CERROR ("Can't set TCP_KEEPIDLE: %d\n", rc); - return (rc); + return rc; } rc = kernel_setsockopt(sock, SOL_TCP, TCP_KEEPINTVL, (char *)&keep_intvl, sizeof (keep_intvl)); if (rc != 0) { CERROR ("Can't set TCP_KEEPINTVL: %d\n", rc); - return (rc); + return rc; } rc = kernel_setsockopt(sock, SOL_TCP, TCP_KEEPCNT, (char *)&keep_count, sizeof (keep_count)); if (rc != 0) { CERROR ("Can't set TCP_KEEPCNT: %d\n", rc); - return (rc); + return rc; } - return (0); + return 0; } void -- cgit v1.2.3 From 597ae4685a5654fbb542227cd08283071276d05a Mon Sep 17 00:00:00 2001 From: Andreas Platschek Date: Mon, 19 May 2014 13:37:25 +0000 Subject: staging: lustre: check length of char array This fixes the following sparse error: drivers/staging/lustre/lustre/obdclass/llog_ioctl.c:388:39: error: incompatible types for operation (>) drivers/staging/lustre/lustre/obdclass/llog_ioctl.c:388:39: left side has type char *ioc_inlbuf2 drivers/staging/lustre/lustre/obdclass/llog_ioctl.c:388:39: right side has type int Signed-off-by: Andreas Platschek Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/llog_ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/obdclass/llog_ioctl.c b/drivers/staging/lustre/lustre/obdclass/llog_ioctl.c index da558a5dc92b..e192aab193bb 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_ioctl.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_ioctl.c @@ -385,7 +385,7 @@ int llog_ioctl(const struct lu_env *env, struct llog_ctxt *ctxt, int cmd, GOTO(out_close, rc = -EINVAL); } - if (data->ioc_inlbuf2 > 0) { + if (data->ioc_inllen2 > 0) { /* remove indicate log from the catalog */ rc = str2logid(&plain, data->ioc_inlbuf2, data->ioc_inllen2); -- cgit v1.2.3 From 3456a40e8f5ef46aaba1fcd0f9dfcffa4cdf0c8b Mon Sep 17 00:00:00 2001 From: Rickard Strandqvist Date: Mon, 19 May 2014 23:40:35 +0200 Subject: staging: lustre: lustre: lov: lov_obd.c: Fix for possible null pointer dereference There is otherwise a risk of a possible null pointer dereference. Was largely found by using a static code analysis program called cppcheck. Signed-off-by: Rickard Strandqvist Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lov/lov_obd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 12e778c42255..2d843b1c1ded 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -277,7 +277,7 @@ static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt) osc_obd = class_exp2obd(tgt->ltd_exp); CDEBUG(D_CONFIG, "%s: disconnecting target %s\n", - obd->obd_name, osc_obd->obd_name); + obd->obd_name, osc_obd ? osc_obd->obd_name : "NULL"); if (tgt->ltd_active) { tgt->ltd_active = 0; @@ -285,11 +285,11 @@ static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt) tgt->ltd_exp->exp_obd->obd_inactive = 1; } - lov_proc_dir = obd->obd_proc_private; - if (lov_proc_dir) - lprocfs_remove_proc_entry(osc_obd->obd_name, lov_proc_dir); - if (osc_obd) { + lov_proc_dir = obd->obd_proc_private; + if (lov_proc_dir) { + lprocfs_remove_proc_entry(osc_obd->obd_name, lov_proc_dir); + } /* Pass it on to our clients. * XXX This should be an argument to disconnect, * XXX not a back-door flag on the OBD. Ah well. -- cgit v1.2.3 From fe456ff4bce247e4444bef847ba4905647664895 Mon Sep 17 00:00:00 2001 From: Rickard Strandqvist Date: Mon, 19 May 2014 23:42:08 +0200 Subject: staging: lustre: lustre: ptlrpc: sec_config.c: Fix for possible null pointer dereference There is otherwise a risk of a possible null pointer dereference. Was largely found by using a static code analysis program called cppcheck. Signed-off-by: Rickard Strandqvist Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/sec_config.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c index bf56120abfaf..231656ed7660 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c @@ -745,11 +745,13 @@ void sptlrpc_conf_log_update_begin(const char *logname) mutex_lock(&sptlrpc_conf_lock); conf = sptlrpc_conf_get(fsname, 0); - if (conf && conf->sc_local) { - LASSERT(conf->sc_updated == 0); - sptlrpc_conf_free_rsets(conf); + if (conf) { + if(conf->sc_local) { + LASSERT(conf->sc_updated == 0); + sptlrpc_conf_free_rsets(conf); + } + conf->sc_modified = 0; } - conf->sc_modified = 0; mutex_unlock(&sptlrpc_conf_lock); } -- cgit v1.2.3 From 0c9f38a1d1837de9060ce06f1897235236d38545 Mon Sep 17 00:00:00 2001 From: Manuel Schölling Date: Wed, 21 May 2014 19:16:36 +0200 Subject: staging: lustre: Use time_before() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To be future-proof and for better readability the time comparisons are modified to use time_before() instead of plain, error-prone math. Signed-off-by: Manuel Schölling Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/linux/obd.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/linux/obd.h b/drivers/staging/lustre/lustre/include/linux/obd.h index fea7e6cd44c3..f96f65d5168f 100644 --- a/drivers/staging/lustre/lustre/include/linux/obd.h +++ b/drivers/staging/lustre/lustre/include/linux/obd.h @@ -80,8 +80,8 @@ static inline void __client_obd_list_lock(client_obd_lock_t *lock, break; } - if ((jiffies - cur > 5 * HZ) && - (jiffies - lock->time > 5 * HZ)) { + if (time_before(cur + 5 * HZ, jiffies) && + time_before(lock->time + 5 * HZ, jiffies)) { struct task_struct *task = lock->task; if (task == NULL) -- cgit v1.2.3 From 01c48ad3ea7f976ab9e02dca642c52f7cf1256b9 Mon Sep 17 00:00:00 2001 From: Daeseok Youn Date: Fri, 16 May 2014 18:29:44 +0900 Subject: staging: ozwpan: remove redundant NULL check for devs The "devs" is a pointer to g_net_dev in ozmain.c. g_net_dev has a default value as empty string. So "devs" cannot be NULL, removes NULL check for "devs". Signed-off-by: Daeseok Youn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozproto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ozwpan/ozproto.c b/drivers/staging/ozwpan/ozproto.c index f09acd0bb013..767cac493074 100644 --- a/drivers/staging/ozwpan/ozproto.c +++ b/drivers/staging/ozwpan/ozproto.c @@ -765,7 +765,7 @@ static char *oz_get_next_device_name(char *s, char *dname, int max_size) int oz_protocol_init(char *devs) { skb_queue_head_init(&g_rx_queue); - if (devs && (devs[0] == '*')) { + if (devs[0] == '*') { oz_binding_add(NULL); } else { char d[32]; -- cgit v1.2.3 From ae35f26644d1af10bfc96c5dffc5103c84a9b3c4 Mon Sep 17 00:00:00 2001 From: Anil Belur Date: Mon, 19 May 2014 19:42:48 +1000 Subject: staging: ozwpan: ozproto.c fix for "WARNING: Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)" Fixed the warning message by replacing memcpy() with ether_addr_copy() Signed-off-by: Anil Belur Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozproto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ozwpan/ozproto.c b/drivers/staging/ozwpan/ozproto.c index 767cac493074..110205599190 100644 --- a/drivers/staging/ozwpan/ozproto.c +++ b/drivers/staging/ozwpan/ozproto.c @@ -792,7 +792,7 @@ int oz_get_pd_list(struct oz_mac_addr *addr, int max_count) if (count >= max_count) break; pd = container_of(e, struct oz_pd, link); - memcpy(&addr[count++], pd->mac_addr, ETH_ALEN); + ether_addr_copy((u8 *)&addr[count++], pd->mac_addr); } spin_unlock_bh(&g_polling_lock); return count; -- cgit v1.2.3 From 96747a8f4e7d187f236ad392d86a37a4d1ba0b32 Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Mon, 19 May 2014 15:17:30 +0100 Subject: staging: ozwpan: Change Maintainer I will be not able to work on ozwpan driver anymore. Remove my name & add Tateno as maintainer. Signed-off-by: Rupesh Gujare Acked-by: Shigekatsu Tateno Signed-off-by: Greg Kroah-Hartman --- MAINTAINERS | 2 +- drivers/staging/ozwpan/TODO | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index bbc59497fa97..dc16c6d7b9e2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8478,7 +8478,7 @@ S: Maintained F: drivers/staging/olpc_dcon/ STAGING - OZMO DEVICES USB OVER WIFI DRIVER -M: Rupesh Gujare +M: Shigekatsu Tateno S: Maintained F: drivers/staging/ozwpan/ diff --git a/drivers/staging/ozwpan/TODO b/drivers/staging/ozwpan/TODO index b4febd79a68d..f32c1c0bc875 100644 --- a/drivers/staging/ozwpan/TODO +++ b/drivers/staging/ozwpan/TODO @@ -10,5 +10,5 @@ TODO: - testing with as many devices as possible. Please send any patches for this driver to -Rupesh Gujare +Shigekatsu Tateno and Greg Kroah-Hartman . -- cgit v1.2.3 From ba9108080f861f7cccb58bdec900c4076c2bc803 Mon Sep 17 00:00:00 2001 From: James A Shackleford Date: Wed, 21 May 2014 14:50:26 -0400 Subject: staging: ozwpan: Add missing blanklines after declarations Signed-off-by: James A Shackleford Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozhcd.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index b3d401ae41b4..91bb29e09322 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -294,6 +294,7 @@ static void oz_free_urb_link(struct oz_urb_link *urbl) { if (urbl) { unsigned long irq_state; + spin_lock_irqsave(&g_link_lock, irq_state); if (g_link_pool_size < OZ_MAX_LINK_POOL_SIZE) { urbl->link.next = g_link_pool; @@ -424,6 +425,7 @@ static void oz_ep_free(struct oz_port *port, struct oz_endpoint *ep) if (port) { struct list_head list; struct oz_hcd *ozhcd = port->ozhcd; + INIT_LIST_HEAD(&list); if (ep->flags & OZ_F_EP_HAVE_STREAM) oz_usb_stream_delete(port->hpd, ep->ep_num); @@ -568,6 +570,7 @@ static int oz_dequeue_ep_urb(struct oz_port *port, u8 ep_addr, int in_dir, ep = port->out_ep[ep_addr]; if (ep) { struct list_head *e; + list_for_each(e, &ep->urb_list) { urbl = container_of(e, struct oz_urb_link, link); if (urbl->urb == urb) { @@ -599,6 +602,7 @@ static struct urb *oz_find_urb_by_id(struct oz_port *port, int ep_ix, ep = port->out_ep[ep_ix]; if (ep) { struct list_head *e; + list_for_each(e, &ep->urb_list) { urbl = container_of(e, struct oz_urb_link, link); if (urbl->req_id == req_id) { @@ -815,6 +819,7 @@ void oz_hcd_get_desc_cnf(void *hport, u8 req_id, int status, const u8 *desc, if (status == 0) { int copy_len; int required_size = urb->transfer_buffer_length; + if (required_size > total_size) required_size = total_size; copy_len = required_size-offset; @@ -826,6 +831,7 @@ void oz_hcd_get_desc_cnf(void *hport, u8 req_id, int status, const u8 *desc, struct usb_ctrlrequest *setup = (struct usb_ctrlrequest *)urb->setup_packet; unsigned wvalue = le16_to_cpu(setup->wValue); + if (oz_enqueue_ep_urb(port, 0, 0, urb, req_id)) err = -ENOMEM; else if (oz_usb_get_desc_req(port->hpd, req_id, @@ -919,6 +925,7 @@ static void oz_hcd_complete_set_interface(struct oz_port *port, struct urb *urb, if ((rcode == 0) && (port->config_num > 0)) { struct usb_host_config *config; struct usb_host_interface *intf; + oz_dbg(ON, "Set interface %d alt %d\n", if_num, alt); oz_clean_endpoints_for_interface(hcd, port, if_num); config = &urb->dev->config[port->config_num-1]; @@ -974,6 +981,7 @@ void oz_hcd_control_cnf(void *hport, u8 req_id, u8 rcode, const u8 *data, } else { int copy_len; + oz_dbg(ON, "VENDOR-CLASS - cnf\n"); if (data_len) { if (data_len <= urb->transfer_buffer_length) @@ -1047,6 +1055,7 @@ void oz_hcd_data_ind(void *hport, u8 endpoint, const u8 *data, int data_len) struct oz_urb_link, link); struct urb *urb; int copy_len; + list_del_init(&urbl->link); spin_unlock_bh(&ozhcd->hcd_lock); urb = urbl->urb; @@ -1140,6 +1149,7 @@ int oz_hcd_heartbeat(void *hport) spin_lock_bh(&ozhcd->hcd_lock); list_for_each(e, &port->isoc_in_ep) { struct oz_endpoint *ep = ep_from_link(e); + if (ep->flags & OZ_F_EP_BUFFERING) { if (ep->buffered_units >= OZ_IN_BUFFERING_UNITS) { ep->flags &= ~OZ_F_EP_BUFFERING; @@ -1160,6 +1170,7 @@ int oz_hcd_heartbeat(void *hport) int len = 0; int copy_len; int i; + if (ep->credit < urb->number_of_packets) break; if (ep->buffered_units < urb->number_of_packets) @@ -1215,6 +1226,7 @@ int oz_hcd_heartbeat(void *hport) if (ep) { struct list_head *e; struct list_head *n; + spin_lock_bh(&ozhcd->hcd_lock); list_for_each_safe(e, n, &ep->urb_list) { urbl = container_of(e, struct oz_urb_link, link); @@ -1557,6 +1569,7 @@ static void oz_process_ep0_urb(struct oz_hcd *ozhcd, struct urb *urb, } if (!rc && !complete) { int data_len = 0; + if ((setup->bRequestType & USB_DIR_IN) == 0) data_len = wlength; urb->actual_length = data_len; @@ -1761,6 +1774,7 @@ static void oz_hcd_clear_orphanage(struct oz_hcd *ozhcd, int status) { if (ozhcd) { struct oz_urb_link *urbl; + while (!list_empty(&ozhcd->orphanage)) { urbl = list_first_entry(&ozhcd->orphanage, struct oz_urb_link, link); @@ -2258,6 +2272,7 @@ static int oz_plat_probe(struct platform_device *dev) spin_lock_init(&ozhcd->hcd_lock); for (i = 0; i < OZ_NB_PORTS; i++) { struct oz_port *port = &ozhcd->ports[i]; + port->ozhcd = ozhcd; port->flags = 0; port->status = 0; -- cgit v1.2.3 From a3c97192fbc2fec6afa82a292c65adfd5cbde9b0 Mon Sep 17 00:00:00 2001 From: Peter Senna Tschudin Date: Tue, 20 May 2014 12:33:47 +0200 Subject: staging: ozwpan: Remove useless return variables This patch remove variables that are initialized with a constant, are never updated, and are only used as parameter of return. Return the constant instead of using a variable. Verified by compilation only. The coccinelle script that find and fixes this issue is: // @@ type T; constant C; identifier ret; @@ - T ret = C; ... when != ret - return ret; + return C; // Signed-off-by: Peter Senna Tschudin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozhcd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index 91bb29e09322..30bd9286d47d 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -2011,7 +2011,6 @@ static void oz_get_hub_descriptor(struct usb_hcd *hcd, static int oz_set_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex) { struct oz_port *port; - int err = 0; u8 port_id = (u8)windex; struct oz_hcd *ozhcd = oz_hcd_private(hcd); unsigned set_bits = 0; @@ -2078,7 +2077,7 @@ static int oz_set_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex) spin_unlock_bh(&port->port_lock); } oz_dbg(HUB, "Port[%d] status = 0x%x\n", port_id, port->status); - return err; + return 0; } /* @@ -2087,7 +2086,6 @@ static int oz_set_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex) static int oz_clear_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex) { struct oz_port *port; - int err = 0; u8 port_id = (u8)windex; struct oz_hcd *ozhcd = oz_hcd_private(hcd); unsigned clear_bits = 0; @@ -2154,7 +2152,7 @@ static int oz_clear_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex) } oz_dbg(HUB, "Port[%d] status = 0x%x\n", port_id, ozhcd->ports[port_id-1].status); - return err; + return 0; } /* -- cgit v1.2.3 From be2b8fc1c8584373d5471774530587befa96772b Mon Sep 17 00:00:00 2001 From: Martin Kepplinger Date: Mon, 19 May 2014 12:55:11 +0200 Subject: staging: winbond: use dev_err() instead of printk() For obvious error messages, use dev_err() in order to provide userspace with more useful information and use the common kernel coding style. Signed-off-by: Martin Kepplinger Acked-by: Pavel Machek Signed-off-by: Greg Kroah-Hartman --- drivers/staging/winbond/wb35tx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/winbond/wb35tx.c b/drivers/staging/winbond/wb35tx.c index 708c5b05f86c..870cff39a226 100644 --- a/drivers/staging/winbond/wb35tx.c +++ b/drivers/staging/winbond/wb35tx.c @@ -49,7 +49,7 @@ static void Wb35Tx_complete(struct urb *pUrb) /* The URB is completed, check the result */ if (pWb35Tx->EP4VM_status != 0) { - printk("URB submission failed\n"); + dev_err(&pUrb->dev->dev, "URB submission failed\n"); pWb35Tx->EP4vm_state = VM_STOP; goto error; } @@ -96,7 +96,7 @@ static void Wb35Tx(struct wbsoft_priv *adapter) pWb35Tx->EP4vm_state = VM_RUNNING; retv = usb_submit_urb(pUrb, GFP_ATOMIC); if (retv < 0) { - printk("EP4 Tx Irp sending error\n"); + dev_err(&pUrb->dev->dev, "EP4 Tx Irp sending error\n"); goto cleanup; } @@ -218,7 +218,7 @@ static void Wb35Tx_EP2VM_complete(struct urb *pUrb) /* The Urb is completed, check the result */ if (pWb35Tx->EP2VM_status != 0) { - printk("EP2 IoCompleteRoutine return error\n"); + dev_err(&pUrb->dev->dev, "EP2 IoCompleteRoutine return error\n"); pWb35Tx->EP2vm_state = VM_STOP; goto error; } -- cgit v1.2.3 From c81933857bc1192968bfae736a469a126672143b Mon Sep 17 00:00:00 2001 From: Michele CURTI Date: Sat, 3 May 2014 14:36:52 +0200 Subject: staging/winbond: fix a style error Removed a few spaces to fix style errors Signed-off-by: Michele Curti Signed-off-by: Greg Kroah-Hartman --- drivers/staging/winbond/wb35tx_s.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/winbond/wb35tx_s.h b/drivers/staging/winbond/wb35tx_s.h index 715f87d6ac5b..dc120085d528 100644 --- a/drivers/staging/winbond/wb35tx_s.h +++ b/drivers/staging/winbond/wb35tx_s.h @@ -12,7 +12,7 @@ /* Internal variable for module */ struct wb35_tx { /* For Tx buffer */ - u8 TxBuffer[ MAX_USB_TX_BUFFER_NUMBER ][ MAX_USB_TX_BUFFER ]; + u8 TxBuffer[MAX_USB_TX_BUFFER_NUMBER][MAX_USB_TX_BUFFER]; /* For Interrupt pipe */ u8 EP2_buf[MAX_INTERRUPT_LENGTH]; -- cgit v1.2.3 From 33ae8a5ed3017cfca5742deff4039dd912690015 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Sat, 3 May 2014 02:55:29 -0500 Subject: staging: comedi: addi_apci_1564: board has 32 digital outputs This board always has 32 digital outputs. Remove the test when initializing the subdevice. Also, since this board is the only one supported by this driver, remove the boardinfo about the digital outputs and just use the data directly in the subdevice init. Signed-off-by: Chase Southwood Reviewed-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1564.c | 29 ++++++++----------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index ea22530a5cbd..fbc82ad0de3a 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -17,9 +17,6 @@ static const struct addi_board apci1564_boardtypes[] = { .i_Timer = 1, .interrupt = apci1564_interrupt, .reset = apci1564_reset, - .do_config = apci1564_do_config, - .do_bits = apci1564_do_insn_bits, - .do_read = apci1564_do_read, .timer_config = apci1564_timer_config, .timer_write = apci1564_timer_write, .timer_read = apci1564_timer_read, @@ -98,23 +95,15 @@ static int apci1564_auto_attach(struct comedi_device *dev, /* Allocate and Initialise DO Subdevice Structures */ s = &dev->subdevices[3]; - if (this_board->i_NbrDoChannel) { - s->type = COMEDI_SUBD_DO; - s->subdev_flags = - SDF_READABLE | SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = this_board->i_NbrDoChannel; - s->maxdata = this_board->i_DoMaxdata; - s->len_chanlist = this_board->i_NbrDoChannel; - s->range_table = &range_digital; - - /* insn_config - for digital output memory */ - s->insn_config = this_board->do_config; - s->insn_write = this_board->do_write; - s->insn_bits = this_board->do_bits; - s->insn_read = this_board->do_read; - } else { - s->type = COMEDI_SUBD_UNUSED; - } + s->type = COMEDI_SUBD_DO; + s->subdev_flags = SDF_WRITEABLE; + s->n_chan = 32; + s->maxdata = 0xffffffff; + s->len_chanlist = 32; + s->range_table = &range_digital; + s->insn_config = apci1564_do_config; + s->insn_bits = apci1564_do_insn_bits; + s->insn_read = apci1564_do_read; /* Allocate and Initialise Timer Subdevice Structures */ s = &dev->subdevices[4]; -- cgit v1.2.3 From 9f2dbefb0ddb548b9a062f6ca729534efc15b0d6 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Sat, 3 May 2014 02:56:27 -0500 Subject: staging: comedi: addi_apci_1564: don't allocate unused subdevices The addi-data common code always allocates 7 subdevices. This driver cannot or will not use the ones we are currently allocating for analog input and output or EEPROM, so just don't allocate these subdevices at all. Signed-off-by: Chase Southwood Reviewed-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1564.c | 27 +++++-------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index fbc82ad0de3a..1198540e0a2d 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -47,7 +47,7 @@ static int apci1564_auto_attach(struct comedi_device *dev, const struct addi_board *this_board = comedi_board(dev); struct addi_private *devpriv; struct comedi_subdevice *s; - int ret, n_subdevices; + int ret; dev->board_name = this_board->pc_DriverName; @@ -69,21 +69,12 @@ static int apci1564_auto_attach(struct comedi_device *dev, dev->irq = pcidev->irq; } - n_subdevices = 7; - ret = comedi_alloc_subdevices(dev, n_subdevices); + ret = comedi_alloc_subdevices(dev, 3); if (ret) return ret; - /* Allocate and Initialise AI Subdevice Structures */ - s = &dev->subdevices[0]; - s->type = COMEDI_SUBD_UNUSED; - - /* Allocate and Initialise AO Subdevice Structures */ - s = &dev->subdevices[1]; - s->type = COMEDI_SUBD_UNUSED; - /* Allocate and Initialise DI Subdevice Structures */ - s = &dev->subdevices[2]; + s = &dev->subdevices[0]; s->type = COMEDI_SUBD_DI; s->subdev_flags = SDF_READABLE; s->n_chan = 32; @@ -94,7 +85,7 @@ static int apci1564_auto_attach(struct comedi_device *dev, s->insn_bits = apci1564_di_insn_bits; /* Allocate and Initialise DO Subdevice Structures */ - s = &dev->subdevices[3]; + s = &dev->subdevices[1]; s->type = COMEDI_SUBD_DO; s->subdev_flags = SDF_WRITEABLE; s->n_chan = 32; @@ -106,7 +97,7 @@ static int apci1564_auto_attach(struct comedi_device *dev, s->insn_read = apci1564_do_read; /* Allocate and Initialise Timer Subdevice Structures */ - s = &dev->subdevices[4]; + s = &dev->subdevices[2]; if (this_board->i_Timer) { s->type = COMEDI_SUBD_TIMER; s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; @@ -123,14 +114,6 @@ static int apci1564_auto_attach(struct comedi_device *dev, s->type = COMEDI_SUBD_UNUSED; } - /* Allocate and Initialise TTL */ - s = &dev->subdevices[5]; - s->type = COMEDI_SUBD_UNUSED; - - /* EEPROM */ - s = &dev->subdevices[6]; - s->type = COMEDI_SUBD_UNUSED; - i_ADDI_Reset(dev); return 0; } -- cgit v1.2.3 From aed3f9d498babd9cf4f0656e4a415cd25c725aa3 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Sat, 3 May 2014 02:57:01 -0500 Subject: staging: comedi: addi_apci_1564: absorb apci1564_reset() This is the only reset fuction used by this driver. We can remove it from the boardinfo and absorb the code from hwdrv_apci1564.c into the driver. Signed-off-by: Chase Southwood Reviewed-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci1564.c | 32 ------------------- drivers/staging/comedi/drivers/addi_apci_1564.c | 36 ++++++++++++++++++---- 2 files changed, 30 insertions(+), 38 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c index 7976a22ae94d..b3c3f603fb73 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c @@ -578,35 +578,3 @@ static void apci1564_interrupt(int irq, void *d) } return; } - -static int apci1564_reset(struct comedi_device *dev) -{ - struct addi_private *devpriv = dev->private; - - ui_Type = 0; - - /* Disable the input interrupts and reset status register */ - outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DI_IRQ_REG); - inl(devpriv->i_IobaseAmcc + APCI1564_DI_INT_STATUS_REG); - outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DI_INT_MODE1_REG); - outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DI_INT_MODE2_REG); - - /* Reset the output channels and disable interrupts */ - outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DO_REG); - outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DO_INT_CTRL_REG); - - /* Reset the watchdog registers */ - addi_watchdog_reset(devpriv->i_IobaseAmcc + APCI1564_WDOG_REG); - - /* Reset the timer registers */ - outl(0x0, devpriv->i_IobaseAmcc + APCI1564_TIMER_CTRL_REG); - outl(0x0, devpriv->i_IobaseAmcc + APCI1564_TIMER_RELOAD_REG); - - /* Reset the counter registers */ - outl(0x0, dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER1)); - outl(0x0, dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER2)); - outl(0x0, dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER3)); - outl(0x0, dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER4)); - - return 0; -} diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 1198540e0a2d..f1dc3710aba1 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -16,7 +16,6 @@ static const struct addi_board apci1564_boardtypes[] = { .i_DoMaxdata = 0xffffffff, .i_Timer = 1, .interrupt = apci1564_interrupt, - .reset = apci1564_reset, .timer_config = apci1564_timer_config, .timer_write = apci1564_timer_write, .timer_read = apci1564_timer_read, @@ -32,11 +31,35 @@ static irqreturn_t v_ADDI_Interrupt(int irq, void *d) return IRQ_RETVAL(1); } -static int i_ADDI_Reset(struct comedi_device *dev) +static int apci1564_reset(struct comedi_device *dev) { - const struct addi_board *this_board = comedi_board(dev); + struct addi_private *devpriv = dev->private; + + ui_Type = 0; + + /* Disable the input interrupts and reset status register */ + outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DI_IRQ_REG); + inl(devpriv->i_IobaseAmcc + APCI1564_DI_INT_STATUS_REG); + outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DI_INT_MODE1_REG); + outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DI_INT_MODE2_REG); + + /* Reset the output channels and disable interrupts */ + outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DO_REG); + outl(0x0, devpriv->i_IobaseAmcc + APCI1564_DO_INT_CTRL_REG); + + /* Reset the watchdog registers */ + addi_watchdog_reset(devpriv->i_IobaseAmcc + APCI1564_WDOG_REG); + + /* Reset the timer registers */ + outl(0x0, devpriv->i_IobaseAmcc + APCI1564_TIMER_CTRL_REG); + outl(0x0, devpriv->i_IobaseAmcc + APCI1564_TIMER_RELOAD_REG); + + /* Reset the counter registers */ + outl(0x0, dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER1)); + outl(0x0, dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER2)); + outl(0x0, dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER3)); + outl(0x0, dev->iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER4)); - this_board->reset(dev); return 0; } @@ -62,6 +85,8 @@ static int apci1564_auto_attach(struct comedi_device *dev, dev->iobase = pci_resource_start(pcidev, 1); devpriv->i_IobaseAmcc = pci_resource_start(pcidev, 0); + apci1564_reset(dev); + if (pcidev->irq > 0) { ret = request_irq(pcidev->irq, v_ADDI_Interrupt, IRQF_SHARED, dev->board_name, dev); @@ -114,7 +139,6 @@ static int apci1564_auto_attach(struct comedi_device *dev, s->type = COMEDI_SUBD_UNUSED; } - i_ADDI_Reset(dev); return 0; } @@ -124,7 +148,7 @@ static void apci1564_detach(struct comedi_device *dev) if (devpriv) { if (dev->iobase) - i_ADDI_Reset(dev); + apci1564_reset(dev); if (dev->irq) free_irq(dev->irq, dev); } -- cgit v1.2.3 From 49e66262d9296e618b25d8a8128f2dff1ca59637 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Sat, 3 May 2014 02:57:41 -0500 Subject: staging: comedi: addi_apci_1564: call apci1564_interrupt() directly Remove the boardinfo about the interrupt function and just call it directly. Signed-off-by: Chase Southwood Reviewed-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1564.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index f1dc3710aba1..86276cdb6f47 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -15,7 +15,6 @@ static const struct addi_board apci1564_boardtypes[] = { .i_NbrDoChannel = 32, .i_DoMaxdata = 0xffffffff, .i_Timer = 1, - .interrupt = apci1564_interrupt, .timer_config = apci1564_timer_config, .timer_write = apci1564_timer_write, .timer_read = apci1564_timer_read, @@ -24,10 +23,7 @@ static const struct addi_board apci1564_boardtypes[] = { static irqreturn_t v_ADDI_Interrupt(int irq, void *d) { - struct comedi_device *dev = d; - const struct addi_board *this_board = comedi_board(dev); - - this_board->interrupt(irq, d); + apci1564_interrupt(irq, d); return IRQ_RETVAL(1); } -- cgit v1.2.3 From 0642d08045aafe4f0bbef129e65264cc60502faa Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 5 May 2014 09:35:29 -0700 Subject: staging: comedi: adl_pci9118: remove 'ai_n_chan' from private data This member of the private data is just a copy of the cmd->chanlist_len. Use that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 4be5f67cf14a..6b64484c6ced 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -326,7 +326,6 @@ struct pci9118_private { 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 @@ -712,10 +711,11 @@ static unsigned int defragment_dma_buffer(struct comedi_device *dev, unsigned int num_samples) { struct pci9118_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; unsigned int i = 0, j = 0; unsigned int start_pos = devpriv->ai_add_front, - stop_pos = devpriv->ai_add_front + devpriv->ai_n_chan; - unsigned int raw_scanlen = devpriv->ai_add_front + devpriv->ai_n_chan + + stop_pos = devpriv->ai_add_front + cmd->chanlist_len; + unsigned int raw_scanlen = devpriv->ai_add_front + cmd->chanlist_len + devpriv->ai_add_back; for (i = 0; i < num_samples; i++) { @@ -1616,7 +1616,6 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai12_startstop = 0; devpriv->ai_flags = cmd->flags; - devpriv->ai_n_chan = cmd->chanlist_len; devpriv->ai_n_scanlen = cmd->scan_end_arg; devpriv->ai_chanlist = cmd->chanlist; devpriv->ai_data_len = s->async->prealloc_bufsz; @@ -1725,7 +1724,7 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_add_front = addchans + 1; if (devpriv->usedma == 1) if ((devpriv->ai_add_front + - devpriv->ai_n_chan + + cmd->chanlist_len + devpriv->ai_add_back) & 1) devpriv->ai_add_front++; /* round up to 32 bit */ @@ -1736,16 +1735,16 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) * 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_front + cmd->chanlist_len + devpriv->ai_add_back) * (devpriv->ai_n_scanlen / - devpriv->ai_n_chan); + cmd->chanlist_len); /* check and setup channel list */ - if (!check_channel_list(dev, s, devpriv->ai_n_chan, + if (!check_channel_list(dev, s, cmd->chanlist_len, devpriv->ai_chanlist, devpriv->ai_add_front, devpriv->ai_add_back)) return -EINVAL; - if (!setup_channel_list(dev, s, devpriv->ai_n_chan, + if (!setup_channel_list(dev, s, cmd->chanlist_len, devpriv->ai_chanlist, 0, devpriv->ai_add_front, devpriv->ai_add_back, devpriv->usedma, devpriv->useeoshandle)) -- cgit v1.2.3 From b1869854f477e6d4c96cf1fc753f0e6b6fbbe21d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 5 May 2014 09:35:30 -0700 Subject: staging: comedi: adl_pci9118: remove 'ai_chanlist' from private data This member of the private data is just a copy of the cmd->chanlist. Use that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 6b64484c6ced..cc56da4fe857 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -340,7 +340,6 @@ struct pci9118_private { * 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; @@ -1617,7 +1616,6 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai12_startstop = 0; devpriv->ai_flags = cmd->flags; devpriv->ai_n_scanlen = cmd->scan_end_arg; - devpriv->ai_chanlist = cmd->chanlist; devpriv->ai_data_len = s->async->prealloc_bufsz; devpriv->ai_timer1 = 0; devpriv->ai_timer2 = 0; @@ -1741,11 +1739,11 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) /* check and setup channel list */ if (!check_channel_list(dev, s, cmd->chanlist_len, - devpriv->ai_chanlist, devpriv->ai_add_front, + cmd->chanlist, devpriv->ai_add_front, devpriv->ai_add_back)) return -EINVAL; if (!setup_channel_list(dev, s, cmd->chanlist_len, - devpriv->ai_chanlist, 0, devpriv->ai_add_front, + cmd->chanlist, 0, devpriv->ai_add_front, devpriv->ai_add_back, devpriv->usedma, devpriv->useeoshandle)) return -EINVAL; -- cgit v1.2.3 From cc06e2413114d21045f30545fde573583b8fb024 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 5 May 2014 09:35:31 -0700 Subject: staging: comedi: adl_pci9118: remove 'ai_data_len' from private data This member of the private data is just a copy of the s->async->prealloc_bufsz. Use that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index cc56da4fe857..94ede354b4fa 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -351,7 +351,6 @@ struct pci9118_private { * divisors for start of measure * on external start */ - unsigned int ai_data_len; unsigned short ao_data[2]; /* data output buffer */ unsigned int ai_scans; /* number of scans to do */ char dma_doublebuf; /* we can use double buffering */ @@ -1035,10 +1034,8 @@ 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 - */ + /* how many samples is to end of buffer */ + m = s->async->prealloc_bufsz >> 1; sampls = m; move_block_from_dma(dev, s, devpriv->dmabuf_virt[devpriv->dma_actbuf], @@ -1335,7 +1332,8 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev, return 0; } -static int Compute_and_setup_dma(struct comedi_device *dev) +static int Compute_and_setup_dma(struct comedi_device *dev, + struct comedi_subdevice *s) { struct pci9118_private *devpriv = dev->private; unsigned int dmalen0, dmalen1, i; @@ -1343,15 +1341,13 @@ static int Compute_and_setup_dma(struct comedi_device *dev) dmalen0 = devpriv->dmabuf_size[0]; dmalen1 = devpriv->dmabuf_size[1]; /* isn't output buff smaller that our DMA buff? */ - if (dmalen0 > (devpriv->ai_data_len)) { - dmalen0 = devpriv->ai_data_len & ~3L; /* - * align to 32bit down - */ + if (dmalen0 > s->async->prealloc_bufsz) { + /* align to 32bit down */ + dmalen0 = s->async->prealloc_bufsz & ~3L; } - if (dmalen1 > (devpriv->ai_data_len)) { - dmalen1 = devpriv->ai_data_len & ~3L; /* - * align to 32bit down - */ + if (dmalen1 > s->async->prealloc_bufsz) { + /* align to 32bit down */ + dmalen1 = s->async->prealloc_bufsz & ~3L; } /* we want wake up every scan? */ @@ -1540,7 +1536,7 @@ static int pci9118_ai_docmd_dma(struct comedi_device *dev, { struct pci9118_private *devpriv = dev->private; - Compute_and_setup_dma(dev); + Compute_and_setup_dma(dev, s); switch (devpriv->ai_do) { case 1: @@ -1616,7 +1612,6 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai12_startstop = 0; devpriv->ai_flags = cmd->flags; devpriv->ai_n_scanlen = cmd->scan_end_arg; - devpriv->ai_data_len = s->async->prealloc_bufsz; devpriv->ai_timer1 = 0; devpriv->ai_timer2 = 0; devpriv->ai_add_front = 0; -- cgit v1.2.3 From c8d4bd1b23ccafdca24ae65734aab2f06d840e2d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 5 May 2014 09:35:32 -0700 Subject: staging: comedi: adl_pci9118: remove 'ai_timer1' from private data This member of the private data is set but never used. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 94ede354b4fa..b30d3e83b892 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -340,7 +340,6 @@ struct pci9118_private { * how many channels we must add * before scan to satisfy DMA? */ - unsigned int ai_timer1; unsigned int ai_timer2; unsigned int ai_flags; char ai12_startstop; /* @@ -1612,7 +1611,6 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai12_startstop = 0; devpriv->ai_flags = cmd->flags; devpriv->ai_n_scanlen = cmd->scan_end_arg; - devpriv->ai_timer1 = 0; devpriv->ai_timer2 = 0; devpriv->ai_add_front = 0; devpriv->ai_add_back = 0; @@ -1786,7 +1784,6 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) &devpriv->ai_divisor1, &devpriv->ai_divisor2, devpriv->usessh, devpriv->ai_add_front); - devpriv->ai_timer1 = cmd->scan_begin_arg; devpriv->ai_timer2 = cmd->convert_arg; } -- cgit v1.2.3 From f398b0ea67cc81601b2c0cfcf3471dfd3811ccd3 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 5 May 2014 09:35:33 -0700 Subject: staging: comedi: adl_pci9118: remove 'ai_timer2' from private data This member of the private data is set but never used. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index b30d3e83b892..da1ae75e3482 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -340,7 +340,6 @@ struct pci9118_private { * how many channels we must add * before scan to satisfy DMA? */ - unsigned int ai_timer2; unsigned int ai_flags; char ai12_startstop; /* * measure can start/stop @@ -1611,7 +1610,6 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai12_startstop = 0; devpriv->ai_flags = cmd->flags; devpriv->ai_n_scanlen = cmd->scan_end_arg; - devpriv->ai_timer2 = 0; devpriv->ai_add_front = 0; devpriv->ai_add_back = 0; devpriv->ai_maskerr = 0x10e; @@ -1762,7 +1760,6 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) &devpriv->ai_divisor1, &devpriv->ai_divisor2, devpriv->usessh, devpriv->ai_add_front); - devpriv->ai_timer2 = cmd->convert_arg; } if ((cmd->scan_begin_src == TRIG_TIMER) && @@ -1784,7 +1781,6 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) &devpriv->ai_divisor1, &devpriv->ai_divisor2, devpriv->usessh, devpriv->ai_add_front); - devpriv->ai_timer2 = cmd->convert_arg; } if ((cmd->scan_begin_src == TRIG_FOLLOW) -- cgit v1.2.3 From dab18a96483d9f07d06948a181173e5517ed3afa Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 5 May 2014 09:35:34 -0700 Subject: staging: comedi: adl_pci9118: remove 'ai_n_scanlen' from private data This member of the private data is just a copy of the cmd->scan_end_arg. Use that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 36 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index da1ae75e3482..bdb1ed357adc 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -326,7 +326,6 @@ struct pci9118_private { 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_scanlen; /* len of actual scanlist */ unsigned int ai_n_realscanlen; /* * what we must transfer for one * outgoing scan include front/back adds @@ -732,13 +731,14 @@ static int move_block_from_dma(struct comedi_device *dev, unsigned int num_samples) { struct pci9118_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; unsigned int num_bytes; num_samples = defragment_dma_buffer(dev, s, dma_buffer, num_samples); devpriv->ai_act_scan += - (s->async->cur_chan + num_samples) / devpriv->ai_n_scanlen; + (s->async->cur_chan + num_samples) / cmd->scan_end_arg; s->async->cur_chan += num_samples; - s->async->cur_chan %= devpriv->ai_n_scanlen; + s->async->cur_chan %= cmd->scan_end_arg; num_bytes = cfc_write_array_to_buffer(s, dma_buffer, num_samples * sizeof(short)); @@ -948,6 +948,7 @@ static void interrupt_pci9118_ai_onesample(struct comedi_device *dev, unsigned short int_daq) { struct pci9118_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; unsigned short sampl; if (int_adstat & devpriv->ai_maskerr) @@ -972,9 +973,9 @@ 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) { + if (s->async->cur_chan >= cmd->scan_end_arg) { /* one scan done */ - s->async->cur_chan %= devpriv->ai_n_scanlen; + s->async->cur_chan %= cmd->scan_end_arg; devpriv->ai_act_scan++; if (!devpriv->ai_neverending) { /* all data sampled? */ @@ -1441,18 +1442,18 @@ static int Compute_and_setup_dma(struct comedi_device *dev, devpriv->dmabuf_use_size[1] = dmalen1; #if 0 - if (devpriv->ai_n_scanlen < this_board->half_fifo_size) { + if (cmd->scan_end_arg < this_board->half_fifo_size) { devpriv->dmabuf_panic_size[0] = - (this_board->half_fifo_size / devpriv->ai_n_scanlen + - 1) * devpriv->ai_n_scanlen * sizeof(short); + (this_board->half_fifo_size / cmd->scan_end_arg + + 1) * cmd->scan_end_arg * sizeof(short); devpriv->dmabuf_panic_size[1] = - (this_board->half_fifo_size / devpriv->ai_n_scanlen + - 1) * devpriv->ai_n_scanlen * sizeof(short); + (this_board->half_fifo_size / cmd->scan_end_arg + + 1) * cmd->scan_end_arg * sizeof(short); } else { devpriv->dmabuf_panic_size[0] = - (devpriv->ai_n_scanlen << 1) % devpriv->dmabuf_size[0]; + (cmd->scan_end_arg << 1) % devpriv->dmabuf_size[0]; devpriv->dmabuf_panic_size[1] = - (devpriv->ai_n_scanlen << 1) % devpriv->dmabuf_size[1]; + (cmd->scan_end_arg << 1) % devpriv->dmabuf_size[1]; } #endif @@ -1609,7 +1610,6 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai12_startstop = 0; devpriv->ai_flags = cmd->flags; - devpriv->ai_n_scanlen = cmd->scan_end_arg; devpriv->ai_add_front = 0; devpriv->ai_add_back = 0; devpriv->ai_maskerr = 0x10e; @@ -1658,7 +1658,7 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (devpriv->master) { devpriv->usedma = 1; if ((cmd->flags & TRIG_WAKE_EOS) && - (devpriv->ai_n_scanlen == 1)) { + (cmd->scan_end_arg == 1)) { if (cmd->convert_src == TRIG_NOW) devpriv->ai_add_back = 1; if (cmd->convert_src == TRIG_TIMER) { @@ -1670,8 +1670,8 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) } } if ((cmd->flags & TRIG_WAKE_EOS) && - (devpriv->ai_n_scanlen & 1) && - (devpriv->ai_n_scanlen > 1)) { + (cmd->scan_end_arg & 1) && + (cmd->scan_end_arg > 1)) { if (cmd->scan_begin_src == TRIG_FOLLOW) { /* * vpriv->useeoshandle=1; // change DMA transfer @@ -1722,10 +1722,10 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) /* 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? + * to have cmd->scan_end_arg on output? */ (devpriv->ai_add_front + cmd->chanlist_len + - devpriv->ai_add_back) * (devpriv->ai_n_scanlen / + devpriv->ai_add_back) * (cmd->scan_end_arg / cmd->chanlist_len); /* check and setup channel list */ -- cgit v1.2.3 From 1b27a4369ba9804ad87d2160d9a76e23a484d4de Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 5 May 2014 09:35:35 -0700 Subject: staging: comedi: adl_pci9118: remove 'i8254_osc_base' from private data This member of the private data is always set to I8254_OSC_BASE_4MHZ. Use that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index bdb1ed357adc..ae8afc7788d9 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -322,7 +322,6 @@ struct pci9118_private { 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 */ @@ -789,37 +788,35 @@ static void pci9118_calc_divisors(char mode, struct comedi_device *dev, char usessh, unsigned int chnsshfront) { const struct boardtype *this_board = comedi_board(dev); - struct pci9118_private *devpriv = dev->private; switch (mode) { case 1: case 4: if (*tim2 < this_board->ai_ns_min) *tim2 = this_board->ai_ns_min; - i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, + i8253_cascade_ns_to_timer(I8254_OSC_BASE_4MHZ, div1, div2, tim2, flags & TRIG_ROUND_NEAREST); break; case 2: if (*tim2 < this_board->ai_ns_min) *tim2 = this_board->ai_ns_min; - *div1 = *tim2 / devpriv->i8254_osc_base; + *div1 = *tim2 / I8254_OSC_BASE_4MHZ; /* convert timer (burst) */ if (*div1 < this_board->ai_pacer_min) *div1 = this_board->ai_pacer_min; - *div2 = *tim1 / devpriv->i8254_osc_base; /* scan timer */ + *div2 = *tim1 / I8254_OSC_BASE_4MHZ; /* scan timer */ *div2 = *div2 / *div1; /* major timer is c1*c2 */ if (*div2 < chans) *div2 = chans; - *tim2 = *div1 * devpriv->i8254_osc_base; - /* real convert timer */ + *tim2 = *div1 * I8254_OSC_BASE_4MHZ; /* real convert timer */ if (usessh && (chnsshfront == 0)) /* use BSSH signal */ if (*div2 < (chans + 2)) *div2 = chans + 2; - *tim1 = *div1 * *div2 * devpriv->i8254_osc_base; + *tim1 = *div1 * *div2 * I8254_OSC_BASE_4MHZ; break; } } @@ -1279,7 +1276,7 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev, if (cmd->scan_begin_src == TRIG_TIMER) { tmp = cmd->scan_begin_arg; - i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, + i8253_cascade_ns_to_timer(I8254_OSC_BASE_4MHZ, &divisor1, &divisor2, &cmd->scan_begin_arg, cmd->flags); if (cmd->scan_begin_arg < this_board->ai_ns_min) @@ -1290,7 +1287,7 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev, if (cmd->convert_src & (TRIG_TIMER | TRIG_NOW)) { tmp = cmd->convert_arg; - i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, + i8253_cascade_ns_to_timer(I8254_OSC_BASE_4MHZ, &divisor1, &divisor2, &cmd->convert_arg, cmd->flags); if (cmd->convert_arg < this_board->ai_ns_min) @@ -2065,7 +2062,6 @@ static int pci9118_common_attach(struct comedi_device *dev, int disable_irq, s->insn_bits = pci9118_insn_bits_do; devpriv->valid = 1; - devpriv->i8254_osc_base = I8254_OSC_BASE_4MHZ; devpriv->ai_maskharderr = 0x10a; /* default measure crash condition */ if (hw_err_mask) /* disable some requested */ -- cgit v1.2.3 From 80ffd625f327066e2649e632cb9f13455042e551 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 5 May 2014 09:35:36 -0700 Subject: staging: comedi: adl_pci9118: remove 'ai_scans' from private data This member of the private data is just a copy of the cmd->stop_arg. Use that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index ae8afc7788d9..bfcd90c4b1f8 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -348,7 +348,6 @@ struct pci9118_private { * on external start */ unsigned short ao_data[2]; /* data output buffer */ - unsigned int ai_scans; /* number of scans to do */ char dma_doublebuf; /* we can use double buffering */ unsigned int dma_actbuf; /* which buffer is used now */ unsigned short *dmabuf_virt[2]; /* @@ -976,7 +975,7 @@ static void interrupt_pci9118_ai_onesample(struct comedi_device *dev, devpriv->ai_act_scan++; if (!devpriv->ai_neverending) { /* all data sampled? */ - if (devpriv->ai_act_scan >= devpriv->ai_scans) + if (devpriv->ai_act_scan >= cmd->stop_arg) s->async->events |= COMEDI_CB_EOA; } } @@ -991,6 +990,7 @@ static void interrupt_pci9118_ai_dma(struct comedi_device *dev, unsigned short int_daq) { struct pci9118_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; unsigned int next_dma_buf, samplesinbuf, sampls, m; if (int_amcc & MASTER_ABORT_INT) { @@ -1041,7 +1041,7 @@ static void interrupt_pci9118_ai_dma(struct comedi_device *dev, if (!devpriv->ai_neverending) { /* all data sampled? */ - if (devpriv->ai_act_scan >= devpriv->ai_scans) + if (devpriv->ai_act_scan >= cmd->stop_arg) s->async->events |= COMEDI_CB_EOA; } @@ -1332,6 +1332,7 @@ static int Compute_and_setup_dma(struct comedi_device *dev, struct comedi_subdevice *s) { struct pci9118_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; unsigned int dmalen0, dmalen1, i; dmalen0 = devpriv->dmabuf_size[0]; @@ -1413,10 +1414,10 @@ static int Compute_and_setup_dma(struct comedi_device *dev, /* fits whole measure into one DMA buffer? */ if (dmalen0 > ((devpriv->ai_n_realscanlen << 1) * - devpriv->ai_scans)) { + cmd->stop_arg)) { dmalen0 = (devpriv->ai_n_realscanlen << 1) * - devpriv->ai_scans; + cmd->stop_arg; dmalen0 &= ~3L; } else { /* * fits whole measure into @@ -1424,10 +1425,10 @@ static int Compute_and_setup_dma(struct comedi_device *dev, */ if (dmalen1 > ((devpriv->ai_n_realscanlen << 1) * - devpriv->ai_scans - dmalen0)) + cmd->stop_arg - dmalen0)) dmalen1 = (devpriv->ai_n_realscanlen << 1) * - devpriv->ai_scans - dmalen0; + cmd->stop_arg - dmalen0; dmalen1 &= ~3L; } } @@ -1630,12 +1631,8 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) #endif if (cmd->stop_src == TRIG_NONE) devpriv->ai_neverending = 1; - if (cmd->stop_src == TRIG_COUNT) { - devpriv->ai_scans = cmd->stop_arg; + if (cmd->stop_src == TRIG_COUNT) devpriv->ai_neverending = 0; - } else { - devpriv->ai_scans = 0; - } /* use sample&hold signal? */ if (cmd->convert_src == TRIG_NOW) -- cgit v1.2.3 From f3f15e54ac48b6f68f05973164abc824c4f7dfcf Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 5 May 2014 09:35:37 -0700 Subject: staging: comedi: adl_pci9118: remove 'usessh' from private data This member of the private data is only set when the cmd->convert_src is TRIG_NOW. Use that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index bfcd90c4b1f8..60cc41a7a43a 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -388,7 +388,6 @@ struct pci9118_private { * =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 @@ -784,9 +783,10 @@ static void pci9118_calc_divisors(char mode, struct comedi_device *dev, unsigned int *tim1, unsigned int *tim2, unsigned int flags, int chans, unsigned int *div1, unsigned int *div2, - char usessh, unsigned int chnsshfront) + unsigned int chnsshfront) { const struct boardtype *this_board = comedi_board(dev); + struct comedi_cmd *cmd = &s->async->cmd; switch (mode) { case 1: @@ -811,9 +811,11 @@ static void pci9118_calc_divisors(char mode, struct comedi_device *dev, *tim2 = *div1 * I8254_OSC_BASE_4MHZ; /* real convert timer */ - if (usessh && (chnsshfront == 0)) /* use BSSH signal */ + if (cmd->convert_src == TRIG_NOW && !chnsshfront) { + /* use BSSH signal */ if (*div2 < (chans + 2)) *div2 = chans + 2; + } *tim1 = *div1 * *div2 * I8254_OSC_BASE_4MHZ; break; @@ -1532,6 +1534,7 @@ static int pci9118_ai_docmd_dma(struct comedi_device *dev, struct comedi_subdevice *s) { struct pci9118_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; Compute_and_setup_dma(dev, s); @@ -1546,7 +1549,7 @@ static int pci9118_ai_docmd_dma(struct comedi_device *dev, devpriv->AdFunctionReg = AdFunction_PDTrg | AdFunction_PETrg | AdFunction_BM | AdFunction_BS; - if (devpriv->usessh && (!devpriv->softsshdelay)) + if (cmd->convert_src == TRIG_NOW && !devpriv->softsshdelay) devpriv->AdFunctionReg |= AdFunction_BSSH; outl(devpriv->ai_n_realscanlen, dev->iobase + PCI9118_BURST); break; @@ -1634,14 +1637,6 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (cmd->stop_src == TRIG_COUNT) devpriv->ai_neverending = 0; - /* use sample&hold signal? */ - if (cmd->convert_src == TRIG_NOW) - devpriv->usessh = 1; - /* yes */ - else - devpriv->usessh = 0; - /* no */ - /* * use additional sample at end of every scan * to satisty DMA 32 bit transfer? @@ -1690,7 +1685,7 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) * we need software S&H signal? * It adds two samples before every scan as minimum */ - if (devpriv->usessh && devpriv->softsshdelay) { + if (cmd->convert_src == TRIG_NOW && devpriv->softsshdelay) { devpriv->ai_add_front = 2; if ((devpriv->usedma == 1) && (devpriv->ai_add_back == 1)) { /* move it to front */ @@ -1752,7 +1747,7 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_flags, devpriv->ai_n_realscanlen, &devpriv->ai_divisor1, - &devpriv->ai_divisor2, devpriv->usessh, + &devpriv->ai_divisor2, devpriv->ai_add_front); } @@ -1773,7 +1768,7 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_flags, devpriv->ai_n_realscanlen, &devpriv->ai_divisor1, - &devpriv->ai_divisor2, devpriv->usessh, + &devpriv->ai_divisor2, devpriv->ai_add_front); } -- cgit v1.2.3 From 681a89b3e0c0b966eeda481503c658e051604d17 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 5 May 2014 09:35:38 -0700 Subject: staging: comedi: adl_pci9118: cmd->stop_src == TRIG_INT is not supported The (*do_cmdtest) only allows TRIG_COUNT, TRIG_NONE, or TRIG_EXT as the cmd->stop_src. Remove the disabled code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 60cc41a7a43a..89e6b9277250 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -1626,12 +1626,6 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai12_startstop |= START_AI_INT; s->async->inttrig = pci9118_ai_inttrig; } -#if 0 - if (cmd->stop_src == TRIG_INT) { - devpriv->ai_neverending = 1; - devpriv->ai12_startstop |= STOP_AI_INT; - } -#endif if (cmd->stop_src == TRIG_NONE) devpriv->ai_neverending = 1; if (cmd->stop_src == TRIG_COUNT) -- cgit v1.2.3 From b8546f93d9026ecfe334b31587572e7d24bac39c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 5 May 2014 09:35:39 -0700 Subject: staging: comedi: adl_pci9118: remove 'ai_buf_ptr' from private data This member of the private data is set to 0 but never used. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 89e6b9277250..dd1cd6be66ec 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -324,7 +324,6 @@ struct pci9118_private { char ai_neverending; /* we do unlimited AI */ 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_realscanlen; /* * what we must transfer for one * outgoing scan include front/back adds @@ -875,7 +874,6 @@ static int pci9118_ai_cancel(struct comedi_device *dev, devpriv->ai_act_dmapos = 0; s->async->cur_chan = 0; s->async->inttrig = NULL; - devpriv->ai_buf_ptr = 0; devpriv->ai_neverending = 0; devpriv->dma_actbuf = 0; @@ -1797,7 +1795,6 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_act_scan = 0; devpriv->ai_act_dmapos = 0; s->async->cur_chan = 0; - devpriv->ai_buf_ptr = 0; if (devpriv->usedma) ret = pci9118_ai_docmd_dma(dev, s); -- cgit v1.2.3 From 49b61195e5b5fd7884a3bddab43a2e53983988c7 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 5 May 2014 09:35:40 -0700 Subject: staging: comedi: adl_pci9118: remove 'valid' from private data This member of the private data is set only used during the (*detach) to check if the board can be reset. The pci9118_reset() function just needs a valid dev->iobase. Use that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index dd1cd6be66ec..f60dc41756e2 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -320,7 +320,6 @@ struct pci9118_private { 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 ai_do; /* what do AI? 0=nothing, 1 to 4 mode */ unsigned int ai_act_scan; /* how many scans we finished */ @@ -2044,7 +2043,6 @@ static int pci9118_common_attach(struct comedi_device *dev, int disable_irq, s->range_table = &range_digital; s->insn_bits = pci9118_insn_bits_do; - devpriv->valid = 1; devpriv->ai_maskharderr = 0x10a; /* default measure crash condition */ if (hw_err_mask) /* disable some requested */ @@ -2121,7 +2119,7 @@ static void pci9118_detach(struct comedi_device *dev) struct pci9118_private *devpriv = dev->private; if (devpriv) { - if (devpriv->valid) + if (dev->iobase) pci9118_reset(dev); if (dev->irq) free_irq(dev->irq, dev); -- cgit v1.2.3 From ad7a6230a98728e70b23559aa5e64d1ad6233d83 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 5 May 2014 09:35:41 -0700 Subject: staging: comedi: adl_pci9118: remove 'cnt0_users' from private data This member of the private data is set to 0 but never used. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index f60dc41756e2..8814b060407b 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -364,10 +364,6 @@ struct pci9118_private { 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) @@ -1857,7 +1853,6 @@ static int pci9118_reset(struct comedi_device *dev) * disable INT and DMA */ - devpriv->cnt0_users = 0; devpriv->exttrg_users = 0; return 0; -- cgit v1.2.3 From 4029bd3dad217bbf5b37ed3b2cb0c0d0005a2097 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 5 May 2014 09:35:42 -0700 Subject: staging: comedi: adl_pci9118: remove 'useeoshandle' from private data This member of the private data is always set to 0. Remove it and the affected code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 32 +++------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 8814b060407b..394337e05617 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -378,10 +378,6 @@ struct pci9118_private { */ 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 - */ int softsshdelay; /* * >0 use software S&H, * numer is requested delay in ns @@ -452,7 +448,7 @@ static int check_channel_list(struct comedi_device *dev, static int setup_channel_list(struct comedi_device *dev, struct comedi_subdevice *s, int n_chan, unsigned int *chanlist, int rot, int frontadd, - int backadd, int usedma, char useeos) + int backadd, int usedma) { struct pci9118_private *devpriv = dev->private; unsigned int i, differencial = 0, bipolar = 0; @@ -536,18 +532,6 @@ static int setup_channel_list(struct comedi_device *dev, #ifdef PCI9118_PARANOIDCHECK 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 */ - devpriv->chanlist[(n_chan + i) ^ usedma] = - (CR_CHAN(chanlist[i]) & 0xf) << rot; - } - devpriv->chanlist[(2 * n_chan) ^ usedma] = - devpriv->chanlist[0 ^ usedma]; - /* for 32bit operations */ - useeos = 2; - } else { - useeos = 1; - } #endif outl(0, dev->iobase + PCI9118_SCANMOD); /* close scan queue */ /* udelay(100); important delay, or first sample will be crippled */ @@ -587,7 +571,7 @@ static int pci9118_insn_read_ai(struct comedi_device *dev, * trigger stop */ - if (!setup_channel_list(dev, s, 1, &insn->chanspec, 0, 0, 0, 0, 0)) + if (!setup_channel_list(dev, s, 1, &insn->chanspec, 0, 0, 0, 0)) return -EINVAL; outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */ @@ -1353,8 +1337,6 @@ static int Compute_and_setup_dma(struct comedi_device *dev, } else { /* short first DMA buffer to one scan */ dmalen0 = devpriv->ai_n_realscanlen << 1; - if (devpriv->useeoshandle) - dmalen0 += 2; if (dmalen0 < 4) { dev_info(dev->class_dev, "ERR: DMA0 buf len bug? (%d<4)\n", @@ -1373,8 +1355,6 @@ static int Compute_and_setup_dma(struct comedi_device *dev, } else { /* short second DMA buffer to one scan */ dmalen1 = devpriv->ai_n_realscanlen << 1; - if (devpriv->useeoshandle) - dmalen1 -= 2; if (dmalen1 < 4) { dev_info(dev->class_dev, "ERR: DMA1 buf len bug? (%d<4)\n", @@ -1630,7 +1610,6 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) */ devpriv->ai_add_front = 0; devpriv->ai_add_back = 0; - devpriv->useeoshandle = 0; if (devpriv->master) { devpriv->usedma = 1; if ((cmd->flags & TRIG_WAKE_EOS) && @@ -1649,10 +1628,6 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) (cmd->scan_end_arg & 1) && (cmd->scan_end_arg > 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 @@ -1711,8 +1686,7 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) return -EINVAL; if (!setup_channel_list(dev, s, cmd->chanlist_len, cmd->chanlist, 0, devpriv->ai_add_front, - devpriv->ai_add_back, devpriv->usedma, - devpriv->useeoshandle)) + devpriv->ai_add_back, devpriv->usedma)) return -EINVAL; /* compute timers settings */ -- cgit v1.2.3 From 1fb2082df601fc1800ce3f16d9454f6847356c64 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 5 May 2014 09:35:43 -0700 Subject: staging: comedi: adl_pci9118: remove 'ai16bits' from private data This member of the private data is only set when the analog input subdevice maxdata is 0xffff. Just check the s->maxdata and remove the private data member. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 394337e05617..0e9fc0de8c5a 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -376,7 +376,6 @@ struct pci9118_private { * ptr to actual interrupt * AI function */ - unsigned char ai16bits; /* =1 16 bit card */ unsigned char usedma; /* =1 use DMA transfer and not INT */ int softsshdelay; /* * >0 use software S&H, @@ -586,7 +585,7 @@ static int pci9118_insn_read_ai(struct comedi_device *dev, return ret; } - if (devpriv->ai16bits) { + if (s->maxdata == 0xffff) { data[n] = (inl(dev->iobase + PCI9118_AD_DATA) & 0xffff) ^ 0x8000; @@ -908,7 +907,7 @@ 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 (s->maxdata == 0xffff) array[i] ^= 0x8000; else array[i] = (array[i] >> 4) & 0x0fff; @@ -933,7 +932,7 @@ static void interrupt_pci9118_ai_onesample(struct comedi_device *dev, sampl = inw(dev->iobase + PCI9118_AD_DATA); #ifdef PCI9118_PARANOIDCHECK - if (devpriv->ai16bits == 0) { + if (s->maxdata != 0xffff) { if ((sampl & 0x000f) != devpriv->chanlist[s->async->cur_chan]) { /* data dropout! */ dev_info(dev->class_dev, @@ -2017,15 +2016,6 @@ static int pci9118_common_attach(struct comedi_device *dev, int disable_irq, if (hw_err_mask) /* disable some requested */ devpriv->ai_maskharderr &= ~hw_err_mask; - switch (this_board->ai_maxdata) { - case 0xffff: - devpriv->ai16bits = 1; - break; - default: - devpriv->ai16bits = 0; - break; - } - return 0; } -- cgit v1.2.3 From 901be534fc8b8d7dcafa5af439df705aad31de93 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 5 May 2014 09:35:44 -0700 Subject: staging: comedi: adl_pci9118: remove 'int_ai_func' from private data The devpriv->usedma flag can be checked to determine which handler function should be used to transfer the analog input data. Do that instead and remove the member from the private data. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 0e9fc0de8c5a..358f09c64629 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -369,13 +369,6 @@ struct pci9118_private { * 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 usedma; /* =1 use DMA transfer and not INT */ int softsshdelay; /* * >0 use software S&H, @@ -1040,6 +1033,7 @@ static void interrupt_pci9118_ai_dma(struct comedi_device *dev, static irqreturn_t interrupt_pci9118(int irq, void *d) { struct comedi_device *dev = d; + struct comedi_subdevice *s = dev->read_subdev; struct pci9118_private *devpriv = dev->private; unsigned int int_daq = 0, int_amcc, int_adstat; @@ -1061,7 +1055,7 @@ static irqreturn_t interrupt_pci9118(int irq, void *d) /* get STATUS register */ if (devpriv->ai_do) { - if (devpriv->ai12_startstop) + if (devpriv->ai12_startstop) { if ((int_adstat & AdStatus_DTH) && (int_daq & Int_DTrg)) { /* start stop of measure */ @@ -1095,9 +1089,14 @@ static irqreturn_t interrupt_pci9118(int irq, void *d) } } } + } - (devpriv->int_ai_func) (dev, dev->read_subdev, int_adstat, - int_amcc, int_daq); + if (devpriv->usedma) + interrupt_pci9118_ai_dma(dev, s, int_adstat, + int_amcc, int_daq); + else + interrupt_pci9118_ai_onesample(dev, s, int_adstat, + int_amcc, int_daq); } return IRQ_HANDLED; @@ -1472,9 +1471,6 @@ static int pci9118_ai_docmd_sampl(struct comedi_device *dev, return -EIO; } - devpriv->int_ai_func = interrupt_pci9118_ai_onesample; - /* transfer function */ - if (devpriv->ai12_startstop) pci9118_exttrg_add(dev, EXTTRG_AI); /* activate EXT trigger */ @@ -1553,9 +1549,6 @@ static int pci9118_ai_docmd_dma(struct comedi_device *dev, /* activate EXT trigger */ } - devpriv->int_ai_func = interrupt_pci9118_ai_dma; - /* transfer function */ - outl(0x02000000 | AINT_WRITE_COMPL, devpriv->iobase_a + AMCC_OP_REG_INTCSR); -- cgit v1.2.3 From c089d5af6e93107af52494b816682b05affe809d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 5 May 2014 09:35:45 -0700 Subject: staging: comedi: adl_pci9118: tidy up interrupt_pci9118() For aesthetics, rename this function so it has namespace associated with the driver. Refactor the function to reduce the indent level and tidy up the code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 107 ++++++++++++--------------- 1 file changed, 47 insertions(+), 60 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 358f09c64629..b1d9e35cc657 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -1030,75 +1030,62 @@ static void interrupt_pci9118_ai_dma(struct comedi_device *dev, cfc_handle_events(dev, s); } -static irqreturn_t interrupt_pci9118(int irq, void *d) +static irqreturn_t pci9118_interrupt(int irq, void *d) { struct comedi_device *dev = d; struct comedi_subdevice *s = dev->read_subdev; struct pci9118_private *devpriv = dev->private; - unsigned int int_daq = 0, int_amcc, int_adstat; + unsigned int intsrc; /* IRQ reasons from card */ + unsigned int intcsr; /* INT register from AMCC chip */ + unsigned int adstat; /* STATUS register */ if (!dev->attached) - 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 */ - - if ((!int_daq) && (!(int_amcc & ANY_S593X_INT))) - return IRQ_NONE; /* interrupt from other source */ - - 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 */ - - if (devpriv->ai_do) { - if (devpriv->ai12_startstop) { - 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 */ - outl(devpriv->AdControlReg, - dev->iobase + PCI9118_ADCNTRL); - } else { - if (devpriv->ai12_startstop & - 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 - */ - } - } + return IRQ_NONE; + + intsrc = inl(dev->iobase + PCI9118_INTSRC) & 0xf; + intcsr = inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR); + + if (!intsrc && !(intcsr & ANY_S593X_INT)) + return IRQ_NONE; + + outl(intcsr | 0x00ff0000, devpriv->iobase_a + AMCC_OP_REG_INTCSR); + + adstat = inw(dev->iobase + PCI9118_ADSTAT) & 0x1ff; + + if (!devpriv->ai_do) + return IRQ_HANDLED; + + if (devpriv->ai12_startstop) { + if ((adstat & AdStatus_DTH) && (intsrc & Int_DTrg)) { + /* start/stop of measure */ + if (devpriv->ai12_startstop & START_AI_EXT) { + /* deactivate EXT trigger */ + devpriv->ai12_startstop &= ~START_AI_EXT; + if (!(devpriv->ai12_startstop & STOP_AI_EXT)) + pci9118_exttrg_del(dev, EXTTRG_AI); + + /* start pacer */ + start_pacer(dev, devpriv->ai_do, + devpriv->ai_divisor1, + devpriv->ai_divisor2); + outl(devpriv->AdControlReg, + dev->iobase + PCI9118_ADCNTRL); + } else if (devpriv->ai12_startstop & STOP_AI_EXT) { + /* deactivate EXT trigger */ + devpriv->ai12_startstop &= ~STOP_AI_EXT; + pci9118_exttrg_del(dev, EXTTRG_AI); + + /* on next interrupt measure will stop */ + devpriv->ai_neverending = 0; } } + } - if (devpriv->usedma) - interrupt_pci9118_ai_dma(dev, s, int_adstat, - int_amcc, int_daq); - else - interrupt_pci9118_ai_onesample(dev, s, int_adstat, - int_amcc, int_daq); + if (devpriv->usedma) + interrupt_pci9118_ai_dma(dev, s, adstat, intcsr, intsrc); + else + interrupt_pci9118_ai_onesample(dev, s, adstat, intcsr, intsrc); - } return IRQ_HANDLED; } @@ -1945,7 +1932,7 @@ static int pci9118_common_attach(struct comedi_device *dev, int disable_irq, /* Enable parity check for parity error */ if (!disable_irq && pcidev->irq) { - ret = request_irq(pcidev->irq, interrupt_pci9118, IRQF_SHARED, + ret = request_irq(pcidev->irq, pci9118_interrupt, IRQF_SHARED, dev->board_name, dev); if (ret == 0) dev->irq = pcidev->irq; -- cgit v1.2.3 From bd3772ec57f27807f6f1846b1696f0a1d0de9e5b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 5 May 2014 09:35:46 -0700 Subject: staging: comedi: adl_pci9118: tidy up start_pacer() For aesthetics, rename this function so it has namespace associated with the driver. The divisors used to load the counters are stored in the private data. Get them from there and remove the parameters. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index b1d9e35cc657..2be703767516 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -792,9 +792,12 @@ static void pci9118_calc_divisors(char mode, struct comedi_device *dev, } } -static void start_pacer(struct comedi_device *dev, int mode, - unsigned int divisor1, unsigned int divisor2) +static void pci9118_start_pacer(struct comedi_device *dev, int mode) { + struct pci9118_private *devpriv = dev->private; + unsigned int divisor1 = devpriv->ai_divisor1; + unsigned int divisor2 = devpriv->ai_divisor2; + outl(0x74, dev->iobase + PCI9118_CNTCTRL); outl(0xb4, dev->iobase + PCI9118_CNTCTRL); /* outl(0x30, dev->iobase + PCI9118_CNTCTRL); */ @@ -818,7 +821,7 @@ static int pci9118_ai_cancel(struct comedi_device *dev, (~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 */ + pci9118_start_pacer(dev, 0); /* stop 8254 counters */ devpriv->AdFunctionReg = AdFunction_PDTrg | AdFunction_PETrg; outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); /* @@ -1065,9 +1068,7 @@ static irqreturn_t pci9118_interrupt(int irq, void *d) pci9118_exttrg_del(dev, EXTTRG_AI); /* start pacer */ - start_pacer(dev, devpriv->ai_do, - devpriv->ai_divisor1, - devpriv->ai_divisor2); + pci9118_start_pacer(dev, devpriv->ai_do); outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); } else if (devpriv->ai12_startstop & STOP_AI_EXT) { @@ -1105,8 +1106,7 @@ static int pci9118_ai_inttrig(struct comedi_device *dev, outl(devpriv->IntControlReg, dev->iobase + PCI9118_INTCTRL); outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); if (devpriv->ai_do != 3) { - start_pacer(dev, devpriv->ai_do, devpriv->ai_divisor1, - devpriv->ai_divisor2); + pci9118_start_pacer(dev, devpriv->ai_do); devpriv->AdControlReg |= AdControl_SoftG; } outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); @@ -1475,8 +1475,7 @@ static int pci9118_ai_docmd_sampl(struct comedi_device *dev, outl(devpriv->IntControlReg, dev->iobase + PCI9118_INTCTRL); outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); if (devpriv->ai_do != 3) { - start_pacer(dev, devpriv->ai_do, devpriv->ai_divisor1, - devpriv->ai_divisor2); + pci9118_start_pacer(dev, devpriv->ai_do); devpriv->AdControlReg |= AdControl_SoftG; } outl(devpriv->IntControlReg, dev->iobase + PCI9118_INTCTRL); @@ -1543,8 +1542,7 @@ static int pci9118_ai_docmd_dma(struct comedi_device *dev, outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); outl(devpriv->IntControlReg, dev->iobase + PCI9118_INTCTRL); if (devpriv->ai_do != 3) { - start_pacer(dev, devpriv->ai_do, devpriv->ai_divisor1, - devpriv->ai_divisor2); + pci9118_start_pacer(dev, devpriv->ai_do); devpriv->AdControlReg |= AdControl_SoftG; } outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); @@ -1717,7 +1715,7 @@ 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 */ + pci9118_start_pacer(dev, -1); /* stop pacer */ devpriv->AdControlReg = 0; /* * bipolar, S.E., use 8254, stop 8354, @@ -1763,7 +1761,7 @@ static int pci9118_reset(struct comedi_device *dev) /* disable interrupts source */ outl(0x30, dev->iobase + PCI9118_CNTCTRL); /* outl(0xb4, dev->iobase + PCI9118_CNTCTRL); */ - start_pacer(dev, 0, 0, 0); /* stop 8254 counters */ + pci9118_start_pacer(dev, 0); /* stop 8254 counters */ devpriv->AdControlReg = 0; outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); /* -- cgit v1.2.3 From bdf2fed27642c2202f49387a6150e506a1a63535 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 5 May 2014 09:35:47 -0700 Subject: staging: comedi: adl_pci9118: remove 'cnt0_divisor' from private data This member of the private data is not used. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 2be703767516..c9c6f14f3948 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -368,7 +368,6 @@ struct pci9118_private { * bit field of external trigger * users(0-AI, 1-AO, 2-DI, 3-DO) */ - unsigned int cnt0_divisor; /* actual CNT0 divisor */ unsigned char usedma; /* =1 use DMA transfer and not INT */ int softsshdelay; /* * >0 use software S&H, -- cgit v1.2.3 From 3cc6a135d5123ecfdc4493cfd0a6a1b5b8530aca Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 5 May 2014 09:35:48 -0700 Subject: staging: comedi: adl_pci9118: remove 'dmabuf_samples' from private data This member of the private data is set but never used. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index c9c6f14f3948..89ed2d6dea0a 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -362,7 +362,6 @@ struct pci9118_private { */ 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 exttrg_users; /* * bit field of external trigger @@ -1885,8 +1884,6 @@ static int pci9118_common_attach(struct comedi_device *dev, int disable_irq, if (devpriv->dmabuf_virt[i]) { devpriv->dmabuf_pages[i] = pages; devpriv->dmabuf_size[i] = PAGE_SIZE * pages; - devpriv->dmabuf_samples[i] = - devpriv->dmabuf_size[i] >> 1; devpriv->dmabuf_hw[i] = virt_to_bus((void *) devpriv->dmabuf_virt[i]); -- cgit v1.2.3 From b978052b600c4ea00b445986680629c2867ea311 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 5 May 2014 09:48:17 -0700 Subject: staging: comedi: adl_pc19111: remove 'stop_is_none' from private data This member of the private data can be determined by checking the cmd->stop_src. Do that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9111.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index 96b1bf84d57b..430b51a521e0 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -137,7 +137,6 @@ struct pci9111_private_data { unsigned long lcr_io_base; int stop_counter; - int stop_is_none; unsigned int scan_delay; unsigned int chanlist_len; @@ -485,10 +484,8 @@ static int pci9111_ai_do_cmd(struct comedi_device *dev, if (async_cmd->stop_src == TRIG_COUNT) { dev_private->stop_counter = async_cmd->stop_arg * async_cmd->chanlist_len; - dev_private->stop_is_none = 0; } else { /* TRIG_NONE */ dev_private->stop_counter = 0; - dev_private->stop_is_none = 1; } /* Set timer pacer */ @@ -550,6 +547,7 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device) struct pci9111_private_data *dev_private = dev->private; struct comedi_subdevice *s = dev->read_subdev; struct comedi_async *async; + struct comedi_cmd *cmd; unsigned int status; unsigned long irq_flags; unsigned char intcsr; @@ -561,6 +559,7 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device) } async = s->async; + cmd = &async->cmd; spin_lock_irqsave(&dev->spinlock, irq_flags); @@ -596,12 +595,11 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device) unsigned int num_samples; unsigned int bytes_written = 0; - num_samples = - PCI9111_FIFO_HALF_SIZE > - dev_private->stop_counter - && !dev_private-> - stop_is_none ? dev_private->stop_counter : - PCI9111_FIFO_HALF_SIZE; + if (cmd->stop_src == TRIG_COUNT && + PCI9111_FIFO_HALF_SIZE > dev_private->stop_counter) + num_samples = dev_private->stop_counter; + else + num_samples = PCI9111_FIFO_HALF_SIZE; insw(dev->iobase + PCI9111_AI_FIFO_REG, dev_private->ai_bounce_buffer, num_samples); @@ -664,7 +662,7 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device) } } - if (dev_private->stop_counter == 0 && !dev_private->stop_is_none) + if (cmd->stop_src == TRIG_COUNT && dev_private->stop_counter == 0) async->events |= COMEDI_CB_EOA; outb(0, dev->iobase + PCI9111_INT_CLR_REG); -- cgit v1.2.3 From 8eb18913e16db9c0915bd4e7374608588d3477f2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 5 May 2014 09:48:18 -0700 Subject: staging: comedi: adl_pc19111: rename 'async_cmd' variable in (*do_cmd) The comedi_cmd pointer is typically just called 'cmd'. Rename the local variable in pci9111_ai_do_cmd(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9111.c | 30 ++++++++++++---------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index 430b51a521e0..7596b4e8a96b 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -458,18 +458,18 @@ static int pci9111_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct pci9111_private_data *dev_private = dev->private; - struct comedi_cmd *async_cmd = &s->async->cmd; + struct comedi_cmd *cmd = &s->async->cmd; /* Set channel scan limit */ /* PCI9111 allows only scanning from channel 0 to channel n */ /* TODO: handle the case of an external multiplexer */ - if (async_cmd->chanlist_len > 1) { - outb(async_cmd->chanlist_len - 1, + if (cmd->chanlist_len > 1) { + outb(cmd->chanlist_len - 1, dev->iobase + PCI9111_AI_CHANNEL_REG); pci9111_autoscan_set(dev, true); } else { - outb(CR_CHAN(async_cmd->chanlist[0]), + outb(CR_CHAN(cmd->chanlist[0]), dev->iobase + PCI9111_AI_CHANNEL_REG); pci9111_autoscan_set(dev, false); } @@ -477,20 +477,18 @@ static int pci9111_ai_do_cmd(struct comedi_device *dev, /* Set gain */ /* This is the same gain on every channel */ - outb(CR_RANGE(async_cmd->chanlist[0]) & PCI9111_AI_RANGE_MASK, + outb(CR_RANGE(cmd->chanlist[0]) & PCI9111_AI_RANGE_MASK, dev->iobase + PCI9111_AI_RANGE_STAT_REG); /* Set counter */ - if (async_cmd->stop_src == TRIG_COUNT) { - dev_private->stop_counter = - async_cmd->stop_arg * async_cmd->chanlist_len; - } else { /* TRIG_NONE */ + if (cmd->stop_src == TRIG_COUNT) + dev_private->stop_counter = cmd->stop_arg * cmd->chanlist_len; + else /* TRIG_NONE */ dev_private->stop_counter = 0; - } /* Set timer pacer */ dev_private->scan_delay = 0; - if (async_cmd->convert_src == TRIG_TIMER) { + if (cmd->convert_src == TRIG_TIMER) { pci9111_trigger_source_set(dev, software); pci9111_timer_set(dev); pci9111_fifo_reset(dev); @@ -500,11 +498,9 @@ static int pci9111_ai_do_cmd(struct comedi_device *dev, plx9050_interrupt_control(dev_private->lcr_io_base, true, true, false, true, true); - if (async_cmd->scan_begin_src == TRIG_TIMER) { - dev_private->scan_delay = - (async_cmd->scan_begin_arg / - (async_cmd->convert_arg * - async_cmd->chanlist_len)) - 1; + if (cmd->scan_begin_src == TRIG_TIMER) { + dev_private->scan_delay = (cmd->scan_begin_arg / + (cmd->convert_arg * cmd->chanlist_len)) - 1; } } else { /* TRIG_EXT */ pci9111_trigger_source_set(dev, external); @@ -517,7 +513,7 @@ static int pci9111_ai_do_cmd(struct comedi_device *dev, } dev_private->stop_counter *= (1 + dev_private->scan_delay); - dev_private->chanlist_len = async_cmd->chanlist_len; + dev_private->chanlist_len = cmd->chanlist_len; dev_private->chunk_counter = 0; dev_private->chunk_num_samples = dev_private->chanlist_len * (1 + dev_private->scan_delay); -- cgit v1.2.3 From cae5c9fb97596e2caf2fd081a43b0d1f302fdcd8 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 5 May 2014 09:48:19 -0700 Subject: staging: comedi: adl_pc19111: remove 'chanlist_len' from private data This member of the private data is a copy of the cmd->chanlist_len. Use that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9111.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index 7596b4e8a96b..c84930ca8040 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -139,7 +139,6 @@ struct pci9111_private_data { int stop_counter; unsigned int scan_delay; - unsigned int chanlist_len; unsigned int chunk_counter; unsigned int chunk_num_samples; @@ -513,10 +512,9 @@ static int pci9111_ai_do_cmd(struct comedi_device *dev, } dev_private->stop_counter *= (1 + dev_private->scan_delay); - dev_private->chanlist_len = cmd->chanlist_len; dev_private->chunk_counter = 0; - dev_private->chunk_num_samples = - dev_private->chanlist_len * (1 + dev_private->scan_delay); + dev_private->chunk_num_samples = cmd->chanlist_len * + (1 + dev_private->scan_delay); return 0; } @@ -612,9 +610,8 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device) while (position < num_samples) { if (dev_private->chunk_counter < - dev_private->chanlist_len) { - to_read = - dev_private->chanlist_len - + cmd->chanlist_len) { + to_read = cmd->chanlist_len - dev_private->chunk_counter; if (to_read > -- cgit v1.2.3 From 22a270483da663b5c603e21a1e26742420fdf798 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 6 May 2014 10:55:23 -0700 Subject: staging: comedi: amplc_dio200_common: remove 'continuous' from subdevice private data This member of the subdevice private data can be determined from the cmd->stop_src. Do that instead. Signed-off-by: H Hartley Sweeten Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_dio200_common.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index ee18537b5a92..5125bf0ecb72 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -130,7 +130,6 @@ struct dio200_subdev_intr { unsigned int enabled_isns; unsigned int stopcount; bool active:1; - bool continuous:1; }; static inline const struct dio200_layout * @@ -259,7 +258,7 @@ static int dio200_start_intr(struct comedi_device *dev, struct comedi_cmd *cmd = &s->async->cmd; int retval = 0; - if (!subpriv->continuous && subpriv->stopcount == 0) { + if (cmd->stop_src == TRIG_COUNT && subpriv->stopcount == 0) { /* An empty acquisition! */ s->async->events |= COMEDI_CB_EOA; subpriv->active = false; @@ -311,6 +310,7 @@ static void dio200_read_scan_intr(struct comedi_device *dev, unsigned int triggered) { struct dio200_subdev_intr *subpriv = s->private; + struct comedi_cmd *cmd = &s->async->cmd; unsigned short val; unsigned int n, ch, len; @@ -332,8 +332,7 @@ static void dio200_read_scan_intr(struct comedi_device *dev, } /* Check for end of acquisition. */ - if (!subpriv->continuous) { - /* stop_src == TRIG_COUNT */ + if (cmd->stop_src == TRIG_COUNT) { if (subpriv->stopcount > 0) { subpriv->stopcount--; if (subpriv->stopcount == 0) { @@ -512,17 +511,10 @@ static int dio200_subdev_intr_cmd(struct comedi_device *dev, subpriv->active = true; /* Set up end of acquisition. */ - switch (cmd->stop_src) { - case TRIG_COUNT: - subpriv->continuous = false; + if (cmd->stop_src == TRIG_COUNT) subpriv->stopcount = cmd->stop_arg; - break; - default: - /* TRIG_NONE */ - subpriv->continuous = true; + else /* TRIG_NONE */ subpriv->stopcount = 0; - break; - } if (cmd->start_src == TRIG_INT) s->async->inttrig = dio200_inttrig_start_intr; -- cgit v1.2.3 From af50b31b21126daea60e63a42ed241b807fb8c99 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 6 May 2014 12:26:04 -0700 Subject: staging: comedi: amplc_pci224: use comedi_fc helpers to validate timer args Use the comedi_fc helper cfc_check_trigger_arg_is() to validate the scan_begin_arg when the scan_begin_src is TRIG_TIMER. For aesthetics reasons, rename the local variable 'tmp' to 'arg'. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci224.c | 28 +++++++++++++-------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index c2b352c3c6a6..da4634e8cfeb 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -719,7 +719,7 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, { struct pci224_private *devpriv = dev->private; int err = 0; - unsigned int tmp; + unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -746,14 +746,14 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, * There's only one external trigger signal (which makes these * tests easier). Only one thing can use it. */ - tmp = 0; + arg = 0; if (cmd->start_src & TRIG_EXT) - tmp++; + arg++; if (cmd->scan_begin_src & TRIG_EXT) - tmp++; + arg++; if (cmd->stop_src & TRIG_EXT) - tmp++; - if (tmp > 1) + arg++; + if (arg > 1) err |= -EINVAL; if (err) @@ -786,10 +786,10 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, err |= cfc_check_trigger_arg_max(&cmd->scan_begin_arg, MAX_SCAN_PERIOD); - tmp = cmd->chanlist_len * CONVERT_PERIOD; - if (tmp < MIN_SCAN_PERIOD) - tmp = MIN_SCAN_PERIOD; - err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, tmp); + arg = cmd->chanlist_len * CONVERT_PERIOD; + if (arg < MIN_SCAN_PERIOD) + arg = MIN_SCAN_PERIOD; + err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, arg); break; case TRIG_EXT: /* Force to external trigger 0. */ @@ -840,15 +840,13 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, /* Step 4: fix up any arguments. */ if (cmd->scan_begin_src == TRIG_TIMER) { - tmp = cmd->scan_begin_arg; + arg = cmd->scan_begin_arg; /* Use two timers. */ i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, &devpriv->cached_div1, &devpriv->cached_div2, - &cmd->scan_begin_arg, - cmd->flags); - if (tmp != cmd->scan_begin_arg) - err++; + &arg, cmd->flags); + err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg); } if (err) -- cgit v1.2.3 From 53030b138e555d9406e5c8920e877f0a3c5d5c7d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 6 May 2014 16:08:56 -0700 Subject: staging: comedi: pcl730: add support for Diamond Systems PC/104 modules The Diamond Systems OPMM-1616-XT board is a PC/104 module with 16 optoisolated inputs and 16 relay outputs. The PEARL-MM-P board is a PC/104 module with 16 relay outputs. Both of these boards can be supported by the pcl730 driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/Kconfig | 22 +++++++++++--------- drivers/staging/comedi/drivers/pcl730.c | 36 +++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 703c5d40ae5c..5d56428d508a 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -160,16 +160,18 @@ config COMEDI_PCL730 Enable support for various simple ISA or PC/104 Digital I/O boards. These boards all use 8-bit I/O ports. - Advantech PCL-730 isolated - 16 in/16 out ttl - 16 in/16 out - ICP ISO-730 isolated - 16 in/16 out ttl - 16 in/16 out - ADlink ACL-7130 isolated - 16 in/16 out ttl - 16 in/16 out - Advantech PCM-3730 isolated - 8 in/8 out ttl - 16 in/16 out - Advantech PCL-725 isolated - 8 in/8 out - ICP P8R8-DIO isolated - 8 in/8 out - ADlink ACL-7225b isolated - 16 in/16 out - ICP P16R16-DIO isolated - 16 in/16 out - Advantech PCL-733 isolated - 32 in - Advantech PCL-734 isolated - 32 out + Advantech PCL-730 iso - 16 in/16 out ttl - 16 in/16 out + ICP ISO-730 iso - 16 in/16 out ttl - 16 in/16 out + ADlink ACL-7130 iso - 16 in/16 out ttl - 16 in/16 out + Advantech PCM-3730 iso - 8 in/8 out ttl - 16 in/16 out + Advantech PCL-725 iso - 8 in/8 out + ICP P8R8-DIO iso - 8 in/8 out + ADlink ACL-7225b iso - 16 in/16 out + ICP P16R16-DIO iso - 16 in/16 out + Advantech PCL-733 iso - 32 in + Advantech PCL-734 iso - 32 out + Diamond Systems OPMM-1616-XT iso - 16 in/16 out + Diamond Systems PEARL-MM-P iso - 16 out To compile this driver as a module, choose M here: the module will be called pcl730. diff --git a/drivers/staging/comedi/drivers/pcl730.c b/drivers/staging/comedi/drivers/pcl730.c index 2baaf1db6fbf..7fb044ce399b 100644 --- a/drivers/staging/comedi/drivers/pcl730.c +++ b/drivers/staging/comedi/drivers/pcl730.c @@ -17,6 +17,8 @@ * (ICP) P16R16-DIO [p16r16dio] * (Advantech) PCL-733 [pcl733] * (Advantech) PCL-734 [pcl734] + * (Diamond Systems) OPMM-1616-XT [opmm-1616-xt] + * (Diamond Systems) PEARL-MM-P [prearl-mm-p] * Author: José Luis Sánchez (jsanchezv@teleline.es) * Status: untested * @@ -70,6 +72,27 @@ * BASE+1 Isolated outputs 8-15 (write) or inputs 8-15 (read) * BASE+2 Isolated outputs 16-23 (write) or inputs 16-23 (read) * BASE+3 Isolated outputs 24-31 (write) or inputs 24-31 (read) + * + * The opmm-1616-xt board has this register mapping: + * + * BASE+0 Isolated outputs 0-7 (write) (read back) + * BASE+1 Isolated outputs 8-15 (write) (read back) + * BASE+2 Isolated inputs 0-7 (read) + * BASE+3 Isolated inputs 8-15 (read) + * + * These registers are not currently supported: + * + * BASE+2 Relay select register (write) + * BASE+3 Board reset control register (write) + * BASE+4 Interrupt control register (write) + * BASE+4 Change detect 7-0 status register (read) + * BASE+5 LED control register (write) + * BASE+5 Change detect 15-8 status register (read) + * + * The pearl-mm-p board has this register mapping: + * + * BASE+0 Isolated outputs 0-7 (write) + * BASE+1 Isolated outputs 8-15 (write) */ struct pcl730_board { @@ -158,6 +181,19 @@ static const struct pcl730_board pcl730_boards[] = { .io_range = 0x04, .n_subdevs = 1, .n_iso_out_chan = 32, + }, { + .name = "opmm-1616-xt", + .io_range = 0x10, + .is_acl7225b = 1, + .has_readback = 1, + .n_subdevs = 2, + .n_iso_out_chan = 16, + .n_iso_in_chan = 16, + }, { + .name = "pearl-mm-p", + .io_range = 0x02, + .n_subdevs = 1, + .n_iso_out_chan = 16, }, }; -- cgit v1.2.3 From 3672effdeae5395d661a2103f69082146ef949fc Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 6 May 2014 13:11:59 +0100 Subject: staging: comedi: pass subdevice to comedi_buf_put() Change the parameters of `comedi_buf_put()` to pass a pointer to the comedi subdevice instead of a pointer to the "async" structure belonging to the subdevice. The function puts a sample value in the comedi buffer, but currently only deals with 16-bit sample types. A future version could deal with 16 or 32-bit sample types depending on the value of the SDF_LSAMPL subdevice flag. The main aim at the moment is to replace all the `struct comedi_async *` parameters with `struct comedi_subdevice *` parameters in the comedi driver API. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 3 ++- drivers/staging/comedi/comedidev.h | 2 +- drivers/staging/comedi/drivers/8255.c | 2 +- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 2 +- drivers/staging/comedi/drivers/addi_apci_1032.c | 2 +- drivers/staging/comedi/drivers/addi_apci_2032.c | 2 +- drivers/staging/comedi/drivers/addi_apci_3xxx.c | 2 +- drivers/staging/comedi/drivers/adv_pci1710.c | 4 ++-- drivers/staging/comedi/drivers/amplc_dio200_common.c | 2 +- drivers/staging/comedi/drivers/amplc_pc236.c | 2 +- drivers/staging/comedi/drivers/amplc_pci230.c | 2 +- drivers/staging/comedi/drivers/comedi_parport.c | 2 +- drivers/staging/comedi/drivers/dmm32at.c | 8 +------- drivers/staging/comedi/drivers/dt282x.c | 2 +- drivers/staging/comedi/drivers/dt3000.c | 2 +- drivers/staging/comedi/drivers/me4000.c | 4 ++-- drivers/staging/comedi/drivers/ni_6527.c | 2 +- drivers/staging/comedi/drivers/ni_65xx.c | 2 +- drivers/staging/comedi/drivers/ni_atmio16d.c | 2 +- drivers/staging/comedi/drivers/ni_pcidio.c | 4 ++-- drivers/staging/comedi/drivers/pcl711.c | 2 +- drivers/staging/comedi/drivers/pcl726.c | 2 +- drivers/staging/comedi/drivers/pcl812.c | 4 ++-- drivers/staging/comedi/drivers/pcl816.c | 2 +- drivers/staging/comedi/drivers/pcl818.c | 6 +++--- drivers/staging/comedi/drivers/pcmmio.c | 4 ++-- drivers/staging/comedi/drivers/pcmuio.c | 4 ++-- drivers/staging/comedi/drivers/quatech_daqp_cs.c | 2 +- drivers/staging/comedi/drivers/rtd520.c | 4 ++-- drivers/staging/comedi/drivers/s626.c | 1 - drivers/staging/comedi/drivers/usbdux.c | 2 +- 31 files changed, 40 insertions(+), 46 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index 257595016161..f127bf9bd421 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -416,8 +416,9 @@ unsigned int comedi_buf_read_free(struct comedi_async *async, } EXPORT_SYMBOL_GPL(comedi_buf_read_free); -int comedi_buf_put(struct comedi_async *async, unsigned short x) +int comedi_buf_put(struct comedi_subdevice *s, unsigned short x) { + struct comedi_async *async = s->async; unsigned int n = __comedi_buf_write_alloc(async, sizeof(short), 1); if (n < sizeof(short)) { diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index d46123a97582..a874c1c43a32 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -343,7 +343,7 @@ unsigned int comedi_buf_read_n_available(struct comedi_async *); unsigned int comedi_buf_read_alloc(struct comedi_async *, unsigned int); unsigned int comedi_buf_read_free(struct comedi_async *, unsigned int); -int comedi_buf_put(struct comedi_async *, unsigned short); +int comedi_buf_put(struct comedi_subdevice *s, unsigned short x); int comedi_buf_get(struct comedi_async *, unsigned short *); void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset, diff --git a/drivers/staging/comedi/drivers/8255.c b/drivers/staging/comedi/drivers/8255.c index 1d53e241e84d..46113a374133 100644 --- a/drivers/staging/comedi/drivers/8255.c +++ b/drivers/staging/comedi/drivers/8255.c @@ -117,7 +117,7 @@ void subdev_8255_interrupt(struct comedi_device *dev, d = spriv->io(0, _8255_DATA, 0, iobase); d |= (spriv->io(0, _8255_DATA + 1, 0, iobase) << 8); - comedi_buf_put(s->async, d); + comedi_buf_put(s, d); s->async->events |= COMEDI_CB_EOS; comedi_event(dev, s); diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index e3aa89780c2c..764c8f17f8fa 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -1520,7 +1520,7 @@ static int apci3120_interrupt_handle_eos(struct comedi_device *dev) n_chan = devpriv->ui_AiNbrofChannels; for (i = 0; i < n_chan; i++) - err &= comedi_buf_put(s->async, inw(dev->iobase + 0)); + err &= comedi_buf_put(s, inw(dev->iobase + 0)); s->async->events |= COMEDI_CB_EOS; diff --git a/drivers/staging/comedi/drivers/addi_apci_1032.c b/drivers/staging/comedi/drivers/addi_apci_1032.c index c242afc9134d..1b2e7c040c9f 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1032.c +++ b/drivers/staging/comedi/drivers/addi_apci_1032.c @@ -262,7 +262,7 @@ static irqreturn_t apci1032_interrupt(int irq, void *d) outl(ctrl & ~APCI1032_CTRL_INT_ENA, dev->iobase + APCI1032_CTRL_REG); s->state = inl(dev->iobase + APCI1032_STATUS_REG) & 0xffff; - comedi_buf_put(s->async, s->state); + comedi_buf_put(s, s->state); s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS; comedi_event(dev, s); diff --git a/drivers/staging/comedi/drivers/addi_apci_2032.c b/drivers/staging/comedi/drivers/addi_apci_2032.c index 2fd14553e57c..be0a8a7bd3b2 100644 --- a/drivers/staging/comedi/drivers/addi_apci_2032.c +++ b/drivers/staging/comedi/drivers/addi_apci_2032.c @@ -234,7 +234,7 @@ static irqreturn_t apci2032_interrupt(int irq, void *d) bits |= (1 << i); } - if (comedi_buf_put(s->async, bits)) { + if (comedi_buf_put(s, bits)) { s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS; if (cmd->stop_src == TRIG_COUNT && subpriv->stop_count > 0) { diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c index f290be818845..df3b63ac4a0e 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c +++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c @@ -373,7 +373,7 @@ static irqreturn_t apci3xxx_irq_handler(int irq, void *d) writel(status, devpriv->mmio + 16); val = readl(devpriv->mmio + 28); - comedi_buf_put(s->async, val); + comedi_buf_put(s, val); s->async->events |= COMEDI_CB_EOA; comedi_event(dev, s); diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 0dc946eaa743..a459bdf7e352 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -770,7 +770,7 @@ static void pci1710_handle_every_sample(struct comedi_device *dev, break; } - comedi_buf_put(s->async, val & s->maxdata); + comedi_buf_put(s, val & s->maxdata); s->async->cur_chan++; if (s->async->cur_chan >= cmd->chanlist_len) @@ -814,7 +814,7 @@ static int move_block_from_fifo(struct comedi_device *dev, return ret; } - comedi_buf_put(s->async, val & s->maxdata); + comedi_buf_put(s, val & s->maxdata); s->async->cur_chan++; if (s->async->cur_chan >= cmd->chanlist_len) { diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index 5125bf0ecb72..1a580c374ca8 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -322,7 +322,7 @@ static void dio200_read_scan_intr(struct comedi_device *dev, val |= (1U << n); } /* Write the scan to the buffer. */ - if (comedi_buf_put(s->async, val)) { + if (comedi_buf_put(s, val)) { s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS); } else { /* Error! Stop acquisition. */ diff --git a/drivers/staging/comedi/drivers/amplc_pc236.c b/drivers/staging/comedi/drivers/amplc_pc236.c index 2834d0a9342a..c9a96ad00559 100644 --- a/drivers/staging/comedi/drivers/amplc_pc236.c +++ b/drivers/staging/comedi/drivers/amplc_pc236.c @@ -361,7 +361,7 @@ static irqreturn_t pc236_interrupt(int irq, void *d) handled = pc236_intr_check(dev); if (dev->attached && handled) { - comedi_buf_put(s->async, 0); + comedi_buf_put(s, 0); s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS; comedi_event(dev, s); } diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index ff927c641748..9541e240925e 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -2209,7 +2209,7 @@ static void pci230_handle_ai(struct comedi_device *dev, } } /* Read sample and store in Comedi's circular buffer. */ - if (comedi_buf_put(async, pci230_ai_read(dev)) == 0) { + if (comedi_buf_put(s, pci230_ai_read(dev)) == 0) { events |= COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW; comedi_error(dev, "AI buffer overflow"); break; diff --git a/drivers/staging/comedi/drivers/comedi_parport.c b/drivers/staging/comedi/drivers/comedi_parport.c index 50723b940630..a42748692357 100644 --- a/drivers/staging/comedi/drivers/comedi_parport.c +++ b/drivers/staging/comedi/drivers/comedi_parport.c @@ -229,7 +229,7 @@ static irqreturn_t parport_interrupt(int irq, void *d) if (!(ctrl & PARPORT_CTRL_IRQ_ENA)) return IRQ_NONE; - comedi_buf_put(s->async, 0); + comedi_buf_put(s, 0); s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS; comedi_event(dev, s); diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 68260e6658e4..931150150e10 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -473,12 +473,6 @@ static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) outb(0xff, dev->iobase + DMM32AT_CONV); } -/* for(i=0;ichanlist_len;i++) */ -/* comedi_buf_put(s->async,i*100); */ - -/* s->async->events |= COMEDI_CB_EOA; */ -/* comedi_event(dev, s); */ - return 0; } @@ -519,7 +513,7 @@ static irqreturn_t dmm32at_isr(int irq, void *d) /* invert sign bit to make range unsigned */ samp = ((msb ^ 0x0080) << 8) + lsb; - comedi_buf_put(s->async, samp); + comedi_buf_put(s, samp); } if (devpriv->ai_scans_left != 0xffffffff) { /* TRIG_COUNT */ diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index 474f52dac15d..15d5145166e0 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -466,7 +466,7 @@ static irqreturn_t dt282x_interrupt(int irq, void *d) if (devpriv->ad_2scomp) data ^= 1 << (board->adbits - 1); - ret = comedi_buf_put(s->async, data); + ret = comedi_buf_put(s, data); if (ret == 0) s->async->events |= COMEDI_CB_OVERFLOW; diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/staging/comedi/drivers/dt3000.c index 436e451cadf5..abd999f95f70 100644 --- a/drivers/staging/comedi/drivers/dt3000.c +++ b/drivers/staging/comedi/drivers/dt3000.c @@ -322,7 +322,7 @@ static void dt3k_ai_empty_fifo(struct comedi_device *dev, for (i = 0; i < count; i++) { data = readw(devpriv->io_addr + DPR_ADC_buffer + rear); - comedi_buf_put(s->async, data); + comedi_buf_put(s, data); rear++; if (rear >= AI_FIFO_DEPTH) rear = 0; diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c index a08bc6ffad30..25ce2f78db81 100644 --- a/drivers/staging/comedi/drivers/me4000.c +++ b/drivers/staging/comedi/drivers/me4000.c @@ -1124,7 +1124,7 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id) lval = inl(dev->iobase + ME4000_AI_DATA_REG) & 0xFFFF; lval ^= 0x8000; - if (!comedi_buf_put(s->async, lval)) { + if (!comedi_buf_put(s, lval)) { /* * Buffer overflow, so stop conversion * and disable all interrupts @@ -1169,7 +1169,7 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id) lval = inl(dev->iobase + ME4000_AI_DATA_REG) & 0xFFFF; lval ^= 0x8000; - if (!comedi_buf_put(s->async, lval)) { + if (!comedi_buf_put(s, lval)) { dev_err(dev->class_dev, "Buffer overflow\n"); s->async->events |= COMEDI_CB_OVERFLOW; break; diff --git a/drivers/staging/comedi/drivers/ni_6527.c b/drivers/staging/comedi/drivers/ni_6527.c index 2b2dafe29c05..c8b1fa793a37 100644 --- a/drivers/staging/comedi/drivers/ni_6527.c +++ b/drivers/staging/comedi/drivers/ni_6527.c @@ -215,7 +215,7 @@ static irqreturn_t ni6527_interrupt(int irq, void *d) return IRQ_NONE; if (status & NI6527_STATUS_EDGE) { - comedi_buf_put(s->async, 0); + comedi_buf_put(s, 0); s->async->events |= COMEDI_CB_EOS; comedi_event(dev, s); } diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c index 2051a7c5de10..a74fd1e60c28 100644 --- a/drivers/staging/comedi/drivers/ni_65xx.c +++ b/drivers/staging/comedi/drivers/ni_65xx.c @@ -439,7 +439,7 @@ static irqreturn_t ni_65xx_interrupt(int irq, void *d) writeb(ClrEdge | ClrOverflow, devpriv->mite->daq_io_addr + Clear_Register); - comedi_buf_put(s->async, 0); + comedi_buf_put(s, 0); s->async->events |= COMEDI_CB_EOS; comedi_event(dev, s); return IRQ_HANDLED; diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c b/drivers/staging/comedi/drivers/ni_atmio16d.c index 4262385e4f46..6ad27f50c6ec 100644 --- a/drivers/staging/comedi/drivers/ni_atmio16d.c +++ b/drivers/staging/comedi/drivers/ni_atmio16d.c @@ -221,7 +221,7 @@ static irqreturn_t atmio16d_interrupt(int irq, void *d) struct comedi_device *dev = d; struct comedi_subdevice *s = dev->read_subdev; - comedi_buf_put(s->async, inw(dev->iobase + AD_FIFO_REG)); + comedi_buf_put(s, inw(dev->iobase + AD_FIFO_REG)); comedi_event(dev, s); return IRQ_HANDLED; diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c index 962c2353a79f..6dd10044a023 100644 --- a/drivers/staging/comedi/drivers/ni_pcidio.c +++ b/drivers/staging/comedi/drivers/ni_pcidio.c @@ -447,8 +447,8 @@ static irqreturn_t nidio_interrupt(int irq, void *d) Group_1_FIFO); data1 = auxdata & 0xffff; data2 = (auxdata & 0xffff0000) >> 16; - comedi_buf_put(async, data1); - comedi_buf_put(async, data2); + comedi_buf_put(s, data1); + comedi_buf_put(s, data2); flags = readb(devpriv->mite->daq_io_addr + Group_1_Flags); } diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c index 2da6fec6ab4c..ef3ebeef7a4d 100644 --- a/drivers/staging/comedi/drivers/pcl711.c +++ b/drivers/staging/comedi/drivers/pcl711.c @@ -213,7 +213,7 @@ static irqreturn_t pcl711_interrupt(int irq, void *d) outb(PCL711_INT_STAT_CLR, dev->iobase + PCL711_INT_STAT_REG); - if (comedi_buf_put(s->async, data) == 0) { + if (comedi_buf_put(s, data) == 0) { s->async->events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR; } else { s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS; diff --git a/drivers/staging/comedi/drivers/pcl726.c b/drivers/staging/comedi/drivers/pcl726.c index 07ff1e22e61c..74f6489bd124 100644 --- a/drivers/staging/comedi/drivers/pcl726.c +++ b/drivers/staging/comedi/drivers/pcl726.c @@ -240,7 +240,7 @@ static irqreturn_t pcl726_interrupt(int irq, void *d) if (devpriv->cmd_running) { pcl726_intr_cancel(dev, s); - comedi_buf_put(s->async, 0); + comedi_buf_put(s, 0); s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS); comedi_event(dev, s); } diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 0cf115e54308..542178bba2d4 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -882,7 +882,7 @@ static void pcl812_handle_eoc(struct comedi_device *dev, return; } - comedi_buf_put(s->async, pcl812_ai_get_sample(dev, s)); + comedi_buf_put(s, pcl812_ai_get_sample(dev, s)); /* Set up next channel. Added by abbotti 2010-01-20, but untested. */ next_chan = s->async->cur_chan + 1; @@ -902,7 +902,7 @@ static void transfer_from_dma_buf(struct comedi_device *dev, unsigned int i; for (i = len; i; i--) { - comedi_buf_put(s->async, ptr[bufptr++]); + comedi_buf_put(s, ptr[bufptr++]); if (!pcl812_ai_next_chan(dev, s)) break; diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 6f276f23fabe..1260122ee7ab 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -322,7 +322,7 @@ static void transfer_from_dma_buf(struct comedi_device *dev, int i; for (i = 0; i < len; i++) { - comedi_buf_put(s->async, ptr[bufptr++]); + comedi_buf_put(s, ptr[bufptr++]); if (!pcl816_ai_next_chan(dev, s)) return; diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 6463476ce45a..b960b66bc9a8 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -561,7 +561,7 @@ static void pcl818_handle_eoc(struct comedi_device *dev, if (pcl818_ai_dropout(dev, s, chan)) return; - comedi_buf_put(s->async, val); + comedi_buf_put(s, val); pcl818_ai_next_chan(dev, s); } @@ -590,7 +590,7 @@ static void pcl818_handle_dma(struct comedi_device *dev, if (pcl818_ai_dropout(dev, s, chan)) break; - comedi_buf_put(s->async, val); + comedi_buf_put(s, val); if (!pcl818_ai_next_chan(dev, s)) break; @@ -630,7 +630,7 @@ static void pcl818_handle_fifo(struct comedi_device *dev, if (pcl818_ai_dropout(dev, s, chan)) break; - comedi_buf_put(s->async, val); + comedi_buf_put(s, val); if (!pcl818_ai_next_chan(dev, s)) break; diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c index bb29ecfcfef4..2d185136db78 100644 --- a/drivers/staging/comedi/drivers/pcmmio.c +++ b/drivers/staging/comedi/drivers/pcmmio.c @@ -361,8 +361,8 @@ static void pcmmio_handle_dio_intr(struct comedi_device *dev, } /* Write the scan to the buffer. */ - if (comedi_buf_put(s->async, val) && - comedi_buf_put(s->async, val >> 16)) { + if (comedi_buf_put(s, val) && + comedi_buf_put(s, val >> 16)) { s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS); } else { /* Overflow! Stop acquisition!! */ diff --git a/drivers/staging/comedi/drivers/pcmuio.c b/drivers/staging/comedi/drivers/pcmuio.c index ea45424e8410..182b48a3e88b 100644 --- a/drivers/staging/comedi/drivers/pcmuio.c +++ b/drivers/staging/comedi/drivers/pcmuio.c @@ -338,8 +338,8 @@ static void pcmuio_handle_intr_subdev(struct comedi_device *dev, } /* Write the scan to the buffer. */ - if (comedi_buf_put(s->async, val) && - comedi_buf_put(s->async, val >> 16)) { + if (comedi_buf_put(s, val) && + comedi_buf_put(s, val >> 16)) { s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS); } else { /* Overflow! Stop acquisition!! */ diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c index 298dba03f902..0a8edb8cc190 100644 --- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c +++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c @@ -221,7 +221,7 @@ static enum irqreturn daqp_interrupt(int irq, void *dev_id) data |= inb(dev->iobase + DAQP_FIFO) << 8; data ^= 0x8000; - comedi_buf_put(s->async, data); + comedi_buf_put(s, data); /* If there's a limit, decrement it * and stop conversion if zero diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c index e7c2e34624d9..28402d2f92a2 100644 --- a/drivers/staging/comedi/drivers/rtd520.c +++ b/drivers/staging/comedi/drivers/rtd520.c @@ -629,7 +629,7 @@ static int ai_read_n(struct comedi_device *dev, struct comedi_subdevice *s, d = comedi_offset_munge(s, d); d &= s->maxdata; - if (!comedi_buf_put(s->async, d)) + if (!comedi_buf_put(s, d)) return -1; if (devpriv->ai_count > 0) /* < 0, means read forever */ @@ -658,7 +658,7 @@ static int ai_read_dregs(struct comedi_device *dev, struct comedi_subdevice *s) d = comedi_offset_munge(s, d); d &= s->maxdata; - if (!comedi_buf_put(s->async, d)) + if (!comedi_buf_put(s, d)) return -1; if (devpriv->ai_count > 0) /* < 0, means read forever */ diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index 647b9e50bd74..33b4d027a5cb 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c @@ -1628,7 +1628,6 @@ static bool s626_handle_eos_interrupt(struct comedi_device *dev) readaddr++; /* put data into read buffer */ - /* comedi_buf_put(async, tempdata); */ cfc_write_to_buffer(s, tempdata); } diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 4002f49f0082..011fede33a00 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -373,7 +373,7 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb) val ^= ((s->maxdata + 1) >> 1); /* transfer data */ - err = comedi_buf_put(s->async, val); + err = comedi_buf_put(s, val); if (unlikely(err == 0)) { /* buffer overflow */ usbdux_ai_stop(dev, 0); -- cgit v1.2.3 From 458c13e935d9f33fffb099e49ecb53c67ddd1a21 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 6 May 2014 13:12:00 +0100 Subject: staging: comedi: pass subdevice to comedi_buf_get() Change the parameters of `comedi_buf_get()` to pass a pointer to the comedi subdevice instead of a pointer to the "async" structure belonging to the subdevice. The function gets a sample value from the comedi buffer, but currently only deals with 16-bit sample types. A future version could deal with 16 or 32-bit sample types depending on the value of the SDF_LSAMPL subdevice flag. The main aim at the moment is to replace all the `struct comedi_async *` parameters with `struct comedi_subdevice *` parameters in the comedi driver API. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 3 ++- drivers/staging/comedi/comedidev.h | 2 +- drivers/staging/comedi/drivers/amplc_pci230.c | 4 ++-- drivers/staging/comedi/drivers/ni_mio_common.c | 4 ++-- drivers/staging/comedi/drivers/usbdux.c | 2 +- drivers/staging/comedi/drivers/usbduxsigma.c | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index f127bf9bd421..acb042c3e034 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -431,8 +431,9 @@ int comedi_buf_put(struct comedi_subdevice *s, unsigned short x) } EXPORT_SYMBOL_GPL(comedi_buf_put); -int comedi_buf_get(struct comedi_async *async, unsigned short *x) +int comedi_buf_get(struct comedi_subdevice *s, unsigned short *x) { + struct comedi_async *async = s->async; unsigned int n = comedi_buf_read_n_available(async); if (n < sizeof(short)) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index a874c1c43a32..d19a20ca91b7 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -344,7 +344,7 @@ unsigned int comedi_buf_read_alloc(struct comedi_async *, unsigned int); unsigned int comedi_buf_read_free(struct comedi_async *, unsigned int); int comedi_buf_put(struct comedi_subdevice *s, unsigned short x); -int comedi_buf_get(struct comedi_async *, unsigned short *); +int comedi_buf_get(struct comedi_subdevice *s, unsigned short *x); void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset, const void *source, unsigned int num_bytes); diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 9541e240925e..d0740d603ae7 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -1164,7 +1164,7 @@ static void pci230_handle_ao_nofifo(struct comedi_device *dev, return; for (i = 0; i < cmd->chanlist_len; i++) { /* Read sample from Comedi's circular buffer. */ - ret = comedi_buf_get(s->async, &data); + ret = comedi_buf_get(s, &data); if (ret == 0) { s->async->events |= COMEDI_CB_OVERFLOW; pci230_ao_stop(dev, s); @@ -1250,7 +1250,7 @@ static int pci230_handle_ao_fifo(struct comedi_device *dev, for (i = 0; i < cmd->chanlist_len; i++) { unsigned short datum; - comedi_buf_get(async, &datum); + comedi_buf_get(s, &datum); pci230_ao_write_fifo(dev, datum, CR_CHAN(cmd->chanlist[i])); } diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 087b533625df..d4e99af6de71 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -1149,7 +1149,7 @@ static void ni_ao_fifo_load(struct comedi_device *dev, chan = async->cur_chan; for (i = 0; i < n; i++) { - err &= comedi_buf_get(async, &d); + err &= comedi_buf_get(s, &d); if (err == 0) break; @@ -1159,7 +1159,7 @@ static void ni_ao_fifo_load(struct comedi_device *dev, packed_data = d & 0xffff; /* 6711 only has 16 bit wide ao fifo */ if (board->reg_type != ni_reg_6711) { - err &= comedi_buf_get(async, &d); + err &= comedi_buf_get(s, &d); if (err == 0) break; chan++; diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 011fede33a00..143f63202621 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -484,7 +484,7 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb) unsigned int chan = devpriv->ao_chanlist[i]; unsigned short val; - ret = comedi_buf_get(s->async, &val); + ret = comedi_buf_get(s, &val); if (ret < 0) { dev_err(dev->class_dev, "buffer underflow\n"); s->async->events |= (COMEDI_CB_EOA | diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c index b57c974e5cb6..52b8b8fb9ee4 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -423,7 +423,7 @@ static void usbduxsigma_ao_urb_complete(struct urb *urb) unsigned int chan = devpriv->ao_chanlist[i]; unsigned short val; - ret = comedi_buf_get(s->async, &val); + ret = comedi_buf_get(s, &val); if (ret < 0) { dev_err(dev->class_dev, "buffer underflow\n"); s->async->events |= (COMEDI_CB_EOA | -- cgit v1.2.3 From 00603a9c321e186bba000e01042529bf5cfe68a3 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 6 May 2014 13:12:01 +0100 Subject: staging: comedi: pass subdevice to comedi_buf_memcpy_to() Change the parameters of `comedi_buf_memcpy_to()` to pass a pointer to the comedi subdevice instead of a pointer to the "async" structure belonging to the subdevice. The main aim at the moment is to replace all the `struct comedi_async *` parameters with `struct comedi_subdevice *` parameters in the comedi driver API. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 3 ++- drivers/staging/comedi/comedidev.h | 2 +- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c | 2 +- drivers/staging/comedi/drivers/comedi_fc.c | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index acb042c3e034..de850f3fd49d 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -445,9 +445,10 @@ int comedi_buf_get(struct comedi_subdevice *s, unsigned short *x) } EXPORT_SYMBOL_GPL(comedi_buf_get); -void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset, +void comedi_buf_memcpy_to(struct comedi_subdevice *s, unsigned int offset, const void *data, unsigned int num_bytes) { + struct comedi_async *async = s->async; unsigned int write_ptr = async->buf_write_ptr + offset; if (write_ptr >= async->prealloc_bufsz) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index d19a20ca91b7..221db717ebc4 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -346,7 +346,7 @@ unsigned int comedi_buf_read_free(struct comedi_async *, unsigned int); int comedi_buf_put(struct comedi_subdevice *s, unsigned short x); int comedi_buf_get(struct comedi_subdevice *s, unsigned short *x); -void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset, +void comedi_buf_memcpy_to(struct comedi_subdevice *s, unsigned int offset, const void *source, unsigned int num_bytes); void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset, void *destination, unsigned int num_bytes); diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c index 9b8851c7e072..51095bebc087 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c @@ -2712,7 +2712,7 @@ static int i_APCI3200_InterruptHandleEos(struct comedi_device *dev) s->async->events |= COMEDI_CB_ERROR; } /* Write all 7 scan values in the comedi buffer */ - comedi_buf_memcpy_to(s->async, 0, + comedi_buf_memcpy_to(s, 0, (unsigned int *) s_BoardInfos[dev->minor]. ui_ScanValueArray, (7 + 12) * sizeof(unsigned int)); diff --git a/drivers/staging/comedi/drivers/comedi_fc.c b/drivers/staging/comedi/drivers/comedi_fc.c index 9d9b1469e89a..81749a778de0 100644 --- a/drivers/staging/comedi/drivers/comedi_fc.c +++ b/drivers/staging/comedi/drivers/comedi_fc.c @@ -74,7 +74,7 @@ unsigned int cfc_write_array_to_buffer(struct comedi_subdevice *s, return 0; } - comedi_buf_memcpy_to(async, 0, data, num_bytes); + comedi_buf_memcpy_to(s, 0, data, num_bytes); comedi_buf_write_free(async, num_bytes); cfc_inc_scan_progress(s, num_bytes); async->events |= COMEDI_CB_BLOCK; -- cgit v1.2.3 From 2fadffc0bb2e0b33ebee72be172073f84624bc3d Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 6 May 2014 13:12:02 +0100 Subject: staging: comedi: pass subdevice to comedi_buf_memcpy_from() Change the parameters of `comedi_buf_memcpy_from()` to pass a pointer to the comedi subdevice instead of a pointer to the "async" structure belonging to the subdevice. The main aim at the moment is to replace all the `struct comedi_async *` parameters with `struct comedi_subdevice *` parameters in the comedi driver API. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 3 ++- drivers/staging/comedi/comedidev.h | 2 +- drivers/staging/comedi/drivers/comedi_fc.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index de850f3fd49d..199ebb48974c 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -472,10 +472,11 @@ void comedi_buf_memcpy_to(struct comedi_subdevice *s, unsigned int offset, } EXPORT_SYMBOL_GPL(comedi_buf_memcpy_to); -void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset, +void comedi_buf_memcpy_from(struct comedi_subdevice *s, unsigned int offset, void *dest, unsigned int nbytes) { void *src; + struct comedi_async *async = s->async; unsigned int read_ptr = async->buf_read_ptr + offset; if (read_ptr >= async->prealloc_bufsz) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index 221db717ebc4..0a68006e2c21 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -348,7 +348,7 @@ int comedi_buf_get(struct comedi_subdevice *s, unsigned short *x); void comedi_buf_memcpy_to(struct comedi_subdevice *s, unsigned int offset, const void *source, unsigned int num_bytes); -void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset, +void comedi_buf_memcpy_from(struct comedi_subdevice *s, unsigned int offset, void *destination, unsigned int num_bytes); /* drivers.c - general comedi driver functions */ diff --git a/drivers/staging/comedi/drivers/comedi_fc.c b/drivers/staging/comedi/drivers/comedi_fc.c index 81749a778de0..5eff9d1cd072 100644 --- a/drivers/staging/comedi/drivers/comedi_fc.c +++ b/drivers/staging/comedi/drivers/comedi_fc.c @@ -92,7 +92,7 @@ unsigned int cfc_read_array_from_buffer(struct comedi_subdevice *s, return 0; num_bytes = comedi_buf_read_alloc(async, num_bytes); - comedi_buf_memcpy_from(async, 0, data, num_bytes); + comedi_buf_memcpy_from(s, 0, data, num_bytes); comedi_buf_read_free(async, num_bytes); cfc_inc_scan_progress(s, num_bytes); async->events |= COMEDI_CB_BLOCK; -- cgit v1.2.3 From 67ab76f0ce3b65f5b38501143e07a0b98ff93434 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 6 May 2014 13:12:03 +0100 Subject: staging: comedi: ni_tiocmd: pass subdevice to command setup functions The `ni_tio_input_cmd()`, `ni_tio_output_cmd()` and `ni_tio_cmd_setup()` functions are called from `ni_tio_cmd()` to set up a comedi command. They currently get passed two parameters, a pointer to a `struct ni_gpct` and a pointer to a `struct comedi_async`, but both of those come from members of a `struct comedi_subdevice` (the former from the `private` member). Replace the parameters with a pointer to the `struct comedi_subdevice`. The main motive is to make the comedi subdevice more easily available to the functions for the use of subsequent patches to remove the `struct comedi_async *` parameters from the comedi buffer handling functions. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tiocmd.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tiocmd.c b/drivers/staging/comedi/drivers/ni_tiocmd.c index b9d23db4004b..7a163fc31f5d 100644 --- a/drivers/staging/comedi/drivers/ni_tiocmd.c +++ b/drivers/staging/comedi/drivers/ni_tiocmd.c @@ -115,10 +115,12 @@ static int ni_tio_input_inttrig(struct comedi_device *dev, return retval; } -static int ni_tio_input_cmd(struct ni_gpct *counter, struct comedi_async *async) +static int ni_tio_input_cmd(struct comedi_subdevice *s) { + struct ni_gpct *counter = s->private; struct ni_gpct_device *counter_dev = counter->counter_dev; unsigned cidx = counter->counter_index; + struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; int retval = 0; @@ -164,9 +166,10 @@ static int ni_tio_input_cmd(struct ni_gpct *counter, struct comedi_async *async) return retval; } -static int ni_tio_output_cmd(struct ni_gpct *counter, - struct comedi_async *async) +static int ni_tio_output_cmd(struct comedi_subdevice *s) { + struct ni_gpct *counter = s->private; + dev_err(counter->counter_dev->dev->class_dev, "output commands not yet implemented.\n"); return -ENOTSUPP; @@ -178,9 +181,10 @@ static int ni_tio_output_cmd(struct ni_gpct *counter, return ni_tio_arm(counter, 1, NI_GPCT_ARM_IMMEDIATE); } -static int ni_tio_cmd_setup(struct ni_gpct *counter, struct comedi_async *async) +static int ni_tio_cmd_setup(struct comedi_subdevice *s) { - struct comedi_cmd *cmd = &async->cmd; + struct comedi_cmd *cmd = &s->async->cmd; + struct ni_gpct *counter = s->private; unsigned cidx = counter->counter_index; int set_gate_source = 0; unsigned gate_source; @@ -219,12 +223,12 @@ int ni_tio_cmd(struct comedi_device *dev, struct comedi_subdevice *s) "Interrupt-driven commands not yet implemented.\n"); retval = -EIO; } else { - retval = ni_tio_cmd_setup(counter, async); + retval = ni_tio_cmd_setup(s); if (retval == 0) { if (cmd->flags & CMDF_WRITE) - retval = ni_tio_output_cmd(counter, async); + retval = ni_tio_output_cmd(s); else - retval = ni_tio_input_cmd(counter, async); + retval = ni_tio_input_cmd(s); } } spin_unlock_irqrestore(&counter->lock, flags); -- cgit v1.2.3 From 24e894bbf247ecdeed3ed2f77f658da756760f60 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 6 May 2014 13:12:04 +0100 Subject: staging: comedi: pass subdevice to comedi_buf_write_alloc() Change the parameters of `comedi_buf_write_alloc()` to pass a pointer to the comedi subdevice instead of a pointer to the "async" structure belonging to the subdevice. The main aim at the moment is to replace all the `struct comedi_async *` parameters with `struct comedi_subdevice *` parameters in the comedi driver API. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 4 ++-- drivers/staging/comedi/comedi_fops.c | 6 +++--- drivers/staging/comedi/comedidev.h | 2 +- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c | 3 +-- drivers/staging/comedi/drivers/comedi_fc.c | 2 +- drivers/staging/comedi/drivers/mite.c | 2 +- drivers/staging/comedi/drivers/ni_mio_common.c | 2 +- drivers/staging/comedi/drivers/ni_pcidio.c | 2 +- drivers/staging/comedi/drivers/ni_tiocmd.c | 2 +- 9 files changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index 199ebb48974c..6a655008655f 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -269,10 +269,10 @@ static unsigned int __comedi_buf_write_alloc(struct comedi_async *async, } /* allocates chunk for the writer from free buffer space */ -unsigned int comedi_buf_write_alloc(struct comedi_async *async, +unsigned int comedi_buf_write_alloc(struct comedi_subdevice *s, unsigned int nbytes) { - return __comedi_buf_write_alloc(async, nbytes, 0); + return __comedi_buf_write_alloc(s->async, nbytes, 0); } EXPORT_SYMBOL_GPL(comedi_buf_write_alloc); diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 0affd1f96660..58c1f6e18d27 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -1004,7 +1004,7 @@ static int do_bufinfo_ioctl(struct comedi_device *dev, if (bi.bytes_written && (s->subdev_flags & SDF_CMD_WRITE)) { bi.bytes_written = - comedi_buf_write_alloc(async, bi.bytes_written); + comedi_buf_write_alloc(s, bi.bytes_written); comedi_buf_write_free(async, bi.bytes_written); } @@ -2038,7 +2038,7 @@ static unsigned int comedi_poll(struct file *file, poll_table *wait) unsigned int bps = bytes_per_sample(s); poll_wait(file, &s->async->wait_head, wait); - comedi_buf_write_alloc(s->async, s->async->prealloc_bufsz); + comedi_buf_write_alloc(s, s->async->prealloc_bufsz); if (!s->busy || !comedi_is_subdevice_running(s) || comedi_buf_write_n_allocated(s->async) >= bps) mask |= POLLOUT | POLLWRNORM; @@ -2136,7 +2136,7 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, m = n; if (async->buf_write_ptr + m > async->prealloc_bufsz) m = async->prealloc_bufsz - async->buf_write_ptr; - comedi_buf_write_alloc(async, async->prealloc_bufsz); + comedi_buf_write_alloc(s, async->prealloc_bufsz); if (m > comedi_buf_write_n_allocated(async)) m = comedi_buf_write_n_allocated(async); if (m < n) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index 0a68006e2c21..b47cc969d5ad 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -336,7 +336,7 @@ static inline unsigned int bytes_per_sample(const struct comedi_subdevice *subd) */ int comedi_set_hw_dev(struct comedi_device *dev, struct device *hw_dev); -unsigned int comedi_buf_write_alloc(struct comedi_async *, unsigned int); +unsigned int comedi_buf_write_alloc(struct comedi_subdevice *s, unsigned int n); unsigned int comedi_buf_write_free(struct comedi_async *, unsigned int); unsigned int comedi_buf_read_n_available(struct comedi_async *); diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c index 51095bebc087..246220abf9a9 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c @@ -2702,8 +2702,7 @@ static int i_APCI3200_InterruptHandleEos(struct comedi_device *dev) s->async->events |= COMEDI_CB_EOS; /* Test if enougth memory is available and allocate it for 7 values */ - /* n = comedi_buf_write_alloc(s->async, 7*sizeof(unsigned int)); */ - n = comedi_buf_write_alloc(s->async, + n = comedi_buf_write_alloc(s, (7 + 12) * sizeof(unsigned int)); /* If not enough memory available, event is set to Comedi Buffer Error */ diff --git a/drivers/staging/comedi/drivers/comedi_fc.c b/drivers/staging/comedi/drivers/comedi_fc.c index 5eff9d1cd072..21cf34e7dc78 100644 --- a/drivers/staging/comedi/drivers/comedi_fc.c +++ b/drivers/staging/comedi/drivers/comedi_fc.c @@ -67,7 +67,7 @@ unsigned int cfc_write_array_to_buffer(struct comedi_subdevice *s, if (num_bytes == 0) return 0; - retval = comedi_buf_write_alloc(async, num_bytes); + retval = comedi_buf_write_alloc(s, num_bytes); if (retval != num_bytes) { dev_warn(s->device->class_dev, "buffer overrun\n"); async->events |= COMEDI_CB_OVERFLOW; diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 1a572c83f996..a5999f52ae20 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -533,7 +533,7 @@ int mite_sync_input_dma(struct mite_channel *mite_chan, old_alloc_count = async->buf_write_alloc_count; /* write alloc as much as we can */ - comedi_buf_write_alloc(async, async->prealloc_bufsz); + comedi_buf_write_alloc(s, async->prealloc_bufsz); nbytes = mite_bytes_written_to_memory_lb(mite_chan); if ((int)(mite_bytes_written_to_memory_ub(mite_chan) - diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index d4e99af6de71..d8415fe2188b 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -1505,7 +1505,7 @@ static int ni_ai_setup_MITE_dma(struct comedi_device *dev) /* printk("comedi_debug: using mite channel %i for ai.\n", devpriv->ai_mite_chan->channel); */ /* write alloc the entire buffer */ - comedi_buf_write_alloc(s->async, s->async->prealloc_bufsz); + comedi_buf_write_alloc(s, s->async->prealloc_bufsz); spin_lock_irqsave(&devpriv->mite_channel_lock, flags); if (devpriv->ai_mite_chan == NULL) { diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c index 6dd10044a023..d0ad82a3b4b9 100644 --- a/drivers/staging/comedi/drivers/ni_pcidio.c +++ b/drivers/staging/comedi/drivers/ni_pcidio.c @@ -759,7 +759,7 @@ static int setup_mite_dma(struct comedi_device *dev, struct comedi_subdevice *s) return retval; /* write alloc the entire buffer */ - comedi_buf_write_alloc(s->async, s->async->prealloc_bufsz); + comedi_buf_write_alloc(s, s->async->prealloc_bufsz); spin_lock_irqsave(&devpriv->mite_channel_lock, flags); if (devpriv->di_mite_chan) { diff --git a/drivers/staging/comedi/drivers/ni_tiocmd.c b/drivers/staging/comedi/drivers/ni_tiocmd.c index 7a163fc31f5d..9cc77c0b2f0f 100644 --- a/drivers/staging/comedi/drivers/ni_tiocmd.c +++ b/drivers/staging/comedi/drivers/ni_tiocmd.c @@ -125,7 +125,7 @@ static int ni_tio_input_cmd(struct comedi_subdevice *s) int retval = 0; /* write alloc the entire buffer */ - comedi_buf_write_alloc(async, async->prealloc_bufsz); + comedi_buf_write_alloc(s, async->prealloc_bufsz); counter->mite_chan->dir = COMEDI_INPUT; switch (counter_dev->variant) { case ni_gpct_variant_m_series: -- cgit v1.2.3 From 940dd35d5812ead0b93f3f2a1f44732ac069000b Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 6 May 2014 13:12:05 +0100 Subject: staging: comedi: pass subdevice to comedi_buf_write_free() Change the parameters of `comedi_buf_write_free()` to pass a pointer to the comedi subdevice instead of a pointer to the "async" structure belonging to the subdevice. The main aim at the moment is to replace all the `struct comedi_async *` parameters with `struct comedi_subdevice *` parameters in the comedi driver API. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 5 +++-- drivers/staging/comedi/comedi_fops.c | 4 ++-- drivers/staging/comedi/comedidev.h | 2 +- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c | 2 +- drivers/staging/comedi/drivers/comedi_fc.c | 2 +- drivers/staging/comedi/drivers/mite.c | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index 6a655008655f..220816857128 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -329,9 +329,10 @@ unsigned int comedi_buf_write_n_allocated(struct comedi_async *async) } /* transfers a chunk from writer to filled buffer space */ -unsigned int comedi_buf_write_free(struct comedi_async *async, +unsigned int comedi_buf_write_free(struct comedi_subdevice *s, unsigned int nbytes) { + struct comedi_async *async = s->async; unsigned int allocated = comedi_buf_write_n_allocated(async); if (nbytes > allocated) @@ -426,7 +427,7 @@ int comedi_buf_put(struct comedi_subdevice *s, unsigned short x) return 0; } *(unsigned short *)(async->prealloc_buf + async->buf_write_ptr) = x; - comedi_buf_write_free(async, sizeof(short)); + comedi_buf_write_free(s, sizeof(short)); return 1; } EXPORT_SYMBOL_GPL(comedi_buf_put); diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 58c1f6e18d27..c7010b315701 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -1005,7 +1005,7 @@ static int do_bufinfo_ioctl(struct comedi_device *dev, if (bi.bytes_written && (s->subdev_flags & SDF_CMD_WRITE)) { bi.bytes_written = comedi_buf_write_alloc(s, bi.bytes_written); - comedi_buf_write_free(async, bi.bytes_written); + comedi_buf_write_free(s, bi.bytes_written); } copyback_position: @@ -2167,7 +2167,7 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, n -= m; retval = -EFAULT; } - comedi_buf_write_free(async, n); + comedi_buf_write_free(s, n); count += n; nbytes -= n; diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index b47cc969d5ad..4a795e06d999 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -337,7 +337,7 @@ static inline unsigned int bytes_per_sample(const struct comedi_subdevice *subd) int comedi_set_hw_dev(struct comedi_device *dev, struct device *hw_dev); unsigned int comedi_buf_write_alloc(struct comedi_subdevice *s, unsigned int n); -unsigned int comedi_buf_write_free(struct comedi_async *, unsigned int); +unsigned int comedi_buf_write_free(struct comedi_subdevice *s, unsigned int n); unsigned int comedi_buf_read_n_available(struct comedi_async *); unsigned int comedi_buf_read_alloc(struct comedi_async *, unsigned int); diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c index 246220abf9a9..f540394d17b0 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c @@ -2716,7 +2716,7 @@ static int i_APCI3200_InterruptHandleEos(struct comedi_device *dev) ui_ScanValueArray, (7 + 12) * sizeof(unsigned int)); /* Update comedi buffer pinters indexes */ - comedi_buf_write_free(s->async, + comedi_buf_write_free(s, (7 + 12) * sizeof(unsigned int)); /* Send events */ diff --git a/drivers/staging/comedi/drivers/comedi_fc.c b/drivers/staging/comedi/drivers/comedi_fc.c index 21cf34e7dc78..a7860a41fe32 100644 --- a/drivers/staging/comedi/drivers/comedi_fc.c +++ b/drivers/staging/comedi/drivers/comedi_fc.c @@ -75,7 +75,7 @@ unsigned int cfc_write_array_to_buffer(struct comedi_subdevice *s, } comedi_buf_memcpy_to(s, 0, data, num_bytes); - comedi_buf_write_free(async, num_bytes); + comedi_buf_write_free(s, num_bytes); cfc_inc_scan_progress(s, num_bytes); async->events |= COMEDI_CB_BLOCK; diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index a5999f52ae20..e33c03dc556b 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -550,7 +550,7 @@ int mite_sync_input_dma(struct mite_channel *mite_chan, if (count <= 0) return 0; - comedi_buf_write_free(async, count); + comedi_buf_write_free(s, count); cfc_inc_scan_progress(s, count); async->events |= COMEDI_CB_BLOCK; return 0; -- cgit v1.2.3 From 0f1f34e844a24187270315ffb539d4bd1900c333 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 6 May 2014 13:12:06 +0100 Subject: staging: comedi: pass subdevice to comedi_buf_write_n_allocated() Change the parameters of `comedi_buf_write_n_allocated()` to pass a pointer to the comedi subdevice instead of a pointer to the "async" structure belonging to the subdevice. The main aim at the moment is to replace all the `struct comedi_async *` parameters with `struct comedi_subdevice *` parameters in the comedi driver API. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 6 ++++-- drivers/staging/comedi/comedi_fops.c | 6 +++--- drivers/staging/comedi/comedi_internal.h | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index 220816857128..ac498e0b4865 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -323,8 +323,10 @@ static unsigned int comedi_buf_munge(struct comedi_async *async, return count; } -unsigned int comedi_buf_write_n_allocated(struct comedi_async *async) +unsigned int comedi_buf_write_n_allocated(struct comedi_subdevice *s) { + struct comedi_async *async = s->async; + return async->buf_write_alloc_count - async->buf_write_count; } @@ -333,7 +335,7 @@ unsigned int comedi_buf_write_free(struct comedi_subdevice *s, unsigned int nbytes) { struct comedi_async *async = s->async; - unsigned int allocated = comedi_buf_write_n_allocated(async); + unsigned int allocated = comedi_buf_write_n_allocated(s); if (nbytes > allocated) nbytes = allocated; diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index c7010b315701..bc9386350b76 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -2040,7 +2040,7 @@ static unsigned int comedi_poll(struct file *file, poll_table *wait) poll_wait(file, &s->async->wait_head, wait); comedi_buf_write_alloc(s, s->async->prealloc_bufsz); if (!s->busy || !comedi_is_subdevice_running(s) || - comedi_buf_write_n_allocated(s->async) >= bps) + comedi_buf_write_n_allocated(s) >= bps) mask |= POLLOUT | POLLWRNORM; } @@ -2137,8 +2137,8 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, if (async->buf_write_ptr + m > async->prealloc_bufsz) m = async->prealloc_bufsz - async->buf_write_ptr; comedi_buf_write_alloc(s, async->prealloc_bufsz); - if (m > comedi_buf_write_n_allocated(async)) - m = comedi_buf_write_n_allocated(async); + if (m > comedi_buf_write_n_allocated(s)) + m = comedi_buf_write_n_allocated(s); if (m < n) n = m; diff --git a/drivers/staging/comedi/comedi_internal.h b/drivers/staging/comedi/comedi_internal.h index a492f2d2436e..36e7a99b5079 100644 --- a/drivers/staging/comedi/comedi_internal.h +++ b/drivers/staging/comedi/comedi_internal.h @@ -21,7 +21,7 @@ void comedi_buf_map_get(struct comedi_buf_map *bm); int comedi_buf_map_put(struct comedi_buf_map *bm); struct comedi_buf_map *comedi_buf_map_from_subdev_get( struct comedi_subdevice *s); -unsigned int comedi_buf_write_n_allocated(struct comedi_async *async); +unsigned int comedi_buf_write_n_allocated(struct comedi_subdevice *s); void comedi_device_cancel_all(struct comedi_device *dev); extern unsigned int comedi_default_buf_size_kb; -- cgit v1.2.3 From d13be55a37a136ee4274680308b7d0d7e3818bf3 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 6 May 2014 13:12:07 +0100 Subject: staging: comedi: pass subdevice to comedi_buf_read_alloc() Change the parameters of `comedi_buf_read_alloc()` to pass a pointer to the comedi subdevice instead of a pointer to the "async" structure belonging to the subdevice. The main aim at the moment is to replace all the `struct comedi_async *` parameters with `struct comedi_subdevice *` parameters in the comedi driver API. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 5 +++-- drivers/staging/comedi/comedi_fops.c | 4 ++-- drivers/staging/comedi/comedidev.h | 2 +- drivers/staging/comedi/drivers/comedi_fc.c | 2 +- drivers/staging/comedi/drivers/mite.c | 6 +++--- drivers/staging/comedi/drivers/ni_mio_common.c | 4 ++-- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index ac498e0b4865..07e0b3a51828 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -370,9 +370,10 @@ unsigned int comedi_buf_read_n_available(struct comedi_async *async) EXPORT_SYMBOL_GPL(comedi_buf_read_n_available); /* allocates a chunk for the reader from filled (and munged) buffer space */ -unsigned int comedi_buf_read_alloc(struct comedi_async *async, +unsigned int comedi_buf_read_alloc(struct comedi_subdevice *s, unsigned int nbytes) { + struct comedi_async *async = s->async; unsigned int available; available = async->munge_count - async->buf_read_alloc_count; @@ -441,7 +442,7 @@ int comedi_buf_get(struct comedi_subdevice *s, unsigned short *x) if (n < sizeof(short)) return 0; - comedi_buf_read_alloc(async, sizeof(short)); + comedi_buf_read_alloc(s, sizeof(short)); *x = *(unsigned short *)(async->prealloc_buf + async->buf_read_ptr); comedi_buf_read_free(async, sizeof(short)); return 1; diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index bc9386350b76..5164374f5ab2 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -993,7 +993,7 @@ static int do_bufinfo_ioctl(struct comedi_device *dev, return -EACCES; if (bi.bytes_read && (s->subdev_flags & SDF_CMD_READ)) { - bi.bytes_read = comedi_buf_read_alloc(async, bi.bytes_read); + bi.bytes_read = comedi_buf_read_alloc(s, bi.bytes_read); comedi_buf_read_free(async, bi.bytes_read); if (comedi_is_subdevice_idle(s) && @@ -2272,7 +2272,7 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes, retval = -EFAULT; } - comedi_buf_read_alloc(async, n); + comedi_buf_read_alloc(s, n); comedi_buf_read_free(async, n); count += n; diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index 4a795e06d999..d2131f26de53 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -340,7 +340,7 @@ unsigned int comedi_buf_write_alloc(struct comedi_subdevice *s, unsigned int n); unsigned int comedi_buf_write_free(struct comedi_subdevice *s, unsigned int n); unsigned int comedi_buf_read_n_available(struct comedi_async *); -unsigned int comedi_buf_read_alloc(struct comedi_async *, unsigned int); +unsigned int comedi_buf_read_alloc(struct comedi_subdevice *s, unsigned int n); unsigned int comedi_buf_read_free(struct comedi_async *, unsigned int); int comedi_buf_put(struct comedi_subdevice *s, unsigned short x); diff --git a/drivers/staging/comedi/drivers/comedi_fc.c b/drivers/staging/comedi/drivers/comedi_fc.c index a7860a41fe32..836eb1a37380 100644 --- a/drivers/staging/comedi/drivers/comedi_fc.c +++ b/drivers/staging/comedi/drivers/comedi_fc.c @@ -91,7 +91,7 @@ unsigned int cfc_read_array_from_buffer(struct comedi_subdevice *s, if (num_bytes == 0) return 0; - num_bytes = comedi_buf_read_alloc(async, num_bytes); + num_bytes = comedi_buf_read_alloc(s, num_bytes); comedi_buf_memcpy_from(s, 0, data, num_bytes); comedi_buf_read_free(async, num_bytes); cfc_inc_scan_progress(s, num_bytes); diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index e33c03dc556b..d1423caecf7a 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -560,15 +560,15 @@ EXPORT_SYMBOL_GPL(mite_sync_input_dma); int mite_sync_output_dma(struct mite_channel *mite_chan, struct comedi_async *async) { + struct comedi_subdevice *s = async->subdevice; int count; u32 nbytes_ub, nbytes_lb; unsigned int old_alloc_count; - u32 stop_count = - async->cmd.stop_arg * cfc_bytes_per_scan(async->subdevice); + u32 stop_count = async->cmd.stop_arg * cfc_bytes_per_scan(s); old_alloc_count = async->buf_read_alloc_count; /* read alloc as much as we can */ - comedi_buf_read_alloc(async, async->prealloc_bufsz); + comedi_buf_read_alloc(s, async->prealloc_bufsz); nbytes_lb = mite_bytes_read_from_memory_lb(mite_chan); if (async->cmd.stop_src == TRIG_COUNT && (int)(nbytes_lb - stop_count) > 0) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index d8415fe2188b..950b223440d4 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -1545,7 +1545,7 @@ static int ni_ao_setup_MITE_dma(struct comedi_device *dev) return retval; /* read alloc the entire buffer */ - comedi_buf_read_alloc(s->async, s->async->prealloc_bufsz); + comedi_buf_read_alloc(s, s->async->prealloc_bufsz); spin_lock_irqsave(&devpriv->mite_channel_lock, flags); if (devpriv->ao_mite_chan) { @@ -3565,7 +3565,7 @@ static int ni_cdo_inttrig(struct comedi_device *dev, s->async->inttrig = NULL; /* read alloc the entire buffer */ - comedi_buf_read_alloc(s->async, s->async->prealloc_bufsz); + comedi_buf_read_alloc(s, s->async->prealloc_bufsz); #ifdef PCIDMA spin_lock_irqsave(&devpriv->mite_channel_lock, flags); -- cgit v1.2.3 From f1df8662859e7edee134d3d77f241a32c9cfb8ef Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 6 May 2014 13:12:08 +0100 Subject: staging: comedi: pass subdevice to comedi_buf_read_free() Change the parameters of `comedi_buf_read_free()` to pass a pointer to the comedi subdevice instead of a pointer to the "async" structure belonging to the subdevice. The main aim at the moment is to replace all the `struct comedi_async *` parameters with `struct comedi_subdevice *` parameters in the comedi driver API. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 5 +++-- drivers/staging/comedi/comedi_fops.c | 4 ++-- drivers/staging/comedi/comedidev.h | 2 +- drivers/staging/comedi/drivers/comedi_fc.c | 6 ++---- drivers/staging/comedi/drivers/mite.c | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index 07e0b3a51828..a3c3f21e77f9 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -398,9 +398,10 @@ static unsigned int comedi_buf_read_n_allocated(struct comedi_async *async) } /* transfers control of a chunk from reader to free buffer space */ -unsigned int comedi_buf_read_free(struct comedi_async *async, +unsigned int comedi_buf_read_free(struct comedi_subdevice *s, unsigned int nbytes) { + struct comedi_async *async = s->async; unsigned int allocated; /* @@ -444,7 +445,7 @@ int comedi_buf_get(struct comedi_subdevice *s, unsigned short *x) return 0; comedi_buf_read_alloc(s, sizeof(short)); *x = *(unsigned short *)(async->prealloc_buf + async->buf_read_ptr); - comedi_buf_read_free(async, sizeof(short)); + comedi_buf_read_free(s, sizeof(short)); return 1; } EXPORT_SYMBOL_GPL(comedi_buf_get); diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 5164374f5ab2..365e191228be 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -994,7 +994,7 @@ static int do_bufinfo_ioctl(struct comedi_device *dev, if (bi.bytes_read && (s->subdev_flags & SDF_CMD_READ)) { bi.bytes_read = comedi_buf_read_alloc(s, bi.bytes_read); - comedi_buf_read_free(async, bi.bytes_read); + comedi_buf_read_free(s, bi.bytes_read); if (comedi_is_subdevice_idle(s) && async->buf_write_count == async->buf_read_count) { @@ -2273,7 +2273,7 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes, } comedi_buf_read_alloc(s, n); - comedi_buf_read_free(async, n); + comedi_buf_read_free(s, n); count += n; nbytes -= n; diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index d2131f26de53..c481620042ba 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -341,7 +341,7 @@ unsigned int comedi_buf_write_free(struct comedi_subdevice *s, unsigned int n); unsigned int comedi_buf_read_n_available(struct comedi_async *); unsigned int comedi_buf_read_alloc(struct comedi_subdevice *s, unsigned int n); -unsigned int comedi_buf_read_free(struct comedi_async *, unsigned int); +unsigned int comedi_buf_read_free(struct comedi_subdevice *s, unsigned int n); int comedi_buf_put(struct comedi_subdevice *s, unsigned short x); int comedi_buf_get(struct comedi_subdevice *s, unsigned short *x); diff --git a/drivers/staging/comedi/drivers/comedi_fc.c b/drivers/staging/comedi/drivers/comedi_fc.c index 836eb1a37380..cf3da2cb0cc1 100644 --- a/drivers/staging/comedi/drivers/comedi_fc.c +++ b/drivers/staging/comedi/drivers/comedi_fc.c @@ -86,16 +86,14 @@ EXPORT_SYMBOL_GPL(cfc_write_array_to_buffer); unsigned int cfc_read_array_from_buffer(struct comedi_subdevice *s, void *data, unsigned int num_bytes) { - struct comedi_async *async = s->async; - if (num_bytes == 0) return 0; num_bytes = comedi_buf_read_alloc(s, num_bytes); comedi_buf_memcpy_from(s, 0, data, num_bytes); - comedi_buf_read_free(async, num_bytes); + comedi_buf_read_free(s, num_bytes); cfc_inc_scan_progress(s, num_bytes); - async->events |= COMEDI_CB_BLOCK; + s->async->events |= COMEDI_CB_BLOCK; return num_bytes; } diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index d1423caecf7a..6c8bd7c33082 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -588,7 +588,7 @@ int mite_sync_output_dma(struct mite_channel *mite_chan, return 0; if (count) { - comedi_buf_read_free(async, count); + comedi_buf_read_free(s, count); async->events |= COMEDI_CB_BLOCK; } return 0; -- cgit v1.2.3 From e9edef3a5454a19fd0d0c342cc88b6310b871a48 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 6 May 2014 13:12:09 +0100 Subject: staging: comedi: pass subdevice to comedi_buf_read_n_available() Change the parameters of `comedi_buf_read_n_available()` to pass a pointer to the comedi subdevice instead of a pointer to the "async" structure belonging to the subdevice. The main aim at the moment is to replace all the `struct comedi_async *` parameters with `struct comedi_subdevice *` parameters in the comedi driver API. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 5 +++-- drivers/staging/comedi/comedi_fops.c | 4 ++-- drivers/staging/comedi/comedidev.h | 2 +- drivers/staging/comedi/drivers/amplc_pci224.c | 2 +- drivers/staging/comedi/drivers/amplc_pci230.c | 2 +- drivers/staging/comedi/drivers/cb_pcidas64.c | 2 +- drivers/staging/comedi/drivers/ni_660x.c | 2 +- drivers/staging/comedi/drivers/ni_mio_common.c | 4 ++-- 8 files changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index a3c3f21e77f9..f295285d2aa6 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -350,8 +350,9 @@ unsigned int comedi_buf_write_free(struct comedi_subdevice *s, } EXPORT_SYMBOL_GPL(comedi_buf_write_free); -unsigned int comedi_buf_read_n_available(struct comedi_async *async) +unsigned int comedi_buf_read_n_available(struct comedi_subdevice *s) { + struct comedi_async *async = s->async; unsigned num_bytes; if (!async) @@ -439,7 +440,7 @@ EXPORT_SYMBOL_GPL(comedi_buf_put); int comedi_buf_get(struct comedi_subdevice *s, unsigned short *x) { struct comedi_async *async = s->async; - unsigned int n = comedi_buf_read_n_available(async); + unsigned int n = comedi_buf_read_n_available(s); if (n < sizeof(short)) return 0; diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 365e191228be..ada6024be6ee 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -2029,7 +2029,7 @@ static unsigned int comedi_poll(struct file *file, poll_table *wait) if (s && s->async) { poll_wait(file, &s->async->wait_head, wait); if (!s->busy || !comedi_is_subdevice_running(s) || - comedi_buf_read_n_available(s->async) > 0) + comedi_buf_read_n_available(s) > 0) mask |= POLLIN | POLLRDNORM; } @@ -2229,7 +2229,7 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes, n = nbytes; - m = comedi_buf_read_n_available(async); + m = comedi_buf_read_n_available(s); /* printk("%d available\n",m); */ if (async->buf_read_ptr + m > async->prealloc_bufsz) m = async->prealloc_bufsz - async->buf_read_ptr; diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index c481620042ba..a5d479c1266e 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -339,7 +339,7 @@ int comedi_set_hw_dev(struct comedi_device *dev, struct device *hw_dev); unsigned int comedi_buf_write_alloc(struct comedi_subdevice *s, unsigned int n); unsigned int comedi_buf_write_free(struct comedi_subdevice *s, unsigned int n); -unsigned int comedi_buf_read_n_available(struct comedi_async *); +unsigned int comedi_buf_read_n_available(struct comedi_subdevice *s); unsigned int comedi_buf_read_alloc(struct comedi_subdevice *s, unsigned int n); unsigned int comedi_buf_read_free(struct comedi_subdevice *s, unsigned int n); diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index da4634e8cfeb..e8beeab7a78b 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -558,7 +558,7 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, bytes_per_scan = sizeof(short); } /* Determine number of scans available in buffer. */ - num_scans = comedi_buf_read_n_available(s->async) / bytes_per_scan; + num_scans = comedi_buf_read_n_available(s) / bytes_per_scan; if (cmd->stop_src == TRIG_COUNT) { /* Fixed number of scans. */ if (num_scans > devpriv->ao_stop_count) diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index d0740d603ae7..d6f6a7a5bad1 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -1205,7 +1205,7 @@ static int pci230_handle_ao_fifo(struct comedi_device *dev, dacstat = inw(dev->iobase + PCI230_DACCON); /* Determine number of scans available in buffer. */ bytes_per_scan = cmd->chanlist_len * sizeof(short); - num_scans = comedi_buf_read_n_available(async) / bytes_per_scan; + num_scans = comedi_buf_read_n_available(s) / bytes_per_scan; if (cmd->stop_src == TRIG_COUNT) { /* Fixed number of scans. */ if (num_scans > devpriv->ao_scan_count) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 0e13ac9f3473..aca1e69009a8 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -2893,7 +2893,7 @@ static unsigned int load_ao_dma_buffer(struct comedi_device *dev, buffer_index = devpriv->ao_dma_index; prev_buffer_index = prev_ao_dma_index(dev); - num_bytes = comedi_buf_read_n_available(dev->write_subdev->async); + num_bytes = comedi_buf_read_n_available(dev->write_subdev); if (num_bytes > DMA_BUFFER_SIZE) num_bytes = DMA_BUFFER_SIZE; if (cmd->stop_src == TRIG_COUNT && num_bytes > devpriv->ao_count) diff --git a/drivers/staging/comedi/drivers/ni_660x.c b/drivers/staging/comedi/drivers/ni_660x.c index 0d4b9019f76a..2858b3d559c1 100644 --- a/drivers/staging/comedi/drivers/ni_660x.c +++ b/drivers/staging/comedi/drivers/ni_660x.c @@ -825,7 +825,7 @@ static int ni_660x_input_poll(struct comedi_device *dev, spin_lock_irqsave(&devpriv->interrupt_lock, flags); mite_sync_input_dma(counter->mite_chan, s->async); spin_unlock_irqrestore(&devpriv->interrupt_lock, flags); - return comedi_buf_read_n_available(s->async); + return comedi_buf_read_n_available(s); } static int ni_660x_buf_change(struct comedi_device *dev, diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 950b223440d4..e54488c2eb5a 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -1200,7 +1200,7 @@ static int ni_ao_fifo_half_empty(struct comedi_device *dev, const struct ni_board_struct *board = comedi_board(dev); int n; - n = comedi_buf_read_n_available(s->async); + n = comedi_buf_read_n_available(s); if (n == 0) { s->async->events |= COMEDI_CB_OVERFLOW; return 0; @@ -1230,7 +1230,7 @@ static int ni_ao_prep_fifo(struct comedi_device *dev, ni_ao_win_outl(dev, 0x6, AO_FIFO_Offset_Load_611x); /* load some data */ - n = comedi_buf_read_n_available(s->async); + n = comedi_buf_read_n_available(s); if (n == 0) return 0; -- cgit v1.2.3 From fcc18a9aa2c43765ba37012879936fbf142ba91c Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 6 May 2014 13:12:10 +0100 Subject: staging: comedi: pass subdevice to comedi_buf_reset() Change the parameters of `comedi_buf_reset()` to pass a pointer to the comedi subdevice instead of a pointer to the "async" structure belonging to the subdevice. The main aim at the moment is to replace all the `struct comedi_async *` parameters with `struct comedi_subdevice *` parameters in the comedi driver API. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 4 +++- drivers/staging/comedi/comedi_fops.c | 4 ++-- drivers/staging/comedi/comedi_internal.h | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index f295285d2aa6..fa5d6d4d0351 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -222,8 +222,10 @@ int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s, return 0; } -void comedi_buf_reset(struct comedi_async *async) +void comedi_buf_reset(struct comedi_subdevice *s) { + struct comedi_async *async = s->async; + async->buf_write_alloc_count = 0; async->buf_write_count = 0; async->buf_read_alloc_count = 0; diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index ada6024be6ee..98229bd6cfb2 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -583,7 +583,7 @@ static void do_become_nonbusy(struct comedi_device *dev, comedi_set_subdevice_runflags(s, SRF_RUNNING, 0); if (async) { - comedi_buf_reset(async); + comedi_buf_reset(s); async->inttrig = NULL; kfree(async->cmd.chanlist); async->cmd.chanlist = NULL; @@ -1557,7 +1557,7 @@ static int do_cmd_ioctl(struct comedi_device *dev, goto cleanup; } - comedi_buf_reset(async); + comedi_buf_reset(s); async->cb_mask = COMEDI_CB_EOA | COMEDI_CB_BLOCK | COMEDI_CB_ERROR | diff --git a/drivers/staging/comedi/comedi_internal.h b/drivers/staging/comedi/comedi_internal.h index 36e7a99b5079..3cc81de03b56 100644 --- a/drivers/staging/comedi/comedi_internal.h +++ b/drivers/staging/comedi/comedi_internal.h @@ -15,7 +15,7 @@ void comedi_free_subdevice_minor(struct comedi_subdevice *s); int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s, unsigned long new_size); -void comedi_buf_reset(struct comedi_async *async); +void comedi_buf_reset(struct comedi_subdevice *s); bool comedi_buf_is_mmapped(struct comedi_async *async); void comedi_buf_map_get(struct comedi_buf_map *bm); int comedi_buf_map_put(struct comedi_buf_map *bm); -- cgit v1.2.3 From d4526ab4e03bb16beee03547bfcbc1d8e09707f1 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 6 May 2014 13:12:11 +0100 Subject: staging: comedi: pass subdevice to comedi_buf_is_mmapped() Change the parameters of `comedi_buf_is_mmapped()` to pass a pointer to the comedi subdevice instead of a pointer to the "async" structure belonging to the subdevice. The main aim at the moment is to replace all the `struct comedi_async *` parameters with `struct comedi_subdevice *` parameters in the comedi driver API. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 4 ++-- drivers/staging/comedi/comedi_fops.c | 4 ++-- drivers/staging/comedi/comedi_internal.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index fa5d6d4d0351..46de9338bada 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -183,9 +183,9 @@ comedi_buf_map_from_subdev_get(struct comedi_subdevice *s) return bm; } -bool comedi_buf_is_mmapped(struct comedi_async *async) +bool comedi_buf_is_mmapped(struct comedi_subdevice *s) { - struct comedi_buf_map *bm = async->buf_map; + struct comedi_buf_map *bm = s->async->buf_map; return bm && (atomic_read(&bm->refcount.refcount) > 1); } diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 98229bd6cfb2..012c8fd1aabb 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -251,7 +251,7 @@ static int resize_async_buffer(struct comedi_device *dev, "subdevice is busy, cannot resize buffer\n"); return -EBUSY; } - if (comedi_buf_is_mmapped(async)) { + if (comedi_buf_is_mmapped(s)) { dev_dbg(dev->class_dev, "subdevice is mmapped, cannot resize buffer\n"); return -EBUSY; @@ -635,7 +635,7 @@ static int is_device_busy(struct comedi_device *dev) s = &dev->subdevices[i]; if (s->busy) return 1; - if (s->async && comedi_buf_is_mmapped(s->async)) + if (s->async && comedi_buf_is_mmapped(s)) return 1; } diff --git a/drivers/staging/comedi/comedi_internal.h b/drivers/staging/comedi/comedi_internal.h index 3cc81de03b56..e978c223f5b5 100644 --- a/drivers/staging/comedi/comedi_internal.h +++ b/drivers/staging/comedi/comedi_internal.h @@ -16,7 +16,7 @@ void comedi_free_subdevice_minor(struct comedi_subdevice *s); int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s, unsigned long new_size); void comedi_buf_reset(struct comedi_subdevice *s); -bool comedi_buf_is_mmapped(struct comedi_async *async); +bool comedi_buf_is_mmapped(struct comedi_subdevice *s); void comedi_buf_map_get(struct comedi_buf_map *bm); int comedi_buf_map_put(struct comedi_buf_map *bm); struct comedi_buf_map *comedi_buf_map_from_subdev_get( -- cgit v1.2.3 From 5b108588ba1ff6c18502dc9fe711b0229a18b9f8 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 6 May 2014 13:12:12 +0100 Subject: staging: comedi: pass subdevice to comedi_buf_munge() Local function `comedi_buf_munge()` is called by `comedi_buf_write_free()` to modify (or "munge") the data copied from a device into the buffer. Currently, the function takes a pointer to a `struct comedi_async` and gets a pointer to the comedi subdevice from the `subdevice` member. Change it to take a pointer to a `struct comedi_subdevice` and get a pointer to the "async" structure from the `async` member. The main motivation for this is to elimate the `subdevice` member of `struct comedi_async`. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index 46de9338bada..b5e329e1f623 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -282,10 +282,10 @@ EXPORT_SYMBOL_GPL(comedi_buf_write_alloc); * munging is applied to data by core as it passes between user * and kernel space */ -static unsigned int comedi_buf_munge(struct comedi_async *async, +static unsigned int comedi_buf_munge(struct comedi_subdevice *s, unsigned int num_bytes) { - struct comedi_subdevice *s = async->subdevice; + struct comedi_async *async = s->async; unsigned int count = 0; const unsigned num_sample_bytes = bytes_per_sample(s); @@ -344,7 +344,7 @@ unsigned int comedi_buf_write_free(struct comedi_subdevice *s, async->buf_write_count += nbytes; async->buf_write_ptr += nbytes; - comedi_buf_munge(async, async->buf_write_count - async->munge_count); + comedi_buf_munge(s, async->buf_write_count - async->munge_count); if (async->buf_write_ptr >= async->prealloc_bufsz) async->buf_write_ptr %= async->prealloc_bufsz; -- cgit v1.2.3 From 8ab4fe7e13989ef5b11bd96f1ed6763eabb1d17d Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 6 May 2014 13:12:13 +0100 Subject: staging: comedi: pass subdevice to __comedi_buf_write_alloc() Local function `__comedi_buf_write_alloc()` is called by `comedi_buf_write_alloc()` and `comedi_buf_put()`. It currently takes a pointer to a `struct comedi_async`. Change it to take a pointer to a `struct comedi_subdevice` and use the `async` member for consistency with other comedi buffer handling functions. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index b5e329e1f623..5be91cd88cc3 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -250,10 +250,11 @@ static unsigned int comedi_buf_write_n_available(struct comedi_async *async) return free_end - async->buf_write_alloc_count; } -static unsigned int __comedi_buf_write_alloc(struct comedi_async *async, +static unsigned int __comedi_buf_write_alloc(struct comedi_subdevice *s, unsigned int nbytes, int strict) { + struct comedi_async *async = s->async; unsigned int available = comedi_buf_write_n_available(async); if (nbytes > available) @@ -274,7 +275,7 @@ static unsigned int __comedi_buf_write_alloc(struct comedi_async *async, unsigned int comedi_buf_write_alloc(struct comedi_subdevice *s, unsigned int nbytes) { - return __comedi_buf_write_alloc(s->async, nbytes, 0); + return __comedi_buf_write_alloc(s, nbytes, 0); } EXPORT_SYMBOL_GPL(comedi_buf_write_alloc); @@ -427,7 +428,7 @@ EXPORT_SYMBOL_GPL(comedi_buf_read_free); int comedi_buf_put(struct comedi_subdevice *s, unsigned short x) { struct comedi_async *async = s->async; - unsigned int n = __comedi_buf_write_alloc(async, sizeof(short), 1); + unsigned int n = __comedi_buf_write_alloc(s, sizeof(short), 1); if (n < sizeof(short)) { async->events |= COMEDI_CB_ERROR; -- cgit v1.2.3 From a1c0e5fe68b437ba43b3125fbe5d8c72dca242a2 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 6 May 2014 13:12:14 +0100 Subject: staging: comedi: pass subdevice to comedi_buf_write_n_available() Local function `comedi_buf_write_n_available()` currently takes a pointer to a `struct comedi_async`. Change it to take a pointer to a `struct comedi_subdevice` and use the `async` member for consistency with the other comedi buffer handling functions. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index 5be91cd88cc3..df4a9c4bca35 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -243,8 +243,9 @@ void comedi_buf_reset(struct comedi_subdevice *s) async->events = 0; } -static unsigned int comedi_buf_write_n_available(struct comedi_async *async) +static unsigned int comedi_buf_write_n_available(struct comedi_subdevice *s) { + struct comedi_async *async = s->async; unsigned int free_end = async->buf_read_count + async->prealloc_bufsz; return free_end - async->buf_write_alloc_count; @@ -255,7 +256,7 @@ static unsigned int __comedi_buf_write_alloc(struct comedi_subdevice *s, int strict) { struct comedi_async *async = s->async; - unsigned int available = comedi_buf_write_n_available(async); + unsigned int available = comedi_buf_write_n_available(s); if (nbytes > available) nbytes = strict ? 0 : available; -- cgit v1.2.3 From b74e635d1c00b2532d32de4173115b08047229ed Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 6 May 2014 13:12:15 +0100 Subject: staging: comedi: mite: pass subdevice to mite_buf_change() `mite_buf_change()` in the "mite" module currently takes a pointer to a `struct comedi_async` and gets a pointer to the owning `struct comedi_subdevice` from the `subdevice` member. Change it to take a pointer to a `struct comedi_subdevice` and use the `async` member. The motivation for this is to eliminate the `subdevice` member of `struct comedi_async`. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 5 +++-- drivers/staging/comedi/drivers/mite.h | 2 +- drivers/staging/comedi/drivers/ni_660x.c | 2 +- drivers/staging/comedi/drivers/ni_pcidio.c | 2 +- drivers/staging/comedi/drivers/ni_pcimio.c | 10 +++++----- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 6c8bd7c33082..2d224cfe72e3 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -307,8 +307,9 @@ EXPORT_SYMBOL_GPL(mite_dma_arm); /**************************************/ int mite_buf_change(struct mite_dma_descriptor_ring *ring, - struct comedi_async *async) + struct comedi_subdevice *s) { + struct comedi_async *async = s->async; unsigned int n_links; int i; @@ -333,7 +334,7 @@ int mite_buf_change(struct mite_dma_descriptor_ring *ring, n_links * sizeof(struct mite_dma_descriptor), &ring->descriptors_dma_addr, GFP_KERNEL); if (!ring->descriptors) { - dev_err(async->subdevice->device->class_dev, + dev_err(s->device->class_dev, "mite: ring buffer allocation failed\n"); return -ENOMEM; } diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index 78f235747991..929b9bb3fced 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -120,7 +120,7 @@ int mite_done(struct mite_channel *mite_chan); void mite_prep_dma(struct mite_channel *mite_chan, unsigned int num_device_bits, unsigned int num_memory_bits); int mite_buf_change(struct mite_dma_descriptor_ring *ring, - struct comedi_async *async); + struct comedi_subdevice *s); static inline int CHAN_OFFSET(int channel) { diff --git a/drivers/staging/comedi/drivers/ni_660x.c b/drivers/staging/comedi/drivers/ni_660x.c index 2858b3d559c1..3901e3b5ba51 100644 --- a/drivers/staging/comedi/drivers/ni_660x.c +++ b/drivers/staging/comedi/drivers/ni_660x.c @@ -836,7 +836,7 @@ static int ni_660x_buf_change(struct comedi_device *dev, struct ni_gpct *counter = s->private; int ret; - ret = mite_buf_change(mite_ring(devpriv, counter), s->async); + ret = mite_buf_change(mite_ring(devpriv, counter), s); if (ret < 0) return ret; diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c index d0ad82a3b4b9..1f8423504031 100644 --- a/drivers/staging/comedi/drivers/ni_pcidio.c +++ b/drivers/staging/comedi/drivers/ni_pcidio.c @@ -806,7 +806,7 @@ static int ni_pcidio_change(struct comedi_device *dev, struct nidio96_private *devpriv = dev->private; int ret; - ret = mite_buf_change(devpriv->di_mite_ring, s->async); + ret = mite_buf_change(devpriv->di_mite_ring, s); if (ret < 0) return ret; diff --git a/drivers/staging/comedi/drivers/ni_pcimio.c b/drivers/staging/comedi/drivers/ni_pcimio.c index d40df072583c..89300dc78e35 100644 --- a/drivers/staging/comedi/drivers/ni_pcimio.c +++ b/drivers/staging/comedi/drivers/ni_pcimio.c @@ -1560,7 +1560,7 @@ static int pcimio_ai_change(struct comedi_device *dev, struct ni_private *devpriv = dev->private; int ret; - ret = mite_buf_change(devpriv->ai_mite_ring, s->async); + ret = mite_buf_change(devpriv->ai_mite_ring, s); if (ret < 0) return ret; @@ -1573,7 +1573,7 @@ static int pcimio_ao_change(struct comedi_device *dev, struct ni_private *devpriv = dev->private; int ret; - ret = mite_buf_change(devpriv->ao_mite_ring, s->async); + ret = mite_buf_change(devpriv->ao_mite_ring, s); if (ret < 0) return ret; @@ -1587,7 +1587,7 @@ static int pcimio_gpct0_change(struct comedi_device *dev, struct ni_private *devpriv = dev->private; int ret; - ret = mite_buf_change(devpriv->gpct_mite_ring[0], s->async); + ret = mite_buf_change(devpriv->gpct_mite_ring[0], s); if (ret < 0) return ret; @@ -1601,7 +1601,7 @@ static int pcimio_gpct1_change(struct comedi_device *dev, struct ni_private *devpriv = dev->private; int ret; - ret = mite_buf_change(devpriv->gpct_mite_ring[1], s->async); + ret = mite_buf_change(devpriv->gpct_mite_ring[1], s); if (ret < 0) return ret; @@ -1614,7 +1614,7 @@ static int pcimio_dio_change(struct comedi_device *dev, struct ni_private *devpriv = dev->private; int ret; - ret = mite_buf_change(devpriv->cdo_mite_ring, s->async); + ret = mite_buf_change(devpriv->cdo_mite_ring, s); if (ret < 0) return ret; -- cgit v1.2.3 From 74f63db7ae614aee8370df6152c0da76e14b6ff0 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 6 May 2014 13:12:16 +0100 Subject: staging: comedi: mite: pass subdevice to mite_sync_input_dma() `mite_sync_input_dma()` in the "mite" module currently takes a pointer to a `struct comedi_async` and gets a pointer to the owning `struct comedi_subdevice` from the `subdevice` member. Change it to take a pointer to a `struct comedi_subdevice` and use the `async` member. The motivation for this is to eliminate the `subdevice` member of `struct comedi_async`. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 4 ++-- drivers/staging/comedi/drivers/mite.h | 2 +- drivers/staging/comedi/drivers/ni_660x.c | 2 +- drivers/staging/comedi/drivers/ni_mio_common.c | 2 +- drivers/staging/comedi/drivers/ni_pcidio.c | 4 ++-- drivers/staging/comedi/drivers/ni_tiocmd.c | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 2d224cfe72e3..f473841e1801 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -526,9 +526,9 @@ void mite_dma_disarm(struct mite_channel *mite_chan) EXPORT_SYMBOL_GPL(mite_dma_disarm); int mite_sync_input_dma(struct mite_channel *mite_chan, - struct comedi_async *async) + struct comedi_subdevice *s) { - struct comedi_subdevice *s = async->subdevice; + struct comedi_async *async = s->async; int count; unsigned int nbytes, old_alloc_count; diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index 929b9bb3fced..ba3ad0cf014f 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -106,7 +106,7 @@ unsigned mite_dma_tcr(struct mite_channel *mite_chan); void mite_dma_arm(struct mite_channel *mite_chan); void mite_dma_disarm(struct mite_channel *mite_chan); int mite_sync_input_dma(struct mite_channel *mite_chan, - struct comedi_async *async); + struct comedi_subdevice *s); int mite_sync_output_dma(struct mite_channel *mite_chan, struct comedi_async *async); u32 mite_bytes_written_to_memory_lb(struct mite_channel *mite_chan); diff --git a/drivers/staging/comedi/drivers/ni_660x.c b/drivers/staging/comedi/drivers/ni_660x.c index 3901e3b5ba51..634cde83a02b 100644 --- a/drivers/staging/comedi/drivers/ni_660x.c +++ b/drivers/staging/comedi/drivers/ni_660x.c @@ -823,7 +823,7 @@ static int ni_660x_input_poll(struct comedi_device *dev, /* lock to avoid race with comedi_poll */ spin_lock_irqsave(&devpriv->interrupt_lock, flags); - mite_sync_input_dma(counter->mite_chan, s->async); + mite_sync_input_dma(counter->mite_chan, s); spin_unlock_irqrestore(&devpriv->interrupt_lock, flags); return comedi_buf_read_n_available(s); } diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index e54488c2eb5a..953130b37fda 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -864,7 +864,7 @@ static void ni_sync_ai_dma(struct comedi_device *dev) spin_lock_irqsave(&devpriv->mite_channel_lock, flags); if (devpriv->ai_mite_chan) - mite_sync_input_dma(devpriv->ai_mite_chan, s->async); + mite_sync_input_dma(devpriv->ai_mite_chan, s); spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); } diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c index 1f8423504031..14aaa58bbc9d 100644 --- a/drivers/staging/comedi/drivers/ni_pcidio.c +++ b/drivers/staging/comedi/drivers/ni_pcidio.c @@ -359,7 +359,7 @@ static int ni_pcidio_poll(struct comedi_device *dev, struct comedi_subdevice *s) spin_lock_irqsave(&dev->spinlock, irq_flags); spin_lock(&devpriv->mite_channel_lock); if (devpriv->di_mite_chan) - mite_sync_input_dma(devpriv->di_mite_chan, s->async); + mite_sync_input_dma(devpriv->di_mite_chan, s); spin_unlock(&devpriv->mite_channel_lock); count = s->async->buf_write_count - s->async->buf_read_count; spin_unlock_irqrestore(&dev->spinlock, irq_flags); @@ -405,7 +405,7 @@ static irqreturn_t nidio_interrupt(int irq, void *d) writel(CHOR_CLRLC, mite->mite_io_addr + MITE_CHOR(devpriv->di_mite_chan->channel)); - mite_sync_input_dma(devpriv->di_mite_chan, s->async); + mite_sync_input_dma(devpriv->di_mite_chan, s); /* XXX need to byteswap */ } if (m_status & ~(CHSR_INT | CHSR_LINKC | CHSR_DONE | CHSR_DRDY | diff --git a/drivers/staging/comedi/drivers/ni_tiocmd.c b/drivers/staging/comedi/drivers/ni_tiocmd.c index 9cc77c0b2f0f..2557ab48cb6c 100644 --- a/drivers/staging/comedi/drivers/ni_tiocmd.c +++ b/drivers/staging/comedi/drivers/ni_tiocmd.c @@ -464,7 +464,7 @@ void ni_tio_handle_interrupt(struct ni_gpct *counter, counter->mite_chan->mite->mite_io_addr + MITE_CHOR(counter->mite_chan->channel)); } - mite_sync_input_dma(counter->mite_chan, s->async); + mite_sync_input_dma(counter->mite_chan, s); spin_unlock_irqrestore(&counter->lock, flags); } EXPORT_SYMBOL_GPL(ni_tio_handle_interrupt); -- cgit v1.2.3 From 1e575a9cd9f65f18e7a47a58b10f57dc92263e39 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 6 May 2014 13:12:17 +0100 Subject: staging: comedi: mite: pass subdevice to mite_sync_output_dma() `mite_sync_output_dma()` in the "mite" module currently takes a pointer to a `struct comedi_async` and gets a pointer to the owning `struct comedi_subdevice` from the `subdevice` member. Change it to take a pointer to a `struct comedi_subdevice` and use the `async` member. The motivation for this is to eliminate the `subdevice` member of `struct comedi_async`. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 7 +++---- drivers/staging/comedi/drivers/mite.h | 2 +- drivers/staging/comedi/drivers/ni_mio_common.c | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index f473841e1801..c12806ee4f6f 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -559,9 +559,9 @@ int mite_sync_input_dma(struct mite_channel *mite_chan, EXPORT_SYMBOL_GPL(mite_sync_input_dma); int mite_sync_output_dma(struct mite_channel *mite_chan, - struct comedi_async *async) + struct comedi_subdevice *s) { - struct comedi_subdevice *s = async->subdevice; + struct comedi_async *async = s->async; int count; u32 nbytes_ub, nbytes_lb; unsigned int old_alloc_count; @@ -579,8 +579,7 @@ int mite_sync_output_dma(struct mite_channel *mite_chan, (int)(nbytes_ub - stop_count) > 0) nbytes_ub = stop_count; if ((int)(nbytes_ub - old_alloc_count) > 0) { - dev_warn(async->subdevice->device->class_dev, - "mite: DMA underrun\n"); + dev_warn(s->device->class_dev, "mite: DMA underrun\n"); async->events |= COMEDI_CB_OVERFLOW; return -1; } diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index ba3ad0cf014f..e6e58e989b73 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -108,7 +108,7 @@ void mite_dma_disarm(struct mite_channel *mite_chan); int mite_sync_input_dma(struct mite_channel *mite_chan, struct comedi_subdevice *s); int mite_sync_output_dma(struct mite_channel *mite_chan, - struct comedi_async *async); + struct comedi_subdevice *s); u32 mite_bytes_written_to_memory_lb(struct mite_channel *mite_chan); u32 mite_bytes_written_to_memory_ub(struct mite_channel *mite_chan); u32 mite_bytes_read_from_memory_lb(struct mite_channel *mite_chan); diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 953130b37fda..9afe76f2c7c8 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -877,7 +877,7 @@ static void mite_handle_b_linkc(struct mite_struct *mite, spin_lock_irqsave(&devpriv->mite_channel_lock, flags); if (devpriv->ao_mite_chan) - mite_sync_output_dma(devpriv->ao_mite_chan, s->async); + mite_sync_output_dma(devpriv->ao_mite_chan, s); spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); } @@ -3640,7 +3640,7 @@ static void handle_cdio_interrupt(struct comedi_device *dev) devpriv->mite->mite_io_addr + MITE_CHOR(devpriv->cdo_mite_chan->channel)); } - mite_sync_output_dma(devpriv->cdo_mite_chan, s->async); + mite_sync_output_dma(devpriv->cdo_mite_chan, s); } spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags); #endif -- cgit v1.2.3 From 2891911a32e81942cefb1bbc1398f39e9fe76db5 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 6 May 2014 13:12:18 +0100 Subject: staging: comedi: remove subdevice member of struct comedi_async The `async` member of `struct comedi_subdevice` may point to a `struct comedi_async` or may be NULL. The `subdevice` member of `struct comedi_async` points back to the `struct comedi_subdevice` associated with it in a one-to-one relationship. All uses of the `subdevice` member of `struct comedi_async` apart from its initialization have now been removed (by passing around a pointer to the subdevice instead of to the "async" structure), so get rid of it. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedidev.h | 2 -- drivers/staging/comedi/drivers.c | 1 - 2 files changed, 3 deletions(-) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index a5d479c1266e..d07d47f5db81 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -108,8 +108,6 @@ struct comedi_buf_map { }; struct comedi_async { - struct comedi_subdevice *subdevice; - void *prealloc_buf; /* pre-allocated buffer */ unsigned int prealloc_bufsz; /* buffer size, in bytes */ struct comedi_buf_map *buf_map; /* map of buffer pages */ diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index cb5d21411a0c..299726f39e26 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -307,7 +307,6 @@ static int __comedi_device_postconfig_async(struct comedi_device *dev, return -ENOMEM; init_waitqueue_head(&async->wait_head); - async->subdevice = s; s->async = async; async->max_bufsize = comedi_default_buf_maxsize_kb * 1024; -- cgit v1.2.3 From 7af6741938c2c7dd9315fbd109172d6ca0ed6b15 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Wed, 7 May 2014 02:03:32 -0500 Subject: staging: comedi: addi_apci_1564: remove check for timer subdevice The only board served by this driver always has a timer, so we can init the timer subdevice without checking first. The boardinfo about the timer can also be removed and the data used directly. Signed-off-by: Chase Southwood Reviewed-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1564.c | 27 +++++++++---------------- 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 86276cdb6f47..d7a5c2f9d6e3 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -15,9 +15,6 @@ static const struct addi_board apci1564_boardtypes[] = { .i_NbrDoChannel = 32, .i_DoMaxdata = 0xffffffff, .i_Timer = 1, - .timer_config = apci1564_timer_config, - .timer_write = apci1564_timer_write, - .timer_read = apci1564_timer_read, }, }; @@ -119,21 +116,15 @@ static int apci1564_auto_attach(struct comedi_device *dev, /* Allocate and Initialise Timer Subdevice Structures */ s = &dev->subdevices[2]; - if (this_board->i_Timer) { - s->type = COMEDI_SUBD_TIMER; - s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = 1; - s->maxdata = 0; - s->len_chanlist = 1; - s->range_table = &range_digital; - - s->insn_write = this_board->timer_write; - s->insn_read = this_board->timer_read; - s->insn_config = this_board->timer_config; - s->insn_bits = this_board->timer_bits; - } else { - s->type = COMEDI_SUBD_UNUSED; - } + s->type = COMEDI_SUBD_TIMER; + s->subdev_flags = SDF_WRITEABLE; + s->n_chan = 1; + s->maxdata = 0; + s->len_chanlist = 1; + s->range_table = &range_digital; + s->insn_write = apci1564_timer_write; + s->insn_read = apci1564_timer_read; + s->insn_config = apci1564_timer_config; return 0; } -- cgit v1.2.3 From 55292b3d543a313aee456b3acb4cb0290ca2977c Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Wed, 7 May 2014 02:04:17 -0500 Subject: staging: comedi: addi_apci_1564: remove boardinfo This driver only supports a single board type. Remove the boardinfo and its use in the driver. Signed-off-by: Chase Southwood Reviewed-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1564.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index d7a5c2f9d6e3..cbccbb6a2b76 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -8,16 +8,6 @@ #include "addi-data/hwdrv_apci1564.c" -static const struct addi_board apci1564_boardtypes[] = { - { - .pc_DriverName = "apci1564", - .i_NbrDiChannel = 32, - .i_NbrDoChannel = 32, - .i_DoMaxdata = 0xffffffff, - .i_Timer = 1, - }, -}; - static irqreturn_t v_ADDI_Interrupt(int irq, void *d) { apci1564_interrupt(irq, d); @@ -60,12 +50,11 @@ static int apci1564_auto_attach(struct comedi_device *dev, unsigned long context_unused) { struct pci_dev *pcidev = comedi_to_pci_dev(dev); - const struct addi_board *this_board = comedi_board(dev); struct addi_private *devpriv; struct comedi_subdevice *s; int ret; - dev->board_name = this_board->pc_DriverName; + dev->board_name = dev->driver->driver_name; devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) -- cgit v1.2.3 From 27a2234edd4a5c8b0ebdaaa3f6a5f00183f3154f Mon Sep 17 00:00:00 2001 From: Christian Engelmayer Date: Wed, 7 May 2014 21:45:52 +0200 Subject: staging: comedi: ii_pci20kc: fix usage of uninit scalar in ii20k_attach() This driver supports the PCI-20001C-1a and PCI-20001C-2a carrier boards. The -2a version has 32 on-board DIO channels. In case this variant is detected, local variable 'has_dio' is set accordingly. Otherwise it is left uninitialized and the following subdevice instantiation depends on the stack. Detected by Coverity - CID 1077830. Signed-off-by: Christian Engelmayer Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ii_pci20kc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c index 3558ab3b6e1f..2516ce834839 100644 --- a/drivers/staging/comedi/drivers/ii_pci20kc.c +++ b/drivers/staging/comedi/drivers/ii_pci20kc.c @@ -461,6 +461,7 @@ static int ii20k_attach(struct comedi_device *dev, id = readb(devpriv->ioaddr + II20K_ID_REG); switch (id & II20K_ID_MASK) { case II20K_ID_PCI20001C_1A: + has_dio = false; break; case II20K_ID_PCI20001C_2A: has_dio = true; -- cgit v1.2.3 From 55fce2866ef5c815f7f5df0e2335729281fa5df7 Mon Sep 17 00:00:00 2001 From: Sheetal Tigadoli Date: Thu, 8 May 2014 15:43:37 +0530 Subject: staging: comedi: Fixes Coding Style Warning in file das08.h The Patch fixes following Warnings, found using checkpatch.pl, in file das08.h ./scripts/checkpatch.pl --file --terse drivers/staging/comedi/drivers/das08.h drivers/staging/comedi/drivers/das08.h:43: WARNING: line over 80 characters total: 0 errors, 1 warnings, 50 lines checked Signed-off-by: Sheetal Tigadoli Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/das08.h b/drivers/staging/comedi/drivers/das08.h index 46a314c5113e..18cc170facd0 100644 --- a/drivers/staging/comedi/drivers/das08.h +++ b/drivers/staging/comedi/drivers/das08.h @@ -40,7 +40,9 @@ struct das08_board_struct { }; struct das08_private_struct { - unsigned int do_mux_bits; /* bits for do/mux register on boards without separate do register */ + unsigned int do_mux_bits; /* bits for do/mux register on boards + * without separate do register + */ const unsigned int *pg_gainlist; unsigned int ao_readback[2]; /* assume 2 AO channels */ }; -- cgit v1.2.3 From 33bd00ef6dfc3e0cce7c8e8577ec2204d6fae121 Mon Sep 17 00:00:00 2001 From: Raghavendra Ganiga Date: Mon, 19 May 2014 21:49:03 +0530 Subject: Staging: comedi: fixed warnings reported by checkpatch tool on comedi_test.c file This is a patch to remove warnings reported by checkpatch tool on comedi_test.c file Signed-off-by: Raghavendra Chandra Ganiga Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c index ad5014a4074e..9896a16fe84b 100644 --- a/drivers/staging/comedi/drivers/comedi_test.c +++ b/drivers/staging/comedi/drivers/comedi_test.c @@ -188,6 +188,7 @@ static void waveform_ai_interrupt(unsigned long arg) if (cmd->stop_src == TRIG_COUNT) { unsigned int remaining = cmd->stop_arg - devpriv->ai_count; + if (num_scans >= remaining) { /* about to finish */ num_scans = remaining; @@ -198,6 +199,7 @@ static void waveform_ai_interrupt(unsigned long arg) for (i = 0; i < num_scans; i++) { for (j = 0; j < cmd->chanlist_len; j++) { unsigned short sample; + sample = fake_waveform(dev, CR_CHAN(cmd->chanlist[j]), CR_RANGE(cmd->chanlist[j]), devpriv->usec_current + -- cgit v1.2.3 From 995e13b9b985652f30195690e978e8442d2e0d77 Mon Sep 17 00:00:00 2001 From: Raghavendra Ganiga Date: Mon, 19 May 2014 21:41:36 +0530 Subject: Staging: comedi: fixed warning shown by checkpatch tool on cb_das16_cs.c file This is a patch to fix the warnings shown by checkpatch tool on file cb_das16_cs.c Signed-off-by: Raghavendra Chandra Ganiga Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_das16_cs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/staging/comedi/drivers/cb_das16_cs.c index 645fcb0cf17d..eb1b92d72e87 100644 --- a/drivers/staging/comedi/drivers/cb_das16_cs.c +++ b/drivers/staging/comedi/drivers/cb_das16_cs.c @@ -184,6 +184,7 @@ static int das16cs_ao_winsn(struct comedi_device *dev, for (bit = 15; bit >= 0; bit--) { int b = (d >> bit) & 0x1; + b <<= 1; outw(status1 | b | 0x0000, dev->iobase + DAS16CS_MISC1); udelay(1); -- cgit v1.2.3 From 36682e575c7db04549ae504dd13896dd31c5a014 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Wed, 21 May 2014 19:40:09 -0500 Subject: staging: comedi: addi_apci_1564: move apci1564_di_insn_bits() to addi_apci_1564.c This function is already compliant with the comedi API and is behaving as comedi core expects. This patch moves it out of addi-data/hwdrv_apci1564.c and into the driver proper since no further work needs to be done on it. Signed-off-by: Chase Southwood Reviewed-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c | 12 ------------ drivers/staging/comedi/drivers/addi_apci_1564.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c index b3c3f603fb73..533d156c546e 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c @@ -129,18 +129,6 @@ static int apci1564_di_config(struct comedi_device *dev, return insn->n; } -static int apci1564_di_insn_bits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - - data[1] = inl(devpriv->i_IobaseAmcc + APCI1564_DI_REG); - - return insn->n; -} - /* * Configures The Digital Output Subdevice. * diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index cbccbb6a2b76..fe477cc55af7 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -14,6 +14,18 @@ static irqreturn_t v_ADDI_Interrupt(int irq, void *d) return IRQ_RETVAL(1); } +static int apci1564_di_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + struct addi_private *devpriv = dev->private; + + data[1] = inl(devpriv->i_IobaseAmcc + APCI1564_DI_REG); + + return insn->n; +} + static int apci1564_reset(struct comedi_device *dev) { struct addi_private *devpriv = dev->private; -- cgit v1.2.3 From 96211ca58a5d43e6cb527b2a110fbc5df4d15949 Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Wed, 21 May 2014 19:41:15 -0500 Subject: staging: comedi: addi_apci_1564: move apci1564_do_insn_bits() to addi_apci_1564.c This function is already compliant with the comedi API and is behaving as comedi core expects. This patch moves it out of addi-data/hwdrv_apci1564.c and into the driver proper since no further work needs to be done on it. Signed-off-by: Chase Southwood Reviewed-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/addi-data/hwdrv_apci1564.c | 17 ----------------- drivers/staging/comedi/drivers/addi_apci_1564.c | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c index 533d156c546e..0ba5385226ae 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c @@ -170,23 +170,6 @@ static int apci1564_do_config(struct comedi_device *dev, return insn->n; } -static int apci1564_do_insn_bits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - - s->state = inl(devpriv->i_IobaseAmcc + APCI1564_DO_REG); - - if (comedi_dio_update_state(s, data)) - outl(s->state, devpriv->i_IobaseAmcc + APCI1564_DO_REG); - - data[1] = s->state; - - return insn->n; -} - /* * Configures The Timer, Counter or Watchdog * diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index fe477cc55af7..13d9962b47ec 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -26,6 +26,23 @@ static int apci1564_di_insn_bits(struct comedi_device *dev, return insn->n; } +static int apci1564_do_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + struct addi_private *devpriv = dev->private; + + s->state = inl(devpriv->i_IobaseAmcc + APCI1564_DO_REG); + + if (comedi_dio_update_state(s, data)) + outl(s->state, devpriv->i_IobaseAmcc + APCI1564_DO_REG); + + data[1] = s->state; + + return insn->n; +} + static int apci1564_reset(struct comedi_device *dev) { struct addi_private *devpriv = dev->private; -- cgit v1.2.3 From 6026771417669c064fa20e3f3fd12aafcad1b37d Mon Sep 17 00:00:00 2001 From: Tair Rzayev Date: Sun, 4 May 2014 11:44:52 +0300 Subject: staging: keucr: smilmain.c: cosmetic updates * Move Check_D_MediaFmt() implementation up in smilmain.c to keep all the non-static functions at the top of the file; * Remove unnecessary extern and newlines from "init.h"; Signed-off-by: Tair Rzayev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/keucr/init.h | 4 ---- drivers/staging/keucr/smilmain.c | 34 +++++++++++++++++----------------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/drivers/staging/keucr/init.h b/drivers/staging/keucr/init.h index 32c724df621d..d1367e726ff1 100644 --- a/drivers/staging/keucr/init.h +++ b/drivers/staging/keucr/init.h @@ -1,9 +1,5 @@ #include "common.h" -extern u32 MediaChange; - - - static u8 SM_Init[] = { 0x7B, 0x09, 0x7C, 0xF0, 0x7D, 0x10, 0x7E, 0xE9, 0x7F, 0xCC, 0x12, 0x2F, 0x71, 0x90, 0xE9, 0xCC, diff --git a/drivers/staging/keucr/smilmain.c b/drivers/staging/keucr/smilmain.c index fc7cbc6f8a45..42ec8a669ad3 100644 --- a/drivers/staging/keucr/smilmain.c +++ b/drivers/staging/keucr/smilmain.c @@ -141,23 +141,6 @@ int Media_D_CopySector(struct us_data *us, u32 start, u16 count, u8 *buf) return NO_ERROR; } -/* ----- Release_D_CopySector() ------------------------------------------ */ -static int Release_D_CopySector(struct us_data *us) -{ - Log2Phy[Media.Zone][Media.LogBlock] = WriteBlock; - Media.PhyBlock = ReadBlock; - - if (Media.PhyBlock == NO_ASSIGN) { - Media.PhyBlock = WriteBlock; - return SMSUCCESS; - } - - Clr_D_Bit(Assign[Media.Zone], Media.PhyBlock); - Media.PhyBlock = WriteBlock; - - return SMSUCCESS; -} - /* SmartMedia Physical Format Test Subroutine */ /* ----- Check_D_MediaFmt() --------------------------------------------- */ int Check_D_MediaFmt(struct us_data *us) @@ -184,6 +167,23 @@ int Check_D_MediaFmt(struct us_data *us) return SMSUCCESS; } +/* ----- Release_D_CopySector() ------------------------------------------ */ +static int Release_D_CopySector(struct us_data *us) +{ + Log2Phy[Media.Zone][Media.LogBlock] = WriteBlock; + Media.PhyBlock = ReadBlock; + + if (Media.PhyBlock == NO_ASSIGN) { + Media.PhyBlock = WriteBlock; + return SMSUCCESS; + } + + Clr_D_Bit(Assign[Media.Zone], Media.PhyBlock); + Media.PhyBlock = WriteBlock; + + return SMSUCCESS; +} + /* SmartMedia Physical Address Control Subroutine */ /* ----- Conv_D_MediaAddr() --------------------------------------------- */ static int Conv_D_MediaAddr(struct us_data *us, u32 addr) -- cgit v1.2.3 From 138d7d0340fe1978cdff2140733ff23eb289aeb1 Mon Sep 17 00:00:00 2001 From: Levente Kurusa Date: Sat, 10 May 2014 13:39:32 +0200 Subject: staging: rtl8821ae: fix pointer coding style Found by checkpatch. Signed-off-by: Levente Kurusa Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8821ae/pci.c b/drivers/staging/rtl8821ae/pci.c index 94f72832a838..eef3ebcd78af 100644 --- a/drivers/staging/rtl8821ae/pci.c +++ b/drivers/staging/rtl8821ae/pci.c @@ -392,7 +392,7 @@ static u8 _rtl_pci_get_pciehdr_offset(struct ieee80211_hw *hw) pcicfg_addr_port + (num4bytes << 2)); rtl_pci_raw_read_port_ushort(PCI_CONF_DATA, - (u16*)&capability_hdr); + (u16 *)&capability_hdr); /* Found the PCI express capability. */ if (capability_hdr.capability_id == PCI_CAPABILITY_ID_PCI_EXPRESS) -- cgit v1.2.3 From 1abc4ef449b36b63512a1fbc743c5f51d2c8d2d7 Mon Sep 17 00:00:00 2001 From: Konrad Zapalowicz Date: Sat, 17 May 2014 21:23:37 +0200 Subject: staging: rtl8821ae: fix double const in sw.c This commit fixes the following sparse warning: drivers/staging/rtl8821ae/rtl8821ae/sw.c: - 449:14: warning: duplicate const Signed-off-by: Konrad Zapalowicz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/rtl8821ae/sw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8821ae/rtl8821ae/sw.c b/drivers/staging/rtl8821ae/rtl8821ae/sw.c index a8d175569770..c24d4268c2ef 100644 --- a/drivers/staging/rtl8821ae/rtl8821ae/sw.c +++ b/drivers/staging/rtl8821ae/rtl8821ae/sw.c @@ -446,7 +446,7 @@ MODULE_PARM_DESC(ips, "using no link power save (default 1 is open)\n"); MODULE_PARM_DESC(fwlps, "using linked fw control power save (default 1 is open)\n"); #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) -static const SIMPLE_DEV_PM_OPS(rtlwifi_pm_ops, rtl_pci_suspend, rtl_pci_resume); +static SIMPLE_DEV_PM_OPS(rtlwifi_pm_ops, rtl_pci_suspend, rtl_pci_resume); #endif #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) -- cgit v1.2.3 From 4b9708e0c6c24da9a49cec384472bd1bd7400a69 Mon Sep 17 00:00:00 2001 From: Konrad Zapalowicz Date: Sat, 17 May 2014 21:23:38 +0200 Subject: staging: rtl8821ae: fix not declared symbols should be static in sw.c This commit fixes the following sparse warnings: drivers/staging/rtl8821ae/rtl8821ae/sw.c: - 48:6: warning: symbol 'rtl8821ae_init_aspm_vars' was not declared. Should it be static? - 228:5: warning: symbol 'rtl8812ae_rx_command_packet_handler' was not declared. Should it be static? - 263:20: warning: symbol 'rtl8821ae_hal_ops' was not declared. Should it be static? - 314:23: warning: symbol 'rtl8821ae_mod_params' was not declared. Should it be static? - 321:20: warning: symbol 'rtl8821ae_hal_cfg' was not declared. Should it be static? All of this symbols are local, that is there are no references to them in the other files from this driver. Signed-off-by: Konrad Zapalowicz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/rtl8821ae/sw.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8821ae/rtl8821ae/sw.c b/drivers/staging/rtl8821ae/rtl8821ae/sw.c index c24d4268c2ef..e90806ebeb07 100644 --- a/drivers/staging/rtl8821ae/rtl8821ae/sw.c +++ b/drivers/staging/rtl8821ae/rtl8821ae/sw.c @@ -45,7 +45,7 @@ #include "hal_btc.h" #include "../btcoexist/rtl_btc.h" -void rtl8821ae_init_aspm_vars(struct ieee80211_hw *hw) +static void rtl8821ae_init_aspm_vars(struct ieee80211_hw *hw) { struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); @@ -225,7 +225,7 @@ void rtl8821ae_deinit_sw_vars(struct ieee80211_hw *hw) //printk("<=========rtl8821ae_deinit_sw_vars().\n"); } -u32 rtl8812ae_rx_command_packet_handler( +static u32 rtl8812ae_rx_command_packet_handler( struct ieee80211_hw *hw, struct rtl_stats status, struct sk_buff *skb @@ -260,7 +260,7 @@ bool rtl8821ae_get_btc_status(void) return true; } -struct rtl_hal_ops rtl8821ae_hal_ops = { +static struct rtl_hal_ops rtl8821ae_hal_ops = { .init_sw_vars = rtl8821ae_init_sw_vars, .deinit_sw_vars = rtl8821ae_deinit_sw_vars, .read_eeprom_info = rtl8821ae_read_eeprom_info, @@ -311,14 +311,14 @@ struct rtl_hal_ops rtl8821ae_hal_ops = { .rx_command_packet_handler = rtl8812ae_rx_command_packet_handler, }; -struct rtl_mod_params rtl8821ae_mod_params = { +static struct rtl_mod_params rtl8821ae_mod_params = { .sw_crypto = false, .b_inactiveps = false,//true, .b_swctrl_lps = false, .b_fwctrl_lps = false, //true, }; -struct rtl_hal_cfg rtl8821ae_hal_cfg = { +static struct rtl_hal_cfg rtl8821ae_hal_cfg = { .bar_id = 2, .write_readback = true, .name = "rtl8821ae_pci", -- cgit v1.2.3 From 6fdb1f4fb05998bb255cf4e2605bc5f0e842eb24 Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Thu, 22 May 2014 11:57:16 -0700 Subject: staging/rtl8821ae: avoid format string leak to thread name This makes sure the cfg->name can never accidentally be processed as a format string in the worker thread name. Signed-off-by: Kees Cook Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/base.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8821ae/base.c b/drivers/staging/rtl8821ae/base.c index a4c9cc437bc6..49ee311ddcd9 100644 --- a/drivers/staging/rtl8821ae/base.c +++ b/drivers/staging/rtl8821ae/base.c @@ -404,7 +404,8 @@ static int _rtl_init_deferred_work(struct ieee80211_hw *hw) /**/ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) /**/ - rtlpriv->works.rtl_wq = alloc_workqueue(rtlpriv->cfg->name, 0, 0); + rtlpriv->works.rtl_wq = alloc_workqueue("%s", 0, 0, + rtlpriv->cfg->name); /**/ #else rtlpriv->works.rtl_wq = create_workqueue(rtlpriv->cfg->name); -- cgit v1.2.3 From c90ebb63d88c9ffd62c8141a53a3b58f6293ce9b Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 21 May 2014 21:09:39 +0100 Subject: staging: vt6656: iocmd.h remove dead code. Remove dead strutures and macros. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/iocmd.h | 86 ------------------------------------------ 1 file changed, 86 deletions(-) diff --git a/drivers/staging/vt6656/iocmd.h b/drivers/staging/vt6656/iocmd.h index abf1f86ef0af..b957e6d475af 100644 --- a/drivers/staging/vt6656/iocmd.h +++ b/drivers/staging/vt6656/iocmd.h @@ -35,90 +35,4 @@ typedef enum tagWZONETYPE { ZoneType_Europe = 2 } WZONETYPE; -#define SSID_MAXLEN 32 -#define BSSID_LEN 6 -#define WEP_NKEYS 4 -#define WEP_KEYMAXLEN 29 -#define WEP_40BIT_LEN 5 -#define WEP_104BIT_LEN 13 -#define WEP_232BIT_LEN 16 - -typedef struct tagSBSSIDItem { - - u32 uChannel; - u8 abyBSSID[BSSID_LEN]; - u8 abySSID[SSID_MAXLEN + 1]; - u16 wBeaconInterval; - u16 wCapInfo; - u8 byNetType; - bool bWEPOn; - u32 uRSSI; - -} __packed SBSSIDItem; - -typedef struct tagSNodeItem { - // STA info - u16 wAID; - u8 abyMACAddr[6]; - u16 wTxDataRate; - u16 wInActiveCount; - u16 wEnQueueCnt; - u16 wFlags; - bool bPWBitOn; - u8 byKeyIndex; - u16 wWepKeyLength; - u8 abyWepKey[WEP_KEYMAXLEN]; - // Auto rate fallback vars - bool bIsInFallback; - u32 uTxFailures; - u32 uTxAttempts; - u16 wFailureRatio; - -} __packed SNodeItem; - -struct viawget_hostapd_param { - u32 cmd; - u8 sta_addr[6]; - union { - struct { - u16 aid; - u16 capability; - u8 tx_supp_rates; - } add_sta; - struct { - u32 inactive_sec; - } get_info_sta; - struct { - u8 alg; - u32 flags; - u32 err; - u8 idx; - u8 seq[8]; - u16 key_len; - u8 key[0]; - } crypt; - struct { - u32 flags_and; - u32 flags_or; - } set_flags_sta; - struct { - u16 rid; - u16 len; - u8 data[0]; - } rid; - struct { - u8 len; - u8 data[0]; - } generic_elem; - struct { - u16 cmd; - u16 reason_code; - } mlme; - struct { - u8 ssid_len; - u8 ssid[32]; - } scan_req; - } u; -} __packed; - #endif /* __IOCMD_H__ */ -- cgit v1.2.3 From 4fccf1d6b5314567afd7012f10f0588bbc87e6da Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 21 May 2014 21:09:40 +0100 Subject: staging: vt6656: iowpa.h removed dead code. Remove dead strutures Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/iowpa.h | 53 ------------------------------------------ 1 file changed, 53 deletions(-) diff --git a/drivers/staging/vt6656/iowpa.h b/drivers/staging/vt6656/iowpa.h index 97af32e1fa44..98f2b2195af4 100644 --- a/drivers/staging/vt6656/iowpa.h +++ b/drivers/staging/vt6656/iowpa.h @@ -31,43 +31,6 @@ #define WPA_IE_LEN 64 -//WPA related -/* -typedef enum { WPA_ALG_NONE, WPA_ALG_WEP, WPA_ALG_TKIP, WPA_ALG_CCMP } wpa_alg; -typedef enum { CIPHER_NONE, CIPHER_WEP40, CIPHER_TKIP, CIPHER_CCMP, - CIPHER_WEP104 } wpa_cipher; -typedef enum { KEY_MGMT_802_1X, KEY_MGMT_PSK, KEY_MGMT_NONE, - KEY_MGMT_802_1X_NO_WPA, KEY_MGMT_WPA_NONE } wpa_key_mgmt; -*/ - -enum { - VIAWGET_SET_WPA = 1, - VIAWGET_SET_KEY = 2, - VIAWGET_SET_SCAN = 3, - VIAWGET_GET_SCAN = 4, - VIAWGET_GET_SSID = 5, - VIAWGET_GET_BSSID = 6, - VIAWGET_SET_DROP_UNENCRYPT = 7, - VIAWGET_SET_DEAUTHENTICATE = 8, - VIAWGET_SET_ASSOCIATE = 9, - VIAWGET_SET_DISASSOCIATE = 10 -}; - -enum { - VIAWGET_ASSOC_MSG = 1, - VIAWGET_DISASSOC_MSG = 2, - VIAWGET_PTK_MIC_MSG = 3, - VIAWGET_GTK_MIC_MSG = 4, - VIAWGET_CCKM_ROAM_MSG = 5, - VIAWGET_DEVICECLOSE_MSG = 6 -}; - -typedef struct viawget_wpa_header { - u8 type; - u16 req_ie_len; - u16 resp_ie_len; -} __packed viawget_wpa_header; - struct viawget_wpa_param { u32 cmd; u8 addr[6]; @@ -109,20 +72,4 @@ struct viawget_wpa_param { } u; } __packed; -struct viawget_scan_result { - u8 bssid[6]; - u8 ssid[32]; - u16 ssid_len; - u8 wpa_ie[WPA_IE_LEN]; - u16 wpa_ie_len; - u8 rsn_ie[WPA_IE_LEN]; - u16 rsn_ie_len; - int freq; // MHz - int caps; // e.g. privacy - int qual; // signal quality - int noise; - int level; - int maxrate; -} __packed; - #endif /* __IOWPA_H__ */ -- cgit v1.2.3 From a06978bc6d3877783643d95fab45299871840a50 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 21 May 2014 21:09:41 +0100 Subject: staging: vt6656: ETHbIsBufferCrc32Ok replace CRCdwGetCrc32 CRCdwGetCrc32 is a bitwise not of ether_crc_le. Replace with ether_crc_le. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/tether.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vt6656/tether.c b/drivers/staging/vt6656/tether.c index 1db1e8419a9a..ada3e7e630c4 100644 --- a/drivers/staging/vt6656/tether.c +++ b/drivers/staging/vt6656/tether.c @@ -51,11 +51,11 @@ */ bool ETHbIsBufferCrc32Ok(u8 * pbyBuffer, unsigned int cbFrameLength) { - u32 dwCRC; + u32 n_crc = ~ether_crc_le(cbFrameLength - 4, pbyBuffer); - dwCRC = CRCdwGetCrc32(pbyBuffer, cbFrameLength - 4); - if (cpu_to_le32(*((u32 *)(pbyBuffer + cbFrameLength - 4))) != dwCRC) + if (le32_to_cpu(*((__le32 *)(pbyBuffer + cbFrameLength - 4))) != n_crc) return false; + return true; } -- cgit v1.2.3 From 929cb313fb4e40126180456746b83e31e4897090 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 21 May 2014 21:09:42 +0100 Subject: staging: vt6656: s_vSWencryption replace CRCdwGetCrc32Ex Replace with ether_crc_le which gives the same result. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 2b0ae062e43b..050967259b2e 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -304,7 +304,7 @@ static void s_vSWencryption(struct vnt_private *pDevice, if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { //======================================================================= // Append ICV after payload - dwICV = CRCdwGetCrc32Ex(pbyPayloadHead, wPayloadSize, dwICV);//ICV(Payload) + dwICV = ether_crc_le(wPayloadSize, pbyPayloadHead); pdwICV = (u32 *)(pbyPayloadHead + wPayloadSize); // finally, we must invert dwCRC to get the correct answer *pdwICV = cpu_to_le32(~dwICV); @@ -315,7 +315,7 @@ static void s_vSWencryption(struct vnt_private *pDevice, } else if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) { //======================================================================= //Append ICV after payload - dwICV = CRCdwGetCrc32Ex(pbyPayloadHead, wPayloadSize, dwICV);//ICV(Payload) + dwICV = ether_crc_le(wPayloadSize, pbyPayloadHead); pdwICV = (u32 *)(pbyPayloadHead + wPayloadSize); // finally, we must invert dwCRC to get the correct answer *pdwICV = cpu_to_le32(~dwICV); -- cgit v1.2.3 From 91e2f7f96124891e936b2f0c3daf62c97913cd05 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 21 May 2014 21:09:43 +0100 Subject: staging: vt6656: remove dead code tcrc.c/h Functions are now dead and of no use. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/Makefile | 1 - drivers/staging/vt6656/dpc.c | 1 - drivers/staging/vt6656/main_usb.c | 1 - drivers/staging/vt6656/rxtx.c | 1 - drivers/staging/vt6656/tcrc.c | 183 -------------------------------------- drivers/staging/vt6656/tcrc.h | 38 -------- drivers/staging/vt6656/tether.c | 1 - 7 files changed, 226 deletions(-) delete mode 100644 drivers/staging/vt6656/tcrc.c delete mode 100644 drivers/staging/vt6656/tcrc.h diff --git a/drivers/staging/vt6656/Makefile b/drivers/staging/vt6656/Makefile index 846db132f5d5..e39d2492f24f 100644 --- a/drivers/staging/vt6656/Makefile +++ b/drivers/staging/vt6656/Makefile @@ -18,7 +18,6 @@ vt6656_stage-y += main_usb.o \ datarate.o \ rc4.o \ tether.o \ - tcrc.o \ wpa.o \ key.o \ tkip.o \ diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c index c05a96f2a97a..2ad6c3e8a2de 100644 --- a/drivers/staging/vt6656/dpc.c +++ b/drivers/staging/vt6656/dpc.c @@ -45,7 +45,6 @@ #include "baseband.h" #include "michael.h" #include "tkip.h" -#include "tcrc.h" #include "wctl.h" #include "rf.h" #include "iowpa.h" diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 9f888d511d75..787261ec3a8f 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -57,7 +57,6 @@ #include "power.h" #include "wcmd.h" #include "iocmd.h" -#include "tcrc.h" #include "rxtx.h" #include "bssdb.h" #include "wpactl.h" diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 050967259b2e..ae80e18ccc0d 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -54,7 +54,6 @@ #include "mac.h" #include "michael.h" #include "tkip.h" -#include "tcrc.h" #include "wctl.h" #include "rf.h" #include "datarate.h" diff --git a/drivers/staging/vt6656/tcrc.c b/drivers/staging/vt6656/tcrc.c deleted file mode 100644 index 7229f26c052c..000000000000 --- a/drivers/staging/vt6656/tcrc.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (c) 2003 VIA Networking, Inc. All rights reserved. - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: tcrc.c - * - * Purpose: Implement functions to calculate CRC - * - * Author: Tevin Chen - * - * Date: May 21, 1996 - * - * Functions: - * CRCdwCrc32 - - * CRCdwGetCrc32 - - * CRCdwGetCrc32Ex - - * - * Revision History: - * - */ - -#include "tcrc.h" - -/* 32-bit CRC table */ -static const u32 s_adwCrc32Table[256] = { - 0x00000000L, 0x77073096L, 0xEE0E612CL, 0x990951BAL, - 0x076DC419L, 0x706AF48FL, 0xE963A535L, 0x9E6495A3L, - 0x0EDB8832L, 0x79DCB8A4L, 0xE0D5E91EL, 0x97D2D988L, - 0x09B64C2BL, 0x7EB17CBDL, 0xE7B82D07L, 0x90BF1D91L, - 0x1DB71064L, 0x6AB020F2L, 0xF3B97148L, 0x84BE41DEL, - 0x1ADAD47DL, 0x6DDDE4EBL, 0xF4D4B551L, 0x83D385C7L, - 0x136C9856L, 0x646BA8C0L, 0xFD62F97AL, 0x8A65C9ECL, - 0x14015C4FL, 0x63066CD9L, 0xFA0F3D63L, 0x8D080DF5L, - 0x3B6E20C8L, 0x4C69105EL, 0xD56041E4L, 0xA2677172L, - 0x3C03E4D1L, 0x4B04D447L, 0xD20D85FDL, 0xA50AB56BL, - 0x35B5A8FAL, 0x42B2986CL, 0xDBBBC9D6L, 0xACBCF940L, - 0x32D86CE3L, 0x45DF5C75L, 0xDCD60DCFL, 0xABD13D59L, - 0x26D930ACL, 0x51DE003AL, 0xC8D75180L, 0xBFD06116L, - 0x21B4F4B5L, 0x56B3C423L, 0xCFBA9599L, 0xB8BDA50FL, - 0x2802B89EL, 0x5F058808L, 0xC60CD9B2L, 0xB10BE924L, - 0x2F6F7C87L, 0x58684C11L, 0xC1611DABL, 0xB6662D3DL, - 0x76DC4190L, 0x01DB7106L, 0x98D220BCL, 0xEFD5102AL, - 0x71B18589L, 0x06B6B51FL, 0x9FBFE4A5L, 0xE8B8D433L, - 0x7807C9A2L, 0x0F00F934L, 0x9609A88EL, 0xE10E9818L, - 0x7F6A0DBBL, 0x086D3D2DL, 0x91646C97L, 0xE6635C01L, - 0x6B6B51F4L, 0x1C6C6162L, 0x856530D8L, 0xF262004EL, - 0x6C0695EDL, 0x1B01A57BL, 0x8208F4C1L, 0xF50FC457L, - 0x65B0D9C6L, 0x12B7E950L, 0x8BBEB8EAL, 0xFCB9887CL, - 0x62DD1DDFL, 0x15DA2D49L, 0x8CD37CF3L, 0xFBD44C65L, - 0x4DB26158L, 0x3AB551CEL, 0xA3BC0074L, 0xD4BB30E2L, - 0x4ADFA541L, 0x3DD895D7L, 0xA4D1C46DL, 0xD3D6F4FBL, - 0x4369E96AL, 0x346ED9FCL, 0xAD678846L, 0xDA60B8D0L, - 0x44042D73L, 0x33031DE5L, 0xAA0A4C5FL, 0xDD0D7CC9L, - 0x5005713CL, 0x270241AAL, 0xBE0B1010L, 0xC90C2086L, - 0x5768B525L, 0x206F85B3L, 0xB966D409L, 0xCE61E49FL, - 0x5EDEF90EL, 0x29D9C998L, 0xB0D09822L, 0xC7D7A8B4L, - 0x59B33D17L, 0x2EB40D81L, 0xB7BD5C3BL, 0xC0BA6CADL, - 0xEDB88320L, 0x9ABFB3B6L, 0x03B6E20CL, 0x74B1D29AL, - 0xEAD54739L, 0x9DD277AFL, 0x04DB2615L, 0x73DC1683L, - 0xE3630B12L, 0x94643B84L, 0x0D6D6A3EL, 0x7A6A5AA8L, - 0xE40ECF0BL, 0x9309FF9DL, 0x0A00AE27L, 0x7D079EB1L, - 0xF00F9344L, 0x8708A3D2L, 0x1E01F268L, 0x6906C2FEL, - 0xF762575DL, 0x806567CBL, 0x196C3671L, 0x6E6B06E7L, - 0xFED41B76L, 0x89D32BE0L, 0x10DA7A5AL, 0x67DD4ACCL, - 0xF9B9DF6FL, 0x8EBEEFF9L, 0x17B7BE43L, 0x60B08ED5L, - 0xD6D6A3E8L, 0xA1D1937EL, 0x38D8C2C4L, 0x4FDFF252L, - 0xD1BB67F1L, 0xA6BC5767L, 0x3FB506DDL, 0x48B2364BL, - 0xD80D2BDAL, 0xAF0A1B4CL, 0x36034AF6L, 0x41047A60L, - 0xDF60EFC3L, 0xA867DF55L, 0x316E8EEFL, 0x4669BE79L, - 0xCB61B38CL, 0xBC66831AL, 0x256FD2A0L, 0x5268E236L, - 0xCC0C7795L, 0xBB0B4703L, 0x220216B9L, 0x5505262FL, - 0xC5BA3BBEL, 0xB2BD0B28L, 0x2BB45A92L, 0x5CB36A04L, - 0xC2D7FFA7L, 0xB5D0CF31L, 0x2CD99E8BL, 0x5BDEAE1DL, - 0x9B64C2B0L, 0xEC63F226L, 0x756AA39CL, 0x026D930AL, - 0x9C0906A9L, 0xEB0E363FL, 0x72076785L, 0x05005713L, - 0x95BF4A82L, 0xE2B87A14L, 0x7BB12BAEL, 0x0CB61B38L, - 0x92D28E9BL, 0xE5D5BE0DL, 0x7CDCEFB7L, 0x0BDBDF21L, - 0x86D3D2D4L, 0xF1D4E242L, 0x68DDB3F8L, 0x1FDA836EL, - 0x81BE16CDL, 0xF6B9265BL, 0x6FB077E1L, 0x18B74777L, - 0x88085AE6L, 0xFF0F6A70L, 0x66063BCAL, 0x11010B5CL, - 0x8F659EFFL, 0xF862AE69L, 0x616BFFD3L, 0x166CCF45L, - 0xA00AE278L, 0xD70DD2EEL, 0x4E048354L, 0x3903B3C2L, - 0xA7672661L, 0xD06016F7L, 0x4969474DL, 0x3E6E77DBL, - 0xAED16A4AL, 0xD9D65ADCL, 0x40DF0B66L, 0x37D83BF0L, - 0xA9BCAE53L, 0xDEBB9EC5L, 0x47B2CF7FL, 0x30B5FFE9L, - 0xBDBDF21CL, 0xCABAC28AL, 0x53B39330L, 0x24B4A3A6L, - 0xBAD03605L, 0xCDD70693L, 0x54DE5729L, 0x23D967BFL, - 0xB3667A2EL, 0xC4614AB8L, 0x5D681B02L, 0x2A6F2B94L, - 0xB40BBE37L, 0xC30C8EA1L, 0x5A05DF1BL, 0x2D02EF8DL -}; - -/*+ - * - * Description: - * Generate a CRC-32 from the data stream - * - * Parameters: - * In: - * pbyData - the data stream - * cbByte - the length of the stream - * dwCrcSeed - Seed for CRC32 - * Out: - * none - * - * Return Value: CRC-32 - * --*/ -u32 CRCdwCrc32(u8 * pbyData, unsigned int cbByte, u32 dwCrcSeed) -{ - u32 dwCrc; - - dwCrc = dwCrcSeed; - while (cbByte--) { - dwCrc = s_adwCrc32Table[(u8)((dwCrc ^ (*pbyData)) & 0xFF)] ^ - (dwCrc >> 8); - pbyData++; - } - - return dwCrc; -} - -/*+ - * - * Description: - * To test CRC generator, input 8 bytes packet - * -- 0xff 0xff 0xff 0xff 0x00 0x00 0x00 0x00 - * the generated CRC should be - * -- 0xff 0xff 0xff 0xff - * - * Parameters: - * In: - * pbyData - the data stream - * cbByte - the length of the stream - * Out: - * none - * - * Return Value: CRC-32 - * --*/ -u32 CRCdwGetCrc32(u8 * pbyData, unsigned int cbByte) -{ - return ~CRCdwCrc32(pbyData, cbByte, 0xFFFFFFFFL); -} - -/*+ - * - * Description: - * - * NOTE.... Because CRCdwGetCrc32Ex() is an iteration function, - * this means we will use the output of CRCdwGetCrc32Ex() - * to be a new argument to do next CRCdwGetCrc32Ex() calculation. - * Thus, the final result must be inverted to be the - * correct answer. - * - * Parameters: - * In: - * pbyData - the data stream - * cbByte - the length of the stream - * Out: - * none - * - * Return Value: CRC-32 - * --*/ -u32 CRCdwGetCrc32Ex(u8 * pbyData, unsigned int cbByte, u32 dwPreCRC) -{ - return CRCdwCrc32(pbyData, cbByte, dwPreCRC); -} - diff --git a/drivers/staging/vt6656/tcrc.h b/drivers/staging/vt6656/tcrc.h deleted file mode 100644 index 5b1f368964eb..000000000000 --- a/drivers/staging/vt6656/tcrc.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2003 VIA Networking, Inc. All rights reserved. - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: tcrc.h - * - * Purpose: Implement functions to calculate CRC - * - * Author: Tevin Chen - * - * Date: Jan. 28, 1997 - * - */ - -#ifndef __TCRC_H__ -#define __TCRC_H__ - -#include - -u32 CRCdwCrc32(u8 * pbyData, unsigned int cbByte, u32 dwCrcSeed); -u32 CRCdwGetCrc32(u8 * pbyData, unsigned int cbByte); -u32 CRCdwGetCrc32Ex(u8 * pbyData, unsigned int cbByte, u32 dwPreCRC); - -#endif /* __TCRC_H__ */ diff --git a/drivers/staging/vt6656/tether.c b/drivers/staging/vt6656/tether.c index ada3e7e630c4..2ef54f608cbc 100644 --- a/drivers/staging/vt6656/tether.c +++ b/drivers/staging/vt6656/tether.c @@ -33,7 +33,6 @@ #include "device.h" #include "tmacro.h" -#include "tcrc.h" #include "tether.h" /* -- cgit v1.2.3 From 0e7935aba0db775ef32c861245fea041dda536d8 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 21 May 2014 21:09:44 +0100 Subject: staging: vt6656: dead code remove diversity code bDiversityRegCtlON is always false. In later vendor driver code has been commented out. Remove diversity timers and variables. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 282 -------------------------------------- drivers/staging/vt6656/baseband.h | 7 - drivers/staging/vt6656/device.h | 24 ---- drivers/staging/vt6656/dpc.c | 7 - drivers/staging/vt6656/main_usb.c | 45 ------ 5 files changed, 365 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index 88682c07479a..3a06bf49e7a3 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -635,20 +635,6 @@ static u8 abyVT3184_VT3226D0[] = { static const u16 awcFrameTime[MAX_RATE] = {10, 20, 55, 110, 24, 36, 48, 72, 96, 144, 192, 216}; -/* -static -unsigned long -s_ulGetLowSQ3(PSDevice pDevice); - -static -unsigned long -s_ulGetRatio(PSDevice pDevice); - -static -void -s_vClearSQ3Value(PSDevice pDevice); -*/ - /* * Description: Calculate data frame transmitting time * @@ -1140,274 +1126,6 @@ void BBvExitDeepSleep(struct vnt_private *priv) ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0x01);/* CR13 */ } -static unsigned long s_ulGetLowSQ3(struct vnt_private *pDevice) -{ - int ii; - unsigned long ulSQ3 = 0; - unsigned long ulMaxPacket; - - ulMaxPacket = pDevice->aulPktNum[RATE_54M]; - if (pDevice->aulPktNum[RATE_54M] != 0) - ulSQ3 = pDevice->aulSQ3Val[RATE_54M] / pDevice->aulPktNum[RATE_54M]; - - for (ii = RATE_48M; ii >= RATE_6M; ii--) - if (pDevice->aulPktNum[ii] > ulMaxPacket) { - ulMaxPacket = pDevice->aulPktNum[ii]; - ulSQ3 = pDevice->aulSQ3Val[ii] / pDevice->aulPktNum[ii]; - } - - return ulSQ3; -} - -static unsigned long s_ulGetRatio(struct vnt_private *pDevice) -{ - int ii, jj; - unsigned long ulRatio = 0; - unsigned long ulMaxPacket; - unsigned long ulPacketNum; - - //This is a thousand-ratio - ulMaxPacket = pDevice->aulPktNum[RATE_54M]; - if ( pDevice->aulPktNum[RATE_54M] != 0 ) { - ulPacketNum = pDevice->aulPktNum[RATE_54M]; - ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); - ulRatio += TOP_RATE_54M; - } - for (ii = RATE_48M; ii >= RATE_1M; ii--) - if ( pDevice->aulPktNum[ii] > ulMaxPacket ) { - ulPacketNum = 0; - for ( jj=RATE_54M;jj>=ii;jj--) - ulPacketNum += pDevice->aulPktNum[jj]; - ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); - ulRatio += TOP_RATE_48M; - ulMaxPacket = pDevice->aulPktNum[ii]; - } - - return ulRatio; -} - -static void s_vClearSQ3Value(struct vnt_private *pDevice) -{ - int ii; - pDevice->uDiversityCnt = 0; - - for ( ii=RATE_1M;iiaulPktNum[ii] = 0; - pDevice->aulSQ3Val[ii] = 0; - } -} - -/* - * Description: Antenna Diversity - * - * Parameters: - * In: - * pDevice - Device Structure - * byRSR - RSR from received packet - * bySQ3 - SQ3 value from received packet - * Out: - * none - * - * Return Value: none - * - */ - -void BBvAntennaDiversity(struct vnt_private *pDevice, - u8 byRxRate, u8 bySQ3) -{ - - pDevice->uDiversityCnt++; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pDevice->uDiversityCnt = %d\n", (int)pDevice->uDiversityCnt); - - if (byRxRate == 2) { - pDevice->aulPktNum[RATE_1M]++; - } - else if (byRxRate==4) { - pDevice->aulPktNum[RATE_2M]++; - } - else if (byRxRate==11) { - pDevice->aulPktNum[RATE_5M]++; - } - else if (byRxRate==22) { - pDevice->aulPktNum[RATE_11M]++; - } - else if(byRxRate==12){ - pDevice->aulPktNum[RATE_6M]++; - pDevice->aulSQ3Val[RATE_6M] += bySQ3; - } - else if(byRxRate==18){ - pDevice->aulPktNum[RATE_9M]++; - pDevice->aulSQ3Val[RATE_9M] += bySQ3; - } - else if(byRxRate==24){ - pDevice->aulPktNum[RATE_12M]++; - pDevice->aulSQ3Val[RATE_12M] += bySQ3; - } - else if(byRxRate==36){ - pDevice->aulPktNum[RATE_18M]++; - pDevice->aulSQ3Val[RATE_18M] += bySQ3; - } - else if(byRxRate==48){ - pDevice->aulPktNum[RATE_24M]++; - pDevice->aulSQ3Val[RATE_24M] += bySQ3; - } - else if(byRxRate==72){ - pDevice->aulPktNum[RATE_36M]++; - pDevice->aulSQ3Val[RATE_36M] += bySQ3; - } - else if(byRxRate==96){ - pDevice->aulPktNum[RATE_48M]++; - pDevice->aulSQ3Val[RATE_48M] += bySQ3; - } - else if(byRxRate==108){ - pDevice->aulPktNum[RATE_54M]++; - pDevice->aulSQ3Val[RATE_54M] += bySQ3; - } - - if (pDevice->byAntennaState == 0) { - - if (pDevice->uDiversityCnt > pDevice->ulDiversityNValue) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ulDiversityNValue=[%d],54M-[%d]\n",(int)pDevice->ulDiversityNValue, (int)pDevice->aulPktNum[RATE_54M]); - - pDevice->ulSQ3_State0 = s_ulGetLowSQ3(pDevice); - pDevice->ulRatio_State0 = s_ulGetRatio(pDevice); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State0, SQ3= [%08x] rate = [%08x]\n",(int)pDevice->ulSQ3_State0,(int)pDevice->ulRatio_State0); - - if ( ((pDevice->aulPktNum[RATE_54M] < pDevice->ulDiversityNValue/2) && - (pDevice->ulSQ3_State0 > pDevice->ulSQ3TH) ) || - (pDevice->ulSQ3_State0 == 0 ) ) { - - if ( pDevice->byTMax == 0 ) - return; - - bScheduleCommand((void *) pDevice, - WLAN_CMD_CHANGE_ANTENNA, - NULL); - - pDevice->byAntennaState = 1; - - del_timer(&pDevice->TimerSQ3Tmax3); - del_timer(&pDevice->TimerSQ3Tmax2); - pDevice->TimerSQ3Tmax1.expires = RUN_AT(pDevice->byTMax * HZ); - add_timer(&pDevice->TimerSQ3Tmax1); - - } else { - pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ); - add_timer(&pDevice->TimerSQ3Tmax3); - } - s_vClearSQ3Value(pDevice); - - } - } else { //byAntennaState == 1 - - if (pDevice->uDiversityCnt > pDevice->ulDiversityMValue) { - - del_timer(&pDevice->TimerSQ3Tmax1); - pDevice->ulSQ3_State1 = s_ulGetLowSQ3(pDevice); - pDevice->ulRatio_State1 = s_ulGetRatio(pDevice); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State1, rate0 = %08x,rate1 = %08x\n",(int)pDevice->ulRatio_State0,(int)pDevice->ulRatio_State1); - - if ( ((pDevice->ulSQ3_State1 == 0) && (pDevice->ulSQ3_State0 != 0)) || - ((pDevice->ulSQ3_State1 == 0) && (pDevice->ulSQ3_State0 == 0) && (pDevice->ulRatio_State1 < pDevice->ulRatio_State0)) || - ((pDevice->ulSQ3_State1 != 0) && (pDevice->ulSQ3_State0 != 0) && (pDevice->ulSQ3_State0 < pDevice->ulSQ3_State1)) - ) { - - bScheduleCommand((void *) pDevice, - WLAN_CMD_CHANGE_ANTENNA, - NULL); - - pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ); - pDevice->TimerSQ3Tmax2.expires = RUN_AT(pDevice->byTMax2 * HZ); - add_timer(&pDevice->TimerSQ3Tmax3); - add_timer(&pDevice->TimerSQ3Tmax2); - - } - pDevice->byAntennaState = 0; - s_vClearSQ3Value(pDevice); - } - } //byAntennaState -} - -/*+ - * - * Description: - * Timer for SQ3 antenna diversity - * - * Parameters: - * In: - * pvSysSpec1 - * hDeviceContext - Pointer to the adapter - * pvSysSpec2 - * pvSysSpec3 - * Out: - * none - * - * Return Value: none - * --*/ - -void TimerSQ3CallBack(struct vnt_private *pDevice) -{ - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TimerSQ3CallBack..."); - spin_lock_irq(&pDevice->lock); - - bScheduleCommand((void *) pDevice, WLAN_CMD_CHANGE_ANTENNA, NULL); - pDevice->byAntennaState = 0; - s_vClearSQ3Value(pDevice); - pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ); - pDevice->TimerSQ3Tmax2.expires = RUN_AT(pDevice->byTMax2 * HZ); - add_timer(&pDevice->TimerSQ3Tmax3); - add_timer(&pDevice->TimerSQ3Tmax2); - - spin_unlock_irq(&pDevice->lock); -} - -/*+ - * - * Description: - * Timer for SQ3 antenna diversity - * - * Parameters: - * In: - * pvSysSpec1 - * hDeviceContext - Pointer to the adapter - * pvSysSpec2 - * pvSysSpec3 - * Out: - * none - * - * Return Value: none - * --*/ - -void TimerSQ3Tmax3CallBack(struct vnt_private *pDevice) -{ - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TimerSQ3Tmax3CallBack..."); - spin_lock_irq(&pDevice->lock); - - pDevice->ulRatio_State0 = s_ulGetRatio(pDevice); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State0 = [%08x]\n",(int)pDevice->ulRatio_State0); - - s_vClearSQ3Value(pDevice); - if ( pDevice->byTMax == 0 ) { - pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ); - add_timer(&pDevice->TimerSQ3Tmax3); - spin_unlock_irq(&pDevice->lock); - return; - } - - bScheduleCommand((void *) pDevice, WLAN_CMD_CHANGE_ANTENNA, NULL); - pDevice->byAntennaState = 1; - del_timer(&pDevice->TimerSQ3Tmax3); - del_timer(&pDevice->TimerSQ3Tmax2); - pDevice->TimerSQ3Tmax1.expires = RUN_AT(pDevice->byTMax * HZ); - add_timer(&pDevice->TimerSQ3Tmax1); - - spin_unlock_irq(&pDevice->lock); -} - void BBvUpdatePreEDThreshold(struct vnt_private *priv, int scanning) { u8 cr_201 = 0x0, cr_206 = 0x0; diff --git a/drivers/staging/vt6656/baseband.h b/drivers/staging/vt6656/baseband.h index eda0d8aa6c74..3044d6c42050 100644 --- a/drivers/staging/vt6656/baseband.h +++ b/drivers/staging/vt6656/baseband.h @@ -94,13 +94,6 @@ unsigned int BBuGetFrameTime(u8 preamble_type, u8 pkt_type, void BBvCalculateParameter(struct vnt_private *, u32 frame_length, u16 tx_rate, u8 pkt_type, struct vnt_phy_field *); -/* timer for antenna diversity */ - -void TimerSQ3CallBack(struct vnt_private *); -void TimerSQ3Tmax3CallBack(struct vnt_private *); - -void BBvAntennaDiversity(struct vnt_private *, u8 byRxRate, u8 bySQ3); - void BBvSetShortSlotTime(struct vnt_private *); void BBvSetVGAGainOffset(struct vnt_private *, u8 byData); void BBvSetAntennaMode(struct vnt_private *, u8 byAntennaMode); diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index d55f81c8ec61..e5f84f5b377d 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -492,30 +492,6 @@ struct vnt_private { u8 byRadioCtl; u8 bHWRadioOff; - /* SQ3 functions for antenna diversity */ - struct timer_list TimerSQ3Tmax1; - struct timer_list TimerSQ3Tmax2; - struct timer_list TimerSQ3Tmax3; - - int bDiversityRegCtlON; - int bDiversityEnable; - unsigned long ulDiversityNValue; - unsigned long ulDiversityMValue; - u8 byTMax; - u8 byTMax2; - u8 byTMax3; - unsigned long ulSQ3TH; - - unsigned long uDiversityCnt; - u8 byAntennaState; - unsigned long ulRatio_State0; - unsigned long ulRatio_State1; - unsigned long ulSQ3_State0; - unsigned long ulSQ3_State1; - - unsigned long aulSQ3Val[MAX_RATE]; - unsigned long aulPktNum[MAX_RATE]; - /* IFS & Cw */ u32 uSIFS; /* Current SIFS */ u32 uDIFS; /* Current DIFS */ diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c index 2ad6c3e8a2de..286e7352ce1d 100644 --- a/drivers/staging/vt6656/dpc.c +++ b/drivers/staging/vt6656/dpc.c @@ -556,13 +556,6 @@ int RXbBulkInProcessData(struct vnt_private *pDevice, struct vnt_rcb *pRCB, } } - // Now it only supports 802.11g Infrastructure Mode, and support rate must up to 54 Mbps - if (pDevice->bDiversityEnable && (FrameSize>50) && - pDevice->op_mode == NL80211_IFTYPE_STATION && - (pDevice->bLinkPass == true)) { - BBvAntennaDiversity(pDevice, s_byGetRateIdx(*pbyRxRate), 0); - } - // ++++++++ For BaseBand Algorithm +++++++++++++++ pDevice->uCurrRSSI = *pbyRSSI; pDevice->byCurrSQ = *pbySQ; diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 787261ec3a8f..09e444d8aceb 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -214,7 +214,6 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); static int device_init_registers(struct vnt_private *pDevice); static bool device_init_defrag_cb(struct vnt_private *pDevice); -static void device_init_diversity_timer(struct vnt_private *pDevice); static int ethtool_ioctl(struct net_device *dev, struct ifreq *); static void device_free_tx_bufs(struct vnt_private *pDevice); @@ -261,28 +260,6 @@ device_set_options(struct vnt_private *pDevice) { pDevice->byAutoFBCtrl = AUTO_FB_0; pDevice->byPreambleType = 0; pDevice->bExistSWNetAddr = false; - /* pDevice->bDiversityRegCtlON = true; */ - pDevice->bDiversityRegCtlON = false; -} - -static void device_init_diversity_timer(struct vnt_private *pDevice) -{ - init_timer(&pDevice->TimerSQ3Tmax1); - pDevice->TimerSQ3Tmax1.data = (unsigned long)pDevice; - pDevice->TimerSQ3Tmax1.function = (TimerFunction)TimerSQ3CallBack; - pDevice->TimerSQ3Tmax1.expires = RUN_AT(HZ); - - init_timer(&pDevice->TimerSQ3Tmax2); - pDevice->TimerSQ3Tmax2.data = (unsigned long)pDevice; - pDevice->TimerSQ3Tmax2.function = (TimerFunction)TimerSQ3CallBack; - pDevice->TimerSQ3Tmax2.expires = RUN_AT(HZ); - - init_timer(&pDevice->TimerSQ3Tmax3); - pDevice->TimerSQ3Tmax3.data = (unsigned long)pDevice; - pDevice->TimerSQ3Tmax3.function = (TimerFunction)TimerSQ3Tmax3CallBack; - pDevice->TimerSQ3Tmax3.expires = RUN_AT(HZ); - - return; } /* @@ -444,13 +421,7 @@ static int device_init_registers(struct vnt_private *pDevice) pDevice->byRxAntennaMode = ANT_A; else pDevice->byRxAntennaMode = ANT_B; - - if (pDevice->bDiversityRegCtlON) - pDevice->bDiversityEnable = true; - else - pDevice->bDiversityEnable = false; } else { - pDevice->bDiversityEnable = false; pDevice->byAntennaCount = 1; pDevice->dwTxAntennaSel = 0; pDevice->dwRxAntennaSel = 0; @@ -472,13 +443,6 @@ static int device_init_registers(struct vnt_private *pDevice) } } - pDevice->ulDiversityNValue = 100 * 255; - pDevice->ulDiversityMValue = 100 * 16; - pDevice->byTMax = 1; - pDevice->byTMax2 = 4; - pDevice->ulSQ3TH = 0; - pDevice->byTMax3 = 64; - /* get Auto Fall Back type */ pDevice->byAutoFBCtrl = AUTO_FB_0; @@ -957,9 +921,6 @@ static int device_open(struct net_device *dev) pDevice->bRoaming = false; pDevice->bIsRoaming = false; pDevice->bEnableRoaming = false; - if (pDevice->bDiversityRegCtlON) { - device_init_diversity_timer(pDevice); - } vMgrObjectInit(pDevice); @@ -1053,12 +1014,6 @@ static int device_close(struct net_device *dev) cancel_delayed_work_sync(&pDevice->run_command_work); cancel_delayed_work_sync(&pDevice->second_callback_work); - if (pDevice->bDiversityRegCtlON) { - del_timer(&pDevice->TimerSQ3Tmax1); - del_timer(&pDevice->TimerSQ3Tmax2); - del_timer(&pDevice->TimerSQ3Tmax3); - } - cancel_work_sync(&pDevice->rx_mng_work_item); cancel_work_sync(&pDevice->read_work_item); -- cgit v1.2.3 From c804f5920c4929f86c0d5bbf48d7ce0b05e8ea08 Mon Sep 17 00:00:00 2001 From: Peter Senna Tschudin Date: Tue, 20 May 2014 12:33:48 +0200 Subject: staging: vt6655: Remove useless return variables This patch remove variables that are initialized with a constant, are never updated, and are only used as parameter of return. Return the constant instead of using a variable. Verified by compilation only. The coccinelle script that find and fixes this issue is: // @@ type T; constant C; identifier ret; @@ - T ret = C; ... when != ret - return ret; + return C; // Signed-off-by: Peter Senna Tschudin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/hostap.c | 10 ++++------ drivers/staging/vt6655/wpactl.c | 19 ++++++------------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c index f55d0fbd842a..317c2a8ee162 100644 --- a/drivers/staging/vt6655/hostap.c +++ b/drivers/staging/vt6655/hostap.c @@ -421,7 +421,6 @@ static int hostap_set_encryption(PSDevice pDevice, unsigned char abySeq[MAX_KEY_LEN]; unsigned long long KeyRSC; unsigned char byKeyDecMode = KEY_CTL_WEP; - int ret = 0; int iNodeIndex = -1; int ii; bool bKeyTableFull = false; @@ -475,7 +474,7 @@ static int hostap_set_encryption(PSDevice pDevice, MAX_KEY_LEN ); - return ret; + return 0; } memcpy(abyKey, param->u.crypt.key, param->u.crypt.key_len); @@ -531,7 +530,7 @@ static int hostap_set_encryption(PSDevice pDevice, pMgmt->byCSSGK = KEY_CTL_WEP; pMgmt->sNodeDBTable[iNodeIndex].byCipherSuite = KEY_CTL_WEP; pMgmt->sNodeDBTable[iNodeIndex].dwKeyIndex = dwKeyIndex; - return ret; + return 0; } if (param->u.crypt.seq) { @@ -622,7 +621,7 @@ static int hostap_set_encryption(PSDevice pDevice, pMgmt->sNodeDBTable[iNodeIndex].dwTSC47_16 = 0; pMgmt->sNodeDBTable[iNodeIndex].wTSC15_0 = 0; - return ret; + return 0; } /* @@ -643,7 +642,6 @@ static int hostap_get_encryption(PSDevice pDevice, int param_len) { PSMgmtObject pMgmt = pDevice->pMgmt; - int ret = 0; int ii; int iNodeIndex = 0; @@ -663,7 +661,7 @@ static int hostap_get_encryption(PSDevice pDevice, for (ii = 0; ii < 8; ii++) param->u.crypt.seq[ii] = (unsigned char)pMgmt->sNodeDBTable[iNodeIndex].KeyRSC >> (ii * 8); - return ret; + return 0; } /* diff --git a/drivers/staging/vt6655/wpactl.c b/drivers/staging/vt6655/wpactl.c index 089e8a7bcfbf..8392d4d1d5ed 100644 --- a/drivers/staging/vt6655/wpactl.c +++ b/drivers/staging/vt6655/wpactl.c @@ -411,12 +411,11 @@ static int wpa_set_wpa(PSDevice pDevice, struct viawget_wpa_param *param) { PSMgmtObject pMgmt = pDevice->pMgmt; - int ret = 0; pMgmt->eAuthenMode = WMAC_AUTH_OPEN; pMgmt->bShareKeyAlgorithm = false; - return ret; + return 0; } /* @@ -437,7 +436,6 @@ static int wpa_set_disassociate(PSDevice pDevice, struct viawget_wpa_param *param) { PSMgmtObject pMgmt = pDevice->pMgmt; - int ret = 0; spin_lock_irq(&pDevice->lock); if (pDevice->bLinkPass) { @@ -446,7 +444,7 @@ static int wpa_set_disassociate(PSDevice pDevice, } spin_unlock_irq(&pDevice->lock); - return ret; + return 0; } /* @@ -466,14 +464,12 @@ static int wpa_set_disassociate(PSDevice pDevice, static int wpa_set_scan(PSDevice pDevice, struct viawget_wpa_param *param) { - int ret = 0; - spin_lock_irq(&pDevice->lock); BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass); bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, NULL); spin_unlock_irq(&pDevice->lock); - return ret; + return 0; } /* @@ -494,11 +490,10 @@ static int wpa_get_bssid(PSDevice pDevice, struct viawget_wpa_param *param) { PSMgmtObject pMgmt = pDevice->pMgmt; - int ret = 0; memcpy(param->u.wpa_associate.bssid, pMgmt->abyCurrBSSID , 6); - return ret; + return 0; } /* @@ -520,14 +515,13 @@ static int wpa_get_ssid(PSDevice pDevice, { PSMgmtObject pMgmt = pDevice->pMgmt; PWLAN_IE_SSID pItemSSID; - int ret = 0; pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; memcpy(param->u.wpa_associate.ssid, pItemSSID->abySSID , pItemSSID->len); param->u.wpa_associate.ssid_len = pItemSSID->len; - return ret; + return 0; } /* @@ -668,7 +662,6 @@ static int wpa_set_associate(PSDevice pDevice, PWLAN_IE_SSID pItemSSID; unsigned char abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; unsigned char abyWPAIE[64]; - int ret = 0; bool bWepEnabled = false; // set key type & algorithm @@ -788,7 +781,7 @@ static int wpa_set_associate(PSDevice pDevice, bScheduleCommand((void *)pDevice, WLAN_CMD_SSID, NULL); spin_unlock_irq(&pDevice->lock); - return ret; + return 0; } /* -- cgit v1.2.3 From 539b4f72d0da83e4d20df7cfc27dc49c00316940 Mon Sep 17 00:00:00 2001 From: Benoit Taine Date: Fri, 16 May 2014 14:22:41 +0200 Subject: staging/rtl8192u: Put EXPORT_SYMBOL just after the exported function Export of symbols statement must be placed right after the definition to meet kernel coding style guidelines. This issue was reported by checkpatch. A simplified version of the semantic patch that makes this change is as follows (http://coccinelle.lip6.fr/): // @ r @ identifier f; @@ - EXPORT_SYMBOL(f); @@ identifier r.f; @@ f(...) { ... } + EXPORT_SYMBOL(f); // Signed-off-by: Benoit Taine Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 3 +- .../staging/rtl8192u/ieee80211/ieee80211_softmac.c | 52 +++++++++------------- .../rtl8192u/ieee80211/ieee80211_softmac_wx.c | 42 ++++++++--------- drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c | 3 +- drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c | 19 ++++---- .../staging/rtl8192u/ieee80211/rtl819x_HTProc.c | 3 +- 6 files changed, 52 insertions(+), 70 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index a98414a72bf5..92707fbdaa44 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -1387,6 +1387,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, * hardware as a DMA target */ return 0; } +EXPORT_SYMBOL(ieee80211_rx); #define MGMT_FRAME_FIXED_PART_LENGTH 0x24 @@ -2643,6 +2644,4 @@ void ieee80211_rx_mgt(struct ieee80211_device *ieee, } } - EXPORT_SYMBOL(ieee80211_rx_mgt); -EXPORT_SYMBOL(ieee80211_rx); diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 9caf6fdb8eed..f36683be8d79 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -28,11 +28,13 @@ short ieee80211_is_54g(const struct ieee80211_network *net) { return (net->rates_ex_len > 0) || (net->rates_len > 4); } +EXPORT_SYMBOL(ieee80211_is_54g); short ieee80211_is_shortslot(const struct ieee80211_network *net) { return net->capability & WLAN_CAPABILITY_SHORT_SLOT; } +EXPORT_SYMBOL(ieee80211_is_shortslot); /* returns the total length needed for pleacing the RATE MFIE * tag and the EXTENDED RATE MFIE tag if needed. @@ -415,6 +417,7 @@ void ieee80211_send_probe_requests(struct ieee80211_device *ieee) ieee80211_send_probe(ieee); } } +EXPORT_SYMBOL(ieee80211_send_probe_requests); /* this performs syncro scan blocking the caller until all channels * in the allowed channel map has been checked. @@ -485,7 +488,7 @@ out: up(&ieee->scan_sem); } } - +EXPORT_SYMBOL(ieee80211_softmac_scan_syncro); static void ieee80211_softmac_scan_wq(struct work_struct *work) { @@ -563,7 +566,7 @@ void ieee80211_stop_send_beacons(struct ieee80211_device *ieee) if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS) ieee80211_beacons_stop(ieee); } - +EXPORT_SYMBOL(ieee80211_stop_send_beacons); void ieee80211_start_send_beacons(struct ieee80211_device *ieee) { @@ -572,7 +575,7 @@ void ieee80211_start_send_beacons(struct ieee80211_device *ieee) if(ieee->softmac_features & IEEE_SOFTMAC_BEACONS) ieee80211_beacons_start(ieee); } - +EXPORT_SYMBOL(ieee80211_start_send_beacons); static void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee) { @@ -600,6 +603,7 @@ void ieee80211_stop_scan(struct ieee80211_device *ieee) else ieee->stop_scan(ieee->dev); } +EXPORT_SYMBOL(ieee80211_stop_scan); /* called with ieee->lock held */ static void ieee80211_start_scan(struct ieee80211_device *ieee) @@ -638,6 +642,7 @@ void ieee80211_start_scan_syncro(struct ieee80211_device *ieee) ieee->scan_syncro(ieee->dev); } +EXPORT_SYMBOL(ieee80211_start_scan_syncro); inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *beacon, struct ieee80211_device *ieee, int challengelen) @@ -1709,8 +1714,6 @@ ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb) //FIXME } - - static void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr) { @@ -1721,7 +1724,7 @@ static void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, softmac_ps_mgmt_xmit(buf, ieee); } - +/* EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame); */ static short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) @@ -1889,6 +1892,8 @@ void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success) } spin_unlock_irqrestore(&ieee->lock, flags); } +EXPORT_SYMBOL(ieee80211_ps_tx_ack); + static void ieee80211_process_action(struct ieee80211_device *ieee, struct sk_buff *skb) { @@ -2188,6 +2193,7 @@ void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device * spin_unlock_irqrestore(&ieee->lock,flags); } +EXPORT_SYMBOL(ieee80211_softmac_xmit); /* called with ieee->lock acquired */ static void ieee80211_resume_tx(struct ieee80211_device *ieee) @@ -2229,6 +2235,7 @@ void ieee80211_reset_queue(struct ieee80211_device *ieee) spin_unlock_irqrestore(&ieee->lock,flags); } +EXPORT_SYMBOL(ieee80211_reset_queue); void ieee80211_wake_queue(struct ieee80211_device *ieee) { @@ -2269,7 +2276,7 @@ void ieee80211_wake_queue(struct ieee80211_device *ieee) exit : spin_unlock_irqrestore(&ieee->lock,flags); } - +EXPORT_SYMBOL(ieee80211_wake_queue); void ieee80211_stop_queue(struct ieee80211_device *ieee) { @@ -2284,7 +2291,7 @@ void ieee80211_stop_queue(struct ieee80211_device *ieee) //spin_unlock_irqrestore(&ieee->lock,flags); } - +EXPORT_SYMBOL(ieee80211_stop_queue); inline void ieee80211_randomize_cell(struct ieee80211_device *ieee) { @@ -2502,6 +2509,8 @@ void ieee80211_disassociate(struct ieee80211_device *ieee) notify_wx_assoc_event(ieee); } +EXPORT_SYMBOL(ieee80211_disassociate); + static void ieee80211_associate_retry_wq(struct work_struct *work) { struct delayed_work *dwork = container_of(work, struct delayed_work, work); @@ -2581,6 +2590,7 @@ struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee) return skb; } +EXPORT_SYMBOL(ieee80211_get_beacon); void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee) { @@ -2589,7 +2599,7 @@ void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee) ieee80211_stop_protocol(ieee); up(&ieee->wx_sem); } - +EXPORT_SYMBOL(ieee80211_softmac_stop_protocol); void ieee80211_stop_protocol(struct ieee80211_device *ieee) { @@ -2615,6 +2625,7 @@ void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee) ieee80211_start_protocol(ieee); up(&ieee->wx_sem); } +EXPORT_SYMBOL(ieee80211_softmac_start_protocol); void ieee80211_start_protocol(struct ieee80211_device *ieee) { @@ -3138,6 +3149,7 @@ SendDisassociation( //dev_kfree_skb_any(skb);//edit by thomas } } +EXPORT_SYMBOL(SendDisassociation); int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p) { @@ -3193,6 +3205,7 @@ out: return ret; } +EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl); void notify_wx_assoc_event(struct ieee80211_device *ieee) { @@ -3204,25 +3217,4 @@ void notify_wx_assoc_event(struct ieee80211_device *ieee) memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN); wireless_send_event(ieee->dev, SIOCGIWAP, &wrqu, NULL); } - -EXPORT_SYMBOL(ieee80211_get_beacon); -EXPORT_SYMBOL(ieee80211_wake_queue); -EXPORT_SYMBOL(ieee80211_stop_queue); -EXPORT_SYMBOL(ieee80211_reset_queue); -EXPORT_SYMBOL(ieee80211_softmac_stop_protocol); -EXPORT_SYMBOL(ieee80211_softmac_start_protocol); -EXPORT_SYMBOL(ieee80211_is_shortslot); -EXPORT_SYMBOL(ieee80211_is_54g); -EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl); -EXPORT_SYMBOL(ieee80211_ps_tx_ack); -EXPORT_SYMBOL(ieee80211_softmac_xmit); -EXPORT_SYMBOL(ieee80211_stop_send_beacons); EXPORT_SYMBOL(notify_wx_assoc_event); -EXPORT_SYMBOL(SendDisassociation); -EXPORT_SYMBOL(ieee80211_disassociate); -EXPORT_SYMBOL(ieee80211_start_send_beacons); -EXPORT_SYMBOL(ieee80211_stop_scan); -EXPORT_SYMBOL(ieee80211_send_probe_requests); -EXPORT_SYMBOL(ieee80211_softmac_scan_syncro); -EXPORT_SYMBOL(ieee80211_start_scan_syncro); -//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame); diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c index 7b7d929f1536..a38176834320 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c @@ -26,7 +26,7 @@ const long ieee80211_wlan_frequencies[] = { 2452, 2457, 2462, 2467, 2472, 2484 }; - +EXPORT_SYMBOL(ieee80211_wlan_frequencies); int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) @@ -83,7 +83,7 @@ out: up(&ieee->wx_sem); return ret; } - +EXPORT_SYMBOL(ieee80211_wx_set_freq); int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, @@ -101,6 +101,7 @@ int ieee80211_wx_get_freq(struct ieee80211_device *ieee, return 0; } +EXPORT_SYMBOL(ieee80211_wx_get_freq); int ieee80211_wx_get_wap(struct ieee80211_device *ieee, struct iw_request_info *info, @@ -129,7 +130,7 @@ int ieee80211_wx_get_wap(struct ieee80211_device *ieee, return 0; } - +EXPORT_SYMBOL(ieee80211_wx_get_wap); int ieee80211_wx_set_wap(struct ieee80211_device *ieee, struct iw_request_info *info, @@ -176,6 +177,7 @@ out: up(&ieee->wx_sem); return ret; } +EXPORT_SYMBOL(ieee80211_wx_set_wap); int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) { @@ -211,6 +213,7 @@ out: return ret; } +EXPORT_SYMBOL(ieee80211_wx_get_essid); int ieee80211_wx_set_rate(struct ieee80211_device *ieee, struct iw_request_info *info, @@ -223,8 +226,7 @@ int ieee80211_wx_set_rate(struct ieee80211_device *ieee, //FIXME: we might want to limit rate also in management protocols. return 0; } - - +EXPORT_SYMBOL(ieee80211_wx_set_rate); int ieee80211_wx_get_rate(struct ieee80211_device *ieee, struct iw_request_info *info, @@ -237,7 +239,7 @@ int ieee80211_wx_get_rate(struct ieee80211_device *ieee, return 0; } - +EXPORT_SYMBOL(ieee80211_wx_get_rate); int ieee80211_wx_set_rts(struct ieee80211_device *ieee, struct iw_request_info *info, @@ -254,6 +256,7 @@ int ieee80211_wx_set_rts(struct ieee80211_device *ieee, } return 0; } +EXPORT_SYMBOL(ieee80211_wx_set_rts); int ieee80211_wx_get_rts(struct ieee80211_device *ieee, struct iw_request_info *info, @@ -264,6 +267,8 @@ int ieee80211_wx_get_rts(struct ieee80211_device *ieee, wrqu->rts.disabled = (wrqu->rts.value == DEFAULT_RTS_THRESHOLD); return 0; } +EXPORT_SYMBOL(ieee80211_wx_get_rts); + int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -294,6 +299,7 @@ out: up(&ieee->wx_sem); return 0; } +EXPORT_SYMBOL(ieee80211_wx_set_mode); void ieee80211_wx_sync_scan_wq(struct work_struct *work) { @@ -378,6 +384,7 @@ out: up(&ieee->wx_sem); return ret; } +EXPORT_SYMBOL(ieee80211_wx_set_scan); int ieee80211_wx_set_essid(struct ieee80211_device *ieee, struct iw_request_info *a, @@ -432,6 +439,7 @@ out: up(&ieee->wx_sem); return ret; } +EXPORT_SYMBOL(ieee80211_wx_set_essid); int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) @@ -440,6 +448,7 @@ out: wrqu->mode = ieee->iw_mode; return 0; } +EXPORT_SYMBOL(ieee80211_wx_get_mode); int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, struct iw_request_info *info, @@ -477,6 +486,7 @@ out: return 0; } +EXPORT_SYMBOL(ieee80211_wx_set_rawtx); int ieee80211_wx_get_name(struct ieee80211_device *ieee, struct iw_request_info *info, @@ -502,7 +512,7 @@ int ieee80211_wx_get_name(struct ieee80211_device *ieee, return 0; } - +EXPORT_SYMBOL(ieee80211_wx_get_name); /* this is mostly stolen from hostap */ int ieee80211_wx_set_power(struct ieee80211_device *ieee, @@ -553,6 +563,7 @@ exit: return ret; } +EXPORT_SYMBOL(ieee80211_wx_set_power); /* this is stolen from hostap */ int ieee80211_wx_get_power(struct ieee80211_device *ieee, @@ -593,21 +604,4 @@ exit: return ret; } -EXPORT_SYMBOL(ieee80211_wx_get_essid); -EXPORT_SYMBOL(ieee80211_wx_set_essid); -EXPORT_SYMBOL(ieee80211_wx_set_rate); -EXPORT_SYMBOL(ieee80211_wx_get_rate); -EXPORT_SYMBOL(ieee80211_wx_set_wap); -EXPORT_SYMBOL(ieee80211_wx_get_wap); -EXPORT_SYMBOL(ieee80211_wx_set_mode); -EXPORT_SYMBOL(ieee80211_wx_get_mode); -EXPORT_SYMBOL(ieee80211_wx_set_scan); -EXPORT_SYMBOL(ieee80211_wx_get_freq); -EXPORT_SYMBOL(ieee80211_wx_set_freq); -EXPORT_SYMBOL(ieee80211_wx_set_rawtx); -EXPORT_SYMBOL(ieee80211_wx_get_name); -EXPORT_SYMBOL(ieee80211_wx_set_power); EXPORT_SYMBOL(ieee80211_wx_get_power); -EXPORT_SYMBOL(ieee80211_wlan_frequencies); -EXPORT_SYMBOL(ieee80211_wx_set_rts); -EXPORT_SYMBOL(ieee80211_wx_get_rts); diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c index 6779bdd561d7..953717f1a6e4 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c @@ -236,6 +236,7 @@ void ieee80211_txb_free(struct ieee80211_txb *txb) { return; kfree(txb); } +EXPORT_SYMBOL(ieee80211_txb_free); static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, gfp_t gfp_mask) @@ -913,5 +914,3 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev) return 1; } - -EXPORT_SYMBOL(ieee80211_txb_free); diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c index bdf67ec5df21..38f124dcab6e 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c @@ -305,6 +305,7 @@ int ieee80211_wx_get_scan(struct ieee80211_device *ieee, return err; } +EXPORT_SYMBOL(ieee80211_wx_get_scan); int ieee80211_wx_set_encode(struct ieee80211_device *ieee, struct iw_request_info *info, @@ -479,6 +480,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, } return 0; } +EXPORT_SYMBOL(ieee80211_wx_set_encode); int ieee80211_wx_get_encode(struct ieee80211_device *ieee, struct iw_request_info *info, @@ -521,6 +523,8 @@ int ieee80211_wx_get_encode(struct ieee80211_device *ieee, return 0; } +EXPORT_SYMBOL(ieee80211_wx_get_encode); + #if (WIRELESS_EXT >= 18) int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, struct iw_request_info *info, @@ -695,6 +699,7 @@ done: } return ret; } +EXPORT_SYMBOL(ieee80211_wx_set_encode_ext); int ieee80211_wx_get_encode_ext(struct ieee80211_device *ieee, struct iw_request_info *info, @@ -750,6 +755,7 @@ int ieee80211_wx_get_encode_ext(struct ieee80211_device *ieee, return 0; } +EXPORT_SYMBOL(ieee80211_wx_get_encode_ext); int ieee80211_wx_set_mlme(struct ieee80211_device *ieee, struct iw_request_info *info, @@ -766,6 +772,7 @@ int ieee80211_wx_set_mlme(struct ieee80211_device *ieee, } return 0; } +EXPORT_SYMBOL(ieee80211_wx_set_mlme); int ieee80211_wx_set_auth(struct ieee80211_device *ieee, struct iw_request_info *info, @@ -828,7 +835,9 @@ int ieee80211_wx_set_auth(struct ieee80211_device *ieee, } return 0; } +EXPORT_SYMBOL(ieee80211_wx_set_auth); #endif + int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len) { u8 *buf; @@ -862,14 +871,4 @@ int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len) return 0; } - EXPORT_SYMBOL(ieee80211_wx_set_gen_ie); -#if (WIRELESS_EXT >= 18) -EXPORT_SYMBOL(ieee80211_wx_set_mlme); -EXPORT_SYMBOL(ieee80211_wx_set_auth); -EXPORT_SYMBOL(ieee80211_wx_set_encode_ext); -EXPORT_SYMBOL(ieee80211_wx_get_encode_ext); -#endif -EXPORT_SYMBOL(ieee80211_wx_get_scan); -EXPORT_SYMBOL(ieee80211_wx_set_encode); -EXPORT_SYMBOL(ieee80211_wx_get_encode); diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c index 53ec2d435ffe..0484145080cc 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c @@ -1319,6 +1319,7 @@ void HTUpdateSelfAndPeerSetting(struct ieee80211_device *ieee, struct ieee80211_ // } } +EXPORT_SYMBOL(HTUpdateSelfAndPeerSetting); /******************************************************************************************************************** *function: check whether HT control field exists @@ -1416,5 +1417,3 @@ void HTSetConnectBwModeCallback(struct ieee80211_device *ieee) pHTInfo->bSwBwInProgress = false; } - -EXPORT_SYMBOL(HTUpdateSelfAndPeerSetting); -- cgit v1.2.3 From def2d8b069c3d4f388022f485b9e1823fe1fd6d9 Mon Sep 17 00:00:00 2001 From: Rickard Strandqvist Date: Thu, 22 May 2014 22:25:06 +0200 Subject: staging: rtl8192u: r8192U_core.c: Fix to remove null pointer checks that could never happen Removal of null pointer checks that could never happen Signed-off-by: Rickard Strandqvist Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_core.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 1bb6143cdf0f..b7097505eef5 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -2045,9 +2045,6 @@ static void rtl8192_qos_activate(struct work_struct *work) u32 u4bAcParam; int i; - if (priv == NULL) - return; - mutex_lock(&priv->mutex); if (priv->ieee80211->state != IEEE80211_LINKED) goto success; -- cgit v1.2.3 From 12a7208386ac6bb114d1816ecfb6a9da3f179616 Mon Sep 17 00:00:00 2001 From: Tuomas Tynkkynen Date: Thu, 8 May 2014 14:13:17 +0300 Subject: staging: lirc: Fix sparse warnings Fix sparse warnings by adding __user and __iomem annotations where necessary and removing certain unnecessary casts. While at it, also use u32 in place of __u32. Signed-off-by: Tuomas Tynkkynen Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/lirc/lirc_bt829.c | 6 +++--- drivers/staging/media/lirc/lirc_parallel.c | 26 ++++++++++++----------- drivers/staging/media/lirc/lirc_serial.c | 11 +++++----- drivers/staging/media/lirc/lirc_sir.c | 33 +++++++++++++++--------------- drivers/staging/media/lirc/lirc_zilog.c | 23 +++++++++++---------- 5 files changed, 52 insertions(+), 47 deletions(-) diff --git a/drivers/staging/media/lirc/lirc_bt829.c b/drivers/staging/media/lirc/lirc_bt829.c index 30edc740ac25..fe010542ab4b 100644 --- a/drivers/staging/media/lirc/lirc_bt829.c +++ b/drivers/staging/media/lirc/lirc_bt829.c @@ -64,7 +64,7 @@ static bool debug; static int atir_minor; static phys_addr_t pci_addr_phys; -static unsigned char *pci_addr_lin; +static unsigned char __iomem *pci_addr_lin; static struct lirc_driver atir_driver; @@ -382,7 +382,7 @@ static unsigned char do_get_bits(void) static unsigned int read_index(unsigned char index) { - unsigned char *addr; + unsigned char __iomem *addr; unsigned int value; /* addr = pci_addr_lin + DATA_PCI_OFF + ((index & 0xFF) << 2); */ addr = pci_addr_lin + ((index & 0xFF) << 2); @@ -392,7 +392,7 @@ static unsigned int read_index(unsigned char index) static void write_index(unsigned char index, unsigned int reg_val) { - unsigned char *addr; + unsigned char __iomem *addr; addr = pci_addr_lin + ((index & 0xFF) << 2); writel(reg_val, addr); } diff --git a/drivers/staging/media/lirc/lirc_parallel.c b/drivers/staging/media/lirc/lirc_parallel.c index 62f5137b947b..1394f020e46b 100644 --- a/drivers/staging/media/lirc/lirc_parallel.c +++ b/drivers/staging/media/lirc/lirc_parallel.c @@ -324,7 +324,8 @@ static loff_t lirc_lseek(struct file *filep, loff_t offset, int orig) return -ESPIPE; } -static ssize_t lirc_read(struct file *filep, char *buf, size_t n, loff_t *ppos) +static ssize_t lirc_read(struct file *filep, char __user *buf, size_t n, + loff_t *ppos) { int result = 0; int count = 0; @@ -362,7 +363,7 @@ static ssize_t lirc_read(struct file *filep, char *buf, size_t n, loff_t *ppos) return count ? count : result; } -static ssize_t lirc_write(struct file *filep, const char *buf, size_t n, +static ssize_t lirc_write(struct file *filep, const char __user *buf, size_t n, loff_t *ppos) { int count; @@ -463,43 +464,44 @@ static unsigned int lirc_poll(struct file *file, poll_table *wait) static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) { int result; - __u32 features = LIRC_CAN_SET_TRANSMITTER_MASK | - LIRC_CAN_SEND_PULSE | LIRC_CAN_REC_MODE2; - __u32 mode; - __u32 value; + u32 __user *uptr = (u32 __user *)arg; + u32 features = LIRC_CAN_SET_TRANSMITTER_MASK | + LIRC_CAN_SEND_PULSE | LIRC_CAN_REC_MODE2; + u32 mode; + u32 value; switch (cmd) { case LIRC_GET_FEATURES: - result = put_user(features, (__u32 *) arg); + result = put_user(features, uptr); if (result) return result; break; case LIRC_GET_SEND_MODE: - result = put_user(LIRC_MODE_PULSE, (__u32 *) arg); + result = put_user(LIRC_MODE_PULSE, uptr); if (result) return result; break; case LIRC_GET_REC_MODE: - result = put_user(LIRC_MODE_MODE2, (__u32 *) arg); + result = put_user(LIRC_MODE_MODE2, uptr); if (result) return result; break; case LIRC_SET_SEND_MODE: - result = get_user(mode, (__u32 *) arg); + result = get_user(mode, uptr); if (result) return result; if (mode != LIRC_MODE_PULSE) return -EINVAL; break; case LIRC_SET_REC_MODE: - result = get_user(mode, (__u32 *) arg); + result = get_user(mode, uptr); if (result) return result; if (mode != LIRC_MODE_MODE2) return -ENOSYS; break; case LIRC_SET_TRANSMITTER_MASK: - result = get_user(value, (__u32 *) arg); + result = get_user(value, uptr); if (result) return result; if ((value & LIRC_PARALLEL_TRANSMITTER_MASK) != value) diff --git a/drivers/staging/media/lirc/lirc_serial.c b/drivers/staging/media/lirc/lirc_serial.c index 10c685d5de7c..dc5ba43116c7 100644 --- a/drivers/staging/media/lirc/lirc_serial.c +++ b/drivers/staging/media/lirc/lirc_serial.c @@ -1011,7 +1011,8 @@ static ssize_t lirc_write(struct file *file, const char __user *buf, static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) { int result; - __u32 value; + u32 __user *uptr = (u32 __user *)arg; + u32 value; switch (cmd) { case LIRC_GET_SEND_MODE: @@ -1020,7 +1021,7 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) result = put_user(LIRC_SEND2MODE (hardware[type].features&LIRC_CAN_SEND_MASK), - (__u32 *) arg); + uptr); if (result) return result; break; @@ -1029,7 +1030,7 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) if (!(hardware[type].features&LIRC_CAN_SEND_MASK)) return -ENOIOCTLCMD; - result = get_user(value, (__u32 *) arg); + result = get_user(value, uptr); if (result) return result; /* only LIRC_MODE_PULSE supported */ @@ -1046,7 +1047,7 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) if (!(hardware[type].features&LIRC_CAN_SET_SEND_DUTY_CYCLE)) return -ENOIOCTLCMD; - result = get_user(value, (__u32 *) arg); + result = get_user(value, uptr); if (result) return result; if (value <= 0 || value > 100) @@ -1059,7 +1060,7 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) if (!(hardware[type].features&LIRC_CAN_SET_SEND_CARRIER)) return -ENOIOCTLCMD; - result = get_user(value, (__u32 *) arg); + result = get_user(value, uptr); if (result) return result; if (value > 500000 || value < 20000) diff --git a/drivers/staging/media/lirc/lirc_sir.c b/drivers/staging/media/lirc/lirc_sir.c index f781c532b3c4..e31cbb81f059 100644 --- a/drivers/staging/media/lirc/lirc_sir.c +++ b/drivers/staging/media/lirc/lirc_sir.c @@ -187,10 +187,10 @@ static bool debug; /* Communication with user-space */ static unsigned int lirc_poll(struct file *file, poll_table *wait); -static ssize_t lirc_read(struct file *file, char *buf, size_t count, - loff_t *ppos); -static ssize_t lirc_write(struct file *file, const char *buf, size_t n, - loff_t *pos); +static ssize_t lirc_read(struct file *file, char __user *buf, size_t count, + loff_t *ppos); +static ssize_t lirc_write(struct file *file, const char __user *buf, size_t n, + loff_t *pos); static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg); static void add_read_queue(int flag, unsigned long val); static int init_chrdev(void); @@ -252,8 +252,8 @@ static unsigned int lirc_poll(struct file *file, poll_table *wait) return 0; } -static ssize_t lirc_read(struct file *file, char *buf, size_t count, - loff_t *ppos) +static ssize_t lirc_read(struct file *file, char __user *buf, size_t count, + loff_t *ppos) { int n = 0; int retval = 0; @@ -266,9 +266,9 @@ static ssize_t lirc_read(struct file *file, char *buf, size_t count, set_current_state(TASK_INTERRUPTIBLE); while (n < count) { if (rx_head != rx_tail) { - if (copy_to_user((void *) buf + n, - (void *) (rx_buf + rx_head), - sizeof(int))) { + if (copy_to_user(buf + n, + rx_buf + rx_head, + sizeof(int))) { retval = -EFAULT; break; } @@ -291,8 +291,8 @@ static ssize_t lirc_read(struct file *file, char *buf, size_t count, set_current_state(TASK_RUNNING); return n ? n : retval; } -static ssize_t lirc_write(struct file *file, const char *buf, size_t n, - loff_t *pos) +static ssize_t lirc_write(struct file *file, const char __user *buf, size_t n, + loff_t *pos) { unsigned long flags; int i, count; @@ -338,8 +338,9 @@ static ssize_t lirc_write(struct file *file, const char *buf, size_t n, static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) { + u32 __user *uptr = (u32 __user *)arg; int retval = 0; - __u32 value = 0; + u32 value = 0; #ifdef LIRC_ON_SA1100 if (cmd == LIRC_GET_FEATURES) @@ -364,16 +365,16 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) case LIRC_GET_FEATURES: case LIRC_GET_SEND_MODE: case LIRC_GET_REC_MODE: - retval = put_user(value, (__u32 *) arg); + retval = put_user(value, uptr); break; case LIRC_SET_SEND_MODE: case LIRC_SET_REC_MODE: - retval = get_user(value, (__u32 *) arg); + retval = get_user(value, uptr); break; #ifdef LIRC_ON_SA1100 case LIRC_SET_SEND_DUTY_CYCLE: - retval = get_user(value, (__u32 *) arg); + retval = get_user(value, uptr); if (retval) return retval; if (value <= 0 || value > 100) @@ -388,7 +389,7 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) space_width -= LIRC_ON_SA1100_TRANSMITTER_LATENCY; break; case LIRC_SET_SEND_CARRIER: - retval = get_user(value, (__u32 *) arg); + retval = get_user(value, uptr); if (retval) return retval; if (value > 500000 || value < 20000) diff --git a/drivers/staging/media/lirc/lirc_zilog.c b/drivers/staging/media/lirc/lirc_zilog.c index e1feb6164593..3259aacfd350 100644 --- a/drivers/staging/media/lirc/lirc_zilog.c +++ b/drivers/staging/media/lirc/lirc_zilog.c @@ -892,7 +892,8 @@ out: } /* copied from lirc_dev */ -static ssize_t read(struct file *filep, char *outbuf, size_t n, loff_t *ppos) +static ssize_t read(struct file *filep, char __user *outbuf, size_t n, + loff_t *ppos) { struct IR *ir = filep->private_data; struct IR_rx *rx; @@ -954,7 +955,7 @@ static ssize_t read(struct file *filep, char *outbuf, size_t n, loff_t *ppos) } m = lirc_buffer_read(rbuf, buf); if (m == rbuf->chunk_size) { - ret = copy_to_user((void *)outbuf+written, buf, + ret = copy_to_user(outbuf + written, buf, rbuf->chunk_size); written += rbuf->chunk_size; } else { @@ -1094,8 +1095,8 @@ static int send_code(struct IR_tx *tx, unsigned int code, unsigned int key) * sent to the device. We have a spin lock as per i2c documentation to prevent * multiple concurrent sends which would probably cause the device to explode. */ -static ssize_t write(struct file *filep, const char *buf, size_t n, - loff_t *ppos) +static ssize_t write(struct file *filep, const char __user *buf, size_t n, + loff_t *ppos) { struct IR *ir = filep->private_data; struct IR_tx *tx; @@ -1237,6 +1238,7 @@ static unsigned int poll(struct file *filep, poll_table *wait) static long ioctl(struct file *filep, unsigned int cmd, unsigned long arg) { struct IR *ir = filep->private_data; + unsigned long __user *uptr = (unsigned long __user *)arg; int result; unsigned long mode, features; @@ -1244,11 +1246,10 @@ static long ioctl(struct file *filep, unsigned int cmd, unsigned long arg) switch (cmd) { case LIRC_GET_LENGTH: - result = put_user((unsigned long)13, - (unsigned long *)arg); + result = put_user(13UL, uptr); break; case LIRC_GET_FEATURES: - result = put_user(features, (unsigned long *) arg); + result = put_user(features, uptr); break; case LIRC_GET_REC_MODE: if (!(features&LIRC_CAN_REC_MASK)) @@ -1256,13 +1257,13 @@ static long ioctl(struct file *filep, unsigned int cmd, unsigned long arg) result = put_user(LIRC_REC2MODE (features&LIRC_CAN_REC_MASK), - (unsigned long *)arg); + uptr); break; case LIRC_SET_REC_MODE: if (!(features&LIRC_CAN_REC_MASK)) return -ENOSYS; - result = get_user(mode, (unsigned long *)arg); + result = get_user(mode, uptr); if (!result && !(LIRC_MODE2REC(mode) & features)) result = -EINVAL; break; @@ -1270,13 +1271,13 @@ static long ioctl(struct file *filep, unsigned int cmd, unsigned long arg) if (!(features&LIRC_CAN_SEND_MASK)) return -ENOSYS; - result = put_user(LIRC_MODE_PULSE, (unsigned long *) arg); + result = put_user(LIRC_MODE_PULSE, uptr); break; case LIRC_SET_SEND_MODE: if (!(features&LIRC_CAN_SEND_MASK)) return -ENOSYS; - result = get_user(mode, (unsigned long *) arg); + result = get_user(mode, uptr); if (!result && mode != LIRC_MODE_PULSE) return -EINVAL; break; -- cgit v1.2.3 From 3fc29811e905a350476871f0be4546c0e3a31924 Mon Sep 17 00:00:00 2001 From: Remi Pommarel Date: Tue, 6 May 2014 23:40:50 +0200 Subject: Staging: rtl8188eu: Fixed prohibited spaces after open '(' This patch fixes all prohibited spaces after open '(' checkpatch.pl errors for rtl8188eu. Signed-off-by: Remi Pommarel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/odm_debug.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/odm_debug.h b/drivers/staging/rtl8188eu/include/odm_debug.h index e8c4cab2c354..db7b44e16c48 100644 --- a/drivers/staging/rtl8188eu/include/odm_debug.h +++ b/drivers/staging/rtl8188eu/include/odm_debug.h @@ -85,7 +85,7 @@ /*------------------------Export Marco Definition---------------------------*/ #define DbgPrint pr_info #define RT_PRINTK(fmt, args...) \ - DbgPrint( "%s(): " fmt, __func__, ## args); + DbgPrint("%s(): " fmt, __func__, ## args); #ifndef ASSERT #define ASSERT(expr) @@ -106,8 +106,8 @@ #define ODM_RT_ASSERT(pDM_Odm, expr, fmt) \ if (!(expr)) { \ - DbgPrint( "Assertion failed! %s at ......\n", #expr); \ - DbgPrint( " ......%s,%s,line=%d\n", __FILE__, \ + DbgPrint("Assertion failed! %s at ......\n", #expr); \ + DbgPrint(" ......%s,%s,line=%d\n", __FILE__, \ __func__, __LINE__); \ RT_PRINTK fmt; \ ASSERT(false); \ -- cgit v1.2.3 From 948b60a903174806afbcde4dbe11e5ead8af4b48 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Wed, 7 May 2014 09:27:24 +0530 Subject: staging: rtl8188eu: Remove 'semaphore allrxreturnevt' from struct recv_priv Remove unused variable 'semaphore allrxreturnevt'. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_recv.c | 2 -- drivers/staging/rtl8188eu/include/rtw_recv.h | 1 - 2 files changed, 3 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index 723996eeb4ed..3bdc3532bd81 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -101,8 +101,6 @@ int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) } precvpriv->rx_pending_cnt = 1; - sema_init(&precvpriv->allrxreturnevt, 0); - res = rtw_hal_init_recv_priv(padapter); _init_timer(&precvpriv->signal_stat_timer, padapter->pnetdev, RTW_TIMER_HDL_NAME(signal_stat), padapter); diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index 971dd16d4a27..5b3bf29ab13f 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -193,7 +193,6 @@ struct recv_priv { uint rx_largepacket_crcerr; uint rx_smallpacket_crcerr; uint rx_middlepacket_crcerr; - struct semaphore allrxreturnevt; uint ff_hwaddr; u8 rx_pending_cnt; -- cgit v1.2.3 From 2050d582a2d86921f4c6b1b7acd09fba00d66e6e Mon Sep 17 00:00:00 2001 From: navin patidar Date: Wed, 7 May 2014 09:27:25 +0530 Subject: staging: rtl8188eu: Remove unused member variables of struct recv_priv Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/rtw_recv.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index 5b3bf29ab13f..d52cfe8a9510 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -189,10 +189,6 @@ struct recv_priv { u64 rx_drop; u64 last_rx_bytes; - uint rx_icv_err; - uint rx_largepacket_crcerr; - uint rx_smallpacket_crcerr; - uint rx_middlepacket_crcerr; uint ff_hwaddr; u8 rx_pending_cnt; @@ -212,9 +208,7 @@ struct recv_priv { u8 signal_strength; u8 signal_qual; u8 noise; - int RxSNRdB[2]; s8 RxRssi[2]; - int FalseAlmCnt_all; struct timer_list signal_stat_timer; u32 signal_stat_sampling_interval; -- cgit v1.2.3 From 9fdbb461747550c933b8596c71ce1d9090feb1a5 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Wed, 7 May 2014 09:27:26 +0530 Subject: staging: rtl8188eu: Remove 'spinlock_t lock' from struct recv_priv Remove unused variable 'spinlock_t lock'. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_recv.c | 2 -- drivers/staging/rtl8188eu/include/rtw_recv.h | 1 - 2 files changed, 3 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index 3bdc3532bd81..5c3d416adb67 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -63,8 +63,6 @@ int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) int res = _SUCCESS; - spin_lock_init(&precvpriv->lock); - _rtw_init_queue(&precvpriv->free_recv_queue); _rtw_init_queue(&precvpriv->recv_pending_queue); _rtw_init_queue(&precvpriv->uc_swdec_pending_queue); diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index d52cfe8a9510..68c2ad5f2e7c 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -175,7 +175,6 @@ recv_thread(passive) ; returnpkt(dispatch) using enter_critical section to protect */ struct recv_priv { - spinlock_t lock; struct __queue free_recv_queue; struct __queue recv_pending_queue; struct __queue uc_swdec_pending_queue; -- cgit v1.2.3 From 73885aa05683fb549a9774190004e5d7bfefa337 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Wed, 7 May 2014 09:27:27 +0530 Subject: staging: rtl8188eu: Remove struct zero_bulkout_context Remove unused struct zero_bulkout_context. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c index fb0bba85373b..ba2a8ab80d77 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c @@ -39,13 +39,6 @@ unsigned int ffaddr2pipehdl(struct dvobj_priv *pdvobj, u32 addr) return pipe; } -struct zero_bulkout_context { - void *pbuf; - void *purb; - void *pirp; - void *padapter; -}; - void usb_read_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) { } -- cgit v1.2.3 From db7bf478c8fca70bfc8404665ac40142ecc6c0f7 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Wed, 7 May 2014 09:27:28 +0530 Subject: staging: rtl8188eu: Remove function rtw_os_recv_resource_init() rtw_os_recv_resource_init() has empty defination, so we can remove it. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_recv.c | 2 -- drivers/staging/rtl8188eu/include/recv_osdep.h | 1 - drivers/staging/rtl8188eu/os_dep/recv_linux.c | 7 ------- 3 files changed, 10 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index 5c3d416adb67..b4b6292ece8c 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -71,8 +71,6 @@ int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) precvpriv->free_recvframe_cnt = NR_RECVFRAME; - rtw_os_recv_resource_init(precvpriv, padapter); - precvpriv->pallocated_frame_buf = vzalloc(NR_RECVFRAME * sizeof(struct recv_frame) + RXFRAME_ALIGN_SZ); if (precvpriv->pallocated_frame_buf == NULL) { diff --git a/drivers/staging/rtl8188eu/include/recv_osdep.h b/drivers/staging/rtl8188eu/include/recv_osdep.h index d76cc2db5028..f49ac5635b0e 100644 --- a/drivers/staging/rtl8188eu/include/recv_osdep.h +++ b/drivers/staging/rtl8188eu/include/recv_osdep.h @@ -39,7 +39,6 @@ void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup); int rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter); void rtw_free_recv_priv(struct recv_priv *precvpriv); -int rtw_os_recv_resource_init(struct recv_priv *recvpr, struct adapter *adapt); int rtw_os_recv_resource_alloc(struct adapter *adapt, struct recv_frame *recvfr); void rtw_os_recv_resource_free(struct recv_priv *precvpriv); diff --git a/drivers/staging/rtl8188eu/os_dep/recv_linux.c b/drivers/staging/rtl8188eu/os_dep/recv_linux.c index 29ec0148b573..c1fbe8d7c3b4 100644 --- a/drivers/staging/rtl8188eu/os_dep/recv_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/recv_linux.c @@ -28,13 +28,6 @@ #include #include -/* init os related resource in struct recv_priv */ -int rtw_os_recv_resource_init(struct recv_priv *precvpriv, - struct adapter *padapter) -{ - return _SUCCESS; -} - /* alloc os related resource in struct recv_frame */ int rtw_os_recv_resource_alloc(struct adapter *padapter, struct recv_frame *precvframe) -- cgit v1.2.3 From 5aae05964ef5425503ccf7421618d784218dc21a Mon Sep 17 00:00:00 2001 From: navin patidar Date: Wed, 7 May 2014 09:27:29 +0530 Subject: staging: rtl8188eu: Remove function rtw_os_recv_resource_free() rtw_os_recv_resource_free() has empty defination, so we can remove it. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_recv.c | 2 -- drivers/staging/rtl8188eu/include/recv_osdep.h | 1 - drivers/staging/rtl8188eu/os_dep/recv_linux.c | 5 ----- 3 files changed, 8 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index b4b6292ece8c..0e73df5975b8 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -117,8 +117,6 @@ void _rtw_free_recv_priv (struct recv_priv *precvpriv) rtw_free_uc_swdec_pending_queue(padapter); - rtw_os_recv_resource_free(precvpriv); - if (precvpriv->pallocated_frame_buf) { vfree(precvpriv->pallocated_frame_buf); } diff --git a/drivers/staging/rtl8188eu/include/recv_osdep.h b/drivers/staging/rtl8188eu/include/recv_osdep.h index f49ac5635b0e..44caea957c02 100644 --- a/drivers/staging/rtl8188eu/include/recv_osdep.h +++ b/drivers/staging/rtl8188eu/include/recv_osdep.h @@ -41,7 +41,6 @@ void rtw_free_recv_priv(struct recv_priv *precvpriv); int rtw_os_recv_resource_alloc(struct adapter *adapt, struct recv_frame *recvfr); -void rtw_os_recv_resource_free(struct recv_priv *precvpriv); int rtw_os_recvbuf_resource_alloc(struct adapter *adapt, struct recv_buf *buf); int rtw_os_recvbuf_resource_free(struct adapter *adapt, struct recv_buf *buf); diff --git a/drivers/staging/rtl8188eu/os_dep/recv_linux.c b/drivers/staging/rtl8188eu/os_dep/recv_linux.c index c1fbe8d7c3b4..d1ce6399c4b0 100644 --- a/drivers/staging/rtl8188eu/os_dep/recv_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/recv_linux.c @@ -37,11 +37,6 @@ int rtw_os_recv_resource_alloc(struct adapter *padapter, return _SUCCESS; } -/* free os related resource in struct recv_frame */ -void rtw_os_recv_resource_free(struct recv_priv *precvpriv) -{ -} - /* alloc os related resource in struct recv_buf */ int rtw_os_recvbuf_resource_alloc(struct adapter *padapter, struct recv_buf *precvbuf) -- cgit v1.2.3 From 65ae271b173e621e6893a48e2979e6a7bb3a9f8a Mon Sep 17 00:00:00 2001 From: navin patidar Date: Wed, 7 May 2014 09:27:30 +0530 Subject: staging: rtl8188eu: Remove function rtw_hostapd_mlme_rx() rtw_hostapd_mlme_rx() has empty defination, so we can remove it. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 2 -- drivers/staging/rtl8188eu/include/recv_osdep.h | 1 - drivers/staging/rtl8188eu/os_dep/recv_linux.c | 5 ----- 3 files changed, 8 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 55be52fb34a9..e854732478b8 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -502,8 +502,6 @@ void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame) break; default: _mgt_dispatcher(padapter, ptable, precv_frame); - if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) - rtw_hostapd_mlme_rx(padapter, precv_frame); break; } #else diff --git a/drivers/staging/rtl8188eu/include/recv_osdep.h b/drivers/staging/rtl8188eu/include/recv_osdep.h index 44caea957c02..5333598e46a0 100644 --- a/drivers/staging/rtl8188eu/include/recv_osdep.h +++ b/drivers/staging/rtl8188eu/include/recv_osdep.h @@ -33,7 +33,6 @@ int rtw_recv_indicatepkt(struct adapter *adapter, struct recv_frame *recv_frame); void rtw_recv_returnpacket(struct net_device *cnxt, struct sk_buff *retpkt); -void rtw_hostapd_mlme_rx(struct adapter *padapter, struct recv_frame *recv_fr); void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup); int rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter); diff --git a/drivers/staging/rtl8188eu/os_dep/recv_linux.c b/drivers/staging/rtl8188eu/os_dep/recv_linux.c index d1ce6399c4b0..edb7969a96d8 100644 --- a/drivers/staging/rtl8188eu/os_dep/recv_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/recv_linux.c @@ -95,11 +95,6 @@ void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup) &wrqu, (char *)&ev); } -void rtw_hostapd_mlme_rx(struct adapter *padapter, - struct recv_frame *precv_frame) -{ -} - int rtw_recv_indicatepkt(struct adapter *padapter, struct recv_frame *precv_frame) { -- cgit v1.2.3 From cba1ce62776e1ad43e1ab68ff7f4612884316d4a Mon Sep 17 00:00:00 2001 From: navin patidar Date: Wed, 7 May 2014 09:27:31 +0530 Subject: staging: rtl8188eu: Remove function rtw_os_recvbuf_resource_free() Use usb_free_urb() instead of rtw_os_recvbuf_resource_free() to free URB. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c | 2 +- drivers/staging/rtl8188eu/include/recv_osdep.h | 1 - drivers/staging/rtl8188eu/os_dep/recv_linux.c | 8 -------- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c index 2b4556414e8a..0f6222dab4a6 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c @@ -97,7 +97,7 @@ void rtl8188eu_free_recv_priv(struct adapter *padapter) precvbuf = (struct recv_buf *)precvpriv->precv_buf; for (i = 0; i < NR_RECVBUFF; i++) { - rtw_os_recvbuf_resource_free(padapter, precvbuf); + usb_free_urb(precvbuf->purb); precvbuf++; } diff --git a/drivers/staging/rtl8188eu/include/recv_osdep.h b/drivers/staging/rtl8188eu/include/recv_osdep.h index 5333598e46a0..a4fd95798f00 100644 --- a/drivers/staging/rtl8188eu/include/recv_osdep.h +++ b/drivers/staging/rtl8188eu/include/recv_osdep.h @@ -42,7 +42,6 @@ int rtw_os_recv_resource_alloc(struct adapter *adapt, struct recv_frame *recvfr); int rtw_os_recvbuf_resource_alloc(struct adapter *adapt, struct recv_buf *buf); -int rtw_os_recvbuf_resource_free(struct adapter *adapt, struct recv_buf *buf); void rtw_os_read_port(struct adapter *padapter, struct recv_buf *precvbuf); diff --git a/drivers/staging/rtl8188eu/os_dep/recv_linux.c b/drivers/staging/rtl8188eu/os_dep/recv_linux.c index edb7969a96d8..c0fa8fdb9d92 100644 --- a/drivers/staging/rtl8188eu/os_dep/recv_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/recv_linux.c @@ -51,14 +51,6 @@ int rtw_os_recvbuf_resource_alloc(struct adapter *padapter, return res; } -/* free os related resource in struct recv_buf */ -int rtw_os_recvbuf_resource_free(struct adapter *padapter, - struct recv_buf *precvbuf) -{ - usb_free_urb(precvbuf->purb); - return _SUCCESS; -} - void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup) { union iwreq_data wrqu; -- cgit v1.2.3 From 8885dc250911897bf5468513eb1449b443971131 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Wed, 7 May 2014 09:31:14 +0530 Subject: staging: rtl8188eu: Remove unused inline function recvframe_push() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/rtw_recv.h | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index 68c2ad5f2e7c..e5b4e1031af6 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -296,26 +296,6 @@ static inline u8 *get_rx_status(struct recv_frame *precvframe) return get_rxmem(precvframe); } -static inline u8 *recvframe_push(struct recv_frame *precvframe, int sz) -{ - /* append data before rx_data */ - - /* add data to the start of recv_frame - * - * This function extends the used data area of the recv_frame at the buffer - * start. rx_data must be still larger than rx_head, after pushing. - */ - if (precvframe == NULL) - return NULL; - precvframe->rx_data -= sz; - if (precvframe->rx_data < precvframe->rx_head) { - precvframe->rx_data += sz; - return NULL; - } - precvframe->len += sz; - return precvframe->rx_data; -} - static inline u8 *recvframe_pull(struct recv_frame *precvframe, int sz) { /* rx_data += sz; move rx_data sz bytes hereafter */ -- cgit v1.2.3 From 750eb2d250085acf13fe919f73d7be85d7b46bea Mon Sep 17 00:00:00 2001 From: navin patidar Date: Wed, 7 May 2014 09:31:15 +0530 Subject: staging: rtl8188eu: Remove unused inline function get_rx_status() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/rtw_recv.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index e5b4e1031af6..dac2e0ccbc17 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -291,11 +291,6 @@ static inline u8 *get_rxmem(struct recv_frame *precvframe) return precvframe->rx_head; } -static inline u8 *get_rx_status(struct recv_frame *precvframe) -{ - return get_rxmem(precvframe); -} - static inline u8 *recvframe_pull(struct recv_frame *precvframe, int sz) { /* rx_data += sz; move rx_data sz bytes hereafter */ -- cgit v1.2.3 From b0c9897c4a999addbcef39d2c86c5e90eb291fa1 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Wed, 7 May 2014 09:31:16 +0530 Subject: staging: rtl8188eu: Remove 'void *precvbuf' from struct recv_frame Remove unused variable 'void *precvbuf'. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/usb_ops_linux.c | 1 - drivers/staging/rtl8188eu/include/rtw_recv.h | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/usb_ops_linux.c b/drivers/staging/rtl8188eu/hal/usb_ops_linux.c index d9f60ab8c44d..ca81530f9cf5 100644 --- a/drivers/staging/rtl8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/hal/usb_ops_linux.c @@ -333,7 +333,6 @@ static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb) } _rtw_init_listhead(&precvframe->list); - precvframe->precvbuf = NULL; /* can't access the precvbuf for new arch. */ precvframe->len = 0; update_recvframe_attrib_88e(precvframe, prxstat); diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index dac2e0ccbc17..e14ba986c36f 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -261,7 +261,6 @@ struct recv_frame { u8 *rx_data; u8 *rx_tail; u8 *rx_end; - void *precvbuf; struct sta_info *psta; /* for A-MPDU Rx reordering buffer control */ struct recv_reorder_ctrl *preorder_ctrl; -- cgit v1.2.3 From b85675a8f0c9d24b25b3ee98db678f0d86b67d04 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Wed, 7 May 2014 09:31:17 +0530 Subject: staging: rtl8188eu: Remove 'int frame_tag' from struct recv_frame Remove unused variable 'int frame_tag'. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/rtw_recv.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index e14ba986c36f..b0fbdbd83580 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -254,7 +254,6 @@ struct recv_frame { struct sk_buff *pkt_newalloc; struct adapter *adapter; u8 fragcnt; - int frame_tag; struct rx_pkt_attrib attrib; uint len; u8 *rx_head; -- cgit v1.2.3 From 5b0a7eae9fc51a891c1b5f5cdaaf05d0c4876e16 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Wed, 7 May 2014 09:31:18 +0530 Subject: staging: rtl8188eu: Remove 'u8 fragcnt' from struct recv_frame Remove unused variable 'u8 fragcnt'. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/rtw_recv.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index b0fbdbd83580..f0c26ef8f66a 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -253,7 +253,6 @@ struct recv_frame { struct sk_buff *pkt; struct sk_buff *pkt_newalloc; struct adapter *adapter; - u8 fragcnt; struct rx_pkt_attrib attrib; uint len; u8 *rx_head; -- cgit v1.2.3 From d6a6c916189e4ef0512a1620afc3c88a114e825d Mon Sep 17 00:00:00 2001 From: Christian Engelmayer Date: Wed, 7 May 2014 21:30:23 +0200 Subject: staging: rtl8188eu: fix potential leak in rtw_wx_read32() Function rtw_wx_read32() dynamically allocates a temporary buffer that is not freed in all error paths. Use a centralized exit path and make sure that all memory is freed correctly. Detected by Coverity - CID 1077711. Signed-off-by: Christian Engelmayer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index cf30a08912d1..45b47e2840b7 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -2154,6 +2154,7 @@ static int rtw_wx_read32(struct net_device *dev, u32 bytes; u8 *ptmp; int rv; + int ret = 0; padapter = (struct adapter *)rtw_netdev_priv(dev); p = &wrqu->data; @@ -2163,16 +2164,16 @@ static int rtw_wx_read32(struct net_device *dev, return -ENOMEM; if (copy_from_user(ptmp, p->pointer, len)) { - kfree(ptmp); - return -EFAULT; + ret = -EFAULT; + goto exit; } bytes = 0; addr = 0; rv = sscanf(ptmp, "%d,%x", &bytes, &addr); if (rv != 2) { - kfree(ptmp); - return -EINVAL; + ret = -EINVAL; + goto exit; } switch (bytes) { @@ -2190,12 +2191,14 @@ static int rtw_wx_read32(struct net_device *dev, break; default: DBG_88E(KERN_INFO "%s: usage> read [bytes],[address(hex)]\n", __func__); - return -EINVAL; + ret = -EINVAL; + goto exit; } DBG_88E(KERN_INFO "%s: addr = 0x%08X data =%s\n", __func__, addr, extra); +exit: kfree(ptmp); - return 0; + return ret; } static int rtw_wx_write32(struct net_device *dev, -- cgit v1.2.3 From 5d57f1e8f6699653f2e5b7c9dfad6b0dd0c8dcd3 Mon Sep 17 00:00:00 2001 From: Christian Engelmayer Date: Wed, 7 May 2014 21:31:20 +0200 Subject: staging: rtl8188eu: fix potential leak in rtw_wx_set_enc_ext() Function rtw_wx_set_enc_ext() dynamically allocates a temporary buffer that is not freed in all error paths. Use a centralized exit path and make sure that all memory is freed correctly. Detected by Coverity - CID 1077712. Signed-off-by: Christian Engelmayer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index 45b47e2840b7..1bd476dd81e7 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -2097,7 +2097,8 @@ static int rtw_wx_set_enc_ext(struct net_device *dev, alg_name = "CCMP"; break; default: - return -1; + ret = -1; + goto exit; } strncpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN); @@ -2124,6 +2125,7 @@ static int rtw_wx_set_enc_ext(struct net_device *dev, ret = wpa_set_encryption(dev, param, param_len); +exit: kfree(param); return ret; } -- cgit v1.2.3 From 3dad0d1e40285fb8a5c6b878c5ac5eb556f9dd9e Mon Sep 17 00:00:00 2001 From: Christian Engelmayer Date: Wed, 7 May 2014 21:32:30 +0200 Subject: staging: rtl8188eu: fix potential leak in rtw_mp_QueryDrv() Function rtw_mp_QueryDrv() dynamically allocates a temporary buffer that is not freed in all error paths. Use a centralized exit path and make sure that all memory is freed correctly. Detected by Coverity - CID 1077713. Signed-off-by: Christian Engelmayer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index 1bd476dd81e7..8b1579ba4ca0 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -7350,12 +7350,15 @@ static int rtw_mp_QueryDrv(struct net_device *dev, char *input = kmalloc(wrqu->data.length, GFP_KERNEL); u8 qAutoLoad = 1; struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); + int ret = 0; if (!input) return -ENOMEM; - if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) - return -EFAULT; + if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) { + ret = -EFAULT; + goto exit; + } DBG_88E("%s:iwpriv in =%s\n", __func__, input); qAutoLoad = strncmp(input, "autoload", 8); /* strncmp true is 0 */ @@ -7369,8 +7372,10 @@ static int rtw_mp_QueryDrv(struct net_device *dev, sprintf(extra, "ok"); } wrqu->data.length = strlen(extra) + 1; + +exit: kfree(input); - return 0; + return ret; } static int rtw_mp_set(struct net_device *dev, -- cgit v1.2.3 From c98acd000bc578f4a53c4879760d2d1ccdc794a9 Mon Sep 17 00:00:00 2001 From: Christian Engelmayer Date: Wed, 7 May 2014 21:33:20 +0200 Subject: staging: rtl8188eu: fix potential leak in rtw_mp_SetRFPath() Function rtw_mp_SetRFPath() dynamically allocates a temporary buffer that is not freed in all error paths. Use a centralized exit path and make sure that all memory is freed correctly. Detected by Coverity - CID 1077714. Signed-off-by: Christian Engelmayer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index 8b1579ba4ca0..ea5e1f838ea3 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -7321,11 +7321,14 @@ static int rtw_mp_SetRFPath(struct net_device *dev, struct adapter *padapter = rtw_netdev_priv(dev); char *input = kmalloc(wrqu->data.length, GFP_KERNEL); u8 bMain = 1, bTurnoff = 1; + int ret = 0; if (!input) return -ENOMEM; - if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) - return -EFAULT; + if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) { + ret = -EFAULT; + goto exit; + } DBG_88E("%s:iwpriv in =%s\n", __func__, input); bMain = strncmp(input, "1", 2); /* strncmp true is 0 */ @@ -7338,8 +7341,10 @@ static int rtw_mp_SetRFPath(struct net_device *dev, MP_PHY_SetRFPathSwitch(padapter, false); DBG_88E("%s:PHY_SetRFPathSwitch = false\n", __func__); } + +exit: kfree(input); - return 0; + return ret; } static int rtw_mp_QueryDrv(struct net_device *dev, -- cgit v1.2.3 From e0e2c5cde57d4b0c3af2998c3a591f3db75ce7eb Mon Sep 17 00:00:00 2001 From: Christian Engelmayer Date: Wed, 7 May 2014 21:34:37 +0200 Subject: staging: rtl8188eu: fix potential leak in rtw_mp_pwrtrk() Function rtw_mp_pwrtrk() dynamically allocates a temporary buffer that is not freed in all error paths. Use a centralized exit path and make sure that all memory is freed correctly. Detected by Coverity - 1077715. Signed-off-by: Christian Engelmayer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 28 ++++++++++++++++---------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index ea5e1f838ea3..f04aaa375f0e 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -7119,15 +7119,15 @@ static int rtw_mp_pwrtrk(struct net_device *dev, { u8 enable; u32 thermal; - s32 ret; struct adapter *padapter = rtw_netdev_priv(dev); char *input = kmalloc(wrqu->length, GFP_KERNEL); + int ret = 0; if (!input) return -ENOMEM; if (copy_from_user(input, wrqu->pointer, wrqu->length)) { - kfree(input); - return -EFAULT; + ret = -EFAULT; + goto exit; } _rtw_memset(extra, 0, wrqu->length); @@ -7138,22 +7138,28 @@ static int rtw_mp_pwrtrk(struct net_device *dev, sprintf(extra, "mp tx power tracking stop"); } else if (sscanf(input, "ther =%d", &thermal)) { ret = Hal_SetThermalMeter(padapter, (u8)thermal); - if (ret == _FAIL) - return -EPERM; + if (ret == _FAIL) { + ret = -EPERM; + goto exit; + } sprintf(extra, "mp tx power tracking start, target value =%d ok ", thermal); } else { - kfree(input); - return -EINVAL; + ret = -EINVAL; + goto exit; } } - kfree(input); ret = Hal_SetPowerTracking(padapter, enable); - if (ret == _FAIL) - return -EPERM; + if (ret == _FAIL) { + ret = -EPERM; + goto exit; + } wrqu->length = strlen(extra); - return 0; + +exit: + kfree(input); + return ret; } static int rtw_mp_psd(struct net_device *dev, -- cgit v1.2.3 From c60a9607751ce533681f702d1575638ad7419c04 Mon Sep 17 00:00:00 2001 From: Christian Engelmayer Date: Wed, 7 May 2014 21:42:27 +0200 Subject: staging: rtl8188eu: fix potential leak in update_bcn_wps_ie() Fix a potential leak in the error path of function update_bcn_wps_ie(). Move the affected input verification to the beginning of the function so that it may return directly without leaking already allocated memory. Detected by Coverity - CID 1077718. Signed-off-by: Christian Engelmayer Acked-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c index ff74d0d7efa3..85fda6128db9 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ap.c +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c @@ -1306,6 +1306,10 @@ static void update_bcn_wps_ie(struct adapter *padapter) DBG_88E("%s\n", __func__); + pwps_ie_src = pmlmepriv->wps_beacon_ie; + if (pwps_ie_src == NULL) + return; + pwps_ie = rtw_get_wps_ie(ie+_FIXED_IE_LENGTH_, ielen-_FIXED_IE_LENGTH_, NULL, &wps_ielen); if (pwps_ie == NULL || wps_ielen == 0) @@ -1323,10 +1327,6 @@ static void update_bcn_wps_ie(struct adapter *padapter) memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); } - pwps_ie_src = pmlmepriv->wps_beacon_ie; - if (pwps_ie_src == NULL) - return; - wps_ielen = (uint)pwps_ie_src[1];/* to get ie data len */ if ((wps_offset+wps_ielen+2+remainder_ielen) <= MAX_IE_SZ) { memcpy(pwps_ie, pwps_ie_src, wps_ielen+2); -- cgit v1.2.3 From e0c49319774f06fa7d2bf4731640c2ec1c6847be Mon Sep 17 00:00:00 2001 From: Christian Engelmayer Date: Wed, 7 May 2014 21:39:02 +0200 Subject: staging: rtl8188eu: fix potential leak in rtw_set_key() Fix a potential leak in the error path of rtw_set_key(). In case the requested algorithm is not supported by the driver, the function returns without enqueuing or freeing the already allocated command and parameter structs. Use a centralized exit path and make sure that all memory is freed correctly. Detected by Coverity - CID 1077716, 1077717. Signed-off-by: Christian Engelmayer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 769d4ddc6754..155282ef78fb 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -1727,15 +1727,13 @@ int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, in int res = _SUCCESS; pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (pcmd == NULL) { - res = _FAIL; /* try again */ - goto exit; - } + if (pcmd == NULL) + return _FAIL; /* try again */ + psetkeyparm = (struct setkey_parm *)rtw_zmalloc(sizeof(struct setkey_parm)); if (psetkeyparm == NULL) { - kfree(pcmd); res = _FAIL; - goto exit; + goto err_free_cmd; } _rtw_memset(psetkeyparm, 0, sizeof(struct setkey_parm)); @@ -1784,7 +1782,7 @@ int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, in ("\n rtw_set_key:psecuritypriv->dot11PrivacyAlgrthm=%x (must be 1 or 2 or 4 or 5)\n", psecuritypriv->dot11PrivacyAlgrthm)); res = _FAIL; - goto exit; + goto err_free_parm; } pcmd->cmdcode = _SetKey_CMD_; pcmd->parmbuf = (u8 *)psetkeyparm; @@ -1793,7 +1791,12 @@ int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, in pcmd->rspsz = 0; _rtw_init_listhead(&pcmd->list); res = rtw_enqueue_cmd(pcmdpriv, pcmd); -exit: + return res; + +err_free_parm: + kfree(psetkeyparm); +err_free_cmd: + kfree(pcmd); return res; } -- cgit v1.2.3 From 9eb6f16dfe958e0de659f671809e9f9e31e443ae Mon Sep 17 00:00:00 2001 From: Christian Engelmayer Date: Sat, 17 May 2014 12:38:57 +0200 Subject: staging: rtl8188eu: fix usage of uninit scalar in rtw_drv_init() Function rtw_drv_init() is written in a way that assumes 'status' != _SUCCESS as long as not explicitly set. Thus initialize 'status' to FAIL, in order to prevent undefined behaviour if going through the exit paths. Detected by Coverity - CID 1077832. Signed-off-by: Christian Engelmayer Acked-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index e8ccb576b4b5..86f0ab9ef727 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -686,7 +686,7 @@ static void rtw_usb_if1_deinit(struct adapter *if1) static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device_id *pdid) { struct adapter *if1 = NULL; - int status; + int status = _FAIL; struct dvobj_priv *dvobj; RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_drv_init\n")); -- cgit v1.2.3 From b8f6ad086078fa1892b9db62ba01f321d936dd67 Mon Sep 17 00:00:00 2001 From: Christian Engelmayer Date: Sat, 17 May 2014 12:38:58 +0200 Subject: staging: rtl8188eu: remove dead code in rtw_drv_init() (status != _SUCCESS) immediately after 'status = _SUCCESS' will never evaluate true. Thus remove the logically dead code. Detected by Coverity - CID 1077553. Signed-off-by: Christian Engelmayer Acked-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index 86f0ab9ef727..ed9c6a112759 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -714,8 +714,6 @@ static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device status = _SUCCESS; - if (status != _SUCCESS && if1) - rtw_usb_if1_deinit(if1); free_dvobj: if (status != _SUCCESS) usb_dvobj_deinit(pusb_intf); -- cgit v1.2.3 From 5751dfc11f5c300fd723dca50976211262f89882 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 18 May 2014 20:48:54 +0530 Subject: staging: rtl8188eu: Remove function with empty definition _InitBeaconMaxError(). Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/usb_halinit.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index 617e4c68dfa1..9ce617331ce9 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -420,10 +420,6 @@ static void _InitEDCA(struct adapter *Adapter) rtw_write32(Adapter, REG_EDCA_VO_PARAM, 0x002FA226); } -static void _InitBeaconMaxError(struct adapter *Adapter, bool InfraMode) -{ -} - static void _InitRDGSetting(struct adapter *Adapter) { rtw_write8(Adapter, REG_RD_CTRL, 0xFF); @@ -830,12 +826,8 @@ static u32 rtl8188eu_hal_init(struct adapter *Adapter) InitUsbAggregationSetting(Adapter); _InitOperationMode(Adapter);/* todo */ _InitBeaconParameters(Adapter); - _InitBeaconMaxError(Adapter, true); - - /* */ /* Init CR MACTXEN, MACRXEN after setting RxFF boundary REG_TRXFF_BNDY to patch */ /* Hw bug which Hw initials RxFF boundary size to a value which is larger than the real Rx buffer size in 88E. */ - /* */ /* Enable MACTXEN/MACRXEN block */ value16 = rtw_read16(Adapter, REG_CR); value16 |= (MACTXEN | MACRXEN); -- cgit v1.2.3 From 8a39ec22bf180c1e093f1d1fcbb106eb3e2e022d Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 18 May 2014 20:48:55 +0530 Subject: staging: rtl8188eu: Remove function with empty definition _InitOperationMode() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/usb_halinit.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index 9ce617331ce9..2e7b81ce087b 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -583,10 +583,6 @@ static void InitUsbAggregationSetting(struct adapter *Adapter) haldata->UsbRxHighSpeedMode = false; } -static void _InitOperationMode(struct adapter *Adapter) -{ -} - static void _InitBeaconParameters(struct adapter *Adapter) { struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); @@ -824,7 +820,6 @@ static u32 rtl8188eu_hal_init(struct adapter *Adapter) _InitEDCA(Adapter); _InitRetryFunction(Adapter); InitUsbAggregationSetting(Adapter); - _InitOperationMode(Adapter);/* todo */ _InitBeaconParameters(Adapter); /* Init CR MACTXEN, MACRXEN after setting RxFF boundary REG_TRXFF_BNDY to patch */ /* Hw bug which Hw initials RxFF boundary size to a value which is larger than the real Rx buffer size in 88E. */ -- cgit v1.2.3 From 0f657d1bf07456a495562f9fd075ad26f40e7a4c Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 18 May 2014 20:48:56 +0530 Subject: staging: rtl8188eu: Remove function with empty definition _ps_open_RF() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/usb_halinit.c | 7 ------- drivers/staging/rtl8188eu/include/rtl8188e_hal.h | 1 - 2 files changed, 8 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index 2e7b81ce087b..2fe11351d2df 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -693,7 +693,6 @@ static u32 rtl8188eu_hal_init(struct adapter *Adapter) HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_BEGIN); if (Adapter->pwrctrlpriv.bkeepfwalive) { - _ps_open_RF(Adapter); if (haldata->odmpriv.RFCalibrateInfo.bIQKInitialized) { PHY_IQCalibrate_8188E(Adapter, true); @@ -943,12 +942,6 @@ HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_END); return status; } -void _ps_open_RF(struct adapter *adapt) -{ - /* here call with bRegSSPwrLvl 1, bRegSSPwrLvl 2 needs to be verified */ - /* phy_SsPwrSwitch92CU(adapt, rf_on, 1); */ -} - static void _ps_close_RF(struct adapter *adapt) { /* here call with bRegSSPwrLvl 1, bRegSSPwrLvl 2 needs to be verified */ diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h index 75e41c4aeb27..fe3b4545cdbb 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h @@ -471,6 +471,5 @@ void rtl8188e_stop_thread(struct adapter *padapter); void rtw_IOL_cmd_tx_pkt_buf_dump(struct adapter *Adapter, int len); s32 rtl8188e_iol_efuse_patch(struct adapter *padapter); void rtw_cancel_all_timer(struct adapter *padapter); -void _ps_open_RF(struct adapter *adapt); #endif /* __RTL8188E_HAL_H__ */ -- cgit v1.2.3 From 3cf2f015d5dfcde34d66ae6a4b5ba6df048339e0 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 18 May 2014 20:48:57 +0530 Subject: staging: rtl8188eu: Remove unused function _ps_close_RF() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/usb_halinit.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index 2fe11351d2df..1a83d3174736 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -942,12 +942,6 @@ HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_END); return status; } -static void _ps_close_RF(struct adapter *adapt) -{ - /* here call with bRegSSPwrLvl 1, bRegSSPwrLvl 2 needs to be verified */ - /* phy_SsPwrSwitch92CU(adapt, rf_off, 1); */ -} - static void CardDisableRTL8188EU(struct adapter *Adapter) { u8 val8; @@ -1025,7 +1019,6 @@ static u32 rtl8188eu_hal_deinit(struct adapter *Adapter) DBG_88E("bkeepfwalive(%x)\n", Adapter->pwrctrlpriv.bkeepfwalive); if (Adapter->pwrctrlpriv.bkeepfwalive) { - _ps_close_RF(Adapter); if ((Adapter->pwrctrlpriv.bHWPwrPindetect) && (Adapter->pwrctrlpriv.bHWPowerdown)) rtl8192cu_hw_power_down(Adapter); } else { -- cgit v1.2.3 From 994d77817a6f1a7b62f3ec1cb8268df777944287 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 18 May 2014 20:48:59 +0530 Subject: staging:rtl8188eu:Remove funtion Hal_CustomizeByCustomerID_8188EU() Function has empty defination. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/usb_halinit.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index 1a83d3174736..0cb84aed4533 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -1133,10 +1133,6 @@ static void Hal_EfuseParseMACAddr_8188EU(struct adapter *adapt, u8 *hwinfo, bool eeprom->mac_addr[4], eeprom->mac_addr[5])); } -static void Hal_CustomizeByCustomerID_8188EU(struct adapter *adapt) -{ -} - static void readAdapterInfo_8188EU( struct adapter *adapt @@ -1163,7 +1159,6 @@ readAdapterInfo_8188EU( /* The following part initialize some vars by PG info. */ /* */ Hal_InitChannelPlan(adapt); - Hal_CustomizeByCustomerID_8188EU(adapt); } static void _ReadPROMContent( -- cgit v1.2.3 From b204bc24feca4325e857d78e8b4e558814028776 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 18 May 2014 20:49:00 +0530 Subject: staging: rtl8188eu: Remove unused function rtl8188e_PHY_ConfigRFWithParaFile() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c b/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c index 8079fc678615..b50df3e6729d 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c @@ -631,27 +631,6 @@ int PHY_RFConfig8188E(struct adapter *Adapter) return rtStatus; } - -/*----------------------------------------------------------------------------- - * Function: PHY_ConfigRFWithParaFile() - * - * Overview: This function read RF parameters from general file format, and do RF 3-wire - * - * Input: struct adapter *Adapter - * ps8 pFileName - * enum rf_radio_path eRFPath - * - * Output: NONE - * - * Return: RT_STATUS_SUCCESS: configuration file exist - * - * Note: Delay may be required for RF configuration - *---------------------------------------------------------------------------*/ -int rtl8188e_PHY_ConfigRFWithParaFile(struct adapter *Adapter, u8 *pFileName, enum rf_radio_path eRFPath) -{ - return _SUCCESS; -} - void rtl8192c_PHY_GetHWRegOriginalValue( struct adapter *Adapter -- cgit v1.2.3 From 9578c308203e8f736de0c58c08d335a9dd35a093 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 18 May 2014 20:49:01 +0530 Subject: staging: rtl8188eu: Remove unused function rtl8192c_PHY_GetHWRegOriginalValue() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c b/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c index b50df3e6729d..79f86db354d3 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c @@ -631,24 +631,6 @@ int PHY_RFConfig8188E(struct adapter *Adapter) return rtStatus; } -void -rtl8192c_PHY_GetHWRegOriginalValue( - struct adapter *Adapter - ) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - - /* read rx initial gain */ - pHalData->DefaultInitialGain[0] = (u8)PHY_QueryBBReg(Adapter, rOFDM0_XAAGCCore1, bMaskByte0); - pHalData->DefaultInitialGain[1] = (u8)PHY_QueryBBReg(Adapter, rOFDM0_XBAGCCore1, bMaskByte0); - pHalData->DefaultInitialGain[2] = (u8)PHY_QueryBBReg(Adapter, rOFDM0_XCAGCCore1, bMaskByte0); - pHalData->DefaultInitialGain[3] = (u8)PHY_QueryBBReg(Adapter, rOFDM0_XDAGCCore1, bMaskByte0); - - /* read framesync */ - pHalData->framesync = (u8)PHY_QueryBBReg(Adapter, rOFDM0_RxDetector3, bMaskByte0); - pHalData->framesyncC34 = PHY_QueryBBReg(Adapter, rOFDM0_RxDetector2, bMaskDWord); -} - /* */ /* Description: */ /* Map dBm into Tx power index according to */ -- cgit v1.2.3 From ba814a247e3bb077c4ab0e6445d12dbb68184812 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 18 May 2014 20:49:02 +0530 Subject: staging: rtl8188eu: Remove unused function PHY_UpdateTxPowerDbm8188E() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c | 37 ---------------------- drivers/staging/rtl8188eu/include/Hal8188EPhyCfg.h | 1 - 2 files changed, 38 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c b/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c index 79f86db354d3..7cc7f4423453 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c @@ -878,43 +878,6 @@ PHY_SetTxPowerLevel8188E( rtl8188e_PHY_RF6052SetOFDMTxPower(Adapter, &ofdmPowerLevel[0], &BW20PowerLevel[0], &BW40PowerLevel[0], channel); } -/* */ -/* Description: */ -/* Update transmit power level of all channel supported. */ -/* */ -/* TODO: */ -/* A mode. */ -/* By Bruce, 2008-02-04. */ -/* */ -bool -PHY_UpdateTxPowerDbm8188E( - struct adapter *Adapter, - int powerInDbm - ) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - u8 idx; - u8 rf_path; - - /* TODO: A mode Tx power. */ - u8 CckTxPwrIdx = phy_DbmToTxPwrIdx(Adapter, WIRELESS_MODE_B, powerInDbm); - u8 OfdmTxPwrIdx = phy_DbmToTxPwrIdx(Adapter, WIRELESS_MODE_N_24G, powerInDbm); - - if (OfdmTxPwrIdx - pHalData->LegacyHTTxPowerDiff > 0) - OfdmTxPwrIdx -= pHalData->LegacyHTTxPowerDiff; - else - OfdmTxPwrIdx = 0; - - for (idx = 0; idx < 14; idx++) { - for (rf_path = 0; rf_path < 2; rf_path++) { - pHalData->TxPwrLevelCck[rf_path][idx] = CckTxPwrIdx; - pHalData->TxPwrLevelHT40_1S[rf_path][idx] = - pHalData->TxPwrLevelHT40_2S[rf_path][idx] = OfdmTxPwrIdx; - } - } - return true; -} - void PHY_ScanOperationBackup8188E( struct adapter *Adapter, diff --git a/drivers/staging/rtl8188eu/include/Hal8188EPhyCfg.h b/drivers/staging/rtl8188eu/include/Hal8188EPhyCfg.h index 25cae8147e73..260ea6bf9e83 100644 --- a/drivers/staging/rtl8188eu/include/Hal8188EPhyCfg.h +++ b/drivers/staging/rtl8188eu/include/Hal8188EPhyCfg.h @@ -224,7 +224,6 @@ void rtl8192c_PHY_GetHWRegOriginalValue(struct adapter *adapter); /* BB TX Power R/W */ void PHY_GetTxPowerLevel8188E(struct adapter *adapter, u32 *powerlevel); void PHY_SetTxPowerLevel8188E(struct adapter *adapter, u8 channel); -bool PHY_UpdateTxPowerDbm8188E(struct adapter *adapter, int power); void PHY_ScanOperationBackup8188E(struct adapter *Adapter, u8 Operation); -- cgit v1.2.3 From aae8993ce35d1f01c8901170e5f5534a59dfb8e7 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 18 May 2014 20:49:03 +0530 Subject: staging:rtl8188eu: Remove unused function phy_DbmToTxPwrIdx() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c | 44 ------------------------- 1 file changed, 44 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c b/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c index 7cc7f4423453..16f46c39a25c 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c @@ -631,50 +631,6 @@ int PHY_RFConfig8188E(struct adapter *Adapter) return rtStatus; } -/* */ -/* Description: */ -/* Map dBm into Tx power index according to */ -/* current HW model, for example, RF and PA, and */ -/* current wireless mode. */ -/* By Bruce, 2008-01-29. */ -/* */ -static u8 phy_DbmToTxPwrIdx(struct adapter *Adapter, enum wireless_mode WirelessMode, int PowerInDbm) -{ - u8 TxPwrIdx = 0; - int Offset = 0; - - - /* */ - /* Tested by MP, we found that CCK Index 0 equals to 8dbm, OFDM legacy equals to */ - /* 3dbm, and OFDM HT equals to 0dbm respectively. */ - /* Note: */ - /* The mapping may be different by different NICs. Do not use this formula for what needs accurate result. */ - /* By Bruce, 2008-01-29. */ - /* */ - switch (WirelessMode) { - case WIRELESS_MODE_B: - Offset = -7; - break; - - case WIRELESS_MODE_G: - case WIRELESS_MODE_N_24G: - default: - Offset = -8; - break; - } - - if ((PowerInDbm - Offset) > 0) - TxPwrIdx = (u8)((PowerInDbm - Offset) * 2); - else - TxPwrIdx = 0; - - /* Tx Power Index is too large. */ - if (TxPwrIdx > MAX_TXPWR_IDX_NMODE_92S) - TxPwrIdx = MAX_TXPWR_IDX_NMODE_92S; - - return TxPwrIdx; -} - /* */ /* Description: */ /* Map Tx power index into dBm according to */ -- cgit v1.2.3 From 9a696fe1d8feb09d9a7b406da3bc66aba9a3e973 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 18 May 2014 20:49:04 +0530 Subject: staging: rtl8188eu: Remove unused funtion PHY_GetTxPowerLevel8188E() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c | 46 ------------------------- 1 file changed, 46 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c b/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c index 16f46c39a25c..099345f44fec 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c @@ -665,52 +665,6 @@ static int phy_TxPwrIdxToDbm(struct adapter *Adapter, enum wireless_mode Wireles return PwrOutDbm; } - -/*----------------------------------------------------------------------------- - * Function: GetTxPowerLevel8190() - * - * Overview: This function is export to "common" moudule - * - * Input: struct adapter *Adapter - * psByte Power Level - * - * Output: NONE - * - * Return: NONE - * - *---------------------------------------------------------------------------*/ -void PHY_GetTxPowerLevel8188E(struct adapter *Adapter, u32 *powerlevel) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - u8 TxPwrLevel = 0; - int TxPwrDbm; - - /* */ - /* Because the Tx power indexes are different, we report the maximum of them to */ - /* meet the CCX TPC request. By Bruce, 2008-01-31. */ - /* */ - - /* CCK */ - TxPwrLevel = pHalData->CurrentCckTxPwrIdx; - TxPwrDbm = phy_TxPwrIdxToDbm(Adapter, WIRELESS_MODE_B, TxPwrLevel); - - /* Legacy OFDM */ - TxPwrLevel = pHalData->CurrentOfdm24GTxPwrIdx + pHalData->LegacyHTTxPowerDiff; - - /* Compare with Legacy OFDM Tx power. */ - if (phy_TxPwrIdxToDbm(Adapter, WIRELESS_MODE_G, TxPwrLevel) > TxPwrDbm) - TxPwrDbm = phy_TxPwrIdxToDbm(Adapter, WIRELESS_MODE_G, TxPwrLevel); - - /* HT OFDM */ - TxPwrLevel = pHalData->CurrentOfdm24GTxPwrIdx; - - /* Compare with HT OFDM Tx power. */ - if (phy_TxPwrIdxToDbm(Adapter, WIRELESS_MODE_N_24G, TxPwrLevel) > TxPwrDbm) - TxPwrDbm = phy_TxPwrIdxToDbm(Adapter, WIRELESS_MODE_N_24G, TxPwrLevel); - - *powerlevel = TxPwrDbm; -} - static void getTxPowerIndex88E(struct adapter *Adapter, u8 channel, u8 *cckPowerLevel, u8 *ofdmPowerLevel, u8 *BW20PowerLevel, u8 *BW40PowerLevel) -- cgit v1.2.3 From a25d2594a6b230222cffc9342c55c68a99e8a386 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 18 May 2014 20:49:05 +0530 Subject: staging: rtl8188eu: Remove unused funtion phy_TxPwrIdxToDbm() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c | 34 ------------------------- 1 file changed, 34 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c b/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c index 099345f44fec..a7872c89e417 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c @@ -631,40 +631,6 @@ int PHY_RFConfig8188E(struct adapter *Adapter) return rtStatus; } -/* */ -/* Description: */ -/* Map Tx power index into dBm according to */ -/* current HW model, for example, RF and PA, and */ -/* current wireless mode. */ -/* By Bruce, 2008-01-29. */ -/* */ -static int phy_TxPwrIdxToDbm(struct adapter *Adapter, enum wireless_mode WirelessMode, u8 TxPwrIdx) -{ - int Offset = 0; - int PwrOutDbm = 0; - - /* */ - /* Tested by MP, we found that CCK Index 0 equals to -7dbm, OFDM legacy equals to -8dbm. */ - /* Note: */ - /* The mapping may be different by different NICs. Do not use this formula for what needs accurate result. */ - /* By Bruce, 2008-01-29. */ - /* */ - switch (WirelessMode) { - case WIRELESS_MODE_B: - Offset = -7; - break; - case WIRELESS_MODE_G: - case WIRELESS_MODE_N_24G: - default: - Offset = -8; - break; - } - - PwrOutDbm = TxPwrIdx / 2 + Offset; /* Discard the decimal part. */ - - return PwrOutDbm; -} - static void getTxPowerIndex88E(struct adapter *Adapter, u8 channel, u8 *cckPowerLevel, u8 *ofdmPowerLevel, u8 *BW20PowerLevel, u8 *BW40PowerLevel) -- cgit v1.2.3 From 914df7f88737d2118b9f348779e26aac65a19a06 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 18 May 2014 21:02:18 +0530 Subject: staging: rtl8188eu: Remove unused funtion PHY_ScanOperationBackup8188E() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c b/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c index a7872c89e417..941ff7467c3c 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c @@ -754,14 +754,6 @@ PHY_SetTxPowerLevel8188E( rtl8188e_PHY_RF6052SetOFDMTxPower(Adapter, &ofdmPowerLevel[0], &BW20PowerLevel[0], &BW40PowerLevel[0], channel); } -void -PHY_ScanOperationBackup8188E( - struct adapter *Adapter, - u8 Operation - ) -{ -} - /*----------------------------------------------------------------------------- * Function: PHY_SetBWModeCallback8192C() * -- cgit v1.2.3 From 0149a62fee9a851e28200f8f2c4dd9017b18a647 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 18 May 2014 20:49:07 +0530 Subject: staging: rtl8188eu: Remove unused structure rf_shadow Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188e_rf6052.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_rf6052.c b/drivers/staging/rtl8188eu/hal/rtl8188e_rf6052.c index b1cb5c4a6fd6..2f1348fdae3e 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_rf6052.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_rf6052.c @@ -46,28 +46,6 @@ #include -/*---------------------------Define Local Constant---------------------------*/ -/* Define local structure for debug!!!!! */ -struct rf_shadow { - /* Shadow register value */ - u32 Value; - /* Compare or not flag */ - u8 Compare; - /* Record If it had ever modified unpredicted */ - u8 ErrorOrNot; - /* Recorver Flag */ - u8 Recorver; - /* */ - u8 Driver_Write; -}; - -/*---------------------------Define Local Constant---------------------------*/ - - -/*------------------------Define global variable-----------------------------*/ - -/*------------------------Define local variable------------------------------*/ - /*----------------------------------------------------------------------------- * Function: RF_ChangeTxPath * -- cgit v1.2.3 From ef8e0baed664d602ce1758f9a330bdf8414f50e4 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 18 May 2014 20:49:08 +0530 Subject: staging: rtl8188eu: Remove unused function rtl8188e_RF_ChangeTxPath() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188e_rf6052.c | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_rf6052.c b/drivers/staging/rtl8188eu/hal/rtl8188e_rf6052.c index 2f1348fdae3e..52103da3e264 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_rf6052.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_rf6052.c @@ -46,29 +46,6 @@ #include -/*----------------------------------------------------------------------------- - * Function: RF_ChangeTxPath - * - * Overview: For RL6052, we must change some RF settign for 1T or 2T. - * - * Input: u16 DataRate 0x80-8f, 0x90-9f - * - * Output: NONE - * - * Return: NONE - * - * Revised History: - * When Who Remark - * 09/25/2008 MHC Create Version 0. - * Firmwaer support the utility later. - * - *---------------------------------------------------------------------------*/ -void rtl8188e_RF_ChangeTxPath(struct adapter *Adapter, u16 DataRate) -{ -/* We do not support gain table change inACUT now !!!! Delete later !!! */ -} /* RF_ChangeTxPath */ - - /*----------------------------------------------------------------------------- * Function: PHY_RF6052SetBandwidth() * -- cgit v1.2.3 From ffb2507078ec820007c09c82c356ca7694c31824 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 18 May 2014 20:49:09 +0530 Subject: staging: rtl8188eu: Remove unused function odm_DIGbyRSSI_LPS() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm.c | 45 ------------------------------------- 1 file changed, 45 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index 89a26e3e217f..d8482ab4a349 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -529,51 +529,6 @@ void ODM_Write_DIG(struct odm_dm_struct *pDM_Odm, u8 CurrentIGI) /* Add by Neil Chen to enable edcca to MP Platform */ } -/* Need LPS mode for CE platform --2012--08--24--- */ -/* 8723AS/8189ES */ -void odm_DIGbyRSSI_LPS(struct odm_dm_struct *pDM_Odm) -{ - struct adapter *pAdapter = pDM_Odm->Adapter; - struct false_alarm_stats *pFalseAlmCnt = &pDM_Odm->FalseAlmCnt; - - u8 RSSI_Lower = DM_DIG_MIN_NIC; /* 0x1E or 0x1C */ - u8 bFwCurrentInPSMode = false; - u8 CurrentIGI = pDM_Odm->RSSI_Min; - - CurrentIGI = CurrentIGI + RSSI_OFFSET_DIG; - bFwCurrentInPSMode = pAdapter->pwrctrlpriv.bFwCurrentInPSMode; - - /* Using FW PS mode to make IGI */ - if (bFwCurrentInPSMode) { - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("---Neil---odm_DIG is in LPS mode\n")); - /* Adjust by FA in LPS MODE */ - if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH2_LPS) - CurrentIGI = CurrentIGI+2; - else if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH1_LPS) - CurrentIGI = CurrentIGI+1; - else if (pFalseAlmCnt->Cnt_all < DM_DIG_FA_TH0_LPS) - CurrentIGI = CurrentIGI-1; - } else { - CurrentIGI = RSSI_Lower; - } - - /* Lower bound checking */ - - /* RSSI Lower bound check */ - if ((pDM_Odm->RSSI_Min-10) > DM_DIG_MIN_NIC) - RSSI_Lower = (pDM_Odm->RSSI_Min-10); - else - RSSI_Lower = DM_DIG_MIN_NIC; - - /* Upper and Lower Bound checking */ - if (CurrentIGI > DM_DIG_MAX_NIC) - CurrentIGI = DM_DIG_MAX_NIC; - else if (CurrentIGI < RSSI_Lower) - CurrentIGI = RSSI_Lower; - - ODM_Write_DIG(pDM_Odm, CurrentIGI);/* ODM_Write_DIG(pDM_Odm, pDM_DigTable->CurIGValue); */ -} - void odm_DIGInit(struct odm_dm_struct *pDM_Odm) { struct adapter *adapter = pDM_Odm->Adapter; -- cgit v1.2.3 From 86ff64405ec14d7c01edd5fdb40cc338872728c0 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 18 May 2014 20:49:10 +0530 Subject: staging: rtl8188eu: Remove function odm_DynamicBBPowerSaving() odm_DynamicBBPowerSaving() has empty defination. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index d8482ab4a349..2e105b4b1646 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -183,7 +183,6 @@ void ODM_DMInit(struct odm_dm_struct *pDM_Odm) odm_RateAdaptiveMaskInit(pDM_Odm); odm_PrimaryCCA_Init(pDM_Odm); /* Gary */ - odm_DynamicBBPowerSavingInit(pDM_Odm); odm_DynamicTxPowerInit(pDM_Odm); odm_TXPowerTrackingInit(pDM_Odm); ODM_EdcaTurboInit(pDM_Odm); @@ -215,7 +214,6 @@ void ODM_DMWatchdog(struct odm_dm_struct *pDM_Odm) odm_RefreshRateAdaptiveMask(pDM_Odm); - odm_DynamicBBPowerSaving(pDM_Odm); odm_DynamicPrimaryCCA(pDM_Odm); if ((pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV) || (pDM_Odm->AntDivType == CGCS_RX_HW_ANTDIV) || @@ -865,10 +863,6 @@ void odm_DynamicBBPowerSavingInit(struct odm_dm_struct *pDM_Odm) pDM_PSTable->initialize = 0; } -void odm_DynamicBBPowerSaving(struct odm_dm_struct *pDM_Odm) -{ -} - void odm_1R_CCA(struct odm_dm_struct *pDM_Odm) { struct adapter *adapter = pDM_Odm->Adapter; -- cgit v1.2.3 From 06dd47e3b6342f191fb1e6cfdfdacebc37088af2 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 18 May 2014 20:49:11 +0530 Subject: staging: rtl8188eu: Remove unused function odm_DynamicBBPowerSavingInit() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index 2e105b4b1646..e8ad880ec690 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -848,21 +848,6 @@ void ODM_Write_CCK_CCA_Thres(struct odm_dm_struct *pDM_Odm, u8 CurCCK_CCAThres) pDM_DigTable->CurCCK_CCAThres = CurCCK_CCAThres; } -/* 3============================================================ */ -/* 3 BB Power Save */ -/* 3============================================================ */ -void odm_DynamicBBPowerSavingInit(struct odm_dm_struct *pDM_Odm) -{ - struct rtl_ps *pDM_PSTable = &pDM_Odm->DM_PSTable; - - pDM_PSTable->PreCCAState = CCA_MAX; - pDM_PSTable->CurCCAState = CCA_MAX; - pDM_PSTable->PreRFState = RF_MAX; - pDM_PSTable->CurRFState = RF_MAX; - pDM_PSTable->Rssi_val_min = 0; - pDM_PSTable->initialize = 0; -} - void odm_1R_CCA(struct odm_dm_struct *pDM_Odm) { struct adapter *adapter = pDM_Odm->Adapter; -- cgit v1.2.3 From bd645d88bfbd5aa2b44d99a53837164e7d19fb89 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 18 May 2014 20:49:12 +0530 Subject: staging:rtl8188eu: Remove unused function iodm_1R_CCA() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm.c | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index e8ad880ec690..7319b3e4fe4a 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -848,40 +848,6 @@ void ODM_Write_CCK_CCA_Thres(struct odm_dm_struct *pDM_Odm, u8 CurCCK_CCAThres) pDM_DigTable->CurCCK_CCAThres = CurCCK_CCAThres; } -void odm_1R_CCA(struct odm_dm_struct *pDM_Odm) -{ - struct adapter *adapter = pDM_Odm->Adapter; - struct rtl_ps *pDM_PSTable = &pDM_Odm->DM_PSTable; - - if (pDM_Odm->RSSI_Min != 0xFF) { - if (pDM_PSTable->PreCCAState == CCA_2R) { - if (pDM_Odm->RSSI_Min >= 35) - pDM_PSTable->CurCCAState = CCA_1R; - else - pDM_PSTable->CurCCAState = CCA_2R; - } else { - if (pDM_Odm->RSSI_Min <= 30) - pDM_PSTable->CurCCAState = CCA_2R; - else - pDM_PSTable->CurCCAState = CCA_1R; - } - } else { - pDM_PSTable->CurCCAState = CCA_MAX; - } - - if (pDM_PSTable->PreCCAState != pDM_PSTable->CurCCAState) { - if (pDM_PSTable->CurCCAState == CCA_1R) { - if (pDM_Odm->RFType == ODM_2T2R) - PHY_SetBBReg(adapter, 0xc04, bMaskByte0, 0x13); - else - PHY_SetBBReg(adapter, 0xc04, bMaskByte0, 0x23); - } else { - PHY_SetBBReg(adapter, 0xc04, bMaskByte0, 0x33); - } - pDM_PSTable->PreCCAState = pDM_PSTable->CurCCAState; - } -} - void ODM_RF_Saving(struct odm_dm_struct *pDM_Odm, u8 bForceInNormal) { struct adapter *adapter = pDM_Odm->Adapter; -- cgit v1.2.3 From 53760485ba3575461865db1250e564b53002f0c1 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 18 May 2014 20:49:13 +0530 Subject: staging: rtl8188eu: Remove unused function odm_RefreshRateAdaptiveMaskMP() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index 7319b3e4fe4a..01946ccec841 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -1033,10 +1033,6 @@ void odm_RefreshRateAdaptiveMask(struct odm_dm_struct *pDM_Odm) odm_RefreshRateAdaptiveMaskCE(pDM_Odm); } -void odm_RefreshRateAdaptiveMaskMP(struct odm_dm_struct *pDM_Odm) -{ -} - void odm_RefreshRateAdaptiveMaskCE(struct odm_dm_struct *pDM_Odm) { u8 i; -- cgit v1.2.3 From ba727007e7c0ffa4a1bd4fbeafbe0db269e7faaf Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 18 May 2014 20:49:14 +0530 Subject: staging: rtl8188eu: Remove unused function odm_RefreshRateAdaptiveMaskAPADSL() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index 01946ccec841..cc731885e8b8 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -1061,10 +1061,6 @@ void odm_RefreshRateAdaptiveMaskCE(struct odm_dm_struct *pDM_Odm) } } -void odm_RefreshRateAdaptiveMaskAPADSL(struct odm_dm_struct *pDM_Odm) -{ -} - /* Return Value: bool */ /* - true: RATRState is changed. */ bool ODM_RAStateCheck(struct odm_dm_struct *pDM_Odm, s32 RSSI, bool bForceUpdate, u8 *pRATRState) -- cgit v1.2.3 From 36622c97f07563dc0c42cfe1c9283701fadfb15f Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 18 May 2014 20:49:15 +0530 Subject: staging: rtl8188eu: Remove unused funtion odm_DynamicTxPowerNIC() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index cc731885e8b8..8dd5f7eefebb 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -1131,15 +1131,6 @@ void odm_DynamicTxPower(struct odm_dm_struct *pDM_Odm) /* 2012/01/12 MH According to Luke's suggestion, only high power will support the feature. */ if (!pDM_Odm->ExtPA) return; - - /* 2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate */ - /* at the same time. In the stage2/3, we need to prive universal interface and merge all */ - /* HW dynamic mechanism. */ - odm_DynamicTxPowerNIC(pDM_Odm); -} - -void odm_DynamicTxPowerNIC(struct odm_dm_struct *pDM_Odm) -{ } /* 3============================================================ */ -- cgit v1.2.3 From ddd0d4808510207c2447718fc04c0c545d1a8a60 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 18 May 2014 20:49:16 +0530 Subject: staging: rtl8188eu: Remove unused function odm_SwAntDivChkAntSwitchCallback() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index 8dd5f7eefebb..44421814bcdf 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -1269,22 +1269,6 @@ void odm_TXPowerTrackingCheckCE(struct odm_dm_struct *pDM_Odm) } } -/* antenna mapping info */ -/* 1: right-side antenna */ -/* 2/0: left-side antenna */ -/* PDM_SWAT_Table->CCK_Ant1_Cnt /OFDM_Ant1_Cnt: for right-side antenna: Ant:1 RxDefaultAnt1 */ -/* PDM_SWAT_Table->CCK_Ant2_Cnt /OFDM_Ant2_Cnt: for left-side antenna: Ant:0 RxDefaultAnt2 */ -/* We select left antenna as default antenna in initial process, modify it as needed */ -/* */ - -/* 3============================================================ */ -/* 3 SW Antenna Diversity */ -/* 3============================================================ */ - -void odm_SwAntDivChkAntSwitchCallback(void *FunctionContext) -{ -} - /* 3============================================================ */ /* 3 SW Antenna Diversity */ /* 3============================================================ */ -- cgit v1.2.3 From 293f6c08c72a0a0482f099082946ce691b360871 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 18 May 2014 20:49:17 +0530 Subject: staging: rtl8188eu: Remove unused function ConvertTo_dB() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm.c | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index 44421814bcdf..425c50a4185a 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -1394,28 +1394,3 @@ dm_CheckEdcaTurbo_EXIT: pxmitpriv->last_tx_bytes = pxmitpriv->tx_bytes; precvpriv->last_rx_bytes = precvpriv->rx_bytes; } - -u32 ConvertTo_dB(u32 Value) -{ - u8 i; - u8 j; - u32 dB; - - Value = Value & 0xFFFF; - for (i = 0; i < 8; i++) { - if (Value <= dB_Invert_Table[i][11]) - break; - } - - if (i >= 8) - return 96; /* maximum 96 dB */ - - for (j = 0; j < 12; j++) { - if (Value <= dB_Invert_Table[i][j]) - break; - } - - dB = i*12 + j + 1; - - return dB; -} -- cgit v1.2.3 From 2c4c9a514a3d9a1415a118f731b4f9a06e4717f4 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 18 May 2014 20:49:18 +0530 Subject: staging: rtl8188eu: Remove function with empty defination ODM_CheckPowerStatus() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c b/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c index 056052ddd82e..7c22658ed0f1 100644 --- a/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c +++ b/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c @@ -804,24 +804,12 @@ static void pathb_fill_iqk(struct adapter *adapt, bool iqkok, s32 result[][8], u } } -/* */ -/* 2011/07/26 MH Add an API for testing IQK fail case. */ -/* */ -/* MP Already declare in odm.c */ -static bool ODM_CheckPowerStatus(struct adapter *Adapter) -{ - return true; -} - void _PHY_SaveADDARegisters(struct adapter *adapt, u32 *ADDAReg, u32 *ADDABackup, u32 RegisterNum) { u32 i; struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - if (!ODM_CheckPowerStatus(adapt)) - return; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Save ADDA parameters.\n")); for (i = 0; i < RegisterNum; i++) { ADDABackup[i] = PHY_QueryBBReg(adapt, ADDAReg[i], bMaskDWord); @@ -1294,8 +1282,6 @@ void PHY_IQCalibrate_8188E(struct adapter *adapt, bool recovery) bool is2t; is2t = (dm_odm->RFType == ODM_2T2R) ? true : false; - if (!ODM_CheckPowerStatus(adapt)) - return; if (!(dm_odm->SupportAbility & ODM_RF_CALIBRATION)) return; -- cgit v1.2.3 From 5aac98ab1ee6e6986dc539a5aaa7b8d0cc797beb Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 18 May 2014 20:49:19 +0530 Subject: staging: rtl8188eu: Remove unused function DM_DIG_LowerBound_88E() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm_RTL8188E.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c b/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c index 323eb93be41e..7c1043cffed8 100644 --- a/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c +++ b/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c @@ -20,18 +20,6 @@ #include "odm_precomp.h" -void ODM_DIG_LowerBound_88E(struct odm_dm_struct *dm_odm) -{ - struct rtw_dig *pDM_DigTable = &dm_odm->DM_DigTable; - - if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) { - pDM_DigTable->rx_gain_range_min = (u8) pDM_DigTable->AntDiv_RSSI_max; - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, - ("ODM_DIG_LowerBound_88E(): pDM_DigTable->AntDiv_RSSI_max=%d\n", pDM_DigTable->AntDiv_RSSI_max)); - } - /* If only one Entry connected */ -} - static void odm_RX_HWAntDivInit(struct odm_dm_struct *dm_odm) { struct adapter *adapter = dm_odm->Adapter; -- cgit v1.2.3 From fce87279a0a52d87dd32dde9bffbe632ea1d435a Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 18 May 2014 20:49:20 +0530 Subject: staging: rtl8188eu: Remove unused function ODM_DynamicPrimaryCCA_DupRTS() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm_RTL8188E.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c b/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c index 7c1043cffed8..a90b2c54d2fc 100644 --- a/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c +++ b/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c @@ -377,13 +377,6 @@ void odm_PrimaryCCA_Init(struct odm_dm_struct *dm_odm) PrimaryCCA->PriCCA_flag = 0; } -bool ODM_DynamicPrimaryCCA_DupRTS(struct odm_dm_struct *dm_odm) -{ - struct dyn_primary_cca *PrimaryCCA = &(dm_odm->DM_PriCCA); - - return PrimaryCCA->DupRTS_flag; -} - void odm_DynamicPrimaryCCA(struct odm_dm_struct *dm_odm) { return; -- cgit v1.2.3 From b5e1e9126a4957c7653d1c0ee9b6b54089b7d936 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Sun, 18 May 2014 20:49:21 +0530 Subject: staging: rtl8188eu:Remove function with empty defination odm_DynamicPrimaryCCA() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm.c | 1 - drivers/staging/rtl8188eu/hal/odm_RTL8188E.c | 5 ----- drivers/staging/rtl8188eu/include/odm_RTL8188E.h | 2 -- 3 files changed, 8 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index 425c50a4185a..a39eba9f98c5 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -214,7 +214,6 @@ void ODM_DMWatchdog(struct odm_dm_struct *pDM_Odm) odm_RefreshRateAdaptiveMask(pDM_Odm); - odm_DynamicPrimaryCCA(pDM_Odm); if ((pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV) || (pDM_Odm->AntDivType == CGCS_RX_HW_ANTDIV) || (pDM_Odm->AntDivType == CG_TRX_SMART_ANTDIV)) diff --git a/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c b/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c index a90b2c54d2fc..a24d954e2732 100644 --- a/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c +++ b/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c @@ -376,8 +376,3 @@ void odm_PrimaryCCA_Init(struct odm_dm_struct *dm_odm) PrimaryCCA->Monitor_flag = 0; PrimaryCCA->PriCCA_flag = 0; } - -void odm_DynamicPrimaryCCA(struct odm_dm_struct *dm_odm) -{ - return; -} diff --git a/drivers/staging/rtl8188eu/include/odm_RTL8188E.h b/drivers/staging/rtl8188eu/include/odm_RTL8188E.h index f96ad5af4bd5..02ac78d326d2 100644 --- a/drivers/staging/rtl8188eu/include/odm_RTL8188E.h +++ b/drivers/staging/rtl8188eu/include/odm_RTL8188E.h @@ -51,6 +51,4 @@ void odm_PrimaryCCA_Init(struct odm_dm_struct *pDM_Odm); bool ODM_DynamicPrimaryCCA_DupRTS(struct odm_dm_struct *pDM_Odm); -void odm_DynamicPrimaryCCA(struct odm_dm_struct *pDM_Odm); - #endif -- cgit v1.2.3 From d6c455ac1e50d0c2e377aaeae42f62833c771b2b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Mon, 19 May 2014 10:08:19 +0200 Subject: staging: rtl8188eu: Do not byteswap half initialized variable Copying 16 bits into an uninitialized 32 bit stack variable and then byteswapping it can provide 'interesting' results. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index e854732478b8..f5b49f351a6a 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -6551,7 +6551,6 @@ u8 collect_bss_info(struct adapter *padapter, struct recv_frame *precv_frame, st struct registry_priv *pregistrypriv = &padapter->registrypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - __le32 le32_tmp; len = packet_len - sizeof(struct rtw_ieee80211_hdr_3addr); @@ -6665,8 +6664,8 @@ u8 collect_bss_info(struct adapter *padapter, struct recv_frame *precv_frame, st return _SUCCESS; } - memcpy(&le32_tmp, rtw_get_beacon_interval_from_ie(bssid->IEs), 2); - bssid->Configuration.BeaconPeriod = le32_to_cpu(le32_tmp); + bssid->Configuration.BeaconPeriod = + get_unaligned_le16(rtw_get_beacon_interval_from_ie(bssid->IEs)); val16 = rtw_get_capability((struct wlan_bssid_ex *)bssid); -- cgit v1.2.3 From 89b90c684e54ec2b60fbb39114cf538b9bb99780 Mon Sep 17 00:00:00 2001 From: Rickard Strandqvist Date: Thu, 22 May 2014 21:58:02 +0200 Subject: staging: rtl8188eu: os_dep: usb_intf.c: Fix to remove null pointer checks that could never happen Removal of null pointer checks that could never happen Signed-off-by: Rickard Strandqvist Reviewed-by: Dan Carpenter Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 110 +++++++++++++--------------- 1 file changed, 52 insertions(+), 58 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index ed9c6a112759..246a420c897c 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -306,49 +306,47 @@ int rtw_hw_suspend(struct adapter *padapter) goto error_exit; } - if (padapter) { /* system suspend */ - LeaveAllPowerSaveMode(padapter); + /* system suspend */ + LeaveAllPowerSaveMode(padapter); - DBG_88E("==> rtw_hw_suspend\n"); - _enter_pwrlock(&pwrpriv->lock); - pwrpriv->bips_processing = true; - /* s1. */ - if (pnetdev) { - netif_carrier_off(pnetdev); - rtw_netif_stop_queue(pnetdev); - } + DBG_88E("==> rtw_hw_suspend\n"); + _enter_pwrlock(&pwrpriv->lock); + pwrpriv->bips_processing = true; + /* s1. */ + if (pnetdev) { + netif_carrier_off(pnetdev); + rtw_netif_stop_queue(pnetdev); + } - /* s2. */ - rtw_disassoc_cmd(padapter, 500, false); + /* s2. */ + rtw_disassoc_cmd(padapter, 500, false); - /* s2-2. indicate disconnect to os */ - { - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + /* s2-2. indicate disconnect to os */ + { + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - if (check_fwstate(pmlmepriv, _FW_LINKED)) { - _clr_fwstate_(pmlmepriv, _FW_LINKED); + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + _clr_fwstate_(pmlmepriv, _FW_LINKED); - rtw_led_control(padapter, LED_CTL_NO_LINK); + rtw_led_control(padapter, LED_CTL_NO_LINK); - rtw_os_indicate_disconnect(padapter); + rtw_os_indicate_disconnect(padapter); - /* donnot enqueue cmd */ - rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_DISCONNECT, 0); - } + /* donnot enqueue cmd */ + rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_DISCONNECT, 0); } - /* s2-3. */ - rtw_free_assoc_resources(padapter, 1); + } + /* s2-3. */ + rtw_free_assoc_resources(padapter, 1); - /* s2-4. */ - rtw_free_network_queue(padapter, true); - rtw_ips_dev_unload(padapter); - pwrpriv->rf_pwrstate = rf_off; - pwrpriv->bips_processing = false; + /* s2-4. */ + rtw_free_network_queue(padapter, true); + rtw_ips_dev_unload(padapter); + pwrpriv->rf_pwrstate = rf_off; + pwrpriv->bips_processing = false; + + _exit_pwrlock(&pwrpriv->lock); - _exit_pwrlock(&pwrpriv->lock); - } else { - goto error_exit; - } return 0; error_exit: @@ -362,35 +360,32 @@ int rtw_hw_resume(struct adapter *padapter) struct net_device *pnetdev = padapter->pnetdev; - if (padapter) { /* system resume */ - DBG_88E("==> rtw_hw_resume\n"); - _enter_pwrlock(&pwrpriv->lock); - pwrpriv->bips_processing = true; - rtw_reset_drv_sw(padapter); + /* system resume */ + DBG_88E("==> rtw_hw_resume\n"); + _enter_pwrlock(&pwrpriv->lock); + pwrpriv->bips_processing = true; + rtw_reset_drv_sw(padapter); - if (pm_netdev_open(pnetdev, false) != 0) { - _exit_pwrlock(&pwrpriv->lock); - goto error_exit; - } + if (pm_netdev_open(pnetdev, false) != 0) { + _exit_pwrlock(&pwrpriv->lock); + goto error_exit; + } - netif_device_attach(pnetdev); - netif_carrier_on(pnetdev); + netif_device_attach(pnetdev); + netif_carrier_on(pnetdev); - if (!netif_queue_stopped(pnetdev)) - netif_start_queue(pnetdev); - else - netif_wake_queue(pnetdev); + if (!netif_queue_stopped(pnetdev)) + netif_start_queue(pnetdev); + else + netif_wake_queue(pnetdev); - pwrpriv->bkeepfwalive = false; - pwrpriv->brfoffbyhw = false; + pwrpriv->bkeepfwalive = false; + pwrpriv->brfoffbyhw = false; - pwrpriv->rf_pwrstate = rf_on; - pwrpriv->bips_processing = false; + pwrpriv->rf_pwrstate = rf_on; + pwrpriv->bips_processing = false; - _exit_pwrlock(&pwrpriv->lock); - } else { - goto error_exit; - } + _exit_pwrlock(&pwrpriv->lock); return 0; @@ -501,8 +496,7 @@ int rtw_resume_process(struct adapter *padapter) _enter_pwrlock(&pwrpriv->lock); rtw_reset_drv_sw(padapter); - if (pwrpriv) - pwrpriv->bkeepfwalive = false; + pwrpriv->bkeepfwalive = false; DBG_88E("bkeepfwalive(%x)\n", pwrpriv->bkeepfwalive); if (pm_netdev_open(pnetdev, true) != 0) -- cgit v1.2.3 From 27ea2f167ba5ddd0108b61562698a756e43b0271 Mon Sep 17 00:00:00 2001 From: John Church Date: Wed, 7 May 2014 13:30:02 +0100 Subject: staging : android: Fixes a coding style issue in timed_gpio.c This patch fixes a coding style issue for a line that was over 80 characters long. Signed-off-by: John Church Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/timed_gpio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/android/timed_gpio.c b/drivers/staging/android/timed_gpio.c index f7d124da5b70..180c209a009e 100644 --- a/drivers/staging/android/timed_gpio.c +++ b/drivers/staging/android/timed_gpio.c @@ -92,8 +92,8 @@ static int timed_gpio_probe(struct platform_device *pdev) return -EBUSY; gpio_data = devm_kzalloc(&pdev->dev, - sizeof(struct timed_gpio_data) * pdata->num_gpios, - GFP_KERNEL); + sizeof(struct timed_gpio_data) * pdata->num_gpios, + GFP_KERNEL); if (!gpio_data) return -ENOMEM; -- cgit v1.2.3 From aac22d07bc08befb0e3c7cbc2e91a8d8dce75cf2 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Mon, 19 May 2014 06:31:09 +0200 Subject: staging: wlags49_h2: make return of 0 explicit Delete unnecessary local variable whose value is always 0 and that hides the fact that the result is always 0. A simplified version of the semantic patch that fixes this problem is as follows: (http://coccinelle.lip6.fr/) // @r exists@ local idexpression ret; expression e; position p; @@ -ret = 0; ... when != ret = e return - ret + 0 ; // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/wl_wext.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/staging/wlags49_h2/wl_wext.c b/drivers/staging/wlags49_h2/wl_wext.c index 49eeeaee664b..3aeff818afc2 100644 --- a/drivers/staging/wlags49_h2/wl_wext.c +++ b/drivers/staging/wlags49_h2/wl_wext.c @@ -159,15 +159,12 @@ static int hermes_set_tkip_keys(ltv_t *ltv, u16 key_idx, u8 *addr, /* Set up the LTV to clear the appropriate key */ static int hermes_clear_tkip_keys(ltv_t *ltv, u16 key_idx, u8 *addr) { - int ret; - switch (key_idx) { case 0: if (!is_broadcast_ether_addr(addr)) { ltv->len = 7; ltv->typ = CFG_REMOVE_TKIP_MAPPED_KEY; memcpy(<v->u.u8[0], addr, ETH_ALEN); - ret = 0; } break; case 1: @@ -178,13 +175,12 @@ static int hermes_clear_tkip_keys(ltv_t *ltv, u16 key_idx, u8 *addr) ltv->typ = CFG_REMOVE_TKIP_DEFAULT_KEY; ltv->u.u16[0] = cpu_to_le16(key_idx); - ret = 0; break; default: break; } - return ret; + return 0; } /* Set the WEP keys in the wl_private structure */ @@ -3027,13 +3023,10 @@ static int wireless_set_genie(struct net_device *dev, struct iw_point *data, char *extra) { - int ret = 0; - /* We can't write this to the card, but apparently this * operation needs to succeed */ - ret = 0; - return ret; + return 0; } /*============================================================================*/ -- cgit v1.2.3 From 2b9d89dd7acfc08b2fcb935f73a8d480e9067a97 Mon Sep 17 00:00:00 2001 From: Peter Senna Tschudin Date: Tue, 20 May 2014 12:33:42 +0200 Subject: staging: wlags49_h2: wl_priv: Remove useless return variables This patch remove variables that are initialized with a constant, are never updated, and are only used as parameter of return. Return the constant instead of using a variable. Verified by compilation only. The coccinelle script that find and fixes this issue is: // @@ type T; constant C; identifier ret; @@ - T ret = C; ... when != ret - return ret; + return C; // Signed-off-by: Peter Senna Tschudin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/wl_priv.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/staging/wlags49_h2/wl_priv.c b/drivers/staging/wlags49_h2/wl_priv.c index 41f332499d42..aff927350222 100644 --- a/drivers/staging/wlags49_h2/wl_priv.c +++ b/drivers/staging/wlags49_h2/wl_priv.c @@ -179,8 +179,6 @@ int wvlan_uil(struct uilreq *urq, struct wl_private *lp) ******************************************************************************/ int wvlan_uil_connect(struct uilreq *urq, struct wl_private *lp) { - int result = 0; - if (!(lp->flags & WVLAN2_UIL_CONNECTED)) { lp->flags |= WVLAN2_UIL_CONNECTED; urq->hcfCtx = &(lp->hcfCtx); @@ -190,7 +188,7 @@ int wvlan_uil_connect(struct uilreq *urq, struct wl_private *lp) urq->result = UIL_ERR_IN_USE; } - return result; + return 0; } /* wvlan_uil_connect */ /*============================================================================*/ @@ -218,8 +216,6 @@ int wvlan_uil_connect(struct uilreq *urq, struct wl_private *lp) ******************************************************************************/ int wvlan_uil_disconnect(struct uilreq *urq, struct wl_private *lp) { - int result = 0; - if (urq->hcfCtx == &(lp->hcfCtx)) { if (lp->flags & WVLAN2_UIL_CONNECTED) { lp->flags &= ~WVLAN2_UIL_CONNECTED; @@ -238,7 +234,7 @@ int wvlan_uil_disconnect(struct uilreq *urq, struct wl_private *lp) urq->result = UIL_ERR_WRONG_IFB; } - return result; + return 0; } /* wvlan_uil_disconnect */ /*============================================================================*/ @@ -1580,7 +1576,6 @@ int wvlan_set_netname(struct net_device *dev, { struct wl_private *lp = wl_priv(dev); unsigned long flags; - int ret = 0; wl_lock(lp, &flags); @@ -1591,7 +1586,7 @@ int wvlan_set_netname(struct net_device *dev, wl_apply(lp); wl_unlock(lp, &flags); - return ret; + return 0; } /* wvlan_set_netname */ /*============================================================================*/ @@ -1683,7 +1678,6 @@ int wvlan_set_station_nickname(struct net_device *dev, struct wl_private *lp = wl_priv(dev); unsigned long flags; size_t len; - int ret = 0; wl_lock(lp, &flags); @@ -1695,7 +1689,7 @@ int wvlan_set_station_nickname(struct net_device *dev, wl_apply(lp); wl_unlock(lp, &flags); - return ret; + return 0; } /* wvlan_set_station_nickname */ /*============================================================================*/ -- cgit v1.2.3 From 540958e2f5a87b81aa5f55ce40b3e2869754f97d Mon Sep 17 00:00:00 2001 From: Raghavendra Ganiga Date: Sat, 10 May 2014 21:54:14 +0530 Subject: staging: comedi: removing warnings reported by checkpatch tool on cb_pcimdas.c This is a patch to remove warnings reported by checkpatch tool on cb_pcimdas.c file Signed-off-by: Raghavendra Chandra Ganiga Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcimdas.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/staging/comedi/drivers/cb_pcimdas.c index d3141c865fe7..50e522e6e690 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdas.c +++ b/drivers/staging/comedi/drivers/cb_pcimdas.c @@ -31,7 +31,8 @@ Configuration Options: Developed from cb_pcidas and skel by Richard Bytheway (mocelet@sucs.org). Only supports DIO, AO and simple AI in it's present form. -No interrupts, multi channel or FIFO AI, although the card looks like it could support this. +No interrupts, multi channel or FIFO AI, +although the card looks like it could support this. See http://www.mccdaq.com/PDFs/Manuals/pcim-das1602-16.pdf for more details. */ @@ -128,8 +129,12 @@ static int cb_pcimdas_ai_rinsn(struct comedi_device *dev, d = d & 0xfd; outb(d, devpriv->BADR3 + 5); } - outb(0x01, devpriv->BADR3 + 6); /* set bursting off, conversions on */ - outb(0x00, devpriv->BADR3 + 7); /* set range to 10V. UP/BP is controlled by a switch on the board */ + + /* set bursting off, conversions on */ + outb(0x01, devpriv->BADR3 + 6); + + /* set range to 10V. UP/BP is controlled by a switch on the board */ + outb(0x00, devpriv->BADR3 + 7); /* * write channel limits to multiplexer, set Low (bits 0-3) and -- cgit v1.2.3 From 55d4f6cc4c922123cf8eb7b428191a0c33f08704 Mon Sep 17 00:00:00 2001 From: Christian Engelmayer Date: Wed, 7 May 2014 21:36:48 +0200 Subject: staging: rtl8712: fix potential leak in r871x_wx_set_enc_ext() Fix a potential leak in the error path of r871x_wx_set_enc_ext(). In case the requested algorithm is not supported by the driver, the function returns without freeing the already allocated 'param' struct. Move the input verification to the beginning of the function so that the direct return is safe. Detected by Coverity - CID 144373. Signed-off-by: Christian Engelmayer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c index 23d539dba7ef..1eca992ce066 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c @@ -1801,13 +1801,6 @@ static int r871x_wx_set_enc_ext(struct net_device *dev, u32 param_len; int ret = 0; - param_len = sizeof(struct ieee_param) + pext->key_len; - param = (struct ieee_param *)_malloc(param_len); - if (param == NULL) - return -ENOMEM; - memset(param, 0, param_len); - param->cmd = IEEE_CMD_SET_ENCRYPTION; - memset(param->sta_addr, 0xff, ETH_ALEN); switch (pext->alg) { case IW_ENCODE_ALG_NONE: alg_name = "none"; @@ -1824,6 +1817,15 @@ static int r871x_wx_set_enc_ext(struct net_device *dev, default: return -EINVAL; } + + param_len = sizeof(struct ieee_param) + pext->key_len; + param = (struct ieee_param *)_malloc(param_len); + if (param == NULL) + return -ENOMEM; + memset(param, 0, param_len); + param->cmd = IEEE_CMD_SET_ENCRYPTION; + memset(param->sta_addr, 0xff, ETH_ALEN); + strncpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN); if (pext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) param->u.crypt.set_tx = 0; -- cgit v1.2.3 From 2af9e74ae6b013a6e30d631246db7825185abac0 Mon Sep 17 00:00:00 2001 From: Christian Engelmayer Date: Wed, 7 May 2014 21:40:41 +0200 Subject: staging: rtl8712: fix potential leaks in r8712_set_key() Fix potential leaks in the error paths of r8712_set_key(). In case the algorithm specific checks fail, the function returns without enqueuing or freeing the already allocated command and parameter structs. Use a centralized exit path and make sure that all memory is freed correctly. Detected by Coverity - CID 144370, 144371. Signed-off-by: Christian Engelmayer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_mlme.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c index 3ea99aea4385..23fd8c1fda3c 100644 --- a/drivers/staging/rtl8712/rtl871x_mlme.c +++ b/drivers/staging/rtl8712/rtl871x_mlme.c @@ -1243,14 +1243,15 @@ sint r8712_set_key(struct _adapter *adapter, struct cmd_obj *pcmd; struct setkey_parm *psetkeyparm; u8 keylen; + sint ret = _SUCCESS; pcmd = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); if (pcmd == NULL) return _FAIL; psetkeyparm = (struct setkey_parm *)_malloc(sizeof(struct setkey_parm)); if (psetkeyparm == NULL) { - kfree((unsigned char *)pcmd); - return _FAIL; + ret = _FAIL; + goto err_free_cmd; } memset(psetkeyparm, 0, sizeof(struct setkey_parm)); if (psecuritypriv->AuthAlgrthm == 2) { /* 802.1X */ @@ -1274,23 +1275,28 @@ sint r8712_set_key(struct _adapter *adapter, psecuritypriv->DefKey[keyid].skey, keylen); break; case _TKIP_: - if (keyid < 1 || keyid > 2) - return _FAIL; + if (keyid < 1 || keyid > 2) { + ret = _FAIL; + goto err_free_parm; + } keylen = 16; memcpy(psetkeyparm->key, &psecuritypriv->XGrpKey[keyid - 1], keylen); psetkeyparm->grpkey = 1; break; case _AES_: - if (keyid < 1 || keyid > 2) - return _FAIL; + if (keyid < 1 || keyid > 2) { + ret = _FAIL; + goto err_free_parm; + } keylen = 16; memcpy(psetkeyparm->key, &psecuritypriv->XGrpKey[keyid - 1], keylen); psetkeyparm->grpkey = 1; break; default: - return _FAIL; + ret = _FAIL; + goto err_free_parm; } pcmd->cmdcode = _SetKey_CMD_; pcmd->parmbuf = (u8 *)psetkeyparm; @@ -1299,7 +1305,13 @@ sint r8712_set_key(struct _adapter *adapter, pcmd->rspsz = 0; _init_listhead(&pcmd->list); r8712_enqueue_cmd(pcmdpriv, pcmd); - return _SUCCESS; + return ret; + +err_free_parm: + kfree(psetkeyparm); +err_free_cmd: + kfree(pcmd); + return ret; } /* adjust IEs for r8712_joinbss_cmd in WMM */ -- cgit v1.2.3 From 4679934a72ec0943ab628080f9f6e5fe23c73fe7 Mon Sep 17 00:00:00 2001 From: Marcus Farkas Date: Sat, 17 May 2014 19:38:29 +0200 Subject: staging: rtl8712: fix missing blank lines after declarations This commit fixes the following checkpatch warnings: rtl8712/rtl871x_security.c - 275: WARNING: Missing a blank line after declarations - 768: WARNING: Missing a blank line after declarations - 801: WARNING: Missing a blank line after declarations Signed-off-by: Marcus Farkas Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_security.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/rtl8712/rtl871x_security.c b/drivers/staging/rtl8712/rtl871x_security.c index 5ffc489e9501..b053a4d0b18b 100644 --- a/drivers/staging/rtl8712/rtl871x_security.c +++ b/drivers/staging/rtl8712/rtl871x_security.c @@ -272,6 +272,7 @@ static void secmicputuint32(u8 *p, u32 val) /* Convert from Us4Byte32 to Byte[] in a portable way */ { long i; + for (i = 0; i < 4; i++) { *p++ = (u8) (val & 0xff); val >>= 8; @@ -765,6 +766,7 @@ static void xor_128(u8 *a, u8 *b, u8 *out) static void xor_32(u8 *a, u8 *b, u8 *out) { sint i; + for (i = 0; i < 4; i++) out[i] = a[i] ^ b[i]; } @@ -798,6 +800,7 @@ static void next_key(u8 *key, sint round) static void byte_sub(u8 *in, u8 *out) { sint i; + for (i = 0; i < 16; i++) out[i] = sbox(in[i]); } -- cgit v1.2.3 From 0ac07ce022c8e0e1680e7576b97465a49ba7bbf0 Mon Sep 17 00:00:00 2001 From: Marcus Farkas Date: Sat, 17 May 2014 19:38:30 +0200 Subject: staging: rtl8712: fix unnecessary parentheses This commit fixes the following checkpatch warnings: rtl8712/rtl871x_security.c - 1167: WARNING: Unnecessary parentheses - maybe == should be = ? - 1374: WARNING: Unnecessary parentheses - maybe == should be = ? Signed-off-by: Marcus Farkas Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_security.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_security.c b/drivers/staging/rtl8712/rtl871x_security.c index b053a4d0b18b..1f2e197cc954 100644 --- a/drivers/staging/rtl8712/rtl871x_security.c +++ b/drivers/staging/rtl8712/rtl871x_security.c @@ -1167,7 +1167,7 @@ u32 r8712_aes_encrypt(struct _adapter *padapter, u8 *pxmitframe) return _FAIL; pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + TXDESC_OFFSET; /* 4 start to encrypt each fragment */ - if ((pattrib->encrypt == _AES_)) { + if (pattrib->encrypt == _AES_) { if (pattrib->psta) stainfo = pattrib->psta; else @@ -1374,7 +1374,7 @@ u32 r8712_aes_decrypt(struct _adapter *padapter, u8 *precvframe) pframe = (unsigned char *)((union recv_frame *)precvframe)-> u.hdr.rx_data; /* 4 start to encrypt each fragment */ - if ((prxattrib->encrypt == _AES_)) { + if (prxattrib->encrypt == _AES_) { stainfo = r8712_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]); if (stainfo != NULL) { -- cgit v1.2.3 From 265b8e5f85b9537e058f8073d5960d0788b81576 Mon Sep 17 00:00:00 2001 From: Marcus Farkas Date: Sat, 17 May 2014 19:38:31 +0200 Subject: staging: rtl8712: fix unnecessary line continuations This commit fixes the following checkpatch warning: rtl8712/rtl871x_security.c - 1178: WARNING: Avoid unnecessary line continuations Signed-off-by: Marcus Farkas Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_security.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8712/rtl871x_security.c b/drivers/staging/rtl8712/rtl871x_security.c index 1f2e197cc954..0912f52def99 100644 --- a/drivers/staging/rtl8712/rtl871x_security.c +++ b/drivers/staging/rtl8712/rtl871x_security.c @@ -1178,7 +1178,7 @@ u32 r8712_aes_encrypt(struct _adapter *padapter, u8 *pxmitframe) prwskeylen = 16; for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { - if ((curfragnum + 1) == pattrib->nr_frags) {\ + if ((curfragnum + 1) == pattrib->nr_frags) { length = pattrib->last_txcmdsz - pattrib->hdrlen - pattrib->iv_len - -- cgit v1.2.3 From ac082bc52dd197ee7fbc1271f17cea63615b239f Mon Sep 17 00:00:00 2001 From: Rickard Strandqvist Date: Tue, 20 May 2014 23:34:25 +0200 Subject: staging: rtl8712: usb_intf.c: Fix for possible null pointer dereference There is otherwise a risk of a possible null pointer dereference. Was largely found by using a static code analysis program called cppcheck. Signed-off-by: Rickard Strandqvist Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/usb_intf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c index bbd5888e316b..ba743542babc 100644 --- a/drivers/staging/rtl8712/usb_intf.c +++ b/drivers/staging/rtl8712/usb_intf.c @@ -595,7 +595,7 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf, error: usb_put_dev(udev); usb_set_intfdata(pusb_intf, NULL); - if (padapter->dvobj_deinit != NULL) + if (padapter && padapter->dvobj_deinit != NULL) padapter->dvobj_deinit(padapter); if (pnetdev) free_netdev(pnetdev); -- cgit v1.2.3 From 3eed8c0387106535cade04357040a37a4c8c4cc6 Mon Sep 17 00:00:00 2001 From: Pawel Lebioda Date: Wed, 14 May 2014 19:20:27 +0200 Subject: Staging: usbip: missing a blank lines after declarations Fix "Missing a blank line after declaration" style problems for all files in drivers/staging/usbip. Signed-off-by: Pawel Lebioda Signed-off-by: Greg Kroah-Hartman --- drivers/staging/usbip/stub_dev.c | 1 + drivers/staging/usbip/stub_tx.c | 1 + drivers/staging/usbip/usbip_common.h | 2 ++ drivers/staging/usbip/userspace/libsrc/usbip_common.c | 2 +- drivers/staging/usbip/userspace/src/usbip_attach.c | 1 + drivers/staging/usbip/userspace/src/usbipd.c | 6 +++++- drivers/staging/usbip/vhci_hcd.c | 2 ++ 7 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c index de692d7011a5..51d0c7188738 100644 --- a/drivers/staging/usbip/stub_dev.c +++ b/drivers/staging/usbip/stub_dev.c @@ -99,6 +99,7 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr, if (sockfd != -1) { int err; + dev_info(dev, "stub up\n"); spin_lock_irq(&sdev->ud.lock); diff --git a/drivers/staging/usbip/stub_tx.c b/drivers/staging/usbip/stub_tx.c index 1622563823a3..38fe551650c2 100644 --- a/drivers/staging/usbip/stub_tx.c +++ b/drivers/staging/usbip/stub_tx.c @@ -218,6 +218,7 @@ static int stub_send_ret_submit(struct stub_device *sdev) */ int i; + for (i = 0; i < urb->number_of_packets; i++) { iov[iovnum].iov_base = urb->transfer_buffer + urb->iso_frame_desc[i].offset; diff --git a/drivers/staging/usbip/usbip_common.h b/drivers/staging/usbip/usbip_common.h index f555d834f134..4da3866a037d 100644 --- a/drivers/staging/usbip/usbip_common.h +++ b/drivers/staging/usbip/usbip_common.h @@ -321,12 +321,14 @@ int usbip_event_happened(struct usbip_device *ud); static inline int interface_to_busnum(struct usb_interface *interface) { struct usb_device *udev = interface_to_usbdev(interface); + return udev->bus->busnum; } static inline int interface_to_devnum(struct usb_interface *interface) { struct usb_device *udev = interface_to_usbdev(interface); + return udev->devnum; } diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.c b/drivers/staging/usbip/userspace/libsrc/usbip_common.c index 238bf5bf7f4c..05a7443b3835 100644 --- a/drivers/staging/usbip/userspace/libsrc/usbip_common.c +++ b/drivers/staging/usbip/userspace/libsrc/usbip_common.c @@ -75,6 +75,7 @@ const char *usbip_speed_string(int num) void dump_usb_interface(struct usbip_usb_interface *uinf) { char buff[100]; + usbip_names_get_class(buff, sizeof(buff), uinf->bInterfaceClass, uinf->bInterfaceSubClass, @@ -86,7 +87,6 @@ void dump_usb_device(struct usbip_usb_device *udev) { char buff[100]; - dbg("%-20s = %s", "path", udev->path); dbg("%-20s = %s", "busid", udev->busid); diff --git a/drivers/staging/usbip/userspace/src/usbip_attach.c b/drivers/staging/usbip/userspace/src/usbip_attach.c index 716a79e284c4..d58a14dfc094 100644 --- a/drivers/staging/usbip/userspace/src/usbip_attach.c +++ b/drivers/staging/usbip/userspace/src/usbip_attach.c @@ -56,6 +56,7 @@ static int record_connection(char *host, char *port, char *busid, int rhport) /* if VHCI_STATE_PATH exists, then it better be a directory */ if (errno == EEXIST) { struct stat s; + ret = stat(VHCI_STATE_PATH, &s); if (ret < 0) return -1; diff --git a/drivers/staging/usbip/userspace/src/usbipd.c b/drivers/staging/usbip/userspace/src/usbipd.c index 2cae4ce48d11..b32047af809f 100644 --- a/drivers/staging/usbip/userspace/src/usbipd.c +++ b/drivers/staging/usbip/userspace/src/usbipd.c @@ -372,6 +372,7 @@ static int listen_all_addrinfo(struct addrinfo *ai_head, int sockfdlist[], for (ai = ai_head; ai && nsockfd < maxsockfd; ai = ai->ai_next) { int sock; + addrinfo_to_text(ai, ai_buf, ai_buf_size); dbg("opening %s", ai_buf); sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); @@ -461,7 +462,9 @@ static void write_pid_file() { if (pid_file) { dbg("creating pid file %s", pid_file); - FILE *fp = fopen(pid_file, "w"); + FILE *fp; + + fp = fopen(pid_file, "w"); if (!fp) { err("pid_file: %s: %d (%s)", pid_file, errno, strerror(errno)); @@ -602,6 +605,7 @@ int main(int argc, char *argv[]) int daemonize = 0; int ipv4 = 0, ipv6 = 0; int opt, rc = -1; + pid_file = NULL; usbip_use_stderr = 1; diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c index 70e17551943d..0007d30e45bd 100644 --- a/drivers/staging/usbip/vhci_hcd.c +++ b/drivers/staging/usbip/vhci_hcd.c @@ -635,6 +635,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) { int ret = 0; + ret = usb_hcd_check_unlink_urb(hcd, urb, status); if (ret) { spin_unlock(&the_controller->lock); @@ -885,6 +886,7 @@ static int vhci_start(struct usb_hcd *hcd) for (rhport = 0; rhport < VHCI_NPORTS; rhport++) { struct vhci_device *vdev = &vhci->vdev[rhport]; + vhci_device_init(vdev); vdev->rhport = rhport; } -- cgit v1.2.3 From 1949551393b3c1579696f2e7025761dd6901871b Mon Sep 17 00:00:00 2001 From: Pawel Lebioda Date: Wed, 14 May 2014 21:28:27 +0200 Subject: staging: usbip: Fix bad fuction definitions in usbip Fix bad function definitions in all files from drivers/staging/usbip directory Signed-off-by: Pawel Lebioda Signed-off-by: Greg Kroah-Hartman --- drivers/staging/usbip/userspace/libsrc/usbip_common.c | 2 +- drivers/staging/usbip/userspace/libsrc/vhci_driver.c | 2 +- drivers/staging/usbip/userspace/src/usbip_port.c | 2 +- drivers/staging/usbip/userspace/src/usbipd.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.c b/drivers/staging/usbip/userspace/libsrc/usbip_common.c index 05a7443b3835..ac73710473de 100644 --- a/drivers/staging/usbip/userspace/libsrc/usbip_common.c +++ b/drivers/staging/usbip/userspace/libsrc/usbip_common.c @@ -237,7 +237,7 @@ int usbip_names_init(char *f) return names_init(f); } -void usbip_names_free() +void usbip_names_free(void) { names_free(); } diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c index 8901fcb7946f..ad9204773533 100644 --- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c +++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c @@ -260,7 +260,7 @@ err: } -void usbip_vhci_driver_close() +void usbip_vhci_driver_close(void) { if (!vhci_driver) return; diff --git a/drivers/staging/usbip/userspace/src/usbip_port.c b/drivers/staging/usbip/userspace/src/usbip_port.c index 52aa168b46b3..a2e884fd9226 100644 --- a/drivers/staging/usbip/userspace/src/usbip_port.c +++ b/drivers/staging/usbip/userspace/src/usbip_port.c @@ -16,7 +16,7 @@ #include "vhci_driver.h" #include "usbip_common.h" -static int list_imported_devices() +static int list_imported_devices(void) { int i; struct usbip_imported_device *idev; diff --git a/drivers/staging/usbip/userspace/src/usbipd.c b/drivers/staging/usbip/userspace/src/usbipd.c index b32047af809f..2f87f2d348ba 100644 --- a/drivers/staging/usbip/userspace/src/usbipd.c +++ b/drivers/staging/usbip/userspace/src/usbipd.c @@ -458,7 +458,7 @@ static void set_signal(void) static const char *pid_file; -static void write_pid_file() +static void write_pid_file(void) { if (pid_file) { dbg("creating pid file %s", pid_file); @@ -475,7 +475,7 @@ static void write_pid_file() } } -static void remove_pid_file() +static void remove_pid_file(void) { if (pid_file) { dbg("removing pid file %s", pid_file); -- cgit v1.2.3 From a4570140b3f80d0dfc71fdcad00b9768db0b8b04 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Sun, 11 May 2014 14:15:19 +0300 Subject: staging: octeon-usb: delete redudant prefetches cvmx_usb_pipe fits into a cache-line so additional prefetches are not really helping anything. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/octeon-hcd.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index 2d15001b3061..b0c5f51f990e 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -2008,7 +2008,6 @@ static struct cvmx_usb_pipe *__cvmx_usb_find_ready_pipe( ((((int)current_frame - (int)pipe->split_sc_frame) & 0x7f) < 0x40)) && (!usb->active_split || (usb->active_split == t))) { - CVMX_PREFETCH(pipe, 128); CVMX_PREFETCH(t, 0); return pipe; } @@ -2660,7 +2659,6 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) /* Make sure this channel is tied to a valid pipe */ pipe = usb->pipe_for_channel[channel]; CVMX_PREFETCH(pipe, 0); - CVMX_PREFETCH(pipe, 128); if (!pipe) return 0; transaction = list_first_entry(&pipe->transactions, -- cgit v1.2.3 From 20f6b82992a2500cfc93f41ab0a62105a1440b7d Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Sun, 11 May 2014 14:15:20 +0300 Subject: staging: octeon-usb: use generic prefetch Use generic prefetch. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/octeon-hcd.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index b0c5f51f990e..98a493a73498 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -245,9 +246,6 @@ enum cvmx_usb_pipe_flags { __CVMX_USB_PIPE_FLAGS_NEED_PING = 1 << 18, }; -/* Normal prefetch that use the pref instruction. */ -#define CVMX_PREFETCH(address, offset) asm volatile ("pref %[type], %[off](%[rbase])" : : [rbase] "d" (address), [off] "I" (offset), [type] "n" (0)) - /* Maximum number of times to retry failed transactions */ #define MAX_RETRIES 3 @@ -2008,7 +2006,7 @@ static struct cvmx_usb_pipe *__cvmx_usb_find_ready_pipe( ((((int)current_frame - (int)pipe->split_sc_frame) & 0x7f) < 0x40)) && (!usb->active_split || (usb->active_split == t))) { - CVMX_PREFETCH(t, 0); + prefetch(t); return pipe; } } @@ -2658,13 +2656,13 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) /* Make sure this channel is tied to a valid pipe */ pipe = usb->pipe_for_channel[channel]; - CVMX_PREFETCH(pipe, 0); + prefetch(pipe); if (!pipe) return 0; transaction = list_first_entry(&pipe->transactions, typeof(*transaction), node); - CVMX_PREFETCH(transaction, 0); + prefetch(transaction); /* * Disconnect this pipe from the HW channel. Later the schedule @@ -3121,11 +3119,7 @@ static int cvmx_usb_poll(struct cvmx_usb_state *usb) union cvmx_usbcx_hfnum usbc_hfnum; union cvmx_usbcx_gintsts usbc_gintsts; - CVMX_PREFETCH(usb, 0); - CVMX_PREFETCH(usb, 1*128); - CVMX_PREFETCH(usb, 2*128); - CVMX_PREFETCH(usb, 3*128); - CVMX_PREFETCH(usb, 4*128); + prefetch_range(usb, sizeof(*usb)); /* Update the frame counter */ usbc_hfnum.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HFNUM(usb->index)); -- cgit v1.2.3 From f510643522471410ee8acf42d86d38d2bec4b268 Mon Sep 17 00:00:00 2001 From: Paul Davies C Date: Sun, 11 May 2014 18:41:32 +0530 Subject: staging: octeon-usb: Add blank line after all declarations in octeon-hcd.c Add blank lines after each declarations in drivers/staging/octeon-usb/octeon-hcd.c. Signed-off-by: Paul Davies C Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/octeon-hcd.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index 98a493a73498..c1abf4d6d586 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -890,6 +890,7 @@ static int cvmx_usb_initialize(struct cvmx_usb_state *usb, */ { union cvmx_usbcx_gusbcfg usbcx_gusbcfg; + usbcx_gusbcfg.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GUSBCFG(usb->index)); usbcx_gusbcfg.s.toutcal = 0; @@ -947,6 +948,7 @@ static int cvmx_usb_initialize(struct cvmx_usb_state *usb, */ { union cvmx_usbcx_hcfg usbcx_hcfg; + usbcx_hcfg.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCFG(usb->index)); usbcx_hcfg.s.fslssupp = 0; @@ -1074,6 +1076,7 @@ static int cvmx_usb_enable(struct cvmx_usb_state *usb) */ { union cvmx_usbcx_gnptxfsiz siz; + siz.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GNPTXFSIZ(usb->index)); siz.s.nptxfdep = usbcx_ghwcfg3.s.dfifodepth / 2; @@ -1088,6 +1091,7 @@ static int cvmx_usb_enable(struct cvmx_usb_state *usb) */ { union cvmx_usbcx_hptxfsiz siz; + siz.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPTXFSIZ(usb->index)); siz.s.ptxfsize = usbcx_ghwcfg3.s.dfifodepth / 4; @@ -1217,8 +1221,8 @@ static struct cvmx_usb_port_status cvmx_usb_get_status( * Returns: A non-NULL value is a pipe. NULL means an error. */ static struct cvmx_usb_pipe *cvmx_usb_open_pipe(struct cvmx_usb_state *usb, - int device_addr, int - endpoint_num, + int device_addr, + int endpoint_num, enum cvmx_usb_speed device_speed, int max_packet, @@ -1421,6 +1425,7 @@ static void __cvmx_usb_poll_tx_fifo(struct cvmx_usb_state *usb) { if (usb->periodic.head != usb->periodic.tail) { union cvmx_usbcx_hptxsts tx_status; + tx_status.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPTXSTS(usb->index)); if (__cvmx_usb_fill_tx_hw(usb, &usb->periodic, @@ -1436,6 +1441,7 @@ static void __cvmx_usb_poll_tx_fifo(struct cvmx_usb_state *usb) if (usb->nonperiodic.head != usb->nonperiodic.tail) { union cvmx_usbcx_gnptxsts tx_status; + tx_status.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GNPTXSTS(usb->index)); if (__cvmx_usb_fill_tx_hw(usb, &usb->nonperiodic, @@ -1720,6 +1726,7 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb, /* Setup the locations the DMA engines use */ { uint64_t dma_address = transaction->buffer + transaction->actual_bytes; + if (transaction->type == CVMX_USB_TRANSFER_ISOCHRONOUS) dma_address = transaction->buffer + transaction->iso_packets[0].offset + transaction->actual_bytes; __cvmx_usb_write_csr64(usb, CVMX_USBNX_DMA0_OUTB_CHN0(usb->index) + channel*8, dma_address); @@ -2035,6 +2042,7 @@ static void __cvmx_usb_schedule(struct cvmx_usb_state *usb, int is_sof) */ union cvmx_usbcx_hfnum hfnum = {.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HFNUM(usb->index))}; union cvmx_usbcx_hfir hfir = {.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HFIR(usb->index))}; + if (hfnum.s.frrem < hfir.s.frint/4) goto done; } @@ -2519,6 +2527,7 @@ static int cvmx_usb_cancel_all(struct cvmx_usb_state *usb, /* Simply loop through and attempt to cancel each transaction */ list_for_each_entry_safe(transaction, next, &pipe->transactions, node) { int result = cvmx_usb_cancel(usb, pipe, transaction); + if (unlikely(result != 0)) return result; } @@ -3079,6 +3088,7 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) pipe->interval; } else { struct cvmx_usb_port_status port; + port = cvmx_usb_get_status(usb); if (port.port_enabled) { /* We'll retry the exact same transaction again */ @@ -3188,6 +3198,7 @@ static int cvmx_usb_poll(struct cvmx_usb_state *usb) * to clear this bit. */ union cvmx_usbcx_haint usbc_haint; + usbc_haint.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HAINT(usb->index)); while (usbc_haint.u32) { int channel; @@ -3259,6 +3270,7 @@ static int octeon_usb_urb_enqueue(struct usb_hcd *hcd, enum cvmx_usb_speed speed; int split_device = 0; int split_port = 0; + switch (usb_pipetype(urb->pipe)) { case PIPE_ISOCHRONOUS: transfer_type = CVMX_USB_TRANSFER_ISOCHRONOUS; @@ -3295,6 +3307,7 @@ static int octeon_usb_urb_enqueue(struct usb_hcd *hcd, * tree. */ struct usb_device *dev = urb->dev; + while (dev->parent) { /* * If our parent is high speed then he'll @@ -3454,6 +3467,7 @@ static void octeon_usb_endpoint_disable(struct usb_hcd *hcd, struct octeon_hcd *priv = hcd_to_octeon(hcd); struct cvmx_usb_pipe *pipe = ep->hcpriv; unsigned long flags; + spin_lock_irqsave(&priv->lock, flags); cvmx_usb_cancel_all(&priv->usb, pipe); if (cvmx_usb_close_pipe(&priv->usb, pipe)) @@ -3770,6 +3784,7 @@ static int octeon_usb_probe(struct platform_device *pdev) if (irq < 0) { /* Defective device tree, but we know how to fix it. */ irq_hw_number_t hwirq = usb_num ? (1 << 6) + 17 : 56; + irq = irq_create_mapping(NULL, hwirq); } -- cgit v1.2.3 From e725cef3e55ad58f7f37917cc6f7b57b86a4b9bf Mon Sep 17 00:00:00 2001 From: Paul Davies C Date: Sun, 11 May 2014 18:41:33 +0530 Subject: staging: octeon-usb: Fix lines with more than 80 chars in octeon-hcd.c Some lines with more than 80 characters are converted in to multiple lines. Signed-off-by: Paul Davies C Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/octeon-hcd.c | 89 ++++++++++++++++++++++++--------- 1 file changed, 66 insertions(+), 23 deletions(-) diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index c1abf4d6d586..27f1f276eba4 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -460,7 +460,8 @@ struct octeon_hcd { } while (0) /* Returns the IO address to push/pop stuff data from the FIFOs */ -#define USB_FIFO_ADDRESS(channel, usb_index) (CVMX_USBCX_GOTGCTL(usb_index) + ((channel)+1)*0x1000) +#define USB_FIFO_ADDRESS(channel, usb_index) \ + (CVMX_USBCX_GOTGCTL(usb_index) + ((channel)+1)*0x1000) /** * struct octeon_temp_buffer - a bounce buffer for USB transfers @@ -1288,7 +1289,8 @@ static struct cvmx_usb_pipe *cvmx_usb_open_pipe(struct cvmx_usb_state *usb, if (__cvmx_usb_pipe_needs_split(usb, pipe)) { pipe->interval = interval*8; /* Force start splits to be schedule on uFrame 0 */ - pipe->next_tx_frame = ((usb->frame_number+7)&~7) + pipe->interval; + pipe->next_tx_frame = ((usb->frame_number+7)&~7) + + pipe->interval; } else { pipe->interval = interval; pipe->next_tx_frame = usb->frame_number + pipe->interval; @@ -1339,9 +1341,13 @@ static void __cvmx_usb_poll_rx_fifo(struct cvmx_usb_state *usb) return; /* Get where the DMA engine would have written this data */ - address = __cvmx_usb_read_csr64(usb, CVMX_USBNX_DMA0_INB_CHN0(usb->index) + channel*8); + address = __cvmx_usb_read_csr64(usb, + CVMX_USBNX_DMA0_INB_CHN0(usb->index) + channel*8); + ptr = cvmx_phys_to_ptr(address); - __cvmx_usb_write_csr64(usb, CVMX_USBNX_DMA0_INB_CHN0(usb->index) + channel*8, address + bytes); + __cvmx_usb_write_csr64(usb, + CVMX_USBNX_DMA0_INB_CHN0(usb->index) + channel*8, + address + bytes); /* Loop writing the FIFO data for this packet into memory */ while (bytes > 0) { @@ -1546,19 +1552,27 @@ static void __cvmx_usb_start_channel_control(struct cvmx_usb_state *usb, usbc_hctsiz.s.pid = 3; /* Setup */ bytes_to_transfer = sizeof(*header); /* All Control operations start with a setup going OUT */ - USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), union cvmx_usbcx_hccharx, epdir, CVMX_USB_DIRECTION_OUT); + USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), + union cvmx_usbcx_hccharx, epdir, + CVMX_USB_DIRECTION_OUT); /* * Setup send the control header instead of the buffer data. The * buffer data will be used in the next stage */ - __cvmx_usb_write_csr64(usb, CVMX_USBNX_DMA0_OUTB_CHN0(usb->index) + channel*8, transaction->control_header); + __cvmx_usb_write_csr64(usb, + CVMX_USBNX_DMA0_OUTB_CHN0(usb->index) + channel*8, + transaction->control_header); break; case CVMX_USB_STAGE_SETUP_SPLIT_COMPLETE: usbc_hctsiz.s.pid = 3; /* Setup */ bytes_to_transfer = 0; /* All Control operations start with a setup going OUT */ - USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), union cvmx_usbcx_hccharx, epdir, CVMX_USB_DIRECTION_OUT); - USB_SET_FIELD32(CVMX_USBCX_HCSPLTX(channel, usb->index), union cvmx_usbcx_hcspltx, compsplt, 1); + USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), + union cvmx_usbcx_hccharx, epdir, + CVMX_USB_DIRECTION_OUT); + + USB_SET_FIELD32(CVMX_USBCX_HCSPLTX(channel, usb->index), + union cvmx_usbcx_hcspltx, compsplt, 1); break; case CVMX_USB_STAGE_DATA: usbc_hctsiz.s.pid = __cvmx_usb_get_data_pid(pipe); @@ -1688,6 +1702,7 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb, /* Clear all channel status bits */ usbc_hcint.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCINTX(channel, usb->index)); + __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCINTX(channel, usb->index), usbc_hcint.u32); @@ -1718,19 +1733,31 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb, __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCINTMSKX(channel, usb->index), usbc_hcintmsk.u32); /* Enable the channel interrupt to propagate */ - usbc_haintmsk.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HAINTMSK(usb->index)); + usbc_haintmsk.u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_HAINTMSK(usb->index)); usbc_haintmsk.s.haintmsk |= 1<index), usbc_haintmsk.u32); + __cvmx_usb_write_csr32(usb, + CVMX_USBCX_HAINTMSK(usb->index), + usbc_haintmsk.u32); } /* Setup the locations the DMA engines use */ { - uint64_t dma_address = transaction->buffer + transaction->actual_bytes; + uint64_t dma_address = transaction->buffer + + transaction->actual_bytes; if (transaction->type == CVMX_USB_TRANSFER_ISOCHRONOUS) - dma_address = transaction->buffer + transaction->iso_packets[0].offset + transaction->actual_bytes; - __cvmx_usb_write_csr64(usb, CVMX_USBNX_DMA0_OUTB_CHN0(usb->index) + channel*8, dma_address); - __cvmx_usb_write_csr64(usb, CVMX_USBNX_DMA0_INB_CHN0(usb->index) + channel*8, dma_address); + dma_address = transaction->buffer + + transaction->iso_packets[0].offset + + transaction->actual_bytes; + + __cvmx_usb_write_csr64(usb, + CVMX_USBNX_DMA0_OUTB_CHN0(usb->index) + channel*8, + dma_address); + + __cvmx_usb_write_csr64(usb, + CVMX_USBNX_DMA0_INB_CHN0(usb->index) + channel*8, + dma_address); } /* Setup both the size of the transfer and the SPLIT characteristics */ @@ -2040,8 +2067,15 @@ static void __cvmx_usb_schedule(struct cvmx_usb_state *usb, int is_sof) * Without DMA we need to be careful to not schedule something * at the end of a frame and cause an overrun. */ - union cvmx_usbcx_hfnum hfnum = {.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HFNUM(usb->index))}; - union cvmx_usbcx_hfir hfir = {.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HFIR(usb->index))}; + union cvmx_usbcx_hfnum hfnum = { + .u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_HFNUM(usb->index)) + }; + + union cvmx_usbcx_hfir hfir = { + .u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_HFIR(usb->index)) + }; if (hfnum.s.frrem < hfir.s.frint/4) goto done; @@ -2660,7 +2694,9 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel) } /* Disable the channel interrupts now that it is done */ - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCINTMSKX(channel, usb->index), 0); + __cvmx_usb_write_csr32(usb, + CVMX_USBCX_HCINTMSKX(channel, usb->index), + 0); usb->idle_hardware_channels |= (1<next_tx_frame += pipe->interval; + pipe->next_tx_frame += + pipe->interval; __cvmx_usb_perform_complete( usb, pipe, @@ -3132,17 +3169,21 @@ static int cvmx_usb_poll(struct cvmx_usb_state *usb) prefetch_range(usb, sizeof(*usb)); /* Update the frame counter */ - usbc_hfnum.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HFNUM(usb->index)); + usbc_hfnum.u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_HFNUM(usb->index)); if ((usb->frame_number&0x3fff) > usbc_hfnum.s.frnum) usb->frame_number += 0x4000; usb->frame_number &= ~0x3fffull; usb->frame_number |= usbc_hfnum.s.frnum; /* Read the pending interrupts */ - usbc_gintsts.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GINTSTS(usb->index)); + usbc_gintsts.u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_GINTSTS(usb->index)); /* Clear the interrupts now that we know about them */ - __cvmx_usb_write_csr32(usb, CVMX_USBCX_GINTSTS(usb->index), usbc_gintsts.u32); + __cvmx_usb_write_csr32(usb, + CVMX_USBCX_GINTSTS(usb->index), + usbc_gintsts.u32); if (usbc_gintsts.s.rxflvl) { /* @@ -3199,7 +3240,8 @@ static int cvmx_usb_poll(struct cvmx_usb_state *usb) */ union cvmx_usbcx_haint usbc_haint; - usbc_haint.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HAINT(usb->index)); + usbc_haint.u32 = __cvmx_usb_read_csr32(usb, + CVMX_USBCX_HAINT(usb->index)); while (usbc_haint.u32) { int channel; @@ -3492,7 +3534,8 @@ static int octeon_usb_hub_status_data(struct usb_hcd *hcd, char *buf) return buf[0] != 0; } -static int octeon_usb_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex, char *buf, u16 wLength) +static int octeon_usb_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, + u16 wIndex, char *buf, u16 wLength) { struct octeon_hcd *priv = hcd_to_octeon(hcd); struct device *dev = hcd->self.controller; -- cgit v1.2.3 From ae4af9adf11ba6e25261969c9f31e0d09ee5ccc6 Mon Sep 17 00:00:00 2001 From: Denis Pithon Date: Sat, 17 May 2014 00:30:16 +0200 Subject: staging/wlan-ng: add prefix to function name Renamed convert_frame_to_ether() to p80211_convert_to_ether(). Signed-off-by: Denis Pithon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/p80211netdev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c index 61a30928a9c1..64dd93572ff9 100644 --- a/drivers/staging/wlan-ng/p80211netdev.c +++ b/drivers/staging/wlan-ng/p80211netdev.c @@ -244,7 +244,7 @@ void p80211netdev_rx(wlandevice_t *wlandev, struct sk_buff *skb) #define CONV_TO_ETHER_FAILED 0x02 /** - * convert_frame_to_ether - conversion from 802.11 frame to ethernet frame + * p80211_convert_to_ether - conversion from 802.11 frame to ethernet frame * @wlandev: pointer to WLAN device * @skb: pointer to socket buffer * @@ -252,7 +252,7 @@ void p80211netdev_rx(wlandevice_t *wlandev, struct sk_buff *skb) * CONV_TO_ETHER_FAILED if conversion failed * CONV_TO_ETHER_SKIPPED if frame is ignored */ -static int convert_frame_to_ether(wlandevice_t *wlandev, struct sk_buff *skb) +static int p80211_convert_to_ether(wlandevice_t *wlandev, struct sk_buff *skb) { struct p80211_hdr_a3 *hdr; @@ -314,7 +314,7 @@ static void p80211netdev_rx_bh(unsigned long arg) netif_rx_ni(skb); continue; } else { - if (!convert_frame_to_ether(wlandev, skb)) + if (!p80211_convert_to_ether(wlandev, skb)) continue; } } -- cgit v1.2.3 From 9b3ac7a892c12a6ac1a4b7f435be91c22b65e067 Mon Sep 17 00:00:00 2001 From: Denis Pithon Date: Sat, 17 May 2014 00:14:50 +0200 Subject: staging/wlan-ng: compare using ether_addr_equal_unaligned Replaced generic memcmp() with dedicated ether_addr_equal_unaligned() call. I did not find any clue of u16 alignment for both addresses. Signed-off-by: Denis Pithon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/p80211netdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c index 64dd93572ff9..13fe068ce8f4 100644 --- a/drivers/staging/wlan-ng/p80211netdev.c +++ b/drivers/staging/wlan-ng/p80211netdev.c @@ -263,7 +263,8 @@ static int p80211_convert_to_ether(wlandevice_t *wlandev, struct sk_buff *skb) /* perform mcast filtering */ if (wlandev->netdev->flags & IFF_ALLMULTI) { /* allow my local address through */ - if (memcmp(hdr->a1, wlandev->netdev->dev_addr, ETH_ALEN) != 0) { + if (!ether_addr_equal_unaligned(wlandev->netdev->dev_addr, + hdr->a1)) { /* but reject anything else that isn't multicast */ if (!(hdr->a1[0] & 0x01)) return CONV_TO_ETHER_SKIPPED; -- cgit v1.2.3 From 02b3b53a083f833650cccffe2655711d6d0ab64c Mon Sep 17 00:00:00 2001 From: Denis Pithon Date: Sat, 17 May 2014 00:14:51 +0200 Subject: staging/wlan-ng: multicast address checking Used is_multicast_ether_addr() to perform the checking. Signed-off-by: Denis Pithon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/p80211netdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c index 13fe068ce8f4..63edc83d23a5 100644 --- a/drivers/staging/wlan-ng/p80211netdev.c +++ b/drivers/staging/wlan-ng/p80211netdev.c @@ -266,7 +266,7 @@ static int p80211_convert_to_ether(wlandevice_t *wlandev, struct sk_buff *skb) if (!ether_addr_equal_unaligned(wlandev->netdev->dev_addr, hdr->a1)) { /* but reject anything else that isn't multicast */ - if (!(hdr->a1[0] & 0x01)) + if (!is_multicast_ether_addr(hdr->a1)) return CONV_TO_ETHER_SKIPPED; } } -- cgit v1.2.3 From 95c9668dda663b0d5fca3f4212c6f71157256daa Mon Sep 17 00:00:00 2001 From: Denis Pithon Date: Sat, 17 May 2014 00:14:52 +0200 Subject: staging/wlan-ng: rearrange comments Gathered together comments in front of multicast filtering block. Signed-off-by: Denis Pithon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/p80211netdev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c index 63edc83d23a5..21ca17e7c461 100644 --- a/drivers/staging/wlan-ng/p80211netdev.c +++ b/drivers/staging/wlan-ng/p80211netdev.c @@ -260,12 +260,12 @@ static int p80211_convert_to_ether(wlandevice_t *wlandev, struct sk_buff *skb) if (p80211_rx_typedrop(wlandev, hdr->fc)) return CONV_TO_ETHER_SKIPPED; - /* perform mcast filtering */ + /* perform mcast filtering: allow my local address through but reject + * anything else that isn't multicast + */ if (wlandev->netdev->flags & IFF_ALLMULTI) { - /* allow my local address through */ if (!ether_addr_equal_unaligned(wlandev->netdev->dev_addr, hdr->a1)) { - /* but reject anything else that isn't multicast */ if (!is_multicast_ether_addr(hdr->a1)) return CONV_TO_ETHER_SKIPPED; } -- cgit v1.2.3 From 79f9e634cc8312790d9674ea1faa998ea9cacfee Mon Sep 17 00:00:00 2001 From: Denis Pithon Date: Sat, 17 May 2014 00:24:09 +0200 Subject: staging/wlan-ng: log with netdev_xxx and dev_xxx Wherever possible, replaced printk() and pr_xxx() calls with netdev_xxx() / dev_xxx() calls; used pr_xxx() otherwise. Signed-off-by: Denis Pithon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/p80211netdev.c | 45 +++++++++++++++++----------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c index 21ca17e7c461..00b186c59725 100644 --- a/drivers/staging/wlan-ng/p80211netdev.c +++ b/drivers/staging/wlan-ng/p80211netdev.c @@ -279,7 +279,7 @@ static int p80211_convert_to_ether(wlandevice_t *wlandev, struct sk_buff *skb) return 0; } - pr_debug("p80211_to_ether failed.\n"); + netdev_dbg(wlandev->netdev, "p80211_convert_to_ether failed.\n"); return CONV_TO_ETHER_FAILED; } @@ -365,7 +365,7 @@ static int p80211knetdev_hard_start_xmit(struct sk_buff *skb, memset(&p80211_wep, 0, sizeof(struct p80211_metawep)); if (netif_queue_stopped(netdev)) { - pr_debug("called when queue stopped.\n"); + netdev_dbg(netdev, "called when queue stopped.\n"); result = 1; goto failed; } @@ -385,8 +385,7 @@ static int p80211knetdev_hard_start_xmit(struct sk_buff *skb, */ if (skb->protocol != ETH_P_80211_RAW) { netif_start_queue(wlandev->netdev); - printk(KERN_NOTICE - "Tx attempt prior to association, frame dropped.\n"); + netdev_notice(netdev, "Tx attempt prior to association, frame dropped.\n"); wlandev->linux_stats.tx_dropped++; result = 0; goto failed; @@ -408,8 +407,8 @@ static int p80211knetdev_hard_start_xmit(struct sk_buff *skb, (wlandev, wlandev->ethconv, skb, &p80211_hdr, &p80211_wep) != 0) { /* convert failed */ - pr_debug("ether_to_80211(%d) failed.\n", - wlandev->ethconv); + netdev_dbg(netdev, "ether_to_80211(%d) failed.\n", + wlandev->ethconv); result = 1; goto failed; } @@ -434,17 +433,17 @@ static int p80211knetdev_hard_start_xmit(struct sk_buff *skb, result = NETDEV_TX_OK; } else if (txresult == 1) { /* success, no more avail */ - pr_debug("txframe success, no more bufs\n"); + netdev_dbg(netdev, "txframe success, no more bufs\n"); /* netdev->tbusy = 1; don't set here, irqhdlr */ /* may have already cleared it */ result = NETDEV_TX_OK; } else if (txresult == 2) { /* alloc failure, drop frame */ - pr_debug("txframe returned alloc_fail\n"); + netdev_dbg(netdev, "txframe returned alloc_fail\n"); result = NETDEV_TX_BUSY; } else { /* buffer full or queue busy, drop frame. */ - pr_debug("txframe returned full or busy\n"); + netdev_dbg(netdev, "txframe returned full or busy\n"); result = NETDEV_TX_BUSY; } @@ -564,7 +563,7 @@ static int p80211knetdev_do_ioctl(netdevice_t *dev, struct ifreq *ifr, int cmd) wlandevice_t *wlandev = dev->ml_priv; u8 *msgbuf; - pr_debug("rx'd ioctl, cmd=%d, len=%d\n", cmd, req->len); + netdev_dbg(dev, "rx'd ioctl, cmd=%d, len=%d\n", cmd, req->len); #ifdef SIOCETHTOOL if (cmd == SIOCETHTOOL) { @@ -685,8 +684,7 @@ static int p80211knetdev_set_mac_address(netdevice_t *dev, void *addr) * change the netdev address */ if (result != 0 || resultcode->data != P80211ENUM_resultcode_success) { - printk(KERN_ERR - "Low-level driver failed dot11req_mibset(dot11MACAddress).\n"); + netdev_err(dev, "Low-level driver failed dot11req_mibset(dot11MACAddress).\n"); result = -EADDRNOTAVAIL; } else { /* everything's ok, change the addr in netdev */ @@ -765,7 +763,7 @@ int wlan_setup(wlandevice_t *wlandev, struct device *physdev) /* Allocate and initialize the wiphy struct */ wiphy = wlan_create_wiphy(physdev, wlandev); if (wiphy == NULL) { - printk(KERN_ERR "Failed to alloc wiphy.\n"); + dev_err(physdev, "Failed to alloc wiphy.\n"); return 1; } @@ -773,7 +771,7 @@ int wlan_setup(wlandevice_t *wlandev, struct device *physdev) netdev = alloc_netdev(sizeof(struct wireless_dev), "wlan%d", ether_setup); if (netdev == NULL) { - printk(KERN_ERR "Failed to alloc netdev.\n"); + dev_err(physdev, "Failed to alloc netdev.\n"); wlan_free_wiphy(wiphy); result = 1; } else { @@ -949,7 +947,8 @@ static int p80211_rx_typedrop(wlandevice_t *wlandev, u16 fc) ftype = WLAN_GET_FC_FTYPE(fc); fstype = WLAN_GET_FC_FSTYPE(fc); #if 0 - pr_debug("rx_typedrop : ftype=%d fstype=%d.\n", ftype, fstype); + netdev_dbg(wlandev->netdev, "rx_typedrop : ftype=%d fstype=%d.\n", + ftype, fstype); #endif switch (ftype) { case WLAN_FTYPE_MGMT: @@ -958,7 +957,7 @@ static int p80211_rx_typedrop(wlandevice_t *wlandev, u16 fc) drop = 1; break; } - pr_debug("rx'd mgmt:\n"); + netdev_dbg(wlandev->netdev, "rx'd mgmt:\n"); wlandev->rx.mgmt++; switch (fstype) { case WLAN_FSTYPE_ASSOCREQ: @@ -1020,7 +1019,7 @@ static int p80211_rx_typedrop(wlandevice_t *wlandev, u16 fc) drop = 1; break; } - pr_debug("rx'd ctl:\n"); + netdev_dbg(wlandev->netdev, "rx'd ctl:\n"); wlandev->rx.ctl++; switch (fstype) { case WLAN_FSTYPE_PSPOLL: @@ -1072,19 +1071,19 @@ static int p80211_rx_typedrop(wlandevice_t *wlandev, u16 fc) wlandev->rx.data__cfack_cfpoll++; break; case WLAN_FSTYPE_NULL: - pr_debug("rx'd data:null\n"); + netdev_dbg(wlandev->netdev, "rx'd data:null\n"); wlandev->rx.null++; break; case WLAN_FSTYPE_CFACK: - pr_debug("rx'd data:cfack\n"); + netdev_dbg(wlandev->netdev, "rx'd data:cfack\n"); wlandev->rx.cfack++; break; case WLAN_FSTYPE_CFPOLL: - pr_debug("rx'd data:cfpoll\n"); + netdev_dbg(wlandev->netdev, "rx'd data:cfpoll\n"); wlandev->rx.cfpoll++; break; case WLAN_FSTYPE_CFACK_CFPOLL: - pr_debug("rx'd data:cfack_cfpoll\n"); + netdev_dbg(wlandev->netdev, "rx'd data:cfack_cfpoll\n"); wlandev->rx.cfack_cfpoll++; break; default: @@ -1105,8 +1104,8 @@ static void p80211knetdev_tx_timeout(netdevice_t *netdev) if (wlandev->tx_timeout) { wlandev->tx_timeout(wlandev); } else { - printk(KERN_WARNING "Implement tx_timeout for %s\n", - wlandev->nsdname); + netdev_warn(netdev, "Implement tx_timeout for %s\n", + wlandev->nsdname); netif_wake_queue(wlandev->netdev); } } -- cgit v1.2.3 From 02d9b1eb4b21b9309efdf8c8aee023a59d3f76e0 Mon Sep 17 00:00:00 2001 From: Vitaly Osipov Date: Sun, 18 May 2014 16:59:36 +1000 Subject: staging: wlan-ng: use netdev_() instead of printk() Replaced all uses of printk() in wlan-ng with netdev_err / _warn where a netdev exists. If a few cases where a netdev does not yet exist, dev_ or pr_ was used. Checkpatch complains about lines over 80 chars or split string constants - the messages are just too long, keeping it completely happy would make the code less readable. Signed-off-by: Vitaly Osipov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/p80211conv.c | 31 ++++----- drivers/staging/wlan-ng/p80211req.c | 6 +- drivers/staging/wlan-ng/prism2fw.c | 101 ++++++++++++++-------------- drivers/staging/wlan-ng/prism2mgmt.c | 123 +++++++++++++++++++---------------- drivers/staging/wlan-ng/prism2mib.c | 4 +- drivers/staging/wlan-ng/prism2sta.c | 21 +++--- 6 files changed, 147 insertions(+), 139 deletions(-) diff --git a/drivers/staging/wlan-ng/p80211conv.c b/drivers/staging/wlan-ng/p80211conv.c index 3df753b51e89..913676e1797e 100644 --- a/drivers/staging/wlan-ng/p80211conv.c +++ b/drivers/staging/wlan-ng/p80211conv.c @@ -195,8 +195,8 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv, memcpy(p80211_hdr->a3.a3, &e_hdr.saddr, ETH_ALEN); break; default: - printk(KERN_ERR - "Error: Converting eth to wlan in unknown mode.\n"); + netdev_err(wlandev->netdev, + "Error: Converting eth to wlan in unknown mode.\n"); return 1; break; } @@ -213,7 +213,7 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv, (wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK), p80211_wep->iv, p80211_wep->icv); if (foo) { - printk(KERN_WARNING + netdev_warn(wlandev->netdev, "Host en-WEP failed, dropping frame (%d).\n", foo); return 2; @@ -310,7 +310,7 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv, } else { payload_offset = WLAN_HDR_A4_LEN; if (payload_length < WLAN_HDR_A4_LEN - WLAN_HDR_A3_LEN) { - printk(KERN_ERR "A4 frame too short!\n"); + netdev_err(netdev, "A4 frame too short!\n"); return 1; } payload_length -= (WLAN_HDR_A4_LEN - WLAN_HDR_A3_LEN); @@ -322,8 +322,8 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv, if ((wlandev->hostwep & HOSTWEP_PRIVACYINVOKED) && WLAN_GET_FC_ISWEP(fc) && (wlandev->hostwep & HOSTWEP_DECRYPT)) { if (payload_length <= 8) { - printk(KERN_ERR "WEP frame too short (%u).\n", - skb->len); + netdev_err(netdev, + "WEP frame too short (%u).\n", skb->len); return 1; } foo = wep_decrypt(wlandev, skb->data + payload_offset + 4, @@ -367,7 +367,7 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv, if (payload_length > (netdev->mtu + WLAN_ETHHDR_LEN)) { /* A bogus length ethfrm has been encap'd. */ /* Is someone trying an oflow attack? */ - printk(KERN_ERR "ENCAP frame too large (%d > %d)\n", + netdev_err(netdev, "ENCAP frame too large (%d > %d)\n", payload_length, netdev->mtu + WLAN_ETHHDR_LEN); return 1; } @@ -396,7 +396,7 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv, if (payload_length > netdev->mtu) { /* A bogus length ethfrm has been sent. */ /* Is someone trying an oflow attack? */ - printk(KERN_ERR "SNAP frame too large (%d > %d)\n", + netdev_err(netdev, "SNAP frame too large (%d > %d)\n", payload_length, netdev->mtu); return 1; } @@ -428,7 +428,7 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv, > netdev->mtu) { /* A bogus length ethfrm has been sent. */ /* Is someone trying an oflow attack? */ - printk(KERN_ERR "DIXII frame too large (%ld > %d)\n", + netdev_err(netdev, "DIXII frame too large (%ld > %d)\n", (long int)(payload_length - sizeof(struct wlan_llc) - sizeof(struct wlan_snap)), netdev->mtu); @@ -463,7 +463,7 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv, if (payload_length > netdev->mtu) { /* A bogus length ethfrm has been sent. */ /* Is someone trying an oflow attack? */ - printk(KERN_ERR "OTHER frame too large (%d > %d)\n", + netdev_err(netdev, "OTHER frame too large (%d > %d)\n", payload_length, netdev->mtu); return 1; } @@ -603,8 +603,8 @@ int p80211skb_rxmeta_attach(struct wlandevice *wlandev, struct sk_buff *skb) /* If these already have metadata, we error out! */ if (P80211SKB_RXMETA(skb) != NULL) { - printk(KERN_ERR "%s: RXmeta already attached!\n", - wlandev->name); + netdev_err(wlandev->netdev, + "%s: RXmeta already attached!\n", wlandev->name); result = 0; goto exit; } @@ -613,8 +613,8 @@ int p80211skb_rxmeta_attach(struct wlandevice *wlandev, struct sk_buff *skb) rxmeta = kzalloc(sizeof(struct p80211_rxmeta), GFP_ATOMIC); if (rxmeta == NULL) { - printk(KERN_ERR "%s: Failed to allocate rxmeta.\n", - wlandev->name); + netdev_err(wlandev->netdev, + "%s: Failed to allocate rxmeta.\n", wlandev->name); result = 1; goto exit; } @@ -656,6 +656,7 @@ void p80211skb_free(struct wlandevice *wlandev, struct sk_buff *skb) if (meta && meta->rx) p80211skb_rxmeta_detach(skb); else - printk(KERN_ERR "Freeing an skb (%p) w/ no frmmeta.\n", skb); + netdev_err(wlandev->netdev, + "Freeing an skb (%p) w/ no frmmeta.\n", skb); dev_kfree_skb(skb); } diff --git a/drivers/staging/wlan-ng/p80211req.c b/drivers/staging/wlan-ng/p80211req.c index cdfd808d6854..97795749a4ab 100644 --- a/drivers/staging/wlan-ng/p80211req.c +++ b/drivers/staging/wlan-ng/p80211req.c @@ -109,9 +109,9 @@ int p80211req_dorequest(wlandevice_t *wlandev, u8 *msgbuf) /* Check Permissions */ if (!capable(CAP_NET_ADMIN) && (msg->msgcode != DIDmsg_dot11req_mibget)) { - printk(KERN_ERR - "%s: only dot11req_mibget allowed for non-root.\n", - wlandev->name); + netdev_err(wlandev->netdev, + "%s: only dot11req_mibget allowed for non-root.\n", + wlandev->name); return -EPERM; } diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c index 2b0c23587dfc..f7870355c69f 100644 --- a/drivers/staging/wlan-ng/prism2fw.c +++ b/drivers/staging/wlan-ng/prism2fw.c @@ -205,19 +205,20 @@ static int prism2_fwtry(struct usb_device *udev, wlandevice_t *wlandev) { const struct firmware *fw_entry = NULL; - printk(KERN_INFO "prism2_usb: Checking for firmware %s\n", + netdev_info(wlandev->netdev, "prism2_usb: Checking for firmware %s\n", PRISM2_USB_FWFILE); if (request_ihex_firmware(&fw_entry, PRISM2_USB_FWFILE, &udev->dev) != 0) { - printk(KERN_INFO + netdev_info(wlandev->netdev, "prism2_usb: Firmware not available, but not essential\n"); - printk(KERN_INFO + netdev_info(wlandev->netdev, "prism2_usb: can continue to use card anyway.\n"); return 1; } - printk(KERN_INFO "prism2_usb: %s will be processed, size %zu\n", - PRISM2_USB_FWFILE, fw_entry->size); + netdev_info(wlandev->netdev, + "prism2_usb: %s will be processed, size %zu\n", + PRISM2_USB_FWFILE, fw_entry->size); prism2_fwapply((const struct ihex_binrec *)fw_entry->data, wlandev); release_firmware(fw_entry); @@ -275,7 +276,7 @@ static int prism2_fwapply(const struct ihex_binrec *rfptr, wlandevice_t *wlandev /* Build the PDA we're going to use. */ if (read_cardpda(&pda, wlandev)) { - printk(KERN_ERR "load_cardpda failed, exiting.\n"); + netdev_err(wlandev->netdev, "load_cardpda failed, exiting.\n"); return 1; } @@ -299,7 +300,7 @@ static int prism2_fwapply(const struct ihex_binrec *rfptr, wlandevice_t *wlandev /* DIDmsg_dot11req_mibget */ prism2mgmt_mibset_mibget(wlandev, &getmsg); if (getmsg.resultcode.data != P80211ENUM_resultcode_success) - printk(KERN_ERR "Couldn't fetch PRI-SUP info\n"); + netdev_err(wlandev->netdev, "Couldn't fetch PRI-SUP info\n"); /* Already in host order */ priid.role = *data++; @@ -311,19 +312,21 @@ static int prism2_fwapply(const struct ihex_binrec *rfptr, wlandevice_t *wlandev /* Read the S3 file */ result = read_fwfile(rfptr); if (result) { - printk(KERN_ERR "Failed to read the data exiting.\n"); + netdev_err(wlandev->netdev, + "Failed to read the data exiting.\n"); return 1; } result = validate_identity(); if (result) { - printk(KERN_ERR "Incompatible firmware image.\n"); + netdev_err(wlandev->netdev, "Incompatible firmware image.\n"); return 1; } if (startaddr == 0x00000000) { - printk(KERN_ERR "Can't RAM download a Flash image!\n"); + netdev_err(wlandev->netdev, + "Can't RAM download a Flash image!\n"); return 1; } @@ -333,20 +336,20 @@ static int prism2_fwapply(const struct ihex_binrec *rfptr, wlandevice_t *wlandev /* Do any plugging */ result = plugimage(fchunk, nfchunks, s3plug, ns3plug, &pda); if (result) { - printk(KERN_ERR "Failed to plug data.\n"); + netdev_err(wlandev->netdev, "Failed to plug data.\n"); return 1; } /* Insert any CRCs */ if (crcimage(fchunk, nfchunks, s3crc, ns3crc)) { - printk(KERN_ERR "Failed to insert all CRCs\n"); + netdev_err(wlandev->netdev, "Failed to insert all CRCs\n"); return 1; } /* Write the image */ result = writeimage(wlandev, fchunk, nfchunks); if (result) { - printk(KERN_ERR "Failed to ramwrite image data.\n"); + netdev_err(wlandev->netdev, "Failed to ramwrite image data.\n"); return 1; } @@ -354,7 +357,7 @@ static int prism2_fwapply(const struct ihex_binrec *rfptr, wlandevice_t *wlandev free_chunks(fchunk, &nfchunks); free_srecs(); - printk(KERN_INFO "prism2_usb: firmware loading finished.\n"); + netdev_info(wlandev->netdev, "prism2_usb: firmware loading finished.\n"); return result; } @@ -410,8 +413,7 @@ static int crcimage(struct imgchunk *fchunk, unsigned int nfchunks, break; } if (c >= nfchunks) { - printk(KERN_ERR - "Failed to find chunk for " + pr_err("Failed to find chunk for " "crcrec[%d], addr=0x%06x len=%d , " "aborting crc.\n", i, s3crc[i].addr, s3crc[i].len); @@ -537,8 +539,7 @@ static int mkimage(struct imgchunk *clist, unsigned int *ccnt) for (i = 0; i < *ccnt; i++) { clist[i].data = kzalloc(clist[i].len, GFP_KERNEL); if (clist[i].data == NULL) { - printk(KERN_ERR - "failed to allocate image space, exitting.\n"); + pr_err("failed to allocate image space, exitting.\n"); return 1; } pr_debug("chunk[%d]: addr=0x%06x len=%d\n", @@ -556,8 +557,7 @@ static int mkimage(struct imgchunk *clist, unsigned int *ccnt) break; } if (((unsigned int)j) >= (*ccnt)) { - printk(KERN_ERR - "s3rec(a=0x%06x,l=%d), no chunk match, exiting.\n", + pr_err("s3rec(a=0x%06x,l=%d), no chunk match, exiting.\n", s3start, s3data[i].len); return 1; } @@ -627,8 +627,7 @@ static int mkpdrlist(struct pda *pda) } if (curroff >= (HFA384x_PDA_LEN_MAX / 2)) { - printk(KERN_ERR - "no end record found or invalid lengths in " + pr_err("no end record found or invalid lengths in " "PDR data, exiting. %x %d\n", curroff, pda->nrec); return 1; } @@ -685,8 +684,7 @@ static int plugimage(struct imgchunk *fchunk, unsigned int nfchunks, j = -1; } if (j >= pda->nrec && j != -1) { /* if no matching PDR, fail */ - printk(KERN_WARNING - "warning: Failed to find PDR for " + pr_warn("warning: Failed to find PDR for " "plugrec 0x%04x.\n", s3plug[i].itemcode); continue; /* and move on to the next PDR */ #if 0 @@ -704,8 +702,7 @@ static int plugimage(struct imgchunk *fchunk, unsigned int nfchunks, /* Validate plug len against PDR len */ if (j != -1 && s3plug[i].len < le16_to_cpu(pda->rec[j]->len)) { - printk(KERN_ERR - "error: Plug vs. PDR len mismatch for " + pr_err("error: Plug vs. PDR len mismatch for " "plugrec 0x%04x, abort plugging.\n", s3plug[i].itemcode); result = 1; @@ -720,8 +717,7 @@ static int plugimage(struct imgchunk *fchunk, unsigned int nfchunks, break; } if (c >= nfchunks) { - printk(KERN_ERR - "error: Failed to find image chunk for " + pr_err("error: Failed to find image chunk for " "plugrec 0x%04x.\n", s3plug[i].itemcode); result = 1; continue; @@ -898,7 +894,7 @@ static int read_fwfile(const struct ihex_binrec *record) ns3plug++; if (ns3plug == S3PLUG_MAX) { - printk(KERN_ERR "S3 plugrec limit reached - aborting\n"); + pr_err("S3 plugrec limit reached - aborting\n"); return 1; } break; @@ -915,7 +911,7 @@ static int read_fwfile(const struct ihex_binrec *record) s3crc[ns3crc].dowrite); ns3crc++; if (ns3crc == S3CRC_MAX) { - printk(KERN_ERR "S3 crcrec limit reached - aborting\n"); + pr_err("S3 crcrec limit reached - aborting\n"); return 1; } break; @@ -929,7 +925,7 @@ static int read_fwfile(const struct ihex_binrec *record) s3info[ns3info].len, s3info[ns3info].type); if (((s3info[ns3info].len - 1) * sizeof(u16)) > sizeof(s3info[ns3info].info)) { - printk(KERN_ERR " S3 inforec length too long - aborting\n"); + pr_err("S3 inforec length too long - aborting\n"); return 1; } @@ -943,7 +939,7 @@ static int read_fwfile(const struct ihex_binrec *record) ns3info++; if (ns3info == S3INFO_MAX) { - printk(KERN_ERR "S3 inforec limit reached - aborting\n"); + pr_err("S3 inforec limit reached - aborting\n"); return 1; } break; @@ -953,7 +949,7 @@ static int read_fwfile(const struct ihex_binrec *record) s3data[ns3data].data = (uint8_t *) record->data; ns3data++; if (ns3data == S3DATA_MAX) { - printk(KERN_ERR "S3 datarec limit reached - aborting\n"); + pr_err("S3 datarec limit reached - aborting\n"); return 1; } break; @@ -997,9 +993,9 @@ static int writeimage(wlandevice_t *wlandev, struct imgchunk *fchunk, if (!rstmsg || !rwrmsg) { kfree(rstmsg); kfree(rwrmsg); - printk(KERN_ERR - "writeimage: no memory for firmware download, " - "aborting download\n"); + netdev_err(wlandev->netdev, + "writeimage: no memory for firmware download, " + "aborting download\n"); return -ENOMEM; } @@ -1042,16 +1038,16 @@ static int writeimage(wlandevice_t *wlandev, struct imgchunk *fchunk, result = prism2mgmt_ramdl_state(wlandev, rstmsg); if (result) { - printk(KERN_ERR - "writeimage state enable failed w/ result=%d, " - "aborting download\n", result); + netdev_err(wlandev->netdev, + "writeimage state enable failed w/ result=%d, " + "aborting download\n", result); goto free_result; } resultcode = rstmsg->resultcode.data; if (resultcode != P80211ENUM_resultcode_success) { - printk(KERN_ERR - "writeimage()->xxxdl_state msg indicates failure, " - "w/ resultcode=%d, aborting download.\n", resultcode); + netdev_err(wlandev->netdev, + "writeimage()->xxxdl_state msg indicates failure, " + "w/ resultcode=%d, aborting download.\n", resultcode); result = 1; goto free_result; } @@ -1085,15 +1081,14 @@ static int writeimage(wlandevice_t *wlandev, struct imgchunk *fchunk, /* Check the results */ if (result) { - printk(KERN_ERR - "writeimage chunk write failed w/ result=%d, " - "aborting download\n", result); + netdev_err(wlandev->netdev, + "writeimage chunk write failed w/ " + "result=%d, aborting download\n", result); goto free_result; } resultcode = rstmsg->resultcode.data; if (resultcode != P80211ENUM_resultcode_success) { - printk(KERN_ERR - "writeimage()->xxxdl_write msg indicates failure, " + pr_err("writeimage()->xxxdl_write msg indicates failure, " "w/ resultcode=%d, aborting download.\n", resultcode); result = 1; @@ -1110,16 +1105,16 @@ static int writeimage(wlandevice_t *wlandev, struct imgchunk *fchunk, result = prism2mgmt_ramdl_state(wlandev, rstmsg); if (result) { - printk(KERN_ERR - "writeimage state disable failed w/ result=%d, " - "aborting download\n", result); + netdev_err(wlandev->netdev, + "writeimage state disable failed w/ result=%d, " + "aborting download\n", result); goto free_result; } resultcode = rstmsg->resultcode.data; if (resultcode != P80211ENUM_resultcode_success) { - printk(KERN_ERR - "writeimage()->xxxdl_state msg indicates failure, " - "w/ resultcode=%d, aborting download.\n", resultcode); + netdev_err(wlandev->netdev, + "writeimage()->xxxdl_state msg indicates failure, " + "w/ resultcode=%d, aborting download.\n", resultcode); result = 1; goto free_result; } diff --git a/drivers/staging/wlan-ng/prism2mgmt.c b/drivers/staging/wlan-ng/prism2mgmt.c index a9909f6b0001..d110b362c3bd 100644 --- a/drivers/staging/wlan-ng/prism2mgmt.c +++ b/drivers/staging/wlan-ng/prism2mgmt.c @@ -129,8 +129,8 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) hw->ident_sta_fw.minor, hw->ident_sta_fw.variant) < HFA384x_FIRMWARE_VERSION(1, 3, 2)) { - printk(KERN_ERR - "HostScan not supported with current firmware (<1.3.2).\n"); + netdev_err(wlandev->netdev, + "HostScan not supported with current firmware (<1.3.2).\n"); result = 1; msg->resultcode.data = P80211ENUM_resultcode_not_supported; goto exit; @@ -143,8 +143,8 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) HFA384x_RID_CNFROAMINGMODE, &roamingmode); if (result) { - printk(KERN_ERR "getconfig(ROAMMODE) failed. result=%d\n", - result); + netdev_err(wlandev->netdev, + "getconfig(ROAMMODE) failed. result=%d\n", result); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; @@ -155,8 +155,8 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) HFA384x_RID_CNFROAMINGMODE, HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM); if (result) { - printk(KERN_ERR "setconfig(ROAMINGMODE) failed. result=%d\n", - result); + netdev_err(wlandev->netdev, + "setconfig(ROAMINGMODE) failed. result=%d\n", result); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; @@ -176,8 +176,9 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPASSIVESCANCTRL, word); if (result) { - printk(KERN_WARNING "Passive scan not supported with " - "current firmware. (<1.5.1)\n"); + netdev_warn(wlandev->netdev, + "Passive scan not supported with " + "current firmware. (<1.5.1)\n"); } } @@ -203,8 +204,8 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) /* Enable the MAC port if it's not already enabled */ result = hfa384x_drvr_getconfig16(hw, HFA384x_RID_PORTSTATUS, &word); if (result) { - printk(KERN_ERR "getconfig(PORTSTATUS) failed. " - "result=%d\n", result); + netdev_err(wlandev->netdev, + "getconfig(PORTSTATUS) failed. result=%d\n", result); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; @@ -216,9 +217,9 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) HFA384x_RID_CNFROAMINGMODE, HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM); if (result) { - printk(KERN_ERR - "setconfig(ROAMINGMODE) failed. result=%d\n", - result); + netdev_err(wlandev->netdev, + "setconfig(ROAMINGMODE) failed. result=%d\n", + result); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; @@ -232,7 +233,7 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) wordbuf, HFA384x_RID_CNFOWNSSID_LEN); if (result) { - printk(KERN_ERR "Failed to set OwnSSID.\n"); + netdev_err(wlandev->netdev, "Failed to set OwnSSID.\n"); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; @@ -241,7 +242,8 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) wordbuf, HFA384x_RID_CNFDESIREDSSID_LEN); if (result) { - printk(KERN_ERR "Failed to set DesiredSSID.\n"); + netdev_err(wlandev->netdev, + "Failed to set DesiredSSID.\n"); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; @@ -251,7 +253,8 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) HFA384x_RID_CNFPORTTYPE, HFA384x_PORTTYPE_IBSS); if (result) { - printk(KERN_ERR "Failed to set CNFPORTTYPE.\n"); + netdev_err(wlandev->netdev, + "Failed to set CNFPORTTYPE.\n"); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; @@ -261,15 +264,16 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) HFA384x_RID_CREATEIBSS, HFA384x_CREATEIBSS_JOINCREATEIBSS); if (result) { - printk(KERN_ERR "Failed to set CREATEIBSS.\n"); + netdev_err(wlandev->netdev, + "Failed to set CREATEIBSS.\n"); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; } result = hfa384x_drvr_enable(hw, 0); if (result) { - printk(KERN_ERR "drvr_enable(0) failed. " - "result=%d\n", result); + netdev_err(wlandev->netdev, + "drvr_enable(0) failed. result=%d\n", result); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; @@ -288,8 +292,8 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) HFA384x_RID_HOSTSCAN, &scanreq, sizeof(hfa384x_HostScanRequest_data_t)); if (result) { - printk(KERN_ERR "setconfig(SCANREQUEST) failed. result=%d\n", - result); + netdev_err(wlandev->netdev, + "setconfig(SCANREQUEST) failed. result=%d\n", result); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; @@ -310,8 +314,8 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) if (istmpenable) { result = hfa384x_drvr_disable(hw, 0); if (result) { - printk(KERN_ERR "drvr_disable(0) failed. " - "result=%d\n", result); + netdev_err(wlandev->netdev, + "drvr_disable(0) failed. result=%d\n", result); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; @@ -322,8 +326,8 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFROAMINGMODE, roamingmode); if (result) { - printk(KERN_ERR "setconfig(ROAMMODE) failed. result=%d\n", - result); + netdev_err(wlandev->netdev, + "setconfig(ROAMMODE) failed. result=%d\n", result); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; @@ -372,8 +376,9 @@ int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp) req->resultcode.status = P80211ENUM_msgitem_status_data_ok; if (!hw->scanresults) { - printk(KERN_ERR - "dot11req_scan_results can only be used after a successful dot11req_scan.\n"); + netdev_err(wlandev->netdev, + "dot11req_scan_results can only be used after " + "a successful dot11req_scan.\n"); result = 2; req->resultcode.data = P80211ENUM_resultcode_invalid_parameters; goto exit; @@ -555,14 +560,14 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp) result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFOWNSSID, bytebuf, HFA384x_RID_CNFOWNSSID_LEN); if (result) { - printk(KERN_ERR "Failed to set CnfOwnSSID\n"); + netdev_err(wlandev->netdev, "Failed to set CnfOwnSSID\n"); goto failed; } result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFDESIREDSSID, bytebuf, HFA384x_RID_CNFDESIREDSSID_LEN); if (result) { - printk(KERN_ERR "Failed to set CnfDesiredSSID\n"); + netdev_err(wlandev->netdev, "Failed to set CnfDesiredSSID\n"); goto failed; } @@ -574,7 +579,8 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp) word = msg->beaconperiod.data; result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFAPBCNint, word); if (result) { - printk(KERN_ERR "Failed to set beacon period=%d.\n", word); + netdev_err(wlandev->netdev, + "Failed to set beacon period=%d.\n", word); goto failed; } @@ -582,7 +588,8 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp) word = msg->dschannel.data; result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFOWNCHANNEL, word); if (result) { - printk(KERN_ERR "Failed to set channel=%d.\n", word); + netdev_err(wlandev->netdev, + "Failed to set channel=%d.\n", word); goto failed; } /* Basic rates */ @@ -610,7 +617,8 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp) result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFBASICRATES, word); if (result) { - printk(KERN_ERR "Failed to set basicrates=%d.\n", word); + netdev_err(wlandev->netdev, + "Failed to set basicrates=%d.\n", word); goto failed; } @@ -639,13 +647,14 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp) result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFSUPPRATES, word); if (result) { - printk(KERN_ERR "Failed to set supprates=%d.\n", word); + netdev_err(wlandev->netdev, + "Failed to set supprates=%d.\n", word); goto failed; } result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_TXRATECNTL, word); if (result) { - printk(KERN_ERR "Failed to set txrates=%d.\n", word); + netdev_err(wlandev->netdev, "Failed to set txrates=%d.\n", word); goto failed; } @@ -659,7 +668,8 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp) /* Enable the Port */ result = hfa384x_drvr_enable(hw, 0); if (result) { - printk(KERN_ERR "Enable macport failed, result=%d.\n", result); + netdev_err(wlandev->netdev, + "Enable macport failed, result=%d.\n", result); goto failed; } @@ -704,8 +714,8 @@ int prism2mgmt_readpda(wlandevice_t *wlandev, void *msgp) * state. */ if (wlandev->msdstate != WLAN_MSD_FWLOAD) { - printk(KERN_ERR - "PDA may only be read " "in the fwload state.\n"); + netdev_err(wlandev->netdev, + "PDA may only be read in the fwload state.\n"); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; @@ -717,9 +727,9 @@ int prism2mgmt_readpda(wlandevice_t *wlandev, void *msgp) msg->pda.data, HFA384x_PDA_LEN_MAX); if (result) { - printk(KERN_ERR - "hfa384x_drvr_readpda() failed, " - "result=%d\n", result); + netdev_err(wlandev->netdev, + "hfa384x_drvr_readpda() failed, " + "result=%d\n", result); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; @@ -766,9 +776,9 @@ int prism2mgmt_ramdl_state(wlandevice_t *wlandev, void *msgp) struct p80211msg_p2req_ramdl_state *msg = msgp; if (wlandev->msdstate != WLAN_MSD_FWLOAD) { - printk(KERN_ERR - "ramdl_state(): may only be called " - "in the fwload state.\n"); + netdev_err(wlandev->netdev, + "ramdl_state(): may only be called " + "in the fwload state.\n"); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; @@ -825,9 +835,9 @@ int prism2mgmt_ramdl_write(wlandevice_t *wlandev, void *msgp) u8 *buf; if (wlandev->msdstate != WLAN_MSD_FWLOAD) { - printk(KERN_ERR - "ramdl_write(): may only be called " - "in the fwload state.\n"); + netdev_err(wlandev->netdev, + "ramdl_write(): may only be called " + "in the fwload state.\n"); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; @@ -885,9 +895,9 @@ int prism2mgmt_flashdl_state(wlandevice_t *wlandev, void *msgp) struct p80211msg_p2req_flashdl_state *msg = msgp; if (wlandev->msdstate != WLAN_MSD_FWLOAD) { - printk(KERN_ERR - "flashdl_state(): may only be called " - "in the fwload state.\n"); + netdev_err(wlandev->netdev, + "flashdl_state(): may only be called " + "in the fwload state.\n"); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; @@ -920,8 +930,9 @@ int prism2mgmt_flashdl_state(wlandevice_t *wlandev, void *msgp) wlandev->msdstate = WLAN_MSD_HWPRESENT; result = prism2sta_ifstate(wlandev, P80211ENUM_ifstate_fwload); if (result != P80211ENUM_resultcode_success) { - printk(KERN_ERR "prism2sta_ifstate(fwload) failed," - "P80211ENUM_resultcode=%d\n", result); + netdev_err(wlandev->netdev, + "prism2sta_ifstate(fwload) failed," + "P80211ENUM_resultcode=%d\n", result); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; result = -1; @@ -958,9 +969,9 @@ int prism2mgmt_flashdl_write(wlandevice_t *wlandev, void *msgp) u8 *buf; if (wlandev->msdstate != WLAN_MSD_FWLOAD) { - printk(KERN_ERR - "flashdl_write(): may only be called " - "in the fwload state.\n"); + netdev_err(wlandev->netdev, + "flashdl_write(): may only be called " + "in the fwload state.\n"); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; @@ -1153,7 +1164,7 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp) } - printk(KERN_INFO "monitor mode disabled\n"); + netdev_info(wlandev->netdev, "monitor mode disabled\n"); msg->resultcode.data = P80211ENUM_resultcode_success; result = 0; goto exit; @@ -1282,7 +1293,7 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp) } if (wlandev->netdev->type == ARPHRD_ETHER) - printk(KERN_INFO "monitor mode enabled\n"); + netdev_info(wlandev->netdev, "monitor mode enabled\n"); /* Set the driver state */ /* Do we want the prism2 header? */ diff --git a/drivers/staging/wlan-ng/prism2mib.c b/drivers/staging/wlan-ng/prism2mib.c index 9b5f3b72d3ca..0fb42dfca2a4 100644 --- a/drivers/staging/wlan-ng/prism2mib.c +++ b/drivers/staging/wlan-ng/prism2mib.c @@ -672,7 +672,7 @@ static int prism2mib_fragmentationthreshold(struct mibrec *mib, if (!isget) if ((*uint32) % 2) { - printk(KERN_WARNING "Attempt to set odd number " + netdev_warn(wlandev->netdev, "Attempt to set odd number " "FragmentationThreshold\n"); msg->resultcode.data = P80211ENUM_resultcode_not_supported; @@ -742,7 +742,7 @@ static int prism2mib_priv(struct mibrec *mib, break; } default: - printk(KERN_ERR "Unhandled DID 0x%08x\n", mib->did); + netdev_err(wlandev->netdev, "Unhandled DID 0x%08x\n", mib->did); } return 0; diff --git a/drivers/staging/wlan-ng/prism2sta.c b/drivers/staging/wlan-ng/prism2sta.c index 3fd4538d9408..278b6a1ef31f 100644 --- a/drivers/staging/wlan-ng/prism2sta.c +++ b/drivers/staging/wlan-ng/prism2sta.c @@ -401,8 +401,9 @@ static int prism2sta_mlmerequest(wlandevice_t *wlandev, struct p80211msg *msg) break; } default: - printk(KERN_WARNING "Unknown mgmt request message 0x%08x", - msg->msgcode); + netdev_warn(wlandev->netdev, + "Unknown mgmt request message 0x%08x", + msg->msgcode); break; } @@ -465,7 +466,7 @@ u32 prism2sta_ifstate(wlandevice_t *wlandev, u32 ifstate) result = P80211ENUM_resultcode_success; break; case WLAN_MSD_RUNNING: - printk(KERN_WARNING + netdev_warn(wlandev->netdev, "Cannot enter fwload state from enable state," "you must disable first.\n"); result = P80211ENUM_resultcode_invalid_parameters; @@ -1427,7 +1428,7 @@ void prism2sta_processing_defer(struct work_struct *data) default: /* This is bad, IO port problems? */ - printk(KERN_WARNING + netdev_warn(wlandev->netdev, "unknown linkstatus=0x%02x\n", hw->link_status); return; } @@ -1509,7 +1510,7 @@ static void prism2sta_inf_assocstatus(wlandevice_t *wlandev, if (i >= hw->authlist.cnt) { if (rec.assocstatus != HFA384x_ASSOCSTATUS_AUTHFAIL) - printk(KERN_WARNING + netdev_warn(wlandev->netdev, "assocstatus info frame received for non-authenticated station.\n"); } else { hw->authlist.assoc[i] = @@ -1517,7 +1518,7 @@ static void prism2sta_inf_assocstatus(wlandevice_t *wlandev, rec.assocstatus == HFA384x_ASSOCSTATUS_REASSOC); if (rec.assocstatus == HFA384x_ASSOCSTATUS_AUTHFAIL) - printk(KERN_WARNING + netdev_warn(wlandev->netdev, "authfail assocstatus info frame received for authenticated station.\n"); } } @@ -1787,16 +1788,16 @@ void prism2sta_ev_info(wlandevice_t *wlandev, hfa384x_InfFrame_t *inf) prism2sta_inf_psusercnt(wlandev, inf); break; case HFA384x_IT_KEYIDCHANGED: - printk(KERN_WARNING "Unhandled IT_KEYIDCHANGED\n"); + netdev_warn(wlandev->netdev, "Unhandled IT_KEYIDCHANGED\n"); break; case HFA384x_IT_ASSOCREQ: - printk(KERN_WARNING "Unhandled IT_ASSOCREQ\n"); + netdev_warn(wlandev->netdev, "Unhandled IT_ASSOCREQ\n"); break; case HFA384x_IT_MICFAILURE: - printk(KERN_WARNING "Unhandled IT_MICFAILURE\n"); + netdev_warn(wlandev->netdev, "Unhandled IT_MICFAILURE\n"); break; default: - printk(KERN_WARNING + netdev_warn(wlandev->netdev, "Unknown info type=0x%02x\n", inf->infotype); break; } -- cgit v1.2.3 From 9140fcd655541fee5655701df05ab0b06653c24c Mon Sep 17 00:00:00 2001 From: Daeseok Youn Date: Mon, 19 May 2014 18:56:34 +0900 Subject: staging: dgap: implement error handling in dgap_tty_register() - alloc_tty_driver() is deprecated so it is changed to tty_alloc_driver() - Pointers which are allocated by alloc_tty_driver() and kzalloc() can be NULL so it need to check NULL for them. - If one of those is failed, it need to add proper handler for avoiding memory leak. - If both of drivers are registered normally, and then set TRUE to dgap_major_serial{print}_registered. If one of drivers is failed to register, leave a default value as FALSE. Signed-off-by: Daeseok Youn Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 45 +++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index d7cfc453e4f5..8cf0816c0217 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -1210,9 +1210,11 @@ static int dgap_ms_sleep(ulong ms) */ static int dgap_tty_register(struct board_t *brd) { - int rc = 0; + int rc; - brd->serial_driver = alloc_tty_driver(MAXPORTS); + brd->serial_driver = tty_alloc_driver(MAXPORTS, 0); + if (IS_ERR(brd->serial_driver)) + return PTR_ERR(brd->serial_driver); snprintf(brd->serial_name, MAXTTYNAMELEN, "tty_dgap_%d_", brd->boardnum); @@ -1231,8 +1233,10 @@ static int dgap_tty_register(struct board_t *brd) /* The kernel wants space to store pointers to tty_structs */ brd->serial_driver->ttys = kzalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL); - if (!brd->serial_driver->ttys) - return -ENOMEM; + if (!brd->serial_driver->ttys) { + rc = -ENOMEM; + goto free_serial_drv; + } /* * Entry points for driver. Called by the kernel from @@ -1245,7 +1249,11 @@ static int dgap_tty_register(struct board_t *brd) * again, separately so we don't get the LD confused about what major * we are when we get into the dgap_tty_open() routine. */ - brd->print_driver = alloc_tty_driver(MAXPORTS); + brd->print_driver = tty_alloc_driver(MAXPORTS, 0); + if (IS_ERR(brd->print_driver)) { + rc = PTR_ERR(brd->print_driver); + goto free_serial_drv; + } snprintf(brd->print_name, MAXTTYNAMELEN, "pr_dgap_%d_", brd->boardnum); @@ -1264,8 +1272,10 @@ static int dgap_tty_register(struct board_t *brd) /* The kernel wants space to store pointers to tty_structs */ brd->print_driver->ttys = kzalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL); - if (!brd->print_driver->ttys) - return -ENOMEM; + if (!brd->print_driver->ttys) { + rc = -ENOMEM; + goto free_print_drv; + } /* * Entry points for driver. Called by the kernel from @@ -1276,19 +1286,30 @@ static int dgap_tty_register(struct board_t *brd) /* Register tty devices */ rc = tty_register_driver(brd->serial_driver); if (rc < 0) - return rc; - brd->dgap_major_serial_registered = TRUE; - dgap_boards_by_major[brd->serial_driver->major] = brd; - brd->dgap_serial_major = brd->serial_driver->major; + goto free_print_drv; /* Register Transparent Print devices */ rc = tty_register_driver(brd->print_driver); if (rc < 0) - return rc; + goto unregister_serial_drv; + + brd->dgap_major_serial_registered = TRUE; + dgap_boards_by_major[brd->serial_driver->major] = brd; + brd->dgap_serial_major = brd->serial_driver->major; + brd->dgap_major_transparent_print_registered = TRUE; dgap_boards_by_major[brd->print_driver->major] = brd; brd->dgap_transparent_print_major = brd->print_driver->major; + return 0; + +unregister_serial_drv: + tty_unregister_driver(brd->serial_driver); +free_print_drv: + put_tty_driver(brd->print_driver); +free_serial_drv: + put_tty_driver(brd->serial_driver); + return rc; } -- cgit v1.2.3 From e54766c08a7b41b5ac7f90e84060c3da3fddf6e4 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 21 May 2014 13:02:52 -0400 Subject: staging: dgap: fix smatch warn: unsigned var is never less than zero This patch fixes a smatch warning about an unsigned integer being tested for less than zero. Signed-off-by: Mark Hounschell Tested-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h index cd2150bf88f1..650a4624d940 100644 --- a/drivers/staging/dgap/dgap.h +++ b/drivers/staging/dgap/dgap.h @@ -637,7 +637,7 @@ struct un_t { struct channel_t *un_ch; u32 un_time; u32 un_type; - u32 un_open_count; /* Counter of opens to port */ + int un_open_count; /* Counter of opens to port */ struct tty_struct *un_tty;/* Pointer to unit tty structure */ u32 un_flags; /* Unit flags */ wait_queue_head_t un_flags_wait; /* Place to sleep to wait on unit */ -- cgit v1.2.3 From d78acae3d172991dd960b57ad9f18e4471b7d8fe Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 21 May 2014 15:08:32 -0400 Subject: staging: dgap: Remove dead sniff buffer code The sniff buffer was a /proc filesystem file. This module no longer uses /proc. This patch removes the deaed code associated with the sniff buffer. Signed-off-by: Mark Hounschell Tested-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 124 -------------------------------------------- drivers/staging/dgap/dgap.h | 6 --- 2 files changed, 130 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 8cf0816c0217..b452d840c5af 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -1464,7 +1464,6 @@ static int dgap_tty_init(struct board_t *brd) init_waitqueue_head(&ch->ch_flags_wait); init_waitqueue_head(&ch->ch_tun.un_flags_wait); init_waitqueue_head(&ch->ch_pun.un_flags_wait); - init_waitqueue_head(&ch->ch_sniff_wait); /* Turn on all modem interrupts for now */ modem = (DM_CD | DM_DSR | DM_CTS | DM_RI); @@ -1531,123 +1530,6 @@ static void dgap_tty_uninit(struct board_t *brd) } } -#define TMPBUFLEN (1024) -/* - * dgap_sniff - Dump data out to the "sniff" buffer if the - * proc sniff file is opened... - */ -static void dgap_sniff_nowait_nolock(struct channel_t *ch, u8 *text, - u8 *buf, int len) -{ - struct timeval tv; - int n; - int r; - int nbuf; - int i; - int tmpbuflen; - char tmpbuf[TMPBUFLEN]; - char *p = tmpbuf; - int too_much_data; - - /* Leave if sniff not open */ - if (!(ch->ch_sniff_flags & SNIFF_OPEN)) - return; - - do_gettimeofday(&tv); - - /* Create our header for data dump */ - p += sprintf(p, "<%ld %ld><%s><", tv.tv_sec, tv.tv_usec, text); - tmpbuflen = p - tmpbuf; - - do { - too_much_data = 0; - - for (i = 0; i < len && tmpbuflen < (TMPBUFLEN - 4); i++) { - p += sprintf(p, "%02x ", *buf); - buf++; - tmpbuflen = p - tmpbuf; - } - - if (tmpbuflen < (TMPBUFLEN - 4)) { - if (i > 0) - p += sprintf(p - 1, "%s\n", ">"); - else - p += sprintf(p, "%s\n", ">"); - } else { - too_much_data = 1; - len -= i; - } - - nbuf = strlen(tmpbuf); - p = tmpbuf; - - /* - * Loop while data remains. - */ - while (nbuf > 0 && ch->ch_sniff_buf) { - /* - * Determine the amount of available space left in the - * buffer. If there's none, wait until some appears. - */ - n = (ch->ch_sniff_out - ch->ch_sniff_in - 1) & - SNIFF_MASK; - - /* - * If there is no space left to write to in our sniff - * buffer, we have no choice but to drop the data. - * We *cannot* sleep here waiting for space, because - * this function was probably called by the - * interrupt/timer routines! - */ - if (n == 0) - return; - - /* - * Copy as much data as will fit. - */ - - if (n > nbuf) - n = nbuf; - - r = SNIFF_MAX - ch->ch_sniff_in; - - if (r <= n) { - memcpy(ch->ch_sniff_buf + - ch->ch_sniff_in, p, r); - - n -= r; - ch->ch_sniff_in = 0; - p += r; - nbuf -= r; - } - - memcpy(ch->ch_sniff_buf + ch->ch_sniff_in, p, n); - - ch->ch_sniff_in += n; - p += n; - nbuf -= n; - - /* - * Wakeup any thread waiting for data - */ - if (ch->ch_sniff_flags & SNIFF_WAIT_DATA) { - ch->ch_sniff_flags &= ~SNIFF_WAIT_DATA; - wake_up_interruptible(&ch->ch_sniff_wait); - } - } - - /* - * If the user sent us too much data to push into our tmpbuf, - * we need to keep looping around on all the data. - */ - if (too_much_data) { - p = tmpbuf; - tmpbuflen = 0; - } - - } while (too_much_data); -} - /*======================================================================= * * dgap_input - Process received data. @@ -1811,7 +1693,6 @@ static void dgap_input(struct channel_t *ch) break; memcpy_fromio(buf, ch->ch_raddr + tail, s); - dgap_sniff_nowait_nolock(ch, "USER READ", buf, s); tail += s; buf += s; @@ -2875,8 +2756,6 @@ static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, vaddr = ch->ch_taddr + head; memcpy_toio(vaddr, (u8 *) buf, remain); - dgap_sniff_nowait_nolock(ch, "USER WRITE", (u8 *) buf, - remain); head = ch->ch_tstart; buf += remain; @@ -2891,9 +2770,6 @@ static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, remain = n; memcpy_toio(vaddr, (u8 *) buf, remain); - dgap_sniff_nowait_nolock(ch, "USER WRITE", (u8 *)buf, - remain); - head += remain; } diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h index 650a4624d940..03c020e35f88 100644 --- a/drivers/staging/dgap/dgap.h +++ b/drivers/staging/dgap/dgap.h @@ -1041,12 +1041,6 @@ struct channel_t { ulong ch_err_frame; /* Count of framing errors on channel */ ulong ch_err_break; /* Count of breaks on channel */ ulong ch_err_overrun; /* Count of overruns on channel */ - - uint ch_sniff_in; - uint ch_sniff_out; - char *ch_sniff_buf; /* Sniff buffer for proc */ - ulong ch_sniff_flags; /* Channel flags */ - wait_queue_head_t ch_sniff_wait; }; /************************************************************************ -- cgit v1.2.3 From 5512d3971ba7368a5df8e08ca8f93622c10247c3 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 21 May 2014 15:16:02 -0400 Subject: staging: dgap: Remove erroneous comment This patch removes a false comment Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index b452d840c5af..b34d903d596a 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -567,7 +567,6 @@ static int dgap_init_pci(void) return pci_register_driver(&dgap_driver); } -/* returns count (>= 0), or negative on error */ static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) { int rc; -- cgit v1.2.3 From 490de248d6479654f0120d1b9675424bfed34a3c Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 21 May 2014 15:48:47 -0400 Subject: staging: dgap: Remove unnecessary test on count This patch removes an unnecessary test. We've already tested it by the time we get here with no possiblity of it being changed. Signed-off-by: Mark Hounschell Tested-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index b34d903d596a..28c238141264 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -2731,16 +2731,6 @@ static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, ch->ch_flags &= ~CH_PRON; } - /* - * If there is nothing left to copy, or - * I can't handle any more data, leave. - */ - if (count <= 0) { - dgap_set_firmware_event(un, UN_LOW | UN_EMPTY); - spin_unlock_irqrestore(&ch->ch_lock, lock_flags); - return 0; - } - n = count; /* -- cgit v1.2.3 From 608144375866db32a6946df56491c143e0f52630 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 21 May 2014 16:17:51 -0400 Subject: staging: dgap: replace dgap_savestring function with kstrdup Removes dgap_savestring function to use kstrdup instead. Signed-off-by: Mark Hounschell Tested-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 44 +++++++++++++++----------------------------- 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 28c238141264..2ab7b7c2fc38 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -150,7 +150,6 @@ static void dgap_firmware_reset_port(struct channel_t *ch); */ static int dgap_gettok(char **in, struct cnode *p); static char *dgap_getword(char **in); -static char *dgap_savestring(char *s); static struct cnode *dgap_newnode(int t); static int dgap_checknode(struct cnode *p); static void dgap_err(char *s); @@ -6449,7 +6448,7 @@ static int dgap_parsefile(char **in, int remove) } p = p->next; - p->u.board.status = dgap_savestring("No"); + p->u.board.status = kstrdup("No", GFP_KERNEL); line = conc = NULL; brd = p; linecnt = -1; @@ -6547,7 +6546,7 @@ static int dgap_parsefile(char **in, int remove) dgap_err("unexpected end of file"); return -1; } - p->u.board.portstr = dgap_savestring(s); + p->u.board.portstr = kstrdup(s, GFP_KERNEL); if (kstrtol(s, 0, &p->u.board.port)) { dgap_err("bad number for IO port"); return -1; @@ -6565,7 +6564,7 @@ static int dgap_parsefile(char **in, int remove) dgap_err("unexpected end of file"); return -1; } - p->u.board.addrstr = dgap_savestring(s); + p->u.board.addrstr = kstrdup(s, GFP_KERNEL); if (kstrtoul(s, 0, &p->u.board.addr)) { dgap_err("bad number for memory address"); return -1; @@ -6583,7 +6582,7 @@ static int dgap_parsefile(char **in, int remove) dgap_err("unexpected end of file"); return -1; } - p->u.board.pcibusstr = dgap_savestring(s); + p->u.board.pcibusstr = kstrdup(s, GFP_KERNEL); if (kstrtoul(s, 0, &p->u.board.pcibus)) { dgap_err("bad number for pci bus"); return -1; @@ -6594,7 +6593,7 @@ static int dgap_parsefile(char **in, int remove) dgap_err("unexpected end of file"); return -1; } - p->u.board.pcislotstr = dgap_savestring(s); + p->u.board.pcislotstr = kstrdup(s, GFP_KERNEL); if (kstrtoul(s, 0, &p->u.board.pcislot)) { dgap_err("bad number for pci slot"); return -1; @@ -6612,7 +6611,7 @@ static int dgap_parsefile(char **in, int remove) dgap_err("unexpected end of file"); return -1; } - p->u.board.method = dgap_savestring(s); + p->u.board.method = kstrdup(s, GFP_KERNEL); p->u.board.v_method = 1; break; @@ -6626,7 +6625,7 @@ static int dgap_parsefile(char **in, int remove) dgap_err("unexpected end of file"); return -1; } - p->u.board.status = dgap_savestring(s); + p->u.board.status = kstrdup(s, GFP_KERNEL); break; case NPORTS: /* number of ports */ @@ -6676,13 +6675,13 @@ static int dgap_parsefile(char **in, int remove) return -1; } - p->u.board.status = dgap_savestring(s); + p->u.board.status = kstrdup(s, GFP_KERNEL); if (p->type == CNODE) { - p->u.conc.id = dgap_savestring(s); + p->u.conc.id = kstrdup(s, GFP_KERNEL); p->u.conc.v_id = 1; } else if (p->type == MNODE) { - p->u.module.id = dgap_savestring(s); + p->u.module.id = kstrdup(s, GFP_KERNEL); p->u.module.v_id = 1; } else { dgap_err("id only valid for concentrators or modules"); @@ -6744,7 +6743,7 @@ static int dgap_parsefile(char **in, int remove) dgap_err("unexpeced end of file"); return -1; } - p->u.ttyname = dgap_savestring(s); + p->u.ttyname = kstrdup(s, GFP_KERNEL); if (!p->u.ttyname) { dgap_err("out of memory"); return -1; @@ -6765,7 +6764,7 @@ static int dgap_parsefile(char **in, int remove) dgap_err("unexpeced end of file"); return -1; } - p->u.cuname = dgap_savestring(s); + p->u.cuname = kstrdup(s, GFP_KERNEL); if (!p->u.cuname) { dgap_err("out of memory"); return -1; @@ -6889,7 +6888,7 @@ static int dgap_parsefile(char **in, int remove) dgap_err("unexpected end of file"); return -1; } - p->u.line.cable = dgap_savestring(s); + p->u.line.cable = kstrdup(s, GFP_KERNEL); p->u.line.v_cable = 1; } break; @@ -6930,7 +6929,7 @@ static int dgap_parsefile(char **in, int remove) dgap_err("unexpected end of file"); return -1; } - p->u.conc.connect = dgap_savestring(s); + p->u.conc.connect = kstrdup(s, GFP_KERNEL); p->u.conc.v_connect = 1; } break; @@ -6948,7 +6947,7 @@ static int dgap_parsefile(char **in, int remove) dgap_err("unexpeced end of file"); return -1; } - p->u.printname = dgap_savestring(s); + p->u.printname = kstrdup(s, GFP_KERNEL); if (!p->u.printname) { dgap_err("out of memory"); return -1; @@ -7313,19 +7312,6 @@ static int dgap_checknode(struct cnode *p) return 0; } -/* - * save a string somewhere - */ -static char *dgap_savestring(char *s) -{ - char *p; - - p = kmalloc(strlen(s) + 1, GFP_ATOMIC); - if (p) - strcpy(p, s); - return p; -} - /* * Given a board pointer, returns whether we should use interrupts or not. */ -- cgit v1.2.3 From 6d602cf17b5672525cb6491cf3bf0b01ede8904d Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Fri, 16 May 2014 12:31:45 +0900 Subject: staging: ft1000: Convert printk to dev_err in ft1000_cs.c This patch converts printk to dev_err in ft1000_cs.c Signed-off-by: Masanari Iida Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.c index f376ca43720d..1f8b3ca35c69 100644 --- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.c +++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.c @@ -95,20 +95,20 @@ static int ft1000_config(struct pcmcia_device *link) /* setup IO window */ ret = pcmcia_loop_config(link, ft1000_confcheck, NULL); if (ret) { - printk(KERN_INFO "ft1000: Could not configure pcmcia\n"); + dev_err(&link->dev, "Could not configure pcmcia\n"); return -ENODEV; } /* configure device */ ret = pcmcia_enable_device(link); if (ret) { - printk(KERN_INFO "ft1000: could not enable pcmcia\n"); + dev_err(&link->dev, "Could not enable pcmcia\n"); goto failed; } link->priv = init_ft1000_card(link, &ft1000_reset); if (!link->priv) { - printk(KERN_INFO "ft1000: Could not register as network device\n"); + dev_err(&link->dev, "Could not register as network device\n"); goto failed; } -- cgit v1.2.3 From 9267462e6ca233ba3227c046f704018b38e944ca Mon Sep 17 00:00:00 2001 From: Eli Billauer Date: Sun, 11 May 2014 19:53:46 +0300 Subject: staging: xillybus: Use devm_ API on probe and remove Suggested-by: Baruch Siach Signed-off-by: Eli Billauer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xillybus/xillybus.h | 1 - drivers/staging/xillybus/xillybus_core.c | 2 +- drivers/staging/xillybus/xillybus_of.c | 47 +++++------------------ drivers/staging/xillybus/xillybus_pcie.c | 65 +++++++++----------------------- 4 files changed, 27 insertions(+), 88 deletions(-) diff --git a/drivers/staging/xillybus/xillybus.h b/drivers/staging/xillybus/xillybus.h index e5e91d612885..78a749a7a1c1 100644 --- a/drivers/staging/xillybus/xillybus.h +++ b/drivers/staging/xillybus/xillybus.h @@ -116,7 +116,6 @@ struct xilly_endpoint { */ struct pci_dev *pdev; struct device *dev; - struct resource res; /* OF devices only */ struct xilly_endpoint_hardware *ephw; struct list_head ep_list; diff --git a/drivers/staging/xillybus/xillybus_core.c b/drivers/staging/xillybus/xillybus_core.c index b0a6696f2da0..fe8f9d28b03b 100644 --- a/drivers/staging/xillybus/xillybus_core.c +++ b/drivers/staging/xillybus/xillybus_core.c @@ -2094,7 +2094,7 @@ struct xilly_endpoint *xillybus_init_endpoint(struct pci_dev *pdev, { struct xilly_endpoint *endpoint; - endpoint = kzalloc(sizeof(*endpoint), GFP_KERNEL); + endpoint = devm_kzalloc(dev, sizeof(*endpoint), GFP_KERNEL); if (!endpoint) { dev_err(dev, "Failed to allocate memory. Aborting.\n"); return NULL; diff --git a/drivers/staging/xillybus/xillybus_of.c b/drivers/staging/xillybus/xillybus_of.c index 23a609b0ab1d..46ea010b4ac6 100644 --- a/drivers/staging/xillybus/xillybus_of.c +++ b/drivers/staging/xillybus/xillybus_of.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "xillybus.h" MODULE_DESCRIPTION("Xillybus driver for Open Firmware"); @@ -123,6 +124,7 @@ static int xilly_drv_probe(struct platform_device *op) struct xilly_endpoint *endpoint; int rc = 0; int irq; + struct resource res; struct xilly_endpoint_hardware *ephw = &of_hw; if (of_property_read_bool(dev->of_node, "dma-coherent")) @@ -135,38 +137,26 @@ static int xilly_drv_probe(struct platform_device *op) dev_set_drvdata(dev, endpoint); - rc = of_address_to_resource(dev->of_node, 0, &endpoint->res); + rc = of_address_to_resource(dev->of_node, 0, &res); if (rc) { dev_warn(endpoint->dev, "Failed to obtain device tree resource\n"); - goto failed_request_regions; + return rc; } - if (!request_mem_region(endpoint->res.start, - resource_size(&endpoint->res), xillyname)) { - dev_err(endpoint->dev, - "request_mem_region failed. Aborting.\n"); - rc = -EBUSY; - goto failed_request_regions; - } + endpoint->registers = devm_ioremap_resource(dev, &res); - endpoint->registers = of_iomap(dev->of_node, 0); - if (!endpoint->registers) { - dev_err(endpoint->dev, - "Failed to map I/O memory. Aborting.\n"); - rc = -EIO; - goto failed_iomap0; - } + if (IS_ERR(endpoint->registers)) + return PTR_ERR(endpoint->registers); irq = irq_of_parse_and_map(dev->of_node, 0); - rc = request_irq(irq, xillybus_isr, 0, xillyname, endpoint); + rc = devm_request_irq(dev, irq, xillybus_isr, 0, xillyname, endpoint); if (rc) { dev_err(endpoint->dev, "Failed to register IRQ handler. Aborting.\n"); - rc = -ENODEV; - goto failed_register_irq; + return -ENODEV; } rc = xillybus_endpoint_discovery(endpoint); @@ -174,18 +164,8 @@ static int xilly_drv_probe(struct platform_device *op) if (!rc) return 0; - free_irq(irq, endpoint); - -failed_register_irq: - iounmap(endpoint->registers); -failed_iomap0: - release_mem_region(endpoint->res.start, - resource_size(&endpoint->res)); - -failed_request_regions: xillybus_do_cleanup(&endpoint->cleanup, endpoint); - kfree(endpoint); return rc; } @@ -193,20 +173,11 @@ static int xilly_drv_remove(struct platform_device *op) { struct device *dev = &op->dev; struct xilly_endpoint *endpoint = dev_get_drvdata(dev); - int irq = irq_of_parse_and_map(dev->of_node, 0); xillybus_endpoint_remove(endpoint); - free_irq(irq, endpoint); - - iounmap(endpoint->registers); - release_mem_region(endpoint->res.start, - resource_size(&endpoint->res)); - xillybus_do_cleanup(&endpoint->cleanup, endpoint); - kfree(endpoint); - return 0; } diff --git a/drivers/staging/xillybus/xillybus_pcie.c b/drivers/staging/xillybus/xillybus_pcie.c index 51426d80ca7b..a4fe51c90e92 100644 --- a/drivers/staging/xillybus/xillybus_pcie.c +++ b/drivers/staging/xillybus/xillybus_pcie.c @@ -141,38 +141,32 @@ static int xilly_probe(struct pci_dev *pdev, pci_set_drvdata(pdev, endpoint); - rc = pci_enable_device(pdev); - - /* L0s has caused packet drops. No power saving, thank you. */ - - pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S); + rc = pcim_enable_device(pdev); if (rc) { dev_err(endpoint->dev, - "pci_enable_device() failed. Aborting.\n"); - goto no_enable; + "pcim_enable_device() failed. Aborting.\n"); + return rc; } + /* L0s has caused packet drops. No power saving, thank you. */ + + pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S); + if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { dev_err(endpoint->dev, "Incorrect BAR configuration. Aborting.\n"); - rc = -ENODEV; - goto bad_bar; + return -ENODEV; } - rc = pci_request_regions(pdev, xillyname); + rc = pcim_iomap_regions(pdev, 0x01, xillyname); if (rc) { dev_err(endpoint->dev, - "pci_request_regions() failed. Aborting.\n"); - goto failed_request_regions; + "pcim_iomap_regions() failed. Aborting.\n"); + return rc; } - endpoint->registers = pci_iomap(pdev, 0, 128); - if (!endpoint->registers) { - dev_err(endpoint->dev, "Failed to map BAR 0. Aborting.\n"); - rc = -EIO; - goto failed_iomap0; - } + endpoint->registers = pcim_iomap_table(pdev)[0]; pci_set_master(pdev); @@ -180,16 +174,15 @@ static int xilly_probe(struct pci_dev *pdev, if (pci_enable_msi(pdev)) { dev_err(endpoint->dev, "Failed to enable MSI interrupts. Aborting.\n"); - rc = -ENODEV; - goto failed_enable_msi; + return -ENODEV; } - rc = request_irq(pdev->irq, xillybus_isr, 0, xillyname, endpoint); + rc = devm_request_irq(&pdev->dev, pdev->irq, xillybus_isr, 0, + xillyname, endpoint); if (rc) { dev_err(endpoint->dev, "Failed to register MSI handler. Aborting.\n"); - rc = -ENODEV; - goto failed_register_msi; + return -ENODEV; } /* @@ -203,8 +196,7 @@ static int xilly_probe(struct pci_dev *pdev, endpoint->dma_using_dac = 0; else { dev_err(endpoint->dev, "Failed to set DMA mask. Aborting.\n"); - rc = -ENODEV; - goto failed_dmamask; + return -ENODEV; } rc = xillybus_endpoint_discovery(endpoint); @@ -212,22 +204,8 @@ static int xilly_probe(struct pci_dev *pdev, if (!rc) return 0; -failed_dmamask: - free_irq(pdev->irq, endpoint); -failed_register_msi: - pci_disable_msi(pdev); -failed_enable_msi: - /* pci_clear_master(pdev); Nobody else seems to do this */ - pci_iounmap(pdev, endpoint->registers); -failed_iomap0: - pci_release_regions(pdev); -failed_request_regions: -bad_bar: - pci_disable_device(pdev); -no_enable: xillybus_do_cleanup(&endpoint->cleanup, endpoint); - kfree(endpoint); return rc; } @@ -237,16 +215,7 @@ static void xilly_remove(struct pci_dev *pdev) xillybus_endpoint_remove(endpoint); - free_irq(pdev->irq, endpoint); - - pci_disable_msi(pdev); - pci_iounmap(pdev, endpoint->registers); - pci_release_regions(pdev); - pci_disable_device(pdev); - xillybus_do_cleanup(&endpoint->cleanup, endpoint); - - kfree(endpoint); } MODULE_DEVICE_TABLE(pci, xillyids); -- cgit v1.2.3 From a82477c3dcacb20c00481fa59cf850e0012d6533 Mon Sep 17 00:00:00 2001 From: Masaru Nomura Date: Sat, 17 May 2014 01:17:07 +0100 Subject: staging: dgnc: dgnc_tty: Add a required space Add a required space before an open parenthesis of if statement to meet kernel coding style. Signed-off-by: Masaru Nomura Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_tty.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index e3001b52146c..516405866d1f 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -660,7 +660,7 @@ void dgnc_input(struct channel_t *ch) tp = ch->ch_tun.un_tty; bd = ch->ch_bd; - if(!bd || bd->magic != DGNC_BOARD_MAGIC) + if (!bd || bd->magic != DGNC_BOARD_MAGIC) return; DGNC_LOCK(ch->ch_lock, lock_flags); @@ -1038,7 +1038,7 @@ void dgnc_check_queue_flow_control(struct channel_t *ch) if (qleft < 256) { /* HWFLOW */ if (ch->ch_digi.digi_flags & CTSPACE || ch->ch_c_cflag & CRTSCTS) { - if(!(ch->ch_flags & CH_RECEIVER_OFF)) { + if (!(ch->ch_flags & CH_RECEIVER_OFF)) { ch->ch_bd->bd_ops->disable_receiver(ch); ch->ch_flags |= (CH_RECEIVER_OFF); DPR_READ(("Internal queue hit hilevel mark (%d)! Turning off interrupts.\n", @@ -3025,7 +3025,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, DGNC_LOCK(ch->ch_lock, lock_flags); - if(((cmd == TCSBRK) && (!arg)) || (cmd == TCSBRKP)) { + if (((cmd == TCSBRK) && (!arg)) || (cmd == TCSBRKP)) { ch->ch_bd->bd_ops->send_break(ch, 250); } -- cgit v1.2.3 From 9cdf838b3a25b3cf939c7d71c3d10823d7bbab6c Mon Sep 17 00:00:00 2001 From: Masaru Nomura Date: Sat, 17 May 2014 02:04:10 +0100 Subject: staging: dgnc: dgnc_tty: Remove a prohibited space Remove a prohibited space before a closed parenthesis of if statement to meet kernel coding style. Signed-off-by: Masaru Nomura Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_tty.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index 516405866d1f..4135cb0ed9f5 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -1676,7 +1676,7 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) /* * turn off print device when closing print device. */ - if ((un->un_type == DGNC_PRINT) && (ch->ch_flags & CH_PRON) ) { + if ((un->un_type == DGNC_PRINT) && (ch->ch_flags & CH_PRON)) { dgnc_wmove(ch, ch->ch_digi.digi_offstr, (int) ch->ch_digi.digi_offlen); ch->ch_flags &= ~CH_PRON; @@ -1734,7 +1734,7 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) /* * turn off print device when closing print device. */ - if ((un->un_type == DGNC_PRINT) && (ch->ch_flags & CH_PRON) ) { + if ((un->un_type == DGNC_PRINT) && (ch->ch_flags & CH_PRON)) { dgnc_wmove(ch, ch->ch_digi.digi_offstr, (int) ch->ch_digi.digi_offlen); ch->ch_flags &= ~CH_PRON; @@ -1838,7 +1838,7 @@ static int dgnc_maxcps_room(struct tty_struct *tty, int bytes_available) if (un->un_type != DGNC_PRINT) return bytes_available; - if (ch->ch_digi.digi_maxcps > 0 && ch->ch_digi.digi_bufsize > 0 ) { + if (ch->ch_digi.digi_maxcps > 0 && ch->ch_digi.digi_bufsize > 0) { int cps_limit = 0; unsigned long current_time = jiffies; unsigned long buffer_time = current_time + -- cgit v1.2.3 From 26e2fa765cd7325906ef8bbee366c74e24b3d768 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Mon, 19 May 2014 06:31:12 +0200 Subject: staging: rtl8192e: make return of 0 explicit Delete unnecessary use of a local variable to immediately return 0. A simplified version of the semantic patch that fixes this problem is as follows: (http://coccinelle.lip6.fr/) // @r exists@ local idexpression ret; expression e; position p; @@ -ret = 0; ... when != ret = e return - ret + 0 ; // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 356d5217e9d4..2920e406030a 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -1915,8 +1915,7 @@ int rtl8192_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); if (queue_index == TXCMD_QUEUE) { rtl8192_tx_cmd(dev, skb); - ret = 0; - return ret; + return 0; } else { tcb_desc->RATRIndex = 7; tcb_desc->bTxDisableRateFallBack = 1; -- cgit v1.2.3 From bf5269574013772050a91ace0a137d33f1f4e4d5 Mon Sep 17 00:00:00 2001 From: Benoit Taine Date: Mon, 19 May 2014 18:24:26 +0200 Subject: staging: rts5208: Use pci_device_id rather than DEFINE_PCI_DEVICE_TABLE This patch enhances kernel style usage for the rts5208 driver. We should prefer `struct pci_device_id` over `DEFINE_PCI_DEVICE_TABLE` to meet kernel coding style guidelines. This issue was reported by checkpatch. Signed-off-by: Benoit Taine Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rts5208/rtsx.c b/drivers/staging/rts5208/rtsx.c index d2d1345fb06c..c0a0e6010372 100644 --- a/drivers/staging/rts5208/rtsx.c +++ b/drivers/staging/rts5208/rtsx.c @@ -1030,7 +1030,7 @@ static void rtsx_remove(struct pci_dev *pci) } /* PCI IDs */ -static DEFINE_PCI_DEVICE_TABLE(rtsx_ids) = { +static const struct pci_device_id rtsx_ids[] = { { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x5208), PCI_CLASS_OTHERS << 16, 0xFF0000 }, { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x5288), -- cgit v1.2.3 From add645261560545c947c8778ad51b1eb1f68d51c Mon Sep 17 00:00:00 2001 From: Peter Senna Tschudin Date: Tue, 20 May 2014 12:33:44 +0200 Subject: staging: ft1000: Remove useless return variables This patch remove variables that are initialized with a constant, are never updated, and are only used as parameter of return. Return the constant instead of using a variable. Verified by compilation only. The coccinelle script that find and fixes this issue is: // @@ type T; constant C; identifier ret; @@ - T ret = C; ... when != ret - return ret; + return C; // Signed-off-by: Peter Senna Tschudin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_download.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index cab9cdf6273e..65f980167130 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -522,7 +522,6 @@ static void usb_dnld_complete(struct urb *urb) static int write_blk_fifo(struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile, long word_length) { - int Status = 0; int byte_length; byte_length = word_length * 4; @@ -547,7 +546,7 @@ static int write_blk_fifo(struct ft1000_usb *ft1000dev, u16 **pUsFile, *pUsFile = *pUsFile + (word_length << 1); *pUcFile = *pUcFile + (word_length << 2); - return Status; + return 0; } static int scram_start_dwnld(struct ft1000_usb *ft1000dev, u16 *hshake, -- cgit v1.2.3 From 8a5e7b012d761e85ed8703412e53d1ef997b43ff Mon Sep 17 00:00:00 2001 From: Gengis Dave Date: Fri, 23 May 2014 01:07:13 +0200 Subject: staging: gdm72xx: return values cleanup Return values cleanup Signed-off-by: Davide Gianforte Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm72xx/gdm_wimax.c | 3 +-- drivers/staging/gdm72xx/usb_boot.c | 5 +---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/staging/gdm72xx/gdm_wimax.c b/drivers/staging/gdm72xx/gdm_wimax.c index 492bc78c250d..2c917c12db2b 100644 --- a/drivers/staging/gdm72xx/gdm_wimax.c +++ b/drivers/staging/gdm72xx/gdm_wimax.c @@ -167,7 +167,6 @@ static inline int gdm_wimax_header(struct sk_buff **pskb) { u16 buf[HCI_HEADER_SIZE / sizeof(u16)]; struct sk_buff *skb = *pskb; - int ret = 0; if (unlikely(skb_headroom(skb) < HCI_HEADER_SIZE)) { struct sk_buff *skb2; @@ -187,7 +186,7 @@ static inline int gdm_wimax_header(struct sk_buff **pskb) memcpy(skb->data, buf, HCI_HEADER_SIZE); *pskb = skb; - return ret; + return 0; } static void gdm_wimax_event_rcv(struct net_device *dev, u16 type, void *msg, diff --git a/drivers/staging/gdm72xx/usb_boot.c b/drivers/staging/gdm72xx/usb_boot.c index 75149d7027db..7d235b161ae6 100644 --- a/drivers/staging/gdm72xx/usb_boot.c +++ b/drivers/staging/gdm72xx/usb_boot.c @@ -332,11 +332,8 @@ out: static int em_fw_reset(struct usb_device *usbdev) { - int ret; - /*Send ZLP*/ - ret = gdm_wibro_send(usbdev, NULL, 0); - return ret; + return gdm_wibro_send(usbdev, NULL, 0); } int usb_emergency(struct usb_device *usbdev) -- cgit v1.2.3 From 8ffca9eae662004016a6d60a2a79ce93f81f150e Mon Sep 17 00:00:00 2001 From: Peter Senna Tschudin Date: Tue, 20 May 2014 12:33:41 +0200 Subject: staging: r8712u: Remove useless return variables This patch remove variables that are initialized with a constant, are never updated, and are only used as parameter of return. Return the constant instead of using a variable. Verified by compilation only. The coccinelle script that find and fixes this issue is: // @@ type T; constant C; identifier ret; @@ - T ret = C; ... when != ret - return ret; + return C; // Signed-off-by: Peter Senna Tschudin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/ieee80211.c | 8 ++--- drivers/staging/rtl8712/rtl8712_cmd.c | 3 +- drivers/staging/rtl8712/rtl8712_recv.c | 7 ++--- drivers/staging/rtl8712/rtl871x_mlme.c | 3 +- drivers/staging/rtl8712/rtl871x_mp.c | 3 +- drivers/staging/rtl8712/rtl871x_mp_ioctl.c | 49 ++++++++++-------------------- drivers/staging/rtl8712/rtl871x_recv.c | 4 +-- 7 files changed, 26 insertions(+), 51 deletions(-) diff --git a/drivers/staging/rtl8712/ieee80211.c b/drivers/staging/rtl8712/ieee80211.c index 57fef70ad984..fe9459e483c5 100644 --- a/drivers/staging/rtl8712/ieee80211.c +++ b/drivers/staging/rtl8712/ieee80211.c @@ -289,7 +289,7 @@ static int r8712_get_wpa2_cipher_suite(u8 *s) int r8712_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher) { - int i, ret = _SUCCESS; + int i; int left, count; u8 *pos; @@ -324,13 +324,13 @@ int r8712_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, } } else if (left == 1) return _FAIL; - return ret; + return _SUCCESS; } int r8712_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwise_cipher) { - int i, ret = _SUCCESS; + int i; int left, count; u8 *pos; @@ -364,7 +364,7 @@ int r8712_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, } } else if (left == 1) return _FAIL; - return ret; + return _SUCCESS; } int r8712_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, diff --git a/drivers/staging/rtl8712/rtl8712_cmd.c b/drivers/staging/rtl8712/rtl8712_cmd.c index 1a4b7a651f92..8ca7d7e68dca 100644 --- a/drivers/staging/rtl8712/rtl8712_cmd.c +++ b/drivers/staging/rtl8712/rtl8712_cmd.c @@ -290,8 +290,7 @@ static struct cmd_obj *cmd_hdl_filter(struct _adapter *padapter, static u8 check_cmd_fifo(struct _adapter *padapter, uint sz) { - u8 res = _SUCCESS; - return res; + return _SUCCESS; } u8 r8712_fw_cmd(struct _adapter *pAdapter, u32 cmd) diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c index 0723b2f73aad..667398a67370 100644 --- a/drivers/staging/rtl8712/rtl8712_recv.c +++ b/drivers/staging/rtl8712/rtl8712_recv.c @@ -123,8 +123,6 @@ void r8712_free_recv_priv(struct recv_priv *precvpriv) int r8712_init_recvbuf(struct _adapter *padapter, struct recv_buf *precvbuf) { - int res = _SUCCESS; - precvbuf->transfer_len = 0; precvbuf->len = 0; precvbuf->ref_cnt = 0; @@ -134,7 +132,7 @@ int r8712_init_recvbuf(struct _adapter *padapter, struct recv_buf *precvbuf) precvbuf->ptail = precvbuf->pbuf; precvbuf->pend = precvbuf->pdata + MAX_RECVBUF_SZ; } - return res; + return _SUCCESS; } int r8712_free_recvframe(union recv_frame *precvframe, @@ -347,7 +345,6 @@ static int amsdu_to_msdu(struct _adapter *padapter, union recv_frame *prframe) _pkt *sub_skb, *subframes[MAX_SUBFRAME_COUNT]; struct recv_priv *precvpriv = &padapter->recvpriv; struct __queue *pfree_recv_queue = &(precvpriv->free_recv_queue); - int ret = _SUCCESS; nr_subframes = 0; pattrib = &prframe->u.hdr.attrib; @@ -435,7 +432,7 @@ static int amsdu_to_msdu(struct _adapter *padapter, union recv_frame *prframe) exit: prframe->u.hdr.len = 0; r8712_free_recvframe(prframe, pfree_recv_queue); - return ret; + return _SUCCESS; } void r8712_rxcmd_event_hdl(struct _adapter *padapter, void *prxcmdbuf) diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c index 23fd8c1fda3c..f8f651a9d7b0 100644 --- a/drivers/staging/rtl8712/rtl871x_mlme.c +++ b/drivers/staging/rtl8712/rtl871x_mlme.c @@ -1211,7 +1211,6 @@ sint r8712_set_auth(struct _adapter *adapter, struct cmd_priv *pcmdpriv = &adapter->cmdpriv; struct cmd_obj *pcmd; struct setauth_parm *psetauthparm; - sint ret = _SUCCESS; pcmd = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); if (pcmd == NULL) @@ -1232,7 +1231,7 @@ sint r8712_set_auth(struct _adapter *adapter, pcmd->rspsz = 0; _init_listhead(&pcmd->list); r8712_enqueue_cmd(pcmdpriv, pcmd); - return ret; + return _SUCCESS; } sint r8712_set_key(struct _adapter *adapter, diff --git a/drivers/staging/rtl8712/rtl871x_mp.c b/drivers/staging/rtl8712/rtl871x_mp.c index 0563318a19ff..5fd60cd322bf 100644 --- a/drivers/staging/rtl8712/rtl871x_mp.c +++ b/drivers/staging/rtl8712/rtl871x_mp.c @@ -80,9 +80,8 @@ _exit_init_mp_priv: static int free_mp_priv(struct mp_priv *pmp_priv) { - int res = 0; kfree(pmp_priv->pallocated_mp_xmitframe_buf); - return res; + return 0; } void mp871xinit(struct _adapter *padapter) diff --git a/drivers/staging/rtl8712/rtl871x_mp_ioctl.c b/drivers/staging/rtl8712/rtl871x_mp_ioctl.c index 5bd42966fd5c..9827ff8143b2 100644 --- a/drivers/staging/rtl8712/rtl871x_mp_ioctl.c +++ b/drivers/staging/rtl8712/rtl871x_mp_ioctl.c @@ -66,7 +66,6 @@ uint oid_rt_wireless_mode_hdl(struct oid_par_priv *poid_par_priv) uint oid_rt_pro_write_bb_reg_hdl(struct oid_par_priv *poid_par_priv) { - uint status = RNDIS_STATUS_SUCCESS; struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); struct bb_reg_param *pbbreg; @@ -83,12 +82,11 @@ uint oid_rt_pro_write_bb_reg_hdl(struct oid_par_priv *poid_par_priv) offset |= BB_REG_BASE_ADDR; value = pbbreg->value; r8712_bb_reg_write(Adapter, offset, value); - return status; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_read_bb_reg_hdl(struct oid_par_priv *poid_par_priv) { - uint status = RNDIS_STATUS_SUCCESS; struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); struct bb_reg_param *pbbreg; @@ -106,12 +104,11 @@ uint oid_rt_pro_read_bb_reg_hdl(struct oid_par_priv *poid_par_priv) value = r8712_bb_reg_read(Adapter, offset); pbbreg->value = value; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - return status; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_write_rf_reg_hdl(struct oid_par_priv *poid_par_priv) { - uint status = RNDIS_STATUS_SUCCESS; struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); struct rf_reg_param *pbbreg; @@ -130,14 +127,13 @@ uint oid_rt_pro_write_rf_reg_hdl(struct oid_par_priv *poid_par_priv) offset = (u8)pbbreg->offset; value = pbbreg->value; r8712_rf_reg_write(Adapter, path, offset, value); - return status; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_read_rf_reg_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = RNDIS_STATUS_SUCCESS; struct rf_reg_param *pbbreg; u8 path; u8 offset; @@ -155,7 +151,7 @@ uint oid_rt_pro_read_rf_reg_hdl(struct oid_par_priv *poid_par_priv) value = r8712_rf_reg_read(Adapter, path, offset); pbbreg->value = value; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - return status; + return RNDIS_STATUS_SUCCESS; } /*This function initializes the DUT to the MP test mode*/ @@ -266,7 +262,6 @@ uint oid_rt_pro_set_data_rate_hdl(struct oid_par_priv { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = RNDIS_STATUS_SUCCESS; u32 ratevalue; if (poid_par_priv->type_of_oid != SET_OID) @@ -278,7 +273,7 @@ uint oid_rt_pro_set_data_rate_hdl(struct oid_par_priv return RNDIS_STATUS_INVALID_DATA; Adapter->mppriv.curr_rateidx = ratevalue; r8712_SetDataRate(Adapter); - return status; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_start_test_hdl(struct oid_par_priv *poid_par_priv) @@ -328,7 +323,6 @@ uint oid_rt_pro_set_channel_direct_call_hdl(struct oid_par_priv { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = RNDIS_STATUS_SUCCESS; u32 Channel; if (poid_par_priv->type_of_oid != SET_OID) @@ -340,14 +334,13 @@ uint oid_rt_pro_set_channel_direct_call_hdl(struct oid_par_priv return RNDIS_STATUS_NOT_ACCEPTED; Adapter->mppriv.curr_ch = Channel; r8712_SetChannel(Adapter); - return status; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_set_antenna_bb_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = RNDIS_STATUS_SUCCESS; u32 antenna; if (poid_par_priv->type_of_oid != SET_OID) @@ -358,7 +351,7 @@ uint oid_rt_pro_set_antenna_bb_hdl(struct oid_par_priv *poid_par_priv) Adapter->mppriv.antenna_tx = (u16)((antenna & 0xFFFF0000) >> 16); Adapter->mppriv.antenna_rx = (u16)(antenna & 0x0000FFFF); r8712_SwitchAntenna(Adapter); - return status; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_set_tx_power_control_hdl( @@ -366,7 +359,6 @@ uint oid_rt_pro_set_tx_power_control_hdl( { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = RNDIS_STATUS_SUCCESS; u32 tx_pwr_idx; if (poid_par_priv->type_of_oid != SET_OID) @@ -378,7 +370,7 @@ uint oid_rt_pro_set_tx_power_control_hdl( return RNDIS_STATUS_NOT_ACCEPTED; Adapter->mppriv.curr_txpoweridx = (u8)tx_pwr_idx; r8712_SetTxPower(Adapter); - return status; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_query_tx_packet_sent_hdl( @@ -839,7 +831,6 @@ uint oid_rt_poll_rx_status_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = RNDIS_STATUS_SUCCESS; if (poid_par_priv->type_of_oid != QUERY_OID) return RNDIS_STATUS_NOT_ACCEPTED; @@ -847,7 +838,7 @@ uint oid_rt_poll_rx_status_hdl(struct oid_par_priv *poid_par_priv) (unsigned char *)&Adapter->mppriv.rxstat, sizeof(struct recv_stat)); *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - return status; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_cfg_debug_message_hdl(struct oid_par_priv @@ -875,7 +866,6 @@ uint oid_rt_get_thermal_meter_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = RNDIS_STATUS_SUCCESS; if (poid_par_priv->type_of_oid != QUERY_OID) return RNDIS_STATUS_NOT_ACCEPTED; @@ -897,7 +887,7 @@ uint oid_rt_get_thermal_meter_hdl(struct oid_par_priv *poid_par_priv) *(u32 *)poid_par_priv->information_buf = Adapter->mppriv.workparam.io_value; *poid_par_priv->bytes_rw = sizeof(u32); - return status; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_set_power_tracking_hdl(struct oid_par_priv @@ -1091,7 +1081,6 @@ uint oid_rt_pro_dele_sta_info_hdl(struct oid_par_priv *poid_par_priv) (poid_par_priv->adapter_context); unsigned long irqL; - uint status = RNDIS_STATUS_SUCCESS; struct sta_info *psta = NULL; u8 *macaddr; @@ -1113,7 +1102,7 @@ uint oid_rt_pro_dele_sta_info_hdl(struct oid_par_priv *poid_par_priv) spin_unlock_irqrestore(&(Adapter->stapriv.sta_hash_lock), irqL); } - return status; + return RNDIS_STATUS_SUCCESS; } /*--------------------------------------------------------------------------*/ static u32 mp_query_drv_var(struct _adapter *padapter, u8 offset, u32 var) @@ -1126,8 +1115,6 @@ uint oid_rt_pro_query_dr_variable_hdl(struct oid_par_priv *poid_par_priv) struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = RNDIS_STATUS_SUCCESS; - struct DR_VARIABLE_STRUCT *pdrv_var; if (poid_par_priv->type_of_oid != QUERY_OID) @@ -1139,7 +1126,7 @@ uint oid_rt_pro_query_dr_variable_hdl(struct oid_par_priv *poid_par_priv) pdrv_var->variable = mp_query_drv_var(Adapter, pdrv_var->offset, pdrv_var->variable); *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - return status; + return RNDIS_STATUS_SUCCESS; } /*--------------------------------------------------------------------------*/ @@ -1243,7 +1230,6 @@ uint oid_rt_get_efuse_current_size_hdl(struct oid_par_priv { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = RNDIS_STATUS_SUCCESS; if (poid_par_priv->type_of_oid != QUERY_OID) return RNDIS_STATUS_NOT_ACCEPTED; @@ -1254,14 +1240,13 @@ uint oid_rt_get_efuse_current_size_hdl(struct oid_par_priv r8712_efuse_get_current_size(Adapter); r8712_efuse_reg_uninit(Adapter); *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - return status; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_get_efuse_max_size_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = RNDIS_STATUS_SUCCESS; if (poid_par_priv->type_of_oid != QUERY_OID) return RNDIS_STATUS_NOT_ACCEPTED; @@ -1270,7 +1255,7 @@ uint oid_rt_get_efuse_max_size_hdl(struct oid_par_priv *poid_par_priv) *(int *)poid_par_priv->information_buf = r8712_efuse_get_max_size(Adapter); *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - return status; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_efuse_hdl(struct oid_par_priv *poid_par_priv) @@ -1320,7 +1305,6 @@ uint oid_rt_set_bandwidth_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = RNDIS_STATUS_SUCCESS; u32 bandwidth; if (poid_par_priv->type_of_oid != SET_OID) @@ -1332,14 +1316,13 @@ uint oid_rt_set_bandwidth_hdl(struct oid_par_priv *poid_par_priv) bandwidth = HT_CHANNEL_WIDTH_40; Adapter->mppriv.curr_bandwidth = (u8)bandwidth; r8712_SwitchBandwidth(Adapter); - return status; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_set_crystal_cap_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = RNDIS_STATUS_SUCCESS; u32 crystal_cap = 0; if (poid_par_priv->type_of_oid != SET_OID) @@ -1351,7 +1334,7 @@ uint oid_rt_set_crystal_cap_hdl(struct oid_par_priv *poid_par_priv) return RNDIS_STATUS_NOT_ACCEPTED; Adapter->mppriv.curr_crystalcap = crystal_cap; r8712_SetCrystalCap(Adapter); - return status; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_set_rx_packet_type_hdl(struct oid_par_priv diff --git a/drivers/staging/rtl8712/rtl871x_recv.c b/drivers/staging/rtl8712/rtl871x_recv.c index 274c359279ef..4ac4a1b44d2a 100644 --- a/drivers/staging/rtl8712/rtl871x_recv.c +++ b/drivers/staging/rtl8712/rtl871x_recv.c @@ -605,8 +605,6 @@ sint r8712_wlanhdr_to_ethhdr(union recv_frame *precvframe) u8 bsnaphdr; u8 *psnap_type; struct ieee80211_snap_hdr *psnap; - - sint ret = _SUCCESS; struct _adapter *adapter = precvframe->u.hdr.adapter; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; @@ -653,7 +651,7 @@ sint r8712_wlanhdr_to_ethhdr(union recv_frame *precvframe) len = htons(len); memcpy(ptr + 12, &len, 2); } - return ret; + return _SUCCESS; } s32 r8712_recv_entry(union recv_frame *precvframe) -- cgit v1.2.3 From 43339bed7010da6e7cf797db3216a136a974a0cd Mon Sep 17 00:00:00 2001 From: Eli Billauer Date: Fri, 16 May 2014 11:26:35 +0300 Subject: devres: Add devm_get_free_pages API devm_get_free_pages() and devm_free_pages() are the managed counterparts for __get_free_pages() and free_pages(). Signed-off-by: Eli Billauer Acked-by: Tejun Heo Signed-off-by: Greg Kroah-Hartman --- Documentation/driver-model/devres.txt | 2 + drivers/base/devres.c | 76 +++++++++++++++++++++++++++++++++++ include/linux/device.h | 4 ++ 3 files changed, 82 insertions(+) diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt index 499951873997..e1a27074caae 100644 --- a/Documentation/driver-model/devres.txt +++ b/Documentation/driver-model/devres.txt @@ -237,6 +237,8 @@ MEM devm_kzalloc() devm_kfree() devm_kmemdup() + devm_get_free_pages() + devm_free_pages() IIO devm_iio_device_alloc() diff --git a/drivers/base/devres.c b/drivers/base/devres.c index d0914cba2413..52302946770f 100644 --- a/drivers/base/devres.c +++ b/drivers/base/devres.c @@ -852,3 +852,79 @@ void *devm_kmemdup(struct device *dev, const void *src, size_t len, gfp_t gfp) return p; } EXPORT_SYMBOL_GPL(devm_kmemdup); + +struct pages_devres { + unsigned long addr; + unsigned int order; +}; + +static int devm_pages_match(struct device *dev, void *res, void *p) +{ + struct pages_devres *devres = res; + struct pages_devres *target = p; + + return devres->addr == target->addr; +} + +static void devm_pages_release(struct device *dev, void *res) +{ + struct pages_devres *devres = res; + + free_pages(devres->addr, devres->order); +} + +/** + * devm_get_free_pages - Resource-managed __get_free_pages + * @dev: Device to allocate memory for + * @gfp_mask: Allocation gfp flags + * @order: Allocation size is (1 << order) pages + * + * Managed get_free_pages. Memory allocated with this function is + * automatically freed on driver detach. + * + * RETURNS: + * Address of allocated memory on success, 0 on failure. + */ + +unsigned long devm_get_free_pages(struct device *dev, + gfp_t gfp_mask, unsigned int order) +{ + struct pages_devres *devres; + unsigned long addr; + + addr = __get_free_pages(gfp_mask, order); + + if (unlikely(!addr)) + return 0; + + devres = devres_alloc(devm_pages_release, + sizeof(struct pages_devres), GFP_KERNEL); + if (unlikely(!devres)) { + free_pages(addr, order); + return 0; + } + + devres->addr = addr; + devres->order = order; + + devres_add(dev, devres); + return addr; +} +EXPORT_SYMBOL_GPL(devm_get_free_pages); + +/** + * devm_free_pages - Resource-managed free_pages + * @dev: Device this memory belongs to + * @addr: Memory to free + * + * Free memory allocated with devm_get_free_pages(). Unlike free_pages, + * there is no need to supply the @order. + */ +void devm_free_pages(struct device *dev, unsigned long addr) +{ + struct pages_devres devres = { .addr = addr }; + + WARN_ON(devres_release(dev, devm_pages_release, devm_pages_match, + &devres)); +} +EXPORT_SYMBOL_GPL(devm_free_pages); diff --git a/include/linux/device.h b/include/linux/device.h index ab871588da89..3dc69a2faa51 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -626,6 +626,10 @@ extern char *devm_kstrdup(struct device *dev, const char *s, gfp_t gfp); extern void *devm_kmemdup(struct device *dev, const void *src, size_t len, gfp_t gfp); +extern unsigned long devm_get_free_pages(struct device *dev, + gfp_t gfp_mask, unsigned int order); +extern void devm_free_pages(struct device *dev, unsigned long addr); + void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res); void __iomem *devm_request_and_ioremap(struct device *dev, struct resource *res); -- cgit v1.2.3 From 6baf139e8b0efd7450cca792db5a37b0bccb8761 Mon Sep 17 00:00:00 2001 From: Djordje Zekovic Date: Fri, 23 May 2014 14:18:03 +0000 Subject: staging: usbip: use kcalloc instead of kzalloc for array allocations The advantage of kcalloc is, that will prevent integer overflows which could result from the multiplication of number of elements and size and it is also a bit nicer to read. Signed-off-by: Djordje Zekovic Signed-off-by: Greg Kroah-Hartman --- drivers/staging/usbip/stub_tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/usbip/stub_tx.c b/drivers/staging/usbip/stub_tx.c index 38fe551650c2..dbcabc9dbe0d 100644 --- a/drivers/staging/usbip/stub_tx.c +++ b/drivers/staging/usbip/stub_tx.c @@ -179,7 +179,7 @@ static int stub_send_ret_submit(struct stub_device *sdev) else iovnum = 2; - iov = kzalloc(iovnum * sizeof(struct kvec), GFP_KERNEL); + iov = kcalloc(iovnum, sizeof(struct kvec), GFP_KERNEL); if (!iov) { usbip_event_add(&sdev->ud, SDEV_EVENT_ERROR_MALLOC); -- cgit v1.2.3 From 7dfa383108eb0f7a658b265dad31dae58025bf0f Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Fri, 23 May 2014 10:14:02 -0400 Subject: staging: dgap: Remove unnecessary initialization of variables in declarations Removes unnecessary initialization of variables in declarations Signed-off-by: Mark Hounschell Tested-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 175 +++++++++++++++++++++----------------------- 1 file changed, 84 insertions(+), 91 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 2ab7b7c2fc38..02aa1d6eebb3 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -466,7 +466,7 @@ static struct toklist dgap_tlist[] = { */ static int dgap_init_module(void) { - int rc = 0; + int rc; pr_info("%s, Digi International Part Number %s\n", DG_NAME, DG_PART); @@ -499,7 +499,7 @@ module_init(dgap_init_module); */ static int dgap_start(void) { - int rc = 0; + int rc; unsigned long flags; struct device *device; @@ -635,7 +635,7 @@ static void dgap_cleanup_module(void) */ static void dgap_cleanup_board(struct board_t *brd) { - int i = 0; + int i; if (!brd || brd->magic != DGAP_BOARD_MAGIC) return; @@ -678,7 +678,7 @@ static int dgap_found_board(struct pci_dev *pdev, int id) { struct board_t *brd; unsigned int pci_irq; - int i = 0; + int i; /* get the board structure and prep it */ brd = kzalloc(sizeof(struct board_t), GFP_KERNEL); @@ -1165,7 +1165,7 @@ static irqreturn_t dgap_intr(int irq, void *voidbrd) */ static void dgap_init_globals(void) { - int i = 0; + int i; for (i = 0; i < MAXBOARDS; i++) dgap_board[i] = NULL; @@ -1321,9 +1321,9 @@ static int dgap_tty_init(struct board_t *brd) { int i; int tlw; - uint true_count = 0; + uint true_count; u8 __iomem *vaddr; - u8 modem = 0; + u8 modem; struct channel_t *ch; struct bs_t __iomem *bs; struct cm_t __iomem *cm; @@ -1491,7 +1491,7 @@ static int dgap_tty_init(struct board_t *brd) static void dgap_tty_uninit(struct board_t *brd) { struct device *dev; - int i = 0; + int i; if (brd->dgap_major_serial_registered) { dgap_boards_by_major[brd->serial_driver->major] = NULL; @@ -1549,11 +1549,11 @@ static void dgap_input(struct channel_t *ch) ulong lock_flags; ulong lock_flags2; int flip_len; - int len = 0; - int n = 0; + int len; + int n; u8 *buf; u8 tmpchar; - int s = 0; + int s; if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) return; @@ -1866,15 +1866,13 @@ static int dgap_tty_open(struct tty_struct *tty, struct file *file) struct channel_t *ch; struct un_t *un; struct bs_t __iomem *bs; - uint major = 0; - uint minor = 0; - int rc = 0; + uint major; + uint minor; + int rc; ulong lock_flags; ulong lock_flags2; u16 head; - rc = 0; - major = MAJOR(tty_devnum(tty)); minor = MINOR(tty_devnum(tty)); @@ -2020,10 +2018,10 @@ static int dgap_block_til_ready(struct tty_struct *tty, struct file *file, struct channel_t *ch) { int retval = 0; - struct un_t *un = NULL; + struct un_t *un; ulong lock_flags; - uint old_flags = 0; - int sleep_on_un_flags = 0; + uint old_flags; + int sleep_on_un_flags; if (!tty || tty->magic != TTY_MAGIC || !file || !ch || ch->magic != DGAP_CHANNEL_MAGIC) @@ -2187,7 +2185,6 @@ static void dgap_tty_close(struct tty_struct *tty, struct file *file) struct channel_t *ch; struct un_t *un; ulong lock_flags; - int rc = 0; if (!tty || tty->magic != TTY_MAGIC) return; @@ -2253,7 +2250,7 @@ static void dgap_tty_close(struct tty_struct *tty, struct file *file) /* wait for output to drain */ /* This will also return if we take an interrupt */ - rc = dgap_wait_for_drain(tty); + dgap_wait_for_drain(tty); dgap_tty_flush_buffer(tty); tty_ldisc_flush(tty); @@ -2316,12 +2313,12 @@ static void dgap_tty_close(struct tty_struct *tty, struct file *file) */ static int dgap_tty_chars_in_buffer(struct tty_struct *tty) { - struct board_t *bd = NULL; - struct channel_t *ch = NULL; - struct un_t *un = NULL; + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; struct bs_t __iomem *bs; u8 tbusy; - uint chars = 0; + uint chars; u16 thead, ttail, tmask, chead, ctail; ulong lock_flags = 0; ulong lock_flags2 = 0; @@ -2411,26 +2408,24 @@ static int dgap_wait_for_drain(struct tty_struct *tty) struct channel_t *ch; struct un_t *un; struct bs_t __iomem *bs; - int ret = -EIO; + int ret = 0; uint count = 1; ulong lock_flags = 0; if (!tty || tty->magic != TTY_MAGIC) - return ret; + return -EIO; un = tty->driver_data; if (!un || un->magic != DGAP_UNIT_MAGIC) - return ret; + return -EIO; ch = un->un_ch; if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return ret; + return -EIO; bs = ch->ch_bs; if (!bs) - return ret; - - ret = 0; + return -EIO; /* Loop until data is drained */ while (count != 0) { @@ -2471,8 +2466,8 @@ static int dgap_wait_for_drain(struct tty_struct *tty) */ static int dgap_maxcps_room(struct tty_struct *tty, int bytes_available) { - struct channel_t *ch = NULL; - struct un_t *un = NULL; + struct channel_t *ch; + struct un_t *un; if (tty == NULL) return bytes_available; @@ -2520,8 +2515,8 @@ static int dgap_maxcps_room(struct tty_struct *tty, int bytes_available) static inline void dgap_set_firmware_event(struct un_t *un, unsigned int event) { - struct channel_t *ch = NULL; - struct bs_t __iomem *bs = NULL; + struct channel_t *ch; + struct bs_t __iomem *bs; if (!un || un->magic != DGAP_UNIT_MAGIC) return; @@ -2553,11 +2548,11 @@ static inline void dgap_set_firmware_event(struct un_t *un, unsigned int event) */ static int dgap_tty_write_room(struct tty_struct *tty) { - struct channel_t *ch = NULL; - struct un_t *un = NULL; + struct channel_t *ch; + struct un_t *un; struct bs_t __iomem *bs; u16 head, tail, tmask; - int ret = 0; + int ret; ulong lock_flags = 0; if (!tty) @@ -2642,13 +2637,13 @@ static int dgap_tty_put_char(struct tty_struct *tty, unsigned char c) static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, int count) { - struct channel_t *ch = NULL; - struct un_t *un = NULL; + struct channel_t *ch; + struct un_t *un; struct bs_t __iomem *bs; char __iomem *vaddr; u16 head, tail, tmask, remain; - int bufcount = 0, n = 0; - int orig_count = 0; + int bufcount, n; + int orig_count; ulong lock_flags; if (!tty) @@ -2809,20 +2804,20 @@ static int dgap_tty_tiocmget(struct tty_struct *tty) { struct channel_t *ch; struct un_t *un; - int result = -EIO; - u8 mstat = 0; + int result; + u8 mstat; ulong lock_flags; if (!tty || tty->magic != TTY_MAGIC) - return result; + return -EIO; un = tty->driver_data; if (!un || un->magic != DGAP_UNIT_MAGIC) - return result; + return -EIO; ch = un->un_ch; if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return result; + return -EIO; spin_lock_irqsave(&ch->ch_lock, lock_flags); @@ -2861,24 +2856,23 @@ static int dgap_tty_tiocmset(struct tty_struct *tty, struct board_t *bd; struct channel_t *ch; struct un_t *un; - int ret = -EIO; ulong lock_flags; ulong lock_flags2; if (!tty || tty->magic != TTY_MAGIC) - return ret; + return -EIO; un = tty->driver_data; if (!un || un->magic != DGAP_UNIT_MAGIC) - return ret; + return -EIO; ch = un->un_ch; if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return ret; + return -EIO; bd = ch->ch_bd; if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return ret; + return -EIO; spin_lock_irqsave(&bd->bd_lock, lock_flags); spin_lock_irqsave(&ch->ch_lock, lock_flags2); @@ -2921,24 +2915,23 @@ static int dgap_tty_send_break(struct tty_struct *tty, int msec) struct board_t *bd; struct channel_t *ch; struct un_t *un; - int ret = -EIO; ulong lock_flags; ulong lock_flags2; if (!tty || tty->magic != TTY_MAGIC) - return ret; + return -EIO; un = tty->driver_data; if (!un || un->magic != DGAP_UNIT_MAGIC) - return ret; + return -EIO; ch = un->un_ch; if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return ret; + return -EIO; bd = ch->ch_bd; if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return ret; + return -EIO; switch (msec) { case -1: @@ -3035,10 +3028,10 @@ static void dgap_tty_send_xchar(struct tty_struct *tty, char c) */ static int dgap_get_modem_info(struct channel_t *ch, unsigned int __user *value) { - int result = 0; - u8 mstat = 0; + int result; + u8 mstat; ulong lock_flags; - int rc = 0; + int rc; if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) return -ENXIO; @@ -3082,25 +3075,25 @@ static int dgap_set_modem_info(struct tty_struct *tty, unsigned int command, struct board_t *bd; struct channel_t *ch; struct un_t *un; - int ret = -ENXIO; - unsigned int arg = 0; + int ret; + unsigned int arg; ulong lock_flags; ulong lock_flags2; if (!tty || tty->magic != TTY_MAGIC) - return ret; + return -EIO; un = tty->driver_data; if (!un || un->magic != DGAP_UNIT_MAGIC) - return ret; + return -EIO; ch = un->un_ch; if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return ret; + return -EIO; bd = ch->ch_bd; if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return ret; + return -EIO; ret = get_user(arg, value); if (ret) @@ -3690,7 +3683,7 @@ static void dgap_tty_flush_buffer(struct tty_struct *tty) struct un_t *un; ulong lock_flags; ulong lock_flags2; - u16 head = 0; + u16 head; if (!tty || tty->magic != TTY_MAGIC) return; @@ -3748,7 +3741,7 @@ static int dgap_tty_ioctl(struct tty_struct *tty, unsigned int cmd, struct channel_t *ch; struct un_t *un; int rc; - u16 head = 0; + u16 head; ulong lock_flags = 0; ulong lock_flags2 = 0; void __user *uarg = (void __user *) arg; @@ -4371,7 +4364,7 @@ static void dgap_do_reset_board(struct board_t *brd) u8 check; u32 check1; u32 check2; - int i = 0; + int i; if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase || !brd->re_map_port) @@ -4419,7 +4412,7 @@ static void dgap_do_reset_board(struct board_t *brd) static void dgap_do_conc_load(struct board_t *brd, u8 *uaddr, int len) { char __iomem *vaddr; - u16 offset = 0; + u16 offset; struct downld_t *to_dp; if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) @@ -4949,7 +4942,7 @@ static uint dgap_get_custom_baud(struct channel_t *ch) { u8 __iomem *vaddr; ulong offset; - uint value = 0; + uint value; if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) return 0; @@ -5732,7 +5725,7 @@ static ssize_t dgap_ports_state_show(struct device *p, { struct board_t *bd; int count = 0; - int i = 0; + int i; bd = dgap_verify_board(p); if (!bd) @@ -5753,7 +5746,7 @@ static ssize_t dgap_ports_baud_show(struct device *p, { struct board_t *bd; int count = 0; - int i = 0; + int i; bd = dgap_verify_board(p); if (!bd) @@ -5774,7 +5767,7 @@ static ssize_t dgap_ports_msignals_show(struct device *p, { struct board_t *bd; int count = 0; - int i = 0; + int i; bd = dgap_verify_board(p); if (!bd) @@ -5811,7 +5804,7 @@ static ssize_t dgap_ports_iflag_show(struct device *p, { struct board_t *bd; int count = 0; - int i = 0; + int i; bd = dgap_verify_board(p); if (!bd) @@ -5831,7 +5824,7 @@ static ssize_t dgap_ports_cflag_show(struct device *p, { struct board_t *bd; int count = 0; - int i = 0; + int i; bd = dgap_verify_board(p); if (!bd) @@ -5851,7 +5844,7 @@ static ssize_t dgap_ports_oflag_show(struct device *p, { struct board_t *bd; int count = 0; - int i = 0; + int i; bd = dgap_verify_board(p); if (!bd) @@ -5871,7 +5864,7 @@ static ssize_t dgap_ports_lflag_show(struct device *p, { struct board_t *bd; int count = 0; - int i = 0; + int i; bd = dgap_verify_board(p); if (!bd) @@ -5891,7 +5884,7 @@ static ssize_t dgap_ports_digi_flag_show(struct device *p, { struct board_t *bd; int count = 0; - int i = 0; + int i; bd = dgap_verify_board(p); if (!bd) @@ -5911,7 +5904,7 @@ static ssize_t dgap_ports_rxcount_show(struct device *p, { struct board_t *bd; int count = 0; - int i = 0; + int i; bd = dgap_verify_board(p); if (!bd) @@ -5931,7 +5924,7 @@ static ssize_t dgap_ports_txcount_show(struct device *p, { struct board_t *bd; int count = 0; - int i = 0; + int i; bd = dgap_verify_board(p); if (!bd) @@ -6257,11 +6250,11 @@ static ssize_t dgap_tty_name_show(struct device *d, struct un_t *un; int cn; int bn; - struct cnode *cptr = NULL; + struct cnode *cptr; int found = FALSE; int ncount = 0; int starto = 0; - int i = 0; + int i; if (!d) return 0; @@ -6401,7 +6394,7 @@ static int dgap_parsefile(char **in, int remove) { struct cnode *p, *brd, *line, *conc; int rc; - char *s = NULL; + char *s; int linecnt = 0; p = &dgap_head; @@ -7317,7 +7310,7 @@ static int dgap_checknode(struct cnode *p) */ static uint dgap_config_get_useintr(struct board_t *bd) { - struct cnode *p = NULL; + struct cnode *p; if (!bd) return 0; @@ -7343,7 +7336,7 @@ static uint dgap_config_get_useintr(struct board_t *bd) */ static uint dgap_config_get_altpin(struct board_t *bd) { - struct cnode *p = NULL; + struct cnode *p; if (!bd) return 0; @@ -7370,7 +7363,7 @@ static uint dgap_config_get_altpin(struct board_t *bd) */ static struct cnode *dgap_find_config(int type, int bus, int slot) { - struct cnode *p, *prev = NULL, *prev2 = NULL, *found = NULL; + struct cnode *p, *prev, *prev2, *found; p = &dgap_head; @@ -7435,7 +7428,7 @@ static struct cnode *dgap_find_config(int type, int bus, int slot) static uint dgap_config_get_num_prts(struct board_t *bd) { int count = 0; - struct cnode *p = NULL; + struct cnode *p; if (!bd) return 0; @@ -7464,8 +7457,8 @@ static uint dgap_config_get_num_prts(struct board_t *bd) static char *dgap_create_config_string(struct board_t *bd, char *string) { char *ptr = string; - struct cnode *p = NULL; - struct cnode *q = NULL; + struct cnode *p; + struct cnode *q; int speed; if (!bd) { -- cgit v1.2.3 From 174efc1fe40a217ded2f4a132a0cecc1ce66dd85 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Fri, 23 May 2014 12:54:04 -0400 Subject: staging: dgap: Remove more extra white space and tabs Removes more extra white space and tabs Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 178 +++++++++++++++++++++----------------------- 1 file changed, 86 insertions(+), 92 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 02aa1d6eebb3..d7b27d6e53ac 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -306,11 +306,11 @@ static struct pci_driver dgap_driver = { }; struct firmware_info { - u8 *conf_name; /* dgap.conf */ + u8 *conf_name; /* dgap.conf */ u8 *bios_name; /* BIOS filename */ u8 *fep_name; /* FEP filename */ u8 *con_name; /* Concentrator filename FIXME*/ - int num; /* sequence number */ + int num; /* sequence number */ }; /* @@ -398,8 +398,8 @@ static struct cnode dgap_head; static char dgap_cword[MAXCWORD]; struct toklist { - int token; - char *string; + int token; + char *string; }; static struct toklist dgap_tlist[] = { @@ -1542,12 +1542,12 @@ static void dgap_input(struct channel_t *ch) struct bs_t __iomem *bs; struct tty_struct *tp; struct tty_ldisc *ld; - uint rmask; - uint head; - uint tail; - int data_len; - ulong lock_flags; - ulong lock_flags2; + uint rmask; + uint head; + uint tail; + int data_len; + ulong lock_flags; + ulong lock_flags2; int flip_len; int len; int n; @@ -1862,16 +1862,16 @@ static void dgap_carrier(struct channel_t *ch) */ static int dgap_tty_open(struct tty_struct *tty, struct file *file) { - struct board_t *brd; + struct board_t *brd; struct channel_t *ch; - struct un_t *un; + struct un_t *un; struct bs_t __iomem *bs; - uint major; - uint minor; - int rc; - ulong lock_flags; - ulong lock_flags2; - u16 head; + uint major; + uint minor; + int rc; + ulong lock_flags; + ulong lock_flags2; + u16 head; major = MAJOR(tty_devnum(tty)); minor = MINOR(tty_devnum(tty)); @@ -2019,8 +2019,8 @@ static int dgap_block_til_ready(struct tty_struct *tty, struct file *file, { int retval = 0; struct un_t *un; - ulong lock_flags; - uint old_flags; + ulong lock_flags; + uint old_flags; int sleep_on_un_flags; if (!tty || tty->magic != TTY_MAGIC || !file || !ch || @@ -2150,9 +2150,9 @@ static int dgap_block_til_ready(struct tty_struct *tty, struct file *file, */ static void dgap_tty_hangup(struct tty_struct *tty) { - struct board_t *bd; + struct board_t *bd; struct channel_t *ch; - struct un_t *un; + struct un_t *un; if (!tty || tty->magic != TTY_MAGIC) return; @@ -2171,7 +2171,6 @@ static void dgap_tty_hangup(struct tty_struct *tty) /* flush the transmit queues */ dgap_tty_flush_buffer(tty); - } /* @@ -2320,8 +2319,8 @@ static int dgap_tty_chars_in_buffer(struct tty_struct *tty) u8 tbusy; uint chars; u16 thead, ttail, tmask, chead, ctail; - ulong lock_flags = 0; - ulong lock_flags2 = 0; + ulong lock_flags = 0; + ulong lock_flags2 = 0; if (tty == NULL) return 0; @@ -2410,7 +2409,7 @@ static int dgap_wait_for_drain(struct tty_struct *tty) struct bs_t __iomem *bs; int ret = 0; uint count = 1; - ulong lock_flags = 0; + ulong lock_flags = 0; if (!tty || tty->magic != TTY_MAGIC) return -EIO; @@ -2553,7 +2552,7 @@ static int dgap_tty_write_room(struct tty_struct *tty) struct bs_t __iomem *bs; u16 head, tail, tmask; int ret; - ulong lock_flags = 0; + ulong lock_flags = 0; if (!tty) return 0; @@ -3213,7 +3212,7 @@ static int dgap_tty_digiseta(struct tty_struct *tty, struct channel_t *ch; struct un_t *un; struct digi_t new_digi; - ulong lock_flags = 0; + ulong lock_flags = 0; unsigned long lock_flags2; if (!tty || tty->magic != TTY_MAGIC) @@ -3493,8 +3492,8 @@ static void dgap_tty_throttle(struct tty_struct *tty) struct board_t *bd; struct channel_t *ch; struct un_t *un; - ulong lock_flags; - ulong lock_flags2; + ulong lock_flags; + ulong lock_flags2; if (!tty || tty->magic != TTY_MAGIC) return; @@ -3529,8 +3528,8 @@ static void dgap_tty_unthrottle(struct tty_struct *tty) struct board_t *bd; struct channel_t *ch; struct un_t *un; - ulong lock_flags; - ulong lock_flags2; + ulong lock_flags; + ulong lock_flags2; if (!tty || tty->magic != TTY_MAGIC) return; @@ -3565,8 +3564,8 @@ static void dgap_tty_start(struct tty_struct *tty) struct board_t *bd; struct channel_t *ch; struct un_t *un; - ulong lock_flags; - ulong lock_flags2; + ulong lock_flags; + ulong lock_flags2; if (!tty || tty->magic != TTY_MAGIC) return; @@ -3590,7 +3589,6 @@ static void dgap_tty_start(struct tty_struct *tty) spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - } static void dgap_tty_stop(struct tty_struct *tty) @@ -3598,8 +3596,8 @@ static void dgap_tty_stop(struct tty_struct *tty) struct board_t *bd; struct channel_t *ch; struct un_t *un; - ulong lock_flags; - ulong lock_flags2; + ulong lock_flags; + ulong lock_flags2; if (!tty || tty->magic != TTY_MAGIC) return; @@ -3623,7 +3621,6 @@ static void dgap_tty_stop(struct tty_struct *tty) spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - } /* @@ -3644,8 +3641,8 @@ static void dgap_tty_flush_chars(struct tty_struct *tty) struct board_t *bd; struct channel_t *ch; struct un_t *un; - ulong lock_flags; - ulong lock_flags2; + ulong lock_flags; + ulong lock_flags2; if (!tty || tty->magic != TTY_MAGIC) return; @@ -3681,9 +3678,9 @@ static void dgap_tty_flush_buffer(struct tty_struct *tty) struct board_t *bd; struct channel_t *ch; struct un_t *un; - ulong lock_flags; - ulong lock_flags2; - u16 head; + ulong lock_flags; + ulong lock_flags2; + u16 head; if (!tty || tty->magic != TTY_MAGIC) return; @@ -3741,9 +3738,9 @@ static int dgap_tty_ioctl(struct tty_struct *tty, unsigned int cmd, struct channel_t *ch; struct un_t *un; int rc; - u16 head; - ulong lock_flags = 0; - ulong lock_flags2 = 0; + u16 head; + ulong lock_flags = 0; + ulong lock_flags2 = 0; void __user *uarg = (void __user *) arg; if (!tty || tty->magic != TTY_MAGIC) @@ -4402,7 +4399,6 @@ static void dgap_do_reset_board(struct board_t *brd) brd->dpastatus = BD_NOFEP; return; } - } #ifdef DIGI_CONCENTRATORS_SUPPORTED @@ -4548,7 +4544,7 @@ static void dgap_get_vpd(struct board_t *brd) static void dgap_poll_tasklet(unsigned long data) { struct board_t *bd = (struct board_t *) data; - ulong lock_flags; + ulong lock_flags; char __iomem *vaddr; u16 head, tail; @@ -4625,12 +4621,12 @@ out: static void dgap_cmdb(struct channel_t *ch, u8 cmd, u8 byte1, u8 byte2, uint ncmds) { - char __iomem *vaddr; + char __iomem *vaddr; struct __iomem cm_t *cm_addr; - uint count; - uint n; - u16 head; - u16 tail; + uint count; + uint n; + u16 head; + u16 tail; if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) return; @@ -4710,12 +4706,12 @@ static void dgap_cmdb(struct channel_t *ch, u8 cmd, u8 byte1, *=======================================================================*/ static void dgap_cmdw(struct channel_t *ch, u8 cmd, u16 word, uint ncmds) { - char __iomem *vaddr; + char __iomem *vaddr; struct __iomem cm_t *cm_addr; - uint count; - uint n; - u16 head; - u16 tail; + uint count; + uint n; + u16 head; + u16 tail; if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) return; @@ -4793,12 +4789,12 @@ static void dgap_cmdw(struct channel_t *ch, u8 cmd, u16 word, uint ncmds) *=======================================================================*/ static void dgap_cmdw_ext(struct channel_t *ch, u16 cmd, u16 word, uint ncmds) { - char __iomem *vaddr; + char __iomem *vaddr; struct __iomem cm_t *cm_addr; - uint count; - uint n; - u16 head; - u16 tail; + uint count; + uint n; + u16 head; + u16 tail; if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) return; @@ -4886,10 +4882,10 @@ static void dgap_cmdw_ext(struct channel_t *ch, u16 cmd, u16 word, uint ncmds) *=======================================================================*/ static void dgap_wmove(struct channel_t *ch, char *buf, uint cnt) { - int n; - char __iomem *taddr; + int n; + char __iomem *taddr; struct bs_t __iomem *bs; - u16 head; + u16 head; if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) return; @@ -5008,12 +5004,12 @@ static int dgap_param(struct tty_struct *tty) struct board_t *bd; struct channel_t *ch; struct bs_t __iomem *bs; - struct un_t *un; - u16 head; - u16 cflag; - u16 iflag; - u8 mval; - u8 hflow; + struct un_t *un; + u16 head; + u16 cflag; + u16 iflag; + u8 mval; + u8 hflow; if (!tty || tty->magic != TTY_MAGIC) return -ENXIO; @@ -5282,7 +5278,6 @@ static int dgap_param(struct tty_struct *tty) dgap_cmdb(ch, SHFLOW, (u8) hflow, 0xff, 0); } - /* * Set RTS and/or DTR Toggle if needed, * but only if product is FEP5+ based. @@ -5458,18 +5453,18 @@ static void dgap_write_wakeup(struct board_t *bd, struct channel_t *ch, static int dgap_event(struct board_t *bd) { struct channel_t *ch; - ulong lock_flags; - ulong lock_flags2; + ulong lock_flags; + ulong lock_flags2; struct bs_t __iomem *bs; - u8 __iomem *event; - u8 __iomem *vaddr; + u8 __iomem *event; + u8 __iomem *vaddr; struct ev_t __iomem *eaddr; - uint head; - uint tail; - int port; - int reason; - int modem; - int b1; + uint head; + uint tail; + int port; + int reason; + int modem; + int b1; if (!bd || bd->magic != DGAP_BOARD_MAGIC) return -ENXIO; @@ -6248,8 +6243,8 @@ static ssize_t dgap_tty_name_show(struct device *d, struct board_t *bd; struct channel_t *ch; struct un_t *un; - int cn; - int bn; + int cn; + int bn; struct cnode *cptr; int found = FALSE; int ncount = 0; @@ -6346,7 +6341,6 @@ static ssize_t dgap_tty_name_show(struct device *d, return snprintf(buf, PAGE_SIZE, "%s_dgap_%d_%d\n", (un->un_type == DGAP_PRINT) ? "pr" : "tty", bn, cn); - } static DEVICE_ATTR(custom_name, S_IRUSR, dgap_tty_name_show, NULL); @@ -6390,12 +6384,12 @@ static void dgap_remove_tty_sysfs(struct device *c) /* * Parse a configuration file read into memory as a string. */ -static int dgap_parsefile(char **in, int remove) +static int dgap_parsefile(char **in, int remove) { struct cnode *p, *brd, *line, *conc; - int rc; - char *s; - int linecnt = 0; + int rc; + char *s; + int linecnt = 0; p = &dgap_head; brd = line = conc = NULL; @@ -7137,7 +7131,7 @@ static int dgap_parsefile(char **in, int remove) */ static char *dgap_sindex(char *string, char *group) { - char *ptr; + char *ptr; if (!string || !group) return (char *) NULL; @@ -7169,7 +7163,7 @@ static char *dgap_sindex(char *string, char *group) */ static int dgap_gettok(char **in, struct cnode *p) { - char *w; + char *w; struct toklist *t; if (strstr(dgap_cword, "boar")) { -- cgit v1.2.3 From ee487100ce307baec964ca3708409fdb65c58f49 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Fri, 23 May 2014 13:13:03 -0400 Subject: staging: dgap: Replace double negative conditionals This patch replaces double negativeconditionals Signed-off-by: Mark Hounschell Tested-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index d7b27d6e53ac..f811cbf5332e 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -6395,7 +6395,7 @@ static int dgap_parsefile(char **in, int remove) brd = line = conc = NULL; /* perhaps we are adding to an existing list? */ - while (p->next != NULL) + while (p->next) p = p->next; /* file must start with a BEGIN */ @@ -7233,7 +7233,7 @@ static struct cnode *dgap_newnode(int t) struct cnode *n; n = kmalloc(sizeof(struct cnode), GFP_ATOMIC); - if (n != NULL) { + if (n) { memset((char *)n, 0, sizeof(struct cnode)); n->type = t; } @@ -7361,7 +7361,7 @@ static struct cnode *dgap_find_config(int type, int bus, int slot) p = &dgap_head; - while (p->next != NULL) { + while (p->next) { prev = p; p = p->next; @@ -7381,7 +7381,7 @@ static struct cnode *dgap_find_config(int type, int bus, int slot) * Keep walking thru the list till we * find the next board. */ - while (p->next != NULL) { + while (p->next) { prev2 = p; p = p->next; if (p->type == BNODE) { @@ -7478,13 +7478,11 @@ static char *dgap_create_config_string(struct board_t *bd, char *string) */ speed = p->u.conc.speed; q = p->next; - if ((q != NULL) && (q->type == MNODE)) { + if (q && (q->type == MNODE)) { *ptr = (p->u.conc.nport + 0x80); ptr++; p = q; - while ((q->next != NULL) && - (q->next->type) == MNODE) { - + while (q->next && (q->next->type) == MNODE) { *ptr = (q->u.module.nport + 0x80); ptr++; p = q; -- cgit v1.2.3 From 0c24b2325598326cc7af3e93266ebe232c629fe4 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Fri, 23 May 2014 13:45:57 -0400 Subject: staging: dgap: Simplify get_altpin and get_useintr functions Simplify dgap_config_get_useintr and dgap_config_get_altpin changing the case statement to an if statement. Signed-off-by: Mark Hounschell Tested-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index f811cbf5332e..a89606e1fda9 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -7310,14 +7310,11 @@ static uint dgap_config_get_useintr(struct board_t *bd) return 0; for (p = bd->bd_config; p; p = p->next) { - switch (p->type) { - case INTRNODE: + if (p->type == INTRNODE) { /* * check for pcxr types. */ return p->u.useintr; - default: - break; } } @@ -7336,14 +7333,11 @@ static uint dgap_config_get_altpin(struct board_t *bd) return 0; for (p = bd->bd_config; p; p = p->next) { - switch (p->type) { - case ANODE: + if (p->type == ANODE) { /* * check for pcxr types. */ return p->u.altpin; - default: - break; } } -- cgit v1.2.3 From 244a0341d2804f788b4341eb860861899394d6db Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Fri, 23 May 2014 14:02:34 -0400 Subject: staging: dgap: Change GFP_ATOMICs to GFP_KERNEL We don't need to use GFP_ATOMIC at driver load time so use GFP_KERNEL instead. Signed-off-by: Mark Hounschell Tested-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index a89606e1fda9..ca264f950f9c 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -1378,7 +1378,7 @@ static int dgap_tty_init(struct board_t *brd) for (i = 0; i < brd->nasync; i++) { if (!brd->channels[i]) { brd->channels[i] = - kzalloc(sizeof(struct channel_t), GFP_ATOMIC); + kzalloc(sizeof(struct channel_t), GFP_KERNEL); if (!brd->channels[i]) return -ENOMEM; } @@ -4121,11 +4121,11 @@ static int dgap_after_config_loaded(int board) /* * allocate flip buffer for board. */ - dgap_board[board]->flipbuf = kmalloc(MYFLIPLEN, GFP_ATOMIC); + dgap_board[board]->flipbuf = kmalloc(MYFLIPLEN, GFP_KERNEL); if (!dgap_board[board]->flipbuf) return -ENOMEM; - dgap_board[board]->flipflagbuf = kmalloc(MYFLIPLEN, GFP_ATOMIC); + dgap_board[board]->flipflagbuf = kmalloc(MYFLIPLEN, GFP_KERNEL); if (!dgap_board[board]->flipflagbuf) { kfree(dgap_board[board]->flipbuf); return -ENOMEM; @@ -7232,7 +7232,7 @@ static struct cnode *dgap_newnode(int t) { struct cnode *n; - n = kmalloc(sizeof(struct cnode), GFP_ATOMIC); + n = kmalloc(sizeof(struct cnode), GFP_KERNEL); if (n) { memset((char *)n, 0, sizeof(struct cnode)); n->type = t; -- cgit v1.2.3 From e6c1ef6ce9dadadd1961578487f9c76fa134b020 Mon Sep 17 00:00:00 2001 From: Joel Pelaez Jorge Date: Fri, 23 May 2014 14:27:43 -0500 Subject: Staging: rtl8192u: Remove old WIRELESS_EXT support Remove support for building against ancient WIRELESS_EXT versions, only leaving support for the current version: 22 Signed-off-by: Joel Pelaez Jorge Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211.h | 14 ------------- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 5 +---- drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c | 24 +---------------------- drivers/staging/rtl8192u/r8192U_core.c | 6 +----- drivers/staging/rtl8192u/r8192U_wx.c | 20 +------------------ 5 files changed, 4 insertions(+), 65 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h index cac2056b7f82..3b40b61ce29f 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h @@ -354,12 +354,10 @@ enum _ReasonCode{ #define ieee80211_wx_get_scan ieee80211_wx_get_scan_rsl #define ieee80211_wx_set_encode ieee80211_wx_set_encode_rsl #define ieee80211_wx_get_encode ieee80211_wx_get_encode_rsl -#if WIRELESS_EXT >= 18 #define ieee80211_wx_set_mlme ieee80211_wx_set_mlme_rsl #define ieee80211_wx_set_auth ieee80211_wx_set_auth_rsl #define ieee80211_wx_set_encode_ext ieee80211_wx_set_encode_ext_rsl #define ieee80211_wx_get_encode_ext ieee80211_wx_get_encode_ext_rsl -#endif typedef struct ieee_param { @@ -392,16 +390,6 @@ typedef struct ieee_param { }ieee_param; -#if WIRELESS_EXT < 17 -#define IW_QUAL_QUAL_INVALID 0x10 -#define IW_QUAL_LEVEL_INVALID 0x20 -#define IW_QUAL_NOISE_INVALID 0x40 -#define IW_QUAL_QUAL_UPDATED 0x1 -#define IW_QUAL_LEVEL_UPDATED 0x2 -#define IW_QUAL_NOISE_UPDATED 0x4 -#endif - - // 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 @@ -2398,7 +2386,6 @@ extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *key); -#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); @@ -2411,7 +2398,6 @@ extern int ieee80211_wx_set_auth(struct ieee80211_device *ieee, extern int ieee80211_wx_set_mlme(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -#endif extern int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len); /* ieee80211_softmac.c */ diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index 92707fbdaa44..89389c4d0b80 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -950,7 +950,6 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, //IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, skb->data, skb->len); #ifdef NOT_YET -#if WIRELESS_EXT > 15 /* Put this code here so that we avoid duplicating it in all * Rx paths. - Jean II */ #ifdef IW_WIRELESS_SPY /* defined in iw_handler.h */ @@ -964,18 +963,16 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, wireless_spy_update(dev, hdr->addr2, &wstats); } #endif /* IW_WIRELESS_SPY */ -#endif /* WIRELESS_EXT > 15 */ hostap_update_rx_stats(local->ap, hdr, rx_stats); #endif -#if WIRELESS_EXT > 15 if (ieee->iw_mode == IW_MODE_MONITOR) { ieee80211_monitor_rx(ieee, skb, rx_stats); stats->rx_packets++; stats->rx_bytes += skb->len; return 1; } -#endif + if (ieee->host_decrypt) { int idx = 0; if (skb->len >= hdrlen + 3) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c index 38f124dcab6e..d43e4a78f70d 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c @@ -194,7 +194,7 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee, iwe.u.data.length = p - custom; if (iwe.u.data.length) start = iwe_stream_add_point(info, start, stop, &iwe, custom); -#if (WIRELESS_EXT < 18) + if (ieee->wpa_enabled && network->wpa_ie_len){ char buf[MAX_WPA_IE_LEN * 2 + 30]; // printk("WPA IE\n"); @@ -224,26 +224,6 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee, iwe.u.data.length = strlen(buf); start = iwe_stream_add_point(info, start, stop, &iwe, buf); } -#else - memset(&iwe, 0, sizeof(iwe)); - if (network->wpa_ie_len) - { - char buf[MAX_WPA_IE_LEN]; - memcpy(buf, network->wpa_ie, network->wpa_ie_len); - iwe.cmd = IWEVGENIE; - iwe.u.data.length = network->wpa_ie_len; - start = iwe_stream_add_point(info, start, stop, &iwe, buf); - } - memset(&iwe, 0, sizeof(iwe)); - if (network->rsn_ie_len) - { - char buf[MAX_WPA_IE_LEN]; - memcpy(buf, network->rsn_ie, network->rsn_ie_len); - iwe.cmd = IWEVGENIE; - iwe.u.data.length = network->rsn_ie_len; - start = iwe_stream_add_point(info, start, stop, &iwe, buf); - } -#endif /* Add EXTRA: Age to display seconds since last beacon/probe response @@ -525,7 +505,6 @@ int ieee80211_wx_get_encode(struct ieee80211_device *ieee, } EXPORT_SYMBOL(ieee80211_wx_get_encode); -#if (WIRELESS_EXT >= 18) int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -836,7 +815,6 @@ int ieee80211_wx_set_auth(struct ieee80211_device *ieee, return 0; } EXPORT_SYMBOL(ieee80211_wx_set_auth); -#endif int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len) { diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index b7097505eef5..97af38f9f281 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -4978,12 +4978,8 @@ static int rtl8192_usb_probe(struct usb_interface *intf, dev->netdev_ops = &rtl8192_netdev_ops; -#if WIRELESS_EXT >= 12 -#if WIRELESS_EXT < 17 - dev->get_wireless_stats = r8192_get_wireless_stats; -#endif dev->wireless_handlers = (struct iw_handler_def *) &r8192_wx_handlers_def; -#endif + dev->type = ARPHRD_ETHER; dev->watchdog_timeo = HZ*3; //modified by john, 0805 diff --git a/drivers/staging/rtl8192u/r8192U_wx.c b/drivers/staging/rtl8192u/r8192U_wx.c index 72db77317dec..abae1631a4f0 100644 --- a/drivers/staging/rtl8192u/r8192U_wx.c +++ b/drivers/staging/rtl8192u/r8192U_wx.c @@ -319,10 +319,8 @@ static int rtl8180_wx_get_range(struct net_device *dev, } range->num_frequency = val; range->num_channels = val; -#if WIRELESS_EXT > 17 range->enc_capa = IW_ENC_CAPA_WPA|IW_ENC_CAPA_WPA2| IW_ENC_CAPA_CIPHER_TKIP|IW_ENC_CAPA_CIPHER_CCMP; -#endif tmp->scan_capa = 0x01; return 0; } @@ -732,7 +730,6 @@ exit: return err; } -#if (WIRELESS_EXT >= 18) //hw security need to reorganized. static int r8192_wx_set_enc_ext(struct net_device *dev, struct iw_request_info *info, @@ -842,7 +839,7 @@ static int r8192_wx_set_mlme(struct net_device *dev, up(&priv->wx_sem); return ret; } -#endif + static int r8192_wx_set_gen_ie(struct net_device *dev, struct iw_request_info *info, union iwreq_data *data, char *extra) @@ -890,11 +887,7 @@ static iw_handler r8192_wx_handlers[] = NULL, /* SIOCWIWTHRSPY */ r8192_wx_set_wap, /* SIOCSIWAP */ r8192_wx_get_wap, /* SIOCGIWAP */ -#if (WIRELESS_EXT >= 18) r8192_wx_set_mlme, /* MLME-- */ -#else - NULL, -#endif dummy, /* SIOCGIWAPLIST -- deprecated */ r8192_wx_set_scan, /* SIOCSIWSCAN */ r8192_wx_get_scan, /* SIOCGIWSCAN */ @@ -923,17 +916,10 @@ static iw_handler r8192_wx_handlers[] = r8192_wx_set_gen_ie,//NULL, /* SIOCSIWGENIE */ NULL, /* SIOCSIWGENIE */ -#if (WIRELESS_EXT >= 18) r8192_wx_set_auth,//NULL, /* SIOCSIWAUTH */ NULL,//r8192_wx_get_auth,//NULL, /* SIOCSIWAUTH */ r8192_wx_set_enc_ext, /* SIOCSIWENCODEEXT */ NULL,//r8192_wx_get_enc_ext,//NULL, /* SIOCSIWENCODEEXT */ -#else - NULL, - NULL, - NULL, - NULL, -#endif NULL, /* SIOCSIWPMKSA */ NULL, /*---hole---*/ @@ -977,7 +963,6 @@ static iw_handler r8192_private_handler[] = { r8192_wx_force_reset, }; -//#if WIRELESS_EXT >= 17 struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); @@ -1006,7 +991,6 @@ struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev) wstats->qual.updated = IW_QUAL_ALL_UPDATED| IW_QUAL_DBM; return wstats; } -//#endif struct iw_handler_def r8192_wx_handlers_def={ @@ -1015,8 +999,6 @@ struct iw_handler_def r8192_wx_handlers_def={ .private = r8192_private_handler, .num_private = ARRAY_SIZE(r8192_private_handler), .num_private_args = sizeof(r8192_private_args) / sizeof(struct iw_priv_args), -#if WIRELESS_EXT >= 17 .get_wireless_stats = r8192_get_wireless_stats, -#endif .private_args = (struct iw_priv_args *)r8192_private_args, }; -- cgit v1.2.3 From 0292bd466ac5a1a5f3e706790f3aec05cd45ee5f Mon Sep 17 00:00:00 2001 From: Chaitanya Hazarey Date: Fri, 23 May 2014 12:24:37 -0700 Subject: Staging: xgifb: Fixed a code-style warning Added a blank line after declarations to fix the following warning issued by checkpatch.pl: drivers/staging/xgifb/vb_init.c:800: WARNING: Missing a blank line after declarations Signed-off-by: Chaitanya Hazarey Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_setmode.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index c638c8febee9..8795e173cb5a 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -5462,6 +5462,7 @@ unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info, unsigned short ModeIdIndex; struct vb_device_info VBINF; struct vb_device_info *pVBInfo = &VBINF; + pVBInfo->IF_DEF_LVDS = 0; if (HwDeviceExtension->jChipType >= XG20) -- cgit v1.2.3 From 7585940325874d395daa0949686671f543aa1ddf Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 23 May 2014 18:00:00 +0100 Subject: staging: vt6656: remove camel case MACvWriteMultiAddr Camel case changes. pDevice -> priv Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/mac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index 8298a9e25ee2..22dd65399fce 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -53,11 +53,11 @@ static int msglevel =MSG_LEVEL_INFO; * Return Value: none * */ -void MACvWriteMultiAddr(struct vnt_private *pDevice, u64 mc_filter) +void MACvWriteMultiAddr(struct vnt_private *priv, u64 mc_filter) { __le64 le_mc = cpu_to_le64(mc_filter); - CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_WRITE, MAC_REG_MAR0, + CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, MAC_REG_MAR0, MESSAGE_REQUEST_MACREG, sizeof(le_mc), (u8 *)&le_mc); } -- cgit v1.2.3 From 88eee075dd7f7b99d25d2bd0cf1f081ae484f196 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 23 May 2014 18:00:01 +0100 Subject: staging: vt6656: remove camel case MACbShutdown Camel case changes pDevice -> priv signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/mac.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index 22dd65399fce..cc80c8e40633 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -72,15 +72,9 @@ void MACvWriteMultiAddr(struct vnt_private *priv, u64 mc_filter) * * */ -void MACbShutdown(struct vnt_private *pDevice) +void MACbShutdown(struct vnt_private *priv) { - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_MACSHUTDOWN, - 0, - 0, - 0, - NULL - ); + CONTROLnsRequestOut(priv, MESSAGE_TYPE_MACSHUTDOWN, 0, 0, 0, NULL); } void MACvSetBBType(struct vnt_private *pDevice, u8 byType) -- cgit v1.2.3 From bee7b68add90105a504360f262ea8efa5c4c3aaa Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 23 May 2014 18:00:02 +0100 Subject: staging: vt6656: camel case clean up MACvSetBBType Camel case changes pDevice -> priv byType -> type pbyData -> data Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/mac.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index cc80c8e40633..0e14aabca736 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -77,20 +77,15 @@ void MACbShutdown(struct vnt_private *priv) CONTROLnsRequestOut(priv, MESSAGE_TYPE_MACSHUTDOWN, 0, 0, 0, NULL); } -void MACvSetBBType(struct vnt_private *pDevice, u8 byType) +void MACvSetBBType(struct vnt_private *priv, u8 type) { - u8 pbyData[2]; + u8 data[2]; - pbyData[0] = byType; - pbyData[1] = EnCFG_BBType_MASK; + data[0] = type; + data[1] = EnCFG_BBType_MASK; - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE_MASK, - MAC_REG_ENCFG0, - MESSAGE_REQUEST_MACREG, - ARRAY_SIZE(pbyData), - pbyData - ); + CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE_MASK, MAC_REG_ENCFG0, + MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } /* -- cgit v1.2.3 From 9190c4d2867a31f1023a22b3555648bbc038ef75 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 23 May 2014 18:00:03 +0100 Subject: staging: vt6656: MACvDisableKeyEntry fix sizeof uEntryIdx to u8 Remove byData and change all callers to u8. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/iwctl.c | 2 +- drivers/staging/vt6656/mac.c | 10 +++------- drivers/staging/vt6656/mac.h | 2 +- drivers/staging/vt6656/main_usb.c | 2 +- drivers/staging/vt6656/wpactl.c | 2 +- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/staging/vt6656/iwctl.c b/drivers/staging/vt6656/iwctl.c index de2ae1d46434..3edeb2f44f6a 100644 --- a/drivers/staging/vt6656/iwctl.c +++ b/drivers/staging/vt6656/iwctl.c @@ -1150,7 +1150,7 @@ int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info, struct iw_point *wrq = &wrqu->encoding; u32 dwKeyIndex = (u32)(wrq->flags & IW_ENCODE_INDEX); int ii; - int uu; + u8 uu; int rc = 0; int index = (wrq->flags & IW_ENCODE_INDEX); diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index 0e14aabca736..a341eab8986b 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -102,19 +102,15 @@ void MACvSetBBType(struct vnt_private *priv, u8 type) * Return Value: none * */ -void MACvDisableKeyEntry(struct vnt_private *pDevice, u32 uEntryIdx) +void MACvDisableKeyEntry(struct vnt_private *pDevice, u8 uEntryIdx) { - u8 byData; - - byData = (u8) uEntryIdx; - //issue write misc fifo command to device CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_CLRKEYENTRY, 0, 0, - 1, - &byData + sizeof(uEntryIdx), + &uEntryIdx ); } diff --git a/drivers/staging/vt6656/mac.h b/drivers/staging/vt6656/mac.h index 4053e431ef99..2084d4b1e532 100644 --- a/drivers/staging/vt6656/mac.h +++ b/drivers/staging/vt6656/mac.h @@ -406,7 +406,7 @@ void MACvWriteMultiAddr(struct vnt_private *, u64); void MACbShutdown(struct vnt_private *); void MACvSetBBType(struct vnt_private *, u8); -void MACvDisableKeyEntry(struct vnt_private *, u32); +void MACvDisableKeyEntry(struct vnt_private *, u8); void MACvSetKeyEntry(struct vnt_private *, u16, u32, u32, u8 *, u32 *); void MACvRegBitsOff(struct vnt_private *, u8, u8); void MACvRegBitsOn(struct vnt_private *, u8, u8); diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 09e444d8aceb..ed04804d1d50 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -984,7 +984,7 @@ static int device_close(struct net_device *dev) { struct vnt_private *pDevice = netdev_priv(dev); struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - int uu; + u8 uu; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_close1\n"); if (pDevice == NULL) diff --git a/drivers/staging/vt6656/wpactl.c b/drivers/staging/vt6656/wpactl.c index b6885a91d1a4..587e1117b8c7 100644 --- a/drivers/staging/vt6656/wpactl.c +++ b/drivers/staging/vt6656/wpactl.c @@ -66,7 +66,7 @@ int wpa_set_keys(struct vnt_private *pDevice, void *ctx) u64 KeyRSC; u8 byKeyDecMode = KEY_CTL_WEP; int ret = 0; - int uu; + u8 uu; int ii; if (param->u.wpa_key.alg_name > WPA_ALG_CCMP) -- cgit v1.2.3 From e836e4267c65fa4cb161225e9812c58c19ab27fd Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 23 May 2014 18:00:04 +0100 Subject: staging: vt6656: camel case clean up MACvDisableKeyEntry Camel case changes pDevice -> priv uEntryIdx -> entry_idx Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/mac.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index a341eab8986b..c6bddf592ac7 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -102,16 +102,10 @@ void MACvSetBBType(struct vnt_private *priv, u8 type) * Return Value: none * */ -void MACvDisableKeyEntry(struct vnt_private *pDevice, u8 uEntryIdx) +void MACvDisableKeyEntry(struct vnt_private *priv, u8 entry_idx) { - //issue write misc fifo command to device - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_CLRKEYENTRY, - 0, - 0, - sizeof(uEntryIdx), - &uEntryIdx - ); + CONTROLnsRequestOut(priv, MESSAGE_TYPE_CLRKEYENTRY, 0, 0, + sizeof(entry_idx), &entry_idx); } /* -- cgit v1.2.3 From f22f76980e58adc1da098d239e8da956c4e70274 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 23 May 2014 18:00:05 +0100 Subject: staging: vt6656: camel case cleanup MACvRegBitsOff camel case changes pDevice -> priv byRegOfs -> reg_ofs byBits -> bits pbyData -> data Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/mac.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index c6bddf592ac7..2edbaf9c084d 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -181,20 +181,15 @@ void MACvSetKeyEntry(struct vnt_private *pDevice, u16 wKeyCtl, u32 uEntryIdx, } -void MACvRegBitsOff(struct vnt_private *pDevice, u8 byRegOfs, u8 byBits) +void MACvRegBitsOff(struct vnt_private *priv, u8 reg_ofs, u8 bits) { - u8 pbyData[2]; + u8 data[2]; - pbyData[0] = 0; - pbyData[1] = byBits; + data[0] = 0; + data[1] = bits; - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE_MASK, - byRegOfs, - MESSAGE_REQUEST_MACREG, - ARRAY_SIZE(pbyData), - pbyData - ); + CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE_MASK, + reg_ofs, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } void MACvRegBitsOn(struct vnt_private *pDevice, u8 byRegOfs, u8 byBits) -- cgit v1.2.3 From 8fda36cac1a2cdb4ad00966ab25120bb540fd558 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 23 May 2014 18:00:06 +0100 Subject: staging: vt6656: camel case clean up MACvRegBitsOn camel case changes pDevice -> priv byRegOfs -> reg_ofs byBits -> bits pbyData -> data Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/mac.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index 2edbaf9c084d..bb0c90955934 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -192,20 +192,15 @@ void MACvRegBitsOff(struct vnt_private *priv, u8 reg_ofs, u8 bits) reg_ofs, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } -void MACvRegBitsOn(struct vnt_private *pDevice, u8 byRegOfs, u8 byBits) +void MACvRegBitsOn(struct vnt_private *priv, u8 reg_ofs, u8 bits) { - u8 pbyData[2]; + u8 data[2]; - pbyData[0] = byBits; - pbyData[1] = byBits; + data[0] = bits; + data[1] = bits; - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE_MASK, - byRegOfs, - MESSAGE_REQUEST_MACREG, - ARRAY_SIZE(pbyData), - pbyData - ); + CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE_MASK, + reg_ofs, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } void MACvWriteWord(struct vnt_private *pDevice, u8 byRegOfs, u16 wData) -- cgit v1.2.3 From e1cc91f688b0932d2641259fb38c6899eefcf978 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 23 May 2014 18:00:07 +0100 Subject: staging: vt6656: camel case cleanup MACvWriteWord camel case changes pDevice -> priv byRegOfs -> reg_ofs wData -> word pbyData -> data Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/mac.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index bb0c90955934..a195703a69e4 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -203,21 +203,15 @@ void MACvRegBitsOn(struct vnt_private *priv, u8 reg_ofs, u8 bits) reg_ofs, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } -void MACvWriteWord(struct vnt_private *pDevice, u8 byRegOfs, u16 wData) +void MACvWriteWord(struct vnt_private *priv, u8 reg_ofs, u16 word) { - u8 pbyData[2]; - - pbyData[0] = (u8)(wData & 0xff); - pbyData[1] = (u8)(wData >> 8); + u8 data[2]; - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE, - byRegOfs, - MESSAGE_REQUEST_MACREG, - ARRAY_SIZE(pbyData), - pbyData - ); + data[0] = (u8)(word & 0xff); + data[1] = (u8)(word >> 8); + CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, + reg_ofs, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } void MACvWriteBSSIDAddress(struct vnt_private *pDevice, u8 *pbyEtherAddr) -- cgit v1.2.3 From 08a150c5061d39977de64da19734e472f3aaf6a1 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 23 May 2014 18:00:08 +0100 Subject: staging: vt6656: MACvWriteBSSIDAddress remove pbyData Remove pbyData and point directly to pbyEtherAddr The size is always ETH_ALEN (6) Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/mac.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index a195703a69e4..31f54fbcd4ac 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -216,21 +216,12 @@ void MACvWriteWord(struct vnt_private *priv, u8 reg_ofs, u16 word) void MACvWriteBSSIDAddress(struct vnt_private *pDevice, u8 *pbyEtherAddr) { - u8 pbyData[6]; - - pbyData[0] = *((u8 *)pbyEtherAddr); - pbyData[1] = *((u8 *)pbyEtherAddr+1); - pbyData[2] = *((u8 *)pbyEtherAddr+2); - pbyData[3] = *((u8 *)pbyEtherAddr+3); - pbyData[4] = *((u8 *)pbyEtherAddr+4); - pbyData[5] = *((u8 *)pbyEtherAddr+5); - CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_WRITE, MAC_REG_BSSID0, MESSAGE_REQUEST_MACREG, - ARRAY_SIZE(pbyData), - pbyData + ETH_ALEN, + pbyEtherAddr ); } -- cgit v1.2.3 From 1195200fff5562c527bfdba87462c5f669c2dbfe Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 23 May 2014 18:00:09 +0100 Subject: staging: vt6656: camel case clean up MACvWriteBSSIDAddress camel case changes pDevice -> priv pbyEtherAddr -> addr Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/mac.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index 31f54fbcd4ac..a19602f38b93 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -214,15 +214,10 @@ void MACvWriteWord(struct vnt_private *priv, u8 reg_ofs, u16 word) reg_ofs, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } -void MACvWriteBSSIDAddress(struct vnt_private *pDevice, u8 *pbyEtherAddr) +void MACvWriteBSSIDAddress(struct vnt_private *priv, u8 *addr) { - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE, - MAC_REG_BSSID0, - MESSAGE_REQUEST_MACREG, - ETH_ALEN, - pbyEtherAddr - ); + CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, MAC_REG_BSSID0, + MESSAGE_REQUEST_MACREG, ETH_ALEN, addr); } void MACvEnableProtectMD(struct vnt_private *pDevice) -- cgit v1.2.3 From a7ecb9d3ea3fdc91a3abb40203f5f7810ffe88c2 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 23 May 2014 18:00:10 +0100 Subject: staging: vt6656: camel case clean up MACvEnableProtectMD Camel case changes pDevice -> priv pbyData -> data Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/mac.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index a19602f38b93..7783a37bff94 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -220,20 +220,15 @@ void MACvWriteBSSIDAddress(struct vnt_private *priv, u8 *addr) MESSAGE_REQUEST_MACREG, ETH_ALEN, addr); } -void MACvEnableProtectMD(struct vnt_private *pDevice) +void MACvEnableProtectMD(struct vnt_private *priv) { - u8 pbyData[2]; + u8 data[2]; - pbyData[0] = EnCFG_ProtectMd; - pbyData[1] = EnCFG_ProtectMd; + data[0] = EnCFG_ProtectMd; + data[1] = EnCFG_ProtectMd; - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE_MASK, - MAC_REG_ENCFG0, - MESSAGE_REQUEST_MACREG, - ARRAY_SIZE(pbyData), - pbyData - ); + CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE_MASK, + MAC_REG_ENCFG0, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } void MACvDisableProtectMD(struct vnt_private *pDevice) -- cgit v1.2.3 From 04cc8ef525e9a6af961052950e7be658c1685e9e Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 23 May 2014 18:00:11 +0100 Subject: staging: vt6656: camel case clean up MACvDisableProtectMD camel case changes pDevice -> priv pbyData -> data Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/mac.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index 7783a37bff94..0805341db201 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -231,20 +231,15 @@ void MACvEnableProtectMD(struct vnt_private *priv) MAC_REG_ENCFG0, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } -void MACvDisableProtectMD(struct vnt_private *pDevice) +void MACvDisableProtectMD(struct vnt_private *priv) { - u8 pbyData[2]; + u8 data[2]; - pbyData[0] = 0; - pbyData[1] = EnCFG_ProtectMd; + data[0] = 0; + data[1] = EnCFG_ProtectMd; - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE_MASK, - MAC_REG_ENCFG0, - MESSAGE_REQUEST_MACREG, - ARRAY_SIZE(pbyData), - pbyData - ); + CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE_MASK, + MAC_REG_ENCFG0, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } void MACvEnableBarkerPreambleMd(struct vnt_private *pDevice) -- cgit v1.2.3 From 23cde77f5a1071e710fd10bcfb7ecce22e84879b Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 23 May 2014 18:00:12 +0100 Subject: staging: vt6656: camel case clean up MACvEnableBarkerPreambleMd Camel case changes pDevice -> priv pbyData -> data Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/mac.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index 0805341db201..86bf3fb43327 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -242,20 +242,15 @@ void MACvDisableProtectMD(struct vnt_private *priv) MAC_REG_ENCFG0, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } -void MACvEnableBarkerPreambleMd(struct vnt_private *pDevice) +void MACvEnableBarkerPreambleMd(struct vnt_private *priv) { - u8 pbyData[2]; + u8 data[2]; - pbyData[0] = EnCFG_BarkerPream; - pbyData[1] = EnCFG_BarkerPream; + data[0] = EnCFG_BarkerPream; + data[1] = EnCFG_BarkerPream; - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE_MASK, - MAC_REG_ENCFG2, - MESSAGE_REQUEST_MACREG, - ARRAY_SIZE(pbyData), - pbyData - ); + CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE_MASK, + MAC_REG_ENCFG2, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } void MACvDisableBarkerPreambleMd(struct vnt_private *pDevice) -- cgit v1.2.3 From 67933f425775e9a61ebc107f4e089c773681e2c8 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 23 May 2014 18:00:13 +0100 Subject: staging: vt6656: camel case clean up MACvDisableBarkerPreambleMd camel case changes pDevice -> priv phyData -> data Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/mac.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index 86bf3fb43327..b370b0aae451 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -253,20 +253,15 @@ void MACvEnableBarkerPreambleMd(struct vnt_private *priv) MAC_REG_ENCFG2, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } -void MACvDisableBarkerPreambleMd(struct vnt_private *pDevice) +void MACvDisableBarkerPreambleMd(struct vnt_private *priv) { - u8 pbyData[2]; + u8 data[2]; - pbyData[0] = 0; - pbyData[1] = EnCFG_BarkerPream; + data[0] = 0; + data[1] = EnCFG_BarkerPream; - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE_MASK, - MAC_REG_ENCFG2, - MESSAGE_REQUEST_MACREG, - ARRAY_SIZE(pbyData), - pbyData - ); + CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE_MASK, + MAC_REG_ENCFG2, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } void MACvWriteBeaconInterval(struct vnt_private *pDevice, u16 wInterval) -- cgit v1.2.3 From ddb8c95f9364dd99330db7ef3582f5871b05a811 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 23 May 2014 18:00:14 +0100 Subject: staging: vt6656: camel case clean up MACvWriteBeaconInterval camel case changes pDevice -> priv wInterval -> interval pbyData -> data Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/mac.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index b370b0aae451..f48683407496 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -264,18 +264,13 @@ void MACvDisableBarkerPreambleMd(struct vnt_private *priv) MAC_REG_ENCFG2, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } -void MACvWriteBeaconInterval(struct vnt_private *pDevice, u16 wInterval) +void MACvWriteBeaconInterval(struct vnt_private *priv, u16 interval) { - u8 pbyData[2]; + u8 data[2]; - pbyData[0] = (u8)(wInterval & 0xff); - pbyData[1] = (u8)(wInterval >> 8); + data[0] = (u8)(interval & 0xff); + data[1] = (u8)(interval >> 8); - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE, - MAC_REG_BI, - MESSAGE_REQUEST_MACREG, - ARRAY_SIZE(pbyData), - pbyData - ); + CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, + MAC_REG_BI, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } -- cgit v1.2.3 From 3605f84e780252c987a4eae7050aaddcec8bf639 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 23 May 2014 18:00:15 +0100 Subject: staging: vt6656: camel case clean up CARDvCalculateOFDMRParameter Camel case changes wRate -> rate byBBType -> bb_type pbyTxRate -> tx_rate pbyRsvTime -> rsv_time Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/card.c | 185 +++++++++++++++++++----------------------- 1 file changed, 83 insertions(+), 102 deletions(-) diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index b8f35e7a25ee..1674a6f49278 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -190,114 +190,95 @@ static u16 swGetOFDMControlRate(struct vnt_private *pDevice, u16 wRateIdx) * Description: Calculate TxRate and RsvTime fields for RSPINF in OFDM mode. * * Parameters: - * In: - * wRate - Tx Rate - * byPktType - Tx Packet type - * Out: - * pbyTxRate - pointer to RSPINF TxRate field - * pbyRsvTime - pointer to RSPINF RsvTime field + * In: + * rate - Tx Rate + * bb_type - Tx Packet type + * Out: + * tx_rate - pointer to RSPINF TxRate field + * rsv_time- pointer to RSPINF RsvTime field * * Return Value: none * */ -static void -CARDvCalculateOFDMRParameter ( - u16 wRate, - u8 byBBType, - u8 * pbyTxRate, - u8 * pbyRsvTime - ) +void CARDvCalculateOFDMRParameter(u16 rate, u8 bb_type, + u8 *tx_rate, u8 *rsv_time) { - switch (wRate) { - case RATE_6M : - if (byBBType == BB_TYPE_11A) {//5GHZ - *pbyTxRate = 0x9B; - *pbyRsvTime = 24; - } - else { - *pbyTxRate = 0x8B; - *pbyRsvTime = 30; - } - break; - - case RATE_9M : - if (byBBType == BB_TYPE_11A) {//5GHZ - *pbyTxRate = 0x9F; - *pbyRsvTime = 16; - } - else { - *pbyTxRate = 0x8F; - *pbyRsvTime = 22; - } - break; - - case RATE_12M : - if (byBBType == BB_TYPE_11A) {//5GHZ - *pbyTxRate = 0x9A; - *pbyRsvTime = 12; - } - else { - *pbyTxRate = 0x8A; - *pbyRsvTime = 18; - } - break; - - case RATE_18M : - if (byBBType == BB_TYPE_11A) {//5GHZ - *pbyTxRate = 0x9E; - *pbyRsvTime = 8; - } - else { - *pbyTxRate = 0x8E; - *pbyRsvTime = 14; - } - break; - - case RATE_36M : - if (byBBType == BB_TYPE_11A) {//5GHZ - *pbyTxRate = 0x9D; - *pbyRsvTime = 4; - } - else { - *pbyTxRate = 0x8D; - *pbyRsvTime = 10; - } - break; - - case RATE_48M : - if (byBBType == BB_TYPE_11A) {//5GHZ - *pbyTxRate = 0x98; - *pbyRsvTime = 4; - } - else { - *pbyTxRate = 0x88; - *pbyRsvTime = 10; - } - break; - - case RATE_54M : - if (byBBType == BB_TYPE_11A) {//5GHZ - *pbyTxRate = 0x9C; - *pbyRsvTime = 4; - } - else { - *pbyTxRate = 0x8C; - *pbyRsvTime = 10; - } - break; - case RATE_24M : - default : - if (byBBType == BB_TYPE_11A) {//5GHZ - *pbyTxRate = 0x99; - *pbyRsvTime = 8; - } - else { - *pbyTxRate = 0x89; - *pbyRsvTime = 14; - } - break; - } + switch (rate) { + case RATE_6M: + if (bb_type == BB_TYPE_11A) { + *tx_rate = 0x9b; + *rsv_time = 24; + } else { + *tx_rate = 0x8b; + *rsv_time = 30; + } + break; + case RATE_9M: + if (bb_type == BB_TYPE_11A) { + *tx_rate = 0x9f; + *rsv_time = 16; + } else { + *tx_rate = 0x8f; + *rsv_time = 22; + } + break; + case RATE_12M: + if (bb_type == BB_TYPE_11A) { + *tx_rate = 0x9a; + *rsv_time = 12; + } else { + *tx_rate = 0x8a; + *rsv_time = 18; + } + break; + case RATE_18M: + if (bb_type == BB_TYPE_11A) { + *tx_rate = 0x9e; + *rsv_time = 8; + } else { + *tx_rate = 0x8e; + *rsv_time = 14; + } + break; + case RATE_36M: + if (bb_type == BB_TYPE_11A) { + *tx_rate = 0x9d; + *rsv_time = 4; + } else { + *tx_rate = 0x8d; + *rsv_time = 10; + } + break; + case RATE_48M: + if (bb_type == BB_TYPE_11A) { + *tx_rate = 0x98; + *rsv_time = 4; + } else { + *tx_rate = 0x88; + *rsv_time = 10; + } + break; + case RATE_54M: + if (bb_type == BB_TYPE_11A) { + *tx_rate = 0x9c; + *rsv_time = 4; + } else { + *tx_rate = 0x8c; + *rsv_time = 10; + } + break; + case RATE_24M: + default: + if (bb_type == BB_TYPE_11A) { + *tx_rate = 0x99; + *rsv_time = 8; + } else { + *tx_rate = 0x89; + *rsv_time = 14; + } + break; + } } /* -- cgit v1.2.3 From 652d0f00f60c249ef022f4c36b46b616eb4ceb9f Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 23 May 2014 18:00:16 +0100 Subject: staging: vt6656: camel case cleanup CARDvSetRSPINF camel case changes pDevice -> priv byBBType -> bb_type Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/card.c | 179 +++++++++++++++++++----------------------- drivers/staging/vt6656/card.h | 2 +- 2 files changed, 80 insertions(+), 101 deletions(-) diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index 1674a6f49278..43554e0549c6 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -293,112 +293,91 @@ void CARDvCalculateOFDMRParameter(u16 rate, u8 bb_type, * Return Value: None. * */ -void CARDvSetRSPINF(struct vnt_private *pDevice, u8 byBBType) + +void CARDvSetRSPINF(struct vnt_private *priv, u8 bb_type) { struct vnt_phy_field phy[4]; - u8 abyTxRate[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; /* For OFDM */ - u8 abyRsvTime[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; - u8 abyData[34]; + u8 tx_rate[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; /* For OFDM */ + u8 rsv_time[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; + u8 data[34]; int i; - //RSPINF_b_1 - BBvCalculateParameter(pDevice, 14, - swGetCCKControlRate(pDevice, RATE_1M), PK_TYPE_11B, &phy[0]); - - ///RSPINF_b_2 - BBvCalculateParameter(pDevice, 14, - swGetCCKControlRate(pDevice, RATE_2M), PK_TYPE_11B, &phy[1]); - - //RSPINF_b_5 - BBvCalculateParameter(pDevice, 14, - swGetCCKControlRate(pDevice, RATE_5M), PK_TYPE_11B, &phy[2]); - - //RSPINF_b_11 - BBvCalculateParameter(pDevice, 14, - swGetCCKControlRate(pDevice, RATE_11M), PK_TYPE_11B, &phy[3]); - - //RSPINF_a_6 - CARDvCalculateOFDMRParameter (RATE_6M, - byBBType, - &abyTxRate[0], - &abyRsvTime[0]); - - //RSPINF_a_9 - CARDvCalculateOFDMRParameter (RATE_9M, - byBBType, - &abyTxRate[1], - &abyRsvTime[1]); - - //RSPINF_a_12 - CARDvCalculateOFDMRParameter (RATE_12M, - byBBType, - &abyTxRate[2], - &abyRsvTime[2]); - - //RSPINF_a_18 - CARDvCalculateOFDMRParameter (RATE_18M, - byBBType, - &abyTxRate[3], - &abyRsvTime[3]); - - //RSPINF_a_24 - CARDvCalculateOFDMRParameter (RATE_24M, - byBBType, - &abyTxRate[4], - &abyRsvTime[4]); - - //RSPINF_a_36 - CARDvCalculateOFDMRParameter (swGetOFDMControlRate(pDevice, RATE_36M), - byBBType, - &abyTxRate[5], - &abyRsvTime[5]); - - //RSPINF_a_48 - CARDvCalculateOFDMRParameter (swGetOFDMControlRate(pDevice, RATE_48M), - byBBType, - &abyTxRate[6], - &abyRsvTime[6]); - - //RSPINF_a_54 - CARDvCalculateOFDMRParameter (swGetOFDMControlRate(pDevice, RATE_54M), - byBBType, - &abyTxRate[7], - &abyRsvTime[7]); - - //RSPINF_a_72 - CARDvCalculateOFDMRParameter (swGetOFDMControlRate(pDevice, RATE_54M), - byBBType, - &abyTxRate[8], - &abyRsvTime[8]); - - put_unaligned(phy[0].len, (u16 *)&abyData[0]); - abyData[2] = phy[0].signal; - abyData[3] = phy[0].service; - - put_unaligned(phy[1].len, (u16 *)&abyData[4]); - abyData[6] = phy[1].signal; - abyData[7] = phy[1].service; - - put_unaligned(phy[2].len, (u16 *)&abyData[8]); - abyData[10] = phy[2].signal; - abyData[11] = phy[2].service; - - put_unaligned(phy[3].len, (u16 *)&abyData[12]); - abyData[14] = phy[3].signal; - abyData[15] = phy[3].service; - - for (i = 0; i < 9; i++) { - abyData[16+i*2] = abyTxRate[i]; - abyData[16+i*2+1] = abyRsvTime[i]; - } + /*RSPINF_b_1*/ + BBvCalculateParameter(priv, 14, + swGetCCKControlRate(priv, RATE_1M), PK_TYPE_11B, &phy[0]); - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE, - MAC_REG_RSPINF_B_1, - MESSAGE_REQUEST_MACREG, - 34, - &abyData[0]); + /*RSPINF_b_2*/ + BBvCalculateParameter(priv, 14, + swGetCCKControlRate(priv, RATE_2M), PK_TYPE_11B, &phy[1]); + + /*RSPINF_b_5*/ + BBvCalculateParameter(priv, 14, + swGetCCKControlRate(priv, RATE_5M), PK_TYPE_11B, &phy[2]); + + /*RSPINF_b_11*/ + BBvCalculateParameter(priv, 14, + swGetCCKControlRate(priv, RATE_11M), PK_TYPE_11B, &phy[3]); + + + /*RSPINF_a_6*/ + CARDvCalculateOFDMRParameter(RATE_6M, bb_type, + &tx_rate[0], &rsv_time[0]); + + /*RSPINF_a_9*/ + CARDvCalculateOFDMRParameter(RATE_9M, bb_type, + &tx_rate[1], &rsv_time[1]); + + /*RSPINF_a_12*/ + CARDvCalculateOFDMRParameter(RATE_12M, bb_type, + &tx_rate[2], &rsv_time[2]); + + /*RSPINF_a_18*/ + CARDvCalculateOFDMRParameter(RATE_18M, bb_type, + &tx_rate[3], &rsv_time[3]); + + /*RSPINF_a_24*/ + CARDvCalculateOFDMRParameter(RATE_24M, bb_type, + &tx_rate[4], &rsv_time[4]); + + /*RSPINF_a_36*/ + CARDvCalculateOFDMRParameter(swGetOFDMControlRate(priv, RATE_36M), + bb_type, &tx_rate[5], &rsv_time[5]); + + /*RSPINF_a_48*/ + CARDvCalculateOFDMRParameter(swGetOFDMControlRate(priv, RATE_48M), + bb_type, &tx_rate[6], &rsv_time[6]); + + /*RSPINF_a_54*/ + CARDvCalculateOFDMRParameter(swGetOFDMControlRate(priv, RATE_54M), + bb_type, &tx_rate[7], &rsv_time[7]); + + /*RSPINF_a_72*/ + CARDvCalculateOFDMRParameter(swGetOFDMControlRate(priv, RATE_54M), + bb_type, &tx_rate[8], &rsv_time[8]); + + put_unaligned(phy[0].len, (u16 *)&data[0]); + data[2] = phy[0].signal; + data[3] = phy[0].service; + + put_unaligned(phy[1].len, (u16 *)&data[4]); + data[6] = phy[1].signal; + data[7] = phy[1].service; + + put_unaligned(phy[2].len, (u16 *)&data[8]); + data[10] = phy[2].signal; + data[11] = phy[2].service; + + put_unaligned(phy[3].len, (u16 *)&data[12]); + data[14] = phy[3].signal; + data[15] = phy[3].service; + + for (i = 0; i < 9; i++) { + data[16 + i * 2] = tx_rate[i]; + data[16 + i * 2 + 1] = rsv_time[i]; + } + CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, + MAC_REG_RSPINF_B_1, MESSAGE_REQUEST_MACREG, 34, &data[0]); } /* diff --git a/drivers/staging/vt6656/card.h b/drivers/staging/vt6656/card.h index f843e50875f9..6123c1326103 100644 --- a/drivers/staging/vt6656/card.h +++ b/drivers/staging/vt6656/card.h @@ -46,7 +46,7 @@ typedef enum _CARD_PHY_TYPE { struct vnt_private; void CARDbSetMediaChannel(struct vnt_private *pDevice, u32 uConnectionChannel); -void CARDvSetRSPINF(struct vnt_private *pDevice, u8 byBBType); +void CARDvSetRSPINF(struct vnt_private *, u8); void vUpdateIFS(struct vnt_private *pDevice); void CARDvUpdateBasicTopRate(struct vnt_private *pDevice); void CARDbAddBasicRate(struct vnt_private *pDevice, u16 wRateIdx); -- cgit v1.2.3 From 5ebc46d64ca9bebc3d358c7f14ad8b175a159c1c Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 23 May 2014 18:00:17 +0100 Subject: staging: vt6656: camel case cleanup vUpdateIFS camel case changes pDevice -> priv byMaxMin -> max_min byData -> data pItemRates -> item_rates Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/card.c | 159 +++++++++++++++++++++--------------------- drivers/staging/vt6656/card.h | 2 +- 2 files changed, 79 insertions(+), 82 deletions(-) diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index 43554e0549c6..58d31bc7a1c6 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -385,95 +385,92 @@ void CARDvSetRSPINF(struct vnt_private *priv, u8 bb_type) * * Parameters: * In: - * pDevice - The adapter to be set - * Out: - * none + * priv - The adapter to be set + * Out: + * none * * Return Value: None. * */ -void vUpdateIFS(struct vnt_private *pDevice) +void vUpdateIFS(struct vnt_private *priv) { - u8 byMaxMin = 0; - u8 byData[4]; - - if (pDevice->byPacketType==PK_TYPE_11A) {//0000 0000 0000 0000,11a - pDevice->uSlot = C_SLOT_SHORT; - pDevice->uSIFS = C_SIFS_A; - pDevice->uDIFS = C_SIFS_A + 2*C_SLOT_SHORT; - pDevice->uCwMin = C_CWMIN_A; - byMaxMin = 4; - } - else if (pDevice->byPacketType==PK_TYPE_11B) {//0000 0001 0000 0000,11b - pDevice->uSlot = C_SLOT_LONG; - pDevice->uSIFS = C_SIFS_BG; - pDevice->uDIFS = C_SIFS_BG + 2*C_SLOT_LONG; - pDevice->uCwMin = C_CWMIN_B; - byMaxMin = 5; - } - else {// PK_TYPE_11GA & PK_TYPE_11GB - u8 byRate = 0; - bool bOFDMRate = false; - unsigned int ii = 0; - PWLAN_IE_SUPP_RATES pItemRates = NULL; - - pDevice->uSIFS = C_SIFS_BG; - if (pDevice->bShortSlotTime) { - pDevice->uSlot = C_SLOT_SHORT; - } else { - pDevice->uSlot = C_SLOT_LONG; - } - pDevice->uDIFS = C_SIFS_BG + 2*pDevice->uSlot; - - pItemRates = (PWLAN_IE_SUPP_RATES)pDevice->vnt_mgmt.abyCurrSuppRates; - for (ii = 0; ii < pItemRates->len; ii++) { - byRate = (u8)(pItemRates->abyRates[ii]&0x7F); - if (RATEwGetRateIdx(byRate) > RATE_11M) { - bOFDMRate = true; - break; - } - } - if (bOFDMRate == false) { - pItemRates = (PWLAN_IE_SUPP_RATES)pDevice->vnt_mgmt - .abyCurrExtSuppRates; - for (ii = 0; ii < pItemRates->len; ii++) { - byRate = (u8)(pItemRates->abyRates[ii]&0x7F); - if (RATEwGetRateIdx(byRate) > RATE_11M) { - bOFDMRate = true; - break; - } - } - } - if (bOFDMRate == true) { - pDevice->uCwMin = C_CWMIN_A; - byMaxMin = 4; - } else { - pDevice->uCwMin = C_CWMIN_B; - byMaxMin = 5; - } - } + u8 max_min = 0; + u8 data[4]; + + if (priv->byPacketType == PK_TYPE_11A) { + priv->uSlot = C_SLOT_SHORT; + priv->uSIFS = C_SIFS_A; + priv->uDIFS = C_SIFS_A + 2 * C_SLOT_SHORT; + priv->uCwMin = C_CWMIN_A; + max_min = 4; + } else if (priv->byPacketType == PK_TYPE_11B) { + priv->uSlot = C_SLOT_LONG; + priv->uSIFS = C_SIFS_BG; + priv->uDIFS = C_SIFS_BG + 2 * C_SLOT_LONG; + priv->uCwMin = C_CWMIN_B; + max_min = 5; + } else {/* PK_TYPE_11GA & PK_TYPE_11GB */ + u8 rate = 0; + bool ofdm_rate = false; + unsigned int ii = 0; + PWLAN_IE_SUPP_RATES item_rates = NULL; + + priv->uSIFS = C_SIFS_BG; + + if (priv->bShortSlotTime) + priv->uSlot = C_SLOT_SHORT; + else + priv->uSlot = C_SLOT_LONG; + + priv->uDIFS = C_SIFS_BG + 2 * priv->uSlot; + + item_rates = + (PWLAN_IE_SUPP_RATES)priv->vnt_mgmt.abyCurrSuppRates; + + for (ii = 0; ii < item_rates->len; ii++) { + rate = (u8)(item_rates->abyRates[ii] & 0x7f); + if (RATEwGetRateIdx(rate) > RATE_11M) { + ofdm_rate = true; + break; + } + } - pDevice->uCwMax = C_CWMAX; - pDevice->uEIFS = C_EIFS; + if (ofdm_rate == false) { + item_rates = (PWLAN_IE_SUPP_RATES)priv->vnt_mgmt + .abyCurrExtSuppRates; + for (ii = 0; ii < item_rates->len; ii++) { + rate = (u8)(item_rates->abyRates[ii] & 0x7f); + if (RATEwGetRateIdx(rate) > RATE_11M) { + ofdm_rate = true; + break; + } + } + } - byData[0] = (u8)pDevice->uSIFS; - byData[1] = (u8)pDevice->uDIFS; - byData[2] = (u8)pDevice->uEIFS; - byData[3] = (u8)pDevice->uSlot; - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE, - MAC_REG_SIFS, - MESSAGE_REQUEST_MACREG, - 4, - &byData[0]); + if (ofdm_rate == true) { + priv->uCwMin = C_CWMIN_A; + max_min = 4; + } else { + priv->uCwMin = C_CWMIN_B; + max_min = 5; + } + } - byMaxMin |= 0xA0;//1010 1111,C_CWMAX = 1023 - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE, - MAC_REG_CWMAXMIN0, - MESSAGE_REQUEST_MACREG, - 1, - &byMaxMin); + priv->uCwMax = C_CWMAX; + priv->uEIFS = C_EIFS; + + data[0] = (u8)priv->uSIFS; + data[1] = (u8)priv->uDIFS; + data[2] = (u8)priv->uEIFS; + data[3] = (u8)priv->uSlot; + + CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, MAC_REG_SIFS, + MESSAGE_REQUEST_MACREG, 4, &data[0]); + + max_min |= 0xa0; + + CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, MAC_REG_CWMAXMIN0, + MESSAGE_REQUEST_MACREG, 1, &max_min); } void CARDvUpdateBasicTopRate(struct vnt_private *pDevice) diff --git a/drivers/staging/vt6656/card.h b/drivers/staging/vt6656/card.h index 6123c1326103..4986e2dd638e 100644 --- a/drivers/staging/vt6656/card.h +++ b/drivers/staging/vt6656/card.h @@ -47,7 +47,7 @@ struct vnt_private; void CARDbSetMediaChannel(struct vnt_private *pDevice, u32 uConnectionChannel); void CARDvSetRSPINF(struct vnt_private *, u8); -void vUpdateIFS(struct vnt_private *pDevice); +void vUpdateIFS(struct vnt_private *); void CARDvUpdateBasicTopRate(struct vnt_private *pDevice); void CARDbAddBasicRate(struct vnt_private *pDevice, u16 wRateIdx); int CARDbIsOFDMinBasicRate(struct vnt_private *pDevice); -- cgit v1.2.3 From dcce9e0b0825d056447fad7114fcaee94e1ecdcc Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 23 May 2014 18:00:18 +0100 Subject: staging: vt6656: camel case clean up CARDvUpdateBasicTopRate Camel case changes pDevice -> priv byTopOFDM -> top_ofdm byTopCCK -> top_cck Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/card.c | 46 ++++++++++++++++++++++--------------------- drivers/staging/vt6656/card.h | 2 +- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index 58d31bc7a1c6..c52b9839f7e4 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -473,29 +473,31 @@ void vUpdateIFS(struct vnt_private *priv) MESSAGE_REQUEST_MACREG, 1, &max_min); } -void CARDvUpdateBasicTopRate(struct vnt_private *pDevice) +void CARDvUpdateBasicTopRate(struct vnt_private *priv) { - u8 byTopOFDM = RATE_24M, byTopCCK = RATE_1M; - u8 ii; - - //Determines the highest basic rate. - for (ii = RATE_54M; ii >= RATE_6M; ii --) { - if ( (pDevice->wBasicRate) & ((u16)(1<byTopOFDMBasicRate = byTopOFDM; - - for (ii = RATE_11M;; ii --) { - if ( (pDevice->wBasicRate) & ((u16)(1<byTopCCKBasicRate = byTopCCK; + u8 top_ofdm = RATE_24M, top_cck = RATE_1M; + u8 i; + + /*Determines the highest basic rate.*/ + for (i = RATE_54M; i >= RATE_6M; i--) { + if (priv->wBasicRate & (u16)(1 << i)) { + top_ofdm = i; + break; + } + } + + priv->byTopOFDMBasicRate = top_ofdm; + + for (i = RATE_11M;; i--) { + if (priv->wBasicRate & (u16)(1 << i)) { + top_cck = i; + break; + } + if (i == RATE_1M) + break; + } + + priv->byTopCCKBasicRate = top_cck; } /* diff --git a/drivers/staging/vt6656/card.h b/drivers/staging/vt6656/card.h index 4986e2dd638e..78bd96fb9a31 100644 --- a/drivers/staging/vt6656/card.h +++ b/drivers/staging/vt6656/card.h @@ -48,7 +48,7 @@ struct vnt_private; void CARDbSetMediaChannel(struct vnt_private *pDevice, u32 uConnectionChannel); void CARDvSetRSPINF(struct vnt_private *, u8); void vUpdateIFS(struct vnt_private *); -void CARDvUpdateBasicTopRate(struct vnt_private *pDevice); +void CARDvUpdateBasicTopRate(struct vnt_private *); void CARDbAddBasicRate(struct vnt_private *pDevice, u16 wRateIdx); int CARDbIsOFDMinBasicRate(struct vnt_private *pDevice); void CARDvAdjustTSF(struct vnt_private *pDevice, u8 byRxRate, -- cgit v1.2.3 From 6db0deaec99f6319cc678e7e964a599dc94e5a65 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 23 May 2014 18:00:19 +0100 Subject: staging: vt6656: camel case cleanup CARDbAddBasicRate camel case changes pDevice -> priv wRateIdx -> rate_idx Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/card.c | 9 ++++----- drivers/staging/vt6656/card.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index c52b9839f7e4..439e536fbeee 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -513,14 +513,13 @@ void CARDvUpdateBasicTopRate(struct vnt_private *priv) * Return Value: true if succeeded; false if failed. * */ -void CARDbAddBasicRate(struct vnt_private *pDevice, u16 wRateIdx) +void CARDbAddBasicRate(struct vnt_private *priv, u16 rate_idx) { - u16 wRate = (1 << wRateIdx); - pDevice->wBasicRate |= wRate; + priv->wBasicRate |= (1 << rate_idx); - //Determines the highest basic rate. - CARDvUpdateBasicTopRate(pDevice); + /*Determines the highest basic rate.*/ + CARDvUpdateBasicTopRate(priv); } int CARDbIsOFDMinBasicRate(struct vnt_private *pDevice) diff --git a/drivers/staging/vt6656/card.h b/drivers/staging/vt6656/card.h index 78bd96fb9a31..ac734714c7d1 100644 --- a/drivers/staging/vt6656/card.h +++ b/drivers/staging/vt6656/card.h @@ -49,7 +49,7 @@ void CARDbSetMediaChannel(struct vnt_private *pDevice, u32 uConnectionChannel); void CARDvSetRSPINF(struct vnt_private *, u8); void vUpdateIFS(struct vnt_private *); void CARDvUpdateBasicTopRate(struct vnt_private *); -void CARDbAddBasicRate(struct vnt_private *pDevice, u16 wRateIdx); +void CARDbAddBasicRate(struct vnt_private *, u16); int CARDbIsOFDMinBasicRate(struct vnt_private *pDevice); void CARDvAdjustTSF(struct vnt_private *pDevice, u8 byRxRate, u64 qwBSSTimestamp, u64 qwLocalTSF); -- cgit v1.2.3 From 7949f30a36550b9feeedff10bb4b156b372c6e53 Mon Sep 17 00:00:00 2001 From: Nicolas Joseph Date: Fri, 23 May 2014 21:45:08 +0200 Subject: staging/olpc_dcon: fix checkpatch warnings WARNING: Missing a blank line after declarations Signed-off-by: Nicolas Joseph Signed-off-by: Greg Kroah-Hartman --- drivers/staging/olpc_dcon/olpc_dcon.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c b/drivers/staging/olpc_dcon/olpc_dcon.c index 26b4ec56fd30..eb83b28b8cd1 100644 --- a/drivers/staging/olpc_dcon/olpc_dcon.c +++ b/drivers/staging/olpc_dcon/olpc_dcon.c @@ -210,6 +210,7 @@ static void dcon_sleep(struct dcon_priv *dcon, bool sleep) if (sleep) { u8 pm = 0; + x = olpc_ec_cmd(EC_DCON_POWER_MODE, &pm, 1, NULL, 0); if (x) pr_warn("unable to force dcon to power down: %d!\n", x); @@ -240,6 +241,7 @@ static void dcon_sleep(struct dcon_priv *dcon, bool sleep) static void dcon_load_holdoff(struct dcon_priv *dcon) { struct timespec delta_t, now; + while (1) { getnstimeofday(&now); delta_t = timespec_sub(now, dcon->load_time); @@ -399,14 +401,15 @@ static ssize_t dcon_mode_show(struct device *dev, struct device_attribute *attr, char *buf) { struct dcon_priv *dcon = dev_get_drvdata(dev); + return sprintf(buf, "%4.4X\n", dcon->disp_mode); } static ssize_t dcon_sleep_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct dcon_priv *dcon = dev_get_drvdata(dev); + return sprintf(buf, "%d\n", dcon->asleep); } @@ -414,6 +417,7 @@ static ssize_t dcon_freeze_show(struct device *dev, struct device_attribute *attr, char *buf) { struct dcon_priv *dcon = dev_get_drvdata(dev); + return sprintf(buf, "%d\n", dcon->curr_src == DCON_SOURCE_DCON ? 1 : 0); } @@ -421,6 +425,7 @@ static ssize_t dcon_mono_show(struct device *dev, struct device_attribute *attr, char *buf) { struct dcon_priv *dcon = dev_get_drvdata(dev); + return sprintf(buf, "%d\n", dcon->mono); } @@ -534,6 +539,7 @@ static int dcon_bl_update(struct backlight_device *dev) static int dcon_bl_get(struct backlight_device *dev) { struct dcon_priv *dcon = bl_get_data(dev); + return dcon->bl_val; } -- cgit v1.2.3 From 22f6b9789aef2e0b0b409b1d7708cc653540248c Mon Sep 17 00:00:00 2001 From: Mitchel Humpherys Date: Fri, 23 May 2014 13:01:22 -0700 Subject: staging: ion: WARN when the handle kmap_cnt is going to wrap around There are certain client bugs (double unmap, for example) that can cause the handle->kmap_cnt (an unsigned int) to wrap around from zero. This causes problems when the handle is destroyed because we have: while (handle->kmap_cnt) ion_handle_kmap_put(handle); which takes a long time to complete when kmap_cnt starts at ~0 and can result in a watchdog timeout. WARN and bail when kmap_cnt is about to wrap around from zero. Signed-off-by: Mitchel Humpherys Acked-by: Colin Cross Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index ea2c8a9addb5..389b8f67a2ec 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -627,6 +627,10 @@ static void ion_handle_kmap_put(struct ion_handle *handle) { struct ion_buffer *buffer = handle->buffer; + if (!handle->kmap_cnt) { + WARN(1, "%s: Double unmap detected! bailing...\n", __func__); + return; + } handle->kmap_cnt--; if (!handle->kmap_cnt) ion_buffer_kmap_put(buffer); -- cgit v1.2.3 From a3709f7a143d9522ede046d23ed46b7f4fe67102 Mon Sep 17 00:00:00 2001 From: Davide Gianforte Date: Fri, 23 May 2014 22:06:44 +0200 Subject: staging: gdm72xx: code cleanup Checkpatch.pl cleanup Thanks again to Greg KH and Dan Carpenter for the patience :) Signed-off-by: Davide Gianforte Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm72xx/gdm_qos.c | 9 ++++++--- drivers/staging/gdm72xx/gdm_sdio.c | 6 ++++-- drivers/staging/gdm72xx/gdm_usb.c | 16 ++++++++++------ drivers/staging/gdm72xx/gdm_wimax.c | 19 ++++++++++++------- drivers/staging/gdm72xx/netlink_k.c | 3 ++- drivers/staging/gdm72xx/usb_boot.c | 3 ++- 6 files changed, 36 insertions(+), 20 deletions(-) diff --git a/drivers/staging/gdm72xx/gdm_qos.c b/drivers/staging/gdm72xx/gdm_qos.c index eba3bfaebacd..df6f000534d4 100644 --- a/drivers/staging/gdm72xx/gdm_qos.c +++ b/drivers/staging/gdm72xx/gdm_qos.c @@ -47,7 +47,8 @@ static void *alloc_qos_entry(void) spin_lock_irqsave(&qos_free_list.lock, flags); if (qos_free_list.cnt) { - entry = list_entry(qos_free_list.head.prev, struct qos_entry_s, list); + entry = list_entry(qos_free_list.head.prev, struct qos_entry_s, + list); list_del(&entry->list); qos_free_list.cnt--; spin_unlock_irqrestore(&qos_free_list.lock, flags); @@ -228,7 +229,8 @@ static u32 extract_qos_list(struct nic *nic, struct list_head *head) if (list_empty(&qcb->qos_list[i])) continue; - entry = list_entry(qcb->qos_list[i].prev, struct qos_entry_s, list); + entry = list_entry(qcb->qos_list[i].prev, struct qos_entry_s, + list); list_move_tail(&entry->list, head); qcb->csr[i].qos_buf_count++; @@ -430,7 +432,8 @@ void gdm_recv_qos_hci_packet(void *nic_ptr, u8 *buf, int size) qcb->qos_list_cnt--; qcb->qos_limit_size = 254/qcb->qos_list_cnt; - list_for_each_entry_safe(entry, n, &qcb->qos_list[index], list) { + list_for_each_entry_safe(entry, n, &qcb->qos_list[index], + list) { list_move_tail(&entry->list, &free_list); } spin_unlock_irqrestore(&qcb->qos_lock, flags); diff --git a/drivers/staging/gdm72xx/gdm_sdio.c b/drivers/staging/gdm72xx/gdm_sdio.c index 6d1de33e2e90..7398d451ccc2 100644 --- a/drivers/staging/gdm72xx/gdm_sdio.c +++ b/drivers/staging/gdm72xx/gdm_sdio.c @@ -312,7 +312,8 @@ static void send_sdu(struct sdio_func *func, struct tx_cxt *tx) spin_unlock_irqrestore(&tx->lock, flags); } -static void send_hci(struct sdio_func *func, struct tx_cxt *tx, struct sdio_tx *t) +static void send_hci(struct sdio_func *func, struct tx_cxt *tx, + struct sdio_tx *t) { unsigned long flags; @@ -601,7 +602,8 @@ static int gdm_sdio_receive(void *priv_dev, return 0; } -static int sdio_wimax_probe(struct sdio_func *func, const struct sdio_device_id *id) +static int sdio_wimax_probe(struct sdio_func *func, + const struct sdio_device_id *id) { int ret; struct phy_dev *phy_dev = NULL; diff --git a/drivers/staging/gdm72xx/gdm_usb.c b/drivers/staging/gdm72xx/gdm_usb.c index c59a7a4be82f..78d6667fa0d5 100644 --- a/drivers/staging/gdm72xx/gdm_usb.c +++ b/drivers/staging/gdm72xx/gdm_usb.c @@ -527,7 +527,8 @@ static void do_pm_control(struct work_struct *work) } #endif /* CONFIG_WIMAX_GDM72XX_USB_PM */ -static int gdm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) +static int gdm_usb_probe(struct usb_interface *intf, + const struct usb_device_id *id) { int ret = 0; u8 bConfigurationValue; @@ -556,7 +557,8 @@ static int gdm_usb_probe(struct usb_interface *intf, const struct usb_device_id } /* Support for EEPROM bootloader */ - if (bConfigurationValue == DOWNLOAD_CONF_VALUE || idProduct & B_DOWNLOAD) { + if (bConfigurationValue == DOWNLOAD_CONF_VALUE || + idProduct & B_DOWNLOAD) { ret = usb_boot(usbdev, bcdDevice); goto out; } @@ -628,7 +630,8 @@ static void gdm_usb_disconnect(struct usb_interface *intf) idProduct = L2H(usbdev->descriptor.idProduct); if (idProduct != EMERGENCY_PID && - bConfigurationValue != DOWNLOAD_CONF_VALUE && (idProduct & B_DOWNLOAD) == 0) { + bConfigurationValue != DOWNLOAD_CONF_VALUE && + (idProduct & B_DOWNLOAD) == 0) { udev = phy_dev->priv_dev; udev->usbdev = NULL; @@ -731,7 +734,8 @@ static int k_mode_thread(void *arg) spin_lock_irqsave(&tx->lock, flags); - list_for_each_entry_safe(t, temp, &tx->pending_list, p_list) { + list_for_each_entry_safe(t, temp, &tx->pending_list, + p_list) { list_del(&t->p_list); ret = usb_submit_urb(t->urb, GFP_ATOMIC); @@ -747,8 +751,8 @@ static int k_mode_thread(void *arg) spin_lock_irqsave(&k_lock, flags2); } wait_event_interruptible_lock_irq(k_wait, - !list_empty(&k_list) || k_mode_stop, - k_lock); + !list_empty(&k_list) || + k_mode_stop, k_lock); spin_unlock_irqrestore(&k_lock, flags2); } return 0; diff --git a/drivers/staging/gdm72xx/gdm_wimax.c b/drivers/staging/gdm72xx/gdm_wimax.c index 2c917c12db2b..e5e511585122 100644 --- a/drivers/staging/gdm72xx/gdm_wimax.c +++ b/drivers/staging/gdm72xx/gdm_wimax.c @@ -346,7 +346,8 @@ int gdm_wimax_send_tx(struct sk_buff *skb, struct net_device *dev) int ret = 0; struct nic *nic = netdev_priv(dev); - ret = gdm_wimax_send_with_cb(nic, skb->data, skb->len, tx_complete, nic); + ret = gdm_wimax_send_with_cb(nic, skb->data, skb->len, tx_complete, + nic); if (ret == -ENOSPC) { netif_stop_queue(dev); ret = 0; @@ -535,7 +536,8 @@ static void gdm_wimax_cleanup_ioctl(struct net_device *dev) static void gdm_update_fsm(struct net_device *dev, struct fsm_s *new_fsm) { struct nic *nic = netdev_priv(dev); - struct fsm_s *cur_fsm = (struct fsm_s *)nic->sdk_data[SIOC_DATA_FSM].buf; + struct fsm_s *cur_fsm = (struct fsm_s *) + nic->sdk_data[SIOC_DATA_FSM].buf; if (!cur_fsm) return; @@ -572,15 +574,16 @@ static int gdm_wimax_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) return -EOPNOTSUPP; } if (req->cmd == SIOCG_DATA) { - ret = gdm_wimax_ioctl_get_data(&req->data, - &nic->sdk_data[req->data_id]); + ret = gdm_wimax_ioctl_get_data( + &req->data, &nic->sdk_data[req->data_id]); if (ret < 0) return ret; } else if (req->cmd == SIOCS_DATA) { if (req->data_id == SIOC_DATA_FSM) { /*NOTE: gdm_update_fsm should be called before gdm_wimax_ioctl_set_data is called*/ - gdm_update_fsm(dev, (struct fsm_s *)req->data.buf); + gdm_update_fsm(dev, + (struct fsm_s *)req->data.buf); } ret = gdm_wimax_ioctl_set_data( &nic->sdk_data[req->data_id], &req->data); @@ -657,7 +660,8 @@ static int gdm_wimax_hci_get_tlv(u8 *buf, u8 *T, u16 *L, u8 **V) return next_pos; } -static int gdm_wimax_get_prepared_info(struct net_device *dev, char *buf, int len) +static int gdm_wimax_get_prepared_info(struct net_device *dev, char *buf, + int len) { u8 T, *V; u16 L; @@ -781,7 +785,8 @@ static void gdm_wimax_transmit_pkt(struct net_device *dev, char *buf, int len) switch (cmd_evt) { case WIMAX_RX_SDU_AGGR: - gdm_wimax_transmit_aggr_pkt(dev, &buf[HCI_HEADER_SIZE], cmd_len); + gdm_wimax_transmit_aggr_pkt(dev, &buf[HCI_HEADER_SIZE], + cmd_len); break; case WIMAX_RX_SDU: gdm_wimax_netif_rx(dev, &buf[HCI_HEADER_SIZE], cmd_len); diff --git a/drivers/staging/gdm72xx/netlink_k.c b/drivers/staging/gdm72xx/netlink_k.c index 06f7b13b3196..9bf00e683f13 100644 --- a/drivers/staging/gdm72xx/netlink_k.c +++ b/drivers/staging/gdm72xx/netlink_k.c @@ -55,7 +55,8 @@ static void netlink_rcv_cb(struct sk_buff *skb) if (skb->len >= NLMSG_HDRLEN) { nlh = (struct nlmsghdr *)skb->data; - if (skb->len < nlh->nlmsg_len || nlh->nlmsg_len > ND_MAX_MSG_LEN) { + if (skb->len < nlh->nlmsg_len || + nlh->nlmsg_len > ND_MAX_MSG_LEN) { netdev_err(skb->dev, "Invalid length (%d,%d)\n", skb->len, nlh->nlmsg_len); return; diff --git a/drivers/staging/gdm72xx/usb_boot.c b/drivers/staging/gdm72xx/usb_boot.c index 7d235b161ae6..d59bac872ffe 100644 --- a/drivers/staging/gdm72xx/usb_boot.c +++ b/drivers/staging/gdm72xx/usb_boot.c @@ -106,7 +106,8 @@ static int gdm_wibro_recv(struct usb_device *usbdev, void *data, int len) return 0; } -static int download_image(struct usb_device *usbdev, const struct firmware *firm, +static int download_image(struct usb_device *usbdev, + const struct firmware *firm, loff_t pos, u32 img_len, u32 magic_num) { struct dn_header h; -- cgit v1.2.3 From c4396e7479cc1e389f9e50ac02fdf9443718ac74 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 23 May 2014 22:23:39 +0200 Subject: Staging: bcm: Shortened code by using variable Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index 4564c63f908c..6793e25b1ae4 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -1881,19 +1881,22 @@ VOID OverrideServiceFlowParams(struct bcm_mini_adapter *Adapter, PUINT puiBuffer BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Going to Delete SF"); deleteSFBySfid(Adapter, uiSearchRuleIndex); } else { - Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value = ntohs(pHostInfo->VCID); - Adapter->PackInfo[uiSearchRuleIndex].usCID = ntohs(pHostInfo->newCID); - Adapter->PackInfo[uiSearchRuleIndex].bActive = false; + struct bcm_packet_info *packinfo = + &Adapter->PackInfo[uiSearchRuleIndex]; + + packinfo->usVCID_Value = ntohs(pHostInfo->VCID); + packinfo->usCID = ntohs(pHostInfo->newCID); + packinfo->bActive = false; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "pHostInfo->QoSParamSet: 0x%x\n", pHostInfo->QoSParamSet); if (pHostInfo->QoSParamSet & 0x1) - Adapter->PackInfo[uiSearchRuleIndex].bAuthorizedSet = TRUE; + packinfo->bAuthorizedSet = TRUE; if (pHostInfo->QoSParamSet & 0x2) - Adapter->PackInfo[uiSearchRuleIndex].bAdmittedSet = TRUE; + packinfo->bAdmittedSet = TRUE; if (pHostInfo->QoSParamSet & 0x4) { - Adapter->PackInfo[uiSearchRuleIndex].bActiveSet = TRUE; - Adapter->PackInfo[uiSearchRuleIndex].bActive = TRUE; + packinfo->bActiveSet = TRUE; + packinfo->bActive = TRUE; } } } -- cgit v1.2.3 From c4fe6fa71dffe3631f842b7f1a7a49018683818f Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 23 May 2014 22:23:40 +0200 Subject: Staging: bcm: Shortened lines in OverrideServiceFlowParams() Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index 6793e25b1ae4..16262bbc5c23 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -1853,7 +1853,8 @@ int get_dsx_sf_data_to_application(struct bcm_mini_adapter *Adapter, UINT uiSFId return STATUS_SUCCESS; } -VOID OverrideServiceFlowParams(struct bcm_mini_adapter *Adapter, PUINT puiBuffer) +VOID OverrideServiceFlowParams(struct bcm_mini_adapter *Adapter, + PUINT puiBuffer) { B_UINT32 u32NumofSFsinMsg = ntohl(*(puiBuffer + 1)); struct bcm_stim_sfhostnotify *pHostInfo = NULL; @@ -1861,7 +1862,8 @@ VOID OverrideServiceFlowParams(struct bcm_mini_adapter *Adapter, PUINT puiBuffer ULONG ulSFID = 0; puiBuffer += 2; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32NumofSFsinMsg: 0x%x\n", u32NumofSFsinMsg); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "u32NumofSFsinMsg: 0x%x\n", u32NumofSFsinMsg); while (u32NumofSFsinMsg != 0 && u32NumofSFsinMsg < NO_OF_QUEUES) { u32NumofSFsinMsg--; @@ -1870,15 +1872,21 @@ VOID OverrideServiceFlowParams(struct bcm_mini_adapter *Adapter, PUINT puiBuffer ulSFID = ntohl(pHostInfo->SFID); uiSearchRuleIndex = SearchSfid(Adapter, ulSFID); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SFID: 0x%lx\n", ulSFID); - - if (uiSearchRuleIndex >= NO_OF_QUEUES || uiSearchRuleIndex == HiPriority) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "The SFID <%lx> doesn't exist in host entry or is Invalid\n", ulSFID); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "SFID: 0x%lx\n", ulSFID); + + if (uiSearchRuleIndex >= NO_OF_QUEUES + || uiSearchRuleIndex == HiPriority) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, + DBG_LVL_ALL, + "The SFID <%lx> doesn't exist in host entry or is Invalid\n", + ulSFID); continue; } if (pHostInfo->RetainSF == false) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Going to Delete SF"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, + DBG_LVL_ALL, "Going to Delete SF"); deleteSFBySfid(Adapter, uiSearchRuleIndex); } else { struct bcm_packet_info *packinfo = @@ -1888,7 +1896,10 @@ VOID OverrideServiceFlowParams(struct bcm_mini_adapter *Adapter, PUINT puiBuffer packinfo->usCID = ntohs(pHostInfo->newCID); packinfo->bActive = false; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "pHostInfo->QoSParamSet: 0x%x\n", pHostInfo->QoSParamSet); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, + DBG_LVL_ALL, + "pHostInfo->QoSParamSet: 0x%x\n", + pHostInfo->QoSParamSet); if (pHostInfo->QoSParamSet & 0x1) packinfo->bAuthorizedSet = TRUE; -- cgit v1.2.3 From 15bba866c775baf236c5a6ee4d4aeb1edd48681e Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 23 May 2014 22:23:41 +0200 Subject: Staging: bcm: Shortened lines in get_dsx_sf_data_to_application() Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index 16262bbc5c23..3d8c04912739 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -1831,22 +1831,29 @@ bool CmControlResponseMessage(struct bcm_mini_adapter *Adapter, /* = NO_OF_QUEUES) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SFID %d not present in queue !!!", uiSFId); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "SFID %d not present in queue !!!", uiSFId); return -EINVAL; } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "status =%d", status); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "status =%d", status); psSfInfo = &Adapter->PackInfo[status]; - if (psSfInfo->pstSFIndication && copy_to_user(user_buffer, - psSfInfo->pstSFIndication, sizeof(struct bcm_add_indication_alt))) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "copy to user failed SFID %d, present in queue !!!", uiSFId); + if (psSfInfo->pstSFIndication + && copy_to_user(user_buffer, psSfInfo->pstSFIndication, + sizeof(struct bcm_add_indication_alt))) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "copy to user failed SFID %d, present in queue !!!", + uiSFId); status = -EFAULT; return status; } -- cgit v1.2.3 From 311cb0786aae1c561608fbccb2d34e5a997c3d43 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 23 May 2014 22:23:42 +0200 Subject: Staging: bcm: Outsourced restoring of endianess for ip adresses Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index 3d8c04912739..59a3eb900163 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -14,6 +14,9 @@ enum E_CLASSIFIER_ACTION { }; static ULONG GetNextTargetBufferLocation(struct bcm_mini_adapter *Adapter, B_UINT16 tid); +static void restore_endianess_of_pstClassifierEntry( + struct bcm_classifier_rule *pstClassifierEntry, + enum bcm_ipaddr_context eIpAddrContext); /************************************************************ * Function - SearchSfid @@ -200,15 +203,10 @@ CopyIpAddrToClassifier(struct bcm_classifier_rule *pstClassifierEntry, } if (bIpVersion6) { /* Restore EndianNess of Struct */ - for (i = 0; i < MAX_IP_RANGE_LENGTH * 4; i++) { - if (eIpAddrContext == eSrcIpAddress) { - pstClassifierEntry->stSrcIpAddress.ulIpv6Addr[i] = ntohl(pstClassifierEntry->stSrcIpAddress.ulIpv6Addr[i]); - pstClassifierEntry->stSrcIpAddress.ulIpv6Mask[i] = ntohl(pstClassifierEntry->stSrcIpAddress.ulIpv6Mask[i]); - } else if (eIpAddrContext == eDestIpAddress) { - pstClassifierEntry->stDestIpAddress.ulIpv6Addr[i] = ntohl(pstClassifierEntry->stDestIpAddress.ulIpv6Addr[i]); - pstClassifierEntry->stDestIpAddress.ulIpv6Mask[i] = ntohl(pstClassifierEntry->stDestIpAddress.ulIpv6Mask[i]); - } - } + restore_endianess_of_pstClassifierEntry( + pstClassifierEntry, + eIpAddrContext + ); } } } @@ -1919,3 +1917,19 @@ VOID OverrideServiceFlowParams(struct bcm_mini_adapter *Adapter, } } } + +static void restore_endianess_of_pstClassifierEntry( + struct bcm_classifier_rule *pstClassifierEntry, + enum bcm_ipaddr_context eIpAddrContext) +{ + int i; + for (i = 0; i < MAX_IP_RANGE_LENGTH * 4; i++) { + if (eIpAddrContext == eSrcIpAddress) { + pstClassifierEntry->stSrcIpAddress.ulIpv6Addr[i] = ntohl(pstClassifierEntry->stSrcIpAddress.ulIpv6Addr[i]); + pstClassifierEntry->stSrcIpAddress.ulIpv6Mask[i] = ntohl(pstClassifierEntry->stSrcIpAddress.ulIpv6Mask[i]); + } else if (eIpAddrContext == eDestIpAddress) { + pstClassifierEntry->stDestIpAddress.ulIpv6Addr[i] = ntohl(pstClassifierEntry->stDestIpAddress.ulIpv6Addr[i]); + pstClassifierEntry->stDestIpAddress.ulIpv6Mask[i] = ntohl(pstClassifierEntry->stDestIpAddress.ulIpv6Mask[i]); + } + } +} -- cgit v1.2.3 From cdc299b7a54d84d9485dfe50b3ef0f511db84d60 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 23 May 2014 22:23:43 +0200 Subject: Staging: bcm: Simplified by using variables Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index 59a3eb900163..181c4e9d9445 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -1923,13 +1923,16 @@ static void restore_endianess_of_pstClassifierEntry( enum bcm_ipaddr_context eIpAddrContext) { int i; + union u_ip_address *stSrc = &pstClassifierEntry->stSrcIpAddress; + union u_ip_address *stDest = &pstClassifierEntry->stDestIpAddress; + for (i = 0; i < MAX_IP_RANGE_LENGTH * 4; i++) { if (eIpAddrContext == eSrcIpAddress) { - pstClassifierEntry->stSrcIpAddress.ulIpv6Addr[i] = ntohl(pstClassifierEntry->stSrcIpAddress.ulIpv6Addr[i]); - pstClassifierEntry->stSrcIpAddress.ulIpv6Mask[i] = ntohl(pstClassifierEntry->stSrcIpAddress.ulIpv6Mask[i]); + stSrc->ulIpv6Addr[i] = ntohl(stSrc->ulIpv6Addr[i]); + stSrc->ulIpv6Mask[i] = ntohl(stSrc->ulIpv6Mask[i]); } else if (eIpAddrContext == eDestIpAddress) { - pstClassifierEntry->stDestIpAddress.ulIpv6Addr[i] = ntohl(pstClassifierEntry->stDestIpAddress.ulIpv6Addr[i]); - pstClassifierEntry->stDestIpAddress.ulIpv6Mask[i] = ntohl(pstClassifierEntry->stDestIpAddress.ulIpv6Mask[i]); + stDest->ulIpv6Addr[i] = ntohl(stDest->ulIpv6Addr[i]); + stDest->ulIpv6Mask[i] = ntohl(stDest->ulIpv6Mask[i]); } } } -- cgit v1.2.3 From 2ad5c499b9dd517138d46f5b5e3f20db3bff50e4 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 23 May 2014 22:23:44 +0200 Subject: Staging: bcm: Shortened line Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index 181c4e9d9445..3f29deaaee2c 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -1571,7 +1571,8 @@ int AllocAdapterDsxBuffer(struct bcm_mini_adapter *Adapter) * Need to Allocate memory to contain the SUPER Large structures * Our driver can't create these structures on Stack */ - Adapter->caDsxReqResp = kmalloc(sizeof(struct bcm_add_indication_alt)+LEADER_SIZE, GFP_KERNEL); + Adapter->caDsxReqResp = kmalloc(sizeof(struct bcm_add_indication_alt) + + LEADER_SIZE, GFP_KERNEL); if (!Adapter->caDsxReqResp) return -ENOMEM; -- cgit v1.2.3 From 0e5129185a479cc4ed9f9afedd8384489bccfc35 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 23 May 2014 22:23:45 +0200 Subject: Staging: bcm: Shortenend lines in GetNextTargetBufferLocation() Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index 3f29deaaee2c..9fea9a8a46ae 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -1531,12 +1531,14 @@ ULONG SetUpTargetDsxBuffers(struct bcm_mini_adapter *Adapter) return 1; } -static ULONG GetNextTargetBufferLocation(struct bcm_mini_adapter *Adapter, B_UINT16 tid) +static ULONG GetNextTargetBufferLocation(struct bcm_mini_adapter *Adapter, + B_UINT16 tid) { ULONG dsx_buf; ULONG idx, max_try; - if ((Adapter->ulTotalTargetBuffersAvailable == 0) || (Adapter->ulFreeTargetBufferCnt == 0)) { + if ((Adapter->ulTotalTargetBuffersAvailable == 0) + || (Adapter->ulFreeTargetBufferCnt == 0)) { ClearTargetDSXBuffer(Adapter, tid, false); return 0; } @@ -1549,7 +1551,9 @@ static ULONG GetNextTargetBufferLocation(struct bcm_mini_adapter *Adapter, B_UIN } if (max_try == 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "\n GetNextTargetBufferLocation : Error No Free Target DSX Buffers FreeCnt : %lx ", Adapter->ulFreeTargetBufferCnt); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "\n GetNextTargetBufferLocation : Error No Free Target DSX Buffers FreeCnt : %lx ", + Adapter->ulFreeTargetBufferCnt); ClearTargetDSXBuffer(Adapter, tid, false); return 0; } @@ -1560,7 +1564,9 @@ static ULONG GetNextTargetBufferLocation(struct bcm_mini_adapter *Adapter, B_UIN Adapter->ulFreeTargetBufferCnt--; idx = (idx+1)%Adapter->ulTotalTargetBuffersAvailable; Adapter->ulCurrentTargetBuffer = idx; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "GetNextTargetBufferLocation :Returning address %lx tid %d\n", dsx_buf, tid); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "GetNextTargetBufferLocation :Returning address %lx tid %d\n", + dsx_buf, tid); return dsx_buf; } -- cgit v1.2.3 From ae6586f5de0058002d5c05ad07efb9799994bc86 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 23 May 2014 22:23:46 +0200 Subject: Staging: bcm: Shortened lines in SetupTargetDsxBuffers() Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index 9fea9a8a46ae..2743d16e5912 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -1492,31 +1492,44 @@ ULONG SetUpTargetDsxBuffers(struct bcm_mini_adapter *Adapter) int Status; if (!Adapter) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Adapter was NULL!!!"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Adapter was NULL!!!"); return 0; } if (Adapter->astTargetDsxBuffer[0].ulTargetDsxBuffer) return 1; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Size of Each DSX Buffer(Also size of connection manager parameters): %zx ", sizeof(struct bcm_connect_mgr_params)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Reading DSX buffer From Target location %x ", DSX_MESSAGE_EXCHANGE_BUFFER); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Size of Each DSX Buffer(Also size of connection manager parameters): %zx ", + sizeof(struct bcm_connect_mgr_params)); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Reading DSX buffer From Target location %x ", + DSX_MESSAGE_EXCHANGE_BUFFER); - Status = rdmalt(Adapter, DSX_MESSAGE_EXCHANGE_BUFFER, (PUINT)&ulTargetDsxBuffersBase, sizeof(UINT)); + Status = rdmalt(Adapter, DSX_MESSAGE_EXCHANGE_BUFFER, + (PUINT)&ulTargetDsxBuffersBase, sizeof(UINT)); if (Status < 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "RDM failed!!"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "RDM failed!!"); return 0; } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Base Address Of DSX Target Buffer : 0x%lx", ulTargetDsxBuffersBase); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Tgt Buffer is Now %lx :", ulTargetDsxBuffersBase); - ulCntTargetBuffers = DSX_MESSAGE_EXCHANGE_BUFFER_SIZE / sizeof(struct bcm_connect_mgr_params); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Base Address Of DSX Target Buffer : 0x%lx", + ulTargetDsxBuffersBase); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Tgt Buffer is Now %lx :", ulTargetDsxBuffersBase); + ulCntTargetBuffers = DSX_MESSAGE_EXCHANGE_BUFFER_SIZE / + sizeof(struct bcm_connect_mgr_params); Adapter->ulTotalTargetBuffersAvailable = ulCntTargetBuffers > MAX_TARGET_DSX_BUFFERS ? MAX_TARGET_DSX_BUFFERS : ulCntTargetBuffers; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " Total Target DSX Buffer setup %lx ", Adapter->ulTotalTargetBuffersAvailable); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + " Total Target DSX Buffer setup %lx ", + Adapter->ulTotalTargetBuffersAvailable); for (i = 0; i < Adapter->ulTotalTargetBuffersAvailable; i++) { Adapter->astTargetDsxBuffer[i].ulTargetDsxBuffer = ulTargetDsxBuffersBase; -- cgit v1.2.3 From f61d1d554d2f817594364b35f4d28fce810c8e39 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 23 May 2014 22:23:47 +0200 Subject: Staging: bcm: Shortened lines in RestoreCmControlResponseMessage() Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 102 +++++++++++++++++++++++++++++++------------ 1 file changed, 73 insertions(+), 29 deletions(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index 2743d16e5912..3b65990941d0 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -1406,40 +1406,63 @@ ULONG StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, PVOID pvBu } static inline struct bcm_add_indication_alt -*RestoreCmControlResponseMessage(register struct bcm_mini_adapter *Adapter, register PVOID pvBuffer) +*RestoreCmControlResponseMessage(register struct bcm_mini_adapter *Adapter, + register PVOID pvBuffer) { ULONG ulStatus = 0; struct bcm_add_indication *pstAddIndication = NULL; struct bcm_add_indication_alt *pstAddIndicationDest = NULL; pstAddIndication = pvBuffer; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "=====>"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "=====>"); if ((pstAddIndication->u8Type == DSD_REQ) || (pstAddIndication->u8Type == DSD_RSP) || (pstAddIndication->u8Type == DSD_ACK)) return pvBuffer; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Inside RestoreCmControlResponseMessage "); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Inside RestoreCmControlResponseMessage "); /* * Need to Allocate memory to contain the SUPER Large structures * Our driver can't create these structures on Stack :( */ - pstAddIndicationDest = kmalloc(sizeof(struct bcm_add_indication_alt), GFP_KERNEL); + pstAddIndicationDest = kmalloc(sizeof(struct bcm_add_indication_alt), + GFP_KERNEL); if (pstAddIndicationDest) { - memset(pstAddIndicationDest, 0, sizeof(struct bcm_add_indication_alt)); + memset(pstAddIndicationDest, 0, + sizeof(struct bcm_add_indication_alt)); } else { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Failed to allocate memory for SF Add Indication Structure "); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, + DBG_LVL_ALL, + "Failed to allocate memory for SF Add Indication Structure "); return NULL; } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u8Type : 0x%X", pstAddIndication->u8Type); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u8Direction : 0x%X", pstAddIndication->eConnectionDir); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u8TID : 0x%X", ntohs(pstAddIndication->u16TID)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u8CID : 0x%X", ntohs(pstAddIndication->u16CID)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u16VCID : 0x%X", ntohs(pstAddIndication->u16VCID)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-autorized set loc : %p", pstAddIndication->psfAuthorizedSet); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-admitted set loc : %p", pstAddIndication->psfAdmittedSet); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-Active set loc : %p", pstAddIndication->psfActiveSet); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "AddIndication-u8Type : 0x%X", + pstAddIndication->u8Type); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "AddIndication-u8Direction : 0x%X", + pstAddIndication->eConnectionDir); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "AddIndication-u8TID : 0x%X", + ntohs(pstAddIndication->u16TID)); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "AddIndication-u8CID : 0x%X", + ntohs(pstAddIndication->u16CID)); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "AddIndication-u16VCID : 0x%X", + ntohs(pstAddIndication->u16VCID)); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "AddIndication-autorized set loc : %p", + pstAddIndication->psfAuthorizedSet); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "AddIndication-admitted set loc : %p", + pstAddIndication->psfAdmittedSet); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "AddIndication-Active set loc : %p", + pstAddIndication->psfActiveSet); pstAddIndicationDest->u8Type = pstAddIndication->u8Type; pstAddIndicationDest->u8Direction = pstAddIndication->eConnectionDir; @@ -1448,39 +1471,60 @@ static inline struct bcm_add_indication_alt pstAddIndicationDest->u16VCID = pstAddIndication->u16VCID; pstAddIndicationDest->u8CC = pstAddIndication->u8CC; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Restoring Active Set "); - ulStatus = RestoreSFParam(Adapter, (ULONG)pstAddIndication->psfActiveSet, (PUCHAR)&pstAddIndicationDest->sfActiveSet); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Restoring Active Set "); + ulStatus = RestoreSFParam(Adapter, + (ULONG)pstAddIndication->psfActiveSet, + (PUCHAR)&pstAddIndicationDest->sfActiveSet); if (ulStatus != 1) goto failed_restore_sf_param; if (pstAddIndicationDest->sfActiveSet.u8TotalClassifiers > MAX_CLASSIFIERS_IN_SF) - pstAddIndicationDest->sfActiveSet.u8TotalClassifiers = MAX_CLASSIFIERS_IN_SF; + pstAddIndicationDest->sfActiveSet.u8TotalClassifiers = + MAX_CLASSIFIERS_IN_SF; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Restoring Admitted Set "); - ulStatus = RestoreSFParam(Adapter, (ULONG)pstAddIndication->psfAdmittedSet, (PUCHAR)&pstAddIndicationDest->sfAdmittedSet); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Restoring Admitted Set "); + ulStatus = RestoreSFParam(Adapter, + (ULONG)pstAddIndication->psfAdmittedSet, + (PUCHAR)&pstAddIndicationDest->sfAdmittedSet); if (ulStatus != 1) goto failed_restore_sf_param; if (pstAddIndicationDest->sfAdmittedSet.u8TotalClassifiers > MAX_CLASSIFIERS_IN_SF) - pstAddIndicationDest->sfAdmittedSet.u8TotalClassifiers = MAX_CLASSIFIERS_IN_SF; + pstAddIndicationDest->sfAdmittedSet.u8TotalClassifiers = + MAX_CLASSIFIERS_IN_SF; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Restoring Authorized Set "); - ulStatus = RestoreSFParam(Adapter, (ULONG)pstAddIndication->psfAuthorizedSet, (PUCHAR)&pstAddIndicationDest->sfAuthorizedSet); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Restoring Authorized Set "); + ulStatus = RestoreSFParam(Adapter, + (ULONG)pstAddIndication->psfAuthorizedSet, + (PUCHAR)&pstAddIndicationDest->sfAuthorizedSet); if (ulStatus != 1) goto failed_restore_sf_param; if (pstAddIndicationDest->sfAuthorizedSet.u8TotalClassifiers > MAX_CLASSIFIERS_IN_SF) - pstAddIndicationDest->sfAuthorizedSet.u8TotalClassifiers = MAX_CLASSIFIERS_IN_SF; + pstAddIndicationDest->sfAuthorizedSet.u8TotalClassifiers = + MAX_CLASSIFIERS_IN_SF; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Dumping the whole raw packet"); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "============================================================"); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " pstAddIndicationDest->sfActiveSet size %zx %p", sizeof(*pstAddIndicationDest), pstAddIndicationDest); - /* BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, (unsigned char *)pstAddIndicationDest, sizeof(*pstAddIndicationDest)); */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "============================================================"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Dumping the whole raw packet"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "============================================================"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + " pstAddIndicationDest->sfActiveSet size %zx %p", + sizeof(*pstAddIndicationDest), pstAddIndicationDest); + /* BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, CONN_MSG, + * DBG_LVL_ALL, (unsigned char *)pstAddIndicationDest, + * sizeof(*pstAddIndicationDest)); + */ + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "============================================================"); return pstAddIndicationDest; failed_restore_sf_param: kfree(pstAddIndicationDest); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "<====="); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "<====="); return NULL; } -- cgit v1.2.3 From c61f404478fa9735cf661b9dc9721bb1060b9ba0 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 23 May 2014 22:23:48 +0200 Subject: Staging: bcm: Shortened lines in StoreCmControlResponseMessage() Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index 3b65990941d0..f54b177fe5bd 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -1291,7 +1291,8 @@ static ULONG StoreSFParam(struct bcm_mini_adapter *Adapter, PUCHAR pucSrcBuffer, return 1; } -ULONG StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, PVOID pvBuffer, UINT *puBufferLength) +ULONG StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, + PVOID pvBuffer, UINT *puBufferLength) { struct bcm_add_indication_alt *pstAddIndicationAlt = NULL; struct bcm_add_indication *pstAddIndication = NULL; @@ -1325,13 +1326,15 @@ ULONG StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, PVOID pvBu } /* For DSA_REQ, only up to "psfAuthorizedSet" parameter should be accessed by driver! */ - pstAddIndication = kmalloc(sizeof(struct bcm_add_indication), GFP_KERNEL); + pstAddIndication = kmalloc(sizeof(struct bcm_add_indication), + GFP_KERNEL); if (pstAddIndication == NULL) return 0; /* AUTHORIZED SET */ pstAddIndication->psfAuthorizedSet = (struct bcm_connect_mgr_params *) - GetNextTargetBufferLocation(Adapter, pstAddIndicationAlt->u16TID); + GetNextTargetBufferLocation(Adapter, + pstAddIndicationAlt->u16TID); if (!pstAddIndication->psfAuthorizedSet) { kfree(pstAddIndication); return 0; @@ -1344,7 +1347,9 @@ ULONG StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, PVOID pvBu } /* this can't possibly be right */ - pstAddIndication->psfAuthorizedSet = (struct bcm_connect_mgr_params *)ntohl((ULONG)pstAddIndication->psfAuthorizedSet); + pstAddIndication->psfAuthorizedSet = + (struct bcm_connect_mgr_params *) ntohl( + (ULONG)pstAddIndication->psfAuthorizedSet); if (pstAddIndicationAlt->u8Type == DSA_REQ) { struct bcm_add_request AddRequest; @@ -1373,31 +1378,39 @@ ULONG StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, PVOID pvBu /* ADMITTED SET */ pstAddIndication->psfAdmittedSet = (struct bcm_connect_mgr_params *) - GetNextTargetBufferLocation(Adapter, pstAddIndicationAlt->u16TID); + GetNextTargetBufferLocation(Adapter, + pstAddIndicationAlt->u16TID); if (!pstAddIndication->psfAdmittedSet) { kfree(pstAddIndication); return 0; } - if (StoreSFParam(Adapter, (PUCHAR)&pstAddIndicationAlt->sfAdmittedSet, (ULONG)pstAddIndication->psfAdmittedSet) != 1) { + if (StoreSFParam(Adapter, (PUCHAR)&pstAddIndicationAlt->sfAdmittedSet, + (ULONG)pstAddIndication->psfAdmittedSet) != 1) { kfree(pstAddIndication); return 0; } - pstAddIndication->psfAdmittedSet = (struct bcm_connect_mgr_params *)ntohl((ULONG)pstAddIndication->psfAdmittedSet); + pstAddIndication->psfAdmittedSet = + (struct bcm_connect_mgr_params *) ntohl( + (ULONG) pstAddIndication->psfAdmittedSet); /* ACTIVE SET */ pstAddIndication->psfActiveSet = (struct bcm_connect_mgr_params *) - GetNextTargetBufferLocation(Adapter, pstAddIndicationAlt->u16TID); + GetNextTargetBufferLocation(Adapter, + pstAddIndicationAlt->u16TID); if (!pstAddIndication->psfActiveSet) { kfree(pstAddIndication); return 0; } - if (StoreSFParam(Adapter, (PUCHAR)&pstAddIndicationAlt->sfActiveSet, (ULONG)pstAddIndication->psfActiveSet) != 1) { + if (StoreSFParam(Adapter, (PUCHAR)&pstAddIndicationAlt->sfActiveSet, + (ULONG)pstAddIndication->psfActiveSet) != 1) { kfree(pstAddIndication); return 0; } - pstAddIndication->psfActiveSet = (struct bcm_connect_mgr_params *)ntohl((ULONG)pstAddIndication->psfActiveSet); + pstAddIndication->psfActiveSet = + (struct bcm_connect_mgr_params *) ntohl( + (ULONG)pstAddIndication->psfActiveSet); (*puBufferLength) = sizeof(struct bcm_add_indication); *(struct bcm_add_indication *)pvBuffer = *pstAddIndication; -- cgit v1.2.3 From b9e9c27410503810c7e285fae8dd501c1e66f388 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 23 May 2014 22:23:49 +0200 Subject: Staging: bcm: Shortened lines in StoreSFParam() Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index f54b177fe5bd..ea73c5289931 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -1275,7 +1275,8 @@ static inline ULONG RestoreSFParam(struct bcm_mini_adapter *Adapter, ULONG ulAdd return 1; } -static ULONG StoreSFParam(struct bcm_mini_adapter *Adapter, PUCHAR pucSrcBuffer, ULONG ulAddrSFParamSet) +static ULONG StoreSFParam(struct bcm_mini_adapter *Adapter, PUCHAR pucSrcBuffer, + ULONG ulAddrSFParamSet) { UINT nBytesToWrite = sizeof(struct bcm_connect_mgr_params); int ret = 0; @@ -1285,7 +1286,8 @@ static ULONG StoreSFParam(struct bcm_mini_adapter *Adapter, PUCHAR pucSrcBuffer, ret = wrm(Adapter, ulAddrSFParamSet, (u8 *)pucSrcBuffer, nBytesToWrite); if (ret < 0) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "%s:%d WRM failed", __func__, __LINE__); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "%s:%d WRM failed", __func__, __LINE__); return ret; } return 1; -- cgit v1.2.3 From ba3d0ee976b48ea09f1a95d36a8fe5e1ca732ea9 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 23 May 2014 22:23:50 +0200 Subject: Staging: bcm: Shortened lines in RestoreSFParam() Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index ea73c5289931..377e68143886 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -1258,18 +1258,20 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " bValid: 0x%X", pstAddIndication->sfActiveSet.bValid); } -static inline ULONG RestoreSFParam(struct bcm_mini_adapter *Adapter, ULONG ulAddrSFParamSet, PUCHAR pucDestBuffer) +static inline ULONG RestoreSFParam(struct bcm_mini_adapter *Adapter, + ULONG ulAddrSFParamSet, PUCHAR pucDestBuffer) { UINT nBytesToRead = sizeof(struct bcm_connect_mgr_params); if (ulAddrSFParamSet == 0 || NULL == pucDestBuffer) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Got Param address as 0!!"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Got Param address as 0!!"); return 0; } ulAddrSFParamSet = ntohl(ulAddrSFParamSet); /* Read out the SF Param Set At the indicated Location */ - if (rdm(Adapter, ulAddrSFParamSet, (PUCHAR)pucDestBuffer, nBytesToRead) < 0) + if (rdm(Adapter, ulAddrSFParamSet,(PUCHAR)pucDestBuffer, nBytesToRead) < 0) return STATUS_FAILURE; return 1; -- cgit v1.2.3 From 500501fad67e14c30180c20dd77b17872e88efc7 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 23 May 2014 22:23:51 +0200 Subject: Staging: bcm: Replaced long member-accessing This patch replaces long object->member.member foo by variable useage. Increases the reading experience a lot by introducing only one variable (as it decreases the whoa-wall-of-text experience). Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 107 ++++++++++++++++++++++--------------------- 1 file changed, 55 insertions(+), 52 deletions(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index 377e68143886..644087cea851 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -1159,99 +1159,102 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) for (nIndex = 0; nIndex < nCurClassifierCnt; nIndex++) { struct bcm_convergence_types *psfCSType = NULL; + struct bcm_packet_class_rules *clsRule = NULL; + + psfCSType = &pstAddIndication->sfActiveSet.cConvergenceSLTypes[nIndex]; + clsRule = &psfCSType->cCPacketClassificationRule; - psfCSType = &pstAddIndication->sfActiveSet.cConvergenceSLTypes[nIndex]; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " CCPacketClassificationRuleSI====>"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ClassifierRulePriority: 0x%X ", - psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority); + clsRule->u8ClassifierRulePriority); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPTypeOfServiceLength: 0x%X ", - psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength); + clsRule->u8IPTypeOfServiceLength); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPTypeOfService[3]: 0x%X ,0x%X ,0x%X ", - psfCSType->cCPacketClassificationRule.u8IPTypeOfService[0], - psfCSType->cCPacketClassificationRule.u8IPTypeOfService[1], - psfCSType->cCPacketClassificationRule.u8IPTypeOfService[2]); + clsRule->u8IPTypeOfService[0], + clsRule->u8IPTypeOfService[1], + clsRule->u8IPTypeOfService[2]); for (uiLoopIndex = 0; uiLoopIndex < 1; uiLoopIndex++) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8Protocol: 0x%X ", psfCSType->cCPacketClassificationRule.u8Protocol); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8Protocol: 0x%X ", clsRule->u8Protocol); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddressLength: 0x%X ", - psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddressLength); + clsRule->u8IPMaskedSourceAddressLength); for (uiLoopIndex = 0; uiLoopIndex < 32; uiLoopIndex++) BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddress[32]: 0x%X ", - psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddress[uiLoopIndex]); + clsRule->u8IPMaskedSourceAddress[uiLoopIndex]); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPDestinationAddressLength: 0x%02X ", - psfCSType->cCPacketClassificationRule.u8IPDestinationAddressLength); + clsRule->u8IPDestinationAddressLength); for (uiLoopIndex = 0; uiLoopIndex < 32; uiLoopIndex++) BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPDestinationAddress[32]:0x%X ", - psfCSType->cCPacketClassificationRule.u8IPDestinationAddress[uiLoopIndex]); + clsRule->u8IPDestinationAddress[uiLoopIndex]); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ProtocolSourcePortRangeLength: 0x%X ", - psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRangeLength); + clsRule->u8ProtocolSourcePortRangeLength); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ProtocolSourcePortRange[4]: 0x%X ,0x%X ,0x%X ,0x%X ", - psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[0], - psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[1], - psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[2], - psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[3]); + clsRule->u8ProtocolSourcePortRange[0], + clsRule->u8ProtocolSourcePortRange[1], + clsRule->u8ProtocolSourcePortRange[2], + clsRule->u8ProtocolSourcePortRange[3]); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ProtocolDestPortRangeLength: 0x%X ", - psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRangeLength); + clsRule->u8ProtocolDestPortRangeLength); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ProtocolDestPortRange[4]: 0x%X ,0x%X ,0x%X ,0x%X ", - psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[0], - psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[1], - psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[2], - psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[3]); + clsRule->u8ProtocolDestPortRange[0], + clsRule->u8ProtocolDestPortRange[1], + clsRule->u8ProtocolDestPortRange[2], + clsRule->u8ProtocolDestPortRange[3]); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8EthernetDestMacAddressLength: 0x%X ", - psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength); + clsRule->u8EthernetDestMacAddressLength); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8EthernetDestMacAddress[6]: 0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X", - psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[0], - psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[1], - psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[2], - psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[3], - psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[4], - psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[5]); + clsRule->u8EthernetDestMacAddress[0], + clsRule->u8EthernetDestMacAddress[1], + clsRule->u8EthernetDestMacAddress[2], + clsRule->u8EthernetDestMacAddress[3], + clsRule->u8EthernetDestMacAddress[4], + clsRule->u8EthernetDestMacAddress[5]); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8EthernetSourceMACAddressLength: 0x%X ", - psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength); + clsRule->u8EthernetDestMacAddressLength); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddress[6]: 0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X", - psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[0], - psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[1], - psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[2], - psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[3], - psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[4], - psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[5]); + clsRule->u8EthernetSourceMACAddress[0], + clsRule->u8EthernetSourceMACAddress[1], + clsRule->u8EthernetSourceMACAddress[2], + clsRule->u8EthernetSourceMACAddress[3], + clsRule->u8EthernetSourceMACAddress[4], + clsRule->u8EthernetSourceMACAddress[5]); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8EthertypeLength: 0x%X ", - psfCSType->cCPacketClassificationRule.u8EthertypeLength); + clsRule->u8EthertypeLength); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8Ethertype[3]: 0x%X ,0x%X ,0x%X ", - psfCSType->cCPacketClassificationRule.u8Ethertype[0], - psfCSType->cCPacketClassificationRule.u8Ethertype[1], - psfCSType->cCPacketClassificationRule.u8Ethertype[2]); + clsRule->u8Ethertype[0], + clsRule->u8Ethertype[1], + clsRule->u8Ethertype[2]); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16UserPriority: 0x%X ", - psfCSType->cCPacketClassificationRule.u16UserPriority); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16VLANID: 0x%X ", psfCSType->cCPacketClassificationRule.u16VLANID); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8AssociatedPHSI: 0x%X ", psfCSType->cCPacketClassificationRule.u8AssociatedPHSI); + clsRule->u16UserPriority); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16VLANID: 0x%X ", clsRule->u16VLANID); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8AssociatedPHSI: 0x%X ", clsRule->u8AssociatedPHSI); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16PacketClassificationRuleIndex:0x%X ", - psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex); + clsRule->u16PacketClassificationRuleIndex); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8VendorSpecificClassifierParamLength:0x%X ", - psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParamLength); + clsRule->u8VendorSpecificClassifierParamLength); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8VendorSpecificClassifierParam[1]:0x%X ", - psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParam[0]); + clsRule->u8VendorSpecificClassifierParam[0]); #ifdef VERSION_D5 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPv6FlowLableLength: 0x%X ", - psfCSType->cCPacketClassificationRule.u8IPv6FlowLableLength); + clsRule->u8IPv6FlowLableLength); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPv6FlowLable[6]: 0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X ", - psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[0], - psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[1], - psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[2], - psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[3], - psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[4], - psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[5]); + clsRule->u8IPv6FlowLable[0], + clsRule->u8IPv6FlowLable[1], + clsRule->u8IPv6FlowLable[2], + clsRule->u8IPv6FlowLable[3], + clsRule->u8IPv6FlowLable[4], + clsRule->u8IPv6FlowLable[5]); #endif } -- cgit v1.2.3 From 5c2c68d01b6a4350f36445eb8ec72f8b96261bfb Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 23 May 2014 22:23:52 +0200 Subject: Staging: bcm: Shortened some lines in DumpCmControlPacker() Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 106 +++++++++++++++++++++++++++++++------------ 1 file changed, 78 insertions(+), 28 deletions(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index 644087cea851..89030cc2ef8f 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -1164,53 +1164,81 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) psfCSType = &pstAddIndication->sfActiveSet.cConvergenceSLTypes[nIndex]; clsRule = &psfCSType->cCPacketClassificationRule; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " CCPacketClassificationRuleSI====>"); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ClassifierRulePriority: 0x%X ", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, " CCPacketClassificationRuleSI====>"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, " u8ClassifierRulePriority: 0x%X ", clsRule->u8ClassifierRulePriority); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPTypeOfServiceLength: 0x%X ", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, " u8IPTypeOfServiceLength: 0x%X ", clsRule->u8IPTypeOfServiceLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPTypeOfService[3]: 0x%X ,0x%X ,0x%X ", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u8IPTypeOfService[3]: 0x%X ,0x%X ,0x%X ", clsRule->u8IPTypeOfService[0], clsRule->u8IPTypeOfService[1], clsRule->u8IPTypeOfService[2]); for (uiLoopIndex = 0; uiLoopIndex < 1; uiLoopIndex++) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8Protocol: 0x%X ", clsRule->u8Protocol); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u8Protocol: 0x%X ", + clsRule->u8Protocol); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddressLength: 0x%X ", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + "u8IPMaskedSourceAddressLength: 0x%X ", clsRule->u8IPMaskedSourceAddressLength); for (uiLoopIndex = 0; uiLoopIndex < 32; uiLoopIndex++) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddress[32]: 0x%X ", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + "u8IPMaskedSourceAddress[32]: 0x%X ", clsRule->u8IPMaskedSourceAddress[uiLoopIndex]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPDestinationAddressLength: 0x%02X ", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + "u8IPDestinationAddressLength: 0x%02X ", clsRule->u8IPDestinationAddressLength); for (uiLoopIndex = 0; uiLoopIndex < 32; uiLoopIndex++) - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPDestinationAddress[32]:0x%X ", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u8IPDestinationAddress[32]:0x%X ", clsRule->u8IPDestinationAddress[uiLoopIndex]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ProtocolSourcePortRangeLength: 0x%X ", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u8ProtocolSourcePortRangeLength: 0x%X ", clsRule->u8ProtocolSourcePortRangeLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ProtocolSourcePortRange[4]: 0x%X ,0x%X ,0x%X ,0x%X ", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u8ProtocolSourcePortRange[4]: 0x%X ,0x%X ,0x%X ,0x%X ", clsRule->u8ProtocolSourcePortRange[0], clsRule->u8ProtocolSourcePortRange[1], clsRule->u8ProtocolSourcePortRange[2], clsRule->u8ProtocolSourcePortRange[3]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ProtocolDestPortRangeLength: 0x%X ", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u8ProtocolDestPortRangeLength: 0x%X ", clsRule->u8ProtocolDestPortRangeLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ProtocolDestPortRange[4]: 0x%X ,0x%X ,0x%X ,0x%X ", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u8ProtocolDestPortRange[4]: 0x%X ,0x%X ,0x%X ,0x%X ", clsRule->u8ProtocolDestPortRange[0], clsRule->u8ProtocolDestPortRange[1], clsRule->u8ProtocolDestPortRange[2], clsRule->u8ProtocolDestPortRange[3]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8EthernetDestMacAddressLength: 0x%X ", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u8EthernetDestMacAddressLength: 0x%X ", clsRule->u8EthernetDestMacAddressLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8EthernetDestMacAddress[6]: 0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u8EthernetDestMacAddress[6]: 0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X", clsRule->u8EthernetDestMacAddress[0], clsRule->u8EthernetDestMacAddress[1], clsRule->u8EthernetDestMacAddress[2], @@ -1218,9 +1246,13 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) clsRule->u8EthernetDestMacAddress[4], clsRule->u8EthernetDestMacAddress[5]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8EthernetSourceMACAddressLength: 0x%X ", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u8EthernetSourceMACAddressLength: 0x%X ", clsRule->u8EthernetDestMacAddressLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddress[6]: 0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + "u8EthernetSourceMACAddress[6]: 0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X", clsRule->u8EthernetSourceMACAddress[0], clsRule->u8EthernetSourceMACAddress[1], clsRule->u8EthernetSourceMACAddress[2], @@ -1228,27 +1260,44 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) clsRule->u8EthernetSourceMACAddress[4], clsRule->u8EthernetSourceMACAddress[5]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8EthertypeLength: 0x%X ", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, " u8EthertypeLength: 0x%X ", clsRule->u8EthertypeLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8Ethertype[3]: 0x%X ,0x%X ,0x%X ", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u8Ethertype[3]: 0x%X ,0x%X ,0x%X ", clsRule->u8Ethertype[0], clsRule->u8Ethertype[1], clsRule->u8Ethertype[2]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16UserPriority: 0x%X ", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, " u16UserPriority: 0x%X ", clsRule->u16UserPriority); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16VLANID: 0x%X ", clsRule->u16VLANID); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8AssociatedPHSI: 0x%X ", clsRule->u8AssociatedPHSI); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16PacketClassificationRuleIndex:0x%X ", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, " u16VLANID: 0x%X ", + clsRule->u16VLANID); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, " u8AssociatedPHSI: 0x%X ", + clsRule->u8AssociatedPHSI); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u16PacketClassificationRuleIndex:0x%X ", clsRule->u16PacketClassificationRuleIndex); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8VendorSpecificClassifierParamLength:0x%X ", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u8VendorSpecificClassifierParamLength:0x%X ", clsRule->u8VendorSpecificClassifierParamLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8VendorSpecificClassifierParam[1]:0x%X ", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u8VendorSpecificClassifierParam[1]:0x%X ", clsRule->u8VendorSpecificClassifierParam[0]); #ifdef VERSION_D5 - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPv6FlowLableLength: 0x%X ", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, " u8IPv6FlowLableLength: 0x%X ", clsRule->u8IPv6FlowLableLength); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPv6FlowLable[6]: 0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X ", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, + DBG_LVL_ALL, + " u8IPv6FlowLable[6]: 0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X ", clsRule->u8IPv6FlowLable[0], clsRule->u8IPv6FlowLable[1], clsRule->u8IPv6FlowLable[2], @@ -1258,7 +1307,8 @@ static VOID DumpCmControlPacket(PVOID pvBuffer) #endif } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " bValid: 0x%X", pstAddIndication->sfActiveSet.bValid); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, + " bValid: 0x%X", pstAddIndication->sfActiveSet.bValid); } static inline ULONG RestoreSFParam(struct bcm_mini_adapter *Adapter, -- cgit v1.2.3 From efd2ee6d5afb46e9f228de6b6bf7f7357916a119 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 23 May 2014 22:23:53 +0200 Subject: Staging: bcm: Outsourced PHS rule applying This patch outsources the big PHS-rule-applying code chunk into a function. It also replaces member accessing by using variables. Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 170 +++++++++++++++++++++++++------------------ 1 file changed, 99 insertions(+), 71 deletions(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index 89030cc2ef8f..21074ae906fb 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -18,6 +18,14 @@ static void restore_endianess_of_pstClassifierEntry( struct bcm_classifier_rule *pstClassifierEntry, enum bcm_ipaddr_context eIpAddrContext); +static void apply_phs_rule_to_all_classifiers( + register struct bcm_mini_adapter *Adapter, + register UINT uiSearchRuleIndex, + USHORT uVCID, + struct bcm_phs_rule *sPhsRule, + struct bcm_phs_rules *cPhsRule, + struct bcm_add_indication_alt *pstAddIndication); + /************************************************************ * Function - SearchSfid * @@ -627,79 +635,12 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* cPhsRule.u8PHSI) { /* Apply This PHS Rule to all classifiers whose Associated PHSI Match */ - unsigned int uiClassifierIndex = 0; - if (pstAddIndication->u8Direction == UPLINK_DIR) { - for (uiClassifierIndex = 0; uiClassifierIndex < MAX_CLASSIFIERS; uiClassifierIndex++) { - if ((Adapter->astClassifierTable[uiClassifierIndex].bUsed) && - (Adapter->astClassifierTable[uiClassifierIndex].ulSFID == Adapter->PackInfo[uiSearchRuleIndex].ulSFID) && - (Adapter->astClassifierTable[uiClassifierIndex].u8AssociatedPHSI == psfCSType->cPhsRule.u8PHSI)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, - "Adding PHS Rule For Classifier: 0x%x cPhsRule.u8PHSI: 0x%x\n", - Adapter->astClassifierTable[uiClassifierIndex].uiClassifierRuleIndex, - psfCSType->cPhsRule.u8PHSI); - /* Update The PHS Rule for this classifier as Associated PHSI id defined */ - - /* Copy the PHS Rule */ - sPhsRule.u8PHSI = psfCSType->cPhsRule.u8PHSI; - sPhsRule.u8PHSFLength = psfCSType->cPhsRule.u8PHSFLength; - sPhsRule.u8PHSMLength = psfCSType->cPhsRule.u8PHSMLength; - sPhsRule.u8PHSS = psfCSType->cPhsRule.u8PHSS; - sPhsRule.u8PHSV = psfCSType->cPhsRule.u8PHSV; - memcpy(sPhsRule.u8PHSF, psfCSType->cPhsRule.u8PHSF, MAX_PHS_LENGTHS); - memcpy(sPhsRule.u8PHSM, psfCSType->cPhsRule.u8PHSM, MAX_PHS_LENGTHS); - sPhsRule.u8RefCnt = 0; - sPhsRule.bUnclassifiedPHSRule = false; - sPhsRule.PHSModifiedBytes = 0; - sPhsRule.PHSModifiedNumPackets = 0; - sPhsRule.PHSErrorNumPackets = 0; - - /* bPHSRuleAssociated = TRUE; */ - /* Store The PHS Rule for this classifier */ - - PhsUpdateClassifierRule( - &Adapter->stBCMPhsContext, - uVCID, - Adapter->astClassifierTable[uiClassifierIndex].uiClassifierRuleIndex, - &sPhsRule, - Adapter->astClassifierTable[uiClassifierIndex].u8AssociatedPHSI); - - /* Update PHS Rule For the Classifier */ - if (sPhsRule.u8PHSI) { - Adapter->astClassifierTable[uiClassifierIndex].u32PHSRuleID = sPhsRule.u8PHSI; - memcpy(&Adapter->astClassifierTable[uiClassifierIndex].sPhsRule, &sPhsRule, sizeof(struct bcm_phs_rule)); - } - } - } - } else { - /* Error PHS Rule specified in signaling could not be applied to any classifier */ - - /* Copy the PHS Rule */ - sPhsRule.u8PHSI = psfCSType->cPhsRule.u8PHSI; - sPhsRule.u8PHSFLength = psfCSType->cPhsRule.u8PHSFLength; - sPhsRule.u8PHSMLength = psfCSType->cPhsRule.u8PHSMLength; - sPhsRule.u8PHSS = psfCSType->cPhsRule.u8PHSS; - sPhsRule.u8PHSV = psfCSType->cPhsRule.u8PHSV; - memcpy(sPhsRule.u8PHSF, psfCSType->cPhsRule.u8PHSF, MAX_PHS_LENGTHS); - memcpy(sPhsRule.u8PHSM, psfCSType->cPhsRule.u8PHSM, MAX_PHS_LENGTHS); - sPhsRule.u8RefCnt = 0; - sPhsRule.bUnclassifiedPHSRule = TRUE; - sPhsRule.PHSModifiedBytes = 0; - sPhsRule.PHSModifiedNumPackets = 0; - sPhsRule.PHSErrorNumPackets = 0; - /* Store The PHS Rule for this classifier */ - - /* - * Passing the argument u8PHSI instead of clsid. Because for DL with no classifier rule, - * clsid will be zero hence we can't have multiple PHS rules for the same SF. - * To support multiple PHS rule, passing u8PHSI. - */ - PhsUpdateClassifierRule( - &Adapter->stBCMPhsContext, + apply_phs_rule_to_all_classifiers(Adapter, + uiSearchRuleIndex, uVCID, - sPhsRule.u8PHSI, &sPhsRule, - sPhsRule.u8PHSI); - } + &psfCSType->cPhsRule, + pstAddIndication); } break; } @@ -2070,3 +2011,90 @@ static void restore_endianess_of_pstClassifierEntry( } } } + +static void apply_phs_rule_to_all_classifiers( + register struct bcm_mini_adapter *Adapter, /* u8Direction == UPLINK_DIR) { + for (uiClassifierIndex = 0; uiClassifierIndex < MAX_CLASSIFIERS; uiClassifierIndex++) { + curr_classifier = + &Adapter->astClassifierTable[uiClassifierIndex]; + if ((curr_classifier->bUsed) && + (curr_classifier->ulSFID == Adapter->PackInfo[uiSearchRuleIndex].ulSFID) && + (curr_classifier->u8AssociatedPHSI == cPhsRule->u8PHSI)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Adding PHS Rule For Classifier: 0x%x cPhsRule.u8PHSI: 0x%x\n", + curr_classifier->uiClassifierRuleIndex, + cPhsRule->u8PHSI); + /* Update The PHS Rule for this classifier as Associated PHSI id defined */ + + /* Copy the PHS Rule */ + sPhsRule->u8PHSI = cPhsRule->u8PHSI; + sPhsRule->u8PHSFLength = cPhsRule->u8PHSFLength; + sPhsRule->u8PHSMLength = cPhsRule->u8PHSMLength; + sPhsRule->u8PHSS = cPhsRule->u8PHSS; + sPhsRule->u8PHSV = cPhsRule->u8PHSV; + memcpy(sPhsRule->u8PHSF, cPhsRule->u8PHSF, MAX_PHS_LENGTHS); + memcpy(sPhsRule->u8PHSM, cPhsRule->u8PHSM, MAX_PHS_LENGTHS); + sPhsRule->u8RefCnt = 0; + sPhsRule->bUnclassifiedPHSRule = false; + sPhsRule->PHSModifiedBytes = 0; + sPhsRule->PHSModifiedNumPackets = 0; + sPhsRule->PHSErrorNumPackets = 0; + + /* bPHSRuleAssociated = TRUE; */ + /* Store The PHS Rule for this classifier */ + + PhsUpdateClassifierRule( + &Adapter->stBCMPhsContext, + uVCID, + curr_classifier->uiClassifierRuleIndex, + sPhsRule, + curr_classifier->u8AssociatedPHSI); + + /* Update PHS Rule For the Classifier */ + if (sPhsRule->u8PHSI) { + curr_classifier->u32PHSRuleID = sPhsRule->u8PHSI; + memcpy(&curr_classifier->sPhsRule, sPhsRule, sizeof(struct bcm_phs_rule)); + } + } + } + } else { + /* Error PHS Rule specified in signaling could not be applied to any classifier */ + + /* Copy the PHS Rule */ + sPhsRule->u8PHSI = cPhsRule->u8PHSI; + sPhsRule->u8PHSFLength = cPhsRule->u8PHSFLength; + sPhsRule->u8PHSMLength = cPhsRule->u8PHSMLength; + sPhsRule->u8PHSS = cPhsRule->u8PHSS; + sPhsRule->u8PHSV = cPhsRule->u8PHSV; + memcpy(sPhsRule->u8PHSF, cPhsRule->u8PHSF, MAX_PHS_LENGTHS); + memcpy(sPhsRule->u8PHSM, cPhsRule->u8PHSM, MAX_PHS_LENGTHS); + sPhsRule->u8RefCnt = 0; + sPhsRule->bUnclassifiedPHSRule = TRUE; + sPhsRule->PHSModifiedBytes = 0; + sPhsRule->PHSModifiedNumPackets = 0; + sPhsRule->PHSErrorNumPackets = 0; + /* Store The PHS Rule for this classifier */ + + /* + * Passing the argument u8PHSI instead of clsid. Because for DL with no classifier rule, + * clsid will be zero hence we can't have multiple PHS rules for the same SF. + * To support multiple PHS rule, passing u8PHSI. + */ + PhsUpdateClassifierRule( + &Adapter->stBCMPhsContext, + uVCID, + sPhsRule->u8PHSI, + sPhsRule, + sPhsRule->u8PHSI); + } +} -- cgit v1.2.3 From 7d4e9104628d477bce0c7eb4bc4402367501051f Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 23 May 2014 22:23:54 +0200 Subject: Staging: bcm: Replaced struct member accessing with variable Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 96 ++++++++++++++++++++++---------------------- 1 file changed, 49 insertions(+), 47 deletions(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index 21074ae906fb..d5e2ac2df21b 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -447,10 +447,12 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* PackInfo[uiSearchRuleIndex].usVCID_Value; + struct bcm_packet_info *curr_packinfo = + &Adapter->PackInfo[uiSearchRuleIndex]; + USHORT uVCID = curr_packinfo->usVCID_Value; UINT UGIValue = 0; - Adapter->PackInfo[uiSearchRuleIndex].bValid = TRUE; + curr_packinfo->bValid = TRUE; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Search Rule Index = %d\n", uiSearchRuleIndex); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "%s: SFID= %x ", __func__, ntohl(psfLocalSet->u32SFID)); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Updating Queue %d", uiSearchRuleIndex); @@ -459,65 +461,65 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* PackInfo[uiSearchRuleIndex].bIPCSSupport = 0; - Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = 0; + curr_packinfo->bIPCSSupport = 0; + curr_packinfo->bEthCSSupport = 0; /* Enable IP/ETh CS Support As Required */ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "CopyToAdapter : u8CSSpecification : %X\n", psfLocalSet->u8CSSpecification); switch (psfLocalSet->u8CSSpecification) { case eCSPacketIPV4: - Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV4_CS; + curr_packinfo->bIPCSSupport = IPV4_CS; break; case eCSPacketIPV6: - Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV6_CS; + curr_packinfo->bIPCSSupport = IPV6_CS; break; case eCS802_3PacketEthernet: case eCS802_1QPacketVLAN: - Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = ETH_CS_802_3; + curr_packinfo->bEthCSSupport = ETH_CS_802_3; break; case eCSPacketIPV4Over802_1QVLAN: case eCSPacketIPV4Over802_3Ethernet: - Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV4_CS; - Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = ETH_CS_802_3; + curr_packinfo->bIPCSSupport = IPV4_CS; + curr_packinfo->bEthCSSupport = ETH_CS_802_3; break; case eCSPacketIPV6Over802_1QVLAN: case eCSPacketIPV6Over802_3Ethernet: - Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV6_CS; - Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = ETH_CS_802_3; + curr_packinfo->bIPCSSupport = IPV6_CS; + curr_packinfo->bEthCSSupport = ETH_CS_802_3; break; default: BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Error in value of CS Classification.. setting default to IP CS\n"); - Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV4_CS; + curr_packinfo->bIPCSSupport = IPV4_CS; break; } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "CopyToAdapter : Queue No : %X ETH CS Support : %X , IP CS Support : %X\n", uiSearchRuleIndex, - Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport, - Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport); + curr_packinfo->bEthCSSupport, + curr_packinfo->bIPCSSupport); /* Store IP Version used */ /* Get The Version Of IP used (IPv6 or IPv4) from CSSpecification field of SF */ - if (Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport == IPV6_CS) - Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion = IPV6; + if (curr_packinfo->bIPCSSupport == IPV6_CS) + curr_packinfo->ucIpVersion = IPV6; else - Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion = IPV4; + curr_packinfo->ucIpVersion = IPV4; /* To ensure that the ETH CS code doesn't gets executed if the BS doesn't supports ETH CS */ if (!Adapter->bETHCSEnabled) - Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = 0; + curr_packinfo->bEthCSSupport = 0; if (psfLocalSet->u8ServiceClassNameLength > 0 && psfLocalSet->u8ServiceClassNameLength < 32) - memcpy(Adapter->PackInfo[uiSearchRuleIndex].ucServiceClassName, psfLocalSet->u8ServiceClassName, psfLocalSet->u8ServiceClassNameLength); + memcpy(curr_packinfo->ucServiceClassName, psfLocalSet->u8ServiceClassName, psfLocalSet->u8ServiceClassNameLength); - Adapter->PackInfo[uiSearchRuleIndex].u8QueueType = psfLocalSet->u8ServiceFlowSchedulingType; + curr_packinfo->u8QueueType = psfLocalSet->u8ServiceFlowSchedulingType; - if (Adapter->PackInfo[uiSearchRuleIndex].u8QueueType == BE && Adapter->PackInfo[uiSearchRuleIndex].ucDirection) + if (curr_packinfo->u8QueueType == BE && curr_packinfo->ucDirection) Adapter->usBestEffortQueueIndex = uiSearchRuleIndex; - Adapter->PackInfo[uiSearchRuleIndex].ulSFID = ntohl(psfLocalSet->u32SFID); + curr_packinfo->ulSFID = ntohl(psfLocalSet->u32SFID); - Adapter->PackInfo[uiSearchRuleIndex].u8TrafficPriority = psfLocalSet->u8TrafficPriority; + curr_packinfo->u8TrafficPriority = psfLocalSet->u8TrafficPriority; /* copy all the classifier in the Service Flow param structure */ for (i = 0; i < psfLocalSet->u8TotalClassifiers; i++) { @@ -526,10 +528,10 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* cCPacketClassificationRule.u8ClassifierRulePriority) - Adapter->PackInfo[uiSearchRuleIndex].bClassifierPriority = TRUE; + curr_packinfo->bClassifierPriority = TRUE; if (psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority) - Adapter->PackInfo[uiSearchRuleIndex].bClassifierPriority = TRUE; + curr_packinfo->bClassifierPriority = TRUE; if (ucDsxType == DSA_ACK) { eClassifierAction = eAddClassifier; @@ -648,20 +650,20 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* u32MaxSustainedTrafficRate == 0) { /* No Rate Limit . Set Max Sustained Traffic Rate to Maximum */ - Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate = WIMAX_MAX_ALLOWED_RATE; + curr_packinfo->uiMaxAllowedRate = WIMAX_MAX_ALLOWED_RATE; } else if (ntohl(psfLocalSet->u32MaxSustainedTrafficRate) > WIMAX_MAX_ALLOWED_RATE) { /* Too large Allowed Rate specified. Limiting to Wi Max Allowed rate */ - Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate = WIMAX_MAX_ALLOWED_RATE; + curr_packinfo->uiMaxAllowedRate = WIMAX_MAX_ALLOWED_RATE; } else { - Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate = ntohl(psfLocalSet->u32MaxSustainedTrafficRate); + curr_packinfo->uiMaxAllowedRate = ntohl(psfLocalSet->u32MaxSustainedTrafficRate); } - Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency = ntohl(psfLocalSet->u32MaximumLatency); - if (Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency == 0) /* 0 should be treated as infinite */ - Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency = MAX_LATENCY_ALLOWED; + curr_packinfo->uiMaxLatency = ntohl(psfLocalSet->u32MaximumLatency); + if (curr_packinfo->uiMaxLatency == 0) /* 0 should be treated as infinite */ + curr_packinfo->uiMaxLatency = MAX_LATENCY_ALLOWED; - if ((Adapter->PackInfo[uiSearchRuleIndex].u8QueueType == ERTPS || - Adapter->PackInfo[uiSearchRuleIndex].u8QueueType == UGS)) + if ((curr_packinfo->u8QueueType == ERTPS || + curr_packinfo->u8QueueType == UGS)) UGIValue = ntohs(psfLocalSet->u16UnsolicitedGrantInterval); if (UGIValue == 0) @@ -673,42 +675,42 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* PackInfo[uiSearchRuleIndex].uiMaxBucketSize = - (DEFAULT_UGI_FACTOR*Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate*UGIValue)/1000; + curr_packinfo->uiMaxBucketSize = + (DEFAULT_UGI_FACTOR*curr_packinfo->uiMaxAllowedRate*UGIValue)/1000; - if (Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize < WIMAX_MAX_MTU*8) { + if (curr_packinfo->uiMaxBucketSize < WIMAX_MAX_MTU*8) { UINT UGIFactor = 0; /* Special Handling to ensure the biggest size of packet can go out from host to FW as follows: * 1. Any packet from Host to FW can go out in different packet size. * 2. So in case the Bucket count is smaller than MTU, the packets of size (Size > TokenCount), will get dropped. * 3. We can allow packets of MaxSize from Host->FW that can go out from FW in multiple SDUs by fragmentation at Wimax Layer */ - UGIFactor = (Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency/UGIValue + 1); + UGIFactor = (curr_packinfo->uiMaxLatency/UGIValue + 1); if (UGIFactor > DEFAULT_UGI_FACTOR) - Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize = - (UGIFactor*Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate*UGIValue)/1000; + curr_packinfo->uiMaxBucketSize = + (UGIFactor*curr_packinfo->uiMaxAllowedRate*UGIValue)/1000; - if (Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize > WIMAX_MAX_MTU*8) - Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize = WIMAX_MAX_MTU*8; + if (curr_packinfo->uiMaxBucketSize > WIMAX_MAX_MTU*8) + curr_packinfo->uiMaxBucketSize = WIMAX_MAX_MTU*8; } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "LAT: %d, UGI: %d\n", Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency, UGIValue); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "LAT: %d, UGI: %d\n", curr_packinfo->uiMaxLatency, UGIValue); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "uiMaxAllowedRate: 0x%x, u32MaxSustainedTrafficRate: 0x%x ,uiMaxBucketSize: 0x%x", - Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate, + curr_packinfo->uiMaxAllowedRate, ntohl(psfLocalSet->u32MaxSustainedTrafficRate), - Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize); + curr_packinfo->uiMaxBucketSize); /* copy the extended SF Parameters to Support MIBS */ CopyMIBSExtendedSFParameters(Adapter, psfLocalSet, uiSearchRuleIndex); /* store header suppression enabled flag per SF */ - Adapter->PackInfo[uiSearchRuleIndex].bHeaderSuppressionEnabled = + curr_packinfo->bHeaderSuppressionEnabled = !(psfLocalSet->u8RequesttransmissionPolicy & MASK_DISABLE_HEADER_SUPPRESSION); - kfree(Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication); - Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication = pstAddIndication; + kfree(curr_packinfo->pstSFIndication); + curr_packinfo->pstSFIndication = pstAddIndication; /* Re Sort the SF list in PackInfo according to Traffic Priority */ SortPackInfo(Adapter); -- cgit v1.2.3 From ad9af0801d2bd7dfe1f928526ac647212cb714c1 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 23 May 2014 22:23:55 +0200 Subject: Staging: bcm: Shortened lines in CopyToAdapter() Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 97 ++++++++++++++++++++++++++++++++------------ 1 file changed, 70 insertions(+), 27 deletions(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index d5e2ac2df21b..a13f2adbadb2 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -453,9 +453,12 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* bValid = TRUE; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Search Rule Index = %d\n", uiSearchRuleIndex); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "%s: SFID= %x ", __func__, ntohl(psfLocalSet->u32SFID)); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Updating Queue %d", uiSearchRuleIndex); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Search Rule Index = %d\n", uiSearchRuleIndex); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "%s: SFID= %x ", __func__, ntohl(psfLocalSet->u32SFID)); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Updating Queue %d", uiSearchRuleIndex); ulSFID = ntohl(psfLocalSet->u32SFID); /* Store IP Version used */ @@ -465,7 +468,9 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* bEthCSSupport = 0; /* Enable IP/ETh CS Support As Required */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "CopyToAdapter : u8CSSpecification : %X\n", psfLocalSet->u8CSSpecification); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "CopyToAdapter : u8CSSpecification : %X\n", + psfLocalSet->u8CSSpecification); switch (psfLocalSet->u8CSSpecification) { case eCSPacketIPV4: curr_packinfo->bIPCSSupport = IPV4_CS; @@ -488,12 +493,14 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* bEthCSSupport = ETH_CS_802_3; break; default: - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Error in value of CS Classification.. setting default to IP CS\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Error in value of CS Classification.. setting default to IP CS\n"); curr_packinfo->bIPCSSupport = IPV4_CS; break; } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "CopyToAdapter : Queue No : %X ETH CS Support : %X , IP CS Support : %X\n", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "CopyToAdapter : Queue No : %X ETH CS Support : %X , IP CS Support : %X\n", uiSearchRuleIndex, curr_packinfo->bEthCSSupport, curr_packinfo->bIPCSSupport); @@ -510,7 +517,9 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* bEthCSSupport = 0; if (psfLocalSet->u8ServiceClassNameLength > 0 && psfLocalSet->u8ServiceClassNameLength < 32) - memcpy(curr_packinfo->ucServiceClassName, psfLocalSet->u8ServiceClassName, psfLocalSet->u8ServiceClassNameLength); + memcpy(curr_packinfo->ucServiceClassName, + psfLocalSet->u8ServiceClassName, + psfLocalSet->u8ServiceClassNameLength); curr_packinfo->u8QueueType = psfLocalSet->u8ServiceFlowSchedulingType; @@ -523,9 +532,11 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* u8TotalClassifiers; i++) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Classifier index =%d", i); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Classifier index =%d", i); psfCSType = &psfLocalSet->cConvergenceSLTypes[i]; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Classifier index =%d", i); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Classifier index =%d", i); if (psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority) curr_packinfo->bClassifierPriority = TRUE; @@ -557,20 +568,30 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* MAX_CLASSIFIERS) { nClassifierIndex = SearchFreeClsid(Adapter); if (nClassifierIndex > MAX_CLASSIFIERS) { /* Failed To get a free Entry */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Error Failed To get a free Classifier Entry"); + BCM_DEBUG_PRINT(Adapter, + DBG_TYPE_OTHERS, + CONN_MSG, + DBG_LVL_ALL, + "Error Failed To get a free Classifier Entry"); break; } /* Copy the Classifier Rule for this service flow into our Classifier table maintained per SF. */ - CopyClassifierRuleToSF(Adapter, psfCSType, uiSearchRuleIndex, nClassifierIndex); + CopyClassifierRuleToSF(Adapter, psfCSType, + uiSearchRuleIndex, + nClassifierIndex); } else { /* This Classifier Already Exists and it is invalid to Add Classifier with existing PCRI */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + CONN_MSG, + DBG_LVL_ALL, "CopyToAdapter: Error The Specified Classifier Already Exists and attempted To Add Classifier with Same PCRI : 0x%x\n", u16PacketClassificationRuleIndex); } @@ -578,27 +599,35 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* MAX_CLASSIFIERS) { /* Failed To search the classifier */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Error Search for Classifier To be replaced failed"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + CONN_MSG, DBG_LVL_ALL, + "Error Search for Classifier To be replaced failed"); break; } /* Copy the Classifier Rule for this service flow into our Classifier table maintained per SF. */ - CopyClassifierRuleToSF(Adapter, psfCSType, uiSearchRuleIndex, nClassifierIndex); + CopyClassifierRuleToSF(Adapter, psfCSType, + uiSearchRuleIndex, nClassifierIndex); break; case eDeleteClassifier: /* Get the Classifier Index From Classifier table for this SF and replace existing Classifier */ /* with the new classifier Contained in this message */ - nClassifierIndex = SearchClsid(Adapter, ulSFID, u16PacketClassificationRuleIndex); + nClassifierIndex = SearchClsid(Adapter, ulSFID, + u16PacketClassificationRuleIndex); if (nClassifierIndex > MAX_CLASSIFIERS) { /* Failed To search the classifier */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Error Search for Classifier To be deleted failed"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + CONN_MSG, DBG_LVL_ALL, + "Error Search for Classifier To be deleted failed"); break; } /* Delete This classifier */ - DeleteClassifierRuleFromSF(Adapter, uiSearchRuleIndex, nClassifierIndex); + DeleteClassifierRuleFromSF(Adapter, uiSearchRuleIndex, + nClassifierIndex); break; default: /* Invalid Action for classifier */ @@ -609,20 +638,29 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* u8TotalClassifiers; i++) { psfCSType = &psfLocalSet->cConvergenceSLTypes[i]; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "psfCSType->u8PhsDSCAction : 0x%x\n", psfCSType->u8PhsDSCAction); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "psfCSType->u8PhsDSCAction : 0x%x\n", + psfCSType->u8PhsDSCAction); switch (psfCSType->u8PhsDSCAction) { case eDeleteAllPHSRules: - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Deleting All PHS Rules For VCID: 0x%X\n", uVCID); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, + DBG_LVL_ALL, + "Deleting All PHS Rules For VCID: 0x%X\n", + uVCID); /* Delete All the PHS rules for this Service flow */ PhsDeleteSFRules(&Adapter->stBCMPhsContext, uVCID); break; case eDeletePHSRule: - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "PHS DSC Action = Delete PHS Rule\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, + DBG_LVL_ALL, + "PHS DSC Action = Delete PHS Rule\n"); if (psfCSType->cPhsRule.u8PHSI) - PhsDeletePHSRule(&Adapter->stBCMPhsContext, uVCID, psfCSType->cCPacketClassificationRule.u8AssociatedPHSI); + PhsDeletePHSRule(&Adapter->stBCMPhsContext, + uVCID, + psfCSType->cCPacketClassificationRule.u8AssociatedPHSI); break; default: @@ -655,7 +693,8 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* uiMaxAllowedRate = WIMAX_MAX_ALLOWED_RATE; } else { - curr_packinfo->uiMaxAllowedRate = ntohl(psfLocalSet->u32MaxSustainedTrafficRate); + curr_packinfo->uiMaxAllowedRate = + ntohl(psfLocalSet->u32MaxSustainedTrafficRate); } curr_packinfo->uiMaxLatency = ntohl(psfLocalSet->u32MaximumLatency); @@ -695,8 +734,11 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* uiMaxBucketSize = WIMAX_MAX_MTU*8; } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "LAT: %d, UGI: %d\n", curr_packinfo->uiMaxLatency, UGIValue); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "uiMaxAllowedRate: 0x%x, u32MaxSustainedTrafficRate: 0x%x ,uiMaxBucketSize: 0x%x", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "LAT: %d, UGI: %d\n", curr_packinfo->uiMaxLatency, + UGIValue); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "uiMaxAllowedRate: 0x%x, u32MaxSustainedTrafficRate: 0x%x ,uiMaxBucketSize: 0x%x", curr_packinfo->uiMaxAllowedRate, ntohl(psfLocalSet->u32MaxSustainedTrafficRate), curr_packinfo->uiMaxBucketSize); @@ -720,7 +762,8 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* stBCMPhsContext); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "%s <=====", __func__); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "%s <=====", __func__); } /*********************************************************************** -- cgit v1.2.3 From a03420b622f74771fec9359e565f6c7a52176ab4 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 23 May 2014 22:23:56 +0200 Subject: Staging: bcm: Shortened line in DeleteAllClassifiersForSF() Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index a13f2adbadb2..aa121b7c8798 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -401,7 +401,8 @@ static inline VOID DeleteClassifierRuleFromSF(struct bcm_mini_adapter *Adapter, /* * @ingroup ctrl_pkt_functions */ -VOID DeleteAllClassifiersForSF(struct bcm_mini_adapter *Adapter, UINT uiSearchRuleIndex) +VOID DeleteAllClassifiersForSF(struct bcm_mini_adapter *Adapter, + UINT uiSearchRuleIndex) { struct bcm_classifier_rule *pstClassifierEntry = NULL; int i; @@ -420,7 +421,8 @@ VOID DeleteAllClassifiersForSF(struct bcm_mini_adapter *Adapter, UINT uiSearchRu pstClassifierEntry = &Adapter->astClassifierTable[i]; if (pstClassifierEntry->bUsed) - DeleteClassifierRuleFromSF(Adapter, uiSearchRuleIndex, i); + DeleteClassifierRuleFromSF(Adapter, + uiSearchRuleIndex, i); } } -- cgit v1.2.3 From e8a94477801f49655812e8a0c711dd24ca2525ff Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 23 May 2014 22:23:57 +0200 Subject: Staging: bcm: Shortened lines in DeleteClassifierRuleFromSF() Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index aa121b7c8798..918661937f1e 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -370,7 +370,8 @@ static inline VOID CopyClassifierRuleToSF(struct bcm_mini_adapter *Adapter, stru /* * @ingroup ctrl_pkt_functions */ -static inline VOID DeleteClassifierRuleFromSF(struct bcm_mini_adapter *Adapter, UINT uiSearchRuleIndex, UINT nClassifierIndex) +static inline VOID DeleteClassifierRuleFromSF(struct bcm_mini_adapter *Adapter, + UINT uiSearchRuleIndex, UINT nClassifierIndex) { struct bcm_classifier_rule *pstClassifierEntry = NULL; B_UINT16 u16PacketClassificationRuleIndex; @@ -386,15 +387,18 @@ static inline VOID DeleteClassifierRuleFromSF(struct bcm_mini_adapter *Adapter, if (usVCID == 0) return; - u16PacketClassificationRuleIndex = Adapter->astClassifierTable[nClassifierIndex].uiClassifierRuleIndex; + u16PacketClassificationRuleIndex = + Adapter->astClassifierTable[nClassifierIndex].uiClassifierRuleIndex; pstClassifierEntry = &Adapter->astClassifierTable[nClassifierIndex]; if (pstClassifierEntry) { pstClassifierEntry->bUsed = false; pstClassifierEntry->uiClassifierRuleIndex = 0; - memset(pstClassifierEntry, 0, sizeof(struct bcm_classifier_rule)); + memset(pstClassifierEntry, 0, + sizeof(struct bcm_classifier_rule)); /* Delete the PHS Rule for this classifier */ - PhsDeleteClassifierRule(&Adapter->stBCMPhsContext, usVCID, u16PacketClassificationRuleIndex); + PhsDeleteClassifierRule(&Adapter->stBCMPhsContext, usVCID, + u16PacketClassificationRuleIndex); } } -- cgit v1.2.3 From 732f1eee33e5f1322a3c3cef8cdd31593698e796 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 23 May 2014 22:23:58 +0200 Subject: Staging: bcm: Replaced member accessing with variable Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 77 +++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index 918661937f1e..20e41742d4fe 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -249,12 +249,15 @@ static inline VOID CopyClassifierRuleToSF(struct bcm_mini_adapter *Adapter, stru /* UCHAR ucProtocolLength=0; */ /* ULONG ulPhsStatus; */ + struct bcm_packet_class_rules *pack_class_rule = + &psfCSType->cCPacketClassificationRule; + if (Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value == 0 || nClassifierIndex > (MAX_CLASSIFIERS-1)) return; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Storing Classifier Rule Index : %X", - ntohs(psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex)); + ntohs(pack_class_rule->u16PacketClassificationRuleIndex)); if (nClassifierIndex > MAX_CLASSIFIERS-1) return; @@ -265,14 +268,14 @@ static inline VOID CopyClassifierRuleToSF(struct bcm_mini_adapter *Adapter, stru pstClassifierEntry->bIpv6Protocol = (Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion == IPV6) ? TRUE : false; /* Destinaiton Port */ - pstClassifierEntry->ucDestPortRangeLength = psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRangeLength / 4; + pstClassifierEntry->ucDestPortRangeLength = pack_class_rule->u8ProtocolDestPortRangeLength / 4; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Destination Port Range Length:0x%X ", pstClassifierEntry->ucDestPortRangeLength); - if (psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRangeLength <= MAX_PORT_RANGE) { + if (pack_class_rule->u8ProtocolDestPortRangeLength <= MAX_PORT_RANGE) { for (i = 0; i < (pstClassifierEntry->ucDestPortRangeLength); i++) { - pstClassifierEntry->usDestPortRangeLo[i] = *((PUSHORT)(psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange+i)); + pstClassifierEntry->usDestPortRangeLo[i] = *((PUSHORT)(pack_class_rule->u8ProtocolDestPortRange+i)); pstClassifierEntry->usDestPortRangeHi[i] = - *((PUSHORT)(psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange+2+i)); + *((PUSHORT)(pack_class_rule->u8ProtocolDestPortRange+2+i)); pstClassifierEntry->usDestPortRangeLo[i] = ntohs(pstClassifierEntry->usDestPortRangeLo[i]); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Destination Port Range Lo:0x%X ", pstClassifierEntry->usDestPortRangeLo[i]); @@ -284,15 +287,15 @@ static inline VOID CopyClassifierRuleToSF(struct bcm_mini_adapter *Adapter, stru /* Source Port */ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Source Port Range Length:0x%X ", - psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRangeLength); - if (psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRangeLength <= MAX_PORT_RANGE) { - pstClassifierEntry->ucSrcPortRangeLength = psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRangeLength/4; + pack_class_rule->u8ProtocolSourcePortRangeLength); + if (pack_class_rule->u8ProtocolSourcePortRangeLength <= MAX_PORT_RANGE) { + pstClassifierEntry->ucSrcPortRangeLength = pack_class_rule->u8ProtocolSourcePortRangeLength/4; for (i = 0; i < (pstClassifierEntry->ucSrcPortRangeLength); i++) { pstClassifierEntry->usSrcPortRangeLo[i] = - *((PUSHORT)(psfCSType->cCPacketClassificationRule. + *((PUSHORT)(pack_class_rule-> u8ProtocolSourcePortRange+i)); pstClassifierEntry->usSrcPortRangeHi[i] = - *((PUSHORT)(psfCSType->cCPacketClassificationRule. + *((PUSHORT)(pack_class_rule-> u8ProtocolSourcePortRange+2+i)); pstClassifierEntry->usSrcPortRangeLo[i] = ntohs(pstClassifierEntry->usSrcPortRangeLo[i]); @@ -304,8 +307,8 @@ static inline VOID CopyClassifierRuleToSF(struct bcm_mini_adapter *Adapter, stru /* Destination Ip Address and Mask */ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Ip Destination Parameters : "); CopyIpAddrToClassifier(pstClassifierEntry, - psfCSType->cCPacketClassificationRule.u8IPDestinationAddressLength, - psfCSType->cCPacketClassificationRule.u8IPDestinationAddress, + pack_class_rule->u8IPDestinationAddressLength, + pack_class_rule->u8IPDestinationAddress, (Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion == IPV6) ? TRUE : false, eDestIpAddress); @@ -313,33 +316,33 @@ static inline VOID CopyClassifierRuleToSF(struct bcm_mini_adapter *Adapter, stru BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Ip Source Parameters : "); CopyIpAddrToClassifier(pstClassifierEntry, - psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddressLength, - psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddress, + pack_class_rule->u8IPMaskedSourceAddressLength, + pack_class_rule->u8IPMaskedSourceAddress, (Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion == IPV6) ? TRUE : false, eSrcIpAddress); /* TOS */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "TOS Length:0x%X ", psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength); - if (psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength == 3) { - pstClassifierEntry->ucIPTypeOfServiceLength = psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength; - pstClassifierEntry->ucTosLow = psfCSType->cCPacketClassificationRule.u8IPTypeOfService[0]; - pstClassifierEntry->ucTosHigh = psfCSType->cCPacketClassificationRule.u8IPTypeOfService[1]; - pstClassifierEntry->ucTosMask = psfCSType->cCPacketClassificationRule.u8IPTypeOfService[2]; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "TOS Length:0x%X ", pack_class_rule->u8IPTypeOfServiceLength); + if (pack_class_rule->u8IPTypeOfServiceLength == 3) { + pstClassifierEntry->ucIPTypeOfServiceLength = pack_class_rule->u8IPTypeOfServiceLength; + pstClassifierEntry->ucTosLow = pack_class_rule->u8IPTypeOfService[0]; + pstClassifierEntry->ucTosHigh = pack_class_rule->u8IPTypeOfService[1]; + pstClassifierEntry->ucTosMask = pack_class_rule->u8IPTypeOfService[2]; pstClassifierEntry->bTOSValid = TRUE; } - if (psfCSType->cCPacketClassificationRule.u8Protocol == 0) { + if (pack_class_rule->u8Protocol == 0) { /* we didn't get protocol field filled in by the BS */ pstClassifierEntry->ucProtocolLength = 0; } else { pstClassifierEntry->ucProtocolLength = 1; /* 1 valid protocol */ } - pstClassifierEntry->ucProtocol[0] = psfCSType->cCPacketClassificationRule.u8Protocol; - pstClassifierEntry->u8ClassifierRulePriority = psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority; + pstClassifierEntry->ucProtocol[0] = pack_class_rule->u8Protocol; + pstClassifierEntry->u8ClassifierRulePriority = pack_class_rule->u8ClassifierRulePriority; /* store the classifier rule ID and set this classifier entry as valid */ pstClassifierEntry->ucDirection = Adapter->PackInfo[uiSearchRuleIndex].ucDirection; - pstClassifierEntry->uiClassifierRuleIndex = ntohs(psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex); + pstClassifierEntry->uiClassifierRuleIndex = ntohs(pack_class_rule->u16PacketClassificationRuleIndex); pstClassifierEntry->usVCID_Value = Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value; pstClassifierEntry->ulSFID = Adapter->PackInfo[uiSearchRuleIndex].ulSFID; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Search Index %d Dir: %d, Index: %d, Vcid: %d\n", @@ -347,21 +350,21 @@ static inline VOID CopyClassifierRuleToSF(struct bcm_mini_adapter *Adapter, stru pstClassifierEntry->uiClassifierRuleIndex, pstClassifierEntry->usVCID_Value); - if (psfCSType->cCPacketClassificationRule.u8AssociatedPHSI) - pstClassifierEntry->u8AssociatedPHSI = psfCSType->cCPacketClassificationRule.u8AssociatedPHSI; + if (pack_class_rule->u8AssociatedPHSI) + pstClassifierEntry->u8AssociatedPHSI = pack_class_rule->u8AssociatedPHSI; /* Copy ETH CS Parameters */ - pstClassifierEntry->ucEthCSSrcMACLen = (psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddressLength); - memcpy(pstClassifierEntry->au8EThCSSrcMAC, psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress, MAC_ADDRESS_SIZE); - memcpy(pstClassifierEntry->au8EThCSSrcMACMask, psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress + MAC_ADDRESS_SIZE, MAC_ADDRESS_SIZE); - pstClassifierEntry->ucEthCSDestMACLen = (psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength); - memcpy(pstClassifierEntry->au8EThCSDestMAC, psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress, MAC_ADDRESS_SIZE); - memcpy(pstClassifierEntry->au8EThCSDestMACMask, psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress + MAC_ADDRESS_SIZE, MAC_ADDRESS_SIZE); - pstClassifierEntry->ucEtherTypeLen = (psfCSType->cCPacketClassificationRule.u8EthertypeLength); - memcpy(pstClassifierEntry->au8EthCSEtherType, psfCSType->cCPacketClassificationRule.u8Ethertype, NUM_ETHERTYPE_BYTES); - memcpy(pstClassifierEntry->usUserPriority, &psfCSType->cCPacketClassificationRule.u16UserPriority, 2); - pstClassifierEntry->usVLANID = ntohs(psfCSType->cCPacketClassificationRule.u16VLANID); - pstClassifierEntry->usValidityBitMap = ntohs(psfCSType->cCPacketClassificationRule.u16ValidityBitMap); + pstClassifierEntry->ucEthCSSrcMACLen = (pack_class_rule->u8EthernetSourceMACAddressLength); + memcpy(pstClassifierEntry->au8EThCSSrcMAC, pack_class_rule->u8EthernetSourceMACAddress, MAC_ADDRESS_SIZE); + memcpy(pstClassifierEntry->au8EThCSSrcMACMask, pack_class_rule->u8EthernetSourceMACAddress + MAC_ADDRESS_SIZE, MAC_ADDRESS_SIZE); + pstClassifierEntry->ucEthCSDestMACLen = (pack_class_rule->u8EthernetDestMacAddressLength); + memcpy(pstClassifierEntry->au8EThCSDestMAC, pack_class_rule->u8EthernetDestMacAddress, MAC_ADDRESS_SIZE); + memcpy(pstClassifierEntry->au8EThCSDestMACMask, pack_class_rule->u8EthernetDestMacAddress + MAC_ADDRESS_SIZE, MAC_ADDRESS_SIZE); + pstClassifierEntry->ucEtherTypeLen = (pack_class_rule->u8EthertypeLength); + memcpy(pstClassifierEntry->au8EthCSEtherType, pack_class_rule->u8Ethertype, NUM_ETHERTYPE_BYTES); + memcpy(pstClassifierEntry->usUserPriority, &pack_class_rule->u16UserPriority, 2); + pstClassifierEntry->usVLANID = ntohs(pack_class_rule->u16VLANID); + pstClassifierEntry->usValidityBitMap = ntohs(pack_class_rule->u16ValidityBitMap); pstClassifierEntry->bUsed = TRUE; } -- cgit v1.2.3 From eb8d0c9195de173e055ec5fc7a9deebe05025b41 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 23 May 2014 22:23:59 +0200 Subject: Staging: bcm: Shortened lines in CopyClassifierRuleToSF() Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 128 ++++++++++++++++++++++++++++++------------- 1 file changed, 89 insertions(+), 39 deletions(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index 20e41742d4fe..94f3f15ddd5c 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -241,7 +241,10 @@ void ClearTargetDSXBuffer(struct bcm_mini_adapter *Adapter, B_UINT16 TID, bool b * @ingroup ctrl_pkt_functions * copy classifier rule into the specified SF index */ -static inline VOID CopyClassifierRuleToSF(struct bcm_mini_adapter *Adapter, struct bcm_convergence_types *psfCSType, UINT uiSearchRuleIndex, UINT nClassifierIndex) +static inline VOID CopyClassifierRuleToSF(struct bcm_mini_adapter *Adapter, + struct bcm_convergence_types *psfCSType, + UINT uiSearchRuleIndex, + UINT nClassifierIndex) { struct bcm_classifier_rule *pstClassifierEntry = NULL; /* VOID *pvPhsContext = NULL; */ @@ -256,7 +259,8 @@ static inline VOID CopyClassifierRuleToSF(struct bcm_mini_adapter *Adapter, stru nClassifierIndex > (MAX_CLASSIFIERS-1)) return; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Storing Classifier Rule Index : %X", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Storing Classifier Rule Index : %X", ntohs(pack_class_rule->u16PacketClassificationRuleIndex)); if (nClassifierIndex > MAX_CLASSIFIERS-1) @@ -265,31 +269,42 @@ static inline VOID CopyClassifierRuleToSF(struct bcm_mini_adapter *Adapter, stru pstClassifierEntry = &Adapter->astClassifierTable[nClassifierIndex]; if (pstClassifierEntry) { /* Store if Ipv6 */ - pstClassifierEntry->bIpv6Protocol = (Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion == IPV6) ? TRUE : false; + pstClassifierEntry->bIpv6Protocol = + (Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion == IPV6) ? TRUE : false; /* Destinaiton Port */ - pstClassifierEntry->ucDestPortRangeLength = pack_class_rule->u8ProtocolDestPortRangeLength / 4; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Destination Port Range Length:0x%X ", pstClassifierEntry->ucDestPortRangeLength); + pstClassifierEntry->ucDestPortRangeLength = + pack_class_rule->u8ProtocolDestPortRangeLength / 4; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Destination Port Range Length:0x%X ", + pstClassifierEntry->ucDestPortRangeLength); if (pack_class_rule->u8ProtocolDestPortRangeLength <= MAX_PORT_RANGE) { for (i = 0; i < (pstClassifierEntry->ucDestPortRangeLength); i++) { - pstClassifierEntry->usDestPortRangeLo[i] = *((PUSHORT)(pack_class_rule->u8ProtocolDestPortRange+i)); + pstClassifierEntry->usDestPortRangeLo[i] = + *((PUSHORT)(pack_class_rule->u8ProtocolDestPortRange+i)); pstClassifierEntry->usDestPortRangeHi[i] = *((PUSHORT)(pack_class_rule->u8ProtocolDestPortRange+2+i)); - pstClassifierEntry->usDestPortRangeLo[i] = ntohs(pstClassifierEntry->usDestPortRangeLo[i]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Destination Port Range Lo:0x%X ", + pstClassifierEntry->usDestPortRangeLo[i] = + ntohs(pstClassifierEntry->usDestPortRangeLo[i]); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + CONN_MSG, DBG_LVL_ALL, + "Destination Port Range Lo:0x%X ", pstClassifierEntry->usDestPortRangeLo[i]); - pstClassifierEntry->usDestPortRangeHi[i] = ntohs(pstClassifierEntry->usDestPortRangeHi[i]); + pstClassifierEntry->usDestPortRangeHi[i] = + ntohs(pstClassifierEntry->usDestPortRangeHi[i]); } } else { pstClassifierEntry->ucDestPortRangeLength = 0; } /* Source Port */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Source Port Range Length:0x%X ", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Source Port Range Length:0x%X ", pack_class_rule->u8ProtocolSourcePortRangeLength); if (pack_class_rule->u8ProtocolSourcePortRangeLength <= MAX_PORT_RANGE) { - pstClassifierEntry->ucSrcPortRangeLength = pack_class_rule->u8ProtocolSourcePortRangeLength/4; + pstClassifierEntry->ucSrcPortRangeLength = + pack_class_rule->u8ProtocolSourcePortRangeLength/4; for (i = 0; i < (pstClassifierEntry->ucSrcPortRangeLength); i++) { pstClassifierEntry->usSrcPortRangeLo[i] = *((PUSHORT)(pack_class_rule-> @@ -299,13 +314,17 @@ static inline VOID CopyClassifierRuleToSF(struct bcm_mini_adapter *Adapter, stru u8ProtocolSourcePortRange+2+i)); pstClassifierEntry->usSrcPortRangeLo[i] = ntohs(pstClassifierEntry->usSrcPortRangeLo[i]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Source Port Range Lo:0x%X ", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, + CONN_MSG, DBG_LVL_ALL, + "Source Port Range Lo:0x%X ", pstClassifierEntry->usSrcPortRangeLo[i]); - pstClassifierEntry->usSrcPortRangeHi[i] = ntohs(pstClassifierEntry->usSrcPortRangeHi[i]); + pstClassifierEntry->usSrcPortRangeHi[i] = + ntohs(pstClassifierEntry->usSrcPortRangeHi[i]); } } /* Destination Ip Address and Mask */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Ip Destination Parameters : "); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Ip Destination Parameters : "); CopyIpAddrToClassifier(pstClassifierEntry, pack_class_rule->u8IPDestinationAddressLength, pack_class_rule->u8IPDestinationAddress, @@ -313,7 +332,8 @@ static inline VOID CopyClassifierRuleToSF(struct bcm_mini_adapter *Adapter, stru TRUE : false, eDestIpAddress); /* Source Ip Address and Mask */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Ip Source Parameters : "); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Ip Source Parameters : "); CopyIpAddrToClassifier(pstClassifierEntry, pack_class_rule->u8IPMaskedSourceAddressLength, @@ -322,12 +342,18 @@ static inline VOID CopyClassifierRuleToSF(struct bcm_mini_adapter *Adapter, stru eSrcIpAddress); /* TOS */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "TOS Length:0x%X ", pack_class_rule->u8IPTypeOfServiceLength); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "TOS Length:0x%X ", + pack_class_rule->u8IPTypeOfServiceLength); if (pack_class_rule->u8IPTypeOfServiceLength == 3) { - pstClassifierEntry->ucIPTypeOfServiceLength = pack_class_rule->u8IPTypeOfServiceLength; - pstClassifierEntry->ucTosLow = pack_class_rule->u8IPTypeOfService[0]; - pstClassifierEntry->ucTosHigh = pack_class_rule->u8IPTypeOfService[1]; - pstClassifierEntry->ucTosMask = pack_class_rule->u8IPTypeOfService[2]; + pstClassifierEntry->ucIPTypeOfServiceLength = + pack_class_rule->u8IPTypeOfServiceLength; + pstClassifierEntry->ucTosLow = + pack_class_rule->u8IPTypeOfService[0]; + pstClassifierEntry->ucTosHigh = + pack_class_rule->u8IPTypeOfService[1]; + pstClassifierEntry->ucTosMask = + pack_class_rule->u8IPTypeOfService[2]; pstClassifierEntry->bTOSValid = TRUE; } if (pack_class_rule->u8Protocol == 0) { @@ -338,33 +364,57 @@ static inline VOID CopyClassifierRuleToSF(struct bcm_mini_adapter *Adapter, stru } pstClassifierEntry->ucProtocol[0] = pack_class_rule->u8Protocol; - pstClassifierEntry->u8ClassifierRulePriority = pack_class_rule->u8ClassifierRulePriority; + pstClassifierEntry->u8ClassifierRulePriority = + pack_class_rule->u8ClassifierRulePriority; /* store the classifier rule ID and set this classifier entry as valid */ - pstClassifierEntry->ucDirection = Adapter->PackInfo[uiSearchRuleIndex].ucDirection; - pstClassifierEntry->uiClassifierRuleIndex = ntohs(pack_class_rule->u16PacketClassificationRuleIndex); - pstClassifierEntry->usVCID_Value = Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value; - pstClassifierEntry->ulSFID = Adapter->PackInfo[uiSearchRuleIndex].ulSFID; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Search Index %d Dir: %d, Index: %d, Vcid: %d\n", - uiSearchRuleIndex, pstClassifierEntry->ucDirection, + pstClassifierEntry->ucDirection = + Adapter->PackInfo[uiSearchRuleIndex].ucDirection; + pstClassifierEntry->uiClassifierRuleIndex = + ntohs(pack_class_rule->u16PacketClassificationRuleIndex); + pstClassifierEntry->usVCID_Value = + Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value; + pstClassifierEntry->ulSFID = + Adapter->PackInfo[uiSearchRuleIndex].ulSFID; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Search Index %d Dir: %d, Index: %d, Vcid: %d\n", + uiSearchRuleIndex, + pstClassifierEntry->ucDirection, pstClassifierEntry->uiClassifierRuleIndex, pstClassifierEntry->usVCID_Value); if (pack_class_rule->u8AssociatedPHSI) - pstClassifierEntry->u8AssociatedPHSI = pack_class_rule->u8AssociatedPHSI; + pstClassifierEntry->u8AssociatedPHSI = + pack_class_rule->u8AssociatedPHSI; /* Copy ETH CS Parameters */ - pstClassifierEntry->ucEthCSSrcMACLen = (pack_class_rule->u8EthernetSourceMACAddressLength); - memcpy(pstClassifierEntry->au8EThCSSrcMAC, pack_class_rule->u8EthernetSourceMACAddress, MAC_ADDRESS_SIZE); - memcpy(pstClassifierEntry->au8EThCSSrcMACMask, pack_class_rule->u8EthernetSourceMACAddress + MAC_ADDRESS_SIZE, MAC_ADDRESS_SIZE); - pstClassifierEntry->ucEthCSDestMACLen = (pack_class_rule->u8EthernetDestMacAddressLength); - memcpy(pstClassifierEntry->au8EThCSDestMAC, pack_class_rule->u8EthernetDestMacAddress, MAC_ADDRESS_SIZE); - memcpy(pstClassifierEntry->au8EThCSDestMACMask, pack_class_rule->u8EthernetDestMacAddress + MAC_ADDRESS_SIZE, MAC_ADDRESS_SIZE); - pstClassifierEntry->ucEtherTypeLen = (pack_class_rule->u8EthertypeLength); - memcpy(pstClassifierEntry->au8EthCSEtherType, pack_class_rule->u8Ethertype, NUM_ETHERTYPE_BYTES); - memcpy(pstClassifierEntry->usUserPriority, &pack_class_rule->u16UserPriority, 2); - pstClassifierEntry->usVLANID = ntohs(pack_class_rule->u16VLANID); - pstClassifierEntry->usValidityBitMap = ntohs(pack_class_rule->u16ValidityBitMap); + pstClassifierEntry->ucEthCSSrcMACLen = + (pack_class_rule->u8EthernetSourceMACAddressLength); + memcpy(pstClassifierEntry->au8EThCSSrcMAC, + pack_class_rule->u8EthernetSourceMACAddress, + MAC_ADDRESS_SIZE); + memcpy(pstClassifierEntry->au8EThCSSrcMACMask, + pack_class_rule->u8EthernetSourceMACAddress + + MAC_ADDRESS_SIZE, MAC_ADDRESS_SIZE); + pstClassifierEntry->ucEthCSDestMACLen = + (pack_class_rule->u8EthernetDestMacAddressLength); + memcpy(pstClassifierEntry->au8EThCSDestMAC, + pack_class_rule->u8EthernetDestMacAddress, + MAC_ADDRESS_SIZE); + memcpy(pstClassifierEntry->au8EThCSDestMACMask, + pack_class_rule->u8EthernetDestMacAddress + + MAC_ADDRESS_SIZE, MAC_ADDRESS_SIZE); + pstClassifierEntry->ucEtherTypeLen = + (pack_class_rule->u8EthertypeLength); + memcpy(pstClassifierEntry->au8EthCSEtherType, + pack_class_rule->u8Ethertype, + NUM_ETHERTYPE_BYTES); + memcpy(pstClassifierEntry->usUserPriority, + &pack_class_rule->u16UserPriority, 2); + pstClassifierEntry->usVLANID = + ntohs(pack_class_rule->u16VLANID); + pstClassifierEntry->usValidityBitMap = + ntohs(pack_class_rule->u16ValidityBitMap); pstClassifierEntry->bUsed = TRUE; } -- cgit v1.2.3 From d52fe04a6448bae89ce8820911efdb38001324df Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 23 May 2014 22:24:00 +0200 Subject: Staging: bcm: Shortened lines and replaced member accessing in CopyIpAddrToClassifier() Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index 94f3f15ddd5c..d5d5a9fb73bf 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -222,16 +222,20 @@ CopyIpAddrToClassifier(struct bcm_classifier_rule *pstClassifierEntry, void ClearTargetDSXBuffer(struct bcm_mini_adapter *Adapter, B_UINT16 TID, bool bFreeAll) { int i; + struct bcm_targetdsx_buffer *curr_buf; for (i = 0; i < Adapter->ulTotalTargetBuffersAvailable; i++) { - if (Adapter->astTargetDsxBuffer[i].valid) + curr_buf = &Adapter->astTargetDsxBuffer[i]; + + if (curr_buf->valid) continue; - if ((bFreeAll) || (Adapter->astTargetDsxBuffer[i].tid == TID)) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "ClearTargetDSXBuffer: found tid %d buffer cleared %lx\n", - TID, Adapter->astTargetDsxBuffer[i].ulTargetDsxBuffer); - Adapter->astTargetDsxBuffer[i].valid = 1; - Adapter->astTargetDsxBuffer[i].tid = 0; + if ((bFreeAll) || (curr_buf->tid == TID)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, + "ClearTargetDSXBuffer: found tid %d buffer cleared %lx\n", + TID, curr_buf->ulTargetDsxBuffer); + curr_buf->valid = 1; + curr_buf->tid = 0; Adapter->ulFreeTargetBufferCnt++; } } -- cgit v1.2.3 From 780eb92c857c63c995807193f6b3bdf86855ade0 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 23 May 2014 22:24:01 +0200 Subject: Staging: bcm: Replaced member accessing by variable Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index d5d5a9fb73bf..7fb8568ad270 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -139,6 +139,13 @@ CopyIpAddrToClassifier(struct bcm_classifier_rule *pstClassifierEntry, BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Ip Address Range Length:0x%X ", u8IpAddressLen); if ((bIpVersion6 ? (IPV6_ADDRESS_SIZEINBYTES * MAX_IP_RANGE_LENGTH * 2) : (TOTAL_MASKED_ADDRESS_IN_BYTES)) >= u8IpAddressLen) { + + union u_ip_address *st_dest_ip = + &pstClassifierEntry->stDestIpAddress; + + union u_ip_address *st_src_ip = + &pstClassifierEntry->stSrcIpAddress; + /* * checking both the mask and address togethor in Classification. * So length will be : TotalLengthInBytes/nSizeOfIPAddressInBytes * 2 @@ -147,20 +154,20 @@ CopyIpAddrToClassifier(struct bcm_classifier_rule *pstClassifierEntry, if (eIpAddrContext == eDestIpAddress) { pstClassifierEntry->ucIPDestinationAddressLength = u8IpAddressLen/(nSizeOfIPAddressInBytes * 2); if (bIpVersion6) { - ptrClassifierIpAddress = pstClassifierEntry->stDestIpAddress.ucIpv6Address; - ptrClassifierIpMask = pstClassifierEntry->stDestIpAddress.ucIpv6Mask; + ptrClassifierIpAddress = st_dest_ip->ucIpv6Address; + ptrClassifierIpMask = st_dest_ip->ucIpv6Mask; } else { - ptrClassifierIpAddress = pstClassifierEntry->stDestIpAddress.ucIpv4Address; - ptrClassifierIpMask = pstClassifierEntry->stDestIpAddress.ucIpv4Mask; + ptrClassifierIpAddress = st_dest_ip->ucIpv4Address; + ptrClassifierIpMask = st_dest_ip->ucIpv4Mask; } } else if (eIpAddrContext == eSrcIpAddress) { pstClassifierEntry->ucIPSourceAddressLength = u8IpAddressLen/(nSizeOfIPAddressInBytes * 2); if (bIpVersion6) { - ptrClassifierIpAddress = pstClassifierEntry->stSrcIpAddress.ucIpv6Address; - ptrClassifierIpMask = pstClassifierEntry->stSrcIpAddress.ucIpv6Mask; + ptrClassifierIpAddress = st_src_ip->ucIpv6Address; + ptrClassifierIpMask = st_src_ip->ucIpv6Mask; } else { - ptrClassifierIpAddress = pstClassifierEntry->stSrcIpAddress.ucIpv4Address; - ptrClassifierIpMask = pstClassifierEntry->stSrcIpAddress.ucIpv4Mask; + ptrClassifierIpAddress = st_src_ip->ucIpv4Address; + ptrClassifierIpMask = st_src_ip->ucIpv4Mask; } } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Address Length:0x%X\n", pstClassifierEntry->ucIPDestinationAddressLength); @@ -172,13 +179,13 @@ CopyIpAddrToClassifier(struct bcm_classifier_rule *pstClassifierEntry, if (!bIpVersion6) { if (eIpAddrContext == eSrcIpAddress) { - pstClassifierEntry->stSrcIpAddress.ulIpv4Addr[i] = ntohl(pstClassifierEntry->stSrcIpAddress.ulIpv4Addr[i]); + st_src_ip->ulIpv4Addr[i] = ntohl(st_src_ip->ulIpv4Addr[i]); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Src Ip Address:0x%luX ", - pstClassifierEntry->stSrcIpAddress.ulIpv4Addr[i]); + st_src_ip->ulIpv4Addr[i]); } else if (eIpAddrContext == eDestIpAddress) { - pstClassifierEntry->stDestIpAddress.ulIpv4Addr[i] = ntohl(pstClassifierEntry->stDestIpAddress.ulIpv4Addr[i]); + st_dest_ip->ulIpv4Addr[i] = ntohl(st_dest_ip->ulIpv4Addr[i]); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Dest Ip Address:0x%luX ", - pstClassifierEntry->stDestIpAddress.ulIpv4Addr[i]); + st_dest_ip->ulIpv4Addr[i]); } } u8IpAddressLen -= nSizeOfIPAddressInBytes; @@ -191,15 +198,15 @@ CopyIpAddrToClassifier(struct bcm_classifier_rule *pstClassifierEntry, if (!bIpVersion6) { if (eIpAddrContext == eSrcIpAddress) { - pstClassifierEntry->stSrcIpAddress.ulIpv4Mask[i] = - ntohl(pstClassifierEntry->stSrcIpAddress.ulIpv4Mask[i]); + st_src_ip->ulIpv4Mask[i] = + ntohl(st_src_ip->ulIpv4Mask[i]); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Src Ip Mask Address:0x%luX ", - pstClassifierEntry->stSrcIpAddress.ulIpv4Mask[i]); + st_src_ip->ulIpv4Mask[i]); } else if (eIpAddrContext == eDestIpAddress) { - pstClassifierEntry->stDestIpAddress.ulIpv4Mask[i] = - ntohl(pstClassifierEntry->stDestIpAddress.ulIpv4Mask[i]); + st_dest_ip->ulIpv4Mask[i] = + ntohl(st_dest_ip->ulIpv4Mask[i]); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Dest Ip Mask Address:0x%luX ", - pstClassifierEntry->stDestIpAddress.ulIpv4Mask[i]); + st_dest_ip->ulIpv4Mask[i]); } } u8IpAddressLen -= nSizeOfIPAddressInBytes; -- cgit v1.2.3 From e61f63557bcbe7bc036048c4f2b8391eb2134423 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 23 May 2014 22:24:02 +0200 Subject: Staging: bcm: Shortened lines in CopyIpAddrToClassifier() Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 72 ++++++++++++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 20 deletions(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index 7fb8568ad270..5bd6e1c12a8a 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -136,7 +136,8 @@ CopyIpAddrToClassifier(struct bcm_classifier_rule *pstClassifierEntry, nSizeOfIPAddressInBytes = IPV6_ADDRESS_SIZEINBYTES; /* Destination Ip Address */ - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Ip Address Range Length:0x%X ", u8IpAddressLen); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Ip Address Range Length:0x%X ", u8IpAddressLen); if ((bIpVersion6 ? (IPV6_ADDRESS_SIZEINBYTES * MAX_IP_RANGE_LENGTH * 2) : (TOTAL_MASKED_ADDRESS_IN_BYTES)) >= u8IpAddressLen) { @@ -152,39 +153,61 @@ CopyIpAddrToClassifier(struct bcm_classifier_rule *pstClassifierEntry, * (nSizeOfIPAddressInBytes for address and nSizeOfIPAddressInBytes for mask) */ if (eIpAddrContext == eDestIpAddress) { - pstClassifierEntry->ucIPDestinationAddressLength = u8IpAddressLen/(nSizeOfIPAddressInBytes * 2); + pstClassifierEntry->ucIPDestinationAddressLength = + u8IpAddressLen/(nSizeOfIPAddressInBytes * 2); if (bIpVersion6) { - ptrClassifierIpAddress = st_dest_ip->ucIpv6Address; - ptrClassifierIpMask = st_dest_ip->ucIpv6Mask; + ptrClassifierIpAddress = + st_dest_ip->ucIpv6Address; + ptrClassifierIpMask = + st_dest_ip->ucIpv6Mask; } else { - ptrClassifierIpAddress = st_dest_ip->ucIpv4Address; - ptrClassifierIpMask = st_dest_ip->ucIpv4Mask; + ptrClassifierIpAddress = + st_dest_ip->ucIpv4Address; + ptrClassifierIpMask = + st_dest_ip->ucIpv4Mask; } } else if (eIpAddrContext == eSrcIpAddress) { - pstClassifierEntry->ucIPSourceAddressLength = u8IpAddressLen/(nSizeOfIPAddressInBytes * 2); + pstClassifierEntry->ucIPSourceAddressLength = + u8IpAddressLen/(nSizeOfIPAddressInBytes * 2); if (bIpVersion6) { - ptrClassifierIpAddress = st_src_ip->ucIpv6Address; + ptrClassifierIpAddress = + st_src_ip->ucIpv6Address; ptrClassifierIpMask = st_src_ip->ucIpv6Mask; } else { - ptrClassifierIpAddress = st_src_ip->ucIpv4Address; + ptrClassifierIpAddress = + st_src_ip->ucIpv4Address; ptrClassifierIpMask = st_src_ip->ucIpv4Mask; } } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Address Length:0x%X\n", pstClassifierEntry->ucIPDestinationAddressLength); - while ((u8IpAddressLen >= nSizeOfIPAddressInBytes) && (i < MAX_IP_RANGE_LENGTH)) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, + "Address Length:0x%X\n", + pstClassifierEntry->ucIPDestinationAddressLength); + while ((u8IpAddressLen >= nSizeOfIPAddressInBytes) + && (i < MAX_IP_RANGE_LENGTH)) { memcpy(ptrClassifierIpAddress + (i * nSizeOfIPAddressInBytes), - (pu8IpAddressMaskSrc+(i*nSizeOfIPAddressInBytes*2)), + (pu8IpAddressMaskSrc + + (i * nSizeOfIPAddressInBytes * 2)), nSizeOfIPAddressInBytes); if (!bIpVersion6) { if (eIpAddrContext == eSrcIpAddress) { - st_src_ip->ulIpv4Addr[i] = ntohl(st_src_ip->ulIpv4Addr[i]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Src Ip Address:0x%luX ", + st_src_ip->ulIpv4Addr[i] = + ntohl(st_src_ip->ulIpv4Addr[i]); + BCM_DEBUG_PRINT(Adapter, + DBG_TYPE_OTHERS, + CONN_MSG, + DBG_LVL_ALL, + "Src Ip Address:0x%luX ", st_src_ip->ulIpv4Addr[i]); } else if (eIpAddrContext == eDestIpAddress) { - st_dest_ip->ulIpv4Addr[i] = ntohl(st_dest_ip->ulIpv4Addr[i]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Dest Ip Address:0x%luX ", + st_dest_ip->ulIpv4Addr[i] = + ntohl(st_dest_ip->ulIpv4Addr[i]); + BCM_DEBUG_PRINT(Adapter, + DBG_TYPE_OTHERS, + CONN_MSG, + DBG_LVL_ALL, + "Dest Ip Address:0x%luX ", st_dest_ip->ulIpv4Addr[i]); } } @@ -192,20 +215,29 @@ CopyIpAddrToClassifier(struct bcm_classifier_rule *pstClassifierEntry, if (u8IpAddressLen >= nSizeOfIPAddressInBytes) { memcpy(ptrClassifierIpMask + (i * nSizeOfIPAddressInBytes), - (pu8IpAddressMaskSrc+nSizeOfIPAddressInBytes + - (i*nSizeOfIPAddressInBytes*2)), + (pu8IpAddressMaskSrc + + nSizeOfIPAddressInBytes + + (i * nSizeOfIPAddressInBytes * 2)), nSizeOfIPAddressInBytes); if (!bIpVersion6) { if (eIpAddrContext == eSrcIpAddress) { st_src_ip->ulIpv4Mask[i] = ntohl(st_src_ip->ulIpv4Mask[i]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Src Ip Mask Address:0x%luX ", + BCM_DEBUG_PRINT(Adapter, + DBG_TYPE_OTHERS, + CONN_MSG, + DBG_LVL_ALL, + "Src Ip Mask Address:0x%luX ", st_src_ip->ulIpv4Mask[i]); } else if (eIpAddrContext == eDestIpAddress) { st_dest_ip->ulIpv4Mask[i] = ntohl(st_dest_ip->ulIpv4Mask[i]); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Dest Ip Mask Address:0x%luX ", + BCM_DEBUG_PRINT(Adapter, + DBG_TYPE_OTHERS, + CONN_MSG, + DBG_LVL_ALL, + "Dest Ip Mask Address:0x%luX ", st_dest_ip->ulIpv4Mask[i]); } } -- cgit v1.2.3 From 3563e4ee9ca099c10a0bc4bebe38a5661ba2ac28 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 23 May 2014 22:24:03 +0200 Subject: Staging: bcm: Shortened lines in deleteSFBySfid() Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index 5bd6e1c12a8a..6dfa361f5fae 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -109,7 +109,8 @@ static int SearchFreeClsid(struct bcm_mini_adapter *Adapter /**Adapter Context*/ return MAX_CLASSIFIERS+1; } -static VOID deleteSFBySfid(struct bcm_mini_adapter *Adapter, UINT uiSearchRuleIndex) +static VOID deleteSFBySfid(struct bcm_mini_adapter *Adapter, + UINT uiSearchRuleIndex) { /* deleting all the packet held in the SF */ flush_queue(Adapter, uiSearchRuleIndex); @@ -118,7 +119,8 @@ static VOID deleteSFBySfid(struct bcm_mini_adapter *Adapter, UINT uiSearchRuleIn DeleteAllClassifiersForSF(Adapter, uiSearchRuleIndex); /* Resetting only MIBS related entries in the SF */ - memset((PVOID)&Adapter->PackInfo[uiSearchRuleIndex], 0, sizeof(struct bcm_mibs_table)); + memset((PVOID)&Adapter->PackInfo[uiSearchRuleIndex], 0, + sizeof(struct bcm_mibs_table)); } static inline VOID -- cgit v1.2.3 From 3fdf44ca2a52c1ecd339e9ed19b6f60e547835df Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 23 May 2014 22:24:04 +0200 Subject: Staging: bcm: Shortened lines in SearchClsid() Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index 6dfa361f5fae..182efccdd64c 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -78,13 +78,16 @@ static int SearchFreeSfid(struct bcm_mini_adapter *Adapter) * B_UINT16 uiClassifierID - The classifier ID to be searched * Return: int :Classifier table index of matching entry */ -static int SearchClsid(struct bcm_mini_adapter *Adapter, ULONG ulSFID, B_UINT16 uiClassifierID) +static int SearchClsid(struct bcm_mini_adapter *Adapter, + ULONG ulSFID, + B_UINT16 uiClassifierID) { int i; for (i = 0; i < MAX_CLASSIFIERS; i++) { if ((Adapter->astClassifierTable[i].bUsed) && - (Adapter->astClassifierTable[i].uiClassifierRuleIndex == uiClassifierID) && + (Adapter->astClassifierTable[i].uiClassifierRuleIndex + == uiClassifierID) && (Adapter->astClassifierTable[i].ulSFID == ulSFID)) return i; } -- cgit v1.2.3 From 1808bc67b1f00a54b3b5a23c51c361fd618796eb Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 23 May 2014 22:24:05 +0200 Subject: Staging: bcm: Shortened prototype for GetNextTargetBufferLocation() Signed-off-by: Matthias Beyer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index 182efccdd64c..fb1d932c5d79 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -13,7 +13,8 @@ enum E_CLASSIFIER_ACTION { eDeleteClassifier }; -static ULONG GetNextTargetBufferLocation(struct bcm_mini_adapter *Adapter, B_UINT16 tid); +static ULONG GetNextTargetBufferLocation(struct bcm_mini_adapter *Adapter, + B_UINT16 tid); static void restore_endianess_of_pstClassifierEntry( struct bcm_classifier_rule *pstClassifierEntry, enum bcm_ipaddr_context eIpAddrContext); -- cgit v1.2.3 From c4a6ca97439a40164cd65e7f695a9f380776817f Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 24 May 2014 13:01:06 -0700 Subject: Revert "staging: r8188eu: Add support for Dlink DWA-121 802.11n Wireless N 150 Pico Adapter" This reverts commit 599a2c02a784934b9bf0725920c1bc235b9b28ce. Larry writes: This patch should be dropped. The 0x2001:0x3308 device is an RTL8188CU, not RTL8188EU. As a result, it is already in the USB device tables. Cc: Larry Finger Cc: Kim Nylund Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index 246a420c897c..a368aa92b259 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -55,7 +55,6 @@ static struct usb_device_id rtw_usb_id_tbl[] = { /*=== Customer ID ===*/ /****** 8188EUS ********/ {USB_DEVICE(0x07b8, 0x8179)}, /* Abocom - Abocom */ - {USB_DEVICE(0x2001, 0x3308)}, /* DLink DWA-121 REV A1 */ {USB_DEVICE(0x2001, 0x330F)}, /* DLink DWA-125 REV D1 */ {USB_DEVICE(0x2001, 0x3310)}, /* Dlink DWA-123 REV D1 */ {} /* Terminating entry */ -- cgit v1.2.3 From a91a73c8b39a6b8bcc53fafa5372c65387c81233 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 24 May 2014 12:52:10 +0100 Subject: iio:adc:max1363 incorrect resolutions for max11604, max11605, max11610 and max11611. Cc: Stable@vger.kernel.org> Reported-by: Erik Habbinga Signed-off-by: Jonathan Cameron Acked-by: Hartmut Knaack --- drivers/iio/adc/max1363.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c index 9cf3229a7272..1b3b74be5c20 100644 --- a/drivers/iio/adc/max1363.c +++ b/drivers/iio/adc/max1363.c @@ -1252,8 +1252,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { .num_modes = ARRAY_SIZE(max1238_mode_list), .default_mode = s0to11, .info = &max1238_info, - .channels = max1238_channels, - .num_channels = ARRAY_SIZE(max1238_channels), + .channels = max1038_channels, + .num_channels = ARRAY_SIZE(max1038_channels), }, [max11605] = { .bits = 8, @@ -1262,8 +1262,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { .num_modes = ARRAY_SIZE(max1238_mode_list), .default_mode = s0to11, .info = &max1238_info, - .channels = max1238_channels, - .num_channels = ARRAY_SIZE(max1238_channels), + .channels = max1038_channels, + .num_channels = ARRAY_SIZE(max1038_channels), }, [max11606] = { .bits = 10, @@ -1312,8 +1312,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { .num_modes = ARRAY_SIZE(max1238_mode_list), .default_mode = s0to11, .info = &max1238_info, - .channels = max1238_channels, - .num_channels = ARRAY_SIZE(max1238_channels), + .channels = max1138_channels, + .num_channels = ARRAY_SIZE(max1138_channels), }, [max11611] = { .bits = 10, @@ -1322,8 +1322,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { .num_modes = ARRAY_SIZE(max1238_mode_list), .default_mode = s0to11, .info = &max1238_info, - .channels = max1238_channels, - .num_channels = ARRAY_SIZE(max1238_channels), + .channels = max1138_channels, + .num_channels = ARRAY_SIZE(max1138_channels), }, [max11612] = { .bits = 12, -- cgit v1.2.3 From 34683a5c6e0ffaa61528ff71c283efe3063cc53f Mon Sep 17 00:00:00 2001 From: Toralf Förster Date: Sat, 24 May 2014 14:25:00 +0100 Subject: fix format string missmatch in staging/iio/Documentation/iio_utils.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit spotted by cppcheck Signed-off-by: Toralf Förster Signed-off-by: Jonathan Cameron --- drivers/staging/iio/Documentation/iio_utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/Documentation/iio_utils.h b/drivers/staging/iio/Documentation/iio_utils.h index 2064839ef2cd..a9cfc06edb01 100644 --- a/drivers/staging/iio/Documentation/iio_utils.h +++ b/drivers/staging/iio/Documentation/iio_utils.h @@ -318,7 +318,7 @@ inline int build_channel_array(const char *device_dir, free(filename); goto error_close_dir; } - fscanf(sysfsfp, "%u", &ret); + fscanf(sysfsfp, "%i", &ret); if (ret == 1) (*counter)++; fclose(sysfsfp); @@ -350,7 +350,7 @@ inline int build_channel_array(const char *device_dir, ret = -errno; goto error_cleanup_array; } - fscanf(sysfsfp, "%u", ¤t_enabled); + fscanf(sysfsfp, "%i", ¤t_enabled); fclose(sysfsfp); if (!current_enabled) { -- cgit v1.2.3 From 0b596b2a707ee2b0c62243d594d2f4ff79b0eeab Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 24 May 2014 14:36:57 +0100 Subject: staging: vt6656: Convert remaining locks to spin_lock_irqsave. Convert all remaining locks to spin_lock_irqsave and spin_unlock_irqrestore Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/dpc.c | 5 +++-- drivers/staging/vt6656/int.c | 5 +++-- drivers/staging/vt6656/iwctl.c | 17 ++++++++++++----- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c index 286e7352ce1d..c0ec5b37aa7c 100644 --- a/drivers/staging/vt6656/dpc.c +++ b/drivers/staging/vt6656/dpc.c @@ -863,13 +863,14 @@ void RXvWorkItem(struct work_struct *work) container_of(work, struct vnt_private, read_work_item); int status; struct vnt_rcb *rcb = NULL; + unsigned long flags; if (priv->Flags & fMP_DISCONNECTED) return; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Rx Polling Thread\n"); - spin_lock_irq(&priv->lock); + spin_lock_irqsave(&priv->lock, flags); while ((priv->Flags & fMP_POST_READS) && MP_IS_READY(priv) && (priv->NumRecvFreeList != 0)) { @@ -884,7 +885,7 @@ void RXvWorkItem(struct work_struct *work) priv->bIsRxWorkItemQueued = false; - spin_unlock_irq(&priv->lock); + spin_unlock_irqrestore(&priv->lock, flags); } void RXvFreeRCB(struct vnt_rcb *rcb, int re_alloc_skb) diff --git a/drivers/staging/vt6656/int.c b/drivers/staging/vt6656/int.c index cca56b2f243d..f2a5225b50f8 100644 --- a/drivers/staging/vt6656/int.c +++ b/drivers/staging/vt6656/int.c @@ -65,15 +65,16 @@ static int msglevel = MSG_LEVEL_INFO; /* MSG_LEVEL_DEBUG */ -*/ void INTvWorkItem(struct vnt_private *pDevice) { + unsigned long flags; int ntStatus; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Interrupt Polling Thread\n"); - spin_lock_irq(&pDevice->lock); + spin_lock_irqsave(&pDevice->lock, flags); ntStatus = PIPEnsInterruptRead(pDevice); - spin_unlock_irq(&pDevice->lock); + spin_unlock_irqrestore(&pDevice->lock, flags); } void INTnsProcessData(struct vnt_private *priv) diff --git a/drivers/staging/vt6656/iwctl.c b/drivers/staging/vt6656/iwctl.c index 3edeb2f44f6a..e7b7ca5586cc 100644 --- a/drivers/staging/vt6656/iwctl.c +++ b/drivers/staging/vt6656/iwctl.c @@ -91,6 +91,7 @@ int iwctl_siwscan(struct net_device *dev, struct iw_request_info *info, struct iw_scan_req *req = (struct iw_scan_req *)extra; u8 abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; PWLAN_IE_SSID pItemSSID = NULL; + unsigned long flags; if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) return -EINVAL; @@ -115,7 +116,7 @@ int iwctl_siwscan(struct net_device *dev, struct iw_request_info *info, return 0; } - spin_lock_irq(&pDevice->lock); + spin_lock_irqsave(&pDevice->lock, flags); BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass); @@ -136,7 +137,8 @@ int iwctl_siwscan(struct net_device *dev, struct iw_request_info *info, PRINT_K("SIOCSIWSCAN:[desired_ssid=%s,len=%d]\n", ((PWLAN_IE_SSID)abyScanSSID)->abySSID, ((PWLAN_IE_SSID)abyScanSSID)->len); bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID); - spin_unlock_irq(&pDevice->lock); + + spin_unlock_irqrestore(&pDevice->lock, flags); return 0; } else if (req->scan_type == IW_SCAN_TYPE_PASSIVE) { // passive scan @@ -148,7 +150,8 @@ int iwctl_siwscan(struct net_device *dev, struct iw_request_info *info, pMgmt->eScanType = WMAC_SCAN_PASSIVE; bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, NULL); - spin_unlock_irq(&pDevice->lock); + + spin_unlock_irqrestore(&pDevice->lock, flags); return 0; } @@ -375,6 +378,7 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info, struct vnt_private *pDevice = netdev_priv(dev); __u32 *wmode = &wrqu->mode; struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + unsigned long flags; int rc = 0; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWMODE\n"); @@ -415,10 +419,13 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info, if (pDevice->bCommit) { if (pMgmt->eConfigMode == WMAC_CONFIG_AP) { netif_stop_queue(pDevice->dev); - spin_lock_irq(&pDevice->lock); + + spin_lock_irqsave(&pDevice->lock, flags); + bScheduleCommand((void *) pDevice, WLAN_CMD_RUN_AP, NULL); - spin_unlock_irq(&pDevice->lock); + + spin_unlock_irqrestore(&pDevice->lock, flags); } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Commit the settings\n"); -- cgit v1.2.3 From de0eb9ef70fb0ed92510b2cebb2a7249d68ad2eb Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 24 May 2014 14:36:58 +0100 Subject: staging: vt6656: camel case clean up CARDbIsOFDMinBasicRate camel case change pDevice -> priv Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/card.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index 439e536fbeee..5a357c5ab27c 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -522,15 +522,16 @@ void CARDbAddBasicRate(struct vnt_private *priv, u16 rate_idx) CARDvUpdateBasicTopRate(priv); } -int CARDbIsOFDMinBasicRate(struct vnt_private *pDevice) +int CARDbIsOFDMinBasicRate(struct vnt_private *priv) { int ii; - for (ii = RATE_54M; ii >= RATE_6M; ii --) { - if ((pDevice->wBasicRate) & ((u16)(1<= RATE_6M; ii--) { + if ((priv->wBasicRate) & ((u16)(1 << ii))) + return true; + } + + return false; } u8 CARDbyGetPktType(struct vnt_private *pDevice) -- cgit v1.2.3 From 1f44238f6c040694f4bf5226db72c34e90c97e26 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 24 May 2014 14:36:59 +0100 Subject: staging: vt6656: camel case and cleanup CARDbyGetPktType camel case changes pDevice -> priv Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/card.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index 5a357c5ab27c..e39bdd59dfd6 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -534,18 +534,15 @@ int CARDbIsOFDMinBasicRate(struct vnt_private *priv) return false; } -u8 CARDbyGetPktType(struct vnt_private *pDevice) +u8 CARDbyGetPktType(struct vnt_private *priv) { - if (pDevice->byBBType == BB_TYPE_11A || pDevice->byBBType == BB_TYPE_11B) { - return (u8)pDevice->byBBType; - } - else if (CARDbIsOFDMinBasicRate(pDevice)) { - return PK_TYPE_11GA; - } - else { - return PK_TYPE_11GB; - } + if (priv->byBBType == BB_TYPE_11A || priv->byBBType == BB_TYPE_11B) + return (u8)priv->byBBType; + else if (CARDbIsOFDMinBasicRate(priv)) + return PK_TYPE_11GA; + else + return PK_TYPE_11GB; } /* -- cgit v1.2.3 From 3fd2a69c6ebf7c16b731438bd4de003e9c929ea7 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 24 May 2014 14:37:00 +0100 Subject: staging: vt6656: CARDqGetTSFOffset remove camel case camel case changes byRxRate -> rx_rate qwTSF1 -> tsf1 qwTSF2 -> tsf2 qwTSFOffset -> tsf_offset wRxBcnTSFOffst -> rx_bcn_offset Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/card.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index e39bdd59dfd6..8d12ae9a7ac5 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -551,27 +551,27 @@ u8 CARDbyGetPktType(struct vnt_private *priv) * * Parameters: * In: - * pDevice - The adapter to be sync. - * qwTSF1 - Rx BCN's TSF - * qwTSF2 - Local TSF + * rx_rate - rx rate. + * tsf1 - Rx BCN's TSF + * tsf2 - Local TSF * Out: * none * * Return Value: TSF Offset value * */ -u64 CARDqGetTSFOffset(u8 byRxRate, u64 qwTSF1, u64 qwTSF2) +u64 CARDqGetTSFOffset(u8 rx_rate, u64 tsf1, u64 tsf2) { - u64 qwTSFOffset = 0; - u16 wRxBcnTSFOffst = 0; + u64 tsf_offset = 0; + u16 rx_bcn_offset = 0; - wRxBcnTSFOffst = cwRXBCNTSFOff[byRxRate % MAX_RATE]; + rx_bcn_offset = cwRXBCNTSFOff[rx_rate % MAX_RATE]; - qwTSF2 += (u64)wRxBcnTSFOffst; + tsf2 += (u64)rx_bcn_offset; - qwTSFOffset = qwTSF1 - qwTSF2; + tsf_offset = tsf1 - tsf2; - return qwTSFOffset; + return tsf_offset; } /* -- cgit v1.2.3 From 302361d47539881865ce5913e36cadd90f90a4b9 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 24 May 2014 14:37:01 +0100 Subject: staging: vt6656: camel case and clean up CARDvAdjustTSF camel case changes pDevice -> priv byRxRate -> rx_rate qwBSSTimestamp -> time_stamp qwLocalTSF -> local_tsf qwTSFOffset -> tsf_offset pbyData -> data Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/card.c | 44 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index 8d12ae9a7ac5..4b0b3efd56ba 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -580,42 +580,34 @@ u64 CARDqGetTSFOffset(u8 rx_rate, u64 tsf1, u64 tsf2) * * Parameters: * In: - * pDevice - The adapter to be sync. - * qwBSSTimestamp - Rx BCN's TSF - * qwLocalTSF - Local TSF + * priv - The adapter to be sync. + * time_stamp - Rx BCN's TSF + * local_tsf - Local TSF * Out: * none * * Return Value: none * */ -void CARDvAdjustTSF(struct vnt_private *pDevice, u8 byRxRate, - u64 qwBSSTimestamp, u64 qwLocalTSF) +void CARDvAdjustTSF(struct vnt_private *priv, u8 rx_rate, + u64 time_stamp, u64 local_tsf) { - u64 qwTSFOffset = 0; - u8 pbyData[8]; - - qwTSFOffset = CARDqGetTSFOffset(byRxRate, qwBSSTimestamp, qwLocalTSF); - // adjust TSF - // HW's TSF add TSF Offset reg + u64 tsf_offset = 0; + u8 data[8]; - pbyData[0] = (u8)qwTSFOffset; - pbyData[1] = (u8)(qwTSFOffset >> 8); - pbyData[2] = (u8)(qwTSFOffset >> 16); - pbyData[3] = (u8)(qwTSFOffset >> 24); - pbyData[4] = (u8)(qwTSFOffset >> 32); - pbyData[5] = (u8)(qwTSFOffset >> 40); - pbyData[6] = (u8)(qwTSFOffset >> 48); - pbyData[7] = (u8)(qwTSFOffset >> 56); + tsf_offset = CARDqGetTSFOffset(rx_rate, time_stamp, local_tsf); - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_SET_TSFTBTT, - MESSAGE_REQUEST_TSF, - 0, - 8, - pbyData - ); + data[0] = (u8)tsf_offset; + data[1] = (u8)(tsf_offset >> 8); + data[2] = (u8)(tsf_offset >> 16); + data[3] = (u8)(tsf_offset >> 24); + data[4] = (u8)(tsf_offset >> 32); + data[5] = (u8)(tsf_offset >> 40); + data[6] = (u8)(tsf_offset >> 48); + data[7] = (u8)(tsf_offset >> 56); + CONTROLnsRequestOut(priv, MESSAGE_TYPE_SET_TSFTBTT, + MESSAGE_REQUEST_TSF, 0, 8, data); } /* * Description: Read NIC TSF counter -- cgit v1.2.3 From 2092dfa4ef9ca6e72aaad4d4ee31c6bae747e9c7 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 24 May 2014 14:37:02 +0100 Subject: staging: vt6656: CARDbGetCurrentTSF remove camel case pDevice -> priv pqwCurrTSF -> current_tsf Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/card.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index 4b0b3efd56ba..b904b2011e80 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -615,17 +615,17 @@ void CARDvAdjustTSF(struct vnt_private *priv, u8 rx_rate, * * Parameters: * In: - * pDevice - The adapter to be read + * priv - The adapter to be read * Out: - * qwCurrTSF - Current TSF counter + * current_tsf - Current TSF counter * * Return Value: true if success; otherwise false * */ -bool CARDbGetCurrentTSF(struct vnt_private *pDevice, u64 *pqwCurrTSF) +bool CARDbGetCurrentTSF(struct vnt_private *priv, u64 *current_tsf) { - *pqwCurrTSF = pDevice->qwCurrTSF; + *current_tsf = priv->qwCurrTSF; return true; } -- cgit v1.2.3 From e151e478fdebfc890195ec472b5bf030612430ce Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 24 May 2014 14:37:03 +0100 Subject: staging: vt6656: CARDbClearCurrentTSF remove camel case pDevice -> priv Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/card.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index b904b2011e80..bb06f59e37b7 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -636,17 +636,17 @@ bool CARDbGetCurrentTSF(struct vnt_private *priv, u64 *current_tsf) * * Parameters: * In: - * pDevice - The adapter to be read + * priv - The adapter to be read * * Return Value: true if success; otherwise false * */ -bool CARDbClearCurrentTSF(struct vnt_private *pDevice) +bool CARDbClearCurrentTSF(struct vnt_private *priv) { - MACvRegBitsOn(pDevice, MAC_REG_TFTCTL, TFTCTL_TSFCNTRST); + MACvRegBitsOn(priv, MAC_REG_TFTCTL, TFTCTL_TSFCNTRST); - pDevice->qwCurrTSF = 0; + priv->qwCurrTSF = 0; return true; } -- cgit v1.2.3 From 5f4dfb66e6afdfa3d6e2a4a104b91c891dd41efe Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 24 May 2014 14:37:04 +0100 Subject: staging: vt6656: CARDqGetNextTBTT remove camel case qwTSF -> tsf wBeaconInterval -> beacon_interval uBeaconInterval -> beacon_int Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/card.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index bb06f59e37b7..3ed218a9a472 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -657,30 +657,30 @@ bool CARDbClearCurrentTSF(struct vnt_private *priv) * * Parameters: * In: - * qwTSF - Current TSF counter - * wbeaconInterval - Beacon Interval + * tsf - Current TSF counter + * beacon_interval - Beacon Interval * Out: - * qwCurrTSF - Current TSF counter + * tsf - Current TSF counter * * Return Value: TSF value of next Beacon * */ -u64 CARDqGetNextTBTT(u64 qwTSF, u16 wBeaconInterval) +u64 CARDqGetNextTBTT(u64 tsf, u16 beacon_interval) { - u32 uBeaconInterval; + u32 beacon_int; - uBeaconInterval = wBeaconInterval * 1024; + beacon_int = beacon_interval * 1024; /* Next TBTT = * ((local_current_TSF / beacon_interval) + 1) * beacon_interval */ - if (uBeaconInterval) { - do_div(qwTSF, uBeaconInterval); - qwTSF += 1; - qwTSF *= uBeaconInterval; + if (beacon_int) { + do_div(tsf, beacon_int); + tsf += 1; + tsf *= beacon_int; } - return qwTSF; + return tsf; } /* -- cgit v1.2.3 From 414475f6fd843b01e0656947e451b208ab2d1e4d Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 24 May 2014 14:37:05 +0100 Subject: staging: vt6656: camel case and clean up CARDvSetFirstNextTBTT camel case changes pDevice -> priv wBeaconInterval -> beacon_interval qwNextTBTT -> next_tbtt pbyData -> data Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/card.c | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index 3ed218a9a472..b73b1b841b43 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -690,41 +690,35 @@ u64 CARDqGetNextTBTT(u64 tsf, u16 beacon_interval) * Parameters: * In: * dwIoBase - IO Base - * wBeaconInterval - Beacon Interval + * beacon_interval - Beacon Interval * Out: * none * * Return Value: none * */ -void CARDvSetFirstNextTBTT(struct vnt_private *pDevice, u16 wBeaconInterval) +void CARDvSetFirstNextTBTT(struct vnt_private *priv, u16 beacon_interval) { - u64 qwNextTBTT = 0; - u8 pbyData[8]; + u64 next_tbtt = 0; + u8 data[8]; - CARDbClearCurrentTSF(pDevice); - //CARDbGetCurrentTSF(pDevice, &qwNextTBTT); //Get Local TSF counter - qwNextTBTT = CARDqGetNextTBTT(qwNextTBTT, wBeaconInterval); - // Set NextTBTT + CARDbClearCurrentTSF(priv); - pbyData[0] = (u8)qwNextTBTT; - pbyData[1] = (u8)(qwNextTBTT >> 8); - pbyData[2] = (u8)(qwNextTBTT >> 16); - pbyData[3] = (u8)(qwNextTBTT >> 24); - pbyData[4] = (u8)(qwNextTBTT >> 32); - pbyData[5] = (u8)(qwNextTBTT >> 40); - pbyData[6] = (u8)(qwNextTBTT >> 48); - pbyData[7] = (u8)(qwNextTBTT >> 56); + next_tbtt = CARDqGetNextTBTT(next_tbtt, beacon_interval); - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_SET_TSFTBTT, - MESSAGE_REQUEST_TBTT, - 0, - 8, - pbyData - ); + data[0] = (u8)next_tbtt; + data[1] = (u8)(next_tbtt >> 8); + data[2] = (u8)(next_tbtt >> 16); + data[3] = (u8)(next_tbtt >> 24); + data[4] = (u8)(next_tbtt >> 32); + data[5] = (u8)(next_tbtt >> 40); + data[6] = (u8)(next_tbtt >> 48); + data[7] = (u8)(next_tbtt >> 56); - return; + CONTROLnsRequestOut(priv, MESSAGE_TYPE_SET_TSFTBTT, + MESSAGE_REQUEST_TBTT, 0, 8, data); + + return; } /* -- cgit v1.2.3 From 8b515de7a762d2456b6f0a0791ce4d7abb8c8f5d Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 24 May 2014 14:37:06 +0100 Subject: staging: vt6656: camel case clean up CARDvUpdateNextTBTT camel case changes pDevice -> priv qwTSF -> tsf wBeaconInterval -> beacon_interval pbyData -> data Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/card.c | 45 ++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index b73b1b841b43..09b6de5286ad 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -727,45 +727,38 @@ void CARDvSetFirstNextTBTT(struct vnt_private *priv, u16 beacon_interval) * * Parameters: * In: - * pDevice - The adapter to be set - * qwTSF - Current TSF counter - * wBeaconInterval - Beacon Interval + * priv - The adapter to be set + * tsf - Current TSF counter + * beacon_interval - Beacon Interval * Out: * none * * Return Value: none * */ -void CARDvUpdateNextTBTT(struct vnt_private *pDevice, u64 qwTSF, - u16 wBeaconInterval) +void CARDvUpdateNextTBTT(struct vnt_private *priv, u64 tsf, + u16 beacon_interval) { - u8 pbyData[8]; - - qwTSF = CARDqGetNextTBTT(qwTSF, wBeaconInterval); + u8 data[8]; - // Set NextTBTT + tsf = CARDqGetNextTBTT(tsf, beacon_interval); - pbyData[0] = (u8)qwTSF; - pbyData[1] = (u8)(qwTSF >> 8); - pbyData[2] = (u8)(qwTSF >> 16); - pbyData[3] = (u8)(qwTSF >> 24); - pbyData[4] = (u8)(qwTSF >> 32); - pbyData[5] = (u8)(qwTSF >> 40); - pbyData[6] = (u8)(qwTSF >> 48); - pbyData[7] = (u8)(qwTSF >> 56); + data[0] = (u8)tsf; + data[1] = (u8)(tsf >> 8); + data[2] = (u8)(tsf >> 16); + data[3] = (u8)(tsf >> 24); + data[4] = (u8)(tsf >> 32); + data[5] = (u8)(tsf >> 40); + data[6] = (u8)(tsf >> 48); + data[7] = (u8)(tsf >> 56); - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_SET_TSFTBTT, - MESSAGE_REQUEST_TBTT, - 0, - 8, - pbyData - ); + CONTROLnsRequestOut(priv, MESSAGE_TYPE_SET_TSFTBTT, + MESSAGE_REQUEST_TBTT, 0, 8, data); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "Card:Update Next TBTT[%8lx]\n", (unsigned long)qwTSF); + "Card:Update Next TBTT[%8lx]\n", (unsigned long)tsf); - return; + return; } /* -- cgit v1.2.3 From 07deb71093f44d350772e98d5008367d0bfd808c Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 24 May 2014 14:37:07 +0100 Subject: staging: vt6656: camel case clean up CARDbRadioPowerOff camel case changes pDevice -> priv bResult -> ret Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/card.c | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index 09b6de5286ad..2635cf725ad4 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -766,38 +766,36 @@ void CARDvUpdateNextTBTT(struct vnt_private *priv, u64 tsf, * * Parameters: * In: - * pDevice - The adapter to be turned off + * priv - The adapter to be turned off * Out: * none * * Return Value: true if success; otherwise false * */ -int CARDbRadioPowerOff(struct vnt_private *pDevice) +int CARDbRadioPowerOff(struct vnt_private *priv) { - int bResult = true; - - //if (pDevice->bRadioOff == true) - // return true; - - pDevice->bRadioOff = true; - - switch (pDevice->byRFType) { - case RF_AL2230: - case RF_AL2230S: - case RF_AIROHA7230: - case RF_VT3226: //RobertYu:20051111 - case RF_VT3226D0: - case RF_VT3342A0: //RobertYu:20060609 - MACvRegBitsOff(pDevice, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3)); - break; - } + int ret = true; + + priv->bRadioOff = true; + + switch (priv->byRFType) { + case RF_AL2230: + case RF_AL2230S: + case RF_AIROHA7230: + case RF_VT3226: + case RF_VT3226D0: + case RF_VT3342A0: + MACvRegBitsOff(priv, MAC_REG_SOFTPWRCTL, + (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3)); + break; + } - MACvRegBitsOff(pDevice, MAC_REG_HOSTCR, HOSTCR_RXON); + MACvRegBitsOff(priv, MAC_REG_HOSTCR, HOSTCR_RXON); - BBvSetDeepSleep(pDevice); + BBvSetDeepSleep(priv); - return bResult; + return ret; } /* -- cgit v1.2.3 From f320314435163773a03a33ca533ba9dd926c376b Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 24 May 2014 14:37:08 +0100 Subject: staging: vt6656: camel case clean up CARDbRadioPowerOn camel case changes pDevice -> priv bResult -> ret Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/card.c | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index 2635cf725ad4..3d417095b934 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -803,42 +803,39 @@ int CARDbRadioPowerOff(struct vnt_private *priv) * * Parameters: * In: - * pDevice - The adapter to be turned on + * priv - The adapter to be turned on * Out: * none * * Return Value: true if success; otherwise false * */ -int CARDbRadioPowerOn(struct vnt_private *pDevice) +int CARDbRadioPowerOn(struct vnt_private *priv) { - int bResult = true; - - if ((pDevice->bHWRadioOff == true) || (pDevice->bRadioControlOff == true)) { - return false; - } + int ret = true; - //if (pDevice->bRadioOff == false) - // return true; + if (priv->bHWRadioOff == true || priv->bRadioControlOff == true) + return false; - pDevice->bRadioOff = false; + priv->bRadioOff = false; - BBvExitDeepSleep(pDevice); + BBvExitDeepSleep(priv); - MACvRegBitsOn(pDevice, MAC_REG_HOSTCR, HOSTCR_RXON); + MACvRegBitsOn(priv, MAC_REG_HOSTCR, HOSTCR_RXON); - switch (pDevice->byRFType) { - case RF_AL2230: - case RF_AL2230S: - case RF_AIROHA7230: - case RF_VT3226: //RobertYu:20051111 - case RF_VT3226D0: - case RF_VT3342A0: //RobertYu:20060609 - MACvRegBitsOn(pDevice, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3)); - break; - } + switch (priv->byRFType) { + case RF_AL2230: + case RF_AL2230S: + case RF_AIROHA7230: + case RF_VT3226: + case RF_VT3226D0: + case RF_VT3342A0: + MACvRegBitsOn(priv, MAC_REG_SOFTPWRCTL, + (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3)); + break; + } - return bResult; + return ret; } void CARDvSetBSSMode(struct vnt_private *pDevice) -- cgit v1.2.3 From 1efb8facf805c75596903068622fd77bfd271b3e Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 24 May 2014 14:37:09 +0100 Subject: staging: vt6656: camel case and clean up CARDvSetBSSMode camel case changes pDevice -> priv Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/card.c | 80 +++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 41 deletions(-) diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index 3d417095b934..5a65f75c5335 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -838,46 +838,44 @@ int CARDbRadioPowerOn(struct vnt_private *priv) return ret; } -void CARDvSetBSSMode(struct vnt_private *pDevice) +void CARDvSetBSSMode(struct vnt_private *priv) { - // Set BB and packet type at the same time.//{{RobertYu:20050222, AL7230 have two TX PA output, only connet to b/g now - // so in 11a mode need to set the MAC Reg0x4C to 11b/g mode to turn on PA - if( (pDevice->byRFType == RF_AIROHA7230 ) && (pDevice->byBBType == BB_TYPE_11A) ) - { - MACvSetBBType(pDevice, BB_TYPE_11G); - } - else - { - MACvSetBBType(pDevice, pDevice->byBBType); - } - pDevice->byPacketType = CARDbyGetPktType(pDevice); - - if (pDevice->byBBType == BB_TYPE_11A) { - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, 0x03); - } else if (pDevice->byBBType == BB_TYPE_11B) { - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, 0x02); - } else if (pDevice->byBBType == BB_TYPE_11G) { - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, 0x08); - } - - vUpdateIFS(pDevice); - CARDvSetRSPINF(pDevice, (u8)pDevice->byBBType); - - if ( pDevice->byBBType == BB_TYPE_11A ) { - //request by Jack 2005-04-26 - if (pDevice->byRFType == RF_AIROHA7230) { - pDevice->abyBBVGA[0] = 0x20; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xE7, pDevice->abyBBVGA[0]); - } - pDevice->abyBBVGA[2] = 0x10; - pDevice->abyBBVGA[3] = 0x10; - } else { - //request by Jack 2005-04-26 - if (pDevice->byRFType == RF_AIROHA7230) { - pDevice->abyBBVGA[0] = 0x1C; - ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xE7, pDevice->abyBBVGA[0]); - } - pDevice->abyBBVGA[2] = 0x0; - pDevice->abyBBVGA[3] = 0x0; - } + if (priv->byRFType == RF_AIROHA7230 && priv->byBBType == BB_TYPE_11A) + MACvSetBBType(priv, BB_TYPE_11G); + else + MACvSetBBType(priv, priv->byBBType); + + priv->byPacketType = CARDbyGetPktType(priv); + + if (priv->byBBType == BB_TYPE_11A) + ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0x88, 0x03); + else if (priv->byBBType == BB_TYPE_11B) + ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0x88, 0x02); + else if (priv->byBBType == BB_TYPE_11G) + ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0x88, 0x08); + + vUpdateIFS(priv); + CARDvSetRSPINF(priv, (u8)priv->byBBType); + + if (priv->byBBType == BB_TYPE_11A) { + if (priv->byRFType == RF_AIROHA7230) { + priv->abyBBVGA[0] = 0x20; + + ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, + 0xe7, priv->abyBBVGA[0]); + } + + priv->abyBBVGA[2] = 0x10; + priv->abyBBVGA[3] = 0x10; + } else { + if (priv->byRFType == RF_AIROHA7230) { + priv->abyBBVGA[0] = 0x1c; + + ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, + 0xe7, priv->abyBBVGA[0]); + } + + priv->abyBBVGA[2] = 0x0; + priv->abyBBVGA[3] = 0x0; + } } -- cgit v1.2.3 From fd4859f61b002270cd38e1ea5c81f1c6c7be9236 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 24 May 2014 14:37:10 +0100 Subject: staging: vt6656: CARDvCalculateOFDMRParameter fix indentation rsv_time In patch staging: vt6656 camel case clean up CARDvCalculateOFDMRParameter rsv_time is indented incorrectly. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/card.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index 5a65f75c5335..ce069c9db854 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -256,7 +256,7 @@ void CARDvCalculateOFDMRParameter(u16 rate, u8 bb_type, *rsv_time = 4; } else { *tx_rate = 0x88; - *rsv_time = 10; + *rsv_time = 10; } break; case RATE_54M: -- cgit v1.2.3 From 2d53426be7dabb8a43b633fee85738fd01432884 Mon Sep 17 00:00:00 2001 From: Dominique van den Broeck Date: Sat, 24 May 2014 01:35:24 +0200 Subject: staging: panel: (coding style) Multiple assignments Style-only modifications to comply with checkpatch.pl --strict --file. . Breaks down compound assignments. Signed-off-by: Dominique van den Broeck Signed-off-by: Greg Kroah-Hartman --- drivers/staging/panel/panel.c | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c index 0cc5e084653a..4e9229363c36 100644 --- a/drivers/staging/panel/panel.c +++ b/drivers/staging/panel/panel.c @@ -664,8 +664,12 @@ static void pin_to_bits(int pin, unsigned char *d_val, unsigned char *c_val) { int d_bit, c_bit, inv; - d_val[0] = c_val[0] = d_val[1] = c_val[1] = 0; - d_val[2] = c_val[2] = 0xFF; + d_val[0] = 0; + c_val[0] = 0; + d_val[1] = 0; + c_val[1] = 0; + d_val[2] = 0xFF; + c_val[2] = 0xFF; if (pin == 0) return; @@ -674,7 +678,8 @@ static void pin_to_bits(int pin, unsigned char *d_val, unsigned char *c_val) if (inv) pin = -pin; - d_bit = c_bit = 0; + d_bit = 0; + c_bit = 0; switch (pin) { case PIN_STROBE: /* strobe, inverted */ @@ -867,7 +872,8 @@ static void lcd_clear_fast_s(void) { int pos; - lcd_addr_x = lcd_addr_y = 0; + lcd_addr_x = 0; + lcd_addr_y = 0; lcd_gotoxy(); spin_lock_irq(&pprt_lock); @@ -879,7 +885,8 @@ static void lcd_clear_fast_s(void) } spin_unlock_irq(&pprt_lock); - lcd_addr_x = lcd_addr_y = 0; + lcd_addr_x = 0; + lcd_addr_y = 0; lcd_gotoxy(); } @@ -888,7 +895,8 @@ static void lcd_clear_fast_p8(void) { int pos; - lcd_addr_x = lcd_addr_y = 0; + lcd_addr_x = 0; + lcd_addr_y = 0; lcd_gotoxy(); spin_lock_irq(&pprt_lock); @@ -915,7 +923,8 @@ static void lcd_clear_fast_p8(void) } spin_unlock_irq(&pprt_lock); - lcd_addr_x = lcd_addr_y = 0; + lcd_addr_x = 0; + lcd_addr_y = 0; lcd_gotoxy(); } @@ -924,7 +933,8 @@ static void lcd_clear_fast_tilcd(void) { int pos; - lcd_addr_x = lcd_addr_y = 0; + lcd_addr_x = 0; + lcd_addr_y = 0; lcd_gotoxy(); spin_lock_irq(&pprt_lock); @@ -936,7 +946,8 @@ static void lcd_clear_fast_tilcd(void) spin_unlock_irq(&pprt_lock); - lcd_addr_x = lcd_addr_y = 0; + lcd_addr_x = 0; + lcd_addr_y = 0; lcd_gotoxy(); } @@ -944,7 +955,8 @@ static void lcd_clear_fast_tilcd(void) static void lcd_clear_display(void) { lcd_write_cmd(0x01); /* clear display */ - lcd_addr_x = lcd_addr_y = 0; + lcd_addr_x = 0; + lcd_addr_y = 0; /* we must wait a few milliseconds (15) */ long_sleep(15); } @@ -1292,7 +1304,8 @@ static void lcd_write_char(char c) processed = 1; } else if (!strcmp(lcd_escape, "[H")) { /* cursor to home */ - lcd_addr_x = lcd_addr_y = 0; + lcd_addr_x = 0; + lcd_addr_y = 0; lcd_gotoxy(); processed = 1; } @@ -1576,7 +1589,8 @@ static void lcd_init(void) panel_lcd_print("\x1b[Lc\x1b[Lb\x1b[L*Linux-" UTS_RELEASE "\nPanel-" PANEL_VERSION); #endif - lcd_addr_x = lcd_addr_y = 0; + lcd_addr_x = 0; + lcd_addr_y = 0; /* clear the display on the next device opening */ lcd_must_clear = 1; lcd_gotoxy(); @@ -1953,7 +1967,10 @@ static int input_name2mask(const char *name, pmask_t *mask, pmask_t *value, char im, om; pmask_t m, v; - om = im = m = v = 0ULL; + om = 0ULL; + im = 0ULL; + m = 0ULL; + v = 0ULL; while (*name) { int in, out, bit, neg; -- cgit v1.2.3 From ffd07de65ef5315053ea16356cd533b7f47c17e9 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Fri, 23 May 2014 17:16:53 -0700 Subject: staging/mt29f_spinand: Terminate of match table Failure to terminate this match table can lead to boot failures depending on where the compiler places the match table. Cc: Kamlakant Patel Cc: Mona Anonuevo Cc: linux-mtd@lists.infradead.org Signed-off-by: Stephen Boyd Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt29f_spinand/mt29f_spinand.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/mt29f_spinand/mt29f_spinand.c b/drivers/staging/mt29f_spinand/mt29f_spinand.c index 51dbc13e757f..5a40925680ac 100644 --- a/drivers/staging/mt29f_spinand/mt29f_spinand.c +++ b/drivers/staging/mt29f_spinand/mt29f_spinand.c @@ -924,6 +924,7 @@ static int spinand_remove(struct spi_device *spi) static const struct of_device_id spinand_dt[] = { { .compatible = "spinand,mt29f", }, + {} }; /* -- cgit v1.2.3 From 35b8dfd411f9162647717b018569471656460267 Mon Sep 17 00:00:00 2001 From: Greg DeAngelis Date: Fri, 23 May 2014 23:09:11 -0400 Subject: staging: lustre: Fixed warnings about using 0 as NULL ptr Fixed a bunch of warnings pointed out by sparse about using 0 to represent a NULL pointer. Signed-off-by: Greg DeAngelis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/mgc/lproc_mgc.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c index 1506af13f1bf..6c877c5a6a71 100644 --- a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c +++ b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c @@ -56,21 +56,21 @@ static int mgc_ir_state_seq_show(struct seq_file *m, void *v) LPROC_SEQ_FOPS_RO(mgc_ir_state); static struct lprocfs_vars lprocfs_mgc_obd_vars[] = { - { "uuid", &mgc_uuid_fops, 0, 0 }, - { "ping", &mgc_ping_fops, 0, 0222 }, - { "connect_flags", &mgc_connect_flags_fops, 0, 0 }, - { "mgs_server_uuid", &mgc_server_uuid_fops, 0, 0 }, - { "mgs_conn_uuid", &mgc_conn_uuid_fops, 0, 0 }, - { "import", &mgc_import_fops, 0, 0 }, - { "state", &mgc_state_fops, 0, 0 }, - { "ir_state", &mgc_ir_state_fops, 0, 0 }, - { 0 } + { "uuid", &mgc_uuid_fops, NULL, 0 }, + { "ping", &mgc_ping_fops, NULL, 0222 }, + { "connect_flags", &mgc_connect_flags_fops, NULL, 0 }, + { "mgs_server_uuid", &mgc_server_uuid_fops, NULL, 0 }, + { "mgs_conn_uuid", &mgc_conn_uuid_fops, NULL, 0 }, + { "import", &mgc_import_fops, NULL, 0 }, + { "state", &mgc_state_fops, NULL, 0 }, + { "ir_state", &mgc_ir_state_fops, NULL, 0 }, + { NULL } }; LPROC_SEQ_FOPS_RO_TYPE(mgc, numrefs); static struct lprocfs_vars lprocfs_mgc_module_vars[] = { - { "num_refs", &mgc_numrefs_fops, 0, 0 }, - { 0 } + { "num_refs", &mgc_numrefs_fops, NULL, 0 }, + { NULL } }; void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars) -- cgit v1.2.3 From 17dd4338f37634bcd28aeba988734eeccca46538 Mon Sep 17 00:00:00 2001 From: David Matlack Date: Fri, 23 May 2014 21:04:54 -0700 Subject: staging: slicoss: remove private netdev list Remove the private linked list of netdev structs. This list isn't being used anyway. This patch has no noticable effect. Signed-off-by: David Matlack Signed-off-by: Greg Kroah-Hartman --- drivers/staging/slicoss/slic.h | 1 - drivers/staging/slicoss/slicoss.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h index 15a24c024d22..3a5aa882b957 100644 --- a/drivers/staging/slicoss/slic.h +++ b/drivers/staging/slicoss/slic.h @@ -401,7 +401,6 @@ struct adapter { uint card_size; uint chipid; struct net_device *netdev; - struct net_device *next_netdevice; struct slic_spinlock adapter_lock; struct slic_spinlock reset_lock; struct pci_dev *pcidev; diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index 86dd47210f96..6cb1a0affba8 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -104,8 +104,6 @@ static char *slic_banner = "Alacritech SLIC Technology(tm) Server " static char *slic_proc_version = "2.0.351 2006/07/14 12:26:00"; -static struct net_device *head_netdevice; - static struct base_driver slic_global = { {}, 0, 0, 0, 1, NULL, NULL }; static int intagg_delay = 100; static u32 dynamic_intagg; @@ -2918,8 +2916,6 @@ static void slic_init_adapter(struct net_device *netdev, adapter->slic_regs = (__iomem struct slic_regs *)memaddr; adapter->irq = pcidev->irq; /* adapter->netdev = netdev;*/ - adapter->next_netdevice = head_netdevice; - head_netdevice = netdev; adapter->chipid = chip_idx; adapter->port = 0; /*adapter->functionnumber;*/ adapter->cardindex = adapter->port; -- cgit v1.2.3 From 811e843ddf9a6583b5c7b45f700fdc92aad24d06 Mon Sep 17 00:00:00 2001 From: David Matlack Date: Fri, 23 May 2014 21:04:55 -0700 Subject: staging: slicoss: clean up use of dev_err First, don't print pci device information or driver prefixes, this is already printed by dev_err. Next, don't report error messages via dev_err when the failing function already reports all errors via dev_err. Signed-off-by: David Matlack Signed-off-by: Greg Kroah-Hartman --- drivers/staging/slicoss/slicoss.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index 6cb1a0affba8..48841e7c2f74 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -395,7 +395,7 @@ static int slic_card_download_gbrcv(struct adapter *adapter) ret = request_firmware(&fw, file, &adapter->pcidev->dev); if (ret) { dev_err(&adapter->pcidev->dev, - "SLICOSS: Failed to load firmware %s\n", file); + "Failed to load firmware %s\n", file); return ret; } @@ -473,7 +473,7 @@ static int slic_card_download(struct adapter *adapter) ret = request_firmware(&fw, file, &adapter->pcidev->dev); if (ret) { dev_err(&adapter->pcidev->dev, - "SLICOSS: Failed to load firmware %s\n", file); + "Failed to load firmware %s\n", file); return ret; } numsects = *(u32 *)(fw->data + index); @@ -2699,13 +2699,8 @@ static int slic_card_init(struct sliccard *card, struct adapter *adapter) /* Download the microcode */ status = slic_card_download(adapter); - - if (status != 0) { - dev_err(&adapter->pcidev->dev, - "download failed bus %d slot %d\n", - adapter->busnumber, adapter->slotnumber); + if (status) return status; - } if (!card->config_set) { peeprom = pci_alloc_consistent(adapter->pcidev, @@ -2717,8 +2712,7 @@ static int slic_card_init(struct sliccard *card, struct adapter *adapter) if (!peeprom) { dev_err(&adapter->pcidev->dev, - "eeprom read failed to get memory bus %d slot %d\n", adapter->busnumber, - adapter->slotnumber); + "Failed to allocate DMA memory for EEPROM.\n"); return -ENOMEM; } else { memset(peeprom, 0, sizeof(struct slic_eeprom)); @@ -2767,8 +2761,7 @@ static int slic_card_init(struct sliccard *card, struct adapter *adapter) i++; if (i > 5000) { dev_err(&adapter->pcidev->dev, - "%d config data fetch timed out!\n", - adapter->port); + "Fetch of config data timed out.\n"); slic_reg64_write(adapter, &slic_regs->slic_isp, 0, &slic_regs->slic_addr_upper, @@ -2851,19 +2844,16 @@ static int slic_card_init(struct sliccard *card, struct adapter *adapter) slic_reg64_write(adapter, &slic_regs->slic_isp, 0, &slic_regs->slic_addr_upper, 0, FLUSH); - dev_err(&adapter->pcidev->dev, - "unsupported CONFIGURATION EEPROM invalid\n"); + dev_err(&adapter->pcidev->dev, "EEPROM invalid.\n"); return -EINVAL; } card->config_set = 1; } - if (slic_card_download_gbrcv(adapter)) { - dev_err(&adapter->pcidev->dev, - "unable to download GB receive microcode\n"); - return -EINVAL; - } + status = slic_card_download_gbrcv(adapter); + if (status) + return status; if (slic_global.dynamic_intagg) slic_intagg_set(adapter, 0); -- cgit v1.2.3 From 91d435fe368ab30702d7bcd50f680e7185899295 Mon Sep 17 00:00:00 2001 From: Vitaly Osipov Date: Sat, 24 May 2014 18:19:27 +1000 Subject: staging: rtl8712: remove _malloc() This patch removes all usage of _malloc() and the function itself. Most uses are straightforward replacements by kmalloc(..., GFP_ATOMIC), because this was the definition of _malloc(). In a few places it was possible to use kzalloc() or memdup_user. A further improvement would be to replace GFP_ATOMIC with GFP_KERNEL where possible. Verified by compilation only. Initial replacement done by running a Coccinelle script along the lines of: @@ type T; expression E; identifier V; @@ - V = (T) _malloc(E); + V = kmalloc(E, GFP_ATOMIC); @@ expression E, E1; @@ - E1 = _malloc(E); + E1 = kmalloc(E, GFP_ATOMIC); Signed-off-by: Vitaly Osipov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/hal_init.c | 2 +- drivers/staging/rtl8712/mlme_linux.c | 3 +- drivers/staging/rtl8712/osdep_service.h | 5 -- drivers/staging/rtl8712/rtl8712_recv.c | 6 +- drivers/staging/rtl8712/rtl871x_cmd.c | 123 +++++++++++--------------- drivers/staging/rtl8712/rtl871x_io.c | 11 +-- drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 35 +++----- drivers/staging/rtl8712/rtl871x_mlme.c | 17 ++-- drivers/staging/rtl8712/rtl871x_mp.c | 10 +-- drivers/staging/rtl8712/rtl871x_recv.c | 6 +- drivers/staging/rtl8712/rtl871x_sta_mgt.c | 4 +- drivers/staging/rtl8712/rtl871x_xmit.c | 16 ++-- drivers/staging/rtl8712/usb_ops_linux.c | 2 +- 13 files changed, 102 insertions(+), 138 deletions(-) diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c index d801c5af006a..36de7e478f32 100644 --- a/drivers/staging/rtl8712/hal_init.c +++ b/drivers/staging/rtl8712/hal_init.c @@ -183,7 +183,7 @@ static u8 rtl8712_dl_fw(struct _adapter *padapter) maxlen = (fwhdr.img_IMEM_size > fwhdr.img_SRAM_size) ? fwhdr.img_IMEM_size : fwhdr.img_SRAM_size; maxlen += txdscp_sz; - ptmpchar = _malloc(maxlen + FWBUFF_ALIGN_SZ); + ptmpchar = kmalloc(maxlen + FWBUFF_ALIGN_SZ, GFP_ATOMIC); if (ptmpchar == NULL) return ret; diff --git a/drivers/staging/rtl8712/mlme_linux.c b/drivers/staging/rtl8712/mlme_linux.c index f569a7081be5..377efb88676f 100644 --- a/drivers/staging/rtl8712/mlme_linux.c +++ b/drivers/staging/rtl8712/mlme_linux.c @@ -147,10 +147,9 @@ void r8712_report_sec_ie(struct _adapter *adapter, u8 authmode, u8 *sec_ie) buff = NULL; if (authmode == _WPA_IE_ID_) { - buff = _malloc(IW_CUSTOM_MAX); + buff = kzalloc(IW_CUSTOM_MAX, GFP_ATOMIC); if (buff == NULL) return; - memset(buff, 0, IW_CUSTOM_MAX); p = buff; p += sprintf(p, "ASSOCINFO(ReqIEs="); len = sec_ie[1] + 2; diff --git a/drivers/staging/rtl8712/osdep_service.h b/drivers/staging/rtl8712/osdep_service.h index 566235a14a80..09e156199e7f 100644 --- a/drivers/staging/rtl8712/osdep_service.h +++ b/drivers/staging/rtl8712/osdep_service.h @@ -168,11 +168,6 @@ static inline void sleep_schedulable(int ms) return; } -static inline u8 *_malloc(u32 sz) -{ - return kmalloc(sz, GFP_ATOMIC); -} - static inline unsigned char _cancel_timer_ex(struct timer_list *ptimer) { return del_timer(ptimer); diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c index 667398a67370..1f700171af13 100644 --- a/drivers/staging/rtl8712/rtl8712_recv.c +++ b/drivers/staging/rtl8712/rtl8712_recv.c @@ -58,12 +58,10 @@ int r8712_init_recv_priv(struct recv_priv *precvpriv, struct _adapter *padapter) /*init recv_buf*/ _init_queue(&precvpriv->free_recv_buf_queue); - precvpriv->pallocated_recv_buf = _malloc(NR_RECVBUFF * - sizeof(struct recv_buf) + 4); + precvpriv->pallocated_recv_buf = kzalloc(NR_RECVBUFF * sizeof(struct recv_buf) + 4, + GFP_ATOMIC); if (precvpriv->pallocated_recv_buf == NULL) return _FAIL; - memset(precvpriv->pallocated_recv_buf, 0, NR_RECVBUFF * - sizeof(struct recv_buf) + 4); precvpriv->precv_buf = precvpriv->pallocated_recv_buf + 4 - ((addr_t) (precvpriv->pallocated_recv_buf) & 3); precvbuf = (struct recv_buf *)precvpriv->precv_buf; diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index a67185db392b..6a3cecc8a09b 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -64,13 +64,14 @@ static sint _init_cmd_priv(struct cmd_priv *pcmdpriv) /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */ pcmdpriv->cmd_seq = 1; - pcmdpriv->cmd_allocated_buf = _malloc(MAX_CMDSZ + CMDBUFF_ALIGN_SZ); + pcmdpriv->cmd_allocated_buf = kmalloc(MAX_CMDSZ + CMDBUFF_ALIGN_SZ, + GFP_ATOMIC); if (pcmdpriv->cmd_allocated_buf == NULL) return _FAIL; pcmdpriv->cmd_buf = pcmdpriv->cmd_allocated_buf + CMDBUFF_ALIGN_SZ - ((addr_t)(pcmdpriv->cmd_allocated_buf) & (CMDBUFF_ALIGN_SZ-1)); - pcmdpriv->rsp_allocated_buf = _malloc(MAX_RSPSZ + 4); + pcmdpriv->rsp_allocated_buf = kmalloc(MAX_RSPSZ + 4, GFP_ATOMIC); if (pcmdpriv->rsp_allocated_buf == NULL) return _FAIL; pcmdpriv->rsp_buf = pcmdpriv->rsp_allocated_buf + 4 - @@ -85,7 +86,7 @@ static sint _init_evt_priv(struct evt_priv *pevtpriv) { /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */ pevtpriv->event_seq = 0; - pevtpriv->evt_allocated_buf = _malloc(MAX_EVTSZ + 4); + pevtpriv->evt_allocated_buf = kmalloc(MAX_EVTSZ + 4, GFP_ATOMIC); if (pevtpriv->evt_allocated_buf == NULL) return _FAIL; @@ -226,11 +227,10 @@ u8 r8712_sitesurvey_cmd(struct _adapter *padapter, struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + ph2c = kmalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ph2c == NULL) return _FAIL; - psurveyPara = (struct sitesurvey_parm *)_malloc( - sizeof(struct sitesurvey_parm)); + psurveyPara = kmalloc(sizeof(struct sitesurvey_parm), GFP_ATOMIC); if (psurveyPara == NULL) { kfree((unsigned char *) ph2c); return _FAIL; @@ -259,11 +259,11 @@ u8 r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset) struct setdatarate_parm *pbsetdataratepara; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + ph2c = kmalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ph2c == NULL) return _FAIL; - pbsetdataratepara = (struct setdatarate_parm *)_malloc( - sizeof(struct setdatarate_parm)); + pbsetdataratepara = kmalloc(sizeof(struct setdatarate_parm), + GFP_ATOMIC); if (pbsetdataratepara == NULL) { kfree((u8 *) ph2c); return _FAIL; @@ -282,11 +282,11 @@ u8 r8712_set_chplan_cmd(struct _adapter *padapter, int chplan) struct SetChannelPlan_param *psetchplanpara; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + ph2c = kmalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ph2c == NULL) return _FAIL; - psetchplanpara = (struct SetChannelPlan_param *) - _malloc(sizeof(struct SetChannelPlan_param)); + psetchplanpara = kmalloc(sizeof(struct SetChannelPlan_param), + GFP_ATOMIC); if (psetchplanpara == NULL) { kfree((u8 *) ph2c); return _FAIL; @@ -304,11 +304,11 @@ u8 r8712_setbasicrate_cmd(struct _adapter *padapter, u8 *rateset) struct setbasicrate_parm *pssetbasicratepara; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + ph2c = kmalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ph2c == NULL) return _FAIL; - pssetbasicratepara = (struct setbasicrate_parm *)_malloc( - sizeof(struct setbasicrate_parm)); + pssetbasicratepara = kmalloc(sizeof(struct setbasicrate_parm), + GFP_ATOMIC); if (pssetbasicratepara == NULL) { kfree((u8 *) ph2c); return _FAIL; @@ -327,11 +327,10 @@ u8 r8712_setptm_cmd(struct _adapter *padapter, u8 type) struct writePTM_parm *pwriteptmparm; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + ph2c = kmalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ph2c == NULL) return _FAIL; - pwriteptmparm = (struct writePTM_parm *) - _malloc(sizeof(struct writePTM_parm)); + pwriteptmparm = kmalloc(sizeof(struct writePTM_parm), GFP_ATOMIC); if (pwriteptmparm == NULL) { kfree((u8 *) ph2c); return _FAIL; @@ -348,11 +347,10 @@ u8 r8712_setfwdig_cmd(struct _adapter *padapter, u8 type) struct writePTM_parm *pwriteptmparm; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + ph2c = kmalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ph2c == NULL) return _FAIL; - pwriteptmparm = (struct writePTM_parm *) - _malloc(sizeof(struct setdig_parm)); + pwriteptmparm = kmalloc(sizeof(struct setdig_parm), GFP_ATOMIC); if (pwriteptmparm == NULL) { kfree((u8 *) ph2c); return _FAIL; @@ -369,11 +367,10 @@ u8 r8712_setfwra_cmd(struct _adapter *padapter, u8 type) struct writePTM_parm *pwriteptmparm; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + ph2c = kmalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ph2c == NULL) return _FAIL; - pwriteptmparm = (struct writePTM_parm *) - _malloc(sizeof(struct setra_parm)); + pwriteptmparm = kmalloc(sizeof(struct setra_parm), GFP_ATOMIC); if (pwriteptmparm == NULL) { kfree((u8 *) ph2c); return _FAIL; @@ -390,11 +387,10 @@ u8 r8712_setrfreg_cmd(struct _adapter *padapter, u8 offset, u32 val) struct writeRF_parm *pwriterfparm; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + ph2c = kmalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ph2c == NULL) return _FAIL; - pwriterfparm = (struct writeRF_parm *)_malloc( - sizeof(struct writeRF_parm)); + pwriterfparm = kmalloc(sizeof(struct writeRF_parm), GFP_ATOMIC); if (pwriterfparm == NULL) { kfree((u8 *) ph2c); return _FAIL; @@ -412,10 +408,10 @@ u8 r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 *pval) struct readRF_parm *prdrfparm; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + ph2c = kmalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ph2c == NULL) return _FAIL; - prdrfparm = (struct readRF_parm *)_malloc(sizeof(struct readRF_parm)); + prdrfparm = kmalloc(sizeof(struct readRF_parm), GFP_ATOMIC); if (prdrfparm == NULL) { kfree((u8 *) ph2c); return _FAIL; @@ -456,7 +452,7 @@ u8 r8712_createbss_cmd(struct _adapter *padapter) &padapter->registrypriv.dev_network; padapter->ledpriv.LedControlHandler(padapter, LED_CTL_START_TO_LINK); - pcmd = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + pcmd = kmalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (pcmd == NULL) return _FAIL; _init_listhead(&pcmd->list); @@ -490,7 +486,7 @@ u8 r8712_joinbss_cmd(struct _adapter *padapter, struct wlan_network *pnetwork) network.InfrastructureMode; padapter->ledpriv.LedControlHandler(padapter, LED_CTL_START_TO_LINK); - pcmd = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + pcmd = kmalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (pcmd == NULL) return _FAIL; t_len = sizeof(u32) + 6 * sizeof(unsigned char) + 2 + @@ -628,11 +624,10 @@ u8 r8712_disassoc_cmd(struct _adapter *padapter) /* for sta_mode */ struct disconnect_parm *pdisconnect; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - pdisconnect_cmd = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + pdisconnect_cmd = kmalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (pdisconnect_cmd == NULL) return _FAIL; - pdisconnect = (struct disconnect_parm *)_malloc( - sizeof(struct disconnect_parm)); + pdisconnect = kmalloc(sizeof(struct disconnect_parm), GFP_ATOMIC); if (pdisconnect == NULL) { kfree((u8 *)pdisconnect_cmd); return _FAIL; @@ -651,11 +646,10 @@ u8 r8712_setopmode_cmd(struct _adapter *padapter, struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + ph2c = kmalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ph2c == NULL) return _FAIL; - psetop = (struct setopmode_parm *)_malloc( - sizeof(struct setopmode_parm)); + psetop = kmalloc(sizeof(struct setopmode_parm), GFP_ATOMIC); if (psetop == NULL) { kfree((u8 *) ph2c); return _FAIL; @@ -676,17 +670,15 @@ u8 r8712_setstakey_cmd(struct _adapter *padapter, u8 *psta, u8 unicast_key) struct security_priv *psecuritypriv = &padapter->securitypriv; struct sta_info *sta = (struct sta_info *)psta; - ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + ph2c = kmalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ph2c == NULL) return _FAIL; - psetstakey_para = (struct set_stakey_parm *)_malloc( - sizeof(struct set_stakey_parm)); + psetstakey_para = kmalloc(sizeof(struct set_stakey_parm), GFP_ATOMIC); if (psetstakey_para == NULL) { kfree((u8 *) ph2c); return _FAIL; } - psetstakey_rsp = (struct set_stakey_rsp *)_malloc( - sizeof(struct set_stakey_rsp)); + psetstakey_rsp = kmalloc(sizeof(struct set_stakey_rsp), GFP_ATOMIC); if (psetstakey_rsp == NULL) { kfree((u8 *) ph2c); kfree((u8 *) psetstakey_para); @@ -718,11 +710,10 @@ u8 r8712_setrfintfs_cmd(struct _adapter *padapter, u8 mode) struct setrfintfs_parm *psetrfintfsparm; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + ph2c = kmalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ph2c == NULL) return _FAIL; - psetrfintfsparm = (struct setrfintfs_parm *)_malloc( - sizeof(struct setrfintfs_parm)); + psetrfintfsparm = kmalloc(sizeof(struct setrfintfs_parm), GFP_ATOMIC); if (psetrfintfsparm == NULL) { kfree((unsigned char *) ph2c); return _FAIL; @@ -741,11 +732,10 @@ u8 r8712_setrttbl_cmd(struct _adapter *padapter, struct setratable_parm *psetrttblparm; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + ph2c = kmalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ph2c == NULL) return _FAIL; - psetrttblparm = (struct setratable_parm *)_malloc( - sizeof(struct setratable_parm)); + psetrttblparm = kmalloc(sizeof(struct setratable_parm), GFP_ATOMIC); if (psetrttblparm == NULL) { kfree((unsigned char *)ph2c); return _FAIL; @@ -763,11 +753,10 @@ u8 r8712_gettssi_cmd(struct _adapter *padapter, u8 offset, u8 *pval) struct cmd_obj *ph2c; struct readTSSI_parm *prdtssiparm; - ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + ph2c = kmalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ph2c == NULL) return _FAIL; - prdtssiparm = (struct readTSSI_parm *) - _malloc(sizeof(struct readTSSI_parm)); + prdtssiparm = kmalloc(sizeof(struct readTSSI_parm), GFP_ATOMIC); if (prdtssiparm == NULL) { kfree((unsigned char *) ph2c); return _FAIL; @@ -790,11 +779,11 @@ u8 r8712_setMacAddr_cmd(struct _adapter *padapter, u8 *mac_addr) struct cmd_obj *ph2c; struct SetMacAddr_param *psetMacAddr_para; - ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + ph2c = kmalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ph2c == NULL) return _FAIL; - psetMacAddr_para = (struct SetMacAddr_param *)_malloc( - sizeof(struct SetMacAddr_param)); + psetMacAddr_para = kmalloc(sizeof(struct SetMacAddr_param), + GFP_ATOMIC); if (psetMacAddr_para == NULL) { kfree((u8 *) ph2c); return _FAIL; @@ -813,17 +802,17 @@ u8 r8712_setassocsta_cmd(struct _adapter *padapter, u8 *mac_addr) struct set_assocsta_parm *psetassocsta_para; struct set_assocsta_rsp *psetassocsta_rsp = NULL; - ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + ph2c = kmalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ph2c == NULL) return _FAIL; - psetassocsta_para = (struct set_assocsta_parm *) - _malloc(sizeof(struct set_assocsta_parm)); + psetassocsta_para = kmalloc(sizeof(struct set_assocsta_parm), + GFP_ATOMIC); if (psetassocsta_para == NULL) { kfree((u8 *) ph2c); return _FAIL; } - psetassocsta_rsp = (struct set_assocsta_rsp *)_malloc( - sizeof(struct set_assocsta_rsp)); + psetassocsta_rsp = kmalloc(sizeof(struct set_assocsta_rsp), + GFP_ATOMIC); if (psetassocsta_rsp == NULL) { kfree((u8 *)ph2c); kfree((u8 *)psetassocsta_para); @@ -843,11 +832,10 @@ u8 r8712_addbareq_cmd(struct _adapter *padapter, u8 tid) struct cmd_obj *ph2c; struct addBaReq_parm *paddbareq_parm; - ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + ph2c = kmalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ph2c == NULL) return _FAIL; - paddbareq_parm = (struct addBaReq_parm *)_malloc( - sizeof(struct addBaReq_parm)); + paddbareq_parm = kmalloc(sizeof(struct addBaReq_parm), GFP_ATOMIC); if (paddbareq_parm == NULL) { kfree((unsigned char *)ph2c); return _FAIL; @@ -865,11 +853,10 @@ u8 r8712_wdg_wk_cmd(struct _adapter *padapter) struct drvint_cmd_parm *pdrvintcmd_param; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + ph2c = kmalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ph2c == NULL) return _FAIL; - pdrvintcmd_param = (struct drvint_cmd_parm *)_malloc( - sizeof(struct drvint_cmd_parm)); + pdrvintcmd_param = kmalloc(sizeof(struct drvint_cmd_parm), GFP_ATOMIC); if (pdrvintcmd_param == NULL) { kfree((unsigned char *)ph2c); return _FAIL; @@ -1040,16 +1027,14 @@ u8 r8712_disconnectCtrlEx_cmd(struct _adapter *adapter, u32 enableDrvCtrl, struct DisconnectCtrlEx_param *param; struct cmd_priv *pcmdpriv = &adapter->cmdpriv; - ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + ph2c = kmalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ph2c == NULL) return _FAIL; - param = (struct DisconnectCtrlEx_param *) - _malloc(sizeof(struct DisconnectCtrlEx_param)); + param = kzalloc(sizeof(struct DisconnectCtrlEx_param), GFP_ATOMIC); if (param == NULL) { kfree((unsigned char *) ph2c); return _FAIL; } - memset(param, 0, sizeof(struct DisconnectCtrlEx_param)); param->EnableDrvCtrl = (unsigned char)enableDrvCtrl; param->TryPktCnt = (unsigned char)tryPktCnt; diff --git a/drivers/staging/rtl8712/rtl871x_io.c b/drivers/staging/rtl8712/rtl871x_io.c index abc1c97378f7..37a841a14889 100644 --- a/drivers/staging/rtl8712/rtl871x_io.c +++ b/drivers/staging/rtl8712/rtl871x_io.c @@ -60,8 +60,8 @@ static uint _init_intf_hdl(struct _adapter *padapter, set_intf_funs = &(r8712_usb_set_intf_funs); set_intf_ops = &r8712_usb_set_intf_ops; init_intf_priv = &r8712_usb_init_intf_priv; - pintf_priv = pintf_hdl->pintfpriv = (struct intf_priv *) - _malloc(sizeof(struct intf_priv)); + pintf_priv = pintf_hdl->pintfpriv = kmalloc(sizeof(struct intf_priv), + GFP_ATOMIC); if (pintf_priv == NULL) goto _init_intf_hdl_fail; pintf_hdl->adapter = (u8 *)padapter; @@ -112,15 +112,16 @@ uint r8712_alloc_io_queue(struct _adapter *adapter) struct io_queue *pio_queue; struct io_req *pio_req; - pio_queue = (struct io_queue *)_malloc(sizeof(struct io_queue)); + pio_queue = kmalloc(sizeof(struct io_queue), GFP_ATOMIC); if (pio_queue == NULL) goto alloc_io_queue_fail; _init_listhead(&pio_queue->free_ioreqs); _init_listhead(&pio_queue->processing); _init_listhead(&pio_queue->pending); spin_lock_init(&pio_queue->lock); - pio_queue->pallocated_free_ioreqs_buf = (u8 *)_malloc(NUM_IOREQ * - (sizeof(struct io_req)) + 4); + pio_queue->pallocated_free_ioreqs_buf = kmalloc(NUM_IOREQ * + (sizeof(struct io_req)) + 4, + GFP_ATOMIC); if ((pio_queue->pallocated_free_ioreqs_buf) == NULL) goto alloc_io_queue_fail; memset(pio_queue->pallocated_free_ioreqs_buf, 0, diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c index 1eca992ce066..e147c4bfe124 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c @@ -424,10 +424,9 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, wep_key_idx = 0; if (wep_key_len > 0) { wep_key_len = wep_key_len <= 5 ? 5 : 13; - pwep = (struct NDIS_802_11_WEP *)_malloc((u32) - (wep_key_len + - FIELD_OFFSET(struct NDIS_802_11_WEP, - KeyMaterial))); + pwep = kmalloc((u32)(wep_key_len + + FIELD_OFFSET(struct NDIS_802_11_WEP, KeyMaterial)), + GFP_ATOMIC); if (pwep == NULL) return -ENOMEM; memset(pwep, 0, sizeof(struct NDIS_802_11_WEP)); @@ -518,10 +517,9 @@ static int r871x_set_wpa_ie(struct _adapter *padapter, char *pie, if ((ielen > MAX_WPA_IE_LEN) || (pie == NULL)) return -EINVAL; if (ielen) { - buf = _malloc(ielen); + buf = kmemdup(pie, ielen, GFP_ATOMIC); if (buf == NULL) return -ENOMEM; - memcpy(buf, pie , ielen); pos = buf; if (ielen < RSN_HEADER_LEN) { ret = -EINVAL; @@ -959,13 +957,9 @@ static int r871x_wx_set_priv(struct net_device *dev, struct iw_point *dwrq = (struct iw_point *)awrq; len = dwrq->length; - ext = _malloc(len); - if (!ext) - return -ENOMEM; - if (copy_from_user(ext, dwrq->pointer, len)) { - kfree(ext); - return -EFAULT; - } + ext = memdup_user(dwrq->pointer, len); + if (IS_ERR(ext)) + return PTR_ERR(ext); if (0 == strcasecmp(ext, "RSSI")) { /*Return received signal strength indicator in -db for */ @@ -1819,10 +1813,9 @@ static int r871x_wx_set_enc_ext(struct net_device *dev, } param_len = sizeof(struct ieee_param) + pext->key_len; - param = (struct ieee_param *)_malloc(param_len); + param = kzalloc(param_len, GFP_ATOMIC); if (param == NULL) return -ENOMEM; - memset(param, 0, param_len); param->cmd = IEEE_CMD_SET_ENCRYPTION; memset(param->sta_addr, 0xff, ETH_ALEN); @@ -1922,7 +1915,7 @@ static int r871x_mp_ioctl_hdl(struct net_device *dev, bset = (u8)(p->flags & 0xFFFF); len = p->length; pparmbuf = NULL; - pparmbuf = (u8 *)_malloc(len); + pparmbuf = kmalloc(len, GFP_ATOMIC); if (pparmbuf == NULL) { ret = -ENOMEM; goto _r871x_mp_ioctl_hdl_exit; @@ -2195,13 +2188,9 @@ static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p) if (p->length < sizeof(struct ieee_param) || !p->pointer) return -EINVAL; - param = (struct ieee_param *)_malloc(p->length); - if (param == NULL) - return -ENOMEM; - if (copy_from_user(param, p->pointer, p->length)) { - kfree((u8 *)param); - return -EFAULT; - } + param = memdup_user(p->pointer, p->length); + if (IS_ERR(param)) + return PTR_ERR(param); switch (param->cmd) { case IEEE_CMD_SET_WPA_PARAM: ret = wpa_set_param(dev, param->u.wpa_param.name, diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c index f8f651a9d7b0..02339e100014 100644 --- a/drivers/staging/rtl8712/rtl871x_mlme.c +++ b/drivers/staging/rtl8712/rtl871x_mlme.c @@ -62,7 +62,8 @@ static sint _init_mlme_priv(struct _adapter *padapter) _init_queue(&(pmlmepriv->scanned_queue)); set_scanned_network_val(pmlmepriv, 0); memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct ndis_802_11_ssid)); - pbuf = _malloc(MAX_BSS_CNT * (sizeof(struct wlan_network))); + pbuf = kmalloc(MAX_BSS_CNT * (sizeof(struct wlan_network)), + GFP_ATOMIC); if (pbuf == NULL) return _FAIL; pmlmepriv->free_bss_buf = pbuf; @@ -725,8 +726,7 @@ void r8712_joinbss_event_callback(struct _adapter *adapter, u8 *pbuf) struct wlan_network *pnetwork; if (sizeof(struct list_head) == 4 * sizeof(u32)) { - pnetwork = (struct wlan_network *) - _malloc(sizeof(struct wlan_network)); + pnetwork = kmalloc(sizeof(struct wlan_network), GFP_ATOMIC); memcpy((u8 *)pnetwork+16, (u8 *)pbuf + 8, sizeof(struct wlan_network) - 16); } else @@ -1212,17 +1212,15 @@ sint r8712_set_auth(struct _adapter *adapter, struct cmd_obj *pcmd; struct setauth_parm *psetauthparm; - pcmd = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + pcmd = kmalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (pcmd == NULL) return _FAIL; - psetauthparm = (struct setauth_parm *)_malloc( - sizeof(struct setauth_parm)); + psetauthparm = kzalloc(sizeof(struct setauth_parm), GFP_ATOMIC); if (psetauthparm == NULL) { kfree((unsigned char *)pcmd); return _FAIL; } - memset(psetauthparm, 0, sizeof(struct setauth_parm)); psetauthparm->mode = (u8)psecuritypriv->AuthAlgrthm; pcmd->cmdcode = _SetAuth_CMD_; pcmd->parmbuf = (unsigned char *)psetauthparm; @@ -1244,15 +1242,14 @@ sint r8712_set_key(struct _adapter *adapter, u8 keylen; sint ret = _SUCCESS; - pcmd = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + pcmd = kmalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (pcmd == NULL) return _FAIL; - psetkeyparm = (struct setkey_parm *)_malloc(sizeof(struct setkey_parm)); + psetkeyparm = kzalloc(sizeof(struct setkey_parm), GFP_ATOMIC); if (psetkeyparm == NULL) { ret = _FAIL; goto err_free_cmd; } - memset(psetkeyparm, 0, sizeof(struct setkey_parm)); if (psecuritypriv->AuthAlgrthm == 2) { /* 802.1X */ psetkeyparm->algorithm = (u8)psecuritypriv->XGrpPrivacy; diff --git a/drivers/staging/rtl8712/rtl871x_mp.c b/drivers/staging/rtl8712/rtl871x_mp.c index 5fd60cd322bf..389062fe8eaf 100644 --- a/drivers/staging/rtl8712/rtl871x_mp.c +++ b/drivers/staging/rtl8712/rtl871x_mp.c @@ -53,8 +53,9 @@ static int init_mp_priv(struct mp_priv *pmp_priv) _init_mp_priv_(pmp_priv); _init_queue(&pmp_priv->free_mp_xmitqueue); pmp_priv->pallocated_mp_xmitframe_buf = NULL; - pmp_priv->pallocated_mp_xmitframe_buf = _malloc(NR_MP_XMITFRAME * - sizeof(struct mp_xmit_frame) + 4); + pmp_priv->pallocated_mp_xmitframe_buf = kmalloc(NR_MP_XMITFRAME * + sizeof(struct mp_xmit_frame) + 4, + GFP_ATOMIC); if (pmp_priv->pallocated_mp_xmitframe_buf == NULL) { res = _FAIL; goto _exit_init_mp_priv; @@ -280,11 +281,10 @@ void r8712_SetChannel(struct _adapter *pAdapter) struct SetChannel_parm *pparm = NULL; u16 code = GEN_CMD_CODE(_SetChannel); - pcmd = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); + pcmd = kmalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (pcmd == NULL) return; - pparm = (struct SetChannel_parm *)_malloc(sizeof(struct - SetChannel_parm)); + pparm = kmalloc(sizeof(struct SetChannel_parm), GFP_ATOMIC); if (pparm == NULL) { kfree(pcmd); return; diff --git a/drivers/staging/rtl8712/rtl871x_recv.c b/drivers/staging/rtl8712/rtl871x_recv.c index 4ac4a1b44d2a..eb775872c93c 100644 --- a/drivers/staging/rtl8712/rtl871x_recv.c +++ b/drivers/staging/rtl8712/rtl871x_recv.c @@ -72,9 +72,9 @@ sint _r8712_init_recv_priv(struct recv_priv *precvpriv, _init_queue(&precvpriv->recv_pending_queue); precvpriv->adapter = padapter; precvpriv->free_recvframe_cnt = NR_RECVFRAME; - precvpriv->pallocated_frame_buf = _malloc(NR_RECVFRAME * - sizeof(union recv_frame) + - RXFRAME_ALIGN_SZ); + precvpriv->pallocated_frame_buf = kmalloc(NR_RECVFRAME * + sizeof(union recv_frame) + RXFRAME_ALIGN_SZ, + GFP_ATOMIC); if (precvpriv->pallocated_frame_buf == NULL) return _FAIL; kmemleak_not_leak(precvpriv->pallocated_frame_buf); diff --git a/drivers/staging/rtl8712/rtl871x_sta_mgt.c b/drivers/staging/rtl8712/rtl871x_sta_mgt.c index 8db6849d4b24..6c649842abd7 100644 --- a/drivers/staging/rtl8712/rtl871x_sta_mgt.c +++ b/drivers/staging/rtl8712/rtl871x_sta_mgt.c @@ -51,8 +51,8 @@ u32 _r8712_init_sta_priv(struct sta_priv *pstapriv) struct sta_info *psta; s32 i; - pstapriv->pallocated_stainfo_buf = _malloc(sizeof(struct sta_info) * - NUM_STA + 4); + pstapriv->pallocated_stainfo_buf = kmalloc(sizeof(struct sta_info) * + NUM_STA + 4, GFP_ATOMIC); if (pstapriv->pallocated_stainfo_buf == NULL) return _FAIL; pstapriv->pstainfo_buf = pstapriv->pallocated_stainfo_buf + 4 - diff --git a/drivers/staging/rtl8712/rtl871x_xmit.c b/drivers/staging/rtl8712/rtl871x_xmit.c index 78f570b571a7..230681a8042f 100644 --- a/drivers/staging/rtl8712/rtl871x_xmit.c +++ b/drivers/staging/rtl8712/rtl871x_xmit.c @@ -87,8 +87,8 @@ sint _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv, and initialize free_xmit_frame below. Please also apply free_txobj to link_up all the xmit_frames... */ - pxmitpriv->pallocated_frame_buf = _malloc(NR_XMITFRAME * - sizeof(struct xmit_frame) + 4); + pxmitpriv->pallocated_frame_buf = kmalloc(NR_XMITFRAME * sizeof(struct xmit_frame) + 4, + GFP_ATOMIC); if (pxmitpriv->pallocated_frame_buf == NULL) { pxmitpriv->pxmit_frame_buf = NULL; return _FAIL; @@ -126,8 +126,8 @@ sint _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv, /*init xmit_buf*/ _init_queue(&pxmitpriv->free_xmitbuf_queue); _init_queue(&pxmitpriv->pending_xmitbuf_queue); - pxmitpriv->pallocated_xmitbuf = _malloc(NR_XMITBUFF * - sizeof(struct xmit_buf) + 4); + pxmitpriv->pallocated_xmitbuf = kmalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4, + GFP_ATOMIC); if (pxmitpriv->pallocated_xmitbuf == NULL) return _FAIL; pxmitpriv->pxmitbuf = pxmitpriv->pallocated_xmitbuf + 4 - @@ -135,8 +135,8 @@ sint _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv, pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf; for (i = 0; i < NR_XMITBUFF; i++) { _init_listhead(&pxmitbuf->list); - pxmitbuf->pallocated_buf = _malloc(MAX_XMITBUF_SZ + - XMITBUF_ALIGN_SZ); + pxmitbuf->pallocated_buf = kmalloc(MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ, + GFP_ATOMIC); if (pxmitbuf->pallocated_buf == NULL) return _FAIL; pxmitbuf->pbuf = pxmitbuf->pallocated_buf + XMITBUF_ALIGN_SZ - @@ -955,8 +955,8 @@ static void alloc_hwxmits(struct _adapter *padapter) struct xmit_priv *pxmitpriv = &padapter->xmitpriv; pxmitpriv->hwxmit_entry = HWXMIT_ENTRY; - pxmitpriv->hwxmits = (struct hw_xmit *)_malloc(sizeof(struct hw_xmit) * - pxmitpriv->hwxmit_entry); + pxmitpriv->hwxmits = kmalloc(sizeof(struct hw_xmit) * pxmitpriv->hwxmit_entry, + GFP_ATOMIC); if (pxmitpriv->hwxmits == NULL) return; hwxmits = pxmitpriv->hwxmits; diff --git a/drivers/staging/rtl8712/usb_ops_linux.c b/drivers/staging/rtl8712/usb_ops_linux.c index dca398a0656b..064dc1076d2a 100644 --- a/drivers/staging/rtl8712/usb_ops_linux.c +++ b/drivers/staging/rtl8712/usb_ops_linux.c @@ -495,7 +495,7 @@ int r8712_usbctrl_vendorreq(struct intf_priv *pintfpriv, u8 request, u16 value, */ u8 *palloc_buf, *pIo_buf; - palloc_buf = _malloc((u32) len + 16); + palloc_buf = kmalloc((u32)len + 16, GFP_ATOMIC); if (palloc_buf == NULL) { dev_err(&udev->dev, "%s: Can't alloc memory for vendor request\n", __func__); -- cgit v1.2.3 From f8628a47ba502ec2ec795dc0134f052f45ce2cd4 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Fri, 23 May 2014 22:13:20 -0700 Subject: staging: Convert __FUNCTION__ to __func__ Use the normal mechanism for emitting a function name. Signed-off-by: Joe Perches Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Qos.c | 14 ++++----- drivers/staging/keucr/scsiglue.c | 2 +- drivers/staging/octeon-usb/octeon-hcd.c | 2 +- drivers/staging/rtl8192u/ieee80211/ieee80211.h | 2 +- .../rtl8192u/ieee80211/ieee80211_crypt_ccmp.c | 2 +- .../rtl8192u/ieee80211/ieee80211_crypt_tkip.c | 2 +- .../rtl8192u/ieee80211/ieee80211_crypt_wep.c | 2 +- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 34 +++++++++++----------- .../staging/rtl8192u/ieee80211/ieee80211_softmac.c | 10 +++---- drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c | 2 +- drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c | 2 +- .../staging/rtl8192u/ieee80211/rtl819x_BAProc.c | 22 +++++++------- .../staging/rtl8192u/ieee80211/rtl819x_HTProc.c | 10 +++---- .../staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 10 +++---- drivers/staging/rtl8192u/r8192U_dm.c | 12 ++++---- drivers/staging/rtl8192u/r8192U_wx.c | 12 ++++---- drivers/staging/rtl8192u/r819xU_firmware.c | 6 ++-- drivers/staging/rtl8723au/hal/hal_com.c | 4 +-- drivers/staging/rtl8723au/hal/odm.c | 4 +-- drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 24 +++++++-------- drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c | 2 +- drivers/staging/rtl8723au/hal/rtl8723au_recv.c | 2 +- drivers/staging/rtl8723au/hal/usb_ops_linux.c | 16 +++++----- .../rtl8723au/include/rtl8723a_bt-coexist.h | 2 +- drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 4 +-- .../staging/usbip/userspace/libsrc/usbip_common.h | 2 +- 26 files changed, 103 insertions(+), 103 deletions(-) diff --git a/drivers/staging/bcm/Qos.c b/drivers/staging/bcm/Qos.c index 64ae92b13160..0c742da8c6b5 100644 --- a/drivers/staging/bcm/Qos.c +++ b/drivers/staging/bcm/Qos.c @@ -591,7 +591,7 @@ static bool EthCSMatchSrcMACAddress(struct bcm_classifier_rule *pstClassifierRul struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); if (pstClassifierRule->ucEthCSSrcMACLen == 0) return TRUE; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s\n", __FUNCTION__); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s\n", __func__); for (i = 0; i < MAC_ADDRESS_SIZE; i++) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "SRC MAC[%x] = %x ClassifierRuleSrcMAC = %x Mask : %x\n", i, Mac[i], pstClassifierRule->au8EThCSSrcMAC[i], pstClassifierRule->au8EThCSSrcMACMask[i]); if ((pstClassifierRule->au8EThCSSrcMAC[i] & pstClassifierRule->au8EThCSSrcMACMask[i]) != @@ -607,7 +607,7 @@ static bool EthCSMatchDestMACAddress(struct bcm_classifier_rule *pstClassifierRu struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); if (pstClassifierRule->ucEthCSDestMACLen == 0) return TRUE; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s\n", __FUNCTION__); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s\n", __func__); for (i = 0; i < MAC_ADDRESS_SIZE; i++) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "SRC MAC[%x] = %x ClassifierRuleSrcMAC = %x Mask : %x\n", i, Mac[i], pstClassifierRule->au8EThCSDestMAC[i], pstClassifierRule->au8EThCSDestMACMask[i]); if ((pstClassifierRule->au8EThCSDestMAC[i] & pstClassifierRule->au8EThCSDestMACMask[i]) != @@ -624,9 +624,9 @@ static bool EthCSMatchEThTypeSAP(struct bcm_classifier_rule *pstClassifierRule, (pstClassifierRule->au8EthCSEtherType[0] == 0)) return TRUE; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s SrcEtherType:%x CLS EtherType[0]:%x\n", __FUNCTION__, pstEthCsPktInfo->usEtherType, pstClassifierRule->au8EthCSEtherType[0]); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s SrcEtherType:%x CLS EtherType[0]:%x\n", __func__, pstEthCsPktInfo->usEtherType, pstClassifierRule->au8EthCSEtherType[0]); if (pstClassifierRule->au8EthCSEtherType[0] == 1) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s CLS EtherType[1]:%x EtherType[2]:%x\n", __FUNCTION__, pstClassifierRule->au8EthCSEtherType[1], pstClassifierRule->au8EthCSEtherType[2]); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s CLS EtherType[1]:%x EtherType[2]:%x\n", __func__, pstClassifierRule->au8EthCSEtherType[1], pstClassifierRule->au8EthCSEtherType[2]); if (memcmp(&pstEthCsPktInfo->usEtherType, &pstClassifierRule->au8EthCSEtherType[1], 2) == 0) return TRUE; @@ -638,7 +638,7 @@ static bool EthCSMatchEThTypeSAP(struct bcm_classifier_rule *pstClassifierRule, if (eEth802LLCFrame != pstEthCsPktInfo->eNwpktEthFrameType) return false; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s EthCS DSAP:%x EtherType[2]:%x\n", __FUNCTION__, pstEthCsPktInfo->ucDSAP, pstClassifierRule->au8EthCSEtherType[2]); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s EthCS DSAP:%x EtherType[2]:%x\n", __func__, pstEthCsPktInfo->ucDSAP, pstClassifierRule->au8EthCSEtherType[2]); if (pstEthCsPktInfo->ucDSAP == pstClassifierRule->au8EthCSEtherType[2]) return TRUE; else @@ -657,7 +657,7 @@ static bool EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule, s B_UINT8 uPriority = 0; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s CLS UserPrio:%x CLS VLANID:%x\n", __FUNCTION__, ntohs(*((USHORT *)pstClassifierRule->usUserPriority)), pstClassifierRule->usVLANID); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s CLS UserPrio:%x CLS VLANID:%x\n", __func__, ntohs(*((USHORT *)pstClassifierRule->usUserPriority)), pstClassifierRule->usVLANID); /* In case FW didn't receive the TLV, the priority field should be ignored */ if (pstClassifierRule->usValidityBitMap & (1<data + sizeof(struct bcm_eth_header))) & 0xFFF; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s Pkt VLANID %x Priority: %d\n", __FUNCTION__, usVLANID, uPriority); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s Pkt VLANID %x Priority: %d\n", __func__, usVLANID, uPriority); if (usVLANID == ((pstClassifierRule->usVLANID & 0xFFF0) >> 4)) bClassificationSucceed = TRUE; diff --git a/drivers/staging/keucr/scsiglue.c b/drivers/staging/keucr/scsiglue.c index ac3d34dcc438..7d8d444910c1 100644 --- a/drivers/staging/keucr/scsiglue.c +++ b/drivers/staging/keucr/scsiglue.c @@ -106,7 +106,7 @@ static int queuecommand_lck(struct scsi_cmnd *srb, /* check for state-transition errors */ if (us->srb != NULL) { /* pr_info("Error in %s: us->srb = %p\n" - __FUNCTION__, us->srb); */ + __func__, us->srb); */ return SCSI_MLQUEUE_HOST_BUSY; } diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index 27f1f276eba4..c4c731f60529 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -1546,7 +1546,7 @@ static void __cvmx_usb_start_channel_control(struct cvmx_usb_state *usb, switch (transaction->stage) { case CVMX_USB_STAGE_NON_CONTROL: case CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE: - cvmx_dprintf("%s: ERROR - Non control stage\n", __FUNCTION__); + cvmx_dprintf("%s: ERROR - Non control stage\n", __func__); break; case CVMX_USB_STAGE_SETUP: usbc_hctsiz.s.pid = 3; /* Setup */ diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h index 3b40b61ce29f..e0aa069fe9b1 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h @@ -527,7 +527,7 @@ do { if (ieee80211_debug_level & (level)) \ { \ int i; \ u8 *pdata = (u8 *) data; \ - printk(KERN_DEBUG "ieee80211: %s()\n", __FUNCTION__); \ + printk(KERN_DEBUG "ieee80211: %s()\n", __func__); \ for(i=0; i<(int)(datalen); i++) \ { \ printk("%2x ", pdata[i]); \ diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c index f2b16775a638..af2128b956b7 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c @@ -444,7 +444,7 @@ static char *ieee80211_ccmp_print_stats(char *p, void *priv) void ieee80211_ccmp_null(void) { -// printk("============>%s()\n", __FUNCTION__); +// printk("============>%s()\n", __func__); return; } diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c index 93121b42f16b..fcc90a5700d6 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c @@ -773,6 +773,6 @@ void __exit ieee80211_crypto_tkip_exit(void) void ieee80211_tkip_null(void) { -// printk("============>%s()\n", __FUNCTION__); +// printk("============>%s()\n", __func__); return; } diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c index f20223695897..8c1bf1f56883 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c @@ -290,6 +290,6 @@ void __exit ieee80211_crypto_wep_exit(void) void ieee80211_wep_null(void) { -// printk("============>%s()\n", __FUNCTION__); +// printk("============>%s()\n", __func__); return; } diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index 89389c4d0b80..0cd6a001bcc5 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -549,7 +549,7 @@ void ieee80211_indicate_packets(struct ieee80211_device *ieee, struct ieee80211_ u8 i = 0 , j=0; u16 ethertype; // if(index > 1) -// IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): hahahahhhh, We indicate packet from reorder list, index is %u\n",__FUNCTION__,index); +// IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): hahahahhhh, We indicate packet from reorder list, index is %u\n",__func__,index); for(j = 0; jRxIndicateSeq + WinSize -1)%4096; u8 index = 0; bool bMatchWinStart = false, bPktInBuf = false; - IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): Seq is %d,pTS->RxIndicateSeq is %d, WinSize is %d\n",__FUNCTION__,SeqNum,pTS->RxIndicateSeq,WinSize); + IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): Seq is %d,pTS->RxIndicateSeq is %d, WinSize is %d\n",__func__,SeqNum,pTS->RxIndicateSeq,WinSize); /* Rx Reorder initialize condition.*/ if(pTS->RxIndicateSeq == 0xffff) { pTS->RxIndicateSeq = SeqNum; @@ -662,11 +662,11 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee, IEEE80211_DEBUG(IEEE80211_DL_REORDER, "Packets indication!! IndicateSeq: %d, NewSeq: %d\n",\ pTS->RxIndicateSeq, SeqNum); prxbIndicateArray[0] = prxb; -// printk("========================>%s(): SeqNum is %d\n",__FUNCTION__,SeqNum); +// printk("========================>%s(): SeqNum is %d\n",__func__,SeqNum); index = 1; } else { /* Current packet is going to be inserted into pending list.*/ - //IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): We RX no ordered packed, insert to ordered list\n",__FUNCTION__); + //IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): We RX no ordered packed, insert to ordered list\n",__func__); if(!list_empty(&ieee->RxReorder_Unused_List)) { pReorderEntry = (PRX_REORDER_ENTRY)list_entry(ieee->RxReorder_Unused_List.next,RX_REORDER_ENTRY,List); list_del_init(&pReorderEntry->List); @@ -674,11 +674,11 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee, /* Make a reorder entry and insert into a the packet list.*/ pReorderEntry->SeqNum = SeqNum; pReorderEntry->prxb = prxb; - // IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): pREorderEntry->SeqNum is %d\n",__FUNCTION__,pReorderEntry->SeqNum); + // IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): pREorderEntry->SeqNum is %d\n",__func__,pReorderEntry->SeqNum); if(!AddReorderEntry(pTS, pReorderEntry)) { IEEE80211_DEBUG(IEEE80211_DL_REORDER, "%s(): Duplicate packet is dropped!! IndicateSeq: %d, NewSeq: %d\n", - __FUNCTION__, pTS->RxIndicateSeq, SeqNum); + __func__, pTS->RxIndicateSeq, SeqNum); list_add_tail(&pReorderEntry->List,&ieee->RxReorder_Unused_List); { int i; @@ -713,7 +713,7 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee, /* Check if there is any packet need indicate.*/ while(!list_empty(&pTS->RxPendingPktList)) { - IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): start RREORDER indicate\n",__FUNCTION__); + IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): start RREORDER indicate\n",__func__); pReorderEntry = (PRX_REORDER_ENTRY)list_entry(pTS->RxPendingPktList.prev,RX_REORDER_ENTRY,List); if( SN_LESS(pReorderEntry->SeqNum, pTS->RxIndicateSeq) || SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) @@ -732,7 +732,7 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee, IEEE80211_DEBUG(IEEE80211_DL_REORDER,"Packets indication!! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum); prxbIndicateArray[index] = pReorderEntry->prxb; - // printk("========================>%s(): pReorderEntry->SeqNum is %d\n",__FUNCTION__,pReorderEntry->SeqNum); + // printk("========================>%s(): pReorderEntry->SeqNum is %d\n",__func__,pReorderEntry->SeqNum); index++; list_add_tail(&pReorderEntry->List,&ieee->RxReorder_Unused_List); @@ -758,7 +758,7 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee, if(bPktInBuf && pTS->RxTimeoutIndicateSeq==0xffff) { // Set new pending timer. - IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): SET rx timeout timer\n", __FUNCTION__); + IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): SET rx timeout timer\n", __func__); pTS->RxTimeoutIndicateSeq = pTS->RxIndicateSeq; if(timer_pending(&pTS->RxPktPendingTimer)) del_timer_sync(&pTS->RxPktPendingTimer); @@ -832,8 +832,8 @@ static u8 parse_subframe(struct sk_buff *skb, if(skb->len<(ETHERNET_HEADER_SIZE + nSubframe_Length)) { printk("%s: A-MSDU parse error!! pRfd->nTotalSubframe : %d\n",\ - __FUNCTION__,rxb->nr_subframes); - printk("%s: A-MSDU parse error!! Subframe Length: %d\n",__FUNCTION__, nSubframe_Length); + __func__,rxb->nr_subframes); + printk("%s: A-MSDU parse error!! Subframe Length: %d\n",__func__, nSubframe_Length); printk("nRemain_Length is %d and nSubframe_Length is : %d\n",skb->len,nSubframe_Length); printk("The Packet SeqNum is %d\n",SeqNum); return 0; @@ -1024,7 +1024,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, else { PRX_TS_RECORD pRxTS = NULL; - //IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): QOS ENABLE AND RECEIVE QOS DATA , we will get Ts, tid:%d\n",__FUNCTION__, tid); + //IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): QOS ENABLE AND RECEIVE QOS DATA , we will get Ts, tid:%d\n",__func__, tid); if(GetTs( ieee, (PTS_COMMON_INFO *) &pRxTS, @@ -1034,7 +1034,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, true)) { - // IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): pRxTS->RxLastFragNum is %d,frag is %d,pRxTS->RxLastSeqNum is %d,seq is %d\n",__FUNCTION__,pRxTS->RxLastFragNum,frag,pRxTS->RxLastSeqNum,WLAN_GET_SEQ_SEQ(sc)); + // IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): pRxTS->RxLastFragNum is %d,frag is %d,pRxTS->RxLastSeqNum is %d,seq is %d\n",__func__,pRxTS->RxLastFragNum,frag,pRxTS->RxLastSeqNum,WLAN_GET_SEQ_SEQ(sc)); if( (fc & (1<<11)) && (frag == pRxTS->RxLastFragNum) && (WLAN_GET_SEQ_SEQ(sc) == pRxTS->RxLastSeqNum) ) @@ -1049,7 +1049,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, } else { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "%s(): No TS!! Skip the check!!\n",__FUNCTION__); + IEEE80211_DEBUG(IEEE80211_DL_ERR, "%s(): No TS!! Skip the check!!\n",__func__); goto rx_dropped; } } @@ -1294,7 +1294,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, rxb = kmalloc(sizeof(struct ieee80211_rxb), GFP_ATOMIC); if(rxb == NULL) { - IEEE80211_DEBUG(IEEE80211_DL_ERR,"%s(): kmalloc rxb error\n",__FUNCTION__); + IEEE80211_DEBUG(IEEE80211_DL_ERR,"%s(): kmalloc rxb error\n",__func__); goto rx_dropped; } /* to parse amsdu packets */ @@ -1360,7 +1360,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, } else { - IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): REORDER ENABLE AND PTS not NULL, and we will enter RxReorderIndicatePacket()\n",__FUNCTION__); + IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): REORDER ENABLE AND PTS not NULL, and we will enter RxReorderIndicatePacket()\n",__func__); RxReorderIndicatePacket(ieee, rxb, pTS, SeqNum); } #ifndef JOHN_NOCPY @@ -1927,7 +1927,7 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee, info_element->data[1] == 0x13 && info_element->data[2] == 0x74)) { - printk("========>%s(): athros AP is exist\n",__FUNCTION__); + printk("========>%s(): athros AP is exist\n",__func__); network->atheros_cap_exist = true; } else diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index f36683be8d79..5274ff0fb7a2 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -273,7 +273,7 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee /* as for the completion function, it does not need * to check it any more. * */ - printk("%s():insert to waitqueue!\n",__FUNCTION__); + printk("%s():insert to waitqueue!\n",__func__); skb_queue_tail(&ieee->skb_waitQ[tcb_desc->queue_index], skb); } else { //printk("TX packet!\n"); @@ -675,7 +675,7 @@ inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *be auth->algorithm = WLAN_AUTH_SHARED_KEY; else if(ieee->auth_mode == 2) auth->algorithm = WLAN_AUTH_OPEN;//0x80; - printk("=================>%s():auth->algorithm is %d\n",__FUNCTION__,auth->algorithm); + printk("=================>%s():auth->algorithm is %d\n",__func__,auth->algorithm); auth->transaction = cpu_to_le16(ieee->associate_seq); ieee->associate_seq++; @@ -1217,7 +1217,7 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco memcpy(tag, realtek_ie_buf,realtek_ie_len -2 ); } } -// printk("<=====%s(), %p, %p\n", __FUNCTION__, ieee->dev, ieee->dev->dev_addr); +// printk("<=====%s(), %p, %p\n", __func__, ieee->dev, ieee->dev->dev_addr); // IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, skb->data, skb->len); return skb; } @@ -1403,7 +1403,7 @@ static void ieee80211_associate_procedure_wq(struct work_struct *work) ieee->data_hard_stop(ieee->dev); ieee80211_stop_scan(ieee); - printk("===>%s(), chan:%d\n", __FUNCTION__, ieee->current_network.channel); + printk("===>%s(), chan:%d\n", __func__, ieee->current_network.channel); //ieee->set_chan(ieee->dev, ieee->current_network.channel); HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT); @@ -2647,7 +2647,7 @@ void ieee80211_start_protocol(struct ieee80211_device *ieee) if (ieee->current_network.beacon_interval == 0) ieee->current_network.beacon_interval = 100; -// printk("===>%s(), chan:%d\n", __FUNCTION__, ieee->current_network.channel); +// printk("===>%s(), chan:%d\n", __func__, ieee->current_network.channel); // ieee->set_chan(ieee->dev,ieee->current_network.channel); for(i = 0; i < 17; i++) { diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c index 953717f1a6e4..029a97651797 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c @@ -188,7 +188,7 @@ int ieee80211_encrypt_fragment( if (!(crypt && crypt->ops)) { - printk("=========>%s(), crypt is null\n", __FUNCTION__); + printk("=========>%s(), crypt is null\n", __func__); return -1; } #ifdef CONFIG_IEEE80211_CRYPT_TKIP diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c index d43e4a78f70d..698507e00f31 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c @@ -778,7 +778,7 @@ int ieee80211_wx_set_auth(struct ieee80211_device *ieee, break; case IW_AUTH_80211_AUTH_ALG: - //printk("======>%s():data->value is %d\n",__FUNCTION__,data->value); + //printk("======>%s():data->value is %d\n",__func__,data->value); // ieee->open_wep = (data->value&IW_AUTH_ALG_OPEN_SYSTEM)?1:0; if(data->value & IW_AUTH_ALG_SHARED_KEY){ ieee->open_wep = 0; diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c index 7bf55e393554..b8cc6a537c36 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c @@ -113,7 +113,7 @@ static struct sk_buff *ieee80211_ADDBA(struct ieee80211_device *ieee, u8 *Dst, P u16 tmp = 0; u16 len = ieee->tx_headroom + 9; //category(1) + action field(1) + Dialog Token(1) + BA Parameter Set(2) + BA Timeout Value(2) + BA Start SeqCtrl(2)(or StatusCode(2)) - IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA, "========>%s(), frame(%d) sentd to:%pM, ieee->dev:%p\n", __FUNCTION__, type, Dst, ieee->dev); + IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA, "========>%s(), frame(%d) sentd to:%pM, ieee->dev:%p\n", __func__, type, Dst, ieee->dev); if (pBA == NULL||ieee == NULL) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "pBA(%p) is NULL or ieee(%p) is NULL\n", pBA, ieee); @@ -201,7 +201,7 @@ static struct sk_buff *ieee80211_DELBA( u16 len = 6 + ieee->tx_headroom; if (net_ratelimit()) - IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA, "========>%s(), ReasonCode(%d) sentd to:%pM\n", __FUNCTION__, ReasonCode, dst); + IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA, "========>%s(), ReasonCode(%d) sentd to:%pM\n", __func__, ReasonCode, dst); memset(&DelbaParamSet, 0, 2); @@ -240,7 +240,7 @@ static struct sk_buff *ieee80211_DELBA( IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len); if (net_ratelimit()) - IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA, "<=====%s()\n", __FUNCTION__); + IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA, "<=====%s()\n", __func__); return skb; } @@ -266,7 +266,7 @@ static void ieee80211_send_ADDBAReq(struct ieee80211_device *ieee, } else { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __FUNCTION__); + IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __func__); } return; } @@ -291,7 +291,7 @@ static void ieee80211_send_ADDBARsp(struct ieee80211_device *ieee, u8 *dst, } else { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __FUNCTION__); + IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __func__); } return; @@ -320,7 +320,7 @@ static void ieee80211_send_DELBA(struct ieee80211_device *ieee, u8 *dst, } else { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __FUNCTION__); + IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __func__); } return ; } @@ -380,7 +380,7 @@ int ieee80211_rx_ADDBAReq( struct ieee80211_device *ieee, struct sk_buff *skb) true) ) { rc = ADDBA_STATUS_REFUSED; - IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS in %s()\n", __FUNCTION__); + IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS in %s()\n", __func__); goto OnADDBAReq_Fail; } pBA = &pTS->RxAdmittedBARecord; @@ -391,7 +391,7 @@ int ieee80211_rx_ADDBAReq( struct ieee80211_device *ieee, struct sk_buff *skb) if(pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED) { rc = ADDBA_STATUS_INVALID_PARAM; - IEEE80211_DEBUG(IEEE80211_DL_ERR, "BA Policy is not correct in %s()\n", __FUNCTION__); + IEEE80211_DEBUG(IEEE80211_DL_ERR, "BA Policy is not correct in %s()\n", __func__); goto OnADDBAReq_Fail; } // Admit the ADDBA Request @@ -479,7 +479,7 @@ int ieee80211_rx_ADDBARsp( struct ieee80211_device *ieee, struct sk_buff *skb) TX_DIR, false) ) { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS in %s()\n", __FUNCTION__); + IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS in %s()\n", __func__); ReasonCode = DELBA_REASON_UNKNOWN_BA; goto OnADDBARsp_Reject; } @@ -603,7 +603,7 @@ int ieee80211_rx_DELBA(struct ieee80211_device *ieee,struct sk_buff *skb) RX_DIR, false) ) { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS for RXTS in %s()\n", __FUNCTION__); + IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS for RXTS in %s()\n", __func__); return -1; } @@ -621,7 +621,7 @@ int ieee80211_rx_DELBA(struct ieee80211_device *ieee,struct sk_buff *skb) TX_DIR, false) ) { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS for TXTS in %s()\n", __FUNCTION__); + IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS for TXTS in %s()\n", __func__); return -1; } diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c index 0484145080cc..e7c54ac60720 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c @@ -130,7 +130,7 @@ void HTDebugHTCapability(u8 *CapIE, u8 *TitleString ) if(!memcmp(CapIE, EWC11NHTCap, sizeof(EWC11NHTCap))) { //EWC IE - IEEE80211_DEBUG(IEEE80211_DL_HT, "EWC IE in %s()\n", __FUNCTION__); + IEEE80211_DEBUG(IEEE80211_DL_HT, "EWC IE in %s()\n", __func__); pCapELE = (PHT_CAPABILITY_ELE)(&CapIE[4]); }else pCapELE = (PHT_CAPABILITY_ELE)(&CapIE[0]); @@ -167,7 +167,7 @@ void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString) if(!memcmp(InfoIE, EWC11NHTInfo, sizeof(EWC11NHTInfo))) { // Not EWC IE - IEEE80211_DEBUG(IEEE80211_DL_HT, "EWC IE in %s()\n", __FUNCTION__); + IEEE80211_DEBUG(IEEE80211_DL_HT, "EWC IE in %s()\n", __func__); pHTInfoEle = (PHT_INFORMATION_ELE)(&InfoIE[4]); }else pHTInfoEle = (PHT_INFORMATION_ELE)(&InfoIE[0]); @@ -1134,7 +1134,7 @@ void HTInitializeHTInfo(struct ieee80211_device *ieee) // // These parameters will be reset when receiving deauthentication packet // - IEEE80211_DEBUG(IEEE80211_DL_HT, "===========>%s()\n", __FUNCTION__); + IEEE80211_DEBUG(IEEE80211_DL_HT, "===========>%s()\n", __func__); pHTInfo->bCurrentHTSupport = false; // 40MHz channel support @@ -1229,7 +1229,7 @@ void HTResetSelfAndSavePeerSetting(struct ieee80211_device *ieee, struct ieee802 // // Save Peer Setting before Association // - IEEE80211_DEBUG(IEEE80211_DL_HT, "==============>%s()\n", __FUNCTION__); + IEEE80211_DEBUG(IEEE80211_DL_HT, "==============>%s()\n", __func__); /*unmark bEnableHT flag here is the same reason why unmarked in function ieee80211_softmac_new_net. WB 2008.09.10*/ // if( pHTInfo->bEnableHT && pNetwork->bssht.bdSupportHT) if (pNetwork->bssht.bdSupportHT) @@ -1398,7 +1398,7 @@ void HTSetConnectBwModeCallback(struct ieee80211_device *ieee) { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - IEEE80211_DEBUG(IEEE80211_DL_HT, "======>%s()\n", __FUNCTION__); + IEEE80211_DEBUG(IEEE80211_DL_HT, "======>%s()\n", __func__); if(pHTInfo->bCurBW40MHz) { diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index 426f223e6a21..c4514109d0ee 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -38,7 +38,7 @@ static void RxPktPendingTimeout(unsigned long data) spin_lock_irqsave(&(ieee->reorder_spinlock), flags); //PlatformAcquireSpinLock(Adapter, RT_RX_SPINLOCK); - IEEE80211_DEBUG(IEEE80211_DL_REORDER,"==================>%s()\n",__FUNCTION__); + IEEE80211_DEBUG(IEEE80211_DL_REORDER,"==================>%s()\n",__func__); if(pRxTs->RxTimeoutIndicateSeq != 0xffff) { // Indicate the pending packets sequentially according to SeqNum until meet the gap. @@ -144,7 +144,7 @@ void TSInitialize(struct ieee80211_device *ieee) PRX_TS_RECORD pRxTS = ieee->RxTsRecord; PRX_REORDER_ENTRY pRxReorderEntry = ieee->RxReorderEntry; u8 count = 0; - IEEE80211_DEBUG(IEEE80211_DL_TS, "==========>%s()\n", __FUNCTION__); + IEEE80211_DEBUG(IEEE80211_DL_TS, "==========>%s()\n", __func__); // Initialize Tx TS related info. INIT_LIST_HEAD(&ieee->Tx_TS_Admit_List); INIT_LIST_HEAD(&ieee->Tx_TS_Pending_List); @@ -361,7 +361,7 @@ bool GetTs( // In WMM case: we use 4 TID only if (!IsACValid(TID)) { - IEEE80211_DEBUG(IEEE80211_DL_ERR, " in %s(), TID(%d) is not valid\n", __FUNCTION__, TID); + IEEE80211_DEBUG(IEEE80211_DL_ERR, " in %s(), TID(%d) is not valid\n", __func__, TID); return false; } @@ -463,7 +463,7 @@ bool GetTs( } else { - IEEE80211_DEBUG(IEEE80211_DL_ERR, "in function %s() There is not enough TS record to be used!!", __FUNCTION__); + IEEE80211_DEBUG(IEEE80211_DL_ERR, "in function %s() There is not enough TS record to be used!!", __func__); return false; } } @@ -619,5 +619,5 @@ void TsStartAddBaProcess(struct ieee80211_device *ieee, PTX_TS_RECORD pTxTS) } } else - IEEE80211_DEBUG(IEEE80211_DL_ERR, "%s()==>BA timer is already added\n", __FUNCTION__); + IEEE80211_DEBUG(IEEE80211_DL_ERR, "%s()==>BA timer is already added\n", __func__); } diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index 9fa12e4618b1..b4264e1353c9 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -2523,7 +2523,7 @@ static void dm_check_edca_turbo( if(priv->ieee80211->pHTInfo->IOTAction & HT_IOT_ACT_DISABLE_EDCA_TURBO) goto dm_CheckEdcaTurbo_EXIT; -// printk("========>%s():bis_any_nonbepkts is %d\n",__FUNCTION__,priv->bis_any_nonbepkts); +// printk("========>%s():bis_any_nonbepkts is %d\n",__func__,priv->bis_any_nonbepkts); // Check the status for current condition. if(!priv->ieee80211->bis_any_nonbepkts) { @@ -3183,7 +3183,7 @@ void dm_fsync_timer_callback(unsigned long data) static void dm_StartHWFsync(struct net_device *dev) { - RT_TRACE(COMP_HALDM, "%s\n", __FUNCTION__); + RT_TRACE(COMP_HALDM, "%s\n", __func__); write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c12cf); write_nic_byte(dev, 0xc3b, 0x41); } @@ -3192,7 +3192,7 @@ static void dm_EndSWFsync(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); - RT_TRACE(COMP_HALDM, "%s\n", __FUNCTION__); + RT_TRACE(COMP_HALDM, "%s\n", __func__); del_timer_sync(&(priv->fsync_timer)); // Let Register return to default value; @@ -3216,7 +3216,7 @@ static void dm_StartSWFsync(struct net_device *dev) u32 rateIndex; u32 rateBitmap; - RT_TRACE(COMP_HALDM,"%s\n", __FUNCTION__); + RT_TRACE(COMP_HALDM,"%s\n", __func__); // Initial rate record to zero, start to record. priv->rate_record = 0; // Initialize continue diff count to zero, start to record. @@ -3251,7 +3251,7 @@ static void dm_StartSWFsync(struct net_device *dev) static void dm_EndHWFsync(struct net_device *dev) { - RT_TRACE(COMP_HALDM,"%s\n", __FUNCTION__); + RT_TRACE(COMP_HALDM,"%s\n", __func__); write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c52cd); write_nic_byte(dev, 0xc3b, 0x49); @@ -3483,7 +3483,7 @@ static void dm_dynamic_txpower(struct net_device *dev) txlowpower_threshold = TX_POWER_NEAR_FIELD_THRESH_LOW; } -// printk("=======>%s(): txhipower_threshhold is %d,txlowpower_threshold is %d\n",__FUNCTION__,txhipower_threshhold,txlowpower_threshold); +// printk("=======>%s(): txhipower_threshhold is %d,txlowpower_threshold is %d\n",__func__,txhipower_threshhold,txlowpower_threshold); RT_TRACE(COMP_TXAGC,"priv->undecorated_smoothed_pwdb = %ld \n" , priv->undecorated_smoothed_pwdb); if(priv->ieee80211->state == IEEE80211_LINKED) diff --git a/drivers/staging/rtl8192u/r8192U_wx.c b/drivers/staging/rtl8192u/r8192U_wx.c index abae1631a4f0..dab716f765fc 100644 --- a/drivers/staging/rtl8192u/r8192U_wx.c +++ b/drivers/staging/rtl8192u/r8192U_wx.c @@ -135,7 +135,7 @@ static int r8192_wx_force_reset(struct net_device *dev, down(&priv->wx_sem); - printk("%s(): force reset ! extra is %d\n",__FUNCTION__, *extra); + printk("%s(): force reset ! extra is %d\n",__func__, *extra); priv->force_reset = *extra; up(&priv->wx_sem); return 0; @@ -738,7 +738,7 @@ static int r8192_wx_set_enc_ext(struct net_device *dev, int ret=0; struct r8192_priv *priv = ieee80211_priv(dev); struct ieee80211_device *ieee = priv->ieee80211; - //printk("===>%s()\n", __FUNCTION__); + //printk("===>%s()\n", __func__); down(&priv->wx_sem); @@ -817,7 +817,7 @@ static int r8192_wx_set_auth(struct net_device *dev, union iwreq_data *data, char *extra) { int ret=0; - //printk("====>%s()\n", __FUNCTION__); + //printk("====>%s()\n", __func__); struct r8192_priv *priv = ieee80211_priv(dev); down(&priv->wx_sem); ret = ieee80211_wx_set_auth(priv->ieee80211, info, &(data->param), extra); @@ -829,7 +829,7 @@ static int r8192_wx_set_mlme(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - //printk("====>%s()\n", __FUNCTION__); + //printk("====>%s()\n", __func__); int ret=0; struct r8192_priv *priv = ieee80211_priv(dev); @@ -844,13 +844,13 @@ static int r8192_wx_set_gen_ie(struct net_device *dev, struct iw_request_info *info, union iwreq_data *data, char *extra) { - //printk("====>%s(), len:%d\n", __FUNCTION__, data->length); + //printk("====>%s(), len:%d\n", __func__, data->length); int ret=0; struct r8192_priv *priv = ieee80211_priv(dev); down(&priv->wx_sem); ret = ieee80211_wx_set_gen_ie(priv->ieee80211, extra, data->data.length); up(&priv->wx_sem); - //printk("<======%s(), ret:%d\n", __FUNCTION__, ret); + //printk("<======%s(), ret:%d\n", __func__, ret); return ret; diff --git a/drivers/staging/rtl8192u/r819xU_firmware.c b/drivers/staging/rtl8192u/r819xU_firmware.c index 98a113a6e439..04b8f5ec67e9 100644 --- a/drivers/staging/rtl8192u/r819xU_firmware.c +++ b/drivers/staging/rtl8192u/r819xU_firmware.c @@ -162,7 +162,7 @@ static bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev) return rt_status; CPUCheckMainCodeOKAndTurnOnCPU_Fail: - RT_TRACE(COMP_ERR, "ERR in %s()\n", __FUNCTION__); + RT_TRACE(COMP_ERR, "ERR in %s()\n", __func__); rt_status = FALSE; return rt_status; } @@ -191,7 +191,7 @@ static bool CPUcheck_firmware_ready(struct net_device *dev) return rt_status; CPUCheckFirmwareReady_Fail: - RT_TRACE(COMP_ERR, "ERR in %s()\n", __FUNCTION__); + RT_TRACE(COMP_ERR, "ERR in %s()\n", __func__); rt_status = false; return rt_status; @@ -334,7 +334,7 @@ bool init_firmware(struct net_device *dev) return rt_status; download_firmware_fail: - RT_TRACE(COMP_ERR, "ERR in %s()\n", __FUNCTION__); + RT_TRACE(COMP_ERR, "ERR in %s()\n", __func__); rt_status = FALSE; return rt_status; diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index af7e6b375841..d2ee240496cc 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -593,7 +593,7 @@ void rtl8723a_on_rcr_am(struct rtw_adapter *padapter) { rtl8723au_write32(padapter, REG_RCR, rtl8723au_read32(padapter, REG_RCR) | RCR_AM); - DBG_8723A("%s, %d, RCR = %x \n", __FUNCTION__, __LINE__, + DBG_8723A("%s, %d, RCR = %x \n", __func__, __LINE__, rtl8723au_read32(padapter, REG_RCR)); } @@ -601,7 +601,7 @@ void rtl8723a_off_rcr_am(struct rtw_adapter *padapter) { rtl8723au_write32(padapter, REG_RCR, rtl8723au_read32(padapter, REG_RCR) & (~RCR_AM)); - DBG_8723A("%s, %d, RCR = %x \n", __FUNCTION__, __LINE__, + DBG_8723A("%s, %d, RCR = %x \n", __func__, __LINE__, rtl8723au_read32(padapter, REG_RCR)); } diff --git a/drivers/staging/rtl8723au/hal/odm.c b/drivers/staging/rtl8723au/hal/odm.c index 05ddd724e1be..6b3b2f0378a8 100644 --- a/drivers/staging/rtl8723au/hal/odm.c +++ b/drivers/staging/rtl8723au/hal/odm.c @@ -1280,7 +1280,7 @@ u32 ODM_Get_Rate_Bitmap23a(struct dm_odm_t *pDM_Odm, break; } - /* printk("%s ==> rssi_level:0x%02x, WirelessMode:0x%02x, rate_bitmap:0x%08x \n", __FUNCTION__, rssi_level, WirelessMode, rate_bitmap); */ + /* printk("%s ==> rssi_level:0x%02x, WirelessMode:0x%02x, rate_bitmap:0x%08x \n", __func__, rssi_level, WirelessMode, rate_bitmap); */ ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, (" ==> rssi_level:0x%02x, WirelessMode:0x%02x, rate_bitmap:0x%08x \n", rssi_level, WirelessMode, rate_bitmap)); return rate_bitmap; @@ -1336,7 +1336,7 @@ void odm_RefreshRateAdaptiveMask23aCE23a(struct dm_odm_t *pDM_Odm) return; } - /* printk("==> %s \n", __FUNCTION__); */ + /* printk("==> %s \n", __func__); */ for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) { struct sta_info *pstat = pDM_Odm->pODM_StaInfo[i]; diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c index e78f773af105..e8737916c7ba 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c @@ -179,7 +179,7 @@ void rtl8723a_set_FwPwrMode_cmd(struct rtw_adapter *padapter, u8 Mode) struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - DBG_8723A("%s: Mode =%d SmartPS =%d UAPSD =%d BcnMode = 0x%02x\n", __FUNCTION__, + DBG_8723A("%s: Mode =%d SmartPS =%d UAPSD =%d BcnMode = 0x%02x\n", __func__, Mode, pwrpriv->smart_ps, padapter->registrypriv.uapsd_enable, pwrpriv->bcn_ant_mode); /* Forece leave RF low power mode for 1T1R to @@ -211,7 +211,7 @@ static void ConstructBeacon(struct rtw_adapter *padapter, u8 *pframe, u32 *pLeng u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; int bcn_fixed_size; - /* DBG_8723A("%s\n", __FUNCTION__); */ + /* DBG_8723A("%s\n", __func__); */ pwlanhdr = (struct ieee80211_hdr *)pframe; @@ -301,7 +301,7 @@ _ConstructBeacon: *pLength = pktlen; - /* DBG_8723A("%s bcn_sz =%d\n", __FUNCTION__, pktlen); */ + /* DBG_8723A("%s bcn_sz =%d\n", __func__, pktlen); */ } @@ -413,7 +413,7 @@ static void ConstructProbeRsp(struct rtw_adapter *padapter, u8 *pframe, struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; - /* DBG_8723A("%s\n", __FUNCTION__); */ + /* DBG_8723A("%s\n", __func__); */ pwlanhdr = (struct ieee80211_hdr *)pframe; @@ -473,11 +473,11 @@ static void SetFwRsvdPagePkt(struct rtw_adapter *padapter, bool bDLFinished) u32 TotalPacketLen; struct rsvdpage_loc RsvdPageLoc; - DBG_8723A("%s\n", __FUNCTION__); + DBG_8723A("%s\n", __func__); ReservedPagePacket = kzalloc(1000, GFP_KERNEL); if (ReservedPagePacket == NULL) { - DBG_8723A("%s: alloc ReservedPagePacket fail!\n", __FUNCTION__); + DBG_8723A("%s: alloc ReservedPagePacket fail!\n", __func__); return; } @@ -584,7 +584,7 @@ static void SetFwRsvdPagePkt(struct rtw_adapter *padapter, bool bDLFinished) rtl8723au_mgnt_xmit(padapter, pmgntframe); - DBG_8723A("%s: Set RSVD page location to Fw\n", __FUNCTION__); + DBG_8723A("%s: Set RSVD page location to Fw\n", __func__); FillH2CCmd(padapter, RSVD_PAGE_EID, sizeof(RsvdPageLoc), (u8 *)&RsvdPageLoc); exit: @@ -598,7 +598,7 @@ void rtl8723a_set_FwJoinBssReport_cmd(struct rtw_adapter *padapter, u8 mstatus) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - DBG_8723A("%s mstatus(%x)\n", __FUNCTION__, mstatus); + DBG_8723A("%s mstatus(%x)\n", __func__, mstatus); if (mstatus == 1) { bool bRecover = false; @@ -680,11 +680,11 @@ static void SetFwRsvdPagePkt_BTCoex(struct rtw_adapter *padapter) u32 TotalPacketLen; struct rsvdpage_loc RsvdPageLoc; - DBG_8723A("+%s\n", __FUNCTION__); + DBG_8723A("+%s\n", __func__); ReservedPagePacket = kzalloc(1024, GFP_KERNEL); if (ReservedPagePacket == NULL) { - DBG_8723A("%s: alloc ReservedPagePacket fail!\n", __FUNCTION__); + DBG_8723A("%s: alloc ReservedPagePacket fail!\n", __func__); return; } @@ -746,7 +746,7 @@ static void SetFwRsvdPagePkt_BTCoex(struct rtw_adapter *padapter) rtl8723au_mgnt_xmit(padapter, pmgntframe); - DBG_8723A("%s: Set RSVD page location to Fw\n", __FUNCTION__); + DBG_8723A("%s: Set RSVD page location to Fw\n", __func__); FillH2CCmd(padapter, RSVD_PAGE_EID, sizeof(RsvdPageLoc), (u8 *)&RsvdPageLoc); exit: @@ -758,7 +758,7 @@ void rtl8723a_set_BTCoex_AP_mode_FwRsvdPkt_cmd(struct rtw_adapter *padapter) struct hal_data_8723a *pHalData; u8 bRecover = false; - DBG_8723A("+%s\n", __FUNCTION__); + DBG_8723A("+%s\n", __func__); pHalData = GET_HAL_DATA(padapter); diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c b/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c index 97da41409bc3..d23525e664fb 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c @@ -1099,7 +1099,7 @@ static void _PHY_SwChnl8723A(struct rtw_adapter *Adapter, u8 channel) struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); if (Adapter->bNotifyChannelChange) - DBG_8723A("[%s] ch = %d\n", __FUNCTION__, channel); + DBG_8723A("[%s] ch = %d\n", __func__, channel); /* s1. pre common command - CmdID_SetTxPowerLevel */ PHY_SetTxPowerLevel8723A(Adapter, channel); diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_recv.c b/drivers/staging/rtl8723au/hal/rtl8723au_recv.c index f0ce944dc4c4..6075b6dc1bee 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723au_recv.c +++ b/drivers/staging/rtl8723au/hal/rtl8723au_recv.c @@ -242,7 +242,7 @@ void update_recvframe_phyinfo(struct recv_frame *precvframe, psta = rtw_get_stainfo23a(pstapriv, sa); if (psta) { pkt_info.StationID = psta->mac_id; - /* printk("%s ==> StationID(%d)\n", __FUNCTION__, pkt_info.StationID); */ + /* printk("%s ==> StationID(%d)\n", __func__, pkt_info.StationID); */ } pkt_info.Rate = pattrib->mcs_rate; diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index df2e884dbb8b..4ba6b47e6f5b 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -45,7 +45,7 @@ static int usbctrl_vendorreq(struct rtw_adapter *padapter, u8 request, if (len > MAX_VENDOR_REQ_CMD_SIZE) { DBG_8723A("[%s] Buffer len error , vendor request failed\n", - __FUNCTION__); + __func__); status = -EINVAL; goto exit; } @@ -56,7 +56,7 @@ static int usbctrl_vendorreq(struct rtw_adapter *padapter, u8 request, pIo_buf = pdvobjpriv->usb_vendor_req_buf; if (pIo_buf == NULL) { - DBG_8723A("[%s] pIo_buf == NULL \n", __FUNCTION__); + DBG_8723A("[%s] pIo_buf == NULL \n", __func__); status = -ENOMEM; goto release_mutex; } @@ -352,7 +352,7 @@ static void usb_read_interrupt_complete(struct urb *purb) padapter->bReadPortCancel) { DBG_8723A("%s() RX Warning! bDriverStopped(%d) OR " "bSurpriseRemoved(%d) bReadPortCancel(%d)\n", - __FUNCTION__, padapter->bDriverStopped, + __func__, padapter->bDriverStopped, padapter->bSurpriseRemoved, padapter->bReadPortCancel); return; @@ -508,7 +508,7 @@ static int recvbuf2recvframe(struct rtw_adapter *padapter, struct sk_buff *pskb) RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvbuf2recvframe: precvframe == NULL\n")); DBG_8723A("%s()-%d: rtw_alloc_recvframe23a() failed! RX " - "Drop!\n", __FUNCTION__, __LINE__); + "Drop!\n", __func__, __LINE__); goto _exit_recvbuf2recvframe; } @@ -520,7 +520,7 @@ static int recvbuf2recvframe(struct rtw_adapter *padapter, struct sk_buff *pskb) if (pattrib->crc_err) { DBG_8723A("%s()-%d: RX Warning! rx CRC ERROR !!\n", - __FUNCTION__, __LINE__); + __func__, __LINE__); rtw_free_recvframe23a(precvframe); goto _exit_recvbuf2recvframe; } @@ -532,7 +532,7 @@ static int recvbuf2recvframe(struct rtw_adapter *padapter, struct sk_buff *pskb) RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("recvbuf2recvframe: pkt_len<= 0\n")); DBG_8723A("%s()-%d: RX Warning!\n", - __FUNCTION__, __LINE__); + __func__, __LINE__); rtw_free_recvframe23a(precvframe); goto _exit_recvbuf2recvframe; } @@ -664,7 +664,7 @@ static void usb_read_port_complete(struct urb *purb) DBG_8723A("%s()-%d: RX Warning! bDriverStopped(%d) OR " "bSurpriseRemoved(%d) bReadPortCancel(%d)\n", - __FUNCTION__, __LINE__, padapter->bDriverStopped, + __func__, __LINE__, padapter->bDriverStopped, padapter->bSurpriseRemoved, padapter->bReadPortCancel); return; } @@ -679,7 +679,7 @@ static void usb_read_port_complete(struct urb *purb) rtl8723au_read_port(padapter, RECV_BULK_IN_ADDR, 0, precvbuf); DBG_8723A("%s()-%d: RX Warning!\n", - __FUNCTION__, __LINE__); + __func__, __LINE__); } else { rtw_reset_continual_urb_error( adapter_to_dvobj(padapter)); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h index 154bb4779953..615101918865 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h @@ -1099,7 +1099,7 @@ struct btdata_entry { #define BTHCI_SM_WITH_INFO(_Adapter, _StateToEnter, _StateCmd, _EntryNum) \ { \ - RTPRINT(FIOCTL, IOCTL_STATE, ("[BT state change] caused by ""%s"", line =%d\n", __FUNCTION__, __LINE__)); \ + RTPRINT(FIOCTL, IOCTL_STATE, ("[BT state change] caused by ""%s"", line =%d\n", __func__, __LINE__)); \ BTHCI_StateMachine(_Adapter, _StateToEnter, _StateCmd, _EntryNum);\ } diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 0f757307ebb6..badbce09559d 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -594,11 +594,11 @@ void mlmeext_sta_add_event_callback23a(struct rtw_adapter *padapter, struct sta_ void linked_status_chk23a(struct rtw_adapter *padapter); #define set_survey_timer(mlmeext, ms) \ - /*DBG_8723A("%s set_survey_timer(%p, %d)\n", __FUNCTION__, (mlmeext), (ms));*/ \ + /*DBG_8723A("%s set_survey_timer(%p, %d)\n", __func__, (mlmeext), (ms));*/ \ mod_timer(&mlmeext->survey_timer, jiffies + msecs_to_jiffies(ms)); #define set_link_timer(mlmeext, ms) \ - /*DBG_8723A("%s set_link_timer(%p, %d)\n", __FUNCTION__, (mlmeext), (ms));*/ \ + /*DBG_8723A("%s set_link_timer(%p, %d)\n", __func__, (mlmeext), (ms));*/ \ mod_timer(&mlmeext->link_timer, jiffies + msecs_to_jiffies(ms)); int cckrates_included23a(unsigned char *rate, int ratelen); diff --git a/drivers/staging/usbip/userspace/libsrc/usbip_common.h b/drivers/staging/usbip/userspace/libsrc/usbip_common.h index 23be848f24fb..5a0e95edf4df 100644 --- a/drivers/staging/usbip/userspace/libsrc/usbip_common.h +++ b/drivers/staging/usbip/userspace/libsrc/usbip_common.h @@ -47,7 +47,7 @@ extern int usbip_use_debug ; #define pr_fmt(fmt) "%s: %s: " fmt "\n", PROGNAME #define dbg_fmt(fmt) pr_fmt("%s:%d:[%s] " fmt), "debug", \ - __FILE__, __LINE__, __FUNCTION__ + __FILE__, __LINE__, __func__ #define err(fmt, args...) \ do { \ -- cgit v1.2.3 From 77870a1b856d181936ca13f6732010e63b803b4a Mon Sep 17 00:00:00 2001 From: Pascal COMBES Date: Sat, 24 May 2014 15:58:09 +0200 Subject: Staging: dgap: Fixed iomem accesses in dgap.c I changed dereferences from iomem into the adequate ioread function. Signed-off-by: Pascal COMBES Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index ca264f950f9c..1475532b4df0 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -1431,8 +1431,8 @@ static int dgap_tty_init(struct board_t *brd) ch->ch_dsr = DM_DSR; } - ch->ch_taddr = vaddr + ((ch->ch_bs->tx_seg) << 4); - ch->ch_raddr = vaddr + ((ch->ch_bs->rx_seg) << 4); + ch->ch_taddr = vaddr + (ioread16(&(ch->ch_bs->tx_seg)) << 4); + ch->ch_raddr = vaddr + (ioread16(&(ch->ch_bs->rx_seg)) << 4); ch->ch_tx_win = 0; ch->ch_rx_win = 0; ch->ch_tsize = readw(&(ch->ch_bs->tx_max)) + 1; @@ -4958,8 +4958,8 @@ static uint dgap_get_custom_baud(struct channel_t *ch) * Go get from fep mem, what the fep * believes the custom baud rate is. */ - offset = ((((*(unsigned short __iomem *)(vaddr + ECS_SEG)) << 4) + - (ch->ch_portnum * 0x28) + LINE_SPEED)); + offset = (ioread16(vaddr + ECS_SEG) << 4) + (ch->ch_portnum * 0x28) + + LINE_SPEED; value = readw(vaddr + offset); return value; @@ -5506,10 +5506,10 @@ static int dgap_event(struct board_t *bd) event = bd->re_map_membase + tail + EVSTART; - port = event[0]; - reason = event[1]; - modem = event[2]; - b1 = event[3]; + port = ioread8(event); + reason = ioread8(event + 1); + modem = ioread8(event + 2); + b1 = ioread8(event + 3); /* * Make sure the interrupt is valid. -- cgit v1.2.3 From 296066093b5f5ccf30a9c3b2047eb6a8875a88f0 Mon Sep 17 00:00:00 2001 From: Niv Yehezkel Date: Sat, 24 May 2014 10:28:07 -0400 Subject: staging: android: describe use of memory barrier on sync.c Added comments describing the purpose of using write memory barrier in the context of sync_timeline_destory. Signed-off-by: Niv Yehezkel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/sync.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index 1f88c5d0f0c7..18174f7c871c 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -92,6 +92,10 @@ static void sync_timeline_free(struct kref *kref) void sync_timeline_destroy(struct sync_timeline *obj) { obj->destroyed = true; + /* + * Ensure timeline is marked as destroyed before + * changing timeline's fences status. + */ smp_wmb(); /* -- cgit v1.2.3 From e9329bd3dd4a1913c97287f3ee40880308a759e6 Mon Sep 17 00:00:00 2001 From: Konrad Zapalowicz Date: Sat, 24 May 2014 17:23:06 +0200 Subject: staging: rtl8821ae: add static for local symbols in halbtc8723b1ant.c This commit fixes the sparse warning: "warning: symbol 'X' was not declared. Should it be static?" Where the X is one of the following: glbt_info_src_8723b_2ant glcoex_ver_date_8723b_2ant glcoex_ver_8723b_2ant halbtc8723b2ant_bt_rssi_state halbtc8723b2ant_wifi_rssi_state halbtc8723b2ant_monitor_bt_enable_disable halbtc8723b2ant_monitor_bt_ctr halbtc8723b2ant_query_bt_info halbtc8723b2ant_is_wifi_status_changed halbtc8723b2ant_update_bt_link_info halbtc8723b2ant_action_algorithm halbtc8723b2ant_need_to_dec_bt_pwr halbtc8723b2ant_set_fw_dac_swing_level halbtc8723b2ant_set_fw_dec_bt_pwr halbtc8723b2ant_dec_bt_pwr halbtc8723b2ant_set_bt_auto_report halbtc8723b2ant_bt_auto_report halbtc8723b2ant_fw_dac_swing_lvl halbtc8723b2ant_set_sw_rf_rx_lpf_corner halbtc8723b2ant_rf_shrink halbtc8723b2ant_set_sw_penalty_txrate_adaptive halbtc8723b2ant_low_penalty_ra halbtc8723b2ant_set_dac_swing_reg halbtc8723b2ant_set_sw_fulltime_dac_swing halbtc8723b2ant_dac_swing halbtc8723b2ant_set_adc_backoff halbtc8723b2ant_adc_backoff halbtc8723b2ant_set_agc_table halbtc8723b2ant_agc_table halbtc8723b2ant_set_coex_table halbtc8723b2ant_coex_table halbtc8723b2ant_coex_table_with_type halbtc8723b2ant_set_fw_ignore_wlan_act halbtc8723b2ant_ignore_wlan_act halbtc8723b2ant_set_fw_ps_tdma halbtc8723b2ant_sw_mechanism1 halbtc8723b2ant_sw_mechanism2 halbtc8723b2ant_set_ant_path halbtc8723b2ant_ps_tdma halbtc8723b2ant_coex_alloff halbtc8723b2ant_init_coex_dm halbtc8723b2ant_action_bt_inquiry halbtc8723b2ant_is_common_action halbtc8723b2ant_tdma_duration_adjust halbtc8723b2ant_action_sco halbtc8723b2ant_action_hid halbtc8723b2ant_action_a2dp halbtc8723b2ant_action_a2dp_pan_hs halbtc8723b2ant_action_pan_edr halbtc8723b2ant_action_pan_hs halbtc8723b2ant_action_pan_edr_a2dp halbtc8723b2ant_action_pan_edr_hid halbtc8723b2ant_action_hid_a2dp_pan_edr halbtc8723b2ant_action_hid_a2dp halbtc8723b2ant_run_coexist_mechanism halbtc8723b2ant_wifioff_hwcfg Signed-off-by: Konrad Zapalowicz Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8821ae/btcoexist/halbtc8723b1ant.c | 203 +++++++++++---------- 1 file changed, 109 insertions(+), 94 deletions(-) diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtc8723b1ant.c b/drivers/staging/rtl8821ae/btcoexist/halbtc8723b1ant.c index 9677943fc20d..5337782de1a9 100644 --- a/drivers/staging/rtl8821ae/btcoexist/halbtc8723b1ant.c +++ b/drivers/staging/rtl8821ae/btcoexist/halbtc8723b1ant.c @@ -22,14 +22,14 @@ static struct coex_dm_8723b_1ant *coex_dm = &glcoex_dm_8723b_1ant; static struct coex_sta_8723b_1ant glcoex_sta_8723b_1ant; static struct coex_sta_8723b_1ant *coex_sta = &glcoex_sta_8723b_1ant; -const char *const GLBtInfoSrc8723b1Ant[]={ +static const char *const GLBtInfoSrc8723b1Ant[] = { "BT Info[wifi fw]", "BT Info[bt rsp]", "BT Info[bt auto report]", }; -u32 glcoex_ver_date_8723b_1ant = 20130906; -u32 glcoex_ver_8723b_1ant = 0x45; +static u32 glcoex_ver_date_8723b_1ant = 20130906; +static u32 glcoex_ver_8723b_1ant = 0x45; /*************************************************************** * local function proto type if needed @@ -37,7 +37,8 @@ u32 glcoex_ver_8723b_1ant = 0x45; /*************************************************************** * local function start with halbtc8723b1ant_ ***************************************************************/ -u8 halbtc8723b1ant_bt_rssi_state(u8 level_num, u8 rssi_thresh, u8 rssi_thresh1) +static u8 halbtc8723b1ant_bt_rssi_state(u8 level_num, u8 rssi_thresh, + u8 rssi_thresh1) { s32 bt_rssi=0; u8 bt_rssi_state = coex_sta->pre_bt_rssi_state; @@ -134,9 +135,9 @@ u8 halbtc8723b1ant_bt_rssi_state(u8 level_num, u8 rssi_thresh, u8 rssi_thresh1) return bt_rssi_state; } -u8 halbtc8723b1ant_wifi_rssi_state(struct btc_coexist *btcoexist, - u8 index, u8 level_num, - u8 rssi_thresh, u8 rssi_thresh1) +static u8 halbtc8723b1ant_wifi_rssi_state(struct btc_coexist *btcoexist, + u8 index, u8 level_num, + u8 rssi_thresh, u8 rssi_thresh1) { s32 wifi_rssi=0; u8 wifi_rssi_state = coex_sta->pre_wifi_rssi_state[index]; @@ -249,8 +250,8 @@ u8 halbtc8723b1ant_wifi_rssi_state(struct btc_coexist *btcoexist, return wifi_rssi_state; } -void halbtc8723b1ant_updatera_mask(struct btc_coexist *btcoexist, - bool force_exec, u32 dis_rate_mask) +static void halbtc8723b1ant_updatera_mask(struct btc_coexist *btcoexist, + bool force_exec, u32 dis_rate_mask) { coex_dm->curra_mask = dis_rate_mask; @@ -261,8 +262,9 @@ void halbtc8723b1ant_updatera_mask(struct btc_coexist *btcoexist, coex_dm->prera_mask = coex_dm->curra_mask; } -void halbtc8723b1ant_auto_rate_fallback_retry(struct btc_coexist *btcoexist, - bool force_exec, u8 type) +static void halbtc8723b1ant_auto_rate_fallback_retry( + struct btc_coexist *btcoexist, + bool force_exec, u8 type) { bool wifi_under_bmode = false; @@ -300,8 +302,8 @@ void halbtc8723b1ant_auto_rate_fallback_retry(struct btc_coexist *btcoexist, coex_dm->pre_arfr_type = coex_dm->cur_arfr_type; } -void halbtc8723b1ant_retry_limit(struct btc_coexist *btcoexist, - bool force_exec, u8 type) +static void halbtc8723b1ant_retry_limit(struct btc_coexist *btcoexist, + bool force_exec, u8 type) { coex_dm->cur_retry_limit_type = type; @@ -324,8 +326,8 @@ void halbtc8723b1ant_retry_limit(struct btc_coexist *btcoexist, coex_dm->pre_retry_limit_type = coex_dm->cur_retry_limit_type; } -void halbtc8723b1ant_ampdu_maxtime(struct btc_coexist *btcoexist, - bool force_exec, u8 type) +static void halbtc8723b1ant_ampdu_maxtime(struct btc_coexist *btcoexist, + bool force_exec, u8 type) { coex_dm->cur_ampdu_time_type = type; @@ -348,7 +350,7 @@ void halbtc8723b1ant_ampdu_maxtime(struct btc_coexist *btcoexist, coex_dm->pre_ampdu_time_type = coex_dm->cur_ampdu_time_type; } -void halbtc8723b1ant_limited_tx(struct btc_coexist *btcoexist, +static void halbtc8723b1ant_limited_tx(struct btc_coexist *btcoexist, bool force_exec, u8 ra_maskType, u8 arfr_type, u8 retry_limit_type, u8 ampdu_time_type) { @@ -375,7 +377,7 @@ void halbtc8723b1ant_limited_tx(struct btc_coexist *btcoexist, halbtc8723b1ant_ampdu_maxtime(btcoexist, force_exec, ampdu_time_type); } -void halbtc8723b1ant_limited_rx(struct btc_coexist *btcoexist, +static void halbtc8723b1ant_limited_rx(struct btc_coexist *btcoexist, bool force_exec, bool rej_ap_agg_pkt, bool b_bt_ctrl_agg_buf_size, u8 agg_buf_size) { @@ -398,7 +400,7 @@ void halbtc8723b1ant_limited_rx(struct btc_coexist *btcoexist, btcoexist->btc_set(btcoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL); } -void halbtc8723b1ant_monitor_bt_ctr(struct btc_coexist *btcoexist) +static void halbtc8723b1ant_monitor_bt_ctr(struct btc_coexist *btcoexist) { u32 reg_hp_txrx, reg_lp_txrx, u32tmp; u32 reg_hp_tx = 0, reg_hp_rx = 0; @@ -424,7 +426,7 @@ void halbtc8723b1ant_monitor_bt_ctr(struct btc_coexist *btcoexist) btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc); } -void halbtc8723b1ant_query_bt_info(struct btc_coexist *btcoexist) +static void halbtc8723b1ant_query_bt_info(struct btc_coexist *btcoexist) { u8 h2c_parameter[1] = {0}; @@ -439,7 +441,8 @@ void halbtc8723b1ant_query_bt_info(struct btc_coexist *btcoexist) btcoexist->btc_fill_h2c(btcoexist, 0x61, 1, h2c_parameter); } -bool halbtc8723b1ant_is_wifi_status_changed(struct btc_coexist *btcoexist) +static bool halbtc8723b1ant_is_wifi_status_changed( + struct btc_coexist *btcoexist) { static bool pre_wifi_busy = false; static bool pre_under_4way = false, pre_bt_hs_on = false; @@ -471,7 +474,7 @@ bool halbtc8723b1ant_is_wifi_status_changed(struct btc_coexist *btcoexist) return false; } -void halbtc8723b1ant_update_bt_link_info(struct btc_coexist *btcoexist) +static void halbtc8723b1ant_update_bt_link_info(struct btc_coexist *btcoexist) { struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; bool bt_hs_on = false; @@ -519,7 +522,7 @@ void halbtc8723b1ant_update_bt_link_info(struct btc_coexist *btcoexist) bt_link_info->hid_only = false; } -u8 halbtc8723b1ant_action_algorithm(struct btc_coexist *btcoexist) +static u8 halbtc8723b1ant_action_algorithm(struct btc_coexist *btcoexist) { struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; bool bt_hs_on = false; @@ -719,7 +722,7 @@ u8 halbtc8723b1ant_action_algorithm(struct btc_coexist *btcoexist) return algorithm; } -bool halbtc8723b1ant_need_to_dec_bt_pwr(struct btc_coexist *btcoexist) +static bool halbtc8723b1ant_need_to_dec_bt_pwr(struct btc_coexist *btcoexist) { bool ret = false; bool bt_hs_on = false, wifi_connected = false; @@ -750,8 +753,9 @@ bool halbtc8723b1ant_need_to_dec_bt_pwr(struct btc_coexist *btcoexist) return ret; } -void halbtc8723b1ant_set_fw_dac_swing_level(struct btc_coexist *btcoexist, - u8 dac_swing_lvl) +static void halbtc8723b1ant_set_fw_dac_swing_level( + struct btc_coexist *btcoexist, + u8 dac_swing_lvl) { u8 h2c_parameter[1] = {0}; @@ -767,7 +771,7 @@ void halbtc8723b1ant_set_fw_dac_swing_level(struct btc_coexist *btcoexist, btcoexist->btc_fill_h2c(btcoexist, 0x64, 1, h2c_parameter); } -void halbtc8723b1ant_set_fw_dec_bt_pwr(struct btc_coexist *btcoexist, +static void halbtc8723b1ant_set_fw_dec_bt_pwr(struct btc_coexist *btcoexist, bool dec_bt_pwr) { u8 h2c_parameter[1] = {0}; @@ -784,7 +788,7 @@ void halbtc8723b1ant_set_fw_dec_bt_pwr(struct btc_coexist *btcoexist, btcoexist->btc_fill_h2c(btcoexist, 0x62, 1, h2c_parameter); } -void halbtc8723b1ant_dec_bt_pwr(struct btc_coexist *btcoexist, +static void halbtc8723b1ant_dec_bt_pwr(struct btc_coexist *btcoexist, bool force_exec, bool dec_bt_pwr) { return; @@ -806,7 +810,7 @@ void halbtc8723b1ant_dec_bt_pwr(struct btc_coexist *btcoexist, coex_dm->pre_dec_bt_pwr = coex_dm->cur_dec_bt_pwr; } -void halbtc8723b1ant_set_bt_auto_report(struct btc_coexist *btcoexist, +static void halbtc8723b1ant_set_bt_auto_report(struct btc_coexist *btcoexist, bool enable_auto_report) { u8 h2c_parameter[1] = {0}; @@ -824,7 +828,7 @@ void halbtc8723b1ant_set_bt_auto_report(struct btc_coexist *btcoexist, btcoexist->btc_fill_h2c(btcoexist, 0x68, 1, h2c_parameter); } -void halbtc8723b1ant_bt_auto_report(struct btc_coexist *btcoexist, +static void halbtc8723b1ant_bt_auto_report(struct btc_coexist *btcoexist, bool force_exec, bool enable_auto_report) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, @@ -849,7 +853,7 @@ void halbtc8723b1ant_bt_auto_report(struct btc_coexist *btcoexist, coex_dm->pre_bt_auto_report = coex_dm->cur_bt_auto_report; } -void halbtc8723b1ant_fw_dac_swing_lvl(struct btc_coexist *btcoexist, +static void halbtc8723b1ant_fw_dac_swing_lvl(struct btc_coexist *btcoexist, bool force_exec, u8 fw_dac_swing_lvl) { return; @@ -876,8 +880,9 @@ void halbtc8723b1ant_fw_dac_swing_lvl(struct btc_coexist *btcoexist, coex_dm->pre_fw_dac_swing_lvl = coex_dm->cur_fw_dac_swing_lvl; } -void halbtc8723b1ant_set_sw_rf_rx_lpf_corner(struct btc_coexist *btcoexist, - bool rx_rf_shrink_on) +static void halbtc8723b1ant_set_sw_rf_rx_lpf_corner( + struct btc_coexist *btcoexist, + bool rx_rf_shrink_on) { if (rx_rf_shrink_on) { /*Shrink RF Rx LPF corner */ @@ -898,7 +903,7 @@ void halbtc8723b1ant_set_sw_rf_rx_lpf_corner(struct btc_coexist *btcoexist, } } -void halbtc8723b1ant_rf_shrink(struct btc_coexist *btcoexist, +static void halbtc8723b1ant_rf_shrink(struct btc_coexist *btcoexist, bool force_exec, bool rx_rf_shrink_on) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, @@ -924,7 +929,7 @@ void halbtc8723b1ant_rf_shrink(struct btc_coexist *btcoexist, coex_dm->pre_rf_rx_lpf_shrink = coex_dm->cur_rf_rx_lpf_shrink; } -void halbtc8723b1ant_set_sw_penalty_tx_rate_adaptive( +static void halbtc8723b1ant_set_sw_penalty_tx_rate_adaptive( struct btc_coexist *btcoexist, bool low_penalty_ra) { @@ -948,7 +953,7 @@ void halbtc8723b1ant_set_sw_penalty_tx_rate_adaptive( btcoexist->btc_fill_h2c(btcoexist, 0x69, 6, h2c_parameter); } -void halbtc8723b1ant_low_penalty_ra(struct btc_coexist *btcoexist, +static void halbtc8723b1ant_low_penalty_ra(struct btc_coexist *btcoexist, bool force_exec, bool low_penalty_ra) { coex_dm->cur_low_penalty_ra = low_penalty_ra; @@ -963,7 +968,8 @@ void halbtc8723b1ant_low_penalty_ra(struct btc_coexist *btcoexist, coex_dm->pre_low_penalty_ra = coex_dm->cur_low_penalty_ra; } -void halbtc8723b1ant_set_dac_swing_reg(struct btc_coexist *btcoexist, u32 level) +static void halbtc8723b1ant_set_dac_swing_reg(struct btc_coexist *btcoexist, + u32 level) { u8 val = (u8) level; @@ -972,7 +978,8 @@ void halbtc8723b1ant_set_dac_swing_reg(struct btc_coexist *btcoexist, u32 level) btcoexist->btc_write_1byte_bitmask(btcoexist, 0x883, 0x3e, val); } -void halbtc8723b1ant_set_sw_full_time_dac_swing(struct btc_coexist *btcoexist, +static void halbtc8723b1ant_set_sw_full_time_dac_swing( + struct btc_coexist *btcoexist, bool sw_dac_swing_on, u32 sw_dac_swing_lvl) { @@ -983,8 +990,8 @@ void halbtc8723b1ant_set_sw_full_time_dac_swing(struct btc_coexist *btcoexist, } -void halbtc8723b1ant_dac_swing(struct btc_coexist *btcoexist, bool force_exec, - bool dac_swing_on, u32 dac_swing_lvl) +static void halbtc8723b1ant_dac_swing(struct btc_coexist *btcoexist, + bool force_exec, bool dac_swing_on, u32 dac_swing_lvl) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, "[BTCoex], %s turn DacSwing=%s, dac_swing_lvl=0x%x\n", @@ -1014,8 +1021,8 @@ void halbtc8723b1ant_dac_swing(struct btc_coexist *btcoexist, bool force_exec, coex_dm->pre_dac_swing_lvl = coex_dm->cur_dac_swing_lvl; } -void halbtc8723b1ant_set_adc_backoff(struct btc_coexist *btcoexist, - bool adc_backoff) +static void halbtc8723b1ant_set_adc_backoff(struct btc_coexist *btcoexist, + bool adc_backoff) { if (adc_backoff) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, @@ -1028,7 +1035,7 @@ void halbtc8723b1ant_set_adc_backoff(struct btc_coexist *btcoexist, } } -void halbtc8723b1ant_adc_backoff(struct btc_coexist *btcoexist, +static void halbtc8723b1ant_adc_backoff(struct btc_coexist *btcoexist, bool force_exec, bool adc_backoff) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, @@ -1050,7 +1057,7 @@ void halbtc8723b1ant_adc_backoff(struct btc_coexist *btcoexist, coex_dm->cur_adc_backoff; } -void halbtc8723b1ant_set_agc_table(struct btc_coexist *btcoexist, +static void halbtc8723b1ant_set_agc_table(struct btc_coexist *btcoexist, bool adc_table_en) { u8 rssi_adjust_val = 0; @@ -1085,7 +1092,7 @@ void halbtc8723b1ant_set_agc_table(struct btc_coexist *btcoexist, } -void halbtc8723b1ant_agc_table(struct btc_coexist *btcoexist, +static void halbtc8723b1ant_agc_table(struct btc_coexist *btcoexist, bool force_exec, bool adc_table_en) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, @@ -1108,7 +1115,7 @@ void halbtc8723b1ant_agc_table(struct btc_coexist *btcoexist, coex_dm->pre_agc_table_en = coex_dm->cur_agc_table_en; } -void halbtc8723b1ant_set_coex_table(struct btc_coexist *btcoexist, +static void halbtc8723b1ant_set_coex_table(struct btc_coexist *btcoexist, u32 val0x6c0, u32 val0x6c4, u32 val0x6c8, u8 val0x6cc) { @@ -1129,7 +1136,7 @@ void halbtc8723b1ant_set_coex_table(struct btc_coexist *btcoexist, btcoexist->btc_write_1byte(btcoexist, 0x6cc, val0x6cc); } -void halbtc8723b1ant_coex_table(struct btc_coexist *btcoexist, +static void halbtc8723b1ant_coex_table(struct btc_coexist *btcoexist, bool force_exec, u32 val0x6c0, u32 val0x6c4, u32 val0x6c8, u8 val0x6cc) @@ -1159,7 +1166,7 @@ void halbtc8723b1ant_coex_table(struct btc_coexist *btcoexist, coex_dm->pre_val0x6cc = coex_dm->cur_val0x6cc; } -void halbtc8723b1ant_coex_table_with_type(struct btc_coexist *btcoexist, +static void halbtc8723b1ant_coex_table_with_type(struct btc_coexist *btcoexist, bool force_exec, u8 type) { switch (type) { @@ -1200,7 +1207,7 @@ void halbtc8723b1ant_coex_table_with_type(struct btc_coexist *btcoexist, } } -void halbtc8723b1ant_SetFwIgnoreWlanAct(struct btc_coexist *btcoexist, +static void halbtc8723b1ant_SetFwIgnoreWlanAct(struct btc_coexist *btcoexist, bool enable) { u8 h2c_parameter[1] = {0}; @@ -1215,7 +1222,7 @@ void halbtc8723b1ant_SetFwIgnoreWlanAct(struct btc_coexist *btcoexist, btcoexist->btc_fill_h2c(btcoexist, 0x63, 1, h2c_parameter); } -void halbtc8723b1ant_ignore_wlan_act(struct btc_coexist *btcoexist, +static void halbtc8723b1ant_ignore_wlan_act(struct btc_coexist *btcoexist, bool force_exec, bool enable) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, @@ -1239,7 +1246,7 @@ void halbtc8723b1ant_ignore_wlan_act(struct btc_coexist *btcoexist, coex_dm->pre_ignore_wlan_act = coex_dm->cur_ignore_wlan_act; } -void halbtc8723b1ant_set_fw_ps_tdma(struct btc_coexist *btcoexist, +static void halbtc8723b1ant_set_fw_ps_tdma(struct btc_coexist *btcoexist, u8 byte1, u8 byte2, u8 byte3, u8 byte4, u8 byte5) { @@ -1285,7 +1292,7 @@ void halbtc8723b1ant_set_fw_ps_tdma(struct btc_coexist *btcoexist, btcoexist->btc_fill_h2c(btcoexist, 0x60, 5, h2c_parameter); } -void halbtc8723b1ant_SetLpsRpwm(struct btc_coexist *btcoexist, +static void halbtc8723b1ant_SetLpsRpwm(struct btc_coexist *btcoexist, u8 lps_val, u8 rpwm_val) { u8 lps = lps_val; @@ -1295,8 +1302,8 @@ void halbtc8723b1ant_SetLpsRpwm(struct btc_coexist *btcoexist, btcoexist->btc_set(btcoexist, BTC_SET_U1_1ANT_RPWM, &rpwm); } -void halbtc8723b1ant_LpsRpwm(struct btc_coexist *btcoexist, bool force_exec, - u8 lps_val, u8 rpwm_val) +static void halbtc8723b1ant_LpsRpwm(struct btc_coexist *btcoexist, + bool force_exec, u8 lps_val, u8 rpwm_val) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, @@ -1326,7 +1333,7 @@ void halbtc8723b1ant_LpsRpwm(struct btc_coexist *btcoexist, bool force_exec, coex_dm->pre_rpwm = coex_dm->cur_rpwm; } -void halbtc8723b1ant_sw_mechanism1(struct btc_coexist *btcoexist, +static void halbtc8723b1ant_sw_mechanism1(struct btc_coexist *btcoexist, bool shrink_rx_lpf, bool low_penalty_ra, bool limited_dig, bool bt_lna_constrain) { @@ -1337,7 +1344,7 @@ void halbtc8723b1ant_sw_mechanism1(struct btc_coexist *btcoexist, halbtc8723b1ant_low_penalty_ra(btcoexist, NORMAL_EXEC, low_penalty_ra); } -void halbtc8723b1ant_sw_mechanism2(struct btc_coexist *btcoexist, +static void halbtc8723b1ant_sw_mechanism2(struct btc_coexist *btcoexist, bool agc_table_shift, bool adc_backoff, bool sw_dac_swing, u32 dac_swing_lvl) { @@ -1346,7 +1353,7 @@ void halbtc8723b1ant_sw_mechanism2(struct btc_coexist *btcoexist, agc_table_shift, adc_backoff, sw_dac_swing); } -void halbtc8723b1ant_SetAntPath(struct btc_coexist *btcoexist, +static void halbtc8723b1ant_SetAntPath(struct btc_coexist *btcoexist, u8 ant_pos_type, bool init_hw_cfg, bool wifi_off) { @@ -1537,8 +1544,8 @@ void halbtc8723b1ant_SetAntPath(struct btc_coexist *btcoexist, } } -void halbtc8723b1ant_ps_tdma(struct btc_coexist *btcoexist, bool force_exec, - bool turn_on, u8 type) +static void halbtc8723b1ant_ps_tdma(struct btc_coexist *btcoexist, + bool force_exec, bool turn_on, u8 type) { bool wifi_busy = false; u8 rssi_adjust_val = 0; @@ -1783,7 +1790,7 @@ void halbtc8723b1ant_ps_tdma(struct btc_coexist *btcoexist, bool force_exec, coex_dm->pre_ps_tdma = coex_dm->cur_ps_tdma; } -void halbtc8723b1ant_coex_alloff(struct btc_coexist *btcoexist) +static void halbtc8723b1ant_coex_alloff(struct btc_coexist *btcoexist) { /* fw all off */ halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); @@ -1798,7 +1805,7 @@ void halbtc8723b1ant_coex_alloff(struct btc_coexist *btcoexist) halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0); } -bool halbtc8723b1ant_is_common_action(struct btc_coexist *btcoexist) +static bool halbtc8723b1ant_is_common_action(struct btc_coexist *btcoexist) { bool commom = false, wifi_connected = false; bool wifi_busy = false; @@ -1896,8 +1903,9 @@ bool halbtc8723b1ant_is_common_action(struct btc_coexist *btcoexist) } -void halbtc8723b1ant_tdma_duration_adjust_for_acl(struct btc_coexist *btcoexist, - u8 wifi_status) +static void halbtc8723b1ant_tdma_duration_adjust_for_acl( + struct btc_coexist *btcoexist, + u8 wifi_status) { static s32 up, dn, m, n, wait_count; /* 0: no change, +1: increase WiFi duration, @@ -2082,8 +2090,8 @@ void halbtc8723b1ant_tdma_duration_adjust_for_acl(struct btc_coexist *btcoexist, } } -u8 halbtc8723b1ant_ps_tdma_type_by_wifi_rssi(s32 wifi_rssi, s32 pre_wifi_rssi, - u8 wifi_rssi_thresh) +static u8 halbtc8723b1ant_ps_tdma_type_by_wifi_rssi(s32 wifi_rssi, + s32 pre_wifi_rssi, u8 wifi_rssi_thresh) { u8 ps_tdma_type=0; @@ -2102,8 +2110,8 @@ u8 halbtc8723b1ant_ps_tdma_type_by_wifi_rssi(s32 wifi_rssi, s32 pre_wifi_rssi, return ps_tdma_type; } -void halbtc8723b1ant_PsTdmaCheckForPowerSaveState(struct btc_coexist *btcoexist, - bool new_ps_state) +static void halbtc8723b1ant_PsTdmaCheckForPowerSaveState( + struct btc_coexist *btcoexist, bool new_ps_state) { u8 lps_mode = 0x0; @@ -2128,7 +2136,7 @@ void halbtc8723b1ant_PsTdmaCheckForPowerSaveState(struct btc_coexist *btcoexist, } } -void halbtc8723b1ant_power_save_state(struct btc_coexist *btcoexist, +static void halbtc8723b1ant_power_save_state(struct btc_coexist *btcoexist, u8 ps_type, u8 lps_val, u8 rpwm_val) { @@ -2162,13 +2170,14 @@ void halbtc8723b1ant_power_save_state(struct btc_coexist *btcoexist, } } -void halbtc8723b1ant_action_wifi_only(struct btc_coexist *btcoexist) +static void halbtc8723b1ant_action_wifi_only(struct btc_coexist *btcoexist) { halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0); halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 9); } -void halbtc8723b1ant_monitor_bt_enable_disable(struct btc_coexist *btcoexist) +static void halbtc8723b1ant_monitor_bt_enable_disable( + struct btc_coexist *btcoexist) { static bool pre_bt_disabled = false; static u32 bt_disable_cnt = 0; @@ -2231,7 +2240,7 @@ void halbtc8723b1ant_monitor_bt_enable_disable(struct btc_coexist *btcoexist) * ***************************************************/ /* SCO only or SCO+PAN(HS) */ -void halbtc8723b1ant_action_sco(struct btc_coexist *btcoexist) +static void halbtc8723b1ant_action_sco(struct btc_coexist *btcoexist) { u8 wifi_rssi_state; u32 wifi_bw; @@ -2280,7 +2289,7 @@ void halbtc8723b1ant_action_sco(struct btc_coexist *btcoexist) } -void halbtc8723b1ant_action_hid(struct btc_coexist *btcoexist) +static void halbtc8723b1ant_action_hid(struct btc_coexist *btcoexist) { u8 wifi_rssi_state, bt_rssi_state; u32 wifi_bw; @@ -2331,7 +2340,7 @@ void halbtc8723b1ant_action_hid(struct btc_coexist *btcoexist) } /*A2DP only / PAN(EDR) only/ A2DP+PAN(HS) */ -void halbtc8723b1ant_action_a2dp(struct btc_coexist *btcoexist) +static void halbtc8723b1ant_action_a2dp(struct btc_coexist *btcoexist) { u8 wifi_rssi_state, bt_rssi_state; u32 wifi_bw; @@ -2380,7 +2389,7 @@ void halbtc8723b1ant_action_a2dp(struct btc_coexist *btcoexist) } } -void halbtc8723b1ant_action_a2dp_pan_hs(struct btc_coexist *btcoexist) +static void halbtc8723b1ant_action_a2dp_pan_hs(struct btc_coexist *btcoexist) { u8 wifi_rssi_state, bt_rssi_state, bt_info_ext; u32 wifi_bw; @@ -2430,7 +2439,7 @@ void halbtc8723b1ant_action_a2dp_pan_hs(struct btc_coexist *btcoexist) } } -void halbtc8723b1ant_action_pan_edr(struct btc_coexist *btcoexist) +static void halbtc8723b1ant_action_pan_edr(struct btc_coexist *btcoexist) { u8 wifi_rssi_state, bt_rssi_state; u32 wifi_bw; @@ -2481,7 +2490,7 @@ void halbtc8723b1ant_action_pan_edr(struct btc_coexist *btcoexist) /* PAN(HS) only */ -void halbtc8723b1ant_action_pan_hs(struct btc_coexist *btcoexist) +static void halbtc8723b1ant_action_pan_hs(struct btc_coexist *btcoexist) { u8 wifi_rssi_state, bt_rssi_state; u32 wifi_bw; @@ -2544,7 +2553,7 @@ void halbtc8723b1ant_action_pan_hs(struct btc_coexist *btcoexist) } /*PAN(EDR)+A2DP */ -void halbtc8723b1ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist) +static void halbtc8723b1ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist) { u8 wifi_rssi_state, bt_rssi_state, bt_info_ext; u32 wifi_bw; @@ -2595,7 +2604,7 @@ void halbtc8723b1ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist) } } -void halbtc8723b1ant_action_pan_edr_hid(struct btc_coexist *btcoexist) +static void halbtc8723b1ant_action_pan_edr_hid(struct btc_coexist *btcoexist) { u8 wifi_rssi_state, bt_rssi_state; u32 wifi_bw; @@ -2645,7 +2654,8 @@ void halbtc8723b1ant_action_pan_edr_hid(struct btc_coexist *btcoexist) } /* HID+A2DP+PAN(EDR) */ -void halbtc8723b1ant_action_hid_a2dp_pan_edr(struct btc_coexist *btcoexist) +static void halbtc8723b1ant_action_hid_a2dp_pan_edr( + struct btc_coexist *btcoexist) { u8 wifi_rssi_state, bt_rssi_state, bt_info_ext; u32 wifi_bw; @@ -2695,7 +2705,7 @@ void halbtc8723b1ant_action_hid_a2dp_pan_edr(struct btc_coexist *btcoexist) } } -void halbtc8723b1ant_action_hid_a2dp(struct btc_coexist *btcoexist) +static void halbtc8723b1ant_action_hid_a2dp(struct btc_coexist *btcoexist) { u8 wifi_rssi_state, bt_rssi_state, bt_info_ext; u32 wifi_bw; @@ -2748,13 +2758,13 @@ void halbtc8723b1ant_action_hid_a2dp(struct btc_coexist *btcoexist) * Non-Software Coex Mechanism start * *****************************************************/ -void halbtc8723b1ant_action_hs(struct btc_coexist *btcoexist) +static void halbtc8723b1ant_action_hs(struct btc_coexist *btcoexist) { halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5); halbtc8723b1ant_coex_table_with_type(btcoexist, FORCE_EXEC, 2); } -void halbtc8723b1ant_action_bt_inquiry(struct btc_coexist *btcoexist) +static void halbtc8723b1ant_action_bt_inquiry(struct btc_coexist *btcoexist) { struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; bool wifi_connected = false, ap_enable = false; @@ -2790,8 +2800,9 @@ void halbtc8723b1ant_action_bt_inquiry(struct btc_coexist *btcoexist) } } -void halbtc8723b1ant_action_bt_sco_hid_only_busy(struct btc_coexist * btcoexist, - u8 wifi_status) +static void halbtc8723b1ant_action_bt_sco_hid_only_busy( + struct btc_coexist *btcoexist, + u8 wifi_status) { struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; bool wifi_connected = false; @@ -2810,7 +2821,7 @@ void halbtc8723b1ant_action_bt_sco_hid_only_busy(struct btc_coexist * btcoexist, } } -void halbtc8723b1ant_action_wifi_connected_bt_acl_busy( +static void halbtc8723b1ant_action_wifi_connected_bt_acl_busy( struct btc_coexist *btcoexist, u8 wifi_status) { @@ -2870,7 +2881,8 @@ void halbtc8723b1ant_action_wifi_connected_bt_acl_busy( } } -void halbtc8723b1ant_action_wifi_not_connected(struct btc_coexist *btcoexist) +static void halbtc8723b1ant_action_wifi_not_connected( + struct btc_coexist *btcoexist) { /* power save state */ halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, @@ -2881,7 +2893,7 @@ void halbtc8723b1ant_action_wifi_not_connected(struct btc_coexist *btcoexist) halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0); } -void halbtc8723b1ant_action_wifi_not_connected_asso_auth_scan( +static void halbtc8723b1ant_action_wifi_not_connected_asso_auth_scan( struct btc_coexist *btcoexist) { halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, @@ -2891,7 +2903,8 @@ void halbtc8723b1ant_action_wifi_not_connected_asso_auth_scan( halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1); } -void halbtc8723b1ant_ActionWifiConnectedScan(struct btc_coexist *btcoexist) +static void halbtc8723b1ant_ActionWifiConnectedScan( + struct btc_coexist *btcoexist) { struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; @@ -2921,7 +2934,7 @@ void halbtc8723b1ant_ActionWifiConnectedScan(struct btc_coexist *btcoexist) } } -void halbtc8723b1ant_action_wifi_connected_special_packet( +static void halbtc8723b1ant_action_wifi_connected_special_packet( struct btc_coexist *btcoexist) { bool hs_connecting = false; @@ -2951,7 +2964,7 @@ void halbtc8723b1ant_action_wifi_connected_special_packet( } } -void halbtc8723b1ant_action_wifi_connected(struct btc_coexist *btcoexist) +static void halbtc8723b1ant_action_wifi_connected(struct btc_coexist *btcoexist) { bool wifi_busy = false; bool scan = false, link = false, roam = false; @@ -3031,7 +3044,8 @@ void halbtc8723b1ant_action_wifi_connected(struct btc_coexist *btcoexist) } } -void halbtc8723b1ant_run_sw_coexist_mechanism(struct btc_coexist *btcoexist) +static void halbtc8723b1ant_run_sw_coexist_mechanism( + struct btc_coexist *btcoexist) { u8 algorithm = 0; @@ -3104,7 +3118,7 @@ void halbtc8723b1ant_run_sw_coexist_mechanism(struct btc_coexist *btcoexist) } } -void halbtc8723b1ant_run_coexist_mechanism(struct btc_coexist *btcoexist) +static void halbtc8723b1ant_run_coexist_mechanism(struct btc_coexist *btcoexist) { struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; bool wifi_connected = false, bt_hs_on = false; @@ -3218,7 +3232,7 @@ void halbtc8723b1ant_run_coexist_mechanism(struct btc_coexist *btcoexist) } } -void halbtc8723b1ant_init_coex_dm(struct btc_coexist *btcoexist) +static void halbtc8723b1ant_init_coex_dm(struct btc_coexist *btcoexist) { /* force to reset coex mechanism */ halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, FORCE_EXEC, 6); @@ -3232,7 +3246,8 @@ void halbtc8723b1ant_init_coex_dm(struct btc_coexist *btcoexist) halbtc8723b1ant_coex_table_with_type(btcoexist, FORCE_EXEC, 0); } -void halbtc8723b1ant_init_hw_config(struct btc_coexist *btcoexist, bool backup) +static void halbtc8723b1ant_init_hw_config(struct btc_coexist *btcoexist, + bool backup) { u32 u32tmp = 0; u8 u8tmp = 0; @@ -3304,7 +3319,7 @@ void halbtc8723b1ant_init_hw_config(struct btc_coexist *btcoexist, bool backup) } -void halbtc8723b1ant_wifi_off_hw_cfg(struct btc_coexist *btcoexist) +static void halbtc8723b1ant_wifi_off_hw_cfg(struct btc_coexist *btcoexist) { /* set wlan_act to low */ btcoexist->btc_write_1byte(btcoexist, 0x76e, 0); -- cgit v1.2.3 From f2591796b8a2ca40f7bda245e21f15051eb6c600 Mon Sep 17 00:00:00 2001 From: Konrad Zapalowicz Date: Sat, 24 May 2014 17:23:07 +0200 Subject: staging: rtl8821ae: deal with unused functions in halbtc8723b1ant.c This commit fixes the compiler -Wunused-function warning. Most of the unused functions were removed however for a few of them it was enough to put #define around them. Removed symbols: halbtc8723b1ant_rf_shrink halbtc8723b1ant_dac_swing halbtc8723b1ant_adc_backoff halbtc8723b1ant_agc_table halbtc8723b1ant_coex_alloff halbtc8723b1ant_ps_tdma_type_by_wifi_rssi halbtc8723b1ant_set_sw_rf_rx_lpf_corner halbtc8723b1ant_set_sw_full_time_dac_swing halbtc8723b1ant_set_adc_backoff halbtc8723b1ant_set_agc_table halbtc8723b1ant_set_dac_swing_reg Conditionally compiled symbols: halbtc8723b1ant_bt_auto_report halbtc8723b1ant_set_bt_auto_report halbtc8723b1ant_action_wifi_only halbtc8723b1ant_monitor_bt_enable_disable Signed-off-by: Konrad Zapalowicz Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8821ae/btcoexist/halbtc8723b1ant.c | 235 +-------------------- 1 file changed, 4 insertions(+), 231 deletions(-) diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtc8723b1ant.c b/drivers/staging/rtl8821ae/btcoexist/halbtc8723b1ant.c index 5337782de1a9..c9693944c137 100644 --- a/drivers/staging/rtl8821ae/btcoexist/halbtc8723b1ant.c +++ b/drivers/staging/rtl8821ae/btcoexist/halbtc8723b1ant.c @@ -810,6 +810,7 @@ static void halbtc8723b1ant_dec_bt_pwr(struct btc_coexist *btcoexist, coex_dm->pre_dec_bt_pwr = coex_dm->cur_dec_bt_pwr; } +#if (BT_AUTO_REPORT_ONLY_8723B_1ANT == 0) static void halbtc8723b1ant_set_bt_auto_report(struct btc_coexist *btcoexist, bool enable_auto_report) { @@ -852,6 +853,7 @@ static void halbtc8723b1ant_bt_auto_report(struct btc_coexist *btcoexist, coex_dm->pre_bt_auto_report = coex_dm->cur_bt_auto_report; } +#endif static void halbtc8723b1ant_fw_dac_swing_lvl(struct btc_coexist *btcoexist, bool force_exec, u8 fw_dac_swing_lvl) @@ -880,55 +882,6 @@ static void halbtc8723b1ant_fw_dac_swing_lvl(struct btc_coexist *btcoexist, coex_dm->pre_fw_dac_swing_lvl = coex_dm->cur_fw_dac_swing_lvl; } -static void halbtc8723b1ant_set_sw_rf_rx_lpf_corner( - struct btc_coexist *btcoexist, - bool rx_rf_shrink_on) -{ - if (rx_rf_shrink_on) { - /*Shrink RF Rx LPF corner */ - BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, - "[BTCoex], Shrink RF Rx LPF corner!!\n"); - btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1e, - 0xfffff, 0xffff7); - } else { - /*Resume RF Rx LPF corner - * After initialized, we can use coex_dm->btRf0x1eBackup */ - if (btcoexist->initilized) { - BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, - "[BTCoex], Resume RF Rx LPF corner!!\n"); - btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, - 0x1e, 0xfffff, - coex_dm->bt_rf0x1e_backup); - } - } -} - -static void halbtc8723b1ant_rf_shrink(struct btc_coexist *btcoexist, - bool force_exec, bool rx_rf_shrink_on) -{ - BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, - "[BTCoex], %s turn Rx RF Shrink = %s\n", - (force_exec? "force to":""), - ((rx_rf_shrink_on)? "ON":"OFF")); - coex_dm->cur_rf_rx_lpf_shrink = rx_rf_shrink_on; - - if (!force_exec) { - BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, - "[BTCoex], bPreRfRxLpfShrink=%d, " - "bCurRfRxLpfShrink=%d\n", - coex_dm->pre_rf_rx_lpf_shrink, - coex_dm->cur_rf_rx_lpf_shrink); - - if (coex_dm->pre_rf_rx_lpf_shrink == - coex_dm->cur_rf_rx_lpf_shrink) - return; - } - halbtc8723b1ant_set_sw_rf_rx_lpf_corner(btcoexist, - coex_dm->cur_rf_rx_lpf_shrink); - - coex_dm->pre_rf_rx_lpf_shrink = coex_dm->cur_rf_rx_lpf_shrink; -} - static void halbtc8723b1ant_set_sw_penalty_tx_rate_adaptive( struct btc_coexist *btcoexist, bool low_penalty_ra) @@ -968,153 +921,6 @@ static void halbtc8723b1ant_low_penalty_ra(struct btc_coexist *btcoexist, coex_dm->pre_low_penalty_ra = coex_dm->cur_low_penalty_ra; } -static void halbtc8723b1ant_set_dac_swing_reg(struct btc_coexist *btcoexist, - u32 level) -{ - u8 val = (u8) level; - - BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, - "[BTCoex], Write SwDacSwing = 0x%x\n", level); - btcoexist->btc_write_1byte_bitmask(btcoexist, 0x883, 0x3e, val); -} - -static void halbtc8723b1ant_set_sw_full_time_dac_swing( - struct btc_coexist *btcoexist, - bool sw_dac_swing_on, - u32 sw_dac_swing_lvl) -{ - if (sw_dac_swing_on) - halbtc8723b1ant_set_dac_swing_reg(btcoexist, sw_dac_swing_lvl); - else - halbtc8723b1ant_set_dac_swing_reg(btcoexist, 0x18); -} - - -static void halbtc8723b1ant_dac_swing(struct btc_coexist *btcoexist, - bool force_exec, bool dac_swing_on, u32 dac_swing_lvl) -{ - BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, - "[BTCoex], %s turn DacSwing=%s, dac_swing_lvl=0x%x\n", - (force_exec ? "force to" : ""), (dac_swing_on ? "ON" : "OFF"), - dac_swing_lvl); - - coex_dm->cur_dac_swing_on = dac_swing_on; - coex_dm->cur_dac_swing_lvl = dac_swing_lvl; - - if (!force_exec) { - BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, - "[BTCoex], bPreDacSwingOn=%d, preDacSwingLvl=0x%x, " - "bCurDacSwingOn=%d, curDacSwingLvl=0x%x\n", - coex_dm->pre_dac_swing_on, coex_dm->pre_dac_swing_lvl, - coex_dm->cur_dac_swing_on, - coex_dm->cur_dac_swing_lvl); - - if ((coex_dm->pre_dac_swing_on == coex_dm->cur_dac_swing_on) && - (coex_dm->pre_dac_swing_lvl == coex_dm->cur_dac_swing_lvl)) - return; - } - mdelay(30); - halbtc8723b1ant_set_sw_full_time_dac_swing(btcoexist, dac_swing_on, - dac_swing_lvl); - - coex_dm->pre_dac_swing_on = coex_dm->cur_dac_swing_on; - coex_dm->pre_dac_swing_lvl = coex_dm->cur_dac_swing_lvl; -} - -static void halbtc8723b1ant_set_adc_backoff(struct btc_coexist *btcoexist, - bool adc_backoff) -{ - if (adc_backoff) { - BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, - "[BTCoex], BB BackOff Level On!\n"); - btcoexist->btc_write_1byte_bitmask(btcoexist, 0x8db, 0x60, 0x3); - } else { - BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, - "[BTCoex], BB BackOff Level Off!\n"); - btcoexist->btc_write_1byte_bitmask(btcoexist, 0x8db, 0x60, 0x1); - } -} - -static void halbtc8723b1ant_adc_backoff(struct btc_coexist *btcoexist, - bool force_exec, bool adc_backoff) -{ - BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, - "[BTCoex], %s turn AdcBackOff = %s\n", - (force_exec ? "force to" : ""), (adc_backoff ? "ON" : "OFF")); - coex_dm->cur_adc_backoff = adc_backoff; - - if (!force_exec) { - BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, - "[BTCoex], bPreAdcBackOff=%d, bCurAdcBackOff=%d\n", - coex_dm->pre_adc_backoff, coex_dm->cur_adc_backoff); - - if(coex_dm->pre_adc_backoff == coex_dm->cur_adc_backoff) - return; - } - halbtc8723b1ant_set_adc_backoff(btcoexist, coex_dm->cur_adc_backoff); - - coex_dm->pre_adc_backoff = - coex_dm->cur_adc_backoff; -} - -static void halbtc8723b1ant_set_agc_table(struct btc_coexist *btcoexist, - bool adc_table_en) -{ - u8 rssi_adjust_val = 0; - - btcoexist->btc_set_rf_reg(btcoexist, - BTC_RF_A, 0xef, 0xfffff, 0x02000); - if (adc_table_en) { - BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, - "[BTCoex], Agc Table On!\n"); - btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x3b, - 0xfffff, 0x3fa58); - btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x3b, - 0xfffff, 0x37a58); - btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x3b, - 0xfffff, 0x2fa58); - rssi_adjust_val = 8; - } else { - BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, - "[BTCoex], Agc Table Off!\n"); - btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x3b, - 0xfffff, 0x39258); - btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x3b, - 0xfffff, 0x31258); - btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x3b, - 0xfffff, 0x29258); - } - btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0xef, 0xfffff, 0x0); - - /* set rssi_adjust_val for wifi module. */ - btcoexist->btc_set(btcoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, - &rssi_adjust_val); -} - - -static void halbtc8723b1ant_agc_table(struct btc_coexist *btcoexist, - bool force_exec, bool adc_table_en) -{ - BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, - "[BTCoex], %s %s Agc Table\n", - (force_exec ? "force to" : ""), - (adc_table_en ? "Enable" : "Disable")); - coex_dm->cur_agc_table_en = adc_table_en; - - if (!force_exec) { - BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, - "[BTCoex], bPreAgcTableEn=%d, bCurAgcTableEn=%d\n", - coex_dm->pre_agc_table_en, - coex_dm->cur_agc_table_en); - - if(coex_dm->pre_agc_table_en == coex_dm->cur_agc_table_en) - return; - } - halbtc8723b1ant_set_agc_table(btcoexist, adc_table_en); - - coex_dm->pre_agc_table_en = coex_dm->cur_agc_table_en; -} - static void halbtc8723b1ant_set_coex_table(struct btc_coexist *btcoexist, u32 val0x6c0, u32 val0x6c4, u32 val0x6c8, u8 val0x6cc) @@ -1790,21 +1596,6 @@ static void halbtc8723b1ant_ps_tdma(struct btc_coexist *btcoexist, coex_dm->pre_ps_tdma = coex_dm->cur_ps_tdma; } -static void halbtc8723b1ant_coex_alloff(struct btc_coexist *btcoexist) -{ - /* fw all off */ - halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); - halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); - - /* sw all off */ - halbtc8723b1ant_sw_mechanism1(btcoexist, false, false, false, false); - halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, false, 0x18); - - - /* hw all off */ - halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0); -} - static bool halbtc8723b1ant_is_common_action(struct btc_coexist *btcoexist) { bool commom = false, wifi_connected = false; @@ -2090,26 +1881,6 @@ static void halbtc8723b1ant_tdma_duration_adjust_for_acl( } } -static u8 halbtc8723b1ant_ps_tdma_type_by_wifi_rssi(s32 wifi_rssi, - s32 pre_wifi_rssi, u8 wifi_rssi_thresh) -{ - u8 ps_tdma_type=0; - - if (wifi_rssi > pre_wifi_rssi) { - if (wifi_rssi > (wifi_rssi_thresh + 5)) - ps_tdma_type = 26; - else - ps_tdma_type = 25; - } else { - if (wifi_rssi > wifi_rssi_thresh) - ps_tdma_type = 26; - else - ps_tdma_type = 25; - } - - return ps_tdma_type; -} - static void halbtc8723b1ant_PsTdmaCheckForPowerSaveState( struct btc_coexist *btcoexist, bool new_ps_state) { @@ -2170,6 +1941,7 @@ static void halbtc8723b1ant_power_save_state(struct btc_coexist *btcoexist, } } +#if (BT_AUTO_REPORT_ONLY_8723B_1ANT == 0) static void halbtc8723b1ant_action_wifi_only(struct btc_coexist *btcoexist) { halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0); @@ -2233,6 +2005,7 @@ static void halbtc8723b1ant_monitor_bt_enable_disable( } } } +#endif /*************************************************** * -- cgit v1.2.3 From 8b596f5993860781081ac9d8f4d46c35036e4697 Mon Sep 17 00:00:00 2001 From: Konrad Zapalowicz Date: Sat, 24 May 2014 17:23:08 +0200 Subject: staging: rtl8821ae: add static for local symbols in halbtc8723b2ant.c This commit fixes the sparse warning: "warning: symbol 'X' was not declared. Should it be static?" Where the X is one of the following: glbt_info_src_8723b_2ant glcoex_ver_date_8723b_2ant glcoex_ver_8723b_2ant halbtc8723b2ant_bt_rssi_state halbtc8723b2ant_wifi_rssi_state halbtc8723b2ant_monitor_bt_enable_disable halbtc8723b2ant_monitor_bt_ctr halbtc8723b2ant_query_bt_info halbtc8723b2ant_is_wifi_status_changed halbtc8723b2ant_update_bt_link_info halbtc8723b2ant_action_algorithm halbtc8723b2ant_need_to_dec_bt_pwr halbtc8723b2ant_set_fw_dac_swing_level halbtc8723b2ant_set_fw_dec_bt_pwr halbtc8723b2ant_dec_bt_pwr halbtc8723b2ant_set_bt_auto_report halbtc8723b2ant_bt_auto_report halbtc8723b2ant_fw_dac_swing_lvl halbtc8723b2ant_set_sw_rf_rx_lpf_corner halbtc8723b2ant_rf_shrink halbtc8723b2ant_set_sw_penalty_txrate_adaptive halbtc8723b2ant_low_penalty_ra halbtc8723b2ant_set_dac_swing_reg halbtc8723b2ant_set_sw_fulltime_dac_swing halbtc8723b2ant_dac_swing halbtc8723b2ant_set_adc_backoff halbtc8723b2ant_adc_backoff halbtc8723b2ant_set_agc_table halbtc8723b2ant_agc_table halbtc8723b2ant_set_coex_table halbtc8723b2ant_coex_table halbtc8723b2ant_coex_table_with_type halbtc8723b2ant_set_fw_ignore_wlan_act halbtc8723b2ant_ignore_wlan_act halbtc8723b2ant_set_fw_ps_tdma halbtc8723b2ant_sw_mechanism1 halbtc8723b2ant_sw_mechanism2 halbtc8723b2ant_set_ant_path halbtc8723b2ant_ps_tdma halbtc8723b2ant_coex_alloff halbtc8723b2ant_init_coex_dm halbtc8723b2ant_action_bt_inquiry halbtc8723b2ant_is_common_action halbtc8723b2ant_tdma_duration_adjust halbtc8723b2ant_action_sco halbtc8723b2ant_action_hid halbtc8723b2ant_action_a2dp halbtc8723b2ant_action_a2dp_pan_hs halbtc8723b2ant_action_pan_edr halbtc8723b2ant_action_pan_hs halbtc8723b2ant_action_pan_edr_a2dp halbtc8723b2ant_action_pan_edr_hid halbtc8723b2ant_action_hid_a2dp_pan_edr halbtc8723b2ant_action_hid_a2dp halbtc8723b2ant_run_coexist_mechanism halbtc8723b2ant_wifioff_hwcfg Signed-off-by: Konrad Zapalowicz Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8821ae/btcoexist/halbtc8723b2ant.c | 141 +++++++++++---------- 1 file changed, 75 insertions(+), 66 deletions(-) diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtc8723b2ant.c b/drivers/staging/rtl8821ae/btcoexist/halbtc8723b2ant.c index d337bd0b3c1b..f67b375dab11 100644 --- a/drivers/staging/rtl8821ae/btcoexist/halbtc8723b2ant.c +++ b/drivers/staging/rtl8821ae/btcoexist/halbtc8723b2ant.c @@ -20,14 +20,14 @@ static struct coex_dm_8723b_2ant *coex_dm = &glcoex_dm_8723b_2ant; static struct coex_sta_8723b_2ant glcoex_sta_8723b_2ant; static struct coex_sta_8723b_2ant *coex_sta = &glcoex_sta_8723b_2ant; -const char *const glbt_info_src_8723b_2ant[] = { +static const char *const glbt_info_src_8723b_2ant[] = { "BT Info[wifi fw]", "BT Info[bt rsp]", "BT Info[bt auto report]", }; -u32 glcoex_ver_date_8723b_2ant = 20131113; -u32 glcoex_ver_8723b_2ant = 0x3f; +static u32 glcoex_ver_date_8723b_2ant = 20131113; +static u32 glcoex_ver_8723b_2ant = 0x3f; /************************************************************** * local function proto type if needed @@ -35,7 +35,8 @@ u32 glcoex_ver_8723b_2ant = 0x3f; /************************************************************** * local function start with halbtc8723b2ant_ **************************************************************/ -u8 halbtc8723b2ant_bt_rssi_state(u8 level_num, u8 rssi_thresh, u8 rssi_thresh1) +static u8 halbtc8723b2ant_bt_rssi_state(u8 level_num, u8 rssi_thresh, + u8 rssi_thresh1) { s32 bt_rssi = 0; u8 bt_rssi_state = coex_sta->pre_bt_rssi_state; @@ -132,7 +133,7 @@ u8 halbtc8723b2ant_bt_rssi_state(u8 level_num, u8 rssi_thresh, u8 rssi_thresh1) return bt_rssi_state; } -u8 halbtc8723b2ant_wifi_rssi_state(struct btc_coexist *btcoexist, +static u8 halbtc8723b2ant_wifi_rssi_state(struct btc_coexist *btcoexist, u8 index, u8 level_num, u8 rssi_thresh, u8 rssi_thresh1) { @@ -246,7 +247,8 @@ u8 halbtc8723b2ant_wifi_rssi_state(struct btc_coexist *btcoexist, return wifi_rssi_state; } -void halbtc8723b2ant_monitor_bt_enable_disable(struct btc_coexist *btcoexist) +static void halbtc8723b2ant_monitor_bt_enable_disable( + struct btc_coexist *btcoexist) { static bool pre_bt_disabled = false; static u32 bt_disable_cnt = 0; @@ -299,7 +301,7 @@ void halbtc8723b2ant_monitor_bt_enable_disable(struct btc_coexist *btcoexist) } } -void halbtc8723b2ant_monitor_bt_ctr(struct btc_coexist *btcoexist) +static void halbtc8723b2ant_monitor_bt_ctr(struct btc_coexist *btcoexist) { u32 reg_hp_txrx, reg_lp_txrx, u32tmp; u32 reg_hp_tx = 0, reg_hp_rx = 0; @@ -332,7 +334,7 @@ void halbtc8723b2ant_monitor_bt_ctr(struct btc_coexist *btcoexist) btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc); } -void halbtc8723b2ant_query_bt_info(struct btc_coexist *btcoexist) +static void halbtc8723b2ant_query_bt_info(struct btc_coexist *btcoexist) { u8 h2c_parameter[1] ={0}; @@ -347,7 +349,8 @@ void halbtc8723b2ant_query_bt_info(struct btc_coexist *btcoexist) btcoexist->btc_fill_h2c(btcoexist, 0x61, 1, h2c_parameter); } -bool halbtc8723b2ant_is_wifi_status_changed(struct btc_coexist *btcoexist) +static bool halbtc8723b2ant_is_wifi_status_changed( + struct btc_coexist *btcoexist) { static bool pre_wifi_busy = false; static bool pre_under_4way = false; @@ -382,7 +385,7 @@ bool halbtc8723b2ant_is_wifi_status_changed(struct btc_coexist *btcoexist) return false; } -void halbtc8723b2ant_update_bt_link_info(struct btc_coexist *btcoexist) +static void halbtc8723b2ant_update_bt_link_info(struct btc_coexist *btcoexist) { /*struct btc_stack_info *stack_info = &btcoexist->stack_info;*/ struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; @@ -446,7 +449,7 @@ void halbtc8723b2ant_update_bt_link_info(struct btc_coexist *btcoexist) bt_link_info->hid_only = false; } -u8 halbtc8723b2ant_action_algorithm(struct btc_coexist *btcoexist) +static u8 halbtc8723b2ant_action_algorithm(struct btc_coexist *btcoexist) { struct btc_bt_link_info *bt_link_info=&btcoexist->bt_link_info; bool bt_hs_on = false; @@ -634,7 +637,7 @@ u8 halbtc8723b2ant_action_algorithm(struct btc_coexist *btcoexist) return algorithm; } -bool halbtc8723b2ant_need_to_dec_bt_pwr(struct btc_coexist *btcoexist) +static bool halbtc8723b2ant_need_to_dec_bt_pwr(struct btc_coexist *btcoexist) { bool bRet = false; bool bt_hs_on = false, wifi_connected = false; @@ -675,8 +678,9 @@ bool halbtc8723b2ant_need_to_dec_bt_pwr(struct btc_coexist *btcoexist) return bRet; } -void halbtc8723b2ant_set_fw_dac_swing_level(struct btc_coexist *btcoexist, - u8 dac_swing_lvl) +static void halbtc8723b2ant_set_fw_dac_swing_level( + struct btc_coexist *btcoexist, + u8 dac_swing_lvl) { u8 h2c_parameter[1] ={0}; @@ -692,7 +696,7 @@ void halbtc8723b2ant_set_fw_dac_swing_level(struct btc_coexist *btcoexist, btcoexist->btc_fill_h2c(btcoexist, 0x64, 1, h2c_parameter); } -void halbtc8723b2ant_set_fw_dec_bt_pwr(struct btc_coexist *btcoexist, +static void halbtc8723b2ant_set_fw_dec_bt_pwr(struct btc_coexist *btcoexist, bool dec_bt_pwr) { u8 h2c_parameter[1] = {0}; @@ -709,8 +713,8 @@ void halbtc8723b2ant_set_fw_dec_bt_pwr(struct btc_coexist *btcoexist, btcoexist->btc_fill_h2c(btcoexist, 0x62, 1, h2c_parameter); } -void halbtc8723b2ant_dec_bt_pwr(struct btc_coexist *btcoexist, - bool force_exec, bool dec_bt_pwr) +static void halbtc8723b2ant_dec_bt_pwr(struct btc_coexist *btcoexist, + bool force_exec, bool dec_bt_pwr) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, "[BTCoex], %s Dec BT power = %s\n", @@ -730,7 +734,7 @@ void halbtc8723b2ant_dec_bt_pwr(struct btc_coexist *btcoexist, coex_dm->pre_dec_bt_pwr = coex_dm->cur_dec_bt_pwr; } -void halbtc8723b2ant_set_bt_auto_report(struct btc_coexist *btcoexist, +static void halbtc8723b2ant_set_bt_auto_report(struct btc_coexist *btcoexist, bool enable_auto_report) { u8 h2c_parameter[1] = {0}; @@ -747,7 +751,7 @@ void halbtc8723b2ant_set_bt_auto_report(struct btc_coexist *btcoexist, btcoexist->btc_fill_h2c(btcoexist, 0x68, 1, h2c_parameter); } -void halbtc8723b2ant_bt_auto_report(struct btc_coexist *btcoexist, +static void halbtc8723b2ant_bt_auto_report(struct btc_coexist *btcoexist, bool force_exec, bool enable_auto_report) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, @@ -772,7 +776,7 @@ void halbtc8723b2ant_bt_auto_report(struct btc_coexist *btcoexist, coex_dm->pre_bt_auto_report = coex_dm->cur_bt_auto_report; } -void halbtc8723b2ant_fw_dac_swing_lvl(struct btc_coexist *btcoexist, +static void halbtc8723b2ant_fw_dac_swing_lvl(struct btc_coexist *btcoexist, bool force_exec, u8 fw_dac_swing_lvl) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, @@ -797,8 +801,9 @@ void halbtc8723b2ant_fw_dac_swing_lvl(struct btc_coexist *btcoexist, coex_dm->pre_fw_dac_swing_lvl = coex_dm->cur_fw_dac_swing_lvl; } -void halbtc8723b2ant_set_sw_rf_rx_lpf_corner(struct btc_coexist *btcoexist, - bool rx_rf_shrink_on) +static void halbtc8723b2ant_set_sw_rf_rx_lpf_corner( + struct btc_coexist *btcoexist, + bool rx_rf_shrink_on) { if (rx_rf_shrink_on) { /* Shrink RF Rx LPF corner */ @@ -819,7 +824,7 @@ void halbtc8723b2ant_set_sw_rf_rx_lpf_corner(struct btc_coexist *btcoexist, } } -void halbtc8723b2ant_rf_shrink(struct btc_coexist *btcoexist, +static void halbtc8723b2ant_rf_shrink(struct btc_coexist *btcoexist, bool force_exec, bool rx_rf_shrink_on) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, @@ -844,7 +849,7 @@ void halbtc8723b2ant_rf_shrink(struct btc_coexist *btcoexist, coex_dm->pre_rf_rx_lpf_shrink = coex_dm->cur_rf_rx_lpf_shrink; } -void halbtc8723b2ant_set_sw_penalty_txrate_adaptive( +static void halbtc8723b2ant_set_sw_penalty_txrate_adaptive( struct btc_coexist *btcoexist, bool low_penalty_ra) { @@ -868,7 +873,7 @@ void halbtc8723b2ant_set_sw_penalty_txrate_adaptive( btcoexist->btc_fill_h2c(btcoexist, 0x69, 6, h2c_parameter); } -void halbtc8723b2ant_low_penalty_ra(struct btc_coexist *btcoexist, +static void halbtc8723b2ant_low_penalty_ra(struct btc_coexist *btcoexist, bool force_exec, bool low_penalty_ra) { /*return; */ @@ -893,7 +898,7 @@ void halbtc8723b2ant_low_penalty_ra(struct btc_coexist *btcoexist, coex_dm->pre_low_penalty_ra = coex_dm->cur_low_penalty_ra; } -void halbtc8723b2ant_set_dac_swing_reg(struct btc_coexist * btcoexist, +static void halbtc8723b2ant_set_dac_swing_reg(struct btc_coexist *btcoexist, u32 level) { u8 val = (u8) level; @@ -902,9 +907,10 @@ void halbtc8723b2ant_set_dac_swing_reg(struct btc_coexist * btcoexist, btcoexist->btc_write_1byte_bitmask(btcoexist, 0x883, 0x3e, val); } -void halbtc8723b2ant_set_sw_fulltime_dac_swing(struct btc_coexist *btcoexist, - bool sw_dac_swing_on, - u32 sw_dac_swing_lvl) +static void halbtc8723b2ant_set_sw_fulltime_dac_swing( + struct btc_coexist *btcoexist, + bool sw_dac_swing_on, + u32 sw_dac_swing_lvl) { if(sw_dac_swing_on) halbtc8723b2ant_set_dac_swing_reg(btcoexist, sw_dac_swing_lvl); @@ -913,7 +919,7 @@ void halbtc8723b2ant_set_sw_fulltime_dac_swing(struct btc_coexist *btcoexist, } -void halbtc8723b2ant_dac_swing(struct btc_coexist *btcoexist, +static void halbtc8723b2ant_dac_swing(struct btc_coexist *btcoexist, bool force_exec, bool dac_swing_on, u32 dac_swing_lvl) { @@ -944,7 +950,7 @@ void halbtc8723b2ant_dac_swing(struct btc_coexist *btcoexist, coex_dm->pre_dac_swing_lvl = coex_dm->cur_dac_swing_lvl; } -void halbtc8723b2ant_set_adc_backoff(struct btc_coexist *btcoexist, +static void halbtc8723b2ant_set_adc_backoff(struct btc_coexist *btcoexist, bool adc_backoff) { if (adc_backoff) { @@ -958,7 +964,7 @@ void halbtc8723b2ant_set_adc_backoff(struct btc_coexist *btcoexist, } } -void halbtc8723b2ant_adc_backoff(struct btc_coexist *btcoexist, +static void halbtc8723b2ant_adc_backoff(struct btc_coexist *btcoexist, bool force_exec, bool adc_backoff) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, @@ -980,7 +986,7 @@ void halbtc8723b2ant_adc_backoff(struct btc_coexist *btcoexist, coex_dm->pre_adc_back_off = coex_dm->cur_adc_back_off; } -void halbtc8723b2ant_set_agc_table(struct btc_coexist *btcoexist, +static void halbtc8723b2ant_set_agc_table(struct btc_coexist *btcoexist, bool agc_table_en) { u8 rssi_adjust_val = 0; @@ -1054,7 +1060,7 @@ void halbtc8723b2ant_set_agc_table(struct btc_coexist *btcoexist, &rssi_adjust_val); } -void halbtc8723b2ant_agc_table(struct btc_coexist *btcoexist, +static void halbtc8723b2ant_agc_table(struct btc_coexist *btcoexist, bool force_exec, bool agc_table_en) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, @@ -1076,7 +1082,7 @@ void halbtc8723b2ant_agc_table(struct btc_coexist *btcoexist, coex_dm->pre_agc_table_en = coex_dm->cur_agc_table_en; } -void halbtc8723b2ant_set_coex_table(struct btc_coexist *btcoexist, +static void halbtc8723b2ant_set_coex_table(struct btc_coexist *btcoexist, u32 val0x6c0, u32 val0x6c4, u32 val0x6c8, u8 val0x6cc) { @@ -1097,7 +1103,7 @@ void halbtc8723b2ant_set_coex_table(struct btc_coexist *btcoexist, btcoexist->btc_write_1byte(btcoexist, 0x6cc, val0x6cc); } -void halbtc8723b2ant_coex_table(struct btc_coexist *btcoexist, +static void halbtc8723b2ant_coex_table(struct btc_coexist *btcoexist, bool force_exec, u32 val0x6c0, u32 val0x6c4, u32 val0x6c8, u8 val0x6cc) @@ -1141,7 +1147,7 @@ void halbtc8723b2ant_coex_table(struct btc_coexist *btcoexist, coex_dm->pre_val0x6cc = coex_dm->cur_val0x6cc; } -void halbtc8723b2ant_coex_table_with_type(struct btc_coexist *btcoexist, +static void halbtc8723b2ant_coex_table_with_type(struct btc_coexist *btcoexist, bool force_exec, u8 type) { switch (type) { @@ -1202,8 +1208,9 @@ void halbtc8723b2ant_coex_table_with_type(struct btc_coexist *btcoexist, } } -void halbtc8723b2ant_set_fw_ignore_wlan_act(struct btc_coexist *btcoexist, - bool enable) +static void halbtc8723b2ant_set_fw_ignore_wlan_act( + struct btc_coexist *btcoexist, + bool enable) { u8 h2c_parameter[1] ={0}; @@ -1217,7 +1224,7 @@ void halbtc8723b2ant_set_fw_ignore_wlan_act(struct btc_coexist *btcoexist, btcoexist->btc_fill_h2c(btcoexist, 0x63, 1, h2c_parameter); } -void halbtc8723b2ant_ignore_wlan_act(struct btc_coexist *btcoexist, +static void halbtc8723b2ant_ignore_wlan_act(struct btc_coexist *btcoexist, bool force_exec, bool enable) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, @@ -1241,8 +1248,8 @@ void halbtc8723b2ant_ignore_wlan_act(struct btc_coexist *btcoexist, coex_dm->pre_ignore_wlan_act = coex_dm->cur_ignore_wlan_act; } -void halbtc8723b2ant_set_fw_ps_tdma(struct btc_coexist *btcoexist, u8 byte1, - u8 byte2, u8 byte3, u8 byte4, u8 byte5) +static void halbtc8723b2ant_set_fw_ps_tdma(struct btc_coexist *btcoexist, + u8 byte1, u8 byte2, u8 byte3, u8 byte4, u8 byte5) { u8 h2c_parameter[5] ={0}; @@ -1267,7 +1274,7 @@ void halbtc8723b2ant_set_fw_ps_tdma(struct btc_coexist *btcoexist, u8 byte1, btcoexist->btc_fill_h2c(btcoexist, 0x60, 5, h2c_parameter); } -void halbtc8723b2ant_sw_mechanism1(struct btc_coexist *btcoexist, +static void halbtc8723b2ant_sw_mechanism1(struct btc_coexist *btcoexist, bool shrink_rx_lpf, bool low_penalty_ra, bool limited_dig, bool bt_lna_constrain) { @@ -1287,7 +1294,7 @@ void halbtc8723b2ant_sw_mechanism1(struct btc_coexist *btcoexist, halbtc8723b2ant_low_penalty_ra(btcoexist, NORMAL_EXEC, low_penalty_ra); } -void halbtc8723b2ant_sw_mechanism2(struct btc_coexist *btcoexist, +static void halbtc8723b2ant_sw_mechanism2(struct btc_coexist *btcoexist, bool agc_table_shift, bool adc_backoff, bool sw_dac_swing, u32 dac_swing_lvl) { @@ -1297,7 +1304,7 @@ void halbtc8723b2ant_sw_mechanism2(struct btc_coexist *btcoexist, dac_swing_lvl); } -void halbtc8723b2ant_set_ant_path(struct btc_coexist *btcoexist, +static void halbtc8723b2ant_set_ant_path(struct btc_coexist *btcoexist, u8 antpos_type, bool init_hwcfg, bool wifi_off) { @@ -1377,8 +1384,9 @@ void halbtc8723b2ant_set_ant_path(struct btc_coexist *btcoexist, } -void halbtc8723b2ant_ps_tdma(struct btc_coexist *btcoexist, bool force_exec, - bool turn_on, u8 type) +static void halbtc8723b2ant_ps_tdma(struct btc_coexist *btcoexist, + bool force_exec, + bool turn_on, u8 type) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, @@ -1514,7 +1522,7 @@ void halbtc8723b2ant_ps_tdma(struct btc_coexist *btcoexist, bool force_exec, coex_dm->pre_ps_tdma = coex_dm->cur_ps_tdma; } -void halbtc8723b2ant_coex_alloff(struct btc_coexist *btcoexist) +static void halbtc8723b2ant_coex_alloff(struct btc_coexist *btcoexist) { /* fw all off */ halbtc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 1); @@ -1530,7 +1538,7 @@ void halbtc8723b2ant_coex_alloff(struct btc_coexist *btcoexist) halbtc8723b2ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0); } -void halbtc8723b2ant_init_coex_dm(struct btc_coexist *btcoexist) +static void halbtc8723b2ant_init_coex_dm(struct btc_coexist *btcoexist) { /* force to reset coex mechanism*/ @@ -1542,7 +1550,7 @@ void halbtc8723b2ant_init_coex_dm(struct btc_coexist *btcoexist) halbtc8723b2ant_sw_mechanism2(btcoexist, false, false, false, 0x18); } -void halbtc8723b2ant_action_bt_inquiry(struct btc_coexist *btcoexist) +static void halbtc8723b2ant_action_bt_inquiry(struct btc_coexist *btcoexist) { bool wifi_connected = false; bool low_pwr_disable = true; @@ -1572,7 +1580,7 @@ void halbtc8723b2ant_action_bt_inquiry(struct btc_coexist *btcoexist) false, false); } -bool halbtc8723b2ant_is_common_action(struct btc_coexist *btcoexist) +static bool halbtc8723b2ant_is_common_action(struct btc_coexist *btcoexist) { bool bCommon = false, wifi_connected = false; bool wifi_busy = false; @@ -1713,7 +1721,8 @@ bool halbtc8723b2ant_is_common_action(struct btc_coexist *btcoexist) return bCommon; } -void halbtc8723b2ant_tdma_duration_adjust(struct btc_coexist *btcoexist, + +static void halbtc8723b2ant_tdma_duration_adjust(struct btc_coexist *btcoexist, bool sco_hid, bool tx_pause, u8 max_interval) { @@ -2772,7 +2781,7 @@ void halbtc8723b2ant_tdma_duration_adjust(struct btc_coexist *btcoexist, } /* SCO only or SCO+PAN(HS) */ -void halbtc8723b2ant_action_sco(struct btc_coexist *btcoexist) +static void halbtc8723b2ant_action_sco(struct btc_coexist *btcoexist) { u8 wifi_rssi_state; u32 wifi_bw; @@ -2830,8 +2839,7 @@ void halbtc8723b2ant_action_sco(struct btc_coexist *btcoexist) } } - -void halbtc8723b2ant_action_hid(struct btc_coexist *btcoexist) +static void halbtc8723b2ant_action_hid(struct btc_coexist *btcoexist) { u8 wifi_rssi_state, bt_rssi_state; u32 wifi_bw; @@ -2893,7 +2901,7 @@ void halbtc8723b2ant_action_hid(struct btc_coexist *btcoexist) } /*A2DP only / PAN(EDR) only/ A2DP+PAN(HS)*/ -void halbtc8723b2ant_action_a2dp(struct btc_coexist *btcoexist) +static void halbtc8723b2ant_action_a2dp(struct btc_coexist *btcoexist) { u8 wifi_rssi_state, wifi_rssi_state1, bt_rssi_state; u32 wifi_bw; @@ -2981,7 +2989,7 @@ void halbtc8723b2ant_action_a2dp(struct btc_coexist *btcoexist) } } -void halbtc8723b2ant_action_a2dp_pan_hs(struct btc_coexist *btcoexist) +static void halbtc8723b2ant_action_a2dp_pan_hs(struct btc_coexist *btcoexist) { u8 wifi_rssi_state; u32 wifi_bw; @@ -3034,7 +3042,7 @@ void halbtc8723b2ant_action_a2dp_pan_hs(struct btc_coexist *btcoexist) } } -void halbtc8723b2ant_action_pan_edr(struct btc_coexist *btcoexist) +static void halbtc8723b2ant_action_pan_edr(struct btc_coexist *btcoexist) { u8 wifi_rssi_state, bt_rssi_state; u32 wifi_bw; @@ -3091,9 +3099,8 @@ void halbtc8723b2ant_action_pan_edr(struct btc_coexist *btcoexist) } } - /*PAN(HS) only*/ -void halbtc8723b2ant_action_pan_hs(struct btc_coexist *btcoexist) +static void halbtc8723b2ant_action_pan_hs(struct btc_coexist *btcoexist) { u8 wifi_rssi_state; u32 wifi_bw; @@ -3146,7 +3153,7 @@ void halbtc8723b2ant_action_pan_hs(struct btc_coexist *btcoexist) } /*PAN(EDR)+A2DP*/ -void halbtc8723b2ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist) +static void halbtc8723b2ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist) { u8 wifi_rssi_state, bt_rssi_state; u32 wifi_bw; @@ -3210,7 +3217,7 @@ void halbtc8723b2ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist) } } -void halbtc8723b2ant_action_pan_edr_hid(struct btc_coexist *btcoexist) +static void halbtc8723b2ant_action_pan_edr_hid(struct btc_coexist *btcoexist) { u8 wifi_rssi_state, bt_rssi_state; u32 wifi_bw; @@ -3282,7 +3289,8 @@ void halbtc8723b2ant_action_pan_edr_hid(struct btc_coexist *btcoexist) } /* HID+A2DP+PAN(EDR) */ -void halbtc8723b2ant_action_hid_a2dp_pan_edr(struct btc_coexist *btcoexist) +static void halbtc8723b2ant_action_hid_a2dp_pan_edr( + struct btc_coexist *btcoexist) { u8 wifi_rssi_state, bt_rssi_state; u32 wifi_bw; @@ -3346,7 +3354,7 @@ void halbtc8723b2ant_action_hid_a2dp_pan_edr(struct btc_coexist *btcoexist) } } -void halbtc8723b2ant_action_hid_a2dp(struct btc_coexist *btcoexist) +static void halbtc8723b2ant_action_hid_a2dp(struct btc_coexist *btcoexist) { u8 wifi_rssi_state, bt_rssi_state; u32 wifi_bw; @@ -3404,7 +3412,8 @@ void halbtc8723b2ant_action_hid_a2dp(struct btc_coexist *btcoexist) } } -void halbtc8723b2ant_run_coexist_mechanism(struct btc_coexist *btcoexist) +static void halbtc8723b2ant_run_coexist_mechanism( + struct btc_coexist *btcoexist) { u8 algorithm = 0; @@ -3525,7 +3534,7 @@ void halbtc8723b2ant_run_coexist_mechanism(struct btc_coexist *btcoexist) } } -void halbtc8723b2ant_wifioff_hwcfg(struct btc_coexist *btcoexist) +static void halbtc8723b2ant_wifioff_hwcfg(struct btc_coexist *btcoexist) { /* set wlan_act to low */ btcoexist->btc_write_1byte(btcoexist, 0x76e, 0x4); -- cgit v1.2.3 From 65aa61c03646377cfaba7490eeff1c364f8cf9a2 Mon Sep 17 00:00:00 2001 From: Konrad Zapalowicz Date: Sat, 24 May 2014 17:23:09 +0200 Subject: staging: rtl8821ae: deal with unused functions in halbtc8723b2ant.c This commit fixes the compiler -Wunused-function warning. It was enough to put #define around them to supress this warning. One was a special case because it's usage was commented-out therefore, as I did not want to remove it completely, I disabled it with #if 0 Conditionally compiled symbols halbtc8723b2ant_monitor_bt_enable_disable halbtc8723b2ant_set_bt_auto_report halbtc8723b2ant_bt_auto_report Disabled symbols halbtc8723b2ant_adc_backoff halbtc8723b2ant_set_adc_backoff Signed-off-by: Konrad Zapalowicz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/btcoexist/halbtc8723b2ant.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtc8723b2ant.c b/drivers/staging/rtl8821ae/btcoexist/halbtc8723b2ant.c index f67b375dab11..da3f62da4e40 100644 --- a/drivers/staging/rtl8821ae/btcoexist/halbtc8723b2ant.c +++ b/drivers/staging/rtl8821ae/btcoexist/halbtc8723b2ant.c @@ -247,6 +247,7 @@ static u8 halbtc8723b2ant_wifi_rssi_state(struct btc_coexist *btcoexist, return wifi_rssi_state; } +#if (BT_AUTO_REPORT_ONLY_8723B_2ANT == 0) static void halbtc8723b2ant_monitor_bt_enable_disable( struct btc_coexist *btcoexist) { @@ -300,6 +301,7 @@ static void halbtc8723b2ant_monitor_bt_enable_disable( } } } +#endif static void halbtc8723b2ant_monitor_bt_ctr(struct btc_coexist *btcoexist) { @@ -734,6 +736,7 @@ static void halbtc8723b2ant_dec_bt_pwr(struct btc_coexist *btcoexist, coex_dm->pre_dec_bt_pwr = coex_dm->cur_dec_bt_pwr; } +#if (BT_AUTO_REPORT_ONLY_8723B_2ANT == 0) static void halbtc8723b2ant_set_bt_auto_report(struct btc_coexist *btcoexist, bool enable_auto_report) { @@ -775,6 +778,7 @@ static void halbtc8723b2ant_bt_auto_report(struct btc_coexist *btcoexist, coex_dm->pre_bt_auto_report = coex_dm->cur_bt_auto_report; } +#endif static void halbtc8723b2ant_fw_dac_swing_lvl(struct btc_coexist *btcoexist, bool force_exec, u8 fw_dac_swing_lvl) @@ -950,6 +954,7 @@ static void halbtc8723b2ant_dac_swing(struct btc_coexist *btcoexist, coex_dm->pre_dac_swing_lvl = coex_dm->cur_dac_swing_lvl; } +#if 0 static void halbtc8723b2ant_set_adc_backoff(struct btc_coexist *btcoexist, bool adc_backoff) { @@ -985,6 +990,7 @@ static void halbtc8723b2ant_adc_backoff(struct btc_coexist *btcoexist, coex_dm->pre_adc_back_off = coex_dm->cur_adc_back_off; } +#endif static void halbtc8723b2ant_set_agc_table(struct btc_coexist *btcoexist, bool agc_table_en) -- cgit v1.2.3 From 0eec210abcf009ceecf73d8ea87420f7278f8654 Mon Sep 17 00:00:00 2001 From: Konrad Zapalowicz Date: Sat, 24 May 2014 17:23:10 +0200 Subject: staging: rtl8821ae: add static for local symbols in halbtcoutsrc.c This commit fixes the sparse warning: "warning: symbol 'X' was not declared. Should it be static?" Where the X is one of the following: bt_profile_string bt_spec_string bt_link_role_string h2c_state_string io_state_string btc_dbg_buf halbtc_is_bt_coexist_available halbtc_is_wifi_busy halbtc_dbg_init halbtc_is_hw_mailbox_exist halbtc_is_bt40 halbtc_legacy halbtc_get_wifi_bw halbtc_get_wifi_central_chnl halbtc_leave_lps halbtc_enter_lps halbtc_normal_lps halbtc_leave_low_power halbtc_nomal_low_power halbtc_disable_low_power halbtc_aggregation_check halbtc_get_bt_patch_version halbtc_get_wifi_rssi halbtc_get halbtc_set halbtc_display_coex_statistics halbtc_display_bt_link_info halbtc_display_bt_fw_info halbtc_display_fw_pwr_mode_cmd halbtc_read_1byte halbtc_read_2byte halbtc_read_4byte halbtc_write_1byte halbtc_bitmask_write_1byte halbtc_write_2byte halbtc_write_4byte halbtc_set_macreg halbtc_get_macreg halbtc_set_bbreg halbtc_get_bbreg halbtc_set_rfreg halbtc_get_rfreg halbtc_fill_h2c_cmd halbtc_display_dbg_msg halbtc_under_ips Signed-off-by: Konrad Zapalowicz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/btcoexist/halbtcoutsrc.c | 93 +++++++++++----------- 1 file changed, 48 insertions(+), 45 deletions(-) diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtcoutsrc.c b/drivers/staging/rtl8821ae/btcoexist/halbtcoutsrc.c index c4e83773ec98..248ec12fa003 100644 --- a/drivers/staging/rtl8821ae/btcoexist/halbtcoutsrc.c +++ b/drivers/staging/rtl8821ae/btcoexist/halbtcoutsrc.c @@ -25,7 +25,7 @@ /*********************************************** * Global variables ***********************************************/ -const char *const bt_profile_string[]={ +static const char *const bt_profile_string[] = { "NONE", "A2DP", "PAN", @@ -33,7 +33,7 @@ const char *const bt_profile_string[]={ "SCO", }; -const char *const bt_spec_string[]={ +static const char *const bt_spec_string[] = { "1.0b", "1.1", "1.2", @@ -43,19 +43,19 @@ const char *const bt_spec_string[]={ "4.0", }; -const char *const bt_link_role_string[]={ +static const char *const bt_link_role_string[] = { "Master", "Slave", }; -const char *const h2c_state_string[]={ +static const char *const h2c_state_string[] = { "successful", "h2c busy", "rf off", "fw not read", }; -const char *const io_state_string[]={ +static const char *const io_state_string[] = { "IO_STATUS_SUCCESS", "IO_STATUS_FAIL_CANNOT_IO", "IO_STATUS_FAIL_RF_OFF", @@ -72,12 +72,12 @@ const char *const io_state_string[]={ struct btc_coexist gl_bt_coexist; u32 btc_dbg_type[BTC_MSG_MAX]; -u8 btc_dbg_buf[100]; +static u8 btc_dbg_buf[100]; /*************************************************** * Debug related function ***************************************************/ -bool halbtc_is_bt_coexist_available(struct btc_coexist *btcoexist) +static bool halbtc_is_bt_coexist_available(struct btc_coexist *btcoexist) { if (!btcoexist->binded || NULL == btcoexist->adapter) return false; @@ -85,7 +85,7 @@ bool halbtc_is_bt_coexist_available(struct btc_coexist *btcoexist) return true; } -bool halbtc_is_wifi_busy(struct rtl_priv *rtlpriv) +static bool halbtc_is_wifi_busy(struct rtl_priv *rtlpriv) { if (rtlpriv->link_info.b_busytraffic) @@ -95,7 +95,7 @@ bool halbtc_is_wifi_busy(struct rtl_priv *rtlpriv) } -void halbtc_dbg_init(void) +static void halbtc_dbg_init(void) { u8 i; @@ -121,12 +121,12 @@ void halbtc_dbg_init(void) 0; } -bool halbtc_is_hw_mailbox_exist(struct btc_coexist *btcoexist) +static bool halbtc_is_hw_mailbox_exist(struct btc_coexist *btcoexist) { return true; } -bool halbtc_is_bt40(struct rtl_priv *adapter) +static bool halbtc_is_bt40(struct rtl_priv *adapter) { struct rtl_priv *rtlpriv = adapter; struct rtl_phy *rtlphy = &(rtlpriv->phy); @@ -142,7 +142,7 @@ bool halbtc_is_bt40(struct rtl_priv *adapter) return is_ht40; } -bool halbtc_legacy(struct rtl_priv *adapter) +static bool halbtc_legacy(struct rtl_priv *adapter) { struct rtl_priv *rtlpriv = adapter; struct rtl_mac *mac = rtl_mac(rtlpriv); @@ -165,7 +165,7 @@ bool halbtc_is_wifi_uplink(struct rtl_priv *adapter) return false; } -u32 halbtc_get_wifi_bw(struct btc_coexist *btcoexist) +static u32 halbtc_get_wifi_bw(struct btc_coexist *btcoexist) { struct rtl_priv *rtlpriv = (struct rtl_priv *)btcoexist->adapter; @@ -182,7 +182,7 @@ u32 halbtc_get_wifi_bw(struct btc_coexist *btcoexist) return wifi_bw; } -u8 halbtc_get_wifi_central_chnl(struct btc_coexist *btcoexist) +static u8 halbtc_get_wifi_central_chnl(struct btc_coexist *btcoexist) { struct rtl_priv *rtlpriv = btcoexist->adapter; struct rtl_phy *rtlphy = &(rtlpriv->phy); @@ -196,7 +196,7 @@ u8 halbtc_get_wifi_central_chnl(struct btc_coexist *btcoexist) return chnl; } -void halbtc_leave_lps(struct btc_coexist *btcoexist) +static void halbtc_leave_lps(struct btc_coexist *btcoexist) { struct rtl_priv *rtlpriv; struct rtl_ps_ctl *ppsc; @@ -217,7 +217,7 @@ void halbtc_leave_lps(struct btc_coexist *btcoexist) btcoexist->bt_info.bt_lps_on = false; } -void halbtc_enter_lps(struct btc_coexist *btcoexist) +static void halbtc_enter_lps(struct btc_coexist *btcoexist) { struct rtl_priv *rtlpriv; struct rtl_ps_ctl *ppsc; @@ -238,7 +238,7 @@ void halbtc_enter_lps(struct btc_coexist *btcoexist) btcoexist->bt_info.bt_lps_on = false; } -void halbtc_normal_lps(struct btc_coexist *btcoexist) +static void halbtc_normal_lps(struct btc_coexist *btcoexist) { if (btcoexist->bt_info.bt_ctrl_lps) { btcoexist->bt_info.bt_lps_on = false; @@ -247,29 +247,29 @@ void halbtc_normal_lps(struct btc_coexist *btcoexist) } -void halbtc_leave_low_power(void) +static void halbtc_leave_low_power(void) { } -void halbtc_nomal_low_power(void) +static void halbtc_nomal_low_power(void) { } -void halbtc_disable_low_power(void) +static void halbtc_disable_low_power(void) { } -void halbtc_aggregation_check(void) +static void halbtc_aggregation_check(void) { } -u32 halbtc_get_bt_patch_version(struct btc_coexist *btcoexist) +static u32 halbtc_get_bt_patch_version(struct btc_coexist *btcoexist) { return 0; } -s32 halbtc_get_wifi_rssi(struct rtl_priv *adapter) +static s32 halbtc_get_wifi_rssi(struct rtl_priv *adapter) { struct rtl_priv *rtlpriv = adapter; s32 undecorated_smoothed_pwdb = 0; @@ -283,7 +283,7 @@ s32 halbtc_get_wifi_rssi(struct rtl_priv *adapter) return undecorated_smoothed_pwdb; } -bool halbtc_get(void *void_btcoexist, u8 get_type, void *out_buf) +static bool halbtc_get(void *void_btcoexist, u8 get_type, void *out_buf) { struct btc_coexist *btcoexist = (struct btc_coexist *)void_btcoexist; struct rtl_priv *rtlpriv = btcoexist->adapter; @@ -422,7 +422,7 @@ bool halbtc_get(void *void_btcoexist, u8 get_type, void *out_buf) return true; } -bool halbtc_set(void *void_btcoexist, u8 set_type, void *in_buf) +static bool halbtc_set(void *void_btcoexist, u8 set_type, void *in_buf) { struct btc_coexist *btcoexist = (struct btc_coexist *)void_btcoexist; bool *bool_tmp = (bool *)in_buf; @@ -516,26 +516,26 @@ bool halbtc_set(void *void_btcoexist, u8 set_type, void *in_buf) return true; } -void halbtc_display_coex_statistics(struct btc_coexist *btcoexist) +static void halbtc_display_coex_statistics(struct btc_coexist *btcoexist) { } -void halbtc_display_bt_link_info(struct btc_coexist *btcoexist) +static void halbtc_display_bt_link_info(struct btc_coexist *btcoexist) { } -void halbtc_display_bt_fw_info(struct btc_coexist *btcoexist) +static void halbtc_display_bt_fw_info(struct btc_coexist *btcoexist) { } -void halbtc_display_fw_pwr_mode_cmd(struct btc_coexist *btcoexist) +static void halbtc_display_fw_pwr_mode_cmd(struct btc_coexist *btcoexist) { } /************************************************************ * IO related function ************************************************************/ -u8 halbtc_read_1byte(void *bt_context, u32 reg_addr) +static u8 halbtc_read_1byte(void *bt_context, u32 reg_addr) { struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; struct rtl_priv *rtlpriv = btcoexist->adapter; @@ -544,7 +544,7 @@ u8 halbtc_read_1byte(void *bt_context, u32 reg_addr) } -u16 halbtc_read_2byte(void *bt_context, u32 reg_addr) +static u16 halbtc_read_2byte(void *bt_context, u32 reg_addr) { struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; struct rtl_priv *rtlpriv = btcoexist->adapter; @@ -553,7 +553,7 @@ u16 halbtc_read_2byte(void *bt_context, u32 reg_addr) } -u32 halbtc_read_4byte(void *bt_context, u32 reg_addr) +static u32 halbtc_read_4byte(void *bt_context, u32 reg_addr) { struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; struct rtl_priv *rtlpriv = btcoexist->adapter; @@ -562,7 +562,7 @@ u32 halbtc_read_4byte(void *bt_context, u32 reg_addr) } -void halbtc_write_1byte(void *bt_context, u32 reg_addr, u8 data) +static void halbtc_write_1byte(void *bt_context, u32 reg_addr, u8 data) { struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; struct rtl_priv *rtlpriv = btcoexist->adapter; @@ -570,7 +570,7 @@ void halbtc_write_1byte(void *bt_context, u32 reg_addr, u8 data) rtl_write_byte(rtlpriv, reg_addr, data); } -void halbtc_bitmask_write_1byte(void *bt_context, u32 reg_addr, +static void halbtc_bitmask_write_1byte(void *bt_context, u32 reg_addr, u8 bit_mask, u8 data) { struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; @@ -592,7 +592,7 @@ void halbtc_bitmask_write_1byte(void *bt_context, u32 reg_addr, } -void halbtc_write_2byte(void *bt_context, u32 reg_addr, u16 data) +static void halbtc_write_2byte(void *bt_context, u32 reg_addr, u16 data) { struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; struct rtl_priv *rtlpriv = btcoexist->adapter; @@ -601,7 +601,7 @@ void halbtc_write_2byte(void *bt_context, u32 reg_addr, u16 data) } -void halbtc_write_4byte(void *bt_context, u32 reg_addr, u32 data) +static void halbtc_write_4byte(void *bt_context, u32 reg_addr, u32 data) { struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; @@ -611,7 +611,8 @@ void halbtc_write_4byte(void *bt_context, u32 reg_addr, u32 data) } -void halbtc_set_macreg(void *bt_context, u32 reg_addr, u32 bit_mask, u32 data) +static void halbtc_set_macreg(void *bt_context, u32 reg_addr, + u32 bit_mask, u32 data) { struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; struct rtl_priv *rtlpriv = btcoexist->adapter; @@ -620,7 +621,7 @@ void halbtc_set_macreg(void *bt_context, u32 reg_addr, u32 bit_mask, u32 data) } -u32 halbtc_get_macreg(void *bt_context, u32 reg_addr, u32 bit_mask) +static u32 halbtc_get_macreg(void *bt_context, u32 reg_addr, u32 bit_mask) { struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; struct rtl_priv *rtlpriv = btcoexist->adapter; @@ -629,7 +630,8 @@ u32 halbtc_get_macreg(void *bt_context, u32 reg_addr, u32 bit_mask) } -void halbtc_set_bbreg(void *bt_context, u32 reg_addr, u32 bit_mask, u32 data) +static void halbtc_set_bbreg(void *bt_context, u32 reg_addr, + u32 bit_mask, u32 data) { struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; struct rtl_priv *rtlpriv = btcoexist->adapter; @@ -638,7 +640,7 @@ void halbtc_set_bbreg(void *bt_context, u32 reg_addr, u32 bit_mask, u32 data) } -u32 halbtc_get_bbreg(void *bt_context, u32 reg_addr, u32 bit_mask) +static u32 halbtc_get_bbreg(void *bt_context, u32 reg_addr, u32 bit_mask) { struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; struct rtl_priv *rtlpriv = btcoexist->adapter; @@ -647,7 +649,7 @@ u32 halbtc_get_bbreg(void *bt_context, u32 reg_addr, u32 bit_mask) } -void halbtc_set_rfreg(void *bt_context, u8 rf_path, u32 reg_addr, +static void halbtc_set_rfreg(void *bt_context, u8 rf_path, u32 reg_addr, u32 bit_mask, u32 data) { struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; @@ -657,7 +659,8 @@ void halbtc_set_rfreg(void *bt_context, u8 rf_path, u32 reg_addr, } -u32 halbtc_get_rfreg(void *bt_context, u8 rf_path, u32 reg_addr, u32 bit_mask) +static u32 halbtc_get_rfreg(void *bt_context, u8 rf_path, + u32 reg_addr, u32 bit_mask) { struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; struct rtl_priv *rtlpriv = btcoexist->adapter; @@ -666,7 +669,7 @@ u32 halbtc_get_rfreg(void *bt_context, u8 rf_path, u32 reg_addr, u32 bit_mask) } -void halbtc_fill_h2c_cmd(void *bt_context, u8 element_id, +static void halbtc_fill_h2c_cmd(void *bt_context, u8 element_id, u32 cmd_len, u8 *cmd_buf) { struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; @@ -676,7 +679,7 @@ void halbtc_fill_h2c_cmd(void *bt_context, u8 element_id, cmd_len, cmd_buf); } -void halbtc_display_dbg_msg(void *bt_context, u8 disp_type) +static void halbtc_display_dbg_msg(void *bt_context, u8 disp_type) { struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; switch (disp_type) { @@ -697,7 +700,7 @@ void halbtc_display_dbg_msg(void *bt_context, u8 disp_type) } } -bool halbtc_under_ips(struct btc_coexist *btcoexist) +static bool halbtc_under_ips(struct btc_coexist *btcoexist) { struct rtl_priv *rtlpriv = btcoexist->adapter; struct rtl_ps_ctl *ppsc = rtl_psc(rtlpriv); -- cgit v1.2.3 From 45475dc312d586744baabf8c5a330878faaf55ba Mon Sep 17 00:00:00 2001 From: Konrad Zapalowicz Date: Sat, 24 May 2014 17:23:11 +0200 Subject: staging: rtl8821ae: deal with unused functions in halbtcoutsrc.c This commit fixes the compiler -Wunused-function warning. Several functions had to be removed. Removed symbols halbtc_is_hw_mailbox_exist halbtc_set_macreg halbtc_get_macreg halbtc_under_ips Signed-off-by: Konrad Zapalowicz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/btcoexist/halbtcoutsrc.c | 44 ---------------------- 1 file changed, 44 deletions(-) diff --git a/drivers/staging/rtl8821ae/btcoexist/halbtcoutsrc.c b/drivers/staging/rtl8821ae/btcoexist/halbtcoutsrc.c index 248ec12fa003..01f5a74028a0 100644 --- a/drivers/staging/rtl8821ae/btcoexist/halbtcoutsrc.c +++ b/drivers/staging/rtl8821ae/btcoexist/halbtcoutsrc.c @@ -121,11 +121,6 @@ static void halbtc_dbg_init(void) 0; } -static bool halbtc_is_hw_mailbox_exist(struct btc_coexist *btcoexist) -{ - return true; -} - static bool halbtc_is_bt40(struct rtl_priv *adapter) { struct rtl_priv *rtlpriv = adapter; @@ -610,26 +605,6 @@ static void halbtc_write_4byte(void *bt_context, u32 reg_addr, u32 data) rtl_write_dword(rtlpriv, reg_addr, data); } - -static void halbtc_set_macreg(void *bt_context, u32 reg_addr, - u32 bit_mask, u32 data) -{ - struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; - struct rtl_priv *rtlpriv = btcoexist->adapter; - - rtl_set_bbreg(rtlpriv->mac80211.hw, reg_addr, bit_mask, data); -} - - -static u32 halbtc_get_macreg(void *bt_context, u32 reg_addr, u32 bit_mask) -{ - struct btc_coexist *btcoexist = (struct btc_coexist *)bt_context; - struct rtl_priv *rtlpriv = btcoexist->adapter; - - return rtl_get_bbreg(rtlpriv->mac80211.hw, reg_addr, bit_mask); -} - - static void halbtc_set_bbreg(void *bt_context, u32 reg_addr, u32 bit_mask, u32 data) { @@ -700,25 +675,6 @@ static void halbtc_display_dbg_msg(void *bt_context, u8 disp_type) } } -static bool halbtc_under_ips(struct btc_coexist *btcoexist) -{ - struct rtl_priv *rtlpriv = btcoexist->adapter; - struct rtl_ps_ctl *ppsc = rtl_psc(rtlpriv); - enum rf_pwrstate rtstate; - - if (ppsc->b_inactiveps) { - rtstate = ppsc->rfpwr_state; - - if (rtstate != ERFON && - ppsc->rfoff_reason == RF_CHANGE_BY_IPS) { - - return true; - } - } - - return false; -} - /***************************************************************** * Extern functions called by other module *****************************************************************/ -- cgit v1.2.3 From 83991567b15ac0fac45f515dbc128a792d83e562 Mon Sep 17 00:00:00 2001 From: Konrad Zapalowicz Date: Sat, 24 May 2014 17:23:12 +0200 Subject: staging: rtl8821ae: add static for local symbols in rtl_btc.c This commit fixes the sparse warning: "warning: symbol 'X' was not declared. Should it be static?" Where the X is one of the following rtl_btc_operation Signed-off-by: Konrad Zapalowicz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/btcoexist/rtl_btc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8821ae/btcoexist/rtl_btc.c b/drivers/staging/rtl8821ae/btcoexist/rtl_btc.c index 6653f147757c..6be0acafba5d 100644 --- a/drivers/staging/rtl8821ae/btcoexist/rtl_btc.c +++ b/drivers/staging/rtl8821ae/btcoexist/rtl_btc.c @@ -32,7 +32,7 @@ #include "rtl_btc.h" #include "halbt_precomp.h" -struct rtl_btc_ops rtl_btc_operation ={ +static struct rtl_btc_ops rtl_btc_operation = { .btc_init_variables = rtl_btc_init_variables, .btc_init_hal_vars = rtl_btc_init_hal_vars, .btc_init_hw_config = rtl_btc_init_hw_config, -- cgit v1.2.3 From e017a92b2e768c13503765e1eabfa566bf791807 Mon Sep 17 00:00:00 2001 From: Manuel Schölling Date: Sun, 25 May 2014 15:05:24 +0200 Subject: staging: rtl8188eu: use time_before/time_after and change type of ips_deny_time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To be future-proof and for better readability the time comparisons are modified to use time_before/_after() instead of plain, error-prone math. To suppress compiler warnings the type of ips_deny_time was changed. Signed-off-by: Manuel Schölling Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_pwrctrl.c | 9 ++++++--- drivers/staging/rtl8188eu/include/rtw_pwrctrl.h | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c index f6583734aefa..eaf26304143c 100644 --- a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c @@ -122,7 +122,7 @@ static bool rtw_pwr_unassociated_idle(struct adapter *adapter) bool ret = false; - if (adapter->pwrctrlpriv.ips_deny_time >= jiffies) + if (time_after_eq(adapter->pwrctrlpriv.ips_deny_time, jiffies)) goto exit; if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE|WIFI_SITE_MONITOR) || @@ -523,9 +523,11 @@ int _rtw_pwr_wakeup(struct adapter *padapter, u32 ips_deffer_ms, const char *cal { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + unsigned long expires; int ret = _SUCCESS; - if (pwrpriv->ips_deny_time < jiffies + rtw_ms_to_systime(ips_deffer_ms)) + expires = jiffies + rtw_ms_to_systime(ips_deffer_ms); + if (time_before(pwrpriv->ips_deny_time, expires)) pwrpriv->ips_deny_time = jiffies + rtw_ms_to_systime(ips_deffer_ms); { @@ -580,7 +582,8 @@ int _rtw_pwr_wakeup(struct adapter *padapter, u32 ips_deffer_ms, const char *cal } exit: - if (pwrpriv->ips_deny_time < jiffies + rtw_ms_to_systime(ips_deffer_ms)) + expires = jiffies + rtw_ms_to_systime(ips_deffer_ms); + if (time_before(pwrpriv->ips_deny_time, expires)) pwrpriv->ips_deny_time = jiffies + rtw_ms_to_systime(ips_deffer_ms); return ret; } diff --git a/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h b/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h index 9a42859d612b..4211023081bf 100644 --- a/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h +++ b/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h @@ -192,7 +192,7 @@ struct pwrctrl_priv { u8 ips_mode_req; /* used to accept the mode setting request, * will update to ipsmode later */ uint bips_processing; - u32 ips_deny_time; /* will deny IPS when system time less than this */ + unsigned long ips_deny_time; /* will deny IPS when system time less than this */ u8 ps_processing; /* temp used to mark whether in rtw_ps_processor */ u8 bLeisurePs; -- cgit v1.2.3 From bd215fb98cbb630a8736c58bbb2c12ee8caaeb6b Mon Sep 17 00:00:00 2001 From: Chaitanya Hazarey Date: Sun, 25 May 2014 09:15:06 -0700 Subject: Staging: rtl8192u: r819xU_firmware_img.c Fixed checkpatch.pl ERRORs Fixed a lot of errors of the type "ERROR: space required after that ',' (ctx:VxV)" Added tabs at the beginning of line. Signed-off-by: Chaitanya Hazarey Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_firmware_img.c | 1042 ++++++++++++------------ 1 file changed, 521 insertions(+), 521 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_firmware_img.c b/drivers/staging/rtl8192u/r819xU_firmware_img.c index 0785de72a5ea..4eb43cfe5690 100644 --- a/drivers/staging/rtl8192u/r819xU_firmware_img.c +++ b/drivers/staging/rtl8192u/r819xU_firmware_img.c @@ -3,546 +3,546 @@ #include "r819xU_firmware_img.h" u32 Rtl8192UsbPHY_REGArray[] = { -0x0, }; + 0x0, }; u32 Rtl8192UsbPHY_REG_1T2RArray[] = { -0x800,0x00000000, -0x804,0x00000001, -0x808,0x0000fc00, -0x80c,0x0000001c, -0x810,0x801010aa, -0x814,0x008514d0, -0x818,0x00000040, -0x81c,0x00000000, -0x820,0x00000004, -0x824,0x00690000, -0x828,0x00000004, -0x82c,0x00e90000, -0x830,0x00000004, -0x834,0x00690000, -0x838,0x00000004, -0x83c,0x00e90000, -0x840,0x00000000, -0x844,0x00000000, -0x848,0x00000000, -0x84c,0x00000000, -0x850,0x00000000, -0x854,0x00000000, -0x858,0x65a965a9, -0x85c,0x65a965a9, -0x860,0x001f0010, -0x864,0x007f0010, -0x868,0x001f0010, -0x86c,0x007f0010, -0x870,0x0f100f70, -0x874,0x0f100f70, -0x878,0x00000000, -0x87c,0x00000000, -0x880,0x6870e36c, -0x884,0xe3573600, -0x888,0x4260c340, -0x88c,0x0000ff00, -0x890,0x00000000, -0x894,0xfffffffe, -0x898,0x4c42382f, -0x89c,0x00656056, -0x8b0,0x00000000, -0x8e0,0x00000000, -0x8e4,0x00000000, -0x900,0x00000000, -0x904,0x00000023, -0x908,0x00000000, -0x90c,0x31121311, -0xa00,0x00d0c7d8, -0xa04,0x811f0008, -0xa08,0x80cd8300, -0xa0c,0x2e62740f, -0xa10,0x95009b78, -0xa14,0x11145008, -0xa18,0x00881117, -0xa1c,0x89140fa0, -0xa20,0x1a1b0000, -0xa24,0x090e1317, -0xa28,0x00000204, -0xa2c,0x00000000, -0xc00,0x00000040, -0xc04,0x00005433, -0xc08,0x000000e4, -0xc0c,0x6c6c6c6c, -0xc10,0x08800000, -0xc14,0x40000100, -0xc18,0x08000000, -0xc1c,0x40000100, -0xc20,0x08000000, -0xc24,0x40000100, -0xc28,0x08000000, -0xc2c,0x40000100, -0xc30,0x6de9ac44, -0xc34,0x465c52cd, -0xc38,0x497f5994, -0xc3c,0x0a969764, -0xc40,0x1f7c403f, -0xc44,0x000100b7, -0xc48,0xec020000, -0xc4c,0x00000300, -0xc50,0x69543420, -0xc54,0x433c0094, -0xc58,0x69543420, -0xc5c,0x433c0094, -0xc60,0x69543420, -0xc64,0x433c0094, -0xc68,0x69543420, -0xc6c,0x433c0094, -0xc70,0x2c7f000d, -0xc74,0x0186175b, -0xc78,0x0000001f, -0xc7c,0x00b91612, -0xc80,0x40000100, -0xc84,0x20000000, -0xc88,0x40000100, -0xc8c,0x20200000, -0xc90,0x40000100, -0xc94,0x00000000, -0xc98,0x40000100, -0xc9c,0x00000000, -0xca0,0x00492492, -0xca4,0x00000000, -0xca8,0x00000000, -0xcac,0x00000000, -0xcb0,0x00000000, -0xcb4,0x00000000, -0xcb8,0x00000000, -0xcbc,0x00492492, -0xcc0,0x00000000, -0xcc4,0x00000000, -0xcc8,0x00000000, -0xccc,0x00000000, -0xcd0,0x00000000, -0xcd4,0x00000000, -0xcd8,0x64b22427, -0xcdc,0x00766932, -0xce0,0x00222222, -0xd00,0x00000750, -0xd04,0x00000403, -0xd08,0x0000907f, -0xd0c,0x00000001, -0xd10,0xa0633333, -0xd14,0x33333c63, -0xd18,0x6a8f5b6b, -0xd1c,0x00000000, -0xd20,0x00000000, -0xd24,0x00000000, -0xd28,0x00000000, -0xd2c,0xcc979975, -0xd30,0x00000000, -0xd34,0x00000000, -0xd38,0x00000000, -0xd3c,0x00027293, -0xd40,0x00000000, -0xd44,0x00000000, -0xd48,0x00000000, -0xd4c,0x00000000, -0xd50,0x6437140a, -0xd54,0x024dbd02, -0xd58,0x00000000, -0xd5c,0x04032064, -0xe00,0x161a1a1a, -0xe04,0x12121416, -0xe08,0x00001800, -0xe0c,0x00000000, -0xe10,0x161a1a1a, -0xe14,0x12121416, -0xe18,0x161a1a1a, -0xe1c,0x12121416, + 0x800, 0x00000000, + 0x804, 0x00000001, + 0x808, 0x0000fc00, + 0x80c, 0x0000001c, + 0x810, 0x801010aa, + 0x814, 0x008514d0, + 0x818, 0x00000040, + 0x81c, 0x00000000, + 0x820, 0x00000004, + 0x824, 0x00690000, + 0x828, 0x00000004, + 0x82c, 0x00e90000, + 0x830, 0x00000004, + 0x834, 0x00690000, + 0x838, 0x00000004, + 0x83c, 0x00e90000, + 0x840, 0x00000000, + 0x844, 0x00000000, + 0x848, 0x00000000, + 0x84c, 0x00000000, + 0x850, 0x00000000, + 0x854, 0x00000000, + 0x858, 0x65a965a9, + 0x85c, 0x65a965a9, + 0x860, 0x001f0010, + 0x864, 0x007f0010, + 0x868, 0x001f0010, + 0x86c, 0x007f0010, + 0x870, 0x0f100f70, + 0x874, 0x0f100f70, + 0x878, 0x00000000, + 0x87c, 0x00000000, + 0x880, 0x6870e36c, + 0x884, 0xe3573600, + 0x888, 0x4260c340, + 0x88c, 0x0000ff00, + 0x890, 0x00000000, + 0x894, 0xfffffffe, + 0x898, 0x4c42382f, + 0x89c, 0x00656056, + 0x8b0, 0x00000000, + 0x8e0, 0x00000000, + 0x8e4, 0x00000000, + 0x900, 0x00000000, + 0x904, 0x00000023, + 0x908, 0x00000000, + 0x90c, 0x31121311, + 0xa00, 0x00d0c7d8, + 0xa04, 0x811f0008, + 0xa08, 0x80cd8300, + 0xa0c, 0x2e62740f, + 0xa10, 0x95009b78, + 0xa14, 0x11145008, + 0xa18, 0x00881117, + 0xa1c, 0x89140fa0, + 0xa20, 0x1a1b0000, + 0xa24, 0x090e1317, + 0xa28, 0x00000204, + 0xa2c, 0x00000000, + 0xc00, 0x00000040, + 0xc04, 0x00005433, + 0xc08, 0x000000e4, + 0xc0c, 0x6c6c6c6c, + 0xc10, 0x08800000, + 0xc14, 0x40000100, + 0xc18, 0x08000000, + 0xc1c, 0x40000100, + 0xc20, 0x08000000, + 0xc24, 0x40000100, + 0xc28, 0x08000000, + 0xc2c, 0x40000100, + 0xc30, 0x6de9ac44, + 0xc34, 0x465c52cd, + 0xc38, 0x497f5994, + 0xc3c, 0x0a969764, + 0xc40, 0x1f7c403f, + 0xc44, 0x000100b7, + 0xc48, 0xec020000, + 0xc4c, 0x00000300, + 0xc50, 0x69543420, + 0xc54, 0x433c0094, + 0xc58, 0x69543420, + 0xc5c, 0x433c0094, + 0xc60, 0x69543420, + 0xc64, 0x433c0094, + 0xc68, 0x69543420, + 0xc6c, 0x433c0094, + 0xc70, 0x2c7f000d, + 0xc74, 0x0186175b, + 0xc78, 0x0000001f, + 0xc7c, 0x00b91612, + 0xc80, 0x40000100, + 0xc84, 0x20000000, + 0xc88, 0x40000100, + 0xc8c, 0x20200000, + 0xc90, 0x40000100, + 0xc94, 0x00000000, + 0xc98, 0x40000100, + 0xc9c, 0x00000000, + 0xca0, 0x00492492, + 0xca4, 0x00000000, + 0xca8, 0x00000000, + 0xcac, 0x00000000, + 0xcb0, 0x00000000, + 0xcb4, 0x00000000, + 0xcb8, 0x00000000, + 0xcbc, 0x00492492, + 0xcc0, 0x00000000, + 0xcc4, 0x00000000, + 0xcc8, 0x00000000, + 0xccc, 0x00000000, + 0xcd0, 0x00000000, + 0xcd4, 0x00000000, + 0xcd8, 0x64b22427, + 0xcdc, 0x00766932, + 0xce0, 0x00222222, + 0xd00, 0x00000750, + 0xd04, 0x00000403, + 0xd08, 0x0000907f, + 0xd0c, 0x00000001, + 0xd10, 0xa0633333, + 0xd14, 0x33333c63, + 0xd18, 0x6a8f5b6b, + 0xd1c, 0x00000000, + 0xd20, 0x00000000, + 0xd24, 0x00000000, + 0xd28, 0x00000000, + 0xd2c, 0xcc979975, + 0xd30, 0x00000000, + 0xd34, 0x00000000, + 0xd38, 0x00000000, + 0xd3c, 0x00027293, + 0xd40, 0x00000000, + 0xd44, 0x00000000, + 0xd48, 0x00000000, + 0xd4c, 0x00000000, + 0xd50, 0x6437140a, + 0xd54, 0x024dbd02, + 0xd58, 0x00000000, + 0xd5c, 0x04032064, + 0xe00, 0x161a1a1a, + 0xe04, 0x12121416, + 0xe08, 0x00001800, + 0xe0c, 0x00000000, + 0xe10, 0x161a1a1a, + 0xe14, 0x12121416, + 0xe18, 0x161a1a1a, + 0xe1c, 0x12121416, }; u32 Rtl8192UsbRadioA_Array[] = { -0x019,0x00000003, -0x000,0x000000bf, -0x001,0x00000ee0, -0x002,0x0000004c, -0x003,0x000007f1, -0x004,0x00000975, -0x005,0x00000c58, -0x006,0x00000ae6, -0x007,0x000000ca, -0x008,0x00000e1c, -0x009,0x000007f0, -0x00a,0x000009d0, -0x00b,0x000001ba, -0x00c,0x00000240, -0x00e,0x00000020, -0x00f,0x00000990, -0x012,0x00000806, -0x014,0x000005ab, -0x015,0x00000f80, -0x016,0x00000020, -0x017,0x00000597, -0x018,0x0000050a, -0x01a,0x00000f80, -0x01b,0x00000f5e, -0x01c,0x00000008, -0x01d,0x00000607, -0x01e,0x000006cc, -0x01f,0x00000000, -0x020,0x000001a5, -0x01f,0x00000001, -0x020,0x00000165, -0x01f,0x00000002, -0x020,0x000000c6, -0x01f,0x00000003, -0x020,0x00000086, -0x01f,0x00000004, -0x020,0x00000046, -0x01f,0x00000005, -0x020,0x000001e6, -0x01f,0x00000006, -0x020,0x000001a6, -0x01f,0x00000007, -0x020,0x00000166, -0x01f,0x00000008, -0x020,0x000000c7, -0x01f,0x00000009, -0x020,0x00000087, -0x01f,0x0000000a, -0x020,0x000000f7, -0x01f,0x0000000b, -0x020,0x000000d7, -0x01f,0x0000000c, -0x020,0x000000b7, -0x01f,0x0000000d, -0x020,0x00000097, -0x01f,0x0000000e, -0x020,0x00000077, -0x01f,0x0000000f, -0x020,0x00000057, -0x01f,0x00000010, -0x020,0x00000037, -0x01f,0x00000011, -0x020,0x000000fb, -0x01f,0x00000012, -0x020,0x000000db, -0x01f,0x00000013, -0x020,0x000000bb, -0x01f,0x00000014, -0x020,0x000000ff, -0x01f,0x00000015, -0x020,0x000000e3, -0x01f,0x00000016, -0x020,0x000000c3, -0x01f,0x00000017, -0x020,0x000000a3, -0x01f,0x00000018, -0x020,0x00000083, -0x01f,0x00000019, -0x020,0x00000063, -0x01f,0x0000001a, -0x020,0x00000043, -0x01f,0x0000001b, -0x020,0x00000023, -0x01f,0x0000001c, -0x020,0x00000003, -0x01f,0x0000001d, -0x020,0x000001e3, -0x01f,0x0000001e, -0x020,0x000001c3, -0x01f,0x0000001f, -0x020,0x000001a3, -0x01f,0x00000020, -0x020,0x00000183, -0x01f,0x00000021, -0x020,0x00000163, -0x01f,0x00000022, -0x020,0x00000143, -0x01f,0x00000023, -0x020,0x00000123, -0x01f,0x00000024, -0x020,0x00000103, -0x023,0x00000203, -0x024,0x00000200, -0x00b,0x000001ba, -0x02c,0x000003d7, -0x02d,0x00000ff0, -0x000,0x00000037, -0x004,0x00000160, -0x007,0x00000080, -0x002,0x0000088d, -0x0fe,0x00000000, -0x0fe,0x00000000, -0x016,0x00000200, -0x016,0x00000380, -0x016,0x00000020, -0x016,0x000001a0, -0x000,0x000000bf, -0x00d,0x0000001f, -0x00d,0x00000c9f, -0x002,0x0000004d, -0x000,0x00000cbf, -0x004,0x00000975, -0x007,0x00000700, + 0x019, 0x00000003, + 0x000, 0x000000bf, + 0x001, 0x00000ee0, + 0x002, 0x0000004c, + 0x003, 0x000007f1, + 0x004, 0x00000975, + 0x005, 0x00000c58, + 0x006, 0x00000ae6, + 0x007, 0x000000ca, + 0x008, 0x00000e1c, + 0x009, 0x000007f0, + 0x00a, 0x000009d0, + 0x00b, 0x000001ba, + 0x00c, 0x00000240, + 0x00e, 0x00000020, + 0x00f, 0x00000990, + 0x012, 0x00000806, + 0x014, 0x000005ab, + 0x015, 0x00000f80, + 0x016, 0x00000020, + 0x017, 0x00000597, + 0x018, 0x0000050a, + 0x01a, 0x00000f80, + 0x01b, 0x00000f5e, + 0x01c, 0x00000008, + 0x01d, 0x00000607, + 0x01e, 0x000006cc, + 0x01f, 0x00000000, + 0x020, 0x000001a5, + 0x01f, 0x00000001, + 0x020, 0x00000165, + 0x01f, 0x00000002, + 0x020, 0x000000c6, + 0x01f, 0x00000003, + 0x020, 0x00000086, + 0x01f, 0x00000004, + 0x020, 0x00000046, + 0x01f, 0x00000005, + 0x020, 0x000001e6, + 0x01f, 0x00000006, + 0x020, 0x000001a6, + 0x01f, 0x00000007, + 0x020, 0x00000166, + 0x01f, 0x00000008, + 0x020, 0x000000c7, + 0x01f, 0x00000009, + 0x020, 0x00000087, + 0x01f, 0x0000000a, + 0x020, 0x000000f7, + 0x01f, 0x0000000b, + 0x020, 0x000000d7, + 0x01f, 0x0000000c, + 0x020, 0x000000b7, + 0x01f, 0x0000000d, + 0x020, 0x00000097, + 0x01f, 0x0000000e, + 0x020, 0x00000077, + 0x01f, 0x0000000f, + 0x020, 0x00000057, + 0x01f, 0x00000010, + 0x020, 0x00000037, + 0x01f, 0x00000011, + 0x020, 0x000000fb, + 0x01f, 0x00000012, + 0x020, 0x000000db, + 0x01f, 0x00000013, + 0x020, 0x000000bb, + 0x01f, 0x00000014, + 0x020, 0x000000ff, + 0x01f, 0x00000015, + 0x020, 0x000000e3, + 0x01f, 0x00000016, + 0x020, 0x000000c3, + 0x01f, 0x00000017, + 0x020, 0x000000a3, + 0x01f, 0x00000018, + 0x020, 0x00000083, + 0x01f, 0x00000019, + 0x020, 0x00000063, + 0x01f, 0x0000001a, + 0x020, 0x00000043, + 0x01f, 0x0000001b, + 0x020, 0x00000023, + 0x01f, 0x0000001c, + 0x020, 0x00000003, + 0x01f, 0x0000001d, + 0x020, 0x000001e3, + 0x01f, 0x0000001e, + 0x020, 0x000001c3, + 0x01f, 0x0000001f, + 0x020, 0x000001a3, + 0x01f, 0x00000020, + 0x020, 0x00000183, + 0x01f, 0x00000021, + 0x020, 0x00000163, + 0x01f, 0x00000022, + 0x020, 0x00000143, + 0x01f, 0x00000023, + 0x020, 0x00000123, + 0x01f, 0x00000024, + 0x020, 0x00000103, + 0x023, 0x00000203, + 0x024, 0x00000200, + 0x00b, 0x000001ba, + 0x02c, 0x000003d7, + 0x02d, 0x00000ff0, + 0x000, 0x00000037, + 0x004, 0x00000160, + 0x007, 0x00000080, + 0x002, 0x0000088d, + 0x0fe, 0x00000000, + 0x0fe, 0x00000000, + 0x016, 0x00000200, + 0x016, 0x00000380, + 0x016, 0x00000020, + 0x016, 0x000001a0, + 0x000, 0x000000bf, + 0x00d, 0x0000001f, + 0x00d, 0x00000c9f, + 0x002, 0x0000004d, + 0x000, 0x00000cbf, + 0x004, 0x00000975, + 0x007, 0x00000700, }; u32 Rtl8192UsbRadioB_Array[] = { -0x019,0x00000003, -0x000,0x000000bf, -0x001,0x000006e0, -0x002,0x0000004c, -0x003,0x000007f1, -0x004,0x00000975, -0x005,0x00000c58, -0x006,0x00000ae6, -0x007,0x000000ca, -0x008,0x00000e1c, -0x000,0x000000b7, -0x00a,0x00000850, -0x000,0x000000bf, -0x00b,0x000001ba, -0x00c,0x00000240, -0x00e,0x00000020, -0x015,0x00000f80, -0x016,0x00000020, -0x017,0x00000597, -0x018,0x0000050a, -0x01a,0x00000e00, -0x01b,0x00000f5e, -0x01d,0x00000607, -0x01e,0x000006cc, -0x00b,0x000001ba, -0x023,0x00000203, -0x024,0x00000200, -0x000,0x00000037, -0x004,0x00000160, -0x016,0x00000200, -0x016,0x00000380, -0x016,0x00000020, -0x016,0x000001a0, -0x00d,0x00000ccc, -0x000,0x000000bf, -0x002,0x0000004d, -0x000,0x00000cbf, -0x004,0x00000975, -0x007,0x00000700, + 0x019, 0x00000003, + 0x000, 0x000000bf, + 0x001, 0x000006e0, + 0x002, 0x0000004c, + 0x003, 0x000007f1, + 0x004, 0x00000975, + 0x005, 0x00000c58, + 0x006, 0x00000ae6, + 0x007, 0x000000ca, + 0x008, 0x00000e1c, + 0x000, 0x000000b7, + 0x00a, 0x00000850, + 0x000, 0x000000bf, + 0x00b, 0x000001ba, + 0x00c, 0x00000240, + 0x00e, 0x00000020, + 0x015, 0x00000f80, + 0x016, 0x00000020, + 0x017, 0x00000597, + 0x018, 0x0000050a, + 0x01a, 0x00000e00, + 0x01b, 0x00000f5e, + 0x01d, 0x00000607, + 0x01e, 0x000006cc, + 0x00b, 0x000001ba, + 0x023, 0x00000203, + 0x024, 0x00000200, + 0x000, 0x00000037, + 0x004, 0x00000160, + 0x016, 0x00000200, + 0x016, 0x00000380, + 0x016, 0x00000020, + 0x016, 0x000001a0, + 0x00d, 0x00000ccc, + 0x000, 0x000000bf, + 0x002, 0x0000004d, + 0x000, 0x00000cbf, + 0x004, 0x00000975, + 0x007, 0x00000700, }; u32 Rtl8192UsbRadioC_Array[] = { -0x0, }; + 0x0, }; u32 Rtl8192UsbRadioD_Array[] = { -0x0, }; + 0x0, }; u32 Rtl8192UsbMACPHY_Array[] = { -0x03c,0xffff0000,0x00000f0f, -0x340,0xffffffff,0x161a1a1a, -0x344,0xffffffff,0x12121416, -0x348,0x0000ffff,0x00001818, -0x12c,0xffffffff,0x04000802, -0x318,0x00000fff,0x00000100, + 0x03c, 0xffff0000, 0x00000f0f, + 0x340, 0xffffffff, 0x161a1a1a, + 0x344, 0xffffffff, 0x12121416, + 0x348, 0x0000ffff, 0x00001818, + 0x12c, 0xffffffff, 0x04000802, + 0x318, 0x00000fff, 0x00000100, }; u32 Rtl8192UsbMACPHY_Array_PG[] = { -0x03c,0xffff0000,0x00000f0f, -0xe00,0xffffffff,0x06090909, -0xe04,0xffffffff,0x00030306, -0xe08,0x0000ff00,0x00000000, -0xe10,0xffffffff,0x0a0c0d0f, -0xe14,0xffffffff,0x06070809, -0xe18,0xffffffff,0x0a0c0d0f, -0xe1c,0xffffffff,0x06070809, -0x12c,0xffffffff,0x04000802, -0x318,0x00000fff,0x00000800, + 0x03c, 0xffff0000, 0x00000f0f, + 0xe00, 0xffffffff, 0x06090909, + 0xe04, 0xffffffff, 0x00030306, + 0xe08, 0x0000ff00, 0x00000000, + 0xe10, 0xffffffff, 0x0a0c0d0f, + 0xe14, 0xffffffff, 0x06070809, + 0xe18, 0xffffffff, 0x0a0c0d0f, + 0xe1c, 0xffffffff, 0x06070809, + 0x12c, 0xffffffff, 0x04000802, + 0x318, 0x00000fff, 0x00000800, }; u32 Rtl8192UsbAGCTAB_Array[] = { -0xc78,0x7d000001, -0xc78,0x7d010001, -0xc78,0x7d020001, -0xc78,0x7d030001, -0xc78,0x7d040001, -0xc78,0x7d050001, -0xc78,0x7c060001, -0xc78,0x7b070001, -0xc78,0x7a080001, -0xc78,0x79090001, -0xc78,0x780a0001, -0xc78,0x770b0001, -0xc78,0x760c0001, -0xc78,0x750d0001, -0xc78,0x740e0001, -0xc78,0x730f0001, -0xc78,0x72100001, -0xc78,0x71110001, -0xc78,0x70120001, -0xc78,0x6f130001, -0xc78,0x6e140001, -0xc78,0x6d150001, -0xc78,0x6c160001, -0xc78,0x6b170001, -0xc78,0x6a180001, -0xc78,0x69190001, -0xc78,0x681a0001, -0xc78,0x671b0001, -0xc78,0x661c0001, -0xc78,0x651d0001, -0xc78,0x641e0001, -0xc78,0x491f0001, -0xc78,0x48200001, -0xc78,0x47210001, -0xc78,0x46220001, -0xc78,0x45230001, -0xc78,0x44240001, -0xc78,0x43250001, -0xc78,0x28260001, -0xc78,0x27270001, -0xc78,0x26280001, -0xc78,0x25290001, -0xc78,0x242a0001, -0xc78,0x232b0001, -0xc78,0x222c0001, -0xc78,0x212d0001, -0xc78,0x202e0001, -0xc78,0x0a2f0001, -0xc78,0x08300001, -0xc78,0x06310001, -0xc78,0x05320001, -0xc78,0x04330001, -0xc78,0x03340001, -0xc78,0x02350001, -0xc78,0x01360001, -0xc78,0x00370001, -0xc78,0x00380001, -0xc78,0x00390001, -0xc78,0x003a0001, -0xc78,0x003b0001, -0xc78,0x003c0001, -0xc78,0x003d0001, -0xc78,0x003e0001, -0xc78,0x003f0001, -0xc78,0x7d400001, -0xc78,0x7d410001, -0xc78,0x7d420001, -0xc78,0x7d430001, -0xc78,0x7d440001, -0xc78,0x7d450001, -0xc78,0x7c460001, -0xc78,0x7b470001, -0xc78,0x7a480001, -0xc78,0x79490001, -0xc78,0x784a0001, -0xc78,0x774b0001, -0xc78,0x764c0001, -0xc78,0x754d0001, -0xc78,0x744e0001, -0xc78,0x734f0001, -0xc78,0x72500001, -0xc78,0x71510001, -0xc78,0x70520001, -0xc78,0x6f530001, -0xc78,0x6e540001, -0xc78,0x6d550001, -0xc78,0x6c560001, -0xc78,0x6b570001, -0xc78,0x6a580001, -0xc78,0x69590001, -0xc78,0x685a0001, -0xc78,0x675b0001, -0xc78,0x665c0001, -0xc78,0x655d0001, -0xc78,0x645e0001, -0xc78,0x495f0001, -0xc78,0x48600001, -0xc78,0x47610001, -0xc78,0x46620001, -0xc78,0x45630001, -0xc78,0x44640001, -0xc78,0x43650001, -0xc78,0x28660001, -0xc78,0x27670001, -0xc78,0x26680001, -0xc78,0x25690001, -0xc78,0x246a0001, -0xc78,0x236b0001, -0xc78,0x226c0001, -0xc78,0x216d0001, -0xc78,0x206e0001, -0xc78,0x0a6f0001, -0xc78,0x08700001, -0xc78,0x06710001, -0xc78,0x05720001, -0xc78,0x04730001, -0xc78,0x03740001, -0xc78,0x02750001, -0xc78,0x01760001, -0xc78,0x00770001, -0xc78,0x00780001, -0xc78,0x00790001, -0xc78,0x007a0001, -0xc78,0x007b0001, -0xc78,0x007c0001, -0xc78,0x007d0001, -0xc78,0x007e0001, -0xc78,0x007f0001, -0xc78,0x2e00001e, -0xc78,0x2e01001e, -0xc78,0x2e02001e, -0xc78,0x2e03001e, -0xc78,0x2e04001e, -0xc78,0x2e05001e, -0xc78,0x3006001e, -0xc78,0x3407001e, -0xc78,0x3908001e, -0xc78,0x3c09001e, -0xc78,0x3f0a001e, -0xc78,0x420b001e, -0xc78,0x440c001e, -0xc78,0x450d001e, -0xc78,0x460e001e, -0xc78,0x460f001e, -0xc78,0x4710001e, -0xc78,0x4811001e, -0xc78,0x4912001e, -0xc78,0x4a13001e, -0xc78,0x4b14001e, -0xc78,0x4b15001e, -0xc78,0x4c16001e, -0xc78,0x4d17001e, -0xc78,0x4e18001e, -0xc78,0x4f19001e, -0xc78,0x4f1a001e, -0xc78,0x501b001e, -0xc78,0x511c001e, -0xc78,0x521d001e, -0xc78,0x521e001e, -0xc78,0x531f001e, -0xc78,0x5320001e, -0xc78,0x5421001e, -0xc78,0x5522001e, -0xc78,0x5523001e, -0xc78,0x5624001e, -0xc78,0x5725001e, -0xc78,0x5726001e, -0xc78,0x5827001e, -0xc78,0x5828001e, -0xc78,0x5929001e, -0xc78,0x592a001e, -0xc78,0x5a2b001e, -0xc78,0x5b2c001e, -0xc78,0x5c2d001e, -0xc78,0x5c2e001e, -0xc78,0x5d2f001e, -0xc78,0x5e30001e, -0xc78,0x5f31001e, -0xc78,0x6032001e, -0xc78,0x6033001e, -0xc78,0x6134001e, -0xc78,0x6235001e, -0xc78,0x6336001e, -0xc78,0x6437001e, -0xc78,0x6438001e, -0xc78,0x6539001e, -0xc78,0x663a001e, -0xc78,0x673b001e, -0xc78,0x673c001e, -0xc78,0x683d001e, -0xc78,0x693e001e, -0xc78,0x6a3f001e, + 0xc78, 0x7d000001, + 0xc78, 0x7d010001, + 0xc78, 0x7d020001, + 0xc78, 0x7d030001, + 0xc78, 0x7d040001, + 0xc78, 0x7d050001, + 0xc78, 0x7c060001, + 0xc78, 0x7b070001, + 0xc78, 0x7a080001, + 0xc78, 0x79090001, + 0xc78, 0x780a0001, + 0xc78, 0x770b0001, + 0xc78, 0x760c0001, + 0xc78, 0x750d0001, + 0xc78, 0x740e0001, + 0xc78, 0x730f0001, + 0xc78, 0x72100001, + 0xc78, 0x71110001, + 0xc78, 0x70120001, + 0xc78, 0x6f130001, + 0xc78, 0x6e140001, + 0xc78, 0x6d150001, + 0xc78, 0x6c160001, + 0xc78, 0x6b170001, + 0xc78, 0x6a180001, + 0xc78, 0x69190001, + 0xc78, 0x681a0001, + 0xc78, 0x671b0001, + 0xc78, 0x661c0001, + 0xc78, 0x651d0001, + 0xc78, 0x641e0001, + 0xc78, 0x491f0001, + 0xc78, 0x48200001, + 0xc78, 0x47210001, + 0xc78, 0x46220001, + 0xc78, 0x45230001, + 0xc78, 0x44240001, + 0xc78, 0x43250001, + 0xc78, 0x28260001, + 0xc78, 0x27270001, + 0xc78, 0x26280001, + 0xc78, 0x25290001, + 0xc78, 0x242a0001, + 0xc78, 0x232b0001, + 0xc78, 0x222c0001, + 0xc78, 0x212d0001, + 0xc78, 0x202e0001, + 0xc78, 0x0a2f0001, + 0xc78, 0x08300001, + 0xc78, 0x06310001, + 0xc78, 0x05320001, + 0xc78, 0x04330001, + 0xc78, 0x03340001, + 0xc78, 0x02350001, + 0xc78, 0x01360001, + 0xc78, 0x00370001, + 0xc78, 0x00380001, + 0xc78, 0x00390001, + 0xc78, 0x003a0001, + 0xc78, 0x003b0001, + 0xc78, 0x003c0001, + 0xc78, 0x003d0001, + 0xc78, 0x003e0001, + 0xc78, 0x003f0001, + 0xc78, 0x7d400001, + 0xc78, 0x7d410001, + 0xc78, 0x7d420001, + 0xc78, 0x7d430001, + 0xc78, 0x7d440001, + 0xc78, 0x7d450001, + 0xc78, 0x7c460001, + 0xc78, 0x7b470001, + 0xc78, 0x7a480001, + 0xc78, 0x79490001, + 0xc78, 0x784a0001, + 0xc78, 0x774b0001, + 0xc78, 0x764c0001, + 0xc78, 0x754d0001, + 0xc78, 0x744e0001, + 0xc78, 0x734f0001, + 0xc78, 0x72500001, + 0xc78, 0x71510001, + 0xc78, 0x70520001, + 0xc78, 0x6f530001, + 0xc78, 0x6e540001, + 0xc78, 0x6d550001, + 0xc78, 0x6c560001, + 0xc78, 0x6b570001, + 0xc78, 0x6a580001, + 0xc78, 0x69590001, + 0xc78, 0x685a0001, + 0xc78, 0x675b0001, + 0xc78, 0x665c0001, + 0xc78, 0x655d0001, + 0xc78, 0x645e0001, + 0xc78, 0x495f0001, + 0xc78, 0x48600001, + 0xc78, 0x47610001, + 0xc78, 0x46620001, + 0xc78, 0x45630001, + 0xc78, 0x44640001, + 0xc78, 0x43650001, + 0xc78, 0x28660001, + 0xc78, 0x27670001, + 0xc78, 0x26680001, + 0xc78, 0x25690001, + 0xc78, 0x246a0001, + 0xc78, 0x236b0001, + 0xc78, 0x226c0001, + 0xc78, 0x216d0001, + 0xc78, 0x206e0001, + 0xc78, 0x0a6f0001, + 0xc78, 0x08700001, + 0xc78, 0x06710001, + 0xc78, 0x05720001, + 0xc78, 0x04730001, + 0xc78, 0x03740001, + 0xc78, 0x02750001, + 0xc78, 0x01760001, + 0xc78, 0x00770001, + 0xc78, 0x00780001, + 0xc78, 0x00790001, + 0xc78, 0x007a0001, + 0xc78, 0x007b0001, + 0xc78, 0x007c0001, + 0xc78, 0x007d0001, + 0xc78, 0x007e0001, + 0xc78, 0x007f0001, + 0xc78, 0x2e00001e, + 0xc78, 0x2e01001e, + 0xc78, 0x2e02001e, + 0xc78, 0x2e03001e, + 0xc78, 0x2e04001e, + 0xc78, 0x2e05001e, + 0xc78, 0x3006001e, + 0xc78, 0x3407001e, + 0xc78, 0x3908001e, + 0xc78, 0x3c09001e, + 0xc78, 0x3f0a001e, + 0xc78, 0x420b001e, + 0xc78, 0x440c001e, + 0xc78, 0x450d001e, + 0xc78, 0x460e001e, + 0xc78, 0x460f001e, + 0xc78, 0x4710001e, + 0xc78, 0x4811001e, + 0xc78, 0x4912001e, + 0xc78, 0x4a13001e, + 0xc78, 0x4b14001e, + 0xc78, 0x4b15001e, + 0xc78, 0x4c16001e, + 0xc78, 0x4d17001e, + 0xc78, 0x4e18001e, + 0xc78, 0x4f19001e, + 0xc78, 0x4f1a001e, + 0xc78, 0x501b001e, + 0xc78, 0x511c001e, + 0xc78, 0x521d001e, + 0xc78, 0x521e001e, + 0xc78, 0x531f001e, + 0xc78, 0x5320001e, + 0xc78, 0x5421001e, + 0xc78, 0x5522001e, + 0xc78, 0x5523001e, + 0xc78, 0x5624001e, + 0xc78, 0x5725001e, + 0xc78, 0x5726001e, + 0xc78, 0x5827001e, + 0xc78, 0x5828001e, + 0xc78, 0x5929001e, + 0xc78, 0x592a001e, + 0xc78, 0x5a2b001e, + 0xc78, 0x5b2c001e, + 0xc78, 0x5c2d001e, + 0xc78, 0x5c2e001e, + 0xc78, 0x5d2f001e, + 0xc78, 0x5e30001e, + 0xc78, 0x5f31001e, + 0xc78, 0x6032001e, + 0xc78, 0x6033001e, + 0xc78, 0x6134001e, + 0xc78, 0x6235001e, + 0xc78, 0x6336001e, + 0xc78, 0x6437001e, + 0xc78, 0x6438001e, + 0xc78, 0x6539001e, + 0xc78, 0x663a001e, + 0xc78, 0x673b001e, + 0xc78, 0x673c001e, + 0xc78, 0x683d001e, + 0xc78, 0x693e001e, + 0xc78, 0x6a3f001e, }; -- cgit v1.2.3 From 7879be810c05e7a1e6ef0dde65ad730d704535df Mon Sep 17 00:00:00 2001 From: Manuel Schölling Date: Sun, 25 May 2014 20:07:02 +0200 Subject: staging: dgnc: Use time_after_eq() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To be future-proof and for better readability the time comparisons are modified to use time_after_eq() instead of plain, error-prone math. Signed-off-by: Manuel Schölling Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_neo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c index 2d472e643b01..9de988cc892b 100644 --- a/drivers/staging/dgnc/dgnc_neo.c +++ b/drivers/staging/dgnc/dgnc_neo.c @@ -395,7 +395,8 @@ static inline void neo_clear_break(struct channel_t *ch, int force) /* Turn break off, and unset some variables */ if (ch->ch_flags & CH_BREAK_SENDING) { - if ((jiffies >= ch->ch_stop_sending_break) || force) { + if (time_after_eq(jiffies, ch->ch_stop_sending_break) + || force) { uchar temp = readb(&ch->ch_neo_uart->lcr); writeb((temp & ~UART_LCR_SBC), &ch->ch_neo_uart->lcr); neo_pci_posting_flush(ch->ch_bd); -- cgit v1.2.3 From a5a7c439065bec8ef74e116fac0a2cb0f4c0543c Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sun, 25 May 2014 21:36:22 +0100 Subject: staging: vt6656: swGetOFDMControlRate remove camel case camel case changes pDevice -> priv wRateIdx -> rate_idx Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/card.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index ce069c9db854..f025010c96eb 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -149,31 +149,31 @@ static u16 swGetCCKControlRate(struct vnt_private *pDevice, u16 wRateIdx) * * Parameters: * In: - * pDevice - The adapter to be set - * wRateIdx - Receiving data rate + * priv - The adapter to be set + * rate_idx - Receiving data rate * Out: * none * * Return Value: response Control frame rate * */ -static u16 swGetOFDMControlRate(struct vnt_private *pDevice, u16 wRateIdx) +static u16 swGetOFDMControlRate(struct vnt_private *priv, u16 rate_idx) { - u16 ui = wRateIdx; + u16 ui = rate_idx; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BASIC RATE: %X\n", - pDevice->wBasicRate); + priv->wBasicRate); - if (!CARDbIsOFDMinBasicRate(pDevice)) { + if (!CARDbIsOFDMinBasicRate(priv)) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "swGetOFDMControlRate:(NO OFDM) %d\n", wRateIdx); - if (wRateIdx > RATE_24M) - wRateIdx = RATE_24M; - return wRateIdx; + "swGetOFDMControlRate:(NO OFDM) %d\n", rate_idx); + if (rate_idx > RATE_24M) + rate_idx = RATE_24M; + return rate_idx; } while (ui > RATE_11M) { - if (pDevice->wBasicRate & (1 << ui)) { + if (priv->wBasicRate & (1 << ui)) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "swGetOFDMControlRate: %d\n", ui); return ui; -- cgit v1.2.3 From 3d2988c74b6ed05c9d6256df93e9b2869ffa585d Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sun, 25 May 2014 21:36:23 +0100 Subject: staging; vt6656: swGetCCKControlRate remove camel case camel case changes pDevice -> priv wRateIdx -> rate_idx Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/card.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index f025010c96eb..c162ce4937a0 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -123,20 +123,20 @@ void CARDbSetMediaChannel(struct vnt_private *priv, u32 connection_channel) * * Parameters: * In: - * pDevice - The adapter to be set - * wRateIdx - Receiving data rate + * priv - The adapter to be set + * rate_idx - Receiving data rate * Out: * none * * Return Value: response Control frame rate * */ -static u16 swGetCCKControlRate(struct vnt_private *pDevice, u16 wRateIdx) +static u16 swGetCCKControlRate(struct vnt_private *priv, u16 rate_idx) { - u16 ui = wRateIdx; + u16 ui = rate_idx; while (ui > RATE_1M) { - if (pDevice->wBasicRate & (1 << ui)) + if (priv->wBasicRate & (1 << ui)) return ui; ui--; } -- cgit v1.2.3 From 842e3ecceae9f805f52d8a2eca8b8951151a438d Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sun, 25 May 2014 21:36:24 +0100 Subject: staging: vt6656: card.c replace DBG_PRT debug messages. Replace with dev_dbg Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/card.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index c162ce4937a0..6da912b4ec68 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -59,9 +59,6 @@ #include "datarate.h" #include "control.h" -//static int msglevel =MSG_LEVEL_DEBUG; -static int msglevel =MSG_LEVEL_INFO; - //const u16 cwRXBCNTSFOff[MAX_RATE] = //{17, 34, 96, 192, 34, 23, 17, 11, 8, 5, 4, 3}; @@ -161,12 +158,12 @@ static u16 swGetOFDMControlRate(struct vnt_private *priv, u16 rate_idx) { u16 ui = rate_idx; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BASIC RATE: %X\n", - priv->wBasicRate); + dev_dbg(&priv->usb->dev, "%s basic rate: %d\n", + __func__, priv->wBasicRate); if (!CARDbIsOFDMinBasicRate(priv)) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "swGetOFDMControlRate:(NO OFDM) %d\n", rate_idx); + dev_dbg(&priv->usb->dev, "%s (NO OFDM) %d\n", + __func__, rate_idx); if (rate_idx > RATE_24M) rate_idx = RATE_24M; return rate_idx; @@ -174,14 +171,14 @@ static u16 swGetOFDMControlRate(struct vnt_private *priv, u16 rate_idx) while (ui > RATE_11M) { if (priv->wBasicRate & (1 << ui)) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "swGetOFDMControlRate: %d\n", ui); + dev_dbg(&priv->usb->dev, "%s rate: %d\n", + __func__, ui); return ui; } ui--; } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"swGetOFDMControlRate: 6M\n"); + dev_dbg(&priv->usb->dev, "%s basic rate: 24M\n", __func__); return RATE_24M; } @@ -755,8 +752,7 @@ void CARDvUpdateNextTBTT(struct vnt_private *priv, u64 tsf, CONTROLnsRequestOut(priv, MESSAGE_TYPE_SET_TSFTBTT, MESSAGE_REQUEST_TBTT, 0, 8, data); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "Card:Update Next TBTT[%8lx]\n", (unsigned long)tsf); + dev_dbg(&priv->usb->dev, "%s TBTT: %8llx\n", __func__, tsf); return; } -- cgit v1.2.3 From 7b1f9eefc8c900a030b5aa0bc619c4c909b068f8 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sun, 25 May 2014 21:36:25 +0100 Subject: staging: vt6656: baseband.c replace DBG_PRT debug messages Replace with dev_dbg Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index 3a06bf49e7a3..c2b0897d090b 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -43,9 +43,6 @@ #include "control.h" #include "datarate.h" -static int msglevel =MSG_LEVEL_INFO; -//static int msglevel =MSG_LEVEL_DEBUG; - static u8 abyVT3184_AGC[] = { 0x00, //0 0x00, //1 @@ -910,20 +907,20 @@ int BBbVT3184Init(struct vnt_private *priv) (priv->abyEEPROM[EEP_OFS_ZONETYPE] != 0x00)) { priv->abyEEPROM[EEP_OFS_ZONETYPE] = 0; priv->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0B; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "Init Zone Type :USA\n"); + + dev_dbg(&priv->usb->dev, "Init Zone Type :USA\n"); } else if ((priv->config_file.ZoneType == 1) && (priv->abyEEPROM[EEP_OFS_ZONETYPE] != 0x01)) { priv->abyEEPROM[EEP_OFS_ZONETYPE] = 0x01; priv->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0D; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "Init Zone Type :Japan\n"); + + dev_dbg(&priv->usb->dev, "Init Zone Type :Japan\n"); } else if ((priv->config_file.ZoneType == 2) && (priv->abyEEPROM[EEP_OFS_ZONETYPE] != 0x02)) { priv->abyEEPROM[EEP_OFS_ZONETYPE] = 0x02; priv->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0D; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "Init Zone Type :Europe\n"); + + dev_dbg(&priv->usb->dev, "Init Zone Type :Europe\n"); } else { if (priv->config_file.ZoneType != priv->abyEEPROM[EEP_OFS_ZONETYPE]) @@ -943,10 +940,9 @@ int BBbVT3184Init(struct vnt_private *priv) priv->byRFType = priv->abyEEPROM[EEP_OFS_RFTYPE]; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Zone Type %x\n", - priv->byZoneType); + dev_dbg(&priv->usb->dev, "Zone Type %x\n", priv->byZoneType); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RF Type %d\n", priv->byRFType); + dev_dbg(&priv->usb->dev, "RF Type %d\n", priv->byRFType); if ((priv->byRFType == RF_AL2230) || (priv->byRFType == RF_AL2230S)) { -- cgit v1.2.3 From 4237fe4fd6f99d51660b6f65e9e6fef32899d85c Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sun, 25 May 2014 21:36:26 +0100 Subject: staging: vt6656: BBbVT3184Init fix word lenght Correct to length Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index c2b0897d090b..309a3cb74391 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -886,10 +886,10 @@ void BBvSetAntennaMode(struct vnt_private *priv, u8 antenna_mode) int BBbVT3184Init(struct vnt_private *priv) { int status; - u16 lenght; + u16 length; u8 *addr; u8 *agc; - u16 lenght_agc; + u16 length_agc; u8 array[256]; u8 data; @@ -947,10 +947,10 @@ int BBbVT3184Init(struct vnt_private *priv) if ((priv->byRFType == RF_AL2230) || (priv->byRFType == RF_AL2230S)) { priv->byBBRxConf = abyVT3184_AL2230[10]; - lenght = sizeof(abyVT3184_AL2230); + length = sizeof(abyVT3184_AL2230); addr = abyVT3184_AL2230; agc = abyVT3184_AGC; - lenght_agc = sizeof(abyVT3184_AGC); + length_agc = sizeof(abyVT3184_AGC); priv->abyBBVGA[0] = 0x1C; priv->abyBBVGA[1] = 0x10; @@ -962,10 +962,10 @@ int BBbVT3184Init(struct vnt_private *priv) priv->ldBmThreshold[3] = 0; } else if (priv->byRFType == RF_AIROHA7230) { priv->byBBRxConf = abyVT3184_AL2230[10]; - lenght = sizeof(abyVT3184_AL2230); + length = sizeof(abyVT3184_AL2230); addr = abyVT3184_AL2230; agc = abyVT3184_AGC; - lenght_agc = sizeof(abyVT3184_AGC); + length_agc = sizeof(abyVT3184_AGC); addr[0xd7] = 0x06; @@ -980,10 +980,10 @@ int BBbVT3184Init(struct vnt_private *priv) } else if ((priv->byRFType == RF_VT3226) || (priv->byRFType == RF_VT3226D0)) { priv->byBBRxConf = abyVT3184_VT3226D0[10]; - lenght = sizeof(abyVT3184_VT3226D0); + length = sizeof(abyVT3184_VT3226D0); addr = abyVT3184_VT3226D0; agc = abyVT3184_AGC; - lenght_agc = sizeof(abyVT3184_AGC); + length_agc = sizeof(abyVT3184_AGC); priv->abyBBVGA[0] = 0x20; priv->abyBBVGA[1] = 0x10; @@ -997,10 +997,10 @@ int BBbVT3184Init(struct vnt_private *priv) MACvRegBitsOn(priv, MAC_REG_SOFTPWRCTL2, SOFTPWRCTL_RFLEOPT); } else if ((priv->byRFType == RF_VT3342A0)) { priv->byBBRxConf = abyVT3184_VT3226D0[10]; - lenght = sizeof(abyVT3184_VT3226D0); + length = sizeof(abyVT3184_VT3226D0); addr = abyVT3184_VT3226D0; agc = abyVT3184_AGC; - lenght_agc = sizeof(abyVT3184_AGC); + length_agc = sizeof(abyVT3184_AGC); priv->abyBBVGA[0] = 0x20; priv->abyBBVGA[1] = 0x10; @@ -1016,15 +1016,15 @@ int BBbVT3184Init(struct vnt_private *priv) return true; } - memcpy(array, addr, lenght); + memcpy(array, addr, length); CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, 0, - MESSAGE_REQUEST_BBREG, lenght, array); + MESSAGE_REQUEST_BBREG, length, array); - memcpy(array, agc, lenght_agc); + memcpy(array, agc, length_agc); CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, 0, - MESSAGE_REQUEST_BBAGC, lenght_agc, array); + MESSAGE_REQUEST_BBAGC, length_agc, array); if ((priv->byRFType == RF_VT3226) || (priv->byRFType == RF_VT3342A0)) { -- cgit v1.2.3 From 3b6cee7be3910aeae25481f147beac0faf0dfe82 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sun, 25 May 2014 21:36:27 +0100 Subject: staging: vt6656: s_uGetRTSCTSRsvTime fix word lenght Correct to length Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index ae80e18ccc0d..742559de64ec 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -117,7 +117,7 @@ static unsigned int s_uGetTxRsvTime(struct vnt_private *pDevice, u8 byPktType, u32 cbFrameLength, u16 wRate, int bNeedAck); static __le16 s_uGetRTSCTSRsvTime(struct vnt_private *priv, - u8 rsv_type, u8 pkt_type, u32 frame_lenght, u16 current_rate); + u8 rsv_type, u8 pkt_type, u32 frame_length, u16 current_rate); static u16 s_vFillCTSHead(struct vnt_private *pDevice, u8 byPktType, union vnt_tx_data_head *head, u32 cbFrameLength, @@ -366,14 +366,14 @@ static __le16 vnt_rxtx_rsvtime_le16(struct vnt_private *priv, u8 pkt_type, //byFreqType: 0=>5GHZ 1=>2.4GHZ static __le16 s_uGetRTSCTSRsvTime(struct vnt_private *priv, - u8 rsv_type, u8 pkt_type, u32 frame_lenght, u16 current_rate) + u8 rsv_type, u8 pkt_type, u32 frame_length, u16 current_rate) { u32 rrv_time, rts_time, cts_time, ack_time, data_time; rrv_time = rts_time = cts_time = ack_time = data_time = 0; data_time = BBuGetFrameTime(priv->byPreambleType, pkt_type, - frame_lenght, current_rate); + frame_length, current_rate); if (rsv_type == 0) { rts_time = BBuGetFrameTime(priv->byPreambleType, -- cgit v1.2.3 From 5cb5bff703008c2a2dc2357ac660bcbf02796161 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sun, 25 May 2014 21:36:28 +0100 Subject: staging: vt6656: s_vFillTxKey fix indentation of memcpy Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 742559de64ec..f11c2d3b22c2 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -204,7 +204,7 @@ static void s_vFillTxKey(struct vnt_private *pDevice, pTransmitKey->uKeyLength); if (pTransmitKey->uKeyLength == WLAN_WEP40_KEYLEN) { memcpy(pbyBuf+8, (u8 *)&rev_iv_counter, 3); - memcpy(pbyBuf+11, pTransmitKey->abyKey, + memcpy(pbyBuf+11, pTransmitKey->abyKey, pTransmitKey->uKeyLength); } -- cgit v1.2.3 From 83bf96fe5167c3ce8434bc0056c8b2d548d72732 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sun, 25 May 2014 21:36:29 +0100 Subject: staging: vt6656: MACvSetKeyEntry create structure to write key Create structure for wKeyCtl , pbyAddr and pbyKey wKeyCtl(key_ctl) and pbyAddr(addr) form an union of 64 bits with swap of two 32 bits. pbyKey(key) has a length of WLAN_KEY_LEN_CCMP(16) bytes. swap is needed because high order 32 bits needs to written out first. pbyKey is memcpy on to key. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/mac.c | 65 ++++++++++++-------------------------------- drivers/staging/vt6656/mac.h | 11 ++++++++ 2 files changed, 29 insertions(+), 47 deletions(-) diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index f48683407496..bc72144f0d21 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -125,60 +125,31 @@ void MACvDisableKeyEntry(struct vnt_private *priv, u8 entry_idx) void MACvSetKeyEntry(struct vnt_private *pDevice, u16 wKeyCtl, u32 uEntryIdx, u32 uKeyIdx, u8 *pbyAddr, u32 *pdwKey) { - u8 *pbyKey; + struct vnt_mac_set_key set_key; + u8 *pbyKey = (u8 *)pdwKey; u16 wOffset; - u32 dwData1, dwData2; - int ii; - u8 pbyData[24]; if (pDevice->byLocalID <= MAC_REVISION_A1) if (pDevice->vnt_mgmt.byCSSPK == KEY_CTL_CCMP) return; - wOffset = MISCFIFO_KEYETRY0; - wOffset += (uEntryIdx * MISCFIFO_KEYENTRYSIZE); - - dwData1 = 0; - dwData1 |= wKeyCtl; - dwData1 <<= 16; - dwData1 |= MAKEWORD(*(pbyAddr+4), *(pbyAddr+5)); - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"1. wOffset: %d, Data: %X,"\ - " KeyCtl:%X\n", wOffset, dwData1, wKeyCtl); - - dwData2 = 0; - dwData2 |= *(pbyAddr+3); - dwData2 <<= 8; - dwData2 |= *(pbyAddr+2); - dwData2 <<= 8; - dwData2 |= *(pbyAddr+1); - dwData2 <<= 8; - dwData2 |= *(pbyAddr+0); - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"2. wOffset: %d, Data: %X\n", - wOffset, dwData2); - - pbyKey = (u8 *)pdwKey; - - pbyData[0] = (u8)dwData1; - pbyData[1] = (u8)(dwData1>>8); - pbyData[2] = (u8)(dwData1>>16); - pbyData[3] = (u8)(dwData1>>24); - pbyData[4] = (u8)dwData2; - pbyData[5] = (u8)(dwData2>>8); - pbyData[6] = (u8)(dwData2>>16); - pbyData[7] = (u8)(dwData2>>24); - for (ii = 8; ii < 24; ii++) - pbyData[ii] = *pbyKey++; - - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_SETKEY, - wOffset, - (u16)uKeyIdx, - ARRAY_SIZE(pbyData), - pbyData - ); + wOffset = MISCFIFO_KEYETRY0; + wOffset += (uEntryIdx * MISCFIFO_KEYENTRYSIZE); + set_key.u.write.key_ctl = cpu_to_le16(wKeyCtl); + memcpy(set_key.u.write.addr, pbyAddr, ETH_ALEN); + + /* swap over swap[0] and swap[1] to get correct write order */ + swap(set_key.u.swap[0], set_key.u.swap[1]); + + memcpy(set_key.key, pbyKey, WLAN_KEY_LEN_CCMP); + + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + "offset %d key ctl %d set key %24ph\n", + wOffset, wKeyCtl, (u8 *)&set_key); + + CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_SETKEY, wOffset, + (u16)uKeyIdx, sizeof(struct vnt_mac_set_key), (u8 *)&set_key); } void MACvRegBitsOff(struct vnt_private *priv, u8 reg_ofs, u8 bits) diff --git a/drivers/staging/vt6656/mac.h b/drivers/staging/vt6656/mac.h index 2084d4b1e532..81006853dbda 100644 --- a/drivers/staging/vt6656/mac.h +++ b/drivers/staging/vt6656/mac.h @@ -403,6 +403,17 @@ #define MAC_REVISION_A0 0x00 #define MAC_REVISION_A1 0x01 +struct vnt_mac_set_key { + union { + struct { + u8 addr[ETH_ALEN]; + __le16 key_ctl; + } write __packed; + u32 swap[2]; + } u; + u8 key[WLAN_KEY_LEN_CCMP]; +} __packed; + void MACvWriteMultiAddr(struct vnt_private *, u64); void MACbShutdown(struct vnt_private *); void MACvSetBBType(struct vnt_private *, u8); -- cgit v1.2.3 From c1caefbb4c3f600260a12dbe7dfc087a1a98d51c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:01 +0200 Subject: staging: rtl8723au: ieee80211.h: Remove some unused #defines Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/ieee80211.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/rtl8723au/include/ieee80211.h b/drivers/staging/rtl8723au/include/ieee80211.h index e69f1cc67883..69c0f5c94fcc 100644 --- a/drivers/staging/rtl8723au/include/ieee80211.h +++ b/drivers/staging/rtl8723au/include/ieee80211.h @@ -330,21 +330,11 @@ join_res: > 0: TID */ -#define DEFAULT_MAX_SCAN_AGE (15 * HZ) -#define DEFAULT_FTS 2346 #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" #define MAC_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3],((u8*)(x))[4],((u8*)(x))[5] -#define CFG_IEEE80211_RESERVE_FCS (1<<0) -#define CFG_IEEE80211_COMPUTE_FCS (1<<1) - #define MAXTID 16 -#define IEEE_A (1<<0) -#define IEEE_B (1<<1) -#define IEEE_G (1<<2) -#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G) - enum _PUBLIC_ACTION{ ACT_PUBLIC_BSSCOEXIST = 0, /* 20/40 BSS Coexistence */ ACT_PUBLIC_DSE_ENABLE = 1, -- cgit v1.2.3 From 06e17e361eadc3897bcd58370a6e5dbf94722d21 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:02 +0200 Subject: staging: rtl8723au: Use ieee80211.h defines for IV/ICV len values Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 4 ++-- drivers/staging/rtl8723au/core/rtw_recv.c | 12 ++++++------ drivers/staging/rtl8723au/core/rtw_xmit.c | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index b78e453b7a0f..b0f218b4ca2f 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -3085,7 +3085,7 @@ static void issue_auth(struct rtw_adapter *padapter, struct sta_info *psta, (unsigned char *)&val32, &pattrib->pktlen); - pattrib->iv_len = 4; + pattrib->iv_len = IEEE80211_WEP_IV_LEN; } pframe = rtw_set_fixed_ie23a(pframe, _AUTH_ALGM_NUM_, @@ -3121,7 +3121,7 @@ static void issue_auth(struct rtw_adapter *padapter, struct sta_info *psta, pattrib->encrypt = WLAN_CIPHER_SUITE_WEP40; - pattrib->icv_len = 4; + pattrib->icv_len = IEEE80211_WEP_ICV_LEN; pattrib->pktlen += pattrib->icv_len; } diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 3275287ca25a..24fa28848769 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -1410,16 +1410,16 @@ static int validate_recv_data_frame(struct rtw_adapter *adapter, { case WLAN_CIPHER_SUITE_WEP40: case WLAN_CIPHER_SUITE_WEP104: - pattrib->iv_len = 4; - pattrib->icv_len = 4; + pattrib->iv_len = IEEE80211_WEP_IV_LEN; + pattrib->icv_len = IEEE80211_WEP_ICV_LEN; break; case WLAN_CIPHER_SUITE_TKIP: - pattrib->iv_len = 8; - pattrib->icv_len = 4; + pattrib->iv_len = IEEE80211_TKIP_IV_LEN; + pattrib->icv_len = IEEE80211_TKIP_ICV_LEN; break; case WLAN_CIPHER_SUITE_CCMP: - pattrib->iv_len = 8; - pattrib->icv_len = 8; + pattrib->iv_len = IEEE80211_CCMP_HDR_LEN; + pattrib->icv_len = IEEE80211_CCMP_MIC_LEN; break; default: pattrib->iv_len = 0; diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 3869386f441a..0c66d3541665 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -597,13 +597,13 @@ static int update_attrib(struct rtw_adapter *padapter, switch (pattrib->encrypt) { case WLAN_CIPHER_SUITE_WEP40: case WLAN_CIPHER_SUITE_WEP104: - pattrib->iv_len = 4; - pattrib->icv_len = 4; + pattrib->iv_len = IEEE80211_WEP_IV_LEN; + pattrib->icv_len = IEEE80211_WEP_ICV_LEN; break; case WLAN_CIPHER_SUITE_TKIP: - pattrib->iv_len = 8; - pattrib->icv_len = 4; + pattrib->iv_len = IEEE80211_TKIP_IV_LEN; + pattrib->icv_len = IEEE80211_TKIP_ICV_LEN; if (!padapter->securitypriv.busetkipkey) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, @@ -619,8 +619,8 @@ static int update_attrib(struct rtw_adapter *padapter, RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("pattrib->encrypt =%d (WLAN_CIPHER_SUITE_CCMP)\n", pattrib->encrypt)); - pattrib->iv_len = 8; - pattrib->icv_len = 8; + pattrib->iv_len = IEEE80211_CCMP_HDR_LEN; + pattrib->icv_len = IEEE80211_CCMP_MIC_LEN; break; default: -- cgit v1.2.3 From 04e57767ef1805393f22ef9989e5dfcb61379711 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:03 +0200 Subject: staging: rtl8723au: rtw_xmit.c: Use ether_addr_copy() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 0c66d3541665..90604941624c 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -902,9 +902,9 @@ static int rtw_make_wlanhdr(struct rtw_adapter *padapter, u8 *hdr, /* Data transfer to AP */ pwlanhdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_TODS); - memcpy(pwlanhdr->addr1, get_bssid(pmlmepriv), ETH_ALEN); - memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN); - memcpy(pwlanhdr->addr3, pattrib->dst, ETH_ALEN); + ether_addr_copy(pwlanhdr->addr1, get_bssid(pmlmepriv)); + ether_addr_copy(pwlanhdr->addr2, pattrib->src); + ether_addr_copy(pwlanhdr->addr3, pattrib->dst); if (pmlmepriv->qos_option) qos_option = true; @@ -914,18 +914,18 @@ static int rtw_make_wlanhdr(struct rtw_adapter *padapter, u8 *hdr, /* to_ds = 0, fr_ds = 1; */ pwlanhdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_FROMDS); - memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN); - memcpy(pwlanhdr->addr2, get_bssid(pmlmepriv), ETH_ALEN); - memcpy(pwlanhdr->addr3, pattrib->src, ETH_ALEN); + ether_addr_copy(pwlanhdr->addr1, pattrib->dst); + ether_addr_copy(pwlanhdr->addr2, get_bssid(pmlmepriv)); + ether_addr_copy(pwlanhdr->addr3, pattrib->src); if (psta->qos_option) qos_option = true; } else if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) || (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) { - memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN); - memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN); - memcpy(pwlanhdr->addr3, get_bssid(pmlmepriv), ETH_ALEN); + ether_addr_copy(pwlanhdr->addr1, pattrib->dst); + ether_addr_copy(pwlanhdr->addr2, pattrib->src); + ether_addr_copy(pwlanhdr->addr3, get_bssid(pmlmepriv)); if (psta->qos_option) qos_option = true; -- cgit v1.2.3 From f2f97035f08a5ea1f0c23e65f6ea9cd2f3cd2586 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:04 +0200 Subject: staging: rtl8723au: Don't explicitly check check_fwstate() == true Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 12 +++++----- drivers/staging/rtl8723au/core/rtw_ioctl_set.c | 24 +++++++++----------- drivers/staging/rtl8723au/core/rtw_led.c | 31 +++++++++++++------------- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 8 +++---- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 12 +++++----- drivers/staging/rtl8723au/core/rtw_recv.c | 26 ++++++++++----------- drivers/staging/rtl8723au/core/rtw_xmit.c | 22 ++++++++---------- 7 files changed, 63 insertions(+), 72 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index bf9e56229a30..1768a94f8f79 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -349,7 +349,7 @@ int rtw_sitesurvey_cmd23a(struct rtw_adapter *padapter, struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) + if (check_fwstate(pmlmepriv, _FW_LINKED)) rtw_lps_ctrl_wk_cmd23a(padapter, LPS_CTRL_SCAN, 1); ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); @@ -1030,7 +1030,7 @@ static void dynamic_chk_wk_hdl(struct rtw_adapter *padapter, u8 *pbuf, int sz) pmlmepriv = &padapter->mlmepriv; #ifdef CONFIG_8723AU_AP_MODE - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) expire_timeout_chk23a(padapter); #endif @@ -1055,8 +1055,8 @@ static void lps_ctrl_wk_hdl(struct rtw_adapter *padapter, u8 lps_ctrl_type) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; u8 mstatus; - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) return; switch (lps_ctrl_type) @@ -1597,8 +1597,8 @@ void rtw_setassocsta_cmdrsp_callback23a(struct rtw_adapter *padapter, spin_lock_bh(&pmlmepriv->lock); - if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) && - (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true)) + if (check_fwstate(pmlmepriv, WIFI_MP_STATE) && + check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); set_fwstate(pmlmepriv, _FW_LINKED); diff --git a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c index f65443c62baf..ff740afffbb8 100644 --- a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c @@ -82,7 +82,7 @@ int rtw_do_join23a(struct rtw_adapter *padapter) mod_timer(&pmlmepriv->assoc_timer, jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT)); } else { - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { struct wlan_bssid_ex *pdev_network; /* submit createbss_cmd to change to a ADHOC_MASTER */ @@ -175,14 +175,12 @@ int rtw_set_802_11_ssid23a(struct rtw_adapter* padapter, spin_lock_bh(&pmlmepriv->lock); DBG_8723A("Set SSID under fw_state = 0x%08x\n", get_fwstate(pmlmepriv)); - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) { + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) goto handle_tkip_countermeasure; - } else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) { + else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) goto release_mlme_lock; - } - if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) - { + if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE)) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_ssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n")); @@ -200,12 +198,12 @@ int rtw_set_802_11_ssid23a(struct rtw_adapter* padapter, /* if in WIFI_ADHOC_MASTER_STATE | WIFI_ADHOC_STATE, create bss or rejoin again */ rtw_disassoc_cmd23a(padapter, 0, true); - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) + if (check_fwstate(pmlmepriv, _FW_LINKED)) rtw_indicate_disconnect23a(padapter); rtw_free_assoc_resources23a(padapter, 1); - if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); } @@ -228,12 +226,12 @@ int rtw_set_802_11_ssid23a(struct rtw_adapter* padapter, rtw_disassoc_cmd23a(padapter, 0, true); - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) + if (check_fwstate(pmlmepriv, _FW_LINKED)) rtw_indicate_disconnect23a(padapter); rtw_free_assoc_resources23a(padapter, 1); - if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); } @@ -260,12 +258,10 @@ handle_tkip_countermeasure: memcpy(&pmlmepriv->assoc_ssid, ssid, sizeof(struct cfg80211_ssid)); pmlmepriv->assoc_by_bssid = false; - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) { + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) pmlmepriv->to_join = true; - } - else { + else status = rtw_do_join23a(padapter); - } release_mlme_lock: spin_unlock_bh(&pmlmepriv->lock); diff --git a/drivers/staging/rtl8723au/core/rtw_led.c b/drivers/staging/rtl8723au/core/rtw_led.c index 68532a3b2c14..c4337688b206 100644 --- a/drivers/staging/rtl8723au/core/rtw_led.c +++ b/drivers/staging/rtl8723au/core/rtw_led.c @@ -225,7 +225,7 @@ static void SwLedBlink1(struct led_8723a *pLed) if (pLed->BlinkTimes == 0) bStopBlinking = true; if (bStopBlinking) { - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { pLed->bLedLinkBlinkInProgress = true; pLed->CurrLedState = LED_BLINK_NORMAL; if (pLed->bLedOn) @@ -258,7 +258,7 @@ static void SwLedBlink1(struct led_8723a *pLed) if (pLed->BlinkTimes == 0) bStopBlinking = true; if (bStopBlinking) { - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { pLed->bLedLinkBlinkInProgress = true; pLed->CurrLedState = LED_BLINK_NORMAL; if (pLed->bLedOn) @@ -450,8 +450,7 @@ static void SwLedBlink3(struct led_8723a *pLed) { SwLedOff23a(padapter, pLed); } - else if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { + else if (check_fwstate(pmlmepriv, _FW_LINKED)) { pLed->CurrLedState = RTW_LED_ON; pLed->BlinkingLedState = RTW_LED_ON; if (!pLed->bLedOn) @@ -499,9 +498,8 @@ static void SwLedBlink3(struct led_8723a *pLed) if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { SwLedOff23a(padapter, pLed); - } - else if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { + } else if (check_fwstate(pmlmepriv, + _FW_LINKED)) { pLed->CurrLedState = RTW_LED_ON; pLed->BlinkingLedState = RTW_LED_ON; @@ -914,8 +912,8 @@ SwLedControlMode1(struct rtw_adapter *padapter, enum led_ctl_mode LedAction) break; case LED_CTL_SITE_SURVEY: - if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && - (check_fwstate(pmlmepriv, _FW_LINKED) == true)) + if (pmlmepriv->LinkDetectInfo.bBusyTraffic && + check_fwstate(pmlmepriv, _FW_LINKED)) ; else if (pLed->bLedScanBlinkInProgress == false) { if (IS_LED_WPS_BLINKING(pLed)) @@ -1118,8 +1116,8 @@ SwLedControlMode2(struct rtw_adapter *padapter, enum led_ctl_mode LedAction) break; case LED_CTL_TX: case LED_CTL_RX: - if ((pLed->bLedBlinkInProgress == false) && - (check_fwstate(pmlmepriv, _FW_LINKED) == true)) { + if (pLed->bLedBlinkInProgress == false && + check_fwstate(pmlmepriv, _FW_LINKED)) { if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) { return; @@ -1261,8 +1259,8 @@ SwLedControlMode3(struct rtw_adapter *padapter, enum led_ctl_mode LedAction) case LED_CTL_TX: case LED_CTL_RX: - if ((pLed->bLedBlinkInProgress == false) && - (check_fwstate(pmlmepriv, _FW_LINKED) == true)) { + if (pLed->bLedBlinkInProgress == false && + check_fwstate(pmlmepriv, _FW_LINKED)) { if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) { return; @@ -1477,8 +1475,8 @@ SwLedControlMode4(struct rtw_adapter *padapter, enum led_ctl_mode LedAction) break; case LED_CTL_SITE_SURVEY: - if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && - (check_fwstate(pmlmepriv, _FW_LINKED) == true)) + if (pmlmepriv->LinkDetectInfo.bBusyTraffic && + check_fwstate(pmlmepriv, _FW_LINKED)) ; else if (pLed->bLedScanBlinkInProgress == false) { if (IS_LED_WPS_BLINKING(pLed)) @@ -1714,7 +1712,8 @@ SwLedControlMode5(struct rtw_adapter *padapter, enum led_ctl_mode LedAction) break; case LED_CTL_SITE_SURVEY: - if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && (check_fwstate(pmlmepriv, _FW_LINKED) == true)) + if (pmlmepriv->LinkDetectInfo.bBusyTraffic && + check_fwstate(pmlmepriv, _FW_LINKED)) ; else if (pLed->bLedScanBlinkInProgress == false) { diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index b0f218b4ca2f..aaadd8d19df3 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -643,7 +643,7 @@ void mgt_dispatcher23a(struct rtw_adapter *padapter, switch (stype) { case IEEE80211_STYPE_AUTH: - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) ptable->func = &OnAuth23a; else ptable->func = &OnAuth23aClient23a; @@ -653,7 +653,7 @@ void mgt_dispatcher23a(struct rtw_adapter *padapter, _mgt_dispatcher23a(padapter, ptable, precv_frame); break; case IEEE80211_STYPE_PROBE_REQ: - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) _mgt_dispatcher23a(padapter, ptable, precv_frame); else _mgt_dispatcher23a(padapter, ptable, precv_frame); @@ -662,7 +662,7 @@ void mgt_dispatcher23a(struct rtw_adapter *padapter, _mgt_dispatcher23a(padapter, ptable, precv_frame); break; case IEEE80211_STYPE_ACTION: - /* if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) */ + /* if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) */ _mgt_dispatcher23a(padapter, ptable, precv_frame); break; default: @@ -1880,7 +1880,7 @@ OnDeAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) DBG_8723A("%s Reason code(%d)\n", __func__, reason); #ifdef CONFIG_8723AU_AP_MODE - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { struct sta_info *psta; struct sta_priv *pstapriv = &padapter->stapriv; diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index 8af8e572c73b..54d7bfc157b1 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -300,10 +300,10 @@ static u8 PS_RDY_CHECK(struct rtw_adapter * padapter) return false; if (check_fwstate(pmlmepriv, _FW_LINKED) == false || - check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true || - check_fwstate(pmlmepriv, WIFI_AP_STATE) == true || - check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true || - check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) + check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) || + check_fwstate(pmlmepriv, WIFI_AP_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) return false; if (pwrpriv->bInSuspend) return false; @@ -462,7 +462,7 @@ void LeaveAllPowerSaveMode23a(struct rtw_adapter *Adapter) u8 enqueue = 0; /* DBG_8723A("%s.....\n", __func__); */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) + if (check_fwstate(pmlmepriv, _FW_LINKED)) rtw_lps_ctrl_wk_cmd23a(Adapter, LPS_CTRL_LEAVE, enqueue); } @@ -589,7 +589,7 @@ int _rtw_pwr_wakeup23a(struct rtw_adapter *padapter, u32 ips_deffer_ms, const ch } /* I think this should be check in IPS, LPS, autosuspend functions... */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { ret = _SUCCESS; goto exit; } diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 24fa28848769..95e74552c36f 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -800,8 +800,8 @@ static int sta2sta_data_frame(struct rtw_adapter *adapter, - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { /* filter packets that SA is myself or multicast or broadcast */ if (ether_addr_equal(myhwaddr, pattrib->src)) { @@ -824,7 +824,7 @@ static int sta2sta_data_frame(struct rtw_adapter *adapter, } sta_addr = pattrib->src; - } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { + } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { /* For Station mode, sa and bssid should always be BSSID, and DA is my mac-address */ if (!ether_addr_equal(pattrib->bssid, pattrib->src)) { @@ -837,7 +837,7 @@ static int sta2sta_data_frame(struct rtw_adapter *adapter, sta_addr = pattrib->bssid; - } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { + } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { if (bmcast) { /* For AP mode, if DA == MCAST, then BSSID should be also MCAST */ if (!is_multicast_ether_addr(pattrib->bssid)) { @@ -854,7 +854,7 @@ static int sta2sta_data_frame(struct rtw_adapter *adapter, sta_addr = pattrib->src; } - } else if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) { + } else if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) { ether_addr_copy(pattrib->dst, hdr->addr1); ether_addr_copy(pattrib->src, hdr->addr2); ether_addr_copy(pattrib->bssid, hdr->addr3); @@ -901,9 +901,9 @@ int ap2sta_data_frame(struct rtw_adapter *adapter, - if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) && - (check_fwstate(pmlmepriv, _FW_LINKED) == true || - check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true)) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && + (check_fwstate(pmlmepriv, _FW_LINKED) || + check_fwstate(pmlmepriv, _FW_UNDER_LINKING))) { /* filter packets that SA is myself or multicast or broadcast */ if (ether_addr_equal(myhwaddr, pattrib->src)) { @@ -966,8 +966,8 @@ int ap2sta_data_frame(struct rtw_adapter *adapter, goto exit; } - } else if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) && - (check_fwstate(pmlmepriv, _FW_LINKED) == true)) { + } else if (check_fwstate(pmlmepriv, WIFI_MP_STATE) && + check_fwstate(pmlmepriv, _FW_LINKED)) { ether_addr_copy(pattrib->dst, hdr->addr1); ether_addr_copy(pattrib->src, hdr->addr2); ether_addr_copy(pattrib->bssid, hdr->addr3); @@ -985,7 +985,7 @@ int ap2sta_data_frame(struct rtw_adapter *adapter, ret = _FAIL; goto exit; } - } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { + } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { /* Special case */ ret = RTW_RX_HANDLED; goto exit; @@ -1029,7 +1029,7 @@ int sta2ap_data_frame(struct rtw_adapter *adapter, - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { /* For AP mode, RA = BSSID, TX = STA(SRC_ADDR), A3 = DST_ADDR */ if (!ether_addr_equal(pattrib->bssid, mybssid)) { ret = _FAIL; @@ -1589,7 +1589,7 @@ static int wlanhdr_to_ethhdr (struct recv_frame *precvframe) pattrib->hdrlen, pattrib->iv_len)); pattrib->eth_type = eth_type; - if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true)) { + if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) { ptr += hdrlen; *ptr = 0x87; *(ptr + 1) = 0x12; diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 90604941624c..cdd27c47f8fd 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -443,16 +443,14 @@ static int update_attrib(struct rtw_adapter *padapter, pattrib->pctrl = 0; - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { ether_addr_copy(pattrib->ra, pattrib->dst); ether_addr_copy(pattrib->ta, pattrib->src); - } - else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { + } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { ether_addr_copy(pattrib->ra, get_bssid(pmlmepriv)); ether_addr_copy(pattrib->ta, pattrib->src); - } - else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { ether_addr_copy(pattrib->ra, pattrib->dst); ether_addr_copy(pattrib->ta, get_bssid(pmlmepriv)); } @@ -510,7 +508,7 @@ static int update_attrib(struct rtw_adapter *padapter, MAC_FMT"\n", MAC_ARG(pattrib->ra))); res = _FAIL; goto exit; - } else if ((check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) && + } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) && (!(psta->state & _FW_LINKED))) { res = _FAIL; goto exit; @@ -897,7 +895,7 @@ static int rtw_make_wlanhdr(struct rtw_adapter *padapter, u8 *hdr, pwlanhdr->frame_control = cpu_to_le16(pattrib->type); if (pattrib->type & IEEE80211_FTYPE_DATA) { - if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true)) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { /* to_ds = 1, fr_ds = 0; */ /* Data transfer to AP */ pwlanhdr->frame_control |= @@ -909,8 +907,7 @@ static int rtw_make_wlanhdr(struct rtw_adapter *padapter, u8 *hdr, if (pmlmepriv->qos_option) qos_option = true; - } - else if ((check_fwstate(pmlmepriv, WIFI_AP_STATE) == true)) { + } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { /* to_ds = 0, fr_ds = 1; */ pwlanhdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_FROMDS); @@ -920,9 +917,8 @@ static int rtw_make_wlanhdr(struct rtw_adapter *padapter, u8 *hdr, if (psta->qos_option) qos_option = true; - } - else if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) { + } else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { ether_addr_copy(pwlanhdr->addr1, pattrib->dst); ether_addr_copy(pwlanhdr->addr2, pattrib->src); ether_addr_copy(pwlanhdr->addr3, get_bssid(pmlmepriv)); -- cgit v1.2.3 From a6ab752c3f2a0cc4ba667b06c4259dc9a843d35f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:05 +0200 Subject: staging: rtl8723au: Make check_fwstate() return bool Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtw_mlme.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index 1bb9e6cce796..1aafa26aff5b 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -332,7 +332,7 @@ static inline u8 *get_bssid(struct mlme_priv *pmlmepriv) return pmlmepriv->cur_network.network.MacAddress; } -static inline int check_fwstate(struct mlme_priv *pmlmepriv, int state) +static inline bool check_fwstate(struct mlme_priv *pmlmepriv, int state) { if (pmlmepriv->fw_state & state) return true; -- cgit v1.2.3 From 0618dbc637c8ae9e3e4ebff4632a23bb6cc97ad8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:06 +0200 Subject: staging: rtl8723au: Don't check check_fwstate() == false In addition, remove a followon check for false just after having checked for true. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ioctl_set.c | 3 +-- drivers/staging/rtl8723au/core/rtw_led.c | 17 ++++++----------- drivers/staging/rtl8723au/core/rtw_mlme.c | 6 +++--- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 2 +- drivers/staging/rtl8723au/core/rtw_recv.c | 3 +-- drivers/staging/rtl8723au/core/rtw_xmit.c | 4 ++-- 6 files changed, 14 insertions(+), 21 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c index ff740afffbb8..cf897c723f4a 100644 --- a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c @@ -187,8 +187,7 @@ int rtw_set_802_11_ssid23a(struct rtw_adapter* padapter, if ((pmlmepriv->assoc_ssid.ssid_len == ssid->ssid_len) && !memcmp(&pmlmepriv->assoc_ssid.ssid, ssid->ssid, ssid->ssid_len)) { - if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == false)) - { + if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("Set SSID is the same ssid, fw_state = 0x%08x\n", get_fwstate(pmlmepriv))); diff --git a/drivers/staging/rtl8723au/core/rtw_led.c b/drivers/staging/rtl8723au/core/rtw_led.c index c4337688b206..e21a42c5418f 100644 --- a/drivers/staging/rtl8723au/core/rtw_led.c +++ b/drivers/staging/rtl8723au/core/rtw_led.c @@ -234,7 +234,7 @@ static void SwLedBlink1(struct led_8723a *pLed) pLed->BlinkingLedState = RTW_LED_ON; delay = LED_BLINK_LINK_INTERVAL_ALPHA; RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } else if (check_fwstate(pmlmepriv, _FW_LINKED) == false) { + } else { pLed->bLedNoLinkBlinkInProgress = true; pLed->CurrLedState = LED_BLINK_SLOWLY; if (pLed->bLedOn) @@ -267,8 +267,7 @@ static void SwLedBlink1(struct led_8723a *pLed) pLed->BlinkingLedState = RTW_LED_ON; delay = LED_BLINK_LINK_INTERVAL_ALPHA; RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } else if (check_fwstate(pmlmepriv, - _FW_LINKED) == false) { + } else { pLed->bLedNoLinkBlinkInProgress = true; pLed->CurrLedState = LED_BLINK_SLOWLY; if (pLed->bLedOn) @@ -354,7 +353,7 @@ static void SwLedBlink2(struct led_8723a *pLed) RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop scan blink CurrLedState %d\n", pLed->CurrLedState)); - } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { + } else { pLed->CurrLedState = RTW_LED_OFF; pLed->BlinkingLedState = RTW_LED_OFF; SwLedOff23a(padapter, pLed); @@ -390,7 +389,7 @@ static void SwLedBlink2(struct led_8723a *pLed) RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop CurrLedState %d\n", pLed->CurrLedState)); - } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { + } else { pLed->CurrLedState = RTW_LED_OFF; pLed->BlinkingLedState = RTW_LED_OFF; SwLedOff23a(padapter, pLed); @@ -457,9 +456,7 @@ static void SwLedBlink3(struct led_8723a *pLed) SwLedOn23a(padapter, pLed); RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } - else if (check_fwstate(pmlmepriv, _FW_LINKED) == false) - { + } else { pLed->CurrLedState = RTW_LED_OFF; pLed->BlinkingLedState = RTW_LED_OFF; if (pLed->bLedOn) @@ -507,9 +504,7 @@ static void SwLedBlink3(struct led_8723a *pLed) SwLedOn23a(padapter, pLed); RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); - } - else if (check_fwstate(pmlmepriv, _FW_LINKED) == false) - { + } else { pLed->CurrLedState = RTW_LED_OFF; pLed->BlinkingLedState = RTW_LED_OFF; diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 148e11f2837b..547986ac0102 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -221,7 +221,7 @@ int rtw_if_up23a(struct rtw_adapter *padapter) int res; if (padapter->bDriverStopped || padapter->bSurpriseRemoved || - check_fwstate(&padapter->mlmepriv, _FW_LINKED) == false) { + !check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_if_up23a:bDriverStopped(%d) OR " "bSurpriseRemoved(%d)", padapter->bDriverStopped, @@ -682,7 +682,7 @@ void rtw_survey_event_cb23a(struct rtw_adapter *adapter, const u8 *pbuf) } /* lock pmlmepriv->lock when you accessing network_q */ - if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == false) { + if (!check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) { if (pnetwork->Ssid.ssid[0] == 0) pnetwork->Ssid.ssid_len = 0; @@ -730,7 +730,7 @@ rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf) if (pmlmepriv->to_join == true) { if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { - if (check_fwstate(pmlmepriv, _FW_LINKED) == false) { + if (!check_fwstate(pmlmepriv, _FW_LINKED)) { set_fwstate(pmlmepriv, _FW_UNDER_LINKING); if (rtw_select_and_join_from_scanned_queue23a( diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index 54d7bfc157b1..90359d1a0923 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -299,7 +299,7 @@ static u8 PS_RDY_CHECK(struct rtw_adapter * padapter) if (delta_time < LPS_DELAY_TIME) return false; - if (check_fwstate(pmlmepriv, _FW_LINKED) == false || + if (!check_fwstate(pmlmepriv, _FW_LINKED) || check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) || check_fwstate(pmlmepriv, WIFI_AP_STATE) || check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 95e74552c36f..f21aa20b9372 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -2379,8 +2379,7 @@ void rtw_signal_stat_timer_hdl23a(unsigned long data) } /* update value of signal_strength, rssi, signal_qual */ - if (check_fwstate(&adapter->mlmepriv, _FW_UNDER_SURVEY) == - false) { + if (!check_fwstate(&adapter->mlmepriv, _FW_UNDER_SURVEY)) { tmp_s = (avg_signal_strength + (_alpha - 1) * recvpriv->signal_strength); if (tmp_s %_alpha) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index cdd27c47f8fd..d0dc6386d237 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -560,7 +560,7 @@ static int update_attrib(struct rtw_adapter *padapter, pattrib->encrypt = 0; if ((pattrib->ether_type != ETH_P_PAE) && - (check_fwstate(pmlmepriv, WIFI_MP_STATE) == false)) { + !check_fwstate(pmlmepriv, WIFI_MP_STATE)) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("\npsta->ieee8021x_blocked == true, " "pattrib->ether_type(%.4x) != 0x888e\n", @@ -1968,7 +1968,7 @@ int xmitframe_enqueue_for_sleeping_sta23a(struct rtw_adapter *padapter, struct x struct mlme_priv *pmlmepriv = &padapter->mlmepriv; int bmcst = is_multicast_ether_addr(pattrib->ra); - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == false) + if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) return ret; if (pattrib->psta) { -- cgit v1.2.3 From 656f6c8c87c2b64ec67dec18ca79e3bec923fec5 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:07 +0200 Subject: staging: rtl8723au: Remove unused enum SCAN_RESULT_TYPE Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtw_mlme.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index 1aafa26aff5b..129c524578ca 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -83,13 +83,6 @@ enum { GHZ_24, }; -enum SCAN_RESULT_TYPE { - SCAN_RESULT_P2P_ONLY = 0, /* Will return all the P2P devices. */ - SCAN_RESULT_ALL = 1, /* Will return all the scanned device, include AP. */ - SCAN_RESULT_WFD_TYPE = 2 /* Will just return the correct WFD device. */ - /* If this device is Miracast sink device, it will just return all the Miracast source devices. */ -}; - /* there are several "locks" in mlme_priv, -- cgit v1.2.3 From e92843e3add3d11b02ea32cabe7ecd44c4753ae4 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:08 +0200 Subject: staging: rtl8723au: rtw_mlme.h: Remove a bunch of unused structs Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtw_mlme.h | 63 ---------------------------- 1 file changed, 63 deletions(-) diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index 129c524578ca..d601c554f3f5 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -97,16 +97,6 @@ To avoid possible dead lock, any thread trying to modifiying mlme_priv SHALL not lock up more than one locks at a time! */ -#define traffic_threshold 10 -#define traffic_scan_period 500 - -struct sitesurvey_ctrl { - u64 last_tx_pkts; - uint last_rx_pkts; - int traffic_busy; - struct timer_list sitesurvey_ctrl_timer; -}; - struct rt_link_detect { u32 NumTxOkInPeriod; u32 NumRxOkInPeriod; @@ -119,59 +109,6 @@ struct rt_link_detect { bool bHigherBusyTxTraffic; /* We may disable Tx interrupt according as Tx traffic. */ }; -struct profile_info { - u8 ssidlen; - u8 ssid[IEEE80211_MAX_SSID_LEN]; - u8 peermac[ETH_ALEN]; -}; - -struct tx_invite_req_info { - u8 token; - u8 benable; - u8 go_ssid[IEEE80211_MAX_SSID_LEN]; - u8 ssidlen; - u8 go_bssid[ETH_ALEN]; - u8 peer_macaddr[ETH_ALEN]; - u8 operating_ch; /* This information will be set by using the p2p_set op_ch = x */ - u8 peer_ch; /* The listen channel for peer P2P device */ - -}; - -struct tx_invite_resp_info { - u8 token; /* Used to record the dialog token of p2p invitation request frame. */ -}; - -struct tx_provdisc_req_info { - u16 wps_config_method_request; /* Used when sending the provisioning request frame */ - u16 peer_channel_num[2]; /* The channel number which the receiver stands. */ - struct cfg80211_ssid ssid; - u8 peerDevAddr[ETH_ALEN]; /* Peer device address */ - u8 peerIFAddr[ETH_ALEN]; /* Peer interface address */ - u8 benable; /* This provision discovery request frame is trigger to send or not */ -}; - -struct rx_provdisc_req_info { /* When peer device issue prov_disc_req first, we should store the following informations */ - u8 peerDevAddr[ETH_ALEN]; /* Peer device address */ - u8 strconfig_method_desc_of_prov_disc_req[4]; /* description for the config method located in the provisioning discovery request frame. */ - /* The UI must know this information to know which config method the remote p2p device is requiring. */ -}; - -struct tx_nego_req_info { - u16 peer_channel_num[2]; /* The channel number which the receiver stands. */ - u8 peerDevAddr[ETH_ALEN];/* Peer device address */ - u8 benable; /* This negoitation request frame is trigger to send or not */ -}; - -struct group_id_info { - u8 go_device_addr[ETH_ALEN]; /*The GO's device address of P2P group */ - u8 ssid[IEEE80211_MAX_SSID_LEN]; /* The SSID of this P2P group */ -}; - -struct scan_limit_info { - u8 scan_op_ch_only; /* When this flag is set, the driver should just scan the operation channel */ - u8 operation_ch[2]; /* Store the operation channel of invitation request frame */ -}; - struct mlme_priv { spinlock_t lock; int fw_state; -- cgit v1.2.3 From aaa1d6359b0732e5d31cecc39a998f54e3bc0af2 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:09 +0200 Subject: staging: rtl8723au: Remove unused struct hostapd_priv Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/drv_types.h | 4 ---- drivers/staging/rtl8723au/include/rtw_mlme.h | 10 ---------- 2 files changed, 14 deletions(-) diff --git a/drivers/staging/rtl8723au/include/drv_types.h b/drivers/staging/rtl8723au/include/drv_types.h index c3d633c4ec1e..49add5ffbb2b 100644 --- a/drivers/staging/rtl8723au/include/drv_types.h +++ b/drivers/staging/rtl8723au/include/drv_types.h @@ -229,10 +229,6 @@ struct rtw_adapter { struct eeprom_priv eeprompriv; struct led_priv ledpriv; -#ifdef CONFIG_8723AU_AP_MODE - struct hostapd_priv *phostapdpriv; -#endif - u32 setband; void *HalData; diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index d601c554f3f5..4d327ba775b0 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -225,16 +225,6 @@ struct mlme_priv { u32 wfd_go_probe_resp_ie_len; /* for GO */ }; -#ifdef CONFIG_8723AU_AP_MODE - -struct hostapd_priv { - struct rtw_adapter *padapter; -}; - -int hostapd_mode_init(struct rtw_adapter *padapter); -void hostapd_mode_unload(struct rtw_adapter *padapter); -#endif - void rtw_joinbss_event_prehandle23a(struct rtw_adapter *adapter, u8 *pbuf); void rtw_survey_event_cb23a(struct rtw_adapter *adapter, const u8 *pbuf); void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf); -- cgit v1.2.3 From 8b506ef18102fd1a30719d075e2be0efa1c2a920 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:10 +0200 Subject: staging: rtl8723au: Do not call netdev_open23a() from cfg80211_rtw_change_iface() Calling open on the device when changing the interface type is wrong. Let the stack call open at the right time. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index f75a82596243..2bcdbe10ae0f 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -1391,15 +1391,6 @@ static int cfg80211_rtw_change_iface(struct wiphy *wiphy, int ret = 0; DBG_8723A("%s(%s): call netdev_open23a\n", __func__, ndev->name); - if (netdev_open23a(ndev) != 0) { - ret = -EPERM; - goto exit; - } - - if (_FAIL == rtw_pwr_wakeup(padapter)) { - ret = -EPERM; - goto exit; - } old_type = rtw_wdev->iftype; DBG_8723A("%s(%s): old_iftype =%d, new_iftype =%d\n", -- cgit v1.2.3 From 888df442ef023adbca6536888eae65b2cd8ae295 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:11 +0200 Subject: staging: rtl8723au: ioctl_cfg80211.c: Use ether_addr_copy() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 25 ++++++++++++----------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 2bcdbe10ae0f..d183098dedcf 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -317,14 +317,14 @@ static int rtw_cfg80211_inform_bss(struct rtw_adapter *padapter, pwlanhdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON); } else { - memcpy(pwlanhdr->addr1, myid(&padapter->eeprompriv), ETH_ALEN); + ether_addr_copy(pwlanhdr->addr1, myid(&padapter->eeprompriv)); pwlanhdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); } - memcpy(pwlanhdr->addr2, pnetwork->network.MacAddress, ETH_ALEN); - memcpy(pwlanhdr->addr3, pnetwork->network.MacAddress, ETH_ALEN); + ether_addr_copy(pwlanhdr->addr2, pnetwork->network.MacAddress); + ether_addr_copy(pwlanhdr->addr3, pnetwork->network.MacAddress); pbuf += sizeof(struct ieee80211_hdr_3addr); len = sizeof(struct ieee80211_hdr_3addr); @@ -458,7 +458,7 @@ static int set_pairwise_key(struct rtw_adapter *padapter, struct sta_info *psta) psetstakey_para->algorithm = psta->dot118021XPrivacy; - memcpy(psetstakey_para->addr, psta->hwaddr, ETH_ALEN); + ether_addr_copy(psetstakey_para->addr, psta->hwaddr); memcpy(psetstakey_para->key, &psta->dot118021x_UncstKey, 16); @@ -1148,7 +1148,7 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev, } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { #ifdef CONFIG_8723AU_AP_MODE if (mac_addr) - memcpy(param->sta_addr, (void *)mac_addr, ETH_ALEN); + ether_addr_copy(param->sta_addr, mac_addr); ret = rtw_cfg80211_ap_set_encryption(ndev, param, param_len); #endif @@ -2340,8 +2340,9 @@ static int cfg80211_rtw_set_pmksa(struct wiphy *wiphy, DBG_8723A("%s(%s): Use new entry index = %d for this PMKID\n", __func__, netdev->name, psecuritypriv->PMKIDIndex); - memcpy(psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex]. - Bssid, pmksa->bssid, ETH_ALEN); + ether_addr_copy( + psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex]. + Bssid, pmksa->bssid); memcpy(psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex]. PMKID, pmksa->pmkid, WLAN_PMKID_LEN); @@ -2479,9 +2480,9 @@ void rtw_cfg80211_indicate_sta_disassoc(struct rtw_adapter *padapter, pwlanhdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DEAUTH); - memcpy(pwlanhdr->addr1, myid(&padapter->eeprompriv), ETH_ALEN); - memcpy(pwlanhdr->addr2, da, ETH_ALEN); - memcpy(pwlanhdr->addr3, get_my_bssid23a(&pmlmeinfo->network), ETH_ALEN); + ether_addr_copy(pwlanhdr->addr1, myid(&padapter->eeprompriv)); + ether_addr_copy(pwlanhdr->addr2, da); + ether_addr_copy(pwlanhdr->addr3, get_my_bssid23a(&pmlmeinfo->network)); pwlanhdr->seq_ctrl = cpu_to_le16(IEEE80211_SN_TO_SEQ(pmlmeext->mgnt_seq)); @@ -2575,8 +2576,8 @@ static int rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, skb_pull(skb, dot11_hdr_len + qos_len + snap_len - ETH_ALEN * 2); pdata = (unsigned char *)skb->data; - memcpy(pdata, dst_mac_addr, ETH_ALEN); - memcpy(pdata + ETH_ALEN, src_mac_addr, ETH_ALEN); + ether_addr_copy(pdata, dst_mac_addr); + ether_addr_copy(pdata + ETH_ALEN, src_mac_addr); DBG_8723A("should be eapol packet\n"); -- cgit v1.2.3 From cc2db7cb8de67cb172b90b72bf42c784b08959ad Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:12 +0200 Subject: staging: rtl8723au: ioctl_cfg80211.c: Use ether_addr_equal() ... and in one case use is_zero_ether_addr() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 25 +++++++++++------------ 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index d183098dedcf..b16a4161c072 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -1258,7 +1258,7 @@ static int cfg80211_rtw_get_station(struct wiphy *wiphy, check_fwstate(pmlmepriv, _FW_LINKED)) { struct wlan_network *cur_network = &pmlmepriv->cur_network; - if (memcmp(mac, cur_network->network.MacAddress, ETH_ALEN)) { + if (!ether_addr_equal(mac, cur_network->network.MacAddress)) { DBG_8723A("%s, mismatch bssid =" MAC_FMT "\n", __func__, MAC_ARG(cur_network->network.MacAddress)); ret = -ENOENT; @@ -2068,8 +2068,8 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, dst_bssid = pnetwork->network.MacAddress; if (sme->bssid) { - if (memcmp(pnetwork->network.MacAddress, - sme->bssid, ETH_ALEN)) + if (!ether_addr_equal(pnetwork->network.MacAddress, + sme->bssid)) continue; } @@ -2083,7 +2083,7 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, if (sme->bssid) { src_bssid = sme->bssid; - if ((!memcmp(dst_bssid, src_bssid, ETH_ALEN))) { + if (ether_addr_equal(dst_bssid, src_bssid)) { DBG_8723A("matched by bssid\n"); ndis_ssid.ssid_len = @@ -2307,20 +2307,18 @@ static int cfg80211_rtw_set_pmksa(struct wiphy *wiphy, u8 index, blInserted = false; struct rtw_adapter *padapter = wiphy_to_adapter(wiphy); struct security_priv *psecuritypriv = &padapter->securitypriv; - u8 strZeroMacAddress[ETH_ALEN] = { 0x00 }; DBG_8723A("%s(%s)\n", __func__, netdev->name); - if (!memcmp(pmksa->bssid, strZeroMacAddress, ETH_ALEN)) { + if (is_zero_ether_addr(pmksa->bssid)) return -EINVAL; - } blInserted = false; /* overwrite PMKID */ for (index = 0; index < NUM_PMKID_CACHE; index++) { - if (!memcmp(psecuritypriv->PMKIDList[index].Bssid, - pmksa->bssid, ETH_ALEN)) { + if (ether_addr_equal(psecuritypriv->PMKIDList[index].Bssid, + pmksa->bssid)) { /* BSSID is matched, the same AP => rewrite with new PMKID. */ DBG_8723A("%s(%s): BSSID exists in the PMKList.\n", @@ -2368,9 +2366,10 @@ static int cfg80211_rtw_del_pmksa(struct wiphy *wiphy, DBG_8723A("%s(%s)\n", __func__, netdev->name); for (index = 0; index < NUM_PMKID_CACHE; index++) { - if (!memcmp(psecuritypriv->PMKIDList[index].Bssid, - pmksa->bssid, ETH_ALEN)) { - /* BSSID is matched, the same AP => Remove this PMKID information and reset it. */ + if (ether_addr_equal(psecuritypriv->PMKIDList[index].Bssid, + pmksa->bssid)) { + /* BSSID is matched, the same AP => Remove this PMKID + information and reset it. */ eth_zero_addr(psecuritypriv->PMKIDList[index].Bssid); memset(psecuritypriv->PMKIDList[index].PMKID, 0x00, WLAN_PMKID_LEN); @@ -2961,7 +2960,7 @@ static int cfg80211_rtw_del_station(struct wiphy *wiphy, list_for_each_safe(plist, ptmp, phead) { psta = container_of(plist, struct sta_info, asoc_list); - if (!memcmp(mac, psta->hwaddr, ETH_ALEN)) { + if (ether_addr_equal(mac, psta->hwaddr)) { if (psta->dot8021xalg == 1 && psta->bpairwise_key_installed == false) { DBG_8723A("%s, sta's dot8021xalg = 1 and " -- cgit v1.2.3 From 58af40a9a4fb936e8832c0bbd56261a3287c04f8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:13 +0200 Subject: staging: rtl8723au: Delete unused rtw_cfg80211_set_mgnt_wpsp2pie() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/ioctl_cfg80211.h | 3 - drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 166 --------------------- 2 files changed, 169 deletions(-) diff --git a/drivers/staging/rtl8723au/include/ioctl_cfg80211.h b/drivers/staging/rtl8723au/include/ioctl_cfg80211.h index ed91ba0d24d4..d0d6bbc8b0f6 100644 --- a/drivers/staging/rtl8723au/include/ioctl_cfg80211.h +++ b/drivers/staging/rtl8723au/include/ioctl_cfg80211.h @@ -88,9 +88,6 @@ void rtw_cfg80211_issue_p2p_provision_request23a(struct rtw_adapter *padapter, void rtw_cfg80211_rx_action(struct rtw_adapter *adapter, u8 *frame, uint frame_len, const char*msg); -int rtw_cfg80211_set_mgnt_wpsp2pie(struct net_device *net, char *buf, int len, - int type); - bool rtw_cfg80211_pwr_mgmt(struct rtw_adapter *adapter); #define rtw_cfg80211_rx_mgmt(adapter, freq, sig_dbm, buf, len, gfp) \ diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index b16a4161c072..09e6e8180c76 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -3189,172 +3189,6 @@ static void cfg80211_rtw_mgmt_frame_register(struct wiphy *wiphy, return; } -static int rtw_cfg80211_set_beacon_wpsp2pie(struct net_device *ndev, char *buf, - int len) -{ - int ret = 0; - uint wps_ielen = 0; - u8 *wps_ie; -#ifdef CONFIG_8723AU_AP_MODE - u8 wps_oui[8] = { 0x0, 0x50, 0xf2, 0x04 }; -#endif - struct rtw_adapter *padapter = netdev_priv(ndev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - - DBG_8723A("%s(%s): ielen =%d\n", __func__, ndev->name, len); - - if (len > 0) { - wps_ie = rtw_get_wps_ie23a(buf, len, NULL, &wps_ielen); - if (wps_ie) { - DBG_8723A("bcn_wps_ielen =%d\n", wps_ielen); - - if (pmlmepriv->wps_beacon_ie) { - pmlmepriv->wps_beacon_ie_len = 0; - kfree(pmlmepriv->wps_beacon_ie); - pmlmepriv->wps_beacon_ie = NULL; - } - - pmlmepriv->wps_beacon_ie = kmemdup(wps_ie, wps_ielen, - GFP_KERNEL); - if (pmlmepriv->wps_beacon_ie == NULL) { - DBG_8723A("%s()-%d: kmalloc() ERROR!\n", - __func__, __LINE__); - return -EINVAL; - } - pmlmepriv->wps_beacon_ie_len = wps_ielen; - -#ifdef CONFIG_8723AU_AP_MODE - update_beacon23a(padapter, WLAN_EID_VENDOR_SPECIFIC, - wps_oui, true); -#endif - } - - pmlmeext->bstart_bss = true; - - } - - return ret; -} - -static int rtw_cfg80211_set_probe_resp_wpsp2pie(struct net_device *net, - char *buf, int len) -{ - struct rtw_adapter *padapter = netdev_priv(net); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - int ret = 0; - uint wps_ielen = 0; - u8 *wps_ie; - - if (len > 0) { - wps_ie = rtw_get_wps_ie23a(buf, len, NULL, &wps_ielen); - if (wps_ie) { - uint attr_contentlen = 0; - u16 uconfig_method, *puconfig_method = NULL; - - if (pmlmepriv->wps_probe_resp_ie) { - pmlmepriv->wps_probe_resp_ie_len = 0; - kfree(pmlmepriv->wps_probe_resp_ie); - pmlmepriv->wps_probe_resp_ie = NULL; - } - - pmlmepriv->wps_probe_resp_ie = - kmalloc(wps_ielen, GFP_KERNEL); - if (pmlmepriv->wps_probe_resp_ie == NULL) { - DBG_8723A("%s()-%d: kmalloc() ERROR!\n", - __func__, __LINE__); - return -EINVAL; - - } - - /* add PUSH_BUTTON config_method by driver self in - wpsie of probe_resp at GO Mode */ - puconfig_method = (u16 *)rtw_get_wps_attr_content23a(wps_ie, wps_ielen, - WPS_ATTR_CONF_METHOD, - NULL, - &attr_contentlen); - if (puconfig_method) { - uconfig_method = WPS_CM_PUSH_BUTTON; - uconfig_method = cpu_to_be16(uconfig_method); - - *puconfig_method |= uconfig_method; - } - - memcpy(pmlmepriv->wps_probe_resp_ie, wps_ie, wps_ielen); - pmlmepriv->wps_probe_resp_ie_len = wps_ielen; - - } - - } - - return ret; -} - -static int rtw_cfg80211_set_assoc_resp_wpsp2pie(struct net_device *net, - char *buf, int len) -{ - int ret = 0; - struct rtw_adapter *padapter = netdev_priv(net); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - DBG_8723A("%s, ielen =%d\n", __func__, len); - - if (len > 0) { - if (pmlmepriv->wps_assoc_resp_ie) { - pmlmepriv->wps_assoc_resp_ie_len = 0; - kfree(pmlmepriv->wps_assoc_resp_ie); - pmlmepriv->wps_assoc_resp_ie = NULL; - } - - pmlmepriv->wps_assoc_resp_ie = kmemdup(buf, len, GFP_KERNEL); - if (pmlmepriv->wps_assoc_resp_ie == NULL) { - DBG_8723A("%s()-%d: kmalloc() ERROR!\n", - __func__, __LINE__); - return -EINVAL; - - } - pmlmepriv->wps_assoc_resp_ie_len = len; - } - - return ret; -} - -int rtw_cfg80211_set_mgnt_wpsp2pie(struct net_device *net, char *buf, int len, - int type) -{ - int ret = 0; - uint wps_ielen = 0; - - DBG_8723A("%s, ielen =%d\n", __func__, len); - - if (rtw_get_wps_ie23a(buf, len, NULL, &wps_ielen) && (wps_ielen > 0)) { - if (net) { - switch (type) { - case 0x1: /* BEACON */ - ret = - rtw_cfg80211_set_beacon_wpsp2pie(net, buf, - len); - break; - case 0x2: /* PROBE_RESP */ - ret = - rtw_cfg80211_set_probe_resp_wpsp2pie(net, - buf, - len); - break; - case 0x4: /* ASSOC_RESP */ - ret = - rtw_cfg80211_set_assoc_resp_wpsp2pie(net, - buf, - len); - break; - } - } - } - - return ret; - -} - static struct cfg80211_ops rtw_cfg80211_ops = { .change_virtual_intf = cfg80211_rtw_change_iface, .add_key = cfg80211_rtw_add_key, -- cgit v1.2.3 From de62f67a00286eb78d44762ce845b00742d79dd0 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:14 +0200 Subject: staging: rtl8723au: _cfg80211_rtw_mgmt_tx() clean up checking function return values Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 09e6e8180c76..5f508ac765e2 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -3055,7 +3055,6 @@ static int _cfg80211_rtw_mgmt_tx(struct rtw_adapter *padapter, u8 tx_ch, struct pkt_attrib *pattrib; unsigned char *pframe; int ret = _FAIL; - bool ack = true; struct ieee80211_hdr *pwlanhdr; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -3079,7 +3078,7 @@ static int _cfg80211_rtw_mgmt_tx(struct rtw_adapter *padapter, u8 tx_ch, /* starting alloc mgmt frame to dump it */ pmgntframe = alloc_mgtxmitframe23a(pxmitpriv); - if (pmgntframe == NULL) { + if (!pmgntframe) { /* ret = -ENOMEM; */ ret = _FAIL; goto exit; @@ -3105,15 +3104,12 @@ static int _cfg80211_rtw_mgmt_tx(struct rtw_adapter *padapter, u8 tx_ch, pattrib->last_txcmdsz = pattrib->pktlen; - if (dump_mgntframe23a_and_wait_ack23a(padapter, pmgntframe) != _SUCCESS) { - ack = false; - ret = _FAIL; + ret = dump_mgntframe23a_and_wait_ack23a(padapter, pmgntframe); - DBG_8723A("%s, ack == _FAIL\n", __func__); - } else { - DBG_8723A("%s, ack =%d, ok!\n", __func__, ack); - ret = _SUCCESS; - } + if (ret != _SUCCESS) + DBG_8723A("%s, ack == false\n", __func__); + else + DBG_8723A("%s, ack == true\n", __func__); exit: -- cgit v1.2.3 From 015e425e06d08fdc042d6d69196d61932a214866 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:15 +0200 Subject: staging: rtl8723au: Get rid of unused struct rtw_wdev_invit_info Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/ioctl_cfg80211.h | 19 ------------------- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 1 - 2 files changed, 20 deletions(-) diff --git a/drivers/staging/rtl8723au/include/ioctl_cfg80211.h b/drivers/staging/rtl8723au/include/ioctl_cfg80211.h index d0d6bbc8b0f6..5fc710b0f410 100644 --- a/drivers/staging/rtl8723au/include/ioctl_cfg80211.h +++ b/drivers/staging/rtl8723au/include/ioctl_cfg80211.h @@ -15,23 +15,6 @@ #ifndef __IOCTL_CFG80211_H__ #define __IOCTL_CFG80211_H__ -struct rtw_wdev_invit_info { - u8 token; - u8 flags; - u8 status; - u8 req_op_ch; - u8 rsp_op_ch; -}; - -#define rtw_wdev_invit_info_init(invit_info) \ - do { \ - (invit_info)->token = 0; \ - (invit_info)->flags = 0x00; \ - (invit_info)->status = 0xff; \ - (invit_info)->req_op_ch = 0; \ - (invit_info)->rsp_op_ch = 0; \ - } while (0) - struct rtw_wdev_priv { struct wireless_dev *rtw_wdev; @@ -47,8 +30,6 @@ struct rtw_wdev_priv { u8 provdisc_req_issued; - struct rtw_wdev_invit_info invit_info; - bool block; bool power_mgmt; }; diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 5f508ac765e2..6b9bf16a76ea 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -3407,7 +3407,6 @@ int rtw_wdev_alloc(struct rtw_adapter *padapter, struct device *dev) pwdev_priv->p2p_enabled = false; pwdev_priv->provdisc_req_issued = false; - rtw_wdev_invit_info_init(&pwdev_priv->invit_info); if (padapter->registrypriv.power_mgnt != PS_MODE_ACTIVE) pwdev_priv->power_mgmt = true; -- cgit v1.2.3 From 661f70698b1339b4be6c00bb37d528ca0f5df83f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:16 +0200 Subject: staging: rtl8723au: struct rtw_wdev_priv: Remove some never 'true' variables Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/ioctl_cfg80211.h | 3 --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 7 ------- 2 files changed, 10 deletions(-) diff --git a/drivers/staging/rtl8723au/include/ioctl_cfg80211.h b/drivers/staging/rtl8723au/include/ioctl_cfg80211.h index 5fc710b0f410..e1eaf9c29e8a 100644 --- a/drivers/staging/rtl8723au/include/ioctl_cfg80211.h +++ b/drivers/staging/rtl8723au/include/ioctl_cfg80211.h @@ -28,9 +28,6 @@ struct rtw_wdev_priv { u8 p2p_enabled; - u8 provdisc_req_issued; - - bool block; bool power_mgmt; }; diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 6b9bf16a76ea..017ea44ee433 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -2012,12 +2012,6 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, DBG_8723A("privacy =%d, key =%p, key_len =%d, key_idx =%d\n", sme->privacy, sme->key, sme->key_len, sme->key_idx); - if (wdev_to_priv(padapter->rtw_wdev)->block) { - ret = -EBUSY; - DBG_8723A("%s wdev_priv.block is set\n", __func__); - goto exit; - } - if (_FAIL == rtw_pwr_wakeup(padapter)) { ret = -EPERM; goto exit; @@ -3406,7 +3400,6 @@ int rtw_wdev_alloc(struct rtw_adapter *padapter, struct device *dev) spin_lock_init(&pwdev_priv->scan_req_lock); pwdev_priv->p2p_enabled = false; - pwdev_priv->provdisc_req_issued = false; if (padapter->registrypriv.power_mgnt != PS_MODE_ACTIVE) pwdev_priv->power_mgmt = true; -- cgit v1.2.3 From 56b0bd91e0087e0b172aec022bdfb4fcd9de9194 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:17 +0200 Subject: staging: rtl8723au: Remove some pointless cfg80211_* wrapper macros Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/ioctl_cfg80211.h | 19 ------------------- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 15 ++++++++------- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/drivers/staging/rtl8723au/include/ioctl_cfg80211.h b/drivers/staging/rtl8723au/include/ioctl_cfg80211.h index e1eaf9c29e8a..256000f2bebd 100644 --- a/drivers/staging/rtl8723au/include/ioctl_cfg80211.h +++ b/drivers/staging/rtl8723au/include/ioctl_cfg80211.h @@ -68,23 +68,4 @@ void rtw_cfg80211_rx_action(struct rtw_adapter *adapter, u8 *frame, bool rtw_cfg80211_pwr_mgmt(struct rtw_adapter *adapter); -#define rtw_cfg80211_rx_mgmt(adapter, freq, sig_dbm, buf, len, gfp) \ - cfg80211_rx_mgmt((adapter)->rtw_wdev, freq, sig_dbm, buf, len, 0, gfp) - -#define rtw_cfg80211_send_rx_assoc(adapter, bss, buf, len) \ - cfg80211_send_rx_assoc((adapter)->pnetdev, bss, buf, len) - -#define rtw_cfg80211_mgmt_tx_status(adapter, cookie, buf, len, ack, gfp) \ - cfg80211_mgmt_tx_status((adapter)->rtw_wdev, cookie, buf, \ - len, ack, gfp) - -#define rtw_cfg80211_ready_on_channel(adapter, cookie, chan, \ - channel_type, duration, gfp) \ - cfg80211_ready_on_channel((adapter)->rtw_wdev, cookie, chan, \ - duration, gfp) -#define rtw_cfg80211_remain_on_channel_expired(adapter, cookie, chan, \ - chan_type, gfp) \ - cfg80211_remain_on_channel_expired((adapter)->rtw_wdev, \ - cookie, chan, gfp) - #endif /* __IOCTL_CFG80211_H__ */ diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 017ea44ee433..9f9f034fd5e6 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -2433,8 +2433,8 @@ void rtw_cfg80211_indicate_sta_assoc(struct rtw_adapter *padapter, freq = ieee80211_channel_to_frequency(channel, IEEE80211_BAND_5GHZ); - rtw_cfg80211_rx_mgmt(padapter, freq, 0, pmgmt_frame, frame_len, - GFP_ATOMIC); + cfg80211_rx_mgmt(padapter->rtw_wdev, freq, 0, pmgmt_frame, frame_len, + 0, GFP_ATOMIC); #endif /* defined(RTW_USE_CFG80211_STA_EVENT) */ } @@ -2489,8 +2489,8 @@ void rtw_cfg80211_indicate_sta_disassoc(struct rtw_adapter *padapter, WLAN_REASON_PREV_AUTH_NOT_VALID, (unsigned char *)&reason, &frame_len); - rtw_cfg80211_rx_mgmt(padapter, freq, 0, mgmt_buf, frame_len, - GFP_ATOMIC); + cfg80211_rx_mgmt(padapter->rtw_wdev, freq, 0, mgmt_buf, frame_len, + 0, GFP_ATOMIC); #endif /* defined(RTW_USE_CFG80211_STA_EVENT) */ } @@ -3039,7 +3039,8 @@ void rtw_cfg80211_rx_action(struct rtw_adapter *adapter, u8 *frame, freq = ieee80211_channel_to_frequency(channel, IEEE80211_BAND_5GHZ); - rtw_cfg80211_rx_mgmt(adapter, freq, 0, frame, frame_len, GFP_ATOMIC); + cfg80211_rx_mgmt(adapter->rtw_wdev, freq, 0, frame, frame_len, + 0, GFP_ATOMIC); } static int _cfg80211_rtw_mgmt_tx(struct rtw_adapter *padapter, u8 tx_ch, @@ -3141,8 +3142,8 @@ static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, padapter->pnetdev->name, len, tx_ch); /* indicate ack before issue frame to avoid racing with rsp frame */ - rtw_cfg80211_mgmt_tx_status(padapter, *cookie, buf, len, ack, - GFP_KERNEL); + cfg80211_mgmt_tx_status(padapter->rtw_wdev, *cookie, buf, len, ack, + GFP_KERNEL); DBG_8723A("RTW_Tx:tx_ch =%d, da =" MAC_FMT "\n", tx_ch, MAC_ARG(hdr->da)); -- cgit v1.2.3 From d165e4efbc6d76cff51abb523567a840cb6623b9 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:18 +0200 Subject: staging: rtl8723au: rtw_wdev_alloc(): Don't register wiphy before kmalloc() completed There is no point starting to register the wiphy and then having to unregister it again if the followon kmalloc() fails. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 9f9f034fd5e6..4528c95b8e67 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -3367,22 +3367,24 @@ int rtw_wdev_alloc(struct rtw_adapter *padapter, struct device *dev) ret = -ENOMEM; goto exit; } + + /* wdev */ + wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL); + if (!wdev) { + DBG_8723A("Couldn't allocate wireless device\n"); + ret = -ENOMEM; + goto free_wiphy; + } + set_wiphy_dev(wiphy, dev); rtw_cfg80211_preinit_wiphy(padapter, wiphy); ret = wiphy_register(wiphy); if (ret < 0) { DBG_8723A("Couldn't register wiphy device\n"); - goto free_wiphy; + goto free_wdev; } - /* wdev */ - wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL); - if (!wdev) { - DBG_8723A("Couldn't allocate wireless device\n"); - ret = -ENOMEM; - goto unregister_wiphy; - } wdev->wiphy = wiphy; wdev->netdev = pnetdev; /* wdev->iftype = NL80211_IFTYPE_STATION; */ @@ -3408,8 +3410,8 @@ int rtw_wdev_alloc(struct rtw_adapter *padapter, struct device *dev) pwdev_priv->power_mgmt = false; return ret; -unregister_wiphy: - wiphy_unregister(wiphy); +free_wdev: + kfree(wdev); free_wiphy: wiphy_free(wiphy); exit: -- cgit v1.2.3 From e6d880db3ca183cf223ccf8e477b37297371ab67 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:19 +0200 Subject: staging: rtl8723au: Remove unused prototype rtw_cfg80211_issue_p2p_provision_request23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/ioctl_cfg80211.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8723au/include/ioctl_cfg80211.h b/drivers/staging/rtl8723au/include/ioctl_cfg80211.h index 256000f2bebd..63e921f921d3 100644 --- a/drivers/staging/rtl8723au/include/ioctl_cfg80211.h +++ b/drivers/staging/rtl8723au/include/ioctl_cfg80211.h @@ -61,8 +61,6 @@ void rtw_cfg80211_indicate_sta_disassoc(struct rtw_adapter *padapter, unsigned char *da, unsigned short reason); #endif /* CONFIG_8723AU_AP_MODE */ -void rtw_cfg80211_issue_p2p_provision_request23a(struct rtw_adapter *padapter, - const u8 *buf, size_t len); void rtw_cfg80211_rx_action(struct rtw_adapter *adapter, u8 *frame, uint frame_len, const char*msg); -- cgit v1.2.3 From 32dfcb1bf22a04251de857adc70666266c08731c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:20 +0200 Subject: staging: rtl8723au: bInternalAutoSuspend is always false Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 13 ++----------- drivers/staging/rtl8723au/include/rtw_pwrctrl.h | 1 - drivers/staging/rtl8723au/os_dep/os_intfs.c | 4 ---- drivers/staging/rtl8723au/os_dep/usb_intf.c | 11 +++-------- 4 files changed, 5 insertions(+), 24 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index 90359d1a0923..86ce51f849e9 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -481,7 +481,6 @@ void rtw_init_pwrctrl_priv23a(struct rtw_adapter *padapter) pwrctrlpriv->pwr_state_check_interval = RTW_PWR_STATE_CHK_INTERVAL; pwrctrlpriv->pwr_state_check_cnts = 0; - pwrctrlpriv->bInternalAutoSuspend = false; pwrctrlpriv->bInSuspend = false; pwrctrlpriv->bkeepfwalive = false; @@ -562,7 +561,7 @@ int _rtw_pwr_wakeup23a(struct rtw_adapter *padapter, u32 ips_deffer_ms, const ch DBG_8723A("%s wait sreset_inprogress done\n", __func__); } - if (pwrpriv->bInternalAutoSuspend == false && pwrpriv->bInSuspend) { + if (pwrpriv->bInSuspend) { DBG_8723A("%s wait bInSuspend...\n", __func__); while (pwrpriv->bInSuspend && (jiffies_to_msecs(jiffies - start) <= 3000)) { @@ -575,15 +574,7 @@ int _rtw_pwr_wakeup23a(struct rtw_adapter *padapter, u32 ips_deffer_ms, const ch } /* System suspend is not allowed to wakeup */ - if (pwrpriv->bInternalAutoSuspend == false && - pwrpriv->bInSuspend == true) { - ret = _FAIL; - goto exit; - } - - /* block??? */ - if (pwrpriv->bInternalAutoSuspend == true && - padapter->net_closed == true) { + if (pwrpriv->bInSuspend) { ret = _FAIL; goto exit; } diff --git a/drivers/staging/rtl8723au/include/rtw_pwrctrl.h b/drivers/staging/rtl8723au/include/rtw_pwrctrl.h index 44a7d4f97e09..a458af978145 100644 --- a/drivers/staging/rtl8723au/include/rtw_pwrctrl.h +++ b/drivers/staging/rtl8723au/include/rtw_pwrctrl.h @@ -191,7 +191,6 @@ struct pwrctrl_priv { s32 pnp_current_pwr_state; u8 pnp_bstop_trx; - u8 bInternalAutoSuspend; u8 bInSuspend; #ifdef CONFIG_8723AU_BT_COEXIST u8 bAutoResume; diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index d572f643ba59..5b27eb4474ba 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -835,10 +835,6 @@ static int netdev_close(struct net_device *pnetdev) RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+871x_drv - drv_close\n")); - if (padapter->pwrctrlpriv.bInternalAutoSuspend) { - if (padapter->pwrctrlpriv.rf_pwrstate == rf_off) - padapter->pwrctrlpriv.ps_flag = true; - } padapter->net_closed = true; if (padapter->pwrctrlpriv.rf_pwrstate == rf_on) { diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index f78be19aa333..8b25c1aa2025 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -314,8 +314,7 @@ static void rtw_dev_unload(struct rtw_adapter *padapter) rtl8723a_usb_intf_stop(padapter); /* s4. */ - if (!padapter->pwrctrlpriv.bInternalAutoSuspend) - flush_workqueue(padapter->cmdpriv.wq); + flush_workqueue(padapter->cmdpriv.wq); /* s5. */ if (!padapter->bSurpriseRemoved) { @@ -505,13 +504,9 @@ static int rtw_resume(struct usb_interface *pusb_intf) { struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf); struct rtw_adapter *padapter = dvobj->if1; - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - int ret = 0; + int ret; - if (pwrpriv->bInternalAutoSuspend) - ret = rtw_resume_process23a(padapter); - else - ret = rtw_resume_process23a(padapter); + ret = rtw_resume_process23a(padapter); return ret; } -- cgit v1.2.3 From 9160518e252a1358b333c484325adc2de7b76979 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:21 +0200 Subject: staging: rtl8723au: _rtw_pwr_wakeup23a(): Do not mix _FAIL/false as return value Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index 86ce51f849e9..937bbbcaa1bc 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -600,7 +600,7 @@ int _rtw_pwr_wakeup23a(struct rtw_adapter *padapter, u32 ips_deffer_ms, const ch DBG_8723A("%s: bDriverStopped =%d, bup =%d, hw_init_completed " "=%u\n", caller, padapter->bDriverStopped, padapter->bup, padapter->hw_init_completed); - ret = false; + ret = _FAIL; goto exit; } -- cgit v1.2.3 From 983ebef5c9cca4c8ca2171d976525ab57621ec76 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:22 +0200 Subject: staging: rtl8723au: PS_RDY_CHECK() return bools in 'bool' Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index 937bbbcaa1bc..79cc729cdae6 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -288,7 +288,7 @@ void rtw_set_rpwm23a(struct rtw_adapter *padapter, u8 pslv) pwrpriv->cpwm = pslv; } -static u8 PS_RDY_CHECK(struct rtw_adapter * padapter) +static bool PS_RDY_CHECK(struct rtw_adapter * padapter) { unsigned long delta_time; struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; -- cgit v1.2.3 From 3a159d9acc2ad4938d82fb9fc166f6f00fd26fe9 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:23 +0200 Subject: staging: rtl8723au: Create rtl8723au_bt_intf.h Use this header for declaring functions that are currently #ifdef'ed out in the general code. Start by moving BTDM_1Ant8723A() there and renaming it appropriately. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 10 ++++---- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 6 ++--- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 2 +- drivers/staging/rtl8723au/hal/hal_com.c | 2 +- .../staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 8 +++--- .../rtl8723au/include/rtl8723a_bt-coexist.h | 2 -- .../staging/rtl8723au/include/rtl8723a_bt_intf.h | 30 ++++++++++++++++++++++ drivers/staging/rtl8723au/include/rtl8723a_hal.h | 1 + 8 files changed, 45 insertions(+), 16 deletions(-) create mode 100644 drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 1768a94f8f79..db97ffb989c1 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -991,7 +991,7 @@ static void traffic_status_watchdog(struct rtw_adapter *padapter) } #ifdef CONFIG_8723AU_BT_COEXIST - if (BT_1Ant(padapter) == false) + if (rtl8723a_BT_using_antenna_1(padapter) == false) #endif { /* check traffic for powersaving. */ @@ -1064,7 +1064,7 @@ static void lps_ctrl_wk_hdl(struct rtw_adapter *padapter, u8 lps_ctrl_type) case LPS_CTRL_SCAN: #ifdef CONFIG_8723AU_BT_COEXIST BT_WifiScanNotify(padapter, true); - if (BT_1Ant(padapter) == false) + if (rtl8723a_BT_using_antenna_1(padapter) == false) #endif { if (check_fwstate(pmlmepriv, _FW_LINKED)) @@ -1087,7 +1087,7 @@ static void lps_ctrl_wk_hdl(struct rtw_adapter *padapter, u8 lps_ctrl_type) mstatus = 0;/* disconnect */ #ifdef CONFIG_8723AU_BT_COEXIST BT_WifiMediaStatusNotify(padapter, mstatus); - if (BT_1Ant(padapter) == false) + if (rtl8723a_BT_using_antenna_1(padapter) == false) #endif { LPS_Leave23a(padapter); @@ -1098,7 +1098,7 @@ static void lps_ctrl_wk_hdl(struct rtw_adapter *padapter, u8 lps_ctrl_type) pwrpriv->DelayLPSLastTimeStamp = jiffies; #ifdef CONFIG_8723AU_BT_COEXIST BT_SpecialPacketNotify(padapter); - if (BT_1Ant(padapter) == false) + if (rtl8723a_BT_using_antenna_1(padapter) == false) #endif { LPS_Leave23a(padapter); @@ -1107,7 +1107,7 @@ static void lps_ctrl_wk_hdl(struct rtw_adapter *padapter, u8 lps_ctrl_type) case LPS_CTRL_LEAVE: #ifdef CONFIG_8723AU_BT_COEXIST BT_LpsLeave(padapter); - if (BT_1Ant(padapter) == false) + if (rtl8723a_BT_using_antenna_1(padapter) == false) #endif { LPS_Leave23a(padapter); diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index aaadd8d19df3..def329923fb4 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -3479,7 +3479,7 @@ static void issue_assocreq(struct rtw_adapter *padapter) cpu_to_le16(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info); #ifdef CONFIG_8723AU_BT_COEXIST - if (BT_1Ant(padapter) == true) { + if (rtl8723a_BT_using_antenna_1(padapter)) { /* set to 8K */ pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para &= (u8)~IEEE80211_HT_AMPDU_PARM_FACTOR; /* pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para |= MAX_AMPDU_FACTOR_8K */ @@ -4038,7 +4038,7 @@ void issue_action_BA23a(struct rtw_adapter *padapter, &pattrib->pktlen); #ifdef CONFIG_8723AU_BT_COEXIST - if ((BT_1Ant(padapter) == true) && + if (rtl8723a_BT_using_antenna_1(padapter) && ((pmlmeinfo->assoc_AP_vendor != broadcomAP) || memcmp(raddr, tendaAPMac, 3))) { /* A-MSDU NOT Supported */ @@ -4105,7 +4105,7 @@ void issue_action_BA23a(struct rtw_adapter *padapter, BA_para_set = ((le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x1000); /* 64 buffer size */ #ifdef CONFIG_8723AU_BT_COEXIST - if ((BT_1Ant(padapter) == true) && + if (rtl8723a_BT_using_antenna_1(padapter) && ((pmlmeinfo->assoc_AP_vendor != broadcomAP) || memcmp(raddr, tendaAPMac, 3))) { /* max buffer size is 8 MSDU */ diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index 79cc729cdae6..f4e32d9efb8b 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -352,7 +352,7 @@ void rtw_set_ps_mode23a(struct rtw_adapter *padapter, u8 ps_mode, } else { if (PS_RDY_CHECK(padapter) #ifdef CONFIG_8723AU_BT_COEXIST - || (BT_1Ant(padapter) == true) + || (rtl8723a_BT_using_antenna_1(padapter)) #endif ) { DBG_8723A("%s: Enter 802.11 power save\n", __func__); diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index d2ee240496cc..dc4dfe9626c9 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -457,7 +457,7 @@ void rtl8723a_set_ampdu_factor(struct rtw_adapter *padapter, u8 FactorToSet) pRegToSet = RegToSet_Normal; /* 0xb972a841; */ #ifdef CONFIG_8723AU_BT_COEXIST if ((BT_IsBtDisabled(padapter) == false) && - (BT_1Ant(padapter) == true)) { + rtl8723a_BT_using_antenna_1(padapter)) { MaxAggNum = 0x8; } else #endif /* CONFIG_8723AU_BT_COEXIST */ diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index a0ab7abf67c8..4c4f0bf12605 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -9262,7 +9262,7 @@ void BTDM_SetFw3a( { u8 H2C_Parameter[5] = {0}; - if (BTDM_1Ant8723A(padapter)) { + if (rtl8723a_BT_using_antenna_1(padapter)) { if ((!check_fwstate(&padapter->mlmepriv, WIFI_STATION_STATE)) && (get_fwstate(&padapter->mlmepriv) != WIFI_NULL_STATE)) { /* for softap mode */ @@ -9818,7 +9818,7 @@ static void BTDM_ForDhcp8723A(struct rtw_adapter *padapter) BTDM_1AntForDhcp(padapter); } -u8 BTDM_1Ant8723A(struct rtw_adapter *padapter) +bool rtl8723a_BT_using_antenna_1(struct rtw_adapter *padapter) { if (btdm_BtWifiAntNum(padapter) == Ant_x1) return true; @@ -10572,7 +10572,7 @@ u8 BTDM_DisableEDCATurbo(struct rtw_adapter *padapter) return bRet; } - if (BT_1Ant(padapter)) { + if (rtl8723a_BT_using_antenna_1(padapter)) { bRet = false; pHalData->bt_coexist.lastBtEdca = 0; return bRet; @@ -10750,7 +10750,7 @@ void BTDM_TurnOffBtCoexistBeforeEnterIPS(struct rtw_adapter *padapter) return; /* 8723 1Ant doesn't need to turn off bt coexist mechanism. */ - if (BTDM_1Ant8723A(padapter)) + if (rtl8723a_BT_using_antenna_1(padapter)) return; /* Before enter IPS, turn off FW BT Co-exist mechanism */ diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h index 615101918865..bb6790713b7e 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h @@ -1330,8 +1330,6 @@ void BTDM_SetSwPenaltyTxRateAdaptive(struct rtw_adapter * padapter, u8 raType); void BTDM_SetFwDecBtPwr(struct rtw_adapter * padapter, u8 bDecBtPwr); u8 BTDM_BtProfileSupport(struct rtw_adapter * padapter); void BTDM_LpsLeave(struct rtw_adapter * padapter); -u8 BTDM_1Ant8723A(struct rtw_adapter * padapter); -#define BT_1Ant BTDM_1Ant8723A /* ===== End of sync from SD7 driver HAL/BTCoexist/HalBtc8723.h ===== */ diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h new file mode 100644 index 000000000000..66a3f1843545 --- /dev/null +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h @@ -0,0 +1,30 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * Copyright(c) 2014, Jes Sorensen + * + * 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. + * + ******************************************************************************/ +#ifndef __RTL8723A_BT_INTF_H__ +#define __RTL8723A_BT_INTF_H__ + +#include + +#ifdef CONFIG_8723AU_BT_COEXIST +bool rtl8723a_BT_using_antenna_1(struct rtw_adapter *padapter); +#else +static inline bool rtl8723a_BT_using_antenna_1(struct rtw_adapter *padapter) +{ + return false; +} +#endif + +#endif diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index 2dc7c93df62e..33ad2b7ee69e 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -20,6 +20,7 @@ #include "Hal8723APhyReg.h" #include "Hal8723APhyCfg.h" #include "rtl8723a_rf.h" +#include "rtl8723a_bt_intf.h" #ifdef CONFIG_8723AU_BT_COEXIST #include "rtl8723a_bt-coexist.h" #endif -- cgit v1.2.3 From bf2a7b99516d716fb06fbdd03e5d477b8c8a5cd1 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:24 +0200 Subject: staging: rtl8723au: Convert BT_IsBtDisabled() into rtl8723a_BT_enabled() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_com.c | 11 ++++------- .../staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 22 +++++++++++----------- .../rtl8723au/include/rtl8723a_bt-coexist.h | 2 -- .../staging/rtl8723au/include/rtl8723a_bt_intf.h | 5 +++++ 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index dc4dfe9626c9..09e888aaef71 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -455,15 +455,12 @@ void rtl8723a_set_ampdu_factor(struct rtw_adapter *padapter, u8 FactorToSet) u8 index = 0; pRegToSet = RegToSet_Normal; /* 0xb972a841; */ -#ifdef CONFIG_8723AU_BT_COEXIST - if ((BT_IsBtDisabled(padapter) == false) && - rtl8723a_BT_using_antenna_1(padapter)) { + + if (rtl8723a_BT_enabled(padapter) && + rtl8723a_BT_using_antenna_1(padapter)) MaxAggNum = 0x8; - } else -#endif /* CONFIG_8723AU_BT_COEXIST */ - { + else MaxAggNum = 0xF; - } if (FactorToSet <= 3) { FactorToSet = (1 << (FactorToSet + 2)); diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index 4c4f0bf12605..b28dc1ae9047 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -5519,7 +5519,7 @@ _btdm_1AntSetPSTDMA(struct rtw_adapter *padapter, u8 bPSEn, u8 smartps, if (!bTDMAOn) { btdm_1AntPsTdma(padapter, false, tdmaType); } else { - if ((BT_IsBtDisabled(padapter)) || + if (!rtl8723a_BT_enabled(padapter) || (pHalData->bt_coexist.halCoex8723.c2hBtInfo == BT_INFO_STATE_NO_CONNECTION) || (pHalData->bt_coexist.halCoex8723.c2hBtInfo == BT_INFO_STATE_CONNECT_IDLE) || (tdmaType == 29)) @@ -6064,7 +6064,7 @@ static void btdm_1AntBtCoexistHandler(struct rtw_adapter *padapter) pBtCoex8723 = &pHalData->bt_coexist.halCoex8723; pBtdm8723 = &pBtCoex8723->btdm1Ant; padapter->pwrctrlpriv.btcoex_rfon = false; - if (BT_IsBtDisabled(padapter)) { + if (!rtl8723a_BT_enabled(padapter)) { RTPRINT(FBT, BT_TRACE, ("[BTCoex], BT is disabled\n")); if (BTDM_IsWifiConnectionExist(padapter)) { @@ -6243,7 +6243,7 @@ static void BTDM_1AntWifiAssociateNotify(struct rtw_adapter *padapter, u8 type) if (type) { rtl8723a_CheckAntenna_Selection(padapter); - if (BT_IsBtDisabled(padapter)) + if (!rtl8723a_BT_enabled(padapter)) btdm_1AntSetPSTDMA(padapter, false, 0, false, 9); else { struct bt_coexist_8723a *pBtCoex; @@ -6275,7 +6275,7 @@ static void BTDM_1AntWifiAssociateNotify(struct rtw_adapter *padapter, u8 type) } } } else { - if (BT_IsBtDisabled(padapter)) { + if (!rtl8723a_BT_enabled(padapter)) { if (!BTDM_IsWifiConnectionExist(padapter)) { btdm_1AntPsTdma(padapter, false, 0); btdm_1AntTSFSwitch(padapter, false); @@ -6360,7 +6360,7 @@ static void BTDM_1AntWifiScanNotify(struct rtw_adapter *padapter, u8 scanType) if (scanType) { rtl8723a_CheckAntenna_Selection(padapter); - if (BT_IsBtDisabled(padapter)) { + if (!rtl8723a_BT_enabled(padapter)) { btdm_1AntSetPSTDMA(padapter, false, 0, false, 9); } else if (BTDM_IsWifiConnectionExist(padapter) == false) { BTDM_1AntWifiAssociateNotify(padapter, true); @@ -9306,7 +9306,7 @@ void BTDM_QueryBtInformation(struct rtw_adapter *padapter) pHalData = GET_HAL_DATA(padapter); pBtCoex = &pHalData->bt_coexist.halCoex8723; - if (BT_IsBtDisabled(padapter)) { + if (!rtl8723a_BT_enabled(padapter)) { pBtCoex->c2hBtInfo = BT_INFO_STATE_DISABLED; pBtCoex->bC2hBtInfoReqSent = false; return; @@ -9851,7 +9851,7 @@ static void BTDM_BTCoexist8723A(struct rtw_adapter *padapter) } if (pBtCoex->bC2hBtInfoReqSent) { - if (BT_IsBtDisabled(padapter)) { + if (!rtl8723a_BT_enabled(padapter)) { pBtCoex->c2hBtInfo = BT_INFO_STATE_DISABLED; } else { if (pBtCoex->c2hBtInfo == BT_INFO_STATE_DISABLED) @@ -9859,7 +9859,7 @@ static void BTDM_BTCoexist8723A(struct rtw_adapter *padapter) } btdm_BTCoexist8723AHandler(padapter); - } else if (BT_IsBtDisabled(padapter) == true) { + } else if (!rtl8723a_BT_enabled(padapter)) { pBtCoex->c2hBtInfo = BT_INFO_STATE_DISABLED; btdm_BTCoexist8723AHandler(padapter); } @@ -11236,14 +11236,14 @@ u8 BTDM_IsActionPANA2DP(struct rtw_adapter *padapter) return bRet; } -u8 BTDM_IsBtDisabled(struct rtw_adapter *padapter) +bool rtl8723a_BT_enabled(struct rtw_adapter *padapter) { struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); if (pHalData->bt_coexist.bCurBtDisabled) - return true; - else return false; + else + return true; } /* ===== End of sync from SD7 driver HAL/BTCoexist/HalBtCoexist.c ===== */ diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h index bb6790713b7e..d8a324484b55 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h @@ -1601,8 +1601,6 @@ u8 BTDM_IsActionPAN(struct rtw_adapter * padapter); u8 BTDM_IsActionHIDA2DP(struct rtw_adapter * padapter); u8 BTDM_IsActionHIDPAN(struct rtw_adapter * padapter); u8 BTDM_IsActionPANA2DP(struct rtw_adapter * padapter); -u8 BTDM_IsBtDisabled(struct rtw_adapter * padapter); -#define BT_IsBtDisabled BTDM_IsBtDisabled u32 BTDM_BtTxRxCounterH(struct rtw_adapter * padapter); u32 BTDM_BtTxRxCounterL(struct rtw_adapter * padapter); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h index 66a3f1843545..653af15d5ec3 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h @@ -20,11 +20,16 @@ #ifdef CONFIG_8723AU_BT_COEXIST bool rtl8723a_BT_using_antenna_1(struct rtw_adapter *padapter); +bool rtl8723a_BT_enabled(struct rtw_adapter *padapter); #else static inline bool rtl8723a_BT_using_antenna_1(struct rtw_adapter *padapter) { return false; } +static inline bool rtl8723a_BT_enabled(struct rtw_adapter *padapter) +{ + return false; +} #endif #endif -- cgit v1.2.3 From 1af4072b441862eab7274a45fe300d99eeb88dce Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:25 +0200 Subject: staging: rtl8723au: Introduce rtl8723a_BT_coexist() - and use it! Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 39 +++++++++------------- .../staging/rtl8723au/include/rtl8723a_bt_intf.h | 5 +++ 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index b28dc1ae9047..9326e0548489 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -9484,7 +9484,7 @@ static void BTDM_Display8723ABtCoexInfo(struct rtw_adapter *padapter) rsprintf(btCoexDbgBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============"); DCMD_Printf(btCoexDbgBuf); - if (!pHalData->bt_coexist.BluetoothCoexist) { + if (!rtl8723a_BT_coexist(padapter)) { rsprintf(btCoexDbgBuf, BT_TMP_BUF_SIZE, "\r\n BT not exists !!!"); DCMD_Printf(btCoexDbgBuf); return; @@ -9930,7 +9930,7 @@ void BTDM_CheckBTIdleChange1Ant(struct rtw_adapter *padapter) u32 BT_Active, BT_State; u32 regBTActive = 0, regBTState = 0, regBTPolling = 0; - if (!pHalData->bt_coexist.BluetoothCoexist) + if (!rtl8723a_BT_coexist(padapter)) return; if (pBtMgnt->ExtConfig.bManualControl) return; @@ -10560,7 +10560,7 @@ u8 BTDM_DisableEDCATurbo(struct rtw_adapter *padapter) pHalData = GET_HAL_DATA(padapter); pBtMgnt = &pHalData->BtInfo.BtMgnt; - if (!pHalData->bt_coexist.BluetoothCoexist) { + if (!rtl8723a_BT_coexist(padapter)) { bRet = false; pHalData->bt_coexist.lastBtEdca = 0; return bRet; @@ -10743,10 +10743,9 @@ void BTDM_CoexAllOff(struct rtw_adapter *padapter) void BTDM_TurnOffBtCoexistBeforeEnterIPS(struct rtw_adapter *padapter) { - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); struct pwrctrl_priv *ppwrctrl = &padapter->pwrctrlpriv; - if (!pHalData->bt_coexist.BluetoothCoexist) + if (!rtl8723a_BT_coexist(padapter)) return; /* 8723 1Ant doesn't need to turn off bt coexist mechanism. */ @@ -10771,7 +10770,7 @@ void BTDM_Coexist(struct rtw_adapter *padapter) { struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - if (!pHalData->bt_coexist.BluetoothCoexist) { + if (!rtl8723a_BT_coexist(padapter)) { RTPRINT(FBT, BT_TRACE, ("[DM][BT], BT not exists!!\n")); return; } @@ -10981,9 +10980,7 @@ void BTDM_SetBtCoexCurrAntNum(struct rtw_adapter *padapter, u8 antNum) void BTDM_ForHalt(struct rtw_adapter *padapter) { - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - - if (!pHalData->bt_coexist.BluetoothCoexist) + if (!rtl8723a_BT_coexist(padapter)) return; BTDM_ForHalt8723A(padapter); @@ -10992,9 +10989,7 @@ void BTDM_ForHalt(struct rtw_adapter *padapter) void BTDM_WifiScanNotify(struct rtw_adapter *padapter, u8 scanType) { - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - - if (!pHalData->bt_coexist.BluetoothCoexist) + if (!rtl8723a_BT_coexist(padapter)) return; BTDM_WifiScanNotify8723A(padapter, scanType); @@ -11002,9 +10997,7 @@ void BTDM_WifiScanNotify(struct rtw_adapter *padapter, u8 scanType) void BTDM_WifiAssociateNotify(struct rtw_adapter *padapter, u8 action) { - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - - if (!pHalData->bt_coexist.BluetoothCoexist) + if (!rtl8723a_BT_coexist(padapter)) return; BTDM_WifiAssociateNotify8723A(padapter, action); @@ -11012,9 +11005,7 @@ void BTDM_WifiAssociateNotify(struct rtw_adapter *padapter, u8 action) void BTDM_MediaStatusNotify(struct rtw_adapter *padapter, enum rt_media_status mstatus) { - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - - if (!pHalData->bt_coexist.BluetoothCoexist) + if (!rtl8723a_BT_coexist(padapter)) return; BTDM_MediaStatusNotify8723A(padapter, mstatus); @@ -11022,9 +11013,7 @@ void BTDM_MediaStatusNotify(struct rtw_adapter *padapter, enum rt_media_status m void BTDM_ForDhcp(struct rtw_adapter *padapter) { - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - - if (!pHalData->bt_coexist.BluetoothCoexist) + if (!rtl8723a_BT_coexist(padapter)) return; BTDM_ForDhcp8723A(padapter); @@ -11315,8 +11304,10 @@ void HALBT_InitBTVars8723A(struct rtw_adapter *padapter) pHalData->bt_coexist.BT_Ant_isolation = pHalData->EEPROMBluetoothAntIsolation; pHalData->bt_coexist.bt_radiosharedtype = pHalData->EEPROMBluetoothRadioShared; - RT_TRACE(_module_hal_init_c_, _drv_info_, ("BT Coexistance = 0x%x\n", pHalData->bt_coexist.BluetoothCoexist)); - if (pHalData->bt_coexist.BluetoothCoexist) { + RT_TRACE(_module_hal_init_c_, _drv_info_, + ("BT Coexistance = 0x%x\n", rtl8723a_BT_coexist(padapter))); + + if (rtl8723a_BT_coexist(padapter)) { if (pHalData->bt_coexist.BT_Ant_Num == Ant_x2) { BTDM_SetBtCoexCurrAntNum(padapter, 2); RT_TRACE(_module_hal_init_c_, _drv_info_, ("BlueTooth BT_Ant_Num = Antx2\n")); @@ -11336,7 +11327,7 @@ void HALBT_InitBTVars8723A(struct rtw_adapter *padapter) } } -u8 HALBT_IsBTExist(struct rtw_adapter *padapter) +bool rtl8723a_BT_coexist(struct rtw_adapter *padapter) { struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h index 653af15d5ec3..02178ac264d4 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h @@ -21,6 +21,7 @@ #ifdef CONFIG_8723AU_BT_COEXIST bool rtl8723a_BT_using_antenna_1(struct rtw_adapter *padapter); bool rtl8723a_BT_enabled(struct rtw_adapter *padapter); +bool rtl8723a_BT_coexist(struct rtw_adapter *padapter); #else static inline bool rtl8723a_BT_using_antenna_1(struct rtw_adapter *padapter) { @@ -30,6 +31,10 @@ static inline bool rtl8723a_BT_enabled(struct rtw_adapter *padapter) { return false; } +static inline bool rtl8723a_BT_coexist(struct rtw_adapter *padapter) +{ + return false; +} #endif #endif -- cgit v1.2.3 From ef95e276a8fd4da4b5b8617793451da4653d7ae4 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:26 +0200 Subject: staging: rtl8723au: Remove some CONFIG_8723AU_BT_COEXIST clutter Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index db97ffb989c1..e4caa3f8e701 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -990,23 +990,21 @@ static void traffic_status_watchdog(struct rtw_adapter *padapter) bHigherBusyTxTraffic = true; } -#ifdef CONFIG_8723AU_BT_COEXIST - if (rtl8723a_BT_using_antenna_1(padapter) == false) -#endif - { + if (!rtl8723a_BT_coexist(padapter) || + !rtl8723a_BT_using_antenna_1(padapter)) { /* check traffic for powersaving. */ - if (((pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod + - pmlmepriv->LinkDetectInfo.NumTxOkInPeriod) > 8) || - (pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod > 2)) - bEnterPS = false; - else - bEnterPS = true; + if (((pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod + + pmlmepriv->LinkDetectInfo.NumTxOkInPeriod) > 8) || + pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod >2) + bEnterPS = false; + else + bEnterPS = true; - /* LeisurePS only work in infra mode. */ - if (bEnterPS) - LPS_Enter23a(padapter); - else - LPS_Leave23a(padapter); + /* LeisurePS only work in infra mode. */ + if (bEnterPS) + LPS_Enter23a(padapter); + else + LPS_Leave23a(padapter); } } else LPS_Leave23a(padapter); -- cgit v1.2.3 From febf30876e28346b58a96c5411933397b0474655 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:27 +0200 Subject: staging: rtl8723au: Rename BTDM_Coexist() to rtl8723a_BT_do_coexist() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 4 +--- drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 4 ++-- drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h | 2 -- drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h | 2 ++ 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index e4caa3f8e701..986abd818e92 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -1039,12 +1039,10 @@ static void dynamic_chk_wk_hdl(struct rtw_adapter *padapter, u8 *pbuf, int sz) rtl8723a_HalDmWatchDog(padapter); -#ifdef CONFIG_8723AU_BT_COEXIST /* */ /* BT-Coexist */ /* */ - BT_CoexistMechanism(padapter); -#endif + rtl8723a_BT_do_coexist(padapter); } static void lps_ctrl_wk_hdl(struct rtw_adapter *padapter, u8 lps_ctrl_type) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index 9326e0548489..ab34b2bb4574 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -10766,7 +10766,7 @@ void BTDM_SignalCompensation(struct rtw_adapter *padapter, u8 *rssi_wifi, u8 *rs BTDM_8723ASignalCompensation(padapter, rssi_wifi, rssi_bt); } -void BTDM_Coexist(struct rtw_adapter *padapter) +void rtl8723a_BT_do_coexist(struct rtw_adapter *padapter) { struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); @@ -11347,7 +11347,7 @@ u8 HALBT_BTChipType(struct rtw_adapter *padapter) void HALBT_InitHwConfig(struct rtw_adapter *padapter) { halbt_InitHwConfig8723A(padapter); - BTDM_Coexist(padapter); + rtl8723a_BT_do_coexist(padapter); } void HALBT_SetRtsCtsNoLenLimit(struct rtw_adapter *padapter) diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h index d8a324484b55..db25b7257113 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h @@ -1571,8 +1571,6 @@ void BTDM_HWCoexAllOff(struct rtw_adapter * padapter); void BTDM_CoexAllOff(struct rtw_adapter * padapter); void BTDM_TurnOffBtCoexistBeforeEnterIPS(struct rtw_adapter * padapter); void BTDM_SignalCompensation(struct rtw_adapter * padapter, u8 *rssi_wifi, u8 *rssi_bt); -void BTDM_Coexist(struct rtw_adapter * padapter); -#define BT_CoexistMechanism BTDM_Coexist void BTDM_UpdateCoexState(struct rtw_adapter * padapter); u8 BTDM_IsSameCoexistState(struct rtw_adapter * padapter); void BTDM_PWDBMonitor(struct rtw_adapter * padapter); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h index 02178ac264d4..3e7bdde84b60 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h @@ -22,6 +22,7 @@ bool rtl8723a_BT_using_antenna_1(struct rtw_adapter *padapter); bool rtl8723a_BT_enabled(struct rtw_adapter *padapter); bool rtl8723a_BT_coexist(struct rtw_adapter *padapter); +void rtl8723a_BT_do_coexist(struct rtw_adapter *padapter); #else static inline bool rtl8723a_BT_using_antenna_1(struct rtw_adapter *padapter) { @@ -35,6 +36,7 @@ static inline bool rtl8723a_BT_coexist(struct rtw_adapter *padapter) { return false; } +#define rtl8723a_BT_do_coexist(padapter) do {} while(0) #endif #endif -- cgit v1.2.3 From d952e4c4af8ab641bac850cbac283c1fec67ca1e Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:28 +0200 Subject: staging: rtl8723au: Rename BT_WifiScanNotify() rtl8723a_BT_wifiscan_notify() Providing a dummy wrapper also allows removing some more CONFIG_8723AU_BT_COEXIST clutter Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 7 ++----- drivers/staging/rtl8723au/hal/hal_com.c | 4 +--- drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 2 +- drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h | 1 - drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h | 2 ++ 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 986abd818e92..a4875aeda446 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -1058,11 +1058,8 @@ static void lps_ctrl_wk_hdl(struct rtw_adapter *padapter, u8 lps_ctrl_type) switch (lps_ctrl_type) { case LPS_CTRL_SCAN: -#ifdef CONFIG_8723AU_BT_COEXIST - BT_WifiScanNotify(padapter, true); - if (rtl8723a_BT_using_antenna_1(padapter) == false) -#endif - { + rtl8723a_BT_wifiscan_notify(padapter, true); + if (!rtl8723a_BT_using_antenna_1(padapter)) { if (check_fwstate(pmlmepriv, _FW_LINKED)) LPS_Leave23a(padapter); } diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index 09e888aaef71..9fba04945152 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -581,9 +581,7 @@ void rtl8723a_mlme_sitesurvey(struct rtw_adapter *padapter, u8 flag) rtl8723au_write32(padapter, REG_RCR, v32); } -#ifdef CONFIG_8723AU_BT_COEXIST - BT_WifiScanNotify(padapter, flag ? true : false); -#endif + rtl8723a_BT_wifiscan_notify(padapter, flag ? true : false); } void rtl8723a_on_rcr_am(struct rtw_adapter *padapter) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index ab34b2bb4574..5efdbfa6b69d 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -138,7 +138,7 @@ void BT_SignalCompensation(struct rtw_adapter *padapter, u8 *rssi_wifi, u8 *rssi BTDM_SignalCompensation(padapter, rssi_wifi, rssi_bt); } -void BT_WifiScanNotify(struct rtw_adapter *padapter, u8 scanType) +void rtl8723a_BT_wifiscan_notify(struct rtw_adapter *padapter, u8 scanType) { BTHCI_WifiScanNotify(padapter, scanType); BTDM_CheckAntSelMode(padapter); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h index db25b7257113..aacbe397bdbf 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h @@ -31,7 +31,6 @@ enum rt_media_status { void BT_SignalCompensation(struct rtw_adapter *padapter, u8 *rssi_wifi, u8 *rssi_bt); -void BT_WifiScanNotify(struct rtw_adapter *padapter, u8 scanType); void BT_WifiAssociateNotify(struct rtw_adapter *padapter, u8 action); void BT_WifiMediaStatusNotify(struct rtw_adapter *padapter, enum rt_media_status mstatus); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h index 3e7bdde84b60..b198cf073596 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h @@ -23,6 +23,7 @@ bool rtl8723a_BT_using_antenna_1(struct rtw_adapter *padapter); bool rtl8723a_BT_enabled(struct rtw_adapter *padapter); bool rtl8723a_BT_coexist(struct rtw_adapter *padapter); void rtl8723a_BT_do_coexist(struct rtw_adapter *padapter); +void rtl8723a_BT_wifiscan_notify(struct rtw_adapter *padapter, u8 scanType); #else static inline bool rtl8723a_BT_using_antenna_1(struct rtw_adapter *padapter) { @@ -37,6 +38,7 @@ static inline bool rtl8723a_BT_coexist(struct rtw_adapter *padapter) return false; } #define rtl8723a_BT_do_coexist(padapter) do {} while(0) +#define rtl8723a_BT_wifiscan_notify(padapter, scanType) do {} while(0) #endif #endif -- cgit v1.2.3 From 43de03040998e98d8703b48dd0bf7705b649dfae Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:29 +0200 Subject: staging: rtl8723au: Rename BT_WifiMediaStatusNotify() rtl8723a_BT_mediastatus_notify() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 12 +++--------- drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 8 ++------ drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h | 2 -- drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h | 4 ++++ 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index a4875aeda446..c89a19c391db 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -1072,19 +1072,13 @@ static void lps_ctrl_wk_hdl(struct rtw_adapter *padapter, u8 lps_ctrl_type) /* Reset LPS Setting */ padapter->pwrctrlpriv.LpsIdleCount = 0; rtl8723a_set_FwJoinBssReport_cmd(padapter, 1); -#ifdef CONFIG_8723AU_BT_COEXIST - BT_WifiMediaStatusNotify(padapter, mstatus); -#endif + rtl8723a_BT_mediastatus_notify(padapter, mstatus); break; case LPS_CTRL_DISCONNECT: mstatus = 0;/* disconnect */ -#ifdef CONFIG_8723AU_BT_COEXIST - BT_WifiMediaStatusNotify(padapter, mstatus); - if (rtl8723a_BT_using_antenna_1(padapter) == false) -#endif - { + rtl8723a_BT_mediastatus_notify(padapter, mstatus); + if (!rtl8723a_BT_using_antenna_1(padapter)) LPS_Leave23a(padapter); - } rtl8723a_set_FwJoinBssReport_cmd(padapter, 0); break; case LPS_CTRL_SPECIAL_PACKET: diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index 5efdbfa6b69d..dbaa7c497978 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -156,11 +156,6 @@ void BT_WifiAssociateNotify(struct rtw_adapter *padapter, u8 action) BTDM_WifiAssociateNotify(padapter, action); } -void BT_WifiMediaStatusNotify(struct rtw_adapter *padapter, enum rt_media_status mstatus) -{ - BTDM_MediaStatusNotify(padapter, mstatus); -} - void BT_SpecialPacketNotify(struct rtw_adapter *padapter) { BTDM_ForDhcp(padapter); @@ -11003,7 +10998,8 @@ void BTDM_WifiAssociateNotify(struct rtw_adapter *padapter, u8 action) BTDM_WifiAssociateNotify8723A(padapter, action); } -void BTDM_MediaStatusNotify(struct rtw_adapter *padapter, enum rt_media_status mstatus) +void rtl8723a_BT_mediastatus_notify(struct rtw_adapter *padapter, + enum rt_media_status mstatus) { if (!rtl8723a_BT_coexist(padapter)) return; diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h index aacbe397bdbf..46e29045d2bc 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h @@ -32,8 +32,6 @@ enum rt_media_status { void BT_SignalCompensation(struct rtw_adapter *padapter, u8 *rssi_wifi, u8 *rssi_bt); void BT_WifiAssociateNotify(struct rtw_adapter *padapter, u8 action); -void BT_WifiMediaStatusNotify(struct rtw_adapter *padapter, - enum rt_media_status mstatus); void BT_SpecialPacketNotify(struct rtw_adapter * padapter); void BT_HaltProcess(struct rtw_adapter * padapter); void BT_LpsLeave(struct rtw_adapter * padapter); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h index b198cf073596..7ef59a21d249 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h @@ -19,11 +19,14 @@ #include #ifdef CONFIG_8723AU_BT_COEXIST +enum rt_media_status; bool rtl8723a_BT_using_antenna_1(struct rtw_adapter *padapter); bool rtl8723a_BT_enabled(struct rtw_adapter *padapter); bool rtl8723a_BT_coexist(struct rtw_adapter *padapter); void rtl8723a_BT_do_coexist(struct rtw_adapter *padapter); void rtl8723a_BT_wifiscan_notify(struct rtw_adapter *padapter, u8 scanType); +void rtl8723a_BT_mediastatus_notify(struct rtw_adapter *padapter, + enum rt_media_status mstatus); #else static inline bool rtl8723a_BT_using_antenna_1(struct rtw_adapter *padapter) { @@ -39,6 +42,7 @@ static inline bool rtl8723a_BT_coexist(struct rtw_adapter *padapter) } #define rtl8723a_BT_do_coexist(padapter) do {} while(0) #define rtl8723a_BT_wifiscan_notify(padapter, scanType) do {} while(0) +#define rtl8723a_BT_mediastatus_notify(padapter, mstatus) do {} while(0) #endif #endif -- cgit v1.2.3 From f83e9e2a1359eea10caf04c3ea2dfd8d6f59d9df Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:30 +0200 Subject: staging: rtl8723au: Rename BTDM_ForDhcp() to rtl8723a_BT_specialpacket_notify() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 8 ++------ drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 7 +------ drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h | 4 +++- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index c89a19c391db..0f837fa3820e 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -1083,13 +1083,9 @@ static void lps_ctrl_wk_hdl(struct rtw_adapter *padapter, u8 lps_ctrl_type) break; case LPS_CTRL_SPECIAL_PACKET: pwrpriv->DelayLPSLastTimeStamp = jiffies; -#ifdef CONFIG_8723AU_BT_COEXIST - BT_SpecialPacketNotify(padapter); - if (rtl8723a_BT_using_antenna_1(padapter) == false) -#endif - { + rtl8723a_BT_specialpacket_notify(padapter); + if (!rtl8723a_BT_using_antenna_1(padapter)) LPS_Leave23a(padapter); - } break; case LPS_CTRL_LEAVE: #ifdef CONFIG_8723AU_BT_COEXIST diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index dbaa7c497978..f00313b9cc89 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -156,11 +156,6 @@ void BT_WifiAssociateNotify(struct rtw_adapter *padapter, u8 action) BTDM_WifiAssociateNotify(padapter, action); } -void BT_SpecialPacketNotify(struct rtw_adapter *padapter) -{ - BTDM_ForDhcp(padapter); -} - void BT_HaltProcess(struct rtw_adapter *padapter) { BTDM_ForHalt(padapter); @@ -11007,7 +11002,7 @@ void rtl8723a_BT_mediastatus_notify(struct rtw_adapter *padapter, BTDM_MediaStatusNotify8723A(padapter, mstatus); } -void BTDM_ForDhcp(struct rtw_adapter *padapter) +void rtl8723a_BT_specialpacket_notify(struct rtw_adapter *padapter) { if (!rtl8723a_BT_coexist(padapter)) return; diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h index 7ef59a21d249..52e17329bc48 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h @@ -27,6 +27,7 @@ void rtl8723a_BT_do_coexist(struct rtw_adapter *padapter); void rtl8723a_BT_wifiscan_notify(struct rtw_adapter *padapter, u8 scanType); void rtl8723a_BT_mediastatus_notify(struct rtw_adapter *padapter, enum rt_media_status mstatus); +void rtl8723a_BT_specialpacket_notify(struct rtw_adapter *padapter); #else static inline bool rtl8723a_BT_using_antenna_1(struct rtw_adapter *padapter) { @@ -40,9 +41,10 @@ static inline bool rtl8723a_BT_coexist(struct rtw_adapter *padapter) { return false; } -#define rtl8723a_BT_do_coexist(padapter) do {} while(0) +#define rtl8723a_BT_do_coexist(padapter) do {} while(0) #define rtl8723a_BT_wifiscan_notify(padapter, scanType) do {} while(0) #define rtl8723a_BT_mediastatus_notify(padapter, mstatus) do {} while(0) +#define rtl8723a_BT_specialpacket_notify(padapter) do {} while(0) #endif #endif -- cgit v1.2.3 From a862d5d307609be8ee7068a11626e571d4712e2b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:31 +0200 Subject: staging: rtl8723au: Rename BT_LpsLeave() rtl8723a_BT_lps_leave() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 8 ++------ drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 7 +------ drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h | 2 ++ 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 0f837fa3820e..646b59b28551 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -1088,13 +1088,9 @@ static void lps_ctrl_wk_hdl(struct rtw_adapter *padapter, u8 lps_ctrl_type) LPS_Leave23a(padapter); break; case LPS_CTRL_LEAVE: -#ifdef CONFIG_8723AU_BT_COEXIST - BT_LpsLeave(padapter); - if (rtl8723a_BT_using_antenna_1(padapter) == false) -#endif - { + rtl8723a_BT_lps_leave(padapter); + if (!rtl8723a_BT_using_antenna_1(padapter)) LPS_Leave23a(padapter); - } break; default: diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index f00313b9cc89..9891a2f70cb2 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -161,11 +161,6 @@ void BT_HaltProcess(struct rtw_adapter *padapter) BTDM_ForHalt(padapter); } -void BT_LpsLeave(struct rtw_adapter *padapter) -{ - BTDM_LpsLeave(padapter); -} - /* ===== End of sync from SD7 driver COMMOM/BT.c ===== */ #define i64fmt "ll" @@ -9728,7 +9723,7 @@ BTDM_Set8723ABtCoexCurrAntNum(struct rtw_adapter *padapter, u8 antNum) pBtCoex->TotalAntNum = Ant_x2; } -void BTDM_LpsLeave(struct rtw_adapter *padapter) +void rtl8723a_BT_lps_leave(struct rtw_adapter *padapter) { struct bt_30info *pBTInfo = GET_BT_INFO(padapter); struct bt_mgnt *pBtMgnt = &pBTInfo->BtMgnt; diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h index 52e17329bc48..1b2845e67513 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h @@ -28,6 +28,7 @@ void rtl8723a_BT_wifiscan_notify(struct rtw_adapter *padapter, u8 scanType); void rtl8723a_BT_mediastatus_notify(struct rtw_adapter *padapter, enum rt_media_status mstatus); void rtl8723a_BT_specialpacket_notify(struct rtw_adapter *padapter); +void rtl8723a_BT_lps_leave(struct rtw_adapter *padapter); #else static inline bool rtl8723a_BT_using_antenna_1(struct rtw_adapter *padapter) { @@ -45,6 +46,7 @@ static inline bool rtl8723a_BT_coexist(struct rtw_adapter *padapter) #define rtl8723a_BT_wifiscan_notify(padapter, scanType) do {} while(0) #define rtl8723a_BT_mediastatus_notify(padapter, mstatus) do {} while(0) #define rtl8723a_BT_specialpacket_notify(padapter) do {} while(0) +#define rtl8723a_BT_lps_leave(padapter) do {} while(0) #endif #endif -- cgit v1.2.3 From 09d8879195c37dad2b4b122740af67271f84d1dd Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:32 +0200 Subject: staging: rtl8723au: rtw_cmd.c: Remove last #ifdef CONFIG_8723AU_BT_COEXIST usage Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 646b59b28551..1696cb8b17cb 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -21,10 +21,6 @@ #include #include -#ifdef CONFIG_8723AU_BT_COEXIST -#include -#endif /* CONFIG_8723AU_BT_COEXIST */ - static struct cmd_hdl wlancmds[] = { GEN_DRV_CMD_HANDLER(0, NULL) /*0*/ GEN_DRV_CMD_HANDLER(0, NULL) @@ -950,25 +946,19 @@ static void traffic_status_watchdog(struct rtw_adapter *padapter) u8 bHigherBusyTraffic = false, bHigherBusyRxTraffic = false; u8 bHigherBusyTxTraffic = false; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -#ifndef CONFIG_8723AU_BT_COEXIST int BusyThreshold = 100; -#endif /* */ /* Determine if our traffic is busy now */ /* */ if (check_fwstate(pmlmepriv, _FW_LINKED)) { -#ifdef CONFIG_8723AU_BT_COEXIST - if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > 50 || - pmlmepriv->LinkDetectInfo.NumTxOkInPeriod > 50) -#else /* !CONFIG_8723AU_BT_COEXIST */ + if (rtl8723a_BT_coexist(padapter)) + BusyThreshold = 50; + else if (pmlmepriv->LinkDetectInfo.bBusyTraffic) + BusyThreshold = 75; /* if we raise bBusyTraffic in last watchdog, using lower threshold. */ - if (pmlmepriv->LinkDetectInfo.bBusyTraffic) - BusyThreshold = 75; if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > BusyThreshold || - pmlmepriv->LinkDetectInfo.NumTxOkInPeriod > BusyThreshold) -#endif /* !CONFIG_8723AU_BT_COEXIST */ - { + pmlmepriv->LinkDetectInfo.NumTxOkInPeriod > BusyThreshold) { bBusyTraffic = true; if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > -- cgit v1.2.3 From e631bae3636be516f7c9788136c351871bc23b36 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:33 +0200 Subject: staging: rtl8723au: rtw_pwrctrl.c: Remove an unnecessary COEXIST #ifdef Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index f4e32d9efb8b..ef9b46879f11 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -350,11 +350,8 @@ void rtw_set_ps_mode23a(struct rtw_adapter *padapter, u8 ps_mode, rtl8723a_set_FwPwrMode_cmd(padapter, ps_mode); pwrpriv->bFwCurrentInPSMode = false; } else { - if (PS_RDY_CHECK(padapter) -#ifdef CONFIG_8723AU_BT_COEXIST - || (rtl8723a_BT_using_antenna_1(padapter)) -#endif - ) { + if (PS_RDY_CHECK(padapter) || + rtl8723a_BT_using_antenna_1(padapter)) { DBG_8723A("%s: Enter 802.11 power save\n", __func__); pwrpriv->bFwCurrentInPSMode = true; -- cgit v1.2.3 From 280e7a0bfab16cadeea48f212abcbab1b4a22a8e Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:34 +0200 Subject: staging: rtl8723au: rtw_pwrctrl.c: Eliminate CONFIG_8723AU_BT_COEXIST #ifdefs Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 9 +++------ drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 2 +- drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h | 2 ++ 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index ef9b46879f11..dbd01b652e02 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -20,9 +20,7 @@ #include #include -#ifdef CONFIG_8723AU_BT_COEXIST -#include -#endif +#include #include void ips_enter23a(struct rtw_adapter * padapter) @@ -38,9 +36,8 @@ void ips_enter23a(struct rtw_adapter * padapter) pwrpriv->ips_enter23a_cnts++; DBG_8723A("==>ips_enter23a cnts:%d\n", pwrpriv->ips_enter23a_cnts); -#ifdef CONFIG_8723AU_BT_COEXIST - BTDM_TurnOffBtCoexistBeforeEnterIPS(padapter); -#endif + rtl8723a_BT_disable_coexist(padapter); + if (pwrpriv->change_rfpwrstate == rf_off) { pwrpriv->bpower_saving = true; DBG_8723A_LEVEL(_drv_always_, "nolinked power save enter\n"); diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index 9891a2f70cb2..b746b08db497 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -10726,7 +10726,7 @@ void BTDM_CoexAllOff(struct rtw_adapter *padapter) BTDM_HWCoexAllOff(padapter); } -void BTDM_TurnOffBtCoexistBeforeEnterIPS(struct rtw_adapter *padapter) +void rtl8723a_BT_disable_coexist(struct rtw_adapter *padapter) { struct pwrctrl_priv *ppwrctrl = &padapter->pwrctrlpriv; diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h index 1b2845e67513..b63288909891 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h @@ -29,6 +29,7 @@ void rtl8723a_BT_mediastatus_notify(struct rtw_adapter *padapter, enum rt_media_status mstatus); void rtl8723a_BT_specialpacket_notify(struct rtw_adapter *padapter); void rtl8723a_BT_lps_leave(struct rtw_adapter *padapter); +void rtl8723a_BT_disable_coexist(struct rtw_adapter *padapter); #else static inline bool rtl8723a_BT_using_antenna_1(struct rtw_adapter *padapter) { @@ -47,6 +48,7 @@ static inline bool rtl8723a_BT_coexist(struct rtw_adapter *padapter) #define rtl8723a_BT_mediastatus_notify(padapter, mstatus) do {} while(0) #define rtl8723a_BT_specialpacket_notify(padapter) do {} while(0) #define rtl8723a_BT_lps_leave(padapter) do {} while(0) +#define rtl8723a_BT_disable_coexist(padapter) do {} while(0) #endif #endif -- cgit v1.2.3 From 92825e6e363804ef2280024bdded9bc5f398ba72 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:35 +0200 Subject: staging: rtl8723au: rtw_mlme_ext.c: Remove CONFIG_8723AU_BT_COEXIST #ifdefs Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index def329923fb4..a994f1491772 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -3478,13 +3478,12 @@ static void issue_assocreq(struct rtw_adapter *padapter) pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info = cpu_to_le16(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info); -#ifdef CONFIG_8723AU_BT_COEXIST - if (rtl8723a_BT_using_antenna_1(padapter)) { + if (rtl8723a_BT_coexist(padapter) && + rtl8723a_BT_using_antenna_1(padapter)) { /* set to 8K */ pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para &= (u8)~IEEE80211_HT_AMPDU_PARM_FACTOR; /* pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para |= MAX_AMPDU_FACTOR_8K */ } -#endif pframe = rtw_set_ie23a(pframe, WLAN_EID_HT_CAPABILITY, p[1], (u8 *)&pmlmeinfo->HT_caps, @@ -3986,9 +3985,7 @@ void issue_action_BA23a(struct rtw_adapter *padapter, struct sta_info *psta; struct sta_priv *pstapriv = &padapter->stapriv; struct registry_priv *pregpriv = &padapter->registrypriv; -#ifdef CONFIG_8723AU_BT_COEXIST u8 tendaAPMac[] = {0xC8, 0x3A, 0x35}; -#endif DBG_8723A("%s, category =%d, action =%d, status =%d\n", __func__, category, action, status); @@ -4037,9 +4034,9 @@ void issue_action_BA23a(struct rtw_adapter *padapter, pframe = rtw_set_fixed_ie23a(pframe, 1, &pmlmeinfo->dialogToken, &pattrib->pktlen); -#ifdef CONFIG_8723AU_BT_COEXIST - if (rtl8723a_BT_using_antenna_1(padapter) && - ((pmlmeinfo->assoc_AP_vendor != broadcomAP) || + if (rtl8723a_BT_coexist(padapter) && + rtl8723a_BT_using_antenna_1(padapter) && + (pmlmeinfo->assoc_AP_vendor != broadcomAP || memcmp(raddr, tendaAPMac, 3))) { /* A-MSDU NOT Supported */ BA_para_set = 0; @@ -4052,9 +4049,7 @@ void issue_action_BA23a(struct rtw_adapter *padapter, /* max buffer size is 8 MSDU */ BA_para_set |= (8 << 6) & IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK; - } else -#endif - { + } else { /* immediate ack & 64 buffer size */ BA_para_set = (0x1002 | ((status & 0xf) << 2)); } @@ -4104,16 +4099,15 @@ void issue_action_BA23a(struct rtw_adapter *padapter, else BA_para_set = ((le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x1000); /* 64 buffer size */ -#ifdef CONFIG_8723AU_BT_COEXIST - if (rtl8723a_BT_using_antenna_1(padapter) && - ((pmlmeinfo->assoc_AP_vendor != broadcomAP) || + if (rtl8723a_BT_coexist(padapter) && + rtl8723a_BT_using_antenna_1(padapter) && + (pmlmeinfo->assoc_AP_vendor != broadcomAP || memcmp(raddr, tendaAPMac, 3))) { /* max buffer size is 8 MSDU */ BA_para_set &= ~IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK; BA_para_set |= (8 << 6) & IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK; } -#endif if (pregpriv->ampdu_amsdu == 0)/* disabled */ BA_para_set = cpu_to_le16(BA_para_set & ~BIT(0)); -- cgit v1.2.3 From d0fc14642f59f2f5c73e6c3deaab24b81d8f69f2 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:36 +0200 Subject: staging: rtl8723au: rtw_mlme_ext.c: Sanitize calls to alloc_mgtxmitframe23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index a994f1491772..e1b28a234259 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -2467,7 +2467,8 @@ void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms) /* DBG_8723A("%s\n", __func__); */ - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) { + pmgntframe = alloc_mgtxmitframe23a(pxmitpriv); + if (!pmgntframe) { DBG_8723A("%s, alloc mgnt frame fail\n", __func__); return; } @@ -2843,7 +2844,8 @@ static int _issue_probereq(struct rtw_adapter *padapter, RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+%s\n", __func__)); - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) + pmgntframe = alloc_mgtxmitframe23a(pxmitpriv); + if (!pmgntframe) goto exit; /* update attribute */ @@ -2991,7 +2993,8 @@ static void issue_auth(struct rtw_adapter *padapter, struct sta_info *psta, struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) + pmgntframe = alloc_mgtxmitframe23a(pxmitpriv); + if (!pmgntframe) return; /* update attribute */ @@ -3569,7 +3572,8 @@ static int _issue_nulldata23a(struct rtw_adapter *padapter, unsigned char *da, pmlmeext = &padapter->mlmeextpriv; pmlmeinfo = &pmlmeext->mlmext_info; - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) + pmgntframe = alloc_mgtxmitframe23a(pxmitpriv); + if (!pmgntframe) goto exit; /* update attribute */ @@ -3685,7 +3689,8 @@ static int _issue_qos_nulldata23a(struct rtw_adapter *padapter, DBG_8723A("%s\n", __func__); - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) + pmgntframe = alloc_mgtxmitframe23a(pxmitpriv); + if (!pmgntframe) goto exit; /* update attribute */ @@ -3810,7 +3815,8 @@ static int _issue_deauth(struct rtw_adapter *padapter, unsigned char *da, /* DBG_8723A("%s to "MAC_FMT"\n", __func__, MAC_ARG(da)); */ - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) + pmgntframe = alloc_mgtxmitframe23a(pxmitpriv); + if (!pmgntframe) goto exit; /* update attribute */ @@ -3921,7 +3927,8 @@ void issue_action_spct_ch_switch23a(struct rtw_adapter *padapter, DBG_8723A("%s(%s): ra ="MAC_FMT", ch:%u, offset:%u\n", __func__, padapter->pnetdev->name, MAC_ARG(ra), new_ch, ch_offset); - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) + pmgntframe = alloc_mgtxmitframe23a(pxmitpriv); + if (!pmgntframe) return; /* update attribute */ @@ -3990,7 +3997,8 @@ void issue_action_BA23a(struct rtw_adapter *padapter, DBG_8723A("%s, category =%d, action =%d, status =%d\n", __func__, category, action, status); - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) + pmgntframe = alloc_mgtxmitframe23a(pxmitpriv); + if (!pmgntframe) return; /* update attribute */ -- cgit v1.2.3 From dddeff3f20fc9ca78a4f78e951207879ae8e4365 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:37 +0200 Subject: staging: rtl8723au: odm.c: Rename BTDM_DisableEDCATurbo() to rtl8723a_BT_disable_EDCA_turbo() Make it return bool since it only returns true/false, and get rid of Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/odm.c | 4 +--- drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 4 ++-- drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h | 2 -- drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h | 5 +++++ 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/odm.c b/drivers/staging/rtl8723au/hal/odm.c index 6b3b2f0378a8..e15ebfe1881b 100644 --- a/drivers/staging/rtl8723au/hal/odm.c +++ b/drivers/staging/rtl8723au/hal/odm.c @@ -1668,10 +1668,8 @@ void odm_EdcaTurboCheck23aCE23a(struct dm_odm_t *pDM_Odm) if (pmlmeinfo->assoc_AP_vendor >= HT_IOT_PEER_MAX) goto dm_CheckEdcaTurbo_EXIT; -#ifdef CONFIG_8723AU_BT_COEXIST - if (BT_DisableEDCATurbo(Adapter)) + if (rtl8723a_BT_disable_EDCA_turbo(Adapter)) goto dm_CheckEdcaTurbo_EXIT; -#endif /* Check if the status needs to be changed. */ if ((bbtchange) || (!precvpriv->bIsAnyNonBEPkts)) { diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index b746b08db497..4d94b4b99d60 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -10534,13 +10534,13 @@ u8 BTDM_CheckCoexRSSIState(struct rtw_adapter *padapter, u8 levelNum, return btRssiState; } -u8 BTDM_DisableEDCATurbo(struct rtw_adapter *padapter) +bool rtl8723a_BT_disable_EDCA_turbo(struct rtw_adapter *padapter) { struct bt_mgnt *pBtMgnt; struct hal_data_8723a *pHalData; u8 bBtChangeEDCA = false; u32 EDCA_BT_BE = 0x5ea42b, cur_EDCA_reg; - u8 bRet = false; + bool bRet = false; pHalData = GET_HAL_DATA(padapter); pBtMgnt = &pHalData->BtInfo.BtMgnt; diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h index 46e29045d2bc..b5659fd9692d 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h @@ -1557,8 +1557,6 @@ s32 BTDM_GetRxSS(struct rtw_adapter * padapter); u8 BTDM_CheckCoexBcnRssiState(struct rtw_adapter * padapter, u8 levelNum, u8 RssiThresh, u8 RssiThresh1); u8 BTDM_CheckCoexRSSIState1(struct rtw_adapter * padapter, u8 levelNum, u8 RssiThresh, u8 RssiThresh1); u8 BTDM_CheckCoexRSSIState(struct rtw_adapter * padapter, u8 levelNum, u8 RssiThresh, u8 RssiThresh1); -u8 BTDM_DisableEDCATurbo(struct rtw_adapter * padapter); -#define BT_DisableEDCATurbo BTDM_DisableEDCATurbo void BTDM_Balance(struct rtw_adapter * padapter, u8 bBalanceOn, u8 ms0, u8 ms1); void BTDM_AGCTable(struct rtw_adapter * padapter, u8 type); void BTDM_BBBackOffLevel(struct rtw_adapter * padapter, u8 type); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h index b63288909891..5de42b0f97ad 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h @@ -30,6 +30,7 @@ void rtl8723a_BT_mediastatus_notify(struct rtw_adapter *padapter, void rtl8723a_BT_specialpacket_notify(struct rtw_adapter *padapter); void rtl8723a_BT_lps_leave(struct rtw_adapter *padapter); void rtl8723a_BT_disable_coexist(struct rtw_adapter *padapter); +bool rtl8723a_BT_disable_EDCA_turbo(struct rtw_adapter *padapter); #else static inline bool rtl8723a_BT_using_antenna_1(struct rtw_adapter *padapter) { @@ -49,6 +50,10 @@ static inline bool rtl8723a_BT_coexist(struct rtw_adapter *padapter) #define rtl8723a_BT_specialpacket_notify(padapter) do {} while(0) #define rtl8723a_BT_lps_leave(padapter) do {} while(0) #define rtl8723a_BT_disable_coexist(padapter) do {} while(0) +static inline bool rtl8723a_BT_disable_EDCA_turbo(struct rtw_adapter *padapter) +{ + return false; +} #endif #endif -- cgit v1.2.3 From dadc54b8eb2aa54ae62968de07fd943986468378 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:38 +0200 Subject: staging: rtl8723au: Move rtl8723a_dual_antenna_detection() to rtl8723a_bt-coexist.c Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 46 ++++++++++++++++++++ drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 49 ---------------------- drivers/staging/rtl8723au/hal/usb_halinit.c | 4 +- .../staging/rtl8723au/include/rtl8723a_bt_intf.h | 2 + drivers/staging/rtl8723au/include/rtl8723a_hal.h | 4 -- 5 files changed, 49 insertions(+), 56 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index 4d94b4b99d60..48c16f4b2355 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -11341,3 +11341,49 @@ void HALBT_SetRtsCtsNoLenLimit(struct rtw_adapter *padapter) } /* ===== End of sync from SD7 driver HAL/HalBT.c ===== */ + +void rtl8723a_dual_antenna_detection(struct rtw_adapter *padapter) +{ + struct hal_data_8723a *pHalData; + struct dm_odm_t *pDM_Odm; + struct sw_ant_sw *pDM_SWAT_Table; + u8 i; + + pHalData = GET_HAL_DATA(padapter); + pDM_Odm = &pHalData->odmpriv; + pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table; + + /* */ + /* RTL8723A Single and Dual antenna dynamic detection + mechanism when RF power state is on. */ + /* We should take power tracking, IQK, LCK, RCK RF read/write + operation into consideration. */ + /* 2011.12.15. */ + /* */ + if (!pHalData->bAntennaDetected) { + u8 btAntNum = BT_GetPGAntNum(padapter); + + /* Set default antenna B status */ + if (btAntNum == Ant_x2) + pDM_SWAT_Table->ANTB_ON = true; + else if (btAntNum == Ant_x1) + pDM_SWAT_Table->ANTB_ON = false; + else + pDM_SWAT_Table->ANTB_ON = true; + + if (pHalData->CustomerID != RT_CID_TOSHIBA) { + for (i = 0; i < MAX_ANTENNA_DETECTION_CNT; i++) { + if (ODM_SingleDualAntennaDetection + (&pHalData->odmpriv, ANTTESTALL) == true) + break; + } + + /* Set default antenna number for BT coexistence */ + if (btAntNum == Ant_x2) + BT_SetBtCoexCurrAntNum(padapter, + pDM_SWAT_Table-> + ANTB_ON ? 2 : 1); + } + pHalData->bAntennaDetected = true; + } +} diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 20c93e471adc..970b5858aad0 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -2575,52 +2575,3 @@ void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type) } #endif } - -#ifdef CONFIG_8723AU_BT_COEXIST - -void rtl8723a_SingleDualAntennaDetection(struct rtw_adapter *padapter) -{ - struct hal_data_8723a *pHalData; - struct dm_odm_t *pDM_Odm; - struct sw_ant_sw *pDM_SWAT_Table; - u8 i; - - pHalData = GET_HAL_DATA(padapter); - pDM_Odm = &pHalData->odmpriv; - pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table; - - /* */ - /* RTL8723A Single and Dual antenna dynamic detection - mechanism when RF power state is on. */ - /* We should take power tracking, IQK, LCK, RCK RF read/write - operation into consideration. */ - /* 2011.12.15. */ - /* */ - if (!pHalData->bAntennaDetected) { - u8 btAntNum = BT_GetPGAntNum(padapter); - - /* Set default antenna B status */ - if (btAntNum == Ant_x2) - pDM_SWAT_Table->ANTB_ON = true; - else if (btAntNum == Ant_x1) - pDM_SWAT_Table->ANTB_ON = false; - else - pDM_SWAT_Table->ANTB_ON = true; - - if (pHalData->CustomerID != RT_CID_TOSHIBA) { - for (i = 0; i < MAX_ANTENNA_DETECTION_CNT; i++) { - if (ODM_SingleDualAntennaDetection - (&pHalData->odmpriv, ANTTESTALL) == true) - break; - } - - /* Set default antenna number for BT coexistence */ - if (btAntNum == Ant_x2) - BT_SetBtCoexCurrAntNum(padapter, - pDM_SWAT_Table-> - ANTB_ON ? 2 : 1); - } - pHalData->bAntennaDetected = true; - } -} -#endif /* CONFIG_8723AU_BT_COEXIST */ diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index d30ba1b022ed..cbd5a8ce45c1 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -831,9 +831,7 @@ static int rtl8723au_hal_init(struct rtw_adapter *Adapter) HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_LCK); rtl8723a_phy_lc_calibrate(Adapter); -#ifdef CONFIG_8723AU_BT_COEXIST - rtl8723a_SingleDualAntennaDetection(Adapter); -#endif + rtl8723a_dual_antenna_detection(Adapter); } HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MISC21); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h index 5de42b0f97ad..7cf4de62c987 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h @@ -31,6 +31,7 @@ void rtl8723a_BT_specialpacket_notify(struct rtw_adapter *padapter); void rtl8723a_BT_lps_leave(struct rtw_adapter *padapter); void rtl8723a_BT_disable_coexist(struct rtw_adapter *padapter); bool rtl8723a_BT_disable_EDCA_turbo(struct rtw_adapter *padapter); +void rtl8723a_dual_antenna_detection(struct rtw_adapter *padapter); #else static inline bool rtl8723a_BT_using_antenna_1(struct rtw_adapter *padapter) { @@ -54,6 +55,7 @@ static inline bool rtl8723a_BT_disable_EDCA_turbo(struct rtw_adapter *padapter) { return false; } +#define rtl8723a_dual_antenna_detection(padapter) do {} while(0) #endif #endif diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index 33ad2b7ee69e..344b7085f877 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -529,10 +529,6 @@ void Hal_EfuseParseThermalMeter_8723A(struct rtw_adapter *padapter, u8 *hwinfo, void Hal_InitChannelPlan23a(struct rtw_adapter *padapter); -#ifdef CONFIG_8723AU_BT_COEXIST -void rtl8723a_SingleDualAntennaDetection(struct rtw_adapter *padapter); -#endif - /* register */ void SetBcnCtrlReg23a(struct rtw_adapter *padapter, u8 SetBits, u8 ClearBits); void rtl8723a_InitBeaconParameters(struct rtw_adapter *padapter); -- cgit v1.2.3 From 00e8b24aee7d4d5cf72d028b23d5604ff14abf86 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:39 +0200 Subject: staging: rtl8723au: Rename HALBT_InitHwConfig() rtl8723a_BT_init_hwconfig() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 2 +- drivers/staging/rtl8723au/hal/usb_halinit.c | 4 ++-- drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h | 2 -- drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h | 2 ++ 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index 48c16f4b2355..30506073a56c 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -11330,7 +11330,7 @@ u8 HALBT_BTChipType(struct rtw_adapter *padapter) return pHalData->bt_coexist.BT_CoexistType; } -void HALBT_InitHwConfig(struct rtw_adapter *padapter) +void rtl8723a_BT_init_hwconfig(struct rtw_adapter *padapter) { halbt_InitHwConfig8723A(padapter); rtl8723a_BT_do_coexist(padapter); diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index cbd5a8ce45c1..2fde327be10f 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -869,9 +869,9 @@ static int rtl8723au_hal_init(struct rtw_adapter *Adapter) #ifdef CONFIG_8723AU_BT_COEXIST HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_BT_COEXIST); - /* Init BT hw config. */ - BT_InitHwConfig(Adapter); #endif + /* Init BT hw config. */ + rtl8723a_BT_init_hwconfig(Adapter); HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_HAL_DM); rtl8723a_InitHalDm(Adapter); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h index b5659fd9692d..8ab56d8b1e72 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h @@ -1613,8 +1613,6 @@ void HALBT_InitBTVars8723A(struct rtw_adapter * padapter); u8 HALBT_IsBTExist(struct rtw_adapter * padapter); #define BT_IsBtExist HALBT_IsBTExist u8 HALBT_BTChipType(struct rtw_adapter * padapter); -void HALBT_InitHwConfig(struct rtw_adapter * padapter); -#define BT_InitHwConfig HALBT_InitHwConfig void HALBT_SetRtsCtsNoLenLimit(struct rtw_adapter * padapter); /* ===== End of sync from SD7 driver HAL/HalBT.c ===== */ diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h index 7cf4de62c987..98bea65a8478 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h @@ -32,6 +32,7 @@ void rtl8723a_BT_lps_leave(struct rtw_adapter *padapter); void rtl8723a_BT_disable_coexist(struct rtw_adapter *padapter); bool rtl8723a_BT_disable_EDCA_turbo(struct rtw_adapter *padapter); void rtl8723a_dual_antenna_detection(struct rtw_adapter *padapter); +void rtl8723a_BT_init_hwconfig(struct rtw_adapter *padapter); #else static inline bool rtl8723a_BT_using_antenna_1(struct rtw_adapter *padapter) { @@ -56,6 +57,7 @@ static inline bool rtl8723a_BT_disable_EDCA_turbo(struct rtw_adapter *padapter) return false; } #define rtl8723a_dual_antenna_detection(padapter) do {} while(0) +#define rtl8723a_BT_init_hwconfig(padapter) do {} while(0) #endif #endif -- cgit v1.2.3 From 1305565cfad28300cdd995e2ce56974bfd011f71 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:40 +0200 Subject: staging: rtl8723au: usb_halinit.c: Remove no-op HAL_INIT_PROFILE_TAG() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_halinit.c | 58 ++++++++--------------------- 1 file changed, 16 insertions(+), 42 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 2fde327be10f..2032b5efbf56 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -616,9 +616,6 @@ static int rtl8723au_hal_init(struct rtw_adapter *Adapter) unsigned long init_start_time = jiffies; -#define HAL_INIT_PROFILE_TAG(stage) do {} while (0) - - HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_BEGIN); if (Adapter->pwrctrlpriv.bkeepfwalive) { _ps_open_RF23a(Adapter); @@ -650,7 +647,6 @@ static int rtl8723au_hal_init(struct rtw_adapter *Adapter) ("%s: MAC has already power on\n", __func__)); } - HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_PW_ON); status = _InitPowerOn(Adapter); if (status == _FAIL) { RT_TRACE(_module_hci_hal_init_c_, _drv_err_, @@ -658,7 +654,6 @@ static int rtl8723au_hal_init(struct rtw_adapter *Adapter) goto exit; } - HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_LLTT); if (!pregistrypriv->wifi_spec) { boundary = TX_PAGE_BOUNDARY; } else { @@ -675,11 +670,9 @@ static int rtl8723au_hal_init(struct rtw_adapter *Adapter) } } - HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MISC01); if (pHalData->bRDGEnable) _InitRDGSetting(Adapter); - HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_DOWNLOAD_FW); status = rtl8723a_FirmwareDownload(Adapter); if (status != _SUCCESS) { Adapter->bFWReady = false; @@ -711,14 +704,12 @@ static int rtl8723au_hal_init(struct rtw_adapter *Adapter) /* Current Channel will be updated again later. */ pHalData->CurrentChannel = 6;/* default set to 6 */ - HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MAC); status = PHY_MACConfig8723A(Adapter); if (status == _FAIL) { DBG_8723A("PHY_MACConfig8723A fault !!\n"); goto exit; } - HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_BB); /* */ /* d. Initialize BB related configurations. */ /* */ @@ -731,7 +722,6 @@ static int rtl8723au_hal_init(struct rtw_adapter *Adapter) /* Add for tx power by rate fine tune. We need to call the function after BB config. */ /* Because the tx power by rate table is inited in BB config. */ - HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_RF); status = PHY_RFConfig8723A(Adapter); if (status == _FAIL) { DBG_8723A("PHY_RFConfig8723A fault !!\n"); @@ -757,7 +747,6 @@ static int rtl8723au_hal_init(struct rtw_adapter *Adapter) pHalData->RfRegChnlVal[0] = PHY_QueryRFReg(Adapter, (enum RF_RADIO_PATH)0, RF_CHNLBW, bRFRegOffsetMask); pHalData->RfRegChnlVal[1] = PHY_QueryRFReg(Adapter, (enum RF_RADIO_PATH)1, RF_CHNLBW, bRFRegOffsetMask); - HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MISC02); if (!pHalData->bMACFuncEnable) { _InitQueueReservedPage(Adapter); _InitTxBufferBoundary(Adapter); @@ -783,14 +772,11 @@ static int rtl8723au_hal_init(struct rtw_adapter *Adapter) _InitHWLed(Adapter); - HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_TURN_ON_BLOCK); _BBTurnOnBlock(Adapter); /* NicIFSetMacAddress(padapter, padapter->PermanentAddress); */ - HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_SECURITY); invalidate_cam_all23a(Adapter); - HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MISC11); /* 2010/12/17 MH We need to set TX power according to EFUSE content at first. */ PHY_SetTxPowerLevel8723A(Adapter, pHalData->CurrentChannel); @@ -812,30 +798,26 @@ static int rtl8723au_hal_init(struct rtw_adapter *Adapter) /* Move by Neo for USB SS from above setp */ _RfPowerSave(Adapter); - HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_IQK); - /* 2010/08/26 MH Merge from 8192CE. */ - /* sherry masked that it has been done in _RfPowerSave */ - /* 20110927 */ - /* recovery for 8192cu and 9723Au 20111017 */ - if (pwrctrlpriv->rf_pwrstate == rf_on) { - if (pHalData->bIQKInitialized) { - rtl8723a_phy_iq_calibrate(Adapter, true); - } else { - rtl8723a_phy_iq_calibrate(Adapter, false); - pHalData->bIQKInitialized = true; - } + /* 2010/08/26 MH Merge from 8192CE. */ + /* sherry masked that it has been done in _RfPowerSave */ + /* 20110927 */ + /* recovery for 8192cu and 9723Au 20111017 */ + if (pwrctrlpriv->rf_pwrstate == rf_on) { + if (pHalData->bIQKInitialized) { + rtl8723a_phy_iq_calibrate(Adapter, true); + } else { + rtl8723a_phy_iq_calibrate(Adapter, false); + pHalData->bIQKInitialized = true; + } - HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_PW_TRACK); - rtl8723a_odm_check_tx_power_tracking(Adapter); + rtl8723a_odm_check_tx_power_tracking(Adapter); - HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_LCK); - rtl8723a_phy_lc_calibrate(Adapter); + rtl8723a_phy_lc_calibrate(Adapter); - rtl8723a_dual_antenna_detection(Adapter); - } + rtl8723a_dual_antenna_detection(Adapter); + } - HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MISC21); - /* fixed USB interface interference issue */ + /* fixed USB interface interference issue */ rtl8723au_write8(Adapter, 0xfe40, 0xe0); rtl8723au_write8(Adapter, 0xfe41, 0x8d); rtl8723au_write8(Adapter, 0xfe42, 0x80); @@ -864,19 +846,13 @@ static int rtl8723au_hal_init(struct rtw_adapter *Adapter) } -/* HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_PABIAS); */ /* _InitPABias(Adapter); */ -#ifdef CONFIG_8723AU_BT_COEXIST - HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_BT_COEXIST); -#endif /* Init BT hw config. */ rtl8723a_BT_init_hwconfig(Adapter); - HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_HAL_DM); rtl8723a_InitHalDm(Adapter); - HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MISC31); rtl8723a_set_nav_upper(Adapter, WiFiNavUpperUs); /* 2011/03/09 MH debug only, UMC-B cut pass 2500 S5 test, but we need to fin root cause. */ @@ -891,8 +867,6 @@ static int rtl8723au_hal_init(struct rtw_adapter *Adapter) rtl8723au_read32(Adapter, REG_FWHW_TXQ_CTRL)|BIT(12)); exit: - HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_END); - DBG_8723A("%s in %dms\n", __func__, jiffies_to_msecs(jiffies - init_start_time)); return status; -- cgit v1.2.3 From 900a3260fb2ebefdf0ed796e87cdb78e72d55b1e Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:41 +0200 Subject: staging: rtl8723au: rtl8732au_hal_init.c: Use rtl8723au_BT_coexist() to pick firmware image Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 970b5858aad0..dc97885669a3 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -309,15 +309,15 @@ int rtl8723a_FirmwareDownload(struct rtw_adapter *padapter) DBG_8723A(" Rtl8723_FwUMCBCutImageArrayWithoutBT for " "RTL8723A B CUT\n"); } else { -#ifdef CONFIG_8723AU_BT_COEXIST - fw_name = "rtlwifi/rtl8723aufw_B.bin"; - DBG_8723A(" Rtl8723_FwUMCBCutImageArrayWithBT for " - "RTL8723A B CUT\n"); -#else - fw_name = "rtlwifi/rtl8723aufw_B_NoBT.bin"; - DBG_8723A(" Rtl8723_FwUMCBCutImageArrayWithoutBT for " - "RTL8723A B CUT\n"); -#endif + if (rtl8723a_BT_coexist(padapter)) { + fw_name = "rtlwifi/rtl8723aufw_B.bin"; + DBG_8723A(" Rtl8723_FwUMCBCutImageArrayWithBT " + "for RTL8723A B CUT\n"); + } else { + fw_name = "rtlwifi/rtl8723aufw_B_NoBT.bin"; + DBG_8723A(" Rtl8723_FwUMCBCutImageArrayWithout " + "BT for RTL8723A B CUT\n"); + } } } else { /* We should download proper RAM Code here -- cgit v1.2.3 From c814d4d6df4a4d8a6ddd4518020ba30504182161 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:42 +0200 Subject: staging: rtl8723au: Rename BT_WifiAssociateNotify() rtl8723a_BT_wifiassociate_notify() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 2 +- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 6 ++---- drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h | 2 -- drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h | 2 ++ 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index 30506073a56c..ed084d100e5c 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -145,7 +145,7 @@ void rtl8723a_BT_wifiscan_notify(struct rtw_adapter *padapter, u8 scanType) BTDM_WifiScanNotify(padapter, scanType); } -void BT_WifiAssociateNotify(struct rtw_adapter *padapter, u8 action) +void rtl8723a_BT_wifiassociate_notify(struct rtw_adapter *padapter, u8 action) { /* action : */ /* true = associate start */ diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index dc97885669a3..f13a21c53e3b 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -2558,20 +2558,18 @@ void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type) RetryLimit << RETRY_LIMIT_SHORT_SHIFT | RetryLimit << RETRY_LIMIT_LONG_SHIFT); -#ifdef CONFIG_8723AU_BT_COEXIST switch (type) { case 0: /* prepare to join */ - BT_WifiAssociateNotify(padapter, true); + rtl8723a_BT_wifiassociate_notify(padapter, true); break; case 1: /* joinbss_event callback when join res < 0 */ - BT_WifiAssociateNotify(padapter, false); + rtl8723a_BT_wifiassociate_notify(padapter, false); break; case 2: /* sta add event callback */ /* BT_WifiMediaStatusNotify(padapter, RT_MEDIA_CONNECT); */ break; } -#endif } diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h index 8ab56d8b1e72..eff40214b6d6 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h @@ -31,8 +31,6 @@ enum rt_media_status { void BT_SignalCompensation(struct rtw_adapter *padapter, u8 *rssi_wifi, u8 *rssi_bt); -void BT_WifiAssociateNotify(struct rtw_adapter *padapter, u8 action); -void BT_SpecialPacketNotify(struct rtw_adapter * padapter); void BT_HaltProcess(struct rtw_adapter * padapter); void BT_LpsLeave(struct rtw_adapter * padapter); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h index 98bea65a8478..ff9ad3f1d510 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h @@ -33,6 +33,7 @@ void rtl8723a_BT_disable_coexist(struct rtw_adapter *padapter); bool rtl8723a_BT_disable_EDCA_turbo(struct rtw_adapter *padapter); void rtl8723a_dual_antenna_detection(struct rtw_adapter *padapter); void rtl8723a_BT_init_hwconfig(struct rtw_adapter *padapter); +void rtl8723a_BT_wifiassociate_notify(struct rtw_adapter *padapter, u8 action); #else static inline bool rtl8723a_BT_using_antenna_1(struct rtw_adapter *padapter) { @@ -58,6 +59,7 @@ static inline bool rtl8723a_BT_disable_EDCA_turbo(struct rtw_adapter *padapter) } #define rtl8723a_dual_antenna_detection(padapter) do {} while(0) #define rtl8723a_BT_init_hwconfig(padapter) do {} while(0) +#define rtl8723a_BT_wifiassociate_notify(padapter, action) do {} while(0) #endif #endif -- cgit v1.2.3 From ec6d68713434a1cd2a8f1917396399ebe8d02177 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:43 +0200 Subject: staging: rtl8723au: Make rtl8723a_set_BTCoex_AP_mode_FwRsvdPkt_cmd() a no-op when no co-exist enabled Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 2 -- drivers/staging/rtl8723au/include/rtl8723a_cmd.h | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index f13a21c53e3b..fb364d1ba3a4 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -2395,10 +2395,8 @@ void hw_var_set_opmode(struct rtw_adapter *padapter, u8 mode) val8 = DIS_TSF_UDT | EN_BCN_FUNCTION | DIS_BCNQ_SUB; SetBcnCtrlReg23a(padapter, val8, ~val8); } else if (mode == _HW_STATE_AP_) { -#ifdef CONFIG_8723AU_BT_COEXIST /* add NULL Data and BT NULL Data Packets to FW RSVD Page */ rtl8723a_set_BTCoex_AP_mode_FwRsvdPkt_cmd(padapter); -#endif ResumeTxBeacon(padapter); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_cmd.h b/drivers/staging/rtl8723au/include/rtl8723a_cmd.h index 3a15c9e8628b..900baccc3c24 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_cmd.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_cmd.h @@ -146,6 +146,8 @@ void rtl8723a_set_FwPwrMode_cmd(struct rtw_adapter *padapter, u8 Mode); void rtl8723a_set_FwJoinBssReport_cmd(struct rtw_adapter *padapter, u8 mstatus); #ifdef CONFIG_8723AU_BT_COEXIST void rtl8723a_set_BTCoex_AP_mode_FwRsvdPkt_cmd(struct rtw_adapter *padapter); +#else +#define rtl8723a_set_BTCoex_AP_mode_FwRsvdPkt_cmd(padapter) do {} while(0) #endif int rtl8723a_set_rssi_cmd(struct rtw_adapter *padapter, u8 *param); int rtl8723a_set_raid_cmd(struct rtw_adapter *padapter, u32 mask, u8 arg); -- cgit v1.2.3 From 9b2d4aeaa83261dcb0eaad26700e9eaf973b7b1a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:44 +0200 Subject: staging: rtl8723au: Rename HALBT_InitBTVars8723A() rtl8723a_BT_init_hal_vars() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 2 +- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 5 ++--- drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h | 3 --- drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h | 2 ++ 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index ed084d100e5c..5aa9ea5a22b9 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -11278,7 +11278,7 @@ void HALBT_RemoveKey(struct rtw_adapter *padapter, u8 EntryNum) } } -void HALBT_InitBTVars8723A(struct rtw_adapter *padapter) +void rtl8723a_BT_init_hal_vars(struct rtw_adapter *padapter) { struct hal_data_8723a *pHalData; diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index fb364d1ba3a4..7798532d3dfb 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1943,9 +1943,8 @@ Hal_EfuseParseBTCoexistInfo_8723A(struct rtw_adapter *padapter, pHalData->EEPROMBluetoothAntIsolation = 0; pHalData->EEPROMBluetoothRadioShared = BT_Radio_Shared; } -#ifdef CONFIG_8723AU_BT_COEXIST - BT_InitHalVars(padapter); -#endif + + rtl8723a_BT_init_hal_vars(padapter); } void diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h index eff40214b6d6..36376190cfdf 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h @@ -1605,9 +1605,6 @@ u8 HALBT_GetPGAntNum(struct rtw_adapter * padapter); #define BT_GetPGAntNum HALBT_GetPGAntNum void HALBT_SetKey(struct rtw_adapter * padapter, u8 EntryNum); void HALBT_RemoveKey(struct rtw_adapter * padapter, u8 EntryNum); -void HALBT_InitBTVars8723A(struct rtw_adapter * padapter); -#define HALBT_InitHalVars HALBT_InitBTVars8723A -#define BT_InitHalVars HALBT_InitHalVars u8 HALBT_IsBTExist(struct rtw_adapter * padapter); #define BT_IsBtExist HALBT_IsBTExist u8 HALBT_BTChipType(struct rtw_adapter * padapter); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h index ff9ad3f1d510..fdcee7569027 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h @@ -34,6 +34,7 @@ bool rtl8723a_BT_disable_EDCA_turbo(struct rtw_adapter *padapter); void rtl8723a_dual_antenna_detection(struct rtw_adapter *padapter); void rtl8723a_BT_init_hwconfig(struct rtw_adapter *padapter); void rtl8723a_BT_wifiassociate_notify(struct rtw_adapter *padapter, u8 action); +void rtl8723a_BT_init_hal_vars(struct rtw_adapter *padapter); #else static inline bool rtl8723a_BT_using_antenna_1(struct rtw_adapter *padapter) { @@ -60,6 +61,7 @@ static inline bool rtl8723a_BT_disable_EDCA_turbo(struct rtw_adapter *padapter) #define rtl8723a_dual_antenna_detection(padapter) do {} while(0) #define rtl8723a_BT_init_hwconfig(padapter) do {} while(0) #define rtl8723a_BT_wifiassociate_notify(padapter, action) do {} while(0) +#define rtl8723a_BT_init_hal_vars(padapter) do {} while(0) #endif #endif -- cgit v1.2.3 From d5a1427b5d51b75ecec1c53b14f0caee198ef329 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:45 +0200 Subject: staging: rtl8723au: rtl8723a_bt-coexist.c: Remove unnecessary #ifdef CONFIG_8723AU_BT_COEXIST This file is only compiled if CONFIG_8723AU_BT_COEXIST=y Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index 5aa9ea5a22b9..c1d54bcf5be7 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -19,8 +19,6 @@ #define DIS_PS_RX_BCN -#ifdef CONFIG_8723AU_BT_COEXIST - u32 BTCoexDbgLevel = _bt_dbg_off_; #define RTPRINT(_Comp, _Level, Fmt)\ @@ -71,7 +69,6 @@ if ((BTCoexDbgLevel == _bt_dbg_on_)) {\ printk(_TitleString); \ printk(": %d, <%s>\n", _Len, buffer); \ } -#endif #define DCMD_Printf(...) #define RT_ASSERT(...) -- cgit v1.2.3 From 1d599de6b967964125540509fe66c5387fefa48f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:46 +0200 Subject: staging: rtl8723au: Rename BTDM_FwC2hBtInfo8723A() to rtl8723a_fw_c2h_BT_info() In addition get rid of some pointless code obfuscating wrappers Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 9 ++------- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 5 ++--- drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h | 2 -- drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h | 2 ++ 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index c1d54bcf5be7..c00105389090 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -9396,8 +9396,8 @@ static void BTDM_FwC2hBtRssi8723A(struct rtw_adapter *padapter, u8 *tmpBuf) /*RTPRINT(FBT, BT_TRACE, ("[BTC2H], BT RSSI =%d\n", percent)); */ } -static void -BTDM_FwC2hBtInfo8723A(struct rtw_adapter *padapter, u8 *tmpBuf, u8 length) +void +rtl8723a_fw_c2h_BT_info(struct rtw_adapter *padapter, u8 *tmpBuf, u8 length) { struct hal_data_8723a *pHalData; struct bt_30info *pBTInfo; @@ -10131,11 +10131,6 @@ void BTDM_FwC2hBtRssi(struct rtw_adapter *padapter, u8 *tmpBuf) BTDM_FwC2hBtRssi8723A(padapter, tmpBuf); } -void BTDM_FwC2hBtInfo(struct rtw_adapter *padapter, u8 *tmpBuf, u8 length) -{ - BTDM_FwC2hBtInfo8723A(padapter, tmpBuf, length); -} - void BTDM_DisplayBtCoexInfo(struct rtw_adapter *padapter) { BTDM_Display8723ABtCoexInfo(padapter); diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 7798532d3dfb..487629c198ff 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -1202,12 +1202,11 @@ int c2h_handler_8723a(struct rtw_adapter *padapter, struct c2h_evt_hdr *c2h_evt) c2h_evt->payload[3], c2h_evt->payload[4])); break; -#ifdef CONFIG_8723AU_BT_COEXIST case C2H_BT_INFO: DBG_8723A("%s , Got C2H_BT_INFO \n", __func__); - BT_FwC2hBtInfo(padapter, c2h_evt->payload, c2h_evt->plen); + rtl8723a_fw_c2h_BT_info(padapter, + c2h_evt->payload, c2h_evt->plen); break; -#endif default: ret = _FAIL; diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h index 36376190cfdf..2a6a1005d6cf 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h @@ -1543,8 +1543,6 @@ struct bt_coexist_str { void BTDM_CheckAntSelMode(struct rtw_adapter * padapter); void BTDM_FwC2hBtRssi(struct rtw_adapter * padapter, u8 *tmpBuf); #define BT_FwC2hBtRssi BTDM_FwC2hBtRssi -void BTDM_FwC2hBtInfo(struct rtw_adapter * padapter, u8 *tmpBuf, u8 length); -#define BT_FwC2hBtInfo BTDM_FwC2hBtInfo void BTDM_DisplayBtCoexInfo(struct rtw_adapter * padapter); #define BT_DisplayBtCoexInfo BTDM_DisplayBtCoexInfo void BTDM_RejectAPAggregatedPacket(struct rtw_adapter * padapter, u8 bReject); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h index fdcee7569027..4733559970e5 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt_intf.h @@ -35,6 +35,7 @@ void rtl8723a_dual_antenna_detection(struct rtw_adapter *padapter); void rtl8723a_BT_init_hwconfig(struct rtw_adapter *padapter); void rtl8723a_BT_wifiassociate_notify(struct rtw_adapter *padapter, u8 action); void rtl8723a_BT_init_hal_vars(struct rtw_adapter *padapter); +void rtl8723a_fw_c2h_BT_info(struct rtw_adapter *padapter, u8 *tmpBuf, u8 length); #else static inline bool rtl8723a_BT_using_antenna_1(struct rtw_adapter *padapter) { @@ -62,6 +63,7 @@ static inline bool rtl8723a_BT_disable_EDCA_turbo(struct rtw_adapter *padapter) #define rtl8723a_BT_init_hwconfig(padapter) do {} while(0) #define rtl8723a_BT_wifiassociate_notify(padapter, action) do {} while(0) #define rtl8723a_BT_init_hal_vars(padapter) do {} while(0) +#define rtl8723a_fw_c2h_BT_info(padapter, tmpBuf, length) do {} while(0) #endif #endif -- cgit v1.2.3 From 13aa75858bff8ae0799f40ab2b37dfa912f8947c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:47 +0200 Subject: staging: rtl8723au: Remove unused struct btdata_info Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h index 2a6a1005d6cf..05069652bae1 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_bt-coexist.h @@ -1086,12 +1086,6 @@ enum hci_ext_bp_operation { HCI_BT_OP_MAX }; -/* Function proto type */ -struct btdata_entry { - struct list_head List; - void *pDataBlock; -}; - #define BTHCI_SM_WITH_INFO(_Adapter, _StateToEnter, _StateCmd, _EntryNum) \ { \ RTPRINT(FIOCTL, IOCTL_STATE, ("[BT state change] caused by ""%s"", line =%d\n", __func__, __LINE__)); \ -- cgit v1.2.3 From ef71c9b86d392f025b7c46cea6dcafea0f750fc1 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Sun, 25 May 2014 22:43:48 +0200 Subject: staging: rtl8723au: _InitQueueReservedPage(): Remove pointless brackets Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_halinit.c | 40 +++++++++++++---------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 2032b5efbf56..6a7fb28e03da 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -150,33 +150,29 @@ static void _InitQueueReservedPage(struct rtw_adapter *Adapter) u32 value32; u8 value8; bool bWiFiConfig = pregistrypriv->wifi_spec; - /* u32 txQPageNum, txQPageUnit, txQRemainPage; */ - { /* for WMM */ - /* RT_ASSERT((outEPNum>= 2), ("for WMM , number of out-ep " - "must more than or equal to 2!\n")); */ + /* RT_ASSERT((outEPNum>= 2), ("for WMM , number of out-ep " + "must more than or equal to 2!\n")); */ - numPubQ = bWiFiConfig ? - WMM_NORMAL_PAGE_NUM_PUBQ : NORMAL_PAGE_NUM_PUBQ; + numPubQ = bWiFiConfig ? WMM_NORMAL_PAGE_NUM_PUBQ : NORMAL_PAGE_NUM_PUBQ; - if (pHalData->OutEpQueueSel & TX_SELE_HQ) { - numHQ = bWiFiConfig ? - WMM_NORMAL_PAGE_NUM_HPQ : NORMAL_PAGE_NUM_HPQ; - } + if (pHalData->OutEpQueueSel & TX_SELE_HQ) { + numHQ = bWiFiConfig ? + WMM_NORMAL_PAGE_NUM_HPQ : NORMAL_PAGE_NUM_HPQ; + } - if (pHalData->OutEpQueueSel & TX_SELE_LQ) { - numLQ = bWiFiConfig ? - WMM_NORMAL_PAGE_NUM_LPQ : NORMAL_PAGE_NUM_LPQ; - } - /* NOTE: This step shall be proceed before - writting REG_RQPN. */ - if (pHalData->OutEpQueueSel & TX_SELE_NQ) { - numNQ = bWiFiConfig ? - WMM_NORMAL_PAGE_NUM_NPQ : NORMAL_PAGE_NUM_NPQ; - } - value8 = (u8)_NPQ(numNQ); - rtl8723au_write8(Adapter, REG_RQPN_NPQ, value8); + if (pHalData->OutEpQueueSel & TX_SELE_LQ) { + numLQ = bWiFiConfig ? + WMM_NORMAL_PAGE_NUM_LPQ : NORMAL_PAGE_NUM_LPQ; + } + /* NOTE: This step shall be proceed before + writting REG_RQPN. */ + if (pHalData->OutEpQueueSel & TX_SELE_NQ) { + numNQ = bWiFiConfig ? + WMM_NORMAL_PAGE_NUM_NPQ : NORMAL_PAGE_NUM_NPQ; } + value8 = (u8)_NPQ(numNQ); + rtl8723au_write8(Adapter, REG_RQPN_NPQ, value8); /* TX DMA */ value32 = _HPQ(numHQ) | _LPQ(numLQ) | _PUBQ(numPubQ) | LD_RQPN; -- cgit v1.2.3 From 9c73b46af4f74c255fbc26edebef8b2a61f2b7e4 Mon Sep 17 00:00:00 2001 From: Chaitanya Hazarey Date: Sun, 25 May 2014 21:58:43 -0700 Subject: Staging: Silicom: bpctl_mod.c & bypass.c: Adding blank lines Added a blank line after declarations in many places to fix the following warning issued by checkpatch.pl: WARNING: Missing a blank line after declarations Signed-off-by: Chaitanya Hazarey Signed-off-by: Greg Kroah-Hartman --- drivers/staging/silicom/bpctl_mod.c | 88 +++++++++++++++++++++++++++++- drivers/staging/silicom/bypasslib/bypass.c | 2 + 2 files changed, 88 insertions(+), 2 deletions(-) diff --git a/drivers/staging/silicom/bpctl_mod.c b/drivers/staging/silicom/bpctl_mod.c index e361cde0ec69..22bf4bf03993 100644 --- a/drivers/staging/silicom/bpctl_mod.c +++ b/drivers/staging/silicom/bpctl_mod.c @@ -752,6 +752,7 @@ static void write_reg(struct bpctl_dev *pbpctl_dev, unsigned char value, uint32_t ctrl_ext = 0, ctrl = 0; struct bpctl_dev *pbpctl_dev_c = NULL; unsigned long flags; + if (pbpctl_dev->bp_10g9) { pbpctl_dev_c = get_status_port_fn(pbpctl_dev); if (!pbpctl_dev_c) @@ -927,6 +928,7 @@ static int read_reg(struct bpctl_dev *pbpctl_dev, unsigned char addr) #ifdef BP_SYNC_FLAG unsigned long flags; + spin_lock_irqsave(&pbpctl_dev->bypass_wr_lock, flags); #else atomic_set(&pbpctl_dev->wdt_busy, 1); @@ -1563,6 +1565,7 @@ int pulse_set_fn(struct bpctl_dev *pbpctl_dev, unsigned int counter) int zero_set_fn(struct bpctl_dev *pbpctl_dev) { uint32_t ctrl_ext = 0, ctrl_value = 0; + if (!pbpctl_dev) return -1; @@ -1588,6 +1591,7 @@ int zero_set_fn(struct bpctl_dev *pbpctl_dev) int pulse_get2_fn(struct bpctl_dev *pbpctl_dev) { uint32_t ctrl_ext = 0, ctrl_value = 0; + if (!pbpctl_dev) return -1; @@ -1603,6 +1607,7 @@ int pulse_get2_fn(struct bpctl_dev *pbpctl_dev) int pulse_get1_fn(struct bpctl_dev *pbpctl_dev) { uint32_t ctrl_ext = 0, ctrl_value = 0; + if (!pbpctl_dev) return -1; @@ -1666,6 +1671,7 @@ static struct bpctl_dev *lookup_port(struct bpctl_dev *dev) { struct bpctl_dev *p; int n; + for (n = 0, p = bpctl_dev_arr; n < device_num && p->pdev; n++) { if (p->bus == dev->bus && p->slot == dev->slot @@ -1843,6 +1849,7 @@ static int bypass_off(struct bpctl_dev *pbpctl_dev) static int tap_off(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; + if ((pbpctl_dev->bp_caps & TAP_CAP) && (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER)) { write_data(pbpctl_dev, TAP_OFF); @@ -1856,6 +1863,7 @@ static int tap_off(struct bpctl_dev *pbpctl_dev) static int tap_on(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; + if ((pbpctl_dev->bp_caps & TAP_CAP) && (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER)) { write_data(pbpctl_dev, TAP_ON); @@ -1869,6 +1877,7 @@ static int tap_on(struct bpctl_dev *pbpctl_dev) static int disc_off(struct bpctl_dev *pbpctl_dev) { int ret = 0; + if ((pbpctl_dev->bp_caps & DISC_CAP) && (pbpctl_dev->bp_ext_ver >= 0x8)) { write_data(pbpctl_dev, DISC_OFF); msec_delay_bp(LATCH_DELAY); @@ -1881,6 +1890,7 @@ static int disc_off(struct bpctl_dev *pbpctl_dev) static int disc_on(struct bpctl_dev *pbpctl_dev) { int ret = 0; + if ((pbpctl_dev->bp_caps & DISC_CAP) && (pbpctl_dev->bp_ext_ver >= 0x8)) { write_data(pbpctl_dev, /*DISC_ON */ 0x85); msec_delay_bp(LATCH_DELAY); @@ -2270,6 +2280,7 @@ static int set_tx(struct bpctl_dev *pbpctl_dev, int tx_state) { int ret = 0, ctrl = 0; struct bpctl_dev *pbpctl_dev_m; + if ((is_bypass_fn(pbpctl_dev)) == 1) pbpctl_dev_m = pbpctl_dev; else @@ -2802,6 +2813,7 @@ int wdt_time_left(struct bpctl_dev *pbpctl_dev) static int wdt_timer(struct bpctl_dev *pbpctl_dev, int *time_left) { int ret = 0; + if (pbpctl_dev->bp_caps & WD_CTL_CAP) { { if (pbpctl_dev->wdt_status == WDT_STATUS_UNKNOWN) @@ -3014,6 +3026,7 @@ static int tx_status(struct bpctl_dev *pbpctl_dev) { uint32_t ctrl = 0; struct bpctl_dev *pbpctl_dev_m; + if ((is_bypass_fn(pbpctl_dev)) == 1) pbpctl_dev_m = pbpctl_dev; else @@ -3195,6 +3208,7 @@ static int bypass_change_status(struct bpctl_dev *pbpctl_dev) static int bypass_status(struct bpctl_dev *pbpctl_dev) { u32 ctrl_ext = 0; + if (pbpctl_dev->bp_caps & BP_CAP) { struct bpctl_dev *pbpctl_dev_b = NULL; @@ -3323,6 +3337,7 @@ static int dis_bypass_cap_status(struct bpctl_dev *pbpctl_dev) static int wdt_programmed(struct bpctl_dev *pbpctl_dev, int *timeout) { int ret = 0; + if (pbpctl_dev->bp_caps & WD_CTL_CAP) { if (pbpctl_dev->bp_ext_ver >= PXG2BPI_VER) { if ((read_reg(pbpctl_dev, STATUS_REG_ADDR)) & @@ -3386,6 +3401,7 @@ static int tap_flag_status(struct bpctl_dev *pbpctl_dev) static int tap_flag_status_clear(struct bpctl_dev *pbpctl_dev) { uint32_t status_reg = 0; + if (pbpctl_dev->bp_caps & TAP_STATUS_CAP) { if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) { status_reg = read_reg(pbpctl_dev, STATUS_TAP_REG_ADDR); @@ -3400,6 +3416,7 @@ static int tap_flag_status_clear(struct bpctl_dev *pbpctl_dev) static int tap_change_status(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; + if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) { if (pbpctl_dev->bp_caps & TAP_CAP) { if (pbpctl_dev->bp_caps & BP_CAP) { @@ -3490,6 +3507,7 @@ static int disc_flag_status(struct bpctl_dev *pbpctl_dev) static int disc_flag_status_clear(struct bpctl_dev *pbpctl_dev) { uint32_t status_reg = 0; + if (pbpctl_dev->bp_caps & DISC_CAP) { if (pbpctl_dev->bp_ext_ver >= 0x8) { status_reg = read_reg(pbpctl_dev, STATUS_DISC_REG_ADDR); @@ -3504,6 +3522,7 @@ static int disc_flag_status_clear(struct bpctl_dev *pbpctl_dev) static int disc_change_status(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; + if (pbpctl_dev->bp_caps & DISC_CAP) { ret = disc_flag_status(pbpctl_dev); disc_flag_status_clear(pbpctl_dev); @@ -3599,6 +3618,7 @@ static int disc_off_status(struct bpctl_dev *pbpctl_dev) static int disc_status(struct bpctl_dev *pbpctl_dev) { int ctrl = 0; + if (pbpctl_dev->bp_caps & DISC_CAP) { ctrl = disc_off_status(pbpctl_dev); if (ctrl < 0) @@ -3744,6 +3764,7 @@ static void bypass_caps_init(struct bpctl_dev *pbpctl_dev) #ifdef BYPASS_DEBUG int ret = 0; + if (!(INTEL_IF_SERIES(adapter->bp_device_block.subdevice))) { ret = read_reg(pbpctl_dev, VER_REG_ADDR); printk("VER_REG reg1=%x\n", ret); @@ -4155,6 +4176,7 @@ static int get_bypass_change_fn(struct bpctl_dev *pbpctl_dev) static int set_dis_bypass_fn(struct bpctl_dev *pbpctl_dev, int dis_param) { int ret = 0; + if (!pbpctl_dev) return -1; @@ -4182,6 +4204,7 @@ static int get_dis_bypass_fn(struct bpctl_dev *pbpctl_dev) static int set_bypass_pwoff_fn(struct bpctl_dev *pbpctl_dev, int bypass_mode) { int ret = 0; + if (!pbpctl_dev) return -1; @@ -4209,6 +4232,7 @@ static int get_bypass_pwoff_fn(struct bpctl_dev *pbpctl_dev) static int set_bypass_pwup_fn(struct bpctl_dev *pbpctl_dev, int bypass_mode) { int ret = 0; + if (!pbpctl_dev) return -1; @@ -4236,6 +4260,7 @@ static int get_bypass_pwup_fn(struct bpctl_dev *pbpctl_dev) static int set_bypass_wd_fn(struct bpctl_dev *pbpctl_dev, int timeout) { int ret = 0; + if (!pbpctl_dev) return -1; @@ -4282,8 +4307,8 @@ static int reset_bypass_wd_timer_fn(struct bpctl_dev *pbpctl_dev) static int get_wd_set_caps_fn(struct bpctl_dev *pbpctl_dev) { int bp_status = 0; - unsigned int step_value = TIMEOUT_MAX_STEP + 1, bit_cnt = 0; + if (!pbpctl_dev) return -1; @@ -4306,6 +4331,7 @@ static int get_wd_set_caps_fn(struct bpctl_dev *pbpctl_dev) static int set_std_nic_fn(struct bpctl_dev *pbpctl_dev, int nic_mode) { int ret = 0; + if (!pbpctl_dev) return -1; @@ -4358,6 +4384,7 @@ static int get_tap_fn(struct bpctl_dev *pbpctl_dev) static int set_tap_pwup_fn(struct bpctl_dev *pbpctl_dev, int tap_mode) { int ret = 0; + if (!pbpctl_dev) return -1; @@ -4376,6 +4403,7 @@ static int set_tap_pwup_fn(struct bpctl_dev *pbpctl_dev, int tap_mode) static int get_tap_pwup_fn(struct bpctl_dev *pbpctl_dev) { int ret = 0; + if (!pbpctl_dev) return -1; @@ -4396,6 +4424,7 @@ static int get_tap_change_fn(struct bpctl_dev *pbpctl_dev) static int set_dis_tap_fn(struct bpctl_dev *pbpctl_dev, int dis_param) { int ret = 0; + if (!pbpctl_dev) return -1; @@ -4438,6 +4467,7 @@ static int set_disc_fn(struct bpctl_dev *pbpctl_dev, int disc_mode) static int get_disc_fn(struct bpctl_dev *pbpctl_dev) { int ret = 0; + if (!pbpctl_dev) return -1; @@ -4449,6 +4479,7 @@ static int get_disc_fn(struct bpctl_dev *pbpctl_dev) static int set_disc_pwup_fn(struct bpctl_dev *pbpctl_dev, int disc_mode) { int ret = 0; + if (!pbpctl_dev) return -1; @@ -4467,6 +4498,7 @@ static int set_disc_pwup_fn(struct bpctl_dev *pbpctl_dev, int disc_mode) static int get_disc_pwup_fn(struct bpctl_dev *pbpctl_dev) { int ret = 0; + if (!pbpctl_dev) return -1; @@ -4477,6 +4509,7 @@ static int get_disc_pwup_fn(struct bpctl_dev *pbpctl_dev) static int get_disc_change_fn(struct bpctl_dev *pbpctl_dev) { int ret = 0; + if (!pbpctl_dev) return -1; @@ -4487,6 +4520,7 @@ static int get_disc_change_fn(struct bpctl_dev *pbpctl_dev) static int set_dis_disc_fn(struct bpctl_dev *pbpctl_dev, int dis_param) { int ret = 0; + if (!pbpctl_dev) return -1; @@ -4505,6 +4539,7 @@ static int set_dis_disc_fn(struct bpctl_dev *pbpctl_dev, int dis_param) static int get_dis_disc_fn(struct bpctl_dev *pbpctl_dev) { int ret = 0; + if (!pbpctl_dev) return -1; @@ -4531,8 +4566,8 @@ static int set_wd_exp_mode_fn(struct bpctl_dev *pbpctl_dev, int param) static int set_tx_fn(struct bpctl_dev *pbpctl_dev, int tx_state) { - struct bpctl_dev *pbpctl_dev_b = NULL; + if (!pbpctl_dev) return -1; @@ -4610,6 +4645,7 @@ static int get_bypass_slave_fn(struct bpctl_dev *pbpctl_dev, struct bpctl_dev **pbpctl_dev_out) { int idx_dev = 0; + if (!pbpctl_dev) return -1; @@ -4653,6 +4689,7 @@ static int is_bypass(struct bpctl_dev *pbpctl_dev) static int get_tx_fn(struct bpctl_dev *pbpctl_dev) { struct bpctl_dev *pbpctl_dev_b = NULL; + if (!pbpctl_dev) return -1; @@ -4812,6 +4849,7 @@ static int set_tpl_fn(struct bpctl_dev *pbpctl_dev, int tpl_mode) static int get_tpl_fn(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; + if (!pbpctl_dev) return -1; @@ -4846,6 +4884,7 @@ static int set_bp_wait_at_pwup_fn(struct bpctl_dev *pbpctl_dev, int tap_mode) static int get_bp_wait_at_pwup_fn(struct bpctl_dev *pbpctl_dev) { int ret = 0; + if (!pbpctl_dev) return -1; @@ -4879,6 +4918,7 @@ static int set_bp_hw_reset_fn(struct bpctl_dev *pbpctl_dev, int tap_mode) static int get_bp_hw_reset_fn(struct bpctl_dev *pbpctl_dev) { int ret = 0; + if (!pbpctl_dev) return -1; @@ -4906,6 +4946,7 @@ static int get_bypass_info_fn(struct bpctl_dev *pbpctl_dev, char *dev_name, static int get_dev_idx_bsf(int bus, int slot, int func) { int idx_dev = 0; + for (idx_dev = 0; ((bpctl_dev_arr[idx_dev].pdev != NULL) && (idx_dev < device_num)); idx_dev++) { @@ -6401,6 +6442,7 @@ static int __init bypass_init_module(void) static void __exit bypass_cleanup_module(void) { int i; + unregister_netdevice_notifier(&bp_notifier_block); for (i = 0; i < device_num; i++) { @@ -6705,6 +6747,7 @@ int get_bypass_slave_sd(int ifindex) { struct bpctl_dev *pbpctl_dev_out; int ret = get_bypass_slave_fn(get_dev_idx_p(ifindex), &pbpctl_dev_out); + if (ret == 1) return pbpctl_dev_out->ifindex; return -1; @@ -6754,6 +6797,7 @@ static int procfs_add(char *proc_name, const struct file_operations *fops, struct bpctl_dev *dev) { struct bypass_pfs_sd *pfs = &dev->bypass_pfs_set; + if (!proc_create_data(proc_name, 0644, pfs->bypass_entry, fops, dev)) return -1; return 0; @@ -6798,6 +6842,7 @@ static int show_bypass_slave(struct seq_file *m, void *v) { struct bpctl_dev *dev = m->private; struct bpctl_dev *slave = get_status_port_fn(dev); + if (!slave) slave = dev; if (!slave) @@ -6812,6 +6857,7 @@ static int show_bypass_caps(struct seq_file *m, void *v) { struct bpctl_dev *dev = m->private; int ret = get_bypass_caps_fn(dev); + if (ret == BP_NOT_CAP) seq_puts(m, "-1\n"); else @@ -6824,6 +6870,7 @@ static int show_wd_set_caps(struct seq_file *m, void *v) { struct bpctl_dev *dev = m->private; int ret = get_wd_set_caps_fn(dev); + if (ret == BP_NOT_CAP) seq_puts(m, "-1\n"); else @@ -6860,6 +6907,7 @@ static ssize_t bypass_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { int bypass_param = user_on_off(buffer, count); + if (bypass_param < 0) return -1; @@ -6870,6 +6918,7 @@ static int show_bypass(struct seq_file *m, void *v) { struct bpctl_dev *dev = m->private; int ret = get_bypass_fn(dev); + if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); else if (ret == 1) @@ -6884,6 +6933,7 @@ static ssize_t tap_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { int tap_param = user_on_off(buffer, count); + if (tap_param < 0) return -1; @@ -6894,6 +6944,7 @@ static int show_tap(struct seq_file *m, void *v) { struct bpctl_dev *dev = m->private; int ret = get_tap_fn(dev); + if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); else if (ret == 1) @@ -6908,6 +6959,7 @@ static ssize_t disc_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { int tap_param = user_on_off(buffer, count); + if (tap_param < 0) return -1; @@ -6918,6 +6970,7 @@ static int show_disc(struct seq_file *m, void *v) { struct bpctl_dev *dev = m->private; int ret = get_disc_fn(dev); + if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); else if (ret == 1) @@ -6932,6 +6985,7 @@ static int show_bypass_change(struct seq_file *m, void *v) { struct bpctl_dev *dev = m->private; int ret = get_bypass_change_fn(dev); + if (ret == 1) seq_puts(m, "on\n"); else if (ret == 0) @@ -6946,6 +7000,7 @@ static int show_tap_change(struct seq_file *m, void *v) { struct bpctl_dev *dev = m->private; int ret = get_tap_change_fn(dev); + if (ret == 1) seq_puts(m, "on\n"); else if (ret == 0) @@ -6960,6 +7015,7 @@ static int show_disc_change(struct seq_file *m, void *v) { struct bpctl_dev *dev = m->private; int ret = get_disc_change_fn(dev); + if (ret == 1) seq_puts(m, "on\n"); else if (ret == 0) @@ -6976,6 +7032,7 @@ static ssize_t bypass_wd_write(struct file *file, const char __user *buffer, struct bpctl_dev *dev = PDE_DATA(file_inode(file)); int timeout; int ret = kstrtoint_from_user(buffer, count, 10, &timeout); + if (ret) return ret; set_bypass_wd_fn(dev, timeout); @@ -7003,6 +7060,7 @@ static int show_wd_expire_time(struct seq_file *m, void *v) { struct bpctl_dev *dev = m->private; int ret = 0, timeout = 0; + ret = get_wd_expire_time_fn(dev, &timeout); if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); @@ -7021,6 +7079,7 @@ static ssize_t tpl_write(struct file *file, const char __user *buffer, { struct bpctl_dev *dev = PDE_DATA(file_inode(file)); int tpl_param = user_on_off(buffer, count); + if (tpl_param < 0) return -1; @@ -7031,6 +7090,7 @@ static int show_tpl(struct seq_file *m, void *v) { struct bpctl_dev *dev = m->private; int ret = get_tpl_fn(dev); + if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); else if (ret == 1) @@ -7047,6 +7107,7 @@ static ssize_t wait_at_pwup_write(struct file *file, const char __user *buffer, { struct bpctl_dev *dev = PDE_DATA(file_inode(file)); int tpl_param = user_on_off(buffer, count); + if (tpl_param < 0) return -1; @@ -7057,6 +7118,7 @@ static int show_wait_at_pwup(struct seq_file *m, void *v) { struct bpctl_dev *dev = m->private; int ret = get_bp_wait_at_pwup_fn(dev); + if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); else if (ret == 1) @@ -7072,6 +7134,7 @@ static ssize_t hw_reset_write(struct file *file, const char __user *buffer, { struct bpctl_dev *dev = PDE_DATA(file_inode(file)); int tpl_param = user_on_off(buffer, count); + if (tpl_param < 0) return -1; @@ -7082,6 +7145,7 @@ static int show_hw_reset(struct seq_file *m, void *v) { struct bpctl_dev *dev = m->private; int ret = get_bp_hw_reset_fn(dev); + if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); else if (ret == 1) @@ -7098,6 +7162,7 @@ static int show_reset_bypass_wd(struct seq_file *m, void *v) { struct bpctl_dev *dev = m->private; int ret = reset_bypass_wd_timer_fn(dev); + if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); else if (ret == 0) @@ -7112,6 +7177,7 @@ static ssize_t dis_bypass_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { int bypass_param = user_on_off(buffer, count); + if (bypass_param < 0) return -EINVAL; @@ -7122,6 +7188,7 @@ static int show_dis_bypass(struct seq_file *m, void *v) { struct bpctl_dev *dev = m->private; int ret = get_dis_bypass_fn(dev); + if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); else if (ret == 0) @@ -7136,6 +7203,7 @@ static ssize_t dis_tap_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { int tap_param = user_on_off(buffer, count); + if (tap_param < 0) return -EINVAL; @@ -7146,6 +7214,7 @@ static int show_dis_tap(struct seq_file *m, void *v) { struct bpctl_dev *dev = m->private; int ret = get_dis_tap_fn(dev); + if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); else if (ret == 0) @@ -7160,6 +7229,7 @@ static ssize_t dis_disc_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { int tap_param = user_on_off(buffer, count); + if (tap_param < 0) return -EINVAL; @@ -7170,6 +7240,7 @@ static int show_dis_disc(struct seq_file *m, void *v) { struct bpctl_dev *dev = m->private; int ret = get_dis_disc_fn(dev); + if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); else if (ret == 0) @@ -7184,6 +7255,7 @@ static ssize_t bypass_pwup_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { int bypass_param = user_on_off(buffer, count); + if (bypass_param < 0) return -EINVAL; @@ -7194,6 +7266,7 @@ static int show_bypass_pwup(struct seq_file *m, void *v) { struct bpctl_dev *dev = m->private; int ret = get_bypass_pwup_fn(dev); + if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); else if (ret == 0) @@ -7208,6 +7281,7 @@ static ssize_t bypass_pwoff_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { int bypass_param = user_on_off(buffer, count); + if (bypass_param < 0) return -EINVAL; @@ -7218,6 +7292,7 @@ static int show_bypass_pwoff(struct seq_file *m, void *v) { struct bpctl_dev *dev = m->private; int ret = get_bypass_pwoff_fn(dev); + if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); else if (ret == 0) @@ -7232,6 +7307,7 @@ static ssize_t tap_pwup_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { int tap_param = user_on_off(buffer, count); + if (tap_param < 0) return -EINVAL; @@ -7242,6 +7318,7 @@ static int show_tap_pwup(struct seq_file *m, void *v) { struct bpctl_dev *dev = m->private; int ret = get_tap_pwup_fn(dev); + if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); else if (ret == 0) @@ -7256,6 +7333,7 @@ static ssize_t disc_pwup_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { int tap_param = user_on_off(buffer, count); + if (tap_param < 0) return -EINVAL; @@ -7266,6 +7344,7 @@ static int show_disc_pwup(struct seq_file *m, void *v) { struct bpctl_dev *dev = m->private; int ret = get_disc_pwup_fn(dev); + if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); else if (ret == 0) @@ -7280,6 +7359,7 @@ static ssize_t std_nic_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { int bypass_param = user_on_off(buffer, count); + if (bypass_param < 0) return -EINVAL; @@ -7290,6 +7370,7 @@ static int show_std_nic(struct seq_file *m, void *v) { struct bpctl_dev *dev = m->private; int ret = get_std_nic_fn(dev); + if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); else if (ret == 0) @@ -7332,6 +7413,7 @@ static int show_wd_exp_mode(struct seq_file *m, void *v) { struct bpctl_dev *dev = m->private; int ret = get_wd_exp_mode_fn(dev); + if (ret == 1) seq_puts(m, "tap\n"); else if (ret == 0) @@ -7349,6 +7431,7 @@ static ssize_t wd_autoreset_write(struct file *file, const char __user *buffer, { int timeout; int ret = kstrtoint_from_user(buffer, count, 10, &timeout); + if (ret) return ret; set_wd_autoreset_fn(PDE_DATA(file_inode(file)), timeout); @@ -7358,6 +7441,7 @@ static int show_wd_autoreset(struct seq_file *m, void *v) { struct bpctl_dev *dev = m->private; int ret = get_wd_autoreset_fn(dev); + if (ret >= 0) seq_printf(m, "%d\n", ret); else diff --git a/drivers/staging/silicom/bypasslib/bypass.c b/drivers/staging/silicom/bypasslib/bypass.c index a58251f5a8f8..8e714a8ea3a0 100644 --- a/drivers/staging/silicom/bypasslib/bypass.c +++ b/drivers/staging/silicom/bypasslib/bypass.c @@ -135,6 +135,7 @@ static int doit(int cmd, int if_index, int *data) static int is_dev_sd(int if_index) { int ret = 0; + SET_BPLIB_INT_FN(is_bypass, int, if_index, ret); return ret >= 0 ? 1 : 0; } @@ -186,6 +187,7 @@ static int is_bypass_dev(int if_index) static int is_bypass(int if_index) { int ret = 0; + SET_BPLIB_INT_FN(is_bypass, int, if_index, ret); if (ret < 0) -- cgit v1.2.3 From 4764ca981b040048766e4f39a45a4b9c5cecff9c Mon Sep 17 00:00:00 2001 From: Peter Senna Tschudin Date: Mon, 26 May 2014 16:08:50 +0200 Subject: drivers/staging: Remove useless return variables This patch remove variables that are initialized with a constant, are never updated, and are only used as parameter of return. Return the constant instead of using a variable. Verified by compilation only. The coccinelle script that find and fixes this issue is: // @@ type T; constant C; identifier ret; @@ - T ret = C; ... when != ret when strict return - ret + C ; // Signed-off-by: Peter Senna Tschudin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 3 +-- drivers/staging/bcm/InterfaceIdleMode.c | 3 +-- drivers/staging/bcm/PHSModule.c | 9 +++------ drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c | 3 +-- drivers/staging/rtl8192e/rtllib_rx.c | 3 +-- drivers/staging/rtl8192e/rtllib_softmac.c | 3 +-- drivers/staging/rtl8192e/rtllib_softmac_wx.c | 4 +--- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 3 +-- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 3 +-- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c | 4 +--- drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c | 3 +-- drivers/staging/rtl8192u/r819xU_cmdpkt.c | 3 +-- drivers/staging/rtl8192u/r819xU_phy.c | 3 +-- drivers/staging/sep/sep_main.c | 3 +-- drivers/staging/silicom/bpctl_mod.c | 4 ++-- drivers/staging/wlan-ng/hfa384x_usb.c | 3 +-- drivers/staging/wlan-ng/p80211req.c | 3 +-- 17 files changed, 20 insertions(+), 40 deletions(-) diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index 52809dc3d106..606d5f5e9216 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -1849,7 +1849,6 @@ static int bcm_char_ioctl_flash2x_section_bitmap(void __user *argp, { struct bcm_flash2x_bitmap *psFlash2xBitMap; struct bcm_ioctl_buffer IoBuffer; - INT Status = STATUS_FAILURE; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP Called"); @@ -1892,7 +1891,7 @@ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, } kfree(psFlash2xBitMap); - return Status; + return STATUS_FAILURE; } static int bcm_char_ioctl_set_active_section(void __user *argp, diff --git a/drivers/staging/bcm/InterfaceIdleMode.c b/drivers/staging/bcm/InterfaceIdleMode.c index fecf81ffe066..c84ee494f55f 100644 --- a/drivers/staging/bcm/InterfaceIdleMode.c +++ b/drivers/staging/bcm/InterfaceIdleMode.c @@ -223,7 +223,6 @@ static int InterfaceAbortIdlemode(struct bcm_mini_adapter *Adapter, } int InterfaceIdleModeWakeup(struct bcm_mini_adapter *Adapter) { - ULONG Status = 0; if (Adapter->bTriedToWakeUpFromlowPowerMode) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, @@ -233,7 +232,7 @@ int InterfaceIdleModeWakeup(struct bcm_mini_adapter *Adapter) InterfaceAbortIdlemode(Adapter, Adapter->usIdleModePattern); } - return Status; + return 0; } void InterfaceHandleShutdownModeWakeup(struct bcm_mini_adapter *Adapter) diff --git a/drivers/staging/bcm/PHSModule.c b/drivers/staging/bcm/PHSModule.c index afc7bcc3e54b..07c5a0bae1ed 100644 --- a/drivers/staging/bcm/PHSModule.c +++ b/drivers/staging/bcm/PHSModule.c @@ -409,7 +409,6 @@ ULONG PhsUpdateClassifierRule(IN void *pvContext, */ ULONG PhsDeletePHSRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT8 u8PHSI) { - ULONG lStatus = 0; UINT nSFIndex = 0, nClsidIndex = 0; struct bcm_phs_entry *pstServiceFlowEntry = NULL; struct bcm_phs_classifier_table *pstClassifierRulesTable = NULL; @@ -446,7 +445,7 @@ ULONG PhsDeletePHSRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT8 u8PHSI } } } - return lStatus; + return 0; } /* @@ -467,7 +466,6 @@ ULONG PhsDeletePHSRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT8 u8PHSI */ ULONG PhsDeleteClassifierRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT16 uiClsId) { - ULONG lStatus = 0; UINT nSFIndex = 0, nClsidIndex = 0; struct bcm_phs_entry *pstServiceFlowEntry = NULL; struct bcm_phs_classifier_entry *pstClassifierEntry = NULL; @@ -504,7 +502,7 @@ ULONG PhsDeleteClassifierRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT1 memset(pstClassifierEntry, 0, sizeof(struct bcm_phs_classifier_entry)); } } - return lStatus; + return 0; } /* @@ -524,7 +522,6 @@ ULONG PhsDeleteClassifierRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT1 */ ULONG PhsDeleteSFRules(IN void *pvContext, IN B_UINT16 uiVcid) { - ULONG lStatus = 0; UINT nSFIndex = 0, nClsidIndex = 0; struct bcm_phs_entry *pstServiceFlowEntry = NULL; struct bcm_phs_classifier_table *pstClassifierRulesTable = NULL; @@ -573,7 +570,7 @@ ULONG PhsDeleteSFRules(IN void *pvContext, IN B_UINT16 uiVcid) pstServiceFlowEntry->uiVcid = 0; } - return lStatus; + return 0; } /* diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c index b4bfafe5c4a1..88489215dc2b 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c @@ -729,7 +729,6 @@ u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, { int i; - u8 ret = 0; switch (eRFPath) { case RF90_PATH_A: @@ -787,7 +786,7 @@ u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, break; } - return ret; + return 0; } static void rtl8192_SetTxPowerLevel(struct net_device *dev, u8 channel) diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 7413816dd92b..60de54cc601f 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -1589,7 +1589,6 @@ static int rtllib_qos_convert_ac_to_parameters(struct rtllib_qos_parameter_info { struct rtllib_qos_ac_parameter *ac_params; struct rtllib_qos_parameters *qos_param = &(qos_data->parameters); - int rc = 0; int i; u8 aci; u8 acm; @@ -1640,7 +1639,7 @@ static int rtllib_qos_convert_ac_to_parameters(struct rtllib_qos_parameter_info (ac_params->aci_aifsn & 0x10) ? 0x01 : 0x00; qos_param->tx_op_limit[aci] = ac_params->tx_op_limit; } - return rc; + return 0; } /* diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index d65cba428941..684ceed17232 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -3239,7 +3239,6 @@ static int rtllib_wpa_set_auth_algs(struct rtllib_device *ieee, int value) struct rtllib_security sec = { .flags = SEC_AUTH_MODE, }; - int ret = 0; if (value & AUTH_ALG_SHARED_KEY) { sec.auth_mode = WLAN_AUTH_SHARED_KEY; @@ -3259,7 +3258,7 @@ static int rtllib_wpa_set_auth_algs(struct rtllib_device *ieee, int value) if (ieee->set_security) ieee->set_security(ieee->dev, &sec); - return ret; + return 0; } static int rtllib_wpa_set_param(struct rtllib_device *ieee, u8 name, u32 value) diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c index e6af8cfab12b..65b650cc3d0a 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c @@ -628,8 +628,6 @@ int rtllib_wx_get_power(struct rtllib_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - int ret = 0; - down(&ieee->wx_sem); if (ieee->ps == RTLLIB_PS_DISABLED) { @@ -657,7 +655,7 @@ int rtllib_wx_get_power(struct rtllib_device *ieee, exit: up(&ieee->wx_sem); - return ret; + return 0; } EXPORT_SYMBOL(rtllib_wx_get_power); diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index 0cd6a001bcc5..d9a8299c48eb 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -1477,7 +1477,6 @@ static int ieee80211_qos_convert_ac_to_parameters(struct ieee80211_qos_parameters *qos_param) { - int rc = 0; int i; struct ieee80211_qos_ac_parameter *ac_params; u8 aci; @@ -1504,7 +1503,7 @@ static int ieee80211_qos_convert_ac_to_parameters(struct (ac_params->aci_aifsn & 0x10) ? 0x01 : 0x00; qos_param->tx_op_limit[aci] = le16_to_cpu(ac_params->tx_op_limit); } - return rc; + return 0; } /* diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 5274ff0fb7a2..c5a0a5da97da 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -2854,7 +2854,6 @@ static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value) struct ieee80211_security sec = { .flags = SEC_AUTH_MODE, }; - int ret = 0; if (value & AUTH_ALG_SHARED_KEY) { sec.auth_mode = WLAN_AUTH_SHARED_KEY; @@ -2877,7 +2876,7 @@ static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value) //else // ret = -EOPNOTSUPP; - return ret; + return 0; } static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, u32 value) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c index a38176834320..935a8f4adcf9 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c @@ -570,8 +570,6 @@ int ieee80211_wx_get_power(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - int ret =0; - down(&ieee->wx_sem); if(ieee->ps == IEEE80211_PS_DISABLED){ @@ -601,7 +599,7 @@ int ieee80211_wx_get_power(struct ieee80211_device *ieee, exit: up(&ieee->wx_sem); - return ret; + return 0; } EXPORT_SYMBOL(ieee80211_wx_get_power); diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c index e7c54ac60720..2694a085e3aa 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c @@ -415,8 +415,7 @@ static void HTIOTPeerDetermine(struct ieee80211_device *ieee) * *****************************************************************************************************************/ static u8 HTIOTActIsDisableMCS14(struct ieee80211_device *ieee, u8 *PeerMacAddr) { - u8 ret = 0; - return ret; + return 0; } diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.c b/drivers/staging/rtl8192u/r819xU_cmdpkt.c index 723c8630e9e2..545f49ec9c03 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.c +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.c @@ -28,7 +28,6 @@ rt_status SendTxCommandPacket(struct net_device *dev, void *pData, u32 DataLen) { - rt_status rtStatus = RT_STATUS_SUCCESS; struct r8192_priv *priv = ieee80211_priv(dev); struct sk_buff *skb; cb_desc *tcb_desc; @@ -58,7 +57,7 @@ rt_status SendTxCommandPacket(struct net_device *dev, void *pData, u32 DataLen) priv->ieee80211->softmac_hard_start_xmit(skb, dev); } - return rtStatus; + return RT_STATUS_SUCCESS; } /*----------------------------------------------------------------------------- diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index 87e07ba49ecd..02554c981203 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -991,7 +991,6 @@ u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, { int i; - u8 ret = 0; switch (eRFPath) { case RF90_PATH_A: @@ -1058,7 +1057,7 @@ u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, break; } - return ret; + return 0; } diff --git a/drivers/staging/sep/sep_main.c b/drivers/staging/sep/sep_main.c index e301207eb0bd..75ca15e86a27 100644 --- a/drivers/staging/sep/sep_main.c +++ b/drivers/staging/sep/sep_main.c @@ -1400,7 +1400,6 @@ static int sep_lli_table_secure_dma(struct sep_device *sep, struct sep_dma_context *dma_ctx) { - int error = 0; u32 count; /* The the page of the end address of the user space buffer */ u32 end_page; @@ -1491,7 +1490,7 @@ static int sep_lli_table_secure_dma(struct sep_device *sep, dma_ctx->dma_res_arr[dma_ctx->nr_dcb_creat].out_map_array = NULL; dma_ctx->dma_res_arr[dma_ctx->nr_dcb_creat].out_map_num_entries = 0; - return error; + return 0; } /** diff --git a/drivers/staging/silicom/bpctl_mod.c b/drivers/staging/silicom/bpctl_mod.c index 22bf4bf03993..f74b5e711609 100644 --- a/drivers/staging/silicom/bpctl_mod.c +++ b/drivers/staging/silicom/bpctl_mod.c @@ -1564,7 +1564,7 @@ int pulse_set_fn(struct bpctl_dev *pbpctl_dev, unsigned int counter) int zero_set_fn(struct bpctl_dev *pbpctl_dev) { - uint32_t ctrl_ext = 0, ctrl_value = 0; + uint32_t ctrl_ext = 0; if (!pbpctl_dev) return -1; @@ -1585,7 +1585,7 @@ int zero_set_fn(struct bpctl_dev *pbpctl_dev) BPCTLI_CTRL_EXT_MDIO_DATA))); } - return ctrl_value; + return 0; } int pulse_get2_fn(struct bpctl_dev *pbpctl_dev) diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c index f0ab5a27015e..98343ff70615 100644 --- a/drivers/staging/wlan-ng/hfa384x_usb.c +++ b/drivers/staging/wlan-ng/hfa384x_usb.c @@ -2642,7 +2642,6 @@ done: ----------------------------------------------------------------*/ int hfa384x_drvr_stop(hfa384x_t *hw) { - int result = 0; int i; might_sleep(); @@ -2667,7 +2666,7 @@ int hfa384x_drvr_stop(hfa384x_t *hw) for (i = 0; i < HFA384x_NUMPORTS_MAX; i++) hw->port_enabled[i] = 0; - return result; + return 0; } /*---------------------------------------------------------------- diff --git a/drivers/staging/wlan-ng/p80211req.c b/drivers/staging/wlan-ng/p80211req.c index 97795749a4ab..7221379c9742 100644 --- a/drivers/staging/wlan-ng/p80211req.c +++ b/drivers/staging/wlan-ng/p80211req.c @@ -95,7 +95,6 @@ static void p80211req_mibset_mibget(wlandevice_t *wlandev, ----------------------------------------------------------------*/ int p80211req_dorequest(wlandevice_t *wlandev, u8 *msgbuf) { - int result = 0; struct p80211msg *msg = (struct p80211msg *) msgbuf; /* Check to make sure the MSD is running */ @@ -129,7 +128,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 0; /* if result==0, msg->status still may contain an err */ } /*---------------------------------------------------------------- -- cgit v1.2.3 From ddafd514b1729718690c04b875035da60ec6ef04 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 26 May 2014 11:08:18 +0200 Subject: staging/lustre/llite: Remove unnecessary check for NULL before iput() iput() already checks for the inode being NULL, thus it's unnecessary to check before calling. Signed-off-by: Tobias Klauser Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/llite_lib.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 7372986ac145..deca27ea33fe 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -591,8 +591,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, return err; out_root: - if (root) - iput(root); + iput(root); out_lock_cn_cb: obd_fid_fini(sbi->ll_dt_exp->exp_obd); out_dt: -- cgit v1.2.3 From 462310f3f3f2f86b02d2a0c8681ea7900e2bb82c Mon Sep 17 00:00:00 2001 From: Daeseok Youn Date: Mon, 26 May 2014 19:23:01 +0900 Subject: staging: dgap: remove unneeded kfree() for ttys in tty_driver In destruct_tty_driver() from put_tty_driver() will free the ttys in tty_driver. Signed-off-by: Daeseok Youn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 1475532b4df0..60b7d700b07d 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -1503,8 +1503,6 @@ static void dgap_tty_uninit(struct board_t *brd) tty_unregister_device(brd->serial_driver, i); } tty_unregister_driver(brd->serial_driver); - kfree(brd->serial_driver->ttys); - brd->serial_driver->ttys = NULL; put_tty_driver(brd->serial_driver); kfree(brd->serial_ports); brd->dgap_major_serial_registered = FALSE; @@ -1520,8 +1518,6 @@ static void dgap_tty_uninit(struct board_t *brd) tty_unregister_device(brd->print_driver, i); } tty_unregister_driver(brd->print_driver); - kfree(brd->print_driver->ttys); - brd->print_driver->ttys = NULL; put_tty_driver(brd->print_driver); kfree(brd->printer_ports); brd->dgap_major_transparent_print_registered = FALSE; -- cgit v1.2.3 From 0ade4a34fd439d62df46937e8f3e584eb0879579 Mon Sep 17 00:00:00 2001 From: Daeseok Youn Date: Mon, 26 May 2014 19:24:17 +0900 Subject: staging: dgap: remove unneeded kfree() in dgap_tty_register_ports() When it failed to allocate for printer_ports, serial_ports can be freed in dgap_tty_uninit(). Signed-off-by: Daeseok Youn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 60b7d700b07d..06abb2047443 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -4147,10 +4147,9 @@ static int dgap_tty_register_ports(struct board_t *brd) brd->printer_ports = kcalloc(brd->nasync, sizeof(*brd->printer_ports), GFP_KERNEL); - if (brd->printer_ports == NULL) { - kfree(brd->serial_ports); + if (brd->printer_ports == NULL) return -ENOMEM; - } + for (i = 0; i < brd->nasync; i++) tty_port_init(&brd->printer_ports[i]); -- cgit v1.2.3 From a66369a59016e6f5c5da77afbd53eec49b03fb68 Mon Sep 17 00:00:00 2001 From: Daeseok Youn Date: Mon, 26 May 2014 19:24:47 +0900 Subject: staging: dgap: move tty_port_init() for serial_ports. If printer_ports which is allocated after serial_ports is failed to allocate, tty_port_init for serial_ports doesn't need anymore. So move this after allocating memory for printer_ports. Signed-off-by: Daeseok Youn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 06abb2047443..65d651ed7117 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -4142,16 +4142,16 @@ static int dgap_tty_register_ports(struct board_t *brd) GFP_KERNEL); if (brd->serial_ports == NULL) return -ENOMEM; - for (i = 0; i < brd->nasync; i++) - tty_port_init(&brd->serial_ports[i]); brd->printer_ports = kcalloc(brd->nasync, sizeof(*brd->printer_ports), GFP_KERNEL); if (brd->printer_ports == NULL) return -ENOMEM; - for (i = 0; i < brd->nasync; i++) + for (i = 0; i < brd->nasync; i++) { + tty_port_init(&brd->serial_ports[i]); tty_port_init(&brd->printer_ports[i]); + } ch = brd->channels[0]; for (i = 0; i < brd->nasync; i++, ch = brd->channels[i]) { -- cgit v1.2.3 From c1ad28a3995da1e8300d29ac01fd3757c8dfadfc Mon Sep 17 00:00:00 2001 From: Joel Porquet Date: Mon, 26 May 2014 18:07:38 +0200 Subject: staging: silicom/bypasslib/bp_ioctl.h: Fix erroneous global variable definitions Originally, this header was defining two new typedefs, CMND_TYPE and CMND_TYPE_SD, following this type of declaration: typedef enum { ... } CMND_TYPE; A previous commit (785086556a573f07747b3633732a9dbd7e45728f) tried to fix warnings that were pointed out by checkpatch.pl, concerning not adding new typedefs. But this commit only removed the 'typedef' keyword, thus transforming both the typedefs into two the definition of global variables. For example: enum { ... } CMND_TYPE; As noticed by the Sparse tool, this patch removes those erroneous global variable definitions, and just leaves anonymous enum type definitions: enum { ... }; Signed-off-by: Joel Porquet Signed-off-by: Greg Kroah-Hartman --- drivers/staging/silicom/bypasslib/bp_ioctl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/silicom/bypasslib/bp_ioctl.h b/drivers/staging/silicom/bypasslib/bp_ioctl.h index bf47f786866b..a13932af733b 100644 --- a/drivers/staging/silicom/bypasslib/bp_ioctl.h +++ b/drivers/staging/silicom/bypasslib/bp_ioctl.h @@ -101,7 +101,7 @@ enum { SET_BP_WAIT_AT_PWUP, GET_BP_HW_RESET, SET_BP_HW_RESET, -} CMND_TYPE; +}; enum { IF_SCAN_SD, @@ -154,7 +154,7 @@ enum { GET_BP_HW_RESET_SD, SET_BP_HW_RESET_SD, -} CMND_TYPE_SD; +}; #define SIOCGIFBYPASS (SIOCDEVPRIVATE+10) -- cgit v1.2.3 From 954e8142a5c251283cdaa7eaaa8bb9af1c5a4a52 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 26 May 2014 13:58:58 +0100 Subject: staging: vt6656: MACvSetKeyEntry change u32 pdwKey to u8 pointer Change pdwKey u32 pointer to key u8 pointer. Callers are already u8 remove u32 pointer cast. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/key.c | 15 +++++++++++---- drivers/staging/vt6656/mac.c | 5 ++--- drivers/staging/vt6656/mac.h | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/staging/vt6656/key.c b/drivers/staging/vt6656/key.c index a88c6b1886dc..9283612f670e 100644 --- a/drivers/staging/vt6656/key.c +++ b/drivers/staging/vt6656/key.c @@ -247,7 +247,9 @@ int KeybSetKey(struct vnt_private *pDevice, PSKeyManagement pTable, if (uKeyLength == WLAN_WEP104_KEYLEN) pKey->abyKey[15] |= 0x80; } - MACvSetKeyEntry(pDevice, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pbyBSSID, (u32 *)pKey->abyKey); + + MACvSetKeyEntry(pDevice, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, + pbyBSSID, pKey->abyKey); if ((dwKeyIndex & USE_KEYRSC) == 0) pKey->KeyRSC = 0; /* RSC set by NIC */ @@ -315,7 +317,9 @@ int KeybSetKey(struct vnt_private *pDevice, PSKeyManagement pTable, if (uKeyLength == WLAN_WEP104_KEYLEN) pKey->abyKey[15] |= 0x80; } - MACvSetKeyEntry(pDevice, pTable->KeyTable[j].wKeyCtl, j, uKeyIdx, pbyBSSID, (u32 *)pKey->abyKey); + + MACvSetKeyEntry(pDevice, pTable->KeyTable[j].wKeyCtl, j, uKeyIdx, + pbyBSSID, pKey->abyKey); if ((dwKeyIndex & USE_KEYRSC) == 0) pKey->KeyRSC = 0; /* RSC set by NIC */ @@ -610,7 +614,9 @@ int KeybSetDefaultKey(struct vnt_private *pDevice, PSKeyManagement pTable, pKey->abyKey[15] |= 0x80; } - MACvSetKeyEntry(pDevice, pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl, MAX_KEY_TABLE-1, uKeyIdx, pTable->KeyTable[MAX_KEY_TABLE-1].abyBSSID, (u32 *) pKey->abyKey); + MACvSetKeyEntry(pDevice, pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl, + MAX_KEY_TABLE-1, uKeyIdx, + pTable->KeyTable[MAX_KEY_TABLE-1].abyBSSID, pKey->abyKey); if ((dwKeyIndex & USE_KEYRSC) == 0) pKey->KeyRSC = 0; /* RSC set by NIC */ @@ -704,7 +710,8 @@ int KeybSetAllGroupKey(struct vnt_private *pDevice, PSKeyManagement pTable, pKey->abyKey[15] |= 0x80; } - MACvSetKeyEntry(pDevice, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pTable->KeyTable[i].abyBSSID, (u32 *) pKey->abyKey); + MACvSetKeyEntry(pDevice, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, + pTable->KeyTable[i].abyBSSID, pKey->abyKey); if ((dwKeyIndex & USE_KEYRSC) == 0) pKey->KeyRSC = 0; /* RSC set by NIC */ diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index bc72144f0d21..a030c592cd3a 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -123,10 +123,9 @@ void MACvDisableKeyEntry(struct vnt_private *priv, u8 entry_idx) * */ void MACvSetKeyEntry(struct vnt_private *pDevice, u16 wKeyCtl, u32 uEntryIdx, - u32 uKeyIdx, u8 *pbyAddr, u32 *pdwKey) + u32 uKeyIdx, u8 *pbyAddr, u8 *key) { struct vnt_mac_set_key set_key; - u8 *pbyKey = (u8 *)pdwKey; u16 wOffset; if (pDevice->byLocalID <= MAC_REVISION_A1) @@ -142,7 +141,7 @@ void MACvSetKeyEntry(struct vnt_private *pDevice, u16 wKeyCtl, u32 uEntryIdx, /* swap over swap[0] and swap[1] to get correct write order */ swap(set_key.u.swap[0], set_key.u.swap[1]); - memcpy(set_key.key, pbyKey, WLAN_KEY_LEN_CCMP); + memcpy(set_key.key, key, WLAN_KEY_LEN_CCMP); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "offset %d key ctl %d set key %24ph\n", diff --git a/drivers/staging/vt6656/mac.h b/drivers/staging/vt6656/mac.h index 81006853dbda..6e45d479bffb 100644 --- a/drivers/staging/vt6656/mac.h +++ b/drivers/staging/vt6656/mac.h @@ -418,7 +418,7 @@ void MACvWriteMultiAddr(struct vnt_private *, u64); void MACbShutdown(struct vnt_private *); void MACvSetBBType(struct vnt_private *, u8); void MACvDisableKeyEntry(struct vnt_private *, u8); -void MACvSetKeyEntry(struct vnt_private *, u16, u32, u32, u8 *, u32 *); +void MACvSetKeyEntry(struct vnt_private *, u16, u32, u32, u8 *, u8 *); void MACvRegBitsOff(struct vnt_private *, u8, u8); void MACvRegBitsOn(struct vnt_private *, u8, u8); void MACvWriteWord(struct vnt_private *, u8, u16); -- cgit v1.2.3 From 39dd526e5171b528b43be4ddb8d183a3064b7489 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 26 May 2014 13:58:59 +0100 Subject: staging: vt6656: MACvSetKeyEntry remove camel case. camel case changes pDevice -> priv wKeyCtl -> key_ctl uEntryIdx -> entry_idx uKeyIdx -> key_idx pbyAddr -> addr wOffset -> offset Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/mac.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index a030c592cd3a..573ea4f9ca8b 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -122,21 +122,21 @@ void MACvDisableKeyEntry(struct vnt_private *priv, u8 entry_idx) * Return Value: none * */ -void MACvSetKeyEntry(struct vnt_private *pDevice, u16 wKeyCtl, u32 uEntryIdx, - u32 uKeyIdx, u8 *pbyAddr, u8 *key) +void MACvSetKeyEntry(struct vnt_private *priv, u16 key_ctl, u32 entry_idx, + u32 key_idx, u8 *addr, u8 *key) { struct vnt_mac_set_key set_key; - u16 wOffset; + u16 offset; - if (pDevice->byLocalID <= MAC_REVISION_A1) - if (pDevice->vnt_mgmt.byCSSPK == KEY_CTL_CCMP) + if (priv->byLocalID <= MAC_REVISION_A1) + if (priv->vnt_mgmt.byCSSPK == KEY_CTL_CCMP) return; - wOffset = MISCFIFO_KEYETRY0; - wOffset += (uEntryIdx * MISCFIFO_KEYENTRYSIZE); + offset = MISCFIFO_KEYETRY0; + offset += (entry_idx * MISCFIFO_KEYENTRYSIZE); - set_key.u.write.key_ctl = cpu_to_le16(wKeyCtl); - memcpy(set_key.u.write.addr, pbyAddr, ETH_ALEN); + set_key.u.write.key_ctl = cpu_to_le16(key_ctl); + memcpy(set_key.u.write.addr, addr, ETH_ALEN); /* swap over swap[0] and swap[1] to get correct write order */ swap(set_key.u.swap[0], set_key.u.swap[1]); @@ -145,10 +145,10 @@ void MACvSetKeyEntry(struct vnt_private *pDevice, u16 wKeyCtl, u32 uEntryIdx, DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "offset %d key ctl %d set key %24ph\n", - wOffset, wKeyCtl, (u8 *)&set_key); + offset, key_ctl, (u8 *)&set_key); - CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_SETKEY, wOffset, - (u16)uKeyIdx, sizeof(struct vnt_mac_set_key), (u8 *)&set_key); + CONTROLnsRequestOut(priv, MESSAGE_TYPE_SETKEY, offset, + (u16)key_idx, sizeof(struct vnt_mac_set_key), (u8 *)&set_key); } void MACvRegBitsOff(struct vnt_private *priv, u8 reg_ofs, u8 bits) -- cgit v1.2.3 From 88a8926fba921f0d6bf0c513203f13874a8301e1 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 26 May 2014 13:59:00 +0100 Subject: staging: vt6656: mac.c remove DBG_PRT debug message. Replace with dev_dbg Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/mac.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index 573ea4f9ca8b..9211ec1c5e25 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -37,9 +37,6 @@ #include "80211hdr.h" #include "control.h" -//static int msglevel =MSG_LEVEL_DEBUG; -static int msglevel =MSG_LEVEL_INFO; - /* * Description: * Write MAC Multicast Address Mask @@ -143,8 +140,7 @@ void MACvSetKeyEntry(struct vnt_private *priv, u16 key_ctl, u32 entry_idx, memcpy(set_key.key, key, WLAN_KEY_LEN_CCMP); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "offset %d key ctl %d set key %24ph\n", + dev_dbg(&priv->usb->dev, "offset %d key ctl %d set key %24ph\n", offset, key_ctl, (u8 *)&set_key); CONTROLnsRequestOut(priv, MESSAGE_TYPE_SETKEY, offset, -- cgit v1.2.3 From 1390b02a2f5d3b8d0a13e2f2d67dc2a562bc0b89 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 26 May 2014 13:59:01 +0100 Subject: staging: vt6656: rename PIPEnsControlOut/CONTROLnsRequestOut to vnt_control_out Rename all CONTROLnsRequestOut and remove macro from control.h Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 8 ++++---- drivers/staging/vt6656/card.c | 14 +++++++------- drivers/staging/vt6656/control.c | 6 +++--- drivers/staging/vt6656/control.h | 3 --- drivers/staging/vt6656/firmware.c | 4 ++-- drivers/staging/vt6656/key.c | 23 +++++++---------------- drivers/staging/vt6656/mac.c | 28 ++++++++++++++-------------- drivers/staging/vt6656/main_usb.c | 2 +- drivers/staging/vt6656/power.c | 2 +- drivers/staging/vt6656/rf.c | 12 ++++++------ drivers/staging/vt6656/usbpipe.c | 4 ++-- drivers/staging/vt6656/usbpipe.h | 3 +-- drivers/staging/vt6656/wcmd.c | 2 +- 13 files changed, 49 insertions(+), 62 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index 309a3cb74391..8a509d895615 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -865,7 +865,7 @@ void BBvSetAntennaMode(struct vnt_private *priv, u8 antenna_mode) break; } - CONTROLnsRequestOut(priv, MESSAGE_TYPE_SET_ANTMD, + vnt_control_out(priv, MESSAGE_TYPE_SET_ANTMD, (u16)antenna_mode, 0, 0, NULL); } @@ -1018,12 +1018,12 @@ int BBbVT3184Init(struct vnt_private *priv) memcpy(array, addr, length); - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, 0, + vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0, MESSAGE_REQUEST_BBREG, length, array); memcpy(array, agc, length_agc); - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, 0, + vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0, MESSAGE_REQUEST_BBAGC, length_agc, array); if ((priv->byRFType == RF_VT3226) || @@ -1049,7 +1049,7 @@ int BBbVT3184Init(struct vnt_private *priv) data |= 0x2; - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, USB_REG4, + vnt_control_out(priv, MESSAGE_TYPE_WRITE, USB_REG4, MESSAGE_REQUEST_MEM, sizeof(data), &data); return true; diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index 6da912b4ec68..1f20e9adc923 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -94,7 +94,7 @@ void CARDbSetMediaChannel(struct vnt_private *priv, u32 connection_channel) /* Set Channel[7] = 0 to tell H/W channel is changing now. */ MACvRegBitsOff(priv, MAC_REG_CHANNEL, 0xb0); - CONTROLnsRequestOut(priv, MESSAGE_TYPE_SELECT_CHANNLE, + vnt_control_out(priv, MESSAGE_TYPE_SELECT_CHANNLE, connection_channel, 0, 0, NULL); if (priv->byBBType == BB_TYPE_11A) { @@ -373,7 +373,7 @@ void CARDvSetRSPINF(struct vnt_private *priv, u8 bb_type) data[16 + i * 2 + 1] = rsv_time[i]; } - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, + vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_RSPINF_B_1, MESSAGE_REQUEST_MACREG, 34, &data[0]); } @@ -461,12 +461,12 @@ void vUpdateIFS(struct vnt_private *priv) data[2] = (u8)priv->uEIFS; data[3] = (u8)priv->uSlot; - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, MAC_REG_SIFS, + vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_SIFS, MESSAGE_REQUEST_MACREG, 4, &data[0]); max_min |= 0xa0; - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, MAC_REG_CWMAXMIN0, + vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_CWMAXMIN0, MESSAGE_REQUEST_MACREG, 1, &max_min); } @@ -603,7 +603,7 @@ void CARDvAdjustTSF(struct vnt_private *priv, u8 rx_rate, data[6] = (u8)(tsf_offset >> 48); data[7] = (u8)(tsf_offset >> 56); - CONTROLnsRequestOut(priv, MESSAGE_TYPE_SET_TSFTBTT, + vnt_control_out(priv, MESSAGE_TYPE_SET_TSFTBTT, MESSAGE_REQUEST_TSF, 0, 8, data); } /* @@ -712,7 +712,7 @@ void CARDvSetFirstNextTBTT(struct vnt_private *priv, u16 beacon_interval) data[6] = (u8)(next_tbtt >> 48); data[7] = (u8)(next_tbtt >> 56); - CONTROLnsRequestOut(priv, MESSAGE_TYPE_SET_TSFTBTT, + vnt_control_out(priv, MESSAGE_TYPE_SET_TSFTBTT, MESSAGE_REQUEST_TBTT, 0, 8, data); return; @@ -749,7 +749,7 @@ void CARDvUpdateNextTBTT(struct vnt_private *priv, u64 tsf, data[6] = (u8)(tsf >> 48); data[7] = (u8)(tsf >> 56); - CONTROLnsRequestOut(priv, MESSAGE_TYPE_SET_TSFTBTT, + vnt_control_out(priv, MESSAGE_TYPE_SET_TSFTBTT, MESSAGE_REQUEST_TBTT, 0, 8, data); dev_dbg(&priv->usb->dev, "%s TBTT: %8llx\n", __func__, tsf); diff --git a/drivers/staging/vt6656/control.c b/drivers/staging/vt6656/control.c index fc19166e2f8b..074052190ed5 100644 --- a/drivers/staging/vt6656/control.c +++ b/drivers/staging/vt6656/control.c @@ -26,7 +26,7 @@ * Date: Apr. 5, 2004 * * Functions: - * CONTROLnsRequestOut - Write variable length bytes to MEM/BB/MAC/EEPROM + * vnt_control_out - Write variable length bytes to MEM/BB/MAC/EEPROM * 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 @@ -49,7 +49,7 @@ void ControlvWriteByte(struct vnt_private *pDevice, u8 reg, u8 reg_off, u8 data) { - CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_WRITE, reg_off, reg, + vnt_control_out(pDevice, MESSAGE_TYPE_WRITE, reg_off, reg, sizeof(u8), &data); return; @@ -71,7 +71,7 @@ void ControlvMaskByte(struct vnt_private *pDevice, u8 reg_type, u8 reg_off, reg_data[0] = data; reg_data[1] = reg_mask; - CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_WRITE_MASK, reg_off, + vnt_control_out(pDevice, MESSAGE_TYPE_WRITE_MASK, reg_off, reg_type, ARRAY_SIZE(reg_data), reg_data); return; diff --git a/drivers/staging/vt6656/control.h b/drivers/staging/vt6656/control.h index 4658910ca4c1..17a23d532adb 100644 --- a/drivers/staging/vt6656/control.h +++ b/drivers/staging/vt6656/control.h @@ -33,9 +33,6 @@ #include "device.h" #include "usbpipe.h" -#define CONTROLnsRequestOut(Device, Request, Value, Index, Length, Buffer) \ - PIPEnsControlOut(Device, Request, Value, Index, Length, Buffer) - #define CONTROLnsRequestIn(Device, Request, Value, Index, Length, Buffer) \ PIPEnsControlIn(Device, Request, Value, Index, Length, Buffer) diff --git a/drivers/staging/vt6656/firmware.c b/drivers/staging/vt6656/firmware.c index 1d3d268ef772..13b68d5c5588 100644 --- a/drivers/staging/vt6656/firmware.c +++ b/drivers/staging/vt6656/firmware.c @@ -70,7 +70,7 @@ int FIRMWAREbDownload(struct vnt_private *pDevice) wLength = min_t(int, fw->size - ii, FIRMWARE_CHUNK_SIZE); memcpy(pBuffer, fw->data + ii, wLength); - NdisStatus = CONTROLnsRequestOut(pDevice, + NdisStatus = vnt_control_out(pDevice, 0, 0x1200+ii, 0x0000, @@ -100,7 +100,7 @@ int FIRMWAREbBrach2Sram(struct vnt_private *pDevice) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Branch to Sram\n"); - NdisStatus = CONTROLnsRequestOut(pDevice, + NdisStatus = vnt_control_out(pDevice, 1, 0x1200, 0x0000, diff --git a/drivers/staging/vt6656/key.c b/drivers/staging/vt6656/key.c index 9283612f670e..11aa82a08f0e 100644 --- a/drivers/staging/vt6656/key.c +++ b/drivers/staging/vt6656/key.c @@ -67,15 +67,10 @@ static void s_vCheckKeyTableValid(struct vnt_private *pDevice, //MACvDisableKeyEntry(pDevice, i); } } - if ( wLength != 0 ) { - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_CLRKEYENTRY, - 0, - 0, - wLength, - pbyData - ); - } + + if (wLength != 0) + vnt_control_out(pDevice, MESSAGE_TYPE_CLRKEYENTRY, + 0, 0, wLength, pbyData); } @@ -112,13 +107,9 @@ void KeyvInitTable(struct vnt_private *pDevice, PSKeyManagement pTable) pbyData[i] = (u8) i; } pbyData[i] = (u8) i; - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_CLRKEYENTRY, - 0, - 0, - 11, - pbyData - ); + + vnt_control_out(pDevice, MESSAGE_TYPE_CLRKEYENTRY, + 0, 0, 11, pbyData); return; } diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index 9211ec1c5e25..51e4a355d9d7 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -54,7 +54,7 @@ void MACvWriteMultiAddr(struct vnt_private *priv, u64 mc_filter) { __le64 le_mc = cpu_to_le64(mc_filter); - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, MAC_REG_MAR0, + vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_MAR0, MESSAGE_REQUEST_MACREG, sizeof(le_mc), (u8 *)&le_mc); } @@ -71,7 +71,7 @@ void MACvWriteMultiAddr(struct vnt_private *priv, u64 mc_filter) */ void MACbShutdown(struct vnt_private *priv) { - CONTROLnsRequestOut(priv, MESSAGE_TYPE_MACSHUTDOWN, 0, 0, 0, NULL); + vnt_control_out(priv, MESSAGE_TYPE_MACSHUTDOWN, 0, 0, 0, NULL); } void MACvSetBBType(struct vnt_private *priv, u8 type) @@ -81,7 +81,7 @@ void MACvSetBBType(struct vnt_private *priv, u8 type) data[0] = type; data[1] = EnCFG_BBType_MASK; - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE_MASK, MAC_REG_ENCFG0, + vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, MAC_REG_ENCFG0, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } @@ -101,7 +101,7 @@ void MACvSetBBType(struct vnt_private *priv, u8 type) */ void MACvDisableKeyEntry(struct vnt_private *priv, u8 entry_idx) { - CONTROLnsRequestOut(priv, MESSAGE_TYPE_CLRKEYENTRY, 0, 0, + vnt_control_out(priv, MESSAGE_TYPE_CLRKEYENTRY, 0, 0, sizeof(entry_idx), &entry_idx); } @@ -143,7 +143,7 @@ void MACvSetKeyEntry(struct vnt_private *priv, u16 key_ctl, u32 entry_idx, dev_dbg(&priv->usb->dev, "offset %d key ctl %d set key %24ph\n", offset, key_ctl, (u8 *)&set_key); - CONTROLnsRequestOut(priv, MESSAGE_TYPE_SETKEY, offset, + vnt_control_out(priv, MESSAGE_TYPE_SETKEY, offset, (u16)key_idx, sizeof(struct vnt_mac_set_key), (u8 *)&set_key); } @@ -154,7 +154,7 @@ void MACvRegBitsOff(struct vnt_private *priv, u8 reg_ofs, u8 bits) data[0] = 0; data[1] = bits; - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE_MASK, + vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, reg_ofs, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } @@ -165,7 +165,7 @@ void MACvRegBitsOn(struct vnt_private *priv, u8 reg_ofs, u8 bits) data[0] = bits; data[1] = bits; - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE_MASK, + vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, reg_ofs, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } @@ -176,13 +176,13 @@ void MACvWriteWord(struct vnt_private *priv, u8 reg_ofs, u16 word) data[0] = (u8)(word & 0xff); data[1] = (u8)(word >> 8); - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, + vnt_control_out(priv, MESSAGE_TYPE_WRITE, reg_ofs, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } void MACvWriteBSSIDAddress(struct vnt_private *priv, u8 *addr) { - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, MAC_REG_BSSID0, + vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_BSSID0, MESSAGE_REQUEST_MACREG, ETH_ALEN, addr); } @@ -193,7 +193,7 @@ void MACvEnableProtectMD(struct vnt_private *priv) data[0] = EnCFG_ProtectMd; data[1] = EnCFG_ProtectMd; - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE_MASK, + vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, MAC_REG_ENCFG0, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } @@ -204,7 +204,7 @@ void MACvDisableProtectMD(struct vnt_private *priv) data[0] = 0; data[1] = EnCFG_ProtectMd; - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE_MASK, + vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, MAC_REG_ENCFG0, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } @@ -215,7 +215,7 @@ void MACvEnableBarkerPreambleMd(struct vnt_private *priv) data[0] = EnCFG_BarkerPream; data[1] = EnCFG_BarkerPream; - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE_MASK, + vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, MAC_REG_ENCFG2, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } @@ -226,7 +226,7 @@ void MACvDisableBarkerPreambleMd(struct vnt_private *priv) data[0] = 0; data[1] = EnCFG_BarkerPream; - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE_MASK, + vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, MAC_REG_ENCFG2, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } @@ -237,6 +237,6 @@ void MACvWriteBeaconInterval(struct vnt_private *priv, u16 interval) data[0] = (u8)(interval & 0xff); data[1] = (u8)(interval >> 8); - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, + vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_BI, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index ed04804d1d50..9e70aa5c29d1 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -314,7 +314,7 @@ static int device_init_registers(struct vnt_private *pDevice) init_cmd->long_retry_limit = pDevice->byLongRetryLimit; /* issue card_init command to device */ - ntStatus = CONTROLnsRequestOut(pDevice, + ntStatus = vnt_control_out(pDevice, MESSAGE_TYPE_CARDINIT, 0, 0, sizeof(struct vnt_cmd_card_init), (u8 *)init_cmd); if (ntStatus != STATUS_SUCCESS) { diff --git a/drivers/staging/vt6656/power.c b/drivers/staging/vt6656/power.c index c4bea74f86f9..a5cea43b8bc1 100644 --- a/drivers/staging/vt6656/power.c +++ b/drivers/staging/vt6656/power.c @@ -129,7 +129,7 @@ void PSvDisablePowerSaving(struct vnt_private *pDevice) { /* disable power saving hw function */ - CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_DISABLE_PS, 0, + vnt_control_out(pDevice, MESSAGE_TYPE_DISABLE_PS, 0, 0, 0, NULL); /* clear AutoSleep */ diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c index 7217f2c8bb04..58ea16c8767d 100644 --- a/drivers/staging/vt6656/rf.c +++ b/drivers/staging/vt6656/rf.c @@ -715,7 +715,7 @@ int IFRFbWriteEmbedded(struct vnt_private *pDevice, u32 dwData) pbyData[2] = (u8)(dwData >> 16); pbyData[3] = (u8)(dwData >> 24); - CONTROLnsRequestOut(pDevice, + vnt_control_out(pDevice, MESSAGE_TYPE_WRITE_IFRF, 0, 0, 4, pbyData); return true; @@ -1046,7 +1046,7 @@ void RFbRFTableDownload(struct vnt_private *priv) /* Init Table */ memcpy(array, addr1, length1); - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, 0, + vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0, MESSAGE_REQUEST_RF_INIT, length1, array); /* Channel Table 0 */ @@ -1059,7 +1059,7 @@ void RFbRFTableDownload(struct vnt_private *priv) memcpy(array, addr2, length); - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, + vnt_control_out(priv, MESSAGE_TYPE_WRITE, value, MESSAGE_REQUEST_RF_CH0, length, array); length2 -= length; @@ -1077,7 +1077,7 @@ void RFbRFTableDownload(struct vnt_private *priv) memcpy(array, addr3, length); - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, + vnt_control_out(priv, MESSAGE_TYPE_WRITE, value, MESSAGE_REQUEST_RF_CH1, length, array); length3 -= length; @@ -1094,7 +1094,7 @@ void RFbRFTableDownload(struct vnt_private *priv) memcpy(array, addr1, length1); /* Init Table 2 */ - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, + vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0, MESSAGE_REQUEST_RF_INIT2, length1, array); /* Channel Table 0 */ @@ -1107,7 +1107,7 @@ void RFbRFTableDownload(struct vnt_private *priv) memcpy(array, addr2, length); - CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, + vnt_control_out(priv, MESSAGE_TYPE_WRITE, value, MESSAGE_REQUEST_RF_CH2, length, array); length2 -= length; diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 2dfa16e3ad01..443338eb18bf 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -26,7 +26,7 @@ * Date: Mar. 29, 2005 * * Functions: - * CONTROLnsRequestOut - Write variable length bytes to MEM/BB/MAC/EEPROM + * vnt_control_out - Write variable length bytes to MEM/BB/MAC/EEPROM * 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 @@ -61,7 +61,7 @@ static void s_nsInterruptUsbIoCompleteRead(struct urb *urb); static void s_nsBulkInUsbIoCompleteRead(struct urb *urb); static void s_nsBulkOutIoCompleteWrite(struct urb *urb); -int PIPEnsControlOut(struct vnt_private *priv, u8 request, u16 value, +int vnt_control_out(struct vnt_private *priv, u8 request, u16 value, u16 index, u16 length, u8 *buffer) { int status = 0; diff --git a/drivers/staging/vt6656/usbpipe.h b/drivers/staging/vt6656/usbpipe.h index 42ad4f73243c..6ca250f8aeaf 100644 --- a/drivers/staging/vt6656/usbpipe.h +++ b/drivers/staging/vt6656/usbpipe.h @@ -32,8 +32,7 @@ #include "device.h" -int PIPEnsControlOut(struct vnt_private *, u8 byRequest, u16 wValue, - u16 wIndex, u16 wLength, u8 *pbyBuffer); +int vnt_control_out(struct vnt_private *, u8, u16, u16, u16, u8 *); int PIPEnsControlIn(struct vnt_private *, u8 byRequest, u16 wValue, u16 wIndex, u16 wLength, u8 *pbyBuffer); diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c index ff4e4ae0485d..99477944c045 100644 --- a/drivers/staging/vt6656/wcmd.c +++ b/drivers/staging/vt6656/wcmd.c @@ -852,7 +852,7 @@ void vRunCommand(struct work_struct *work) ControlvReadByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PSCTL, &byData); if ((byData & PSCTL_PS) != 0) { // disable power saving hw function - CONTROLnsRequestOut(pDevice, + vnt_control_out(pDevice, MESSAGE_TYPE_DISABLE_PS, 0, 0, -- cgit v1.2.3 From 441c21c3f0a0db21e96f1598fb05ac3d8782ac59 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 26 May 2014 13:59:02 +0100 Subject: staging: vt6656: rename PIPEnsControlIn/CONTROLnsRequestIn with vnt_control_in Replace all to CONTROLnsRequestIn with vnt_control_in and remove macro. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 4 ++-- drivers/staging/vt6656/control.c | 3 +-- drivers/staging/vt6656/control.h | 3 --- drivers/staging/vt6656/firmware.c | 2 +- drivers/staging/vt6656/main_usb.c | 8 ++++---- drivers/staging/vt6656/usbpipe.c | 4 ++-- drivers/staging/vt6656/usbpipe.h | 3 +-- drivers/staging/vt6656/wcmd.c | 2 +- 8 files changed, 12 insertions(+), 17 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index 8a509d895615..8a965bf821c5 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -893,7 +893,7 @@ int BBbVT3184Init(struct vnt_private *priv) u8 array[256]; u8 data; - status = CONTROLnsRequestIn(priv, MESSAGE_TYPE_READ, 0, + status = vnt_control_in(priv, MESSAGE_TYPE_READ, 0, MESSAGE_REQUEST_EEPROM, EEP_MAX_CONTEXT_SIZE, priv->abyEEPROM); if (status != STATUS_SUCCESS) @@ -1044,7 +1044,7 @@ int BBbVT3184Init(struct vnt_private *priv) /* Fix for TX USB resets from vendors driver */ - CONTROLnsRequestIn(priv, MESSAGE_TYPE_READ, USB_REG4, + vnt_control_in(priv, MESSAGE_TYPE_READ, USB_REG4, MESSAGE_REQUEST_MEM, sizeof(data), &data); data |= 0x2; diff --git a/drivers/staging/vt6656/control.c b/drivers/staging/vt6656/control.c index 074052190ed5..0c59d6d13f9b 100644 --- a/drivers/staging/vt6656/control.c +++ b/drivers/staging/vt6656/control.c @@ -27,7 +27,6 @@ * * Functions: * vnt_control_out - Write variable length bytes to MEM/BB/MAC/EEPROM - * 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 @@ -58,7 +57,7 @@ void ControlvWriteByte(struct vnt_private *pDevice, u8 reg, u8 reg_off, void ControlvReadByte(struct vnt_private *pDevice, u8 reg, u8 reg_off, u8 *data) { - CONTROLnsRequestIn(pDevice, MESSAGE_TYPE_READ, + vnt_control_in(pDevice, MESSAGE_TYPE_READ, reg_off, reg, sizeof(u8), data); return; } diff --git a/drivers/staging/vt6656/control.h b/drivers/staging/vt6656/control.h index 17a23d532adb..db9dd54c7623 100644 --- a/drivers/staging/vt6656/control.h +++ b/drivers/staging/vt6656/control.h @@ -33,9 +33,6 @@ #include "device.h" #include "usbpipe.h" -#define CONTROLnsRequestIn(Device, Request, Value, Index, Length, Buffer) \ - PIPEnsControlIn(Device, Request, Value, Index, Length, Buffer) - void ControlvWriteByte(struct vnt_private *pDevice, u8 reg, u8 reg_off, u8 data); diff --git a/drivers/staging/vt6656/firmware.c b/drivers/staging/vt6656/firmware.c index 13b68d5c5588..f9d685f00300 100644 --- a/drivers/staging/vt6656/firmware.c +++ b/drivers/staging/vt6656/firmware.c @@ -116,7 +116,7 @@ int FIRMWAREbCheckVersion(struct vnt_private *pDevice) { int ntStatus; - ntStatus = CONTROLnsRequestIn(pDevice, + ntStatus = vnt_control_in(pDevice, MESSAGE_TYPE_READ, 0, MESSAGE_REQUEST_VERSION, diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 9e70aa5c29d1..01dd0680c012 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -322,7 +322,7 @@ static int device_init_registers(struct vnt_private *pDevice) return false; } - ntStatus = CONTROLnsRequestIn(pDevice, MESSAGE_TYPE_INIT_RSP, 0, 0, + ntStatus = vnt_control_in(pDevice, MESSAGE_TYPE_INIT_RSP, 0, 0, sizeof(struct vnt_rsp_card_init), (u8 *)init_rsp); if (ntStatus != STATUS_SUCCESS) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO @@ -331,7 +331,7 @@ static int device_init_registers(struct vnt_private *pDevice) } /* local ID for AES functions */ - ntStatus = CONTROLnsRequestIn(pDevice, MESSAGE_TYPE_READ, + ntStatus = vnt_control_in(pDevice, MESSAGE_TYPE_READ, MAC_REG_LOCALID, MESSAGE_REQUEST_MACREG, 1, &pDevice->byLocalID); if (ntStatus != STATUS_SUCCESS) @@ -535,7 +535,7 @@ static int device_init_registers(struct vnt_private *pDevice) pDevice->bHWRadioOff = false; if ((pDevice->byRadioCtl & EEP_RADIOCTL_ENABLE) != 0) { - ntStatus = CONTROLnsRequestIn(pDevice, MESSAGE_TYPE_READ, + ntStatus = vnt_control_in(pDevice, MESSAGE_TYPE_READ, MAC_REG_GPIOCTL1, MESSAGE_REQUEST_MACREG, 1, &byTmp); if (ntStatus != STATUS_SUCCESS) @@ -1269,7 +1269,7 @@ void vnt_configure_filter(struct vnt_private *priv) u8 tmp = 0; int rc; - rc = CONTROLnsRequestIn(priv, MESSAGE_TYPE_READ, + rc = vnt_control_in(priv, MESSAGE_TYPE_READ, MAC_REG_RCR, MESSAGE_REQUEST_MACREG, 1, &tmp); if (rc == 0) priv->byRxMode = tmp; diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 443338eb18bf..7d4e131303de 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -27,7 +27,7 @@ * * Functions: * vnt_control_out - Write variable length bytes to MEM/BB/MAC/EEPROM - * CONTROLnsRequestIn - Read variable length bytes from MEM/BB/MAC/EEPROM + * vnt_control_in - 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 @@ -83,7 +83,7 @@ int vnt_control_out(struct vnt_private *priv, u8 request, u16 value, return STATUS_SUCCESS; } -int PIPEnsControlIn(struct vnt_private *priv, u8 request, u16 value, +int vnt_control_in(struct vnt_private *priv, u8 request, u16 value, u16 index, u16 length, u8 *buffer) { int status; diff --git a/drivers/staging/vt6656/usbpipe.h b/drivers/staging/vt6656/usbpipe.h index 6ca250f8aeaf..f04e30bfbfae 100644 --- a/drivers/staging/vt6656/usbpipe.h +++ b/drivers/staging/vt6656/usbpipe.h @@ -33,8 +33,7 @@ #include "device.h" int vnt_control_out(struct vnt_private *, u8, u16, u16, u16, u8 *); -int PIPEnsControlIn(struct vnt_private *, u8 byRequest, u16 wValue, - u16 wIndex, u16 wLength, u8 *pbyBuffer); +int vnt_control_in(struct vnt_private *, u8, u16, u16, u16, u8 *); int PIPEnsInterruptRead(struct vnt_private *); int PIPEnsBulkInUsbRead(struct vnt_private *, struct vnt_rcb *pRCB); diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c index 99477944c045..aae573baec1b 100644 --- a/drivers/staging/vt6656/wcmd.c +++ b/drivers/staging/vt6656/wcmd.c @@ -725,7 +725,7 @@ void vRunCommand(struct work_struct *work) int ntStatus = STATUS_SUCCESS; u8 byTmp; - ntStatus = CONTROLnsRequestIn(pDevice, + ntStatus = vnt_control_in(pDevice, MESSAGE_TYPE_READ, MAC_REG_GPIOCTL1, MESSAGE_REQUEST_MACREG, -- cgit v1.2.3 From 285d58c486a1b0921a10730772b64e38cb06ae54 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 26 May 2014 13:59:03 +0100 Subject: staging: vt6656: replace ControlvWriteByte with vnt_control_out_u8 add new function in usbpipe.c to replace ControlvWriteByte Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 26 +++++++++++++------------- drivers/staging/vt6656/card.c | 12 ++++++------ drivers/staging/vt6656/control.c | 11 ----------- drivers/staging/vt6656/control.h | 3 --- drivers/staging/vt6656/main_usb.c | 12 ++++++------ drivers/staging/vt6656/usbpipe.c | 8 +++++++- drivers/staging/vt6656/usbpipe.h | 2 ++ 7 files changed, 34 insertions(+), 40 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index 8a965bf821c5..3373812c80bc 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -1028,17 +1028,17 @@ int BBbVT3184Init(struct vnt_private *priv) if ((priv->byRFType == RF_VT3226) || (priv->byRFType == RF_VT3342A0)) { - ControlvWriteByte(priv, MESSAGE_REQUEST_MACREG, + vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG, MAC_REG_ITRTMSET, 0x23); MACvRegBitsOn(priv, MAC_REG_PAPEDELAY, 0x01); } else if (priv->byRFType == RF_VT3226D0) { - ControlvWriteByte(priv, MESSAGE_REQUEST_MACREG, + vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG, MAC_REG_ITRTMSET, 0x11); MACvRegBitsOn(priv, MAC_REG_PAPEDELAY, 0x01); } - ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0x04, 0x7f); - ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0x01); + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x04, 0x7f); + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0x01); RFbRFTableDownload(priv); @@ -1081,13 +1081,13 @@ void BBvSetShortSlotTime(struct vnt_private *priv) if (bb_vga == priv->abyBBVGA[0]) priv->byBBRxConf |= 0x20; - ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0x0a, priv->byBBRxConf); + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0a, priv->byBBRxConf); } void BBvSetVGAGainOffset(struct vnt_private *priv, u8 data) { - ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0xE7, data); + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0xE7, data); /* patch for 3253B0 Baseband with Cardbus module */ if (priv->bShortSlotTime) @@ -1095,7 +1095,7 @@ void BBvSetVGAGainOffset(struct vnt_private *priv, u8 data) else priv->byBBRxConf |= 0x20; /* 0010 0000 */ - ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0x0a, priv->byBBRxConf); + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0a, priv->byBBRxConf); } /* @@ -1112,14 +1112,14 @@ void BBvSetVGAGainOffset(struct vnt_private *priv, u8 data) */ void BBvSetDeepSleep(struct vnt_private *priv) { - ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0x0c, 0x17);/* CR12 */ - ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0xB9);/* CR13 */ + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0c, 0x17);/* CR12 */ + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0xB9);/* CR13 */ } void BBvExitDeepSleep(struct vnt_private *priv) { - ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0x0c, 0x00);/* CR12 */ - ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0x01);/* CR13 */ + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0c, 0x00);/* CR12 */ + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0x01);/* CR13 */ } void BBvUpdatePreEDThreshold(struct vnt_private *priv, int scanning) @@ -1384,7 +1384,7 @@ void BBvUpdatePreEDThreshold(struct vnt_private *priv, int scanning) if (!cr_201 && !cr_206) return; - ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0xc9, cr_201); - ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0xce, cr_206); + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0xc9, cr_201); + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0xce, cr_206); } diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index 1f20e9adc923..9313730117fc 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -111,7 +111,7 @@ void CARDbSetMediaChannel(struct vnt_private *priv, u32 connection_channel) priv->abyCCKPwrTbl[connection_channel-1], RATE_1M); } - ControlvWriteByte(priv, MESSAGE_REQUEST_MACREG, MAC_REG_CHANNEL, + vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG, MAC_REG_CHANNEL, (u8)(connection_channel|0x80)); } @@ -844,11 +844,11 @@ void CARDvSetBSSMode(struct vnt_private *priv) priv->byPacketType = CARDbyGetPktType(priv); if (priv->byBBType == BB_TYPE_11A) - ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0x88, 0x03); + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x88, 0x03); else if (priv->byBBType == BB_TYPE_11B) - ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0x88, 0x02); + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x88, 0x02); else if (priv->byBBType == BB_TYPE_11G) - ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0x88, 0x08); + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x88, 0x08); vUpdateIFS(priv); CARDvSetRSPINF(priv, (u8)priv->byBBType); @@ -857,7 +857,7 @@ void CARDvSetBSSMode(struct vnt_private *priv) if (priv->byRFType == RF_AIROHA7230) { priv->abyBBVGA[0] = 0x20; - ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0xe7, priv->abyBBVGA[0]); } @@ -867,7 +867,7 @@ void CARDvSetBSSMode(struct vnt_private *priv) if (priv->byRFType == RF_AIROHA7230) { priv->abyBBVGA[0] = 0x1c; - ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, + vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0xe7, priv->abyBBVGA[0]); } diff --git a/drivers/staging/vt6656/control.c b/drivers/staging/vt6656/control.c index 0c59d6d13f9b..14346a6b928e 100644 --- a/drivers/staging/vt6656/control.c +++ b/drivers/staging/vt6656/control.c @@ -27,7 +27,6 @@ * * Functions: * vnt_control_out - Write variable length bytes to 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 @@ -44,16 +43,6 @@ /* static int msglevel =MSG_LEVEL_INFO; */ /* static int msglevel =MSG_LEVEL_DEBUG; */ -void ControlvWriteByte(struct vnt_private *pDevice, u8 reg, u8 reg_off, - u8 data) -{ - - vnt_control_out(pDevice, MESSAGE_TYPE_WRITE, reg_off, reg, - sizeof(u8), &data); - - return; -} - void ControlvReadByte(struct vnt_private *pDevice, u8 reg, u8 reg_off, u8 *data) { diff --git a/drivers/staging/vt6656/control.h b/drivers/staging/vt6656/control.h index db9dd54c7623..e4e252ecbc28 100644 --- a/drivers/staging/vt6656/control.h +++ b/drivers/staging/vt6656/control.h @@ -33,9 +33,6 @@ #include "device.h" #include "usbpipe.h" -void ControlvWriteByte(struct vnt_private *pDevice, u8 reg, u8 reg_off, - u8 data); - void ControlvReadByte(struct vnt_private *pDevice, u8 reg, u8 reg_off, u8 *data); diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 01dd0680c012..6cc056d07a22 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -468,28 +468,28 @@ static int device_init_registers(struct vnt_private *pDevice) byCalibRXIQ = pDevice->abyEEPROM[EEP_OFS_CALIB_RX_IQ]; if (byCalibTXIQ || byCalibTXDC || byCalibRXIQ) { /* CR255, enable TX/RX IQ and DC compensation mode */ - ControlvWriteByte(pDevice, + vnt_control_out_u8(pDevice, MESSAGE_REQUEST_BBREG, 0xff, 0x03); /* CR251, TX I/Q Imbalance Calibration */ - ControlvWriteByte(pDevice, + vnt_control_out_u8(pDevice, MESSAGE_REQUEST_BBREG, 0xfb, byCalibTXIQ); /* CR252, TX DC-Offset Calibration */ - ControlvWriteByte(pDevice, + vnt_control_out_u8(pDevice, MESSAGE_REQUEST_BBREG, 0xfC, byCalibTXDC); /* CR253, RX I/Q Imbalance Calibration */ - ControlvWriteByte(pDevice, + vnt_control_out_u8(pDevice, MESSAGE_REQUEST_BBREG, 0xfd, byCalibRXIQ); } else { /* CR255, turn off BB Calibration compensation */ - ControlvWriteByte(pDevice, + vnt_control_out_u8(pDevice, MESSAGE_REQUEST_BBREG, 0xff, 0x0); @@ -1310,7 +1310,7 @@ void vnt_configure_filter(struct vnt_private *priv) priv->byRxMode &= ~(RCR_UNICAST); } - ControlvWriteByte(priv, MESSAGE_REQUEST_MACREG, + vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG, MAC_REG_RCR, priv->byRxMode); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 7d4e131303de..2264c8c7ec7e 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -28,7 +28,7 @@ * Functions: * vnt_control_out - Write variable length bytes to MEM/BB/MAC/EEPROM * vnt_control_in - Read variable length bytes from MEM/BB/MAC/EEPROM - * ControlvWriteByte - Write one byte to MEM/BB/MAC/EEPROM + * vnt_control_out_u8 - 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 * @@ -83,6 +83,12 @@ int vnt_control_out(struct vnt_private *priv, u8 request, u16 value, return STATUS_SUCCESS; } +void vnt_control_out_u8(struct vnt_private *priv, u8 reg, u8 reg_off, u8 data) +{ + vnt_control_out(priv, MESSAGE_TYPE_WRITE, + reg_off, reg, sizeof(u8), &data); +} + int vnt_control_in(struct vnt_private *priv, u8 request, u16 value, u16 index, u16 length, u8 *buffer) { diff --git a/drivers/staging/vt6656/usbpipe.h b/drivers/staging/vt6656/usbpipe.h index f04e30bfbfae..a3d3bacd4d66 100644 --- a/drivers/staging/vt6656/usbpipe.h +++ b/drivers/staging/vt6656/usbpipe.h @@ -35,6 +35,8 @@ int vnt_control_out(struct vnt_private *, u8, u16, u16, u16, u8 *); int vnt_control_in(struct vnt_private *, u8, u16, u16, u16, u8 *); +void vnt_control_out_u8(struct vnt_private *, u8, u8, u8); + int PIPEnsInterruptRead(struct vnt_private *); int PIPEnsBulkInUsbRead(struct vnt_private *, struct vnt_rcb *pRCB); int PIPEnsSendBulkOut(struct vnt_private *, -- cgit v1.2.3 From 96f6975bd3841a227185712bbd672c278e481816 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 26 May 2014 13:59:04 +0100 Subject: staging: vt6656: Create new function to set led state. Create vnt_mac_set_led to set state and led. state has two modes LEDSTS_TMLEN which sets the blink rate on TX activity and LEDSTS_STS which sets the led. As result of this patch ControlvMaskByte becomes dead code. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/bssdb.c | 14 ++++++-------- drivers/staging/vt6656/iwctl.c | 4 +--- drivers/staging/vt6656/mac.c | 13 +++++++++++++ drivers/staging/vt6656/mac.h | 1 + drivers/staging/vt6656/main_usb.c | 6 ++---- drivers/staging/vt6656/wcmd.c | 30 +++++++++++++++++++++--------- drivers/staging/vt6656/wmgr.c | 14 ++++++++++---- 7 files changed, 54 insertions(+), 28 deletions(-) diff --git a/drivers/staging/vt6656/bssdb.c b/drivers/staging/vt6656/bssdb.c index 5f631c8f522b..12b6436eb2a3 100644 --- a/drivers/staging/vt6656/bssdb.c +++ b/drivers/staging/vt6656/bssdb.c @@ -1015,10 +1015,10 @@ void BSSvSecondCallBack(struct work_struct *work) pMgmt->eCurrState = WMAC_STATE_IDLE; netif_stop_queue(pDevice->dev); pDevice->bLinkPass = false; - ControlvMaskByte(pDevice, - MESSAGE_REQUEST_MACREG, - MAC_REG_PAPEDELAY, LEDSTS_STS, - LEDSTS_SLOW); + + vnt_mac_set_led(pDevice, LEDSTS_STS, + LEDSTS_SLOW); + pDevice->bRoaming = true; pDevice->bIsRoaming = false; @@ -1126,10 +1126,8 @@ void BSSvSecondCallBack(struct work_struct *work) pMgmt->eCurrState = WMAC_STATE_STARTED; netif_stop_queue(pDevice->dev); pDevice->bLinkPass = false; - ControlvMaskByte(pDevice, - MESSAGE_REQUEST_MACREG, - MAC_REG_PAPEDELAY, LEDSTS_STS, - LEDSTS_SLOW); + vnt_mac_set_led(pDevice, LEDSTS_STS, + LEDSTS_SLOW); } } } diff --git a/drivers/staging/vt6656/iwctl.c b/drivers/staging/vt6656/iwctl.c index e7b7ca5586cc..0a8e4384d83b 100644 --- a/drivers/staging/vt6656/iwctl.c +++ b/drivers/staging/vt6656/iwctl.c @@ -442,9 +442,7 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info, memset(pMgmt->abyCurrBSSID, 0, 6); } - ControlvMaskByte(pDevice, - MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, - LEDSTS_STS, LEDSTS_SLOW); + vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_SLOW); netif_stop_queue(pDevice->dev); diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index 51e4a355d9d7..fdb244f9e3a9 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -240,3 +240,16 @@ void MACvWriteBeaconInterval(struct vnt_private *priv, u16 interval) vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_BI, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } + +void vnt_mac_set_led(struct vnt_private *priv, u8 state, u8 led) +{ + u8 data[2]; + + data[0] = led; + data[1] = state; + + vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, MAC_REG_PAPEDELAY, + MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); + + return; +} diff --git a/drivers/staging/vt6656/mac.h b/drivers/staging/vt6656/mac.h index 6e45d479bffb..986ca95f7204 100644 --- a/drivers/staging/vt6656/mac.h +++ b/drivers/staging/vt6656/mac.h @@ -428,5 +428,6 @@ void MACvDisableProtectMD(struct vnt_private *); void MACvEnableBarkerPreambleMd(struct vnt_private *); void MACvDisableBarkerPreambleMd(struct vnt_private *); void MACvWriteBeaconInterval(struct vnt_private *, u16); +void vnt_mac_set_led(struct vnt_private *priv, u8, u8); #endif /* __MAC_H__ */ diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 6cc056d07a22..df206e607680 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -551,11 +551,9 @@ static int device_init_registers(struct vnt_private *pDevice) } - ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, - MAC_REG_PAPEDELAY, LEDSTS_TMLEN, 0x38); + vnt_mac_set_led(pDevice, LEDSTS_TMLEN, 0x38); - ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, - MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_SLOW); + vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_SLOW); MACvRegBitsOn(pDevice, MAC_REG_GPIOCTL0, 0x01); diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c index aae573baec1b..79f7463be443 100644 --- a/drivers/staging/vt6656/wcmd.c +++ b/drivers/staging/vt6656/wcmd.c @@ -426,7 +426,9 @@ void vRunCommand(struct work_struct *work) (8), &Status); pDevice->bLinkPass = false; - ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_SLOW); + + vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_SLOW); + // unlock command busy pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; pItemSSID->len = 0; @@ -472,7 +474,8 @@ void vRunCommand(struct work_struct *work) } netif_stop_queue(pDevice->dev); pDevice->bLinkPass = false; - ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_SLOW); + + vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_SLOW); } // set initial state pMgmt->eCurrState = WMAC_STATE_IDLE; @@ -507,7 +510,9 @@ void vRunCommand(struct work_struct *work) if (netif_queue_stopped(pDevice->dev)) netif_wake_queue(pDevice->dev); pDevice->bLinkPass = true; - ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_INTER); + + vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_INTER); + pMgmt->sNodeDBTable[0].bActive = true; pMgmt->sNodeDBTable[0].uInActiveCount = 0; } else { @@ -538,7 +543,6 @@ void vRunCommand(struct work_struct *work) s_bClearBSSID_SCAN(pDevice); /* pDevice->bLinkPass = true; - ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER); if (netif_queue_stopped(pDevice->dev)){ netif_wake_queue(pDevice->dev); } @@ -600,7 +604,9 @@ void vRunCommand(struct work_struct *work) pDevice->byLinkWaitCount = 0; pDevice->byReAssocCount = 0; pDevice->bLinkPass = true; - ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_INTER); + + vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_INTER); + s_bClearBSSID_SCAN(pDevice); if (netif_queue_stopped(pDevice->dev)) @@ -626,7 +632,8 @@ void vRunCommand(struct work_struct *work) pMgmt->eCurrState = WMAC_STATE_IDLE; pMgmt->eCurrMode = WMAC_MODE_STANDBY; pDevice->bLinkPass = false; - ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_SLOW); + + vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_SLOW); BSSvClearNodeDBTable(pDevice, 0); @@ -647,7 +654,9 @@ void vRunCommand(struct work_struct *work) if (netif_queue_stopped(pDevice->dev)) netif_wake_queue(pDevice->dev); pDevice->bLinkPass = true; - ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_INTER); + + vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_INTER); + schedule_delayed_work(&pDevice->second_callback_work, HZ); } break; @@ -791,14 +800,17 @@ void vRunCommand(struct work_struct *work) netif_stop_queue(pDevice->dev); CARDbRadioPowerOff(pDevice); MACvRegBitsOn(pDevice, MAC_REG_GPIOCTL1, GPIO3_INTMD); - ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_OFF); + + vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_OFF); + pDevice->bHWRadioOff = true; } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" WLAN_CMD_RADIO_START_ON........................\n"); pDevice->bHWRadioOff = false; CARDbRadioPowerOn(pDevice); MACvRegBitsOff(pDevice, MAC_REG_GPIOCTL1, GPIO3_INTMD); - ControlvMaskByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PAPEDELAY, LEDSTS_STS, LEDSTS_ON); + + vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_ON); } } diff --git a/drivers/staging/vt6656/wmgr.c b/drivers/staging/vt6656/wmgr.c index 4f46aa6e25f5..8cb80a677335 100644 --- a/drivers/staging/vt6656/wmgr.c +++ b/drivers/staging/vt6656/wmgr.c @@ -756,7 +756,8 @@ static void s_vMgrRxAssocResponse(struct vnt_private *pDevice, pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID; DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Link with AP(SSID): %s\n", pItemSSID->abySSID); pDevice->bLinkPass = true; - ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER); + + vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_INTER); //if(pDevice->bWPASuppWextEnabled == true) { @@ -1398,7 +1399,8 @@ static void s_vMgrRxDeauthentication(struct vnt_private *pDevice, pMgmt->eCurrState = WMAC_STATE_IDLE; netif_stop_queue(pDevice->dev); pDevice->bLinkPass = false; - ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW); + + vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_SLOW); } } @@ -1883,7 +1885,9 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==true) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Current IBSS State: [Started]........to: [Jointed] \n"); pMgmt->eCurrState = WMAC_STATE_JOINTED; pDevice->bLinkPass = true; - ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER); + + vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_INTER); + if (netif_queue_stopped(pDevice->dev)){ netif_wake_queue(pDevice->dev); } @@ -2488,7 +2492,9 @@ void vMgrJoinBSSBegin(struct vnt_private *pDevice, PCMD_STATUS pStatus) // Adopt BSS state in Adapter Device Object pDevice->op_mode = NL80211_IFTYPE_ADHOC; pDevice->bLinkPass = true; - ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_INTER); + + vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_INTER); + memcpy(pDevice->abyBSSID, pCurr->abyBSSID, WLAN_BSSID_LEN); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Join IBSS ok:%pM\n", -- cgit v1.2.3 From 3d61e4c7883e3f8476a3bb08a0d49dd9b6281ea0 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 26 May 2014 13:59:05 +0100 Subject: staging: vt6656: remove dead code ControlvMaskByte Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/control.c | 14 -------------- drivers/staging/vt6656/control.h | 3 --- 2 files changed, 17 deletions(-) diff --git a/drivers/staging/vt6656/control.c b/drivers/staging/vt6656/control.c index 14346a6b928e..b6e31f3cf962 100644 --- a/drivers/staging/vt6656/control.c +++ b/drivers/staging/vt6656/control.c @@ -50,17 +50,3 @@ void ControlvReadByte(struct vnt_private *pDevice, u8 reg, u8 reg_off, reg_off, reg, sizeof(u8), data); return; } - -void ControlvMaskByte(struct vnt_private *pDevice, u8 reg_type, u8 reg_off, - u8 reg_mask, u8 data) -{ - u8 reg_data[2]; - - reg_data[0] = data; - reg_data[1] = reg_mask; - - vnt_control_out(pDevice, MESSAGE_TYPE_WRITE_MASK, reg_off, - reg_type, ARRAY_SIZE(reg_data), reg_data); - - return; -} diff --git a/drivers/staging/vt6656/control.h b/drivers/staging/vt6656/control.h index e4e252ecbc28..48f4836a5146 100644 --- a/drivers/staging/vt6656/control.h +++ b/drivers/staging/vt6656/control.h @@ -36,7 +36,4 @@ void ControlvReadByte(struct vnt_private *pDevice, u8 reg, u8 reg_off, u8 *data); -void ControlvMaskByte(struct vnt_private *pDevice, u8 reg_type, u8 reg_off, - u8 reg_mask, u8 data); - #endif /* __CONTROL_H__ */ -- cgit v1.2.3 From 53742906bca9f035ec97fe3578c6064e015c3821 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 26 May 2014 13:59:06 +0100 Subject: staging: vt6656: create vnt_control_in_u8 to replace ControlvReadByte ControlvReadByte will be removed in next patch Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 2 +- drivers/staging/vt6656/power.c | 2 +- drivers/staging/vt6656/usbpipe.c | 9 +++++++-- drivers/staging/vt6656/usbpipe.h | 1 + drivers/staging/vt6656/wcmd.c | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index 3373812c80bc..4cdea2cfdd29 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -1076,7 +1076,7 @@ void BBvSetShortSlotTime(struct vnt_private *priv) else priv->byBBRxConf |= 0x20; - ControlvReadByte(priv, MESSAGE_REQUEST_BBREG, 0xe7, &bb_vga); + vnt_control_in_u8(priv, MESSAGE_REQUEST_BBREG, 0xe7, &bb_vga); if (bb_vga == priv->abyBBVGA[0]) priv->byBBRxConf |= 0x20; diff --git a/drivers/staging/vt6656/power.c b/drivers/staging/vt6656/power.c index a5cea43b8bc1..b8ebf589fd9f 100644 --- a/drivers/staging/vt6656/power.c +++ b/drivers/staging/vt6656/power.c @@ -162,7 +162,7 @@ int PSbConsiderPowerDown(struct vnt_private *pDevice, int bCheckRxDMA, u8 byData; /* check if already in Doze mode */ - ControlvReadByte(pDevice, MESSAGE_REQUEST_MACREG, + vnt_control_in_u8(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PSCTL, &byData); if ((byData & PSCTL_PS) != 0) diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 2264c8c7ec7e..fc68badd8636 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -29,7 +29,7 @@ * vnt_control_out - Write variable length bytes to MEM/BB/MAC/EEPROM * vnt_control_in - Read variable length bytes from MEM/BB/MAC/EEPROM * vnt_control_out_u8 - Write one byte to MEM/BB/MAC/EEPROM - * ControlvReadByte - Read one byte from MEM/BB/MAC/EEPROM + * vnt_control_in_u8 - 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 * * Revision History: @@ -41,7 +41,6 @@ #include "int.h" #include "rxtx.h" #include "dpc.h" -#include "control.h" #include "desc.h" #include "device.h" @@ -111,6 +110,12 @@ int vnt_control_in(struct vnt_private *priv, u8 request, u16 value, return STATUS_SUCCESS; } +void vnt_control_in_u8(struct vnt_private *priv, u8 reg, u8 reg_off, u8 *data) +{ + vnt_control_in(priv, MESSAGE_TYPE_READ, + reg_off, reg, sizeof(u8), data); +} + /* * Description: * Allocates an usb interrupt in irp and calls USBD. diff --git a/drivers/staging/vt6656/usbpipe.h b/drivers/staging/vt6656/usbpipe.h index a3d3bacd4d66..ea71782d8901 100644 --- a/drivers/staging/vt6656/usbpipe.h +++ b/drivers/staging/vt6656/usbpipe.h @@ -36,6 +36,7 @@ int vnt_control_out(struct vnt_private *, u8, u16, u16, u16, u8 *); int vnt_control_in(struct vnt_private *, u8, u16, u16, u16, u8 *); void vnt_control_out_u8(struct vnt_private *, u8, u8, u8); +void vnt_control_in_u8(struct vnt_private *, u8, u8, u8 *); int PIPEnsInterruptRead(struct vnt_private *); int PIPEnsBulkInUsbRead(struct vnt_private *, struct vnt_rcb *pRCB); diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c index 79f7463be443..91754fd2cedb 100644 --- a/drivers/staging/vt6656/wcmd.c +++ b/drivers/staging/vt6656/wcmd.c @@ -861,7 +861,7 @@ void vRunCommand(struct work_struct *work) break; case WLAN_CMD_MAC_DISPOWERSAVING_START: - ControlvReadByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PSCTL, &byData); + vnt_control_in_u8(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PSCTL, &byData); if ((byData & PSCTL_PS) != 0) { // disable power saving hw function vnt_control_out(pDevice, -- cgit v1.2.3 From 62c8526d60181da14fa73a43ed23f3314523b4f5 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 26 May 2014 13:59:07 +0100 Subject: staging: vt6656: dead code remove control.c/h Replace control.h headers with usbpipe.h Also add to usbpipe.c its header Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/Makefile | 1 - drivers/staging/vt6656/baseband.c | 2 +- drivers/staging/vt6656/bssdb.c | 2 +- drivers/staging/vt6656/card.c | 2 +- drivers/staging/vt6656/control.c | 52 --------------------------------------- drivers/staging/vt6656/control.h | 39 ----------------------------- drivers/staging/vt6656/firmware.c | 2 +- drivers/staging/vt6656/iwctl.c | 2 +- drivers/staging/vt6656/key.c | 2 +- drivers/staging/vt6656/mac.c | 2 +- drivers/staging/vt6656/main_usb.c | 2 +- drivers/staging/vt6656/power.c | 2 +- drivers/staging/vt6656/rf.c | 2 +- drivers/staging/vt6656/usbpipe.c | 1 + drivers/staging/vt6656/wcmd.c | 2 +- drivers/staging/vt6656/wmgr.c | 2 +- drivers/staging/vt6656/wpactl.c | 2 +- 17 files changed, 14 insertions(+), 105 deletions(-) delete mode 100644 drivers/staging/vt6656/control.c delete mode 100644 drivers/staging/vt6656/control.h diff --git a/drivers/staging/vt6656/Makefile b/drivers/staging/vt6656/Makefile index e39d2492f24f..b5ec483f3eb4 100644 --- a/drivers/staging/vt6656/Makefile +++ b/drivers/staging/vt6656/Makefile @@ -27,7 +27,6 @@ vt6656_stage-y += main_usb.o \ wpactl.o \ usbpipe.o \ channel.o \ - control.o \ firmware.o \ int.o diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index 4cdea2cfdd29..d96308f00d22 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -40,7 +40,7 @@ #include "mac.h" #include "baseband.h" #include "rf.h" -#include "control.h" +#include "usbpipe.h" #include "datarate.h" static u8 abyVT3184_AGC[] = { diff --git a/drivers/staging/vt6656/bssdb.c b/drivers/staging/vt6656/bssdb.c index 12b6436eb2a3..f53d3bf629be 100644 --- a/drivers/staging/vt6656/bssdb.c +++ b/drivers/staging/vt6656/bssdb.c @@ -53,7 +53,7 @@ #include "card.h" #include "mac.h" #include "wpa2.h" -#include "control.h" +#include "usbpipe.h" #include "iowpa.h" #include "power.h" diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index 9313730117fc..06f8b00c6746 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -57,7 +57,7 @@ #include "rc4.h" #include "country.h" #include "datarate.h" -#include "control.h" +#include "usbpipe.h" //const u16 cwRXBCNTSFOff[MAX_RATE] = //{17, 34, 96, 192, 34, 23, 17, 11, 8, 5, 4, 3}; diff --git a/drivers/staging/vt6656/control.c b/drivers/staging/vt6656/control.c deleted file mode 100644 index b6e31f3cf962..000000000000 --- a/drivers/staging/vt6656/control.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: control.c - * - * Purpose: Handle USB control endpoint - * - * Author: Jerry Chen - * - * Date: Apr. 5, 2004 - * - * Functions: - * vnt_control_out - Write variable length bytes 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 - * - * Revision History: - * 04-05-2004 Jerry Chen: Initial release - * 11-24-2004 Warren Hsu: Add ControlvWriteByte, ControlvReadByte, - * ControlvMaskByte - * - */ - -#include "control.h" - -/* static int msglevel =MSG_LEVEL_INFO; */ -/* static int msglevel =MSG_LEVEL_DEBUG; */ - -void ControlvReadByte(struct vnt_private *pDevice, u8 reg, u8 reg_off, - u8 *data) -{ - vnt_control_in(pDevice, MESSAGE_TYPE_READ, - reg_off, reg, sizeof(u8), data); - return; -} diff --git a/drivers/staging/vt6656/control.h b/drivers/staging/vt6656/control.h deleted file mode 100644 index 48f4836a5146..000000000000 --- a/drivers/staging/vt6656/control.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. - * All rights reserved. - * - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * File: control.h - * - * Purpose: - * - * Author: Jerry Chen - * - * Date: Apr. 5, 2004 - * - */ - -#ifndef __CONTROL_H__ -#define __CONTROL_H__ - -#include "device.h" -#include "usbpipe.h" - -void ControlvReadByte(struct vnt_private *pDevice, u8 reg, u8 reg_off, - u8 *data); - -#endif /* __CONTROL_H__ */ diff --git a/drivers/staging/vt6656/firmware.c b/drivers/staging/vt6656/firmware.c index f9d685f00300..1159f0b34578 100644 --- a/drivers/staging/vt6656/firmware.c +++ b/drivers/staging/vt6656/firmware.c @@ -33,7 +33,7 @@ #include #include "firmware.h" -#include "control.h" +#include "usbpipe.h" static int msglevel = MSG_LEVEL_INFO; /* static int msglevel = MSG_LEVEL_DEBUG; */ diff --git a/drivers/staging/vt6656/iwctl.c b/drivers/staging/vt6656/iwctl.c index 0a8e4384d83b..94b7fe8940ce 100644 --- a/drivers/staging/vt6656/iwctl.c +++ b/drivers/staging/vt6656/iwctl.c @@ -38,7 +38,7 @@ #include "rf.h" #include "iowpa.h" #include "wpactl.h" -#include "control.h" +#include "usbpipe.h" #include "baseband.h" static const long frequency_list[] = { diff --git a/drivers/staging/vt6656/key.c b/drivers/staging/vt6656/key.c index 11aa82a08f0e..38ea67531d97 100644 --- a/drivers/staging/vt6656/key.c +++ b/drivers/staging/vt6656/key.c @@ -39,7 +39,7 @@ #include "mac.h" #include "tmacro.h" #include "key.h" -#include "control.h" +#include "usbpipe.h" static int msglevel =MSG_LEVEL_INFO; //static int msglevel =MSG_LEVEL_DEBUG; diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index fdb244f9e3a9..cadf7cd280c3 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -35,7 +35,7 @@ #include "desc.h" #include "mac.h" #include "80211hdr.h" -#include "control.h" +#include "usbpipe.h" /* * Description: diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index df206e607680..e18071f121c5 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -65,7 +65,7 @@ #include "datarate.h" #include "rf.h" #include "firmware.h" -#include "control.h" +#include "usbpipe.h" #include "channel.h" #include "int.h" #include "iowpa.h" diff --git a/drivers/staging/vt6656/power.c b/drivers/staging/vt6656/power.c index b8ebf589fd9f..ddbd04695c99 100644 --- a/drivers/staging/vt6656/power.c +++ b/drivers/staging/vt6656/power.c @@ -44,7 +44,7 @@ #include "wcmd.h" #include "rxtx.h" #include "card.h" -#include "control.h" +#include "usbpipe.h" static int msglevel = MSG_LEVEL_INFO; diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c index 58ea16c8767d..d244dab498e0 100644 --- a/drivers/staging/vt6656/rf.c +++ b/drivers/staging/vt6656/rf.c @@ -38,7 +38,7 @@ #include "mac.h" #include "rf.h" #include "baseband.h" -#include "control.h" +#include "usbpipe.h" #include "datarate.h" static int msglevel =MSG_LEVEL_INFO; diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index fc68badd8636..e4751b71e4d3 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -43,6 +43,7 @@ #include "dpc.h" #include "desc.h" #include "device.h" +#include "usbpipe.h" //endpoint def //endpoint 0: control diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c index 91754fd2cedb..9a166fbcfa1f 100644 --- a/drivers/staging/vt6656/wcmd.c +++ b/drivers/staging/vt6656/wcmd.c @@ -48,7 +48,7 @@ #include "power.h" #include "wctl.h" #include "baseband.h" -#include "control.h" +#include "usbpipe.h" #include "rxtx.h" #include "rf.h" #include "channel.h" diff --git a/drivers/staging/vt6656/wmgr.c b/drivers/staging/vt6656/wmgr.c index 8cb80a677335..18723eab93d2 100644 --- a/drivers/staging/vt6656/wmgr.c +++ b/drivers/staging/vt6656/wmgr.c @@ -78,7 +78,7 @@ #include "wpa.h" #include "rf.h" #include "iowpa.h" -#include "control.h" +#include "usbpipe.h" static int msglevel = MSG_LEVEL_INFO; //static int msglevel =MSG_LEVEL_DEBUG; diff --git a/drivers/staging/vt6656/wpactl.c b/drivers/staging/vt6656/wpactl.c index 587e1117b8c7..0a067151eca5 100644 --- a/drivers/staging/vt6656/wpactl.c +++ b/drivers/staging/vt6656/wpactl.c @@ -38,7 +38,7 @@ #include "wmgr.h" #include "iocmd.h" #include "iowpa.h" -#include "control.h" +#include "usbpipe.h" #include "rf.h" static int msglevel = MSG_LEVEL_INFO; -- cgit v1.2.3 From 4e2a3040add9774ba2e959c0b95f79df3cc34b55 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 26 May 2014 13:59:08 +0100 Subject: staging: vt6656: Fix CARDvCalculateOFDMRParameter static warning Fix warning: symbol 'CARDvCalculateOFDMRParameter' was not declared. Should it be static? Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/card.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index 06f8b00c6746..5ad0a984eeb8 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -197,7 +197,7 @@ static u16 swGetOFDMControlRate(struct vnt_private *priv, u16 rate_idx) * Return Value: none * */ -void CARDvCalculateOFDMRParameter(u16 rate, u8 bb_type, +static void CARDvCalculateOFDMRParameter(u16 rate, u8 bb_type, u8 *tx_rate, u8 *rsv_time) { -- cgit v1.2.3 From 1156bc313df28842aaba14067ae6bacf03afda8b Mon Sep 17 00:00:00 2001 From: navin patidar Date: Mon, 26 May 2014 21:35:16 +0530 Subject: staging: rtl8188eu: Remove unused function rtw_interface_ps_func() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_pwrctrl.c | 9 --------- drivers/staging/rtl8188eu/include/rtw_pwrctrl.h | 2 -- 2 files changed, 11 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c index eaf26304143c..739e25041692 100644 --- a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c @@ -497,15 +497,6 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter) _init_timer(&(pwrctrlpriv->pwr_state_check_timer), padapter->pnetdev, pwr_state_check_handler, (u8 *)padapter); } -u8 rtw_interface_ps_func(struct adapter *padapter, enum hal_intf_ps_func efunc_id, u8 *val) -{ - u8 bResult = true; - rtw_hal_intf_ps_func(padapter, efunc_id, val); - - return bResult; -} - - inline void rtw_set_ips_deny(struct adapter *padapter, u32 ms) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; diff --git a/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h b/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h index 4211023081bf..54dfbf07564b 100644 --- a/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h +++ b/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h @@ -258,8 +258,6 @@ s32 LPS_RF_ON_check(struct adapter *adapter, u32 delay_ms); void LPS_Enter(struct adapter *adapter); void LPS_Leave(struct adapter *adapter); -u8 rtw_interface_ps_func(struct adapter *adapter, - enum hal_intf_ps_func efunc_id, u8 *val); void rtw_set_ips_deny(struct adapter *adapter, u32 ms); int _rtw_pwr_wakeup(struct adapter *adapter, u32 ips_defer_ms, const char *caller); -- cgit v1.2.3 From ad2963fb13c9ed1a50967c6a7c5033e294700b78 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Mon, 26 May 2014 21:35:17 +0530 Subject: staging: rtl8188eu: Remove unused function rtw_hal_intf_ps_func() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/hal_intf.c | 9 --------- drivers/staging/rtl8188eu/include/hal_intf.h | 3 --- 2 files changed, 12 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/hal_intf.c b/drivers/staging/rtl8188eu/hal/hal_intf.c index d75ca7a27c86..43eee48a2640 100644 --- a/drivers/staging/rtl8188eu/hal/hal_intf.c +++ b/drivers/staging/rtl8188eu/hal/hal_intf.c @@ -207,15 +207,6 @@ u32 rtw_hal_inirp_deinit(struct adapter *adapt) return _FAIL; } -u8 rtw_hal_intf_ps_func(struct adapter *adapt, - enum hal_intf_ps_func efunc_id, u8 *val) -{ - if (adapt->HalFunc.interface_ps_func) - return adapt->HalFunc.interface_ps_func(adapt, efunc_id, - val); - return _FAIL; -} - s32 rtw_hal_xmit(struct adapter *adapt, struct xmit_frame *pxmitframe) { if (adapt->HalFunc.hal_xmit) diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h index c274b349f61e..9228bc655efc 100644 --- a/drivers/staging/rtl8188eu/include/hal_intf.h +++ b/drivers/staging/rtl8188eu/include/hal_intf.h @@ -332,9 +332,6 @@ void rtw_hal_disable_interrupt(struct adapter *padapter); u32 rtw_hal_inirp_init(struct adapter *padapter); u32 rtw_hal_inirp_deinit(struct adapter *padapter); -u8 rtw_hal_intf_ps_func(struct adapter *padapter, - enum hal_intf_ps_func efunc_id, u8 *val); - s32 rtw_hal_xmit(struct adapter *padapter, struct xmit_frame *pxmitframe); s32 rtw_hal_mgnt_xmit(struct adapter *padapter, struct xmit_frame *pmgntframe); -- cgit v1.2.3 From 7270ad5f7e000dff8c643fe5981024a51c6d7179 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Mon, 26 May 2014 21:35:18 +0530 Subject: staging: rtl8188eu: Remove unused function pointer ->interface_ps_func Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/usb_halinit.c | 2 -- drivers/staging/rtl8188eu/include/hal_intf.h | 3 --- 2 files changed, 5 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index 0cb84aed4533..90201299de93 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -2272,7 +2272,5 @@ void rtl8188eu_set_hal_ops(struct adapter *adapt) halfunc->hal_xmit = &rtl8188eu_hal_xmit; halfunc->mgnt_xmit = &rtl8188eu_mgnt_xmit; - halfunc->interface_ps_func = &rtl8188eu_ps_func; - rtl8188e_set_hal_ops(halfunc); } diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h index 9228bc655efc..acdef1db98b0 100644 --- a/drivers/staging/rtl8188eu/include/hal_intf.h +++ b/drivers/staging/rtl8188eu/include/hal_intf.h @@ -218,9 +218,6 @@ struct hal_ops { void (*AntDivCompareHandler)(struct adapter *adapter, struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src); - u8 (*interface_ps_func)(struct adapter *padapter, - enum hal_intf_ps_func efunc_id, u8 *val); - s32 (*hal_xmit)(struct adapter *padapter, struct xmit_frame *pxmitframe); s32 (*mgnt_xmit)(struct adapter *padapter, -- cgit v1.2.3 From b56f4d326a5beeead8f4667d0323abd6c111f3de Mon Sep 17 00:00:00 2001 From: navin patidar Date: Mon, 26 May 2014 21:35:19 +0530 Subject: staging: rtl8188eu: Remove unused function rtl8188eu_ps_func() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/usb_halinit.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index 90201299de93..141f85ae5618 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -2226,12 +2226,6 @@ static void rtl8188eu_init_default_value(struct adapter *adapt) haldata->odmpriv.RFCalibrateInfo.ThermalValue_HP[i] = 0; } -static u8 rtl8188eu_ps_func(struct adapter *Adapter, enum hal_intf_ps_func efunc_id, u8 *val) -{ - u8 bResult = true; - return bResult; -} - void rtl8188eu_set_hal_ops(struct adapter *adapt) { struct hal_ops *halfunc = &adapt->HalFunc; -- cgit v1.2.3 From 4a55af8859bc68dec23cbb3b58f867e4a102c71f Mon Sep 17 00:00:00 2001 From: navin patidar Date: Mon, 26 May 2014 21:35:20 +0530 Subject: staging: rtl8188eu: Remove unused function ODM_MacStatusQuery() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm_HWConfig.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm_HWConfig.c b/drivers/staging/rtl8188eu/hal/odm_HWConfig.c index a755df35ec7d..0145a112e1d3 100644 --- a/drivers/staging/rtl8188eu/hal/odm_HWConfig.c +++ b/drivers/staging/rtl8188eu/hal/odm_HWConfig.c @@ -436,14 +436,6 @@ void ODM_PhyStatusQuery(struct odm_dm_struct *dm_odm, ODM_PhyStatusQuery_92CSeries(dm_odm, pPhyInfo, pPhyStatus, pPktinfo); } -/* For future use. */ -void ODM_MacStatusQuery(struct odm_dm_struct *dm_odm, u8 *mac_stat, - u8 macid, bool pkt_match_bssid, - bool pkttoself, bool pkt_beacon) -{ - /* 2011/10/19 Driver team will handle in the future. */ -} - enum HAL_STATUS ODM_ConfigRFWithHeaderFile(struct odm_dm_struct *dm_odm, enum rf_radio_path content, enum rf_radio_path rfpath) -- cgit v1.2.3 From 6a96ded956b248c9f7d2bfc8b4b2a8cfb9611cbd Mon Sep 17 00:00:00 2001 From: navin patidar Date: Mon, 26 May 2014 21:35:21 +0530 Subject: staging: rtl8188eu: Remove unused function odm_Init_RSSIForDM() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm_HWConfig.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm_HWConfig.c b/drivers/staging/rtl8188eu/hal/odm_HWConfig.c index 0145a112e1d3..f2e1d02b8ae3 100644 --- a/drivers/staging/rtl8188eu/hal/odm_HWConfig.c +++ b/drivers/staging/rtl8188eu/hal/odm_HWConfig.c @@ -275,10 +275,6 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, dm_odm->DM_FatTable.antsel_rx_keep_2 = pPhyStaRpt->antsel_rx_keep_2; } -void odm_Init_RSSIForDM(struct odm_dm_struct *dm_odm) -{ -} - static void odm_Process_RSSIForDM(struct odm_dm_struct *dm_odm, struct odm_phy_status_info *pPhyInfo, struct odm_per_pkt_info *pPktinfo) -- cgit v1.2.3 From 0c1fb098ff8ad3638004f9bd4b70346ebb1c2c3f Mon Sep 17 00:00:00 2001 From: navin patidar Date: Mon, 26 May 2014 21:35:22 +0530 Subject: staging: rtl8188eu: Remove function with empty defination dm_CheckStatistics() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188e_dm.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c b/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c index cf88bf247c85..4e9f79769c11 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c @@ -31,10 +31,6 @@ #include -static void dm_CheckStatistics(struct adapter *Adapter) -{ -} - /* Initialize GPIO setting registers */ static void dm_InitGPIOSetting(struct adapter *Adapter) { @@ -173,12 +169,6 @@ void rtl8188e_HalDmWatchDog(struct adapter *Adapter) if (Adapter->wdinfo.p2p_ps_mode) fw_ps_awake = false; - if (hw_init_completed && ((!fw_cur_in_ps) && fw_ps_awake)) { - /* Calculate Tx/Rx statistics. */ - dm_CheckStatistics(Adapter); - - } - /* ODM */ if (hw_init_completed) { struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; -- cgit v1.2.3 From 9c4b31bf31ca13a0c4987896fbe1082a2016ba80 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Mon, 26 May 2014 21:35:23 +0530 Subject: staging: rtl8188eu: Remove function rtw_hal_dm_deinit() rtw_hal_dm_deinit() calls rtl8188e_deinit_dm_priv() using funtion pointer. rtl8188e_deinit_dm_priv() has empty defination, so we can remove rtw_hal_dm_deinit() and later rtl8188e_deinit_dm_priv() also will be removed. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/hal_intf.c | 7 ------- drivers/staging/rtl8188eu/include/hal_intf.h | 1 - drivers/staging/rtl8188eu/os_dep/os_intfs.c | 2 -- 3 files changed, 10 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/hal_intf.c b/drivers/staging/rtl8188eu/hal/hal_intf.c index 43eee48a2640..d0ac4a183335 100644 --- a/drivers/staging/rtl8188eu/hal/hal_intf.c +++ b/drivers/staging/rtl8188eu/hal/hal_intf.c @@ -60,13 +60,6 @@ void rtw_hal_dm_init(struct adapter *adapt) adapt->HalFunc.dm_init(adapt); } -void rtw_hal_dm_deinit(struct adapter *adapt) -{ - /* cancel dm timer */ - if (adapt->HalFunc.dm_deinit) - adapt->HalFunc.dm_deinit(adapt); -} - void rtw_hal_sw_led_init(struct adapter *adapt) { if (adapt->HalFunc.InitSwLeds) diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h index acdef1db98b0..a8f25c9880e1 100644 --- a/drivers/staging/rtl8188eu/include/hal_intf.h +++ b/drivers/staging/rtl8188eu/include/hal_intf.h @@ -296,7 +296,6 @@ void rtw_hal_def_value_init(struct adapter *padapter); void rtw_hal_free_data(struct adapter *padapter); void rtw_hal_dm_init(struct adapter *padapter); -void rtw_hal_dm_deinit(struct adapter *padapter); void rtw_hal_sw_led_init(struct adapter *padapter); void rtw_hal_sw_led_deinit(struct adapter *padapter); diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index 9edb8e880ae8..c1368b8c8a68 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -951,8 +951,6 @@ void rtw_cancel_all_timer(struct adapter *padapter) _cancel_timer_ex(&padapter->pwrctrlpriv.pwr_state_check_timer); _cancel_timer_ex(&padapter->recvpriv.signal_stat_timer); - /* cancel dm timer */ - rtw_hal_dm_deinit(padapter); } u8 rtw_free_drv_sw(struct adapter *padapter) -- cgit v1.2.3 From 4a7a4b6f3521e0711be56383851a4c87772ba2a9 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Mon, 26 May 2014 21:35:24 +0530 Subject: staging: rtl8188eu: Remove unused function pointer ->dm_init Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c | 1 - drivers/staging/rtl8188eu/include/hal_intf.h | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c index f9d5558431e0..5a22c6df4d06 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c @@ -1843,7 +1843,6 @@ void rtl8188e_set_hal_ops(struct hal_ops *pHalFunc) pHalFunc->free_hal_data = &rtl8188e_free_hal_data; pHalFunc->dm_init = &rtl8188e_init_dm_priv; - pHalFunc->dm_deinit = &rtl8188e_deinit_dm_priv; pHalFunc->read_chip_version = &rtl8188e_read_chip_version; diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h index a8f25c9880e1..c59fccde39c5 100644 --- a/drivers/staging/rtl8188eu/include/hal_intf.h +++ b/drivers/staging/rtl8188eu/include/hal_intf.h @@ -166,7 +166,6 @@ struct hal_ops { void (*DeInitSwLeds)(struct adapter *padapter); void (*dm_init)(struct adapter *padapter); - void (*dm_deinit)(struct adapter *padapter); void (*read_chip_version)(struct adapter *padapter); void (*init_default_value)(struct adapter *padapter); -- cgit v1.2.3 From 9eb1438c36c45bd52935818308ffd76ac0f5e5ef Mon Sep 17 00:00:00 2001 From: navin patidar Date: Mon, 26 May 2014 21:35:25 +0530 Subject: staging: rtl8188eu: Remove unused function rtl8188e_deinit_dm_priv() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188e_dm.c | 4 ---- drivers/staging/rtl8188eu/include/rtl8188e_dm.h | 1 - 2 files changed, 5 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c b/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c index 4e9f79769c11..d5cd30bcb3c7 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c @@ -203,10 +203,6 @@ void rtl8188e_init_dm_priv(struct adapter *Adapter) ODM_InitDebugSetting(podmpriv); } -void rtl8188e_deinit_dm_priv(struct adapter *Adapter) -{ -} - /* Add new function to reset the state of antenna diversity before link. */ /* Compare RSSI for deciding antenna */ void AntDivCompare8188E(struct adapter *Adapter, struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src) diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_dm.h b/drivers/staging/rtl8188eu/include/rtl8188e_dm.h index 97a3175250ef..5e0ac31ef464 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_dm.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_dm.h @@ -51,7 +51,6 @@ struct dm_priv { }; void rtl8188e_init_dm_priv(struct adapter *adapt); -void rtl8188e_deinit_dm_priv(struct adapter *adapt); void rtl8188e_InitHalDm(struct adapter *adapt); void rtl8188e_HalDmWatchDog(struct adapter *adapt); -- cgit v1.2.3 From f3f64d27d19660bac79bd42475f76651e649f309 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Mon, 26 May 2014 21:35:26 +0530 Subject: staging: rtl8188eu: remove unused header inclusion from rtw_mp.c Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mp.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mp.c b/drivers/staging/rtl8188eu/core/rtw_mp.c index 705f666bca6b..17427a68b66c 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mp.c +++ b/drivers/staging/rtl8188eu/core/rtw_mp.c @@ -21,7 +21,6 @@ #include -#include "odm_precomp.h" #include "rtl8188e_hal.h" #include -- cgit v1.2.3 From e194573874bc2694a7e78102c3af2e4ffd6e100f Mon Sep 17 00:00:00 2001 From: navin patidar Date: Mon, 26 May 2014 21:35:27 +0530 Subject: staging: rtl8188eu: Remove unused macros and enum defined in odm_types.h Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/odm_types.h | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/odm_types.h b/drivers/staging/rtl8188eu/include/odm_types.h index 78ee2bac0d8d..c1355b959c55 100644 --- a/drivers/staging/rtl8188eu/include/odm_types.h +++ b/drivers/staging/rtl8188eu/include/odm_types.h @@ -20,31 +20,13 @@ #ifndef __ODM_TYPES_H__ #define __ODM_TYPES_H__ -/* */ -/* Define Different SW team support */ -/* */ -#define ODM_AP 0x01 /* BIT0 */ -#define ODM_ADSL 0x02 /* BIT1 */ #define ODM_CE 0x04 /* BIT2 */ -#define ODM_MP 0x08 /* BIT3 */ - -#define RT_PCI_INTERFACE 1 -#define RT_USB_INTERFACE 2 -#define RT_SDIO_INTERFACE 3 enum HAL_STATUS { HAL_STATUS_SUCCESS, HAL_STATUS_FAILURE, }; -enum RT_SPINLOCK_TYPE { - RT_TEMP = 1, -}; - -#include - -#define DEV_BUS_TYPE RT_USB_INTERFACE - #define SET_TX_DESC_ANTSEL_A_88E(__pTxDesc, __Value) \ SET_BITS_TO_LE_4BYTE(__pTxDesc+8, 24, 1, __Value) #define SET_TX_DESC_ANTSEL_B_88E(__pTxDesc, __Value) \ @@ -52,11 +34,4 @@ enum RT_SPINLOCK_TYPE { #define SET_TX_DESC_ANTSEL_C_88E(__pTxDesc, __Value) \ SET_BITS_TO_LE_4BYTE(__pTxDesc+28, 29, 1, __Value) -/* define useless flag to avoid compile warning */ -#define USE_WORKITEM 0 -#define FOR_BRAZIL_PRETEST 0 -#define BT_30_SUPPORT 0 -#define FPGA_TWO_MAC_VERIFICATION 0 - - #endif /* __ODM_TYPES_H__ */ -- cgit v1.2.3 From 355dbc14af6e9465b5aa7bac961a622741390019 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Mon, 26 May 2014 21:35:28 +0530 Subject: staging: rtl8188eu: Remove unused structure "rtl8192cd_priv" Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/odm.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/odm.h b/drivers/staging/rtl8188eu/include/odm.h index 9d1a79c21a2e..e83812f35ad6 100644 --- a/drivers/staging/rtl8188eu/include/odm.h +++ b/drivers/staging/rtl8188eu/include/odm.h @@ -90,14 +90,6 @@ #define ANTTESTA 0x01 /* Ant A will be Testing */ #define ANTTESTB 0x02 /* Ant B will be testing */ -/* structure and define */ - -/* Add for AP/ADSLpseudo DM structuer requirement. */ -/* We need to remove to other position??? */ -struct rtl8192cd_priv { - u8 temp; -}; - struct rtw_dig { u8 Dig_Enable_Flag; u8 Dig_Ext_Port_Stage; -- cgit v1.2.3 From 8c6d463cf859950093f39b05f4464ba26d737fab Mon Sep 17 00:00:00 2001 From: navin patidar Date: Mon, 26 May 2014 21:35:29 +0530 Subject: staging: rtl8188eu: Remove unused macros in odm_interface.h Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/odm_interface.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/odm_interface.h b/drivers/staging/rtl8188eu/include/odm_interface.h index 548a309db199..3fc3e3c18d41 100644 --- a/drivers/staging/rtl8188eu/include/odm_interface.h +++ b/drivers/staging/rtl8188eu/include/odm_interface.h @@ -21,18 +21,7 @@ #ifndef __ODM_INTERFACE_H__ #define __ODM_INTERFACE_H__ -/* */ -/* =========== Constant/Structure/Enum/... Define */ -/* */ - -/* */ /* =========== Macro Define */ -/* */ - -#define _reg_all(_name) ODM_##_name -#define _reg_ic(_name, _ic) ODM_##_name##_ic -#define _bit_all(_name) BIT_##_name -#define _bit_ic(_name, _ic) BIT_##_name##_ic /* _cat: implemented by Token-Pasting Operator. */ -- cgit v1.2.3 From 49ac3ae8d5c356131fcfba59327a91318b98289d Mon Sep 17 00:00:00 2001 From: navin patidar Date: Mon, 26 May 2014 21:35:30 +0530 Subject: staging: rtl8188eu: Remove unused function pointer declaration. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/odm_interface.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/odm_interface.h b/drivers/staging/rtl8188eu/include/odm_interface.h index 3fc3e3c18d41..5338290c3579 100644 --- a/drivers/staging/rtl8188eu/include/odm_interface.h +++ b/drivers/staging/rtl8188eu/include/odm_interface.h @@ -58,16 +58,6 @@ enum odm_h2c_cmd { ODM_MAX_H2CCMD }; -/* 2012/02/17 MH For non-MP compile pass only. Linux does not support workitem. */ -/* Suggest HW team to use thread instead of workitem. Windows also support the feature. */ -typedef void (*RT_WORKITEM_CALL_BACK)(void *pContext); - -/* =========== Extern Variable ??? It should be forbidden. */ - -/* =========== EXtern Function Prototype */ - -/* Memory Relative Function. */ - /* ODM Timer relative API. */ void ODM_CancelTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer); -- cgit v1.2.3 From 524180fd8065110af04d4146a27abbafbf567fc0 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Mon, 26 May 2014 21:35:31 +0530 Subject: staging: rtl8188eu: Remove unused function declaration. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/odm_interface.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/odm_interface.h b/drivers/staging/rtl8188eu/include/odm_interface.h index 5338290c3579..ba58a67a8ecc 100644 --- a/drivers/staging/rtl8188eu/include/odm_interface.h +++ b/drivers/staging/rtl8188eu/include/odm_interface.h @@ -58,10 +58,6 @@ enum odm_h2c_cmd { ODM_MAX_H2CCMD }; -/* ODM Timer relative API. */ - -void ODM_CancelTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer); - /* ODM FW relative API. */ u32 ODM_FillH2CCmd(u8 *pH2CBuffer, u32 H2CBufferLen, u32 CmdNum, u32 *pElementID, u32 *pCmdLen, u8 **pCmbBuffer, -- cgit v1.2.3 From 4bdfb1ce1b71079e1238b8c344e073d66b644a64 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Mon, 26 May 2014 21:35:32 +0530 Subject: staging: rtl8188eu: Use "ODM_REG_CCK_CCA_11N" in ODM_Write_CCK_CCA_Thres() Use "ODM_REG_CCK_CCA_11N" directly instead of using ODM_REG(CCK_CCA, pDM_Odm) which produces same after preprocessing. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index a39eba9f98c5..540527db7517 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -842,7 +842,7 @@ void ODM_Write_CCK_CCA_Thres(struct odm_dm_struct *pDM_Odm, u8 CurCCK_CCAThres) struct adapter *adapt = pDM_Odm->Adapter; if (pDM_DigTable->CurCCK_CCAThres != CurCCK_CCAThres) /* modify by Guo.Mingzhi 2012-01-03 */ - rtw_write8(adapt, ODM_REG(CCK_CCA, pDM_Odm), CurCCK_CCAThres); + rtw_write8(adapt, ODM_REG_CCK_CCA_11N, CurCCK_CCAThres); pDM_DigTable->PreCCK_CCAThres = pDM_DigTable->CurCCK_CCAThres; pDM_DigTable->CurCCK_CCAThres = CurCCK_CCAThres; } -- cgit v1.2.3 From e4916f35f011d00e26e1491152ebb56e33978192 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Mon, 26 May 2014 21:35:33 +0530 Subject: staging: rtl8188eu: Use ODM_REG_IGI_A_11N and ODM_BIT_IGI_11N in odm_DIGInit() ODM_REG(IGI_A, pDM_Odm) and ODM_BIT(IGI, pDM_Odm) macros produce ODM_REG_IGI_A_11N and ODM_BIT_IGI_11N respectively after preprocessing. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index 540527db7517..2bd68aa519f4 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -531,7 +531,7 @@ void odm_DIGInit(struct odm_dm_struct *pDM_Odm) struct adapter *adapter = pDM_Odm->Adapter; struct rtw_dig *pDM_DigTable = &pDM_Odm->DM_DigTable; - pDM_DigTable->CurIGValue = (u8) PHY_QueryBBReg(adapter, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm)); + pDM_DigTable->CurIGValue = (u8) PHY_QueryBBReg(adapter, ODM_REG_IGI_A_11N, ODM_BIT_IGI_11N); pDM_DigTable->RssiLowThresh = DM_DIG_THRESH_LOW; pDM_DigTable->RssiHighThresh = DM_DIG_THRESH_HIGH; pDM_DigTable->FALowThresh = DM_false_ALARM_THRESH_LOW; -- cgit v1.2.3 From a4e76443f7330f236ee082a16740e74f2beb6943 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Mon, 26 May 2014 21:35:34 +0530 Subject: staging: rtl8188eu: Remove unnecessary debugging message from ODM_Write_DIG() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index 2bd68aa519f4..205ba7fab863 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -511,19 +511,10 @@ void ODM_Write_DIG(struct odm_dm_struct *pDM_Odm, u8 CurrentIGI) struct rtw_dig *pDM_DigTable = &pDM_Odm->DM_DigTable; struct adapter *adapter = pDM_Odm->Adapter; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, - ("ODM_REG(IGI_A,pDM_Odm)=0x%x, ODM_BIT(IGI,pDM_Odm)=0x%x\n", - ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm))); - if (pDM_DigTable->CurIGValue != CurrentIGI) { PHY_SetBBReg(adapter, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("CurrentIGI(0x%02x).\n", CurrentIGI)); - /* pDM_DigTable->PreIGValue = pDM_DigTable->CurIGValue; */ pDM_DigTable->CurIGValue = CurrentIGI; } - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("ODM_Write_DIG():CurrentIGI=0x%x\n", CurrentIGI)); - -/* Add by Neil Chen to enable edcca to MP Platform */ } void odm_DIGInit(struct odm_dm_struct *pDM_Odm) -- cgit v1.2.3 From 9caf175047656c999650f82f20d81d68fd495135 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Mon, 26 May 2014 21:35:35 +0530 Subject: staging: rtl8188eu: Use ODM_REG_IGI_A_11N and ODM_BIT_IGI_11N in ODM_Write_DIG() ODM_REG(IGI_A, pDM_Odm) and ODM_BIT(IGI, pDM_Odm) macros produce ODM_REG_IGI_A_11N and ODM_BIT_IGI_11N respectively after preprocessing. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index 205ba7fab863..2a0ac4ab23d2 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -512,7 +512,7 @@ void ODM_Write_DIG(struct odm_dm_struct *pDM_Odm, u8 CurrentIGI) struct adapter *adapter = pDM_Odm->Adapter; if (pDM_DigTable->CurIGValue != CurrentIGI) { - PHY_SetBBReg(adapter, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); + PHY_SetBBReg(adapter, ODM_REG_IGI_A_11N, ODM_BIT_IGI_11N, CurrentIGI); pDM_DigTable->CurIGValue = CurrentIGI; } } -- cgit v1.2.3 From 4cae8c2217a8b24ddd53696c3c096d09c913bed8 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Mon, 26 May 2014 21:35:36 +0530 Subject: staging: rtl8188eu: Remove unused macros defined in odm_interface.h Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/odm_interface.h | 30 ----------------------- 1 file changed, 30 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/odm_interface.h b/drivers/staging/rtl8188eu/include/odm_interface.h index ba58a67a8ecc..2c2991e8a089 100644 --- a/drivers/staging/rtl8188eu/include/odm_interface.h +++ b/drivers/staging/rtl8188eu/include/odm_interface.h @@ -21,36 +21,6 @@ #ifndef __ODM_INTERFACE_H__ #define __ODM_INTERFACE_H__ -/* =========== Macro Define */ - -/* _cat: implemented by Token-Pasting Operator. */ - -/*=================================== - -#define ODM_REG_DIG_11N 0xC50 -#define ODM_REG_DIG_11AC 0xDDD - -ODM_REG(DIG,_pDM_Odm) -=====================================*/ - -#define _reg_11N(_name) ODM_REG_##_name##_11N -#define _reg_11AC(_name) ODM_REG_##_name##_11AC -#define _bit_11N(_name) ODM_BIT_##_name##_11N -#define _bit_11AC(_name) ODM_BIT_##_name##_11AC - -#define _cat(_name, _ic_type, _func) \ - ( \ - (_ic_type) ? _func##_11N(_name) : \ - _func##_11AC(_name) \ - ) - -/* _name: name of register or bit. */ -/* Example: "ODM_REG(R_A_AGC_CORE1, pDM_Odm)" */ -/* gets "ODM_R_A_AGC_CORE1" or "ODM_R_A_AGC_CORE1_8192C", - * depends on SupportICType. */ -#define ODM_REG(_name, _pDM_Odm) _cat(_name, _pDM_Odm->SupportICType, _reg) -#define ODM_BIT(_name, _pDM_Odm) _cat(_name, _pDM_Odm->SupportICType, _bit) - enum odm_h2c_cmd { ODM_H2C_RSSI_REPORT = 0, ODM_H2C_PSD_RESULT = 1, -- cgit v1.2.3 From 209acfd2e680657b9a95718f721669509198a2d7 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Mon, 26 May 2014 21:35:37 +0530 Subject: staging: rtl8188eu: Remove unused function declaration. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/odm_interface.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/odm_interface.h b/drivers/staging/rtl8188eu/include/odm_interface.h index 2c2991e8a089..e29ac79e4b22 100644 --- a/drivers/staging/rtl8188eu/include/odm_interface.h +++ b/drivers/staging/rtl8188eu/include/odm_interface.h @@ -27,10 +27,4 @@ enum odm_h2c_cmd { ODM_H2C_PathDiv = 2, ODM_MAX_H2CCMD }; - -/* ODM FW relative API. */ -u32 ODM_FillH2CCmd(u8 *pH2CBuffer, u32 H2CBufferLen, u32 CmdNum, - u32 *pElementID, u32 *pCmdLen, u8 **pCmbBuffer, - u8 *CmdStartSeq); - #endif /* __ODM_INTERFACE_H__ */ -- cgit v1.2.3 From 4052faa328c682c44a11c867eb955ae5530d3434 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Mon, 26 May 2014 21:35:38 +0530 Subject: staging: rtl8188eu: Remove unused enum odm_h2c_cmd. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/odm_interface.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/odm_interface.h b/drivers/staging/rtl8188eu/include/odm_interface.h index e29ac79e4b22..dc6b1c224388 100644 --- a/drivers/staging/rtl8188eu/include/odm_interface.h +++ b/drivers/staging/rtl8188eu/include/odm_interface.h @@ -21,10 +21,4 @@ #ifndef __ODM_INTERFACE_H__ #define __ODM_INTERFACE_H__ -enum odm_h2c_cmd { - ODM_H2C_RSSI_REPORT = 0, - ODM_H2C_PSD_RESULT = 1, - ODM_H2C_PathDiv = 2, - ODM_MAX_H2CCMD -}; #endif /* __ODM_INTERFACE_H__ */ -- cgit v1.2.3 From a61a9390500b46fa262fb8c92027cf227827804a Mon Sep 17 00:00:00 2001 From: navin patidar Date: Mon, 26 May 2014 21:35:39 +0530 Subject: staging: rtl8188eu: Remove empty file odm_interface.h Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/odm_interface.h | 24 ----------------------- drivers/staging/rtl8188eu/include/odm_precomp.h | 1 - 2 files changed, 25 deletions(-) delete mode 100644 drivers/staging/rtl8188eu/include/odm_interface.h diff --git a/drivers/staging/rtl8188eu/include/odm_interface.h b/drivers/staging/rtl8188eu/include/odm_interface.h deleted file mode 100644 index dc6b1c224388..000000000000 --- a/drivers/staging/rtl8188eu/include/odm_interface.h +++ /dev/null @@ -1,24 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ - -#ifndef __ODM_INTERFACE_H__ -#define __ODM_INTERFACE_H__ - -#endif /* __ODM_INTERFACE_H__ */ diff --git a/drivers/staging/rtl8188eu/include/odm_precomp.h b/drivers/staging/rtl8188eu/include/odm_precomp.h index 6e6a656b4154..2eb769b3f35d 100644 --- a/drivers/staging/rtl8188eu/include/odm_precomp.h +++ b/drivers/staging/rtl8188eu/include/odm_precomp.h @@ -44,7 +44,6 @@ #include "Hal8188ERateAdaptive.h"/* for RA,Power training */ #include "rtl8188e_hal.h" -#include "odm_interface.h" #include "odm_reg.h" #include "HalHWImg8188E_MAC.h" -- cgit v1.2.3 From 09e4659e50ab8692d090c9135c75357d166d23d8 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 26 May 2014 14:06:04 -0500 Subject: staging: r8192ee: Fix kernel WARN splat associated with rate control The 0day kernel testing robot got the kernel warning caused by trying to register a particular rate-control algorithm more than once. I believe that the core already protects against a particular driver doing the registration more than once, but an analysis of the code reveals that the identical name is used for the rtlwifi drivers in the regular wireless tree, and the staging drivers r8192ee and r8821ae. The fix is to rename the algorithm used in r8192ee. Reported-by: Jet Chen Signed-off-by: Larry Finger Tested-by: Jet Chen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192ee/rc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192ee/rc.c b/drivers/staging/rtl8192ee/rc.c index f0ce6a99ab00..c4c34ddcf8cd 100644 --- a/drivers/staging/rtl8192ee/rc.c +++ b/drivers/staging/rtl8192ee/rc.c @@ -267,7 +267,7 @@ static void rtl_rate_free_sta(void *rtlpriv, } static struct rate_control_ops rtl_rate_ops = { - .name = "rtl_rc", + .name = "rtl_rc_92e", .alloc = rtl_rate_alloc, .free = rtl_rate_free, .alloc_sta = rtl_rate_alloc_sta, -- cgit v1.2.3 From 42e4c20f114c71e12cdf35d9b5dd60d2546c7d57 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 26 May 2014 14:06:05 -0500 Subject: staging: r8192ee: Fix build errors when PCI is not available A build of this driver fails when PCI is not selected. It would also fail if MAC80211 is not selected. Kconfig is fixed to handle these conditions, and to select additional necessary components. Reported-by: Randy Dunlap Reported-by: Ben Hutchings Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192ee/Kconfig | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/staging/rtl8192ee/Kconfig b/drivers/staging/rtl8192ee/Kconfig index 92c5f442df3d..beb07ac24e80 100644 --- a/drivers/staging/rtl8192ee/Kconfig +++ b/drivers/staging/rtl8192ee/Kconfig @@ -1,6 +1,13 @@ config R8192EE tristate "Realtek RTL8192EE Wireless Network Adapter" + depends on PCI && WLAN && MAC80211 + depends on m + select WIRELESS_EXT + select WEXT_PRIV + select EEPROM_93CX6 + select CRYPTO select FW_LOADER + default N ---help--- This is the driver for Realtek RTL8192EE 802.11 PCIe wireless network adapters. -- cgit v1.2.3 From 9c0b41d43d8c9c4b182cfb89dce29da6dd33692d Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 26 May 2014 14:06:06 -0500 Subject: staging: r8821ae: Fix potential problem with rate control registration The zero day testing facility reported a problem with duplicate registration of the rate-control algorithm. Although not yet reported, this driver needs the same fix. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/rc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8821ae/rc.c b/drivers/staging/rtl8821ae/rc.c index 0cc32c60ddee..a5a09baa99c5 100644 --- a/drivers/staging/rtl8821ae/rc.c +++ b/drivers/staging/rtl8821ae/rc.c @@ -286,7 +286,7 @@ static void rtl_rate_free_sta(void *rtlpriv, } static struct rate_control_ops rtl_rate_ops = { - .name = "rtl_rc", + .name = "rtl_rc_21ae", .alloc = rtl_rate_alloc, .free = rtl_rate_free, .alloc_sta = rtl_rate_alloc_sta, -- cgit v1.2.3 From f8cc81f845456c126fd0ab4d8379a8c47f5ca743 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Mon, 26 May 2014 22:19:51 +0200 Subject: staging: rtl8192u: rename CONFIG_IEEE80211_CRYPT_TKIP The Kconfig symbol IEEE80211_CRYPT_TKIP was renamed to LIB80211_CRYPT_TKIP in commit 274bfb8dc5ff ("lib80211: absorb crypto bits from net/ieee80211"). So when rtl8192u was added as a staging driver in v2.6.33 its checks for CONFIG_IEEE80211_CRYPT_TKIP were already outdated. Use CONFIG_LIB80211_CRYPT_TKIP instead, as was clearly intended. Signed-off-by: Paul Bolle Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 2 +- drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index d9a8299c48eb..800206755edd 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -352,7 +352,7 @@ ieee80211_rx_frame_decrypt(struct ieee80211_device *ieee, struct sk_buff *skb, hdr = (struct ieee80211_hdr_4addr *) skb->data; hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); -#ifdef CONFIG_IEEE80211_CRYPT_TKIP +#ifdef CONFIG_LIB80211_CRYPT_TKIP if (ieee->tkip_countermeasures && strcmp(crypt->ops->name, "TKIP") == 0) { if (net_ratelimit()) { diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c index 029a97651797..0bb474a193e6 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c @@ -191,7 +191,7 @@ int ieee80211_encrypt_fragment( printk("=========>%s(), crypt is null\n", __func__); return -1; } -#ifdef CONFIG_IEEE80211_CRYPT_TKIP +#ifdef CONFIG_LIB80211_CRYPT_TKIP struct ieee80211_hdr *header; if (ieee->tkip_countermeasures && -- cgit v1.2.3 From d3921a03a89acb1b9ca599590c0131c89f8737d8 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Mon, 26 May 2014 21:47:11 +0200 Subject: staging: tidspbridge: check for CONFIG_SND_OMAP_SOC_MCBSP Commit d0f47ff17f29 ("ASoC: OMAP: Build config cleanup for McBSP") removed the Kconfig symbol OMAP_MCBSP. It left two checks for CONFIG_OMAP_MCBSP untouched. Convert these to checks for CONFIG_SND_OMAP_SOC_MCBSP. That must be correct, since that re-enables calls to functions that are all found in sound/soc/omap/mcbsp.c. And that file is built only if CONFIG_SND_OMAP_SOC_MCBSP is defined. Fixes: d0f47ff17f29 ("ASoC: OMAP: Build config cleanup for McBSP") Signed-off-by: Paul Bolle Signed-off-by: Greg Kroah-Hartman --- drivers/staging/tidspbridge/core/dsp-clock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/tidspbridge/core/dsp-clock.c b/drivers/staging/tidspbridge/core/dsp-clock.c index 2f084e181d39..a1aca4416ca7 100644 --- a/drivers/staging/tidspbridge/core/dsp-clock.c +++ b/drivers/staging/tidspbridge/core/dsp-clock.c @@ -226,7 +226,7 @@ int dsp_clk_enable(enum dsp_clk_id clk_id) case GPT_CLK: status = omap_dm_timer_start(timer[clk_id - 1]); break; -#ifdef CONFIG_OMAP_MCBSP +#ifdef CONFIG_SND_OMAP_SOC_MCBSP case MCBSP_CLK: omap_mcbsp_request(MCBSP_ID(clk_id)); omap2_mcbsp_set_clks_src(MCBSP_ID(clk_id), MCBSP_CLKS_PAD_SRC); @@ -302,7 +302,7 @@ int dsp_clk_disable(enum dsp_clk_id clk_id) case GPT_CLK: status = omap_dm_timer_stop(timer[clk_id - 1]); break; -#ifdef CONFIG_OMAP_MCBSP +#ifdef CONFIG_SND_OMAP_SOC_MCBSP case MCBSP_CLK: omap2_mcbsp_set_clks_src(MCBSP_ID(clk_id), MCBSP_CLKS_PRCM_SRC); omap_mcbsp_free(MCBSP_ID(clk_id)); -- cgit v1.2.3 From e31273ee121c9e100135f6400553d28e73b9d6a8 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Mon, 26 May 2014 21:40:46 +0200 Subject: staging: rtl8192u: remove checks for CONFIG_RTL8192_PM When the rtl8192u driver was added in v2.6.33 its code contained checks for CONFIG_RTL8192_PM. The related Kconfig symbol didn't exist then. It still doesn't exist now. Remove these checks. Signed-off-by: Paul Bolle Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_core.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 97af38f9f281..24272c51bc9d 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -97,10 +97,6 @@ double __extendsfdf2(float a) #include // FIXME: check if 2.6.7 is ok -#ifdef CONFIG_RTL8192_PM -#include "r8192_pm.h" -#endif - #include "dot11d.h" //set here to open your trace code. //WB u32 rt_global_debug_component = COMP_DOWN | @@ -159,13 +155,8 @@ static struct usb_driver rtl8192_usb_driver = { .id_table = rtl8192_usb_id_tbl, /* PCI_ID table */ .probe = rtl8192_usb_probe, /* probe fn */ .disconnect = rtl8192_usb_disconnect, /* remove fn */ -#ifdef CONFIG_RTL8192_PM - .suspend = rtl8192_suspend, /* PM suspend fn */ - .resume = rtl8192_resume, /* PM resume fn */ -#else .suspend = NULL, /* PM suspend fn */ .resume = NULL, /* PM resume fn */ -#endif }; -- cgit v1.2.3 From 3746cfb684cdd9cce843e914012ec56e7064dbe2 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Mon, 26 May 2014 21:26:57 +0200 Subject: staging: lirc: remove checks for CONFIG_LIRC_SERIAL_NSLU2 When support for homebrew serial port receivers was added in v2.6.36 its code contained checks for CONFIG_LIRC_SERIAL_NSLU2. The related Kconfig symbol didn't exist then. It still doesn't exist now. Remove these checks. Signed-off-by: Paul Bolle Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/lirc/lirc_serial.c | 81 -------------------------------- 1 file changed, 81 deletions(-) diff --git a/drivers/staging/media/lirc/lirc_serial.c b/drivers/staging/media/lirc/lirc_serial.c index dc5ba43116c7..efe561cd0935 100644 --- a/drivers/staging/media/lirc/lirc_serial.c +++ b/drivers/staging/media/lirc/lirc_serial.c @@ -73,9 +73,6 @@ #include #include -#ifdef CONFIG_LIRC_SERIAL_NSLU2 -#include -#endif /* From Intel IXP42X Developer's Manual (#252480-005): */ /* ftp://download.intel.com/design/network/manuals/25248005.pdf */ #define UART_IE_IXP42X_UUE 0x40 /* IXP42X UART Unit enable */ @@ -198,33 +195,6 @@ static struct lirc_serial hardware[] = { .features = LIRC_CAN_REC_MODE2 #endif }, - -#ifdef CONFIG_LIRC_SERIAL_NSLU2 - /* - * Modified Linksys Network Storage Link USB 2.0 (NSLU2): - * We receive on CTS of the 2nd serial port (R142,LHS), we - * transmit with a IR diode between GPIO[1] (green status LED), - * and ground (Matthias Goebl ). - * See also http://www.nslu2-linux.org for this device - */ - [LIRC_NSLU2] = { - .lock = __SPIN_LOCK_UNLOCKED(hardware[LIRC_NSLU2].lock), - .signal_pin = UART_MSR_CTS, - .signal_pin_change = UART_MSR_DCTS, - .on = (UART_MCR_RTS | UART_MCR_OUT2 | UART_MCR_DTR), - .off = (UART_MCR_RTS | UART_MCR_OUT2), - .send_pulse = send_pulse_homebrew, - .send_space = send_space_homebrew, -#ifdef CONFIG_LIRC_SERIAL_TRANSMITTER - .features = (LIRC_CAN_SET_SEND_DUTY_CYCLE | - LIRC_CAN_SET_SEND_CARRIER | - LIRC_CAN_SEND_PULSE | LIRC_CAN_REC_MODE2) -#else - .features = LIRC_CAN_REC_MODE2 -#endif - }, -#endif - }; #define RS_ISR_PASS_LIMIT 256 @@ -315,16 +285,6 @@ static void soutp(int offset, u8 value) static void on(void) { -#ifdef CONFIG_LIRC_SERIAL_NSLU2 - /* - * On NSLU2, we put the transmit diode between the output of the green - * status LED and ground - */ - if (type == LIRC_NSLU2) { - gpio_set_value(NSLU2_LED_GRN, 0); - return; - } -#endif if (txsense) soutp(UART_MCR, hardware[type].off); else @@ -333,12 +293,6 @@ static void on(void) static void off(void) { -#ifdef CONFIG_LIRC_SERIAL_NSLU2 - if (type == LIRC_NSLU2) { - gpio_set_value(NSLU2_LED_GRN, 1); - return; - } -#endif if (txsense) soutp(UART_MCR, hardware[type].on); else @@ -793,20 +747,6 @@ static int hardware_init_port(void) sinp(UART_IIR); sinp(UART_MSR); -#ifdef CONFIG_LIRC_SERIAL_NSLU2 - if (type == LIRC_NSLU2) { - /* Setup NSLU2 UART */ - - /* Enable UART */ - soutp(UART_IER, sinp(UART_IER) | UART_IE_IXP42X_UUE); - /* Disable Receiver data Time out interrupt */ - soutp(UART_IER, sinp(UART_IER) & ~UART_IE_IXP42X_RTOIE); - /* set out2 = interrupt unmask; off() doesn't set MCR - on NSLU2 */ - soutp(UART_MCR, UART_MCR_RTS|UART_MCR_OUT2); - } -#endif - /* Set line for power source */ off(); @@ -842,16 +782,6 @@ static int lirc_serial_probe(struct platform_device *dev) { int i, nlow, nhigh, result; -#ifdef CONFIG_LIRC_SERIAL_NSLU2 - /* This GPIO is used for a LED on the NSLU2 */ - result = devm_gpio_request(dev, NSLU2_LED_GRN, "lirc-serial"); - if (result) - return result; - result = gpio_direction_output(NSLU2_LED_GRN, 0); - if (result) - return result; -#endif - result = request_irq(irq, lirc_irq_handler, (share_irq ? IRQF_SHARED : 0), LIRC_DRIVER_NAME, (void *)&hardware); @@ -1217,14 +1147,6 @@ static int __init lirc_serial_init_module(void) io = io ? io : 0x3f8; irq = irq ? irq : 4; break; -#ifdef CONFIG_LIRC_SERIAL_NSLU2 - case LIRC_NSLU2: - io = io ? io : IRQ_IXP4XX_UART2; - irq = irq ? irq : (IXP4XX_UART2_BASE_VIRT + REG_OFFSET); - iommap = iommap ? iommap : IXP4XX_UART2_BASE_PHYS; - ioshift = ioshift ? ioshift : 2; - break; -#endif default: return -EINVAL; } @@ -1232,9 +1154,6 @@ static int __init lirc_serial_init_module(void) switch (type) { case LIRC_HOMEBREW: case LIRC_IGOR: -#ifdef CONFIG_LIRC_SERIAL_NSLU2 - case LIRC_NSLU2: -#endif hardware[type].features &= ~(LIRC_CAN_SET_SEND_DUTY_CYCLE| LIRC_CAN_SET_SEND_CARRIER); -- cgit v1.2.3 From 464ae880a3caa0128a7d0e6c91e3d96afc2da6f0 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Mon, 26 May 2014 21:18:01 +0200 Subject: staging: ctx1e1: remove checks for three macros When the ctx1e1 driver was added in v2.6.35 it contained checks for CONFIG_SBE_HDLC_V7, CONFIG_SBE_WAN256T3_HDLC_V7, and CONFIG_SBE_WAN256T3_NCOMM (and MODULE variants). The related Kconfig symbols didn't exist then. They still don't exist now. Remove these checks. Do some related cleaning up and remove the unused V7() macro too. Signed-off-by: Paul Bolle Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cxt1e1/functions.c | 18 ------------------ drivers/staging/cxt1e1/linux.c | 17 ----------------- drivers/staging/cxt1e1/musycc.c | 30 ------------------------------ 3 files changed, 65 deletions(-) diff --git a/drivers/staging/cxt1e1/functions.c b/drivers/staging/cxt1e1/functions.c index ee9d39bbd251..65b6fc36edf6 100644 --- a/drivers/staging/cxt1e1/functions.c +++ b/drivers/staging/cxt1e1/functions.c @@ -24,24 +24,6 @@ #include "libsbew.h" #include "pmcc4.h" -#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; diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c index 4b4609db9f89..09f3d5ca75ac 100644 --- a/drivers/staging/cxt1e1/linux.c +++ b/drivers/staging/cxt1e1/linux.c @@ -83,23 +83,6 @@ int musycc_start_xmit(ci_t *, int, void *); 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 cxt1e1_log_level = LOG_ERROR; static int log_level_default = LOG_ERROR; diff --git a/drivers/staging/cxt1e1/musycc.c b/drivers/staging/cxt1e1/musycc.c index a87f80237f47..0bcbd8a3fc84 100644 --- a/drivers/staging/cxt1e1/musycc.c +++ b/drivers/staging/cxt1e1/musycc.c @@ -918,9 +918,6 @@ musycc_bh_tx_eom(mpi_t *pi, int gchan) md->data = 0; if (md->mem_token) { -#ifdef CONFIG_SBE_WAN256T3_NCOMM - int hdlcnum = 0; -#endif /* upcount channel */ atomic_sub(OS_mem_token_tlen(md->mem_token), &ch->tx_pending); @@ -931,18 +928,6 @@ musycc_bh_tx_eom(mpi_t *pi, int gchan) 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 */ - 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 = NULL; } @@ -1039,21 +1024,6 @@ musycc_bh_rx_eom(mpi_t *pi, int gchan) 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 ***/ - { m2 = OS_mem_token_alloc(cxt1e1_max_mru); if (m2) { -- cgit v1.2.3 From f30f2c2d417b9de3d967016ade0bea2d93190624 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Mon, 26 May 2014 21:09:10 +0200 Subject: staging: comedi: remove check for CONFIG_KMOD The comedi driver was added in v2.6.29. That's the same release that removed the Kconfig symbol KMOD. So the code behind a test for its macro has been hidden since it was in staging. Remove it. Remove a useless assignment to "dev->in_request_module" too. That variable seems pointless anyhow, but that's a different issue. Signed-off-by: Paul Bolle Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 012c8fd1aabb..70ad00c501ef 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -2351,14 +2351,6 @@ static int comedi_open(struct inode *inode, struct file *file) if (capable(CAP_NET_ADMIN) && dev->in_request_module) goto ok; - dev->in_request_module = true; - -#ifdef CONFIG_KMOD - mutex_unlock(&dev->mutex); - request_module("char-major-%i-%i", COMEDI_MAJOR, dev->minor); - mutex_lock(&dev->mutex); -#endif - dev->in_request_module = false; if (!dev->attached && !capable(CAP_NET_ADMIN)) { -- cgit v1.2.3 From efc273ce344eb6984d16964201617f4720beb2dd Mon Sep 17 00:00:00 2001 From: Vitaly Osipov Date: Tue, 27 May 2014 22:26:12 +1000 Subject: staging: rtl8712: fix kmalloc parameters After the commit 91d435f replaced _malloc with kmalloc, smatch picked up a couple of new warnings. This fixes warnings: warn: struct type mismatch 'writePTM_parm vs setdig_parm' warn: struct type mismatch 'writePTM_parm vs setra_parm' The difference is u8 vs unsigned char. Signed-off-by: Vitaly Osipov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index 6a3cecc8a09b..7a252200e902 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -350,7 +350,7 @@ u8 r8712_setfwdig_cmd(struct _adapter *padapter, u8 type) ph2c = kmalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ph2c == NULL) return _FAIL; - pwriteptmparm = kmalloc(sizeof(struct setdig_parm), GFP_ATOMIC); + pwriteptmparm = kmalloc(sizeof(struct writePTM_parm), GFP_ATOMIC); if (pwriteptmparm == NULL) { kfree((u8 *) ph2c); return _FAIL; @@ -370,7 +370,7 @@ u8 r8712_setfwra_cmd(struct _adapter *padapter, u8 type) ph2c = kmalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ph2c == NULL) return _FAIL; - pwriteptmparm = kmalloc(sizeof(struct setra_parm), GFP_ATOMIC); + pwriteptmparm = kmalloc(sizeof(struct writePTM_parm), GFP_ATOMIC); if (pwriteptmparm == NULL) { kfree((u8 *) ph2c); return _FAIL; -- cgit v1.2.3 From 735e33fa32d56e58dccb8406281efb2fff419f23 Mon Sep 17 00:00:00 2001 From: Vitaly Osipov Date: Tue, 27 May 2014 22:27:37 +1000 Subject: staging: rtl8712: return -ENOMEM instead of -1 After the commit 91d435f replaced _malloc with kmalloc, smatch picked up a couple of new warnings. This fixes the warning: warn: returning -1 instead of -ENOMEM is sloppy Signed-off-by: Vitaly Osipov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/usb_ops_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8712/usb_ops_linux.c b/drivers/staging/rtl8712/usb_ops_linux.c index 064dc1076d2a..a6c2aab0a946 100644 --- a/drivers/staging/rtl8712/usb_ops_linux.c +++ b/drivers/staging/rtl8712/usb_ops_linux.c @@ -499,7 +499,7 @@ int r8712_usbctrl_vendorreq(struct intf_priv *pintfpriv, u8 request, u16 value, if (palloc_buf == NULL) { dev_err(&udev->dev, "%s: Can't alloc memory for vendor request\n", __func__); - return -1; + return -ENOMEM; } pIo_buf = palloc_buf + 16 - ((addr_t)(palloc_buf) & 0x0f); if (requesttype == 0x01) { -- cgit v1.2.3 From bc25d1974e5f3fe49eedf8ef276c8b751ad04580 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 27 May 2014 15:25:47 +0530 Subject: staging: rtl8192ee: Fix build error Fixes the followign build error: drivers/staging/rtl8192ee/btcoexist/halbtc8723b1ant.c:1387:6: error: called object is not a function or function pointer ("[BTCoex], Wifi non connected-idle + BT Busy!!\n")); Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192ee/btcoexist/halbtc8723b1ant.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192ee/btcoexist/halbtc8723b1ant.c b/drivers/staging/rtl8192ee/btcoexist/halbtc8723b1ant.c index d561c54524b7..153048f6b4de 100644 --- a/drivers/staging/rtl8192ee/btcoexist/halbtc8723b1ant.c +++ b/drivers/staging/rtl8192ee/btcoexist/halbtc8723b1ant.c @@ -1384,7 +1384,7 @@ static bool halbtc8723b1ant_is_common_action(struct btc_coexist *btcoexist) (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE != coex_dm->bt_status)) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, - ("[BTCoex], Wifi non connected-idle + BT Busy!!\n")); + "[BTCoex], Wifi non connected-idle + BT Busy!!\n"); halbtc8723b1ant_sw_mechanism(btcoexist, false); commom = true; } else { -- cgit v1.2.3 From b415a2267c5e1a29ecf7f84c3bea89bc5fa2ab50 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 27 May 2014 15:25:48 +0530 Subject: staging: rtl8192ee: Remove unneeded version.h inclusion version.h inclusion is not needed as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192ee/wifi.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8192ee/wifi.h b/drivers/staging/rtl8192ee/wifi.h index 9cb08116d384..96fa261a70a5 100644 --- a/drivers/staging/rtl8192ee/wifi.h +++ b/drivers/staging/rtl8192ee/wifi.h @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include "debug.h" -- cgit v1.2.3 From 03d3dedd747b84990a249445c8a99061f656ca2b Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 27 May 2014 15:28:08 +0530 Subject: staging: rtl8723au: Remove unneeded version.h inclusion in osdep_service.h version.h inclusion is not needed as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/osdep_service.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index d85f850b77b5..a5ebdb81ce38 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -19,7 +19,6 @@ #define _SUCCESS 1 #define RTW_RX_HANDLED 2 -#include #include #include #include -- cgit v1.2.3 From 546e2553ed06dc411c84283c47030c0626f2bc0d Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 27 May 2014 15:28:10 +0530 Subject: staging: rtl8723au: Remove unneeded version.h inclusion in os_intfs.c version.h inclusion is not needed as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/os_intfs.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index 5b27eb4474ba..4e32003a4437 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -23,8 +23,6 @@ #include -#include - MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Realtek Wireless Lan Driver"); MODULE_AUTHOR("Realtek Semiconductor Corp."); -- cgit v1.2.3 From 260c0f73be312ab6207c9ec56e4fe0fb365c8ac3 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 27 May 2014 15:28:09 +0530 Subject: staging: rtl8723au: Remove unneeded version.h inclusion in ioctl_cfg80211.c version.h inclusion is not needed as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 4528c95b8e67..0c9f5cebfb42 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -20,7 +20,6 @@ #include #include "ioctl_cfg80211.h" -#include #define RTW_MAX_MGMT_TX_CNT 8 -- cgit v1.2.3 From a5897f77607c52acb078b152b59fbe29ac92c640 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 27 May 2014 15:06:17 +0100 Subject: staging: comedi: remove in_request_module The `in_request_module` member of `struct comedi_device` is only ever set to `false`, so remove the code that checks for it being `true` and remove the member. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 26 -------------------------- drivers/staging/comedi/comedidev.h | 1 - 2 files changed, 27 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 70ad00c501ef..9d99fb3c18a6 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -2327,38 +2327,12 @@ static int comedi_open(struct inode *inode, struct file *file) return -ENODEV; } - /* This is slightly hacky, but we want module autoloading - * to work for root. - * case: user opens device, attached -> ok - * case: user opens device, unattached, !in_request_module -> autoload - * case: user opens device, unattached, in_request_module -> fail - * case: root opens device, attached -> ok - * case: root opens device, unattached, in_request_module -> ok - * (typically called from modprobe) - * case: root opens device, unattached, !in_request_module -> autoload - * - * The last could be changed to "-> ok", which would deny root - * autoloading. - */ mutex_lock(&dev->mutex); - if (dev->attached) - goto ok; - if (!capable(CAP_NET_ADMIN) && dev->in_request_module) { - dev_dbg(dev->class_dev, "in request module\n"); - rc = -ENODEV; - goto out; - } - if (capable(CAP_NET_ADMIN) && dev->in_request_module) - goto ok; - - dev->in_request_module = false; - if (!dev->attached && !capable(CAP_NET_ADMIN)) { dev_dbg(dev->class_dev, "not attached and not CAP_NET_ADMIN\n"); rc = -ENODEV; goto out; } -ok: if (dev->attached && dev->use_count == 0) { if (!try_module_get(dev->driver->module)) { rc = -ENOSYS; diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index d07d47f5db81..8f4e44bfbe00 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -180,7 +180,6 @@ struct comedi_device { const char *board_name; const void *board_ptr; bool attached:1; - bool in_request_module:1; bool ioenabled:1; spinlock_t spinlock; struct mutex mutex; -- cgit v1.2.3 From 8b292b00070f124b2b60735e9e603649e20772d6 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 27 May 2014 16:02:33 +0530 Subject: staging: rtl8821ae: base.c: Remove version specific code The code should be for the current kernel version. Remove conditional version based code. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/base.c | 46 +--------------------------------------- 1 file changed, 1 insertion(+), 45 deletions(-) diff --git a/drivers/staging/rtl8821ae/base.c b/drivers/staging/rtl8821ae/base.c index 49ee311ddcd9..4a36da06c01c 100644 --- a/drivers/staging/rtl8821ae/base.c +++ b/drivers/staging/rtl8821ae/base.c @@ -320,9 +320,6 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw) /* <5> set hw caps */ hw->flags = IEEE80211_HW_SIGNAL_DBM | IEEE80211_HW_RX_INCLUDES_FCS | -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0)) - IEEE80211_HW_BEACON_FILTER | -#endif IEEE80211_HW_AMPDU_AGGREGATION | IEEE80211_HW_REPORTS_TX_ACK_STATUS | IEEE80211_HW_CONNECTION_MONITOR | @@ -335,8 +332,6 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw) IEEE80211_HW_PS_NULLFUNC_STACK | /* IEEE80211_HW_SUPPORTS_DYNAMIC_PS | */ 0; -/**/ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_STATION) | @@ -344,23 +339,10 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw) BIT(NL80211_IFTYPE_MESH_POINT) | BIT(NL80211_IFTYPE_P2P_CLIENT) | BIT(NL80211_IFTYPE_P2P_GO); -#else -/**/ - hw->wiphy->interface_modes = - BIT(NL80211_IFTYPE_AP) | - BIT(NL80211_IFTYPE_STATION) | - BIT(NL80211_IFTYPE_ADHOC) | - BIT(NL80211_IFTYPE_MESH_POINT) ; -/**/ -#endif -/**/ -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 39)) + hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; -#endif -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)) hw->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; -#endif hw->wiphy->rts_threshold = 2347; @@ -401,16 +383,8 @@ static int _rtl_init_deferred_work(struct ieee80211_hw *hw) rtl_easy_concurrent_retrytimer_callback, (unsigned long)hw); /* <2> work queue */ rtlpriv->works.hw = hw; -/**/ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) -/**/ rtlpriv->works.rtl_wq = alloc_workqueue("%s", 0, 0, rtlpriv->cfg->name); -/**/ -#else - rtlpriv->works.rtl_wq = create_workqueue(rtlpriv->cfg->name); -#endif -/**/ if (!rtlpriv->works.rtl_wq) return -ENOMEM; @@ -901,13 +875,8 @@ bool rtl_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx) hdr->addr3, tid); if (skb_delba) { -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)) rx_status.freq = hw->conf.chandef.chan->center_freq; rx_status.band = hw->conf.chandef.chan->band; -#else - rx_status.freq = hw->conf.channel->center_freq; - rx_status.band = hw->conf.channel->band; -#endif rx_status.flag |= RX_FLAG_DECRYPTED; rx_status.flag |= RX_FLAG_MACTIME_MPDU; rx_status.rate_idx = 0; @@ -1482,21 +1451,8 @@ int rtl_send_smps_action(struct ieee80211_hw *hw, /* rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0); */ info->control.rates[0].idx = 0; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)) info->band = hw->conf.chandef.chan->band; -#else - info->band = hw->conf.channel->band; -#endif -/**/ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) - info->control.sta = sta; - rtlpriv->intf_ops->adapter_tx(hw, skb, &tcb_desc); -#else -/**/ rtlpriv->intf_ops->adapter_tx(hw, sta, skb, &tcb_desc); -/**/ -#endif -/**/ } return 1; -- cgit v1.2.3 From 80e3e09c0e5918d85c692f6f4677b6e5a7d277ed Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 27 May 2014 16:02:34 +0530 Subject: staging: rtl8821ae: cam.c: Remove version specific code The code should be for the current kernel version. Remove conditional version based code. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/cam.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8821ae/cam.c b/drivers/staging/rtl8821ae/cam.c index 72743e78954b..3bc6b3d06514 100644 --- a/drivers/staging/rtl8821ae/cam.c +++ b/drivers/staging/rtl8821ae/cam.c @@ -28,9 +28,7 @@ *****************************************************************************/ #include "wifi.h" #include "cam.h" -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) #include -#endif void rtl_cam_reset_sec_info(struct ieee80211_hw *hw) { -- cgit v1.2.3 From 479774008ac2c592e6cebe1d2cdb5fff8f354d30 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 27 May 2014 16:02:35 +0530 Subject: staging: rtl8821ae: compat.h: Remove version specific code The code should be for the current kernel version. Remove conditional version based code. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/compat.h | 57 -------------------------------------- 1 file changed, 57 deletions(-) diff --git a/drivers/staging/rtl8821ae/compat.h b/drivers/staging/rtl8821ae/compat.h index 68269cc2d477..ffb5f8b07bd0 100644 --- a/drivers/staging/rtl8821ae/compat.h +++ b/drivers/staging/rtl8821ae/compat.h @@ -1,65 +1,8 @@ #ifndef __RTL_COMPAT_H__ #define __RTL_COMPAT_H__ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) -/* - * Use this if you want to use the same suspend and resume callbacks for suspend - * to RAM and hibernation. - */ -#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \ -struct dev_pm_ops name = { \ - .suspend = suspend_fn, \ - .resume = resume_fn, \ - .freeze = suspend_fn, \ - .thaw = resume_fn, \ - .poweroff = suspend_fn, \ - .restore = resume_fn, \ -} - -#define compat_pci_suspend(fn) \ - int fn##_compat(struct pci_dev *pdev, pm_message_t state) \ - { \ - int r; \ - \ - r = fn(&pdev->dev); \ - if (r) \ - return r; \ - \ - pci_save_state(pdev); \ - pci_disable_device(pdev); \ - pci_set_power_state(pdev, PCI_D3hot); \ - \ - return 0; \ - } - -#define compat_pci_resume(fn) \ - int fn##_compat(struct pci_dev *pdev) \ - { \ - int r; \ - \ - pci_set_power_state(pdev, PCI_D0); \ - r = pci_enable_device(pdev); \ - if (r) \ - return r; \ - pci_restore_state(pdev); \ - \ - return fn(&pdev->dev); \ - } -#endif - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) -#define RX_FLAG_MACTIME_MPDU RX_FLAG_TSFT -#else -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) #define RX_FLAG_MACTIME_MPDU RX_FLAG_MACTIME_START -#else -#endif -//#define NETDEV_TX_OK -#endif - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)) #define IEEE80211_KEY_FLAG_SW_MGMT IEEE80211_KEY_FLAG_SW_MGMT_TX -#endif struct ieee80211_mgmt_compat { __le16 frame_control; -- cgit v1.2.3 From 0cd05ba54a535b03eceaf048decf81cc7ff6fca0 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 27 May 2014 16:02:36 +0530 Subject: staging: rtl8821ae: core.c: Remove version specific code The code should be for the current kernel version. Remove conditional version based code. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/core.c | 156 +-------------------------------------- 1 file changed, 2 insertions(+), 154 deletions(-) diff --git a/drivers/staging/rtl8821ae/core.c b/drivers/staging/rtl8821ae/core.c index ff3139b6da65..9a37408708f4 100644 --- a/drivers/staging/rtl8821ae/core.c +++ b/drivers/staging/rtl8821ae/core.c @@ -88,42 +88,9 @@ static void rtl_op_stop(struct ieee80211_hw *hw) mutex_unlock(&rtlpriv->locks.conf_mutex); } -/**/ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) -static int rtl_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); - struct rtl_tcb_desc tcb_desc; - memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc)); - - if (unlikely(is_hal_stop(rtlhal) || ppsc->rfpwr_state != ERFON)) - goto err_free; - - if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status)) - goto err_free; - - if (!rtlpriv->intf_ops->waitq_insert(hw, skb)) - rtlpriv->intf_ops->adapter_tx(hw, skb, &tcb_desc); - - return NETDEV_TX_OK; - -err_free: - dev_kfree_skb_any(skb); - return NETDEV_TX_OK; -} -#else -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) -static void rtl_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) -#else -/**/ static void rtl_op_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control, struct sk_buff *skb) -/**/ -#endif -/**/ { struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); @@ -137,26 +104,14 @@ static void rtl_op_tx(struct ieee80211_hw *hw, if (!test_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status)) goto err_free; -/**/ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) - if (!rtlpriv->intf_ops->waitq_insert(hw, skb)) - rtlpriv->intf_ops->adapter_tx(hw, skb, &tcb_desc); -#else -/**/ if (!rtlpriv->intf_ops->waitq_insert(hw, control->sta, skb)) rtlpriv->intf_ops->adapter_tx(hw, control->sta, skb, &tcb_desc); -/**/ -#endif -/**/ return; err_free: dev_kfree_skb_any(skb); return; } -/**/ -#endif -/**/ static int rtl_op_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) @@ -171,26 +126,15 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw, return -EOPNOTSUPP; } -/*This flag is not defined before kernel 3.4*/ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER; -#endif rtl_ips_nic_on(hw); mutex_lock(&rtlpriv->locks.conf_mutex); -/**/ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) switch (ieee80211_vif_type_p2p(vif)) { case NL80211_IFTYPE_P2P_CLIENT: mac->p2p = P2P_ROLE_CLIENT; /*fall through*/ -#else -/**/ - switch (vif->type) { -/**/ -#endif -/**/ case NL80211_IFTYPE_STATION: if (mac->beacon_enabled == 1) { RT_TRACE(COMP_MAC80211, DBG_LOUD, @@ -214,13 +158,9 @@ static int rtl_op_add_interface(struct ieee80211_hw *hw, (u8 *) (&mac->basic_rates)); break; -/**/ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) case NL80211_IFTYPE_P2P_GO: mac->p2p = P2P_ROLE_GO; /*fall through*/ -#endif -/**/ case NL80211_IFTYPE_AP: RT_TRACE(COMP_MAC80211, DBG_LOUD, ("NL80211_IFTYPE_AP \n")); @@ -310,9 +250,7 @@ static void rtl_op_remove_interface(struct ieee80211_hw *hw, mutex_unlock(&rtlpriv->locks.conf_mutex); } -/**/ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) -/**/ + static int rtl_op_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, enum nl80211_iftype new_type, bool p2p) @@ -328,9 +266,7 @@ static int rtl_op_change_interface(struct ieee80211_hw *hw, (" p2p %x\n",p2p)); return ret; } -/**/ -#endif -/**/ + static int rtl_op_config(struct ieee80211_hw *hw, u32 changed) { struct rtl_priv *rtlpriv = rtl_priv(hw); @@ -398,14 +334,9 @@ static int rtl_op_config(struct ieee80211_hw *hw, u32 changed) } if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) struct ieee80211_channel *channel = hw->conf.chandef.chan; enum nl80211_channel_type channel_type = cfg80211_get_chandef_type(&(hw->conf.chandef)); -#else - struct ieee80211_channel *channel = hw->conf.channel; - enum nl80211_channel_type channel_type = hw->conf.channel_type; -#endif u8 wide_chan = (u8) channel->hw_value; if (mac->act_scanning) @@ -661,14 +592,9 @@ static int _rtl_get_hal_qnum(u16 queue) *for mac80211 VO=0, VI=1, BE=2, BK=3 *for rtl819x BE=0, BK=1, VI=2, VO=3 */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) static int rtl_op_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue, const struct ieee80211_tx_queue_params *param) -#else -static int rtl_op_conf_tx(struct ieee80211_hw *hw, u16 queue, - const struct ieee80211_tx_queue_params *param) -#endif { struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); @@ -964,11 +890,7 @@ out: mutex_unlock(&rtlpriv->locks.conf_mutex); } -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) static u64 rtl_op_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) -#else -static u64 rtl_op_get_tsf(struct ieee80211_hw *hw) -#endif { struct rtl_priv *rtlpriv = rtl_priv(hw); u64 tsf; @@ -977,12 +899,8 @@ static u64 rtl_op_get_tsf(struct ieee80211_hw *hw) return tsf; } -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) static void rtl_op_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u64 tsf) -#else -static void rtl_op_set_tsf(struct ieee80211_hw *hw, u64 tsf) -#endif { struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); @@ -992,11 +910,7 @@ static void rtl_op_set_tsf(struct ieee80211_hw *hw, u64 tsf) rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_CORRECT_TSF, (u8 *) (&bibss)); } -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) static void rtl_op_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) -#else -static void rtl_op_reset_tsf(struct ieee80211_hw *hw) -#endif { struct rtl_priv *rtlpriv = rtl_priv(hw); u8 tmp = 0; @@ -1023,13 +937,7 @@ static int rtl_op_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, enum ieee80211_ampdu_mlme_action action, struct ieee80211_sta *sta, u16 tid, u16 * ssn -/**/ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) -/**/ ,u8 buf_size -/**/ -#endif -/**/ ) { struct rtl_priv *rtlpriv = rtl_priv(hw); @@ -1040,13 +948,9 @@ static int rtl_op_ampdu_action(struct ieee80211_hw *hw, ("IEEE80211_AMPDU_TX_START: TID:%d\n", tid)); return rtl_tx_agg_start(hw, vif, sta, tid, ssn); break; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) case IEEE80211_AMPDU_TX_STOP_CONT: case IEEE80211_AMPDU_TX_STOP_FLUSH: case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: -#else - case IEEE80211_AMPDU_TX_STOP: -#endif RT_TRACE(COMP_MAC80211, DBG_TRACE, ("IEEE80211_AMPDU_TX_STOP: TID:%d\n", tid)); return rtl_tx_agg_stop(hw, vif, sta, tid); @@ -1174,9 +1078,6 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, mutex_lock(&rtlpriv->locks.conf_mutex); /* <1> get encryption alg */ -/**/ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) -/**/ switch (key->cipher) { case WLAN_CIPHER_SUITE_WEP40: key_type = WEP40_ENCRYPTION; @@ -1209,43 +1110,6 @@ static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, ("alg_err:%x!!!!:\n", key->cipher)); goto out_unlock; } -/**/ -#else - switch (key->alg) { - case ALG_WEP: - if (key->keylen == WLAN_KEY_LEN_WEP40) { - key_type = WEP40_ENCRYPTION; - RT_TRACE(COMP_SEC, DBG_DMESG, ("alg:WEP40\n")); - } else { - RT_TRACE(COMP_SEC, DBG_DMESG, - ("alg:WEP104\n")); - key_type = WEP104_ENCRYPTION; - } - break; - case ALG_TKIP: - key_type = TKIP_ENCRYPTION; - RT_TRACE(COMP_SEC, DBG_DMESG, ("alg:TKIP\n")); - break; - case ALG_CCMP: - key_type = AESCCMP_ENCRYPTION; - RT_TRACE(COMP_SEC, DBG_DMESG, ("alg:CCMP\n")); - break; - case ALG_AES_CMAC: - /*HW don't support CMAC encryption, use software CMAC encryption */ - key_type = AESCMAC_ENCRYPTION; - RT_TRACE(COMP_SEC, DBG_DMESG, ("alg:CMAC\n")); - RT_TRACE(COMP_SEC, DBG_DMESG, - ("HW don't support CMAC encryption, " - "use software CMAC encryption\n")); - err = -EOPNOTSUPP; - goto out_unlock; - default: - RT_TRACE(COMP_ERR, DBG_EMERG, - ("alg_err:%x!!!!:\n", key->alg)); - goto out_unlock; - } -#endif -/**/ if(key_type == WEP40_ENCRYPTION || key_type == WEP104_ENCRYPTION || vif->type == NL80211_IFTYPE_ADHOC) @@ -1414,7 +1278,6 @@ static void rtl_op_rfkill_poll(struct ieee80211_hw *hw) * before switch channel or power save, or tx buffer packet * maybe send after offchannel or rf sleep, this may cause * dis-association by AP */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) static void rtl_op_flush(struct ieee80211_hw *hw, u32 queues, bool drop) { struct rtl_priv *rtlpriv = rtl_priv(hw); @@ -1422,15 +1285,6 @@ static void rtl_op_flush(struct ieee80211_hw *hw, u32 queues, bool drop) if (rtlpriv->intf_ops->flush) rtlpriv->intf_ops->flush(hw, queues, drop); } -#else -static void rtl_op_flush(struct ieee80211_hw *hw, bool drop) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - - if (rtlpriv->intf_ops->flush) - rtlpriv->intf_ops->flush(hw, drop); -} -#endif const struct ieee80211_ops rtl_ops = { .start = rtl_op_start, @@ -1438,13 +1292,7 @@ const struct ieee80211_ops rtl_ops = { .tx = rtl_op_tx, .add_interface = rtl_op_add_interface, .remove_interface = rtl_op_remove_interface, -/**/ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) -/**/ .change_interface = rtl_op_change_interface, -/**/ -#endif -/**/ .config = rtl_op_config, .configure_filter = rtl_op_configure_filter, .set_key = rtl_op_set_key, -- cgit v1.2.3 From 4874043a6c1effd4f52d6c5f83805b7e1bf50939 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 27 May 2014 16:02:37 +0530 Subject: staging: rtl8821ae: debug.c: Remove version specific code The code should be for the current kernel version. Remove conditional version based code. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/debug.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/rtl8821ae/debug.c b/drivers/staging/rtl8821ae/debug.c index 8a6c794bda41..8aefbf10a45e 100644 --- a/drivers/staging/rtl8821ae/debug.c +++ b/drivers/staging/rtl8821ae/debug.c @@ -30,12 +30,7 @@ #include "wifi.h" #include "cam.h" -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) #define GET_INODE_DATA(__node) PDE_DATA(__node) -#else -#define GET_INODE_DATA(__node) PDE(__node)->data -#endif - void rtl_dbgp_flag_init(struct ieee80211_hw *hw) { -- cgit v1.2.3 From 1939f350a251c84106a994588fe410d43bfa9468 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 27 May 2014 16:02:38 +0530 Subject: staging: rtl8821ae: efuse.c: Remove version specific code The code should be for the current kernel version. Remove conditional version based code. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/efuse.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8821ae/efuse.c b/drivers/staging/rtl8821ae/efuse.c index 250aae1ce631..206012cf3601 100644 --- a/drivers/staging/rtl8821ae/efuse.c +++ b/drivers/staging/rtl8821ae/efuse.c @@ -29,9 +29,7 @@ #include "wifi.h" #include "efuse.h" #include "btcoexist/halbt_precomp.h" -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) #include -#endif static const u8 MAX_PGPKT_SIZE = 9; static const u8 PGPKT_DATA_SIZE = 8; -- cgit v1.2.3 From c6e8a9e8ef85ab561324b1558c572a97d42e4528 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 27 May 2014 16:02:39 +0530 Subject: staging: rtl8821ae: pci.c: Remove version specific code The code should be for the current kernel version. Remove conditional version based code. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/pci.c | 120 ---------------------------------------- 1 file changed, 120 deletions(-) diff --git a/drivers/staging/rtl8821ae/pci.c b/drivers/staging/rtl8821ae/pci.c index eef3ebcd78af..e194ffe58acc 100644 --- a/drivers/staging/rtl8821ae/pci.c +++ b/drivers/staging/rtl8821ae/pci.c @@ -33,9 +33,7 @@ #include "base.h" #include "ps.h" #include "efuse.h" -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) #include -#endif static const u16 pcibridge_vendors[PCI_BRIDGE_VENDOR_MAX] = { INTEL_VENDOR_ID, @@ -364,47 +362,6 @@ static bool rtl_pci_get_amd_l1_patch(struct ieee80211_hw *hw) return status; } -/**/ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)) -static u8 _rtl_pci_get_pciehdr_offset(struct ieee80211_hw *hw) -{ - u8 capability_offset; - u8 num4bytes = 0x34/4; - struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); - u32 pcicfg_addr_port = (pcipriv->ndis_adapter.pcibridge_busnum << 16)| - (pcipriv->ndis_adapter.pcibridge_devnum << 11)| - (pcipriv->ndis_adapter.pcibridge_funcnum << 8)| - (1 << 31); - - rtl_pci_raw_write_port_ulong(PCI_CONF_ADDRESS , pcicfg_addr_port - + (num4bytes << 2)); - rtl_pci_raw_read_port_uchar(PCI_CONF_DATA, &capability_offset); - while (capability_offset != 0) { - struct rtl_pci_capabilities_header capability_hdr; - - num4bytes = capability_offset / 4; - /* Read the header of the capability at this offset. - * If the retrieved capability is not the power management - * capability that we are looking for, follow the link to - * the next capability and continue looping. - */ - rtl_pci_raw_write_port_ulong(PCI_CONF_ADDRESS , - pcicfg_addr_port + - (num4bytes << 2)); - rtl_pci_raw_read_port_ushort(PCI_CONF_DATA, - (u16 *)&capability_hdr); - /* Found the PCI express capability. */ - if (capability_hdr.capability_id == - PCI_CAPABILITY_ID_PCI_EXPRESS) - break; - else - capability_offset = capability_hdr.next; - } - return capability_offset; -} -#endif -/**/ - bool rtl_pci_check_buddy_priv(struct ieee80211_hw *hw, struct rtl_priv **buddy_priv) { @@ -610,14 +567,7 @@ static void _rtl_pci_tx_chk_waitq(struct ieee80211_hw *hw) _rtl_pci_update_earlymode_info(hw, skb, &tcb_desc, tid); -/**/ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) - rtlpriv->intf_ops->adapter_tx(hw, skb, &tcb_desc); -#else -/**/ rtlpriv->intf_ops->adapter_tx(hw, NULL, skb, &tcb_desc); -#endif -/**/ } } } @@ -1201,19 +1151,9 @@ static void _rtl_pci_prepare_bcn_tasklet(struct ieee80211_hw *hw) if (rtlpriv->use_new_trx_flow) pbuffer_desc = &ring->buffer_desc[0]; -/**/ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) - rtlpriv->cfg->ops->fill_tx_desc(hw, hdr, (u8 *) pdesc, - (u8 *)pbuffer_desc, info, pskb, - BEACON_QUEUE, &tcb_desc); -#else -/**/ rtlpriv->cfg->ops->fill_tx_desc(hw, hdr, (u8 *) pdesc, (u8 *)pbuffer_desc, info, NULL, pskb, BEACON_QUEUE, &tcb_desc); -/**/ -#endif -/**/ __skb_queue_tail(&ring->queue, pskb); @@ -1616,26 +1556,11 @@ int rtl_pci_reset_trx_ring(struct ieee80211_hw *hw) return 0; } -/**/ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) -static bool rtl_pci_tx_chk_waitq_insert(struct ieee80211_hw *hw, - struct sk_buff *skb) -#else -/**/ static bool rtl_pci_tx_chk_waitq_insert(struct ieee80211_hw *hw, struct ieee80211_sta *sta, struct sk_buff *skb) -/**/ -#endif -/**/ { struct rtl_priv *rtlpriv = rtl_priv(hw); -/**/ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - struct ieee80211_sta *sta = info->control.sta; -#endif -/**/ struct rtl_sta_info *sta_entry = NULL; u8 tid = rtl_get_tid(skb); u16 fc = rtl_get_fc(skb); @@ -1671,28 +1596,14 @@ static bool rtl_pci_tx_chk_waitq_insert(struct ieee80211_hw *hw, return true; } -/**/ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) -int rtl_pci_tx(struct ieee80211_hw *hw, struct sk_buff *skb, - struct rtl_tcb_desc *ptcb_desc) -#else -/**/ static int rtl_pci_tx(struct ieee80211_hw *hw, struct ieee80211_sta *sta, struct sk_buff *skb, struct rtl_tcb_desc *ptcb_desc) -/**/ -#endif -/**/ { struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_sta_info *sta_entry = NULL; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); -/**/ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) - struct ieee80211_sta *sta = info->control.sta; -#endif -/**/ struct rtl8192_tx_ring *ring; struct rtl_tx_desc *pdesc; struct rtl_tx_buffer_desc *ptx_bd_desc = NULL; @@ -1777,19 +1688,9 @@ static int rtl_pci_tx(struct ieee80211_hw *hw, if (ieee80211_is_data(fc)) rtlpriv->cfg->ops->led_control(hw, LED_CTL_TX); -/**/ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) - rtlpriv->cfg->ops->fill_tx_desc(hw, hdr, (u8 *) pdesc, - (u8 *)ptx_bd_desc, info, skb, - hw_queue, ptcb_desc); -#else -/**/ rtlpriv->cfg->ops->fill_tx_desc(hw, hdr, (u8 *) pdesc, (u8 *)ptx_bd_desc, info, sta, skb, hw_queue, ptcb_desc); -/**/ -#endif -/**/ __skb_queue_tail(&ring->queue, skb); if (rtlpriv->use_new_trx_flow) { @@ -1819,11 +1720,7 @@ static int rtl_pci_tx(struct ieee80211_hw *hw, return 0; } -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) static void rtl_pci_flush(struct ieee80211_hw *hw, u32 queues, bool drop) -#else -static void rtl_pci_flush(struct ieee80211_hw *hw, bool drop) -#endif { struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); @@ -1838,12 +1735,10 @@ static void rtl_pci_flush(struct ieee80211_hw *hw, bool drop) for (queue_id = RTL_PCI_MAX_TX_QUEUE_COUNT - 1; queue_id >= 0;) { u32 queue_len; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) if (((queues >> queue_id) & 0x1) == 0) { queue_id--; continue; } -#endif ring = &pcipriv->dev.tx_ring[queue_id]; queue_len = skb_queue_len(&ring->queue); if (queue_len == 0 || queue_id == BEACON_QUEUE || @@ -2122,17 +2017,8 @@ static bool _rtl_pci_find_adapter(struct pci_dev *pdev, (pcipriv->ndis_adapter.pcibridge_busnum << 16) | (pcipriv->ndis_adapter.pcibridge_devnum << 11) | (pcipriv->ndis_adapter.pcibridge_funcnum << 8) | (1 << 31); -/**/ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) -/**/ pcipriv->ndis_adapter.pcibridge_pciehdr_offset = pci_pcie_cap(bridge_pdev); -/**/ -#else - pcipriv->ndis_adapter.pcibridge_pciehdr_offset = - _rtl_pci_get_pciehdr_offset(hw); -#endif -/**/ pcipriv->ndis_adapter.num4bytes = (pcipriv->ndis_adapter.pcibridge_pciehdr_offset + 0x10) / 4; @@ -2230,14 +2116,8 @@ static int rtl_pci_intr_mode_decide(struct ieee80211_hw *hw) * hw pointer in rtl_pci_get_hw_pointer */ struct ieee80211_hw *hw_export = NULL; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) int rtl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) - -#else -int __devinit rtl_pci_probe(struct pci_dev *pdev, - const struct pci_device_id *id) -#endif { struct ieee80211_hw *hw = NULL; -- cgit v1.2.3 From aa59f7a5263d67750732142c7459876e37b01ffc Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 27 May 2014 16:02:40 +0530 Subject: staging: rtl8821ae: pci.h: Remove version specific code The code should be for the current kernel version. Remove conditional version based code. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/pci.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/rtl8821ae/pci.h b/drivers/staging/rtl8821ae/pci.h index 06eaa521e0eb..3f16ec90296a 100644 --- a/drivers/staging/rtl8821ae/pci.h +++ b/drivers/staging/rtl8821ae/pci.h @@ -282,13 +282,8 @@ int rtl_pci_reset_trx_ring(struct ieee80211_hw *hw); extern struct rtl_intf_ops rtl_pci_ops; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) int rtl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id); -#else -int __devinit rtl_pci_probe(struct pci_dev *pdev, - const struct pci_device_id *id); -#endif void rtl_pci_disconnect(struct pci_dev *pdev); int rtl_pci_suspend(struct device *dev); int rtl_pci_resume(struct device *dev); -- cgit v1.2.3 From 35722b4141f9d504ec0fb287d80dd1b7f06ce87c Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 27 May 2014 16:02:41 +0530 Subject: staging: rtl8821ae: ps.c: Remove version specific code The code should be for the current kernel version. Remove conditional version based code. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/ps.c | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/drivers/staging/rtl8821ae/ps.c b/drivers/staging/rtl8821ae/ps.c index 7876442417f4..5a9bbf025e25 100644 --- a/drivers/staging/rtl8821ae/ps.c +++ b/drivers/staging/rtl8821ae/ps.c @@ -30,9 +30,7 @@ #include "wifi.h" #include "base.h" #include "ps.h" -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) #include -#endif #include "btcoexist/rtl_btc.h" bool rtl_ps_enable_nic(struct ieee80211_hw *hw) @@ -542,17 +540,8 @@ void rtl_swlps_beacon(struct ieee80211_hw *hw, void *data, unsigned int len) tim_len = tim[1]; tim_ie = (struct ieee80211_tim_ie *) &tim[2]; -/**/ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) -/**/ if (!WARN_ON_ONCE(!hw->conf.ps_dtim_period)) rtlpriv->psc.dtim_counter = tim_ie->dtim_count; -/**/ -#else - if (!WARN_ON_ONCE(!mac->vif->bss_conf.dtim_period)) - rtlpriv->psc.dtim_counter = tim_ie->dtim_count; -#endif -/**/ /* Check whenever the PHY can be turned off again. */ @@ -656,9 +645,6 @@ void rtl_swlps_rf_sleep(struct ieee80211_hw *hw) * time to sleep_intv = rtlpriv->psc.dtim_counter or * MAX_SW_LPS_SLEEP_INTV(default set to 5) */ -/**/ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) -/**/ if (rtlpriv->psc.dtim_counter == 0) { if (hw->conf.ps_dtim_period == 1) sleep_intv = hw->conf.ps_dtim_period * 2; @@ -667,18 +653,6 @@ void rtl_swlps_rf_sleep(struct ieee80211_hw *hw) } else { sleep_intv = rtlpriv->psc.dtim_counter; } -/**/ -#else - if (rtlpriv->psc.dtim_counter == 0) { - if (mac->vif->bss_conf.dtim_period == 1) - sleep_intv = mac->vif->bss_conf.dtim_period * 2; - else - sleep_intv = mac->vif->bss_conf.dtim_period; - } else { - sleep_intv = rtlpriv->psc.dtim_counter; - } -#endif -/**/ if (sleep_intv > MAX_SW_LPS_SLEEP_INTV) sleep_intv = MAX_SW_LPS_SLEEP_INTV; -- cgit v1.2.3 From 756a748106f44513906507e2ddef7a12b81a0990 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 27 May 2014 16:02:42 +0530 Subject: staging: rtl8821ae: rc.c: Remove version specific code The code should be for the current kernel version. Remove conditional version based code. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/rc.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/drivers/staging/rtl8821ae/rc.c b/drivers/staging/rtl8821ae/rc.c index a5a09baa99c5..0b4f32185082 100644 --- a/drivers/staging/rtl8821ae/rc.c +++ b/drivers/staging/rtl8821ae/rc.c @@ -210,16 +210,8 @@ static void rtl_tx_status(void *ppriv, tid)) { sta_entry->tids[tid].agg.agg_state = RTL_AGG_PROGRESS; - /**/ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) - /**/ ieee80211_start_tx_ba_session(sta, tid, 5000); - /**/ -#else - ieee80211_start_tx_ba_session(sta, tid); -#endif - /**/ } } } @@ -232,15 +224,6 @@ static void rtl_rate_init(void *ppriv, struct ieee80211_sta *sta, void *priv_sta) { } -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)) -static void rtl_rate_update(void *ppriv, - struct ieee80211_supported_band *sband, - struct ieee80211_sta *sta, void *priv_sta, - u32 changed, - enum nl80211_channel_type oper_chan_type) -{ -} -#else static void rtl_rate_update(void *ppriv, struct ieee80211_supported_band *sband, struct cfg80211_chan_def *chandef, @@ -248,7 +231,6 @@ static void rtl_rate_update(void *ppriv, u32 changed) { } -#endif static void *rtl_rate_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) { struct rtl_priv *rtlpriv = rtl_priv(hw); -- cgit v1.2.3 From b9ddcee90306b824c591cbee210f39d7377db220 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 27 May 2014 16:02:43 +0530 Subject: staging: rtl8821ae: regd.c: Remove version specific code The code should be for the current kernel version. Remove conditional version based code. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/regd.c | 52 ---------------------------------------- 1 file changed, 52 deletions(-) diff --git a/drivers/staging/rtl8821ae/regd.c b/drivers/staging/rtl8821ae/regd.c index 0a4b3984b7ef..2efa5f31822b 100644 --- a/drivers/staging/rtl8821ae/regd.c +++ b/drivers/staging/rtl8821ae/regd.c @@ -158,11 +158,6 @@ static void _rtl_reg_apply_beaconing_flags(struct wiphy *wiphy, const struct ieee80211_reg_rule *reg_rule; struct ieee80211_channel *ch; unsigned int i; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)) - u32 bandwidth = 0; - int r; -#endif - for (band = 0; band < IEEE80211_NUM_BANDS; band++) { if (!wiphy->bands[band]) @@ -176,16 +171,9 @@ static void _rtl_reg_apply_beaconing_flags(struct wiphy *wiphy, (ch->flags & IEEE80211_CHAN_RADAR)) continue; if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) { -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) reg_rule = freq_reg_info(wiphy, ch->center_freq); if (IS_ERR(reg_rule)) continue; -#else - r = freq_reg_info(wiphy, ch->center_freq, - bandwidth, ®_rule); - if (r) - continue; -#endif /* *If 11d had a rule for this channel ensure @@ -219,10 +207,6 @@ static void _rtl_reg_apply_active_scan_flags(struct wiphy *wiphy, struct ieee80211_supported_band *sband; struct ieee80211_channel *ch; const struct ieee80211_reg_rule *reg_rule; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)) - u32 bandwidth = 0; - int r; -#endif if (!wiphy->bands[IEEE80211_BAND_2GHZ]) return; @@ -250,26 +234,16 @@ static void _rtl_reg_apply_active_scan_flags(struct wiphy *wiphy, */ ch = &sband->channels[11]; /* CH 12 */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) reg_rule = freq_reg_info(wiphy, ch->center_freq); if (!IS_ERR(reg_rule)) { -#else - r = freq_reg_info(wiphy, ch->center_freq, bandwidth, ®_rule); - if (!r) { -#endif if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN)) if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN) ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN; } ch = &sband->channels[12]; /* CH 13 */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) reg_rule = freq_reg_info(wiphy, ch->center_freq); if (!IS_ERR(reg_rule)) { -#else - r = freq_reg_info(wiphy, ch->center_freq, bandwidth, ®_rule); - if (!r) { -#endif if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN)) if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN) ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN; @@ -389,19 +363,11 @@ static const struct ieee80211_regdomain *_rtl_regdomain_select( } } -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) static int _rtl_regd_init_wiphy(struct rtl_regulatory *reg, struct wiphy *wiphy, void (*reg_notifier) (struct wiphy * wiphy, struct regulatory_request * request)) -#else -static int _rtl_regd_init_wiphy(struct rtl_regulatory *reg, - struct wiphy *wiphy, - int (*reg_notifier) (struct wiphy * wiphy, - struct regulatory_request * - request)) -#endif { const struct ieee80211_regdomain *regd; @@ -429,15 +395,9 @@ static struct country_code_to_enum_rd *_rtl_regd_find_country(u16 countrycode) return NULL; } -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) int rtl_regd_init(struct ieee80211_hw *hw, void (*reg_notifier) (struct wiphy *wiphy, struct regulatory_request *request)) -#else -int rtl_regd_init(struct ieee80211_hw *hw, - int (*reg_notifier) (struct wiphy *wiphy, - struct regulatory_request *request)) -#endif { struct rtl_priv *rtlpriv = rtl_priv(hw); struct wiphy *wiphy = hw->wiphy; @@ -480,7 +440,6 @@ int rtl_regd_init(struct ieee80211_hw *hw, return 0; } -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) void rtl_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request) { struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); @@ -490,14 +449,3 @@ void rtl_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request) _rtl_reg_notifier_apply(wiphy, request, &rtlpriv->regd); } -#else -int rtl_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request) -{ - struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); - struct rtl_priv *rtlpriv = rtl_priv(hw); - - RT_TRACE(COMP_REGD, DBG_LOUD, ("\n")); - - return _rtl_reg_notifier_apply(wiphy, request, &rtlpriv->regd); -} -#endif -- cgit v1.2.3 From 0c288d454dab047801ac83f5af9f72be1364c74e Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 27 May 2014 16:02:44 +0530 Subject: staging: rtl8821ae: regd.h: Remove version specific code The code should be for the current kernel version. Remove conditional version based code. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/regd.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/rtl8821ae/regd.h b/drivers/staging/rtl8821ae/regd.h index dceb3f18200b..1cfcb97b0ab1 100644 --- a/drivers/staging/rtl8821ae/regd.h +++ b/drivers/staging/rtl8821ae/regd.h @@ -60,16 +60,8 @@ enum country_code_type_t { COUNTRY_CODE_MAX }; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) int rtl_regd_init(struct ieee80211_hw *hw, void (*reg_notifier) (struct wiphy *wiphy, struct regulatory_request *request)); void rtl_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request); -#else -int rtl_regd_init(struct ieee80211_hw *hw, - int (*reg_notifier) (struct wiphy *wiphy, - struct regulatory_request *request)); -int rtl_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request); -#endif - #endif -- cgit v1.2.3 From 575e8dace0d3d94c76b67e400a31f8998953f870 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 27 May 2014 16:02:45 +0530 Subject: staging: rtl8821ae: sw.c: Remove version specific code The code should be for the current kernel version. Remove conditional version based code. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/rtl8821ae/sw.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/drivers/staging/rtl8821ae/rtl8821ae/sw.c b/drivers/staging/rtl8821ae/rtl8821ae/sw.c index e90806ebeb07..26212755f88e 100644 --- a/drivers/staging/rtl8821ae/rtl8821ae/sw.c +++ b/drivers/staging/rtl8821ae/rtl8821ae/sw.c @@ -415,19 +415,11 @@ static struct rtl_hal_cfg rtl8821ae_hal_cfg = { .maps[RTL_RC_HT_RATEMCS15] = DESC_RATEMCS15, }; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) static struct pci_device_id rtl8821ae_pci_ids[] = { {RTL_PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8812, rtl8821ae_hal_cfg)}, {RTL_PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8821, rtl8821ae_hal_cfg)}, {}, }; -#else -static struct pci_device_id rtl8821ae_pci_ids[] __devinitdata = { - {RTL_PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8812, rtl8821ae_hal_cfg)}, - {RTL_PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8821, rtl8821ae_hal_cfg)}, - {}, -}; -#endif MODULE_DEVICE_TABLE(pci, rtl8821ae_pci_ids); @@ -445,14 +437,7 @@ MODULE_PARM_DESC(swenc, "using hardware crypto (default 0 [hardware])\n"); MODULE_PARM_DESC(ips, "using no link power save (default 1 is open)\n"); MODULE_PARM_DESC(fwlps, "using linked fw control power save (default 1 is open)\n"); -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) static SIMPLE_DEV_PM_OPS(rtlwifi_pm_ops, rtl_pci_suspend, rtl_pci_resume); -#endif - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) -compat_pci_suspend(rtl_pci_suspend) -compat_pci_resume(rtl_pci_resume) -#endif static struct pci_driver rtl8821ae_driver = { .name = KBUILD_MODNAME, @@ -460,13 +445,7 @@ static struct pci_driver rtl8821ae_driver = { .probe = rtl_pci_probe, .remove = rtl_pci_disconnect, -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) .driver.pm = &rtlwifi_pm_ops, -#elif defined(CONFIG_PM) - .suspend = rtl_pci_suspend_compat, - .resume = rtl_pci_resume_compat, -#endif - }; -- cgit v1.2.3 From e7f5a2194255bf2a742e3986c9d89dde07f2ec35 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 27 May 2014 16:02:46 +0530 Subject: staging: rtl8821ae: trx.c: Remove version specific code The code should be for the current kernel version. Remove conditional version based code. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/rtl8821ae/trx.c | 45 ------------------------------- 1 file changed, 45 deletions(-) diff --git a/drivers/staging/rtl8821ae/rtl8821ae/trx.c b/drivers/staging/rtl8821ae/rtl8821ae/trx.c index f40a93c0d2bb..b4943e8b7f80 100644 --- a/drivers/staging/rtl8821ae/rtl8821ae/trx.c +++ b/drivers/staging/rtl8821ae/rtl8821ae/trx.c @@ -77,11 +77,7 @@ static int _rtl8821ae_rate_mapping(struct ieee80211_hw *hw, int rate_idx; if (false == isht) { -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) if (IEEE80211_BAND_2GHZ == hw->conf.chandef.chan->band) { -#else - if (IEEE80211_BAND_2GHZ == hw->conf.channel->band) { -#endif switch (desc_rate) { case DESC_RATE1M: rate_idx = 0; @@ -579,13 +575,8 @@ bool rtl8821ae_rx_query_desc(struct ieee80211_hw *hw, if (status->wake_match) RT_TRACE(COMP_RXDESC,DBG_LOUD, ("GGGGGGGGGGGGGet Wakeup Packet!! WakeMatch=%d\n",status->wake_match )); -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) rx_status->freq = hw->conf.chandef.chan->center_freq; rx_status->band = hw->conf.chandef.chan->band; -#else - rx_status->freq = hw->conf.channel->center_freq; - rx_status->band = hw->conf.channel->band; -#endif hdr = (struct ieee80211_hdr *)(skb->data + status->rx_drvinfo_size + status->rx_bufshift); @@ -650,33 +641,17 @@ bool rtl8821ae_rx_query_desc(struct ieee80211_hw *hw, return true; } -/**/ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) -void rtl8821ae_tx_fill_desc(struct ieee80211_hw *hw, - struct ieee80211_hdr *hdr, u8 *pdesc_tx, u8 *txbd, - struct ieee80211_tx_info *info, struct sk_buff *skb, - u8 hw_queue, struct rtl_tcb_desc *ptcb_desc) -#else -/**/ void rtl8821ae_tx_fill_desc(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr, u8 *pdesc_tx, u8 *txbd, struct ieee80211_tx_info *info, struct ieee80211_sta *sta, struct sk_buff *skb, u8 hw_queue, struct rtl_tcb_desc *ptcb_desc) -/**/ -#endif -/**/ { struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); struct rtl_hal *rtlhal = rtl_hal(rtlpriv); -/**/ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) - struct ieee80211_sta *sta = info->control.sta; -#endif -/**/ u8 *pdesc = (u8 *) pdesc_tx; u16 seq_number; u16 fc = le16_to_cpu(hdr->frame_control); @@ -783,9 +758,6 @@ void rtl8821ae_tx_fill_desc(struct ieee80211_hw *hw, } if (info->control.hw_key) { struct ieee80211_key_conf *keyconf = info->control.hw_key; -/**/ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) -/**/ switch (keyconf->cipher) { case WLAN_CIPHER_SUITE_WEP40: case WLAN_CIPHER_SUITE_WEP104: @@ -800,23 +772,6 @@ void rtl8821ae_tx_fill_desc(struct ieee80211_hw *hw, break; } -/**/ -#else - switch (keyconf->alg) { - case ALG_WEP: - case ALG_TKIP: - SET_TX_DESC_SEC_TYPE(pdesc, 0x1); - break; - case ALG_CCMP: - SET_TX_DESC_SEC_TYPE(pdesc, 0x3); - break; - default: - SET_TX_DESC_SEC_TYPE(pdesc, 0x0); - break; - - } -#endif -/**/ } SET_TX_DESC_QUEUE_SEL(pdesc, fw_qsel); -- cgit v1.2.3 From 2b4b5a628cb4c447cd22507e6c8d724c8ac23e22 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 27 May 2014 16:02:47 +0530 Subject: staging: rtl8821ae: trx.h: Remove version specific code The code should be for the current kernel version. Remove conditional version based code. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/rtl8821ae/trx.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/staging/rtl8821ae/rtl8821ae/trx.h b/drivers/staging/rtl8821ae/rtl8821ae/trx.h index da93e5c7ece7..af017844d82f 100644 --- a/drivers/staging/rtl8821ae/rtl8821ae/trx.h +++ b/drivers/staging/rtl8821ae/rtl8821ae/trx.h @@ -609,23 +609,12 @@ struct rx_desc_8821ae { } __packed; -/**/ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) -void rtl8821ae_tx_fill_desc(struct ieee80211_hw *hw, - struct ieee80211_hdr *hdr, u8 *pdesc_tx, u8 *txbd, - struct ieee80211_tx_info *info, struct sk_buff *skb, - u8 hw_queue, struct rtl_tcb_desc *ptcb_desc); -#else -/**/ void rtl8821ae_tx_fill_desc(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr, u8 *pdesc_tx, u8 *txbd, struct ieee80211_tx_info *info, struct ieee80211_sta *sta, struct sk_buff *skb, u8 hw_queue, struct rtl_tcb_desc *ptcb_desc); -/**/ -#endif -/**/ bool rtl8821ae_rx_query_desc(struct ieee80211_hw *hw, struct rtl_stats *status, struct ieee80211_rx_status *rx_status, -- cgit v1.2.3 From fe6d68f212b319561712e36acc363f482c56024f Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 27 May 2014 16:02:48 +0530 Subject: staging: rtl8821ae: stats.c: Remove version specific code The code should be for the current kernel version. Remove conditional version based code. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/stats.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8821ae/stats.c b/drivers/staging/rtl8821ae/stats.c index a20c0f8f65ec..4d383d11574e 100644 --- a/drivers/staging/rtl8821ae/stats.c +++ b/drivers/staging/rtl8821ae/stats.c @@ -28,9 +28,7 @@ *****************************************************************************/ #include "wifi.h" #include "stats.h" -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) #include -#endif u8 rtl_query_rxpwrpercentage(char antpower) { -- cgit v1.2.3 From 0481bfce17b3728d04d618ec6bc7367fa8f952b4 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Tue, 27 May 2014 21:05:41 +0530 Subject: staging: rtl8188eu:Remove function rtw_set_tx_chksum_offload() rtw_set_tx_chksum_offload() has empty defination. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_xmit.c | 2 -- drivers/staging/rtl8188eu/include/xmit_osdep.h | 2 -- drivers/staging/rtl8188eu/os_dep/xmit_linux.c | 4 ---- 3 files changed, 8 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index 8d4265fb486d..1413ec8ad3bf 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -621,8 +621,6 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("update_attrib: bswenc = false\n")); } - rtw_set_tx_chksum_offload(pkt, pattrib); - update_attrib_phy_info(pattrib, psta); exit: diff --git a/drivers/staging/rtl8188eu/include/xmit_osdep.h b/drivers/staging/rtl8188eu/include/xmit_osdep.h index 48bc5fca996d..13965f2489db 100644 --- a/drivers/staging/rtl8188eu/include/xmit_osdep.h +++ b/drivers/staging/rtl8188eu/include/xmit_osdep.h @@ -49,8 +49,6 @@ int rtw_os_xmit_resource_alloc(struct adapter *padapter, void rtw_os_xmit_resource_free(struct adapter *padapter, struct xmit_buf *pxmitbuf, u32 free_sz); -void rtw_set_tx_chksum_offload(struct sk_buff *pkt, struct pkt_attrib *pattrib); - uint rtw_remainder_len(struct pkt_file *pfile); void _rtw_open_pktfile(struct sk_buff *pkt, struct pkt_file *pfile); uint _rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint rlen); diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c index 2c8e3f72dec7..6089baea72ab 100644 --- a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c @@ -77,10 +77,6 @@ int rtw_endofpktfile(struct pkt_file *pfile) return false; } -void rtw_set_tx_chksum_offload(struct sk_buff *pkt, struct pkt_attrib *pattrib) -{ -} - int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitbuf, u32 alloc_sz) { int i; -- cgit v1.2.3 From c95c51170d3025c85fffa5aa28e65d462438a01c Mon Sep 17 00:00:00 2001 From: navin patidar Date: Tue, 27 May 2014 21:05:42 +0530 Subject: staging:rtl8188eu:Remove code specific to kernel version < 2.6.35 Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/xmit_linux.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c index 6089baea72ab..91723802dffd 100644 --- a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c @@ -113,7 +113,6 @@ void rtw_os_xmit_resource_free(struct adapter *padapter, void rtw_os_pkt_complete(struct adapter *padapter, struct sk_buff *pkt) { -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)) u16 queue; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; @@ -126,10 +125,6 @@ void rtw_os_pkt_complete(struct adapter *padapter, struct sk_buff *pkt) if (__netif_subqueue_stopped(padapter->pnetdev, queue)) netif_wake_subqueue(padapter->pnetdev, queue); } -#else - if (netif_queue_stopped(padapter->pnetdev)) - netif_wake_queue(padapter->pnetdev); -#endif dev_kfree_skb_any(pkt); } -- cgit v1.2.3 From baf3a0112c242a748aaa2d59f3365193adb23f78 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Tue, 27 May 2014 21:05:44 +0530 Subject: staging: rtl8188eu:Assign RTL8188E to padapter->chip_type directly Assign RTL8188E to padapter->chip_type directly instead of calling chip_by_usb_id() function to do same. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index a368aa92b259..fbf967d5b7c4 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -546,11 +546,8 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, dvobj->if1 = padapter; padapter->bDriverStopped = true; - padapter->hw_init_mutex = &usb_drv->hw_init_mutex; - - /* step 1-1., decide the chip_type via vid/pid */ - chip_by_usb_id(padapter, pdid); + padapter->chip_type = RTL8188E; if (rtw_handle_dualmac(padapter, 1) != _SUCCESS) goto free_adapter; -- cgit v1.2.3 From 4814257cc68930feefdffa40477c4f30d544c43c Mon Sep 17 00:00:00 2001 From: navin patidar Date: Tue, 27 May 2014 21:05:45 +0530 Subject: staging: rtl8188eu:Remove unused function chip_by_usb_id() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index fbf967d5b7c4..1e62713e15c9 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -219,13 +219,6 @@ static void usb_dvobj_deinit(struct usb_interface *usb_intf) } -static void chip_by_usb_id(struct adapter *padapter, - const struct usb_device_id *pdid) -{ - padapter->chip_type = NULL_CHIP_TYPE; - hal_set_hw_type(padapter); -} - static void usb_intf_start(struct adapter *padapter) { RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+usb_intf_start\n")); -- cgit v1.2.3 From 920f2e1134ead98958090b4b7139e325fc7b451c Mon Sep 17 00:00:00 2001 From: navin patidar Date: Tue, 27 May 2014 21:05:46 +0530 Subject: staging: rtl8188eu:Remove unused function rtl8188eu_set_hw_type() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/usb_ops_linux.c | 6 ------ drivers/staging/rtl8188eu/include/usb_ops.h | 1 - 2 files changed, 7 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/usb_ops_linux.c b/drivers/staging/rtl8188eu/hal/usb_ops_linux.c index ca81530f9cf5..3aadf560de00 100644 --- a/drivers/staging/rtl8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/hal/usb_ops_linux.c @@ -682,9 +682,3 @@ void rtl8188eu_set_intf_ops(struct _io_ops *pops) pops->_read_port_cancel = &usb_read_port_cancel; pops->_write_port_cancel = &usb_write_port_cancel; } - -void rtl8188eu_set_hw_type(struct adapter *adapt) -{ - adapt->chip_type = RTL8188E; - DBG_88E("CHIP TYPE: RTL8188E\n"); -} diff --git a/drivers/staging/rtl8188eu/include/usb_ops.h b/drivers/staging/rtl8188eu/include/usb_ops.h index 7d33477d551d..a290e0ff3060 100644 --- a/drivers/staging/rtl8188eu/include/usb_ops.h +++ b/drivers/staging/rtl8188eu/include/usb_ops.h @@ -63,7 +63,6 @@ enum{ #include void rtl8188eu_set_hw_type(struct adapter *padapter); -#define hal_set_hw_type rtl8188eu_set_hw_type void rtl8188eu_set_intf_ops(struct _io_ops *pops); #define usb_set_intf_ops rtl8188eu_set_intf_ops -- cgit v1.2.3 From 0f56c6e9783b2d4b7c4f64291337881f4075da92 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Tue, 27 May 2014 21:05:47 +0530 Subject: staging: rtl8188eu:Drop rtw_handle_dualmac() function calls in rtw_usb_if1_init() rtw_usb_if1_init() initializes pbuddy_padapter variable which is not being used. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index 1e62713e15c9..aa93cd00c4ae 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -542,12 +542,9 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, padapter->hw_init_mutex = &usb_drv->hw_init_mutex; padapter->chip_type = RTL8188E; - if (rtw_handle_dualmac(padapter, 1) != _SUCCESS) - goto free_adapter; - pnetdev = rtw_init_netdev(padapter); if (pnetdev == NULL) - goto handle_dualmac; + goto free_adapter; SET_NETDEV_DEV(pnetdev, dvobj_to_dev(dvobj)); padapter = rtw_netdev_priv(pnetdev); @@ -621,9 +618,6 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, free_hal_data: if (status != _SUCCESS) kfree(padapter->HalData); -handle_dualmac: - if (status != _SUCCESS) - rtw_handle_dualmac(padapter, 0); free_adapter: if (status != _SUCCESS) { if (pnetdev) -- cgit v1.2.3 From 383ff5492d491c9a19395b28d755f434f8536b95 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Tue, 27 May 2014 21:05:48 +0530 Subject: staging: rtl8188eu:Drop rtw_handle_dualmac() function calls in rtw_usb_if1_deinit() rtw_usb_if1_init() assign NULL to pbuddy_padapter variable which is not being used. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index aa93cd00c4ae..7b1c774cfc9e 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -654,7 +654,6 @@ static void rtw_usb_if1_deinit(struct adapter *if1) rtw_dev_unload(if1); DBG_88E("+r871xu_dev_remove, hw_init_completed=%d\n", if1->hw_init_completed); - rtw_handle_dualmac(if1, 0); rtw_free_drv_sw(if1); if (pnetdev) rtw_free_netdev(pnetdev); -- cgit v1.2.3 From 253e0114eb6c1b4f248d793ec5d678ea27dc03f6 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Tue, 27 May 2014 21:05:49 +0530 Subject: staging: rtl8188eu:Remove unused function rtw_handle_dualmac() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index 6c9e9a16b2e9..c1195a03eee3 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -1663,24 +1663,3 @@ void beacon_timing_control(struct adapter *padapter) } static struct adapter *pbuddy_padapter; - -int rtw_handle_dualmac(struct adapter *adapter, bool init) -{ - int status = _SUCCESS; - - if (init) { - if (pbuddy_padapter == NULL) { - pbuddy_padapter = adapter; - DBG_88E("%s(): pbuddy_padapter == NULL, Set pbuddy_padapter\n", __func__); - } else { - adapter->pbuddy_adapter = pbuddy_padapter; - pbuddy_padapter->pbuddy_adapter = adapter; - /* clear global value */ - pbuddy_padapter = NULL; - DBG_88E("%s(): pbuddy_padapter exist, Exchange Information\n", __func__); - } - } else { - pbuddy_padapter = NULL; - } - return status; -} -- cgit v1.2.3 From a05270ef632d7e6689f12c7e4b129f43a3120911 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Tue, 27 May 2014 21:05:50 +0530 Subject: staging: rtl8188eu:Remove unused variable struct adapter *pbuddy_padapter Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index c1195a03eee3..6fb8caa94abb 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -1661,5 +1661,3 @@ void beacon_timing_control(struct adapter *padapter) { rtw_hal_bcn_related_reg_setting(padapter); } - -static struct adapter *pbuddy_padapter; -- cgit v1.2.3 From 457c7b6a4d8c69fc6cf83c45ab1f7fbfa3d5a48a Mon Sep 17 00:00:00 2001 From: navin patidar Date: Tue, 27 May 2014 21:05:51 +0530 Subject: staging: rtl8188eu:Remove inline function rtw_netif_wake_queue() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/osdep_service.h | 5 ----- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h index 5889f58ed7d3..e5012f312880 100644 --- a/drivers/staging/rtl8188eu/include/osdep_service.h +++ b/drivers/staging/rtl8188eu/include/osdep_service.h @@ -119,11 +119,6 @@ static inline int rtw_netif_queue_stopped(struct net_device *pnetdev) netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 3)); } -static inline void rtw_netif_wake_queue(struct net_device *pnetdev) -{ - netif_tx_wake_all_queues(pnetdev); -} - static inline void rtw_netif_start_queue(struct net_device *pnetdev) { netif_tx_start_all_queues(pnetdev); diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index c1368b8c8a68..93f9f25c2c17 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -1084,7 +1084,7 @@ int _netdev_open(struct net_device *pnetdev) if (!rtw_netif_queue_stopped(pnetdev)) rtw_netif_start_queue(pnetdev); else - rtw_netif_wake_queue(pnetdev); + netif_tx_wake_all_queues(pnetdev); netdev_br_init(pnetdev); -- cgit v1.2.3 From 778869739199349df533b053beb4cf5fb02c3492 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Tue, 27 May 2014 21:05:52 +0530 Subject: staging: rtl8188eu:Remove inline function rtw_netif_start_queue() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/osdep_service.h | 5 ----- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h index e5012f312880..e82ba63e3a59 100644 --- a/drivers/staging/rtl8188eu/include/osdep_service.h +++ b/drivers/staging/rtl8188eu/include/osdep_service.h @@ -119,11 +119,6 @@ static inline int rtw_netif_queue_stopped(struct net_device *pnetdev) netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 3)); } -static inline void rtw_netif_start_queue(struct net_device *pnetdev) -{ - netif_tx_start_all_queues(pnetdev); -} - static inline void rtw_netif_stop_queue(struct net_device *pnetdev) { netif_tx_stop_all_queues(pnetdev); diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index 93f9f25c2c17..e6596d506224 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -1082,7 +1082,7 @@ int _netdev_open(struct net_device *pnetdev) rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv); if (!rtw_netif_queue_stopped(pnetdev)) - rtw_netif_start_queue(pnetdev); + netif_tx_start_all_queues(pnetdev); else netif_tx_wake_all_queues(pnetdev); -- cgit v1.2.3 From 945c097243b85001bd1c3c90a41e92bce623daf5 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Tue, 27 May 2014 21:05:53 +0530 Subject: staging: rtl8188eu:Remove inline function rtw_netif_stop_queue() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/osdep_service.h | 5 ----- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 4 ++-- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 4 ++-- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h index e82ba63e3a59..9d32bb2f8f2c 100644 --- a/drivers/staging/rtl8188eu/include/osdep_service.h +++ b/drivers/staging/rtl8188eu/include/osdep_service.h @@ -119,11 +119,6 @@ static inline int rtw_netif_queue_stopped(struct net_device *pnetdev) netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 3)); } -static inline void rtw_netif_stop_queue(struct net_device *pnetdev) -{ - netif_tx_stop_all_queues(pnetdev); -} - #ifndef BIT #define BIT(x) (1 << (x)) #endif diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index e6596d506224..0e0c32d46431 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -1096,7 +1096,7 @@ netdev_open_normal_process: netdev_open_error: padapter->bup = false; netif_carrier_off(pnetdev); - rtw_netif_stop_queue(pnetdev); + netif_tx_stop_all_queues(pnetdev); RT_TRACE(_module_os_intfs_c_, _drv_err_, ("-88eu_drv - dev_open, fail!\n")); DBG_88E("-88eu_drv - drv_open fail, bup =%d\n", padapter->bup); return -1; @@ -1219,7 +1219,7 @@ int netdev_close(struct net_device *pnetdev) /* s1. */ if (pnetdev) { if (!rtw_netif_queue_stopped(pnetdev)) - rtw_netif_stop_queue(pnetdev); + netif_tx_stop_all_queues(pnetdev); } /* s2. */ diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index 7b1c774cfc9e..7526b989dcbf 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -307,7 +307,7 @@ int rtw_hw_suspend(struct adapter *padapter) /* s1. */ if (pnetdev) { netif_carrier_off(pnetdev); - rtw_netif_stop_queue(pnetdev); + netif_tx_stop_all_queues(pnetdev); } /* s2. */ @@ -416,7 +416,7 @@ static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message) /* s1. */ if (pnetdev) { netif_carrier_off(pnetdev); - rtw_netif_stop_queue(pnetdev); + netif_tx_stop_all_queues(pnetdev); } /* s2. */ -- cgit v1.2.3 From 8a089b1f34b3bc04d92ff37303fac7410fc436a5 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Tue, 27 May 2014 21:05:54 +0530 Subject: staging: rtl8188eu:Remove unused inline function res_to_status() Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/osdep_service.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h index 9d32bb2f8f2c..b500991735fd 100644 --- a/drivers/staging/rtl8188eu/include/osdep_service.h +++ b/drivers/staging/rtl8188eu/include/osdep_service.h @@ -239,11 +239,6 @@ static inline void flush_signals_thread(void) flush_signals(current); } -static inline int res_to_status(int res) -{ - return res; -} - #define _RND(sz, r) ((((sz)+((r)-1))/(r))*(r)) #define RND4(x) (((x >> 2) + (((x & 3) == 0) ? 0 : 1)) << 2) -- cgit v1.2.3 From 47d5636026407c599bb3ce52977bd0f60625822b Mon Sep 17 00:00:00 2001 From: navin patidar Date: Tue, 27 May 2014 21:05:55 +0530 Subject: staging: rtl8188eu:Remove unused macros defined in osdep_service.h Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/osdep_service.h | 39 ----------------------- 1 file changed, 39 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h index b500991735fd..3859acd358a6 100644 --- a/drivers/staging/rtl8188eu/include/osdep_service.h +++ b/drivers/staging/rtl8188eu/include/osdep_service.h @@ -339,15 +339,7 @@ u64 rtw_division64(u64 x, u64 y); #define RTW_GET_BE24(a) ((((u32) (a)[0]) << 16) | (((u32) (a)[1]) << 8) | \ ((u32) (a)[2])) -#define RTW_PUT_BE24(a, val) \ - do { \ - (a)[0] = (u8) ((((u32) (val)) >> 16) & 0xff); \ - (a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff); \ - (a)[2] = (u8) (((u32) (val)) & 0xff); \ - } while (0) -#define RTW_GET_BE32(a) ((((u32) (a)[0]) << 24) | (((u32) (a)[1]) << 16) | \ - (((u32) (a)[2]) << 8) | ((u32) (a)[3])) #define RTW_PUT_BE32(a, val) \ do { \ (a)[0] = (u8) ((((u32) (val)) >> 24) & 0xff); \ @@ -356,37 +348,6 @@ u64 rtw_division64(u64 x, u64 y); (a)[3] = (u8) (((u32) (val)) & 0xff); \ } while (0) -#define RTW_GET_LE32(a) ((((u32) (a)[3]) << 24) | (((u32) (a)[2]) << 16) | \ - (((u32) (a)[1]) << 8) | ((u32) (a)[0])) -#define RTW_PUT_LE32(a, val) \ - do { \ - (a)[3] = (u8) ((((u32) (val)) >> 24) & 0xff); \ - (a)[2] = (u8) ((((u32) (val)) >> 16) & 0xff); \ - (a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff); \ - (a)[0] = (u8) (((u32) (val)) & 0xff); \ - } while (0) - -#define RTW_GET_BE64(a) ((((u64) (a)[0]) << 56) | (((u64) (a)[1]) << 48) | \ - (((u64) (a)[2]) << 40) | (((u64) (a)[3]) << 32) | \ - (((u64) (a)[4]) << 24) | (((u64) (a)[5]) << 16) | \ - (((u64) (a)[6]) << 8) | ((u64) (a)[7])) -#define RTW_PUT_BE64(a, val) \ - do { \ - (a)[0] = (u8) (((u64) (val)) >> 56); \ - (a)[1] = (u8) (((u64) (val)) >> 48); \ - (a)[2] = (u8) (((u64) (val)) >> 40); \ - (a)[3] = (u8) (((u64) (val)) >> 32); \ - (a)[4] = (u8) (((u64) (val)) >> 24); \ - (a)[5] = (u8) (((u64) (val)) >> 16); \ - (a)[6] = (u8) (((u64) (val)) >> 8); \ - (a)[7] = (u8) (((u64) (val)) & 0xff); \ - } while (0) - -#define RTW_GET_LE64(a) ((((u64) (a)[7]) << 56) | (((u64) (a)[6]) << 48) | \ - (((u64) (a)[5]) << 40) | (((u64) (a)[4]) << 32) | \ - (((u64) (a)[3]) << 24) | (((u64) (a)[2]) << 16) | \ - (((u64) (a)[1]) << 8) | ((u64) (a)[0])) - void rtw_buf_free(u8 **buf, u32 *buf_len); void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len); -- cgit v1.2.3 From 6371f2105a94121d3a061b04aaf0b8b392852bc5 Mon Sep 17 00:00:00 2001 From: Chaitanya Hazarey Date: Tue, 27 May 2014 15:35:09 -0700 Subject: Staging: rtl8192u: r8180_93cx6.c Added missing spaces Added spaces needed in the proper places to address: ERROR: space required after that ',' (ctx:VxV) ERROR: space required after that ';' (ctx:VxV) ERROR: space required after that close brace '}' ERROR: space required before the open brace '{' ERROR: space required before the open parenthesis '(' ERROR: spaces required around that '<' (ctx:VxV) ERROR: spaces required around that '=' (ctx:VxV) ERROR: spaces required around that '==' (ctx:VxV) Signed-off-by: Chaitanya Hazarey Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8180_93cx6.c | 46 +++++++++++++++++----------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/staging/rtl8192u/r8180_93cx6.c b/drivers/staging/rtl8192u/r8180_93cx6.c index cd06054fbedb..fb8a7a8ac64c 100644 --- a/drivers/staging/rtl8192u/r8180_93cx6.c +++ b/drivers/staging/rtl8192u/r8180_93cx6.c @@ -53,7 +53,7 @@ static void eprom_ck_cycle(struct net_device *dev) } -static void eprom_w(struct net_device *dev,short bit) +static void eprom_w(struct net_device *dev, short bit) { u8 cmdreg; @@ -86,7 +86,7 @@ static void eprom_send_bits_string(struct net_device *dev, short b[], int len) { int i; - for(i=0; iepromtype==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; + 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); @@ -137,7 +137,7 @@ u32 eprom_read(struct net_device *dev, u32 addr) //I'm unsure if it is necessary, but anyway shouldn't hurt eprom_w(dev, 0); - for(i=0;i<16;i++){ + 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); -- cgit v1.2.3 From 8b9c012a425b23c1df52cc1ddfec8259035c6754 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Tue, 27 May 2014 19:08:36 -0400 Subject: Staging: speakup: don't die if accessing sysfs without synth Setting a 'silent' parameter without a synth would crash the kernel. Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/speakup/synth.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c index 0b3549bd909d..172cf62b1aaf 100644 --- a/drivers/staging/speakup/synth.c +++ b/drivers/staging/speakup/synth.c @@ -212,6 +212,9 @@ void synth_start(void) void spk_do_flush(void) { + if (!synth) + return; + speakup_info.flushing = 1; synth_buffer_clear(); if (synth->alive) { -- cgit v1.2.3 From 9046db518e5d3da5371eb64bfe96203243b722c0 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 27 May 2014 21:05:17 +0100 Subject: staging: vt6656: WCTLbIsDuplicate fix PSCacheEntry base types and warnings Fix wFmSequence and wFrameCtl to __le16 Don't restrict to u8, if packet is a duplicate both bytes of __le16 will be the same. Fixes warnings wctl.c:66:9: warning: restricted __le16 degrades to integer wctl.c:71:56: warning: restricted __le16 degrades to integer wctl.c:73:49: warning: cast from restricted __le16 wctl.c:83:30: warning: incorrect type in assignment (different base types) wctl.c:83:30: expected unsigned short [unsigned] [usertype] wFmSequence wctl.c:83:30: got restricted __le16 [usertype] seq_ctrl wctl.c:85:28: warning: incorrect type in assignment (different base types) wctl.c:85:28: expected unsigned short [unsigned] [usertype] wFrameCtl wctl.c:85:28: got restricted __le16 [usertype] frame_control Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/device.h | 6 +++--- drivers/staging/vt6656/wctl.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index e5f84f5b377d..5b64ca7b62f3 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -340,9 +340,9 @@ typedef struct tagSPMKIDCandidateEvent { /* The receive duplicate detection cache entry */ typedef struct tagSCacheEntry{ - u16 wFmSequence; - u8 abyAddr2[ETH_ALEN]; - u16 wFrameCtl; + __le16 wFmSequence; + u8 abyAddr2[ETH_ALEN]; + __le16 wFrameCtl; } SCacheEntry, *PSCacheEntry; typedef struct tagSCache{ diff --git a/drivers/staging/vt6656/wctl.c b/drivers/staging/vt6656/wctl.c index 814342cd948e..efdc5d5d38ee 100644 --- a/drivers/staging/vt6656/wctl.c +++ b/drivers/staging/vt6656/wctl.c @@ -70,7 +70,7 @@ bool WCTLbIsDuplicate (PSCache pCache, struct ieee80211_hdr *pMACHeader) pCacheEntry = &(pCache->asCacheEntry[uIndex]); if ((pCacheEntry->wFmSequence == pMACHeader->seq_ctrl) && ether_addr_equal(pCacheEntry->abyAddr2, pMACHeader->addr2) && - (LOBYTE(pCacheEntry->wFrameCtl) == LOBYTE(pMACHeader->frame_control)) + (pCacheEntry->wFrameCtl == pMACHeader->frame_control) ) { /* Duplicate match */ return true; -- cgit v1.2.3 From 25d279d3b2fd8c6647cc4eac025be479248e8cf4 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 27 May 2014 21:05:18 +0100 Subject: staging: vt6656: IFRFbWriteEmbedded use ARRAY_SIZE Replace magic number with ARRAY_SIZE of pbyData Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c index d244dab498e0..912615685112 100644 --- a/drivers/staging/vt6656/rf.c +++ b/drivers/staging/vt6656/rf.c @@ -716,7 +716,7 @@ int IFRFbWriteEmbedded(struct vnt_private *pDevice, u32 dwData) pbyData[3] = (u8)(dwData >> 24); vnt_control_out(pDevice, - MESSAGE_TYPE_WRITE_IFRF, 0, 0, 4, pbyData); + MESSAGE_TYPE_WRITE_IFRF, 0, 0, ARRAY_SIZE(pbyData), pbyData); return true; } -- cgit v1.2.3 From d6df2bf2bf24fc8392e5c4a8e551713559279471 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 27 May 2014 21:05:19 +0100 Subject: staging: vt6656: IFRFbWriteEmbedded remove camel case Camel case changes pDevice -> priv dwData -> data pbyData -> reg_data Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rf.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c index 912615685112..a8e50f785e97 100644 --- a/drivers/staging/vt6656/rf.c +++ b/drivers/staging/vt6656/rf.c @@ -706,17 +706,17 @@ const u8 RFaby11aChannelIndex[200] = { * Return Value: true if succeeded; false if failed. * */ -int IFRFbWriteEmbedded(struct vnt_private *pDevice, u32 dwData) +int IFRFbWriteEmbedded(struct vnt_private *priv, u32 data) { - u8 pbyData[4]; + u8 reg_data[4]; - pbyData[0] = (u8)dwData; - pbyData[1] = (u8)(dwData >> 8); - pbyData[2] = (u8)(dwData >> 16); - pbyData[3] = (u8)(dwData >> 24); + reg_data[0] = (u8)data; + reg_data[1] = (u8)(data >> 8); + reg_data[2] = (u8)(data >> 16); + reg_data[3] = (u8)(data >> 24); - vnt_control_out(pDevice, - MESSAGE_TYPE_WRITE_IFRF, 0, 0, ARRAY_SIZE(pbyData), pbyData); + vnt_control_out(priv, MESSAGE_TYPE_WRITE_IFRF, + 0, 0, ARRAY_SIZE(reg_data), reg_data); return true; } -- cgit v1.2.3 From 32c48cb8ba86941631e9b05b87d7ef3834f52703 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 27 May 2014 21:05:20 +0100 Subject: staging: vt6656: rf.c: rename IFRFbWriteEmbedded to vnt_rf_write_embedded Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rf.c | 48 ++++++++++++++++++++++----------------------- drivers/staging/vt6656/rf.h | 2 +- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c index a8e50f785e97..b30a37315398 100644 --- a/drivers/staging/vt6656/rf.c +++ b/drivers/staging/vt6656/rf.c @@ -26,7 +26,7 @@ * Date: Feb. 19, 2004 * * Functions: - * IFRFbWriteEmbedded - Embedded write RF register via MAC + * vnt_rf_write_embedded - Embedded write RF register via MAC * * Revision History: * RF_VT3226: RobertYu:20051111, VT3226C0 and before @@ -706,7 +706,7 @@ const u8 RFaby11aChannelIndex[200] = { * Return Value: true if succeeded; false if failed. * */ -int IFRFbWriteEmbedded(struct vnt_private *priv, u32 data) +int vnt_rf_write_embedded(struct vnt_private *priv, u32 data) { u8 reg_data[4]; @@ -827,42 +827,42 @@ int RFbRawSetPower(struct vnt_private *priv, u8 power, u32 rate) if (priv->byCurPwr >= AL2230_PWR_IDX_LEN) return false; - ret &= IFRFbWriteEmbedded(priv, + ret &= vnt_rf_write_embedded(priv, al2230_power_table[priv->byCurPwr]); if (rate <= RATE_11M) - ret &= IFRFbWriteEmbedded(priv, 0x0001b400 + + ret &= vnt_rf_write_embedded(priv, 0x0001b400 + (BY_AL2230_REG_LEN << 3) + IFREGCTL_REGW); else - ret &= IFRFbWriteEmbedded(priv, 0x0005a400 + + ret &= vnt_rf_write_embedded(priv, 0x0005a400 + (BY_AL2230_REG_LEN << 3) + IFREGCTL_REGW); break; case RF_AL2230S: if (priv->byCurPwr >= AL2230_PWR_IDX_LEN) return false; - ret &= IFRFbWriteEmbedded(priv, + ret &= vnt_rf_write_embedded(priv, al2230_power_table[priv->byCurPwr]); if (rate <= RATE_11M) { - ret &= IFRFbWriteEmbedded(priv, 0x040c1400 + + ret &= vnt_rf_write_embedded(priv, 0x040c1400 + (BY_AL2230_REG_LEN << 3) + IFREGCTL_REGW); - ret &= IFRFbWriteEmbedded(priv, 0x00299b00 + + ret &= vnt_rf_write_embedded(priv, 0x00299b00 + (BY_AL2230_REG_LEN << 3) + IFREGCTL_REGW); } else { - ret &= IFRFbWriteEmbedded(priv, 0x0005a400 + + ret &= vnt_rf_write_embedded(priv, 0x0005a400 + (BY_AL2230_REG_LEN << 3) + IFREGCTL_REGW); - ret &= IFRFbWriteEmbedded(priv, 0x00099b00 + + ret &= vnt_rf_write_embedded(priv, 0x00099b00 + (BY_AL2230_REG_LEN << 3) + IFREGCTL_REGW); } break; case RF_AIROHA7230: if (rate <= RATE_11M) - ret &= IFRFbWriteEmbedded(priv, 0x111bb900 + + ret &= vnt_rf_write_embedded(priv, 0x111bb900 + (BY_AL7230_REG_LEN << 3)+IFREGCTL_REGW); else - ret &= IFRFbWriteEmbedded(priv, 0x221bb900 + + ret &= vnt_rf_write_embedded(priv, 0x221bb900 + (BY_AL7230_REG_LEN << 3)+IFREGCTL_REGW); if (priv->byCurPwr > AL7230_PWR_IDX_LEN) @@ -875,7 +875,7 @@ int RFbRawSetPower(struct vnt_private *priv, u8 power, u32 rate) power_setting = 0x080c0b00 | ((priv->byCurPwr) << 12) | (BY_AL7230_REG_LEN << 3) | IFREGCTL_REGW; - ret &= IFRFbWriteEmbedded(priv, power_setting); + ret &= vnt_rf_write_embedded(priv, power_setting); break; @@ -885,7 +885,7 @@ int RFbRawSetPower(struct vnt_private *priv, u8 power, u32 rate) power_setting = ((0x3f - priv->byCurPwr) << 20) | (0x17 << 8) | (BY_VT3226_REG_LEN << 3) | IFREGCTL_REGW; - ret &= IFRFbWriteEmbedded(priv, power_setting); + ret &= vnt_rf_write_embedded(priv, power_setting); break; case RF_VT3226D0: @@ -897,27 +897,27 @@ int RFbRawSetPower(struct vnt_private *priv, u8 power, u32 rate) (0xe07 << 8) | (BY_VT3226_REG_LEN << 3) | IFREGCTL_REGW; - ret &= IFRFbWriteEmbedded(priv, power_setting); - ret &= IFRFbWriteEmbedded(priv, 0x03c6a200 + + ret &= vnt_rf_write_embedded(priv, power_setting); + ret &= vnt_rf_write_embedded(priv, 0x03c6a200 + (BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW); if (priv->vnt_mgmt.eScanState != WMAC_NO_SCANNING) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "RFbRawSetPower> 11B mode uCurrChannel[%d]\n", priv->vnt_mgmt.uScanChannel); - ret &= IFRFbWriteEmbedded(priv, + ret &= vnt_rf_write_embedded(priv, vt3226d0_lo_current_table[priv-> vnt_mgmt.uScanChannel - 1]); } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "RFbRawSetPower> 11B mode uCurrChannel[%d]\n", priv->vnt_mgmt.uCurrChannel); - ret &= IFRFbWriteEmbedded(priv, + ret &= vnt_rf_write_embedded(priv, vt3226d0_lo_current_table[priv-> vnt_mgmt.uCurrChannel - 1]); } - ret &= IFRFbWriteEmbedded(priv, 0x015C0800 + + ret &= vnt_rf_write_embedded(priv, 0x015C0800 + (BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW); } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO @@ -927,12 +927,12 @@ int RFbRawSetPower(struct vnt_private *priv, u8 power, u32 rate) (0x7 << 8) | (BY_VT3226_REG_LEN << 3) | IFREGCTL_REGW; - ret &= IFRFbWriteEmbedded(priv, power_setting); - ret &= IFRFbWriteEmbedded(priv, 0x00C6A200 + + ret &= vnt_rf_write_embedded(priv, power_setting); + ret &= vnt_rf_write_embedded(priv, 0x00C6A200 + (BY_VT3226_REG_LEN << 3) + IFREGCTL_REGW); - ret &= IFRFbWriteEmbedded(priv, 0x016BC600 + + ret &= vnt_rf_write_embedded(priv, 0x016BC600 + (BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW); - ret &= IFRFbWriteEmbedded(priv, 0x00900800 + + ret &= vnt_rf_write_embedded(priv, 0x00900800 + (BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW); } break; @@ -945,7 +945,7 @@ int RFbRawSetPower(struct vnt_private *priv, u8 power, u32 rate) (0x27 << 8) | (BY_VT3342_REG_LEN << 3) | IFREGCTL_REGW; - ret &= IFRFbWriteEmbedded(priv, power_setting); + ret &= vnt_rf_write_embedded(priv, power_setting); break; default: diff --git a/drivers/staging/vt6656/rf.h b/drivers/staging/vt6656/rf.h index e9a01fee4127..70d5b82ad0c0 100644 --- a/drivers/staging/vt6656/rf.h +++ b/drivers/staging/vt6656/rf.h @@ -57,7 +57,7 @@ extern const u8 RFaby11aChannelIndex[200]; -int IFRFbWriteEmbedded(struct vnt_private *, u32 dwData); +int vnt_rf_write_embedded(struct vnt_private *, u32); int RFbSetPower(struct vnt_private *, u32 uRATE, u32 uCH); int RFbRawSetPower(struct vnt_private *, u8 byPwr, u32 uRATE); void RFvRSSITodBm(struct vnt_private *, u8 byCurrRSSI, long *pldBm); -- cgit v1.2.3 From 4f5290ea3c2ad00cde2b5ec19c678c28cdc65597 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 27 May 2014 21:05:21 +0100 Subject: staging: vt6656: rf.c/h rename RFbSetPower to vnt_rf_setpower Removing camel case Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rf.c | 2 +- drivers/staging/vt6656/rf.h | 2 +- drivers/staging/vt6656/rxtx.c | 4 ++-- drivers/staging/vt6656/wcmd.c | 3 ++- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c index b30a37315398..c1e0a795c398 100644 --- a/drivers/staging/vt6656/rf.c +++ b/drivers/staging/vt6656/rf.c @@ -734,7 +734,7 @@ int vnt_rf_write_embedded(struct vnt_private *priv, u32 data) * Return Value: true if succeeded; false if failed. * */ -int RFbSetPower(struct vnt_private *priv, u32 rate, u32 channel) +int vnt_rf_setpower(struct vnt_private *priv, u32 rate, u32 channel) { int ret = true; u8 power = priv->byCCKPwr; diff --git a/drivers/staging/vt6656/rf.h b/drivers/staging/vt6656/rf.h index 70d5b82ad0c0..e47b67d23f46 100644 --- a/drivers/staging/vt6656/rf.h +++ b/drivers/staging/vt6656/rf.h @@ -58,7 +58,7 @@ extern const u8 RFaby11aChannelIndex[200]; int vnt_rf_write_embedded(struct vnt_private *, u32); -int RFbSetPower(struct vnt_private *, u32 uRATE, u32 uCH); +int vnt_rf_setpower(struct vnt_private *, u32, u32); int RFbRawSetPower(struct vnt_private *, u8 byPwr, u32 uRATE); void RFvRSSITodBm(struct vnt_private *, u8 byCurrRSSI, long *pldBm); void RFbRFTableDownload(struct vnt_private *pDevice); diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index f11c2d3b22c2..704f4d3639be 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -1386,9 +1386,9 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, } if (pMgmt->eScanState != WMAC_NO_SCANNING) - RFbSetPower(pDevice, wCurrentRate, pDevice->byCurrentCh); + vnt_rf_setpower(pDevice, wCurrentRate, pDevice->byCurrentCh); else - RFbSetPower(pDevice, wCurrentRate, pMgmt->uCurrChannel); + vnt_rf_setpower(pDevice, wCurrentRate, pMgmt->uCurrChannel); pDevice->wCurrentRate = wCurrentRate; diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c index 9a166fbcfa1f..da72d4df6fca 100644 --- a/drivers/staging/vt6656/wcmd.c +++ b/drivers/staging/vt6656/wcmd.c @@ -835,7 +835,8 @@ void vRunCommand(struct work_struct *work) case WLAN_CMD_SETPOWER_START: - RFbSetPower(pDevice, pDevice->wCurrentRate, pMgmt->uCurrChannel); + vnt_rf_setpower(pDevice, pDevice->wCurrentRate, + pMgmt->uCurrChannel); break; -- cgit v1.2.3 From 8543bb9c21042e921ad6cff517d1c4f98b34ba51 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 27 May 2014 21:05:22 +0100 Subject: staging: vt6656: rf.c/h rename RFbRawSetPower to vnt_rf_set_txpower Remove raw and use txpower. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/card.c | 6 +++--- drivers/staging/vt6656/rf.c | 10 +++++----- drivers/staging/vt6656/rf.h | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index 5ad0a984eeb8..d662e5431dad 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -99,15 +99,15 @@ void CARDbSetMediaChannel(struct vnt_private *priv, u32 connection_channel) if (priv->byBBType == BB_TYPE_11A) { priv->byCurPwr = 0xff; - RFbRawSetPower(priv, + vnt_rf_set_txpower(priv, priv->abyOFDMAPwrTbl[connection_channel-15], RATE_54M); } else if (priv->byBBType == BB_TYPE_11G) { priv->byCurPwr = 0xff; - RFbRawSetPower(priv, + vnt_rf_set_txpower(priv, priv->abyOFDMPwrTbl[connection_channel-1], RATE_54M); } else { priv->byCurPwr = 0xff; - RFbRawSetPower(priv, + vnt_rf_set_txpower(priv, priv->abyCCKPwrTbl[connection_channel-1], RATE_1M); } diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c index c1e0a795c398..fd699609b242 100644 --- a/drivers/staging/vt6656/rf.c +++ b/drivers/staging/vt6656/rf.c @@ -763,7 +763,7 @@ int vnt_rf_setpower(struct vnt_private *priv, u32 rate, u32 channel) break; } - ret = RFbRawSetPower(priv, power, rate); + ret = vnt_rf_set_txpower(priv, power, rate); return ret; } @@ -808,7 +808,7 @@ static u8 vnt_rf_addpower(struct vnt_private *priv) * */ -int RFbRawSetPower(struct vnt_private *priv, u8 power, u32 rate) +int vnt_rf_set_txpower(struct vnt_private *priv, u8 power, u32 rate) { u32 power_setting = 0; int ret = true; @@ -903,14 +903,14 @@ int RFbRawSetPower(struct vnt_private *priv, u8 power, u32 rate) if (priv->vnt_mgmt.eScanState != WMAC_NO_SCANNING) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "RFbRawSetPower> 11B mode uCurrChannel[%d]\n", + "vnt_rf_set_txpower> 11B mode uCurrChannel[%d]\n", priv->vnt_mgmt.uScanChannel); ret &= vnt_rf_write_embedded(priv, vt3226d0_lo_current_table[priv-> vnt_mgmt.uScanChannel - 1]); } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "RFbRawSetPower> 11B mode uCurrChannel[%d]\n", + "vnt_rf_set_txpower> 11B mode uCurrChannel[%d]\n", priv->vnt_mgmt.uCurrChannel); ret &= vnt_rf_write_embedded(priv, vt3226d0_lo_current_table[priv-> @@ -921,7 +921,7 @@ int RFbRawSetPower(struct vnt_private *priv, u8 power, u32 rate) (BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW); } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO - "@@@@ RFbRawSetPower> 11G mode\n"); + "@@@@ vnt_rf_set_txpower> 11G mode\n"); power_setting = ((0x3f-priv->byCurPwr) << 20) | (0x7 << 8) | (BY_VT3226_REG_LEN << 3) | diff --git a/drivers/staging/vt6656/rf.h b/drivers/staging/vt6656/rf.h index e47b67d23f46..2040d5074a9a 100644 --- a/drivers/staging/vt6656/rf.h +++ b/drivers/staging/vt6656/rf.h @@ -59,7 +59,7 @@ extern const u8 RFaby11aChannelIndex[200]; int vnt_rf_write_embedded(struct vnt_private *, u32); int vnt_rf_setpower(struct vnt_private *, u32, u32); -int RFbRawSetPower(struct vnt_private *, u8 byPwr, u32 uRATE); +int vnt_rf_set_txpower(struct vnt_private *, u8, u32); void RFvRSSITodBm(struct vnt_private *, u8 byCurrRSSI, long *pldBm); void RFbRFTableDownload(struct vnt_private *pDevice); -- cgit v1.2.3 From 21bba58ae1ae90aae063edf07036296a3ed0e429 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 27 May 2014 21:05:23 +0100 Subject: staging: vt6656: rf.c/h rename RFvRSSITodBm to vnt_rf_rssi_to_dbm Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/bssdb.c | 9 +++++---- drivers/staging/vt6656/iwctl.c | 6 +++--- drivers/staging/vt6656/rf.c | 2 +- drivers/staging/vt6656/rf.h | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/staging/vt6656/bssdb.c b/drivers/staging/vt6656/bssdb.c index f53d3bf629be..8e9ce96442a0 100644 --- a/drivers/staging/vt6656/bssdb.c +++ b/drivers/staging/vt6656/bssdb.c @@ -457,8 +457,9 @@ int BSSbInsertToBSSList(struct vnt_private *pDevice, /* Monitor if RSSI is too strong. */ pBSSList->byRSSIStatCnt = 0; - RFvRSSITodBm(pDevice, (u8) (pRxPacket->uRSSI), - &pBSSList->ldBmMAX); + + vnt_rf_rssi_to_dbm(pDevice, (u8)pRxPacket->uRSSI, &pBSSList->ldBmMAX); + pBSSList->ldBmAverage[0] = pBSSList->ldBmMAX; pBSSList->ldBmAverRange = pBSSList->ldBmMAX; for (ii = 1; ii < RSSI_STAT_COUNT; ii++) @@ -578,7 +579,7 @@ int BSSbUpdateToBSSList(struct vnt_private *pDevice, } if (pRxPacket->uRSSI != 0) { - RFvRSSITodBm(pDevice, (u8) (pRxPacket->uRSSI), &ldBm); + vnt_rf_rssi_to_dbm(pDevice, (u8)pRxPacket->uRSSI, &ldBm); /* Monitor if RSSI is too strong. */ pBSSList->byRSSIStatCnt++; pBSSList->byRSSIStatCnt %= RSSI_STAT_COUNT; @@ -1417,7 +1418,7 @@ static void s_uCalculateLinkQual(struct vnt_private *pDevice) if (pDevice->bLinkPass != true) { pDevice->wstats.qual.qual = 0; } else { - RFvRSSITodBm(pDevice, (u8) (pDevice->uCurrRSSI), &ldBm); + vnt_rf_rssi_to_dbm(pDevice, (u8) (pDevice->uCurrRSSI), &ldBm); if (-ldBm < 50) RssiRatio = 4000; else if (-ldBm > 90) diff --git a/drivers/staging/vt6656/iwctl.c b/drivers/staging/vt6656/iwctl.c index 94b7fe8940ce..c43718d788c0 100644 --- a/drivers/staging/vt6656/iwctl.c +++ b/drivers/staging/vt6656/iwctl.c @@ -57,7 +57,7 @@ struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev) long ldBm; pDevice->wstats.status = pDevice->op_mode; - RFvRSSITodBm(pDevice, (u8)(pDevice->uCurrRSSI), &ldBm); + vnt_rf_rssi_to_dbm(pDevice, (u8)(pDevice->uCurrRSSI), &ldBm); pDevice->wstats.qual.level = ldBm; pDevice->wstats.qual.noise = 0; pDevice->wstats.qual.updated = 1; @@ -235,7 +235,7 @@ int iwctl_giwscan(struct net_device *dev, struct iw_request_info *info, // ADD quality memset(&iwe, 0, sizeof(iwe)); iwe.cmd = IWEVQUAL; - RFvRSSITodBm(pDevice, (u8)(pBSS->uRSSI), &ldBm); + vnt_rf_rssi_to_dbm(pDevice, (u8)(pBSS->uRSSI), &ldBm); iwe.u.qual.level = ldBm; iwe.u.qual.noise = 0; @@ -1399,7 +1399,7 @@ int iwctl_giwsens(struct net_device *dev, struct iw_request_info *info, DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSENS\n"); if (pDevice->bLinkPass == true) { - RFvRSSITodBm(pDevice, (u8)(pDevice->uCurrRSSI), &ldBm); + vnt_rf_rssi_to_dbm(pDevice, (u8)(pDevice->uCurrRSSI), &ldBm); wrq->value = ldBm; } else { wrq->value = 0; diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c index fd699609b242..4e1a28d70f2e 100644 --- a/drivers/staging/vt6656/rf.c +++ b/drivers/staging/vt6656/rf.c @@ -969,7 +969,7 @@ int vnt_rf_set_txpower(struct vnt_private *priv, u8 power, u32 rate) * Return Value: none * -*/ -void RFvRSSITodBm(struct vnt_private *priv, u8 rssi, long *dbm) +void vnt_rf_rssi_to_dbm(struct vnt_private *priv, u8 rssi, long *dbm) { u8 idx = (((rssi & 0xc0) >> 6) & 0x03); long b = (rssi & 0x3f); diff --git a/drivers/staging/vt6656/rf.h b/drivers/staging/vt6656/rf.h index 2040d5074a9a..bc0e9233a661 100644 --- a/drivers/staging/vt6656/rf.h +++ b/drivers/staging/vt6656/rf.h @@ -60,7 +60,7 @@ extern const u8 RFaby11aChannelIndex[200]; int vnt_rf_write_embedded(struct vnt_private *, u32); int vnt_rf_setpower(struct vnt_private *, u32, u32); int vnt_rf_set_txpower(struct vnt_private *, u8, u32); -void RFvRSSITodBm(struct vnt_private *, u8 byCurrRSSI, long *pldBm); +void vnt_rf_rssi_to_dbm(struct vnt_private *, u8, long *); void RFbRFTableDownload(struct vnt_private *pDevice); #endif /* __RF_H__ */ -- cgit v1.2.3 From c49d7550e5fa85f2b592594f4c1867550b80835a Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 27 May 2014 21:05:24 +0100 Subject: staging: vt6656: rf.c rename RFbRFTableDownload to vnt_rf_table_download. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 3 +-- drivers/staging/vt6656/rf.c | 2 +- drivers/staging/vt6656/rf.h | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index d96308f00d22..694e34a5ff90 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -1040,8 +1040,7 @@ int BBbVT3184Init(struct vnt_private *priv) vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x04, 0x7f); vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0x01); - RFbRFTableDownload(priv); - + vnt_rf_table_download(priv); /* Fix for TX USB resets from vendors driver */ vnt_control_in(priv, MESSAGE_TYPE_READ, USB_REG4, diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c index 4e1a28d70f2e..44201141bd63 100644 --- a/drivers/staging/vt6656/rf.c +++ b/drivers/staging/vt6656/rf.c @@ -992,7 +992,7 @@ void vnt_rf_rssi_to_dbm(struct vnt_private *priv, u8 rssi, long *dbm) *dbm = -1 * (a + b * 2); } -void RFbRFTableDownload(struct vnt_private *priv) +void vnt_rf_table_download(struct vnt_private *priv) { u16 length1 = 0, length2 = 0, length3 = 0; u8 *addr1 = NULL, *addr2 = NULL, *addr3 = NULL; diff --git a/drivers/staging/vt6656/rf.h b/drivers/staging/vt6656/rf.h index bc0e9233a661..cb331518568e 100644 --- a/drivers/staging/vt6656/rf.h +++ b/drivers/staging/vt6656/rf.h @@ -61,6 +61,6 @@ int vnt_rf_write_embedded(struct vnt_private *, u32); int vnt_rf_setpower(struct vnt_private *, u32, u32); int vnt_rf_set_txpower(struct vnt_private *, u8, u32); void vnt_rf_rssi_to_dbm(struct vnt_private *, u8, long *); -void RFbRFTableDownload(struct vnt_private *pDevice); +void vnt_rf_table_download(struct vnt_private *); #endif /* __RF_H__ */ -- cgit v1.2.3 From c85a81b22d1bc25a801beef522ed6fb07cb1fe18 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 27 May 2014 21:05:25 +0100 Subject: staging: vt6656: rf.c Fix typo error at3226* In commit 78a650dc19ba44e2e07768c6d3b2ff080cf9d245 there was a typo error abyVT3226_InitTable -> at3226_init_table abyVT3226D0_InitTable -> at3226d0_init_table Shoud be vt3226_init_table and vt3226d0_init_table Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c index 44201141bd63..d5098395e54f 100644 --- a/drivers/staging/vt6656/rf.c +++ b/drivers/staging/vt6656/rf.c @@ -354,7 +354,7 @@ static u8 al7230_channel_table2[CB_MAX_CHANNEL][3] = { }; ///{{RobertYu:20051111 -static u8 at3226_init_table[CB_VT3226_INIT_SEQ][3] = { +static u8 vt3226_init_table[CB_VT3226_INIT_SEQ][3] = { {0x03, 0xFF, 0x80}, {0x02, 0x82, 0xA1}, {0x03, 0xC6, 0xA2}, @@ -368,7 +368,7 @@ static u8 at3226_init_table[CB_VT3226_INIT_SEQ][3] = { {0x02, 0x00, 0x2A} }; -static u8 at3226d0_init_table[CB_VT3226_INIT_SEQ][3] = { +static u8 vt3226d0_init_table[CB_VT3226_INIT_SEQ][3] = { {0x03, 0xFF, 0x80}, {0x03, 0x02, 0x21}, //RobertYu:20060327 {0x03, 0xC6, 0xA2}, @@ -1021,7 +1021,7 @@ void vnt_rf_table_download(struct vnt_private *priv) length1 = CB_VT3226_INIT_SEQ * 3; length2 = CB_MAX_CHANNEL_24G * 3; length3 = CB_MAX_CHANNEL_24G * 3; - addr1 = &at3226_init_table[0][0]; + addr1 = &vt3226_init_table[0][0]; addr2 = &vt3226_channel_table0[0][0]; addr3 = &vt3226_channel_table1[0][0]; break; @@ -1029,7 +1029,7 @@ void vnt_rf_table_download(struct vnt_private *priv) length1 = CB_VT3226_INIT_SEQ * 3; length2 = CB_MAX_CHANNEL_24G * 3; length3 = CB_MAX_CHANNEL_24G * 3; - addr1 = &at3226d0_init_table[0][0]; + addr1 = &vt3226d0_init_table[0][0]; addr2 = &vt3226_channel_table0[0][0]; addr3 = &vt3226_channel_table1[0][0]; break; -- cgit v1.2.3 From 5dda2528ef830b0cb61a43164dfbada9e658cef9 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 27 May 2014 21:05:26 +0100 Subject: staging: vt6656: rf.c replace DBG_PRT debug messages replace with dev_dbg Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rf.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c index d5098395e54f..3f54ae3cfb4e 100644 --- a/drivers/staging/vt6656/rf.c +++ b/drivers/staging/vt6656/rf.c @@ -41,8 +41,6 @@ #include "usbpipe.h" #include "datarate.h" -static int msglevel =MSG_LEVEL_INFO; -//static int msglevel =MSG_LEVEL_DEBUG; #define BY_AL2230_REG_LEN 23 //24bit #define CB_AL2230_INIT_SEQ 15 #define AL2230_PWR_IDX_LEN 64 @@ -902,14 +900,14 @@ int vnt_rf_set_txpower(struct vnt_private *priv, u8 power, u32 rate) (BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW); if (priv->vnt_mgmt.eScanState != WMAC_NO_SCANNING) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + dev_dbg(&priv->usb->dev, "vnt_rf_set_txpower> 11B mode uCurrChannel[%d]\n", priv->vnt_mgmt.uScanChannel); ret &= vnt_rf_write_embedded(priv, vt3226d0_lo_current_table[priv-> vnt_mgmt.uScanChannel - 1]); } else { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + dev_dbg(&priv->usb->dev, "vnt_rf_set_txpower> 11B mode uCurrChannel[%d]\n", priv->vnt_mgmt.uCurrChannel); ret &= vnt_rf_write_embedded(priv, @@ -920,7 +918,7 @@ int vnt_rf_set_txpower(struct vnt_private *priv, u8 power, u32 rate) ret &= vnt_rf_write_embedded(priv, 0x015C0800 + (BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW); } else { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + dev_dbg(&priv->usb->dev, "@@@@ vnt_rf_set_txpower> 11G mode\n"); power_setting = ((0x3f-priv->byCurPwr) << 20) | -- cgit v1.2.3 From 0c4df9c9697887c32db41fe6cdff847f92bce244 Mon Sep 17 00:00:00 2001 From: Konrad Zapalowicz Date: Tue, 27 May 2014 17:42:25 +0200 Subject: staging: vt6655: refactor iwctl_giwaplist() to avoid -Wframe-larger-than warn. This commit refactors the iwctl_giwaplist() function so that the sparse warning "the frame size of 1292 bytes is larger than 1024 bytes [-Wframe-larger-than=]" is no more. The root cause of this warning were two arrays allocated on the stack and this commit changes this - these arrays are now kmalloc'ed. As a result the function is refactored and hopefully stil working the same. I were not able to test these changes so at least the carefull review is more than welcomed. Note that my changes has broadened the set of error codes that this function can return. The new error code is ENOMEM. Luckily, this is no issue. Signed-off-by: Konrad Zapalowicz Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/iwctl.c | 72 ++++++++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 24 deletions(-) diff --git a/drivers/staging/vt6655/iwctl.c b/drivers/staging/vt6655/iwctl.c index eb03e68cc04d..ae2b87f177fb 100644 --- a/drivers/staging/vt6655/iwctl.c +++ b/drivers/staging/vt6655/iwctl.c @@ -714,42 +714,66 @@ int iwctl_giwaplist(struct net_device *dev, char *extra) { int ii, jj, rc = 0; - struct sockaddr sock[IW_MAX_AP]; - struct iw_quality qual[IW_MAX_AP]; + struct sockaddr *sock = NULL; + struct sockaddr *s = NULL; + struct iw_quality *qual = NULL; + struct iw_quality *q = NULL; + PKnownBSS pBSS = NULL; + PSDevice pDevice = (PSDevice)netdev_priv(dev); PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAPLIST \n"); - // Only super-user can see AP list + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAPLIST\n"); if (!capable(CAP_NET_ADMIN)) { rc = -EPERM; - return rc; + goto exit; } - if (wrq->pointer) { - PKnownBSS pBSS = &(pMgmt->sBSSList[0]); + if (!wrq->pointer) + goto exit; - for (ii = 0, jj = 0; ii < MAX_BSS_NUM; ii++) { - pBSS = &(pMgmt->sBSSList[ii]); - if (!pBSS->bActive) - continue; - if (jj >= IW_MAX_AP) - break; - memcpy(sock[jj].sa_data, pBSS->abyBSSID, 6); - sock[jj].sa_family = ARPHRD_ETHER; - qual[jj].level = pBSS->uRSSI; - qual[jj].qual = qual[jj].noise = 0; - qual[jj].updated = 2; - jj++; - } + sock = kmalloc_array(IW_MAX_AP, sizeof(struct sockaddr), GFP_KERNEL); + if (!sock) { + rc = -ENOMEM; + goto exit; + } + + qual = kmalloc_array(IW_MAX_AP, sizeof(struct iw_quality), GFP_KERNEL); + if (!qual) { + rc = -ENOMEM; + goto exit; + } + + for (ii = 0, jj = 0; ii < MAX_BSS_NUM; ii++) { + pBSS = &(pMgmt->sBSSList[ii]); + + if (!pBSS->bActive) + continue; + if (jj >= IW_MAX_AP) + break; + + s = &sock[jj]; + q = &qual[jj]; - wrq->flags = 1; // Should be define'd - wrq->length = jj; - memcpy(extra, sock, sizeof(struct sockaddr)*jj); - memcpy(extra + sizeof(struct sockaddr)*jj, qual, sizeof(struct iw_quality)*jj); + memcpy(s->sa_data, pBSS->abyBSSID, 6); + s->sa_family = ARPHRD_ETHER; + q->level = pBSS->uRSSI; + q->qual = 0; + q->noise = 0; + q->updated = 2; + jj++; } + wrq->flags = 1; /* Should be define'd */ + wrq->length = jj; + memcpy(extra, sock, sizeof(struct sockaddr) * jj); + memcpy(extra + sizeof(struct sockaddr) * jj, + qual, + sizeof(struct iw_quality) * jj); +exit: + kfree(sock); + kfree(qual); return rc; } -- cgit v1.2.3 From 81aa143bae1595e478e7c20644fcd236936bfeaa Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 28 May 2014 14:15:37 -0700 Subject: Revert "staging: rtl8192u: rename CONFIG_IEEE80211_CRYPT_TKIP" This reverts commit f8cc81f845456c126fd0ab4d8379a8c47f5ca743. It breaks the build in linux-next. Reported-by: Stephen Rothwell Cc: Paul Bolle Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 2 +- drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index 800206755edd..d9a8299c48eb 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -352,7 +352,7 @@ ieee80211_rx_frame_decrypt(struct ieee80211_device *ieee, struct sk_buff *skb, hdr = (struct ieee80211_hdr_4addr *) skb->data; hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); -#ifdef CONFIG_LIB80211_CRYPT_TKIP +#ifdef CONFIG_IEEE80211_CRYPT_TKIP if (ieee->tkip_countermeasures && strcmp(crypt->ops->name, "TKIP") == 0) { if (net_ratelimit()) { diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c index 0bb474a193e6..029a97651797 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c @@ -191,7 +191,7 @@ int ieee80211_encrypt_fragment( printk("=========>%s(), crypt is null\n", __func__); return -1; } -#ifdef CONFIG_LIB80211_CRYPT_TKIP +#ifdef CONFIG_IEEE80211_CRYPT_TKIP struct ieee80211_hdr *header; if (ieee->tkip_countermeasures && -- cgit v1.2.3 From 6015bd55382e3aa93fa0d597fffd8a5a51b0f51a Mon Sep 17 00:00:00 2001 From: Marcin Kostrzewa Date: Tue, 27 May 2014 14:38:58 +0000 Subject: Staging: comedi: addi-data: clean up formatting of the else statement Signed-off-by: Marcin Kostrzewa Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c index 20e89b0bdc4d..e82c3fcd048b 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c @@ -102,11 +102,7 @@ static int apci3501_write_insn_timer(struct comedi_device *dev, ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x1UL; /* Enable the Watchdog */ outl(ul_Command1, dev->iobase + APCI3501_TIMER_CTRL_REG); - } - - else if (data[1] == 0) /* Stop The Watchdog */ - { - /* Stop The Watchdog */ + } else if (data[1] == 0) { /* Stop The Watchdog */ ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG); ul_Command1 = ul_Command1 & 0xFFFFF9FEUL; outl(0x0, dev->iobase + APCI3501_TIMER_CTRL_REG); -- cgit v1.2.3 From c2803ad11005a7f305438ba1501f33e13e04b479 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 28 May 2014 10:22:22 -0700 Subject: staging: comedi: TODO: remove item "reserve major number" The major number for comedi has been listed in Documentation/devices.txt since kernel 2.1.88. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/TODO | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/comedi/TODO b/drivers/staging/comedi/TODO index fa8da9aada30..b68fbdb5eebf 100644 --- a/drivers/staging/comedi/TODO +++ b/drivers/staging/comedi/TODO @@ -3,7 +3,6 @@ TODO: - Lindent - remove all wrappers - audit userspace interface - - reserve major number - cleanup the individual comedi drivers as well Please send patches to Greg Kroah-Hartman and -- cgit v1.2.3 From 7158fddc165c23c82ac396b3db5bb10ecfaf646f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:12:39 -0700 Subject: staging: comedi: adl_pci9111: use comedi_fc helpers to validate timer args Use the comedi_fc helper, cfc_check_trigger_arg_is(), to validate the cmd->convert_arg for the convert_src TRIG_TIMER. Pass the local variable to i8253_cascade_ns_to_timer() instead of the cmd argument. This value is modified by that function to return the actual time (in nanoseconds) that the timer will be programmed with based on the calculated divisors. The cfc_check_trigger_arg_is() helper will then validate that the cmd->convert_arg is that value and modify it if not. Also use cfc_check_trigger_arg_is() to validate that the cmd->scan_begin_arg is the calculate value and modify it if not. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9111.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index c84930ca8040..bb1d56e887ba 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -418,9 +418,8 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev, i8253_cascade_ns_to_timer(I8254_OSC_BASE_2MHZ, &dev_private->div1, &dev_private->div2, - &cmd->convert_arg, cmd->flags); - if (cmd->convert_arg != arg) - err |= -EINVAL; + &arg, cmd->flags); + err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg); } /* @@ -433,10 +432,7 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev, if (arg < cmd->scan_begin_arg) arg *= (cmd->scan_begin_arg / arg); - if (cmd->scan_begin_arg != arg) { - cmd->scan_begin_arg = arg; - err |= -EINVAL; - } + err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg); } if (err) -- cgit v1.2.3 From 474cd8a1fe3ff251cd645a8faf9c2815b82c127c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:12:40 -0700 Subject: staging: comedi: adv_pci1710: use comedi_fc helpers to validate timer args Use the comedi_fc helper, cfc_check_trigger_arg_is(), to validate the cmd->convert_arg for the convert_src TRIG_TIMER. Pass the local variable to i8253_cascade_ns_to_timer() instead of the cmd argument. This value is modified by that function to return the actual time (in nanoseconds) that the timer will be programmed with based on the calculated divisors. The cfc_check_trigger_arg_is() helper will then validate that the cmd->convert_arg is that value and modify it if not. The minimum validation is not needed. That was already handled in Step 3. All the arguments are unsigned int, change the local variable to an unsigned int and rename it for aesthetic reasons.. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index a459bdf7e352..602b7a1e40e6 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -971,7 +971,7 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev, const struct boardtype *this_board = comedi_board(dev); struct pci1710_private *devpriv = dev->private; int err = 0; - int tmp; + unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -1019,15 +1019,12 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ if (cmd->convert_src == TRIG_TIMER) { - tmp = cmd->convert_arg; + arg = cmd->convert_arg; i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, &devpriv->next_divisor1, &devpriv->next_divisor2, - &cmd->convert_arg, cmd->flags); - if (cmd->convert_arg < this_board->ai_ns_min) - cmd->convert_arg = this_board->ai_ns_min; - if (tmp != cmd->convert_arg) - err++; + &arg, cmd->flags); + err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg); } if (err) -- cgit v1.2.3 From 1406057d365fc11a0a39e425b12b4007e27f9f3f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:12:41 -0700 Subject: staging: comedi: dt3000: use comedi_fc helpers to validate timer args Use the comedi_fc helper, cfc_check_trigger_arg_is(), to validate the cmd->scan_begin_arg for the scan_begin_src TRIG_TIMER. Pass the local variable to dt2k_ns_to_timer() instead of the cmd argument. This value is modified by that function to return the actual time (in nanoseconds) that the timer will be programmed with based on the calculated divisor. The cfc_check_trigger_arg_is() helper will then validate that the cmd->cscan_begin_arg is that value and modify it if not. Also use cfc_check_trigger_arg_is() to validate the cmd->convert_arg using the same logic. Use cfc_check_trigger_arg_min() to do validate the cmd->scan_begin_arg when the convert_src and scan_begin_src are both TRIG_TIMER. All the arguments are unsigned int, change the local variable to an unsigned int and rename it for aesthetic reasons. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt3000.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/staging/comedi/drivers/dt3000.c index abd999f95f70..4ab4de005924 100644 --- a/drivers/staging/comedi/drivers/dt3000.c +++ b/drivers/staging/comedi/drivers/dt3000.c @@ -416,7 +416,7 @@ static int dt3k_ai_cmdtest(struct comedi_device *dev, { const struct dt3k_boardtype *this_board = comedi_board(dev); int err = 0; - int tmp; + unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -466,25 +466,20 @@ static int dt3k_ai_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ if (cmd->scan_begin_src == TRIG_TIMER) { - tmp = cmd->scan_begin_arg; - dt3k_ns_to_timer(100, &cmd->scan_begin_arg, - cmd->flags & TRIG_ROUND_MASK); - if (tmp != cmd->scan_begin_arg) - err++; + arg = cmd->scan_begin_arg; + dt3k_ns_to_timer(100, &arg, cmd->flags & TRIG_ROUND_MASK); + err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg); } if (cmd->convert_src == TRIG_TIMER) { - tmp = cmd->convert_arg; - dt3k_ns_to_timer(50, &cmd->convert_arg, - cmd->flags & TRIG_ROUND_MASK); - if (tmp != cmd->convert_arg) - err++; - if (cmd->scan_begin_src == TRIG_TIMER && - cmd->scan_begin_arg < - cmd->convert_arg * cmd->scan_end_arg) { - cmd->scan_begin_arg = - cmd->convert_arg * cmd->scan_end_arg; - err++; + arg = cmd->convert_arg; + dt3k_ns_to_timer(50, &arg, cmd->flags & TRIG_ROUND_MASK); + err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg); + + if (cmd->scan_begin_src == TRIG_TIMER) { + arg = cmd->convert_arg * cmd->scan_end_arg; + err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, + arg); } } -- cgit v1.2.3 From 9c1efda8388fd9f6f99df0053eb25996a39fba89 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:12:42 -0700 Subject: staging: comedi: adl_pci9118: use comedi_fc helpers to validate timer args Use the comedi_fc helper, cfc_check_trigger_arg_is(), to validate the arguments for the TRIG_TIMER command sources. Pass the local variable to i8253_cascade_ns_to_timer() instead of the cmd argument. This value is modified by that function to return the actual time (in nanoseconds) that the timer will be programmed with based on the calculated divisors. The cfc_check_trigger_arg_is() helper will then validate that the argument is that value and modify it if not. Use cfc_check_trigger_arg_min() to do validate the cmd->scan_begin_arg when the scan_begin_src is TRIG_TIMER and the convert_src is TRIG_NOW. All the arguments are unsigned int, change the local variable to an unsigned int and rename it for aesthetic reasons. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 45 ++++++++++------------------ 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 89ed2d6dea0a..59a65cbc6db9 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -1120,7 +1120,7 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev, struct pci9118_private *devpriv = dev->private; int err = 0; unsigned int flags; - int tmp; + unsigned int arg; unsigned int divisor1 = 0, divisor2 = 0; /* Step 1 : check if triggers are trivially valid */ @@ -1237,45 +1237,30 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ if (cmd->scan_begin_src == TRIG_TIMER) { - tmp = cmd->scan_begin_arg; + arg = cmd->scan_begin_arg; i8253_cascade_ns_to_timer(I8254_OSC_BASE_4MHZ, &divisor1, &divisor2, - &cmd->scan_begin_arg, cmd->flags); - if (cmd->scan_begin_arg < this_board->ai_ns_min) - cmd->scan_begin_arg = this_board->ai_ns_min; - if (tmp != cmd->scan_begin_arg) - err++; + &arg, cmd->flags); + err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg); } if (cmd->convert_src & (TRIG_TIMER | TRIG_NOW)) { - tmp = cmd->convert_arg; + arg = cmd->convert_arg; i8253_cascade_ns_to_timer(I8254_OSC_BASE_4MHZ, &divisor1, &divisor2, - &cmd->convert_arg, cmd->flags); - if (cmd->convert_arg < this_board->ai_ns_min) - cmd->convert_arg = this_board->ai_ns_min; - if (tmp != cmd->convert_arg) - err++; - if (cmd->scan_begin_src == TRIG_TIMER - && cmd->convert_src == TRIG_NOW) { + &arg, cmd->flags); + err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg); + + if (cmd->scan_begin_src == TRIG_TIMER && + cmd->convert_src == TRIG_NOW) { if (cmd->convert_arg == 0) { - if (cmd->scan_begin_arg < - this_board->ai_ns_min * - (cmd->scan_end_arg + 2)) { - cmd->scan_begin_arg = - this_board->ai_ns_min * - (cmd->scan_end_arg + 2); - err++; - } + arg = this_board->ai_ns_min * + (cmd->scan_end_arg + 2); } else { - if (cmd->scan_begin_arg < - cmd->convert_arg * cmd->chanlist_len) { - cmd->scan_begin_arg = - cmd->convert_arg * - cmd->chanlist_len; - err++; - } + arg = cmd->convert_arg * cmd->chanlist_len; } + err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, + arg); } } -- cgit v1.2.3 From 815bb5b5c9778a9ee019475911db02cc395e676a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:12:43 -0700 Subject: staging: comedi: cb_pcidas: use comedi_fc helpers to validate timer args Use the comedi_fc helper cfc_check_trigger_arg_is() to validate the trigger arguments when the source is TRIG_TIMER. All the arguments are unsigned int, change the local variable to an unsigned int and rename it for aesthetic reasons. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index 0df55dd0fb53..7b029596b11f 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -837,7 +837,7 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev, const struct cb_pcidas_board *thisboard = comedi_board(dev); struct cb_pcidas_private *devpriv = dev->private; int err = 0; - int tmp; + unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -912,22 +912,20 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ if (cmd->scan_begin_src == TRIG_TIMER) { - tmp = cmd->scan_begin_arg; + arg = cmd->scan_begin_arg; i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, &devpriv->divisor1, &devpriv->divisor2, - &cmd->scan_begin_arg, cmd->flags); - if (tmp != cmd->scan_begin_arg) - err++; + &arg, cmd->flags); + err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg); } if (cmd->convert_src == TRIG_TIMER) { - tmp = cmd->convert_arg; + arg = cmd->convert_arg; i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, &devpriv->divisor1, &devpriv->divisor2, - &cmd->convert_arg, cmd->flags); - if (tmp != cmd->convert_arg) - err++; + &arg, cmd->flags); + err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg); } if (err) @@ -1064,7 +1062,7 @@ static int cb_pcidas_ao_cmdtest(struct comedi_device *dev, const struct cb_pcidas_board *thisboard = comedi_board(dev); struct cb_pcidas_private *devpriv = dev->private; int err = 0; - int tmp; + unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -1107,13 +1105,12 @@ static int cb_pcidas_ao_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ if (cmd->scan_begin_src == TRIG_TIMER) { - tmp = cmd->scan_begin_arg; + arg = cmd->scan_begin_arg; i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, &devpriv->ao_divisor1, &devpriv->ao_divisor2, - &cmd->scan_begin_arg, cmd->flags); - if (tmp != cmd->scan_begin_arg) - err++; + &arg, cmd->flags); + err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg); } if (err) -- cgit v1.2.3 From b2ef4813d0a1b012622f14f71b320c8c7a9e6bdb Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:12:44 -0700 Subject: staging: comedi: comedi_test: use comedi_fc helpers to validate timer args Use the comedi_fc helper cfc_check_trigger_arg_is() to validate the trigger arguments when the source is TRIG_TIMER. All the arguments are unsigned int, change the local variable to an unsigned int and rename it for aesthetic reasons. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_test.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c index 9896a16fe84b..67a09aa6b721 100644 --- a/drivers/staging/comedi/drivers/comedi_test.c +++ b/drivers/staging/comedi/drivers/comedi_test.c @@ -226,7 +226,7 @@ static int waveform_ai_cmdtest(struct comedi_device *dev, struct comedi_cmd *cmd) { int err = 0; - int tmp; + unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -278,22 +278,18 @@ static int waveform_ai_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ if (cmd->scan_begin_src == TRIG_TIMER) { - tmp = cmd->scan_begin_arg; + arg = cmd->scan_begin_arg; /* round to nearest microsec */ - cmd->scan_begin_arg = - nano_per_micro * ((tmp + - (nano_per_micro / 2)) / nano_per_micro); - if (tmp != cmd->scan_begin_arg) - err++; + arg = nano_per_micro * + ((arg + (nano_per_micro / 2)) / nano_per_micro); + err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg); } if (cmd->convert_src == TRIG_TIMER) { - tmp = cmd->convert_arg; + arg = cmd->convert_arg; /* round to nearest microsec */ - cmd->convert_arg = - nano_per_micro * ((tmp + - (nano_per_micro / 2)) / nano_per_micro); - if (tmp != cmd->convert_arg) - err++; + arg = nano_per_micro * + ((arg + (nano_per_micro / 2)) / nano_per_micro); + err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg); } if (err) -- cgit v1.2.3 From 0e21721125e6fe9677ed9c2eb07057ae6e466fcf Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:12:45 -0700 Subject: staging: comedi: das16: use comedi_fc helpers to validate timer args Use the comedi_fc helper cfc_check_trigger_arg_is() to validate the trigger arguments when the source is TRIG_TIMER. Tidy up the local varaibles in the function. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index a18c6b696ecf..f40d42298a11 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -633,23 +633,23 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, { const struct das16_board *board = comedi_board(dev); struct das16_private_struct *devpriv = dev->private; - int err = 0, tmp; - int mask; + int err = 0; + unsigned int trig_mask; + unsigned int arg; /* Step 1 : check if triggers are trivially valid */ err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW); - mask = TRIG_FOLLOW; + trig_mask = TRIG_FOLLOW; if (devpriv->can_burst) - mask |= TRIG_TIMER | TRIG_EXT; - err |= cfc_check_trigger_src(&cmd->scan_begin_src, mask); + trig_mask |= TRIG_TIMER | TRIG_EXT; + err |= cfc_check_trigger_src(&cmd->scan_begin_src, trig_mask); - tmp = cmd->convert_src; - mask = TRIG_TIMER | TRIG_EXT; + trig_mask = TRIG_TIMER | TRIG_EXT; if (devpriv->can_burst) - mask |= TRIG_NOW; - err |= cfc_check_trigger_src(&cmd->convert_src, mask); + trig_mask |= TRIG_NOW; + err |= cfc_check_trigger_src(&cmd->convert_src, trig_mask); err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT); err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE); @@ -700,22 +700,20 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, /* step 4: fix up arguments */ if (cmd->scan_begin_src == TRIG_TIMER) { - unsigned int tmp = cmd->scan_begin_arg; - /* set divisors, correct timing arguments */ + arg = cmd->scan_begin_arg; i8253_cascade_ns_to_timer(devpriv->clockbase, &devpriv->divisor1, &devpriv->divisor2, - &cmd->scan_begin_arg, cmd->flags); - err += (tmp != cmd->scan_begin_arg); + &arg, cmd->flags); + err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg); } if (cmd->convert_src == TRIG_TIMER) { - unsigned int tmp = cmd->convert_arg; - /* set divisors, correct timing arguments */ + arg = cmd->convert_arg; i8253_cascade_ns_to_timer(devpriv->clockbase, &devpriv->divisor1, &devpriv->divisor2, - &cmd->convert_arg, cmd->flags); - err += (tmp != cmd->convert_arg); + &arg, cmd->flags); + err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg); } if (err) return 4; -- cgit v1.2.3 From e9ace43cbff7894f63a4f5a9d8c0f7d20545add4 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:12:46 -0700 Subject: staging: comedi: das16m1: use comedi_fc helpers to validate timer args Use the comedi_fc helper cfc_check_trigger_arg_is() to validate the trigger arguments when the source is TRIG_TIMER. For aesthetics, rename the local variable 'tmp' to 'arg'. Also, change the 'err' variable to the correct type. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index c97444991d89..ec039fbff0f9 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -182,7 +182,8 @@ static int das16m1_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { struct das16m1_private_struct *devpriv = dev->private; - unsigned int err = 0, tmp; + int err = 0; + unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -231,14 +232,12 @@ static int das16m1_cmd_test(struct comedi_device *dev, /* step 4: fix up arguments */ if (cmd->convert_src == TRIG_TIMER) { - tmp = cmd->convert_arg; - /* calculate counter values that give desired timing */ + arg = cmd->convert_arg; i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, &devpriv->divisor1, &devpriv->divisor2, - &cmd->convert_arg, cmd->flags); - if (tmp != cmd->convert_arg) - err++; + &arg, cmd->flags); + err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg); } if (err) -- cgit v1.2.3 From 58245cc968b1e44bbc3055a8fac25ed3449914a9 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:12:47 -0700 Subject: staging: comedi: das800: use comedi_fc helpers to validate timer args Use the comedi_fc helper cfc_check_trigger_arg_is() to validate the trigger arguments when the source is TRIG_TIMER. All the arguments are unsigned int, change the local variable to an unsigned int and rename it for aesthetic reasons. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das800.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c index 615ae3f1c6cc..38f6a6d9e1dc 100644 --- a/drivers/staging/comedi/drivers/das800.c +++ b/drivers/staging/comedi/drivers/das800.c @@ -331,6 +331,7 @@ static int das800_ai_do_cmdtest(struct comedi_device *dev, const struct das800_board *thisboard = comedi_board(dev); struct das800_private *devpriv = dev->private; int err = 0; + unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -376,15 +377,12 @@ static int das800_ai_do_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ if (cmd->convert_src == TRIG_TIMER) { - int tmp = cmd->convert_arg; - - /* calculate counter values that give desired timing */ + arg = cmd->convert_arg; i8253_cascade_ns_to_timer(I8254_OSC_BASE_1MHZ, &devpriv->divisor1, &devpriv->divisor2, - &cmd->convert_arg, cmd->flags); - if (tmp != cmd->convert_arg) - err++; + &arg, cmd->flags); + err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg); } if (err) -- cgit v1.2.3 From d579392a3fab9acd63123f4167abd822600777a4 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:12:48 -0700 Subject: staging: comedi: dmm32at: use comedi_fc helpers to validate timer args Use the comedi_fc helper cfc_check_trigger_arg_is() to validate the trigger arguments when the source is TRIG_TIMER. Use cfc_check_trigger_arg_min() to vaidate the scan_begin_arg when the scan_begin_src and convert_src are both TRIG_TIMER. All the arguments are unsigned int, change the local variable to an unsigned int and rename it for aesthetic reasons. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 931150150e10..ad7a5d53b97b 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -275,7 +275,7 @@ static int dmm32at_ai_cmdtest(struct comedi_device *dev, struct comedi_cmd *cmd) { int err = 0; - int tmp; + unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -351,24 +351,19 @@ static int dmm32at_ai_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ if (cmd->scan_begin_src == TRIG_TIMER) { - tmp = cmd->scan_begin_arg; - dmm32at_ns_to_timer(&cmd->scan_begin_arg, - cmd->flags & TRIG_ROUND_MASK); - if (tmp != cmd->scan_begin_arg) - err++; + arg = cmd->scan_begin_arg; + dmm32at_ns_to_timer(&arg, cmd->flags & TRIG_ROUND_MASK); + err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg); } if (cmd->convert_src == TRIG_TIMER) { - tmp = cmd->convert_arg; - dmm32at_ns_to_timer(&cmd->convert_arg, - cmd->flags & TRIG_ROUND_MASK); - if (tmp != cmd->convert_arg) - err++; - if (cmd->scan_begin_src == TRIG_TIMER && - cmd->scan_begin_arg < - cmd->convert_arg * cmd->scan_end_arg) { - cmd->scan_begin_arg = - cmd->convert_arg * cmd->scan_end_arg; - err++; + arg = cmd->convert_arg; + dmm32at_ns_to_timer(&arg, cmd->flags & TRIG_ROUND_MASK); + err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg); + + if (cmd->scan_begin_src == TRIG_TIMER) { + arg = cmd->convert_arg * cmd->scan_end_arg; + err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, + arg); } } -- cgit v1.2.3 From 704b0050f4be3e271e091ca05bc54186926a50bf Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:12:49 -0700 Subject: staging: comedi: dt2814: use comedi_fc helpers to validate timer arg Use the comedi_fc helper cfc_check_trigger_arg_is() to validate the trigger argument when the source is TRIG_TIMER. All the arguments are unsigned int, change the local variable to an unsigned int and rename it for aesthetic reasons. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2814.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2814.c b/drivers/staging/comedi/drivers/dt2814.c index 3794b7e52091..904c9f0e4afb 100644 --- a/drivers/staging/comedi/drivers/dt2814.c +++ b/drivers/staging/comedi/drivers/dt2814.c @@ -128,7 +128,7 @@ static int dt2814_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { int err = 0; - int tmp; + unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -170,10 +170,9 @@ static int dt2814_ai_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ - tmp = cmd->scan_begin_arg; - dt2814_ns_to_timer(&cmd->scan_begin_arg, cmd->flags & TRIG_ROUND_MASK); - if (tmp != cmd->scan_begin_arg) - err++; + arg = cmd->scan_begin_arg; + dt2814_ns_to_timer(&arg, cmd->flags & TRIG_ROUND_MASK); + err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg); if (err) return 4; -- cgit v1.2.3 From 9f57921507dacdcba186e384b2025601ad09b227 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:12:50 -0700 Subject: staging: comedi: dt282x: use comedi_fc helpers to validate timer args Use the comedi_fc helper cfc_check_trigger_arg_is() to validate the trigger arguments when the source is TRIG_TIMER. All the arguments are unsigned int, change the local variable to an unsigned int and rename it for aesthetic reasons. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt282x.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index 15d5145166e0..c2a66dcf99fe 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -578,7 +578,7 @@ static int dt282x_ai_cmdtest(struct comedi_device *dev, { const struct dt282x_board *board = comedi_board(dev); int err = 0; - int tmp; + unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -633,10 +633,9 @@ static int dt282x_ai_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ - tmp = cmd->convert_arg; - dt282x_ns_to_timer(&cmd->convert_arg, cmd->flags & TRIG_ROUND_MASK); - if (tmp != cmd->convert_arg) - err++; + arg = cmd->convert_arg; + dt282x_ns_to_timer(&arg, cmd->flags & TRIG_ROUND_MASK); + err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg); if (err) return 4; @@ -825,7 +824,7 @@ static int dt282x_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { int err = 0; - int tmp; + unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -865,10 +864,9 @@ static int dt282x_ao_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ - tmp = cmd->scan_begin_arg; - dt282x_ns_to_timer(&cmd->scan_begin_arg, cmd->flags & TRIG_ROUND_MASK); - if (tmp != cmd->scan_begin_arg) - err++; + arg = cmd->scan_begin_arg; + dt282x_ns_to_timer(&arg, cmd->flags & TRIG_ROUND_MASK); + err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg); if (err) return 4; -- cgit v1.2.3 From 75cff543a5c9a4a8b553359024f58f1bc6be4988 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:12:51 -0700 Subject: staging: comedi: ni_at_a2150: use comedi_fc helpers to validate timer arg Use the comedi_fc helper cfc_check_trigger_arg_is() to validate the trigger argument when the source is TRIG_TIMER. All the arguments are unsigned int, change the local variable to an unsigned int and rename it for aesthetic reasons. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_at_a2150.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/staging/comedi/drivers/ni_at_a2150.c index f8d6bfce17e6..5bd19494dbf6 100644 --- a/drivers/staging/comedi/drivers/ni_at_a2150.c +++ b/drivers/staging/comedi/drivers/ni_at_a2150.c @@ -334,7 +334,7 @@ static int a2150_ai_cmdtest(struct comedi_device *dev, { const struct a2150_board *thisboard = comedi_board(dev); int err = 0; - int tmp; + unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -379,10 +379,9 @@ static int a2150_ai_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ if (cmd->scan_begin_src == TRIG_TIMER) { - tmp = cmd->scan_begin_arg; - a2150_get_timing(dev, &cmd->scan_begin_arg, cmd->flags); - if (tmp != cmd->scan_begin_arg) - err++; + arg = cmd->scan_begin_arg; + a2150_get_timing(dev, &arg, cmd->flags); + err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg); } if (err) -- cgit v1.2.3 From 370936b1776b7444190850fa050ae912c18f0dd0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:12:52 -0700 Subject: staging: comedi: ni_pcidio: use comedi_fc helpers to validate timer arg Use the comedi_fc helper cfc_check_trigger_arg_is() to validate the trigger argument when the source is TRIG_TIMER. All the arguments are unsigned int, change the local variable to an unsigned int and rename it for aesthetic reasons. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_pcidio.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c index 14aaa58bbc9d..5fc74d6ff6af 100644 --- a/drivers/staging/comedi/drivers/ni_pcidio.c +++ b/drivers/staging/comedi/drivers/ni_pcidio.c @@ -536,7 +536,7 @@ static int ni_pcidio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { int err = 0; - int tmp; + unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -595,11 +595,9 @@ static int ni_pcidio_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ if (cmd->scan_begin_src == TRIG_TIMER) { - tmp = cmd->scan_begin_arg; - ni_pcidio_ns_to_timer(&cmd->scan_begin_arg, - cmd->flags & TRIG_ROUND_MASK); - if (tmp != cmd->scan_begin_arg) - err++; + arg = cmd->scan_begin_arg; + ni_pcidio_ns_to_timer(&arg, cmd->flags & TRIG_ROUND_MASK); + err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg); } if (err) -- cgit v1.2.3 From 2eb2a5ddc3473d1f53d47d326cc3620508fd3557 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:12:53 -0700 Subject: staging: comedi: pcl711: use comedi_fc helpers to validate timer arg Use the comedi_fc helper cfc_check_trigger_arg_is() to validate the trigger argument when the source is TRIG_TIMER. All the arguments are unsigned int, change the local variable to an unsigned int and rename it for aesthetic reasons. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl711.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c index ef3ebeef7a4d..d879052b1b23 100644 --- a/drivers/staging/comedi/drivers/pcl711.c +++ b/drivers/staging/comedi/drivers/pcl711.c @@ -295,8 +295,8 @@ static int pcl711_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { struct pcl711_private *devpriv = dev->private; - int tmp; int err = 0; + unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -344,14 +344,12 @@ static int pcl711_ai_cmdtest(struct comedi_device *dev, /* step 4 */ if (cmd->scan_begin_src == TRIG_TIMER) { - tmp = cmd->scan_begin_arg; + arg = cmd->scan_begin_arg; i8253_cascade_ns_to_timer(I8254_OSC_BASE_2MHZ, &devpriv->divisor1, &devpriv->divisor2, - &cmd->scan_begin_arg, - cmd->flags); - if (tmp != cmd->scan_begin_arg) - err++; + &arg, cmd->flags); + err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg); } if (err) -- cgit v1.2.3 From d3ab24c80c5ec39733304f214686159596b3c926 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:12:54 -0700 Subject: staging: comedi: pcl812: use comedi_fc helpers to validate timer arg Use the comedi_fc helper cfc_check_trigger_arg_is() to validate the trigger argument when the source is TRIG_TIMER. The minimum test is not needed, this was already validated in Step 3. All the arguments are unsigned int, change the local variable to an unsigned int and rename it for aesthetic reasons. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 542178bba2d4..3338e5d613b0 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -721,7 +721,7 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev, struct pcl812_private *devpriv = dev->private; int err = 0; unsigned int flags; - int tmp; + unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -774,15 +774,12 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ if (cmd->convert_src == TRIG_TIMER) { - tmp = cmd->convert_arg; + arg = cmd->convert_arg; i8253_cascade_ns_to_timer(I8254_OSC_BASE_2MHZ, &devpriv->divisor1, &devpriv->divisor2, - &cmd->convert_arg, cmd->flags); - if (cmd->convert_arg < board->ai_ns_min) - cmd->convert_arg = board->ai_ns_min; - if (tmp != cmd->convert_arg) - err++; + &arg, cmd->flags); + err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg); } if (err) -- cgit v1.2.3 From e4d18fe6b43760ad0a4728a3c908de955cbd206c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:12:55 -0700 Subject: staging: comedi: pcl816: use comedi_fc helpers to validate timer arg Use the comedi_fc helper cfc_check_trigger_arg_is() to validate the trigger argument when the source is TRIG_TIMER. The minimum test is not needed, this was already validated in Step 3. All the arguments are unsigned int, change the local variable to an unsigned int and rename it for aesthetic reasons. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 1260122ee7ab..3742f5f78fc6 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -370,7 +370,7 @@ static int pcl816_ai_cmdtest(struct comedi_device *dev, { struct pcl816_private *devpriv = dev->private; int err = 0; - int tmp; + unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -417,15 +417,12 @@ static int pcl816_ai_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ if (cmd->convert_src == TRIG_TIMER) { - tmp = cmd->convert_arg; + arg = cmd->convert_arg; i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ, &devpriv->divisor1, &devpriv->divisor2, - &cmd->convert_arg, cmd->flags); - if (cmd->convert_arg < 10000) - cmd->convert_arg = 10000; - if (tmp != cmd->convert_arg) - err++; + &arg, cmd->flags); + err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg); } if (err) -- cgit v1.2.3 From 863731fd6f9d375ce6e72f5816d578913a2d3223 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:12:56 -0700 Subject: staging: comedi: pcl818: use comedi_fc helpers to validate timer arg Use the comedi_fc helper cfc_check_trigger_arg_is() to validate the trigger argument when the source is TRIG_TIMER. The minimum test is not needed, this was already validated in Step 3. All the arguments are unsigned int, change the local variable to an unsigned int and rename it for aesthetic reasons. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index b960b66bc9a8..48b81c39c6a8 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -741,7 +741,7 @@ static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, const struct pcl818_board *board = comedi_board(dev); struct pcl818_private *devpriv = dev->private; int err = 0; - int tmp; + unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -788,15 +788,12 @@ static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, /* step 4: fix up any arguments */ if (cmd->convert_src == TRIG_TIMER) { - tmp = cmd->convert_arg; + arg = cmd->convert_arg; i8253_cascade_ns_to_timer(devpriv->i8253_osc_base, &devpriv->divisor1, &devpriv->divisor2, - &cmd->convert_arg, cmd->flags); - if (cmd->convert_arg < board->ns_min) - cmd->convert_arg = board->ns_min; - if (tmp != cmd->convert_arg) - err++; + &arg, cmd->flags); + err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg); } if (err) -- cgit v1.2.3 From 6c71941d3da2714602b2ccc146882647824d270e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:12:57 -0700 Subject: staging: comedi: quatech_daqp_cs: use comedi_fc helpers to validate timer args Use the comedi_fc helper cfc_check_trigger_arg_is() to validate the trigger arguments when the source is TRIG_TIMER. All the arguments are unsigned int, change the local variable to an unsigned int and rename it for aesthetic reasons. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/quatech_daqp_cs.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c index 0a8edb8cc190..b3bbec0a0d23 100644 --- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c +++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c @@ -373,7 +373,7 @@ static int daqp_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { int err = 0; - int tmp; + unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -435,19 +435,15 @@ static int daqp_ai_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ if (cmd->scan_begin_src == TRIG_TIMER) { - tmp = cmd->scan_begin_arg; - daqp_ns_to_timer(&cmd->scan_begin_arg, - cmd->flags & TRIG_ROUND_MASK); - if (tmp != cmd->scan_begin_arg) - err++; + arg = cmd->scan_begin_arg; + daqp_ns_to_timer(&arg, cmd->flags & TRIG_ROUND_MASK); + err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg); } if (cmd->convert_src == TRIG_TIMER) { - tmp = cmd->convert_arg; - daqp_ns_to_timer(&cmd->convert_arg, - cmd->flags & TRIG_ROUND_MASK); - if (tmp != cmd->convert_arg) - err++; + arg = cmd->convert_arg; + daqp_ns_to_timer(&arg, cmd->flags & TRIG_ROUND_MASK); + err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg); } if (err) -- cgit v1.2.3 From 3d6a4d118de05725a4fa45af9ba131a4314b1ecb Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:12:58 -0700 Subject: staging: comedi: rtd520: use comedi_fc helpers to validate timer args Use the comedi_fc helper cfc_check_trigger_arg_is() to validate the trigger arguments when the source is TRIG_TIMER. Use cfc_check_trigger_arg_min() to vaidate the scan_begin_arg when the scan_begin_src and convert_src are both TRIG_TIMER. All the arguments are unsigned int, change the local variable to an unsigned int and rename it for aesthetic reasons. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/rtd520.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c index 28402d2f92a2..d55c5893203b 100644 --- a/drivers/staging/comedi/drivers/rtd520.c +++ b/drivers/staging/comedi/drivers/rtd520.c @@ -779,7 +779,7 @@ static int rtd_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { int err = 0; - int tmp; + unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -894,26 +894,20 @@ static int rtd_ai_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ if (cmd->scan_begin_src == TRIG_TIMER) { - tmp = cmd->scan_begin_arg; - rtd_ns_to_timer(&cmd->scan_begin_arg, - cmd->flags & TRIG_ROUND_MASK); - if (tmp != cmd->scan_begin_arg) - err++; - + arg = cmd->scan_begin_arg; + rtd_ns_to_timer(&arg, cmd->flags & TRIG_ROUND_MASK); + err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg); } + if (cmd->convert_src == TRIG_TIMER) { - tmp = cmd->convert_arg; - rtd_ns_to_timer(&cmd->convert_arg, - cmd->flags & TRIG_ROUND_MASK); - if (tmp != cmd->convert_arg) - err++; - - if (cmd->scan_begin_src == TRIG_TIMER - && (cmd->scan_begin_arg - < (cmd->convert_arg * cmd->scan_end_arg))) { - cmd->scan_begin_arg = - cmd->convert_arg * cmd->scan_end_arg; - err++; + arg = cmd->convert_arg; + rtd_ns_to_timer(&arg, cmd->flags & TRIG_ROUND_MASK); + err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg); + + if (cmd->scan_begin_src == TRIG_TIMER) { + arg = cmd->convert_arg * cmd->scan_end_arg; + err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, + arg); } } -- cgit v1.2.3 From c646efe13fd1e76d00b25d1c4ebc7d8053ae907b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:12:59 -0700 Subject: staging: comedi: s626: use comedi_fc helpers to validate timer args Use the comedi_fc helper cfc_check_trigger_arg_is() to validate the trigger arguments when the source is TRIG_TIMER. Use cfc_check_trigger_arg_min() to vaidate the scan_begin_arg when the scan_begin_src and convert_src are both TRIG_TIMER. All the arguments are unsigned int, change the local variable to an unsigned int and rename it for aesthetic reasons. Change the type of the first parameter to s626_ns_to_timer() to remove the need for the casts. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/s626.c | 36 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index 33b4d027a5cb..0838f8aa6951 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c @@ -2098,7 +2098,7 @@ static int s626_ai_inttrig(struct comedi_device *dev, * Also, it should adjust ns so that it cooresponds to the actual time * that the device will use. */ -static int s626_ns_to_timer(int *nanosec, int round_mode) +static int s626_ns_to_timer(unsigned int *nanosec, int round_mode) { int divider, base; @@ -2206,7 +2206,7 @@ static int s626_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) * interval */ k = &s626_enc_chan_info[5]; - tick = s626_ns_to_timer((int *)&cmd->scan_begin_arg, + tick = s626_ns_to_timer(&cmd->scan_begin_arg, cmd->flags & TRIG_ROUND_MASK); /* load timer value and enable interrupt */ @@ -2229,7 +2229,7 @@ static int s626_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) * interval */ k = &s626_enc_chan_info[4]; - tick = s626_ns_to_timer((int *)&cmd->convert_arg, + tick = s626_ns_to_timer(&cmd->convert_arg, cmd->flags & TRIG_ROUND_MASK); /* load timer value and enable interrupt */ @@ -2288,7 +2288,7 @@ static int s626_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { int err = 0; - int tmp; + unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -2371,24 +2371,20 @@ static int s626_ai_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ if (cmd->scan_begin_src == TRIG_TIMER) { - tmp = cmd->scan_begin_arg; - s626_ns_to_timer((int *)&cmd->scan_begin_arg, - cmd->flags & TRIG_ROUND_MASK); - if (tmp != cmd->scan_begin_arg) - err++; + arg = cmd->scan_begin_arg; + s626_ns_to_timer(&arg, cmd->flags & TRIG_ROUND_MASK); + err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg); } + if (cmd->convert_src == TRIG_TIMER) { - tmp = cmd->convert_arg; - s626_ns_to_timer((int *)&cmd->convert_arg, - cmd->flags & TRIG_ROUND_MASK); - if (tmp != cmd->convert_arg) - err++; - if (cmd->scan_begin_src == TRIG_TIMER && - cmd->scan_begin_arg < cmd->convert_arg * - cmd->scan_end_arg) { - cmd->scan_begin_arg = cmd->convert_arg * - cmd->scan_end_arg; - err++; + arg = cmd->convert_arg; + s626_ns_to_timer(&arg, cmd->flags & TRIG_ROUND_MASK); + err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg); + + if (cmd->scan_begin_src == TRIG_TIMER) { + arg = cmd->convert_arg * cmd->scan_end_arg; + err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, + arg); } } -- cgit v1.2.3 From dcd0a7a3417833cb0d2f5df10eaf39d3f9da2517 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:13:00 -0700 Subject: staging: comedi: skel: use comedi_fc helpers to validate timer args Use the comedi_fc helper cfc_check_trigger_arg_is() to validate the trigger arguments when the source is TRIG_TIMER. Use cfc_check_trigger_arg_min() to vaidate the scan_begin_arg when the scan_begin_src and convert_src are both TRIG_TIMER. All the arguments are unsigned int, change the local variable to an unsigned int and rename it for aesthetic reasons. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/skel.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/skel.c b/drivers/staging/comedi/drivers/skel.c index 39008cf30ecb..3bfa221faf4d 100644 --- a/drivers/staging/comedi/drivers/skel.c +++ b/drivers/staging/comedi/drivers/skel.c @@ -220,7 +220,7 @@ static int skel_ai_cmdtest(struct comedi_device *dev, struct comedi_cmd *cmd) { int err = 0; - int tmp; + unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -286,24 +286,19 @@ static int skel_ai_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ if (cmd->scan_begin_src == TRIG_TIMER) { - tmp = cmd->scan_begin_arg; - skel_ns_to_timer(&cmd->scan_begin_arg, - cmd->flags & TRIG_ROUND_MASK); - if (tmp != cmd->scan_begin_arg) - err++; + arg = cmd->scan_begin_arg; + skel_ns_to_timer(&arg, cmd->flags & TRIG_ROUND_MASK); + err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg); } if (cmd->convert_src == TRIG_TIMER) { - tmp = cmd->convert_arg; - skel_ns_to_timer(&cmd->convert_arg, - cmd->flags & TRIG_ROUND_MASK); - if (tmp != cmd->convert_arg) - err++; - if (cmd->scan_begin_src == TRIG_TIMER && - cmd->scan_begin_arg < - cmd->convert_arg * cmd->scan_end_arg) { - cmd->scan_begin_arg = - cmd->convert_arg * cmd->scan_end_arg; - err++; + arg = cmd->convert_arg; + skel_ns_to_timer(&arg, cmd->flags & TRIG_ROUND_MASK); + err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg); + + if (cmd->scan_begin_src == TRIG_TIMER) { + arg = cmd->convert_arg * cmd->scan_end_arg; + err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, + arg); } } -- cgit v1.2.3 From 66e3015f6ec84f7143af0f01ce096b6cd9e1a4b9 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:13:01 -0700 Subject: staging: comedi: addi_apci_3xxx: use comedi_fc helpers to validate timer arg Use the comedi_fc helper cfc_check_trigger_arg_is() to validate the trigger argument when the source is TRIG_TIMER. For aesthetics, rename the local variable 'tmp' to 'arg'. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3xxx.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c index df3b63ac4a0e..0532b6cc40e3 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c +++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c @@ -533,7 +533,7 @@ static int apci3xxx_ai_cmdtest(struct comedi_device *dev, { const struct apci3xxx_boardinfo *board = comedi_board(dev); int err = 0; - unsigned int tmp; + unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -573,11 +573,9 @@ static int apci3xxx_ai_cmdtest(struct comedi_device *dev, /* step 4: fix up any arguments */ - tmp = cmd->convert_arg; - err |= apci3xxx_ai_ns_to_timer(dev, &cmd->convert_arg, - cmd->flags & TRIG_ROUND_MASK); - if (tmp != cmd->convert_arg) - err |= -EINVAL; + arg = cmd->convert_arg; + err |= apci3xxx_ai_ns_to_timer(dev, &arg, cmd->flags & TRIG_ROUND_MASK); + err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg); if (err) return 4; -- cgit v1.2.3 From 40642e95850b4425eef1eb74793d28085605ac75 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:30:37 -0700 Subject: staging: comedi: usbdux: remove 'ai_continuous' from private data This member of the private data can be determined from the cmd->stop_src. Do that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 143f63202621..5f6b1b3c0bdb 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -207,7 +207,6 @@ struct usbdux_private { unsigned int high_speed:1; unsigned int ai_cmd_running:1; - unsigned int ai_continous:1; unsigned int ao_cmd_running:1; unsigned int ao_continous:1; unsigned int pwm_cmd_running:1; @@ -266,6 +265,7 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb) struct comedi_device *dev = urb->context; struct comedi_subdevice *s = dev->read_subdev; struct usbdux_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; int i, err, n; /* first we test if something unusual has just happened */ @@ -349,7 +349,7 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb) devpriv->ai_counter = devpriv->ai_timer; /* test, if we transmit only a fixed number of samples */ - if (!devpriv->ai_continous) { + if (cmd->stop_src == TRIG_COUNT) { /* not continuous, fixed number of samples */ devpriv->ai_sample_count--; /* all samples received? */ @@ -778,10 +778,8 @@ static int usbdux_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (cmd->stop_src == TRIG_COUNT) { /* data arrives as one packet */ devpriv->ai_sample_count = cmd->stop_arg; - devpriv->ai_continous = 0; } else { /* continous acquisition */ - devpriv->ai_continous = 1; devpriv->ai_sample_count = 0; } -- cgit v1.2.3 From c8f3174a9015a88cd59fd424d3c60b25fc9bc5e1 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:30:38 -0700 Subject: staging: comedi: usbdux: remove 'ao_continuous' from private data This member of the private data can be determined from the cmd->stop_src. Do that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 5f6b1b3c0bdb..dfbf6613a6f5 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -208,7 +208,6 @@ struct usbdux_private { unsigned int high_speed:1; unsigned int ai_cmd_running:1; unsigned int ao_cmd_running:1; - unsigned int ao_continous:1; unsigned int pwm_cmd_running:1; /* number of samples to acquire */ @@ -414,6 +413,7 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb) struct comedi_device *dev = urb->context; struct comedi_subdevice *s = dev->write_subdev; struct usbdux_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; uint8_t *datap; int len; int ret; @@ -463,7 +463,7 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb) devpriv->ao_counter = devpriv->ao_timer; /* handle non continous acquisition */ - if (!devpriv->ao_continous) { + if (cmd->stop_src == TRIG_COUNT) { /* fixed number of samples */ devpriv->ao_sample_count--; if (devpriv->ao_sample_count < 0) { @@ -1074,10 +1074,8 @@ static int usbdux_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) /* data arrives as one packet */ devpriv->ao_sample_count = cmd->stop_arg; } - devpriv->ao_continous = 0; } else { /* continous acquisition */ - devpriv->ao_continous = 1; devpriv->ao_sample_count = 0; } -- cgit v1.2.3 From 61ff4709a5820bc28e76f184aa92f5a17ba88ea6 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:30:39 -0700 Subject: staging: comedi: usbduxfast: remove 'ai_continuous' from private data This member of the private data can be determined from the cmd->stop_src. Do that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxfast.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c index a4d7bfbcc6b9..376d14608926 100644 --- a/drivers/staging/comedi/drivers/usbduxfast.c +++ b/drivers/staging/comedi/drivers/usbduxfast.c @@ -154,7 +154,6 @@ struct usbduxfast_private { uint8_t *duxbuf; int8_t *inbuf; short int ai_cmd_running; /* asynchronous command is running */ - short int ai_continous; /* continous acquisition */ long int ai_sample_count; /* number of samples to acquire */ int ignore; /* counter which ignores the first buffers */ @@ -239,6 +238,7 @@ static void usbduxfast_ai_interrupt(struct urb *urb) struct comedi_device *dev = urb->context; struct comedi_subdevice *s = dev->read_subdev; struct comedi_async *async = s->async; + struct comedi_cmd *cmd = &async->cmd; struct usb_device *usb = comedi_to_usb_dev(dev); struct usbduxfast_private *devpriv = dev->private; int n, err; @@ -285,7 +285,7 @@ static void usbduxfast_ai_interrupt(struct urb *urb) } if (!devpriv->ignore) { - if (!devpriv->ai_continous) { + if (cmd->stop_src == TRIG_COUNT) { /* not continuous, fixed number of samples */ n = urb->actual_length / sizeof(uint16_t); if (unlikely(devpriv->ai_sample_count < n)) { @@ -817,10 +817,8 @@ static int usbduxfast_ai_cmd(struct comedi_device *dev, up(&devpriv->sem); return -EFAULT; } - devpriv->ai_continous = 0; } else { /* continous acquisition */ - devpriv->ai_continous = 1; devpriv->ai_sample_count = 0; } -- cgit v1.2.3 From fee5ba92cd5b00df49b19d4b014f5ff30bb67419 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:30:40 -0700 Subject: staging: comedi: usbduxsigma: remove 'ai_continuous' from private data This member of the private data can be determined from the cmd->stop_src. Do that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxsigma.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c index 52b8b8fb9ee4..05fb52e44b87 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -166,7 +166,6 @@ struct usbduxsigma_private { unsigned high_speed:1; unsigned ai_cmd_running:1; - unsigned ai_continuous:1; unsigned ao_cmd_running:1; unsigned ao_continuous:1; unsigned pwm_cmd_running:1; @@ -223,6 +222,7 @@ static void usbduxsigma_ai_urb_complete(struct urb *urb) struct comedi_device *dev = urb->context; struct usbduxsigma_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; + struct comedi_cmd *cmd = &s->async->cmd; unsigned int dio_state; uint32_t val; int ret; @@ -301,7 +301,7 @@ static void usbduxsigma_ai_urb_complete(struct urb *urb) /* timer zero, transfer measurements to comedi */ devpriv->ai_counter = devpriv->ai_timer; - if (!devpriv->ai_continuous) { + if (cmd->stop_src == TRIG_COUNT) { /* not continuous, fixed number of samples */ devpriv->ai_sample_count--; if (devpriv->ai_sample_count < 0) { @@ -596,10 +596,8 @@ static int usbduxsigma_ai_cmdtest(struct comedi_device *dev, if (cmd->stop_src == TRIG_COUNT) { /* data arrives as one packet */ devpriv->ai_sample_count = cmd->stop_arg; - devpriv->ai_continuous = 0; } else { /* continuous acquisition */ - devpriv->ai_continuous = 1; devpriv->ai_sample_count = 0; } -- cgit v1.2.3 From 1b81dbc29b9a1ac6cb5c58217c181b675e91220c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:30:41 -0700 Subject: staging: comedi: usbduxsigma: remove 'ao_continuous' from private data This member of the private data can be determined from the cmd->stop_src. Do that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxsigma.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c index 05fb52e44b87..6394f8b2f954 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -167,7 +167,6 @@ struct usbduxsigma_private { unsigned high_speed:1; unsigned ai_cmd_running:1; unsigned ao_cmd_running:1; - unsigned ao_continuous:1; unsigned pwm_cmd_running:1; /* number of samples to acquire */ @@ -360,6 +359,7 @@ static void usbduxsigma_ao_urb_complete(struct urb *urb) struct comedi_device *dev = urb->context; struct usbduxsigma_private *devpriv = dev->private; struct comedi_subdevice *s = dev->write_subdev; + struct comedi_cmd *cmd = &s->async->cmd; uint8_t *datap; int len; int ret; @@ -403,7 +403,7 @@ static void usbduxsigma_ao_urb_complete(struct urb *urb) /* timer zero, transfer from comedi */ devpriv->ao_counter = devpriv->ao_timer; - if (!devpriv->ao_continuous) { + if (cmd->stop_src == TRIG_COUNT) { /* not continuous, fixed number of samples */ devpriv->ao_sample_count--; if (devpriv->ao_sample_count < 0) { @@ -984,10 +984,8 @@ static int usbduxsigma_ao_cmdtest(struct comedi_device *dev, */ devpriv->ao_sample_count = cmd->stop_arg; } - devpriv->ao_continuous = 0; } else { /* continuous acquisition */ - devpriv->ao_continuous = 1; devpriv->ao_sample_count = 0; } -- cgit v1.2.3 From 33938a9dfa67d55aee836172418e4a7705798950 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:30:42 -0700 Subject: staging: comedi: usbdux: remove 'ao_chanlist' from private data This member of the private data is just a copy of the channels from the cmd->chanlist. Remove the member and just use the cmd->chanlist directly. Remove the unneeded 'len' local variable in usbdux_ao_isoc_irq(). This is just the cmd->chanlist_len. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index dfbf6613a6f5..e61e4a93cc19 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -202,7 +202,6 @@ struct usbdux_private { /* input buffer for single insn */ uint16_t *insn_buf; - uint8_t ao_chanlist[USBDUX_NUM_AO_CHAN]; unsigned int ao_readback[USBDUX_NUM_AO_CHAN]; unsigned int high_speed:1; @@ -415,7 +414,6 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb) struct usbdux_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; uint8_t *datap; - int len; int ret; int i; @@ -478,10 +476,9 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb) /* transmit data to the USB bus */ datap = urb->transfer_buffer; - len = s->async->cmd.chanlist_len; - *datap++ = len; - for (i = 0; i < s->async->cmd.chanlist_len; i++) { - unsigned int chan = devpriv->ao_chanlist[i]; + *datap++ = cmd->chanlist_len; + for (i = 0; i < cmd->chanlist_len; i++) { + unsigned int chan = CR_CHAN(cmd->chanlist[i]); unsigned short val; ret = comedi_buf_get(s, &val); @@ -1030,7 +1027,6 @@ static int usbdux_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) struct usbdux_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; int ret = -EBUSY; - int i; down(&devpriv->sem); @@ -1040,9 +1036,6 @@ static int usbdux_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) /* set current channel of the running acquisition to zero */ s->async->cur_chan = 0; - for (i = 0; i < cmd->chanlist_len; ++i) - devpriv->ao_chanlist[i] = CR_CHAN(cmd->chanlist[i]); - /* we count in steps of 1ms (125us) */ /* 125us mode not used yet */ if (0) { /* (devpriv->high_speed) */ -- cgit v1.2.3 From a49b45fb498be9c7fd42cccdb1d71fe424c962ca Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:30:43 -0700 Subject: staging: comedi: usbdux: use 'cmd' pointer in usbduxsub_ai_isoc_irq() Use the 'cmd' pointer to access the chanlist instead of getting to it using the comedi_subdevice pointer. Remove the unneeded 'n' local variable, this is just the cmd->chanlist_len. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index e61e4a93cc19..5f65e4213c6e 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -264,7 +264,7 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb) struct comedi_subdevice *s = dev->read_subdev; struct usbdux_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - int i, err, n; + int i, err; /* first we test if something unusual has just happened */ switch (urb->status) { @@ -361,9 +361,8 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb) } } /* get the data from the USB bus and hand it over to comedi */ - n = s->async->cmd.chanlist_len; - for (i = 0; i < n; i++) { - unsigned int range = CR_RANGE(s->async->cmd.chanlist[i]); + for (i = 0; i < cmd->chanlist_len; i++) { + unsigned int range = CR_RANGE(cmd->chanlist[i]); uint16_t val = le16_to_cpu(devpriv->in_buf[i]); /* bipolar data is two's-complement */ -- cgit v1.2.3 From d54e5e6bc5de032641486843a0df41ac3f7167ed Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:30:44 -0700 Subject: staging: comedi: usbduxsigma: remove 'ao_chanlist' from private data This member of the private data is just a copy of the channels from the cmd->chanlist. Remove the member and just use the cmd->chanlist directly. Remove the unneeded 'len' local variable in usbduxsigma_ao_urb_complete(). This is just the cmd->chanlist_len. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxsigma.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c index 6394f8b2f954..13f5644ff3b6 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -161,7 +161,6 @@ struct usbduxsigma_private { /* input buffer for single insn */ uint8_t *insn_buf; - uint8_t ao_chanlist[USBDUXSIGMA_NUM_AO_CHAN]; unsigned int ao_readback[USBDUXSIGMA_NUM_AO_CHAN]; unsigned high_speed:1; @@ -361,7 +360,6 @@ static void usbduxsigma_ao_urb_complete(struct urb *urb) struct comedi_subdevice *s = dev->write_subdev; struct comedi_cmd *cmd = &s->async->cmd; uint8_t *datap; - int len; int ret; int i; @@ -417,10 +415,9 @@ static void usbduxsigma_ao_urb_complete(struct urb *urb) /* transmit data to the USB bus */ datap = urb->transfer_buffer; - len = s->async->cmd.chanlist_len; - *datap++ = len; - for (i = 0; i < len; i++) { - unsigned int chan = devpriv->ao_chanlist[i]; + *datap++ = cmd->chanlist_len; + for (i = 0; i < cmd->chanlist_len; i++) { + unsigned int chan = CR_CHAN(cmd->chanlist[i]); unsigned short val; ret = comedi_buf_get(s, &val); @@ -1001,14 +998,11 @@ static int usbduxsigma_ao_cmd(struct comedi_device *dev, struct usbduxsigma_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; int ret; - int i; down(&devpriv->sem); /* set current channel of the running acquisition to zero */ s->async->cur_chan = 0; - for (i = 0; i < cmd->chanlist_len; ++i) - devpriv->ao_chanlist[i] = CR_CHAN(cmd->chanlist[i]); devpriv->ao_counter = devpriv->ao_timer; -- cgit v1.2.3 From 8ffffae6cf20099f03a9bb178b5c2f2c006b94a5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:30:45 -0700 Subject: staging: comedi: das800: add a local var for the comedi_cmd pointer For aesthetics, use a local variable to access the comedi_cmd as a pointer in das800_ai_do_cmd() instead of getting to it from the comedi_async pointer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das800.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c index 38f6a6d9e1dc..1e2e3d56d9fe 100644 --- a/drivers/staging/comedi/drivers/das800.c +++ b/drivers/staging/comedi/drivers/das800.c @@ -404,9 +404,10 @@ static int das800_ai_do_cmd(struct comedi_device *dev, const struct das800_board *thisboard = comedi_board(dev); struct das800_private *devpriv = dev->private; struct comedi_async *async = s->async; - unsigned int gain = CR_RANGE(async->cmd.chanlist[0]); - unsigned int start_chan = CR_CHAN(async->cmd.chanlist[0]); - unsigned int end_chan = (start_chan + async->cmd.chanlist_len - 1) % 8; + struct comedi_cmd *cmd = &async->cmd; + unsigned int gain = CR_RANGE(cmd->chanlist[0]); + unsigned int start_chan = CR_CHAN(cmd->chanlist[0]); + unsigned int end_chan = (start_chan + cmd->chanlist_len - 1) % 8; unsigned int scan_chans = (end_chan << 3) | start_chan; int conv_bits; unsigned long irq_flags; @@ -424,8 +425,8 @@ static int das800_ai_do_cmd(struct comedi_device *dev, gain &= 0xf; outb(gain, dev->iobase + DAS800_GAIN); - if (async->cmd.stop_src == TRIG_COUNT) { - devpriv->count = async->cmd.stop_arg * async->cmd.chanlist_len; + if (cmd->stop_src == TRIG_COUNT) { + devpriv->count = cmd->stop_arg * cmd->chanlist_len; devpriv->forever = false; } else { /* TRIG_NONE */ devpriv->forever = true; @@ -437,9 +438,9 @@ static int das800_ai_do_cmd(struct comedi_device *dev, */ conv_bits = 0; conv_bits |= EACS | IEOC; - if (async->cmd.start_src == TRIG_EXT) + if (cmd->start_src == TRIG_EXT) conv_bits |= DTEN; - if (async->cmd.convert_src == TRIG_TIMER) { + if (cmd->convert_src == TRIG_TIMER) { conv_bits |= CASC | ITE; /* set conversion frequency */ das800_set_frequency(dev); -- cgit v1.2.3 From 9dad12fe4746c091ba7304bbd690f4a05fb1216a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:30:46 -0700 Subject: staging: comedi: das800: remove 'forever' from private data This member of the private data can be determined from the cmd->stop_src. Do that instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das800.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c index 1e2e3d56d9fe..6f7f8d531dd5 100644 --- a/drivers/staging/comedi/drivers/das800.c +++ b/drivers/staging/comedi/drivers/das800.c @@ -224,7 +224,6 @@ struct das800_private { unsigned int divisor1; /* counter 1 value for timed conversions */ unsigned int divisor2; /* counter 2 value for timed conversions */ unsigned int do_bits; /* digital output bits */ - bool forever; /* flag that we should take data forever */ }; static void das800_ind_write(struct comedi_device *dev, @@ -290,7 +289,6 @@ static int das800_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { struct das800_private *devpriv = dev->private; - devpriv->forever = false; devpriv->count = 0; das800_disable(dev); return 0; @@ -425,13 +423,10 @@ static int das800_ai_do_cmd(struct comedi_device *dev, gain &= 0xf; outb(gain, dev->iobase + DAS800_GAIN); - if (cmd->stop_src == TRIG_COUNT) { + if (cmd->stop_src == TRIG_COUNT) devpriv->count = cmd->stop_arg * cmd->chanlist_len; - devpriv->forever = false; - } else { /* TRIG_NONE */ - devpriv->forever = true; + else /* TRIG_NONE */ devpriv->count = 0; - } /* enable auto channel scan, send interrupts on end of conversion * and set clock source to internal or external @@ -467,7 +462,8 @@ static irqreturn_t das800_interrupt(int irq, void *d) struct comedi_device *dev = d; struct das800_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; - struct comedi_async *async = s ? s->async : NULL; + struct comedi_async *async; + struct comedi_cmd *cmd; unsigned long irq_flags; unsigned int status; unsigned int val; @@ -481,6 +477,9 @@ static irqreturn_t das800_interrupt(int irq, void *d) if (!dev->attached) return IRQ_HANDLED; + async = s->async; + cmd = &async->cmd; + spin_lock_irqsave(&dev->spinlock, irq_flags); status = das800_ind_read(dev, CONTROL1) & STATUS2_HCEN; /* @@ -512,7 +511,7 @@ static irqreturn_t das800_interrupt(int irq, void *d) val >>= 4; /* 12-bit sample */ /* if there are more data points to collect */ - if (devpriv->count > 0 || devpriv->forever) { + if (cmd->stop_src == TRIG_NONE || devpriv->count > 0) { /* write data point to buffer */ cfc_write_to_buffer(s, val & s->maxdata); devpriv->count--; @@ -527,7 +526,7 @@ static irqreturn_t das800_interrupt(int irq, void *d) return IRQ_HANDLED; } - if (devpriv->count > 0 || devpriv->forever) { + if (cmd->stop_src == TRIG_NONE || devpriv->count > 0) { /* Re-enable card's interrupt. * We already have spinlock, so indirect addressing is safe */ das800_ind_write(dev, CONTROL1_INTE | devpriv->do_bits, -- cgit v1.2.3 From 71ba7506f05e6512e4b25df2233fa238025399d5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:30:47 -0700 Subject: staging: comedi: amplc_dio200_common: use comedi_cmd pointer Use the local variable to access the comedi_cmd as a pointer in dio200_read_scan_intr() instead of getting to it from the comedi_subdevice pointer. Remove the unnecessary local variable 'len', this is just the cmd->chanlist_len. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_dio200_common.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index 1a580c374ca8..3edaa4028da2 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -312,12 +312,11 @@ static void dio200_read_scan_intr(struct comedi_device *dev, struct dio200_subdev_intr *subpriv = s->private; struct comedi_cmd *cmd = &s->async->cmd; unsigned short val; - unsigned int n, ch, len; + unsigned int n, ch; val = 0; - len = s->async->cmd.chanlist_len; - for (n = 0; n < len; n++) { - ch = CR_CHAN(s->async->cmd.chanlist[n]); + for (n = 0; n < cmd->chanlist_len; n++) { + ch = CR_CHAN(cmd->chanlist[n]); if (triggered & (1U << ch)) val |= (1U << n); } -- cgit v1.2.3 From 9af39b31b57965f2b1f8b2bfdd8f313b485a87ff Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:30:48 -0700 Subject: staging: comedi: amplc_pci224: use comedi_cmd pointer Use the local variable to access the comedi_cmd as a pointer in pci224_ao_munge() instead of getting to it from the comedi_async pointer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci224.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index e8beeab7a78b..44904fd87b27 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -987,7 +987,7 @@ pci224_ao_munge(struct comedi_device *dev, struct comedi_subdevice *s, { const struct pci224_board *thisboard = comedi_board(dev); struct pci224_private *devpriv = dev->private; - struct comedi_async *async = s->async; + struct comedi_cmd *cmd = &s->async->cmd; unsigned short *array = data; unsigned int length = num_bytes / sizeof(*array); unsigned int offset; @@ -997,7 +997,7 @@ pci224_ao_munge(struct comedi_device *dev, struct comedi_subdevice *s, /* The hardware expects 16-bit numbers. */ shift = 16 - thisboard->ao_bits; /* Channels will be all bipolar or all unipolar. */ - if ((devpriv->hwrange[CR_RANGE(async->cmd.chanlist[0])] & + if ((devpriv->hwrange[CR_RANGE(cmd->chanlist[0])] & PCI224_DACCON_POLAR_MASK) == PCI224_DACCON_POLAR_UNI) { /* Unipolar */ offset = 0; -- cgit v1.2.3 From 1eb9cf92da92a33d38c6418b609743e673f366fc Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:30:49 -0700 Subject: staging: comedi: amplc_pci230: use comedi_cmd pointer Use the local variable to access the comedi_cmd as a pointer in pci230_handle_ai() instead of getting to it from the comedi_async pointer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci230.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index d6f6a7a5bad1..9c8254386704 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -2151,14 +2151,14 @@ static void pci230_handle_ai(struct comedi_device *dev, struct comedi_subdevice *s) { struct pci230_private *devpriv = dev->private; - struct comedi_cmd *cmd = &s->async->cmd; + struct comedi_async *async = s->async; + struct comedi_cmd *cmd = &async->cmd; + unsigned int scanlen = cmd->scan_end_arg; unsigned int events = 0; unsigned int status_fifo; unsigned int i; unsigned int todo; unsigned int fifoamount; - struct comedi_async *async = s->async; - unsigned int scanlen = async->cmd.scan_end_arg; /* Determine number of samples to read. */ if (cmd->stop_src != TRIG_COUNT) { -- cgit v1.2.3 From bedd62fc6d35a99e19710f05aabaec9d6c19575d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:30:50 -0700 Subject: staging: comedi: cb_pcidas: use comedi_cmd pointer Use the local variable to access the comedi_cmd as a pointer instead of getting to it from the comedi_async pointer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index 7b029596b11f..7377da1aff7c 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -1321,7 +1321,7 @@ static void handle_ao_interrupt(struct comedi_device *dev, unsigned int status) num_points * sizeof(short)); num_points = num_bytes / sizeof(short); - if (async->cmd.stop_src == TRIG_COUNT) + if (cmd->stop_src == TRIG_COUNT) devpriv->ao_count -= num_points; /* write data to board's fifo */ outsw(devpriv->ao_registers + DACDATA, devpriv->ao_buffer, @@ -1343,6 +1343,7 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d) struct cb_pcidas_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; struct comedi_async *async; + struct comedi_cmd *cmd; int status, s5933_status; int half_fifo = thisboard->fifo_size / 2; unsigned int num_samples, i; @@ -1353,6 +1354,7 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d) return IRQ_NONE; async = s->async; + cmd = &async->cmd; s5933_status = inl(devpriv->s5933_config + AMCC_OP_REG_INTCSR); @@ -1375,7 +1377,7 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d) if (status & ADHFI) { /* read data */ num_samples = half_fifo; - if (async->cmd.stop_src == TRIG_COUNT && + if (cmd->stop_src == TRIG_COUNT && num_samples > devpriv->count) { num_samples = devpriv->count; } @@ -1384,7 +1386,7 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d) cfc_write_array_to_buffer(s, devpriv->ai_buffer, num_samples * sizeof(short)); devpriv->count -= num_samples; - if (async->cmd.stop_src == TRIG_COUNT && devpriv->count == 0) + if (cmd->stop_src == TRIG_COUNT && devpriv->count == 0) async->events |= COMEDI_CB_EOA; /* clear half-full interrupt latch */ spin_lock_irqsave(&dev->spinlock, flags); @@ -1399,7 +1401,7 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d) INT_ADCFIFO)) == 0) break; cfc_write_to_buffer(s, inw(devpriv->adc_fifo)); - if (async->cmd.stop_src == TRIG_COUNT && + if (cmd->stop_src == TRIG_COUNT && --devpriv->count == 0) { /* end of acquisition */ async->events |= COMEDI_CB_EOA; -- cgit v1.2.3 From d1462b9430d8c7e2e17c807116f2e24b3a81cd87 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:30:51 -0700 Subject: staging: comedi: das1800: use comedi_cmd pointer Use the local variable to access the comedi_cmd as a pointer instead of getting to it from the comedi_subdevice pointer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das1800.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index ba357b6ec127..859519026c4c 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -547,7 +547,7 @@ static void das1800_flush_dma_channel(struct comedi_device *dev, munge_data(dev, buffer, num_samples); cfc_write_array_to_buffer(s, buffer, num_bytes); - if (s->async->cmd.stop_src == TRIG_COUNT) + if (cmd->stop_src == TRIG_COUNT) devpriv->count -= num_samples; return; -- cgit v1.2.3 From 45c9db919127bccdecb8105ee393e58c27040061 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:30:52 -0700 Subject: staging: comedi: mite: tidy up local variables in mite_sync_output_dma() Tidy up the local variables so that the comedi_cmd is accessed as a pointer instead of getting to it from the comedi_async pointer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index c12806ee4f6f..19c029acbc99 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -562,21 +562,19 @@ int mite_sync_output_dma(struct mite_channel *mite_chan, struct comedi_subdevice *s) { struct comedi_async *async = s->async; - int count; + struct comedi_cmd *cmd = &async->cmd; + u32 stop_count = cmd->stop_arg * cfc_bytes_per_scan(s); + unsigned int old_alloc_count = async->buf_read_alloc_count; u32 nbytes_ub, nbytes_lb; - unsigned int old_alloc_count; - u32 stop_count = async->cmd.stop_arg * cfc_bytes_per_scan(s); + int count; - old_alloc_count = async->buf_read_alloc_count; /* read alloc as much as we can */ comedi_buf_read_alloc(s, async->prealloc_bufsz); nbytes_lb = mite_bytes_read_from_memory_lb(mite_chan); - if (async->cmd.stop_src == TRIG_COUNT && - (int)(nbytes_lb - stop_count) > 0) + if (cmd->stop_src == TRIG_COUNT && (int)(nbytes_lb - stop_count) > 0) nbytes_lb = stop_count; nbytes_ub = mite_bytes_read_from_memory_ub(mite_chan); - if (async->cmd.stop_src == TRIG_COUNT && - (int)(nbytes_ub - stop_count) > 0) + if (cmd->stop_src == TRIG_COUNT && (int)(nbytes_ub - stop_count) > 0) nbytes_ub = stop_count; if ((int)(nbytes_ub - old_alloc_count) > 0) { dev_warn(s->device->class_dev, "mite: DMA underrun\n"); -- cgit v1.2.3 From f2353b2036ddb54e8ba6e11dad1b4967729aca78 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:30:53 -0700 Subject: staging: comedi: ni_65xx: remove commented out local variable This function does not use the comedi_cmd. Remove the commented out local variable. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_65xx.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c index a74fd1e60c28..9a139d6b8ef4 100644 --- a/drivers/staging/comedi/drivers/ni_65xx.c +++ b/drivers/staging/comedi/drivers/ni_65xx.c @@ -491,7 +491,6 @@ static int ni_65xx_intr_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { struct ni_65xx_private *devpriv = dev->private; - /* struct comedi_cmd *cmd = &s->async->cmd; */ writeb(ClrEdge | ClrOverflow, devpriv->mite->daq_io_addr + Clear_Register); -- cgit v1.2.3 From c2ccd69aba484ce6d8cfd174a5831a3eb547f2e9 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:30:54 -0700 Subject: staging: comedi: usbduxsigma: use comedi_cmd pointer Use the local variable to access the comedi_cmd as a pointer instead of getting to it from the comedi_subdevice pointer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxsigma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c index 13f5644ff3b6..ccc3ef7ba55c 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -312,7 +312,7 @@ static void usbduxsigma_ai_urb_complete(struct urb *urb) } /* get the data from the USB bus and hand it over to comedi */ - for (i = 0; i < s->async->cmd.chanlist_len; i++) { + for (i = 0; i < cmd->chanlist_len; i++) { /* transfer data, note first byte is the DIO state */ val = be32_to_cpu(devpriv->in_buf[i+1]); val &= 0x00ffffff; /* strip status byte */ -- cgit v1.2.3 From 3516a5ef16500aa49b4a5ea7a8a2c7147fd2fbfb Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:30:55 -0700 Subject: staging: comedi: pcmuio: tidy up local variables in pcmuio_handle_intr_subdev() Tidy up the local variables so that the comedi_cmd is accessed as a pointer instead of getting to it from the comedi_subdevice pointer. Remove the local variable 'len' and use the cmd->chanlist_len directly. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcmuio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcmuio.c b/drivers/staging/comedi/drivers/pcmuio.c index 182b48a3e88b..62914bb342d2 100644 --- a/drivers/staging/comedi/drivers/pcmuio.c +++ b/drivers/staging/comedi/drivers/pcmuio.c @@ -317,7 +317,7 @@ static void pcmuio_handle_intr_subdev(struct comedi_device *dev, struct pcmuio_private *devpriv = dev->private; int asic = pcmuio_subdevice_to_asic(s); struct pcmuio_asic *chip = &devpriv->asics[asic]; - unsigned int len = s->async->cmd.chanlist_len; + struct comedi_cmd *cmd = &s->async->cmd; unsigned oldevents = s->async->events; unsigned int val = 0; unsigned long flags; @@ -331,8 +331,8 @@ static void pcmuio_handle_intr_subdev(struct comedi_device *dev, if (!(triggered & chip->enabled_mask)) goto done; - for (i = 0; i < len; i++) { - unsigned int chan = CR_CHAN(s->async->cmd.chanlist[i]); + for (i = 0; i < cmd->chanlist_len; i++) { + unsigned int chan = CR_CHAN(cmd->chanlist[i]); if (triggered & (1 << chan)) val |= (1 << i); } -- cgit v1.2.3 From aecbc17285caeae98d5e729d02fdc93ded7a0186 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:30:56 -0700 Subject: staging: comedi: pcmmio: use comedi_cmd pointer Use a local variable to access the comedi_cmd as a pointer instead of getting to from the comedi_subdevice pointer. Remove the unnecessary local variables used for the cmd->chanlist_len. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcmmio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c index 2d185136db78..76b67a6e8ca8 100644 --- a/drivers/staging/comedi/drivers/pcmmio.c +++ b/drivers/staging/comedi/drivers/pcmmio.c @@ -339,8 +339,8 @@ static void pcmmio_handle_dio_intr(struct comedi_device *dev, unsigned int triggered) { struct pcmmio_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; unsigned int oldevents = s->async->events; - unsigned int len = s->async->cmd.chanlist_len; unsigned int val = 0; unsigned long flags; int i; @@ -353,8 +353,8 @@ static void pcmmio_handle_dio_intr(struct comedi_device *dev, if (!(triggered & devpriv->enabled_mask)) goto done; - for (i = 0; i < len; i++) { - unsigned int chan = CR_CHAN(s->async->cmd.chanlist[i]); + for (i = 0; i < cmd->chanlist_len; i++) { + unsigned int chan = CR_CHAN(cmd->chanlist[i]); if (triggered & (1 << chan)) val |= (1 << i); -- cgit v1.2.3 From 29791cf5cc0a5d1c7b14dd6b8d31ff584c4b02af Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:30:57 -0700 Subject: staging: comedi: pcmmio: remove 'continuous' from private data This member of the private data can be determined from the cmd->stop_src. Do that instead and remove the member. Refactor pcmmio_handle_dio_intr() to remove an indent level. For aesthetics, change the switch in pcmmio_cmd() to an if/else. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcmmio.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c index 76b67a6e8ca8..fed7e77e0305 100644 --- a/drivers/staging/comedi/drivers/pcmmio.c +++ b/drivers/staging/comedi/drivers/pcmmio.c @@ -192,7 +192,6 @@ struct pcmmio_private { unsigned int enabled_mask; unsigned int stop_count; unsigned int active:1; - unsigned int continuous:1; unsigned int ao_readback[8]; }; @@ -371,15 +370,12 @@ static void pcmmio_handle_dio_intr(struct comedi_device *dev, } /* Check for end of acquisition. */ - if (!devpriv->continuous) { - /* stop_src == TRIG_COUNT */ - if (devpriv->stop_count > 0) { - devpriv->stop_count--; - if (devpriv->stop_count == 0) { - s->async->events |= COMEDI_CB_EOA; - /* TODO: STOP_ACQUISITION_CALL_HERE!! */ - pcmmio_stop_intr(dev, s); - } + if (cmd->stop_src == TRIG_COUNT && devpriv->stop_count > 0) { + devpriv->stop_count--; + if (devpriv->stop_count == 0) { + s->async->events |= COMEDI_CB_EOA; + /* TODO: STOP_ACQUISITION_CALL_HERE!! */ + pcmmio_stop_intr(dev, s); } } @@ -421,7 +417,7 @@ static int pcmmio_start_intr(struct comedi_device *dev, unsigned int pol_bits = 0; int i; - if (!devpriv->continuous && devpriv->stop_count == 0) { + if (cmd->stop_src == TRIG_COUNT && devpriv->stop_count == 0) { /* An empty acquisition! */ s->async->events |= COMEDI_CB_EOA; devpriv->active = 0; @@ -502,17 +498,10 @@ static int pcmmio_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->active = 1; /* Set up end of acquisition. */ - switch (cmd->stop_src) { - case TRIG_COUNT: - devpriv->continuous = 0; + if (cmd->stop_src == TRIG_COUNT) devpriv->stop_count = cmd->stop_arg; - break; - default: - /* TRIG_NONE */ - devpriv->continuous = 1; + else /* TRIG_NONE */ devpriv->stop_count = 0; - break; - } /* Set up start of acquisition. */ if (cmd->start_src == TRIG_INT) -- cgit v1.2.3 From b5fc9c1031407010ea308be15342bd01b848a853 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:30:58 -0700 Subject: staging: comedi: pcl816: fix DMA 'bytes' calculation The calculation for the total number of bytes in the DMA transfer is incorrect. Fix it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 3742f5f78fc6..9c1b963a0bed 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -164,9 +164,7 @@ static void pcl816_ai_setup_dma(struct comedi_device *dev, bytes = devpriv->hwdmasize; if (cmd->stop_src == TRIG_COUNT) { /* how many */ - bytes = s->async->cmd.chanlist_len * - s->async->cmd.chanlist_len * - sizeof(short); + bytes = cmd->stop_arg * cmd->chanlist_len * sizeof(short); /* how many DMA pages we must fill */ devpriv->dma_runs_to_end = bytes / devpriv->hwdmasize; -- cgit v1.2.3 From ae2348e22824529112b50cbbda7451749b185479 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:30:59 -0700 Subject: staging: comedi: pcl711: use comedi_cmd pointer Use a local variable to access the comedi_cmd as a pointer instead of getting to from the comedi_subdevice pointer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl711.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c index d879052b1b23..c38d97a9a899 100644 --- a/drivers/staging/comedi/drivers/pcl711.c +++ b/drivers/staging/comedi/drivers/pcl711.c @@ -202,6 +202,7 @@ static irqreturn_t pcl711_interrupt(int irq, void *d) struct comedi_device *dev = d; struct pcl711_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; + struct comedi_cmd *cmd = &s->async->cmd; unsigned int data; if (!dev->attached) { @@ -217,8 +218,7 @@ static irqreturn_t pcl711_interrupt(int irq, void *d) s->async->events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR; } else { s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS; - if (s->async->cmd.stop_src == TRIG_COUNT && - !(--devpriv->ntrig)) { + if (cmd->stop_src == TRIG_COUNT && !(--devpriv->ntrig)) { pcl711_ai_set_mode(dev, PCL711_MODE_SOFTTRIG); s->async->events |= COMEDI_CB_EOA; } -- cgit v1.2.3 From 9663ab1f9fda4b53cfbfe7a0b196b6d0c1de8efa Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:31:00 -0700 Subject: staging: comedi: ni_mio_common: use comedi_cmd pointer Use a local variable to access the comedi_cmd as a pointer instead of getting to from the comedi_async pointer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 9afe76f2c7c8..7ffdcc07ef92 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -1468,10 +1468,11 @@ static void ni_ai_munge(struct comedi_device *dev, struct comedi_subdevice *s, { struct ni_private *devpriv = dev->private; struct comedi_async *async = s->async; - unsigned int i; + struct comedi_cmd *cmd = &async->cmd; unsigned int length = num_bytes / bytes_per_sample(s); unsigned short *array = data; unsigned int *larray = data; + unsigned int i; for (i = 0; i < length; i++) { #ifdef PCIDMA @@ -1485,7 +1486,7 @@ static void ni_ai_munge(struct comedi_device *dev, struct comedi_subdevice *s, else array[i] += devpriv->ai_offset[chan_index]; chan_index++; - chan_index %= async->cmd.chanlist_len; + chan_index %= cmd->chanlist_len; } } @@ -2710,22 +2711,22 @@ static void ni_ao_munge(struct comedi_device *dev, struct comedi_subdevice *s, { const struct ni_board_struct *board = comedi_board(dev); struct comedi_async *async = s->async; - unsigned int range; - unsigned int i; - unsigned int offset; + struct comedi_cmd *cmd = &async->cmd; unsigned int length = num_bytes / sizeof(short); + unsigned int offset = 1 << (board->aobits - 1); unsigned short *array = data; + unsigned int range; + unsigned int i; - offset = 1 << (board->aobits - 1); for (i = 0; i < length; i++) { - range = CR_RANGE(async->cmd.chanlist[chan_index]); + range = CR_RANGE(cmd->chanlist[chan_index]); if (board->ao_unipolar == 0 || (range & 1) == 0) array[i] -= offset; #ifdef PCIDMA array[i] = cpu_to_le16(array[i]); #endif chan_index++; - chan_index %= async->cmd.chanlist_len; + chan_index %= cmd->chanlist_len; } } -- cgit v1.2.3 From 3cd3195251e7c21c2e258f04440483478de3e286 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:31:01 -0700 Subject: staging: comedi: ni_labpc_isadma: use comedi_cmd pointer Use a local variable to access the comedi_cmd as a pointer instead of getting to from the comedi_async pointer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc_isadma.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc_isadma.c b/drivers/staging/comedi/drivers/ni_labpc_isadma.c index 2149596830af..d9f25fdbb728 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_isadma.c +++ b/drivers/staging/comedi/drivers/ni_labpc_isadma.c @@ -87,6 +87,7 @@ void labpc_drain_dma(struct comedi_device *dev) struct labpc_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; struct comedi_async *async = s->async; + struct comedi_cmd *cmd = &async->cmd; int status; unsigned long flags; unsigned int max_points, num_points, residue, leftover; @@ -108,12 +109,12 @@ void labpc_drain_dma(struct comedi_device *dev) */ residue = get_dma_residue(devpriv->dma_chan) / sample_size; num_points = max_points - residue; - if (devpriv->count < num_points && async->cmd.stop_src == TRIG_COUNT) + if (cmd->stop_src == TRIG_COUNT && devpriv->count < num_points) num_points = devpriv->count; /* figure out how many points will be stored next time */ leftover = 0; - if (async->cmd.stop_src != TRIG_COUNT) { + if (cmd->stop_src != TRIG_COUNT) { leftover = devpriv->dma_transfer_size / sample_size; } else if (devpriv->count > num_points) { leftover = devpriv->count - num_points; @@ -125,7 +126,7 @@ void labpc_drain_dma(struct comedi_device *dev) for (i = 0; i < num_points; i++) cfc_write_to_buffer(s, devpriv->dma_buffer[i]); - if (async->cmd.stop_src == TRIG_COUNT) + if (cmd->stop_src == TRIG_COUNT) devpriv->count -= num_points; /* set address and count for next transfer */ -- cgit v1.2.3 From b727a91f59df86f022f868522fd0d1f9d294ca0b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:31:02 -0700 Subject: staging: comedi: ni_labpc: use comedi_cmd pointer Use a local variable to access the comedi_cmd as a pointer instead of getting to from the comedi_async pointer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index c6e914dc70cf..3e3f940fa57c 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -874,8 +874,9 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) static int labpc_drain_fifo(struct comedi_device *dev) { struct labpc_private *devpriv = dev->private; - unsigned short data; struct comedi_async *async = dev->read_subdev->async; + struct comedi_cmd *cmd = &async->cmd; + unsigned short data; const int timeout = 10000; unsigned int i; @@ -884,7 +885,7 @@ static int labpc_drain_fifo(struct comedi_device *dev) for (i = 0; (devpriv->stat1 & STAT1_DAVAIL) && i < timeout; i++) { /* quit if we have all the data we want */ - if (async->cmd.stop_src == TRIG_COUNT) { + if (cmd->stop_src == TRIG_COUNT) { if (devpriv->count == 0) break; devpriv->count--; -- cgit v1.2.3 From 421ab41bce410854363a43afc49e5d95832ef887 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:31:03 -0700 Subject: staging: comedi: cb_pcidas64: use comedi_cmd pointer Use a local variable to access the comedi_cmd as a pointer instead of getting to from the comedi_async pointer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index aca1e69009a8..63b00cf3bd87 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -2723,6 +2723,7 @@ static void drain_dma_buffers(struct comedi_device *dev, unsigned int channel) const struct pcidas64_board *thisboard = comedi_board(dev); struct pcidas64_private *devpriv = dev->private; struct comedi_async *async = dev->read_subdev->async; + struct comedi_cmd *cmd = &async->cmd; uint32_t next_transfer_addr; int j; int num_samples = 0; @@ -2744,7 +2745,7 @@ static void drain_dma_buffers(struct comedi_device *dev, unsigned int channel) DMA_BUFFER_SIZE) && j < ai_dma_ring_count(thisboard); j++) { /* transfer data from dma buffer to comedi buffer */ num_samples = dma_transfer_size(dev); - if (async->cmd.stop_src == TRIG_COUNT) { + if (cmd->stop_src == TRIG_COUNT) { if (num_samples > devpriv->ai_count) num_samples = devpriv->ai_count; devpriv->ai_count -= num_samples; -- cgit v1.2.3 From f5f3a2c6569eb336e0638513ae9ccc68532c632f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:31:04 -0700 Subject: staging: comedi: cb_pcidas64: change params to external_ai_queue_in_use() The caller already has the comedi_subdevice and comedi_cmd pointers. Pass those variables to the helper function. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 63b00cf3bd87..035c3a176005 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -3205,15 +3205,17 @@ static int prep_ao_dma(struct comedi_device *dev, const struct comedi_cmd *cmd) return 0; } -static inline int external_ai_queue_in_use(struct comedi_device *dev) +static inline int external_ai_queue_in_use(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) { const struct pcidas64_board *thisboard = comedi_board(dev); - if (dev->read_subdev->busy) + if (s->busy) return 0; if (thisboard->layout == LAYOUT_4020) return 0; - else if (use_internal_queue_6xxx(&dev->read_subdev->async->cmd)) + else if (use_internal_queue_6xxx(cmd)) return 0; return 1; } @@ -3247,7 +3249,7 @@ static int ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) struct pcidas64_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - if (external_ai_queue_in_use(dev)) { + if (external_ai_queue_in_use(dev, s, cmd)) { warn_external_queue(dev); return -EBUSY; } -- cgit v1.2.3 From 3ba01fe6188196be85d0a384395c7b5a0f4b8546 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:31:05 -0700 Subject: staging: comedi: comedi_fc: use comedi_cmd pointer Use a local variable to access the comedi_cmd as a pointer instead of getting to from the comedi_subdevice pointer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_fc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_fc.c b/drivers/staging/comedi/drivers/comedi_fc.c index cf3da2cb0cc1..c33c3e5680a6 100644 --- a/drivers/staging/comedi/drivers/comedi_fc.c +++ b/drivers/staging/comedi/drivers/comedi_fc.c @@ -24,7 +24,7 @@ unsigned int cfc_bytes_per_scan(struct comedi_subdevice *s) { - unsigned int chanlist_len = s->async->cmd.chanlist_len; + struct comedi_cmd *cmd = &s->async->cmd; unsigned int num_samples; unsigned int bits_per_sample; @@ -33,11 +33,11 @@ unsigned int cfc_bytes_per_scan(struct comedi_subdevice *s) case COMEDI_SUBD_DO: case COMEDI_SUBD_DIO: bits_per_sample = 8 * bytes_per_sample(s); - num_samples = (chanlist_len + bits_per_sample - 1) / + num_samples = (cmd->chanlist_len + bits_per_sample - 1) / bits_per_sample; break; default: - num_samples = chanlist_len; + num_samples = cmd->chanlist_len; break; } return num_samples * bytes_per_sample(s); -- cgit v1.2.3 From 35a51030995157dc03142ae6f9e17741b0224beb Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:31:06 -0700 Subject: staging: comedi: amplc_pci224: use cfc_bytes_per_scan() The cmd->chanlist_len will always be >= 1 in this function. Remove the unnecessary checks. Use the comedi_fc helper function to get the 'bytes_per_scan'. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci224.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index 44904fd87b27..339c47c1eb97 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -545,18 +545,12 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, { struct pci224_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; + unsigned int bytes_per_scan = cfc_bytes_per_scan(s); unsigned int num_scans; unsigned int room; unsigned short dacstat; unsigned int i, n; - unsigned int bytes_per_scan; - if (cmd->chanlist_len) { - bytes_per_scan = cmd->chanlist_len * sizeof(short); - } else { - /* Shouldn't get here! */ - bytes_per_scan = sizeof(short); - } /* Determine number of scans available in buffer. */ num_scans = comedi_buf_read_n_available(s) / bytes_per_scan; if (cmd->stop_src == TRIG_COUNT) { @@ -597,8 +591,7 @@ 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) - room /= cmd->chanlist_len; + room /= cmd->chanlist_len; /* Determine how many scans to process. */ if (num_scans > room) -- cgit v1.2.3 From b7a775f815f2469b40636369e73c9e3db2a045d9 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:31:07 -0700 Subject: staging: comedi: amplc_pci230: use cfc_bytes_per_scan() Use the comedi_fc helper function to get the 'bytes_per_scan'. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci230.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 9c8254386704..3895bc7cb3e3 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -1197,15 +1197,13 @@ static int pci230_handle_ao_fifo(struct comedi_device *dev, unsigned int room; unsigned short dacstat; unsigned int i, n; - unsigned int bytes_per_scan; unsigned int events = 0; int running; /* Get DAC FIFO status. */ dacstat = inw(dev->iobase + PCI230_DACCON); /* Determine number of scans available in buffer. */ - bytes_per_scan = cmd->chanlist_len * sizeof(short); - num_scans = comedi_buf_read_n_available(s) / bytes_per_scan; + num_scans = comedi_buf_read_n_available(s) / cfc_bytes_per_scan(s); if (cmd->stop_src == TRIG_COUNT) { /* Fixed number of scans. */ if (num_scans > devpriv->ao_scan_count) -- cgit v1.2.3 From 4bc030446fd6d4ad3d719228f2f30be2b989c575 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:31:09 -0700 Subject: staging: comedi: das16: use cfc_bytes_per_scan() Use the comedi_fc helper to get the number of bytes per scan. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index f40d42298a11..2feecf199f27 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -762,8 +762,7 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s) return -1; } - devpriv->adc_byte_count = - cmd->stop_arg * cmd->chanlist_len * sizeof(uint16_t); + devpriv->adc_byte_count = cmd->stop_arg * cfc_bytes_per_scan(s); if (devpriv->can_burst) outb(DAS1600_CONV_DISABLE, dev->iobase + DAS1600_CONV_REG); -- cgit v1.2.3 From 897d21b9ac61e6199e03da67c2307553db0736bf Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:31:10 -0700 Subject: staging: comedi: pcl812: use cfc_bytes_per_scan() Use the comedi_fc helper to get the number of bytes per scan. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 3338e5d613b0..4c1b94706478 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -557,10 +557,8 @@ static void pcl812_ai_setup_dma(struct comedi_device *dev, /* we use EOS, so adapt DMA buffer to one scan */ if (devpriv->ai_eos) { - devpriv->dmabytestomove[0] = - cmd->chanlist_len * sizeof(short); - devpriv->dmabytestomove[1] = - cmd->chanlist_len * sizeof(short); + devpriv->dmabytestomove[0] = cfc_bytes_per_scan(s); + devpriv->dmabytestomove[1] = cfc_bytes_per_scan(s); devpriv->dma_runs_to_end = 1; } else { devpriv->dmabytestomove[0] = devpriv->hwdmasize; @@ -575,8 +573,7 @@ static void pcl812_ai_setup_dma(struct comedi_device *dev, devpriv->dma_runs_to_end = 1; } else { /* how many samples we must transfer? */ - bytes = cmd->chanlist_len * - cmd->stop_arg * sizeof(short); + bytes = cmd->stop_arg * cfc_bytes_per_scan(s); /* how many DMA pages we must fill */ devpriv->dma_runs_to_end = -- cgit v1.2.3 From 4acaec1cfa57fb44ede0fea52f242bd4a9a1422d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:31:11 -0700 Subject: staging: comedi: pcl816: use cfc_bytes_per_scan() Use the comedi_fc helper to get the number of bytes per scan. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 9c1b963a0bed..d9ca7fe16c96 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -164,7 +164,7 @@ static void pcl816_ai_setup_dma(struct comedi_device *dev, bytes = devpriv->hwdmasize; if (cmd->stop_src == TRIG_COUNT) { /* how many */ - bytes = cmd->stop_arg * cmd->chanlist_len * sizeof(short); + bytes = cmd->stop_arg * cfc_bytes_per_scan(s); /* how many DMA pages we must fill */ devpriv->dma_runs_to_end = bytes / devpriv->hwdmasize; -- cgit v1.2.3 From 42e21c974377e2188888d88b2cf2d3c95033d9d7 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:31:12 -0700 Subject: staging: comedi: pcl818: use cfc_bytes_per_scan() Use the comedi_fc helper to get the number of bytes per scan. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl818.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 48b81c39c6a8..7d00ae639d38 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -353,7 +353,7 @@ static void pcl818_ai_setup_dma(struct comedi_device *dev, disable_dma(devpriv->dma); /* disable dma */ bytes = devpriv->hwdmasize; if (cmd->stop_src == TRIG_COUNT) { - bytes = cmd->chanlist_len * cmd->stop_arg * sizeof(short); + bytes = cmd->stop_arg * cfc_bytes_per_scan(s); devpriv->dma_runs_to_end = bytes / devpriv->hwdmasize; devpriv->last_dma_run = bytes % devpriv->hwdmasize; devpriv->dma_runs_to_end--; -- cgit v1.2.3 From 71cf2b4aaa1c1055ade82917972832f70180cfcb Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:31:13 -0700 Subject: staging: comedi: usbduxfast: remove unreachable code in usbduxfast_ai_cmd() The (*do_cmdtest) validates that the 'stop_arg' is >= 1 for a 'stop_src' of TRIG_COUNT and the 'scan_end_arg' is validated to be the 'chanlist_len' which will always be >= 1. Remove the unreachable error code for an 'ai_sample_count < 1'. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxfast.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c index 376d14608926..85f9dcf59403 100644 --- a/drivers/staging/comedi/drivers/usbduxfast.c +++ b/drivers/staging/comedi/drivers/usbduxfast.c @@ -809,18 +809,11 @@ static int usbduxfast_ai_cmd(struct comedi_device *dev, up(&devpriv->sem); return result; } - if (cmd->stop_src == TRIG_COUNT) { + + if (cmd->stop_src == TRIG_COUNT) devpriv->ai_sample_count = cmd->stop_arg * cmd->scan_end_arg; - if (devpriv->ai_sample_count < 1) { - dev_err(dev->class_dev, - "(cmd->stop_arg)*(cmd->scan_end_arg)<1, aborting\n"); - up(&devpriv->sem); - return -EFAULT; - } - } else { - /* continous acquisition */ + else /* TRIG_NONE */ devpriv->ai_sample_count = 0; - } if ((cmd->start_src == TRIG_NOW) || (cmd->start_src == TRIG_EXT)) { /* enable this acquisition operation */ -- cgit v1.2.3 From 9a8805bb80cff97741b9f45a1195cd2eddbe6525 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 27 May 2014 10:31:14 -0700 Subject: staging: comedi: adl_pci9111: factor fifo handling out of pci9111_interrupt() Factor the fifo half-full handling out of the interrupt function to reduce the indent level of the code. Tidy up the factored out code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9111.c | 128 +++++++++++++-------------- 1 file changed, 60 insertions(+), 68 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index bb1d56e887ba..584fd57ecb70 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -531,6 +531,64 @@ static void pci9111_ai_munge(struct comedi_device *dev, array[i] = ((array[i] >> shift) & maxdata) ^ invert; } +static void pci9111_handle_fifo_half_full(struct comedi_device *dev, + struct comedi_subdevice *s) +{ + struct pci9111_private_data *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; + unsigned int total = 0; + unsigned int samples; + + if (cmd->stop_src == TRIG_COUNT && + PCI9111_FIFO_HALF_SIZE > devpriv->stop_counter) + samples = devpriv->stop_counter; + else + samples = PCI9111_FIFO_HALF_SIZE; + + insw(dev->iobase + PCI9111_AI_FIFO_REG, + devpriv->ai_bounce_buffer, samples); + + if (devpriv->scan_delay < 1) { + total = cfc_write_array_to_buffer(s, + devpriv->ai_bounce_buffer, + samples * sizeof(short)); + } else { + unsigned int pos = 0; + unsigned int to_read; + + while (pos < samples) { + if (devpriv->chunk_counter < cmd->chanlist_len) { + to_read = cmd->chanlist_len - + devpriv->chunk_counter; + + if (to_read > samples - pos) + to_read = samples - pos; + + total += cfc_write_array_to_buffer(s, + devpriv->ai_bounce_buffer + pos, + to_read * sizeof(short)); + } else { + to_read = devpriv->chunk_num_samples - + devpriv->chunk_counter; + + if (to_read > samples - pos) + to_read = samples - pos; + + total += to_read * sizeof(short); + } + + pos += to_read; + devpriv->chunk_counter += to_read; + + if (devpriv->chunk_counter >= + devpriv->chunk_num_samples) + devpriv->chunk_counter = 0; + } + } + + devpriv->stop_counter -= total / sizeof(short); +} + static irqreturn_t pci9111_interrupt(int irq, void *p_device) { struct comedi_device *dev = p_device; @@ -581,74 +639,8 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device) } /* '0' means FIFO is half-full */ - if (!(status & PCI9111_AI_STAT_FF_HF)) { - unsigned int num_samples; - unsigned int bytes_written = 0; - - if (cmd->stop_src == TRIG_COUNT && - PCI9111_FIFO_HALF_SIZE > dev_private->stop_counter) - num_samples = dev_private->stop_counter; - else - num_samples = PCI9111_FIFO_HALF_SIZE; - insw(dev->iobase + PCI9111_AI_FIFO_REG, - dev_private->ai_bounce_buffer, num_samples); - - if (dev_private->scan_delay < 1) { - bytes_written = - cfc_write_array_to_buffer(s, - dev_private-> - ai_bounce_buffer, - num_samples * - sizeof(short)); - } else { - int position = 0; - int to_read; - - while (position < num_samples) { - if (dev_private->chunk_counter < - cmd->chanlist_len) { - to_read = cmd->chanlist_len - - dev_private->chunk_counter; - - if (to_read > - num_samples - position) - to_read = - num_samples - - position; - - bytes_written += - cfc_write_array_to_buffer - (s, - dev_private->ai_bounce_buffer - + position, - to_read * sizeof(short)); - } else { - to_read = - dev_private->chunk_num_samples - - - dev_private->chunk_counter; - if (to_read > - num_samples - position) - to_read = - num_samples - - position; - - bytes_written += - sizeof(short) * to_read; - } - - position += to_read; - dev_private->chunk_counter += to_read; - - if (dev_private->chunk_counter >= - dev_private->chunk_num_samples) - dev_private->chunk_counter = 0; - } - } - - dev_private->stop_counter -= - bytes_written / sizeof(short); - } + if (!(status & PCI9111_AI_STAT_FF_HF)) + pci9111_handle_fifo_half_full(dev, s); } if (cmd->stop_src == TRIG_COUNT && dev_private->stop_counter == 0) -- cgit v1.2.3 From 7bbf567071d994090af33eb0a38d962d5e199827 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 28 May 2014 16:58:18 +0530 Subject: staging: rtl8188eu: Remove unneeded version.h inclusion version.h inclusion is not needed as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/xmit_linux.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c index 91723802dffd..400356831c5e 100644 --- a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c @@ -19,7 +19,6 @@ ******************************************************************************/ #define _XMIT_OSDEP_C_ -#include #include #include -- cgit v1.2.3 From 7b38ba17eb071ba02edbbadc3eac4fe8ab53803a Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 28 May 2014 17:09:01 +0530 Subject: staging: rtl8723au: Remove duplicate inclusion of wlan_bssdef.h wlan_bssdef.h was included twice. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/drv_types.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8723au/include/drv_types.h b/drivers/staging/rtl8723au/include/drv_types.h index 49add5ffbb2b..a94857df2def 100644 --- a/drivers/staging/rtl8723au/include/drv_types.h +++ b/drivers/staging/rtl8723au/include/drv_types.h @@ -38,7 +38,6 @@ enum _NIC_VERSION { #include #include -#include #include #include #include -- cgit v1.2.3 From 3151878e843646f67dc1aec413be9b7b699892df Mon Sep 17 00:00:00 2001 From: Robin Schroer Date: Wed, 28 May 2014 14:52:45 +0200 Subject: Staging/frontier/tranzport: coding style fixes added newlines after declarations in two places Signed-off-by: Robin Schroer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/frontier/tranzport.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/frontier/tranzport.c b/drivers/staging/frontier/tranzport.c index 334ba04ae44b..2f86163d7013 100644 --- a/drivers/staging/frontier/tranzport.c +++ b/drivers/staging/frontier/tranzport.c @@ -475,6 +475,7 @@ static unsigned int usb_tranzport_poll(struct file *file, poll_table *wait) { struct usb_tranzport *dev; unsigned int mask = 0; + dev = file->private_data; poll_wait(file, &dev->read_wait, wait); poll_wait(file, &dev->write_wait, wait); @@ -937,6 +938,7 @@ static void usb_tranzport_disconnect(struct usb_interface *intf) { struct usb_tranzport *dev; int minor; + mutex_lock(&disconnect_mutex); dev = usb_get_intfdata(intf); usb_set_intfdata(intf, NULL); -- cgit v1.2.3 From fd21c2806bb02397a356a22fe04f98f7006f0fe5 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Mon, 26 May 2014 16:45:47 +0200 Subject: rtl8192ee: btcoexist: remove undefined Kconfig macros There are references to four undefined Kconfig macros in the code. Commit 8542373dccd2 ("Staging: rtl8812ae: remove undefined Kconfig macros") removed identical references from another staging driver, but they resurfaced in rtl8192ee. Remove these again as the checks for them still will always evaluate to false. Signed-off-by: Paul Bolle Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192ee/btcoexist/halbtcoutsrc.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/rtl8192ee/btcoexist/halbtcoutsrc.c b/drivers/staging/rtl8192ee/btcoexist/halbtcoutsrc.c index 9757f138a37f..2d9fc24b1e21 100644 --- a/drivers/staging/rtl8192ee/btcoexist/halbtcoutsrc.c +++ b/drivers/staging/rtl8192ee/btcoexist/halbtcoutsrc.c @@ -736,17 +736,7 @@ bool exhalbtc92e_initlize_variables(struct rtl_priv *adapter) else btcoexist->binded = true; -#if (defined(CONFIG_PCI_HCI)) - btcoexist->chip_interface = BTC_INTF_PCI; -#elif (defined(CONFIG_USB_HCI)) - btcoexist->chip_interface = BTC_INTF_USB; -#elif (defined(CONFIG_SDIO_HCI)) - btcoexist->chip_interface = BTC_INTF_SDIO; -#elif (defined(CONFIG_GSPI_HCI)) - btcoexist->chip_interface = BTC_INTF_GSPI; -#else btcoexist->chip_interface = BTC_INTF_UNKNOWN; -#endif if (NULL == btcoexist->adapter) btcoexist->adapter = adapter; -- cgit v1.2.3 From 654d1ce9189c60294f62cde55a231898639683f3 Mon Sep 17 00:00:00 2001 From: Chaitanya Hazarey Date: Wed, 28 May 2014 07:32:38 -0700 Subject: Staging: rtl8192u: r8192U_wx.c Added missing spaces Added spaces needed in the proper places to address: WARNING: please, no spaces at the start of a line WARNING: missing space after struct definition ERROR: spaces required around that '!=' (ctx:WxV) ERROR: spaces required around that '=' (ctx:WxV) ERROR: spaces required around that '=' (ctx:VxW) ERROR: spaces required around that '&&' (ctx:VxV) ERROR: spaces required around that '!=' (ctx:VxV) ERROR: spaces required around that '=' (ctx:VxV) ERROR: spaces required around that '==' (ctx:VxV) ERROR: spaces required around that '<' (ctx:VxV) ERROR: space required before the open parenthesis '(' ERROR: space required before the open brace '{' ERROR: space required after that ',' (ctx:VxV) ERROR: space required after that close brace '}' ERROR: space prohibited before that '--' (ctx:WxO) ERROR: space prohibited before that close parenthesis ')' ERROR: space prohibited after that open parenthesis '(' Signed-off-by: Chaitanya Hazarey Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_wx.c | 146 +++++++++++++++++------------------ 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_wx.c b/drivers/staging/rtl8192u/r8192U_wx.c index dab716f765fc..1ba03ad36b43 100644 --- a/drivers/staging/rtl8192u/r8192U_wx.c +++ b/drivers/staging/rtl8192u/r8192U_wx.c @@ -24,8 +24,8 @@ #include "dot11d.h" #define RATE_COUNT 12 -u32 rtl8180_rates[] = {1000000,2000000,5500000,11000000, - 6000000,9000000,12000000,18000000,24000000,36000000,48000000,54000000}; +u32 rtl8180_rates[] = {1000000, 2000000, 5500000, 11000000, + 6000000, 9000000, 12000000, 18000000, 24000000, 36000000, 48000000, 54000000}; #ifndef ENETDOWN @@ -38,16 +38,16 @@ static int r8192_wx_get_freq(struct net_device *dev, { struct r8192_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_freq(priv->ieee80211,a,wrqu,b); + return ieee80211_wx_get_freq(priv->ieee80211, a, wrqu, b); } static int r8192_wx_get_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct r8192_priv *priv=ieee80211_priv(dev); + struct r8192_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_mode(priv->ieee80211,a,wrqu,b); + return ieee80211_wx_get_mode(priv->ieee80211, a, wrqu, b); } @@ -57,7 +57,7 @@ static int r8192_wx_get_rate(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_rate(priv->ieee80211,info,wrqu,extra); + return ieee80211_wx_get_rate(priv->ieee80211, info, wrqu, extra); } @@ -71,7 +71,7 @@ static int r8192_wx_set_rate(struct net_device *dev, down(&priv->wx_sem); - ret = ieee80211_wx_set_rate(priv->ieee80211,info,wrqu,extra); + ret = ieee80211_wx_set_rate(priv->ieee80211, info, wrqu, extra); up(&priv->wx_sem); @@ -88,7 +88,7 @@ static int r8192_wx_set_rts(struct net_device *dev, down(&priv->wx_sem); - ret = ieee80211_wx_set_rts(priv->ieee80211,info,wrqu,extra); + ret = ieee80211_wx_set_rts(priv->ieee80211, info, wrqu, extra); up(&priv->wx_sem); @@ -100,7 +100,7 @@ static int r8192_wx_get_rts(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_rts(priv->ieee80211,info,wrqu,extra); + return ieee80211_wx_get_rts(priv->ieee80211, info, wrqu, extra); } static int r8192_wx_set_power(struct net_device *dev, @@ -112,7 +112,7 @@ static int r8192_wx_set_power(struct net_device *dev, down(&priv->wx_sem); - ret = ieee80211_wx_set_power(priv->ieee80211,info,wrqu,extra); + ret = ieee80211_wx_set_power(priv->ieee80211, info, wrqu, extra); up(&priv->wx_sem); @@ -124,7 +124,7 @@ static int r8192_wx_get_power(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_power(priv->ieee80211,info,wrqu,extra); + return ieee80211_wx_get_power(priv->ieee80211, info, wrqu, extra); } static int r8192_wx_force_reset(struct net_device *dev, @@ -135,7 +135,7 @@ static int r8192_wx_force_reset(struct net_device *dev, down(&priv->wx_sem); - printk("%s(): force reset ! extra is %d\n",__func__, *extra); + printk("%s(): force reset ! extra is %d\n", __func__, *extra); priv->force_reset = *extra; up(&priv->wx_sem); return 0; @@ -171,15 +171,15 @@ static int r8192_wx_set_crcmon(struct net_device *dev, down(&priv->wx_sem); - if(enable) - priv->crcmon=1; + if (enable) + priv->crcmon = 1; else - priv->crcmon=0; + priv->crcmon = 0; DMESG("bad CRC in monitor mode are %s", priv->crcmon ? "accepted" : "rejected"); - if(prev != priv->crcmon && priv->up){ + if (prev != priv->crcmon && priv->up) { //rtl8180_down(dev); //rtl8180_up(dev); } @@ -196,7 +196,7 @@ static int r8192_wx_set_mode(struct net_device *dev, struct iw_request_info *a, int ret; down(&priv->wx_sem); - ret = ieee80211_wx_set_mode(priv->ieee80211,a,wrqu,b); + ret = ieee80211_wx_set_mode(priv->ieee80211, a, wrqu, b); rtl8192_set_rxconf(dev); @@ -258,7 +258,7 @@ static int rtl8180_wx_get_range(struct net_device *dev, // range->old_num_channels; // range->old_num_frequency; // range->old_freq[6]; /* Filler to keep "version" at the same offset */ - if(priv->rf_set_sens != NULL) + if (priv->rf_set_sens != NULL) range->sensitivity = priv->max_sens; /* signal level threshold range */ range->max_qual.qual = 100; @@ -281,7 +281,7 @@ static int rtl8180_wx_get_range(struct net_device *dev, range->min_frag = MIN_FRAG_THRESHOLD; range->max_frag = MAX_FRAG_THRESHOLD; - range->min_pmp=0; + range->min_pmp = 0; range->max_pmp = 5000000; range->min_pmt = 0; range->max_pmt = 65535*1000; @@ -333,7 +333,7 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a, struct ieee80211_device *ieee = priv->ieee80211; int ret = 0; - if(!priv->up) return -ENETDOWN; + if (!priv->up) return -ENETDOWN; if (priv->ieee80211->LinkDetectInfo.bBusyTraffic == true) return -EAGAIN; @@ -350,13 +350,13 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a, } down(&priv->wx_sem); - if(priv->ieee80211->state != IEEE80211_LINKED){ + if (priv->ieee80211->state != IEEE80211_LINKED) { priv->ieee80211->scanning = 0; ieee80211_softmac_scan_syncro(priv->ieee80211); ret = 0; } else - ret = ieee80211_wx_set_scan(priv->ieee80211,a,wrqu,b); + ret = ieee80211_wx_set_scan(priv->ieee80211, a, wrqu, b); up(&priv->wx_sem); return ret; } @@ -369,11 +369,11 @@ static int r8192_wx_get_scan(struct net_device *dev, struct iw_request_info *a, int ret; struct r8192_priv *priv = ieee80211_priv(dev); - if(!priv->up) return -ENETDOWN; + if (!priv->up) return -ENETDOWN; down(&priv->wx_sem); - ret = ieee80211_wx_get_scan(priv->ieee80211,a,wrqu,b); + ret = ieee80211_wx_get_scan(priv->ieee80211, a, wrqu, b); up(&priv->wx_sem); @@ -388,7 +388,7 @@ static int r8192_wx_set_essid(struct net_device *dev, int ret; down(&priv->wx_sem); - ret = ieee80211_wx_set_essid(priv->ieee80211,a,wrqu,b); + ret = ieee80211_wx_set_essid(priv->ieee80211, a, wrqu, b); up(&priv->wx_sem); @@ -483,7 +483,7 @@ static int r8192_wx_set_wap(struct net_device *dev, // struct sockaddr *temp = (struct sockaddr *)awrq; down(&priv->wx_sem); - ret = ieee80211_wx_set_wap(priv->ieee80211,info,awrq,extra); + ret = ieee80211_wx_set_wap(priv->ieee80211, info, awrq, extra); up(&priv->wx_sem); @@ -498,7 +498,7 @@ static int r8192_wx_get_wap(struct net_device *dev, { struct r8192_priv *priv = ieee80211_priv(dev); - return ieee80211_wx_get_wap(priv->ieee80211,info,wrqu,extra); + return ieee80211_wx_get_wap(priv->ieee80211, info, wrqu, extra); } @@ -520,34 +520,34 @@ static int r8192_wx_set_enc(struct net_device *dev, int ret; //u32 TargetContent; - u32 hwkey[4]={0,0,0,0}; - u8 mask=0xff; - u32 key_idx=0; + u32 hwkey[4] = {0, 0, 0, 0}; + u8 mask = 0xff; + u32 key_idx = 0; //u8 broadcast_addr[6] ={ 0xff,0xff,0xff,0xff,0xff,0xff}; - u8 zero_addr[4][6] ={ {0x00,0x00,0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x01}, - {0x00,0x00,0x00,0x00,0x00,0x02}, - {0x00,0x00,0x00,0x00,0x00,0x03} }; + u8 zero_addr[4][6] = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x02}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x03} }; int i; - if(!priv->up) return -ENETDOWN; + if (!priv->up) return -ENETDOWN; down(&priv->wx_sem); RT_TRACE(COMP_SEC, "Setting SW wep key"); - ret = ieee80211_wx_set_encode(priv->ieee80211,info,wrqu,key); + ret = ieee80211_wx_set_encode(priv->ieee80211, info, wrqu, key); up(&priv->wx_sem); //sometimes, the length is zero while we do not type key value - if(wrqu->encoding.length!=0){ + if (wrqu->encoding.length != 0) { - for(i=0 ; i<4 ; i++){ + for (i = 0; i < 4; i++) { hwkey[i] |= key[4*i+0]&mask; - if(i==1&&(4*i+1)==wrqu->encoding.length) mask=0x00; - if(i==3&&(4*i+1)==wrqu->encoding.length) mask=0x00; + if (i == 1 && (4*i+1) == wrqu->encoding.length) mask = 0x00; + if (i == 3 && (4*i+1) == wrqu->encoding.length) mask = 0x00; hwkey[i] |= (key[4*i+1]&mask)<<8; hwkey[i] |= (key[4*i+2]&mask)<<16; hwkey[i] |= (key[4*i+3]&mask)<<24; @@ -556,7 +556,7 @@ static int r8192_wx_set_enc(struct net_device *dev, #define CONF_WEP40 0x4 #define CONF_WEP104 0x14 - switch (wrqu->encoding.flags & IW_ENCODE_INDEX){ + switch (wrqu->encoding.flags & IW_ENCODE_INDEX) { case 0: key_idx = ieee->tx_keyidx; break; case 1: key_idx = 0; break; case 2: key_idx = 1; break; @@ -565,11 +565,11 @@ static int r8192_wx_set_enc(struct net_device *dev, default: break; } - if(wrqu->encoding.length==0x5){ + if (wrqu->encoding.length == 0x5) { ieee->pairwise_key_type = KEY_TYPE_WEP40; EnableHWSecurityConfig8192(dev); - setKey( dev, + setKey(dev, key_idx, //EntryNo key_idx, //KeyIndex KEY_TYPE_WEP40, //KeyType @@ -579,11 +579,11 @@ static int r8192_wx_set_enc(struct net_device *dev, } - else if(wrqu->encoding.length==0xd){ + else if (wrqu->encoding.length == 0xd) { ieee->pairwise_key_type = KEY_TYPE_WEP104; EnableHWSecurityConfig8192(dev); - setKey( dev, + setKey(dev, key_idx, //EntryNo key_idx, //KeyIndex KEY_TYPE_WEP104, //KeyType @@ -601,11 +601,11 @@ static int r8192_wx_set_enc(struct net_device *dev, static int r8192_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union - iwreq_data *wrqu, char *p){ + iwreq_data *wrqu, char *p){ struct r8192_priv *priv = ieee80211_priv(dev); - int *parms=(int *)p; - int mode=parms[0]; + int *parms = (int *)p; + int mode = parms[0]; priv->ieee80211->active_scan = mode; @@ -628,20 +628,20 @@ static int r8192_wx_set_retry(struct net_device *dev, err = -EINVAL; goto exit; } - if (!(wrqu->retry.flags & IW_RETRY_LIMIT)){ + if (!(wrqu->retry.flags & IW_RETRY_LIMIT)) { err = -EINVAL; goto exit; } - if(wrqu->retry.value > R8180_MAX_RETRY){ - err= -EINVAL; + if (wrqu->retry.value > R8180_MAX_RETRY) { + err = -EINVAL; goto exit; } if (wrqu->retry.flags & IW_RETRY_MAX) { priv->retry_rts = wrqu->retry.value; DMESG("Setting retry for RTS/CTS data to %d", wrqu->retry.value); - }else { + } else { priv->retry_data = wrqu->retry.value; DMESG("Setting retry for non RTS/CTS data to %d", wrqu->retry.value); } @@ -698,7 +698,7 @@ static int r8192_wx_get_sens(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct r8192_priv *priv = ieee80211_priv(dev); - if(priv->rf_set_sens == NULL) + if (priv->rf_set_sens == NULL) return -1; /* we have not this support for this radio */ wrqu->sens.value = priv->sens; return 0; @@ -715,14 +715,14 @@ static int r8192_wx_set_sens(struct net_device *dev, short err = 0; down(&priv->wx_sem); //DMESG("attempt to set sensivity to %ddb",wrqu->sens.value); - if(priv->rf_set_sens == NULL) { - err= -1; /* we have not this support for this radio */ + if (priv->rf_set_sens == NULL) { + err = -1; /* we have not this support for this radio */ goto exit; } - if(priv->rf_set_sens(dev, wrqu->sens.value) == 0) + if (priv->rf_set_sens(dev, wrqu->sens.value) == 0) priv->sens = wrqu->sens.value; else - err= -EINVAL; + err = -EINVAL; exit: up(&priv->wx_sem); @@ -735,7 +735,7 @@ static int r8192_wx_set_enc_ext(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - int ret=0; + int ret = 0; struct r8192_priv *priv = ieee80211_priv(dev); struct ieee80211_device *ieee = priv->ieee80211; //printk("===>%s()\n", __func__); @@ -745,7 +745,7 @@ static int r8192_wx_set_enc_ext(struct net_device *dev, ret = ieee80211_wx_set_encode_ext(priv->ieee80211, info, wrqu, extra); { - u8 broadcast_addr[6] = {0xff,0xff,0xff,0xff,0xff,0xff}; + u8 broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; u8 zero[6] = {0}; u32 key[4] = {0}; struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; @@ -758,22 +758,22 @@ static int r8192_wx_set_enc_ext(struct net_device *dev, alg = (ext->alg == IW_ENCODE_ALG_CCMP)?KEY_TYPE_CCMP:ext->alg; // as IW_ENCODE_ALG_CCMP is defined to be 3 and KEY_TYPE_CCMP is defined to 4; idx = encoding->flags & IW_ENCODE_INDEX; if (idx) - idx --; + idx--; group = ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY; if ((!group) || (IW_MODE_ADHOC == ieee->iw_mode) || (alg == KEY_TYPE_WEP40)) { - if ((ext->key_len == 13) && (alg == KEY_TYPE_WEP40) ) + if ((ext->key_len == 13) && (alg == KEY_TYPE_WEP40)) alg = KEY_TYPE_WEP104; ieee->pairwise_key_type = alg; EnableHWSecurityConfig8192(dev); } memcpy((u8 *)key, ext->key, 16); //we only get 16 bytes key.why? WB 2008.7.1 - if ((alg & KEY_TYPE_WEP40) && (ieee->auth_mode !=2) ) + if ((alg & KEY_TYPE_WEP40) && (ieee->auth_mode != 2)) { - setKey( dev, + setKey(dev, idx,//EntryNo idx, //KeyIndex alg, //KeyType @@ -784,7 +784,7 @@ static int r8192_wx_set_enc_ext(struct net_device *dev, else if (group) { ieee->group_key_type = alg; - setKey( dev, + setKey(dev, idx,//EntryNo idx, //KeyIndex alg, //KeyType @@ -794,7 +794,7 @@ static int r8192_wx_set_enc_ext(struct net_device *dev, } else //pairwise key { - setKey( dev, + setKey(dev, 4,//EntryNo idx, //KeyIndex alg, //KeyType @@ -816,7 +816,7 @@ static int r8192_wx_set_auth(struct net_device *dev, struct iw_request_info *info, union iwreq_data *data, char *extra) { - int ret=0; + int ret = 0; //printk("====>%s()\n", __func__); struct r8192_priv *priv = ieee80211_priv(dev); down(&priv->wx_sem); @@ -831,7 +831,7 @@ static int r8192_wx_set_mlme(struct net_device *dev, { //printk("====>%s()\n", __func__); - int ret=0; + int ret = 0; struct r8192_priv *priv = ieee80211_priv(dev); down(&priv->wx_sem); ret = ieee80211_wx_set_mlme(priv->ieee80211, info, wrqu, extra); @@ -845,7 +845,7 @@ static int r8192_wx_set_gen_ie(struct net_device *dev, union iwreq_data *data, char *extra) { //printk("====>%s(), len:%d\n", __func__, data->length); - int ret=0; + int ret = 0; struct r8192_priv *priv = ieee80211_priv(dev); down(&priv->wx_sem); ret = ieee80211_wx_set_gen_ie(priv->ieee80211, extra, data->data.length); @@ -857,7 +857,7 @@ static int r8192_wx_set_gen_ie(struct net_device *dev, } static int dummy(struct net_device *dev, struct iw_request_info *a, - union iwreq_data *wrqu,char *b) + union iwreq_data *wrqu, char *b) { return -1; } @@ -965,13 +965,13 @@ static iw_handler r8192_private_handler[] = { struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev) { - struct r8192_priv *priv = ieee80211_priv(dev); + struct r8192_priv *priv = ieee80211_priv(dev); struct ieee80211_device *ieee = priv->ieee80211; struct iw_statistics *wstats = &priv->wstats; int tmp_level = 0; int tmp_qual = 0; int tmp_noise = 0; - if(ieee->state < IEEE80211_LINKED) + if (ieee->state < IEEE80211_LINKED) { wstats->qual.qual = 0; wstats->qual.level = 0; @@ -980,7 +980,7 @@ struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev) return wstats; } - tmp_level = (&ieee->current_network)->stats.rssi; + tmp_level = (&ieee->current_network)->stats.rssi; tmp_qual = (&ieee->current_network)->stats.signal; tmp_noise = (&ieee->current_network)->stats.noise; //printk("level:%d, qual:%d, noise:%d\n", tmp_level, tmp_qual, tmp_noise); @@ -993,7 +993,7 @@ struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev) } -struct iw_handler_def r8192_wx_handlers_def={ +struct iw_handler_def r8192_wx_handlers_def = { .standard = r8192_wx_handlers, .num_standard = ARRAY_SIZE(r8192_wx_handlers), .private = r8192_private_handler, -- cgit v1.2.3 From 28cda5ae0917a31d2e0436fe91901bc82f8e2492 Mon Sep 17 00:00:00 2001 From: Chaitanya Hazarey Date: Wed, 28 May 2014 07:32:39 -0700 Subject: Staging: rtl8192u: r8192U_wx.c Added {} braces and newlines Added {} braces and newlines to address the following: ERROR: else should follow close brace '}' ERROR: space required before the open brace '{' ERROR: trailing statements should be on next line ERROR: space required before the open parenthesis '(' ERROR: that open brace { should be on the previous line Signed-off-by: Chaitanya Hazarey Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_wx.c | 84 ++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 38 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_wx.c b/drivers/staging/rtl8192u/r8192U_wx.c index 1ba03ad36b43..1af7c5d5bb55 100644 --- a/drivers/staging/rtl8192u/r8192U_wx.c +++ b/drivers/staging/rtl8192u/r8192U_wx.c @@ -315,7 +315,7 @@ static int rtl8180_wx_get_range(struct net_device *dev, } if (val == IW_MAX_FREQUENCIES) - break; + break; } range->num_frequency = val; range->num_channels = val; @@ -333,15 +333,14 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a, struct ieee80211_device *ieee = priv->ieee80211; int ret = 0; - if (!priv->up) return -ENETDOWN; + if (!priv->up) + return -ENETDOWN; if (priv->ieee80211->LinkDetectInfo.bBusyTraffic == true) return -EAGAIN; - if (wrqu->data.flags & IW_SCAN_THIS_ESSID) - { + if (wrqu->data.flags & IW_SCAN_THIS_ESSID) { struct iw_scan_req *req = (struct iw_scan_req *)b; - if (req->essid_len) - { + if (req->essid_len) { //printk("==**&*&*&**===>scan set ssid:%s\n", req->essid); ieee->current_network.ssid_len = req->essid_len; memcpy(ieee->current_network.ssid, req->essid, req->essid_len); @@ -354,9 +353,9 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a, priv->ieee80211->scanning = 0; ieee80211_softmac_scan_syncro(priv->ieee80211); ret = 0; + } else { + ret = ieee80211_wx_set_scan(priv->ieee80211, a, wrqu, b); } - else - ret = ieee80211_wx_set_scan(priv->ieee80211, a, wrqu, b); up(&priv->wx_sem); return ret; } @@ -369,7 +368,8 @@ static int r8192_wx_get_scan(struct net_device *dev, struct iw_request_info *a, int ret; struct r8192_priv *priv = ieee80211_priv(dev); - if (!priv->up) return -ENETDOWN; + if (!priv->up) + return -ENETDOWN; down(&priv->wx_sem); @@ -530,7 +530,8 @@ static int r8192_wx_set_enc(struct net_device *dev, {0x00, 0x00, 0x00, 0x00, 0x00, 0x03} }; int i; - if (!priv->up) return -ENETDOWN; + if (!priv->up) + return -ENETDOWN; down(&priv->wx_sem); @@ -546,8 +547,10 @@ static int r8192_wx_set_enc(struct net_device *dev, for (i = 0; i < 4; i++) { hwkey[i] |= key[4*i+0]&mask; - if (i == 1 && (4*i+1) == wrqu->encoding.length) mask = 0x00; - if (i == 3 && (4*i+1) == wrqu->encoding.length) mask = 0x00; + if (i == 1 && (4*i+1) == wrqu->encoding.length) + mask = 0x00; + if (i == 3 && (4*i+1) == wrqu->encoding.length) + mask = 0x00; hwkey[i] |= (key[4*i+1]&mask)<<8; hwkey[i] |= (key[4*i+2]&mask)<<16; hwkey[i] |= (key[4*i+3]&mask)<<24; @@ -557,12 +560,23 @@ static int r8192_wx_set_enc(struct net_device *dev, #define CONF_WEP104 0x14 switch (wrqu->encoding.flags & IW_ENCODE_INDEX) { - case 0: key_idx = ieee->tx_keyidx; break; - case 1: key_idx = 0; break; - case 2: key_idx = 1; break; - case 3: key_idx = 2; break; - case 4: key_idx = 3; break; - default: break; + case 0: + key_idx = ieee->tx_keyidx; + break; + case 1: + key_idx = 0; + break; + case 2: + key_idx = 1; + break; + case 3: + key_idx = 2; + break; + case 4: + key_idx = 3; + break; + default: + break; } if (wrqu->encoding.length == 0x5) { @@ -591,8 +605,9 @@ static int r8192_wx_set_enc(struct net_device *dev, 0, //DefaultKey hwkey); //KeyContent + } else { + printk("wrong type in WEP, not WEP40 and WEP104\n"); } - else printk("wrong type in WEP, not WEP40 and WEP104\n"); } @@ -600,8 +615,8 @@ static int r8192_wx_set_enc(struct net_device *dev, } -static int r8192_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union - iwreq_data *wrqu, char *p){ +static int r8192_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, + union iwreq_data *wrqu, char *p){ struct r8192_priv *priv = ieee80211_priv(dev); int *parms = (int *)p; @@ -751,18 +766,18 @@ static int r8192_wx_set_enc_ext(struct net_device *dev, struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; struct iw_point *encoding = &wrqu->encoding; u8 idx = 0, alg = 0, group = 0; - if ((encoding->flags & IW_ENCODE_DISABLED) || - ext->alg == IW_ENCODE_ALG_NONE) //none is not allowed to use hwsec WB 2008.07.01 + if ((encoding->flags & IW_ENCODE_DISABLED) || ext->alg == IW_ENCODE_ALG_NONE) + //none is not allowed to use hwsec WB 2008.07.01 goto end_hw_sec; - alg = (ext->alg == IW_ENCODE_ALG_CCMP)?KEY_TYPE_CCMP:ext->alg; // as IW_ENCODE_ALG_CCMP is defined to be 3 and KEY_TYPE_CCMP is defined to 4; + // as IW_ENCODE_ALG_CCMP is defined to be 3 and KEY_TYPE_CCMP is defined to 4; + alg = (ext->alg == IW_ENCODE_ALG_CCMP)?KEY_TYPE_CCMP:ext->alg; idx = encoding->flags & IW_ENCODE_INDEX; if (idx) idx--; group = ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY; - if ((!group) || (IW_MODE_ADHOC == ieee->iw_mode) || (alg == KEY_TYPE_WEP40)) - { + if ((!group) || (IW_MODE_ADHOC == ieee->iw_mode) || (alg == KEY_TYPE_WEP40)) { if ((ext->key_len == 13) && (alg == KEY_TYPE_WEP40)) alg = KEY_TYPE_WEP104; ieee->pairwise_key_type = alg; @@ -770,8 +785,7 @@ static int r8192_wx_set_enc_ext(struct net_device *dev, } memcpy((u8 *)key, ext->key, 16); //we only get 16 bytes key.why? WB 2008.7.1 - if ((alg & KEY_TYPE_WEP40) && (ieee->auth_mode != 2)) - { + if ((alg & KEY_TYPE_WEP40) && (ieee->auth_mode != 2)) { setKey(dev, idx,//EntryNo @@ -780,9 +794,7 @@ static int r8192_wx_set_enc_ext(struct net_device *dev, zero, //MacAddr 0, //DefaultKey key); //KeyContent - } - else if (group) - { + } else if (group) { ieee->group_key_type = alg; setKey(dev, idx,//EntryNo @@ -791,9 +803,7 @@ static int r8192_wx_set_enc_ext(struct net_device *dev, broadcast_addr, //MacAddr 0, //DefaultKey key); //KeyContent - } - else //pairwise key - { + } else {//pairwise key setKey(dev, 4,//EntryNo idx, //KeyIndex @@ -863,8 +873,7 @@ static int dummy(struct net_device *dev, struct iw_request_info *a, } -static iw_handler r8192_wx_handlers[] = -{ +static iw_handler r8192_wx_handlers[] = { NULL, /* SIOCSIWCOMMIT */ r8192_wx_get_name, /* SIOCGIWNAME */ dummy, /* SIOCSIWNWID */ @@ -971,8 +980,7 @@ struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev) int tmp_level = 0; int tmp_qual = 0; int tmp_noise = 0; - if (ieee->state < IEEE80211_LINKED) - { + if (ieee->state < IEEE80211_LINKED) { wstats->qual.qual = 0; wstats->qual.level = 0; wstats->qual.noise = 0; -- cgit v1.2.3 From 9a133a9039bf8f65d79937ec05db74d7dd0a069b Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 28 May 2014 16:17:45 -0400 Subject: staging: dgap: misc cleanup of NULL conditionals refactors NULL conditionals Signed-off-by: Mark Hounschell Tested-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 64 ++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 65d651ed7117..7912d9865e22 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -2318,7 +2318,7 @@ static int dgap_tty_chars_in_buffer(struct tty_struct *tty) ulong lock_flags = 0; ulong lock_flags2 = 0; - if (tty == NULL) + if (!tty) return 0; un = tty->driver_data; @@ -2464,7 +2464,7 @@ static int dgap_maxcps_room(struct tty_struct *tty, int bytes_available) struct channel_t *ch; struct un_t *un; - if (tty == NULL) + if (!tty) return bytes_available; un = tty->driver_data; @@ -4140,12 +4140,12 @@ static int dgap_tty_register_ports(struct board_t *brd) brd->serial_ports = kcalloc(brd->nasync, sizeof(*brd->serial_ports), GFP_KERNEL); - if (brd->serial_ports == NULL) + if (!brd->serial_ports) return -ENOMEM; brd->printer_ports = kcalloc(brd->nasync, sizeof(*brd->printer_ports), GFP_KERNEL); - if (brd->printer_ports == NULL) + if (!brd->printer_ports) return -ENOMEM; for (i = 0; i < brd->nasync; i++) { @@ -6524,7 +6524,7 @@ static int dgap_parsefile(char **in, int remove) return -1; } s = dgap_getword(in); - if (s == NULL) { + if (!s) { dgap_err("unexpected end of file"); return -1; } @@ -6542,7 +6542,7 @@ static int dgap_parsefile(char **in, int remove) return -1; } s = dgap_getword(in); - if (s == NULL) { + if (!s) { dgap_err("unexpected end of file"); return -1; } @@ -6560,7 +6560,7 @@ static int dgap_parsefile(char **in, int remove) return -1; } s = dgap_getword(in); - if (s == NULL) { + if (!s) { dgap_err("unexpected end of file"); return -1; } @@ -6571,7 +6571,7 @@ static int dgap_parsefile(char **in, int remove) } p->u.board.v_pcibus = 1; s = dgap_getword(in); - if (s == NULL) { + if (!s) { dgap_err("unexpected end of file"); return -1; } @@ -6589,7 +6589,7 @@ static int dgap_parsefile(char **in, int remove) return -1; } s = dgap_getword(in); - if (s == NULL) { + if (!s) { dgap_err("unexpected end of file"); return -1; } @@ -6603,7 +6603,7 @@ static int dgap_parsefile(char **in, int remove) return -1; } s = dgap_getword(in); - if (s == NULL) { + if (!s) { dgap_err("unexpected end of file"); return -1; } @@ -6613,7 +6613,7 @@ static int dgap_parsefile(char **in, int remove) case NPORTS: /* number of ports */ if (p->type == BNODE) { s = dgap_getword(in); - if (s == NULL) { + if (!s) { dgap_err("unexpected end of file"); return -1; } @@ -6624,7 +6624,7 @@ static int dgap_parsefile(char **in, int remove) p->u.board.v_nport = 1; } else if (p->type == CNODE) { s = dgap_getword(in); - if (s == NULL) { + if (!s) { dgap_err("unexpected end of file"); return -1; } @@ -6635,7 +6635,7 @@ static int dgap_parsefile(char **in, int remove) p->u.conc.v_nport = 1; } else if (p->type == MNODE) { s = dgap_getword(in); - if (s == NULL) { + if (!s) { dgap_err("unexpected end of file"); return -1; } @@ -6652,7 +6652,7 @@ static int dgap_parsefile(char **in, int remove) case ID: /* letter ID used in tty name */ s = dgap_getword(in); - if (s == NULL) { + if (!s) { dgap_err("unexpected end of file"); return -1; } @@ -6674,7 +6674,7 @@ static int dgap_parsefile(char **in, int remove) case STARTO: /* start offset of ID */ if (p->type == BNODE) { s = dgap_getword(in); - if (s == NULL) { + if (!s) { dgap_err("unexpected end of file"); return -1; } @@ -6685,7 +6685,7 @@ static int dgap_parsefile(char **in, int remove) p->u.board.v_start = 1; } else if (p->type == CNODE) { s = dgap_getword(in); - if (s == NULL) { + if (!s) { dgap_err("unexpected end of file"); return -1; } @@ -6696,7 +6696,7 @@ static int dgap_parsefile(char **in, int remove) p->u.conc.v_start = 1; } else if (p->type == MNODE) { s = dgap_getword(in); - if (s == NULL) { + if (!s) { dgap_err("unexpected end of file"); return -1; } @@ -6756,7 +6756,7 @@ static int dgap_parsefile(char **in, int remove) case LINE: /* line information */ if (dgap_checknode(p)) return -1; - if (brd == NULL) { + if (!brd) { dgap_err("must specify board before line info"); return -1; } @@ -6779,7 +6779,7 @@ static int dgap_parsefile(char **in, int remove) case CONC: /* concentrator information */ if (dgap_checknode(p)) return -1; - if (line == NULL) { + if (!line) { dgap_err("must specify line info before concentrator"); return -1; } @@ -6818,7 +6818,7 @@ static int dgap_parsefile(char **in, int remove) case MOD: /* EBI module */ if (dgap_checknode(p)) return -1; - if (brd == NULL) { + if (!brd) { dgap_err("must specify board info before EBI modules"); return -1; } @@ -6827,7 +6827,7 @@ static int dgap_parsefile(char **in, int remove) linecnt = 0; break; default: - if (conc == NULL) { + if (!conc) { dgap_err("must specify concentrator info before EBI module"); return -1; } @@ -6878,7 +6878,7 @@ static int dgap_parsefile(char **in, int remove) case SPEED: /* sync line speed indication */ if (p->type == LNODE) { s = dgap_getword(in); - if (s == NULL) { + if (!s) { dgap_err("unexpected end of file"); return -1; } @@ -6889,7 +6889,7 @@ static int dgap_parsefile(char **in, int remove) p->u.line.v_speed = 1; } else if (p->type == CNODE) { s = dgap_getword(in); - if (s == NULL) { + if (!s) { dgap_err("unexpected end of file"); return -1; } @@ -6946,7 +6946,7 @@ static int dgap_parsefile(char **in, int remove) } p = p->next; s = dgap_getword(in); - if (s == NULL) { + if (!s) { dgap_err("unexpected end of file"); return -1; } @@ -6966,7 +6966,7 @@ static int dgap_parsefile(char **in, int remove) } p = p->next; s = dgap_getword(in); - if (s == NULL) { + if (!s) { dgap_err("unexpected end of file"); return -1; } @@ -6986,7 +6986,7 @@ static int dgap_parsefile(char **in, int remove) } p = p->next; s = dgap_getword(in); - if (s == NULL) { + if (!s) { dgap_err("unexpected end of file"); return -1; } @@ -7006,7 +7006,7 @@ static int dgap_parsefile(char **in, int remove) } p = p->next; s = dgap_getword(in); - if (s == NULL) { + if (!s) { dgap_err("unexpected end of file"); return -1; } @@ -7026,7 +7026,7 @@ static int dgap_parsefile(char **in, int remove) } p = p->next; s = dgap_getword(in); - if (s == NULL) { + if (!s) { dgap_err("unexpected end of file"); return -1; } @@ -7046,7 +7046,7 @@ static int dgap_parsefile(char **in, int remove) } p = p->next; s = dgap_getword(in); - if (s == NULL) { + if (!s) { dgap_err("unexpected end of file"); return -1; } @@ -7066,7 +7066,7 @@ static int dgap_parsefile(char **in, int remove) } p = p->next; s = dgap_getword(in); - if (s == NULL) { + if (!s) { dgap_err("unexpected end of file"); return -1; } @@ -7086,7 +7086,7 @@ static int dgap_parsefile(char **in, int remove) } p = p->next; s = dgap_getword(in); - if (s == NULL) { + if (!s) { dgap_err("unexpected end of file"); return -1; } @@ -7106,7 +7106,7 @@ static int dgap_parsefile(char **in, int remove) } p = p->next; s = dgap_getword(in); - if (s == NULL) { + if (!s) { dgap_err("unexpected end of file"); return -1; } -- cgit v1.2.3 From 0be048cbc66e0cc98e9578769afede9fe103806b Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 28 May 2014 16:17:55 -0400 Subject: staging: dgap: Simplify dgap_find_config Simplify ugly dgap_find_config function Signed-off-by: Mark Hounschell Tested-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 84 +++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 7912d9865e22..09e247855c91 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -7354,51 +7354,53 @@ static struct cnode *dgap_find_config(int type, int bus, int slot) prev = p; p = p->next; - if (p->type == BNODE) { + if (p->type != BNODE) + continue; - if (p->u.board.type == type) { + if (p->u.board.type != type) + continue; - if (p->u.board.v_pcibus && - p->u.board.pcibus != bus) - continue; - if (p->u.board.v_pcislot && - p->u.board.pcislot != slot) - continue; + if (p->u.board.v_pcibus && + p->u.board.pcibus != bus) + continue; - found = p; - /* - * Keep walking thru the list till we - * find the next board. - */ - while (p->next) { - prev2 = p; - p = p->next; - if (p->type == BNODE) { - - /* - * Mark the end of our 1 board - * chain of configs. - */ - prev2->next = NULL; - - /* - * Link the "next" board to the - * previous board, effectively - * "unlinking" our board from - * the main config. - */ - prev->next = p; - - return found; - } - } - /* - * It must be the last board in the list. - */ - prev->next = NULL; - return found; - } + if (p->u.board.v_pcislot && + p->u.board.pcislot != slot) + continue; + + found = p; + /* + * Keep walking thru the list till we + * find the next board. + */ + while (p->next) { + prev2 = p; + p = p->next; + + if (p->type != BNODE) + continue; + + /* + * Mark the end of our 1 board + * chain of configs. + */ + prev2->next = NULL; + + /* + * Link the "next" board to the + * previous board, effectively + * "unlinking" our board from + * the main config. + */ + prev->next = p; + + return found; } + /* + * It must be the last board in the list. + */ + prev->next = NULL; + return found; } return NULL; } -- cgit v1.2.3 From 6d488a0c780346f5b0a7f7bd41cd347deb2952b2 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Wed, 28 May 2014 16:18:03 -0400 Subject: staging: dgap: Use EIO instead of ENXIO Replaces ENXIO with EIO errno Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 09e247855c91..48c13c949724 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -975,7 +975,7 @@ static int dgap_firmware_load(struct pci_dev *pdev, int card_type) static int dgap_do_remap(struct board_t *brd) { if (!brd || brd->magic != DGAP_BOARD_MAGIC) - return -ENXIO; + return -EIO; if (!request_mem_region(brd->membase, 0x200000, "dgap")) return -ENOMEM; @@ -1329,7 +1329,7 @@ static int dgap_tty_init(struct board_t *brd) struct cm_t __iomem *cm; if (!brd) - return -ENXIO; + return -EIO; /* * Initialize board structure elements. @@ -1367,7 +1367,7 @@ static int dgap_tty_init(struct board_t *brd) if (!brd->nasync) { brd->state = BOARD_FAILED; brd->dpastatus = BD_NOFEP; - return -ENXIO; + return -EIO; } } @@ -1873,12 +1873,12 @@ static int dgap_tty_open(struct tty_struct *tty, struct file *file) minor = MINOR(tty_devnum(tty)); if (major > 255) - return -ENXIO; + return -EIO; /* Get board pointer from our array of majors we have allocated */ brd = dgap_boards_by_major[major]; if (!brd) - return -ENXIO; + return -EIO; /* * If board is not yet up to a state of READY, go to @@ -1895,19 +1895,19 @@ static int dgap_tty_open(struct tty_struct *tty, struct file *file) /* The wait above should guarantee this cannot happen */ if (brd->state != BOARD_READY) { spin_unlock_irqrestore(&brd->bd_lock, lock_flags); - return -ENXIO; + return -EIO; } /* If opened device is greater than our number of ports, bail. */ if (MINOR(tty_devnum(tty)) > brd->nasync) { spin_unlock_irqrestore(&brd->bd_lock, lock_flags); - return -ENXIO; + return -EIO; } ch = brd->channels[minor]; if (!ch) { spin_unlock_irqrestore(&brd->bd_lock, lock_flags); - return -ENXIO; + return -EIO; } /* Grab channel lock */ @@ -1923,7 +1923,7 @@ static int dgap_tty_open(struct tty_struct *tty, struct file *file) } else { spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); spin_unlock_irqrestore(&brd->bd_lock, lock_flags); - return -ENXIO; + return -EIO; } /* Store our unit into driver_data, so we always have it available. */ @@ -1936,7 +1936,7 @@ static int dgap_tty_open(struct tty_struct *tty, struct file *file) if (!bs) { spin_unlock_irqrestore(&ch->ch_lock, lock_flags2); spin_unlock_irqrestore(&brd->bd_lock, lock_flags); - return -ENXIO; + return -EIO; } /* @@ -2021,11 +2021,11 @@ static int dgap_block_til_ready(struct tty_struct *tty, struct file *file, if (!tty || tty->magic != TTY_MAGIC || !file || !ch || ch->magic != DGAP_CHANNEL_MAGIC) - return -ENXIO; + return -EIO; un = tty->driver_data; if (!un || un->magic != DGAP_UNIT_MAGIC) - return -ENXIO; + return -EIO; spin_lock_irqsave(&ch->ch_lock, lock_flags); @@ -2041,7 +2041,7 @@ static int dgap_block_til_ready(struct tty_struct *tty, struct file *file, * bail with error. */ if (ch->ch_bd->state == BOARD_FAILED) { - retval = -ENXIO; + retval = -EIO; break; } @@ -3029,7 +3029,7 @@ static int dgap_get_modem_info(struct channel_t *ch, unsigned int __user *value) int rc; if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return -ENXIO; + return -EIO; spin_lock_irqsave(&ch->ch_lock, lock_flags); @@ -5007,23 +5007,23 @@ static int dgap_param(struct tty_struct *tty) u8 hflow; if (!tty || tty->magic != TTY_MAGIC) - return -ENXIO; + return -EIO; un = (struct un_t *) tty->driver_data; if (!un || un->magic != DGAP_UNIT_MAGIC) - return -ENXIO; + return -EIO; ch = un->un_ch; if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) - return -ENXIO; + return -EIO; bd = ch->ch_bd; if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return -ENXIO; + return -EIO; bs = ch->ch_bs; if (!bs) - return -ENXIO; + return -EIO; ts = &tty->termios; @@ -5462,7 +5462,7 @@ static int dgap_event(struct board_t *bd) int b1; if (!bd || bd->magic != DGAP_BOARD_MAGIC) - return -ENXIO; + return -EIO; spin_lock_irqsave(&bd->bd_lock, lock_flags); @@ -5470,7 +5470,7 @@ static int dgap_event(struct board_t *bd) if (!vaddr) { spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - return -ENXIO; + return -EIO; } eaddr = (struct ev_t __iomem *) (vaddr + EVBUF); @@ -5487,7 +5487,7 @@ static int dgap_event(struct board_t *bd) (head | tail) & 03) { /* Let go of board lock */ spin_unlock_irqrestore(&bd->bd_lock, lock_flags); - return -ENXIO; + return -EIO; } /* -- cgit v1.2.3 From 47b0c98db487c5fdb55a7b9e44513052f7a3e7e1 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 28 May 2014 17:36:24 +0530 Subject: staging: rtl8723au: Remove redundant casting in rtw_mlme.c Casting value returned by k[cmz]alloc is useless. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 547986ac0102..7170258d2601 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -1824,8 +1824,7 @@ int rtw_set_auth23a(struct rtw_adapter * adapter, goto exit; } - psetauthparm = (struct setauth_parm*) - kzalloc(sizeof(struct setauth_parm), GFP_KERNEL); + psetauthparm = kzalloc(sizeof(struct setauth_parm), GFP_KERNEL); if (!psetauthparm) { kfree(pcmd); res = _FAIL; @@ -1866,7 +1865,7 @@ int rtw_set_key23a(struct rtw_adapter *adapter, goto exit; } - pcmd = (struct cmd_obj *)kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); + pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (!pcmd) { res = _FAIL; /* try again */ goto exit; -- cgit v1.2.3 From 7b20f7b353445bb16eaf6474397fcd221a5dee88 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 28 May 2014 17:36:25 +0530 Subject: staging: rtl8723au: Remove redundant casting in rtw_recv.c Casting value returned by k[cmz]alloc is useless. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_recv.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index f21aa20b9372..690970efc22f 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -58,8 +58,7 @@ int _rtw_init_recv_priv23a(struct recv_priv *precvpriv, precvpriv->adapter = padapter; for (i = 0; i < NR_RECVFRAME ; i++) { - precvframe = (struct recv_frame *) - kzalloc(sizeof(struct recv_frame), GFP_KERNEL); + precvframe = kzalloc(sizeof(struct recv_frame), GFP_KERNEL); if (!precvframe) break; INIT_LIST_HEAD(&precvframe->list); -- cgit v1.2.3 From 8f17a38c61a5954353c02bba8fc6537cd33e5dbe Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 28 May 2014 17:36:26 +0530 Subject: staging: rtl8723au: Remove redundant casting in rtw_sta_mgt.c Casting value returned by k[cmz]alloc is useless. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_sta_mgt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c index b829c2eb0c5a..14a82bea826f 100644 --- a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c @@ -116,7 +116,7 @@ rtw_alloc_stainfo23a(struct sta_priv *pstapriv, u8 *hwaddr, gfp_t gfp) int i = 0; u16 wRxSeqInitialValue = 0xffff; - psta = (struct sta_info *)kmalloc(sizeof(struct sta_info), gfp); + psta = kmalloc(sizeof(struct sta_info), gfp); if (!psta) return NULL; -- cgit v1.2.3 From e1a35432cde3cf805194ab685d294fd6ff9a0d87 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 28 May 2014 17:36:27 +0530 Subject: staging: rtl8723au: Remove redundant casting in rtw_wlan_util.c Casting value returned by k[cmz]alloc is useless. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 256385c2f382..579a4a8c8276 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -919,8 +919,7 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, return true; } - bssid = (struct wlan_bssid_ex *)kzalloc(sizeof(struct wlan_bssid_ex), - GFP_ATOMIC); + bssid = kzalloc(sizeof(struct wlan_bssid_ex), GFP_ATOMIC); if (!bssid) return _FAIL; -- cgit v1.2.3 From 4947f5e4e9b4aac23f79c7cd0b7307ada0e5d49c Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 28 May 2014 17:36:28 +0530 Subject: staging: rtl8723au: Remove redundant casting in rtw_xmit.c Casting value returned by k[cmz]alloc is useless. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index d0dc6386d237..b917526f570a 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -77,8 +77,7 @@ int _rtw_init_xmit_priv23a(struct xmit_priv *pxmitpriv, _rtw_init_queue23a(&pxmitpriv->free_xmit_queue); for (i = 0; i < NR_XMITFRAME; i++) { - pxframe = (struct xmit_frame *) - kzalloc(sizeof(struct xmit_frame), GFP_KERNEL); + pxframe = kzalloc(sizeof(struct xmit_frame), GFP_KERNEL); if (!pxframe) break; INIT_LIST_HEAD(&pxframe->list); @@ -127,8 +126,7 @@ int _rtw_init_xmit_priv23a(struct xmit_priv *pxmitpriv, _rtw_init_queue23a(&pxmitpriv->free_xframe_ext_queue); for (i = 0; i < num_xmit_extbuf; i++) { - pxframe = (struct xmit_frame *) - kzalloc(sizeof(struct xmit_frame), GFP_KERNEL); + pxframe = kzalloc(sizeof(struct xmit_frame), GFP_KERNEL); if (!pxframe) break; INIT_LIST_HEAD(&pxframe->list); -- cgit v1.2.3 From 2e69759c149ccdb8785db56f3bf59f588b434619 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 28 May 2014 17:36:29 +0530 Subject: staging: rtl8723au: Remove redundant casting in rtl8723a_hal_init.c Casting value returned by k[cmz]alloc is useless. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 487629c198ff..0acacab95a48 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -489,7 +489,7 @@ hal_ReadEFuse_WiFi(struct rtw_adapter *padapter, return; } - efuseTbl = (u8 *) kmalloc(EFUSE_MAP_LEN_8723A, GFP_KERNEL); + efuseTbl = kmalloc(EFUSE_MAP_LEN_8723A, GFP_KERNEL); if (efuseTbl == NULL) { DBG_8723A("%s: alloc efuseTbl fail!\n", __func__); return; -- cgit v1.2.3 From f9de4a30a5e647bff71509d6f5d419f6967ba291 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 28 May 2014 17:36:30 +0530 Subject: staging: rtl8723au: Remove redundant casting in usb_ops_linux.c Casting value returned by k[cmz]alloc is useless. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_ops_linux.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c b/drivers/staging/rtl8723au/hal/usb_ops_linux.c index 4ba6b47e6f5b..8e9e61c74bd0 100644 --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c @@ -382,8 +382,7 @@ static void usb_read_interrupt_complete(struct urb *purb) struct evt_work *c2w; int res; - c2w = (struct evt_work *) - kmalloc(sizeof(struct evt_work), + c2w = kmalloc(sizeof(struct evt_work), GFP_ATOMIC); if (!c2w) { -- cgit v1.2.3 From 792407484a09b455064722c5190b45e1e1f2cecd Mon Sep 17 00:00:00 2001 From: Heesub Shin Date: Wed, 28 May 2014 15:52:52 +0900 Subject: staging: ion: tidy up a bit For aesthetics and readability, rename goto labels, remove useless code lines, and clarify function return type. Signed-off-by: Heesub Shin Reviewed-by: Mitchel Humpherys Tested-by: John Stultz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion_page_pool.c | 2 +- drivers/staging/android/ion/ion_priv.h | 2 +- drivers/staging/android/ion/ion_system_heap.c | 57 ++++++++++++--------------- 3 files changed, 28 insertions(+), 33 deletions(-) diff --git a/drivers/staging/android/ion/ion_page_pool.c b/drivers/staging/android/ion/ion_page_pool.c index ecb5fc34ec5c..ead405458c75 100644 --- a/drivers/staging/android/ion/ion_page_pool.c +++ b/drivers/staging/android/ion/ion_page_pool.c @@ -89,7 +89,7 @@ static struct page *ion_page_pool_remove(struct ion_page_pool *pool, bool high) return page; } -void *ion_page_pool_alloc(struct ion_page_pool *pool) +struct page *ion_page_pool_alloc(struct ion_page_pool *pool) { struct page *page = NULL; diff --git a/drivers/staging/android/ion/ion_priv.h b/drivers/staging/android/ion/ion_priv.h index c2dc942418bf..c8f01757abfa 100644 --- a/drivers/staging/android/ion/ion_priv.h +++ b/drivers/staging/android/ion/ion_priv.h @@ -378,7 +378,7 @@ struct ion_page_pool { struct ion_page_pool *ion_page_pool_create(gfp_t gfp_mask, unsigned int order); void ion_page_pool_destroy(struct ion_page_pool *); -void *ion_page_pool_alloc(struct ion_page_pool *); +struct page *ion_page_pool_alloc(struct ion_page_pool *); void ion_page_pool_free(struct ion_page_pool *, struct page *); /** ion_page_pool_shrink - shrinks the size of the memory cached in the pool diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c index a14499514eb6..ae3c9ed59b09 100644 --- a/drivers/staging/android/ion/ion_system_heap.c +++ b/drivers/staging/android/ion/ion_system_heap.c @@ -42,7 +42,7 @@ static int order_to_index(unsigned int order) return -1; } -static unsigned int order_to_size(int order) +static inline unsigned int order_to_size(int order) { return PAGE_SIZE << order; } @@ -79,8 +79,6 @@ static struct page *alloc_buffer_page(struct ion_system_heap *heap, ion_pages_sync_for_device(NULL, page, PAGE_SIZE << order, DMA_BIDIRECTIONAL); } - if (!page) - return NULL; return page; } @@ -126,7 +124,6 @@ static struct page_info *alloc_largest_available(struct ion_system_heap *heap, info->page = page; info->order = orders[i]; - INIT_LIST_HEAD(&info->list); return info; } kfree(info); @@ -144,7 +141,6 @@ static int ion_system_heap_allocate(struct ion_heap *heap, heap); struct sg_table *table; struct scatterlist *sg; - int ret; struct list_head pages; struct page_info *info, *tmp_info; int i = 0; @@ -162,24 +158,23 @@ static int ion_system_heap_allocate(struct ion_heap *heap, info = alloc_largest_available(sys_heap, buffer, size_remaining, max_order); if (!info) - goto err; + goto free_pages; list_add_tail(&info->list, &pages); - size_remaining -= (1 << info->order) * PAGE_SIZE; + size_remaining -= PAGE_SIZE << info->order; max_order = info->order; i++; } table = kmalloc(sizeof(struct sg_table), GFP_KERNEL); if (!table) - goto err; + goto free_pages; - ret = sg_alloc_table(table, i, GFP_KERNEL); - if (ret) - goto err1; + if (sg_alloc_table(table, i, GFP_KERNEL)) + goto free_table; sg = table->sgl; list_for_each_entry_safe(info, tmp_info, &pages, list) { struct page *page = info->page; - sg_set_page(sg, page, (1 << info->order) * PAGE_SIZE, 0); + sg_set_page(sg, page, PAGE_SIZE << info->order, 0); sg = sg_next(sg); list_del(&info->list); kfree(info); @@ -187,9 +182,10 @@ static int ion_system_heap_allocate(struct ion_heap *heap, buffer->priv_virt = table; return 0; -err1: + +free_table: kfree(table); -err: +free_pages: list_for_each_entry_safe(info, tmp_info, &pages, list) { free_buffer_page(sys_heap, buffer, info->page, info->order); kfree(info); @@ -199,14 +195,12 @@ err: static void ion_system_heap_free(struct ion_buffer *buffer) { - struct ion_heap *heap = buffer->heap; - struct ion_system_heap *sys_heap = container_of(heap, + struct ion_system_heap *sys_heap = container_of(buffer->heap, struct ion_system_heap, heap); struct sg_table *table = buffer->sg_table; bool cached = ion_buffer_cached(buffer); struct scatterlist *sg; - LIST_HEAD(pages); int i; /* uncached pages come from the page pools, zero them before returning @@ -276,10 +270,10 @@ static int ion_system_heap_debug_show(struct ion_heap *heap, struct seq_file *s, seq_printf(s, "%d order %u highmem pages in pool = %lu total\n", pool->high_count, pool->order, - (1 << pool->order) * PAGE_SIZE * pool->high_count); + (PAGE_SIZE << pool->order) * pool->high_count); seq_printf(s, "%d order %u lowmem pages in pool = %lu total\n", pool->low_count, pool->order, - (1 << pool->order) * PAGE_SIZE * pool->low_count); + (PAGE_SIZE << pool->order) * pool->low_count); } return 0; } @@ -298,7 +292,7 @@ struct ion_heap *ion_system_heap_create(struct ion_platform_heap *unused) heap->pools = kzalloc(sizeof(struct ion_page_pool *) * num_orders, GFP_KERNEL); if (!heap->pools) - goto err_alloc_pools; + goto free_heap; for (i = 0; i < num_orders; i++) { struct ion_page_pool *pool; gfp_t gfp_flags = low_order_gfp_flags; @@ -307,18 +301,18 @@ struct ion_heap *ion_system_heap_create(struct ion_platform_heap *unused) gfp_flags = high_order_gfp_flags; pool = ion_page_pool_create(gfp_flags, orders[i]); if (!pool) - goto err_create_pool; + goto destroy_pools; heap->pools[i] = pool; } heap->heap.debug_show = ion_system_heap_debug_show; return &heap->heap; -err_create_pool: - for (i = 0; i < num_orders; i++) - if (heap->pools[i]) - ion_page_pool_destroy(heap->pools[i]); + +destroy_pools: + while (i--) + ion_page_pool_destroy(heap->pools[i]); kfree(heap->pools); -err_alloc_pools: +free_heap: kfree(heap); return ERR_PTR(-ENOMEM); } @@ -364,12 +358,12 @@ static int ion_system_contig_heap_allocate(struct ion_heap *heap, table = kmalloc(sizeof(struct sg_table), GFP_KERNEL); if (!table) { ret = -ENOMEM; - goto out; + goto free_pages; } ret = sg_alloc_table(table, 1, GFP_KERNEL); if (ret) - goto out; + goto free_table; sg_set_page(table->sgl, page, len, 0); @@ -379,10 +373,12 @@ static int ion_system_contig_heap_allocate(struct ion_heap *heap, return 0; -out: +free_table: + kfree(table); +free_pages: for (i = 0; i < len >> PAGE_SHIFT; i++) __free_page(page + i); - kfree(table); + return ret; } @@ -448,4 +444,3 @@ void ion_system_contig_heap_destroy(struct ion_heap *heap) { kfree(heap); } - -- cgit v1.2.3 From 80cb77dc6310a72002f6cb8255316c5aaea78807 Mon Sep 17 00:00:00 2001 From: Heesub Shin Date: Wed, 28 May 2014 15:52:53 +0900 Subject: staging: ion: simplify ion_page_pool_total() ion_page_pool_total() returns the total number of pages in the pool. Depending on the argument passed, it counts highmem pages in or not. This commit simplifies the code lines for better readability. Signed-off-by: Heesub Shin Reviewed-by: Mitchel Humpherys Tested-by: John Stultz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion_page_pool.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/android/ion/ion_page_pool.c b/drivers/staging/android/ion/ion_page_pool.c index ead405458c75..168478077cb8 100644 --- a/drivers/staging/android/ion/ion_page_pool.c +++ b/drivers/staging/android/ion/ion_page_pool.c @@ -119,12 +119,12 @@ void ion_page_pool_free(struct ion_page_pool *pool, struct page *page) static int ion_page_pool_total(struct ion_page_pool *pool, bool high) { - int total = 0; + int count = pool->low_count; - total += high ? (pool->high_count + pool->low_count) * - (1 << pool->order) : - pool->low_count * (1 << pool->order); - return total; + if (high) + count += pool->high_count; + + return count << pool->order; } int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask, -- cgit v1.2.3 From 38c003b113ceab37f80d020999d3ec2cbf784da3 Mon Sep 17 00:00:00 2001 From: Heesub Shin Date: Wed, 28 May 2014 15:52:54 +0900 Subject: staging: ion: remove struct ion_page_pool_item The page pool uses an internal data structure, ion_page_pool_item, for wrapping pooled pages and constructing a list. As the struct page already provides ways for doing exactly the same thing, we do not need to reinvent the wheel. This commit removes the data structure and slab allocations for it. Signed-off-by: Heesub Shin Reviewed-by: Mitchel Humpherys Tested-by: John Stultz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion_page_pool.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/drivers/staging/android/ion/ion_page_pool.c b/drivers/staging/android/ion/ion_page_pool.c index 168478077cb8..111777c6e25a 100644 --- a/drivers/staging/android/ion/ion_page_pool.c +++ b/drivers/staging/android/ion/ion_page_pool.c @@ -23,11 +23,6 @@ #include #include "ion_priv.h" -struct ion_page_pool_item { - struct page *page; - struct list_head list; -}; - static void *ion_page_pool_alloc_pages(struct ion_page_pool *pool) { struct page *page = alloc_pages(pool->gfp_mask, pool->order); @@ -47,19 +42,12 @@ static void ion_page_pool_free_pages(struct ion_page_pool *pool, static int ion_page_pool_add(struct ion_page_pool *pool, struct page *page) { - struct ion_page_pool_item *item; - - item = kmalloc(sizeof(struct ion_page_pool_item), GFP_KERNEL); - if (!item) - return -ENOMEM; - mutex_lock(&pool->mutex); - item->page = page; if (PageHighMem(page)) { - list_add_tail(&item->list, &pool->high_items); + list_add_tail(&page->lru, &pool->high_items); pool->high_count++; } else { - list_add_tail(&item->list, &pool->low_items); + list_add_tail(&page->lru, &pool->low_items); pool->low_count++; } mutex_unlock(&pool->mutex); @@ -68,24 +56,19 @@ static int ion_page_pool_add(struct ion_page_pool *pool, struct page *page) static struct page *ion_page_pool_remove(struct ion_page_pool *pool, bool high) { - struct ion_page_pool_item *item; struct page *page; if (high) { BUG_ON(!pool->high_count); - item = list_first_entry(&pool->high_items, - struct ion_page_pool_item, list); + page = list_first_entry(&pool->high_items, struct page, lru); pool->high_count--; } else { BUG_ON(!pool->low_count); - item = list_first_entry(&pool->low_items, - struct ion_page_pool_item, list); + page = list_first_entry(&pool->low_items, struct page, lru); pool->low_count--; } - list_del(&item->list); - page = item->page; - kfree(item); + list_del(&page->lru); return page; } -- cgit v1.2.3 From bdeb9f1c4276864e97a725c8c0a8bc9a8686edfe Mon Sep 17 00:00:00 2001 From: Heesub Shin Date: Wed, 28 May 2014 15:52:55 +0900 Subject: staging: ion: use compound pages on high order pages for system heap Using compound pages relieves burden on tracking the meta information which are currently stored in page_info. Signed-off-by: Heesub Shin Reviewed-by: Mitchel Humpherys Tested-by: John Stultz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion_page_pool.c | 4 +++- drivers/staging/android/ion/ion_system_heap.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/android/ion/ion_page_pool.c b/drivers/staging/android/ion/ion_page_pool.c index 111777c6e25a..c1cea42b0510 100644 --- a/drivers/staging/android/ion/ion_page_pool.c +++ b/drivers/staging/android/ion/ion_page_pool.c @@ -95,6 +95,8 @@ void ion_page_pool_free(struct ion_page_pool *pool, struct page *page) { int ret; + BUG_ON(pool->order != compound_order(page)); + ret = ion_page_pool_add(pool, page); if (ret) ion_page_pool_free_pages(pool, page); @@ -150,7 +152,7 @@ struct ion_page_pool *ion_page_pool_create(gfp_t gfp_mask, unsigned int order) pool->low_count = 0; INIT_LIST_HEAD(&pool->low_items); INIT_LIST_HEAD(&pool->high_items); - pool->gfp_mask = gfp_mask; + pool->gfp_mask = gfp_mask | __GFP_COMP; pool->order = order; mutex_init(&pool->mutex); plist_node_init(&pool->list, order); diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c index ae3c9ed59b09..cb7ae08a5e24 100644 --- a/drivers/staging/android/ion/ion_system_heap.c +++ b/drivers/staging/android/ion/ion_system_heap.c @@ -73,7 +73,7 @@ static struct page *alloc_buffer_page(struct ion_system_heap *heap, if (order > 4) gfp_flags = high_order_gfp_flags; - page = alloc_pages(gfp_flags, order); + page = alloc_pages(gfp_flags | __GFP_COMP, order); if (!page) return NULL; ion_pages_sync_for_device(NULL, page, PAGE_SIZE << order, -- cgit v1.2.3 From 0cd2dc4db3ba23ff8ab38b8ae81b126626f795d5 Mon Sep 17 00:00:00 2001 From: Heesub Shin Date: Wed, 28 May 2014 15:52:59 +0900 Subject: staging: ion: shrink highmem pages on kswapd ION system heap keeps pages in its pool for better performance. When the system is under memory pressure, slab shrinker calls the callback registered and then the pages pooled get freed. When the shrinker is called, it checks gfp_mask and determines whether the pages from highmem need to be freed or the pages from lowmem. Usually, slab shrinker is invoked on kswapd context which gfp_mask is always GFP_KERNEL, so only lowmem pages are released on kswapd context. This means that highmem pages in the pool are never reclaimed until direct reclaim occurs. This can be problematic when the page pool holds excessive amounts of highmem. For now, the shrinker callback cannot know exactly which zone should be targeted for reclamation, as enough information are not passed to. Thus, it makes sense to shrink both lowmem and highmem zone on kswapd context. Reported-by: Wonseo Choi Signed-off-by: Heesub Shin Reviewed-by: Mitchel Humpherys Tested-by: John Stultz Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion_page_pool.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/staging/android/ion/ion_page_pool.c b/drivers/staging/android/ion/ion_page_pool.c index c1cea42b0510..5864f3dfcbc6 100644 --- a/drivers/staging/android/ion/ion_page_pool.c +++ b/drivers/staging/android/ion/ion_page_pool.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "ion_priv.h" static void *ion_page_pool_alloc_pages(struct ion_page_pool *pool) @@ -118,7 +119,10 @@ int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask, int freed; bool high; - high = !!(gfp_mask & __GFP_HIGHMEM); + if (current_is_kswapd()) + high = 1; + else + high = !!(gfp_mask & __GFP_HIGHMEM); if (nr_to_scan == 0) return ion_page_pool_total(pool, high); -- cgit v1.2.3 From e00b8fdca8c04eb39bd2ff8a68c7154135e4e179 Mon Sep 17 00:00:00 2001 From: Chaitanya Hazarey Date: Wed, 28 May 2014 16:23:47 -0700 Subject: Staging: rtl8192u: r8192U_wx.c Fixed a misplaced brace Fixed a misplaced brace in a function Signed-off-by: Chaitanya Hazarey Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_wx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192u/r8192U_wx.c b/drivers/staging/rtl8192u/r8192U_wx.c index 1af7c5d5bb55..675a12d6aa8c 100644 --- a/drivers/staging/rtl8192u/r8192U_wx.c +++ b/drivers/staging/rtl8192u/r8192U_wx.c @@ -616,7 +616,8 @@ static int r8192_wx_set_enc(struct net_device *dev, static int r8192_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, - union iwreq_data *wrqu, char *p){ + union iwreq_data *wrqu, char *p) +{ struct r8192_priv *priv = ieee80211_priv(dev); int *parms = (int *)p; -- cgit v1.2.3 From aec46bbdeab172a2129ef4e64051e706cbe9ec56 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 29 May 2014 13:59:03 -0700 Subject: Revert "staging: dgap: remove unneeded kfree() in dgap_tty_register_ports()" This reverts commit 0ade4a34fd439d62df46937e8f3e584eb0879579 as it was wrong. Cc: Dan Carpenter Cc: Daeseok Youn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 48c13c949724..170d6f3e4221 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -4145,8 +4145,10 @@ static int dgap_tty_register_ports(struct board_t *brd) brd->printer_ports = kcalloc(brd->nasync, sizeof(*brd->printer_ports), GFP_KERNEL); - if (!brd->printer_ports) + if (!brd->printer_ports) { + kfree(brd->serial_ports); return -ENOMEM; + } for (i = 0; i < brd->nasync; i++) { tty_port_init(&brd->serial_ports[i]); -- cgit v1.2.3 From 5bcfab136078d02e8ad990bffcb76d150be83dd9 Mon Sep 17 00:00:00 2001 From: Alexandr Terekhov Date: Sat, 31 May 2014 18:20:39 +0300 Subject: staging: lustre: fix integer as NULL pointer warnings Fix several sparse warnings "Using plain integer as NULL pointer" Signed-off-by: Alexandr Terekhov drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 4 ++-- drivers/staging/lustre/lustre/obdclass/obd_mount.c | 4 ++-- drivers/staging/lustre/lustre/obdecho/lproc_echo.c | 4 ++-- drivers/staging/lustre/lustre/osc/osc_dev.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/import.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 4 ++-- drivers/staging/lustre/lustre/obdclass/obd_mount.c | 4 ++-- drivers/staging/lustre/lustre/obdecho/lproc_echo.c | 4 ++-- drivers/staging/lustre/lustre/osc/osc_dev.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/import.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index a4cec5e63ce0..c55d72f79b26 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -89,7 +89,7 @@ int ldlm_proc_setup(void) { int rc; struct lprocfs_vars list[] = { - { "dump_namespaces", &ldlm_dump_ns_fops, 0, 0222 }, + { "dump_namespaces", &ldlm_dump_ns_fops, NULL, 0222 }, { "dump_granted_max", &ldlm_rw_uint_fops, &ldlm_dump_granted_max }, { "cancel_unused_locks_before_replay", &ldlm_rw_uint_fops, @@ -322,7 +322,7 @@ void ldlm_namespace_proc_unregister(struct ldlm_namespace *ns) snprintf(lock_name, MAX_STRING_SIZE, name); \ lock_vars[0].data = var; \ lock_vars[0].fops = ops; \ - lprocfs_add_vars(ns_pde, lock_vars, 0); \ + lprocfs_add_vars(ns_pde, lock_vars, NULL); \ } while (0) int ldlm_namespace_proc_register(struct ldlm_namespace *ns) diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index 419a32361359..a034aee37fc1 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -383,7 +383,7 @@ int lustre_start_mgc(struct super_block *sb) /* Start the MGC */ rc = lustre_start_simple(mgcname, LUSTRE_MGC_NAME, (char *)uuid->uuid, LUSTRE_MGS_OBDNAME, - niduuid, 0, 0); + niduuid, NULL, NULL); OBD_FREE_PTR(uuid); if (rc) GOTO(out_free, rc); @@ -482,7 +482,7 @@ static int lustre_stop_mgc(struct super_block *sb) { struct lustre_sb_info *lsi = s2lsi(sb); struct obd_device *obd; - char *niduuid = 0, *ptr = 0; + char *niduuid = NULL, *ptr = NULL; int i, rc = 0, len = 0; if (!lsi) diff --git a/drivers/staging/lustre/lustre/obdecho/lproc_echo.c b/drivers/staging/lustre/lustre/obdecho/lproc_echo.c index b9abac1c4dca..8fe9245a8aad 100644 --- a/drivers/staging/lustre/lustre/obdecho/lproc_echo.c +++ b/drivers/staging/lustre/lustre/obdecho/lproc_echo.c @@ -39,13 +39,13 @@ #ifdef LPROCFS LPROC_SEQ_FOPS_RO_TYPE(echo, uuid); static struct lprocfs_vars lprocfs_echo_obd_vars[] = { - { "uuid", &echo_uuid_fops, 0, 0 }, + { "uuid", &echo_uuid_fops, NULL, 0 }, { 0 } }; LPROC_SEQ_FOPS_RO_TYPE(echo, numrefs); static struct lprocfs_vars lprocfs_echo_module_vars[] = { - { "num_refs", &echo_numrefs_fops, 0, 0 }, + { "num_refs", &echo_numrefs_fops, NULL, 0 }, { 0 } }; diff --git a/drivers/staging/lustre/lustre/osc/osc_dev.c b/drivers/staging/lustre/lustre/osc/osc_dev.c index 6a6483920c4d..a7c1ec0d56fe 100644 --- a/drivers/staging/lustre/lustre/osc/osc_dev.c +++ b/drivers/staging/lustre/lustre/osc/osc_dev.c @@ -193,7 +193,7 @@ static int osc_device_init(const struct lu_env *env, struct lu_device *d, static struct lu_device *osc_device_fini(const struct lu_env *env, struct lu_device *d) { - return 0; + return NULL; } static struct lu_device *osc_device_free(const struct lu_env *env, diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index 1c73194421a6..8573f328bd2a 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -645,7 +645,7 @@ int ptlrpc_connect_import(struct obd_import *imp) if (rc) GOTO(out, rc); - rc = sptlrpc_import_sec_adapt(imp, NULL, 0); + rc = sptlrpc_import_sec_adapt(imp, NULL, NULL); if (rc) GOTO(out, rc); -- cgit v1.2.3 From 57bab7cb353d71c10611c34571fcb3c9f38b4792 Mon Sep 17 00:00:00 2001 From: Tair Rzayev Date: Sat, 31 May 2014 22:43:34 +0300 Subject: staging: android: binder.c: Use more appropriate functions for euid retrieval Instead of getting the reference to whole credential structure, use task_euid() and current_euid() to get it. Signed-off-by: Tair Rzayev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/binder.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c index e8dd7ddcba41..989f809f323f 100644 --- a/drivers/staging/android/binder.c +++ b/drivers/staging/android/binder.c @@ -1326,7 +1326,6 @@ static void binder_transaction(struct binder_proc *proc, struct binder_transaction *in_reply_to = NULL; struct binder_transaction_log_entry *e; uint32_t return_error; - const struct cred *cred = __task_cred(proc->tsk); e = binder_transaction_log_add(&binder_transaction_log); e->call_type = reply ? 2 : !!(tr->flags & TF_ONE_WAY); @@ -1468,7 +1467,7 @@ static void binder_transaction(struct binder_proc *proc, t->from = thread; else t->from = NULL; - t->sender_euid = cred->euid; + t->sender_euid = task_euid(proc->tsk); t->to_proc = target_proc; t->to_thread = target_thread; t->code = tr->code; @@ -2602,7 +2601,7 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) struct binder_thread *thread; unsigned int size = _IOC_SIZE(cmd); void __user *ubuf = (void __user *)arg; - const struct cred *cred = current_cred(); + kuid_t curr_euid = current_euid(); /*pr_info("binder_ioctl: %d:%d %x %lx\n", proc->pid, current->pid, cmd, arg);*/ @@ -2688,15 +2687,16 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) goto err; } if (uid_valid(binder_context_mgr_uid)) { - if (!uid_eq(binder_context_mgr_uid, cred->euid)) { + if (!uid_eq(binder_context_mgr_uid, curr_euid)) { pr_err("BINDER_SET_CONTEXT_MGR bad uid %d != %d\n", - from_kuid(&init_user_ns, cred->euid), + from_kuid(&init_user_ns, curr_euid), from_kuid(&init_user_ns, binder_context_mgr_uid)); ret = -EPERM; goto err; } - } else - binder_context_mgr_uid = cred->euid; + } else { + binder_context_mgr_uid = curr_euid; + } binder_context_mgr_node = binder_new_node(proc, 0, 0); if (binder_context_mgr_node == NULL) { ret = -ENOMEM; -- cgit v1.2.3 From 5b39bd5f33bb65f60492441bf6b50d88bc843e1c Mon Sep 17 00:00:00 2001 From: Josep Puigdemont Date: Sun, 1 Jun 2014 20:23:16 +0200 Subject: staging: lustre: Fix coding style The if block should be placed in a new line rather than after the if statement. Blank line required between variable declarations and code. Signed-off-by: Josep Puigdemont Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/llite_nfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c index e0e112b710d7..a614b913ddc2 100644 --- a/drivers/staging/lustre/lustre/llite/llite_nfs.c +++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c @@ -51,7 +51,9 @@ __u32 get_uuid2int(const char *name, int len) __u32 key0 = 0x12a3fe2d, key1 = 0x37abe8f9; while (len--) { __u32 key = key1 + (key0 ^ (*name++ * 7152373)); - if (key & 0x80000000) key -= 0x7fffffff; + + if (key & 0x80000000) + key -= 0x7fffffff; key1 = key0; key0 = key; } -- cgit v1.2.3 From f4d90513c83d8d8e2e33f88c1ccba1db2dc31e72 Mon Sep 17 00:00:00 2001 From: James A Shackleford Date: Sun, 1 Jun 2014 19:34:28 -0400 Subject: staging: silicom: fix sparse warning for static variable This patch fixes the following sparse warning in bpctl_mod.c: warning: symbol 'bpvm_lock' was not declared. Should it be static? Signed-off-by: James A Shackleford Signed-off-by: Greg Kroah-Hartman --- drivers/staging/silicom/bpctl_mod.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/silicom/bpctl_mod.c b/drivers/staging/silicom/bpctl_mod.c index f74b5e711609..765fce84d9dd 100644 --- a/drivers/staging/silicom/bpctl_mod.c +++ b/drivers/staging/silicom/bpctl_mod.c @@ -41,7 +41,7 @@ MODULE_AUTHOR("Anna Lukin, annal@silicom.co.il"); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION(BP_MOD_DESCR); MODULE_VERSION(BP_MOD_VER); -spinlock_t bpvm_lock; +static spinlock_t bpvm_lock; #define unlock_bpctl() \ up(&bpctl_sema); -- cgit v1.2.3 From aeb49155dbc5a9404b1cdcd087132ef959bf666d Mon Sep 17 00:00:00 2001 From: Simon Boulay Date: Sun, 1 Jun 2014 16:57:44 +0200 Subject: staging/mt29f_spinand: coding style fixes This patch fixes coding style errors reported by checkpatch.pl. It adds new lines after declarations in two places. Signed-off-by: Simon Boulay Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt29f_spinand/mt29f_spinand.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/mt29f_spinand/mt29f_spinand.c b/drivers/staging/mt29f_spinand/mt29f_spinand.c index 5a40925680ac..3464e0c521e6 100644 --- a/drivers/staging/mt29f_spinand/mt29f_spinand.c +++ b/drivers/staging/mt29f_spinand/mt29f_spinand.c @@ -699,6 +699,7 @@ static void spinand_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) { struct spinand_state *state = mtd_to_state(mtd); + memcpy(state->buf + state->buf_ptr, buf, len); state->buf_ptr += len; } @@ -706,6 +707,7 @@ static void spinand_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) static void spinand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) { struct spinand_state *state = mtd_to_state(mtd); + memcpy(buf, state->buf + state->buf_ptr, len); state->buf_ptr += len; } -- cgit v1.2.3 From 7eb843aa5050a395bc922db1b41b7237f238d2ba Mon Sep 17 00:00:00 2001 From: James A Shackleford Date: Sun, 1 Jun 2014 19:52:49 -0400 Subject: staging: skein: fix sparse warning for static declarations This patch fixes the following sparse warnings: skein_block.c:43:6: warning: symbol 'skein_256_process_block' was not declared. Should it be static? skein_block.c:252:6: warning: symbol 'skein_512_process_block' was not declared. Should it be static? skein_block.c:483:6: warning: symbol 'skein_1024_process_block' was not declared. Should it be static? by including the header skein_block.h, which contains the declarations in question. Signed-off-by: James A Shackleford Signed-off-by: Greg Kroah-Hartman --- drivers/staging/skein/skein_block.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/skein/skein_block.c b/drivers/staging/skein/skein_block.c index f49eb2e9e5af..04ce1d005479 100644 --- a/drivers/staging/skein/skein_block.c +++ b/drivers/staging/skein/skein_block.c @@ -16,6 +16,7 @@ #include #include "skein.h" +#include "skein_block.h" #ifndef SKEIN_USE_ASM #define SKEIN_USE_ASM (0) /* default is all C code (no ASM) */ -- cgit v1.2.3